sane-backends-1.0.29/0000755000000000000000000000000013615535555011265 500000000000000sane-backends-1.0.29/configure0000755000000000000000000335676513615534566013146 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for sane-backends 1.0.29. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: sane-devel@alioth-lists.debian.net about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='sane-backends' PACKAGE_TARNAME='sane-backends' PACKAGE_VERSION='1.0.29' PACKAGE_STRING='sane-backends 1.0.29' PACKAGE_BUGREPORT='sane-devel@alioth-lists.debian.net' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" gt_needs= ac_config_libobj_dir=lib ac_header_list= ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS AM_LDFLAGS AM_CXXFLAGS AM_CFLAGS AM_CPPFLAGS WITH_API_HTML_FALSE WITH_API_HTML_TRUE WITH_API_PDF_FALSE WITH_API_PDF_TRUE WITH_API_PS_FALSE WITH_API_PS_TRUE PPMTOGIF DLH GS FIG2DEV PDFLATEX LATEX DVIPS MAKEINDEX BACKEND_MANS_ENABLED BACKEND_CONFS_ENABLED PRELOADABLE_BACKENDS_ENABLED preloadable_backends_enabled_FALSE preloadable_backends_enabled_TRUE PRELOADABLE_BACKENDS INSTALL_UMAX_PP_TOOLS_FALSE INSTALL_UMAX_PP_TOOLS_TRUE BACKEND_LIBS_ENABLED SANEI_SANEI_JPEG_LO HAVE_JPEG_FALSE HAVE_JPEG_TRUE BACKENDS COMPILE_SANED_FALSE COMPILE_SANED_TRUE configdir locksanedir SCSI_LIBS have_libxml2_FALSE have_libxml2_TRUE XML_LIBS XML_CFLAGS have_libcurl_FALSE have_libcurl_TRUE libcurl_LIBS libcurl_CFLAGS have_usblib_FALSE have_usblib_TRUE USB_LIBS USB_CFLAGS SYSTEMD_LIBS SYSTEMD_CFLAGS SOCKET_LIBS LTALLOCA LIBOBJS ALLOCA RESMGR_LIBS SNMP_CFLAGS SNMP_LIBS SNMP_CONFIG_PATH have_libavahi_FALSE have_libavahi_TRUE AVAHI_LIBS AVAHI_CFLAGS LIBV4L_LIBS LIBV4L_CFLAGS GPHOTO2_LDFLAGS GPHOTO2_LIBS GPHOTO2_CPPFLAGS HAVE_GPHOTO2 LOCKPATH_GROUP INSTALL_LOCKPATH SANEI_THREAD_LIBS PTHREAD_LIBS IEEE1284_LIBS PNG_LIBS TIFF_LIBS JPEG_LIBS SYSLOG_LIBS MATH_LIB DYNAMIC_FLAG DL_LIBS effective_target STRICT_LDFLAGS HAVE_CXX11 CROSS_COMPILING_FALSE CROSS_COMPILING_TRUE PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG SANE_CONFIG_PATH POSUB LTLIBINTL LIBINTL INTLLIBS LTLIBICONV LIBICONV INTL_MACOSX_LIBS XGETTEXT_EXTRA_OPTIONS MSGMERGE XGETTEXT_015 XGETTEXT GMSGFMT_015 MSGFMT_015 GMSGFMT MSGFMT GETTEXT_MACRO_VERSION USE_NLS CXXCPP LT_SYS_LIBRARY_PATH OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP SED host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL OBJDUMP DLLTOOL AS ac_ct_AR AR EGREP GREP CPP am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE ac_ct_CXX CXXFLAGS CXX am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC V_REV V_MINOR V_MAJOR MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL am__quote' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_maintainer_mode enable_dependency_tracking enable_static enable_shared with_pic enable_fast_install with_aix_soname with_gnu_ld with_sysroot enable_libtool_lock enable_nls enable_rpath with_libiconv_prefix with_libintl_prefix enable_warnings enable_dynamic enable_pthread enable_locking with_group with_gphoto2 with_v4l enable_avahi with_snmp with_systemd with_usb with_libcurl with_usb_record_replay enable_scsibuffersize enable_scsi_directio enable_ipv6 enable_preload with_lockdir enable_local_backends enable_pnm_backend enable_parport_directio with_api_spec ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CXX CXXFLAGS CCC CPP LT_SYS_LIBRARY_PATH CXXCPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR LIBV4L_CFLAGS LIBV4L_LIBS AVAHI_CFLAGS AVAHI_LIBS SYSTEMD_CFLAGS SYSTEMD_LIBS USB_CFLAGS USB_LIBS libcurl_CFLAGS libcurl_LIBS XML_CFLAGS XML_LIBS BACKENDS PRELOADABLE_BACKENDS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures sane-backends 1.0.29 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/sane-backends] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of sane-backends 1.0.29:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-static[=PKGS] build static libraries [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-nls do not use Native Language Support --disable-rpath do not hardcode runtime library paths --enable-warnings turn on tons of compiler warnings (GCC only) --disable-dynamic Disable dynamic loading of backends --enable-pthread use pthread instead of fork (default=yes for Linux/MacOS X/MINGW, no for everything else) --enable-locking activate device locking (default=yes, but only used by some backends) --enable-avahi enable Avahi support for saned and the net backend --enable-scsibuffersize=N specify the default size in bytes of the buffer for SCSI commands [default=131072] --enable-scsi-directio enable SCSI direct IO (Linux only, dangerous, see README.linux) --disable-ipv6 disable IPv6 support --disable-preload Disable preloading of backends --disable-local-backends turn off compilation of all backends but net --enable-pnm-backend enable the pnm backend for testing frontends (possible security risk, see PROBLEMS file) --enable-parport-directio enable direct hardware access to the parallel port, so frontends will require special permission level Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX, [default=aix]. --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib --without-libintl-prefix don't search for libintl in includedir and libdir --with-group use the specified group for lock dir [default=uucp] --with-gphoto2 include the gphoto2 backend [default=yes] --with-v4l include the v4l backend [default=yes] --with-snmp enable SNMP support [default=yes] --with-systemd enable systemd support [default=yes] --with-usb enable USB support [default=check] --with-libcurl enable functionality that needs libcurl [default=check] --with-usb-record-replay enable USB record and replay to XML files [default=yes] --with-lockdir=DIR set SANE lockdir [localstatedir/lock/sane] --with-api-spec convert API spec to supported output formats [default=check] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags CPP C preprocessor LT_SYS_LIBRARY_PATH User-defined run-time library search path. CXXCPP C++ preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path LIBV4L_CFLAGS C compiler flags for LIBV4L, overriding pkg-config LIBV4L_LIBS linker flags for LIBV4L, overriding pkg-config AVAHI_CFLAGS C compiler flags for AVAHI, overriding pkg-config AVAHI_LIBS linker flags for AVAHI, overriding pkg-config SYSTEMD_CFLAGS C compiler flags for SYSTEMD, overriding pkg-config SYSTEMD_LIBS linker flags for SYSTEMD, overriding pkg-config USB_CFLAGS C compiler flags for USB, overriding pkg-config USB_LIBS linker flags for USB, overriding pkg-config libcurl_CFLAGS C compiler flags for libcurl, overriding pkg-config libcurl_LIBS linker flags for libcurl, overriding pkg-config XML_CFLAGS C compiler flags for XML, overriding pkg-config XML_LIBS linker flags for XML, overriding pkg-config BACKENDS list of backends to compile PRELOADABLE_BACKENDS list of backends to preload into single DLL Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF sane-backends configure 1.0.29 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------------------------- ## ## Report this to sane-devel@alioth-lists.debian.net ## ## ------------------------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by sane-backends $as_me 1.0.29, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi gt_needs="$gt_needs " as_fn_append ac_header_list " stdlib.h" as_fn_append ac_header_list " unistd.h" as_fn_append ac_header_list " sys/param.h" # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers include/sane/config.h" am__api_version='1.16' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='sane-backends' VERSION='1.0.29' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE if test x = "x$AWK"; then : for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done fi if test x = "x`echo $VERSION | sed 's/[.0-9]//g'`"; then : is_release=yes else is_release=no fi V_MAJOR=`echo $VERSION | $AWK -F. '{print $1}'` V_MINOR=`echo $VERSION | $AWK -F. '{print $2}'` V_REV=`echo $VERSION | $AWK -F. '{print $3}' | sed 's/^\([0-9]*\).*/\1/'`; cat >>confdefs.h <<_ACEOF #define SANE_DLL_V_MAJOR $V_MAJOR _ACEOF cat >>confdefs.h <<_ACEOF #define SANE_DLL_V_MINOR $V_MINOR _ACEOF cat >>confdefs.h <<_ACEOF #define SANE_DLL_V_BUILD $V_REV _ACEOF ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 $as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } case $?:`cat confinc.out 2>/dev/null` in #( '0:this is the am__doit target') : case $s in #( BSD) : am__include='.include' am__quote='"' ;; #( *) : am__include='include' am__quote='' ;; esac ;; #( *) : ;; esac if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 $as_echo "${_am_result}" >&6; } # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi sane_save_CC=$CC { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 $as_echo_n "checking for $CC option to accept ISO C99... " >&6; } if ${ac_cv_prog_cc_c99+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c99=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include #include // Check varargs macros. These examples are taken from C99 6.10.3.5. #define debug(...) fprintf (stderr, __VA_ARGS__) #define showlist(...) puts (#__VA_ARGS__) #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) static void test_varargs_macros (void) { int x = 1234; int y = 5678; debug ("Flag"); debug ("X = %d\n", x); showlist (The first, second, and third items.); report (x>y, "x is %d but y is %d", x, y); } // Check long long types. #define BIG64 18446744073709551615ull #define BIG32 4294967295ul #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) #if !BIG_OK your preprocessor is broken; #endif #if BIG_OK #else your preprocessor is broken; #endif static long long int bignum = -9223372036854775807LL; static unsigned long long int ubignum = BIG64; struct incomplete_array { int datasize; double data[]; }; struct named_init { int number; const wchar_t *name; double average; }; typedef const char *ccp; static inline int test_restrict (ccp restrict text) { // See if C++-style comments work. // Iterate through items via the restricted pointer. // Also check for declarations in for loops. for (unsigned int i = 0; *(text+i) != '\0'; ++i) continue; return 0; } // Check varargs and va_copy. static void test_varargs (const char *format, ...) { va_list args; va_start (args, format); va_list args_copy; va_copy (args_copy, args); const char *str; int number; float fnumber; while (*format) { switch (*format++) { case 's': // string str = va_arg (args_copy, const char *); break; case 'd': // int number = va_arg (args_copy, int); break; case 'f': // float fnumber = va_arg (args_copy, double); break; default: break; } } va_end (args_copy); va_end (args); } int main () { // Check bool. _Bool success = false; // Check restrict. if (test_restrict ("String literal") == 0) success = true; char *restrict newvar = "Another string"; // Check varargs. test_varargs ("s, d' f .", "string", 65, 34.234); test_varargs_macros (); // Check flexible array members. struct incomplete_array *ia = malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); ia->datasize = 10; for (int i = 0; i < ia->datasize; ++i) ia->data[i] = i * 1.234; // Check named initializers. struct named_init ni = { .number = 34, .name = L"Test wide string", .average = 543.34343, }; ni.number = 58; int dynamic_array[ni.number]; dynamic_array[ni.number - 1] = 543; // work around unused variable warnings return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' || dynamic_array[ni.number - 1] != 543); ; return 0; } _ACEOF for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c99=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c99" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c99" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c99" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 $as_echo "$ac_cv_prog_cc_c99" >&6; } ;; esac if test "x$ac_cv_prog_cc_c99" != xno; then : fi if test xno != "x$ac_cv_prog_cc_c99"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $sane_save_CC option for ISO C99 w/o extensions" >&5 $as_echo_n "checking for $sane_save_CC option for ISO C99 w/o extensions... " >&6; } case $ac_cv_prog_cc_c99 in #( -std=gnu99) : sane_prog_cc_c99="-std=c99" ;; #( -qlanglvl=extc99) : sane_prog_cc_c99="-qlanglvl=stdc99" ;; #( *) : ;; esac if test "x$ac_cv_prog_cc_c99" = "x$sane_prog_cc_c99"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_99" >&5 $as_echo "$ac_cv_prog_cc_99" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sane_prog_cc_c99" >&5 $as_echo "$sane_prog_cc_c99" >&6; } CC="$sane_save_CC $sane_prog_cc_c99" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" if test $ac_cv_c_compiler_gnu = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 $as_echo_n "checking whether $CC needs -traditional... " >&6; } if ${ac_cv_prog_gcc_traditional+:} false; then : $as_echo_n "(cached) " >&6 else ac_pattern="Autoconf.*'x'" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 $as_echo "$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" if test "x$ac_cv_header_minix_config_h" = xyes; then : MINIX=yes else MINIX= fi if test "$MINIX" = yes; then $as_echo "#define _POSIX_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h $as_echo "#define _MINIX 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } if ${ac_cv_safe_to_define___extensions__+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # define __EXTENSIONS__ 1 $ac_includes_default int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_define___extensions__=yes else ac_cv_safe_to_define___extensions__=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } test $ac_cv_safe_to_define___extensions__ = yes && $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h $as_echo "#define _ALL_SOURCE 1" >>confdefs.h $as_echo "#define _GNU_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h if test -n "$ac_tool_prefix"; then for ac_prog in ar lib "link -lib" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar lib "link -lib" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} { $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 $as_echo_n "checking the archiver ($AR) interface... " >&6; } if ${am_cv_ar_interface+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am_cv_ar_interface=ar cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int some_variable = 0; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 (eval $am_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then am_cv_ar_interface=ar else am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 (eval $am_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then am_cv_ar_interface=lib else am_cv_ar_interface=unknown fi fi rm -f conftest.lib libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 $as_echo "$am_cv_ar_interface" >&6; } case $am_cv_ar_interface in ar) ;; lib) # Microsoft lib, so override with the ar-lib wrapper script. # FIXME: It is wrong to rewrite AR. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__AR in this case, # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something # similar. AR="$am_aux_dir/ar-lib $AR" ;; unknown) as_fn_error $? "could not determine $AR interface" "$LINENO" 5 ;; esac case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.6' macro_revision='2.4.6' ltmain=$ac_aux_dir/ltmain.sh # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case $ECHO in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n "$lt_cv_sys_max_cmd_len"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi ;; darwin*) if test yes = "$GCC"; then reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5 if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 $as_echo "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 $as_echo_n "checking for a working dd... " >&6; } if ${ac_cv_path_lt_DD+:} false; then : $as_echo_n "(cached) " >&6 else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} if test -z "$lt_DD"; then ac_path_lt_DD_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in dd; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_lt_DD" || continue if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi $ac_path_lt_DD_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_lt_DD"; then : fi else ac_cv_path_lt_DD=$lt_DD fi rm -f conftest.i conftest2.i conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 $as_echo "$ac_cv_path_lt_DD" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 $as_echo_n "checking how to truncate binary pipes... " >&6; } if ${lt_cv_truncate_bin+:} false; then : $as_echo_n "(cached) " >&6 else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 $as_echo "$lt_cv_truncate_bin" >&6; } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[012][,.]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done func_stripname_cnf () { case $2 in .*) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%\\\\$2\$%%"`;; *) func_stripname_result=`$ECHO "$3" | $SED "s%^$1%%; s%$2\$%%"`;; esac } # func_stripname_cnf # Set options # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac else enable_static=no fi enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AS"; then ac_cv_prog_AS="$AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AS="${ac_tool_prefix}as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AS=$ac_cv_prog_AS if test -n "$AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 $as_echo "$AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AS"; then ac_ct_AS=$AS # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AS"; then ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AS="as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AS=$ac_cv_prog_ac_ct_AS if test -n "$ac_ct_AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 $as_echo "$ac_ct_AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AS" = x; then AS="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AS=$ac_ct_AS fi else AS="$ac_cv_prog_AS" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi ;; esac test -z "$AS" && AS=as test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$OBJDUMP" && OBJDUMP=objdump enable_dlopen=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac else enable_shared=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac else pic_mode=default fi # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac else enable_fast_install=yes fi shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[5-9]*,yes) { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 $as_echo_n "checking which variant of shared library versioning to provide... " >&6; } # Check whether --with-aix-soname was given. if test "${with_aix_soname+set}" = set; then : withval=$with_aix_soname; case $withval in aix|svr4|both) ;; *) as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 ;; esac lt_cv_with_aix_soname=$with_aix_soname else if ${lt_cv_with_aix_soname+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_with_aix_soname=aix fi with_aix_soname=$lt_cv_with_aix_soname fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 $as_echo "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o func_cc_basename $compiler cc_basename=$func_cc_basename_result # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/${ac_tool_prefix}file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test yes = "$GCC"; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi lt_prog_compiler_pic='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test no = "$hard_links"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs=yes ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) export_dynamic_flag_spec='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. hardcode_direct=no hardcode_direct_absolute=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' $wl-bernotok' allow_undefined_flag=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test yes = "$GCC"; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi link_all_deplibs=no else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler ld_shlibs=yes archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' else archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes ;; osf3*) if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test yes = "$GCC"; then wlarc='$wl' archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='$wl-z,text' allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen=shl_load else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen=dlopen else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi fi fi fi fi fi ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report what library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC if test -n "$CXX" && ( test no != "$CXX" && ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || (test g++ != "$CXX"))); then ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu else _lt_caught_CXX_error=yes fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu archive_cmds_need_lc_CXX=no allow_undefined_flag_CXX= always_export_symbols_CXX=no archive_expsym_cmds_CXX= compiler_needs_object_CXX=no export_dynamic_flag_spec_CXX= hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no hardcode_libdir_flag_spec_CXX= hardcode_libdir_separator_CXX= hardcode_minus_L_CXX=no hardcode_shlibpath_var_CXX=unsupported hardcode_automatic_CXX=no inherit_rpath_CXX=no module_cmds_CXX= module_expsym_cmds_CXX= link_all_deplibs_CXX=unknown old_archive_cmds_CXX=$old_archive_cmds reload_flag_CXX=$reload_flag reload_cmds_CXX=$reload_cmds no_undefined_flag_CXX= whole_archive_flag_spec_CXX= enable_shared_with_static_runtimes_CXX=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o objext_CXX=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_caught_CXX_error"; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC compiler_CXX=$CC func_cc_basename $compiler cc_basename=$func_cc_basename_result if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test yes = "$GXX"; then lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' else lt_prog_compiler_no_builtin_flag_CXX= fi if test yes = "$GXX"; then # Set up default GNU C++ configuration # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test yes = "$with_gnu_ld"; then archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec_CXX= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds_CXX='' hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes file_list_spec_CXX='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. hardcode_direct_CXX=no hardcode_direct_absolute_CXX=no ;; esac if test yes = "$GXX"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct_CXX=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L_CXX=yes hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_libdir_separator_CXX= fi esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag=$shared_flag' $wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi export_dynamic_flag_spec_CXX='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. always_export_symbols_CXX=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. # The "-G" linker flag allows undefined symbols. no_undefined_flag_CXX='-bernotok' # Determine the default libpath from the value encoded in an empty # executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec_CXX='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag_CXX="-z nodefs" archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath__CXX+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath__CXX fi hardcode_libdir_flag_spec_CXX='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag_CXX=' $wl-bernotok' allow_undefined_flag_CXX=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec_CXX='$convenience' fi archive_cmds_need_lc_CXX=yes archive_expsym_cmds_CXX='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi archive_expsym_cmds_CXX="$archive_expsym_cmds_CXX"'~$RM -r $output_objdir/$realname.d' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag_CXX=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs_CXX=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec_CXX=' ' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=yes file_list_spec_CXX='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds_CXX='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true' enable_shared_with_static_runtimes_CXX=yes # Don't use ranlib old_postinstall_cmds_CXX='chmod 644 $oldlib' postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ func_to_tool_file "$lt_outputfile"~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec_CXX='-L$libdir' export_dynamic_flag_spec_CXX='$wl--export-all-symbols' allow_undefined_flag_CXX=unsupported always_export_symbols_CXX=no enable_shared_with_static_runtimes_CXX=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds_CXX='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs_CXX=no fi ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc_CXX=no hardcode_direct_CXX=no hardcode_automatic_CXX=yes hardcode_shlibpath_var_CXX=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec_CXX='' fi link_all_deplibs_CXX=yes allow_undefined_flag_CXX=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" if test yes != "$lt_cv_apple_cc_single_mod"; then archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi else ld_shlibs_CXX=no fi ;; os2*) hardcode_libdir_flag_spec_CXX='-L$libdir' hardcode_minus_L_CXX=yes allow_undefined_flag_CXX=unsupported shrext_cmds=.dll archive_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds_CXX='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes_CXX=yes ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF ld_shlibs_CXX=no ;; freebsd-elf*) archive_cmds_need_lc_CXX=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes ;; haiku*) archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs_CXX=yes ;; hpux9*) hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir' hardcode_libdir_separator_CXX=: export_dynamic_flag_spec_CXX='$wl-E' hardcode_direct_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; hpux10*|hpux11*) if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec_CXX='$wl+b $wl$libdir' hardcode_libdir_separator_CXX=: case $host_cpu in hppa*64*|ia64*) ;; *) export_dynamic_flag_spec_CXX='$wl-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no ;; *) hardcode_direct_CXX=yes hardcode_direct_absolute_CXX=yes hardcode_minus_L_CXX=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; aCC*) case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds_CXX='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; interix[3-9]*) hardcode_direct_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' export_dynamic_flag_spec_CXX='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' fi fi link_all_deplibs_CXX=yes ;; esac hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' hardcode_libdir_separator_CXX=: inherit_rpath_CXX=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac archive_cmds_need_lc_CXX=no hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' whole_archive_flag_spec_CXX='$wl--whole-archive$convenience $wl--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [1-5].* | *pgcpp\ [1-5].*) prelink_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' old_archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' archive_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='$wl--rpath $wl$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' whole_archive_flag_spec_CXX='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ;; cxx*) # Compaq C++ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec_CXX='-rpath $libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' export_dynamic_flag_spec_CXX='$wl--export-dynamic' archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' hardcode_libdir_flag_spec_CXX='-R$libdir' whole_archive_flag_spec_CXX='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object_CXX=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; m88k*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) ld_shlibs_CXX=yes ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct_CXX=yes hardcode_shlibpath_var_CXX=no hardcode_direct_absolute_CXX=yes archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' export_dynamic_flag_spec_CXX='$wl-E' whole_archive_flag_spec_CXX=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else ld_shlibs_CXX=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' hardcode_libdir_flag_spec_CXX='$wl-rpath,$libdir' hardcode_libdir_separator_CXX=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; cxx*) case $host in osf3*) allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*' archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' ;; *) allow_undefined_flag_CXX=' -expect_unresolved \*' archive_cmds_CXX='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ $RM $lib.exp' hardcode_libdir_flag_spec_CXX='-rpath $libdir' ;; esac hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes,no = "$GXX,$with_gnu_ld"; then allow_undefined_flag_CXX=' $wl-expect_unresolved $wl\*' case $host in osf3*) archive_cmds_CXX='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; *) archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; esac hardcode_libdir_flag_spec_CXX='$wl-rpath $wl$libdir' hardcode_libdir_separator_CXX=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # FIXME: insert proper C++ library support ld_shlibs_CXX=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ archive_cmds_need_lc_CXX=yes no_undefined_flag_CXX=' -zdefs' archive_cmds_CXX='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' hardcode_libdir_flag_spec_CXX='-R$libdir' hardcode_shlibpath_var_CXX=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs_CXX=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test yes,no = "$GXX,$with_gnu_ld"; then no_undefined_flag_CXX=' $wl-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. archive_cmds_CXX='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"' fi hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir' case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) whole_archive_flag_spec_CXX='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag_CXX='$wl-z,text' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag_CXX='$wl-z,text' allow_undefined_flag_CXX='$wl-z,nodefs' archive_cmds_need_lc_CXX=no hardcode_shlibpath_var_CXX=no hardcode_libdir_flag_spec_CXX='$wl-R,$libdir' hardcode_libdir_separator_CXX=':' link_all_deplibs_CXX=yes export_dynamic_flag_spec_CXX='$wl-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) archive_cmds_CXX='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~ '"$old_archive_cmds_CXX" reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~ '"$reload_cmds_CXX" ;; *) archive_cmds_CXX='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds_CXX='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; *) # FIXME: insert proper C++ library support ld_shlibs_CXX=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test no = "$ld_shlibs_CXX" && can_build_shared=no GCC_CXX=$GXX LD_CXX=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... # Dependencies to place before and after the object being linked: predep_objects_CXX= postdep_objects_CXX= predeps_CXX= postdeps_CXX= compiler_lib_search_path_CXX= cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $prev$p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test x-L = "$p" || test x-R = "$p"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test no = "$pre_test_object_deps_done"; then case $prev in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$compiler_lib_search_path_CXX"; then compiler_lib_search_path_CXX=$prev$p else compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} $prev$p" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$postdeps_CXX"; then postdeps_CXX=$prev$p else postdeps_CXX="${postdeps_CXX} $prev$p" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test no = "$pre_test_object_deps_done"; then if test -z "$predep_objects_CXX"; then predep_objects_CXX=$p else predep_objects_CXX="$predep_objects_CXX $p" fi else if test -z "$postdep_objects_CXX"; then postdep_objects_CXX=$p else postdep_objects_CXX="$postdep_objects_CXX $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling CXX test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken case $host_os in interix[3-9]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. predep_objects_CXX= postdep_objects_CXX= postdeps_CXX= ;; esac case " $postdeps_CXX " in *" -lc "*) archive_cmds_need_lc_CXX=no ;; esac compiler_lib_search_dirs_CXX= if test -n "${compiler_lib_search_path_CXX}"; then compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | $SED -e 's! -L! !g' -e 's!^ !!'` fi lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= # C++ specific cases for pic, static, wl, etc. if test yes = "$GXX"; then lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' fi lt_prog_compiler_pic_CXX='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic_CXX='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic_CXX='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static_CXX='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic_CXX='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all lt_prog_compiler_pic_CXX= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static_CXX= ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic_CXX=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; *) lt_prog_compiler_pic_CXX='-fPIC' ;; esac else case $host_os in aix[4-9]*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static_CXX='-Bstatic' else lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_CXX='-DDLL_EXPORT' ;; dgux*) case $cc_basename in ec++*) lt_prog_compiler_pic_CXX='-KPIC' ;; ghcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='$wl-a ${wl}archive' if test ia64 != "$host_cpu"; then lt_prog_compiler_pic_CXX='+Z' fi ;; aCC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='$wl-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic_CXX='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_static_CXX='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler lt_prog_compiler_wl_CXX='--backend -Wl,' lt_prog_compiler_pic_CXX='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64, which still supported -KPIC. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fPIC' lt_prog_compiler_static_CXX='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-fpic' lt_prog_compiler_static_CXX='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; xlc* | xlC* | bgxl[cC]* | mpixl[cC]*) # IBM XL 8.0, 9.0 on PPC and BlueGene lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-qpic' lt_prog_compiler_static_CXX='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) lt_prog_compiler_pic_CXX='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic_CXX='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) lt_prog_compiler_wl_CXX='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 lt_prog_compiler_pic_CXX='-pic' ;; cxx*) # Digital/Compaq C++ lt_prog_compiler_wl_CXX='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' lt_prog_compiler_wl_CXX='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler lt_prog_compiler_pic_CXX='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x lt_prog_compiler_pic_CXX='-pic' lt_prog_compiler_static_CXX='-Bstatic' ;; lcc*) # Lucid lt_prog_compiler_pic_CXX='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) lt_prog_compiler_wl_CXX='-Wl,' lt_prog_compiler_pic_CXX='-KPIC' lt_prog_compiler_static_CXX='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 lt_prog_compiler_pic_CXX='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) lt_prog_compiler_can_build_shared_CXX=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic_CXX= ;; *) lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works_CXX=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then case $lt_prog_compiler_pic_CXX in "" | " "*) ;; *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; esac else lt_prog_compiler_pic_CXX= lt_prog_compiler_can_build_shared_CXX=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works_CXX=yes fi else lt_cv_prog_compiler_static_works_CXX=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 $as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then : else lt_prog_compiler_static_CXX= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o_CXX=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test no = "$hard_links"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' case $host_os in aix[4-9]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) export_symbols_cmds_CXX=$ltdll_cmds ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' ;; esac ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs_CXX=no ;; *) export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 $as_echo "$ld_shlibs_CXX" >&6; } test no = "$ld_shlibs_CXX" && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc_CXX" in x|xyes) # Assume -lc should be added archive_cmds_need_lc_CXX=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds_CXX in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl_CXX pic_flag=$lt_prog_compiler_pic_CXX compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc_CXX=no else lt_cv_archive_cmds_need_lc_CXX=yes fi allow_undefined_flag_CXX=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 $as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec_CXX='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || test yes = "$hardcode_automatic_CXX"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct_CXX" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" && test no != "$hardcode_minus_L_CXX"; then # Linking always hardcodes the temporary library directory. hardcode_action_CXX=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action_CXX=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action_CXX=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 $as_echo "$hardcode_action_CXX" >&6; } if test relink = "$hardcode_action_CXX" || test yes = "$inherit_rpath_CXX"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test yes != "$_lt_caught_CXX_error" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_commands="$ac_config_commands libtool" # Only expand once: { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 $as_echo_n "checking whether NLS is requested... " >&6; } # Check whether --enable-nls was given. if test "${enable_nls+set}" = set; then : enableval=$enable_nls; USE_NLS=$enableval else USE_NLS=yes fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 $as_echo "$USE_NLS" >&6; } GETTEXT_MACRO_VERSION=0.19 # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MSGFMT+:} false; then : $as_echo_n "(cached) " >&6 else case "$MSGFMT" in [\\/]* | ?:[\\/]*) ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 && (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" ;; esac fi MSGFMT="$ac_cv_path_MSGFMT" if test "$MSGFMT" != ":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 $as_echo "$MSGFMT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GMSGFMT+:} false; then : $as_echo_n "(cached) " >&6 else case $GMSGFMT in [\\/]* | ?:[\\/]*) ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" ;; esac fi GMSGFMT=$ac_cv_path_GMSGFMT if test -n "$GMSGFMT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 $as_echo "$GMSGFMT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; *) MSGFMT_015=$MSGFMT ;; esac case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; *) GMSGFMT_015=$GMSGFMT ;; esac # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_XGETTEXT+:} false; then : $as_echo_n "(cached) " >&6 else case "$XGETTEXT" in [\\/]* | ?:[\\/]*) ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 && (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" ;; esac fi XGETTEXT="$ac_cv_path_XGETTEXT" if test "$XGETTEXT" != ":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 $as_echo "$XGETTEXT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f messages.po case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; *) XGETTEXT_015=$XGETTEXT ;; esac # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi # Find out how to test for executable files. Don't use a zero-byte file, # as systems may use methods other than mode bits to determine executability. cat >conf$$.file <<_ASEOF #! /bin/sh exit 0 _ASEOF chmod +x conf$$.file if test -x conf$$.file >/dev/null 2>&1; then ac_executable_p="test -x" else ac_executable_p="test -f" fi rm -f conf$$.file # Extract the first word of "msgmerge", so it can be a program name with args. set dummy msgmerge; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MSGMERGE+:} false; then : $as_echo_n "(cached) " >&6 else case "$MSGMERGE" in [\\/]* | ?:[\\/]*) ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. ;; *) ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$ac_save_IFS" test -z "$ac_dir" && ac_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then echo "$as_me: trying $ac_dir/$ac_word..." >&5 if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" break 2 fi fi done done IFS="$ac_save_IFS" test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" ;; esac fi MSGMERGE="$ac_cv_path_MSGMERGE" if test "$MSGMERGE" != ":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 $as_echo "$MSGMERGE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$localedir" || localedir='${datadir}/locale' test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= ac_config_commands="$ac_config_commands po-directories" if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${acl_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$acl_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${acl_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$acl_cv_prog_gnu_ld" >&6; } with_gnu_ld=$acl_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 $as_echo_n "checking for shared library run path origin... " >&6; } if ${acl_cv_rpath+:} false; then : $as_echo_n "(cached) " >&6 else CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 $as_echo "$acl_cv_rpath" >&6; } wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" # Check whether --enable-rpath was given. if test "${enable_rpath+set}" = set; then : enableval=$enable_rpath; : else enable_rpath=yes fi acl_libdirstem=lib acl_libdirstem2= case "$host_os" in solaris*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 $as_echo_n "checking for 64-bit host... " >&6; } if ${gl_cv_solaris_64bit+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _LP64 sixtyfour bits #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "sixtyfour bits" >/dev/null 2>&1; then : gl_cv_solaris_64bit=yes else gl_cv_solaris_64bit=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 $as_echo "$gl_cv_solaris_64bit" >&6; } if test $gl_cv_solaris_64bit = yes; then acl_libdirstem=lib/64 case "$host_cpu" in sparc*) acl_libdirstem2=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; esac fi ;; *) searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libiconv-prefix was given. if test "${with_libiconv_prefix+set}" = set; then : withval=$with_libiconv_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBICONV= LTLIBICONV= INCICONV= LIBICONV_PREFIX= HAVE_LIBICONV= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='iconv ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" else LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'iconv'; then LIBICONV_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'iconv'; then LIBICONV_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" ;; esac done fi else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFPreferencesCopyAppValue" >&5 $as_echo_n "checking for CFPreferencesCopyAppValue... " >&6; } if ${gt_cv_func_CFPreferencesCopyAppValue+:} false; then : $as_echo_n "(cached) " >&6 else gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { CFPreferencesCopyAppValue(NULL, NULL) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gt_cv_func_CFPreferencesCopyAppValue=yes else gt_cv_func_CFPreferencesCopyAppValue=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$gt_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 $as_echo "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then $as_echo "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5 $as_echo_n "checking for CFLocaleCopyCurrent... " >&6; } if ${gt_cv_func_CFLocaleCopyCurrent+:} false; then : $as_echo_n "(cached) " >&6 else gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { CFLocaleCopyCurrent(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : gt_cv_func_CFLocaleCopyCurrent=yes else gt_cv_func_CFLocaleCopyCurrent=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$gt_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 $as_echo "$gt_cv_func_CFLocaleCopyCurrent" >&6; } if test $gt_cv_func_CFLocaleCopyCurrent = yes; then $as_echo "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h fi INTL_MACOSX_LIBS= if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" fi LIBINTL= LTLIBINTL= POSUB= case " $gt_needs " in *" need-formatstring-macros "*) gt_api_version=3 ;; *" need-ngettext "*) gt_api_version=2 ;; *) gt_api_version=1 ;; esac gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" if test "$USE_NLS" = "yes"; then gt_use_preinstalled_gnugettext=no if test $gt_api_version -ge 3; then gt_revision_test_code=' #ifndef __GNU_GETTEXT_SUPPORTED_REVISION #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) #endif typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; ' else gt_revision_test_code= fi if test $gt_api_version -ge 2; then gt_expression_test_code=' + * ngettext ("", "", 0)' else gt_expression_test_code= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libc" >&5 $as_echo_n "checking for GNU gettext in libc... " >&6; } if eval \${$gt_func_gnugettext_libc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION extern int _nl_msg_cat_cntr; extern int *_nl_domain_bindings; #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) #else #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 #endif $gt_revision_test_code int main () { bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$gt_func_gnugettext_libc=yes" else eval "$gt_func_gnugettext_libc=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$gt_func_gnugettext_libc { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then am_save_CPPFLAGS="$CPPFLAGS" for element in $INCICONV; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if ${am_cv_func_iconv+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_lib_iconv=yes am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$am_save_LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 $as_echo "$am_cv_func_iconv" >&6; } if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 $as_echo_n "checking for working iconv... " >&6; } if ${am_cv_func_iconv_works+:} false; then : $as_echo_n "(cached) " >&6 else am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi am_cv_func_iconv_works=no for ac_iconv_const in '' 'const'; do if test "$cross_compiling" = yes; then : case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef ICONV_CONST # define ICONV_CONST $ac_iconv_const #endif int main () { int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 1; iconv_close (cd_utf8_to_88591); } } /* Test against Solaris 10 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\263"; char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 2; iconv_close (cd_ascii_to_88591); } } /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ { iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304"; static char buf[2] = { (char)0xDE, (char)0xAD }; ICONV_CONST char *inptr = input; size_t inbytesleft = 1; char *outptr = buf; size_t outbytesleft = 1; size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) result |= 4; iconv_close (cd_88591_to_utf8); } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) result |= 8; iconv_close (cd_88591_to_utf8); } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) result |= 16; return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : am_cv_func_iconv_works=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi test "$am_cv_func_iconv_works" = no || break done LIBS="$am_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 $as_echo "$am_cv_func_iconv_works" >&6; } case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libintl-prefix was given. if test "${with_libintl_prefix+set}" = set; then : withval=$with_libintl_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBINTL= LTLIBINTL= INCINTL= LIBINTL_PREFIX= HAVE_LIBINTL= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='intl ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" else LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a" else LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'intl'; then LIBINTL_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'intl'; then LIBINTL_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBINTL; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBINTL="${LIBINTL}${LIBINTL:+ }$dep" LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep" ;; esac done fi else LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir" done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libintl" >&5 $as_echo_n "checking for GNU gettext in libintl... " >&6; } if eval \${$gt_func_gnugettext_libintl+:} false; then : $as_echo_n "(cached) " >&6 else gt_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $INCINTL" gt_save_LIBS="$LIBS" LIBS="$LIBS $LIBINTL" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *); #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) #else #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 #endif $gt_revision_test_code int main () { bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$gt_func_gnugettext_libintl=yes" else eval "$gt_func_gnugettext_libintl=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then LIBS="$LIBS $LIBICONV" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif const char *_nl_expand_alias (const char *); #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) #else #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 #endif $gt_revision_test_code int main () { bindtextdomain ("", ""); return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : LIBINTL="$LIBINTL $LIBICONV" LTLIBINTL="$LTLIBINTL $LTLIBICONV" eval "$gt_func_gnugettext_libintl=yes" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi CPPFLAGS="$gt_save_CPPFLAGS" LIBS="$gt_save_LIBS" fi eval ac_res=\$$gt_func_gnugettext_libintl { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ && test "$PACKAGE" != gettext-runtime \ && test "$PACKAGE" != gettext-tools; }; then gt_use_preinstalled_gnugettext=yes else LIBINTL= LTLIBINTL= INCINTL= fi if test -n "$INTL_MACOSX_LIBS"; then if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" fi fi if test "$gt_use_preinstalled_gnugettext" = "yes" \ || test "$nls_cv_use_gnu_gettext" = "yes"; then $as_echo "#define ENABLE_NLS 1" >>confdefs.h else USE_NLS=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use NLS" >&5 $as_echo_n "checking whether to use NLS... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 $as_echo "$USE_NLS" >&6; } if test "$USE_NLS" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking where the gettext function comes from" >&5 $as_echo_n "checking where the gettext function comes from... " >&6; } if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then gt_source="external libintl" else gt_source="libc" fi else gt_source="included intl directory" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_source" >&5 $as_echo "$gt_source" >&6; } fi if test "$USE_NLS" = "yes"; then if test "$gt_use_preinstalled_gnugettext" = "yes"; then if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libintl" >&5 $as_echo_n "checking how to link with libintl... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBINTL" >&5 $as_echo "$LIBINTL" >&6; } for element in $INCINTL; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done fi $as_echo "#define HAVE_GETTEXT 1" >>confdefs.h $as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h fi POSUB=po fi INTLLIBS="$LIBINTL" # Extract the first word of "sane-config", so it can be a program name with args. set dummy sane-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_SANE_CONFIG_PATH+:} false; then : $as_echo_n "(cached) " >&6 else case $SANE_CONFIG_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_SANE_CONFIG_PATH="$SANE_CONFIG_PATH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_SANE_CONFIG_PATH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SANE_CONFIG_PATH" && ac_cv_path_SANE_CONFIG_PATH="no" ;; esac fi SANE_CONFIG_PATH=$ac_cv_path_SANE_CONFIG_PATH if test -n "$SANE_CONFIG_PATH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SANE_CONFIG_PATH" >&5 $as_echo "$SANE_CONFIG_PATH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi if test x$cross_compiling = xyes; then CROSS_COMPILING_TRUE= CROSS_COMPILING_FALSE='#' else CROSS_COMPILING_TRUE='#' CROSS_COMPILING_FALSE= fi if test "${ac_cv_c_compiler_gnu}" = "yes"; then DEFAULT_WARNINGS="\ -Wall" EXTRA_WARNINGS="\ -Wextra \ -pedantic" for flag in $DEFAULT_WARNINGS; do case "$AM_CFLAGS" in "$flag" | "$flag "* | *" $flag" | *" $flag "* ) : ;; *) AM_CFLAGS="$AM_CFLAGS $flag" ;; esac case "$AM_CXXFLAGS" in "$flag" | "$flag "* | *" $flag" | *" $flag "* ) : ;; *) AM_CXXFLAGS="$AM_CXXFLAGS $flag" ;; esac done # Check whether --enable-warnings was given. if test "${enable_warnings+set}" = set; then : enableval=$enable_warnings; if eval "test x$enable_warnings = xyes"; then for flag in $EXTRA_WARNINGS; do case "$AM_CFLAGS" in "$flag" | "$flag "* | *" $flag" | *" $flag "* ) : ;; *) AM_CFLAGS="$AM_CFLAGS $flag" ;; esac case "$AM_CXXFLAGS" in "$flag" | "$flag "* | *" $flag" | *" $flag "* ) : ;; *) AM_CXXFLAGS="$AM_CXXFLAGS $flag" ;; esac done fi else if test x$is_release = xno; then # Warnings enabled by default (development) for flag in $EXTRA_WARNINGS; do case "$AM_CFLAGS" in "$flag" | "$flag "* | *" $flag" | *" $flag "* ) : ;; *) AM_CFLAGS="$AM_CFLAGS $flag" ;; esac case "$AM_CXXFLAGS" in "$flag" | "$flag "* | *" $flag" | *" $flag "* ) : ;; *) AM_CXXFLAGS="$AM_CXXFLAGS $flag" ;; esac done fi fi fi # ac_cv_c_compiler_gnu ax_cxx_compile_alternatives="11 0x" ax_cxx_compile_cxx11_required=false ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_success=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 $as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } if ${ax_cv_cxx_compile_cxx11+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ // If the compiler admits that it is not ready for C++11, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201103L #error "This is not a C++11 compiler" #else namespace cxx11 { namespace test_static_assert { template struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; } namespace test_final_override { struct Base { virtual void f() {} }; struct Derived : public Base { virtual void f() override {} }; } namespace test_double_right_angle_brackets { template < typename T > struct check {}; typedef check single_type; typedef check> double_type; typedef check>> triple_type; typedef check>>> quadruple_type; } namespace test_decltype { int f() { int a = 1; decltype(a) b = 2; return a + b; } } namespace test_type_deduction { template < typename T1, typename T2 > struct is_same { static const bool value = false; }; template < typename T > struct is_same { static const bool value = true; }; template < typename T1, typename T2 > auto add(T1 a1, T2 a2) -> decltype(a1 + a2) { return a1 + a2; } int test(const int c, volatile int v) { static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); static_assert(is_same::value == false, ""); auto ac = c; auto av = v; auto sumi = ac + av + 'x'; auto sumf = ac + av + 1.0; static_assert(is_same::value == true, ""); static_assert(is_same::value == true, ""); static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); static_assert(is_same::value == true, ""); return (sumf > 0.0) ? sumi : add(c, v); } } namespace test_noexcept { int f() { return 0; } int g() noexcept { return 0; } static_assert(noexcept(f()) == false, ""); static_assert(noexcept(g()) == true, ""); } namespace test_constexpr { template < typename CharT > unsigned long constexpr strlen_c_r(const CharT *const s, const unsigned long acc) noexcept { return *s ? strlen_c_r(s + 1, acc + 1) : acc; } template < typename CharT > unsigned long constexpr strlen_c(const CharT *const s) noexcept { return strlen_c_r(s, 0UL); } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("1") == 1UL, ""); static_assert(strlen_c("example") == 7UL, ""); static_assert(strlen_c("another\0example") == 7UL, ""); } namespace test_rvalue_references { template < int N > struct answer { static constexpr int value = N; }; answer<1> f(int&) { return answer<1>(); } answer<2> f(const int&) { return answer<2>(); } answer<3> f(int&&) { return answer<3>(); } void test() { int i = 0; const int c = 0; static_assert(decltype(f(i))::value == 1, ""); static_assert(decltype(f(c))::value == 2, ""); static_assert(decltype(f(0))::value == 3, ""); } } namespace test_uniform_initialization { struct test { static const int zero {}; static const int one {1}; }; static_assert(test::zero == 0, ""); static_assert(test::one == 1, ""); } namespace test_lambdas { void test1() { auto lambda1 = [](){}; auto lambda2 = lambda1; lambda1(); lambda2(); } int test2() { auto a = [](int i, int j){ return i + j; }(1, 2); auto b = []() -> int { return '0'; }(); auto c = [=](){ return a + b; }(); auto d = [&](){ return c; }(); auto e = [a, &b](int x) mutable { const auto identity = [](int y){ return y; }; for (auto i = 0; i < a; ++i) a += b--; return x + identity(a + b); }(0); return a + b + c + d + e; } int test3() { const auto nullary = [](){ return 0; }; const auto unary = [](int x){ return x; }; using nullary_t = decltype(nullary); using unary_t = decltype(unary); const auto higher1st = [](nullary_t f){ return f(); }; const auto higher2nd = [unary](nullary_t f1){ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; }; return higher1st(nullary) + higher2nd(nullary)(unary); } } namespace test_variadic_templates { template struct sum; template struct sum { static constexpr auto value = N0 + sum::value; }; template <> struct sum<> { static constexpr auto value = 0; }; static_assert(sum<>::value == 0, ""); static_assert(sum<1>::value == 1, ""); static_assert(sum<23>::value == 23, ""); static_assert(sum<1, 2>::value == 3, ""); static_assert(sum<5, 5, 11>::value == 21, ""); static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); } // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function // because of this. namespace test_template_alias_sfinae { struct foo {}; template using member = typename T::member_type; template void func(...) {} template void func(member*) {} void test(); void test() { func(0); } } } // namespace cxx11 #endif // __cplusplus >= 201103L _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ax_cv_cxx_compile_cxx11=yes else ax_cv_cxx_compile_cxx11=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 $as_echo "$ax_cv_cxx_compile_cxx11" >&6; } if test x$ax_cv_cxx_compile_cxx11 = xyes; then ac_success=yes fi if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 $as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } if eval \${$cachevar+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_CXX="$CXX" CXX="$CXX $switch" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ // If the compiler admits that it is not ready for C++11, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201103L #error "This is not a C++11 compiler" #else namespace cxx11 { namespace test_static_assert { template struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; } namespace test_final_override { struct Base { virtual void f() {} }; struct Derived : public Base { virtual void f() override {} }; } namespace test_double_right_angle_brackets { template < typename T > struct check {}; typedef check single_type; typedef check> double_type; typedef check>> triple_type; typedef check>>> quadruple_type; } namespace test_decltype { int f() { int a = 1; decltype(a) b = 2; return a + b; } } namespace test_type_deduction { template < typename T1, typename T2 > struct is_same { static const bool value = false; }; template < typename T > struct is_same { static const bool value = true; }; template < typename T1, typename T2 > auto add(T1 a1, T2 a2) -> decltype(a1 + a2) { return a1 + a2; } int test(const int c, volatile int v) { static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); static_assert(is_same::value == false, ""); auto ac = c; auto av = v; auto sumi = ac + av + 'x'; auto sumf = ac + av + 1.0; static_assert(is_same::value == true, ""); static_assert(is_same::value == true, ""); static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); static_assert(is_same::value == true, ""); return (sumf > 0.0) ? sumi : add(c, v); } } namespace test_noexcept { int f() { return 0; } int g() noexcept { return 0; } static_assert(noexcept(f()) == false, ""); static_assert(noexcept(g()) == true, ""); } namespace test_constexpr { template < typename CharT > unsigned long constexpr strlen_c_r(const CharT *const s, const unsigned long acc) noexcept { return *s ? strlen_c_r(s + 1, acc + 1) : acc; } template < typename CharT > unsigned long constexpr strlen_c(const CharT *const s) noexcept { return strlen_c_r(s, 0UL); } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("1") == 1UL, ""); static_assert(strlen_c("example") == 7UL, ""); static_assert(strlen_c("another\0example") == 7UL, ""); } namespace test_rvalue_references { template < int N > struct answer { static constexpr int value = N; }; answer<1> f(int&) { return answer<1>(); } answer<2> f(const int&) { return answer<2>(); } answer<3> f(int&&) { return answer<3>(); } void test() { int i = 0; const int c = 0; static_assert(decltype(f(i))::value == 1, ""); static_assert(decltype(f(c))::value == 2, ""); static_assert(decltype(f(0))::value == 3, ""); } } namespace test_uniform_initialization { struct test { static const int zero {}; static const int one {1}; }; static_assert(test::zero == 0, ""); static_assert(test::one == 1, ""); } namespace test_lambdas { void test1() { auto lambda1 = [](){}; auto lambda2 = lambda1; lambda1(); lambda2(); } int test2() { auto a = [](int i, int j){ return i + j; }(1, 2); auto b = []() -> int { return '0'; }(); auto c = [=](){ return a + b; }(); auto d = [&](){ return c; }(); auto e = [a, &b](int x) mutable { const auto identity = [](int y){ return y; }; for (auto i = 0; i < a; ++i) a += b--; return x + identity(a + b); }(0); return a + b + c + d + e; } int test3() { const auto nullary = [](){ return 0; }; const auto unary = [](int x){ return x; }; using nullary_t = decltype(nullary); using unary_t = decltype(unary); const auto higher1st = [](nullary_t f){ return f(); }; const auto higher2nd = [unary](nullary_t f1){ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; }; return higher1st(nullary) + higher2nd(nullary)(unary); } } namespace test_variadic_templates { template struct sum; template struct sum { static constexpr auto value = N0 + sum::value; }; template <> struct sum<> { static constexpr auto value = 0; }; static_assert(sum<>::value == 0, ""); static_assert(sum<1>::value == 1, ""); static_assert(sum<23>::value == 23, ""); static_assert(sum<1, 2>::value == 3, ""); static_assert(sum<5, 5, 11>::value == 21, ""); static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); } // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function // because of this. namespace test_template_alias_sfinae { struct foo {}; template using member = typename T::member_type; template void func(...) {} template void func(member*) {} void test(); void test() { func(0); } } } // namespace cxx11 #endif // __cplusplus >= 201103L _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval $cachevar=yes else eval $cachevar=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CXX="$ac_save_CXX" fi eval ac_res=\$$cachevar { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done if test x$ac_success = xyes; then break fi done fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test x$ax_cxx_compile_cxx11_required = xtrue; then if test x$ac_success = xno; then as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 fi fi if test x$ac_success = xno; then HAVE_CXX11=0 { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 $as_echo "$as_me: No compiler with C++11 support was found" >&6;} else HAVE_CXX11=1 $as_echo "#define HAVE_CXX11 1" >>confdefs.h fi # Define stricter linking policy on GNU systems. This is not # added to global LDFLAGS because we may want to create convenience # libraries that don't require such strick linking. if test "$GCC" = yes; then case ${host_os} in linux* | solaris*) STRICT_LDFLAGS="-Wl,-z,defs" ;; esac fi case "${host_os}" in aix*) #enable .so libraries, disable archives AM_LDFLAGS="$AM_LDFLAGS -Wl,-brtl" ;; darwin*) #include frameworks LIBS="$LIBS -framework CoreFoundation -framework IOKit" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5 $as_echo_n "checking for library containing strerror... " >&6; } if ${ac_cv_search_strerror+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char strerror (); int main () { return strerror (); ; return 0; } _ACEOF for ac_lib in '' cposix; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_strerror=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_strerror+:} false; then : break fi done if ${ac_cv_search_strerror+:} false; then : else ac_cv_search_strerror=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5 $as_echo "$ac_cv_search_strerror" >&6; } ac_res=$ac_cv_search_strerror if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi ac_byteorder_h=`echo include/byteorder.h` ac_dir=`echo $ac_byteorder_h|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_byteorder" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi # We're only interested in the target CPU, but it's not always set effective_target="$target" if test "x$effective_target" = xNONE -o "x$effective_target" = x ; then effective_target="$host" fi ac_byteorder=_byteorder.tmp cat > "$ac_byteorder" << EOF /* This file is generated automatically by configure */ /* It is valid only for the system type ${effective_target} */ #ifndef __BYTEORDER_H #define __BYTEORDER_H EOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for le32toh in machine/endian.h" >&5 $as_echo_n "checking for le32toh in machine/endian.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef le32toh symbol is present #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "symbol is present|\" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } HAVE_LE32TOH=1 cat >> "$ac_byteorder" << EOF /* extended byte swapping macros are already available */ #include EOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ntohl in arpa/inet.h" >&5 $as_echo_n "checking for ntohl in arpa/inet.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef ntohl symbol is present #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "symbol is present|\" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >> "$ac_byteorder" << EOF /* ntohl and relatives live here */ #include EOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ntohl in netinet/in.h" >&5 $as_echo_n "checking for ntohl in netinet/in.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef ntohl symbol is present #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "symbol is present|\" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >> "$ac_byteorder" << EOF /* ntohl and relatives live here */ #include EOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } true fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* { $as_echo "$as_me:${as_lineno-$LINENO}: checking for swap32 in machine/endian.h" >&5 $as_echo_n "checking for swap32 in machine/endian.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef swap32 symbol is present #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "symbol is present|\" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >> "$ac_byteorder" << EOF /* swap32 and swap16 are defined in machine/endian.h */ EOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bswap_32 in byteswap.h" >&5 $as_echo_n "checking for bswap_32 in byteswap.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef bswap_32 symbol is present #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "symbol is present|\" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >> "$ac_byteorder" << EOF /* Define generic byte swapping functions */ #include #define swap16(x) bswap_16(x) #define swap32(x) bswap_32(x) #define swap64(x) bswap_64(x) EOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bswap32 in machine/endian.h" >&5 $as_echo_n "checking for bswap32 in machine/endian.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef bswap32 symbol is present #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "symbol is present|\" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >> "$ac_byteorder" << EOF /* Define generic byte swapping functions */ EOF if test "$HAVE_LE32TOH" != "1"; then echo '#include '>> "$ac_byteorder" fi cat >> "$ac_byteorder" << EOF #define swap16(x) bswap16(x) #define swap32(x) bswap32(x) #define swap64(x) bswap64(x) EOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __byte_swap_long in sys/types.h" >&5 $as_echo_n "checking for __byte_swap_long in sys/types.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef __byte_swap_long symbol is present #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "symbol is present|\<__byte_swap_long\>" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >> "$ac_byteorder" << EOF /* Define generic byte swapping functions */ #include #define swap16(x) __byte_swap_word(x) #define swap32(x) __byte_swap_long(x) /* No optimized 64 bit byte swapping macro is available */ #define swap64(x) ((uint64_t)(((uint64_t)(x) << 56) & 0xff00000000000000ULL | \\ ((uint64_t)(x) << 40) & 0x00ff000000000000ULL | \\ ((uint64_t)(x) << 24) & 0x0000ff0000000000ULL | \\ ((uint64_t)(x) << 8) & 0x000000ff00000000ULL | \\ ((x) >> 8) & 0x00000000ff000000ULL | \\ ((x) >> 24) & 0x0000000000ff0000ULL | \\ ((x) >> 40) & 0x000000000000ff00ULL | \\ ((x) >> 56) & 0x00000000000000ffULL)) EOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NXSwapLong in machine/byte_order.h" >&5 $as_echo_n "checking for NXSwapLong in machine/byte_order.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef NXSwapLong symbol is present #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "symbol is present|\" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } cat >> "$ac_byteorder" << EOF /* Define generic byte swapping functions */ #include #define swap16(x) NXSwapShort(x) #define swap32(x) NXSwapLong(x) #define swap64(x) NXSwapLongLong(x) EOF else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if test $ac_cv_c_bigendian = yes; then cat >> "$ac_byteorder" << EOF /* No other byte swapping functions are available on this big-endian system */ #define swap16(x) ((uint16_t)(((x) << 8) | ((uint16_t)(x) >> 8))) #define swap32(x) ((uint32_t)(((uint32_t)(x) << 24) & 0xff000000UL | \\ ((uint32_t)(x) << 8) & 0x00ff0000UL | \\ ((x) >> 8) & 0x0000ff00UL | \\ ((x) >> 24) & 0x000000ffUL)) #define swap64(x) ((uint64_t)(((uint64_t)(x) << 56) & 0xff00000000000000ULL | \\ ((uint64_t)(x) << 40) & 0x00ff000000000000ULL | \\ ((uint64_t)(x) << 24) & 0x0000ff0000000000ULL | \\ ((uint64_t)(x) << 8) & 0x000000ff00000000ULL | \\ ((x) >> 8) & 0x00000000ff000000ULL | \\ ((x) >> 24) & 0x0000000000ff0000ULL | \\ ((x) >> 40) & 0x000000000000ff00ULL | \\ ((x) >> 56) & 0x00000000000000ffULL)) EOF else cat >> "$ac_byteorder" << EOF /* Use these as generic byteswapping macros on this little endian system */ #define swap16(x) ntohs(x) #define swap32(x) ntohl(x) /* No optimized 64 bit byte swapping macro is available */ #define swap64(x) ((uint64_t)(((uint64_t)(x) << 56) & 0xff00000000000000ULL | \\ ((uint64_t)(x) << 40) & 0x00ff000000000000ULL | \\ ((uint64_t)(x) << 24) & 0x0000ff0000000000ULL | \\ ((uint64_t)(x) << 8) & 0x000000ff00000000ULL | \\ ((x) >> 8) & 0x00000000ff000000ULL | \\ ((x) >> 24) & 0x0000000000ff0000ULL | \\ ((x) >> 40) & 0x000000000000ff00ULL | \\ ((x) >> 56) & 0x00000000000000ffULL)) EOF fi fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* if test "$HAVE_LE32TOH" != "1"; then cat >> "$ac_byteorder" << EOF /* The byte swapping macros have the form: */ /* EENN[a]toh or htoEENN[a] where EE is be (big endian) or */ /* le (little-endian), NN is 16 or 32 (number of bits) and a, */ /* if present, indicates that the endian side is a pointer to an */ /* array of uint8_t bytes instead of an integer of the specified length. */ /* h refers to the host's ordering method. */ /* So, to convert a 32-bit integer stored in a buffer in little-endian */ /* format into a uint32_t usable on this machine, you could use: */ /* uint32_t value = le32atoh(&buf[3]); */ /* To put that value back into the buffer, you could use: */ /* htole32a(&buf[3], value); */ /* Define aliases for the standard byte swapping macros */ /* Arguments to these macros must be properly aligned on natural word */ /* boundaries in order to work properly on all architectures */ #ifndef htobe16 #define htobe16(x) htons(x) #endif #ifndef htobe32 #define htobe32(x) htonl(x) #endif #ifndef be16toh #define be16toh(x) ntohs(x) #endif #ifndef be32toh #define be32toh(x) ntohl(x) #endif #define HTOBE16(x) (x) = htobe16(x) #define HTOBE32(x) (x) = htobe32(x) #define BE32TOH(x) (x) = be32toh(x) #define BE16TOH(x) (x) = be16toh(x) EOF if test $ac_cv_c_bigendian = yes; then cat >> "$ac_byteorder" << EOF /* Define our own extended byte swapping macros for big-endian machines */ #ifndef htole16 #define htole16(x) swap16(x) #endif #ifndef htole32 #define htole32(x) swap32(x) #endif #ifndef le16toh #define le16toh(x) swap16(x) #endif #ifndef le32toh #define le32toh(x) swap32(x) #endif #ifndef htobe64 #define htobe64(x) (x) #endif #ifndef be64toh #define be64toh(x) (x) #endif #define HTOLE16(x) (x) = htole16(x) #define HTOLE32(x) (x) = htole32(x) #define LE16TOH(x) (x) = le16toh(x) #define LE32TOH(x) (x) = le32toh(x) #define HTOBE64(x) (void) (x) #define BE64TOH(x) (void) (x) EOF else cat >> "$ac_byteorder" << EOF /* On little endian machines, these macros are null */ #ifndef htole16 #define htole16(x) (x) #endif #ifndef htole32 #define htole32(x) (x) #endif #ifndef htole64 #define htole64(x) (x) #endif #ifndef le16toh #define le16toh(x) (x) #endif #ifndef le32toh #define le32toh(x) (x) #endif #ifndef le64toh #define le64toh(x) (x) #endif #define HTOLE16(x) (void) (x) #define HTOLE32(x) (void) (x) #define HTOLE64(x) (void) (x) #define LE16TOH(x) (void) (x) #define LE32TOH(x) (void) (x) #define LE64TOH(x) (void) (x) /* These don't have standard aliases */ #ifndef htobe64 #define htobe64(x) swap64(x) #endif #ifndef be64toh #define be64toh(x) swap64(x) #endif #define HTOBE64(x) (x) = htobe64(x) #define BE64TOH(x) (x) = be64toh(x) EOF fi fi cat >> "$ac_byteorder" << EOF /* Define the C99 standard length-specific integer types */ #include <_stdint.h> EOF case "${effective_target}" in i[3456]86-*) cat >> "$ac_byteorder" << EOF /* Here are some macros to create integers from a byte array */ /* These are used to get and put integers from/into a uint8_t array */ /* with a specific endianness. This is the most portable way to generate */ /* and read messages to a network or serial device. Each member of a */ /* packet structure must be handled separately. */ /* The i386 and compatibles can handle unaligned memory access, */ /* so use the optimized macros above to do this job */ #define be16atoh(x) be16toh(*(uint16_t*)(x)) #define be32atoh(x) be32toh(*(uint32_t*)(x)) #define be64atoh(x) be64toh(*(uint64_t*)(x)) #define le16atoh(x) le16toh(*(uint16_t*)(x)) #define le32atoh(x) le32toh(*(uint32_t*)(x)) #define le64atoh(x) le64toh(*(uint64_t*)(x)) #define htobe16a(a,x) *(uint16_t*)(a) = htobe16(x) #define htobe32a(a,x) *(uint32_t*)(a) = htobe32(x) #define htobe64a(a,x) *(uint64_t*)(a) = htobe64(x) #define htole16a(a,x) *(uint16_t*)(a) = htole16(x) #define htole32a(a,x) *(uint32_t*)(a) = htole32(x) #define htole64a(a,x) *(uint64_t*)(a) = htole64(x) EOF ;; *) cat >> "$ac_byteorder" << EOF /* Here are some macros to create integers from a byte array */ /* These are used to get and put integers from/into a uint8_t array */ /* with a specific endianness. This is the most portable way to generate */ /* and read messages to a network or serial device. Each member of a */ /* packet structure must be handled separately. */ /* Non-optimized but portable macros */ #define be16atoh(x) ((uint16_t)(((x)[0]<<8)|(x)[1])) #define be32atoh(x) ((uint32_t)(((x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])) #define be64atoh(x) ((uint64_t)(((x)[0]<<56)|((x)[1]<<48)|((x)[2]<<40)| \\ ((x)[3]<<32)|((x)[4]<<24)|((x)[5]<<16)|((x)[6]<<8)|(x)[7])) #define le16atoh(x) ((uint16_t)(((x)[1]<<8)|(x)[0])) #define le32atoh(x) ((uint32_t)(((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|(x)[0])) #define le64atoh(x) ((uint64_t)(((x)[7]<<56)|((x)[6]<<48)|((x)[5]<<40)| \\ ((x)[4]<<32)|((x)[3]<<24)|((x)[2]<<16)|((x)[1]<<8)|(x)[0])) #define htobe16a(a,x) (a)[0]=(uint8_t)((x)>>8), (a)[1]=(uint8_t)(x) #define htobe32a(a,x) (a)[0]=(uint8_t)((x)>>24), (a)[1]=(uint8_t)((x)>>16), \\ (a)[2]=(uint8_t)((x)>>8), (a)[3]=(uint8_t)(x) #define htobe64a(a,x) (a)[0]=(uint8_t)((x)>>56), (a)[1]=(uint8_t)((x)>>48), \\ (a)[2]=(uint8_t)((x)>>40), (a)[3]=(uint8_t)((x)>>32), \\ (a)[4]=(uint8_t)((x)>>24), (a)[5]=(uint8_t)((x)>>16), \\ (a)[6]=(uint8_t)((x)>>8), (a)[7]=(uint8_t)(x) #define htole16a(a,x) (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) #define htole32a(a,x) (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \\ (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) #define htole64a(a,x) (a)[7]=(uint8_t)((x)>>56), (a)[6]=(uint8_t)((x)>>48), \\ (a)[5]=(uint8_t)((x)>>40), (a)[4]=(uint8_t)((x)>>32), \\ (a)[3]=(uint8_t)((x)>>24), (a)[2]=(uint8_t)((x)>>16), \\ (a)[1]=(uint8_t)((x)>>8), (a)[0]=(uint8_t)(x) EOF ;; esac cat >> "$ac_byteorder" << EOF #endif /*__BYTEORDER_H*/ EOF if cmp -s $ac_byteorder_h $ac_byteorder 2>/dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_byteorder_h is unchanged" >&5 $as_echo "$as_me: $ac_byteorder_h is unchanged" >&6;} rm $ac_byteorder else rm -f $ac_byteorder_h mv $ac_byteorder $ac_byteorder_h fi # ------ AX CREATE STDINT H ------------------------------------- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint types" >&5 $as_echo_n "checking for stdint types... " >&6; } ac_stdint_h=`echo include/_stdint.h` # try to shortcircuit - if the default include path of the compiler # can find a "stdint.h" header then we assume that all compilers can. if ${ac_cv_header_stdint_t+:} false; then : $as_echo_n "(cached) " >&6 else old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS="" old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="" old_CFLAGS="$CFLAGS" ; CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int_least32_t v = 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_stdint_result="(assuming C99 compatible system)" ac_cv_header_stdint_t="stdint.h"; else ac_cv_header_stdint_t="" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "$GCC" = "yes" && test ".$ac_cv_header_stdint_t" = "."; then CFLAGS="-std=c99" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int_least32_t v = 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: your GCC compiler has a defunct stdint.h for its default-mode" >&5 $as_echo "$as_me: WARNING: your GCC compiler has a defunct stdint.h for its default-mode" >&2;} fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi CXXFLAGS="$old_CXXFLAGS" CPPFLAGS="$old_CPPFLAGS" CFLAGS="$old_CFLAGS" fi v="... $ac_cv_header_stdint_h" if test "$ac_stdint_h" = "stdint.h" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: (are you sure you want them in ./stdint.h?)" >&5 $as_echo "(are you sure you want them in ./stdint.h?)" >&6; } elif test "$ac_stdint_h" = "inttypes.h" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: (are you sure you want them in ./inttypes.h?)" >&5 $as_echo "(are you sure you want them in ./inttypes.h?)" >&6; } elif test "_$ac_cv_header_stdint_t" = "_" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: (putting them into $ac_stdint_h)$v" >&5 $as_echo "(putting them into $ac_stdint_h)$v" >&6; } else ac_cv_header_stdint="$ac_cv_header_stdint_t" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdint (shortcircuit)" >&5 $as_echo "$ac_cv_header_stdint (shortcircuit)" >&6; } fi if test "_$ac_cv_header_stdint_t" = "_" ; then # cannot shortcircuit.. inttype_headers=`echo | sed -e 's/,/ /g'` ac_cv_stdint_result="(no helpful system typedefs seen)" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint uintptr_t" >&5 $as_echo_n "checking for stdint uintptr_t... " >&6; } if ${ac_cv_header_stdint_x+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h) { $as_echo "$as_me:${as_lineno-$LINENO}: result: (..)" >&5 $as_echo "(..)" >&6; } for i in stdint.h inttypes.h sys/inttypes.h $inttype_headers do unset ac_cv_type_uintptr_t unset ac_cv_type_uint64_t ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "#include <$i> " if test "x$ac_cv_type_uintptr_t" = xyes; then : ac_cv_header_stdint_x=$i else continue fi ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "#include<$i> " if test "x$ac_cv_type_uint64_t" = xyes; then : and64="/uint64_t" else and64="" fi ac_cv_stdint_result="(seen uintptr_t$and64 in $i)" break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint uintptr_t" >&5 $as_echo_n "checking for stdint uintptr_t... " >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdint_x" >&5 $as_echo "$ac_cv_header_stdint_x" >&6; } if test "_$ac_cv_header_stdint_x" = "_" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint uint32_t" >&5 $as_echo_n "checking for stdint uint32_t... " >&6; } if ${ac_cv_header_stdint_o+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h) { $as_echo "$as_me:${as_lineno-$LINENO}: result: (..)" >&5 $as_echo "(..)" >&6; } for i in inttypes.h sys/inttypes.h stdint.h $inttype_headers do unset ac_cv_type_uint32_t unset ac_cv_type_uint64_t ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "#include <$i> " if test "x$ac_cv_type_uint32_t" = xyes; then : ac_cv_header_stdint_o=$i else continue fi ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "#include<$i> " if test "x$ac_cv_type_uint64_t" = xyes; then : and64="/uint64_t" else and64="" fi ac_cv_stdint_result="(seen uint32_t$and64 in $i)" break break; done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint uint32_t" >&5 $as_echo_n "checking for stdint uint32_t... " >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdint_o" >&5 $as_echo "$ac_cv_header_stdint_o" >&6; } fi if test "_$ac_cv_header_stdint_x" = "_" ; then if test "_$ac_cv_header_stdint_o" = "_" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint u_int32_t" >&5 $as_echo_n "checking for stdint u_int32_t... " >&6; } if ${ac_cv_header_stdint_u+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h) { $as_echo "$as_me:${as_lineno-$LINENO}: result: (..)" >&5 $as_echo "(..)" >&6; } for i in sys/types.h inttypes.h sys/inttypes.h $inttype_headers ; do unset ac_cv_type_u_int32_t unset ac_cv_type_u_int64_t ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "#include <$i> " if test "x$ac_cv_type_u_int32_t" = xyes; then : ac_cv_header_stdint_u=$i else continue fi ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "#include<$i> " if test "x$ac_cv_type_u_int64_t" = xyes; then : and64="/u_int64_t" else and64="" fi ac_cv_stdint_result="(seen u_int32_t$and64 in $i)" break break; done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint u_int32_t" >&5 $as_echo_n "checking for stdint u_int32_t... " >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdint_u" >&5 $as_echo "$ac_cv_header_stdint_u" >&6; } fi fi if test "_$ac_cv_header_stdint_x" = "_" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint datatype model" >&5 $as_echo_n "checking for stdint datatype model... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: (..)" >&5 $as_echo "(..)" >&6; } # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char" >&5 $as_echo_n "checking size of char... " >&6; } if ${ac_cv_sizeof_char+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default"; then : else if test "$ac_cv_type_char" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (char) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_char=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5 $as_echo "$ac_cv_sizeof_char" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_CHAR $ac_cv_sizeof_char _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 $as_echo_n "checking size of short... " >&6; } if ${ac_cv_sizeof_short+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : else if test "$ac_cv_type_short" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (short) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_short=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 $as_echo "$ac_cv_sizeof_short" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } if ${ac_cv_sizeof_int+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : else if test "$ac_cv_type_int" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 $as_echo "$ac_cv_sizeof_int" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } if ${ac_cv_sizeof_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 $as_echo "$ac_cv_sizeof_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void*" >&5 $as_echo_n "checking size of void*... " >&6; } if ${ac_cv_sizeof_voidp+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void*))" "ac_cv_sizeof_voidp" "$ac_includes_default"; then : else if test "$ac_cv_type_voidp" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (void*) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_voidp=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_voidp" >&5 $as_echo "$ac_cv_sizeof_voidp" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_VOIDP $ac_cv_sizeof_voidp _ACEOF ac_cv_char_data_model="" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int" ac_cv_long_data_model="" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp" { $as_echo "$as_me:${as_lineno-$LINENO}: checking data model" >&5 $as_echo_n "checking data model... " >&6; } case "$ac_cv_char_data_model/$ac_cv_long_data_model" in 122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;; 122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;; 122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;; 124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;; 124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;; 124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;; 124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;; 128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;; 128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;; 222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;; 333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;; 444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;; 666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;; 888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;; 222/*|333/*|444/*|666/*|888/*) : ac_cv_data_model="iDSP" ; n="unusual dsptype" ;; *) ac_cv_data_model="none" ; n="very unusual model" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_data_model ($ac_cv_long_data_model, $n)" >&5 $as_echo "$ac_cv_data_model ($ac_cv_long_data_model, $n)" >&6; } fi if test "_$ac_cv_header_stdint_x" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_x" elif test "_$ac_cv_header_stdint_o" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_o" elif test "_$ac_cv_header_stdint_u" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_u" else ac_cv_header_stdint="stddef.h" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for extra inttypes in chosen header" >&5 $as_echo_n "checking for extra inttypes in chosen header... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: ($ac_cv_header_stdint)" >&5 $as_echo "($ac_cv_header_stdint)" >&6; } unset ac_cv_type_int_least32_t unset ac_cv_type_int_fast32_t ac_fn_c_check_type "$LINENO" "int_least32_t" "ac_cv_type_int_least32_t" "#include <$ac_cv_header_stdint> " if test "x$ac_cv_type_int_least32_t" = xyes; then : fi ac_fn_c_check_type "$LINENO" "int_fast32_t" "ac_cv_type_int_fast32_t" "#include<$ac_cv_header_stdint> " if test "x$ac_cv_type_int_fast32_t" = xyes; then : fi ac_fn_c_check_type "$LINENO" "intmax_t" "ac_cv_type_intmax_t" "#include <$ac_cv_header_stdint> " if test "x$ac_cv_type_intmax_t" = xyes; then : fi fi # shortcircuit to system "stdint.h" # ------------------ PREPARE VARIABLES ------------------------------ if test "$GCC" = "yes" ; then ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` else ac_cv_stdint_message="using $CC" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: make use of $ac_cv_header_stdint in $ac_stdint_h $ac_cv_stdint_result" >&5 $as_echo "make use of $ac_cv_header_stdint in $ac_stdint_h $ac_cv_stdint_result" >&6; } # ----------------- DONE inttypes.h checks START header ------------- ac_config_commands="$ac_config_commands $ac_stdint_h" # Check whether --enable-dynamic was given. if test "${enable_dynamic+set}" = set; then : enableval=$enable_dynamic; enable_dynamic=$enableval else enable_dynamic=auto fi DL_LIBS="" if test "${enable_dynamic}" = "auto"; then # default to disabled unless library found. enable_dynamic=no # dlopen for ac_header in dlfcn.h do : ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : DL_LIBS=-ldl fi saved_LIBS="${LIBS}" LIBS="${LIBS} ${DL_LIBS}" for ac_func in dlopen do : ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLOPEN 1 _ACEOF enable_dynamic=yes fi done LIBS="${saved_LIBS}" fi done # HP/UX DLL handling for ac_header in dl.h do : ac_fn_c_check_header_mongrel "$LINENO" "dl.h" "ac_cv_header_dl_h" "$ac_includes_default" if test "x$ac_cv_header_dl_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DL_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : DL_LIBS=-ldld fi saved_LIBS="${LIBS}" LIBS="${LIBS} ${DL_LIBS}" for ac_func in shl_load do : ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SHL_LOAD 1 _ACEOF enable_dynamic=yes fi done LIBS="${saved_LIBS}" fi done if test -z "$DL_LIBS" ; then # old Mac OS X/Darwin (without dlopen) for ac_header in mach-o/dyld.h do : ac_fn_c_check_header_mongrel "$LINENO" "mach-o/dyld.h" "ac_cv_header_mach_o_dyld_h" "$ac_includes_default" if test "x$ac_cv_header_mach_o_dyld_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_MACH_O_DYLD_H 1 _ACEOF for ac_func in NSLinkModule do : ac_fn_c_check_func "$LINENO" "NSLinkModule" "ac_cv_func_NSLinkModule" if test "x$ac_cv_func_NSLinkModule" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_NSLINKMODULE 1 _ACEOF enable_dynamic=yes fi done fi done fi fi DYNAMIC_FLAG= if test "${enable_dynamic}" = yes ; then DYNAMIC_FLAG=-module fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqrt in -lm" >&5 $as_echo_n "checking for sqrt in -lm... " >&6; } if ${ac_cv_lib_m_sqrt+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sqrt (); int main () { return sqrt (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_m_sqrt=yes else ac_cv_lib_m_sqrt=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sqrt" >&5 $as_echo "$ac_cv_lib_m_sqrt" >&6; } if test "x$ac_cv_lib_m_sqrt" = xyes; then : MATH_LIB="-lm" fi case ${host_os} in os2*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sylog in -lsyslog" >&5 $as_echo_n "checking for sylog in -lsyslog... " >&6; } if ${ac_cv_lib_syslog_sylog+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsyslog $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sylog (); int main () { return sylog (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_syslog_sylog=yes else ac_cv_lib_syslog_sylog=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_syslog_sylog" >&5 $as_echo "$ac_cv_lib_syslog_sylog" >&6; } if test "x$ac_cv_lib_syslog_sylog" = xyes; then : SYSLOG_LIBS="-lsyslog" fi ;; beos*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for syslog in -lbe" >&5 $as_echo_n "checking for syslog in -lbe... " >&6; } if ${ac_cv_lib_be_syslog+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbe $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char syslog (); int main () { return syslog (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_be_syslog=yes else ac_cv_lib_be_syslog=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_be_syslog" >&5 $as_echo "$ac_cv_lib_be_syslog" >&6; } if test "x$ac_cv_lib_be_syslog" = xyes; then : SYSLOG_LIBS="-lbe" fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_start_decompress in -ljpeg" >&5 $as_echo_n "checking for jpeg_start_decompress in -ljpeg... " >&6; } if ${ac_cv_lib_jpeg_jpeg_start_decompress+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ljpeg $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char jpeg_start_decompress (); int main () { return jpeg_start_decompress (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_jpeg_jpeg_start_decompress=yes else ac_cv_lib_jpeg_jpeg_start_decompress=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_start_decompress" >&5 $as_echo "$ac_cv_lib_jpeg_jpeg_start_decompress" >&6; } if test "x$ac_cv_lib_jpeg_jpeg_start_decompress" = xyes; then : ac_fn_c_check_header_mongrel "$LINENO" "jconfig.h" "ac_cv_header_jconfig_h" "$ac_includes_default" if test "x$ac_cv_header_jconfig_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeglib - version >= 61 (6a)" >&5 $as_echo_n "checking for jpeglib - version >= 61 (6a)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if JPEG_LIB_VERSION >= 61 sane_correct_jpeg_lib_version_found #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "sane_correct_jpeg_lib_version_found" >/dev/null 2>&1; then : sane_cv_use_libjpeg="yes"; JPEG_LIBS="-ljpeg"; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest* fi fi if test "$sane_cv_use_libjpeg" = "yes" ; then $as_echo "#define HAVE_LIBJPEG 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIFFFdOpen in -ltiff" >&5 $as_echo_n "checking for TIFFFdOpen in -ltiff... " >&6; } if ${ac_cv_lib_tiff_TIFFFdOpen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltiff $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char TIFFFdOpen (); int main () { return TIFFFdOpen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_tiff_TIFFFdOpen=yes else ac_cv_lib_tiff_TIFFFdOpen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tiff_TIFFFdOpen" >&5 $as_echo "$ac_cv_lib_tiff_TIFFFdOpen" >&6; } if test "x$ac_cv_lib_tiff_TIFFFdOpen" = xyes; then : ac_fn_c_check_header_mongrel "$LINENO" "tiffio.h" "ac_cv_header_tiffio_h" "$ac_includes_default" if test "x$ac_cv_header_tiffio_h" = xyes; then : sane_cv_use_libtiff="yes"; TIFF_LIBS="-ltiff" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for png_init_io in -lpng" >&5 $as_echo_n "checking for png_init_io in -lpng... " >&6; } if ${ac_cv_lib_png_png_init_io+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpng $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char png_init_io (); int main () { return png_init_io (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_png_png_init_io=yes else ac_cv_lib_png_png_init_io=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_png_png_init_io" >&5 $as_echo "$ac_cv_lib_png_png_init_io" >&6; } if test "x$ac_cv_lib_png_png_init_io" = xyes; then : ac_fn_c_check_header_mongrel "$LINENO" "png.h" "ac_cv_header_png_h" "$ac_includes_default" if test "x$ac_cv_header_png_h" = xyes; then : sane_cv_use_libpng="yes"; PNG_LIBS="-lpng" fi fi if test "$sane_cv_use_libpng" = "yes" ; then $as_echo "#define HAVE_LIBPNG 1" >>confdefs.h fi ac_fn_c_check_header_mongrel "$LINENO" "ieee1284.h" "ac_cv_header_ieee1284_h" "$ac_includes_default" if test "x$ac_cv_header_ieee1284_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libieee1284 >= 0.1.5" >&5 $as_echo_n "checking for libieee1284 >= 0.1.5... " >&6; } if ${sane_cv_use_libieee1284+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { struct parport p; char *buf; ieee1284_nibble_read(&p, 0, buf, 1); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : sane_cv_use_libieee1284="yes"; IEEE1284_LIBS="-lieee1284" else sane_cv_use_libieee1284="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sane_cv_use_libieee1284" >&5 $as_echo "$sane_cv_use_libieee1284" >&6; } fi if test "$sane_cv_use_libieee1284" = "yes" ; then $as_echo "#define HAVE_LIBIEEE1284 1" >>confdefs.h fi case "${host_os}" in linux* | darwin* | mingw*) # enabled by default on Linux, MacOS X and MINGW use_pthread=yes ;; *) use_pthread=no esac have_pthread=no # # now that we have the systems preferences, we check # the user # Check whether --enable-pthread was given. if test "${enable_pthread+set}" = set; then : enableval=$enable_pthread; if test $enableval = yes ; then use_pthread=yes else use_pthread=no fi fi if test $use_pthread = yes ; then for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTHREAD_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes else ac_cv_lib_pthread_pthread_create=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : PTHREAD_LIBS="-lpthread" fi have_pthread=yes save_LIBS="$LIBS" LIBS="$LIBS $PTHREAD_LIBS" for ac_func in pthread_create pthread_kill pthread_join pthread_detach pthread_cancel pthread_testcancel do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF else have_pthread=no; use_pthread=no fi done LIBS="$save_LIBS" else have_pthread=no; use_pthread=no fi done fi # Based on a similar test for pthread_key_t from the Python project. # See https://bugs.python.org/review/25658/patch/19209/75870 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_t is integer" >&5 $as_echo_n "checking whether pthread_t is integer... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { pthread_t k; k * 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_pthread_t_is_integer=yes else ac_pthread_t_is_integer=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pthread_t_is_integer" >&5 $as_echo "$ac_pthread_t_is_integer" >&6; } if test "$ac_pthread_t_is_integer" = yes ; then $as_echo "#define PTHREAD_T_IS_INTEGER 1" >>confdefs.h else # Until the sanei_thread implementation is fixed. use_pthread=no fi if test "$have_pthread" = "yes" ; then AM_CPPFLAGS="${AM_CPPFLAGS} -D_REENTRANT" fi if test $use_pthread = yes ; then cat >>confdefs.h <<_ACEOF #define USE_PTHREAD "$use_pthread" _ACEOF SANEI_THREAD_LIBS=$PTHREAD_LIBS else SANEI_THREAD_LIBS="" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable pthread support" >&5 $as_echo_n "checking whether to enable pthread support... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_pthread" >&5 $as_echo "$have_pthread" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use pthread instead of fork" >&5 $as_echo_n "checking whether to use pthread instead of fork... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_pthread" >&5 $as_echo "$use_pthread" >&6; } LOCKPATH_GROUP=uucp use_locking=yes case "${host_os}" in os2* ) use_locking=no ;; esac # # we check the user # Check whether --enable-locking was given. if test "${enable_locking+set}" = set; then : enableval=$enable_locking; if test $enableval = yes ; then use_locking=yes else use_locking=no fi fi if test $use_locking = yes ; then # Check whether --with-group was given. if test "${with_group+set}" = set; then : withval=$with_group; LOCKPATH_GROUP="$withval" fi # check if the group does exist lasterror="" touch sanetest.file chgrp $LOCKPATH_GROUP sanetest.file 2>/dev/null || lasterror=$? rm -f sanetest.file if test ! -z "$lasterror"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Group $LOCKPATH_GROUP does not exist on this system." >&5 $as_echo "$as_me: WARNING: Group $LOCKPATH_GROUP does not exist on this system." >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Locking feature will be disabled." >&5 $as_echo "$as_me: WARNING: Locking feature will be disabled." >&2;} use_locking=no fi fi if test $use_locking = yes ; then INSTALL_LOCKPATH=install-lockpath $as_echo "#define ENABLE_LOCKING 1" >>confdefs.h else INSTALL_LOCKPATH= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable device locking" >&5 $as_echo_n "checking whether to enable device locking... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_locking" >&5 $as_echo "$use_locking" >&6; } if test $use_locking = yes ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Setting lockdir group to $LOCKPATH_GROUP" >&5 $as_echo "$as_me: Setting lockdir group to $LOCKPATH_GROUP" >&6;} fi # Check whether --with-gphoto2 was given. if test "${with_gphoto2+set}" = set; then : withval=$with_gphoto2; # If --with-gphoto2=no or --without-gphoto2, disable backend # as "$with_gphoto2" will be set to "no" fi # If --with-gphoto2=yes (or not supplied), first check if # pkg-config exists, then use it to check if libgphoto2 is # present. If all that works, then see if we can actually link # a program. And, if that works, then add the -l flags to # GPHOTO2_LIBS and any other flags to GPHOTO2_LDFLAGS to pass to # sane-config. if test "$with_gphoto2" != "no" ; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_HAVE_GPHOTO2+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$HAVE_GPHOTO2"; then ac_cv_prog_HAVE_GPHOTO2="$HAVE_GPHOTO2" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_HAVE_GPHOTO2="${ac_tool_prefix}pkg-config" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi HAVE_GPHOTO2=$ac_cv_prog_HAVE_GPHOTO2 if test -n "$HAVE_GPHOTO2"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_GPHOTO2" >&5 $as_echo "$HAVE_GPHOTO2" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_HAVE_GPHOTO2"; then ac_ct_HAVE_GPHOTO2=$HAVE_GPHOTO2 # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_HAVE_GPHOTO2+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_HAVE_GPHOTO2"; then ac_cv_prog_ac_ct_HAVE_GPHOTO2="$ac_ct_HAVE_GPHOTO2" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_HAVE_GPHOTO2="pkg-config" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_HAVE_GPHOTO2=$ac_cv_prog_ac_ct_HAVE_GPHOTO2 if test -n "$ac_ct_HAVE_GPHOTO2"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_HAVE_GPHOTO2" >&5 $as_echo "$ac_ct_HAVE_GPHOTO2" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_HAVE_GPHOTO2" = x; then HAVE_GPHOTO2="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac HAVE_GPHOTO2=$ac_ct_HAVE_GPHOTO2 fi else HAVE_GPHOTO2="$ac_cv_prog_HAVE_GPHOTO2" fi if test ${HAVE_GPHOTO2} != "false" ; then if pkg-config --exists libgphoto2 ; then with_gphoto2="`pkg-config --modversion libgphoto2`" GPHOTO2_CPPFLAGS="`pkg-config --cflags libgphoto2`" GPHOTO2_LIBS="`pkg-config --libs libgphoto2`" saved_CPPFLAGS="${CPPFLAGS}" CPPFLAGS="${GPHOTO2_CPPFLAGS}" saved_LIBS="${LIBS}" LIBS="${LIBS} ${GPHOTO2_LIBS}" # Make sure we an really use the library for ac_func in gp_camera_init do : ac_fn_c_check_func "$LINENO" "gp_camera_init" "ac_cv_func_gp_camera_init" if test "x$ac_cv_func_gp_camera_init" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GP_CAMERA_INIT 1 _ACEOF HAVE_GPHOTO2=true else HAVE_GPHOTO2=false fi done if test "${HAVE_GPHOTO2}" = "true"; then for ac_func in gp_port_info_get_path do : ac_fn_c_check_func "$LINENO" "gp_port_info_get_path" "ac_cv_func_gp_port_info_get_path" if test "x$ac_cv_func_gp_port_info_get_path" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GP_PORT_INFO_GET_PATH 1 _ACEOF fi done fi CPPFLAGS="${saved_CPPFLAGS}" LIBS="${saved_LIBS}" else HAVE_GPHOTO2=false fi if test "${HAVE_GPHOTO2}" = "false"; then GPHOTO2_CPPFLAGS="" GPHOTO2_LIBS="" else tmp_LIBS="" for param in ${GPHOTO2_LIBS}; do case "${param}" in -l*) tmp_LIBS="${tmp_LIBS} ${param}" ;; *) GPHOTO2_LDFLAGS="${GPHOTO2_LDFLAGS} ${param}" ;; esac done GPHOTO2_LIBS="${tmp_LIBS}" unset tmp_LIBS unset param if pkg-config --atleast-version=2.5.0 libgphoto2; then $as_echo "#define GPLOGFUNC_NO_VARGS 1" >>confdefs.h fi fi fi fi # Check whether --with-v4l was given. if test "${with_v4l+set}" = set; then : withval=$with_v4l; # If --with-v4l=no or --without-v4l, disable backend # as "$with_v4l" will be set to "no" fi if test "$with_v4l" != "no" ; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBV4L" >&5 $as_echo_n "checking for LIBV4L... " >&6; } if test -n "$LIBV4L_CFLAGS"; then pkg_cv_LIBV4L_CFLAGS="$LIBV4L_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libv4l1\""; } >&5 ($PKG_CONFIG --exists --print-errors "libv4l1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBV4L_CFLAGS=`$PKG_CONFIG --cflags "libv4l1" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBV4L_LIBS"; then pkg_cv_LIBV4L_LIBS="$LIBV4L_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libv4l1\""; } >&5 ($PKG_CONFIG --exists --print-errors "libv4l1") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBV4L_LIBS=`$PKG_CONFIG --libs "libv4l1" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBV4L_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libv4l1" 2>&1` else LIBV4L_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libv4l1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBV4L_PKG_ERRORS" >&5 have_libv4l1=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_libv4l1=no else LIBV4L_CFLAGS=$pkg_cv_LIBV4L_CFLAGS LIBV4L_LIBS=$pkg_cv_LIBV4L_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_libv4l1=yes fi fi # Check whether --enable-avahi was given. if test "${enable_avahi+set}" = set; then : enableval=$enable_avahi; enable_avahi=$enableval else enable_avahi=no fi if test "$enable_avahi" = "yes"; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AVAHI" >&5 $as_echo_n "checking for AVAHI... " >&6; } if test -n "$AVAHI_CFLAGS"; then pkg_cv_AVAHI_CFLAGS="$AVAHI_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" avahi-client >= 0.6.24 \""; } >&5 ($PKG_CONFIG --exists --print-errors " avahi-client >= 0.6.24 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_AVAHI_CFLAGS=`$PKG_CONFIG --cflags " avahi-client >= 0.6.24 " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$AVAHI_LIBS"; then pkg_cv_AVAHI_LIBS="$AVAHI_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" avahi-client >= 0.6.24 \""; } >&5 ($PKG_CONFIG --exists --print-errors " avahi-client >= 0.6.24 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_AVAHI_LIBS=`$PKG_CONFIG --libs " avahi-client >= 0.6.24 " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then AVAHI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " avahi-client >= 0.6.24 " 2>&1` else AVAHI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " avahi-client >= 0.6.24 " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$AVAHI_PKG_ERRORS" >&5 enable_avahi=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } enable_avahi=no else AVAHI_CFLAGS=$pkg_cv_AVAHI_CFLAGS AVAHI_LIBS=$pkg_cv_AVAHI_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define WITH_AVAHI 1" >>confdefs.h fi fi if test x != "x$AVAHI_LIBS"; then have_libavahi_TRUE= have_libavahi_FALSE='#' else have_libavahi_TRUE='#' have_libavahi_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sane_init in -lsane" >&5 $as_echo_n "checking for sane_init in -lsane... " >&6; } if ${ac_cv_lib_sane_sane_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsane $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sane_init (); int main () { return sane_init (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_sane_sane_init=yes else ac_cv_lib_sane_sane_init=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sane_sane_init" >&5 $as_echo "$ac_cv_lib_sane_sane_init" >&6; } if test "x$ac_cv_lib_sane_sane_init" = xyes; then : LIBSANE_EXISTS="yes" fi # Check whether --with-snmp was given. if test "${with_snmp+set}" = set; then : withval=$with_snmp; fi if test "$with_snmp" = "no"; then echo "Not including SNMP support" else # Extract the first word of "net-snmp-config", so it can be a program name with args. set dummy net-snmp-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_SNMP_CONFIG_PATH+:} false; then : $as_echo_n "(cached) " >&6 else case $SNMP_CONFIG_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_SNMP_CONFIG_PATH="$SNMP_CONFIG_PATH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_SNMP_CONFIG_PATH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SNMP_CONFIG_PATH" && ac_cv_path_SNMP_CONFIG_PATH=""no"" ;; esac fi SNMP_CONFIG_PATH=$ac_cv_path_SNMP_CONFIG_PATH if test -n "$SNMP_CONFIG_PATH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SNMP_CONFIG_PATH" >&5 $as_echo "$SNMP_CONFIG_PATH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for snmp_timeout in -lnetsnmp" >&5 $as_echo_n "checking for snmp_timeout in -lnetsnmp... " >&6; } if ${ac_cv_lib_netsnmp_snmp_timeout+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnetsnmp $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char snmp_timeout (); int main () { return snmp_timeout (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_netsnmp_snmp_timeout=yes else ac_cv_lib_netsnmp_snmp_timeout=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_netsnmp_snmp_timeout" >&5 $as_echo "$ac_cv_lib_netsnmp_snmp_timeout" >&6; } if test "x$ac_cv_lib_netsnmp_snmp_timeout" = xyes; then : LIBSNMP_EXISTS="yes" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for proper SNMP version" >&5 $as_echo_n "checking for proper SNMP version... " >&6; } if test "$SNMP_CONFIG_PATH" != "no" ; then snmp_version=`$SNMP_CONFIG_PATH --version 2>/dev/null` vers=`echo $snmp_version | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2);}'` if test -n "$vers" && test "$vers" -ge 5006; then SNMP_LIBS=`$SNMP_CONFIG_PATH --libs` SNMP_CFLAGS=`$SNMP_CONFIG_PATH --cflags` { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } with_snmp="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You need at least net-snmp 5.6, your version is $snmp_version" >&5 $as_echo "$as_me: WARNING: You need at least net-snmp 5.6, your version is $snmp_version" >&2;} with_snmp="no" fi else with_snmp="no" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test "$with_snmp" = "yes" && test "${LIBSNMP_EXISTS}x" = "yesx"; then $as_echo "#define HAVE_LIBSNMP 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: net-snmp library disabled, autodetecting network scanners will not be supported." >&5 $as_echo "$as_me: WARNING: net-snmp library disabled, autodetecting network scanners will not be supported." >&2;} fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi for ac_header in fcntl.h unistd.h libc.h sys/dsreq.h sys/select.h \ sys/time.h sys/shm.h sys/ipc.h sys/scanio.h os2.h \ sys/socket.h sys/io.h sys/hw.h sys/types.h linux/ppdev.h \ dev/ppbus/ppi.h machine/cpufunc.h sys/sem.h sys/poll.h \ windows.h be/kernel/OS.h limits.h sys/ioctl.h asm/types.h\ netinet/in.h tiffio.h ifaddrs.h pwd.h getopt.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in asm/io.h do : ac_fn_c_check_header_compile "$LINENO" "asm/io.h" "ac_cv_header_asm_io_h" "#include " if test "x$ac_cv_header_asm_io_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ASM_IO_H 1 _ACEOF fi done MISSING_HEADERS= if test "${ac_cv_header_fcntl_h}" != "yes" ; then MISSING_HEADERS="${MISSING_HEADERS}\"fcntl.h\" " fi if test "${ac_cv_header_sys_time_h}" != "yes" ; then MISSING_HEADERS="${MISSING_HEADERS}\"sys/time.h\" " fi if test "${ac_cv_header_unistd_h}" != "yes" ; then MISSING_HEADERS="${MISSING_HEADERS}\"unistd.h\" " fi if test "${ac_cv_header_stdc}" != "yes" ; then MISSING_HEADERS="${MISSING_HEADERS}\"ANSI C headers\" " fi if test "${MISSING_HEADERS}" != "" ; then echo "*** The following essential header files couldn't be found:" echo "*** ${MISSING_HEADERS}" echo "*** Maybe the compiler isn't ANSI C compliant or not properly installed?" echo "*** For details on what went wrong see config.log." as_fn_error $? "Exiting now." "$LINENO" 5 fi for ac_header in winsock2.h do : ac_fn_c_check_header_mongrel "$LINENO" "winsock2.h" "ac_cv_header_winsock2_h" "$ac_includes_default" if test "x$ac_cv_header_winsock2_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_WINSOCK2_H 1 _ACEOF SOCKET_LIB="-lws2_32" fi done ac_fn_c_check_header_mongrel "$LINENO" "resmgr.h" "ac_cv_header_resmgr_h" "$ac_includes_default" if test "x$ac_cv_header_resmgr_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rsm_open_device in -lresmgr" >&5 $as_echo_n "checking for rsm_open_device in -lresmgr... " >&6; } if ${ac_cv_lib_resmgr_rsm_open_device+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lresmgr $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char rsm_open_device (); int main () { return rsm_open_device (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_resmgr_rsm_open_device=yes else ac_cv_lib_resmgr_rsm_open_device=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resmgr_rsm_open_device" >&5 $as_echo "$ac_cv_lib_resmgr_rsm_open_device" >&6; } if test "x$ac_cv_lib_resmgr_rsm_open_device" = xyes; then : $as_echo "#define HAVE_RESMGR 1" >>confdefs.h RESMGR_LIBS="-lresmgr" fi fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define ssize_t int _ACEOF fi ac_fn_c_check_type "$LINENO" "u_char" "ac_cv_type_u_char" "$ac_includes_default" if test "x$ac_cv_type_u_char" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_U_CHAR 1 _ACEOF fi ac_fn_c_check_type "$LINENO" "u_short" "ac_cv_type_u_short" "$ac_includes_default" if test "x$ac_cv_type_u_short" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_U_SHORT 1 _ACEOF fi ac_fn_c_check_type "$LINENO" "u_int" "ac_cv_type_u_int" "$ac_includes_default" if test "x$ac_cv_type_u_int" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_U_INT 1 _ACEOF fi ac_fn_c_check_type "$LINENO" "u_long" "ac_cv_type_u_long" "$ac_includes_default" if test "x$ac_cv_type_u_long" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_U_LONG 1 _ACEOF fi # from Python, check for "long long" type { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long support" >&5 $as_echo_n "checking for long long support... " >&6; } have_long_long=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { long long x; x = (long long)0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_LONG_LONG 1" >>confdefs.h have_long_long=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_long_long" >&5 $as_echo "$have_long_long" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t in " >&5 $as_echo_n "checking for socklen_t in ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { socklen_t len ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; $as_echo "#define socklen_t int" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for union semun in " >&5 $as_echo_n "checking for union semun in ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { union semun test_semun ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; $as_echo "#define HAVE_UNION_SEMUN 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct flock in fcntl.h" >&5 $as_echo_n "checking for struct flock in fcntl.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "struct flock" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } ; $as_echo "#define HAVE_STRUCT_FLOCK 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest* { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux ioctl defines" >&5 $as_echo_n "checking for Linux ioctl defines... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { __u32 houba = _IOR('v',14, unsigned long); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; have_linux_ioctl_defines="yes"; else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } if ${ac_cv_working_alloca_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char *p = (char *) alloca (2 * sizeof (int)); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_working_alloca_h=yes else ac_cv_working_alloca_h=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 $as_echo "$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then $as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } if ${ac_cv_func_alloca_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # ifdef _MSC_VER # include # define alloca _alloca # else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ void *alloca (size_t); # endif # endif # endif # endif #endif int main () { char *p = (char *) alloca (1); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_alloca_works=yes else ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 $as_echo "$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h else # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=\${LIBOBJDIR}alloca.$ac_objext $as_echo "#define C_ALLOCA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } if ${ac_cv_os_cray+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined CRAY && ! defined CRAY2 webecray #else wenotbecray #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "webecray" >/dev/null 2>&1; then : ac_cv_os_cray=yes else ac_cv_os_cray=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 $as_echo "$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } if ${ac_cv_c_stack_direction+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_c_stack_direction=0 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int find_stack_direction (int *addr, int depth) { int dir, dummy = 0; if (! addr) addr = &dummy; *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; dir = depth ? find_stack_direction (addr, depth - 1) : 0; return dir + dummy; } int main (int argc, char **argv) { return find_stack_direction (0, argc + !argv + 20) < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_stack_direction=1 else ac_cv_c_stack_direction=-1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 $as_echo "$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi ac_fn_c_check_func "$LINENO" "getenv" "ac_cv_func_getenv" if test "x$ac_cv_func_getenv" = xyes; then : $as_echo "#define HAVE_GETENV 1" >>confdefs.h else case " $LIBOBJS " in *" getenv.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getenv.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop" if test "x$ac_cv_func_inet_ntop" = xyes; then : $as_echo "#define HAVE_INET_NTOP 1" >>confdefs.h else case " $LIBOBJS " in *" inet_ntop.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS inet_ntop.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton" if test "x$ac_cv_func_inet_pton" = xyes; then : $as_echo "#define HAVE_INET_PTON 1" >>confdefs.h else case " $LIBOBJS " in *" inet_pton.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS inet_pton.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "sigprocmask" "ac_cv_func_sigprocmask" if test "x$ac_cv_func_sigprocmask" = xyes; then : $as_echo "#define HAVE_SIGPROCMASK 1" >>confdefs.h else case " $LIBOBJS " in *" sigprocmask.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS sigprocmask.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "sleep" "ac_cv_func_sleep" if test "x$ac_cv_func_sleep" = xyes; then : $as_echo "#define HAVE_SLEEP 1" >>confdefs.h else case " $LIBOBJS " in *" sleep.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS sleep.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf" if test "x$ac_cv_func_snprintf" = xyes; then : $as_echo "#define HAVE_SNPRINTF 1" >>confdefs.h else case " $LIBOBJS " in *" snprintf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS snprintf.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strcasestr" "ac_cv_func_strcasestr" if test "x$ac_cv_func_strcasestr" = xyes; then : $as_echo "#define HAVE_STRCASESTR 1" >>confdefs.h else case " $LIBOBJS " in *" strcasestr.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strcasestr.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" if test "x$ac_cv_func_strdup" = xyes; then : $as_echo "#define HAVE_STRDUP 1" >>confdefs.h else case " $LIBOBJS " in *" strdup.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strdup.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strndup" "ac_cv_func_strndup" if test "x$ac_cv_func_strndup" = xyes; then : $as_echo "#define HAVE_STRNDUP 1" >>confdefs.h else case " $LIBOBJS " in *" strndup.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strndup.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strsep" "ac_cv_func_strsep" if test "x$ac_cv_func_strsep" = xyes; then : $as_echo "#define HAVE_STRSEP 1" >>confdefs.h else case " $LIBOBJS " in *" strsep.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strsep.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "syslog" "ac_cv_func_syslog" if test "x$ac_cv_func_syslog" = xyes; then : $as_echo "#define HAVE_SYSLOG 1" >>confdefs.h else case " $LIBOBJS " in *" syslog.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS syslog.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "usleep" "ac_cv_func_usleep" if test "x$ac_cv_func_usleep" = xyes; then : $as_echo "#define HAVE_USLEEP 1" >>confdefs.h else case " $LIBOBJS " in *" usleep.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS usleep.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "vsyslog" "ac_cv_func_vsyslog" if test "x$ac_cv_func_vsyslog" = xyes; then : $as_echo "#define HAVE_VSYSLOG 1" >>confdefs.h else case " $LIBOBJS " in *" vsyslog.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS vsyslog.$ac_objext" ;; esac fi if test x != x$ALLOCA; then : LTALLOCA=`echo "$ALLOCA" | sed 's/\.o$//; s/\.obj$//'`.lo fi ac_fn_c_check_func "$LINENO" "gethostbyaddr" "ac_cv_func_gethostbyaddr" if test "x$ac_cv_func_gethostbyaddr" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyaddr in -lbind" >&5 $as_echo_n "checking for gethostbyaddr in -lbind... " >&6; } if ${ac_cv_lib_bind_gethostbyaddr+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbind $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyaddr (); int main () { return gethostbyaddr (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_bind_gethostbyaddr=yes else ac_cv_lib_bind_gethostbyaddr=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bind_gethostbyaddr" >&5 $as_echo "$ac_cv_lib_bind_gethostbyaddr" >&6; } if test "x$ac_cv_lib_bind_gethostbyaddr" = xyes; then : BIND_LIB="-lbind" fi fi ac_fn_c_check_func "$LINENO" "gethostbyaddr" "ac_cv_func_gethostbyaddr" if test "x$ac_cv_func_gethostbyaddr" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyaddr in -lnsl" >&5 $as_echo_n "checking for gethostbyaddr in -lnsl... " >&6; } if ${ac_cv_lib_nsl_gethostbyaddr+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyaddr (); int main () { return gethostbyaddr (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nsl_gethostbyaddr=yes else ac_cv_lib_nsl_gethostbyaddr=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyaddr" >&5 $as_echo "$ac_cv_lib_nsl_gethostbyaddr" >&6; } if test "x$ac_cv_lib_nsl_gethostbyaddr" = xyes; then : NSL_LIB="-lnsl" fi fi ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket" if test "x$ac_cv_func_socket" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 $as_echo_n "checking for socket in -lsocket... " >&6; } if ${ac_cv_lib_socket_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char socket (); int main () { return socket (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_socket_socket=yes else ac_cv_lib_socket_socket=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 $as_echo "$ac_cv_lib_socket_socket" >&6; } if test "x$ac_cv_lib_socket_socket" = xyes; then : SOCKET_LIB="-lsocket" fi fi ac_fn_c_check_func "$LINENO" "inet_aton" "ac_cv_func_inet_aton" if test "x$ac_cv_func_inet_aton" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton in -lresolv" >&5 $as_echo_n "checking for inet_aton in -lresolv... " >&6; } if ${ac_cv_lib_resolv_inet_aton+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lresolv $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char inet_aton (); int main () { return inet_aton (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_resolv_inet_aton=yes else ac_cv_lib_resolv_inet_aton=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_inet_aton" >&5 $as_echo "$ac_cv_lib_resolv_inet_aton" >&6; } if test "x$ac_cv_lib_resolv_inet_aton" = xyes; then : RESOLV_LIB="-lresolv" fi fi SOCKET_LIBS="$SOCKET_LIB $NSL_LIB $BIND_LIB $RESOLV_LIB" save_LIBS="$LIBS" LIBS="$LIBS $SOCKET_LIBS" for ac_func in inet_addr inet_aton inet_ntoa do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done LIBS="$save_LIBS" if test "$ac_cv_header_be_kernel_OS_h" = "yes" ; then ac_cv_func_getaddrinfo=no ac_cv_func_getnameinfo=no fi for ac_header in $ac_header_list do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in getpagesize do : ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" if test "x$ac_cv_func_getpagesize" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETPAGESIZE 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 $as_echo_n "checking for working mmap... " >&6; } if ${ac_cv_func_mmap_fixed_mapped+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_mmap_fixed_mapped=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default /* malloc might have been renamed as rpl_malloc. */ #undef malloc /* Thanks to Mike Haertel and Jim Avera for this test. Here is a matrix of mmap possibilities: mmap private not fixed mmap private fixed at somewhere currently unmapped mmap private fixed at somewhere already mapped mmap shared not fixed mmap shared fixed at somewhere currently unmapped mmap shared fixed at somewhere already mapped For private mappings, we should verify that changes cannot be read() back from the file, nor mmap's back from the file at a different address. (There have been systems where private was not correctly implemented like the infamous i386 svr4.0, and systems where the VM page cache was not coherent with the file system buffer cache like early versions of FreeBSD and possibly contemporary NetBSD.) For shared mappings, we should conversely verify that changes get propagated back to all the places they're supposed to be. Grep wants private fixed already mapped. The main things grep needs to know about mmap are: * does it exist and is it safe to write into the mmap'd area * how to use it (BSD variants) */ #include #include #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H char *malloc (); #endif /* This mess was copied from the GNU getpagesize.h. */ #ifndef HAVE_GETPAGESIZE # ifdef _SC_PAGESIZE # define getpagesize() sysconf(_SC_PAGESIZE) # else /* no _SC_PAGESIZE */ # ifdef HAVE_SYS_PARAM_H # include # ifdef EXEC_PAGESIZE # define getpagesize() EXEC_PAGESIZE # else /* no EXEC_PAGESIZE */ # ifdef NBPG # define getpagesize() NBPG * CLSIZE # ifndef CLSIZE # define CLSIZE 1 # endif /* no CLSIZE */ # else /* no NBPG */ # ifdef NBPC # define getpagesize() NBPC # else /* no NBPC */ # ifdef PAGESIZE # define getpagesize() PAGESIZE # endif /* PAGESIZE */ # endif /* no NBPC */ # endif /* no NBPG */ # endif /* no EXEC_PAGESIZE */ # else /* no HAVE_SYS_PARAM_H */ # define getpagesize() 8192 /* punt totally */ # endif /* no HAVE_SYS_PARAM_H */ # endif /* no _SC_PAGESIZE */ #endif /* no HAVE_GETPAGESIZE */ int main () { char *data, *data2, *data3; const char *cdata2; int i, pagesize; int fd, fd2; pagesize = getpagesize (); /* First, make a file with some known garbage in it. */ data = (char *) malloc (pagesize); if (!data) return 1; for (i = 0; i < pagesize; ++i) *(data + i) = rand (); umask (0); fd = creat ("conftest.mmap", 0600); if (fd < 0) return 2; if (write (fd, data, pagesize) != pagesize) return 3; close (fd); /* Next, check that the tail of a page is zero-filled. File must have non-zero length, otherwise we risk SIGBUS for entire page. */ fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); if (fd2 < 0) return 4; cdata2 = ""; if (write (fd2, cdata2, 1) != 1) return 5; data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); if (data2 == MAP_FAILED) return 6; for (i = 0; i < pagesize; ++i) if (*(data2 + i)) return 7; close (fd2); if (munmap (data2, pagesize)) return 8; /* Next, try to mmap the file at a fixed address which already has something else allocated at it. If we can, also make sure that we see the same garbage. */ fd = open ("conftest.mmap", O_RDWR); if (fd < 0) return 9; if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0L)) return 10; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data2 + i)) return 11; /* Finally, make sure that changes to the mapped area do not percolate back to the file as seen by read(). (This is a bug on some variants of i386 svr4.0.) */ for (i = 0; i < pagesize; ++i) *(data2 + i) = *(data2 + i) + 1; data3 = (char *) malloc (pagesize); if (!data3) return 12; if (read (fd, data3, pagesize) != pagesize) return 13; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data3 + i)) return 14; close (fd); free (data); free (data3); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_mmap_fixed_mapped=yes else ac_cv_func_mmap_fixed_mapped=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 $as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; } if test $ac_cv_func_mmap_fixed_mapped = yes; then $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt for ac_func in atexit ioperm i386_set_ioperm \ mkdir strftime strstr strtod \ cfmakeraw tcsendbreak strcasecmp strncasecmp _portaccess \ getaddrinfo getnameinfo poll setitimer iopl getuid getpass do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "${ac_cv_header_sys_io_h}" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inb,outb (provided by sys/io.h)" >&5 $as_echo_n "checking for inb,outb (provided by sys/io.h)... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { inb(0);outb(0,0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } sane_cv_have_sys_io_h_with_inb_outb="yes" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } sane_cv_have_sys_io_h_with_inb_outb="no" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: sys/io.h does not provide inb,outb (non i386/x32/x86_64 arch?)" >&5 $as_echo "$as_me: WARNING: sys/io.h does not provide inb,outb (non i386/x32/x86_64 arch?)" >&2;} fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$sane_cv_have_sys_io_h_with_inb_outb" = "yes"; then $as_echo "#define SANE_HAVE_SYS_IO_H_WITH_INB_OUTB 1" >>confdefs.h fi else sane_cv_have_sys_io_h_with_inb_outb="no" fi if test "$ac_cv_header_os2_h" = "yes" ; then $as_echo "#define strncasecmp strnicmp" >>confdefs.h $as_echo "#define strcasecmp stricmp" >>confdefs.h fi if test "$ac_cv_header_getopt_h" = "yes" ; then for ac_func in getopt_long do : ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long" if test "x$ac_cv_func_getopt_long" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETOPT_LONG 1 _ACEOF fi done fi # Slightly abuse the AC_LIBOBJ macro to mark files as replacement code if test x$ac_cv_header_getopt_h != xyes \ && test x$ac_cv_func_getopt_long != xyes; then : case " $LIBOBJS " in *" getopt.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt.$ac_objext" ;; esac case " $LIBOBJS " in *" getopt1.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt1.$ac_objext" ;; esac fi if test -c /dev/urandom ; then $as_echo "#define HAVE_DEV_URANDOM 1" >>confdefs.h fi # Check whether --with-systemd was given. if test "${with_systemd+set}" = set; then : withval=$with_systemd; fi if test "x$with_systemd" != xno ; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SYSTEMD" >&5 $as_echo_n "checking for SYSTEMD... " >&6; } if test -n "$SYSTEMD_CFLAGS"; then pkg_cv_SYSTEMD_CFLAGS="$SYSTEMD_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd\""; } >&5 ($PKG_CONFIG --exists --print-errors "libsystemd") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SYSTEMD_CFLAGS=`$PKG_CONFIG --cflags "libsystemd" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$SYSTEMD_LIBS"; then pkg_cv_SYSTEMD_LIBS="$SYSTEMD_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd\""; } >&5 ($PKG_CONFIG --exists --print-errors "libsystemd") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SYSTEMD_LIBS=`$PKG_CONFIG --libs "libsystemd" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libsystemd" 2>&1` else SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libsystemd" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$SYSTEMD_PKG_ERRORS" >&5 have_systemd=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_systemd=no else SYSTEMD_CFLAGS=$pkg_cv_SYSTEMD_CFLAGS SYSTEMD_LIBS=$pkg_cv_SYSTEMD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_systemd=yes fi if test "x$have_systemd" = xno; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SYSTEMD" >&5 $as_echo_n "checking for SYSTEMD... " >&6; } if test -n "$SYSTEMD_CFLAGS"; then pkg_cv_SYSTEMD_CFLAGS="$SYSTEMD_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd-daemon\""; } >&5 ($PKG_CONFIG --exists --print-errors "libsystemd-daemon") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SYSTEMD_CFLAGS=`$PKG_CONFIG --cflags "libsystemd-daemon" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$SYSTEMD_LIBS"; then pkg_cv_SYSTEMD_LIBS="$SYSTEMD_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libsystemd-daemon\""; } >&5 ($PKG_CONFIG --exists --print-errors "libsystemd-daemon") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SYSTEMD_LIBS=`$PKG_CONFIG --libs "libsystemd-daemon" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libsystemd-daemon" 2>&1` else SYSTEMD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libsystemd-daemon" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$SYSTEMD_PKG_ERRORS" >&5 have_systemd=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_systemd=no else SYSTEMD_CFLAGS=$pkg_cv_SYSTEMD_CFLAGS SYSTEMD_LIBS=$pkg_cv_SYSTEMD_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_systemd=yes fi fi if test "x$have_systemd" = xyes; then $as_echo "#define HAVE_SYSTEMD 1" >>confdefs.h else if test "x$with_systemd" = xyes; then as_fn_error $? "Systemd support was requested but systemd was not found" "$LINENO" 5 fi fi fi # Check whether --with-usb was given. if test "${with_usb+set}" = set; then : withval=$with_usb; else with_usb=check fi if test xno != "x$with_usb"; then : have_usb=no case x$host_os in #( xbeos*) : ac_fn_c_check_header_mongrel "$LINENO" "be/drivers/USB_scanner.h" "ac_cv_header_be_drivers_USB_scanner_h" "$ac_includes_default" if test "x$ac_cv_header_be_drivers_USB_scanner_h" = xyes; then : have_usb=yes fi ;; #( xos2*) : ac_fn_c_check_header_compile "$LINENO" "usbcalls.h" "ac_cv_header_usbcalls_h" "#include #include " if test "x$ac_cv_header_usbcalls_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for UsbQueryNumberDevices in -lusbcall" >&5 $as_echo_n "checking for UsbQueryNumberDevices in -lusbcall... " >&6; } if ${ac_cv_lib_usbcall_UsbQueryNumberDevices+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusbcall $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char UsbQueryNumberDevices (); int main () { return UsbQueryNumberDevices (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usbcall_UsbQueryNumberDevices=yes else ac_cv_lib_usbcall_UsbQueryNumberDevices=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usbcall_UsbQueryNumberDevices" >&5 $as_echo "$ac_cv_lib_usbcall_UsbQueryNumberDevices" >&6; } if test "x$ac_cv_lib_usbcall_UsbQueryNumberDevices" = xyes; then : USB_LIBS="-lusbcall" have_usb=yes $as_echo "#define HAVE_USBCALLS 1" >>confdefs.h fi fi ;; #( *) : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB" >&5 $as_echo_n "checking for USB... " >&6; } if test -n "$USB_CFLAGS"; then pkg_cv_USB_CFLAGS="$USB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_USB_CFLAGS=`$PKG_CONFIG --cflags "libusb-1.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$USB_LIBS"; then pkg_cv_USB_LIBS="$USB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb-1.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_USB_LIBS=`$PKG_CONFIG --libs "libusb-1.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then USB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb-1.0" 2>&1` else USB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb-1.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$USB_PKG_ERRORS" >&5 pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB" >&5 $as_echo_n "checking for USB... " >&6; } if test -n "$USB_CFLAGS"; then pkg_cv_USB_CFLAGS="$USB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb >= 0.1.8\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb >= 0.1.8") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_USB_CFLAGS=`$PKG_CONFIG --cflags "libusb >= 0.1.8" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$USB_LIBS"; then pkg_cv_USB_LIBS="$USB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb >= 0.1.8\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb >= 0.1.8") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_USB_LIBS=`$PKG_CONFIG --libs "libusb >= 0.1.8" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then USB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb >= 0.1.8" 2>&1` else USB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb >= 0.1.8" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$USB_PKG_ERRORS" >&5 ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" if test "x$ac_cv_header_usb_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_interrupt_read in -lusb" >&5 $as_echo_n "checking for usb_interrupt_read in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_interrupt_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_interrupt_read (); int main () { return usb_interrupt_read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_interrupt_read=yes else ac_cv_lib_usb_usb_interrupt_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 $as_echo "$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test "x$ac_cv_lib_usb_usb_interrupt_read" = xyes; then : USB_LIBS="-lusb" have_usb=yes fi fi for ac_header in lusb0_usb.h do : ac_fn_c_check_header_mongrel "$LINENO" "lusb0_usb.h" "ac_cv_header_lusb0_usb_h" "$ac_includes_default" if test "x$ac_cv_header_lusb0_usb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LUSB0_USB_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_interrupt_read in -lusb" >&5 $as_echo_n "checking for usb_interrupt_read in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_interrupt_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_interrupt_read (); int main () { return usb_interrupt_read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_interrupt_read=yes else ac_cv_lib_usb_usb_interrupt_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 $as_echo "$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test "x$ac_cv_lib_usb_usb_interrupt_read" = xyes; then : USB_LIBS="-lusb" have_usb=yes fi fi done elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" if test "x$ac_cv_header_usb_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_interrupt_read in -lusb" >&5 $as_echo_n "checking for usb_interrupt_read in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_interrupt_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_interrupt_read (); int main () { return usb_interrupt_read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_interrupt_read=yes else ac_cv_lib_usb_usb_interrupt_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 $as_echo "$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test "x$ac_cv_lib_usb_usb_interrupt_read" = xyes; then : USB_LIBS="-lusb" have_usb=yes fi fi for ac_header in lusb0_usb.h do : ac_fn_c_check_header_mongrel "$LINENO" "lusb0_usb.h" "ac_cv_header_lusb0_usb_h" "$ac_includes_default" if test "x$ac_cv_header_lusb0_usb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LUSB0_USB_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_interrupt_read in -lusb" >&5 $as_echo_n "checking for usb_interrupt_read in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_interrupt_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_interrupt_read (); int main () { return usb_interrupt_read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_interrupt_read=yes else ac_cv_lib_usb_usb_interrupt_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 $as_echo "$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test "x$ac_cv_lib_usb_usb_interrupt_read" = xyes; then : USB_LIBS="-lusb" have_usb=yes fi fi done else USB_CFLAGS=$pkg_cv_USB_CFLAGS USB_LIBS=$pkg_cv_USB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LIBUSB_LEGACY 1" >>confdefs.h have_usb=yes fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB" >&5 $as_echo_n "checking for USB... " >&6; } if test -n "$USB_CFLAGS"; then pkg_cv_USB_CFLAGS="$USB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb >= 0.1.8\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb >= 0.1.8") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_USB_CFLAGS=`$PKG_CONFIG --cflags "libusb >= 0.1.8" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$USB_LIBS"; then pkg_cv_USB_LIBS="$USB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb >= 0.1.8\""; } >&5 ($PKG_CONFIG --exists --print-errors "libusb >= 0.1.8") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_USB_LIBS=`$PKG_CONFIG --libs "libusb >= 0.1.8" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then USB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb >= 0.1.8" 2>&1` else USB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb >= 0.1.8" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$USB_PKG_ERRORS" >&5 ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" if test "x$ac_cv_header_usb_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_interrupt_read in -lusb" >&5 $as_echo_n "checking for usb_interrupt_read in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_interrupt_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_interrupt_read (); int main () { return usb_interrupt_read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_interrupt_read=yes else ac_cv_lib_usb_usb_interrupt_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 $as_echo "$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test "x$ac_cv_lib_usb_usb_interrupt_read" = xyes; then : USB_LIBS="-lusb" have_usb=yes fi fi for ac_header in lusb0_usb.h do : ac_fn_c_check_header_mongrel "$LINENO" "lusb0_usb.h" "ac_cv_header_lusb0_usb_h" "$ac_includes_default" if test "x$ac_cv_header_lusb0_usb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LUSB0_USB_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_interrupt_read in -lusb" >&5 $as_echo_n "checking for usb_interrupt_read in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_interrupt_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_interrupt_read (); int main () { return usb_interrupt_read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_interrupt_read=yes else ac_cv_lib_usb_usb_interrupt_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 $as_echo "$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test "x$ac_cv_lib_usb_usb_interrupt_read" = xyes; then : USB_LIBS="-lusb" have_usb=yes fi fi done elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ac_fn_c_check_header_mongrel "$LINENO" "usb.h" "ac_cv_header_usb_h" "$ac_includes_default" if test "x$ac_cv_header_usb_h" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_interrupt_read in -lusb" >&5 $as_echo_n "checking for usb_interrupt_read in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_interrupt_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_interrupt_read (); int main () { return usb_interrupt_read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_interrupt_read=yes else ac_cv_lib_usb_usb_interrupt_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 $as_echo "$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test "x$ac_cv_lib_usb_usb_interrupt_read" = xyes; then : USB_LIBS="-lusb" have_usb=yes fi fi for ac_header in lusb0_usb.h do : ac_fn_c_check_header_mongrel "$LINENO" "lusb0_usb.h" "ac_cv_header_lusb0_usb_h" "$ac_includes_default" if test "x$ac_cv_header_lusb0_usb_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LUSB0_USB_H 1 _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_interrupt_read in -lusb" >&5 $as_echo_n "checking for usb_interrupt_read in -lusb... " >&6; } if ${ac_cv_lib_usb_usb_interrupt_read+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lusb $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char usb_interrupt_read (); int main () { return usb_interrupt_read (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_usb_usb_interrupt_read=yes else ac_cv_lib_usb_usb_interrupt_read=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 $as_echo "$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test "x$ac_cv_lib_usb_usb_interrupt_read" = xyes; then : USB_LIBS="-lusb" have_usb=yes fi fi done else USB_CFLAGS=$pkg_cv_USB_CFLAGS USB_LIBS=$pkg_cv_USB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LIBUSB_LEGACY 1" >>confdefs.h have_usb=yes fi else USB_CFLAGS=$pkg_cv_USB_CFLAGS USB_LIBS=$pkg_cv_USB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LIBUSB 1" >>confdefs.h have_usb=yes fi ;; esac fi if test xyes = "x$with_usb" && test xyes != "x$have_usb"; then : as_fn_error $? "USB support requested but required libraries not found." "$LINENO" 5 fi if test x != "x$USB_LIBS"; then have_usblib_TRUE= have_usblib_FALSE='#' else have_usblib_TRUE='#' have_usblib_FALSE= fi # Check whether --with-libcurl was given. if test "${with_libcurl+set}" = set; then : withval=$with_libcurl; else with_libcurl=check fi $as_echo "#define HAVE_LIBCURL 0" >>confdefs.h if test xno != "x$with_libcurl"; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libcurl" >&5 $as_echo_n "checking for libcurl... " >&6; } if test -n "$libcurl_CFLAGS"; then pkg_cv_libcurl_CFLAGS="$libcurl_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcurl\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcurl") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_libcurl_CFLAGS=`$PKG_CONFIG --cflags "libcurl" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$libcurl_LIBS"; then pkg_cv_libcurl_LIBS="$libcurl_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libcurl\""; } >&5 ($PKG_CONFIG --exists --print-errors "libcurl") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_libcurl_LIBS=`$PKG_CONFIG --libs "libcurl" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then libcurl_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libcurl" 2>&1` else libcurl_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libcurl" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$libcurl_PKG_ERRORS" >&5 if test xcheck != "x$with_libcurl"; then : as_fn_error $? "libcurl requested but not found" "$LINENO" 5 fi with_libcurl=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if test xcheck != "x$with_libcurl"; then : as_fn_error $? "libcurl requested but not found" "$LINENO" 5 fi with_libcurl=no else libcurl_CFLAGS=$pkg_cv_libcurl_CFLAGS libcurl_LIBS=$pkg_cv_libcurl_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_LIBCURL 1" >>confdefs.h with_libcurl=yes fi fi if test x != "x$libcurl_LIBS"; then have_libcurl_TRUE= have_libcurl_FALSE='#' else have_libcurl_TRUE='#' have_libcurl_FALSE= fi # Check whether --with-usb_record_replay was given. if test "${with_usb_record_replay+set}" = set; then : withval=$with_usb_record_replay; fi if test "x$with_usb_record_replay" != "xno"; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XML" >&5 $as_echo_n "checking for XML... " >&6; } if test -n "$XML_CFLAGS"; then pkg_cv_XML_CFLAGS="$XML_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxml-2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libxml-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_XML_CFLAGS=`$PKG_CONFIG --cflags "libxml-2.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$XML_LIBS"; then pkg_cv_XML_LIBS="$XML_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxml-2.0\""; } >&5 ($PKG_CONFIG --exists --print-errors "libxml-2.0") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_XML_LIBS=`$PKG_CONFIG --libs "libxml-2.0" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then XML_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libxml-2.0" 2>&1` else XML_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libxml-2.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$XML_PKG_ERRORS" >&5 have_libxml=no elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_libxml=no else XML_CFLAGS=$pkg_cv_XML_CFLAGS XML_LIBS=$pkg_cv_XML_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } have_libxml=yes fi if test "x$have_libxml" = xyes; then $as_echo "#define HAVE_LIBXML2 1" >>confdefs.h $as_echo "#define WITH_USB_RECORD_REPLAY 1" >>confdefs.h else if test "x$with_usb_record_replay" = xyes; then as_fn_error $? "USB record and replay support was requested but libxml-2.0 was not found" "$LINENO" 5 fi fi fi if test x != "x$XML_LIBS"; then have_libxml2_TRUE= have_libxml2_FALSE='#' else have_libxml2_TRUE='#' have_libxml2_FALSE= fi # Unset VERSION during the SCSI header check sed "s!^#define VERSION .*!/* & */!" confdefs.h > confdefs.h.tmp mv confdefs.h.tmp confdefs.h for ac_header in IOKit/scsi/SCSITaskLib.h IOKit/cdb/IOSCSILib.h \ IOKit/scsi/SCSICommandOperationCodes.h \ IOKit/scsi-commands/SCSICommandOperationCodes.h scsi.h sys/scsi.h \ sys/scsicmd.h sys/scsiio.h bsd/dev/scsireg.h scsi/sg.h \ camlib.h gscdds.h sys/scsi/scsi.h sys/scsi/sgdefs.h \ sys/scsi/targets/scgio.h apollo/scsi.h sys/sdi_comm.h \ sys/passthrudef.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Restore VERSION sed "s!/\* \(#define VERSION .*\) \*/!\1!" confdefs.h > confdefs.h.tmp mv confdefs.h.tmp confdefs.h for ac_header in io/cam/cam.h do : ac_fn_c_check_header_compile "$LINENO" "io/cam/cam.h" "ac_cv_header_io_cam_cam_h" "#include " if test "x$ac_cv_header_io_cam_cam_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_IO_CAM_CAM_H 1 _ACEOF fi done for ac_header in ntddscsi.h ddk/ntddscsi.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done if test "$ac_cv_header_sys_scsiio_h" = "yes" \ && test "$ac_cv_header_scsi_h" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if 'scsireq_t' needs to be defined as 'struct scsireq'" >&5 $as_echo_n "checking if 'scsireq_t' needs to be defined as 'struct scsireq'... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { scsireq_t req ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; $as_echo "#define scsireq_t struct scsireq_t" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for scsireq_enter in -lscsi" >&5 $as_echo_n "checking for scsireq_enter in -lscsi... " >&6; } if ${ac_cv_lib_scsi_scsireq_enter+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lscsi $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char scsireq_enter (); int main () { return scsireq_enter (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_scsi_scsireq_enter=yes else ac_cv_lib_scsi_scsireq_enter=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_scsi_scsireq_enter" >&5 $as_echo "$ac_cv_lib_scsi_scsireq_enter" >&6; } if test "x$ac_cv_lib_scsi_scsireq_enter" = xyes; then : SCSI_LIBS="-lscsi" fi # FreeBSD needs this { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cam_open_device in -lcam" >&5 $as_echo_n "checking for cam_open_device in -lcam... " >&6; } if ${ac_cv_lib_cam_cam_open_device+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcam $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char cam_open_device (); int main () { return cam_open_device (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_cam_cam_open_device=yes else ac_cv_lib_cam_cam_open_device=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cam_cam_open_device" >&5 $as_echo "$ac_cv_lib_cam_cam_open_device" >&6; } if test "x$ac_cv_lib_cam_cam_open_device" = xyes; then : SCSI_LIBS="-lcam" fi # FreeBSD 3+ needs this for ac_func in scsireq_enter do : ac_fn_c_check_func "$LINENO" "scsireq_enter" "ac_cv_func_scsireq_enter" if test "x$ac_cv_func_scsireq_enter" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SCSIREQ_ENTER 1 _ACEOF fi done if test "$ac_cv_header_scsi_sg_h" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sg_header.target_status in " >&5 $as_echo_n "checking for sg_header.target_status in ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct sg_header hdr; hdr.target_status = 1; return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; $as_echo "#define HAVE_SG_TARGET_STATUS 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$ac_cv_header_IOKit_scsi_SCSITaskLib_h" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SCSITaskSGElement in IOKit/scsi/SCSITaskLib.h" >&5 $as_echo_n "checking for SCSITaskSGElement in IOKit/scsi/SCSITaskLib.h... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #undef VERSION #include int main () { SCSITaskSGElement range; return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; $as_echo "#define HAVE_SCSITASKSGELEMENT 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi # Multiple platforms can set SCSI_LIBS so do substitution at end. # Check whether --enable-scsibuffersize was given. if test "${enable_scsibuffersize+set}" = set; then : enableval=$enable_scsibuffersize; set_scsibuffersize="$enableval" else set_scsibuffersize=131072 fi cat >>confdefs.h <<_ACEOF #define SCSIBUFFERSIZE $set_scsibuffersize _ACEOF echo "scsi buffersize: $set_scsibuffersize" # Check whether --enable-scsi-directio was given. if test "${enable_scsi_directio+set}" = set; then : enableval=$enable_scsi_directio; if eval "test x$enable_scsi_directio = xyes"; then AM_CFLAGS="$AM_CFLAGS -DENABLE_SCSI_DIRECTIO" fi fi if test "$ac_cv_func_getnameinfo" = "yes" \ && test "$ac_cv_func_getaddrinfo" = "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable IPv6" >&5 $as_echo_n "checking whether to enable IPv6... " >&6; } # Check whether --enable-ipv6 was given. if test "${enable_ipv6+set}" = set; then : enableval=$enable_ipv6; if test "$enableval" = "no" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, manually disabled" >&5 $as_echo "no, manually disabled" >&6; } ipv6=no fi fi if test "$ipv6" != "no" ; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define INET6 #include #include int main () { /* AF_INET6 available check */ if (socket(AF_INET6, SOCK_STREAM, 0) < 0) exit(1); else exit(0); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define ENABLE_IPV6 1" >>confdefs.h ipv6=yes else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no (couldn't compile test program)" >&5 $as_echo "no (couldn't compile test program)" >&6; } ipv6=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "$ipv6" != "no" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct sockaddr_storage has an ss_family member" >&5 $as_echo_n "checking whether struct sockaddr_storage has an ss_family member... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define INET6 #include #include int main () { /* test if the ss_family member exists in struct sockaddr_storage */ struct sockaddr_storage ss; ss.ss_family = AF_INET; exit (0); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAS_SS_FAMILY 1" >>confdefs.h else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define INET6 #include #include int main () { /* test if the __ss_family member exists in struct sockaddr_storage */ struct sockaddr_storage ss; ss.__ss_family = AF_INET; exit (0); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, but __ss_family exists" >&5 $as_echo "no, but __ss_family exists" >&6; } $as_echo "#define HAS___SS_FAMILY 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ipv6=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi else ipv6="no" fi # Check whether --enable-preload was given. if test "${enable_preload+set}" = set; then : enableval=$enable_preload; enable_preload=$enableval else enable_preload=auto fi case $host_os in cygwin* | mingw* | beos* | os2*) AM_LDFLAGS="$AM_LDFLAGS -no-undefined" esac # Check whether --with-lockdir was given. if test "${with_lockdir+set}" = set; then : withval=$with_lockdir; locksanedir=$withval else locksanedir=${localstatedir}/lock/sane fi configdir="${sysconfdir}/sane.d" AM_CPPFLAGS="${AM_CPPFLAGS} -DPATH_SANE_CONFIG_DIR=\$(configdir) \ -DPATH_SANE_DATA_DIR=\$(datadir) \ -DPATH_SANE_LOCK_DIR=\$(locksanedir) \ -DV_MAJOR=${V_MAJOR} -DV_MINOR=${V_MINOR}" if test "${ac_cv_header_sys_socket_h}" = "no"; then echo "*** disabling saned (sys/socket.h not found)" SANED= else SANED=saned fi if test x$SANED = xsaned; then COMPILE_SANED_TRUE= COMPILE_SANED_FALSE='#' else COMPILE_SANED_TRUE='#' COMPILE_SANED_FALSE= fi # Check whether --enable-local-backends was given. if test "${enable_local_backends+set}" = set; then : enableval=$enable_local_backends; fi ALL_BACKENDS="abaton agfafocus apple artec artec_eplus48u as6e \ avision bh canon canon630u canon_dr canon_pp cardscan \ coolscan coolscan2 coolscan3 dc25 dc210 dc240 \ dell1600n_net dmc epjitsu epson epson2 epsonds escl fujitsu \ genesys gphoto2 gt68xx hp hp3500 hp3900 hp4200 hp5400 \ hp5590 hpsj5s hpljm1005 hs2p ibm kodak kodakaio kvs1025 kvs20xx \ kvs40xx leo lexmark ma1509 magicolor \ matsushita microtek microtek2 mustek mustek_pp \ mustek_usb mustek_usb2 nec net niash pie pieusb pint \ pixma plustek plustek_pp qcam ricoh ricoh2 rts8891 s9036 \ sceptre sharp sm3600 sm3840 snapscan sp15c st400 \ stv680 tamarack teco1 teco2 teco3 test u12 umax umax_pp umax1220u v4l xerox_mfp p5" # If user specifies backends manually then cause configure # to fail if its detected it can't be compiled. If we # are in automatic mode then remove backend from list instead. user_selected_backends="yes" if eval "test x$enable_local_backends = xno"; then BACKENDS="net" else if test "${BACKENDS}" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Manually selected backends: ${BACKENDS}" >&5 $as_echo "$as_me: Manually selected backends: ${BACKENDS}" >&6;} else BACKENDS="$ALL_BACKENDS" user_selected_backends="no" fi fi if test "${user_selected_backends}" = "yes"; then DISABLE_MSG="aborting" else DISABLE_MSG="disabling" fi FILTERED_BACKENDS="" for be in ${BACKENDS}; do backend_supported="yes" case $be in plustek_pp) case "$host_os" in gnu*) echo "*** $be backend not supported on GNU/Hurd - $DISABLE_MSG" backend_supported="no" ;; esac ;; dc210|dc240|pixma) if test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; canon_pp|hpsj5s) if test "${sane_cv_use_libieee1284}" != "yes"; then echo "*** $be backend requires libieee1284 library - $DISABLE_MSG" backend_supported="no" fi ;; genesys) if test "${HAVE_CXX11}" != "1"; then echo "*** $be backend requires C++11 support - $DISABLE_MSG" backend_supported="no" fi ;; mustek_pp) if test "${sane_cv_use_libieee1284}" != "yes" && test "${enable_parport_directio}" != "yes"; then echo "*** $be backend requires libieee1284 or parport-directio libraries - $DISABLE_MSG" backend_supported="no" fi ;; dell1600n_net) if test "${sane_cv_use_libjpeg}" != "yes" || test "${sane_cv_use_libtiff}" != "yes"; then echo "*** $be backend requires JPEG and TIFF library - $DISABLE_MSG" backend_supported="no" fi ;; epsonds) if test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; escl) if test "x${enable_avahi}" != "xyes"; then echo "*** $be backend requires AVAHI library - $DISABLE_MSG" backend_supported="no" fi if test "x${with_libcurl}" != "xyes"; then echo "*** $be backend requires cURL library - $DISABLE_MSG" backend_supported="no" fi if test "x${have_libxml}" != "xyes"; then echo "*** $be backend requires XML library - $DISABLE_MSG" backend_supported="no" fi # FIXME: Remove when PNG and/or PDF support have been added. if test "x${sane_cv_use_libjpeg}" != "xyes"; then echo "*** $be backend currently requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; gphoto2) if test "${HAVE_GPHOTO2}" != "true" \ || test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires gphoto2 and JPEG libraries - $DISABLE_MSG" backend_supported="no" fi ;; pint) if test "${ac_cv_header_sys_scanio_h}" = "no"; then echo "*** $be backend requires sys/scanio.h - $DISABLE_MSG" backend_supported="no" fi ;; qcam) if ( test "${ac_cv_func_ioperm}" = "no" || test "${sane_cv_have_sys_io_h_with_inb_outb}" = "no" )\ && test "${ac_cv_func__portaccess}" = "no"; then echo "*** $be backend requires (ioperm, inb and outb) or portaccess functions - $DISABLE_MSG" backend_supported="no" fi ;; v4l) if test "${have_linux_ioctl_defines}" != "yes" \ || test "${have_libv4l1}" != "yes"; then echo "*** $be backend requires v4l libraries - $DISABLE_MSG" backend_supported="no" fi ;; net) if test "${ac_cv_header_sys_socket_h}" = "no"; then echo "*** $be backend requires sys/socket.h - $DISABLE_MSG" backend_supported="no" fi ;; mustek_usb2|kvs40xx) if test "${have_pthread}" != "yes"; then echo "*** $be backend requires pthread library - $DISABLE_MSG" backend_supported="no" fi ;; esac if test "${backend_supported}" = "no"; then if test "${user_selected_backends}" = "yes"; then exit 1 fi else FILTERED_BACKENDS="${FILTERED_BACKENDS} $be" fi done if test "${sane_cv_use_libjpeg}" = "yes"; then SANEI_SANEI_JPEG_LO="../sanei/sanei_jpeg.lo" fi if test x$sane_cv_use_libjpeg = xyes; then HAVE_JPEG_TRUE= HAVE_JPEG_FALSE='#' else HAVE_JPEG_TRUE='#' HAVE_JPEG_FALSE= fi # Check whether --enable-pnm-backend was given. if test "${enable_pnm_backend+set}" = set; then : enableval=$enable_pnm_backend; FILTERED_BACKENDS="${FILTERED_BACKENDS} pnm" else echo "*** pnm backend not manually selected - disabling" fi BACKENDS="$FILTERED_BACKENDS" BACKEND_LIBS_ENABLED="" BACKEND_CONFS_ENABLED="" BACKEND_MANS_ENABLED="" for backend in ${BACKENDS} ; do BACKEND_LIBS_ENABLED="${BACKEND_LIBS_ENABLED} libsane-${backend}.la" BACKEND_CONFS_ENABLED="${BACKEND_CONFS_ENABLED} ${backend}.conf" BACKEND_MANS_ENABLED="${BACKEND_MANS_ENABLED} sane-${backend}.5" if test x$backend = xumax_pp; then install_umax_pp_tools=yes fi done if test xyes = x$install_umax_pp_tools; then INSTALL_UMAX_PP_TOOLS_TRUE= INSTALL_UMAX_PP_TOOLS_FALSE='#' else INSTALL_UMAX_PP_TOOLS_TRUE='#' INSTALL_UMAX_PP_TOOLS_FALSE= fi if test "${enable_preload}" = "auto"; then if test "${enable_shared}" = "no" || test "${enable_dynamic}" != "yes"; then enable_preload=yes fi fi if test "${enable_preload}" = "yes"; then echo "preloading backends into DLL" # If user specifies backends manually then cause configure # to fail if its detected it can't be compiled. If we # are in automatic mode then remove backend from list instead. user_selected_backends="yes" if eval "test x$enable_local_backends = xno"; then PRELOADABLE_BACKENDS="net" else if test "${PRELOADABLE_BACKENDS}" != "" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: Manually selected preloadable backends: ${PRELOADABLE_BACKENDS}" >&5 $as_echo "$as_me: Manually selected preloadable backends: ${PRELOADABLE_BACKENDS}" >&6;} else PRELOADABLE_BACKENDS="$BACKENDS" user_selected_backends="no" fi fi saved_BACKENDS="$BACKENDS" BACKENDS="${PRELOADABLE_BACKENDS}" if test "${user_selected_backends}" = "yes"; then DISABLE_MSG="aborting" else DISABLE_MSG="disabling" fi FILTERED_BACKENDS="" for be in ${BACKENDS}; do backend_supported="yes" case $be in plustek_pp) case "$host_os" in gnu*) echo "*** $be backend not supported on GNU/Hurd - $DISABLE_MSG" backend_supported="no" ;; esac ;; dc210|dc240|pixma) if test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; canon_pp|hpsj5s) if test "${sane_cv_use_libieee1284}" != "yes"; then echo "*** $be backend requires libieee1284 library - $DISABLE_MSG" backend_supported="no" fi ;; genesys) if test "${HAVE_CXX11}" != "1"; then echo "*** $be backend requires C++11 support - $DISABLE_MSG" backend_supported="no" fi ;; mustek_pp) if test "${sane_cv_use_libieee1284}" != "yes" && test "${enable_parport_directio}" != "yes"; then echo "*** $be backend requires libieee1284 or parport-directio libraries - $DISABLE_MSG" backend_supported="no" fi ;; dell1600n_net) if test "${sane_cv_use_libjpeg}" != "yes" || test "${sane_cv_use_libtiff}" != "yes"; then echo "*** $be backend requires JPEG and TIFF library - $DISABLE_MSG" backend_supported="no" fi ;; epsonds) if test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; escl) if test "x${enable_avahi}" != "xyes"; then echo "*** $be backend requires AVAHI library - $DISABLE_MSG" backend_supported="no" fi if test "x${with_libcurl}" != "xyes"; then echo "*** $be backend requires cURL library - $DISABLE_MSG" backend_supported="no" fi if test "x${have_libxml}" != "xyes"; then echo "*** $be backend requires XML library - $DISABLE_MSG" backend_supported="no" fi # FIXME: Remove when PNG and/or PDF support have been added. if test "x${sane_cv_use_libjpeg}" != "xyes"; then echo "*** $be backend currently requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; gphoto2) if test "${HAVE_GPHOTO2}" != "true" \ || test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires gphoto2 and JPEG libraries - $DISABLE_MSG" backend_supported="no" fi ;; pint) if test "${ac_cv_header_sys_scanio_h}" = "no"; then echo "*** $be backend requires sys/scanio.h - $DISABLE_MSG" backend_supported="no" fi ;; qcam) if ( test "${ac_cv_func_ioperm}" = "no" || test "${sane_cv_have_sys_io_h_with_inb_outb}" = "no" )\ && test "${ac_cv_func__portaccess}" = "no"; then echo "*** $be backend requires (ioperm, inb and outb) or portaccess functions - $DISABLE_MSG" backend_supported="no" fi ;; v4l) if test "${have_linux_ioctl_defines}" != "yes" \ || test "${have_libv4l1}" != "yes"; then echo "*** $be backend requires v4l libraries - $DISABLE_MSG" backend_supported="no" fi ;; net) if test "${ac_cv_header_sys_socket_h}" = "no"; then echo "*** $be backend requires sys/socket.h - $DISABLE_MSG" backend_supported="no" fi ;; mustek_usb2|kvs40xx) if test "${have_pthread}" != "yes"; then echo "*** $be backend requires pthread library - $DISABLE_MSG" backend_supported="no" fi ;; esac if test "${backend_supported}" = "no"; then if test "${user_selected_backends}" = "yes"; then exit 1 fi else FILTERED_BACKENDS="${FILTERED_BACKENDS} $be" fi done PRELOADABLE_BACKENDS="$FILTERED_BACKENDS" BACKENDS="$saved_BACKENDS" else PRELOADABLE_BACKENDS="" fi PRELOADABLE_BACKENDS_ENABLED="" # Do not initialize BACKEND_CONFS_ENABLED so that its a combination # of all backends. for backend in ${PRELOADABLE_BACKENDS} ; do BACKEND_CONFS_ENABLED="${BACKEND_CONFS_ENABLED} ${backend}.conf" BACKEND_MANS_ENABLED="${BACKEND_MANS_ENABLED} sane-${backend}.5" # Special hacks. Normally, we create a convenience library that # matches the backend's name but in some cases that will conflict # with an external library name that also matches backend name. # Work around that here by renaming internal library. if test "${backend}" = "gphoto2"; then backend=gphoto2_i fi PRELOADABLE_BACKENDS_ENABLED="${PRELOADABLE_BACKENDS_ENABLED} lib${backend}.la" done if test x != "x$PRELOADABLE_BACKENDS_ENABLED"; then preloadable_backends_enabled_TRUE= preloadable_backends_enabled_FALSE='#' else preloadable_backends_enabled_TRUE='#' preloadable_backends_enabled_FALSE= fi case $host_os in beos*) libdir='${exec_prefix}/add-ons' ;; esac # Check whether --enable-parport-directio was given. if test "${enable_parport_directio+set}" = set; then : enableval=$enable_parport_directio; if eval "test x$enable_parport_directio = xyes"; then AM_CFLAGS="$AM_CFLAGS -DENABLE_PARPORT_DIRECTIO" fi fi # Check whether --with-api-spec was given. if test "${with_api_spec+set}" = set; then : withval=$with_api_spec; else with_api_spec=check fi # Extract the first word of "makeindex", so it can be a program name with args. set dummy makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_MAKEINDEX="$MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_MAKEINDEX" && ac_cv_path_MAKEINDEX="no" ;; esac fi MAKEINDEX=$ac_cv_path_MAKEINDEX if test -n "$MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKEINDEX" >&5 $as_echo "$MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "dvips", so it can be a program name with args. set dummy dvips; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DVIPS+:} false; then : $as_echo_n "(cached) " >&6 else case $DVIPS in [\\/]* | ?:[\\/]*) ac_cv_path_DVIPS="$DVIPS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DVIPS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_DVIPS" && ac_cv_path_DVIPS="no" ;; esac fi DVIPS=$ac_cv_path_DVIPS if test -n "$DVIPS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DVIPS" >&5 $as_echo "$DVIPS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "latex", so it can be a program name with args. set dummy latex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_LATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $LATEX in [\\/]* | ?:[\\/]*) ac_cv_path_LATEX="$LATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_LATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_LATEX" && ac_cv_path_LATEX="no" ;; esac fi LATEX=$ac_cv_path_LATEX if test -n "$LATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LATEX" >&5 $as_echo "$LATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "pdflatex", so it can be a program name with args. set dummy pdflatex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PDFLATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $PDFLATEX in [\\/]* | ?:[\\/]*) ac_cv_path_PDFLATEX="$PDFLATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PDFLATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PDFLATEX" && ac_cv_path_PDFLATEX="no" ;; esac fi PDFLATEX=$ac_cv_path_PDFLATEX if test -n "$PDFLATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PDFLATEX" >&5 $as_echo "$PDFLATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "fig2dev", so it can be a program name with args. set dummy fig2dev; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_FIG2DEV+:} false; then : $as_echo_n "(cached) " >&6 else case $FIG2DEV in [\\/]* | ?:[\\/]*) ac_cv_path_FIG2DEV="$FIG2DEV" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_FIG2DEV="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_FIG2DEV" && ac_cv_path_FIG2DEV="no" ;; esac fi FIG2DEV=$ac_cv_path_FIG2DEV if test -n "$FIG2DEV"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FIG2DEV" >&5 $as_echo "$FIG2DEV" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "gs", so it can be a program name with args. set dummy gs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GS+:} false; then : $as_echo_n "(cached) " >&6 else case $GS in [\\/]* | ?:[\\/]*) ac_cv_path_GS="$GS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_GS" && ac_cv_path_GS="no" ;; esac fi GS=$ac_cv_path_GS if test -n "$GS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GS" >&5 $as_echo "$GS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "dlh", so it can be a program name with args. set dummy dlh; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DLH+:} false; then : $as_echo_n "(cached) " >&6 else case $DLH in [\\/]* | ?:[\\/]*) ac_cv_path_DLH="$DLH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DLH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_DLH" && ac_cv_path_DLH="no" ;; esac fi DLH=$ac_cv_path_DLH if test -n "$DLH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLH" >&5 $as_echo "$DLH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "ppmtogif", so it can be a program name with args. set dummy ppmtogif; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PPMTOGIF+:} false; then : $as_echo_n "(cached) " >&6 else case $PPMTOGIF in [\\/]* | ?:[\\/]*) ac_cv_path_PPMTOGIF="$PPMTOGIF" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PPMTOGIF="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PPMTOGIF" && ac_cv_path_PPMTOGIF="no" ;; esac fi PPMTOGIF=$ac_cv_path_PPMTOGIF if test -n "$PPMTOGIF"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PPMTOGIF" >&5 $as_echo "$PPMTOGIF" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test xno != "x$with_api_spec"; then : if test xno != "x$MAKEINDEX" \ && test xno != "x$DVIPS" \ && test xno != "x$FIG2DEV" \ && test xno != "x$LATEX"; then : with_api_ps=yes fi if test xno != "x$MAKEINDEX" \ && test xno != "x$PDFLATEX" \ && test xno != "x$FIG2DEV" \ && test xno != "x$GS"; then : with_api_pdf=yes fi if test xno != "x$MAKEINDEX" \ && test xno != "x$DVIPS" \ && test xno != "x$FIG2DEV" \ && test xno != "x$DLH" \ && test xno != "x$GS" \ && test xno != "x$PPMTOFIG" ; then : with_api_html=yes fi if test xyes = "x$with_api_spec" \ && test xyes != "x$with_api_ps" \ && test xyes != "x$with_api_pdf" \ && test xyes != "x$with_api_html"; then : as_fn_error $? "tools to convert the API spec are missing" "$LINENO" 5 fi fi if test x$with_api_ps = xyes; then WITH_API_PS_TRUE= WITH_API_PS_FALSE='#' else WITH_API_PS_TRUE='#' WITH_API_PS_FALSE= fi if test x$with_api_pdf = xyes; then WITH_API_PDF_TRUE= WITH_API_PDF_FALSE='#' else WITH_API_PDF_TRUE='#' WITH_API_PDF_FALSE= fi if test x$with_api_html = xyes; then WITH_API_HTML_TRUE= WITH_API_HTML_FALSE='#' else WITH_API_HTML_TRUE='#' WITH_API_HTML_FALSE= fi ac_config_files="$ac_config_files Makefile lib/Makefile sanei/Makefile frontend/Makefile japi/Makefile backend/Makefile include/Makefile doc/Makefile po/Makefile.in testsuite/Makefile testsuite/backend/Makefile testsuite/backend/genesys/Makefile testsuite/sanei/Makefile testsuite/tools/Makefile tools/Makefile doc/doxygen-sanei.conf doc/doxygen-genesys.conf" ac_config_files="$ac_config_files tools/sane-config" ac_config_files="$ac_config_files tools/sane-backends.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CROSS_COMPILING_TRUE}" && test -z "${CROSS_COMPILING_FALSE}"; then as_fn_error $? "conditional \"CROSS_COMPILING\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${have_libavahi_TRUE}" && test -z "${have_libavahi_FALSE}"; then as_fn_error $? "conditional \"have_libavahi\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${have_usblib_TRUE}" && test -z "${have_usblib_FALSE}"; then as_fn_error $? "conditional \"have_usblib\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${have_libcurl_TRUE}" && test -z "${have_libcurl_FALSE}"; then as_fn_error $? "conditional \"have_libcurl\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${have_libxml2_TRUE}" && test -z "${have_libxml2_FALSE}"; then as_fn_error $? "conditional \"have_libxml2\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COMPILE_SANED_TRUE}" && test -z "${COMPILE_SANED_FALSE}"; then as_fn_error $? "conditional \"COMPILE_SANED\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_JPEG_TRUE}" && test -z "${HAVE_JPEG_FALSE}"; then as_fn_error $? "conditional \"HAVE_JPEG\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INSTALL_UMAX_PP_TOOLS_TRUE}" && test -z "${INSTALL_UMAX_PP_TOOLS_FALSE}"; then as_fn_error $? "conditional \"INSTALL_UMAX_PP_TOOLS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${preloadable_backends_enabled_TRUE}" && test -z "${preloadable_backends_enabled_FALSE}"; then as_fn_error $? "conditional \"preloadable_backends_enabled\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_API_PS_TRUE}" && test -z "${WITH_API_PS_FALSE}"; then as_fn_error $? "conditional \"WITH_API_PS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_API_PDF_TRUE}" && test -z "${WITH_API_PDF_FALSE}"; then as_fn_error $? "conditional \"WITH_API_PDF\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${WITH_API_HTML_TRUE}" && test -z "${WITH_API_HTML_FALSE}"; then as_fn_error $? "conditional \"WITH_API_HTML\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by sane-backends $as_me 1.0.29, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ sane-backends config.status 1.0.29 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`' predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`' postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`' predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`' postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`' LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`' reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`' reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`' GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`' module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`' with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`' allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`' hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`' hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`' inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`' link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`' always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`' export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`' exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`' include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`' prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`' postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`' file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`' hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`' predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`' postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`' predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`' postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`' compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in AS \ DLLTOOL \ OBJDUMP \ SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ lt_cv_nm_interface \ nm_file_list_spec \ lt_cv_truncate_bin \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib \ compiler_lib_search_dirs \ predep_objects \ postdep_objects \ predeps \ postdeps \ compiler_lib_search_path \ LD_CXX \ reload_flag_CXX \ compiler_CXX \ lt_prog_compiler_no_builtin_flag_CXX \ lt_prog_compiler_pic_CXX \ lt_prog_compiler_wl_CXX \ lt_prog_compiler_static_CXX \ lt_cv_prog_compiler_c_o_CXX \ export_dynamic_flag_spec_CXX \ whole_archive_flag_spec_CXX \ compiler_needs_object_CXX \ with_gnu_ld_CXX \ allow_undefined_flag_CXX \ no_undefined_flag_CXX \ hardcode_libdir_flag_spec_CXX \ hardcode_libdir_separator_CXX \ exclude_expsyms_CXX \ include_expsyms_CXX \ file_list_spec_CXX \ compiler_lib_search_dirs_CXX \ predep_objects_CXX \ postdep_objects_CXX \ predeps_CXX \ postdeps_CXX \ compiler_lib_search_path_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ configure_time_dlsearch_path \ configure_time_lt_sys_library_path \ reload_cmds_CXX \ old_archive_cmds_CXX \ old_archive_from_new_cmds_CXX \ old_archive_from_expsyms_cmds_CXX \ archive_cmds_CXX \ archive_expsym_cmds_CXX \ module_cmds_CXX \ module_expsym_cmds_CXX \ export_symbols_cmds_CXX \ prelink_cmds_CXX \ postlink_cmds_CXX; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile' # Capture the value of obsolete ALL_LINGUAS because we need it to compute # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it # from automake < 1.5. eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' # Capture the value of LINGUAS because we need it to compute CATALOGS. LINGUAS="${LINGUAS-%UNSET%}" # variables for create stdint.h replacement PACKAGE="$PACKAGE" VERSION="$VERSION" ac_stdint_h="$ac_stdint_h" _ac_stdint_h=`$as_echo "_$PACKAGE-$ac_stdint_h" | $as_tr_cpp` ac_cv_stdint_message="$ac_cv_stdint_message" ac_cv_header_stdint_t="$ac_cv_header_stdint_t" ac_cv_header_stdint_x="$ac_cv_header_stdint_x" ac_cv_header_stdint_o="$ac_cv_header_stdint_o" ac_cv_header_stdint_u="$ac_cv_header_stdint_u" ac_cv_type_uint64_t="$ac_cv_type_uint64_t" ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t" ac_cv_char_data_model="$ac_cv_char_data_model" ac_cv_long_data_model="$ac_cv_long_data_model" ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t" ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t" ac_cv_type_intmax_t="$ac_cv_type_intmax_t" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "include/sane/config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/sane/config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;; "$ac_stdint_h") CONFIG_COMMANDS="$CONFIG_COMMANDS $ac_stdint_h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; "sanei/Makefile") CONFIG_FILES="$CONFIG_FILES sanei/Makefile" ;; "frontend/Makefile") CONFIG_FILES="$CONFIG_FILES frontend/Makefile" ;; "japi/Makefile") CONFIG_FILES="$CONFIG_FILES japi/Makefile" ;; "backend/Makefile") CONFIG_FILES="$CONFIG_FILES backend/Makefile" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; "testsuite/backend/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/backend/Makefile" ;; "testsuite/backend/genesys/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/backend/genesys/Makefile" ;; "testsuite/sanei/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/sanei/Makefile" ;; "testsuite/tools/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/tools/Makefile" ;; "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; "doc/doxygen-sanei.conf") CONFIG_FILES="$CONFIG_FILES doc/doxygen-sanei.conf" ;; "doc/doxygen-genesys.conf") CONFIG_FILES="$CONFIG_FILES doc/doxygen-genesys.conf" ;; "tools/sane-config") CONFIG_FILES="$CONFIG_FILES tools/sane-config" ;; "tools/sane-backends.pc") CONFIG_FILES="$CONFIG_FILES tools/sane-backends.pc" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. case $CONFIG_FILES in #( *\'*) : eval set x "$CONFIG_FILES" ;; #( *) : set x $CONFIG_FILES ;; #( *) : ;; esac shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`$as_dirname -- "$am_mf" || $as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$am_mf" : 'X\(//\)[^/]' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$am_mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` am_filepart=`$as_basename -- "$am_mf" || $as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$am_mf" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` { echo "$as_me:$LINENO: cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles" >&5 (cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } || am_rc=$? done if test $am_rc -ne 0; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments for automatic dependency tracking. Try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } fi { am_dirpart=; unset am_dirpart;} { am_filepart=; unset am_filepart;} { am_mf=; unset am_mf;} { am_rc=; unset am_rc;} rm -f conftest-deps.mk } ;; "libtool":C) # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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; either version 2 of of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # The names of the tagged configurations supported by this script. available_tags='CXX ' # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build static libraries. build_old_libs=$enable_static # Assembler program. AS=$lt_AS # DLL creation program. DLLTOOL=$lt_DLLTOOL # Object dumper program. OBJDUMP=$lt_OBJDUMP # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shared archive member basename,for filename based shared library versioning on AIX. shared_archive_member_spec=$shared_archive_member_spec # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm into a list of symbols to manually relocate. global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name lister interface. nm_interface=$lt_lt_cv_nm_interface # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and where our libraries should be installed. lt_sysroot=$lt_sysroot # Command to truncate a binary pipe. lt_truncate_bin=$lt_lt_cv_truncate_bin # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Detected run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path # Explicit LT_SYS_LIBRARY_PATH set during ./configure time. configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects postdep_objects=$lt_postdep_objects predeps=$lt_predeps postdeps=$lt_postdeps # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: CXX # The linker used to build libraries. LD=$lt_LD_CXX # How to create reloadable object files. reload_flag=$lt_reload_flag_CXX reload_cmds=$lt_reload_cmds_CXX # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_CXX # A language specific compiler. CC=$lt_compiler_CXX # Is the compiler the GNU compiler? with_gcc=$GCC_CXX # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_CXX # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_CXX # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_CXX # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_CXX # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_CXX # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_CXX archive_expsym_cmds=$lt_archive_expsym_cmds_CXX # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_CXX module_expsym_cmds=$lt_module_expsym_cmds_CXX # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_CXX # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_CXX # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_CXX # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_CXX # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_CXX # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_CXX # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_CXX # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_CXX # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_CXX # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_CXX # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_CXX # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_CXX # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_CXX # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_CXX # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds_CXX # Specify filename containing input files. file_list_spec=$lt_file_list_spec_CXX # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_CXX # The directories searched by this compiler when creating a shared library. compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX # Dependencies to place before and after the objects being linked to # create a shared library. predep_objects=$lt_predep_objects_CXX postdep_objects=$lt_postdep_objects_CXX predeps=$lt_predeps_CXX postdeps=$lt_postdeps_CXX # The library search path used internally by the compiler when linking # a shared library. compiler_lib_search_path=$lt_compiler_lib_search_path_CXX # ### END LIBTOOL TAG CONFIG: CXX _LT_EOF ;; "po-directories":C) for ac_file in $CONFIG_FILES; do # Support "outfile[:infile[:infile...]]" case "$ac_file" in *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; esac # PO directories have a Makefile.in generated from Makefile.in.in. case "$ac_file" in */Makefile.in) # Adjust a relative srcdir. ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'` ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` # In autoconf-2.13 it is called $ac_given_srcdir. # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; /*) top_srcdir="$ac_given_srcdir" ;; *) top_srcdir="$ac_dots$ac_given_srcdir" ;; esac # Treat a directory as a PO directory if and only if it has a # POTFILES.in file. This allows packages to have multiple PO # directories under different names or in different locations. if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then rm -f "$ac_dir/POTFILES" test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" gt_tab=`printf '\t'` cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" POMAKEFILEDEPS="POTFILES.in" # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend # on $ac_dir but don't depend on user-specified configuration # parameters. if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then # The LINGUAS file contains the set of available languages. if test -n "$OBSOLETE_ALL_LINGUAS"; then test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" fi ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` # Hide the ALL_LINGUAS assignment from automake < 1.5. eval 'ALL_LINGUAS''=$ALL_LINGUAS_' POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" else # The set of available languages was given in configure.in. # Hide the ALL_LINGUAS assignment from automake < 1.5. eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' fi # Compute POFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) # Compute UPDATEPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) # Compute DUMMYPOFILES # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) # Compute GMOFILES # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) case "$ac_given_srcdir" in .) srcdirpre= ;; *) srcdirpre='$(srcdir)/' ;; esac POFILES= UPDATEPOFILES= DUMMYPOFILES= GMOFILES= for lang in $ALL_LINGUAS; do POFILES="$POFILES $srcdirpre$lang.po" UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" DUMMYPOFILES="$DUMMYPOFILES $lang.nop" GMOFILES="$GMOFILES $srcdirpre$lang.gmo" done # CATALOGS depends on both $ac_dir and the user's LINGUAS # environment variable. INST_LINGUAS= if test -n "$ALL_LINGUAS"; then for presentlang in $ALL_LINGUAS; do useit=no if test "%UNSET%" != "$LINGUAS"; then desiredlanguages="$LINGUAS" else desiredlanguages="$ALL_LINGUAS" fi for desiredlang in $desiredlanguages; do # Use the presentlang catalog if desiredlang is # a. equal to presentlang, or # b. a variant of presentlang (because in this case, # presentlang can be used as a fallback for messages # which are not translated in the desiredlang catalog). case "$desiredlang" in "$presentlang"*) useit=yes;; esac done if test $useit = yes; then INST_LINGUAS="$INST_LINGUAS $presentlang" fi done fi CATALOGS= if test -n "$INST_LINGUAS"; then for lang in $INST_LINGUAS; do CATALOGS="$CATALOGS $lang.gmo" done fi test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do if test -f "$f"; then case "$f" in *.orig | *.bak | *~) ;; *) cat "$f" >> "$ac_dir/Makefile" ;; esac fi done fi ;; esac done ;; "$ac_stdint_h":C) { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_stdint_h : $_ac_stdint_h" >&5 $as_echo "$as_me: creating $ac_stdint_h : $_ac_stdint_h" >&6;} ac_stdint=$tmp/_stdint.h echo "#ifndef" $_ac_stdint_h >$ac_stdint echo "#define" $_ac_stdint_h "1" >>$ac_stdint echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint if test "_$ac_cv_header_stdint_t" != "_" ; then echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint echo "#include " >>$ac_stdint echo "#endif" >>$ac_stdint echo "#endif" >>$ac_stdint else cat >>$ac_stdint < #else #include /* .................... configured part ............................ */ STDINT_EOF echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint if test "_$ac_cv_header_stdint_x" != "_" ; then ac_header="$ac_cv_header_stdint_x" echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint fi echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint if test "_$ac_cv_header_stdint_o" != "_" ; then ac_header="$ac_cv_header_stdint_o" echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint fi echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint if test "_$ac_cv_header_stdint_u" != "_" ; then ac_header="$ac_cv_header_stdint_u" echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint fi echo "" >>$ac_stdint if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then echo "#include <$ac_header>" >>$ac_stdint echo "" >>$ac_stdint fi fi echo "/* which 64bit typedef has been found */" >>$ac_stdint if test "$ac_cv_type_uint64_t" = "yes" ; then echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint fi if test "$ac_cv_type_u_int64_t" = "yes" ; then echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint fi echo "" >>$ac_stdint echo "/* which type model has been detected */" >>$ac_stdint if test "_$ac_cv_char_data_model" != "_" ; then echo "#define _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint echo "#define _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint else echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint fi echo "" >>$ac_stdint echo "/* whether int_least types were detected */" >>$ac_stdint if test "$ac_cv_type_int_least32_t" = "yes"; then echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint fi echo "/* whether int_fast types were detected */" >>$ac_stdint if test "$ac_cv_type_int_fast32_t" = "yes"; then echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint fi echo "/* whether intmax_t type was detected */" >>$ac_stdint if test "$ac_cv_type_intmax_t" = "yes"; then echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint fi echo "" >>$ac_stdint cat >>$ac_stdint <= 199901L #define _HAVE_UINT64_T #define _HAVE_LONGLONG_UINT64_T typedef long long int64_t; typedef unsigned long long uint64_t; #elif !defined __STRICT_ANSI__ #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ #define _HAVE_UINT64_T typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__ /* note: all ELF-systems seem to have loff-support which needs 64-bit */ #if !defined _NO_LONGLONG #define _HAVE_UINT64_T #define _HAVE_LONGLONG_UINT64_T typedef long long int64_t; typedef unsigned long long uint64_t; #endif #elif defined __alpha || (defined __mips && defined _ABIN32) #if !defined _NO_LONGLONG typedef long int64_t; typedef unsigned long uint64_t; #endif /* compiler/cpu type to define int64_t */ #endif #endif #endif #if defined _STDINT_HAVE_U_INT_TYPES /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */ typedef u_int8_t uint8_t; typedef u_int16_t uint16_t; typedef u_int32_t uint32_t; /* glibc compatibility */ #ifndef __int8_t_defined #define __int8_t_defined #endif #endif #ifdef _STDINT_NEED_INT_MODEL_T /* we must guess all the basic types. Apart from byte-addressable system, */ /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */ /* (btw, those nibble-addressable systems are way off, or so we assume) */ #if defined _STDINT_BYTE_MODEL #if _STDINT_LONG_MODEL+0 == 242 /* 2:4:2 = IP16 = a normal 16-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef long int32_t; #endif #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444 /* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */ /* 4:4:4 = ILP32 = a normal 32-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488 /* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */ /* 4:8:8 = LP64 = a normal 64-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif /* this system has a "long" of 64bit */ #ifndef _HAVE_UINT64_T #define _HAVE_UINT64_T typedef unsigned long uint64_t; typedef long int64_t; #endif #elif _STDINT_LONG_MODEL+0 == 448 /* LLP64 a 64-bit system derived from a 32-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif /* assuming the system has a "long long" */ #ifndef _HAVE_UINT64_T #define _HAVE_UINT64_T #define _HAVE_LONGLONG_UINT64_T typedef unsigned long long uint64_t; typedef long long int64_t; #endif #else #define _STDINT_NO_INT32_T #endif #else #define _STDINT_NO_INT8_T #define _STDINT_NO_INT32_T #endif #endif /* * quote from SunOS-5.8 sys/inttypes.h: * Use at your own risk. As of February 1996, the committee is squarely * behind the fixed sized types; the "least" and "fast" types are still being * discussed. The probability that the "fast" types may be removed before * the standard is finalized is high enough that they are not currently * implemented. */ #if defined _STDINT_NEED_INT_LEAST_T typedef int8_t int_least8_t; typedef int16_t int_least16_t; typedef int32_t int_least32_t; #ifdef _HAVE_UINT64_T typedef int64_t int_least64_t; #endif typedef uint8_t uint_least8_t; typedef uint16_t uint_least16_t; typedef uint32_t uint_least32_t; #ifdef _HAVE_UINT64_T typedef uint64_t uint_least64_t; #endif /* least types */ #endif #if defined _STDINT_NEED_INT_FAST_T typedef int8_t int_fast8_t; typedef int int_fast16_t; typedef int32_t int_fast32_t; #ifdef _HAVE_UINT64_T typedef int64_t int_fast64_t; #endif typedef uint8_t uint_fast8_t; typedef unsigned uint_fast16_t; typedef uint32_t uint_fast32_t; #ifdef _HAVE_UINT64_T typedef uint64_t uint_fast64_t; #endif /* fast types */ #endif #ifdef _STDINT_NEED_INTMAX_T #ifdef _HAVE_UINT64_T typedef int64_t intmax_t; typedef uint64_t uintmax_t; #else typedef long intmax_t; typedef unsigned long uintmax_t; #endif #endif #ifdef _STDINT_NEED_INTPTR_T #ifndef __intptr_t_defined #define __intptr_t_defined /* we encourage using "long" to store pointer values, never use "int" ! */ #if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484 typedef unsigned int uintptr_t; typedef int intptr_t; #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444 typedef unsigned long uintptr_t; typedef long intptr_t; #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T typedef uint64_t uintptr_t; typedef int64_t intptr_t; #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */ typedef unsigned long uintptr_t; typedef long intptr_t; #endif #endif #endif /* The ISO C99 standard specifies that in C++ implementations these should only be defined if explicitly requested. */ #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS #ifndef UINT32_C /* Signed. */ # define INT8_C(c) c # define INT16_C(c) c # define INT32_C(c) c # ifdef _HAVE_LONGLONG_UINT64_T # define INT64_C(c) c ## L # else # define INT64_C(c) c ## LL # endif /* Unsigned. */ # define UINT8_C(c) c ## U # define UINT16_C(c) c ## U # define UINT32_C(c) c ## U # ifdef _HAVE_LONGLONG_UINT64_T # define UINT64_C(c) c ## UL # else # define UINT64_C(c) c ## ULL # endif /* Maximal type. */ # ifdef _HAVE_LONGLONG_UINT64_T # define INTMAX_C(c) c ## L # define UINTMAX_C(c) c ## UL # else # define INTMAX_C(c) c ## LL # define UINTMAX_C(c) c ## ULL # endif /* literalnumbers */ #endif #endif /* These limits are merrily those of a two complement byte-oriented system */ /* Minimum of signed integral types. */ # define INT8_MIN (-128) # define INT16_MIN (-32767-1) # define INT32_MIN (-2147483647-1) # define INT64_MIN (-__INT64_C(9223372036854775807)-1) /* Maximum of signed integral types. */ # define INT8_MAX (127) # define INT16_MAX (32767) # define INT32_MAX (2147483647) # define INT64_MAX (__INT64_C(9223372036854775807)) /* Maximum of unsigned integral types. */ # define UINT8_MAX (255) # define UINT16_MAX (65535) # define UINT32_MAX (4294967295U) # define UINT64_MAX (__UINT64_C(18446744073709551615)) /* Minimum of signed integral types having a minimum size. */ # define INT_LEAST8_MIN INT8_MIN # define INT_LEAST16_MIN INT16_MIN # define INT_LEAST32_MIN INT32_MIN # define INT_LEAST64_MIN INT64_MIN /* Maximum of signed integral types having a minimum size. */ # define INT_LEAST8_MAX INT8_MAX # define INT_LEAST16_MAX INT16_MAX # define INT_LEAST32_MAX INT32_MAX # define INT_LEAST64_MAX INT64_MAX /* Maximum of unsigned integral types having a minimum size. */ # define UINT_LEAST8_MAX UINT8_MAX # define UINT_LEAST16_MAX UINT16_MAX # define UINT_LEAST32_MAX UINT32_MAX # define UINT_LEAST64_MAX UINT64_MAX /* shortcircuit*/ #endif /* once */ #endif #endif STDINT_EOF fi if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_stdint_h is unchanged" >&5 $as_echo "$as_me: $ac_stdint_h is unchanged" >&6;} else ac_dir=`$as_dirname -- "$ac_stdint_h" || $as_expr X"$ac_stdint_h" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_stdint_h" : 'X\(//\)[^/]' \| \ X"$ac_stdint_h" : 'X\(//\)$' \| \ X"$ac_stdint_h" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_stdint_h" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p rm -f $ac_stdint_h mv $ac_stdint $ac_stdint_h fi ;; "tools/sane-config":F) chmod a+x tools/sane-config ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi echo "-> Variables used for compilation/linking:" echo AM_CPPFLAGS=\"${AM_CPPFLAGS}\" echo AM_CFLAGS=\"${AM_CFLAGS}\" echo AM_CXXFLAGS=\"${AM_CXXFLAGS}\" echo AM_LDFLAGS=\"${AM_LDFLAGS}\" echo LIBS=\"${LIBS}\" echo "-> Installation directories:" echo "Configuration: `eval eval echo ${sysconfdir}`" echo "Libraries: `eval eval echo ${libdir}`" echo "Binaries: `eval eval echo ${bindir}` and `eval eval echo ${sbindir}`" echo "Manpages: `eval eval echo ${mandir}`" echo "Documentation: `eval eval echo ${docdir}`" if eval "test x$INSTALL_LOCKPATH = xinstall-lockpath" ; then echo "Lockfiles: `eval eval echo ${locksanedir}`" else echo "Lockfiles: Feature is disabled!" fi echo "-> Network parameters:" if test "${SANED}" = "saned" ; then echo "Build saned: yes" else echo "Build saned: no" fi echo "IPv6 support: `eval eval echo ${ipv6}`" echo "Avahi support: `eval eval echo ${enable_avahi}`" echo "cURL support: `eval eval echo ${with_libcurl}`" echo "SNMP support: `eval eval echo ${with_snmp}`" echo "-> The following backends will be built:" for backend in ${BACKENDS} ; do echo $ECHO_N "${backend} " done echo echo echo "-> The following preload backends will be built:" for backend in ${PRELOADABLE_BACKENDS} ; do echo $ECHO_N "${backend} " done echo if test "$SANE_CONFIG_PATH" != "no" ; then SANE_INSTALLED_VERSION=`$SANE_CONFIG_PATH --version` SANE_INSTALLED_PREFIX=`$SANE_CONFIG_PATH --prefix` if test "$SANE_INSTALLED_PREFIX" != "$prefix" ; then echo "*** WARNING: SANE is already installed (version $SANE_INSTALLED_VERSION). The old" echo "*** installation is at $SANE_INSTALLED_PREFIX while SANE will now be installed" echo "*** at $prefix. It is recommended to uninstall the old SANE version" echo "*** before installing the new one to avoid problems." fi else if test "$LIBSANE_EXISTS" = "yes" ; then echo "*** Warning: An old version of SANE was detected but the sane-config program" echo "*** couldn't be found. If you encounter any problems with SANE remove the old" echo "*** SANE files and reinstall this version." fi fi if eval "test x${sysconfdir} = x/usr/etc" ; then echo "*** WARNING: Configuration files are stored in /usr/etc. If this is not" echo "*** intended, use --sysconfdir to set another path (e.g. "/etc")." fi if test "$SELECTED_BACKENDS" != "" ; then echo "*** Warning: Local backends have been disabled. This means that scanners" echo "*** connected to your local computer won't be supported. Only a network" echo "*** connection to a remote host is possible." fi if test "$with_usb" != "no" && test "$have_usb" != "yes" ; then echo "*** Warning: sane-backends will be built without USB support. There may" echo "*** be valid reasons to do so, e.g. if you don't use USB scanners or on" echo "*** platforms without USB support but generally this means that you" echo "*** can't use USB devices with SANE. The most probable cause is that" if test "${ac_cv_header_usb_h}" != "yes"; then echo "*** the libusb header file usb.h is not installed. If you use Linux" echo "*** you may need a package called 'libusb-dev', 'libusb-devel' or similar." else echo "*** libusb is not installed at all or is too old. See README." fi fi echo "****************************************************************" echo "* Please be sure to read file PROBLEMS in this directory *" echo "* BEFORE running any of the SANE applications. Some devices *" echo "* may be damaged by improper operation, so please do heed this *" echo "* advice. *" echo "****************************************************************" sane-backends-1.0.29/ChangeLog0000666000000000000000000072425313615534570012774 00000000000000commit e52a5bf71979365a028bbf8aa5bd5e5e6b983b7f (HEAD, tag: 1.0.29, origin/release/1.0.29, refs/pipelines/114287994) Author: Olaf Meeuwissen Date: 2020-02-02 20:19:37 +0900 NEWS: Update with changes committed to the release/1.0.29 branch commit f35aab0de76a720615da845e04b9f8863ed01bd7 Author: Olaf Meeuwissen Date: 2020-02-02 20:07:39 +0900 po/*.po: Update Project-Id-Version of several translations This only affects those languages for which translatable messages have been updated since the last release (1.0.28). commit 0c90e6bdef277bdc497d875f31d2dee6d5a71301 Merge: 3c714b48 8bc98d0f Author: Povilas Kanapickas Date: 2020-01-19 13:09:24 +0000 Merge branch '225-fix-genesys-testsuite-compiler-warning' into 'release/1.0.29' Resolve "genesys test utility generates a compiler warning on Debian 10" See merge request sane-project/backends!309 commit 3c714b48afb7eeaff54a4e6212c111647a803153 Merge: 3825e0ca fe38a70d Author: Rolf Bensch Date: 2020-01-18 19:59:38 +0000 Merge branch 'de-minimal-translation-updates' into 'release/1.0.29' Minimal German translation updates See merge request sane-project/backends!312 commit fe38a70d73c0f677fb4b10b865be464252c6c32a Author: Olaf Meeuwissen Date: 2020-01-18 12:13:30 +0900 po/de.po: Cherry pick fixes for fuzzies and untranslated messages commit 3825e0ca6496b1de08b847c802125c655ad025f2 Merge: f22dc84b b91dca43 Author: Olaf Meeuwissen Date: 2020-01-18 02:53:48 +0000 Merge branch 'bellaperez/cat_translations' into 'release/1.0.29' Update Catalan and Valencian translations See merge request sane-project/backends!311 commit b91dca43d504e2019521e49b3abc8d259d92c9aa Author: Antoni Bella Pérez Date: 2020-01-18 02:53:48 +0000 Update Catalan and Valencian translations Adapted and tested: * msgmerge --silent --previous --width=75 --lang= * msgfmt -vc commit f22dc84b71a95afb01a41ad38b87b10f9e2baa83 Merge: 77c92f49 f72862dd Author: Olaf Meeuwissen Date: 2020-01-14 13:05:02 +0000 Merge branch 'undefined' into 'release/1.0.29' Update Ukrainian translation See merge request sane-project/backends!305 commit f72862ddf8b4dac5857cc9858f2d3ee6efca63ff Author: Yuri Chornoivan Date: 2020-01-14 13:05:02 +0000 Update Ukrainian translation commit 8bc98d0f7d37bec2dc77d8fea5d57e95ba1534a8 Author: Olaf Meeuwissen Date: 2020-01-13 18:37:21 +0900 testsuite/backend/genesys: Fix include path for out-of-tree builds commit ba84a8f69c5277723df6e77c53521365a7645558 Author: Olaf Meeuwissen Date: 2020-01-13 18:35:33 +0900 testsuite/backend/genesys: Fix [-Wcatch-value=] compiler warning Exceptions ought to be caught by reference. commit 77c92f49af02a9cb4389ddc2473e68dbed32642a Author: Gerhard Jäger Date: 2020-01-13 09:38:30 +0100 Issue#113: Fix applied (thanks David Binderman). commit d36a9ba786d10b302a40a92cdeb55da74a363809 Author: Rolf Bensch Date: 2020-01-12 21:07:18 +0100 INSTALL.linux: add missing development packages these packages are mandatory for building escl backend commit 4a9c723646cfbd7a6df976e24284f24986f28038 Merge: ca63c6cf cc31c110 Author: Ralph Little Date: 2020-01-12 19:37:39 +0000 Merge branch 'uk-english-translations' into 'release/1.0.29' Update British English translations See merge request sane-project/backends!306 commit cc31c110c94d03f0895cd94bf82e139ba89b9e92 Author: Ralph Little Date: 2020-01-12 10:39:27 -0800 Updated British English translations commit ca63c6cf9a387c594e8995cfc3fdf94d1858a86c Author: Olaf Meeuwissen Date: 2020-01-12 21:28:21 +0900 NEWS: Add most relevant changes for 1.0.29 commit 7b45c89b023dd902cd6d8d81713e977df4caa444 Merge: 0f394f55 055cd9f2 Author: Olaf Meeuwissen Date: 2020-01-12 08:26:50 +0000 Merge branch 'dll-conf-sync' into 'master' Synchronize dll configuration file See merge request sane-project/backends!304 commit 055cd9f28211cc72436827f264a87d645f9212ad Author: Olaf Meeuwissen Date: 2020-01-12 17:11:40 +0900 dll: Sort dll.conf.in for ease of maintenance Only the `net` backend is treated special to match the file comment. commit 4f77e6dcfa4532741370096f2d517cdc9d0fe8d8 Author: Olaf Meeuwissen Date: 2020-01-12 17:10:38 +0900 dll: Add kvs40xx and pieusb backends to dll.conf.in commit 0f394f55ed5daf742f62f4139b0f5c89572aa6e5 Merge: 42b25624 2b927f16 Author: Olaf Meeuwissen Date: 2020-01-12 07:44:10 +0000 Merge branch 'i18n-update' into 'master' I18n update See merge request sane-project/backends!303 commit 2b927f165b08dcef3c207e36597a45878c956676 Author: Olaf Meeuwissen Date: 2020-01-12 16:26:15 +0900 po: Synchronize message catalogs with latest code commit f094033990ee1f1106299dbc70e5491328ed3700 Author: Olaf Meeuwissen Date: 2020-01-12 15:10:32 +0900 po: Regenerate POTFILES.in The file now contains only those backend files that mention SANE_I18N and contains all of them. commit 8ae5ba0522c139f4958d91620fd5c94cc94905d6 Author: Olaf Meeuwissen Date: 2020-01-12 14:46:14 +0900 escl: Use standardized, translated option group titles commit 42b256247061aedf0c4adb3e324d122329b09118 Merge: 75162d0f d40a8ff9 Author: Olaf Meeuwissen Date: 2020-01-12 03:37:34 +0000 Merge branch 'escl-debug' into 'master' Log message improvements. See merge request sane-project/backends!302 commit 75162d0f005a5e89f8815dce27abc9a2e0cbbc01 Merge: d9188a76 3e49c3af Author: Olaf Meeuwissen Date: 2020-01-12 03:19:00 +0000 Merge branch '201-old-incorrect-link-in-sane-man' into 'master' Resolve "Old, incorrect link in sane.man" Closes #201 See merge request sane-project/backends!291 commit d9188a7699a6db1f5925c1ac80c0ea7a880283ce Merge: 0830b839 c821f277 Author: Olaf Meeuwissen Date: 2020-01-12 03:16:45 +0000 Merge branch '153-is-pthread_t-check-for-non-integers-still-neccesary' into 'master' Resolve "Is pthread_t check for non-integers still necessary?" Closes #153 See merge request sane-project/backends!289 commit 0830b83915900bb1f936372adaafd00f814a5eae Merge: aedebece c4a88e6b Author: Povilas Kanapickas Date: 2020-01-11 15:50:06 +0000 Merge branch '188-hp-scanjet-3670-fails-to-scan-at-75dpi' into 'master' Resolve "HP ScanJet 3670 fails to scan at 75dpi" Closes #188 See merge request sane-project/backends!298 commit d40a8ff90da71193762dc46518f2eba58799707b Author: Thierry HUCHARD Date: 2020-01-11 09:15:51 +0100 Delete unused file. commit d8f983bbd9cd1e02ecf5a80b9250cd314ae4b541 Author: Thierry HUCHARD Date: 2020-01-11 08:56:46 +0100 Log message improvements. commit aedebecef790867c390e97e05741965f53a8e3e0 Merge: 28264dcf 913be936 Author: Olaf Meeuwissen Date: 2020-01-09 12:27:11 +0000 Merge branch 'escl-integration-fixes' into 'master' Escl integration fixes See merge request sane-project/backends!299 commit 913be9367248966c2f346244d8968fa71787a73c Author: Olaf Meeuwissen Date: 2020-01-09 21:09:47 +0900 escl: Mark backend as new for upcoming release commit e5e601379cef583a5541c9eeaa43cbbe5438f071 Author: Olaf Meeuwissen Date: 2020-01-09 21:09:06 +0900 dll: Enable loading of escl backend commit 28264dcfd825d7c2f84e3cd7e117ee7e831ba11d Merge: 8b611a25 74131ede Author: Olaf Meeuwissen Date: 2020-01-08 11:29:40 +0000 Merge branch 'escl-Securing-libcurl' into 'master' Escl securing libcurl See merge request sane-project/backends!297 commit 8b611a252d40b5bdab3c6b3135fe3300b63088b7 Merge: bc804f56 66ec4dda Author: Olaf Meeuwissen Date: 2020-01-08 11:28:08 +0000 Merge branch 'escl-Memory-and-file-handle-leak' into 'master' Escl memory and file handle leak See merge request sane-project/backends!296 commit c4a88e6bf4a2e153ec667f811dfdeb35ef2e9464 Author: Ralph Little Date: 2020-01-07 22:52:14 -0800 genesys: renamed HP ScanJet 3670C to 3670. Model has no C suffix commit 88ea0d48e7357799e33a7352e73694967857e502 Author: Ralph Little Date: 2020-01-07 22:36:09 -0800 genesys: added 50dpi to HP ScanJet 3670 backend Windows driver supports 50dpi as the lowest mode. commit bc804f56410c2eb4347650733eda8a3c415d6b32 Merge: dad06306 bd2d5f5e Author: Louis Lagendijk Date: 2020-01-07 16:07:46 +0000 Merge branch 'pixma_bjnp_model_not_found' into 'master' pixma_bjnp: Report that scanner model is not supported as suggested in issue #69 See merge request sane-project/backends!293 commit bd2d5f5e7d6dc2047448e5e027d94d753dc7baef Author: Louis Lagendijk Date: 2020-01-07 16:07:46 +0000 pixma_bjnp: Report that scanner model is not supported as suggested in issue #69 pixma: Improved logging for search for scanner model Moved lookup_scanner from pixma_io_sanei.c to pixma_bjnp.c pixma_io_sanei.c: fix whitespace commit 74131ede6c6438d215b324a5ee23c09a0efc0a6a Author: Ordissimo Date: 2020-01-07 14:14:19 +0000 Add header curl. commit 94daddc6bd15c1975dc66dcd97d5fb2ca4567c92 Author: thierry1970 Date: 2020-01-07 15:01:47 +0100 cURL global init/cleanup issues. commit 66ec4dda26016457d145f1438e8494c5f872f7c1 Author: thierry1970 Date: 2020-01-07 14:07:29 +0100 Buffer overflow. commit 7e192f8ba7f99fddb33862efad6d7ac8790f6296 Author: thierry1970 Date: 2020-01-07 14:06:11 +0100 Memory and file handle leak. commit dad063068dc9738143d417223e8780f7b6a480ba Author: Rolf Bensch Date: 2020-01-05 12:49:20 +0100 pixma: backend version 0.27.0 commit 4a0d222e88b6dd0699d7d98b660a3c6672d0a382 Merge: ba2f14fd b7e0d9af Author: Rolf Bensch Date: 2020-01-05 11:45:51 +0000 Merge branch 'pixma/move-to-subfolder' into 'master' move pixma source files to subfolder See merge request sane-project/backends!290 commit b7e0d9afae230a8ae6b552297a58bc8b7efdf44b Author: Rolf Bensch Date: 2020-01-02 13:56:05 +0100 pixma: fix comment commit 7b228be5e7dad536640abb91ec6db605c956e1f5 Author: Rolf Bensch Date: 2020-01-02 12:36:49 +0100 pixma: move source files to subfolder commit ba2f14fde17ebff30261551d1fad1aa8c311ca40 Author: Rolf Bensch Date: 2020-01-04 12:39:59 +0100 pixma: backend version 0.26.1 commit c2e512db8b438f40627c7d2de2b5fdbf9cb64729 Merge: b30784a7 d910d52d Author: Rolf Bensch Date: 2020-01-04 11:23:36 +0000 Merge branch '183-add-support-for-canon-mf743c' into 'master' Resolve "Add support for Canon MF743C" Closes #183 See merge request sane-project/backends!258 commit d910d52dabb983fa190ac92864a1069895572ed8 Author: Rolf Bensch Date: 2019-12-19 20:07:16 +0100 pixma: restrict ADFDUP scans to 300dpi for i-SENSYS MF741C/743C commit cf506daab35626c10c690ee36ad0935f8da0d658 Author: Rolf Bensch Date: 2019-12-15 11:56:47 +0100 pixma: new scanner Canon i-SENSYS MF741/743 commit 3e49c3af0b3a4034dd62df4ee46f7c959c1f929f Author: Olaf Meeuwissen Date: 2020-01-04 15:37:51 +0900 sane.man: Drop outdated link for coolscan2 backend commit 70cfd20c206e0b248d08b8cc9ebd666fe620d7c7 Author: Rolf Bensch Date: 2020-01-03 18:32:01 +0100 update last edited date commit 59bd48ea7275c94b1d0590af7a72f334dad204c2 Author: Rolf Bensch Date: 2020-01-03 18:31:31 +0100 update pixma backend description commit b30784a73015fd00a5edf95628188f577158666a Author: Jakub Benda Date: 2020-01-03 19:48:37 +0300 xerox_mfp: Fix Samsung CLX-3175FW color scan "Not a JPEG file" Exclude "Samsung CLX-3170 Series" from JPEG mode. Closes #200. Reference: https://gitlab.com/sane-project/backends/issues/200 commit 8d022c29b25f9529d0c090070f37e37b66aa9e10 Merge: 3a1d6dbb 5927ecfa Author: Olaf Meeuwissen Date: 2020-01-02 10:57:08 +0000 Merge branch 'escl-png' into 'master' Added PNG and TIFF decoder. See merge request sane-project/backends!283 commit 5927ecfa2a5212eb71731926fea7e57d10e3a5e3 Author: thierry1970 Date: 2020-01-02 09:39:16 +0100 Using strcmp instead of strncmp, strncmp is not justified. commit 3a1d6dbb96def4e7be4058a19ee29f0d0256a425 Author: Olaf Meeuwissen Date: 2019-12-31 12:49:40 +0900 .gitignore: .dirstamp files and *-s.cpp files [skip CI] commit c821f277f3149a0ab57940e2512e893c6f886a20 Author: Olaf Meeuwissen Date: 2019-12-31 12:33:13 +0900 build: Rename *THREAD_LIBS parameters This aims to clarify the purpose of each parameter: SANEI_THREAD_LIBS for any code that uses sanei/sanei_thread.c and a plain PTHREAD_LIBS for code that uses the pthread library directly. commit 9050ae3b6a3489a78c791ca0c3aa71d13e68d966 Author: Olaf Meeuwissen Date: 2019-12-31 12:14:46 +0900 mustek_usb2: Remove unneeded linking arguments commit 378a85fe0960e7969e552325f9cf774fdfc45852 Author: Olaf Meeuwissen Date: 2019-12-31 11:55:31 +0900 Don't disable backends using pthreads directly. Fixes #153 The use of pthreads was disabled in case of a non-integral pthread_t type in 756d286f3605143b26471eb7e1e7a45bc7ba356a as the sanei_thread implementation assumes an integral type. This also disabled building of the kvs40xx and mustek_usb2 backends which use pthreads directly. This re-enables the build of these backends. commit fa882855be117ae74e49e72ac7d483209e414788 Merge: 75310001 adaef043 Author: Olaf Meeuwissen Date: 2019-12-30 07:06:02 +0000 Merge branch '120-fix-all-compiler-warnings-on-the-debian-10-builds' into 'master' CI: Turn compiler warnings into errors on Debian 10. Fixes #120 Closes #120 See merge request sane-project/backends!288 commit adaef0435a77b48c777f720036f288611762cb5f Author: Olaf Meeuwissen Date: 2019-12-30 15:48:56 +0900 CI: Turn compiler warnings into errors on Debian 10. Fixes #120 commit 75310001f1765f6e9c083c89c3b894e6f97abf3a Merge: b2c83de8 b4ce7199 Author: Olaf Meeuwissen Date: 2019-12-30 06:19:39 +0000 Merge branch 'fix-kvs40xx-cast-function-type-warning' into 'master' kvs40xx: Fix [-Wcast-function-type] compiler warning. Re #120 See merge request sane-project/backends!229 commit b2c83de8a41286faee798b1300aa48de6f43a203 Merge: a9ab9df9 4c8e4dd9 Author: Olaf Meeuwissen Date: 2019-12-30 03:11:15 +0000 Merge branch '196-fix-compiler-warning-for-pieusb-backend' into 'master' pieusb: fix compiler warnings Closes #196 See merge request sane-project/backends!287 commit 4c8e4dd934efe3d204c3dd9b0bf15463fb640d4b Author: Klaus Kämpf Date: 2019-12-23 19:43:43 +0100 pieusb: fix compiler warnings fixes #196 commit a9ab9df99738d74759a9e8775b3aa2ffa2023f49 Merge: 6f34396a 7f977124 Author: Ralph Little Date: 2019-12-29 19:08:01 +0000 Merge branch '198-fix-compiler-warning-in-scanimage-frontend' into 'master' Resolve "Fix compiler warning in scanimage frontend" Closes #198 See merge request sane-project/backends!286 commit 160b63a9c2c5fee2703c1e14fc8d5a77904cb055 Author: Thierry HUCHARD Date: 2019-12-29 10:52:11 +0100 Using strcmp instead of strncmp, strncmp is not justified. commit 925bf77419967cbd1fa667214cee31f7675dc76f Author: Thierry HUCHARD Date: 2019-12-29 10:50:43 +0100 Removing the png and tiff test from the header. commit 7f977124917b4b9d65ce0e8ececd93777fbe07a1 Author: Olaf Meeuwissen Date: 2019-12-29 17:37:17 +0900 scanimage: Combine conditions to reduce nesting commit 6f34396ab4938bfabfbe3b7db1e24eb1b45706ab Author: Rolf Bensch Date: 2019-12-28 13:58:11 +0100 pixma: backend version 0.26.0 commit eae4137ae1ee19fc2743ae62558f9a62cf8be7b5 Author: Rolf Bensch Date: 2019-12-28 13:55:26 +0100 pixma: update date of man page commit a7c78f41d6ba81d746384b3b43a15286b14ae578 Author: Rolf Bensch Date: 2019-12-28 13:45:02 +0100 pixma: reorder scanner defines commit c83b1a17d23512cd43fd1425f81923f0666c51e9 Merge: b1ad53ff 18670166 Author: Rolf Bensch Date: 2019-12-28 12:53:52 +0000 Merge branch 'master' into 'master' Add model 2019: G6000, G6080, TS5300, TS5380, TS6300, TS6380, TS7330, TS8300,... See merge request sane-project/backends!226 commit 18670166a68c90394de1366e3d7fffcf69ed5136 Author: Ordissimo Date: 2019-12-28 12:53:52 +0000 pixma: Add model 2019: G6000, G6080, TS5300, TS5380, TS6300, TS6380, TS7330, TS8300, TS8380, TS8330, XK60, TS6330, TS3300 and E3300 commit b1ad53fff5687df439b0cc2a3f50ffa731226e43 Merge: bac0c4ab a297073b Author: Rolf Bensch Date: 2019-12-28 13:34:47 +0100 Merge branch 'perillamint/backends-add-canon-pixma-g2010-support' pixma: Add support for Canon PIXMA G2010 Series see merge request sane-project/backends!223 commit a297073bc9d91aea9ebbfff721c6dd27dd415c0d Author: Rolf Bensch Date: 2019-12-28 13:26:54 +0100 pixma: Canon PIXMA G2010 Series is working commit aa76967917e5118362f21f4fa9c67f4da2b8473d Author: Rolf Bensch Date: 2019-12-28 13:26:11 +0100 pixma: fix device define for Canon PIXMA G2010 Series commit 4fbb5d2f1b7068ed8b312c43d72e88f69356a757 Author: Olaf Meeuwissen Date: 2019-12-28 18:52:59 +0900 scanimage: Use destination size to limit strncpy() commit df114df05f8fdb8b3086608ed2d0bf5012b236b5 Author: Olaf Meeuwissen Date: 2019-12-28 18:46:02 +0900 scanimage: Replace string length computations by temporary strings This creates temporary strings that correspond to the colon-delimited username and password that are read from file in `auth_callback()`. The null-terminated strings are used directly to determine lengths. commit 6682223b260f00ebe936307997e90e79712cd94a Author: Olaf Meeuwissen Date: 2019-12-28 18:26:43 +0900 scanimage: Improve readability of auth_callback implementation Rather than repeatedly calling `strchr`, use descriptive variables to hold the result. commit 5e6a111ffa3c8bd1218dd36284ddcb3537ecfe97 Author: Olaf Meeuwissen Date: 2019-12-28 18:03:00 +0900 scanimage: Un-word-wrap auth_callback to improve readability This is one of those cases where word-wrapping to less than 80 or so characters isn't helpful in understanding the code. commit bac0c4abcef14bb6e777cf2a5294cc5ec0838593 Merge: e80034a6 5275b3bb Author: Olaf Meeuwissen Date: 2019-12-28 05:55:59 +0000 Merge branch 'escl-discovery' into 'master' Solves the problem of HP device discovery. See merge request sane-project/backends!285 commit d527110a52569beddb5a631756bccf807a0ebf4e Merge: f956fd00 5275b3bb Author: thierry1970 Date: 2019-12-27 15:23:02 +0100 Merge commit '5275b3bb' into escl-png commit f956fd00ba42da9202225aa1622d923a8a980033 Merge: 5372f218 45c67025 Author: thierry1970 Date: 2019-12-27 15:22:38 +0100 Merge commit '45c67025' into escl-png commit 5275b3bbd65a56eaf0e5e27f48f7d44b7dd28620 Author: thierry1970 Date: 2019-12-27 15:07:10 +0100 Solves the problem of HP device discovery. commit 45c6702552733e04a3b2439172c842cdbf160b94 Author: thierry1970 Date: 2019-12-27 15:04:57 +0100 Formatting of the code to not exceed 80 characters. commit e80034a6e0d5f4cf5efccc64c9a986cfe15d5d8d Merge: 7a76f21c adf9bb83 Author: Olaf Meeuwissen Date: 2019-12-27 11:22:05 +0000 Merge branch '199-hpsj5s-backend-generates-compiler-warnings-in-debian-10' into 'master' Resolve "hpsj5s backend generates compiler warnings in Debian 10" Closes #199 See merge request sane-project/backends!281 commit adf9bb837fc85016ee8e83e8c300910fa43ac400 Author: Ralph Little Date: 2019-12-27 11:22:05 +0000 Resolve "hpsj5s backend generates compiler warnings in Debian 10" commit 7a76f21ccdaa27ca493dfdbb88c04d02c6bd7e5a Merge: d190c559 53efe582 Author: Povilas Kanapickas Date: 2019-12-26 15:31:53 +0000 Merge branch 'genesys-lide-fixes' into 'master' genesys: Various fixes affecting LiDE 100,110,120,200,210,220 See merge request sane-project/backends!284 commit 53efe5822dcc47d77e418d17218914ef8ac0c6ab Author: Povilas Kanapickas Date: 2019-12-26 17:13:34 +0200 genesys: Remove excessive debug logs during data read commit 2b00ef39950e32447080687c4373bda1fae0e955 Author: Povilas Kanapickas Date: 2019-12-26 17:13:33 +0200 genesys: Improve calibration speed by making convergence faster commit fd13c10b5cebb6a2375a4ba40fd17748b97e66c4 Author: Povilas Kanapickas Date: 2019-12-26 17:13:32 +0200 genesys: Fix invalid memory access in ImagePipelineNodeDesegment commit cacc68a6d45ccd656a71ca6b0593a9eeefda22ae Author: Povilas Kanapickas Date: 2019-12-26 17:13:31 +0200 genesys: Fix initial register values on gl124 commit 66ac8c62032829da854ff5a5b29957ee94c25160 Author: Povilas Kanapickas Date: 2019-12-26 17:13:30 +0200 genesys: Fix sensor table for LiDE 120 commit 2661115251be1bb7dd53382773ce2db0066a59d9 Author: Povilas Kanapickas Date: 2019-12-26 17:13:29 +0200 genesys: Fix sensor table for LiDE 110 commit d7d227a3f7b58bd6cbae4a019042c3ea9230d798 Author: Povilas Kanapickas Date: 2019-12-26 17:13:28 +0200 genesys: Fix sensor table for LiDE 200 commit 09a84d11d80b0b7cd18c440701ce15f2640c9526 Author: Povilas Kanapickas Date: 2019-12-26 17:13:27 +0200 genesys: Fix sensor table for LiDE 100 commit 01bdc63d7d3c73465340c19075d5af5b3981d7f3 Author: Povilas Kanapickas Date: 2019-12-26 17:13:26 +0200 genesys: Fix step selector masks on gl124 commit 40a2a0d55491fae4b592b596ac2088b594eecfd3 Author: Povilas Kanapickas Date: 2019-12-26 17:13:25 +0200 genesys: Remove unnecessary model check in calibration init commit 47431a8776881613a993e198c5a1b6330b2eae81 Author: Povilas Kanapickas Date: 2019-12-26 17:13:24 +0200 genesys: Fix exception on LiDE 210 when going back from unknown position commit e2bb81ef01e37cad50a4fde4cf11e24ab0476180 Author: Povilas Kanapickas Date: 2019-12-26 17:13:23 +0200 genesys: Add extra sleep during scan stop for gl646 commit 5372f21810ce6251b8753c694c25c579f3233f50 Author: Ordissimo Date: 2019-12-26 14:11:09 +0000 Fix typo. commit 1a95f30210c15f03e9fc54a4bd6ae5af492a98c2 Author: Ordissimo Date: 2019-12-26 14:08:15 +0000 Fixing the comparison. commit 2ea6552ed3220c0ff9495863c79bb0e366375a51 Author: thierry1970 Date: 2019-12-26 14:03:33 +0100 Fix style. commit 65470e95aad9ed66d8344343ac7619d964aa794b Author: thierry1970 Date: 2019-12-26 14:01:00 +0100 Addition of the TIFF decoder. commit a23dfbfff569da2a02fa0d48f4b87f112a974c29 Author: thierry1970 Date: 2019-12-26 11:55:00 +0100 Standardization of method signatures. commit d190c559c24f0d984a4fba7394a60e2801572722 Merge: 0ae128d1 d1940cf9 Author: Olaf Meeuwissen Date: 2019-12-26 10:27:47 +0000 Merge branch 'epjitsu-backend-generates-compiler-warning-in-debian-10' into 'master' Resolve "epjitsu backend generates compiler warning in Debian 10" Closes #193 See merge request sane-project/backends!267 commit df59815895846505c5fccb84dd309405395dbccb Author: Ordissimo Date: 2019-12-25 18:43:56 +0000 Remove unused function. commit 296a4b68f907013ddf43eed89ea5e06a5af73612 Author: Ordissimo Date: 2019-12-25 18:34:57 +0000 Fix syntaxe. commit d3efc20a0bf5815ccf0393d57bb7a766d4f92bcd Author: Thierry HUCHARD Date: 2019-12-25 18:36:23 +0100 Decoding files in one phase. commit c6e8d381e070cfc8775401a7f35a0dcae23ed01c Author: Thierry HUCHARD Date: 2019-12-25 00:49:52 +0100 Fix syntax. commit 5c15d372488bc4e5d6f08f232433ae3cbfde4bd4 Author: Thierry HUCHARD Date: 2019-12-25 00:39:04 +0100 Adding png support. The decompressors (Jpeg and Png) are in separate files. commit 0ae128d1ab64bfacead805ab5f8177b672ad9f9d Merge: 6d9cb35b 3d124249 Author: Olaf Meeuwissen Date: 2019-12-24 12:03:09 +0000 Merge branch 'gt68xx-backend-generates-compiler-warnings-on-debian-10' into 'master' Resolve "gt68xx backend generates compiler warnings on Debian 10" Closes #194 See merge request sane-project/backends!268 commit 6d9cb35b1faf808f8da602617d0cc739e6deba49 Merge: c77f89de b02a208a Author: Olaf Meeuwissen Date: 2019-12-24 09:05:30 +0000 Merge branch 'as6e-generates-compiler-warnings-in-debian-10' into 'master' Resolve "as6e generates compiler warnings in Debian 10" Closes #192 See merge request sane-project/backends!266 commit c77f89de62502c4e4b86afb68729226d8787723d Merge: f506aceb 3bb5e94d Author: Olaf Meeuwissen Date: 2019-12-24 09:01:13 +0000 Merge branch 'artec-backend-produces-compiler-warnings-on-debian-10' into 'master' Resolve "artec backend produces compiler warnings on Debian 10" Closes #191 See merge request sane-project/backends!265 commit f506aceb33d348b6cfca3149bc3deee19696e1d0 Merge: 92308130 821efb26 Author: Olaf Meeuwissen Date: 2019-12-24 08:59:27 +0000 Merge branch 'ibm-backend-produces-compiler-warnings-in-debian-10' into 'master' Resolve "IBM & Ricoh backends produces compiler warnings in Debian 10" Closes #190 See merge request sane-project/backends!264 commit 92308130f4ec5d978f629a6b78b13184c9407884 Merge: 9527e72a 328a5d65 Author: Ralph Little Date: 2019-12-23 17:04:19 +0000 Merge branch '197-fix-hp3900-backend-compiler-warning' into 'master' hp3900: Fix [-Wtautological-compare] compiler warning Closes #197 See merge request sane-project/backends!280 commit 9527e72a53cdef9f1922c588f4e4213876132efc Merge: 37f96cc8 70ef8db5 Author: Ralph Little Date: 2019-12-23 16:49:11 +0000 Merge branch '195-fix-hp-backend-compiler-warning' into 'master' hp: Fix [-Wstringop-truncation] compiler warning Closes #195 See merge request sane-project/backends!279 commit 37f96cc800f2705acf5ca1a6fad3ff059f455cc4 Merge: 74f60118 fd407cc5 Author: Ralph Little Date: 2019-12-23 16:39:34 +0000 Merge branch 'fix-dll-compiler-warnings' into 'master' Address dll compiler warnings See merge request sane-project/backends!269 commit 328a5d654bef3b8367eb696e3f5e0a9f169d88e0 Author: Olaf Meeuwissen Date: 2019-12-23 21:57:36 +0900 hp3900: Fix [-Wtautological-compare] compiler warning Although the fix changes the backend's logic, it probably matches what was the original code's intent. commit 70ef8db5d6f5a640093a06d733c82fd56c6df429 Author: Olaf Meeuwissen Date: 2019-12-23 21:36:13 +0900 hp: Fix [-Wstringop-truncation] compiler warning commit 74f601188b4ee0dc0737dfbc1418c36f748448e2 Merge: 4bf176c7 2788328e Author: Olaf Meeuwissen Date: 2019-12-23 11:57:10 +0000 Merge branch 'escl-force-formatext' into 'master' indicator of the presence of the DocumentFormatExt field See merge request sane-project/backends!261 commit 4bf176c73efc4f01a519e74d18800ef894b7f0bb Merge: a0e978d4 538b34f4 Author: Povilas Kanapickas Date: 2019-12-23 00:42:01 +0000 Merge branch 'genesys-fix-gl646-scanning' into 'master' genesys: Work around invalid acceleration curves on certain gl646 scanners See merge request sane-project/backends!278 commit 538b34f418f9bf2a2b6f603a715ab9b30f5520a4 Author: Povilas Kanapickas Date: 2019-12-23 02:27:20 +0200 genesys: Fix testing mode in gl646 commit 5d83753b07871fd6e204c44eb74011f06795e0c6 Author: Povilas Kanapickas Date: 2019-12-23 02:27:05 +0200 genesys: Work around bad acceleration curves on certain gl646 scanners commit a0e978d4aee319578aee0e2f8a393836d1ed089b Merge: e8f6a508 fb1dea32 Author: Povilas Kanapickas Date: 2019-12-22 23:59:05 +0000 Merge branch 'genesys-fix-gl646-scanning' into 'master' genesys: Fix completely broken scanning on GL646 See merge request sane-project/backends!277 commit fb1dea325cdbdb8e1f72ee85a31f817d59395408 Author: Povilas Kanapickas Date: 2019-12-23 01:43:39 +0200 genesys: Fix crash when moving back hove on gl646 commit 9f4cabb55c778446a3220e7bdf51128860f70afe Author: Povilas Kanapickas Date: 2019-12-23 01:43:38 +0200 genesys: Fix random lock ups when waiting for motor to stop on gl646 commit fffcb6254410c9da9841447d50e1d7c58528702e Author: Povilas Kanapickas Date: 2019-12-23 01:43:37 +0200 genesys: Fix completely broken backtracing calculation on gl646 commit e8f6a508ca2a022512d5f1a55f058928158606ce Merge: b10c1559 e437f17b Author: Povilas Kanapickas Date: 2019-12-22 21:37:51 +0000 Merge branch 'genesys-8600f-enable-ir-resolutions' into 'master' genesys: Enable additional IR resolutions on CanoScan 8600F See merge request sane-project/backends!276 commit e437f17b40ece55bd34b242d638057b21f444c05 Author: Povilas Kanapickas Date: 2019-12-22 23:23:18 +0200 genesys: Enable more infrared resolutions on 8600F commit d1a0c1589a5c22a5e0c36a18123bed3e6c797744 Author: Povilas Kanapickas Date: 2019-12-22 23:23:17 +0200 genesys: Sort 8600F sensor tables commit 216250361fd9639a6938c297c36a265545bc0dc6 Author: Povilas Kanapickas Date: 2019-12-22 23:23:16 +0200 genesys: Fix uninitialized variable warning commit b10c15595b26d5cd49ff67f25cfefc7f7c240b31 Merge: 408329e8 6fb58864 Author: Povilas Kanapickas Date: 2019-12-22 15:55:53 +0000 Merge branch 'genesys-use-fast-moving-home' into 'master' genesys: Use fast moving when returning home See merge request sane-project/backends!275 commit 6fb588648c9bf57f7c03e2d19759671b00a1ec3d Author: Povilas Kanapickas Date: 2019-12-14 10:20:27 +0200 genesys: Fix infinite loop when we overestimate distance to home sensor commit 01ca9c9030cb1af5303c5d98ecb5ff044c5bd210 Author: Povilas Kanapickas Date: 2019-12-14 10:20:20 +0200 genesys: Use fast moving for most of the distance when moving back home commit 2397d8879a8208c00ad87b1becd8d0a730e53ef1 Author: Povilas Kanapickas Date: 2019-12-14 10:20:18 +0200 genesys: Fix collection of scanhead movement information commit 29166d9b3b2b22b6f812192dae95bdcac112d014 Author: Povilas Kanapickas Date: 2019-12-14 10:20:16 +0200 genesys: Remove rewind() function due to unreliability commit 408329e8cfc7d7025c0798d78aafb5b615887e54 Merge: 01bae130 fd29cae6 Author: Povilas Kanapickas Date: 2019-12-22 15:24:48 +0000 Merge branch 'genesys-fix-motor-acceleration-calculations' into 'master' genesys: Fix calculations of scan head acceleration tables See merge request sane-project/backends!274 commit fd29cae64aad017b09c3bc9e19e2a9b0988d6c1f Author: Povilas Kanapickas Date: 2019-12-14 10:20:26 +0200 genesys: Correctly set LINESEL on 4400F commit 69067f2f7f0f48cf2ae7c20277c18b166f7babce Author: Povilas Kanapickas Date: 2019-12-14 10:20:25 +0200 genesys: Remove no longer used final_exposure commit 35385625deaa0b07c849ce536de4d4be88fb9223 Author: Povilas Kanapickas Date: 2019-12-14 10:20:24 +0200 genesys: Delete unused code commit 38f988dc39afa95d673f3db8caa8bcf28a036467 Author: Povilas Kanapickas Date: 2019-12-14 10:20:23 +0200 genesys: Use correct SHDAREA setting on 4400F commit 67638f55b21f6551252079dd853d21291a3dac29 Author: Povilas Kanapickas Date: 2019-12-14 10:20:22 +0200 genesys: Use a more reasonable backtract distance on gl843 commit 2a6081affe9e8b84d648dd6c1b4079351783b5d0 Author: Povilas Kanapickas Date: 2019-12-14 10:20:21 +0200 genesys: Fix scanning table length calculation on gl843 commit 33bfa923d5dfc5c3ec2a9c8520a146eb0ec74ac5 Author: Povilas Kanapickas Date: 2019-12-14 10:20:19 +0200 genesys: Add a way to create fastest motor acceleration table commit 83fa276b907cfbfbf65ef6bafa4e16fdd963dea6 Author: Povilas Kanapickas Date: 2019-12-14 10:20:17 +0200 genesys: Fix bug in setting up motor tables 3,4,5 on gl843 commit 01bae1305f656794f82b58a78751220efde4fec6 Merge: e0679c31 5cfb4436 Author: Povilas Kanapickas Date: 2019-12-22 14:48:28 +0000 Merge branch 'genesys-remove-broken-resolutions' into 'master' genesys: Disable broken resolutions on LiDE 50 and 80 See merge request sane-project/backends!273 commit e0679c316e85c001c15a2afc0fb13bfa6dec8c18 Merge: 053a2c10 49934f06 Author: Povilas Kanapickas Date: 2019-12-22 14:44:01 +0000 Merge branch 'genesys-fix-4850c' into 'master' genesys: Fix black scans on HP 4850C See merge request sane-project/backends!272 commit 053a2c10d33aac78f863fb24dfa882b354bac576 Merge: 42070a60 8c99dc48 Author: Povilas Kanapickas Date: 2019-12-22 14:38:58 +0000 Merge branch 'genesys-fix-stagger-config' into 'master' genesys: Fix staggerred CCD configuration on OpticFilm 7200i/7300/7500i and Canon 8400F/8600F scanners See merge request sane-project/backends!271 commit 49934f0678843df5c4b1543fade1b60902682c10 Author: Povilas Kanapickas Date: 2019-12-14 10:11:37 +0200 genesys: Fix black side calibration on HP 4850c commit 8d8157b96edee51392084b56480000d5dc0cb5bd Author: Povilas Kanapickas Date: 2019-12-14 10:11:36 +0200 genesys: Fix scan area Y position on HP 4850c commit 355f2ddd4db6c51168f20111ffdafd0d836152ad Author: Povilas Kanapickas Date: 2019-12-14 10:11:35 +0200 genesys: Fix black scans on HP 4850c commit 8c99dc4819d6ef68330a043e8617519df3a938cc Author: Povilas Kanapickas Date: 2019-12-14 09:42:58 +0200 genesys: Fix stagger configuration on 8600F commit a8df8201e9d8c083fcc65c5836d231d8eb95e4f3 Author: Povilas Kanapickas Date: 2019-12-14 09:42:57 +0200 genesys: Fix stagger configuration on 8400F commit 8a2af6d4b2458a155e1bacc932f0b66bfed6710b Author: Povilas Kanapickas Date: 2019-12-14 09:42:56 +0200 genesys: Fix stagger configuration on OpticFilm scanners commit 42070a606cd5c5df73ac1d5d095d6a7c8716c676 Merge: e0d669ac 02b0f0d4 Author: Povilas Kanapickas Date: 2019-12-22 14:23:17 +0000 Merge branch 'genesys-stagger-convert' into 'master' genesys: Convert old broken stagger configuration to a per-sensor configuration See merge request sane-project/backends!270 commit 2788328e1926da293261c0410321565baf1cfe1b Author: Thierry HUCHARD Date: 2019-12-22 13:48:55 +0100 Fix: better readability. commit fd407cc58bce4162a8329fb4ec587837f50c1fd0 Author: Olaf Meeuwissen Date: 2019-12-22 18:34:45 +0900 dll: Make previous change backwardly compatible Older GCC do not know the cast-function-pragma and flag that as a warning. That results in an error on our Debian 9 build. commit e7f6c6e864200fc51a05c8eb5963a78b3251adbd Author: Olaf Meeuwissen Date: 2019-12-22 17:58:39 +0900 dll: Ignore [-Wcast-function-type] compiler warnings commit afc9b62c7e43b99c0e951da9b2aec9484afd7471 Author: Thierry HUCHARD Date: 2019-12-22 09:50:04 +0100 Fix: better readability. commit a993e6438eff1e5b71f1dcc97df478ca954aae9f Author: Olaf Meeuwissen Date: 2019-12-22 16:05:51 +0900 dll: Fix [-Wformat-truncation=] compiler warning Per POSIX, `readdir` returns filenames that are at most `NAME_MAX` long. commit 3d1242496118536af32cd1865ffd177be26ffe83 Author: Ralph Little Date: 2019-12-21 22:53:16 -0800 gt68xx: suppressed strncpy compiler warnings. commit a4360b0a75fe730e78bf6722d7630eba4941a94a Author: Ralph Little Date: 2019-12-21 22:07:39 -0800 gt68xx: suppress snprintf warning with return length check. commit b02a208a943a1a128d3b27bd9a63e33f316ef4a9 Author: Ralph Little Date: 2019-12-21 22:02:50 -0800 as6e: data type correction. size_t is unsigned so -1 error from snprintf would not be properly detected. commit d1940cf9b843d871a8eae32a44d2967d9b2c92da Author: Ralph Little Date: 2019-12-21 21:44:39 -0800 epjitsu: strncpy() compiler warning suppressed. commit 2230614edec80c81868d1c0335b914e2fcd1d75c Author: Ralph Little Date: 2019-12-21 21:24:19 -0800 as6e: compiler warnings suppressed for problematic use of strncat. Replaced with snprintf which simplifies the code and suppresses the warning. commit 3bb5e94d654acae88aef0efef908459a054cd45a Author: Ralph Little Date: 2019-12-21 20:57:48 -0800 artec: strncpy replaced with memcpy() This was a cheeky strncpy hiding what is really the job of memcpy(). commit 821efb262692b3782a948f8ad7cafdc744c1c502 Author: Ralph Little Date: 2019-12-21 20:21:52 -0800 ibm/ricoh: suppress warning by using snprintf instead of strncat commit e0d669acfe01e26c619cbbdf342b6ad475c0b9b3 Merge: 3b0ab4f0 809ccfe6 Author: Olaf Meeuwissen Date: 2019-12-22 03:49:59 +0000 Merge branch 'bump-alpine-to-3.11' into 'master' CI: Bump Alpine from 3.10 to 3.11 See merge request sane-project/backends!263 commit 809ccfe695ccad9607207140829f86a4626fb4aa Author: Olaf Meeuwissen Date: 2019-12-22 12:33:27 +0900 CI: Bump Alpine from 3.10 to 3.11 commit 3b0ab4f097166725ff1f2f718a9a9437371453ca Merge: 3a4d5a00 790bdd82 Author: Olaf Meeuwissen Date: 2019-12-22 02:05:53 +0000 Merge branch 'plustek-silence_compiler_warning' into 'master' Resolve "Plustek backend generates compiler warnings on Debian 10" Closes #189 See merge request sane-project/backends!262 commit 790bdd822a29779a90e7f903b5daf655bc5258cf Author: Ralph Little Date: 2019-12-22 02:05:53 +0000 plustek: Fix [-Wformat-overflow=] compiler warnings on Debian 10 Also fixes a format truncation warning observed elsewhere. commit 6506cd9595843d6a2eab0628dfd4b39c9dc4db3f Author: thierry1970 Date: 2019-12-19 14:30:35 +0100 indicator of the presence of the DocumentFormatExt field, forces for certain printer the output format. commit 3a4d5a002c1c5db5055974bed11b6f8edffb3a76 Merge: 02251c64 97dea949 Author: Olaf Meeuwissen Date: 2019-12-19 12:14:16 +0000 Merge branch '120-fix-all-compiler-warnings-on-the-debian-10-builds' into 'master' Fix umax_pp compiler warnings See merge request sane-project/backends!259 commit 97dea949598220dba43fd1dcadf0f8930f81260f Author: Ralph Little Date: 2019-12-19 12:14:16 +0000 Revert "plustex: suppressed format truncated compiler warning." This reverts commit cc7fbd35e535e22cd13cd58979921e0c01fb38b4 commit 02251c6489f9923a9492bf0eedbce402bf342789 Merge: 277194d5 8de208c2 Author: Olaf Meeuwissen Date: 2019-12-19 11:57:25 +0000 Merge branch 'add_sp112' into 'master' Add SP-112SU model See merge request sane-project/backends!260 commit 8de208c24c5618009e99dc5cb44b7a98a17649ed Author: Stanislav Yuzvinsky Date: 2019-12-19 11:57:25 +0000 Add SP-112SU model commit 277194d5347ddc978ad76f10f76156126a2deab9 Author: Thierry HUCHARD Date: 2019-12-17 20:00:19 +0100 Revert "uniformise signature." This reverts commit 2eff3e82bad5b03dd5af6cf491fe206c48b6e928. commit 2eff3e82bad5b03dd5af6cf491fe206c48b6e928 Author: Thierry HUCHARD Date: 2019-12-17 19:58:14 +0100 uniformise signature. commit f95fcf9d56e44869e4185a595c0a2ad08d13a2be Author: Rolf Bensch Date: 2019-12-15 11:37:41 +0100 pixma: Canon imageCLASS D570 is working See issue sane-project/backends#182 commit 48fd80d20829f36b2db43a6c9d5a5749be18b514 Author: Povilas Kanapickas Date: 2019-12-14 10:20:15 +0200 genesys: Simplify handling of motor step multiplier commit 1d7adfcfc19aaf64f8c192941f18b4b4fc219060 Author: Povilas Kanapickas Date: 2019-12-14 10:20:14 +0200 genesys: Fix naming of step multiplier commit 194920159d299c3450e335f378e7993823d62bc4 Author: Povilas Kanapickas Date: 2019-12-14 10:20:13 +0200 genesys: Remove support for legacy curves commit 3d9113997f30de42066727e81d0cd24c51335b65 Author: Povilas Kanapickas Date: 2019-12-14 10:20:12 +0200 genesys: Switch remaining legacy curve uses to physical curves commit 9a245a1325a16da6a483d17f12905d3c55ebc71e Author: Povilas Kanapickas Date: 2019-12-14 10:20:11 +0200 genesys: Switch unused motor curves to physical format commit 7d477da4047886526e8a69f25ff8e22059ca3cb5 Author: Povilas Kanapickas Date: 2019-12-14 10:20:10 +0200 genesys: Use MotorSlope in gl646 code commit dec996277331dbed6dfa6cb6e2267129a6c0e759 Author: Povilas Kanapickas Date: 2019-12-14 10:20:09 +0200 genesys: Make the size of slope tables configurable by asic type commit c685ac075be5cdc9771a8e36bb5a65ff54742b6f Author: Povilas Kanapickas Date: 2019-12-14 10:20:08 +0200 genesys: Return MotorSlopeTable out of *_generate_slope_table() commit 8731a6cc5d0f025ba3800872eb8bc3c83f595d2c Author: Povilas Kanapickas Date: 2019-12-14 10:20:07 +0200 genesys: Return MotorSlopeTable out of *_create_slope_table3() commit 7c6229f272bace0d022f08842afeffb9ef28e958 Author: Povilas Kanapickas Date: 2019-12-14 10:20:06 +0200 genesys: Rename MotorSlopeTable::{scan_steps -> steps_count} commit 54034c3fae484974898ec162cc9825b608c5983a Author: Povilas Kanapickas Date: 2019-12-14 10:20:05 +0200 genesys: Fix Opticfilm 7200i and 7500i motor curves commit 868c4378962f1dade54a6ef2ea1fe97dd97348da Author: Povilas Kanapickas Date: 2019-12-14 10:20:04 +0200 genesys: Convert hardcoded motor slopes to physical slope config commit 465077c6cb6c832708f1da28563864d910e64fac Author: Povilas Kanapickas Date: 2019-12-14 10:20:03 +0200 genesys: Remove manual override of the first value in motor tables commit f605e7c2297e6d26c8d3521301206b25c3ae40a8 Author: Povilas Kanapickas Date: 2019-12-14 10:20:02 +0200 genesys: Fix testing mode recording of scanner_slow_back_home_ta() commit c1d791f11cdbfbf2090570b68be17bf3749204a2 Author: Povilas Kanapickas Date: 2019-12-14 10:20:01 +0200 genesys: Raise error when TA scan head takes too long to return home commit 8270a82bc0423df7739813c734307e3a2ac87052 Merge: fdcb2fa5 7c34046a Author: Olaf Meeuwissen Date: 2019-12-14 08:13:54 +0000 Merge branch 'escl-2019' into 'master' See merge request sane-project/backends!242 commit 7c34046a396045c8e042d80674c6ef1ea880d97d Author: Touboul Nathane Date: 2019-12-14 08:13:54 +0000 Add escl backend commit 5cfb44366bb6e2405a573c03c980bd85445fe3bd Author: Povilas Kanapickas Date: 2019-12-14 10:13:09 +0200 genesys: Disable broken resolutions on LiDE 50 and 80 commit 02b0f0d474fddffa0097a549336f8e389d6bd50c Author: Povilas Kanapickas Date: 2019-12-14 09:12:29 +0200 genesys: Convert old broken stagger configuration to per-sensor config commit 4c0f63052b6c91b51c9ef2d57ffccb62ec6c6fa7 Author: Povilas Kanapickas Date: 2019-12-14 09:12:28 +0200 genesys: Add a way to configure per-sensor stagger config commit fdcb2fa5e8d6a1a4856c88fbf8787ecc4cfc768c Author: m. allan noah Date: 2019-12-11 21:10:07 -0500 Update fujitsu.desc status for iX1500 commit 58b4371bb50ee68c5eafcf4757a9d25d525e4e4f Merge: ae732126 4ef2e398 Author: Povilas Kanapickas Date: 2019-12-10 23:39:25 +0000 Merge branch 'genesys-remove-sensor-profile' into 'master' genesys: Remove sensor profile struct See merge request sane-project/backends!257 commit ae732126b94a867ba59d7e55e67c4d4d48722bd1 Merge: 037f0671 3d068a9e Author: Povilas Kanapickas Date: 2019-12-09 17:33:39 +0000 Merge branch 'genesys-motors-refactor' into 'master' genesys: Extract move chip-specific motor handling code to the common area See merge request sane-project/backends!256 commit 037f06712ecbba2033ae514b18f54b32e529a02e Merge: 4156fae1 5b7c19a7 Author: Povilas Kanapickas Date: 2019-12-09 17:06:05 +0000 Merge branch 'genesys-reduce-duplication' into 'master' genesys: Reduce duplication in scan head movement routines See merge request sane-project/backends!255 commit 4ef2e3987234f03e765a5290c34823dcb9aef693 Author: Povilas Kanapickas Date: 2019-12-08 11:42:32 +0200 genesys: Remove remaining uses of SensorProfile commit 7971ee56934e300ebd564fdf0045eaaeaf232193 Author: Povilas Kanapickas Date: 2019-12-08 11:42:31 +0200 genesys: Use sensor profile information directly from profiles commit 524c9de1fa0cc953fc3b441db22ca141cf2d52d4 Author: Povilas Kanapickas Date: 2019-12-08 11:42:30 +0200 genesys: Fix calibration exposure in testing mode commit 791433c895a0ed67aebd0696bf857cdbf0cfd938 Author: Povilas Kanapickas Date: 2019-12-08 11:42:29 +0200 genesys: Duplicate SensorProfile information into Genesys_Sensor struct commit 716689161dd3013b093c75e3a18dea95efc03f0d Author: Povilas Kanapickas Date: 2019-12-08 11:42:28 +0200 genesys: Use correct sensor for scanning on gl124 commit 1f33bafe5d561660d0a414a45b6788e5e9e32f88 Author: Povilas Kanapickas Date: 2019-12-08 11:42:27 +0200 genesys: Remove unused fallback sensor profile code commit a7fd1d6ae1fc499605cba9bea5bb8aad0b5113dd Author: Povilas Kanapickas Date: 2019-12-08 11:42:26 +0200 genesys: Simplify sensor profile definition commit 99101d43194999dfe032e473351aea46dd9a833b Author: Povilas Kanapickas Date: 2019-12-08 11:42:25 +0200 genesys: Move ResolutionFilter definition above SensorProfile commit 7a2d3df0e3c9f0c2a9a99d08a4c90d44ba4fde77 Author: Povilas Kanapickas Date: 2019-12-08 11:42:24 +0200 genesys: Use correct sensor for calibration on gl847 commit 6c8c4bb74f48f01a46d5f80ac94abf035164ca91 Author: Povilas Kanapickas Date: 2019-12-08 11:42:23 +0200 genesys: Use correct sensor for calibration on gl846 commit 4dfa7d25a327ea84225700545ec81556c3c16115 Author: Povilas Kanapickas Date: 2019-12-08 11:42:22 +0200 genesys: Use correct sensor for calibration on gl124 commit 059da17ac06a880c329af6ab16713c83689bc092 Author: Povilas Kanapickas Date: 2019-12-08 11:42:21 +0200 genesys: Simplify register definitions on gl846 commit cb64243e5dcf4132abb24238104735eea2fbee3b Author: Povilas Kanapickas Date: 2019-12-08 11:42:20 +0200 genesys: Simplify register definitions on gl847 commit 06742ab7d44a8764a4f760da806e20a1c71405d9 Author: Povilas Kanapickas Date: 2019-12-08 11:42:19 +0200 genesys: Simplify register definitions on gl124 commit 4156fae159d707a145ac9728f21d7adb7a7573f0 Merge: 560af93a 738444cd Author: Rolf Bensch Date: 2019-12-04 16:10:27 +0000 Merge branch 'debug_add_timestamp' into 'master' add timestamp to debug outputs See merge request sane-project/backends!228 commit 560af93a391f94bf57b202f5f95b88b00659e638 Author: Rolf Bensch Date: 2019-12-04 17:07:20 +0100 pixma: update manpage commit 34922d957413688469627fb9d9761fe2df4bd8bc Author: Louis Lagendijk Date: 2019-12-04 00:56:37 +0100 pixma: fixed MB5400 ADF scan. MB5400 works upto 1200DPI and with ADF or ADF-duplex commit 0bbb7ef3ba837162929f946595aa177963c3de19 Author: Louis Lagendijk Date: 2019-12-03 22:05:13 +0100 tstbackend: make it compile again commit 46eacadc78a3aa34aaa68a4ecd9e2b9316a2399a Author: Louis Lagendijk Date: 2019-12-03 22:01:08 +0100 pixma_bjnp.c: fix parsing of mfnp in pixma config file commit 22c1bceda2c4bd1992a279ebc35f3f1c93567a10 Merge: fa75eff7 3a1c1bad Author: Olaf Meeuwissen Date: 2019-12-03 11:02:34 +0000 Merge branch 'update_uk' into 'master' Update Ukrainian translation See merge request sane-project/backends!254 commit 3a1c1bad32f983037bc537d10007c691b61a7558 Author: Yuri Chornoivan Date: 2019-12-03 11:02:34 +0000 Update Ukrainian translation commit fa75eff7b4df9bf98f64567697487b9a9a9e902b Merge: f41bd003 311b9ff5 Author: Olaf Meeuwissen Date: 2019-12-02 11:59:50 +0000 Merge branch '178-ci-requires-remote-resources-to-succeed-in-tools-update-upstreams-sh' into 'master' Resolve "CI requires remote resources to succeed in ./tools/update-upstreams.sh" Closes #178 See merge request sane-project/backends!253 commit 311b9ff5bfb3ca2a14d48c5c00a08597b65fb40a Author: Olaf Meeuwissen Date: 2019-12-02 20:40:20 +0900 Remove dependency on external resources during CI. Fixes #178 The update-upstreams.sh script is kept for the convenience of those who want or need to use it. It has been slightly modified to provide more feedback in case of error conditions. commit f41bd003d06505c4d4cf6b10f103a143b1fdfa58 Merge: 1c4cff20 f98bec2a Author: Povilas Kanapickas Date: 2019-12-01 13:22:45 +0000 Merge branch 'genesys-use-full-scan-ta' into 'master' genesys: Use full scan initialization in slow_back_home_ta() See merge request sane-project/backends!251 commit 3d068a9eee49cae318aa9b14e7d69f26d219e896 Author: Povilas Kanapickas Date: 2019-12-01 10:43:12 +0200 genesys: Fix TA support in scanner_move() commit 6a5fd2d36c288c396be576612c00e4db0c5d6e17 Author: Povilas Kanapickas Date: 2019-12-01 10:43:11 +0200 genesys: Support multiple scan methods in scanner_move() commit 27aea235b47c7ba6c98f6788f57d1d87c104e330 Author: Povilas Kanapickas Date: 2019-12-01 10:43:10 +0200 genesys: Rename slow_back_home() to move_back_home() commit 35c8cb84f81102dc8c9483a9f7175291c500d0b1 Author: Povilas Kanapickas Date: 2019-12-01 10:43:09 +0200 genesys: Extract slow_back_home_ta() to common code commit 1c4cff20050fcfe9238a32b9ad4fdd2d919e081d Merge: 6b4be81e c24a9566 Author: Olaf Meeuwissen Date: 2019-12-01 08:11:28 +0000 Merge branch 'pixma-fix-usbid-case-warning' into 'master' canon_pixma: Use lowercase in usbid description to avoid warning See merge request sane-project/backends!249 commit 5b7c19a7d58f5fac6752fd2b53b1cf376db1e003 Author: Povilas Kanapickas Date: 2019-12-01 10:08:59 +0200 genesys: Reduce duplication of *_stop_action() across the ASICs commit 9e092f9d67651b5db82500098b1b5c7f96d1547a Author: Povilas Kanapickas Date: 2019-12-01 10:08:58 +0200 genesys: Extract scanner_is_motor_stopped() to use across the asics commit c2863d6ba14cccd615eb43a371c22d3d2cac23f3 Author: Povilas Kanapickas Date: 2019-12-01 10:08:57 +0200 genesys: Fix inconsistent check of scanner status in *_stop_action() commit a90ab552a9e78b6b0aec318998865b0659483eb5 Author: Povilas Kanapickas Date: 2019-12-01 10:08:56 +0200 genesys: Extract scanner_stop_action_no_move() to use across the asics commit 6913513dc26c98a0965429086831f306d3279c91 Author: Povilas Kanapickas Date: 2019-12-01 10:08:55 +0200 genesys: Extract regs_set_optical_off() to use across the ASICs commit 052aa0162608fdb435f6f90733ca6d34911a2df9 Author: Povilas Kanapickas Date: 2019-12-01 10:08:54 +0200 genesys: Reduce duplication of *_feed() across different ASICs commit e435036b97fb0876804b06be7b043e280f2c8caf Author: Povilas Kanapickas Date: 2019-12-01 10:08:53 +0200 genesys: Use single function to set exposure on all ASICs commit 6b4be81e9002006b9c675bfa40f73e0490b183ce Merge: 072487ee 97ae3fc9 Author: Povilas Kanapickas Date: 2019-11-30 23:40:52 +0000 Merge branch 'genesys-motors-refactor' into 'master' genesys: Motors refactor See merge request sane-project/backends!250 commit 072487ee7bcd0489e722d59df8e09a2a7410f144 Author: Louis Lagendijk Date: 2019-11-30 23:51:03 +0100 pixma: made backend obey local_only setting in sane_get_devices commit f98bec2afb2a093cfbc5b86cabcea478e907cb3e Author: Povilas Kanapickas Date: 2019-11-30 19:19:21 +0200 genesys: Use full scan initialization in slow_back_home_ta() commit 66a95875d402ef27ef49771f663f06a5a8cc4d60 Author: Povilas Kanapickas Date: 2019-11-30 19:19:20 +0200 genesys: Remove duplicate operation a register The same value is set just several lines above. commit 4743a0235359ef9f5749aa9a38850b199a437368 Author: Povilas Kanapickas Date: 2019-11-30 19:19:19 +0200 genesys: Remove duplicate operation on a register init_regs_for_scan_session() already sets the value of the register to what we expect. commit 8aee1f0982dbca641b5553766d692c0626b3d8f8 Author: Povilas Kanapickas Date: 2019-11-30 19:19:18 +0200 genesys: Expose slow_back_home_ta() to the cmd set commit 97ae3fc94621ecbf6e01d0ddbefcf2bc176155fa Author: Povilas Kanapickas Date: 2019-11-30 19:06:52 +0200 genesys: Reduce duplication of slow_back_home() across different asics commit cba6086ce79fcc0debce0a47925b8b73c61ed29b Author: Povilas Kanapickas Date: 2019-11-30 19:06:51 +0200 genesys: Expose init_regs_for_scan_session() to the cmd set commit 79b4d1560ad0121dcd58edb4273fa5a05b502839 Author: Povilas Kanapickas Date: 2019-11-30 19:06:50 +0200 genesys: Remove no longer needed global settings modification commit a355df168a6f0990559dd6eb574f89c5fa451257 Author: Povilas Kanapickas Date: 2019-11-30 19:06:49 +0200 genesys: Expose update_home_sensor_gpio() in the cmd set commit 326733a479888716a4d690b04cc6f288e8570a95 Author: Povilas Kanapickas Date: 2019-11-30 19:06:48 +0200 genesys: Simplify slow_back_home() on gl646 commit 98dbd206eebda52f704b06b032f9cd8032c682a9 Author: Povilas Kanapickas Date: 2019-11-30 19:06:47 +0200 genesys: Reduce duplication of slope upload on gl646 commit 66264538048e89679cc17bc0cea0b37b1f1f39ce Author: Povilas Kanapickas Date: 2019-11-30 19:06:46 +0200 genesys: Reduce duplication of scanner status printing commit df8a411de386ed632b6cda98ec8e9bef0fce121f Author: Povilas Kanapickas Date: 2019-11-30 19:06:45 +0200 genesys: Extract reliable reading of home sensor to separate function commit 2ca325c63854c3287800d82bc9abdab9cd2d4e50 Author: Povilas Kanapickas Date: 2019-11-30 19:06:44 +0200 genesys: Simplify scanner status handling commit 7385e0d305ecac52e5fff85079d2e60928d0488c Author: Povilas Kanapickas Date: 2019-11-30 19:06:43 +0200 genesys: Simplify get_gain4_bit() implementation commit 3ada79c35ab6fcb5cea56595573510bc5781ec6c Author: Povilas Kanapickas Date: 2019-11-30 19:06:42 +0200 genesys: Move motor direction register adjustment to low level functions commit 50149e90642d6ba99e04af04eccc68888e2cc630 Author: Povilas Kanapickas Date: 2019-11-30 19:06:41 +0200 genesys: Use enum class for motor flags commit 6c0282e06f190ffcc023f6ba145d54c052853bf4 Author: Rolf Bensch Date: 2019-11-30 17:52:19 +0100 INSTALL.linux: add missing dev package "libusb-1.0.0-dev" commit c24a956685cc13b17a435514f25d5651722d162a Author: Povilas Kanapickas Date: 2019-11-30 17:51:12 +0200 canon_pixma: Use lowercase in usbid description to avoid warning commit 0b4165b27f43b646063ca89c956b8dbefd1a266c Merge: 3dff8085 837ec33c Author: Povilas Kanapickas Date: 2019-11-30 15:04:14 +0000 Merge branch 'genesys-motors-refactor' into 'master' genesys: Motors refactor See merge request sane-project/backends!248 commit 738444cd1ca29d0bfe4633f17f1183d5c8e3f1ad Author: Rolf Bensch Date: 2019-11-26 17:33:07 +0100 add µsec to timestamp commit d9f35d1b5e582b99a1e286cff80d6d22906fd885 Author: Rolf Bensch Date: 2019-10-19 22:00:35 +0200 add timestamp to debug outputs commit 3dff8085e771ca945fc46fd93cdf2eb8454e8470 Merge: 9bee993c acc5fd31 Author: Povilas Kanapickas Date: 2019-11-24 12:19:20 +0000 Merge branch 'genesys-remove-macros' into 'master' genesys: Use enums instead of macro constants See merge request sane-project/backends!246 commit 9bee993c3cd25dac13481a2d641838df77e1b1e7 Merge: f1cf1ff1 9472dce5 Author: Olaf Meeuwissen Date: 2019-11-24 01:59:29 +0000 Merge branch 'fix-scanimage-overflow' into 'master' scanimage: Fix 32-bit overflow when calculating total bytes to transfer See merge request sane-project/backends!234 commit acc5fd318c3d3010f001cf72a16e4f3cc6c99370 Author: Povilas Kanapickas Date: 2019-11-18 22:10:29 +0200 genesys: Replace unneeded uses of macros with enums commit 10662d297336c712ac7499cf293e723ab268d550 Author: Povilas Kanapickas Date: 2019-11-18 22:10:28 +0200 genesys: Remove uses of SETREG and INITREG macros commit 185fdcc9ce0b45e93fff54df24ce35b61c9ccc97 Author: Povilas Kanapickas Date: 2019-11-18 22:10:27 +0200 genesys: Replace defines with constants in register lists commit 6d9259bd4853fa1299816910a7bbaad89cc66604 Author: Povilas Kanapickas Date: 2019-11-18 22:10:26 +0200 genesys: Put chip-specific functionality into namespaces commit f1cf1ff1d97ac7387c4fac22c6e27406b7741e6c Merge: 5cd65e6e f366073b Author: Povilas Kanapickas Date: 2019-11-23 13:10:15 +0000 Merge branch 'genesys-canon-4400f' into 'master' genesys: Add initial support for flatbed mode on Canon 4400F See merge request sane-project/backends!245 commit 5cd65e6e19544d4421bee51336eb61d7841347fe Merge: 7e7f0277 e46b6927 Author: Povilas Kanapickas Date: 2019-11-23 13:09:27 +0000 Merge branch 'correct-man' into 'master' Mention correct man file for ricoh2 See merge request sane-project/backends!243 commit f366073b0835c4005f4f4fc891f407cc4c25a6c3 Author: Povilas Kanapickas Date: 2019-11-23 14:54:10 +0200 genesys: Add initial support for flatbed mode on Canon 4400F commit 837ec33c7fe0babb020c1b56aa7029fa310ccf89 Author: Povilas Kanapickas Date: 2019-11-23 12:38:51 +0200 genesys: Make scan flags an enum commit 05e3091d5fb12a853c71e9eb189a4203ea284554 Author: Povilas Kanapickas Date: 2019-11-23 12:38:50 +0200 genesys: Remove duplication of motor startup commit 9cd373fe6c5e4b9d1aa68e54ba72aa1bddf3bc2c Author: Povilas Kanapickas Date: 2019-11-23 12:38:49 +0200 genesys: Return MotorSlopeTable out of sanei_genesys_slope_table() commit 63b0366b43cb256b9e7b83df29fe8884c335dce7 Author: Povilas Kanapickas Date: 2019-11-23 12:38:48 +0200 genesys: Store motor profile tables in std::vector commit cbe45396feb3796e3d9e7a0aac34490832fff9e0 Author: Povilas Kanapickas Date: 2019-11-23 12:38:47 +0200 genesys: Move static initialization functionality to a separate file commit f6f27e053953661c7bbf3261a91ca71553772945 Author: Povilas Kanapickas Date: 2019-11-23 12:38:46 +0200 genesys: Implement building of motor tables based on physical slope commit 34bba237b5c0ed6b29fd93150b4be6d3f341aaf6 Author: Povilas Kanapickas Date: 2019-11-23 12:38:45 +0200 genesys: Don't select motor profile twice during setup of same scan commit b43a21d25a4ae4d4fdeb37d7f5156e90a6cdf17d Author: Povilas Kanapickas Date: 2019-11-23 12:38:44 +0200 genesys: Add new motor slope type commit 15819a7d12eef1e10921b0f4b1f1d10746786bcb Author: Povilas Kanapickas Date: 2019-11-23 12:38:43 +0200 genesys: Add tests for sanei_genesys_create_slope_table3() commit ddcce5295faa5cfdc822f308391d917d496a3656 Author: Povilas Kanapickas Date: 2019-11-23 12:38:42 +0200 genesys: Use StepType enum more commit c6784d2f1db40a65721766b6fc6442a93bc6eab8 Author: Povilas Kanapickas Date: 2019-11-23 12:38:41 +0200 genesys: Simplify API of sanei_genesys_create_slope_table3() commit ce59a69224cb24a07f27f6f8ccd4a38f54476e9e Author: Povilas Kanapickas Date: 2019-11-23 12:38:40 +0200 genesys: Record motor slope tables in the config test commit d8e8899a760fc24e175f2641f69af7ba3eb674af Author: Povilas Kanapickas Date: 2019-11-23 12:38:39 +0200 genesys: Remove unused code commit e46b6927dd344c8b0aa1ab4d5021c2b7163885a5 Author: Stanislav Yuzvinsky Date: 2019-11-17 17:08:42 +0300 Mention correct man file for ricoh2 commit 7e7f02773e1e62ef3ae16229863fa8561e78d3e2 Author: Alex Belkin Date: 2019-11-05 22:01:53 +0300 xerox_mfp: Fix crash in test mode Do not decode JPEG into output buffer if it's NULL. Also, I add assert() for `dev->decData` size, which is never checked anywhere. Thanks to Michal Nowak for report and testing. Fixes #128. References: https://gitlab.com/sane-project/backends/issues/128 Tested-by: Michal Nowak commit 3c863c2bd9a2f06b3a92b93bc1031fe03c44c0a0 Author: Louis Lagendijk Date: 2019-11-11 13:22:59 +0100 sane-pixma.man: fixed typos commit 2cffe0e7a6a836091b47d301f3018f42d6678b69 Merge: aeadb8ef e2e72535 Author: Povilas Kanapickas Date: 2019-11-10 20:36:01 +0000 Merge branch 'genesys-smoke-tests' into 'master' genesys: Add smoke tests See merge request sane-project/backends!241 commit aeadb8ef1eaf9853d9a40dc2dc0dc692633ef5c8 Merge: fa01471c 391d4721 Author: Povilas Kanapickas Date: 2019-11-10 19:45:16 +0000 Merge branch 'genesys-scanner-interface' into 'master' genesys: Low-level scanner interface See merge request sane-project/backends!240 commit 391d4721273eeeb94b5b111d396c5f085c1c1fde Author: Povilas Kanapickas Date: 2019-10-26 11:38:48 +0200 genesys: Rename record_{test => progress}_message commit e2e3ea094770b888b6cdad8866fae622b403b66b Author: Povilas Kanapickas Date: 2019-10-26 11:38:47 +0200 genesys: Route sleep calls through low level scanner interface commit 521c0428892fd001a4db9e00c5e8c5e836422cdd Author: Povilas Kanapickas Date: 2019-10-26 11:38:46 +0200 genesys: Route low-level status debug messages through scanner interface commit 779725ab55cebb0a9f3c2800f2ce411c91ba4584 Author: Povilas Kanapickas Date: 2019-10-26 11:38:45 +0200 genesys: Extract attach_usb_device() commit 908053751f32faf162d44dd4dc098f94ad1ad091 Author: Povilas Kanapickas Date: 2019-10-26 11:38:44 +0200 genesys: Use generic USB device interface througout the backend commit 978ad5e52bdafbf4c713e005b86c4174efa06b7e Author: Povilas Kanapickas Date: 2019-10-26 11:38:43 +0200 genesys: Add interface for USB devices to allow mocking of them commit 4e9b47de56a8ce97e069ea9cbbf9c7eaa4c672e0 Author: Povilas Kanapickas Date: 2019-10-26 11:38:42 +0200 genesys: Move low level data writing API to scanner interface commit 0fed92b0ff541ccccad04bd8afbe133cd303181c Author: Povilas Kanapickas Date: 2019-10-26 11:38:41 +0200 genesys: Remove unneeded wrapper for scanner interface functions commit 0582b5448c1943ea73ba51f7c2e8a9b19c3f566c Author: Povilas Kanapickas Date: 2019-10-26 11:38:40 +0200 genesys: Move low-level protocol implementation to ScannerInterfaceUsb commit c6e60013eff280689e44f3febde0fce622784a17 Author: Povilas Kanapickas Date: 2019-10-26 11:38:39 +0200 genesys: Add low level scanner test interface commit 0ea8ec115cf69dce5735700dfd4b68726f78f436 Author: Povilas Kanapickas Date: 2019-10-26 11:38:38 +0200 genesys: Add low level interface for interaction with the scanner commit fa01471c9287663bba02225e2b9c0c300271ec67 Author: m. allan noah Date: 2019-11-10 10:46:50 -0500 fujitsu backend v135 - set has_MS_lamp=0 for fi-72x0, bug #134 commit 8c4879c835256a5d02f15f0fbdabd3b3d73304de Merge: 99d1abe1 9d955257 Author: Povilas Kanapickas Date: 2019-11-10 14:56:00 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!239 commit 99d1abe1e7fd210570e3b55503114efe87f6d678 Author: m. allan noah Date: 2019-11-10 09:40:47 -0500 fujitsu backend: add iX1500 IDs - updated per bug #131 commit 9d9552575d6c578cda0a3892403158db33d0e00e Author: Povilas Kanapickas Date: 2019-11-02 17:13:20 +0200 genesys: Extract MethodResolutions::get_resolutions() commit 42a58387b6847ab820dbd80ab1a54597eb04db96 Author: Povilas Kanapickas Date: 2019-11-02 17:13:19 +0200 genesys: Extract conversion of ScanColorMode to separate functions commit 3ad5a9241486b8fa785d37c92892919d1cda8ec0 Author: Povilas Kanapickas Date: 2019-11-02 17:13:18 +0200 genesys: Move conversion of ScanMethod to option strings to enums.cpp commit 5c0838e42383d37256dc775c246d3f476234b95a Merge: 779d09a0 72137383 Author: Povilas Kanapickas Date: 2019-11-10 14:32:41 +0000 Merge branch 'genesys-fix-calibration' into 'master' genesys: Fix calibration issues See merge request sane-project/backends!238 commit 779d09a0b56c65cfdd776c16b46d4efec0fe256b Author: m. allan noah Date: 2019-11-10 09:01:06 -0500 canon_dr backend v58 - adjust wait_scanner to set runRS only as a last resort, bug #154 commit a15d960228c028154766a0018a4dcffa304da95d Merge: e4a908d8 d2aaa822 Author: Povilas Kanapickas Date: 2019-11-10 12:12:41 +0000 Merge branch 'genesys-logging-improvements' into 'master' genesys: Miscellaneous logging improvements See merge request sane-project/backends!237 commit e4a908d88b1736902c30f23caa6a3ace032a71aa Merge: 05f313cc a1bc0d33 Author: Povilas Kanapickas Date: 2019-11-10 12:04:51 +0000 Merge branch 'genesys-session-cleanup' into 'master' genesys: More cleanup for ScanSession See merge request sane-project/backends!236 commit 9472dce5f7cbd4446fc1bc2bc4a580f3e0a981a4 Author: Povilas Kanapickas Date: 2019-11-09 22:58:30 +0200 scanimage: Fix 32-bit overflow when calculating total bytes to transfer commit 05f313cc53106de0a284f157aac646bf4ce9205d Merge: fae60806 c2479ed0 Author: Povilas Kanapickas Date: 2019-11-10 11:22:41 +0000 Merge branch 'genesys-improve-8400f' into 'master' genesys: Add support for 3200 dpi resolution on 8400F See merge request sane-project/backends!235 commit 7213738359a7b54018711f2300ae4f2bf128a9a9 Author: Povilas Kanapickas Date: 2019-11-10 10:32:11 +0200 genesys: Make sure correct session data is used for saving calibration commit 68f388eb6a9427d340a21a7aeb6bb6082d054aeb Author: Povilas Kanapickas Date: 2019-11-10 10:32:10 +0200 genesys: Remove is_compatible_calibration() wrappers commit ced1ee03066edcc4513ff8364940e238c20ce930 Author: Povilas Kanapickas Date: 2019-11-10 10:32:09 +0200 genesys: Use common impl of is_compatible_calibration() on gl646 commit 8659536e1b8b820e281a5a8f8fc264fa6bbffb9d Author: Povilas Kanapickas Date: 2019-11-10 10:32:08 +0200 genesys: Implement calculate_scan_session() on gl646 commit 84e4ababa517063514cfc4395fe8d35df787f5f0 Author: Povilas Kanapickas Date: 2019-11-10 10:32:07 +0200 genesys: Correctly serialize GenesysFrontendLayout commit 8557e0c2204e4d1ffae17b05341e3e0a60fb31ca Author: Povilas Kanapickas Date: 2019-11-10 10:32:06 +0200 genesys: Don't modify global state in *_is_compatible_calibration() commit f4f58f6c185123f907e0fd71d067ae009e61a816 Author: Povilas Kanapickas Date: 2019-11-10 10:32:05 +0200 genesys: Remove no longer used Genesys_Current_Setup commit 8c6987e5a1002bbe40a5b52b1bd761e090cd3947 Author: Povilas Kanapickas Date: 2019-11-10 10:32:04 +0200 genesys: Rewrite is_compatible_calculation() to use session data commit 9662a501a9bc5347884644a9aa746c9ee3192678 Author: Povilas Kanapickas Date: 2019-11-10 10:32:03 +0200 genesys: Use data from session directly when possible commit fae6080630ee1c03186e5fb1e36e74d7e3778b65 Merge: 71b817ce 44812981 Author: Povilas Kanapickas Date: 2019-11-09 21:09:17 +0000 Merge branch 'genesys-misc-fixes' into 'master' genesys: Miscellaneous fixes See merge request sane-project/backends!233 commit 44812981295b0300b65aadd9e7958c0c6cd81a6f Author: Povilas Kanapickas Date: 2019-11-09 22:51:42 +0200 genesys: Fix invalid memory access on DSMobile 600 and DocketPort 467 commit c6b85390323fa357573ef0f604494bfcd1c4bfe1 Author: Povilas Kanapickas Date: 2019-11-09 22:51:41 +0200 genesys: Disable support for Canon Image Formula 101 commit 3632d4ec3795ce498be0285991285c92d57a6573 Author: Povilas Kanapickas Date: 2019-11-09 22:51:40 +0200 genesys: Fix out of bounds write during initialization of shading data commit e967d98aabe326bb1d6d043edd55adf8f5b7e060 Author: Povilas Kanapickas Date: 2019-11-09 22:51:39 +0200 genesys: Disable broken support for 4800 dpi on LiDE 210 and 220 commit cb7521e7c11e63abcc4c72ff580987805541b568 Author: Povilas Kanapickas Date: 2019-11-09 22:51:38 +0200 genesys: Remove currently unsupported resolutions on 8600F commit 18206d845d92ea036384cc8b20140cf6012ae541 Author: Povilas Kanapickas Date: 2019-11-09 22:51:37 +0200 genesys: Fix crash on startup on Canon 4400F commit a5a03dfce2dc1e7237180ff17b710de65ad4385b Author: Povilas Kanapickas Date: 2019-11-09 22:51:36 +0200 genesys: Remove incorrect assert on gl841 commit a7be52a5a11aaa602fdd782af11b4e98156fff4d Author: Povilas Kanapickas Date: 2019-11-09 22:51:35 +0200 genesys: Fix crash on gl646 when sensor matches any resolution commit ddb8685755783b59053ae072c68755abfeb6cce3 Author: Povilas Kanapickas Date: 2019-11-09 22:51:34 +0200 genesys: Fix null name of the "extras group" option leading to crashes commit 54edeaf69d187c5301204b8ac40152a4023af8f6 Author: Povilas Kanapickas Date: 2019-11-09 22:51:33 +0200 genesys: Inherit from std::exception publicly commit ecb1d899b936f83638adbf704ef4b8f91435c799 Author: Povilas Kanapickas Date: 2019-11-09 22:51:32 +0200 genesys: Fix typo which prevented calibration data from being used commit cac57c3e9fa1f38ec8e6b886639c08005d69c535 Author: Povilas Kanapickas Date: 2019-11-09 22:51:31 +0200 genesys: Remove duplicate handling of document end This duplicates work done in genesys_fill_read_buffer() commit 71b817cef8e28c3c4a8aa1a7cbc23478e66ce783 Author: Olaf Meeuwissen Date: 2019-11-07 20:24:31 +0900 hpaio.desc: Sync with hplip-3.19.11 Re #166 commit ee3f9b47ece844262f4614ebedfd9f21bebc3f24 Author: Rolf Bensch Date: 2019-11-06 18:08:41 +0100 pixma: backend version 0.25.1 commit eca978c258fb4e6e1f24dd47ff77dbaa36b80230 Author: Louis Lagendijk Date: 2019-11-05 23:03:27 +0100 pixma_bjnp: added options to completely disable networking or skip auto detection. commit 0f493e155aae4b3411fef89f7cdc98eb373c7a7f Author: Louis Lagendijk Date: 2019-11-05 20:09:42 +0100 Fixed pixma_bjnp.c commit a1ecd8c15887c62c052f02952f4f90e32b38f197 Author: Louis Lagendijk Date: 2019-11-05 19:45:30 +0100 Fixed completely messed up pixma_bjnp.c commit bda9ae39bad41b32992a84ddec8fddc24ce7ee74 Author: Louis Lagendijk Date: 2019-11-05 19:22:11 +0100 pixma_bjnp.c sane-pixma.doc Fix trailing spaces commit 462df7d6ad72b1c35e155987ec9f173f45a1ee91 Author: Louis Lagendijk Date: 2019-11-05 18:31:39 +0100 usane-pixma: - Document that Canon seems to be remving the supported MFNP and BJNP protocols in new printers/scanners - Added an mfnp example in the pixma.conf file commit 739cfc8d83f6b1903c6694a7e5d24e081dd12a18 Author: Louis Lagendijk Date: 2019-11-05 17:16:09 +0100 pixma_bjnp.c: redsign of timeout code commit 5dd50be523375c888ac0c16a32bb046c256e43ca Author: Louis Lagendijk Date: 2019-11-05 14:35:11 +0100 xma_bjnp.c: fixed parsing of model in parse_IEEE1284_to_model commit 766b4937c3bad766c422951b07125e424bdf5efb Author: Louis Lagendijk Date: 2019-11-05 13:56:23 +0100 pixma_bjnp.c Retry TCP connect in case the scanner is not yet ready commit c9a2b3bd23cbe6496aca2f0d977c60341cb4c056 Author: Olaf Meeuwissen Date: 2019-11-04 11:17:44 +0900 utsushi.desc: Sync with upstream commit 6fe1db1c734b9df8afe3c7a5c46203a7c858ece4 Author: Povilas Kanapickas Date: 2019-11-02 17:13:17 +0200 genesys: Use std where needed commit 429d8e4d5b811fa70383ab5d3f8d414733181158 Author: Povilas Kanapickas Date: 2019-11-02 17:13:16 +0200 genesys: Remove unused code commit a7ca16a415e526bae47d9e98eae282408875c001 Author: Povilas Kanapickas Date: 2019-11-02 17:13:15 +0200 genesys: Add file with class forward declarations commit f5410b7738e46689a64e95279ea17b5178356785 Author: Povilas Kanapickas Date: 2019-11-02 17:13:14 +0200 genesys: Add an easy way to override SANE API linkage commit 66c17ebf846406ee68ba9dcd202c197fcdd086ff Author: perillamint Date: 2019-10-22 15:34:04 +0900 pixma: Add support for Canon PIXMA G2010 Series This commit adds support for Canon PIXMA G2010 Series. commit 572c5e6e6100da229dfcc6aef0a10d5551703298 Author: Rolf Bensch Date: 2019-11-01 19:53:41 +0100 pixma: backend version 0.25.0 commit 27cac478e72ca6dbdd035f33d2eefb4574d284c5 Author: Rolf Bensch Date: 2019-11-01 19:52:57 +0100 pixma: CanoScan LiDE 300 & 400 support all scan resolutions commit 053e5fd7526b08795e9a4e20bc9b03d887e532db Merge: 69e40e9a e16a2b05 Author: Rolf Bensch Date: 2019-11-01 19:30:53 +0000 Merge branch 'pixma/lide400_low_dpi' into 'master' CanoScan LiDE400 scans below 300dpi See merge request sane-project/backends!231 commit e16a2b05b1a6584b3ef9fd0506f0645accb70a2d Author: Rolf Bensch Date: 2019-11-01 19:46:16 +0100 pixma_mp150: activate image down-scaling for LiDE300 & 400 we don't need to force >=300 dpi scans anymore commit cffeb11ee63905ae44fb1f4454081674cd21cbb3 Author: Rolf Bensch Date: 2019-11-01 19:44:27 +0100 pixma_mp150: special image format handling only needed for existing sub-images commit 95e208527a1eadc5c4e11e2c083990fe1cde11ea Author: Rolf Bensch Date: 2019-11-01 19:42:16 +0100 pixma_mp150: new function shrink_image() call shrink_image() from post processing image data commit 452b28a81fba249d4afd2071ad7e79b849c37e17 Author: Rolf Bensch Date: 2019-11-01 19:21:50 +0100 pixma_mp150: use mp->scale to calculate scan parameters for down-scaling images the values for xdpi, ydpi, x, xs, y and wx must be expanded to minimum image size commit b4cf3343bd0b253ad5df00772983e390336fcfda Author: Rolf Bensch Date: 2019-11-01 19:16:14 +0100 pixma_mp150: add comments and some debug outputs commit 5d64760f0f61092c2f18b04414bd41a75d163e63 Author: Rolf Bensch Date: 2019-11-01 19:06:53 +0100 pixma_mp150: new sub-driver parameter scale commit bd811cb0b0b7d4e41910193608a8a7c3b02c178c Author: Rolf Bensch Date: 2019-11-01 19:02:01 +0100 pixma: new device option: min_xdpi used for scaling scanned images commit 69e40e9a62a4157165c9865dc3653f293ccaeaab Merge: e97112fa 1bd2dcc9 Author: Olaf Meeuwissen Date: 2019-10-31 12:03:33 +0000 Merge branch 'ci-fedora-31' into 'master' CI: Bump Fedora from 30 to 31 See merge request sane-project/backends!230 commit 1bd2dcc9c81c9d930cf943a4024deb3716d18817 Author: Olaf Meeuwissen Date: 2019-10-31 18:23:15 +0900 CI: Bump Fedora from 30 to 31 commit b4ce719973a45aeaf55d732c5847d5e460943bb5 Author: Olaf Meeuwissen Date: 2019-10-30 20:28:33 +0900 kvs40xx: Fix [-Wcast-function-type] compiler warning. Re #120 The changes are meant to make explicit what the run-time or compiler is thought to be doing anyway. commit e97112fa9649a4a7f9f5fda57ca9eac94d564447 Merge: fe30fbe8 ffcc232b Author: Olaf Meeuwissen Date: 2019-10-29 11:28:57 +0000 Merge branch 'patch-1' into 'master' Added the list of devices supported by scangearmp2. See merge request sane-project/backends!227 commit ffcc232b6cc2ec5e4fd4079742ece7558cd8c48b Author: Ordissimo Date: 2019-10-29 11:28:57 +0000 Add list of devices supported by scangearmp2 commit d2aaa822f36c0643323eb6abe6f2c7c04591c990 Author: Povilas Kanapickas Date: 2019-10-27 11:48:36 +0200 genesys: Allow use of TIE() macro outside the genesys namespace commit 87b5a78e377b5febc2acb79974e30029586bb974 Author: Povilas Kanapickas Date: 2019-10-27 11:48:35 +0200 genesys: Add more logging commit 1faa3223089cad06d99061cc8c9706079aa08e24 Author: Povilas Kanapickas Date: 2019-10-27 11:48:34 +0200 genesys: Add a way to log messages using DBG_HELPER commit 9ca0a109381ebe7d9a4d737bee8cd3b5020811d3 Author: Povilas Kanapickas Date: 2019-10-27 11:48:33 +0200 genesys: Improve class method identifiers in debug messages commit 6d7365ba897890ec75eaa83c9981393677239fac Author: Povilas Kanapickas Date: 2019-10-27 11:48:32 +0200 genesys: Return errors as exceptions commit 46876064d7ccff723d422a8c42fb2da94f61f3fe Author: Povilas Kanapickas Date: 2019-10-27 11:48:31 +0200 genesys: Improve error logging commit a1bc0d33cd0283f015fd5663f5fe6764b028803e Author: Povilas Kanapickas Date: 2019-10-27 10:42:01 +0200 genesys: Move line-distance correction data to session commit 0fa25a233b4306a9d8f3e78a80f900974179fd6c Author: Povilas Kanapickas Date: 2019-10-27 10:42:00 +0200 genesys: Merge chip-specific compute_session functions commit c2479ed0e938b54b115b84679f81132ab417acd7 Author: Povilas Kanapickas Date: 2019-10-27 10:29:56 +0200 genesys: Add support for 3200dpi flatbed resolution on 8400F commit 7f49bd2a2ef39c09a2a75db7fb7dbc0f2513d3b5 Author: Povilas Kanapickas Date: 2019-10-27 10:29:55 +0200 genesys: Enable all transparency resolutions for infrared scans on 8400F commit 7336ec8969015fb77ad2e8e5a25217af82473335 Author: Povilas Kanapickas Date: 2019-10-27 10:29:54 +0200 genesys: Fix 1600 dpi flatbed / 3200 dpi TA support on 8400F commit e2e72535b5caa86707fa0ff37e929a45a44a41c5 Author: Povilas Kanapickas Date: 2019-10-26 12:42:50 +0200 genesys: Record data that is important for shading data upload commit 67588e46ef343839795933d22bf6e1299d0cbd6a Author: Povilas Kanapickas Date: 2019-10-26 12:42:49 +0200 genesys: Add checkpoints to record internal state commit eadfdb57a460f7197cf6cc9aef7e50d3e799ebac Author: Povilas Kanapickas Date: 2019-10-26 12:42:48 +0200 genesys: Add a way to record backend internals using test scanner iface commit 95366b1f1b7d640e1a512546b4a622dfe4a5cc13 Author: Povilas Kanapickas Date: 2019-10-26 12:42:47 +0200 genesys: Add a way to record arbitrary data for debugging commit 3ac009abe207873627b709544c63a775982ab7b3 Author: Povilas Kanapickas Date: 2019-10-26 12:42:46 +0200 genesys: Add more debug printers commit 38c32ff7029553aadf0e17689a27fe605fe4635a Author: Povilas Kanapickas Date: 2019-10-26 12:42:45 +0200 genesys: Extract formatting functionality out of debug_dump() commit 105f7fbfaddd762455430bb787b2283d9b13899a Author: Povilas Kanapickas Date: 2019-10-26 12:42:44 +0200 genesys: Add utility to restore stream state commit 655c6b14b654585bb65d43bb2bbdf2256a3018c7 Author: Povilas Kanapickas Date: 2019-10-26 11:38:37 +0200 genesys: Extract low level register set functionality to separate class commit 309ee441de2875f7e6d498dcad7c3d78262b1166 Author: Povilas Kanapickas Date: 2019-10-26 11:38:36 +0200 genesys: Remove trivial bulk_{read,write}_data() wrapper commit fe30fbe893a9842470768bfbc3fd204bacb74e97 Merge: 99ae5490 82e971a7 Author: Povilas Kanapickas Date: 2019-10-25 20:22:38 +0000 Merge branch 'glibcxx-assertions-abort' into 'master' genesys: Fix #156 - [Fedora] Abort due out-of-bound access Closes #156 See merge request sane-project/backends!224 commit 82e971a7862a9c87c3f49e62e39a34da67d0b069 Author: Zdenek Dohnal Date: 2019-10-25 13:06:15 +0200 Fix #156 - [Fedora] Abort due out-of-bound access commit 99ae5490a677c3210e23c770b2032dc235bcd8b7 Author: Rolf Bensch Date: 2019-10-24 15:10:23 +0200 pixma: backend version 0.24.1 commit 7b388d14da4ef9cf76cd987c575494fe6256fdc5 Author: Rolf Bensch Date: 2019-10-24 15:04:09 +0200 pixma_mp150: fix scan height calculation this fixes: pixma_mp150: remove (ccd) color shifting (fc300be) commit 63ce5153760cddfc6b15a1f2fc20bfa69d80fc82 Author: Rolf Bensch Date: 2019-10-22 20:09:00 +0200 pixma_mp800: remove double PIXMA_CAP_CCD settings commit 2f2bce2ae9f259646512ce7b1be3791001e08245 Author: Rolf Bensch Date: 2019-10-22 19:41:49 +0200 pixma: backend version 0.24.0 commit 7db4449fa044e8ee06b7c7f83a54a7725f861da4 Merge: 2b1ce918 ab031439 Author: Rolf Bensch Date: 2019-10-22 19:40:06 +0200 Merge branch 'pixma/separate_ccd_from_cis' commit ab0314399a26b470d7f601a69649f7ce7975d1c0 Author: Rolf Bensch Date: 2019-10-22 19:32:07 +0200 pixma_mp810: rename => pixma_mp800 1st ccd scanner in pixma_mp810 is MP800 commit fc300be715eeee3b719824b694a660672de99d78 Author: Rolf Bensch Date: 2019-10-22 19:23:18 +0200 pixma_mp150: remove (ccd) color shifting commit 1b8fe029a256d6ef4202838a1c69fc2e9307daa7 Author: Rolf Bensch Date: 2019-10-22 19:10:53 +0200 pixma_mp150: remove unused code unused scanner functions: ccd, tpu commit 83a0a1c55f973db2d4fb7ce9d664477e46516651 Author: Rolf Bensch Date: 2019-10-22 18:03:33 +0200 pixma_mp150: move ccd scanners => pixma_mp810 commit 657f1d8e26f0259f380c11aa16cdcfc00249648a Author: Rolf Bensch Date: 2019-10-22 17:46:19 +0200 pixma_mp810: all scanners have ccd commit 97cd2e10bb6149cbdaab8fc306ea2761aa83f972 Author: Rolf Bensch Date: 2019-10-22 17:46:01 +0200 pixma_mp750: all scanners have ccd commit 2b1ce918aef19061bf5f0cc3cba625314bb6f1c3 Author: Louis Lagendijk Date: 2019-10-18 19:45:37 +0200 pixma_bjnp.c: Fixed compile warnings on My Fedora build commit 6b0f3ca124fc3e31db1d4750f9e6e006f135976d Merge: 9ee689c6 0b4a5f94 Author: Povilas Kanapickas Date: 2019-10-17 19:44:38 +0000 Merge branch 'genesys-misc-fixes' into 'master' genesys: Miscellaneous fixes for numerous scanners See merge request sane-project/backends!222 commit 0b4a5f941ad2550e90d06ff1c6ba7f7e909312d5 Author: Povilas Kanapickas Date: 2019-10-17 22:30:27 +0300 genesys: Use correct min resolution for feeding commit abec99006c78353a300747e34ae39f9be7d5673d Author: Povilas Kanapickas Date: 2019-10-17 22:30:26 +0300 genesys: Add missing includes commit 2d0a1a34709670d2e7946e8f0695af4b73b75847 Author: Povilas Kanapickas Date: 2019-10-17 22:30:25 +0300 genesys: Enable 1200 Y resolution on HP ScanJet 2300 commit 2a8be5e191550dadc44ca8eaf9fafe45171bb76d Author: Povilas Kanapickas Date: 2019-10-17 22:30:24 +0300 genesys: Use motor base dpi for shading calibration on gl847 commit 87969174bd9d68983f6b4b47aae51f813e64054e Author: Povilas Kanapickas Date: 2019-10-17 22:30:23 +0300 genesys: Fix shading target for Canon LiDE 110, 120, 210, 220 commit 36f0685d0a5db1c2b361ad250b8235b5e07aaafd Author: Povilas Kanapickas Date: 2019-10-17 22:30:22 +0300 genesys: Improve robustness of calibration on gl847 commit 67d6a194e588fffdea15e5f3c0e2279de519f5f8 Author: Povilas Kanapickas Date: 2019-10-17 22:30:21 +0300 genesys: Fix geometry for Canon LiDE 110 commit 0096d56cb61dbeb7426c6699cea4c0bf0eb7f2de Author: Povilas Kanapickas Date: 2019-10-17 22:30:20 +0300 genesys: Fix X resolution list for Canon LiDE 100 and 120 commit dab38144a03cd1da055cc9ab06defb6d0a79872e Author: Povilas Kanapickas Date: 2019-10-17 22:30:19 +0300 genesys: Fix geometry of HP G4050 commit 661fa1d590c5ab7ef1d8f85513c55aa63d3c78a5 Author: Povilas Kanapickas Date: 2019-10-17 22:30:18 +0300 genesys: Add missing resolutions for Canon 5600F commit 2c7f7fcac283c1f3e073908601f5da0444fc3819 Author: Povilas Kanapickas Date: 2019-10-17 22:30:17 +0300 genesys: Fix sensor gamma of LiDE 100, 110, 120, 200, 210, 220 scanners commit b391b35fd9180af4222ed0c9ff71e7aa62baca4b Author: Povilas Kanapickas Date: 2019-10-17 22:30:16 +0300 genesys: Fix uninitialized variable warning in SaneException c-tor commit 1ac04c6266dd1bf721b9b950ebe3540112af0beb Author: Povilas Kanapickas Date: 2019-10-17 22:30:15 +0300 genesys: Don't enable gamma when not needed commit 9ee689c6f67e48b3e94a2ff0d129c28476ff855b Merge: 680ebd9f 93e980d0 Author: Povilas Kanapickas Date: 2019-10-17 19:20:11 +0000 Merge branch 'genesys-median-shading' into 'master' genesys: Use median filter during to average columns during shading calculations See merge request sane-project/backends!221 commit 93e980d0c1d3b03bea1d2db45ea588f2272c94ab Author: Povilas Kanapickas Date: 2019-10-17 22:07:01 +0300 genesys: Use median instead of mean when computing shading calib data commit f9d36d1a1b5150866d2a714380c7e7579e4e1189 Author: Povilas Kanapickas Date: 2019-10-17 22:07:00 +0300 genesys: Add utility to compute percentille of columns in image commit 051ff59e0c21e512823093a125e1a1da4a70a79a Author: Povilas Kanapickas Date: 2019-10-17 22:06:59 +0300 testsuite: Add a way to test exception throwing commit 680ebd9f3f6576686a25e721138f01c5ae8d9c72 Merge: efb693e0 bc2f40b2 Author: ABC Date: 2019-10-16 15:48:10 +0000 Merge branch 'samsungc460-no-jpeg-support' into 'master' xerox_mfp: Samsung C460 does not have the JPEG mode So blacklist it from jpeg parser. See merge request sane-project/backends!218 https://gitlab.com/sane-project/backends/merge_requests/218 Downstream references: https://bugzilla.redhat.com/show_bug.cgi?id=1760916 commit bc2f40b274ceb9292c3665ea55755e43d0b99487 Author: Zdenek Dohnal Date: 2019-10-15 12:49:48 +0200 Samsung C460 does not have the JPEG mode commit efb693e0b7fa1ad020bf7e0c0d1cf06b7a9dd61e Merge: 82b1a892 885eb828 Author: Povilas Kanapickas Date: 2019-10-13 15:49:07 +0000 Merge branch 'genesys-per-scan-method-resolutions' into 'master' genesys: Support different resolutions depending on scan method See merge request sane-project/backends!217 commit 885eb8280120fc9e41c151d15ee01973125df515 Author: Povilas Kanapickas Date: 2019-10-13 18:30:28 +0300 genesys: Update resolutions specific to scan method in model list commit a5fe12a37fbc200475a03c7644ec429e213107da Author: Povilas Kanapickas Date: 2019-10-13 18:30:27 +0300 genesys: Allow supported resolutions to vary depending on scan method commit 24230aea7d1865b0a1fac649f53c7fdcac0aee51 Author: Povilas Kanapickas Date: 2019-10-13 18:30:26 +0300 genesys: Simplify option setup commit b716c1a45760a79ea8a31d4296270d0605f669b7 Author: Povilas Kanapickas Date: 2019-10-13 18:30:25 +0300 genesys: Remove duplicate definitions of SCAN_FLAG_* commit 82b1a8922ef981ae03126d492389bdc897fc7243 Merge: f04ab61e 3037ba1e Author: Povilas Kanapickas Date: 2019-10-13 10:41:13 +0000 Merge branch 'genesys-searchable-register-names' into 'master' genesys: Use a searchable name for register enums See merge request sane-project/backends!216 commit f04ab61eaab8335866cce7c48796c080b2729db2 Merge: 9fe2026a 0ab82e9f Author: Povilas Kanapickas Date: 2019-10-13 10:15:12 +0000 Merge branch 'genesys-fix-warnings' into 'master' genesys: Fix floating-point conversion warnings See merge request sane-project/backends!215 commit 0ab82e9f86d4b1d94e6e1eb1e501498570c89cb2 Author: Povilas Kanapickas Date: 2019-10-13 06:18:51 +0300 genesys: Resolve various floating-point conversion warnings commit f4a295754159acb6d4df0868f02b69531667cd92 Author: Povilas Kanapickas Date: 2019-10-13 06:18:50 +0300 genesys: Use unsigned for resolution in various places commit 59e356ac1340c930bd8a2f2ffc79ac36cd3d837d Author: Povilas Kanapickas Date: 2019-10-13 06:18:49 +0300 genesys: Don't use variants of M_PI that aren't guaranteed to be present commit a694002364761f179db8d0694b46afe5a3509750 Author: Povilas Kanapickas Date: 2019-10-13 06:18:48 +0300 genesys: Switch session startx and starty to unsigned The sources and destinations are integer in most cases for these variables. commit 0840c6e9d9e1a878b625ba6547958e5bc41645d8 Author: Povilas Kanapickas Date: 2019-10-13 06:18:47 +0300 genesys: Fix float conversion warnings in the tables commit 9fe2026accee3bdfcfd81fbb158934d2a2f5d37c Merge: 41ce1eb2 68e5f8a9 Author: Povilas Kanapickas Date: 2019-10-12 20:06:18 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!214 commit 68e5f8a912067731af262c7218d9eaf88e032721 Author: Povilas Kanapickas Date: 2019-10-02 12:01:28 +0300 genesys: Put the backend code into a separate namespace commit 41ce1eb204130a974e15c63cec418b6197cf41c4 Author: Rolf Bensch Date: 2019-10-12 18:49:10 +0200 pixma: backend version 0.23.5 commit a89ffe8f2c02d45cbd7a26608c02535b972d1dfa Merge: d5c0240f eb2f8364 Author: Povilas Kanapickas Date: 2019-10-12 16:09:29 +0000 Merge branch 'genesys-remove-1bit-support' into 'master' genesys: Remove support for scanning 1 bit output See merge request sane-project/backends!212 commit d5c0240f43a9186f3149fc57b8c2ebcd30725208 Merge: f6c9b83d 6638f00b Author: Rolf Bensch Date: 2019-10-12 18:07:03 +0200 Merge remote-tracking branch 'origin/master' commit 6638f00b8496977d02ceda8f90208e029a6616f2 Merge: 9581f29f 09336e02 Author: Povilas Kanapickas Date: 2019-10-12 16:05:18 +0000 Merge branch 'genesys-fix-warnings' into 'master' genesys: Fix warnings See merge request sane-project/backends!211 commit f6c9b83dcd7b6d9afcfcf337ec30d2ba5d8966e9 Merge: 6959c2d1 ba9bc24f Author: Rolf Bensch Date: 2019-10-12 18:00:51 +0200 Merge branch 'pixma/fix-debian10-compiler-warning_format-truncation' See issue sane-project/backends#120 commit ba9bc24fd2040351f5d00b9a6d4624bab57b0d4c Author: Rolf Bensch Date: 2019-10-12 17:59:13 +0200 pixma: replace snprintf() by strftime() strftime() uses format specifiers with fixed lengths. commit 9581f29f135db2e4c23056d37997fe35416a3d5f Merge: 5ca0acd1 42cace02 Author: Povilas Kanapickas Date: 2019-10-12 15:43:04 +0000 Merge branch 'genesys-fix-warnings' into 'master' genesys: Fix warnings not enabled in regular build See merge request sane-project/backends!209 commit 5ca0acd19a2a8958c4de78eb0ccffe520ca7d1b1 Merge: ebfb9396 f8623e8f Author: Povilas Kanapickas Date: 2019-10-12 15:41:59 +0000 Merge branch 'genesys-plustek-7300-7500i' into 'master' genesys: Implement support for Plustek OpticFilm 7300 and 7500i scanners See merge request sane-project/backends!210 commit ebfb939647c301bf2b4d9af87321c3e57596fa7d Merge: 6959c2d1 d3d86a45 Author: Povilas Kanapickas Date: 2019-10-12 15:39:20 +0000 Merge branch 'genesys-move-to-dir' into 'master' genesys: Move the backend to a separate directory See merge request sane-project/backends!207 commit f8623e8f538063ba209b8b5fd235e3a5f9f866c3 Author: Povilas Kanapickas Date: 2019-10-12 18:23:56 +0300 genesys: Add support for Plustek OpticFilm 7500i commit 20da3df5014abfc6b380a65853d5b522f02ded7e Author: Povilas Kanapickas Date: 2019-10-12 18:23:55 +0300 genesys: Add support for Plustek Opticfilm 7300 commit d3d86a457ed71884eb42efd2003599ea9beceec8 Author: Povilas Kanapickas Date: 2019-10-12 17:43:32 +0300 po: Sync with latest source commit b5e4d86eb2699ef61c79e81835db0d0598267735 Author: Povilas Kanapickas Date: 2019-10-01 08:42:09 +0300 genesys: Use separate translation unit for conversion functions commit 9f44bab6e094527a323d4c4bf057fd65d399d39b Author: Povilas Kanapickas Date: 2019-10-01 08:42:08 +0300 genesys: Move backend files to a separate directory commit 6959c2d14e7fff2c61bee5972304782dc84e07ea Merge: 9ce4cb08 497c9aeb Author: Povilas Kanapickas Date: 2019-10-12 15:06:44 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!208 commit 9ce4cb089f1ad10e91a5ce5d9bd222a06f764c41 Merge: 9ccf5865 61e1f1bf Author: Povilas Kanapickas Date: 2019-10-12 14:13:44 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!206 commit 9ccf586575ed274fa9a11084dd831709e8b1fd08 Merge: 0e4a2d10 0781f3fd Author: Povilas Kanapickas Date: 2019-10-12 00:13:59 +0000 Merge branch 'genesys-fix-gl841-init-crash' into 'master' genesys: Make sure calib_reg are available before writing into them Closes #136 See merge request sane-project/backends!205 commit 0781f3fd3960ae30d1b1f8ecfd842b82bc7df2bb Author: Povilas Kanapickas Date: 2019-10-12 02:59:11 +0300 genesys: Make sure calib_reg are available before writing into them commit 0e4a2d107a957e7476cee994c3373cdc7e1d7354 Merge: 6933315e fc699d2b Author: Olaf Meeuwissen Date: 2019-10-06 02:47:36 +0000 Merge branch 'hh' into 'master' uClibc-ng fixes See merge request sane-project/backends!198 commit 6933315e16a04ba2a5170aeccc29e5de694d8889 Merge: f8131fd6 eb7d1739 Author: Rolf Bensch Date: 2019-10-05 21:29:57 +0200 Merge remote-tracking branch 'origin/master' commit f8131fd6fe3652ce8930275898578ba56fc3ddc6 Author: Rolf Bensch Date: 2019-10-05 21:29:14 +0200 pixma: i-SENSYS MF640 Series networking tested commit eb7d173916b6dc56139d10f56f243eff75a8dbe1 Merge: 9e8f7805 ec8dadc0 Author: Povilas Kanapickas Date: 2019-10-05 08:14:36 +0000 Merge branch 'genesys-use-consistent-enum-names' into 'master' genesys: Use consistent enum names See merge request sane-project/backends!204 commit ec8dadc0a065e038821ba27cd079e5eb504fd6a0 Author: Povilas Kanapickas Date: 2019-09-30 13:52:07 +0300 genesys: Use consistent names for enums of Canon scanners commit 6a1055143f32bd0bef1cef3ae91594f496894bf1 Author: Povilas Kanapickas Date: 2019-09-30 13:52:06 +0300 genesys: Use consistent names for enums of Plustek scanners commit 9e8f7805742db9318125ce77838cb61109a8632b Merge: 290d19a0 a42a177a Author: Povilas Kanapickas Date: 2019-10-05 07:06:51 +0000 Merge branch 'genesys-strongly-typed-enums' into 'master' genesys: Convert weakly typed enums to strongly typed enums See merge request sane-project/backends!203 commit 290d19a0974f68a5037fb6a17e44af8f95fe9793 Merge: 7a7009a7 7fb65821 Author: Povilas Kanapickas Date: 2019-10-05 06:27:44 +0000 Merge branch 'genesys-model-flag-inverted-output' into 'master' genesys: Introduce a model flag for inverted 16-bit output See merge request sane-project/backends!202 commit 7a7009a79d86b772de70113b305ce9595537fe07 Merge: 303cc7de 32dea769 Author: Povilas Kanapickas Date: 2019-10-05 06:21:12 +0000 Merge branch 'genesys-virtual-functions-for-cmdset' into 'master' genesys: Use virtual functions for command set actions See merge request sane-project/backends!201 commit 7fb6582157ae2b55f38936e58b1ed8bf174b6055 Author: Povilas Kanapickas Date: 2019-10-05 09:01:32 +0300 genesys: Introduce a model flag for inverted 16-bit output commit 32dea7695672d89245dff98448b0e697e83086f9 Author: Povilas Kanapickas Date: 2019-10-05 09:01:31 +0300 genesys: Use virtual functions for command set actions commit 303cc7dedd3d1fb8b4cd64b53c1a40065f931835 Merge: 65d9497f 1face929 Author: Povilas Kanapickas Date: 2019-10-05 05:30:18 +0000 Merge branch 'fix-memory-errors' into 'master' Fix memory errors in various places See merge request sane-project/backends!200 commit 1face9299d866996e0d30d8692e7345c2388b254 Author: Povilas Kanapickas Date: 2019-10-05 01:01:32 +0300 genesys: Fix uninitialized option group names commit 6b3ba8af8a62545c90051b0dbf30b955d2462841 Author: Povilas Kanapickas Date: 2019-10-05 01:01:31 +0300 sanei_usb: Fix memory leak in USB testing mode commit 643ac8eab272cf1fe528bf79a94c873227d84614 Author: Povilas Kanapickas Date: 2019-10-05 01:01:30 +0300 genesys: Fix memory leaks in global data commit 65d9497ff30dcc4748a9a5940d1c73b2a8a47c5c Author: Rolf Bensch Date: 2019-10-04 21:29:13 +0200 pixma: fix network scanner model for Canon i-SENSYS MF640 Series commit 67c732f2f03fa6528099990065a073c02d404f27 Author: Rolf Bensch Date: 2019-10-04 15:46:30 +0200 pixma: PIXMA MG3000 Series is working commit 8841b4e593141f70532379ec83c64c62855b7cce Author: Rolf Bensch Date: 2019-10-04 12:32:56 +0200 pixma: i-SENSYS MF640 Series is working commit d78dc1a30be2fb8ac740f9f19a348ae134f5627d Merge: 4239428c 3c449a75 Author: Rolf Bensch Date: 2019-10-04 11:22:09 +0200 Merge remote-tracking branch 'origin/master' commit 4239428c87d021825f554ca5a9c376df5a03136c Author: Rolf Bensch Date: 2019-10-04 11:21:43 +0200 pixma: backend version 0.23.4 commit 14851d780d9c4743e8d5df55ebcc668a603b1a22 Author: Rolf Bensch Date: 2019-10-04 11:21:14 +0200 pixma: CanoScan LiDE 300 supports max. 2400 dpi commit 3c449a75154e9f7cdd2c599b2c2c81ec8300c1fe Merge: 899d6968 0146888d Author: Povilas Kanapickas Date: 2019-10-04 04:16:07 +0000 Merge branch 'genesys-plustek-opticfilm-7200i' into 'master' genesys: Implement infrared scanning support on OpticFilm 7200i See merge request sane-project/backends!199 commit fc699d2bf573444a55ada47ad2317dc47b67c6d7 Author: Rosen Penev Date: 2019-10-02 18:41:07 -0700 treewide: Replace bzero with memset bzero was removed in POSIX 2008. It is optionally unavailable with uClibc-ng. Signed-off-by: Rosen Penev commit 428bec49bfda8bf6502b97bb02e1eb292aa6e4e6 Author: Rosen Penev Date: 2019-10-02 18:27:36 -0700 sanei_scsi: Replace bcopy with memcpy bcopy was deprecated in POSIX 2008 and is optionally unavailable with uClibc-ng. Signed-off-by: Rosen Penev commit 5c0f0eb12896b26553de88401605391aefc84d02 Author: Rosen Penev Date: 2019-10-02 18:25:02 -0700 pieusb_buffer: Define L_tmpnam if not available uClibc-ng does not make it available for some reason. Signed-off-by: Rosen Penev commit c320a72e32eb6651bd6f1918b83a7a44ca6fcc87 Author: Rosen Penev Date: 2019-10-02 18:21:59 -0700 treewide: Replace mktemp by mkstemp mktemp has been removed in POSIX 2008. uClibc-ng optionally does not make it available. Signed-off-by: Rosen Penev commit 3037ba1eafb551524b30865323900bc5afa1dd6a Author: Povilas Kanapickas Date: 2019-10-02 14:28:59 +0300 genesys: Use a searchable name for register enums commit e32a45fef814c36756bedb259c2baa692da25c39 Author: Povilas Kanapickas Date: 2019-10-02 12:01:27 +0300 genesys: Retrieve depth from session in genesys_warmup_lamp() commit 17740df924c692d8585bc24258a357cc5f3d17b2 Author: Povilas Kanapickas Date: 2019-10-02 12:01:26 +0300 genesys: Remove support for binary logging commit 899d6968fada5caabde4f4c81a701354f6fbe666 Author: Rolf Bensch Date: 2019-10-01 22:58:54 +0200 pixma: backend version 0.23.3 commit af09cf3ac8e33ca17875d6f3f6b5f05cf8c8e9f5 Author: Rolf Bensch Date: 2019-10-01 22:57:18 +0200 pixma: add document feeder support for i-SENSYS MF260 Series commit cc6afc02ea9095204f364ad5231dcb922824dcfb Author: Rolf Bensch Date: 2019-10-01 22:41:19 +0200 pixma: uncomment and edit experimental scanners list in sane-pixma.man We have no experimental scanners yet. But environment variable PIXMA_EXPERIMENT is specified and may be used again in future. commit 607eacaa7104c62cd6082c02f4fcf83c4523ddd9 Author: Rolf Bensch Date: 2019-10-01 22:37:15 +0200 pixma: reorder scanners in pixma.desc commit eb2f8364818d5fbd30e06e7a2b296699a1ad5af8 Author: Povilas Kanapickas Date: 2019-10-01 18:11:52 +0300 genesys: Remove low-level support for 1-bit depth scans commit 0180c4c5d871c55ecd38c8ad9891c4a51dc70c1a Author: Povilas Kanapickas Date: 2019-10-01 18:11:51 +0300 genesys: Remove SCAN_FLAG_DYNAMIC_LINEART commit 8be96ecd6072a9199ab2cb6f105b79efab97b9e2 Author: Povilas Kanapickas Date: 2019-10-01 18:11:50 +0300 genesys: Simplify code as dynamic_lineart is always enabled for lineart commit 3263b986ce7afc802c96276d4b876632bcdf3146 Author: Povilas Kanapickas Date: 2019-10-01 18:11:49 +0300 genesys: Remove support of --disable-dynamic-lineart option commit bff9f2fdc4a31f1f498223144814168f64aaf802 Author: Povilas Kanapickas Date: 2019-10-01 18:11:48 +0300 genesys: Fix crash during sane_exit() on high debug level commit 158cc81e206a03f4c25a66b2e3147c1c4c31abf8 Author: Povilas Kanapickas Date: 2019-10-01 18:11:47 +0300 genesys: Simplify setup of session depth parameter commit 09336e0286ce828c5288ac361ae3bd83e671cffb Author: Povilas Kanapickas Date: 2019-10-01 15:41:27 +0300 genesys: Remove code that has no effect commit cccd1e949ab53f6463bb8f97431dde9a0bc5e632 Author: Povilas Kanapickas Date: 2019-10-01 15:41:26 +0300 genesys: Fix unused exception warning commit 60b6465115eb391b93e84a237cabdfa7e88e2cb4 Author: Povilas Kanapickas Date: 2019-10-01 15:41:25 +0300 genesys: Emit single vtable of ImagePipelineNodeCallableSource commit c8f2a815c03478bd61b16ad35f34cab7edf7ed30 Author: Povilas Kanapickas Date: 2019-10-01 15:41:24 +0300 genesys: Don't use std types from global namespace commit 1423db661858e566dbf17430c82e5471a69c0b2a Author: Povilas Kanapickas Date: 2019-10-01 15:41:23 +0300 genesys: Include missing includes commit 42cace02c52e19a9520dcafaf56dfeb442eb7c50 Author: Povilas Kanapickas Date: 2019-10-01 12:09:51 +0300 genesys: Simplify version logging commit 4c90bfcaeea4c470c96cf7bc6c4b0f277742ec17 Author: Povilas Kanapickas Date: 2019-10-01 12:09:50 +0300 genesys: Remove uses of old-style casts where possible commit 8537ba21b7fa9dfca25068735d11916b1b8869e2 Author: Povilas Kanapickas Date: 2019-10-01 12:09:49 +0300 genesys: Don't emit symbols of internal objects commit 9c7199c09ec88832b285add6178272e158f6101d Author: Povilas Kanapickas Date: 2019-10-01 12:09:48 +0300 genesys: Don't use std identifiers from global scope commit bb84d6d9e4b7c6de55cb432892af26ed89750354 Author: Povilas Kanapickas Date: 2019-10-01 12:09:47 +0300 genesys: Remove unused code commit e20e73f43465e79336a30792c16adb0dffc6084b Author: Povilas Kanapickas Date: 2019-10-01 12:09:46 +0300 genesys: Don't use C-style casts where possible commit 497c9aeba2f4dc2a7a472b643b884fd4a7b3753c Author: Povilas Kanapickas Date: 2019-10-01 10:52:44 +0300 genesys: Wrap SANE_Fixed into class which automatically converts values commit b176366dcf375499868eb54057e5f4c8cbbf4924 Author: Povilas Kanapickas Date: 2019-10-01 10:52:43 +0300 genesys: Increase wait for home timeout to 200 seconds commit 8a1bc90521e205f7747cf2f12e0849ca7c0772aa Author: Povilas Kanapickas Date: 2019-10-01 10:52:42 +0300 genesys: Simplify sanei_genesys_wait_for_home() commit 61e1f1bf08f6483608f876ffb085eb6c2d2a7317 Author: Povilas Kanapickas Date: 2019-10-01 08:18:47 +0300 genesys: Simplify usage of sanei_genesys_get_status() commit 26e418537ff694e1b92074d7032fa93aeaa6dc72 Author: Povilas Kanapickas Date: 2019-10-01 08:18:46 +0300 genesys: Reduce duplication of waiting for non-empty buffer state commit bf9d69d20df3c0b80a683cada2c23999699e6d5d Author: Povilas Kanapickas Date: 2019-10-01 08:18:45 +0300 genesys: Replace uses of SANE_Bool with bool commit 6da4e69d95f47db0afe8f020d4fc0dd926281069 Author: Povilas Kanapickas Date: 2019-10-01 08:18:44 +0300 genesys: Mark overridden functions consistently commit 44ac90d309e68d447026e375b02996fa54800219 Author: Povilas Kanapickas Date: 2019-10-01 08:18:43 +0300 genesys: Fix misuses of comma operator commit 7ac53bce10264644fe70b55af2a5fd13d4b16f82 Author: Povilas Kanapickas Date: 2019-10-01 08:18:42 +0300 genesys: Replace uses of nullptr commit a42a177a7ad54eb26e079b80f61a9bc7739212c0 Author: Povilas Kanapickas Date: 2019-09-30 13:52:05 +0300 genesys: Bump calibration version commit 98b4742aab09eaa58c232b434fdd3f46a3c02b35 Author: Povilas Kanapickas Date: 2019-09-30 13:52:04 +0300 genesys: Use strong enum for motor step type commit 719a0cf55ce7ad84d2fc561fb9859c823113b783 Author: Povilas Kanapickas Date: 2019-09-30 13:52:03 +0300 genesys: Use strong enum for motor id commit 45aec261047cdb7a68e85bba93ced441cfb434ce Author: Povilas Kanapickas Date: 2019-09-30 13:52:02 +0300 genesys: Use strong enum for gpio type commit d4ca0177a13cf21fce320a876ddcfa66c2490acb Author: Povilas Kanapickas Date: 2019-09-30 13:52:01 +0300 genesys: Use strong enum for ADC id commit df14234297f969ccab005227760bfb2bedc168ec Author: Povilas Kanapickas Date: 2019-09-30 13:52:00 +0300 genesys: Use strong enum for sensor id commit 66937f646827fe558a96828980552f94fe6edde9 Author: Povilas Kanapickas Date: 2019-09-30 13:51:59 +0300 genesys: Remove invalid comment commit 6971301590e5cbd7c8932ea9b2246c0df8253c33 Author: Povilas Kanapickas Date: 2019-09-30 13:51:58 +0300 genesys: Rename Genesys_Sensor::{CCD -> ccd}_start_xoffset commit 591309a29e4667ea9e5bb27b6535b0400e8738da Author: Povilas Kanapickas Date: 2019-09-30 13:51:57 +0300 genesys: Use strongly typed enum for model id commit 9824dfe8b027de2aa8d09ad11eb05e5a3f14922f Merge: 1dc1da59 ef29ed60 Author: Povilas Kanapickas Date: 2019-09-29 22:15:02 +0000 Merge branch 'genesys-opticfilm-7200i' into 'master' genesys: Implement support for Plustek Opticfilm 7200i See merge request sane-project/backends!197 commit ef29ed60c2a5928d6be916fc7e85efc692cb8a2f Author: Povilas Kanapickas Date: 2019-09-19 00:30:23 +0300 genesys: Implement support for Plustek Opticfilm 7200i commit 1dc1da59428ec6715dae67f0bc8a99f150fc73b3 Merge: 4c9f9f08 1bab4037 Author: Povilas Kanapickas Date: 2019-09-29 19:18:59 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!196 commit 4c9f9f0847ee6d2e9ebc406a28f63889473068c4 Merge: 7df7acba 323f3775 Author: Povilas Kanapickas Date: 2019-09-29 18:44:12 +0000 Merge branch 'genesys-host-side-calibration' into 'master' genesys: Implement support for host-side calibration See merge request sane-project/backends!195 commit 7df7acbafd584bb041d0ef73220edcedafd4cc31 Merge: cf5f30de 5e2a0f57 Author: Povilas Kanapickas Date: 2019-09-29 18:31:46 +0000 Merge branch 'genesys-gl843-image-calibration' into 'master' genesys: Use image pipeline for calibration on gl843 See merge request sane-project/backends!194 commit cf5f30dec30902be8172721eb8130ec299080346 Merge: b3445a18 3c99d405 Author: Povilas Kanapickas Date: 2019-09-29 18:23:12 +0000 Merge branch 'genesys-fix-depth-option' into 'master' genesys: Fix handling of the `--depth` option See merge request sane-project/backends!193 commit b3445a1803ef372240485b0de8a7c14bbe02fb19 Merge: a30daa96 b09aa658 Author: Povilas Kanapickas Date: 2019-09-29 18:09:59 +0000 Merge branch 'genesys-move-register-lists-to-separate-files' into 'master' genesys: Move register address lists to separate files See merge request sane-project/backends!192 commit a30daa96d150b1c79fac765a7f01be5bc45407d6 Merge: 7bd4a1db 11c80b12 Author: Povilas Kanapickas Date: 2019-09-29 18:00:13 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!191 commit 7bd4a1db49b94ed4c72aa445626cadda0d7ef30d Merge: 32c49e5e 599443bf Author: Povilas Kanapickas Date: 2019-09-29 17:49:38 +0000 Merge branch 'genesys-image-limit-output-sheetfed-scanners' into 'master' genesys: Fix output limiting for sheetfed scanners See merge request sane-project/backends!190 commit 32c49e5ec1e4b204f1da2320b6323abb9c6293f1 Merge: b6eef086 e53058e8 Author: Povilas Kanapickas Date: 2019-09-29 17:25:50 +0000 Merge branch 'genesys-image-full-ownership' into 'master' genesys: Add class that handles full ownership of image data See merge request sane-project/backends!188 commit e53058e8b085351ac907fe72897f32483cd77126 Author: Povilas Kanapickas Date: 2019-09-15 15:27:11 +0300 genesys: Add class that handles data ownership for full image commit 6ced865d53570f04a66855fb324817fa24e5fb50 Author: Povilas Kanapickas Date: 2019-09-15 15:27:10 +0300 genesys: Move pixel-related functionality to separate file commit b6eef08610810a9b38f98fc5c233f4138c230358 Merge: 28b21651 ab62a144 Author: Povilas Kanapickas Date: 2019-09-29 04:33:06 +0000 Merge branch 'genesys-session-calib-pixel-offsets' into 'master' genesys: Use session for pixel coordinates during calibration See merge request sane-project/backends!189 commit 28b216513e86ae57f9baea5bce464e825245313a Merge: 7b66a8f7 050b0c1d Author: Povilas Kanapickas Date: 2019-09-28 18:22:42 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!185 commit 7b66a8f732b01f6366694c941180dab7bd2e6735 Merge: f2019bef b9346f0f Author: Povilas Kanapickas Date: 2019-09-28 18:19:58 +0000 Merge branch 'genesys-override-dpi' into 'master' genesys: Add a way to override logical dpi and physical pixel counts See merge request sane-project/backends!187 commit f2019befd7558421ae13022d0e92798fd032f145 Merge: 345be52f db36dd81 Author: Povilas Kanapickas Date: 2019-09-28 18:02:33 +0000 Merge branch 'genesys-session-pixel-offsets' into 'master' genesys: Move pixel coordinate calculation to a single place See merge request sane-project/backends!186 commit 345be52f9e322b30a28910238492a9ea30631096 Author: Olaf Meeuwissen Date: 2019-09-28 20:33:26 +0900 nec: Fix [-Werror=implicit-fallthrough] warning The fallthrough would log a message that is probably misleading. commit b0b8e8f980692c67ba8aff760344c9305ea02013 Author: Olaf Meeuwissen Date: 2019-09-28 18:07:27 +0900 Revert "CI: Speed up compile stage jobs" The additional variables: section in the template hides any variables set for each job that uses the template! This reverts commit 14e7ba47dda2ee7389e8db21268cd49e80ea968a. commit e00d5462dee98bd6fa7d8672fba730af9874db87 Author: Olaf Meeuwissen Date: 2019-09-28 17:43:06 +0900 Fix libusb related [-Werror=deprecated-declarations] warnings See http://libusb.sourceforge.net/api-1.0/group__libusb__lib.html commit 29580b08b55a60209c03ce4bf17a834f0904ead3 Merge: bf3e170d be4c3c1f Author: Povilas Kanapickas Date: 2019-09-28 05:49:11 +0000 Merge branch 'genesys-deduplicate-shading-calibration' into 'master' genesys: Deduplicate shading calibration See merge request sane-project/backends!184 commit bf3e170dba7a1c0a01ae8e207247a368f75fa00c Merge: f3d0a7c1 bee1179e Author: Povilas Kanapickas Date: 2019-09-28 05:48:28 +0000 Merge branch 'genesys-use-image-pipeline' into 'master' genesys: Use new image operations pipeline for image data reading and conversion See merge request sane-project/backends!183 commit f3d0a7c17cc2244059773116091e481ed5ee116b Merge: d1badffa 8cf57352 Author: Povilas Kanapickas Date: 2019-09-28 05:34:34 +0000 Merge branch 'genesys-fix-pow-ambiguity' into 'master' genesys: Fix ambiguity of std::pow() on old compilers See merge request sane-project/backends!182 commit bee1179e0efa7a00d45bddaedd74f5819ee1ad74 Author: Povilas Kanapickas Date: 2019-09-13 17:04:05 +0300 genesys: Print debug images of intermediate pipeline output commit 41addb973065b0b8e68f975ae060df49ebe57ded Author: Povilas Kanapickas Date: 2019-09-13 17:04:04 +0300 genesys: Fix debug identifiers commit 9cd1de5c5268a89b20c21e2777229bde08f8e3d6 Author: Povilas Kanapickas Date: 2019-09-13 17:04:03 +0300 genesys: Add a way to debug image pipelines commit cd712f9f9942c424ee1c554f81ba8fa038ed41c7 Author: Povilas Kanapickas Date: 2019-09-13 17:04:02 +0300 genesys: Use new image pipeline for row scaling commit bf7e890fa4d6c17d2313d3eaf0f90d68c9ae98cd Author: Povilas Kanapickas Date: 2019-09-13 17:04:01 +0300 genesys: Use new image pipeline for CCD line shifts and unstagger commit 0b1bfa3f1201b5cfa9e93ecbc4fcf00a57d6b63d Author: Povilas Kanapickas Date: 2019-09-13 17:04:00 +0300 genesys: Swap 16-bit pixel endian on big endian machines commit cae3015b66ab340cf585fb224745e73ae6c53ae6 Author: Povilas Kanapickas Date: 2019-09-13 17:03:59 +0300 genesys: Use new image pipeline for format and CIS reordering commit 8cf5735278af26afd6c0b563915f3be879ad14c4 Author: Povilas Kanapickas Date: 2019-09-28 06:56:03 +0300 genesys: Fix ambiguity of std::pow() on old compilers commit d1badffa886b1065322978a8ea8e5b94d88abde5 Merge: 9eefac82 802a62ee Author: Povilas Kanapickas Date: 2019-09-28 03:54:56 +0000 Merge branch 'genesys-fix-output-line-bytes-raw' into 'master' genesys: Fix calculation of session output_line_bytes_raw See merge request sane-project/backends!181 commit 9eefac82ca98faf28bb56271b8526331413a2c75 Merge: a500f577 97387e20 Author: Olaf Meeuwissen Date: 2019-09-28 03:09:07 +0000 Merge branch '103-add-old-changelogs-to-source-tarball' into 'master' Resolve "Source tarball does not include older ChangeLogs" Closes #103 See merge request sane-project/backends!127 commit a500f577c04a300cddcacccffd52de59c3f80909 Merge: c9e95999 efbfcb0a Author: Povilas Kanapickas Date: 2019-09-27 22:43:07 +0000 Merge branch 'genesys-calibration-variable-names' into 'master' genesys: Improve clarity of calibration offset variable names See merge request sane-project/backends!180 commit c9e95999f350a2145797954adcc770da91d4ffd7 Merge: da745b2f 661aa3bc Author: Povilas Kanapickas Date: 2019-09-27 22:38:55 +0000 Merge branch 'genesys-generic-register-set' into 'master' genesys: Make GenesysRegisterSettingSet generic See merge request sane-project/backends!179 commit da745b2f3007d3450845af1fde87265f23366aa3 Merge: dc52dc84 d4e4bf35 Author: Povilas Kanapickas Date: 2019-09-27 22:35:42 +0000 Merge branch 'genesys-image-pipeline-segmented-sensors' into 'master' genesys: Use the new image pipeline for segmented sensor desegmentation See merge request sane-project/backends!178 commit dc52dc84f047749abf5e226f2d4c23c0c8fa131c Merge: 7a8da5c4 9a844e1e Author: Povilas Kanapickas Date: 2019-09-27 21:56:17 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!177 commit 7a8da5c40bf4c4e08f7da21a4a4f33e0ac2bd228 Merge: 0440123b d73915ba Author: Povilas Kanapickas Date: 2019-09-27 21:32:02 +0000 Merge branch 'genesys-analog-devices-adc-calibration' into 'master' genesys: Implement gain calibration for Analog-Devices ADC See merge request sane-project/backends!176 commit 0440123bdc5b6104a44098c4d066d8c3404cd413 Merge: 4cd9dbb7 ad1067ad Author: Povilas Kanapickas Date: 2019-09-27 21:21:09 +0000 Merge branch 'genesys-gl843-segmented-sensors' into 'master' genesys: Add support for segmented sensors on gl843 See merge request sane-project/backends!175 commit 4cd9dbb73d745891732f3ba3c2b48268f7b1a713 Merge: c59f9a03 1c7ef4b5 Author: Povilas Kanapickas Date: 2019-09-27 21:06:44 +0000 Merge branch 'genesys-image-library' into 'master' genesys: Implement a streaming image library See merge request sane-project/backends!174 commit c59f9a037bc5a53ad4dfd23f28c602a8e0bac557 Merge: 17dc1aee 2f3d9e9d Author: Povilas Kanapickas Date: 2019-09-27 20:55:51 +0000 Merge branch 'genesys-default-scan-method' into 'master' genesys: Add a way to specify default scan method See merge request sane-project/backends!173 commit 17dc1aee81b247c973d82a045e66fec871d5af9b Merge: 60ce6b5c 9b7ab937 Author: Povilas Kanapickas Date: 2019-09-27 20:44:47 +0000 Merge branch 'genesys-desegmentation-refactor' into 'master' genesys: Simplify desegmentation state (part 6) See merge request sane-project/backends!172 commit 60ce6b5c0128676b6d5aed75ee6ddd73e91776c8 Merge: 015252e4 e0974ab7 Author: Povilas Kanapickas Date: 2019-09-27 20:37:08 +0000 Merge branch 'stv-werror-fix-constant-redefinition' into 'master' stv: Fix macro constant redefinition See merge request sane-project/backends!171 commit 015252e4a8285c9b39cb0e8ba9aaf883ef7187e5 Merge: 3618a244 0290a263 Author: Povilas Kanapickas Date: 2019-09-27 20:35:13 +0000 Merge branch 'sanei-usb-optimize-test-mode-bulk-transfers' into 'master' sanei_usb: Optimize bulk USB transfers in testing mode See merge request sane-project/backends!170 commit e0974ab74ac90b47975739d69b04ff8e2b86a7cb Author: Povilas Kanapickas Date: 2019-09-20 17:29:41 +0300 stv: Fix macro constant redefinition commit 0290a263946e233c743b4721e56fdc98b1624b1f Author: Povilas Kanapickas Date: 2019-09-27 23:19:52 +0300 sanei_usb: Optimize bulk USB transfers in testing mode commit 3618a244af39ea26cf7c9cbfc914d9ccd2706e69 Merge: 86b9768d 0267eeee Author: Povilas Kanapickas Date: 2019-09-27 19:44:15 +0000 Merge branch 'genesys-desegmentation-refactor' into 'master' genesys: Simplify desegmentation state (part 5) See merge request sane-project/backends!169 commit 86b9768dd3238b9238751e4a969edb476f084b93 Merge: 16b00334 eb0882ec Author: Povilas Kanapickas Date: 2019-09-27 19:22:08 +0000 Merge branch 'genesys-desegmentation-refactor' into 'master' genesys: Simplify desegmentation state (part 4) See merge request sane-project/backends!168 commit 16b0033439fd56280abd124a4d94852f3e033b0e Merge: 4f1890f1 693ff3e7 Author: Povilas Kanapickas Date: 2019-09-27 00:32:05 +0000 Merge branch 'genesys-fix-cxx11-build' into 'master' genesys: Remove accidental use of C++14 features See merge request sane-project/backends!166 commit 693ff3e77a46ed2318b4528e94c595fddf1b537f Author: Povilas Kanapickas Date: 2019-09-27 03:10:53 +0300 genesys: Remove accidental use of C++14 features commit 4f1890f19536637f0b697dcb21a3998171cb2e04 Merge: a4729cff b856c2cb Author: Povilas Kanapickas Date: 2019-09-24 22:46:08 +0000 Merge branch 'genesys-desegmentation-refactor' into 'master' genesys: Simplify desegmentation state (part 3) See merge request sane-project/backends!165 commit a4729cff19aa736fa5c0fb1c2941774bfee2e3e2 Merge: e4e1a027 a830fca9 Author: Povilas Kanapickas Date: 2019-09-24 21:11:09 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!164 commit e4e1a02733dd3c7733e747bb6e2f7b30db7c9fcf Merge: 37b60ada 52baae02 Author: Povilas Kanapickas Date: 2019-09-24 15:08:50 +0000 Merge branch 'genesys-session-hwdpi-divisor' into 'master' genesys: Use common code path to compute session hwdpi divisor See merge request sane-project/backends!163 commit 37b60ada834d707618e494d6b94f4f7b5d0217f9 Merge: 8539f350 676831dc Author: Povilas Kanapickas Date: 2019-09-24 14:41:17 +0000 Merge branch 'genesys-desegmetation-refactor' into 'master' genesys: Simplify desegmentation state (part 2) See merge request sane-project/backends!162 commit 8539f350fd3bfe654a5fd680428fa97cea352034 Author: Olaf Meeuwissen Date: 2019-09-24 21:22:13 +0900 sanei_wire: Fix sanei_w_void function signature This function needs to have the same number of arguments as any other functions passed to sanei_w_array() via its w_element argument, i.e. sanei_w_char and sanei_w_word, in the w_option_value() implementation in sanei/sanei_net.c. Fixes [-Werror=cast-function-type] compiler warning. commit cad4085565437579884698e42c38eb0a685ad4a7 Merge: ce2d9840 cbb7e953 Author: Povilas Kanapickas Date: 2019-09-22 20:47:19 +0000 Merge branch 'genesys-session-buffer-sizes' into 'master' genesys: Use common code path for computing session buffer sizes See merge request sane-project/backends!161 commit ce2d9840a741906844de36e5cf96575e33d02f4d Merge: f44c0bb6 88d6cdcc Author: Povilas Kanapickas Date: 2019-09-22 18:29:02 +0000 Merge branch 'genesys-desegmentation-refactor' into 'master' genesys: Simplify desegmentation state (part 1) See merge request sane-project/backends!160 commit f44c0bb6802a6263ff692d0bcdebef21f2c64ea8 Merge: 37734c88 ed4419e7 Author: Povilas Kanapickas Date: 2019-09-22 17:39:15 +0000 Merge branch 'genesys-session-line-sizes' into 'master' genesys: Use common code path to compute session line sizes See merge request sane-project/backends!159 commit 37734c880d467cc14c143a43e963e746ab36ca09 Merge: 0cf4c1d5 991eec63 Author: Povilas Kanapickas Date: 2019-09-22 17:17:29 +0000 Merge branch 'genesys-session-output-line-count' into 'master' genesys: Use common code path to compute session output_line_count See merge request sane-project/backends!158 commit 0cf4c1d555671058ef9e3a77167891822199b56e Merge: 6f51393b 605fcf97 Author: Povilas Kanapickas Date: 2019-09-22 16:58:14 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup in gl646 motor code See merge request sane-project/backends!157 commit 6f51393bd7a935086989f1c10a012d4fccd91141 Merge: d0365bd7 ce144ed4 Author: Povilas Kanapickas Date: 2019-09-21 15:59:41 +0000 Merge branch 'genesys-session-max-color-shift-lines' into 'master' genesys: Use common code path to compute session max_color_shift_lines See merge request sane-project/backends!155 commit d0365bd7e4d37c45668c7aa7da3c11da5fbabd8a Merge: 9afaf9a2 c69e22eb Author: Povilas Kanapickas Date: 2019-09-21 15:56:34 +0000 Merge branch 'sanei-fix--usb-testing-mode-in-release' into 'master' sanei_usb: Fix uninitialized device struct in USB testing code See merge request sane-project/backends!156 commit c69e22eb766d9cb1505099f5075c44a24dd412c8 Author: Povilas Kanapickas Date: 2019-09-21 18:42:56 +0300 sanei_usb: Fix uninitialized device struct in USB testing code commit 9afaf9a2cf373f40fafd26b3c69414ec15294076 Merge: da9307c7 77e0acde Author: Povilas Kanapickas Date: 2019-09-20 14:37:24 +0000 Merge branch 'genesys-fix-total-bytes-to-read' into 'master' genesys: Fix computation of total_bytes_to_read See merge request sane-project/backends!154 commit da9307c7a63b8c05c5275e3768de2760325f2f29 Merge: bd35742b 0961c5d3 Author: Povilas Kanapickas Date: 2019-09-19 22:51:01 +0000 Merge branch 'genesys-session-output-pixels' into 'master' genesys: Use common code path to compute session output_pixels See merge request sane-project/backends!153 commit bd35742b789ac1ea1b528880afca75b0489020bc Merge: c1b8cb5c 50e5c804 Author: Povilas Kanapickas Date: 2019-09-19 22:32:54 +0000 Merge branch 'genesys-handle-non-uniform-scans-at-high-level' into 'master' genesys: handle non-uniform scans at high level See merge request sane-project/backends!152 commit c1b8cb5c31b39f375881f12f73d91a61a610d50f Merge: 1e2f64dc 453a6b75 Author: Povilas Kanapickas Date: 2019-09-19 22:17:43 +0000 Merge branch 'genesys-session-num-staggered-lines' into 'master' genesys: Use common code path to compute session num_staggered_lines See merge request sane-project/backends!151 commit 0146888d79e7abfb81d977df1dd6a75e65bb0e11 Author: Povilas Kanapickas Date: 2019-09-19 01:28:17 +0300 genesys: Implement infrared scanning support on OpticFilm 7200i commit 1bab4037f56fa36c59a32b809cbe8407890db2fb Author: Povilas Kanapickas Date: 2019-09-18 23:31:47 +0300 genesys: Remove unused command set name property commit 60534b89ae5217e55ea23eaf1b56d025d9764173 Author: Povilas Kanapickas Date: 2019-09-18 23:31:46 +0300 genesys: Store the calibration session into device struct commit 17fe9d8393147f4af94463c6212bba299724f0b1 Author: Povilas Kanapickas Date: 2019-09-18 23:31:45 +0300 genesys: Print debug image of raw data coming from the scanner commit 323f37753a66a8f1ebe35fff8a12fd6e3c6a6963 Author: Povilas Kanapickas Date: 2019-09-18 03:54:52 +0300 genesys: Implement support for host-side calibration commit 5e2a0f5724070d8813657812c54c82c2f5e2292c Author: Povilas Kanapickas Date: 2019-09-17 17:21:06 +0300 genesys: Use Image in gl843_search_strip() commit 08a4d8455f8248577324e2441f29db83589c3d9e Author: Povilas Kanapickas Date: 2019-09-17 17:21:05 +0300 genesys: Use Image in gl843_coarse_gain_calibration() commit 074603598085a1850005076dde3b8793772aae3d Author: Povilas Kanapickas Date: 2019-09-17 17:21:04 +0300 genesys: Use Image in gl843_offset_calibration() commit ac54f7f9bd511c1dd545037d49390f5046384014 Author: Povilas Kanapickas Date: 2019-09-17 17:21:03 +0300 genesys: Use Image in gl843_led_calibration() commit 4a6216501416bd8b1d84e90c5072b91be0329f1e Author: Povilas Kanapickas Date: 2019-09-17 17:21:02 +0300 genesys: Use Image in gl843_search_start_position commit 93395bd24e21d9555fbe69d7bae89f9e22c49d33 Author: Povilas Kanapickas Date: 2019-09-17 17:21:01 +0300 genesys: Add wrapper to retrieve raw channel value from image commit 4f74dceaba9e02e967c0b94390642ace399b16e3 Author: Povilas Kanapickas Date: 2019-09-17 17:21:00 +0300 genesys: Add wrapper that reads Image from the scanner commit a5006703a33c4a14a6a65bcdda608175cdc7d096 Author: Povilas Kanapickas Date: 2019-09-17 17:20:59 +0300 genesys: Implement wrapper that writes Image to pnm file commit 093439153e553d10824598ba935097307ef4c807 Author: Povilas Kanapickas Date: 2019-09-17 17:20:58 +0300 genesys: Add a way to retrieve full output of pipeline as an image commit 3c99d405e0ced32f9cca9fb5de0f6362ec48ccbf Author: Povilas Kanapickas Date: 2019-09-16 12:44:01 +0300 genesys: Fix the default value of the depth option commit a93d80651f5bf2658a412eb31013f7052140972d Author: Povilas Kanapickas Date: 2019-09-16 12:44:00 +0300 genesys: Don't disable depth option even if one value is possible commit b09aa6584d8e52a3565b7c775cad37842c039885 Author: Povilas Kanapickas Date: 2019-09-16 11:36:02 +0300 genesys: Add include guards to headers where missing commit dc1350781f7874cb580b25397dceb4e779f58b7e Author: Povilas Kanapickas Date: 2019-09-16 11:36:01 +0300 genesys: Move register address lists to separate files commit 11c80b129ee92b2d80dab4e895cc4e9463075b8c Author: Povilas Kanapickas Date: 2019-09-16 09:50:12 +0300 genesys: Extract wait_until_has_valid_words() commit b58192493e33a54ae53a209f8a8d181795e17b44 Author: Povilas Kanapickas Date: 2019-09-16 09:50:11 +0300 genesys: Properly use 16-bit data when calibrating commit 599443bf72aac832d4602c56556d996b5127651e Author: Povilas Kanapickas Date: 2019-09-16 09:34:15 +0300 genesys: Remove uses of dev->read_bytes_left_after_deseg commit 5e60cc3636b85d01f26a731194c9ec443149e98a Author: Povilas Kanapickas Date: 2019-09-16 09:34:14 +0300 genesys: Simplify calculations when on early document end commit 20ad0c8c2efa34d65fc5da887892ffc6c12dcc96 Author: Povilas Kanapickas Date: 2019-09-16 09:34:13 +0300 genesys: Add output_line_bytes_requested to the session struct commit 88adea9cd6697674bace583a48e05019bd4a4c90 Author: Povilas Kanapickas Date: 2019-09-16 09:34:12 +0300 genesys: Add the number of total bytes to the session struct commit c3e7411aca85515ae6c0f20e7e372a764f272788 Author: Povilas Kanapickas Date: 2019-09-16 09:34:11 +0300 genesys: Allow limiting the amount of data read from pipeline sources commit 663e3a99ed9008cd1eb8650f15b6211104d558c9 Author: Povilas Kanapickas Date: 2019-09-16 09:34:10 +0300 genesys: Add a way to report persistent eof() status from pipeline commit 2e10f4ac172b3431dbf852668589533bfda8a8f8 Author: Povilas Kanapickas Date: 2019-09-16 09:34:09 +0300 genesys: Report failures to produce full lines in pipeline commit f2b1b4449e5d4af6b852877fcf7a22afd76e420f Author: Povilas Kanapickas Date: 2019-09-16 09:34:08 +0300 genesys: Add a way to use an image as a source for a pipeline commit ab62a1448cb11a2dfb6fd9b3393850f087acc202 Author: Povilas Kanapickas Date: 2019-09-15 15:40:31 +0300 genesys: Use session for pixel coordinates during calibration commit b9346f0f79b87a25a58814dddfc9b6331feda5b4 Author: Povilas Kanapickas Date: 2019-09-15 15:14:18 +0300 genesys: Add a way to multiply the pixel counts sent to the scanner commit 00b8441dfab058e01d5b9168755f241d16e3deeb Author: Povilas Kanapickas Date: 2019-09-15 15:14:17 +0300 genesys: Add a way to override logical HW dpi commit 34c7a4cb2910848da5beeace0ceefe165f274d6c Author: Povilas Kanapickas Date: 2019-09-15 15:14:16 +0300 genesys: Rename {dpihw => register_dpihw}_override commit 050b0c1d8af5930b9f3faa64b7de1f15abfaeb1e Author: Povilas Kanapickas Date: 2019-09-15 14:46:48 +0300 genesys: Invert meaning of GENESYS_FLAG_LAZY_INIT commit c7bb34c998a08802e5eba1e2d5a87686d1e0e8e5 Author: Povilas Kanapickas Date: 2019-09-15 14:46:47 +0300 genesys: Simplify calibration calculations on GL843 commit 079fa25b0d6e864124fe2bb8c198cebab202836f Author: Povilas Kanapickas Date: 2019-09-15 14:46:46 +0300 genesys: Allow full value range of the frontend registers to be set commit 2bb31ed5d8c2f107bb32235d7d2442f30a30a92f Author: Povilas Kanapickas Date: 2019-09-15 14:46:45 +0300 genesys: Remove duplicate logs of information included into session commit db36dd81036ac7ee9d5c15efc7f117805546f81d Author: Povilas Kanapickas Date: 2019-09-15 10:36:58 +0300 genesys: Move pixel coordinate calculation to a single place commit be4c3c1f699cef1aa1f169fba9a736f4c51467cb Author: Povilas Kanapickas Date: 2019-09-14 13:49:23 +0300 genesys: Reduce duplication of shading calculations commit 580b9db56238ee8f98a9d6e1b4cbc7c7cad1ce04 Author: Povilas Kanapickas Date: 2019-09-14 13:49:22 +0300 genesys: Don't duplicate actions when DARK_CALIBRATION flag is off commit 8790940cc343b892a1a4c4912da6ed09e22bd8df Author: Povilas Kanapickas Date: 2019-09-14 13:49:21 +0300 genesys: Remove code that has no effects commit 154ab4578b1f87d9791e359473f2003caa4ba5e6 Author: Povilas Kanapickas Date: 2019-09-14 13:49:20 +0300 genesys: Extract calculation of dummy dark shading commit 6f29caef0d7125c91e488b13e826c115a6ab8998 Author: Povilas Kanapickas Date: 2019-09-14 13:49:19 +0300 genesys: Extract post-shading repark out of white calibration function commit 802a62ee2cd13336ef0889281aa2da1a7bf2bbe7 Author: Povilas Kanapickas Date: 2019-09-13 16:40:42 +0300 genesys: Fix incorrect calculation of output_line_bytes_raw on gl646 commit 40b2d8928f22e5885dedc8eb424bd5590ce57647 Author: Povilas Kanapickas Date: 2019-09-13 16:40:41 +0300 genesys: Fix definition of output_line_bytes_raw on gl841 CIS scanners commit 434b03d4986febf22bd65c06521540a0296fe2c9 Author: Povilas Kanapickas Date: 2019-09-13 16:40:40 +0300 genesys: Fix definition of output_line_bytes_raw on gl124 commit efbfcb0a7fc88fdfda0aeb13d0b32379d7e9100d Author: Povilas Kanapickas Date: 2019-09-13 16:03:21 +0300 genesys: Improve clarity of calibration offset variable names commit 661aa3bcdb42a30ff02ffbe7d3f74ad09573a4a6 Author: Povilas Kanapickas Date: 2019-09-13 15:56:44 +0300 genesys: Make GenesysRegisterSettingSet generic commit d4e4bf35c1275448bb212e33ee5eebe9afa505cf Author: Povilas Kanapickas Date: 2019-09-13 15:37:33 +0300 genesys: Fix a bug in segmented sensors when scanning 16-bit data commit af17797d3ce91aad2b7ff9cb604955716a1195ad Author: Povilas Kanapickas Date: 2019-09-13 15:37:32 +0300 genesys: Use new image pipeline for handling segmented sensors commit 7f852e0417a7524b6abb7bc6e428cee87dbef20d Author: Povilas Kanapickas Date: 2019-09-13 15:37:31 +0300 genesys: Fix depth calculation for segmented sensors in lineart mode commit e89c6a0aab188938b77c885946ab163ba1cbfa64 Author: Povilas Kanapickas Date: 2019-09-13 15:37:30 +0300 genesys: Remove accidental uses of C++14 APIs commit 9a844e1eded54687aa4094359fdabe5f233f24d2 Author: Povilas Kanapickas Date: 2019-09-13 11:36:56 +0300 genesys: Compute what image processing will be needed in session commit a5efb969789f1ea8f663267ed5e1012ac7c35831 Author: Povilas Kanapickas Date: 2019-09-13 11:36:55 +0300 genesys: Replace uses of Genesys_Color_Order with ColorOrder commit 05ed63fa34edd1e3c842b996f85d554bee8d8df1 Author: Povilas Kanapickas Date: 2019-09-13 11:36:54 +0300 genesys: Move setup of read buffer to a single function commit 28d15784e4e3ee5750203f7bb401d716037df436 Author: Povilas Kanapickas Date: 2019-09-13 11:36:53 +0300 genesys: Remove unused code commit 8ed2cd991b24f64ff6945ee67adaa93e40dcd43a Author: Povilas Kanapickas Date: 2019-09-13 11:36:52 +0300 genesys: Initialize frontend state from the outset commit d73915ba197a9d33dc9e3e8131660c01d2c6b833 Author: Povilas Kanapickas Date: 2019-09-13 11:01:48 +0300 genesys: Implement gain calibration for Analog-Devices ADC commit e45e668326a4499a8586ab94b6a7bb2a2380efa3 Author: Povilas Kanapickas Date: 2019-09-13 11:01:47 +0300 genesys: Extract gain computation into a separate function commit 94c1cf1d5a640aa6a40b93d3f37dba3a60816477 Author: Povilas Kanapickas Date: 2019-09-13 11:01:46 +0300 genesys: Add clamp() utility function commit ad1067ad03b4a043372ce6c2ec6408448e65e4ff Author: Povilas Kanapickas Date: 2019-09-13 10:52:35 +0300 genesys: Add support for segmented sensors on gl843 commit 1c7ef4b55ee998af7612a68e50de97a5fbc5a0e8 Author: Povilas Kanapickas Date: 2019-09-13 10:38:05 +0300 genesys: Implement image data source that mimics current reading from USB commit 7d7a3952773258027c92d331f9d7e6e9d6ba6f69 Author: Povilas Kanapickas Date: 2019-09-13 10:38:04 +0300 genesys: Implement library for image manipulation commit 2f3d9e9d7682bce0cd87bdf3e7322943a27742ab Author: Povilas Kanapickas Date: 2019-09-12 23:48:16 +0300 genesys: Don't crash when default scan method is not supported commit 4c18ef27a247c4a1d04ee34d2d7f00c7063683e7 Author: Povilas Kanapickas Date: 2019-09-12 23:48:15 +0300 genesys: Raise exception when device structs are not found commit c2115543db126832450bbf4d2a66b82d53ce4a85 Author: Povilas Kanapickas Date: 2019-09-12 23:48:14 +0300 genesys: Implement a way to set default scan method used internally commit c0010fcd9f26f9af34de7b49f3aef90dc938896e Author: Povilas Kanapickas Date: 2019-09-12 23:48:13 +0300 genesys: Fix incorrect scan method in move function on gl646 commit 1e2f64dc3dee2f53cf9a8eb5f9201660cff5cd6c Author: Rolf Bensch Date: 2019-09-12 22:09:22 +0200 pixma: backend version 0.23.2 commit aacdd88a274e2ebaf702ce161292529f41946a35 Author: Rolf Bensch Date: 2019-09-12 22:08:49 +0200 pixma: update doc files commit fd94a7e60c24d7564cbf1bf49c99fedda377f036 Merge: 7e3a68c9 7f491519 Author: Rolf Bensch Date: 2019-09-12 19:42:12 +0000 Merge branch 'MF633_635_645' into 'master' pixma: new scanners Canon i-SENSYS MF633C/MF635C, MF645C See merge request sane-project/backends!126 commit a830fca943fcf6c2a30669392b8dea3ab68e65ca Author: Povilas Kanapickas Date: 2019-09-12 22:40:57 +0300 genesys: Remove GL123 enum commit 322a9a6810f18a45055eae2c90e73c457ee02880 Author: Povilas Kanapickas Date: 2019-09-12 22:40:56 +0300 genesys: Don't modify session in *_init_scan_regs() commit 80d0129f4415a55325f53f3622802f05d4e8f6e5 Author: Povilas Kanapickas Date: 2019-09-12 22:40:55 +0300 genesys: Pass start pixel to *_init_optical_regs_scan() via session commit c0e465784e7fd85ce811b15159ee8b849b68f158 Author: Povilas Kanapickas Date: 2019-09-12 22:40:54 +0300 genesys: Deduplicate different get_sensor_profile implementations commit 9b7ab9372786c63a90c01817f25ad17dbb12808e Author: Povilas Kanapickas Date: 2019-09-12 22:39:22 +0300 genesys: Add unit test for genesys_fill_segmented_buffer() commit 502478a40d66030895abcc351250fc040bfe41a9 Author: Povilas Kanapickas Date: 2019-09-12 22:39:21 +0300 genesys: Reindent genesys_fill_segmented_buffer() commit c2c65f29c9a2fa6695141532f104f00d1d7bfd17 Author: Povilas Kanapickas Date: 2019-09-12 22:39:20 +0300 genesys: Simplify genesys_fill_segmented_buffer() commit 0267eeeeae4be4b2dbf45d8be3e1d0be5efb0e12 Author: Povilas Kanapickas Date: 2019-09-12 22:22:00 +0300 genesys: Remove the desegmentation state struct commit 3d023060a35fb8b1cf2311746340f83d1118c59e Author: Povilas Kanapickas Date: 2019-09-12 22:21:59 +0300 genesys: Move desegmentation skip_bytes to session struct commit 192dd886cd9e7fd368c339f4ef3526b082a18c83 Author: Povilas Kanapickas Date: 2019-09-12 22:21:58 +0300 genesys: Use common code path to compute ..._segment_pixel_group_count commit 4870a9f97529b09fa9cf013c76b3e40329078024 Author: Povilas Kanapickas Date: 2019-09-12 22:21:57 +0300 genesys: Properly set conseq_pixel_dist_bytes on gl124 commit 95eb6a72ddf52a1d95b5427a6d441d9992bd9ce1 Author: Povilas Kanapickas Date: 2019-09-12 22:21:56 +0300 genesys: Use single code path to compute session output_line_bytes_raw commit 1f4a5311d74b518b25411bc12da4e7d5974b7d20 Author: Povilas Kanapickas Date: 2019-09-12 22:21:55 +0300 genesys: Rename DesegmentationState::raw_{channel => line}_bytes commit 61d4779402c7c79852187f7e8916ff661d8963f2 Author: Povilas Kanapickas Date: 2019-09-12 22:21:54 +0300 genesys: Remove erroneously named raw_line_bytes The raw_channel_bytes is what we store the line information to. Turns out raw_line_bytes is unnecessary and only ever used by error. commit 4df8872ab3559e7162f99fab4d1078f5db1827e4 Author: Povilas Kanapickas Date: 2019-09-12 22:21:53 +0300 genesys: Simplify raw_channel_bytes computation more On the chipsets in question, session.hwdpi_divisor == sensor.optical_res / sensor.get_register_hwdpi(...), so the divisor cancels out with the rest of the expression. commit 95a3836f1a08252d5d7f32748389d1175bf93d1c Author: Povilas Kanapickas Date: 2019-09-12 22:21:52 +0300 genesys: Simplify raw_channel_bytes calculation commit 98320f5b8126e638e0e0064d43555b63b80f9515 Author: Povilas Kanapickas Date: 2019-09-12 22:21:51 +0300 genesys: Don't overflow in multiply_by_depth_ceil commit eb0882ecc4459d6e8982e97446b34f1f9357b517 Author: Povilas Kanapickas Date: 2019-09-12 22:11:20 +0300 genesys: Use common code path to compute session optical_pixels_raw commit 3a323a751a60e1091d8bde2a569a7daadd072db1 Author: Povilas Kanapickas Date: 2019-09-12 22:11:19 +0300 genesys: Use common code path to compute session conseq_pixel_dist_bytes commit 52baae02dca2f0bd346d9f9453b6afeff03874da Author: Povilas Kanapickas Date: 2019-09-12 21:55:30 +0300 genesys: Use common code path to compute session hwdpi_divisor commit f480521a231596f5c3ce35dbc7466b6913aa34af Author: Povilas Kanapickas Date: 2019-09-12 21:55:29 +0300 genesys: Pass sensor profile directly to *_setup_sensor() where possible commit 676831dc7bf9cab36fe72786e8a89d935ea8da0b Author: Povilas Kanapickas Date: 2019-09-12 21:26:58 +0300 genesys: Move Genesys_Device::curr to DesegmentationState commit f92253adc86b425abc228ddbed6de1dac67f40c3 Author: Povilas Kanapickas Date: 2019-09-12 21:26:57 +0300 genesys: Move Genesys_Device::segnb to DesegmentationState commit 15996983ba34868927750665dd49b3d13b76a2c8 Author: Povilas Kanapickas Date: 2019-09-12 21:26:56 +0300 genesys: Rename SensorProfile::segment_{count => size} commit 31820384de76a71e83b6fa003b2d2c95d2a85272 Author: Povilas Kanapickas Date: 2019-09-12 21:26:55 +0300 genesys: Move Genesys_Device::skip to DesegmentationState commit 9bd14f535059e674016a96b1f04a38533bc15a4b Author: Povilas Kanapickas Date: 2019-09-12 21:26:54 +0300 genesys: Move Genesys_Device::len to DesegmentationState commit 07d8db5423cae48cbe247f3a3b6f42a1c33aa6ca Author: Povilas Kanapickas Date: 2019-09-12 21:26:53 +0300 genesys: Move Genesys_Device::dist to DesegmentationState commit dd702968279b4328d0650853a15cc4bf96542494 Author: Povilas Kanapickas Date: 2019-09-12 21:26:52 +0300 genesys: Move desegmentation line width data to a separate struct commit 827c3a049db4391501dda81f2999df8e4d011403 Author: Povilas Kanapickas Date: 2019-09-12 21:26:51 +0300 genesys: Rename ScanSession::output_{line_channel => channel}_bytes commit b856c2cb6f8946a2560959783d6c85bbbb766fed Author: Povilas Kanapickas Date: 2019-09-12 21:24:32 +0300 genesys: Remove used_pixels to simplify segment setup commit 0a10bcef59bc1cd021cc6b97fb561e551f468845 Author: Povilas Kanapickas Date: 2019-09-12 21:24:31 +0300 genesys: Refactor the segment setup code to expose chip similarities commit 41b5e5f5ff3932758348e2d673fa9ab492617dda Author: Povilas Kanapickas Date: 2019-09-12 21:24:30 +0300 genesys: Use common code path to compute session segment_count commit ae784d9927b9c0c5395d3eb7b7189971a146fdc2 Author: Povilas Kanapickas Date: 2019-09-12 21:24:29 +0300 genesys: Simplify segment count calculation commit cbb7e953505e09f049e142f8cf30d903fb1d1d50 Author: Povilas Kanapickas Date: 2019-09-12 20:28:46 +0300 genesys: Use common code path to compute session buffer sizes commit a0cead1cd5d43bba44fc400676ee52b86fc8c186 Author: Povilas Kanapickas Date: 2019-09-12 20:28:45 +0300 genesys: Pass asic type to sanei_genesys_get_bulk_max_size() commit 88d6cdcc32c13114531b9879ece1410b56e3de09 Author: Povilas Kanapickas Date: 2019-09-12 20:06:38 +0300 genesys: Rename read_bytes_left -> read_bytes_left_after_deseg commit 96a893bb0d9c46ae2ce0a4824d7fc63f863e8c0d Author: Povilas Kanapickas Date: 2019-09-12 20:06:37 +0300 genesys: Simplify words_per_line calculations commit 463f5f4364b8e702369af10f28fb78bc7b253633 Author: Povilas Kanapickas Date: 2019-09-12 20:06:36 +0300 genesys: Don't duplicate data passed to *_init_optical_regs_scan() commit ed4419e73d631f04e9f6b2da07ea1adc2429f3fc Author: Povilas Kanapickas Date: 2019-09-12 19:49:51 +0300 genesys: Use common code path to calculate session line sizes commit 9915608309a803c4cc306158c896117cb64ccf76 Author: Povilas Kanapickas Date: 2019-09-12 19:49:50 +0300 genesys: Extract multiplication by depth to a separate function commit 991eec63d57ef58a6c67af7e18f182edf13aaf7c Author: Povilas Kanapickas Date: 2019-09-12 19:34:43 +0300 genesys: Use common code path to compute session output_line_count commit 605fcf97626fcc66fd3f7b0c9e2e1aa9e29afa1a Author: Povilas Kanapickas Date: 2019-09-12 19:11:07 +0300 genesys: Assume correct resolution is passed from high-level commit 73951b4bf80a498ec238a6a9ef951fc598b3b7ae Author: Povilas Kanapickas Date: 2019-09-12 19:11:06 +0300 genesys: Simplify motor code on gl646 by retining real motor dpi prop commit ce144ed46fe7b28b4e1753753651796af70fc47d Author: Povilas Kanapickas Date: 2019-09-12 18:27:45 +0300 genesys: Use common code path to compute session max_color_shift_lines commit 0961c5d32fc173bb55a30cdd55d7b28ac6c5a1ab Author: Povilas Kanapickas Date: 2019-09-12 18:23:32 +0300 genesys: Use common code path to compute session output_pixels commit 77e0acde229f89efaf3fbea1e990b90ae1d9f932 Author: Povilas Kanapickas Date: 2019-09-12 18:22:57 +0300 genesys: Fix computation of total_bytes_to_read commit 50e5c804346bf92528b7aad384dbc4749dec0f98 Author: Povilas Kanapickas Date: 2019-09-12 18:21:18 +0300 genesys: Remove low-level handling of xdpi < ydpi case The high-level code ensures that the xdpi is always natively supported by the scanner. commit 548eff4a329b9ee0ff860cc0edb332f20b3ab201 Author: Povilas Kanapickas Date: 2019-09-12 18:21:17 +0300 genesys: Fix support for scans when xdpi Date: 2019-09-12 18:21:16 +0300 genesys: Use Sensor::optical_res directly where possible commit 453a6b75be86522aa03d666ceddd77c0950880dd Author: Povilas Kanapickas Date: 2019-09-12 17:59:47 +0300 genesys: Use common code path to compute session num_staggered_lines commit 7e3a68c9e7ceee244ad7cbe1ed0842ae5dd7cf2e Merge: 489a8008 f2ce27f4 Author: Povilas Kanapickas Date: 2019-09-09 21:54:13 +0000 Merge branch 'sanei-usb-fix-build-without-usb' into 'master' sanei_usb: Fix build when USB support is disabled Closes #123 See merge request sane-project/backends!150 commit f2ce27f441307ae42c888a033328c8007e62bc36 Author: Povilas Kanapickas Date: 2019-09-10 00:39:08 +0300 sanei_usb: Fix build when USB support is disabled commit 489a80088abc289be23c2ab6f44840030b8f8293 Merge: 6b7052c4 8f1615f3 Author: Stanislav Yuzvinsky Date: 2019-09-07 18:20:19 +0000 Merge branch 'ricoh2' into 'master' ricoh2: Add support for Aficio SG3110SFNw See merge request sane-project/backends!149 commit 8f1615f3337d401961094cd707d2271c5b281f12 Author: Vladislav Bogdanov Date: 2019-09-04 11:07:26 +0300 ricoh2: Add support for Aficio SG3110SFNw commit 6b7052c4cf24c3a01d1871bdeb90c6627c083e51 Merge: fc85e7d1 2757475d Author: Povilas Kanapickas Date: 2019-08-31 18:19:57 +0000 Merge branch 'genesys-misc-cleanup' into 'master' genesys: Miscellaneous cleanup See merge request sane-project/backends!148 commit fc85e7d15d4a8631e9777cf7704d3115fdc8058a Merge: 3db2278b 5226a163 Author: Povilas Kanapickas Date: 2019-08-31 18:02:54 +0000 Merge branch 'genesys-session-optical-pixels' into 'master' genesys: Use common code path to compute session optical_pixels See merge request sane-project/backends!147 commit 3db2278bea1af5d74923ff6b746ed390a16f769a Merge: 66c804a7 ec5225e1 Author: Povilas Kanapickas Date: 2019-08-31 17:44:21 +0000 Merge branch 'genesys-misc-simplify' into 'master' genesys: Miscellaneous simplifications See merge request sane-project/backends!146 commit 66c804a7ea40f30fe771421a9eab4ccac90ac8be Merge: 6fcfab3f a2ade508 Author: Povilas Kanapickas Date: 2019-08-31 17:18:37 +0000 Merge branch 'genesys-ensure-correct-resolution-high-level' into 'master' genesys: Ensure that correct resolution is passed from high level See merge request sane-project/backends!145 commit 6fcfab3fdad1783765fa48c280d586bce03ac3ca Merge: dc7c1f81 f4823941 Author: Povilas Kanapickas Date: 2019-08-31 17:02:03 +0000 Merge branch 'genesys-session-optical-resolution' into 'master' genesys: Use common code path to compute session optical_resolution See merge request sane-project/backends!144 commit dc7c1f81f384bf23b8275d56229d689258eb42c6 Merge: da5d0bc9 687b549f Author: Povilas Kanapickas Date: 2019-08-31 16:45:04 +0000 Merge branch 'genesys-session-ccd-size-divisor' into 'master' genesys: Use ScanSession to compute ccd_size_divisor on all chips See merge request sane-project/backends!143 commit da5d0bc91698dd4f923398b1b1fad7534201283a Merge: 1a02dfc8 510b6d0d Author: Povilas Kanapickas Date: 2019-08-31 16:22:45 +0000 Merge branch 'genesys-gl646-simplify-setup-registers' into 'master' genesys: Simplify gl646 register setup See merge request sane-project/backends!142 commit 510b6d0d86be7892e284ddb7a0e592faa5a8bc12 Author: Povilas Kanapickas Date: 2019-08-26 00:29:18 +0300 genesys: Remove gl646-specific get_ccd_size_divisor commit e0efbd37b80022f1451b19aa558775d22300bdf5 Author: Povilas Kanapickas Date: 2019-08-25 23:40:39 +0300 genesys: Use sensor functionality instead of compute_ccd_size_divisor() commit a6a785e28d95d644c48a03f201519712f5cc7c1c Author: Povilas Kanapickas Date: 2019-08-25 23:34:38 +0300 genesys: Use common path to compute ccd_size_divisor on gl646 commit e2e1efae804fb3f1e2fb2a2c083e332fd6878048 Author: Povilas Kanapickas Date: 2019-08-25 23:24:19 +0300 genesys: Use the sensor passed to gl646_setup_registers() commit 1a02dfc8cb072bde4cde5f46ff297da0cacd623f Merge: ab9f5531 ceb56a8b Author: Povilas Kanapickas Date: 2019-08-31 15:44:23 +0000 Merge branch 'genesys-gl646-common-sensor-table' into 'master' genesys: Use common sensor table on gl646 See merge request sane-project/backends!141 commit ab9f5531c1f23e36bd891c90b32f5be442079b2c Merge: 0c6d7cd4 5532f2f2 Author: Povilas Kanapickas Date: 2019-08-31 15:23:06 +0000 Merge branch 'genesys-identify-sensor-channel-count' into 'master' genesys: Identify sensor by supported channel count See merge request sane-project/backends!140 commit 0c6d7cd4a40d29dfb9139cf0739cf6149dd739ef Merge: 3e2b6cea eb4fb440 Author: Povilas Kanapickas Date: 2019-08-31 14:56:23 +0000 Merge branch 'genesys-fix-missing-return-after-refactor' into 'master' genesys: Fix missing return from a previous refactor See merge request sane-project/backends!138 commit 3e2b6cead083f441ec68e32e62e31c1bd1acf80d Merge: 6216ada2 d9fab3a7 Author: Povilas Kanapickas Date: 2019-08-31 14:55:57 +0000 Merge branch 'genesys-gl646-simplify-sensor' into 'master' genesys: Simplify sensor setup on GL646 See merge request sane-project/backends!139 commit 6216ada2e7cabb2620aa947980152476f224ffa8 Merge: 5b99a428 86ac877d Author: Povilas Kanapickas Date: 2019-08-31 14:43:05 +0000 Merge branch 'genesys-fix-sensor-write' into 'master' genesys: Fix writing to sensors See merge request sane-project/backends!137 commit 5b99a428d2cdf45b35daa5ecbeb9eaddb30f2f0f Merge: 6e950209 0cd26a8a Author: Povilas Kanapickas Date: 2019-08-31 14:39:01 +0000 Merge branch 'genesys-resolution-filter-class' into 'master' genesys: Extract resolution filtering to separate class See merge request sane-project/backends!136 commit 6e950209b688cd82dd6804d108ad2a4eb8b2b6ad Merge: c34cd7cd 107404dc Author: Povilas Kanapickas Date: 2019-08-31 14:09:52 +0000 Merge branch 'genesys-session-ccd-size-divisor' into 'master' genesys: Use common code path for ccd_size_divisor computation See merge request sane-project/backends!135 commit c34cd7cd8661e7b046e1974c2f9eda55cadd0f42 Merge: 302932c1 53d447b6 Author: Povilas Kanapickas Date: 2019-08-31 13:25:34 +0000 Merge branch 'genesys-common-sensor-profiles' into 'master' genesys: Use the sensor description list for sensor profiles See merge request sane-project/backends!134 commit 302932c1dbb592797e15042c61c79eba5f91360c Merge: 4a9738b7 7872f874 Author: Povilas Kanapickas Date: 2019-08-31 13:20:00 +0000 Merge branch 'genesys-gl843-single-gpio-setting-list' into 'master' genesys: Move all gpio settings to a single struct on GL843 See merge request sane-project/backends!133 commit 4a9738b71958e81704c5f257ef9eb82bc29520d5 Merge: 2896c21f 759e450b Author: Povilas Kanapickas Date: 2019-08-31 13:04:53 +0000 Merge branch 'genesys-simplify-reg-setting-set' into 'master' genesys: Reduce duplication in GenesysRegisterSettingSet See merge request sane-project/backends!132 commit 2896c21ffe9d75b0b0a36f25b7de273ef3172986 Merge: 562f9003 8fce6b62 Author: Povilas Kanapickas Date: 2019-08-31 12:58:50 +0000 Merge branch 'genesys-frontend-type' into 'master' genesys: Add frontend type to the frontend description See merge request sane-project/backends!131 commit 562f900337be1a94eb980b960288cba83f7e2185 Merge: e452e869 a76a2a09 Author: Povilas Kanapickas Date: 2019-08-31 12:54:14 +0000 Merge branch 'genesys-override-dpiset' into 'master' genesys: Implement a way to override dpiset See merge request sane-project/backends!130 commit e452e869c267452756c11704adeffb058e371e9c Merge: c73a7b5b 503797c2 Author: Povilas Kanapickas Date: 2019-08-31 12:46:46 +0000 Merge branch 'genesys-simplify-shading-calibration' into 'master' genesys: Simplify shading calibration See merge request sane-project/backends!129 commit c73a7b5b0601016ee5b75b1d962879891ad1d4fd Merge: e6b27863 5e5a1a6f Author: Povilas Kanapickas Date: 2019-08-31 12:24:34 +0000 Merge branch 'genesys-fix-std-accumulate' into 'master' genesys: Use correct type for std::plus See merge request sane-project/backends!128 commit 5e5a1a6fc3abe9418090438b235ffa7b2f4f8dc2 Author: Povilas Kanapickas Date: 2019-08-31 15:11:40 +0300 genesys: Use correct type for std::plus commit e6b27863807654e24c0d2c6169bb506be68d4f2d Merge: b4c95a8a f18ef0e2 Author: Stanislav Yuzvinsky Date: 2019-08-30 14:16:41 +0000 Merge branch 'macos-malloc-fix' into 'master' ricoh2_buffer: fix malloc header location on macOS See merge request sane-project/backends!90 commit 97387e20890035b4685b939415af46b21958903f Author: Olaf Meeuwissen Date: 2019-08-28 21:21:07 +0900 Install ChangeLogs/ files in $docdir/ChangeLogs/ This makes the trailing comment in ChangeLog correct for both the repository and installed documentation. Complements ee2653b02b75e6b99a0ff77745a4a738049d58db. commit 7f491519d106ecd672e5ef2bb16693056e21ea1d Author: Mikael Vallerie Date: 2019-08-27 15:34:47 +0200 Removing MF635_PID, using MF630_PID instead commit d08e4c9000808aba840b7f8e7e5b26f2af2326c1 Author: Mikael Vallerie Date: 2019-08-27 15:33:58 +0200 Removing MF633C/MF635C from docs, as it's just a variant of MF630 commit 13008723cd9f6954ecc86f51fb612171ec183570 Author: Mikael Vallerie Date: 2019-08-26 18:41:29 +0200 Right PIDs for MF633C/MF635C and MF645C commit f38f0b868117eff208460ba0e77a6270247c71fd Author: Mikael Vallerie Date: 2019-08-26 18:41:06 +0200 Right pid for MF645C commit 8f3b84f6f4e166cfbae73220d888eaa9d7d7025d Author: Olaf Meeuwissen Date: 2019-08-26 21:53:09 +0900 Adjust ChangeLog trailer comment to match Makefile.am comment commit 2baee4914d0d31aac01e939d91885b6695bcc47d Author: Olaf Meeuwissen Date: 2019-08-26 21:48:52 +0900 umax_pp: Drop reference to ChangeLog in code comment commit eb5382c7535caf2deedfe54bc5e455de4dd55b11 Author: Olaf Meeuwissen Date: 2019-08-26 21:48:09 +0900 mustek_pp: Drop unused ChangeLog: references from comments commit fe6bac727f6c557df01f0385a56b8b5133561ea0 Author: Olaf Meeuwissen Date: 2019-08-26 21:43:52 +0900 doc: Drop moving of ChangeLog files with each release. See #103 commit 47f0b5dee2af853c6f024edc4d8affd9f225656d Author: Olaf Meeuwissen Date: 2019-08-26 21:43:25 +0900 doc: Update ChangeLog related documentation commit 2a9d98be6e9ec22507c13b3c5cceba3bd234ec8a Author: Olaf Meeuwissen Date: 2019-08-24 17:24:23 +0900 Resurrect ChangeLog-1.0.11 It was missing in the ChangeLogs/ directory. Content has been dug up from the ChangeLog file for the RELEASE_1_0_11 tag. commit ee2653b02b75e6b99a0ff77745a4a738049d58db Author: Olaf Meeuwissen Date: 2019-08-24 17:10:27 +0900 Include ChangeLogs/ directory content in source tarball. Re #103 The files are installed next to the ChangeLog file in $docdir. There will be *no* $docdir/ChangeLogs/ directory. commit 2757475dd99863eeb5e59ea38333c362bfd26604 Author: Povilas Kanapickas Date: 2019-08-24 10:13:44 +0300 genesys: Use session.params.xres directly where possible commit ba3013b1aae35b57e35dc38c4027e182f2fb519f Author: Povilas Kanapickas Date: 2019-08-24 10:13:43 +0300 genesys: Handle full sensor scans on gl841 consistently to other chips commit 48251cf8b22dec638861cd8832bbf1fe0d1e38bc Author: Povilas Kanapickas Date: 2019-08-24 10:13:42 +0300 genesys: Simplify start pixel computation on gl841 commit 6ca11bfd719fdf6e08fd5c8711356af0f9bca97d Author: Povilas Kanapickas Date: 2019-08-24 10:13:41 +0300 genesys: Always dump session after computing it commit 5226a163ab606178474bcbdc12466689a53a2604 Author: Povilas Kanapickas Date: 2019-08-24 10:05:53 +0300 genesys: Use common code path to compute session optical_pixels commit ec5225e1f8a165fd50786459383b16f5c0c39524 Author: Povilas Kanapickas Date: 2019-08-24 10:00:52 +0300 genesys: Assume correct resolution is passed from high-level commit 9a21a8335fadc7f5722b85dc0172ee24f221b3b1 Author: Povilas Kanapickas Date: 2019-08-24 10:00:51 +0300 genesys: Remove dead code related to SCAN_FLAG_USE_OPTICAL_RES commit 21f949bd8736ecffe0ed0ad1409bbe01d882d148 Author: Povilas Kanapickas Date: 2019-08-24 10:00:50 +0300 genesys: Remove *_compute_exposure() wrappers commit b4c95a8ade91463a9f2d5c9f51daad9f6548d0e5 Author: Rolf Bensch Date: 2019-08-20 13:30:25 +0200 pixma: backend version 0.23.1 commit f64489bd7179e148f50d9586be2c5f064a4c1804 Author: Rolf Bensch Date: 2019-08-20 13:16:32 +0200 pixma: fix ADF scanning for Canon MAXIFY MB2000 and MB2300 Series commit 8446baf4f9eb7f11d56b5b0771bc452dca7e6507 Author: Rolf Bensch Date: 2019-08-20 13:11:57 +0200 pixma: fix ADF scanning for Canon MAXIFY MB5000 Series commit 62284c2ed5739e51accaa4e3c8b96e0047425996 Author: Mikael Vallerie Date: 2019-08-19 20:21:23 +0200 Docs for MF633C/MF635C and MF645C commit 5e74e1b7940e32b2a6f387410755149d21672a4f Author: Olaf Meeuwissen Date: 2019-08-19 22:06:33 +0900 genesys: Make std::plus<> template type instantiation explicit This fixes compile errors on older versions of gcc and possibly other C++ compilers. commit 5d21800b51f86b7d6e4d8be8c89b7e2186a7daa7 Author: Mikael Vallerie Date: 2019-08-18 18:53:08 +0200 pixma: new scanners Canon i-SENSYS MF633C/MF635C, MF645C commit a2ade508700adab5ecffca3301170fa0f3ed8ca0 Author: Povilas Kanapickas Date: 2019-08-18 11:13:01 +0300 genesys: Ensure that resolution is set to a supported one at high-level Previously we relied on low-level implementation to detect when the requested resolution is higher than one supported by the scanner and seamlessly patch around so that the high-level code does not notice. This complicates the low level implementation and results to duplicate code. commit 61a055a8cfb8fb8874ba077cb602a9447dd5f128 Author: Povilas Kanapickas Date: 2019-08-18 11:13:00 +0300 genesys: Pass the line width requested by the frontend separately commit 0b2840a3ff61a791f8a19c0f9e5d0343f6d9a229 Author: Povilas Kanapickas Date: 2019-08-18 11:12:59 +0300 genesys: Clarify frontend param processing a little commit ec0ceaebb5fa61390f38655c2e497063aa021608 Author: Povilas Kanapickas Date: 2019-08-18 11:12:58 +0300 genesys: Use correct resolution to select sensor during option parsing commit f48239419ab3756fd84e51e05625d54b142341df Author: Povilas Kanapickas Date: 2019-08-18 10:39:36 +0300 genesys: Use common code path to compute session optical_resolution commit 687b549f0ad1f25d31d045d9a10098a4001444c9 Author: Povilas Kanapickas Date: 2019-08-18 10:37:49 +0300 genesys: Use ScanSession to compute ccd_size_divisor on all chips commit ceb56a8b3b5d4ebf8515a2e2d4d496d9b9264344 Author: Povilas Kanapickas Date: 2019-08-17 12:02:45 +0300 genesys: Move gl646 sensor settings to the common sensor table commit a31da79e076155b1ea2d743b5f7f06687f4125db Author: Povilas Kanapickas Date: 2019-08-17 12:02:44 +0300 genesys: Compute cksel from register descriptions on gl646 commit 0cd26a8adf3d4a7190b8565897df236bfd466632 Author: Povilas Kanapickas Date: 2019-08-17 11:56:45 +0300 genesys: Extract resolution filtering to separate class commit 5532f2f277f5fdaad17b870138555e125c89f415 Author: Povilas Kanapickas Date: 2019-08-17 11:51:35 +0300 genesys: Add channel count to the parameters that identify a sensor commit f2871ca81dd29512be9af19dcad5ad6e191f788e Author: Povilas Kanapickas Date: 2019-08-17 11:51:34 +0300 genesys: Reduce duplication in channel count and depth calculation commit d9fab3a7d8fd4b5a9ce196f0125c1e6648eea13f Author: Povilas Kanapickas Date: 2019-08-17 11:49:10 +0300 genesys: Fix incorrect channel count when fetching ccd_size_divisor All current scanners use the same divisor on both 1 and 3 channels, so this commit does not change behavior. commit e8d9b6ff5dde80f69e80632ce715e0ad7e9902b6 Author: Povilas Kanapickas Date: 2019-08-17 11:49:09 +0300 genesys: Reduce duplication in the Sensor_Master struct list commit f228e427a958c4aa80d6c9fd4d35cdad20d557d1 Author: Povilas Kanapickas Date: 2019-08-17 11:49:08 +0300 genesys: Store sensor settings in std::vector on gl646 commit a8ed3df0fd486400d14927b5ec53684bcacacf1f Author: Povilas Kanapickas Date: 2019-08-17 11:49:07 +0300 genesys: Merge Sensor_Settings struct to Sensor_Master commit c001662c0506c9e6bc4a0ee94b31e8b515c8b5c8 Author: Povilas Kanapickas Date: 2019-08-17 11:49:06 +0300 genesys: Reorder the components on Sensor_Master struct commit 71a467ddf34d61f8abc9e7edef4898ad222490be Author: Povilas Kanapickas Date: 2019-08-17 11:49:05 +0300 genesys: Remove unused data from Sensor_Master on gl646 commit b19720cfa17047c2030225e59174dd1bace6eda8 Author: Povilas Kanapickas Date: 2019-08-17 11:49:04 +0300 genesys: Simplify sensor register desc by matching ccd_size_divisor commit e36d6b8fb5ad09ab1b70616b0a79223fb273f099 Author: Povilas Kanapickas Date: 2019-08-17 11:49:03 +0300 genesys: Simplify exposure setting on gl646 commit a4a1003ffc8e5e0133592e0830978597ac9932a7 Author: Povilas Kanapickas Date: 2019-08-17 11:49:02 +0300 genesys: Rename Sensor_Master::{exposure->exposure_lperiod} commit a3a3647006882f8671395d107df791064d9086f4 Author: Povilas Kanapickas Date: 2019-08-17 11:49:01 +0300 genesys: Compute dpiset instead of storing it in tables on gl646 commit d2d43d5ed8e564d74c2529c1fda12cc56c2cbd55 Author: Povilas Kanapickas Date: 2019-08-17 11:49:00 +0300 genesys: Make sensor table initialization more generic on gl646 commit 1330d2289ba081d1ac11e83ef5644332ba1e5884 Author: Povilas Kanapickas Date: 2019-08-17 11:48:59 +0300 genesys: Correctly initialize Sensor_Master struct commit eb4fb440486846cdca3c14811c12c324f9ddb9ef Author: Povilas Kanapickas Date: 2019-08-17 11:30:33 +0300 genesys: Fix missing return from a previous refactor commit 107404dcd05e442068f112e339bc996e8c82be7f Author: Povilas Kanapickas Date: 2019-08-17 11:11:15 +0300 genesys: Move ccd_size_divisor computation to compute_session() commit 92412a90b25f11a866f6c68c132a47edc7d9e459 Author: Povilas Kanapickas Date: 2019-08-17 11:11:14 +0300 genesys: Create compute_session() for common session computation commit 86ac877d8225722fa2ec3fc52ad518a9c5f812e4 Author: Povilas Kanapickas Date: 2019-08-17 11:05:38 +0300 genesys: Remove unused code commit eb1c4fadb9497992691b4407c93cf77fa2a31512 Author: Povilas Kanapickas Date: 2019-08-17 11:05:37 +0300 genesys: Pick correct sensors during option parsing commit 1902c9fbcbb108e1fe7fa4588fa140ac29acfc84 Author: Povilas Kanapickas Date: 2019-08-17 11:05:36 +0300 genesys: Fix sensor const safety in *_search_start_position() commit f019f9e7b80f3a7c2aa6f4099e2fda1529b17365 Author: Povilas Kanapickas Date: 2019-08-17 11:05:35 +0300 genesys: Don't modify sensor in *_led_calibration() commit 53d447b6dcbb8d4fc2cc4653888e4b36febb0b6a Author: Povilas Kanapickas Date: 2019-08-17 11:02:39 +0300 genesys: Move GL846 sensor profiles to a common sensor array commit 4978eceda330ae361e79d301f591c475fe6cf204 Author: Povilas Kanapickas Date: 2019-08-17 11:02:38 +0300 genesys: Move GL847 sensor profiles to a common sensor array commit 63cc11bce15428fd76918a6e91ece1d742949d00 Author: Povilas Kanapickas Date: 2019-08-17 11:02:37 +0300 genesys: Move GL124 sensor profiles to a common sensor array commit 4348451e47fdd1e006b121786e4f065710ef56f3 Author: Povilas Kanapickas Date: 2019-08-17 11:02:36 +0300 genesys: Add sensor profile to the sensor struct This will allow moving per-chip sensor profile tables to a common configuration commit ba546d5370e4df85dd6cd002c03f67e890b0bef9 Author: Povilas Kanapickas Date: 2019-08-17 11:02:35 +0300 genesys: Store segment order as a std::vector commit 503797c2480b046aefe27043467ab000efd7d34e Author: Povilas Kanapickas Date: 2019-08-17 10:53:56 +0300 genesys: Simplify shading computation by using enum for color order commit 3a1163480a28214cb2f92c395e6b8a7b5dc96d86 Author: Povilas Kanapickas Date: 2019-08-17 10:53:55 +0300 genesys: Store calibration data using correct type internally commit 7872f87475c6aeb1e6b7152247f7abf66e7eb802 Author: Povilas Kanapickas Date: 2019-08-17 10:38:58 +0300 genesys: Move all gpio settings to a single struct on GL843 commit 8fce6b624c03db44b8cd5b1c56739f408b0802c3 Author: Povilas Kanapickas Date: 2019-08-17 10:27:42 +0300 genesys: Don't perform offset and gain calibration on unknown frontends commit 5580fc0db1c85902867761db90aeaf5575a194dc Author: Povilas Kanapickas Date: 2019-08-17 10:27:41 +0300 genesys: Add frontend type to the layout struct commit a76a2a096e377e887357ddf0754fea9205bc7ff6 Author: Povilas Kanapickas Date: 2019-08-17 10:21:04 +0300 genesys: Implement a way to override DPISET on GL124 and GL843 commit db15a755044cdc723ebbd4febd7b2fbcf3d75334 Author: Povilas Kanapickas Date: 2019-08-17 10:21:03 +0300 genesys: Add a way to override dpihw commit 458e31a0c0918a2a824fb878673a936b3859fe71 Author: Povilas Kanapickas Date: 2019-08-17 10:21:02 +0300 genesys: Extract setting of DPIHW to a separate function commit 759e450b6b0aaf5d68456ec2397d5d73a426243c Author: Povilas Kanapickas Date: 2019-08-17 10:02:40 +0300 genesys: Reduce logical duplication in GenesysRegisterSettingSet commit 543ba367bcaeb2e9c28a79d8fabe83f89404319a Author: Povilas Kanapickas Date: 2019-08-17 10:02:39 +0300 genesys: Rename GenesysRegisterSettingSet::{regs_->registers_} commit f37326784dcf71e498383fbe3317e45b1f669caf Merge: 21bb96d6 740f0132 Author: Olaf Meeuwissen Date: 2019-08-12 09:16:37 +0000 Merge branch 'ci-tweaks' into 'master' CI tweaks See merge request sane-project/backends!125 commit 740f013292fdda3d45726a6a9595396f2d26c7f5 Author: Olaf Meeuwissen Date: 2019-08-12 18:01:35 +0900 CI: Document the various jobs commit 5aa84ed9ead0c1d24757ea18a7782bf6ce0a092b Author: Olaf Meeuwissen Date: 2019-08-12 17:39:54 +0900 CI: Drop Debian 9 mini build The "mini" build scenario is sufficiently covered by Debian 10 mini. Considering the Debian 9 is now oldstable, there is not much value in keeping it around. commit 69044bdffe6d6ff1b8ce8181abe75b4074eed006 Author: Olaf Meeuwissen Date: 2019-08-12 17:38:54 +0900 CI: Drop Fedora 29 compile job It's package version make up is too similar to Debian 10 for it to be worth the CPU cycles. commit 08bff060f8cbf12c4299f46eaf233522956893af Author: Olaf Meeuwissen Date: 2019-08-11 17:20:47 +0900 CI: Fix make distclean target Implicit compile dependencies prevent automake from adding dependency tracking files to the list of files to clean up. commit 1f1b9dcd56e67c9b7dac1164505f60859da7d076 Author: Olaf Meeuwissen Date: 2019-08-11 12:59:07 +0900 CI: Only keep snapshots for 90 days The snapshots aren't meant to stay around forever, that's for releases. commit 8cb53a191ea04f32075a447da26b72a6d3f390a6 Author: Olaf Meeuwissen Date: 2019-08-11 12:52:03 +0900 CI: Move after_script: from stretch to buster This follows c90e9674e74f15b0839ea944de47f887566d07ee. commit 14e7ba47dda2ee7389e8db21268cd49e80ea968a Author: Olaf Meeuwissen Date: 2019-08-11 12:49:19 +0900 CI: Speed up compile stage jobs commit 68d70def14542af1862eeb6edbd07c50c2626f95 Author: Olaf Meeuwissen Date: 2019-08-11 12:22:19 +0900 autofoo: Fix ltmain.sh.patch offsets to match new version commit 041ea5f53c3330b84a9462b42032783ed770b51d Author: Olaf Meeuwissen Date: 2019-08-11 12:10:07 +0900 japi: Fix BUILT_SOURCES dependency Newer automake versions have the dist target depend on BUILT_SOURCES so that variable should not heavy build dependencies. This fixes the dist target sufficiently, for CI purposes at least, in that it leads to inclusion of the same list of files. Note that CI does not build anything in the japi/ directory. commit c90e9674e74f15b0839ea944de47f887566d07ee Author: Olaf Meeuwissen Date: 2019-08-11 12:08:50 +0900 CI: Build our source tarball on Debian's Buster This bumps the build distribution's version, up from Stretch. commit 21bb96d61e5b9f1507f6d973c51230ce7b591d78 Merge: f80cb86a 5cba3bd4 Author: Olaf Meeuwissen Date: 2019-08-11 01:48:16 +0000 Merge branch 'fix-warnings' into 'master' Fix -Wimplicit-fallthrough warnings See merge request sane-project/backends!85 commit 5cba3bd465f128784306214f07c9ee334f723518 Author: Olaf Meeuwissen Date: 2019-08-11 10:37:10 +0900 saned: Fix misleading log messages caused by fall through commit e42e3bc849ab98a45c27b30c4a44fe10cdf462a3 Author: Olaf Meeuwissen Date: 2019-08-11 10:23:29 +0900 scanimage: Fix misleading fall through annotation The `scanimage_exit()` call exits the program. commit 9344a957ed2e67cf1cd285eac66ed7dd159d8d13 Author: Olaf Meeuwissen Date: 2019-08-11 10:16:00 +0900 apple: Fix [-Wimplicit-fallthrough] compiler warning It doesn't make sense to log a value as both `Fixed` *and* `Int`. commit 797cd1fb37ee87185ad79fd4bf87648b33599e83 Author: Olaf Meeuwissen Date: 2019-08-10 21:05:48 +0900 epson2, epsonds, kodakaio, magicolor: Don't set invalid value If the value to be set is not valid, it should not change the sval structure (even if doing so has no negative side effects). This also makes the fallthrough less confusing by removing the first cast of two for the br-x and br-y values. commit f80cb86a1f677f32a9f612db0fbc99d73bf01247 Merge: 7159bbee 6912400c Author: Povilas Kanapickas Date: 2019-08-10 15:53:39 +0000 Merge branch 'genesys-split-tables' into 'master' genesys: Split tables into separate files See merge request sane-project/backends!124 commit 7159bbee3296fbe13e82293e8fd1e3fb61edd31f Merge: 8a48e877 8cb6130c Author: Povilas Kanapickas Date: 2019-08-10 15:33:38 +0000 Merge branch 'genesys-cleanup-gpo' into 'master' genesys: Cleanup the gpo setup See merge request sane-project/backends!123 commit 8a48e8774109d62642404729ee5917331188e45e Merge: b5ff3b4f ca54462b Author: Povilas Kanapickas Date: 2019-08-10 12:28:50 +0000 Merge branch 'genesys-simplify-gl843-dpi' into 'master' genesys: Simplify GL843 DPI calculation See merge request sane-project/backends!122 commit b5ff3b4f43722cf8cee420d824daa5a979ae1071 Merge: 608680f8 ae525fb9 Author: Povilas Kanapickas Date: 2019-08-10 12:23:20 +0000 Merge branch 'genesys-cleanup-motors' into 'master' genesys: Cleanup motor definitions See merge request sane-project/backends!121 commit ae525fb91b69e8956298d9a3b0cc59667f5464b2 Author: Povilas Kanapickas Date: 2019-08-10 15:10:31 +0300 genesys: Remove trailing whitespace commit 608680f8b80fc7b8f684beeac6568da3673be47e Merge: 7d6897ec b85a83f6 Author: Povilas Kanapickas Date: 2019-08-10 12:10:27 +0000 Merge branch 'genesys-remove-optical-flags' into 'master' genesys: Remove optical flags See merge request sane-project/backends!120 commit 7d6897ecb4bd23e90bf106aa0d8f945a2157cce3 Merge: 6bf49297 e5a90e80 Author: Povilas Kanapickas Date: 2019-08-10 11:55:49 +0000 Merge branch 'genesys-fix-search-reference-point' into 'master' genesys: Fix search reference point to update all sensors See merge request sane-project/backends!118 commit 6bf49297c21538462323efef2d27c2d68475e1f9 Merge: 8897f787 e733f669 Author: Povilas Kanapickas Date: 2019-08-10 11:55:03 +0000 Merge branch 'genesys-cleanup' into 'master' genesys: Miscellaneous cleanups and refactors See merge request sane-project/backends!119 commit fcd537e2077eea1c8e00a1875a7fed56852bfb9b Author: Olaf Meeuwissen Date: 2019-08-10 20:49:09 +0900 sm3600: Fix [-Wimplicit-fallthrough] warning This fixes the warning for both #define SM3600_SUPPORT_EXPOSURE values. commit 8897f787535bca06de3c9d40cbd07639dba05f06 Merge: a18ec0fa cafb97d2 Author: Povilas Kanapickas Date: 2019-08-10 11:40:53 +0000 Merge branch 'genesys-session-settings' into 'master' genesys: Use session struct to pass data to the setup functions See merge request sane-project/backends!117 commit a18ec0faac2c1cf7fe26d780dacaeb116b87e806 Merge: 0df7e1ab 38b97f14 Author: Povilas Kanapickas Date: 2019-08-10 11:19:29 +0000 Merge branch 'genesys-session-settings' into 'master' genesys: Session settings refactor See merge request sane-project/backends!116 commit 0df7e1ab5021e5e79ee22d90443dc220763bf0ce Merge: 6ef28885 408469d9 Author: Olaf Meeuwissen Date: 2019-08-10 07:08:56 +0000 Merge branch 'patch-1' into 'master' Update hp3900_rts8822.c See merge request sane-project/backends!92 commit 6ef288855ed5e0068902ce9cb2772b8ed6a32158 Merge: 1267a9a5 d2653efb Author: Olaf Meeuwissen Date: 2019-08-10 06:06:38 +0000 Merge branch 'sanei-usb-capture-debug-msg' into 'master' sanei_usb: Add a way to record debug messages to USB captures See merge request sane-project/backends!93 commit 1267a9a5cc09c424cc2f1f95c7d5ffb7a33a8785 Merge: a2085a97 df580b94 Author: Rolf Bensch Date: 2019-08-09 20:18:55 +0200 Merge remote-tracking branch 'origin/master' commit a2085a973ff1fcdf5e0a3021eb819710d331c9a5 Author: Rolf Bensch Date: 2019-08-09 20:16:59 +0200 po/de.po: add/fix some German translations commit 97dd074595622948e456a9d8f20fb8457bd39b19 Author: Rolf Bensch Date: 2019-08-09 20:11:05 +0200 po/de.po: recreate German translations file commit 453b48180d22012b65fa9712be47d24c3e75cf93 Author: Rolf Bensch Date: 2019-08-09 19:51:18 +0200 pixma: Canon PIXMA TS6200 Series is working (#109) commit df580b9480eaacf02348742df064ab22daebf100 Merge: 90852605 cdb14d9f Author: Povilas Kanapickas Date: 2019-08-09 11:10:43 +0000 Merge branch 'genesys-simplify-register-set-access' into 'master' genesys: Simplify register set access See merge request sane-project/backends!115 commit 9085260541c288e765af7183ab2abf3826e66a6a Merge: 041389e5 598aa997 Author: Povilas Kanapickas Date: 2019-08-09 10:51:06 +0000 Merge branch 'genesys-remove-half-ccd' into 'master' genesys: Improve code clarity by retiring half_ccd See merge request sane-project/backends!114 commit 041389e57f748ce6e38f11c2db836e3cc12b7f0c Merge: 03595193 16c55bf3 Author: Povilas Kanapickas Date: 2019-08-09 10:46:36 +0000 Merge branch 'genesys-cleanup-cmd-set' into 'master' genesys: Cleanup cmd_set implementation See merge request sane-project/backends!113 commit 035951933b19472f0f548afed4cd8df113db847b Merge: a3e492d6 f9a9d3f8 Author: Povilas Kanapickas Date: 2019-08-09 10:28:10 +0000 Merge branch 'genesys-physical-register-state' into 'master' genesys: Cache physical register state See merge request sane-project/backends!111 commit a3e492d6d59a75e869d8f35122a2d1044d4dc579 Merge: ccd40d39 f9b87de4 Author: Povilas Kanapickas Date: 2019-08-09 10:23:15 +0000 Merge branch 'genesys-remove-manual-alloc' into 'master' genesys: Remove manual allocations See merge request sane-project/backends!112 commit ccd40d3969806c67b973a7e7466c76690de395c0 Merge: 5bd9ab49 fc9159b4 Author: Povilas Kanapickas Date: 2019-08-09 10:15:53 +0000 Merge branch 'genesys-improve-readability-model-struct' into 'master' genesys: Improve readability of model struct setup See merge request sane-project/backends!110 commit 5bd9ab4941f749047944e2748f9c711cf047b17d Merge: 239147d4 49b94dc0 Author: Povilas Kanapickas Date: 2019-08-09 09:57:02 +0000 Merge branch 'genesys-split-genesys-low' into 'master' genesys: Split genesys_low.h into several files See merge request sane-project/backends!109 commit 239147d4c71ae2d39798172e2752318bf9c228bf Merge: c4468f99 3c663555 Author: Povilas Kanapickas Date: 2019-08-09 08:45:38 +0000 Merge branch 'genesys-cleanup' into 'master' genesys: Cleanups See merge request sane-project/backends!106 commit c4468f998acedb2ebf6b80aa37171435c15ce1c5 Merge: ebac8aee faa078cd Author: Povilas Kanapickas Date: 2019-08-09 08:26:52 +0000 Merge branch 'genesys-return-errors-as-exceptions' into 'master' genesys: Return errors as exceptions instead of error codes See merge request sane-project/backends!105 commit ebac8aee75bc231a9b6975562e1208100ba86fcd Merge: 15360230 c6dacdf0 Author: Povilas Kanapickas Date: 2019-08-09 07:51:05 +0000 Merge branch 'genesys-return-errors-as-exceptions' into 'master' genesys: Return errors as exceptions instead of error codes See merge request sane-project/backends!104 commit 153602308cd87e99b19c8f2b339c633daa95e4c6 Merge: b30567c2 bd6afe37 Author: Povilas Kanapickas Date: 2019-08-09 07:33:28 +0000 Merge branch 'genesys-refactor-model-list' into 'master' genesys: Refactor model list See merge request sane-project/backends!103 commit b30567c271a4fb3a1f6855fb356f11bec9a7e833 Merge: 326b2a04 847a3a6e Author: Povilas Kanapickas Date: 2019-08-09 07:12:47 +0000 Merge branch 'genesys-canoscan-8400f-infrared' into 'master' genesys: Add infrared channel support for CanoScan 8400F See merge request sane-project/backends!102 commit 326b2a04f7c1d5d6bf3d06540e096039bcf3e2c2 Merge: 7d1617e4 57d8eb56 Author: Povilas Kanapickas Date: 2019-08-09 06:53:42 +0000 Merge branch 'genesys-return-errors-as-exceptions' into 'master' genesys: Return errors as exceptions instead of error codes See merge request sane-project/backends!101 commit 57d8eb565ffbaacb5e23d8b02d659775f21e8650 Author: Povilas Kanapickas Date: 2019-08-09 09:40:54 +0300 genesys: Add missing dependencies to the unit tests commit 7d1617e4c067704704b5b828fc192a534ee09d1d Merge: 9a8eb90d 5c32aefd Author: Povilas Kanapickas Date: 2019-08-08 20:09:54 +0000 Merge branch 'genesys-canoscan-8400f' into 'master' genesys: Implement regular and transparency scans for Canon CanoScan 8400F See merge request sane-project/backends!100 commit 9a8eb90dc3694d259a82853fa82be368457f59ed Merge: 820ff529 6d6dbd81 Author: Povilas Kanapickas Date: 2019-08-08 19:51:06 +0000 Merge branch 'genesys-canoscan-8600f-infrared' into 'master' genesys: Add infrared support to Canon CanoScan 8600F See merge request sane-project/backends!99 commit 820ff5293acaafe1ca218c7943d6cdc2a9c258be Merge: 45646240 ac6ccfc1 Author: Povilas Kanapickas Date: 2019-08-08 18:51:09 +0000 Merge branch 'genesys-repark-before-setting-shading-regs' into 'master' genesys: Repark before regs are setup in white_shading_calibration() See merge request sane-project/backends!98 commit 45646240bf4322702d0f270e44b33f684734ef77 Merge: 8d3369f6 af0f8e7e Author: Povilas Kanapickas Date: 2019-08-08 18:33:41 +0000 Merge branch 'genesys-fix-gl843-gain-calibration' into 'master' genesys: Improve gain calibration on GL843 See merge request sane-project/backends!97 commit 8d3369f68ecf171c8a4e6dc319b8b5d501206dc5 Merge: 1491a106 74854a85 Author: Povilas Kanapickas Date: 2019-08-08 18:13:30 +0000 Merge branch 'genesys-reinit-regs-before-shading' into 'master' genesys: Reinit registers before each shading calibration step See merge request sane-project/backends!96 commit d2653efbd9dbe8b8f6611c10209864eeb5c5be58 Author: Povilas Kanapickas Date: 2019-08-08 20:51:24 +0300 sanei_usb: Add a way to record debug messages to USB captures commit 1491a1067e6cdf39d0088ed788fabf66b2216a75 Merge: 0fc4eb80 aa6bdba7 Author: Povilas Kanapickas Date: 2019-08-08 17:49:06 +0000 Merge branch 'genesys-usb-capture-debug-msg' into 'master' genesys: Add a way to record debug messages to USB captures See merge request sane-project/backends!95 commit aa6bdba74d07fa140c60cd354d8cab6faa086edb Author: Povilas Kanapickas Date: 2019-06-28 18:18:28 +0300 genesys: Add a way to record debug messages to USB captures commit 0fc4eb80e3665af8aecedcdab2cd5110325f52cf Merge: eae96342 34d37834 Author: Povilas Kanapickas Date: 2019-08-08 16:51:43 +0000 Merge branch 'genesys-cleanup' into 'master' genesys: Various cleanups See merge request sane-project/backends!94 commit eae96342d838347479565e8870e0686dca5be2a3 Merge: 1be824f2 fdc23d12 Author: Ralph Little Date: 2019-08-08 16:44:19 +0000 Merge branch 'text_corrections' into 'master' Some fixes to US messages in source. See merge request sane-project/backends!91 commit 408469d94e67725fb3f9a87f4e1a5527fdca49bf Author: Cor Date: 2019-08-08 14:58:09 +0000 Update hp3900_rts8822.c After increase the timeout from 10 to 60 seconds, the hp3970 can scan black and white 35mm films using the parameters Gray, 16 bit and 2400 dpi. More information in https://gitlab.com/sane-project/backends/issues/77 commit 1be824f2c5bdf81998dc875cd43c28ce617fc871 Merge: 953ed4c2 f8f90f8b Author: Olaf Meeuwissen Date: 2019-08-08 14:01:30 +0000 Merge branch 'sanei-usb-testing-mode' into 'master' sanei: Support capture and replay of USB data for testing See merge request sane-project/backends!55 commit 953ed4c2b0b2927516382927e1cb1f8f8863ba8d Author: Olaf Meeuwissen Date: 2019-08-08 21:41:22 +0900 mustek_usb2: Fix sprintf invocation. Fixes #110 commit 6fdbc95bf3386492f0787e730a2404c222ab08ba Author: Olaf Meeuwissen Date: 2019-08-06 22:36:57 +0900 CI: Fix broken dependency after job renames commit 2874d215146924b2cf8aab279c770a41c1aeae76 Author: Olaf Meeuwissen Date: 2019-08-06 21:42:08 +0900 CI: Rename stages and jobs for clarity It drops the common `compile:` prefix because the web UI ellipsizes job names. This leads to names that are hard to tell apart when the prefix is applied. The archive stage has been renamed to snapshot to differentiate it more from the release stage. The prepare moniker did not clearly describe the stage's intent and has been renamed to tarball. The job names for these stages now reflect the `make` invocations used in an attempt to be more descriptive. commit fdc23d129ab2746ba19b2c2d405b8d9965cd53cb Author: Ralph Little Date: 2019-08-05 20:54:18 -0700 1) Correct some spelling mistakes 2) Convert some British spellings to US 3) Modified some longer sentences to improve readability. 4) Modified en_GB to suit commit 6912400cf48ab027dd17569003d9385fd161a5f0 Author: Povilas Kanapickas Date: 2019-08-04 18:21:08 +0300 genesys: Move motor profile tables to a single file commit aa4ee9c49e7e603c283ca48d41e75f979550c470 Author: Povilas Kanapickas Date: 2019-08-04 18:21:07 +0300 genesys: Split genesys_devices.cc file to separate files for each table commit 6592692448f8b4f35e2eb8fc9d6e31375a6a4ae3 Author: Povilas Kanapickas Date: 2019-08-04 18:21:06 +0300 genesys: Compile genesys_devices.cc as a separate translation unit commit 8cb6130cfe7d08a4c8bea6d6d8cb528aa1039c44 Author: Povilas Kanapickas Date: 2019-08-04 14:01:50 +0300 genesys: Cleanup the gpo setup commit ca54462bd287cbf8b48d04e703cddac18f8ffc37 Author: Povilas Kanapickas Date: 2019-08-04 13:17:52 +0300 genesys: Simplify shading upload on gl843 commit 2df86f551f128248550485ec26dbe07f6fdb64dc Author: Povilas Kanapickas Date: 2019-08-04 13:17:51 +0300 genesys: Fix incorrect dpi computation for G4050 commit d365637dfc7687313c39375d4140462875e95ce9 Author: Povilas Kanapickas Date: 2019-08-04 13:17:50 +0300 genesys: Simplify optical regs setup on gl843 commit 3e09ba18fa4e7e5c7818faeb6e85b9a354548d5f Author: Povilas Kanapickas Date: 2019-08-04 13:17:49 +0300 genesys: Move pixel coordinate calculation to gl843_compute_session() commit 6a0f17cecca0536c5689aafaaee46bf658b2d5b0 Author: Povilas Kanapickas Date: 2019-08-04 13:17:48 +0300 genesys: Raise an exception if input resolution is out of bounds commit 1c61d3692a236d3d86903c1d6f00ca72e004d3b6 Author: Povilas Kanapickas Date: 2019-08-04 12:01:52 +0300 genesys: Rewrap extremely long lines in motor step definitions commit ea602f7ebc38d84858d18727621af91d6748b667 Author: Povilas Kanapickas Date: 2019-08-04 12:01:51 +0300 genesys: Rewrite and document sanei_genesys_calculate_zmod() commit 6f20e6d341c67fe394c860de716d2771f97e81ca Author: Povilas Kanapickas Date: 2019-08-04 12:01:50 +0300 genesys: Use std::vector for the motor slope tables commit 510e8123f3826938cfe3fdda68d4eef0a9519976 Author: Povilas Kanapickas Date: 2019-08-04 12:01:49 +0300 genesys: Remove support for multiple motor power modes commit 239eab6ea661654fc7134684b8c8bb07b2478fc6 Author: Povilas Kanapickas Date: 2019-08-04 12:01:48 +0300 genesys: Simplify motor setup to make it easier to expand commit b85a83f6af03b5300a1808cef0b68330c70f1d9a Author: Povilas Kanapickas Date: 2019-08-04 10:52:58 +0300 genesys: Remove no longer used optical flags variables commit 306b160f00661f488337b906e5a83eda67f6eeaa Author: Povilas Kanapickas Date: 2019-08-04 10:52:57 +0300 genesys: Pass OPTICAL_FLAG_DISABLE_SHADING flag via session commit 86d4828ece1db3e42cef876c344bd7d5b91cd010 Author: Povilas Kanapickas Date: 2019-08-04 10:52:56 +0300 genesys: Pass OPTICAL_FLAG_DISABLE_GAMMA flag via session commit d503701fb754c9d152866440f7382aa6f9fd650e Author: Povilas Kanapickas Date: 2019-08-04 10:52:55 +0300 genesys: Pass OPTICAL_FLAG_USE_XPA flag via session commit 773170af094193209992739a07c9f220f25a4290 Author: Povilas Kanapickas Date: 2019-08-04 10:52:54 +0300 genesys: Pass OPTICAL_FLAG_DISABLE_LAMP flag via session commit 8618a49182ea59bd6d25e282f877437d5d3d7f63 Author: Povilas Kanapickas Date: 2019-08-04 10:52:53 +0300 genesys: Pass OPTICAL_FLAG_STAGGER flag via session commit a4b551be0c07f26b54c1cda8c631f920dcc9eac9 Author: Povilas Kanapickas Date: 2019-08-04 10:52:52 +0300 genesys: Pass OPTICAL_FLAG_ENABLE_LEDADD flag via session commit e5a90e8005375577fc795f3f71c111e2467c70a8 Author: Povilas Kanapickas Date: 2019-08-04 02:48:29 +0300 genesys: Update all sensors when searching for reference point commit 91b20fb268e649249ce062cbca7afc835874a5d0 Author: Povilas Kanapickas Date: 2019-08-04 02:48:28 +0300 genesys: Make sanei_genesys_search_reference_point() non-destructive commit d0dbfa6ec33c04e3f1973b478ce912966411deb3 Author: Povilas Kanapickas Date: 2019-08-04 02:48:27 +0300 genesys: Print traces of more data commit 824f922e49de40fe4bb4cac263732c6ad09c0ac9 Author: Povilas Kanapickas Date: 2019-08-04 02:48:26 +0300 genesys: Don't do additional scans in case of debug commit e733f669601f0ae2184680107e46ec70b3b19d02 Author: Povilas Kanapickas Date: 2019-08-04 01:11:08 +0300 genesys: Add a way to customize per-sensor divisor management commit ea78c00882a1db9322062d4efa271d5ecaedebff Author: Povilas Kanapickas Date: 2019-08-04 01:11:07 +0300 genesys: Fix duplicate hwdpi conversion on gl124 commit 1ba4018a6e71090d5d92c8ba30f0987442b0056d Author: Povilas Kanapickas Date: 2019-08-04 01:11:06 +0300 genesys: Pass session directly to gl843_init_optical_regs_scan() commit cafb97d2935a58d86976cbd7c73d57c1849cc2ff Author: Povilas Kanapickas Date: 2019-08-03 22:42:20 +0300 genesys: Use session struct to pass data to the setup functions commit 598aa99778fc178fd6dd62f8aa42deca31f0cb66 Author: Povilas Kanapickas Date: 2019-08-03 01:31:07 +0300 genesys: Improve code clarity by retiring half_ccd commit 16c55bf330f80db64f886cd5bc9ceda588e00ba0 Author: Povilas Kanapickas Date: 2019-08-02 22:39:05 +0300 genesys: Init cmd_set directly instead of going through a function commit a58b20d2c8663ae75356663b68a1734936f4d0dd Author: Povilas Kanapickas Date: 2019-08-02 22:39:04 +0300 genesys: Move cmd_set from model to device struct commit f9a9d3f84a45d58b2e4d94901ff74c1b0597787c Author: Povilas Kanapickas Date: 2019-08-02 22:39:01 +0300 genesys: Cache physical register state in the device on writes commit faab7b02e0ee513834d35e313f7186245b2584a1 Author: Povilas Kanapickas Date: 2019-08-02 22:39:00 +0300 genesys: Cache physical register state in the device on bulk writes commit 7836ea5778cbaba908a6cdb27014e723fdce8e6c Author: Povilas Kanapickas Date: 2019-08-02 22:38:59 +0300 genesys: Remove bulk_write_register from the cmd_set structures commit 60146456640985f46c8319f8acdc2f535f66e9cb Author: Povilas Kanapickas Date: 2019-08-02 22:38:58 +0300 genesys: Cache physical register state in the device on reads commit f9b87de44a6ab4ae74c10be6eb242798a2b88fc3 Author: Povilas Kanapickas Date: 2019-08-02 22:38:54 +0300 genesys: Remove manual allocations from calibration functions commit 6b2919db9a14d6b7ddffb7fe504060a3eec9df65 Author: Povilas Kanapickas Date: 2019-08-02 22:38:53 +0300 genesys: Remove manual allocations in device class commit fc9159b4075ca16ae41090f55ca785757762b65b Author: Povilas Kanapickas Date: 2019-08-02 22:36:12 +0300 genesys: Improve readability of model struct setup commit 49b94dc09e1dd2c9af99e85d88a0a5dacd1b9f2a Author: Povilas Kanapickas Date: 2019-08-02 22:35:16 +0300 genesys: Split genesys_low.h into several files commit 3c6635559f3221b6c839532ceeb18121a76002a0 Author: Povilas Kanapickas Date: 2019-08-02 22:31:58 +0300 genesys: Remove unused code commit 13b2d09a42e22e35993cad5e170310d0b81c07ea Author: Povilas Kanapickas Date: 2019-08-02 22:31:57 +0300 genesys: Fix printing of errors on exceptions commit 025ec317e32dba0b269a5f5e9dea0e056b6d40b1 Author: Povilas Kanapickas Date: 2019-08-02 22:31:56 +0300 genesys: Move logical and register dpi computation to sensor struct commit f18ef0e282f1a5437adce032b735f47b00f91168 Author: Caleb Xu Date: 2019-08-01 23:51:20 -0400 ricoh2_buffer: fix malloc header location on macOS commit 90684c53bb646e6db98b4547cde9aeb2d41cf602 Author: Olaf Meeuwissen Date: 2019-08-01 21:14:08 +0900 doc: Remove :new markers in external backend descriptions External backends are per definition not new sane-backends. Removing the commented out info makes for fewer false hits when searching. commit 85674f12138882ef34f493749cb1731b07f26b9e Author: Olaf Meeuwissen Date: 2019-08-01 21:13:33 +0900 doc: Update as per post-release instructions commit 9a16b62e33ac55ecc5c4fdfd9f17f407541ab6ab Author: Olaf Meeuwissen Date: 2019-08-01 21:13:19 +0900 doc: Update post-release instructions This reflects the post-release changes that have been taken care of and are still considered somewhat meaningful. MD5 checksums have been replaced by SHA512 and SHA256 checksum files on the Releases page. The descriptions.db was used by the no longer existant Search Engine on the website. commit faa078cd213a2c27f43a4c52599b65302d1f49f2 Author: Povilas Kanapickas Date: 2019-07-27 10:12:36 +0300 genesys: Return errors as exceptions from remaining functions commit c0360248108e39604a0a0378a62b60e1a5641869 Author: Povilas Kanapickas Date: 2019-07-27 10:12:35 +0300 genesys: Return errors as exceptions from genesys_buffer_image() commit 748acbbb818919ed78b7084c5a287e5fef108442 Author: Povilas Kanapickas Date: 2019-07-27 10:12:34 +0300 genesys: Simplify code by removing uses of RIE() macro commit c6bbc5f7739711100ed6ec3a4a861c14af8fd2ff Author: Povilas Kanapickas Date: 2019-07-27 10:12:33 +0300 genesys: Return errors as exceptions from genesys_read_ordered_data() commit 1c030da1c29963ad815db4c4a5e2ea6e28092af1 Author: Povilas Kanapickas Date: 2019-07-27 10:12:32 +0300 genesys: Return errors as exceptions from image manipulation functions commit 39e5daa7b452b422b5135e7016ea6582fc1950f2 Author: Povilas Kanapickas Date: 2019-07-27 10:12:31 +0300 genesys: Remove unused code commit db2bb793d4a25aa900117d82bb15c9ac2a97b4f0 Author: Povilas Kanapickas Date: 2019-07-27 10:12:30 +0300 genesys: Remove obsolete comments commit 107019c5de73d3efc7f23285b4ce3dd2ca32d3bb Author: Povilas Kanapickas Date: 2019-07-27 10:12:29 +0300 genesys: Return errors as exceptions from init_options() commit 1fd16cd16bd61b2d578cb4ccbcaee6b5517e8406 Author: Povilas Kanapickas Date: 2019-07-27 10:12:28 +0300 genesys: Return errors as exceptions from calc_parameters() commit 10947b94f115ccb0016408ba4a28bd2a534d56f2 Author: Povilas Kanapickas Date: 2019-07-27 10:12:27 +0300 genesys: Return errors as exceptions from pixel format conv functions commit f727f1a01ba2d2e630c4f1c878290f712667ec81 Author: Povilas Kanapickas Date: 2019-07-27 10:12:26 +0300 genesys: Return errors as exceptions from genesys_fill_read_buffer() commit a6855efb575e6fb40413d6f36c9c33413f48ac05 Author: Povilas Kanapickas Date: 2019-07-27 10:12:25 +0300 genesys: Return errors as exceptions from genesys_fill_segmented_buffer() commit a18ef2e17ffd0963b12e10caa8f64d70ddb89ef9 Author: Povilas Kanapickas Date: 2019-07-27 10:12:24 +0300 genesys: Return errors as exceptions from genesys_fill_line_interp_buffer() commit 38b97f1402e9def3ce0536e187cb439661781e53 Author: Povilas Kanapickas Date: 2019-07-27 05:12:31 +0300 genesys: Include full session description into the device struct commit f4401d501fb28da8045bfa6b3b2d42ff89cf56bd Author: Povilas Kanapickas Date: 2019-07-27 05:12:30 +0300 genesys: Make asic type an enum commit e34814aef85d11fe09d0fd86745fc1717d86d9ae Author: Povilas Kanapickas Date: 2019-07-27 05:12:29 +0300 genesys: Remove duplicate fields out of settings struct commit 808cc5737d4abe5d229cf31c767f7f25fd15a7d1 Author: Povilas Kanapickas Date: 2019-07-27 05:12:28 +0300 genesys: Move ScanSession to genesys_settings.h commit d0ed3795f625e39f56f2d4ad2e316fe911a62805 Author: Povilas Kanapickas Date: 2019-07-27 05:12:27 +0300 genesys: Remove unused code commit cdb14d9fef9e2f9137c9be6cb210649b516a2760 Author: Povilas Kanapickas Date: 2019-07-21 18:41:50 +0300 genesys: Remove uses of sanei_genesys_set_reg_from_set() commit 36714a781044f431f078fc269ad21a41f2a0b643 Author: Povilas Kanapickas Date: 2019-07-21 18:41:49 +0300 genesys: Remove uses of sanei_genesys_read_reg_from_set() commit e6dbfd64a352e8d7702d73f5be3e1a4465a4b871 Author: Povilas Kanapickas Date: 2019-07-21 18:41:48 +0300 genesys: Remove uses of sanei_genesys_set_triple() commit 08c98e13b2c59bf192f122a8714363bd6a4a2be6 Author: Povilas Kanapickas Date: 2019-07-21 18:41:47 +0300 genesys: Remove uses of sanei_genesys_set_double() commit 98546ecff05239ab1c864b246092312d499e09e0 Author: Povilas Kanapickas Date: 2019-07-21 18:41:46 +0300 genesys: Remove uses of sanei_genesys_get_triple() commit fa9fcc31a13cc0400cacb5c5cbf01683af6c98da Author: Povilas Kanapickas Date: 2019-07-21 18:41:45 +0300 genesys: Remove uses of sanei_genesys_get_double() commit 847a3a6e7c8e85bd26f7d3bb67699c6877788910 Author: Povilas Kanapickas Date: 2019-07-20 21:17:31 +0300 genesys: Fix 8400F 2400 dpi scans commit b29bb66a36481bc906b2ad09403102f08b177a49 Author: Povilas Kanapickas Date: 2019-07-20 21:17:30 +0300 genesys: Add support for infrared scanning on 8400F commit ce713f95c0470e1afb20148e1c886310bcc09eb4 Author: Povilas Kanapickas Date: 2019-07-20 21:17:29 +0300 genesys: Refactor XPA lamp setup function to be more extensible commit c6dacdf0149063057dc9446abd9393155d86df4b Author: Povilas Kanapickas Date: 2019-07-20 11:02:41 +0300 genesys: Return errors as exceptions from accurate_line_read() commit 53450b681051b5c71746af5d4bfeb53f7c25d5df Author: Povilas Kanapickas Date: 2019-07-20 11:02:40 +0300 genesys: Return errors as exceptions from genesys_start_scan() commit 1ad6aca5018dd8c5f204f6db9bafd5ceef701095 Author: Povilas Kanapickas Date: 2019-07-20 11:02:39 +0300 genesys: Return errors as exceptions from genesys_load_lut() commit 7c70d30f63e62f23c69845e2c2a1354bc041c831 Author: Povilas Kanapickas Date: 2019-07-20 11:02:38 +0300 genesys: Return errors as exceptions from genesys_*_calibration() commit b41ad140ad64c878342edb07136b5b6ff88534bf Author: Povilas Kanapickas Date: 2019-07-20 11:02:37 +0300 genesys: Return errors as exceptions from *genesys_warmup_lamp() commit fa07b4806c08af6f2dfbb5a45bdf4d9fc868b532 Author: Povilas Kanapickas Date: 2019-07-20 11:02:36 +0300 genesys: Return errors as exceptions from genesys_save_calibration() commit e3d4b8fb9138c7c08ad6fade46c79330f0fb399a Author: Povilas Kanapickas Date: 2019-07-20 11:02:35 +0300 genesys: Return errors as exceptions from genesys_send_shading_coefficient() commit 82afcfae2d9e6fd76b904cf06f84ac6f2001a27e Author: Povilas Kanapickas Date: 2019-07-20 11:02:34 +0300 genesys: Return errors as exceptions from genesys_*_shading_calibration() commit edb442afe8b9f2890295c70e772b078b5113b0ae Author: Povilas Kanapickas Date: 2019-07-20 11:02:33 +0300 genesys: Return errors as exceptions from genesys_dummy_dark_shading() commit cd87e4e6626a33feacaa45cdd389a78301a83539 Author: Povilas Kanapickas Date: 2019-07-20 11:02:32 +0300 genesys: Return errors as exceptions from genesys_average_white() commit 05a9a0837458cf62e38626381b70d1b811344d14 Author: Povilas Kanapickas Date: 2019-07-20 11:02:31 +0300 genesys: Return errors as exceptions from *rewind() commit 579df0d0b75c6519982e19466aa1e55069bf4648 Author: Povilas Kanapickas Date: 2019-07-20 11:02:30 +0300 genesys: Return errors as exceptions from *move_to_ta() commit 92d1817c2454a528c2f5b714f7b0d3193d51f838 Author: Povilas Kanapickas Date: 2019-07-20 11:02:29 +0300 genesys: Return errors as exceptions from *search_strip() commit 4247ced84ae6a3315a9c24a4b19e97de71d2ec3b Author: Povilas Kanapickas Date: 2019-07-20 11:02:28 +0300 genesys: Return errors as exceptions from *detect_document_end() commit 3862f53f24c06988a0be6b60931053b761279085 Author: Povilas Kanapickas Date: 2019-07-20 11:02:27 +0300 genesys: Return errors as exceptions from *load_document() commit 24625dcc2ca173728f89b037d19c8e4393da6c75 Author: Povilas Kanapickas Date: 2019-07-20 11:02:26 +0300 genesys: Return errors as exceptions from *update_hardware_sensors() commit 0db604d4dd2113639eb9a2a82cfc63bbfc6f05fc Author: Povilas Kanapickas Date: 2019-07-20 11:02:25 +0300 genesys: Return errors as exceptions from *led_calibration() commit dd29e02457bbaf5b10b539d866fb8a318e8f0ab3 Author: Povilas Kanapickas Date: 2019-07-20 11:02:24 +0300 genesys: Return errors as exceptions from *coarse_gain_calibration() commit faea78eae6ea9b1f491e5e327117754dfb5c0351 Author: Povilas Kanapickas Date: 2019-07-20 11:02:23 +0300 genesys: Return errors as exceptions from *offset_calibration() commit 1eaa88963285026bb7b3be57efeac4688b4acee1 Author: Povilas Kanapickas Date: 2019-07-20 11:02:22 +0300 genesys: Return errors as exceptions from *search_start_position() commit d46d5cd0277dcc3be13bde79c2fededca2bf9a6f Author: Povilas Kanapickas Date: 2019-07-20 11:02:21 +0300 genesys: Return errors as exceptions from *init_regs_for_scan() commit 8837f8adcc55d65bd093c560851a553d8d53c087 Author: Povilas Kanapickas Date: 2019-07-20 11:02:20 +0300 genesys: Return errors as exceptions from *init_regs_for_shading() commit 61f74af2498081206cef56733a71a71686d2441e Author: Povilas Kanapickas Date: 2019-07-20 11:02:19 +0300 genesys: Return errors as exceptions from *init_regs_for_warmup() commit 75144683328632702bfd6d0cb63a4a6b22e870b0 Author: Povilas Kanapickas Date: 2019-07-20 11:02:18 +0300 genesys: Return errors as exceptions from *coarse_calibration() commit 88e7268bbe0525388bad97b3d350d65d2d029195 Author: Povilas Kanapickas Date: 2019-07-20 11:02:17 +0300 genesys: Return errors as exceptions from *for_coarse_calibration() commit 7019901aa57ca630fd0ac09f29275a802e1eae97 Author: Povilas Kanapickas Date: 2019-07-20 11:02:16 +0300 genesys: Return errors as exceptions from *simple_scan() commit 94abc7f964d1b97ce7bfd2d26cdea8da099d91c4 Author: Povilas Kanapickas Date: 2019-07-20 11:02:15 +0300 genesys: Return errors as exceptions from *read_data_from_scanner() commit 867d907bb9fed29cee3408ae5d4b8ed4c66ad0dc Author: Povilas Kanapickas Date: 2019-07-20 11:02:14 +0300 genesys: Return errors as exceptions from *init() commit 67f187bceb609d3981299edcb7f4ae5023bd91f6 Author: Povilas Kanapickas Date: 2019-07-20 11:02:13 +0300 genesys: Return errors as exceptions from *end_scan() commit eaeb05ead5ab691f2a40e4f682442487814506d7 Author: Povilas Kanapickas Date: 2019-07-20 11:02:12 +0300 genesys: Return errors as exceptions from *search_reference_point() commit 196e0824549b84c9c1a186050987e49c39077bca Author: Povilas Kanapickas Date: 2019-07-20 11:02:11 +0300 genesys: Return errors as exceptions from *write_file() commit 241a4ea913c5796506c807b3f469c1eb919c2f61 Author: Povilas Kanapickas Date: 2019-07-20 11:02:10 +0300 genesys: Return errors as exceptions from *write_pnm_file() commit a6cbb980699e385168f954d665bdce1d41c054cf Author: Povilas Kanapickas Date: 2019-07-20 11:02:09 +0300 genesys: Return errors as exceptions from *eject_document() commit 0bc253de07abc3e2348b16dcd1a105e4648dfd4c Author: Povilas Kanapickas Date: 2019-07-20 11:02:08 +0300 genesys: Return errors as exceptions from *start_motor() commit 3477b827ee178f22098da4b8a9389f2119eae091 Author: Povilas Kanapickas Date: 2019-07-20 11:02:07 +0300 genesys: Return errors as exceptions from *get_paper_sensor() commit 5d2d8e9509f5459fba74fca0409ac7738a4c25b3 Author: Povilas Kanapickas Date: 2019-07-20 11:02:06 +0300 genesys: Return errors as exceptions from *send_gamma_table() commit e614c9e102629bcf34547eee2082dcfbd384adf6 Author: Povilas Kanapickas Date: 2019-07-20 11:02:05 +0300 genesys: Return errors as exceptions from *repark_head() commit d8d1638fdedec78832cb926bce56ea1614843a64 Author: Povilas Kanapickas Date: 2019-07-20 11:02:04 +0300 genesys: Return errors as exceptions from *asic_test() commit a0aa335d90cb74fcfbf4c9817f5219d2cb0a7901 Author: Povilas Kanapickas Date: 2019-07-20 11:02:03 +0300 genesys: Return errors as exceptions from *set_powersaving() commit fd12b4052f9933247288474ea3f3f5d5016740e3 Author: Povilas Kanapickas Date: 2019-07-20 11:02:02 +0300 genesys: Return errors as exceptions from *save_power() commit d75aa89c9f12502cf30402da84a72c495db0be27 Author: Povilas Kanapickas Date: 2019-07-20 11:02:01 +0300 genesys: Return errors as exceptions from *slow_back_home() commit 075d733613bbe0ee4ba82f5267d5367dcb241eea Author: Povilas Kanapickas Date: 2019-07-20 11:02:00 +0300 genesys: Return errors as exceptions from *feed() commit 104ad9b44877563718d93023ef2e42b418d623af Author: Povilas Kanapickas Date: 2019-07-20 11:01:59 +0300 genesys: Return errors as exceptions from setup_for_scan() commit 32a3faa3b56635fe54b24b452bc604c0e69e0ab8 Author: Povilas Kanapickas Date: 2019-07-20 11:01:58 +0300 genesys: Return errors as exceptions from *setup_registers() and deps commit 06367877202dfff9a1f92302c9c3c04febe5b8f4 Author: Povilas Kanapickas Date: 2019-07-20 11:01:57 +0300 genesys: Return errors as exceptions from *stop_motor() commit e5e9b5dc0d5797fb1e387e8dd3eeb8d942a06a83 Author: Povilas Kanapickas Date: 2019-07-20 11:01:56 +0300 genesys: Return errors as exceptions from *begin_scan() commit 02efbdee43054a02c21ebf2640486ab04fcb3166 Author: Povilas Kanapickas Date: 2019-07-20 11:01:55 +0300 genesys: Return errors as exceptions from *xpa_motor_power() commit 8a3b5a88a5ee356fb95402ac5c6f69656c6c9c80 Author: Povilas Kanapickas Date: 2019-07-20 11:01:54 +0300 genesys: Return errors as exceptions from *stop_action() commit fa6e4ab4c3961e4377091aa99bda80ca672bb319 Author: Povilas Kanapickas Date: 2019-07-20 11:01:53 +0300 genesys: Return errors as exceptions from *setup_scan_gpio() commit 86a151a4f2c021c3d0433f060f89e04a1b733591 Author: Povilas Kanapickas Date: 2019-07-20 11:01:52 +0300 genesys: Return errors as exceptions from *boot() and friends commit 67ecc10b81030d6d95addd5ad58fff8972d29b1c Author: Povilas Kanapickas Date: 2019-07-20 11:01:51 +0300 genesys: Return errors as exceptions from *init_gpio() commit 8e9253e301458fd299c9ba77b1976edeea391211 Author: Povilas Kanapickas Date: 2019-07-20 11:01:50 +0300 genesys: Return errors as exceptions from *genesys_init_shading_data() commit 24775d6e0eb398a3f02f781c09882d2ae57f6830 Author: Povilas Kanapickas Date: 2019-07-20 11:01:49 +0300 genesys: Return errors as exceptions from *homsnr_gpio() commit 08a1ae562543c842b8fafe2df43690e2a80af9c1 Author: Povilas Kanapickas Date: 2019-07-20 11:01:48 +0300 genesys: Return errors as exceptions from *start_action() commit c843e3e83db31f0d42f48f21b9c46b4e689ee95f Author: Povilas Kanapickas Date: 2019-07-20 11:01:47 +0300 genesys: Return errors as exceptions from *init_scan_regs() commit bd6afe373684672d3e50503b8e40726f86fa6325 Author: Povilas Kanapickas Date: 2019-07-20 09:16:36 +0300 genesys: Store available DPI into proper array commit bca1ab1d99ac48138881f7dc3c57abebd9d4012f Author: Povilas Kanapickas Date: 2019-07-20 09:16:35 +0300 genesys: Store available resolutions into proper array commit 341061f3df51a0c2339aea1112b026c6832cfdd2 Author: Povilas Kanapickas Date: 2019-07-20 09:16:34 +0300 genesys: Correctly initialize Genesys_Model commit 7d4e7efa4ef9c9e2b36bddd2c5cf948a94814f73 Author: Povilas Kanapickas Date: 2019-07-20 09:16:33 +0300 genesys: Initialize usb device list in a function commit 5c32aefd0f4d79a43b4f20bc23dc80a7416a7612 Author: Povilas Kanapickas Date: 2019-07-20 03:11:24 +0300 genesys: Implement transparency scanning support for 8400F commit ab2952d1df2acd1935d8db451984621e05ee7017 Author: Povilas Kanapickas Date: 2019-07-20 03:11:23 +0300 genesys: Add support for regular scans on CanoScan 8400F commit 0c1dded259055a5136556875d982fd2bf0da5c50 Author: Povilas Kanapickas Date: 2019-07-20 03:11:22 +0300 genesys: Enable support for CanoScan 8400F commit c19ab1fce57481b061e1b829bf4461d4cea4fef2 Author: Povilas Kanapickas Date: 2019-07-14 23:41:05 +0300 genesys: Return errors as exceptions from *init_motor_regs_scan() commit 9c9a118e12fcc9986d73824ccca40f917b924c78 Author: Povilas Kanapickas Date: 2019-07-14 23:41:04 +0300 genesys: Return errors as exceptions from *send_slope_table() commit 7d9f4d2c58e2d94521e7e6901572b4e2a2f164f3 Author: Povilas Kanapickas Date: 2019-07-14 23:41:03 +0300 genesys: Return errors as exceptions from *init_optical_regs_scan() commit 876b7bba4e19f33a775a91a5f0b63d8710167cba Author: Povilas Kanapickas Date: 2019-07-14 23:41:02 +0300 genesys: Return errors as exceptions from *set_fe() commit ce06801d5537cdfef728438d22841a6cca266cf9 Author: Povilas Kanapickas Date: 2019-07-14 23:41:01 +0300 genesys: Support variadic format string in SaneException commit 290f71d6c1f9e1579efcac6a9dfe9e7494bf6ae7 Author: Povilas Kanapickas Date: 2019-07-14 23:41:00 +0300 genesys: Move SaneException implementation to source file commit f258158ff3ab84d127170dd7873d46b4c8a3978d Author: Povilas Kanapickas Date: 2019-07-14 23:40:59 +0300 genesys: Return errors as exceptions from *send_offset_and_shading() commit 2f6052046fdbb908381f4118a1538197b8a981f9 Author: Povilas Kanapickas Date: 2019-07-14 23:40:58 +0300 genesys: Return errors as exceptions from gl843_set_buffer_address() commit 4303877059c1f05f5493faf43012c4f3088e7fea Author: Povilas Kanapickas Date: 2019-07-14 23:40:57 +0300 genesys: Return errors as exceptions from *init_cmd_set() commit d29f6862c63d401dff116103498c6546021b3e22 Author: Povilas Kanapickas Date: 2019-07-14 23:40:56 +0300 genesys: Return errors as exceptions from *wait_for_home() commit 2a9764b4fd50ca3ea15f206c6587efc6c98e5aae Author: Povilas Kanapickas Date: 2019-07-14 23:40:55 +0300 genesys: Return errors as exceptions from *send_shading_data() commit 99b5f1e94e355e2cb0ae626f203a49ca957a90c1 Author: Povilas Kanapickas Date: 2019-07-14 23:40:54 +0300 genesys: Return errors as exceptions from *gamma_buffer() commit e78cfa750feab63b4796392c3087196e4da0b5dc Author: Povilas Kanapickas Date: 2019-07-14 23:40:53 +0300 genesys: Return errors as exceptions from *fe_read_data() commit ad231613db7ad1e0cd183ebb04aebe504ed6fba2 Author: Povilas Kanapickas Date: 2019-07-14 23:40:52 +0300 genesys: Return errors as exceptions from *read_feed_steps() commit 612ff9487c9ab72e722892236c5d726ded07b977 Author: Povilas Kanapickas Date: 2019-07-14 23:40:51 +0300 genesys: Return errors as exceptions from *fe_write_data() commit 32a2eeaa5f163afd3e25c0c29c62acfb0befd1da Author: Povilas Kanapickas Date: 2019-07-14 23:40:50 +0300 genesys: Return errors as exceptions from *write_ahb() commit 693d42c0250d1e7d43ded9e7eb141bef5d808cee Author: Povilas Kanapickas Date: 2019-07-14 23:40:49 +0300 genesys: Return errors as exceptions from *read_valid_words() commit 478ddd5d01853a135830c36284e577447a9621a6 Author: Povilas Kanapickas Date: 2019-07-14 23:40:48 +0300 genesys: Return errors as exceptions from *read_scancnt() commit 5c0a382bc9cde7f1d409d020db9563df6b8fa76a Author: Povilas Kanapickas Date: 2019-07-14 23:40:47 +0300 genesys: Return errors as exceptions from *test_buffer_empty() commit f153fb109e82db4ef0821af69cbf7408933e1c8c Author: Povilas Kanapickas Date: 2019-07-14 23:40:46 +0300 genesys: Return errors as exceptions from *get_status() commit e388fc505884819a5168495c05b9c05706b6dd98 Author: Povilas Kanapickas Date: 2019-07-14 23:40:45 +0300 genesys: Return errors as exceptions from *bulk_write_register() commit 0dc3342be12be1c99660b4a8f608397faa98736e Author: Povilas Kanapickas Date: 2019-07-14 23:40:44 +0300 genesys: Return errors as exceptions from *bulk_write_data() commit 1c5960f9aa568c167fc68e7a10d9d1f8b9d6d180 Author: Povilas Kanapickas Date: 2019-07-14 23:40:43 +0300 genesys: Replace explicit DBG messages with DBG_HELPER commit 3a47a9ed4da8aa5f9c5505d879e9ad4ece02d38d Author: Povilas Kanapickas Date: 2019-07-14 23:40:42 +0300 genesys: Return errors as exceptions from *set_buffer_address() commit 17a619a927b11671d331dc63723d5f9ee6b18a3e Author: Povilas Kanapickas Date: 2019-07-14 23:40:41 +0300 genesys: Return errors as exceptions from *write_register() commit d1cffab8f4500247e3f865c3ce5ea4faec8a3083 Author: Povilas Kanapickas Date: 2019-07-14 23:40:40 +0300 genesys: Return errors as exceptions from *write_gl847_register() commit 3d17645fade5945e5aefa7a73ef9fa9425937e0c Author: Povilas Kanapickas Date: 2019-07-14 23:40:39 +0300 genesys: Return errors as exceptions from *read_register() commit bfef12cc4941f61700fb2e9563bf2d8c6b3253b4 Author: Povilas Kanapickas Date: 2019-07-14 23:40:38 +0300 genesys: Return errors as exceptions from *read_gl847_register() commit 9e15623411b81a345aeac8e12d409190bdac48d2 Author: Povilas Kanapickas Date: 2019-07-14 23:40:37 +0300 genesys: Return errors as exceptions from *write_0x8c() commit 1e5a7bd4d88d830a59d748272df575adda0ea035 Author: Povilas Kanapickas Date: 2019-07-14 23:40:36 +0300 genesys: Return errors as exceptions from *write_hregister() commit f856a3dacfff8eefc9468b4b73c12020d7aa55b7 Author: Povilas Kanapickas Date: 2019-07-14 23:40:35 +0300 genesys: Return errors as exceptions from *read_hregister() commit a79f1404f3bd504ad51a5dc4b24a2287ff6ee668 Author: Povilas Kanapickas Date: 2019-07-14 23:40:34 +0300 genesys: Return errors as exceptions from *bulk_read_data() commit 6d6dbd81d32d1754208512c09d6bdeb9fc6c8fda Author: Povilas Kanapickas Date: 2019-07-13 04:14:47 +0300 genesys: Improve documentation of Genesys_Model struct commit 644314bdad83cc0213c88b899343e2f9f3da35a5 Author: Povilas Kanapickas Date: 2019-07-13 04:14:46 +0300 genesys: Put 0x72/0x73 registers to sensor definition on GL843 commit 1a5e3944b3ae64ab4d95d189a978d2ceb999f17f Author: Povilas Kanapickas Date: 2019-07-13 04:14:45 +0300 genesys: Add option to get a raw scan ignoring offsets commit 144ed1f29b5d6869d40dc495edb5fda813a0de4c Author: Povilas Kanapickas Date: 2019-07-13 04:14:44 +0300 genesys: Implement infrared channel support for 8600F commit 78cdb347bea6e0fbfacd10a73537c6d680a99258 Author: Povilas Kanapickas Date: 2019-07-13 04:14:43 +0300 genesys: Fix lperiod on transparency scans on 8600F commit 3137639aca481b8a3257c0e78d07c8469b4b602f Author: Povilas Kanapickas Date: 2019-07-13 04:14:42 +0300 genesys: Make scan method explicit when selecting sensor commit c96a34f4a8b65f3390fac427124fffca619328df Author: Povilas Kanapickas Date: 2019-07-13 04:14:41 +0300 genesys: Fix partial width during calibration support commit 7e2a1eed97d2cf77830d282acc522a878c2a7b2f Author: Povilas Kanapickas Date: 2019-07-13 04:14:40 +0300 genesys: Fix alignment of lamp and sensor during of transparency scan The calibration area does not necessarily need to be at the zero position. We may need to drive sensor to the lamp and then drive both to the calibration. commit 7d32dca50e2f7ae3c9b5d795dae3c938e7a93b7e Author: Povilas Kanapickas Date: 2019-07-13 04:14:39 +0300 genesys: Sync GPIO with window driver on transparency scans on 8600F commit 0db759d996c1bd6f05e867a687f4de30f7055c19 Author: Povilas Kanapickas Date: 2019-07-13 04:14:38 +0300 genesys: Don't enable buggy behavior on newly supported scanners commit 34d378347c93976f37e985f273b1f37a863c51bd Author: Povilas Kanapickas Date: 2019-07-06 21:02:28 +0300 genesys: Remove unused register read commit 8c9d6d7208ab7f88f479411153cf33add777cae1 Author: Povilas Kanapickas Date: 2019-07-06 21:02:27 +0300 genesys: Read the value of CKSEL from the sensor definition directly commit 1a641316b0921abdc6882f9df7b5692968d6a406 Author: Povilas Kanapickas Date: 2019-07-06 21:02:26 +0300 genesys: Remove duplicate entry of Canon 5600F in config file commit f84f1b9d4252cc0686c45c824478f9f977cf3fc8 Author: Povilas Kanapickas Date: 2019-07-06 21:02:25 +0300 genesys: Sort the initial register map by register on GL843 commit a6a09f5dc5941a67ea0809064c7086846432cc1c Author: Povilas Kanapickas Date: 2019-07-06 21:02:24 +0300 genesys: Don't reuse non-applicable macro just because its value matches commit f4d5fd4ad6520ac4d54cbf8dd1f9bcdde1680867 Author: Povilas Kanapickas Date: 2019-07-06 21:02:23 +0300 genesys: Add a way to dump Genesys_Register_Set to debug commit ac6ccfc1844f7212ed6bb274874046e16edcae81 Author: Povilas Kanapickas Date: 2019-07-02 23:30:53 +0300 genesys: Repark before regs are setup in white_shading_calibration() Reparking after registers have been setup is very brittle approach, as it must preserve everything intact. commit af0f8e7e460ef61571ef347ec7242a6c61643b98 Author: Povilas Kanapickas Date: 2019-07-02 23:30:50 +0300 genesys: Improve gain calibration on GL843 commit 74854a85aab4d5c35e9570fcfc1c86544cd174a1 Author: Povilas Kanapickas Date: 2019-07-02 23:30:48 +0300 genesys: Reinit registers for shading again before white shading commit a5c5ea56ada665769f4819a59953ceae0820666d Author: Povilas Kanapickas Date: 2019-07-02 23:30:47 +0300 genesys: Add debug markers to data captured during calibration commit f8f90f8b98c29c6a823b14a71be411b3efd63bda Author: Povilas Kanapickas Date: 2019-06-30 22:31:14 +0300 configure: Make --with-usb-record-replay opt-in rather than opt-out commit baa4eb30483c59e0b34c045a1476562286ffa25b Author: Povilas Kanapickas Date: 2019-06-30 22:18:11 +0300 testsuite: Add missing libs to `make check` programs commit 3dde8f28f094f8440050c773720312383ea73933 Author: Povilas Kanapickas Date: 2019-06-30 11:58:33 +0300 niash: Fix an implicit fallthrough bug in handling of threshold option commit e40596c2a59e188a0a44f44877aa91e41a5698aa Author: Povilas Kanapickas Date: 2019-06-30 11:58:32 +0300 Fix -Wimplicit-fallthrough warnings by adding standard annotations commit 599bfe519c4d3e835e9825ea9ceb9d0360d0166a Author: Povilas Kanapickas Date: 2019-06-16 21:12:42 +0300 sanei_usb: Fix build when USB replay-record mode is disabled commit f3df7b9db14eeaae3915fb96d25877e1f61ff897 Author: Povilas Kanapickas Date: 2019-06-16 21:12:41 +0300 genesys: Don't sleep during tests commit 4edfb7a287635c28fde1201f57e183efbf1b89b9 Author: Povilas Kanapickas Date: 2019-04-29 23:18:38 +0300 sanei_usb: Add function to check whether we are using fake data commit fd6adf2a46e8776ea0f133481bb7f14e3a1277d8 Author: Povilas Kanapickas Date: 2019-05-09 00:38:45 +0300 sanei_usb: Don't crash when recording failed reads commit b30406873c81ebd922f805747a58aa4ffdce2ed5 Author: Povilas Kanapickas Date: 2019-04-27 12:16:13 +0300 sanei_usb: Add support for record testing mode commit 7de8efd395375f84629a8d8c980009f5292841da Author: Povilas Kanapickas Date: 2019-04-27 12:16:12 +0300 sanei_usb: Add support for "development mode" replay testing commit 21ed18b230bd542055a4f3c8e7271777f71b893f Author: Povilas Kanapickas Date: 2019-04-27 12:16:11 +0300 dll: Report when testing backend is unknown commit 0122c060b7dad349584cbe11a1cc348a92f65bc1 Author: Povilas Kanapickas Date: 2019-04-27 12:16:10 +0300 sanei_usb: Add support for replay testing commit a88b6241cd7fc849619d81063663a5e609dfe951 Author: Povilas Kanapickas Date: 2019-05-25 09:12:30 +0300 configure: Add option to enable USB record-replay ---------------------------------------------------------------------- Older ChangeLog entries can be found in the ChangeLogs/ directory on a file per release basis. Please note that version 1.0.26 was skipped. sane-backends-1.0.29/README.unixware70000666000000000000000000000540113615534521014011 00000000000000SANE on UnixWare 7 ================== The easiest way to get SANE working on a UnixWare 7.1.X system (UW 7.0.0 and 7.0.1 are not supported) is to download and install the SANE binary distribution from SCOs Skunkware web site. The URL is: ftp://ftp.sco.com/skunkware/uw7/Packages Use the pkgadd command to install the files, e.g.: # pkgadd -d `pwd`/sane-1.0.2.pkg A web page with further information specific to SANE on UnixWare 7 can be found here: http://www.sco.com/skunkware/sane/index.html However, please note that the SANE package that is available from the Skunkware server will most likely contain the latest stable version of SANE. Since SANE is continously being worked on, you might want to download the latest source from the Git repository and build the source yourself. To build SANE on a UnixWare 7.1.X system the following packages are required: * make (GNU make) * glibs (contains gtk, glib, libjpeg, libpnm, libtiff etc.; only necessary for frontends xscanimage, xcam, and xsane which are distributed separately) The packages can be downloaded from the Skunkware ftp server (see URL above). I've used the following versions to build sane-1.0.2: * make-3.78.1.pkg * glibs-2.0.3.pkg If you want to include support for The Gimp (this is optional), you need to install the gimp package, too. This is the version I've used: * gimp-1.0.4.pkg GCC is not required. SANE compiles quite happily (and faster) with UnixWares native C compiler. Set the LD_RUN_PATH variable to add /usr/local/lib to the list of directories to be searched by the dynamic linker: $ LD_RUN_PATH=/usr/local/lib $ export LD_RUN_PATH Run the configure script as following: $ LIBS="-lsdi" ./configure (The sdi library contains the SCSI passthrough functions the UW7 port of SANE uses to access the scanner from user space.) Run gmake to build SANE: $ gmake SCSI access from user space requires special privileges. If you want users without root perms to be able to use the scanner you can use the filepriv command to change the privileges that are associated with the SANE applications: # /sbin/filepriv -f driver -f sysops /usr/local/bin/scanimage # /sbin/filepriv -f driver -f sysops /usr/local/bin/xscanimage # /sbin/filepriv -f sysops /usr/local/bin/xcam If you have built SANE with support for The Gimp you might want to create a symlink from the plug-in directory to the xscanimage and xcam binaries, e.g.: # ln -s /usr/local/bin/xscanimage \ /usr/local/lib/gimp/1.0/plug-ins/xscanimage # ln -s /usr/local/bin/xcam /usr/local/lib/gimp/1.0/plug-ins/xcam Questions? Comments? Please send e-mail to jenss@sco.com or skunkware@sco.com! sane-backends-1.0.29/README.unixware20000666000000000000000000000753113615534521014012 00000000000000UNIXWARE PORT of SANE - HOWTO build and what you need to run You need a sane SCSI driver to run SANE on Unixware 2.x. There is at least one such driver: the sane driver by R=I+S. The Unixware sane driver is a binary loadable module driver for UW2.x. Please send Email to wolfgang@rapp-informatik.de to receive. What you need to build xane on Unixware 2.x - gnu make You dont't need gcc. All is build with the standard Unixware cc and libs!! For the X-frontends xscanimage and xsane (separately distributed) you need libs like libgtk libgimp and the image libs for jpeg, tiff and png. It is also good to have gettext with libintl installed. Most of the libs are available on the Skunkware CD's from SCO in pkgadd format. If you build the frontends with this libs gimp plugin is also supported by xscanimage and xsane. Latest xsane version tested was 0.48. With the following configure should run an build shared libs with libtool 1.3.4 LD_RUN_PATH=/usr/local/lib CPPFLAGS="-I/usr/local/include -I/isr/X/include" CFLAGS="-I/usr/local/include -I/usr/X/include -I/usr/ucbinclude -L/usr/local/lib -L/usr/ucblib -l ucb" LIBS="-lsocket -lnsl -lgen -I/opt/include -L/usr/ucblib -lucb" ./configure After running configure you have to edit the generated file libtool Append to the line archive_cmds="\$LD -G -o \$lib \$libobjs \$deplibs \$linkopts so that it looks like this. archive_cmds="\$LD -G -o \$lib \$libobjs \$deplibs \$linkopts -B bind_now -L/usr/local/lib -lintl -L/usr/ucblib -lucb -lm" This is a must to link the libucb.a , libintl.a in when the sane libs are build.It's also necessary for mathematic lib -lm . Not doing this will bring runtime errors like missimg usleep or pow function. ATTENTION:!!! libucb.a of Unixware 2.x has a buggy readdir function so it is recommanded to remove readdir.o from libucb.a with ar -d readdir.o libucb.a Often used and neded functions from libucb.a are strncasecmp or getpagesize. If you use -I/usr/ucbinclude it is also a good idea to move /usr/ucbinlcude/unistd.h to another file, because it will be included first and some sources will not compile. Then you can run make with GNU make. After this say su and then ist good to say LD_RUN_PATH=/usr/local/lib export LD_RUN_PATH after this you can install with make install Tested on Unixware 2.0.x with Umax Astra 1220S and HP C5100A with sane-1.0.1. With Microtek backend earlier on sane-0.74. If you use the net backend you do not need the Unixware sanedrv. The driver is a shareware product. The driver is supplied binary in pkgadd(1m) format and is tested from UW2.0x. Please send Email to wolfgang@rapp-informatik.de to get the driver in binary pkgadd package. To install it on a Unixware do: cd /tmp get sanedrv.pkg.tgz gunzip sanedrv.pkg.tgz tar xvf sanedrv.pkg.tar as root: pkgadd -d /tmp/sanedrv Once the driver is installed, there should be a device nodes /dev/sane and /dev/scanner /dev/scanner1 for the second, and so on...) The scanner my be connected to any SCSI controller in the system, also if you have additional devices like disks or cdroms on the same controller. The UW2.x sane driver do not block the controller. The scanner must be switched on to be recognized by UW, if the low level driver p.e. adsl is loaded. To configure an UMAX scanner, configuration file /usr/local/etc/sane.d/umax.conf might contain: /dev/scanner The driver is configured to recognice all scsi scanners with ID SCANNER and all HP Scsi scanners with ID Processor and Inquiry string starting with "HP" string. For details have a look to /etc/conf/pack.d/sane/space.c. If you change this then you must unload the sane driver modadmin -U sane, build the new module by /etc/conf/bin/idbuild -M sane and the install the driver with modadmin -l sane. If you have questions or problems with the Unixware support in SANE, send mail to: wolfgang@rapp-informatik.de sane-backends-1.0.29/config.sub0000755000000000000000000010645013615534556013176 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2018 Free Software Foundation, Inc. timestamp='2018-02-22' # This file 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; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo "$1" exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo "$1" | sed 's/-[^-]*$//'` if [ "$basic_machine" != "$1" ] then os=`echo "$1" | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | wasm32 \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-pc os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2*) basic_machine=m68k-bull os=-sysv3 ;; e500v[12]) basic_machine=powerpc-unknown os=$os"spe" ;; e500v[12]-*) basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=$os"spe" ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; nsv-tandem) basic_machine=nsv-tandem ;; nsx-tandem) basic_machine=nsx-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh5el) basic_machine=sh5le-unknown ;; simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; x64) basic_machine=x86_64-pc ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases that might get confused # with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # es1800 is here to avoid being matched by es* (a different OS) -es1800*) os=-ose ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ | -midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -xray | -os68k* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo "$os" | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4*) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -pikeos*) # Until real need of OS specific support for # particular features comes up, bare metal # configurations are quite functional. case $basic_machine in arm*) os=-eabi ;; *) os=-elf ;; esac ;; -nacl*) ;; -ios) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; pru-*) os=-elf ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac echo "$basic_machine$os" exit # Local variables: # eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: sane-backends-1.0.29/README.zeta0000666000000000000000000000144013615534521013022 00000000000000SANE and Zeta ------------- The Zeta port is based on existing BeOS port, with some changes to accomodate yellowTAB's internal build procedure, and some new conventions brought up by Zeta. Cf. README.beos for more historical stuff. SANE 1.0.9 was updated for Zeta by Ithamar Adema for yellowTAB. SANE 1.0.15 was updated for BeOS and Zeta by François Revol for yellowTAB. Zeta uses a modified version of Philippe Houdoin's Sanity GUI frontend. http://philippe.houdoin.free.fr/phil/beos/sanity/index-en.html SANE was reported to work with the following configuration and features: Platform: Zeta R1 (== BeOS R6.x) ix86 Latest SANE version tested: 1.0.15 Compiler: gcc 2.95.3 User-level SCSI support: yes USB support: yes Shared library support: yes Dynamic loading support: yes X11 clients: no sane-backends-1.0.29/.editorconfig0000666000000000000000000000067013615534521013661 00000000000000# .editorconfig -- settings for consistent coding style conventions # Copyright (C) 2017 Olaf Meeuwissen # # License: GPL-3.0+ # Your editor may need a plugin for this configuration to take effect. # See http://editorconfig.org/#download for details. root = true ; look no further [*] charset = utf-8 insert_final_newline = true trim_trailing_whitespace = true [backend/escl/*] indent_size = 4 indent_style = space sane-backends-1.0.29/depcomp0000755000000000000000000005602013615534557012566 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2018-03-07.03; # UTC # Copyright (C) 1999-2018 Free Software Foundation, Inc. # 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; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: sane-backends-1.0.29/Makefile.am0000666000000000000000000001112213615534521013232 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2009 Chris Bagwell and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. SUBDIRS = include lib sanei backend frontend tools doc po testsuite DIST_SUBDIRS = include lib sanei backend frontend tools doc po japi testsuite dist_doc_DATA = AUTHORS COPYING LICENSE NEWS PROBLEMS PROJECTS \ README README.aix README.beos README.darwin README.djpeg README.freebsd \ README.hp-ux README.linux README.netbsd README.openbsd README.os2 \ README.solaris README.unixware2 README.unixware7 README.windows \ README.zeta dist_doc_DATA += ChangeLog changelogsdir = $(docdir)/ChangeLogs dist_changelogs_DATA = ChangeLogs/ChangeLog-1.0.28 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.27 ## sane-backends-1.0.26 was skipped dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.25 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.24 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.23 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.22 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.21 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.20 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.19 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.18 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.17 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.16 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.15 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.14 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.13 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.12 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.11 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.10 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.9 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.8 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.7 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.6 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.5 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.4 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.3 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.2 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.1 dist_changelogs_DATA += ChangeLogs/ChangeLog-1.0.0 EXTRA_DIST = .editorconfig EXTRA_DIST += po/README # # Keep the .gitignore files sorted, and use this target to do it. # Note that git's negated ignore patterns introduce order dependency # and should therefor be sorted with much more care than we do here. # Until that has been taken care of, such files are best left alone. # PERL=perl sort-gitignore: for f in `find . -name .gitignore`; do \ if test -n "`sed -n '/^\!/p' $$f`"; then \ echo "$$f: skipping file with negated pattern" >&2; \ fi; \ $(PERL) -e 'print sort <>;' < $$f > $$f.tmptmp; \ mv $$f.tmptmp $$f; \ done # # Check to make sure only sane_ and sanei_ symbols are exported from # the libraries # libcheck: @echo "Libraries exporting 'illegal' symbols:" @for lib in backend/.libs/*.so backend/.libs/*.a; do \ lines=`nm -g $$lib|grep '\( T \)\|\( D \)'|egrep -v ' _fini| _init'|egrep -v ' sane_| sanei_'`; \ if test -n "$$lines" ; then \ echo -e "*** $$lib:\n$$lines"; \ found_errors="yes"; \ fi \ done; \ echo; \ echo "Libraries exporting 'non-standard sane_*' symbols:"; \ for lib in backend/.libs/*.so backend/.libs/*.a; do \ lines=`nm -g $$lib|grep '\( T \)\|\( D \)'|egrep ' sane_' | egrep -v 'sane_.*init|sane_.*exit|sane_.*get_devices|sane_.*open|sane_.*close|sane_.*get_option_descriptor|sane_.*control_option|sane_.*get_parameters|sane_.*start|sane_.*read|sane_.*cancel|sane_.*set_io_mode|sane_.*get_select_fd|sane_strstatus'` ; \ if test -n "$$lines" ; then \ echo -e "*** $$lib:\n$$lines"; \ found_errors="yes"; \ fi \ done; if test ! -z $$found_errors ; then \ exit 1; \ fi # Verify that backends do not contain any unwanted public symbols # anytime check or distcheck is ran. # TODO: Currently this doesn't pass. Uncomment once symbols have # been cleaned up. #check-am: libcheck # Run testsuite any time installcheck or distcheck is ran. # Must run testsuite after install or else shared library backends # will not be found (including test backend). installcheck-local: cd testsuite && $(MAKE) test.local md5: dist md5sum $(distdir).tar.gz > $(distdir).tar.gz.md5 sane-backends: md5 # Clean files created by custom targets in this file. clean-local: rm -f $(distdir).tar.gz.md5 # Clean files created by configure distclean-local: rm -f include/_stdint.h rm -f include/byteorder.h ACLOCAL_AMFLAGS = -I m4 # Make potential issues stick out when running `make distcheck`. DISTCHECK_CONFIGURE_FLAGS = --enable-silent-rules sane-backends-1.0.29/testsuite/0000755000000000000000000000000013615535555013316 500000000000000sane-backends-1.0.29/testsuite/Makefile.am0000666000000000000000000000274513615534521015276 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2009 Chris Bagwell and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. SUBDIRS = backend sanei tools SCANIMAGE = ../frontend/scanimage$(EXEEXT) TESTFILE = $(srcdir)/testfile.pnm OUTFILE = outfile.pnm DEVICE = test OPTIONS = --mode Color --depth 16 --test-picture "Color pattern" --resolution 50 -y 20 -x 20 > $(OUTFILE) EXTRA_DIST = README testfile.pnm CLEANFILES = $(OUTFILE) all: help help: @echo "Use 'make test' to run the tests." test: test.local test.local: @echo "**** Testing $(SCANIMAGE) with device $(DEVICE)" @if echo "---> Trying flatbed scanner" && \ $(SCANIMAGE) -d $(DEVICE) -T && \ echo "<--- Flatbed scanner succeeded" && \ echo "---> Trying three pass flatbed scanner" && \ $(SCANIMAGE) -d $(DEVICE) --mode Color --three-pass=yes -T && \ echo "<--- Three pass scanner succeeded" && \ echo "---> Trying hand scanner" && \ $(SCANIMAGE) -d $(DEVICE) --hand-scanner=yes -T && \ echo "<--- Hand scanner succeeded" && \ echo "---> Checking 16 bit color mode" && \ $(SCANIMAGE) -d $(DEVICE) $(OPTIONS) && \ cmp -s $(TESTFILE) $(OUTFILE) && \ echo "<--- 16 bit color mode succeeded" && \ rm $(OUTFILE) ; \ then echo ; echo ; echo "**** All tests passed" ; \ else echo ; echo; \ echo "**** Something failed (maybe test backend not enabled by configure?)";\ exit 1; \ fi sane-backends-1.0.29/testsuite/testfile.pnm0000666000000000000000000002171113615534521015567 00000000000000P6 # SANE data follows 39 39 65535 UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU  !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU                           ! " UUUUUUUUUUUUUUUUUUUUUUUU                           ! " UUUUUUUUUUUUUUUUUUUUUUUU                           ! " UUUUUUUUUUUUUUUUUUUUUUUU                           ! " UUUUUUUUUUUUUUUUUUUUUUUU                           ! " UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU      !"UUUUUUUUUUUUUUUUUUUUUUUU                           ! " UUUUUUUUUUUUUUUUUUUUUUUU!!!!!!!!! ! ! ! ! !!!!!!!!!!!!!!!!!!! !!!"!UUUUUUUUUUUUUUUUUUUUUUUU""""""""" " " " " """"""""""""""""""" "!"""sane-backends-1.0.29/testsuite/backend/0000755000000000000000000000000013615535555014705 500000000000000sane-backends-1.0.29/testsuite/backend/genesys/0000755000000000000000000000000013615535555016362 500000000000000sane-backends-1.0.29/testsuite/backend/genesys/tests.cpp0000666000000000000000000000221413615534521020143 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define DEBUG_DECLARE_ONLY #include "tests.h" #include "minigtest.h" int main() { genesys::test_calibration_parsing(); genesys::test_image(); genesys::test_image_pipeline(); genesys::test_motor(); genesys::test_row_buffer(); genesys::test_utilities(); return finish_tests(); } sane-backends-1.0.29/testsuite/backend/genesys/Makefile.am0000666000000000000000000000221213615534521020327 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2019 Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. TEST_LDADD = \ ../../../sanei/libsanei.la \ ../../../sanei/sanei_usb.lo \ ../../../sanei/sanei_magic.lo \ ../../../lib/liblib.la \ ../../../backend/libgenesys.la \ ../../../backend/sane_strstatus.lo \ $(MATH_LIB) $(USB_LIBS) $(XML_LIBS) $(PTHREAD_LIBS) check_PROGRAMS = genesys_unit_tests genesys_session_config_tests TESTS = genesys_unit_tests AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include $(USB_CFLAGS) \ -DBACKEND_NAME=genesys -DTESTSUITE_BACKEND_GENESYS_SRCDIR=$(srcdir) genesys_unit_tests_SOURCES = tests.cpp tests.h \ minigtest.cpp minigtest.h tests_printers.h \ tests_calibration.cpp \ tests_image.cpp \ tests_image_pipeline.cpp \ tests_motor.cpp \ tests_row_buffer.cpp \ tests_utilities.cpp genesys_unit_tests_LDADD = $(TEST_LDADD) genesys_session_config_tests_SOURCES = session_config_test.cpp genesys_session_config_tests_LDADD = $(TEST_LDADD) sane-backends-1.0.29/testsuite/backend/genesys/tests_calibration.cpp0000666000000000000000000000720313615534521022515 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define DEBUG_DECLARE_ONLY #include "tests.h" #include "minigtest.h" #include "../../../backend/genesys/low.h" #include namespace genesys { Genesys_Calibration_Cache create_fake_calibration_entry() { Genesys_Calibration_Cache calib; calib.params.channels = 3; calib.params.depth = 8; calib.params.lines = 100; calib.params.pixels = 200; GenesysFrontendLayout wolfson_layout; wolfson_layout.offset_addr = { 0x20, 0x21, 0x22 }; wolfson_layout.gain_addr = { 0x28, 0x29, 0x2a }; Genesys_Frontend fe; fe.id = AdcId::WOLFSON_UMAX; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x05 }, { 0x03, 0x11 }, { ' ', 0x80 }, // check whether space-like integer values are correctly serialized { ',', 0x80 }, { '\r', '\n' }, { '\n', 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x02 }, { 0x29, 0x02 }, { 0x2a, 0x02 }, }; fe.reg2 = {0x00, 0x00, 0x00}; calib.frontend = fe; Genesys_Sensor sensor; sensor.sensor_id = SensorId::CCD_UMAX; sensor.optical_res = 1200; sensor.black_pixels = 48; sensor.dummy_pixel = 64; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10800; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.custom_regs = { { 0x08, 0x01 }, { 0x09, 0x03 }, { 0x0a, 0x05 }, { 0x0b, 0x07 }, { 0x16, 0x33 }, { 0x17, 0x05 }, { 0x18, 0x31 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x13 }, { 0x53, 0x17 }, { 0x54, 0x03 }, { 0x55, 0x07 }, { 0x56, 0x0b }, { 0x57, 0x0f }, { 0x58, 0x23 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 }, }; sensor.gamma = {1.0, 1.0, 1.0}; calib.sensor = sensor; calib.calib_pixels = 12345; calib.calib_channels = 3; calib.average_size = 7; calib.white_average_data = { 8, 7, 6, 5, 4, 3, 2 }; calib.dark_average_data = { 6, 5, 4, 3, 2, 18, 12 }; return calib; } void test_calibration_roundtrip() { Genesys_Device::Calibration calibration = { create_fake_calibration_entry() }; Genesys_Device::Calibration deserialized; std::stringstream str; serialize(static_cast(str), calibration); serialize(static_cast(str), deserialized); ASSERT_TRUE(calibration == deserialized); int x; str >> x; ASSERT_TRUE(str.eof()); } void test_calibration_parsing() { test_calibration_roundtrip(); } } // namespace genesys sane-backends-1.0.29/testsuite/backend/genesys/tests_utilities.cpp0000666000000000000000000000666413615534521022253 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define DEBUG_DECLARE_ONLY #include "tests.h" #include "minigtest.h" #include "tests_printers.h" #include "../../../backend/genesys/utilities.h" namespace genesys { void test_utilities_compute_array_percentile_approx_empty() { std::vector data; data.resize(1, 0); ASSERT_RAISES(compute_array_percentile_approx(data.data(), data.data(), 0, 0, 0.0f), SaneException); } void test_utilities_compute_array_percentile_approx_single_line() { std::vector data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; std::vector expected = data; std::vector result; result.resize(data.size(), 0); compute_array_percentile_approx(result.data(), data.data(), 1, data.size(), 0.5f); ASSERT_EQ(result, expected); } void test_utilities_compute_array_percentile_approx_multiple_lines() { std::vector data = { 5, 17, 4, 14, 3, 9, 9, 5, 10, 1, 6, 1, 0, 18, 8, 5, 11, 11, 15, 12, 6, 8, 7, 3, 2, 15, 5, 12, 3, 3, 6, 12, 17, 6, 7, 7, 1, 6, 3, 18, 10, 5, 8, 0, 14, 3, 3, 7, 10, 5, 18, 7, 3, 11, 0, 14, 12, 19, 18, 11, 5, 16, 2, 9, 8, 2, 7, 6, 11, 18, 16, 5, 2, 2, 14, 18, 19, 13, 16, 1, 5, 9, 14, 6, 17, 16, 1, 1, 16, 0, 19, 18, 4, 12, 0, 7, 15, 3, 2, 6, }; std::vector result; result.resize(10, 0); std::vector expected = { 5, 1, 0, 0, 0, 2, 1, 1, 2, 0, }; compute_array_percentile_approx(result.data(), data.data(), 10, 10, 0.0f); ASSERT_EQ(result, expected); expected = { 5, 5, 2, 3, 2, 5, 3, 5, 3, 1, }; compute_array_percentile_approx(result.data(), data.data(), 10, 10, 0.25f); ASSERT_EQ(result, expected); expected = { 6, 9, 4, 9, 8, 9, 9, 7, 11, 6, }; compute_array_percentile_approx(result.data(), data.data(), 10, 10, 0.5f); ASSERT_EQ(result, expected); expected = { 16, 16, 8, 12, 14, 15, 12, 12, 16, 12, }; compute_array_percentile_approx(result.data(), data.data(), 10, 10, 0.75f); ASSERT_EQ(result, expected); expected = { 19, 18, 17, 18, 17, 18, 19, 19, 18, 18, }; compute_array_percentile_approx(result.data(), data.data(), 10, 10, 1.0f); ASSERT_EQ(result, expected); } void test_utilities() { test_utilities_compute_array_percentile_approx_empty(); test_utilities_compute_array_percentile_approx_single_line(); test_utilities_compute_array_percentile_approx_multiple_lines(); } } // namespace genesys sane-backends-1.0.29/testsuite/backend/genesys/minigtest.h0000666000000000000000000000673113615534521020461 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef SANE_TESTSUITE_BACKEND_GENESYS_MINIGTEST_H #define SANE_TESTSUITE_BACKEND_GENESYS_MINIGTEST_H #include #include extern size_t s_num_successes; extern size_t s_num_failures; inline void print_location(std::ostream& out, const char* function, const char* path, unsigned line) { out << path << ":" << line << " in " << function; } template void check_equal(const T& t, const U& u, const char* function, const char* path, unsigned line) { if (!(t == u)) { s_num_failures++; std::cerr << "FAILURE at "; print_location(std::cerr, function, path, line); std::cerr << " :\n" << t << " != " << u << "\n\n"; } else { s_num_successes++; std::cerr << "SUCCESS at "; print_location(std::cerr, function, path, line); std::cerr << "\n"; } } inline void check_true(bool x, const char* function, const char* path, unsigned line) { if (x) { s_num_successes++; std::cerr << "SUCCESS at "; } else { s_num_failures++; std::cerr << "FAILURE at "; } print_location(std::cerr, function, path, line); std::cerr << "\n"; } inline void check_raises_success(const char* function, const char* path, unsigned line) { s_num_successes++; std::cerr << "SUCCESS at "; print_location(std::cerr, function, path, line); std::cerr << "\n"; } inline void check_raises_did_not_raise(const char* function, const char* path, unsigned line) { s_num_failures++; std::cerr << "FAILURE at "; print_location(std::cerr, function, path, line); std::cerr << " : did not raise exception\n"; } inline void check_raises_raised_unexpected(const char* function, const char* path, unsigned line) { s_num_failures++; std::cerr << "FAILURE at "; print_location(std::cerr, function, path, line); std::cerr << " : unexpected exception raised\n"; } #define ASSERT_EQ(x, y) do { check_equal((x), (y), __func__, __FILE__, __LINE__); } \ while (false) #define ASSERT_TRUE(x) do { check_true(bool(x), __func__, __FILE__, __LINE__); } \ while (false) #define ASSERT_FALSE(x) do { check_true(!bool(x), __func__, __FILE__, __LINE__); } \ while (false) #define ASSERT_RAISES(x, T) \ do { try { \ x; \ check_raises_did_not_raise(__func__, __FILE__, __LINE__); \ } catch (const T&) { \ check_raises_success(__func__, __FILE__, __LINE__); \ } catch (...) { \ check_raises_raised_unexpected(__func__, __FILE__, __LINE__); \ } } while (false) int finish_tests(); #endif sane-backends-1.0.29/testsuite/backend/genesys/tests_motor.cpp0000666000000000000000000003307613615534521021375 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define DEBUG_DECLARE_ONLY #include "tests.h" #include "minigtest.h" #include "tests_printers.h" #include "../../../backend/genesys/low.h" #include "../../../backend/genesys/enums.h" namespace genesys { void test_create_slope_table3() { auto asic_type = AsicType::GL841; auto max_table_size = get_slope_table_max_size(asic_type); Genesys_Motor motor; motor.id = MotorId::CANON_LIDE_200; motor.base_ydpi = 1200; motor.optical_ydpi = 6400; motor.slopes.push_back(MotorSlope::create_from_steps(10000, 1000, 20)); motor.slopes.push_back(MotorSlope::create_from_steps(10000, 1000, 20)); motor.slopes.push_back(MotorSlope::create_from_steps(10000, 1000, 16)); auto table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::FULL, 10000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 10000u); ASSERT_EQ(table.steps_count, 1u); std::vector expected_steps = { 10000, }; expected_steps.resize(max_table_size, 10000); ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::FULL, 2000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 33830u); ASSERT_EQ(table.steps_count, 7u); expected_steps = { 10000, 10000, 4099, 3028, 2511, 2192, 2000 }; expected_steps.resize(max_table_size, 2000); ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::HALF, 10000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 5000u); ASSERT_EQ(table.steps_count, 1u); expected_steps = { 5000, }; expected_steps.resize(max_table_size, 5000); ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::HALF, 2000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 16914u); ASSERT_EQ(table.steps_count, 7u); expected_steps = { 5000, 5000, 2049, 1514, 1255, 1096, 1000 }; expected_steps.resize(max_table_size, 1000); ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::QUARTER, 10000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 2500u); ASSERT_EQ(table.steps_count, 1u); expected_steps = { 2500, }; expected_steps.resize(max_table_size, 2500); ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::QUARTER, 2000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 7680u); ASSERT_EQ(table.steps_count, 6u); expected_steps = { 2500, 2500, 932, 683, 565, 500 }; expected_steps.resize(max_table_size, 500); ASSERT_EQ(table.table, expected_steps); } void test_create_slope_table_small_full_step() { unsigned max_table_size = 1024; // created approximately from LIDE 110 slow table: { 62464, 7896, 2632, 0 } MotorSlope slope; slope.initial_speed_w = 62464; slope.max_speed_w = 2632; slope.acceleration = 1.2e-8; auto table = create_slope_table(slope, 5000, StepType::FULL, 4, 8, max_table_size); std::vector expected_table = { 62464, 62464, 6420, 5000 }; expected_table.resize(max_table_size, 5000); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 8u); ASSERT_EQ(table.pixeltime_sum, 156348u); table = create_slope_table(slope, 3000, StepType::FULL, 4, 8, max_table_size); expected_table = { 62464, 62464, 6420, 4552, 3720, 3223, 3000 }; expected_table.resize(max_table_size, 3000); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 8u); ASSERT_EQ(table.pixeltime_sum, 148843u); } void test_create_slope_table_small_full_step_target_speed_too_high() { unsigned max_table_size = 1024; // created approximately from LIDE 110 slow table: { 62464, 7896, 2632, 0 } MotorSlope slope; slope.initial_speed_w = 62464; slope.max_speed_w = 2632; slope.acceleration = 1.2e-8; auto table = create_slope_table(slope, 2000, StepType::FULL, 4, 8, max_table_size); std::vector expected_table = { 62464, 62464, 6420, 4552, 3720, 3223, 2883, 2632 }; expected_table.resize(max_table_size, 2632); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 8u); ASSERT_EQ(table.pixeltime_sum, 148358u); } void test_create_slope_table_small_half_step() { unsigned max_table_size = 1024; // created approximately from LIDE 110 slow table: { 62464, 7896, 2632, 0 } MotorSlope slope; slope.initial_speed_w = 62464; slope.max_speed_w = 2632; slope.acceleration = 1.2e-8; auto table = create_slope_table(slope, 5000, StepType::HALF, 4, 8, max_table_size); std::vector expected_table = { 31232, 31232, 3210, 2500 }; expected_table.resize(max_table_size, 2500); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 8u); ASSERT_EQ(table.pixeltime_sum, 78174u); table = create_slope_table(slope, 3000, StepType::HALF, 4, 8, max_table_size); expected_table = { 31232, 31232, 3210, 2276, 1860, 1611, 1500 }; expected_table.resize(max_table_size, 1500); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 8u); ASSERT_EQ(table.pixeltime_sum, 74421u); } void test_create_slope_table_large_full_step() { unsigned max_table_size = 1024; /* created approximately from Canon 8600F table: 54612, 54612, 34604, 26280, 21708, 18688, 16564, 14936, 13652, 12616, 11768, 11024, 10400, 9872, 9392, 8960, 8584, 8240, 7940, 7648, 7404, 7160, 6948, 6732, 6544, 6376, 6208, 6056, 5912, 5776, 5644, 5520, 5408, 5292, 5192, 5092, 5000, 4908, 4820, 4736, 4660, 4580, 4508, 4440, 4368, 4304, 4240, 4184, 4124, 4068, 4012, 3960, 3908, 3860, 3808, 3764, 3720, 3676, 3636, 3592, 3552, 3516, 3476, 3440, 3400, 3368, 3332, 3300, 3268, 3236, 3204, 3176, 3148, 3116, 3088, 3060, 3036, 3008, 2984, 2956, 2932, 2908, 2884, 2860, 2836, 2816, 2796, 2772, 2752, 2732, 2708, 2692, 2672, 2652, 2632, 2616, 2596, 2576, 2560, 2544, 2528, 2508, 2492, 2476, 2460, 2444, 2432, 2416, 2400, 2384, 2372, 2356, 2344, 2328, 2316, 2304, 2288, 2276, 2260, 2252, 2236, 2224, 2212, 2200, 2188, 2176, 2164, 2156, 2144, 2132, 2120, 2108, 2100, 2088, 2080, 2068, 2056, 2048, 2036, 2028, 2020, 2008, 2000, 1988, 1980, 1972, 1964, 1952, 1944, 1936, 1928, 1920, 1912, 1900, 1892, 1884, 1876, 1868, 1860, 1856, 1848, 1840, 1832, 1824, 1816, 1808, 1800, 1796, 1788, 1780, 1772, 1764, 1760, 1752, 1744, 1740, 1732, 1724, 1720, 1712, 1708, 1700, 1692, 1688, 1680, 1676, 1668, 1664, 1656, 1652, 1644, 1640, 1636, 1628, 1624, 1616, 1612, 1608, 1600, 1596, 1592, 1584, 1580, 1576, 1568, 1564, 1560, 1556, 1548, 1544, 1540, 1536, 1528, 1524, 1520, 1516, 1512, 1508, 1500, */ MotorSlope slope; slope.initial_speed_w = 54612; slope.max_speed_w = 1500; slope.acceleration = 1.013948e-9; auto table = create_slope_table(slope, 3000, StepType::FULL, 4, 8, max_table_size); std::vector expected_table = { 54612, 54612, 20570, 15090, 12481, 10880, 9770, 8943, 8295, 7771, 7335, 6964, 6645, 6366, 6120, 5900, 5702, 5523, 5359, 5210, 5072, 4945, 4826, 4716, 4613, 4517, 4426, 4341, 4260, 4184, 4111, 4043, 3977, 3915, 3855, 3799, 3744, 3692, 3642, 3594, 3548, 3503, 3461, 3419, 3379, 3341, 3304, 3268, 3233, 3199, 3166, 3135, 3104, 3074, 3045, 3017, 3000, }; expected_table.resize(max_table_size, 3000); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 60u); ASSERT_EQ(table.pixeltime_sum, 412616u); table = create_slope_table(slope, 1500, StepType::FULL, 4, 8, max_table_size); expected_table = { 54612, 54612, 20570, 15090, 12481, 10880, 9770, 8943, 8295, 7771, 7335, 6964, 6645, 6366, 6120, 5900, 5702, 5523, 5359, 5210, 5072, 4945, 4826, 4716, 4613, 4517, 4426, 4341, 4260, 4184, 4111, 4043, 3977, 3915, 3855, 3799, 3744, 3692, 3642, 3594, 3548, 3503, 3461, 3419, 3379, 3341, 3304, 3268, 3233, 3199, 3166, 3135, 3104, 3074, 3045, 3017, 2989, 2963, 2937, 2911, 2886, 2862, 2839, 2816, 2794, 2772, 2750, 2729, 2709, 2689, 2670, 2651, 2632, 2614, 2596, 2578, 2561, 2544, 2527, 2511, 2495, 2480, 2464, 2449, 2435, 2420, 2406, 2392, 2378, 2364, 2351, 2338, 2325, 2313, 2300, 2288, 2276, 2264, 2252, 2241, 2229, 2218, 2207, 2196, 2186, 2175, 2165, 2155, 2145, 2135, 2125, 2115, 2106, 2096, 2087, 2078, 2069, 2060, 2051, 2042, 2034, 2025, 2017, 2009, 2000, 1992, 1984, 1977, 1969, 1961, 1953, 1946, 1938, 1931, 1924, 1917, 1910, 1903, 1896, 1889, 1882, 1875, 1869, 1862, 1855, 1849, 1843, 1836, 1830, 1824, 1818, 1812, 1806, 1800, 1794, 1788, 1782, 1776, 1771, 1765, 1760, 1754, 1749, 1743, 1738, 1733, 1727, 1722, 1717, 1712, 1707, 1702, 1697, 1692, 1687, 1682, 1677, 1673, 1668, 1663, 1659, 1654, 1649, 1645, 1640, 1636, 1631, 1627, 1623, 1618, 1614, 1610, 1606, 1601, 1597, 1593, 1589, 1585, 1581, 1577, 1573, 1569, 1565, 1561, 1557, 1554, 1550, 1546, 1542, 1539, 1535, 1531, 1528, 1524, 1520, 1517, 1513, 1510, 1506, 1503, 1500, }; expected_table.resize(max_table_size, 1500); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 224u); ASSERT_EQ(table.pixeltime_sum, 734910u); } void test_create_slope_table_large_half_step() { unsigned max_table_size = 1024; // created approximately from Canon 8600F table, see the full step test for the data MotorSlope slope; slope.initial_speed_w = 54612; slope.max_speed_w = 1500; slope.acceleration = 1.013948e-9; auto table = create_slope_table(slope, 3000, StepType::HALF, 4, 8, max_table_size); std::vector expected_table = { 27306, 27306, 10285, 7545, 6240, 5440, 4885, 4471, 4147, 3885, 3667, 3482, 3322, 3183, 3060, 2950, 2851, 2761, 2679, 2605, 2536, 2472, 2413, 2358, 2306, 2258, 2213, 2170, 2130, 2092, 2055, 2021, 1988, 1957, 1927, 1899, 1872, 1846, 1821, 1797, 1774, 1751, 1730, 1709, 1689, 1670, 1652, 1634, 1616, 1599, 1583, 1567, 1552, 1537, 1522, 1508, 1500, }; expected_table.resize(max_table_size, 1500); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 60u); ASSERT_EQ(table.pixeltime_sum, 206294u); table = create_slope_table(slope, 1500, StepType::HALF, 4, 8, max_table_size); expected_table = { 27306, 27306, 10285, 7545, 6240, 5440, 4885, 4471, 4147, 3885, 3667, 3482, 3322, 3183, 3060, 2950, 2851, 2761, 2679, 2605, 2536, 2472, 2413, 2358, 2306, 2258, 2213, 2170, 2130, 2092, 2055, 2021, 1988, 1957, 1927, 1899, 1872, 1846, 1821, 1797, 1774, 1751, 1730, 1709, 1689, 1670, 1652, 1634, 1616, 1599, 1583, 1567, 1552, 1537, 1522, 1508, 1494, 1481, 1468, 1455, 1443, 1431, 1419, 1408, 1397, 1386, 1375, 1364, 1354, 1344, 1335, 1325, 1316, 1307, 1298, 1289, 1280, 1272, 1263, 1255, 1247, 1240, 1232, 1224, 1217, 1210, 1203, 1196, 1189, 1182, 1175, 1169, 1162, 1156, 1150, 1144, 1138, 1132, 1126, 1120, 1114, 1109, 1103, 1098, 1093, 1087, 1082, 1077, 1072, 1067, 1062, 1057, 1053, 1048, 1043, 1039, 1034, 1030, 1025, 1021, 1017, 1012, 1008, 1004, 1000, 996, 992, 988, 984, 980, 976, 973, 969, 965, 962, 958, 955, 951, 948, 944, 941, 937, 934, 931, 927, 924, 921, 918, 915, 912, 909, 906, 903, 900, 897, 894, 891, 888, 885, 882, 880, 877, 874, 871, 869, 866, 863, 861, 858, 856, 853, 851, 848, 846, 843, 841, 838, 836, 834, 831, 829, 827, 824, 822, 820, 818, 815, 813, 811, 809, 807, 805, 803, 800, 798, 796, 794, 792, 790, 788, 786, 784, 782, 780, 778, 777, 775, 773, 771, 769, 767, 765, 764, 762, 760, 758, 756, 755, 753, 751, 750, }; expected_table.resize(max_table_size, 750); ASSERT_EQ(table.table, expected_table); ASSERT_EQ(table.steps_count, 224u); ASSERT_EQ(table.pixeltime_sum, 367399u); } void test_motor() { test_create_slope_table3(); test_create_slope_table_small_full_step(); test_create_slope_table_small_full_step_target_speed_too_high(); test_create_slope_table_small_half_step(); test_create_slope_table_large_full_step(); test_create_slope_table_large_half_step(); } } // namespace genesys sane-backends-1.0.29/testsuite/backend/genesys/tests_row_buffer.cpp0000666000000000000000000000476513615534521022400 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define DEBUG_DECLARE_ONLY #include "tests.h" #include "minigtest.h" #include "tests_printers.h" #include "../../../backend/genesys/low.h" #include namespace genesys { void test_row_buffer_push_pop_forward(unsigned size) { RowBuffer buf{1}; ASSERT_TRUE(buf.empty()); for (unsigned i = 0; i < size; i++) { buf.push_back(); *buf.get_back_row_ptr() = i; for (unsigned j = 0; j < i + 1; j++) { ASSERT_EQ(*buf.get_row_ptr(j), j); } } ASSERT_FALSE(buf.empty()); for (unsigned i = 0; i < 10; i++) { ASSERT_EQ(buf.height(), size); ASSERT_EQ(static_cast(*buf.get_front_row_ptr()), i); buf.pop_front(); ASSERT_EQ(buf.height(), size - 1); buf.push_back(); *buf.get_back_row_ptr() = i + size; } } void test_row_buffer_push_pop_backward(unsigned size) { RowBuffer buf{1}; ASSERT_TRUE(buf.empty()); for (unsigned i = 0; i < size; i++) { buf.push_front(); *buf.get_front_row_ptr() = i; for (unsigned j = 0; j < i + 1; j++) { ASSERT_EQ(*buf.get_row_ptr(j), i - j); } } ASSERT_FALSE(buf.empty()); for (unsigned i = 0; i < 10; i++) { ASSERT_EQ(buf.height(), size); ASSERT_EQ(static_cast(*buf.get_back_row_ptr()), i); buf.pop_back(); ASSERT_EQ(buf.height(), size - 1); buf.push_front(); *buf.get_front_row_ptr() = i + size; } } void test_row_buffer() { for (unsigned size = 1; size < 5; ++size) { test_row_buffer_push_pop_forward(size); test_row_buffer_push_pop_backward(size); } } } // namespace genesys sane-backends-1.0.29/testsuite/backend/genesys/tests.h0000666000000000000000000000222713615534521017614 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef SANE_TESTSUITE_BACKEND_GENESYS_GENESYS_UNIT_TEST_H #define SANE_TESTSUITE_BACKEND_GENESYS_GENESYS_UNIT_TEST_H namespace genesys { void test_calibration_parsing(); void test_image(); void test_image_pipeline(); void test_motor(); void test_row_buffer(); void test_utilities(); } // namespace genesys #endif sane-backends-1.0.29/testsuite/backend/genesys/tests_image.cpp0000666000000000000000000006075313615534521021321 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define DEBUG_DECLARE_ONLY #include "tests.h" #include "minigtest.h" #include "tests_printers.h" #include "../../../backend/genesys/image.h" #include "../../../backend/genesys/image_pipeline.h" #include namespace genesys { void test_get_pixel_from_row() { std::vector data = { 0x12, 0x34, 0x56, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x21, 0x43, 0x65, 0x87 }; ASSERT_EQ(get_pixel_from_row(data.data(), 0, PixelFormat::I1), Pixel(0, 0, 0)); ASSERT_EQ(get_pixel_from_row(data.data(), 3, PixelFormat::I1), Pixel(0xffff, 0xffff, 0xffff)); ASSERT_EQ(get_pixel_from_row(data.data(), 0, PixelFormat::RGB111), Pixel(0, 0, 0)); ASSERT_EQ(get_pixel_from_row(data.data(), 1, PixelFormat::RGB111), Pixel(0xffff, 0, 0)); ASSERT_EQ(get_pixel_from_row(data.data(), 2, PixelFormat::RGB111), Pixel(0xffff, 0, 0)); ASSERT_EQ(get_pixel_from_row(data.data(), 3, PixelFormat::RGB111), Pixel(0, 0xffff, 0xffff)); ASSERT_EQ(get_pixel_from_row(data.data(), 0, PixelFormat::I8), Pixel(0x1212, 0x1212, 0x1212)); ASSERT_EQ(get_pixel_from_row(data.data(), 1, PixelFormat::I8), Pixel(0x3434, 0x3434, 0x3434)); ASSERT_EQ(get_pixel_from_row(data.data(), 0, PixelFormat::RGB888), Pixel(0x1212, 0x3434, 0x5656)); ASSERT_EQ(get_pixel_from_row(data.data(), 1, PixelFormat::RGB888), Pixel(0x6767, 0x8989, 0xabab)); ASSERT_EQ(get_pixel_from_row(data.data(), 0, PixelFormat::BGR888), Pixel(0x5656, 0x3434, 0x1212)); ASSERT_EQ(get_pixel_from_row(data.data(), 1, PixelFormat::BGR888), Pixel(0xabab, 0x8989, 0x6767)); ASSERT_EQ(get_pixel_from_row(data.data(), 0, PixelFormat::I16), Pixel(0x3412, 0x3412, 0x3412)); ASSERT_EQ(get_pixel_from_row(data.data(), 1, PixelFormat::I16), Pixel(0x6756, 0x6756, 0x6756)); ASSERT_EQ(get_pixel_from_row(data.data(), 0, PixelFormat::RGB161616), Pixel(0x3412, 0x6756, 0xab89)); ASSERT_EQ(get_pixel_from_row(data.data(), 1, PixelFormat::RGB161616), Pixel(0xefcd, 0x4321, 0x8765)); ASSERT_EQ(get_pixel_from_row(data.data(), 0, PixelFormat::BGR161616), Pixel(0xab89, 0x6756, 0x3412)); ASSERT_EQ(get_pixel_from_row(data.data(), 1, PixelFormat::BGR161616), Pixel(0x8765, 0x4321, 0xefcd)); } void test_set_pixel_to_row() { using Data = std::vector; Data data; data.resize(12, 0); auto reset = [&]() { std::fill(data.begin(), data.end(), 0); }; Pixel pixel; pixel = Pixel(0x8000, 0x8000, 0x8000); set_pixel_to_row(data.data(), 0, pixel, PixelFormat::I1); ASSERT_EQ(data, Data({0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x8000, 0x8000, 0x8000); set_pixel_to_row(data.data(), 2, pixel, PixelFormat::I1); ASSERT_EQ(data, Data({0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x8000, 0x8000, 0x8000); set_pixel_to_row(data.data(), 8, pixel, PixelFormat::I1); ASSERT_EQ(data, Data({0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x8000, 0x0000, 0x8000); set_pixel_to_row(data.data(), 0, pixel, PixelFormat::RGB111); ASSERT_EQ(data, Data({0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x8000, 0x0000, 0x8000); set_pixel_to_row(data.data(), 1, pixel, PixelFormat::RGB111); ASSERT_EQ(data, Data({0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x8000, 0x0000, 0x8000); set_pixel_to_row(data.data(), 8, pixel, PixelFormat::RGB111); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1200, 0x1200, 0x1200); set_pixel_to_row(data.data(), 0, pixel, PixelFormat::I8); ASSERT_EQ(data, Data({0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1200, 0x1200, 0x1200); set_pixel_to_row(data.data(), 2, pixel, PixelFormat::I8); ASSERT_EQ(data, Data({0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1200, 0x3400, 0x5600); set_pixel_to_row(data.data(), 0, pixel, PixelFormat::RGB888); ASSERT_EQ(data, Data({0x12, 0x34, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1200, 0x3400, 0x5600); set_pixel_to_row(data.data(), 1, pixel, PixelFormat::RGB888); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x12, 0x34, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1200, 0x3400, 0x5600); set_pixel_to_row(data.data(), 0, pixel, PixelFormat::BGR888); ASSERT_EQ(data, Data({0x56, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1200, 0x3400, 0x5600); set_pixel_to_row(data.data(), 1, pixel, PixelFormat::BGR888); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x56, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1234, 0x1234, 0x1234); set_pixel_to_row(data.data(), 0, pixel, PixelFormat::I16); ASSERT_EQ(data, Data({0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1234, 0x1234, 0x1234); set_pixel_to_row(data.data(), 1, pixel, PixelFormat::I16); ASSERT_EQ(data, Data({0x00, 0x00, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1234, 0x5678, 0x9abc); set_pixel_to_row(data.data(), 0, pixel, PixelFormat::RGB161616); ASSERT_EQ(data, Data({0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1234, 0x5678, 0x9abc); set_pixel_to_row(data.data(), 1, pixel, PixelFormat::RGB161616); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a})); reset(); pixel = Pixel(0x1234, 0x5678, 0x9abc); set_pixel_to_row(data.data(), 0, pixel, PixelFormat::BGR161616); ASSERT_EQ(data, Data({0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = Pixel(0x1234, 0x5678, 0x9abc); set_pixel_to_row(data.data(), 1, pixel, PixelFormat::BGR161616); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12})); reset(); } void test_get_raw_pixel_from_row() { std::vector data = { 0x12, 0x34, 0x56, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x21, 0x43, 0x65, 0x87 }; ASSERT_EQ(get_raw_pixel_from_row(data.data(), 0, PixelFormat::I1), RawPixel(0x0)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 3, PixelFormat::I1), RawPixel(0x1)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 0, PixelFormat::RGB111), RawPixel(0)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 1, PixelFormat::RGB111), RawPixel(0x4)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 2, PixelFormat::RGB111), RawPixel(0x4)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 3, PixelFormat::RGB111), RawPixel(0x3)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 0, PixelFormat::I8), RawPixel(0x12)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 1, PixelFormat::I8), RawPixel(0x34)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 0, PixelFormat::RGB888), RawPixel(0x12, 0x34, 0x56)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 1, PixelFormat::RGB888), RawPixel(0x67, 0x89, 0xab)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 0, PixelFormat::BGR888), RawPixel(0x12, 0x34, 0x56)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 1, PixelFormat::BGR888), RawPixel(0x67, 0x89, 0xab)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 0, PixelFormat::I16), RawPixel(0x12, 0x34)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 1, PixelFormat::I16), RawPixel(0x56, 0x67)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 0, PixelFormat::RGB161616), RawPixel(0x12, 0x34, 0x56, 0x67, 0x89, 0xab)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 1, PixelFormat::RGB161616), RawPixel(0xcd, 0xef, 0x21, 0x43, 0x65, 0x87)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 0, PixelFormat::BGR161616), RawPixel(0x12, 0x34, 0x56, 0x67, 0x89, 0xab)); ASSERT_EQ(get_raw_pixel_from_row(data.data(), 1, PixelFormat::BGR161616), RawPixel(0xcd, 0xef, 0x21, 0x43, 0x65, 0x87)); } void test_set_raw_pixel_to_row() { using Data = std::vector; Data data; data.resize(12, 0); auto reset = [&]() { std::fill(data.begin(), data.end(), 0); }; RawPixel pixel; pixel = RawPixel(0x01); set_raw_pixel_to_row(data.data(), 0, pixel, PixelFormat::I1); ASSERT_EQ(data, Data({0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x01); set_raw_pixel_to_row(data.data(), 2, pixel, PixelFormat::I1); ASSERT_EQ(data, Data({0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x01); set_raw_pixel_to_row(data.data(), 8, pixel, PixelFormat::I1); ASSERT_EQ(data, Data({0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x05); set_raw_pixel_to_row(data.data(), 0, pixel, PixelFormat::RGB111); ASSERT_EQ(data, Data({0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x05); set_raw_pixel_to_row(data.data(), 1, pixel, PixelFormat::RGB111); ASSERT_EQ(data, Data({0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x05); set_raw_pixel_to_row(data.data(), 8, pixel, PixelFormat::RGB111); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x12); set_raw_pixel_to_row(data.data(), 0, pixel, PixelFormat::I8); ASSERT_EQ(data, Data({0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x12); set_raw_pixel_to_row(data.data(), 2, pixel, PixelFormat::I8); ASSERT_EQ(data, Data({0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x12, 0x34, 0x56); set_raw_pixel_to_row(data.data(), 0, pixel, PixelFormat::RGB888); ASSERT_EQ(data, Data({0x12, 0x34, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x12, 0x34, 0x56); set_raw_pixel_to_row(data.data(), 1, pixel, PixelFormat::RGB888); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x12, 0x34, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x12, 0x34, 0x56); set_raw_pixel_to_row(data.data(), 0, pixel, PixelFormat::BGR888); ASSERT_EQ(data, Data({0x12, 0x34, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x12, 0x34, 0x56); set_raw_pixel_to_row(data.data(), 1, pixel, PixelFormat::BGR888); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x12, 0x34, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x34, 0x12); set_raw_pixel_to_row(data.data(), 0, pixel, PixelFormat::I16); ASSERT_EQ(data, Data({0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x34, 0x12); set_raw_pixel_to_row(data.data(), 1, pixel, PixelFormat::I16); ASSERT_EQ(data, Data({0x00, 0x00, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a); set_raw_pixel_to_row(data.data(), 0, pixel, PixelFormat::RGB161616); ASSERT_EQ(data, Data({0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a); set_raw_pixel_to_row(data.data(), 1, pixel, PixelFormat::RGB161616); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a})); reset(); pixel = RawPixel(0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a); set_raw_pixel_to_row(data.data(), 0, pixel, PixelFormat::BGR161616); ASSERT_EQ(data, Data({0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); pixel = RawPixel(0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a); set_raw_pixel_to_row(data.data(), 1, pixel, PixelFormat::BGR161616); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12, 0x78, 0x56, 0xbc, 0x9a})); reset(); } void test_get_raw_channel_from_row() { std::vector data = { 0x12, 0x34, 0x56, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x21, 0x43, 0x65, 0x87 }; ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 0, PixelFormat::I1), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 3, 0, PixelFormat::I1), 1); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 0, PixelFormat::RGB111), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 1, PixelFormat::RGB111), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 2, PixelFormat::RGB111), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 0, PixelFormat::RGB111), 1); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 1, PixelFormat::RGB111), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 2, PixelFormat::RGB111), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 2, 0, PixelFormat::RGB111), 1); ASSERT_EQ(get_raw_channel_from_row(data.data(), 2, 1, PixelFormat::RGB111), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 2, 2, PixelFormat::RGB111), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 3, 0, PixelFormat::RGB111), 0); ASSERT_EQ(get_raw_channel_from_row(data.data(), 3, 1, PixelFormat::RGB111), 1); ASSERT_EQ(get_raw_channel_from_row(data.data(), 3, 2, PixelFormat::RGB111), 1); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 0, PixelFormat::I8), 0x12); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 0, PixelFormat::I8), 0x34); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 0, PixelFormat::RGB888), 0x12); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 1, PixelFormat::RGB888), 0x34); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 2, PixelFormat::RGB888), 0x56); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 0, PixelFormat::RGB888), 0x67); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 1, PixelFormat::RGB888), 0x89); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 2, PixelFormat::RGB888), 0xab); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 0, PixelFormat::BGR888), 0x12); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 1, PixelFormat::BGR888), 0x34); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 2, PixelFormat::BGR888), 0x56); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 0, PixelFormat::BGR888), 0x67); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 1, PixelFormat::BGR888), 0x89); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 2, PixelFormat::BGR888), 0xab); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 0, PixelFormat::I16), 0x3412); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 0, PixelFormat::I16), 0x6756); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 0, PixelFormat::RGB161616), 0x3412); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 1, PixelFormat::RGB161616), 0x6756); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 2, PixelFormat::RGB161616), 0xab89); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 0, PixelFormat::RGB161616), 0xefcd); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 1, PixelFormat::RGB161616), 0x4321); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 2, PixelFormat::RGB161616), 0x8765); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 0, PixelFormat::BGR161616), 0x3412); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 1, PixelFormat::BGR161616), 0x6756); ASSERT_EQ(get_raw_channel_from_row(data.data(), 0, 2, PixelFormat::BGR161616), 0xab89); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 0, PixelFormat::BGR161616), 0xefcd); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 1, PixelFormat::BGR161616), 0x4321); ASSERT_EQ(get_raw_channel_from_row(data.data(), 1, 2, PixelFormat::BGR161616), 0x8765); } void test_set_raw_channel_to_row() { using Data = std::vector; Data data; data.resize(12, 0); auto reset = [&]() { std::fill(data.begin(), data.end(), 0); }; set_raw_channel_to_row(data.data(), 0, 0, 1, PixelFormat::I1); ASSERT_EQ(data, Data({0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 2, 0, 1, PixelFormat::I1); ASSERT_EQ(data, Data({0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 8, 0, 1, PixelFormat::I1); ASSERT_EQ(data, Data({0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 0, 0, 1, PixelFormat::RGB111); ASSERT_EQ(data, Data({0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 0, 1, 1, PixelFormat::RGB111); ASSERT_EQ(data, Data({0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 0, 2, 1, PixelFormat::RGB111); ASSERT_EQ(data, Data({0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 8, 0, 1, PixelFormat::RGB111); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 0, 0, 0x12, PixelFormat::I8); ASSERT_EQ(data, Data({0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 2, 0, 0x12, PixelFormat::I8); ASSERT_EQ(data, Data({0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); for (auto format : { PixelFormat::RGB888, PixelFormat::BGR888 }) { set_raw_channel_to_row(data.data(), 0, 0, 0x12, format); ASSERT_EQ(data, Data({0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 0, 1, 0x12, format); ASSERT_EQ(data, Data({0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 0, 2, 0x12, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 1, 0, 0x12, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 1, 1, 0x12, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 1, 2, 0x12, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); } set_raw_channel_to_row(data.data(), 0, 0, 0x1234, PixelFormat::I16); ASSERT_EQ(data, Data({0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 1, 0, 0x1234, PixelFormat::I16); ASSERT_EQ(data, Data({0x00, 0x00, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); for (auto format : { PixelFormat::RGB161616, PixelFormat::BGR161616 }) { set_raw_channel_to_row(data.data(), 0, 0, 0x1234, format); ASSERT_EQ(data, Data({0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 0, 1, 0x1234, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 0, 2, 0x1234, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 1, 0, 0x1234, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12, 0x00, 0x00, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 1, 1, 0x1234, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12, 0x00, 0x00})); reset(); set_raw_channel_to_row(data.data(), 1, 2, 0x1234, format); ASSERT_EQ(data, Data({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x12})); reset(); } } void test_convert_pixel_row_format() { // The actual work is done in set_channel_to_row and get_channel_from_row, so we don't need // to test all format combinations. using Data = std::vector; Data in_data = { 0x12, 0x34, 0x56, 0x78, 0x98, 0xab, 0xcd, 0xef, 0x21, }; Data out_data; out_data.resize(in_data.size() * 2); convert_pixel_row_format(in_data.data(), PixelFormat::RGB888, out_data.data(), PixelFormat::BGR161616, 3); Data expected_data = { 0x56, 0x56, 0x34, 0x34, 0x12, 0x12, 0xab, 0xab, 0x98, 0x98, 0x78, 0x78, 0x21, 0x21, 0xef, 0xef, 0xcd, 0xcd, }; ASSERT_EQ(out_data, expected_data); } void test_image() { test_get_pixel_from_row(); test_set_pixel_to_row(); test_get_raw_pixel_from_row(); test_set_raw_pixel_to_row(); test_get_raw_channel_from_row(); test_set_raw_channel_to_row(); test_convert_pixel_row_format(); } } // namespace genesys sane-backends-1.0.29/testsuite/backend/genesys/Makefile.in0000644000000000000000000011467413615534557020365 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ check_PROGRAMS = genesys_unit_tests$(EXEEXT) \ genesys_session_config_tests$(EXEEXT) TESTS = genesys_unit_tests$(EXEEXT) subdir = testsuite/backend/genesys ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_genesys_session_config_tests_OBJECTS = \ session_config_test.$(OBJEXT) genesys_session_config_tests_OBJECTS = \ $(am_genesys_session_config_tests_OBJECTS) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = ../../../sanei/libsanei.la \ ../../../sanei/sanei_usb.lo ../../../sanei/sanei_magic.lo \ ../../../lib/liblib.la ../../../backend/libgenesys.la \ ../../../backend/sane_strstatus.lo $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) genesys_session_config_tests_DEPENDENCIES = $(am__DEPENDENCIES_2) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_genesys_unit_tests_OBJECTS = tests.$(OBJEXT) minigtest.$(OBJEXT) \ tests_calibration.$(OBJEXT) tests_image.$(OBJEXT) \ tests_image_pipeline.$(OBJEXT) tests_motor.$(OBJEXT) \ tests_row_buffer.$(OBJEXT) tests_utilities.$(OBJEXT) genesys_unit_tests_OBJECTS = $(am_genesys_unit_tests_OBJECTS) genesys_unit_tests_DEPENDENCIES = $(am__DEPENDENCIES_2) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/sane depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/minigtest.Po \ ./$(DEPDIR)/session_config_test.Po ./$(DEPDIR)/tests.Po \ ./$(DEPDIR)/tests_calibration.Po ./$(DEPDIR)/tests_image.Po \ ./$(DEPDIR)/tests_image_pipeline.Po ./$(DEPDIR)/tests_motor.Po \ ./$(DEPDIR)/tests_row_buffer.Po ./$(DEPDIR)/tests_utilities.Po am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(genesys_session_config_tests_SOURCES) \ $(genesys_unit_tests_SOURCES) DIST_SOURCES = $(genesys_session_config_tests_SOURCES) \ $(genesys_unit_tests_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/test-driver 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) -DBACKEND_NAME=genesys \ -DTESTSUITE_BACKEND_GENESYS_SRCDIR=$(srcdir) AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ TEST_LDADD = \ ../../../sanei/libsanei.la \ ../../../sanei/sanei_usb.lo \ ../../../sanei/sanei_magic.lo \ ../../../lib/liblib.la \ ../../../backend/libgenesys.la \ ../../../backend/sane_strstatus.lo \ $(MATH_LIB) $(USB_LIBS) $(XML_LIBS) $(PTHREAD_LIBS) genesys_unit_tests_SOURCES = tests.cpp tests.h \ minigtest.cpp minigtest.h tests_printers.h \ tests_calibration.cpp \ tests_image.cpp \ tests_image_pipeline.cpp \ tests_motor.cpp \ tests_row_buffer.cpp \ tests_utilities.cpp genesys_unit_tests_LDADD = $(TEST_LDADD) genesys_session_config_tests_SOURCES = session_config_test.cpp genesys_session_config_tests_LDADD = $(TEST_LDADD) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/backend/genesys/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu testsuite/backend/genesys/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list genesys_session_config_tests$(EXEEXT): $(genesys_session_config_tests_OBJECTS) $(genesys_session_config_tests_DEPENDENCIES) $(EXTRA_genesys_session_config_tests_DEPENDENCIES) @rm -f genesys_session_config_tests$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(genesys_session_config_tests_OBJECTS) $(genesys_session_config_tests_LDADD) $(LIBS) genesys_unit_tests$(EXEEXT): $(genesys_unit_tests_OBJECTS) $(genesys_unit_tests_DEPENDENCIES) $(EXTRA_genesys_unit_tests_DEPENDENCIES) @rm -f genesys_unit_tests$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(genesys_unit_tests_OBJECTS) $(genesys_unit_tests_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minigtest.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/session_config_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests_calibration.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests_image.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests_image_pipeline.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests_motor.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests_row_buffer.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests_utilities.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? genesys_unit_tests.log: genesys_unit_tests$(EXEEXT) @p='genesys_unit_tests$(EXEEXT)'; \ b='genesys_unit_tests'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/minigtest.Po -rm -f ./$(DEPDIR)/session_config_test.Po -rm -f ./$(DEPDIR)/tests.Po -rm -f ./$(DEPDIR)/tests_calibration.Po -rm -f ./$(DEPDIR)/tests_image.Po -rm -f ./$(DEPDIR)/tests_image_pipeline.Po -rm -f ./$(DEPDIR)/tests_motor.Po -rm -f ./$(DEPDIR)/tests_row_buffer.Po -rm -f ./$(DEPDIR)/tests_utilities.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/minigtest.Po -rm -f ./$(DEPDIR)/session_config_test.Po -rm -f ./$(DEPDIR)/tests.Po -rm -f ./$(DEPDIR)/tests_calibration.Po -rm -f ./$(DEPDIR)/tests_image.Po -rm -f ./$(DEPDIR)/tests_image_pipeline.Po -rm -f ./$(DEPDIR)/tests_motor.Po -rm -f ./$(DEPDIR)/tests_row_buffer.Po -rm -f ./$(DEPDIR)/tests_utilities.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ check-am clean clean-checkPROGRAMS clean-generic clean-libtool \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/testsuite/backend/genesys/tests_printers.h0000666000000000000000000000352313615534521021542 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef SANE_TESTSUITE_BACKEND_GENESYS_TESTS_PRINTERS_H #define SANE_TESTSUITE_BACKEND_GENESYS_TESTS_PRINTERS_H #include "../../../backend/genesys/image_pixel.h" #include "../../../backend/genesys/utilities.h" #include #include #include template std::ostream& operator<<(std::ostream& str, const std::vector& arg) { str << genesys::format_vector_unsigned(4, arg) << '\n'; return str; } inline std::ostream& operator<<(std::ostream& str, const genesys::PixelFormat& arg) { str << static_cast(arg); return str; } inline std::ostream& operator<<(std::ostream& str, const genesys::Pixel& arg) { str << "{ " << arg.r << ", " << arg.g << ", " << arg.b << " }"; return str; } inline std::ostream& operator<<(std::ostream& str, const genesys::RawPixel& arg) { auto flags = str.flags(); str << std::hex; for (auto el : arg.data) { str << static_cast(el) << " "; } str.flags(flags); return str; } #endif sane-backends-1.0.29/testsuite/backend/genesys/minigtest.cpp0000666000000000000000000000222413615534521021005 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "minigtest.h" #define DEBUG_DECLARE_ONLY size_t s_num_successes = 0; size_t s_num_failures = 0; int finish_tests() { std::cerr << "Finished tests. Sucessses: " << s_num_successes << " failures: " << s_num_failures << "\n"; if (s_num_failures > 0) return 1; return 0; } sane-backends-1.0.29/testsuite/backend/genesys/session_config_test.cpp0000666000000000000000000004025013615534521023052 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define DEBUG_DECLARE_ONLY #include "../../../backend/genesys/device.h" #include "../../../backend/genesys/enums.h" #include "../../../backend/genesys/error.h" #include "../../../backend/genesys/low.h" #include "../../../backend/genesys/genesys.h" #include "../../../backend/genesys/test_settings.h" #include "../../../backend/genesys/test_scanner_interface.h" #include "../../../backend/genesys/utilities.h" #include "../../../include/sane/saneopts.h" #include "sys/stat.h" #include #include #include #include #include #include #define XSTR(s) STR(s) #define STR(s) #s #define CURR_SRCDIR XSTR(TESTSUITE_BACKEND_GENESYS_SRCDIR) struct TestConfig { std::uint16_t vendor_id = 0; std::uint16_t product_id = 0; std::string model_name; genesys::ScanMethod method = genesys::ScanMethod::FLATBED; genesys::ScanColorMode color_mode = genesys::ScanColorMode::COLOR_SINGLE_PASS; unsigned depth = 0; unsigned resolution = 0; std::string name() const { std::stringstream out; out << "capture_" << model_name << '_' << method << '_' << color_mode << "_depth" << depth << "_dpi" << resolution; return out.str(); } }; class SaneOptions { public: void fetch(SANE_Handle handle) { handle_ = handle; options_.resize(1); options_[0] = fetch_option(0); if (std::strcmp(options_[0].name, SANE_NAME_NUM_OPTIONS) != 0 || options_[0].type != SANE_TYPE_INT) { throw std::runtime_error("Expected option number option"); } int option_count = 0; TIE(sane_control_option(handle, 0, SANE_ACTION_GET_VALUE, &option_count, nullptr)); options_.resize(option_count); for (int i = 0; i < option_count; ++i) { options_[i] = fetch_option(i); } } void close() { handle_ = nullptr; } bool get_value_bool(const std::string& name) const { auto i = find_option(name, SANE_TYPE_BOOL); int value = 0; TIE(sane_control_option(handle_, i, SANE_ACTION_GET_VALUE, &value, nullptr)); return value; } void set_value_bool(const std::string& name, bool value) { auto i = find_option(name, SANE_TYPE_BOOL); int value_int = value; TIE(sane_control_option(handle_, i, SANE_ACTION_SET_VALUE, &value_int, nullptr)); } bool get_value_button(const std::string& name) const { auto i = find_option(name, SANE_TYPE_BUTTON); int value = 0; TIE(sane_control_option(handle_, i, SANE_ACTION_GET_VALUE, &value, nullptr)); return value; } void set_value_button(const std::string& name, bool value) { auto i = find_option(name, SANE_TYPE_BUTTON); int value_int = value; TIE(sane_control_option(handle_, i, SANE_ACTION_SET_VALUE, &value_int, nullptr)); } int get_value_int(const std::string& name) const { auto i = find_option(name, SANE_TYPE_INT); int value = 0; TIE(sane_control_option(handle_, i, SANE_ACTION_GET_VALUE, &value, nullptr)); return value; } void set_value_int(const std::string& name, int value) { auto i = find_option(name, SANE_TYPE_INT); TIE(sane_control_option(handle_, i, SANE_ACTION_SET_VALUE, &value, nullptr)); } float get_value_float(const std::string& name) const { auto i = find_option(name, SANE_TYPE_FIXED); int value = 0; TIE(sane_control_option(handle_, i, SANE_ACTION_GET_VALUE, &value, nullptr)); return static_cast(SANE_UNFIX(value)); } void set_value_float(const std::string& name, float value) { auto i = find_option(name, SANE_TYPE_FIXED); int value_int = SANE_FIX(value); TIE(sane_control_option(handle_, i, SANE_ACTION_SET_VALUE, &value_int, nullptr)); } std::string get_value_string(const std::string& name) const { auto i = find_option(name, SANE_TYPE_STRING); std::string value; value.resize(options_[i].size + 1); TIE(sane_control_option(handle_, i, SANE_ACTION_GET_VALUE, &value.front(), nullptr)); value.resize(std::strlen(&value.front())); return value; } void set_value_string(const std::string& name, const std::string& value) { auto i = find_option(name, SANE_TYPE_STRING); TIE(sane_control_option(handle_, i, SANE_ACTION_SET_VALUE, const_cast(&value.front()), nullptr)); } private: SANE_Option_Descriptor fetch_option(int index) { const auto* option = sane_get_option_descriptor(handle_, index); if (option == nullptr) { throw std::runtime_error("Got nullptr option"); } return *option; } std::size_t find_option(const std::string& name, SANE_Value_Type type) const { for (std::size_t i = 0; i < options_.size(); ++i) { if (options_[i].name == name) { if (options_[i].type != type) { throw std::runtime_error("Option has incorrect type"); } return i; } } throw std::runtime_error("Could not find option"); } SANE_Handle handle_; std::vector options_; }; void build_checkpoint(const genesys::Genesys_Device& dev, genesys::TestScannerInterface& iface, const std::string& checkpoint_name, std::stringstream& out) { out << "\n\n================\n" << "Checkpoint: " << checkpoint_name << "\n" << "================\n\n" << "dev: " << genesys::format_indent_braced_list(4, dev) << "\n\n" << "iface.cached_regs: " << genesys::format_indent_braced_list(4, iface.cached_regs()) << "\n\n" << "iface.cached_fe_regs: " << genesys::format_indent_braced_list(4, iface.cached_fe_regs()) << "\n\n" << "iface.last_progress_message: " << iface.last_progress_message() << "\n\n"; out << "iface.slope_tables: {\n"; for (const auto& kv : iface.recorded_slope_tables()) { out << " " << kv.first << ": {"; for (unsigned i = 0; i < kv.second.size(); ++i) { if (i % 10 == 0) { out << "\n "; } out << ' ' << kv.second[i]; } out << "\n }\n"; } out << "}\n"; if (iface.recorded_key_values().empty()) { out << "iface.recorded_key_values: []\n"; } else { out << "iface.recorded_key_values: {\n"; for (const auto& kv : iface.recorded_key_values()) { out << " " << kv.first << " : " << kv.second << '\n'; } out << "}\n"; } iface.recorded_key_values().clear(); out << "\n"; } void run_single_test_scan(const TestConfig& config, std::stringstream& out) { auto build_checkpoint_wrapper = [&](const genesys::Genesys_Device& dev, genesys::TestScannerInterface& iface, const std::string& checkpoint_name) { build_checkpoint(dev, iface, checkpoint_name, out); }; genesys::enable_testing_mode(config.vendor_id, config.product_id, build_checkpoint_wrapper); SANE_Handle handle; TIE(sane_init(nullptr, nullptr)); TIE(sane_open(genesys::get_testing_device_name().c_str(), &handle)); SaneOptions options; options.fetch(handle); options.set_value_button("force-calibration", true); options.set_value_string(SANE_NAME_SCAN_SOURCE, genesys::scan_method_to_option_string(config.method)); options.set_value_string(SANE_NAME_SCAN_MODE, genesys::scan_color_mode_to_option_string(config.color_mode)); if (config.color_mode != genesys::ScanColorMode::LINEART) { options.set_value_int(SANE_NAME_BIT_DEPTH, config.depth); } options.set_value_int(SANE_NAME_SCAN_RESOLUTION, config.resolution); options.close(); TIE(sane_start(handle)); SANE_Parameters params; TIE(sane_get_parameters(handle, ¶ms)); int buffer_size = 1024 * 1024; std::vector buffer; buffer.resize(buffer_size); std::uint64_t total_data_size = std::uint64_t(params.bytes_per_line) * params.lines; std::uint64_t total_got_data = 0; while (total_got_data < total_data_size) { int ask_len = std::min(buffer_size, total_data_size - total_got_data); int got_data = 0; auto status = sane_read(handle, buffer.data(), ask_len, &got_data); total_got_data += got_data; if (status == SANE_STATUS_EOF) { break; } TIE(status); } sane_cancel(handle); sane_close(handle); sane_exit(); genesys::disable_testing_mode(); } std::string read_file_to_string(const std::string& path) { std::ifstream in; in.open(path); if (!in.is_open()) { return ""; } std::stringstream in_str; in_str << in.rdbuf(); return in_str.str(); } void write_string_to_file(const std::string& path, const std::string& contents) { std::ofstream out; out.open(path); if (!out.is_open()) { throw std::runtime_error("Could not open output file: " + path); } out << contents; out.close(); } struct TestResult { bool success = true; TestConfig config; std::string failure_message; }; TestResult perform_single_test(const TestConfig& config, const std::string& check_directory, const std::string& output_directory) { TestResult test_result; test_result.config = config; std::stringstream result_output_stream; std::string exception_output; try { run_single_test_scan(config, result_output_stream); } catch (const std::exception& exc) { exception_output = std::string("got exception: ") + typeid(exc).name() + " with message\n" + exc.what() + "\n"; test_result.success = false; test_result.failure_message += exception_output; } catch (...) { exception_output = "got unknown exception\n"; test_result.success = false; test_result.failure_message += exception_output; } auto result_output = result_output_stream.str(); if (!exception_output.empty()) { result_output += "\n\n" + exception_output; } auto test_filename = config.name() + ".txt"; auto expected_session_path = check_directory + "/" + test_filename; auto current_session_path = output_directory + "/" + test_filename; auto expected_output = read_file_to_string(expected_session_path); bool has_output = !output_directory.empty(); if (has_output) { mkdir(output_directory.c_str(), 0777); // note that check_directory and output_directory may be the same, so make sure removal // happens after the expected output has already been read. std::remove(current_session_path.c_str()); } if (expected_output.empty()) { test_result.failure_message += "the expected data file does not exist\n"; test_result.success = false; } else if (expected_output != result_output) { test_result.failure_message += "expected and current output are not equal\n"; if (has_output) { test_result.failure_message += "To examine, run:\ndiff -u \"" + current_session_path + "\" \"" + expected_session_path + "\"\n"; } test_result.success = false; } if (has_output) { write_string_to_file(current_session_path, result_output); } return test_result; } std::vector get_all_test_configs() { genesys::genesys_init_usb_device_tables(); std::vector configs; std::unordered_set model_names; for (const auto& usb_dev : *genesys::s_usb_devices) { if (usb_dev.model.flags & GENESYS_FLAG_UNTESTED) { continue; } if (model_names.find(usb_dev.model.name) != model_names.end()) { continue; } model_names.insert(usb_dev.model.name); for (auto scan_mode : { genesys::ScanColorMode::LINEART, genesys::ScanColorMode::GRAY, genesys::ScanColorMode::COLOR_SINGLE_PASS }) { auto depth_values = usb_dev.model.bpp_gray_values; if (scan_mode == genesys::ScanColorMode::COLOR_SINGLE_PASS) { depth_values = usb_dev.model.bpp_color_values; } for (unsigned depth : depth_values) { for (auto method_resolutions : usb_dev.model.resolutions) { for (auto method : method_resolutions.methods) { for (unsigned resolution : method_resolutions.get_resolutions()) { TestConfig config; config.vendor_id = usb_dev.vendor; config.product_id = usb_dev.product; config.model_name = usb_dev.model.name; config.method = method; config.depth = depth; config.resolution = resolution; config.color_mode = scan_mode; configs.push_back(config); } } } } } } return configs; } void print_help() { std::cerr << "Usage:\n" << "session_config_test [--test={test_name}] {check_directory} [{output_directory}]\n" << "session_config_test --help\n" << "session_config_test --print_test_names\n"; } int main(int argc, const char* argv[]) { std::string check_directory; std::string output_directory; std::string test_name_filter; bool print_test_names = false; for (int argi = 1; argi < argc; ++argi) { std::string arg = argv[argi]; if (arg.rfind("--test=", 0) == 0) { test_name_filter = arg.substr(7); } else if (arg == "-h" || arg == "--help") { print_help(); return 0; } else if (arg == "--print_test_names") { print_test_names = true; } else if (check_directory.empty()) { check_directory = arg; } else if (output_directory.empty()) { output_directory = arg; } } auto configs = get_all_test_configs(); if (print_test_names) { for (const auto& config : configs) { std::cout << config.name() << "\n"; } return 0; } if (check_directory.empty()) { print_help(); return 1; } bool test_success = true; for (unsigned i = 0; i < configs.size(); ++i) { const auto& config = configs[i]; if (!test_name_filter.empty() && config.name() != test_name_filter) { continue; } auto result = perform_single_test(config, check_directory, output_directory); std::cerr << "(" << i << "/" << configs.size() << "): " << (result.success ? "SUCCESS: " : "FAIL: ") << result.config.name() << "\n"; if (!result.success) { std::cerr << result.failure_message; } test_success &= result.success; } if (!test_success) { return 1; } return 0; } sane-backends-1.0.29/testsuite/backend/genesys/tests_image_pipeline.cpp0000666000000000000000000004010013615534521023166 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define DEBUG_DECLARE_ONLY #include "tests.h" #include "minigtest.h" #include "tests_printers.h" #include "../../../backend/genesys/image_pipeline.h" #include namespace genesys { void test_image_buffer_genesys_usb() { std::vector requests; auto on_read_usb = [&](std::size_t x, std::uint8_t* data) { (void) data; requests.push_back(x); }; FakeBufferModel model; model.push_step(453120, 1); model.push_step(56640, 3540); ImageBufferGenesysUsb buffer{1086780, model, on_read_usb}; std::vector dummy; dummy.resize(1086780); ASSERT_TRUE(buffer.get_data(453120, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); std::vector expected = { 453120, 56576, 56576, 56576, 56832, 56576, 56576, 56576, 56832, 56576, 56576, 56576, 11008 }; ASSERT_EQ(requests, expected); } void test_image_buffer_genesys_usb_capped_remaining_bytes() { std::vector requests; auto on_read_usb = [&](std::size_t x, std::uint8_t* data) { (void) data; requests.push_back(x); }; FakeBufferModel model; model.push_step(453120, 1); model.push_step(56640, 3540); ImageBufferGenesysUsb buffer{1086780, model, on_read_usb}; std::vector dummy; dummy.resize(1086780); ASSERT_TRUE(buffer.get_data(453120, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); ASSERT_TRUE(buffer.get_data(56640, dummy.data())); buffer.set_remaining_size(10000); ASSERT_FALSE(buffer.get_data(56640, dummy.data())); std::vector expected = { // note that the sizes are rounded-up to 256 bytes 453120, 56576, 56576, 56576, 56832, 10240 }; ASSERT_EQ(requests, expected); } void test_node_buffered_callable_source() { using Data = std::vector; Data in_data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; std::size_t chunk_size = 3; std::size_t curr_index = 0; auto data_source_cb = [&](std::size_t size, std::uint8_t* out_data) { ASSERT_EQ(size, chunk_size); std::copy(in_data.begin() + curr_index, in_data.begin() + curr_index + chunk_size, out_data); curr_index += chunk_size; return true; }; ImagePipelineStack stack; stack.push_first_node(4, 3, PixelFormat::I8, chunk_size, data_source_cb); Data out_data; out_data.resize(4); ASSERT_EQ(curr_index, 0u); ASSERT_TRUE(stack.get_next_row_data(out_data.data())); ASSERT_EQ(out_data, Data({0, 1, 2, 3})); ASSERT_EQ(curr_index, 6u); ASSERT_TRUE(stack.get_next_row_data(out_data.data())); ASSERT_EQ(out_data, Data({4, 5, 6, 7})); ASSERT_EQ(curr_index, 9u); ASSERT_TRUE(stack.get_next_row_data(out_data.data())); ASSERT_EQ(out_data, Data({8, 9, 10, 11})); ASSERT_EQ(curr_index, 12u); } void test_node_format_convert() { using Data = std::vector; Data in_data = { 0x12, 0x34, 0x56, 0x78, 0x98, 0xab, 0xcd, 0xef, 0x21, }; ImagePipelineStack stack; stack.push_first_node(3, 1, PixelFormat::RGB888, std::move(in_data)); stack.push_node(PixelFormat::BGR161616); ASSERT_EQ(stack.get_output_width(), 3u); ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_row_bytes(), 6u * 3); ASSERT_EQ(stack.get_output_format(), PixelFormat::BGR161616); auto out_data = stack.get_all_data(); Data expected_data = { 0x56, 0x56, 0x34, 0x34, 0x12, 0x12, 0xab, 0xab, 0x98, 0x98, 0x78, 0x78, 0x21, 0x21, 0xef, 0xef, 0xcd, 0xcd, }; ASSERT_EQ(out_data, expected_data); } void test_node_desegment_1_line() { using Data = std::vector; Data in_data = { 1, 5, 9, 13, 17, 3, 7, 11, 15, 19, 2, 6, 10, 14, 18, 4, 8, 12, 16, 20, 21, 25, 29, 33, 37, 23, 27, 31, 35, 39, 22, 26, 30, 34, 38, 24, 28, 32, 36, 40, }; ImagePipelineStack stack; stack.push_first_node(20, 2, PixelFormat::I8, std::move(in_data)); stack.push_node(20, std::vector{ 0, 2, 1, 3 }, 5, 1, 1); ASSERT_EQ(stack.get_output_width(), 20u); ASSERT_EQ(stack.get_output_height(), 2u); ASSERT_EQ(stack.get_output_row_bytes(), 20u); ASSERT_EQ(stack.get_output_format(), PixelFormat::I8); auto out_data = stack.get_all_data(); Data expected_data; expected_data.resize(40, 0); std::iota(expected_data.begin(), expected_data.end(), 1); // will fill with 1, 2, 3, ..., 40 ASSERT_EQ(out_data, expected_data); } void test_node_deinterleave_lines_i8() { using Data = std::vector; Data in_data = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, }; ImagePipelineStack stack; stack.push_first_node(10, 2, PixelFormat::I8, std::move(in_data)); stack.push_node(2, 1); ASSERT_EQ(stack.get_output_width(), 20u); ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_row_bytes(), 20u); ASSERT_EQ(stack.get_output_format(), PixelFormat::I8); auto out_data = stack.get_all_data(); Data expected_data; expected_data.resize(20, 0); std::iota(expected_data.begin(), expected_data.end(), 1); // will fill with 1, 2, 3, ..., 20 ASSERT_EQ(out_data, expected_data); } void test_node_deinterleave_lines_rgb888() { using Data = std::vector; Data in_data = { 1, 2, 3, 7, 8, 9, 13, 14, 15, 19, 20, 21, 4, 5, 6, 10, 11, 12, 16, 17, 18, 22, 23, 24, }; ImagePipelineStack stack; stack.push_first_node(4, 2, PixelFormat::RGB888, std::move(in_data)); stack.push_node(2, 1); ASSERT_EQ(stack.get_output_width(), 8u); ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_row_bytes(), 24u); ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB888); auto out_data = stack.get_all_data(); Data expected_data; expected_data.resize(24, 0); std::iota(expected_data.begin(), expected_data.end(), 1); // will fill with 1, 2, 3, ..., 20 ASSERT_EQ(out_data, expected_data); } void test_node_swap_16bit_endian() { using Data = std::vector; Data in_data = { 0x10, 0x20, 0x30, 0x11, 0x21, 0x31, 0x12, 0x22, 0x32, 0x13, 0x23, 0x33, 0x14, 0x24, 0x34, 0x15, 0x25, 0x35, 0x16, 0x26, 0x36, 0x17, 0x27, 0x37, }; ImagePipelineStack stack; stack.push_first_node(4, 1, PixelFormat::RGB161616, std::move(in_data)); stack.push_node(); ASSERT_EQ(stack.get_output_width(), 4u); ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_row_bytes(), 24u); ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB161616); auto out_data = stack.get_all_data(); Data expected_data = { 0x20, 0x10, 0x11, 0x30, 0x31, 0x21, 0x22, 0x12, 0x13, 0x32, 0x33, 0x23, 0x24, 0x14, 0x15, 0x34, 0x35, 0x25, 0x26, 0x16, 0x17, 0x36, 0x37, 0x27, }; ASSERT_EQ(out_data, expected_data); } void test_node_merge_mono_lines() { using Data = std::vector; Data in_data = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, }; ImagePipelineStack stack; stack.push_first_node(8, 3, PixelFormat::I8, std::move(in_data)); stack.push_node(ColorOrder::RGB); ASSERT_EQ(stack.get_output_width(), 8u); ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_row_bytes(), 24u); ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB888); auto out_data = stack.get_all_data(); Data expected_data = { 0x10, 0x20, 0x30, 0x11, 0x21, 0x31, 0x12, 0x22, 0x32, 0x13, 0x23, 0x33, 0x14, 0x24, 0x34, 0x15, 0x25, 0x35, 0x16, 0x26, 0x36, 0x17, 0x27, 0x37, }; ASSERT_EQ(out_data, expected_data); } void test_node_split_mono_lines() { using Data = std::vector; Data in_data = { 0x10, 0x20, 0x30, 0x11, 0x21, 0x31, 0x12, 0x22, 0x32, 0x13, 0x23, 0x33, 0x14, 0x24, 0x34, 0x15, 0x25, 0x35, 0x16, 0x26, 0x36, 0x17, 0x27, 0x37, }; ImagePipelineStack stack; stack.push_first_node(8, 1, PixelFormat::RGB888, std::move(in_data)); stack.push_node(); ASSERT_EQ(stack.get_output_width(), 8u); ASSERT_EQ(stack.get_output_height(), 3u); ASSERT_EQ(stack.get_output_row_bytes(), 8u); ASSERT_EQ(stack.get_output_format(), PixelFormat::I8); auto out_data = stack.get_all_data(); Data expected_data = { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, }; ASSERT_EQ(out_data, expected_data); } void test_node_component_shift_lines() { using Data = std::vector; Data in_data = { 0x10, 0x20, 0x30, 0x11, 0x21, 0x31, 0x12, 0x22, 0x32, 0x13, 0x23, 0x33, 0x14, 0x24, 0x34, 0x15, 0x25, 0x35, 0x16, 0x26, 0x36, 0x17, 0x27, 0x37, 0x18, 0x28, 0x38, 0x19, 0x29, 0x39, 0x1a, 0x2a, 0x3a, 0x1b, 0x2b, 0x3b, 0x1c, 0x2c, 0x3c, 0x1d, 0x2d, 0x3d, 0x1e, 0x2e, 0x3e, 0x1f, 0x2f, 0x3f, }; ImagePipelineStack stack; stack.push_first_node(4, 4, PixelFormat::RGB888, std::move(in_data)); stack.push_node(0, 1, 2); ASSERT_EQ(stack.get_output_width(), 4u); ASSERT_EQ(stack.get_output_height(), 2u); ASSERT_EQ(stack.get_output_row_bytes(), 12u); ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB888); auto out_data = stack.get_all_data(); Data expected_data = { 0x10, 0x24, 0x38, 0x11, 0x25, 0x39, 0x12, 0x26, 0x3a, 0x13, 0x27, 0x3b, 0x14, 0x28, 0x3c, 0x15, 0x29, 0x3d, 0x16, 0x2a, 0x3e, 0x17, 0x2b, 0x3f, }; ASSERT_EQ(out_data, expected_data); } void test_node_pixel_shift_lines() { using Data = std::vector; Data in_data = { 0x10, 0x20, 0x30, 0x11, 0x21, 0x31, 0x12, 0x22, 0x32, 0x13, 0x23, 0x33, 0x14, 0x24, 0x34, 0x15, 0x25, 0x35, 0x16, 0x26, 0x36, 0x17, 0x27, 0x37, 0x18, 0x28, 0x38, 0x19, 0x29, 0x39, 0x1a, 0x2a, 0x3a, 0x1b, 0x2b, 0x3b, 0x1c, 0x2c, 0x3c, 0x1d, 0x2d, 0x3d, 0x1e, 0x2e, 0x3e, 0x1f, 0x2f, 0x3f, }; ImagePipelineStack stack; stack.push_first_node(4, 4, PixelFormat::RGB888, std::move(in_data)); stack.push_node(std::vector{0, 2}); ASSERT_EQ(stack.get_output_width(), 4u); ASSERT_EQ(stack.get_output_height(), 2u); ASSERT_EQ(stack.get_output_row_bytes(), 12u); ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB888); auto out_data = stack.get_all_data(); Data expected_data = { 0x10, 0x20, 0x30, 0x19, 0x29, 0x39, 0x12, 0x22, 0x32, 0x1b, 0x2b, 0x3b, 0x14, 0x24, 0x34, 0x1d, 0x2d, 0x3d, 0x16, 0x26, 0x36, 0x1f, 0x2f, 0x3f, }; ASSERT_EQ(out_data, expected_data); } void test_node_calibrate_8bit() { using Data = std::vector; Data in_data = { 0x20, 0x38, 0x38 }; std::vector bottom = { 0x1000, 0x2000, 0x3000 }; std::vector top = { 0x3000, 0x4000, 0x5000 }; ImagePipelineStack stack; stack.push_first_node(1, 1, PixelFormat::RGB888, std::move(in_data)); stack.push_node(bottom, top); ASSERT_EQ(stack.get_output_width(), 1u); ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_row_bytes(), 3u); ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB888); auto out_data = stack.get_all_data(); Data expected_data = { // note that we don't handle rounding properly in the implementation 0x80, 0xc1, 0x41 }; ASSERT_EQ(out_data, expected_data); } void test_node_calibrate_16bit() { using Data = std::vector; Data in_data = { 0x00, 0x20, 0x00, 0x38, 0x00, 0x38 }; std::vector bottom = { 0x1000, 0x2000, 0x3000 }; std::vector top = { 0x3000, 0x4000, 0x5000 }; ImagePipelineStack stack; stack.push_first_node(1, 1, PixelFormat::RGB161616, std::move(in_data)); stack.push_node(bottom, top); ASSERT_EQ(stack.get_output_width(), 1u); ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_row_bytes(), 6u); ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB161616); auto out_data = stack.get_all_data(); Data expected_data = { // note that we don't handle rounding properly in the implementation 0x00, 0x80, 0xff, 0xbf, 0x00, 0x40 }; ASSERT_EQ(out_data, expected_data); } void test_image_pipeline() { test_image_buffer_genesys_usb(); test_image_buffer_genesys_usb_capped_remaining_bytes(); test_node_buffered_callable_source(); test_node_format_convert(); test_node_desegment_1_line(); test_node_deinterleave_lines_i8(); test_node_deinterleave_lines_rgb888(); test_node_swap_16bit_endian(); test_node_merge_mono_lines(); test_node_split_mono_lines(); test_node_component_shift_lines(); test_node_pixel_shift_lines(); test_node_calibrate_8bit(); test_node_calibrate_16bit(); } } // namespace genesys sane-backends-1.0.29/testsuite/backend/Makefile.am0000666000000000000000000000035713615534521016662 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2019 Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. SUBDIRS = genesys sane-backends-1.0.29/testsuite/backend/Makefile.in0000644000000000000000000005154713615534557016707 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = testsuite/backend ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_CPPFLAGS = @AM_CPPFLAGS@ AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = genesys all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/backend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu testsuite/backend/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/testsuite/tools/0000755000000000000000000000000013615535555014456 500000000000000sane-backends-1.0.29/testsuite/tools/Makefile.am0000666000000000000000000000272613615534521016435 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2013 Stéphane Voltz and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. all: @echo "run 'make check' to run tests" SANEDESC = ../../tools/sane-desc$(EXEEXT) TESTFILE = $(srcdir)/data/testfile.desc OUTFILES = *.res DEVICE = test EXTRA_DIST = data/testfile.desc data/ascii.ref data/db.ref data/hal-new.ref \ data/hal.ref data/html-backends-split.ref data/html-mfgs.ref \ data/hwdb.ref data/plist.ref data/statistics.ref \ data/udev+acl.ref data/udev+hwdb.ref data/udev.ref \ data/usermap.ref data/xml.ref CLEANFILES = $(OUTFILES) all: help help: @echo "Use 'make check' to run the tests." check: check.local check.local: @echo "**** Testing $(SANEDESC) with $(TESTFILE)" @for mode in ascii html-backends-split html-mfgs xml statistics usermap db udev udev+acl udev+hwdb hwdb plist hal hal-new; \ do \ $(SANEDESC) -m $$mode -s $(srcdir)/data >$$mode.res ;\ if diff -I "[ 012][0-9]:[0-5][0-9]:[0-6][0-9] 20[0-9][0-9]" \ -I "sane-backends 1\.0\.[0-9]\+\([-0-9a-fgdirty]\+\)\?$$" \ $(srcdir)/data/$$mode.ref $$mode.res ; \ then \ echo "PASS: sane-desc -m $$mode -s $(srcdir)/data"; \ else \ echo "FAIL: sane-desc -m $$mode -s $(srcdir)/data"; \ exit 1 ;\ fi; \ done ;\ echo "================" ;\ echo "All tests passed" ;\ echo "================" sane-backends-1.0.29/testsuite/tools/data/0000755000000000000000000000000013615535555015367 500000000000000sane-backends-1.0.29/testsuite/tools/data/html-mfgs.ref0000666000000000000000000301057513615534521017712 00000000000000 SANE: Supported Devices
SANE

SANE: Supported Devices


The following table summarizes the devices supported by the latest version of sane-backends.

This is only a summary! Please consult the manpages and the author-supplied webpages for more detailed (and usually important) information concerning each backend.

If you have new information or corrections, please file a bug report with as many details as possible. Also please tell us if your scanner isn't mentioned in this list at all.

For an explanation of the tables, see the legend.

Summary

Device type Number of devices
Total Supported Untested Unsupported
Sum Complete Good Basic Minimal
Scanners 2012 1205 417 662 101 25 325 482
Still cameras 5 5 1 2 2 0 0 0
Video Cameras 8 3 0 1 0 2 3 2
Meta backends 2 n/a
APIs 5 n/a

Scanners

Manufacturers: Abaton, Acer Peripherals, Across Technologies, Actown, Adlib, Advent, AGFA, Ambir, Apple, Aries, Artec/Ultima, Avigramm, Avision, Bell and Howell, Bell+Howell, BenQ, Benq (Acer), BlackWidow, Boeder, BrightScan, Brother, C-Channel, Canon, Chinon, Compaq, Compeye, Corex, Cybercom, DCT, Dell, Devcom, Dextra, Dexxa, E-Lux, EDGE, EDT (Electronic Document Technology), Enhans, Epson, Escom, Escort, Fujitsu, Gallery, Genius, Googlegear, Guillemot, Guillemot / Hercules, Hercules, Hewlett-Packard, IBM, IOMagic, Iris, iVina, Kodak, Komodo, KONICA MINOLTA, Kyocera, LEO, Lexmark, Linotype Hell, Logitech, Medion/Lifetec/Tevion/Cytron, Memorex, Micromaxx, Microstar, Microtek, Minolta, Minolta-QMS, Mitsubishi, Mustek, NeatReceipts, NEC, Network, Nikon, Nortek, OKI, Olivetti, Olympus, Optoelectronics, Optrox, Packard Bell, Panasonic, Pentax, PIE, PIOTECH, PLANon, Plustek, Portable Peripheral Co., Ltd., Primax, Prolink, Quato, Reflecta, Relisys, RevScan, Ricoh, Samsung, Scanport, Scanshell, Sceptre, Sharp, Sicos, Siemens, SmartDisk, Spot Technology, Syscan, Tamarack, Targa, TCE, Teco, Tiny, TriGem, Trust, UMAX, Vantas, Visioneer, Viviscan, Vobis, Vuego, Xerox, Yakumo

Manufacturer: Abaton

Model Interface USB id Status Comment Backend Manpage
Scan 300/GS SCSI   Complete All known modes and functions supported abaton
(unmaintained)
sane-abaton
Scan 300/S SCSI   Untested Untested, use with caution abaton
(unmaintained)
sane-abaton

Manufacturer: Acer Peripherals

Comment: Company was renamed to Benq.

Manufacturer: Across Technologies

Model Interface USB id Status Comment Backend Manpage
FS-1130 SCSI   Good FCC ID LUZFS1130 leo
(1.0-10)
sane-leo

Manufacturer: Actown

Model Interface USB id Status Comment Backend Manpage
ACT Scan I 30 SCSI   Untested sub model VM3520A teco1
(1.0-10)
sane-teco1

Manufacturer: Adlib

Model Interface USB id Status Comment Backend Manpage
JetScan630 SCSI   Good   pie
(1.0)
sane-pie
JetScan636PRO SCSI   Untested   pie
(1.0)
sane-pie

Manufacturer: Advent

Link(s): http://www.adventcomputers.co.uk

Model Interface USB id Status Comment Backend Manpage
AW10 USB 0x040a/0x4060 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio

Manufacturer: AGFA

Link(s): http://www.agfa.com/, http://www.agfa.com

Model Interface USB id Status Comment Backend Manpage
Arcus 1200 SCSI   Good Optional transparency unit supported. SnapScan
(1.4)
sane-snapscan
Arcus II SCSI   Good Arcus *II*, not Arcus! microtek
(0.13.1)
sane-microtek
DuoScan SCSI   Basic   microtek
(0.13.1)
sane-microtek
DuoScan f40 USB IEEE-1394 0x06bd/0x02bf Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
DuoScan T2000XL SCSI   Unsupported Unsupported. Same as Microtek ArtixScan 2020? unsupported
(2010-06-09)
?
DuoScan T2500 SCSI IEEE-1384   Unsupported Unsupported. Same as Microtek Artixscan 2500f unsupported
(2010-06-09)
?
Focus Color SCSI   Good 3-pass agfafocus
(unmaintained)
sane-agfafocus
Focus Color Plus SCSI   Good 3-pass agfafocus
(unmaintained)
sane-agfafocus
Focus GS Scanner SCSI   Untested 6 bit gray agfafocus
(unmaintained)
sane-agfafocus
Focus II SCSI   Untested gray only agfafocus
(unmaintained)
sane-agfafocus
Focus Lineart Scanner SCSI   Untested Lineart only? Untested. agfafocus
(unmaintained)
sane-agfafocus
SnapScan SCSI   Good   SnapScan
(1.4)
sane-snapscan
SnapScan 300 SCSI   Good   SnapScan
(1.4)
sane-snapscan
SnapScan 310 SCSI   Good   SnapScan
(1.4)
sane-snapscan
SnapScan 310P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
SnapScan 600 SCSI   Good Optional ADF supported. SnapScan
(1.4)
sane-snapscan
SnapScan 1200P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
SnapScan 1212P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
SnapScan 1212U USB 0x06bd/0x0001 Good   SnapScan
(1.4)
sane-snapscan
SnapScan 1212U_2 USB 0x06bd/0x2061 Good   SnapScan
(1.4)
sane-snapscan
SnapScan 1236s SCSI   Good Optional ADF and transparency unit supported. SnapScan
(1.4)
sane-snapscan
SnapScan 1236u USB 0x06bd/0x0002 Good Optional ADF and transparency unit supported. SnapScan
(1.4)
sane-snapscan
SnapScan e10 USB 0x06bd/0x2093 Good   SnapScan
(1.4)
sane-snapscan
SnapScan e20 USB 0x06bd/0x2091 Good   SnapScan
(1.4)
sane-snapscan
SnapScan e25 USB 0x06bd/0x2095 Good   SnapScan
(1.4)
sane-snapscan
SnapScan e26 USB 0x06bd/0x2097 Good   SnapScan
(1.4)
sane-snapscan
SnapScan e40 USB 0x06bd/0x208d Good   SnapScan
(1.4)
sane-snapscan
SnapScan e42 USB 0x06bd/0x20ff Good   SnapScan
(1.4)
sane-snapscan
SnapScan e50 USB 0x06bd/0x208f Good Optional tranparency unit supported SnapScan
(1.4)
sane-snapscan
SnapScan e52 USB 0x06bd/0x20fd Good Optional tranparency unit supported SnapScan
(1.4)
sane-snapscan
SnapScan e60 USB   Untested   SnapScan
(1.4)
sane-snapscan
SnapScan EZ Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
Snapscan Touch USB 0x06bd/0x0100 Complete   niash
(0.3)
sane-niash
StudioScan SCSI   Good   microtek
(0.13.1)
sane-microtek
StudioScan II SCSI   Good   microtek
(0.13.1)
sane-microtek
StudioScan IIsi SCSI   Good   microtek
(0.13.1)
sane-microtek
Studiostar SCSI   Minimal Is detected but scans are very dark microtek
(0.13.1)
sane-microtek

Manufacturer: Ambir

Model Interface USB id Status Comment Backend Manpage
Visigo A4 USB 0x0a82/0x4600 Complete Rebaged Travelscan 464 plustek
(0.52)
sane-plustek

Manufacturer: Apple

Link(s): http://developer.apple.com/, http://www.apple.com/

Model Interface USB id Status Comment Backend Manpage
Apple Scanner SCSI   Good 4bit, 16 shades of gray apple
(unmaintained)
sane-apple
Color OneScanner SCSI   Minimal truecolor (needs much work) but it scans in non color modes. apple
(unmaintained)
sane-apple
Color OneScanner 600/27 SCSI   Good Rebadged CanoScan 300 canon
(1.12)
sane-canon
OneScanner SCSI   Basic 8bit, 256 shades of gray. The backend needs work especially in the quantization code but it may work. apple
(unmaintained)
sane-apple

Manufacturer: Aries

Model Interface USB id Status Comment Backend Manpage
Scan-It Pro 4800 Parport (SPP, EPP)   Complete use driver-switch mov=2 plustek_pp
(0.43)
sane-plustek_pp

Manufacturer: Artec/Ultima

Link(s): http://www.artecusa.com/

Model Interface USB id Status Comment Backend Manpage
1236 USB USB 0x05d8/0x4001 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
A6000C SCSI   Complete all modes working artec
(unmaintained)
sane-artec
A6000C PLUS SCSI   Complete f/w <= v1.92 basic, f/w >= v1.93 OK artec
(unmaintained)
sane-artec
AM12e+ Parport   Unsupported Unsupported. Chips found inside: AT015, AD9816JS. Maybe similar to SCSI version or as6e? unsupported
(2010-06-09)
?
AM12S SCSI   Complete all modes working artec
(unmaintained)
sane-artec
AS6E Parport   Basic Requires the program 'as6edriver' to run. as6e
(0.5)
sane-as6e
AT3 SCSI   Complete all modes working artec
(unmaintained)
sane-artec
AT6 SCSI   Good Scan head needs to return home before another scan can be started. artec
(unmaintained)
sane-artec
AT12 SCSI   Complete all modes working artec
(unmaintained)
sane-artec
E+ 48U USB 0x05d8/0x4003 Good CIS scanner based on the GT6816 chip. Apparently all other devices are re-badged Artec scanners. artec_eplus48u
(unmaintained)
sane-artec_eplus48u
E+ Pro USB 0x05d8/0x4004 Minimal Works up to 600dpi, but not 1200. Needs better calibration. See bug #310490 artec_eplus48u
(unmaintained)
sane-artec_eplus48u
Ultima 2000 USB 0x05d8/0x4002 Good Works, only product id 0x4002 is supported gt68xx
(1.0-84)
sane-gt68xx
Ultima 2000 (0x4001) USB 0x05d8/0x4001 Unsupported Same name, but different ids: This scanner is not supported. The scanner with product id 0x4002 is supported by the gt68xx backend, however. unsupported
(2010-06-09)
?
Ultima 2000 e+ USB 0x05d8/0x4002 Good Works, however 12 bit mode doesn't seem to be supported gt68xx
(1.0-84)
sane-gt68xx

Manufacturer: Avigramm

Model Interface USB id Status Comment Backend Manpage
Minidoc USB Parport 0x05cb/0x1483 Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Avision

Link(s): http://www.avision.com, http://www.avision.com/

Model Interface USB id Status Comment Backend Manpage
@V2500 USB 0x0638/0x0aa1 Untested   avision
(Build: 296)
sane-avision
@V5100 USB 0x0638/0x0a45 Good 1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors avision
(Build: 296)
sane-avision
AM3000 Series USB 0x0638/0x0a41 Basic MFD avision
(Build: 296)
sane-avision
AV100CS SCSI   Untested   avision
(Build: 296)
sane-avision
AV100IIICS SCSI   Untested   avision
(Build: 296)
sane-avision
AV100S SCSI   Untested   avision
(Build: 296)
sane-avision
AV120 USB 0x0638/0x0a27 Complete sheetfed scanner avision
(Build: 296)
sane-avision
AV121 USB 0x0638/0x0a3c Good sheetfed scanner avision
(Build: 296)
sane-avision
AV122 USB 0x0638/0x0a33 Good sheetfed duplex scanner avision
(Build: 296)
sane-avision
AV122 C2 USB 0x0638/0x0a93 Good sheetfed duplex scanner avision
(Build: 296)
sane-avision
AV210 USB 0x0638/0x0a25 Complete sheetfed scanner avision
(Build: 296)
sane-avision
AV210 USB 0x0638/0x0a24 Complete sheetfed scanner avision
(Build: 296)
sane-avision
AV210C2 USB 0x0638/0x0a3a Complete sheetfed scanner avision
(Build: 296)
sane-avision
AV210C2-G USB 0x0638/0x0a2f Complete sheetfed scanner avision
(Build: 296)
sane-avision
AV210D2+ USB 0x0638/0x1a35 Complete sheetfed scanner avision
(Build: 296)
sane-avision
AV220 USB 0x0638/0x0a23 Complete duplex! sheetfed scanner avision
(Build: 296)
sane-avision
AV220+ USB 0x0638/0x0a2c Complete duplex! sheetfed scanner avision
(Build: 296)
sane-avision
AV220-G USB 0x0638/0x0a94 Complete duplex! sheetfed scanner avision
(Build: 296)
sane-avision
AV220C2 USB 0x0638/0x0a2a Complete duplex! sheetfed scanner avision
(Build: 296)
sane-avision
AV220C2-B USB 0x0638/0x0a2e Complete duplex! sheetfed scanner avision
(Build: 296)
sane-avision
AV220C2-G USB 0x0638/0x0a2d Complete duplex! sheetfed scanner avision
(Build: 296)
sane-avision
AV220D2 USB 0x0638/0x0a2b Complete duplex! sheetfed scanner avision
(Build: 296)
sane-avision
AV240SC SCSI   Untested   avision
(Build: 296)
sane-avision
AV260CS SCSI   Untested   avision
(Build: 296)
sane-avision
AV360CS SCSI   Untested   avision
(Build: 296)
sane-avision
AV363CS SCSI   Untested   avision
(Build: 296)
sane-avision
AV420CS SCSI   Untested   avision
(Build: 296)
sane-avision
AV600U USB 0x0638/0x0a13 Good 1 pass, 600 dpi avision
(Build: 296)
sane-avision
AV600U Plus USB 0x0638/0x0a18 Good   avision
(Build: 296)
sane-avision
AV610 USB 0x0638/0x0a18 Good   avision
(Build: 296)
sane-avision
AV610C2 USB 0x0638/0x0a5e Good   avision
(Build: 296)
sane-avision
AV620CS SCSI   Complete 1 pass, 600 dpi avision
(Build: 296)
sane-avision
AV620CS Plus SCSI   Complete 1 pass, 1200 dpi avision
(Build: 296)
sane-avision
AV630CS SCSI   Complete 1 pass, 1200 dpi avision
(Build: 296)
sane-avision
AV630CSL SCSI   Untested 1 pass, 1200 dpi avision
(Build: 296)
sane-avision
AV660S SCSI   Untested 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV680S SCSI   Untested 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV690U SCSI   Untested 1 pass, 2400 dpi avision
(Build: 296)
sane-avision
AV800S SCSI   Untested 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV810C SCSI   Untested 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV820 SCSI   Untested 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV820C SCSI   Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV820C Plus SCSI   Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV830C SCSI   Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV830C Plus SCSI   Untested 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV880 SCSI   Untested 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV880C SCSI   Untested 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV3200C SCSI   Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV3200SU USB 0x0638/0x0a4e Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV3730SU USB 0x0638/0x0a4f Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV3750SU USB 0x0638/0x0a65 Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV3800C SCSI   Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV3850SU USB 0x0638/0x0a66 Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV6120 SCSI   Untested   avision
(Build: 296)
sane-avision
AV6240 SCSI   Complete 1 pass, ??? dpi avision
(Build: 296)
sane-avision
AV8000S SCSI   Complete 1 pass, 1200 dpi, A3 avision
(Build: 296)
sane-avision
AV8050U USB 0x0638/0x0a4d Complete 1 pass, 1200 dpi, A3 - duplex! avision
(Build: 296)
sane-avision
AV8300 USB 0x0638/0x0a40 Complete 1 pass, 1200 dpi, A3 - duplex! avision
(Build: 296)
sane-avision
AV8350 USB 0x0638/0x0a68 Complete 1 pass, 1200 dpi, A3 - duplex! avision
(Build: 296)
sane-avision
AVA3 SCSI   Basic 1 pass, 600 dpi, A3 avision
(Build: 296)
sane-avision
DS310F Parport   Unsupported Probably not supported. Scanner/printer/copier combination. unsupported
(2010-06-09)
?
DS610CU Scancopier USB 0x0638/0x0a16 Good 1 pass, 600 dpi, A4 avision
(Build: 296)
sane-avision
FB2080E USB 0x0638/0x0a84 Basic 1 pass, 600 dpi, zero-edge avision
(Build: 296)
sane-avision
FB6000E SCSI   Complete 1 pass, 1200 dpi, A3 - duplex! - zero edge! avision
(Build: 296)
sane-avision
FB6080E USB 0x0638/0x0a82 Complete 1 pass, 1200 dpi, A3 - duplex! - zero edge! avision
(Build: 296)
sane-avision
IT8300 USB 0x0638/0x0a61 Good 1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors avision
(Build: 296)
sane-avision
iVina 1600 USB 0x0638/0x0a10 Unsupported GL646 based, to be added to genesys backend. Same as UMAX Astra 4500. unsupported
(2010-06-09)
?
iVina FB1800 USB 0x0638/0x0a20 Unsupported GL646/GL660 based. Same as UMAX Astra 4700. unsupported
(2010-06-09)
?
iVina FB2400 USB   Unsupported Not supported. No chipset information available. Same as UMAX Astra 6700. unsupported
(2010-06-09)
?

Manufacturer: Bell and Howell

Link(s): http://www.bhscanners.com/

Model Interface USB id Status Comment Backend Manpage
COPISCAN II 2135 SCSI   Untested Simplex Scanner bh
(1.0-4)
sane-bh
COPISCAN II 2137(A) SCSI   Good Simplex Scanner (with ACE) - limited testing bh
(1.0-4)
sane-bh
COPISCAN II 2138A SCSI   Untested Simplex Scanner with ACE bh
(1.0-4)
sane-bh
COPISCAN II 3238 SCSI   Untested Simplex Scanner bh
(1.0-4)
sane-bh
COPISCAN II 3338(A) SCSI   Untested Simplex Scanner (with ACE) bh
(1.0-4)
sane-bh
COPISCAN II 6338 SCSI   Good Duplex Scanner with ACE - development model bh
(1.0-4)
sane-bh

Manufacturer: Bell+Howell

Model Interface USB id Status Comment Backend Manpage
2000F SCSI   Basic 1 pass, ??? dpi, A4 avision
(Build: 296)
sane-avision

Manufacturer: BenQ

Link(s): http://www.benq.com/

Model Interface USB id Status Comment Backend Manpage
5550 USB 0x04a5/0x2211 Minimal developing yet hp3900
(0.12)
sane-hp3900

Manufacturer: Benq (Acer)

Link(s): http://www.benq.com
Comment: Formerly Acer Peripherals

Model Interface USB id Status Comment Backend Manpage
300f SCSI   Good   SnapScan
(1.4)
sane-snapscan
310P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
310s SCSI   Good   SnapScan
(1.4)
sane-snapscan
310U USB 0x04a5/0x1a20 Good   SnapScan
(1.4)
sane-snapscan
320P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
320U USB 0x04a5/0x2022 Good   SnapScan
(1.4)
sane-snapscan
340P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
340U USB 0x04a5/0x2022 Good   SnapScan
(1.4)
sane-snapscan
610P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
610plus SCSI   Good   SnapScan
(1.4)
sane-snapscan
610PT Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
610s SCSI   Good   SnapScan
(1.4)
sane-snapscan
620P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
620PT Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
620s SCSI   Good   SnapScan
(1.4)
sane-snapscan
620U USB 0x04a5/0x1a2a Good Optional tranparency unit supported SnapScan
(1.4)
sane-snapscan
620UT USB 0x04a5/0x2040 Good Optional tranparency unit supported SnapScan
(1.4)
sane-snapscan
640BT USB 0x04a5/0x20be Good Optional tranparency unit supported SnapScan
(1.4)
sane-snapscan
640bu USB 0x04a5/0x207e Good   SnapScan
(1.4)
sane-snapscan
640P Parport   Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
640U USB 0x04a5/0x2060 Good Optional tranparency unit supported SnapScan
(1.4)
sane-snapscan
1240 USB 0x04a5/0x20c0 Good Optional tranparency unit supported SnapScan
(1.4)
sane-snapscan
3300 USB 0x04a5/0x20de Good   SnapScan
(1.4)
sane-snapscan
3300 USB 0x04a5/0x20b0 Good   SnapScan
(1.4)
sane-snapscan
4300 USB 0x04a5/0x20de Good   SnapScan
(1.4)
sane-snapscan
4300 USB 0x04a5/0x20b0 Good   SnapScan
(1.4)
sane-snapscan
5000 USB 0x04a5/0x20f8 Good USB ID 0x04a5,0x20f8: Color / grayscale scans working up to 1200 DPI SnapScan
(1.4)
sane-snapscan
5000E USB 0x04a5/0x20fc Basic Same as 5000U, working up to 600 DPI SnapScan
(1.4)
sane-snapscan
5000U USB 0x04a5/0x20fc Basic Same as 5000E, working up to 600 DPI SnapScan
(1.4)
sane-snapscan
5150 USB 0x04a5/0x2137 Basic Calibration algorithm unknown SnapScan
(1.4)
sane-snapscan
5250 USB 0x04a5/0x2137 Basic Same hardware as 5150 (?), Calibration algorithm unknown SnapScan
(1.4)
sane-snapscan
5300 USB 0x04a5/0x20fe Basic Problems with firmware upload reported SnapScan
(1.4)
sane-snapscan
5450 USB 0x04a5/0x211e Unsupported Unsupported. unsupported
(2010-06-09)
?
5550 USB 0x04a5/0x2211 Unsupported Unsupported, see link for details. unsupported
(2010-06-09)
?
5560 USB 0x04a5/0x2311 Unsupported   unsupported
(2010-06-09)
?
7400UT USB 0x04a5/0x2202 Unsupported   unsupported
(2010-06-09)
?
ScanWit 2720s SCSI   Good   SnapScan
(1.4)
sane-snapscan

Manufacturer: BlackWidow

Link(s): http://www.blackwidow.co.uk/

Model Interface USB id Status Comment Backend Manpage
BW4800SP SCSI   Complete rebadged Artec AT3 artec
(unmaintained)
sane-artec

Manufacturer: Boeder

Model Interface USB id Status Comment Backend Manpage
Sm@rtScan Office Parport USB 0x05cb/0x1483 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
Sm@rtScan Slim Edition USB 0x05d8/0x4002 Good Similar to Artec Ultima 2000 gt68xx
(1.0-84)
sane-gt68xx

Manufacturer: BrightScan

Model Interface USB id Status Comment Backend Manpage
BrighScan OpticPro Parport (SPP, EPP)   Complete Reported as P12 plustek_pp
(0.43)
sane-plustek_pp

Manufacturer: Brother

Link(s): http://www.brother.com/

Model Interface USB id Status Comment Backend Manpage
MFC 2500 USB 0x04f9/0x000a Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
MFC 4600 Parport   Unsupported The parport 200x400dpi grayscale version of this scanner is unsupported. Dmitri Katchalov did some investigations on this scanner. If you want to write a backend, contact him (see link). unsupported
(2010-06-09)
?
MFC 7300c Parport USB 0x04f9/0x0106 Unsupported   unsupported
(2010-06-09)
?
MFC 9600 USB 0x04f9/0x0101 Unsupported   unsupported
(2010-06-09)
?

Manufacturer: C-Channel

Link(s): http://www.c-channel.ch/

Model Interface USB id Status Comment Backend Manpage
MoneyPen II USB   Unsupported Probably unsupported. unsupported
(2010-06-09)
?
MyPen Light USB 0x0a93/0x0005 Unsupported See bug #306792 for details. unsupported
(2010-06-09)
?
MyPen Pro USB   Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Canon

Link(s): http://www.canon.com/

Model Interface USB id Status Comment Backend Manpage
Canon Image Formula 101 USB 0x1083/0x162e Unsupported GL846 based, work in progress genesys
(1.0-63)
sane-genesys
CanoScan 300 SCSI   Good 1 pass; flatbed scanner canon
(1.12)
sane-canon
CanoScan 600 SCSI   Good 1 pass; flatbed scanner canon
(1.12)
sane-canon
CanoScan 620S SCSI   Good 1 pass; flatbed scanner canon
(1.12)
sane-canon
CanoScan 700F USB 0x04a9/0x1907 Good GL847 based, resolution from 75 to 4800 dpi genesys
(1.0-63)
sane-genesys
CanoScan 1200S SCSI   Good 1 pass; flatbed scanner canon
(1.12)
sane-canon
CanoScan 2700F SCSI   Good 1 pass; film scanner canon
(1.12)
sane-canon
CanoScan 2710S SCSI   Good 1 pass; 36bit film scanner canon
(1.12)
sane-canon
CanoScan 3000 USB 0x04a9/0x2215 Unsupported GL660+GL646 based. unsupported
(2010-06-09)
?
CanoScan 3000ex USB 0x04a9/0x2215 Unsupported GL660+GL646 based. unsupported
(2010-06-09)
?
CanoScan 3000F USB 0x04a9/0x2215 Unsupported GL660+GL646 based, to be added to genesys backend unsupported
(2010-06-09)
?
CanoScan 4200F USB 0x04a9/0x221b Unsupported Probably unsupported. See link. unsupported
(2010-06-09)
?
CanoScan 4400F USB 0x04a9/0x2228 Unsupported GL843 based, to be added to genesys backend unsupported
(2010-06-09)
?
CanoScan 4400f USB 0x04a9/0x2228 Unsupported GL843 based, to be added to the genesys backend genesys
(1.0-63)
sane-genesys
CanoScan 5000F USB 0x04a9/0x2212 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
CanoScan 5200F USB 0x04a9/0x2217 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
CanoScan 5600F USB 0x04a9/0x1906 Unsupported GL847 based, to be added to the genesys backend genesys
(1.0-63)
sane-genesys
CanoScan 8000F USB 0x04a9/0x220f Unsupported Not supported. See link for more information. With transparency adapter. unsupported
(2010-06-09)
?
CanoScan 8400F USB 0x04a9/0x221e Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
CanoScan 8600F USB 0x04a9/0x2229 Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
CanoScan 8800F USB 0x04a9/0x1901 Complete Flatbed scan. TPU for negatives and slides. All resolutions supported (up to 4800DPI). pixma
(0.17.3)
sane-pixma
CanoScan 9000F USB 0x04a9/0x1908 Complete Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI. pixma
(0.17.3)
sane-pixma
CanoScan 9000F Mark II USB 0x04a9/0x190d Complete Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI. pixma
(0.17.3)
sane-pixma
CanoScan 9900F USB 0x04a9/0x2210 Unsupported Probably unsupported, similar to 8000F. 3200x6400 dpi USB2. With transparency adapter. unsupported
(2010-06-09)
?
CanoScan 9950F USB 0x04a9/0x2219 Unsupported Probably unsupported. unsupported
(2010-06-09)
?
CanoScan D646U USB 0x04a9/0x220b Unsupported Probably not supported. See link for more information and test program. unsupported
(2010-06-09)
?
CanoScan D646U ex USB 0x04a9/0x220b Unsupported Probably not supported. See D646. unsupported
(2010-06-09)
?
CanoScan D660U USB 0x04a9/0x2208 Good TPA scans not perfect plustek
(0.52)
sane-plustek
CanoScan D1230U USB 0x04a9/0x2209 Unsupported Probably not supported. unsupported
(2010-06-09)
?
CanoScan D1250U2 USB 0x04a9/0x220c Unsupported Not supported. However, someone started working on this scanner and some information is available (see link). unsupported
(2010-06-09)
?
CanoScan D2400UF USB 0x04a9/0x220a Unsupported Not supported. See link. unsupported
(2010-06-09)
?
CanoScan FB310P Parport (ECP)   Unsupported Rebadged Avision, different command set canon_pp
(0.33)
sane-canon_pp
CanoScan FB320P Parport (ECP)   Basic Newly added support canon_pp
(0.33)
sane-canon_pp
CanoScan FB320U USB 0x04a9/0x2201 Unsupported Probably not supported. No details known. unsupported
(2010-06-09)
?
CanoScan FB330P Parport (ECP)   Good   canon_pp
(0.33)
sane-canon_pp
CanoScan FB610P Parport (ECP)   Unsupported Rebadged Avision, different command set canon_pp
(0.33)
sane-canon_pp
CanoScan FB620P Parport (ECP)   Basic Newly added support canon_pp
(0.33)
sane-canon_pp
CanoScan FB620U USB 0x04a9/0x2202 Unsupported Probably not supported. Some information is available. unsupported
(2010-06-09)
?
CanoScan FB630P Parport (ECP)   Good   canon_pp
(0.33)
sane-canon_pp
CanoScan fb630u USB 0x04a9/0x2204 Good OK canon630u
(0.1)
sane-canon630u
CanoScan fb636u USB 0x04a9/0x2204 Good OK canon630u
(0.1)
sane-canon630u
CanoScan FB1210U USB 0x04a9/0x2205 Unsupported Not supported. However, a stand-alone program for FreeBSD is available. unsupported
(2010-06-09)
?
CanoScan LiDE 35 USB 0x04a9/0x2213 Good Same ids as LiDE 50. genesys
(1.0-63)
sane-genesys
CanoScan LiDE 40 USB 0x04a9/0x2213 Good Same ids as LiDE 50. genesys
(1.0-63)
sane-genesys
CanoScan LiDE 50 USB 0x04a9/0x2213 Good   genesys
(1.0-63)
sane-genesys
CanoScan LiDE 60 USB 0x04a9/0x221c Good   genesys
(1.0-63)
sane-genesys
CanoScan LiDE 70 USB 0x04a9/0x2225 Unsupported Philips chip. Backend started, see link unsupported
(2010-06-09)
?
CanoScan LiDE 80 USB 0x04a9/0x2214 Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
CanoScan LiDE 90 USB 0x04a9/0x1900 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
CanoScan LiDE 100 USB 0x04a9/0x1904 Complete GL847 based, resolution from 75 to 2400 dpi genesys
(1.0-63)
sane-genesys
CanoScan LiDE 110 USB 0x04a9/0x1909 Complete GL124 based, resolution from 75 to 2400 dpi genesys
(1.0-63)
sane-genesys
CanoScan LiDE 200 USB 0x04a9/0x1905 Complete GL847 based, resolution from 75 to 4800 dpi genesys
(1.0-63)
sane-genesys
CanoScan LiDE 210 USB 0x04a9/0x190a Complete GL124 based, resolution from 75 to 2400 dpi genesys
(1.0-63)
sane-genesys
CanoScan LiDE 500F USB 0x04a9/0x221f Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
CanoScan LiDE 600 USB 0x04a9/0x2224 Unsupported Philips chip. Backend started, see link unsupported
(2010-06-09)
?
CanoScan LiDE 600F USB 0x04a9/0x2224 Unsupported Philips chip. Backend started, see link unsupported
(2010-06-09)
?
CanoScan LiDE25 USB 0x04a9/0x2220 Good   plustek
(0.52)
sane-plustek
CanoScan N340P Parport (ECP)   Good   canon_pp
(0.33)
sane-canon_pp
CanoScan N640P Parport (ECP)   Good   canon_pp
(0.33)
sane-canon_pp
CanoScan N640P ex Parport (ECP)   Good Just an N640P in a different box? canon_pp
(0.33)
sane-canon_pp
CanoScan N650U/N656U USB 0x04a9/0x2206 Complete   plustek
(0.52)
sane-plustek
CanoScan N670U/N676U/LiDE20 USB 0x04a9/0x220d Complete   plustek
(0.52)
sane-plustek
CanoScan N1220U USB 0x04a9/0x2207 Complete   plustek
(0.52)
sane-plustek
CanoScan N1240U/LiDE30 USB 0x04a9/0x220e Complete   plustek
(0.52)
sane-plustek
CR-25 USB 0x1083/0x161a Untested Please test! canon_dr
(38)
sane-canon_dr
CR-55 USB 0x1083/0x160c Untested Please test! canon_dr
(38)
sane-canon_dr
CR-135i USB SCSI 0x1083/0x1639 Untested Please test! canon_dr
(38)
sane-canon_dr
CR-180 USB SCSI 0x04a9/0x1602 Untested Please test! canon_dr
(38)
sane-canon_dr
CR-180II USB SCSI 0x04a9/0x1602 Untested Same as CR-180? Please test! canon_dr
(38)
sane-canon_dr
CR-190i USB SCSI 0x1083/0x162b Untested Please test! canon_dr
(38)
sane-canon_dr
DR-1210C USB 0x1083/0x160f Untested Later version? Please test! canon_dr
(38)
sane-canon_dr
DR-1210C USB 0x04a9/0x2222 Untested Older version? Please test! canon_dr
(38)
sane-canon_dr
DR-2010C USB 0x1083/0x161b Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions. canon_dr
(38)
sane-canon_dr
DR-2010M USB   Untested Mac version of DR-2010C? Please test! canon_dr
(38)
sane-canon_dr
DR-2020U USB   Unsupported GL84x? unsupported
(2010-06-09)
?
DR-2050C USB 0x04a9/0x160a Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration. canon_dr
(38)
sane-canon_dr
DR-2050SP USB 0x04a9/0x160a Untested Same as DR-2050C? Please test! canon_dr
(38)
sane-canon_dr
DR-2080C USB SCSI 0x04a9/0x1601 Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration canon_dr
(38)
sane-canon_dr
DR-2510C USB 0x1083/0x1617 Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions canon_dr
(38)
sane-canon_dr
DR-2510M USB   Untested Mac version of DR-2510C? Please test! canon_dr
(38)
sane-canon_dr
DR-2580C USB SCSI 0x04a9/0x1608 Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration canon_dr
(38)
sane-canon_dr
DR-3010C USB 0x1083/0x161d Good Minimal testing, settings copied from DR-2510C canon_dr
(38)
sane-canon_dr
DR-3020C SCSI   Untested Please test! canon_dr
(38)
sane-canon_dr
DR-3060 SCSI   Untested Please test! canon_dr
(38)
sane-canon_dr
DR-3080C SCSI   Untested Almost works, need to investigate traces from windows driver canon_dr
(38)
sane-canon_dr
DR-3080CII USB SCSI 0x04a9/0x1609 Untested Almost works, need to investigate traces from windows driver canon_dr
(38)
sane-canon_dr
DR-4010C USB 0x1083/0x1614 Good Binary/HT/Gray/Color, Simplex/Duplex working. Multistream unsupported. canon_dr
(38)
sane-canon_dr
DR-4580U USB   Untested Please test! canon_dr
(38)
sane-canon_dr
DR-5010C USB 0x04a9/0x1606 Untested Please test! canon_dr
(38)
sane-canon_dr
DR-5020 SCSI   Good LineArt, Duplex working, cannot read buttons or screen? canon_dr
(38)
sane-canon_dr
DR-5060F SCSI   Basic Grayscale works, LineArt might canon_dr
(38)
sane-canon_dr
DR-5080C SCSI   Untested Please test! canon_dr
(38)
sane-canon_dr
DR-6010C USB SCSI 0x1083/0x1626 Untested Please test! canon_dr
(38)
sane-canon_dr
DR-6030C USB SCSI 0x1083/0x1638 Untested Please test! canon_dr
(38)
sane-canon_dr
DR-6050C USB SCSI 0x1083/0x1624 Good Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode canon_dr
(38)
sane-canon_dr
DR-6080 USB SCSI 0x04a9/0x1607 Good Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported canon_dr
(38)
sane-canon_dr
DR-7080C USB SCSI 0x04a9/0x1604 Untested Please test! canon_dr
(38)
sane-canon_dr
DR-7090C USB SCSI 0x1083/0x1620 Good ADF and flatbed work canon_dr
(38)
sane-canon_dr
DR-7550C USB SCSI 0x1083/0x1623 Untested Assumed compatible with DR-6050C canon_dr
(38)
sane-canon_dr
DR-7580 USB SCSI 0x04a9/0x160b Good Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported canon_dr
(38)
sane-canon_dr
DR-9050C USB SCSI 0x1083/0x1622 Good Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode canon_dr
(38)
sane-canon_dr
DR-9080C USB SCSI 0x04a9/0x1603 Good Simplex, duplex, all resolutions, binary/ht/gray/color, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported canon_dr
(38)
sane-canon_dr
DR-X10C USB SCSI 0x1083/0x1618 Untested Please test! canon_dr
(38)
sane-canon_dr
DR3020 SCSI   Untested Please test! canon_dr
(38)
sane-canon_dr
DR4080U USB   Untested Please test! canon_dr
(38)
sane-canon_dr
FS4000 USB SCSI 0x04a9/0x3042 Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
i-SENSYS MF3010 USB Ethernet 0x04a9/0x2759 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
I-SENSYS MF4320d USB 0x04a9/0x26ee Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
I-SENSYS MF4330d USB 0x04a9/0x26ee Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
i-SENSYS MF4550d USB 0x04a9/0x2736 Good Flatbed and ADF scan. All resolutions supported (up to 600DPI). pixma
(0.17.3)
sane-pixma
i-SENSYS MF5880dn USB 0x04a9/0x26f9 Untested Testers needed! pixma
(0.17.3)
sane-pixma
i-SENSYS MF6680dn USB 0x04a9/0x26fa Untested Testers needed! pixma
(0.17.3)
sane-pixma
imageCLASS D420 USB 0x04a9/0x26ef Complete All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported. pixma
(0.17.3)
sane-pixma
imageCLASS D480 USB 0x04a9/0x26ed Complete All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported. pixma
(0.17.3)
sane-pixma
imageCLASS MF3110 USB 0x04a9/0x2660 Complete All resolutions supported (up to 600DPI). pixma
(0.17.3)
sane-pixma
imageCLASS MF3240 USB 0x04a9/0x2684 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4010 USB 0x04a9/0x26b4 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4018 USB 0x04a9/0x26b4 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4120 USB 0x04a9/0x26a3 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4122 USB 0x04a9/0x26a3 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4140 USB 0x04a9/0x26a3 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4150 USB 0x04a9/0x26a3 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4270 USB 0x04a9/0x26b5 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4350d USB 0x04a9/0x26ee Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4370dn USB 0x04a9/0x26ec Good Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported pixma
(0.17.3)
sane-pixma
imageCLASS MF4380dn USB 0x04a9/0x26ec Good Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported pixma
(0.17.3)
sane-pixma
imageCLASS MF4410 USB 0x04a9/0x2737 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4430 USB 0x04a9/0x2737 Good Flatbed and ADF scan. All resolutions supported (up to 600DPI). ADF empty buggy. pixma
(0.17.3)
sane-pixma
imageCLASS MF4660 USB 0x04a9/0x26b0 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF4690 USB 0x04a9/0x26b0 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF5630 USB 0x04a9/0x264e Untested Testers needed! pixma
(0.17.3)
sane-pixma
imageCLASS MF5730 USB 0x04a9/0x265d Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
imageCLASS MF5750 USB 0x04a9/0x265e Untested Testers needed! pixma
(0.17.3)
sane-pixma
imageCLASS MF5770 USB 0x04a9/0x265f Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI). pixma
(0.17.3)
sane-pixma
imageCLASS MF6500 series USB 0x04a9/0x2686 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF6550 USB 0x04a9/0x2686 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
imageCLASS MF8030 USB 0x04a9/0x2707 Untested Testers needed! pixma
(0.17.3)
sane-pixma
imageCLASS MF8170c USB 0x04a9/0x2659 Untested Testers needed! pixma
(0.17.3)
sane-pixma
imageRUNNER 1020/1024/1025 USB 0x04a9/0x26e6 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
ImageRunner iR1018 USB 0x04a9/0x269d Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
ImageRunner iR1022 USB 0x04a9/0x269d Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
ImageRunner iR1023 USB 0x04a9/0x269d Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
IS 12 USB   Unsupported Probably not supported. Scanner cardridge for Canon inkjet printers. unsupported
(2010-06-09)
?
IS 22 Parport   Unsupported Probably not supported. Scanner cardridge for Canon inkjet printers. unsupported
(2010-06-09)
?
IS 32 USB 0x04a9/0x105d Unsupported Probably not supported. Scanner cardridge for Canon inkjet printers. unsupported
(2010-06-09)
?
IS 52 USB   Unsupported Probably not supported. Scanner cardridge for Canon inkjet printers. unsupported
(2010-06-09)
?
IX-4015 SCSI   Good 1 pass; flatbed scanner canon
(1.12)
sane-canon
laserBase MF5650 USB 0x04a9/0x264f Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA E500 USB 0x04a9/0x1758 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA E510 USB 0x04a9/0x1761 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA E600 USB 0x04a9/0x175a Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA E610 USB 0x04a9/0x1767 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MG2100 Series USB 0x04a9/0x1751 Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MG2200 Series USB 0x04a9/0x1760 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MG3100 Series USB WLAN 0x04a9/0x1752 Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MG3200 Series USB 0x04a9/0x1762 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MG4100 Series USB 0x04a9/0x1753 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MG4200 Series USB 0x04a9/0x1763 Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MG5100 Series USB 0x04a9/0x1748 Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MG5200 Series USB 0x04a9/0x1749 Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MG5300 Series USB 0x04a9/0x1754 Complete All resolutions supported (up to 2400DPI). pixma
(0.17.3)
sane-pixma
PIXMA MG5400 Series USB 0x04a9/0x1764 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MG6100 Series USB 0x04a9/0x174a Complete All resolutions supported (up to 2400 DPI) pixma
(0.17.3)
sane-pixma
PIXMA MG6200 Series USB 0x04a9/0x1755 Complete All resolutions supported (up to 4800 DPI) pixma
(0.17.3)
sane-pixma
PIXMA MG6300 Series USB Ethernet 0x04a9/0x1765 Complete All resolutions supported (up to 2400DPI). pixma
(0.17.3)
sane-pixma
PIXMA MG8100 Series USB 0x04a9/0x174b Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MG8200 Series USB Ethernet 0x04a9/0x1756 Complete All resolutions supported (up to 4800DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP110 USB 0x04a9/0x1700 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
PIXMA MP130 USB 0x04a9/0x1701 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
PIXMA MP140 USB 0x04a9/0x172b Complete All resolutions supported (up to 600 DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP150 USB 0x04a9/0x1709 Good   pixma
(0.17.3)
sane-pixma
PIXMA MP160 USB 0x04a9/0x1714 Basic   pixma
(0.17.3)
sane-pixma
PIXMA MP170 USB 0x04a9/0x170a Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP180 USB 0x04a9/0x1715 Basic   pixma
(0.17.3)
sane-pixma
PIXMA MP190 USB 0x04a9/0x1734 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP210 USB 0x04a9/0x1721 Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP220 USB 0x04a9/0x1722 Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP230 USB 0x04a9/0x175f Complete All resolutions supported (up to 600DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP240 USB 0x04a9/0x1732 Complete All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP250 USB 0x04a9/0x173a Complete All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP260 USB 0x04a9/0x1733 Complete All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP270 USB 0x04a9/0x173b Complete All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP280 USB 0x04a9/0x1746 Good All resolutions supported (up to 600DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP360 USB 0x04a9/0x263c Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP370 USB 0x04a9/0x263d Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP375R USB 0x04a9/0x263f Untested Same protocol as Pixma MP360/370/390? Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MP390 USB 0x04a9/0x263e Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP450 USB 0x04a9/0x170b Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP460 USB 0x04a9/0x1716 Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP470 USB 0x04a9/0x1723 Complete All resolutions supported (up to 2400DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP480 USB 0x04a9/0x1731 Complete All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP490 USB 0x04a9/0x173c Complete All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP493 USB 0x04a9/0x1757 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MP495 USB 0x04a9/0x1747 Untested Same protocol as Pixma MP280? Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MP500 USB 0x04a9/0x170c Good   pixma
(0.17.3)
sane-pixma
PIXMA MP510 USB 0x04a9/0x1717 Complete All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP520 USB 0x04a9/0x1724 Complete All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP530 USB 0x04a9/0x1712 Good   pixma
(0.17.3)
sane-pixma
PIXMA MP540 USB 0x04a9/0x1730 Complete All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP550 USB 0x04a9/0x173d Complete All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP560 USB 0x04a9/0x173e Complete All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP600 USB 0x04a9/0x1718 Complete All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP600R USB Ethernet 0x04a9/0x1719 Complete All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP610 USB 0x04a9/0x1725 Complete All resolutions supported (up to 4800DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP620 USB Ethernet 0x04a9/0x172f Complete All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP630 USB 0x04a9/0x172e Complete All resolutions supported (up to 4800DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP640 USB Ethernet 0x04a9/0x173f Complete All resolutions supported (up to 4800DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP700 USB 0x04a9/0x2630 Complete All resolutions supported (flatbed color up to 1200DPI, grayscale up to 600DPI). pixma
(0.17.3)
sane-pixma
PIXMA MP710 USB 0x04a9/0x264d Complete All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MP730 USB 0x04a9/0x262f Good Flatbed color up to 1200DPI, grayscale up to 600DPI. ADF scan to be confirmed. pixma
(0.17.3)
sane-pixma
PIXMA MP740 USB 0x04a9/0x264c Untested Same protocol as Pixma MP710? Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MP750 USB 0x04a9/0x1706 Minimal No grayscale. Canceling scan in ADF mode doesn't eject the paper! pixma
(0.17.3)
sane-pixma
PIXMA MP760 USB 0x04a9/0x1708 Minimal No grayscale. The scanner sometimes hangs! pixma
(0.17.3)
sane-pixma
PIXMA MP770 USB 0x04a9/0x1708 Minimal No grayscale. The scanner sometimes hangs! pixma
(0.17.3)
sane-pixma
PIXMA MP780 USB 0x04a9/0x1707 Minimal No grayscale. The scanner sometimes hangs! pixma
(0.17.3)
sane-pixma
PIXMA MP790 USB 0x04a9/0x1707 Minimal No grayscale. The scanner sometimes hangs! pixma
(0.17.3)
sane-pixma
PIXMA MP800 USB 0x04a9/0x170d Complete All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI. pixma
(0.17.3)
sane-pixma
PIXMA MP800R USB 0x04a9/0x170e Complete All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI. pixma
(0.17.3)
sane-pixma
PIXMA MP810 USB 0x04a9/0x171a Complete All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI. pixma
(0.17.3)
sane-pixma
PIXMA MP830 USB 0x04a9/0x1713 Complete All resolutions supported up to 2400DPI. Flatbed, ADF simplex and Duplex supported. pixma
(0.17.3)
sane-pixma
PIXMA MP960 USB 0x04a9/0x171b Complete All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI. pixma
(0.17.3)
sane-pixma
PIXMA MP970 USB Ethernet 0x04a9/0x1726 Complete All resolutions supported (up to 4800DPI). Full TPU support (negative and slides) at 24 or 48 bits. pixma
(0.17.3)
sane-pixma
PIXMA MP980 USB Ethernet 0x04a9/0x172d Complete Working fine at all resolutions. pixma
(0.17.3)
sane-pixma
PIXMA MP990 USB Ethernet 0x04a9/0x1740 Complete Working fine at all resolutions. pixma
(0.17.3)
sane-pixma
PIXMA MX300 USB 0x04a9/0x1727 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI) pixma
(0.17.3)
sane-pixma
PIXMA MX310 USB 0x04a9/0x1728 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MX320 USB 0x04a9/0x1736 Untested Same protocol as Pixma Generation 3? Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX330 USB 0x04a9/0x1737 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MX340 USB 0x04a9/0x1741 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MX350 USB Ethernet 0x04a9/0x1742 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI) pixma
(0.17.3)
sane-pixma
PIXMA MX360 USB 0x04a9/0x174d Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy. pixma
(0.17.3)
sane-pixma
PIXMA MX370 Series USB 0x04a9/0x1759 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI). pixma
(0.17.3)
sane-pixma
PIXMA MX390 Series USB 0x04a9/0x1766 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX410 USB Ethernet 0x04a9/0x174e Untested Same protocol as Pixma MX420? Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX420 USB Ethernet 0x04a9/0x174f Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy. pixma
(0.17.3)
sane-pixma
PIXMA MX430 Series USB Ethernet 0x04a9/0x175b Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX450 Series USB 0x04a9/0x1768 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX510 Series USB Ethernet 0x04a9/0x175c Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX520 Series USB 0x04a9/0x1769 Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX700 USB Ethernet 0x04a9/0x1729 Complete Flatbed and ADF scan. All resolutions supported (up to 2400DPI) pixma
(0.17.3)
sane-pixma
PIXMA MX710 Series USB Ethernet 0x04a9/0x175d Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX720 Series USB 0x04a9/0x176a Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX850 USB Ethernet 0x04a9/0x172c Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported. pixma
(0.17.3)
sane-pixma
PIXMA MX860 USB Ethernet 0x04a9/0x1735 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported. pixma
(0.17.3)
sane-pixma
PIXMA MX870 USB Ethernet 0x04a9/0x1743 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. pixma
(0.17.3)
sane-pixma
PIXMA MX880 Series USB Ethernet 0x04a9/0x1750 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. pixma
(0.17.3)
sane-pixma
PIXMA MX882 USB Ethernet 0x04a9/0x1750 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. pixma
(0.17.3)
sane-pixma
PIXMA MX885 USB Ethernet 0x04a9/0x1750 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. pixma
(0.17.3)
sane-pixma
PIXMA MX890 Series USB Ethernet 0x04a9/0x175e Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. pixma
(0.17.3)
sane-pixma
PIXMA MX920 Series USB 0x04a9/0x176b Untested Testers needed! pixma
(0.17.3)
sane-pixma
PIXMA MX7600 USB Ethernet 0x04a9/0x171c Complete Flatbed and ADF scan. All resolutions supported (up to 4800DPI) pixma
(0.17.3)
sane-pixma

Manufacturer: Chinon

Model Interface USB id Status Comment Backend Manpage
DS-3000 Parport Serial Port   Unsupported Unsupported at the moment, but a backend is in preparation. See link. unsupported
(2010-06-09)
?

Manufacturer: Compaq

Link(s): http://www.compaq.com/

Model Interface USB id Status Comment Backend Manpage
S4-100 USB 0x049f/0x001a Complete Identical to UMAX 3400 plustek
(0.52)
sane-plustek
S200 USB 0x049f/0x0021 Unsupported Not supported. 2400x1200 dpi. One bulk-in, one bulk-out and one interrupt endpoint. Type-number: U0001-HB21, another type nr on the inside: 75100512-00 unsupported
(2010-06-09)
?

Manufacturer: Compeye

Model Interface USB id Status Comment Backend Manpage
Simplex 1236C Parport USB 0x05cb/0x1483 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Corex

Link(s): http://www.cardscan.com/

Model Interface USB id Status Comment Backend Manpage
600c USB 0x08f0/0x0002 Basic 4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner cardscan
(2)
sane-cardscan
800c USB 0x08f0/0x0005 Good 4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner cardscan
(2)
sane-cardscan
Cardscan 500 USB 0x08f0/0x0001 Unsupported Probably not supported. Businesscard reader. unsupported
(2010-06-09)
?
Cardscan 700 C USB 0x08f0/0x0004 Unsupported Probably not supported. unsupported
(2010-06-09)
?

Manufacturer: Cybercom

Model Interface USB id Status Comment Backend Manpage
9352 Parport (EPP)   Good CIS scanner mustek_pp
(13)
sane-mustek_pp

Manufacturer: DCT

Link(s): http://www.docucap.com/
Comment: Successor of Syscan in the USA

Model Interface USB id Status Comment Backend Manpage
DocketPort 487 USB 0x1dcc/0x4810 Basic All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally. genesys
(1.0-63)
sane-genesys

Manufacturer: Dell

Link(s): http://www.dell.com/

Model Interface USB id Status Comment Backend Manpage
922 USB 0x413c/0x5109 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
1600n Ethernet USB 0x413c/0x5250 Basic Supports colour and monochrome scans over ethernet (USB not supported) dell1600n_net ?
A920 USB 0x413c/0x5105 Good Relabelled X11xx model lexmark
(1.0-0)
sane-lexmark
A940 USB 0x413c/0x5106 Unsupported Probably rebadged Lexmark X5150. May work with sane-lexmark? See bug #312130 unsupported
(2010-06-09)
?
A960 USB 0x413c/0x5107 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
Dell MFP Laser Printer 1815dn USB 0x413c/0x5124 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp

Manufacturer: Devcom

Link(s): http://www.blackwidow.co.uk/

Model Interface USB id Status Comment Backend Manpage
9630S SCSI   Untested   pie
(1.0)
sane-pie
9636PRO SCSI   Good   pie
(1.0)
sane-pie
9636S SCSI   Untested   pie
(1.0)
sane-pie

Manufacturer: Dextra

Model Interface USB id Status Comment Backend Manpage
DF-600P SCSI   Good sub model VM3510 teco1
(1.0-10)
sane-teco1
DF-1200T+ SCSI   Untested sub model VM3530+ teco1
(1.0-10)
sane-teco1
DF-4830T SCSI   Untested sub model VM4542 teco1
(1.0-10)
sane-teco1
DF-9624 SCSI   Untested sub model VM6530+ teco1
(1.0-10)
sane-teco1

Manufacturer: Dexxa

Link(s): http://www.dexxa.com

Model Interface USB id Status Comment Backend Manpage
4800 Parport   Basic Requires the program 'as6edriver' to run. as6e
(0.5)
sane-as6e

Manufacturer: E-Lux

Comment: E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX

Model Interface USB id Status Comment Backend Manpage
j-6121 Parport   Unsupported Probably unsupported. Sold 1998. Same as E-Lux j-6121. unsupported
(2010-06-09)
?

Manufacturer: EDGE

Model Interface USB id Status Comment Backend Manpage
KTX-9600US SCSI   Untested no feedback umax
(1.0-41)
sane-umax

Manufacturer: EDT (Electronic Document Technology)

Link(s): http://www.bizcardreader.com/

Model Interface USB id Status Comment Backend Manpage
BizCardReader 900C USB 0x0a53/0x5001 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Enhans

Comment: E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX

Model Interface USB id Status Comment Backend Manpage
j-6121 Parport   Unsupported Probably unsupported. Sold 1998. Same as E-Lux j-6121. unsupported
(2010-06-09)
?
M-3630 A Parport   Unsupported Probably unsupported. unsupported
(2010-06-09)
?

Manufacturer: Epson

Link(s): http://www.epson.com/, http://www.epson.com

Model Interface USB id Status Comment Backend Manpage
Actionscanner II parallel SCSI   Good overseas version of the GT-5000 epson2
(1.0.124)
sane-epson2
Actionscanner II SCSI Parport   Good US version of GT-5000 epson
(unmaintained)
sane-epson
AcuLaser CX11 USB 0x04b8/0x0815 Good overseas version of the LP-A500 epson2
(1.0.124)
sane-epson2
AcuLaser CX11 USB 0x04b8/0x0815 Good   epson
(unmaintained)
sane-epson
AcuLaser CX11NF USB Network 0x04b8/0x0815 Good network interface supported
AcuLaser CX11 with network interface and fax
epson2
(1.0.124)
sane-epson2
AcuLaser CX11NF USB 0x04b8/0x0815 Good   epson
(unmaintained)
sane-epson
AcuLaser CX21 USB 0x04b8/0x0835 Good network interface probably supported epson2
(1.0.124)
sane-epson2
Artisan 700 USB Network 0x04b8/0x0846 Good network interface supported
all-in-one
overseas version of the EP-801A
epson2
(1.0.124)
sane-epson2
Artisan 710 Series USB 0x04b8/0x0852 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Artisan 800 USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
overseas version of the EP-901A
epson2
(1.0.124)
sane-epson2
Artisan 810 Series USB 0x04b8/0x0853 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
CC-500L USB 0x04b8/0x010d Unsupported all-in-one epson2
(1.0.124)
sane-epson2
CC-550L USB 0x04b8/0x011a Unsupported all-in-one epson2
(1.0.124)
sane-epson2
CC-570L USB 0x04b8/0x0802 Good all-in-one epson2
(1.0.124)
sane-epson2
CC-600PX USB 0x04b8/0x0801 Good all-in-one epson2
(1.0.124)
sane-epson2
CC-700 USB 0x04b8/0x0108 Unsupported all-in-one epson2
(1.0.124)
sane-epson2
CX-3200 USB 0x04b8/0x0802 Good   epson
(unmaintained)
sane-epson
CX-3600 USB 0x04b8/0x080e Good   epson
(unmaintained)
sane-epson
CX-3650 USB 0x04b8/0x080e Good   epson
(unmaintained)
sane-epson
CX-3700 USB 0x04b8/0x0818 Good   epson
(unmaintained)
sane-epson
CX-3800 USB 0x04b8/0x0818 Good   epson
(unmaintained)
sane-epson
CX-4200 USB 0x04b8/0x0820 Good   epson
(unmaintained)
sane-epson
CX-4600 USB 0x04b8/0x080d Good   epson
(unmaintained)
sane-epson
CX-4800 USB 0x04b8/0x0819 Good   epson
(unmaintained)
sane-epson
CX-5000 USB 0x04b8/0x082b Good   epson
(unmaintained)
sane-epson
CX-5200 USB 0x04b8/0x0801 Good   epson
(unmaintained)
sane-epson
CX-5400 USB 0x04b8/0x0808 Good   epson
(unmaintained)
sane-epson
CX-5400 USB 0x04b8/0x0801 Good   epson
(unmaintained)
sane-epson
CX-6300 USB 0x04b8/0x0805 Good   epson
(unmaintained)
sane-epson
CX-6400 USB 0x04b8/0x0805 Good   epson
(unmaintained)
sane-epson
CX-6500 USB 0x04b8/0x0813 Good   epson
(unmaintained)
sane-epson
CX-6600 USB 0x04b8/0x0813 Good   epson
(unmaintained)
sane-epson
DX-3800 USB 0x04b8/0x0818 Good   epson
(unmaintained)
sane-epson
DX-3850 USB 0x04b8/0x0818 Good   epson
(unmaintained)
sane-epson
DX-4050 USB 0x04b8/0x082f Good   epson
(unmaintained)
sane-epson
DX-5000 USB 0x04b8/0x082b Good   epson
(unmaintained)
sane-epson
DX-5050 USB 0x04b8/0x082b Good   epson
(unmaintained)
sane-epson
DX-6000 USB 0x04b8/0x082e Good   epson
(unmaintained)
sane-epson
DX-7400 USB 0x04b8/0x0838 Good   epson
(unmaintained)
sane-epson
EP-702A USB 0x04b8/0x0850 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
EP-801A USB Network 0x04b8/0x0846 Good network interface supported
all-in-one
epson2
(1.0.124)
sane-epson2
EP-802A USB 0x04b8/0x0852 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
EP-901A USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
epson2
(1.0.124)
sane-epson2
EP-901F USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
epson2
(1.0.124)
sane-epson2
EP-902A USB 0x04b8/0x0853 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
ES-300C SCSI parallel   Good overseas version of the GT-6000 epson2
(1.0.124)
sane-epson2
ES-300C SCSI Parport   Good US version of GT-6000 epson
(unmaintained)
sane-epson
ES-300GS SCSI   Good   epson2
(1.0.124)
sane-epson2
ES-300GS SCSI   Good   epson
(unmaintained)
sane-epson
ES-600C parallel   Good overseas version of the GT-5400 epson2
(1.0.124)
sane-epson2
ES-600C Parport   Good US version of GT-6500 epson
(unmaintained)
sane-epson
ES-800C SCSI   Good overseas version of the GT-8000 epson2
(1.0.124)
sane-epson2
ES-1000C ?   Unsupported overseas version of the GT-8500 epson2
(1.0.124)
sane-epson2
ES-1200C parallel   Good overseas version of the GT-9000 epson2
(1.0.124)
sane-epson2
ES-1200C Parport   Good US version of GT-9000 epson
(unmaintained)
sane-epson
ES-2000 SCSI USB 0x04b8/0x0107 Complete IEEE1394 untested epson2
(1.0.124)
sane-epson2
ES-2200 SCSI USB 0x04b8/0x010e Complete IEEE1394 untested epson2
(1.0.124)
sane-epson2
ES-6000 SCSI   Good   epson2
(1.0.124)
sane-epson2
ES-6000H SCSI   Good IEEE1394 untested epson2
(1.0.124)
sane-epson2
ES-6000HS SCSI   Good IEEE1394 untested epson2
(1.0.124)
sane-epson2
ES-7000H SCSI USB 0x04b8/0x0126 Good network interface unsupported
IEEE1394 untested
epson2
(1.0.124)
sane-epson2
ES-8000 SCSI   Untested   epson2
(1.0.124)
sane-epson2
ES-8500 SCSI USB 0x04b8/0x0109 Good IEEE1394 untested epson2
(1.0.124)
sane-epson2
ES-8500 SCSI   Good   epson
(unmaintained)
sane-epson
ES-9000H SCSI   Good IEEE1394 untested epson2
(1.0.124)
sane-epson2
ES-10000G USB 0x04b8/0x0129 Good network interface unsupported
IEEE1394 untested
epson2
(1.0.124)
sane-epson2
ES-D400 USB 0x04b8/0x0136 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
ES-H300 USB 0x04b8/0x012b Good network interface probably supported epson2
(1.0.124)
sane-epson2
ES-H7200 USB Ethernet 0x04b8/0x0138 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Expression 636 SCSI   Complete overseas version of the GT-9500 epson2
(1.0.124)
sane-epson2
Expression 636 SCSI   Complete US version of GT-9500 epson
(unmaintained)
sane-epson
Expression 800 SCSI   Complete overseas version of the GT-9600 epson2
(1.0.124)
sane-epson2
Expression 800 SCSI   Complete   epson
(unmaintained)
sane-epson
Expression 836XL SCSI   Untested overseas version of the ES-8000 epson2
(1.0.124)
sane-epson2
Expression 1600 SCSI USB 0x04b8/0x0107 Complete IEEE1394 untested
overseas version of the ES-2000
epson2
(1.0.124)
sane-epson2
Expression 1600 SCSI USB IEEE-1394 0x04b8/0x0107 Complete   epson
(unmaintained)
sane-epson
Expression 1640XL SCSI USB 0x04b8/0x0109 Good IEEE1394 untested
overseas version of the ES-8500
epson2
(1.0.124)
sane-epson2
Expression 1680 SCSI USB 0x04b8/0x010e Complete IEEE1394 untested
overseas version of the ES-2200
epson2
(1.0.124)
sane-epson2
Expression 1680 SCSI USB IEEE-1394 0x04b8/0x010e Complete   epson
(unmaintained)
sane-epson
Expression 1680 Pro SCSI USB   Untested IEEE1394 option epson2
(1.0.124)
sane-epson2
Expression 1680XL Pro SCSI USB   Untested   epson2
(1.0.124)
sane-epson2
Expression 10000XL USB 0x04b8/0x0129 Good network interface probably supported
IEEE1394 untested
overseas version of the ES-10000G
epson2
(1.0.124)
sane-epson2
Expression 10000XL Graphic Arts USB IEEE1394   Untested network interface probably supported epson2
(1.0.124)
sane-epson2
Expression 10000XL Photo USB IEEE1394   Untested network interface probably supported epson2
(1.0.124)
sane-epson2
F-3200 USB IEEE1394 0x04b8/0x080a Unsupported Film scanner epson2
(1.0.124)
sane-epson2
F-3200 Photo USB IEEE1394   Unsupported   epson2
(1.0.124)
sane-epson2
FilmScan 200 SCSI   Minimal will be supported epson2
(1.0.124)
sane-epson2
GT-1500 USB 0x04b8/0x0133 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-2200 USB 0x04b8/0x0102 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
GT-2200 USB 0x04b8/0x0102 Unsupported   epson2
(1.0.124)
sane-epson2
GT-2500 USB 0x04b8/0x012b Good network interface probably supported
overseas version of the ES-H300
epson2
(1.0.124)
sane-epson2
GT-4000 ?   Untested   epson2
(1.0.124)
sane-epson2
GT-5000 parallel SCSI   Good   epson2
(1.0.124)
sane-epson2
GT-5000 SCSI Parport   Good   epson
(unmaintained)
sane-epson
GT-5400 parallel   Good   epson2
(1.0.124)
sane-epson2
GT-5500 SCSI   Good   epson2
(1.0.124)
sane-epson2
GT-5500 SCSI   Good   epson
(unmaintained)
sane-epson
GT-6000 SCSI Parport   Good   epson2
(1.0.124)
sane-epson2
GT-6000 SCSI Parport   Good   epson
(unmaintained)
sane-epson
GT-6500 parallel   Good overseas version of the GT-5400 epson2
(1.0.124)
sane-epson2
GT-6500 Parport   Good   epson
(unmaintained)
sane-epson
GT-6600U USB 0x04b8/0x0103 Complete   epson2
(1.0.124)
sane-epson2
GT-6700U USB 0x04b8/0x010c Complete   epson2
(1.0.124)
sane-epson2
GT-7000 SCSI   Good   epson
(unmaintained)
sane-epson
GT-7000S SCSI   Complete   epson2
(1.0.124)
sane-epson2
GT-7000U USB 0x04b8/0x0101 Complete   epson2
(1.0.124)
sane-epson2
GT-7200U USB 0x04b8/0x010f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-7300U USB 0x04b8/0x011d Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-7400U USB 0x04b8/0x0120 Unsupported supported by the snapscan backend epson2
(1.0.124)
sane-epson2
GT-7600S SCSI   Complete SCSI version of the GT-7600U epson2
(1.0.124)
sane-epson2
GT-7600U USB 0x04b8/0x0104 Complete USB version of the GT-7600S epson2
(1.0.124)
sane-epson2
GT-7600UF USB 0x04b8/0x0104 Complete GT-7600U with TPU option bundled epson2
(1.0.124)
sane-epson2
GT-7700U USB 0x04b8/0x010b Complete   epson2
(1.0.124)
sane-epson2
GT-8000 SCSI   Good   epson2
(1.0.124)
sane-epson2
GT-8000 SCSI   Good   epson
(unmaintained)
sane-epson
GT-8200U USB 0x04b8/0x0110 Complete   epson2
(1.0.124)
sane-epson2
GT-8200UF USB 0x04b8/0x0110 Good   epson2
(1.0.124)
sane-epson2
GT-8300UF USB 0x04b8/0x011e Complete   epson2
(1.0.124)
sane-epson2
GT-8400UF USB 0x04b8/0x011f Unsupported   epson2
(1.0.124)
sane-epson2
GT-8500 ?   Untested   epson2
(1.0.124)
sane-epson2
GT-8700 SCSI USB 0x04b8/0x010a Complete   epson2
(1.0.124)
sane-epson2
GT-8700F SCSI USB 0x04b8/0x010a Good GT-8700U with TPU option bundled epson2
(1.0.124)
sane-epson2
GT-9000 parallel   Good   epson2
(1.0.124)
sane-epson2
GT-9300UF USB 0x04b8/0x011b Complete   epson2
(1.0.124)
sane-epson2
GT-9400UF USB 0x04b8/0x0116 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-9500 SCSI   Complete   epson2
(1.0.124)
sane-epson2
GT-9600 SCSI   Complete   epson2
(1.0.124)
sane-epson2
GT-9700F USB 0x04b8/0x0112 Complete IEEE1394 untested epson2
(1.0.124)
sane-epson2
GT-9800F USB 0x04b8/0x011c Complete IEEE1394 untested epson2
(1.0.124)
sane-epson2
GT-10000 SCSI   Good overseas version of the ES-6000 epson2
(1.0.124)
sane-epson2
GT-10000+ SCSI   Good IEEE1394 untested
overseas version of the ES-6000H
epson2
(1.0.124)
sane-epson2
GT-12000 SCSI   Untested overseas version of the ES-8000 epson2
(1.0.124)
sane-epson2
GT-15000 SCSI USB 0x04b8/0x0126 Good IEEE1394 untested
overseas version of the ES-7000H
epson2
(1.0.124)
sane-epson2
GT-20000 USB Ethernet 0x04b8/0x0138 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-30000 SCSI   Good IEEE1394 untested
overseas version of the ES-9000H
epson2
(1.0.124)
sane-epson2
GT-D1000 USB 0x04b8/0x0133 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F500 USB 0x04b8/0x0121 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F520 USB 0x04b8/0x0122 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F550 USB 0x04b8/0x0121 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F570 USB 0x04b8/0x0122 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F600 USB 0x04b8/0x0118 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F650 USB 0x04b8/0x012d Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F670 USB 0x04b8/0x012e Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F700 USB 0x04b8/0x012f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-F720 USB 0x04b8/0x0131 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-S50 USB 0x04b8/0x0137 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-S80 USB 0x04b8/0x0136 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-S600 USB 0x04b8/0x012d Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-S620 USB 0x04b8/0x0131 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-X700 USB 0x04b8/0x0128 Complete IEEE1394 untested epson2
(1.0.124)
sane-epson2
GT-X750 USB 0x04b8/0x0119 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-X770 USB 0x04b8/0x0130 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-X800 USB 0x04b8/0x012a Complete film area guide mode not supported
IEEE1394 untested
epson2
(1.0.124)
sane-epson2
GT-X820 USB 0x04b8/0x013a Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
GT-X900 USB 0x04b8/0x012c Good IEEE1394 untested epson2
(1.0.124)
sane-epson2
GT-X970 USB 0x04b8/0x0135 Good IEEE1394 untested epson2
(1.0.124)
sane-epson2
LP-7900CS ?   Untested business all-in-one; scanner is a ES-7000H epson2
(1.0.124)
sane-epson2
LP-9000CCH ?   Untested business all-in-one; scanner is a ES-9000H epson2
(1.0.124)
sane-epson2
LP-9000CCS ?   Untested business all-in-one; scanner is a ES-7000H epson2
(1.0.124)
sane-epson2
LP-9000CFH ?   Untested business all-in-one; scanner is a ES-9000H epson2
(1.0.124)
sane-epson2
LP-9500CCS ?   Untested business all-in-one; scanner is a ES-7000H epson2
(1.0.124)
sane-epson2
LP-9500CFH ?   Untested business all-in-one; scanner is a ES-9000H epson2
(1.0.124)
sane-epson2
LP-9500CH2 ?   Untested business all-in-one; scanner is a ES-9000H epson2
(1.0.124)
sane-epson2
LP-9800CCH ?   Untested business all-in-one; scanner is a ES-9000H epson2
(1.0.124)
sane-epson2
LP-9800CCS ?   Untested business all-in-one; scanner is a ES-7000H epson2
(1.0.124)
sane-epson2
LP-9800CFH ?   Untested business all-in-one; scanner is a ES-9000H epson2
(1.0.124)
sane-epson2
LP-A500 USB Network 0x04b8/0x0815 Good network interface supported
business all-in-one
epson2
(1.0.124)
sane-epson2
LP-M5000 USB 0x04b8/0x0843 Good network interface probably supported
business all-in-one
epson2
(1.0.124)
sane-epson2
LP-M5500 USB 0x04b8/0x0817 Good network interface probably supported
business all-in-one
epson2
(1.0.124)
sane-epson2
LP-M5500F USB 0x04b8/0x0817 Good network interface probably supported
business all-in-one
LP-M5500 with the fax option bundled
epson2
(1.0.124)
sane-epson2
LP-M5600 USB 0x04b8/0x0833 Good network interface probably supported
business all-in-one
epson2
(1.0.124)
sane-epson2
LP-M6000 USB 0x04b8/0x0834 Good network interface probably supported
business all-in-one
epson2
(1.0.124)
sane-epson2
ME 200 USB 0x04b8/0x0830 Good all-in-one epson2
(1.0.124)
sane-epson2
ME 300 USB 0x04b8/0x0841 Good all-in-one
overseas version of the PX-401A
epson2
(1.0.124)
sane-epson2
ME OFFICE 510 USB 0x04b8/0x084f Good all-in-one epson2
(1.0.124)
sane-epson2
ME Office 600F USB 0x04b8/0x0848 Good all-in-one epson2
(1.0.124)
sane-epson2
ME OFFICE 650FN Series USB 0x04b8/0x0854 Good all-in-one epson2
(1.0.124)
sane-epson2
ME Office 700FW USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
epson2
(1.0.124)
sane-epson2
Perfection 600 SCSI   Good OK, SCSI-ID=EPSON Perfection600 umax
(1.0-41)
sane-umax
Perfection 610 USB 0x04b8/0x0103 Complete overseas version of the GT-6600U epson2
(1.0.124)
sane-epson2
Perfection 610 USB 0x04b8/0x0103 Complete   epson
(unmaintained)
sane-epson
Perfection 636 SCSI   Complete   epson
(unmaintained)
sane-epson
Perfection 636S SCSI   Complete overseas version of the GT-7000S epson2
(1.0.124)
sane-epson2
Perfection 636S SCSI   Complete US version of GT-7000 epson
(unmaintained)
sane-epson
Perfection 636U USB 0x04b8/0x0101 Complete overseas version of the GT-7000U epson2
(1.0.124)
sane-epson2
Perfection 636U USB 0x04b8/0x0101 Complete   epson
(unmaintained)
sane-epson
Perfection 640 USB 0x04b8/0x010c Complete   epson
(unmaintained)
sane-epson
Perfection 640U USB 0x04b8/0x010c Complete overseas version of the GT-6700U epson2
(1.0.124)
sane-epson2
Perfection 660 USB 0x04b8/0x0114 Good   SnapScan
(1.4)
sane-snapscan
Perfection 1200Photo USB 0x04b8/0x0104 Complete with TPU epson
(unmaintained)
sane-epson
Perfection 1200S SCSI   Complete overseas version of the GT-7600S epson2
(1.0.124)
sane-epson2
Perfection 1200S SCSI   Complete   epson
(unmaintained)
sane-epson
Perfection 1200U USB 0x04b8/0x0104 Complete overseas version of the GT-7600U epson2
(1.0.124)
sane-epson2
Perfection 1200U USB 0x04b8/0x0104 Complete   epson
(unmaintained)
sane-epson
Perfection 1200U PHOTO USB 0x04b8/0x0104 Complete Perfection 1200U with TPU option bundled
overseas version of the GT-7600UF
epson2
(1.0.124)
sane-epson2
Perfection 1240 SCSI USB 0x04b8/0x010b Complete   epson
(unmaintained)
sane-epson
Perfection 1240U USB 0x04b8/0x010b Complete overseas version of the GT-7700U epson2
(1.0.124)
sane-epson2
Perfection 1250 USB 0x04b8/0x010f Complete   plustek
(0.52)
sane-plustek
Perfection 1250 PHOTO USB 0x04b8/0x010f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 1250Photo USB 0x04b8/0x010f Good TPA scans not perfect plustek
(0.52)
sane-plustek
Perfection 1260 USB 0x04b8/0x011d Complete   plustek
(0.52)
sane-plustek
Perfection 1260 PHOTO USB 0x04b8/0x011d Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 1260Photo USB 0x04b8/0x011d Good TPA scans not perfect plustek
(0.52)
sane-plustek
Perfection 1270 USB 0x04b8/0x0120 Good   SnapScan
(1.4)
sane-snapscan
Perfection 1600 SCSI   Unsupported   epson2
(1.0.124)
sane-epson2
Perfection 1640 SCSI USB 0x04b8/0x010a Complete   epson
(unmaintained)
sane-epson
Perfection 1640SU SCSI USB 0x04b8/0x010a Complete overseas version of the GT-8700 epson2
(1.0.124)
sane-epson2
Perfection 1640SU PHOTO SCSI USB 0x04b8/0x010a Good overseas version of the GT-8700F epson2
(1.0.124)
sane-epson2
Perfection 1650 USB 0x04b8/0x0110 Complete overseas version of the GT-8200U epson2
(1.0.124)
sane-epson2
Perfection 1650 USB 0x04b8/0x0110 Complete   epson
(unmaintained)
sane-epson
Perfection 1650 PHOTO USB 0x04b8/0x0110 Good overseas version of the GT-8200UF epson2
(1.0.124)
sane-epson2
Perfection 1660 USB 0x04b8/0x011e Complete   epson
(unmaintained)
sane-epson
Perfection 1660 PHOTO USB 0x04b8/0x011e Complete overseas version of the GT-8300UF epson2
(1.0.124)
sane-epson2
Perfection 1670 USB 0x04b8/0x011f Good   SnapScan
(1.4)
sane-snapscan
Perfection 1670 PHOTO USB 0x04b8/0x011f Unsupported supported by the snapscan backend
overseas version of the GT-8400UF
epson2
(1.0.124)
sane-epson2
Perfection 2400 USB 0x04b8/0x011b Complete   epson
(unmaintained)
sane-epson
Perfection 2400 PHOTO USB 0x04b8/0x011b Complete overseas version of the GT-9300UF epson2
(1.0.124)
sane-epson2
Perfection 2450 USB IEEE-1394 0x04b8/0x0112 Complete   epson
(unmaintained)
sane-epson
Perfection 2450 PHOTO USB IEEE-1394 0x04b8/0x0112 Complete overseas version of the GT-9700F epson2
(1.0.124)
sane-epson2
Perfection 2480 USB 0x04b8/0x0121 Good   SnapScan
(1.4)
sane-snapscan
Perfection 2480 PHOTO USB 0x04b8/0x0121 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 2580 USB 0x04b8/0x0121 Basic Film scanning unit unsupported SnapScan
(1.4)
sane-snapscan
Perfection 2580 PHOTO USB 0x04b8/0x0121 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 3170 PHOTO USB 0x04b8/0x0116 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 3200 USB IEEE-1394 0x04b8/0x011c Complete US version of the GT-9800 epson
(unmaintained)
sane-epson
Perfection 3200 PHOTO USB IEEE-1394 0x04b8/0x011c Complete overseas version of the GT-9800F epson2
(1.0.124)
sane-epson2
Perfection 3490 USB 0x04b8/0x0122 Good   SnapScan
(1.4)
sane-snapscan
Perfection 3490 PHOTO USB 0x04b8/0x0122 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 3590 USB 0x04b8/0x0122 Basic Film scanning unit unsupported SnapScan
(1.4)
sane-snapscan
Perfection 3590 PHOTO USB 0x04b8/0x0122 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 4180 PHOTO USB 0x04b8/0x0118 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 4490 PHOTO USB 0x04b8/0x0119 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection 4870 USB 0x04b8/0x0128 Complete US version of the GT-X700 epson
(unmaintained)
sane-epson
Perfection 4870 PHOTO USB 0x04b8/0x0128 Complete IEEE1394 untested
overseas version of the GT-X700
epson2
(1.0.124)
sane-epson2
Perfection 4990 USB 0x04b8/0x012a Complete US version of the GT-X800 epson
(unmaintained)
sane-epson
Perfection 4990 PHOTO USB 0x04b8/0x012a Good film area guide mode not supported
IEEE1394 untested
overseas version of the GT-X800
epson2
(1.0.124)
sane-epson2
Perfection 4990 Pro USB IEEE1394   Untested seems to be a 4990 PHOTO with additional software epson2
(1.0.124)
sane-epson2
Perfection V10 USB 0x04b8/0x012d Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection V30 USB 0x04b8/0x0131 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection V100 Photo USB 0x04b8/0x012d Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection V200 Photo USB 0x04b8/0x012e Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection V300 Photo USB 0x04b8/0x0131 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection V350 Photo USB 0x04b8/0x012f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection V500 Photo USB 0x04b8/0x0130 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection V600 Photo USB 0x04b8/0x013a Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Perfection V700 Photo USB 0x04b8/0x012c Good IEEE1394 untested
overseas version of the GT-X900
epson2
(1.0.124)
sane-epson2
Perfection V750 Photo USB 0x04b8/0x012c Good IEEE1394 untested
overseas version of the GT-X900
epson2
(1.0.124)
sane-epson2
PM-A700 USB 0x04b8/0x0814 Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A750 USB 0x04b8/0x081a Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A820 USB 0x04b8/0x0827 Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A840 USB 0x04b8/0x083c Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A840S USB 0x04b8/0x083c Good network interface probably supported
all-in-one
epson2
(1.0.124)
sane-epson2
PM-A850 USB 0x04b8/0x0806 Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A870 USB 0x04b8/0x0811 Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A890 USB 0x04b8/0x081c Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A900 USB 0x04b8/0x0810 Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A920 USB 0x04b8/0x082a Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A940 USB 0x04b8/0x0837 Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A950 USB 0x04b8/0x081d Good all-in-one epson2
(1.0.124)
sane-epson2
PM-A970 USB 0x04b8/0x0828 Good all-in-one epson2
(1.0.124)
sane-epson2
PM-T960 USB 0x04b8/0x0836 Good all-in-one epson2
(1.0.124)
sane-epson2
PM-T990 USB 0x04b8/0x0829 Good all-in-one
PM-A970 with network interface
epson2
(1.0.124)
sane-epson2
PX-401A USB 0x04b8/0x0841 Good all-in-one epson2
(1.0.124)
sane-epson2
PX-402A USB 0x04b8/0x084d Good all-in-one epson2
(1.0.124)
sane-epson2
PX-501A USB 0x04b8/0x084a Good network interface probably supported
all-in-one
epson2
(1.0.124)
sane-epson2
PX-502A USB 0x04b8/0x0856 Good all-in-one epson2
(1.0.124)
sane-epson2
PX-601F USB 0x04b8/0x0847 Good network interface probably supported epson2
(1.0.124)
sane-epson2
PX-A550 USB 0x04b8/0x080e Good all-in-one epson2
(1.0.124)
sane-epson2
PX-A620 USB 0x04b8/0x082f Good all-in-one epson2
(1.0.124)
sane-epson2
PX-A640 USB 0x04b8/0x0838 Good all-in-one epson2
(1.0.124)
sane-epson2
PX-A650 USB 0x04b8/0x0819 Good all-in-one epson2
(1.0.124)
sane-epson2
PX-A720 USB 0x04b8/0x082e Good all-in-one epson2
(1.0.124)
sane-epson2
PX-A740 USB 0x04b8/0x0839 Good all-in-one epson2
(1.0.124)
sane-epson2
PX-FA700 USB 0x04b8/0x083a Good all-in-one epson2
(1.0.124)
sane-epson2
RX-425 USB 0x04b8/0x080f Good   epson
(unmaintained)
sane-epson
RX-500 USB 0x04b8/0x0807 Good   epson
(unmaintained)
sane-epson
RX-600 USB 0x04b8/0x0806 Good   epson
(unmaintained)
sane-epson
RX-620 USB 0x04b8/0x0811 Good   epson
(unmaintained)
sane-epson
RX-700 USB 0x04b8/0x0810 Good   epson
(unmaintained)
sane-epson
Stylus CX-1500 USB 0x04b8/0x080c Good   SnapScan
(1.4)
sane-snapscan
Stylus CX-5800 USB   Unsupported Probably unsupported at the moment. Not compatible to snapscan backend. It's not known if it may work with epson or epkowa backend. unsupported
(2010-06-09)
?
Stylus CX1500 USB 0x04b8/0x080c Unsupported supported by the snapscan backend
all-in-one
epson2
(1.0.124)
sane-epson2
Stylus CX2800 USB 0x04b8/0x0830 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX2900 USB 0x04b8/0x0830 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX3100 USB 0x04b8/0x0802 Good all-in-one
overseas version of the CC-570L
epson2
(1.0.124)
sane-epson2
Stylus CX3200 USB 0x04b8/0x0802 Good all-in-one
overseas version of the CC-570L
epson2
(1.0.124)
sane-epson2
Stylus CX3500 USB 0x04b8/0x080e Good all-in-one
overseas version of the PX-A550
epson2
(1.0.124)
sane-epson2
Stylus CX3600 USB 0x04b8/0x080e Good all-in-one
overseas version of the PX-A550
epson2
(1.0.124)
sane-epson2
Stylus CX3650 USB 0x04b8/0x080e Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX3700 USB 0x04b8/0x0818 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX3800 USB 0x04b8/0x0818 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX3810 USB   Untested all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX3900 USB 0x04b8/0x082f Good all-in-one
overseas version of the PX-A620
epson2
(1.0.124)
sane-epson2
Stylus CX4100 USB 0x04b8/0x0820 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX4200 USB 0x04b8/0x0820 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX4300 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus CX4400 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus CX4500 USB 0x04b8/0x080d Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX4600 USB 0x04b8/0x080d Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX4700 USB 0x04b8/0x0819 Good all-in-one
overseas version of the PX-A650
epson2
(1.0.124)
sane-epson2
Stylus CX4800 USB 0x04b8/0x0819 Good all-in-one
overseas version of the PX-A650
epson2
(1.0.124)
sane-epson2
Stylus CX4900 USB 0x04b8/0x082b Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX5000 USB 0x04b8/0x082b Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX5100 USB 0x04b8/0x0801 Good all-in-one
overseas version of the CC-600PX
epson2
(1.0.124)
sane-epson2
Stylus CX5200 USB 0x04b8/0x0801 Good all-in-one
overseas version of the CC-600PX
epson2
(1.0.124)
sane-epson2
Stylus CX5300 USB 0x04b8/0x0808 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX5400 USB 0x04b8/0x0808 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX5500 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus CX5600 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus CX5700F USB 0x04b8/0x0821 Unsupported may work with the snapscan backend
all-in-one with FAX
epson2
(1.0.124)
sane-epson2
Stylus CX5800F USB 0x04b8/0x0821 Unsupported may work with the snapscan backend
all-in-one with FAX
epson2
(1.0.124)
sane-epson2
Stylus CX5900 USB 0x04b8/0x082e Good all-in-one
overseas version of the PX-A720
epson2
(1.0.124)
sane-epson2
Stylus CX6000 USB 0x04b8/0x082e Good all-in-one
overseas version of the PX-A720
epson2
(1.0.124)
sane-epson2
Stylus CX6300 USB 0x04b8/0x0805 Good all-in-one
mistakenly thinks its a PX-A650
epson2
(1.0.124)
sane-epson2
Stylus CX6400 USB 0x04b8/0x0805 Good all-in-one
mistakenly thinks its a PX-A650
epson2
(1.0.124)
sane-epson2
Stylus CX6500 USB 0x04b8/0x0813 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX6600 USB 0x04b8/0x0813 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX6900F USB 0x04b8/0x0831 Unsupported may work with the snapscan backend
all-in-one with FAX
epson2
(1.0.124)
sane-epson2
Stylus CX7000F USB 0x04b8/0x0831 Unsupported may work with the snapscan backend
all-in-one with FAX
epson2
(1.0.124)
sane-epson2
Stylus CX7300 USB 0x04b8/0x0838 Good all-in-one
overseas version of the PX-A640
epson2
(1.0.124)
sane-epson2
Stylus CX7400 USB 0x04b8/0x0838 Good all-in-one
overseas version of the PX-A640
epson2
(1.0.124)
sane-epson2
Stylus CX7700 USB 0x04b8/0x081f Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX7800 USB 0x04b8/0x081f Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus CX8300 USB 0x04b8/0x0839 Good all-in-one
overseas version of the PX-A740
epson2
(1.0.124)
sane-epson2
Stylus CX8400 USB 0x04b8/0x0839 Good all-in-one
overseas version of the PX-A740
epson2
(1.0.124)
sane-epson2
Stylus CX9300F USB 0x04b8/0x083a Good all-in-one
overseas version of the PX-FA700
epson2
(1.0.124)
sane-epson2
Stylus CX9400Fax USB 0x04b8/0x083a Good all-in-one
overseas version of the PX-FA700
epson2
(1.0.124)
sane-epson2
Stylus DX3800 USB 0x04b8/0x0818 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus DX3850 USB   Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus DX4000 USB 0x04b8/0x082f Good all-in-one
overseas version of the PX-A620
epson2
(1.0.124)
sane-epson2
Stylus DX4200 USB 0x04b8/0x0820 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus DX4400 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus DX4450 USB 0x04b8/0x083f Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
Stylus DX4800 USB 0x04b8/0x0819 Good all-in-one
overseas version of the PX-A650
epson2
(1.0.124)
sane-epson2
Stylus DX4850 USB 0x04b8/0x0819 Good all-in-one
DX4800 + card reader
epson2
(1.0.124)
sane-epson2
Stylus DX5000 USB 0x04b8/0x082b Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus DX6000 USB 0x04b8/0x082e Good all-in-one
overseas version of the PX-A720
epson2
(1.0.124)
sane-epson2
Stylus DX7000F USB 0x04b8/0x0831 Unsupported may work with the snapscan backend
all-in-one with FAX
epson2
(1.0.124)
sane-epson2
Stylus DX7400 USB 0x04b8/0x0838 Good all-in-one
overseas version of the PX-A640
epson2
(1.0.124)
sane-epson2
Stylus DX8400 USB 0x04b8/0x0839 Good all-in-one
overseas version of the PX-A740
epson2
(1.0.124)
sane-epson2
Stylus DX9400F USB 0x04b8/0x083a Good all-in-one
overseas version of the PX-FA700
epson2
(1.0.124)
sane-epson2
Stylus NX100 USB 0x04b8/0x0841 Good all-in-one
overseas version of the PX-401A
epson2
(1.0.124)
sane-epson2
Stylus NX110 Series USB 0x04b8/0x084d Good all-in-one
overseas version of the PX-402A
epson2
(1.0.124)
sane-epson2
Stylus NX200 USB 0x04b8/0x0849 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus NX210 Series USB 0x04b8/0x084f Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus NX300 USB 0x04b8/0x0848 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus NX400 USB 0x04b8/0x084a Good network interface probably supported
all-in-one
overseas version of the PX-501A
epson2
(1.0.124)
sane-epson2
Stylus NX410 Series USB 0x04b8/0x0851 Good network interface probably supported
all-in-one
epson2
(1.0.124)
sane-epson2
Stylus NX510 Series USB 0x04b8/0x0856 Good all-in-one
overseas version of the PX-502A
epson2
(1.0.124)
sane-epson2
Stylus Office BX300F USB 0x04b8/0x0848 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Office BX310FN Series USB 0x04b8/0x0854 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Office BX600FW USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
epson2
(1.0.124)
sane-epson2
Stylus Office BX610FW Series USB 0x04b8/0x0855 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus Office TX300F USB 0x04b8/0x0848 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Office TX510FN Series USB 0x04b8/0x0854 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Office TX600FW USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
epson2
(1.0.124)
sane-epson2
Stylus Office TX610FW Series USB 0x04b8/0x0855 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus Photo PX650 Series USB 0x04b8/0x0850 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus Photo PX700W USB Network 0x04b8/0x0846 Good network interface supported
all-in-one
overseas version of the EP-801A
epson2
(1.0.124)
sane-epson2
Stylus Photo PX710W Series USB 0x04b8/0x0852 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus Photo PX800FW USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
overseas version of the EP-901A
epson2
(1.0.124)
sane-epson2
Stylus Photo PX810FW Series USB 0x04b8/0x0853 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus Photo RX420 USB 0x04b8/0x080f Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Photo RX425 USB 0x04b8/0x080f Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Photo RX430 USB 0x04b8/0x080f Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Photo RX500 USB 0x04b8/0x0807 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Photo RX510 USB 0x04b8/0x0807 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus Photo RX520 USB 0x04b8/0x081a Good all-in-one
overseas version of the PM-A750
epson2
(1.0.124)
sane-epson2
Stylus Photo RX530 USB 0x04b8/0x081a Good all-in-one
overseas version of the PM-A750
epson2
(1.0.124)
sane-epson2
Stylus Photo RX560 USB 0x04b8/0x0827 Good all-in-one
overseas version of the PM-A820
epson2
(1.0.124)
sane-epson2
Stylus Photo RX580 USB 0x04b8/0x0827 Good all-in-one
overseas version of the PM-A820
epson2
(1.0.124)
sane-epson2
Stylus Photo RX585 USB 0x04b8/0x083c Good all-in-one
overseas version of the PM-A840
epson2
(1.0.124)
sane-epson2
Stylus Photo RX590 USB 0x04b8/0x0827 Good all-in-one
overseas version of the PM-A820
epson2
(1.0.124)
sane-epson2
Stylus Photo RX595 USB 0x04b8/0x083c Good all-in-one
overseas version of the PM-A840
epson2
(1.0.124)
sane-epson2
Stylus Photo RX600 USB 0x04b8/0x0806 Good all-in-one
overseas version of the PM-A850
epson2
(1.0.124)
sane-epson2
Stylus Photo RX610 USB 0x04b8/0x083c Good all-in-one
overseas version of the PM-A840
epson2
(1.0.124)
sane-epson2
Stylus Photo RX620 USB 0x04b8/0x0811 Good all-in-one
overseas version of the PM-A870
epson2
(1.0.124)
sane-epson2
Stylus Photo RX630 USB 0x04b8/0x0811 Good all-in-one
overseas version of the PM-A870
epson2
(1.0.124)
sane-epson2
Stylus Photo RX640 USB 0x04b8/0x081c Good all-in-one
overseas version of the PM-A890
epson2
(1.0.124)
sane-epson2
Stylus Photo RX650 USB 0x04b8/0x081c Good all-in-one
overseas version of the PM-A890
epson2
(1.0.124)
sane-epson2
Stylus Photo RX680 USB 0x04b8/0x0837 Good all-in-one
overseas version of the PM-A940
epson2
(1.0.124)
sane-epson2
Stylus Photo RX685 USB 0x04b8/0x0837 Good all-in-one
overseas version of the PM-A940
epson2
(1.0.124)
sane-epson2
Stylus Photo RX690 USB 0x04b8/0x0837 Good all-in-one
overseas version of the PM-A940
epson2
(1.0.124)
sane-epson2
Stylus Photo RX700 USB 0x04b8/0x0810 Good all-in-one
overseas version of the PM-A900
epson2
(1.0.124)
sane-epson2
Stylus Photo TX650 Series USB 0x04b8/0x0850 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus Photo TX700W USB 0x04b8/0x0846 Good network interface probably supported
all-in-one
overseas version of the EP-801A
epson2
(1.0.124)
sane-epson2
Stylus Photo TX710W Series USB 0x04b8/0x0852 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus Photo TX800FW USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
overseas version of the EP-901A
epson2
(1.0.124)
sane-epson2
Stylus Scan 2000 USB 0x04b8/0x0105 Untested apparently mostly the same as the Stylus Scan 2500 epson2
(1.0.124)
sane-epson2
Stylus Scan 2500 USB 0x04b8/0x0106 Untested scanner is apparently a GT-7000 epson2
(1.0.124)
sane-epson2
Stylus SX100 USB 0x04b8/0x0841 Good all-in-one
overseas version of the PX-401A
epson2
(1.0.124)
sane-epson2
Stylus SX110 Series USB 0x04b8/0x084d Good all-in-one
overseas version of the PX-402A
epson2
(1.0.124)
sane-epson2
Stylus SX125 USB 0x04b8/0x085c Untested all-in-one epson2
(1.0.124)
sane-epson2
Stylus SX200 USB 0x04b8/0x0849 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus SX205 USB 0x04b8/0x0849 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus SX210 Series USB 0x04b8/0x084f Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus SX400 USB 0x04b8/0x084a Good network interface probably supported
all-in-one
overseas version of the PX-501A
epson2
(1.0.124)
sane-epson2
Stylus SX405 USB 0x04b8/0x084a Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus SX410 Series USB 0x04b8/0x0851 Good network interface probably supported
all-in-one
epson2
(1.0.124)
sane-epson2
Stylus SX510W Series USB 0x04b8/0x0856 Good all-in-one
overseas version of the PX-502A
epson2
(1.0.124)
sane-epson2
Stylus SX600FW USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
epson2
(1.0.124)
sane-epson2
Stylus SX610FW Series USB 0x04b8/0x0855 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2
Stylus TX100 USB 0x04b8/0x0841 Good all-in-one
overseas version of the PX-401A
epson2
(1.0.124)
sane-epson2
Stylus TX110 Series USB 0x04b8/0x084d Good all-in-one
overseas version of the PX-402A
epson2
(1.0.124)
sane-epson2
Stylus TX200 USB 0x04b8/0x0849 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus TX203 USB 0x04b8/0x0849 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus TX209 USB 0x04b8/0x0849 Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus TX210 Series USB 0x04b8/0x084f Good all-in-one epson2
(1.0.124)
sane-epson2
Stylus TX400 USB 0x04b8/0x084a Good network interface probably supported
all-in-one
overseas version of the PX-501A
epson2
(1.0.124)
sane-epson2
Stylus TX410 Series USB 0x04b8/0x0851 Good network interface probably supported
all-in-one
epson2
(1.0.124)
sane-epson2
Stylus TX550W Series USB 0x04b8/0x0856 Good all-in-one
overseas version of the PX-502A
epson2
(1.0.124)
sane-epson2
StylusScan 2000 USB 0x04b8/0x0105 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
V700 USB IEEE-1394 0x04b8/0x012c Good   epson
(unmaintained)
sane-epson
V750 USB IEEE-1394 0x04b8/0x012c Good   epson
(unmaintained)
sane-epson
WorkForce 310 Series USB 0x04b8/0x0854 Good all-in-one epson2
(1.0.124)
sane-epson2
WorkForce 500 USB 0x04b8/0x084c Good all-in-one epson2
(1.0.124)
sane-epson2
WorkForce 600 USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
epson2
(1.0.124)
sane-epson2
WorkForce 610 Series USB 0x04b8/0x0855 Unsupported supported by the epkowa backend plus non-free interpreter epson2
(1.0.124)
sane-epson2

Manufacturer: Escom

Model Interface USB id Status Comment Backend Manpage
Image Scanner 256 SCSI   Good OK, SCSI-ID=UMAX UG 80 umax
(1.0-41)
sane-umax

Manufacturer: Escort

Model Interface USB id Status Comment Backend Manpage
Galleria 600 SCSI   Untested untested, SCSI-ID=ESCORT Galleria 600S umax
(1.0-41)
sane-umax

Manufacturer: Fujitsu

Link(s): http://www.fujitsu.com, http://www.fujitsu.com/, http://www.fcpa.fujitsu.com/products/scanners/

Model Interface USB id Status Comment Backend Manpage
1200CUS USB 0x05d8/0x4002 Basic Works, but is slow. Probably a Mustek BearPaw 2400 CU clone. gt68xx
(1.0-84)
sane-gt68xx
fi-60F USB 0x04c5/0x10c7 Basic A6-size flatbed, 300/600 dpi, color/gray/binary epjitsu
(20)
sane-epjitsu
fi-4010CU USB 0x04c5/0x1029 Untested   avision
(Build: 296)
sane-avision
fi-4110EOX/2/3 USB 0x04c5/0x1040 Unsupported Uses ma1509 chip, but very different from other scanners supported by the ma1509 backend ma1509
(1.0-3)
sane-ma1509
fi-4120C SCSI USB 0x04c5/0x1041 Complete small, recent, discontinued, usb 1.1 fujitsu
(117)
sane-fujitsu
fi-4120C2 SCSI USB 0x04c5/0x10ae Complete small, recent, discontinued, usb 2.0 fujitsu
(117)
sane-fujitsu
fi-4220C SCSI USB 0x04c5/0x1042 Complete small, recent, discontinued, usb 1.1 fujitsu
(117)
sane-fujitsu
fi-4220C2 SCSI USB 0x04c5/0x10af Complete small, recent, discontinued, usb 2.0 fujitsu
(117)
sane-fujitsu
fi-4340C SCSI USB 0x04c5/0x10cf Complete medium, current fujitsu
(117)
sane-fujitsu
fi-4530C SCSI USB 0x04c5/0x1078 Complete medium, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-4640S SCSI   Complete medium, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-4750C SCSI   Complete medium, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-4750L SCSI   Complete big, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-4860C SCSI   Complete big, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-4860C2 SCSI   Complete big, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-4990C SCSI   Complete big, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5000N Ethernet   Untested Not a scanner, rather a scanner to ethernet interface fujitsu
(117)
sane-fujitsu
fi-5015C USB 0x04c5/0x10ef Good   avision
(Build: 296)
sane-avision
fi-5110C USB 0x04c5/0x1097 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5110EOX/2 USB 0x04c5/0x1096 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5110EOX3 USB 0x04c5/0x10e6 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5110EOXM USB 0x04c5/0x10f2 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5120C SCSI USB 0x04c5/0x10e0 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5220C SCSI USB 0x04c5/0x10e1 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5530C SCSI USB 0x04c5/0x10e2 Complete medium, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5530C2 SCSI USB 0x04c5/0x114a Complete medium, current fujitsu
(117)
sane-fujitsu
fi-5650C SCSI USB 0x04c5/0x10ad Complete big, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5750C SCSI USB 0x04c5/0x1095 Complete big, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-5900C SCSI USB 0x04c5/0x10e7 Good big, recent, discontinued. Independent ultrasonic control and multistream unsupported fujitsu
(117)
sane-fujitsu
fi-5950 SCSI USB 0x04c5/0x1213 Untested big, current. Faster version of fi-5900? fujitsu
(117)
sane-fujitsu
fi-6000NS Ethernet   Untested small, recent, discontinued, integrated touchscreen and keyboard fujitsu
(117)
sane-fujitsu
fi-6110 USB 0x04c5/0x11fc Complete small, current fujitsu
(117)
sane-fujitsu
fi-6130 USB 0x04c5/0x114f Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-6130Z USB 0x04c5/0x11f3 Complete small, current fujitsu
(117)
sane-fujitsu
fi-6140 SCSI USB 0x04c5/0x114d Complete medium, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-6140Z SCSI USB 0x04c5/0x11f1 Complete medium, current fujitsu
(117)
sane-fujitsu
fi-6230 USB 0x04c5/0x1150 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-6230Z USB 0x04c5/0x11f4 Complete small, current fujitsu
(117)
sane-fujitsu
fi-6240 SCSI USB 0x04c5/0x114e Complete medium, recent, discontinued fujitsu
(117)
sane-fujitsu
fi-6240Z SCSI USB 0x04c5/0x11f2 Complete medium, current fujitsu
(117)
sane-fujitsu
fi-6670 SCSI USB 0x04c5/0x1176 Good big, current, won't wakeup via software fujitsu
(117)
sane-fujitsu
fi-6670A SCSI USB 0x04c5/0x1177 Good big, current, VRS CGA board unsupported, won't wakeup via software fujitsu
(117)
sane-fujitsu
fi-6750S USB 0x04c5/0x1178 Untested Simplex, USB only version of fi-6770, won't wakeup via software, discontinued fujitsu
(117)
sane-fujitsu
fi-6770 SCSI USB 0x04c5/0x1174 Good big, current, won't wakeup via software fujitsu
(117)
sane-fujitsu
fi-6770A SCSI USB 0x04c5/0x1175 Good big, current, VRS CGA board unsupported, won't wakeup via software fujitsu
(117)
sane-fujitsu
fi-6800 SCSI USB 0x04c5/0x119d Untested big, current. Independent ultrasonic control and multistream unsupported fujitsu
(117)
sane-fujitsu
fi-6800-CGA SCSI USB 0x04c5/0x119e Untested big, current. VRS CGA board unsupported, Independent ultrasonic control and multistream unsupported fujitsu
(117)
sane-fujitsu
M3091DC SCSI   Complete small, old, discontinued fujitsu
(117)
sane-fujitsu
M3092DC SCSI   Complete small, old, discontinued fujitsu
(117)
sane-fujitsu
M3093DE RS232C/Video   Unsupported medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3093DG SCSI   Complete medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3093E RS232C/Video   Unsupported medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3093EX RS232C/Video   Unsupported medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3093GX SCSI   Complete medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3096EX RS232C/Video   Unsupported medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3096GX SCSI   Complete medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3097DE RS232C/Video   Unsupported medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3097DG SCSI   Complete medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3097E+ RS232C/Video   Unsupported medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3097G+ SCSI   Complete medium, old, discontinued fujitsu
(117)
sane-fujitsu
M3099A RS232C/Video   Unsupported big, old, discontinued fujitsu
(117)
sane-fujitsu
M3099EH RS232C/Video   Unsupported big, old, discontinued fujitsu
(117)
sane-fujitsu
M3099EX RS232C/Video   Unsupported big, old, discontinued fujitsu
(117)
sane-fujitsu
M3099G SCSI   Complete big, old, discontinued fujitsu
(117)
sane-fujitsu
M3099GH SCSI   Complete big, old, discontinued fujitsu
(117)
sane-fujitsu
M3099GX SCSI   Complete big, old, discontinued fujitsu
(117)
sane-fujitsu
M4097D SCSI   Complete big, old, discontinued fujitsu
(117)
sane-fujitsu
M4099D SCSI   Complete big, old, discontinued fujitsu
(117)
sane-fujitsu
ScanPartner SCSI   Untested   avision
(Build: 296)
sane-avision
ScanPartner 10 SCSI   Untested   avision
(Build: 296)
sane-avision
ScanPartner 10C SCSI   Untested   avision
(Build: 296)
sane-avision
ScanPartner 15C SCSI   Good   sp15c
(unmaintained)
sane-sp15c
ScanPartner 300C SCSI   Untested   avision
(Build: 296)
sane-avision
ScanPartner 600C SCSI   Good   sp15c
(unmaintained)
sane-sp15c
ScanPartner 620C SCSI   Good   avision
(Build: 296)
sane-avision
ScanPartner Jr SCSI   Untested   avision
(Build: 296)
sane-avision
ScanSnap fi-6010N Ethernet   Untested small, current, integrated touchscreen and keyboard fujitsu
(117)
sane-fujitsu
ScanSnap iX500 USB WiFi 0x04c5/0x132b Good small, current, WiFi not supported. Hardware only scans in color. Backend generates binary and grayscale modes. fujitsu
(117)
sane-fujitsu
ScanSnap N1800 Ethernet   Untested small, current, integrated touchscreen and keyboard fujitsu
(117)
sane-fujitsu
ScanSnap S300 USB 0x04c5/0x1156 Good Duplex, 150/225/300/600 dpi, color/gray/binary, AC/USB power, buttons/sensors all supported. Scanner always scans in _triplex_ color, fast USB required. epjitsu
(20)
sane-epjitsu
ScanSnap S300M USB 0x04c5/0x117f Good Same as S300, with different usb id epjitsu
(20)
sane-epjitsu
ScanSnap S500 USB 0x04c5/0x10fe Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
ScanSnap S500M USB 0x04c5/0x1135 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
ScanSnap S510 USB 0x04c5/0x1155 Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
ScanSnap S510M USB 0x04c5/0x116f Complete small, recent, discontinued fujitsu
(117)
sane-fujitsu
ScanSnap S1100 USB 0x04c5/0x1200 Unsupported Beta version of backend source available, which works well, but breaks support for other epjitsu scanners. See http://ubuntuforums.org/showthread.php?t=1678335 epjitsu
(20)
sane-epjitsu
ScanSnap S1300 USB 0x04c5/0x11ed Good Same as S300, with different usb id epjitsu
(20)
sane-epjitsu
ScanSnap S1500 USB 0x04c5/0x11a2 Complete small, discontinued fujitsu
(117)
sane-fujitsu
ScanSnap S1500M USB 0x04c5/0x11a2 Complete small, discontinued, same as S1500 fujitsu
(117)
sane-fujitsu
ScanStation SCSI   Untested   avision
(Build: 296)
sane-avision

Manufacturer: Gallery

Model Interface USB id Status Comment Backend Manpage
4800 Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp

Manufacturer: Genius

Link(s): http://www.genius-kye.com/, http://www.geniusmouse.co.uk/, http://www.geniusnet.com.tw/

Model Interface USB id Status Comment Backend Manpage
ColorPage CS SCSI   Unsupported Probably unsupported, see link for details. unsupported
(2010-06-09)
?
ColorPage HR6 V1 USB 0x0458/0x2004 Basic   u12
(0.02)
sane-u12
Colorpage HR6 V2 USB 0x0458/0x2008 Complete   plustek
(0.52)
sane-plustek
Colorpage HR6 V2 USB 0x0458/0x2007 Complete   plustek
(0.52)
sane-plustek
Colorpage HR6A USB 0x0458/0x2009 Untested   plustek
(0.52)
sane-plustek
Colorpage HR6X USB 0x0458/0x2016 Untested   plustek
(0.52)
sane-plustek
Colorpage HR6X EPP Parport (SPP, EPP)   Good Negative scanning does not work correctly plustek_pp
(0.43)
sane-plustek_pp
ColorPage HR6X Slim USB 0x0458/0x2019 Unsupported GL646 based, to be added to genesys backend unsupported
(2010-06-09)
?
Colorpage HR7 USB 0x0458/0x2013 Complete   plustek
(0.52)
sane-plustek
Colorpage HR7LE USB 0x0458/0x2015 Untested   plustek
(0.52)
sane-plustek
ColorPage HR7X USB 0x0458/0x2018 Unsupported GL646 based, to be added to genesys backend unsupported
(2010-06-09)
?
ColorPage HR7XE USB 0x06dc/0x0012 Unsupported Unsuported. See link for details. unsupported
(2010-06-09)
?
ColorPage HR8 USB 0x0458/0x201c Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
Colorpage SF600 USB 0x0458/0x2021 Basic   gt68xx
(1.0-84)
sane-gt68xx
ColorPage Slim 1200 USB 0x0458/0x201e Untested Untested but should work. gt68xx
(1.0-84)
sane-gt68xx
Colorpage Vivid 1200 X USB 0x0458/0x201d Good   gt68xx
(1.0-84)
sane-gt68xx
Colorpage Vivid 1200 XE USB 0x0458/0x201f Good   gt68xx
(1.0-84)
sane-gt68xx
ColorPage Vivid III USB USB 0x07b3/0x0001 Untested Note: Device has Plustek vendor and product ID (0x07b3/0x0001) u12
(0.02)
sane-u12
Colorpage Vivid III V2 Parport (SPP, EPP)   Complete Reported as PT12 plustek_pp
(0.43)
sane-plustek_pp
Colorpage Vivid Pro II Film Parport (SPP, EPP)   Complete Reported as OP9636T/12000T plustek_pp
(0.43)
sane-plustek_pp
Colorpage Vivid3 V2 USB 0x0458/0x2011 Good Same as Colorpage Vivid3x gt68xx
(1.0-84)
sane-gt68xx
Colorpage Vivid3x USB 0x0458/0x2011 Good   gt68xx
(1.0-84)
sane-gt68xx
Colorpage Vivid3xe USB 0x0458/0x2017 Good   gt68xx
(1.0-84)
sane-gt68xx
Colorpage Vivid4 USB 0x0458/0x2014 Good   gt68xx
(1.0-84)
sane-gt68xx
Colorpage Vivid4x USB 0x0458/0x201b Good   gt68xx
(1.0-84)
sane-gt68xx
Colorpage Vivid4xe USB 0x0458/0x201a Good   gt68xx
(1.0-84)
sane-gt68xx
ColorPage-EP Parport   Good   microtek2
(unmaintained)
sane-microtek2
ColorPage-HR5 (Pro) SCSI   Good OK, SCSI-ID=KYE ColorPage-HR5 umax
(1.0-41)
sane-umax
ColorPage-Life Pro Parport (EPP/ECP)   Good works (relabelled 1220P and 2000P) umax_pp
(1)
sane-umax_pp
ColorPage-Slim 1200 USB2 USB 0x0458/0x2020 Unsupported GL841 based, to be added to genesys backend. unsupported
(2010-06-09)
?
Colorpage-SP2 SCSI   Good Same as Microtek Scanmaker E3 microtek
(0.13.1)
sane-microtek
FS-1130 Colorpage Scanner SCSI   Good   leo
(1.0-10)
sane-leo

Manufacturer: Googlegear

Model Interface USB id Status Comment Backend Manpage
2000 USB 0x05d8/0x4002 Good Same as Artec Ultima 2000. gt68xx
(1.0-84)
sane-gt68xx

Manufacturer: Guillemot

Model Interface USB id Status Comment Backend Manpage
Maxi Scan A4 Parallel 36 bit Parport   Unsupported Probably unsupported. Identical to the Benq Prisa 620P. unsupported
(2010-06-09)
?
SCAN@HOME 48 USB USB 0x080d/0x0102 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Guillemot / Hercules

Link(s): http://www.guillemot.com

Model Interface USB id Status Comment Backend Manpage
Maxi A4 36 bit USB 0x04a5/0x2060 Good Rebadged Benq 620U, needs Benq firmware file u96v???.bin SnapScan
(1.4)
sane-snapscan
Maxi Scan A4 Deluxe (SCSI) SCSI   Good Rebadged SnapScan 310s. SnapScan
(1.4)
sane-snapscan
Maxi Scan A4 USB 640U USB 0x04a5/0x2060 Good Rebadged Benq 640U. SnapScan
(1.4)
sane-snapscan
Scan@home Touch 1248 (USB) USB 0x04a5/0x20de Good Rebadged Benq 3300. SnapScan
(1.4)
sane-snapscan

Manufacturer: Hercules

Model Interface USB id Status Comment Backend Manpage
SCAN@HOME 48 USB USB 0x080d/0x0102 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Hewlett-Packard

Link(s): http://www.hp.com, http://www.hp.com/

Model Interface USB id Status Comment Backend Manpage
LaserJet M1005 MFP USB 0x03f0/0x3b17 Good grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI hpljm1005
(0)
sane-hpljm1005
LaserJet M1120 MFP USB 0x03f0/0x5617 Good grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI hpljm1005
(0)
sane-hpljm1005
LaserJet M1120n MFP USB 0x03f0/0x5717 Good grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI hpljm1005
(0)
sane-hpljm1005
Photo Scanner 1000 USB 0x03f0/0x1001 Unsupported Not supported by SANE. However, it's detected as mass storage device so just mounting it is reported to work. See link for device data. unsupported
(2010-06-09)
?
Photosmart 1200 Photo USB   Unsupported Probably not supported by SANE. No details known. 10x15 cm. Maybe similar to Photo Scanner 1000? unsupported
(2010-06-09)
?
Photosmart C3180 USB 0x03f0/0x5611 Unsupported Not supported yet by SANE. See link for details. unsupported
(2010-06-09)
?
Photosmart C5100 series USB 0x03f0/0x5811 Unsupported Not supported yet by SANE. See link for details. unsupported
(2010-06-09)
?
PhotoSmart PhotoScanner SCSI   Complete   hp
(1.06)
sane-hp
Photosmart S20 (C5101A) USB 0x03f0/0x0102 Unsupported Not supported yet by SANE. See link for details. unsupported
(2010-06-09)
?
Photosmart S20xi (C7150A) USB 0x03f0/0x0102 Unsupported Not supported yet by SANE. See link for details. unsupported
(2010-06-09)
?
ScanJet 3c SCSI   Complete   hp
(1.06)
sane-hp
ScanJet 3p SCSI   Complete   hp
(1.06)
sane-hp
ScanJet 4c SCSI   Complete   hp
(1.06)
sane-hp
ScanJet 4p SCSI   Complete   hp
(1.06)
sane-hp
ScanJet 5p SCSI   Complete   hp
(1.06)
sane-hp
ScanJet 5s Parport (EPP)   Minimal Requires libieee1284 library. Only gray mode. hpsj5s
(0.03)
sane-hpsj5s
ScanJet 2100C USB 0x03f0/0x0505 Complete   plustek
(0.52)
sane-plustek
ScanJet 2200C USB 0x03f0/0x0605 Complete   plustek
(0.52)
sane-plustek
ScanJet 2300C USB 0x03f0/0x0901 Complete 600x1200 dpi max genesys
(1.0-63)
sane-genesys
ScanJet 2400C USB 0x03f0/0x0a01 Complete 1200x1200 dpi max genesys
(1.0-63)
sane-genesys
Scanjet 3200C Parport (EPP/ECP)   Good works (relabelled 1220P and 2000P) umax_pp
(1)
sane-umax_pp
ScanJet 3300c USB 0x03f0/0x0205 Complete   niash
(0.3)
sane-niash
ScanJet 3400c USB 0x03f0/0x0405 Complete If you use Linux 2.6, version 2.6.8 or newer is necessary. niash
(0.3)
sane-niash
ScanJet 3500C USB 0x03f0/0x2205 Good   hp3500
(1.1)
sane-hp3500
ScanJet 3530C USB 0x03f0/0x2005 Good   hp3500
(1.1)
sane-hp3500
ScanJet 3570C USB 0x03f0/0x2005 Good   hp3500
(1.1)
sane-hp3500
ScanJet 3670 USB 0x03f0/0x1405 Complete 1200x1200 dpi max, complete transparency adaptor support genesys
(1.0-63)
sane-genesys
ScanJet 3690C USB 0x03f0/0x1405 Complete 1200x1200 dpi max, same as HP 3670 genesys
(1.0-63)
sane-genesys
ScanJet 3770 USB 0x03f0/0x2505 Unsupported While an external binary-only backend exists, it works only on Linux i386. Therefore the scanner is unsupported on other platforms. unsupported
(2010-06-09)
?
ScanJet 3800 USB 0x03f0/0x2605 Basic Works with resolutions equal and less than 600dpi hp3900
(0.12)
sane-hp3900
ScanJet 3970c USB 0x03f0/0x2305 Good   hp3900
(0.12)
sane-hp3900
ScanJet 4070 Photosmart USB 0x03f0/0x2405 Good   hp3900
(0.12)
sane-hp3900
ScanJet 4100C USB 0x03f0/0x0101 Complete   hp
(1.06)
sane-hp
ScanJet 4200C USB 0x03f0/0x0105 Basic 8bpp color, 75/150/300/600 dpi only hp4200
(1.0-2)
sane-hp4200
ScanJet 4200Cse USB 0x03f0/0x0105 Basic 8bpp color, 75/150/300/600 dpi only hp4200
(1.0-2)
sane-hp4200
ScanJet 4200Cxi USB 0x03f0/0x0105 Basic 8bpp color, 75/150/300/600 dpi only hp4200
(1.0-2)
sane-hp4200
ScanJet 4300c USB 0x03f0/0x0305 Complete If you use Linux 2.6, version 2.6.8 or newer is necessary. niash
(0.3)
sane-niash
ScanJet 4300c/Silitek USB 0x047b/0x1002 Complete If you use Linux 2.6, version 2.6.8 or newer is necessary. niash
(0.3)
sane-niash
ScanJet 4370 USB 0x03f0/0x4105 Basic Works with resolutions lower than 1200dpi hp3900
(0.12)
sane-hp3900
scanjet 4400c USB 0x03f0/0x0705 Good exists with 2 different sensors of which only one works rts8891
(1.0-0)
sane-rts8891
scanjet 4470c USB 0x03f0/0x0805 Good re-branded Astra 4400 rts8891
(1.0-0)
sane-rts8891
ScanJet 4500C USB 0x03f0/0x1205 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives hp5590
(1.0.5)
sane-hp5590
ScanJet 4570C USB 0x03f0/0x1305 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives hp5590
(1.0.5)
sane-hp5590
ScanJet 4600 USB 0x03f0/0x3005 Unsupported Not supported. See link for details, or http://www.chmil.org/hp4600linux/ for code unsupported
(2010-06-09)
?
ScanJet 4670 USB 0x03f0/0x3005 Unsupported Not supported. See ScanJet 4600 entry. unsupported
(2010-06-09)
?
ScanJet 4850C USB 0x03f0/0x1b05 Untested resolution from 100 to 2400 supported, UTA not supported yet genesys
(1.0-63)
sane-genesys
ScanJet 4890C USB 0x03f0/0x1b05 Unsupported GL843, maybe can be added to genesys backend unsupported
(2010-06-09)
?
ScanJet 5100C Parport   Complete Requires ppscsi driver and epst module hp
(1.06)
sane-hp
ScanJet 5200C Parport USB 0x03f0/0x0401 Complete Parallel interface requires ppscsi driver and epst module hp
(1.06)
sane-hp
ScanJet 5300C USB 0x03f0/0x0701 Complete 1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi avision
(Build: 296)
sane-avision
ScanJet 5370C USB 0x03f0/0x0701 Good 1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi avision
(Build: 296)
sane-avision
ScanJet 5400c USB 0x03f0/0x1005 Basic   hp5400
(1.0-2)
sane-hp5400
ScanJet 5470c USB 0x03f0/0x1105 Basic   hp5400
(1.0-2)
sane-hp5400
ScanJet 5490c USB   Basic   hp5400
(1.0-2)
sane-hp5400
ScanJet 5500C USB 0x03f0/0x1305 Untested Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives hp5590
(1.0.5)
sane-hp5590
ScanJet 5530C Photosmart USB 0x03f0/0x1605 Unsupported Maybe GL841_HP, but not confirmed, maybe can be added to genesys backend unsupported
(2010-06-09)
?
ScanJet 5550C USB 0x03f0/0x1205 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives hp5590
(1.0.5)
sane-hp5590
ScanJet 5590 USB 0x03f0/0x1705 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives hp5590
(1.0.5)
sane-hp5590
ScanJet 6100C SCSI   Complete   hp
(1.06)
sane-hp
ScanJet 6200C SCSI USB 0x03f0/0x0201 Complete   hp
(1.06)
sane-hp
ScanJet 6250C SCSI USB 0x03f0/0x0201 Complete   hp
(1.06)
sane-hp
ScanJet 6300C SCSI USB 0x03f0/0x0601 Complete   hp
(1.06)
sane-hp
ScanJet 6350C SCSI USB 0x03f0/0x0601 Complete   hp
(1.06)
sane-hp
ScanJet 6390C SCSI USB 0x03f0/0x0601 Complete   hp
(1.06)
sane-hp
ScanJet 7400c USB 0x03f0/0x0801 Good 1 pass, 2400 dpi - dual USB/SCSI interface avision
(Build: 296)
sane-avision
ScanJet 7450c USB 0x03f0/0x0801 Good 1 pass, 2400 dpi - dual USB/SCSI interface avision
(Build: 296)
sane-avision
ScanJet 7490c USB 0x03f0/0x0801 Good 1 pass, 1200 dpi - dual USB/SCSI interface avision
(Build: 296)
sane-avision
ScanJet 7650 USB 0x03f0/0x1805 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives hp5590
(1.0.5)
sane-hp5590
ScanJet 8200 USB 0x03f0/0x0b01 Good 1 pass, 4800 (?) dpi - USB 2.0 avision
(Build: 296)
sane-avision
ScanJet 8250 USB 0x03f0/0x0b01 Good 1 pass, 4800 (?) dpi - USB 2.0 avision
(Build: 296)
sane-avision
ScanJet 8270 USB 0x03f0/0x3905 Good 1 pass, 4800 (?) dpi - USB 2.0 avision
(Build: 296)
sane-avision
ScanJet 8290 USB 0x03f0/0x0b01 Good 1 pass, 4800 (?) dpi - USB 2.0 and SCSI - only SCSI tested so far avision
(Build: 296)
sane-avision
ScanJet 8300 USB 0x03f0/0x3805 Good 1 pass, 4800 (?) dpi - USB 2.0 avision
(Build: 296)
sane-avision
ScanJet 8350 USB 0x03f0/0x3805 Good 1 pass, 4800 (?) dpi - USB 2.0 avision
(Build: 296)
sane-avision
ScanJet 8390 USB 0x03f0/0x3805 Good 1 pass, 4800 (?) dpi - USB 2.0 avision
(Build: 296)
sane-avision
ScanJet G2410 USB 0x03f0/0x0a01 Basic clone of the HP 2400C genesys
(1.0-63)
sane-genesys
ScanJet G2710 USB 0x03f0/0x2805 Basic Similar to hp scanjet 3800 hp3900
(0.12)
sane-hp3900
ScanJet G3010 USB 0x03f0/0x4205 Basic Similar to hp scanjet 4370 hp3900
(0.12)
sane-hp3900
ScanJet G3110 USB 0x03f0/0x4305 Basic Similar to hp scanjet 4370 hp3900
(0.12)
sane-hp3900
ScanJet G4000 USB 0x03f0/0x4505 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
ScanJet G4010 USB 0x03f0/0x4505 Good resolution from 100 to 2400 supported, UTA not supported yet genesys
(1.0-63)
sane-genesys
ScanJet G4050 USB 0x03f0/0x4605 Good resolution from 100 to 2400 supported, UTA not supported yet genesys
(1.0-63)
sane-genesys
ScanJet IIc SCSI   Complete   hp
(1.06)
sane-hp
ScanJet IIcx SCSI   Complete   hp
(1.06)
sane-hp
ScanJet IIp SCSI   Complete   hp
(1.06)
sane-hp
ScanJet N6310 USB 0x03f0/0x4705 Untested Not supported yet genesys
(1.0-63)
sane-genesys
ScanJet Plus Propietary   Complete Driver for HP parallel interface card required hp
(1.06)
sane-hp

Manufacturer: IBM

Link(s): http://www.ibm.com/, http://www.ibm.com

Model Interface USB id Status Comment Backend Manpage
2456 SCSI   Basic Was reported to work long time ago. Reports are welcome. ibm
(1.0-4)
sane-ibm
ADF Color Scanner Proprietary   Unsupported Unsupported. Uses proprietary ISA card. Maybe the same as the Plustek Spectra ADF? unsupported
(2010-06-09)
?

Manufacturer: IOMagic

Link(s): http://www.iomagic.com/

Model Interface USB id Status Comment Backend Manpage
MobileScan USB USB Parport 0x05cb/0x1483 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Iris

Link(s): http://irislink.com/

Model Interface USB id Status Comment Backend Manpage
IriScan USB 0x0a53/0x1000 Unsupported Unsupported. LM9832/3. See link for details. unsupported
(2010-06-09)
?
IRISCard Pro (IBCR II) USB 0x0a38/0x0301 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
IRISPen Translator Executive USB 0x0f43/0x015a Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: iVina

Model Interface USB id Status Comment Backend Manpage
1200U USB 0x0638/0x0268 Untested   avision
(Build: 296)
sane-avision

Manufacturer: Kodak

Link(s): http://www.kodak.com, http://www.kodak.com/

Model Interface USB id Status Comment Backend Manpage
Color Scanner 3590C SCSI   Untested Please test! kodak
(7)
sane-kodak
Color Scanner 4500 SCSI   Untested Please test! kodak
(7)
sane-kodak
ESP 5 USB 0x040a/0x4032 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 7 USB 0x040a/0x403e Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 9 USB 0x040a/0x403f Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 2150 USB 0x040a/0x4059 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 2170 USB 0x040a/0x4066 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 3200 USB 0x040a/0x4043 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 3300 USB 0x040a/0x4031 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 4100 USB 0x040a/0x4053 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 5000 USB 0x040a/0x4028 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 5100 USB 0x040a/0x4025 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 5200 USB Ethernet 0x040a/0x4041 Basic USB good, Network good kodakaio
(2.4.6)
sane-kodakaio
ESP 5300 USB 0x040a/0x4026 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 5500 USB 0x040a/0x4027 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 6100 USB 0x040a/0x4054 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 7200 USB 0x040a/0x4056 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP 9200 USB 0x040a/0x4065 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP C110 USB 0x040a/0x4057 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP C115 USB 0x040a/0x4058 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP C310 USB 0x040a/0x405d Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
ESP C315 USB 0x040a/0x405e Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
Hero 3.1 USB 0x040a/0x406d Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
Hero 5.1 USB 0x040a/0x4064 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
Hero 7.1 USB 0x040a/0x4063 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
Hero 9.1 USB Ethernet 0x040a/0x4067 Basic USB good, Network good kodakaio
(2.4.6)
sane-kodakaio
Hero Office 6.1 USB 0x040a/0x4062 Untested Please test! kodakaio
(2.4.6)
sane-kodakaio
i30 USB 0x040a/0x6001 Untested   avision
(Build: 296)
sane-avision
i40 USB 0x040a/0x6002 Basic   avision
(Build: 296)
sane-avision
i50 USB 0x040a/0x6003 Untested   avision
(Build: 296)
sane-avision
i55 USB 0x040a/0x6003 Untested   avision
(Build: 296)
sane-avision
i60 USB 0x040a/0x6004 Untested   avision
(Build: 296)
sane-avision
i65 USB 0x040a/0x6004 Untested   avision
(Build: 296)
sane-avision
i80 USB 0x040a/0x6005 Good   avision
(Build: 296)
sane-avision
i150 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i160 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i250 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i260 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i280 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i610 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i620 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i640 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i660 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i730 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i750 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i780 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i810 Scanner SCSI   Untested Please test! kodak
(7)
sane-kodak
i820 Scanner SCSI   Untested Please test! kodak
(7)
sane-kodak
i830 Scanner SCSI   Untested Please test! kodak
(7)
sane-kodak
i840 Scanner SCSI   Untested Please test! kodak
(7)
sane-kodak
i1840 Scanner IEEE-1394   Untested Please test! kodak
(7)
sane-kodak
i1860 Scanner IEEE-1394   Basic Uncompressed B&W, Gray and Color, some automatic features supported kodak
(7)
sane-kodak
s1740 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 900 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 923 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 1500 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 2500 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 3500 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 3510 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 3520 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 5500 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 7500 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 7520 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 9500 SCSI   Untested Please test! kodak
(7)
sane-kodak
Scanner 9520 SCSI   Untested Please test! kodak
(7)
sane-kodak
Snapshot Photo Scanner 1 Parport   Unsupported Unsupported. FCC ID HWF96PHS unsupported
(2010-06-09)
?

Manufacturer: Komodo

Link(s): http://www.komodo.com/

Model Interface USB id Status Comment Backend Manpage
S1200 SCSI   Untested rebadged Sceptre S1200 sceptre
(1.0-10)
sane-sceptre

Manufacturer: KONICA MINOLTA

Link(s): http://www.konicaminolta.com/

Model Interface USB id Status Comment Backend Manpage
BizHub 162/132 USB Network   Unsupported Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov. magicolor
(1.0.0)
sane-magicolor
DiMage 1611 USB Network   Unsupported Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov. magicolor
(1.0.0)
sane-magicolor
DiMAGE Scan Elite 5400 USB IEEE-1394 0x0686/0x400e Unsupported Probably unsupported. May work with vuescan. See link for details. unsupported
(2010-06-09)
?
DiMAGE Scan Elite 5400 2 USB 0x132b/0x0012 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
DiMAGE Scan Multi Pro IEEE-1394   Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
Dual Scan III USB 0x0686/0x400d Unsupported Unsupported. May work with vuescan. See link for details. unsupported
(2010-06-09)
?
Dual Scan IV USB 0x132b/0x000a Unsupported Unsupported. Works with vuescan. See link for details. unsupported
(2010-06-09)
?
magicolor 1690MF USB Network 0x132b/0x2089 Good Multi-function color laser printer with fax, scanner and network interface magicolor
(1.0.0)
sane-magicolor
magicolor 2480MF USB Network   Unsupported Uses a different scanning protocol than the magicolor 1690MF unsupported
(2010-06-09)
?

Manufacturer: Kyocera

Model Interface USB id Status Comment Backend Manpage
FS-1016MFP USB 0x0482/0x0335 Untested 1 pass, ??? dpi, A4 avision
(Build: 296)
sane-avision

Manufacturer: LEO

Model Interface USB id Status Comment Backend Manpage
LEOScan S3 SCSI   Good FCC ID LUZFS1130 leo
(1.0-10)
sane-leo

Manufacturer: Lexmark

Link(s): http://www.lexmark.com/

Model Interface USB id Status Comment Backend Manpage
P6250 USB 0x043d/0x0097 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
Photo 3150 USB 0x043d/0x007d Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
X12xx USB 0x043d/0x007d Good USB1.1 is OK, USB2.0 needs testing lexmark
(1.0-0)
sane-lexmark
X70 USB 0x043d/0x002d Good Works, some resolutions fail at 16 bit gt68xx
(1.0-84)
sane-gt68xx
X73 USB 0x043d/0x002d Good Works, some resolutions fail at 16 bit, same as X70 gt68xx
(1.0-84)
sane-gt68xx
X74 USB 0x043d/0x0060 Good Supports 75, 150, 300, 600 dpi lexmark
(1.0-0)
sane-lexmark
X75 USB 0x043d/0x0060 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
X75 PrinTrio USB 0x043d/0x0060 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
X83 USB 0x043d/0x003d Unsupported Unsupported. GL640. unsupported
(2010-06-09)
?
X1110 USB 0x043d/0x007c Untested   lexmark
(1.0-0)
sane-lexmark
X1130 USB 0x043d/0x007c Good Supports 75, 150, 300, 600 dpi lexmark
(1.0-0)
sane-lexmark
X1140 USB 0x043d/0x007c Untested   lexmark
(1.0-0)
sane-lexmark
X1150 USB 0x043d/0x007c Good Supports 75, 150, 300, 600 dpi lexmark
(1.0-0)
sane-lexmark
X1170 USB 0x043d/0x007c Good Supports 75, 150, 300, 600 dpi lexmark
(1.0-0)
sane-lexmark
X1180 USB 0x043d/0x007c Good   lexmark
(1.0-0)
sane-lexmark
X1185 USB 0x043d/0x007c Good Tested with xscanimage. Supports 75, 150, 300, 600, 1200(600x1200) dpi resolutions. Does grayscale or colour scans in the following sizes: wallet, 3x5, 4x6, 5x7, 8x10, letter. lexmark
(1.0-0)
sane-lexmark
X1195 USB 0x043d/0x007c Untested   lexmark
(1.0-0)
sane-lexmark
X2330 USB 0x043d/0x00bb Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
X3450 USB 0x043d/0x00f6 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
X5130 USB 0x043d/0x0065 Unsupported Unsupported. unsupported
(2010-06-09)
?
X5150 USB 0x043d/0x0065 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
X5250 USB 0x043d/0x0093 Unsupported Unsupported. unsupported
(2010-06-09)
?
X6170 USB 0x043d/0x0072 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
X7170 USB 0x043d/0x0098 Unsupported Unsupported. See bug #310889 for details. unsupported
(2010-06-09)
?
X7350 USB 0x043d/0x00b8 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
X8350 USB 0x043d/0x00b9 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Linotype Hell

Link(s): http://www.heidelberg.com/

Model Interface USB id Status Comment Backend Manpage
Jade SCSI   Good OK, SCSI-ID=LinoHell JADE umax
(1.0-41)
sane-umax
Jade SCSI   Good OK, SCSI-ID=LinoHell Office umax
(1.0-41)
sane-umax
Jade2 SCSI   Good OK, SCSI-ID=LinoHell Office2 umax
(1.0-41)
sane-umax
Linoscan 1400 SCSI   Good OK, SCSI-ID=HDM LS4H1S umax
(1.0-41)
sane-umax
Opal SCSI   Untested support disabled until tested - please contact author umax
(1.0-41)
sane-umax
Opal Ultra SCSI   Untested support disabled until tested - please contact author umax
(1.0-41)
sane-umax
Opal2 SCSI   Good OK; SCSI-ID=LinoHell OPAL2 umax
(1.0-41)
sane-umax
Saphir SCSI   Untested support disabled until tested - please contact author umax
(1.0-41)
sane-umax
Saphir HiRes SCSI   Untested support disabled until tested - please contact author umax
(1.0-41)
sane-umax
Saphir Ultra SCSI   Untested support disabled until tested - please contact author umax
(1.0-41)
sane-umax
Saphir Ultra II SCSI   Good OK, SCSI-ID=Linotype SAPHIR4 umax
(1.0-41)
sane-umax
Saphir2 SCSI   Good OK, SCSI-ID=LinoHell SAPHIR2 umax
(1.0-41)
sane-umax
Saphir3 SCSI   Good OK, SCSI-ID=LinoHell SAPHIR3 umax
(1.0-41)
sane-umax

Manufacturer: Logitech

Model Interface USB id Status Comment Backend Manpage
PageScan Color Parport   Unsupported Most probably unsupported. unsupported
(2010-06-09)
?
PageScan USB USB 0x046d/0x040f Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Medion/Lifetec/Tevion/Cytron

Link(s): http://www.medion.com, http://www.medion.com/, http://www.medion.de/
Comment: Sold by Aldi and Tchibo.

Model Interface USB id Status Comment Backend Manpage
LT 9452 USB 0x05d8/0x4002 Good Similar to Mustek ScanExpress 1200 UB Plus gt68xx
(1.0-84)
sane-gt68xx
MD 4394 USB 0x05d8/0x4002 Good Product id 0x4002. If you have 0x4003, use artec_eplus48u backend. gt68xx
(1.0-84)
sane-gt68xx
MD 6190 USB 0x0461/0x037b Unsupported Probably unsupported. There seem to exist two different scanners with that name. See link for details. unsupported
(2010-06-09)
?
MD 6190 USB 0x0461/0x0392 Unsupported Probably unsupported. There seem to exist two different scanners with that name. See link for details. unsupported
(2010-06-09)
?
MD 9458 USB 0x05d8/0x4002 Good Similar to Artec Ultima 2000 (e+?) gt68xx
(1.0-84)
sane-gt68xx
MD 9806 Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp
MD 9848 Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp
MD 40420 USB 0x05da/0x3008 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
MD 41260 USB 0x0461/0x037b Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
MD 41985 USB 0x0461/0x037b Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
MD 42666 USB 0x05da/0x3008 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
MD 85264 USB 0x08ff/0x2580 Unsupported Fingerprint sensor. See link for details. unsupported
(2010-06-09)
?
MD 90009 USB 0x05da/0x30e5 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
MD 90070 USB 0x05da/0x3022 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
MD 90090 USB 0x05da/0x3022 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
MD/LT 935x Parport (EPP)   Good 600x1200 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
MD/LT 985x Parport (EPP)   Good 600x1200 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
MD/LT 9375 USB 0x05d8/0x4002 Untested Untested, but is reported to have the same ids as the Artec Ultima 2000. Please test. gt68xx
(1.0-84)
sane-gt68xx
MD/LT 9385 USB 0x05d8/0x4002 Good Similar to Artec Ultima 2000 gt68xx
(1.0-84)
sane-gt68xx
MD/LT 9890 Parport (EPP)   Good 600x1200 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
MD4394 USB 0x05d8/0x4003 Good Only scanners with product id 0x4003 will work; try the gt68xx backend, if your scanner has product id 0x4002 artec_eplus48u
(unmaintained)
sane-artec_eplus48u
MD5345 USB 0x0461/0x0377 Good Has a Primax USB ID genesys
(1.0-63)
sane-genesys
MD6228 USB 0x0461/0x0377 Good Has a Primax USB ID. Same as MD5345 genesys
(1.0-63)
sane-genesys
MD6471 USB 0x0461/0x0377 Complete Has a Primax USB ID. Same as MD5345 genesys
(1.0-63)
sane-genesys
MD9693 USB 0x05d8/0x4003 Good   artec_eplus48u
(unmaintained)
sane-artec_eplus48u
MD9705 USB 0x05d8/0x4003 Good   artec_eplus48u
(unmaintained)
sane-artec_eplus48u

Manufacturer: Memorex

Link(s): http://www.artecusa.com/, http://www.memorex.com/

Model Interface USB id Status Comment Backend Manpage
6136u USB 0x0461/0x0346 Unsupported Probably unsupported. unsupported
(2010-06-09)
?
6142u USB 0x0461/0x0347 Unsupported Probably unsupported. Same as Visioneer Onetouch 4400. See link for details. unsupported
(2010-06-09)
?
MaxxScan 6122 USB Parport 0x05cb/0x1483 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
MEM 48U USB 0x05d8/0x4005 Good   artec_eplus48u
(unmaintained)
sane-artec_eplus48u
SCF 9612P Parport   Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Micromaxx

Model Interface USB id Status Comment Backend Manpage
MM-9851 Parport (EPP)   Good 300x600 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp

Manufacturer: Microstar

Link(s): http://www.microstar.de/

Model Interface USB id Status Comment Backend Manpage
MR 9791 USB 0x05d8/0x4003 Good   artec_eplus48u
(unmaintained)
sane-artec_eplus48u

Manufacturer: Microtek

Link(s): http://www.microtek.com/
Comment: Microtek makes a wide variety of devices.

Model Interface USB id Status Comment Backend Manpage
ArtixScan 2020 SCSI   Unsupported Unsupported. Same as Agfa DuoScan T2000XL? unsupported
(2010-06-09)
?
Artixscan 2500f SCSI IEEE-1384   Unsupported Unsupported. Same as Agfa DuoScan T2500? unsupported
(2010-06-09)
?
ArtixScan 4000tf USB   Unsupported Unsupported. Uses ALI M5611B. unsupported
(2010-06-09)
?
ArtixScanDI 2020 USB 0x05da/0x202e Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
Color PageWiz SCSI (Parport)   Basic sheet-fed (preliminary, see mapage) microtek
(0.13.1)
sane-microtek
FilmScan 35 USB 0x05e3/0x0120 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
Phantom 330CX Parport   Complete   microtek2
(unmaintained)
sane-microtek2
Phantom 636 SCSI   Complete   microtek2
(unmaintained)
sane-microtek2
Phantom 636CX Parport   Complete   microtek2
(unmaintained)
sane-microtek2
ScanMaker 5 SCSI   Unsupported Probably unsupported. See link for more details. unsupported
(2010-06-09)
?
Scanmaker 35 SCSI   Good slide-scanner microtek
(0.13.1)
sane-microtek
Scanmaker 35t+ SCSI   Good slide-scanner microtek
(0.13.1)
sane-microtek
Scanmaker 45t SCSI   Good slide-scanner microtek
(0.13.1)
sane-microtek
ScanMaker 330 SCSI   Basic   microtek2
(unmaintained)
sane-microtek2
ScanMaker 336 CX SCSI   Unsupported Probably unsupported. Seems to be similar to the Microtek 330 CX and is detected by the microtek2 backend. Scanning doesn't seem to work however. unsupported
(2010-06-09)
?
Scanmaker 600G(S) SCSI   Basic gray only (see manpage) microtek
(0.13.1)
sane-microtek
Scanmaker 600Z(S) SCSI   Untested   microtek
(0.13.1)
sane-microtek
ScanMaker 630 SCSI   Basic   microtek2
(unmaintained)
sane-microtek2
ScanMaker 636 SCSI   Complete   microtek2
(unmaintained)
sane-microtek2
Scanmaker 1850S SCSI   Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
ScanMaker 3600 USB 0x05da/0x40ff Basic works sm3600
(0.1)
sane-sm3600
ScanMaker 3600 USB 0x05da/0x40ca Basic works sm3600
(0.1)
sane-sm3600
ScanMaker 3600 USB 0x05da/0x40b3 Basic works sm3600
(0.1)
sane-sm3600
ScanMaker 3630 USB 0x0461/0x0347 Unsupported Unsupported. Doesn't seem to be compatible to 3600 series, see link. unsupported
(2010-06-09)
?
ScanMaker 3700 USB 0x05da/0x40cb Basic works sm3600
(0.1)
sane-sm3600
ScanMaker 3700 USB 0x05da/0x40b8 Basic works sm3600
(0.1)
sane-sm3600
ScanMaker 3750 USB 0x05da/0x40dd Basic works (told) sm3600
(0.1)
sane-sm3600
ScanMaker 3800 USB 0x05da/0x30ce Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 3830 USB 0x05da/0x30ce Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 3840 USB 0x05da/0x30d4 Good 8 and 16 bit, color and grayscale sm3840
(1.1)
sane-sm3840
ScanMaker 3860 USB 0x05da/0x3023 Unsupported Unsupported. See link for more details. Appears to be similar to ScanMaker 3880. unsupported
(2010-06-09)
?
ScanMaker 3880 USB 0x05da/0x3021 Unsupported Unsupported. SQ113 chip. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 4600 USB 0x05da/0x40c7 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 4700 USB 0x05da/0x20b4 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 4800 USB 0x05da/0x30cf Good Same hardware as SM3840, different color box sm3840
(1.1)
sane-sm3840
ScanMaker 4850 USB 0x05da/0x30d9 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
ScanMaker 4850 II USB 0x05da/0x3008 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
ScanMaker 4900 USB 0x05da/0x30b9 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 5600 USB 0x05da/0x20a7 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 5700 USB 0x05da/0x20bd Unsupported Unsupported. Uses ALI M5615 like the ScanMaker 4700. unsupported
(2010-06-09)
?
ScanMaker 5800 USB 0x05da/0x30d8 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
ScanMaker 5800 USB 0x05da/0x3008 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
ScanMaker 5900 USB 0x05da/0x30d8 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 5950 USB 0x05da/0x30d8 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 6000 USB 0x05da/0x30e5 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 6100 USB 0x05da/0x30e5 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanMaker 6400XL SCSI   Complete   microtek2
(unmaintained)
sane-microtek2
ScanMaker 6700 USB IEEE-1394 0x05da/0x20c9 Unsupported Unsupported. See link. unsupported
(2010-06-09)
?
ScanMaker 8700 USB IEEE-1394 0x05da/0x20b1 Unsupported Unsupported. See link for details. USB vendor and product ids to be checked. unsupported
(2010-06-09)
?
ScanMaker 9600XL USB IEEE-1394 0x05da/0x20de Unsupported Probably unsupported. SCSI seems to work with microtek2 backend. unsupported
(2010-06-09)
?
ScanMaker 9600XL SCSI   Good only flatbed mode ? microtek2
(unmaintained)
sane-microtek2
ScanMaker 9800XL USB SCSI 0x05da/0x20de Unsupported Partly unsupported. IEEE-1394 works with microtek2 backend. See link. unsupported
(2010-06-09)
?
ScanMaker 9800XL IEEE-1394   Minimal IEEE-1394 seems to work. See link. More reports welcome. microtek2
(unmaintained)
sane-microtek2
Scanmaker E2 SCSI   Good 3-pass microtek
(0.13.1)
sane-microtek
Scanmaker E3 SCSI   Good   microtek
(0.13.1)
sane-microtek
ScanMaker E3plus SCSI   Complete   microtek2
(unmaintained)
sane-microtek2
ScanMaker E3plus Parport   Complete   microtek2
(unmaintained)
sane-microtek2
Scanmaker E6 SCSI   Good   microtek
(0.13.1)
sane-microtek
ScanMaker i320 USB 0x05da/0x30e6 Unsupported Unsupported. See link. unsupported
(2010-06-09)
?
Scanmaker II SCSI   Good 3-pass microtek
(0.13.1)
sane-microtek
Scanmaker IIG SCSI   Good gray only microtek
(0.13.1)
sane-microtek
Scanmaker IIHR SCSI   Good 3-pass microtek
(0.13.1)
sane-microtek
Scanmaker III SCSI   Good   microtek
(0.13.1)
sane-microtek
Scanmaker IISP SCSI   Good   microtek
(0.13.1)
sane-microtek
ScanMaker S400 USB 0x05da/0x300b Unsupported Unsupported. See link. unsupported
(2010-06-09)
?
ScanMaker s400 USB 0x05da/0x201c Unsupported Unsupported. See link. unsupported
(2010-06-09)
?
ScanMaker V6UPL USB 0x05da/0x00b6 Basic Sometimes scan speed goes to fast and results look badly smudged. microtek2
(unmaintained)
sane-microtek2
ScanMaker V6USL USB 0x05da/0x80a3 Complete   microtek2
(unmaintained)
sane-microtek2
ScanMaker V6USL USB 0x05da/0x00a3 Complete   microtek2
(unmaintained)
sane-microtek2
ScanMaker V6USL SCSI   Complete   microtek2
(unmaintained)
sane-microtek2
ScanMaker V300 Parport   Good   microtek2
(unmaintained)
sane-microtek2
ScanMaker V300 SCSI   Good   microtek2
(unmaintained)
sane-microtek2
ScanMaker V310 Parport   Basic   microtek2
(unmaintained)
sane-microtek2
ScanMaker V310 SCSI   Basic   microtek2
(unmaintained)
sane-microtek2
ScanMaker V600 Parport   Basic   microtek2
(unmaintained)
sane-microtek2
ScanMaker V600 SCSI   Basic   microtek2
(unmaintained)
sane-microtek2
ScanMaker X6 SCSI   Complete   microtek2
(unmaintained)
sane-microtek2
ScanMaker X6EL SCSI   Basic   microtek2
(unmaintained)
sane-microtek2
ScanMaker X6USB USB 0x05da/0x0099 Good   microtek2
(unmaintained)
sane-microtek2
ScanMaker X12USL SCSI   Good only Flatbed mode ? microtek2
(unmaintained)
sane-microtek2
ScanPort 3000 USB 0x04a7/0x0224 Unsupported Unsupported. Vendor/Product ids: 0x04a7/0x0224. Realtek RTS8801B?. See link for details. unsupported
(2010-06-09)
?
SlimScan C3 Parport   Complete   microtek2
(unmaintained)
sane-microtek2
SlimScan C6 USB 0x05da/0x009a Complete   microtek2
(unmaintained)
sane-microtek2

Manufacturer: Minolta

Link(s): http://www.minolta.com

Model Interface USB id Status Comment Backend Manpage
Dimage Scan Dual I SCSI   Basic   avision
(Build: 296)
sane-avision
Dimage Scan Dual II USB 0x0638/0x026a Good 1 pass, film-scanner avision
(Build: 296)
sane-avision
Dimage Scan Dual III USB 0x0686/0x400d Good 1 pass, film-scanner avision
(Build: 296)
sane-avision
Dimage Scan Elite 5400 USB 0x0686/0x400e Good 1 pass, film-scanner avision
(Build: 296)
sane-avision
Elite II USB 0x0686/0x4004 Untested 1 pass, film-scanner avision
(Build: 296)
sane-avision
Scan Multi Pro SCSI   Untested   avision
(Build: 296)
sane-avision

Manufacturer: Minolta-QMS

Model Interface USB id Status Comment Backend Manpage
SC-110 USB 0x0638/0x0a15 Untested   avision
(Build: 296)
sane-avision
SC-215 USB 0x0638/0x0a16 Good   avision
(Build: 296)
sane-avision

Manufacturer: Mitsubishi

Link(s): http://www.mitsubishi.com

Model Interface USB id Status Comment Backend Manpage
Diamondview 648UT USB 0x04a5/0x2022 Good Rebadged Benq 320u. SnapScan
(1.4)
sane-snapscan
Diamondview 650U USB 0x04a5/0x20b0 Good Rebadged Benq 4300. SnapScan
(1.4)
sane-snapscan
MCA-ADFC SCSI   Untested   avision
(Build: 296)
sane-avision
S600C SCSI   Untested   avision
(Build: 296)
sane-avision
S1200C SCSI   Untested   avision
(Build: 296)
sane-avision
SS600 SCSI   Good   avision
(Build: 296)
sane-avision

Manufacturer: Mustek

Link(s): http://www.mustek.com/, http://www.mustek.com.tw/, http://www.mustek.de/

Model Interface USB id Status Comment Backend Manpage
96 CP Parport (EPP)   Good 300x600 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
600 III EP Plus Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp
1200 III EP Parport   Unsupported Probably not supported. quarlewm at jmu dot edu offers to temporarily loan such a scanner to anyone who is interested in writing a driver. unsupported
(2010-06-09)
?
2400 M USB   Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
BearPaw 1200 USB 0x0400/0x1001 Complete both product versions are supported, see backends' man-page plustek
(0.52)
sane-plustek
BearPaw 1200 USB 0x0400/0x1000 Complete both product versions are supported, see backends' man-page plustek
(0.52)
sane-plustek
BearPaw 1200 CS USB 0x055f/0x021e Good   gt68xx
(1.0-84)
sane-gt68xx
BearPaw 1200 CU USB 0x05d8/0x4002 Good   gt68xx
(1.0-84)
sane-gt68xx
BearPaw 1200 CU Plus USB 0x055f/0x021c Good   gt68xx
(1.0-84)
sane-gt68xx
BearPaw 1200 CU Plus USB 0x055f/0x021b Good   gt68xx
(1.0-84)
sane-gt68xx
BearPaw 1200 F USB 0x055f/0x0010 Good Works upto 600 dpi. No support for TA and ADF yet. ma1509
(1.0-3)
sane-ma1509
BearPaw 1200 TA USB 0x055f/0x021e Good Transparency adapter supported gt68xx
(1.0-84)
sane-gt68xx
BearPaw 1248 CU USB 0x055f/0x021c Good Seems to use the same ids as BearPaw 1200 CU Plus. gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2400 USB 0x0400/0x1001 Complete   plustek
(0.52)
sane-plustek
BearPaw 2400 CS USB 0x055f/0x0218 Untested Probably works, reports are welcome gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2400 CS Plus USB 0x055f/0x0219 Good Works, problems with 12/16 bit modes? gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2400 CU USB 0x05d8/0x4002 Basic Works, but is slow gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2400 CU Plus USB 0x055f/0x021d Good   gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2400 TA USB 0x055f/0x0218 Good Transparency adapter supported gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2400 TA Plus USB 0x055f/0x0219 Good Transparency adapter supported gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2400 TA Pro USB 0x055f/0x0400 Unsupported Not supported. May be supported by mustek_usb2 backend later. See link for some information. unsupported
(2010-06-09)
?
BearPaw 2448 CS Plus USB 0x055f/0x021a Basic Slow. Same as 2448 TA Plus, but without TA. gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2448 CU Pro USB 0x055f/0x0408 Unsupported Not supported. May be supported by mustek_usb2 backend later. See link for some information. unsupported
(2010-06-09)
?
BearPaw 2448 TA Plus USB 0x055f/0x021a Basic Slow. Transparency adapter supported. Slow. Brightness depends on resolution? gt68xx
(1.0-84)
sane-gt68xx
BearPaw 2448TA Pro USB 0x055f/0x0409 Good   mustek_usb2
(1.0-10)
sane-mustek_usb2
BearPaw 4800 TA Pro USB 0x055f/0x1000 Unsupported Not supported. See link for some information. unsupported
(2010-06-09)
?
BearPaw 4800 TA Pro II USB 0x055f/0x040a Unsupported Not supported. May be supported by mustek_usb2 backend later. See link for some information. unsupported
(2010-06-09)
?
BearPaw 6400 TA Pro USB 0x055f/0x040b Unsupported Not supported. May be supported by mustek_usb2 backend later. See link for some information. unsupported
(2010-06-09)
?
Paragon 600 II CD SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon 600 II ED Parport   Untested Completely untested. If it's the same as the 600 II EP, it may work. Please contact me if you own such a device. mustek
(1.0-138)
sane-mustek
Paragon 600 II EP Parport   Minimal Works, however only low resolutions and quality in color mode is bad. mustek
(1.0-138)
sane-mustek
Paragon 600 II N Proprietary   Basic Resolutions above 300 dpi may cause trouble. mustek
(1.0-138)
sane-mustek
Paragon 800 II EP Parport   Unsupported Not supported. Maybe similar to 600 II EP (SCSI_over-parport)? In this case it could be supported by the mustek SCSI backend. unsupported
(2010-06-09)
?
Paragon 800 II SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon 1200 A3 Pro SCSI   Complete ADF and TA untested. Please contact me if you own such equipment. mustek
(1.0-138)
sane-mustek
Paragon 1200 III SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon 1200 LS SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon 1200 SP Pro SCSI   Good   mustek
(1.0-138)
sane-mustek
Paragon MFC-600S SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon MFC-800S SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon MFS-1200SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon MFS-6000CX SCSI   Good 3-pass mustek
(1.0-138)
sane-mustek
Paragon MFS-6000SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon MFS-8000SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
Paragon MFS-12000CX SCSI   Good 3-pass mustek
(1.0-138)
sane-mustek
Paragon MFS-12000SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
Plug-n-Scan 2400 M USB 0x055f/0x0219 Good Works but is slow in high resolutions. Same as BearPaw 2400 CS Plus. gt68xx
(1.0-84)
sane-gt68xx
Plug-n-Scan 2400 MT USB 0x055f/0x0219 Good Works but is slow in high resolutions. Same as BearPaw 2400 TA Plus. gt68xx
(1.0-84)
sane-gt68xx
ScanExpress 600 CP Parport (EPP)   Good 300x600 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
ScanExpress 600 CU USB 0x055f/0x0002 Complete   mustek_usb
(1.0-18)
sane-mustek_usb
ScanExpress 600 SEP Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp
ScanExpress 600 USB USB 0x055f/0x0873 Unsupported Unsupported. Programming information is available. unsupported
(2010-06-09)
?
ScanExpress 1200 CP Parport (EPP)   Good 600x1200 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
ScanExpress 1200 CP+ Parport (EPP)   Good 600x1200 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
ScanExpress 1200 CU USB 0x055f/0x0001 Complete   mustek_usb
(1.0-18)
sane-mustek_usb
ScanExpress 1200 CU Plus USB 0x055f/0x0008 Complete   mustek_usb
(1.0-18)
sane-mustek_usb
ScanExpress 1200 FS SCSI   Untested One report that it crashes the computer. SCSI driver issue? Please contact me if you own such a device. mustek
(1.0-138)
sane-mustek
ScanExpress 1200 UB USB 0x055f/0x0006 Complete For the UB Plus, see gt68xx backend mustek_usb
(1.0-18)
sane-mustek_usb
ScanExpress 1200 UB Plus USB 0x05d8/0x4002 Good   gt68xx
(1.0-84)
sane-gt68xx
ScanExpress 1200 USB USB 0x055f/0x0003 Unsupported Unsupported. Programming information is available. unsupported
(2010-06-09)
?
ScanExpress 1200 USB Plus USB 0x055f/0x0007 Unsupported Unsupported. unsupported
(2010-06-09)
?
ScanExpress 1248 UB USB 0x055f/0x021f Complete   gt68xx
(1.0-84)
sane-gt68xx
ScanExpress 2400 USB USB 0x05d8/0x4002 Minimal Should be detected but may need some more work in the code. Testers welcome. Please contact me if you own this scanner. gt68xx
(1.0-84)
sane-gt68xx
ScanExpress 6000 P Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp
ScanExpress 6000SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
ScanExpress 12000 P Parport   Unsupported Not supported. Asic 1505/05. unsupported
(2010-06-09)
?
ScanExpress 12000SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
ScanExpress 12000SP Plus SCSI   Complete   mustek
(1.0-138)
sane-mustek
ScanExpress A3 EP Parport   Unsupported Not supported. Maybe it will be supported by the mustek_pp backend in future. unsupported
(2010-06-09)
?
ScanExpress A3 SP SCSI   Basic Please test! mustek
(1.0-138)
sane-mustek
ScanExpress A3 USB USB 0x055f/0x0210 Basic Still some vertical stripes. gt68xx
(1.0-84)
sane-gt68xx
ScanExpress CardSmart USB   Unsupported Probably unsupported. USB business card scanner. Maybe works as USB storage device? unsupported
(2010-06-09)
?
ScanMagic 600 CP Parport (EPP)   Good 300x600 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
ScanMagic 600 II SP SCSI   Complete   mustek
(1.0-138)
sane-mustek
ScanMagic 1200 UB Plus USB 0x05d8/0x4002 Good Same as ScanExpress 1200 UB Plus gt68xx
(1.0-84)
sane-gt68xx
ScanMagic 4800 P Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp
ScanMagic 4830S SCSI   Untested sub model VM3575 teco2
(1.0-9)
sane-teco2
ScanMagic 9636P Parport   Unsupported Probably not supported. Same as Mustek 12000 P?. ASIC 1505. unsupported
(2010-06-09)
?
ScanMagic 9636S SCSI   Complete   mustek
(1.0-138)
sane-mustek
ScanMagic 9636S Plus SCSI   Complete   mustek
(1.0-138)
sane-mustek
TwainScan II SP SCSI   Complete   mustek
(1.0-138)
sane-mustek

Manufacturer: NeatReceipts

Model Interface USB id Status Comment Backend Manpage
Mobile Scanner USB 0x07b3/0x0462 Basic Similar to Plustek OpticSlim M12. gt68xx
(1.0-84)
sane-gt68xx
Scanalizer Professional 2.5 USB 0x07b3/0x0412 Untested Similar to Plustek OpticSlim M12. Please tell us if this scanner works. gt68xx
(1.0-84)
sane-gt68xx

Manufacturer: NEC

Link(s): http://www.nevt.co.jp/

Model Interface USB id Status Comment Backend Manpage
PC-IN500/4C SCSI   Good PC-IN500/4C was sold only in JAPAN nec
(0.12)
sane-nec
Petiscan USB 0x0475/0x0100 Unsupported Most probably unsupported. See link for details. Vendor ID is Relisys/Teco. Not known if it is similar to other Relisys/Teco USB scanners. unsupported
(2010-06-09)
?

Manufacturer: Network

Model Interface USB id Status Comment Backend Manpage
Easy Plus 30 Bit Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp

Manufacturer: Nikon

Link(s): http://www.nikon.com/

Model Interface USB id Status Comment Backend Manpage
AX-110 / Scantouch 110 SCSI   Untested may work, please test and give feedback umax
(1.0-41)
sane-umax
AX-210 SCSI   Good OK umax
(1.0-41)
sane-umax
Coolscan III SCSI   Complete Rebadged LS 30? coolscan3
(1.0.0)
sane-coolscan3
Coolscan V ED USB 0x04b0/0x4001 Minimal Rebadged LS 50? coolscan3
(1.0.0)
sane-coolscan3
Coolscan V ED USB 0x04b0/0x4001 Minimal   coolscan2
(0.1.8)
sane-coolscan2
Coolspan IV USB 0x04b0/0x4000 Complete Rebadged LS 40? coolscan3
(1.0.0)
sane-coolscan3
LS 30 SCSI   Complete   coolscan3
(1.0.0)
sane-coolscan3
LS 30 SCSI   Complete working -- model available to developer coolscan2
(0.1.8)
sane-coolscan2
LS 40 ED USB 0x04b0/0x4000 Complete   coolscan3
(1.0.0)
sane-coolscan3
LS 40 ED USB 0x04b0/0x4000 Complete   coolscan2
(0.1.8)
sane-coolscan2
LS 50 ED USB 0x04b0/0x4001 Minimal   coolscan3
(1.0.0)
sane-coolscan3
LS 50 ED USB 0x04b0/0x4001 Minimal   coolscan2
(0.1.8)
sane-coolscan2
LS 2000 SCSI   Good   coolscan3
(1.0.0)
sane-coolscan3
LS 2000 SCSI   Good   coolscan2
(0.1.8)
sane-coolscan2
LS 4000 ED IEEE-1394   Good needs linux kernel 2.4.19 or later coolscan3
(1.0.0)
sane-coolscan3
LS 4000 ED IEEE-1394   Good needs linux kernel 2.4.19 or later coolscan2
(0.1.8)
sane-coolscan2
LS 8000 ED IEEE-1394   Good needs linux kernel 2.4.19 or later coolscan3
(1.0.0)
sane-coolscan3
LS 8000 ED IEEE-1394   Good needs linux kernel 2.4.19 or later coolscan2
(0.1.8)
sane-coolscan2
LS-20 SCSI   Basic The LS-20 has been replaced by the LS-30 coolscan
(0.4.3)
sane-coolscan
LS-30 SCSI   Basic alpha: only 24/30 bit RGB + 32/40 bit RGBI coolscan
(0.4.3)
sane-coolscan
LS-1000 SCSI   Basic Doesn't support gamma correction coolscan
(0.4.3)
sane-coolscan
LS-2000 SCSI   Basic alpha: only 24/36 bit + RGB 32/48 bit RGBI coolscan
(0.4.3)
sane-coolscan
LS-9000 ED IEEE-1394   Unsupported Probably not supported. See link for details. Possibly similar to LS-8000 ED. unsupported
(2010-06-09)
?
Super Coolscan LS-5000 ED USB 0x04b0/0x4002 Untested May work, similar to LS 50 ED, but untested. Please tell us if it works. coolscan3
(1.0.0)
sane-coolscan3
Super Coolscan LS-5000 ED USB 0x04b0/0x4002 Untested May work, similar to LS 50 ED, but untested. Please tell us if it works. coolscan2
(0.1.8)
sane-coolscan2

Manufacturer: Nortek

Model Interface USB id Status Comment Backend Manpage
MyScan 1200 USB 0x07b3/0x040b Untested Untested. Please test. Similar to Plustek OpticPro S12? gt68xx
(1.0-84)
sane-gt68xx

Manufacturer: OKI

Model Interface USB id Status Comment Backend Manpage
S700 Scancopier USB 0x0638/0x0a16 Good 1 pass, 600 dpi, A4 avision
(Build: 296)
sane-avision

Manufacturer: Olivetti

Link(s): http://www.olivetti.com

Model Interface USB id Status Comment Backend Manpage
Job-Jet M400 USB 0x0b3c/0xa880 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Olympus

Link(s): http://www.olympus.com

Model Interface USB id Status Comment Backend Manpage
ES-10P Parport   Unsupported   unsupported
(2010-06-09)
?
ES-10S SCSI   Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Optoelectronics

Model Interface USB id Status Comment Backend Manpage
Barcode scanner USB 0x065a/0x0001 Unsupported Probably not supported. unsupported
(2010-06-09)
?

Manufacturer: Optrox

Model Interface USB id Status Comment Backend Manpage
PhotoMaker 3C Parport   Unsupported   unsupported
(2010-06-09)
?
PhotoMaker 3E Parport   Unsupported   unsupported
(2010-06-09)
?
PhotoMaker 3F Proprietary   Unsupported Special ISA card unsupported
(2010-06-09)
?
PhotoMaker 3S Parport   Unsupported   unsupported
(2010-06-09)
?
PhotoMaker 6E Parport   Unsupported   unsupported
(2010-06-09)
?
PhotoMaker 6F Proprietary   Unsupported Special ISA card unsupported
(2010-06-09)
?

Manufacturer: Packard Bell

Model Interface USB id Status Comment Backend Manpage
Diamond 1200 USB 0x05d8/0x4002 Good Similar to Mustek BearPaw 1200 (Plus) gt68xx
(1.0-84)
sane-gt68xx
Diamond 1200 Plus USB 0x055f/0x021b Good Similar to Mustek BearPaw 1200 Plus gt68xx
(1.0-84)
sane-gt68xx
Diamond 1200 Plus USB 0x055f/0x021c Good Similar to Mustek BearPaw 1200 Plus gt68xx
(1.0-84)
sane-gt68xx
Diamond 2450 USB 0x055f/0x0219 Good   gt68xx
(1.0-84)
sane-gt68xx

Manufacturer: Panasonic

Link(s): http://www.panasonic.com/

Model Interface USB id Status Comment Backend Manpage
KV-S1020C USB 0x04da/0x1007 Good   kvs1025
(unmaintained)
sane-kvs1025
KV-S1025C USB 0x04da/0x1006 Good   kvs1025
(unmaintained)
sane-kvs1025
KV-S1045C USB 0x04da/0x1010 Good   kvs1025
(unmaintained)
sane-kvs1025
KV-S2025C SCSI   Minimal no color, no high resolution, no automatic cropping matsushita
(1.0-7)
sane-matsushita
KV-S2026C USB SCSI 0x04da/0x1000 Untested   kvs20xx
(unmaintained)
sane-kvs20xx
KV-S2028C USB 0x04da/0x100a Untested   kvs20xx
(unmaintained)
sane-kvs20xx
KV-S2045C SCSI   Minimal no color, no high resolution, no automatic cropping matsushita
(1.0-7)
sane-matsushita
KV-S2046C USB SCSI 0x04da/0x1001 Untested   kvs20xx
(unmaintained)
sane-kvs20xx
KV-S2048C USB 0x04da/0x1009 Untested   kvs20xx
(unmaintained)
sane-kvs20xx
KV-S2055L SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S2055W USB SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S2065L SCSI   Minimal no color, no high resolution, no automatic cropping matsushita
(1.0-7)
sane-matsushita
KV-S2065W SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S3065CL USB SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S3065CW USB SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S3085 USB SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S3105C USB SCSI   Unsupported might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool. unsupported
(2010-06-09)
?
KV-S4065C USB 0x04da/0x100d Untested   kvs40xx
(unmaintained)
sane-kvs40xx
KV-S4085C USB 0x04da/0x100c Untested   kvs40xx
(unmaintained)
sane-kvs40xx
KV-S6040W SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S6045W SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S6050W SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S6055W SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S7065C USB SCSI   Unsupported might be supported by matsushita backend. unsupported
(2010-06-09)
?
KV-S7075C USB 0x04da/0x100e Untested   kvs40xx
(unmaintained)
sane-kvs40xx
KV-SS25 SCSI   Complete   matsushita
(1.0-7)
sane-matsushita
KV-SS25D SCSI   Complete   matsushita
(1.0-7)
sane-matsushita
KV-SS50 SCSI   Untested   matsushita
(1.0-7)
sane-matsushita
KV-SS50EX SCSI   Untested   matsushita
(1.0-7)
sane-matsushita
KV-SS55 SCSI   Untested   matsushita
(1.0-7)
sane-matsushita
KV-SS55EX SCSI   Minimal no color, no high resolution, no automatic cropping matsushita
(1.0-7)
sane-matsushita
KV-SS080 USB 0x04da/0x100f Complete All resolution and mode supported, calibration is available. Support sponsored by cncsolutions (http://www.cncsolutions.com.br) genesys
(1.0-63)
sane-genesys
KV-SS850 SCSI   Untested   matsushita
(1.0-7)
sane-matsushita
KV-SS855 SCSI   Untested   matsushita
(1.0-7)
sane-matsushita
KV-SS905C SCSI   Unsupported might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool. unsupported
(2010-06-09)
?

Manufacturer: Pentax

Link(s): http://www.pentaxtech.com/, http://mobilesolutions.brother-usa.com/

Model Interface USB id Status Comment Backend Manpage
DSmobile 600 USB 0x04f9/0x2038 Good All resolution and mode supported, calibration is available genesys
(1.0-63)
sane-genesys
DSmobile 600 USB 0x0a17/0x3210 Good All resolution and mode supported, calibration is available genesys
(1.0-63)
sane-genesys
DSmobile USB USB 0x0a82/0x2000 Unsupported Probably not supported. Some information is available. unsupported
(2010-06-09)
?

Manufacturer: PIE

Link(s): http://www.scanace.com/
Comment: Pacific Image Electronics

Model Interface USB id Status Comment Backend Manpage
PF3650 Pro3 Film Scanner USB IEEE-1394 0x05e3/0x0143 Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
Powerslide 3600 USB IEEE-1394 0x05e3/0x0142 Unsupported Probably unsupported. Film scanner that can scan directly from the magazine. unsupported
(2010-06-09)
?
Primefilm 1800u USB 0x05e3/0x0120 Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
Primefilm 2700 USB   Unsupported   unsupported
(2010-06-09)
?
Primefilm 3600PRO USB IEEE-1394   Unsupported Probably not supported. unsupported
(2010-06-09)
?
ScanAce 630S SCSI   Untested   pie
(1.0)
sane-pie
ScanAce 636S SCSI   Untested   pie
(1.0)
sane-pie
ScanAce 1230S SCSI   Good   pie
(1.0)
sane-pie
ScanAce 1236S SCSI   Good   pie
(1.0)
sane-pie
ScanAce II SCSI   Untested   pie
(1.0)
sane-pie
ScanAce II Plus SCSI   Untested   pie
(1.0)
sane-pie
ScanAce III SCSI   Good   pie
(1.0)
sane-pie
ScanAce III Plus SCSI   Untested   pie
(1.0)
sane-pie
ScanAce Plus SCSI   Untested   pie
(1.0)
sane-pie
ScanAce ScanMedia SCSI   Untested   pie
(1.0)
sane-pie
ScanAce ScanMedia II SCSI   Untested   pie
(1.0)
sane-pie
ScanAce V SCSI   Untested   pie
(1.0)
sane-pie

Manufacturer: PIOTECH

Link(s): http://www.image-land.com/

Model Interface USB id Status Comment Backend Manpage
Splendeur 3024 SCSI   Good sub model VM3552 teco3
(1.0-1)
sane-teco3

Manufacturer: PLANon

Link(s): http://www.planon.com/

Model Interface USB id Status Comment Backend Manpage
DocuPen (DPEN-BW) USB   Unsupported Probably not supported. No details known. unsupported
(2010-06-09)
?
DocuPen R700 USB 0x10c4/0xea60 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
DocuPen RC800 USB   Unsupported Probably not supported. No details known. unsupported
(2010-06-09)
?

Manufacturer: Plustek

Link(s): http://www.plustek.com/, http://www.plustek.de/

Model Interface USB id Status Comment Backend Manpage
Iriscan Express 2 USB 0x07b3/0x045f Complete Works up to 1200 dpi. Calibration with external calibration sheet supported gt68xx
(1.0-84)
sane-gt68xx
OptiCard 600+ USB   Unsupported Business card reader. No further information available. unsupported
(2010-06-09)
?
OpticBook 3600 USB 0x07b3/0x0900 Basic Has a Primax USB ID genesys
(1.0-63)
sane-genesys
OpticFilm 7200 USB 0x07b3/0x0807 Unsupported GL842 based, maybe to be added to genesys backend unsupported
(2010-06-09)
?
OpticFilm 7200i USB 0x07b3/0x0c04 Unsupported GL843 based, maybe to be added to genesys backend unsupported
(2010-06-09)
?
OpticPro 600P/6000P Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 1212U USB 0x07b3/0x0001 Basic   u12
(0.02)
sane-u12
OpticPro 1236P Parport (SPP, EPP)   Complete reported as OpticPro 12000P/96000P plustek_pp
(0.43)
sane-plustek_pp
OpticPro 1248U USB 0x07b3/0x0401 Good   gt68xx
(1.0-84)
sane-gt68xx
OpticPro 1248U USB 0x07b3/0x0400 Good   gt68xx
(1.0-84)
sane-gt68xx
OpticPro 2400SP SCSI   Untested sub model VM3552 teco3
(1.0-1)
sane-teco3
OpticPro 4800P Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 4830P Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 4831P Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 9600P Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 9630P Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 9630PL Parport (SPP, EPP)   Complete use driver-switch mov=1 plustek_pp
(0.43)
sane-plustek_pp
OpticPro 9636P Parport (SPP, EPP)   Complete use driver-switch mov=4 plustek_pp
(0.43)
sane-plustek_pp
OpticPro 9636P+/Turbo Parport (SPP, EPP)   Complete use driver-switch mov=3 plustek_pp
(0.43)
sane-plustek_pp
OpticPro 9636T Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 12000P/96000P Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 12000T Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro 19200S SCSI   Complete rebadged Artec AM12S artec
(unmaintained)
sane-artec
OpticPro A3U USB   Unsupported Uses Plustek ASIC P99002 unsupported
(2010-06-09)
?
OpticPro AI3 Parport (SPP, EPP)   Basic use driver-switch mov=5, poor picture quality plustek_pp
(0.43)
sane-plustek_pp
OpticPro P8 Parport   Untested   plustek_pp
(0.43)
sane-plustek_pp
OpticPro P12 Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro PT12 Parport (SPP, EPP)   Complete   plustek_pp
(0.43)
sane-plustek_pp
OpticPro S6 USB   Unsupported Uses RealTek chipset (RTL8801D) unsupported
(2010-06-09)
?
OpticPro S12 USB 0x07b3/0x0600 Unsupported Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend. unsupported
(2010-06-09)
?
OpticPro S12 USB 0x07b3/0x040b Good Product ID 0x040b only. gt68xx
(1.0-84)
sane-gt68xx
OpticPro S24 USB 0x07b3/0x0601 Unsupported Product id 0x0601 is unsupported but may be supported by the genesys backend in future /GL646). Product id 0x040e is supported by the gt68xx backend. unsupported
(2010-06-09)
?
OpticPro S24 USB 0x07b3/0x040e Good Product ID 0x040e only. Is reported to work. gt68xx
(1.0-84)
sane-gt68xx
OpticPro S28 USB 0x07b3/0x0801 Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
OpticPro ST12 USB 0x07b3/0x0600 Unsupported Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend. unsupported
(2010-06-09)
?
OpticPro ST12 USB 0x07b3/0x040b Untested Product ID 0x040b only. Needs testing. Transparency adapter completely untested. Please contact me if you own such a scanner. gt68xx
(1.0-84)
sane-gt68xx
OpticPro ST16 USB 0x07b3/0x0600 Unsupported GL646 based, to be added to genesys backend unsupported
(2010-06-09)
?
OpticPro ST24 USB 0x07b3/0x0601 Unsupported GL646 based, to be added to genesys backend unsupported
(2010-06-09)
?
OpticPro ST28 USB 0x07b3/0x0802 Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
OpticPro ST28 USB 0x07b3/0x0801 Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
OpticPro ST48 USB 0x07b3/0x0800 Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
OpticPro ST64 USB 0x07b3/0x0c00 Unsupported GL843 based, maybe to be added to genesys backend unsupported
(2010-06-09)
?
OpticPro ST64+ USB 0x07b3/0x0c03 Unsupported GL843 based. See link for more details. unsupported
(2010-06-09)
?
OpticPro U12 USB 0x07b3/0x0001 Basic Note: Only devices with product ID 0x0001 are supported! u12
(0.02)
sane-u12
OpticPro U12 USB 0x07b3/0x0010 Complete NOTE: Devices with product ID 0x0001 are not supported! plustek
(0.52)
sane-plustek
OpticPro U16B USB 0x07b3/0x0402 Good   gt68xx
(1.0-84)
sane-gt68xx
OpticPro U16B+ USB 0x07b3/0x0403 Good   gt68xx
(1.0-84)
sane-gt68xx
OpticPro U24 USB 0x07b3/0x0015 Complete   plustek
(0.52)
sane-plustek
OpticPro U24 USB 0x07b3/0x0011 Complete   plustek
(0.52)
sane-plustek
OpticPro UA18 USB   Unsupported Probably LM983x based. unsupported
(2010-06-09)
?
OpticPro UT12 USB 0x07b3/0x0001 Basic Note: Only devices with product ID 0x0001 are supported! u12
(0.02)
sane-u12
OpticPro UT12 USB 0x07b3/0x0017 Complete Note: Devices with product ID 0x0001 are not supported! plustek
(0.52)
sane-plustek
OpticPro UT12 USB 0x07b3/0x0013 Complete   plustek
(0.52)
sane-plustek
OpticPro UT16 USB 0x07b3/0x0017 Complete   plustek
(0.52)
sane-plustek
OpticPro UT16B USB 0x07b3/0x0403 Untested Probably works. Transparency adapter not supported yet. Please contact me if you own such a device. gt68xx
(1.0-84)
sane-gt68xx
OpticPro UT24 USB 0x07b3/0x0017 Complete   plustek
(0.52)
sane-plustek
OpticSlim 500 USB 0x07b3/0x0458 Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
OpticSlim 1200 USB 0x07b3/0x0413 Good   gt68xx
(1.0-84)
sane-gt68xx
OpticSlim 2400 USB 0x07b3/0x0422 Good Works up to 1200 dpi. gt68xx
(1.0-84)
sane-gt68xx
OpticSlim 2400 plus USB 0x07b3/0x0454 Good Same as OpticSlim 2400. gt68xx
(1.0-84)
sane-gt68xx
OpticSlim 2420 USB 0x07b3/0x0806 Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
OpticSlim 2420+ USB 0x07b3/0x0914 Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
OpticSlim M12 USB 0x07b3/0x0412 Complete Works up to 1200 dpi. Calibration with external calibration sheet supported gt68xx
(1.0-84)
sane-gt68xx
OpticWorks 2000 Parport   Unsupported Multifunction device. No further information available. unsupported
(2010-06-09)
?
PL 806 USB 0x07b3/0x0c0c Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
ScanCopy 115 USB 0x07b3/0x081c Unsupported GL841 based, to be added to genesys backend unsupported
(2010-06-09)
?
SmartOffice PL 812 USB 0x07b3/0x0c0d Unsupported Unsupported. See link for more details. unsupported
(2010-06-09)
?
Spectra ADF Proprietary   Unsupported Unsupported. Uses proprietary ISA card that also provides power and is labelled GPS-1 PAGE-A from Taiwan. Other labels on the scanner include ADF Color Scanner and SF600AS. Maybe the same as the IBM ADF Color Scanner? unsupported
(2010-06-09)
?
Umax AstraScan 4750 USB 0x07b3/0x0802 Unsupported GL841 based, to be added to genesys backend, rebadged Plustek ST28 unsupported
(2010-06-09)
?
Unknown Plustek Device USB 0x07b3/0x0016 Unsupported Probably unsupported. Scanner name not known yet. unsupported
(2010-06-09)
?
Unknown Plustek Device USB 0x07b3/0x0014 Unsupported Probably unsupported. Scanner name not known yet. unsupported
(2010-06-09)
?
Unknown Plustek Device USB 0x07b3/0x0012 Unsupported Probably unsupported. Scanner name not known yet. unsupported
(2010-06-09)
?
Unknown Plustek Device USB 0x07b3/0x000f Unsupported Probably unsupported. Scanner name not known yet. unsupported
(2010-06-09)
?
Unknown Plustek Device USB 0x07b3/0x0007 Unsupported Probably unsupported. Scanner name not known yet. unsupported
(2010-06-09)
?
Unknown Plustek Device USB 0x07b3/0x0005 Unsupported Probably unsupported. Scanner name not known yet. unsupported
(2010-06-09)
?

Manufacturer: Portable Peripheral Co., Ltd.

Link(s): http://www.pandp.com.tw/

Model Interface USB id Status Comment Backend Manpage
Q-Scan USB001 (A4 portable scanner) USB 0x0a53/0x1000 Complete   plustek
(0.52)
sane-plustek
Q-Scan USB201 (A6 portable scanner) USB 0x0a53/0x2000 Good   plustek
(0.52)
sane-plustek

Manufacturer: Primax

Link(s): http://www.primax.nl/, http://www.primax.com.tw

Model Interface USB id Status Comment Backend Manpage
Colorado 600U USB 0x0461/0x0341 Unsupported Not supported. Some information is available. unsupported
(2010-06-09)
?
Colorado 1200p Parport   Unsupported Unsupported by SANE. But is reported to partly work with pxscan. See link. unsupported
(2010-06-09)
?
Colorado 1200u USB 0x0461/0x0361 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
Colorado 4800 Parport (SPP, EPP)   Untested same as OpticPro 4800P plustek_pp
(0.43)
sane-plustek_pp
Colorado Direct 600 Parport   Unsupported Not supported. However, a stand-alone program is available. unsupported
(2010-06-09)
?
Colorado Direct 9600 Parport   Unsupported Not supported. However, a stand-alone program is available. unsupported
(2010-06-09)
?
Colorado USB 9600 USB 0x0461/0x0340 Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
Compact 4800 Direct Parport (SPP, EPP)   Complete use driver-switch mov=2 plustek_pp
(0.43)
sane-plustek_pp
Compact 4800 Direct-30 Parport (SPP, EPP)   Complete same as OpticPro 4830P, use driver-switch mov=7 plustek_pp
(0.43)
sane-plustek_pp
Compact 4800 SCSI SCSI   Complete Mustek 600 II CD compatible mustek
(1.0-138)
sane-mustek
Compact 9600 Direct-30 Parport (SPP, EPP)   Complete same as OpticPro 9630P plustek_pp
(0.43)
sane-plustek_pp
G2-300 USB 0x0461/0x0300 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
G2-300 #2 USB 0x0461/0x0302 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
G2-600 USB 0x0461/0x0380 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
G2-600 #2 USB 0x0461/0x0382 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
G2E-300 USB 0x0461/0x0301 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
G2E-300 #2 USB 0x0461/0x0303 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
G2E-600 USB 0x0461/0x0383 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
Jewel 4800 SCSI   Good sub model VM356A teco2
(1.0-9)
sane-teco2
OneTouch 5300 Parport   Unsupported Not supported. unsupported
(2010-06-09)
?
Onetouch 8920 USB 0x0461/0x0371 Unsupported Not supported. Look similar to Visioneer Onetouch 8920 (same USB product id). unsupported
(2010-06-09)
?
PagePartner Parport (EPP/ECP)   Basic Sheetfed scanner, work in gray and color, but uncalibrated scans p5
(1)
sane-p5
Primascan Colorado 2600u USB 0x0461/0x0347 Unsupported Unsupported. Same as Visioneer Onetouch 4400. See link for details. unsupported
(2010-06-09)
?
Profi 9600 SCSI   Basic sub model VM6575 teco2
(1.0-9)
sane-teco2
Profi 19200 SCSI   Good sub model VM6586 teco2
(1.0-9)
sane-teco2
ReadyScan 636i USB 0x0461/0x0381 Unsupported Probably unsupported. No details known. unsupported
(2010-06-09)
?
Slim-Line 1200 USB   Unsupported Maybe GL646. Maybe similar to Medion MD 6228? unsupported
(2010-06-09)
?

Manufacturer: Prolink

Link(s): http://www.fida.com/

Model Interface USB id Status Comment Backend Manpage
Winscan Pro 2000 USB Parport   Unsupported Not supported. No further information available. unsupported
(2010-06-09)
?
Winscan Pro 2448U USB 0x06dc/0x0014 Unsupported Not supported. Some information is available. RealTek RTS8801. unsupported
(2010-06-09)
?

Manufacturer: Quato

Link(s): http://www.quato.de/

Model Interface USB id Status Comment Backend Manpage
X-Finity SCSI   Unsupported Probably not supported. No details yet. Originally manufactured by PFU? unsupported
(2010-06-09)
?
X-Finity Ultra USB IEEE-1394   Unsupported Probably not supported. No details yet. unsupported
(2010-06-09)
?

Manufacturer: Reflecta

Model Interface USB id Status Comment Backend Manpage
DigitDia 3600 USB IEEE-1394 0x05e3/0x0142 Unsupported Film scanner that can scan directly from the magazine. unsupported
(2010-06-09)
?
iScan 1800 USB 0x05e3/0x0120 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
ProScan 4000 USB IEEE-1394 0x05e3/0x0143 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Relisys

Link(s): http://www.relisys.com/, http://www.tecoimage.com.tw/

Model Interface USB id Status Comment Backend Manpage
APOLLO Express 3 SCSI   Basic sub model VM356A teco2
(1.0-9)
sane-teco2
APOLLO Express 6 SCSI   Good sub model VM6565 teco2
(1.0-9)
sane-teco2
AVEC 2400 SCSI   Complete sub model VM3520 teco1
(1.0-10)
sane-teco1
AVEC 2412 SCSI   Complete sub model VM3520+ teco1
(1.0-10)
sane-teco1
AVEC 4800 SCSI   Untested sub model VM4530 teco1
(1.0-10)
sane-teco1
AVEC 4816 SCSI   Untested sub model VM4530+ teco1
(1.0-10)
sane-teco1
AVEC II E3 Parport   Unsupported Parport version of AVEC II S3?. See bug #304992 for details unsupported
(2010-06-09)
?
AVEC II S3 SCSI   Good sub model VM3564 teco2
(1.0-9)
sane-teco2
AVEC Super 3 SCSI   Untested sub model VM3575 teco2
(1.0-9)
sane-teco2
Eclipse 1200U USB 0x0475/0x0103 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
Episode USB 0x0475/0x0103 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?
Infinity Scorpio SCSI   Good sub model VM3552 teco3
(1.0-1)
sane-teco3
RELI 2400 SCSI   Untested sub model VM3530 teco1
(1.0-10)
sane-teco1
RELI 2412 SCSI   Complete sub model VM3530+ teco1
(1.0-10)
sane-teco1
RELI 4816 SCSI   Complete sub model VM4540 teco1
(1.0-10)
sane-teco1
RELI 4830 SCSI   Good sub model VM4542 teco1
(1.0-10)
sane-teco1
RELI 9600 SCSI   Untested sub model VM6530 teco1
(1.0-10)
sane-teco1
RELI 9612 SCSI   Untested sub model VM6530* teco1
(1.0-10)
sane-teco1
RELI 9624 SCSI   Untested sub model VM6530+ teco1
(1.0-10)
sane-teco1
RELI 9630 SCSI   Untested sub model VM6540 teco1
(1.0-10)
sane-teco1
RELI DS6 SCSI   Untested sub model VM3420 teco1
(1.0-10)
sane-teco1
RELI DS15 SCSI   Untested sub model VM3440 teco1
(1.0-10)
sane-teco1
SCORPIO Pro SCSI   Good sub model VM6575 teco2
(1.0-9)
sane-teco2
SCORPIO Pro-S SCSI   Untested sub model VM6586 teco2
(1.0-9)
sane-teco2
SCORPIO Super 3 SCSI   Good sub model VM3575 teco2
(1.0-9)
sane-teco2
Scorpio Ultra 3 USB 0x0475/0x0210 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: RevScan

Model Interface USB id Status Comment Backend Manpage
19200i USB 0x07b3/0x0400 Good Similar to Plustek OpticPro 1248U gt68xx
(1.0-84)
sane-gt68xx
RevScan Orange R48Ti USB 0x07b3/0x0001 Basic Rebadged Plustek OpticPro UT12 u12
(0.02)
sane-u12

Manufacturer: Ricoh

Link(s): http://www.ricoh.com/

Model Interface USB id Status Comment Backend Manpage
IS-410 SCSI   Untested Untested, please report! ibm
(1.0-4)
sane-ibm
IS-410 SCSI   Untested Untested, please report! hs2p
(1.00)
sane-hs2p
IS-420 SCSI   Basic Works at least in flatbed mode. ibm
(1.0-4)
sane-ibm
IS-430 SCSI   Untested Untested, please report! ibm
(1.0-4)
sane-ibm
IS-430 SCSI   Untested Untested, please report! hs2p
(1.00)
sane-hs2p
IS450 SCSI   Complete All major scanning-related features are supported (except for IPU). Certain non-scanning features, such as those related to scanner maintenance, are not supported. Such features would be better implemented in a separate stand-alone tool. For instance, if you replace the ADF Unit, you must recalibrate the scanner optics using a Ricoh Test Sheet and reset the E^2PROM registers. Reports are welcome. hs2p
(1.00)
sane-hs2p
Ricoh IS50 SCSI   Basic   ricoh
(unmaintained)
sane-ricoh
Ricoh IS60 SCSI   Basic   ricoh
(unmaintained)
sane-ricoh

Manufacturer: Samsung

Link(s): http://www.samsung.com

Model Interface USB id Status Comment Backend Manpage
C460 USB 0x04e8/0x3468 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-2160 USB 0x04e8/0x3425 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-3160 USB 0x04e8/0x341c Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-3170fn (CLX-3170 Series) USB 0x04e8/0x342a Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-3175FW USB 0x04e8/0x342a Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-3185 USB 0x04e8/0x343d Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-3300 Series USB 0x04e8/0x3456 Basic   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-4190 USB 0x04e8/0x345a Minimal   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-6200 USB 0x04e8/0x3427 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-6220 USB 0x04e8/0x343a Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-6240 USB 0x04e8/0x3428 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-6250 USB 0x04e8/0x343b Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-6260 USB 0x04e8/0x3455 Minimal   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-8380 USB 0x04e8/0x3421 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-8385 USB 0x04e8/0x3439 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-8385X USB 0x04e8/0x3444 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
CLX-8540 USB 0x04e8/0x343f Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
M267x 287x Series USB 0x04e8/0x3461 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
M337x 387x 407x Series USB 0x04e8/0x3460 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
MFP-65x USB 0x04e8/0x3435 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
MFP-560 USB 0x04e8/0x340e Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
MFP-750 USB 0x04e8/0x340f Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4x16 USB 0x04e8/0x3409 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4x20 USB 0x04e8/0x3412 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4x21 USB 0x04e8/0x3419 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4x26 USB 0x04e8/0x3432 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-5x30 USB 0x04e8/0x341a Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-6x20 USB 0x04e8/0x340d Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-6x22 USB 0x04e8/0x341d Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-6x45 USB 0x04e8/0x3420 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-6x55 USB 0x04e8/0x3429 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-6x55X USB 0x04e8/0x3443 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-470x USB 0x04e8/0x3457 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-681x USB 0x04e8/0x3466 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-3205W (SCX-3200 Series) USB Ethernet 0x04e8/0x3441 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-3400 USB 0x04e8/0x344f Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-3405W Ethernet   Basic   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4100 USB 0x04e8/0x3413 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4200 USB 0x04e8/0x341b Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4300 USB 0x04e8/0x342e Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4500 USB 0x04e8/0x3426 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4500W USB Ethernet 0x04e8/0x342b Basic   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4600 USB 0x04e8/0x3433 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4623 USB 0x04e8/0x3434 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4623FW USB 0x04e8/0x3440 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4650 4x21S Series USB 0x04e8/0x345b Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4725FN USB 0x04e8/0x341f Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
SCX-4729FD USB 0x04e8/0x3453 Basic   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4824 (SCX-4x24 Series) USB 0x04e8/0x342c Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4825FN (SCX-4x25 Series) USB 0x04e8/0x343c Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4828FN (SCX-4x28 Series) USB 0x04e8/0x342d Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4833FD USB 0x04e8/0x344b Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-4835FD Ethernet 0x04e8/0x344b Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-5635 USB 0x04e8/0x3430 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-5835_5935 USB 0x04e8/0x342f Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-5835_5935X USB 0x04e8/0x3446 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-6545 USB 0x04e8/0x3437 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX-6545X USB 0x04e8/0x3442 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX4725 USB 0x04e8/0x341f Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp
SCX4725-FN USB 0x04e8/0x341f Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
SF-760 USB 0x04e8/0x3450 Untested   xerox_mfp
(1.0-13)
sane-xerox_mfp

Manufacturer: Scanport

Link(s): http://www.scanport.com/

Model Interface USB id Status Comment Backend Manpage
SQ300 Parport?   Basic   microtek2
(unmaintained)
sane-microtek2
SQ2030 Parport   Basic   microtek2
(unmaintained)
sane-microtek2
SQ4836 SCSI   Basic   microtek2
(unmaintained)
sane-microtek2

Manufacturer: Scanshell

Model Interface USB id Status Comment Backend Manpage
800N USB 0x0a82/0x6605 Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Sceptre

Link(s): http://www.sceptre.com/

Model Interface USB id Status Comment Backend Manpage
Vividscan S1200 SCSI   Basic   sceptre
(1.0-10)
sane-sceptre

Manufacturer: Sharp

Link(s): http://sharp-world.com/

Model Interface USB id Status Comment Backend Manpage
JX-250 SCSI   Good   sharp
(0.32)
sane-sharp
JX-320 SCSI   Good   sharp
(0.32)
sane-sharp
JX-325 SCSI   Untested   sharp
(0.32)
sane-sharp
JX-330 SCSI   Good   sharp
(0.32)
sane-sharp
JX-350 SCSI   Good   sharp
(0.32)
sane-sharp
JX-610 SCSI   Good   sharp
(0.32)
sane-sharp

Manufacturer: Sicos

Model Interface USB id Status Comment Backend Manpage
DMS 2000 proprietary   Unsupported Not supported until now. Work on a backend has started, contact the author for details (see link) unsupported
(2010-06-09)
?

Manufacturer: Siemens

Link(s): http://www.siemens.com/, http://www.siemens.de/

Model Interface USB id Status Comment Backend Manpage
9036 Flatbed scanner SCSI   Basic   s9036
(unmaintained)
sane-s9036
Cherry FingerTIP ID Board - Sensor USB 0x0681/0x0010 Unsupported Not supported. unsupported
(2010-06-09)
?
ID Mouse Professional USB 0x0681/0x0005 Unsupported Not supported. unsupported
(2010-06-09)
?
S9036 SCSI   Untested gray only agfafocus
(unmaintained)
sane-agfafocus
ST400 SCSI   Basic 6 bit gray st400
(1.6)
sane-st400
ST800 SCSI   Basic 6 bit gray st400
(1.6)
sane-st400

Manufacturer: SmartDisk

Model Interface USB id Status Comment Backend Manpage
SmartScan 3600 USB IEEE-1394   Unsupported Probably not supported. Same as PIE Primefilm 2600 PRO. unsupported
(2010-06-09)
?

Manufacturer: Spot Technology

Comment: Spot seems have gone out of business.

Model Interface USB id Status Comment Backend Manpage
Maxiscan A4 proprietary   Unsupported Not supported until now. Work on a backend has started, see link for more information. unsupported
(2010-06-09)
?
ScanTak 2c proprietary   Unsupported Not supported. Work on a backend has started, see link for more information. unsupported
(2010-06-09)
?
ScanTak 3c proprietary   Unsupported Not supported. Work on a backend has started, see link for more information. unsupported
(2010-06-09)
?

Manufacturer: Syscan

Link(s): http://www.syscaninc.com/

Model Interface USB id Status Comment Backend Manpage
DocketPort 465 USB 0x0a82/0x4802 Untested All resolution and mode should be supported, but uncorrected scans genesys
(1.0-63)
sane-genesys
DocketPort 485 USB 0x0a82/0x4810 Basic All resolution and mode supported, front- and backside side-by-side, with backside mirrored horizontally. genesys
(1.0-63)
sane-genesys
DocketPort 665 USB 0x0a82/0x4803 Basic All resolution and mode supported, calibration is available genesys
(1.0-63)
sane-genesys
DocketPort 685/ Ambir DS685 USB 0x0a82/0x480c Good All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally. genesys
(1.0-63)
sane-genesys
TravelScan 460/464 USB 0x0a82/0x4600 Complete   plustek
(0.52)
sane-plustek
TravelScan 662 USB 0x0a82/0x6620 Complete   plustek
(0.52)
sane-plustek
TravelScan FS-531 USB 0x0a82/0x0530 Unsupported Not supported. May work with the Plustek backend in future. See link for details. unsupported
(2010-06-09)
?
TravelScan Pro USB 0x0a82/0x2000 Unsupported Probably not supported. Some information is available. unsupported
(2010-06-09)
?

Manufacturer: Tamarack

Model Interface USB id Status Comment Backend Manpage
Artiscan 2400FS USB 0x05e3/0x0100 Unsupported Unsupported. See link for more information. unsupported
(2010-06-09)
?
Artiscan 6000C SCSI   Good 3 pass, 300 DPI tamarack
(unmaintained)
sane-tamarack
Artiscan 8000C SCSI   Good 3 pass, 400 DPI tamarack
(unmaintained)
sane-tamarack
Artiscan 9600 Parport   Unsupported Unsupported at the moment. See link for a project for that scanner taht may support it in future. unsupported
(2010-06-09)
?
Artiscan 9600 pro 36 Parport   Unsupported Unsupported at the moment. See link for a project for that scanner. unsupported
(2010-06-09)
?
Artiscan 12000C SCSI   Good 3 pass, 600 DPI tamarack
(unmaintained)
sane-tamarack

Manufacturer: Targa

Model Interface USB id Status Comment Backend Manpage
Funline TS6 EP Parport (EPP)   Good 300x600 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
Funline TS12 EP Parport (EPP)   Good 600x1200 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp

Manufacturer: TCE

Link(s): http://www.tce.com.br/
Comment: Brasilian vendor.

Model Interface USB id Status Comment Backend Manpage
MK600U USB 0x0461/0x0346 Unsupported Not supported. Some information is available. unsupported
(2010-06-09)
?
S450 Parport   Unsupported Not supported by SANE but is reported to work with pxscan (see link). unsupported
(2010-06-09)
?

Manufacturer: Teco

Link(s): http://www.tecoimage.com.tw/

Model Interface USB id Status Comment Backend Manpage
VM6509F USB 0x080d/0x0102 Unsupported Probably unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: Tiny

Model Interface USB id Status Comment Backend Manpage
FU661E USB 0x0461/0x0347 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: TriGem

Link(s): http://www.nikon.com/

Model Interface USB id Status Comment Backend Manpage
PowerScanII SCSI   Good OK umax
(1.0-41)
sane-umax

Manufacturer: Trust

Link(s): http://www.trust-site.com, http://www.trust-site.com/home/, http://www.trust.com
Comment: Carefully check the model names. Trust uses similar names for completely different hardware.

Model Interface USB id Status Comment Backend Manpage
240H Easy Webscan Gold USB 0x05d8/0x4007 Basic Works up to 600 dpi artec_eplus48u
(unmaintained)
sane-artec_eplus48u
240TH Easy Webscan Gold USB 0x055f/0x0218 Good Same as Mustek Bearpaw 2400 TA plus. gt68xx
(1.0-84)
sane-gt68xx
CombiScan 19200 Parport USB 0x05cb/0x1483 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
Compact Scan USB 19200 USB 0x055f/0x0006 Complete Mustek 1200 UB compatible mustek_usb
(1.0-18)
sane-mustek_usb
Compact Scan USB 19200 USB 0x05d8/0x4002 Good Works, if you have vendor id 0x055f and product id 0x0006, use the mustek_usb backend instead, similar to Mustek ScanExpress 1200 UB (Plus) gt68xx
(1.0-84)
sane-gt68xx
Direct WebScan 19200 USB 0x055f/0x021c Good Same as Mustek BearPaw 1200 CU Plus (0x021c). gt68xx
(1.0-84)
sane-gt68xx
Easy Connect 9600+ Parport (EPP)   Good 300x600 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
Easy Connect 19200+ Parport (EPP)   Good 300x600 dpi CIS scanner mustek_pp
(13)
sane-mustek_pp
Easy Scan 9600 Plus Parport   Basic Requires the program 'as6edriver' to run. as6e
(0.5)
sane-as6e
Easy Webscan 19200 USB 0x05d8/0x4006 Good   artec_eplus48u
(unmaintained)
sane-artec_eplus48u
EasyScan 19200 Parport   Unsupported   unsupported
(2010-06-09)
?
Flat Scan USB 19200 USB 0x05d8/0x4002 Good Similar to Artec Ultima 2000 gt68xx
(1.0-84)
sane-gt68xx
Imagery 1200 SCSI   Good 3-pass, Mustek Paragon MFS-6000CX compatible mustek
(1.0-138)
sane-mustek
Imagery 1200 SP SCSI   Complete Mustek Paragon MFS-6000SP compatible mustek
(1.0-138)
sane-mustek
Imagery 2400 SP SCSI   Good sub model VM3552 teco3
(1.0-1)
sane-teco3
Imagery 4800 SP SCSI   Complete Mustek Paragon 600 II CD compatible mustek
(1.0-138)
sane-mustek
Imagery 4800 SP+ SCSI   Good sub model VM3552 teco3
(1.0-1)
sane-teco3
Imagery 9600 SP SCSI   Untested sub model VM3552 teco3
(1.0-1)
sane-teco3
Office Scan USB 19200 USB 0x047b/0x1000 Complete   niash
(0.3)
sane-niash
SCSI Connect 19200 SCSI   Complete Mustek ScanExpress 12000SP compatible mustek
(1.0-138)
sane-mustek
SCSI excellence series 19200 SCSI   Complete Mustek ScanExpress 12000SP compatible mustek
(1.0-138)
sane-mustek
SCSI Scan 19200 -Excellence Series- SCSI   Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?

Manufacturer: UMAX

Link(s): http://www.umax.com/, http://www.umax.com.tw/, http://www.umax.de/en, http://www.umax-europe.com, http://www.umaxjapan.co.jp, http://www.umax.com.cn, http://www.umax.com

Model Interface USB id Status Comment Backend Manpage
Astra 600P Parport (SPP/ECP)   Unsupported untested, but should be close to 610P umax_pp
(1)
sane-umax_pp
Astra 600S SCSI   Good OK umax
(1.0-41)
sane-umax
Astra 610P Parport (SPP/ECP)   Good   umax_pp
(1)
sane-umax_pp
Astra 610S SCSI   Good OK umax
(1.0-41)
sane-umax
Astra 1200S SCSI   Good OK umax
(1.0-41)
sane-umax
Astra 1220P Parport (EPP/ECP)   Good   umax_pp
(1)
sane-umax_pp
Astra 1220S SCSI   Good OK umax
(1.0-41)
sane-umax
Astra 1220U USB 0x1606/0x0010 Good   umax1220u
(unmaintained)
sane-umax1220u
Astra 1600P Parport (EPP/ECP)   Good   umax_pp
(1)
sane-umax_pp
Astra 1600U USB 0x1606/0x0030 Good   umax1220u
(unmaintained)
sane-umax1220u
Astra 2000P Parport (EPP/ECP)   Good   umax_pp
(1)
sane-umax_pp
Astra 2000U USB 0x1606/0x0030 Good   umax1220u
(unmaintained)
sane-umax1220u
Astra 2100S SCSI   Good OK umax
(1.0-41)
sane-umax
Astra 2100U USB 0x1606/0x0130 Good   umax1220u
(unmaintained)
sane-umax1220u
Astra 2200 (SU) USB 0x1606/0x0230 Good OK, needs USB control messages umax
(1.0-41)
sane-umax
Astra 2200 (SU) SCSI   Good OK umax
(1.0-41)
sane-umax
Astra 2400S SCSI   Good OK umax
(1.0-41)
sane-umax
Astra 2500 USB 0x0461/0x0374 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
Astra 2850 USB 0x07b3/0x0601 Unsupported Probably not supported. Same IDs as Plustek OpticPro ST24. See link for details. unsupported
(2010-06-09)
?
Astra 3000 USB 0x0461/0x038a Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
Astra 3600 USB 0x0461/0x038a Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
Astra 4000 USB 0x1606/0x1030 Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
Astra 4100 USB 0x0461/0x038c Unsupported Not supported, to be added to genesys backend. unsupported
(2010-06-09)
?
Astra 4400 USB 0x1606/0x0070 Good Supports 75, 150, 300, 600 and 1200 dpi rts8891
(1.0-0)
sane-rts8891
Astra 4450 USB 0x1606/0x0070 Untested   rts8891
(1.0-0)
sane-rts8891
Astra 4500 USB 0x0638/0x0a10 Unsupported GL646 based, to be added to genesys backend. Avision iVina FB1600 clone unsupported
(2010-06-09)
?
Astra 4600 USB   Unsupported Probably not supported, no details known. unsupported
(2010-06-09)
?
Astra 4700 USB 0x0638/0x0a20 Unsupported GL646/GL660 based. Avision iVina FB1800 clone. unsupported
(2010-06-09)
?
Astra 4900 USB 0x06dc/0x0020 Minimal developing yet hp3900
(0.12)
sane-hp3900
Astra 6400 IEEE-1394   Unsupported will probably work one day umax
(1.0-41)
sane-umax
Astra 6450 IEEE-1394   Unsupported will probably work one day umax
(1.0-41)
sane-umax
Astra 6700 USB   Unsupported Not supported. No chipset information available. Same as Avision iVina FB2400. unsupported
(2010-06-09)
?
Astra MX3 USB   Good OK, needs USB control messages umax
(1.0-41)
sane-umax
Astra MX3 SCSI   Good OK umax
(1.0-41)
sane-umax
AstraSlim USB 0x080d/0x0104 Unsupported Probably not supported currently. See link for more details. unsupported
(2010-06-09)
?
AstraSlim 1200 USB 0x080d/0x0110 Unsupported See link for more details. unsupported
(2010-06-09)
?
AstraSlim 1200 SE USB 0x05d8/0x4010 Good   artec_eplus48u
(unmaintained)
sane-artec_eplus48u
AstraSlim 6000 USB 0x080d/0x0104 Unsupported Probably not supported currently. See link for more details. unsupported
(2010-06-09)
?
AstraSlim SE USB 0x05d8/0x4009 Good   artec_eplus48u
(unmaintained)
sane-artec_eplus48u
Gemini D-16 SCSI   Good OK umax
(1.0-41)
sane-umax
Mirage D-16L SCSI   Good OK umax
(1.0-41)
sane-umax
Mirage II SCSI   Good OK umax
(1.0-41)
sane-umax
Mirage IIse SCSI   Good OK umax
(1.0-41)
sane-umax
Nete3470' Parport   Unsupported Probably not supported. No details known.. unsupported
(2010-06-09)
?
PL-II SCSI   Good OK umax
(1.0-41)
sane-umax
PowerLook SCSI   Good OK, SCSI-ID=PS-2400X umax
(1.0-41)
sane-umax
Powerlook 180 USB   Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
PowerLook 270 SCSI   Unsupported incompatible umax
(1.0-41)
sane-umax
PowerLook 270plus SCSI   Unsupported incompatible umax
(1.0-41)
sane-umax
Powerlook 1000 USB USB   Unsupported Probably not supported. No further information available. unsupported
(2010-06-09)
?
PowerLook 1100 IEEE-1394   Unsupported will probably work one day umax
(1.0-41)
sane-umax
PowerLook 2000 SCSI   Good OK umax
(1.0-41)
sane-umax
PowerLook 2100XL SCSI   Good OK umax
(1.0-41)
sane-umax
PowerLook 3000 SCSI   Good OK umax
(1.0-41)
sane-umax
PowerLook III SCSI   Good OK umax
(1.0-41)
sane-umax
PSD SCSI   Good OK umax
(1.0-41)
sane-umax
Supervista S-12 SCSI   Good OK umax
(1.0-41)
sane-umax
UC 630 SCSI   Good Version 2.8 OK, others only lineart OK umax
(1.0-41)
sane-umax
UC 840 SCSI   Good Version 1.6 OK, others only lineart OK umax
(1.0-41)
sane-umax
UC 1200S SCSI   Untested may work, please test and give feedback umax
(1.0-41)
sane-umax
UC 1200SE SCSI   Good Version 3.0 OK, others unknown umax
(1.0-41)
sane-umax
UC 1260 SCSI   Good Version 1.6 OK, others unknown umax
(1.0-41)
sane-umax
UG 80 SCSI   Good OK umax
(1.0-41)
sane-umax
UG 630 SCSI   Good OK umax
(1.0-41)
sane-umax
UMAX 3400 USB 0x1606/0x0060 Complete there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x plustek
(0.52)
sane-plustek
UMAX 3400 USB 0x1606/0x0050 Complete there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x plustek
(0.52)
sane-plustek
UMAX 3450 USB 0x1606/0x0060 Complete   plustek
(0.52)
sane-plustek
UMAX 5400 USB 0x1606/0x0160 Complete   plustek
(0.52)
sane-plustek
UMAX Astranet ia101 USB 0x1606/0x0060 Complete seems to be a renamed UMAX 3400 plustek
(0.52)
sane-plustek
UMAX S-6E SCSI   Good OK umax
(1.0-41)
sane-umax
UMAX S-6EG SCSI   Good OK umax
(1.0-41)
sane-umax
UMAX S-12 SCSI   Good OK umax
(1.0-41)
sane-umax
UMAX S-12G SCSI   Good OK umax
(1.0-41)
sane-umax
UMAX VT600 SCSI   Untested may work, please test and give feedback umax
(1.0-41)
sane-umax
Vista S6 SCSI   Good OK umax
(1.0-41)
sane-umax
Vista S6E SCSI   Good OK umax
(1.0-41)
sane-umax
Vista-S8 SCSI   Good OK umax
(1.0-41)
sane-umax
Vista-T630 SCSI   Good OK for some firmwareversions, on others only lineart OK umax
(1.0-41)
sane-umax

Manufacturer: Vantas

Model Interface USB id Status Comment Backend Manpage
3000 USB 0x04a7/0x0224 Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?

Manufacturer: Visioneer

Link(s): http://www.visioneer.com/

Model Interface USB id Status Comment Backend Manpage
4800 One Touch USB 0x04a7/0x03a0 Unsupported Unsupported. See link for details. Different id compared to One Touch 4800? unsupported
(2010-06-09)
?
6200 USB 0x0461/0x0345 Unsupported Not supported. Is reported to use the E5 chipset. Uses a Primax ID. Looks similar to Primascan Colorado 2600u. unsupported
(2010-06-09)
?
6200 EPP/USB USB 0x04a7/0x0311 Unsupported Not supported. Id is from Primax? Yet another scanner with the same name? unsupported
(2010-06-09)
?
9320 USB 0x04a7/0x0420 Complete sheetfed scanner avision
(Build: 296)
sane-avision
9420 USB 0x0461/0x03a8 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
9450 USB 0x04a7/0x0421 Complete sheetfed scanner avision
(Build: 296)
sane-avision
9450 USB USB 0x04a7/0x0421 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
9450-G USB 0x04a7/0x047a Complete sheetfed scanner avision
(Build: 296)
sane-avision
9550 USB 0x04a7/0x0422 Complete sheetfed scanner avision
(Build: 296)
sane-avision
9650 USB 0x04a7/0x0390 Complete sheetfed scanner avision
(Build: 296)
sane-avision
9650-G USB 0x04a7/0x047b Complete sheetfed scanner avision
(Build: 296)
sane-avision
9750 USB 0x04a7/0x0423 Complete sheetfed scanner avision
(Build: 296)
sane-avision
9750-G USB 0x04a7/0x0493 Complete sheetfed scanner avision
(Build: 296)
sane-avision
DocuImage 620S SCSI   Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
DocuMate 510 USB 0x04a7/0x047c Unsupported Not supported. See link for more details. Yet another USB id. unsupported
(2010-06-09)
?
DocuMate 510 USB 0x04a7/0x0446 Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
One Touch 4800 USB 0x04a7/0x0224 Unsupported Unsupported. See link for details. Different id compared to 4800 One Touch? unsupported
(2010-06-09)
?
Onetouch 4400 USB 0x0461/0x0347 Unsupported Not supported. E5 chipset? See link for more details. unsupported
(2010-06-09)
?
OneTouch 4800 USB USB 0x04a7/0x0224 Unsupported Unsupported. Seems to use Realtek RTS8801B. Same as Microtek Scanport 3000. See link for details. unsupported
(2010-06-09)
?
OneTouch 5300 USB 0x04a7/0x0221 Unsupported Not supported. Yet another scanner with this name? unsupported
(2010-06-09)
?
OneTouch 5300 USB USB 0x04a7/0x0226 Unsupported Not supported. Chipset is RTS8801B(?). See link for output of /proc/bus/usb/devices. unsupported
(2010-06-09)
?
OneTouch 5800 USB USB 0x04a7/0x0226 Unsupported Unsupported. 48 bit scanner, doesn't work with viceo backend. RTS8801C. unsupported
(2010-06-09)
?
OneTouch 6600 USB 0x04a7/0x022a Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
Onetouch 7100 USB 0x04a7/0x0229 Unsupported GL646 based, to be added to genesys backend unsupported
(2010-06-09)
?
OneTouch 7300 USB 0x04a7/0x0444 Good Works upto 1200 dpi and 12 bits/color. gt68xx
(1.0-84)
sane-gt68xx
Onetouch 7700 USB 0x04a7/0x0380 Unsupported LM9832/3 based, to be added to plustek backend unsupported
(2010-06-09)
?
OneTouch 8100 USB 0x04a7/0x0321 Unsupported Unsupported. See link for details. unsupported
(2010-06-09)
?
Onetouch 8700 USB 0x04a7/0x0371 Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
Onetouch 8900 USB 0x04a7/0x0371 Unsupported Not supported. Same as 8920 but without TA? unsupported
(2010-06-09)
?
Onetouch 8920 USB 0x04a7/0x0371 Unsupported Not supported. Same as 8700 and 8900 but includes a TA. Uses a Primax ID. Chipset is RTS8801C. See link for output of /proc/bus/usb/devices. unsupported
(2010-06-09)
?
Onetouch 9000 USB 0x04a7/0x022c Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
Onetouch 9020 USB 0x04a7/0x022c Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
Onetouch 9320 USB 0x04a7/0x0362 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
Onetouch Pro 8800 USB 0x04a7/0x0410 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
Onetouch Pro 8820 USB 0x04a7/0x0410 Unsupported Probably not supported. See link for details. unsupported
(2010-06-09)
?
PaperPort 3100b Parport   Unsupported Most probably not supported. See link for details. unsupported
(2010-06-09)
?
PaperPort 6100 Parport   Unsupported Most probably not supported. More details would be appreciated. unsupported
(2010-06-09)
?
PaperPort OneTouch Parport   Unsupported Most probably not supported. See link for details. unsupported
(2010-06-09)
?
Patriot 430 USB 0x04a7/0x0497 Complete sheetfed scanner avision
(Build: 296)
sane-avision
Patriot 470 USB 0x04a7/0x048f Complete sheetfed scanner avision
(Build: 296)
sane-avision
Patriot 680 USB 0x04a7/0x0498 Complete sheetfed scanner avision
(Build: 296)
sane-avision
Patriot 780 USB 0x04a7/0x0499 Complete sheetfed scanner avision
(Build: 296)
sane-avision
Roadwarrior USB 0x04a7/0x0494 Basic All resolution and mode supported, calibration is available genesys
(1.0-63)
sane-genesys
Strobe Pro USB USB 0x04a7/0x0102 Unsupported Not supported. See link for details. unsupported
(2010-06-09)
?
Strobe XP 100 USB 0x04a7/0x0427 Basic   plustek
(0.52)
sane-plustek
Strobe XP 100,r3 USB 0x04a7/0x049b Good All resolution and mode supported, calibration is available genesys
(1.0-63)
sane-genesys
Strobe XP 200 USB 0x04a7/0x0426 Good All resolution and mode supported, calibration is available genesys
(1.0-63)
sane-genesys
Strobe XP 300 USB 0x04a7/0x0474 Good All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally. genesys
(1.0-63)
sane-genesys
Strobe XP 450 USB 0x04a7/0x0424 Complete sheetfed scanner avision
(Build: 296)
sane-avision
Strobe XP 450-G USB 0x04a7/0x0491 Complete sheetfed scanner avision
(Build: 296)
sane-avision
Strobe XP 470 USB 0x04a7/0x0479 Complete sheetfed scanner avision
(Build: 296)
sane-avision
Strobe XP 470-G USB 0x04a7/0x048f Complete sheetfed scanner avision
(Build: 296)
sane-avision
Visioneer OneTouch 7100 USB 0x04a7/0x0229 Complete Same as MD5345 genesys
(1.0-63)
sane-genesys
WorkCentre 470cx Parport   Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
WorkCentre M15i USB 0x0924/0xffef Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
WorkCentre PE16 USB Parport 0x0924/0x4220 Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
WorkCentre PE120i USB 0x0924/0x4237 Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
WorkCentre Pro 412 USB Parport 0x043d/0x4303 Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
WorkCentre XK35c USB Parport 0x043d/0x0020 Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?
WorkCentre XK50cx USB 0x04e8/0x3903 Unsupported Not supported. See link for more details. unsupported
(2010-06-09)
?

Manufacturer: Viviscan

Model Interface USB id Status Comment Backend Manpage
Compact II Parport (EPP)   Good 300 dpi CCD scanner mustek_pp
(13)
sane-mustek_pp

Manufacturer: Vobis

Link(s): http://www.vobis.de/

Model Interface USB id Status Comment Backend Manpage
HighScan SCSI   Complete only E3plus based models microtek2
(unmaintained)
sane-microtek2
Highscreen Realscan SCSI   Good   microtek
(0.13.1)
sane-microtek
Highscreen Scanboostar Premium SCSI   Good OK, SCSI-ID=LinoHell Office2 umax
(1.0-41)
sane-umax

Manufacturer: Vuego

Comment: Company was renamed to Benq.

Manufacturer: Xerox

Link(s): http://www.xerox.com/, http://www.office.xerox.com/

Model Interface USB id Status Comment Backend Manpage
2400 Onetouch USB 0x0461/0x038b Complete GL646 based, resolution from 75 to 2400 dpi genesys
(1.0-63)
sane-genesys
DocuMate150 USB 0x04a7/0x049c Good   avision
(Build: 296)
sane-avision
DocuMate152 USB 0x04a7/0x0477 Good   avision
(Build: 296)
sane-avision
DocuMate162 USB 0x04a7/0x049d Good   avision
(Build: 296)
sane-avision
DocuMate232 USB 0x04a7/0x0476 Good   avision
(Build: 296)
sane-avision
DocuMate250 USB 0x04a7/0x0448 Good   avision
(Build: 296)
sane-avision
DocuMate250-G USB 0x04a7/0x0490 Good   avision
(Build: 296)
sane-avision
DocuMate252 USB 0x04a7/0x0449 Good   avision
(Build: 296)
sane-avision
DocuMate252-G USB 0x04a7/0x048c Good   avision
(Build: 296)
sane-avision
DocuMate262 USB 0x04a7/0x044c Good   avision
(Build: 296)
sane-avision
DocuMate262-G USB 0x04a7/0x048d Good   avision
(Build: 296)
sane-avision
DocuMate262i USB 0x04a7/0x04a7 Good   avision
(Build: 296)
sane-avision
DocuMate272 USB 0x04a7/0x0475 Untested   avision
(Build: 296)
sane-avision
DocuMate272-G USB 0x04a7/0x048e Untested   avision
(Build: 296)
sane-avision
DocuMate510 USB 0x04a7/0x0446 Untested   avision
(Build: 296)
sane-avision
DocuMate510-G USB 0x04a7/0x047c Untested   avision
(Build: 296)
sane-avision
DocuMate512 USB 0x04a7/0x0495 Untested   avision
(Build: 296)
sane-avision
DocuMate520 USB 0x04a7/0x0447 Untested   avision
(Build: 296)
sane-avision
DocuMate520-G USB 0x04a7/0x0492 Untested   avision
(Build: 296)
sane-avision
DocuMate632 USB 0x04a7/0x0498 Untested   avision
(Build: 296)
sane-avision
DocuMate752 USB 0x04a7/0x049a Untested   avision
(Build: 296)
sane-avision
DocuMate752 USB 0x04a7/0x0478 Untested   avision
(Build: 296)
sane-avision
Phaser 3200MFP USB 0x0924/0x3da4 Complete   xerox_mfp
(1.0-13)
sane-xerox_mfp
Phaser 6110MFP USB 0x0924/0x3d5d Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
Travel Scanner 100 USB 0x04a7/0x04ac Good All resolution and mode supported, calibration is available genesys
(1.0-63)
sane-genesys
WorkCentre 3119 Series USB 0x0924/0x4265 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
WorkCentre 3210 USB 0x0924/0x4293 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
WorkCentre 3220 USB 0x0924/0x4294 Good   xerox_mfp
(1.0-13)
sane-xerox_mfp
WorkCentre 4118 Series USB 0x0924/0x420c Good   xerox_mfp
(1.0-13)
sane-xerox_mfp

Manufacturer: Yakumo

Link(s): http://www.yakumo.com/

Model Interface USB id Status Comment Backend Manpage
Scan50 USB 0x05d8/0x4011 Good   artec_eplus48u
(unmaintained)
sane-artec_eplus48u

Still Cameras

Manufacturers: Kodak, Polaroid

Manufacturer: Kodak

Link(s): http://www.kodak.com/global/en/service/digCam/dc25/dc25.shtml, http://www.kodak.com/global/en/service/digCam/dc210/dc210.shtml, http://www.kodak.com/global/en/service/products/ekn006568.jhtml

Model Interface USB id Status Comment Backend Manpage
DC20 Serial port   Basic DC-20 untested by author but reported to work dc25
(1.2)
sane-dc25
DC25 Serial port   Complete   dc25
(1.2)
sane-dc25
DC210 Serial port   Basic   dc210
(0.0)
sane-dc210
DC240 Serial port   Good Use gphoto2 backend to get USB support dc240
(0.0)
sane-dc240

Manufacturer: Polaroid

Link(s): http://www.polaroid.com/

Model Interface USB id Status Comment Backend Manpage
DMC SCSI   Good   dmc
(unmaintained)
sane-dmc

Video Cameras

Manufacturers: Aiptek, Biolux, Connectix, Creative, Digital Dream, Grandtek Scopecam, Konica

Manufacturer: Aiptek

Link(s): http://www.aiptek.com.tw

Model Interface USB id Status Comment Backend Manpage
Aiptek Pencam USB 0x0553/0x0202 Minimal image is OK for CIF and QCIF, VGA and QVGA untested, streaming video is a problem stv680
(1.0-1)
sane-stv680

Manufacturer: Biolux

Model Interface USB id Status Comment Backend Manpage
654 (micrOcular) USB 0x0923/0x010f Unsupported Not supported yet. See link for more details. unsupported
(2010-06-09)
?

Manufacturer: Connectix

Model Interface USB id Status Comment Backend Manpage
Color QuickCam Parport   Good Requires root privileges. qcam
(unmaintained)
sane-qcam
Greyscale QuickCam Parport   Minimal Requires root privileges. Partly working. qcam
(unmaintained)
sane-qcam

Manufacturer: Creative

Link(s): http://www.creative.com/

Model Interface USB id Status Comment Backend Manpage
WebCam Go Mini USB 0x041e/0x4007 Untested stv680
(1.0-1)
sane-stv680

Manufacturer: Digital Dream

Link(s): http://www.digitaldreamco.com/en/index.shtml

Model Interface USB id Status Comment Backend Manpage
l' espion XS USB 0x1183/0x0001 Untested stv680
(1.0-1)
sane-stv680

Manufacturer: Grandtek Scopecam

Model Interface USB id Status Comment Backend Manpage
8x30 Binocular & Digital Camera USB 0x0797/0x801c Unsupported Not Supported yet. See link for more details. unsupported
(2010-06-09)
?

Manufacturer: Konica

Link(s): http://www.konicaminolta.com

Model Interface USB id Status Comment Backend Manpage
e-mini USB 0x04c8/0x0722 Untested stv680
(1.0-1)
sane-stv680

APIs

Backends: gphoto2, pint, pnm, test, v4l

Backend: gphoto2 (0.0)

Link(s): mailto:peter@fales-lorenz.net
Manual page: sane-gphoto2
Description: Multiple cameras supported by the gphoto2 libraries
Comment: The long-term plan is to support all the cameras supported by the gphoto2 libraries (currently over 140 models). However, at this stage, only a handful of cameras are definitely known to work with SANE. Other cameras will probably work if the native file format is EXIF or JPEG. Testers welcome!

Backend: pint (unmaintained)

Manual page: sane-pint
Description: Scanners with the machine-independent PINT interface
Comment: Haven't been tested for a long time. Handle with care.

Backend: pnm (1.0.8)

Link(s): mailto:henning@meier-geinitz.de
Manual page: sane-pnm
Description: Reads PNM files
Comment: Used for debugging frontends. Obsolete, use test backend instead.

Backend: test (1.0-28)

Link(s): http://www.meier-geinitz.de/sane/test-backend/
Manual page: sane-test
Description: Frontend-tester
Comment: Backend for testing frontends. Also serves as example for SANE backend options.

Backend: v4l (1.0-3)

Link(s): mailto:henning@meier-geinitz.de
Manual page: sane-v4l
Description: Interface to Video For Linux API
Comment: Supports video cameras and other devices accessed by the v4l kernel API, e.g. bttv devices. Quite a lot of known bugs.

Meta Backends

Backends: dll, net

Backend: dll (1.0.13)

Link(s): mailto:henning@meier-geinitz.de
Manual page: sane-dll
Description: Dynamic loading of shared-library backends.

Backend: net (1.0.14)

Link(s): http://www.penguin-breeder.org/?page=sane-net
Manual page: sane-net
Description: Network access to saned servers
Comment: Can be used to access any scanner supported by SANE over the net. Supports IPv4 and IPv6.

Legend:

Model:
Name of the device.
Interface:
How the device is connected to the computer.
USB id:
The USB vendor and product ids as printed by sane-find-scanner -q (only applicable for USB devices).
Status:
Indicates how many of the features the device provides are supported by SANE.
  • unsupported means the device is not supported at least by this backend. It may be supported by other backends, however.
  • untested means the device may be supported but couldn't be tested. Be very careful and report success/failure.
  • minimal means that the device is detected and scans at least in one mode. But the quality is bad or important features won't work.
  • basic means it works at least in the most important modes but quality is not perfect.
  • good means the device is usable for day-to-day work. Some rather exotic features may be missing.
  • complete means the backends supports everything the device can do.
Comment:
More information about the backend or model, e.g. the level of support and possible problems.
Backend:
Name of the backend, in parentheses if available: Version of backend/driver; newer versions may be available from their home sites.
NEW! means brand-new to the current release of SANE.
UNMAINTAINED means that nobody maintains that backend. Expect no new features or newly supported devices. You are welcome to take over maintainership.
Manual Page:
A link to the man-page online, if it exists.
Manufacturer:
Manufacturer, vendor or brand name of the device.
Description:
The scope of application of the backend.

SANE homepage
Contact
This page was last updated on Wed Jul 31 07:52:48 2013 by sane-desc 3.5 from sane-backends 1.0.24git sane-backends-1.0.29/testsuite/tools/data/db.ref0000666000000000000000000012741613615534521016401 00000000000000# This file was automatically created based on description files (*.desc) # by sane-desc 3.5 from sane-backends 1.0.24git on Wed Jul 31 07:52:48 2013 # # The entries below are used to detect a USB device when it's plugged in # and then run a script to change the ownership and # permissions on the "device node" used by libusb. # Sample entry (replace 0xVVVV and 0xPPPP with vendor ID and product ID # respectively): # # 0xVVVV0xPPPProot:scanner0664[/usr/local/bin/foo.sh] # Fields: # vendor ID # product ID # ownership (user:group) # permissions # path of an optional script to run (it can be omitted) # # If your scanner isn't listed below, you can add it as explained above. # # If your scanner is supported by some external backend (brother, epkowa, # hpaio, etc) please ask the author of the backend to provide proper # device detection support for your OS # # If the scanner is supported by sane-backends, please mail the entry to # the sane-devel mailing list (sane-devel@alioth-lists.debian.net). # # Hewlett-Packard ScanJet 4100C 0x03f0 0x0101 root:scanner 0664 # Hewlett-Packard ScanJet 4200C | Hewlett-Packard ScanJet 4200Cxi | Hewlett-Packard ScanJet 4200Cse 0x03f0 0x0105 root:scanner 0664 # Hewlett-Packard ScanJet 6200C | Hewlett-Packard ScanJet 6250C 0x03f0 0x0201 root:scanner 0664 # Hewlett-Packard ScanJet 3300c 0x03f0 0x0205 root:scanner 0664 # Hewlett-Packard ScanJet 4300c 0x03f0 0x0305 root:scanner 0664 # Hewlett-Packard ScanJet 5200C 0x03f0 0x0401 root:scanner 0664 # Hewlett-Packard ScanJet 3400c 0x03f0 0x0405 root:scanner 0664 # Hewlett-Packard ScanJet 2100C 0x03f0 0x0505 root:scanner 0664 # Hewlett-Packard ScanJet 6300C | Hewlett-Packard ScanJet 6350C | Hewlett-Packard ScanJet 6390C 0x03f0 0x0601 root:scanner 0664 # Hewlett-Packard ScanJet 2200C 0x03f0 0x0605 root:scanner 0664 # Hewlett-Packard ScanJet 5300C | Hewlett-Packard ScanJet 5370C 0x03f0 0x0701 root:scanner 0664 # Hewlett-Packard scanjet 4400c 0x03f0 0x0705 root:scanner 0664 # Hewlett-Packard ScanJet 7400c | Hewlett-Packard ScanJet 7450c | Hewlett-Packard ScanJet 7490c 0x03f0 0x0801 root:scanner 0664 # Hewlett-Packard scanjet 4470c 0x03f0 0x0805 root:scanner 0664 # Hewlett-Packard ScanJet 2300C 0x03f0 0x0901 root:scanner 0664 # Hewlett-Packard ScanJet 2400C | Hewlett-Packard ScanJet G2410 0x03f0 0x0a01 root:scanner 0664 # Hewlett-Packard ScanJet 8200 | Hewlett-Packard ScanJet 8250 | Hewlett-Packard ScanJet 8290 0x03f0 0x0b01 root:scanner 0664 # Hewlett-Packard ScanJet 5400c 0x03f0 0x1005 root:scanner 0664 # Hewlett-Packard ScanJet 5470c 0x03f0 0x1105 root:scanner 0664 # Hewlett-Packard ScanJet 4500C | Hewlett-Packard ScanJet 5550C 0x03f0 0x1205 root:scanner 0664 # Hewlett-Packard ScanJet 4570C | Hewlett-Packard ScanJet 5500C 0x03f0 0x1305 root:scanner 0664 # Hewlett-Packard ScanJet 3670 | Hewlett-Packard ScanJet 3690C 0x03f0 0x1405 root:scanner 0664 # Hewlett-Packard ScanJet 5590 0x03f0 0x1705 root:scanner 0664 # Hewlett-Packard ScanJet 7650 0x03f0 0x1805 root:scanner 0664 # Hewlett-Packard ScanJet 4850C 0x03f0 0x1b05 root:scanner 0664 # Hewlett-Packard ScanJet 3530C | Hewlett-Packard ScanJet 3570C 0x03f0 0x2005 root:scanner 0664 # Hewlett-Packard ScanJet 3500C 0x03f0 0x2205 root:scanner 0664 # Hewlett-Packard ScanJet 3970c 0x03f0 0x2305 root:scanner 0664 # Hewlett-Packard ScanJet 4070 Photosmart 0x03f0 0x2405 root:scanner 0664 # Hewlett-Packard ScanJet 3800 0x03f0 0x2605 root:scanner 0664 # Hewlett-Packard ScanJet G2710 0x03f0 0x2805 root:scanner 0664 # Hewlett-Packard ScanJet 8300 | Hewlett-Packard ScanJet 8350 | Hewlett-Packard ScanJet 8390 0x03f0 0x3805 root:scanner 0664 # Hewlett-Packard ScanJet 8270 0x03f0 0x3905 root:scanner 0664 # Hewlett-Packard LaserJet M1005 MFP 0x03f0 0x3b17 root:scanner 0664 # Hewlett-Packard ScanJet 4370 0x03f0 0x4105 root:scanner 0664 # Hewlett-Packard ScanJet G3010 0x03f0 0x4205 root:scanner 0664 # Hewlett-Packard ScanJet G3110 0x03f0 0x4305 root:scanner 0664 # Hewlett-Packard ScanJet G4010 0x03f0 0x4505 root:scanner 0664 # Hewlett-Packard ScanJet G4050 0x03f0 0x4605 root:scanner 0664 # Hewlett-Packard ScanJet N6310 0x03f0 0x4705 root:scanner 0664 # Hewlett-Packard LaserJet M1120 MFP 0x03f0 0x5617 root:scanner 0664 # Hewlett-Packard LaserJet M1120n MFP 0x03f0 0x5717 root:scanner 0664 # Mustek BearPaw 1200 0x0400 0x1000 root:scanner 0664 # Mustek BearPaw 1200 | Mustek BearPaw 2400 0x0400 0x1001 root:scanner 0664 # Kodak ESP 5100 0x040a 0x4025 root:scanner 0664 # Kodak ESP 5300 0x040a 0x4026 root:scanner 0664 # Kodak ESP 5500 0x040a 0x4027 root:scanner 0664 # Kodak ESP 5000 0x040a 0x4028 root:scanner 0664 # Kodak ESP 3300 0x040a 0x4031 root:scanner 0664 # Kodak ESP 5 0x040a 0x4032 root:scanner 0664 # Kodak ESP 7 0x040a 0x403e root:scanner 0664 # Kodak ESP 9 0x040a 0x403f root:scanner 0664 # Kodak ESP 5200 0x040a 0x4041 root:scanner 0664 # Kodak ESP 3200 0x040a 0x4043 root:scanner 0664 # Kodak ESP 4100 0x040a 0x4053 root:scanner 0664 # Kodak ESP 6100 0x040a 0x4054 root:scanner 0664 # Kodak ESP 7200 0x040a 0x4056 root:scanner 0664 # Kodak ESP C110 0x040a 0x4057 root:scanner 0664 # Kodak ESP C115 0x040a 0x4058 root:scanner 0664 # Kodak ESP 2150 0x040a 0x4059 root:scanner 0664 # Kodak ESP C310 0x040a 0x405d root:scanner 0664 # Kodak ESP C315 0x040a 0x405e root:scanner 0664 # Advent AW10 0x040a 0x4060 root:scanner 0664 # Kodak Hero Office 6.1 0x040a 0x4062 root:scanner 0664 # Kodak Hero 7.1 0x040a 0x4063 root:scanner 0664 # Kodak Hero 5.1 0x040a 0x4064 root:scanner 0664 # Kodak ESP 9200 0x040a 0x4065 root:scanner 0664 # Kodak ESP 2170 0x040a 0x4066 root:scanner 0664 # Kodak Hero 9.1 0x040a 0x4067 root:scanner 0664 # Kodak Hero 3.1 0x040a 0x406d root:scanner 0664 # Kodak i30 0x040a 0x6001 root:scanner 0664 # Kodak i40 0x040a 0x6002 root:scanner 0664 # Kodak i50 | Kodak i55 0x040a 0x6003 root:scanner 0664 # Kodak i60 | Kodak i65 0x040a 0x6004 root:scanner 0664 # Kodak i80 0x040a 0x6005 root:scanner 0664 # Creative WebCam Go Mini 0x041e 0x4007 root:scanner 0664 # Lexmark X70 | Lexmark X73 0x043d 0x002d root:scanner 0664 # Lexmark X74 0x043d 0x0060 root:scanner 0664 # Lexmark X1110 | Lexmark X1130 | Lexmark X1140 | Lexmark X1150 | Lexmark X1170 | Lexmark X1180 | Lexmark X1185 | Lexmark X1195 0x043d 0x007c root:scanner 0664 # Lexmark X12xx 0x043d 0x007d root:scanner 0664 # Genius ColorPage HR6 V1 0x0458 0x2004 root:scanner 0664 # Genius Colorpage HR6 V2 0x0458 0x2007 root:scanner 0664 # Genius Colorpage HR6 V2 0x0458 0x2008 root:scanner 0664 # Genius Colorpage HR6A 0x0458 0x2009 root:scanner 0664 # Genius Colorpage Vivid3x | Genius Colorpage Vivid3 V2 0x0458 0x2011 root:scanner 0664 # Genius Colorpage HR7 0x0458 0x2013 root:scanner 0664 # Genius Colorpage Vivid4 0x0458 0x2014 root:scanner 0664 # Genius Colorpage HR7LE 0x0458 0x2015 root:scanner 0664 # Genius Colorpage HR6X 0x0458 0x2016 root:scanner 0664 # Genius Colorpage Vivid3xe 0x0458 0x2017 root:scanner 0664 # Genius Colorpage Vivid4xe 0x0458 0x201a root:scanner 0664 # Genius Colorpage Vivid4x 0x0458 0x201b root:scanner 0664 # Genius Colorpage Vivid 1200 X 0x0458 0x201d root:scanner 0664 # Genius ColorPage Slim 1200 0x0458 0x201e root:scanner 0664 # Genius Colorpage Vivid 1200 XE 0x0458 0x201f root:scanner 0664 # Genius Colorpage SF600 0x0458 0x2021 root:scanner 0664 # Medion/Lifetec/Tevion/Cytron MD5345 | Medion/Lifetec/Tevion/Cytron MD6228 | Medion/Lifetec/Tevion/Cytron MD6471 0x0461 0x0377 root:scanner 0664 # Xerox 2400 Onetouch 0x0461 0x038b root:scanner 0664 # Trust Office Scan USB 19200 0x047b 0x1000 root:scanner 0664 # Hewlett-Packard ScanJet 4300c/Silitek 0x047b 0x1002 root:scanner 0664 # Kyocera FS-1016MFP 0x0482 0x0335 root:scanner 0664 # Compaq S4-100 0x049f 0x001a root:scanner 0664 # Benq (Acer) 310U 0x04a5 0x1a20 root:scanner 0664 # Benq (Acer) 620U 0x04a5 0x1a2a root:scanner 0664 # Benq (Acer) 320U | Benq (Acer) 340U | Mitsubishi Diamondview 648UT 0x04a5 0x2022 root:scanner 0664 # Benq (Acer) 620UT 0x04a5 0x2040 root:scanner 0664 # Benq (Acer) 640U | Guillemot / Hercules Maxi Scan A4 USB 640U | Guillemot / Hercules Maxi A4 36 bit 0x04a5 0x2060 root:scanner 0664 # Benq (Acer) 640bu 0x04a5 0x207e root:scanner 0664 # Benq (Acer) 3300 | Benq (Acer) 4300 | Mitsubishi Diamondview 650U 0x04a5 0x20b0 root:scanner 0664 # Benq (Acer) 640BT 0x04a5 0x20be root:scanner 0664 # Benq (Acer) 1240 0x04a5 0x20c0 root:scanner 0664 # Benq (Acer) 3300 | Benq (Acer) 4300 | Guillemot / Hercules Scan@home Touch 1248 (USB) 0x04a5 0x20de root:scanner 0664 # Benq (Acer) 5000 0x04a5 0x20f8 root:scanner 0664 # Benq (Acer) 5000E | Benq (Acer) 5000U 0x04a5 0x20fc root:scanner 0664 # Benq (Acer) 5300 0x04a5 0x20fe root:scanner 0664 # Benq (Acer) 5150 | Benq (Acer) 5250 0x04a5 0x2137 root:scanner 0664 # BenQ 5550 0x04a5 0x2211 root:scanner 0664 # Visioneer Visioneer OneTouch 7100 0x04a7 0x0229 root:scanner 0664 # Visioneer 9650 0x04a7 0x0390 root:scanner 0664 # Visioneer 9320 0x04a7 0x0420 root:scanner 0664 # Visioneer 9450 0x04a7 0x0421 root:scanner 0664 # Visioneer 9550 0x04a7 0x0422 root:scanner 0664 # Visioneer 9750 0x04a7 0x0423 root:scanner 0664 # Visioneer Strobe XP 450 0x04a7 0x0424 root:scanner 0664 # Visioneer Strobe XP 200 0x04a7 0x0426 root:scanner 0664 # Visioneer Strobe XP 100 0x04a7 0x0427 root:scanner 0664 # Visioneer OneTouch 7300 0x04a7 0x0444 root:scanner 0664 # Xerox DocuMate510 0x04a7 0x0446 root:scanner 0664 # Xerox DocuMate520 0x04a7 0x0447 root:scanner 0664 # Xerox DocuMate250 0x04a7 0x0448 root:scanner 0664 # Xerox DocuMate252 0x04a7 0x0449 root:scanner 0664 # Xerox DocuMate262 0x04a7 0x044c root:scanner 0664 # Visioneer Strobe XP 300 0x04a7 0x0474 root:scanner 0664 # Xerox DocuMate272 0x04a7 0x0475 root:scanner 0664 # Xerox DocuMate232 0x04a7 0x0476 root:scanner 0664 # Xerox DocuMate152 0x04a7 0x0477 root:scanner 0664 # Xerox DocuMate752 0x04a7 0x0478 root:scanner 0664 # Visioneer Strobe XP 470 0x04a7 0x0479 root:scanner 0664 # Visioneer 9450-G 0x04a7 0x047a root:scanner 0664 # Visioneer 9650-G 0x04a7 0x047b root:scanner 0664 # Xerox DocuMate510-G 0x04a7 0x047c root:scanner 0664 # Xerox DocuMate252-G 0x04a7 0x048c root:scanner 0664 # Xerox DocuMate262-G 0x04a7 0x048d root:scanner 0664 # Xerox DocuMate272-G 0x04a7 0x048e root:scanner 0664 # Visioneer Strobe XP 470-G | Visioneer Patriot 470 0x04a7 0x048f root:scanner 0664 # Xerox DocuMate250-G 0x04a7 0x0490 root:scanner 0664 # Visioneer Strobe XP 450-G 0x04a7 0x0491 root:scanner 0664 # Xerox DocuMate520-G 0x04a7 0x0492 root:scanner 0664 # Visioneer 9750-G 0x04a7 0x0493 root:scanner 0664 # Visioneer Roadwarrior 0x04a7 0x0494 root:scanner 0664 # Xerox DocuMate512 0x04a7 0x0495 root:scanner 0664 # Visioneer Patriot 430 0x04a7 0x0497 root:scanner 0664 # Visioneer Patriot 680 | Xerox DocuMate632 0x04a7 0x0498 root:scanner 0664 # Visioneer Patriot 780 0x04a7 0x0499 root:scanner 0664 # Xerox DocuMate752 0x04a7 0x049a root:scanner 0664 # Visioneer Strobe XP 100,r3 0x04a7 0x049b root:scanner 0664 # Xerox DocuMate150 0x04a7 0x049c root:scanner 0664 # Xerox DocuMate162 0x04a7 0x049d root:scanner 0664 # Xerox DocuMate262i 0x04a7 0x04a7 root:scanner 0664 # Xerox Travel Scanner 100 0x04a7 0x04ac root:scanner 0664 # Canon DR-2080C 0x04a9 0x1601 root:scanner 0664 # Canon CR-180 | Canon CR-180II 0x04a9 0x1602 root:scanner 0664 # Canon DR-9080C 0x04a9 0x1603 root:scanner 0664 # Canon DR-7080C 0x04a9 0x1604 root:scanner 0664 # Canon DR-5010C 0x04a9 0x1606 root:scanner 0664 # Canon DR-6080 0x04a9 0x1607 root:scanner 0664 # Canon DR-2580C 0x04a9 0x1608 root:scanner 0664 # Canon DR-3080CII 0x04a9 0x1609 root:scanner 0664 # Canon DR-2050C | Canon DR-2050SP 0x04a9 0x160a root:scanner 0664 # Canon DR-7580 0x04a9 0x160b root:scanner 0664 # Canon PIXMA MP750 0x04a9 0x1706 root:scanner 0664 # Canon PIXMA MP780 | Canon PIXMA MP790 0x04a9 0x1707 root:scanner 0664 # Canon PIXMA MP760 | Canon PIXMA MP770 0x04a9 0x1708 root:scanner 0664 # Canon PIXMA MP150 0x04a9 0x1709 root:scanner 0664 # Canon PIXMA MP170 0x04a9 0x170a root:scanner 0664 # Canon PIXMA MP450 0x04a9 0x170b root:scanner 0664 # Canon PIXMA MP500 0x04a9 0x170c root:scanner 0664 # Canon PIXMA MP800 0x04a9 0x170d root:scanner 0664 # Canon PIXMA MP800R 0x04a9 0x170e root:scanner 0664 # Canon PIXMA MP530 0x04a9 0x1712 root:scanner 0664 # Canon PIXMA MP830 0x04a9 0x1713 root:scanner 0664 # Canon PIXMA MP160 0x04a9 0x1714 root:scanner 0664 # Canon PIXMA MP180 0x04a9 0x1715 root:scanner 0664 # Canon PIXMA MP460 0x04a9 0x1716 root:scanner 0664 # Canon PIXMA MP510 0x04a9 0x1717 root:scanner 0664 # Canon PIXMA MP600 0x04a9 0x1718 root:scanner 0664 # Canon PIXMA MP600R 0x04a9 0x1719 root:scanner 0664 # Canon PIXMA MP810 0x04a9 0x171a root:scanner 0664 # Canon PIXMA MP960 0x04a9 0x171b root:scanner 0664 # Canon PIXMA MX7600 0x04a9 0x171c root:scanner 0664 # Canon PIXMA MP210 0x04a9 0x1721 root:scanner 0664 # Canon PIXMA MP220 0x04a9 0x1722 root:scanner 0664 # Canon PIXMA MP470 0x04a9 0x1723 root:scanner 0664 # Canon PIXMA MP520 0x04a9 0x1724 root:scanner 0664 # Canon PIXMA MP610 0x04a9 0x1725 root:scanner 0664 # Canon PIXMA MP970 0x04a9 0x1726 root:scanner 0664 # Canon PIXMA MX300 0x04a9 0x1727 root:scanner 0664 # Canon PIXMA MX310 0x04a9 0x1728 root:scanner 0664 # Canon PIXMA MX700 0x04a9 0x1729 root:scanner 0664 # Canon PIXMA MP140 0x04a9 0x172b root:scanner 0664 # Canon PIXMA MX850 0x04a9 0x172c root:scanner 0664 # Canon PIXMA MP980 0x04a9 0x172d root:scanner 0664 # Canon PIXMA MP630 0x04a9 0x172e root:scanner 0664 # Canon PIXMA MP620 0x04a9 0x172f root:scanner 0664 # Canon PIXMA MP540 0x04a9 0x1730 root:scanner 0664 # Canon PIXMA MP480 0x04a9 0x1731 root:scanner 0664 # Canon PIXMA MP240 0x04a9 0x1732 root:scanner 0664 # Canon PIXMA MP260 0x04a9 0x1733 root:scanner 0664 # Canon PIXMA MP190 0x04a9 0x1734 root:scanner 0664 # Canon PIXMA MX860 0x04a9 0x1735 root:scanner 0664 # Canon PIXMA MX320 0x04a9 0x1736 root:scanner 0664 # Canon PIXMA MX330 0x04a9 0x1737 root:scanner 0664 # Canon PIXMA MP250 0x04a9 0x173a root:scanner 0664 # Canon PIXMA MP270 0x04a9 0x173b root:scanner 0664 # Canon PIXMA MP490 0x04a9 0x173c root:scanner 0664 # Canon PIXMA MP550 0x04a9 0x173d root:scanner 0664 # Canon PIXMA MP560 0x04a9 0x173e root:scanner 0664 # Canon PIXMA MP640 0x04a9 0x173f root:scanner 0664 # Canon PIXMA MP990 0x04a9 0x1740 root:scanner 0664 # Canon PIXMA MX340 0x04a9 0x1741 root:scanner 0664 # Canon PIXMA MX350 0x04a9 0x1742 root:scanner 0664 # Canon PIXMA MX870 0x04a9 0x1743 root:scanner 0664 # Canon PIXMA MP280 0x04a9 0x1746 root:scanner 0664 # Canon PIXMA MP495 0x04a9 0x1747 root:scanner 0664 # Canon PIXMA MG5100 Series 0x04a9 0x1748 root:scanner 0664 # Canon PIXMA MG5200 Series 0x04a9 0x1749 root:scanner 0664 # Canon PIXMA MG6100 Series 0x04a9 0x174a root:scanner 0664 # Canon PIXMA MG8100 Series 0x04a9 0x174b root:scanner 0664 # Canon PIXMA MX360 0x04a9 0x174d root:scanner 0664 # Canon PIXMA MX410 0x04a9 0x174e root:scanner 0664 # Canon PIXMA MX420 0x04a9 0x174f root:scanner 0664 # Canon PIXMA MX880 Series | Canon PIXMA MX882 | Canon PIXMA MX885 0x04a9 0x1750 root:scanner 0664 # Canon PIXMA MG2100 Series 0x04a9 0x1751 root:scanner 0664 # Canon PIXMA MG3100 Series 0x04a9 0x1752 root:scanner 0664 # Canon PIXMA MG4100 Series 0x04a9 0x1753 root:scanner 0664 # Canon PIXMA MG5300 Series 0x04a9 0x1754 root:scanner 0664 # Canon PIXMA MG6200 Series 0x04a9 0x1755 root:scanner 0664 # Canon PIXMA MG8200 Series 0x04a9 0x1756 root:scanner 0664 # Canon PIXMA MP493 0x04a9 0x1757 root:scanner 0664 # Canon PIXMA E500 0x04a9 0x1758 root:scanner 0664 # Canon PIXMA MX370 Series 0x04a9 0x1759 root:scanner 0664 # Canon PIXMA E600 0x04a9 0x175a root:scanner 0664 # Canon PIXMA MX430 Series 0x04a9 0x175b root:scanner 0664 # Canon PIXMA MX510 Series 0x04a9 0x175c root:scanner 0664 # Canon PIXMA MX710 Series 0x04a9 0x175d root:scanner 0664 # Canon PIXMA MX890 Series 0x04a9 0x175e root:scanner 0664 # Canon PIXMA MP230 0x04a9 0x175f root:scanner 0664 # Canon PIXMA MG2200 Series 0x04a9 0x1760 root:scanner 0664 # Canon PIXMA E510 0x04a9 0x1761 root:scanner 0664 # Canon PIXMA MG3200 Series 0x04a9 0x1762 root:scanner 0664 # Canon PIXMA MG4200 Series 0x04a9 0x1763 root:scanner 0664 # Canon PIXMA MG5400 Series 0x04a9 0x1764 root:scanner 0664 # Canon PIXMA MG6300 Series 0x04a9 0x1765 root:scanner 0664 # Canon PIXMA MX390 Series 0x04a9 0x1766 root:scanner 0664 # Canon PIXMA E610 0x04a9 0x1767 root:scanner 0664 # Canon PIXMA MX450 Series 0x04a9 0x1768 root:scanner 0664 # Canon PIXMA MX520 Series 0x04a9 0x1769 root:scanner 0664 # Canon PIXMA MX720 Series 0x04a9 0x176a root:scanner 0664 # Canon PIXMA MX920 Series 0x04a9 0x176b root:scanner 0664 # Canon CanoScan 8800F 0x04a9 0x1901 root:scanner 0664 # Canon CanoScan LiDE 100 0x04a9 0x1904 root:scanner 0664 # Canon CanoScan LiDE 200 0x04a9 0x1905 root:scanner 0664 # Canon CanoScan 700F 0x04a9 0x1907 root:scanner 0664 # Canon CanoScan 9000F 0x04a9 0x1908 root:scanner 0664 # Canon CanoScan LiDE 110 0x04a9 0x1909 root:scanner 0664 # Canon CanoScan LiDE 210 0x04a9 0x190a root:scanner 0664 # Canon CanoScan 9000F Mark II 0x04a9 0x190d root:scanner 0664 # Canon CanoScan fb630u | Canon CanoScan fb636u 0x04a9 0x2204 root:scanner 0664 # Canon CanoScan N650U/N656U 0x04a9 0x2206 root:scanner 0664 # Canon CanoScan N1220U 0x04a9 0x2207 root:scanner 0664 # Canon CanoScan D660U 0x04a9 0x2208 root:scanner 0664 # Canon CanoScan N670U/N676U/LiDE20 0x04a9 0x220d root:scanner 0664 # Canon CanoScan N1240U/LiDE30 0x04a9 0x220e root:scanner 0664 # Canon CanoScan LiDE 35 | Canon CanoScan LiDE 40 | Canon CanoScan LiDE 50 0x04a9 0x2213 root:scanner 0664 # Canon CanoScan LiDE 60 0x04a9 0x221c root:scanner 0664 # Canon CanoScan LiDE25 0x04a9 0x2220 root:scanner 0664 # Canon DR-1210C 0x04a9 0x2222 root:scanner 0664 # Canon PIXMA MP730 0x04a9 0x262f root:scanner 0664 # Canon PIXMA MP700 0x04a9 0x2630 root:scanner 0664 # Canon PIXMA MP360 0x04a9 0x263c root:scanner 0664 # Canon PIXMA MP370 0x04a9 0x263d root:scanner 0664 # Canon PIXMA MP390 0x04a9 0x263e root:scanner 0664 # Canon PIXMA MP375R 0x04a9 0x263f root:scanner 0664 # Canon PIXMA MP740 0x04a9 0x264c root:scanner 0664 # Canon PIXMA MP710 0x04a9 0x264d root:scanner 0664 # Canon imageCLASS MF5630 0x04a9 0x264e root:scanner 0664 # Canon laserBase MF5650 0x04a9 0x264f root:scanner 0664 # Canon imageCLASS MF8170c 0x04a9 0x2659 root:scanner 0664 # Canon imageCLASS MF5730 0x04a9 0x265d root:scanner 0664 # Canon imageCLASS MF5750 0x04a9 0x265e root:scanner 0664 # Canon imageCLASS MF5770 0x04a9 0x265f root:scanner 0664 # Canon imageCLASS MF3110 0x04a9 0x2660 root:scanner 0664 # Canon imageCLASS MF3240 0x04a9 0x2684 root:scanner 0664 # Canon imageCLASS MF6500 series | Canon imageCLASS MF6550 0x04a9 0x2686 root:scanner 0664 # Canon imageCLASS MF4120 | Canon imageCLASS MF4122 | Canon imageCLASS MF4140 | Canon imageCLASS MF4150 0x04a9 0x26a3 root:scanner 0664 # Canon imageCLASS MF4660 | Canon imageCLASS MF4690 0x04a9 0x26b0 root:scanner 0664 # Canon imageCLASS MF4010 | Canon imageCLASS MF4018 0x04a9 0x26b4 root:scanner 0664 # Canon imageCLASS MF4270 0x04a9 0x26b5 root:scanner 0664 # Canon imageRUNNER 1020/1024/1025 0x04a9 0x26e6 root:scanner 0664 # Canon imageCLASS MF4370dn | Canon imageCLASS MF4380dn 0x04a9 0x26ec root:scanner 0664 # Canon imageCLASS D480 0x04a9 0x26ed root:scanner 0664 # Canon I-SENSYS MF4320d | Canon I-SENSYS MF4330d | Canon imageCLASS MF4350d 0x04a9 0x26ee root:scanner 0664 # Canon imageCLASS D420 0x04a9 0x26ef root:scanner 0664 # Canon i-SENSYS MF5880dn 0x04a9 0x26f9 root:scanner 0664 # Canon i-SENSYS MF6680dn 0x04a9 0x26fa root:scanner 0664 # Canon imageCLASS MF8030 0x04a9 0x2707 root:scanner 0664 # Canon i-SENSYS MF4550d 0x04a9 0x2736 root:scanner 0664 # Canon imageCLASS MF4410 | Canon imageCLASS MF4430 0x04a9 0x2737 root:scanner 0664 # Canon i-SENSYS MF3010 0x04a9 0x2759 root:scanner 0664 # Nikon LS 40 ED | Nikon LS 40 ED | Nikon Coolspan IV 0x04b0 0x4000 root:scanner 0664 # Nikon LS 50 ED | Nikon Coolscan V ED | Nikon LS 50 ED | Nikon Coolscan V ED 0x04b0 0x4001 root:scanner 0664 # Nikon Super Coolscan LS-5000 ED | Nikon Super Coolscan LS-5000 ED 0x04b0 0x4002 root:scanner 0664 # Epson Perfection 636U | Epson GT-7000U | Epson Perfection 636U 0x04b8 0x0101 root:scanner 0664 # Epson Perfection 610 | Epson GT-6600U | Epson Perfection 610 0x04b8 0x0103 root:scanner 0664 # Epson Perfection 1200U | Epson Perfection 1200Photo | Epson GT-7600U | Epson GT-7600UF | Epson Perfection 1200U | Epson Perfection 1200U PHOTO 0x04b8 0x0104 root:scanner 0664 # Epson Stylus Scan 2000 0x04b8 0x0105 root:scanner 0664 # Epson Stylus Scan 2500 0x04b8 0x0106 root:scanner 0664 # Epson Expression 1600 | Epson ES-2000 | Epson Expression 1600 0x04b8 0x0107 root:scanner 0664 # Epson ES-8500 | Epson Expression 1640XL 0x04b8 0x0109 root:scanner 0664 # Epson Perfection 1640 | Epson GT-8700 | Epson GT-8700F | Epson Perfection 1640SU | Epson Perfection 1640SU PHOTO 0x04b8 0x010a root:scanner 0664 # Epson Perfection 1240 | Epson GT-7700U | Epson Perfection 1240U 0x04b8 0x010b root:scanner 0664 # Epson Perfection 640 | Epson GT-6700U | Epson Perfection 640U 0x04b8 0x010c root:scanner 0664 # Epson Expression 1680 | Epson ES-2200 | Epson Expression 1680 0x04b8 0x010e root:scanner 0664 # Epson Perfection 1250 | Epson Perfection 1250Photo 0x04b8 0x010f root:scanner 0664 # Epson Perfection 1650 | Epson GT-8200U | Epson GT-8200UF | Epson Perfection 1650 | Epson Perfection 1650 PHOTO 0x04b8 0x0110 root:scanner 0664 # Epson Perfection 2450 | Epson GT-9700F | Epson Perfection 2450 PHOTO 0x04b8 0x0112 root:scanner 0664 # Epson Perfection 660 0x04b8 0x0114 root:scanner 0664 # Epson Perfection 2400 | Epson GT-9300UF | Epson Perfection 2400 PHOTO 0x04b8 0x011b root:scanner 0664 # Epson Perfection 3200 | Epson GT-9800F | Epson Perfection 3200 PHOTO 0x04b8 0x011c root:scanner 0664 # Epson Perfection 1260 | Epson Perfection 1260Photo 0x04b8 0x011d root:scanner 0664 # Epson Perfection 1660 | Epson GT-8300UF | Epson Perfection 1660 PHOTO 0x04b8 0x011e root:scanner 0664 # Epson Perfection 1670 0x04b8 0x011f root:scanner 0664 # Epson Perfection 1270 0x04b8 0x0120 root:scanner 0664 # Epson Perfection 2480 | Epson Perfection 2580 0x04b8 0x0121 root:scanner 0664 # Epson Perfection 3490 | Epson Perfection 3590 0x04b8 0x0122 root:scanner 0664 # Epson ES-7000H | Epson GT-15000 0x04b8 0x0126 root:scanner 0664 # Epson Perfection 4870 | Epson GT-X700 | Epson Perfection 4870 PHOTO 0x04b8 0x0128 root:scanner 0664 # Epson ES-10000G | Epson Expression 10000XL 0x04b8 0x0129 root:scanner 0664 # Epson Perfection 4990 | Epson GT-X800 | Epson Perfection 4990 PHOTO 0x04b8 0x012a root:scanner 0664 # Epson ES-H300 | Epson GT-2500 0x04b8 0x012b root:scanner 0664 # Epson V700 | Epson V750 | Epson GT-X900 | Epson Perfection V700 Photo | Epson Perfection V750 Photo 0x04b8 0x012c root:scanner 0664 # Epson GT-X970 0x04b8 0x0135 root:scanner 0664 # Epson CX-5200 | Epson CX-5400 | Epson CC-600PX | Epson Stylus CX5100 | Epson Stylus CX5200 0x04b8 0x0801 root:scanner 0664 # Epson CX-3200 | Epson CC-570L | Epson Stylus CX3100 | Epson Stylus CX3200 0x04b8 0x0802 root:scanner 0664 # Epson CX-6300 | Epson CX-6400 | Epson Stylus CX6300 | Epson Stylus CX6400 0x04b8 0x0805 root:scanner 0664 # Epson RX-600 | Epson PM-A850 | Epson Stylus Photo RX600 0x04b8 0x0806 root:scanner 0664 # Epson RX-500 | Epson Stylus Photo RX500 | Epson Stylus Photo RX510 0x04b8 0x0807 root:scanner 0664 # Epson CX-5400 | Epson Stylus CX5300 | Epson Stylus CX5400 0x04b8 0x0808 root:scanner 0664 # Epson Stylus CX-1500 0x04b8 0x080c root:scanner 0664 # Epson CX-4600 | Epson Stylus CX4500 | Epson Stylus CX4600 0x04b8 0x080d root:scanner 0664 # Epson CX-3600 | Epson CX-3650 | Epson PX-A550 | Epson Stylus CX3500 | Epson Stylus CX3600 | Epson Stylus CX3650 0x04b8 0x080e root:scanner 0664 # Epson RX-425 | Epson Stylus Photo RX420 | Epson Stylus Photo RX425 | Epson Stylus Photo RX430 0x04b8 0x080f root:scanner 0664 # Epson RX-700 | Epson PM-A900 | Epson Stylus Photo RX700 0x04b8 0x0810 root:scanner 0664 # Epson RX-620 | Epson PM-A870 | Epson Stylus Photo RX620 | Epson Stylus Photo RX630 0x04b8 0x0811 root:scanner 0664 # Epson CX-6500 | Epson CX-6600 | Epson Stylus CX6500 | Epson Stylus CX6600 0x04b8 0x0813 root:scanner 0664 # Epson PM-A700 0x04b8 0x0814 root:scanner 0664 # Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson LP-A500 0x04b8 0x0815 root:scanner 0664 # Epson LP-M5500 | Epson LP-M5500F 0x04b8 0x0817 root:scanner 0664 # Epson DX-3850 | Epson CX-3700 | Epson CX-3800 | Epson DX-3800 | Epson Stylus CX3700 | Epson Stylus CX3800 | Epson Stylus DX3800 0x04b8 0x0818 root:scanner 0664 # Epson CX-4800 | Epson PX-A650 | Epson Stylus CX4700 | Epson Stylus CX4800 | Epson Stylus DX4800 | Epson Stylus DX4850 0x04b8 0x0819 root:scanner 0664 # Epson PM-A750 | Epson Stylus Photo RX520 | Epson Stylus Photo RX530 0x04b8 0x081a root:scanner 0664 # Epson PM-A890 | Epson Stylus Photo RX640 | Epson Stylus Photo RX650 0x04b8 0x081c root:scanner 0664 # Epson PM-A950 0x04b8 0x081d root:scanner 0664 # Epson Stylus CX7700 | Epson Stylus CX7800 0x04b8 0x081f root:scanner 0664 # Epson CX-4200 | Epson Stylus CX4100 | Epson Stylus CX4200 | Epson Stylus DX4200 0x04b8 0x0820 root:scanner 0664 # Epson PM-A820 | Epson Stylus Photo RX560 | Epson Stylus Photo RX580 | Epson Stylus Photo RX590 0x04b8 0x0827 root:scanner 0664 # Epson PM-A970 0x04b8 0x0828 root:scanner 0664 # Epson PM-T990 0x04b8 0x0829 root:scanner 0664 # Epson PM-A920 0x04b8 0x082a root:scanner 0664 # Epson CX-5000 | Epson DX-5000 | Epson DX-5050 | Epson Stylus CX4900 | Epson Stylus CX5000 | Epson Stylus DX5000 0x04b8 0x082b root:scanner 0664 # Epson DX-6000 | Epson PX-A720 | Epson Stylus CX5900 | Epson Stylus CX6000 | Epson Stylus DX6000 0x04b8 0x082e root:scanner 0664 # Epson DX-4050 | Epson PX-A620 | Epson Stylus CX3900 | Epson Stylus DX4000 0x04b8 0x082f root:scanner 0664 # Epson ME 200 | Epson Stylus CX2800 | Epson Stylus CX2900 0x04b8 0x0830 root:scanner 0664 # Epson LP-M5600 0x04b8 0x0833 root:scanner 0664 # Epson LP-M6000 0x04b8 0x0834 root:scanner 0664 # Epson AcuLaser CX21 0x04b8 0x0835 root:scanner 0664 # Epson PM-T960 0x04b8 0x0836 root:scanner 0664 # Epson PM-A940 | Epson Stylus Photo RX680 | Epson Stylus Photo RX685 | Epson Stylus Photo RX690 0x04b8 0x0837 root:scanner 0664 # Epson DX-7400 | Epson PX-A640 | Epson Stylus CX7300 | Epson Stylus CX7400 | Epson Stylus DX7400 0x04b8 0x0838 root:scanner 0664 # Epson PX-A740 | Epson Stylus CX8300 | Epson Stylus CX8400 | Epson Stylus DX8400 0x04b8 0x0839 root:scanner 0664 # Epson PX-FA700 | Epson Stylus CX9300F | Epson Stylus CX9400Fax | Epson Stylus DX9400F 0x04b8 0x083a root:scanner 0664 # Epson PM-A840 | Epson PM-A840S | Epson Stylus Photo RX585 | Epson Stylus Photo RX595 | Epson Stylus Photo RX610 0x04b8 0x083c root:scanner 0664 # Epson ME 300 | Epson PX-401A | Epson Stylus NX100 | Epson Stylus SX100 | Epson Stylus TX100 0x04b8 0x0841 root:scanner 0664 # Epson LP-M5000 0x04b8 0x0843 root:scanner 0664 # Epson Artisan 800 | Epson EP-901A | Epson EP-901F | Epson Stylus Photo PX800FW | Epson Stylus Photo TX800FW 0x04b8 0x0844 root:scanner 0664 # Epson Artisan 700 | Epson EP-801A | Epson Stylus Photo PX700W | Epson Stylus Photo TX700W 0x04b8 0x0846 root:scanner 0664 # Epson ME Office 700FW | Epson PX-601F | Epson Stylus Office BX600FW | Epson Stylus Office TX600FW | Epson Stylus SX600FW | Epson WorkForce 600 0x04b8 0x0847 root:scanner 0664 # Epson ME Office 600F | Epson Stylus Office BX300F | Epson Stylus Office TX300F | Epson Stylus NX300 0x04b8 0x0848 root:scanner 0664 # Epson Stylus NX200 | Epson Stylus SX200 | Epson Stylus SX205 | Epson Stylus TX200 | Epson Stylus TX203 | Epson Stylus TX209 0x04b8 0x0849 root:scanner 0664 # Epson PX-501A | Epson Stylus NX400 | Epson Stylus SX400 | Epson Stylus SX405 | Epson Stylus TX400 0x04b8 0x084a root:scanner 0664 # Epson WorkForce 500 0x04b8 0x084c root:scanner 0664 # Epson PX-402A | Epson Stylus NX110 Series | Epson Stylus SX110 Series | Epson Stylus TX110 Series 0x04b8 0x084d root:scanner 0664 # Epson ME OFFICE 510 | Epson Stylus NX210 Series | Epson Stylus SX210 Series | Epson Stylus TX210 Series 0x04b8 0x084f root:scanner 0664 # Epson Stylus NX410 Series | Epson Stylus SX410 Series | Epson Stylus TX410 Series 0x04b8 0x0851 root:scanner 0664 # Epson ME OFFICE 650FN Series | Epson Stylus Office BX310FN Series | Epson Stylus Office TX510FN Series | Epson WorkForce 310 Series 0x04b8 0x0854 root:scanner 0664 # Epson PX-502A | Epson Stylus NX510 Series | Epson Stylus SX510W Series | Epson Stylus TX550W Series 0x04b8 0x0856 root:scanner 0664 # Epson Stylus SX125 0x04b8 0x085c root:scanner 0664 # Fujitsu fi-4010CU 0x04c5 0x1029 root:scanner 0664 # Fujitsu fi-4120C 0x04c5 0x1041 root:scanner 0664 # Fujitsu fi-4220C 0x04c5 0x1042 root:scanner 0664 # Fujitsu fi-4530C 0x04c5 0x1078 root:scanner 0664 # Fujitsu fi-5750C 0x04c5 0x1095 root:scanner 0664 # Fujitsu fi-5110EOX/2 0x04c5 0x1096 root:scanner 0664 # Fujitsu fi-5110C 0x04c5 0x1097 root:scanner 0664 # Fujitsu fi-5650C 0x04c5 0x10ad root:scanner 0664 # Fujitsu fi-4120C2 0x04c5 0x10ae root:scanner 0664 # Fujitsu fi-4220C2 0x04c5 0x10af root:scanner 0664 # Fujitsu fi-60F 0x04c5 0x10c7 root:scanner 0664 # Fujitsu fi-4340C 0x04c5 0x10cf root:scanner 0664 # Fujitsu fi-5120C 0x04c5 0x10e0 root:scanner 0664 # Fujitsu fi-5220C 0x04c5 0x10e1 root:scanner 0664 # Fujitsu fi-5530C 0x04c5 0x10e2 root:scanner 0664 # Fujitsu fi-5110EOX3 0x04c5 0x10e6 root:scanner 0664 # Fujitsu fi-5900C 0x04c5 0x10e7 root:scanner 0664 # Fujitsu fi-5015C 0x04c5 0x10ef root:scanner 0664 # Fujitsu fi-5110EOXM 0x04c5 0x10f2 root:scanner 0664 # Fujitsu ScanSnap S500 0x04c5 0x10fe root:scanner 0664 # Fujitsu ScanSnap S500M 0x04c5 0x1135 root:scanner 0664 # Fujitsu fi-5530C2 0x04c5 0x114a root:scanner 0664 # Fujitsu fi-6140 0x04c5 0x114d root:scanner 0664 # Fujitsu fi-6240 0x04c5 0x114e root:scanner 0664 # Fujitsu fi-6130 0x04c5 0x114f root:scanner 0664 # Fujitsu fi-6230 0x04c5 0x1150 root:scanner 0664 # Fujitsu ScanSnap S510 0x04c5 0x1155 root:scanner 0664 # Fujitsu ScanSnap S300 0x04c5 0x1156 root:scanner 0664 # Fujitsu ScanSnap S510M 0x04c5 0x116f root:scanner 0664 # Fujitsu fi-6770 0x04c5 0x1174 root:scanner 0664 # Fujitsu fi-6770A 0x04c5 0x1175 root:scanner 0664 # Fujitsu fi-6670 0x04c5 0x1176 root:scanner 0664 # Fujitsu fi-6670A 0x04c5 0x1177 root:scanner 0664 # Fujitsu fi-6750S 0x04c5 0x1178 root:scanner 0664 # Fujitsu ScanSnap S300M 0x04c5 0x117f root:scanner 0664 # Fujitsu fi-6800 0x04c5 0x119d root:scanner 0664 # Fujitsu fi-6800-CGA 0x04c5 0x119e root:scanner 0664 # Fujitsu ScanSnap S1500 | Fujitsu ScanSnap S1500M 0x04c5 0x11a2 root:scanner 0664 # Fujitsu ScanSnap S1300 0x04c5 0x11ed root:scanner 0664 # Fujitsu fi-6140Z 0x04c5 0x11f1 root:scanner 0664 # Fujitsu fi-6240Z 0x04c5 0x11f2 root:scanner 0664 # Fujitsu fi-6130Z 0x04c5 0x11f3 root:scanner 0664 # Fujitsu fi-6230Z 0x04c5 0x11f4 root:scanner 0664 # Fujitsu fi-6110 0x04c5 0x11fc root:scanner 0664 # Fujitsu fi-5950 0x04c5 0x1213 root:scanner 0664 # Fujitsu ScanSnap iX500 0x04c5 0x132b root:scanner 0664 # Konica e-mini 0x04c8 0x0722 root:scanner 0664 # Panasonic KV-S2026C 0x04da 0x1000 root:scanner 0664 # Panasonic KV-S2046C 0x04da 0x1001 root:scanner 0664 # Panasonic KV-S1025C 0x04da 0x1006 root:scanner 0664 # Panasonic KV-S1020C 0x04da 0x1007 root:scanner 0664 # Panasonic KV-S2048C 0x04da 0x1009 root:scanner 0664 # Panasonic KV-S2028C 0x04da 0x100a root:scanner 0664 # Panasonic KV-S4085C 0x04da 0x100c root:scanner 0664 # Panasonic KV-S4065C 0x04da 0x100d root:scanner 0664 # Panasonic KV-S7075C 0x04da 0x100e root:scanner 0664 # Panasonic KV-SS080 0x04da 0x100f root:scanner 0664 # Panasonic KV-S1045C 0x04da 0x1010 root:scanner 0664 # Samsung SCX-4x16 0x04e8 0x3409 root:scanner 0664 # Samsung SCX-6x20 0x04e8 0x340d root:scanner 0664 # Samsung MFP-560 0x04e8 0x340e root:scanner 0664 # Samsung MFP-750 0x04e8 0x340f root:scanner 0664 # Samsung SCX-4x20 0x04e8 0x3412 root:scanner 0664 # Samsung SCX-4100 0x04e8 0x3413 root:scanner 0664 # Samsung SCX-4x21 0x04e8 0x3419 root:scanner 0664 # Samsung SCX-5x30 0x04e8 0x341a root:scanner 0664 # Samsung SCX-4200 0x04e8 0x341b root:scanner 0664 # Samsung CLX-3160 0x04e8 0x341c root:scanner 0664 # Samsung SCX-6x22 0x04e8 0x341d root:scanner 0664 # Samsung SCX4725 | Samsung SCX4725-FN 0x04e8 0x341f root:scanner 0664 # Samsung SCX-6x45 0x04e8 0x3420 root:scanner 0664 # Samsung CLX-8380 0x04e8 0x3421 root:scanner 0664 # Samsung CLX-2160 0x04e8 0x3425 root:scanner 0664 # Samsung SCX-4500 0x04e8 0x3426 root:scanner 0664 # Samsung CLX-6200 0x04e8 0x3427 root:scanner 0664 # Samsung CLX-6240 0x04e8 0x3428 root:scanner 0664 # Samsung SCX-6x55 0x04e8 0x3429 root:scanner 0664 # Samsung CLX-3170fn (CLX-3170 Series) | Samsung CLX-3175FW 0x04e8 0x342a root:scanner 0664 # Samsung SCX-4500W 0x04e8 0x342b root:scanner 0664 # Samsung SCX-4824 (SCX-4x24 Series) 0x04e8 0x342c root:scanner 0664 # Samsung SCX-4828FN (SCX-4x28 Series) 0x04e8 0x342d root:scanner 0664 # Samsung SCX-4300 0x04e8 0x342e root:scanner 0664 # Samsung SCX-5835_5935 0x04e8 0x342f root:scanner 0664 # Samsung SCX-5635 0x04e8 0x3430 root:scanner 0664 # Samsung SCX-4x26 0x04e8 0x3432 root:scanner 0664 # Samsung SCX-4600 0x04e8 0x3433 root:scanner 0664 # Samsung SCX-4623 0x04e8 0x3434 root:scanner 0664 # Samsung MFP-65x 0x04e8 0x3435 root:scanner 0664 # Samsung SCX-6545 0x04e8 0x3437 root:scanner 0664 # Samsung CLX-8385 0x04e8 0x3439 root:scanner 0664 # Samsung CLX-6220 0x04e8 0x343a root:scanner 0664 # Samsung CLX-6250 0x04e8 0x343b root:scanner 0664 # Samsung SCX-4825FN (SCX-4x25 Series) 0x04e8 0x343c root:scanner 0664 # Samsung CLX-3185 0x04e8 0x343d root:scanner 0664 # Samsung CLX-8540 0x04e8 0x343f root:scanner 0664 # Samsung SCX-4623FW 0x04e8 0x3440 root:scanner 0664 # Samsung SCX-3205W (SCX-3200 Series) 0x04e8 0x3441 root:scanner 0664 # Samsung SCX-6545X 0x04e8 0x3442 root:scanner 0664 # Samsung SCX-6x55X 0x04e8 0x3443 root:scanner 0664 # Samsung CLX-8385X 0x04e8 0x3444 root:scanner 0664 # Samsung SCX-5835_5935X 0x04e8 0x3446 root:scanner 0664 # Samsung SCX-4833FD | Samsung SCX-4835FD 0x04e8 0x344b root:scanner 0664 # Samsung SCX-3400 0x04e8 0x344f root:scanner 0664 # Samsung SF-760 0x04e8 0x3450 root:scanner 0664 # Samsung SCX-4729FD 0x04e8 0x3453 root:scanner 0664 # Samsung CLX-6260 0x04e8 0x3455 root:scanner 0664 # Samsung CLX-3300 Series 0x04e8 0x3456 root:scanner 0664 # Samsung SCX-470x 0x04e8 0x3457 root:scanner 0664 # Samsung CLX-4190 0x04e8 0x345a root:scanner 0664 # Samsung SCX-4650 4x21S Series 0x04e8 0x345b root:scanner 0664 # Samsung M337x 387x 407x Series 0x04e8 0x3460 root:scanner 0664 # Samsung M267x 287x Series 0x04e8 0x3461 root:scanner 0664 # Samsung SCX-681x 0x04e8 0x3466 root:scanner 0664 # Samsung C460 0x04e8 0x3468 root:scanner 0664 # Pentax DSmobile 600 0x04f9 0x2038 root:scanner 0664 # Aiptek Aiptek Pencam 0x0553 0x0202 root:scanner 0664 # Mustek ScanExpress 1200 CU 0x055f 0x0001 root:scanner 0664 # Mustek ScanExpress 600 CU 0x055f 0x0002 root:scanner 0664 # Mustek ScanExpress 1200 UB | Trust Compact Scan USB 19200 0x055f 0x0006 root:scanner 0664 # Mustek ScanExpress 1200 CU Plus 0x055f 0x0008 root:scanner 0664 # Mustek BearPaw 1200 F 0x055f 0x0010 root:scanner 0664 # Mustek ScanExpress A3 USB 0x055f 0x0210 root:scanner 0664 # Mustek BearPaw 2400 CS | Mustek BearPaw 2400 TA | Trust 240TH Easy Webscan Gold 0x055f 0x0218 root:scanner 0664 # Mustek BearPaw 2400 CS Plus | Mustek BearPaw 2400 TA Plus | Mustek Plug-n-Scan 2400 MT | Mustek Plug-n-Scan 2400 M | Packard Bell Diamond 2450 0x055f 0x0219 root:scanner 0664 # Mustek BearPaw 2448 CS Plus | Mustek BearPaw 2448 TA Plus 0x055f 0x021a root:scanner 0664 # Mustek BearPaw 1200 CU Plus | Packard Bell Diamond 1200 Plus 0x055f 0x021b root:scanner 0664 # Mustek BearPaw 1200 CU Plus | Mustek BearPaw 1248 CU | Packard Bell Diamond 1200 Plus | Trust Direct WebScan 19200 0x055f 0x021c root:scanner 0664 # Mustek BearPaw 2400 CU Plus 0x055f 0x021d root:scanner 0664 # Mustek BearPaw 1200 CS | Mustek BearPaw 1200 TA 0x055f 0x021e root:scanner 0664 # Mustek ScanExpress 1248 UB 0x055f 0x021f root:scanner 0664 # Mustek BearPaw 2448TA Pro 0x055f 0x0409 root:scanner 0664 # Artec/Ultima Ultima 2000 | Artec/Ultima Ultima 2000 e+ | Boeder Sm@rtScan Slim Edition | Fujitsu 1200CUS | Googlegear 2000 | Medion/Lifetec/Tevion/Cytron MD 4394 | Medion/Lifetec/Tevion/Cytron MD/LT 9375 | Medion/Lifetec/Tevion/Cytron MD/LT 9385 | Medion/Lifetec/Tevion/Cytron LT 9452 | Medion/Lifetec/Tevion/Cytron MD 9458 | Mustek BearPaw 1200 CU | Mustek BearPaw 2400 CU | Mustek ScanExpress 1200 UB Plus | Mustek ScanExpress 2400 USB | Mustek ScanMagic 1200 UB Plus | Packard Bell Diamond 1200 | Trust Compact Scan USB 19200 | Trust Flat Scan USB 19200 0x05d8 0x4002 root:scanner 0664 # Artec/Ultima E+ 48U | Medion/Lifetec/Tevion/Cytron MD9693 | Medion/Lifetec/Tevion/Cytron MD9705 | Medion/Lifetec/Tevion/Cytron MD4394 | Microstar MR 9791 0x05d8 0x4003 root:scanner 0664 # Artec/Ultima E+ Pro 0x05d8 0x4004 root:scanner 0664 # Memorex MEM 48U 0x05d8 0x4005 root:scanner 0664 # Trust Easy Webscan 19200 0x05d8 0x4006 root:scanner 0664 # Trust 240H Easy Webscan Gold 0x05d8 0x4007 root:scanner 0664 # UMAX AstraSlim SE 0x05d8 0x4009 root:scanner 0664 # UMAX AstraSlim 1200 SE 0x05d8 0x4010 root:scanner 0664 # Yakumo Scan50 0x05d8 0x4011 root:scanner 0664 # Microtek ScanMaker X6USB 0x05da 0x0099 root:scanner 0664 # Microtek SlimScan C6 0x05da 0x009a root:scanner 0664 # Microtek ScanMaker V6USL 0x05da 0x00a3 root:scanner 0664 # Microtek ScanMaker V6UPL 0x05da 0x00b6 root:scanner 0664 # Microtek ScanMaker 4800 0x05da 0x30cf root:scanner 0664 # Microtek ScanMaker 3840 0x05da 0x30d4 root:scanner 0664 # Microtek ScanMaker 3600 0x05da 0x40b3 root:scanner 0664 # Microtek ScanMaker 3700 0x05da 0x40b8 root:scanner 0664 # Microtek ScanMaker 3600 0x05da 0x40ca root:scanner 0664 # Microtek ScanMaker 3700 0x05da 0x40cb root:scanner 0664 # Microtek ScanMaker 3750 0x05da 0x40dd root:scanner 0664 # Microtek ScanMaker 3600 0x05da 0x40ff root:scanner 0664 # Microtek ScanMaker V6USL 0x05da 0x80a3 root:scanner 0664 # iVina 1200U 0x0638 0x0268 root:scanner 0664 # Minolta Dimage Scan Dual II 0x0638 0x026a root:scanner 0664 # Avision AV600U 0x0638 0x0a13 root:scanner 0664 # Minolta-QMS SC-110 0x0638 0x0a15 root:scanner 0664 # Avision DS610CU Scancopier | Minolta-QMS SC-215 | OKI S700 Scancopier 0x0638 0x0a16 root:scanner 0664 # Avision AV610 | Avision AV600U Plus 0x0638 0x0a18 root:scanner 0664 # Avision AV220 0x0638 0x0a23 root:scanner 0664 # Avision AV210 0x0638 0x0a24 root:scanner 0664 # Avision AV210 0x0638 0x0a25 root:scanner 0664 # Avision AV120 0x0638 0x0a27 root:scanner 0664 # Avision AV220C2 0x0638 0x0a2a root:scanner 0664 # Avision AV220D2 0x0638 0x0a2b root:scanner 0664 # Avision AV220+ 0x0638 0x0a2c root:scanner 0664 # Avision AV220C2-G 0x0638 0x0a2d root:scanner 0664 # Avision AV220C2-B 0x0638 0x0a2e root:scanner 0664 # Avision AV210C2-G 0x0638 0x0a2f root:scanner 0664 # Avision AV122 0x0638 0x0a33 root:scanner 0664 # Avision AV210C2 0x0638 0x0a3a root:scanner 0664 # Avision AV121 0x0638 0x0a3c root:scanner 0664 # Avision AV8300 0x0638 0x0a40 root:scanner 0664 # Avision AM3000 Series 0x0638 0x0a41 root:scanner 0664 # Avision @V5100 0x0638 0x0a45 root:scanner 0664 # Avision AV8050U 0x0638 0x0a4d root:scanner 0664 # Avision AV3200SU 0x0638 0x0a4e root:scanner 0664 # Avision AV3730SU 0x0638 0x0a4f root:scanner 0664 # Avision AV610C2 0x0638 0x0a5e root:scanner 0664 # Avision IT8300 0x0638 0x0a61 root:scanner 0664 # Avision AV3750SU 0x0638 0x0a65 root:scanner 0664 # Avision AV3850SU 0x0638 0x0a66 root:scanner 0664 # Avision AV8350 0x0638 0x0a68 root:scanner 0664 # Avision FB6080E 0x0638 0x0a82 root:scanner 0664 # Avision FB2080E 0x0638 0x0a84 root:scanner 0664 # Avision AV122 C2 0x0638 0x0a93 root:scanner 0664 # Avision AV220-G 0x0638 0x0a94 root:scanner 0664 # Avision @V2500 0x0638 0x0aa1 root:scanner 0664 # Avision AV210D2+ 0x0638 0x1a35 root:scanner 0664 # Minolta Elite II 0x0686 0x4004 root:scanner 0664 # Minolta Dimage Scan Dual III 0x0686 0x400d root:scanner 0664 # Minolta Dimage Scan Elite 5400 0x0686 0x400e root:scanner 0664 # AGFA SnapScan 1212U 0x06bd 0x0001 root:scanner 0664 # AGFA SnapScan 1236u 0x06bd 0x0002 root:scanner 0664 # Agfa Snapscan Touch 0x06bd 0x0100 root:scanner 0664 # AGFA SnapScan 1212U_2 0x06bd 0x2061 root:scanner 0664 # AGFA SnapScan e40 0x06bd 0x208d root:scanner 0664 # AGFA SnapScan e50 0x06bd 0x208f root:scanner 0664 # AGFA SnapScan e20 0x06bd 0x2091 root:scanner 0664 # AGFA SnapScan e10 0x06bd 0x2093 root:scanner 0664 # AGFA SnapScan e25 0x06bd 0x2095 root:scanner 0664 # AGFA SnapScan e26 0x06bd 0x2097 root:scanner 0664 # AGFA SnapScan e52 0x06bd 0x20fd root:scanner 0664 # AGFA SnapScan e42 0x06bd 0x20ff root:scanner 0664 # UMAX Astra 4900 0x06dc 0x0020 root:scanner 0664 # Plustek OpticPro U12 | Plustek OpticPro UT12 | Plustek OpticPro 1212U | RevScan RevScan Orange R48Ti | Genius ColorPage Vivid III USB 0x07b3 0x0001 root:scanner 0664 # Plustek OpticPro U12 0x07b3 0x0010 root:scanner 0664 # Plustek OpticPro U24 0x07b3 0x0011 root:scanner 0664 # Plustek OpticPro UT12 0x07b3 0x0013 root:scanner 0664 # Plustek OpticPro U24 0x07b3 0x0015 root:scanner 0664 # Plustek OpticPro UT12 | Plustek OpticPro UT16 | Plustek OpticPro UT24 0x07b3 0x0017 root:scanner 0664 # Plustek OpticPro 1248U | RevScan 19200i 0x07b3 0x0400 root:scanner 0664 # Plustek OpticPro 1248U 0x07b3 0x0401 root:scanner 0664 # Plustek OpticPro U16B 0x07b3 0x0402 root:scanner 0664 # Plustek OpticPro U16B+ | Plustek OpticPro UT16B 0x07b3 0x0403 root:scanner 0664 # Nortek MyScan 1200 | Plustek OpticPro S12 | Plustek OpticPro ST12 0x07b3 0x040b root:scanner 0664 # Plustek OpticPro S24 0x07b3 0x040e root:scanner 0664 # NeatReceipts Scanalizer Professional 2.5 | Plustek OpticSlim M12 0x07b3 0x0412 root:scanner 0664 # Plustek OpticSlim 1200 0x07b3 0x0413 root:scanner 0664 # Plustek OpticSlim 2400 0x07b3 0x0422 root:scanner 0664 # Plustek OpticSlim 2400 plus 0x07b3 0x0454 root:scanner 0664 # Plustek Iriscan Express 2 0x07b3 0x045f root:scanner 0664 # NeatReceipts Mobile Scanner 0x07b3 0x0462 root:scanner 0664 # Plustek OpticBook 3600 0x07b3 0x0900 root:scanner 0664 # Corex 600c 0x08f0 0x0002 root:scanner 0664 # Corex 800c 0x08f0 0x0005 root:scanner 0664 # Xerox Phaser 6110MFP 0x0924 0x3d5d root:scanner 0664 # Xerox Phaser 3200MFP 0x0924 0x3da4 root:scanner 0664 # Xerox WorkCentre 4118 Series 0x0924 0x420c root:scanner 0664 # Xerox WorkCentre 3119 Series 0x0924 0x4265 root:scanner 0664 # Xerox WorkCentre 3210 0x0924 0x4293 root:scanner 0664 # Xerox WorkCentre 3220 0x0924 0x4294 root:scanner 0664 # Pentax DSmobile 600 0x0a17 0x3210 root:scanner 0664 # Portable Peripheral Co., Ltd. Q-Scan USB001 (A4 portable scanner) 0x0a53 0x1000 root:scanner 0664 # Portable Peripheral Co., Ltd. Q-Scan USB201 (A6 portable scanner) 0x0a53 0x2000 root:scanner 0664 # Syscan TravelScan 460/464 | Ambir Visigo A4 0x0a82 0x4600 root:scanner 0664 # Syscan DocketPort 465 0x0a82 0x4802 root:scanner 0664 # Syscan DocketPort 665 0x0a82 0x4803 root:scanner 0664 # Syscan DocketPort 685/ Ambir DS685 0x0a82 0x480c root:scanner 0664 # Syscan DocketPort 485 0x0a82 0x4810 root:scanner 0664 # Syscan TravelScan 662 0x0a82 0x6620 root:scanner 0664 # Canon CR-55 0x1083 0x160c root:scanner 0664 # Canon DR-1210C 0x1083 0x160f root:scanner 0664 # Canon DR-4010C 0x1083 0x1614 root:scanner 0664 # Canon DR-2510C 0x1083 0x1617 root:scanner 0664 # Canon DR-X10C 0x1083 0x1618 root:scanner 0664 # Canon CR-25 0x1083 0x161a root:scanner 0664 # Canon DR-2010C 0x1083 0x161b root:scanner 0664 # Canon DR-3010C 0x1083 0x161d root:scanner 0664 # Canon DR-7090C 0x1083 0x1620 root:scanner 0664 # Canon DR-9050C 0x1083 0x1622 root:scanner 0664 # Canon DR-7550C 0x1083 0x1623 root:scanner 0664 # Canon DR-6050C 0x1083 0x1624 root:scanner 0664 # Canon DR-6010C 0x1083 0x1626 root:scanner 0664 # Canon CR-190i 0x1083 0x162b root:scanner 0664 # Canon DR-6030C 0x1083 0x1638 root:scanner 0664 # Canon CR-135i 0x1083 0x1639 root:scanner 0664 # Digital Dream l' espion XS 0x1183 0x0001 root:scanner 0664 # KONICA MINOLTA magicolor 1690MF 0x132b 0x2089 root:scanner 0664 # UMAX Astra 1220U 0x1606 0x0010 root:scanner 0664 # UMAX Astra 1600U | UMAX Astra 2000U 0x1606 0x0030 root:scanner 0664 # Umax UMAX 3400 0x1606 0x0050 root:scanner 0664 # Umax UMAX 3400 | Umax UMAX Astranet ia101 | Umax UMAX 3450 0x1606 0x0060 root:scanner 0664 # UMAX Astra 4400 | UMAX Astra 4450 0x1606 0x0070 root:scanner 0664 # UMAX Astra 2100U 0x1606 0x0130 root:scanner 0664 # Umax UMAX 5400 0x1606 0x0160 root:scanner 0664 # UMAX Astra 2200 (SU) 0x1606 0x0230 root:scanner 0664 # DCT DocketPort 487 0x1dcc 0x4810 root:scanner 0664 # Dell A920 0x413c 0x5105 root:scanner 0664 # Dell Dell MFP Laser Printer 1815dn 0x413c 0x5124 root:scanner 0664 # Dell 1600n 0x413c 0x5250 root:scanner 0664 sane-backends-1.0.29/testsuite/tools/data/testfile.desc0000666000000000000000000123462713615534521020001 00000000000000:backend "abaton" :version "unmaintained" :manpage "sane-abaton" ;:url "http://aix2.uottawa.ca/~s1204672/sane/" :devicetype :scanner :mfg "Abaton" ;:url "http://www.everex.com/" ;dead? :model "Scan 300/GS" :interface "SCSI" :status :complete :comment "All known modes and functions supported" :model "Scan 300/S" :interface "SCSI" :status :untested :comment "Untested, use with caution" :backend "agfafocus" :version "unmaintained" :manpage "sane-agfafocus" :devicetype :scanner :mfg "AGFA" :url "http://www.agfa.com/" :model "Focus GS Scanner" :interface "SCSI" :status :untested :comment "6 bit gray" :model "Focus Lineart Scanner" :interface "SCSI" :status :untested :comment "Lineart only? Untested." :model "Focus II" :interface "SCSI" :status :untested :comment "gray only" :model "Focus Color" :interface "SCSI" :status :good :comment "3-pass" :model "Focus Color Plus" :interface "SCSI" :status :good :comment "3-pass" :mfg "Siemens" :model "S9036" :interface "SCSI" :status :untested :comment "gray only" ;Apple backend .desc file by Milon Firikis. :backend "apple" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-apple" ; name of manpage (if it exists) ;:url "http://no.www.page.yet/" ; backend's web page :devicetype :scanner ; start of a list of devices.... :mfg "Apple" :url "http://developer.apple.com/" :model "Apple Scanner" :interface "SCSI" :status :good ; :alpha, :beta, :stable, :new :comment "4bit, 16 shades of gray" :model "OneScanner" :interface "SCSI" :comment "8bit, 256 shades of gray. The backend needs work especially in the quantization code but it may work." :status :basic ; :alpha, :beta, :stable, :new :model "Color OneScanner" :interface "SCSI" :status :minimal ; :alpha, :beta, :stable, :new :comment "truecolor (needs much work) but it scans in non color modes." ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "artec" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-artec" ; name of manpage (if it exists) :url "http://www4.infi.net/~cpinkham/sane/sane-artec-doc.html" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Artec/Ultima" ; name a manufacturer :url "http://www.artecusa.com/" ;; name models for above-specified mfg. :model "AT3" :interface "SCSI" :status :complete :comment "all modes working" :model "A6000C" :interface "SCSI" :status :complete :comment "all modes working" :model "A6000C PLUS" :interface "SCSI" :status :complete :comment "f/w <= v1.92 basic, f/w >= v1.93 OK" :model "AT6" :status :good :interface "SCSI" :comment "Scan head needs to return home before another scan can be started." :model "AT12" :interface "SCSI" :status :complete :comment "all modes working" :model "AM12S" :interface "SCSI" :status :complete :comment "all modes working" :mfg "BlackWidow" :url "http://www.blackwidow.co.uk/" :model "BW4800SP" :interface "SCSI" :status :complete :comment "rebadged Artec AT3" :mfg "Plustek" :url "http://www.plustek.com/" :model "OpticPro 19200S" :interface "SCSI" :status :complete :comment "rebadged Artec AM12S" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; :backend "artec_eplus48u" :version "unmaintained" :manpage "sane-artec_eplus48u" ;:url "http://www.angelfire.com/linux/crapsite/" :devicetype :scanner :mfg "Artec/Ultima" :url "http://www.artecusa.com/" :model "E+ 48U" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :comment "CIS scanner based on the GT6816 chip. Apparently all other devices are re-badged Artec scanners." :model "E+ Pro" :status :minimal :interface "USB" :usbid "0x05d8" "0x4004" :comment "Works up to 600dpi, but not 1200. Needs better calibration. See bug #310490" :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.com" :comment "Sold by Aldi and Tchibo." :model "MD9693" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :model "MD9705" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :model "MD4394" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :comment "Only scanners with product id 0x4003 will work; try the gt68xx backend, if your scanner has product id 0x4002 " :mfg "Trust" :url "http://www.trust-site.com" :model "Easy Webscan 19200" :status :good :interface "USB" :usbid "0x05d8" "0x4006" :model "240H Easy Webscan Gold" :status :basic :interface "USB" :usbid "0x05d8" "0x4007" :comment "Works up to 600 dpi" :mfg "Memorex" :url "http://www.artecusa.com/" :model "MEM 48U" :status :good :interface "USB" :usbid "0x05d8" "0x4005" :mfg "Microstar" :url "http://www.microstar.de/" :model "MR 9791" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :mfg "UMAX" :url "http://www.umax.com/" :url "http://www.umax.com.tw/" :url "http://www.umax.de/en" :url "http://www.umax-europe.com" :url "http://www.umaxjapan.co.jp" :url "http://www.umax.com.cn" :model "AstraSlim SE" :status :good :interface "USB" :usbid "0x05d8" "0x4009" :model "AstraSlim 1200 SE" :status :good :interface "USB" :usbid "0x05d8" "0x4010" :mfg "Yakumo" :url "http://www.yakumo.com/" :model "Scan50" :status :good :interface "USB" :usbid "0x05d8" "0x4011" ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "as6e" ; name of backend :version "0.5" ; version of backend :manpage "sane-as6e" ; name of manpage (if it exists) :url "http://as6edriver.sourceforge.net/" :devicetype :scanner :mfg "Artec/Ultima" ; name a manufacturer :url "http://www.artecusa.com/" :model "AS6E" :interface "Parport" :status :basic :comment "Requires the program 'as6edriver' to run." :mfg "Trust" ; name a manufacturer :url "http://www.trust-site.com" :comment "Carefully check the model names. Trust uses similar names for completely different hardware." :model "Easy Scan 9600 Plus" :interface "Parport" :status :basic :comment "Requires the program 'as6edriver' to run." :mfg "Dexxa" ; name a manufacturer :url "http://www.dexxa.com" :model "4800" :interface "Parport" :status :basic :comment "Requires the program 'as6edriver' to run." ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; SANE Backend specification file ; ; THIS FILE IS GENERATED FROM THE "avision.c" FILE AUTOMATICALLY - DO NOT EDIT ; THIS FILE MANUALLY !!! ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; name of backend :backend "avision" ; version of backend :version "Build: 296" ;status: alpha, beta, stable, new ;:status :stable ; backend's web page :url "http://skull.piratehaven.org/~mike/sane/avision.html" ; name of manpage (if it exists) :manpage "sane-avision" :devicetype :scanner :mfg "Avision" :url "http://www.avision.com" :model "AV100CS" :interface "SCSI" :status :untested :model "AV100IIICS" :interface "SCSI" :status :untested :model "AV100S" :interface "SCSI" :status :untested :model "AV120" :interface "USB" :usbid "0x0638" "0x0a27" :comment "sheetfed scanner" :status :complete :model "AV121" :interface "USB" :usbid "0x0638" "0x0a3c" :comment "sheetfed scanner" :status :good :model "AV122" :interface "USB" :usbid "0x0638" "0x0a33" :comment "sheetfed duplex scanner" :status :good :model "AV122 C2" :interface "USB" :usbid "0x0638" "0x0a93" :comment "sheetfed duplex scanner" :status :good :model "AV210" :interface "USB" :usbid "0x0638" "0x0a24" :comment "sheetfed scanner" :status :complete :model "AV210" :interface "USB" :usbid "0x0638" "0x0a25" :comment "sheetfed scanner" :status :complete :model "AV210C2" :interface "USB" :usbid "0x0638" "0x0a3a" :comment "sheetfed scanner" :status :complete :model "AV210C2-G" :interface "USB" :usbid "0x0638" "0x0a2f" :comment "sheetfed scanner" :status :complete :model "AV210D2+" :interface "USB" :usbid "0x0638" "0x1a35" :comment "sheetfed scanner" :status :complete :model "AV220" :interface "USB" :usbid "0x0638" "0x0a23" :comment "duplex! sheetfed scanner" :status :complete :model "AV220C2" :interface "USB" :usbid "0x0638" "0x0a2a" :comment "duplex! sheetfed scanner" :status :complete :model "AV220D2" :interface "USB" :usbid "0x0638" "0x0a2b" :comment "duplex! sheetfed scanner" :status :complete :model "AV220+" :interface "USB" :usbid "0x0638" "0x0a2c" :comment "duplex! sheetfed scanner" :status :complete :model "AV220C2-G" :interface "USB" :usbid "0x0638" "0x0a2d" :comment "duplex! sheetfed scanner" :status :complete :model "AV220C2-B" :interface "USB" :usbid "0x0638" "0x0a2e" :comment "duplex! sheetfed scanner" :status :complete :model "AV220-G" :interface "USB" :usbid "0x0638" "0x0a94" :comment "duplex! sheetfed scanner" :status :complete :model "AV240SC" :interface "SCSI" :status :untested :model "AV260CS" :interface "SCSI" :status :untested :model "AV360CS" :interface "SCSI" :status :untested :model "AV363CS" :interface "SCSI" :status :untested :model "AV420CS" :interface "SCSI" :status :untested :model "AV6120" :interface "SCSI" :status :untested :model "AV610" :interface "USB" :usbid "0x0638" "0x0a18" :status :good :model "AV600U Plus" :interface "USB" :usbid "0x0638" "0x0a18" :status :good :model "AV610C2" :interface "USB" :usbid "0x0638" "0x0a5e" :status :good :model "AM3000 Series" :interface "USB" :usbid "0x0638" "0x0a41" :comment "MFD" :status :basic :model "DS610CU Scancopier" :interface "USB" :usbid "0x0638" "0x0a16" :comment "1 pass, 600 dpi, A4" :status :good :model "AV620CS" :interface "SCSI" :comment "1 pass, 600 dpi" :status :complete :model "AV620CS Plus" :interface "SCSI" :comment "1 pass, 1200 dpi" :status :complete :model "AV630CS" :interface "SCSI" :comment "1 pass, 1200 dpi" :status :complete :model "AV630CSL" :interface "SCSI" :comment "1 pass, 1200 dpi" :status :untested :model "AV6240" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV600U" :interface "USB" :usbid "0x0638" "0x0a13" :comment "1 pass, 600 dpi" :status :good :model "AV660S" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV680S" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV690U" :interface "SCSI" :comment "1 pass, 2400 dpi" :status :untested :model "AV800S" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV810C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV820" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV820C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV820C Plus" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV830C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV830C Plus" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV880" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV880C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV3200C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV3200SU" :interface "USB" :usbid "0x0638" "0x0a4e" :comment "1 pass, ??? dpi" :status :complete :model "AV3730SU" :interface "USB" :usbid "0x0638" "0x0a4f" :comment "1 pass, ??? dpi" :status :complete :model "AV3750SU" :interface "USB" :usbid "0x0638" "0x0a65" :comment "1 pass, ??? dpi" :status :complete :model "AV3800C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV3850SU" :interface "USB" :usbid "0x0638" "0x0a66" :comment "1 pass, ??? dpi" :status :complete :model "FB6000E" :interface "SCSI" :comment "1 pass, 1200 dpi, A3 - duplex! - zero edge!" :status :complete :model "FB6080E" :interface "USB" :usbid "0x0638" "0x0a82" :comment "1 pass, 1200 dpi, A3 - duplex! - zero edge!" :status :complete :model "FB2080E" :interface "USB" :usbid "0x0638" "0x0a84" :comment "1 pass, 600 dpi, zero-edge" ASIC 7 :status :basic :model "AV8000S" :interface "SCSI" :comment "1 pass, 1200 dpi, A3" :status :complete :model "AV8050U" :interface "USB" :usbid "0x0638" "0x0a4d" :comment "1 pass, 1200 dpi, A3 - duplex!" :status :complete :model "AV8300" :interface "USB" :usbid "0x0638" "0x0a40" :comment "1 pass, 1200 dpi, A3 - duplex!" :status :complete :model "AV8350" :interface "USB" :usbid "0x0638" "0x0a68" :comment "1 pass, 1200 dpi, A3 - duplex!" :status :complete :model "IT8300" :interface "USB" :usbid "0x0638" "0x0a61" :comment "1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors" :status :good :model "@V2500" :interface "USB" :usbid "0x0638" "0x0aa1" :status :untested :model "@V5100" :interface "USB" :usbid "0x0638" "0x0a45" :comment "1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors" :status :good :model "AVA3" :interface "SCSI" :comment "1 pass, 600 dpi, A3" :status :basic :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "ScanJet 5300C" :interface "USB" :usbid "0x03f0" "0x0701" :comment "1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi" :status :complete :model "ScanJet 5370C" :interface "USB" :usbid "0x03f0" "0x0701" :comment "1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi" :status :good :model "ScanJet 7400c" :interface "USB" :usbid "0x03f0" "0x0801" :comment "1 pass, 2400 dpi - dual USB/SCSI interface" :status :good :model "ScanJet 7450c" :interface "USB" :usbid "0x03f0" "0x0801" :comment "1 pass, 2400 dpi - dual USB/SCSI interface" :status :good :model "ScanJet 7490c" :interface "USB" :usbid "0x03f0" "0x0801" :comment "1 pass, 1200 dpi - dual USB/SCSI interface" :status :good :model "ScanJet 8200" :interface "USB" :usbid "0x03f0" "0x0b01" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8250" :interface "USB" :usbid "0x03f0" "0x0b01" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8270" :interface "USB" :usbid "0x03f0" "0x3905" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8290" :interface "USB" :usbid "0x03f0" "0x0b01" :comment "1 pass, 4800 (?) dpi - USB 2.0 and SCSI - only SCSI tested so far" :status :good :model "ScanJet 8300" :interface "USB" :usbid "0x03f0" "0x3805" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8350" :interface "USB" :usbid "0x03f0" "0x3805" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8390" :interface "USB" :usbid "0x03f0" "0x3805" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :mfg "Minolta" :url "http://www.minolta.com" :model "Dimage Scan Dual I" :interface "SCSI" :status :basic :model "Scan Multi Pro" :interface "SCSI" :status :untested :model "Dimage Scan Dual II" :interface "USB" :usbid "0x0638" "0x026a" :comment "1 pass, film-scanner" :status :good :model "Elite II" :interface "USB" :usbid "0x0686" "0x4004" :comment "1 pass, film-scanner" :status :untested :model "Dimage Scan Dual III" :interface "USB" :usbid "0x0686" "0x400d" :comment "1 pass, film-scanner" :status :good :model "Dimage Scan Elite 5400" :interface "USB" :usbid "0x0686" "0x400e" :comment "1 pass, film-scanner" :status :good :mfg "Minolta-QMS" :model "SC-110" :interface "USB" :usbid "0x0638" "0x0a15" :status :untested :model "SC-215" :interface "USB" :usbid "0x0638" "0x0a16" :status :good :mfg "Mitsubishi" :model "MCA-ADFC" :interface "SCSI" :status :untested :model "S1200C" :interface "SCSI" :status :untested :model "S600C" :interface "SCSI" :status :untested :model "SS600" :interface "SCSI" :status :good :mfg "Fujitsu" :url "http://www.fujitsu.com" :model "ScanPartner" :interface "SCSI" :status :untested :model "ScanPartner 10" :interface "SCSI" :status :untested :model "ScanPartner 10C" :interface "SCSI" :status :untested :model "ScanPartner 15C" :interface "SCSI" :status :untested :model "ScanPartner 300C" :interface "SCSI" :status :untested :model "ScanPartner 600C" :interface "SCSI" :status :untested :model "ScanPartner 620C" :interface "SCSI" :status :good :model "ScanPartner Jr" :interface "SCSI" :status :untested :model "ScanStation" :interface "SCSI" :status :untested :model "fi-4010CU" :interface "USB" :usbid "0x04c5" "0x1029" :status :untested :model "fi-5015C" :interface "USB" :usbid "0x04c5" "0x10ef" :status :good :mfg "Kodak" :url "http://www.kodak.com" :model "i30" :interface "USB" :usbid "0x040a" "0x6001" :status :untested :model "i40" :interface "USB" :usbid "0x040a" "0x6002" :status :basic :model "i50" :interface "USB" :usbid "0x040a" "0x6003" :status :untested :model "i55" :interface "USB" :usbid "0x040a" "0x6003" :status :untested :model "i60" :interface "USB" :usbid "0x040a" "0x6004" :status :untested :model "i65" :interface "USB" :usbid "0x040a" "0x6004" :status :untested :model "i80" :interface "USB" :usbid "0x040a" "0x6005" :status :good :mfg "iVina" :model "1200U" :interface "USB" :usbid "0x0638" "0x0268" :status :untested :mfg "Visioneer" :model "Strobe XP 450" :interface "USB" :usbid "0x04a7" "0x0424" :comment "sheetfed scanner" :status :complete :model "Strobe XP 450-G" :interface "USB" :usbid "0x04a7" "0x0491" :comment "sheetfed scanner" :status :complete :model "Strobe XP 470" :interface "USB" :usbid "0x04a7" "0x0479" :comment "sheetfed scanner" :status :complete :model "Strobe XP 470-G" :interface "USB" :usbid "0x04a7" "0x048f" :comment "sheetfed scanner" :status :complete :model "9320" :interface "USB" :usbid "0x04a7" "0x0420" :comment "sheetfed scanner" :status :complete :model "9450" :interface "USB" :usbid "0x04a7" "0x0421" :comment "sheetfed scanner" :status :complete :model "9450-G" :interface "USB" :usbid "0x04a7" "0x047a" :comment "sheetfed scanner" :status :complete :model "9550" :interface "USB" :usbid "0x04a7" "0x0422" :comment "sheetfed scanner" :status :complete :model "9650" :interface "USB" :usbid "0x04a7" "0x0390" :comment "sheetfed scanner" :status :complete :model "9650-G" :interface "USB" :usbid "0x04a7" "0x047b" :comment "sheetfed scanner" :status :complete :model "9750" :interface "USB" :usbid "0x04a7" "0x0423" :comment "sheetfed scanner" :status :complete :model "9750-G" :interface "USB" :usbid "0x04a7" "0x0493" :comment "sheetfed scanner" :status :complete :model "Patriot 430" :interface "USB" :usbid "0x04a7" "0x0497" :comment "sheetfed scanner" :status :complete :model "Patriot 470" :interface "USB" :usbid "0x04a7" "0x048f" :comment "sheetfed scanner" :status :complete :model "Patriot 680" :interface "USB" :usbid "0x04a7" "0x0498" :comment "sheetfed scanner" :status :complete :model "Patriot 780" :interface "USB" :usbid "0x04a7" "0x0499" :comment "sheetfed scanner" :status :complete :mfg "Xerox" :model "DocuMate150" :interface "USB" :usbid "0x04a7" "0x049c" :status :good :model "DocuMate152" :interface "USB" :usbid "0x04a7" "0x0477" :status :good :model "DocuMate162" :interface "USB" :usbid "0x04a7" "0x049d" :status :good :model "DocuMate250" :interface "USB" :usbid "0x04a7" "0x0448" :status :good :model "DocuMate250-G" :interface "USB" :usbid "0x04a7" "0x0490" :status :good :model "DocuMate252" :interface "USB" :usbid "0x04a7" "0x0449" :status :good :model "DocuMate252-G" :interface "USB" :usbid "0x04a7" "0x048c" :status :good :model "DocuMate232" :interface "USB" :usbid "0x04a7" "0x0476" :status :good :model "DocuMate262" :interface "USB" :usbid "0x04a7" "0x044c" :status :good :model "DocuMate262-G" :interface "USB" :usbid "0x04a7" "0x048d" :status :good :model "DocuMate262i" :interface "USB" :usbid "0x04a7" "0x04a7" :status :good :model "DocuMate272" :interface "USB" :usbid "0x04a7" "0x0475" :status :untested :model "DocuMate272-G" :interface "USB" :usbid "0x04a7" "0x048e" :status :untested :model "DocuMate510" :interface "USB" :usbid "0x04a7" "0x0446" :status :untested :model "DocuMate512" :interface "USB" :usbid "0x04a7" "0x0495" :status :untested :model "DocuMate510-G" :interface "USB" :usbid "0x04a7" "0x047c" :status :untested :model "DocuMate520" :interface "USB" :usbid "0x04a7" "0x0447" :status :untested :model "DocuMate520-G" :interface "USB" :usbid "0x04a7" "0x0492" :status :untested :model "DocuMate632" :interface "USB" :usbid "0x04a7" "0x0498" :status :untested :model "DocuMate752" :interface "USB" :usbid "0x04a7" "0x0478" :status :untested :model "DocuMate752" :interface "USB" :usbid "0x04a7" "0x049a" :status :untested :mfg "OKI" :model "S700 Scancopier" :interface "USB" :usbid "0x0638" "0x0a16" :comment "1 pass, 600 dpi, A4" :status :good :mfg "Bell+Howell" :model "2000F" :interface "SCSI" :comment "1 pass, ??? dpi, A4" :status :basic :mfg "Kyocera" :model "FS-1016MFP" :interface "USB" :usbid "0x0482" "0x0335" :comment "1 pass, ??? dpi, A4" :status :untested ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "bh" ; name of backend :version "1.0-4" ; version of backend :manpage "sane-bh" ; name of manpage (if it exists) :url "http://www.martoneconsulting.com/sane-bh.html" ; backend's web page :comment "Supports Copiscan II scanners with Remote SCSI Controller (RSC) interface" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Bell and Howell" ; name a manufacturer :url "http://www.bhscanners.com/" :model "COPISCAN II 6338" :interface "SCSI" :status :good :comment "Duplex Scanner with ACE - development model" :model "COPISCAN II 2135" :status :untested :interface "SCSI" :comment "Simplex Scanner" :model "COPISCAN II 2137(A)" :interface "SCSI" :status :good :comment "Simplex Scanner (with ACE) - limited testing" :model "COPISCAN II 2138A" :status :untested :interface "SCSI" :comment "Simplex Scanner with ACE" :model "COPISCAN II 3238" :status :untested :interface "SCSI" :comment "Simplex Scanner" :model "COPISCAN II 3338(A)" :status :untested :interface "SCSI" :comment "Simplex Scanner (with ACE)" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon630u" ; name of backend :manpage "sane-canon630u" :version "0.1" ; version of backend ;:status :beta :url "http://canon-fb630u.sourceforge.net/" ; backend home page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" :model "CanoScan fb630u" ; name models for above-specified mfg. :interface "USB" :usbid "0x04a9" "0x2204" :comment "OK" :status :good :model "CanoScan fb636u" ; name models for above-specified mfg. :interface "USB" :usbid "0x04a9" "0x2204" :status :good :comment "OK" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon" ; name of backend :manpage "sane-canon" :version "1.12" ; version of backend ;:status :good ; :alpha, :beta, :stable, :new :url "http://www.rzg.mpg.de/~mpd/sane/" ; backend home page :devicetype :scanner :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" :model "CanoScan 300" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :model "CanoScan 600" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :model "CanoScan 620S" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :model "CanoScan 1200S" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :model "CanoScan 2700F" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; film scanner" :status :good :model "CanoScan 2710S" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; 36bit film scanner" :status :good :model "IX-4015" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :mfg "Apple" ; name a manufacturer :url "http://www.apple.com/" :model "Color OneScanner 600/27" ; name models for above-specified mfg. :interface "SCSI" :comment "Rebadged CanoScan 300" :status :good ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon_dr" ; name of backend :url "http://www.thebility.com/canon/" :version "38" ; version of backend :manpage "sane-canon_dr" ; name of manpage (if it exists) :comment "Backend updated for SANE release 1.0.23, see sane-canon_dr manpage" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" ;================================================== :model "CR-25" :interface "USB" :usbid "0x1083" "0x161a" :status :untested :comment "Please test!" :model "CR-55" :interface "USB" :usbid "0x1083" "0x160c" :status :untested :comment "Please test!" :model "CR-135i" :interface "USB SCSI" :usbid "0x1083" "0x1639" :status :untested :comment "Please test!" :model "CR-180" :interface "USB SCSI" :usbid "0x04a9" "0x1602" :status :untested :comment "Please test!" :model "CR-180II" :interface "USB SCSI" :usbid "0x04a9" "0x1602" :status :untested :comment "Same as CR-180? Please test!" :model "CR-190i" :interface "USB SCSI" :usbid "0x1083" "0x162b" :status :untested :comment "Please test!" :model "DR-1210C" :interface "USB" :usbid "0x04a9" "0x2222" :status :untested :comment "Older version? Please test!" :model "DR-1210C" :interface "USB" :usbid "0x1083" "0x160f" :status :untested :comment "Later version? Please test!" :model "DR-2010C" :interface "USB" :usbid "0x1083" "0x161b" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions." :model "DR-2010M" :interface "USB" :status :untested :comment "Mac version of DR-2010C? Please test!" :model "DR-2050C" :interface "USB" :usbid "0x04a9" "0x160a" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration." :model "DR-2050SP" :interface "USB" :usbid "0x04a9" "0x160a" :status :untested :comment "Same as DR-2050C? Please test!" :model "DR-2080C" :interface "USB SCSI" :usbid "0x04a9" "0x1601" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration" :model "DR-2510C" :interface "USB" :usbid "0x1083" "0x1617" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions" :model "DR-2510M" :interface "USB" :status :untested :comment "Mac version of DR-2510C? Please test!" :model "DR-2580C" :interface "USB SCSI" :usbid "0x04a9" "0x1608" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration" :model "DR-3010C" :interface "USB" :usbid "0x1083" "0x161d" :status :good :comment "Minimal testing, settings copied from DR-2510C" :model "DR3020" :interface "SCSI" :status :untested :comment "Please test!" :model "DR-3020C" :interface "SCSI" :status :untested :comment "Please test!" :model "DR-3060" :interface "SCSI" :status :untested :comment "Please test!" :model "DR-3080C" :interface "SCSI" :status :untested :comment "Almost works, need to investigate traces from windows driver" :model "DR-3080CII" :interface "USB SCSI" :usbid "0x04a9" "0x1609" :status :untested :comment "Almost works, need to investigate traces from windows driver" :model "DR-4010C" :interface "USB" :usbid "0x1083" "0x1614" :status :good :comment "Binary/HT/Gray/Color, Simplex/Duplex working. Multistream unsupported." :model "DR4080U" :interface "USB" ;:usbid "0x1083" "0x1614" :status :untested :comment "Please test!" :model "DR-4580U" :interface "USB" ;:usbid "0x1083" "0x1614" :status :untested :comment "Please test!" :model "DR-5010C" :interface "USB" :usbid "0x04a9" "0x1606" :status :untested :comment "Please test!" :model "DR-5020" :interface "SCSI" :status :good :comment "LineArt, Duplex working, cannot read buttons or screen?" :model "DR-5060F" :interface "SCSI" :status :basic :comment "Grayscale works, LineArt might" :model "DR-5080C" :interface "SCSI" :status :untested :comment "Please test!" :model "DR-6010C" :interface "USB SCSI" :usbid "0x1083" "0x1626" :status :untested :comment "Please test!" :model "DR-6030C" :interface "USB SCSI" :usbid "0x1083" "0x1638" :status :untested :comment "Please test!" :model "DR-6050C" :interface "USB SCSI" :usbid "0x1083" "0x1624" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode" :model "DR-6080" :interface "USB SCSI" :usbid "0x04a9" "0x1607" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported" :model "DR-7080C" :interface "USB SCSI" :usbid "0x04a9" "0x1604" :status :untested :comment "Please test!" :model "DR-7090C" :interface "USB SCSI" :usbid "0x1083" "0x1620" :status :good :comment "ADF and flatbed work" :model "DR-7550C" :interface "USB SCSI" :usbid "0x1083" "0x1623" :status :untested :comment "Assumed compatible with DR-6050C" :model "DR-7580" :interface "USB SCSI" :usbid "0x04a9" "0x160b" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported" :model "DR-9050C" :interface "USB SCSI" :usbid "0x1083" "0x1622" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode" :model "DR-9080C" :interface "USB SCSI" :usbid "0x04a9" "0x1603" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray/color, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported" :model "DR-X10C" :interface "USB SCSI" :usbid "0x1083" "0x1618" :status :untested :comment "Please test!" ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon_pp" ; name of backend :manpage "sane-canon_pp" :version "0.33" ; version of backend :url "http://canon-fb330p.sourceforge.net" ; backend home page :devicetype :scanner :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" :model "CanoScan FB310P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :unsupported :comment "Rebadged Avision, different command set" :model "CanoScan FB610P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :unsupported :comment "Rebadged Avision, different command set" :model "CanoScan FB320P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :basic :comment "Newly added support" :model "CanoScan FB620P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :basic :comment "Newly added support" :model "CanoScan FB330P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :model "CanoScan FB630P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :model "CanoScan N340P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :model "CanoScan N640P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :model "CanoScan N640P ex" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :comment "Just an N640P in a different box?" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "cardscan" ; name of backend :url "http://www.thebility.com/cardscan/" :version "2" ; version of backend :manpage "sane-cardscan" ; name of manpage (if it exists) :comment "Backend updated for SANE release 1.0.21, see sane-cardscan manpage" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Corex" ; name a manufacturer :url "http://www.cardscan.com/" :model "800c" :interface "USB" :usbid "0x08f0" "0x0005" :status :good :comment "4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner" :model "600c" :interface "USB" :usbid "0x08f0" "0x0002" :status :basic :comment "4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner" ; ; SANE Backend specification file for coolscan2 ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "coolscan2" :version "0.1.8" :manpage "sane-coolscan2" :url "http://coolscan2.sourceforge.net/" :devicetype :scanner :mfg "Nikon" :url "http://www.nikon.com/" :model "LS 30" :interface "SCSI" :comment "working -- model available to developer" :status :complete :model "LS 2000" :interface "SCSI" :status :good :model "LS 40 ED" :interface "USB" :usbid "0x04b0" "0x4000" :status :complete :model "LS 4000 ED" :interface "IEEE-1394" :status :good :comment "needs linux kernel 2.4.19 or later" :model "LS 50 ED" ;:url "unsupported/nikon-ls50-ed.html" :interface "USB" :usbid "0x04b0" "0x4001" :status :minimal :model "Coolscan V ED" :url "unsupported/nikon-ls50-ed.html" :interface "USB" :usbid "0x04b0" "0x4001" :status :minimal :model "Super Coolscan LS-5000 ED" :url "unsupported/nikon-ls5000-ed.html" :interface "USB" :usbid "0x04b0" "0x4002" :status :untested :comment "May work, similar to LS 50 ED, but untested. Please tell us if it works." :model "LS 8000 ED" :interface "IEEE-1394" :status :good :comment "needs linux kernel 2.4.19 or later" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file for coolscan2 ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "coolscan3" :version "1.0.0" :manpage "sane-coolscan3" :devicetype :scanner :mfg "Nikon" :url "http://www.nikon.com/" :model "LS 30" :interface "SCSI" :status :complete :model "Coolscan III" :interface "SCSI" :status :complete :comment "Rebadged LS 30?" :model "LS 40 ED" :interface "USB" :usbid "0x04b0" "0x4000" :status :complete :model "Coolspan IV" :interface "USB" :usbid "0x04b0" "0x4000" :status :complete :comment "Rebadged LS 40?" :model "LS 50 ED" :url "unsupported/nikon-ls50-ed.html" :interface "USB" :usbid "0x04b0" "0x4001" :status :minimal :model "Coolscan V ED" :url "unsupported/nikon-ls50-ed.html" :interface "USB" :usbid "0x04b0" "0x4001" :status :minimal :comment "Rebadged LS 50?" :model "LS 2000" :interface "SCSI" :status :good :model "LS 4000 ED" :interface "IEEE-1394" :status :good :comment "needs linux kernel 2.4.19 or later" :model "Super Coolscan LS-5000 ED" :url "unsupported/nikon-ls5000-ed.html" :interface "USB" :usbid "0x04b0" "0x4002" :status :untested :comment "May work, similar to LS 50 ED, but untested. Please tell us if it works." :model "LS 8000 ED" :interface "IEEE-1394" :status :good :comment "needs linux kernel 2.4.19 or later" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "coolscan" ; name of backend :version "0.4.3" ; version of backend :url "http://andreas.rick.free.fr/sane/" ; backend's web page :manpage "sane-coolscan" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Nikon" ; name a manufacturer :url "http://www.nikon.com/" :model "LS-20" ; name models for above-specified mfg. :interface "SCSI" :comment "The LS-20 has been replaced by the LS-30" :status :basic :model "LS-30" ; name models for above-specified mfg. :interface "SCSI" :comment "alpha: only 24/30 bit RGB + 32/40 bit RGBI" :status :basic :model "LS-2000" ; name models for above-specified mfg. :interface "SCSI" :comment "alpha: only 24/36 bit + RGB 32/48 bit RGBI" :status :basic :model "LS-1000" :interface "SCSI" :comment "Doesn't support gamma correction" :status :basic ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ;Kodak DC210 backend .desc file by Brian J. Murrell :backend "dc210" ; name of backend :version "0.0" ; version of backend :manpage "sane-dc210" ; name of manpage (if it exists) :url "mailto:peter@fales-lorenz.net" ; backend's web page :devicetype :stillcam ; start of a list of devices.... :mfg "Kodak" :url "http://www.kodak.com/global/en/service/digCam/dc210/dc210.shtml" :model "DC210" :interface "Serial port" :status :basic ;Kodak DC240 backend .desc file by Peter S. Fales :backend "dc240" ; name of backend :version "0.0" ; version of backend :manpage "sane-dc240" ; name of manpage (if it exists) :url "mailto:peter@fales-lorenz.net" ; backend's web page :devicetype :stillcam ; start of a list of devices.... :mfg "Kodak" :url "http://www.kodak.com/global/en/service/products/ekn006568.jhtml" :model "DC240" :status :good ; minimal, basic, good, complete :interface "Serial port" :comment "Use gphoto2 backend to get USB support" ;Kodak DC25 backend .desc file by Peter Fales :backend "dc25" ; name of backend :version "1.2" ; version of backend :manpage "sane-dc25" ; name of manpage (if it exists) :url "mailto:peter@fales-lorenz.net"; :devicetype :stillcam ; start of a list of devices.... :mfg "Kodak" ; Manufacturer :url "http://www.kodak.com/global/en/service/digCam/dc25/dc25.shtml"; :model "DC25" ; :status :complete ; untested, minimal, basic, complete :interface "Serial port" :model "DC20" ; :status :basic ; untested, minimal, basic, complete :interface "Serial port" :comment "DC-20 untested by author but reported to work" ; ; dell1600n_net backend ; Jon Chambers , 2006-05-29 ; :backend "dell1600n_net" :devicetype :scanner :mfg "Dell" :url "http://www.dell.com/" :model "1600n" :interface "Ethernet USB" :usbid "0x413c" "0x5250" :status :basic :comment "Supports colour and monochrome scans over ethernet (USB not supported)" :backend "dll" ; name of backend :version "1.0.13" :manpage "sane-dll" :url "mailto:henning@meier-geinitz.de" :devicetype :meta :desc "Dynamic loading of shared-library backends." ; $Id$ ; ; SANE Backend specification file (Matto Marjanovic's format) ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "dmc" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-dmc" ; name of manpage (if it exists) :devicetype :stillcam ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Polaroid" ; name a manufacturer :url "http://www.polaroid.com/" :model "DMC" ; name models for above-specified mfg. :interface "SCSI" ;:url "http://digitalimage.polaroid.com/products/digital_imaging/digital_cameras/dmcsuite/dmc/" :status :good ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "epjitsu" ; name of backend :url "http://www.thebility.com/epjitsu/" :version "20" ; version of backend :manpage "sane-epjitsu" ; name of manpage (if it exists) :comment "Backend updated for SANE release 1.0.21, see sane-epjitsu manpage" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Fujitsu" ; name a manufacturer :url "http://www.fujitsu.com/" ;================================================== :model "fi-60F" :interface "USB" :status :basic :usbid "0x04c5" "0x10c7" :comment "A6-size flatbed, 300/600 dpi, color/gray/binary" :model "ScanSnap S300" :interface "USB" :status :good :usbid "0x04c5" "0x1156" :comment "Duplex, 150/225/300/600 dpi, color/gray/binary, AC/USB power, buttons/sensors all supported. Scanner always scans in _triplex_ color, fast USB required." :model "ScanSnap S300M" :interface "USB" :status :good :usbid "0x04c5" "0x117f" :comment "Same as S300, with different usb id" :model "ScanSnap S1100" :interface "USB" :status :unsupported :usbid "0x04c5" "0x1200" :comment "Beta version of backend source available, which works well, but breaks support for other epjitsu scanners. See http://ubuntuforums.org/showthread.php?t=1678335" :model "ScanSnap S1300" :interface "USB" :status :good :usbid "0x04c5" "0x11ed" :comment "Same as S300, with different usb id" ; ; SANE Backend specification file for the epson2 backend ; ; Copyright (C) 2009-10 Alessandro Zummo ; Released under GPLv2 ; ; This file is derived from epkowa.desc, Copyright (C) Olaf Meeuwissen, ; distributed with "Image Scan!" and released under GPL. ; ; DO NOT EDIT - It's automatically generated. :backend "epson2" :version "1.0.124" :new :no :manpage "sane-epson2" :devicetype :scanner :mfg "Epson" :url "http://www.epson.com/" :model "Actionscanner II" :interface "parallel SCSI" :status :good :comment "overseas version of the GT-5000" :url "http://www.epson.com/" :model "AcuLaser CX11" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :comment "overseas version of the LP-A500" :model "AcuLaser CX11NF" :interface "USB Network" :usbid "0x04b8" "0x0815" :status :good :comment "network interface supported
AcuLaser CX11 with network interface and fax" :model "AcuLaser CX21" :interface "USB" :usbid "0x04b8" "0x0835" :status :good :comment "network interface probably supported" :model "Artisan 700" :interface "USB Network" :usbid "0x04b8" "0x0846" :status :good :comment "network interface supported
all-in-one
overseas version of the EP-801A" :model "Artisan 710 Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Artisan 800" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one
overseas version of the EP-901A" :model "Artisan 810 Series" :interface "USB" :usbid "0x04b8" "0x0853" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "CC-500L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010d" :status :unsupported :comment "all-in-one" :model "CC-550L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011a" :status :unsupported :comment "all-in-one" :model "CC-570L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one" :model "CC-600PX" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one" :model "CC-700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0108" :status :unsupported :comment "all-in-one" :model "EP-702A" :interface "USB" :usbid "0x04b8" "0x0850" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "EP-801A" :interface "USB Network" :usbid "0x04b8" "0x0846" :status :good :comment "network interface supported
all-in-one" :model "EP-802A" :interface "USB" :usbid "0x04b8" "0x0852" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "EP-901A" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one" :model "EP-901F" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one" :model "EP-902A" :interface "USB" :usbid "0x04b8" "0x0853" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "ES-300C" :interface "SCSI parallel" :status :good :comment "overseas version of the GT-6000" :model "ES-300GS" :interface "SCSI" :status :good :model "ES-600C" :interface "parallel" :status :good :comment "overseas version of the GT-5400" :model "ES-800C" :interface "SCSI" :status :good :comment "overseas version of the GT-8000" :model "ES-1000C" :status :unsupported :comment "overseas version of the GT-8500" :model "ES-1200C" :interface "parallel" :status :good :comment "overseas version of the GT-9000" :model "ES-2000" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0107" :status :complete :comment "IEEE1394 untested" :model "ES-2200" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010e" :status :complete :comment "IEEE1394 untested" :model "ES-6000" ; product spec (JP) :interface "SCSI" :status :good :model "ES-6000H" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-6000HS" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-7000H" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0126" :status :good :comment "network interface unsupported
IEEE1394 untested" :model "ES-8000" :interface "SCSI" :status :untested :model "ES-8500" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0109" :status :good :comment "IEEE1394 untested" :model "ES-9000H" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-10000G" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0129" :status :good :comment "network interface unsupported
IEEE1394 untested" :model "ES-D400" :interface "USB" :usbid "0x04b8" "0x0136" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "ES-H300" :interface "USB" :usbid "0x04b8" "0x012b" :status :good :comment "network interface probably supported" :model "ES-H7200" :interface "USB Ethernet" :usbid "0x04b8" "0x0138" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Expression 636" :interface "SCSI" :status :complete :comment "overseas version of the GT-9500" :model "Expression 800" ; command spec :interface "SCSI" :status :complete :comment "overseas version of the GT-9600" :model "Expression 836XL" ; command spec :interface "SCSI" :status :untested :comment "overseas version of the ES-8000" :model "Expression 1600" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0107" :status :complete :comment "IEEE1394 untested
overseas version of the ES-2000" :model "Expression 1640XL" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0109" :status :good :comment "IEEE1394 untested
overseas version of the ES-8500" :model "Expression 1680" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x010e" :status :complete :comment "IEEE1394 untested
overseas version of the ES-2200" :model "Expression 1680 Pro" :interface "SCSI USB" :status :untested :comment "IEEE1394 option" :model "Expression 1680XL Pro" :interface "SCSI USB" :status :untested :model "Expression 10000XL" ; command spec :interface "USB" :usbid "0x04b8" "0x0129" :status :good :comment "network interface probably supported
IEEE1394 untested
overseas version of the ES-10000G" :model "Expression 10000XL Graphic Arts" :interface "USB IEEE1394" :status :untested :comment "network interface probably supported" :model "Expression 10000XL Photo" :interface "USB IEEE1394" :status :untested :comment "network interface probably supported" :model "F-3200" ; product spec (JP) :interface "USB IEEE1394" :usbid "0x04b8" "0x080a" :status :unsupported :comment "Film scanner" :model "F-3200 Photo" :interface "USB IEEE1394" :status :unsupported :model "FilmScan 200" :interface "SCSI" :status :minimal :comment "will be supported" :model "GT-1500" :interface "USB" :usbid "0x04b8" "0x0133" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-2200" :interface "USB" :usbid "0x04b8" "0x0102" :status :unsupported :model "GT-2500" :interface "USB" :usbid "0x04b8" "0x012b" :status :good :comment "network interface probably supported
overseas version of the ES-H300" :model "GT-4000" :status :untested :model "GT-5000" :interface "parallel SCSI" :status :good :model "GT-5400" :interface "parallel" :status :good :model "GT-5500" :interface "SCSI" :status :good :model "GT-6000" :interface "SCSI Parport" :status :good :model "GT-6500" :interface "parallel" :status :good :comment "overseas version of the GT-5400" :model "GT-6600U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0103" :status :complete :model "GT-6700U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010c" :status :complete :model "GT-7000S" :interface "SCSI" :status :complete :model "GT-7000U" :interface "USB" :usbid "0x04b8" "0x0101" :status :complete :model "GT-7200U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-7300U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-7400U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0120" :status :unsupported :comment "supported by the snapscan backend" :model "GT-7600S" ; product spec (JP) :interface "SCSI" :status :complete :comment "SCSI version of the GT-7600U" :model "GT-7600U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "USB version of the GT-7600S" :model "GT-7600UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "GT-7600U with TPU option bundled" :model "GT-7700U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010b" :status :complete :model "GT-8000" :interface "SCSI" :status :good :model "GT-8200U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0110" :status :complete :model "GT-8200UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0110" :status :good :model "GT-8300UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011e" :status :complete :model "GT-8400UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :model "GT-8500" :status :untested :model "GT-8700" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :complete :model "GT-8700F" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :good :comment "GT-8700U with TPU option bundled" :model "GT-9000" :interface "parallel" :status :good :model "GT-9300UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011b" :status :complete :model "GT-9400UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0116" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-9500" :interface "SCSI" :status :complete :model "GT-9600" :interface "SCSI" :status :complete :model "GT-9700F" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0112" :status :complete :comment "IEEE1394 untested" :model "GT-9800F" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011c" :status :complete :comment "IEEE1394 untested" :model "GT-10000" :interface "SCSI" :status :good :comment "overseas version of the ES-6000" :model "GT-10000+" ; command spec :interface "SCSI" :scsi "EPSON" "SCANNER GT-10000" "processor" :status :good :comment "IEEE1394 untested
overseas version of the ES-6000H" :model "GT-12000" :interface "SCSI" :status :untested :comment "overseas version of the ES-8000" :model "GT-15000" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0126" :status :good :comment "IEEE1394 untested
overseas version of the ES-7000H" :model "GT-20000" :interface "USB Ethernet" :usbid "0x04b8" "0x0138" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-30000" ; command spec :interface "SCSI" :status :good :comment "IEEE1394 untested
overseas version of the ES-9000H" :model "GT-D1000" :interface "USB" :usbid "0x04b8" "0x0133" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F500" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0121" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F520" :interface "USB" :usbid "0x04b8" "0x0122" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F550" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0121" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F570" :interface "USB" :usbid "0x04b8" "0x0122" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F600" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0118" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F650" :interface "USB" :usbid "0x04b8" "0x012d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F670" :interface "USB" :usbid "0x04b8" "0x012e" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F700" :interface "USB" :usbid "0x04b8" "0x012f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-F720" :interface "USB" :usbid "0x04b8" "0x0131" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-S50" :interface "USB" :usbid "0x04b8" "0x0137" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "GT-S80" :interface "USB" :usbid "0x04b8" "0x0136" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "GT-S600" :interface "USB" :usbid "0x04b8" "0x012d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-S620" :interface "USB" :usbid "0x04b8" "0x0131" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-X700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0128" :status :complete :comment "IEEE1394 untested" :model "GT-X750" :interface "USB" :usbid "0x04b8" "0x0119" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-X770" :interface "USB" :usbid "0x04b8" "0x0130" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-X800" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x012a" :status :complete :comment "film area guide mode not supported
IEEE1394 untested" :model "GT-X820" :interface "USB" :usbid "0x04b8" "0x013a" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux/scan/DL1.do" :model "GT-X900" :interface "USB" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested" :model "GT-X970" :interface "USB" :usbid "0x04b8" "0x0135" :status :good :comment "IEEE1394 untested" :model "LP-7900CS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9000CCH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9000CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9000CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9500CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9500CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9500CH2" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9800CCH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9800CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9800CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-A500" :interface "USB Network" :usbid "0x04b8" "0x0815" :status :good :comment "network interface supported
business all-in-one" :model "LP-M5000" :interface "USB" :usbid "0x04b8" "0x0843" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M5500" :interface "USB" :usbid "0x04b8" "0x0817" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M5500F" :interface "USB" :usbid "0x04b8" "0x0817" :status :good :comment "network interface probably supported
business all-in-one
LP-M5500 with the fax option bundled" :model "LP-M5600" :interface "USB" :usbid "0x04b8" "0x0833" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M6000" :interface "USB" :usbid "0x04b8" "0x0834" :status :good :comment "network interface probably supported
business all-in-one" :model "ME 200" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "ME 300" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "ME OFFICE 510" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "ME Office 600F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "all-in-one" :model "ME OFFICE 650FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "ME Office 700FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "PM-A700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0814" :status :good :comment "all-in-one" :model "PM-A750" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one" :model "PM-A820" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one" :model "PM-A840" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one" :model "PM-A840S" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "network interface probably supported
all-in-one" :model "PM-A850" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0806" :status :good :comment "all-in-one" :model "PM-A870" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one" :model "PM-A890" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one" :model "PM-A900" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0810" :status :good :comment "all-in-one" :model "PM-A920" :interface "USB" :usbid "0x04b8" "0x082a" :status :good :comment "all-in-one" :model "PM-A940" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one" :model "PM-A950" :interface "USB" :usbid "0x04b8" "0x081d" :status :good :comment "all-in-one" :model "PM-A970" :interface "USB" :usbid "0x04b8" "0x0828" :status :good :comment "all-in-one" :model "PM-T960" :interface "USB" :usbid "0x04b8" "0x0836" :status :good :comment "all-in-one" :model "PM-T990" :interface "USB" :usbid "0x04b8" "0x0829" :status :good :comment "all-in-one
PM-A970 with network interface" :model "PX-401A" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one" :model "PX-402A" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one" :model "PX-501A" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface probably supported
all-in-one" :model "PX-502A" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one" :model "PX-601F" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported" :model "PX-A550" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one" :model "PX-A620" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one" :model "PX-A640" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one" :model "PX-A650" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one" :model "PX-A720" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one" :model "PX-A740" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one" :model "PX-FA700" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one" :model "Perfection 600" :interface "SCSI" :status :unsupported :comment "supported by the umax backend
rebadged UMAX Astra 1200S" :model "Perfection 610" ; command spec :interface "USB" :usbid "0x04b8" "0x0103" :status :complete :comment "overseas version of the GT-6600U" :model "Perfection 636S" :interface "SCSI" :status :complete :comment "overseas version of the GT-7000S" :model "Perfection 636U" ; command spec :interface "USB" :usbid "0x04b8" "0x0101" :status :complete :comment "overseas version of the GT-7000U" :model "Perfection 640U" ; command spec :interface "USB" :usbid "0x04b8" "0x010c" :status :complete :comment "overseas version of the GT-6700U" :model "Perfection 660" :interface "USB" :usbid "0x04b8" "0x0114" :status :unsupported :comment "supported by the snapscan backend" :model "Perfection 1200S" ; command spec :interface "SCSI" :status :complete :comment "overseas version of the GT-7600S" :model "Perfection 1200U" ; command spec :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "overseas version of the GT-7600U" :model "Perfection 1200U PHOTO" :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "Perfection 1200U with TPU option bundled
overseas version of the GT-7600UF" :model "Perfection 1240U" ; command spec :interface "USB" :usbid "0x04b8" "0x010b" :status :complete :comment "overseas version of the GT-7700U" :model "Perfection 1250" :interface "USB" :usbid "0x04b8" "0x010f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 1250 PHOTO" :interface "USB" :usbid "0x04b8" "0x010f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 1260" :interface "USB" :usbid "0x04b8" "0x011d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 1260 PHOTO" :interface "USB" :usbid "0x04b8" "0x011d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 1270" :interface "USB" :usbid "0x04b8" "0x0120" :status :unsupported :comment "supported by the snapscan backend
overseas version of the GT-7400" :model "Perfection 1600" :interface "SCSI" :status :unsupported :model "Perfection 1640SU" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :complete :comment "overseas version of the GT-8700" :model "Perfection 1640SU PHOTO" :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :good :comment "overseas version of the GT-8700F" :model "Perfection 1650" ; command spec :interface "USB" :usbid "0x04b8" "0x0110" :status :complete :comment "overseas version of the GT-8200U" :model "Perfection 1650 PHOTO" :interface "USB" :usbid "0x04b8" "0x0110" :status :good :comment "overseas version of the GT-8200UF" :model "Perfection 1660 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x011e" :status :complete :comment "overseas version of the GT-8300UF" :model "Perfection 1670" :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :comment "supported by the snapscan backend" :model "Perfection 1670 PHOTO" :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :comment "supported by the snapscan backend
overseas version of the GT-8400UF" :model "Perfection 2400 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x011b" :status :complete :comment "overseas version of the GT-9300UF" :model "Perfection 2450 PHOTO" ; command spec :interface "USB IEEE-1394" :usbid "0x04b8" "0x0112" :scsi "EPSON" "GT-9700" "processor" :status :complete :comment "overseas version of the GT-9700F" :model "Perfection 2480 PHOTO" :interface "USB" :usbid "0x04b8" "0x0121" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 2580 PHOTO" :interface "USB" :usbid "0x04b8" "0x0121" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 3170 PHOTO" :interface "USB" :usbid "0x04b8" "0x0116" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 3200 PHOTO" ; command spec :interface "USB IEEE-1394" :usbid "0x04b8" "0x011c" :scsi "EPSON" "GT-9800" "processor" :status :complete :comment "overseas version of the GT-9800F" :model "Perfection 3490 PHOTO" :interface "USB" :usbid "0x04b8" "0x0122" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 3590 PHOTO" :interface "USB" :usbid "0x04b8" "0x0122" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 4180 PHOTO" :interface "USB" :usbid "0x04b8" "0x0118" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 4490 PHOTO" :interface "USB" :usbid "0x04b8" "0x0119" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection 4870 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x0128" :status :complete :comment "IEEE1394 untested
overseas version of the GT-X700" :model "Perfection 4990 PHOTO" :interface "USB" :usbid "0x04b8" "0x012a" :status :good :comment "film area guide mode not supported
IEEE1394 untested
overseas version of the GT-X800" :model "Perfection 4990 Pro" :interface "USB IEEE1394" :status :untested :comment "seems to be a 4990 PHOTO with additional software" :model "Perfection V10" :interface "USB" :usbid "0x04b8" "0x012d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection V30" :interface "USB" :usbid "0x04b8" "0x0131" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection V100 Photo" :interface "USB" :usbid "0x04b8" "0x012d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection V200 Photo" :interface "USB" :usbid "0x04b8" "0x012e" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection V300 Photo" :interface "USB" :usbid "0x04b8" "0x0131" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection V350 Photo" :interface "USB" :usbid "0x04b8" "0x012f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection V500 Photo" :interface "USB" :usbid "0x04b8" "0x0130" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection V600 Photo" :interface "USB" :usbid "0x04b8" "0x013a" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do" :model "Perfection V700 Photo" :interface "USB" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested
overseas version of the GT-X900" :model "Perfection V750 Photo" :interface "USB" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested
overseas version of the GT-X900" :model "Stylus CX1500" ; Australia :interface "USB" :usbid "0x04b8" "0x080c" :status :unsupported :comment "supported by the snapscan backend
all-in-one" :model "Stylus CX2800" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "Stylus CX2900" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "Stylus CX3100" :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one
overseas version of the CC-570L" :model "Stylus CX3200" :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one
overseas version of the CC-570L" :model "Stylus CX3500" ; Australia :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one
overseas version of the PX-A550" :model "Stylus CX3600" ; UK :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one
overseas version of the PX-A550" :model "Stylus CX3650" ; France :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one" :model "Stylus CX3700" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus CX3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus CX3810" :interface "USB" :status :untested :comment "all-in-one" :model "Stylus CX3900" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one
overseas version of the PX-A620" :model "Stylus CX4100" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus CX4200" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus CX4300" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do" :model "Stylus CX4400" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do" :model "Stylus CX4500" :interface "USB" :usbid "0x04b8" "0x080d" :status :good :comment "all-in-one" :model "Stylus CX4600" :interface "USB" :usbid "0x04b8" "0x080d" :status :good :comment "all-in-one" :model "Stylus CX4700" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus CX4800" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus CX4900" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus CX5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus CX5100" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one
overseas version of the CC-600PX" :model "Stylus CX5200" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one
overseas version of the CC-600PX" :model "Stylus CX5300" :interface "USB" :usbid "0x04b8" "0x0808" :status :good :comment "all-in-one" :model "Stylus CX5400" :interface "USB" :usbid "0x04b8" "0x0808" :status :good :comment "all-in-one" :model "Stylus CX5500" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do" :model "Stylus CX5600" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do" :model "Stylus CX5700F" :interface "USB" :usbid "0x04b8" "0x0821" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX5800F" :interface "USB" :usbid "0x04b8" "0x0821" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX5900" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus CX6000" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus CX6300" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :comment "all-in-one
mistakenly thinks its a PX-A650" :model "Stylus CX6400" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :comment "all-in-one
mistakenly thinks its a PX-A650" :model "Stylus CX6500" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :comment "all-in-one" :model "Stylus CX6600" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :comment "all-in-one" :model "Stylus CX6900F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX7000F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX7300" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus CX7400" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus CX7700" :interface "USB" :usbid "0x04b8" "0x081f" :status :good :comment "all-in-one" :model "Stylus CX7800" :interface "USB" :usbid "0x04b8" "0x081f" :status :good :comment "all-in-one" :model "Stylus CX8300" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus CX8400" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus CX9300F" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus CX9400Fax" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus DX3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus DX3850" :interface "USB" :status :good :comment "all-in-one" :model "Stylus DX4000" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one
overseas version of the PX-A620" :model "Stylus DX4200" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus DX4400" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :url "http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do" :model "Stylus DX4800" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus DX4850" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
DX4800 + card reader" :model "Stylus DX5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus DX6000" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus DX7000F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus DX7400" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus DX8400" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus DX9400F" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus Office BX300F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "all-in-one" :model "Stylus Office BX310FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "Stylus Office BX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "Stylus Office BX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus Office TX300F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "all-in-one" :model "Stylus Office TX510FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "Stylus Office TX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "Stylus Office TX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus Photo PX650 Series" :interface "USB" :usbid "0x04b8" "0x0850" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus Photo PX700W" :interface "USB Network" :usbid "0x04b8" "0x0846" :status :good :comment "network interface supported
all-in-one
overseas version of the EP-801A" :model "Stylus Photo PX710W Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus Photo PX800FW" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one
overseas version of the EP-901A" :model "Stylus Photo PX810FW Series" :interface "USB" :usbid "0x04b8" "0x0853" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus Photo RX420" :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX425" ; France :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX430" ; Australia :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX500" :interface "USB" :usbid "0x04b8" "0x0807" :status :good :comment "all-in-one" :model "Stylus Photo RX510" :interface "USB" :usbid "0x04b8" "0x0807" :status :good :comment "all-in-one" :model "Stylus Photo RX520" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one
overseas version of the PM-A750" :model "Stylus Photo RX530" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one
overseas version of the PM-A750" :model "Stylus Photo RX560" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX585" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX580" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX595" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX590" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX600" :interface "USB" :usbid "0x04b8" "0x0806" :status :good :comment "all-in-one
overseas version of the PM-A850" :model "Stylus Photo RX610" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX620" :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one
overseas version of the PM-A870" :model "Stylus Photo RX630" :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one
overseas version of the PM-A870" :model "Stylus Photo RX640" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one
overseas version of the PM-A890" :model "Stylus Photo RX650" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one
overseas version of the PM-A890" :model "Stylus Photo RX680" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX685" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX690" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX700" :interface "USB" :usbid "0x04b8" "0x0810" :status :good :comment "all-in-one
overseas version of the PM-A900" :model "Stylus Photo TX650 Series" :interface "USB" :usbid "0x04b8" "0x0850" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus Photo TX700W" :interface "USB" :usbid "0x04b8" "0x0846" :status :good :comment "network interface probably supported
all-in-one
overseas version of the EP-801A" :model "Stylus Photo TX710W Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus Photo TX800FW" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one
overseas version of the EP-901A" :model "Stylus NX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus NX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus NX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus NX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus NX300" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "all-in-one" :model "Stylus NX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-501A" :model "Stylus NX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface probably supported
all-in-one" :model "Stylus NX510 Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "Stylus SX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus SX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus SX125" :interface "USB" :usbid "0x04b8" "0x085c" :status :untested :comment "all-in-one" :model "Stylus SX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus SX205" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus SX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus SX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-501A" :model "Stylus SX405" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "all-in-one" :model "Stylus SX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface probably supported
all-in-one" :model "Stylus SX510W Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "Stylus SX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "Stylus SX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus Scan 2000" :interface "USB" :usbid "0x04b8" "0x0105" :status :untested :comment "apparently mostly the same as the Stylus Scan 2500" :model "Stylus Scan 2500" :interface "USB" :usbid "0x04b8" "0x0106" :status :untested :comment "scanner is apparently a GT-7000" :model "Stylus TX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus TX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus TX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX203" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX209" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus TX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-501A" :model "Stylus TX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface probably supported
all-in-one" :model "Stylus TX550W Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "WorkForce 310 Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "WorkForce 500" :interface "USB" :usbid "0x04b8" "0x084c" :status :good :comment "all-in-one" :model "WorkForce 600" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "WorkForce 610 Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "epson" ; name of backend ;:version "0.2.42" ; version of backend :version "unmaintained" ; version of backend :new :no :manpage "sane-epson" ; name of manpage (if it exists) :url "http://www.khk.net/sane" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Epson" ; name a manufacturer :url "http://www.epson.com/" :model "GT-5000" ; name models for above-specified mfg. :interface "SCSI Parport" :status :good :model "Actionscanner II" :comment "US version of GT-5000" :interface "SCSI Parport" :status :good :model "GT-6000" :interface "SCSI Parport" :status :good :model "ES-300C" :comment "US version of GT-6000" :interface "SCSI Parport" :status :good :model "ES-300GS" :interface "SCSI" :status :good :model "GT-5500" :interface "SCSI" :status :good :model "GT-6500" :interface "Parport" :status :good :model "ES-600C" :comment "US version of GT-6500" :interface "Parport" :status :good :model "ES-1200C" :comment "US version of GT-9000" :interface "Parport" :status :good :model "GT-7000" :interface "SCSI" :scsi "EPSON" "SCANNER GT-7000" "processor" :status :good :model "GT-8000" :interface "SCSI" :status :good :model "ES-8500" :interface "SCSI" :status :good :model "Perfection 636S" :comment "US version of GT-7000" :interface "SCSI" :scsi "EPSON" "Perfection1200" "processor" :status :complete :model "Perfection 636" :interface "SCSI" :scsi "EPSON" "Perfection636" "processor" :status :complete :model "Perfection 636U" :interface "USB" :usbid "0x04b8" "0x0101" :status :complete :model "Perfection 610" :interface "USB" :usbid "0x04b8" "0x0103" :status :complete :model "Perfection 640" :interface "USB" :usbid "0x04b8" "0x010c" :status :complete :model "Perfection 1200S" :interface "SCSI" :scsi "EPSON" "Perfection1200" "processor" :status :complete :model "Perfection 1200U" :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :model "Perfection 1200Photo" :comment "with TPU" :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :model "Perfection 1240" :interface "SCSI USB" :usbid "0x04b8" "0x010b" :status :complete :model "Perfection 1640" :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :complete :model "Perfection 1650" :interface "USB" :usbid "0x04b8" "0x0110" :status :complete :model "Perfection 1660" :interface "USB" :usbid "0x04b8" "0x011e" :status :complete :model "Perfection 2400" :interface "USB" :usbid "0x04b8" "0x011b" :status :complete :model "Perfection 2450" :interface "USB IEEE-1394" :usbid "0x04b8" "0x0112" :scsi "EPSON" "GT-9700" "processor" :status :complete :model "Perfection 3200" :comment "US version of the GT-9800" :interface "USB IEEE-1394" :usbid "0x04b8" "0x011c" :scsi "EPSON" "GT-9800" "processor" :status :complete :model "Perfection 4870" :comment "US version of the GT-X700" :interface "USB" :usbid "0x04b8" "0x0128" :status :complete :model "Perfection 4990" :comment "US version of the GT-X800" :interface "USB" :usbid "0x04b8" "0x012a" :status :complete :model "Expression 636" :comment "US version of GT-9500" :interface "SCSI" :status :complete :model "Expression 800" :interface "SCSI" :status :complete :model "Expression 1600" :interface "SCSI USB IEEE-1394" :usbid "0x04b8" "0x0107" :status :complete :model "Expression 1680" :interface "SCSI USB IEEE-1394" :usbid "0x04b8" "0x010e" :status :complete :model "FilmScan 200" :interface "SCSI" :comment "A better backend for the FilmScan 200 can be found at http://www.vjet.demon.co.uk/scanner/" :status :unsupported :url "http://www.vjet.demon.co.uk/scanner/" :model "CX-3200" :interface "USB" :usbid "0x04b8" "0x0802" :status :good :model "CX-3600" :interface "USB" :usbid "0x04b8" "0x080e" :status :good :model "CX-3650" :interface "USB" :usbid "0x04b8" "0x080e" :status :good :model "CX-4600" :interface "USB" :usbid "0x04b8" "0x080d" :status :good :model "CX-4800" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :model "CX-5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :model "CX-5200" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :model "CX-5400" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :model "CX-5400" :interface "USB" :usbid "0x04b8" "0x0808" :status :good :model "CX-6300" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :model "CX-6400" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :model "CX-6500" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :model "CX-6600" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :model "RX-500" :interface "USB" :usbid "0x04b8" "0x0807" :status :good :model "RX-600" :interface "USB" :usbid "0x04b8" "0x0806" :status :good :model "RX-425" :interface "USB" :usbid "0x04b8" "0x080f" :status :good :model "RX-700" :interface "USB" :usbid "0x04b8" "0x0810" :status :good :model "RX-620" :interface "USB" :usbid "0x04b8" "0x0811" :status :good :model "DX-3850" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :model "CX-3700" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :model "CX-3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :model "CX-4200" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :model "DX-3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :model "DX-5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :model "DX-5050" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :model "DX-6000" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :model "DX-7400" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :model "DX-4050" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :model "AcuLaser CX11" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :model "AcuLaser CX11NF" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :model "V700" :interface "USB IEEE-1394" :usbid "0x04b8" "0x012c" :status :good :model "V750" :interface "USB IEEE-1394" :usbid "0x04b8" "0x012c" :status :good ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "fujitsu" ; name of backend :url "http://www.thebility.com/fujitsu/" :version "117" ; version of backend :manpage "sane-fujitsu" ; name of manpage (if it exists) :comment "Backend updated for SANE release 1.0.23, see sane-fujitsu manpage" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Fujitsu" ; name a manufacturer :url "http://www.fujitsu.com/" ;================================================== ; DISCONTINUED OLDER MODELS, SMALL :model "M3091DC" :interface "SCSI" :url "http://www.remote.org/frederik/projects/software/sane/" :status :complete :comment "small, old, discontinued" :model "M3092DC" :interface "SCSI" :status :complete :comment "small, old, discontinued" ;================================================== ; DISCONTINUED NEWER MODELS, SMALL :model "fi-4120C" :interface "SCSI USB" :usbid "0x04c5" "0x1041" :status :complete :comment "small, recent, discontinued, usb 1.1" :model "fi-4120C2" :interface "SCSI USB" :usbid "0x04c5" "0x10ae" :status :complete :comment "small, recent, discontinued, usb 2.0" :model "fi-4220C" :interface "SCSI USB" :usbid "0x04c5" "0x1042" :status :complete :comment "small, recent, discontinued, usb 1.1" :model "fi-4220C2" :interface "SCSI USB" :usbid "0x04c5" "0x10af" :status :complete :comment "small, recent, discontinued, usb 2.0" :model "fi-5110C" :interface "USB" :status :complete :usbid "0x04c5" "0x1097" :comment "small, recent, discontinued" :model "fi-5110EOX/2" :interface "USB" :status :complete :usbid "0x04c5" "0x1096" :comment "small, recent, discontinued" :model "fi-5110EOX3" :interface "USB" :status :complete :usbid "0x04c5" "0x10e6" :comment "small, recent, discontinued" :model "fi-5110EOXM" :interface "USB" :usbid "0x04c5" "0x10f2" :status :complete :comment "small, recent, discontinued" :model "fi-5120C" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x10e0" :comment "small, recent, discontinued" :model "fi-5220C" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x10e1" :comment "small, recent, discontinued" :model "fi-5000N" :interface "Ethernet" :status :untested :comment "Not a scanner, rather a scanner to ethernet interface" :model "fi-6000NS" :interface "Ethernet" :status :untested :comment "small, recent, discontinued, integrated touchscreen and keyboard" :model "ScanSnap S500" :interface "USB" :status :complete :usbid "0x04c5" "0x10fe" :comment "small, recent, discontinued" :model "ScanSnap S500M" :interface "USB" :status :complete :usbid "0x04c5" "0x1135" :comment "small, recent, discontinued" :model "ScanSnap S510" :interface "USB" :status :complete :usbid "0x04c5" "0x1155" :comment "small, recent, discontinued" :model "ScanSnap S510M" :interface "USB" :status :complete :usbid "0x04c5" "0x116f" :comment "small, recent, discontinued" :model "fi-6130" :interface "USB" :status :complete :usbid "0x04c5" "0x114f" :comment "small, recent, discontinued" :model "fi-6230" :interface "USB" :status :complete :usbid "0x04c5" "0x1150" :comment "small, recent, discontinued" :model "ScanSnap S1500" :interface "USB" :status :complete :usbid "0x04c5" "0x11a2" :comment "small, discontinued" :model "ScanSnap S1500M" :interface "USB" :status :complete :usbid "0x04c5" "0x11a2" :comment "small, discontinued, same as S1500" ;================================================== ; CURRENT MODELS, SMALL :model "ScanSnap N1800" :interface "Ethernet" :status :untested :comment "small, current, integrated touchscreen and keyboard" :model "ScanSnap fi-6010N" :interface "Ethernet" :status :untested :comment "small, current, integrated touchscreen and keyboard" :model "fi-6110" :interface "USB" :status :complete :usbid "0x04c5" "0x11fc" :comment "small, current" :model "fi-6130Z" :interface "USB" :status :complete :usbid "0x04c5" "0x11f3" :comment "small, current" :model "fi-6230Z" :interface "USB" :status :complete :usbid "0x04c5" "0x11f4" :comment "small, current" :model "ScanSnap iX500" :interface "USB WiFi" :status :good :usbid "0x04c5" "0x132b" :comment "small, current, WiFi not supported. Hardware only scans in color. Backend generates binary and grayscale modes." ;================================================== ; DISCONTINUED OLDER MODELS, MEDIUM :model "M3093E" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3093DE" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3093DG" :interface "SCSI" :status :complete :comment "medium, old, discontinued" :model "M3093EX" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3093GX" :interface "SCSI" :status :complete :comment "medium, old, discontinued" :model "M3096EX" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3096GX" :interface "SCSI" :status :complete :comment "medium, old, discontinued" :model "M3097E+" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3097G+" :interface "SCSI" :status :complete :comment "medium, old, discontinued" :model "M3097DE" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3097DG" :interface "SCSI" :status :complete :comment "medium, old, discontinued" ;================================================== ; DISCONTINUED NEWER MODELS, MEDIUM :model "fi-4340C" :interface "SCSI USB" :usbid "0x04c5" "0x10cf" :status :complete :comment "medium, current" :model "fi-4530C" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x1078" :comment "medium, recent, discontinued" :model "fi-4640S" :interface "SCSI" :status :complete :comment "medium, recent, discontinued" :model "fi-4750C" :interface "SCSI" :status :complete :comment "medium, recent, discontinued" :model "fi-5530C" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x10e2" :comment "medium, recent, discontinued" :model "fi-6140" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x114d" :comment "medium, recent, discontinued" :model "fi-6240" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x114e" :comment "medium, recent, discontinued" ;================================================== ; CURRENT MODELS, MEDIUM :model "fi-5530C2" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x114a" :comment "medium, current" :model "fi-6140Z" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x11f1" :comment "medium, current" :model "fi-6240Z" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x11f2" :comment "medium, current" ;================================================== ; DISCONTINUED OLDER MODELS, BIG :model "M3099A" :interface "RS232C/Video" :status :unsupported :comment "big, old, discontinued" :model "M3099G" :interface "SCSI" :status :complete :comment "big, old, discontinued" :model "M3099EH" :interface "RS232C/Video" :status :unsupported :comment "big, old, discontinued" :model "M3099GH" :interface "SCSI" :status :complete :comment "big, old, discontinued" :model "M3099EX" :interface "RS232C/Video" :status :unsupported :comment "big, old, discontinued" :model "M3099GX" :interface "SCSI" :status :complete :comment "big, old, discontinued" :model "M4097D" :interface "SCSI" :status :complete :comment "big, old, discontinued" :model "M4099D" :interface "SCSI" :status :complete :comment "big, old, discontinued" ;================================================== ; DISCONTINUED NEWER MODELS, BIG :model "fi-4750L" :interface "SCSI" :status :complete :comment "big, recent, discontinued" :model "fi-4860C" :interface "SCSI" :status :complete :comment "big, recent, discontinued" :model "fi-4860C2" :interface "SCSI" :status :complete :comment "big, recent, discontinued" :model "fi-4990C" :interface "SCSI" :status :complete :comment "big, recent, discontinued" :model "fi-5650C" :interface "SCSI USB" :usbid "0x04c5" "0x10ad" :status :complete :comment "big, recent, discontinued" :model "fi-5750C" :interface "SCSI USB" :usbid "0x04c5" "0x1095" :status :complete :comment "big, recent, discontinued" :model "fi-5900C" :interface "SCSI USB" :usbid "0x04c5" "0x10e7" :status :good :comment "big, recent, discontinued. Independent ultrasonic control and multistream unsupported" :model "fi-6750S" :interface "USB" :status :untested :usbid "0x04c5" "0x1178" :comment "Simplex, USB only version of fi-6770, won't wakeup via software, discontinued" ;================================================== ; CURRENT MODELS, BIG :model "fi-5950" :interface "SCSI USB" :usbid "0x04c5" "0x1213" :status :untested :comment "big, current. Faster version of fi-5900?" :model "fi-6670" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x1176" :comment "big, current, won't wakeup via software" :model "fi-6670A" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x1177" :comment "big, current, VRS CGA board unsupported, won't wakeup via software" :model "fi-6770" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x1174" :comment "big, current, won't wakeup via software" :model "fi-6770A" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x1175" :comment "big, current, VRS CGA board unsupported, won't wakeup via software" :model "fi-6800" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x119d" :comment "big, current. Independent ultrasonic control and multistream unsupported" :model "fi-6800-CGA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x119e" :comment "big, current. VRS CGA board unsupported, Independent ultrasonic control and multistream unsupported" :backend "genesys" :version "1.0-63" :manpage "sane-genesys" :comment "Only the USB scanners mentioned below are currently supported." :url "http://www.meier-geinitz.de/sane/genesys-backend/" :devicetype :scanner ; ----------------------------------------------------------------------------- :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticBook 3600" :interface "USB" :usbid "0x07b3" "0x0900" :status :basic :comment "Has a Primax USB ID" ; ----------------------------------------------------------------------------- :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.com/" :url "http://www.medion.de/" :model "MD5345" :interface "USB" :usbid "0x0461" "0x0377" :status :good :comment "Has a Primax USB ID" :model "MD6228" :interface "USB" :usbid "0x0461" "0x0377" :status :good :comment "Has a Primax USB ID. Same as MD5345" :model "MD6471" :interface "USB" :usbid "0x0461" "0x0377" :status :complete :comment "Has a Primax USB ID. Same as MD5345" ; ----------------------------------------------------------------------------- :mfg "Hewlett-Packard" :url "http://www.hp.com/" :model "ScanJet 2300C" :interface "USB" :usbid "0x03f0" "0x0901" :status :complete :comment "600x1200 dpi max" :model "ScanJet 2400C" :interface "USB" :usbid "0x03f0" "0x0a01" :status :complete :comment "1200x1200 dpi max" :model "ScanJet G2410" :interface "USB" :usbid "0x03f0" "0x0a01" :status :basic :comment "clone of the HP 2400C" :model "ScanJet 3670" :interface "USB" :usbid "0x03f0" "0x1405" :status :complete :comment "1200x1200 dpi max, complete transparency adaptor support" :model "ScanJet 3690C" :interface "USB" :usbid "0x03f0" "0x1405" :status :complete :comment "1200x1200 dpi max, same as HP 3670" :model "ScanJet 4850C" :interface "USB" :usbid "0x03f0" "0x1b05" :status :untested :comment "resolution from 100 to 2400 supported, UTA not supported yet" :model "ScanJet G4010" :interface "USB" :usbid "0x03f0" "0x4505" :status :good :comment "resolution from 100 to 2400 supported, UTA not supported yet" :model "ScanJet G4050" :interface "USB" :usbid "0x03f0" "0x4605" :status :good :comment "resolution from 100 to 2400 supported, UTA not supported yet" :model "ScanJet N6310" :interface "USB" :usbid "0x03f0" "0x4705" :status :untested :comment "Not supported yet" ; ----------------------------------------------------------------------------- :mfg "Canon" :url "http://www.canon.com/" :model "CanoScan LiDE 35" :interface "USB" :usbid "0x04a9" "0x2213" :status :good :comment "Same ids as LiDE 50." :model "CanoScan LiDE 40" :interface "USB" :usbid "0x04a9" "0x2213" :status :good :comment "Same ids as LiDE 50." :model "CanoScan LiDE 50" :interface "USB" :usbid "0x04a9" "0x2213" :status :good :model "CanoScan LiDE 60" :interface "USB" :usbid "0x04a9" "0x221c" :status :good :model "CanoScan LiDE 100" :interface "USB" :usbid "0x04a9" "0x1904" :status :complete :comment "GL847 based, resolution from 75 to 2400 dpi" :model "CanoScan LiDE 110" :interface "USB" :usbid "0x04a9" "0x1909" :status :complete :comment "GL124 based, resolution from 75 to 2400 dpi" :model "CanoScan LiDE 200" :interface "USB" :usbid "0x04a9" "0x1905" :status :complete :comment "GL847 based, resolution from 75 to 4800 dpi" :model "CanoScan LiDE 210" :interface "USB" :usbid "0x04a9" "0x190a" :status :complete :comment "GL124 based, resolution from 75 to 2400 dpi" :model "CanoScan 4400f" :interface "USB" :usbid "0x04a9" "0x2228" :status :unsupported :comment "GL843 based, to be added to the genesys backend" :model "CanoScan 5600F" :interface "USB" :usbid "0x04a9" "0x1906" :status :unsupported :comment "GL847 based, to be added to the genesys backend" :model "CanoScan 700F" :interface "USB" :usbid "0x04a9" "0x1907" :status :good :comment "GL847 based, resolution from 75 to 4800 dpi" :model "Canon Image Formula 101" :interface "USB" :usbid "0x1083" "0x162e" :status :unsupported :comment "GL846 based, work in progress" ; ----------------------------------------------------------------------------- :mfg "Visioneer" :url "http://www.visioneer.com/" :model "Strobe XP 100,r3" :interface "USB" :usbid "0x04a7" "0x049b" :status :good :comment "All resolution and mode supported, calibration is available" :model "Strobe XP 200" :interface "USB" :usbid "0x04a7" "0x0426" :status :good :comment "All resolution and mode supported, calibration is available" :model "Strobe XP 300" :interface "USB" :usbid "0x04a7" "0x0474" :status :good :comment "All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally." :model "Roadwarrior" :interface "USB" :usbid "0x04a7" "0x0494" :status :basic :comment "All resolution and mode supported, calibration is available" :model "Visioneer OneTouch 7100" :interface "USB" :usbid "0x04a7" "0x0229" :status :complete :comment "Same as MD5345" ; ----------------------------------------------------------------------------- :mfg "Pentax" :url "http://www.pentaxtech.com/" :url "http://mobilesolutions.brother-usa.com/" :model "DSmobile 600" :interface "USB" :usbid "0x0a17" "0x3210" :status :good :comment "All resolution and mode supported, calibration is available" :model "DSmobile 600" :interface "USB" :usbid "0x04f9" "0x2038" :status :good :comment "All resolution and mode supported, calibration is available" ; ----------------------------------------------------------------------------- :mfg "DCT" :url "http://www.docucap.com/" :comment "Successor of Syscan in the USA" :model "DocketPort 487" :interface "USB" :usbid "0x1dcc" "0x4810" :status :basic :comment "All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally." ; ----------------------------------------------------------------------------- :mfg "Syscan" :model "DocketPort 485" :interface "USB" :usbid "0x0a82" "0x4810" :status :basic :comment "All resolution and mode supported, front- and backside side-by-side, with backside mirrored horizontally." :model "DocketPort 465" :interface "USB" :usbid "0x0a82" "0x4802" :status :untested :comment "All resolution and mode should be supported, but uncorrected scans" :model "DocketPort 665" :interface "USB" :usbid "0x0a82" "0x4803" :status :basic :comment "All resolution and mode supported, calibration is available" :model "DocketPort 685/ Ambir DS685" :interface "USB" :usbid "0x0a82" "0x480c" :status :good :comment "All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally." :mfg "Xerox" :url "http://www.xerox.com/" :model "Travel Scanner 100" :interface "USB" :usbid "0x04a7" "0x04ac" :status :good :comment "All resolution and mode supported, calibration is available" :model "2400 Onetouch" :interface "USB" :usbid "0x0461" "0x038b" :status :complete :comment "GL646 based, resolution from 75 to 2400 dpi" ; ----------------------------------------------------------------------------- :mfg "Panasonic" :model "KV-SS080" :interface "USB" :usbid "0x04da" "0x100f" :status :complete :comment "All resolution and mode supported, calibration is available. Support sponsored by cncsolutions (http://www.cncsolutions.com.br)" ;gphoto2 backend .desc file by Peter S. Fales :backend "gphoto2" ; name of backend :version "0.0" ; version of backend :manpage "sane-gphoto2" ; name of manpage (if it exists) :url "mailto:peter@fales-lorenz.net" ; backend's web page :devicetype :api ; start of a list of devices.... :desc "Multiple cameras supported by the gphoto2 libraries" :url "http://www.gphoto.org" ;:interface "USB, serial port" :comment "The long-term plan is to support all the cameras supported by the gphoto2 libraries (currently over 140 models). However, at this stage, only a handful of cameras are definitely known to work with SANE. Other cameras will probably work if the native file format is EXIF or JPEG. Testers welcome!" :backend "gt68xx" :version "1.0-84" :manpage "sane-gt68xx" :url "http://www.meier-geinitz.de/sane/gt68xx-backend/" :comment "Only the USB scanners mentioned below are supported. For other Mustek BearPaws, look at the Plustek and the MA-1509 backend." :devicetype :scanner ; ----------------------------------------------------------------------------- :mfg "Artec/Ultima" :url "http://www.artecusa.com/" :model "Ultima 2000" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Works, only product id 0x4002 is supported" :model "Ultima 2000 e+" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Works, however 12 bit mode doesn't seem to be supported" ; ----------------------------------------------------------------------------- :mfg "Boeder" :model "Sm@rtScan Slim Edition" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Artec Ultima 2000" ; ----------------------------------------------------------------------------- :mfg "Fujitsu" :url "http://www.fujitsu.com/" :model "1200CUS" :interface "USB" :usbid "0x05d8" "0x4002" :status :basic :comment "Works, but is slow. Probably a Mustek BearPaw 2400 CU clone." ; ----------------------------------------------------------------------------- :mfg "Genius" :url "http://www.genius-kye.com/" :model "ColorPage Slim 1200" ;:url "unsupported/genius-colorpage-slim-1200.html" :interface "USB" :usbid "0x0458" "0x201e" :status :untested :comment "Untested but should work." :model "Colorpage SF600" :interface "USB" :usbid "0x0458" "0x2021" :status :basic :model "Colorpage Vivid3x" :interface "USB" :usbid "0x0458" "0x2011" :status :good :model "Colorpage Vivid3 V2" :interface "USB" :usbid "0x0458" "0x2011" :status :good :comment "Same as Colorpage Vivid3x" :model "Colorpage Vivid3xe" :interface "USB" :usbid "0x0458" "0x2017" :status :good :model "Colorpage Vivid4" :usbid "0x0458" "0x2014" :interface "USB" :status :good :model "Colorpage Vivid4x" :usbid "0x0458" "0x201b" :interface "USB" :status :good :model "Colorpage Vivid4xe" :usbid "0x0458" "0x201a" :interface "USB" :status :good :model "Colorpage Vivid 1200 X" :interface "USB" :usbid "0x0458" "0x201d" :status :good :model "Colorpage Vivid 1200 XE" :interface "USB" :usbid "0x0458" "0x201f" :status :good ; ----------------------------------------------------------------------------- :mfg "Googlegear" :model "2000" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Same as Artec Ultima 2000." ; ----------------------------------------------------------------------------- :mfg "Lexmark" :url "http://www.lexmark.com/" :model "X70" :interface "USB" :usbid "0x043d" "0x002d" :status :good :comment "Works, some resolutions fail at 16 bit" :model "X73" :interface "USB" :usbid "0x043d" "0x002d" :status :good :comment "Works, some resolutions fail at 16 bit, same as X70" ; ----------------------------------------------------------------------------- :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.com" :comment "Sold by Aldi and Tchibo." :model "MD 4394" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Product id 0x4002. If you have 0x4003, use artec_eplus48u backend." :model "MD/LT 9375" :interface "USB" :usbid "0x05d8" "0x4002" :status :untested :comment "Untested, but is reported to have the same ids as the Artec Ultima 2000. Please test." :model "MD/LT 9385" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Artec Ultima 2000" :model "LT 9452" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Mustek ScanExpress 1200 UB Plus" :model "MD 9458" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Artec Ultima 2000 (e+?)" ; ----------------------------------------------------------------------------- :mfg "Mustek" :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "BearPaw 1200 CS" :interface "USB" :usbid "0x055f" "0x021e" :status :good :model "BearPaw 1200 CU" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :model "BearPaw 1200 CU Plus" :interface "USB" :usbid "0x055f" "0x021b" :status :good :model "BearPaw 1200 CU Plus" :interface "USB" :usbid "0x055f" "0x021c" :status :good :model "BearPaw 1200 TA" :interface "USB" :usbid "0x055f" "0x021e" :status :good :comment "Transparency adapter supported" :model "BearPaw 1248 CU" :interface "USB" :usbid "0x055f" "0x021c" :status :good :comment "Seems to use the same ids as BearPaw 1200 CU Plus." :model "BearPaw 2400 CS" :interface "USB" :usbid "0x055f" "0x0218" :status :untested :comment "Probably works, reports are welcome" :model "BearPaw 2400 CS Plus" :interface "USB" :usbid "0x055f" "0x0219" :status :good :comment "Works, problems with 12/16 bit modes?" :model "BearPaw 2400 CU" :interface "USB" :usbid "0x05d8" "0x4002" :status :basic :comment "Works, but is slow" :model "BearPaw 2400 CU Plus" :interface "USB" :usbid "0x055f" "0x021d" :status :good :model "BearPaw 2400 TA" :interface "USB" :usbid "0x055f" "0x0218" :status :good :comment "Transparency adapter supported" :model "BearPaw 2400 TA Plus" :interface "USB" :usbid "0x055f" "0x0219" :status :good :comment "Transparency adapter supported" :model "BearPaw 2448 CS Plus" :interface "USB" :usbid "0x055f" "0x021a" :status :basic :comment "Slow. Same as 2448 TA Plus, but without TA." :model "BearPaw 2448 TA Plus" :interface "USB" :usbid "0x055f" "0x021a" :status :basic :comment "Slow. Transparency adapter supported. Slow. Brightness depends on resolution?" :model "Plug-n-Scan 2400 MT" :interface "USB" :usbid "0x055f" "0x0219" :status :good :comment "Works but is slow in high resolutions. Same as BearPaw 2400 TA Plus." :model "Plug-n-Scan 2400 M" :interface "USB" :usbid "0x055f" "0x0219" :status :good :comment "Works but is slow in high resolutions. Same as BearPaw 2400 CS Plus." :model "ScanExpress 1200 UB Plus" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :model "ScanExpress 1248 UB" :interface "USB" :usbid "0x055f" "0x021f" :status :complete :model "ScanExpress 2400 USB" :interface "USB" :usbid "0x05d8" "0x4002" :status :minimal :comment "Should be detected but may need some more work in the code. Testers welcome. Please contact me if you own this scanner." :model "ScanExpress A3 USB" :interface "USB" :usbid "0x055f" "0x0210" :status :basic :comment "Still some vertical stripes." :model "ScanMagic 1200 UB Plus" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Same as ScanExpress 1200 UB Plus" ; ----------------------------------------------------------------------------- :mfg "NeatReceipts" :model "Scanalizer Professional 2.5" :interface "USB" :usbid "0x07b3" "0x0412" :status :untested :comment "Similar to Plustek OpticSlim M12. Please tell us if this scanner works." :model "Mobile Scanner" :interface "USB" :usbid "0x07b3" "0x0462" :status :basic :comment "Similar to Plustek OpticSlim M12." ; ----------------------------------------------------------------------------- :mfg "Nortek" :model "MyScan 1200" :interface "USB" :usbid "0x07b3" "0x040b" :status :untested :comment "Untested. Please test. Similar to Plustek OpticPro S12?" ; ----------------------------------------------------------------------------- :mfg "Packard Bell" :model "Diamond 1200" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Mustek BearPaw 1200 (Plus)" :model "Diamond 1200 Plus" :interface "USB" :usbid "0x055f" "0x021c" :status :good :comment "Similar to Mustek BearPaw 1200 Plus" :model "Diamond 1200 Plus" :interface "USB" :usbid "0x055f" "0x021b" :status :good :comment "Similar to Mustek BearPaw 1200 Plus" :model "Diamond 2450" :interface "USB" :usbid "0x055f" "0x0219" :status :good ; ----------------------------------------------------------------------------- :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticPro 1248U" :interface "USB" :usbid "0x07b3" "0x0400" :status :good :model "OpticPro 1248U" :interface "USB" :usbid "0x07b3" "0x0401" :status :good :model "OpticPro U16B" :interface "USB" :usbid "0x07b3" "0x0402" :status :good :model "OpticPro U16B+" :interface "USB" :usbid "0x07b3" "0x0403" :status :good :model "OpticPro UT16B" :interface "USB" :usbid "0x07b3" "0x0403" :status :untested :comment "Probably works. Transparency adapter not supported yet. Please contact me if you own such a device. " :model "OpticPro S12" :interface "USB" :usbid "0x07b3" "0x040b" :status :good :comment "Product ID 0x040b only." :model "OpticPro S24" :interface "USB" :usbid "0x07b3" "0x040e" :status :good :comment "Product ID 0x040e only. Is reported to work." :model "OpticPro ST12" :interface "USB" :usbid "0x07b3" "0x040b" :status :untested :comment "Product ID 0x040b only. Needs testing. Transparency adapter completely untested. Please contact me if you own such a scanner." :model "OpticSlim 1200" :interface "USB" :usbid "0x07b3" "0x0413" :status :good :model "OpticSlim 2400" :interface "USB" :usbid "0x07b3" "0x0422" :status :good :comment "Works up to 1200 dpi." :model "OpticSlim 2400 plus" :interface "USB" :usbid "0x07b3" "0x0454" :status :good :comment "Same as OpticSlim 2400." :model "Iriscan Express 2" :interface "USB" :usbid "0x07b3" "0x045f" :status :complete :comment "Works up to 1200 dpi. Calibration with external calibration sheet supported" ; ----------------------------------------------------------------------------- :model "OpticSlim M12" :interface "USB" :usbid "0x07b3" "0x0412" :status :complete :comment "Works up to 1200 dpi. Calibration with external calibration sheet supported" ; ----------------------------------------------------------------------------- :mfg "RevScan" ;:url "" :model "19200i" :interface "USB" :usbid "0x07b3" "0x0400" :status :good :comment "Similar to Plustek OpticPro 1248U" ; ----------------------------------------------------------------------------- :mfg "Trust" :url "http://www.trust-site.com" :model "240TH Easy Webscan Gold" :interface "USB" :usbid "0x055f" "0x0218" :status :good :comment "Same as Mustek Bearpaw 2400 TA plus." :model "Compact Scan USB 19200" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Works, if you have vendor id 0x055f and product id 0x0006, use the mustek_usb backend instead, similar to Mustek ScanExpress 1200 UB (Plus)" :model "Direct WebScan 19200" :interface "USB" :usbid "0x055f" "0x021c" :status :good :comment "Same as Mustek BearPaw 1200 CU Plus (0x021c)." :model "Flat Scan USB 19200" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Artec Ultima 2000" ; ----------------------------------------------------------------------------- :mfg "Visioneer" :url "http://www.visioneer.com/" :model "OneTouch 7300" :interface "USB" :usbid "0x04a7" "0x0444" :status :good :comment "Works upto 1200 dpi and 12 bits/color." ; ----------------------------------------------------------------------------- ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hp3500" ; name of backend :version "1.1" ; version of backend :manpage "sane-hp3500" ; name of manpage (if it exists) :url "http://projects.troy.rollo.name/rt-scanners/" ; backend's web page :comment "HP3500 series scanners." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com" :model "ScanJet 3500C" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port" or "Propretiary". :usbid "0x03f0" "0x2205" :status :good :model "ScanJet 3530C" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: :usbid "0x03f0" "0x2005" :status :good :model "ScanJet 3570C" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: :usbid "0x03f0" "0x2005" :status :good ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "hp3900" :version "0.12" :manpage "sane-hp3900" :url "http://sourceforge.net/projects/hp3900-series/" :comment "Still Beta" :devicetype :scanner ; ----------------------------------------------------- :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "ScanJet 3800" :interface "USB" :status :basic :usbid "0x03f0" "0x2605" :comment "Works with resolutions equal and less than 600dpi" :model "ScanJet 3970c" :interface "USB" :status :good :usbid "0x03f0" "0x2305" :model "ScanJet 4070 Photosmart" :interface "USB" :status :good :usbid "0x03f0" "0x2405" :model "ScanJet 4370" :interface "USB" :usbid "0x03f0" "0x4105" :status :basic :comment "Works with resolutions lower than 1200dpi" :model "ScanJet G2710" :interface "USB" :usbid "0x03f0" "0x2805" :status :basic :comment "Similar to hp scanjet 3800" :model "ScanJet G3010" :interface "USB" :usbid "0x03f0" "0x4205" :status :basic :comment "Similar to hp scanjet 4370" :model "ScanJet G3110" :interface "USB" :usbid "0x03f0" "0x4305" :status :basic :comment "Similar to hp scanjet 4370" ; ----------------------------------------------------- :mfg "UMAX" :url "http://www.umax.com" :model "Astra 4900" :interface "USB" :usbid "0x06dc" "0x0020" :status :minimal :comment "developing yet" ; ----------------------------------------------------- :mfg "BenQ" :url "http://www.benq.com/" :model "5550" :interface "USB" :usbid "0x04a5" "0x2211" :status :minimal :comment "developing yet" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "hp4200" ; name of backend :version "1.0-2" ; version of backend :manpage "sane-hp4200" ; name of manpage (if it exists) :url "http://hp4200-backend.sourceforge.net" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "ScanJet 4200C" ; name models for above-specified mfg. :interface "USB" :usbid "0x03f0" "0x0105" :status :basic :comment "8bpp color, 75/150/300/600 dpi only" :model "ScanJet 4200Cxi" ; name models for above-specified mfg. :interface "USB" :usbid "0x03f0" "0x0105" :status :basic :comment "8bpp color, 75/150/300/600 dpi only" :model "ScanJet 4200Cse" ; name models for above-specified mfg. :interface "USB" :usbid "0x03f0" "0x0105" :status :basic :comment "8bpp color, 75/150/300/600 dpi only" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; Copied from hp3300 testtools - Martijn van Oosterhout 22/02/2003 ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hp5400" ; name of backend :version "1.0-2" ; version of backend :manpage "sane-hp5400" ; name of manpage (if it exists) :url "http://sourceforge.net/projects/hp5400backend" ; backend's web page :comment "HP5400 and HP5470 scanners. Prototype backend available" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com" :model "ScanJet 5400c" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port" or "Propretiary". :usbid "0x03f0" "0x1005"" :status :basic :model "ScanJet 5470c" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: :usbid "0x03f0" "0x1105" :status :basic :model "ScanJet 5490c" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: :status :basic ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "hp5590" :version "1.0.5" :manpage "sane-hp5590" :devicetype :scanner :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "ScanJet 4500C" :interface "USB" :usbid "0x03f0" "0x1205" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives" :model "ScanJet 4570C" :interface "USB" :usbid "0x03f0" "0x1305" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives" :model "ScanJet 5500C" :interface "USB" :usbid "0x03f0" "0x1305" :status :untested :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives" :model "ScanJet 5550C" :interface "USB" :usbid "0x03f0" "0x1205" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives" :model "ScanJet 5590" :interface "USB" :usbid "0x03f0" "0x1705" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives" :model "ScanJet 7650" :interface "USB" :usbid "0x03f0" "0x1805" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hp" ; name of backend :version "1.06" ; version of backend :manpage "sane-hp" ; name of manpage (if it exists) :url "http://www.kirchgessner.net/" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "ScanJet Plus" ; name models for above-specified mfg. :interface "Propietary" :status :complete :comment "Driver for HP parallel interface card required" :model "ScanJet IIc" :interface "SCSI" :status :complete :scsi "HP" "C1750A" "processor" :model "ScanJet IIp" :interface "SCSI" :status :complete :scsi "HP" "C1790A" "processor" :model "ScanJet IIcx" :interface "SCSI" :status :complete :scsi "HP" "C2500A" "processor" :model "ScanJet 3c" :interface "SCSI" :status :complete :model "ScanJet 3p" :interface "SCSI" :status :complete :model "ScanJet 4c" :interface "SCSI" :status :complete :scsi "HP" "C2520A" "processor" :model "ScanJet 4p" :interface "SCSI" :status :complete :scsi "HP" "C1130A" "processor" :model "ScanJet 4100C" :interface "USB" :usbid "0x03f0" "0x0101" :status :complete :model "ScanJet 5p" :interface "SCSI" :status :complete :scsi "HP" "C5110A" "processor" :model "ScanJet 5100C" :interface "Parport" :status :complete :comment "Requires ppscsi driver and epst module" :model "ScanJet 5200C" :interface "Parport USB" :usbid "0x03f0" "0x0401" :status :complete :comment "Parallel interface requires ppscsi driver and epst module" :model "ScanJet 6100C" :interface "SCSI" :status :complete :model "ScanJet 6200C" :interface "SCSI USB" :scsi "HP" "C6270A" "processor" :usbid "0x03f0" "0x0201" :status :complete :model "ScanJet 6250C" :interface "SCSI USB" :usbid "0x03f0" "0x0201" :status :complete :model "ScanJet 6300C" :interface "SCSI USB" :scsi "HP" "C7670A" "processor" :usbid "0x03f0" "0x0601" :status :complete :model "ScanJet 6350C" :interface "SCSI USB" :usbid "0x03f0" "0x0601" :status :complete :model "ScanJet 6390C" :interface "SCSI USB" :usbid "0x03f0" "0x0601" :status :complete :model "PhotoSmart PhotoScanner" :interface "SCSI" :status :complete ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "hpljm1005" :version "0" :manpage "sane-hpljm1005" :devicetype :scanner :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "LaserJet M1005 MFP" :interface "USB" :usbid "0x03f0" "0x3b17" :status :good :comment "grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI" :model "LaserJet M1120 MFP" :interface "USB" :usbid "0x03f0" "0x5617" :status :good :comment "grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI" :model "LaserJet M1120n MFP" :interface "USB" :usbid "0x03f0" "0x5717" :status :good :comment "grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hpsj5s" ; name of backend :version "0.03" ; version of backend ;:status :alpha ; :alpha, :beta, :stable, :new :manpage "sane-hpsj5s" ; name of manpage (if it exists) :url "http://hpsj5s.sourceforge.net/" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "ScanJet 5s" ; name models for above-specified mfg. :interface "Parport (EPP)" :comment "Requires libieee1284 library. Only gray mode." :status :minimal ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hs2p" ; name of backend :url "http://www.acjlaw.net:8080/~jeremy/Ricoh/" :version "1.00" ; version of backend ; :manpage "sane-hs2p" ; name of manpage (if it exists) :comment "This backend has been tested with the IS450DE (Duplex/Endorser). All major functions necessary for scanning are supported. This backend should work with all Ricoh scanners in the IS450 family as well as the IS420 series, but the IS420 has not yet been tested. Features provided by the optional Image Processing Unit (IPU) are not yet integrated into the backend, as my scanner lacks the IPU." :devicetype :scanner :mfg "Ricoh" ; name a manufacturer :url "http://www.ricoh.com/" :model "IS450" ; name models for above-specified mfg. :interface "SCSI" :status :complete :comment "All major scanning-related features are supported (except for IPU). Certain non-scanning features, such as those related to scanner maintenance, are not supported. Such features would be better implemented in a separate stand-alone tool. For instance, if you replace the ADF Unit, you must recalibrate the scanner optics using a Ricoh Test Sheet and reset the E^2PROM registers. Reports are welcome." :model "IS-410" :interface "SCSI" :status :untested :comment "Untested, please report!" :model "IS-420" :interface "SCSI" :status :untested :comment "Untested, please report!" :model "IS-430" :interface "SCSI" :status :untested :comment "Untested, please report!" ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "ibm" ; name of backend :url "http://www.meier-geinitz.de/sane/ibm-backend/" :version "1.0-4" ; version of backend ; :manpage "sane-ibm" ; name of manpage (if it exists) :comment "This backend has had only limited testing. It needs more work especially for the Ricoh scanners. Patches are welcome." :devicetype :scanner :mfg "IBM" ; name a manufacturer :url "http://www.ibm.com/" :model "2456" ; name models for above-specified mfg. :interface "SCSI" :status :basic :comment "Was reported to work long time ago. Reports are welcome." :mfg "Ricoh" ; name a manufacturer :model "IS-410" :interface "SCSI" :status :untested :comment "Untested, please report!" :model "IS-420" :interface "SCSI" :status :basic :comment "Works at least in flatbed mode." :model "IS-430" :interface "SCSI" :status :untested :comment "Untested, please report!" :backend "kodakaio" :url "http://sourceforge.net/projects/cupsdriverkodak/" :version "2.4.6" :manpage "sane-kodakaio" :comment "Backend for Kodak AiO ESP and Hero printers. Also possibly Advent AWL10" :devicetype :scanner :new :no :mfg "Kodak" :url "http://www.kodak.com/" ;====================================== ; ESP series :model "ESP 2150" :interface "USB" :usbid "0x040a" "0x4059" :status :untested :comment "Please test!" :model "ESP 2170" :interface "USB" :usbid "0x040a" "0x4066" :status :untested :comment "Please test!" :model "ESP 3200" :interface "USB" :usbid "0x040a" "0x4043" :status :untested :comment "Please test!" :model "ESP 3300" :interface "USB" :usbid "0x040a" "0x4031" :status :untested :comment "Please test!" :model "ESP 4100" :interface "USB" :usbid "0x040a" "0x4053" :status :untested :comment "Please test!" :model "ESP 5000" :interface "USB" :usbid "0x040a" "0x4028" :status :untested :comment "Please test!" :model "ESP 5100" :interface "USB" :usbid "0x040a" "0x4025" :status :untested :comment "Please test!" :model "ESP 5200" :interface "USB Ethernet" :usbid "0x040a" "0x4041" :status :basic :comment "USB good, Network good" :model "ESP 5300" :interface "USB" :usbid "0x040a" "0x4026" :status :untested :comment "Please test!" :model "ESP 5500" :interface "USB" :usbid "0x040a" "0x4027" :status :untested :comment "Please test!" :model "ESP 6100" :interface "USB" :usbid "0x040a" "0x4054" :status :untested :comment "Please test!" :model "ESP 7200" :interface "USB" :usbid "0x040a" "0x4056" :status :untested :comment "Please test!" :model "ESP 9200" :interface "USB" :usbid "0x040a" "0x4065" :status :untested :comment "Please test!" :model "ESP 5" :interface "USB" :usbid "0x040a" "0x4032" :status :untested :comment "Please test!" :model "ESP 7" :interface "USB" :usbid "0x040a" "0x403e" :status :untested :comment "Please test!" :model "ESP 9" :interface "USB" :usbid "0x040a" "0x403f" :status :untested :comment "Please test!" :model "ESP C110" :interface "USB" :usbid "0x040a" "0x4057" :status :untested :comment "Please test!" :model "ESP C115" :interface "USB" :usbid "0x040a" "0x4058" :status :untested :comment "Please test!" :model "ESP C310" :interface "USB" :usbid "0x040a" "0x405d" :status :untested :comment "Please test!" :model "ESP C315" :interface "USB" :usbid "0x040a" "0x405e" :status :untested :comment "Please test!" ;====================================== ; Hero series :model "Hero 3.1" :interface "USB" :usbid "0x040a" "0x406d" :status :untested :comment "Please test!" :model "Hero 5.1" :interface "USB" :usbid "0x040a" "0x4064" :status :untested :comment "Please test!" :model "Hero Office 6.1" :interface "USB" :usbid "0x040a" "0x4062" :status :untested :comment "Please test!" :model "Hero 7.1" :interface "USB" :usbid "0x040a" "0x4063" :status :untested :comment "Please test!" :model "Hero 9.1" :interface "USB Ethernet" :usbid "0x040a" "0x4067" :status :basic :comment "USB good, Network good" ;=================================== :mfg "Advent" :url "http://www.adventcomputers.co.uk" :model "AW10" :interface "USB" :usbid "0x040a" "0x4060" :status :untested :comment "Please test!" :backend "kodak" :url "http://www.thebility.com/kodak/" :version "7" :manpage "sane-kodak" :comment "New backend for SANE release 1.0.21, see sane-kodak manpage" :devicetype :scanner :mfg "Kodak" :url "http://www.kodak.com/" ;====================================== ; workgroup machines, old :model "Scanner 1500" :interface "SCSI" :status :untested :comment "Please test!" ;====================================== ; departmental machines, old :model "Scanner 2500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 3500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 3510" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 3520" :interface "SCSI" :status :untested :comment "Please test!" :model "Color Scanner 3590C" :interface "SCSI" :status :untested :comment "Please test!" :model "Color Scanner 4500" :interface "SCSI" :status :untested :comment "Please test!" ;====================================== ; departmental machines, recent :model "i150 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i160 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i250 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i260 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i280 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" ;====================================== ; production machines, old :model "Scanner 900" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 923" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 5500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 7500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 7520" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 9500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 9520" :interface "SCSI" :status :untested :comment "Please test!" ;====================================== ; production machines, recent :model "i610 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i620 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i640 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i660 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i730 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i750 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i780 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i810 Scanner" :interface "SCSI" :status :untested :comment "Please test!" :model "i820 Scanner" :interface "SCSI" :status :untested :comment "Please test!" :model "i830 Scanner" :interface "SCSI" :status :untested :comment "Please test!" :model "i840 Scanner" :interface "SCSI" :status :untested :comment "Please test!" :model "i1840 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i1860 Scanner" :interface "IEEE-1394" :status :basic :comment "Uncompressed B&W, Gray and Color, some automatic features supported" :model "s1740" :interface "SCSI" :status :untested :comment "Please test!" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "kvs1025" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-kvs1025" ; name of manpage (if it exists) :comment "New backend for SANE release 1.0.21, see sane-kvs1025 manpage" :devicetype :scanner ; start of a list of devices.... :mfg "Panasonic" ; name a manufacturer :url "http://www.panasonic.com/" :model "KV-S1020C" :interface "USB" :usbid "0x04da" "0x1007" :status :good :model "KV-S1025C" :interface "USB" :usbid "0x04da" "0x1006" :status :good :model "KV-S1045C" :interface "USB" :usbid "0x04da" "0x1010" :status :good ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "kvs20xx" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-kvs20xx" ; name of manpage (if it exists) :comment "New backend for SANE release 1.0.22, see sane-kvs20xx manpage" :devicetype :scanner ; start of a list of devices.... :mfg "Panasonic" ; name a manufacturer :url "http://www.panasonic.com/" :model "KV-S2025C" :interface "SCSI" :status :untested :model "KV-S2026C" :interface "USB SCSI" :usbid "0x04da" "0x1000" :status :untested :model "KV-S2028C" :interface "USB" :usbid "0x04da" "0x100a" :status :untested :model "KV-S2045C" :interface "SCSI" :status :untested :model "KV-S2046C" :interface "USB SCSI" :usbid "0x04da" "0x1001" :status :untested :model "KV-S2048C" :interface "USB" :usbid "0x04da" "0x1009" :status :untested ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "kvs40xx" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-kvs40xx" ; name of manpage (if it exists) :comment "New backend for SANE release 1.0.23, see sane-kvs40xx manpage" :devicetype :scanner ; start of a list of devices.... :new :no :mfg "Panasonic" ; name a manufacturer :url "http://www.panasonic.com/" :model "KV-S4065C" :interface "USB" :usbid "0x04da" "0x100d" :status :untested :model "KV-S4085C" :interface "USB" :usbid "0x04da" "0x100c" :status :untested :model "KV-S7075C" :interface "USB" :usbid "0x04da" "0x100e" :status :untested ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "leo" ; name of backend :version "1.0-10" ; version of backend :manpage "sane-leo" ; name of manpage (if it exists) :url "http://www.zago.net/sane/#leo" ; backend's web page :devicetype :scanner ; start of a list of devices.... :mfg "LEO" :model "LEOScan S3" :interface "SCSI" :comment "FCC ID LUZFS1130" :status :good :mfg "Across Technologies" :model "FS-1130" :interface "SCSI" :comment "FCC ID LUZFS1130" :status :good :mfg "Genius" :model "FS-1130 Colorpage Scanner" :interface "SCSI" :status :good ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "lexmark" ; name of backend :version "1.0-0" ; version of backend (or "unmaintained") :manpage "sane-lexmark" ; name of manpage (if it exists) :url "http://stef.dev.free.fr/sane/lexmark" ; backend's web page :comment "This backend supports lexmark x1100 series scanners." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Lexmark" ; name a manufacturer :url "http://www.lexmark.com/" ; manufacturer's URL :model "X1110" :interface "USB" :usbid "0x043d" "0x007c" :status :untested :model "X1130" :interface "USB" :usbid "0x043d" "0x007c" :status :good :comment "Supports 75, 150, 300, 600 dpi" :model "X1140" :interface "USB" :usbid "0x043d" "0x007c" :status :untested :model "X1150" :interface "USB" :usbid "0x043d" "0x007c" :status :good :comment "Supports 75, 150, 300, 600 dpi" :model "X1170" :interface "USB" :usbid "0x043d" "0x007c" :status :good :comment "Supports 75, 150, 300, 600 dpi" :model "X1180" :interface "USB" :usbid "0x043d" "0x007c" :status :good :model "X1185" :interface "USB" :usbid "0x043d" "0x007c" :status :good :comment "Tested with xscanimage. Supports 75, 150, 300, 600, 1200(600x1200) dpi resolutions. Does grayscale or colour scans in the following sizes: wallet, 3x5, 4x6, 5x7, 8x10, letter." :model "X1195" :interface "USB" :usbid "0x043d" "0x007c" :status :untested :model "X74" :interface "USB" :usbid "0x043d" "0x0060" :status :good :comment "Supports 75, 150, 300, 600 dpi" :model "X12xx" :interface "USB" :usbid "0x043d" "0x007d" :status :good :comment "USB1.1 is OK, USB2.0 needs testing" :mfg "Dell" ; name a manufacturer :model "A920" :interface "USB" :usbid "0x413c" "0x5105" :status :good :comment "Relabelled X11xx model" ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "ma1509" ; name of backend :version "1.0-3" ; version of backend :manpage "sane-ma1509" ; name of manpage (if it exists) :url "http://www.meier-geinitz.de/sane/ma1509-backend/" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Mustek" ; name a manufacturer :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "BearPaw 1200 F" :interface "USB" :usbid "0x055f" "0x0010" :status :good :comment "Works upto 600 dpi. No support for TA and ADF yet." :mfg "Fujitsu" ; name a manufacturer :url "http://www.fujitsu.com/" :model "fi-4110EOX/2/3" :interface "USB" :usbid "0x04c5" "0x1040" :status :unsupported :comment "Uses ma1509 chip, but very different from other scanners supported by the ma1509 backend" ; ; SANE Backend specification file for the magicolor backend ; ; Copyright (C) 2010-11 Reinhold Kainhofer ; Released under GPLv2 ; :backend "magicolor" :version "1.0.0" :manpage "sane-magicolor" :url "http://wiki.kainhofer.com/hardware/magicolor_scan" :devicetype :scanner :mfg "KONICA MINOLTA" :url "http://www.konicaminolta.com/" :model "magicolor 1690MF" :interface "USB Network" :usbid "0x132b" "0x2089" :status :good :comment "Multi-function color laser printer with fax, scanner and network interface" :url "http://www.konicaminolta.eu/business-solutions/products/laser-printers/all-in-one/magicolor-1690mf/key-features.html" :model "BizHub 162/132" :interface "USB Network" :usbid "ignore" :status :unsupported :comment "Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov." :model "DiMage 1611" :interface "USB Network" :usbid "ignore" :status :unsupported :comment "Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov." ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "matsushita" ; name of backend :version "1.0-7" ; version of backend :manpage "sane-matsushita" ; name of manpage :url "http://www.zago.net/sane" ; backend's web page :devicetype :scanner ; start of a list of devices.... :mfg "Panasonic" ; name a manufacturer :url "http://www.panasonic.com/" :model "KV-SS25" :interface "SCSI" :status :complete :model "KV-SS25D" :interface "SCSI" :status :complete :model "KV-SS50" :interface "SCSI" :status :untested :model "KV-SS55" :interface "SCSI" :status :untested :model "KV-SS50EX" :interface "SCSI" :status :untested :model "KV-SS55EX" :interface "SCSI" :status :minimal :comment "no color, no high resolution, no automatic cropping" :model "KV-SS850" :interface "SCSI" :status :untested :model "KV-SS855" :interface "SCSI" :status :untested :model "KV-S2025C" :interface "SCSI" :status :minimal :comment "no color, no high resolution, no automatic cropping" :model "KV-S2045C" :interface "SCSI" :status :minimal :comment "no color, no high resolution, no automatic cropping" :model "KV-S2065L" :interface "SCSI" :status :minimal :comment "no color, no high resolution, no automatic cropping" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "microtek2" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-microtek2" ; name of manpage (if it exists) :url "http://karstenfestag.gmxhome.de/linux.html" :devicetype :scanner ; start of a list of devices.... :mfg "Microtek" ; name a manufacturer :url "http://www.microtek.com/" :model "ScanMaker E3plus" :interface "Parport" :status :complete :model "ScanMaker E3plus" ; name models for above-specified mfg. :interface "SCSI" :status :complete :model "ScanMaker X6" :interface "SCSI" :status :complete :model "ScanMaker X6EL" :interface "SCSI" :status :basic :model "ScanMaker X6USB" :interface "USB" :usbid "0x05da" "0x0099" :status :good :model "ScanMaker V300" :interface "SCSI" :status :good :model "ScanMaker V300" :interface "Parport" :status :good :model "ScanMaker V310" :interface "SCSI" :status :basic :model "ScanMaker V310" :interface "Parport" :status :basic :model "ScanMaker V600" :interface "SCSI" :status :basic :model "ScanMaker V600" :interface "Parport" :status :basic :model "ScanMaker 330" :interface "SCSI" :status :basic :model "ScanMaker 630" :interface "SCSI" :status :basic :model "ScanMaker 636" :interface "SCSI" :status :complete :model "ScanMaker 6400XL" :interface "SCSI" :status :complete :model "ScanMaker 9600XL" :interface "SCSI" :comment "only flatbed mode ?" :status :good :model "ScanMaker 9800XL" :url "unsupported/microtek-scanmaker-9800.html" :interface "IEEE-1394" :status :minimal :comment "IEEE-1394 seems to work. See link. More reports welcome." :model "Phantom 330CX" :interface "Parport" :status :complete :model "SlimScan C3" :interface "Parport" :status :complete :model "Phantom 636" :interface "SCSI" :status :complete :model "Phantom 636CX" :interface "Parport" :status :complete :model "SlimScan C6" :interface "USB" :usbid "0x05da" "0x009a" :status :complete :model "ScanMaker V6UPL" :interface "USB" :usbid "0x05da" "0x00b6" :status :basic :comment "Sometimes scan speed goes to fast and results look badly smudged." :model "ScanMaker V6USL" :interface "SCSI" :status :complete :model "ScanMaker V6USL" :interface "USB" :usbid "0x05da" "0x00a3" :status :complete :model "ScanMaker V6USL" :interface "USB" :usbid "0x05da" "0x80a3" :status :complete :model "ScanMaker X12USL" :interface "SCSI" :comment "only Flatbed mode ?" :status :good :mfg "Vobis" :url "http://www.vobis.de/" :model "HighScan" ; name models for above-specified mfg. :interface "SCSI" :comment "only E3plus based models" :status :complete :mfg "Scanport" :url "http://www.scanport.com/" :model "SQ300" :interface "Parport?" :status :basic :model "SQ2030" :interface "Parport" :status :basic :model "SQ4836" :interface "SCSI" :status :basic :mfg "Genius" :url "http://www.geniusmouse.co.uk/" :model "ColorPage-EP" :interface "Parport" :status :good :backend "microtek" :version "0.13.1" :manpage "sane-microtek" :url "http://www.mir.com/mtek/" :devicetype :scanner :mfg "Microtek" :url "http://www.microtek.com/" :model "Scanmaker E6" :interface "SCSI" :status :good :model "Scanmaker E3" :interface "SCSI" :status :good :model "Scanmaker E2" :interface "SCSI" :comment "3-pass" :status :good :model "Scanmaker 35t+" :interface "SCSI" :comment "slide-scanner" :status :good :model "Scanmaker 45t" :interface "SCSI" :comment "slide-scanner" :status :good :model "Scanmaker 35" :interface "SCSI" :comment "slide-scanner" :status :good :model "Scanmaker III" :interface "SCSI" :status :good :model "Scanmaker IISP" :interface "SCSI" :status :good :model "Scanmaker IIHR" :interface "SCSI" :comment "3-pass" :status :good :model "Scanmaker IIG" :interface "SCSI" :comment "gray only" :status :good :model "Scanmaker II" :interface "SCSI" :comment "3-pass" :status :good :model "Scanmaker 600Z(S)" :interface "SCSI" :status :untested :model "Scanmaker 600G(S)" :interface "SCSI" :comment "gray only (see manpage)" :status :basic :model "Color PageWiz" :interface "SCSI (Parport)" :comment "sheet-fed (preliminary, see mapage)" :status :basic :mfg "Agfa" :url "http://www.agfa.com/" :model "Arcus II" :interface "SCSI" :comment "Arcus *II*, not Arcus!" :status :good :model "StudioScan" :interface "SCSI" :status :good :model "StudioScan II" :interface "SCSI" :status :good :model "StudioScan IIsi" :interface "SCSI" :status :good :model "Studiostar" :interface "SCSI" :status :minimal :comment "Is detected but scans are very dark" :model "DuoScan" :interface "SCSI" :status :basic :mfg "Vobis" :url "http://www.vobis.de/" :model "Highscreen Realscan" :interface "SCSI" :status :good :mfg "Genius" :url "http://www.genius-kye.com/" :model "Colorpage-SP2" :interface "SCSI" :comment "Same as Microtek Scanmaker E3" :status :good ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "mustek" ; name of backend :version "1.0-138" ; version of backend :manpage "sane-mustek" ; name of manpage (if it exists) :url "http://www.meier-geinitz.de/sane/mustek-backend/" :comment "Most Mustek SCSI scanners are supported by this backend. For USB scanners, look at the mustek_usb backend." :devicetype :scanner :mfg "Mustek" ; name a manufacturer :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "Paragon MFS-6000CX" :interface "SCSI" :comment "3-pass" :status :good :model "Paragon MFS-12000CX" :interface "SCSI" :comment "3-pass" :status :good :model "Paragon MFC-600S" :interface "SCSI" :status :complete :model "Paragon 600 II CD" :interface "SCSI" :status :complete :model "Paragon 600 II ED" :interface "Parport" :status :untested :comment "Completely untested. If it's the same as the 600 II EP, it may work. Please contact me if you own such a device." :model "Paragon 600 II EP" :interface "Parport" :status :minimal :comment "Works, however only low resolutions and quality in color mode is bad." :model "ScanMagic 600 II SP" :interface "SCSI" :status :complete :model "TwainScan II SP" :interface "SCSI" :status :complete :model "Paragon MFC-800S" :interface "SCSI" :status :complete :model "Paragon 800 II SP" :interface "SCSI" :status :complete :model "Paragon MFS-6000SP" :interface "SCSI" :status :complete :model "Paragon MFS-8000SP" :interface "SCSI" :status :complete :model "Paragon MFS-1200SP" :interface "SCSI" :status :complete :model "Paragon MFS-12000SP" :interface "SCSI" :status :complete :model "ScanExpress 6000SP" :interface "SCSI" :status :complete :model "ScanExpress 12000SP" :interface "SCSI" :status :complete :model "ScanExpress 1200 FS" :interface "SCSI" :status :untested :comment "One report that it crashes the computer. SCSI driver issue? Please contact me if you own such a device." :model "ScanExpress 12000SP Plus" :interface "SCSI" :status :complete :model "Paragon 1200 III SP" :interface "SCSI" :status :complete :model "Paragon 1200 LS" :interface "SCSI" :status :complete :model "ScanMagic 9636S" :interface "SCSI" :status :complete :model "ScanMagic 9636S Plus" :interface "SCSI" :status :complete :model "ScanExpress A3 SP" :interface "SCSI" :comment "Please test!" :status :basic :model "Paragon 1200 SP Pro" :interface "SCSI" :status :good :model "Paragon 1200 A3 Pro" :interface "SCSI" :status :complete :comment "ADF and TA untested. Please contact me if you own such equipment." :model "Paragon 600 II N" :interface "Proprietary" :status :basic :comment "Resolutions above 300 dpi may cause trouble." :mfg "Trust" ; name a manufacturer :url "http://www.trust-site.com" :comment "Carefully check the model names. Trust uses similar names for completely different hardware." :model "Imagery 1200" :interface "SCSI" :status :good :comment "3-pass, Mustek Paragon MFS-6000CX compatible" :model "Imagery 1200 SP" :interface "SCSI" :status :complete :comment "Mustek Paragon MFS-6000SP compatible" :model "Imagery 4800 SP" :interface "SCSI" :status :complete :comment "Mustek Paragon 600 II CD compatible" :model "SCSI Connect 19200" :interface "SCSI" :status :complete :comment "Mustek ScanExpress 12000SP compatible" :model "SCSI excellence series 19200" :interface "SCSI" :status :complete :comment "Mustek ScanExpress 12000SP compatible" :mfg "Primax" ; name a manufacturer :url "http://www.primax.nl/" :model "Compact 4800 SCSI" :interface "SCSI" :status :complete :comment "Mustek 600 II CD compatible" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "mustek_pp" ; name of backend :version "13" ; version of backend :manpage "sane-mustek_pp" ; name of manpage (if it exists) ; backend's web page :url "http://penguin-breeder.org/sane/mustek_pp/" :comment "Supports CIS and CCD type parallel port scanners from Mustek." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Mustek" ; name a manufacturer :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "ScanExpress 6000 P" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "ScanExpress 600 SEP" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "ScanMagic 4800 P" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "600 III EP Plus" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "96 CP" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :model "ScanExpress 600 CP" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :model "ScanMagic 600 CP" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :model "ScanExpress 1200 CP" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :model "ScanExpress 1200 CP+" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.de/" :comment "Those scanners are also known as \"Aldi Scanner\" or \"Tchibo Scanners\"" :model "MD 9848" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "MD 9806" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "MD/LT 935x" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :model "MD/LT 985x" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :model "MD/LT 9890" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :mfg "Targa" :model "Funline TS12 EP" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :model "Funline TS6 EP" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :mfg "Trust" :url "http://www.trust-site.com/home/" :model "Easy Connect 9600+" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :model "Easy Connect 19200+" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :mfg "Viviscan" :model "Compact II" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :mfg "Cybercom" :model "9352" :interface "Parport (EPP)" :status :good :comment "CIS scanner" :mfg "Gallery" :model "4800" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :mfg "Network" :model "Easy Plus 30 Bit" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :mfg "Micromaxx" :model "MM-9851" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. :backend "mustek_usb2" :version "1.0-10" :manpage "sane-mustek_usb2" :url "http://www.meier-geinitz.de/sane/mustek_usb2-backend/" :comment "Only BearPaw 2448TA Pro is supported at the moment" :devicetype :scanner :mfg "Mustek" :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "BearPaw 2448TA Pro" :interface "USB" :usbid "0x055f" "0x0409" :status :good :backend "mustek_usb" :version "1.0-18" :manpage "sane-mustek_usb" :url "http://www.meier-geinitz.de/sane/mustek_usb-backend/" :comment "Only the USB scanners mentioned below are supported. For BearPaws, look at the Plustek, MA-1509, and gt68xx backends." :devicetype :scanner :mfg "Mustek" :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "ScanExpress 600 CU" :interface "USB" :usbid "0x055f" "0x0002" :status :complete :model "ScanExpress 1200 CU" :interface "USB" :usbid "0x055f" "0x0001" :status :complete :model "ScanExpress 1200 CU Plus" :interface "USB" :usbid "0x055f" "0x0008" :status :complete :model "ScanExpress 1200 UB" :interface "USB" :usbid "0x055f" "0x0006" :status :complete :comment "For the UB Plus, see gt68xx backend" :mfg "Trust" :url "http://www.trust-site.com" :model "Compact Scan USB 19200" :interface "USB" :usbid "0x055f" "0x0006" :status :complete :comment "Mustek 1200 UB compatible" :backend "nec" ; name of backend :version "0.12" ; version of backend :url "http://www5a.biglobe.ne.jp/~saetaka/" ; backend's homepage :manpage "sane-nec" :devicetype :scanner :mfg "NEC" ; name a manufacturer :url "http://www.nevt.co.jp/" :model "PC-IN500/4C" ; name models for above-specified mfg. :interface "SCSI" :comment "PC-IN500/4C was sold only in JAPAN" :status :good :backend "net" ; name of backend :version "1.0.14" :manpage "sane-net" :url "http://www.penguin-breeder.org/?page=sane-net" :devicetype :meta :desc "Network access to saned servers" :comment "Can be used to access any scanner supported by SANE over the net. Supports IPv4 and IPv6." ; $Id$ ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "niash" :version "0.3" :manpage "sane-niash" :url "http://sourceforge.net/projects/hp3300backend" :devicetype :scanner :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "ScanJet 3300c" :interface "USB" :usbid "0x03f0" "0x0205" :status :complete :model "ScanJet 3400c" :interface "USB" :usbid "0x03f0" "0x0405" :comment "If you use Linux 2.6, version 2.6.8 or newer is necessary." :status :complete :model "ScanJet 4300c" :interface "USB" :usbid "0x03f0" "0x0305" :comment "If you use Linux 2.6, version 2.6.8 or newer is necessary." :status :complete :model "ScanJet 4300c/Silitek" :interface "USB" :usbid "0x047b" "0x1002" :comment "If you use Linux 2.6, version 2.6.8 or newer is necessary." :status :complete :mfg "Agfa" :url "http://www.agfa.com" :model "Snapscan Touch" :interface "USB" :usbid "0x06bd" "0x0100" :status :complete :mfg "Trust" :url "http://www.trust.com" :model "Office Scan USB 19200" :interface "USB" :usbid "0x047b" "0x1000" :status :complete ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "p5" ; name of backend :version "1" ; version of backend :manpage "sane-p5" ; name of manpage (if it exists) :comment "New backend for SANE release 1.0.21, see sane-p5 manpage" :url "http://www.sane-project.org/" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "PRIMAX" ; name a manufacturer :url "http://www.primax.com.tw" :model "PagePartner" :interface "Parport (EPP/ECP)" :status :basic :comment "Sheetfed scanner, work in gray and color, but uncalibrated scans" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "pie" ; name of backend :version "1.0" ; version of backend :manpage "sane-pie" ; name of manpage (if it exists) :url "http://www.munton.demon.co.uk/sane" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Devcom" :url "http://www.blackwidow.co.uk/" :model "9636PRO" :interface "SCSI" :status :good :model "9636S" :interface "SCSI" :status :untested :model "9630S" :interface "SCSI" :status :untested :mfg "PIE" ; name a manufacturer :url "http://www.scanace.com/" :model "ScanAce 1236S" :interface "SCSI" :status :good :model "ScanAce 1230S" :interface "SCSI" :status :good :model "ScanAce II" :interface "SCSI" :status :untested :model "ScanAce III" :interface "SCSI" :status :good :model "ScanAce Plus" :interface "SCSI" :status :untested :model "ScanAce II Plus" :interface "SCSI" :status :untested :model "ScanAce III Plus" :interface "SCSI" :status :untested :model "ScanAce V" :interface "SCSI" :status :untested :model "ScanAce ScanMedia" :interface "SCSI" :status :untested :model "ScanAce ScanMedia II" :interface "SCSI" :status :untested :model "ScanAce 630S" :interface "SCSI" :status :untested :model "ScanAce 636S" :interface "SCSI" :status :untested :mfg "Adlib" :model "JetScan630" :interface "SCSI" :status :good :model "JetScan636PRO" :interface "SCSI" :status :untested ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. :backend "pint" ; name of backend :version "unmaintained" ; version of backend ; :url "" ; backend's homepage :manpage "sane-pint" :devicetype :api ; name models for above-specified mfg. :desc "Scanners with the machine-independent PINT interface" :comment "Haven't been tested for a long time. Handle with care." ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "pixma" ; name of backend :version "0.17.3" ; version of backend (or "unmaintained") :manpage "sane-pixma" ; name of manpage (if it exists) :url "http://home.arcor.de/wittawat/pixma/" ; 0.13.2 backend's web page :url "http://mp610.blogspot.com/" ; the pixma backend blog ;:comment "Devices marked as experimantal are disabled by default. See the manual page for how to enable them." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" :model "PIXMA E500" :interface "USB" :usbid "0x04a9" "0x1758" :status :untested :comment "Testers needed!" :model "PIXMA E510" :interface "USB" :usbid "0x04a9" "0x1761" :status :untested :comment "Testers needed!" :model "PIXMA E600" :interface "USB" :usbid "0x04a9" "0x175a" :status :untested :comment "Testers needed!" :model "PIXMA E610" :interface "USB" :usbid "0x04a9" "0x1767" :status :untested :comment "Testers needed!" :model "PIXMA MG2100 Series" :interface "USB" :usbid "0x04a9" "0x1751" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG2200 Series" :interface "USB" :usbid "0x04a9" "0x1760" :status :untested :comment "Testers needed!" :model "PIXMA MG3100 Series" :interface "USB WLAN" :usbid "0x04a9" "0x1752" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG3200 Series" :interface "USB" :usbid "0x04a9" "0x1762" :status :untested :comment "Testers needed!" :model "PIXMA MG4100 Series" :interface "USB" :usbid "0x04a9" "0x1753" :status :untested :comment "Testers needed!" :model "PIXMA MG4200 Series" :interface "USB" :usbid "0x04a9" "0x1763" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG5100 Series" :interface "USB" :usbid "0x04a9" "0x1748" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG5200 Series" :interface "USB" :usbid "0x04a9" "0x1749" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG5300 Series" :interface "USB" :usbid "0x04a9" "0x1754" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MG5400 Series" :interface "USB" :usbid "0x04a9" "0x1764" :status :untested :comment "Testers needed!" :model "PIXMA MG6100 Series" :interface "USB" :usbid "0x04a9" "0x174a" :status :complete :comment "All resolutions supported (up to 2400 DPI)" :model "PIXMA MG6200 Series" :interface "USB" :usbid "0x04a9" "0x1755" :status :complete :comment "All resolutions supported (up to 4800 DPI)" :model "PIXMA MG6300 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1765" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MG8100 Series" :interface "USB" :usbid "0x04a9" "0x174b" :status :untested :comment "Testers needed!" :model "PIXMA MG8200 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1756" :status :complete :comment "All resolutions supported (up to 4800DPI)." :model "PIXMA MP140" :interface "USB" :usbid "0x04a9" "0x172b" :status :complete :comment "All resolutions supported (up to 600 DPI)" :model "PIXMA MP150" :interface "USB" :usbid "0x04a9" "0x1709" :status :good :model "PIXMA MP160" :interface "USB" :usbid "0x04a9" "0x1714" :status :basic :model "PIXMA MP170" :interface "USB" :usbid "0x04a9" "0x170a" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP180" :interface "USB" :usbid "0x04a9" "0x1715" :status :basic :model "PIXMA MP190" :interface "USB" :usbid "0x04a9" "0x1734" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "PIXMA MP210" :interface "USB" :usbid "0x04a9" "0x1721" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "PIXMA MP220" :interface "USB" :usbid "0x04a9" "0x1722" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP230" :interface "USB" :usbid "0x04a9" "0x175f" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "PIXMA MP240" :interface "USB" :usbid "0x04a9" "0x1732" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP250" :interface "USB" :usbid "0x04a9" "0x173a" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "PIXMA MP260" :interface "USB" :usbid "0x04a9" "0x1733" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP270" :interface "USB" :usbid "0x04a9" "0x173b" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP280" :interface "USB" :usbid "0x04a9" "0x1746" :status :good :comment "All resolutions supported (up to 600DPI)." :model "PIXMA MP360" :interface "USB" :usbid "0x04a9" "0x263c" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP370" :interface "USB" :usbid "0x04a9" "0x263d" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP375R" :interface "USB" :usbid "0x04a9" "0x263f" :status :untested :comment "Same protocol as Pixma MP360/370/390? Testers needed!" :model "PIXMA MP390" :interface "USB" :usbid "0x04a9" "0x263e" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP450" :interface "USB" :usbid "0x04a9" "0x170b" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP460" :interface "USB" :usbid "0x04a9" "0x1716" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP470" :interface "USB" :usbid "0x04a9" "0x1723" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MP480" :interface "USB" :usbid "0x04a9" "0x1731" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP490" :interface "USB" :usbid "0x04a9" "0x173c" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP493" :interface "USB" :usbid "0x04a9" "0x1757" :status :untested :comment "Testers needed!" :model "PIXMA MP495" :interface "USB" :usbid "0x04a9" "0x1747" :status :untested :comment "Same protocol as Pixma MP280? Testers needed!" :model "PIXMA MP500" :interface "USB" :usbid "0x04a9" "0x170c" :status :good :model "PIXMA MP510" :interface "USB" :usbid "0x04a9" "0x1717" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP520" :interface "USB" :usbid "0x04a9" "0x1724" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP530" :interface "USB" :usbid "0x04a9" "0x1712" :status :good :model "PIXMA MP540" :interface "USB" :usbid "0x04a9" "0x1730" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP550" :interface "USB" :usbid "0x04a9" "0x173d" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP560" :interface "USB" :usbid "0x04a9" "0x173e" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP600" :interface "USB" :usbid "0x04a9" "0x1718" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP600R" :interface "USB Ethernet" :usbid "0x04a9" "0x1719" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP610" :interface "USB" :usbid "0x04a9" "0x1725" :status :complete :comment "All resolutions supported (up to 4800DPI)" :model "PIXMA MP620" :interface "USB Ethernet" :usbid "0x04a9" "0x172f" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP630" :interface "USB" :usbid "0x04a9" "0x172e" :status :complete :comment "All resolutions supported (up to 4800DPI)" :model "PIXMA MP640" :interface "USB Ethernet" :usbid "0x04a9" "0x173f" :status :complete :comment "All resolutions supported (up to 4800DPI)" :model "PIXMA MP700" :interface "USB" :usbid "0x04a9" "0x2630" :status :complete :comment "All resolutions supported (flatbed color up to 1200DPI, grayscale up to 600DPI)." :model "PIXMA MP710" :interface "USB" :usbid "0x04a9" "0x264d" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP730" :interface "USB" :usbid "0x04a9" "0x262f" :status :good :comment "Flatbed color up to 1200DPI, grayscale up to 600DPI. ADF scan to be confirmed." :model "PIXMA MP740" :interface "USB" :usbid "0x04a9" "0x264c" :status :untested :comment "Same protocol as Pixma MP710? Testers needed!" :model "PIXMA MP750" :interface "USB" :usbid "0x04a9" "0x1706" :status :minimal :comment "No grayscale. Canceling scan in ADF mode doesn't eject the paper!" :model "PIXMA MP760" :interface "USB" :usbid "0x04a9" "0x1708" :status :minimal :comment "No grayscale. The scanner sometimes hangs!" :model "PIXMA MP770" :interface "USB" :usbid "0x04a9" "0x1708" :status :minimal :comment "No grayscale. The scanner sometimes hangs!" :model "PIXMA MP780" :interface "USB" :usbid "0x04a9" "0x1707" :status :minimal :comment "No grayscale. The scanner sometimes hangs!" :model "PIXMA MP790" :interface "USB" :usbid "0x04a9" "0x1707" :status :minimal :comment "No grayscale. The scanner sometimes hangs!" :model "PIXMA MP800" :interface "USB" :usbid "0x04a9" "0x170d" :status :complete :comment "All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI." :model "PIXMA MP800R" :interface "USB" :usbid "0x04a9" "0x170e" :status :complete :comment "All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI." :model "PIXMA MP810" :interface "USB" :usbid "0x04a9" "0x171a" :status :complete :comment "All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI." :model "PIXMA MP830" :interface "USB" :usbid "0x04a9" "0x1713" :status :complete :comment "All resolutions supported up to 2400DPI. Flatbed, ADF simplex and Duplex supported." :model "PIXMA MP960" :interface "USB" :usbid "0x04a9" "0x171b" :status :complete :comment "All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI." :model "PIXMA MP970" :interface "USB Ethernet" :usbid "0x04a9" "0x1726" :status :complete :comment "All resolutions supported (up to 4800DPI). Full TPU support (negative and slides) at 24 or 48 bits." :model "PIXMA MP980" :interface "USB Ethernet" :usbid "0x04a9" "0x172d" :status :complete :comment "Working fine at all resolutions." :model "PIXMA MP990" :interface "USB Ethernet" :usbid "0x04a9" "0x1740" :status :complete :comment "Working fine at all resolutions." :model "PIXMA MX300" :interface "USB" :usbid "0x04a9" "0x1727" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "PIXMA MX310" :interface "USB" :usbid "0x04a9" "0x1728" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)" :model "PIXMA MX320" :interface "USB" :usbid "0x04a9" "0x1736" :status :untested :comment "Same protocol as Pixma Generation 3? Testers needed!" :model "PIXMA MX330" :interface "USB" :usbid "0x04a9" "0x1737" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)" :model "PIXMA MX340" :interface "USB" :usbid "0x04a9" "0x1741" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)" :model "PIXMA MX350" :interface "USB Ethernet" :usbid "0x04a9" "0x1742" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)" :model "PIXMA MX360" :interface "USB" :usbid "0x04a9" "0x174d" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy." :model "PIXMA MX370 Series" :interface "USB" :usbid "0x04a9" "0x1759" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX390 Series" :interface "USB" :usbid "0x04a9" "0x1766" :status :untested :comment "Testers needed!" :model "PIXMA MX410" :interface "USB Ethernet" :usbid "0x04a9" "0x174e" :status :untested :comment "Same protocol as Pixma MX420? Testers needed!" :model "PIXMA MX420" :interface "USB Ethernet" :usbid "0x04a9" "0x174f" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy." :model "PIXMA MX430 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x175b" :status :untested :comment "Testers needed!" :model "PIXMA MX450 Series" :interface "USB" :usbid "0x04a9" "0x1768" :status :untested :comment "Testers needed!" :model "PIXMA MX510 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x175c" :status :untested :comment "Testers needed!" :model "PIXMA MX520 Series" :interface "USB" :usbid "0x04a9" "0x1769" :status :untested :comment "Testers needed!" :model "PIXMA MX700" :interface "USB Ethernet" :usbid "0x04a9" "0x1729" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 2400DPI)" :model "PIXMA MX710 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x175d" :status :untested :comment "Testers needed!" :model "PIXMA MX720 Series" :interface "USB" :usbid "0x04a9" "0x176a" :status :untested :comment "Testers needed!" :model "PIXMA MX850" :interface "USB Ethernet" :usbid "0x04a9" "0x172c" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX860" :interface "USB Ethernet" :usbid "0x04a9" "0x1735" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX870" :interface "USB Ethernet" :usbid "0x04a9" "0x1743" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy." :model "PIXMA MX880 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1750" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy." :model "PIXMA MX882" :interface "USB Ethernet" :usbid "0x04a9" "0x1750" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy." :model "PIXMA MX885" :interface "USB Ethernet" :usbid "0x04a9" "0x1750" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy." :model "PIXMA MX890 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x175e" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy." :model "PIXMA MX920 Series" :interface "USB" :usbid "0x04a9" "0x176b" :status :untested :comment "Testers needed!" :model "PIXMA MX7600" :interface "USB Ethernet" :usbid "0x04a9" "0x171c" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 4800DPI)" :model "imageCLASS D420" :interface "USB" :usbid "0x04a9" "0x26ef" :status :complete :comment "All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported." :model "imageCLASS D480" :interface "USB" :usbid "0x04a9" "0x26ed" :status :complete :comment "All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported." :model "i-SENSYS MF3010" :interface "USB Ethernet" :usbid "0x04a9" "0x2759" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF3110" :interface "USB" :usbid "0x04a9" "0x2660" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "imageCLASS MF3240" :interface "USB" :usbid "0x04a9" "0x2684" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4010" :interface "USB" :usbid "0x04a9" "0x26b4" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4018" :interface "USB" :usbid "0x04a9" "0x26b4" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4120" :interface "USB" :usbid "0x04a9" "0x26a3" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4122" :interface "USB" :usbid "0x04a9" "0x26a3" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4140" :interface "USB" :usbid "0x04a9" "0x26a3" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4150" :interface "USB" :usbid "0x04a9" "0x26a3" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF4270" :interface "USB" :usbid "0x04a9" "0x26b5" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "I-SENSYS MF4320d" :interface "USB" :usbid "0x04a9" "0x26ee" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "I-SENSYS MF4330d" :interface "USB" :usbid "0x04a9" "0x26ee" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF4350d" :interface "USB" :usbid "0x04a9" "0x26ee" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF4370dn" :interface "USB" :usbid "0x04a9" "0x26ec" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported" :model "imageCLASS MF4380dn" :interface "USB" :usbid "0x04a9" "0x26ec" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported" :model "imageCLASS MF4410" :interface "USB" :usbid "0x04a9" "0x2737" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4430" :interface "USB" :usbid "0x04a9" "0x2737" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). ADF empty buggy." :model "i-SENSYS MF4550d" :interface "USB" :usbid "0x04a9" "0x2736" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "imageCLASS MF4660" :interface "USB" :usbid "0x04a9" "0x26b0" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF4690" :interface "USB" :usbid "0x04a9" "0x26b0" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF5630" :interface "USB" :usbid "0x04a9" "0x264e" :status :untested :comment "Testers needed!" :model "laserBase MF5650" :interface "USB" :usbid "0x04a9" "0x264f" :status :untested :comment "Testers needed!" :model "imageCLASS MF5730" :interface "USB" :usbid "0x04a9" "0x265d" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "imageCLASS MF5750" :interface "USB" :usbid "0x04a9" "0x265e" :status :untested :comment "Testers needed!" :model "imageCLASS MF5770" :interface "USB" :usbid "0x04a9" "0x265f" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF5880dn" :interface "USB" :usbid "0x04a9" "0x26f9" :status :untested :comment "Testers needed!" :model "imageCLASS MF6500 series" :interface "USB" :usbid "0x04a9" "0x2686" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF6550" :interface "USB" :usbid "0x04a9" "0x2686" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "i-SENSYS MF6680dn" :interface "USB" :usbid "0x04a9" "0x26fa" :status :untested :comment "Testers needed!" :model "imageCLASS MF8030" :interface "USB" :usbid "0x04a9" "0x2707" :status :untested :comment "Testers needed!" :model "imageCLASS MF8170c" :interface "USB" :usbid "0x04a9" "0x2659" :status :untested :comment "Testers needed!" :model "imageRUNNER 1020/1024/1025" :interface "USB" :usbid "0x04a9" "0x26e6" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "CanoScan 8800F" :interface "USB" :usbid "0x04a9" "0x1901" :status :complete :comment "Flatbed scan. TPU for negatives and slides. All resolutions supported (up to 4800DPI)." :model "CanoScan 9000F" :interface "USB" :usbid "0x04a9" "0x1908" :status :complete :comment "Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI." :model "CanoScan 9000F Mark II" :interface "USB" :usbid "0x04a9" "0x190d" :status :complete :comment "Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI." ; ; SANE Backend description file for Plustek backend (USB only) ; :backend "plustek" :version "0.52" :manpage "sane-plustek" ; backend's web page :url "http://www.gjaeger.de/scanner/plustek/" :devicetype :scanner ;* Plustek ********************************************************************************** :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticPro U12" :interface "USB" :usbid "0x07b3" "0x0010" :status :complete :comment "NOTE: Devices with product ID 0x0001 are not supported!" :model "OpticPro UT12" :interface "USB" :usbid "0x07b3" "0x0013" :status :complete :model "OpticPro UT12" :interface "USB" :usbid "0x07b3" "0x0017" :status :complete :comment "Note: Devices with product ID 0x0001 are not supported!" :model "OpticPro UT16" :interface "USB" :usbid "0x07b3" "0x0017" :status :complete :model "OpticPro U24" :interface "USB" :usbid "0x07b3" "0x0011" :status :complete :model "OpticPro U24" :interface "USB" :usbid "0x07b3" "0x0015" :status :complete :model "OpticPro UT24" :interface "USB" :usbid "0x07b3" "0x0017" :status :complete ;* Genius/KYE ******************************************************************************************* :mfg "Genius" :url "http://www.geniusnet.com.tw/" :model "Colorpage HR6 V2" :interface "USB" :usbid "0x0458" "0x2007" :status :complete :model "Colorpage HR6 V2" :interface "USB" :usbid "0x0458" "0x2008" :status :complete :model "Colorpage HR7" :interface "USB" :usbid "0x0458" "0x2013" :status :complete :model "Colorpage HR6A" :interface "USB" :usbid "0x0458" "0x2009" :status :untested :model "Colorpage HR7LE" :interface "USB" :usbid "0x0458" "0x2015" :status :untested :model "Colorpage HR6X" :interface "USB" :usbid "0x0458" "0x2016" :status :untested ;* MUSTEK *********************************************************************************** :mfg "Mustek" :url "http://www.mustek.com/" :model "BearPaw 1200" :interface "USB" :usbid "0x0400" "0x1000" :status :complete :comment "both product versions are supported, see backends' man-page" :model "BearPaw 1200" :interface "USB" :usbid "0x0400" "0x1001" :status :complete :comment "both product versions are supported, see backends' man-page" :model "BearPaw 2400" :interface "USB" :usbid "0x0400" "0x1001" :status :complete ;* Hewlett-Packard ************************************************************************** :mfg "Hewlett-Packard" :url "http://www.hp.com/" :model "ScanJet 2100C" :interface "USB" :usbid "0x03f0" "0x0505" :status :complete :model "ScanJet 2200C" :interface "USB" :usbid "0x03f0" "0x0605" :status :complete ;* EPSON ******************************************************************************************* :mfg "Epson" :url "http://www.epson.com/" :model "Perfection 1250" :interface "USB" :usbid "0x04b8" "0x010f" :status :complete :model "Perfection 1250Photo" :interface "USB" :usbid "0x04b8" "0x010f" :status :good :comment "TPA scans not perfect" :model "Perfection 1260" :interface "USB" :usbid "0x04b8" "0x011d" :status :complete :model "Perfection 1260Photo" :interface "USB" :usbid "0x04b8" "0x011d" :status :good :comment "TPA scans not perfect" ;* UMAX ************************************************************************************* :mfg "Umax" :url "http://www.umax.com/" :model "UMAX 3400" :interface "USB" :usbid "0x1606" "0x0050" :status :complete :comment "there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x" :model "UMAX 3400" :interface "USB" :usbid "0x1606" "0x0060" :status :complete :comment "there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x" :model "UMAX Astranet ia101" :interface "USB" :usbid "0x1606" "0x0060" :status :complete :comment "seems to be a renamed UMAX 3400" :model "UMAX 3450" :interface "USB" :usbid "0x1606" "0x0060" :status :complete :model "UMAX 5400" :interface "USB" :usbid "0x1606" "0x0160" :status :complete ;* COMPAQ ****************************************************************************************** :mfg "Compaq" :url "http://www.compaq.com/" :model "S4-100" :interface "USB" :usbid "0x049f" "0x001a" :status :complete :comment "Identical to UMAX 3400" ;* CANON ******************************************************************************************* :mfg "Canon" :url "http://www.canon.com/" :model "CanoScan N650U/N656U" :interface "USB" :usbid "0x04a9" "0x2206" :status :complete :model "CanoScan N1220U" :interface "USB" :usbid "0x04a9" "0x2207" :status :complete :model "CanoScan N670U/N676U/LiDE20" :interface "USB" :usbid "0x04a9" "0x220d" :status :complete :model "CanoScan N1240U/LiDE30" :interface "USB" :usbid "0x04a9" "0x220e" :status :complete :model "CanoScan LiDE25" :interface "USB" :usbid "0x04a9" "0x2220" :status :good :model "CanoScan D660U" :interface "USB" :usbid "0x04a9" "0x2208" :status :good :comment "TPA scans not perfect" ;* SYSCAN ******************************************************************************************* :mfg "Syscan" :url "http://www.syscaninc.com/" :model "TravelScan 460/464" :interface "USB" :usbid "0x0a82" "0x4600" :status :complete :model "TravelScan 662" :interface "USB" :usbid "0x0a82" "0x6620" :status :complete ;* SYSCAN ******************************************************************************************* :mfg "Ambir" :model "Visigo A4" :interface "USB" :usbid "0x0a82" "0x4600" :status :complete :comment "Rebaged Travelscan 464" ;* Portable Peripheral Co., Ltd. ******************************************************************** :mfg "Portable Peripheral Co., Ltd." :url "http://www.pandp.com.tw/" :model "Q-Scan USB001 (A4 portable scanner)" :interface "USB" :usbid "0x0a53" "0x1000" :status :complete :model "Q-Scan USB201 (A6 portable scanner)" :interface "USB" :usbid "0x0a53" "0x2000" :status :good ;* Visioneer **************************************************************************************** :mfg "Visioneer" :url "http://www.visioneer.com/" :model "Strobe XP 100" :interface "USB" :usbid "0x04a7" "0x0427" :status :basic ; ; SANE Backend description file for Plustek_pp backend ; :backend "plustek_pp" :version "0.43" :manpage "sane-plustek_pp" ; backend's web page :url "http://www.gjaeger.de/scanner/plustek_pp/" :devicetype :scanner ;* Plustek ********************************************************************************** :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" ;name models for above-specified mfg. :model "OpticPro 4800P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 4830P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 600P/6000P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 4831P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 9630P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 9630PL" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=1" :model "OpticPro 9600P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 1236P" :interface "Parport (SPP, EPP)" :status :complete :comment "reported as OpticPro 12000P/96000P" :model "OpticPro 12000P/96000P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 9636P" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=4" :model "OpticPro 9636P+/Turbo" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=3" :model "OpticPro 9636T" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 12000T" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro AI3" :interface "Parport (SPP, EPP)" :status :basic :comment "use driver-switch mov=5, poor picture quality" :model "OpticPro P8" :interface "Parport" :status :untested :model "OpticPro P12" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro PT12" :interface "Parport (SPP, EPP)" :status :complete ;* Primax *********************************************************************************** :mfg "Primax" ; name of manufacturer :url "http://www.primax.nl/" ;name models for above-specified mfg. :model "Colorado 4800" :interface "Parport (SPP, EPP)" :status :untested :comment "same as OpticPro 4800P" :model "Compact 4800 Direct" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=2" :model "Compact 4800 Direct-30" :interface "Parport (SPP, EPP)" :status :complete :comment "same as OpticPro 4830P, use driver-switch mov=7" :model "Compact 9600 Direct-30" :interface "Parport (SPP, EPP)" :status :complete :comment "same as OpticPro 9630P" ;* Genius/KYE ******************************************************************************************* :mfg "Genius" :url "http://www.geniusnet.com.tw/" :model "Colorpage Vivid III V2" :interface "Parport (SPP, EPP)" :status :complete :comment "Reported as PT12" :model "Colorpage Vivid Pro II Film" :interface "Parport (SPP, EPP)" :status :complete :comment "Reported as OP9636T/12000T" :model "Colorpage HR6X EPP" :interface "Parport (SPP, EPP)" :status :good :comment "Negative scanning does not work correctly" ;******************************************************************************************** :mfg "Aries" :model "Scan-It Pro 4800" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=2" ;******************************************************************************************** :mfg "BrightScan" :model "BrighScan OpticPro" :interface "Parport (SPP, EPP)" :status :complete :comment "Reported as P12" :backend "pnm" :version "1.0.8" :manpage "sane-pnm" :url "mailto:henning@meier-geinitz.de" :devicetype :api :desc "Reads PNM files" :comment "Used for debugging frontends. Obsolete, use test backend instead." :backend "qcam" ; name of backend :version "unmaintained" ; version of backend ; :url "" ; backend's homepage :manpage "sane-qcam" :devicetype :vidcam :mfg "Connectix" ; name a manufacturer ;:url "http://www.connectix.com/" ; doesn't exist any longer? :model "Color QuickCam" ; name models for above-specified mfg. :interface "Parport" :status :good :comment "Requires root privileges." :model "Greyscale QuickCam" ; name models for above-specified mfg. :interface "Parport" :status :minimal :comment "Requires root privileges. Partly working." ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "ricoh" ; name of backend :version "unmaintained" ; version of backend ; :manpage "sane-ricoh" ; name of manpage (if it exists) :devicetype :scanner :mfg "Ricoh" ; name a manufacturer :url "http://www.ricoh.com/" :model "Ricoh IS50" ; name models for above-specified mfg. :interface "SCSI" :status :basic ;:comment "?" :model "Ricoh IS60" ; name models for above-specified mfg. :interface "SCSI" :status :basic ;:comment "?" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "rts8891" ; name of backend :version "1.0-0" ; version of backend (or "unmaintained") :manpage "sane-rts8891" ; name of manpage (if it exists) :url "http://stef.dev.free.fr/sane/rts8891/index.html" ; backend's web page :comment "This backend supports Realtek RTS8891 ASIC bases scanners." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "UMAX" ; name a manufacturer :url "http://www.umax.com.tw/" ; manufacturer's URL :model "Astra 4400" :interface "USB" :usbid "0x1606" "0x0070" :status :good :comment "Supports 75, 150, 300, 600 and 1200 dpi" :model "Astra 4450" :interface "USB" :usbid "0x1606" "0x0070" :status :untested :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "scanjet 4470c" :interface "USB" :usbid "0x03f0" "0x0805" :status :good :comment "re-branded Astra 4400" :model "scanjet 4400c" :interface "USB" :usbid "0x03f0" "0x0705" :status :good :comment "exists with 2 different sensors of which only one works" :backend "s9036" ; name of backend :version "unmaintained" ; version of backend ; :url "" ; backend's homepage :manpage "sane-s9036" :devicetype :scanner :mfg "Siemens" ; name a manufacturer :url "http://www.siemens.com/" :model "9036 Flatbed scanner" ; name models for above-specified mfg. :interface "SCSI" :status :basic ; :comment "" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "sceptre" :version "1.0-10" ; version of backend :manpage "sane-sceptre" ; name of manpage :url "http://www.zago.net/sane/" ; backend's web page :devicetype :scanner :mfg "Sceptre" :url "http://www.sceptre.com/" :model "Vividscan S1200" :interface "SCSI" :status :basic :mfg "Komodo" :url "http://www.komodo.com/" :model "S1200" :interface "SCSI" :status :untested :comment "rebadged Sceptre S1200" :backend "sharp" ; name of backend :version "0.32" ; version of backend ;:status :beta ; :alpha, :beta, :stable, :new :url "http://www.satzbau-gmbh.de/staff/abel/sane-sharp.html" ; backend's homepage :manpage "sane-sharp" :devicetype :scanner :mfg "Sharp" ; name a manufacturer :url "http://sharp-world.com/" :model "JX-610" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" :model "JX-250" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" :model "JX-320" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" :model "JX-325" ; name models for above-specified mfg. :interface "SCSI" :status :untested :comment "" :model "JX-330" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" :model "JX-350" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "sm3600" ; name of backend :version "0.1" ; version of backend :manpage "sane-sm3600" ; name of manpage (if it exists) :url "http://sm3600.sourceforge.net/" ; backend's web page :devicetype :scanner ; start of a list of devices.... :mfg "Microtek" :url "http://www.microtek.com/" :model "ScanMaker 3600" :interface "USB" :usbid "0x05da" "0x40b3" :comment "works" :status :basic :model "ScanMaker 3600" :interface "USB" :usbid "0x05da" "0x40ca" :comment "works" :status :basic :model "ScanMaker 3600" :interface "USB" :usbid "0x05da" "0x40ff" :comment "works" :status :basic :model "ScanMaker 3700" :interface "USB" :usbid "0x05da" "0x40b8" :comment "works" :status :basic :model "ScanMaker 3700" :interface "USB" :usbid "0x05da" "0x40cb" :comment "works" :status :basic :model "ScanMaker 3750" :interface "USB" :usbid "0x05da" "0x40dd" :comment "works (told)" :status :basic ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "sm3840" ; name of backend :version "1.1" ; version of backend (or "unmaintained") :manpage "sane-sm3840" ; name of manpage (if it exists) :url "http://www.ziplabel.com/sm3840/" ; backend's web page :comment "This reverse-engineered backend supports the USB ScanMaker 3840 model" ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Microtek" ; name a manufacturer :url "http://www.microtek.com/" ; manufacturer's URL :comment "Microtek makes a wide variety of devices." ; comment about the manufacturer :model "ScanMaker 3840" ; name models for above-specified mfg. :status :good ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :usbid "0x05da" "0x30d4" :comment "8 and 16 bit, color and grayscale" ; comment about the model :model "ScanMaker 4800" ; name models for above-specified mfg. :status :good ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :usbid "0x05da" "0x30cf" :comment "Same hardware as SM3840, different color box" ; comment ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; :status specifier is optional after :model and at the top-level ; $Id$ ; ; SANE Backend specification file (Matto Marjanovic's format) ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "SnapScan" ; name of backend :version "1.4" ; version of backend :manpage "sane-snapscan" ; name of manpage (if it exists) :url "http://snapscan.sourceforge.net/" ; backend's web page :comment "Supported bit depths: 24 bit (color), 48 bit (color, Epson) 8 bit (gray)" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api ;----------------------------------------------------------------------------- :mfg "AGFA" ; name a manufacturer :url "http://www.agfa.com/" :model "SnapScan" ; name models for above-specified mfg. :interface "SCSI" :status :good :model "SnapScan 300" :interface "SCSI" :status :good :model "SnapScan 310" :interface "SCSI" :status :good :model "SnapScan 600" :interface "SCSI" :status :good :comment "Optional ADF supported." :model "Arcus 1200" :interface "SCSI" :status :good :comment "Optional transparency unit supported." :model "SnapScan 1236s" :interface "SCSI" :status :good :comment "Optional ADF and transparency unit supported." :model "SnapScan 1236u" :interface "USB" :status :good :usbid "0x06bd" "0x0002" :comment "Optional ADF and transparency unit supported." :model "SnapScan 1212U" :interface "USB" :usbid "0x06bd" "0x0001" :status :good :model "SnapScan 1212U_2" :interface "USB" :usbid "0x06bd" "0x2061" :status :good :model "SnapScan e10" :interface "USB" :usbid "0x06bd" "0x2093" :status :good :model "SnapScan e20" :interface "USB" :usbid "0x06bd" "0x2091" :status :good :model "SnapScan e25" :interface "USB" :usbid "0x06bd" "0x2095" :status :good :model "SnapScan e26" :interface "USB" :usbid "0x06bd" "0x2097" :status :good :model "SnapScan e40" :interface "USB" :usbid "0x06bd" "0x208d" :status :good :model "SnapScan e42" :interface "USB" :usbid "0x06bd" "0x20ff" :status :good :model "SnapScan e50" :interface "USB" :status :good :usbid "0x06bd" "0x208f" :comment "Optional tranparency unit supported" :model "SnapScan e52" :interface "USB" :status :good :usbid "0x06bd" "0x20fd" :comment "Optional tranparency unit supported" :model "SnapScan e60" :interface "USB" :status :untested ;------------------------------------------------------------------------------ :mfg "Acer Peripherals" :comment "Company was renamed to Benq." :mfg "Vuego" :comment "Company was renamed to Benq." :mfg "Benq (Acer)" :url "http://www.benq.com" :comment "Formerly Acer Peripherals" :model "300f" :interface "SCSI" :status :good :model "310s" :interface "SCSI" :status :good :model "610s" :interface "SCSI" :status :good :model "610plus" :interface "SCSI" :status :good :model "620s" :interface "SCSI" :status :good :model "ScanWit 2720s" :interface "SCSI" :status :good :model "310U" :interface "USB" :usbid "0x04a5" "0x1a20" :status :good :model "320U" :interface "USB" :usbid "0x04a5" "0x2022" :status :good :model "340U" :interface "USB" :usbid "0x04a5" "0x2022" :status :good :model "620U" :interface "USB" :usbid "0x04a5" "0x1a2a" :status :good :comment "Optional tranparency unit supported" :model "620UT" :interface "USB" :usbid "0x04a5" "0x2040" :status :good :comment "Optional tranparency unit supported" :model "640U" :interface "USB" :usbid "0x04a5" "0x2060" :status :good :comment "Optional tranparency unit supported" :model "640bu" :interface "USB" :usbid "0x04a5" "0x207e" :status :good :model "640BT" :interface "USB" :usbid "0x04a5" "0x20be" :status :good :comment "Optional tranparency unit supported" :model "1240" :interface "USB" :usbid "0x04a5" "0x20c0" :status :good :comment "Optional tranparency unit supported" :model "3300" :interface "USB" :usbid "0x04a5" "0x20b0" :status :good :model "3300" :interface "USB" :usbid "0x04a5" "0x20de" :status :good :model "4300" :interface "USB" :usbid "0x04a5" "0x20b0" :status :good :model "4300" :interface "USB" :usbid "0x04a5" "0x20de" :status :good :model "5000E" :interface "USB" :usbid "0x04a5" "0x20fc" :status :basic :comment "Same as 5000U, working up to 600 DPI" :model "5000U" :interface "USB" :usbid "0x04a5" "0x20fc" :status :basic :comment "Same as 5000E, working up to 600 DPI" :model "5000" :interface "USB" :usbid "0x04a5" "0x20f8" :status :good :comment "USB ID 0x04a5,0x20f8: Color / grayscale scans working up to 1200 DPI" :model "5150" :interface "USB" :usbid "0x04a5" "0x2137" :status :basic :comment "Calibration algorithm unknown" :model "5250" :interface "USB" :usbid "0x04a5" "0x2137" :status :basic :comment "Same hardware as 5150 (?), Calibration algorithm unknown" :model "5300" :interface "USB" :usbid "0x04a5" "0x20fe" :status :basic :comment "Problems with firmware upload reported" ;------------------------------------------------------------------------------ :mfg "Guillemot / Hercules" :url "http://www.guillemot.com" :model "Maxi Scan A4 Deluxe (SCSI)" :interface "SCSI" :status :good :comment "Rebadged SnapScan 310s." :model "Scan@home Touch 1248 (USB)" :interface "USB" :usbid "0x04a5" "0x20de" :status :good :comment "Rebadged Benq 3300." :model "Maxi Scan A4 USB 640U" :interface "USB" :usbid "0x04a5" "0x2060" :status :good :comment "Rebadged Benq 640U." :model "Maxi A4 36 bit" :interface "USB" :usbid "0x04a5" "0x2060" :status :good :comment "Rebadged Benq 620U, needs Benq firmware file u96v???.bin" ;------------------------------------------------------------------------------ :mfg "Mitsubishi" :url "http://www.mitsubishi.com" :model "Diamondview 648UT" :interface "USB" :usbid "0x04a5" "0x2022" :status :good :comment "Rebadged Benq 320u." :model "Diamondview 650U" :interface "USB" :usbid "0x04a5" "0x20b0" :status :good :comment "Rebadged Benq 4300." ;------------------------------------------------------------------------------ :mfg "Epson" :url "http://www.epson.com" :model "Perfection 660" :interface "USB" :usbid "0x04b8" "0x0114" :status :good :model "Perfection 1270" :interface "USB" :usbid "0x04b8" "0x0120" :status :good :model "Perfection 1670" :interface "USB" :usbid "0x04b8" "0x011f" :status :good :model "Perfection 2480" :interface "USB" :usbid "0x04b8" "0x0121" :status :good :model "Perfection 2580" :interface "USB" :status :basic :usbid "0x04b8" "0x0121" :comment "Film scanning unit unsupported" :model "Perfection 3490" :interface "USB" :usbid "0x04b8" "0x0122" :status :good :model "Perfection 3590" :interface "USB" :usbid "0x04b8" "0x0122" :status :basic :comment "Film scanning unit unsupported" :model "Stylus CX-1500" :interface "USB" :usbid "0x04b8" "0x080c" :status :good ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "sp15c" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-sp15c" ; name of manpage (if it exists) ;:url "http://www.aa.net/~bentson/sane.html" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Fujitsu" ; name a manufacturer :url "http://www.fcpa.fujitsu.com/products/scanners/" :url "http://www.fujitsu.com/" :model "ScanPartner 15C" ; name models for above-specified mfg. :interface "SCSI" :status :good :model "ScanPartner 600C" ; name models for above-specified mfg. :interface "SCSI" :status :good ; ST400 backend .desc by Ingo Wilken :backend "st400" ; name of backend :version "1.6" ; version number :manpage "sane-st400" ; name of manpage (if it exists) :url "http://www.informatik.uni-oldenburg.de/~ingo/sane/" ; backend's web page :devicetype :scanner ; start of a list of devices :mfg "Siemens" :url "http://www.siemens.de/" :model "ST400" :interface "SCSI" :comment "6 bit gray" :status :basic :model "ST800" :interface "SCSI" :comment "6 bit gray" :status :basic ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "stv680" ; name of backend :version "1.0-1" ; version of backend :manpage "sane-stv680" :url "http://gkall.hobby.nl/stv680-aiptek.html" ; backend's web page :comment "This vidcam backend is for the stv0680 chipset, See the website for more info." :devicetype :vidcam ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Aiptek" ; name a manufacturer :url "http://www.aiptek.com.tw" ; name models for above-specified mfg. :model "Aiptek Pencam" :interface "USB" :usbid "0x0553" "0x0202" :status :minimal :comment "image is OK for CIF and QCIF, VGA and QVGA untested, streaming video is a problem" :mfg "Konica" ; name a manufacturer :url "http://www.konicaminolta.com" ; name models for above-specified mfg. :model "e-mini" :interface "USB" :usbid "0x04c8" "0x0722" :status :untested :comment " " :mfg "Digital Dream" ; name a manufacturer :url "http://www.digitaldreamco.com/en/index.shtml" ; name models for above-specified mfg. :model "l' espion XS" :interface "USB" :usbid "0x1183" "0x0001" :status :untested :comment " " :mfg "Creative" ; name a manufacturer :url "http://www.creative.com/" ; name models for above-specified mfg. :model "WebCam Go Mini" :interface "USB" :usbid "0x041e" "0x4007" :status :untested :comment " " ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "tamarack" ; name of backend :version "unmaintained" ; version of backend ; :manpage "sane-tamarack" ; name of manpage (if it exists) :devicetype :scanner :mfg "Tamarack" ; name a manufacturer ;:url "http://www.tamarack.net/" ; doesn't exist anymore? :model "Artiscan 6000C" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "3 pass, 300 DPI" :model "Artiscan 8000C" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "3 pass, 400 DPI" :model "Artiscan 12000C" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "3 pass, 600 DPI" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "teco1" ; name of backend :version "1.0-10" ; version of backend :manpage "sane-teco1" ; name of manpage (if it exists) :url "http://www.zago.net/sane/#teco" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Relisys" :url "http://www.relisys.com/" :url "http://www.tecoimage.com.tw/" :model "RELI 2412" :interface "SCSI" :comment "sub model VM3530+" :status :complete :model "AVEC 2400" :interface "SCSI" :comment "sub model VM3520" :status :complete :model "RELI 4830" :interface "SCSI" :comment "sub model VM4542" :status :good :model "AVEC 2412" :comment "sub model VM3520+" :interface "SCSI" :status :complete :model "AVEC 4800" :comment "sub model VM4530" :interface "SCSI" :status :untested :model "AVEC 4816" :comment "sub model VM4530+" :interface "SCSI" :status :untested :model "RELI DS6" :comment "sub model VM3420" :interface "SCSI" :status :untested :model "RELI DS15" :comment "sub model VM3440" :interface "SCSI" :status :untested :model "RELI 2400" :comment "sub model VM3530" :interface "SCSI" :status :untested :model "RELI 4816" :comment "sub model VM4540" :interface "SCSI" :status :complete :model "RELI 9600" :comment "sub model VM6530" :interface "SCSI" :status :untested :model "RELI 9612" :comment "sub model VM6530*" :interface "SCSI" :status :untested :model "RELI 9624" :comment "sub model VM6530+" :interface "SCSI" :status :untested :model "RELI 9630" :comment "sub model VM6540" :interface "SCSI" :status :untested :mfg "Actown" :model "ACT Scan I 30" :comment "sub model VM3520A" :interface "SCSI" :status :untested :mfg "Dextra" :model "DF-600P" :comment "sub model VM3510" :interface "SCSI" :status :good :model "DF-1200T+" :comment "sub model VM3530+" :interface "SCSI" :status :untested :model "DF-4830T" :comment "sub model VM4542" :interface "SCSI" :status :untested :model "DF-9624" :comment "sub model VM6530+" :interface "SCSI" :status :untested ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "teco2" ; name of backend :version "1.0-9" ; version of backend :manpage "sane-teco2" :url "http://gkall.hobby.nl/teco2.html" ; backend's web page :devicetype :scanner :mfg "Relisys" :url "http://www.relisys.com/" :model "AVEC Super 3" :interface "SCSI" :comment "sub model VM3575" :status :untested :model "AVEC II S3" :interface "SCSI" :comment "sub model VM3564" :status :good :model "SCORPIO Super 3" :comment "sub model VM3575" :interface "SCSI" :status :good :model "APOLLO Express 3" :comment "sub model VM356A" :interface "SCSI" :status :basic :model "APOLLO Express 6" :comment "sub model VM6565" ; aka VM656A :interface "SCSI" :status :good :model "SCORPIO Pro" :comment "sub model VM6575" :interface "SCSI" :status :good :model "SCORPIO Pro-S" :comment "sub model VM6586" :interface "SCSI" :status :untested :mfg "Primax" :url "http://www.primax.nl/" :model "Jewel 4800" :comment "sub model VM356A" :interface "SCSI" :status :good :model "Profi 9600" :comment "sub model VM6575" :interface "SCSI" :status :basic :model "Profi 19200" :comment "sub model VM6586" :interface "SCSI" :status :good :mfg "Mustek" :url "http://www.mustek.com/" :model "ScanMagic 4830S" :comment "sub model VM3575" :interface "SCSI" :status :untested ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "teco3" ; name of backend :version "1.0-1" ; version of backend :manpage "sane-teco3" ; name of manpage (if it exists) :url "http://www.zago.net/sane/#teco3" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Relisys" :url "http://www.tecoimage.com.tw/" :model "Infinity Scorpio" :comment "sub model VM3552" :interface "SCSI" :status :good :mfg "Plustek" :model "OpticPro 2400SP" :comment "sub model VM3552" :interface "SCSI" :status :untested :mfg "PIOTECH" :url "http://www.image-land.com/" :model "Splendeur 3024" :comment "sub model VM3552" :interface "SCSI" :status :good :mfg "Trust" :model "Imagery 2400 SP" :comment "sub model VM3552" :interface "SCSI" :status :good :model "Imagery 4800 SP+" :comment "sub model VM3552" :interface "SCSI" :status :good :model "Imagery 9600 SP" :comment "sub model VM3552" :interface "SCSI" :status :untested ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "test" ; name of backend :version "1.0-28" ; version of backend :manpage "sane-test" ; name of manpage (if it exists) :url "http://www.meier-geinitz.de/sane/test-backend/" ; backend's web page :devicetype :api ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :desc "Frontend-tester" :comment "Backend for testing frontends. Also serves as example for SANE backend options." ; ; SANE Backend description file for U12 backend ; :backend "u12" :version "0.02" :manpage "sane-u12" :new :no ; backend's web page :url "http://www.gjaeger.de/scanner/u12/" :devicetype :scanner ;* Plustek ********************************************************************************** :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticPro U12" :interface "USB" :usbid "0x07b3" "0x0001" :status :basic :comment "Note: Only devices with product ID 0x0001 are supported!" :model "OpticPro UT12" :interface "USB" :usbid "0x07b3" "0x0001" :status :basic :comment "Note: Only devices with product ID 0x0001 are supported!" :model "OpticPro 1212U" :interface "USB" :usbid "0x07b3" "0x0001" :status :basic ;* RevScan ********************************************************************************** :mfg "RevScan" :model "RevScan Orange R48Ti" :interface "USB" :usbid "0x07b3" "0x0001" :status :basic :comment "Rebadged Plustek OpticPro UT12" ;* Genius/KYE ******************************************************************************************* :mfg "Genius" :url "http://www.geniusnet.com.tw/" :model "ColorPage HR6 V1" :interface "USB" :usbid "0x0458" "0x2004" :status :basic :model "ColorPage Vivid III USB" :interface "USB" :usbid "0x07b3" "0x0001" :status :untested :comment "Note: Device has Plustek vendor and product ID (0x07b3/0x0001)" ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "umax1220u" ; name of backend :version "unmaintained" ; version of backend ;:status :stable ; :alpha, :beta, :stable, :new :manpage "sane-umax1220u" ; name of manpage (if it exists) :url "http://sourceforge.net/projects/umax1220u-sane" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "UMAX" ; name a manufacturer :url "http://www.umax.com/" :model "Astra 1220U" ; name models for above-specified mfg. :interface "USB" :usbid "0x1606" "0x0010" :status :good :model "Astra 1600U" :interface "USB" :usbid "0x1606" "0x0030" :status :good :model "Astra 2000U" :interface "USB" :usbid "0x1606" "0x0030" :status :good :model "Astra 2100U" :interface "USB" :usbid "0x1606" "0x0130" :status :good ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "umax" ; name of backend :version "1.0-41" ; version of backend :manpage "sane-umax" ; name of manpage (if it exists) :url "http://www.rauch-domain.de/sane-umax/index.html" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "UMAX" ; name a manufacturer :url "http://www.umax.com/" :url "http://www.umax.com.tw/" :url "http://www.umax.de/en" :url "http://www.umax-europe.com" :url "http://www.umaxjapan.co.jp" :url "http://www.umax.com.cn" :model "Vista S6" :interface "SCSI" :status :good :comment "OK" :model "Vista S6E" :interface "SCSI" :status :good :comment "OK" :model "UMAX S-6E" :interface "SCSI" :status :good :comment "OK" :model "UMAX S-6EG" :interface "SCSI" :status :good :comment "OK" :model "Vista-S8" :interface "SCSI" :status :good :comment "OK" :model "Supervista S-12" :interface "SCSI" :status :good :comment "OK" :model "UMAX S-12" :interface "SCSI" :status :good :comment "OK" :model "UMAX S-12G" :interface "SCSI" :status :good :comment "OK" :model "Astra 600S" :interface "SCSI" :status :good :comment "OK" :model "Astra 610S" :interface "SCSI" :status :good :comment "OK" :model "Astra 1200S" :interface "SCSI" :status :good :comment "OK" :model "Astra 1220S" :interface "SCSI" :status :good :comment "OK" :model "Astra 2100S" :interface "SCSI" :status :good :comment "OK" :model "Astra 2200 (SU)" :interface "SCSI" :status :good :comment "OK" :model "Astra 2200 (SU)" :interface "USB" :usbid "0x1606" "0x0230" :status :good :comment "OK, needs USB control messages" :model "Astra 2400S" :interface "SCSI" :status :good :comment "OK" :model "Astra 6400" :interface "IEEE-1394" :status :unsupported :comment "will probably work one day" :model "Astra 6450" :interface "IEEE-1394" :status :unsupported :comment "will probably work one day" :model "Astra MX3" :interface "SCSI" :status :good :comment "OK" :model "Astra MX3" :interface "USB" :status :good :comment "OK, needs USB control messages" :model "Mirage D-16L" :interface "SCSI" :status :good :comment "OK" :model "Mirage II" :interface "SCSI" :status :good :comment "OK" :model "Mirage IIse" :interface "SCSI" :status :good :comment "OK" :model "PSD" :interface "SCSI" :status :good :comment "OK" :model "PowerLook" :interface "SCSI" :status :good :comment "OK, SCSI-ID=PS-2400X" :model "PL-II" :interface "SCSI" :status :good :comment "OK" :model "PowerLook III" :interface "SCSI" :status :good :comment "OK" :model "PowerLook 270" :interface "SCSI" :status :unsupported :comment "incompatible" :model "PowerLook 270plus" :interface "SCSI" :status :unsupported :comment "incompatible" :model "PowerLook 1100" :interface "IEEE-1394" :status :unsupported :comment "will probably work one day" :model "PowerLook 2000" :interface "SCSI" :status :good :comment "OK" :model "PowerLook 2100XL" :interface "SCSI" :status :good :comment "OK" :model "PowerLook 3000" :interface "SCSI" :status :good :comment "OK" :model "Gemini D-16" :interface "SCSI" :status :good :comment "OK" :model "UMAX VT600" :interface "SCSI" :status :untested :comment "may work, please test and give feedback" :model "Vista-T630" :interface "SCSI" :status :good :comment "OK for some firmwareversions, on others only lineart OK" :model "UC 630" :interface "SCSI" :status :good :comment "Version 2.8 OK, others only lineart OK" :model "UG 630" :interface "SCSI" :status :good :comment "OK" :model "UG 80" :interface "SCSI" :status :good :comment "OK" :model "UC 840" :interface "SCSI" :status :good :comment "Version 1.6 OK, others only lineart OK" :model "UC 1200S" :interface "SCSI" :status :untested :comment "may work, please test and give feedback" :model "UC 1200SE" :interface "SCSI" :status :good :comment "Version 3.0 OK, others unknown" :model "UC 1260" :interface "SCSI" :status :good :comment "Version 1.6 OK, others unknown" :mfg "Linotype Hell" ; another manufacturer... :url "http://www.heidelberg.com/" :model "Jade" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell Office" :model "Jade" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell JADE" :model "Jade2" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell Office2" :model "Saphir" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Saphir2" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell SAPHIR2" :model "Saphir3" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell SAPHIR3" :model "Saphir Ultra" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Saphir Ultra II" :interface "SCSI" :status :good :comment "OK, SCSI-ID=Linotype SAPHIR4" :model "Saphir HiRes" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Opal" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Opal2" :interface "SCSI" :status :good :comment "OK; SCSI-ID=LinoHell OPAL2" :model "Opal Ultra" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Linoscan 1400" :interface "SCSI" :status :good :comment "OK, SCSI-ID=HDM LS4H1S" :mfg "Vobis" :url "http://www.vobis.de/" :model "Highscreen Scanboostar Premium" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell Office2" :mfg "EDGE" ; another manufacturer... ; :url "http://???/" :model "KTX-9600US" :interface "SCSI" :status :untested :comment "no feedback" :mfg "Epson" ; another manufacturer... :url "http://www.epson.com/" :model "Perfection 600" :interface "SCSI" :status :good :comment "OK, SCSI-ID=EPSON Perfection600" :mfg "Escom" ; another manufacturer... :model "Image Scanner 256" :interface "SCSI" :status :good :comment "OK, SCSI-ID=UMAX UG 80" :mfg "Escort" ; another manufacturer... :model "Galleria 600" :interface "SCSI" :status :untested :comment "untested, SCSI-ID=ESCORT Galleria 600S" :mfg "Genius" ; another manufacturer... ;:url "http://www.genius.kye.de/" :model "ColorPage-HR5 (Pro)" :interface "SCSI" :status :good :comment "OK, SCSI-ID=KYE ColorPage-HR5" :mfg "Nikon" ; another manufacturer... :url "http://www.nikon.com/" :model "AX-110 / Scantouch 110" :interface "SCSI" :status :untested :comment "may work, please test and give feedback" :model "AX-210" :interface "SCSI" :status :good :comment "OK" :mfg "TriGem" ; another manufacturer... :url "http://www.nikon.com/" :model "PowerScanII" :interface "SCSI" :status :good :comment "OK" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "umax_pp" ; name of backend :version "1" ; version of backend :manpage "sane-umax_pp" ; name of manpage (if it exists) ; backend's web page :url "http://umax1220p.sourceforge.net/" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "UMAX" ; name a manufacturer :url "http://www.umax.com.tw/" ; These scanners are known to have the same ASIC family. :model "Astra 1220P" :interface "Parport (EPP/ECP)" :status :good :model "Astra 2000P" :interface "Parport (EPP/ECP)" :status :good :model "Astra 1600P" :interface "Parport (EPP/ECP)" :status :good :model "Astra 600P" :interface "Parport (SPP/ECP)" :status :unsupported :comment "untested, but should be close to 610P" :model "Astra 610P" :interface "Parport (SPP/ECP)" :status :good :mfg "Hewlett-Packard" :model "Scanjet 3200C" :interface "Parport (EPP/ECP)" :status :good :comment "works (relabelled 1220P and 2000P)" :mfg "Genius" :model "ColorPage-Life Pro" :interface "Parport (EPP/ECP)" :status :good :comment "works (relabelled 1220P and 2000P)" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "unsupported" ; name of backend :version "2010-06-09" ; version of backend :url "contrib.html" ;:manpage "sane-mustek" ; name of manpage (if it exists) :comment "The devices mentioned here are not supported by any SANE backend. However, there may be links to information about them or stand-alone programs." :devicetype :scanner ;******************************************************************************************** :mfg "Agfa" :model "DuoScan f40" :url "unsupported/agfa-duoscan-f40.html" :interface "USB IEEE-1394" :usbid "0x06bd" "0x02bf" :status :unsupported :comment "Unsupported. See link for details." :model "DuoScan T2000XL" :url "unsupported/agfa-duoscan-t2000xl.html" :interface "SCSI" :status :unsupported :comment "Unsupported. Same as Microtek ArtixScan 2020?" :model "DuoScan T2500" :interface "SCSI IEEE-1384" :status :unsupported :comment "Unsupported. Same as Microtek Artixscan 2500f" :model "SnapScan 310P" :url "unsupported/acer-parport.html" :interface "Parport" :status :unsupported :comment "Unsupported, see link for details." :model "SnapScan EZ" :url "unsupported/acer-parport.html" :interface "Parport" :status :unsupported :comment "Unsupported, see link for details." :model "SnapScan 1200P" :url "unsupported/acer-parport.html" :interface "Parport" :status :unsupported :comment "Unsupported, see link for details." :model "SnapScan 1212P" :url "unsupported/acer-parport.html" :interface "Parport" :status :unsupported :comment "Unsupported, see link for details." ;******************************************************************************************** :mfg "Artec/Ultima" :url "http://www.artecusa.com/" :model "1236 USB" :url "unsupported/artec_1236usb.html" :interface "USB" :usbid "0x05d8" "0x4001" :status :unsupported :comment "Unsupported. See link for details." :model "AM12e+" :status :unsupported :interface "Parport" :comment "Unsupported. Chips found inside: AT015, AD9816JS. Maybe similar to SCSI version or as6e?" :model "Ultima 2000 (0x4001)" :url "unsupported/artec-ultima-2000-2.html" :interface "USB" :usbid "0x05d8" "0x4001" :status :unsupported :comment "Same name, but different ids: This scanner is not supported. The scanner with product id 0x4002 is supported by the gt68xx backend, however." ;******************************************************************************************** :mfg "Avigramm" :model "Minidoc" :url "unsupported/trust-combiscan-19200.html" :interface "USB Parport" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** :mfg "Avision" :url "http://www.avision.com/" :model "DS310F" :interface "Parport" :status :unsupported :comment "Probably not supported. Scanner/printer/copier combination." :model "iVina FB2400" :interface "USB" :status :unsupported :comment "Not supported. No chipset information available. Same as UMAX Astra 6700." :model "iVina 1600" :url "unsupported/umax-astra-4500.html" :interface "USB" :usbid "0x0638" "0x0a10" :status :unsupported :comment "GL646 based, to be added to genesys backend. Same as UMAX Astra 4500." :model "iVina FB1800" :url "unsupported/umax-astra-4700.html" :interface "USB" :usbid "0x0638" "0x0a20" :status :unsupported :comment "GL646/GL660 based. Same as UMAX Astra 4700." ;******************************************************************************************** :mfg "Benq (Acer)" :url "http://www.benq.com" :comment "Formerly Acer Peripherals" :model "310P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "320P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "340P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "610P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "610PT" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "620P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "620PT" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "640P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "5450" :interface "USB" :usbid "0x04a5" "0x211e" :status :unsupported :comment "Unsupported." :model "5550" :url "unsupported/benq-5550.html" :interface "USB" :usbid "0x04a5" "0x2211" :status :unsupported :comment "Unsupported, see link for details." :model "5560" :interface "USB" :usbid "0x04a5" "0x2311" :status :unsupported :url "http://alioth-lists.debian.net/pipermail/sane-devel/2009-January/023447.html" :model "7400UT" :url "unsupported/benq-7400ut.html" :interface "USB" :usbid "0x04a5" "0x2202" :status :unsupported ;******************************************************************************************** :mfg "Boeder" :model "Sm@rtScan Office" :url "unsupported/trust-combiscan-19200.html" :interface "Parport USB" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Brother" :url "http://www.brother.com/" :model "MFC 2500" :url "unsupported/brother-mfc-2500.html" :interface "USB" :usbid "0x04f9" "0x000a" :status :unsupported :comment "Not supported. See link for details." :model "MFC 4600" :status :unsupported :url "http://sourceforge.net/projects/brother-mfc" :interface "Parport" :comment "The parport 200x400dpi grayscale version of this scanner is unsupported. Dmitri Katchalov did some investigations on this scanner. If you want to write a backend, contact him (see link)." :model "MFC 7300c" :url "unsupported/brother-mfc-7300.html" :interface "Parport USB" :usbid "0x04f9" "0x0106" :status :unsupported :model "MFC 9600" :url "unsupported/brother-mfc-9600.html" :interface "USB" :usbid "0x04f9" "0x0101" :status :unsupported ;******************************************************************************************** :mfg "C-Channel" :url "http://www.c-channel.ch/" :model "MyPen Pro" :url "unsupported/c-channel-mypen-pro.html" :interface "USB" ;:usbid "" "" :status :unsupported :comment "Probably unsupported. See link for details." :model "MyPen Light" :interface "USB" :usbid "0x0a93" "0x0005" :status :unsupported :comment "See bug #306792 for details." :model "MoneyPen II" ;:url "unsupported/c-channel-mypen-pro.html" :interface "USB" ;:usbid "" "" :status :unsupported :comment "Probably unsupported." ;******************************************************************************************** :mfg "Canon" :url "http://www.canon.com/" :model "CanoScan 3000" :url "unsupported/canon-3000.html" :interface "USB" :usbid "0x04a9" "0x2215" :status :unsupported :comment "GL660+GL646 based." :model "CanoScan 3000ex" :url "unsupported/canon-3000.html" :interface "USB" :usbid "0x04a9" "0x2215" :status :unsupported :comment "GL660+GL646 based." :model "CanoScan 3000F" :url "unsupported/canon-3000.html" :interface "USB" :usbid "0x04a9" "0x2215" :status :unsupported :comment "GL660+GL646 based, to be added to genesys backend" :model "CanoScan 4200F" :url "unsupported/canon-4200f.html" :interface "USB" :usbid "0x04a9" "0x221b" :status :unsupported :comment "Probably unsupported. See link." :model "CanoScan 4400F" :url "unsupported/canon-4400.html" :interface "USB" :usbid "0x04a9" "0x2228" :status :unsupported :comment "GL843 based, to be added to genesys backend" :model "CanoScan 5000F" :url "unsupported/canon-5000f.html" :interface "USB" :usbid "0x04a9" "0x2212" :status :unsupported :comment "Unsupported. See link for details." :model "CanoScan 5200F" :url "unsupported/canon-5200f.html" :interface "USB" :usbid "0x04a9" "0x2217" :status :unsupported :comment "Probably unsupported. See link for details." :model "CanoScan 8000F" :url "unsupported/canon-8000f.html" :interface "USB" :usbid "0x04a9" "0x220f" :status :unsupported :comment "Not supported. See link for more information. With transparency adapter." :model "CanoScan 8400F" :url "unsupported/canon-8400f.html" :interface "USB" :usbid "0x04a9" "0x221e" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "CanoScan 8600F" :url "unsupported/canon-8600.html" :interface "USB" :usbid "0x04a9" "0x2229" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "CanoScan 9900F" :url "unsupported/canon-9900f.html" :interface "USB" :usbid "0x04a9" "0x2210" :status :unsupported :comment "Probably unsupported, similar to 8000F. 3200x6400 dpi USB2. With transparency adapter." :model "CanoScan 9950F" :url "unsupported/canon-9950f.html" :interface "USB" :usbid "0x04a9" "0x2219" :status :unsupported :comment "Probably unsupported." :model "CanoScan D646U" :url "unsupported/canon-d646u.html" :interface "USB" :usbid "0x04a9" "0x220b" :status :unsupported :comment "Probably not supported. See link for more information and test program." :model "CanoScan D646U ex" :url "unsupported/canon-d646u.html" :interface "USB" :usbid "0x04a9" "0x220b" :status :unsupported :comment "Probably not supported. See D646." :model "CanoScan D1230U" :url "unsupported/canon-d1230u.html" :interface "USB" :usbid "0x04a9" "0x2209" :status :unsupported :comment "Probably not supported. " :model "CanoScan D1250U2" :url "unsupported/canon-d1250u2.html" :interface "USB" :usbid "0x04a9" "0x220c" :status :unsupported :comment "Not supported. However, someone started working on this scanner and some information is available (see link)." :model "CanoScan D2400UF" :url "unsupported/canon-d2400uf.html" :interface "USB" :usbid "0x04a9" "0x220a" :status :unsupported :comment "Not supported. See link." :model "CanoScan FB320U" :interface "USB" :usbid "0x04a9" "0x2201" :status :unsupported :comment "Probably not supported. No details known." :model "CanoScan FB620U" :url "unsupported/canon-fb620u.html" :interface "USB" :usbid "0x04a9" "0x2202" :status :unsupported :comment "Probably not supported. Some information is available." :model "CanoScan FB1210U" :url "http://sourceforge.net/projects/canonscanner/" :interface "USB" :usbid "0x04a9" "0x2205" :status :unsupported :comment "Not supported. However, a stand-alone program for FreeBSD is available." :model "CanoScan LiDE 70" :url "http://www.juergen-ernst.de/info_sane.html" :interface "USB" :usbid "0x04a9" "0x2225" :status :unsupported :comment "Philips chip. Backend started, see link" :model "CanoScan LiDE 80" :url "unsupported/canon-lide-80.html" :interface "USB" :usbid "0x04a9" "0x2214" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "CanoScan LiDE 90" :url "unsupported/canon-lide-90.html" :interface "USB" :usbid "0x04a9" "0x1900" :status :unsupported :comment "Unsupported. See link for details." :model "CanoScan LiDE 500F" :url "unsupported/canon-canoscan-lide-500f.html" :interface "USB" :usbid "0x04a9" "0x221f" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "CanoScan LiDE 600" :interface "USB" :url "http://www.juergen-ernst.de/info_sane.html" :usbid "0x04a9" "0x2224" :status :unsupported :comment "Philips chip. Backend started, see link" :model "CanoScan LiDE 600F" :interface "USB" :url "http://www.juergen-ernst.de/info_sane.html" :usbid "0x04a9" "0x2224" :status :unsupported :comment "Philips chip. Backend started, see link" :model "FS4000" :url "unsupported/canon-fs4000.html" :interface "USB SCSI" :usbid "0x04a9" "0x3042" :status :unsupported :comment "Not supported. See link for more details." :model "IS 12" :url "unsupported/canon-is-12.html" :interface "USB" :status :unsupported :comment "Probably not supported. Scanner cardridge for Canon inkjet printers." :model "IS 22" :url "unsupported/canon-is-22.html" :interface "Parport" :status :unsupported :comment "Probably not supported. Scanner cardridge for Canon inkjet printers." :model "IS 32" :url "unsupported/canon-is-32.html" :interface "USB" :usbid "0x04a9" "0x105d" :status :unsupported :comment "Probably not supported. Scanner cardridge for Canon inkjet printers." :model "IS 52" :url "unsupported/canon-is-52.html" :interface "USB" :status :unsupported :comment "Probably not supported. Scanner cardridge for Canon inkjet printers." :model "ImageRunner iR1018" :url "unsupported/canon-imagerunner.html" :interface "USB" :usbid "0x04a9" "0x269d" :status :unsupported :comment "Probably not supported. See link for details." :model "ImageRunner iR1022" :url "unsupported/canon-imagerunner.html" :interface "USB" :usbid "0x04a9" "0x269d" :status :unsupported :comment "Probably not supported. See link for details." :model "ImageRunner iR1023" :url "unsupported/canon-imagerunner.html" :interface "USB" :usbid "0x04a9" "0x269d" :status :unsupported :comment "Probably not supported. See link for details." :model "PIXMA MP110" :url "unsupported/canon-pixma-mp110.html" :interface "USB" :usbid "0x04a9" "0x1700" :status :unsupported :comment "Probably not supported. See link for details." :model "PIXMA MP130" :url "unsupported/canon-pixma-mp130.html" :interface "USB" :usbid "0x04a9" "0x1701" :status :unsupported :comment "Probably not supported. See link for details." :model "DR-2020U" :interface "USB" :status :unsupported :comment "GL84x?" ;******************************************************************************************** :mfg "Chinon" :model "DS-3000" :url "unsupported/chinon-ds3000.html" :interface "Parport Serial Port" :status :unsupported :comment "Unsupported at the moment, but a backend is in preparation. See link." ;******************************************************************************************** :mfg "Compaq" :url "http://www.compaq.com/" :model "S200" :interface "USB" :usbid "0x049f" "0x0021" :status :unsupported :comment "Not supported. 2400x1200 dpi. One bulk-in, one bulk-out and one interrupt endpoint. Type-number: U0001-HB21, another type nr on the inside: 75100512-00" ;******************************************************************************************** :mfg "Compeye" :model "Simplex 1236C" :url "unsupported/trust-combiscan-19200.html" :interface "Parport USB" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Corex" :url "http://www.cardscan.com/" :model "Cardscan 500" :url "unsupported/corex-cardscan-500.html" :interface "USB" :usbid "0x08f0" "0x0001" :status :unsupported :comment "Probably not supported. Businesscard reader." :model "Cardscan 700 C" :url "unsupported/corex-cardscan-700.html" :interface "USB" :usbid "0x08f0" "0x0004" :status :unsupported :comment "Probably not supported." ;******************************************************************************************** :mfg "Dell" :url "http://www.dell.com/" :model "A940" :interface "USB" :usbid "0x413c" "0x5106" :status :unsupported :comment "Probably rebadged Lexmark X5150. May work with sane-lexmark? See bug #312130" :model "A960" :url "unsupported/dell-a960.html" :interface "USB" :usbid "0x413c" "0x5107" :status :unsupported :comment "Probably not supported. See link for details." :model "922" :url "unsupported/dell-922.html" :interface "USB" :usbid "0x413c" "0x5109" :status :unsupported :comment "Probably not supported. See link for details." ;******************************************************************************************** :mfg "Epson" :url "http://www.epson.com/" :model "GT-2200" :interface "USB" :usbid "0x04b8" "0x0102" :status :unsupported :comment "Probably unsupported. No details known." :model "StylusScan 2000" :interface "USB" :usbid "0x04b8" "0x0105" :status :unsupported :comment "Probably unsupported. No details known." :model "Stylus DX4450" :url "unsupported/epson-stylus-dx4450.html" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "Probably unsupported. See link for details." :model "Stylus CX-5800" :interface "USB" :status :unsupported :comment "Probably unsupported at the moment. Not compatible to snapscan backend. It's not known if it may work with epson or epkowa backend." ;******************************************************************************************** :mfg "EDT (Electronic Document Technology)" :url "http://www.bizcardreader.com/" :model "BizCardReader 900C" :url "unsupported/edt-900c.html" :interface "USB" :usbid "0x0a53" "0x5001" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "E-Lux" :comment "E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX" :model "j-6121" :interface "Parport" :status :unsupported :comment "Probably unsupported. Sold 1998. Same as E-Lux j-6121." ;******************************************************************************************** :mfg "Enhans" :comment "E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX" :model "j-6121" :interface "Parport" :status :unsupported :comment "Probably unsupported. Sold 1998. Same as E-Lux j-6121." :model "M-3630 A" :interface "Parport" :status :unsupported :comment "Probably unsupported. " ;******************************************************************************************** :mfg "Genius" :url "http://www.geniusnet.com.tw/" :url "http://www.genius-kye.com/" :model "ColorPage CS" :url "unsupported/genius-colorpage-cs.html" :interface "SCSI" :status :unsupported :comment "Probably unsupported, see link for details." :model "ColorPage-Slim 1200 USB2" :url "unsupported/genius-colorpage-slim-1200-usb2.html" :interface "USB" :usbid "0x0458" "0x2020" :status :unsupported :comment "GL841 based, to be added to genesys backend." :model "ColorPage HR6X Slim" :url "unsupported/genius-colorpage-hr6x.html" :interface "USB" :usbid "0x0458" "0x2019" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "ColorPage HR7X" :url "unsupported/genius-colorpage-hr7x.html" :interface "USB" :usbid "0x0458" "0x2018" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "ColorPage HR7XE" :url "unsupported/genius-colorpage-hr7xe.html" :interface "USB" :usbid "0x06dc" "0x0012" :status :unsupported :comment "Unsuported. See link for details." :model "ColorPage HR8" :url "unsupported/genius-colorpage-hr8.html" :interface "USB" :usbid "0x0458" "0x201c" :status :unsupported :comment "GL841 based, to be added to genesys backend" ;******************************************************************************************** :mfg "Guillemot" ; name a manufacturer :model "SCAN@HOME 48 USB" :url "unsupported/teco-vm6509.html" :interface "USB" :usbid "0x080d" "0x0102" :status :unsupported :comment "Probably unsupported. See link for details." :model "Maxi Scan A4 Parallel 36 bit" :interface "Parport" :status :unsupported :comment "Probably unsupported. Identical to the Benq Prisa 620P." ;******************************************************************************************** :mfg "Hercules" ; name a manufacturer :model "SCAN@HOME 48 USB" :url "unsupported/teco-vm6509.html" :interface "USB" :usbid "0x080d" "0x0102" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "Photo Scanner 1000" :url "unsupported/hp-photo-1000.html" :interface "USB" :usbid "0x03f0" "0x1001" :status :unsupported :comment "Not supported by SANE. However, it's detected as mass storage device so just mounting it is reported to work. See link for device data." :model "Photosmart 1200 Photo" :interface "USB" :status :unsupported :comment "Probably not supported by SANE. No details known. 10x15 cm. Maybe similar to Photo Scanner 1000?" :model "Photosmart S20 (C5101A)" :url "unsupported/hp-photosmart-s20xi.html" :interface "USB" :usbid "0x03f0" "0x0102" :status :unsupported :comment "Not supported yet by SANE. See link for details." :model "Photosmart S20xi (C7150A)" :url "unsupported/hp-photosmart-s20xi.html" :interface "USB" :usbid "0x03f0" "0x0102" :status :unsupported :comment "Not supported yet by SANE. See link for details." :model "Photosmart C5100 series" :url "unsupported/hp-photosmart-5100.html" :interface "USB" :usbid "0x03f0" "0x5811" :status :unsupported :comment "Not supported yet by SANE. See link for details." :model "ScanJet 2400c" :url "unsupported/hp-scanjet-2400c.html" :interface "USB" :usbid "0x03f0" "0x0a01" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "Photosmart C3180" :url "unsupported/hp-photosmart-3180.html" :interface "USB" :usbid "0x03f0" "0x5611" :status :unsupported :comment "Not supported yet by SANE. See link for details." :model "ScanJet 3770" :status :unsupported :interface "USB" :usbid "0x03f0" "0x2505" :comment "While an external binary-only backend exists, it works only on Linux i386. Therefore the scanner is unsupported on other platforms." :model "ScanJet 4600" :url "unsupported/hp-scanjet-4600.html" :interface "USB" :usbid "0x03f0" "0x3005" :comment "Not supported. See link for details, or http://www.chmil.org/hp4600linux/ for code" :status :unsupported :model "ScanJet 4670" :interface "USB" :usbid "0x03f0" "0x3005" :comment "Not supported. See ScanJet 4600 entry." :status :unsupported :model "ScanJet 4850C" :url "unsupported/hp-scanjet-4850.html" :interface "USB" :usbid "0x03f0" "0x1b05" :comment "GL841, maybe can be added to genesys backend " :status :unsupported :model "ScanJet 4890C" :url "unsupported/hp-scanjet-4850.html" :interface "USB" :usbid "0x03f0" "0x1b05" :comment "GL843, maybe can be added to genesys backend " :status :unsupported :model "ScanJet 5530C Photosmart" :url "unsupported/hp-scanjet-5530.html" :interface "USB" :usbid "0x03f0" "0x1605" :comment "Maybe GL841_HP, but not confirmed, maybe can be added to genesys backend" :status :unsupported :model "ScanJet 8390" :url "unsupported/hp-scanjet-8390.html" :interface "USB" :usbid "0x03f0" "0x3805" :comment "Probably not supported. See link for details." :status :unsupported :model "ScanJet G4000" :url "unsupported/hp-g4000.html" :interface "USB" :usbid "0x03f0" "0x4505" :comment "Probably not supported. See link for details." :status :unsupported ;******************************************************************************************** :mfg "IBM" :url "http://www.ibm.com" :model "ADF Color Scanner" :interface "Proprietary" :status :unsupported :comment "Unsupported. Uses proprietary ISA card. Maybe the same as the Plustek Spectra ADF?" ;******************************************************************************************** :mfg "IOMagic" :url "http://www.iomagic.com/" :model "MobileScan USB" :url "unsupported/trust-combiscan-19200.html" :interface "USB Parport" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Iris" :url "http://irislink.com/" :model "IriScan" :url "unsupported/iris-iriscan.html" :interface "USB" :usbid "0x0a53" "0x1000" :status :unsupported :comment "Unsupported. LM9832/3. See link for details." :model "IRISPen Translator Executive" :url "unsupported/iris-irispen-translator.html" :interface "USB" :usbid "0x0f43" "0x015a" :status :unsupported :comment "Unsupported. See link for details." :model "IRISCard Pro (IBCR II)" :url "unsupported/iris-business.html" :interface "USB" :usbid "0x0a38" "0x0301" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Kodak" :url "http://www.kodak.com" :model "Snapshot Photo Scanner 1" :interface "Parport" :status :unsupported :comment "Unsupported. FCC ID HWF96PHS" ;******************************************************************************************** :mfg "Lexmark" :url "http://www.lexmark.com/" :model "P6250" :url "unsupported/lexmark-p6250.html" :interface "USB" :usbid "0x043d" "0x0097" :status :unsupported :comment "Unsupported. See link for details." :model "Photo 3150" :url "unsupported/lexmark-3150.html" :interface "USB" :usbid "0x043d" "0x007d" :status :unsupported :comment "Unsupported. See link for details." :model "X74" :url "unsupported/lexmark-x75.html" :interface "USB" :usbid "0x043d" "0x0060" :status :unsupported :comment "Unsupported. See link for details." :model "X75" :url "unsupported/lexmark-x75.html" :interface "USB" :usbid "0x043d" "0x0060" :status :unsupported :comment "Unsupported. See link for details." :model "X75 PrinTrio" :url "unsupported/lexmark-x75.html" :interface "USB" :usbid "0x043d" "0x0060" :status :unsupported :comment "Unsupported. See link for details." :model "X83" :url "unsupported/lexmark-x83.html" :interface "USB" :usbid "0x043d" "0x003d" :status :unsupported :comment "Unsupported. GL640." :model "X2330" :url "unsupported/lexmark-x2330.html" :interface "USB" :usbid "0x043d" "0x00bb" :status :unsupported :comment "Unsupported. See link for details." :model "X3450" :url "unsupported/lexmark-x3450.html" :interface "USB" :usbid "0x043d" "0x00f6" :status :unsupported :comment "Unsupported. See link for details." :model "X5130" :url "unsupported/lexmark-x5130.html" :interface "USB" :usbid "0x043d" "0x0065" :status :unsupported :comment "Unsupported." :model "X5150" :url "unsupported/lexmark-x5130.html" :interface "USB" :usbid "0x043d" "0x0065" :status :unsupported :comment "Probably unsupported. See link for details." :model "X5250" :url "unsupported/lexmark-x5250.html" :interface "USB" :usbid "0x043d" "0x0093" :status :unsupported :comment "Unsupported." :model "X6170" :url "unsupported/lexmark-x6170.html" :interface "USB" :usbid "0x043d" "0x0072" :status :unsupported :comment "Unsupported. See link for details." :model "X7170" :interface "USB" :usbid "0x043d" "0x0098" :status :unsupported :comment "Unsupported. See bug #310889 for details." :model "X7350" :url "unsupported/lexmark-x7350.html" :interface "USB" :usbid "0x043d" "0x00b8" :status :unsupported :comment "Unsupported. See link for details." :model "X8350" :url "unsupported/lexmark-x8350.html" :interface "USB" :usbid "0x043d" "0x00b9" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Logitech" :model "PageScan Color" :interface "Parport" :status :unsupported :comment "Most probably unsupported." :model "PageScan USB" :url "unsupported/logitech-pagescan-usb.html" :interface "USB" :usbid "0x046d" "0x040f" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.com/" :url "http://www.medion.de/" :model "MD 6190" :url "unsupported/medion-md6190.html" :interface "USB" :usbid "0x0461" "0x0392" :status :unsupported :comment "Probably unsupported. There seem to exist two different scanners with that name. See link for details." :model "MD 6190" :url "unsupported/medion-md6190.html" :interface "USB" :usbid "0x0461" "0x037b" :status :unsupported :comment "Probably unsupported. There seem to exist two different scanners with that name. See link for details." :model "MD 40420" :url "unsupported/tevion-md40420.html" :interface "USB" :usbid "0x05da" "0x3008" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 41260" :url "unsupported/medion-md6190.html" :interface "USB" :usbid "0x0461" "0x037b" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 41985" :url "unsupported/medion-md6190.html" :interface "USB" :usbid "0x0461" "0x037b" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 42666" :url "unsupported/tevion-md40420.html" :interface "USB" :usbid "0x05da" "0x3008" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 85264" :url "http://gkall.hobby.nl/authentec.html" :interface "USB" :usbid "0x08ff" "0x2580" :status :unsupported :comment "Fingerprint sensor. See link for details." :model "MD 90009" :url "unsupported/tevion-md90009.html" :interface "USB" :usbid "0x05da" "0x30e5" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 90070" :url "unsupported/tevion-md90070.html" :interface "USB" :usbid "0x05da" "0x3022" :status :unsupported :comment "Unsupported. See link for details." :model "MD 90090" :url "unsupported/tevion-md90070.html" :interface "USB" :usbid "0x05da" "0x3022" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Memorex" :url "http://www.memorex.com/" :model "6136u" :url "unsupported/memorex-maxx-6136u.html" :interface "USB" :usbid "0x0461" "0x0346" :status :unsupported :comment "Probably unsupported." :model "6142u" :url "unsupported/visioneer-onetouch4400.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Probably unsupported. Same as Visioneer Onetouch 4400. See link for details." :model "MaxxScan 6122" :url "unsupported/trust-combiscan-19200.html" :interface "USB Parport" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." :model "SCF 9612P" :url "unsupported/memorex-scf-9612p.html" :interface "Parport" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Microtek" :url "http://www.microtek.com/" :model "ArtixScan 2020" :interface "SCSI" :status :unsupported :comment "Unsupported. Same as Agfa DuoScan T2000XL?" :model "ArtixScanDI 2020" :url "unsupported/microtek-artixscan-2020.html" :interface "USB" :usbid "0x05da" "0x202e" :status :unsupported :comment "Unsupported. See link for details." :model "Artixscan 2500f" :interface "SCSI IEEE-1384" :status :unsupported :comment "Unsupported. Same as Agfa DuoScan T2500?" :model "ArtixScan 4000tf" :interface "USB" :status :unsupported :comment "Unsupported. Uses ALI M5611B." :model "FilmScan 35" :url "unsupported/microtek-filmscan-35.html" :interface "USB" :usbid "0x05e3" "0x0120" :status :unsupported :comment "Probably unsupported. See link for details." :model "ScanMaker 336 CX" :interface "SCSI" :status :unsupported :comment "Probably unsupported. Seems to be similar to the Microtek 330 CX and is detected by the microtek2 backend. Scanning doesn't seem to work however." :model "Scanmaker 1850S" :url "unsupported/microtek-scanmaker-1850s.html" :interface "SCSI" :status :unsupported :comment "Unsupported. See link for details." :model "ScanMaker 3630" :url "unsupported/microtek-scanmaker-3630.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Unsupported. Doesn't seem to be compatible to 3600 series, see link." :model "ScanMaker 3800" :url "unsupported/microtek-scanmaker-3800.html" :interface "USB" :usbid "0x05da" "0x30ce" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 3830" :url "unsupported/microtek-scanmaker-3830.html" :interface "USB" :usbid "0x05da" "0x30ce" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 3860" :url "unsupported/microtek-scanmaker-3880.html" :interface "USB" :usbid "0x05da" "0x3023" :status :unsupported :comment "Unsupported. See link for more details. Appears to be similar to ScanMaker 3880." :model "ScanMaker 3880" :url "unsupported/microtek-scanmaker-3880.html" :interface "USB" :usbid "0x05da" "0x3021" :status :unsupported :comment "Unsupported. SQ113 chip. See link for more details." :model "ScanMaker 4600" :url "unsupported/microtek-scanmaker-4600.html" :interface "USB" :usbid "0x05da" "0x40c7" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 4700" :url "unsupported/microtek-scanmaker-4700.html" :interface "USB" :usbid "0x05da" "0x20b4" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 4850" :url "unsupported/microtek-scanmaker-4900.html" :interface "USB" :usbid "0x05da" "0x30d9" :status :unsupported :comment "Probably unsupported. See link for details." :model "ScanMaker 4850 II" :url "unsupported/microtek-scanmaker-4850-2.html" :interface "USB" :usbid "0x05da" "0x3008" :status :unsupported :comment "Probably unsupported. See link for details." :model "ScanMaker 4900" :url "unsupported/microtek-scanmaker-4900.html" :interface "USB" :usbid "0x05da" "0x30b9" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 5" :url "unsupported/microtek-scanmaker-5600.html" :interface "SCSI" :status :unsupported :comment "Probably unsupported. See link for more details." :model "ScanMaker 5600" :url "unsupported/microtek-scanmaker-5600.html" :interface "USB" :usbid "0x05da" "0x20a7" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 5700" :interface "USB" :usbid "0x05da" "0x20bd" :status :unsupported :comment "Unsupported. Uses ALI M5615 like the ScanMaker 4700." :model "ScanMaker 5800" :url "unsupported/microtek-scanmaker-5800.html" :interface "USB" :usbid "0x05da" "0x3008" :status :unsupported :comment "Unsupported. See link for details." :model "ScanMaker 5800" :url "unsupported/microtek-scanmaker-5800.html" :interface "USB" :usbid "0x05da" "0x30d8" :status :unsupported :comment "Unsupported. See link for details." :model "ScanMaker 5900" :url "unsupported/microtek-scanmaker-5900.html" :interface "USB" :usbid "0x05da" "0x30d8" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 5950" :url "unsupported/microtek-scanmaker-5950.html" :interface "USB" :usbid "0x05da" "0x30d8" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 6000" :url "unsupported/microtek-scanmaker-6000.html" :interface "USB" :usbid "0x05da" "0x30e5" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 6100" :url "unsupported/microtek-scanmaker-6100.html" :interface "USB" :usbid "0x05da" "0x30e5" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 6700" :url "unsupported/microtek-scanmaker-6700.html" :interface "USB IEEE-1394" :usbid "0x05da" "0x20c9" :status :unsupported :comment "Unsupported. See link." :model "ScanMaker 8700" :status :unsupported :url "unsupported/microtek-scanmaker-8700.html" :interface "USB IEEE-1394" :usbid "0x05da" "0x20b1" :comment "Unsupported. See link for details. USB vendor and product ids to be checked." :model "ScanMaker 9600XL" :interface "USB IEEE-1394" :usbid "0x05da" "0x20de" :status :unsupported :comment "Probably unsupported. SCSI seems to work with microtek2 backend." :model "ScanMaker 9800XL" :url "unsupported/microtek-scanmaker-9800.html" :interface "USB SCSI" :usbid "0x05da" "0x20de" :status :unsupported :comment "Partly unsupported. IEEE-1394 works with microtek2 backend. See link." :model "ScanMaker i320" :url "unsupported/microtek-scanmaker-i320.html" :interface "USB" :usbid "0x05da" "0x30e6" :status :unsupported :comment "Unsupported. See link." :model "ScanMaker s400" :url "unsupported/microtek-scanmaker-s400.html" :interface "USB" :usbid "0x05da" "0x201c" :status :unsupported :comment "Unsupported. See link." :model "ScanMaker S400" :url "unsupported/microtek-scanmaker-s400.html" :interface "USB" :usbid "0x05da" "0x300b" :status :unsupported :comment "Unsupported. See link." :model "ScanPort 3000" :url "unsupported/microtek-scanport-3000.html" :interface "USB" :usbid "0x04a7" "0x0224" :status :unsupported :comment "Unsupported. Vendor/Product ids: 0x04a7/0x0224. Realtek RTS8801B?. See link for details." ;******************************************************************************************** :mfg "Konica Minolta" :url "http://www.konicaminolta.com/" :model "Dual Scan III" :url "unsupported/minolta-dual-scan-III.html" :interface "USB" :usbid "0x0686" "0x400d" :status :unsupported :comment "Unsupported. May work with vuescan. See link for details." :model "Dual Scan IV" :url "unsupported/minolta-dual-scan-IV.html" :interface "USB" :usbid "0x132b" "0x000a" :status :unsupported :comment "Unsupported. Works with vuescan. See link for details." :model "DiMAGE Scan Elite 5400" :url "unsupported/minolta-dse-5400.html" :interface "USB IEEE-1394" :usbid "0x0686" "0x400e" :status :unsupported :comment "Probably unsupported. May work with vuescan. See link for details." :model "DiMAGE Scan Elite 5400 2" :url "unsupported/minolta-dse-5400-2.html" :interface "USB" :usbid "0x132b" "0x0012" :status :unsupported :comment "Probably unsupported. See link for details." :model "DiMAGE Scan Multi Pro" :url "unsupported/minolta-dimage-scan-multi-pro.html" :interface "IEEE-1394" :status :unsupported :comment "Probably unsupported. See link for details." :model "magicolor 2480MF" :interface "USB Network" :status :unsupported :comment "Uses a different scanning protocol than the magicolor 1690MF" ;******************************************************************************************** :mfg "Mustek" ; name a manufacturer :url "http://www.mustek.com/" :url "http://www.mustek.de/" :url "http://www.mustek.com.tw/" :model "1200 III EP" :interface "Parport" :status :unsupported :comment "Probably not supported. quarlewm at jmu dot edu offers to temporarily loan such a scanner to anyone who is interested in writing a driver." :model "2400 M" :interface "USB" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :status :unsupported :comment "Probably unsupported. No details known." :model "BearPaw 2400 TA Pro" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x0400" :comment "Not supported. May be supported by mustek_usb2 backend later. See link for some information." :status :unsupported :model "BearPaw 2448 CU Pro" :url "unsupported/mustek-bearpaw-2448-cu-pro.html" :usbid "0x055f" "0x0408" :interface "USB" :comment "Not supported. May be supported by mustek_usb2 backend later. See link for some information." :status :unsupported :model "BearPaw 4800 TA Pro" :url "unsupported/mustek-bearpaw-4800ta-pro.html" :interface "USB" :usbid "0x055f" "0x1000" :comment "Not supported. See link for some information." :status :unsupported :model "BearPaw 4800 TA Pro II" :url "unsupported/mustek-bearpaw-4800ta-pro-ii.html" :interface "USB" :usbid "0x055f" "0x040a" :comment "Not supported. May be supported by mustek_usb2 backend later. See link for some information." :status :unsupported :model "BearPaw 6400 TA Pro" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x040b" :comment "Not supported. May be supported by mustek_usb2 backend later. See link for some information." :status :unsupported :model "Paragon 800 II EP" :interface "Parport" :status :unsupported :comment "Not supported. Maybe similar to 600 II EP (SCSI_over-parport)? In this case it could be supported by the mustek SCSI backend." :model "ScanExpress 600 USB" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x0873" :status :unsupported :comment "Unsupported. Programming information is available." :model "ScanExpress 1200 USB" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x0003" :status :unsupported :comment "Unsupported. Programming information is available." :model "ScanExpress 1200 USB Plus" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x0007" :status :unsupported :comment "Unsupported." :model "ScanExpress 12000 P" :url "http://penguin-breeder.org/?page=mustek_pp" :interface "Parport" :status :unsupported :comment "Not supported. Asic 1505/05." :model "ScanExpress A3 EP" :interface "Parport" :status :unsupported :comment "Not supported. Maybe it will be supported by the mustek_pp backend in future." :model "ScanExpress CardSmart" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :status :unsupported :comment "Probably unsupported. USB business card scanner. Maybe works as USB storage device?" :model "ScanMagic 9636P" :url "http://alioth-lists.debian.net/pipermail/sane-devel/2003-May/007682.html" :interface "Parport" :status :unsupported :comment "Probably not supported. Same as Mustek 12000 P?. ASIC 1505." ;******************************************************************************************** :mfg "NEC" :url "http://www.nevt.co.jp/" :model "Petiscan" :url "unsupported/nec-petiscan.html" :interface "USB" :usbid "0x0475" "0x0100" :status :unsupported :comment "Most probably unsupported. See link for details. Vendor ID is Relisys/Teco. Not known if it is similar to other Relisys/Teco USB scanners." ;******************************************************************************************** :mfg "Nikon" :url "http://www.nikon.com/" :model "LS-9000 ED" :url "unsupported/nikon-ls9000-ed.html" :interface "IEEE-1394" :status :unsupported :comment "Probably not supported. See link for details. Possibly similar to LS-8000 ED." ;******************************************************************************************** :mfg "Olivetti" :url "http://www.olivetti.com" :model "Job-Jet M400" :url "unsupported/olivetti-job-jet-m400.html" :interface "USB" :usbid "0x0b3c" "0xa880" :status :unsupported :comment "Probably not supported. See link for details." ;******************************************************************************************** :mfg "Olympus" :url "http://www.olympus.com" :model "ES-10P" :url "http://alioth-lists.debian.net/pipermail/sane-devel/2008-December/023326.html" :interface "Parport" :status :unsupported :model "ES-10S" :url "unsupported/olympus-es10s.html" :interface "SCSI" :status :unsupported :comment "Probably not supported. See link for details." ;******************************************************************************************** :mfg "Optoelectronics" :model "Barcode scanner" :interface "USB" :usbid "0x065a" "0x0001" :status :unsupported :comment "Probably not supported." ;******************************************************************************************** :mfg "Optrox" :model "PhotoMaker 3C" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Parport" :status :unsupported :model "PhotoMaker 3E" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Parport" :status :unsupported :model "PhotoMaker 3F" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Proprietary" :status :unsupported :comment "Special ISA card" :model "PhotoMaker 3S" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Parport" :status :unsupported :model "PhotoMaker 6E" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Parport" :status :unsupported :model "PhotoMaker 6F" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Proprietary" :status :unsupported :comment "Special ISA card" ;******************************************************************************************** :mfg "Panasonic" :model "KV-SS905C" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool." :model "KV-S2055W" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S2055L" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S2065W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S3065CW" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S3065CL" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S3085" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S3105C" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool." :model "KV-S6040W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S6045W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S6050W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S6055W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S7065C" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." ;******************************************************************************************** :mfg "Pentax" :model "DSmobile USB" :url "unsupported/syscan-travelscan-pro.html" :interface "USB" :usbid "0x0a82" "0x2000" :status :unsupported :comment "Probably not supported. Some information is available." ;******************************************************************************************** :mfg "PIE" :url "http://www.scanace.com/" :comment "Pacific Image Electronics" :model "Primefilm 1800u" :url "unsupported/pie-1800u.html" :interface "USB" :usbid "0x05e3" "0x0120" :status :unsupported :comment "Not supported. See link for details." :model "Primefilm 2700" :interface "USB" :status :unsupported :url "http://alioth-lists.debian.net/pipermail/sane-devel/2009-January/023442.html" :model "Primefilm 3600PRO" :interface "USB IEEE-1394" :status :unsupported :comment "Probably not supported. " :model "Powerslide 3600" :url "unsupported/reflecta-digitdia-3600.html" :interface "USB IEEE-1394" :usbid "0x05e3" "0x0142" :status :unsupported :comment "Probably unsupported. Film scanner that can scan directly from the magazine." :model "PF3650 Pro3 Film Scanner" :url "unsupported/pie-pf3650.html" :interface "USB IEEE-1394" :usbid "0x05e3" "0x0143" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** ;:mfg "Packard Bell" ;******************************************************************************************** :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticFilm 7200" :url "unsupported/plustek-opticfilm-7200.html" :interface "USB" :usbid "0x07b3" "0x0807" :status :unsupported :comment "GL842 based, maybe to be added to genesys backend" :model "OpticFilm 7200i" :interface "USB" :usbid "0x07b3" "0x0c04" :status :unsupported :comment "GL843 based, maybe to be added to genesys backend" :model "OpticPro A3U" :interface "USB" :status :unsupported :comment "Uses Plustek ASIC P99002" :model "OpticPro S6" :interface "USB" :status :unsupported :comment "Uses RealTek chipset (RTL8801D)" :model "OpticPro S12" :url "unsupported/plustek-opticpro-st12.html" :interface "USB" :usbid "0x07b3" "0x0600" :status :unsupported :comment "Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend." :model "OpticPro ST12" :url "unsupported/plustek-opticpro-st12.html" :interface "USB" :usbid "0x07b3" "0x0600" :status :unsupported :comment "Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend." :model "OpticPro ST16" :url "unsupported/plustek-opticpro-st16.html" :interface "USB" :usbid "0x07b3" "0x0600" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "OpticPro UA18" :interface "USB" :status :unsupported :comment "Probably LM983x based." :model "OpticPro S24" :url "unsupported/plustek-opticpro-st24.html" :interface "USB" :usbid "0x07b3" "0x0601" :status :unsupported :comment "Product id 0x0601 is unsupported but may be supported by the genesys backend in future /GL646). Product id 0x040e is supported by the gt68xx backend." :model "OpticPro ST24" :url "unsupported/plustek-opticpro-st24.html" :interface "USB" :usbid "0x07b3" "0x0601" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "OpticPro S28" :interface "USB" :url "unsupported/plustek-opticpro-s28.html" :usbid "0x07b3" "0x0801" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticPro ST28" :url "unsupported/plustek-opticpro-s28.html" :interface "USB" :usbid "0x07b3" "0x0801" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticPro ST28" :url "unsupported/plustek-opticpro-st28.html" :interface "USB" :usbid "0x07b3" "0x0802" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "Umax AstraScan 4750" :url "unsupported/umax-astrscan-4750.html" :interface "USB" :usbid "0x07b3" "0x0802" :status :unsupported :comment "GL841 based, to be added to genesys backend, rebadged Plustek ST28" :model "OpticPro ST48" :url "unsupported/plustek-opticpro-st48.html" :interface "USB" :usbid "0x07b3" "0x0800" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticPro ST64" :url "unsupported/plustek-opticpro-st64.html" :interface "USB" :usbid "0x07b3" "0x0c00" :status :unsupported :comment "GL843 based, maybe to be added to genesys backend" :model "OpticPro ST64+" :url "unsupported/plustek-opticpro-st64plus.html" :interface "USB" :usbid "0x07b3" "0x0c03" :status :unsupported :comment "GL843 based. See link for more details." :model "PL 806" :url "unsupported/plustek-pl806.html" :interface "USB" :usbid "0x07b3" "0x0c0c" :status :unsupported :comment "Unsupported. See link for more details." :model "SmartOffice PL 812" :url "unsupported/plustek-pl812.html" :interface "USB" :usbid "0x07b3" "0x0c0d" :status :unsupported :comment "Unsupported. See link for more details." :model "OpticSlim 500" :url "unsupported/plustek-opticslim-500.html" :interface "USB" :usbid "0x07b3" "0x0458" :status :unsupported :comment "Unsupported. See link for more details." :model "OpticSlim 2420" :url "unsupported/plustek-opticslim-2420.html" :interface "USB" :usbid "0x07b3" "0x0806" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticSlim 2420+" :url "unsupported/plustek-opticslim-2420plus.html" :interface "USB" :usbid "0x07b3" "0x0914" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticWorks 2000" :interface "Parport" :status :unsupported :comment "Multifunction device. No further information available." :model "OptiCard 600+" :interface "USB" :status :unsupported :comment "Business card reader. No further information available." :model "ScanCopy 115" :url "unsupported/plustek-scancopy-115.html" :interface "USB" :usbid "0x07b3" "0x081c" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "Spectra ADF" :interface "Proprietary" :status :unsupported :comment "Unsupported. Uses proprietary ISA card that also provides power and is labelled GPS-1 PAGE-A from Taiwan. Other labels on the scanner include ADF Color Scanner and SF600AS. Maybe the same as the IBM ADF Color Scanner?" :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0005" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0007" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x000f" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0012" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0014" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0016" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." ;******************************************************************************************** :mfg "PLANon" :url "http://www.planon.com/" :model "DocuPen RC800" :interface "USB" :status :unsupported :comment "Probably not supported. No details known." :model "DocuPen R700" :url "unsupported/planon-docupen-r700.html" :interface "USB" :usbid "0x10c4" "0xea60" :status :unsupported :comment "Probably not supported. See link for details." :model "DocuPen (DPEN-BW)" :interface "USB" :status :unsupported :comment "Probably not supported. No details known." ;******************************************************************************************** :mfg "Primax" :url "http://www.primax.nl/" :model "Colorado 600U" :url "unsupported/primax-colorado-600u.html" :interface "USB" :usbid "0x0461" "0x0341" :status :unsupported :comment "Not supported. Some information is available." :model "Colorado 1200p" :interface "Parport" :url "http://home2.swipnet.se/~w-25069/pxscan.html" :status :unsupported :comment "Unsupported by SANE. But is reported to partly work with pxscan. See link." :model "Colorado 1200u" :interface "USB" :usbid "0x0461" "0x0361" :status :unsupported :comment "Probably unsupported. No details known." :model "Primascan Colorado 2600u" :url "unsupported/visioneer-onetouch4400.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Unsupported. Same as Visioneer Onetouch 4400. See link for details." :model "Colorado Direct 600" :url "http://home2.swipnet.se/~w-25069/pxscan.html" :interface "Parport" :status :unsupported :comment "Not supported. However, a stand-alone program is available." :model "Colorado Direct 9600" :url "http://home2.swipnet.se/~w-25069/pxscan.html" :interface "Parport" :status :unsupported :comment "Not supported. However, a stand-alone program is available." :model "Colorado USB 9600" :url "unsupported/primax-colorado-usb-9600.html" :interface "USB" :usbid "0x0461" "0x0340" :status :unsupported :comment "Not supported. See link for details." :model "G2-300" :interface "USB" :usbid "0x0461" "0x0300" :status :unsupported :comment "Probably unsupported. No details known." :model "G2-300 #2" :interface "USB" :usbid "0x0461" "0x0302" :status :unsupported :comment "Probably unsupported. No details known." :model "G2E-300" :interface "USB" :usbid "0x0461" "0x0301" :status :unsupported :comment "Probably unsupported. No details known." :model "G2E-300 #2" :usbid "0x0461" "0x0303" :interface "USB" :status :unsupported :comment "Probably unsupported. No details known." :model "G2-600" :usbid "0x0461" "0x0380" :interface "USB" :status :unsupported :comment "Probably unsupported. No details known." :model "G2-600 #2" :interface "USB" :usbid "0x0461" "0x0382" :status :unsupported :comment "Probably unsupported. No details known." :model "G2E-600" :usbid "0x0461" "0x0383" :interface "USB" :status :unsupported :comment "Probably unsupported. No details known." :model "OneTouch 5300" :interface "Parport" :status :unsupported :comment "Not supported." :model "ReadyScan 636i" :usbid "0x0461" "0x0381" :interface "USB" :status :unsupported :comment "Probably unsupported. No details known." :model "Slim-Line 1200" :interface "USB" :status :unsupported :comment "Maybe GL646. Maybe similar to Medion MD 6228?" :model "Onetouch 8920" :url "unsupported/visioneer-onetouch8920.html" :interface "USB" :usbid "0x0461" "0x0371" :status :unsupported :comment "Not supported. Look similar to Visioneer Onetouch 8920 (same USB product id)." ;******************************************************************************************** :mfg "Prolink" :url "http://www.fida.com/" :model "Winscan Pro 2448U" :url "unsupported/prolink-2448u.html" :interface "USB" :usbid "0x06dc" "0x0014" :status :unsupported :comment "Not supported. Some information is available. RealTek RTS8801." :model "Winscan Pro 2000" :interface "USB Parport" :status :unsupported :comment "Not supported. No further information available." ;******************************************************************************************** :mfg "Quato" :url "http://www.quato.de/" :model "X-Finity" :interface "SCSI" :status :unsupported :comment "Probably not supported. No details yet. Originally manufactured by PFU?" :model "X-Finity Ultra" :interface "USB IEEE-1394" :status :unsupported :comment "Probably not supported. No details yet." ;******************************************************************************************** :mfg "Reflecta" :model "DigitDia 3600" :url "unsupported/reflecta-digitdia-3600.html" :interface "USB IEEE-1394" :usbid "0x05e3" "0x0142" :status :unsupported :comment "Film scanner that can scan directly from the magazine." :model "iScan 1800" :url "unsupported/reflecta-iscan-1800.html" :interface "USB" :usbid "0x05e3" "0x0120" :status :unsupported :comment "Probably unsupported. See link for details." :model "ProScan 4000" :url "unsupported/reflecta-proscan-4000.html" :interface "USB IEEE-1394" :usbid "0x05e3" "0x0143" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Relisys" :model "Eclipse 1200U" :url "unsupported/relisys-eclipse-1200u.html" :interface "USB" :usbid "0x0475" "0x0103" :status :unsupported :comment "Probably unsupported. See link for details." :model "Scorpio Ultra 3" :url "unsupported/relisys-scorpio-ultra3.html" :interface "USB" :usbid "0x0475" "0x0210" :status :unsupported :comment "Probably unsupported. See link for details." :model "Episode" :url "unsupported/relisys-episode.html" :interface "USB" :usbid "0x0475" "0x0103" :status :unsupported :comment "Probably unsupported. See link for details." :model "AVEC II E3" :interface "Parport" :status :unsupported :comment "Parport version of AVEC II S3?. See bug #304992 for details" ;******************************************************************************************** :mfg "Samsung" :model "SCX-4725FN" :url "unsupported/samsung-scx-4725.html" :interface "USB" :usbid "0x04e8" "0x341f" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** :mfg "Scanshell" :model "800N" :url "unsupported/scanshell-800n.html" :interface "USB" :usbid "0x0a82" "0x6605" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** :mfg "Sicos" :model "DMS 2000" :url "mailto:ehaase@inf.fu-berlin.de" :interface "proprietary" :status :unsupported :comment "Not supported until now. Work on a backend has started, contact the author for details (see link)" ;******************************************************************************************** :mfg "Siemens" ; name a manufacturer :url "http://www.siemens.com/" :model "ID Mouse Professional" :interface "USB" :usbid "0x0681" "0x0005" :status :unsupported :comment "Not supported." :model "Cherry FingerTIP ID Board - Sensor" :interface "USB" :usbid "0x0681" "0x0010" :status :unsupported :comment "Not supported." ;******************************************************************************************** :mfg "SmartDisk" :model "SmartScan 3600" :interface "USB IEEE-1394" :status :unsupported :comment "Probably not supported. Same as PIE Primefilm 2600 PRO." ;******************************************************************************************** :mfg "Spot Technology" :comment "Spot seems have gone out of business." :model "Maxiscan A4" :url "http://www.el-profesor.net/spoonset/" :interface "proprietary" :status :unsupported :comment "Not supported until now. Work on a backend has started, see link for more information." :model "ScanTak 2c" :url "http://www.el-profesor.net/spoonset" :interface "proprietary" :status :unsupported :comment "Not supported. Work on a backend has started, see link for more information." :model "ScanTak 3c" :url "http://www.el-profesor.net/spoonset" :interface "proprietary" :status :unsupported :comment "Not supported. Work on a backend has started, see link for more information." ;******************************************************************************************** :mfg "Syscan" :model "TravelScan FS-531" :url "unsupported/syscan-travelscan-fs531.html" :interface "USB" :usbid "0x0a82" "0x0530" :status :unsupported :comment "Not supported. May work with the Plustek backend in future. See link for details." :model "TravelScan Pro" :url "unsupported/syscan-travelscan-pro.html" :interface "USB" :usbid "0x0a82" "0x2000" :status :unsupported :comment "Probably not supported. Some information is available." ;******************************************************************************************** :mfg "Tamarack" :model "Artiscan 9600" ; name models for above-specified mfg. :interface "Parport" :status :unsupported :url "http://www.autistici.org/tamarhack/" :comment "Unsupported at the moment. See link for a project for that scanner taht may support it in future." :model "Artiscan 9600 pro 36" ; name models for above-specified mfg. :interface "Parport" :status :unsupported :url "http://www.autistici.org/tamarhack/" :comment "Unsupported at the moment. See link for a project for that scanner." :model "Artiscan 2400FS" :url "unsupported/tamarack-artiscan-2400.html" :interface "USB" :usbid "0x05e3" "0x0100" :status :unsupported :comment "Unsupported. See link for more information." ;******************************************************************************************** :mfg "TCE" :comment "Brasilian vendor." :url "http://www.tce.com.br/" :model "MK600U" :url "unsupported/memorex-maxx-6136u.html" :interface "USB" :usbid "0x0461" "0x0346" :status :unsupported :comment "Not supported. Some information is available." :model "S450" :url "http://home2.swipnet.se/~w-25069/pxscan.html" :interface "Parport" :status :unsupported :comment "Not supported by SANE but is reported to work with pxscan (see link)." ;******************************************************************************************** :mfg "Teco" :url "http://www.tecoimage.com.tw/" :model "VM6509F" :url "unsupported/teco-vm6509.html" :interface "USB" :usbid "0x080d" "0x0102" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Tiny" :model "FU661E" :url "unsupported/visioneer-onetouch4400.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Trust" :url "http://www.trust-site.com" :model "CombiScan 19200" :url "unsupported/trust-combiscan-19200.html" :interface "Parport USB" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." :model "EasyScan 19200" :url "http://alioth-lists.debian.net/pipermail/sane-devel/2008-October/022955.html" :interface "Parport" :status :unsupported :model "SCSI Scan 19200 -Excellence Series-" :url "unsupported/trust-scsi-scan-19200.html" :interface "SCSI" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "UMAX" :url "http://www.umax.com/" :model "Astra 2500" :url "unsupported/umax-astra-2500.html" :interface "USB" :usbid "0x0461" "0x0374" :status :unsupported :comment "Probably not supported. See link for details." :model "Astra 2850" :url "unsupported/plustek-opticpro-st24.html" :interface "USB" :usbid "0x07b3" "0x0601" :status :unsupported :comment "Probably not supported. Same IDs as Plustek OpticPro ST24. See link for details." :model "Astra 3000" :url "unsupported/umax-astra-3000.html" :interface "USB" :usbid "0x0461" "0x038a" :status :unsupported :comment "Probably not supported. See link for details." :model "Astra 3600" :url "unsupported/umax-astra-3600.html" :interface "USB" :usbid "0x0461" "0x038a" :status :unsupported :comment "Probably not supported. See link for details." :model "Astra 4000" :url "unsupported/umax-astra-4000.html" :interface "USB" :usbid "0x1606" "0x1030" :status :unsupported :comment "Not supported. See link for details." :model "Astra 4100" :url "unsupported/umax-astra-4100.html" :interface "USB" :usbid "0x0461" "0x038c" :status :unsupported :comment "Not supported, to be added to genesys backend." :model "Astra 4500" :url "unsupported/umax-astra-4500.html" :interface "USB" :usbid "0x0638" "0x0a10" :status :unsupported :comment "GL646 based, to be added to genesys backend. Avision iVina FB1600 clone" :model "Astra 4600" :interface "USB" :status :unsupported :comment "Probably not supported, no details known." :model "Astra 4700" :url "unsupported/umax-astra-4700.html" :interface "USB" :usbid "0x0638" "0x0a20" :status :unsupported :comment "GL646/GL660 based. Avision iVina FB1800 clone." :model "Astra 6700" :interface "USB" :status :unsupported :comment "Not supported. No chipset information available. Same as Avision iVina FB2400." :model "AstraSlim" :url "unsupported/umax-astraslim.html" :usbid "0x080d" "0x0104" :interface "USB" :status :unsupported :comment "Probably not supported currently. See link for more details." :model "AstraSlim 1200" :url "unsupported/umax-astraslim-1200.html" :interface "USB" :usbid "0x080d" "0x0110" :status :unsupported :comment "See link for more details." :model "AstraSlim 6000" :url "unsupported/umax-astraslim-6000.html" :interface "USB" :usbid "0x080d" "0x0104" :status :unsupported :comment "Probably not supported currently. See link for more details." :model "Nete3470'" :interface "Parport" :status :unsupported :comment "Probably not supported. No details known.." :model "Powerlook 180" :url "unsupported/umax-powerlook-180.html" :interface "USB" ;:usbid "0x3902" "0xc470" #correct? :status :unsupported :comment "Probably not supported. See link for details." :model "Powerlook 1000 USB" :interface "USB" :status :unsupported :comment "Probably not supported. No further information available." ;******************************************************************************************** :mfg "Vantas" :model "3000" :url "unsupported/visioneer-onetouch4800.html" :interface "USB" :usbid "0x04a7" "0x0224" :status :unsupported :comment "Not supported. See link for more details." ;******************************************************************************************** :mfg "Visioneer" :url "http://www.visioneer.com/" :model "6200" :interface "USB" :usbid "0x0461" "0x0345" :status :unsupported :comment "Not supported. Is reported to use the E5 chipset. Uses a Primax ID. Looks similar to Primascan Colorado 2600u." :model "6200 EPP/USB" :interface "USB" :usbid "0x04a7" "0x0311" :status :unsupported :comment "Not supported. Id is from Primax? Yet another scanner with the same name?" :model "9420" :url "unsupported/visioneer-9420.html" :interface "USB" :usbid "0x0461" "0x03a8" :status :unsupported :comment "Unsupported. See link for details." :model "9450 USB" :url "unsupported/visioneer-9450-usb.html" :interface "USB" :usbid "0x04a7" "0x0421" :status :unsupported :comment "Unsupported. See link for details." :model "Onetouch 4400" :url "unsupported/visioneer-onetouch4400.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Not supported. E5 chipset? See link for more details." :model "OneTouch 4800 USB" :url "unsupported/visioneer-onetouch4800.html" :interface "USB" :usbid "0x04a7" "0x0224" :status :unsupported :comment "Unsupported. Seems to use Realtek RTS8801B. Same as Microtek Scanport 3000. See link for details." :model "OneTouch 5300 USB" :url "unsupported/visioneer-onetouch5300.html" :interface "USB" :usbid "0x04a7" "0x0226" :status :unsupported :comment "Not supported. Chipset is RTS8801B(?). See link for output of /proc/bus/usb/devices." :model "OneTouch 5300" :interface "USB" :usbid "0x04a7" "0x0221" :status :unsupported :comment "Not supported. Yet another scanner with this name?" :model "OneTouch 5800 USB" :url "unsupported/visioneer-onetouch5800.html" :interface "USB" :usbid "0x04a7" "0x0226" :status :unsupported :comment "Unsupported. 48 bit scanner, doesn't work with viceo backend. RTS8801C." :model "OneTouch 6600" :url "unsupported/visioneer-onetouch6600.html" :interface "USB" :usbid "0x04a7" "0x022a" :status :unsupported :comment "Unsupported. See link for details." :model "Onetouch 7100" :url "unsupported/visioneer-onetouch7100.html" :interface "USB" :usbid "0x04a7" "0x0229" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "Onetouch 7700" :url "unsupported/visioneer-onetouch7700.html" :interface "USB" :usbid "0x04a7" "0x0380" :status :unsupported :comment "LM9832/3 based, to be added to plustek backend" :model "OneTouch 8100" :url "unsupported/visioneer-onetouch8100.html" :interface "USB" :usbid "0x04a7" "0x0321" :status :unsupported :comment "Unsupported. See link for details." :model "Onetouch 8700" :url "unsupported/visioneer-onetouch8920.html" :interface "USB" :usbid "0x04a7" "0x0371" :status :unsupported :comment "Not supported. See link for details." :model "Onetouch 8900" :url "unsupported/visioneer-onetouch8920.html" :interface "USB" :usbid "0x04a7" "0x0371" :status :unsupported :comment "Not supported. Same as 8920 but without TA?" :model "Onetouch 8920" :url "unsupported/visioneer-onetouch8920.html" :interface "USB" :usbid "0x04a7" "0x0371" :status :unsupported :comment "Not supported. Same as 8700 and 8900 but includes a TA. Uses a Primax ID. Chipset is RTS8801C. See link for output of /proc/bus/usb/devices." :model "Onetouch 9000" :url "unsupported/visioneer-onetouch9020.html" :interface "USB" :usbid "0x04a7" "0x022c" :status :unsupported :comment "Not supported. See link for details." :model "Onetouch 9020" :url "unsupported/visioneer-onetouch9020.html" :interface "USB" :usbid "0x04a7" "0x022c" :status :unsupported :comment "Not supported. See link for details." :model "Onetouch 9320" :url "unsupported/visioneer-onetouch9320.html" :interface "USB" :usbid "0x04a7" "0x0362" :status :unsupported :comment "Probably not supported. See link for details." :model "Onetouch Pro 8800" :url "unsupported/visioneer-onetouch8820.html" :interface "USB" :usbid "0x04a7" "0x0410" :status :unsupported :comment "Probably not supported. See link for details." :model "Onetouch Pro 8820" :url "unsupported/visioneer-onetouch8820.html" :interface "USB" :usbid "0x04a7" "0x0410" :status :unsupported :comment "Probably not supported. See link for details." :model "PaperPort 3100b" :url "unsupported/visioneer-paperport-3100b.html" :interface "Parport" :status :unsupported :comment "Most probably not supported. See link for details." :model "PaperPort 6100" :interface "Parport" :status :unsupported :comment "Most probably not supported. More details would be appreciated." :model "PaperPort OneTouch" :url "unsupported/visioneer-paperport-onetouch.html" :interface "Parport" :status :unsupported :comment "Most probably not supported. See link for details." :model "Strobe Pro USB" :url "unsupported/visioneer-strobe-pro-usb.html" :interface "USB" :usbid "0x04a7" "0x0102" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** :model "4800 One Touch" :url "unsupported/xerox-4800-onetouch.html" :interface "USB" :usbid "0x04a7" "0x03a0" :status :unsupported :comment "Unsupported. See link for details. Different id compared to One Touch 4800?" :model "DocuImage 620S" :url "unsupported/xerox-docuimage-620s.html" :interface "SCSI" :status :unsupported :comment "Not supported. See link for more details." :model "DocuMate 510" :url "unsupported/xerox-documate-510.html" :interface "USB" :status :unsupported :usbid "0x04a7" "0x0446" :comment "Not supported. See link for more details." :model "DocuMate 510" :url "unsupported/xerox-documate-510.html" :interface "USB" :status :unsupported :usbid "0x04a7" "0x047c" :comment "Not supported. See link for more details. Yet another USB id." :model "One Touch 4800" :url "unsupported/visioneer-onetouch4800.html" :interface "USB" :usbid "0x04a7" "0x0224" :status :unsupported :comment "Unsupported. See link for details. Different id compared to 4800 One Touch?" :model "WorkCentre 470cx" :url "unsupported/xerox-workcentre-470cx.html" :interface "Parport" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre M15i" :url "unsupported/xerox-workcentre-m15i.html" :interface "USB" :usbid "0x0924" "0xffef" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre XK35c" :url "unsupported/xerox-workcentre-xk35c.html" :interface "USB Parport" :usbid "0x043d" "0x0020" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre XK50cx" :url "unsupported/xerox-workcentre-xk50cx.html" :interface "USB" :usbid "0x04e8" "0x3903" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre Pro 412" :url "unsupported/xerox-workcentre-pro412.html" :interface "USB Parport" :usbid "0x043d" "0x4303" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre PE16" :url "unsupported/xerox-workcentre-pe16.html" :interface "USB Parport" :usbid "0x0924" "0x4220" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre PE120i" :url "unsupported/xerox-workcentre-pe120i.html" :interface "USB" :usbid "0x0924" "0x4237" :status :unsupported :comment "Not supported. See link for more details." ;******************************************************************************************** ;******************************************************************************************** ;******************************************************************************************** :devicetype :vidcam :mfg "Biolux" :model "654 (micrOcular)" :url "unsupported/biolux-654.html" :interface "USB" :usbid "0x0923" "0x010f" :status :unsupported :comment "Not supported yet. See link for more details." ;******************************************************************************************** :mfg "Grandtek Scopecam" :model "8x30 Binocular & Digital Camera" :url "unsupported/grandtech-scopecam.html" :interface "USB" :usbid "0x0797" "0x801c" :status :unsupported :comment "Not Supported yet. See link for more details." ;******************************************************************************************** ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "v4l" ; name of backend :version "1.0-3" ; version of backend :manpage "sane-v4l" ; name of manpage (if it exists) :url "mailto:henning@meier-geinitz.de" ; backend's web page :devicetype :api ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :desc "Interface to Video For Linux API" ; describe a non-hardware device :comment "Supports video cameras and other devices accessed by the v4l kernel API, e.g. bttv devices. Quite a lot of known bugs." ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. :backend "xerox_mfp" :version "1.0-13" :manpage "sane-xerox_mfp" :devicetype :scanner :mfg "Xerox" :url "http://www.office.xerox.com/" :model "Phaser 6110MFP" :interface "USB" :usbid "0x0924" "0x3d5d" :status :good :model "Phaser 3200MFP" :interface "USB" :usbid "0x0924" "0x3da4" :status :complete :url "http://www.office.xerox.com/multifunction-printer/multifunction-under-30ppm/phaser-3200mfp/spec-enus.html" :model "WorkCentre 3119 Series" :interface "USB" :usbid "0x0924" "0x4265" :status :good :model "WorkCentre 4118 Series" :interface "USB" :usbid "0x0924" "0x420c" :status :good :model "WorkCentre 3210" :interface "USB" :usbid "0x0924" "0x4293" :status :good :model "WorkCentre 3220" :interface "USB" :usbid "0x0924" "0x4294" :status :good :mfg "Dell" :url "http://www.dell.com/" :model "Dell MFP Laser Printer 1815dn" :interface "USB" :usbid "0x413c" "0x5124" :status :good :mfg "Samsung" :url "http://www.samsung.com" :model "SCX-4x16" :interface "USB" :usbid "0x04e8" "0x3409" :status :untested :model "SCX-6x20" :interface "USB" :usbid "0x04e8" "0x340d" :status :untested :model "MFP-560" :interface "USB" :usbid "0x04e8" "0x340e" :status :untested :model "MFP-750" :interface "USB" :usbid "0x04e8" "0x340f" :status :untested :model "SCX-4x20" :interface "USB" :usbid "0x04e8" "0x3412" :status :untested :model "SCX-4100" :interface "USB" :usbid "0x04e8" "0x3413" :status :good :model "SCX-4x21" :interface "USB" :usbid "0x04e8" "0x3419" :status :untested :model "SCX-5x30" :interface "USB" :usbid "0x04e8" "0x341a" :status :untested :model "SCX-4200" :interface "USB" :usbid "0x04e8" "0x341b" :status :good :model "CLX-3160" :interface "USB" :usbid "0x04e8" "0x341c" :status :untested :model "SCX-6x22" :interface "USB" :usbid "0x04e8" "0x341d" :status :untested :model "SCX4725" :interface "USB" :usbid "0x04e8" "0x341f" :status :untested :model "SCX4725-FN" :interface "USB" :usbid "0x04e8" "0x341f" :status :good :model "SCX-6x45" :interface "USB" :usbid "0x04e8" "0x3420" :status :untested :model "CLX-8380" :interface "USB" :usbid "0x04e8" "0x3421" :status :untested :model "CLX-2160" :interface "USB" :usbid "0x04e8" "0x3425" :status :good :model "SCX-4500" :interface "USB" :usbid "0x04e8" "0x3426" :status :good :model "CLX-6200" :interface "USB" :usbid "0x04e8" "0x3427" :status :untested :model "CLX-6240" :interface "USB" :usbid "0x04e8" "0x3428" :status :untested :model "SCX-6x55" :interface "USB" :usbid "0x04e8" "0x3429" :status :untested :model "CLX-3170fn (CLX-3170 Series)" :interface "USB" :usbid "0x04e8" "0x342a" :status :good :model "CLX-3175FW" :interface "USB" :usbid "0x04e8" "0x342a" :status :good :model "SCX-4500W" :interface "USB Ethernet" :usbid "0x04e8" "0x342b" :status :basic :model "SCX-4824 (SCX-4x24 Series)" :interface "USB" :usbid "0x04e8" "0x342c" :status :good :model "SCX-4828FN (SCX-4x28 Series)" :interface "USB" :usbid "0x04e8" "0x342d" :status :good :model "SCX-4300" :interface "USB" :usbid "0x04e8" "0x342e" :status :good :model "SCX-5835_5935" :interface "USB" :usbid "0x04e8" "0x342f" :status :good :model "SCX-5635" :interface "USB" :usbid "0x04e8" "0x3430" :status :untested :model "SCX-4x26" :interface "USB" :usbid "0x04e8" "0x3432" :status :untested :model "SCX-4600" :interface "USB" :usbid "0x04e8" "0x3433" :status :good :model "SCX-4623" :interface "USB" :usbid "0x04e8" "0x3434" :status :good :model "MFP-65x" :interface "USB" :usbid "0x04e8" "0x3435" :status :untested :model "SCX-6545" :interface "USB" :usbid "0x04e8" "0x3437" :status :untested :model "CLX-8385" :interface "USB" :usbid "0x04e8" "0x3439" :status :untested :model "CLX-6220" :interface "USB" :usbid "0x04e8" "0x343a" :status :good :model "CLX-6250" :interface "USB" :usbid "0x04e8" "0x343b" :status :untested :model "SCX-4825FN (SCX-4x25 Series)" :interface "USB" :usbid "0x04e8" "0x343c" :status :good :model "CLX-3185" :interface "USB" :usbid "0x04e8" "0x343d" :status :good :model "CLX-8540" :interface "USB" :usbid "0x04e8" "0x343f" :status :untested :model "SCX-4623FW" :interface "USB" :usbid "0x04e8" "0x3440" :status :good :model "SCX-3205W (SCX-3200 Series)" :interface "USB Ethernet" :usbid "0x04e8" "0x3441" :status :good :model "SCX-6545X" :interface "USB" :usbid "0x04e8" "0x3442" :status :untested :model "SCX-6x55X" :interface "USB" :usbid "0x04e8" "0x3443" :status :untested :model "CLX-8385X" :interface "USB" :usbid "0x04e8" "0x3444" :status :untested :model "SCX-5835_5935X" :interface "USB" :usbid "0x04e8" "0x3446" :status :good :model "SCX-4833FD" :interface "USB" :usbid "0x04e8" "0x344b" :status :good :model "SCX-4835FD" :interface "Ethernet" :usbid "0x04e8" "0x344b" :status :good :model "SCX-3405W" :interface "Ethernet" :status :basic :model "SCX-3400" :interface "USB" :usbid "0x04e8" "0x344f" :status :untested :model "SF-760" :interface "USB" :usbid "0x04e8" "0x3450" :status :untested :model "SCX-4729FD" :interface "USB" :usbid "0x04e8" "0x3453" :status :basic :model "CLX-6260" :interface "USB" :usbid "0x04e8" "0x3455" :status :minimal :model "CLX-3300 Series" :interface "USB" :usbid "0x04e8" "0x3456" :status :basic :model "SCX-470x" :interface "USB" :usbid "0x04e8" "0x3457" :status :untested :model "CLX-4190" :interface "USB" :usbid "0x04e8" "0x345a" :status :minimal :model "SCX-4650 4x21S Series" :interface "USB" :usbid "0x04e8" "0x345b" :status :untested :model "M337x 387x 407x Series" :interface "USB" :usbid "0x04e8" "0x3460" :status :untested :model "M267x 287x Series" :interface "USB" :usbid "0x04e8" "0x3461" :status :untested :model "SCX-681x" :interface "USB" :usbid "0x04e8" "0x3466" :status :untested :model "C460" :interface "USB" :usbid "0x04e8" "0x3468" :status :untested sane-backends-1.0.29/testsuite/tools/data/html-backends-split.ref0000666000000000000000000174525013615534521021664 00000000000000 SANE: Backends (Drivers)
SANE

SANE: Backends (Drivers)


The following table summarizes the backends/drivers distributed with the latest version of sane-backends, and the hardware or software they support.

This is only a summary! Please consult the manpages and the author-supplied webpages for more detailed (and usually important) information concerning each backend.

If you have new information or corrections, please file a bug report with as many details as possible. Also please tell us if your scanner isn't mentioned in this list at all.

For an explanation of the tables, see the legend.

Summary

Device type Number of devices
Total Supported Untested Unsupported
Sum Complete Good Basic Minimal
Scanners 2012 1205 417 662 101 25 325 482
Still cameras 5 5 1 2 2 0 0 0
Video Cameras 8 3 0 1 0 2 3 2
Meta backends 2 n/a
APIs 5 n/a

Scanners

Backends: abaton, agfafocus, apple, artec, artec_eplus48u, as6e, avision, bh, canon, canon630u, canon_dr, canon_pp, cardscan, coolscan, coolscan2, coolscan3, dell1600n_net, epjitsu, epson, epson2, fujitsu, genesys, gt68xx, hp, hp3500, hp3900, hp4200, hp5400, hp5590, hpljm1005, hpsj5s, hs2p, ibm, kodak, kodakaio, kvs20xx, kvs40xx, kvs1025, leo, lexmark, ma1509, magicolor, matsushita, microtek, microtek2, mustek, mustek_pp, mustek_usb, mustek_usb2, nec, niash, p5, pie, pixma, plustek, plustek_pp, ricoh, rts8891, s9036, sceptre, sharp, sm3600, sm3840, SnapScan, sp15c, st400, tamarack, teco1, teco2, teco3, u12, umax, umax1220u, umax_pp, unsupported, xerox_mfp

Backend: abaton (unmaintained)

Manual page: sane-abaton

Manufacturer Model Interface USB id Status Comment
Abaton Scan 300/GS SCSI   Complete All known modes and functions supported
Scan 300/S SCSI   Untested Untested, use with caution

Backend: agfafocus (unmaintained)

Manual page: sane-agfafocus

Manufacturer Model Interface USB id Status Comment
AGFA Focus GS Scanner SCSI   Untested 6 bit gray
Focus Lineart Scanner SCSI   Untested Lineart only? Untested.
Focus II SCSI   Untested gray only
Focus Color SCSI   Good 3-pass
Focus Color Plus SCSI   Good 3-pass
Siemens S9036 SCSI   Untested gray only

Backend: apple (unmaintained)

Manual page: sane-apple

Manufacturer Model Interface USB id Status Comment
Apple Apple Scanner SCSI   Good 4bit, 16 shades of gray
OneScanner SCSI   Basic 8bit, 256 shades of gray. The backend needs work especially in the quantization code but it may work.
Color OneScanner SCSI   Minimal truecolor (needs much work) but it scans in non color modes.

Backend: artec (unmaintained)

Link(s): http://www4.infi.net/~cpinkham/sane/sane-artec-doc.html
Manual page: sane-artec

Manufacturer Model Interface USB id Status Comment
Artec/Ultima AT3 SCSI   Complete all modes working
A6000C SCSI   Complete all modes working
A6000C PLUS SCSI   Complete f/w <= v1.92 basic, f/w >= v1.93 OK
AT6 SCSI   Good Scan head needs to return home before another scan can be started.
AT12 SCSI   Complete all modes working
AM12S SCSI   Complete all modes working
BlackWidow BW4800SP SCSI   Complete rebadged Artec AT3
Plustek OpticPro 19200S SCSI   Complete rebadged Artec AM12S

Backend: artec_eplus48u (unmaintained)

Manual page: sane-artec_eplus48u

Manufacturer Model Interface USB id Status Comment
Artec/Ultima E+ 48U USB 0x05d8/0x4003 Good CIS scanner based on the GT6816 chip. Apparently all other devices are re-badged Artec scanners.
E+ Pro USB 0x05d8/0x4004 Minimal Works up to 600dpi, but not 1200. Needs better calibration. See bug #310490
Medion/Lifetec/Tevion/Cytron MD9693 USB 0x05d8/0x4003 Good  
MD9705 USB 0x05d8/0x4003 Good  
MD4394 USB 0x05d8/0x4003 Good Only scanners with product id 0x4003 will work; try the gt68xx backend, if your scanner has product id 0x4002
Trust Easy Webscan 19200 USB 0x05d8/0x4006 Good  
240H Easy Webscan Gold USB 0x05d8/0x4007 Basic Works up to 600 dpi
Memorex MEM 48U USB 0x05d8/0x4005 Good  
Microstar MR 9791 USB 0x05d8/0x4003 Good  
UMAX AstraSlim SE USB 0x05d8/0x4009 Good  
AstraSlim 1200 SE USB 0x05d8/0x4010 Good  
Yakumo Scan50 USB 0x05d8/0x4011 Good  

Backend: as6e (0.5)

Link(s): http://as6edriver.sourceforge.net/
Manual page: sane-as6e

Manufacturer Model Interface USB id Status Comment
Artec/Ultima AS6E Parport   Basic Requires the program 'as6edriver' to run.
Trust Easy Scan 9600 Plus Parport   Basic Requires the program 'as6edriver' to run.
Dexxa 4800 Parport   Basic Requires the program 'as6edriver' to run.

Backend: avision (Build: 296)

Link(s): http://skull.piratehaven.org/~mike/sane/avision.html
Manual page: sane-avision

Manufacturer Model Interface USB id Status Comment
Avision AV100CS SCSI   Untested  
AV100IIICS SCSI   Untested  
AV100S SCSI   Untested  
AV120 USB 0x0638/0x0a27 Complete sheetfed scanner
AV121 USB 0x0638/0x0a3c Good sheetfed scanner
AV122 USB 0x0638/0x0a33 Good sheetfed duplex scanner
AV122 C2 USB 0x0638/0x0a93 Good sheetfed duplex scanner
AV210 USB 0x0638/0x0a24 Complete sheetfed scanner
AV210 USB 0x0638/0x0a25 Complete sheetfed scanner
AV210C2 USB 0x0638/0x0a3a Complete sheetfed scanner
AV210C2-G USB 0x0638/0x0a2f Complete sheetfed scanner
AV210D2+ USB 0x0638/0x1a35 Complete sheetfed scanner
AV220 USB 0x0638/0x0a23 Complete duplex! sheetfed scanner
AV220C2 USB 0x0638/0x0a2a Complete duplex! sheetfed scanner
AV220D2 USB 0x0638/0x0a2b Complete duplex! sheetfed scanner
AV220+ USB 0x0638/0x0a2c Complete duplex! sheetfed scanner
AV220C2-G USB 0x0638/0x0a2d Complete duplex! sheetfed scanner
AV220C2-B USB 0x0638/0x0a2e Complete duplex! sheetfed scanner
AV220-G USB 0x0638/0x0a94 Complete duplex! sheetfed scanner
AV240SC SCSI   Untested  
AV260CS SCSI   Untested  
AV360CS SCSI   Untested  
AV363CS SCSI   Untested  
AV420CS SCSI   Untested  
AV6120 SCSI   Untested  
AV610 USB 0x0638/0x0a18 Good  
AV600U Plus USB 0x0638/0x0a18 Good  
AV610C2 USB 0x0638/0x0a5e Good  
AM3000 Series USB 0x0638/0x0a41 Basic MFD
DS610CU Scancopier USB 0x0638/0x0a16 Good 1 pass, 600 dpi, A4
AV620CS SCSI   Complete 1 pass, 600 dpi
AV620CS Plus SCSI   Complete 1 pass, 1200 dpi
AV630CS SCSI   Complete 1 pass, 1200 dpi
AV630CSL SCSI   Untested 1 pass, 1200 dpi
AV6240 SCSI   Complete 1 pass, ??? dpi
AV600U USB 0x0638/0x0a13 Good 1 pass, 600 dpi
AV660S SCSI   Untested 1 pass, ??? dpi
AV680S SCSI   Untested 1 pass, ??? dpi
AV690U SCSI   Untested 1 pass, 2400 dpi
AV800S SCSI   Untested 1 pass, ??? dpi
AV810C SCSI   Untested 1 pass, ??? dpi
AV820 SCSI   Untested 1 pass, ??? dpi
AV820C SCSI   Complete 1 pass, ??? dpi
AV820C Plus SCSI   Complete 1 pass, ??? dpi
AV830C SCSI   Complete 1 pass, ??? dpi
AV830C Plus SCSI   Untested 1 pass, ??? dpi
AV880 SCSI   Untested 1 pass, ??? dpi
AV880C SCSI   Untested 1 pass, ??? dpi
AV3200C SCSI   Complete 1 pass, ??? dpi
AV3200SU USB 0x0638/0x0a4e Complete 1 pass, ??? dpi
AV3730SU USB 0x0638/0x0a4f Complete 1 pass, ??? dpi
AV3750SU USB 0x0638/0x0a65 Complete 1 pass, ??? dpi
AV3800C SCSI   Complete 1 pass, ??? dpi
AV3850SU USB 0x0638/0x0a66 Complete 1 pass, ??? dpi
FB6000E SCSI   Complete 1 pass, 1200 dpi, A3 - duplex! - zero edge!
FB6080E USB 0x0638/0x0a82 Complete 1 pass, 1200 dpi, A3 - duplex! - zero edge!
FB2080E USB 0x0638/0x0a84 Basic 1 pass, 600 dpi, zero-edge
AV8000S SCSI   Complete 1 pass, 1200 dpi, A3
AV8050U USB 0x0638/0x0a4d Complete 1 pass, 1200 dpi, A3 - duplex!
AV8300 USB 0x0638/0x0a40 Complete 1 pass, 1200 dpi, A3 - duplex!
AV8350 USB 0x0638/0x0a68 Complete 1 pass, 1200 dpi, A3 - duplex!
IT8300 USB 0x0638/0x0a61 Good 1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors
@V2500 USB 0x0638/0x0aa1 Untested  
@V5100 USB 0x0638/0x0a45 Good 1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors
AVA3 SCSI   Basic 1 pass, 600 dpi, A3
Hewlett-Packard ScanJet 5300C USB 0x03f0/0x0701 Complete 1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi
ScanJet 5370C USB 0x03f0/0x0701 Good 1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi
ScanJet 7400c USB 0x03f0/0x0801 Good 1 pass, 2400 dpi - dual USB/SCSI interface
ScanJet 7450c USB 0x03f0/0x0801 Good 1 pass, 2400 dpi - dual USB/SCSI interface
ScanJet 7490c USB 0x03f0/0x0801 Good 1 pass, 1200 dpi - dual USB/SCSI interface
ScanJet 8200 USB 0x03f0/0x0b01 Good 1 pass, 4800 (?) dpi - USB 2.0
ScanJet 8250 USB 0x03f0/0x0b01 Good 1 pass, 4800 (?) dpi - USB 2.0
ScanJet 8270 USB 0x03f0/0x3905 Good 1 pass, 4800 (?) dpi - USB 2.0
ScanJet 8290 USB 0x03f0/0x0b01 Good 1 pass, 4800 (?) dpi - USB 2.0 and SCSI - only SCSI tested so far
ScanJet 8300 USB 0x03f0/0x3805 Good 1 pass, 4800 (?) dpi - USB 2.0
ScanJet 8350 USB 0x03f0/0x3805 Good 1 pass, 4800 (?) dpi - USB 2.0
ScanJet 8390 USB 0x03f0/0x3805 Good 1 pass, 4800 (?) dpi - USB 2.0
Minolta Dimage Scan Dual I SCSI   Basic  
Scan Multi Pro SCSI   Untested  
Dimage Scan Dual II USB 0x0638/0x026a Good 1 pass, film-scanner
Elite II USB 0x0686/0x4004 Untested 1 pass, film-scanner
Dimage Scan Dual III USB 0x0686/0x400d Good 1 pass, film-scanner
Dimage Scan Elite 5400 USB 0x0686/0x400e Good 1 pass, film-scanner
Minolta-QMS SC-110 USB 0x0638/0x0a15 Untested  
SC-215 USB 0x0638/0x0a16 Good  
Mitsubishi MCA-ADFC SCSI   Untested  
S1200C SCSI   Untested  
S600C SCSI   Untested  
SS600 SCSI   Good  
Fujitsu ScanPartner SCSI   Untested  
ScanPartner 10 SCSI   Untested  
ScanPartner 10C SCSI   Untested  
ScanPartner 15C SCSI   Untested  
ScanPartner 300C SCSI   Untested  
ScanPartner 600C SCSI   Untested  
ScanPartner 620C SCSI   Good  
ScanPartner Jr SCSI   Untested  
ScanStation SCSI   Untested  
fi-4010CU USB 0x04c5/0x1029 Untested  
fi-5015C USB 0x04c5/0x10ef Good  
Kodak i30 USB 0x040a/0x6001 Untested  
i40 USB 0x040a/0x6002 Basic  
i50 USB 0x040a/0x6003 Untested  
i55 USB 0x040a/0x6003 Untested  
i60 USB 0x040a/0x6004 Untested  
i65 USB 0x040a/0x6004 Untested  
i80 USB 0x040a/0x6005 Good  
iVina 1200U USB 0x0638/0x0268 Untested  
Visioneer Strobe XP 450 USB 0x04a7/0x0424 Complete sheetfed scanner
Strobe XP 450-G USB 0x04a7/0x0491 Complete sheetfed scanner
Strobe XP 470 USB 0x04a7/0x0479 Complete sheetfed scanner
Strobe XP 470-G USB 0x04a7/0x048f Complete sheetfed scanner
9320 USB 0x04a7/0x0420 Complete sheetfed scanner
9450 USB 0x04a7/0x0421 Complete sheetfed scanner
9450-G USB 0x04a7/0x047a Complete sheetfed scanner
9550 USB 0x04a7/0x0422 Complete sheetfed scanner
9650 USB 0x04a7/0x0390 Complete sheetfed scanner
9650-G USB 0x04a7/0x047b Complete sheetfed scanner
9750 USB 0x04a7/0x0423 Complete sheetfed scanner
9750-G USB 0x04a7/0x0493 Complete sheetfed scanner
Patriot 430 USB 0x04a7/0x0497 Complete sheetfed scanner
Patriot 470 USB 0x04a7/0x048f Complete sheetfed scanner
Patriot 680 USB 0x04a7/0x0498 Complete sheetfed scanner
Patriot 780 USB 0x04a7/0x0499 Complete sheetfed scanner
Xerox DocuMate150 USB 0x04a7/0x049c Good  
DocuMate152 USB 0x04a7/0x0477 Good  
DocuMate162 USB 0x04a7/0x049d Good  
DocuMate250 USB 0x04a7/0x0448 Good  
DocuMate250-G USB 0x04a7/0x0490 Good  
DocuMate252 USB 0x04a7/0x0449 Good  
DocuMate252-G USB 0x04a7/0x048c Good  
DocuMate232 USB 0x04a7/0x0476 Good  
DocuMate262 USB 0x04a7/0x044c Good  
DocuMate262-G USB 0x04a7/0x048d Good  
DocuMate262i USB 0x04a7/0x04a7 Good  
DocuMate272 USB 0x04a7/0x0475 Untested  
DocuMate272-G USB 0x04a7/0x048e Untested  
DocuMate510 USB 0x04a7/0x0446 Untested  
DocuMate512 USB 0x04a7/0x0495 Untested  
DocuMate510-G USB 0x04a7/0x047c Untested  
DocuMate520 USB 0x04a7/0x0447 Untested  
DocuMate520-G USB 0x04a7/0x0492 Untested  
DocuMate632 USB 0x04a7/0x0498 Untested  
DocuMate752 USB 0x04a7/0x0478 Untested  
DocuMate752 USB 0x04a7/0x049a Untested  
OKI S700 Scancopier USB 0x0638/0x0a16 Good 1 pass, 600 dpi, A4
Bell+Howell 2000F SCSI   Basic 1 pass, ??? dpi, A4
Kyocera FS-1016MFP USB 0x0482/0x0335 Untested 1 pass, ??? dpi, A4

Backend: bh (1.0-4)

Link(s): http://www.martoneconsulting.com/sane-bh.html
Manual page: sane-bh
Comment: Supports Copiscan II scanners with Remote SCSI Controller (RSC) interface

Manufacturer Model Interface USB id Status Comment
Bell and Howell COPISCAN II 6338 SCSI   Good Duplex Scanner with ACE - development model
COPISCAN II 2135 SCSI   Untested Simplex Scanner
COPISCAN II 2137(A) SCSI   Good Simplex Scanner (with ACE) - limited testing
COPISCAN II 2138A SCSI   Untested Simplex Scanner with ACE
COPISCAN II 3238 SCSI   Untested Simplex Scanner
COPISCAN II 3338(A) SCSI   Untested Simplex Scanner (with ACE)

Backend: canon (1.12)

Link(s): http://www.rzg.mpg.de/~mpd/sane/
Manual page: sane-canon

Manufacturer Model Interface USB id Status Comment
Canon CanoScan 300 SCSI   Good 1 pass; flatbed scanner
CanoScan 600 SCSI   Good 1 pass; flatbed scanner
CanoScan 620S SCSI   Good 1 pass; flatbed scanner
CanoScan 1200S SCSI   Good 1 pass; flatbed scanner
CanoScan 2700F SCSI   Good 1 pass; film scanner
CanoScan 2710S SCSI   Good 1 pass; 36bit film scanner
IX-4015 SCSI   Good 1 pass; flatbed scanner
Apple Color OneScanner 600/27 SCSI   Good Rebadged CanoScan 300

Backend: canon630u (0.1)

Link(s): http://canon-fb630u.sourceforge.net/
Manual page: sane-canon630u

Manufacturer Model Interface USB id Status Comment
Canon CanoScan fb630u USB 0x04a9/0x2204 Good OK
CanoScan fb636u USB 0x04a9/0x2204 Good OK

Backend: canon_dr (38)

Link(s): http://www.thebility.com/canon/
Manual page: sane-canon_dr
Comment: Backend updated for SANE release 1.0.23, see sane-canon_dr manpage

Manufacturer Model Interface USB id Status Comment
Canon CR-25 USB 0x1083/0x161a Untested Please test!
CR-55 USB 0x1083/0x160c Untested Please test!
CR-135i USB SCSI 0x1083/0x1639 Untested Please test!
CR-180 USB SCSI 0x04a9/0x1602 Untested Please test!
CR-180II USB SCSI 0x04a9/0x1602 Untested Same as CR-180? Please test!
CR-190i USB SCSI 0x1083/0x162b Untested Please test!
DR-1210C USB 0x04a9/0x2222 Untested Older version? Please test!
DR-1210C USB 0x1083/0x160f Untested Later version? Please test!
DR-2010C USB 0x1083/0x161b Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions.
DR-2010M USB   Untested Mac version of DR-2010C? Please test!
DR-2050C USB 0x04a9/0x160a Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration.
DR-2050SP USB 0x04a9/0x160a Untested Same as DR-2050C? Please test!
DR-2080C USB SCSI 0x04a9/0x1601 Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration
DR-2510C USB 0x1083/0x1617 Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions
DR-2510M USB   Untested Mac version of DR-2510C? Please test!
DR-2580C USB SCSI 0x04a9/0x1608 Complete Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration
DR-3010C USB 0x1083/0x161d Good Minimal testing, settings copied from DR-2510C
DR3020 SCSI   Untested Please test!
DR-3020C SCSI   Untested Please test!
DR-3060 SCSI   Untested Please test!
DR-3080C SCSI   Untested Almost works, need to investigate traces from windows driver
DR-3080CII USB SCSI 0x04a9/0x1609 Untested Almost works, need to investigate traces from windows driver
DR-4010C USB 0x1083/0x1614 Good Binary/HT/Gray/Color, Simplex/Duplex working. Multistream unsupported.
DR4080U USB   Untested Please test!
DR-4580U USB   Untested Please test!
DR-5010C USB 0x04a9/0x1606 Untested Please test!
DR-5020 SCSI   Good LineArt, Duplex working, cannot read buttons or screen?
DR-5060F SCSI   Basic Grayscale works, LineArt might
DR-5080C SCSI   Untested Please test!
DR-6010C USB SCSI 0x1083/0x1626 Untested Please test!
DR-6030C USB SCSI 0x1083/0x1638 Untested Please test!
DR-6050C USB SCSI 0x1083/0x1624 Good Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode
DR-6080 USB SCSI 0x04a9/0x1607 Good Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported
DR-7080C USB SCSI 0x04a9/0x1604 Untested Please test!
DR-7090C USB SCSI 0x1083/0x1620 Good ADF and flatbed work
DR-7550C USB SCSI 0x1083/0x1623 Untested Assumed compatible with DR-6050C
DR-7580 USB SCSI 0x04a9/0x160b Good Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported
DR-9050C USB SCSI 0x1083/0x1622 Good Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode
DR-9080C USB SCSI 0x04a9/0x1603 Good Simplex, duplex, all resolutions, binary/ht/gray/color, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported
DR-X10C USB SCSI 0x1083/0x1618 Untested Please test!

Backend: canon_pp (0.33)

Link(s): http://canon-fb330p.sourceforge.net
Manual page: sane-canon_pp

Manufacturer Model Interface USB id Status Comment
Canon CanoScan FB310P Parport (ECP)   Unsupported Rebadged Avision, different command set
CanoScan FB610P Parport (ECP)   Unsupported Rebadged Avision, different command set
CanoScan FB320P Parport (ECP)   Basic Newly added support
CanoScan FB620P Parport (ECP)   Basic Newly added support
CanoScan FB330P Parport (ECP)   Good  
CanoScan FB630P Parport (ECP)   Good  
CanoScan N340P Parport (ECP)   Good  
CanoScan N640P Parport (ECP)   Good  
CanoScan N640P ex Parport (ECP)   Good Just an N640P in a different box?

Backend: cardscan (2)

Link(s): http://www.thebility.com/cardscan/
Manual page: sane-cardscan
Comment: Backend updated for SANE release 1.0.21, see sane-cardscan manpage

Manufacturer Model Interface USB id Status Comment
Corex 800c USB 0x08f0/0x0005 Good 4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner
600c USB 0x08f0/0x0002 Basic 4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner

Backend: coolscan (0.4.3)

Link(s): http://andreas.rick.free.fr/sane/
Manual page: sane-coolscan

Manufacturer Model Interface USB id Status Comment
Nikon LS-20 SCSI   Basic The LS-20 has been replaced by the LS-30
LS-30 SCSI   Basic alpha: only 24/30 bit RGB + 32/40 bit RGBI
LS-2000 SCSI   Basic alpha: only 24/36 bit + RGB 32/48 bit RGBI
LS-1000 SCSI   Basic Doesn't support gamma correction

Backend: coolscan2 (0.1.8)

Link(s): http://coolscan2.sourceforge.net/
Manual page: sane-coolscan2

Manufacturer Model Interface USB id Status Comment
Nikon LS 30 SCSI   Complete working -- model available to developer
LS 2000 SCSI   Good  
LS 40 ED USB 0x04b0/0x4000 Complete  
LS 4000 ED IEEE-1394   Good needs linux kernel 2.4.19 or later
LS 50 ED USB 0x04b0/0x4001 Minimal  
Coolscan V ED USB 0x04b0/0x4001 Minimal  
Super Coolscan LS-5000 ED USB 0x04b0/0x4002 Untested May work, similar to LS 50 ED, but untested. Please tell us if it works.
LS 8000 ED IEEE-1394   Good needs linux kernel 2.4.19 or later

Backend: coolscan3 (1.0.0)

Manual page: sane-coolscan3

Manufacturer Model Interface USB id Status Comment
Nikon LS 30 SCSI   Complete  
Coolscan III SCSI   Complete Rebadged LS 30?
LS 40 ED USB 0x04b0/0x4000 Complete  
Coolspan IV USB 0x04b0/0x4000 Complete Rebadged LS 40?
LS 50 ED USB 0x04b0/0x4001 Minimal  
Coolscan V ED USB 0x04b0/0x4001 Minimal Rebadged LS 50?
LS 2000 SCSI   Good  
LS 4000 ED IEEE-1394   Good needs linux kernel 2.4.19 or later
Super Coolscan LS-5000 ED USB 0x04b0/0x4002 Untested May work, similar to LS 50 ED, but untested. Please tell us if it works.
LS 8000 ED IEEE-1394   Good needs linux kernel 2.4.19 or later

Backend: dell1600n_net

Manufacturer Model Interface USB id Status Comment
Dell 1600n Ethernet USB 0x413c/0x5250 Basic Supports colour and monochrome scans over ethernet (USB not supported)

Backend: epjitsu (20)

Link(s): http://www.thebility.com/epjitsu/
Manual page: sane-epjitsu
Comment: Backend updated for SANE release 1.0.21, see sane-epjitsu manpage

Manufacturer Model Interface USB id Status Comment
Fujitsu fi-60F USB 0x04c5/0x10c7 Basic A6-size flatbed, 300/600 dpi, color/gray/binary
ScanSnap S300 USB 0x04c5/0x1156 Good Duplex, 150/225/300/600 dpi, color/gray/binary, AC/USB power, buttons/sensors all supported. Scanner always scans in _triplex_ color, fast USB required.
ScanSnap S300M USB 0x04c5/0x117f Good Same as S300, with different usb id
ScanSnap S1100 USB 0x04c5/0x1200 Unsupported Beta version of backend source available, which works well, but breaks support for other epjitsu scanners. See http://ubuntuforums.org/showthread.php?t=1678335
ScanSnap S1300 USB 0x04c5/0x11ed Good Same as S300, with different usb id

Backend: epson (unmaintained)

Link(s): http://www.khk.net/sane
Manual page: sane-epson

Manufacturer Model Interface USB id Status Comment
Epson GT-5000 SCSI Parport   Good  
Actionscanner II SCSI Parport   Good US version of GT-5000
GT-6000 SCSI Parport   Good  
ES-300C SCSI Parport   Good US version of GT-6000
ES-300GS SCSI   Good  
GT-5500 SCSI   Good  
GT-6500 Parport   Good  
ES-600C Parport   Good US version of GT-6500
ES-1200C Parport   Good US version of GT-9000
GT-7000 SCSI   Good  
GT-8000 SCSI   Good  
ES-8500 SCSI   Good  
Perfection 636S SCSI   Complete US version of GT-7000
Perfection 636 SCSI   Complete  
Perfection 636U USB 0x04b8/0x0101 Complete  
Perfection 610 USB 0x04b8/0x0103 Complete  
Perfection 640 USB 0x04b8/0x010c Complete  
Perfection 1200S SCSI   Complete  
Perfection 1200U USB 0x04b8/0x0104 Complete  
Perfection 1200Photo USB 0x04b8/0x0104 Complete with TPU
Perfection 1240 SCSI USB 0x04b8/0x010b Complete  
Perfection 1640 SCSI USB 0x04b8/0x010a Complete  
Perfection 1650 USB 0x04b8/0x0110 Complete  
Perfection 1660 USB 0x04b8/0x011e Complete  
Perfection 2400 USB 0x04b8/0x011b Complete  
Perfection 2450 USB IEEE-1394 0x04b8/0x0112 Complete  
Perfection 3200 USB IEEE-1394 0x04b8/0x011c Complete US version of the GT-9800
Perfection 4870 USB 0x04b8/0x0128 Complete US version of the GT-X700
Perfection 4990 USB 0x04b8/0x012a Complete US version of the GT-X800
Expression 636 SCSI   Complete US version of GT-9500
Expression 800 SCSI   Complete  
Expression 1600 SCSI USB IEEE-1394 0x04b8/0x0107 Complete  
Expression 1680 SCSI USB IEEE-1394 0x04b8/0x010e Complete  
FilmScan 200 SCSI   Unsupported A better backend for the FilmScan 200 can be found at http://www.vjet.demon.co.uk/scanner/
CX-3200 USB 0x04b8/0x0802 Good  
CX-3600 USB 0x04b8/0x080e Good  
CX-3650 USB 0x04b8/0x080e Good  
CX-4600 USB 0x04b8/0x080d Good  
CX-4800 USB 0x04b8/0x0819 Good  
CX-5000 USB 0x04b8/0x082b Good  
CX-5200 USB 0x04b8/0x0801 Good  
CX-5400 USB 0x04b8/0x0801 Good  
CX-5400 USB 0x04b8/0x0808 Good  
CX-6300 USB 0x04b8/0x0805 Good  
CX-6400 USB 0x04b8/0x0805 Good  
CX-6500 USB 0x04b8/0x0813 Good  
CX-6600 USB 0x04b8/0x0813 Good  
RX-500 USB 0x04b8/0x0807 Good  
RX-600 USB 0x04b8/0x0806 Good  
RX-425 USB 0x04b8/0x080f Good  
RX-700 USB 0x04b8/0x0810 Good  
RX-620 USB 0x04b8/0x0811 Good  
DX-3850 USB 0x04b8/0x0818 Good  
CX-3700 USB 0x04b8/0x0818 Good  
CX-3800 USB 0x04b8/0x0818 Good  
CX-4200 USB 0x04b8/0x0820 Good  
DX-3800 USB 0x04b8/0x0818 Good  
DX-5000 USB 0x04b8/0x082b Good  
DX-5050 USB 0x04b8/0x082b Good  
DX-6000 USB 0x04b8/0x082e Good  
DX-7400 USB 0x04b8/0x0838 Good  
DX-4050 USB 0x04b8/0x082f Good  
AcuLaser CX11 USB 0x04b8/0x0815 Good  
AcuLaser CX11NF USB 0x04b8/0x0815 Good  
V700 USB IEEE-1394 0x04b8/0x012c Good  
V750 USB IEEE-1394 0x04b8/0x012c Good  

Backend: epson2 (1.0.124)

Manual page: sane-epson2

Manufacturer Model Interface USB id Status Comment
Epson Actionscanner II parallel SCSI   Good overseas version of the GT-5000
AcuLaser CX11 USB 0x04b8/0x0815 Good overseas version of the LP-A500
AcuLaser CX11NF USB Network 0x04b8/0x0815 Good network interface supported
AcuLaser CX11 with network interface and fax
AcuLaser CX21 USB 0x04b8/0x0835 Good network interface probably supported
Artisan 700 USB Network 0x04b8/0x0846 Good network interface supported
all-in-one
overseas version of the EP-801A
Artisan 710 Series USB 0x04b8/0x0852 Unsupported supported by the epkowa backend plus non-free interpreter
Artisan 800 USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
overseas version of the EP-901A
Artisan 810 Series USB 0x04b8/0x0853 Unsupported supported by the epkowa backend plus non-free interpreter
CC-500L USB 0x04b8/0x010d Unsupported all-in-one
CC-550L USB 0x04b8/0x011a Unsupported all-in-one
CC-570L USB 0x04b8/0x0802 Good all-in-one
CC-600PX USB 0x04b8/0x0801 Good all-in-one
CC-700 USB 0x04b8/0x0108 Unsupported all-in-one
EP-702A USB 0x04b8/0x0850 Unsupported supported by the epkowa backend plus non-free interpreter
EP-801A USB Network 0x04b8/0x0846 Good network interface supported
all-in-one
EP-802A USB 0x04b8/0x0852 Unsupported supported by the epkowa backend plus non-free interpreter
EP-901A USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
EP-901F USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
EP-902A USB 0x04b8/0x0853 Unsupported supported by the epkowa backend plus non-free interpreter
ES-300C SCSI parallel   Good overseas version of the GT-6000
ES-300GS SCSI   Good  
ES-600C parallel   Good overseas version of the GT-5400
ES-800C SCSI   Good overseas version of the GT-8000
ES-1000C ?   Unsupported overseas version of the GT-8500
ES-1200C parallel   Good overseas version of the GT-9000
ES-2000 SCSI USB 0x04b8/0x0107 Complete IEEE1394 untested
ES-2200 SCSI USB 0x04b8/0x010e Complete IEEE1394 untested
ES-6000 SCSI   Good  
ES-6000H SCSI   Good IEEE1394 untested
ES-6000HS SCSI   Good IEEE1394 untested
ES-7000H SCSI USB 0x04b8/0x0126 Good network interface unsupported
IEEE1394 untested
ES-8000 SCSI   Untested  
ES-8500 SCSI USB 0x04b8/0x0109 Good IEEE1394 untested
ES-9000H SCSI   Good IEEE1394 untested
ES-10000G USB 0x04b8/0x0129 Good network interface unsupported
IEEE1394 untested
ES-D400 USB 0x04b8/0x0136 Unsupported supported by the epkowa backend plus non-free interpreter
ES-H300 USB 0x04b8/0x012b Good network interface probably supported
ES-H7200 USB Ethernet 0x04b8/0x0138 Unsupported supported by the epkowa backend plus non-free interpreter
Expression 636 SCSI   Complete overseas version of the GT-9500
Expression 800 SCSI   Complete overseas version of the GT-9600
Expression 836XL SCSI   Untested overseas version of the ES-8000
Expression 1600 SCSI USB 0x04b8/0x0107 Complete IEEE1394 untested
overseas version of the ES-2000
Expression 1640XL SCSI USB 0x04b8/0x0109 Good IEEE1394 untested
overseas version of the ES-8500
Expression 1680 SCSI USB 0x04b8/0x010e Complete IEEE1394 untested
overseas version of the ES-2200
Expression 1680 Pro SCSI USB   Untested IEEE1394 option
Expression 1680XL Pro SCSI USB   Untested  
Expression 10000XL USB 0x04b8/0x0129 Good network interface probably supported
IEEE1394 untested
overseas version of the ES-10000G
Expression 10000XL Graphic Arts USB IEEE1394   Untested network interface probably supported
Expression 10000XL Photo USB IEEE1394   Untested network interface probably supported
F-3200 USB IEEE1394 0x04b8/0x080a Unsupported Film scanner
F-3200 Photo USB IEEE1394   Unsupported  
FilmScan 200 SCSI   Minimal will be supported
GT-1500 USB 0x04b8/0x0133 Unsupported supported by the epkowa backend plus non-free interpreter
GT-2200 USB 0x04b8/0x0102 Unsupported  
GT-2500 USB 0x04b8/0x012b Good network interface probably supported
overseas version of the ES-H300
GT-4000 ?   Untested  
GT-5000 parallel SCSI   Good  
GT-5400 parallel   Good  
GT-5500 SCSI   Good  
GT-6000 SCSI Parport   Good  
GT-6500 parallel   Good overseas version of the GT-5400
GT-6600U USB 0x04b8/0x0103 Complete  
GT-6700U USB 0x04b8/0x010c Complete  
GT-7000S SCSI   Complete  
GT-7000U USB 0x04b8/0x0101 Complete  
GT-7200U USB 0x04b8/0x010f Unsupported supported by the epkowa backend plus non-free interpreter
GT-7300U USB 0x04b8/0x011d Unsupported supported by the epkowa backend plus non-free interpreter
GT-7400U USB 0x04b8/0x0120 Unsupported supported by the snapscan backend
GT-7600S SCSI   Complete SCSI version of the GT-7600U
GT-7600U USB 0x04b8/0x0104 Complete USB version of the GT-7600S
GT-7600UF USB 0x04b8/0x0104 Complete GT-7600U with TPU option bundled
GT-7700U USB 0x04b8/0x010b Complete  
GT-8000 SCSI   Good  
GT-8200U USB 0x04b8/0x0110 Complete  
GT-8200UF USB 0x04b8/0x0110 Good  
GT-8300UF USB 0x04b8/0x011e Complete  
GT-8400UF USB 0x04b8/0x011f Unsupported  
GT-8500 ?   Untested  
GT-8700 SCSI USB 0x04b8/0x010a Complete  
GT-8700F SCSI USB 0x04b8/0x010a Good GT-8700U with TPU option bundled
GT-9000 parallel   Good  
GT-9300UF USB 0x04b8/0x011b Complete  
GT-9400UF USB 0x04b8/0x0116 Unsupported supported by the epkowa backend plus non-free interpreter
GT-9500 SCSI   Complete  
GT-9600 SCSI   Complete  
GT-9700F USB 0x04b8/0x0112 Complete IEEE1394 untested
GT-9800F USB 0x04b8/0x011c Complete IEEE1394 untested
GT-10000 SCSI   Good overseas version of the ES-6000
GT-10000+ SCSI   Good IEEE1394 untested
overseas version of the ES-6000H
GT-12000 SCSI   Untested overseas version of the ES-8000
GT-15000 SCSI USB 0x04b8/0x0126 Good IEEE1394 untested
overseas version of the ES-7000H
GT-20000 USB Ethernet 0x04b8/0x0138 Unsupported supported by the epkowa backend plus non-free interpreter
GT-30000 SCSI   Good IEEE1394 untested
overseas version of the ES-9000H
GT-D1000 USB 0x04b8/0x0133 Unsupported supported by the epkowa backend plus non-free interpreter
GT-F500 USB 0x04b8/0x0121 Unsupported supported by the epkowa backend plus non-free interpreter
GT-F520 USB 0x04b8/0x0122 Unsupported supported by the epkowa backend plus non-free interpreter
GT-F550 USB 0x04b8/0x0121 Unsupported supported by the epkowa backend plus non-free interpreter
GT-F570 USB 0x04b8/0x0122 Unsupported supported by the epkowa backend plus non-free interpreter
GT-F600 USB 0x04b8/0x0118 Unsupported supported by the epkowa backend plus non-free interpreter
GT-F650 USB 0x04b8/0x012d Unsupported supported by the epkowa backend plus non-free interpreter
GT-F670 USB 0x04b8/0x012e Unsupported supported by the epkowa backend plus non-free interpreter
GT-F700 USB 0x04b8/0x012f Unsupported supported by the epkowa backend plus non-free interpreter
GT-F720 USB 0x04b8/0x0131 Unsupported supported by the epkowa backend plus non-free interpreter
GT-S50 USB 0x04b8/0x0137 Unsupported supported by the epkowa backend plus non-free interpreter
GT-S80 USB 0x04b8/0x0136 Unsupported supported by the epkowa backend plus non-free interpreter
GT-S600 USB 0x04b8/0x012d Unsupported supported by the epkowa backend plus non-free interpreter
GT-S620 USB 0x04b8/0x0131 Unsupported supported by the epkowa backend plus non-free interpreter
GT-X700 USB 0x04b8/0x0128 Complete IEEE1394 untested
GT-X750 USB 0x04b8/0x0119 Unsupported supported by the epkowa backend plus non-free interpreter
GT-X770 USB 0x04b8/0x0130 Unsupported supported by the epkowa backend plus non-free interpreter
GT-X800 USB 0x04b8/0x012a Complete film area guide mode not supported
IEEE1394 untested
GT-X820 USB 0x04b8/0x013a Unsupported supported by the epkowa backend plus non-free interpreter
GT-X900 USB 0x04b8/0x012c Good IEEE1394 untested
GT-X970 USB 0x04b8/0x0135 Good IEEE1394 untested
LP-7900CS ?   Untested business all-in-one; scanner is a ES-7000H
LP-9000CCH ?   Untested business all-in-one; scanner is a ES-9000H
LP-9000CCS ?   Untested business all-in-one; scanner is a ES-7000H
LP-9000CFH ?   Untested business all-in-one; scanner is a ES-9000H
LP-9500CCS ?   Untested business all-in-one; scanner is a ES-7000H
LP-9500CFH ?   Untested business all-in-one; scanner is a ES-9000H
LP-9500CH2 ?   Untested business all-in-one; scanner is a ES-9000H
LP-9800CCH ?   Untested business all-in-one; scanner is a ES-9000H
LP-9800CCS ?   Untested business all-in-one; scanner is a ES-7000H
LP-9800CFH ?   Untested business all-in-one; scanner is a ES-9000H
LP-A500 USB Network 0x04b8/0x0815 Good network interface supported
business all-in-one
LP-M5000 USB 0x04b8/0x0843 Good network interface probably supported
business all-in-one
LP-M5500 USB 0x04b8/0x0817 Good network interface probably supported
business all-in-one
LP-M5500F USB 0x04b8/0x0817 Good network interface probably supported
business all-in-one
LP-M5500 with the fax option bundled
LP-M5600 USB 0x04b8/0x0833 Good network interface probably supported
business all-in-one
LP-M6000 USB 0x04b8/0x0834 Good network interface probably supported
business all-in-one
ME 200 USB 0x04b8/0x0830 Good all-in-one
ME 300 USB 0x04b8/0x0841 Good all-in-one
overseas version of the PX-401A
ME OFFICE 510 USB 0x04b8/0x084f Good all-in-one
ME Office 600F USB 0x04b8/0x0848 Good all-in-one
ME OFFICE 650FN Series USB 0x04b8/0x0854 Good all-in-one
ME Office 700FW USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
PM-A700 USB 0x04b8/0x0814 Good all-in-one
PM-A750 USB 0x04b8/0x081a Good all-in-one
PM-A820 USB 0x04b8/0x0827 Good all-in-one
PM-A840 USB 0x04b8/0x083c Good all-in-one
PM-A840S USB 0x04b8/0x083c Good network interface probably supported
all-in-one
PM-A850 USB 0x04b8/0x0806 Good all-in-one
PM-A870 USB 0x04b8/0x0811 Good all-in-one
PM-A890 USB 0x04b8/0x081c Good all-in-one
PM-A900 USB 0x04b8/0x0810 Good all-in-one
PM-A920 USB 0x04b8/0x082a Good all-in-one
PM-A940 USB 0x04b8/0x0837 Good all-in-one
PM-A950 USB 0x04b8/0x081d Good all-in-one
PM-A970 USB 0x04b8/0x0828 Good all-in-one
PM-T960 USB 0x04b8/0x0836 Good all-in-one
PM-T990 USB 0x04b8/0x0829 Good all-in-one
PM-A970 with network interface
PX-401A USB 0x04b8/0x0841 Good all-in-one
PX-402A USB 0x04b8/0x084d Good all-in-one
PX-501A USB 0x04b8/0x084a Good network interface probably supported
all-in-one
PX-502A USB 0x04b8/0x0856 Good all-in-one
PX-601F USB 0x04b8/0x0847 Good network interface probably supported
PX-A550 USB 0x04b8/0x080e Good all-in-one
PX-A620 USB 0x04b8/0x082f Good all-in-one
PX-A640 USB 0x04b8/0x0838 Good all-in-one
PX-A650 USB 0x04b8/0x0819 Good all-in-one
PX-A720 USB 0x04b8/0x082e Good all-in-one
PX-A740 USB 0x04b8/0x0839 Good all-in-one
PX-FA700 USB 0x04b8/0x083a Good all-in-one
Perfection 600 SCSI   Unsupported supported by the umax backend
rebadged UMAX Astra 1200S
Perfection 610 USB 0x04b8/0x0103 Complete overseas version of the GT-6600U
Perfection 636S SCSI   Complete overseas version of the GT-7000S
Perfection 636U USB 0x04b8/0x0101 Complete overseas version of the GT-7000U
Perfection 640U USB 0x04b8/0x010c Complete overseas version of the GT-6700U
Perfection 660 USB 0x04b8/0x0114 Unsupported supported by the snapscan backend
Perfection 1200S SCSI   Complete overseas version of the GT-7600S
Perfection 1200U USB 0x04b8/0x0104 Complete overseas version of the GT-7600U
Perfection 1200U PHOTO USB 0x04b8/0x0104 Complete Perfection 1200U with TPU option bundled
overseas version of the GT-7600UF
Perfection 1240U USB 0x04b8/0x010b Complete overseas version of the GT-7700U
Perfection 1250 USB 0x04b8/0x010f Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 1250 PHOTO USB 0x04b8/0x010f Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 1260 USB 0x04b8/0x011d Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 1260 PHOTO USB 0x04b8/0x011d Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 1270 USB 0x04b8/0x0120 Unsupported supported by the snapscan backend
overseas version of the GT-7400
Perfection 1600 SCSI   Unsupported  
Perfection 1640SU SCSI USB 0x04b8/0x010a Complete overseas version of the GT-8700
Perfection 1640SU PHOTO SCSI USB 0x04b8/0x010a Good overseas version of the GT-8700F
Perfection 1650 USB 0x04b8/0x0110 Complete overseas version of the GT-8200U
Perfection 1650 PHOTO USB 0x04b8/0x0110 Good overseas version of the GT-8200UF
Perfection 1660 PHOTO USB 0x04b8/0x011e Complete overseas version of the GT-8300UF
Perfection 1670 USB 0x04b8/0x011f Unsupported supported by the snapscan backend
Perfection 1670 PHOTO USB 0x04b8/0x011f Unsupported supported by the snapscan backend
overseas version of the GT-8400UF
Perfection 2400 PHOTO USB 0x04b8/0x011b Complete overseas version of the GT-9300UF
Perfection 2450 PHOTO USB IEEE-1394 0x04b8/0x0112 Complete overseas version of the GT-9700F
Perfection 2480 PHOTO USB 0x04b8/0x0121 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 2580 PHOTO USB 0x04b8/0x0121 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 3170 PHOTO USB 0x04b8/0x0116 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 3200 PHOTO USB IEEE-1394 0x04b8/0x011c Complete overseas version of the GT-9800F
Perfection 3490 PHOTO USB 0x04b8/0x0122 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 3590 PHOTO USB 0x04b8/0x0122 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 4180 PHOTO USB 0x04b8/0x0118 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 4490 PHOTO USB 0x04b8/0x0119 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection 4870 PHOTO USB 0x04b8/0x0128 Complete IEEE1394 untested
overseas version of the GT-X700
Perfection 4990 PHOTO USB 0x04b8/0x012a Good film area guide mode not supported
IEEE1394 untested
overseas version of the GT-X800
Perfection 4990 Pro USB IEEE1394   Untested seems to be a 4990 PHOTO with additional software
Perfection V10 USB 0x04b8/0x012d Unsupported supported by the epkowa backend plus non-free interpreter
Perfection V30 USB 0x04b8/0x0131 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection V100 Photo USB 0x04b8/0x012d Unsupported supported by the epkowa backend plus non-free interpreter
Perfection V200 Photo USB 0x04b8/0x012e Unsupported supported by the epkowa backend plus non-free interpreter
Perfection V300 Photo USB 0x04b8/0x0131 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection V350 Photo USB 0x04b8/0x012f Unsupported supported by the epkowa backend plus non-free interpreter
Perfection V500 Photo USB 0x04b8/0x0130 Unsupported supported by the epkowa backend plus non-free interpreter
Perfection V600 Photo USB 0x04b8/0x013a Unsupported supported by the epkowa backend plus non-free interpreter
Perfection V700 Photo USB 0x04b8/0x012c Good IEEE1394 untested
overseas version of the GT-X900
Perfection V750 Photo USB 0x04b8/0x012c Good IEEE1394 untested
overseas version of the GT-X900
Stylus CX1500 USB 0x04b8/0x080c Unsupported supported by the snapscan backend
all-in-one
Stylus CX2800 USB 0x04b8/0x0830 Good all-in-one
Stylus CX2900 USB 0x04b8/0x0830 Good all-in-one
Stylus CX3100 USB 0x04b8/0x0802 Good all-in-one
overseas version of the CC-570L
Stylus CX3200 USB 0x04b8/0x0802 Good all-in-one
overseas version of the CC-570L
Stylus CX3500 USB 0x04b8/0x080e Good all-in-one
overseas version of the PX-A550
Stylus CX3600 USB 0x04b8/0x080e Good all-in-one
overseas version of the PX-A550
Stylus CX3650 USB 0x04b8/0x080e Good all-in-one
Stylus CX3700 USB 0x04b8/0x0818 Good all-in-one
Stylus CX3800 USB 0x04b8/0x0818 Good all-in-one
Stylus CX3810 USB   Untested all-in-one
Stylus CX3900 USB 0x04b8/0x082f Good all-in-one
overseas version of the PX-A620
Stylus CX4100 USB 0x04b8/0x0820 Good all-in-one
Stylus CX4200 USB 0x04b8/0x0820 Good all-in-one
Stylus CX4300 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter
Stylus CX4400 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter
Stylus CX4500 USB 0x04b8/0x080d Good all-in-one
Stylus CX4600 USB 0x04b8/0x080d Good all-in-one
Stylus CX4700 USB 0x04b8/0x0819 Good all-in-one
overseas version of the PX-A650
Stylus CX4800 USB 0x04b8/0x0819 Good all-in-one
overseas version of the PX-A650
Stylus CX4900 USB 0x04b8/0x082b Good all-in-one
Stylus CX5000 USB 0x04b8/0x082b Good all-in-one
Stylus CX5100 USB 0x04b8/0x0801 Good all-in-one
overseas version of the CC-600PX
Stylus CX5200 USB 0x04b8/0x0801 Good all-in-one
overseas version of the CC-600PX
Stylus CX5300 USB 0x04b8/0x0808 Good all-in-one
Stylus CX5400 USB 0x04b8/0x0808 Good all-in-one
Stylus CX5500 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter
Stylus CX5600 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter
Stylus CX5700F USB 0x04b8/0x0821 Unsupported may work with the snapscan backend
all-in-one with FAX
Stylus CX5800F USB 0x04b8/0x0821 Unsupported may work with the snapscan backend
all-in-one with FAX
Stylus CX5900 USB 0x04b8/0x082e Good all-in-one
overseas version of the PX-A720
Stylus CX6000 USB 0x04b8/0x082e Good all-in-one
overseas version of the PX-A720
Stylus CX6300 USB 0x04b8/0x0805 Good all-in-one
mistakenly thinks its a PX-A650
Stylus CX6400 USB 0x04b8/0x0805 Good all-in-one
mistakenly thinks its a PX-A650
Stylus CX6500 USB 0x04b8/0x0813 Good all-in-one
Stylus CX6600 USB 0x04b8/0x0813 Good all-in-one
Stylus CX6900F USB 0x04b8/0x0831 Unsupported may work with the snapscan backend
all-in-one with FAX
Stylus CX7000F USB 0x04b8/0x0831 Unsupported may work with the snapscan backend
all-in-one with FAX
Stylus CX7300 USB 0x04b8/0x0838 Good all-in-one
overseas version of the PX-A640
Stylus CX7400 USB 0x04b8/0x0838 Good all-in-one
overseas version of the PX-A640
Stylus CX7700 USB 0x04b8/0x081f Good all-in-one
Stylus CX7800 USB 0x04b8/0x081f Good all-in-one
Stylus CX8300 USB 0x04b8/0x0839 Good all-in-one
overseas version of the PX-A740
Stylus CX8400 USB 0x04b8/0x0839 Good all-in-one
overseas version of the PX-A740
Stylus CX9300F USB 0x04b8/0x083a Good all-in-one
overseas version of the PX-FA700
Stylus CX9400Fax USB 0x04b8/0x083a Good all-in-one
overseas version of the PX-FA700
Stylus DX3800 USB 0x04b8/0x0818 Good all-in-one
Stylus DX3850 USB   Good all-in-one
Stylus DX4000 USB 0x04b8/0x082f Good all-in-one
overseas version of the PX-A620
Stylus DX4200 USB 0x04b8/0x0820 Good all-in-one
Stylus DX4400 USB 0x04b8/0x083f Unsupported supported by the epkowa backend plus non-free interpreter
Stylus DX4800 USB 0x04b8/0x0819 Good all-in-one
overseas version of the PX-A650
Stylus DX4850 USB 0x04b8/0x0819 Good all-in-one
DX4800 + card reader
Stylus DX5000 USB 0x04b8/0x082b Good all-in-one
Stylus DX6000 USB 0x04b8/0x082e Good all-in-one
overseas version of the PX-A720
Stylus DX7000F USB 0x04b8/0x0831 Unsupported may work with the snapscan backend
all-in-one with FAX
Stylus DX7400 USB 0x04b8/0x0838 Good all-in-one
overseas version of the PX-A640
Stylus DX8400 USB 0x04b8/0x0839 Good all-in-one
overseas version of the PX-A740
Stylus DX9400F USB 0x04b8/0x083a Good all-in-one
overseas version of the PX-FA700
Stylus Office BX300F USB 0x04b8/0x0848 Good all-in-one
Stylus Office BX310FN Series USB 0x04b8/0x0854 Good all-in-one
Stylus Office BX600FW USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
Stylus Office BX610FW Series USB 0x04b8/0x0855 Unsupported supported by the epkowa backend plus non-free interpreter
Stylus Office TX300F USB 0x04b8/0x0848 Good all-in-one
Stylus Office TX510FN Series USB 0x04b8/0x0854 Good all-in-one
Stylus Office TX600FW USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
Stylus Office TX610FW Series USB 0x04b8/0x0855 Unsupported supported by the epkowa backend plus non-free interpreter
Stylus Photo PX650 Series USB 0x04b8/0x0850 Unsupported supported by the epkowa backend plus non-free interpreter
Stylus Photo PX700W USB Network 0x04b8/0x0846 Good network interface supported
all-in-one
overseas version of the EP-801A
Stylus Photo PX710W Series USB 0x04b8/0x0852 Unsupported supported by the epkowa backend plus non-free interpreter
Stylus Photo PX800FW USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
overseas version of the EP-901A
Stylus Photo PX810FW Series USB 0x04b8/0x0853 Unsupported supported by the epkowa backend plus non-free interpreter
Stylus Photo RX420 USB 0x04b8/0x080f Good all-in-one
Stylus Photo RX425 USB 0x04b8/0x080f Good all-in-one
Stylus Photo RX430 USB 0x04b8/0x080f Good all-in-one
Stylus Photo RX500 USB 0x04b8/0x0807 Good all-in-one
Stylus Photo RX510 USB 0x04b8/0x0807 Good all-in-one
Stylus Photo RX520 USB 0x04b8/0x081a Good all-in-one
overseas version of the PM-A750
Stylus Photo RX530 USB 0x04b8/0x081a Good all-in-one
overseas version of the PM-A750
Stylus Photo RX560 USB 0x04b8/0x0827 Good all-in-one
overseas version of the PM-A820
Stylus Photo RX585 USB 0x04b8/0x083c Good all-in-one
overseas version of the PM-A840
Stylus Photo RX580 USB 0x04b8/0x0827 Good all-in-one
overseas version of the PM-A820
Stylus Photo RX595 USB 0x04b8/0x083c Good all-in-one
overseas version of the PM-A840
Stylus Photo RX590 USB 0x04b8/0x0827 Good all-in-one
overseas version of the PM-A820
Stylus Photo RX600 USB 0x04b8/0x0806 Good all-in-one
overseas version of the PM-A850
Stylus Photo RX610 USB 0x04b8/0x083c Good all-in-one
overseas version of the PM-A840
Stylus Photo RX620 USB 0x04b8/0x0811 Good all-in-one
overseas version of the PM-A870
Stylus Photo RX630 USB 0x04b8/0x0811 Good all-in-one
overseas version of the PM-A870
Stylus Photo RX640 USB 0x04b8/0x081c Good all-in-one
overseas version of the PM-A890
Stylus Photo RX650 USB 0x04b8/0x081c Good all-in-one
overseas version of the PM-A890
Stylus Photo RX680 USB 0x04b8/0x0837 Good all-in-one
overseas version of the PM-A940
Stylus Photo RX685 USB 0x04b8/0x0837 Good all-in-one
overseas version of the PM-A940
Stylus Photo RX690 USB 0x04b8/0x0837 Good all-in-one
overseas version of the PM-A940
Stylus Photo RX700 USB 0x04b8/0x0810 Good all-in-one
overseas version of the PM-A900
Stylus Photo TX650 Series USB 0x04b8/0x0850 Unsupported supported by the epkowa backend plus non-free interpreter
Stylus Photo TX700W USB 0x04b8/0x0846 Good network interface probably supported
all-in-one
overseas version of the EP-801A
Stylus Photo TX710W Series USB 0x04b8/0x0852 Unsupported supported by the epkowa backend plus non-free interpreter
Stylus Photo TX800FW USB 0x04b8/0x0844 Good network interface probably supported
all-in-one
overseas version of the EP-901A
Stylus NX100 USB 0x04b8/0x0841 Good all-in-one
overseas version of the PX-401A
Stylus NX110 Series USB 0x04b8/0x084d Good all-in-one
overseas version of the PX-402A
Stylus NX200 USB 0x04b8/0x0849 Good all-in-one
Stylus NX210 Series USB 0x04b8/0x084f Good all-in-one
Stylus NX300 USB 0x04b8/0x0848 Good all-in-one
Stylus NX400 USB 0x04b8/0x084a Good network interface probably supported
all-in-one
overseas version of the PX-501A
Stylus NX410 Series USB 0x04b8/0x0851 Good network interface probably supported
all-in-one
Stylus NX510 Series USB 0x04b8/0x0856 Good all-in-one
overseas version of the PX-502A
Stylus SX100 USB 0x04b8/0x0841 Good all-in-one
overseas version of the PX-401A
Stylus SX110 Series USB 0x04b8/0x084d Good all-in-one
overseas version of the PX-402A
Stylus SX125 USB 0x04b8/0x085c Untested all-in-one
Stylus SX200 USB 0x04b8/0x0849 Good all-in-one
Stylus SX205 USB 0x04b8/0x0849 Good all-in-one
Stylus SX210 Series USB 0x04b8/0x084f Good all-in-one
Stylus SX400 USB 0x04b8/0x084a Good network interface probably supported
all-in-one
overseas version of the PX-501A
Stylus SX405 USB 0x04b8/0x084a Good all-in-one
Stylus SX410 Series USB 0x04b8/0x0851 Good network interface probably supported
all-in-one
Stylus SX510W Series USB 0x04b8/0x0856 Good all-in-one
overseas version of the PX-502A
Stylus SX600FW USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
Stylus SX610FW Series USB 0x04b8/0x0855 Unsupported supported by the epkowa backend plus non-free interpreter
Stylus Scan 2000 USB 0x04b8/0x0105 Untested apparently mostly the same as the Stylus Scan 2500
Stylus Scan 2500 USB 0x04b8/0x0106 Untested scanner is apparently a GT-7000
Stylus TX100 USB 0x04b8/0x0841 Good all-in-one
overseas version of the PX-401A
Stylus TX110 Series USB 0x04b8/0x084d Good all-in-one
overseas version of the PX-402A
Stylus TX200 USB 0x04b8/0x0849 Good all-in-one
Stylus TX203 USB 0x04b8/0x0849 Good all-in-one
Stylus TX209 USB 0x04b8/0x0849 Good all-in-one
Stylus TX210 Series USB 0x04b8/0x084f Good all-in-one
Stylus TX400 USB 0x04b8/0x084a Good network interface probably supported
all-in-one
overseas version of the PX-501A
Stylus TX410 Series USB 0x04b8/0x0851 Good network interface probably supported
all-in-one
Stylus TX550W Series USB 0x04b8/0x0856 Good all-in-one
overseas version of the PX-502A
WorkForce 310 Series USB 0x04b8/0x0854 Good all-in-one
WorkForce 500 USB 0x04b8/0x084c Good all-in-one
WorkForce 600 USB 0x04b8/0x0847 Good network interface probably supported
all-in-one
overseas version of the PX-601F
WorkForce 610 Series USB 0x04b8/0x0855 Unsupported supported by the epkowa backend plus non-free interpreter

Backend: fujitsu (117)

Link(s): http://www.thebility.com/fujitsu/
Manual page: sane-fujitsu
Comment: Backend updated for SANE release 1.0.23, see sane-fujitsu manpage

Manufacturer Model Interface USB id Status Comment
Fujitsu M3091DC SCSI   Complete small, old, discontinued
M3092DC SCSI   Complete small, old, discontinued
fi-4120C SCSI USB 0x04c5/0x1041 Complete small, recent, discontinued, usb 1.1
fi-4120C2 SCSI USB 0x04c5/0x10ae Complete small, recent, discontinued, usb 2.0
fi-4220C SCSI USB 0x04c5/0x1042 Complete small, recent, discontinued, usb 1.1
fi-4220C2 SCSI USB 0x04c5/0x10af Complete small, recent, discontinued, usb 2.0
fi-5110C USB 0x04c5/0x1097 Complete small, recent, discontinued
fi-5110EOX/2 USB 0x04c5/0x1096 Complete small, recent, discontinued
fi-5110EOX3 USB 0x04c5/0x10e6 Complete small, recent, discontinued
fi-5110EOXM USB 0x04c5/0x10f2 Complete small, recent, discontinued
fi-5120C SCSI USB 0x04c5/0x10e0 Complete small, recent, discontinued
fi-5220C SCSI USB 0x04c5/0x10e1 Complete small, recent, discontinued
fi-5000N Ethernet   Untested Not a scanner, rather a scanner to ethernet interface
fi-6000NS Ethernet   Untested small, recent, discontinued, integrated touchscreen and keyboard
ScanSnap S500 USB 0x04c5/0x10fe Complete small, recent, discontinued
ScanSnap S500M USB 0x04c5/0x1135 Complete small, recent, discontinued
ScanSnap S510 USB 0x04c5/0x1155 Complete small, recent, discontinued
ScanSnap S510M USB 0x04c5/0x116f Complete small, recent, discontinued
fi-6130 USB 0x04c5/0x114f Complete small, recent, discontinued
fi-6230 USB 0x04c5/0x1150 Complete small, recent, discontinued
ScanSnap S1500 USB 0x04c5/0x11a2 Complete small, discontinued
ScanSnap S1500M USB 0x04c5/0x11a2 Complete small, discontinued, same as S1500
ScanSnap N1800 Ethernet   Untested small, current, integrated touchscreen and keyboard
ScanSnap fi-6010N Ethernet   Untested small, current, integrated touchscreen and keyboard
fi-6110 USB 0x04c5/0x11fc Complete small, current
fi-6130Z USB 0x04c5/0x11f3 Complete small, current
fi-6230Z USB 0x04c5/0x11f4 Complete small, current
ScanSnap iX500 USB WiFi 0x04c5/0x132b Good small, current, WiFi not supported. Hardware only scans in color. Backend generates binary and grayscale modes.
M3093E RS232C/Video   Unsupported medium, old, discontinued
M3093DE RS232C/Video   Unsupported medium, old, discontinued
M3093DG SCSI   Complete medium, old, discontinued
M3093EX RS232C/Video   Unsupported medium, old, discontinued
M3093GX SCSI   Complete medium, old, discontinued
M3096EX RS232C/Video   Unsupported medium, old, discontinued
M3096GX SCSI   Complete medium, old, discontinued
M3097E+ RS232C/Video   Unsupported medium, old, discontinued
M3097G+ SCSI   Complete medium, old, discontinued
M3097DE RS232C/Video   Unsupported medium, old, discontinued
M3097DG SCSI   Complete medium, old, discontinued
fi-4340C SCSI USB 0x04c5/0x10cf Complete medium, current
fi-4530C SCSI USB 0x04c5/0x1078 Complete medium, recent, discontinued
fi-4640S SCSI   Complete medium, recent, discontinued
fi-4750C SCSI   Complete medium, recent, discontinued
fi-5530C SCSI USB 0x04c5/0x10e2 Complete medium, recent, discontinued
fi-6140 SCSI USB 0x04c5/0x114d Complete medium, recent, discontinued
fi-6240 SCSI USB 0x04c5/0x114e Complete medium, recent, discontinued
fi-5530C2 SCSI USB 0x04c5/0x114a Complete medium, current
fi-6140Z SCSI USB 0x04c5/0x11f1 Complete medium, current
fi-6240Z SCSI USB 0x04c5/0x11f2 Complete medium, current
M3099A RS232C/Video   Unsupported big, old, discontinued
M3099G SCSI   Complete big, old, discontinued
M3099EH RS232C/Video   Unsupported big, old, discontinued
M3099GH SCSI   Complete big, old, discontinued
M3099EX RS232C/Video   Unsupported big, old, discontinued
M3099GX SCSI   Complete big, old, discontinued
M4097D SCSI   Complete big, old, discontinued
M4099D SCSI   Complete big, old, discontinued
fi-4750L SCSI   Complete big, recent, discontinued
fi-4860C SCSI   Complete big, recent, discontinued
fi-4860C2 SCSI   Complete big, recent, discontinued
fi-4990C SCSI   Complete big, recent, discontinued
fi-5650C SCSI USB 0x04c5/0x10ad Complete big, recent, discontinued
fi-5750C SCSI USB 0x04c5/0x1095 Complete big, recent, discontinued
fi-5900C SCSI USB 0x04c5/0x10e7 Good big, recent, discontinued. Independent ultrasonic control and multistream unsupported
fi-6750S USB 0x04c5/0x1178 Untested Simplex, USB only version of fi-6770, won't wakeup via software, discontinued
fi-5950 SCSI USB 0x04c5/0x1213 Untested big, current. Faster version of fi-5900?
fi-6670 SCSI USB 0x04c5/0x1176 Good big, current, won't wakeup via software
fi-6670A SCSI USB 0x04c5/0x1177 Good big, current, VRS CGA board unsupported, won't wakeup via software
fi-6770 SCSI USB 0x04c5/0x1174 Good big, current, won't wakeup via software
fi-6770A SCSI USB 0x04c5/0x1175 Good big, current, VRS CGA board unsupported, won't wakeup via software
fi-6800 SCSI USB 0x04c5/0x119d Untested big, current. Independent ultrasonic control and multistream unsupported
fi-6800-CGA SCSI USB 0x04c5/0x119e Untested big, current. VRS CGA board unsupported, Independent ultrasonic control and multistream unsupported

Backend: genesys (1.0-63)

Link(s): http://www.meier-geinitz.de/sane/genesys-backend/
Manual page: sane-genesys
Comment: Only the USB scanners mentioned below are currently supported.

Manufacturer Model Interface USB id Status Comment
Plustek OpticBook 3600 USB 0x07b3/0x0900 Basic Has a Primax USB ID
Medion/Lifetec/Tevion/Cytron MD5345 USB 0x0461/0x0377 Good Has a Primax USB ID
MD6228 USB 0x0461/0x0377 Good Has a Primax USB ID. Same as MD5345
MD6471 USB 0x0461/0x0377 Complete Has a Primax USB ID. Same as MD5345
Hewlett-Packard ScanJet 2300C USB 0x03f0/0x0901 Complete 600x1200 dpi max
ScanJet 2400C USB 0x03f0/0x0a01 Complete 1200x1200 dpi max
ScanJet G2410 USB 0x03f0/0x0a01 Basic clone of the HP 2400C
ScanJet 3670 USB 0x03f0/0x1405 Complete 1200x1200 dpi max, complete transparency adaptor support
ScanJet 3690C USB 0x03f0/0x1405 Complete 1200x1200 dpi max, same as HP 3670
ScanJet 4850C USB 0x03f0/0x1b05 Untested resolution from 100 to 2400 supported, UTA not supported yet
ScanJet G4010 USB 0x03f0/0x4505 Good resolution from 100 to 2400 supported, UTA not supported yet
ScanJet G4050 USB 0x03f0/0x4605 Good resolution from 100 to 2400 supported, UTA not supported yet
ScanJet N6310 USB 0x03f0/0x4705 Untested Not supported yet
Canon CanoScan LiDE 35 USB 0x04a9/0x2213 Good Same ids as LiDE 50.
CanoScan LiDE 40 USB 0x04a9/0x2213 Good Same ids as LiDE 50.
CanoScan LiDE 50 USB 0x04a9/0x2213 Good  
CanoScan LiDE 60 USB 0x04a9/0x221c Good  
CanoScan LiDE 100 USB 0x04a9/0x1904 Complete GL847 based, resolution from 75 to 2400 dpi
CanoScan LiDE 110 USB 0x04a9/0x1909 Complete GL124 based, resolution from 75 to 2400 dpi
CanoScan LiDE 200 USB 0x04a9/0x1905 Complete GL847 based, resolution from 75 to 4800 dpi
CanoScan LiDE 210 USB 0x04a9/0x190a Complete GL124 based, resolution from 75 to 2400 dpi
CanoScan 4400f USB 0x04a9/0x2228 Unsupported GL843 based, to be added to the genesys backend
CanoScan 5600F USB 0x04a9/0x1906 Unsupported GL847 based, to be added to the genesys backend
CanoScan 700F USB 0x04a9/0x1907 Good GL847 based, resolution from 75 to 4800 dpi
Canon Image Formula 101 USB 0x1083/0x162e Unsupported GL846 based, work in progress
Visioneer Strobe XP 100,r3 USB 0x04a7/0x049b Good All resolution and mode supported, calibration is available
Strobe XP 200 USB 0x04a7/0x0426 Good All resolution and mode supported, calibration is available
Strobe XP 300 USB 0x04a7/0x0474 Good All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally.
Roadwarrior USB 0x04a7/0x0494 Basic All resolution and mode supported, calibration is available
Visioneer OneTouch 7100 USB 0x04a7/0x0229 Complete Same as MD5345
Pentax DSmobile 600 USB 0x0a17/0x3210 Good All resolution and mode supported, calibration is available
DSmobile 600 USB 0x04f9/0x2038 Good All resolution and mode supported, calibration is available
DCT DocketPort 487 USB 0x1dcc/0x4810 Basic All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally.
Syscan DocketPort 485 USB 0x0a82/0x4810 Basic All resolution and mode supported, front- and backside side-by-side, with backside mirrored horizontally.
DocketPort 465 USB 0x0a82/0x4802 Untested All resolution and mode should be supported, but uncorrected scans
DocketPort 665 USB 0x0a82/0x4803 Basic All resolution and mode supported, calibration is available
DocketPort 685/ Ambir DS685 USB 0x0a82/0x480c Good All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally.
Xerox Travel Scanner 100 USB 0x04a7/0x04ac Good All resolution and mode supported, calibration is available
2400 Onetouch USB 0x0461/0x038b Complete GL646 based, resolution from 75 to 2400 dpi
Panasonic KV-SS080 USB 0x04da/0x100f Complete All resolution and mode supported, calibration is available. Support sponsored by cncsolutions (http://www.cncsolutions.com.br)

Backend: gt68xx (1.0-84)

Link(s): http://www.meier-geinitz.de/sane/gt68xx-backend/
Manual page: sane-gt68xx
Comment: Only the USB scanners mentioned below are supported. For other Mustek BearPaws, look at the Plustek and the MA-1509 backend.

Manufacturer Model Interface USB id Status Comment
Artec/Ultima Ultima 2000 USB 0x05d8/0x4002 Good Works, only product id 0x4002 is supported
Ultima 2000 e+ USB 0x05d8/0x4002 Good Works, however 12 bit mode doesn't seem to be supported
Boeder Sm@rtScan Slim Edition USB 0x05d8/0x4002 Good Similar to Artec Ultima 2000
Fujitsu 1200CUS USB 0x05d8/0x4002 Basic Works, but is slow. Probably a Mustek BearPaw 2400 CU clone.
Genius ColorPage Slim 1200 USB 0x0458/0x201e Untested Untested but should work.
Colorpage SF600 USB 0x0458/0x2021 Basic  
Colorpage Vivid3x USB 0x0458/0x2011 Good  
Colorpage Vivid3 V2 USB 0x0458/0x2011 Good Same as Colorpage Vivid3x
Colorpage Vivid3xe USB 0x0458/0x2017 Good  
Colorpage Vivid4 USB 0x0458/0x2014 Good  
Colorpage Vivid4x USB 0x0458/0x201b Good  
Colorpage Vivid4xe USB 0x0458/0x201a Good  
Colorpage Vivid 1200 X USB 0x0458/0x201d Good  
Colorpage Vivid 1200 XE USB 0x0458/0x201f Good  
Googlegear 2000 USB 0x05d8/0x4002 Good Same as Artec Ultima 2000.
Lexmark X70 USB 0x043d/0x002d Good Works, some resolutions fail at 16 bit
X73 USB 0x043d/0x002d Good Works, some resolutions fail at 16 bit, same as X70
Medion/Lifetec/Tevion/Cytron MD 4394 USB 0x05d8/0x4002 Good Product id 0x4002. If you have 0x4003, use artec_eplus48u backend.
MD/LT 9375 USB 0x05d8/0x4002 Untested Untested, but is reported to have the same ids as the Artec Ultima 2000. Please test.
MD/LT 9385 USB 0x05d8/0x4002 Good Similar to Artec Ultima 2000
LT 9452 USB 0x05d8/0x4002 Good Similar to Mustek ScanExpress 1200 UB Plus
MD 9458 USB 0x05d8/0x4002 Good Similar to Artec Ultima 2000 (e+?)
Mustek BearPaw 1200 CS USB 0x055f/0x021e Good  
BearPaw 1200 CU USB 0x05d8/0x4002 Good  
BearPaw 1200 CU Plus USB 0x055f/0x021b Good  
BearPaw 1200 CU Plus USB 0x055f/0x021c Good  
BearPaw 1200 TA USB 0x055f/0x021e Good Transparency adapter supported
BearPaw 1248 CU USB 0x055f/0x021c Good Seems to use the same ids as BearPaw 1200 CU Plus.
BearPaw 2400 CS USB 0x055f/0x0218 Untested Probably works, reports are welcome
BearPaw 2400 CS Plus USB 0x055f/0x0219 Good Works, problems with 12/16 bit modes?
BearPaw 2400 CU USB 0x05d8/0x4002 Basic Works, but is slow
BearPaw 2400 CU Plus USB 0x055f/0x021d Good  
BearPaw 2400 TA USB 0x055f/0x0218 Good Transparency adapter supported
BearPaw 2400 TA Plus USB 0x055f/0x0219 Good Transparency adapter supported
BearPaw 2448 CS Plus USB 0x055f/0x021a Basic Slow. Same as 2448 TA Plus, but without TA.
BearPaw 2448 TA Plus USB 0x055f/0x021a Basic Slow. Transparency adapter supported. Slow. Brightness depends on resolution?
Plug-n-Scan 2400 MT USB 0x055f/0x0219 Good Works but is slow in high resolutions. Same as BearPaw 2400 TA Plus.
Plug-n-Scan 2400 M USB 0x055f/0x0219 Good Works but is slow in high resolutions. Same as BearPaw 2400 CS Plus.
ScanExpress 1200 UB Plus USB 0x05d8/0x4002 Good  
ScanExpress 1248 UB USB 0x055f/0x021f Complete  
ScanExpress 2400 USB USB 0x05d8/0x4002 Minimal Should be detected but may need some more work in the code. Testers welcome. Please contact me if you own this scanner.
ScanExpress A3 USB USB 0x055f/0x0210 Basic Still some vertical stripes.
ScanMagic 1200 UB Plus USB 0x05d8/0x4002 Good Same as ScanExpress 1200 UB Plus
NeatReceipts Scanalizer Professional 2.5 USB 0x07b3/0x0412 Untested Similar to Plustek OpticSlim M12. Please tell us if this scanner works.
Mobile Scanner USB 0x07b3/0x0462 Basic Similar to Plustek OpticSlim M12.
Nortek MyScan 1200 USB 0x07b3/0x040b Untested Untested. Please test. Similar to Plustek OpticPro S12?
Packard Bell Diamond 1200 USB 0x05d8/0x4002 Good Similar to Mustek BearPaw 1200 (Plus)
Diamond 1200 Plus USB 0x055f/0x021c Good Similar to Mustek BearPaw 1200 Plus
Diamond 1200 Plus USB 0x055f/0x021b Good Similar to Mustek BearPaw 1200 Plus
Diamond 2450 USB 0x055f/0x0219 Good  
Plustek OpticPro 1248U USB 0x07b3/0x0400 Good  
OpticPro 1248U USB 0x07b3/0x0401 Good  
OpticPro U16B USB 0x07b3/0x0402 Good  
OpticPro U16B+ USB 0x07b3/0x0403 Good  
OpticPro UT16B USB 0x07b3/0x0403 Untested Probably works. Transparency adapter not supported yet. Please contact me if you own such a device.
OpticPro S12 USB 0x07b3/0x040b Good Product ID 0x040b only.
OpticPro S24 USB 0x07b3/0x040e Good Product ID 0x040e only. Is reported to work.
OpticPro ST12 USB 0x07b3/0x040b Untested Product ID 0x040b only. Needs testing. Transparency adapter completely untested. Please contact me if you own such a scanner.
OpticSlim 1200 USB 0x07b3/0x0413 Good  
OpticSlim 2400 USB 0x07b3/0x0422 Good Works up to 1200 dpi.
OpticSlim 2400 plus USB 0x07b3/0x0454 Good Same as OpticSlim 2400.
Iriscan Express 2 USB 0x07b3/0x045f Complete Works up to 1200 dpi. Calibration with external calibration sheet supported
OpticSlim M12 USB 0x07b3/0x0412 Complete Works up to 1200 dpi. Calibration with external calibration sheet supported
RevScan 19200i USB 0x07b3/0x0400 Good Similar to Plustek OpticPro 1248U
Trust 240TH Easy Webscan Gold USB 0x055f/0x0218 Good Same as Mustek Bearpaw 2400 TA plus.
Compact Scan USB 19200 USB 0x05d8/0x4002 Good Works, if you have vendor id 0x055f and product id 0x0006, use the mustek_usb backend instead, similar to Mustek ScanExpress 1200 UB (Plus)
Direct WebScan 19200 USB 0x055f/0x021c Good Same as Mustek BearPaw 1200 CU Plus (0x021c).
Flat Scan USB 19200 USB 0x05d8/0x4002 Good Similar to Artec Ultima 2000
Visioneer OneTouch 7300 USB 0x04a7/0x0444 Good Works upto 1200 dpi and 12 bits/color.

Backend: hp (1.06)

Link(s): http://www.kirchgessner.net/
Manual page: sane-hp

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard ScanJet Plus Propietary   Complete Driver for HP parallel interface card required
ScanJet IIc SCSI   Complete  
ScanJet IIp SCSI   Complete  
ScanJet IIcx SCSI   Complete  
ScanJet 3c SCSI   Complete  
ScanJet 3p SCSI   Complete  
ScanJet 4c SCSI   Complete  
ScanJet 4p SCSI   Complete  
ScanJet 4100C USB 0x03f0/0x0101 Complete  
ScanJet 5p SCSI   Complete  
ScanJet 5100C Parport   Complete Requires ppscsi driver and epst module
ScanJet 5200C Parport USB 0x03f0/0x0401 Complete Parallel interface requires ppscsi driver and epst module
ScanJet 6100C SCSI   Complete  
ScanJet 6200C SCSI USB 0x03f0/0x0201 Complete  
ScanJet 6250C SCSI USB 0x03f0/0x0201 Complete  
ScanJet 6300C SCSI USB 0x03f0/0x0601 Complete  
ScanJet 6350C SCSI USB 0x03f0/0x0601 Complete  
ScanJet 6390C SCSI USB 0x03f0/0x0601 Complete  
PhotoSmart PhotoScanner SCSI   Complete  

Backend: hp3500 (1.1)

Link(s): http://projects.troy.rollo.name/rt-scanners/
Manual page: sane-hp3500
Comment: HP3500 series scanners.

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard ScanJet 3500C USB 0x03f0/0x2205 Good  
ScanJet 3530C USB 0x03f0/0x2005 Good  
ScanJet 3570C USB 0x03f0/0x2005 Good  

Backend: hp3900 (0.12)

Link(s): http://sourceforge.net/projects/hp3900-series/
Manual page: sane-hp3900
Comment: Still Beta

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard ScanJet 3800 USB 0x03f0/0x2605 Basic Works with resolutions equal and less than 600dpi
ScanJet 3970c USB 0x03f0/0x2305 Good  
ScanJet 4070 Photosmart USB 0x03f0/0x2405 Good  
ScanJet 4370 USB 0x03f0/0x4105 Basic Works with resolutions lower than 1200dpi
ScanJet G2710 USB 0x03f0/0x2805 Basic Similar to hp scanjet 3800
ScanJet G3010 USB 0x03f0/0x4205 Basic Similar to hp scanjet 4370
ScanJet G3110 USB 0x03f0/0x4305 Basic Similar to hp scanjet 4370
UMAX Astra 4900 USB 0x06dc/0x0020 Minimal developing yet
BenQ 5550 USB 0x04a5/0x2211 Minimal developing yet

Backend: hp4200 (1.0-2)

Link(s): http://hp4200-backend.sourceforge.net
Manual page: sane-hp4200

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard ScanJet 4200C USB 0x03f0/0x0105 Basic 8bpp color, 75/150/300/600 dpi only
ScanJet 4200Cxi USB 0x03f0/0x0105 Basic 8bpp color, 75/150/300/600 dpi only
ScanJet 4200Cse USB 0x03f0/0x0105 Basic 8bpp color, 75/150/300/600 dpi only

Backend: hp5400 (1.0-2)

Link(s): http://sourceforge.net/projects/hp5400backend
Manual page: sane-hp5400
Comment: HP5400 and HP5470 scanners. Prototype backend available

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard ScanJet 5400c USB 0x03f0/0x1005 Basic  
ScanJet 5470c USB 0x03f0/0x1105 Basic  
ScanJet 5490c USB   Basic  

Backend: hp5590 (1.0.5)

Manual page: sane-hp5590

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard ScanJet 4500C USB 0x03f0/0x1205 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives
ScanJet 4570C USB 0x03f0/0x1305 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives
ScanJet 5500C USB 0x03f0/0x1305 Untested Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives
ScanJet 5550C USB 0x03f0/0x1205 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives
ScanJet 5590 USB 0x03f0/0x1705 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives
ScanJet 7650 USB 0x03f0/0x1805 Complete Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives

Backend: hpljm1005 (0)

Manual page: sane-hpljm1005

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard LaserJet M1005 MFP USB 0x03f0/0x3b17 Good grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI
LaserJet M1120 MFP USB 0x03f0/0x5617 Good grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI
LaserJet M1120n MFP USB 0x03f0/0x5717 Good grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI

Backend: hpsj5s (0.03)

Link(s): http://hpsj5s.sourceforge.net/
Manual page: sane-hpsj5s

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard ScanJet 5s Parport (EPP)   Minimal Requires libieee1284 library. Only gray mode.

Backend: hs2p (1.00)

Link(s): http://www.acjlaw.net:8080/~jeremy/Ricoh/
Manual page: sane-hs2p
Comment: This backend has been tested with the IS450DE (Duplex/Endorser). All major functions necessary for scanning are supported. This backend should work with all Ricoh scanners in the IS450 family as well as the IS420 series, but the IS420 has not yet been tested. Features provided by the optional Image Processing Unit (IPU) are not yet integrated into the backend, as my scanner lacks the IPU.

Manufacturer Model Interface USB id Status Comment
Ricoh IS450 SCSI   Complete All major scanning-related features are supported (except for IPU). Certain non-scanning features, such as those related to scanner maintenance, are not supported. Such features would be better implemented in a separate stand-alone tool. For instance, if you replace the ADF Unit, you must recalibrate the scanner optics using a Ricoh Test Sheet and reset the E^2PROM registers. Reports are welcome.
IS-410 SCSI   Untested Untested, please report!
IS-420 SCSI   Untested Untested, please report!
IS-430 SCSI   Untested Untested, please report!

Backend: ibm (1.0-4)

Link(s): http://www.meier-geinitz.de/sane/ibm-backend/
Manual page: sane-ibm
Comment: This backend has had only limited testing. It needs more work especially for the Ricoh scanners. Patches are welcome.

Manufacturer Model Interface USB id Status Comment
IBM 2456 SCSI   Basic Was reported to work long time ago. Reports are welcome.
Ricoh IS-410 SCSI   Untested Untested, please report!
IS-420 SCSI   Basic Works at least in flatbed mode.
IS-430 SCSI   Untested Untested, please report!

Backend: kodak (7)

Link(s): http://www.thebility.com/kodak/
Manual page: sane-kodak
Comment: New backend for SANE release 1.0.21, see sane-kodak manpage

Manufacturer Model Interface USB id Status Comment
Kodak Scanner 1500 SCSI   Untested Please test!
Scanner 2500 SCSI   Untested Please test!
Scanner 3500 SCSI   Untested Please test!
Scanner 3510 SCSI   Untested Please test!
Scanner 3520 SCSI   Untested Please test!
Color Scanner 3590C SCSI   Untested Please test!
Color Scanner 4500 SCSI   Untested Please test!
i150 Scanner IEEE-1394   Untested Please test!
i160 Scanner IEEE-1394   Untested Please test!
i250 Scanner IEEE-1394   Untested Please test!
i260 Scanner IEEE-1394   Untested Please test!
i280 Scanner IEEE-1394   Untested Please test!
Scanner 900 SCSI   Untested Please test!
Scanner 923 SCSI   Untested Please test!
Scanner 5500 SCSI   Untested Please test!
Scanner 7500 SCSI   Untested Please test!
Scanner 7520 SCSI   Untested Please test!
Scanner 9500 SCSI   Untested Please test!
Scanner 9520 SCSI   Untested Please test!
i610 Scanner IEEE-1394   Untested Please test!
i620 Scanner IEEE-1394   Untested Please test!
i640 Scanner IEEE-1394   Untested Please test!
i660 Scanner IEEE-1394   Untested Please test!
i730 Scanner IEEE-1394   Untested Please test!
i750 Scanner IEEE-1394   Untested Please test!
i780 Scanner IEEE-1394   Untested Please test!
i810 Scanner SCSI   Untested Please test!
i820 Scanner SCSI   Untested Please test!
i830 Scanner SCSI   Untested Please test!
i840 Scanner SCSI   Untested Please test!
i1840 Scanner IEEE-1394   Untested Please test!
i1860 Scanner IEEE-1394   Basic Uncompressed B&W, Gray and Color, some automatic features supported
s1740 SCSI   Untested Please test!

Backend: kodakaio (2.4.6)

Link(s): http://sourceforge.net/projects/cupsdriverkodak/
Manual page: sane-kodakaio
Comment: Backend for Kodak AiO ESP and Hero printers. Also possibly Advent AWL10

Manufacturer Model Interface USB id Status Comment
Kodak ESP 2150 USB 0x040a/0x4059 Untested Please test!
ESP 2170 USB 0x040a/0x4066 Untested Please test!
ESP 3200 USB 0x040a/0x4043 Untested Please test!
ESP 3300 USB 0x040a/0x4031 Untested Please test!
ESP 4100 USB 0x040a/0x4053 Untested Please test!
ESP 5000 USB 0x040a/0x4028 Untested Please test!
ESP 5100 USB 0x040a/0x4025 Untested Please test!
ESP 5200 USB Ethernet 0x040a/0x4041 Basic USB good, Network good
ESP 5300 USB 0x040a/0x4026 Untested Please test!
ESP 5500 USB 0x040a/0x4027 Untested Please test!
ESP 6100 USB 0x040a/0x4054 Untested Please test!
ESP 7200 USB 0x040a/0x4056 Untested Please test!
ESP 9200 USB 0x040a/0x4065 Untested Please test!
ESP 5 USB 0x040a/0x4032 Untested Please test!
ESP 7 USB 0x040a/0x403e Untested Please test!
ESP 9 USB 0x040a/0x403f Untested Please test!
ESP C110 USB 0x040a/0x4057 Untested Please test!
ESP C115 USB 0x040a/0x4058 Untested Please test!
ESP C310 USB 0x040a/0x405d Untested Please test!
ESP C315 USB 0x040a/0x405e Untested Please test!
Hero 3.1 USB 0x040a/0x406d Untested Please test!
Hero 5.1 USB 0x040a/0x4064 Untested Please test!
Hero Office 6.1 USB 0x040a/0x4062 Untested Please test!
Hero 7.1 USB 0x040a/0x4063 Untested Please test!
Hero 9.1 USB Ethernet 0x040a/0x4067 Basic USB good, Network good
Advent AW10 USB 0x040a/0x4060 Untested Please test!

Backend: kvs20xx (unmaintained)

Manual page: sane-kvs20xx
Comment: New backend for SANE release 1.0.22, see sane-kvs20xx manpage

Manufacturer Model Interface USB id Status Comment
Panasonic KV-S2025C SCSI   Untested  
KV-S2026C USB SCSI 0x04da/0x1000 Untested  
KV-S2028C USB 0x04da/0x100a Untested  
KV-S2045C SCSI   Untested  
KV-S2046C USB SCSI 0x04da/0x1001 Untested  
KV-S2048C USB 0x04da/0x1009 Untested  

Backend: kvs40xx (unmaintained)

Manual page: sane-kvs40xx
Comment: New backend for SANE release 1.0.23, see sane-kvs40xx manpage

Manufacturer Model Interface USB id Status Comment
Panasonic KV-S4065C USB 0x04da/0x100d Untested  
KV-S4085C USB 0x04da/0x100c Untested  
KV-S7075C USB 0x04da/0x100e Untested  

Backend: kvs1025 (unmaintained)

Manual page: sane-kvs1025
Comment: New backend for SANE release 1.0.21, see sane-kvs1025 manpage

Manufacturer Model Interface USB id Status Comment
Panasonic KV-S1020C USB 0x04da/0x1007 Good  
KV-S1025C USB 0x04da/0x1006 Good  
KV-S1045C USB 0x04da/0x1010 Good  

Backend: leo (1.0-10)

Link(s): http://www.zago.net/sane/#leo
Manual page: sane-leo

Manufacturer Model Interface USB id Status Comment
LEO LEOScan S3 SCSI   Good FCC ID LUZFS1130
Across Technologies FS-1130 SCSI   Good FCC ID LUZFS1130
Genius FS-1130 Colorpage Scanner SCSI   Good  

Backend: lexmark (1.0-0)

Link(s): http://stef.dev.free.fr/sane/lexmark
Manual page: sane-lexmark
Comment: This backend supports lexmark x1100 series scanners.

Manufacturer Model Interface USB id Status Comment
Lexmark X1110 USB 0x043d/0x007c Untested  
X1130 USB 0x043d/0x007c Good Supports 75, 150, 300, 600 dpi
X1140 USB 0x043d/0x007c Untested  
X1150 USB 0x043d/0x007c Good Supports 75, 150, 300, 600 dpi
X1170 USB 0x043d/0x007c Good Supports 75, 150, 300, 600 dpi
X1180 USB 0x043d/0x007c Good  
X1185 USB 0x043d/0x007c Good Tested with xscanimage. Supports 75, 150, 300, 600, 1200(600x1200) dpi resolutions. Does grayscale or colour scans in the following sizes: wallet, 3x5, 4x6, 5x7, 8x10, letter.
X1195 USB 0x043d/0x007c Untested  
X74 USB 0x043d/0x0060 Good Supports 75, 150, 300, 600 dpi
X12xx USB 0x043d/0x007d Good USB1.1 is OK, USB2.0 needs testing
Dell A920 USB 0x413c/0x5105 Good Relabelled X11xx model

Backend: ma1509 (1.0-3)

Link(s): http://www.meier-geinitz.de/sane/ma1509-backend/
Manual page: sane-ma1509

Manufacturer Model Interface USB id Status Comment
Mustek BearPaw 1200 F USB 0x055f/0x0010 Good Works upto 600 dpi. No support for TA and ADF yet.
Fujitsu fi-4110EOX/2/3 USB 0x04c5/0x1040 Unsupported Uses ma1509 chip, but very different from other scanners supported by the ma1509 backend

Backend: magicolor (1.0.0)

Link(s): http://wiki.kainhofer.com/hardware/magicolor_scan
Manual page: sane-magicolor

Manufacturer Model Interface USB id Status Comment
KONICA MINOLTA magicolor 1690MF USB Network 0x132b/0x2089 Good Multi-function color laser printer with fax, scanner and network interface
BizHub 162/132 USB Network   Unsupported Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov.
DiMage 1611 USB Network   Unsupported Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov.

Backend: matsushita (1.0-7)

Link(s): http://www.zago.net/sane
Manual page: sane-matsushita

Manufacturer Model Interface USB id Status Comment
Panasonic KV-SS25 SCSI   Complete  
KV-SS25D SCSI   Complete  
KV-SS50 SCSI   Untested  
KV-SS55 SCSI   Untested  
KV-SS50EX SCSI   Untested  
KV-SS55EX SCSI   Minimal no color, no high resolution, no automatic cropping
KV-SS850 SCSI   Untested  
KV-SS855 SCSI   Untested  
KV-S2025C SCSI   Minimal no color, no high resolution, no automatic cropping
KV-S2045C SCSI   Minimal no color, no high resolution, no automatic cropping
KV-S2065L SCSI   Minimal no color, no high resolution, no automatic cropping

Backend: microtek (0.13.1)

Link(s): http://www.mir.com/mtek/
Manual page: sane-microtek

Manufacturer Model Interface USB id Status Comment
Microtek Scanmaker E6 SCSI   Good  
Scanmaker E3 SCSI   Good  
Scanmaker E2 SCSI   Good 3-pass
Scanmaker 35t+ SCSI   Good slide-scanner
Scanmaker 45t SCSI   Good slide-scanner
Scanmaker 35 SCSI   Good slide-scanner
Scanmaker III SCSI   Good  
Scanmaker IISP SCSI   Good  
Scanmaker IIHR SCSI   Good 3-pass
Scanmaker IIG SCSI   Good gray only
Scanmaker II SCSI   Good 3-pass
Scanmaker 600Z(S) SCSI   Untested  
Scanmaker 600G(S) SCSI   Basic gray only (see manpage)
Color PageWiz SCSI (Parport)   Basic sheet-fed (preliminary, see mapage)
Agfa Arcus II SCSI   Good Arcus *II*, not Arcus!
StudioScan SCSI   Good  
StudioScan II SCSI   Good  
StudioScan IIsi SCSI   Good  
Studiostar SCSI   Minimal Is detected but scans are very dark
DuoScan SCSI   Basic  
Vobis Highscreen Realscan SCSI   Good  
Genius Colorpage-SP2 SCSI   Good Same as Microtek Scanmaker E3

Backend: microtek2 (unmaintained)

Link(s): http://karstenfestag.gmxhome.de/linux.html
Manual page: sane-microtek2

Manufacturer Model Interface USB id Status Comment
Microtek ScanMaker E3plus Parport   Complete  
ScanMaker E3plus SCSI   Complete  
ScanMaker X6 SCSI   Complete  
ScanMaker X6EL SCSI   Basic  
ScanMaker X6USB USB 0x05da/0x0099 Good  
ScanMaker V300 SCSI   Good  
ScanMaker V300 Parport   Good  
ScanMaker V310 SCSI   Basic  
ScanMaker V310 Parport   Basic  
ScanMaker V600 SCSI   Basic  
ScanMaker V600 Parport   Basic  
ScanMaker 330 SCSI   Basic  
ScanMaker 630 SCSI   Basic  
ScanMaker 636 SCSI   Complete  
ScanMaker 6400XL SCSI   Complete  
ScanMaker 9600XL SCSI   Good only flatbed mode ?
ScanMaker 9800XL IEEE-1394   Minimal IEEE-1394 seems to work. See link. More reports welcome.
Phantom 330CX Parport   Complete  
SlimScan C3 Parport   Complete  
Phantom 636 SCSI   Complete  
Phantom 636CX Parport   Complete  
SlimScan C6 USB 0x05da/0x009a Complete  
ScanMaker V6UPL USB 0x05da/0x00b6 Basic Sometimes scan speed goes to fast and results look badly smudged.
ScanMaker V6USL SCSI   Complete  
ScanMaker V6USL USB 0x05da/0x00a3 Complete  
ScanMaker V6USL USB 0x05da/0x80a3 Complete  
ScanMaker X12USL SCSI   Good only Flatbed mode ?
Vobis HighScan SCSI   Complete only E3plus based models
Scanport SQ300 Parport?   Basic  
SQ2030 Parport   Basic  
SQ4836 SCSI   Basic  
Genius ColorPage-EP Parport   Good  

Backend: mustek (1.0-138)

Link(s): http://www.meier-geinitz.de/sane/mustek-backend/
Manual page: sane-mustek
Comment: Most Mustek SCSI scanners are supported by this backend. For USB scanners, look at the mustek_usb backend.

Manufacturer Model Interface USB id Status Comment
Mustek Paragon MFS-6000CX SCSI   Good 3-pass
Paragon MFS-12000CX SCSI   Good 3-pass
Paragon MFC-600S SCSI   Complete  
Paragon 600 II CD SCSI   Complete  
Paragon 600 II ED Parport   Untested Completely untested. If it's the same as the 600 II EP, it may work. Please contact me if you own such a device.
Paragon 600 II EP Parport   Minimal Works, however only low resolutions and quality in color mode is bad.
ScanMagic 600 II SP SCSI   Complete  
TwainScan II SP SCSI   Complete  
Paragon MFC-800S SCSI   Complete  
Paragon 800 II SP SCSI   Complete  
Paragon MFS-6000SP SCSI   Complete  
Paragon MFS-8000SP SCSI   Complete  
Paragon MFS-1200SP SCSI   Complete  
Paragon MFS-12000SP SCSI   Complete  
ScanExpress 6000SP SCSI   Complete  
ScanExpress 12000SP SCSI   Complete  
ScanExpress 1200 FS SCSI   Untested One report that it crashes the computer. SCSI driver issue? Please contact me if you own such a device.
ScanExpress 12000SP Plus SCSI   Complete  
Paragon 1200 III SP SCSI   Complete  
Paragon 1200 LS SCSI   Complete  
ScanMagic 9636S SCSI   Complete  
ScanMagic 9636S Plus SCSI   Complete  
ScanExpress A3 SP SCSI   Basic Please test!
Paragon 1200 SP Pro SCSI   Good  
Paragon 1200 A3 Pro SCSI   Complete ADF and TA untested. Please contact me if you own such equipment.
Paragon 600 II N Proprietary   Basic Resolutions above 300 dpi may cause trouble.
Trust Imagery 1200 SCSI   Good 3-pass, Mustek Paragon MFS-6000CX compatible
Imagery 1200 SP SCSI   Complete Mustek Paragon MFS-6000SP compatible
Imagery 4800 SP SCSI   Complete Mustek Paragon 600 II CD compatible
SCSI Connect 19200 SCSI   Complete Mustek ScanExpress 12000SP compatible
SCSI excellence series 19200 SCSI   Complete Mustek ScanExpress 12000SP compatible
Primax Compact 4800 SCSI SCSI   Complete Mustek 600 II CD compatible

Backend: mustek_pp (13)

Link(s): http://penguin-breeder.org/sane/mustek_pp/
Manual page: sane-mustek_pp
Comment: Supports CIS and CCD type parallel port scanners from Mustek.

Manufacturer Model Interface USB id Status Comment
Mustek ScanExpress 6000 P Parport (EPP)   Good 300 dpi CCD scanner
ScanExpress 600 SEP Parport (EPP)   Good 300 dpi CCD scanner
ScanMagic 4800 P Parport (EPP)   Good 300 dpi CCD scanner
600 III EP Plus Parport (EPP)   Good 300 dpi CCD scanner
96 CP Parport (EPP)   Good 300x600 dpi CIS scanner
ScanExpress 600 CP Parport (EPP)   Good 300x600 dpi CIS scanner
ScanMagic 600 CP Parport (EPP)   Good 300x600 dpi CIS scanner
ScanExpress 1200 CP Parport (EPP)   Good 600x1200 dpi CIS scanner
ScanExpress 1200 CP+ Parport (EPP)   Good 600x1200 dpi CIS scanner
Medion/Lifetec/Tevion/Cytron MD 9848 Parport (EPP)   Good 300 dpi CCD scanner
MD 9806 Parport (EPP)   Good 300 dpi CCD scanner
MD/LT 935x Parport (EPP)   Good 600x1200 dpi CIS scanner
MD/LT 985x Parport (EPP)   Good 600x1200 dpi CIS scanner
MD/LT 9890 Parport (EPP)   Good 600x1200 dpi CIS scanner
Targa Funline TS12 EP Parport (EPP)   Good 600x1200 dpi CIS scanner
Funline TS6 EP Parport (EPP)   Good 300x600 dpi CIS scanner
Trust Easy Connect 9600+ Parport (EPP)   Good 300x600 dpi CIS scanner
Easy Connect 19200+ Parport (EPP)   Good 300x600 dpi CIS scanner
Viviscan Compact II Parport (EPP)   Good 300 dpi CCD scanner
Cybercom 9352 Parport (EPP)   Good CIS scanner
Gallery 4800 Parport (EPP)   Good 300 dpi CCD scanner
Network Easy Plus 30 Bit Parport (EPP)   Good 300 dpi CCD scanner
Micromaxx MM-9851 Parport (EPP)   Good 300x600 dpi CIS scanner

Backend: mustek_usb (1.0-18)

Link(s): http://www.meier-geinitz.de/sane/mustek_usb-backend/
Manual page: sane-mustek_usb
Comment: Only the USB scanners mentioned below are supported. For BearPaws, look at the Plustek, MA-1509, and gt68xx backends.

Manufacturer Model Interface USB id Status Comment
Mustek ScanExpress 600 CU USB 0x055f/0x0002 Complete  
ScanExpress 1200 CU USB 0x055f/0x0001 Complete  
ScanExpress 1200 CU Plus USB 0x055f/0x0008 Complete  
ScanExpress 1200 UB USB 0x055f/0x0006 Complete For the UB Plus, see gt68xx backend
Trust Compact Scan USB 19200 USB 0x055f/0x0006 Complete Mustek 1200 UB compatible

Backend: mustek_usb2 (1.0-10)

Link(s): http://www.meier-geinitz.de/sane/mustek_usb2-backend/
Manual page: sane-mustek_usb2
Comment: Only BearPaw 2448TA Pro is supported at the moment

Manufacturer Model Interface USB id Status Comment
Mustek BearPaw 2448TA Pro USB 0x055f/0x0409 Good  

Backend: nec (0.12)

Link(s): http://www5a.biglobe.ne.jp/~saetaka/
Manual page: sane-nec

Manufacturer Model Interface USB id Status Comment
NEC PC-IN500/4C SCSI   Good PC-IN500/4C was sold only in JAPAN

Backend: niash (0.3)

Link(s): http://sourceforge.net/projects/hp3300backend
Manual page: sane-niash

Manufacturer Model Interface USB id Status Comment
Hewlett-Packard ScanJet 3300c USB 0x03f0/0x0205 Complete  
ScanJet 3400c USB 0x03f0/0x0405 Complete If you use Linux 2.6, version 2.6.8 or newer is necessary.
ScanJet 4300c USB 0x03f0/0x0305 Complete If you use Linux 2.6, version 2.6.8 or newer is necessary.
ScanJet 4300c/Silitek USB 0x047b/0x1002 Complete If you use Linux 2.6, version 2.6.8 or newer is necessary.
Agfa Snapscan Touch USB 0x06bd/0x0100 Complete  
Trust Office Scan USB 19200 USB 0x047b/0x1000 Complete  

Backend: p5 (1)

Link(s): http://www.sane-project.org/
Manual page: sane-p5
Comment: New backend for SANE release 1.0.21, see sane-p5 manpage

Manufacturer Model Interface USB id Status Comment
PRIMAX PagePartner Parport (EPP/ECP)   Basic Sheetfed scanner, work in gray and color, but uncalibrated scans

Backend: pie (1.0)

Link(s): http://www.munton.demon.co.uk/sane
Manual page: sane-pie

Manufacturer Model Interface USB id Status Comment
Devcom 9636PRO SCSI   Good  
9636S SCSI   Untested  
9630S SCSI   Untested  
PIE ScanAce 1236S SCSI   Good  
ScanAce 1230S SCSI   Good  
ScanAce II SCSI   Untested  
ScanAce III SCSI   Good  
ScanAce Plus SCSI   Untested  
ScanAce II Plus SCSI   Untested  
ScanAce III Plus SCSI   Untested  
ScanAce V SCSI   Untested  
ScanAce ScanMedia SCSI   Untested  
ScanAce ScanMedia II SCSI   Untested  
ScanAce 630S SCSI   Untested  
ScanAce 636S SCSI   Untested  
Adlib JetScan630 SCSI   Good  
JetScan636PRO SCSI   Untested  

Backend: pixma (0.17.3)

Link(s): http://home.arcor.de/wittawat/pixma/, http://mp610.blogspot.com/
Manual page: sane-pixma

Manufacturer Model Interface USB id Status Comment
Canon PIXMA E500 USB 0x04a9/0x1758 Untested Testers needed!
PIXMA E510 USB 0x04a9/0x1761 Untested Testers needed!
PIXMA E600 USB 0x04a9/0x175a Untested Testers needed!
PIXMA E610 USB 0x04a9/0x1767 Untested Testers needed!
PIXMA MG2100 Series USB 0x04a9/0x1751 Complete All resolutions supported (up to 1200DPI).
PIXMA MG2200 Series USB 0x04a9/0x1760 Untested Testers needed!
PIXMA MG3100 Series USB WLAN 0x04a9/0x1752 Complete All resolutions supported (up to 1200DPI).
PIXMA MG3200 Series USB 0x04a9/0x1762 Untested Testers needed!
PIXMA MG4100 Series USB 0x04a9/0x1753 Untested Testers needed!
PIXMA MG4200 Series USB 0x04a9/0x1763 Complete All resolutions supported (up to 1200DPI).
PIXMA MG5100 Series USB 0x04a9/0x1748 Complete All resolutions supported (up to 1200DPI).
PIXMA MG5200 Series USB 0x04a9/0x1749 Complete All resolutions supported (up to 1200DPI).
PIXMA MG5300 Series USB 0x04a9/0x1754 Complete All resolutions supported (up to 2400DPI).
PIXMA MG5400 Series USB 0x04a9/0x1764 Untested Testers needed!
PIXMA MG6100 Series USB 0x04a9/0x174a Complete All resolutions supported (up to 2400 DPI)
PIXMA MG6200 Series USB 0x04a9/0x1755 Complete All resolutions supported (up to 4800 DPI)
PIXMA MG6300 Series USB Ethernet 0x04a9/0x1765 Complete All resolutions supported (up to 2400DPI).
PIXMA MG8100 Series USB 0x04a9/0x174b Untested Testers needed!
PIXMA MG8200 Series USB Ethernet 0x04a9/0x1756 Complete All resolutions supported (up to 4800DPI).
PIXMA MP140 USB 0x04a9/0x172b Complete All resolutions supported (up to 600 DPI)
PIXMA MP150 USB 0x04a9/0x1709 Good  
PIXMA MP160 USB 0x04a9/0x1714 Basic  
PIXMA MP170 USB 0x04a9/0x170a Complete All resolutions supported (up to 1200DPI).
PIXMA MP180 USB 0x04a9/0x1715 Basic  
PIXMA MP190 USB 0x04a9/0x1734 Complete All resolutions supported (up to 600DPI)
PIXMA MP210 USB 0x04a9/0x1721 Complete All resolutions supported (up to 600DPI)
PIXMA MP220 USB 0x04a9/0x1722 Complete All resolutions supported (up to 1200DPI).
PIXMA MP230 USB 0x04a9/0x175f Complete All resolutions supported (up to 600DPI).
PIXMA MP240 USB 0x04a9/0x1732 Complete All resolutions supported (up to 1200DPI)
PIXMA MP250 USB 0x04a9/0x173a Complete All resolutions supported (up to 600DPI)
PIXMA MP260 USB 0x04a9/0x1733 Complete All resolutions supported (up to 1200DPI)
PIXMA MP270 USB 0x04a9/0x173b Complete All resolutions supported (up to 1200DPI)
PIXMA MP280 USB 0x04a9/0x1746 Good All resolutions supported (up to 600DPI).
PIXMA MP360 USB 0x04a9/0x263c Complete All resolutions supported (up to 1200DPI).
PIXMA MP370 USB 0x04a9/0x263d Complete All resolutions supported (up to 1200DPI).
PIXMA MP375R USB 0x04a9/0x263f Untested Same protocol as Pixma MP360/370/390? Testers needed!
PIXMA MP390 USB 0x04a9/0x263e Complete All resolutions supported (up to 1200DPI).
PIXMA MP450 USB 0x04a9/0x170b Complete All resolutions supported (up to 1200DPI).
PIXMA MP460 USB 0x04a9/0x1716 Complete All resolutions supported (up to 1200DPI).
PIXMA MP470 USB 0x04a9/0x1723 Complete All resolutions supported (up to 2400DPI).
PIXMA MP480 USB 0x04a9/0x1731 Complete All resolutions supported (up to 2400DPI)
PIXMA MP490 USB 0x04a9/0x173c Complete All resolutions supported (up to 1200DPI)
PIXMA MP493 USB 0x04a9/0x1757 Untested Testers needed!
PIXMA MP495 USB 0x04a9/0x1747 Untested Same protocol as Pixma MP280? Testers needed!
PIXMA MP500 USB 0x04a9/0x170c Good  
PIXMA MP510 USB 0x04a9/0x1717 Complete All resolutions supported (up to 1200DPI).
PIXMA MP520 USB 0x04a9/0x1724 Complete All resolutions supported (up to 2400DPI)
PIXMA MP530 USB 0x04a9/0x1712 Good  
PIXMA MP540 USB 0x04a9/0x1730 Complete All resolutions supported (up to 2400DPI)
PIXMA MP550 USB 0x04a9/0x173d Complete All resolutions supported (up to 2400DPI)
PIXMA MP560 USB 0x04a9/0x173e Complete All resolutions supported (up to 2400DPI)
PIXMA MP600 USB 0x04a9/0x1718 Complete All resolutions supported (up to 2400DPI)
PIXMA MP600R USB Ethernet 0x04a9/0x1719 Complete All resolutions supported (up to 2400DPI)
PIXMA MP610 USB 0x04a9/0x1725 Complete All resolutions supported (up to 4800DPI)
PIXMA MP620 USB Ethernet 0x04a9/0x172f Complete All resolutions supported (up to 2400DPI)
PIXMA MP630 USB 0x04a9/0x172e Complete All resolutions supported (up to 4800DPI)
PIXMA MP640 USB Ethernet 0x04a9/0x173f Complete All resolutions supported (up to 4800DPI)
PIXMA MP700 USB 0x04a9/0x2630 Complete All resolutions supported (flatbed color up to 1200DPI, grayscale up to 600DPI).
PIXMA MP710 USB 0x04a9/0x264d Complete All resolutions supported (up to 1200DPI)
PIXMA MP730 USB 0x04a9/0x262f Good Flatbed color up to 1200DPI, grayscale up to 600DPI. ADF scan to be confirmed.
PIXMA MP740 USB 0x04a9/0x264c Untested Same protocol as Pixma MP710? Testers needed!
PIXMA MP750 USB 0x04a9/0x1706 Minimal No grayscale. Canceling scan in ADF mode doesn't eject the paper!
PIXMA MP760 USB 0x04a9/0x1708 Minimal No grayscale. The scanner sometimes hangs!
PIXMA MP770 USB 0x04a9/0x1708 Minimal No grayscale. The scanner sometimes hangs!
PIXMA MP780 USB 0x04a9/0x1707 Minimal No grayscale. The scanner sometimes hangs!
PIXMA MP790 USB 0x04a9/0x1707 Minimal No grayscale. The scanner sometimes hangs!
PIXMA MP800 USB 0x04a9/0x170d Complete All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI.
PIXMA MP800R USB 0x04a9/0x170e Complete All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI.
PIXMA MP810 USB 0x04a9/0x171a Complete All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI.
PIXMA MP830 USB 0x04a9/0x1713 Complete All resolutions supported up to 2400DPI. Flatbed, ADF simplex and Duplex supported.
PIXMA MP960 USB 0x04a9/0x171b Complete All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI.
PIXMA MP970 USB Ethernet 0x04a9/0x1726 Complete All resolutions supported (up to 4800DPI). Full TPU support (negative and slides) at 24 or 48 bits.
PIXMA MP980 USB Ethernet 0x04a9/0x172d Complete Working fine at all resolutions.
PIXMA MP990 USB Ethernet 0x04a9/0x1740 Complete Working fine at all resolutions.
PIXMA MX300 USB 0x04a9/0x1727 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
PIXMA MX310 USB 0x04a9/0x1728 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI)
PIXMA MX320 USB 0x04a9/0x1736 Untested Same protocol as Pixma Generation 3? Testers needed!
PIXMA MX330 USB 0x04a9/0x1737 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI)
PIXMA MX340 USB 0x04a9/0x1741 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI)
PIXMA MX350 USB Ethernet 0x04a9/0x1742 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI)
PIXMA MX360 USB 0x04a9/0x174d Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy.
PIXMA MX370 Series USB 0x04a9/0x1759 Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI).
PIXMA MX390 Series USB 0x04a9/0x1766 Untested Testers needed!
PIXMA MX410 USB Ethernet 0x04a9/0x174e Untested Same protocol as Pixma MX420? Testers needed!
PIXMA MX420 USB Ethernet 0x04a9/0x174f Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy.
PIXMA MX430 Series USB Ethernet 0x04a9/0x175b Untested Testers needed!
PIXMA MX450 Series USB 0x04a9/0x1768 Untested Testers needed!
PIXMA MX510 Series USB Ethernet 0x04a9/0x175c Untested Testers needed!
PIXMA MX520 Series USB 0x04a9/0x1769 Untested Testers needed!
PIXMA MX700 USB Ethernet 0x04a9/0x1729 Complete Flatbed and ADF scan. All resolutions supported (up to 2400DPI)
PIXMA MX710 Series USB Ethernet 0x04a9/0x175d Untested Testers needed!
PIXMA MX720 Series USB 0x04a9/0x176a Untested Testers needed!
PIXMA MX850 USB Ethernet 0x04a9/0x172c Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported.
PIXMA MX860 USB Ethernet 0x04a9/0x1735 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported.
PIXMA MX870 USB Ethernet 0x04a9/0x1743 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.
PIXMA MX880 Series USB Ethernet 0x04a9/0x1750 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.
PIXMA MX882 USB Ethernet 0x04a9/0x1750 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.
PIXMA MX885 USB Ethernet 0x04a9/0x1750 Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.
PIXMA MX890 Series USB Ethernet 0x04a9/0x175e Complete All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.
PIXMA MX920 Series USB 0x04a9/0x176b Untested Testers needed!
PIXMA MX7600 USB Ethernet 0x04a9/0x171c Complete Flatbed and ADF scan. All resolutions supported (up to 4800DPI)
imageCLASS D420 USB 0x04a9/0x26ef Complete All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported.
imageCLASS D480 USB 0x04a9/0x26ed Complete All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported.
i-SENSYS MF3010 USB Ethernet 0x04a9/0x2759 Complete All resolutions supported (up to 600DPI)
imageCLASS MF3110 USB 0x04a9/0x2660 Complete All resolutions supported (up to 600DPI).
imageCLASS MF3240 USB 0x04a9/0x2684 Complete All resolutions supported (up to 600DPI)
imageCLASS MF4010 USB 0x04a9/0x26b4 Complete All resolutions supported (up to 600DPI)
imageCLASS MF4018 USB 0x04a9/0x26b4 Complete All resolutions supported (up to 600DPI)
imageCLASS MF4120 USB 0x04a9/0x26a3 Complete All resolutions supported (up to 600DPI)
imageCLASS MF4122 USB 0x04a9/0x26a3 Complete All resolutions supported (up to 600DPI)
imageCLASS MF4140 USB 0x04a9/0x26a3 Complete All resolutions supported (up to 600DPI)
imageCLASS MF4150 USB 0x04a9/0x26a3 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
imageCLASS MF4270 USB 0x04a9/0x26b5 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
I-SENSYS MF4320d USB 0x04a9/0x26ee Complete All resolutions supported (up to 600DPI)
I-SENSYS MF4330d USB 0x04a9/0x26ee Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
imageCLASS MF4350d USB 0x04a9/0x26ee Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
imageCLASS MF4370dn USB 0x04a9/0x26ec Good Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported
imageCLASS MF4380dn USB 0x04a9/0x26ec Good Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported
imageCLASS MF4410 USB 0x04a9/0x2737 Complete All resolutions supported (up to 600DPI)
imageCLASS MF4430 USB 0x04a9/0x2737 Good Flatbed and ADF scan. All resolutions supported (up to 600DPI). ADF empty buggy.
i-SENSYS MF4550d USB 0x04a9/0x2736 Good Flatbed and ADF scan. All resolutions supported (up to 600DPI).
imageCLASS MF4660 USB 0x04a9/0x26b0 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
imageCLASS MF4690 USB 0x04a9/0x26b0 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
imageCLASS MF5630 USB 0x04a9/0x264e Untested Testers needed!
laserBase MF5650 USB 0x04a9/0x264f Untested Testers needed!
imageCLASS MF5730 USB 0x04a9/0x265d Complete Flatbed and ADF scan. All resolutions supported (up to 1200DPI).
imageCLASS MF5750 USB 0x04a9/0x265e Untested Testers needed!
imageCLASS MF5770 USB 0x04a9/0x265f Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI).
i-SENSYS MF5880dn USB 0x04a9/0x26f9 Untested Testers needed!
imageCLASS MF6500 series USB 0x04a9/0x2686 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
imageCLASS MF6550 USB 0x04a9/0x2686 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
i-SENSYS MF6680dn USB 0x04a9/0x26fa Untested Testers needed!
imageCLASS MF8030 USB 0x04a9/0x2707 Untested Testers needed!
imageCLASS MF8170c USB 0x04a9/0x2659 Untested Testers needed!
imageRUNNER 1020/1024/1025 USB 0x04a9/0x26e6 Complete Flatbed and ADF scan. All resolutions supported (up to 600DPI)
CanoScan 8800F USB 0x04a9/0x1901 Complete Flatbed scan. TPU for negatives and slides. All resolutions supported (up to 4800DPI).
CanoScan 9000F USB 0x04a9/0x1908 Complete Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI.
CanoScan 9000F Mark II USB 0x04a9/0x190d Complete Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI.

Backend: plustek (0.52)

Link(s): http://www.gjaeger.de/scanner/plustek/
Manual page: sane-plustek

Manufacturer Model Interface USB id Status Comment
Plustek OpticPro U12 USB 0x07b3/0x0010 Complete NOTE: Devices with product ID 0x0001 are not supported!
OpticPro UT12 USB 0x07b3/0x0013 Complete  
OpticPro UT12 USB 0x07b3/0x0017 Complete Note: Devices with product ID 0x0001 are not supported!
OpticPro UT16 USB 0x07b3/0x0017 Complete  
OpticPro U24 USB 0x07b3/0x0011 Complete  
OpticPro U24 USB 0x07b3/0x0015 Complete  
OpticPro UT24 USB 0x07b3/0x0017 Complete  
Genius Colorpage HR6 V2 USB 0x0458/0x2007 Complete  
Colorpage HR6 V2 USB 0x0458/0x2008 Complete  
Colorpage HR7 USB 0x0458/0x2013 Complete  
Colorpage HR6A USB 0x0458/0x2009 Untested  
Colorpage HR7LE USB 0x0458/0x2015 Untested  
Colorpage HR6X USB 0x0458/0x2016 Untested  
Mustek BearPaw 1200 USB 0x0400/0x1000 Complete both product versions are supported, see backends' man-page
BearPaw 1200 USB 0x0400/0x1001 Complete both product versions are supported, see backends' man-page
BearPaw 2400 USB 0x0400/0x1001 Complete  
Hewlett-Packard ScanJet 2100C USB 0x03f0/0x0505 Complete  
ScanJet 2200C USB 0x03f0/0x0605 Complete  
Epson Perfection 1250 USB 0x04b8/0x010f Complete  
Perfection 1250Photo USB 0x04b8/0x010f Good TPA scans not perfect
Perfection 1260 USB 0x04b8/0x011d Complete  
Perfection 1260Photo USB 0x04b8/0x011d Good TPA scans not perfect
Umax UMAX 3400 USB 0x1606/0x0050 Complete there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x
UMAX 3400 USB 0x1606/0x0060 Complete there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x
UMAX Astranet ia101 USB 0x1606/0x0060 Complete seems to be a renamed UMAX 3400
UMAX 3450 USB 0x1606/0x0060 Complete  
UMAX 5400 USB 0x1606/0x0160 Complete  
Compaq S4-100 USB 0x049f/0x001a Complete Identical to UMAX 3400
Canon CanoScan N650U/N656U USB 0x04a9/0x2206 Complete  
CanoScan N1220U USB 0x04a9/0x2207 Complete  
CanoScan N670U/N676U/LiDE20 USB 0x04a9/0x220d Complete  
CanoScan N1240U/LiDE30 USB 0x04a9/0x220e Complete  
CanoScan LiDE25 USB 0x04a9/0x2220 Good  
CanoScan D660U USB 0x04a9/0x2208 Good TPA scans not perfect
Syscan TravelScan 460/464 USB 0x0a82/0x4600 Complete  
TravelScan 662 USB 0x0a82/0x6620 Complete  
Ambir Visigo A4 USB 0x0a82/0x4600 Complete Rebaged Travelscan 464
Portable Peripheral Co., Ltd. Q-Scan USB001 (A4 portable scanner) USB 0x0a53/0x1000 Complete  
Q-Scan USB201 (A6 portable scanner) USB 0x0a53/0x2000 Good  
Visioneer Strobe XP 100 USB 0x04a7/0x0427 Basic  

Backend: plustek_pp (0.43)

Link(s): http://www.gjaeger.de/scanner/plustek_pp/
Manual page: sane-plustek_pp

Manufacturer Model Interface USB id Status Comment
Plustek OpticPro 4800P Parport (SPP, EPP)   Complete  
OpticPro 4830P Parport (SPP, EPP)   Complete  
OpticPro 600P/6000P Parport (SPP, EPP)   Complete  
OpticPro 4831P Parport (SPP, EPP)   Complete  
OpticPro 9630P Parport (SPP, EPP)   Complete  
OpticPro 9630PL Parport (SPP, EPP)   Complete use driver-switch mov=1
OpticPro 9600P Parport (SPP, EPP)   Complete  
OpticPro 1236P Parport (SPP, EPP)   Complete reported as OpticPro 12000P/96000P
OpticPro 12000P/96000P Parport (SPP, EPP)   Complete  
OpticPro 9636P Parport (SPP, EPP)   Complete use driver-switch mov=4
OpticPro 9636P+/Turbo Parport (SPP, EPP)   Complete use driver-switch mov=3
OpticPro 9636T Parport (SPP, EPP)   Complete  
OpticPro 12000T Parport (SPP, EPP)   Complete  
OpticPro AI3 Parport (SPP, EPP)   Basic use driver-switch mov=5, poor picture quality
OpticPro P8 Parport   Untested  
OpticPro P12 Parport (SPP, EPP)   Complete  
OpticPro PT12 Parport (SPP, EPP)   Complete  
Primax Colorado 4800 Parport (SPP, EPP)   Untested same as OpticPro 4800P
Compact 4800 Direct Parport (SPP, EPP)   Complete use driver-switch mov=2
Compact 4800 Direct-30 Parport (SPP, EPP)   Complete same as OpticPro 4830P, use driver-switch mov=7
Compact 9600 Direct-30 Parport (SPP, EPP)   Complete same as OpticPro 9630P
Genius Colorpage Vivid III V2 Parport (SPP, EPP)   Complete Reported as PT12
Colorpage Vivid Pro II Film Parport (SPP, EPP)   Complete Reported as OP9636T/12000T
Colorpage HR6X EPP Parport (SPP, EPP)   Good Negative scanning does not work correctly
Aries Scan-It Pro 4800 Parport (SPP, EPP)   Complete use driver-switch mov=2
BrightScan BrighScan OpticPro Parport (SPP, EPP)   Complete Reported as P12

Backend: ricoh (unmaintained)

Manual page: sane-ricoh

Manufacturer Model Interface USB id Status Comment
Ricoh Ricoh IS50 SCSI   Basic  
Ricoh IS60 SCSI   Basic  

Backend: rts8891 (1.0-0)

Link(s): http://stef.dev.free.fr/sane/rts8891/index.html
Manual page: sane-rts8891
Comment: This backend supports Realtek RTS8891 ASIC bases scanners.

Manufacturer Model Interface USB id Status Comment
UMAX Astra 4400 USB 0x1606/0x0070 Good Supports 75, 150, 300, 600 and 1200 dpi
Astra 4450 USB 0x1606/0x0070 Untested  
Hewlett-Packard scanjet 4470c USB 0x03f0/0x0805 Good re-branded Astra 4400
scanjet 4400c USB 0x03f0/0x0705 Good exists with 2 different sensors of which only one works

Backend: s9036 (unmaintained)

Manual page: sane-s9036

Manufacturer Model Interface USB id Status Comment
Siemens 9036 Flatbed scanner SCSI   Basic  

Backend: sceptre (1.0-10)

Link(s): http://www.zago.net/sane/
Manual page: sane-sceptre

Manufacturer Model Interface USB id Status Comment
Sceptre Vividscan S1200 SCSI   Basic  
Komodo S1200 SCSI   Untested rebadged Sceptre S1200

Backend: sharp (0.32)

Link(s): http://www.satzbau-gmbh.de/staff/abel/sane-sharp.html
Manual page: sane-sharp

Manufacturer Model Interface USB id Status Comment
Sharp JX-610 SCSI   Good  
JX-250 SCSI   Good  
JX-320 SCSI   Good  
JX-325 SCSI   Untested  
JX-330 SCSI   Good  
JX-350 SCSI   Good  

Backend: sm3600 (0.1)

Link(s): http://sm3600.sourceforge.net/
Manual page: sane-sm3600

Manufacturer Model Interface USB id Status Comment
Microtek ScanMaker 3600 USB 0x05da/0x40b3 Basic works
ScanMaker 3600 USB 0x05da/0x40ca Basic works
ScanMaker 3600 USB 0x05da/0x40ff Basic works
ScanMaker 3700 USB 0x05da/0x40b8 Basic works
ScanMaker 3700 USB 0x05da/0x40cb Basic works
ScanMaker 3750 USB 0x05da/0x40dd Basic works (told)

Backend: sm3840 (1.1)

Link(s): http://www.ziplabel.com/sm3840/
Manual page: sane-sm3840
Comment: This reverse-engineered backend supports the USB ScanMaker 3840 model

Manufacturer Model Interface USB id Status Comment
Microtek ScanMaker 3840 USB 0x05da/0x30d4 Good 8 and 16 bit, color and grayscale
ScanMaker 4800 USB 0x05da/0x30cf Good Same hardware as SM3840, different color box

Backend: SnapScan (1.4)

Link(s): http://snapscan.sourceforge.net/
Manual page: sane-snapscan
Comment: Supported bit depths: 24 bit (color), 48 bit (color, Epson) 8 bit (gray)

Manufacturer Model Interface USB id Status Comment
AGFA SnapScan SCSI   Good  
SnapScan 300 SCSI   Good  
SnapScan 310 SCSI   Good  
SnapScan 600 SCSI   Good Optional ADF supported.
Arcus 1200 SCSI   Good Optional transparency unit supported.
SnapScan 1236s SCSI   Good Optional ADF and transparency unit supported.
SnapScan 1236u USB 0x06bd/0x0002 Good Optional ADF and transparency unit supported.
SnapScan 1212U USB 0x06bd/0x0001 Good  
SnapScan 1212U_2 USB 0x06bd/0x2061 Good  
SnapScan e10 USB 0x06bd/0x2093 Good  
SnapScan e20 USB 0x06bd/0x2091 Good  
SnapScan e25 USB 0x06bd/0x2095 Good  
SnapScan e26 USB 0x06bd/0x2097 Good  
SnapScan e40 USB 0x06bd/0x208d Good  
SnapScan e42 USB 0x06bd/0x20ff Good  
SnapScan e50 USB 0x06bd/0x208f Good Optional tranparency unit supported
SnapScan e52 USB 0x06bd/0x20fd Good Optional tranparency unit supported
SnapScan e60 USB   Untested  
Benq (Acer) 300f SCSI   Good  
310s SCSI   Good  
610s SCSI   Good  
610plus SCSI   Good  
620s SCSI   Good  
ScanWit 2720s SCSI   Good  
310U USB 0x04a5/0x1a20 Good  
320U USB 0x04a5/0x2022 Good  
340U USB 0x04a5/0x2022 Good  
620U USB 0x04a5/0x1a2a Good Optional tranparency unit supported
620UT USB 0x04a5/0x2040 Good Optional tranparency unit supported
640U USB 0x04a5/0x2060 Good Optional tranparency unit supported
640bu USB 0x04a5/0x207e Good  
640BT USB 0x04a5/0x20be Good Optional tranparency unit supported
1240 USB 0x04a5/0x20c0 Good Optional tranparency unit supported
3300 USB 0x04a5/0x20b0 Good  
3300 USB 0x04a5/0x20de Good  
4300 USB 0x04a5/0x20b0 Good  
4300 USB 0x04a5/0x20de Good  
5000E USB 0x04a5/0x20fc Basic Same as 5000U, working up to 600 DPI
5000U USB 0x04a5/0x20fc Basic Same as 5000E, working up to 600 DPI
5000 USB 0x04a5/0x20f8 Good USB ID 0x04a5,0x20f8: Color / grayscale scans working up to 1200 DPI
5150 USB 0x04a5/0x2137 Basic Calibration algorithm unknown
5250 USB 0x04a5/0x2137 Basic Same hardware as 5150 (?), Calibration algorithm unknown
5300 USB 0x04a5/0x20fe Basic Problems with firmware upload reported
Guillemot / Hercules Maxi Scan A4 Deluxe (SCSI) SCSI   Good Rebadged SnapScan 310s.
Scan@home Touch 1248 (USB) USB 0x04a5/0x20de Good Rebadged Benq 3300.
Maxi Scan A4 USB 640U USB 0x04a5/0x2060 Good Rebadged Benq 640U.
Maxi A4 36 bit USB 0x04a5/0x2060 Good Rebadged Benq 620U, needs Benq firmware file u96v???.bin
Mitsubishi Diamondview 648UT USB 0x04a5/0x2022 Good Rebadged Benq 320u.
Diamondview 650U USB 0x04a5/0x20b0 Good Rebadged Benq 4300.
Epson Perfection 660 USB 0x04b8/0x0114 Good  
Perfection 1270 USB 0x04b8/0x0120 Good  
Perfection 1670 USB 0x04b8/0x011f Good  
Perfection 2480 USB 0x04b8/0x0121 Good  
Perfection 2580 USB 0x04b8/0x0121 Basic Film scanning unit unsupported
Perfection 3490 USB 0x04b8/0x0122 Good  
Perfection 3590 USB 0x04b8/0x0122 Basic Film scanning unit unsupported
Stylus CX-1500 USB 0x04b8/0x080c Good  

Backend: sp15c (unmaintained)

Manual page: sane-sp15c

Manufacturer Model Interface USB id Status Comment
Fujitsu ScanPartner 15C SCSI   Good  
ScanPartner 600C SCSI   Good  

Backend: st400 (1.6)

Link(s): http://www.informatik.uni-oldenburg.de/~ingo/sane/
Manual page: sane-st400

Manufacturer Model Interface USB id Status Comment
Siemens ST400 SCSI   Basic 6 bit gray
ST800 SCSI   Basic 6 bit gray

Backend: tamarack (unmaintained)

Manual page: sane-tamarack

Manufacturer Model Interface USB id Status Comment
Tamarack Artiscan 6000C SCSI   Good 3 pass, 300 DPI
Artiscan 8000C SCSI   Good 3 pass, 400 DPI
Artiscan 12000C SCSI   Good 3 pass, 600 DPI

Backend: teco1 (1.0-10)

Link(s): http://www.zago.net/sane/#teco
Manual page: sane-teco1

Manufacturer Model Interface USB id Status Comment
Relisys RELI 2412 SCSI   Complete sub model VM3530+
AVEC 2400 SCSI   Complete sub model VM3520
RELI 4830 SCSI   Good sub model VM4542
AVEC 2412 SCSI   Complete sub model VM3520+
AVEC 4800 SCSI   Untested sub model VM4530
AVEC 4816 SCSI   Untested sub model VM4530+
RELI DS6 SCSI   Untested sub model VM3420
RELI DS15 SCSI   Untested sub model VM3440
RELI 2400 SCSI   Untested sub model VM3530
RELI 4816 SCSI   Complete sub model VM4540
RELI 9600 SCSI   Untested sub model VM6530
RELI 9612 SCSI   Untested sub model VM6530*
RELI 9624 SCSI   Untested sub model VM6530+
RELI 9630 SCSI   Untested sub model VM6540
Actown ACT Scan I 30 SCSI   Untested sub model VM3520A
Dextra DF-600P SCSI   Good sub model VM3510
DF-1200T+ SCSI   Untested sub model VM3530+
DF-4830T SCSI   Untested sub model VM4542
DF-9624 SCSI   Untested sub model VM6530+

Backend: teco2 (1.0-9)

Link(s): http://gkall.hobby.nl/teco2.html
Manual page: sane-teco2

Manufacturer Model Interface USB id Status Comment
Relisys AVEC Super 3 SCSI   Untested sub model VM3575
AVEC II S3 SCSI   Good sub model VM3564
SCORPIO Super 3 SCSI   Good sub model VM3575
APOLLO Express 3 SCSI   Basic sub model VM356A
APOLLO Express 6 SCSI   Good sub model VM6565
SCORPIO Pro SCSI   Good sub model VM6575
SCORPIO Pro-S SCSI   Untested sub model VM6586
Primax Jewel 4800 SCSI   Good sub model VM356A
Profi 9600 SCSI   Basic sub model VM6575
Profi 19200 SCSI   Good sub model VM6586
Mustek ScanMagic 4830S SCSI   Untested sub model VM3575

Backend: teco3 (1.0-1)

Link(s): http://www.zago.net/sane/#teco3
Manual page: sane-teco3

Manufacturer Model Interface USB id Status Comment
Relisys Infinity Scorpio SCSI   Good sub model VM3552
Plustek OpticPro 2400SP SCSI   Untested sub model VM3552
PIOTECH Splendeur 3024 SCSI   Good sub model VM3552
Trust Imagery 2400 SP SCSI   Good sub model VM3552
Imagery 4800 SP+ SCSI   Good sub model VM3552
Imagery 9600 SP SCSI   Untested sub model VM3552

Backend: u12 (0.02)

Link(s): http://www.gjaeger.de/scanner/u12/
Manual page: sane-u12

Manufacturer Model Interface USB id Status Comment
Plustek OpticPro U12 USB 0x07b3/0x0001 Basic Note: Only devices with product ID 0x0001 are supported!
OpticPro UT12 USB 0x07b3/0x0001 Basic Note: Only devices with product ID 0x0001 are supported!
OpticPro 1212U USB 0x07b3/0x0001 Basic  
RevScan RevScan Orange R48Ti USB 0x07b3/0x0001 Basic Rebadged Plustek OpticPro UT12
Genius ColorPage HR6 V1 USB 0x0458/0x2004 Basic  
ColorPage Vivid III USB USB 0x07b3/0x0001 Untested Note: Device has Plustek vendor and product ID (0x07b3/0x0001)

Backend: umax (1.0-41)

Link(s): http://www.rauch-domain.de/sane-umax/index.html
Manual page: sane-umax

Manufacturer Model Interface USB id Status Comment
UMAX Vista S6 SCSI   Good OK
Vista S6E SCSI   Good OK
UMAX S-6E SCSI   Good OK
UMAX S-6EG SCSI   Good OK
Vista-S8 SCSI   Good OK
Supervista S-12 SCSI   Good OK
UMAX S-12 SCSI   Good OK
UMAX S-12G SCSI   Good OK
Astra 600S SCSI   Good OK
Astra 610S SCSI   Good OK
Astra 1200S SCSI   Good OK
Astra 1220S SCSI   Good OK
Astra 2100S SCSI   Good OK
Astra 2200 (SU) SCSI   Good OK
Astra 2200 (SU) USB 0x1606/0x0230 Good OK, needs USB control messages
Astra 2400S SCSI   Good OK
Astra 6400 IEEE-1394   Unsupported will probably work one day
Astra 6450 IEEE-1394   Unsupported will probably work one day
Astra MX3 SCSI   Good OK
Astra MX3 USB   Good OK, needs USB control messages
Mirage D-16L SCSI   Good OK
Mirage II SCSI   Good OK
Mirage IIse SCSI   Good OK
PSD SCSI   Good OK
PowerLook SCSI   Good OK, SCSI-ID=PS-2400X
PL-II SCSI   Good OK
PowerLook III SCSI   Good OK
PowerLook 270 SCSI   Unsupported incompatible
PowerLook 270plus SCSI   Unsupported incompatible
PowerLook 1100 IEEE-1394   Unsupported will probably work one day
PowerLook 2000 SCSI   Good OK
PowerLook 2100XL SCSI   Good OK
PowerLook 3000 SCSI   Good OK
Gemini D-16 SCSI   Good OK
UMAX VT600 SCSI   Untested may work, please test and give feedback
Vista-T630 SCSI   Good OK for some firmwareversions, on others only lineart OK
UC 630 SCSI   Good Version 2.8 OK, others only lineart OK
UG 630 SCSI   Good OK
UG 80 SCSI   Good OK
UC 840 SCSI   Good Version 1.6 OK, others only lineart OK
UC 1200S SCSI   Untested may work, please test and give feedback
UC 1200SE SCSI   Good Version 3.0 OK, others unknown
UC 1260 SCSI   Good Version 1.6 OK, others unknown
Linotype Hell Jade SCSI   Good OK, SCSI-ID=LinoHell Office
Jade SCSI   Good OK, SCSI-ID=LinoHell JADE
Jade2 SCSI   Good OK, SCSI-ID=LinoHell Office2
Saphir SCSI   Untested support disabled until tested - please contact author
Saphir2 SCSI   Good OK, SCSI-ID=LinoHell SAPHIR2
Saphir3 SCSI   Good OK, SCSI-ID=LinoHell SAPHIR3
Saphir Ultra SCSI   Untested support disabled until tested - please contact author
Saphir Ultra II SCSI   Good OK, SCSI-ID=Linotype SAPHIR4
Saphir HiRes SCSI   Untested support disabled until tested - please contact author
Opal SCSI   Untested support disabled until tested - please contact author
Opal2 SCSI   Good OK; SCSI-ID=LinoHell OPAL2
Opal Ultra SCSI   Untested support disabled until tested - please contact author
Linoscan 1400 SCSI   Good OK, SCSI-ID=HDM LS4H1S
Vobis Highscreen Scanboostar Premium SCSI   Good OK, SCSI-ID=LinoHell Office2
EDGE KTX-9600US SCSI   Untested no feedback
Epson Perfection 600 SCSI   Good OK, SCSI-ID=EPSON Perfection600
Escom Image Scanner 256 SCSI   Good OK, SCSI-ID=UMAX UG 80
Escort Galleria 600 SCSI   Untested untested, SCSI-ID=ESCORT Galleria 600S
Genius ColorPage-HR5 (Pro) SCSI   Good OK, SCSI-ID=KYE ColorPage-HR5
Nikon AX-110 / Scantouch 110 SCSI   Untested may work, please test and give feedback
AX-210 SCSI   Good OK
TriGem PowerScanII SCSI   Good OK

Backend: umax1220u (unmaintained)

Link(s): http://sourceforge.net/projects/umax1220u-sane
Manual page: sane-umax1220u

Manufacturer Model Interface USB id Status Comment
UMAX Astra 1220U USB 0x1606/0x0010 Good  
Astra 1600U USB 0x1606/0x0030 Good  
Astra 2000U USB 0x1606/0x0030 Good  
Astra 2100U USB 0x1606/0x0130 Good  

Backend: umax_pp (1)

Link(s): http://umax1220p.sourceforge.net/
Manual page: sane-umax_pp

Manufacturer Model Interface USB id Status Comment
UMAX Astra 1220P Parport (EPP/ECP)   Good  
Astra 2000P Parport (EPP/ECP)   Good  
Astra 1600P Parport (EPP/ECP)   Good  
Astra 600P Parport (SPP/ECP)   Unsupported untested, but should be close to 610P
Astra 610P Parport (SPP/ECP)   Good  
Hewlett-Packard Scanjet 3200C Parport (EPP/ECP)   Good works (relabelled 1220P and 2000P)
Genius ColorPage-Life Pro Parport (EPP/ECP)   Good works (relabelled 1220P and 2000P)

Backend: unsupported (2010-06-09)

Link(s): contrib.html
Comment: The devices mentioned here are not supported by any SANE backend. However, there may be links to information about them or stand-alone programs.

Manufacturer Model Interface USB id Status Comment
Agfa DuoScan f40 USB IEEE-1394 0x06bd/0x02bf Unsupported Unsupported. See link for details.
DuoScan T2000XL SCSI   Unsupported Unsupported. Same as Microtek ArtixScan 2020?
DuoScan T2500 SCSI IEEE-1384   Unsupported Unsupported. Same as Microtek Artixscan 2500f
SnapScan 310P Parport   Unsupported Unsupported, see link for details.
SnapScan EZ Parport   Unsupported Unsupported, see link for details.
SnapScan 1200P Parport   Unsupported Unsupported, see link for details.
SnapScan 1212P Parport   Unsupported Unsupported, see link for details.
Artec/Ultima 1236 USB USB 0x05d8/0x4001 Unsupported Unsupported. See link for details.
AM12e+ Parport   Unsupported Unsupported. Chips found inside: AT015, AD9816JS. Maybe similar to SCSI version or as6e?
Ultima 2000 (0x4001) USB 0x05d8/0x4001 Unsupported Same name, but different ids: This scanner is not supported. The scanner with product id 0x4002 is supported by the gt68xx backend, however.
Avigramm Minidoc USB Parport 0x05cb/0x1483 Unsupported Not supported. See link for details.
Avision DS310F Parport   Unsupported Probably not supported. Scanner/printer/copier combination.
iVina FB2400 USB   Unsupported Not supported. No chipset information available. Same as UMAX Astra 6700.
iVina 1600 USB 0x0638/0x0a10 Unsupported GL646 based, to be added to genesys backend. Same as UMAX Astra 4500.
iVina FB1800 USB 0x0638/0x0a20 Unsupported GL646/GL660 based. Same as UMAX Astra 4700.
Benq (Acer) 310P Parport   Unsupported Unsupported, see link for details.
320P Parport   Unsupported Unsupported, see link for details.
340P Parport   Unsupported Unsupported, see link for details.
610P Parport   Unsupported Unsupported, see link for details.
610PT Parport   Unsupported Unsupported, see link for details.
620P Parport   Unsupported Unsupported, see link for details.
620PT Parport   Unsupported Unsupported, see link for details.
640P Parport   Unsupported Unsupported, see link for details.
5450 USB 0x04a5/0x211e Unsupported Unsupported.
5550 USB 0x04a5/0x2211 Unsupported Unsupported, see link for details.
5560 USB 0x04a5/0x2311 Unsupported  
7400UT USB 0x04a5/0x2202 Unsupported  
Boeder Sm@rtScan Office Parport USB 0x05cb/0x1483 Unsupported Unsupported. See link for details.
Brother MFC 2500 USB 0x04f9/0x000a Unsupported Not supported. See link for details.
MFC 4600 Parport   Unsupported The parport 200x400dpi grayscale version of this scanner is unsupported. Dmitri Katchalov did some investigations on this scanner. If you want to write a backend, contact him (see link).
MFC 7300c Parport USB 0x04f9/0x0106 Unsupported  
MFC 9600 USB 0x04f9/0x0101 Unsupported  
C-Channel MyPen Pro USB   Unsupported Probably unsupported. See link for details.
MyPen Light USB 0x0a93/0x0005 Unsupported See bug #306792 for details.
MoneyPen II USB   Unsupported Probably unsupported.
Canon CanoScan 3000 USB 0x04a9/0x2215 Unsupported GL660+GL646 based.
CanoScan 3000ex USB 0x04a9/0x2215 Unsupported GL660+GL646 based.
CanoScan 3000F USB 0x04a9/0x2215 Unsupported GL660+GL646 based, to be added to genesys backend
CanoScan 4200F USB 0x04a9/0x221b Unsupported Probably unsupported. See link.
CanoScan 4400F USB 0x04a9/0x2228 Unsupported GL843 based, to be added to genesys backend
CanoScan 5000F USB 0x04a9/0x2212 Unsupported Unsupported. See link for details.
CanoScan 5200F USB 0x04a9/0x2217 Unsupported Probably unsupported. See link for details.
CanoScan 8000F USB 0x04a9/0x220f Unsupported Not supported. See link for more information. With transparency adapter.
CanoScan 8400F USB 0x04a9/0x221e Unsupported GL841 based, to be added to genesys backend
CanoScan 8600F USB 0x04a9/0x2229 Unsupported GL841 based, to be added to genesys backend
CanoScan 9900F USB 0x04a9/0x2210 Unsupported Probably unsupported, similar to 8000F. 3200x6400 dpi USB2. With transparency adapter.
CanoScan 9950F USB 0x04a9/0x2219 Unsupported Probably unsupported.
CanoScan D646U USB 0x04a9/0x220b Unsupported Probably not supported. See link for more information and test program.
CanoScan D646U ex USB 0x04a9/0x220b Unsupported Probably not supported. See D646.
CanoScan D1230U USB 0x04a9/0x2209 Unsupported Probably not supported.
CanoScan D1250U2 USB 0x04a9/0x220c Unsupported Not supported. However, someone started working on this scanner and some information is available (see link).
CanoScan D2400UF USB 0x04a9/0x220a Unsupported Not supported. See link.
CanoScan FB320U USB 0x04a9/0x2201 Unsupported Probably not supported. No details known.
CanoScan FB620U USB 0x04a9/0x2202 Unsupported Probably not supported. Some information is available.
CanoScan FB1210U USB 0x04a9/0x2205 Unsupported Not supported. However, a stand-alone program for FreeBSD is available.
CanoScan LiDE 70 USB 0x04a9/0x2225 Unsupported Philips chip. Backend started, see link
CanoScan LiDE 80 USB 0x04a9/0x2214 Unsupported GL841 based, to be added to genesys backend
CanoScan LiDE 90 USB 0x04a9/0x1900 Unsupported Unsupported. See link for details.
CanoScan LiDE 500F USB 0x04a9/0x221f Unsupported GL841 based, to be added to genesys backend
CanoScan LiDE 600 USB 0x04a9/0x2224 Unsupported Philips chip. Backend started, see link
CanoScan LiDE 600F USB 0x04a9/0x2224 Unsupported Philips chip. Backend started, see link
FS4000 USB SCSI 0x04a9/0x3042 Unsupported Not supported. See link for more details.
IS 12 USB   Unsupported Probably not supported. Scanner cardridge for Canon inkjet printers.
IS 22 Parport   Unsupported Probably not supported. Scanner cardridge for Canon inkjet printers.
IS 32 USB 0x04a9/0x105d Unsupported Probably not supported. Scanner cardridge for Canon inkjet printers.
IS 52 USB   Unsupported Probably not supported. Scanner cardridge for Canon inkjet printers.
ImageRunner iR1018 USB 0x04a9/0x269d Unsupported Probably not supported. See link for details.
ImageRunner iR1022 USB 0x04a9/0x269d Unsupported Probably not supported. See link for details.
ImageRunner iR1023 USB 0x04a9/0x269d Unsupported Probably not supported. See link for details.
PIXMA MP110 USB 0x04a9/0x1700 Unsupported Probably not supported. See link for details.
PIXMA MP130 USB 0x04a9/0x1701 Unsupported Probably not supported. See link for details.
DR-2020U USB   Unsupported GL84x?
Chinon DS-3000 Parport Serial Port   Unsupported Unsupported at the moment, but a backend is in preparation. See link.
Compaq S200 USB 0x049f/0x0021 Unsupported Not supported. 2400x1200 dpi. One bulk-in, one bulk-out and one interrupt endpoint. Type-number: U0001-HB21, another type nr on the inside: 75100512-00
Compeye Simplex 1236C Parport USB 0x05cb/0x1483 Unsupported Unsupported. See link for details.
Corex Cardscan 500 USB 0x08f0/0x0001 Unsupported Probably not supported. Businesscard reader.
Cardscan 700 C USB 0x08f0/0x0004 Unsupported Probably not supported.
Dell A940 USB 0x413c/0x5106 Unsupported Probably rebadged Lexmark X5150. May work with sane-lexmark? See bug #312130
A960 USB 0x413c/0x5107 Unsupported Probably not supported. See link for details.
922 USB 0x413c/0x5109 Unsupported Probably not supported. See link for details.
Epson GT-2200 USB 0x04b8/0x0102 Unsupported Probably unsupported. No details known.
StylusScan 2000 USB 0x04b8/0x0105 Unsupported Probably unsupported. No details known.
Stylus DX4450 USB 0x04b8/0x083f Unsupported Probably unsupported. See link for details.
Stylus CX-5800 USB   Unsupported Probably unsupported at the moment. Not compatible to snapscan backend. It's not known if it may work with epson or epkowa backend.
EDT (Electronic Document Technology) BizCardReader 900C USB 0x0a53/0x5001 Unsupported Probably unsupported. See link for details.
E-Lux j-6121 Parport   Unsupported Probably unsupported. Sold 1998. Same as E-Lux j-6121.
Enhans j-6121 Parport   Unsupported Probably unsupported. Sold 1998. Same as E-Lux j-6121.
M-3630 A Parport   Unsupported Probably unsupported.
Genius ColorPage CS SCSI   Unsupported Probably unsupported, see link for details.
ColorPage-Slim 1200 USB2 USB 0x0458/0x2020 Unsupported GL841 based, to be added to genesys backend.
ColorPage HR6X Slim USB 0x0458/0x2019 Unsupported GL646 based, to be added to genesys backend
ColorPage HR7X USB 0x0458/0x2018 Unsupported GL646 based, to be added to genesys backend
ColorPage HR7XE USB 0x06dc/0x0012 Unsupported Unsuported. See link for details.
ColorPage HR8 USB 0x0458/0x201c Unsupported GL841 based, to be added to genesys backend
Guillemot SCAN@HOME 48 USB USB 0x080d/0x0102 Unsupported Probably unsupported. See link for details.
Maxi Scan A4 Parallel 36 bit Parport   Unsupported Probably unsupported. Identical to the Benq Prisa 620P.
Hercules SCAN@HOME 48 USB USB 0x080d/0x0102 Unsupported Probably unsupported. See link for details.
Hewlett-Packard Photo Scanner 1000 USB 0x03f0/0x1001 Unsupported Not supported by SANE. However, it's detected as mass storage device so just mounting it is reported to work. See link for device data.
Photosmart 1200 Photo USB   Unsupported Probably not supported by SANE. No details known. 10x15 cm. Maybe similar to Photo Scanner 1000?
Photosmart S20 (C5101A) USB 0x03f0/0x0102 Unsupported Not supported yet by SANE. See link for details.
Photosmart S20xi (C7150A) USB 0x03f0/0x0102 Unsupported Not supported yet by SANE. See link for details.
Photosmart C5100 series USB 0x03f0/0x5811 Unsupported Not supported yet by SANE. See link for details.
ScanJet 2400c USB 0x03f0/0x0a01 Unsupported GL646 based, to be added to genesys backend
Photosmart C3180 USB 0x03f0/0x5611 Unsupported Not supported yet by SANE. See link for details.
ScanJet 3770 USB 0x03f0/0x2505 Unsupported While an external binary-only backend exists, it works only on Linux i386. Therefore the scanner is unsupported on other platforms.
ScanJet 4600 USB 0x03f0/0x3005 Unsupported Not supported. See link for details, or http://www.chmil.org/hp4600linux/ for code
ScanJet 4670 USB 0x03f0/0x3005 Unsupported Not supported. See ScanJet 4600 entry.
ScanJet 4850C USB 0x03f0/0x1b05 Unsupported GL841, maybe can be added to genesys backend
ScanJet 4890C USB 0x03f0/0x1b05 Unsupported GL843, maybe can be added to genesys backend
ScanJet 5530C Photosmart USB 0x03f0/0x1605 Unsupported Maybe GL841_HP, but not confirmed, maybe can be added to genesys backend
ScanJet 8390 USB 0x03f0/0x3805 Unsupported Probably not supported. See link for details.
ScanJet G4000 USB 0x03f0/0x4505 Unsupported Probably not supported. See link for details.
IBM ADF Color Scanner Proprietary   Unsupported Unsupported. Uses proprietary ISA card. Maybe the same as the Plustek Spectra ADF?
IOMagic MobileScan USB USB Parport 0x05cb/0x1483 Unsupported Unsupported. See link for details.
Iris IriScan USB 0x0a53/0x1000 Unsupported Unsupported. LM9832/3. See link for details.
IRISPen Translator Executive USB 0x0f43/0x015a Unsupported Unsupported. See link for details.
IRISCard Pro (IBCR II) USB 0x0a38/0x0301 Unsupported Unsupported. See link for details.
Kodak Snapshot Photo Scanner 1 Parport   Unsupported Unsupported. FCC ID HWF96PHS
Lexmark P6250 USB 0x043d/0x0097 Unsupported Unsupported. See link for details.
Photo 3150 USB 0x043d/0x007d Unsupported Unsupported. See link for details.
X74 USB 0x043d/0x0060 Unsupported Unsupported. See link for details.
X75 USB 0x043d/0x0060 Unsupported Unsupported. See link for details.
X75 PrinTrio USB 0x043d/0x0060 Unsupported Unsupported. See link for details.
X83 USB 0x043d/0x003d Unsupported Unsupported. GL640.
X2330 USB 0x043d/0x00bb Unsupported Unsupported. See link for details.
X3450 USB 0x043d/0x00f6 Unsupported Unsupported. See link for details.
X5130 USB 0x043d/0x0065 Unsupported Unsupported.
X5150 USB 0x043d/0x0065 Unsupported Probably unsupported. See link for details.
X5250 USB 0x043d/0x0093 Unsupported Unsupported.
X6170 USB 0x043d/0x0072 Unsupported Unsupported. See link for details.
X7170 USB 0x043d/0x0098 Unsupported Unsupported. See bug #310889 for details.
X7350 USB 0x043d/0x00b8 Unsupported Unsupported. See link for details.
X8350 USB 0x043d/0x00b9 Unsupported Unsupported. See link for details.
Logitech PageScan Color Parport   Unsupported Most probably unsupported.
PageScan USB USB 0x046d/0x040f Unsupported Probably unsupported. See link for details.
Medion/Lifetec/Tevion/Cytron MD 6190 USB 0x0461/0x0392 Unsupported Probably unsupported. There seem to exist two different scanners with that name. See link for details.
MD 6190 USB 0x0461/0x037b Unsupported Probably unsupported. There seem to exist two different scanners with that name. See link for details.
MD 40420 USB 0x05da/0x3008 Unsupported Probably unsupported. See link for details.
MD 41260 USB 0x0461/0x037b Unsupported Probably unsupported. See link for details.
MD 41985 USB 0x0461/0x037b Unsupported Probably unsupported. See link for details.
MD 42666 USB 0x05da/0x3008 Unsupported Probably unsupported. See link for details.
MD 85264 USB 0x08ff/0x2580 Unsupported Fingerprint sensor. See link for details.
MD 90009 USB 0x05da/0x30e5 Unsupported Probably unsupported. See link for details.
MD 90070 USB 0x05da/0x3022 Unsupported Unsupported. See link for details.
MD 90090 USB 0x05da/0x3022 Unsupported Unsupported. See link for details.
Memorex 6136u USB 0x0461/0x0346 Unsupported Probably unsupported.
6142u USB 0x0461/0x0347 Unsupported Probably unsupported. Same as Visioneer Onetouch 4400. See link for details.
MaxxScan 6122 USB Parport 0x05cb/0x1483 Unsupported Unsupported. See link for details.
SCF 9612P Parport   Unsupported Probably unsupported. See link for details.
Microtek ArtixScan 2020 SCSI   Unsupported Unsupported. Same as Agfa DuoScan T2000XL?
ArtixScanDI 2020 USB 0x05da/0x202e Unsupported Unsupported. See link for details.
Artixscan 2500f SCSI IEEE-1384   Unsupported Unsupported. Same as Agfa DuoScan T2500?
ArtixScan 4000tf USB   Unsupported Unsupported. Uses ALI M5611B.
FilmScan 35 USB 0x05e3/0x0120 Unsupported Probably unsupported. See link for details.
ScanMaker 336 CX SCSI   Unsupported Probably unsupported. Seems to be similar to the Microtek 330 CX and is detected by the microtek2 backend. Scanning doesn't seem to work however.
Scanmaker 1850S SCSI   Unsupported Unsupported. See link for details.
ScanMaker 3630 USB 0x0461/0x0347 Unsupported Unsupported. Doesn't seem to be compatible to 3600 series, see link.
ScanMaker 3800 USB 0x05da/0x30ce Unsupported Unsupported. See link for more details.
ScanMaker 3830 USB 0x05da/0x30ce Unsupported Unsupported. See link for more details.
ScanMaker 3860 USB 0x05da/0x3023 Unsupported Unsupported. See link for more details. Appears to be similar to ScanMaker 3880.
ScanMaker 3880 USB 0x05da/0x3021 Unsupported Unsupported. SQ113 chip. See link for more details.
ScanMaker 4600 USB 0x05da/0x40c7 Unsupported Unsupported. See link for more details.
ScanMaker 4700 USB 0x05da/0x20b4 Unsupported Unsupported. See link for more details.
ScanMaker 4850 USB 0x05da/0x30d9 Unsupported Probably unsupported. See link for details.
ScanMaker 4850 II USB 0x05da/0x3008 Unsupported Probably unsupported. See link for details.
ScanMaker 4900 USB 0x05da/0x30b9 Unsupported Unsupported. See link for more details.
ScanMaker 5 SCSI   Unsupported Probably unsupported. See link for more details.
ScanMaker 5600 USB 0x05da/0x20a7 Unsupported Unsupported. See link for more details.
ScanMaker 5700 USB 0x05da/0x20bd Unsupported Unsupported. Uses ALI M5615 like the ScanMaker 4700.
ScanMaker 5800 USB 0x05da/0x3008 Unsupported Unsupported. See link for details.
ScanMaker 5800 USB 0x05da/0x30d8 Unsupported Unsupported. See link for details.
ScanMaker 5900 USB 0x05da/0x30d8 Unsupported Unsupported. See link for more details.
ScanMaker 5950 USB 0x05da/0x30d8 Unsupported Unsupported. See link for more details.
ScanMaker 6000 USB 0x05da/0x30e5 Unsupported Unsupported. See link for more details.
ScanMaker 6100 USB 0x05da/0x30e5 Unsupported Unsupported. See link for more details.
ScanMaker 6700 USB IEEE-1394 0x05da/0x20c9 Unsupported Unsupported. See link.
ScanMaker 8700 USB IEEE-1394 0x05da/0x20b1 Unsupported Unsupported. See link for details. USB vendor and product ids to be checked.
ScanMaker 9600XL USB IEEE-1394 0x05da/0x20de Unsupported Probably unsupported. SCSI seems to work with microtek2 backend.
ScanMaker 9800XL USB SCSI 0x05da/0x20de Unsupported Partly unsupported. IEEE-1394 works with microtek2 backend. See link.
ScanMaker i320 USB 0x05da/0x30e6 Unsupported Unsupported. See link.
ScanMaker s400 USB 0x05da/0x201c Unsupported Unsupported. See link.
ScanMaker S400 USB 0x05da/0x300b Unsupported Unsupported. See link.
ScanPort 3000 USB 0x04a7/0x0224 Unsupported Unsupported. Vendor/Product ids: 0x04a7/0x0224. Realtek RTS8801B?. See link for details.
Konica Minolta Dual Scan III USB 0x0686/0x400d Unsupported Unsupported. May work with vuescan. See link for details.
Dual Scan IV USB 0x132b/0x000a Unsupported Unsupported. Works with vuescan. See link for details.
DiMAGE Scan Elite 5400 USB IEEE-1394 0x0686/0x400e Unsupported Probably unsupported. May work with vuescan. See link for details.
DiMAGE Scan Elite 5400 2 USB 0x132b/0x0012 Unsupported Probably unsupported. See link for details.
DiMAGE Scan Multi Pro IEEE-1394   Unsupported Probably unsupported. See link for details.
magicolor 2480MF USB Network   Unsupported Uses a different scanning protocol than the magicolor 1690MF
Mustek 1200 III EP Parport   Unsupported Probably not supported. quarlewm at jmu dot edu offers to temporarily loan such a scanner to anyone who is interested in writing a driver.
2400 M USB   Unsupported Probably unsupported. No details known.
BearPaw 2400 TA Pro USB 0x055f/0x0400 Unsupported Not supported. May be supported by mustek_usb2 backend later. See link for some information.
BearPaw 2448 CU Pro USB 0x055f/0x0408 Unsupported Not supported. May be supported by mustek_usb2 backend later. See link for some information.
BearPaw 4800 TA Pro USB 0x055f/0x1000 Unsupported Not supported. See link for some information.
BearPaw 4800 TA Pro II USB 0x055f/0x040a Unsupported Not supported. May be supported by mustek_usb2 backend later. See link for some information.
BearPaw 6400 TA Pro USB 0x055f/0x040b Unsupported Not supported. May be supported by mustek_usb2 backend later. See link for some information.
Paragon 800 II EP Parport   Unsupported Not supported. Maybe similar to 600 II EP (SCSI_over-parport)? In this case it could be supported by the mustek SCSI backend.
ScanExpress 600 USB USB 0x055f/0x0873 Unsupported Unsupported. Programming information is available.
ScanExpress 1200 USB USB 0x055f/0x0003 Unsupported Unsupported. Programming information is available.
ScanExpress 1200 USB Plus USB 0x055f/0x0007 Unsupported Unsupported.
ScanExpress 12000 P Parport   Unsupported Not supported. Asic 1505/05.
ScanExpress A3 EP Parport   Unsupported Not supported. Maybe it will be supported by the mustek_pp backend in future.
ScanExpress CardSmart USB   Unsupported Probably unsupported. USB business card scanner. Maybe works as USB storage device?
ScanMagic 9636P Parport   Unsupported Probably not supported. Same as Mustek 12000 P?. ASIC 1505.
NEC Petiscan USB 0x0475/0x0100 Unsupported Most probably unsupported. See link for details. Vendor ID is Relisys/Teco. Not known if it is similar to other Relisys/Teco USB scanners.
Nikon LS-9000 ED IEEE-1394   Unsupported Probably not supported. See link for details. Possibly similar to LS-8000 ED.
Olivetti Job-Jet M400 USB 0x0b3c/0xa880 Unsupported Probably not supported. See link for details.
Olympus ES-10P Parport   Unsupported  
ES-10S SCSI   Unsupported Probably not supported. See link for details.
Optoelectronics Barcode scanner USB 0x065a/0x0001 Unsupported Probably not supported.
Optrox PhotoMaker 3C Parport   Unsupported  
PhotoMaker 3E Parport   Unsupported  
PhotoMaker 3F Proprietary   Unsupported Special ISA card
PhotoMaker 3S Parport   Unsupported  
PhotoMaker 6E Parport   Unsupported  
PhotoMaker 6F Proprietary   Unsupported Special ISA card
Panasonic KV-SS905C SCSI   Unsupported might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool.
KV-S2055W USB SCSI   Unsupported might be supported by matsushita backend.
KV-S2055L SCSI   Unsupported might be supported by matsushita backend.
KV-S2065W SCSI   Unsupported might be supported by matsushita backend.
KV-S3065CW USB SCSI   Unsupported might be supported by matsushita backend.
KV-S3065CL USB SCSI   Unsupported might be supported by matsushita backend.
KV-S3085 USB SCSI   Unsupported might be supported by matsushita backend.
KV-S3105C USB SCSI   Unsupported might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool.
KV-S6040W SCSI   Unsupported might be supported by matsushita backend.
KV-S6045W SCSI   Unsupported might be supported by matsushita backend.
KV-S6050W SCSI   Unsupported might be supported by matsushita backend.
KV-S6055W SCSI   Unsupported might be supported by matsushita backend.
KV-S7065C USB SCSI   Unsupported might be supported by matsushita backend.
Pentax DSmobile USB USB 0x0a82/0x2000 Unsupported Probably not supported. Some information is available.
PIE Primefilm 1800u USB 0x05e3/0x0120 Unsupported Not supported. See link for details.
Primefilm 2700 USB   Unsupported  
Primefilm 3600PRO USB IEEE-1394   Unsupported Probably not supported.
Powerslide 3600 USB IEEE-1394 0x05e3/0x0142 Unsupported Probably unsupported. Film scanner that can scan directly from the magazine.
PF3650 Pro3 Film Scanner USB IEEE-1394 0x05e3/0x0143 Unsupported Not supported. See link for details.
Plustek OpticFilm 7200 USB 0x07b3/0x0807 Unsupported GL842 based, maybe to be added to genesys backend
OpticFilm 7200i USB 0x07b3/0x0c04 Unsupported GL843 based, maybe to be added to genesys backend
OpticPro A3U USB   Unsupported Uses Plustek ASIC P99002
OpticPro S6 USB   Unsupported Uses RealTek chipset (RTL8801D)
OpticPro S12 USB 0x07b3/0x0600 Unsupported Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend.
OpticPro ST12 USB 0x07b3/0x0600 Unsupported Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend.
OpticPro ST16 USB 0x07b3/0x0600 Unsupported GL646 based, to be added to genesys backend
OpticPro UA18 USB   Unsupported Probably LM983x based.
OpticPro S24 USB 0x07b3/0x0601 Unsupported Product id 0x0601 is unsupported but may be supported by the genesys backend in future /GL646). Product id 0x040e is supported by the gt68xx backend.
OpticPro ST24 USB 0x07b3/0x0601 Unsupported GL646 based, to be added to genesys backend
OpticPro S28 USB 0x07b3/0x0801 Unsupported GL841 based, to be added to genesys backend
OpticPro ST28 USB 0x07b3/0x0801 Unsupported GL841 based, to be added to genesys backend
OpticPro ST28 USB 0x07b3/0x0802 Unsupported GL841 based, to be added to genesys backend
Umax AstraScan 4750 USB 0x07b3/0x0802 Unsupported GL841 based, to be added to genesys backend, rebadged Plustek ST28
OpticPro ST48 USB 0x07b3/0x0800 Unsupported GL841 based, to be added to genesys backend
OpticPro ST64 USB 0x07b3/0x0c00 Unsupported GL843 based, maybe to be added to genesys backend
OpticPro ST64+ USB 0x07b3/0x0c03 Unsupported GL843 based. See link for more details.
PL 806 USB 0x07b3/0x0c0c Unsupported Unsupported. See link for more details.
SmartOffice PL 812 USB 0x07b3/0x0c0d Unsupported Unsupported. See link for more details.
OpticSlim 500 USB 0x07b3/0x0458 Unsupported Unsupported. See link for more details.
OpticSlim 2420 USB 0x07b3/0x0806 Unsupported GL841 based, to be added to genesys backend
OpticSlim 2420+ USB 0x07b3/0x0914 Unsupported GL841 based, to be added to genesys backend
OpticWorks 2000 Parport   Unsupported Multifunction device. No further information available.
OptiCard 600+ USB   Unsupported Business card reader. No further information available.
ScanCopy 115 USB 0x07b3/0x081c Unsupported GL841 based, to be added to genesys backend
Spectra ADF Proprietary   Unsupported Unsupported. Uses proprietary ISA card that also provides power and is labelled GPS-1 PAGE-A from Taiwan. Other labels on the scanner include ADF Color Scanner and SF600AS. Maybe the same as the IBM ADF Color Scanner?
Unknown Plustek Device USB 0x07b3/0x0005 Unsupported Probably unsupported. Scanner name not known yet.
Unknown Plustek Device USB 0x07b3/0x0007 Unsupported Probably unsupported. Scanner name not known yet.
Unknown Plustek Device USB 0x07b3/0x000f Unsupported Probably unsupported. Scanner name not known yet.
Unknown Plustek Device USB 0x07b3/0x0012 Unsupported Probably unsupported. Scanner name not known yet.
Unknown Plustek Device USB 0x07b3/0x0014 Unsupported Probably unsupported. Scanner name not known yet.
Unknown Plustek Device USB 0x07b3/0x0016 Unsupported Probably unsupported. Scanner name not known yet.
PLANon DocuPen RC800 USB   Unsupported Probably not supported. No details known.
DocuPen R700 USB 0x10c4/0xea60 Unsupported Probably not supported. See link for details.
DocuPen (DPEN-BW) USB   Unsupported Probably not supported. No details known.
Primax Colorado 600U USB 0x0461/0x0341 Unsupported Not supported. Some information is available.
Colorado 1200p Parport   Unsupported Unsupported by SANE. But is reported to partly work with pxscan. See link.
Colorado 1200u USB 0x0461/0x0361 Unsupported Probably unsupported. No details known.
Primascan Colorado 2600u USB 0x0461/0x0347 Unsupported Unsupported. Same as Visioneer Onetouch 4400. See link for details.
Colorado Direct 600 Parport   Unsupported Not supported. However, a stand-alone program is available.
Colorado Direct 9600 Parport   Unsupported Not supported. However, a stand-alone program is available.
Colorado USB 9600 USB 0x0461/0x0340 Unsupported Not supported. See link for details.
G2-300 USB 0x0461/0x0300 Unsupported Probably unsupported. No details known.
G2-300 #2 USB 0x0461/0x0302 Unsupported Probably unsupported. No details known.
G2E-300 USB 0x0461/0x0301 Unsupported Probably unsupported. No details known.
G2E-300 #2 USB 0x0461/0x0303 Unsupported Probably unsupported. No details known.
G2-600 USB 0x0461/0x0380 Unsupported Probably unsupported. No details known.
G2-600 #2 USB 0x0461/0x0382 Unsupported Probably unsupported. No details known.
G2E-600 USB 0x0461/0x0383 Unsupported Probably unsupported. No details known.
OneTouch 5300 Parport   Unsupported Not supported.
ReadyScan 636i USB 0x0461/0x0381 Unsupported Probably unsupported. No details known.
Slim-Line 1200 USB   Unsupported Maybe GL646. Maybe similar to Medion MD 6228?
Onetouch 8920 USB 0x0461/0x0371 Unsupported Not supported. Look similar to Visioneer Onetouch 8920 (same USB product id).
Prolink Winscan Pro 2448U USB 0x06dc/0x0014 Unsupported Not supported. Some information is available. RealTek RTS8801.
Winscan Pro 2000 USB Parport   Unsupported Not supported. No further information available.
Quato X-Finity SCSI   Unsupported Probably not supported. No details yet. Originally manufactured by PFU?
X-Finity Ultra USB IEEE-1394   Unsupported Probably not supported. No details yet.
Reflecta DigitDia 3600 USB IEEE-1394 0x05e3/0x0142 Unsupported Film scanner that can scan directly from the magazine.
iScan 1800 USB 0x05e3/0x0120 Unsupported Probably unsupported. See link for details.
ProScan 4000 USB IEEE-1394 0x05e3/0x0143 Unsupported Probably unsupported. See link for details.
Relisys Eclipse 1200U USB 0x0475/0x0103 Unsupported Probably unsupported. See link for details.
Scorpio Ultra 3 USB 0x0475/0x0210 Unsupported Probably unsupported. See link for details.
Episode USB 0x0475/0x0103 Unsupported Probably unsupported. See link for details.
AVEC II E3 Parport   Unsupported Parport version of AVEC II S3?. See bug #304992 for details
Samsung SCX-4725FN USB 0x04e8/0x341f Unsupported Not supported. See link for details.
Scanshell 800N USB 0x0a82/0x6605 Unsupported Not supported. See link for details.
Sicos DMS 2000 proprietary   Unsupported Not supported until now. Work on a backend has started, contact the author for details (see link)
Siemens ID Mouse Professional USB 0x0681/0x0005 Unsupported Not supported.
Cherry FingerTIP ID Board - Sensor USB 0x0681/0x0010 Unsupported Not supported.
SmartDisk SmartScan 3600 USB IEEE-1394   Unsupported Probably not supported. Same as PIE Primefilm 2600 PRO.
Spot Technology Maxiscan A4 proprietary   Unsupported Not supported until now. Work on a backend has started, see link for more information.
ScanTak 2c proprietary   Unsupported Not supported. Work on a backend has started, see link for more information.
ScanTak 3c proprietary   Unsupported Not supported. Work on a backend has started, see link for more information.
Syscan TravelScan FS-531 USB 0x0a82/0x0530 Unsupported Not supported. May work with the Plustek backend in future. See link for details.
TravelScan Pro USB 0x0a82/0x2000 Unsupported Probably not supported. Some information is available.
Tamarack Artiscan 9600 Parport   Unsupported Unsupported at the moment. See link for a project for that scanner taht may support it in future.
Artiscan 9600 pro 36 Parport   Unsupported Unsupported at the moment. See link for a project for that scanner.
Artiscan 2400FS USB 0x05e3/0x0100 Unsupported Unsupported. See link for more information.
TCE MK600U USB 0x0461/0x0346 Unsupported Not supported. Some information is available.
S450 Parport   Unsupported Not supported by SANE but is reported to work with pxscan (see link).
Teco VM6509F USB 0x080d/0x0102 Unsupported Probably unsupported. See link for details.
Tiny FU661E USB 0x0461/0x0347 Unsupported Unsupported. See link for details.
Trust CombiScan 19200 Parport USB 0x05cb/0x1483 Unsupported Unsupported. See link for details.
EasyScan 19200 Parport   Unsupported  
SCSI Scan 19200 -Excellence Series- SCSI   Unsupported Unsupported. See link for details.
UMAX Astra 2500 USB 0x0461/0x0374 Unsupported Probably not supported. See link for details.
Astra 2850 USB 0x07b3/0x0601 Unsupported Probably not supported. Same IDs as Plustek OpticPro ST24. See link for details.
Astra 3000 USB 0x0461/0x038a Unsupported Probably not supported. See link for details.
Astra 3600 USB 0x0461/0x038a Unsupported Probably not supported. See link for details.
Astra 4000 USB 0x1606/0x1030 Unsupported Not supported. See link for details.
Astra 4100 USB 0x0461/0x038c Unsupported Not supported, to be added to genesys backend.
Astra 4500 USB 0x0638/0x0a10 Unsupported GL646 based, to be added to genesys backend. Avision iVina FB1600 clone
Astra 4600 USB   Unsupported Probably not supported, no details known.
Astra 4700 USB 0x0638/0x0a20 Unsupported GL646/GL660 based. Avision iVina FB1800 clone.
Astra 6700 USB   Unsupported Not supported. No chipset information available. Same as Avision iVina FB2400.
AstraSlim USB 0x080d/0x0104 Unsupported Probably not supported currently. See link for more details.
AstraSlim 1200 USB 0x080d/0x0110 Unsupported See link for more details.
AstraSlim 6000 USB 0x080d/0x0104 Unsupported Probably not supported currently. See link for more details.
Nete3470' Parport   Unsupported Probably not supported. No details known..
Powerlook 180 USB   Unsupported Probably not supported. See link for details.
Powerlook 1000 USB USB   Unsupported Probably not supported. No further information available.
Vantas 3000 USB 0x04a7/0x0224 Unsupported Not supported. See link for more details.
Visioneer 6200 USB 0x0461/0x0345 Unsupported Not supported. Is reported to use the E5 chipset. Uses a Primax ID. Looks similar to Primascan Colorado 2600u.
6200 EPP/USB USB 0x04a7/0x0311 Unsupported Not supported. Id is from Primax? Yet another scanner with the same name?
9420 USB 0x0461/0x03a8 Unsupported Unsupported. See link for details.
9450 USB USB 0x04a7/0x0421 Unsupported Unsupported. See link for details.
Onetouch 4400 USB 0x0461/0x0347 Unsupported Not supported. E5 chipset? See link for more details.
OneTouch 4800 USB USB 0x04a7/0x0224 Unsupported Unsupported. Seems to use Realtek RTS8801B. Same as Microtek Scanport 3000. See link for details.
OneTouch 5300 USB USB 0x04a7/0x0226 Unsupported Not supported. Chipset is RTS8801B(?). See link for output of /proc/bus/usb/devices.
OneTouch 5300 USB 0x04a7/0x0221 Unsupported Not supported. Yet another scanner with this name?
OneTouch 5800 USB USB 0x04a7/0x0226 Unsupported Unsupported. 48 bit scanner, doesn't work with viceo backend. RTS8801C.
OneTouch 6600 USB 0x04a7/0x022a Unsupported Unsupported. See link for details.
Onetouch 7100 USB 0x04a7/0x0229 Unsupported GL646 based, to be added to genesys backend
Onetouch 7700 USB 0x04a7/0x0380 Unsupported LM9832/3 based, to be added to plustek backend
OneTouch 8100 USB 0x04a7/0x0321 Unsupported Unsupported. See link for details.
Onetouch 8700 USB 0x04a7/0x0371 Unsupported Not supported. See link for details.
Onetouch 8900 USB 0x04a7/0x0371 Unsupported Not supported. Same as 8920 but without TA?
Onetouch 8920 USB 0x04a7/0x0371 Unsupported Not supported. Same as 8700 and 8900 but includes a TA. Uses a Primax ID. Chipset is RTS8801C. See link for output of /proc/bus/usb/devices.
Onetouch 9000 USB 0x04a7/0x022c Unsupported Not supported. See link for details.
Onetouch 9020 USB 0x04a7/0x022c Unsupported Not supported. See link for details.
Onetouch 9320 USB 0x04a7/0x0362 Unsupported Probably not supported. See link for details.
Onetouch Pro 8800 USB 0x04a7/0x0410 Unsupported Probably not supported. See link for details.
Onetouch Pro 8820 USB 0x04a7/0x0410 Unsupported Probably not supported. See link for details.
PaperPort 3100b Parport   Unsupported Most probably not supported. See link for details.
PaperPort 6100 Parport   Unsupported Most probably not supported. More details would be appreciated.
PaperPort OneTouch Parport   Unsupported Most probably not supported. See link for details.
Strobe Pro USB USB 0x04a7/0x0102 Unsupported Not supported. See link for details.
4800 One Touch USB 0x04a7/0x03a0 Unsupported Unsupported. See link for details. Different id compared to One Touch 4800?
DocuImage 620S SCSI   Unsupported Not supported. See link for more details.
DocuMate 510 USB 0x04a7/0x0446 Unsupported Not supported. See link for more details.
DocuMate 510 USB 0x04a7/0x047c Unsupported Not supported. See link for more details. Yet another USB id.
One Touch 4800 USB 0x04a7/0x0224 Unsupported Unsupported. See link for details. Different id compared to 4800 One Touch?
WorkCentre 470cx Parport   Unsupported Not supported. See link for more details.
WorkCentre M15i USB 0x0924/0xffef Unsupported Not supported. See link for more details.
WorkCentre XK35c USB Parport 0x043d/0x0020 Unsupported Not supported. See link for more details.
WorkCentre XK50cx USB 0x04e8/0x3903 Unsupported Not supported. See link for more details.
WorkCentre Pro 412 USB Parport 0x043d/0x4303 Unsupported Not supported. See link for more details.
WorkCentre PE16 USB Parport 0x0924/0x4220 Unsupported Not supported. See link for more details.
WorkCentre PE120i USB 0x0924/0x4237 Unsupported Not supported. See link for more details.

Backend: xerox_mfp (1.0-13)

Manual page: sane-xerox_mfp

Manufacturer Model Interface USB id Status Comment
Xerox Phaser 6110MFP USB 0x0924/0x3d5d Good  
Phaser 3200MFP USB 0x0924/0x3da4 Complete  
WorkCentre 3119 Series USB 0x0924/0x4265 Good  
WorkCentre 4118 Series USB 0x0924/0x420c Good  
WorkCentre 3210 USB 0x0924/0x4293 Good  
WorkCentre 3220 USB 0x0924/0x4294 Good  
Dell Dell MFP Laser Printer 1815dn USB 0x413c/0x5124 Good  
Samsung SCX-4x16 USB 0x04e8/0x3409 Untested  
SCX-6x20 USB 0x04e8/0x340d Untested  
MFP-560 USB 0x04e8/0x340e Untested  
MFP-750 USB 0x04e8/0x340f Untested  
SCX-4x20 USB 0x04e8/0x3412 Untested  
SCX-4100 USB 0x04e8/0x3413 Good  
SCX-4x21 USB 0x04e8/0x3419 Untested  
SCX-5x30 USB 0x04e8/0x341a Untested  
SCX-4200 USB 0x04e8/0x341b Good  
CLX-3160 USB 0x04e8/0x341c Untested  
SCX-6x22 USB 0x04e8/0x341d Untested  
SCX4725 USB 0x04e8/0x341f Untested  
SCX4725-FN USB 0x04e8/0x341f Good  
SCX-6x45 USB 0x04e8/0x3420 Untested  
CLX-8380 USB 0x04e8/0x3421 Untested  
CLX-2160 USB 0x04e8/0x3425 Good  
SCX-4500 USB 0x04e8/0x3426 Good  
CLX-6200 USB 0x04e8/0x3427 Untested  
CLX-6240 USB 0x04e8/0x3428 Untested  
SCX-6x55 USB 0x04e8/0x3429 Untested  
CLX-3170fn (CLX-3170 Series) USB 0x04e8/0x342a Good  
CLX-3175FW USB 0x04e8/0x342a Good  
SCX-4500W USB Ethernet 0x04e8/0x342b Basic  
SCX-4824 (SCX-4x24 Series) USB 0x04e8/0x342c Good  
SCX-4828FN (SCX-4x28 Series) USB 0x04e8/0x342d Good  
SCX-4300 USB 0x04e8/0x342e Good  
SCX-5835_5935 USB 0x04e8/0x342f Good  
SCX-5635 USB 0x04e8/0x3430 Untested  
SCX-4x26 USB 0x04e8/0x3432 Untested  
SCX-4600 USB 0x04e8/0x3433 Good  
SCX-4623 USB 0x04e8/0x3434 Good  
MFP-65x USB 0x04e8/0x3435 Untested  
SCX-6545 USB 0x04e8/0x3437 Untested  
CLX-8385 USB 0x04e8/0x3439 Untested  
CLX-6220 USB 0x04e8/0x343a Good  
CLX-6250 USB 0x04e8/0x343b Untested  
SCX-4825FN (SCX-4x25 Series) USB 0x04e8/0x343c Good  
CLX-3185 USB 0x04e8/0x343d Good  
CLX-8540 USB 0x04e8/0x343f Untested  
SCX-4623FW USB 0x04e8/0x3440 Good  
SCX-3205W (SCX-3200 Series) USB Ethernet 0x04e8/0x3441 Good  
SCX-6545X USB 0x04e8/0x3442 Untested  
SCX-6x55X USB 0x04e8/0x3443 Untested  
CLX-8385X USB 0x04e8/0x3444 Untested  
SCX-5835_5935X USB 0x04e8/0x3446 Good  
SCX-4833FD USB 0x04e8/0x344b Good  
SCX-4835FD Ethernet 0x04e8/0x344b Good  
SCX-3405W Ethernet   Basic  
SCX-3400 USB 0x04e8/0x344f Untested  
SF-760 USB 0x04e8/0x3450 Untested  
SCX-4729FD USB 0x04e8/0x3453 Basic  
CLX-6260 USB 0x04e8/0x3455 Minimal  
CLX-3300 Series USB 0x04e8/0x3456 Basic  
SCX-470x USB 0x04e8/0x3457 Untested  
CLX-4190 USB 0x04e8/0x345a Minimal  
SCX-4650 4x21S Series USB 0x04e8/0x345b Untested  
M337x 387x 407x Series USB 0x04e8/0x3460 Untested  
M267x 287x Series USB 0x04e8/0x3461 Untested  
SCX-681x USB 0x04e8/0x3466 Untested  
C460 USB 0x04e8/0x3468 Untested  

Still Cameras

Backends: dc25, dc210, dc240, dmc

Backend: dc25 (1.2)

Link(s): mailto:peter@fales-lorenz.net
Manual page: sane-dc25

Manufacturer Model Interface USB id Status Comment
Kodak DC25 Serial port   Complete  
DC20 Serial port   Basic DC-20 untested by author but reported to work

Backend: dc210 (0.0)

Link(s): mailto:peter@fales-lorenz.net
Manual page: sane-dc210

Manufacturer Model Interface USB id Status Comment
Kodak DC210 Serial port   Basic  

Backend: dc240 (0.0)

Link(s): mailto:peter@fales-lorenz.net
Manual page: sane-dc240

Manufacturer Model Interface USB id Status Comment
Kodak DC240 Serial port   Good Use gphoto2 backend to get USB support

Backend: dmc (unmaintained)

Manual page: sane-dmc

Manufacturer Model Interface USB id Status Comment
Polaroid DMC SCSI   Good  

Video Cameras

Backends: qcam, stv680, unsupported

Backend: qcam (unmaintained)

Manual page: sane-qcam

Manufacturer Model Interface USB id Status Comment
Connectix Color QuickCam Parport   Good Requires root privileges.
Greyscale QuickCam Parport   Minimal Requires root privileges. Partly working.

Backend: stv680 (1.0-1)

Link(s): http://gkall.hobby.nl/stv680-aiptek.html
Manual page: sane-stv680
Comment: This vidcam backend is for the stv0680 chipset, See the website for more info.

Manufacturer Model Interface USB id Status Comment
Aiptek Aiptek Pencam USB 0x0553/0x0202 Minimal image is OK for CIF and QCIF, VGA and QVGA untested, streaming video is a problem
Konica e-mini USB 0x04c8/0x0722 Untested
Digital Dream l' espion XS USB 0x1183/0x0001 Untested
Creative WebCam Go Mini USB 0x041e/0x4007 Untested

Backend: unsupported (2010-06-09)

Link(s): contrib.html
Comment: The devices mentioned here are not supported by any SANE backend. However, there may be links to information about them or stand-alone programs.

Manufacturer Model Interface USB id Status Comment
Biolux 654 (micrOcular) USB 0x0923/0x010f Unsupported Not supported yet. See link for more details.
Grandtek Scopecam 8x30 Binocular & Digital Camera USB 0x0797/0x801c Unsupported Not Supported yet. See link for more details.

APIs

Backends: gphoto2, pint, pnm, test, v4l

Backend: gphoto2 (0.0)

Link(s): mailto:peter@fales-lorenz.net
Manual page: sane-gphoto2
Description: Multiple cameras supported by the gphoto2 libraries
Comment: The long-term plan is to support all the cameras supported by the gphoto2 libraries (currently over 140 models). However, at this stage, only a handful of cameras are definitely known to work with SANE. Other cameras will probably work if the native file format is EXIF or JPEG. Testers welcome!

Backend: pint (unmaintained)

Manual page: sane-pint
Description: Scanners with the machine-independent PINT interface
Comment: Haven't been tested for a long time. Handle with care.

Backend: pnm (1.0.8)

Link(s): mailto:henning@meier-geinitz.de
Manual page: sane-pnm
Description: Reads PNM files
Comment: Used for debugging frontends. Obsolete, use test backend instead.

Backend: test (1.0-28)

Link(s): http://www.meier-geinitz.de/sane/test-backend/
Manual page: sane-test
Description: Frontend-tester
Comment: Backend for testing frontends. Also serves as example for SANE backend options.

Backend: v4l (1.0-3)

Link(s): mailto:henning@meier-geinitz.de
Manual page: sane-v4l
Description: Interface to Video For Linux API
Comment: Supports video cameras and other devices accessed by the v4l kernel API, e.g. bttv devices. Quite a lot of known bugs.

Meta Backends

Backends: dll, net

Backend: dll (1.0.13)

Link(s): mailto:henning@meier-geinitz.de
Manual page: sane-dll
Description: Dynamic loading of shared-library backends.

Backend: net (1.0.14)

Link(s): http://www.penguin-breeder.org/?page=sane-net
Manual page: sane-net
Description: Network access to saned servers
Comment: Can be used to access any scanner supported by SANE over the net. Supports IPv4 and IPv6.

Legend:

Backend:
Name of the backend, in parentheses if available: Version of backend/driver; newer versions may be available from their home sites.
NEW! means brand-new to the current release of SANE.
UNMAINTAINED means that nobody maintains that backend. Expect no new features or newly supported devices. You are welcome to take over maintainership.
Link(s):
Link(s) to more extensive and detailed information, if it exists, or the email address of the author or maintainer.
Manual Page:
A link to the man-page online, if it exists.
Comment:
More information about the backend or model, e.g. the level of support and possible problems.
Manufacturer:
Manufacturer, vendor or brand name of the device.
Model:
Name of the device.
Interface:
How the device is connected to the computer.
USB id:
The USB vendor and product ids as printed by sane-find-scanner -q (only applicable for USB devices).
Status:
Indicates how many of the features the device provides are supported by SANE.
  • unsupported means the device is not supported at least by this backend. It may be supported by other backends, however.
  • untested means the device may be supported but couldn't be tested. Be very careful and report success/failure.
  • minimal means that the device is detected and scans at least in one mode. But the quality is bad or important features won't work.
  • basic means it works at least in the most important modes but quality is not perfect.
  • good means the device is usable for day-to-day work. Some rather exotic features may be missing.
  • complete means the backends supports everything the device can do.
Description:
The scope of application of the backend.

SANE homepage
Contact
This page was last updated on Wed Jul 31 07:52:48 2013 by sane-desc 3.5 from sane-backends 1.0.24git sane-backends-1.0.29/testsuite/tools/data/udev+hwdb.ref0000666000000000000000000000614213615534521017667 00000000000000# This file was automatically created based on description files (*.desc) # by sane-desc 3.5 from sane-backends 1.0.24git on Thu Aug 1 18:50:15 2013 # # udev rules file for supported USB and SCSI devices # # For the list of supported USB devices see /usr/lib/udev/hwdb.d/20-sane.hwdb # # The SCSI device support is very basic and includes only # scanners that mark themselves as type "scanner" or # SCSI-scanners from HP and other vendors that are entitled "processor" # but are treated accordingly. # # If your SCSI scanner isn't listed below, you can add it to a new rules # file under /etc/udev/rules.d/. # # If your scanner is supported by some external backend (brother, epkowa, # hpaio, etc) please ask the author of the backend to provide proper # device detection support for your OS # # If the scanner is supported by sane-backends, please mail the entry to # the sane-devel mailing list (sane-devel@alioth-lists.debian.net). # ACTION!="add", GOTO="libsane_rules_end" # The following rule will disable USB autosuspend for the device ENV{DEVTYPE}=="usb_device", ENV{libsane_matched}=="yes", TEST=="power/control", ATTR{power/control}="on" SUBSYSTEMS=="scsi", GOTO="libsane_scsi_rules_begin" GOTO="libsane_rules_end" LABEL="libsane_scsi_rules_begin" KERNEL!="sg[0-9]*", GOTO="libsane_rules_end" # Generic: SCSI device type 6 indicates a scanner ATTRS{type}=="6", ENV{libsane_matched}="yes" # Some scanners advertise themselves as SCSI device type 3 # Wildcard: for some Epson SCSI scanners ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="SCANNER*", ENV{libsane_matched}="yes" # Epson Perfection 2450 | Epson Perfection 2450 PHOTO ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="GT-9700", ENV{libsane_matched}="yes" # Epson Perfection 3200 | Epson Perfection 3200 PHOTO ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="GT-9800", ENV{libsane_matched}="yes" # Epson Perfection 636S | Epson Perfection 1200S ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="Perfection1200", ENV{libsane_matched}="yes" # Epson Perfection 636 ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="Perfection636", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4p ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1130A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIc ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1750A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIp ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1790A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIcx ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C2500A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4c ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C2520A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5p ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C5110A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6200C ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C6270A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6300C ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C7670A", ENV{libsane_matched}="yes" LABEL="libsane_rules_end" sane-backends-1.0.29/testsuite/tools/data/statistics.ref0000666000000000000000000000076613615534521020204 00000000000000Number of known devices: Scanners: Total: 2337 Supported: 1205 (complete: 417, good: 662, basic: 101, minimal: 25) Untested: 325 Unsupported: 482 Still cameras: Total: 5 Supported: 5 (complete: 1, good: 2, basic: 2, minimal: 0) Untested: 0 Unsupported: 0 Video cameras: Total: 11 Supported: 3 (complete: 0, good: 1, basic: 0, minimal: 2) Untested: 3 Unsupported: 2 Meta backends: Total: 2 API backends: Total: 5 sane-backends-1.0.29/testsuite/tools/data/ascii.ref0000666000000000000000000143733013615534521017104 00000000000000backend `abaton' version `unmaintained' manpage `sane-abaton' url *none* comment *none* type scanner mfg `Abaton' url *none* comment *none* model `Scan 300/GS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `All known modes and functions supported' model `Scan 300/S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Untested, use with caution' backend `agfafocus' version `unmaintained' manpage `sane-agfafocus' url *none* comment *none* type scanner mfg `AGFA' url `http://www.agfa.com/' comment *none* model `Focus GS Scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `6 bit gray' model `Focus Lineart Scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Lineart only? Untested.' model `Focus II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `gray only' model `Focus Color' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3-pass' model `Focus Color Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3-pass' mfg `Siemens' url *none* comment *none* model `S9036' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `gray only' backend `apple' version `unmaintained' manpage `sane-apple' url *none* comment *none* type scanner mfg `Apple' url `http://developer.apple.com/' comment *none* model `Apple Scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `4bit, 16 shades of gray' model `OneScanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `8bit, 256 shades of gray. The backend needs work especially in the quantization code but it may work.' model `Color OneScanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `truecolor (needs much work) but it scans in non color modes.' backend `artec' version `unmaintained' manpage `sane-artec' url `http://www4.infi.net/~cpinkham/sane/sane-artec-doc.html' comment *none* type scanner mfg `Artec/Ultima' url `http://www.artecusa.com/' comment *none* model `AT3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `all modes working' model `A6000C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `all modes working' model `A6000C PLUS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `f/w <= v1.92 basic, f/w >= v1.93 OK' model `AT6' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Scan head needs to return home before another scan can be started.' model `AT12' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `all modes working' model `AM12S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `all modes working' mfg `BlackWidow' url `http://www.blackwidow.co.uk/' comment *none* model `BW4800SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `rebadged Artec AT3' mfg `Plustek' url `http://www.plustek.com/' comment *none* model `OpticPro 19200S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `rebadged Artec AM12S' backend `artec_eplus48u' version `unmaintained' manpage `sane-artec_eplus48u' url *none* comment *none* type scanner mfg `Artec/Ultima' url `http://www.artecusa.com/' comment *none* model `E+ 48U' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4003' status good url *none* comment `CIS scanner based on the GT6816 chip. Apparently all other devices are re-badged Artec scanners.' model `E+ Pro' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4004' status minimal url *none* comment `Works up to 600dpi, but not 1200. Needs better calibration. See bug #310490' mfg `Medion/Lifetec/Tevion/Cytron' url `http://www.medion.com' comment `Sold by Aldi and Tchibo.' model `MD9693' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4003' status good url *none* comment *none* model `MD9705' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4003' status good url *none* comment *none* model `MD4394' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4003' status good url *none* comment `Only scanners with product id 0x4003 will work; try the gt68xx backend, if your scanner has product id 0x4002 ' mfg `Trust' url `http://www.trust-site.com' comment *none* model `Easy Webscan 19200' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4006' status good url *none* comment *none* model `240H Easy Webscan Gold' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4007' status basic url *none* comment `Works up to 600 dpi' mfg `Memorex' url `http://www.artecusa.com/' comment *none* model `MEM 48U' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4005' status good url *none* comment *none* mfg `Microstar' url `http://www.microstar.de/' comment *none* model `MR 9791' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4003' status good url *none* comment *none* mfg `UMAX' url `http://www.umax.com/' url `http://www.umax.com.tw/' url `http://www.umax.de/en' url `http://www.umax-europe.com' url `http://www.umaxjapan.co.jp' url `http://www.umax.com.cn' comment *none* model `AstraSlim SE' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4009' status good url *none* comment *none* model `AstraSlim 1200 SE' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4010' status good url *none* comment *none* mfg `Yakumo' url `http://www.yakumo.com/' comment *none* model `Scan50' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4011' status good url *none* comment *none* backend `as6e' version `0.5' manpage `sane-as6e' url `http://as6edriver.sourceforge.net/' comment *none* type scanner mfg `Artec/Ultima' url `http://www.artecusa.com/' comment *none* model `AS6E' interface `Parport' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Requires the program 'as6edriver' to run.' mfg `Trust' url `http://www.trust-site.com' comment `Carefully check the model names. Trust uses similar names for completely different hardware.' model `Easy Scan 9600 Plus' interface `Parport' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Requires the program 'as6edriver' to run.' mfg `Dexxa' url `http://www.dexxa.com' comment *none* model `4800' interface `Parport' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Requires the program 'as6edriver' to run.' backend `avision' version `Build: 296' manpage `sane-avision' url `http://skull.piratehaven.org/~mike/sane/avision.html' comment *none* type scanner mfg `Avision' url `http://www.avision.com' comment *none* model `AV100CS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV100IIICS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV100S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV120' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a27' status complete url *none* comment `sheetfed scanner' model `AV121' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a3c' status good url *none* comment `sheetfed scanner' model `AV122' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a33' status good url *none* comment `sheetfed duplex scanner' model `AV122 C2' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a93' status good url *none* comment `sheetfed duplex scanner' model `AV210' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a24' status complete url *none* comment `sheetfed scanner' model `AV210' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a25' status complete url *none* comment `sheetfed scanner' model `AV210C2' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a3a' status complete url *none* comment `sheetfed scanner' model `AV210C2-G' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a2f' status complete url *none* comment `sheetfed scanner' model `AV210D2+' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x1a35' status complete url *none* comment `sheetfed scanner' model `AV220' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a23' status complete url *none* comment `duplex! sheetfed scanner' model `AV220C2' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a2a' status complete url *none* comment `duplex! sheetfed scanner' model `AV220D2' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a2b' status complete url *none* comment `duplex! sheetfed scanner' model `AV220+' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a2c' status complete url *none* comment `duplex! sheetfed scanner' model `AV220C2-G' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a2d' status complete url *none* comment `duplex! sheetfed scanner' model `AV220C2-B' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a2e' status complete url *none* comment `duplex! sheetfed scanner' model `AV220-G' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a94' status complete url *none* comment `duplex! sheetfed scanner' model `AV240SC' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV260CS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV360CS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV363CS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV420CS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV6120' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `AV610' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a18' status good url *none* comment *none* model `AV600U Plus' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a18' status good url *none* comment *none* model `AV610C2' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a5e' status good url *none* comment *none* model `AM3000 Series' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a41' status basic url *none* comment `MFD' model `DS610CU Scancopier' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a16' status good url *none* comment `1 pass, 600 dpi, A4' model `AV620CS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, 600 dpi' model `AV620CS Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, 1200 dpi' model `AV630CS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, 1200 dpi' model `AV630CSL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, 1200 dpi' model `AV6240' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, ??? dpi' model `AV600U' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a13' status good url *none* comment `1 pass, 600 dpi' model `AV660S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, ??? dpi' model `AV680S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, ??? dpi' model `AV690U' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, 2400 dpi' model `AV800S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, ??? dpi' model `AV810C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, ??? dpi' model `AV820' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, ??? dpi' model `AV820C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, ??? dpi' model `AV820C Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, ??? dpi' model `AV830C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, ??? dpi' model `AV830C Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, ??? dpi' model `AV880' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, ??? dpi' model `AV880C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `1 pass, ??? dpi' model `AV3200C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, ??? dpi' model `AV3200SU' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a4e' status complete url *none* comment `1 pass, ??? dpi' model `AV3730SU' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a4f' status complete url *none* comment `1 pass, ??? dpi' model `AV3750SU' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a65' status complete url *none* comment `1 pass, ??? dpi' model `AV3800C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, ??? dpi' model `AV3850SU' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a66' status complete url *none* comment `1 pass, ??? dpi' model `FB6000E' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, 1200 dpi, A3 - duplex! - zero edge!' model `FB6080E' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a82' status complete url *none* comment `1 pass, 1200 dpi, A3 - duplex! - zero edge!' model `FB2080E' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a84' status basic url *none* comment `1 pass, 600 dpi, zero-edge' model `AV8000S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `1 pass, 1200 dpi, A3' model `AV8050U' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a4d' status complete url *none* comment `1 pass, 1200 dpi, A3 - duplex!' model `AV8300' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a40' status complete url *none* comment `1 pass, 1200 dpi, A3 - duplex!' model `AV8350' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a68' status complete url *none* comment `1 pass, 1200 dpi, A3 - duplex!' model `IT8300' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a61' status good url *none* comment `1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors' model `@V2500' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0aa1' status untested url *none* comment *none* model `@V5100' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a45' status good url *none* comment `1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors' model `AVA3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `1 pass, 600 dpi, A3' mfg `Hewlett-Packard' url `http://www.hp.com' comment *none* model `ScanJet 5300C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0701' status complete url *none* comment `1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi' model `ScanJet 5370C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0701' status good url *none* comment `1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi' model `ScanJet 7400c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0801' status good url *none* comment `1 pass, 2400 dpi - dual USB/SCSI interface' model `ScanJet 7450c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0801' status good url *none* comment `1 pass, 2400 dpi - dual USB/SCSI interface' model `ScanJet 7490c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0801' status good url *none* comment `1 pass, 1200 dpi - dual USB/SCSI interface' model `ScanJet 8200' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0b01' status good url *none* comment `1 pass, 4800 (?) dpi - USB 2.0' model `ScanJet 8250' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0b01' status good url *none* comment `1 pass, 4800 (?) dpi - USB 2.0' model `ScanJet 8270' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x3905' status good url *none* comment `1 pass, 4800 (?) dpi - USB 2.0' model `ScanJet 8290' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0b01' status good url *none* comment `1 pass, 4800 (?) dpi - USB 2.0 and SCSI - only SCSI tested so far' model `ScanJet 8300' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x3805' status good url *none* comment `1 pass, 4800 (?) dpi - USB 2.0' model `ScanJet 8350' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x3805' status good url *none* comment `1 pass, 4800 (?) dpi - USB 2.0' model `ScanJet 8390' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x3805' status good url *none* comment `1 pass, 4800 (?) dpi - USB 2.0' mfg `Minolta' url `http://www.minolta.com' comment *none* model `Dimage Scan Dual I' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `Scan Multi Pro' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `Dimage Scan Dual II' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x026a' status good url *none* comment `1 pass, film-scanner' model `Elite II' interface `USB' usb-vendor-id `0x0686' usb-product-id `0x4004' status untested url *none* comment `1 pass, film-scanner' model `Dimage Scan Dual III' interface `USB' usb-vendor-id `0x0686' usb-product-id `0x400d' status good url *none* comment `1 pass, film-scanner' model `Dimage Scan Elite 5400' interface `USB' usb-vendor-id `0x0686' usb-product-id `0x400e' status good url *none* comment `1 pass, film-scanner' mfg `Minolta-QMS' url *none* comment *none* model `SC-110' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a15' status untested url *none* comment *none* model `SC-215' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a16' status good url *none* comment *none* mfg `Mitsubishi' url *none* comment *none* model `MCA-ADFC' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `S1200C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `S600C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `SS600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* mfg `Fujitsu' url `http://www.fujitsu.com' comment *none* model `ScanPartner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanPartner 10' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanPartner 10C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanPartner 15C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanPartner 300C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanPartner 600C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanPartner 620C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ScanPartner Jr' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanStation' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `fi-4010CU' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1029' status untested url *none* comment *none* model `fi-5015C' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x10ef' status good url *none* comment *none* mfg `Kodak' url `http://www.kodak.com' comment *none* model `i30' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x6001' status untested url *none* comment *none* model `i40' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x6002' status basic url *none* comment *none* model `i50' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x6003' status untested url *none* comment *none* model `i55' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x6003' status untested url *none* comment *none* model `i60' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x6004' status untested url *none* comment *none* model `i65' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x6004' status untested url *none* comment *none* model `i80' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x6005' status good url *none* comment *none* mfg `iVina' url *none* comment *none* model `1200U' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0268' status untested url *none* comment *none* mfg `Visioneer' url *none* comment *none* model `Strobe XP 450' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0424' status complete url *none* comment `sheetfed scanner' model `Strobe XP 450-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0491' status complete url *none* comment `sheetfed scanner' model `Strobe XP 470' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0479' status complete url *none* comment `sheetfed scanner' model `Strobe XP 470-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x048f' status complete url *none* comment `sheetfed scanner' model `9320' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0420' status complete url *none* comment `sheetfed scanner' model `9450' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0421' status complete url *none* comment `sheetfed scanner' model `9450-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x047a' status complete url *none* comment `sheetfed scanner' model `9550' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0422' status complete url *none* comment `sheetfed scanner' model `9650' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0390' status complete url *none* comment `sheetfed scanner' model `9650-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x047b' status complete url *none* comment `sheetfed scanner' model `9750' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0423' status complete url *none* comment `sheetfed scanner' model `9750-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0493' status complete url *none* comment `sheetfed scanner' model `Patriot 430' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0497' status complete url *none* comment `sheetfed scanner' model `Patriot 470' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x048f' status complete url *none* comment `sheetfed scanner' model `Patriot 680' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0498' status complete url *none* comment `sheetfed scanner' model `Patriot 780' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0499' status complete url *none* comment `sheetfed scanner' mfg `Xerox' url *none* comment *none* model `DocuMate150' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x049c' status good url *none* comment *none* model `DocuMate152' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0477' status good url *none* comment *none* model `DocuMate162' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x049d' status good url *none* comment *none* model `DocuMate250' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0448' status good url *none* comment *none* model `DocuMate250-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0490' status good url *none* comment *none* model `DocuMate252' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0449' status good url *none* comment *none* model `DocuMate252-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x048c' status good url *none* comment *none* model `DocuMate232' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0476' status good url *none* comment *none* model `DocuMate262' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x044c' status good url *none* comment *none* model `DocuMate262-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x048d' status good url *none* comment *none* model `DocuMate262i' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x04a7' status good url *none* comment *none* model `DocuMate272' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0475' status untested url *none* comment *none* model `DocuMate272-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x048e' status untested url *none* comment *none* model `DocuMate510' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0446' status untested url *none* comment *none* model `DocuMate512' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0495' status untested url *none* comment *none* model `DocuMate510-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x047c' status untested url *none* comment *none* model `DocuMate520' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0447' status untested url *none* comment *none* model `DocuMate520-G' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0492' status untested url *none* comment *none* model `DocuMate632' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0498' status untested url *none* comment *none* model `DocuMate752' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0478' status untested url *none* comment *none* model `DocuMate752' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x049a' status untested url *none* comment *none* mfg `OKI' url *none* comment *none* model `S700 Scancopier' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a16' status good url *none* comment `1 pass, 600 dpi, A4' mfg `Bell+Howell' url *none* comment *none* model `2000F' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `1 pass, ??? dpi, A4' mfg `Kyocera' url *none* comment *none* model `FS-1016MFP' interface `USB' usb-vendor-id `0x0482' usb-product-id `0x0335' status untested url *none* comment `1 pass, ??? dpi, A4' backend `bh' version `1.0-4' manpage `sane-bh' url `http://www.martoneconsulting.com/sane-bh.html' comment `Supports Copiscan II scanners with Remote SCSI Controller (RSC) interface' type scanner mfg `Bell and Howell' url `http://www.bhscanners.com/' comment *none* model `COPISCAN II 6338' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Duplex Scanner with ACE - development model' model `COPISCAN II 2135' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Simplex Scanner' model `COPISCAN II 2137(A)' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Simplex Scanner (with ACE) - limited testing' model `COPISCAN II 2138A' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Simplex Scanner with ACE' model `COPISCAN II 3238' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Simplex Scanner' model `COPISCAN II 3338(A)' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Simplex Scanner (with ACE)' backend `canon' version `1.12' manpage `sane-canon' url `http://www.rzg.mpg.de/~mpd/sane/' comment *none* type scanner mfg `Canon' url `http://www.canon.com/' comment *none* model `CanoScan 300' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `1 pass; flatbed scanner' model `CanoScan 600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `1 pass; flatbed scanner' model `CanoScan 620S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `1 pass; flatbed scanner' model `CanoScan 1200S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `1 pass; flatbed scanner' model `CanoScan 2700F' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `1 pass; film scanner' model `CanoScan 2710S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `1 pass; 36bit film scanner' model `IX-4015' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `1 pass; flatbed scanner' mfg `Apple' url `http://www.apple.com/' comment *none* model `Color OneScanner 600/27' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Rebadged CanoScan 300' backend `canon630u' version `0.1' manpage `sane-canon630u' url `http://canon-fb630u.sourceforge.net/' comment *none* type scanner mfg `Canon' url `http://www.canon.com/' comment *none* model `CanoScan fb630u' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2204' status good url *none* comment `OK' model `CanoScan fb636u' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2204' status good url *none* comment `OK' backend `canon_dr' version `38' manpage `sane-canon_dr' url `http://www.thebility.com/canon/' comment `Backend updated for SANE release 1.0.23, see sane-canon_dr manpage' type scanner mfg `Canon' url `http://www.canon.com/' comment *none* model `CR-25' interface `USB' usb-vendor-id `0x1083' usb-product-id `0x161a' status untested url *none* comment `Please test!' model `CR-55' interface `USB' usb-vendor-id `0x1083' usb-product-id `0x160c' status untested url *none* comment `Please test!' model `CR-135i' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x1639' status untested url *none* comment `Please test!' model `CR-180' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x1602' status untested url *none* comment `Please test!' model `CR-180II' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x1602' status untested url *none* comment `Same as CR-180? Please test!' model `CR-190i' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x162b' status untested url *none* comment `Please test!' model `DR-1210C' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2222' status untested url *none* comment `Older version? Please test!' model `DR-1210C' interface `USB' usb-vendor-id `0x1083' usb-product-id `0x160f' status untested url *none* comment `Later version? Please test!' model `DR-2010C' interface `USB' usb-vendor-id `0x1083' usb-product-id `0x161b' status complete url *none* comment `Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions.' model `DR-2010M' interface `USB' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Mac version of DR-2010C? Please test!' model `DR-2050C' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x160a' status complete url *none* comment `Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration.' model `DR-2050SP' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x160a' status untested url *none* comment `Same as DR-2050C? Please test!' model `DR-2080C' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x1601' status complete url *none* comment `Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration' model `DR-2510C' interface `USB' usb-vendor-id `0x1083' usb-product-id `0x1617' status complete url *none* comment `Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions' model `DR-2510M' interface `USB' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Mac version of DR-2510C? Please test!' model `DR-2580C' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x1608' status complete url *none* comment `Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration' model `DR-3010C' interface `USB' usb-vendor-id `0x1083' usb-product-id `0x161d' status good url *none* comment `Minimal testing, settings copied from DR-2510C' model `DR3020' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `DR-3020C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `DR-3060' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `DR-3080C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Almost works, need to investigate traces from windows driver' model `DR-3080CII' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x1609' status untested url *none* comment `Almost works, need to investigate traces from windows driver' model `DR-4010C' interface `USB' usb-vendor-id `0x1083' usb-product-id `0x1614' status good url *none* comment `Binary/HT/Gray/Color, Simplex/Duplex working. Multistream unsupported.' model `DR4080U' interface `USB' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `DR-4580U' interface `USB' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `DR-5010C' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1606' status untested url *none* comment `Please test!' model `DR-5020' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `LineArt, Duplex working, cannot read buttons or screen?' model `DR-5060F' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Grayscale works, LineArt might' model `DR-5080C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `DR-6010C' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x1626' status untested url *none* comment `Please test!' model `DR-6030C' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x1638' status untested url *none* comment `Please test!' model `DR-6050C' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x1624' status good url *none* comment `Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode' model `DR-6080' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x1607' status good url *none* comment `Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported' model `DR-7080C' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x1604' status untested url *none* comment `Please test!' model `DR-7090C' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x1620' status good url *none* comment `ADF and flatbed work' model `DR-7550C' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x1623' status untested url *none* comment `Assumed compatible with DR-6050C' model `DR-7580' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x160b' status good url *none* comment `Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported' model `DR-9050C' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x1622' status good url *none* comment `Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode' model `DR-9080C' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x1603' status good url *none* comment `Simplex, duplex, all resolutions, binary/ht/gray/color, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported' model `DR-X10C' interface `USB SCSI' usb-vendor-id `0x1083' usb-product-id `0x1618' status untested url *none* comment `Please test!' backend `canon_pp' version `0.33' manpage `sane-canon_pp' url `http://canon-fb330p.sourceforge.net' comment *none* type scanner mfg `Canon' url `http://www.canon.com/' comment *none* model `CanoScan FB310P' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Rebadged Avision, different command set' model `CanoScan FB610P' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Rebadged Avision, different command set' model `CanoScan FB320P' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Newly added support' model `CanoScan FB620P' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Newly added support' model `CanoScan FB330P' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `CanoScan FB630P' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `CanoScan N340P' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `CanoScan N640P' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `CanoScan N640P ex' interface `Parport (ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Just an N640P in a different box?' backend `cardscan' version `2' manpage `sane-cardscan' url `http://www.thebility.com/cardscan/' comment `Backend updated for SANE release 1.0.21, see sane-cardscan manpage' type scanner mfg `Corex' url `http://www.cardscan.com/' comment *none* model `800c' interface `USB' usb-vendor-id `0x08f0' usb-product-id `0x0005' status good url *none* comment `4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner' model `600c' interface `USB' usb-vendor-id `0x08f0' usb-product-id `0x0002' status basic url *none* comment `4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner' backend `coolscan' version `0.4.3' manpage `sane-coolscan' url `http://andreas.rick.free.fr/sane/' comment *none* type scanner mfg `Nikon' url `http://www.nikon.com/' comment *none* model `LS-20' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `The LS-20 has been replaced by the LS-30' model `LS-30' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `alpha: only 24/30 bit RGB + 32/40 bit RGBI' model `LS-2000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `alpha: only 24/36 bit + RGB 32/48 bit RGBI' model `LS-1000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Doesn't support gamma correction' backend `coolscan2' version `0.1.8' manpage `sane-coolscan2' url `http://coolscan2.sourceforge.net/' comment *none* type scanner mfg `Nikon' url `http://www.nikon.com/' comment *none* model `LS 30' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `working -- model available to developer' model `LS 2000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `LS 40 ED' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4000' status complete url *none* comment *none* model `LS 4000 ED' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `needs linux kernel 2.4.19 or later' model `LS 50 ED' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4001' status minimal url *none* comment *none* model `Coolscan V ED' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4001' status minimal url `unsupported/nikon-ls50-ed.html' comment *none* model `Super Coolscan LS-5000 ED' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4002' status untested url `unsupported/nikon-ls5000-ed.html' comment `May work, similar to LS 50 ED, but untested. Please tell us if it works.' model `LS 8000 ED' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `needs linux kernel 2.4.19 or later' backend `coolscan3' version `1.0.0' manpage `sane-coolscan3' url *none* comment *none* type scanner mfg `Nikon' url `http://www.nikon.com/' comment *none* model `LS 30' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Coolscan III' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Rebadged LS 30?' model `LS 40 ED' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4000' status complete url *none* comment *none* model `Coolspan IV' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4000' status complete url *none* comment `Rebadged LS 40?' model `LS 50 ED' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4001' status minimal url `unsupported/nikon-ls50-ed.html' comment *none* model `Coolscan V ED' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4001' status minimal url `unsupported/nikon-ls50-ed.html' comment `Rebadged LS 50?' model `LS 2000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `LS 4000 ED' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `needs linux kernel 2.4.19 or later' model `Super Coolscan LS-5000 ED' interface `USB' usb-vendor-id `0x04b0' usb-product-id `0x4002' status untested url `unsupported/nikon-ls5000-ed.html' comment `May work, similar to LS 50 ED, but untested. Please tell us if it works.' model `LS 8000 ED' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `needs linux kernel 2.4.19 or later' backend `dc25' version `1.2' manpage `sane-dc25' url `mailto:peter@fales-lorenz.net' comment *none* type stillcam mfg `Kodak' url `http://www.kodak.com/global/en/service/digCam/dc25/dc25.shtml' comment *none* model `DC25' interface `Serial port' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `DC20' interface `Serial port' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `DC-20 untested by author but reported to work' backend `dc210' version `0.0' manpage `sane-dc210' url `mailto:peter@fales-lorenz.net' comment *none* type stillcam mfg `Kodak' url `http://www.kodak.com/global/en/service/digCam/dc210/dc210.shtml' comment *none* model `DC210' interface `Serial port' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* backend `dc240' version `0.0' manpage `sane-dc240' url `mailto:peter@fales-lorenz.net' comment *none* type stillcam mfg `Kodak' url `http://www.kodak.com/global/en/service/products/ekn006568.jhtml' comment *none* model `DC240' interface `Serial port' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Use gphoto2 backend to get USB support' backend `dell1600n_net' version *none* manpage *none* url *none* comment *none* type scanner mfg `Dell' url `http://www.dell.com/' comment *none* model `1600n' interface `Ethernet USB' usb-vendor-id `0x413c' usb-product-id `0x5250' status basic url *none* comment `Supports colour and monochrome scans over ethernet (USB not supported)' backend `dll' version `1.0.13' manpage `sane-dll' url `mailto:henning@meier-geinitz.de' comment *none* type meta desc `Dynamic loading of shared-library backends.' url *none* comment *none* backend `dmc' version `unmaintained' manpage `sane-dmc' url *none* comment *none* type stillcam mfg `Polaroid' url `http://www.polaroid.com/' comment *none* model `DMC' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* backend `epjitsu' version `20' manpage `sane-epjitsu' url `http://www.thebility.com/epjitsu/' comment `Backend updated for SANE release 1.0.21, see sane-epjitsu manpage' type scanner mfg `Fujitsu' url `http://www.fujitsu.com/' comment *none* model `fi-60F' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x10c7' status basic url *none* comment `A6-size flatbed, 300/600 dpi, color/gray/binary' model `ScanSnap S300' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1156' status good url *none* comment `Duplex, 150/225/300/600 dpi, color/gray/binary, AC/USB power, buttons/sensors all supported. Scanner always scans in _triplex_ color, fast USB required.' model `ScanSnap S300M' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x117f' status good url *none* comment `Same as S300, with different usb id' model `ScanSnap S1100' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1200' status unsupported url *none* comment `Beta version of backend source available, which works well, but breaks support for other epjitsu scanners. See http://ubuntuforums.org/showthread.php?t=1678335' model `ScanSnap S1300' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x11ed' status good url *none* comment `Same as S300, with different usb id' backend `epson' version `unmaintained' manpage `sane-epson' url `http://www.khk.net/sane' comment *none* type scanner mfg `Epson' url `http://www.epson.com/' comment *none* model `GT-5000' interface `SCSI Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Actionscanner II' interface `SCSI Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `US version of GT-5000' model `GT-6000' interface `SCSI Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ES-300C' interface `SCSI Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `US version of GT-6000' model `ES-300GS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-5500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-6500' interface `Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ES-600C' interface `Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `US version of GT-6500' model `ES-1200C' interface `Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `US version of GT-9000' model `GT-7000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-8000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ES-8500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Perfection 636S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `US version of GT-7000' model `Perfection 636' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Perfection 636U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0101' status complete url *none* comment *none* model `Perfection 610' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0103' status complete url *none* comment *none* model `Perfection 640' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010c' status complete url *none* comment *none* model `Perfection 1200S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Perfection 1200U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0104' status complete url *none* comment *none* model `Perfection 1200Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0104' status complete url *none* comment `with TPU' model `Perfection 1240' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x010b' status complete url *none* comment *none* model `Perfection 1640' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x010a' status complete url *none* comment *none* model `Perfection 1650' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0110' status complete url *none* comment *none* model `Perfection 1660' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011e' status complete url *none* comment *none* model `Perfection 2400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011b' status complete url *none* comment *none* model `Perfection 2450' interface `USB IEEE-1394' usb-vendor-id `0x04b8' usb-product-id `0x0112' status complete url *none* comment *none* model `Perfection 3200' interface `USB IEEE-1394' usb-vendor-id `0x04b8' usb-product-id `0x011c' status complete url *none* comment `US version of the GT-9800' model `Perfection 4870' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0128' status complete url *none* comment `US version of the GT-X700' model `Perfection 4990' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012a' status complete url *none* comment `US version of the GT-X800' model `Expression 636' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `US version of GT-9500' model `Expression 800' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Expression 1600' interface `SCSI USB IEEE-1394' usb-vendor-id `0x04b8' usb-product-id `0x0107' status complete url *none* comment *none* model `Expression 1680' interface `SCSI USB IEEE-1394' usb-vendor-id `0x04b8' usb-product-id `0x010e' status complete url *none* comment *none* model `FilmScan 200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.vjet.demon.co.uk/scanner/' comment `A better backend for the FilmScan 200 can be found at http://www.vjet.demon.co.uk/scanner/' model `CX-3200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0802' status good url *none* comment *none* model `CX-3600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080e' status good url *none* comment *none* model `CX-3650' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080e' status good url *none* comment *none* model `CX-4600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080d' status good url *none* comment *none* model `CX-4800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0819' status good url *none* comment *none* model `CX-5000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082b' status good url *none* comment *none* model `CX-5200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0801' status good url *none* comment *none* model `CX-5400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0801' status good url *none* comment *none* model `CX-5400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0808' status good url *none* comment *none* model `CX-6300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0805' status good url *none* comment *none* model `CX-6400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0805' status good url *none* comment *none* model `CX-6500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0813' status good url *none* comment *none* model `CX-6600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0813' status good url *none* comment *none* model `RX-500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0807' status good url *none* comment *none* model `RX-600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0806' status good url *none* comment *none* model `RX-425' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080f' status good url *none* comment *none* model `RX-700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0810' status good url *none* comment *none* model `RX-620' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0811' status good url *none* comment *none* model `DX-3850' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0818' status good url *none* comment *none* model `CX-3700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0818' status good url *none* comment *none* model `CX-3800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0818' status good url *none* comment *none* model `CX-4200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0820' status good url *none* comment *none* model `DX-3800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0818' status good url *none* comment *none* model `DX-5000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082b' status good url *none* comment *none* model `DX-5050' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082b' status good url *none* comment *none* model `DX-6000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082e' status good url *none* comment *none* model `DX-7400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0838' status good url *none* comment *none* model `DX-4050' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082f' status good url *none* comment *none* model `AcuLaser CX11' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0815' status good url *none* comment *none* model `AcuLaser CX11NF' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0815' status good url *none* comment *none* model `V700' interface `USB IEEE-1394' usb-vendor-id `0x04b8' usb-product-id `0x012c' status good url *none* comment *none* model `V750' interface `USB IEEE-1394' usb-vendor-id `0x04b8' usb-product-id `0x012c' status good url *none* comment *none* backend `epson2' version `1.0.124' manpage `sane-epson2' url *none* comment *none* type scanner mfg `Epson' url `http://www.epson.com/' comment *none* model `Actionscanner II' interface `parallel SCSI' usb-vendor-id *none* usb-product-id *none* status good url `http://www.epson.com/' comment `overseas version of the GT-5000' model `AcuLaser CX11' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0815' status good url *none* comment `overseas version of the LP-A500' model `AcuLaser CX11NF' interface `USB Network' usb-vendor-id `0x04b8' usb-product-id `0x0815' status good url *none* comment `network interface supported
AcuLaser CX11 with network interface and fax' model `AcuLaser CX21' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0835' status good url *none* comment `network interface probably supported' model `Artisan 700' interface `USB Network' usb-vendor-id `0x04b8' usb-product-id `0x0846' status good url *none* comment `network interface supported
all-in-one
overseas version of the EP-801A' model `Artisan 710 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0852' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Artisan 800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0844' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the EP-901A' model `Artisan 810 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0853' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `CC-500L' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010d' status unsupported url *none* comment `all-in-one' model `CC-550L' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011a' status unsupported url *none* comment `all-in-one' model `CC-570L' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0802' status good url *none* comment `all-in-one' model `CC-600PX' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0801' status good url *none* comment `all-in-one' model `CC-700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0108' status unsupported url *none* comment `all-in-one' model `EP-702A' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0850' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `EP-801A' interface `USB Network' usb-vendor-id `0x04b8' usb-product-id `0x0846' status good url *none* comment `network interface supported
all-in-one' model `EP-802A' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0852' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `EP-901A' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0844' status good url *none* comment `network interface probably supported
all-in-one' model `EP-901F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0844' status good url *none* comment `network interface probably supported
all-in-one' model `EP-902A' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0853' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `ES-300C' interface `SCSI parallel' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `overseas version of the GT-6000' model `ES-300GS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ES-600C' interface `parallel' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `overseas version of the GT-5400' model `ES-800C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `overseas version of the GT-8000' model `ES-1000C' interface *none* usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `overseas version of the GT-8500' model `ES-1200C' interface `parallel' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `overseas version of the GT-9000' model `ES-2000' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x0107' status complete url *none* comment `IEEE1394 untested' model `ES-2200' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x010e' status complete url *none* comment `IEEE1394 untested' model `ES-6000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ES-6000H' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `IEEE1394 untested' model `ES-6000HS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `IEEE1394 untested' model `ES-7000H' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x0126' status good url *none* comment `network interface unsupported
IEEE1394 untested' model `ES-8000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ES-8500' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x0109' status good url *none* comment `IEEE1394 untested' model `ES-9000H' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `IEEE1394 untested' model `ES-10000G' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0129' status good url *none* comment `network interface unsupported
IEEE1394 untested' model `ES-D400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0136' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `ES-H300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012b' status good url *none* comment `network interface probably supported' model `ES-H7200' interface `USB Ethernet' usb-vendor-id `0x04b8' usb-product-id `0x0138' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Expression 636' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `overseas version of the GT-9500' model `Expression 800' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `overseas version of the GT-9600' model `Expression 836XL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `overseas version of the ES-8000' model `Expression 1600' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x0107' status complete url *none* comment `IEEE1394 untested
overseas version of the ES-2000' model `Expression 1640XL' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x0109' status good url *none* comment `IEEE1394 untested
overseas version of the ES-8500' model `Expression 1680' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x010e' status complete url *none* comment `IEEE1394 untested
overseas version of the ES-2200' model `Expression 1680 Pro' interface `SCSI USB' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `IEEE1394 option' model `Expression 1680XL Pro' interface `SCSI USB' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `Expression 10000XL' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0129' status good url *none* comment `network interface probably supported
IEEE1394 untested
overseas version of the ES-10000G' model `Expression 10000XL Graphic Arts' interface `USB IEEE1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `network interface probably supported' model `Expression 10000XL Photo' interface `USB IEEE1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `network interface probably supported' model `F-3200' interface `USB IEEE1394' usb-vendor-id `0x04b8' usb-product-id `0x080a' status unsupported url *none* comment `Film scanner' model `F-3200 Photo' interface `USB IEEE1394' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment *none* model `FilmScan 200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `will be supported' model `GT-1500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0133' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-2200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0102' status unsupported url *none* comment *none* model `GT-2500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012b' status good url *none* comment `network interface probably supported
overseas version of the ES-H300' model `GT-4000' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `GT-5000' interface `parallel SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-5400' interface `parallel' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-5500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-6000' interface `SCSI Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-6500' interface `parallel' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `overseas version of the GT-5400' model `GT-6600U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0103' status complete url *none* comment *none* model `GT-6700U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010c' status complete url *none* comment *none* model `GT-7000S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `GT-7000U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0101' status complete url *none* comment *none* model `GT-7200U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010f' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-7300U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011d' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-7400U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0120' status unsupported url *none* comment `supported by the snapscan backend' model `GT-7600S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `SCSI version of the GT-7600U' model `GT-7600U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0104' status complete url *none* comment `USB version of the GT-7600S' model `GT-7600UF' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0104' status complete url *none* comment `GT-7600U with TPU option bundled' model `GT-7700U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010b' status complete url *none* comment *none* model `GT-8000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-8200U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0110' status complete url *none* comment *none* model `GT-8200UF' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0110' status good url *none* comment *none* model `GT-8300UF' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011e' status complete url *none* comment *none* model `GT-8400UF' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011f' status unsupported url *none* comment *none* model `GT-8500' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `GT-8700' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x010a' status complete url *none* comment *none* model `GT-8700F' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x010a' status good url *none* comment `GT-8700U with TPU option bundled' model `GT-9000' interface `parallel' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `GT-9300UF' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011b' status complete url *none* comment *none* model `GT-9400UF' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0116' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-9500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `GT-9600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `GT-9700F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0112' status complete url *none* comment `IEEE1394 untested' model `GT-9800F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011c' status complete url *none* comment `IEEE1394 untested' model `GT-10000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `overseas version of the ES-6000' model `GT-10000+' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `IEEE1394 untested
overseas version of the ES-6000H' model `GT-12000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `overseas version of the ES-8000' model `GT-15000' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x0126' status good url *none* comment `IEEE1394 untested
overseas version of the ES-7000H' model `GT-20000' interface `USB Ethernet' usb-vendor-id `0x04b8' usb-product-id `0x0138' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `GT-30000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `IEEE1394 untested
overseas version of the ES-9000H' model `GT-D1000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0133' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0121' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F520' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0122' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F550' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0121' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F570' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0122' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0118' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F650' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012d' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F670' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012e' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012f' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-F720' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0131' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-S50' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0137' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-S80' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0136' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-S600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012d' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-S620' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0131' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-X700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0128' status complete url *none* comment `IEEE1394 untested' model `GT-X750' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0119' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-X770' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0130' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-X800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012a' status complete url *none* comment `film area guide mode not supported
IEEE1394 untested' model `GT-X820' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x013a' status unsupported url `http://www.avasys.jp/lx-bin2/linux/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `GT-X900' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012c' status good url *none* comment `IEEE1394 untested' model `GT-X970' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0135' status good url *none* comment `IEEE1394 untested' model `LP-7900CS' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-7000H' model `LP-9000CCH' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-9000H' model `LP-9000CCS' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-7000H' model `LP-9000CFH' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-9000H' model `LP-9500CCS' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-7000H' model `LP-9500CFH' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-9000H' model `LP-9500CH2' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-9000H' model `LP-9800CCH' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-9000H' model `LP-9800CCS' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-7000H' model `LP-9800CFH' interface *none* usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `business all-in-one; scanner is a ES-9000H' model `LP-A500' interface `USB Network' usb-vendor-id `0x04b8' usb-product-id `0x0815' status good url *none* comment `network interface supported
business all-in-one' model `LP-M5000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0843' status good url *none* comment `network interface probably supported
business all-in-one' model `LP-M5500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0817' status good url *none* comment `network interface probably supported
business all-in-one' model `LP-M5500F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0817' status good url *none* comment `network interface probably supported
business all-in-one
LP-M5500 with the fax option bundled' model `LP-M5600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0833' status good url *none* comment `network interface probably supported
business all-in-one' model `LP-M6000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0834' status good url *none* comment `network interface probably supported
business all-in-one' model `ME 200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0830' status good url *none* comment `all-in-one' model `ME 300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0841' status good url *none* comment `all-in-one
overseas version of the PX-401A' model `ME OFFICE 510' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084f' status good url *none* comment `all-in-one' model `ME Office 600F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0848' status good url *none* comment `all-in-one' model `ME OFFICE 650FN Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0854' status good url *none* comment `all-in-one' model `ME Office 700FW' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0847' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the PX-601F' model `PM-A700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0814' status good url *none* comment `all-in-one' model `PM-A750' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081a' status good url *none* comment `all-in-one' model `PM-A820' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0827' status good url *none* comment `all-in-one' model `PM-A840' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083c' status good url *none* comment `all-in-one' model `PM-A840S' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083c' status good url *none* comment `network interface probably supported
all-in-one' model `PM-A850' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0806' status good url *none* comment `all-in-one' model `PM-A870' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0811' status good url *none* comment `all-in-one' model `PM-A890' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081c' status good url *none* comment `all-in-one' model `PM-A900' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0810' status good url *none* comment `all-in-one' model `PM-A920' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082a' status good url *none* comment `all-in-one' model `PM-A940' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0837' status good url *none* comment `all-in-one' model `PM-A950' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081d' status good url *none* comment `all-in-one' model `PM-A970' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0828' status good url *none* comment `all-in-one' model `PM-T960' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0836' status good url *none* comment `all-in-one' model `PM-T990' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0829' status good url *none* comment `all-in-one
PM-A970 with network interface' model `PX-401A' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0841' status good url *none* comment `all-in-one' model `PX-402A' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084d' status good url *none* comment `all-in-one' model `PX-501A' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084a' status good url *none* comment `network interface probably supported
all-in-one' model `PX-502A' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0856' status good url *none* comment `all-in-one' model `PX-601F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0847' status good url *none* comment `network interface probably supported' model `PX-A550' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080e' status good url *none* comment `all-in-one' model `PX-A620' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082f' status good url *none* comment `all-in-one' model `PX-A640' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0838' status good url *none* comment `all-in-one' model `PX-A650' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0819' status good url *none* comment `all-in-one' model `PX-A720' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082e' status good url *none* comment `all-in-one' model `PX-A740' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0839' status good url *none* comment `all-in-one' model `PX-FA700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083a' status good url *none* comment `all-in-one' model `Perfection 600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `supported by the umax backend
rebadged UMAX Astra 1200S' model `Perfection 610' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0103' status complete url *none* comment `overseas version of the GT-6600U' model `Perfection 636S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `overseas version of the GT-7000S' model `Perfection 636U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0101' status complete url *none* comment `overseas version of the GT-7000U' model `Perfection 640U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010c' status complete url *none* comment `overseas version of the GT-6700U' model `Perfection 660' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0114' status unsupported url *none* comment `supported by the snapscan backend' model `Perfection 1200S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `overseas version of the GT-7600S' model `Perfection 1200U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0104' status complete url *none* comment `overseas version of the GT-7600U' model `Perfection 1200U PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0104' status complete url *none* comment `Perfection 1200U with TPU option bundled
overseas version of the GT-7600UF' model `Perfection 1240U' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010b' status complete url *none* comment `overseas version of the GT-7700U' model `Perfection 1250' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010f' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 1250 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010f' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 1260' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011d' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 1260 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011d' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 1270' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0120' status unsupported url *none* comment `supported by the snapscan backend
overseas version of the GT-7400' model `Perfection 1600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment *none* model `Perfection 1640SU' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x010a' status complete url *none* comment `overseas version of the GT-8700' model `Perfection 1640SU PHOTO' interface `SCSI USB' usb-vendor-id `0x04b8' usb-product-id `0x010a' status good url *none* comment `overseas version of the GT-8700F' model `Perfection 1650' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0110' status complete url *none* comment `overseas version of the GT-8200U' model `Perfection 1650 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0110' status good url *none* comment `overseas version of the GT-8200UF' model `Perfection 1660 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011e' status complete url *none* comment `overseas version of the GT-8300UF' model `Perfection 1670' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011f' status unsupported url *none* comment `supported by the snapscan backend' model `Perfection 1670 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011f' status unsupported url *none* comment `supported by the snapscan backend
overseas version of the GT-8400UF' model `Perfection 2400 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011b' status complete url *none* comment `overseas version of the GT-9300UF' model `Perfection 2450 PHOTO' interface `USB IEEE-1394' usb-vendor-id `0x04b8' usb-product-id `0x0112' status complete url *none* comment `overseas version of the GT-9700F' model `Perfection 2480 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0121' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 2580 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0121' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 3170 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0116' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 3200 PHOTO' interface `USB IEEE-1394' usb-vendor-id `0x04b8' usb-product-id `0x011c' status complete url *none* comment `overseas version of the GT-9800F' model `Perfection 3490 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0122' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 3590 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0122' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 4180 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0118' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 4490 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0119' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection 4870 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0128' status complete url *none* comment `IEEE1394 untested
overseas version of the GT-X700' model `Perfection 4990 PHOTO' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012a' status good url *none* comment `film area guide mode not supported
IEEE1394 untested
overseas version of the GT-X800' model `Perfection 4990 Pro' interface `USB IEEE1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `seems to be a 4990 PHOTO with additional software' model `Perfection V10' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012d' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection V30' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0131' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection V100 Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012d' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection V200 Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012e' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection V300 Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0131' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection V350 Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012f' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection V500 Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0130' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection V600 Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x013a' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Perfection V700 Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012c' status good url *none* comment `IEEE1394 untested
overseas version of the GT-X900' model `Perfection V750 Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x012c' status good url *none* comment `IEEE1394 untested
overseas version of the GT-X900' model `Stylus CX1500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080c' status unsupported url *none* comment `supported by the snapscan backend
all-in-one' model `Stylus CX2800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0830' status good url *none* comment `all-in-one' model `Stylus CX2900' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0830' status good url *none* comment `all-in-one' model `Stylus CX3100' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0802' status good url *none* comment `all-in-one
overseas version of the CC-570L' model `Stylus CX3200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0802' status good url *none* comment `all-in-one
overseas version of the CC-570L' model `Stylus CX3500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080e' status good url *none* comment `all-in-one
overseas version of the PX-A550' model `Stylus CX3600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080e' status good url *none* comment `all-in-one
overseas version of the PX-A550' model `Stylus CX3650' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080e' status good url *none* comment `all-in-one' model `Stylus CX3700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0818' status good url *none* comment `all-in-one' model `Stylus CX3800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0818' status good url *none* comment `all-in-one' model `Stylus CX3810' interface `USB' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `all-in-one' model `Stylus CX3900' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082f' status good url *none* comment `all-in-one
overseas version of the PX-A620' model `Stylus CX4100' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0820' status good url *none* comment `all-in-one' model `Stylus CX4200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0820' status good url *none* comment `all-in-one' model `Stylus CX4300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083f' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Stylus CX4400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083f' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Stylus CX4500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080d' status good url *none* comment `all-in-one' model `Stylus CX4600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080d' status good url *none* comment `all-in-one' model `Stylus CX4700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0819' status good url *none* comment `all-in-one
overseas version of the PX-A650' model `Stylus CX4800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0819' status good url *none* comment `all-in-one
overseas version of the PX-A650' model `Stylus CX4900' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082b' status good url *none* comment `all-in-one' model `Stylus CX5000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082b' status good url *none* comment `all-in-one' model `Stylus CX5100' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0801' status good url *none* comment `all-in-one
overseas version of the CC-600PX' model `Stylus CX5200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0801' status good url *none* comment `all-in-one
overseas version of the CC-600PX' model `Stylus CX5300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0808' status good url *none* comment `all-in-one' model `Stylus CX5400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0808' status good url *none* comment `all-in-one' model `Stylus CX5500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083f' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Stylus CX5600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083f' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Stylus CX5700F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0821' status unsupported url *none* comment `may work with the snapscan backend
all-in-one with FAX' model `Stylus CX5800F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0821' status unsupported url *none* comment `may work with the snapscan backend
all-in-one with FAX' model `Stylus CX5900' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082e' status good url *none* comment `all-in-one
overseas version of the PX-A720' model `Stylus CX6000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082e' status good url *none* comment `all-in-one
overseas version of the PX-A720' model `Stylus CX6300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0805' status good url *none* comment `all-in-one
mistakenly thinks its a PX-A650' model `Stylus CX6400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0805' status good url *none* comment `all-in-one
mistakenly thinks its a PX-A650' model `Stylus CX6500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0813' status good url *none* comment `all-in-one' model `Stylus CX6600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0813' status good url *none* comment `all-in-one' model `Stylus CX6900F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0831' status unsupported url *none* comment `may work with the snapscan backend
all-in-one with FAX' model `Stylus CX7000F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0831' status unsupported url *none* comment `may work with the snapscan backend
all-in-one with FAX' model `Stylus CX7300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0838' status good url *none* comment `all-in-one
overseas version of the PX-A640' model `Stylus CX7400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0838' status good url *none* comment `all-in-one
overseas version of the PX-A640' model `Stylus CX7700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081f' status good url *none* comment `all-in-one' model `Stylus CX7800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081f' status good url *none* comment `all-in-one' model `Stylus CX8300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0839' status good url *none* comment `all-in-one
overseas version of the PX-A740' model `Stylus CX8400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0839' status good url *none* comment `all-in-one
overseas version of the PX-A740' model `Stylus CX9300F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083a' status good url *none* comment `all-in-one
overseas version of the PX-FA700' model `Stylus CX9400Fax' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083a' status good url *none* comment `all-in-one
overseas version of the PX-FA700' model `Stylus DX3800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0818' status good url *none* comment `all-in-one' model `Stylus DX3850' interface `USB' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `all-in-one' model `Stylus DX4000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082f' status good url *none* comment `all-in-one
overseas version of the PX-A620' model `Stylus DX4200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0820' status good url *none* comment `all-in-one' model `Stylus DX4400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083f' status unsupported url `http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do' comment `supported by the epkowa backend plus non-free interpreter' model `Stylus DX4800' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0819' status good url *none* comment `all-in-one
overseas version of the PX-A650' model `Stylus DX4850' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0819' status good url *none* comment `all-in-one
DX4800 + card reader' model `Stylus DX5000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082b' status good url *none* comment `all-in-one' model `Stylus DX6000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x082e' status good url *none* comment `all-in-one
overseas version of the PX-A720' model `Stylus DX7000F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0831' status unsupported url *none* comment `may work with the snapscan backend
all-in-one with FAX' model `Stylus DX7400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0838' status good url *none* comment `all-in-one
overseas version of the PX-A640' model `Stylus DX8400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0839' status good url *none* comment `all-in-one
overseas version of the PX-A740' model `Stylus DX9400F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083a' status good url *none* comment `all-in-one
overseas version of the PX-FA700' model `Stylus Office BX300F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0848' status good url *none* comment `all-in-one' model `Stylus Office BX310FN Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0854' status good url *none* comment `all-in-one' model `Stylus Office BX600FW' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0847' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the PX-601F' model `Stylus Office BX610FW Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0855' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Stylus Office TX300F' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0848' status good url *none* comment `all-in-one' model `Stylus Office TX510FN Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0854' status good url *none* comment `all-in-one' model `Stylus Office TX600FW' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0847' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the PX-601F' model `Stylus Office TX610FW Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0855' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Stylus Photo PX650 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0850' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Stylus Photo PX700W' interface `USB Network' usb-vendor-id `0x04b8' usb-product-id `0x0846' status good url *none* comment `network interface supported
all-in-one
overseas version of the EP-801A' model `Stylus Photo PX710W Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0852' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Stylus Photo PX800FW' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0844' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the EP-901A' model `Stylus Photo PX810FW Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0853' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Stylus Photo RX420' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080f' status good url *none* comment `all-in-one' model `Stylus Photo RX425' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080f' status good url *none* comment `all-in-one' model `Stylus Photo RX430' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080f' status good url *none* comment `all-in-one' model `Stylus Photo RX500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0807' status good url *none* comment `all-in-one' model `Stylus Photo RX510' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0807' status good url *none* comment `all-in-one' model `Stylus Photo RX520' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081a' status good url *none* comment `all-in-one
overseas version of the PM-A750' model `Stylus Photo RX530' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081a' status good url *none* comment `all-in-one
overseas version of the PM-A750' model `Stylus Photo RX560' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0827' status good url *none* comment `all-in-one
overseas version of the PM-A820' model `Stylus Photo RX585' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083c' status good url *none* comment `all-in-one
overseas version of the PM-A840' model `Stylus Photo RX580' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0827' status good url *none* comment `all-in-one
overseas version of the PM-A820' model `Stylus Photo RX595' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083c' status good url *none* comment `all-in-one
overseas version of the PM-A840' model `Stylus Photo RX590' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0827' status good url *none* comment `all-in-one
overseas version of the PM-A820' model `Stylus Photo RX600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0806' status good url *none* comment `all-in-one
overseas version of the PM-A850' model `Stylus Photo RX610' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083c' status good url *none* comment `all-in-one
overseas version of the PM-A840' model `Stylus Photo RX620' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0811' status good url *none* comment `all-in-one
overseas version of the PM-A870' model `Stylus Photo RX630' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0811' status good url *none* comment `all-in-one
overseas version of the PM-A870' model `Stylus Photo RX640' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081c' status good url *none* comment `all-in-one
overseas version of the PM-A890' model `Stylus Photo RX650' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x081c' status good url *none* comment `all-in-one
overseas version of the PM-A890' model `Stylus Photo RX680' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0837' status good url *none* comment `all-in-one
overseas version of the PM-A940' model `Stylus Photo RX685' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0837' status good url *none* comment `all-in-one
overseas version of the PM-A940' model `Stylus Photo RX690' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0837' status good url *none* comment `all-in-one
overseas version of the PM-A940' model `Stylus Photo RX700' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0810' status good url *none* comment `all-in-one
overseas version of the PM-A900' model `Stylus Photo TX650 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0850' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Stylus Photo TX700W' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0846' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the EP-801A' model `Stylus Photo TX710W Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0852' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Stylus Photo TX800FW' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0844' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the EP-901A' model `Stylus NX100' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0841' status good url *none* comment `all-in-one
overseas version of the PX-401A' model `Stylus NX110 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084d' status good url *none* comment `all-in-one
overseas version of the PX-402A' model `Stylus NX200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0849' status good url *none* comment `all-in-one' model `Stylus NX210 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084f' status good url *none* comment `all-in-one' model `Stylus NX300' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0848' status good url *none* comment `all-in-one' model `Stylus NX400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084a' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the PX-501A' model `Stylus NX410 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0851' status good url *none* comment `network interface probably supported
all-in-one' model `Stylus NX510 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0856' status good url *none* comment `all-in-one
overseas version of the PX-502A' model `Stylus SX100' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0841' status good url *none* comment `all-in-one
overseas version of the PX-401A' model `Stylus SX110 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084d' status good url *none* comment `all-in-one
overseas version of the PX-402A' model `Stylus SX125' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x085c' status untested url *none* comment `all-in-one' model `Stylus SX200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0849' status good url *none* comment `all-in-one' model `Stylus SX205' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0849' status good url *none* comment `all-in-one' model `Stylus SX210 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084f' status good url *none* comment `all-in-one' model `Stylus SX400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084a' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the PX-501A' model `Stylus SX405' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084a' status good url *none* comment `all-in-one' model `Stylus SX410 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0851' status good url *none* comment `network interface probably supported
all-in-one' model `Stylus SX510W Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0856' status good url *none* comment `all-in-one
overseas version of the PX-502A' model `Stylus SX600FW' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0847' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the PX-601F' model `Stylus SX610FW Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0855' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' model `Stylus Scan 2000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0105' status untested url *none* comment `apparently mostly the same as the Stylus Scan 2500' model `Stylus Scan 2500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0106' status untested url *none* comment `scanner is apparently a GT-7000' model `Stylus TX100' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0841' status good url *none* comment `all-in-one
overseas version of the PX-401A' model `Stylus TX110 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084d' status good url *none* comment `all-in-one
overseas version of the PX-402A' model `Stylus TX200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0849' status good url *none* comment `all-in-one' model `Stylus TX203' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0849' status good url *none* comment `all-in-one' model `Stylus TX209' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0849' status good url *none* comment `all-in-one' model `Stylus TX210 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084f' status good url *none* comment `all-in-one' model `Stylus TX400' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084a' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the PX-501A' model `Stylus TX410 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0851' status good url *none* comment `network interface probably supported
all-in-one' model `Stylus TX550W Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0856' status good url *none* comment `all-in-one
overseas version of the PX-502A' model `WorkForce 310 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0854' status good url *none* comment `all-in-one' model `WorkForce 500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x084c' status good url *none* comment `all-in-one' model `WorkForce 600' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0847' status good url *none* comment `network interface probably supported
all-in-one
overseas version of the PX-601F' model `WorkForce 610 Series' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0855' status unsupported url *none* comment `supported by the epkowa backend plus non-free interpreter' backend `fujitsu' version `117' manpage `sane-fujitsu' url `http://www.thebility.com/fujitsu/' comment `Backend updated for SANE release 1.0.23, see sane-fujitsu manpage' type scanner mfg `Fujitsu' url `http://www.fujitsu.com/' comment *none* model `M3091DC' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url `http://www.remote.org/frederik/projects/software/sane/' comment `small, old, discontinued' model `M3092DC' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `small, old, discontinued' model `fi-4120C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1041' status complete url *none* comment `small, recent, discontinued, usb 1.1' model `fi-4120C2' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x10ae' status complete url *none* comment `small, recent, discontinued, usb 2.0' model `fi-4220C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1042' status complete url *none* comment `small, recent, discontinued, usb 1.1' model `fi-4220C2' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x10af' status complete url *none* comment `small, recent, discontinued, usb 2.0' model `fi-5110C' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1097' status complete url *none* comment `small, recent, discontinued' model `fi-5110EOX/2' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1096' status complete url *none* comment `small, recent, discontinued' model `fi-5110EOX3' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x10e6' status complete url *none* comment `small, recent, discontinued' model `fi-5110EOXM' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x10f2' status complete url *none* comment `small, recent, discontinued' model `fi-5120C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x10e0' status complete url *none* comment `small, recent, discontinued' model `fi-5220C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x10e1' status complete url *none* comment `small, recent, discontinued' model `fi-5000N' interface `Ethernet' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Not a scanner, rather a scanner to ethernet interface' model `fi-6000NS' interface `Ethernet' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `small, recent, discontinued, integrated touchscreen and keyboard' model `ScanSnap S500' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x10fe' status complete url *none* comment `small, recent, discontinued' model `ScanSnap S500M' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1135' status complete url *none* comment `small, recent, discontinued' model `ScanSnap S510' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1155' status complete url *none* comment `small, recent, discontinued' model `ScanSnap S510M' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x116f' status complete url *none* comment `small, recent, discontinued' model `fi-6130' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x114f' status complete url *none* comment `small, recent, discontinued' model `fi-6230' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1150' status complete url *none* comment `small, recent, discontinued' model `ScanSnap S1500' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x11a2' status complete url *none* comment `small, discontinued' model `ScanSnap S1500M' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x11a2' status complete url *none* comment `small, discontinued, same as S1500' model `ScanSnap N1800' interface `Ethernet' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `small, current, integrated touchscreen and keyboard' model `ScanSnap fi-6010N' interface `Ethernet' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `small, current, integrated touchscreen and keyboard' model `fi-6110' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x11fc' status complete url *none* comment `small, current' model `fi-6130Z' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x11f3' status complete url *none* comment `small, current' model `fi-6230Z' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x11f4' status complete url *none* comment `small, current' model `ScanSnap iX500' interface `USB WiFi' usb-vendor-id `0x04c5' usb-product-id `0x132b' status good url *none* comment `small, current, WiFi not supported. Hardware only scans in color. Backend generates binary and grayscale modes.' model `M3093E' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `medium, old, discontinued' model `M3093DE' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `medium, old, discontinued' model `M3093DG' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `medium, old, discontinued' model `M3093EX' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `medium, old, discontinued' model `M3093GX' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `medium, old, discontinued' model `M3096EX' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `medium, old, discontinued' model `M3096GX' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `medium, old, discontinued' model `M3097E+' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `medium, old, discontinued' model `M3097G+' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `medium, old, discontinued' model `M3097DE' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `medium, old, discontinued' model `M3097DG' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `medium, old, discontinued' model `fi-4340C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x10cf' status complete url *none* comment `medium, current' model `fi-4530C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1078' status complete url *none* comment `medium, recent, discontinued' model `fi-4640S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `medium, recent, discontinued' model `fi-4750C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `medium, recent, discontinued' model `fi-5530C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x10e2' status complete url *none* comment `medium, recent, discontinued' model `fi-6140' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x114d' status complete url *none* comment `medium, recent, discontinued' model `fi-6240' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x114e' status complete url *none* comment `medium, recent, discontinued' model `fi-5530C2' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x114a' status complete url *none* comment `medium, current' model `fi-6140Z' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x11f1' status complete url *none* comment `medium, current' model `fi-6240Z' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x11f2' status complete url *none* comment `medium, current' model `M3099A' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `big, old, discontinued' model `M3099G' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, old, discontinued' model `M3099EH' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `big, old, discontinued' model `M3099GH' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, old, discontinued' model `M3099EX' interface `RS232C/Video' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `big, old, discontinued' model `M3099GX' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, old, discontinued' model `M4097D' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, old, discontinued' model `M4099D' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, old, discontinued' model `fi-4750L' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, recent, discontinued' model `fi-4860C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, recent, discontinued' model `fi-4860C2' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, recent, discontinued' model `fi-4990C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `big, recent, discontinued' model `fi-5650C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x10ad' status complete url *none* comment `big, recent, discontinued' model `fi-5750C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1095' status complete url *none* comment `big, recent, discontinued' model `fi-5900C' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x10e7' status good url *none* comment `big, recent, discontinued. Independent ultrasonic control and multistream unsupported' model `fi-6750S' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1178' status untested url *none* comment `Simplex, USB only version of fi-6770, won't wakeup via software, discontinued' model `fi-5950' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1213' status untested url *none* comment `big, current. Faster version of fi-5900?' model `fi-6670' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1176' status good url *none* comment `big, current, won't wakeup via software' model `fi-6670A' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1177' status good url *none* comment `big, current, VRS CGA board unsupported, won't wakeup via software' model `fi-6770' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1174' status good url *none* comment `big, current, won't wakeup via software' model `fi-6770A' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x1175' status good url *none* comment `big, current, VRS CGA board unsupported, won't wakeup via software' model `fi-6800' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x119d' status untested url *none* comment `big, current. Independent ultrasonic control and multistream unsupported' model `fi-6800-CGA' interface `SCSI USB' usb-vendor-id `0x04c5' usb-product-id `0x119e' status untested url *none* comment `big, current. VRS CGA board unsupported, Independent ultrasonic control and multistream unsupported' backend `genesys' version `1.0-63' manpage `sane-genesys' url `http://www.meier-geinitz.de/sane/genesys-backend/' comment `Only the USB scanners mentioned below are currently supported.' type scanner mfg `Plustek' url `http://www.plustek.de/' url `http://www.plustek.com/' comment *none* model `OpticBook 3600' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0900' status basic url *none* comment `Has a Primax USB ID' mfg `Medion/Lifetec/Tevion/Cytron' url `http://www.medion.com/' url `http://www.medion.de/' comment *none* model `MD5345' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0377' status good url *none* comment `Has a Primax USB ID' model `MD6228' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0377' status good url *none* comment `Has a Primax USB ID. Same as MD5345' model `MD6471' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0377' status complete url *none* comment `Has a Primax USB ID. Same as MD5345' mfg `Hewlett-Packard' url `http://www.hp.com/' comment *none* model `ScanJet 2300C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0901' status complete url *none* comment `600x1200 dpi max' model `ScanJet 2400C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0a01' status complete url *none* comment `1200x1200 dpi max' model `ScanJet G2410' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0a01' status basic url *none* comment `clone of the HP 2400C' model `ScanJet 3670' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1405' status complete url *none* comment `1200x1200 dpi max, complete transparency adaptor support' model `ScanJet 3690C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1405' status complete url *none* comment `1200x1200 dpi max, same as HP 3670' model `ScanJet 4850C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1b05' status untested url *none* comment `resolution from 100 to 2400 supported, UTA not supported yet' model `ScanJet G4010' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x4505' status good url *none* comment `resolution from 100 to 2400 supported, UTA not supported yet' model `ScanJet G4050' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x4605' status good url *none* comment `resolution from 100 to 2400 supported, UTA not supported yet' model `ScanJet N6310' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x4705' status untested url *none* comment `Not supported yet' mfg `Canon' url `http://www.canon.com/' comment *none* model `CanoScan LiDE 35' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2213' status good url *none* comment `Same ids as LiDE 50.' model `CanoScan LiDE 40' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2213' status good url *none* comment `Same ids as LiDE 50.' model `CanoScan LiDE 50' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2213' status good url *none* comment *none* model `CanoScan LiDE 60' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x221c' status good url *none* comment *none* model `CanoScan LiDE 100' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1904' status complete url *none* comment `GL847 based, resolution from 75 to 2400 dpi' model `CanoScan LiDE 110' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1909' status complete url *none* comment `GL124 based, resolution from 75 to 2400 dpi' model `CanoScan LiDE 200' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1905' status complete url *none* comment `GL847 based, resolution from 75 to 4800 dpi' model `CanoScan LiDE 210' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x190a' status complete url *none* comment `GL124 based, resolution from 75 to 2400 dpi' model `CanoScan 4400f' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2228' status unsupported url *none* comment `GL843 based, to be added to the genesys backend' model `CanoScan 5600F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1906' status unsupported url *none* comment `GL847 based, to be added to the genesys backend' model `CanoScan 700F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1907' status good url *none* comment `GL847 based, resolution from 75 to 4800 dpi' model `Canon Image Formula 101' interface `USB' usb-vendor-id `0x1083' usb-product-id `0x162e' status unsupported url *none* comment `GL846 based, work in progress' mfg `Visioneer' url `http://www.visioneer.com/' comment *none* model `Strobe XP 100,r3' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x049b' status good url *none* comment `All resolution and mode supported, calibration is available' model `Strobe XP 200' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0426' status good url *none* comment `All resolution and mode supported, calibration is available' model `Strobe XP 300' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0474' status good url *none* comment `All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally.' model `Roadwarrior' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0494' status basic url *none* comment `All resolution and mode supported, calibration is available' model `Visioneer OneTouch 7100' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0229' status complete url *none* comment `Same as MD5345' mfg `Pentax' url `http://www.pentaxtech.com/' url `http://mobilesolutions.brother-usa.com/' comment *none* model `DSmobile 600' interface `USB' usb-vendor-id `0x0a17' usb-product-id `0x3210' status good url *none* comment `All resolution and mode supported, calibration is available' model `DSmobile 600' interface `USB' usb-vendor-id `0x04f9' usb-product-id `0x2038' status good url *none* comment `All resolution and mode supported, calibration is available' mfg `DCT' url `http://www.docucap.com/' comment `Successor of Syscan in the USA' model `DocketPort 487' interface `USB' usb-vendor-id `0x1dcc' usb-product-id `0x4810' status basic url *none* comment `All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally.' mfg `Syscan' url *none* comment *none* model `DocketPort 485' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x4810' status basic url *none* comment `All resolution and mode supported, front- and backside side-by-side, with backside mirrored horizontally.' model `DocketPort 465' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x4802' status untested url *none* comment `All resolution and mode should be supported, but uncorrected scans' model `DocketPort 665' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x4803' status basic url *none* comment `All resolution and mode supported, calibration is available' model `DocketPort 685/ Ambir DS685' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x480c' status good url *none* comment `All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally.' mfg `Xerox' url `http://www.xerox.com/' comment *none* model `Travel Scanner 100' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x04ac' status good url *none* comment `All resolution and mode supported, calibration is available' model `2400 Onetouch' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x038b' status complete url *none* comment `GL646 based, resolution from 75 to 2400 dpi' mfg `Panasonic' url *none* comment *none* model `KV-SS080' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x100f' status complete url *none* comment `All resolution and mode supported, calibration is available. Support sponsored by cncsolutions (http://www.cncsolutions.com.br)' backend `gphoto2' version `0.0' manpage `sane-gphoto2' url `mailto:peter@fales-lorenz.net' comment *none* type api desc `Multiple cameras supported by the gphoto2 libraries' url `http://www.gphoto.org' comment `The long-term plan is to support all the cameras supported by the gphoto2 libraries (currently over 140 models). However, at this stage, only a handful of cameras are definitely known to work with SANE. Other cameras will probably work if the native file format is EXIF or JPEG. Testers welcome!' backend `gt68xx' version `1.0-84' manpage `sane-gt68xx' url `http://www.meier-geinitz.de/sane/gt68xx-backend/' comment `Only the USB scanners mentioned below are supported. For other Mustek BearPaws, look at the Plustek and the MA-1509 backend.' type scanner mfg `Artec/Ultima' url `http://www.artecusa.com/' comment *none* model `Ultima 2000' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Works, only product id 0x4002 is supported' model `Ultima 2000 e+' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Works, however 12 bit mode doesn't seem to be supported' mfg `Boeder' url *none* comment *none* model `Sm@rtScan Slim Edition' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Similar to Artec Ultima 2000' mfg `Fujitsu' url `http://www.fujitsu.com/' comment *none* model `1200CUS' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status basic url *none* comment `Works, but is slow. Probably a Mustek BearPaw 2400 CU clone.' mfg `Genius' url `http://www.genius-kye.com/' comment *none* model `ColorPage Slim 1200' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x201e' status untested url *none* comment `Untested but should work.' model `Colorpage SF600' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2021' status basic url *none* comment *none* model `Colorpage Vivid3x' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2011' status good url *none* comment *none* model `Colorpage Vivid3 V2' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2011' status good url *none* comment `Same as Colorpage Vivid3x' model `Colorpage Vivid3xe' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2017' status good url *none* comment *none* model `Colorpage Vivid4' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2014' status good url *none* comment *none* model `Colorpage Vivid4x' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x201b' status good url *none* comment *none* model `Colorpage Vivid4xe' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x201a' status good url *none* comment *none* model `Colorpage Vivid 1200 X' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x201d' status good url *none* comment *none* model `Colorpage Vivid 1200 XE' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x201f' status good url *none* comment *none* mfg `Googlegear' url *none* comment *none* model `2000' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Same as Artec Ultima 2000.' mfg `Lexmark' url `http://www.lexmark.com/' comment *none* model `X70' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x002d' status good url *none* comment `Works, some resolutions fail at 16 bit' model `X73' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x002d' status good url *none* comment `Works, some resolutions fail at 16 bit, same as X70' mfg `Medion/Lifetec/Tevion/Cytron' url `http://www.medion.com' comment `Sold by Aldi and Tchibo.' model `MD 4394' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Product id 0x4002. If you have 0x4003, use artec_eplus48u backend.' model `MD/LT 9375' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status untested url *none* comment `Untested, but is reported to have the same ids as the Artec Ultima 2000. Please test.' model `MD/LT 9385' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Similar to Artec Ultima 2000' model `LT 9452' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Similar to Mustek ScanExpress 1200 UB Plus' model `MD 9458' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Similar to Artec Ultima 2000 (e+?)' mfg `Mustek' url `http://www.mustek.com/' url `http://www.mustek.com.tw/' url `http://www.mustek.de/' comment *none* model `BearPaw 1200 CS' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021e' status good url *none* comment *none* model `BearPaw 1200 CU' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment *none* model `BearPaw 1200 CU Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021b' status good url *none* comment *none* model `BearPaw 1200 CU Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021c' status good url *none* comment *none* model `BearPaw 1200 TA' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021e' status good url *none* comment `Transparency adapter supported' model `BearPaw 1248 CU' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021c' status good url *none* comment `Seems to use the same ids as BearPaw 1200 CU Plus.' model `BearPaw 2400 CS' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0218' status untested url *none* comment `Probably works, reports are welcome' model `BearPaw 2400 CS Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0219' status good url *none* comment `Works, problems with 12/16 bit modes?' model `BearPaw 2400 CU' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status basic url *none* comment `Works, but is slow' model `BearPaw 2400 CU Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021d' status good url *none* comment *none* model `BearPaw 2400 TA' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0218' status good url *none* comment `Transparency adapter supported' model `BearPaw 2400 TA Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0219' status good url *none* comment `Transparency adapter supported' model `BearPaw 2448 CS Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021a' status basic url *none* comment `Slow. Same as 2448 TA Plus, but without TA.' model `BearPaw 2448 TA Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021a' status basic url *none* comment `Slow. Transparency adapter supported. Slow. Brightness depends on resolution?' model `Plug-n-Scan 2400 MT' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0219' status good url *none* comment `Works but is slow in high resolutions. Same as BearPaw 2400 TA Plus.' model `Plug-n-Scan 2400 M' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0219' status good url *none* comment `Works but is slow in high resolutions. Same as BearPaw 2400 CS Plus.' model `ScanExpress 1200 UB Plus' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment *none* model `ScanExpress 1248 UB' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021f' status complete url *none* comment *none* model `ScanExpress 2400 USB' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status minimal url *none* comment `Should be detected but may need some more work in the code. Testers welcome. Please contact me if you own this scanner.' model `ScanExpress A3 USB' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0210' status basic url *none* comment `Still some vertical stripes.' model `ScanMagic 1200 UB Plus' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Same as ScanExpress 1200 UB Plus' mfg `NeatReceipts' url *none* comment *none* model `Scanalizer Professional 2.5' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0412' status untested url *none* comment `Similar to Plustek OpticSlim M12. Please tell us if this scanner works.' model `Mobile Scanner' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0462' status basic url *none* comment `Similar to Plustek OpticSlim M12.' mfg `Nortek' url *none* comment *none* model `MyScan 1200' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x040b' status untested url *none* comment `Untested. Please test. Similar to Plustek OpticPro S12?' mfg `Packard Bell' url *none* comment *none* model `Diamond 1200' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Similar to Mustek BearPaw 1200 (Plus)' model `Diamond 1200 Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021c' status good url *none* comment `Similar to Mustek BearPaw 1200 Plus' model `Diamond 1200 Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021b' status good url *none* comment `Similar to Mustek BearPaw 1200 Plus' model `Diamond 2450' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0219' status good url *none* comment *none* mfg `Plustek' url `http://www.plustek.de/' url `http://www.plustek.com/' comment *none* model `OpticPro 1248U' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0400' status good url *none* comment *none* model `OpticPro 1248U' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0401' status good url *none* comment *none* model `OpticPro U16B' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0402' status good url *none* comment *none* model `OpticPro U16B+' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0403' status good url *none* comment *none* model `OpticPro UT16B' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0403' status untested url *none* comment `Probably works. Transparency adapter not supported yet. Please contact me if you own such a device. ' model `OpticPro S12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x040b' status good url *none* comment `Product ID 0x040b only.' model `OpticPro S24' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x040e' status good url *none* comment `Product ID 0x040e only. Is reported to work.' model `OpticPro ST12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x040b' status untested url *none* comment `Product ID 0x040b only. Needs testing. Transparency adapter completely untested. Please contact me if you own such a scanner.' model `OpticSlim 1200' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0413' status good url *none* comment *none* model `OpticSlim 2400' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0422' status good url *none* comment `Works up to 1200 dpi.' model `OpticSlim 2400 plus' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0454' status good url *none* comment `Same as OpticSlim 2400.' model `Iriscan Express 2' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x045f' status complete url *none* comment `Works up to 1200 dpi. Calibration with external calibration sheet supported' model `OpticSlim M12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0412' status complete url *none* comment `Works up to 1200 dpi. Calibration with external calibration sheet supported' mfg `RevScan' url *none* comment *none* model `19200i' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0400' status good url *none* comment `Similar to Plustek OpticPro 1248U' mfg `Trust' url `http://www.trust-site.com' comment *none* model `240TH Easy Webscan Gold' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0218' status good url *none* comment `Same as Mustek Bearpaw 2400 TA plus.' model `Compact Scan USB 19200' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Works, if you have vendor id 0x055f and product id 0x0006, use the mustek_usb backend instead, similar to Mustek ScanExpress 1200 UB (Plus)' model `Direct WebScan 19200' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x021c' status good url *none* comment `Same as Mustek BearPaw 1200 CU Plus (0x021c).' model `Flat Scan USB 19200' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4002' status good url *none* comment `Similar to Artec Ultima 2000' mfg `Visioneer' url `http://www.visioneer.com/' comment *none* model `OneTouch 7300' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0444' status good url *none* comment `Works upto 1200 dpi and 12 bits/color.' backend `hp' version `1.06' manpage `sane-hp' url `http://www.kirchgessner.net/' comment *none* type scanner mfg `Hewlett-Packard' url `http://www.hp.com/' comment *none* model `ScanJet Plus' interface `Propietary' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Driver for HP parallel interface card required' model `ScanJet IIc' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet IIp' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet IIcx' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet 3c' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet 3p' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet 4c' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet 4p' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet 4100C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0101' status complete url *none* comment *none* model `ScanJet 5p' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet 5100C' interface `Parport' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Requires ppscsi driver and epst module' model `ScanJet 5200C' interface `Parport USB' usb-vendor-id `0x03f0' usb-product-id `0x0401' status complete url *none* comment `Parallel interface requires ppscsi driver and epst module' model `ScanJet 6100C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanJet 6200C' interface `SCSI USB' usb-vendor-id `0x03f0' usb-product-id `0x0201' status complete url *none* comment *none* model `ScanJet 6250C' interface `SCSI USB' usb-vendor-id `0x03f0' usb-product-id `0x0201' status complete url *none* comment *none* model `ScanJet 6300C' interface `SCSI USB' usb-vendor-id `0x03f0' usb-product-id `0x0601' status complete url *none* comment *none* model `ScanJet 6350C' interface `SCSI USB' usb-vendor-id `0x03f0' usb-product-id `0x0601' status complete url *none* comment *none* model `ScanJet 6390C' interface `SCSI USB' usb-vendor-id `0x03f0' usb-product-id `0x0601' status complete url *none* comment *none* model `PhotoSmart PhotoScanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* backend `hp3500' version `1.1' manpage `sane-hp3500' url `http://projects.troy.rollo.name/rt-scanners/' comment `HP3500 series scanners.' type scanner mfg `Hewlett-Packard' url `http://www.hp.com' comment *none* model `ScanJet 3500C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x2205' status good url *none* comment *none* model `ScanJet 3530C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x2005' status good url *none* comment *none* model `ScanJet 3570C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x2005' status good url *none* comment *none* backend `hp3900' version `0.12' manpage `sane-hp3900' url `http://sourceforge.net/projects/hp3900-series/' comment `Still Beta' type scanner mfg `Hewlett-Packard' url `http://www.hp.com' comment *none* model `ScanJet 3800' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x2605' status basic url *none* comment `Works with resolutions equal and less than 600dpi' model `ScanJet 3970c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x2305' status good url *none* comment *none* model `ScanJet 4070 Photosmart' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x2405' status good url *none* comment *none* model `ScanJet 4370' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x4105' status basic url *none* comment `Works with resolutions lower than 1200dpi' model `ScanJet G2710' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x2805' status basic url *none* comment `Similar to hp scanjet 3800' model `ScanJet G3010' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x4205' status basic url *none* comment `Similar to hp scanjet 4370' model `ScanJet G3110' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x4305' status basic url *none* comment `Similar to hp scanjet 4370' mfg `UMAX' url `http://www.umax.com' comment *none* model `Astra 4900' interface `USB' usb-vendor-id `0x06dc' usb-product-id `0x0020' status minimal url *none* comment `developing yet' mfg `BenQ' url `http://www.benq.com/' comment *none* model `5550' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2211' status minimal url *none* comment `developing yet' backend `hp4200' version `1.0-2' manpage `sane-hp4200' url `http://hp4200-backend.sourceforge.net' comment *none* type scanner mfg `Hewlett-Packard' url `http://www.hp.com/' comment *none* model `ScanJet 4200C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0105' status basic url *none* comment `8bpp color, 75/150/300/600 dpi only' model `ScanJet 4200Cxi' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0105' status basic url *none* comment `8bpp color, 75/150/300/600 dpi only' model `ScanJet 4200Cse' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0105' status basic url *none* comment `8bpp color, 75/150/300/600 dpi only' backend `hp5400' version `1.0-2' manpage `sane-hp5400' url `http://sourceforge.net/projects/hp5400backend' comment `HP5400 and HP5470 scanners. Prototype backend available' type scanner mfg `Hewlett-Packard' url `http://www.hp.com' comment *none* model `ScanJet 5400c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1005' status basic url *none* comment *none* model `ScanJet 5470c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1105' status basic url *none* comment *none* model `ScanJet 5490c' interface `USB' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* backend `hp5590' version `1.0.5' manpage `sane-hp5590' url *none* comment *none* type scanner mfg `Hewlett-Packard' url `http://www.hp.com' comment *none* model `ScanJet 4500C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1205' status complete url *none* comment `Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives' model `ScanJet 4570C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1305' status complete url *none* comment `Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives' model `ScanJet 5500C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1305' status untested url *none* comment `Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives' model `ScanJet 5550C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1205' status complete url *none* comment `Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives' model `ScanJet 5590' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1705' status complete url *none* comment `Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives' model `ScanJet 7650' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1805' status complete url *none* comment `Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives' backend `hpljm1005' version `0' manpage `sane-hpljm1005' url *none* comment *none* type scanner mfg `Hewlett-Packard' url `http://www.hp.com' comment *none* model `LaserJet M1005 MFP' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x3b17' status good url *none* comment `grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI' model `LaserJet M1120 MFP' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x5617' status good url *none* comment `grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI' model `LaserJet M1120n MFP' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x5717' status good url *none* comment `grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI' backend `hpsj5s' version `0.03' manpage `sane-hpsj5s' url `http://hpsj5s.sourceforge.net/' comment *none* type scanner mfg `Hewlett-Packard' url `http://www.hp.com/' comment *none* model `ScanJet 5s' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `Requires libieee1284 library. Only gray mode.' backend `hs2p' version `1.00' manpage `sane-hs2p' url `http://www.acjlaw.net:8080/~jeremy/Ricoh/' comment `This backend has been tested with the IS450DE (Duplex/Endorser). All major functions necessary for scanning are supported. This backend should work with all Ricoh scanners in the IS450 family as well as the IS420 series, but the IS420 has not yet been tested. Features provided by the optional Image Processing Unit (IPU) are not yet integrated into the backend, as my scanner lacks the IPU.' type scanner mfg `Ricoh' url `http://www.ricoh.com/' comment *none* model `IS450' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `All major scanning-related features are supported (except for IPU). Certain non-scanning features, such as those related to scanner maintenance, are not supported. Such features would be better implemented in a separate stand-alone tool. For instance, if you replace the ADF Unit, you must recalibrate the scanner optics using a Ricoh Test Sheet and reset the E^2PROM registers. Reports are welcome.' model `IS-410' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Untested, please report!' model `IS-420' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Untested, please report!' model `IS-430' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Untested, please report!' backend `ibm' version `1.0-4' manpage `sane-ibm' url `http://www.meier-geinitz.de/sane/ibm-backend/' comment `This backend has had only limited testing. It needs more work especially for the Ricoh scanners. Patches are welcome.' type scanner mfg `IBM' url `http://www.ibm.com/' comment *none* model `2456' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Was reported to work long time ago. Reports are welcome.' mfg `Ricoh' url *none* comment *none* model `IS-410' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Untested, please report!' model `IS-420' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Works at least in flatbed mode.' model `IS-430' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Untested, please report!' backend `kodak' version `7' manpage `sane-kodak' url `http://www.thebility.com/kodak/' comment `New backend for SANE release 1.0.21, see sane-kodak manpage' type scanner mfg `Kodak' url `http://www.kodak.com/' comment *none* model `Scanner 1500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 2500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 3500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 3510' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 3520' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Color Scanner 3590C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Color Scanner 4500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i150 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i160 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i250 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i260 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i280 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 900' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 923' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 5500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 7500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 7520' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 9500' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `Scanner 9520' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i610 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i620 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i640 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i660 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i730 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i750 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i780 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i810 Scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i820 Scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i830 Scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i840 Scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i1840 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' model `i1860 Scanner' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Uncompressed B&W, Gray and Color, some automatic features supported' model `s1740' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Please test!' backend `kodakaio' version `2.4.6' manpage `sane-kodakaio' url `http://sourceforge.net/projects/cupsdriverkodak/' comment `Backend for Kodak AiO ESP and Hero printers. Also possibly Advent AWL10' type scanner mfg `Kodak' url `http://www.kodak.com/' comment *none* model `ESP 2150' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4059' status untested url *none* comment `Please test!' model `ESP 2170' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4066' status untested url *none* comment `Please test!' model `ESP 3200' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4043' status untested url *none* comment `Please test!' model `ESP 3300' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4031' status untested url *none* comment `Please test!' model `ESP 4100' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4053' status untested url *none* comment `Please test!' model `ESP 5000' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4028' status untested url *none* comment `Please test!' model `ESP 5100' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4025' status untested url *none* comment `Please test!' model `ESP 5200' interface `USB Ethernet' usb-vendor-id `0x040a' usb-product-id `0x4041' status basic url *none* comment `USB good, Network good' model `ESP 5300' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4026' status untested url *none* comment `Please test!' model `ESP 5500' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4027' status untested url *none* comment `Please test!' model `ESP 6100' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4054' status untested url *none* comment `Please test!' model `ESP 7200' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4056' status untested url *none* comment `Please test!' model `ESP 9200' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4065' status untested url *none* comment `Please test!' model `ESP 5' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4032' status untested url *none* comment `Please test!' model `ESP 7' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x403e' status untested url *none* comment `Please test!' model `ESP 9' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x403f' status untested url *none* comment `Please test!' model `ESP C110' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4057' status untested url *none* comment `Please test!' model `ESP C115' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4058' status untested url *none* comment `Please test!' model `ESP C310' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x405d' status untested url *none* comment `Please test!' model `ESP C315' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x405e' status untested url *none* comment `Please test!' model `Hero 3.1' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x406d' status untested url *none* comment `Please test!' model `Hero 5.1' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4064' status untested url *none* comment `Please test!' model `Hero Office 6.1' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4062' status untested url *none* comment `Please test!' model `Hero 7.1' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4063' status untested url *none* comment `Please test!' model `Hero 9.1' interface `USB Ethernet' usb-vendor-id `0x040a' usb-product-id `0x4067' status basic url *none* comment `USB good, Network good' mfg `Advent' url `http://www.adventcomputers.co.uk' comment *none* model `AW10' interface `USB' usb-vendor-id `0x040a' usb-product-id `0x4060' status untested url *none* comment `Please test!' backend `kvs20xx' version `unmaintained' manpage `sane-kvs20xx' url *none* comment `New backend for SANE release 1.0.22, see sane-kvs20xx manpage' type scanner mfg `Panasonic' url `http://www.panasonic.com/' comment *none* model `KV-S2025C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `KV-S2026C' interface `USB SCSI' usb-vendor-id `0x04da' usb-product-id `0x1000' status untested url *none* comment *none* model `KV-S2028C' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x100a' status untested url *none* comment *none* model `KV-S2045C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `KV-S2046C' interface `USB SCSI' usb-vendor-id `0x04da' usb-product-id `0x1001' status untested url *none* comment *none* model `KV-S2048C' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x1009' status untested url *none* comment *none* backend `kvs40xx' version `unmaintained' manpage `sane-kvs40xx' url *none* comment `New backend for SANE release 1.0.23, see sane-kvs40xx manpage' type scanner mfg `Panasonic' url `http://www.panasonic.com/' comment *none* model `KV-S4065C' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x100d' status untested url *none* comment *none* model `KV-S4085C' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x100c' status untested url *none* comment *none* model `KV-S7075C' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x100e' status untested url *none* comment *none* backend `kvs1025' version `unmaintained' manpage `sane-kvs1025' url *none* comment `New backend for SANE release 1.0.21, see sane-kvs1025 manpage' type scanner mfg `Panasonic' url `http://www.panasonic.com/' comment *none* model `KV-S1020C' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x1007' status good url *none* comment *none* model `KV-S1025C' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x1006' status good url *none* comment *none* model `KV-S1045C' interface `USB' usb-vendor-id `0x04da' usb-product-id `0x1010' status good url *none* comment *none* backend `leo' version `1.0-10' manpage `sane-leo' url `http://www.zago.net/sane/#leo' comment *none* type scanner mfg `LEO' url *none* comment *none* model `LEOScan S3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `FCC ID LUZFS1130' mfg `Across Technologies' url *none* comment *none* model `FS-1130' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `FCC ID LUZFS1130' mfg `Genius' url *none* comment *none* model `FS-1130 Colorpage Scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* backend `lexmark' version `1.0-0' manpage `sane-lexmark' url `http://stef.dev.free.fr/sane/lexmark' comment `This backend supports lexmark x1100 series scanners.' type scanner mfg `Lexmark' url `http://www.lexmark.com/' comment *none* model `X1110' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007c' status untested url *none* comment *none* model `X1130' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007c' status good url *none* comment `Supports 75, 150, 300, 600 dpi' model `X1140' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007c' status untested url *none* comment *none* model `X1150' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007c' status good url *none* comment `Supports 75, 150, 300, 600 dpi' model `X1170' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007c' status good url *none* comment `Supports 75, 150, 300, 600 dpi' model `X1180' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007c' status good url *none* comment *none* model `X1185' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007c' status good url *none* comment `Tested with xscanimage. Supports 75, 150, 300, 600, 1200(600x1200) dpi resolutions. Does grayscale or colour scans in the following sizes: wallet, 3x5, 4x6, 5x7, 8x10, letter.' model `X1195' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007c' status untested url *none* comment *none* model `X74' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0060' status good url *none* comment `Supports 75, 150, 300, 600 dpi' model `X12xx' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007d' status good url *none* comment `USB1.1 is OK, USB2.0 needs testing' mfg `Dell' url *none* comment *none* model `A920' interface `USB' usb-vendor-id `0x413c' usb-product-id `0x5105' status good url *none* comment `Relabelled X11xx model' backend `ma1509' version `1.0-3' manpage `sane-ma1509' url `http://www.meier-geinitz.de/sane/ma1509-backend/' comment *none* type scanner mfg `Mustek' url `http://www.mustek.com/' url `http://www.mustek.com.tw/' url `http://www.mustek.de/' comment *none* model `BearPaw 1200 F' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0010' status good url *none* comment `Works upto 600 dpi. No support for TA and ADF yet.' mfg `Fujitsu' url `http://www.fujitsu.com/' comment *none* model `fi-4110EOX/2/3' interface `USB' usb-vendor-id `0x04c5' usb-product-id `0x1040' status unsupported url *none* comment `Uses ma1509 chip, but very different from other scanners supported by the ma1509 backend' backend `magicolor' version `1.0.0' manpage `sane-magicolor' url `http://wiki.kainhofer.com/hardware/magicolor_scan' comment *none* type scanner mfg `KONICA MINOLTA' url `http://www.konicaminolta.com/' comment *none* model `magicolor 1690MF' interface `USB Network' usb-vendor-id `0x132b' usb-product-id `0x2089' status good url `http://www.konicaminolta.eu/business-solutions/products/laser-printers/all-in-one/magicolor-1690mf/key-features.html' comment `Multi-function color laser printer with fax, scanner and network interface' model `BizHub 162/132' interface `USB Network' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov.' model `DiMage 1611' interface `USB Network' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov.' backend `matsushita' version `1.0-7' manpage `sane-matsushita' url `http://www.zago.net/sane' comment *none* type scanner mfg `Panasonic' url `http://www.panasonic.com/' comment *none* model `KV-SS25' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `KV-SS25D' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `KV-SS50' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `KV-SS55' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `KV-SS50EX' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `KV-SS55EX' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `no color, no high resolution, no automatic cropping' model `KV-SS850' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `KV-SS855' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `KV-S2025C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `no color, no high resolution, no automatic cropping' model `KV-S2045C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `no color, no high resolution, no automatic cropping' model `KV-S2065L' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `no color, no high resolution, no automatic cropping' backend `microtek' version `0.13.1' manpage `sane-microtek' url `http://www.mir.com/mtek/' comment *none* type scanner mfg `Microtek' url `http://www.microtek.com/' comment *none* model `Scanmaker E6' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Scanmaker E3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Scanmaker E2' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3-pass' model `Scanmaker 35t+' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `slide-scanner' model `Scanmaker 45t' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `slide-scanner' model `Scanmaker 35' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `slide-scanner' model `Scanmaker III' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Scanmaker IISP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Scanmaker IIHR' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3-pass' model `Scanmaker IIG' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `gray only' model `Scanmaker II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3-pass' model `Scanmaker 600Z(S)' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `Scanmaker 600G(S)' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `gray only (see manpage)' model `Color PageWiz' interface `SCSI (Parport)' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `sheet-fed (preliminary, see mapage)' mfg `Agfa' url `http://www.agfa.com/' comment *none* model `Arcus II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Arcus *II*, not Arcus!' model `StudioScan' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `StudioScan II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `StudioScan IIsi' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Studiostar' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `Is detected but scans are very dark' model `DuoScan' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* mfg `Vobis' url `http://www.vobis.de/' comment *none* model `Highscreen Realscan' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* mfg `Genius' url `http://www.genius-kye.com/' comment *none* model `Colorpage-SP2' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Same as Microtek Scanmaker E3' backend `microtek2' version `unmaintained' manpage `sane-microtek2' url `http://karstenfestag.gmxhome.de/linux.html' comment *none* type scanner mfg `Microtek' url `http://www.microtek.com/' comment *none* model `ScanMaker E3plus' interface `Parport' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanMaker E3plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanMaker X6' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanMaker X6EL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `ScanMaker X6USB' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x0099' status good url *none* comment *none* model `ScanMaker V300' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ScanMaker V300' interface `Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ScanMaker V310' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `ScanMaker V310' interface `Parport' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `ScanMaker V600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `ScanMaker V600' interface `Parport' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `ScanMaker 330' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `ScanMaker 630' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `ScanMaker 636' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanMaker 6400XL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanMaker 9600XL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `only flatbed mode ?' model `ScanMaker 9800XL' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status minimal url `unsupported/microtek-scanmaker-9800.html' comment `IEEE-1394 seems to work. See link. More reports welcome.' model `Phantom 330CX' interface `Parport' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `SlimScan C3' interface `Parport' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Phantom 636' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Phantom 636CX' interface `Parport' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `SlimScan C6' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x009a' status complete url *none* comment *none* model `ScanMaker V6UPL' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x00b6' status basic url *none* comment `Sometimes scan speed goes to fast and results look badly smudged.' model `ScanMaker V6USL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanMaker V6USL' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x00a3' status complete url *none* comment *none* model `ScanMaker V6USL' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x80a3' status complete url *none* comment *none* model `ScanMaker X12USL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `only Flatbed mode ?' mfg `Vobis' url `http://www.vobis.de/' comment *none* model `HighScan' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `only E3plus based models' mfg `Scanport' url `http://www.scanport.com/' comment *none* model `SQ300' interface `Parport?' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `SQ2030' interface `Parport' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `SQ4836' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* mfg `Genius' url `http://www.geniusmouse.co.uk/' comment *none* model `ColorPage-EP' interface `Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* backend `mustek' version `1.0-138' manpage `sane-mustek' url `http://www.meier-geinitz.de/sane/mustek-backend/' comment `Most Mustek SCSI scanners are supported by this backend. For USB scanners, look at the mustek_usb backend.' type scanner mfg `Mustek' url `http://www.mustek.com/' url `http://www.mustek.com.tw/' url `http://www.mustek.de/' comment *none* model `Paragon MFS-6000CX' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3-pass' model `Paragon MFS-12000CX' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3-pass' model `Paragon MFC-600S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon 600 II CD' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon 600 II ED' interface `Parport' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `Completely untested. If it's the same as the 600 II EP, it may work. Please contact me if you own such a device.' model `Paragon 600 II EP' interface `Parport' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `Works, however only low resolutions and quality in color mode is bad.' model `ScanMagic 600 II SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `TwainScan II SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon MFC-800S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon 800 II SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon MFS-6000SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon MFS-8000SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon MFS-1200SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon MFS-12000SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanExpress 6000SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanExpress 12000SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanExpress 1200 FS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `One report that it crashes the computer. SCSI driver issue? Please contact me if you own such a device.' model `ScanExpress 12000SP Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon 1200 III SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `Paragon 1200 LS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanMagic 9636S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanMagic 9636S Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `ScanExpress A3 SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Please test!' model `Paragon 1200 SP Pro' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Paragon 1200 A3 Pro' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `ADF and TA untested. Please contact me if you own such equipment.' model `Paragon 600 II N' interface `Proprietary' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Resolutions above 300 dpi may cause trouble.' mfg `Trust' url `http://www.trust-site.com' comment `Carefully check the model names. Trust uses similar names for completely different hardware.' model `Imagery 1200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3-pass, Mustek Paragon MFS-6000CX compatible' model `Imagery 1200 SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Mustek Paragon MFS-6000SP compatible' model `Imagery 4800 SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Mustek Paragon 600 II CD compatible' model `SCSI Connect 19200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Mustek ScanExpress 12000SP compatible' model `SCSI excellence series 19200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Mustek ScanExpress 12000SP compatible' mfg `Primax' url `http://www.primax.nl/' comment *none* model `Compact 4800 SCSI' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Mustek 600 II CD compatible' backend `mustek_pp' version `13' manpage `sane-mustek_pp' url `http://penguin-breeder.org/sane/mustek_pp/' comment `Supports CIS and CCD type parallel port scanners from Mustek.' type scanner mfg `Mustek' url `http://www.mustek.com/' url `http://www.mustek.com.tw/' url `http://www.mustek.de/' comment *none* model `ScanExpress 6000 P' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' model `ScanExpress 600 SEP' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' model `ScanMagic 4800 P' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' model `600 III EP Plus' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' model `96 CP' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300x600 dpi CIS scanner' model `ScanExpress 600 CP' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300x600 dpi CIS scanner' model `ScanMagic 600 CP' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300x600 dpi CIS scanner' model `ScanExpress 1200 CP' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `600x1200 dpi CIS scanner' model `ScanExpress 1200 CP+' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `600x1200 dpi CIS scanner' mfg `Medion/Lifetec/Tevion/Cytron' url `http://www.medion.de/' comment `Those scanners are also known as "Aldi Scanner " or "Tchibo Scanners "' model `MD 9848' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' model `MD 9806' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' model `MD/LT 935x' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `600x1200 dpi CIS scanner' model `MD/LT 985x' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `600x1200 dpi CIS scanner' model `MD/LT 9890' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `600x1200 dpi CIS scanner' mfg `Targa' url *none* comment *none* model `Funline TS12 EP' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `600x1200 dpi CIS scanner' model `Funline TS6 EP' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300x600 dpi CIS scanner' mfg `Trust' url `http://www.trust-site.com/home/' comment *none* model `Easy Connect 9600+' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300x600 dpi CIS scanner' model `Easy Connect 19200+' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300x600 dpi CIS scanner' mfg `Viviscan' url *none* comment *none* model `Compact II' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' mfg `Cybercom' url *none* comment *none* model `9352' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `CIS scanner' mfg `Gallery' url *none* comment *none* model `4800' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' mfg `Network' url *none* comment *none* model `Easy Plus 30 Bit' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300 dpi CCD scanner' mfg `Micromaxx' url *none* comment *none* model `MM-9851' interface `Parport (EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `300x600 dpi CIS scanner' backend `mustek_usb' version `1.0-18' manpage `sane-mustek_usb' url `http://www.meier-geinitz.de/sane/mustek_usb-backend/' comment `Only the USB scanners mentioned below are supported. For BearPaws, look at the Plustek, MA-1509, and gt68xx backends.' type scanner mfg `Mustek' url `http://www.mustek.com/' url `http://www.mustek.com.tw/' url `http://www.mustek.de/' comment *none* model `ScanExpress 600 CU' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0002' status complete url *none* comment *none* model `ScanExpress 1200 CU' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0001' status complete url *none* comment *none* model `ScanExpress 1200 CU Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0008' status complete url *none* comment *none* model `ScanExpress 1200 UB' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0006' status complete url *none* comment `For the UB Plus, see gt68xx backend' mfg `Trust' url `http://www.trust-site.com' comment *none* model `Compact Scan USB 19200' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0006' status complete url *none* comment `Mustek 1200 UB compatible' backend `mustek_usb2' version `1.0-10' manpage `sane-mustek_usb2' url `http://www.meier-geinitz.de/sane/mustek_usb2-backend/' comment `Only BearPaw 2448TA Pro is supported at the moment' type scanner mfg `Mustek' url `http://www.mustek.com/' url `http://www.mustek.com.tw/' url `http://www.mustek.de/' comment *none* model `BearPaw 2448TA Pro' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0409' status good url *none* comment *none* backend `nec' version `0.12' manpage `sane-nec' url `http://www5a.biglobe.ne.jp/~saetaka/' comment *none* type scanner mfg `NEC' url `http://www.nevt.co.jp/' comment *none* model `PC-IN500/4C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `PC-IN500/4C was sold only in JAPAN' backend `net' version `1.0.14' manpage `sane-net' url `http://www.penguin-breeder.org/?page=sane-net' comment *none* type meta desc `Network access to saned servers' url *none* comment `Can be used to access any scanner supported by SANE over the net. Supports IPv4 and IPv6.' backend `niash' version `0.3' manpage `sane-niash' url `http://sourceforge.net/projects/hp3300backend' comment *none* type scanner mfg `Hewlett-Packard' url `http://www.hp.com' comment *none* model `ScanJet 3300c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0205' status complete url *none* comment *none* model `ScanJet 3400c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0405' status complete url *none* comment `If you use Linux 2.6, version 2.6.8 or newer is necessary.' model `ScanJet 4300c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0305' status complete url *none* comment `If you use Linux 2.6, version 2.6.8 or newer is necessary.' model `ScanJet 4300c/Silitek' interface `USB' usb-vendor-id `0x047b' usb-product-id `0x1002' status complete url *none* comment `If you use Linux 2.6, version 2.6.8 or newer is necessary.' mfg `Agfa' url `http://www.agfa.com' comment *none* model `Snapscan Touch' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x0100' status complete url *none* comment *none* mfg `Trust' url `http://www.trust.com' comment *none* model `Office Scan USB 19200' interface `USB' usb-vendor-id `0x047b' usb-product-id `0x1000' status complete url *none* comment *none* backend `p5' version `1' manpage `sane-p5' url `http://www.sane-project.org/' comment `New backend for SANE release 1.0.21, see sane-p5 manpage' type scanner mfg `PRIMAX' url `http://www.primax.com.tw' comment *none* model `PagePartner' interface `Parport (EPP/ECP)' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `Sheetfed scanner, work in gray and color, but uncalibrated scans' backend `pie' version `1.0' manpage `sane-pie' url `http://www.munton.demon.co.uk/sane' comment *none* type scanner mfg `Devcom' url `http://www.blackwidow.co.uk/' comment *none* model `9636PRO' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `9636S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `9630S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* mfg `PIE' url `http://www.scanace.com/' comment *none* model `ScanAce 1236S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ScanAce 1230S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ScanAce II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanAce III' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ScanAce Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanAce II Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanAce III Plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanAce V' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanAce ScanMedia' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanAce ScanMedia II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanAce 630S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `ScanAce 636S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* mfg `Adlib' url *none* comment *none* model `JetScan630' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `JetScan636PRO' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* backend `pint' version `unmaintained' manpage `sane-pint' url *none* comment *none* type api desc `Scanners with the machine-independent PINT interface' url *none* comment `Haven't been tested for a long time. Handle with care.' backend `pixma' version `0.17.3' manpage `sane-pixma' url `http://home.arcor.de/wittawat/pixma/' url `http://mp610.blogspot.com/' comment *none* type scanner mfg `Canon' url `http://www.canon.com/' comment *none* model `PIXMA E500' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1758' status untested url *none* comment `Testers needed!' model `PIXMA E510' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1761' status untested url *none* comment `Testers needed!' model `PIXMA E600' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x175a' status untested url *none* comment `Testers needed!' model `PIXMA E610' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1767' status untested url *none* comment `Testers needed!' model `PIXMA MG2100 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1751' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MG2200 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1760' status untested url *none* comment `Testers needed!' model `PIXMA MG3100 Series' interface `USB WLAN' usb-vendor-id `0x04a9' usb-product-id `0x1752' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MG3200 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1762' status untested url *none* comment `Testers needed!' model `PIXMA MG4100 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1753' status untested url *none* comment `Testers needed!' model `PIXMA MG4200 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1763' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MG5100 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1748' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MG5200 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1749' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MG5300 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1754' status complete url *none* comment `All resolutions supported (up to 2400DPI).' model `PIXMA MG5400 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1764' status untested url *none* comment `Testers needed!' model `PIXMA MG6100 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x174a' status complete url *none* comment `All resolutions supported (up to 2400 DPI)' model `PIXMA MG6200 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1755' status complete url *none* comment `All resolutions supported (up to 4800 DPI)' model `PIXMA MG6300 Series' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1765' status complete url *none* comment `All resolutions supported (up to 2400DPI).' model `PIXMA MG8100 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x174b' status untested url *none* comment `Testers needed!' model `PIXMA MG8200 Series' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1756' status complete url *none* comment `All resolutions supported (up to 4800DPI).' model `PIXMA MP140' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x172b' status complete url *none* comment `All resolutions supported (up to 600 DPI)' model `PIXMA MP150' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1709' status good url *none* comment *none* model `PIXMA MP160' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1714' status basic url *none* comment *none* model `PIXMA MP170' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x170a' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MP180' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1715' status basic url *none* comment *none* model `PIXMA MP190' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1734' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `PIXMA MP210' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1721' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `PIXMA MP220' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1722' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MP230' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x175f' status complete url *none* comment `All resolutions supported (up to 600DPI).' model `PIXMA MP240' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1732' status complete url *none* comment `All resolutions supported (up to 1200DPI)' model `PIXMA MP250' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x173a' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `PIXMA MP260' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1733' status complete url *none* comment `All resolutions supported (up to 1200DPI)' model `PIXMA MP270' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x173b' status complete url *none* comment `All resolutions supported (up to 1200DPI)' model `PIXMA MP280' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1746' status good url *none* comment `All resolutions supported (up to 600DPI).' model `PIXMA MP360' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x263c' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MP370' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x263d' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MP375R' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x263f' status untested url *none* comment `Same protocol as Pixma MP360/370/390? Testers needed!' model `PIXMA MP390' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x263e' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MP450' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x170b' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MP460' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1716' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MP470' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1723' status complete url *none* comment `All resolutions supported (up to 2400DPI).' model `PIXMA MP480' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1731' status complete url *none* comment `All resolutions supported (up to 2400DPI)' model `PIXMA MP490' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x173c' status complete url *none* comment `All resolutions supported (up to 1200DPI)' model `PIXMA MP493' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1757' status untested url *none* comment `Testers needed!' model `PIXMA MP495' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1747' status untested url *none* comment `Same protocol as Pixma MP280? Testers needed!' model `PIXMA MP500' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x170c' status good url *none* comment *none* model `PIXMA MP510' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1717' status complete url *none* comment `All resolutions supported (up to 1200DPI).' model `PIXMA MP520' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1724' status complete url *none* comment `All resolutions supported (up to 2400DPI)' model `PIXMA MP530' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1712' status good url *none* comment *none* model `PIXMA MP540' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1730' status complete url *none* comment `All resolutions supported (up to 2400DPI)' model `PIXMA MP550' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x173d' status complete url *none* comment `All resolutions supported (up to 2400DPI)' model `PIXMA MP560' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x173e' status complete url *none* comment `All resolutions supported (up to 2400DPI)' model `PIXMA MP600' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1718' status complete url *none* comment `All resolutions supported (up to 2400DPI)' model `PIXMA MP600R' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1719' status complete url *none* comment `All resolutions supported (up to 2400DPI)' model `PIXMA MP610' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1725' status complete url *none* comment `All resolutions supported (up to 4800DPI)' model `PIXMA MP620' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x172f' status complete url *none* comment `All resolutions supported (up to 2400DPI)' model `PIXMA MP630' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x172e' status complete url *none* comment `All resolutions supported (up to 4800DPI)' model `PIXMA MP640' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x173f' status complete url *none* comment `All resolutions supported (up to 4800DPI)' model `PIXMA MP700' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2630' status complete url *none* comment `All resolutions supported (flatbed color up to 1200DPI, grayscale up to 600DPI).' model `PIXMA MP710' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x264d' status complete url *none* comment `All resolutions supported (up to 1200DPI)' model `PIXMA MP730' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x262f' status good url *none* comment `Flatbed color up to 1200DPI, grayscale up to 600DPI. ADF scan to be confirmed.' model `PIXMA MP740' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x264c' status untested url *none* comment `Same protocol as Pixma MP710? Testers needed!' model `PIXMA MP750' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1706' status minimal url *none* comment `No grayscale. Canceling scan in ADF mode doesn't eject the paper!' model `PIXMA MP760' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1708' status minimal url *none* comment `No grayscale. The scanner sometimes hangs!' model `PIXMA MP770' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1708' status minimal url *none* comment `No grayscale. The scanner sometimes hangs!' model `PIXMA MP780' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1707' status minimal url *none* comment `No grayscale. The scanner sometimes hangs!' model `PIXMA MP790' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1707' status minimal url *none* comment `No grayscale. The scanner sometimes hangs!' model `PIXMA MP800' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x170d' status complete url *none* comment `All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI.' model `PIXMA MP800R' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x170e' status complete url *none* comment `All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI.' model `PIXMA MP810' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x171a' status complete url *none* comment `All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI.' model `PIXMA MP830' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1713' status complete url *none* comment `All resolutions supported up to 2400DPI. Flatbed, ADF simplex and Duplex supported.' model `PIXMA MP960' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x171b' status complete url *none* comment `All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI.' model `PIXMA MP970' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1726' status complete url *none* comment `All resolutions supported (up to 4800DPI). Full TPU support (negative and slides) at 24 or 48 bits.' model `PIXMA MP980' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x172d' status complete url *none* comment `Working fine at all resolutions.' model `PIXMA MP990' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1740' status complete url *none* comment `Working fine at all resolutions.' model `PIXMA MX300' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1727' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `PIXMA MX310' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1728' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 1200DPI)' model `PIXMA MX320' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1736' status untested url *none* comment `Same protocol as Pixma Generation 3? Testers needed!' model `PIXMA MX330' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1737' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 1200DPI)' model `PIXMA MX340' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1741' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 1200DPI)' model `PIXMA MX350' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1742' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 1200DPI)' model `PIXMA MX360' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x174d' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy.' model `PIXMA MX370 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1759' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 1200DPI).' model `PIXMA MX390 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1766' status untested url *none* comment `Testers needed!' model `PIXMA MX410' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x174e' status untested url *none* comment `Same protocol as Pixma MX420? Testers needed!' model `PIXMA MX420' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x174f' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy.' model `PIXMA MX430 Series' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x175b' status untested url *none* comment `Testers needed!' model `PIXMA MX450 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1768' status untested url *none* comment `Testers needed!' model `PIXMA MX510 Series' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x175c' status untested url *none* comment `Testers needed!' model `PIXMA MX520 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1769' status untested url *none* comment `Testers needed!' model `PIXMA MX700' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1729' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 2400DPI)' model `PIXMA MX710 Series' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x175d' status untested url *none* comment `Testers needed!' model `PIXMA MX720 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x176a' status untested url *none* comment `Testers needed!' model `PIXMA MX850' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x172c' status complete url *none* comment `All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported.' model `PIXMA MX860' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1735' status complete url *none* comment `All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported.' model `PIXMA MX870' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1743' status complete url *none* comment `All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.' model `PIXMA MX880 Series' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1750' status complete url *none* comment `All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.' model `PIXMA MX882' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1750' status complete url *none* comment `All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.' model `PIXMA MX885' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x1750' status complete url *none* comment `All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.' model `PIXMA MX890 Series' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x175e' status complete url *none* comment `All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy.' model `PIXMA MX920 Series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x176b' status untested url *none* comment `Testers needed!' model `PIXMA MX7600' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x171c' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 4800DPI)' model `imageCLASS D420' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26ef' status complete url *none* comment `All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported.' model `imageCLASS D480' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26ed' status complete url *none* comment `All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported.' model `i-SENSYS MF3010' interface `USB Ethernet' usb-vendor-id `0x04a9' usb-product-id `0x2759' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `imageCLASS MF3110' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2660' status complete url *none* comment `All resolutions supported (up to 600DPI).' model `imageCLASS MF3240' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2684' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `imageCLASS MF4010' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26b4' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `imageCLASS MF4018' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26b4' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `imageCLASS MF4120' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26a3' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `imageCLASS MF4122' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26a3' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `imageCLASS MF4140' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26a3' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `imageCLASS MF4150' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26a3' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `imageCLASS MF4270' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26b5' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `I-SENSYS MF4320d' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26ee' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `I-SENSYS MF4330d' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26ee' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `imageCLASS MF4350d' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26ee' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `imageCLASS MF4370dn' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26ec' status good url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported' model `imageCLASS MF4380dn' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26ec' status good url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported' model `imageCLASS MF4410' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2737' status complete url *none* comment `All resolutions supported (up to 600DPI)' model `imageCLASS MF4430' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2737' status good url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI). ADF empty buggy.' model `i-SENSYS MF4550d' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2736' status good url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI).' model `imageCLASS MF4660' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26b0' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `imageCLASS MF4690' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26b0' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `imageCLASS MF5630' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x264e' status untested url *none* comment `Testers needed!' model `laserBase MF5650' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x264f' status untested url *none* comment `Testers needed!' model `imageCLASS MF5730' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x265d' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 1200DPI).' model `imageCLASS MF5750' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x265e' status untested url *none* comment `Testers needed!' model `imageCLASS MF5770' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x265f' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI).' model `i-SENSYS MF5880dn' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26f9' status untested url *none* comment `Testers needed!' model `imageCLASS MF6500 series' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2686' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `imageCLASS MF6550' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2686' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `i-SENSYS MF6680dn' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26fa' status untested url *none* comment `Testers needed!' model `imageCLASS MF8030' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2707' status untested url *none* comment `Testers needed!' model `imageCLASS MF8170c' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2659' status untested url *none* comment `Testers needed!' model `imageRUNNER 1020/1024/1025' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x26e6' status complete url *none* comment `Flatbed and ADF scan. All resolutions supported (up to 600DPI)' model `CanoScan 8800F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1901' status complete url *none* comment `Flatbed scan. TPU for negatives and slides. All resolutions supported (up to 4800DPI).' model `CanoScan 9000F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1908' status complete url *none* comment `Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI.' model `CanoScan 9000F Mark II' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x190d' status complete url *none* comment `Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI.' backend `plustek' version `0.52' manpage `sane-plustek' url `http://www.gjaeger.de/scanner/plustek/' comment *none* type scanner mfg `Plustek' url `http://www.plustek.de/' url `http://www.plustek.com/' comment *none* model `OpticPro U12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0010' status complete url *none* comment `NOTE: Devices with product ID 0x0001 are not supported!' model `OpticPro UT12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0013' status complete url *none* comment *none* model `OpticPro UT12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0017' status complete url *none* comment `Note: Devices with product ID 0x0001 are not supported!' model `OpticPro UT16' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0017' status complete url *none* comment *none* model `OpticPro U24' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0011' status complete url *none* comment *none* model `OpticPro U24' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0015' status complete url *none* comment *none* model `OpticPro UT24' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0017' status complete url *none* comment *none* mfg `Genius' url `http://www.geniusnet.com.tw/' comment *none* model `Colorpage HR6 V2' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2007' status complete url *none* comment *none* model `Colorpage HR6 V2' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2008' status complete url *none* comment *none* model `Colorpage HR7' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2013' status complete url *none* comment *none* model `Colorpage HR6A' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2009' status untested url *none* comment *none* model `Colorpage HR7LE' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2015' status untested url *none* comment *none* model `Colorpage HR6X' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2016' status untested url *none* comment *none* mfg `Mustek' url `http://www.mustek.com/' comment *none* model `BearPaw 1200' interface `USB' usb-vendor-id `0x0400' usb-product-id `0x1000' status complete url *none* comment `both product versions are supported, see backends' man-page' model `BearPaw 1200' interface `USB' usb-vendor-id `0x0400' usb-product-id `0x1001' status complete url *none* comment `both product versions are supported, see backends' man-page' model `BearPaw 2400' interface `USB' usb-vendor-id `0x0400' usb-product-id `0x1001' status complete url *none* comment *none* mfg `Hewlett-Packard' url `http://www.hp.com/' comment *none* model `ScanJet 2100C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0505' status complete url *none* comment *none* model `ScanJet 2200C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0605' status complete url *none* comment *none* mfg `Epson' url `http://www.epson.com/' comment *none* model `Perfection 1250' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010f' status complete url *none* comment *none* model `Perfection 1250Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x010f' status good url *none* comment `TPA scans not perfect' model `Perfection 1260' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011d' status complete url *none* comment *none* model `Perfection 1260Photo' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011d' status good url *none* comment `TPA scans not perfect' mfg `Umax' url `http://www.umax.com/' comment *none* model `UMAX 3400' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0050' status complete url *none* comment `there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x' model `UMAX 3400' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0060' status complete url *none* comment `there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x' model `UMAX Astranet ia101' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0060' status complete url *none* comment `seems to be a renamed UMAX 3400' model `UMAX 3450' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0060' status complete url *none* comment *none* model `UMAX 5400' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0160' status complete url *none* comment *none* mfg `Compaq' url `http://www.compaq.com/' comment *none* model `S4-100' interface `USB' usb-vendor-id `0x049f' usb-product-id `0x001a' status complete url *none* comment `Identical to UMAX 3400' mfg `Canon' url `http://www.canon.com/' comment *none* model `CanoScan N650U/N656U' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2206' status complete url *none* comment *none* model `CanoScan N1220U' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2207' status complete url *none* comment *none* model `CanoScan N670U/N676U/LiDE20' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x220d' status complete url *none* comment *none* model `CanoScan N1240U/LiDE30' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x220e' status complete url *none* comment *none* model `CanoScan LiDE25' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2220' status good url *none* comment *none* model `CanoScan D660U' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2208' status good url *none* comment `TPA scans not perfect' mfg `Syscan' url `http://www.syscaninc.com/' comment *none* model `TravelScan 460/464' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x4600' status complete url *none* comment *none* model `TravelScan 662' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x6620' status complete url *none* comment *none* mfg `Ambir' url *none* comment *none* model `Visigo A4' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x4600' status complete url *none* comment `Rebaged Travelscan 464' mfg `Portable Peripheral Co., Ltd.' url `http://www.pandp.com.tw/' comment *none* model `Q-Scan USB001 (A4 portable scanner)' interface `USB' usb-vendor-id `0x0a53' usb-product-id `0x1000' status complete url *none* comment *none* model `Q-Scan USB201 (A6 portable scanner)' interface `USB' usb-vendor-id `0x0a53' usb-product-id `0x2000' status good url *none* comment *none* mfg `Visioneer' url `http://www.visioneer.com/' comment *none* model `Strobe XP 100' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0427' status basic url *none* comment *none* backend `plustek_pp' version `0.43' manpage `sane-plustek_pp' url `http://www.gjaeger.de/scanner/plustek_pp/' comment *none* type scanner mfg `Plustek' url `http://www.plustek.de/' url `http://www.plustek.com/' comment *none* model `OpticPro 4800P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro 4830P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro 600P/6000P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro 4831P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro 9630P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro 9630PL' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `use driver-switch mov=1' model `OpticPro 9600P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro 1236P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `reported as OpticPro 12000P/96000P' model `OpticPro 12000P/96000P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro 9636P' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `use driver-switch mov=4' model `OpticPro 9636P+/Turbo' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `use driver-switch mov=3' model `OpticPro 9636T' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro 12000T' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro AI3' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `use driver-switch mov=5, poor picture quality' model `OpticPro P8' interface `Parport' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* model `OpticPro P12' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* model `OpticPro PT12' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment *none* mfg `Primax' url `http://www.primax.nl/' comment *none* model `Colorado 4800' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `same as OpticPro 4800P' model `Compact 4800 Direct' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `use driver-switch mov=2' model `Compact 4800 Direct-30' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `same as OpticPro 4830P, use driver-switch mov=7' model `Compact 9600 Direct-30' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `same as OpticPro 9630P' mfg `Genius' url `http://www.geniusnet.com.tw/' comment *none* model `Colorpage Vivid III V2' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Reported as PT12' model `Colorpage Vivid Pro II Film' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Reported as OP9636T/12000T' model `Colorpage HR6X EPP' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Negative scanning does not work correctly' mfg `Aries' url *none* comment *none* model `Scan-It Pro 4800' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `use driver-switch mov=2' mfg `BrightScan' url *none* comment *none* model `BrighScan OpticPro' interface `Parport (SPP, EPP)' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `Reported as P12' backend `pnm' version `1.0.8' manpage `sane-pnm' url `mailto:henning@meier-geinitz.de' comment *none* type api desc `Reads PNM files' url *none* comment `Used for debugging frontends. Obsolete, use test backend instead.' backend `qcam' version `unmaintained' manpage `sane-qcam' url *none* comment *none* type vidcam mfg `Connectix' url *none* comment *none* model `Color QuickCam' interface `Parport' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Requires root privileges.' model `Greyscale QuickCam' interface `Parport' usb-vendor-id *none* usb-product-id *none* status minimal url *none* comment `Requires root privileges. Partly working.' backend `ricoh' version `unmaintained' manpage `sane-ricoh' url *none* comment *none* type scanner mfg `Ricoh' url `http://www.ricoh.com/' comment *none* model `Ricoh IS50' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `Ricoh IS60' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* backend `rts8891' version `1.0-0' manpage `sane-rts8891' url `http://stef.dev.free.fr/sane/rts8891/index.html' comment `This backend supports Realtek RTS8891 ASIC bases scanners.' type scanner mfg `UMAX' url `http://www.umax.com.tw/' comment *none* model `Astra 4400' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0070' status good url *none* comment `Supports 75, 150, 300, 600 and 1200 dpi' model `Astra 4450' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0070' status untested url *none* comment *none* mfg `Hewlett-Packard' url `http://www.hp.com/' comment *none* model `scanjet 4470c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0805' status good url *none* comment `re-branded Astra 4400' model `scanjet 4400c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0705' status good url *none* comment `exists with 2 different sensors of which only one works' backend `s9036' version `unmaintained' manpage `sane-s9036' url *none* comment *none* type scanner mfg `Siemens' url `http://www.siemens.com/' comment *none* model `9036 Flatbed scanner' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* backend `sceptre' version `1.0-10' manpage `sane-sceptre' url `http://www.zago.net/sane/' comment *none* type scanner mfg `Sceptre' url `http://www.sceptre.com/' comment *none* model `Vividscan S1200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* mfg `Komodo' url `http://www.komodo.com/' comment *none* model `S1200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `rebadged Sceptre S1200' backend `sharp' version `0.32' manpage `sane-sharp' url `http://www.satzbau-gmbh.de/staff/abel/sane-sharp.html' comment *none* type scanner mfg `Sharp' url `http://sharp-world.com/' comment *none* model `JX-610' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `' model `JX-250' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `' model `JX-320' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `' model `JX-325' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `' model `JX-330' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `' model `JX-350' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `' backend `sm3600' version `0.1' manpage `sane-sm3600' url `http://sm3600.sourceforge.net/' comment *none* type scanner mfg `Microtek' url `http://www.microtek.com/' comment *none* model `ScanMaker 3600' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x40b3' status basic url *none* comment `works' model `ScanMaker 3600' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x40ca' status basic url *none* comment `works' model `ScanMaker 3600' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x40ff' status basic url *none* comment `works' model `ScanMaker 3700' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x40b8' status basic url *none* comment `works' model `ScanMaker 3700' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x40cb' status basic url *none* comment `works' model `ScanMaker 3750' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x40dd' status basic url *none* comment `works (told)' backend `sm3840' version `1.1' manpage `sane-sm3840' url `http://www.ziplabel.com/sm3840/' comment `This reverse-engineered backend supports the USB ScanMaker 3840 model' type scanner mfg `Microtek' url `http://www.microtek.com/' comment `Microtek makes a wide variety of devices.' model `ScanMaker 3840' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30d4' status good url *none* comment `8 and 16 bit, color and grayscale' model `ScanMaker 4800' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30cf' status good url *none* comment `Same hardware as SM3840, different color box' backend `SnapScan' version `1.4' manpage `sane-snapscan' url `http://snapscan.sourceforge.net/' comment `Supported bit depths: 24 bit (color), 48 bit (color, Epson) 8 bit (gray)' type scanner mfg `AGFA' url `http://www.agfa.com/' comment *none* model `SnapScan' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `SnapScan 300' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `SnapScan 310' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `SnapScan 600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Optional ADF supported.' model `Arcus 1200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Optional transparency unit supported.' model `SnapScan 1236s' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Optional ADF and transparency unit supported.' model `SnapScan 1236u' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x0002' status good url *none* comment `Optional ADF and transparency unit supported.' model `SnapScan 1212U' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x0001' status good url *none* comment *none* model `SnapScan 1212U_2' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x2061' status good url *none* comment *none* model `SnapScan e10' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x2093' status good url *none* comment *none* model `SnapScan e20' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x2091' status good url *none* comment *none* model `SnapScan e25' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x2095' status good url *none* comment *none* model `SnapScan e26' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x2097' status good url *none* comment *none* model `SnapScan e40' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x208d' status good url *none* comment *none* model `SnapScan e42' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x20ff' status good url *none* comment *none* model `SnapScan e50' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x208f' status good url *none* comment `Optional tranparency unit supported' model `SnapScan e52' interface `USB' usb-vendor-id `0x06bd' usb-product-id `0x20fd' status good url *none* comment `Optional tranparency unit supported' model `SnapScan e60' interface `USB' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment *none* mfg `Acer Peripherals' url *none* comment `Company was renamed to Benq.' model *none* mfg `Vuego' url *none* comment `Company was renamed to Benq.' model *none* mfg `Benq (Acer)' url `http://www.benq.com' comment `Formerly Acer Peripherals' model `300f' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `310s' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `610s' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `610plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `620s' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ScanWit 2720s' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `310U' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x1a20' status good url *none* comment *none* model `320U' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2022' status good url *none* comment *none* model `340U' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2022' status good url *none* comment *none* model `620U' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x1a2a' status good url *none* comment `Optional tranparency unit supported' model `620UT' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2040' status good url *none* comment `Optional tranparency unit supported' model `640U' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2060' status good url *none* comment `Optional tranparency unit supported' model `640bu' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x207e' status good url *none* comment *none* model `640BT' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20be' status good url *none* comment `Optional tranparency unit supported' model `1240' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20c0' status good url *none* comment `Optional tranparency unit supported' model `3300' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20b0' status good url *none* comment *none* model `3300' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20de' status good url *none* comment *none* model `4300' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20b0' status good url *none* comment *none* model `4300' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20de' status good url *none* comment *none* model `5000E' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20fc' status basic url *none* comment `Same as 5000U, working up to 600 DPI' model `5000U' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20fc' status basic url *none* comment `Same as 5000E, working up to 600 DPI' model `5000' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20f8' status good url *none* comment `USB ID 0x04a5,0x20f8: Color / grayscale scans working up to 1200 DPI' model `5150' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2137' status basic url *none* comment `Calibration algorithm unknown' model `5250' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2137' status basic url *none* comment `Same hardware as 5150 (?), Calibration algorithm unknown' model `5300' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20fe' status basic url *none* comment `Problems with firmware upload reported' mfg `Guillemot / Hercules' url `http://www.guillemot.com' comment *none* model `Maxi Scan A4 Deluxe (SCSI)' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Rebadged SnapScan 310s.' model `Scan@home Touch 1248 (USB)' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20de' status good url *none* comment `Rebadged Benq 3300.' model `Maxi Scan A4 USB 640U' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2060' status good url *none* comment `Rebadged Benq 640U.' model `Maxi A4 36 bit' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2060' status good url *none* comment `Rebadged Benq 620U, needs Benq firmware file u96v???.bin' mfg `Mitsubishi' url `http://www.mitsubishi.com' comment *none* model `Diamondview 648UT' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2022' status good url *none* comment `Rebadged Benq 320u.' model `Diamondview 650U' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x20b0' status good url *none* comment `Rebadged Benq 4300.' mfg `Epson' url `http://www.epson.com' comment *none* model `Perfection 660' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0114' status good url *none* comment *none* model `Perfection 1270' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0120' status good url *none* comment *none* model `Perfection 1670' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x011f' status good url *none* comment *none* model `Perfection 2480' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0121' status good url *none* comment *none* model `Perfection 2580' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0121' status basic url *none* comment `Film scanning unit unsupported' model `Perfection 3490' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0122' status good url *none* comment *none* model `Perfection 3590' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0122' status basic url *none* comment `Film scanning unit unsupported' model `Stylus CX-1500' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x080c' status good url *none* comment *none* backend `sp15c' version `unmaintained' manpage `sane-sp15c' url *none* comment *none* type scanner mfg `Fujitsu' url `http://www.fcpa.fujitsu.com/products/scanners/' url `http://www.fujitsu.com/' comment *none* model `ScanPartner 15C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `ScanPartner 600C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* backend `st400' version `1.6' manpage `sane-st400' url `http://www.informatik.uni-oldenburg.de/~ingo/sane/' comment *none* type scanner mfg `Siemens' url `http://www.siemens.de/' comment *none* model `ST400' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `6 bit gray' model `ST800' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `6 bit gray' backend `stv680' version `1.0-1' manpage `sane-stv680' url `http://gkall.hobby.nl/stv680-aiptek.html' comment `This vidcam backend is for the stv0680 chipset, See the website for more info.' type vidcam mfg `Aiptek' url `http://www.aiptek.com.tw' comment *none* model `Aiptek Pencam' interface `USB' usb-vendor-id `0x0553' usb-product-id `0x0202' status minimal url *none* comment `image is OK for CIF and QCIF, VGA and QVGA untested, streaming video is a problem' mfg `Konica' url `http://www.konicaminolta.com' comment *none* model `e-mini' interface `USB' usb-vendor-id `0x04c8' usb-product-id `0x0722' status untested url *none* comment ` ' mfg `Digital Dream' url `http://www.digitaldreamco.com/en/index.shtml' comment *none* model `l' espion XS' interface `USB' usb-vendor-id `0x1183' usb-product-id `0x0001' status untested url *none* comment ` ' mfg `Creative' url `http://www.creative.com/' comment *none* model `WebCam Go Mini' interface `USB' usb-vendor-id `0x041e' usb-product-id `0x4007' status untested url *none* comment ` ' backend `tamarack' version `unmaintained' manpage `sane-tamarack' url *none* comment *none* type scanner mfg `Tamarack' url *none* comment *none* model `Artiscan 6000C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3 pass, 300 DPI' model `Artiscan 8000C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3 pass, 400 DPI' model `Artiscan 12000C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `3 pass, 600 DPI' backend `teco1' version `1.0-10' manpage `sane-teco1' url `http://www.zago.net/sane/#teco' comment *none* type scanner mfg `Relisys' url `http://www.relisys.com/' url `http://www.tecoimage.com.tw/' comment *none* model `RELI 2412' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `sub model VM3530+' model `AVEC 2400' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `sub model VM3520' model `RELI 4830' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM4542' model `AVEC 2412' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `sub model VM3520+' model `AVEC 4800' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM4530' model `AVEC 4816' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM4530+' model `RELI DS6' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3420' model `RELI DS15' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3440' model `RELI 2400' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3530' model `RELI 4816' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status complete url *none* comment `sub model VM4540' model `RELI 9600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM6530' model `RELI 9612' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM6530*' model `RELI 9624' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM6530+' model `RELI 9630' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM6540' mfg `Actown' url *none* comment *none* model `ACT Scan I 30' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3520A' mfg `Dextra' url *none* comment *none* model `DF-600P' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM3510' model `DF-1200T+' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3530+' model `DF-4830T' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM4542' model `DF-9624' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM6530+' backend `teco2' version `1.0-9' manpage `sane-teco2' url `http://gkall.hobby.nl/teco2.html' comment *none* type scanner mfg `Relisys' url `http://www.relisys.com/' comment *none* model `AVEC Super 3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3575' model `AVEC II S3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM3564' model `SCORPIO Super 3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM3575' model `APOLLO Express 3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `sub model VM356A' model `APOLLO Express 6' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM6565' model `SCORPIO Pro' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM6575' model `SCORPIO Pro-S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM6586' mfg `Primax' url `http://www.primax.nl/' comment *none* model `Jewel 4800' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM356A' model `Profi 9600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment `sub model VM6575' model `Profi 19200' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM6586' mfg `Mustek' url `http://www.mustek.com/' comment *none* model `ScanMagic 4830S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3575' backend `teco3' version `1.0-1' manpage `sane-teco3' url `http://www.zago.net/sane/#teco3' comment *none* type scanner mfg `Relisys' url `http://www.tecoimage.com.tw/' comment *none* model `Infinity Scorpio' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM3552' mfg `Plustek' url *none* comment *none* model `OpticPro 2400SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3552' mfg `PIOTECH' url `http://www.image-land.com/' comment *none* model `Splendeur 3024' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM3552' mfg `Trust' url *none* comment *none* model `Imagery 2400 SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM3552' model `Imagery 4800 SP+' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `sub model VM3552' model `Imagery 9600 SP' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `sub model VM3552' backend `test' version `1.0-28' manpage `sane-test' url `http://www.meier-geinitz.de/sane/test-backend/' comment *none* type api desc `Frontend-tester' url *none* comment `Backend for testing frontends. Also serves as example for SANE backend options.' backend `u12' version `0.02' manpage `sane-u12' url `http://www.gjaeger.de/scanner/u12/' comment *none* type scanner mfg `Plustek' url `http://www.plustek.de/' url `http://www.plustek.com/' comment *none* model `OpticPro U12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0001' status basic url *none* comment `Note: Only devices with product ID 0x0001 are supported!' model `OpticPro UT12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0001' status basic url *none* comment `Note: Only devices with product ID 0x0001 are supported!' model `OpticPro 1212U' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0001' status basic url *none* comment *none* mfg `RevScan' url *none* comment *none* model `RevScan Orange R48Ti' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0001' status basic url *none* comment `Rebadged Plustek OpticPro UT12' mfg `Genius' url `http://www.geniusnet.com.tw/' comment *none* model `ColorPage HR6 V1' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2004' status basic url *none* comment *none* model `ColorPage Vivid III USB' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0001' status untested url *none* comment `Note: Device has Plustek vendor and product ID (0x07b3/0x0001)' backend `umax' version `1.0-41' manpage `sane-umax' url `http://www.rauch-domain.de/sane-umax/index.html' comment *none* type scanner mfg `UMAX' url `http://www.umax.com/' url `http://www.umax.com.tw/' url `http://www.umax.de/en' url `http://www.umax-europe.com' url `http://www.umaxjapan.co.jp' url `http://www.umax.com.cn' comment *none* model `Vista S6' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Vista S6E' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `UMAX S-6E' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `UMAX S-6EG' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Vista-S8' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Supervista S-12' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `UMAX S-12' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `UMAX S-12G' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra 600S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra 610S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra 1200S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra 1220S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra 2100S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra 2200 (SU)' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra 2200 (SU)' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0230' status good url *none* comment `OK, needs USB control messages' model `Astra 2400S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra 6400' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `will probably work one day' model `Astra 6450' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `will probably work one day' model `Astra MX3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Astra MX3' interface `USB' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, needs USB control messages' model `Mirage D-16L' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Mirage II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Mirage IIse' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `PSD' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `PowerLook' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=PS-2400X' model `PL-II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `PowerLook III' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `PowerLook 270' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `incompatible' model `PowerLook 270plus' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `incompatible' model `PowerLook 1100' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `will probably work one day' model `PowerLook 2000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `PowerLook 2100XL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `PowerLook 3000' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `Gemini D-16' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `UMAX VT600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `may work, please test and give feedback' model `Vista-T630' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK for some firmwareversions, on others only lineart OK' model `UC 630' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Version 2.8 OK, others only lineart OK' model `UG 630' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `UG 80' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' model `UC 840' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Version 1.6 OK, others only lineart OK' model `UC 1200S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `may work, please test and give feedback' model `UC 1200SE' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Version 3.0 OK, others unknown' model `UC 1260' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `Version 1.6 OK, others unknown' mfg `Linotype Hell' url `http://www.heidelberg.com/' comment *none* model `Jade' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=LinoHell Office' model `Jade' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=LinoHell JADE' model `Jade2' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=LinoHell Office2' model `Saphir' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `support disabled until tested - please contact author' model `Saphir2' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=LinoHell SAPHIR2' model `Saphir3' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=LinoHell SAPHIR3' model `Saphir Ultra' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `support disabled until tested - please contact author' model `Saphir Ultra II' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=Linotype SAPHIR4' model `Saphir HiRes' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `support disabled until tested - please contact author' model `Opal' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `support disabled until tested - please contact author' model `Opal2' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK; SCSI-ID=LinoHell OPAL2' model `Opal Ultra' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `support disabled until tested - please contact author' model `Linoscan 1400' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=HDM LS4H1S' mfg `Vobis' url `http://www.vobis.de/' comment *none* model `Highscreen Scanboostar Premium' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=LinoHell Office2' mfg `EDGE' url *none* comment *none* model `KTX-9600US' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `no feedback' mfg `Epson' url `http://www.epson.com/' comment *none* model `Perfection 600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=EPSON Perfection600' mfg `Escom' url *none* comment *none* model `Image Scanner 256' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=UMAX UG 80' mfg `Escort' url *none* comment *none* model `Galleria 600' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `untested, SCSI-ID=ESCORT Galleria 600S' mfg `Genius' url *none* comment *none* model `ColorPage-HR5 (Pro)' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK, SCSI-ID=KYE ColorPage-HR5' mfg `Nikon' url `http://www.nikon.com/' comment *none* model `AX-110 / Scantouch 110' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status untested url *none* comment `may work, please test and give feedback' model `AX-210' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' mfg `TriGem' url `http://www.nikon.com/' comment *none* model `PowerScanII' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `OK' backend `umax1220u' version `unmaintained' manpage `sane-umax1220u' url `http://sourceforge.net/projects/umax1220u-sane' comment *none* type scanner mfg `UMAX' url `http://www.umax.com/' comment *none* model `Astra 1220U' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0010' status good url *none* comment *none* model `Astra 1600U' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0030' status good url *none* comment *none* model `Astra 2000U' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0030' status good url *none* comment *none* model `Astra 2100U' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x0130' status good url *none* comment *none* backend `umax_pp' version `1' manpage `sane-umax_pp' url `http://umax1220p.sourceforge.net/' comment *none* type scanner mfg `UMAX' url `http://www.umax.com.tw/' comment *none* model `Astra 1220P' interface `Parport (EPP/ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Astra 2000P' interface `Parport (EPP/ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Astra 1600P' interface `Parport (EPP/ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* model `Astra 600P' interface `Parport (SPP/ECP)' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `untested, but should be close to 610P' model `Astra 610P' interface `Parport (SPP/ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment *none* mfg `Hewlett-Packard' url *none* comment *none* model `Scanjet 3200C' interface `Parport (EPP/ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `works (relabelled 1220P and 2000P)' mfg `Genius' url *none* comment *none* model `ColorPage-Life Pro' interface `Parport (EPP/ECP)' usb-vendor-id *none* usb-product-id *none* status good url *none* comment `works (relabelled 1220P and 2000P)' backend `unsupported' version `2010-06-09' manpage *none* url `contrib.html' comment `The devices mentioned here are not supported by any SANE backend. However, there may be links to information about them or stand-alone programs.' type scanner mfg `Agfa' url *none* comment *none* model `DuoScan f40' interface `USB IEEE-1394' usb-vendor-id `0x06bd' usb-product-id `0x02bf' status unsupported url `unsupported/agfa-duoscan-f40.html' comment `Unsupported. See link for details.' model `DuoScan T2000XL' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/agfa-duoscan-t2000xl.html' comment `Unsupported. Same as Microtek ArtixScan 2020?' model `DuoScan T2500' interface `SCSI IEEE-1384' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Unsupported. Same as Microtek Artixscan 2500f' model `SnapScan 310P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `SnapScan EZ' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `SnapScan 1200P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `SnapScan 1212P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' mfg `Artec/Ultima' url `http://www.artecusa.com/' comment *none* model `1236 USB' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4001' status unsupported url `unsupported/artec_1236usb.html' comment `Unsupported. See link for details.' model `AM12e+' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Unsupported. Chips found inside: AT015, AD9816JS. Maybe similar to SCSI version or as6e?' model `Ultima 2000 (0x4001)' interface `USB' usb-vendor-id `0x05d8' usb-product-id `0x4001' status unsupported url `unsupported/artec-ultima-2000-2.html' comment `Same name, but different ids: This scanner is not supported. The scanner with product id 0x4002 is supported by the gt68xx backend, however.' mfg `Avigramm' url *none* comment *none* model `Minidoc' interface `USB Parport' usb-vendor-id `0x05cb' usb-product-id `0x1483' status unsupported url `unsupported/trust-combiscan-19200.html' comment `Not supported. See link for details.' mfg `Avision' url `http://www.avision.com/' comment *none* model `DS310F' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. Scanner/printer/copier combination.' model `iVina FB2400' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Not supported. No chipset information available. Same as UMAX Astra 6700.' model `iVina 1600' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a10' status unsupported url `unsupported/umax-astra-4500.html' comment `GL646 based, to be added to genesys backend. Same as UMAX Astra 4500.' model `iVina FB1800' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a20' status unsupported url `unsupported/umax-astra-4700.html' comment `GL646/GL660 based. Same as UMAX Astra 4700.' mfg `Benq (Acer)' url `http://www.benq.com' comment `Formerly Acer Peripherals' model `310P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `320P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `340P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `610P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `610PT' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `620P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `620PT' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `640P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/acer-parport.html' comment `Unsupported, see link for details.' model `5450' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x211e' status unsupported url *none* comment `Unsupported.' model `5550' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2211' status unsupported url `unsupported/benq-5550.html' comment `Unsupported, see link for details.' model `5560' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2311' status unsupported url `http://alioth-lists.debian.net/pipermail/sane-devel/2009-January/023447.html' comment *none* model `7400UT' interface `USB' usb-vendor-id `0x04a5' usb-product-id `0x2202' status unsupported url `unsupported/benq-7400ut.html' comment *none* mfg `Boeder' url *none* comment *none* model `Sm@rtScan Office' interface `Parport USB' usb-vendor-id `0x05cb' usb-product-id `0x1483' status unsupported url `unsupported/trust-combiscan-19200.html' comment `Unsupported. See link for details.' mfg `Brother' url `http://www.brother.com/' comment *none* model `MFC 2500' interface `USB' usb-vendor-id `0x04f9' usb-product-id `0x000a' status unsupported url `unsupported/brother-mfc-2500.html' comment `Not supported. See link for details.' model `MFC 4600' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://sourceforge.net/projects/brother-mfc' comment `The parport 200x400dpi grayscale version of this scanner is unsupported. Dmitri Katchalov did some investigations on this scanner. If you want to write a backend, contact him (see link).' model `MFC 7300c' interface `Parport USB' usb-vendor-id `0x04f9' usb-product-id `0x0106' status unsupported url `unsupported/brother-mfc-7300.html' comment *none* model `MFC 9600' interface `USB' usb-vendor-id `0x04f9' usb-product-id `0x0101' status unsupported url `unsupported/brother-mfc-9600.html' comment *none* mfg `C-Channel' url `http://www.c-channel.ch/' comment *none* model `MyPen Pro' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/c-channel-mypen-pro.html' comment `Probably unsupported. See link for details.' model `MyPen Light' interface `USB' usb-vendor-id `0x0a93' usb-product-id `0x0005' status unsupported url *none* comment `See bug #306792 for details.' model `MoneyPen II' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably unsupported.' mfg `Canon' url `http://www.canon.com/' comment *none* model `CanoScan 3000' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2215' status unsupported url `unsupported/canon-3000.html' comment `GL660+GL646 based.' model `CanoScan 3000ex' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2215' status unsupported url `unsupported/canon-3000.html' comment `GL660+GL646 based.' model `CanoScan 3000F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2215' status unsupported url `unsupported/canon-3000.html' comment `GL660+GL646 based, to be added to genesys backend' model `CanoScan 4200F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x221b' status unsupported url `unsupported/canon-4200f.html' comment `Probably unsupported. See link.' model `CanoScan 4400F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2228' status unsupported url `unsupported/canon-4400.html' comment `GL843 based, to be added to genesys backend' model `CanoScan 5000F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2212' status unsupported url `unsupported/canon-5000f.html' comment `Unsupported. See link for details.' model `CanoScan 5200F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2217' status unsupported url `unsupported/canon-5200f.html' comment `Probably unsupported. See link for details.' model `CanoScan 8000F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x220f' status unsupported url `unsupported/canon-8000f.html' comment `Not supported. See link for more information. With transparency adapter.' model `CanoScan 8400F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x221e' status unsupported url `unsupported/canon-8400f.html' comment `GL841 based, to be added to genesys backend' model `CanoScan 8600F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2229' status unsupported url `unsupported/canon-8600.html' comment `GL841 based, to be added to genesys backend' model `CanoScan 9900F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2210' status unsupported url `unsupported/canon-9900f.html' comment `Probably unsupported, similar to 8000F. 3200x6400 dpi USB2. With transparency adapter.' model `CanoScan 9950F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2219' status unsupported url `unsupported/canon-9950f.html' comment `Probably unsupported.' model `CanoScan D646U' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x220b' status unsupported url `unsupported/canon-d646u.html' comment `Probably not supported. See link for more information and test program.' model `CanoScan D646U ex' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x220b' status unsupported url `unsupported/canon-d646u.html' comment `Probably not supported. See D646.' model `CanoScan D1230U' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2209' status unsupported url `unsupported/canon-d1230u.html' comment `Probably not supported. ' model `CanoScan D1250U2' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x220c' status unsupported url `unsupported/canon-d1250u2.html' comment `Not supported. However, someone started working on this scanner and some information is available (see link).' model `CanoScan D2400UF' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x220a' status unsupported url `unsupported/canon-d2400uf.html' comment `Not supported. See link.' model `CanoScan FB320U' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2201' status unsupported url *none* comment `Probably not supported. No details known.' model `CanoScan FB620U' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2202' status unsupported url `unsupported/canon-fb620u.html' comment `Probably not supported. Some information is available.' model `CanoScan FB1210U' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2205' status unsupported url `http://sourceforge.net/projects/canonscanner/' comment `Not supported. However, a stand-alone program for FreeBSD is available.' model `CanoScan LiDE 70' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2225' status unsupported url `http://www.juergen-ernst.de/info_sane.html' comment `Philips chip. Backend started, see link' model `CanoScan LiDE 80' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2214' status unsupported url `unsupported/canon-lide-80.html' comment `GL841 based, to be added to genesys backend' model `CanoScan LiDE 90' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1900' status unsupported url `unsupported/canon-lide-90.html' comment `Unsupported. See link for details.' model `CanoScan LiDE 500F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x221f' status unsupported url `unsupported/canon-canoscan-lide-500f.html' comment `GL841 based, to be added to genesys backend' model `CanoScan LiDE 600' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2224' status unsupported url `http://www.juergen-ernst.de/info_sane.html' comment `Philips chip. Backend started, see link' model `CanoScan LiDE 600F' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x2224' status unsupported url `http://www.juergen-ernst.de/info_sane.html' comment `Philips chip. Backend started, see link' model `FS4000' interface `USB SCSI' usb-vendor-id `0x04a9' usb-product-id `0x3042' status unsupported url `unsupported/canon-fs4000.html' comment `Not supported. See link for more details.' model `IS 12' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/canon-is-12.html' comment `Probably not supported. Scanner cardridge for Canon inkjet printers.' model `IS 22' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/canon-is-22.html' comment `Probably not supported. Scanner cardridge for Canon inkjet printers.' model `IS 32' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x105d' status unsupported url `unsupported/canon-is-32.html' comment `Probably not supported. Scanner cardridge for Canon inkjet printers.' model `IS 52' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/canon-is-52.html' comment `Probably not supported. Scanner cardridge for Canon inkjet printers.' model `ImageRunner iR1018' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x269d' status unsupported url `unsupported/canon-imagerunner.html' comment `Probably not supported. See link for details.' model `ImageRunner iR1022' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x269d' status unsupported url `unsupported/canon-imagerunner.html' comment `Probably not supported. See link for details.' model `ImageRunner iR1023' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x269d' status unsupported url `unsupported/canon-imagerunner.html' comment `Probably not supported. See link for details.' model `PIXMA MP110' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1700' status unsupported url `unsupported/canon-pixma-mp110.html' comment `Probably not supported. See link for details.' model `PIXMA MP130' interface `USB' usb-vendor-id `0x04a9' usb-product-id `0x1701' status unsupported url `unsupported/canon-pixma-mp130.html' comment `Probably not supported. See link for details.' model `DR-2020U' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `GL84x?' mfg `Chinon' url *none* comment *none* model `DS-3000' interface `Parport Serial Port' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/chinon-ds3000.html' comment `Unsupported at the moment, but a backend is in preparation. See link.' mfg `Compaq' url `http://www.compaq.com/' comment *none* model `S200' interface `USB' usb-vendor-id `0x049f' usb-product-id `0x0021' status unsupported url *none* comment `Not supported. 2400x1200 dpi. One bulk-in, one bulk-out and one interrupt endpoint. Type-number: U0001-HB21, another type nr on the inside: 75100512-00' mfg `Compeye' url *none* comment *none* model `Simplex 1236C' interface `Parport USB' usb-vendor-id `0x05cb' usb-product-id `0x1483' status unsupported url `unsupported/trust-combiscan-19200.html' comment `Unsupported. See link for details.' mfg `Corex' url `http://www.cardscan.com/' comment *none* model `Cardscan 500' interface `USB' usb-vendor-id `0x08f0' usb-product-id `0x0001' status unsupported url `unsupported/corex-cardscan-500.html' comment `Probably not supported. Businesscard reader.' model `Cardscan 700 C' interface `USB' usb-vendor-id `0x08f0' usb-product-id `0x0004' status unsupported url `unsupported/corex-cardscan-700.html' comment `Probably not supported.' mfg `Dell' url `http://www.dell.com/' comment *none* model `A940' interface `USB' usb-vendor-id `0x413c' usb-product-id `0x5106' status unsupported url *none* comment `Probably rebadged Lexmark X5150. May work with sane-lexmark? See bug #312130' model `A960' interface `USB' usb-vendor-id `0x413c' usb-product-id `0x5107' status unsupported url `unsupported/dell-a960.html' comment `Probably not supported. See link for details.' model `922' interface `USB' usb-vendor-id `0x413c' usb-product-id `0x5109' status unsupported url `unsupported/dell-922.html' comment `Probably not supported. See link for details.' mfg `Epson' url `http://www.epson.com/' comment *none* model `GT-2200' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0102' status unsupported url *none* comment `Probably unsupported. No details known.' model `StylusScan 2000' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x0105' status unsupported url *none* comment `Probably unsupported. No details known.' model `Stylus DX4450' interface `USB' usb-vendor-id `0x04b8' usb-product-id `0x083f' status unsupported url `unsupported/epson-stylus-dx4450.html' comment `Probably unsupported. See link for details.' model `Stylus CX-5800' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably unsupported at the moment. Not compatible to snapscan backend. It's not known if it may work with epson or epkowa backend.' mfg `EDT (Electronic Document Technology)' url `http://www.bizcardreader.com/' comment *none* model `BizCardReader 900C' interface `USB' usb-vendor-id `0x0a53' usb-product-id `0x5001' status unsupported url `unsupported/edt-900c.html' comment `Probably unsupported. See link for details.' mfg `E-Lux' url *none* comment `E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX' model `j-6121' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably unsupported. Sold 1998. Same as E-Lux j-6121.' mfg `Enhans' url *none* comment `E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX' model `j-6121' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably unsupported. Sold 1998. Same as E-Lux j-6121.' model `M-3630 A' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably unsupported. ' mfg `Genius' url `http://www.geniusnet.com.tw/' url `http://www.genius-kye.com/' comment *none* model `ColorPage CS' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/genius-colorpage-cs.html' comment `Probably unsupported, see link for details.' model `ColorPage-Slim 1200 USB2' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2020' status unsupported url `unsupported/genius-colorpage-slim-1200-usb2.html' comment `GL841 based, to be added to genesys backend.' model `ColorPage HR6X Slim' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2019' status unsupported url `unsupported/genius-colorpage-hr6x.html' comment `GL646 based, to be added to genesys backend' model `ColorPage HR7X' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x2018' status unsupported url `unsupported/genius-colorpage-hr7x.html' comment `GL646 based, to be added to genesys backend' model `ColorPage HR7XE' interface `USB' usb-vendor-id `0x06dc' usb-product-id `0x0012' status unsupported url `unsupported/genius-colorpage-hr7xe.html' comment `Unsuported. See link for details.' model `ColorPage HR8' interface `USB' usb-vendor-id `0x0458' usb-product-id `0x201c' status unsupported url `unsupported/genius-colorpage-hr8.html' comment `GL841 based, to be added to genesys backend' mfg `Guillemot' url *none* comment *none* model `SCAN@HOME 48 USB' interface `USB' usb-vendor-id `0x080d' usb-product-id `0x0102' status unsupported url `unsupported/teco-vm6509.html' comment `Probably unsupported. See link for details.' model `Maxi Scan A4 Parallel 36 bit' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably unsupported. Identical to the Benq Prisa 620P.' mfg `Hercules' url *none* comment *none* model `SCAN@HOME 48 USB' interface `USB' usb-vendor-id `0x080d' usb-product-id `0x0102' status unsupported url `unsupported/teco-vm6509.html' comment `Probably unsupported. See link for details.' mfg `Hewlett-Packard' url `http://www.hp.com/' comment *none* model `Photo Scanner 1000' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1001' status unsupported url `unsupported/hp-photo-1000.html' comment `Not supported by SANE. However, it's detected as mass storage device so just mounting it is reported to work. See link for device data.' model `Photosmart 1200 Photo' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported by SANE. No details known. 10x15 cm. Maybe similar to Photo Scanner 1000?' model `Photosmart S20 (C5101A)' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0102' status unsupported url `unsupported/hp-photosmart-s20xi.html' comment `Not supported yet by SANE. See link for details.' model `Photosmart S20xi (C7150A)' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0102' status unsupported url `unsupported/hp-photosmart-s20xi.html' comment `Not supported yet by SANE. See link for details.' model `Photosmart C5100 series' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x5811' status unsupported url `unsupported/hp-photosmart-5100.html' comment `Not supported yet by SANE. See link for details.' model `ScanJet 2400c' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x0a01' status unsupported url `unsupported/hp-scanjet-2400c.html' comment `GL646 based, to be added to genesys backend' model `Photosmart C3180' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x5611' status unsupported url `unsupported/hp-photosmart-3180.html' comment `Not supported yet by SANE. See link for details.' model `ScanJet 3770' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x2505' status unsupported url *none* comment `While an external binary-only backend exists, it works only on Linux i386. Therefore the scanner is unsupported on other platforms.' model `ScanJet 4600' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x3005' status unsupported url `unsupported/hp-scanjet-4600.html' comment `Not supported. See link for details, or http://www.chmil.org/hp4600linux/ for code' model `ScanJet 4670' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x3005' status unsupported url *none* comment `Not supported. See ScanJet 4600 entry.' model `ScanJet 4850C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1b05' status unsupported url `unsupported/hp-scanjet-4850.html' comment `GL841, maybe can be added to genesys backend ' model `ScanJet 4890C' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1b05' status unsupported url `unsupported/hp-scanjet-4850.html' comment `GL843, maybe can be added to genesys backend ' model `ScanJet 5530C Photosmart' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x1605' status unsupported url `unsupported/hp-scanjet-5530.html' comment `Maybe GL841_HP, but not confirmed, maybe can be added to genesys backend' model `ScanJet 8390' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x3805' status unsupported url `unsupported/hp-scanjet-8390.html' comment `Probably not supported. See link for details.' model `ScanJet G4000' interface `USB' usb-vendor-id `0x03f0' usb-product-id `0x4505' status unsupported url `unsupported/hp-g4000.html' comment `Probably not supported. See link for details.' mfg `IBM' url `http://www.ibm.com' comment *none* model `ADF Color Scanner' interface `Proprietary' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Unsupported. Uses proprietary ISA card. Maybe the same as the Plustek Spectra ADF?' mfg `IOMagic' url `http://www.iomagic.com/' comment *none* model `MobileScan USB' interface `USB Parport' usb-vendor-id `0x05cb' usb-product-id `0x1483' status unsupported url `unsupported/trust-combiscan-19200.html' comment `Unsupported. See link for details.' mfg `Iris' url `http://irislink.com/' comment *none* model `IriScan' interface `USB' usb-vendor-id `0x0a53' usb-product-id `0x1000' status unsupported url `unsupported/iris-iriscan.html' comment `Unsupported. LM9832/3. See link for details.' model `IRISPen Translator Executive' interface `USB' usb-vendor-id `0x0f43' usb-product-id `0x015a' status unsupported url `unsupported/iris-irispen-translator.html' comment `Unsupported. See link for details.' model `IRISCard Pro (IBCR II)' interface `USB' usb-vendor-id `0x0a38' usb-product-id `0x0301' status unsupported url `unsupported/iris-business.html' comment `Unsupported. See link for details.' mfg `Kodak' url `http://www.kodak.com' comment *none* model `Snapshot Photo Scanner 1' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Unsupported. FCC ID HWF96PHS' mfg `Lexmark' url `http://www.lexmark.com/' comment *none* model `P6250' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0097' status unsupported url `unsupported/lexmark-p6250.html' comment `Unsupported. See link for details.' model `Photo 3150' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x007d' status unsupported url `unsupported/lexmark-3150.html' comment `Unsupported. See link for details.' model `X74' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0060' status unsupported url `unsupported/lexmark-x75.html' comment `Unsupported. See link for details.' model `X75' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0060' status unsupported url `unsupported/lexmark-x75.html' comment `Unsupported. See link for details.' model `X75 PrinTrio' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0060' status unsupported url `unsupported/lexmark-x75.html' comment `Unsupported. See link for details.' model `X83' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x003d' status unsupported url `unsupported/lexmark-x83.html' comment `Unsupported. GL640.' model `X2330' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x00bb' status unsupported url `unsupported/lexmark-x2330.html' comment `Unsupported. See link for details.' model `X3450' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x00f6' status unsupported url `unsupported/lexmark-x3450.html' comment `Unsupported. See link for details.' model `X5130' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0065' status unsupported url `unsupported/lexmark-x5130.html' comment `Unsupported.' model `X5150' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0065' status unsupported url `unsupported/lexmark-x5130.html' comment `Probably unsupported. See link for details.' model `X5250' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0093' status unsupported url `unsupported/lexmark-x5250.html' comment `Unsupported.' model `X6170' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0072' status unsupported url `unsupported/lexmark-x6170.html' comment `Unsupported. See link for details.' model `X7170' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x0098' status unsupported url *none* comment `Unsupported. See bug #310889 for details.' model `X7350' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x00b8' status unsupported url `unsupported/lexmark-x7350.html' comment `Unsupported. See link for details.' model `X8350' interface `USB' usb-vendor-id `0x043d' usb-product-id `0x00b9' status unsupported url `unsupported/lexmark-x8350.html' comment `Unsupported. See link for details.' mfg `Logitech' url *none* comment *none* model `PageScan Color' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Most probably unsupported.' model `PageScan USB' interface `USB' usb-vendor-id `0x046d' usb-product-id `0x040f' status unsupported url `unsupported/logitech-pagescan-usb.html' comment `Probably unsupported. See link for details.' mfg `Medion/Lifetec/Tevion/Cytron' url `http://www.medion.com/' url `http://www.medion.de/' comment *none* model `MD 6190' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0392' status unsupported url `unsupported/medion-md6190.html' comment `Probably unsupported. There seem to exist two different scanners with that name. See link for details.' model `MD 6190' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x037b' status unsupported url `unsupported/medion-md6190.html' comment `Probably unsupported. There seem to exist two different scanners with that name. See link for details.' model `MD 40420' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x3008' status unsupported url `unsupported/tevion-md40420.html' comment `Probably unsupported. See link for details.' model `MD 41260' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x037b' status unsupported url `unsupported/medion-md6190.html' comment `Probably unsupported. See link for details.' model `MD 41985' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x037b' status unsupported url `unsupported/medion-md6190.html' comment `Probably unsupported. See link for details.' model `MD 42666' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x3008' status unsupported url `unsupported/tevion-md40420.html' comment `Probably unsupported. See link for details.' model `MD 85264' interface `USB' usb-vendor-id `0x08ff' usb-product-id `0x2580' status unsupported url `http://gkall.hobby.nl/authentec.html' comment `Fingerprint sensor. See link for details.' model `MD 90009' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30e5' status unsupported url `unsupported/tevion-md90009.html' comment `Probably unsupported. See link for details.' model `MD 90070' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x3022' status unsupported url `unsupported/tevion-md90070.html' comment `Unsupported. See link for details.' model `MD 90090' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x3022' status unsupported url `unsupported/tevion-md90070.html' comment `Unsupported. See link for details.' mfg `Memorex' url `http://www.memorex.com/' comment *none* model `6136u' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0346' status unsupported url `unsupported/memorex-maxx-6136u.html' comment `Probably unsupported.' model `6142u' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0347' status unsupported url `unsupported/visioneer-onetouch4400.html' comment `Probably unsupported. Same as Visioneer Onetouch 4400. See link for details.' model `MaxxScan 6122' interface `USB Parport' usb-vendor-id `0x05cb' usb-product-id `0x1483' status unsupported url `unsupported/trust-combiscan-19200.html' comment `Unsupported. See link for details.' model `SCF 9612P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/memorex-scf-9612p.html' comment `Probably unsupported. See link for details.' mfg `Microtek' url `http://www.microtek.com/' comment *none* model `ArtixScan 2020' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Unsupported. Same as Agfa DuoScan T2000XL?' model `ArtixScanDI 2020' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x202e' status unsupported url `unsupported/microtek-artixscan-2020.html' comment `Unsupported. See link for details.' model `Artixscan 2500f' interface `SCSI IEEE-1384' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Unsupported. Same as Agfa DuoScan T2500?' model `ArtixScan 4000tf' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Unsupported. Uses ALI M5611B.' model `FilmScan 35' interface `USB' usb-vendor-id `0x05e3' usb-product-id `0x0120' status unsupported url `unsupported/microtek-filmscan-35.html' comment `Probably unsupported. See link for details.' model `ScanMaker 336 CX' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably unsupported. Seems to be similar to the Microtek 330 CX and is detected by the microtek2 backend. Scanning doesn't seem to work however.' model `Scanmaker 1850S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/microtek-scanmaker-1850s.html' comment `Unsupported. See link for details.' model `ScanMaker 3630' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0347' status unsupported url `unsupported/microtek-scanmaker-3630.html' comment `Unsupported. Doesn't seem to be compatible to 3600 series, see link.' model `ScanMaker 3800' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30ce' status unsupported url `unsupported/microtek-scanmaker-3800.html' comment `Unsupported. See link for more details.' model `ScanMaker 3830' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30ce' status unsupported url `unsupported/microtek-scanmaker-3830.html' comment `Unsupported. See link for more details.' model `ScanMaker 3860' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x3023' status unsupported url `unsupported/microtek-scanmaker-3880.html' comment `Unsupported. See link for more details. Appears to be similar to ScanMaker 3880.' model `ScanMaker 3880' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x3021' status unsupported url `unsupported/microtek-scanmaker-3880.html' comment `Unsupported. SQ113 chip. See link for more details.' model `ScanMaker 4600' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x40c7' status unsupported url `unsupported/microtek-scanmaker-4600.html' comment `Unsupported. See link for more details.' model `ScanMaker 4700' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x20b4' status unsupported url `unsupported/microtek-scanmaker-4700.html' comment `Unsupported. See link for more details.' model `ScanMaker 4850' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30d9' status unsupported url `unsupported/microtek-scanmaker-4900.html' comment `Probably unsupported. See link for details.' model `ScanMaker 4850 II' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x3008' status unsupported url `unsupported/microtek-scanmaker-4850-2.html' comment `Probably unsupported. See link for details.' model `ScanMaker 4900' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30b9' status unsupported url `unsupported/microtek-scanmaker-4900.html' comment `Unsupported. See link for more details.' model `ScanMaker 5' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/microtek-scanmaker-5600.html' comment `Probably unsupported. See link for more details.' model `ScanMaker 5600' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x20a7' status unsupported url `unsupported/microtek-scanmaker-5600.html' comment `Unsupported. See link for more details.' model `ScanMaker 5700' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x20bd' status unsupported url *none* comment `Unsupported. Uses ALI M5615 like the ScanMaker 4700.' model `ScanMaker 5800' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x3008' status unsupported url `unsupported/microtek-scanmaker-5800.html' comment `Unsupported. See link for details.' model `ScanMaker 5800' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30d8' status unsupported url `unsupported/microtek-scanmaker-5800.html' comment `Unsupported. See link for details.' model `ScanMaker 5900' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30d8' status unsupported url `unsupported/microtek-scanmaker-5900.html' comment `Unsupported. See link for more details.' model `ScanMaker 5950' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30d8' status unsupported url `unsupported/microtek-scanmaker-5950.html' comment `Unsupported. See link for more details.' model `ScanMaker 6000' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30e5' status unsupported url `unsupported/microtek-scanmaker-6000.html' comment `Unsupported. See link for more details.' model `ScanMaker 6100' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30e5' status unsupported url `unsupported/microtek-scanmaker-6100.html' comment `Unsupported. See link for more details.' model `ScanMaker 6700' interface `USB IEEE-1394' usb-vendor-id `0x05da' usb-product-id `0x20c9' status unsupported url `unsupported/microtek-scanmaker-6700.html' comment `Unsupported. See link.' model `ScanMaker 8700' interface `USB IEEE-1394' usb-vendor-id `0x05da' usb-product-id `0x20b1' status unsupported url `unsupported/microtek-scanmaker-8700.html' comment `Unsupported. See link for details. USB vendor and product ids to be checked.' model `ScanMaker 9600XL' interface `USB IEEE-1394' usb-vendor-id `0x05da' usb-product-id `0x20de' status unsupported url *none* comment `Probably unsupported. SCSI seems to work with microtek2 backend.' model `ScanMaker 9800XL' interface `USB SCSI' usb-vendor-id `0x05da' usb-product-id `0x20de' status unsupported url `unsupported/microtek-scanmaker-9800.html' comment `Partly unsupported. IEEE-1394 works with microtek2 backend. See link.' model `ScanMaker i320' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x30e6' status unsupported url `unsupported/microtek-scanmaker-i320.html' comment `Unsupported. See link.' model `ScanMaker s400' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x201c' status unsupported url `unsupported/microtek-scanmaker-s400.html' comment `Unsupported. See link.' model `ScanMaker S400' interface `USB' usb-vendor-id `0x05da' usb-product-id `0x300b' status unsupported url `unsupported/microtek-scanmaker-s400.html' comment `Unsupported. See link.' model `ScanPort 3000' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0224' status unsupported url `unsupported/microtek-scanport-3000.html' comment `Unsupported. Vendor/Product ids: 0x04a7/0x0224. Realtek RTS8801B?. See link for details.' mfg `Konica Minolta' url `http://www.konicaminolta.com/' comment *none* model `Dual Scan III' interface `USB' usb-vendor-id `0x0686' usb-product-id `0x400d' status unsupported url `unsupported/minolta-dual-scan-III.html' comment `Unsupported. May work with vuescan. See link for details.' model `Dual Scan IV' interface `USB' usb-vendor-id `0x132b' usb-product-id `0x000a' status unsupported url `unsupported/minolta-dual-scan-IV.html' comment `Unsupported. Works with vuescan. See link for details.' model `DiMAGE Scan Elite 5400' interface `USB IEEE-1394' usb-vendor-id `0x0686' usb-product-id `0x400e' status unsupported url `unsupported/minolta-dse-5400.html' comment `Probably unsupported. May work with vuescan. See link for details.' model `DiMAGE Scan Elite 5400 2' interface `USB' usb-vendor-id `0x132b' usb-product-id `0x0012' status unsupported url `unsupported/minolta-dse-5400-2.html' comment `Probably unsupported. See link for details.' model `DiMAGE Scan Multi Pro' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/minolta-dimage-scan-multi-pro.html' comment `Probably unsupported. See link for details.' model `magicolor 2480MF' interface `USB Network' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Uses a different scanning protocol than the magicolor 1690MF' mfg `Mustek' url `http://www.mustek.com/' url `http://www.mustek.de/' url `http://www.mustek.com.tw/' comment *none* model `1200 III EP' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. quarlewm at jmu dot edu offers to temporarily loan such a scanner to anyone who is interested in writing a driver.' model `2400 M' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED' comment `Probably unsupported. No details known.' model `BearPaw 2400 TA Pro' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0400' status unsupported url `http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED' comment `Not supported. May be supported by mustek_usb2 backend later. See link for some information.' model `BearPaw 2448 CU Pro' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0408' status unsupported url `unsupported/mustek-bearpaw-2448-cu-pro.html' comment `Not supported. May be supported by mustek_usb2 backend later. See link for some information.' model `BearPaw 4800 TA Pro' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x1000' status unsupported url `unsupported/mustek-bearpaw-4800ta-pro.html' comment `Not supported. See link for some information.' model `BearPaw 4800 TA Pro II' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x040a' status unsupported url `unsupported/mustek-bearpaw-4800ta-pro-ii.html' comment `Not supported. May be supported by mustek_usb2 backend later. See link for some information.' model `BearPaw 6400 TA Pro' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x040b' status unsupported url `http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED' comment `Not supported. May be supported by mustek_usb2 backend later. See link for some information.' model `Paragon 800 II EP' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Not supported. Maybe similar to 600 II EP (SCSI_over-parport)? In this case it could be supported by the mustek SCSI backend.' model `ScanExpress 600 USB' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0873' status unsupported url `http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED' comment `Unsupported. Programming information is available.' model `ScanExpress 1200 USB' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0003' status unsupported url `http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED' comment `Unsupported. Programming information is available.' model `ScanExpress 1200 USB Plus' interface `USB' usb-vendor-id `0x055f' usb-product-id `0x0007' status unsupported url `http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED' comment `Unsupported.' model `ScanExpress 12000 P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://penguin-breeder.org/?page=mustek_pp' comment `Not supported. Asic 1505/05.' model `ScanExpress A3 EP' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Not supported. Maybe it will be supported by the mustek_pp backend in future.' model `ScanExpress CardSmart' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED' comment `Probably unsupported. USB business card scanner. Maybe works as USB storage device?' model `ScanMagic 9636P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://alioth-lists.debian.net/pipermail/sane-devel/2003-May/007682.html' comment `Probably not supported. Same as Mustek 12000 P?. ASIC 1505.' mfg `NEC' url `http://www.nevt.co.jp/' comment *none* model `Petiscan' interface `USB' usb-vendor-id `0x0475' usb-product-id `0x0100' status unsupported url `unsupported/nec-petiscan.html' comment `Most probably unsupported. See link for details. Vendor ID is Relisys/Teco. Not known if it is similar to other Relisys/Teco USB scanners.' mfg `Nikon' url `http://www.nikon.com/' comment *none* model `LS-9000 ED' interface `IEEE-1394' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/nikon-ls9000-ed.html' comment `Probably not supported. See link for details. Possibly similar to LS-8000 ED.' mfg `Olivetti' url `http://www.olivetti.com' comment *none* model `Job-Jet M400' interface `USB' usb-vendor-id `0x0b3c' usb-product-id `0xa880' status unsupported url `unsupported/olivetti-job-jet-m400.html' comment `Probably not supported. See link for details.' mfg `Olympus' url `http://www.olympus.com' comment *none* model `ES-10P' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://alioth-lists.debian.net/pipermail/sane-devel/2008-December/023326.html' comment *none* model `ES-10S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/olympus-es10s.html' comment `Probably not supported. See link for details.' mfg `Optoelectronics' url *none* comment *none* model `Barcode scanner' interface `USB' usb-vendor-id `0x065a' usb-product-id `0x0001' status unsupported url *none* comment `Probably not supported.' mfg `Optrox' url *none* comment *none* model `PhotoMaker 3C' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.df.lth.se/~triad/krad/optrox/' comment *none* model `PhotoMaker 3E' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.df.lth.se/~triad/krad/optrox/' comment *none* model `PhotoMaker 3F' interface `Proprietary' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.df.lth.se/~triad/krad/optrox/' comment `Special ISA card' model `PhotoMaker 3S' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.df.lth.se/~triad/krad/optrox/' comment *none* model `PhotoMaker 6E' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.df.lth.se/~triad/krad/optrox/' comment *none* model `PhotoMaker 6F' interface `Proprietary' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.df.lth.se/~triad/krad/optrox/' comment `Special ISA card' mfg `Panasonic' url *none* comment *none* model `KV-SS905C' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool.' model `KV-S2055W' interface `USB SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S2055L' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S2065W' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S3065CW' interface `USB SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S3065CL' interface `USB SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S3085' interface `USB SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S3105C' interface `USB SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool.' model `KV-S6040W' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S6045W' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S6050W' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S6055W' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' model `KV-S7065C' interface `USB SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `might be supported by matsushita backend.' mfg `Pentax' url *none* comment *none* model `DSmobile USB' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x2000' status unsupported url `unsupported/syscan-travelscan-pro.html' comment `Probably not supported. Some information is available.' mfg `PIE' url `http://www.scanace.com/' comment `Pacific Image Electronics' model `Primefilm 1800u' interface `USB' usb-vendor-id `0x05e3' usb-product-id `0x0120' status unsupported url `unsupported/pie-1800u.html' comment `Not supported. See link for details.' model `Primefilm 2700' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://alioth-lists.debian.net/pipermail/sane-devel/2009-January/023442.html' comment *none* model `Primefilm 3600PRO' interface `USB IEEE-1394' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. ' model `Powerslide 3600' interface `USB IEEE-1394' usb-vendor-id `0x05e3' usb-product-id `0x0142' status unsupported url `unsupported/reflecta-digitdia-3600.html' comment `Probably unsupported. Film scanner that can scan directly from the magazine.' model `PF3650 Pro3 Film Scanner' interface `USB IEEE-1394' usb-vendor-id `0x05e3' usb-product-id `0x0143' status unsupported url `unsupported/pie-pf3650.html' comment `Not supported. See link for details.' mfg `Plustek' url `http://www.plustek.de/' url `http://www.plustek.com/' comment *none* model `OpticFilm 7200' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0807' status unsupported url `unsupported/plustek-opticfilm-7200.html' comment `GL842 based, maybe to be added to genesys backend' model `OpticFilm 7200i' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0c04' status unsupported url *none* comment `GL843 based, maybe to be added to genesys backend' model `OpticPro A3U' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Uses Plustek ASIC P99002' model `OpticPro S6' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Uses RealTek chipset (RTL8801D)' model `OpticPro S12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0600' status unsupported url `unsupported/plustek-opticpro-st12.html' comment `Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend.' model `OpticPro ST12' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0600' status unsupported url `unsupported/plustek-opticpro-st12.html' comment `Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend.' model `OpticPro ST16' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0600' status unsupported url `unsupported/plustek-opticpro-st16.html' comment `GL646 based, to be added to genesys backend' model `OpticPro UA18' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably LM983x based.' model `OpticPro S24' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0601' status unsupported url `unsupported/plustek-opticpro-st24.html' comment `Product id 0x0601 is unsupported but may be supported by the genesys backend in future /GL646). Product id 0x040e is supported by the gt68xx backend.' model `OpticPro ST24' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0601' status unsupported url `unsupported/plustek-opticpro-st24.html' comment `GL646 based, to be added to genesys backend' model `OpticPro S28' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0801' status unsupported url `unsupported/plustek-opticpro-s28.html' comment `GL841 based, to be added to genesys backend' model `OpticPro ST28' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0801' status unsupported url `unsupported/plustek-opticpro-s28.html' comment `GL841 based, to be added to genesys backend' model `OpticPro ST28' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0802' status unsupported url `unsupported/plustek-opticpro-st28.html' comment `GL841 based, to be added to genesys backend' model `Umax AstraScan 4750' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0802' status unsupported url `unsupported/umax-astrscan-4750.html' comment `GL841 based, to be added to genesys backend, rebadged Plustek ST28' model `OpticPro ST48' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0800' status unsupported url `unsupported/plustek-opticpro-st48.html' comment `GL841 based, to be added to genesys backend' model `OpticPro ST64' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0c00' status unsupported url `unsupported/plustek-opticpro-st64.html' comment `GL843 based, maybe to be added to genesys backend' model `OpticPro ST64+' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0c03' status unsupported url `unsupported/plustek-opticpro-st64plus.html' comment `GL843 based. See link for more details.' model `PL 806' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0c0c' status unsupported url `unsupported/plustek-pl806.html' comment `Unsupported. See link for more details.' model `SmartOffice PL 812' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0c0d' status unsupported url `unsupported/plustek-pl812.html' comment `Unsupported. See link for more details.' model `OpticSlim 500' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0458' status unsupported url `unsupported/plustek-opticslim-500.html' comment `Unsupported. See link for more details.' model `OpticSlim 2420' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0806' status unsupported url `unsupported/plustek-opticslim-2420.html' comment `GL841 based, to be added to genesys backend' model `OpticSlim 2420+' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0914' status unsupported url `unsupported/plustek-opticslim-2420plus.html' comment `GL841 based, to be added to genesys backend' model `OpticWorks 2000' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Multifunction device. No further information available.' model `OptiCard 600+' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Business card reader. No further information available.' model `ScanCopy 115' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x081c' status unsupported url `unsupported/plustek-scancopy-115.html' comment `GL841 based, to be added to genesys backend' model `Spectra ADF' interface `Proprietary' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Unsupported. Uses proprietary ISA card that also provides power and is labelled GPS-1 PAGE-A from Taiwan. Other labels on the scanner include ADF Color Scanner and SF600AS. Maybe the same as the IBM ADF Color Scanner?' model `Unknown Plustek Device' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0005' status unsupported url *none* comment `Probably unsupported. Scanner name not known yet.' model `Unknown Plustek Device' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0007' status unsupported url *none* comment `Probably unsupported. Scanner name not known yet.' model `Unknown Plustek Device' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x000f' status unsupported url *none* comment `Probably unsupported. Scanner name not known yet.' model `Unknown Plustek Device' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0012' status unsupported url *none* comment `Probably unsupported. Scanner name not known yet.' model `Unknown Plustek Device' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0014' status unsupported url *none* comment `Probably unsupported. Scanner name not known yet.' model `Unknown Plustek Device' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0016' status unsupported url *none* comment `Probably unsupported. Scanner name not known yet.' mfg `PLANon' url `http://www.planon.com/' comment *none* model `DocuPen RC800' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. No details known.' model `DocuPen R700' interface `USB' usb-vendor-id `0x10c4' usb-product-id `0xea60' status unsupported url `unsupported/planon-docupen-r700.html' comment `Probably not supported. See link for details.' model `DocuPen (DPEN-BW)' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. No details known.' mfg `Primax' url `http://www.primax.nl/' comment *none* model `Colorado 600U' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0341' status unsupported url `unsupported/primax-colorado-600u.html' comment `Not supported. Some information is available.' model `Colorado 1200p' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://home2.swipnet.se/~w-25069/pxscan.html' comment `Unsupported by SANE. But is reported to partly work with pxscan. See link.' model `Colorado 1200u' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0361' status unsupported url *none* comment `Probably unsupported. No details known.' model `Primascan Colorado 2600u' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0347' status unsupported url `unsupported/visioneer-onetouch4400.html' comment `Unsupported. Same as Visioneer Onetouch 4400. See link for details.' model `Colorado Direct 600' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://home2.swipnet.se/~w-25069/pxscan.html' comment `Not supported. However, a stand-alone program is available.' model `Colorado Direct 9600' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://home2.swipnet.se/~w-25069/pxscan.html' comment `Not supported. However, a stand-alone program is available.' model `Colorado USB 9600' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0340' status unsupported url `unsupported/primax-colorado-usb-9600.html' comment `Not supported. See link for details.' model `G2-300' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0300' status unsupported url *none* comment `Probably unsupported. No details known.' model `G2-300 #2' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0302' status unsupported url *none* comment `Probably unsupported. No details known.' model `G2E-300' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0301' status unsupported url *none* comment `Probably unsupported. No details known.' model `G2E-300 #2' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0303' status unsupported url *none* comment `Probably unsupported. No details known.' model `G2-600' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0380' status unsupported url *none* comment `Probably unsupported. No details known.' model `G2-600 #2' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0382' status unsupported url *none* comment `Probably unsupported. No details known.' model `G2E-600' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0383' status unsupported url *none* comment `Probably unsupported. No details known.' model `OneTouch 5300' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Not supported.' model `ReadyScan 636i' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0381' status unsupported url *none* comment `Probably unsupported. No details known.' model `Slim-Line 1200' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Maybe GL646. Maybe similar to Medion MD 6228?' model `Onetouch 8920' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0371' status unsupported url `unsupported/visioneer-onetouch8920.html' comment `Not supported. Look similar to Visioneer Onetouch 8920 (same USB product id).' mfg `Prolink' url `http://www.fida.com/' comment *none* model `Winscan Pro 2448U' interface `USB' usb-vendor-id `0x06dc' usb-product-id `0x0014' status unsupported url `unsupported/prolink-2448u.html' comment `Not supported. Some information is available. RealTek RTS8801.' model `Winscan Pro 2000' interface `USB Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Not supported. No further information available.' mfg `Quato' url `http://www.quato.de/' comment *none* model `X-Finity' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. No details yet. Originally manufactured by PFU?' model `X-Finity Ultra' interface `USB IEEE-1394' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. No details yet.' mfg `Reflecta' url *none* comment *none* model `DigitDia 3600' interface `USB IEEE-1394' usb-vendor-id `0x05e3' usb-product-id `0x0142' status unsupported url `unsupported/reflecta-digitdia-3600.html' comment `Film scanner that can scan directly from the magazine.' model `iScan 1800' interface `USB' usb-vendor-id `0x05e3' usb-product-id `0x0120' status unsupported url `unsupported/reflecta-iscan-1800.html' comment `Probably unsupported. See link for details.' model `ProScan 4000' interface `USB IEEE-1394' usb-vendor-id `0x05e3' usb-product-id `0x0143' status unsupported url `unsupported/reflecta-proscan-4000.html' comment `Probably unsupported. See link for details.' mfg `Relisys' url *none* comment *none* model `Eclipse 1200U' interface `USB' usb-vendor-id `0x0475' usb-product-id `0x0103' status unsupported url `unsupported/relisys-eclipse-1200u.html' comment `Probably unsupported. See link for details.' model `Scorpio Ultra 3' interface `USB' usb-vendor-id `0x0475' usb-product-id `0x0210' status unsupported url `unsupported/relisys-scorpio-ultra3.html' comment `Probably unsupported. See link for details.' model `Episode' interface `USB' usb-vendor-id `0x0475' usb-product-id `0x0103' status unsupported url `unsupported/relisys-episode.html' comment `Probably unsupported. See link for details.' model `AVEC II E3' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Parport version of AVEC II S3?. See bug #304992 for details' mfg `Samsung' url *none* comment *none* model `SCX-4725FN' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x341f' status unsupported url `unsupported/samsung-scx-4725.html' comment `Not supported. See link for details.' mfg `Scanshell' url *none* comment *none* model `800N' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x6605' status unsupported url `unsupported/scanshell-800n.html' comment `Not supported. See link for details.' mfg `Sicos' url *none* comment *none* model `DMS 2000' interface `proprietary' usb-vendor-id *none* usb-product-id *none* status unsupported url `mailto:ehaase@inf.fu-berlin.de' comment `Not supported until now. Work on a backend has started, contact the author for details (see link)' mfg `Siemens' url `http://www.siemens.com/' comment *none* model `ID Mouse Professional' interface `USB' usb-vendor-id `0x0681' usb-product-id `0x0005' status unsupported url *none* comment `Not supported.' model `Cherry FingerTIP ID Board - Sensor' interface `USB' usb-vendor-id `0x0681' usb-product-id `0x0010' status unsupported url *none* comment `Not supported.' mfg `SmartDisk' url *none* comment *none* model `SmartScan 3600' interface `USB IEEE-1394' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. Same as PIE Primefilm 2600 PRO.' mfg `Spot Technology' url *none* comment `Spot seems have gone out of business.' model `Maxiscan A4' interface `proprietary' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.el-profesor.net/spoonset/' comment `Not supported until now. Work on a backend has started, see link for more information.' model `ScanTak 2c' interface `proprietary' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.el-profesor.net/spoonset' comment `Not supported. Work on a backend has started, see link for more information.' model `ScanTak 3c' interface `proprietary' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.el-profesor.net/spoonset' comment `Not supported. Work on a backend has started, see link for more information.' mfg `Syscan' url *none* comment *none* model `TravelScan FS-531' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x0530' status unsupported url `unsupported/syscan-travelscan-fs531.html' comment `Not supported. May work with the Plustek backend in future. See link for details.' model `TravelScan Pro' interface `USB' usb-vendor-id `0x0a82' usb-product-id `0x2000' status unsupported url `unsupported/syscan-travelscan-pro.html' comment `Probably not supported. Some information is available.' mfg `Tamarack' url *none* comment *none* model `Artiscan 9600' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.autistici.org/tamarhack/' comment `Unsupported at the moment. See link for a project for that scanner taht may support it in future.' model `Artiscan 9600 pro 36' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://www.autistici.org/tamarhack/' comment `Unsupported at the moment. See link for a project for that scanner.' model `Artiscan 2400FS' interface `USB' usb-vendor-id `0x05e3' usb-product-id `0x0100' status unsupported url `unsupported/tamarack-artiscan-2400.html' comment `Unsupported. See link for more information.' mfg `TCE' url `http://www.tce.com.br/' comment `Brasilian vendor.' model `MK600U' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0346' status unsupported url `unsupported/memorex-maxx-6136u.html' comment `Not supported. Some information is available.' model `S450' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://home2.swipnet.se/~w-25069/pxscan.html' comment `Not supported by SANE but is reported to work with pxscan (see link).' mfg `Teco' url `http://www.tecoimage.com.tw/' comment *none* model `VM6509F' interface `USB' usb-vendor-id `0x080d' usb-product-id `0x0102' status unsupported url `unsupported/teco-vm6509.html' comment `Probably unsupported. See link for details.' mfg `Tiny' url *none* comment *none* model `FU661E' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0347' status unsupported url `unsupported/visioneer-onetouch4400.html' comment `Unsupported. See link for details.' mfg `Trust' url `http://www.trust-site.com' comment *none* model `CombiScan 19200' interface `Parport USB' usb-vendor-id `0x05cb' usb-product-id `0x1483' status unsupported url `unsupported/trust-combiscan-19200.html' comment `Unsupported. See link for details.' model `EasyScan 19200' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `http://alioth-lists.debian.net/pipermail/sane-devel/2008-October/022955.html' comment *none* model `SCSI Scan 19200 -Excellence Series-' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/trust-scsi-scan-19200.html' comment `Unsupported. See link for details.' mfg `UMAX' url `http://www.umax.com/' comment *none* model `Astra 2500' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0374' status unsupported url `unsupported/umax-astra-2500.html' comment `Probably not supported. See link for details.' model `Astra 2850' interface `USB' usb-vendor-id `0x07b3' usb-product-id `0x0601' status unsupported url `unsupported/plustek-opticpro-st24.html' comment `Probably not supported. Same IDs as Plustek OpticPro ST24. See link for details.' model `Astra 3000' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x038a' status unsupported url `unsupported/umax-astra-3000.html' comment `Probably not supported. See link for details.' model `Astra 3600' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x038a' status unsupported url `unsupported/umax-astra-3600.html' comment `Probably not supported. See link for details.' model `Astra 4000' interface `USB' usb-vendor-id `0x1606' usb-product-id `0x1030' status unsupported url `unsupported/umax-astra-4000.html' comment `Not supported. See link for details.' model `Astra 4100' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x038c' status unsupported url `unsupported/umax-astra-4100.html' comment `Not supported, to be added to genesys backend.' model `Astra 4500' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a10' status unsupported url `unsupported/umax-astra-4500.html' comment `GL646 based, to be added to genesys backend. Avision iVina FB1600 clone' model `Astra 4600' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported, no details known.' model `Astra 4700' interface `USB' usb-vendor-id `0x0638' usb-product-id `0x0a20' status unsupported url `unsupported/umax-astra-4700.html' comment `GL646/GL660 based. Avision iVina FB1800 clone.' model `Astra 6700' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Not supported. No chipset information available. Same as Avision iVina FB2400.' model `AstraSlim' interface `USB' usb-vendor-id `0x080d' usb-product-id `0x0104' status unsupported url `unsupported/umax-astraslim.html' comment `Probably not supported currently. See link for more details.' model `AstraSlim 1200' interface `USB' usb-vendor-id `0x080d' usb-product-id `0x0110' status unsupported url `unsupported/umax-astraslim-1200.html' comment `See link for more details.' model `AstraSlim 6000' interface `USB' usb-vendor-id `0x080d' usb-product-id `0x0104' status unsupported url `unsupported/umax-astraslim-6000.html' comment `Probably not supported currently. See link for more details.' model `Nete3470'' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. No details known..' model `Powerlook 180' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/umax-powerlook-180.html' comment `Probably not supported. See link for details.' model `Powerlook 1000 USB' interface `USB' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Probably not supported. No further information available.' mfg `Vantas' url *none* comment *none* model `3000' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0224' status unsupported url `unsupported/visioneer-onetouch4800.html' comment `Not supported. See link for more details.' mfg `Visioneer' url `http://www.visioneer.com/' comment *none* model `6200' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0345' status unsupported url *none* comment `Not supported. Is reported to use the E5 chipset. Uses a Primax ID. Looks similar to Primascan Colorado 2600u.' model `6200 EPP/USB' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0311' status unsupported url *none* comment `Not supported. Id is from Primax? Yet another scanner with the same name?' model `9420' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x03a8' status unsupported url `unsupported/visioneer-9420.html' comment `Unsupported. See link for details.' model `9450 USB' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0421' status unsupported url `unsupported/visioneer-9450-usb.html' comment `Unsupported. See link for details.' model `Onetouch 4400' interface `USB' usb-vendor-id `0x0461' usb-product-id `0x0347' status unsupported url `unsupported/visioneer-onetouch4400.html' comment `Not supported. E5 chipset? See link for more details.' model `OneTouch 4800 USB' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0224' status unsupported url `unsupported/visioneer-onetouch4800.html' comment `Unsupported. Seems to use Realtek RTS8801B. Same as Microtek Scanport 3000. See link for details.' model `OneTouch 5300 USB' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0226' status unsupported url `unsupported/visioneer-onetouch5300.html' comment `Not supported. Chipset is RTS8801B(?). See link for output of /proc/bus/usb/devices.' model `OneTouch 5300' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0221' status unsupported url *none* comment `Not supported. Yet another scanner with this name?' model `OneTouch 5800 USB' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0226' status unsupported url `unsupported/visioneer-onetouch5800.html' comment `Unsupported. 48 bit scanner, doesn't work with viceo backend. RTS8801C.' model `OneTouch 6600' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x022a' status unsupported url `unsupported/visioneer-onetouch6600.html' comment `Unsupported. See link for details.' model `Onetouch 7100' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0229' status unsupported url `unsupported/visioneer-onetouch7100.html' comment `GL646 based, to be added to genesys backend' model `Onetouch 7700' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0380' status unsupported url `unsupported/visioneer-onetouch7700.html' comment `LM9832/3 based, to be added to plustek backend' model `OneTouch 8100' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0321' status unsupported url `unsupported/visioneer-onetouch8100.html' comment `Unsupported. See link for details.' model `Onetouch 8700' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0371' status unsupported url `unsupported/visioneer-onetouch8920.html' comment `Not supported. See link for details.' model `Onetouch 8900' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0371' status unsupported url `unsupported/visioneer-onetouch8920.html' comment `Not supported. Same as 8920 but without TA?' model `Onetouch 8920' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0371' status unsupported url `unsupported/visioneer-onetouch8920.html' comment `Not supported. Same as 8700 and 8900 but includes a TA. Uses a Primax ID. Chipset is RTS8801C. See link for output of /proc/bus/usb/devices.' model `Onetouch 9000' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x022c' status unsupported url `unsupported/visioneer-onetouch9020.html' comment `Not supported. See link for details.' model `Onetouch 9020' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x022c' status unsupported url `unsupported/visioneer-onetouch9020.html' comment `Not supported. See link for details.' model `Onetouch 9320' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0362' status unsupported url `unsupported/visioneer-onetouch9320.html' comment `Probably not supported. See link for details.' model `Onetouch Pro 8800' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0410' status unsupported url `unsupported/visioneer-onetouch8820.html' comment `Probably not supported. See link for details.' model `Onetouch Pro 8820' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0410' status unsupported url `unsupported/visioneer-onetouch8820.html' comment `Probably not supported. See link for details.' model `PaperPort 3100b' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/visioneer-paperport-3100b.html' comment `Most probably not supported. See link for details.' model `PaperPort 6100' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url *none* comment `Most probably not supported. More details would be appreciated.' model `PaperPort OneTouch' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/visioneer-paperport-onetouch.html' comment `Most probably not supported. See link for details.' model `Strobe Pro USB' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0102' status unsupported url `unsupported/visioneer-strobe-pro-usb.html' comment `Not supported. See link for details.' model `4800 One Touch' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x03a0' status unsupported url `unsupported/xerox-4800-onetouch.html' comment `Unsupported. See link for details. Different id compared to One Touch 4800?' model `DocuImage 620S' interface `SCSI' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/xerox-docuimage-620s.html' comment `Not supported. See link for more details.' model `DocuMate 510' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0446' status unsupported url `unsupported/xerox-documate-510.html' comment `Not supported. See link for more details.' model `DocuMate 510' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x047c' status unsupported url `unsupported/xerox-documate-510.html' comment `Not supported. See link for more details. Yet another USB id.' model `One Touch 4800' interface `USB' usb-vendor-id `0x04a7' usb-product-id `0x0224' status unsupported url `unsupported/visioneer-onetouch4800.html' comment `Unsupported. See link for details. Different id compared to 4800 One Touch?' model `WorkCentre 470cx' interface `Parport' usb-vendor-id *none* usb-product-id *none* status unsupported url `unsupported/xerox-workcentre-470cx.html' comment `Not supported. See link for more details.' model `WorkCentre M15i' interface `USB' usb-vendor-id `0x0924' usb-product-id `0xffef' status unsupported url `unsupported/xerox-workcentre-m15i.html' comment `Not supported. See link for more details.' model `WorkCentre XK35c' interface `USB Parport' usb-vendor-id `0x043d' usb-product-id `0x0020' status unsupported url `unsupported/xerox-workcentre-xk35c.html' comment `Not supported. See link for more details.' model `WorkCentre XK50cx' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3903' status unsupported url `unsupported/xerox-workcentre-xk50cx.html' comment `Not supported. See link for more details.' model `WorkCentre Pro 412' interface `USB Parport' usb-vendor-id `0x043d' usb-product-id `0x4303' status unsupported url `unsupported/xerox-workcentre-pro412.html' comment `Not supported. See link for more details.' model `WorkCentre PE16' interface `USB Parport' usb-vendor-id `0x0924' usb-product-id `0x4220' status unsupported url `unsupported/xerox-workcentre-pe16.html' comment `Not supported. See link for more details.' model `WorkCentre PE120i' interface `USB' usb-vendor-id `0x0924' usb-product-id `0x4237' status unsupported url `unsupported/xerox-workcentre-pe120i.html' comment `Not supported. See link for more details.' type vidcam mfg `Biolux' url *none* comment *none* model `654 (micrOcular)' interface `USB' usb-vendor-id `0x0923' usb-product-id `0x010f' status unsupported url `unsupported/biolux-654.html' comment `Not supported yet. See link for more details.' mfg `Grandtek Scopecam' url *none* comment *none* model `8x30 Binocular & Digital Camera' interface `USB' usb-vendor-id `0x0797' usb-product-id `0x801c' status unsupported url `unsupported/grandtech-scopecam.html' comment `Not Supported yet. See link for more details.' backend `v4l' version `1.0-3' manpage `sane-v4l' url `mailto:henning@meier-geinitz.de' comment *none* type api desc `Interface to Video For Linux API' url *none* comment `Supports video cameras and other devices accessed by the v4l kernel API, e.g. bttv devices. Quite a lot of known bugs.' backend `xerox_mfp' version `1.0-13' manpage `sane-xerox_mfp' url *none* comment *none* type scanner mfg `Xerox' url `http://www.office.xerox.com/' comment *none* model `Phaser 6110MFP' interface `USB' usb-vendor-id `0x0924' usb-product-id `0x3d5d' status good url *none* comment *none* model `Phaser 3200MFP' interface `USB' usb-vendor-id `0x0924' usb-product-id `0x3da4' status complete url `http://www.office.xerox.com/multifunction-printer/multifunction-under-30ppm/phaser-3200mfp/spec-enus.html' comment *none* model `WorkCentre 3119 Series' interface `USB' usb-vendor-id `0x0924' usb-product-id `0x4265' status good url *none* comment *none* model `WorkCentre 4118 Series' interface `USB' usb-vendor-id `0x0924' usb-product-id `0x420c' status good url *none* comment *none* model `WorkCentre 3210' interface `USB' usb-vendor-id `0x0924' usb-product-id `0x4293' status good url *none* comment *none* model `WorkCentre 3220' interface `USB' usb-vendor-id `0x0924' usb-product-id `0x4294' status good url *none* comment *none* mfg `Dell' url `http://www.dell.com/' comment *none* model `Dell MFP Laser Printer 1815dn' interface `USB' usb-vendor-id `0x413c' usb-product-id `0x5124' status good url *none* comment *none* mfg `Samsung' url `http://www.samsung.com' comment *none* model `SCX-4x16' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3409' status untested url *none* comment *none* model `SCX-6x20' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x340d' status untested url *none* comment *none* model `MFP-560' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x340e' status untested url *none* comment *none* model `MFP-750' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x340f' status untested url *none* comment *none* model `SCX-4x20' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3412' status untested url *none* comment *none* model `SCX-4100' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3413' status good url *none* comment *none* model `SCX-4x21' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3419' status untested url *none* comment *none* model `SCX-5x30' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x341a' status untested url *none* comment *none* model `SCX-4200' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x341b' status good url *none* comment *none* model `CLX-3160' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x341c' status untested url *none* comment *none* model `SCX-6x22' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x341d' status untested url *none* comment *none* model `SCX4725' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x341f' status untested url *none* comment *none* model `SCX4725-FN' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x341f' status good url *none* comment *none* model `SCX-6x45' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3420' status untested url *none* comment *none* model `CLX-8380' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3421' status untested url *none* comment *none* model `CLX-2160' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3425' status good url *none* comment *none* model `SCX-4500' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3426' status good url *none* comment *none* model `CLX-6200' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3427' status untested url *none* comment *none* model `CLX-6240' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3428' status untested url *none* comment *none* model `SCX-6x55' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3429' status untested url *none* comment *none* model `CLX-3170fn (CLX-3170 Series)' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x342a' status good url *none* comment *none* model `CLX-3175FW' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x342a' status good url *none* comment *none* model `SCX-4500W' interface `USB Ethernet' usb-vendor-id `0x04e8' usb-product-id `0x342b' status basic url *none* comment *none* model `SCX-4824 (SCX-4x24 Series)' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x342c' status good url *none* comment *none* model `SCX-4828FN (SCX-4x28 Series)' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x342d' status good url *none* comment *none* model `SCX-4300' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x342e' status good url *none* comment *none* model `SCX-5835_5935' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x342f' status good url *none* comment *none* model `SCX-5635' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3430' status untested url *none* comment *none* model `SCX-4x26' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3432' status untested url *none* comment *none* model `SCX-4600' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3433' status good url *none* comment *none* model `SCX-4623' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3434' status good url *none* comment *none* model `MFP-65x' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3435' status untested url *none* comment *none* model `SCX-6545' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3437' status untested url *none* comment *none* model `CLX-8385' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3439' status untested url *none* comment *none* model `CLX-6220' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x343a' status good url *none* comment *none* model `CLX-6250' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x343b' status untested url *none* comment *none* model `SCX-4825FN (SCX-4x25 Series)' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x343c' status good url *none* comment *none* model `CLX-3185' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x343d' status good url *none* comment *none* model `CLX-8540' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x343f' status untested url *none* comment *none* model `SCX-4623FW' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3440' status good url *none* comment *none* model `SCX-3205W (SCX-3200 Series)' interface `USB Ethernet' usb-vendor-id `0x04e8' usb-product-id `0x3441' status good url *none* comment *none* model `SCX-6545X' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3442' status untested url *none* comment *none* model `SCX-6x55X' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3443' status untested url *none* comment *none* model `CLX-8385X' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3444' status untested url *none* comment *none* model `SCX-5835_5935X' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3446' status good url *none* comment *none* model `SCX-4833FD' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x344b' status good url *none* comment *none* model `SCX-4835FD' interface `Ethernet' usb-vendor-id `0x04e8' usb-product-id `0x344b' status good url *none* comment *none* model `SCX-3405W' interface `Ethernet' usb-vendor-id *none* usb-product-id *none* status basic url *none* comment *none* model `SCX-3400' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x344f' status untested url *none* comment *none* model `SF-760' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3450' status untested url *none* comment *none* model `SCX-4729FD' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3453' status basic url *none* comment *none* model `CLX-6260' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3455' status minimal url *none* comment *none* model `CLX-3300 Series' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3456' status basic url *none* comment *none* model `SCX-470x' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3457' status untested url *none* comment *none* model `CLX-4190' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x345a' status minimal url *none* comment *none* model `SCX-4650 4x21S Series' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x345b' status untested url *none* comment *none* model `M337x 387x 407x Series' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3460' status untested url *none* comment *none* model `M267x 287x Series' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3461' status untested url *none* comment *none* model `SCX-681x' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3466' status untested url *none* comment *none* model `C460' interface `USB' usb-vendor-id `0x04e8' usb-product-id `0x3468' status untested url *none* comment *none* sane-backends-1.0.29/testsuite/tools/data/xml.ref0000666000000000000000000217732413615534521016621 00000000000000 unmaintained sane-abaton *none* *none* *none* *none* SCSI *none* *none* complete *none* All known modes and functions supported SCSI *none* *none* untested *none* Untested, use with caution unmaintained sane-agfafocus *none* *none* `http://www.agfa.com/' *none* SCSI *none* *none* untested *none* 6 bit gray SCSI *none* *none* untested *none* Lineart only? Untested. SCSI *none* *none* untested *none* gray only SCSI *none* *none* good *none* 3-pass SCSI *none* *none* good *none* 3-pass *none* *none* SCSI *none* *none* untested *none* gray only unmaintained sane-apple *none* *none* `http://developer.apple.com/' *none* SCSI *none* *none* good *none* 4bit, 16 shades of gray SCSI *none* *none* basic *none* 8bit, 256 shades of gray. The backend needs work especially in the quantization code but it may work. SCSI *none* *none* minimal *none* truecolor (needs much work) but it scans in non color modes. unmaintained sane-artec http://www4.infi.net/~cpinkham/sane/sane-artec-doc.html *none* `http://www.artecusa.com/' *none* SCSI *none* *none* complete *none* all modes working SCSI *none* *none* complete *none* all modes working SCSI *none* *none* complete *none* f/w <= v1.92 basic, f/w >= v1.93 OK SCSI *none* *none* good *none* Scan head needs to return home before another scan can be started. SCSI *none* *none* complete *none* all modes working SCSI *none* *none* complete *none* all modes working `http://www.blackwidow.co.uk/' *none* SCSI *none* *none* complete *none* rebadged Artec AT3 `http://www.plustek.com/' *none* SCSI *none* *none* complete *none* rebadged Artec AM12S unmaintained sane-artec_eplus48u *none* *none* `http://www.artecusa.com/' *none* USB 0x05d8 0x4003 good *none* CIS scanner based on the GT6816 chip. Apparently all other devices are re-badged Artec scanners. USB 0x05d8 0x4004 minimal *none* Works up to 600dpi, but not 1200. Needs better calibration. See bug #310490 `http://www.medion.com' Sold by Aldi and Tchibo. USB 0x05d8 0x4003 good *none* *none* USB 0x05d8 0x4003 good *none* *none* USB 0x05d8 0x4003 good *none* Only scanners with product id 0x4003 will work; try the gt68xx backend, if your scanner has product id 0x4002 `http://www.trust-site.com' *none* USB 0x05d8 0x4006 good *none* *none* USB 0x05d8 0x4007 basic *none* Works up to 600 dpi `http://www.artecusa.com/' *none* USB 0x05d8 0x4005 good *none* *none* `http://www.microstar.de/' *none* USB 0x05d8 0x4003 good *none* *none* `http://www.umax.com/' `http://www.umax.com.tw/' `http://www.umax.de/en' `http://www.umax-europe.com' `http://www.umaxjapan.co.jp' `http://www.umax.com.cn' *none* USB 0x05d8 0x4009 good *none* *none* USB 0x05d8 0x4010 good *none* *none* `http://www.yakumo.com/' *none* USB 0x05d8 0x4011 good *none* *none* 0.5 sane-as6e http://as6edriver.sourceforge.net/ *none* `http://www.artecusa.com/' *none* Parport *none* *none* basic *none* Requires the program 'as6edriver' to run. `http://www.trust-site.com' Carefully check the model names. Trust uses similar names for completely different hardware. Parport *none* *none* basic *none* Requires the program 'as6edriver' to run. `http://www.dexxa.com' *none* Parport *none* *none* basic *none* Requires the program 'as6edriver' to run. Build: 296 sane-avision http://skull.piratehaven.org/~mike/sane/avision.html *none* `http://www.avision.com' *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* USB 0x0638 0x0a27 complete *none* sheetfed scanner USB 0x0638 0x0a3c good *none* sheetfed scanner USB 0x0638 0x0a33 good *none* sheetfed duplex scanner USB 0x0638 0x0a93 good *none* sheetfed duplex scanner USB 0x0638 0x0a24 complete *none* sheetfed scanner USB 0x0638 0x0a25 complete *none* sheetfed scanner USB 0x0638 0x0a3a complete *none* sheetfed scanner USB 0x0638 0x0a2f complete *none* sheetfed scanner USB 0x0638 0x1a35 complete *none* sheetfed scanner USB 0x0638 0x0a23 complete *none* duplex! sheetfed scanner USB 0x0638 0x0a2a complete *none* duplex! sheetfed scanner USB 0x0638 0x0a2b complete *none* duplex! sheetfed scanner USB 0x0638 0x0a2c complete *none* duplex! sheetfed scanner USB 0x0638 0x0a2d complete *none* duplex! sheetfed scanner USB 0x0638 0x0a2e complete *none* duplex! sheetfed scanner USB 0x0638 0x0a94 complete *none* duplex! sheetfed scanner SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* USB 0x0638 0x0a18 good *none* *none* USB 0x0638 0x0a18 good *none* *none* USB 0x0638 0x0a5e good *none* *none* USB 0x0638 0x0a41 basic *none* MFD USB 0x0638 0x0a16 good *none* 1 pass, 600 dpi, A4 SCSI *none* *none* complete *none* 1 pass, 600 dpi SCSI *none* *none* complete *none* 1 pass, 1200 dpi SCSI *none* *none* complete *none* 1 pass, 1200 dpi SCSI *none* *none* untested *none* 1 pass, 1200 dpi SCSI *none* *none* complete *none* 1 pass, ??? dpi USB 0x0638 0x0a13 good *none* 1 pass, 600 dpi SCSI *none* *none* untested *none* 1 pass, ??? dpi SCSI *none* *none* untested *none* 1 pass, ??? dpi SCSI *none* *none* untested *none* 1 pass, 2400 dpi SCSI *none* *none* untested *none* 1 pass, ??? dpi SCSI *none* *none* untested *none* 1 pass, ??? dpi SCSI *none* *none* untested *none* 1 pass, ??? dpi SCSI *none* *none* complete *none* 1 pass, ??? dpi SCSI *none* *none* complete *none* 1 pass, ??? dpi SCSI *none* *none* complete *none* 1 pass, ??? dpi SCSI *none* *none* untested *none* 1 pass, ??? dpi SCSI *none* *none* untested *none* 1 pass, ??? dpi SCSI *none* *none* untested *none* 1 pass, ??? dpi SCSI *none* *none* complete *none* 1 pass, ??? dpi USB 0x0638 0x0a4e complete *none* 1 pass, ??? dpi USB 0x0638 0x0a4f complete *none* 1 pass, ??? dpi USB 0x0638 0x0a65 complete *none* 1 pass, ??? dpi SCSI *none* *none* complete *none* 1 pass, ??? dpi USB 0x0638 0x0a66 complete *none* 1 pass, ??? dpi SCSI *none* *none* complete *none* 1 pass, 1200 dpi, A3 - duplex! - zero edge! USB 0x0638 0x0a82 complete *none* 1 pass, 1200 dpi, A3 - duplex! - zero edge! USB 0x0638 0x0a84 basic *none* 1 pass, 600 dpi, zero-edge SCSI *none* *none* complete *none* 1 pass, 1200 dpi, A3 USB 0x0638 0x0a4d complete *none* 1 pass, 1200 dpi, A3 - duplex! USB 0x0638 0x0a40 complete *none* 1 pass, 1200 dpi, A3 - duplex! USB 0x0638 0x0a68 complete *none* 1 pass, 1200 dpi, A3 - duplex! USB 0x0638 0x0a61 good *none* 1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors USB 0x0638 0x0aa1 untested *none* *none* USB 0x0638 0x0a45 good *none* 1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors SCSI *none* *none* basic *none* 1 pass, 600 dpi, A3 `http://www.hp.com' *none* USB 0x03f0 0x0701 complete *none* 1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi USB 0x03f0 0x0701 good *none* 1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi USB 0x03f0 0x0801 good *none* 1 pass, 2400 dpi - dual USB/SCSI interface USB 0x03f0 0x0801 good *none* 1 pass, 2400 dpi - dual USB/SCSI interface USB 0x03f0 0x0801 good *none* 1 pass, 1200 dpi - dual USB/SCSI interface USB 0x03f0 0x0b01 good *none* 1 pass, 4800 (?) dpi - USB 2.0 USB 0x03f0 0x0b01 good *none* 1 pass, 4800 (?) dpi - USB 2.0 USB 0x03f0 0x3905 good *none* 1 pass, 4800 (?) dpi - USB 2.0 USB 0x03f0 0x0b01 good *none* 1 pass, 4800 (?) dpi - USB 2.0 and SCSI - only SCSI tested so far USB 0x03f0 0x3805 good *none* 1 pass, 4800 (?) dpi - USB 2.0 USB 0x03f0 0x3805 good *none* 1 pass, 4800 (?) dpi - USB 2.0 USB 0x03f0 0x3805 good *none* 1 pass, 4800 (?) dpi - USB 2.0 `http://www.minolta.com' *none* SCSI *none* *none* basic *none* *none* SCSI *none* *none* untested *none* *none* USB 0x0638 0x026a good *none* 1 pass, film-scanner USB 0x0686 0x4004 untested *none* 1 pass, film-scanner USB 0x0686 0x400d good *none* 1 pass, film-scanner USB 0x0686 0x400e good *none* 1 pass, film-scanner *none* *none* USB 0x0638 0x0a15 untested *none* *none* USB 0x0638 0x0a16 good *none* *none* *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* good *none* *none* `http://www.fujitsu.com' *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* USB 0x04c5 0x1029 untested *none* *none* USB 0x04c5 0x10ef good *none* *none* `http://www.kodak.com' *none* USB 0x040a 0x6001 untested *none* *none* USB 0x040a 0x6002 basic *none* *none* USB 0x040a 0x6003 untested *none* *none* USB 0x040a 0x6003 untested *none* *none* USB 0x040a 0x6004 untested *none* *none* USB 0x040a 0x6004 untested *none* *none* USB 0x040a 0x6005 good *none* *none* *none* *none* USB 0x0638 0x0268 untested *none* *none* *none* *none* USB 0x04a7 0x0424 complete *none* sheetfed scanner USB 0x04a7 0x0491 complete *none* sheetfed scanner USB 0x04a7 0x0479 complete *none* sheetfed scanner USB 0x04a7 0x048f complete *none* sheetfed scanner USB 0x04a7 0x0420 complete *none* sheetfed scanner USB 0x04a7 0x0421 complete *none* sheetfed scanner USB 0x04a7 0x047a complete *none* sheetfed scanner USB 0x04a7 0x0422 complete *none* sheetfed scanner USB 0x04a7 0x0390 complete *none* sheetfed scanner USB 0x04a7 0x047b complete *none* sheetfed scanner USB 0x04a7 0x0423 complete *none* sheetfed scanner USB 0x04a7 0x0493 complete *none* sheetfed scanner USB 0x04a7 0x0497 complete *none* sheetfed scanner USB 0x04a7 0x048f complete *none* sheetfed scanner USB 0x04a7 0x0498 complete *none* sheetfed scanner USB 0x04a7 0x0499 complete *none* sheetfed scanner *none* *none* USB 0x04a7 0x049c good *none* *none* USB 0x04a7 0x0477 good *none* *none* USB 0x04a7 0x049d good *none* *none* USB 0x04a7 0x0448 good *none* *none* USB 0x04a7 0x0490 good *none* *none* USB 0x04a7 0x0449 good *none* *none* USB 0x04a7 0x048c good *none* *none* USB 0x04a7 0x0476 good *none* *none* USB 0x04a7 0x044c good *none* *none* USB 0x04a7 0x048d good *none* *none* USB 0x04a7 0x04a7 good *none* *none* USB 0x04a7 0x0475 untested *none* *none* USB 0x04a7 0x048e untested *none* *none* USB 0x04a7 0x0446 untested *none* *none* USB 0x04a7 0x0495 untested *none* *none* USB 0x04a7 0x047c untested *none* *none* USB 0x04a7 0x0447 untested *none* *none* USB 0x04a7 0x0492 untested *none* *none* USB 0x04a7 0x0498 untested *none* *none* USB 0x04a7 0x0478 untested *none* *none* USB 0x04a7 0x049a untested *none* *none* *none* *none* USB 0x0638 0x0a16 good *none* 1 pass, 600 dpi, A4 *none* *none* SCSI *none* *none* basic *none* 1 pass, ??? dpi, A4 *none* *none* USB 0x0482 0x0335 untested *none* 1 pass, ??? dpi, A4 1.0-4 sane-bh http://www.martoneconsulting.com/sane-bh.html Supports Copiscan II scanners with Remote SCSI Controller (RSC) interface `http://www.bhscanners.com/' *none* SCSI *none* *none* good *none* Duplex Scanner with ACE - development model SCSI *none* *none* untested *none* Simplex Scanner SCSI *none* *none* good *none* Simplex Scanner (with ACE) - limited testing SCSI *none* *none* untested *none* Simplex Scanner with ACE SCSI *none* *none* untested *none* Simplex Scanner SCSI *none* *none* untested *none* Simplex Scanner (with ACE) 1.12 sane-canon http://www.rzg.mpg.de/~mpd/sane/ *none* `http://www.canon.com/' *none* SCSI *none* *none* good *none* 1 pass; flatbed scanner SCSI *none* *none* good *none* 1 pass; flatbed scanner SCSI *none* *none* good *none* 1 pass; flatbed scanner SCSI *none* *none* good *none* 1 pass; flatbed scanner SCSI *none* *none* good *none* 1 pass; film scanner SCSI *none* *none* good *none* 1 pass; 36bit film scanner SCSI *none* *none* good *none* 1 pass; flatbed scanner `http://www.apple.com/' *none* SCSI *none* *none* good *none* Rebadged CanoScan 300 0.1 sane-canon630u http://canon-fb630u.sourceforge.net/ *none* `http://www.canon.com/' *none* USB 0x04a9 0x2204 good *none* OK USB 0x04a9 0x2204 good *none* OK 38 sane-canon_dr http://www.thebility.com/canon/ Backend updated for SANE release 1.0.23, see sane-canon_dr manpage `http://www.canon.com/' *none* USB 0x1083 0x161a untested *none* Please test! USB 0x1083 0x160c untested *none* Please test! USB SCSI 0x1083 0x1639 untested *none* Please test! USB SCSI 0x04a9 0x1602 untested *none* Please test! USB SCSI 0x04a9 0x1602 untested *none* Same as CR-180? Please test! USB SCSI 0x1083 0x162b untested *none* Please test! USB 0x04a9 0x2222 untested *none* Older version? Please test! USB 0x1083 0x160f untested *none* Later version? Please test! USB 0x1083 0x161b complete *none* Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions. USB *none* *none* untested *none* Mac version of DR-2010C? Please test! USB 0x04a9 0x160a complete *none* Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration. USB 0x04a9 0x160a untested *none* Same as DR-2050C? Please test! USB SCSI 0x04a9 0x1601 complete *none* Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration USB 0x1083 0x1617 complete *none* Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions USB *none* *none* untested *none* Mac version of DR-2510C? Please test! USB SCSI 0x04a9 0x1608 complete *none* Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration USB 0x1083 0x161d good *none* Minimal testing, settings copied from DR-2510C SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Almost works, need to investigate traces from windows driver USB SCSI 0x04a9 0x1609 untested *none* Almost works, need to investigate traces from windows driver USB 0x1083 0x1614 good *none* Binary/HT/Gray/Color, Simplex/Duplex working. Multistream unsupported. USB *none* *none* untested *none* Please test! USB *none* *none* untested *none* Please test! USB 0x04a9 0x1606 untested *none* Please test! SCSI *none* *none* good *none* LineArt, Duplex working, cannot read buttons or screen? SCSI *none* *none* basic *none* Grayscale works, LineArt might SCSI *none* *none* untested *none* Please test! USB SCSI 0x1083 0x1626 untested *none* Please test! USB SCSI 0x1083 0x1638 untested *none* Please test! USB SCSI 0x1083 0x1624 good *none* Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode USB SCSI 0x04a9 0x1607 good *none* Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported USB SCSI 0x04a9 0x1604 untested *none* Please test! USB SCSI 0x1083 0x1620 good *none* ADF and flatbed work USB SCSI 0x1083 0x1623 untested *none* Assumed compatible with DR-6050C USB SCSI 0x04a9 0x160b good *none* Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported USB SCSI 0x1083 0x1622 good *none* Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode USB SCSI 0x04a9 0x1603 good *none* Simplex, duplex, all resolutions, binary/ht/gray/color, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported USB SCSI 0x1083 0x1618 untested *none* Please test! 0.33 sane-canon_pp http://canon-fb330p.sourceforge.net *none* `http://www.canon.com/' *none* Parport (ECP) *none* *none* unsupported *none* Rebadged Avision, different command set Parport (ECP) *none* *none* unsupported *none* Rebadged Avision, different command set Parport (ECP) *none* *none* basic *none* Newly added support Parport (ECP) *none* *none* basic *none* Newly added support Parport (ECP) *none* *none* good *none* *none* Parport (ECP) *none* *none* good *none* *none* Parport (ECP) *none* *none* good *none* *none* Parport (ECP) *none* *none* good *none* *none* Parport (ECP) *none* *none* good *none* Just an N640P in a different box? 2 sane-cardscan http://www.thebility.com/cardscan/ Backend updated for SANE release 1.0.21, see sane-cardscan manpage `http://www.cardscan.com/' *none* USB 0x08f0 0x0005 good *none* 4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner USB 0x08f0 0x0002 basic *none* 4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner 0.4.3 sane-coolscan http://andreas.rick.free.fr/sane/ *none* `http://www.nikon.com/' *none* SCSI *none* *none* basic *none* The LS-20 has been replaced by the LS-30 SCSI *none* *none* basic *none* alpha: only 24/30 bit RGB + 32/40 bit RGBI SCSI *none* *none* basic *none* alpha: only 24/36 bit + RGB 32/48 bit RGBI SCSI *none* *none* basic *none* Doesn't support gamma correction 0.1.8 sane-coolscan2 http://coolscan2.sourceforge.net/ *none* `http://www.nikon.com/' *none* SCSI *none* *none* complete *none* working -- model available to developer SCSI *none* *none* good *none* *none* USB 0x04b0 0x4000 complete *none* *none* IEEE-1394 *none* *none* good *none* needs linux kernel 2.4.19 or later USB 0x04b0 0x4001 minimal *none* *none* USB 0x04b0 0x4001 minimal unsupported/nikon-ls50-ed.html *none* USB 0x04b0 0x4002 untested unsupported/nikon-ls5000-ed.html May work, similar to LS 50 ED, but untested. Please tell us if it works. IEEE-1394 *none* *none* good *none* needs linux kernel 2.4.19 or later 1.0.0 sane-coolscan3 *none* *none* `http://www.nikon.com/' *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* Rebadged LS 30? USB 0x04b0 0x4000 complete *none* *none* USB 0x04b0 0x4000 complete *none* Rebadged LS 40? USB 0x04b0 0x4001 minimal unsupported/nikon-ls50-ed.html *none* USB 0x04b0 0x4001 minimal unsupported/nikon-ls50-ed.html Rebadged LS 50? SCSI *none* *none* good *none* *none* IEEE-1394 *none* *none* good *none* needs linux kernel 2.4.19 or later USB 0x04b0 0x4002 untested unsupported/nikon-ls5000-ed.html May work, similar to LS 50 ED, but untested. Please tell us if it works. IEEE-1394 *none* *none* good *none* needs linux kernel 2.4.19 or later 1.2 sane-dc25 mailto:peter@fales-lorenz.net *none* `http://www.kodak.com/global/en/service/digCam/dc25/dc25.shtml' *none* Serial port *none* *none* complete *none* *none* Serial port *none* *none* basic *none* DC-20 untested by author but reported to work 0.0 sane-dc210 mailto:peter@fales-lorenz.net *none* `http://www.kodak.com/global/en/service/digCam/dc210/dc210.shtml' *none* Serial port *none* *none* basic *none* *none* 0.0 sane-dc240 mailto:peter@fales-lorenz.net *none* `http://www.kodak.com/global/en/service/products/ekn006568.jhtml' *none* Serial port *none* *none* good *none* Use gphoto2 backend to get USB support *none* *none* *none* *none* `http://www.dell.com/' *none* Ethernet USB 0x413c 0x5250 basic *none* Supports colour and monochrome scans over ethernet (USB not supported) 1.0.13 sane-dll mailto:henning@meier-geinitz.de *none* Dynamic loading of shared-library backends. *none* *none* unmaintained sane-dmc *none* *none* `http://www.polaroid.com/' *none* SCSI *none* *none* good *none* *none* 20 sane-epjitsu http://www.thebility.com/epjitsu/ Backend updated for SANE release 1.0.21, see sane-epjitsu manpage `http://www.fujitsu.com/' *none* USB 0x04c5 0x10c7 basic *none* A6-size flatbed, 300/600 dpi, color/gray/binary USB 0x04c5 0x1156 good *none* Duplex, 150/225/300/600 dpi, color/gray/binary, AC/USB power, buttons/sensors all supported. Scanner always scans in _triplex_ color, fast USB required. USB 0x04c5 0x117f good *none* Same as S300, with different usb id USB 0x04c5 0x1200 unsupported *none* Beta version of backend source available, which works well, but breaks support for other epjitsu scanners. See http://ubuntuforums.org/showthread.php?t=1678335 USB 0x04c5 0x11ed good *none* Same as S300, with different usb id unmaintained sane-epson http://www.khk.net/sane *none* `http://www.epson.com/' *none* SCSI Parport *none* *none* good *none* *none* SCSI Parport *none* *none* good *none* US version of GT-5000 SCSI Parport *none* *none* good *none* *none* SCSI Parport *none* *none* good *none* US version of GT-6000 SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* Parport *none* *none* good *none* *none* Parport *none* *none* good *none* US version of GT-6500 Parport *none* *none* good *none* US version of GT-9000 SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* complete *none* US version of GT-7000 SCSI *none* *none* complete *none* *none* USB 0x04b8 0x0101 complete *none* *none* USB 0x04b8 0x0103 complete *none* *none* USB 0x04b8 0x010c complete *none* *none* SCSI *none* *none* complete *none* *none* USB 0x04b8 0x0104 complete *none* *none* USB 0x04b8 0x0104 complete *none* with TPU SCSI USB 0x04b8 0x010b complete *none* *none* SCSI USB 0x04b8 0x010a complete *none* *none* USB 0x04b8 0x0110 complete *none* *none* USB 0x04b8 0x011e complete *none* *none* USB 0x04b8 0x011b complete *none* *none* USB IEEE-1394 0x04b8 0x0112 complete *none* *none* USB IEEE-1394 0x04b8 0x011c complete *none* US version of the GT-9800 USB 0x04b8 0x0128 complete *none* US version of the GT-X700 USB 0x04b8 0x012a complete *none* US version of the GT-X800 SCSI *none* *none* complete *none* US version of GT-9500 SCSI *none* *none* complete *none* *none* SCSI USB IEEE-1394 0x04b8 0x0107 complete *none* *none* SCSI USB IEEE-1394 0x04b8 0x010e complete *none* *none* SCSI *none* *none* unsupported http://www.vjet.demon.co.uk/scanner/ A better backend for the FilmScan 200 can be found at <A HREF= "http://www.vjet.demon.co.uk/scanner/ ">http://www.vjet.demon.co.uk/scanner/</A> USB 0x04b8 0x0802 good *none* *none* USB 0x04b8 0x080e good *none* *none* USB 0x04b8 0x080e good *none* *none* USB 0x04b8 0x080d good *none* *none* USB 0x04b8 0x0819 good *none* *none* USB 0x04b8 0x082b good *none* *none* USB 0x04b8 0x0801 good *none* *none* USB 0x04b8 0x0801 good *none* *none* USB 0x04b8 0x0808 good *none* *none* USB 0x04b8 0x0805 good *none* *none* USB 0x04b8 0x0805 good *none* *none* USB 0x04b8 0x0813 good *none* *none* USB 0x04b8 0x0813 good *none* *none* USB 0x04b8 0x0807 good *none* *none* USB 0x04b8 0x0806 good *none* *none* USB 0x04b8 0x080f good *none* *none* USB 0x04b8 0x0810 good *none* *none* USB 0x04b8 0x0811 good *none* *none* USB 0x04b8 0x0818 good *none* *none* USB 0x04b8 0x0818 good *none* *none* USB 0x04b8 0x0818 good *none* *none* USB 0x04b8 0x0820 good *none* *none* USB 0x04b8 0x0818 good *none* *none* USB 0x04b8 0x082b good *none* *none* USB 0x04b8 0x082b good *none* *none* USB 0x04b8 0x082e good *none* *none* USB 0x04b8 0x0838 good *none* *none* USB 0x04b8 0x082f good *none* *none* USB 0x04b8 0x0815 good *none* *none* USB 0x04b8 0x0815 good *none* *none* USB IEEE-1394 0x04b8 0x012c good *none* *none* USB IEEE-1394 0x04b8 0x012c good *none* *none* 1.0.124 sane-epson2 *none* *none* `http://www.epson.com/' *none* parallel SCSI *none* *none* good http://www.epson.com/ overseas version of the GT-5000 USB 0x04b8 0x0815 good *none* overseas version of the LP-A500 USB Network 0x04b8 0x0815 good *none* network interface supported<br>AcuLaser CX11 with network interface and fax USB 0x04b8 0x0835 good *none* network interface probably supported USB Network 0x04b8 0x0846 good *none* network interface supported<br>all-in-one<br>overseas version of the EP-801A USB 0x04b8 0x0852 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0844 good *none* network interface probably supported<br>all-in-one<br>overseas version of the EP-901A USB 0x04b8 0x0853 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x010d unsupported *none* all-in-one USB 0x04b8 0x011a unsupported *none* all-in-one USB 0x04b8 0x0802 good *none* all-in-one USB 0x04b8 0x0801 good *none* all-in-one USB 0x04b8 0x0108 unsupported *none* all-in-one USB 0x04b8 0x0850 unsupported *none* supported by the epkowa backend plus non-free interpreter USB Network 0x04b8 0x0846 good *none* network interface supported<br>all-in-one USB 0x04b8 0x0852 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0844 good *none* network interface probably supported<br>all-in-one USB 0x04b8 0x0844 good *none* network interface probably supported<br>all-in-one USB 0x04b8 0x0853 unsupported *none* supported by the epkowa backend plus non-free interpreter SCSI parallel *none* *none* good *none* overseas version of the GT-6000 SCSI *none* *none* good *none* *none* parallel *none* *none* good *none* overseas version of the GT-5400 SCSI *none* *none* good *none* overseas version of the GT-8000 *none* *none* *none* unsupported *none* overseas version of the GT-8500 parallel *none* *none* good *none* overseas version of the GT-9000 SCSI USB 0x04b8 0x0107 complete *none* IEEE1394 untested SCSI USB 0x04b8 0x010e complete *none* IEEE1394 untested SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* IEEE1394 untested SCSI *none* *none* good *none* IEEE1394 untested SCSI USB 0x04b8 0x0126 good *none* network interface unsupported<br>IEEE1394 untested SCSI *none* *none* untested *none* *none* SCSI USB 0x04b8 0x0109 good *none* IEEE1394 untested SCSI *none* *none* good *none* IEEE1394 untested USB 0x04b8 0x0129 good *none* network interface unsupported<br>IEEE1394 untested USB 0x04b8 0x0136 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012b good *none* network interface probably supported USB Ethernet 0x04b8 0x0138 unsupported *none* supported by the epkowa backend plus non-free interpreter SCSI *none* *none* complete *none* overseas version of the GT-9500 SCSI *none* *none* complete *none* overseas version of the GT-9600 SCSI *none* *none* untested *none* overseas version of the ES-8000 SCSI USB 0x04b8 0x0107 complete *none* IEEE1394 untested<br>overseas version of the ES-2000 SCSI USB 0x04b8 0x0109 good *none* IEEE1394 untested<br>overseas version of the ES-8500 SCSI USB 0x04b8 0x010e complete *none* IEEE1394 untested<br>overseas version of the ES-2200 SCSI USB *none* *none* untested *none* IEEE1394 option SCSI USB *none* *none* untested *none* *none* USB 0x04b8 0x0129 good *none* network interface probably supported<br>IEEE1394 untested<br>overseas version of the ES-10000G USB IEEE1394 *none* *none* untested *none* network interface probably supported USB IEEE1394 *none* *none* untested *none* network interface probably supported USB IEEE1394 0x04b8 0x080a unsupported *none* Film scanner USB IEEE1394 *none* *none* unsupported *none* *none* SCSI *none* *none* minimal *none* will be supported USB 0x04b8 0x0133 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0102 unsupported *none* *none* USB 0x04b8 0x012b good *none* network interface probably supported<br>overseas version of the ES-H300 *none* *none* *none* untested *none* *none* parallel SCSI *none* *none* good *none* *none* parallel *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI Parport *none* *none* good *none* *none* parallel *none* *none* good *none* overseas version of the GT-5400 USB 0x04b8 0x0103 complete *none* *none* USB 0x04b8 0x010c complete *none* *none* SCSI *none* *none* complete *none* *none* USB 0x04b8 0x0101 complete *none* *none* USB 0x04b8 0x010f unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x011d unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0120 unsupported *none* supported by the snapscan backend SCSI *none* *none* complete *none* SCSI version of the GT-7600U USB 0x04b8 0x0104 complete *none* USB version of the GT-7600S USB 0x04b8 0x0104 complete *none* GT-7600U with TPU option bundled USB 0x04b8 0x010b complete *none* *none* SCSI *none* *none* good *none* *none* USB 0x04b8 0x0110 complete *none* *none* USB 0x04b8 0x0110 good *none* *none* USB 0x04b8 0x011e complete *none* *none* USB 0x04b8 0x011f unsupported *none* *none* *none* *none* *none* untested *none* *none* SCSI USB 0x04b8 0x010a complete *none* *none* SCSI USB 0x04b8 0x010a good *none* GT-8700U with TPU option bundled parallel *none* *none* good *none* *none* USB 0x04b8 0x011b complete *none* *none* USB 0x04b8 0x0116 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* USB 0x04b8 0x0112 complete *none* IEEE1394 untested USB 0x04b8 0x011c complete *none* IEEE1394 untested SCSI *none* *none* good *none* overseas version of the ES-6000 SCSI *none* *none* good *none* IEEE1394 untested<br>overseas version of the ES-6000H SCSI *none* *none* untested *none* overseas version of the ES-8000 SCSI USB 0x04b8 0x0126 good *none* IEEE1394 untested<br>overseas version of the ES-7000H USB Ethernet 0x04b8 0x0138 unsupported *none* supported by the epkowa backend plus non-free interpreter SCSI *none* *none* good *none* IEEE1394 untested<br>overseas version of the ES-9000H USB 0x04b8 0x0133 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0121 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0122 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0121 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0122 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0118 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012d unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012e unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012f unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0131 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0137 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0136 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012d unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0131 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0128 complete *none* IEEE1394 untested USB 0x04b8 0x0119 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0130 unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012a complete *none* film area guide mode not supported<br>IEEE1394 untested USB 0x04b8 0x013a unsupported http://www.avasys.jp/lx-bin2/linux/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012c good *none* IEEE1394 untested USB 0x04b8 0x0135 good *none* IEEE1394 untested *none* *none* *none* untested *none* business all-in-one; scanner is a ES-7000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-9000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-7000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-9000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-7000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-9000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-9000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-9000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-7000H *none* *none* *none* untested *none* business all-in-one; scanner is a ES-9000H USB Network 0x04b8 0x0815 good *none* network interface supported<br>business all-in-one USB 0x04b8 0x0843 good *none* network interface probably supported<br>business all-in-one USB 0x04b8 0x0817 good *none* network interface probably supported<br>business all-in-one USB 0x04b8 0x0817 good *none* network interface probably supported<br>business all-in-one<br>LP-M5500 with the fax option bundled USB 0x04b8 0x0833 good *none* network interface probably supported<br>business all-in-one USB 0x04b8 0x0834 good *none* network interface probably supported<br>business all-in-one USB 0x04b8 0x0830 good *none* all-in-one USB 0x04b8 0x0841 good *none* all-in-one<br>overseas version of the PX-401A USB 0x04b8 0x084f good *none* all-in-one USB 0x04b8 0x0848 good *none* all-in-one USB 0x04b8 0x0854 good *none* all-in-one USB 0x04b8 0x0847 good *none* network interface probably supported<br>all-in-one<br>overseas version of the PX-601F USB 0x04b8 0x0814 good *none* all-in-one USB 0x04b8 0x081a good *none* all-in-one USB 0x04b8 0x0827 good *none* all-in-one USB 0x04b8 0x083c good *none* all-in-one USB 0x04b8 0x083c good *none* network interface probably supported<br>all-in-one USB 0x04b8 0x0806 good *none* all-in-one USB 0x04b8 0x0811 good *none* all-in-one USB 0x04b8 0x081c good *none* all-in-one USB 0x04b8 0x0810 good *none* all-in-one USB 0x04b8 0x082a good *none* all-in-one USB 0x04b8 0x0837 good *none* all-in-one USB 0x04b8 0x081d good *none* all-in-one USB 0x04b8 0x0828 good *none* all-in-one USB 0x04b8 0x0836 good *none* all-in-one USB 0x04b8 0x0829 good *none* all-in-one<br>PM-A970 with network interface USB 0x04b8 0x0841 good *none* all-in-one USB 0x04b8 0x084d good *none* all-in-one USB 0x04b8 0x084a good *none* network interface probably supported<br>all-in-one USB 0x04b8 0x0856 good *none* all-in-one USB 0x04b8 0x0847 good *none* network interface probably supported USB 0x04b8 0x080e good *none* all-in-one USB 0x04b8 0x082f good *none* all-in-one USB 0x04b8 0x0838 good *none* all-in-one USB 0x04b8 0x0819 good *none* all-in-one USB 0x04b8 0x082e good *none* all-in-one USB 0x04b8 0x0839 good *none* all-in-one USB 0x04b8 0x083a good *none* all-in-one SCSI *none* *none* unsupported *none* supported by the umax backend<br>rebadged UMAX Astra 1200S USB 0x04b8 0x0103 complete *none* overseas version of the GT-6600U SCSI *none* *none* complete *none* overseas version of the GT-7000S USB 0x04b8 0x0101 complete *none* overseas version of the GT-7000U USB 0x04b8 0x010c complete *none* overseas version of the GT-6700U USB 0x04b8 0x0114 unsupported *none* supported by the snapscan backend SCSI *none* *none* complete *none* overseas version of the GT-7600S USB 0x04b8 0x0104 complete *none* overseas version of the GT-7600U USB 0x04b8 0x0104 complete *none* Perfection 1200U with TPU option bundled<br>overseas version of the GT-7600UF USB 0x04b8 0x010b complete *none* overseas version of the GT-7700U USB 0x04b8 0x010f unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x010f unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x011d unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x011d unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0120 unsupported *none* supported by the snapscan backend<br>overseas version of the GT-7400 SCSI *none* *none* unsupported *none* *none* SCSI USB 0x04b8 0x010a complete *none* overseas version of the GT-8700 SCSI USB 0x04b8 0x010a good *none* overseas version of the GT-8700F USB 0x04b8 0x0110 complete *none* overseas version of the GT-8200U USB 0x04b8 0x0110 good *none* overseas version of the GT-8200UF USB 0x04b8 0x011e complete *none* overseas version of the GT-8300UF USB 0x04b8 0x011f unsupported *none* supported by the snapscan backend USB 0x04b8 0x011f unsupported *none* supported by the snapscan backend<br>overseas version of the GT-8400UF USB 0x04b8 0x011b complete *none* overseas version of the GT-9300UF USB IEEE-1394 0x04b8 0x0112 complete *none* overseas version of the GT-9700F USB 0x04b8 0x0121 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0121 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0116 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB IEEE-1394 0x04b8 0x011c complete *none* overseas version of the GT-9800F USB 0x04b8 0x0122 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0122 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0118 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0119 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0128 complete *none* IEEE1394 untested<br>overseas version of the GT-X700 USB 0x04b8 0x012a good *none* film area guide mode not supported<br>IEEE1394 untested<br>overseas version of the GT-X800 USB IEEE1394 *none* *none* untested *none* seems to be a 4990 PHOTO with additional software USB 0x04b8 0x012d unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0131 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012d unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012e unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0131 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012f unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0130 unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x013a unsupported http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x012c good *none* IEEE1394 untested<br>overseas version of the GT-X900 USB 0x04b8 0x012c good *none* IEEE1394 untested<br>overseas version of the GT-X900 USB 0x04b8 0x080c unsupported *none* supported by the snapscan backend<br>all-in-one USB 0x04b8 0x0830 good *none* all-in-one USB 0x04b8 0x0830 good *none* all-in-one USB 0x04b8 0x0802 good *none* all-in-one<br>overseas version of the CC-570L USB 0x04b8 0x0802 good *none* all-in-one<br>overseas version of the CC-570L USB 0x04b8 0x080e good *none* all-in-one<br>overseas version of the PX-A550 USB 0x04b8 0x080e good *none* all-in-one<br>overseas version of the PX-A550 USB 0x04b8 0x080e good *none* all-in-one USB 0x04b8 0x0818 good *none* all-in-one USB 0x04b8 0x0818 good *none* all-in-one USB *none* *none* untested *none* all-in-one USB 0x04b8 0x082f good *none* all-in-one<br>overseas version of the PX-A620 USB 0x04b8 0x0820 good *none* all-in-one USB 0x04b8 0x0820 good *none* all-in-one USB 0x04b8 0x083f unsupported http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x083f unsupported http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x080d good *none* all-in-one USB 0x04b8 0x080d good *none* all-in-one USB 0x04b8 0x0819 good *none* all-in-one<br>overseas version of the PX-A650 USB 0x04b8 0x0819 good *none* all-in-one<br>overseas version of the PX-A650 USB 0x04b8 0x082b good *none* all-in-one USB 0x04b8 0x082b good *none* all-in-one USB 0x04b8 0x0801 good *none* all-in-one<br>overseas version of the CC-600PX USB 0x04b8 0x0801 good *none* all-in-one<br>overseas version of the CC-600PX USB 0x04b8 0x0808 good *none* all-in-one USB 0x04b8 0x0808 good *none* all-in-one USB 0x04b8 0x083f unsupported http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x083f unsupported http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0821 unsupported *none* may work with the snapscan backend<br>all-in-one with FAX USB 0x04b8 0x0821 unsupported *none* may work with the snapscan backend<br>all-in-one with FAX USB 0x04b8 0x082e good *none* all-in-one<br>overseas version of the PX-A720 USB 0x04b8 0x082e good *none* all-in-one<br>overseas version of the PX-A720 USB 0x04b8 0x0805 good *none* all-in-one<br>mistakenly thinks its a PX-A650 USB 0x04b8 0x0805 good *none* all-in-one<br>mistakenly thinks its a PX-A650 USB 0x04b8 0x0813 good *none* all-in-one USB 0x04b8 0x0813 good *none* all-in-one USB 0x04b8 0x0831 unsupported *none* may work with the snapscan backend<br>all-in-one with FAX USB 0x04b8 0x0831 unsupported *none* may work with the snapscan backend<br>all-in-one with FAX USB 0x04b8 0x0838 good *none* all-in-one<br>overseas version of the PX-A640 USB 0x04b8 0x0838 good *none* all-in-one<br>overseas version of the PX-A640 USB 0x04b8 0x081f good *none* all-in-one USB 0x04b8 0x081f good *none* all-in-one USB 0x04b8 0x0839 good *none* all-in-one<br>overseas version of the PX-A740 USB 0x04b8 0x0839 good *none* all-in-one<br>overseas version of the PX-A740 USB 0x04b8 0x083a good *none* all-in-one<br>overseas version of the PX-FA700 USB 0x04b8 0x083a good *none* all-in-one<br>overseas version of the PX-FA700 USB 0x04b8 0x0818 good *none* all-in-one USB *none* *none* good *none* all-in-one USB 0x04b8 0x082f good *none* all-in-one<br>overseas version of the PX-A620 USB 0x04b8 0x0820 good *none* all-in-one USB 0x04b8 0x083f unsupported http://www.avasys.jp/lx-bin2/linux_e/spc/DL1.do supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0819 good *none* all-in-one<br>overseas version of the PX-A650 USB 0x04b8 0x0819 good *none* all-in-one<br>DX4800 + card reader USB 0x04b8 0x082b good *none* all-in-one USB 0x04b8 0x082e good *none* all-in-one<br>overseas version of the PX-A720 USB 0x04b8 0x0831 unsupported *none* may work with the snapscan backend<br>all-in-one with FAX USB 0x04b8 0x0838 good *none* all-in-one<br>overseas version of the PX-A640 USB 0x04b8 0x0839 good *none* all-in-one<br>overseas version of the PX-A740 USB 0x04b8 0x083a good *none* all-in-one<br>overseas version of the PX-FA700 USB 0x04b8 0x0848 good *none* all-in-one USB 0x04b8 0x0854 good *none* all-in-one USB 0x04b8 0x0847 good *none* network interface probably supported<br>all-in-one<br>overseas version of the PX-601F USB 0x04b8 0x0855 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0848 good *none* all-in-one USB 0x04b8 0x0854 good *none* all-in-one USB 0x04b8 0x0847 good *none* network interface probably supported<br>all-in-one<br>overseas version of the PX-601F USB 0x04b8 0x0855 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0850 unsupported *none* supported by the epkowa backend plus non-free interpreter USB Network 0x04b8 0x0846 good *none* network interface supported<br>all-in-one<br>overseas version of the EP-801A USB 0x04b8 0x0852 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0844 good *none* network interface probably supported<br>all-in-one<br>overseas version of the EP-901A USB 0x04b8 0x0853 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x080f good *none* all-in-one USB 0x04b8 0x080f good *none* all-in-one USB 0x04b8 0x080f good *none* all-in-one USB 0x04b8 0x0807 good *none* all-in-one USB 0x04b8 0x0807 good *none* all-in-one USB 0x04b8 0x081a good *none* all-in-one<br>overseas version of the PM-A750 USB 0x04b8 0x081a good *none* all-in-one<br>overseas version of the PM-A750 USB 0x04b8 0x0827 good *none* all-in-one<br>overseas version of the PM-A820 USB 0x04b8 0x083c good *none* all-in-one<br>overseas version of the PM-A840 USB 0x04b8 0x0827 good *none* all-in-one<br>overseas version of the PM-A820 USB 0x04b8 0x083c good *none* all-in-one<br>overseas version of the PM-A840 USB 0x04b8 0x0827 good *none* all-in-one<br>overseas version of the PM-A820 USB 0x04b8 0x0806 good *none* all-in-one<br>overseas version of the PM-A850 USB 0x04b8 0x083c good *none* all-in-one<br>overseas version of the PM-A840 USB 0x04b8 0x0811 good *none* all-in-one<br>overseas version of the PM-A870 USB 0x04b8 0x0811 good *none* all-in-one<br>overseas version of the PM-A870 USB 0x04b8 0x081c good *none* all-in-one<br>overseas version of the PM-A890 USB 0x04b8 0x081c good *none* all-in-one<br>overseas version of the PM-A890 USB 0x04b8 0x0837 good *none* all-in-one<br>overseas version of the PM-A940 USB 0x04b8 0x0837 good *none* all-in-one<br>overseas version of the PM-A940 USB 0x04b8 0x0837 good *none* all-in-one<br>overseas version of the PM-A940 USB 0x04b8 0x0810 good *none* all-in-one<br>overseas version of the PM-A900 USB 0x04b8 0x0850 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0846 good *none* network interface probably supported<br>all-in-one<br>overseas version of the EP-801A USB 0x04b8 0x0852 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0844 good *none* network interface probably supported<br>all-in-one<br>overseas version of the EP-901A USB 0x04b8 0x0841 good *none* all-in-one<br>overseas version of the PX-401A USB 0x04b8 0x084d good *none* all-in-one<br>overseas version of the PX-402A USB 0x04b8 0x0849 good *none* all-in-one USB 0x04b8 0x084f good *none* all-in-one USB 0x04b8 0x0848 good *none* all-in-one USB 0x04b8 0x084a good *none* network interface probably supported<br>all-in-one<br>overseas version of the PX-501A USB 0x04b8 0x0851 good *none* network interface probably supported<br>all-in-one USB 0x04b8 0x0856 good *none* all-in-one<br>overseas version of the PX-502A USB 0x04b8 0x0841 good *none* all-in-one<br>overseas version of the PX-401A USB 0x04b8 0x084d good *none* all-in-one<br>overseas version of the PX-402A USB 0x04b8 0x085c untested *none* all-in-one USB 0x04b8 0x0849 good *none* all-in-one USB 0x04b8 0x0849 good *none* all-in-one USB 0x04b8 0x084f good *none* all-in-one USB 0x04b8 0x084a good *none* network interface probably supported<br>all-in-one<br>overseas version of the PX-501A USB 0x04b8 0x084a good *none* all-in-one USB 0x04b8 0x0851 good *none* network interface probably supported<br>all-in-one USB 0x04b8 0x0856 good *none* all-in-one<br>overseas version of the PX-502A USB 0x04b8 0x0847 good *none* network interface probably supported<br>all-in-one<br>overseas version of the PX-601F USB 0x04b8 0x0855 unsupported *none* supported by the epkowa backend plus non-free interpreter USB 0x04b8 0x0105 untested *none* apparently mostly the same as the Stylus Scan 2500 USB 0x04b8 0x0106 untested *none* scanner is apparently a GT-7000 USB 0x04b8 0x0841 good *none* all-in-one<br>overseas version of the PX-401A USB 0x04b8 0x084d good *none* all-in-one<br>overseas version of the PX-402A USB 0x04b8 0x0849 good *none* all-in-one USB 0x04b8 0x0849 good *none* all-in-one USB 0x04b8 0x0849 good *none* all-in-one USB 0x04b8 0x084f good *none* all-in-one USB 0x04b8 0x084a good *none* network interface probably supported<br>all-in-one<br>overseas version of the PX-501A USB 0x04b8 0x0851 good *none* network interface probably supported<br>all-in-one USB 0x04b8 0x0856 good *none* all-in-one<br>overseas version of the PX-502A USB 0x04b8 0x0854 good *none* all-in-one USB 0x04b8 0x084c good *none* all-in-one USB 0x04b8 0x0847 good *none* network interface probably supported<br>all-in-one<br>overseas version of the PX-601F USB 0x04b8 0x0855 unsupported *none* supported by the epkowa backend plus non-free interpreter 117 sane-fujitsu http://www.thebility.com/fujitsu/ Backend updated for SANE release 1.0.23, see sane-fujitsu manpage `http://www.fujitsu.com/' *none* SCSI *none* *none* complete http://www.remote.org/frederik/projects/software/sane/ small, old, discontinued SCSI *none* *none* complete *none* small, old, discontinued SCSI USB 0x04c5 0x1041 complete *none* small, recent, discontinued, usb 1.1 SCSI USB 0x04c5 0x10ae complete *none* small, recent, discontinued, usb 2.0 SCSI USB 0x04c5 0x1042 complete *none* small, recent, discontinued, usb 1.1 SCSI USB 0x04c5 0x10af complete *none* small, recent, discontinued, usb 2.0 USB 0x04c5 0x1097 complete *none* small, recent, discontinued USB 0x04c5 0x1096 complete *none* small, recent, discontinued USB 0x04c5 0x10e6 complete *none* small, recent, discontinued USB 0x04c5 0x10f2 complete *none* small, recent, discontinued SCSI USB 0x04c5 0x10e0 complete *none* small, recent, discontinued SCSI USB 0x04c5 0x10e1 complete *none* small, recent, discontinued Ethernet *none* *none* untested *none* Not a scanner, rather a scanner to ethernet interface Ethernet *none* *none* untested *none* small, recent, discontinued, integrated touchscreen and keyboard USB 0x04c5 0x10fe complete *none* small, recent, discontinued USB 0x04c5 0x1135 complete *none* small, recent, discontinued USB 0x04c5 0x1155 complete *none* small, recent, discontinued USB 0x04c5 0x116f complete *none* small, recent, discontinued USB 0x04c5 0x114f complete *none* small, recent, discontinued USB 0x04c5 0x1150 complete *none* small, recent, discontinued USB 0x04c5 0x11a2 complete *none* small, discontinued USB 0x04c5 0x11a2 complete *none* small, discontinued, same as S1500 Ethernet *none* *none* untested *none* small, current, integrated touchscreen and keyboard Ethernet *none* *none* untested *none* small, current, integrated touchscreen and keyboard USB 0x04c5 0x11fc complete *none* small, current USB 0x04c5 0x11f3 complete *none* small, current USB 0x04c5 0x11f4 complete *none* small, current USB WiFi 0x04c5 0x132b good *none* small, current, WiFi not supported. Hardware only scans in color. Backend generates binary and grayscale modes. RS232C/Video *none* *none* unsupported *none* medium, old, discontinued RS232C/Video *none* *none* unsupported *none* medium, old, discontinued SCSI *none* *none* complete *none* medium, old, discontinued RS232C/Video *none* *none* unsupported *none* medium, old, discontinued SCSI *none* *none* complete *none* medium, old, discontinued RS232C/Video *none* *none* unsupported *none* medium, old, discontinued SCSI *none* *none* complete *none* medium, old, discontinued RS232C/Video *none* *none* unsupported *none* medium, old, discontinued SCSI *none* *none* complete *none* medium, old, discontinued RS232C/Video *none* *none* unsupported *none* medium, old, discontinued SCSI *none* *none* complete *none* medium, old, discontinued SCSI USB 0x04c5 0x10cf complete *none* medium, current SCSI USB 0x04c5 0x1078 complete *none* medium, recent, discontinued SCSI *none* *none* complete *none* medium, recent, discontinued SCSI *none* *none* complete *none* medium, recent, discontinued SCSI USB 0x04c5 0x10e2 complete *none* medium, recent, discontinued SCSI USB 0x04c5 0x114d complete *none* medium, recent, discontinued SCSI USB 0x04c5 0x114e complete *none* medium, recent, discontinued SCSI USB 0x04c5 0x114a complete *none* medium, current SCSI USB 0x04c5 0x11f1 complete *none* medium, current SCSI USB 0x04c5 0x11f2 complete *none* medium, current RS232C/Video *none* *none* unsupported *none* big, old, discontinued SCSI *none* *none* complete *none* big, old, discontinued RS232C/Video *none* *none* unsupported *none* big, old, discontinued SCSI *none* *none* complete *none* big, old, discontinued RS232C/Video *none* *none* unsupported *none* big, old, discontinued SCSI *none* *none* complete *none* big, old, discontinued SCSI *none* *none* complete *none* big, old, discontinued SCSI *none* *none* complete *none* big, old, discontinued SCSI *none* *none* complete *none* big, recent, discontinued SCSI *none* *none* complete *none* big, recent, discontinued SCSI *none* *none* complete *none* big, recent, discontinued SCSI *none* *none* complete *none* big, recent, discontinued SCSI USB 0x04c5 0x10ad complete *none* big, recent, discontinued SCSI USB 0x04c5 0x1095 complete *none* big, recent, discontinued SCSI USB 0x04c5 0x10e7 good *none* big, recent, discontinued. Independent ultrasonic control and multistream unsupported USB 0x04c5 0x1178 untested *none* Simplex, USB only version of fi-6770, won't wakeup via software, discontinued SCSI USB 0x04c5 0x1213 untested *none* big, current. Faster version of fi-5900? SCSI USB 0x04c5 0x1176 good *none* big, current, won't wakeup via software SCSI USB 0x04c5 0x1177 good *none* big, current, VRS CGA board unsupported, won't wakeup via software SCSI USB 0x04c5 0x1174 good *none* big, current, won't wakeup via software SCSI USB 0x04c5 0x1175 good *none* big, current, VRS CGA board unsupported, won't wakeup via software SCSI USB 0x04c5 0x119d untested *none* big, current. Independent ultrasonic control and multistream unsupported SCSI USB 0x04c5 0x119e untested *none* big, current. VRS CGA board unsupported, Independent ultrasonic control and multistream unsupported 1.0-63 sane-genesys http://www.meier-geinitz.de/sane/genesys-backend/ Only the USB scanners mentioned below are currently supported. `http://www.plustek.de/' `http://www.plustek.com/' *none* USB 0x07b3 0x0900 basic *none* Has a Primax USB ID `http://www.medion.com/' `http://www.medion.de/' *none* USB 0x0461 0x0377 good *none* Has a Primax USB ID USB 0x0461 0x0377 good *none* Has a Primax USB ID. Same as MD5345 USB 0x0461 0x0377 complete *none* Has a Primax USB ID. Same as MD5345 `http://www.hp.com/' *none* USB 0x03f0 0x0901 complete *none* 600x1200 dpi max USB 0x03f0 0x0a01 complete *none* 1200x1200 dpi max USB 0x03f0 0x0a01 basic *none* clone of the HP 2400C USB 0x03f0 0x1405 complete *none* 1200x1200 dpi max, complete transparency adaptor support USB 0x03f0 0x1405 complete *none* 1200x1200 dpi max, same as HP 3670 USB 0x03f0 0x1b05 untested *none* resolution from 100 to 2400 supported, UTA not supported yet USB 0x03f0 0x4505 good *none* resolution from 100 to 2400 supported, UTA not supported yet USB 0x03f0 0x4605 good *none* resolution from 100 to 2400 supported, UTA not supported yet USB 0x03f0 0x4705 untested *none* Not supported yet `http://www.canon.com/' *none* USB 0x04a9 0x2213 good *none* Same ids as LiDE 50. USB 0x04a9 0x2213 good *none* Same ids as LiDE 50. USB 0x04a9 0x2213 good *none* *none* USB 0x04a9 0x221c good *none* *none* USB 0x04a9 0x1904 complete *none* GL847 based, resolution from 75 to 2400 dpi USB 0x04a9 0x1909 complete *none* GL124 based, resolution from 75 to 2400 dpi USB 0x04a9 0x1905 complete *none* GL847 based, resolution from 75 to 4800 dpi USB 0x04a9 0x190a complete *none* GL124 based, resolution from 75 to 2400 dpi USB 0x04a9 0x2228 unsupported *none* GL843 based, to be added to the genesys backend USB 0x04a9 0x1906 unsupported *none* GL847 based, to be added to the genesys backend USB 0x04a9 0x1907 good *none* GL847 based, resolution from 75 to 4800 dpi USB 0x1083 0x162e unsupported *none* GL846 based, work in progress `http://www.visioneer.com/' *none* USB 0x04a7 0x049b good *none* All resolution and mode supported, calibration is available USB 0x04a7 0x0426 good *none* All resolution and mode supported, calibration is available USB 0x04a7 0x0474 good *none* All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally. USB 0x04a7 0x0494 basic *none* All resolution and mode supported, calibration is available USB 0x04a7 0x0229 complete *none* Same as MD5345 `http://www.pentaxtech.com/' `http://mobilesolutions.brother-usa.com/' *none* USB 0x0a17 0x3210 good *none* All resolution and mode supported, calibration is available USB 0x04f9 0x2038 good *none* All resolution and mode supported, calibration is available `http://www.docucap.com/' Successor of Syscan in the USA USB 0x1dcc 0x4810 basic *none* All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally. *none* *none* USB 0x0a82 0x4810 basic *none* All resolution and mode supported, front- and backside side-by-side, with backside mirrored horizontally. USB 0x0a82 0x4802 untested *none* All resolution and mode should be supported, but uncorrected scans USB 0x0a82 0x4803 basic *none* All resolution and mode supported, calibration is available USB 0x0a82 0x480c good *none* All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally. `http://www.xerox.com/' *none* USB 0x04a7 0x04ac good *none* All resolution and mode supported, calibration is available USB 0x0461 0x038b complete *none* GL646 based, resolution from 75 to 2400 dpi *none* *none* USB 0x04da 0x100f complete *none* All resolution and mode supported, calibration is available. Support sponsored by cncsolutions (http://www.cncsolutions.com.br) 0.0 sane-gphoto2 mailto:peter@fales-lorenz.net *none* Multiple cameras supported by the gphoto2 libraries http://www.gphoto.org The long-term plan is to support all the cameras supported by the gphoto2 libraries (currently over 140 models). However, at this stage, only a handful of cameras are definitely known to work with SANE. Other cameras will probably work if the native file format is EXIF or JPEG. Testers welcome! 1.0-84 sane-gt68xx http://www.meier-geinitz.de/sane/gt68xx-backend/ Only the USB scanners mentioned below are supported. For other Mustek BearPaws, look at the Plustek and the MA-1509 backend. `http://www.artecusa.com/' *none* USB 0x05d8 0x4002 good *none* Works, only product id 0x4002 is supported USB 0x05d8 0x4002 good *none* Works, however 12 bit mode doesn't seem to be supported *none* *none* USB 0x05d8 0x4002 good *none* Similar to Artec Ultima 2000 `http://www.fujitsu.com/' *none* USB 0x05d8 0x4002 basic *none* Works, but is slow. Probably a Mustek BearPaw 2400 CU clone. `http://www.genius-kye.com/' *none* USB 0x0458 0x201e untested *none* Untested but should work. USB 0x0458 0x2021 basic *none* *none* USB 0x0458 0x2011 good *none* *none* USB 0x0458 0x2011 good *none* Same as Colorpage Vivid3x USB 0x0458 0x2017 good *none* *none* USB 0x0458 0x2014 good *none* *none* USB 0x0458 0x201b good *none* *none* USB 0x0458 0x201a good *none* *none* USB 0x0458 0x201d good *none* *none* USB 0x0458 0x201f good *none* *none* *none* *none* USB 0x05d8 0x4002 good *none* Same as Artec Ultima 2000. `http://www.lexmark.com/' *none* USB 0x043d 0x002d good *none* Works, some resolutions fail at 16 bit USB 0x043d 0x002d good *none* Works, some resolutions fail at 16 bit, same as X70 `http://www.medion.com' Sold by Aldi and Tchibo. USB 0x05d8 0x4002 good *none* Product id 0x4002. If you have 0x4003, use artec_eplus48u backend. USB 0x05d8 0x4002 untested *none* Untested, but is reported to have the same ids as the Artec Ultima 2000. Please test. USB 0x05d8 0x4002 good *none* Similar to Artec Ultima 2000 USB 0x05d8 0x4002 good *none* Similar to Mustek ScanExpress 1200 UB Plus USB 0x05d8 0x4002 good *none* Similar to Artec Ultima 2000 (e+?) `http://www.mustek.com/' `http://www.mustek.com.tw/' `http://www.mustek.de/' *none* USB 0x055f 0x021e good *none* *none* USB 0x05d8 0x4002 good *none* *none* USB 0x055f 0x021b good *none* *none* USB 0x055f 0x021c good *none* *none* USB 0x055f 0x021e good *none* Transparency adapter supported USB 0x055f 0x021c good *none* Seems to use the same ids as BearPaw 1200 CU Plus. USB 0x055f 0x0218 untested *none* Probably works, reports are welcome USB 0x055f 0x0219 good *none* Works, problems with 12/16 bit modes? USB 0x05d8 0x4002 basic *none* Works, but is slow USB 0x055f 0x021d good *none* *none* USB 0x055f 0x0218 good *none* Transparency adapter supported USB 0x055f 0x0219 good *none* Transparency adapter supported USB 0x055f 0x021a basic *none* Slow. Same as 2448 TA Plus, but without TA. USB 0x055f 0x021a basic *none* Slow. Transparency adapter supported. Slow. Brightness depends on resolution? USB 0x055f 0x0219 good *none* Works but is slow in high resolutions. Same as BearPaw 2400 TA Plus. USB 0x055f 0x0219 good *none* Works but is slow in high resolutions. Same as BearPaw 2400 CS Plus. USB 0x05d8 0x4002 good *none* *none* USB 0x055f 0x021f complete *none* *none* USB 0x05d8 0x4002 minimal *none* Should be detected but may need some more work in the code. Testers welcome. Please contact me if you own this scanner. USB 0x055f 0x0210 basic *none* Still some vertical stripes. USB 0x05d8 0x4002 good *none* Same as ScanExpress 1200 UB Plus *none* *none* USB 0x07b3 0x0412 untested *none* Similar to Plustek OpticSlim M12. Please tell us if this scanner works. USB 0x07b3 0x0462 basic *none* Similar to Plustek OpticSlim M12. *none* *none* USB 0x07b3 0x040b untested *none* Untested. Please test. Similar to Plustek OpticPro S12? *none* *none* USB 0x05d8 0x4002 good *none* Similar to Mustek BearPaw 1200 (Plus) USB 0x055f 0x021c good *none* Similar to Mustek BearPaw 1200 Plus USB 0x055f 0x021b good *none* Similar to Mustek BearPaw 1200 Plus USB 0x055f 0x0219 good *none* *none* `http://www.plustek.de/' `http://www.plustek.com/' *none* USB 0x07b3 0x0400 good *none* *none* USB 0x07b3 0x0401 good *none* *none* USB 0x07b3 0x0402 good *none* *none* USB 0x07b3 0x0403 good *none* *none* USB 0x07b3 0x0403 untested *none* Probably works. Transparency adapter not supported yet. Please contact me if you own such a device. USB 0x07b3 0x040b good *none* Product ID 0x040b only. USB 0x07b3 0x040e good *none* Product ID 0x040e only. Is reported to work. USB 0x07b3 0x040b untested *none* Product ID 0x040b only. Needs testing. Transparency adapter completely untested. Please contact me if you own such a scanner. USB 0x07b3 0x0413 good *none* *none* USB 0x07b3 0x0422 good *none* Works up to 1200 dpi. USB 0x07b3 0x0454 good *none* Same as OpticSlim 2400. USB 0x07b3 0x045f complete *none* Works up to 1200 dpi. Calibration with external calibration sheet supported USB 0x07b3 0x0412 complete *none* Works up to 1200 dpi. Calibration with external calibration sheet supported *none* *none* USB 0x07b3 0x0400 good *none* Similar to Plustek OpticPro 1248U `http://www.trust-site.com' *none* USB 0x055f 0x0218 good *none* Same as Mustek Bearpaw 2400 TA plus. USB 0x05d8 0x4002 good *none* Works, if you have vendor id 0x055f and product id 0x0006, use the mustek_usb backend instead, similar to Mustek ScanExpress 1200 UB (Plus) USB 0x055f 0x021c good *none* Same as Mustek BearPaw 1200 CU Plus (0x021c). USB 0x05d8 0x4002 good *none* Similar to Artec Ultima 2000 `http://www.visioneer.com/' *none* USB 0x04a7 0x0444 good *none* Works upto 1200 dpi and 12 bits/color. 1.06 sane-hp http://www.kirchgessner.net/ *none* `http://www.hp.com/' *none* Propietary *none* *none* complete *none* Driver for HP parallel interface card required SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* USB 0x03f0 0x0101 complete *none* *none* SCSI *none* *none* complete *none* *none* Parport *none* *none* complete *none* Requires ppscsi driver and epst module Parport USB 0x03f0 0x0401 complete *none* Parallel interface requires ppscsi driver and epst module SCSI *none* *none* complete *none* *none* SCSI USB 0x03f0 0x0201 complete *none* *none* SCSI USB 0x03f0 0x0201 complete *none* *none* SCSI USB 0x03f0 0x0601 complete *none* *none* SCSI USB 0x03f0 0x0601 complete *none* *none* SCSI USB 0x03f0 0x0601 complete *none* *none* SCSI *none* *none* complete *none* *none* 1.1 sane-hp3500 http://projects.troy.rollo.name/rt-scanners/ HP3500 series scanners. `http://www.hp.com' *none* USB 0x03f0 0x2205 good *none* *none* USB 0x03f0 0x2005 good *none* *none* USB 0x03f0 0x2005 good *none* *none* 0.12 sane-hp3900 http://sourceforge.net/projects/hp3900-series/ Still Beta `http://www.hp.com' *none* USB 0x03f0 0x2605 basic *none* Works with resolutions equal and less than 600dpi USB 0x03f0 0x2305 good *none* *none* USB 0x03f0 0x2405 good *none* *none* USB 0x03f0 0x4105 basic *none* Works with resolutions lower than 1200dpi USB 0x03f0 0x2805 basic *none* Similar to hp scanjet 3800 USB 0x03f0 0x4205 basic *none* Similar to hp scanjet 4370 USB 0x03f0 0x4305 basic *none* Similar to hp scanjet 4370 `http://www.umax.com' *none* USB 0x06dc 0x0020 minimal *none* developing yet `http://www.benq.com/' *none* USB 0x04a5 0x2211 minimal *none* developing yet 1.0-2 sane-hp4200 http://hp4200-backend.sourceforge.net *none* `http://www.hp.com/' *none* USB 0x03f0 0x0105 basic *none* 8bpp color, 75/150/300/600 dpi only USB 0x03f0 0x0105 basic *none* 8bpp color, 75/150/300/600 dpi only USB 0x03f0 0x0105 basic *none* 8bpp color, 75/150/300/600 dpi only 1.0-2 sane-hp5400 http://sourceforge.net/projects/hp5400backend HP5400 and HP5470 scanners. Prototype backend available `http://www.hp.com' *none* USB 0x03f0 0x1005 basic *none* *none* USB 0x03f0 0x1105 basic *none* *none* USB *none* *none* basic *none* *none* 1.0.5 sane-hp5590 *none* *none* `http://www.hp.com' *none* USB 0x03f0 0x1205 complete *none* Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives USB 0x03f0 0x1305 complete *none* Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives USB 0x03f0 0x1305 untested *none* Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives USB 0x03f0 0x1205 complete *none* Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives USB 0x03f0 0x1705 complete *none* Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives USB 0x03f0 0x1805 complete *none* Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives 0 sane-hpljm1005 *none* *none* `http://www.hp.com' *none* USB 0x03f0 0x3b17 good *none* grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI USB 0x03f0 0x5617 good *none* grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI USB 0x03f0 0x5717 good *none* grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI 0.03 sane-hpsj5s http://hpsj5s.sourceforge.net/ *none* `http://www.hp.com/' *none* Parport (EPP) *none* *none* minimal *none* Requires libieee1284 library. Only gray mode. 1.00 sane-hs2p http://www.acjlaw.net:8080/~jeremy/Ricoh/ This backend has been tested with the IS450DE (Duplex/Endorser). All major functions necessary for scanning are supported. This backend should work with all Ricoh scanners in the IS450 family as well as the IS420 series, but the IS420 has not yet been tested. Features provided by the optional Image Processing Unit (IPU) are not yet integrated into the backend, as my scanner lacks the IPU. `http://www.ricoh.com/' *none* SCSI *none* *none* complete *none* All major scanning-related features are supported (except for IPU). Certain non-scanning features, such as those related to scanner maintenance, are not supported. Such features would be better implemented in a separate stand-alone tool. For instance, if you replace the ADF Unit, you must recalibrate the scanner optics using a Ricoh Test Sheet and reset the E^2PROM registers. Reports are welcome. SCSI *none* *none* untested *none* Untested, please report! SCSI *none* *none* untested *none* Untested, please report! SCSI *none* *none* untested *none* Untested, please report! 1.0-4 sane-ibm http://www.meier-geinitz.de/sane/ibm-backend/ This backend has had only limited testing. It needs more work especially for the Ricoh scanners. Patches are welcome. `http://www.ibm.com/' *none* SCSI *none* *none* basic *none* Was reported to work long time ago. Reports are welcome. *none* *none* SCSI *none* *none* untested *none* Untested, please report! SCSI *none* *none* basic *none* Works at least in flatbed mode. SCSI *none* *none* untested *none* Untested, please report! 7 sane-kodak http://www.thebility.com/kodak/ New backend for SANE release 1.0.21, see sane-kodak manpage `http://www.kodak.com/' *none* SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! SCSI *none* *none* untested *none* Please test! IEEE-1394 *none* *none* untested *none* Please test! IEEE-1394 *none* *none* basic *none* Uncompressed B&W, Gray and Color, some automatic features supported SCSI *none* *none* untested *none* Please test! 2.4.6 sane-kodakaio http://sourceforge.net/projects/cupsdriverkodak/ Backend for Kodak AiO ESP and Hero printers. Also possibly Advent AWL10 `http://www.kodak.com/' *none* USB 0x040a 0x4059 untested *none* Please test! USB 0x040a 0x4066 untested *none* Please test! USB 0x040a 0x4043 untested *none* Please test! USB 0x040a 0x4031 untested *none* Please test! USB 0x040a 0x4053 untested *none* Please test! USB 0x040a 0x4028 untested *none* Please test! USB 0x040a 0x4025 untested *none* Please test! USB Ethernet 0x040a 0x4041 basic *none* USB good, Network good USB 0x040a 0x4026 untested *none* Please test! USB 0x040a 0x4027 untested *none* Please test! USB 0x040a 0x4054 untested *none* Please test! USB 0x040a 0x4056 untested *none* Please test! USB 0x040a 0x4065 untested *none* Please test! USB 0x040a 0x4032 untested *none* Please test! USB 0x040a 0x403e untested *none* Please test! USB 0x040a 0x403f untested *none* Please test! USB 0x040a 0x4057 untested *none* Please test! USB 0x040a 0x4058 untested *none* Please test! USB 0x040a 0x405d untested *none* Please test! USB 0x040a 0x405e untested *none* Please test! USB 0x040a 0x406d untested *none* Please test! USB 0x040a 0x4064 untested *none* Please test! USB 0x040a 0x4062 untested *none* Please test! USB 0x040a 0x4063 untested *none* Please test! USB Ethernet 0x040a 0x4067 basic *none* USB good, Network good `http://www.adventcomputers.co.uk' *none* USB 0x040a 0x4060 untested *none* Please test! unmaintained sane-kvs20xx *none* New backend for SANE release 1.0.22, see sane-kvs20xx manpage `http://www.panasonic.com/' *none* SCSI *none* *none* untested *none* *none* USB SCSI 0x04da 0x1000 untested *none* *none* USB 0x04da 0x100a untested *none* *none* SCSI *none* *none* untested *none* *none* USB SCSI 0x04da 0x1001 untested *none* *none* USB 0x04da 0x1009 untested *none* *none* unmaintained sane-kvs40xx *none* New backend for SANE release 1.0.23, see sane-kvs40xx manpage `http://www.panasonic.com/' *none* USB 0x04da 0x100d untested *none* *none* USB 0x04da 0x100c untested *none* *none* USB 0x04da 0x100e untested *none* *none* unmaintained sane-kvs1025 *none* New backend for SANE release 1.0.21, see sane-kvs1025 manpage `http://www.panasonic.com/' *none* USB 0x04da 0x1007 good *none* *none* USB 0x04da 0x1006 good *none* *none* USB 0x04da 0x1010 good *none* *none* 1.0-10 sane-leo http://www.zago.net/sane/#leo *none* *none* *none* SCSI *none* *none* good *none* FCC ID LUZFS1130 *none* *none* SCSI *none* *none* good *none* FCC ID LUZFS1130 *none* *none* SCSI *none* *none* good *none* *none* 1.0-0 sane-lexmark http://stef.dev.free.fr/sane/lexmark This backend supports lexmark x1100 series scanners. `http://www.lexmark.com/' *none* USB 0x043d 0x007c untested *none* *none* USB 0x043d 0x007c good *none* Supports 75, 150, 300, 600 dpi USB 0x043d 0x007c untested *none* *none* USB 0x043d 0x007c good *none* Supports 75, 150, 300, 600 dpi USB 0x043d 0x007c good *none* Supports 75, 150, 300, 600 dpi USB 0x043d 0x007c good *none* *none* USB 0x043d 0x007c good *none* Tested with xscanimage. Supports 75, 150, 300, 600, 1200(600x1200) dpi resolutions. Does grayscale or colour scans in the following sizes: wallet, 3x5, 4x6, 5x7, 8x10, letter. USB 0x043d 0x007c untested *none* *none* USB 0x043d 0x0060 good *none* Supports 75, 150, 300, 600 dpi USB 0x043d 0x007d good *none* USB1.1 is OK, USB2.0 needs testing *none* *none* USB 0x413c 0x5105 good *none* Relabelled X11xx model 1.0-3 sane-ma1509 http://www.meier-geinitz.de/sane/ma1509-backend/ *none* `http://www.mustek.com/' `http://www.mustek.com.tw/' `http://www.mustek.de/' *none* USB 0x055f 0x0010 good *none* Works upto 600 dpi. No support for TA and ADF yet. `http://www.fujitsu.com/' *none* USB 0x04c5 0x1040 unsupported *none* Uses ma1509 chip, but very different from other scanners supported by the ma1509 backend 1.0.0 sane-magicolor http://wiki.kainhofer.com/hardware/magicolor_scan *none* `http://www.konicaminolta.com/' *none* USB Network 0x132b 0x2089 good http://www.konicaminolta.eu/business-solutions/products/laser-printers/all-in-one/magicolor-1690mf/key-features.html Multi-function color laser printer with fax, scanner and network interface USB Network *none* *none* unsupported *none* Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov. USB Network *none* *none* unsupported *none* Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov. 1.0-7 sane-matsushita http://www.zago.net/sane *none* `http://www.panasonic.com/' *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* minimal *none* no color, no high resolution, no automatic cropping SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* minimal *none* no color, no high resolution, no automatic cropping SCSI *none* *none* minimal *none* no color, no high resolution, no automatic cropping SCSI *none* *none* minimal *none* no color, no high resolution, no automatic cropping 0.13.1 sane-microtek http://www.mir.com/mtek/ *none* `http://www.microtek.com/' *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* 3-pass SCSI *none* *none* good *none* slide-scanner SCSI *none* *none* good *none* slide-scanner SCSI *none* *none* good *none* slide-scanner SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* 3-pass SCSI *none* *none* good *none* gray only SCSI *none* *none* good *none* 3-pass SCSI *none* *none* untested *none* *none* SCSI *none* *none* basic *none* gray only (see manpage) SCSI (Parport) *none* *none* basic *none* sheet-fed (preliminary, see mapage) `http://www.agfa.com/' *none* SCSI *none* *none* good *none* Arcus *II*, not Arcus! SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* minimal *none* Is detected but scans are very dark SCSI *none* *none* basic *none* *none* `http://www.vobis.de/' *none* SCSI *none* *none* good *none* *none* `http://www.genius-kye.com/' *none* SCSI *none* *none* good *none* Same as Microtek Scanmaker E3 unmaintained sane-microtek2 http://karstenfestag.gmxhome.de/linux.html *none* `http://www.microtek.com/' *none* Parport *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* basic *none* *none* USB 0x05da 0x0099 good *none* *none* SCSI *none* *none* good *none* *none* Parport *none* *none* good *none* *none* SCSI *none* *none* basic *none* *none* Parport *none* *none* basic *none* *none* SCSI *none* *none* basic *none* *none* Parport *none* *none* basic *none* *none* SCSI *none* *none* basic *none* *none* SCSI *none* *none* basic *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* good *none* only flatbed mode ? IEEE-1394 *none* *none* minimal unsupported/microtek-scanmaker-9800.html IEEE-1394 seems to work. See link. More reports welcome. Parport *none* *none* complete *none* *none* Parport *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* Parport *none* *none* complete *none* *none* USB 0x05da 0x009a complete *none* *none* USB 0x05da 0x00b6 basic *none* Sometimes scan speed goes to fast and results look badly smudged. SCSI *none* *none* complete *none* *none* USB 0x05da 0x00a3 complete *none* *none* USB 0x05da 0x80a3 complete *none* *none* SCSI *none* *none* good *none* only Flatbed mode ? `http://www.vobis.de/' *none* SCSI *none* *none* complete *none* only E3plus based models `http://www.scanport.com/' *none* Parport? *none* *none* basic *none* *none* Parport *none* *none* basic *none* *none* SCSI *none* *none* basic *none* *none* `http://www.geniusmouse.co.uk/' *none* Parport *none* *none* good *none* *none* 1.0-138 sane-mustek http://www.meier-geinitz.de/sane/mustek-backend/ Most Mustek SCSI scanners are supported by this backend. For USB scanners, look at the mustek_usb backend. `http://www.mustek.com/' `http://www.mustek.com.tw/' `http://www.mustek.de/' *none* SCSI *none* *none* good *none* 3-pass SCSI *none* *none* good *none* 3-pass SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* Parport *none* *none* untested *none* Completely untested. If it's the same as the 600 II EP, it may work. Please contact me if you own such a device. Parport *none* *none* minimal *none* Works, however only low resolutions and quality in color mode is bad. SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* untested *none* One report that it crashes the computer. SCSI driver issue? Please contact me if you own such a device. SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* complete *none* *none* SCSI *none* *none* basic *none* Please test! SCSI *none* *none* good *none* *none* SCSI *none* *none* complete *none* ADF and TA untested. Please contact me if you own such equipment. Proprietary *none* *none* basic *none* Resolutions above 300 dpi may cause trouble. `http://www.trust-site.com' Carefully check the model names. Trust uses similar names for completely different hardware. SCSI *none* *none* good *none* 3-pass, Mustek Paragon MFS-6000CX compatible SCSI *none* *none* complete *none* Mustek Paragon MFS-6000SP compatible SCSI *none* *none* complete *none* Mustek Paragon 600 II CD compatible SCSI *none* *none* complete *none* Mustek ScanExpress 12000SP compatible SCSI *none* *none* complete *none* Mustek ScanExpress 12000SP compatible `http://www.primax.nl/' *none* SCSI *none* *none* complete *none* Mustek 600 II CD compatible 13 sane-mustek_pp http://penguin-breeder.org/sane/mustek_pp/ Supports CIS and CCD type parallel port scanners from Mustek. `http://www.mustek.com/' `http://www.mustek.com.tw/' `http://www.mustek.de/' *none* Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner Parport (EPP) *none* *none* good *none* 300x600 dpi CIS scanner Parport (EPP) *none* *none* good *none* 300x600 dpi CIS scanner Parport (EPP) *none* *none* good *none* 300x600 dpi CIS scanner Parport (EPP) *none* *none* good *none* 600x1200 dpi CIS scanner Parport (EPP) *none* *none* good *none* 600x1200 dpi CIS scanner `http://www.medion.de/' Those scanners are also known as "Aldi Scanner " or "Tchibo Scanners " Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner Parport (EPP) *none* *none* good *none* 600x1200 dpi CIS scanner Parport (EPP) *none* *none* good *none* 600x1200 dpi CIS scanner Parport (EPP) *none* *none* good *none* 600x1200 dpi CIS scanner *none* *none* Parport (EPP) *none* *none* good *none* 600x1200 dpi CIS scanner Parport (EPP) *none* *none* good *none* 300x600 dpi CIS scanner `http://www.trust-site.com/home/' *none* Parport (EPP) *none* *none* good *none* 300x600 dpi CIS scanner Parport (EPP) *none* *none* good *none* 300x600 dpi CIS scanner *none* *none* Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner *none* *none* Parport (EPP) *none* *none* good *none* CIS scanner *none* *none* Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner *none* *none* Parport (EPP) *none* *none* good *none* 300 dpi CCD scanner *none* *none* Parport (EPP) *none* *none* good *none* 300x600 dpi CIS scanner 1.0-18 sane-mustek_usb http://www.meier-geinitz.de/sane/mustek_usb-backend/ Only the USB scanners mentioned below are supported. For BearPaws, look at the Plustek, MA-1509, and gt68xx backends. `http://www.mustek.com/' `http://www.mustek.com.tw/' `http://www.mustek.de/' *none* USB 0x055f 0x0002 complete *none* *none* USB 0x055f 0x0001 complete *none* *none* USB 0x055f 0x0008 complete *none* *none* USB 0x055f 0x0006 complete *none* For the UB Plus, see gt68xx backend `http://www.trust-site.com' *none* USB 0x055f 0x0006 complete *none* Mustek 1200 UB compatible 1.0-10 sane-mustek_usb2 http://www.meier-geinitz.de/sane/mustek_usb2-backend/ Only BearPaw 2448TA Pro is supported at the moment `http://www.mustek.com/' `http://www.mustek.com.tw/' `http://www.mustek.de/' *none* USB 0x055f 0x0409 good *none* *none* 0.12 sane-nec http://www5a.biglobe.ne.jp/~saetaka/ *none* `http://www.nevt.co.jp/' *none* SCSI *none* *none* good *none* PC-IN500/4C was sold only in JAPAN 1.0.14 sane-net http://www.penguin-breeder.org/?page=sane-net *none* Network access to saned servers *none* Can be used to access any scanner supported by SANE over the net. Supports IPv4 and IPv6. 0.3 sane-niash http://sourceforge.net/projects/hp3300backend *none* `http://www.hp.com' *none* USB 0x03f0 0x0205 complete *none* *none* USB 0x03f0 0x0405 complete *none* If you use Linux 2.6, version 2.6.8 or newer is necessary. USB 0x03f0 0x0305 complete *none* If you use Linux 2.6, version 2.6.8 or newer is necessary. USB 0x047b 0x1002 complete *none* If you use Linux 2.6, version 2.6.8 or newer is necessary. `http://www.agfa.com' *none* USB 0x06bd 0x0100 complete *none* *none* `http://www.trust.com' *none* USB 0x047b 0x1000 complete *none* *none* 1 sane-p5 http://www.sane-project.org/ New backend for SANE release 1.0.21, see sane-p5 manpage `http://www.primax.com.tw' *none* Parport (EPP/ECP) *none* *none* basic *none* Sheetfed scanner, work in gray and color, but uncalibrated scans 1.0 sane-pie http://www.munton.demon.co.uk/sane *none* `http://www.blackwidow.co.uk/' *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* `http://www.scanace.com/' *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* SCSI *none* *none* untested *none* *none* *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* untested *none* *none* unmaintained sane-pint *none* *none* Scanners with the machine-independent PINT interface *none* Haven't been tested for a long time. Handle with care. 0.17.3 sane-pixma http://home.arcor.de/wittawat/pixma/ http://mp610.blogspot.com/ *none* `http://www.canon.com/' *none* USB 0x04a9 0x1758 untested *none* Testers needed! USB 0x04a9 0x1761 untested *none* Testers needed! USB 0x04a9 0x175a untested *none* Testers needed! USB 0x04a9 0x1767 untested *none* Testers needed! USB 0x04a9 0x1751 complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1760 untested *none* Testers needed! USB WLAN 0x04a9 0x1752 complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1762 untested *none* Testers needed! USB 0x04a9 0x1753 untested *none* Testers needed! USB 0x04a9 0x1763 complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1748 complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1749 complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1754 complete *none* All resolutions supported (up to 2400DPI). USB 0x04a9 0x1764 untested *none* Testers needed! USB 0x04a9 0x174a complete *none* All resolutions supported (up to 2400 DPI) USB 0x04a9 0x1755 complete *none* All resolutions supported (up to 4800 DPI) USB Ethernet 0x04a9 0x1765 complete *none* All resolutions supported (up to 2400DPI). USB 0x04a9 0x174b untested *none* Testers needed! USB Ethernet 0x04a9 0x1756 complete *none* All resolutions supported (up to 4800DPI). USB 0x04a9 0x172b complete *none* All resolutions supported (up to 600 DPI) USB 0x04a9 0x1709 good *none* *none* USB 0x04a9 0x1714 basic *none* *none* USB 0x04a9 0x170a complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1715 basic *none* *none* USB 0x04a9 0x1734 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x1721 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x1722 complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x175f complete *none* All resolutions supported (up to 600DPI). USB 0x04a9 0x1732 complete *none* All resolutions supported (up to 1200DPI) USB 0x04a9 0x173a complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x1733 complete *none* All resolutions supported (up to 1200DPI) USB 0x04a9 0x173b complete *none* All resolutions supported (up to 1200DPI) USB 0x04a9 0x1746 good *none* All resolutions supported (up to 600DPI). USB 0x04a9 0x263c complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x263d complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x263f untested *none* Same protocol as Pixma MP360/370/390? Testers needed! USB 0x04a9 0x263e complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x170b complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1716 complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1723 complete *none* All resolutions supported (up to 2400DPI). USB 0x04a9 0x1731 complete *none* All resolutions supported (up to 2400DPI) USB 0x04a9 0x173c complete *none* All resolutions supported (up to 1200DPI) USB 0x04a9 0x1757 untested *none* Testers needed! USB 0x04a9 0x1747 untested *none* Same protocol as Pixma MP280? Testers needed! USB 0x04a9 0x170c good *none* *none* USB 0x04a9 0x1717 complete *none* All resolutions supported (up to 1200DPI). USB 0x04a9 0x1724 complete *none* All resolutions supported (up to 2400DPI) USB 0x04a9 0x1712 good *none* *none* USB 0x04a9 0x1730 complete *none* All resolutions supported (up to 2400DPI) USB 0x04a9 0x173d complete *none* All resolutions supported (up to 2400DPI) USB 0x04a9 0x173e complete *none* All resolutions supported (up to 2400DPI) USB 0x04a9 0x1718 complete *none* All resolutions supported (up to 2400DPI) USB Ethernet 0x04a9 0x1719 complete *none* All resolutions supported (up to 2400DPI) USB 0x04a9 0x1725 complete *none* All resolutions supported (up to 4800DPI) USB Ethernet 0x04a9 0x172f complete *none* All resolutions supported (up to 2400DPI) USB 0x04a9 0x172e complete *none* All resolutions supported (up to 4800DPI) USB Ethernet 0x04a9 0x173f complete *none* All resolutions supported (up to 4800DPI) USB 0x04a9 0x2630 complete *none* All resolutions supported (flatbed color up to 1200DPI, grayscale up to 600DPI). USB 0x04a9 0x264d complete *none* All resolutions supported (up to 1200DPI) USB 0x04a9 0x262f good *none* Flatbed color up to 1200DPI, grayscale up to 600DPI. ADF scan to be confirmed. USB 0x04a9 0x264c untested *none* Same protocol as Pixma MP710? Testers needed! USB 0x04a9 0x1706 minimal *none* No grayscale. Canceling scan in ADF mode doesn't eject the paper! USB 0x04a9 0x1708 minimal *none* No grayscale. The scanner sometimes hangs! USB 0x04a9 0x1708 minimal *none* No grayscale. The scanner sometimes hangs! USB 0x04a9 0x1707 minimal *none* No grayscale. The scanner sometimes hangs! USB 0x04a9 0x1707 minimal *none* No grayscale. The scanner sometimes hangs! USB 0x04a9 0x170d complete *none* All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI. USB 0x04a9 0x170e complete *none* All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI. USB 0x04a9 0x171a complete *none* All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI. USB 0x04a9 0x1713 complete *none* All resolutions supported up to 2400DPI. Flatbed, ADF simplex and Duplex supported. USB 0x04a9 0x171b complete *none* All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI. USB Ethernet 0x04a9 0x1726 complete *none* All resolutions supported (up to 4800DPI). Full TPU support (negative and slides) at 24 or 48 bits. USB Ethernet 0x04a9 0x172d complete *none* Working fine at all resolutions. USB Ethernet 0x04a9 0x1740 complete *none* Working fine at all resolutions. USB 0x04a9 0x1727 complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x1728 complete *none* Flatbed and ADF scan. All resolutions supported (up to 1200DPI) USB 0x04a9 0x1736 untested *none* Same protocol as Pixma Generation 3? Testers needed! USB 0x04a9 0x1737 complete *none* Flatbed and ADF scan. All resolutions supported (up to 1200DPI) USB 0x04a9 0x1741 complete *none* Flatbed and ADF scan. All resolutions supported (up to 1200DPI) USB Ethernet 0x04a9 0x1742 complete *none* Flatbed and ADF scan. All resolutions supported (up to 1200DPI) USB 0x04a9 0x174d complete *none* Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy. USB 0x04a9 0x1759 complete *none* Flatbed and ADF scan. All resolutions supported (up to 1200DPI). USB 0x04a9 0x1766 untested *none* Testers needed! USB Ethernet 0x04a9 0x174e untested *none* Same protocol as Pixma MX420? Testers needed! USB Ethernet 0x04a9 0x174f complete *none* Flatbed and ADF scan. All resolutions supported (up to 1200DPI). ADF empty buggy. USB Ethernet 0x04a9 0x175b untested *none* Testers needed! USB 0x04a9 0x1768 untested *none* Testers needed! USB Ethernet 0x04a9 0x175c untested *none* Testers needed! USB 0x04a9 0x1769 untested *none* Testers needed! USB Ethernet 0x04a9 0x1729 complete *none* Flatbed and ADF scan. All resolutions supported (up to 2400DPI) USB Ethernet 0x04a9 0x175d untested *none* Testers needed! USB 0x04a9 0x176a untested *none* Testers needed! USB Ethernet 0x04a9 0x172c complete *none* All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported. USB Ethernet 0x04a9 0x1735 complete *none* All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported. USB Ethernet 0x04a9 0x1743 complete *none* All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. USB Ethernet 0x04a9 0x1750 complete *none* All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. USB Ethernet 0x04a9 0x1750 complete *none* All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. USB Ethernet 0x04a9 0x1750 complete *none* All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. USB Ethernet 0x04a9 0x175e complete *none* All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported, ADF empty buggy. USB 0x04a9 0x176b untested *none* Testers needed! USB Ethernet 0x04a9 0x171c complete *none* Flatbed and ADF scan. All resolutions supported (up to 4800DPI) USB 0x04a9 0x26ef complete *none* All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported. USB 0x04a9 0x26ed complete *none* All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported. USB Ethernet 0x04a9 0x2759 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x2660 complete *none* All resolutions supported (up to 600DPI). USB 0x04a9 0x2684 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x26b4 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x26b4 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x26a3 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x26a3 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x26a3 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x26a3 complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x26b5 complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x26ee complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x26ee complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x26ee complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x26ec good *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported USB 0x04a9 0x26ec good *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported USB 0x04a9 0x2737 complete *none* All resolutions supported (up to 600DPI) USB 0x04a9 0x2737 good *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI). ADF empty buggy. USB 0x04a9 0x2736 good *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI). USB 0x04a9 0x26b0 complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x26b0 complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x264e untested *none* Testers needed! USB 0x04a9 0x264f untested *none* Testers needed! USB 0x04a9 0x265d complete *none* Flatbed and ADF scan. All resolutions supported (up to 1200DPI). USB 0x04a9 0x265e untested *none* Testers needed! USB 0x04a9 0x265f complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI). USB 0x04a9 0x26f9 untested *none* Testers needed! USB 0x04a9 0x2686 complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x2686 complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x26fa untested *none* Testers needed! USB 0x04a9 0x2707 untested *none* Testers needed! USB 0x04a9 0x2659 untested *none* Testers needed! USB 0x04a9 0x26e6 complete *none* Flatbed and ADF scan. All resolutions supported (up to 600DPI) USB 0x04a9 0x1901 complete *none* Flatbed scan. TPU for negatives and slides. All resolutions supported (up to 4800DPI). USB 0x04a9 0x1908 complete *none* Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI. USB 0x04a9 0x190d complete *none* Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI. 0.52 sane-plustek http://www.gjaeger.de/scanner/plustek/ *none* `http://www.plustek.de/' `http://www.plustek.com/' *none* USB 0x07b3 0x0010 complete *none* NOTE: Devices with product ID 0x0001 are not supported! USB 0x07b3 0x0013 complete *none* *none* USB 0x07b3 0x0017 complete *none* Note: Devices with product ID 0x0001 are not supported! USB 0x07b3 0x0017 complete *none* *none* USB 0x07b3 0x0011 complete *none* *none* USB 0x07b3 0x0015 complete *none* *none* USB 0x07b3 0x0017 complete *none* *none* `http://www.geniusnet.com.tw/' *none* USB 0x0458 0x2007 complete *none* *none* USB 0x0458 0x2008 complete *none* *none* USB 0x0458 0x2013 complete *none* *none* USB 0x0458 0x2009 untested *none* *none* USB 0x0458 0x2015 untested *none* *none* USB 0x0458 0x2016 untested *none* *none* `http://www.mustek.com/' *none* USB 0x0400 0x1000 complete *none* both product versions are supported, see backends' man-page USB 0x0400 0x1001 complete *none* both product versions are supported, see backends' man-page USB 0x0400 0x1001 complete *none* *none* `http://www.hp.com/' *none* USB 0x03f0 0x0505 complete *none* *none* USB 0x03f0 0x0605 complete *none* *none* `http://www.epson.com/' *none* USB 0x04b8 0x010f complete *none* *none* USB 0x04b8 0x010f good *none* TPA scans not perfect USB 0x04b8 0x011d complete *none* *none* USB 0x04b8 0x011d good *none* TPA scans not perfect `http://www.umax.com/' *none* USB 0x1606 0x0050 complete *none* there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x USB 0x1606 0x0060 complete *none* there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x USB 0x1606 0x0060 complete *none* seems to be a renamed UMAX 3400 USB 0x1606 0x0060 complete *none* *none* USB 0x1606 0x0160 complete *none* *none* `http://www.compaq.com/' *none* USB 0x049f 0x001a complete *none* Identical to UMAX 3400 `http://www.canon.com/' *none* USB 0x04a9 0x2206 complete *none* *none* USB 0x04a9 0x2207 complete *none* *none* USB 0x04a9 0x220d complete *none* *none* USB 0x04a9 0x220e complete *none* *none* USB 0x04a9 0x2220 good *none* *none* USB 0x04a9 0x2208 good *none* TPA scans not perfect `http://www.syscaninc.com/' *none* USB 0x0a82 0x4600 complete *none* *none* USB 0x0a82 0x6620 complete *none* *none* *none* *none* USB 0x0a82 0x4600 complete *none* Rebaged Travelscan 464 `http://www.pandp.com.tw/' *none* USB 0x0a53 0x1000 complete *none* *none* USB 0x0a53 0x2000 good *none* *none* `http://www.visioneer.com/' *none* USB 0x04a7 0x0427 basic *none* *none* 0.43 sane-plustek_pp http://www.gjaeger.de/scanner/plustek_pp/ *none* `http://www.plustek.de/' `http://www.plustek.com/' *none* Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* use driver-switch mov=1 Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* reported as OpticPro 12000P/96000P Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* use driver-switch mov=4 Parport (SPP, EPP) *none* *none* complete *none* use driver-switch mov=3 Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* basic *none* use driver-switch mov=5, poor picture quality Parport *none* *none* untested *none* *none* Parport (SPP, EPP) *none* *none* complete *none* *none* Parport (SPP, EPP) *none* *none* complete *none* *none* `http://www.primax.nl/' *none* Parport (SPP, EPP) *none* *none* untested *none* same as OpticPro 4800P Parport (SPP, EPP) *none* *none* complete *none* use driver-switch mov=2 Parport (SPP, EPP) *none* *none* complete *none* same as OpticPro 4830P, use driver-switch mov=7 Parport (SPP, EPP) *none* *none* complete *none* same as OpticPro 9630P `http://www.geniusnet.com.tw/' *none* Parport (SPP, EPP) *none* *none* complete *none* Reported as PT12 Parport (SPP, EPP) *none* *none* complete *none* Reported as OP9636T/12000T Parport (SPP, EPP) *none* *none* good *none* Negative scanning does not work correctly *none* *none* Parport (SPP, EPP) *none* *none* complete *none* use driver-switch mov=2 *none* *none* Parport (SPP, EPP) *none* *none* complete *none* Reported as P12 1.0.8 sane-pnm mailto:henning@meier-geinitz.de *none* Reads PNM files *none* Used for debugging frontends. Obsolete, use test backend instead. unmaintained sane-qcam *none* *none* *none* *none* Parport *none* *none* good *none* Requires root privileges. Parport *none* *none* minimal *none* Requires root privileges. Partly working. unmaintained sane-ricoh *none* *none* `http://www.ricoh.com/' *none* SCSI *none* *none* basic *none* *none* SCSI *none* *none* basic *none* *none* 1.0-0 sane-rts8891 http://stef.dev.free.fr/sane/rts8891/index.html This backend supports Realtek RTS8891 ASIC bases scanners. `http://www.umax.com.tw/' *none* USB 0x1606 0x0070 good *none* Supports 75, 150, 300, 600 and 1200 dpi USB 0x1606 0x0070 untested *none* *none* `http://www.hp.com/' *none* USB 0x03f0 0x0805 good *none* re-branded Astra 4400 USB 0x03f0 0x0705 good *none* exists with 2 different sensors of which only one works unmaintained sane-s9036 *none* *none* `http://www.siemens.com/' *none* SCSI *none* *none* basic *none* *none* 1.0-10 sane-sceptre http://www.zago.net/sane/ *none* `http://www.sceptre.com/' *none* SCSI *none* *none* basic *none* *none* `http://www.komodo.com/' *none* SCSI *none* *none* untested *none* rebadged Sceptre S1200 0.32 sane-sharp http://www.satzbau-gmbh.de/staff/abel/sane-sharp.html *none* `http://sharp-world.com/' *none* SCSI *none* *none* good *none* SCSI *none* *none* good *none* SCSI *none* *none* good *none* SCSI *none* *none* untested *none* SCSI *none* *none* good *none* SCSI *none* *none* good *none* 0.1 sane-sm3600 http://sm3600.sourceforge.net/ *none* `http://www.microtek.com/' *none* USB 0x05da 0x40b3 basic *none* works USB 0x05da 0x40ca basic *none* works USB 0x05da 0x40ff basic *none* works USB 0x05da 0x40b8 basic *none* works USB 0x05da 0x40cb basic *none* works USB 0x05da 0x40dd basic *none* works (told) 1.1 sane-sm3840 http://www.ziplabel.com/sm3840/ This reverse-engineered backend supports the USB ScanMaker 3840 model `http://www.microtek.com/' Microtek makes a wide variety of devices. USB 0x05da 0x30d4 good *none* 8 and 16 bit, color and grayscale USB 0x05da 0x30cf good *none* Same hardware as SM3840, different color box 1.4 sane-snapscan http://snapscan.sourceforge.net/ Supported bit depths: 24 bit (color), 48 bit (color, Epson) 8 bit (gray) `http://www.agfa.com/' *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* Optional ADF supported. SCSI *none* *none* good *none* Optional transparency unit supported. SCSI *none* *none* good *none* Optional ADF and transparency unit supported. USB 0x06bd 0x0002 good *none* Optional ADF and transparency unit supported. USB 0x06bd 0x0001 good *none* *none* USB 0x06bd 0x2061 good *none* *none* USB 0x06bd 0x2093 good *none* *none* USB 0x06bd 0x2091 good *none* *none* USB 0x06bd 0x2095 good *none* *none* USB 0x06bd 0x2097 good *none* *none* USB 0x06bd 0x208d good *none* *none* USB 0x06bd 0x20ff good *none* *none* USB 0x06bd 0x208f good *none* Optional tranparency unit supported USB 0x06bd 0x20fd good *none* Optional tranparency unit supported USB *none* *none* untested *none* *none* *none* Company was renamed to <a href= "#BENQ ">Benq</a>. *none* Company was renamed to <a href= "#BENQ ">Benq</a>. `http://www.benq.com' Formerly Acer Peripherals SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* USB 0x04a5 0x1a20 good *none* *none* USB 0x04a5 0x2022 good *none* *none* USB 0x04a5 0x2022 good *none* *none* USB 0x04a5 0x1a2a good *none* Optional tranparency unit supported USB 0x04a5 0x2040 good *none* Optional tranparency unit supported USB 0x04a5 0x2060 good *none* Optional tranparency unit supported USB 0x04a5 0x207e good *none* *none* USB 0x04a5 0x20be good *none* Optional tranparency unit supported USB 0x04a5 0x20c0 good *none* Optional tranparency unit supported USB 0x04a5 0x20b0 good *none* *none* USB 0x04a5 0x20de good *none* *none* USB 0x04a5 0x20b0 good *none* *none* USB 0x04a5 0x20de good *none* *none* USB 0x04a5 0x20fc basic *none* Same as 5000U, working up to 600 DPI USB 0x04a5 0x20fc basic *none* Same as 5000E, working up to 600 DPI USB 0x04a5 0x20f8 good *none* USB ID 0x04a5,0x20f8: Color / grayscale scans working up to 1200 DPI USB 0x04a5 0x2137 basic *none* Calibration algorithm unknown USB 0x04a5 0x2137 basic *none* Same hardware as 5150 (?), Calibration algorithm unknown USB 0x04a5 0x20fe basic *none* Problems with firmware upload reported `http://www.guillemot.com' *none* SCSI *none* *none* good *none* Rebadged SnapScan 310s. USB 0x04a5 0x20de good *none* Rebadged Benq 3300. USB 0x04a5 0x2060 good *none* Rebadged Benq 640U. USB 0x04a5 0x2060 good *none* Rebadged Benq 620U, needs Benq firmware file u96v???.bin `http://www.mitsubishi.com' *none* USB 0x04a5 0x2022 good *none* Rebadged Benq 320u. USB 0x04a5 0x20b0 good *none* Rebadged Benq 4300. `http://www.epson.com' *none* USB 0x04b8 0x0114 good *none* *none* USB 0x04b8 0x0120 good *none* *none* USB 0x04b8 0x011f good *none* *none* USB 0x04b8 0x0121 good *none* *none* USB 0x04b8 0x0121 basic *none* Film scanning unit unsupported USB 0x04b8 0x0122 good *none* *none* USB 0x04b8 0x0122 basic *none* Film scanning unit unsupported USB 0x04b8 0x080c good *none* *none* unmaintained sane-sp15c *none* *none* `http://www.fcpa.fujitsu.com/products/scanners/' `http://www.fujitsu.com/' *none* SCSI *none* *none* good *none* *none* SCSI *none* *none* good *none* *none* 1.6 sane-st400 http://www.informatik.uni-oldenburg.de/~ingo/sane/ *none* `http://www.siemens.de/' *none* SCSI *none* *none* basic *none* 6 bit gray SCSI *none* *none* basic *none* 6 bit gray 1.0-1 sane-stv680 http://gkall.hobby.nl/stv680-aiptek.html This vidcam backend is for the stv0680 chipset, See the website for more info. `http://www.aiptek.com.tw' *none* USB 0x0553 0x0202 minimal *none* image is OK for CIF and QCIF, VGA and QVGA untested, streaming video is a problem `http://www.konicaminolta.com' *none* USB 0x04c8 0x0722 untested *none* `http://www.digitaldreamco.com/en/index.shtml' *none* USB 0x1183 0x0001 untested *none* `http://www.creative.com/' *none* USB 0x041e 0x4007 untested *none* unmaintained sane-tamarack *none* *none* *none* *none* SCSI *none* *none* good *none* 3 pass, 300 DPI SCSI *none* *none* good *none* 3 pass, 400 DPI SCSI *none* *none* good *none* 3 pass, 600 DPI 1.0-10 sane-teco1 http://www.zago.net/sane/#teco *none* `http://www.relisys.com/' `http://www.tecoimage.com.tw/' *none* SCSI *none* *none* complete *none* sub model VM3530+ SCSI *none* *none* complete *none* sub model VM3520 SCSI *none* *none* good *none* sub model VM4542 SCSI *none* *none* complete *none* sub model VM3520+ SCSI *none* *none* untested *none* sub model VM4530 SCSI *none* *none* untested *none* sub model VM4530+ SCSI *none* *none* untested *none* sub model VM3420 SCSI *none* *none* untested *none* sub model VM3440 SCSI *none* *none* untested *none* sub model VM3530 SCSI *none* *none* complete *none* sub model VM4540 SCSI *none* *none* untested *none* sub model VM6530 SCSI *none* *none* untested *none* sub model VM6530* SCSI *none* *none* untested *none* sub model VM6530+ SCSI *none* *none* untested *none* sub model VM6540 *none* *none* SCSI *none* *none* untested *none* sub model VM3520A *none* *none* SCSI *none* *none* good *none* sub model VM3510 SCSI *none* *none* untested *none* sub model VM3530+ SCSI *none* *none* untested *none* sub model VM4542 SCSI *none* *none* untested *none* sub model VM6530+ 1.0-9 sane-teco2 http://gkall.hobby.nl/teco2.html *none* `http://www.relisys.com/' *none* SCSI *none* *none* untested *none* sub model VM3575 SCSI *none* *none* good *none* sub model VM3564 SCSI *none* *none* good *none* sub model VM3575 SCSI *none* *none* basic *none* sub model VM356A SCSI *none* *none* good *none* sub model VM6565 SCSI *none* *none* good *none* sub model VM6575 SCSI *none* *none* untested *none* sub model VM6586 `http://www.primax.nl/' *none* SCSI *none* *none* good *none* sub model VM356A SCSI *none* *none* basic *none* sub model VM6575 SCSI *none* *none* good *none* sub model VM6586 `http://www.mustek.com/' *none* SCSI *none* *none* untested *none* sub model VM3575 1.0-1 sane-teco3 http://www.zago.net/sane/#teco3 *none* `http://www.tecoimage.com.tw/' *none* SCSI *none* *none* good *none* sub model VM3552 *none* *none* SCSI *none* *none* untested *none* sub model VM3552 `http://www.image-land.com/' *none* SCSI *none* *none* good *none* sub model VM3552 *none* *none* SCSI *none* *none* good *none* sub model VM3552 SCSI *none* *none* good *none* sub model VM3552 SCSI *none* *none* untested *none* sub model VM3552 1.0-28 sane-test http://www.meier-geinitz.de/sane/test-backend/ *none* Frontend-tester *none* Backend for testing frontends. Also serves as example for SANE backend options. 0.02 sane-u12 http://www.gjaeger.de/scanner/u12/ *none* `http://www.plustek.de/' `http://www.plustek.com/' *none* USB 0x07b3 0x0001 basic *none* Note: Only devices with product ID 0x0001 are supported! USB 0x07b3 0x0001 basic *none* Note: Only devices with product ID 0x0001 are supported! USB 0x07b3 0x0001 basic *none* *none* *none* *none* USB 0x07b3 0x0001 basic *none* Rebadged Plustek OpticPro UT12 `http://www.geniusnet.com.tw/' *none* USB 0x0458 0x2004 basic *none* *none* USB 0x07b3 0x0001 untested *none* Note: Device has Plustek vendor and product ID (0x07b3/0x0001) 1.0-41 sane-umax http://www.rauch-domain.de/sane-umax/index.html *none* `http://www.umax.com/' `http://www.umax.com.tw/' `http://www.umax.de/en' `http://www.umax-europe.com' `http://www.umaxjapan.co.jp' `http://www.umax.com.cn' *none* SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK USB 0x1606 0x0230 good *none* OK, needs USB control messages SCSI *none* *none* good *none* OK IEEE-1394 *none* *none* unsupported *none* will probably work one day IEEE-1394 *none* *none* unsupported *none* will probably work one day SCSI *none* *none* good *none* OK USB *none* *none* good *none* OK, needs USB control messages SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK, SCSI-ID=PS-2400X SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* unsupported *none* incompatible SCSI *none* *none* unsupported *none* incompatible IEEE-1394 *none* *none* unsupported *none* will probably work one day SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* untested *none* may work, please test and give feedback SCSI *none* *none* good *none* OK for some firmwareversions, on others only lineart OK SCSI *none* *none* good *none* Version 2.8 OK, others only lineart OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* OK SCSI *none* *none* good *none* Version 1.6 OK, others only lineart OK SCSI *none* *none* untested *none* may work, please test and give feedback SCSI *none* *none* good *none* Version 3.0 OK, others unknown SCSI *none* *none* good *none* Version 1.6 OK, others unknown `http://www.heidelberg.com/' *none* SCSI *none* *none* good *none* OK, SCSI-ID=LinoHell Office SCSI *none* *none* good *none* OK, SCSI-ID=LinoHell JADE SCSI *none* *none* good *none* OK, SCSI-ID=LinoHell Office2 SCSI *none* *none* untested *none* support disabled until tested - please contact author SCSI *none* *none* good *none* OK, SCSI-ID=LinoHell SAPHIR2 SCSI *none* *none* good *none* OK, SCSI-ID=LinoHell SAPHIR3 SCSI *none* *none* untested *none* support disabled until tested - please contact author SCSI *none* *none* good *none* OK, SCSI-ID=Linotype SAPHIR4 SCSI *none* *none* untested *none* support disabled until tested - please contact author SCSI *none* *none* untested *none* support disabled until tested - please contact author SCSI *none* *none* good *none* OK; SCSI-ID=LinoHell OPAL2 SCSI *none* *none* untested *none* support disabled until tested - please contact author SCSI *none* *none* good *none* OK, SCSI-ID=HDM LS4H1S `http://www.vobis.de/' *none* SCSI *none* *none* good *none* OK, SCSI-ID=LinoHell Office2 *none* *none* SCSI *none* *none* untested *none* no feedback `http://www.epson.com/' *none* SCSI *none* *none* good *none* OK, SCSI-ID=EPSON Perfection600 *none* *none* SCSI *none* *none* good *none* OK, SCSI-ID=UMAX UG 80 *none* *none* SCSI *none* *none* untested *none* untested, SCSI-ID=ESCORT Galleria 600S *none* *none* SCSI *none* *none* good *none* OK, SCSI-ID=KYE ColorPage-HR5 `http://www.nikon.com/' *none* SCSI *none* *none* untested *none* may work, please test and give feedback SCSI *none* *none* good *none* OK `http://www.nikon.com/' *none* SCSI *none* *none* good *none* OK unmaintained sane-umax1220u http://sourceforge.net/projects/umax1220u-sane *none* `http://www.umax.com/' *none* USB 0x1606 0x0010 good *none* *none* USB 0x1606 0x0030 good *none* *none* USB 0x1606 0x0030 good *none* *none* USB 0x1606 0x0130 good *none* *none* 1 sane-umax_pp http://umax1220p.sourceforge.net/ *none* `http://www.umax.com.tw/' *none* Parport (EPP/ECP) *none* *none* good *none* *none* Parport (EPP/ECP) *none* *none* good *none* *none* Parport (EPP/ECP) *none* *none* good *none* *none* Parport (SPP/ECP) *none* *none* unsupported *none* untested, but should be close to 610P Parport (SPP/ECP) *none* *none* good *none* *none* *none* *none* Parport (EPP/ECP) *none* *none* good *none* works (relabelled 1220P and 2000P) *none* *none* Parport (EPP/ECP) *none* *none* good *none* works (relabelled 1220P and 2000P) 2010-06-09 *none* contrib.html The devices mentioned here are not supported by any SANE backend. However, there may be links to information about them or stand-alone programs. *none* *none* USB IEEE-1394 0x06bd 0x02bf unsupported unsupported/agfa-duoscan-f40.html Unsupported. See link for details. SCSI *none* *none* unsupported unsupported/agfa-duoscan-t2000xl.html Unsupported. Same as Microtek ArtixScan 2020? SCSI IEEE-1384 *none* *none* unsupported *none* Unsupported. Same as Microtek Artixscan 2500f Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. `http://www.artecusa.com/' *none* USB 0x05d8 0x4001 unsupported unsupported/artec_1236usb.html Unsupported. See link for details. Parport *none* *none* unsupported *none* Unsupported. Chips found inside: AT015, AD9816JS. Maybe similar to SCSI version or as6e? USB 0x05d8 0x4001 unsupported unsupported/artec-ultima-2000-2.html Same name, but different ids: This scanner is not supported. The scanner with product id 0x4002 is supported by the gt68xx backend, however. *none* *none* USB Parport 0x05cb 0x1483 unsupported unsupported/trust-combiscan-19200.html Not supported. See link for details. `http://www.avision.com/' *none* Parport *none* *none* unsupported *none* Probably not supported. Scanner/printer/copier combination. USB *none* *none* unsupported *none* Not supported. No chipset information available. Same as UMAX Astra 6700. USB 0x0638 0x0a10 unsupported unsupported/umax-astra-4500.html GL646 based, to be added to genesys backend. Same as UMAX Astra 4500. USB 0x0638 0x0a20 unsupported unsupported/umax-astra-4700.html GL646/GL660 based. Same as UMAX Astra 4700. `http://www.benq.com' Formerly Acer Peripherals Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. Parport *none* *none* unsupported unsupported/acer-parport.html Unsupported, see link for details. USB 0x04a5 0x211e unsupported *none* Unsupported. USB 0x04a5 0x2211 unsupported unsupported/benq-5550.html Unsupported, see link for details. USB 0x04a5 0x2311 unsupported http://alioth-lists.debian.net/pipermail/sane-devel/2009-January/023447.html *none* USB 0x04a5 0x2202 unsupported unsupported/benq-7400ut.html *none* *none* *none* Parport USB 0x05cb 0x1483 unsupported unsupported/trust-combiscan-19200.html Unsupported. See link for details. `http://www.brother.com/' *none* USB 0x04f9 0x000a unsupported unsupported/brother-mfc-2500.html Not supported. See link for details. Parport *none* *none* unsupported http://sourceforge.net/projects/brother-mfc The parport 200x400dpi grayscale version of this scanner is unsupported. Dmitri Katchalov did some investigations on this scanner. If you want to write a backend, contact him (see link). Parport USB 0x04f9 0x0106 unsupported unsupported/brother-mfc-7300.html *none* USB 0x04f9 0x0101 unsupported unsupported/brother-mfc-9600.html *none* `http://www.c-channel.ch/' *none* USB *none* *none* unsupported unsupported/c-channel-mypen-pro.html Probably unsupported. See link for details. USB 0x0a93 0x0005 unsupported *none* See bug #306792 for details. USB *none* *none* unsupported *none* Probably unsupported. `http://www.canon.com/' *none* USB 0x04a9 0x2215 unsupported unsupported/canon-3000.html GL660+GL646 based. USB 0x04a9 0x2215 unsupported unsupported/canon-3000.html GL660+GL646 based. USB 0x04a9 0x2215 unsupported unsupported/canon-3000.html GL660+GL646 based, to be added to genesys backend USB 0x04a9 0x221b unsupported unsupported/canon-4200f.html Probably unsupported. See link. USB 0x04a9 0x2228 unsupported unsupported/canon-4400.html GL843 based, to be added to genesys backend USB 0x04a9 0x2212 unsupported unsupported/canon-5000f.html Unsupported. See link for details. USB 0x04a9 0x2217 unsupported unsupported/canon-5200f.html Probably unsupported. See link for details. USB 0x04a9 0x220f unsupported unsupported/canon-8000f.html Not supported. See link for more information. With transparency adapter. USB 0x04a9 0x221e unsupported unsupported/canon-8400f.html GL841 based, to be added to genesys backend USB 0x04a9 0x2229 unsupported unsupported/canon-8600.html GL841 based, to be added to genesys backend USB 0x04a9 0x2210 unsupported unsupported/canon-9900f.html Probably unsupported, similar to 8000F. 3200x6400 dpi USB2. With transparency adapter. USB 0x04a9 0x2219 unsupported unsupported/canon-9950f.html Probably unsupported. USB 0x04a9 0x220b unsupported unsupported/canon-d646u.html Probably not supported. See link for more information and test program. USB 0x04a9 0x220b unsupported unsupported/canon-d646u.html Probably not supported. See D646. USB 0x04a9 0x2209 unsupported unsupported/canon-d1230u.html Probably not supported. USB 0x04a9 0x220c unsupported unsupported/canon-d1250u2.html Not supported. However, someone started working on this scanner and some information is available (see link). USB 0x04a9 0x220a unsupported unsupported/canon-d2400uf.html Not supported. See link. USB 0x04a9 0x2201 unsupported *none* Probably not supported. No details known. USB 0x04a9 0x2202 unsupported unsupported/canon-fb620u.html Probably not supported. Some information is available. USB 0x04a9 0x2205 unsupported http://sourceforge.net/projects/canonscanner/ Not supported. However, a stand-alone program for FreeBSD is available. USB 0x04a9 0x2225 unsupported http://www.juergen-ernst.de/info_sane.html Philips chip. Backend started, see link USB 0x04a9 0x2214 unsupported unsupported/canon-lide-80.html GL841 based, to be added to genesys backend USB 0x04a9 0x1900 unsupported unsupported/canon-lide-90.html Unsupported. See link for details. USB 0x04a9 0x221f unsupported unsupported/canon-canoscan-lide-500f.html GL841 based, to be added to genesys backend USB 0x04a9 0x2224 unsupported http://www.juergen-ernst.de/info_sane.html Philips chip. Backend started, see link USB 0x04a9 0x2224 unsupported http://www.juergen-ernst.de/info_sane.html Philips chip. Backend started, see link USB SCSI 0x04a9 0x3042 unsupported unsupported/canon-fs4000.html Not supported. See link for more details. USB *none* *none* unsupported unsupported/canon-is-12.html Probably not supported. Scanner cardridge for Canon inkjet printers. Parport *none* *none* unsupported unsupported/canon-is-22.html Probably not supported. Scanner cardridge for Canon inkjet printers. USB 0x04a9 0x105d unsupported unsupported/canon-is-32.html Probably not supported. Scanner cardridge for Canon inkjet printers. USB *none* *none* unsupported unsupported/canon-is-52.html Probably not supported. Scanner cardridge for Canon inkjet printers. USB 0x04a9 0x269d unsupported unsupported/canon-imagerunner.html Probably not supported. See link for details. USB 0x04a9 0x269d unsupported unsupported/canon-imagerunner.html Probably not supported. See link for details. USB 0x04a9 0x269d unsupported unsupported/canon-imagerunner.html Probably not supported. See link for details. USB 0x04a9 0x1700 unsupported unsupported/canon-pixma-mp110.html Probably not supported. See link for details. USB 0x04a9 0x1701 unsupported unsupported/canon-pixma-mp130.html Probably not supported. See link for details. USB *none* *none* unsupported *none* GL84x? *none* *none* Parport Serial Port *none* *none* unsupported unsupported/chinon-ds3000.html Unsupported at the moment, but a backend is in preparation. See link. `http://www.compaq.com/' *none* USB 0x049f 0x0021 unsupported *none* Not supported. 2400x1200 dpi. One bulk-in, one bulk-out and one interrupt endpoint. Type-number: U0001-HB21, another type nr on the inside: 75100512-00 *none* *none* Parport USB 0x05cb 0x1483 unsupported unsupported/trust-combiscan-19200.html Unsupported. See link for details. `http://www.cardscan.com/' *none* USB 0x08f0 0x0001 unsupported unsupported/corex-cardscan-500.html Probably not supported. Businesscard reader. USB 0x08f0 0x0004 unsupported unsupported/corex-cardscan-700.html Probably not supported. `http://www.dell.com/' *none* USB 0x413c 0x5106 unsupported *none* Probably rebadged Lexmark X5150. May work with sane-lexmark? See bug #312130 USB 0x413c 0x5107 unsupported unsupported/dell-a960.html Probably not supported. See link for details. USB 0x413c 0x5109 unsupported unsupported/dell-922.html Probably not supported. See link for details. `http://www.epson.com/' *none* USB 0x04b8 0x0102 unsupported *none* Probably unsupported. No details known. USB 0x04b8 0x0105 unsupported *none* Probably unsupported. No details known. USB 0x04b8 0x083f unsupported unsupported/epson-stylus-dx4450.html Probably unsupported. See link for details. USB *none* *none* unsupported *none* Probably unsupported at the moment. Not compatible to snapscan backend. It's not known if it may work with epson or epkowa backend. `http://www.bizcardreader.com/' *none* USB 0x0a53 0x5001 unsupported unsupported/edt-900c.html Probably unsupported. See link for details. *none* E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX Parport *none* *none* unsupported *none* Probably unsupported. Sold 1998. Same as E-Lux j-6121. *none* E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX Parport *none* *none* unsupported *none* Probably unsupported. Sold 1998. Same as E-Lux j-6121. Parport *none* *none* unsupported *none* Probably unsupported. `http://www.geniusnet.com.tw/' `http://www.genius-kye.com/' *none* SCSI *none* *none* unsupported unsupported/genius-colorpage-cs.html Probably unsupported, see link for details. USB 0x0458 0x2020 unsupported unsupported/genius-colorpage-slim-1200-usb2.html GL841 based, to be added to genesys backend. USB 0x0458 0x2019 unsupported unsupported/genius-colorpage-hr6x.html GL646 based, to be added to genesys backend USB 0x0458 0x2018 unsupported unsupported/genius-colorpage-hr7x.html GL646 based, to be added to genesys backend USB 0x06dc 0x0012 unsupported unsupported/genius-colorpage-hr7xe.html Unsuported. See link for details. USB 0x0458 0x201c unsupported unsupported/genius-colorpage-hr8.html GL841 based, to be added to genesys backend *none* *none* USB 0x080d 0x0102 unsupported unsupported/teco-vm6509.html Probably unsupported. See link for details. Parport *none* *none* unsupported *none* Probably unsupported. Identical to the Benq Prisa 620P. *none* *none* USB 0x080d 0x0102 unsupported unsupported/teco-vm6509.html Probably unsupported. See link for details. `http://www.hp.com/' *none* USB 0x03f0 0x1001 unsupported unsupported/hp-photo-1000.html Not supported by SANE. However, it's detected as mass storage device so just mounting it is reported to work. See link for device data. USB *none* *none* unsupported *none* Probably not supported by SANE. No details known. 10x15 cm. Maybe similar to Photo Scanner 1000? USB 0x03f0 0x0102 unsupported unsupported/hp-photosmart-s20xi.html Not supported yet by SANE. See link for details. USB 0x03f0 0x0102 unsupported unsupported/hp-photosmart-s20xi.html Not supported yet by SANE. See link for details. USB 0x03f0 0x5811 unsupported unsupported/hp-photosmart-5100.html Not supported yet by SANE. See link for details. USB 0x03f0 0x0a01 unsupported unsupported/hp-scanjet-2400c.html GL646 based, to be added to genesys backend USB 0x03f0 0x5611 unsupported unsupported/hp-photosmart-3180.html Not supported yet by SANE. See link for details. USB 0x03f0 0x2505 unsupported *none* While an external binary-only backend exists, it works only on Linux i386. Therefore the scanner is unsupported on other platforms. USB 0x03f0 0x3005 unsupported unsupported/hp-scanjet-4600.html Not supported. See link for details, or http://www.chmil.org/hp4600linux/ for code USB 0x03f0 0x3005 unsupported *none* Not supported. See ScanJet 4600 entry. USB 0x03f0 0x1b05 unsupported unsupported/hp-scanjet-4850.html GL841, maybe can be added to genesys backend USB 0x03f0 0x1b05 unsupported unsupported/hp-scanjet-4850.html GL843, maybe can be added to genesys backend USB 0x03f0 0x1605 unsupported unsupported/hp-scanjet-5530.html Maybe GL841_HP, but not confirmed, maybe can be added to genesys backend USB 0x03f0 0x3805 unsupported unsupported/hp-scanjet-8390.html Probably not supported. See link for details. USB 0x03f0 0x4505 unsupported unsupported/hp-g4000.html Probably not supported. See link for details. `http://www.ibm.com' *none* Proprietary *none* *none* unsupported *none* Unsupported. Uses proprietary ISA card. Maybe the same as the Plustek Spectra ADF? `http://www.iomagic.com/' *none* USB Parport 0x05cb 0x1483 unsupported unsupported/trust-combiscan-19200.html Unsupported. See link for details. `http://irislink.com/' *none* USB 0x0a53 0x1000 unsupported unsupported/iris-iriscan.html Unsupported. LM9832/3. See link for details. USB 0x0f43 0x015a unsupported unsupported/iris-irispen-translator.html Unsupported. See link for details. USB 0x0a38 0x0301 unsupported unsupported/iris-business.html Unsupported. See link for details. `http://www.kodak.com' *none* Parport *none* *none* unsupported *none* Unsupported. FCC ID HWF96PHS `http://www.lexmark.com/' *none* USB 0x043d 0x0097 unsupported unsupported/lexmark-p6250.html Unsupported. See link for details. USB 0x043d 0x007d unsupported unsupported/lexmark-3150.html Unsupported. See link for details. USB 0x043d 0x0060 unsupported unsupported/lexmark-x75.html Unsupported. See link for details. USB 0x043d 0x0060 unsupported unsupported/lexmark-x75.html Unsupported. See link for details. USB 0x043d 0x0060 unsupported unsupported/lexmark-x75.html Unsupported. See link for details. USB 0x043d 0x003d unsupported unsupported/lexmark-x83.html Unsupported. GL640. USB 0x043d 0x00bb unsupported unsupported/lexmark-x2330.html Unsupported. See link for details. USB 0x043d 0x00f6 unsupported unsupported/lexmark-x3450.html Unsupported. See link for details. USB 0x043d 0x0065 unsupported unsupported/lexmark-x5130.html Unsupported. USB 0x043d 0x0065 unsupported unsupported/lexmark-x5130.html Probably unsupported. See link for details. USB 0x043d 0x0093 unsupported unsupported/lexmark-x5250.html Unsupported. USB 0x043d 0x0072 unsupported unsupported/lexmark-x6170.html Unsupported. See link for details. USB 0x043d 0x0098 unsupported *none* Unsupported. See bug #310889 for details. USB 0x043d 0x00b8 unsupported unsupported/lexmark-x7350.html Unsupported. See link for details. USB 0x043d 0x00b9 unsupported unsupported/lexmark-x8350.html Unsupported. See link for details. *none* *none* Parport *none* *none* unsupported *none* Most probably unsupported. USB 0x046d 0x040f unsupported unsupported/logitech-pagescan-usb.html Probably unsupported. See link for details. `http://www.medion.com/' `http://www.medion.de/' *none* USB 0x0461 0x0392 unsupported unsupported/medion-md6190.html Probably unsupported. There seem to exist two different scanners with that name. See link for details. USB 0x0461 0x037b unsupported unsupported/medion-md6190.html Probably unsupported. There seem to exist two different scanners with that name. See link for details. USB 0x05da 0x3008 unsupported unsupported/tevion-md40420.html Probably unsupported. See link for details. USB 0x0461 0x037b unsupported unsupported/medion-md6190.html Probably unsupported. See link for details. USB 0x0461 0x037b unsupported unsupported/medion-md6190.html Probably unsupported. See link for details. USB 0x05da 0x3008 unsupported unsupported/tevion-md40420.html Probably unsupported. See link for details. USB 0x08ff 0x2580 unsupported http://gkall.hobby.nl/authentec.html Fingerprint sensor. See link for details. USB 0x05da 0x30e5 unsupported unsupported/tevion-md90009.html Probably unsupported. See link for details. USB 0x05da 0x3022 unsupported unsupported/tevion-md90070.html Unsupported. See link for details. USB 0x05da 0x3022 unsupported unsupported/tevion-md90070.html Unsupported. See link for details. `http://www.memorex.com/' *none* USB 0x0461 0x0346 unsupported unsupported/memorex-maxx-6136u.html Probably unsupported. USB 0x0461 0x0347 unsupported unsupported/visioneer-onetouch4400.html Probably unsupported. Same as Visioneer Onetouch 4400. See link for details. USB Parport 0x05cb 0x1483 unsupported unsupported/trust-combiscan-19200.html Unsupported. See link for details. Parport *none* *none* unsupported unsupported/memorex-scf-9612p.html Probably unsupported. See link for details. `http://www.microtek.com/' *none* SCSI *none* *none* unsupported *none* Unsupported. Same as Agfa DuoScan T2000XL? USB 0x05da 0x202e unsupported unsupported/microtek-artixscan-2020.html Unsupported. See link for details. SCSI IEEE-1384 *none* *none* unsupported *none* Unsupported. Same as Agfa DuoScan T2500? USB *none* *none* unsupported *none* Unsupported. Uses ALI M5611B. USB 0x05e3 0x0120 unsupported unsupported/microtek-filmscan-35.html Probably unsupported. See link for details. SCSI *none* *none* unsupported *none* Probably unsupported. Seems to be similar to the Microtek 330 CX and is detected by the microtek2 backend. Scanning doesn't seem to work however. SCSI *none* *none* unsupported unsupported/microtek-scanmaker-1850s.html Unsupported. See link for details. USB 0x0461 0x0347 unsupported unsupported/microtek-scanmaker-3630.html Unsupported. Doesn't seem to be compatible to 3600 series, see link. USB 0x05da 0x30ce unsupported unsupported/microtek-scanmaker-3800.html Unsupported. See link for more details. USB 0x05da 0x30ce unsupported unsupported/microtek-scanmaker-3830.html Unsupported. See link for more details. USB 0x05da 0x3023 unsupported unsupported/microtek-scanmaker-3880.html Unsupported. See link for more details. Appears to be similar to ScanMaker 3880. USB 0x05da 0x3021 unsupported unsupported/microtek-scanmaker-3880.html Unsupported. SQ113 chip. See link for more details. USB 0x05da 0x40c7 unsupported unsupported/microtek-scanmaker-4600.html Unsupported. See link for more details. USB 0x05da 0x20b4 unsupported unsupported/microtek-scanmaker-4700.html Unsupported. See link for more details. USB 0x05da 0x30d9 unsupported unsupported/microtek-scanmaker-4900.html Probably unsupported. See link for details. USB 0x05da 0x3008 unsupported unsupported/microtek-scanmaker-4850-2.html Probably unsupported. See link for details. USB 0x05da 0x30b9 unsupported unsupported/microtek-scanmaker-4900.html Unsupported. See link for more details. SCSI *none* *none* unsupported unsupported/microtek-scanmaker-5600.html Probably unsupported. See link for more details. USB 0x05da 0x20a7 unsupported unsupported/microtek-scanmaker-5600.html Unsupported. See link for more details. USB 0x05da 0x20bd unsupported *none* Unsupported. Uses ALI M5615 like the ScanMaker 4700. USB 0x05da 0x3008 unsupported unsupported/microtek-scanmaker-5800.html Unsupported. See link for details. USB 0x05da 0x30d8 unsupported unsupported/microtek-scanmaker-5800.html Unsupported. See link for details. USB 0x05da 0x30d8 unsupported unsupported/microtek-scanmaker-5900.html Unsupported. See link for more details. USB 0x05da 0x30d8 unsupported unsupported/microtek-scanmaker-5950.html Unsupported. See link for more details. USB 0x05da 0x30e5 unsupported unsupported/microtek-scanmaker-6000.html Unsupported. See link for more details. USB 0x05da 0x30e5 unsupported unsupported/microtek-scanmaker-6100.html Unsupported. See link for more details. USB IEEE-1394 0x05da 0x20c9 unsupported unsupported/microtek-scanmaker-6700.html Unsupported. See link. USB IEEE-1394 0x05da 0x20b1 unsupported unsupported/microtek-scanmaker-8700.html Unsupported. See link for details. USB vendor and product ids to be checked. USB IEEE-1394 0x05da 0x20de unsupported *none* Probably unsupported. SCSI seems to work with microtek2 backend. USB SCSI 0x05da 0x20de unsupported unsupported/microtek-scanmaker-9800.html Partly unsupported. IEEE-1394 works with microtek2 backend. See link. USB 0x05da 0x30e6 unsupported unsupported/microtek-scanmaker-i320.html Unsupported. See link. USB 0x05da 0x201c unsupported unsupported/microtek-scanmaker-s400.html Unsupported. See link. USB 0x05da 0x300b unsupported unsupported/microtek-scanmaker-s400.html Unsupported. See link. USB 0x04a7 0x0224 unsupported unsupported/microtek-scanport-3000.html Unsupported. Vendor/Product ids: 0x04a7/0x0224. Realtek RTS8801B?. See link for details. `http://www.konicaminolta.com/' *none* USB 0x0686 0x400d unsupported unsupported/minolta-dual-scan-III.html Unsupported. May work with vuescan. See link for details. USB 0x132b 0x000a unsupported unsupported/minolta-dual-scan-IV.html Unsupported. Works with vuescan. See link for details. USB IEEE-1394 0x0686 0x400e unsupported unsupported/minolta-dse-5400.html Probably unsupported. May work with vuescan. See link for details. USB 0x132b 0x0012 unsupported unsupported/minolta-dse-5400-2.html Probably unsupported. See link for details. IEEE-1394 *none* *none* unsupported unsupported/minolta-dimage-scan-multi-pro.html Probably unsupported. See link for details. USB Network *none* *none* unsupported *none* Uses a different scanning protocol than the magicolor 1690MF `http://www.mustek.com/' `http://www.mustek.de/' `http://www.mustek.com.tw/' *none* Parport *none* *none* unsupported *none* Probably not supported. quarlewm at jmu dot edu offers to temporarily loan such a scanner to anyone who is interested in writing a driver. USB *none* *none* unsupported http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED Probably unsupported. No details known. USB 0x055f 0x0400 unsupported http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED Not supported. May be supported by mustek_usb2 backend later. See link for some information. USB 0x055f 0x0408 unsupported unsupported/mustek-bearpaw-2448-cu-pro.html Not supported. May be supported by mustek_usb2 backend later. See link for some information. USB 0x055f 0x1000 unsupported unsupported/mustek-bearpaw-4800ta-pro.html Not supported. See link for some information. USB 0x055f 0x040a unsupported unsupported/mustek-bearpaw-4800ta-pro-ii.html Not supported. May be supported by mustek_usb2 backend later. See link for some information. USB 0x055f 0x040b unsupported http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED Not supported. May be supported by mustek_usb2 backend later. See link for some information. Parport *none* *none* unsupported *none* Not supported. Maybe similar to 600 II EP (SCSI_over-parport)? In this case it could be supported by the mustek SCSI backend. USB 0x055f 0x0873 unsupported http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED Unsupported. Programming information is available. USB 0x055f 0x0003 unsupported http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED Unsupported. Programming information is available. USB 0x055f 0x0007 unsupported http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED Unsupported. Parport *none* *none* unsupported http://penguin-breeder.org/?page=mustek_pp Not supported. Asic 1505/05. Parport *none* *none* unsupported *none* Not supported. Maybe it will be supported by the mustek_pp backend in future. USB *none* *none* unsupported http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED Probably unsupported. USB business card scanner. Maybe works as USB storage device? Parport *none* *none* unsupported http://alioth-lists.debian.net/pipermail/sane-devel/2003-May/007682.html Probably not supported. Same as Mustek 12000 P?. ASIC 1505. `http://www.nevt.co.jp/' *none* USB 0x0475 0x0100 unsupported unsupported/nec-petiscan.html Most probably unsupported. See link for details. Vendor ID is Relisys/Teco. Not known if it is similar to other Relisys/Teco USB scanners. `http://www.nikon.com/' *none* IEEE-1394 *none* *none* unsupported unsupported/nikon-ls9000-ed.html Probably not supported. See link for details. Possibly similar to LS-8000 ED. `http://www.olivetti.com' *none* USB 0x0b3c 0xa880 unsupported unsupported/olivetti-job-jet-m400.html Probably not supported. See link for details. `http://www.olympus.com' *none* Parport *none* *none* unsupported http://alioth-lists.debian.net/pipermail/sane-devel/2008-December/023326.html *none* SCSI *none* *none* unsupported unsupported/olympus-es10s.html Probably not supported. See link for details. *none* *none* USB 0x065a 0x0001 unsupported *none* Probably not supported. *none* *none* Parport *none* *none* unsupported http://www.df.lth.se/~triad/krad/optrox/ *none* Parport *none* *none* unsupported http://www.df.lth.se/~triad/krad/optrox/ *none* Proprietary *none* *none* unsupported http://www.df.lth.se/~triad/krad/optrox/ Special ISA card Parport *none* *none* unsupported http://www.df.lth.se/~triad/krad/optrox/ *none* Parport *none* *none* unsupported http://www.df.lth.se/~triad/krad/optrox/ *none* Proprietary *none* *none* unsupported http://www.df.lth.se/~triad/krad/optrox/ Special ISA card *none* *none* SCSI *none* *none* unsupported *none* might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool. USB SCSI *none* *none* unsupported *none* might be supported by matsushita backend. SCSI *none* *none* unsupported *none* might be supported by matsushita backend. SCSI *none* *none* unsupported *none* might be supported by matsushita backend. USB SCSI *none* *none* unsupported *none* might be supported by matsushita backend. USB SCSI *none* *none* unsupported *none* might be supported by matsushita backend. USB SCSI *none* *none* unsupported *none* might be supported by matsushita backend. USB SCSI *none* *none* unsupported *none* might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool. SCSI *none* *none* unsupported *none* might be supported by matsushita backend. SCSI *none* *none* unsupported *none* might be supported by matsushita backend. SCSI *none* *none* unsupported *none* might be supported by matsushita backend. SCSI *none* *none* unsupported *none* might be supported by matsushita backend. USB SCSI *none* *none* unsupported *none* might be supported by matsushita backend. *none* *none* USB 0x0a82 0x2000 unsupported unsupported/syscan-travelscan-pro.html Probably not supported. Some information is available. `http://www.scanace.com/' Pacific Image Electronics USB 0x05e3 0x0120 unsupported unsupported/pie-1800u.html Not supported. See link for details. USB *none* *none* unsupported http://alioth-lists.debian.net/pipermail/sane-devel/2009-January/023442.html *none* USB IEEE-1394 *none* *none* unsupported *none* Probably not supported. USB IEEE-1394 0x05e3 0x0142 unsupported unsupported/reflecta-digitdia-3600.html Probably unsupported. Film scanner that can scan directly from the magazine. USB IEEE-1394 0x05e3 0x0143 unsupported unsupported/pie-pf3650.html Not supported. See link for details. `http://www.plustek.de/' `http://www.plustek.com/' *none* USB 0x07b3 0x0807 unsupported unsupported/plustek-opticfilm-7200.html GL842 based, maybe to be added to genesys backend USB 0x07b3 0x0c04 unsupported *none* GL843 based, maybe to be added to genesys backend USB *none* *none* unsupported *none* Uses Plustek ASIC P99002 USB *none* *none* unsupported *none* Uses RealTek chipset (RTL8801D) USB 0x07b3 0x0600 unsupported unsupported/plustek-opticpro-st12.html Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend. USB 0x07b3 0x0600 unsupported unsupported/plustek-opticpro-st12.html Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend. USB 0x07b3 0x0600 unsupported unsupported/plustek-opticpro-st16.html GL646 based, to be added to genesys backend USB *none* *none* unsupported *none* Probably LM983x based. USB 0x07b3 0x0601 unsupported unsupported/plustek-opticpro-st24.html Product id 0x0601 is unsupported but may be supported by the genesys backend in future /GL646). Product id 0x040e is supported by the gt68xx backend. USB 0x07b3 0x0601 unsupported unsupported/plustek-opticpro-st24.html GL646 based, to be added to genesys backend USB 0x07b3 0x0801 unsupported unsupported/plustek-opticpro-s28.html GL841 based, to be added to genesys backend USB 0x07b3 0x0801 unsupported unsupported/plustek-opticpro-s28.html GL841 based, to be added to genesys backend USB 0x07b3 0x0802 unsupported unsupported/plustek-opticpro-st28.html GL841 based, to be added to genesys backend USB 0x07b3 0x0802 unsupported unsupported/umax-astrscan-4750.html GL841 based, to be added to genesys backend, rebadged Plustek ST28 USB 0x07b3 0x0800 unsupported unsupported/plustek-opticpro-st48.html GL841 based, to be added to genesys backend USB 0x07b3 0x0c00 unsupported unsupported/plustek-opticpro-st64.html GL843 based, maybe to be added to genesys backend USB 0x07b3 0x0c03 unsupported unsupported/plustek-opticpro-st64plus.html GL843 based. See link for more details. USB 0x07b3 0x0c0c unsupported unsupported/plustek-pl806.html Unsupported. See link for more details. USB 0x07b3 0x0c0d unsupported unsupported/plustek-pl812.html Unsupported. See link for more details. USB 0x07b3 0x0458 unsupported unsupported/plustek-opticslim-500.html Unsupported. See link for more details. USB 0x07b3 0x0806 unsupported unsupported/plustek-opticslim-2420.html GL841 based, to be added to genesys backend USB 0x07b3 0x0914 unsupported unsupported/plustek-opticslim-2420plus.html GL841 based, to be added to genesys backend Parport *none* *none* unsupported *none* Multifunction device. No further information available. USB *none* *none* unsupported *none* Business card reader. No further information available. USB 0x07b3 0x081c unsupported unsupported/plustek-scancopy-115.html GL841 based, to be added to genesys backend Proprietary *none* *none* unsupported *none* Unsupported. Uses proprietary ISA card that also provides power and is labelled GPS-1 PAGE-A from Taiwan. Other labels on the scanner include ADF Color Scanner and SF600AS. Maybe the same as the IBM ADF Color Scanner? USB 0x07b3 0x0005 unsupported *none* Probably unsupported. Scanner name not known yet. USB 0x07b3 0x0007 unsupported *none* Probably unsupported. Scanner name not known yet. USB 0x07b3 0x000f unsupported *none* Probably unsupported. Scanner name not known yet. USB 0x07b3 0x0012 unsupported *none* Probably unsupported. Scanner name not known yet. USB 0x07b3 0x0014 unsupported *none* Probably unsupported. Scanner name not known yet. USB 0x07b3 0x0016 unsupported *none* Probably unsupported. Scanner name not known yet. `http://www.planon.com/' *none* USB *none* *none* unsupported *none* Probably not supported. No details known. USB 0x10c4 0xea60 unsupported unsupported/planon-docupen-r700.html Probably not supported. See link for details. USB *none* *none* unsupported *none* Probably not supported. No details known. `http://www.primax.nl/' *none* USB 0x0461 0x0341 unsupported unsupported/primax-colorado-600u.html Not supported. Some information is available. Parport *none* *none* unsupported http://home2.swipnet.se/~w-25069/pxscan.html Unsupported by SANE. But is reported to partly work with pxscan. See link. USB 0x0461 0x0361 unsupported *none* Probably unsupported. No details known. USB 0x0461 0x0347 unsupported unsupported/visioneer-onetouch4400.html Unsupported. Same as Visioneer Onetouch 4400. See link for details. Parport *none* *none* unsupported http://home2.swipnet.se/~w-25069/pxscan.html Not supported. However, a stand-alone program is available. Parport *none* *none* unsupported http://home2.swipnet.se/~w-25069/pxscan.html Not supported. However, a stand-alone program is available. USB 0x0461 0x0340 unsupported unsupported/primax-colorado-usb-9600.html Not supported. See link for details. USB 0x0461 0x0300 unsupported *none* Probably unsupported. No details known. USB 0x0461 0x0302 unsupported *none* Probably unsupported. No details known. USB 0x0461 0x0301 unsupported *none* Probably unsupported. No details known. USB 0x0461 0x0303 unsupported *none* Probably unsupported. No details known. USB 0x0461 0x0380 unsupported *none* Probably unsupported. No details known. USB 0x0461 0x0382 unsupported *none* Probably unsupported. No details known. USB 0x0461 0x0383 unsupported *none* Probably unsupported. No details known. Parport *none* *none* unsupported *none* Not supported. USB 0x0461 0x0381 unsupported *none* Probably unsupported. No details known. USB *none* *none* unsupported *none* Maybe GL646. Maybe similar to Medion MD 6228? USB 0x0461 0x0371 unsupported unsupported/visioneer-onetouch8920.html Not supported. Look similar to Visioneer Onetouch 8920 (same USB product id). `http://www.fida.com/' *none* USB 0x06dc 0x0014 unsupported unsupported/prolink-2448u.html Not supported. Some information is available. RealTek RTS8801. USB Parport *none* *none* unsupported *none* Not supported. No further information available. `http://www.quato.de/' *none* SCSI *none* *none* unsupported *none* Probably not supported. No details yet. Originally manufactured by PFU? USB IEEE-1394 *none* *none* unsupported *none* Probably not supported. No details yet. *none* *none* USB IEEE-1394 0x05e3 0x0142 unsupported unsupported/reflecta-digitdia-3600.html Film scanner that can scan directly from the magazine. USB 0x05e3 0x0120 unsupported unsupported/reflecta-iscan-1800.html Probably unsupported. See link for details. USB IEEE-1394 0x05e3 0x0143 unsupported unsupported/reflecta-proscan-4000.html Probably unsupported. See link for details. *none* *none* USB 0x0475 0x0103 unsupported unsupported/relisys-eclipse-1200u.html Probably unsupported. See link for details. USB 0x0475 0x0210 unsupported unsupported/relisys-scorpio-ultra3.html Probably unsupported. See link for details. USB 0x0475 0x0103 unsupported unsupported/relisys-episode.html Probably unsupported. See link for details. Parport *none* *none* unsupported *none* Parport version of AVEC II S3?. See bug #304992 for details *none* *none* USB 0x04e8 0x341f unsupported unsupported/samsung-scx-4725.html Not supported. See link for details. *none* *none* USB 0x0a82 0x6605 unsupported unsupported/scanshell-800n.html Not supported. See link for details. *none* *none* proprietary *none* *none* unsupported mailto:ehaase@inf.fu-berlin.de Not supported until now. Work on a backend has started, contact the author for details (see link) `http://www.siemens.com/' *none* USB 0x0681 0x0005 unsupported *none* Not supported. USB 0x0681 0x0010 unsupported *none* Not supported. *none* *none* USB IEEE-1394 *none* *none* unsupported *none* Probably not supported. Same as PIE Primefilm 2600 PRO. *none* Spot seems have gone out of business. proprietary *none* *none* unsupported http://www.el-profesor.net/spoonset/ Not supported until now. Work on a backend has started, see link for more information. proprietary *none* *none* unsupported http://www.el-profesor.net/spoonset Not supported. Work on a backend has started, see link for more information. proprietary *none* *none* unsupported http://www.el-profesor.net/spoonset Not supported. Work on a backend has started, see link for more information. *none* *none* USB 0x0a82 0x0530 unsupported unsupported/syscan-travelscan-fs531.html Not supported. May work with the Plustek backend in future. See link for details. USB 0x0a82 0x2000 unsupported unsupported/syscan-travelscan-pro.html Probably not supported. Some information is available. *none* *none* Parport *none* *none* unsupported http://www.autistici.org/tamarhack/ Unsupported at the moment. See link for a project for that scanner taht may support it in future. Parport *none* *none* unsupported http://www.autistici.org/tamarhack/ Unsupported at the moment. See link for a project for that scanner. USB 0x05e3 0x0100 unsupported unsupported/tamarack-artiscan-2400.html Unsupported. See link for more information. `http://www.tce.com.br/' Brasilian vendor. USB 0x0461 0x0346 unsupported unsupported/memorex-maxx-6136u.html Not supported. Some information is available. Parport *none* *none* unsupported http://home2.swipnet.se/~w-25069/pxscan.html Not supported by SANE but is reported to work with pxscan (see link). `http://www.tecoimage.com.tw/' *none* USB 0x080d 0x0102 unsupported unsupported/teco-vm6509.html Probably unsupported. See link for details. *none* *none* USB 0x0461 0x0347 unsupported unsupported/visioneer-onetouch4400.html Unsupported. See link for details. `http://www.trust-site.com' *none* Parport USB 0x05cb 0x1483 unsupported unsupported/trust-combiscan-19200.html Unsupported. See link for details. Parport *none* *none* unsupported http://alioth-lists.debian.net/pipermail/sane-devel/2008-October/022955.html *none* SCSI *none* *none* unsupported unsupported/trust-scsi-scan-19200.html Unsupported. See link for details. `http://www.umax.com/' *none* USB 0x0461 0x0374 unsupported unsupported/umax-astra-2500.html Probably not supported. See link for details. USB 0x07b3 0x0601 unsupported unsupported/plustek-opticpro-st24.html Probably not supported. Same IDs as Plustek OpticPro ST24. See link for details. USB 0x0461 0x038a unsupported unsupported/umax-astra-3000.html Probably not supported. See link for details. USB 0x0461 0x038a unsupported unsupported/umax-astra-3600.html Probably not supported. See link for details. USB 0x1606 0x1030 unsupported unsupported/umax-astra-4000.html Not supported. See link for details. USB 0x0461 0x038c unsupported unsupported/umax-astra-4100.html Not supported, to be added to genesys backend. USB 0x0638 0x0a10 unsupported unsupported/umax-astra-4500.html GL646 based, to be added to genesys backend. Avision iVina FB1600 clone USB *none* *none* unsupported *none* Probably not supported, no details known. USB 0x0638 0x0a20 unsupported unsupported/umax-astra-4700.html GL646/GL660 based. Avision iVina FB1800 clone. USB *none* *none* unsupported *none* Not supported. No chipset information available. Same as Avision iVina FB2400. USB 0x080d 0x0104 unsupported unsupported/umax-astraslim.html Probably not supported currently. See link for more details. USB 0x080d 0x0110 unsupported unsupported/umax-astraslim-1200.html See link for more details. USB 0x080d 0x0104 unsupported unsupported/umax-astraslim-6000.html Probably not supported currently. See link for more details. Parport *none* *none* unsupported *none* Probably not supported. No details known.. USB *none* *none* unsupported unsupported/umax-powerlook-180.html Probably not supported. See link for details. USB *none* *none* unsupported *none* Probably not supported. No further information available. *none* *none* USB 0x04a7 0x0224 unsupported unsupported/visioneer-onetouch4800.html Not supported. See link for more details. `http://www.visioneer.com/' *none* USB 0x0461 0x0345 unsupported *none* Not supported. Is reported to use the E5 chipset. Uses a Primax ID. Looks similar to Primascan Colorado 2600u. USB 0x04a7 0x0311 unsupported *none* Not supported. Id is from Primax? Yet another scanner with the same name? USB 0x0461 0x03a8 unsupported unsupported/visioneer-9420.html Unsupported. See link for details. USB 0x04a7 0x0421 unsupported unsupported/visioneer-9450-usb.html Unsupported. See link for details. USB 0x0461 0x0347 unsupported unsupported/visioneer-onetouch4400.html Not supported. E5 chipset? See link for more details. USB 0x04a7 0x0224 unsupported unsupported/visioneer-onetouch4800.html Unsupported. Seems to use Realtek RTS8801B. Same as Microtek Scanport 3000. See link for details. USB 0x04a7 0x0226 unsupported unsupported/visioneer-onetouch5300.html Not supported. Chipset is RTS8801B(?). See link for output of /proc/bus/usb/devices. USB 0x04a7 0x0221 unsupported *none* Not supported. Yet another scanner with this name? USB 0x04a7 0x0226 unsupported unsupported/visioneer-onetouch5800.html Unsupported. 48 bit scanner, doesn't work with viceo backend. RTS8801C. USB 0x04a7 0x022a unsupported unsupported/visioneer-onetouch6600.html Unsupported. See link for details. USB 0x04a7 0x0229 unsupported unsupported/visioneer-onetouch7100.html GL646 based, to be added to genesys backend USB 0x04a7 0x0380 unsupported unsupported/visioneer-onetouch7700.html LM9832/3 based, to be added to plustek backend USB 0x04a7 0x0321 unsupported unsupported/visioneer-onetouch8100.html Unsupported. See link for details. USB 0x04a7 0x0371 unsupported unsupported/visioneer-onetouch8920.html Not supported. See link for details. USB 0x04a7 0x0371 unsupported unsupported/visioneer-onetouch8920.html Not supported. Same as 8920 but without TA? USB 0x04a7 0x0371 unsupported unsupported/visioneer-onetouch8920.html Not supported. Same as 8700 and 8900 but includes a TA. Uses a Primax ID. Chipset is RTS8801C. See link for output of /proc/bus/usb/devices. USB 0x04a7 0x022c unsupported unsupported/visioneer-onetouch9020.html Not supported. See link for details. USB 0x04a7 0x022c unsupported unsupported/visioneer-onetouch9020.html Not supported. See link for details. USB 0x04a7 0x0362 unsupported unsupported/visioneer-onetouch9320.html Probably not supported. See link for details. USB 0x04a7 0x0410 unsupported unsupported/visioneer-onetouch8820.html Probably not supported. See link for details. USB 0x04a7 0x0410 unsupported unsupported/visioneer-onetouch8820.html Probably not supported. See link for details. Parport *none* *none* unsupported unsupported/visioneer-paperport-3100b.html Most probably not supported. See link for details. Parport *none* *none* unsupported *none* Most probably not supported. More details would be appreciated. Parport *none* *none* unsupported unsupported/visioneer-paperport-onetouch.html Most probably not supported. See link for details. USB 0x04a7 0x0102 unsupported unsupported/visioneer-strobe-pro-usb.html Not supported. See link for details. USB 0x04a7 0x03a0 unsupported unsupported/xerox-4800-onetouch.html Unsupported. See link for details. Different id compared to One Touch 4800? SCSI *none* *none* unsupported unsupported/xerox-docuimage-620s.html Not supported. See link for more details. USB 0x04a7 0x0446 unsupported unsupported/xerox-documate-510.html Not supported. See link for more details. USB 0x04a7 0x047c unsupported unsupported/xerox-documate-510.html Not supported. See link for more details. Yet another USB id. USB 0x04a7 0x0224 unsupported unsupported/visioneer-onetouch4800.html Unsupported. See link for details. Different id compared to 4800 One Touch? Parport *none* *none* unsupported unsupported/xerox-workcentre-470cx.html Not supported. See link for more details. USB 0x0924 0xffef unsupported unsupported/xerox-workcentre-m15i.html Not supported. See link for more details. USB Parport 0x043d 0x0020 unsupported unsupported/xerox-workcentre-xk35c.html Not supported. See link for more details. USB 0x04e8 0x3903 unsupported unsupported/xerox-workcentre-xk50cx.html Not supported. See link for more details. USB Parport 0x043d 0x4303 unsupported unsupported/xerox-workcentre-pro412.html Not supported. See link for more details. USB Parport 0x0924 0x4220 unsupported unsupported/xerox-workcentre-pe16.html Not supported. See link for more details. USB 0x0924 0x4237 unsupported unsupported/xerox-workcentre-pe120i.html Not supported. See link for more details. *none* *none* USB 0x0923 0x010f unsupported unsupported/biolux-654.html Not supported yet. See link for more details. *none* *none* USB 0x0797 0x801c unsupported unsupported/grandtech-scopecam.html Not Supported yet. See link for more details. 1.0-3 sane-v4l mailto:henning@meier-geinitz.de *none* Interface to Video For Linux API *none* Supports video cameras and other devices accessed by the v4l kernel API, e.g. bttv devices. Quite a lot of known bugs. 1.0-13 sane-xerox_mfp *none* *none* `http://www.office.xerox.com/' *none* USB 0x0924 0x3d5d good *none* *none* USB 0x0924 0x3da4 complete http://www.office.xerox.com/multifunction-printer/multifunction-under-30ppm/phaser-3200mfp/spec-enus.html *none* USB 0x0924 0x4265 good *none* *none* USB 0x0924 0x420c good *none* *none* USB 0x0924 0x4293 good *none* *none* USB 0x0924 0x4294 good *none* *none* `http://www.dell.com/' *none* USB 0x413c 0x5124 good *none* *none* `http://www.samsung.com' *none* USB 0x04e8 0x3409 untested *none* *none* USB 0x04e8 0x340d untested *none* *none* USB 0x04e8 0x340e untested *none* *none* USB 0x04e8 0x340f untested *none* *none* USB 0x04e8 0x3412 untested *none* *none* USB 0x04e8 0x3413 good *none* *none* USB 0x04e8 0x3419 untested *none* *none* USB 0x04e8 0x341a untested *none* *none* USB 0x04e8 0x341b good *none* *none* USB 0x04e8 0x341c untested *none* *none* USB 0x04e8 0x341d untested *none* *none* USB 0x04e8 0x341f untested *none* *none* USB 0x04e8 0x341f good *none* *none* USB 0x04e8 0x3420 untested *none* *none* USB 0x04e8 0x3421 untested *none* *none* USB 0x04e8 0x3425 good *none* *none* USB 0x04e8 0x3426 good *none* *none* USB 0x04e8 0x3427 untested *none* *none* USB 0x04e8 0x3428 untested *none* *none* USB 0x04e8 0x3429 untested *none* *none* USB 0x04e8 0x342a good *none* *none* USB 0x04e8 0x342a good *none* *none* USB Ethernet 0x04e8 0x342b basic *none* *none* USB 0x04e8 0x342c good *none* *none* USB 0x04e8 0x342d good *none* *none* USB 0x04e8 0x342e good *none* *none* USB 0x04e8 0x342f good *none* *none* USB 0x04e8 0x3430 untested *none* *none* USB 0x04e8 0x3432 untested *none* *none* USB 0x04e8 0x3433 good *none* *none* USB 0x04e8 0x3434 good *none* *none* USB 0x04e8 0x3435 untested *none* *none* USB 0x04e8 0x3437 untested *none* *none* USB 0x04e8 0x3439 untested *none* *none* USB 0x04e8 0x343a good *none* *none* USB 0x04e8 0x343b untested *none* *none* USB 0x04e8 0x343c good *none* *none* USB 0x04e8 0x343d good *none* *none* USB 0x04e8 0x343f untested *none* *none* USB 0x04e8 0x3440 good *none* *none* USB Ethernet 0x04e8 0x3441 good *none* *none* USB 0x04e8 0x3442 untested *none* *none* USB 0x04e8 0x3443 untested *none* *none* USB 0x04e8 0x3444 untested *none* *none* USB 0x04e8 0x3446 good *none* *none* USB 0x04e8 0x344b good *none* *none* Ethernet 0x04e8 0x344b good *none* *none* Ethernet *none* *none* basic *none* *none* USB 0x04e8 0x344f untested *none* *none* USB 0x04e8 0x3450 untested *none* *none* USB 0x04e8 0x3453 basic *none* *none* USB 0x04e8 0x3455 minimal *none* *none* USB 0x04e8 0x3456 basic *none* *none* USB 0x04e8 0x3457 untested *none* *none* USB 0x04e8 0x345a minimal *none* *none* USB 0x04e8 0x345b untested *none* *none* USB 0x04e8 0x3460 untested *none* *none* USB 0x04e8 0x3461 untested *none* *none* USB 0x04e8 0x3466 untested *none* *none* USB 0x04e8 0x3468 untested *none* *none* sane-backends-1.0.29/testsuite/tools/data/hwdb.ref0000666000000000000000000013642413615534521016737 00000000000000# This file was automatically created based on description files (*.desc) # by sane-desc 3.5 from sane-backends 1.0.25git on Tue Dec 3 15:24:46 2013 # # hwdb file for supported USB devices # # If your scanner isn't listed below, you can add it to a new hwdb file # under /etc/udev/hwdb.d/. # # If your scanner is supported by some external backend (brother, epkowa, # hpaio, etc) please ask the author of the backend to provide proper # device detection support for your OS # # If the scanner is supported by sane-backends, please mail the entry to # the sane-devel mailing list (sane-devel@alioth-lists.debian.net). # # Hewlett-Packard ScanJet 4100C usb:v03F0p0101* libsane_matched=yes # Hewlett-Packard ScanJet 4200C | Hewlett-Packard ScanJet 4200Cxi | Hewlett-Packard ScanJet 4200Cse usb:v03F0p0105* libsane_matched=yes # Hewlett-Packard ScanJet 6200C | Hewlett-Packard ScanJet 6250C usb:v03F0p0201* libsane_matched=yes # Hewlett-Packard ScanJet 3300c usb:v03F0p0205* libsane_matched=yes # Hewlett-Packard ScanJet 4300c usb:v03F0p0305* libsane_matched=yes # Hewlett-Packard ScanJet 5200C usb:v03F0p0401* libsane_matched=yes # Hewlett-Packard ScanJet 3400c usb:v03F0p0405* libsane_matched=yes # Hewlett-Packard ScanJet 2100C usb:v03F0p0505* libsane_matched=yes # Hewlett-Packard ScanJet 6300C | Hewlett-Packard ScanJet 6350C | Hewlett-Packard ScanJet 6390C usb:v03F0p0601* libsane_matched=yes # Hewlett-Packard ScanJet 2200C usb:v03F0p0605* libsane_matched=yes # Hewlett-Packard ScanJet 5300C | Hewlett-Packard ScanJet 5370C usb:v03F0p0701* libsane_matched=yes # Hewlett-Packard scanjet 4400c usb:v03F0p0705* libsane_matched=yes # Hewlett-Packard ScanJet 7400c | Hewlett-Packard ScanJet 7450c | Hewlett-Packard ScanJet 7490c usb:v03F0p0801* libsane_matched=yes # Hewlett-Packard scanjet 4470c usb:v03F0p0805* libsane_matched=yes # Hewlett-Packard ScanJet 2300C usb:v03F0p0901* libsane_matched=yes # Hewlett-Packard ScanJet 2400C | Hewlett-Packard ScanJet G2410 usb:v03F0p0A01* libsane_matched=yes # Hewlett-Packard ScanJet 8200 | Hewlett-Packard ScanJet 8250 | Hewlett-Packard ScanJet 8290 usb:v03F0p0B01* libsane_matched=yes # Hewlett-Packard ScanJet 5400c usb:v03F0p1005* libsane_matched=yes # Hewlett-Packard ScanJet 5470c usb:v03F0p1105* libsane_matched=yes # Hewlett-Packard ScanJet 4500C | Hewlett-Packard ScanJet 5550C usb:v03F0p1205* libsane_matched=yes # Hewlett-Packard ScanJet 4570C | Hewlett-Packard ScanJet 5500C usb:v03F0p1305* libsane_matched=yes # Hewlett-Packard ScanJet 3670 | Hewlett-Packard ScanJet 3690C usb:v03F0p1405* libsane_matched=yes # Hewlett-Packard ScanJet 5590 usb:v03F0p1705* libsane_matched=yes # Hewlett-Packard ScanJet 7650 usb:v03F0p1805* libsane_matched=yes # Hewlett-Packard ScanJet 4850C usb:v03F0p1B05* libsane_matched=yes # Hewlett-Packard ScanJet 3530C | Hewlett-Packard ScanJet 3570C usb:v03F0p2005* libsane_matched=yes # Hewlett-Packard ScanJet 3500C usb:v03F0p2205* libsane_matched=yes # Hewlett-Packard ScanJet 3970c usb:v03F0p2305* libsane_matched=yes # Hewlett-Packard ScanJet 4070 Photosmart usb:v03F0p2405* libsane_matched=yes # Hewlett-Packard ScanJet 3800 usb:v03F0p2605* libsane_matched=yes # Hewlett-Packard ScanJet G2710 usb:v03F0p2805* libsane_matched=yes # Hewlett-Packard ScanJet 8300 | Hewlett-Packard ScanJet 8350 | Hewlett-Packard ScanJet 8390 usb:v03F0p3805* libsane_matched=yes # Hewlett-Packard ScanJet 8270 usb:v03F0p3905* libsane_matched=yes # Hewlett-Packard LaserJet M1005 MFP usb:v03F0p3B17* libsane_matched=yes # Hewlett-Packard ScanJet 4370 usb:v03F0p4105* libsane_matched=yes # Hewlett-Packard ScanJet G3010 usb:v03F0p4205* libsane_matched=yes # Hewlett-Packard ScanJet G3110 usb:v03F0p4305* libsane_matched=yes # Hewlett-Packard ScanJet G4010 usb:v03F0p4505* libsane_matched=yes # Hewlett-Packard ScanJet G4050 usb:v03F0p4605* libsane_matched=yes # Hewlett-Packard ScanJet N6310 usb:v03F0p4705* libsane_matched=yes # Hewlett-Packard LaserJet M1120 MFP usb:v03F0p5617* libsane_matched=yes # Hewlett-Packard LaserJet M1120n MFP usb:v03F0p5717* libsane_matched=yes # Mustek BearPaw 1200 usb:v0400p1000* libsane_matched=yes # Mustek BearPaw 1200 | Mustek BearPaw 2400 usb:v0400p1001* libsane_matched=yes # Kodak ESP 5100 usb:v040Ap4025* libsane_matched=yes # Kodak ESP 5300 usb:v040Ap4026* libsane_matched=yes # Kodak ESP 5500 usb:v040Ap4027* libsane_matched=yes # Kodak ESP 5000 usb:v040Ap4028* libsane_matched=yes # Kodak ESP 3300 usb:v040Ap4031* libsane_matched=yes # Kodak ESP 5 usb:v040Ap4032* libsane_matched=yes # Kodak ESP 7 usb:v040Ap403E* libsane_matched=yes # Kodak ESP 9 usb:v040Ap403F* libsane_matched=yes # Kodak ESP 5200 usb:v040Ap4041* libsane_matched=yes # Kodak ESP 3200 usb:v040Ap4043* libsane_matched=yes # Kodak ESP 4100 usb:v040Ap4053* libsane_matched=yes # Kodak ESP 6100 usb:v040Ap4054* libsane_matched=yes # Kodak ESP 7200 usb:v040Ap4056* libsane_matched=yes # Kodak ESP C110 usb:v040Ap4057* libsane_matched=yes # Kodak ESP C115 usb:v040Ap4058* libsane_matched=yes # Kodak ESP 2150 usb:v040Ap4059* libsane_matched=yes # Kodak ESP C310 usb:v040Ap405D* libsane_matched=yes # Kodak ESP C315 usb:v040Ap405E* libsane_matched=yes # Advent AW10 usb:v040Ap4060* libsane_matched=yes # Kodak Hero Office 6.1 usb:v040Ap4062* libsane_matched=yes # Kodak Hero 7.1 usb:v040Ap4063* libsane_matched=yes # Kodak Hero 5.1 usb:v040Ap4064* libsane_matched=yes # Kodak ESP 9200 usb:v040Ap4065* libsane_matched=yes # Kodak ESP 2170 usb:v040Ap4066* libsane_matched=yes # Kodak Hero 9.1 usb:v040Ap4067* libsane_matched=yes # Kodak Hero 3.1 usb:v040Ap406D* libsane_matched=yes # Kodak i30 usb:v040Ap6001* libsane_matched=yes # Kodak i40 usb:v040Ap6002* libsane_matched=yes # Kodak i50 | Kodak i55 usb:v040Ap6003* libsane_matched=yes # Kodak i60 | Kodak i65 usb:v040Ap6004* libsane_matched=yes # Kodak i80 usb:v040Ap6005* libsane_matched=yes # Creative WebCam Go Mini usb:v041Ep4007* libsane_matched=yes # Lexmark X70 | Lexmark X73 usb:v043Dp002D* libsane_matched=yes # Lexmark X74 usb:v043Dp0060* libsane_matched=yes # Lexmark X1110 | Lexmark X1130 | Lexmark X1140 # Lexmark X1150 | Lexmark X1170 | Lexmark X1180 # Lexmark X1185 | Lexmark X1195 usb:v043Dp007C* libsane_matched=yes # Lexmark X12xx usb:v043Dp007D* libsane_matched=yes # Genius ColorPage HR6 V1 usb:v0458p2004* libsane_matched=yes # Genius Colorpage HR6 V2 usb:v0458p2007* libsane_matched=yes # Genius Colorpage HR6 V2 usb:v0458p2008* libsane_matched=yes # Genius Colorpage HR6A usb:v0458p2009* libsane_matched=yes # Genius Colorpage Vivid3x | Genius Colorpage Vivid3 V2 usb:v0458p2011* libsane_matched=yes # Genius Colorpage HR7 usb:v0458p2013* libsane_matched=yes # Genius Colorpage Vivid4 usb:v0458p2014* libsane_matched=yes # Genius Colorpage HR7LE usb:v0458p2015* libsane_matched=yes # Genius Colorpage HR6X usb:v0458p2016* libsane_matched=yes # Genius Colorpage Vivid3xe usb:v0458p2017* libsane_matched=yes # Genius Colorpage Vivid4xe usb:v0458p201A* libsane_matched=yes # Genius Colorpage Vivid4x usb:v0458p201B* libsane_matched=yes # Genius Colorpage Vivid 1200 X usb:v0458p201D* libsane_matched=yes # Genius ColorPage Slim 1200 usb:v0458p201E* libsane_matched=yes # Genius Colorpage Vivid 1200 XE usb:v0458p201F* libsane_matched=yes # Genius Colorpage SF600 usb:v0458p2021* libsane_matched=yes # Medion/Lifetec/Tevion/Cytron MD5345 | Medion/Lifetec/Tevion/Cytron MD6228 | Medion/Lifetec/Tevion/Cytron MD6471 usb:v0461p0377* libsane_matched=yes # Xerox 2400 Onetouch usb:v0461p038B* libsane_matched=yes # Trust Office Scan USB 19200 usb:v047Bp1000* libsane_matched=yes # Hewlett-Packard ScanJet 4300c/Silitek usb:v047Bp1002* libsane_matched=yes # Kyocera FS-1016MFP usb:v0482p0335* libsane_matched=yes # Compaq S4-100 usb:v049Fp001A* libsane_matched=yes # Benq (Acer) 310U usb:v04A5p1A20* libsane_matched=yes # Benq (Acer) 620U usb:v04A5p1A2A* libsane_matched=yes # Benq (Acer) 320U | Benq (Acer) 340U | Mitsubishi Diamondview 648UT usb:v04A5p2022* libsane_matched=yes # Benq (Acer) 620UT usb:v04A5p2040* libsane_matched=yes # Benq (Acer) 640U | Guillemot / Hercules Maxi Scan A4 USB 640U | Guillemot / Hercules Maxi A4 36 bit usb:v04A5p2060* libsane_matched=yes # Benq (Acer) 640bu usb:v04A5p207E* libsane_matched=yes # Benq (Acer) 3300 | Benq (Acer) 4300 | Mitsubishi Diamondview 650U usb:v04A5p20B0* libsane_matched=yes # Benq (Acer) 640BT usb:v04A5p20BE* libsane_matched=yes # Benq (Acer) 1240 usb:v04A5p20C0* libsane_matched=yes # Benq (Acer) 3300 | Benq (Acer) 4300 | Guillemot / Hercules Scan@home Touch 1248 (USB) usb:v04A5p20DE* libsane_matched=yes # Benq (Acer) 5000 usb:v04A5p20F8* libsane_matched=yes # Benq (Acer) 5000E | Benq (Acer) 5000U usb:v04A5p20FC* libsane_matched=yes # Benq (Acer) 5300 usb:v04A5p20FE* libsane_matched=yes # Benq (Acer) 5150 | Benq (Acer) 5250 usb:v04A5p2137* libsane_matched=yes # BenQ 5550 usb:v04A5p2211* libsane_matched=yes # Visioneer Visioneer OneTouch 7100 usb:v04A7p0229* libsane_matched=yes # Visioneer 9650 usb:v04A7p0390* libsane_matched=yes # Visioneer 9320 usb:v04A7p0420* libsane_matched=yes # Visioneer 9450 usb:v04A7p0421* libsane_matched=yes # Visioneer 9550 usb:v04A7p0422* libsane_matched=yes # Visioneer 9750 usb:v04A7p0423* libsane_matched=yes # Visioneer Strobe XP 450 usb:v04A7p0424* libsane_matched=yes # Visioneer Strobe XP 200 usb:v04A7p0426* libsane_matched=yes # Visioneer Strobe XP 100 usb:v04A7p0427* libsane_matched=yes # Visioneer OneTouch 7300 usb:v04A7p0444* libsane_matched=yes # Xerox DocuMate510 usb:v04A7p0446* libsane_matched=yes # Xerox DocuMate520 usb:v04A7p0447* libsane_matched=yes # Xerox DocuMate250 usb:v04A7p0448* libsane_matched=yes # Xerox DocuMate252 usb:v04A7p0449* libsane_matched=yes # Xerox DocuMate262 usb:v04A7p044C* libsane_matched=yes # Visioneer Strobe XP 300 usb:v04A7p0474* libsane_matched=yes # Xerox DocuMate272 usb:v04A7p0475* libsane_matched=yes # Xerox DocuMate232 usb:v04A7p0476* libsane_matched=yes # Xerox DocuMate152 usb:v04A7p0477* libsane_matched=yes # Xerox DocuMate752 usb:v04A7p0478* libsane_matched=yes # Visioneer Strobe XP 470 usb:v04A7p0479* libsane_matched=yes # Visioneer 9450-G usb:v04A7p047A* libsane_matched=yes # Visioneer 9650-G usb:v04A7p047B* libsane_matched=yes # Xerox DocuMate510-G usb:v04A7p047C* libsane_matched=yes # Xerox DocuMate252-G usb:v04A7p048C* libsane_matched=yes # Xerox DocuMate262-G usb:v04A7p048D* libsane_matched=yes # Xerox DocuMate272-G usb:v04A7p048E* libsane_matched=yes # Visioneer Strobe XP 470-G | Visioneer Patriot 470 usb:v04A7p048F* libsane_matched=yes # Xerox DocuMate250-G usb:v04A7p0490* libsane_matched=yes # Visioneer Strobe XP 450-G usb:v04A7p0491* libsane_matched=yes # Xerox DocuMate520-G usb:v04A7p0492* libsane_matched=yes # Visioneer 9750-G usb:v04A7p0493* libsane_matched=yes # Visioneer Roadwarrior usb:v04A7p0494* libsane_matched=yes # Xerox DocuMate512 usb:v04A7p0495* libsane_matched=yes # Visioneer Patriot 430 usb:v04A7p0497* libsane_matched=yes # Visioneer Patriot 680 | Xerox DocuMate632 usb:v04A7p0498* libsane_matched=yes # Visioneer Patriot 780 usb:v04A7p0499* libsane_matched=yes # Xerox DocuMate752 usb:v04A7p049A* libsane_matched=yes # Visioneer Strobe XP 100,r3 usb:v04A7p049B* libsane_matched=yes # Xerox DocuMate150 usb:v04A7p049C* libsane_matched=yes # Xerox DocuMate162 usb:v04A7p049D* libsane_matched=yes # Xerox DocuMate262i usb:v04A7p04A7* libsane_matched=yes # Xerox Travel Scanner 100 usb:v04A7p04AC* libsane_matched=yes # Canon DR-2080C usb:v04A9p1601* libsane_matched=yes # Canon CR-180 | Canon CR-180II usb:v04A9p1602* libsane_matched=yes # Canon DR-9080C usb:v04A9p1603* libsane_matched=yes # Canon DR-7080C usb:v04A9p1604* libsane_matched=yes # Canon DR-5010C usb:v04A9p1606* libsane_matched=yes # Canon DR-6080 usb:v04A9p1607* libsane_matched=yes # Canon DR-2580C usb:v04A9p1608* libsane_matched=yes # Canon DR-3080CII usb:v04A9p1609* libsane_matched=yes # Canon DR-2050C | Canon DR-2050SP usb:v04A9p160A* libsane_matched=yes # Canon DR-7580 usb:v04A9p160B* libsane_matched=yes # Canon PIXMA MP750 usb:v04A9p1706* libsane_matched=yes # Canon PIXMA MP780 | Canon PIXMA MP790 usb:v04A9p1707* libsane_matched=yes # Canon PIXMA MP760 | Canon PIXMA MP770 usb:v04A9p1708* libsane_matched=yes # Canon PIXMA MP150 usb:v04A9p1709* libsane_matched=yes # Canon PIXMA MP170 usb:v04A9p170A* libsane_matched=yes # Canon PIXMA MP450 usb:v04A9p170B* libsane_matched=yes # Canon PIXMA MP500 usb:v04A9p170C* libsane_matched=yes # Canon PIXMA MP800 usb:v04A9p170D* libsane_matched=yes # Canon PIXMA MP800R usb:v04A9p170E* libsane_matched=yes # Canon PIXMA MP530 usb:v04A9p1712* libsane_matched=yes # Canon PIXMA MP830 usb:v04A9p1713* libsane_matched=yes # Canon PIXMA MP160 usb:v04A9p1714* libsane_matched=yes # Canon PIXMA MP180 usb:v04A9p1715* libsane_matched=yes # Canon PIXMA MP460 usb:v04A9p1716* libsane_matched=yes # Canon PIXMA MP510 usb:v04A9p1717* libsane_matched=yes # Canon PIXMA MP600 usb:v04A9p1718* libsane_matched=yes # Canon PIXMA MP600R usb:v04A9p1719* libsane_matched=yes # Canon PIXMA MP810 usb:v04A9p171A* libsane_matched=yes # Canon PIXMA MP960 usb:v04A9p171B* libsane_matched=yes # Canon PIXMA MX7600 usb:v04A9p171C* libsane_matched=yes # Canon PIXMA MP210 usb:v04A9p1721* libsane_matched=yes # Canon PIXMA MP220 usb:v04A9p1722* libsane_matched=yes # Canon PIXMA MP470 usb:v04A9p1723* libsane_matched=yes # Canon PIXMA MP520 usb:v04A9p1724* libsane_matched=yes # Canon PIXMA MP610 usb:v04A9p1725* libsane_matched=yes # Canon PIXMA MP970 usb:v04A9p1726* libsane_matched=yes # Canon PIXMA MX300 usb:v04A9p1727* libsane_matched=yes # Canon PIXMA MX310 usb:v04A9p1728* libsane_matched=yes # Canon PIXMA MX700 usb:v04A9p1729* libsane_matched=yes # Canon PIXMA MP140 usb:v04A9p172B* libsane_matched=yes # Canon PIXMA MX850 usb:v04A9p172C* libsane_matched=yes # Canon PIXMA MP980 usb:v04A9p172D* libsane_matched=yes # Canon PIXMA MP630 usb:v04A9p172E* libsane_matched=yes # Canon PIXMA MP620 usb:v04A9p172F* libsane_matched=yes # Canon PIXMA MP540 usb:v04A9p1730* libsane_matched=yes # Canon PIXMA MP480 usb:v04A9p1731* libsane_matched=yes # Canon PIXMA MP240 usb:v04A9p1732* libsane_matched=yes # Canon PIXMA MP260 usb:v04A9p1733* libsane_matched=yes # Canon PIXMA MP190 usb:v04A9p1734* libsane_matched=yes # Canon PIXMA MX860 usb:v04A9p1735* libsane_matched=yes # Canon PIXMA MX320 usb:v04A9p1736* libsane_matched=yes # Canon PIXMA MX330 usb:v04A9p1737* libsane_matched=yes # Canon PIXMA MP250 usb:v04A9p173A* libsane_matched=yes # Canon PIXMA MP270 usb:v04A9p173B* libsane_matched=yes # Canon PIXMA MP490 usb:v04A9p173C* libsane_matched=yes # Canon PIXMA MP550 usb:v04A9p173D* libsane_matched=yes # Canon PIXMA MP560 usb:v04A9p173E* libsane_matched=yes # Canon PIXMA MP640 usb:v04A9p173F* libsane_matched=yes # Canon PIXMA MP990 usb:v04A9p1740* libsane_matched=yes # Canon PIXMA MX340 usb:v04A9p1741* libsane_matched=yes # Canon PIXMA MX350 usb:v04A9p1742* libsane_matched=yes # Canon PIXMA MX870 usb:v04A9p1743* libsane_matched=yes # Canon PIXMA MP280 usb:v04A9p1746* libsane_matched=yes # Canon PIXMA MP495 usb:v04A9p1747* libsane_matched=yes # Canon PIXMA MG5100 Series usb:v04A9p1748* libsane_matched=yes # Canon PIXMA MG5200 Series usb:v04A9p1749* libsane_matched=yes # Canon PIXMA MG6100 Series usb:v04A9p174A* libsane_matched=yes # Canon PIXMA MG8100 Series usb:v04A9p174B* libsane_matched=yes # Canon PIXMA MX360 usb:v04A9p174D* libsane_matched=yes # Canon PIXMA MX410 usb:v04A9p174E* libsane_matched=yes # Canon PIXMA MX420 usb:v04A9p174F* libsane_matched=yes # Canon PIXMA MX880 Series | Canon PIXMA MX882 | Canon PIXMA MX885 usb:v04A9p1750* libsane_matched=yes # Canon PIXMA MG2100 Series usb:v04A9p1751* libsane_matched=yes # Canon PIXMA MG3100 Series usb:v04A9p1752* libsane_matched=yes # Canon PIXMA MG4100 Series usb:v04A9p1753* libsane_matched=yes # Canon PIXMA MG5300 Series usb:v04A9p1754* libsane_matched=yes # Canon PIXMA MG6200 Series usb:v04A9p1755* libsane_matched=yes # Canon PIXMA MG8200 Series usb:v04A9p1756* libsane_matched=yes # Canon PIXMA MP493 usb:v04A9p1757* libsane_matched=yes # Canon PIXMA E500 usb:v04A9p1758* libsane_matched=yes # Canon PIXMA MX370 Series usb:v04A9p1759* libsane_matched=yes # Canon PIXMA E600 usb:v04A9p175A* libsane_matched=yes # Canon PIXMA MX430 Series usb:v04A9p175B* libsane_matched=yes # Canon PIXMA MX510 Series usb:v04A9p175C* libsane_matched=yes # Canon PIXMA MX710 Series usb:v04A9p175D* libsane_matched=yes # Canon PIXMA MX890 Series usb:v04A9p175E* libsane_matched=yes # Canon PIXMA MP230 usb:v04A9p175F* libsane_matched=yes # Canon PIXMA MG2200 Series usb:v04A9p1760* libsane_matched=yes # Canon PIXMA E510 usb:v04A9p1761* libsane_matched=yes # Canon PIXMA MG3200 Series usb:v04A9p1762* libsane_matched=yes # Canon PIXMA MG4200 Series usb:v04A9p1763* libsane_matched=yes # Canon PIXMA MG5400 Series usb:v04A9p1764* libsane_matched=yes # Canon PIXMA MG6300 Series usb:v04A9p1765* libsane_matched=yes # Canon PIXMA MX390 Series usb:v04A9p1766* libsane_matched=yes # Canon PIXMA E610 usb:v04A9p1767* libsane_matched=yes # Canon PIXMA MX450 Series usb:v04A9p1768* libsane_matched=yes # Canon PIXMA MX520 Series usb:v04A9p1769* libsane_matched=yes # Canon PIXMA MX720 Series usb:v04A9p176A* libsane_matched=yes # Canon PIXMA MX920 Series usb:v04A9p176B* libsane_matched=yes # Canon CanoScan 8800F usb:v04A9p1901* libsane_matched=yes # Canon CanoScan LiDE 100 usb:v04A9p1904* libsane_matched=yes # Canon CanoScan LiDE 200 usb:v04A9p1905* libsane_matched=yes # Canon CanoScan 700F usb:v04A9p1907* libsane_matched=yes # Canon CanoScan 9000F usb:v04A9p1908* libsane_matched=yes # Canon CanoScan LiDE 110 usb:v04A9p1909* libsane_matched=yes # Canon CanoScan LiDE 210 usb:v04A9p190A* libsane_matched=yes # Canon CanoScan 9000F Mark II usb:v04A9p190D* libsane_matched=yes # Canon CanoScan fb630u | Canon CanoScan fb636u usb:v04A9p2204* libsane_matched=yes # Canon CanoScan N650U/N656U usb:v04A9p2206* libsane_matched=yes # Canon CanoScan N1220U usb:v04A9p2207* libsane_matched=yes # Canon CanoScan D660U usb:v04A9p2208* libsane_matched=yes # Canon CanoScan N670U/N676U/LiDE20 usb:v04A9p220D* libsane_matched=yes # Canon CanoScan N1240U/LiDE30 usb:v04A9p220E* libsane_matched=yes # Canon CanoScan LiDE 35 | Canon CanoScan LiDE 40 | Canon CanoScan LiDE 50 usb:v04A9p2213* libsane_matched=yes # Canon CanoScan LiDE 60 usb:v04A9p221C* libsane_matched=yes # Canon CanoScan LiDE25 usb:v04A9p2220* libsane_matched=yes # Canon DR-1210C usb:v04A9p2222* libsane_matched=yes # Canon PIXMA MP730 usb:v04A9p262F* libsane_matched=yes # Canon PIXMA MP700 usb:v04A9p2630* libsane_matched=yes # Canon PIXMA MP360 usb:v04A9p263C* libsane_matched=yes # Canon PIXMA MP370 usb:v04A9p263D* libsane_matched=yes # Canon PIXMA MP390 usb:v04A9p263E* libsane_matched=yes # Canon PIXMA MP375R usb:v04A9p263F* libsane_matched=yes # Canon PIXMA MP740 usb:v04A9p264C* libsane_matched=yes # Canon PIXMA MP710 usb:v04A9p264D* libsane_matched=yes # Canon imageCLASS MF5630 usb:v04A9p264E* libsane_matched=yes # Canon laserBase MF5650 usb:v04A9p264F* libsane_matched=yes # Canon imageCLASS MF8170c usb:v04A9p2659* libsane_matched=yes # Canon imageCLASS MF5730 usb:v04A9p265D* libsane_matched=yes # Canon imageCLASS MF5750 usb:v04A9p265E* libsane_matched=yes # Canon imageCLASS MF5770 usb:v04A9p265F* libsane_matched=yes # Canon imageCLASS MF3110 usb:v04A9p2660* libsane_matched=yes # Canon imageCLASS MF3240 usb:v04A9p2684* libsane_matched=yes # Canon imageCLASS MF6500 series | Canon imageCLASS MF6550 usb:v04A9p2686* libsane_matched=yes # Canon imageCLASS MF4120 | Canon imageCLASS MF4122 | Canon imageCLASS MF4140 # Canon imageCLASS MF4150 usb:v04A9p26A3* libsane_matched=yes # Canon imageCLASS MF4660 | Canon imageCLASS MF4690 usb:v04A9p26B0* libsane_matched=yes # Canon imageCLASS MF4010 | Canon imageCLASS MF4018 usb:v04A9p26B4* libsane_matched=yes # Canon imageCLASS MF4270 usb:v04A9p26B5* libsane_matched=yes # Canon imageRUNNER 1020/1024/1025 usb:v04A9p26E6* libsane_matched=yes # Canon imageCLASS MF4370dn | Canon imageCLASS MF4380dn usb:v04A9p26EC* libsane_matched=yes # Canon imageCLASS D480 usb:v04A9p26ED* libsane_matched=yes # Canon I-SENSYS MF4320d | Canon I-SENSYS MF4330d | Canon imageCLASS MF4350d usb:v04A9p26EE* libsane_matched=yes # Canon imageCLASS D420 usb:v04A9p26EF* libsane_matched=yes # Canon i-SENSYS MF5880dn usb:v04A9p26F9* libsane_matched=yes # Canon i-SENSYS MF6680dn usb:v04A9p26FA* libsane_matched=yes # Canon imageCLASS MF8030 usb:v04A9p2707* libsane_matched=yes # Canon i-SENSYS MF4550d usb:v04A9p2736* libsane_matched=yes # Canon imageCLASS MF4410 | Canon imageCLASS MF4430 usb:v04A9p2737* libsane_matched=yes # Canon i-SENSYS MF3010 usb:v04A9p2759* libsane_matched=yes # Nikon LS 40 ED | Nikon LS 40 ED | Nikon Coolspan IV usb:v04B0p4000* libsane_matched=yes # Nikon LS 50 ED | Nikon Coolscan V ED | Nikon LS 50 ED # Nikon Coolscan V ED usb:v04B0p4001* libsane_matched=yes # Nikon Super Coolscan LS-5000 ED | Nikon Super Coolscan LS-5000 ED usb:v04B0p4002* libsane_matched=yes # Epson Perfection 636U | Epson GT-7000U | Epson Perfection 636U usb:v04B8p0101* libsane_matched=yes # Epson Perfection 610 | Epson GT-6600U | Epson Perfection 610 usb:v04B8p0103* libsane_matched=yes # Epson Perfection 1200U | Epson Perfection 1200Photo | Epson GT-7600U # Epson GT-7600UF | Epson Perfection 1200U | Epson Perfection 1200U PHOTO usb:v04B8p0104* libsane_matched=yes # Epson Stylus Scan 2000 usb:v04B8p0105* libsane_matched=yes # Epson Stylus Scan 2500 usb:v04B8p0106* libsane_matched=yes # Epson Expression 1600 | Epson ES-2000 | Epson Expression 1600 usb:v04B8p0107* libsane_matched=yes # Epson ES-8500 | Epson Expression 1640XL usb:v04B8p0109* libsane_matched=yes # Epson Perfection 1640 | Epson GT-8700 | Epson GT-8700F # Epson Perfection 1640SU | Epson Perfection 1640SU PHOTO usb:v04B8p010A* libsane_matched=yes # Epson Perfection 1240 | Epson GT-7700U | Epson Perfection 1240U usb:v04B8p010B* libsane_matched=yes # Epson Perfection 640 | Epson GT-6700U | Epson Perfection 640U usb:v04B8p010C* libsane_matched=yes # Epson Expression 1680 | Epson ES-2200 | Epson Expression 1680 usb:v04B8p010E* libsane_matched=yes # Epson Perfection 1250 | Epson Perfection 1250Photo usb:v04B8p010F* libsane_matched=yes # Epson Perfection 1650 | Epson GT-8200U | Epson GT-8200UF # Epson Perfection 1650 | Epson Perfection 1650 PHOTO usb:v04B8p0110* libsane_matched=yes # Epson Perfection 2450 | Epson GT-9700F | Epson Perfection 2450 PHOTO usb:v04B8p0112* libsane_matched=yes # Epson Perfection 660 usb:v04B8p0114* libsane_matched=yes # Epson Perfection 2400 | Epson GT-9300UF | Epson Perfection 2400 PHOTO usb:v04B8p011B* libsane_matched=yes # Epson Perfection 3200 | Epson GT-9800F | Epson Perfection 3200 PHOTO usb:v04B8p011C* libsane_matched=yes # Epson Perfection 1260 | Epson Perfection 1260Photo usb:v04B8p011D* libsane_matched=yes # Epson Perfection 1660 | Epson GT-8300UF | Epson Perfection 1660 PHOTO usb:v04B8p011E* libsane_matched=yes # Epson Perfection 1670 usb:v04B8p011F* libsane_matched=yes # Epson Perfection 1270 usb:v04B8p0120* libsane_matched=yes # Epson Perfection 2480 | Epson Perfection 2580 usb:v04B8p0121* libsane_matched=yes # Epson Perfection 3490 | Epson Perfection 3590 usb:v04B8p0122* libsane_matched=yes # Epson ES-7000H | Epson GT-15000 usb:v04B8p0126* libsane_matched=yes # Epson Perfection 4870 | Epson GT-X700 | Epson Perfection 4870 PHOTO usb:v04B8p0128* libsane_matched=yes # Epson ES-10000G | Epson Expression 10000XL usb:v04B8p0129* libsane_matched=yes # Epson Perfection 4990 | Epson GT-X800 | Epson Perfection 4990 PHOTO usb:v04B8p012A* libsane_matched=yes # Epson ES-H300 | Epson GT-2500 usb:v04B8p012B* libsane_matched=yes # Epson V700 | Epson V750 | Epson GT-X900 # Epson Perfection V700 Photo | Epson Perfection V750 Photo usb:v04B8p012C* libsane_matched=yes # Epson GT-X970 usb:v04B8p0135* libsane_matched=yes # Epson CX-5200 | Epson CX-5400 | Epson CC-600PX # Epson Stylus CX5100 | Epson Stylus CX5200 usb:v04B8p0801* libsane_matched=yes # Epson CX-3200 | Epson CC-570L | Epson Stylus CX3100 # Epson Stylus CX3200 usb:v04B8p0802* libsane_matched=yes # Epson CX-6300 | Epson CX-6400 | Epson Stylus CX6300 # Epson Stylus CX6400 usb:v04B8p0805* libsane_matched=yes # Epson RX-600 | Epson PM-A850 | Epson Stylus Photo RX600 usb:v04B8p0806* libsane_matched=yes # Epson RX-500 | Epson Stylus Photo RX500 | Epson Stylus Photo RX510 usb:v04B8p0807* libsane_matched=yes # Epson CX-5400 | Epson Stylus CX5300 | Epson Stylus CX5400 usb:v04B8p0808* libsane_matched=yes # Epson Stylus CX-1500 usb:v04B8p080C* libsane_matched=yes # Epson CX-4600 | Epson Stylus CX4500 | Epson Stylus CX4600 usb:v04B8p080D* libsane_matched=yes # Epson CX-3600 | Epson CX-3650 | Epson PX-A550 # Epson Stylus CX3500 | Epson Stylus CX3600 | Epson Stylus CX3650 usb:v04B8p080E* libsane_matched=yes # Epson RX-425 | Epson Stylus Photo RX420 | Epson Stylus Photo RX425 # Epson Stylus Photo RX430 usb:v04B8p080F* libsane_matched=yes # Epson RX-700 | Epson PM-A900 | Epson Stylus Photo RX700 usb:v04B8p0810* libsane_matched=yes # Epson RX-620 | Epson PM-A870 | Epson Stylus Photo RX620 # Epson Stylus Photo RX630 usb:v04B8p0811* libsane_matched=yes # Epson CX-6500 | Epson CX-6600 | Epson Stylus CX6500 # Epson Stylus CX6600 usb:v04B8p0813* libsane_matched=yes # Epson PM-A700 usb:v04B8p0814* libsane_matched=yes # Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson AcuLaser CX11 # Epson AcuLaser CX11NF | Epson LP-A500 usb:v04B8p0815* libsane_matched=yes # Epson LP-M5500 | Epson LP-M5500F usb:v04B8p0817* libsane_matched=yes # Epson DX-3850 | Epson CX-3700 | Epson CX-3800 # Epson DX-3800 | Epson Stylus CX3700 | Epson Stylus CX3800 # Epson Stylus DX3800 usb:v04B8p0818* libsane_matched=yes # Epson CX-4800 | Epson PX-A650 | Epson Stylus CX4700 # Epson Stylus CX4800 | Epson Stylus DX4800 | Epson Stylus DX4850 usb:v04B8p0819* libsane_matched=yes # Epson PM-A750 | Epson Stylus Photo RX520 | Epson Stylus Photo RX530 usb:v04B8p081A* libsane_matched=yes # Epson PM-A890 | Epson Stylus Photo RX640 | Epson Stylus Photo RX650 usb:v04B8p081C* libsane_matched=yes # Epson PM-A950 usb:v04B8p081D* libsane_matched=yes # Epson Stylus CX7700 | Epson Stylus CX7800 usb:v04B8p081F* libsane_matched=yes # Epson CX-4200 | Epson Stylus CX4100 | Epson Stylus CX4200 # Epson Stylus DX4200 usb:v04B8p0820* libsane_matched=yes # Epson PM-A820 | Epson Stylus Photo RX560 | Epson Stylus Photo RX580 # Epson Stylus Photo RX590 usb:v04B8p0827* libsane_matched=yes # Epson PM-A970 usb:v04B8p0828* libsane_matched=yes # Epson PM-T990 usb:v04B8p0829* libsane_matched=yes # Epson PM-A920 usb:v04B8p082A* libsane_matched=yes # Epson CX-5000 | Epson DX-5000 | Epson DX-5050 # Epson Stylus CX4900 | Epson Stylus CX5000 | Epson Stylus DX5000 usb:v04B8p082B* libsane_matched=yes # Epson DX-6000 | Epson PX-A720 | Epson Stylus CX5900 # Epson Stylus CX6000 | Epson Stylus DX6000 usb:v04B8p082E* libsane_matched=yes # Epson DX-4050 | Epson PX-A620 | Epson Stylus CX3900 # Epson Stylus DX4000 usb:v04B8p082F* libsane_matched=yes # Epson ME 200 | Epson Stylus CX2800 | Epson Stylus CX2900 usb:v04B8p0830* libsane_matched=yes # Epson LP-M5600 usb:v04B8p0833* libsane_matched=yes # Epson LP-M6000 usb:v04B8p0834* libsane_matched=yes # Epson AcuLaser CX21 usb:v04B8p0835* libsane_matched=yes # Epson PM-T960 usb:v04B8p0836* libsane_matched=yes # Epson PM-A940 | Epson Stylus Photo RX680 | Epson Stylus Photo RX685 # Epson Stylus Photo RX690 usb:v04B8p0837* libsane_matched=yes # Epson DX-7400 | Epson PX-A640 | Epson Stylus CX7300 # Epson Stylus CX7400 | Epson Stylus DX7400 usb:v04B8p0838* libsane_matched=yes # Epson PX-A740 | Epson Stylus CX8300 | Epson Stylus CX8400 # Epson Stylus DX8400 usb:v04B8p0839* libsane_matched=yes # Epson PX-FA700 | Epson Stylus CX9300F | Epson Stylus CX9400Fax # Epson Stylus DX9400F usb:v04B8p083A* libsane_matched=yes # Epson PM-A840 | Epson PM-A840S | Epson Stylus Photo RX585 # Epson Stylus Photo RX595 | Epson Stylus Photo RX610 usb:v04B8p083C* libsane_matched=yes # Epson ME 300 | Epson PX-401A | Epson Stylus NX100 # Epson Stylus SX100 | Epson Stylus TX100 usb:v04B8p0841* libsane_matched=yes # Epson LP-M5000 usb:v04B8p0843* libsane_matched=yes # Epson Artisan 800 | Epson EP-901A | Epson EP-901F # Epson Stylus Photo PX800FW | Epson Stylus Photo TX800FW usb:v04B8p0844* libsane_matched=yes # Epson Artisan 700 | Epson EP-801A | Epson Stylus Photo PX700W # Epson Stylus Photo TX700W usb:v04B8p0846* libsane_matched=yes # Epson ME Office 700FW | Epson PX-601F | Epson Stylus Office BX600FW # Epson Stylus Office TX600FW | Epson Stylus SX600FW | Epson WorkForce 600 usb:v04B8p0847* libsane_matched=yes # Epson ME Office 600F | Epson Stylus Office BX300F | Epson Stylus Office TX300F # Epson Stylus NX300 usb:v04B8p0848* libsane_matched=yes # Epson Stylus NX200 | Epson Stylus SX200 | Epson Stylus SX205 # Epson Stylus TX200 | Epson Stylus TX203 | Epson Stylus TX209 usb:v04B8p0849* libsane_matched=yes # Epson PX-501A | Epson Stylus NX400 | Epson Stylus SX400 # Epson Stylus SX405 | Epson Stylus TX400 usb:v04B8p084A* libsane_matched=yes # Epson WorkForce 500 usb:v04B8p084C* libsane_matched=yes # Epson PX-402A | Epson Stylus NX110 Series | Epson Stylus SX110 Series # Epson Stylus TX110 Series usb:v04B8p084D* libsane_matched=yes # Epson ME OFFICE 510 | Epson Stylus NX210 Series | Epson Stylus SX210 Series # Epson Stylus TX210 Series usb:v04B8p084F* libsane_matched=yes # Epson Stylus NX410 Series | Epson Stylus SX410 Series | Epson Stylus TX410 Series usb:v04B8p0851* libsane_matched=yes # Epson ME OFFICE 650FN Series | Epson Stylus Office BX310FN Series | Epson Stylus Office TX510FN Series # Epson WorkForce 310 Series usb:v04B8p0854* libsane_matched=yes # Epson PX-502A | Epson Stylus NX510 Series | Epson Stylus SX510W Series # Epson Stylus TX550W Series usb:v04B8p0856* libsane_matched=yes # Epson Stylus SX125 usb:v04B8p085C* libsane_matched=yes # Fujitsu fi-4010CU usb:v04C5p1029* libsane_matched=yes # Fujitsu fi-4120C usb:v04C5p1041* libsane_matched=yes # Fujitsu fi-4220C usb:v04C5p1042* libsane_matched=yes # Fujitsu fi-4530C usb:v04C5p1078* libsane_matched=yes # Fujitsu fi-5750C usb:v04C5p1095* libsane_matched=yes # Fujitsu fi-5110EOX/2 usb:v04C5p1096* libsane_matched=yes # Fujitsu fi-5110C usb:v04C5p1097* libsane_matched=yes # Fujitsu fi-5650C usb:v04C5p10AD* libsane_matched=yes # Fujitsu fi-4120C2 usb:v04C5p10AE* libsane_matched=yes # Fujitsu fi-4220C2 usb:v04C5p10AF* libsane_matched=yes # Fujitsu fi-60F usb:v04C5p10C7* libsane_matched=yes # Fujitsu fi-4340C usb:v04C5p10CF* libsane_matched=yes # Fujitsu fi-5120C usb:v04C5p10E0* libsane_matched=yes # Fujitsu fi-5220C usb:v04C5p10E1* libsane_matched=yes # Fujitsu fi-5530C usb:v04C5p10E2* libsane_matched=yes # Fujitsu fi-5110EOX3 usb:v04C5p10E6* libsane_matched=yes # Fujitsu fi-5900C usb:v04C5p10E7* libsane_matched=yes # Fujitsu fi-5015C usb:v04C5p10EF* libsane_matched=yes # Fujitsu fi-5110EOXM usb:v04C5p10F2* libsane_matched=yes # Fujitsu ScanSnap S500 usb:v04C5p10FE* libsane_matched=yes # Fujitsu ScanSnap S500M usb:v04C5p1135* libsane_matched=yes # Fujitsu fi-5530C2 usb:v04C5p114A* libsane_matched=yes # Fujitsu fi-6140 usb:v04C5p114D* libsane_matched=yes # Fujitsu fi-6240 usb:v04C5p114E* libsane_matched=yes # Fujitsu fi-6130 usb:v04C5p114F* libsane_matched=yes # Fujitsu fi-6230 usb:v04C5p1150* libsane_matched=yes # Fujitsu ScanSnap S510 usb:v04C5p1155* libsane_matched=yes # Fujitsu ScanSnap S300 usb:v04C5p1156* libsane_matched=yes # Fujitsu ScanSnap S510M usb:v04C5p116F* libsane_matched=yes # Fujitsu fi-6770 usb:v04C5p1174* libsane_matched=yes # Fujitsu fi-6770A usb:v04C5p1175* libsane_matched=yes # Fujitsu fi-6670 usb:v04C5p1176* libsane_matched=yes # Fujitsu fi-6670A usb:v04C5p1177* libsane_matched=yes # Fujitsu fi-6750S usb:v04C5p1178* libsane_matched=yes # Fujitsu ScanSnap S300M usb:v04C5p117F* libsane_matched=yes # Fujitsu fi-6800 usb:v04C5p119D* libsane_matched=yes # Fujitsu fi-6800-CGA usb:v04C5p119E* libsane_matched=yes # Fujitsu ScanSnap S1500 | Fujitsu ScanSnap S1500M usb:v04C5p11A2* libsane_matched=yes # Fujitsu ScanSnap S1300 usb:v04C5p11ED* libsane_matched=yes # Fujitsu fi-6140Z usb:v04C5p11F1* libsane_matched=yes # Fujitsu fi-6240Z usb:v04C5p11F2* libsane_matched=yes # Fujitsu fi-6130Z usb:v04C5p11F3* libsane_matched=yes # Fujitsu fi-6230Z usb:v04C5p11F4* libsane_matched=yes # Fujitsu fi-6110 usb:v04C5p11FC* libsane_matched=yes # Fujitsu fi-5950 usb:v04C5p1213* libsane_matched=yes # Fujitsu ScanSnap iX500 usb:v04C5p132B* libsane_matched=yes # Konica e-mini usb:v04C8p0722* libsane_matched=yes # Panasonic KV-S2026C usb:v04DAp1000* libsane_matched=yes # Panasonic KV-S2046C usb:v04DAp1001* libsane_matched=yes # Panasonic KV-S1025C usb:v04DAp1006* libsane_matched=yes # Panasonic KV-S1020C usb:v04DAp1007* libsane_matched=yes # Panasonic KV-S2048C usb:v04DAp1009* libsane_matched=yes # Panasonic KV-S2028C usb:v04DAp100A* libsane_matched=yes # Panasonic KV-S4085C usb:v04DAp100C* libsane_matched=yes # Panasonic KV-S4065C usb:v04DAp100D* libsane_matched=yes # Panasonic KV-S7075C usb:v04DAp100E* libsane_matched=yes # Panasonic KV-SS080 usb:v04DAp100F* libsane_matched=yes # Panasonic KV-S1045C usb:v04DAp1010* libsane_matched=yes # Samsung SCX-4x16 usb:v04E8p3409* libsane_matched=yes # Samsung SCX-6x20 usb:v04E8p340D* libsane_matched=yes # Samsung MFP-560 usb:v04E8p340E* libsane_matched=yes # Samsung MFP-750 usb:v04E8p340F* libsane_matched=yes # Samsung SCX-4x20 usb:v04E8p3412* libsane_matched=yes # Samsung SCX-4100 usb:v04E8p3413* libsane_matched=yes # Samsung SCX-4x21 usb:v04E8p3419* libsane_matched=yes # Samsung SCX-5x30 usb:v04E8p341A* libsane_matched=yes # Samsung SCX-4200 usb:v04E8p341B* libsane_matched=yes # Samsung CLX-3160 usb:v04E8p341C* libsane_matched=yes # Samsung SCX-6x22 usb:v04E8p341D* libsane_matched=yes # Samsung SCX4725 | Samsung SCX4725-FN usb:v04E8p341F* libsane_matched=yes # Samsung SCX-6x45 usb:v04E8p3420* libsane_matched=yes # Samsung CLX-8380 usb:v04E8p3421* libsane_matched=yes # Samsung CLX-2160 usb:v04E8p3425* libsane_matched=yes # Samsung SCX-4500 usb:v04E8p3426* libsane_matched=yes # Samsung CLX-6200 usb:v04E8p3427* libsane_matched=yes # Samsung CLX-6240 usb:v04E8p3428* libsane_matched=yes # Samsung SCX-6x55 usb:v04E8p3429* libsane_matched=yes # Samsung CLX-3170fn (CLX-3170 Series) | Samsung CLX-3175FW usb:v04E8p342A* libsane_matched=yes # Samsung SCX-4500W usb:v04E8p342B* libsane_matched=yes # Samsung SCX-4824 (SCX-4x24 Series) usb:v04E8p342C* libsane_matched=yes # Samsung SCX-4828FN (SCX-4x28 Series) usb:v04E8p342D* libsane_matched=yes # Samsung SCX-4300 usb:v04E8p342E* libsane_matched=yes # Samsung SCX-5835_5935 usb:v04E8p342F* libsane_matched=yes # Samsung SCX-5635 usb:v04E8p3430* libsane_matched=yes # Samsung SCX-4x26 usb:v04E8p3432* libsane_matched=yes # Samsung SCX-4600 usb:v04E8p3433* libsane_matched=yes # Samsung SCX-4623 usb:v04E8p3434* libsane_matched=yes # Samsung MFP-65x usb:v04E8p3435* libsane_matched=yes # Samsung SCX-6545 usb:v04E8p3437* libsane_matched=yes # Samsung CLX-8385 usb:v04E8p3439* libsane_matched=yes # Samsung CLX-6220 usb:v04E8p343A* libsane_matched=yes # Samsung CLX-6250 usb:v04E8p343B* libsane_matched=yes # Samsung SCX-4825FN (SCX-4x25 Series) usb:v04E8p343C* libsane_matched=yes # Samsung CLX-3185 usb:v04E8p343D* libsane_matched=yes # Samsung CLX-8540 usb:v04E8p343F* libsane_matched=yes # Samsung SCX-4623FW usb:v04E8p3440* libsane_matched=yes # Samsung SCX-3205W (SCX-3200 Series) usb:v04E8p3441* libsane_matched=yes # Samsung SCX-6545X usb:v04E8p3442* libsane_matched=yes # Samsung SCX-6x55X usb:v04E8p3443* libsane_matched=yes # Samsung CLX-8385X usb:v04E8p3444* libsane_matched=yes # Samsung SCX-5835_5935X usb:v04E8p3446* libsane_matched=yes # Samsung SCX-4833FD | Samsung SCX-4835FD usb:v04E8p344B* libsane_matched=yes # Samsung SCX-3400 usb:v04E8p344F* libsane_matched=yes # Samsung SF-760 usb:v04E8p3450* libsane_matched=yes # Samsung SCX-4729FD usb:v04E8p3453* libsane_matched=yes # Samsung CLX-6260 usb:v04E8p3455* libsane_matched=yes # Samsung CLX-3300 Series usb:v04E8p3456* libsane_matched=yes # Samsung SCX-470x usb:v04E8p3457* libsane_matched=yes # Samsung CLX-4190 usb:v04E8p345A* libsane_matched=yes # Samsung SCX-4650 4x21S Series usb:v04E8p345B* libsane_matched=yes # Samsung M337x 387x 407x Series usb:v04E8p3460* libsane_matched=yes # Samsung M267x 287x Series usb:v04E8p3461* libsane_matched=yes # Samsung SCX-681x usb:v04E8p3466* libsane_matched=yes # Samsung C460 usb:v04E8p3468* libsane_matched=yes # Pentax DSmobile 600 usb:v04F9p2038* libsane_matched=yes # Aiptek Aiptek Pencam usb:v0553p0202* libsane_matched=yes # Mustek ScanExpress 1200 CU usb:v055Fp0001* libsane_matched=yes # Mustek ScanExpress 600 CU usb:v055Fp0002* libsane_matched=yes # Mustek ScanExpress 1200 UB | Trust Compact Scan USB 19200 usb:v055Fp0006* libsane_matched=yes # Mustek ScanExpress 1200 CU Plus usb:v055Fp0008* libsane_matched=yes # Mustek BearPaw 1200 F usb:v055Fp0010* libsane_matched=yes # Mustek ScanExpress A3 USB usb:v055Fp0210* libsane_matched=yes # Mustek BearPaw 2400 CS | Mustek BearPaw 2400 TA | Trust 240TH Easy Webscan Gold usb:v055Fp0218* libsane_matched=yes # Mustek BearPaw 2400 CS Plus | Mustek BearPaw 2400 TA Plus | Mustek Plug-n-Scan 2400 MT # Mustek Plug-n-Scan 2400 M | Packard Bell Diamond 2450 usb:v055Fp0219* libsane_matched=yes # Mustek BearPaw 2448 CS Plus | Mustek BearPaw 2448 TA Plus usb:v055Fp021A* libsane_matched=yes # Mustek BearPaw 1200 CU Plus | Packard Bell Diamond 1200 Plus usb:v055Fp021B* libsane_matched=yes # Mustek BearPaw 1200 CU Plus | Mustek BearPaw 1248 CU | Packard Bell Diamond 1200 Plus # Trust Direct WebScan 19200 usb:v055Fp021C* libsane_matched=yes # Mustek BearPaw 2400 CU Plus usb:v055Fp021D* libsane_matched=yes # Mustek BearPaw 1200 CS | Mustek BearPaw 1200 TA usb:v055Fp021E* libsane_matched=yes # Mustek ScanExpress 1248 UB usb:v055Fp021F* libsane_matched=yes # Mustek BearPaw 2448TA Pro usb:v055Fp0409* libsane_matched=yes # Artec/Ultima Ultima 2000 | Artec/Ultima Ultima 2000 e+ | Boeder Sm@rtScan Slim Edition # Fujitsu 1200CUS | Googlegear 2000 | Medion/Lifetec/Tevion/Cytron MD 4394 # Medion/Lifetec/Tevion/Cytron MD/LT 9375 | Medion/Lifetec/Tevion/Cytron MD/LT 9385 | Medion/Lifetec/Tevion/Cytron LT 9452 # Medion/Lifetec/Tevion/Cytron MD 9458 | Mustek BearPaw 1200 CU | Mustek BearPaw 2400 CU # Mustek ScanExpress 1200 UB Plus | Mustek ScanExpress 2400 USB | Mustek ScanMagic 1200 UB Plus # Packard Bell Diamond 1200 | Trust Compact Scan USB 19200 | Trust Flat Scan USB 19200 usb:v05D8p4002* libsane_matched=yes # Artec/Ultima E+ 48U | Medion/Lifetec/Tevion/Cytron MD9693 | Medion/Lifetec/Tevion/Cytron MD9705 # Medion/Lifetec/Tevion/Cytron MD4394 | Microstar MR 9791 usb:v05D8p4003* libsane_matched=yes # Artec/Ultima E+ Pro usb:v05D8p4004* libsane_matched=yes # Memorex MEM 48U usb:v05D8p4005* libsane_matched=yes # Trust Easy Webscan 19200 usb:v05D8p4006* libsane_matched=yes # Trust 240H Easy Webscan Gold usb:v05D8p4007* libsane_matched=yes # UMAX AstraSlim SE usb:v05D8p4009* libsane_matched=yes # UMAX AstraSlim 1200 SE usb:v05D8p4010* libsane_matched=yes # Yakumo Scan50 usb:v05D8p4011* libsane_matched=yes # Microtek ScanMaker X6USB usb:v05DAp0099* libsane_matched=yes # Microtek SlimScan C6 usb:v05DAp009A* libsane_matched=yes # Microtek ScanMaker V6USL usb:v05DAp00A3* libsane_matched=yes # Microtek ScanMaker V6UPL usb:v05DAp00B6* libsane_matched=yes # Microtek ScanMaker 4800 usb:v05DAp30CF* libsane_matched=yes # Microtek ScanMaker 3840 usb:v05DAp30D4* libsane_matched=yes # Microtek ScanMaker 3600 usb:v05DAp40B3* libsane_matched=yes # Microtek ScanMaker 3700 usb:v05DAp40B8* libsane_matched=yes # Microtek ScanMaker 3600 usb:v05DAp40CA* libsane_matched=yes # Microtek ScanMaker 3700 usb:v05DAp40CB* libsane_matched=yes # Microtek ScanMaker 3750 usb:v05DAp40DD* libsane_matched=yes # Microtek ScanMaker 3600 usb:v05DAp40FF* libsane_matched=yes # Microtek ScanMaker V6USL usb:v05DAp80A3* libsane_matched=yes # iVina 1200U usb:v0638p0268* libsane_matched=yes # Minolta Dimage Scan Dual II usb:v0638p026A* libsane_matched=yes # Avision AV600U usb:v0638p0A13* libsane_matched=yes # Minolta-QMS SC-110 usb:v0638p0A15* libsane_matched=yes # Avision DS610CU Scancopier | Minolta-QMS SC-215 | OKI S700 Scancopier usb:v0638p0A16* libsane_matched=yes # Avision AV610 | Avision AV600U Plus usb:v0638p0A18* libsane_matched=yes # Avision AV220 usb:v0638p0A23* libsane_matched=yes # Avision AV210 usb:v0638p0A24* libsane_matched=yes # Avision AV210 usb:v0638p0A25* libsane_matched=yes # Avision AV120 usb:v0638p0A27* libsane_matched=yes # Avision AV220C2 usb:v0638p0A2A* libsane_matched=yes # Avision AV220D2 usb:v0638p0A2B* libsane_matched=yes # Avision AV220+ usb:v0638p0A2C* libsane_matched=yes # Avision AV220C2-G usb:v0638p0A2D* libsane_matched=yes # Avision AV220C2-B usb:v0638p0A2E* libsane_matched=yes # Avision AV210C2-G usb:v0638p0A2F* libsane_matched=yes # Avision AV122 usb:v0638p0A33* libsane_matched=yes # Avision AV210C2 usb:v0638p0A3A* libsane_matched=yes # Avision AV121 usb:v0638p0A3C* libsane_matched=yes # Avision AV8300 usb:v0638p0A40* libsane_matched=yes # Avision AM3000 Series usb:v0638p0A41* libsane_matched=yes # Avision @V5100 usb:v0638p0A45* libsane_matched=yes # Avision AV8050U usb:v0638p0A4D* libsane_matched=yes # Avision AV3200SU usb:v0638p0A4E* libsane_matched=yes # Avision AV3730SU usb:v0638p0A4F* libsane_matched=yes # Avision AV610C2 usb:v0638p0A5E* libsane_matched=yes # Avision IT8300 usb:v0638p0A61* libsane_matched=yes # Avision AV3750SU usb:v0638p0A65* libsane_matched=yes # Avision AV3850SU usb:v0638p0A66* libsane_matched=yes # Avision AV8350 usb:v0638p0A68* libsane_matched=yes # Avision FB6080E usb:v0638p0A82* libsane_matched=yes # Avision FB2080E usb:v0638p0A84* libsane_matched=yes # Avision AV122 C2 usb:v0638p0A93* libsane_matched=yes # Avision AV220-G usb:v0638p0A94* libsane_matched=yes # Avision @V2500 usb:v0638p0AA1* libsane_matched=yes # Avision AV210D2+ usb:v0638p1A35* libsane_matched=yes # Minolta Elite II usb:v0686p4004* libsane_matched=yes # Minolta Dimage Scan Dual III usb:v0686p400D* libsane_matched=yes # Minolta Dimage Scan Elite 5400 usb:v0686p400E* libsane_matched=yes # AGFA SnapScan 1212U usb:v06BDp0001* libsane_matched=yes # AGFA SnapScan 1236u usb:v06BDp0002* libsane_matched=yes # Agfa Snapscan Touch usb:v06BDp0100* libsane_matched=yes # AGFA SnapScan 1212U_2 usb:v06BDp2061* libsane_matched=yes # AGFA SnapScan e40 usb:v06BDp208D* libsane_matched=yes # AGFA SnapScan e50 usb:v06BDp208F* libsane_matched=yes # AGFA SnapScan e20 usb:v06BDp2091* libsane_matched=yes # AGFA SnapScan e10 usb:v06BDp2093* libsane_matched=yes # AGFA SnapScan e25 usb:v06BDp2095* libsane_matched=yes # AGFA SnapScan e26 usb:v06BDp2097* libsane_matched=yes # AGFA SnapScan e52 usb:v06BDp20FD* libsane_matched=yes # AGFA SnapScan e42 usb:v06BDp20FF* libsane_matched=yes # UMAX Astra 4900 usb:v06DCp0020* libsane_matched=yes # Plustek OpticPro U12 | Plustek OpticPro UT12 | Plustek OpticPro 1212U # RevScan RevScan Orange R48Ti | Genius ColorPage Vivid III USB usb:v07B3p0001* libsane_matched=yes # Plustek OpticPro U12 usb:v07B3p0010* libsane_matched=yes # Plustek OpticPro U24 usb:v07B3p0011* libsane_matched=yes # Plustek OpticPro UT12 usb:v07B3p0013* libsane_matched=yes # Plustek OpticPro U24 usb:v07B3p0015* libsane_matched=yes # Plustek OpticPro UT12 | Plustek OpticPro UT16 | Plustek OpticPro UT24 usb:v07B3p0017* libsane_matched=yes # Plustek OpticPro 1248U | RevScan 19200i usb:v07B3p0400* libsane_matched=yes # Plustek OpticPro 1248U usb:v07B3p0401* libsane_matched=yes # Plustek OpticPro U16B usb:v07B3p0402* libsane_matched=yes # Plustek OpticPro U16B+ | Plustek OpticPro UT16B usb:v07B3p0403* libsane_matched=yes # Nortek MyScan 1200 | Plustek OpticPro S12 | Plustek OpticPro ST12 usb:v07B3p040B* libsane_matched=yes # Plustek OpticPro S24 usb:v07B3p040E* libsane_matched=yes # NeatReceipts Scanalizer Professional 2.5 | Plustek OpticSlim M12 usb:v07B3p0412* libsane_matched=yes # Plustek OpticSlim 1200 usb:v07B3p0413* libsane_matched=yes # Plustek OpticSlim 2400 usb:v07B3p0422* libsane_matched=yes # Plustek OpticSlim 2400 plus usb:v07B3p0454* libsane_matched=yes # Plustek Iriscan Express 2 usb:v07B3p045F* libsane_matched=yes # NeatReceipts Mobile Scanner usb:v07B3p0462* libsane_matched=yes # Plustek OpticBook 3600 usb:v07B3p0900* libsane_matched=yes # Corex 600c usb:v08F0p0002* libsane_matched=yes # Corex 800c usb:v08F0p0005* libsane_matched=yes # Xerox Phaser 6110MFP usb:v0924p3D5D* libsane_matched=yes # Xerox Phaser 3200MFP usb:v0924p3DA4* libsane_matched=yes # Xerox WorkCentre 4118 Series usb:v0924p420C* libsane_matched=yes # Xerox WorkCentre 3119 Series usb:v0924p4265* libsane_matched=yes # Xerox WorkCentre 3210 usb:v0924p4293* libsane_matched=yes # Xerox WorkCentre 3220 usb:v0924p4294* libsane_matched=yes # Pentax DSmobile 600 usb:v0A17p3210* libsane_matched=yes # Portable Peripheral Co., Ltd. Q-Scan USB001 (A4 portable scanner) usb:v0A53p1000* libsane_matched=yes # Portable Peripheral Co., Ltd. Q-Scan USB201 (A6 portable scanner) usb:v0A53p2000* libsane_matched=yes # Syscan TravelScan 460/464 | Ambir Visigo A4 usb:v0A82p4600* libsane_matched=yes # Syscan DocketPort 465 usb:v0A82p4802* libsane_matched=yes # Syscan DocketPort 665 usb:v0A82p4803* libsane_matched=yes # Syscan DocketPort 685/ Ambir DS685 usb:v0A82p480C* libsane_matched=yes # Syscan DocketPort 485 usb:v0A82p4810* libsane_matched=yes # Syscan TravelScan 662 usb:v0A82p6620* libsane_matched=yes # Canon CR-55 usb:v1083p160C* libsane_matched=yes # Canon DR-1210C usb:v1083p160F* libsane_matched=yes # Canon DR-4010C usb:v1083p1614* libsane_matched=yes # Canon DR-2510C usb:v1083p1617* libsane_matched=yes # Canon DR-X10C usb:v1083p1618* libsane_matched=yes # Canon CR-25 usb:v1083p161A* libsane_matched=yes # Canon DR-2010C usb:v1083p161B* libsane_matched=yes # Canon DR-3010C usb:v1083p161D* libsane_matched=yes # Canon DR-7090C usb:v1083p1620* libsane_matched=yes # Canon DR-9050C usb:v1083p1622* libsane_matched=yes # Canon DR-7550C usb:v1083p1623* libsane_matched=yes # Canon DR-6050C usb:v1083p1624* libsane_matched=yes # Canon DR-6010C usb:v1083p1626* libsane_matched=yes # Canon CR-190i usb:v1083p162B* libsane_matched=yes # Canon DR-6030C usb:v1083p1638* libsane_matched=yes # Canon CR-135i usb:v1083p1639* libsane_matched=yes # Digital Dream l' espion XS usb:v1183p0001* libsane_matched=yes # KONICA MINOLTA magicolor 1690MF usb:v132Bp2089* libsane_matched=yes # UMAX Astra 1220U usb:v1606p0010* libsane_matched=yes # UMAX Astra 1600U | UMAX Astra 2000U usb:v1606p0030* libsane_matched=yes # Umax UMAX 3400 usb:v1606p0050* libsane_matched=yes # Umax UMAX 3400 | Umax UMAX Astranet ia101 | Umax UMAX 3450 usb:v1606p0060* libsane_matched=yes # UMAX Astra 4400 | UMAX Astra 4450 usb:v1606p0070* libsane_matched=yes # UMAX Astra 2100U usb:v1606p0130* libsane_matched=yes # Umax UMAX 5400 usb:v1606p0160* libsane_matched=yes # UMAX Astra 2200 (SU) usb:v1606p0230* libsane_matched=yes # DCT DocketPort 487 usb:v1DCCp4810* libsane_matched=yes # Dell A920 usb:v413Cp5105* libsane_matched=yes # Dell Dell MFP Laser Printer 1815dn usb:v413Cp5124* libsane_matched=yes # Dell 1600n usb:v413Cp5250* libsane_matched=yes sane-backends-1.0.29/testsuite/tools/data/plist.ref0000666000000000000000000035070213615534521017143 00000000000000 device info version 2.0 usb IOUSBDevice device type scanner product 0x0101 vendor 0x03f0 device type scanner product 0x0105 vendor 0x03f0 device type scanner product 0x0201 vendor 0x03f0 device type scanner product 0x0205 vendor 0x03f0 device type scanner product 0x0305 vendor 0x03f0 device type scanner product 0x0401 vendor 0x03f0 device type scanner product 0x0405 vendor 0x03f0 device type scanner product 0x0505 vendor 0x03f0 device type scanner product 0x0601 vendor 0x03f0 device type scanner product 0x0605 vendor 0x03f0 device type scanner product 0x0701 vendor 0x03f0 device type scanner product 0x0705 vendor 0x03f0 device type scanner product 0x0801 vendor 0x03f0 device type scanner product 0x0805 vendor 0x03f0 device type scanner product 0x0901 vendor 0x03f0 device type scanner product 0x0a01 vendor 0x03f0 device type scanner product 0x0b01 vendor 0x03f0 device type scanner product 0x1005 vendor 0x03f0 device type scanner product 0x1105 vendor 0x03f0 device type scanner product 0x1205 vendor 0x03f0 device type scanner product 0x1305 vendor 0x03f0 device type scanner product 0x1405 vendor 0x03f0 device type scanner product 0x1705 vendor 0x03f0 device type scanner product 0x1805 vendor 0x03f0 device type scanner product 0x1b05 vendor 0x03f0 device type scanner product 0x2005 vendor 0x03f0 device type scanner product 0x2205 vendor 0x03f0 device type scanner product 0x2305 vendor 0x03f0 device type scanner product 0x2405 vendor 0x03f0 device type scanner product 0x2605 vendor 0x03f0 device type scanner product 0x2805 vendor 0x03f0 device type scanner product 0x3805 vendor 0x03f0 device type scanner product 0x3905 vendor 0x03f0 device type scanner product 0x3b17 vendor 0x03f0 device type scanner product 0x4105 vendor 0x03f0 device type scanner product 0x4205 vendor 0x03f0 device type scanner product 0x4305 vendor 0x03f0 device type scanner product 0x4505 vendor 0x03f0 device type scanner product 0x4605 vendor 0x03f0 device type scanner product 0x4705 vendor 0x03f0 device type scanner product 0x5617 vendor 0x03f0 device type scanner product 0x5717 vendor 0x03f0 device type scanner product 0x1000 vendor 0x0400 device type scanner product 0x1001 vendor 0x0400 device type scanner product 0x4025 vendor 0x040a device type scanner product 0x4026 vendor 0x040a device type scanner product 0x4027 vendor 0x040a device type scanner product 0x4028 vendor 0x040a device type scanner product 0x4031 vendor 0x040a device type scanner product 0x4032 vendor 0x040a device type scanner product 0x403e vendor 0x040a device type scanner product 0x403f vendor 0x040a device type scanner product 0x4041 vendor 0x040a device type scanner product 0x4043 vendor 0x040a device type scanner product 0x4053 vendor 0x040a device type scanner product 0x4054 vendor 0x040a device type scanner product 0x4056 vendor 0x040a device type scanner product 0x4057 vendor 0x040a device type scanner product 0x4058 vendor 0x040a device type scanner product 0x4059 vendor 0x040a device type scanner product 0x405d vendor 0x040a device type scanner product 0x405e vendor 0x040a device type scanner product 0x4060 vendor 0x040a device type scanner product 0x4062 vendor 0x040a device type scanner product 0x4063 vendor 0x040a device type scanner product 0x4064 vendor 0x040a device type scanner product 0x4065 vendor 0x040a device type scanner product 0x4066 vendor 0x040a device type scanner product 0x4067 vendor 0x040a device type scanner product 0x406d vendor 0x040a device type scanner product 0x6001 vendor 0x040a device type scanner product 0x6002 vendor 0x040a device type scanner product 0x6003 vendor 0x040a device type scanner product 0x6004 vendor 0x040a device type scanner product 0x6005 vendor 0x040a device type scanner product 0x4007 vendor 0x041e device type scanner product 0x002d vendor 0x043d device type scanner product 0x0060 vendor 0x043d device type scanner product 0x007c vendor 0x043d device type scanner product 0x007d vendor 0x043d device type scanner product 0x2004 vendor 0x0458 device type scanner product 0x2007 vendor 0x0458 device type scanner product 0x2008 vendor 0x0458 device type scanner product 0x2009 vendor 0x0458 device type scanner product 0x2011 vendor 0x0458 device type scanner product 0x2013 vendor 0x0458 device type scanner product 0x2014 vendor 0x0458 device type scanner product 0x2015 vendor 0x0458 device type scanner product 0x2016 vendor 0x0458 device type scanner product 0x2017 vendor 0x0458 device type scanner product 0x201a vendor 0x0458 device type scanner product 0x201b vendor 0x0458 device type scanner product 0x201d vendor 0x0458 device type scanner product 0x201e vendor 0x0458 device type scanner product 0x201f vendor 0x0458 device type scanner product 0x2021 vendor 0x0458 device type scanner product 0x0377 vendor 0x0461 device type scanner product 0x038b vendor 0x0461 device type scanner product 0x1000 vendor 0x047b device type scanner product 0x1002 vendor 0x047b device type scanner product 0x0335 vendor 0x0482 device type scanner product 0x001a vendor 0x049f device type scanner product 0x1a20 vendor 0x04a5 device type scanner product 0x1a2a vendor 0x04a5 device type scanner product 0x2022 vendor 0x04a5 device type scanner product 0x2040 vendor 0x04a5 device type scanner product 0x2060 vendor 0x04a5 device type scanner product 0x207e vendor 0x04a5 device type scanner product 0x20b0 vendor 0x04a5 device type scanner product 0x20be vendor 0x04a5 device type scanner product 0x20c0 vendor 0x04a5 device type scanner product 0x20de vendor 0x04a5 device type scanner product 0x20f8 vendor 0x04a5 device type scanner product 0x20fc vendor 0x04a5 device type scanner product 0x20fe vendor 0x04a5 device type scanner product 0x2137 vendor 0x04a5 device type scanner product 0x2211 vendor 0x04a5 device type scanner product 0x0229 vendor 0x04a7 device type scanner product 0x0390 vendor 0x04a7 device type scanner product 0x0420 vendor 0x04a7 device type scanner product 0x0421 vendor 0x04a7 device type scanner product 0x0422 vendor 0x04a7 device type scanner product 0x0423 vendor 0x04a7 device type scanner product 0x0424 vendor 0x04a7 device type scanner product 0x0426 vendor 0x04a7 device type scanner product 0x0427 vendor 0x04a7 device type scanner product 0x0444 vendor 0x04a7 device type scanner product 0x0446 vendor 0x04a7 device type scanner product 0x0447 vendor 0x04a7 device type scanner product 0x0448 vendor 0x04a7 device type scanner product 0x0449 vendor 0x04a7 device type scanner product 0x044c vendor 0x04a7 device type scanner product 0x0474 vendor 0x04a7 device type scanner product 0x0475 vendor 0x04a7 device type scanner product 0x0476 vendor 0x04a7 device type scanner product 0x0477 vendor 0x04a7 device type scanner product 0x0478 vendor 0x04a7 device type scanner product 0x0479 vendor 0x04a7 device type scanner product 0x047a vendor 0x04a7 device type scanner product 0x047b vendor 0x04a7 device type scanner product 0x047c vendor 0x04a7 device type scanner product 0x048c vendor 0x04a7 device type scanner product 0x048d vendor 0x04a7 device type scanner product 0x048e vendor 0x04a7 device type scanner product 0x048f vendor 0x04a7 device type scanner product 0x0490 vendor 0x04a7 device type scanner product 0x0491 vendor 0x04a7 device type scanner product 0x0492 vendor 0x04a7 device type scanner product 0x0493 vendor 0x04a7 device type scanner product 0x0494 vendor 0x04a7 device type scanner product 0x0495 vendor 0x04a7 device type scanner product 0x0497 vendor 0x04a7 device type scanner product 0x0498 vendor 0x04a7 device type scanner product 0x0499 vendor 0x04a7 device type scanner product 0x049a vendor 0x04a7 device type scanner product 0x049b vendor 0x04a7 device type scanner product 0x049c vendor 0x04a7 device type scanner product 0x049d vendor 0x04a7 device type scanner product 0x04a7 vendor 0x04a7 device type scanner product 0x04ac vendor 0x04a7 device type scanner product 0x1601 vendor 0x04a9 device type scanner product 0x1602 vendor 0x04a9 device type scanner product 0x1603 vendor 0x04a9 device type scanner product 0x1604 vendor 0x04a9 device type scanner product 0x1606 vendor 0x04a9 device type scanner product 0x1607 vendor 0x04a9 device type scanner product 0x1608 vendor 0x04a9 device type scanner product 0x1609 vendor 0x04a9 device type scanner product 0x160a vendor 0x04a9 device type scanner product 0x160b vendor 0x04a9 device type scanner product 0x1706 vendor 0x04a9 device type scanner product 0x1707 vendor 0x04a9 device type scanner product 0x1708 vendor 0x04a9 device type scanner product 0x1709 vendor 0x04a9 device type scanner product 0x170a vendor 0x04a9 device type scanner product 0x170b vendor 0x04a9 device type scanner product 0x170c vendor 0x04a9 device type scanner product 0x170d vendor 0x04a9 device type scanner product 0x170e vendor 0x04a9 device type scanner product 0x1712 vendor 0x04a9 device type scanner product 0x1713 vendor 0x04a9 device type scanner product 0x1714 vendor 0x04a9 device type scanner product 0x1715 vendor 0x04a9 device type scanner product 0x1716 vendor 0x04a9 device type scanner product 0x1717 vendor 0x04a9 device type scanner product 0x1718 vendor 0x04a9 device type scanner product 0x1719 vendor 0x04a9 device type scanner product 0x171a vendor 0x04a9 device type scanner product 0x171b vendor 0x04a9 device type scanner product 0x171c vendor 0x04a9 device type scanner product 0x1721 vendor 0x04a9 device type scanner product 0x1722 vendor 0x04a9 device type scanner product 0x1723 vendor 0x04a9 device type scanner product 0x1724 vendor 0x04a9 device type scanner product 0x1725 vendor 0x04a9 device type scanner product 0x1726 vendor 0x04a9 device type scanner product 0x1727 vendor 0x04a9 device type scanner product 0x1728 vendor 0x04a9 device type scanner product 0x1729 vendor 0x04a9 device type scanner product 0x172b vendor 0x04a9 device type scanner product 0x172c vendor 0x04a9 device type scanner product 0x172d vendor 0x04a9 device type scanner product 0x172e vendor 0x04a9 device type scanner product 0x172f vendor 0x04a9 device type scanner product 0x1730 vendor 0x04a9 device type scanner product 0x1731 vendor 0x04a9 device type scanner product 0x1732 vendor 0x04a9 device type scanner product 0x1733 vendor 0x04a9 device type scanner product 0x1734 vendor 0x04a9 device type scanner product 0x1735 vendor 0x04a9 device type scanner product 0x1736 vendor 0x04a9 device type scanner product 0x1737 vendor 0x04a9 device type scanner product 0x173a vendor 0x04a9 device type scanner product 0x173b vendor 0x04a9 device type scanner product 0x173c vendor 0x04a9 device type scanner product 0x173d vendor 0x04a9 device type scanner product 0x173e vendor 0x04a9 device type scanner product 0x173f vendor 0x04a9 device type scanner product 0x1740 vendor 0x04a9 device type scanner product 0x1741 vendor 0x04a9 device type scanner product 0x1742 vendor 0x04a9 device type scanner product 0x1743 vendor 0x04a9 device type scanner product 0x1746 vendor 0x04a9 device type scanner product 0x1747 vendor 0x04a9 device type scanner product 0x1748 vendor 0x04a9 device type scanner product 0x1749 vendor 0x04a9 device type scanner product 0x174a vendor 0x04a9 device type scanner product 0x174b vendor 0x04a9 device type scanner product 0x174d vendor 0x04a9 device type scanner product 0x174e vendor 0x04a9 device type scanner product 0x174f vendor 0x04a9 device type scanner product 0x1750 vendor 0x04a9 device type scanner product 0x1751 vendor 0x04a9 device type scanner product 0x1752 vendor 0x04a9 device type scanner product 0x1753 vendor 0x04a9 device type scanner product 0x1754 vendor 0x04a9 device type scanner product 0x1755 vendor 0x04a9 device type scanner product 0x1756 vendor 0x04a9 device type scanner product 0x1757 vendor 0x04a9 device type scanner product 0x1758 vendor 0x04a9 device type scanner product 0x1759 vendor 0x04a9 device type scanner product 0x175a vendor 0x04a9 device type scanner product 0x175b vendor 0x04a9 device type scanner product 0x175c vendor 0x04a9 device type scanner product 0x175d vendor 0x04a9 device type scanner product 0x175e vendor 0x04a9 device type scanner product 0x175f vendor 0x04a9 device type scanner product 0x1760 vendor 0x04a9 device type scanner product 0x1761 vendor 0x04a9 device type scanner product 0x1762 vendor 0x04a9 device type scanner product 0x1763 vendor 0x04a9 device type scanner product 0x1764 vendor 0x04a9 device type scanner product 0x1765 vendor 0x04a9 device type scanner product 0x1766 vendor 0x04a9 device type scanner product 0x1767 vendor 0x04a9 device type scanner product 0x1768 vendor 0x04a9 device type scanner product 0x1769 vendor 0x04a9 device type scanner product 0x176a vendor 0x04a9 device type scanner product 0x176b vendor 0x04a9 device type scanner product 0x1901 vendor 0x04a9 device type scanner product 0x1904 vendor 0x04a9 device type scanner product 0x1905 vendor 0x04a9 device type scanner product 0x1907 vendor 0x04a9 device type scanner product 0x1908 vendor 0x04a9 device type scanner product 0x1909 vendor 0x04a9 device type scanner product 0x190a vendor 0x04a9 device type scanner product 0x190d vendor 0x04a9 device type scanner product 0x2204 vendor 0x04a9 device type scanner product 0x2206 vendor 0x04a9 device type scanner product 0x2207 vendor 0x04a9 device type scanner product 0x2208 vendor 0x04a9 device type scanner product 0x220d vendor 0x04a9 device type scanner product 0x220e vendor 0x04a9 device type scanner product 0x2213 vendor 0x04a9 device type scanner product 0x221c vendor 0x04a9 device type scanner product 0x2220 vendor 0x04a9 device type scanner product 0x2222 vendor 0x04a9 device type scanner product 0x262f vendor 0x04a9 device type scanner product 0x2630 vendor 0x04a9 device type scanner product 0x263c vendor 0x04a9 device type scanner product 0x263d vendor 0x04a9 device type scanner product 0x263e vendor 0x04a9 device type scanner product 0x263f vendor 0x04a9 device type scanner product 0x264c vendor 0x04a9 device type scanner product 0x264d vendor 0x04a9 device type scanner product 0x264e vendor 0x04a9 device type scanner product 0x264f vendor 0x04a9 device type scanner product 0x2659 vendor 0x04a9 device type scanner product 0x265d vendor 0x04a9 device type scanner product 0x265e vendor 0x04a9 device type scanner product 0x265f vendor 0x04a9 device type scanner product 0x2660 vendor 0x04a9 device type scanner product 0x2684 vendor 0x04a9 device type scanner product 0x2686 vendor 0x04a9 device type scanner product 0x26a3 vendor 0x04a9 device type scanner product 0x26b0 vendor 0x04a9 device type scanner product 0x26b4 vendor 0x04a9 device type scanner product 0x26b5 vendor 0x04a9 device type scanner product 0x26e6 vendor 0x04a9 device type scanner product 0x26ec vendor 0x04a9 device type scanner product 0x26ed vendor 0x04a9 device type scanner product 0x26ee vendor 0x04a9 device type scanner product 0x26ef vendor 0x04a9 device type scanner product 0x26f9 vendor 0x04a9 device type scanner product 0x26fa vendor 0x04a9 device type scanner product 0x2707 vendor 0x04a9 device type scanner product 0x2736 vendor 0x04a9 device type scanner product 0x2737 vendor 0x04a9 device type scanner product 0x2759 vendor 0x04a9 device type scanner product 0x4000 vendor 0x04b0 device type scanner product 0x4001 vendor 0x04b0 device type scanner product 0x4002 vendor 0x04b0 device type scanner product 0x0101 vendor 0x04b8 device type scanner product 0x0103 vendor 0x04b8 device type scanner product 0x0104 vendor 0x04b8 device type scanner product 0x0105 vendor 0x04b8 device type scanner product 0x0106 vendor 0x04b8 device type scanner product 0x0107 vendor 0x04b8 device type scanner product 0x0109 vendor 0x04b8 device type scanner product 0x010a vendor 0x04b8 device type scanner product 0x010b vendor 0x04b8 device type scanner product 0x010c vendor 0x04b8 device type scanner product 0x010e vendor 0x04b8 device type scanner product 0x010f vendor 0x04b8 device type scanner product 0x0110 vendor 0x04b8 device type scanner product 0x0112 vendor 0x04b8 device type scanner product 0x0114 vendor 0x04b8 device type scanner product 0x011b vendor 0x04b8 device type scanner product 0x011c vendor 0x04b8 device type scanner product 0x011d vendor 0x04b8 device type scanner product 0x011e vendor 0x04b8 device type scanner product 0x011f vendor 0x04b8 device type scanner product 0x0120 vendor 0x04b8 device type scanner product 0x0121 vendor 0x04b8 device type scanner product 0x0122 vendor 0x04b8 device type scanner product 0x0126 vendor 0x04b8 device type scanner product 0x0128 vendor 0x04b8 device type scanner product 0x0129 vendor 0x04b8 device type scanner product 0x012a vendor 0x04b8 device type scanner product 0x012b vendor 0x04b8 device type scanner product 0x012c vendor 0x04b8 device type scanner product 0x0135 vendor 0x04b8 device type scanner product 0x0801 vendor 0x04b8 device type scanner product 0x0802 vendor 0x04b8 device type scanner product 0x0805 vendor 0x04b8 device type scanner product 0x0806 vendor 0x04b8 device type scanner product 0x0807 vendor 0x04b8 device type scanner product 0x0808 vendor 0x04b8 device type scanner product 0x080c vendor 0x04b8 device type scanner product 0x080d vendor 0x04b8 device type scanner product 0x080e vendor 0x04b8 device type scanner product 0x080f vendor 0x04b8 device type scanner product 0x0810 vendor 0x04b8 device type scanner product 0x0811 vendor 0x04b8 device type scanner product 0x0813 vendor 0x04b8 device type scanner product 0x0814 vendor 0x04b8 device type scanner product 0x0815 vendor 0x04b8 device type scanner product 0x0817 vendor 0x04b8 device type scanner product 0x0818 vendor 0x04b8 device type scanner product 0x0819 vendor 0x04b8 device type scanner product 0x081a vendor 0x04b8 device type scanner product 0x081c vendor 0x04b8 device type scanner product 0x081d vendor 0x04b8 device type scanner product 0x081f vendor 0x04b8 device type scanner product 0x0820 vendor 0x04b8 device type scanner product 0x0827 vendor 0x04b8 device type scanner product 0x0828 vendor 0x04b8 device type scanner product 0x0829 vendor 0x04b8 device type scanner product 0x082a vendor 0x04b8 device type scanner product 0x082b vendor 0x04b8 device type scanner product 0x082e vendor 0x04b8 device type scanner product 0x082f vendor 0x04b8 device type scanner product 0x0830 vendor 0x04b8 device type scanner product 0x0833 vendor 0x04b8 device type scanner product 0x0834 vendor 0x04b8 device type scanner product 0x0835 vendor 0x04b8 device type scanner product 0x0836 vendor 0x04b8 device type scanner product 0x0837 vendor 0x04b8 device type scanner product 0x0838 vendor 0x04b8 device type scanner product 0x0839 vendor 0x04b8 device type scanner product 0x083a vendor 0x04b8 device type scanner product 0x083c vendor 0x04b8 device type scanner product 0x0841 vendor 0x04b8 device type scanner product 0x0843 vendor 0x04b8 device type scanner product 0x0844 vendor 0x04b8 device type scanner product 0x0846 vendor 0x04b8 device type scanner product 0x0847 vendor 0x04b8 device type scanner product 0x0848 vendor 0x04b8 device type scanner product 0x0849 vendor 0x04b8 device type scanner product 0x084a vendor 0x04b8 device type scanner product 0x084c vendor 0x04b8 device type scanner product 0x084d vendor 0x04b8 device type scanner product 0x084f vendor 0x04b8 device type scanner product 0x0851 vendor 0x04b8 device type scanner product 0x0854 vendor 0x04b8 device type scanner product 0x0856 vendor 0x04b8 device type scanner product 0x085c vendor 0x04b8 device type scanner product 0x1029 vendor 0x04c5 device type scanner product 0x1041 vendor 0x04c5 device type scanner product 0x1042 vendor 0x04c5 device type scanner product 0x1078 vendor 0x04c5 device type scanner product 0x1095 vendor 0x04c5 device type scanner product 0x1096 vendor 0x04c5 device type scanner product 0x1097 vendor 0x04c5 device type scanner product 0x10ad vendor 0x04c5 device type scanner product 0x10ae vendor 0x04c5 device type scanner product 0x10af vendor 0x04c5 device type scanner product 0x10c7 vendor 0x04c5 device type scanner product 0x10cf vendor 0x04c5 device type scanner product 0x10e0 vendor 0x04c5 device type scanner product 0x10e1 vendor 0x04c5 device type scanner product 0x10e2 vendor 0x04c5 device type scanner product 0x10e6 vendor 0x04c5 device type scanner product 0x10e7 vendor 0x04c5 device type scanner product 0x10ef vendor 0x04c5 device type scanner product 0x10f2 vendor 0x04c5 device type scanner product 0x10fe vendor 0x04c5 device type scanner product 0x1135 vendor 0x04c5 device type scanner product 0x114a vendor 0x04c5 device type scanner product 0x114d vendor 0x04c5 device type scanner product 0x114e vendor 0x04c5 device type scanner product 0x114f vendor 0x04c5 device type scanner product 0x1150 vendor 0x04c5 device type scanner product 0x1155 vendor 0x04c5 device type scanner product 0x1156 vendor 0x04c5 device type scanner product 0x116f vendor 0x04c5 device type scanner product 0x1174 vendor 0x04c5 device type scanner product 0x1175 vendor 0x04c5 device type scanner product 0x1176 vendor 0x04c5 device type scanner product 0x1177 vendor 0x04c5 device type scanner product 0x1178 vendor 0x04c5 device type scanner product 0x117f vendor 0x04c5 device type scanner product 0x119d vendor 0x04c5 device type scanner product 0x119e vendor 0x04c5 device type scanner product 0x11a2 vendor 0x04c5 device type scanner product 0x11ed vendor 0x04c5 device type scanner product 0x11f1 vendor 0x04c5 device type scanner product 0x11f2 vendor 0x04c5 device type scanner product 0x11f3 vendor 0x04c5 device type scanner product 0x11f4 vendor 0x04c5 device type scanner product 0x11fc vendor 0x04c5 device type scanner product 0x1213 vendor 0x04c5 device type scanner product 0x132b vendor 0x04c5 device type scanner product 0x0722 vendor 0x04c8 device type scanner product 0x1000 vendor 0x04da device type scanner product 0x1001 vendor 0x04da device type scanner product 0x1006 vendor 0x04da device type scanner product 0x1007 vendor 0x04da device type scanner product 0x1009 vendor 0x04da device type scanner product 0x100a vendor 0x04da device type scanner product 0x100c vendor 0x04da device type scanner product 0x100d vendor 0x04da device type scanner product 0x100e vendor 0x04da device type scanner product 0x100f vendor 0x04da device type scanner product 0x1010 vendor 0x04da device type scanner product 0x3409 vendor 0x04e8 device type scanner product 0x340d vendor 0x04e8 device type scanner product 0x340e vendor 0x04e8 device type scanner product 0x340f vendor 0x04e8 device type scanner product 0x3412 vendor 0x04e8 device type scanner product 0x3413 vendor 0x04e8 device type scanner product 0x3419 vendor 0x04e8 device type scanner product 0x341a vendor 0x04e8 device type scanner product 0x341b vendor 0x04e8 device type scanner product 0x341c vendor 0x04e8 device type scanner product 0x341d vendor 0x04e8 device type scanner product 0x341f vendor 0x04e8 device type scanner product 0x3420 vendor 0x04e8 device type scanner product 0x3421 vendor 0x04e8 device type scanner product 0x3425 vendor 0x04e8 device type scanner product 0x3426 vendor 0x04e8 device type scanner product 0x3427 vendor 0x04e8 device type scanner product 0x3428 vendor 0x04e8 device type scanner product 0x3429 vendor 0x04e8 device type scanner product 0x342a vendor 0x04e8 device type scanner product 0x342b vendor 0x04e8 device type scanner product 0x342c vendor 0x04e8 device type scanner product 0x342d vendor 0x04e8 device type scanner product 0x342e vendor 0x04e8 device type scanner product 0x342f vendor 0x04e8 device type scanner product 0x3430 vendor 0x04e8 device type scanner product 0x3432 vendor 0x04e8 device type scanner product 0x3433 vendor 0x04e8 device type scanner product 0x3434 vendor 0x04e8 device type scanner product 0x3435 vendor 0x04e8 device type scanner product 0x3437 vendor 0x04e8 device type scanner product 0x3439 vendor 0x04e8 device type scanner product 0x343a vendor 0x04e8 device type scanner product 0x343b vendor 0x04e8 device type scanner product 0x343c vendor 0x04e8 device type scanner product 0x343d vendor 0x04e8 device type scanner product 0x343f vendor 0x04e8 device type scanner product 0x3440 vendor 0x04e8 device type scanner product 0x3441 vendor 0x04e8 device type scanner product 0x3442 vendor 0x04e8 device type scanner product 0x3443 vendor 0x04e8 device type scanner product 0x3444 vendor 0x04e8 device type scanner product 0x3446 vendor 0x04e8 device type scanner product 0x344b vendor 0x04e8 device type scanner product 0x344f vendor 0x04e8 device type scanner product 0x3450 vendor 0x04e8 device type scanner product 0x3453 vendor 0x04e8 device type scanner product 0x3455 vendor 0x04e8 device type scanner product 0x3456 vendor 0x04e8 device type scanner product 0x3457 vendor 0x04e8 device type scanner product 0x345a vendor 0x04e8 device type scanner product 0x345b vendor 0x04e8 device type scanner product 0x3460 vendor 0x04e8 device type scanner product 0x3461 vendor 0x04e8 device type scanner product 0x3466 vendor 0x04e8 device type scanner product 0x3468 vendor 0x04e8 device type scanner product 0x2038 vendor 0x04f9 device type scanner product 0x0202 vendor 0x0553 device type scanner product 0x0001 vendor 0x055f device type scanner product 0x0002 vendor 0x055f device type scanner product 0x0006 vendor 0x055f device type scanner product 0x0008 vendor 0x055f device type scanner product 0x0010 vendor 0x055f device type scanner product 0x0210 vendor 0x055f device type scanner product 0x0218 vendor 0x055f device type scanner product 0x0219 vendor 0x055f device type scanner product 0x021a vendor 0x055f device type scanner product 0x021b vendor 0x055f device type scanner product 0x021c vendor 0x055f device type scanner product 0x021d vendor 0x055f device type scanner product 0x021e vendor 0x055f device type scanner product 0x021f vendor 0x055f device type scanner product 0x0409 vendor 0x055f device type scanner product 0x4002 vendor 0x05d8 device type scanner product 0x4003 vendor 0x05d8 device type scanner product 0x4004 vendor 0x05d8 device type scanner product 0x4005 vendor 0x05d8 device type scanner product 0x4006 vendor 0x05d8 device type scanner product 0x4007 vendor 0x05d8 device type scanner product 0x4009 vendor 0x05d8 device type scanner product 0x4010 vendor 0x05d8 device type scanner product 0x4011 vendor 0x05d8 device type scanner product 0x0099 vendor 0x05da device type scanner product 0x009a vendor 0x05da device type scanner product 0x00a3 vendor 0x05da device type scanner product 0x00b6 vendor 0x05da device type scanner product 0x30cf vendor 0x05da device type scanner product 0x30d4 vendor 0x05da device type scanner product 0x40b3 vendor 0x05da device type scanner product 0x40b8 vendor 0x05da device type scanner product 0x40ca vendor 0x05da device type scanner product 0x40cb vendor 0x05da device type scanner product 0x40dd vendor 0x05da device type scanner product 0x40ff vendor 0x05da device type scanner product 0x80a3 vendor 0x05da device type scanner product 0x0268 vendor 0x0638 device type scanner product 0x026a vendor 0x0638 device type scanner product 0x0a13 vendor 0x0638 device type scanner product 0x0a15 vendor 0x0638 device type scanner product 0x0a16 vendor 0x0638 device type scanner product 0x0a18 vendor 0x0638 device type scanner product 0x0a23 vendor 0x0638 device type scanner product 0x0a24 vendor 0x0638 device type scanner product 0x0a25 vendor 0x0638 device type scanner product 0x0a27 vendor 0x0638 device type scanner product 0x0a2a vendor 0x0638 device type scanner product 0x0a2b vendor 0x0638 device type scanner product 0x0a2c vendor 0x0638 device type scanner product 0x0a2d vendor 0x0638 device type scanner product 0x0a2e vendor 0x0638 device type scanner product 0x0a2f vendor 0x0638 device type scanner product 0x0a33 vendor 0x0638 device type scanner product 0x0a3a vendor 0x0638 device type scanner product 0x0a3c vendor 0x0638 device type scanner product 0x0a40 vendor 0x0638 device type scanner product 0x0a41 vendor 0x0638 device type scanner product 0x0a45 vendor 0x0638 device type scanner product 0x0a4d vendor 0x0638 device type scanner product 0x0a4e vendor 0x0638 device type scanner product 0x0a4f vendor 0x0638 device type scanner product 0x0a5e vendor 0x0638 device type scanner product 0x0a61 vendor 0x0638 device type scanner product 0x0a65 vendor 0x0638 device type scanner product 0x0a66 vendor 0x0638 device type scanner product 0x0a68 vendor 0x0638 device type scanner product 0x0a82 vendor 0x0638 device type scanner product 0x0a84 vendor 0x0638 device type scanner product 0x0a93 vendor 0x0638 device type scanner product 0x0a94 vendor 0x0638 device type scanner product 0x0aa1 vendor 0x0638 device type scanner product 0x1a35 vendor 0x0638 device type scanner product 0x4004 vendor 0x0686 device type scanner product 0x400d vendor 0x0686 device type scanner product 0x400e vendor 0x0686 device type scanner product 0x0001 vendor 0x06bd device type scanner product 0x0002 vendor 0x06bd device type scanner product 0x0100 vendor 0x06bd device type scanner product 0x2061 vendor 0x06bd device type scanner product 0x208d vendor 0x06bd device type scanner product 0x208f vendor 0x06bd device type scanner product 0x2091 vendor 0x06bd device type scanner product 0x2093 vendor 0x06bd device type scanner product 0x2095 vendor 0x06bd device type scanner product 0x2097 vendor 0x06bd device type scanner product 0x20fd vendor 0x06bd device type scanner product 0x20ff vendor 0x06bd device type scanner product 0x0020 vendor 0x06dc device type scanner product 0x0001 vendor 0x07b3 device type scanner product 0x0010 vendor 0x07b3 device type scanner product 0x0011 vendor 0x07b3 device type scanner product 0x0013 vendor 0x07b3 device type scanner product 0x0015 vendor 0x07b3 device type scanner product 0x0017 vendor 0x07b3 device type scanner product 0x0400 vendor 0x07b3 device type scanner product 0x0401 vendor 0x07b3 device type scanner product 0x0402 vendor 0x07b3 device type scanner product 0x0403 vendor 0x07b3 device type scanner product 0x040b vendor 0x07b3 device type scanner product 0x040e vendor 0x07b3 device type scanner product 0x0412 vendor 0x07b3 device type scanner product 0x0413 vendor 0x07b3 device type scanner product 0x0422 vendor 0x07b3 device type scanner product 0x0454 vendor 0x07b3 device type scanner product 0x045f vendor 0x07b3 device type scanner product 0x0462 vendor 0x07b3 device type scanner product 0x0900 vendor 0x07b3 device type scanner product 0x0002 vendor 0x08f0 device type scanner product 0x0005 vendor 0x08f0 device type scanner product 0x3d5d vendor 0x0924 device type scanner product 0x3da4 vendor 0x0924 device type scanner product 0x420c vendor 0x0924 device type scanner product 0x4265 vendor 0x0924 device type scanner product 0x4293 vendor 0x0924 device type scanner product 0x4294 vendor 0x0924 device type scanner product 0x3210 vendor 0x0a17 device type scanner product 0x1000 vendor 0x0a53 device type scanner product 0x2000 vendor 0x0a53 device type scanner product 0x4600 vendor 0x0a82 device type scanner product 0x4802 vendor 0x0a82 device type scanner product 0x4803 vendor 0x0a82 device type scanner product 0x480c vendor 0x0a82 device type scanner product 0x4810 vendor 0x0a82 device type scanner product 0x6620 vendor 0x0a82 device type scanner product 0x160c vendor 0x1083 device type scanner product 0x160f vendor 0x1083 device type scanner product 0x1614 vendor 0x1083 device type scanner product 0x1617 vendor 0x1083 device type scanner product 0x1618 vendor 0x1083 device type scanner product 0x161a vendor 0x1083 device type scanner product 0x161b vendor 0x1083 device type scanner product 0x161d vendor 0x1083 device type scanner product 0x1620 vendor 0x1083 device type scanner product 0x1622 vendor 0x1083 device type scanner product 0x1623 vendor 0x1083 device type scanner product 0x1624 vendor 0x1083 device type scanner product 0x1626 vendor 0x1083 device type scanner product 0x162b vendor 0x1083 device type scanner product 0x1638 vendor 0x1083 device type scanner product 0x1639 vendor 0x1083 device type scanner product 0x0001 vendor 0x1183 device type scanner product 0x2089 vendor 0x132b device type scanner product 0x0010 vendor 0x1606 device type scanner product 0x0030 vendor 0x1606 device type scanner product 0x0050 vendor 0x1606 device type scanner product 0x0060 vendor 0x1606 device type scanner product 0x0070 vendor 0x1606 device type scanner product 0x0130 vendor 0x1606 device type scanner product 0x0160 vendor 0x1606 device type scanner product 0x0230 vendor 0x1606 device type scanner product 0x4810 vendor 0x1dcc device type scanner product 0x5105 vendor 0x413c device type scanner product 0x5124 vendor 0x413c device type scanner product 0x5250 vendor 0x413c sane-backends-1.0.29/testsuite/tools/data/udev+acl.ref0000666000000000000000000023200413615534521017500 00000000000000# This file was automatically created based on description files (*.desc) # by sane-desc 3.5 from sane-backends 1.0.24git on Wed Jul 31 07:52:49 2013 # # udev rules file for supported USB and SCSI devices # # The SCSI device support is very basic and includes only # scanners that mark themselves as type "scanner" or # SCSI-scanners from HP and other vendors that are entitled "processor" # but are treated accordingly. # # To add a USB device, add a rule to the list below between the # LABEL="libsane_usb_rules_begin" and LABEL="libsane_usb_rules_end" lines. # # To run a script when your device is plugged in, add RUN+="/path/to/script" # to the appropriate rule. # # If your scanner isn't listed below, you can add it as explained above. # # If your scanner is supported by some external backend (brother, epkowa, # hpaio, etc) please ask the author of the backend to provide proper # device detection support for your OS # # If the scanner is supported by sane-backends, please mail the entry to # the sane-devel mailing list (sane-devel@alioth-lists.debian.net). # ACTION!="add", GOTO="libsane_rules_end" ENV{DEVTYPE}=="usb_device", GOTO="libsane_create_usb_dev" SUBSYSTEMS=="scsi", GOTO="libsane_scsi_rules_begin" SUBSYSTEM=="usb_device", GOTO="libsane_usb_rules_begin" SUBSYSTEM!="usb_device", GOTO="libsane_usb_rules_end" # Kernel >= 2.6.22 jumps here LABEL="libsane_create_usb_dev" # For Linux >= 2.6.22 without CONFIG_USB_DEVICE_CLASS=y # If the following rule does not exist on your system yet, uncomment it # ENV{DEVTYPE}=="usb_device", MODE="0664", OWNER="root", GROUP="root" # Kernel < 2.6.22 jumps here LABEL="libsane_usb_rules_begin" # Hewlett-Packard ScanJet 4100C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0101", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4200C | Hewlett-Packard ScanJet 4200Cxi | Hewlett-Packard ScanJet 4200Cse ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0105", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6200C | Hewlett-Packard ScanJet 6250C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0201", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3300c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0205", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4300c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0305", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5200C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0401", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3400c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0405", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 2100C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0505", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6300C | Hewlett-Packard ScanJet 6350C | Hewlett-Packard ScanJet 6390C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0601", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 2200C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0605", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5300C | Hewlett-Packard ScanJet 5370C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0701", ENV{libsane_matched}="yes" # Hewlett-Packard scanjet 4400c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0705", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 7400c | Hewlett-Packard ScanJet 7450c | Hewlett-Packard ScanJet 7490c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0801", ENV{libsane_matched}="yes" # Hewlett-Packard scanjet 4470c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0805", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 2300C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0901", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 2400C | Hewlett-Packard ScanJet G2410 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0a01", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 8200 | Hewlett-Packard ScanJet 8250 | Hewlett-Packard ScanJet 8290 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0b01", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5400c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1005", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5470c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1105", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4500C | Hewlett-Packard ScanJet 5550C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1205", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4570C | Hewlett-Packard ScanJet 5500C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1305", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3670 | Hewlett-Packard ScanJet 3690C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1405", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5590 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1705", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 7650 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1805", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4850C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1b05", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3530C | Hewlett-Packard ScanJet 3570C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2005", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3500C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2205", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3970c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2305", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4070 Photosmart ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2405", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3800 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2605", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G2710 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2805", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 8300 | Hewlett-Packard ScanJet 8350 | Hewlett-Packard ScanJet 8390 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="3805", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 8270 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="3905", ENV{libsane_matched}="yes" # Hewlett-Packard LaserJet M1005 MFP ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="3b17", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4370 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4105", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G3010 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4205", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G3110 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4305", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G4010 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4505", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G4050 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4605", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet N6310 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4705", ENV{libsane_matched}="yes" # Hewlett-Packard LaserJet M1120 MFP ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="5617", ENV{libsane_matched}="yes" # Hewlett-Packard LaserJet M1120n MFP ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="5717", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 ATTRS{idVendor}=="0400", ATTRS{idProduct}=="1000", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 | Mustek BearPaw 2400 ATTRS{idVendor}=="0400", ATTRS{idProduct}=="1001", ENV{libsane_matched}="yes" # Kodak ESP 5100 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4025", ENV{libsane_matched}="yes" # Kodak ESP 5300 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4026", ENV{libsane_matched}="yes" # Kodak ESP 5500 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4027", ENV{libsane_matched}="yes" # Kodak ESP 5000 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4028", ENV{libsane_matched}="yes" # Kodak ESP 3300 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4031", ENV{libsane_matched}="yes" # Kodak ESP 5 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4032", ENV{libsane_matched}="yes" # Kodak ESP 7 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="403e", ENV{libsane_matched}="yes" # Kodak ESP 9 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="403f", ENV{libsane_matched}="yes" # Kodak ESP 5200 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4041", ENV{libsane_matched}="yes" # Kodak ESP 3200 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4043", ENV{libsane_matched}="yes" # Kodak ESP 4100 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4053", ENV{libsane_matched}="yes" # Kodak ESP 6100 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4054", ENV{libsane_matched}="yes" # Kodak ESP 7200 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4056", ENV{libsane_matched}="yes" # Kodak ESP C110 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4057", ENV{libsane_matched}="yes" # Kodak ESP C115 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4058", ENV{libsane_matched}="yes" # Kodak ESP 2150 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4059", ENV{libsane_matched}="yes" # Kodak ESP C310 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="405d", ENV{libsane_matched}="yes" # Kodak ESP C315 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="405e", ENV{libsane_matched}="yes" # Advent AW10 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4060", ENV{libsane_matched}="yes" # Kodak Hero Office 6.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4062", ENV{libsane_matched}="yes" # Kodak Hero 7.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4063", ENV{libsane_matched}="yes" # Kodak Hero 5.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4064", ENV{libsane_matched}="yes" # Kodak ESP 9200 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4065", ENV{libsane_matched}="yes" # Kodak ESP 2170 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4066", ENV{libsane_matched}="yes" # Kodak Hero 9.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4067", ENV{libsane_matched}="yes" # Kodak Hero 3.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="406d", ENV{libsane_matched}="yes" # Kodak i30 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6001", ENV{libsane_matched}="yes" # Kodak i40 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6002", ENV{libsane_matched}="yes" # Kodak i50 | Kodak i55 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6003", ENV{libsane_matched}="yes" # Kodak i60 | Kodak i65 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6004", ENV{libsane_matched}="yes" # Kodak i80 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6005", ENV{libsane_matched}="yes" # Creative WebCam Go Mini ATTRS{idVendor}=="041e", ATTRS{idProduct}=="4007", ENV{libsane_matched}="yes" # Lexmark X70 | Lexmark X73 ATTRS{idVendor}=="043d", ATTRS{idProduct}=="002d", ENV{libsane_matched}="yes" # Lexmark X74 ATTRS{idVendor}=="043d", ATTRS{idProduct}=="0060", ENV{libsane_matched}="yes" # Lexmark X1110 | Lexmark X1130 | Lexmark X1140 # Lexmark X1150 | Lexmark X1170 | Lexmark X1180 # Lexmark X1185 | Lexmark X1195 ATTRS{idVendor}=="043d", ATTRS{idProduct}=="007c", ENV{libsane_matched}="yes" # Lexmark X12xx ATTRS{idVendor}=="043d", ATTRS{idProduct}=="007d", ENV{libsane_matched}="yes" # Genius ColorPage HR6 V1 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2004", ENV{libsane_matched}="yes" # Genius Colorpage HR6 V2 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2007", ENV{libsane_matched}="yes" # Genius Colorpage HR6 V2 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2008", ENV{libsane_matched}="yes" # Genius Colorpage HR6A ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2009", ENV{libsane_matched}="yes" # Genius Colorpage Vivid3x | Genius Colorpage Vivid3 V2 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2011", ENV{libsane_matched}="yes" # Genius Colorpage HR7 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2013", ENV{libsane_matched}="yes" # Genius Colorpage Vivid4 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2014", ENV{libsane_matched}="yes" # Genius Colorpage HR7LE ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2015", ENV{libsane_matched}="yes" # Genius Colorpage HR6X ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2016", ENV{libsane_matched}="yes" # Genius Colorpage Vivid3xe ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2017", ENV{libsane_matched}="yes" # Genius Colorpage Vivid4xe ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201a", ENV{libsane_matched}="yes" # Genius Colorpage Vivid4x ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201b", ENV{libsane_matched}="yes" # Genius Colorpage Vivid 1200 X ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201d", ENV{libsane_matched}="yes" # Genius ColorPage Slim 1200 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201e", ENV{libsane_matched}="yes" # Genius Colorpage Vivid 1200 XE ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201f", ENV{libsane_matched}="yes" # Genius Colorpage SF600 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2021", ENV{libsane_matched}="yes" # Medion/Lifetec/Tevion/Cytron MD5345 | Medion/Lifetec/Tevion/Cytron MD6228 | Medion/Lifetec/Tevion/Cytron MD6471 ATTRS{idVendor}=="0461", ATTRS{idProduct}=="0377", ENV{libsane_matched}="yes" # Xerox 2400 Onetouch ATTRS{idVendor}=="0461", ATTRS{idProduct}=="038b", ENV{libsane_matched}="yes" # Trust Office Scan USB 19200 ATTRS{idVendor}=="047b", ATTRS{idProduct}=="1000", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4300c/Silitek ATTRS{idVendor}=="047b", ATTRS{idProduct}=="1002", ENV{libsane_matched}="yes" # Kyocera FS-1016MFP ATTRS{idVendor}=="0482", ATTRS{idProduct}=="0335", ENV{libsane_matched}="yes" # Compaq S4-100 ATTRS{idVendor}=="049f", ATTRS{idProduct}=="001a", ENV{libsane_matched}="yes" # Benq (Acer) 310U ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="1a20", ENV{libsane_matched}="yes" # Benq (Acer) 620U ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="1a2a", ENV{libsane_matched}="yes" # Benq (Acer) 320U | Benq (Acer) 340U | Mitsubishi Diamondview 648UT ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2022", ENV{libsane_matched}="yes" # Benq (Acer) 620UT ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2040", ENV{libsane_matched}="yes" # Benq (Acer) 640U | Guillemot / Hercules Maxi Scan A4 USB 640U | Guillemot / Hercules Maxi A4 36 bit ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2060", ENV{libsane_matched}="yes" # Benq (Acer) 640bu ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="207e", ENV{libsane_matched}="yes" # Benq (Acer) 3300 | Benq (Acer) 4300 | Mitsubishi Diamondview 650U ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20b0", ENV{libsane_matched}="yes" # Benq (Acer) 640BT ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20be", ENV{libsane_matched}="yes" # Benq (Acer) 1240 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20c0", ENV{libsane_matched}="yes" # Benq (Acer) 3300 | Benq (Acer) 4300 | Guillemot / Hercules Scan@home Touch 1248 (USB) ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20de", ENV{libsane_matched}="yes" # Benq (Acer) 5000 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20f8", ENV{libsane_matched}="yes" # Benq (Acer) 5000E | Benq (Acer) 5000U ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20fc", ENV{libsane_matched}="yes" # Benq (Acer) 5300 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20fe", ENV{libsane_matched}="yes" # Benq (Acer) 5150 | Benq (Acer) 5250 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2137", ENV{libsane_matched}="yes" # BenQ 5550 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2211", ENV{libsane_matched}="yes" # Visioneer Visioneer OneTouch 7100 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0229", ENV{libsane_matched}="yes" # Visioneer 9650 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0390", ENV{libsane_matched}="yes" # Visioneer 9320 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0420", ENV{libsane_matched}="yes" # Visioneer 9450 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0421", ENV{libsane_matched}="yes" # Visioneer 9550 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0422", ENV{libsane_matched}="yes" # Visioneer 9750 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0423", ENV{libsane_matched}="yes" # Visioneer Strobe XP 450 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0424", ENV{libsane_matched}="yes" # Visioneer Strobe XP 200 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0426", ENV{libsane_matched}="yes" # Visioneer Strobe XP 100 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0427", ENV{libsane_matched}="yes" # Visioneer OneTouch 7300 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0444", ENV{libsane_matched}="yes" # Xerox DocuMate510 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0446", ENV{libsane_matched}="yes" # Xerox DocuMate520 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0447", ENV{libsane_matched}="yes" # Xerox DocuMate250 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0448", ENV{libsane_matched}="yes" # Xerox DocuMate252 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0449", ENV{libsane_matched}="yes" # Xerox DocuMate262 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="044c", ENV{libsane_matched}="yes" # Visioneer Strobe XP 300 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0474", ENV{libsane_matched}="yes" # Xerox DocuMate272 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0475", ENV{libsane_matched}="yes" # Xerox DocuMate232 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0476", ENV{libsane_matched}="yes" # Xerox DocuMate152 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0477", ENV{libsane_matched}="yes" # Xerox DocuMate752 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0478", ENV{libsane_matched}="yes" # Visioneer Strobe XP 470 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0479", ENV{libsane_matched}="yes" # Visioneer 9450-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="047a", ENV{libsane_matched}="yes" # Visioneer 9650-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="047b", ENV{libsane_matched}="yes" # Xerox DocuMate510-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="047c", ENV{libsane_matched}="yes" # Xerox DocuMate252-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="048c", ENV{libsane_matched}="yes" # Xerox DocuMate262-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="048d", ENV{libsane_matched}="yes" # Xerox DocuMate272-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="048e", ENV{libsane_matched}="yes" # Visioneer Strobe XP 470-G | Visioneer Patriot 470 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="048f", ENV{libsane_matched}="yes" # Xerox DocuMate250-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0490", ENV{libsane_matched}="yes" # Visioneer Strobe XP 450-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0491", ENV{libsane_matched}="yes" # Xerox DocuMate520-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0492", ENV{libsane_matched}="yes" # Visioneer 9750-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0493", ENV{libsane_matched}="yes" # Visioneer Roadwarrior ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0494", ENV{libsane_matched}="yes" # Xerox DocuMate512 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0495", ENV{libsane_matched}="yes" # Visioneer Patriot 430 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0497", ENV{libsane_matched}="yes" # Visioneer Patriot 680 | Xerox DocuMate632 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0498", ENV{libsane_matched}="yes" # Visioneer Patriot 780 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0499", ENV{libsane_matched}="yes" # Xerox DocuMate752 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="049a", ENV{libsane_matched}="yes" # Visioneer Strobe XP 100,r3 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="049b", ENV{libsane_matched}="yes" # Xerox DocuMate150 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="049c", ENV{libsane_matched}="yes" # Xerox DocuMate162 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="049d", ENV{libsane_matched}="yes" # Xerox DocuMate262i ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="04a7", ENV{libsane_matched}="yes" # Xerox Travel Scanner 100 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="04ac", ENV{libsane_matched}="yes" # Canon DR-2080C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1601", ENV{libsane_matched}="yes" # Canon CR-180 | Canon CR-180II ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1602", ENV{libsane_matched}="yes" # Canon DR-9080C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1603", ENV{libsane_matched}="yes" # Canon DR-7080C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1604", ENV{libsane_matched}="yes" # Canon DR-5010C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1606", ENV{libsane_matched}="yes" # Canon DR-6080 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1607", ENV{libsane_matched}="yes" # Canon DR-2580C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1608", ENV{libsane_matched}="yes" # Canon DR-3080CII ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1609", ENV{libsane_matched}="yes" # Canon DR-2050C | Canon DR-2050SP ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="160a", ENV{libsane_matched}="yes" # Canon DR-7580 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="160b", ENV{libsane_matched}="yes" # Canon PIXMA MP750 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1706", ENV{libsane_matched}="yes" # Canon PIXMA MP780 | Canon PIXMA MP790 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1707", ENV{libsane_matched}="yes" # Canon PIXMA MP760 | Canon PIXMA MP770 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1708", ENV{libsane_matched}="yes" # Canon PIXMA MP150 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1709", ENV{libsane_matched}="yes" # Canon PIXMA MP170 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170a", ENV{libsane_matched}="yes" # Canon PIXMA MP450 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170b", ENV{libsane_matched}="yes" # Canon PIXMA MP500 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170c", ENV{libsane_matched}="yes" # Canon PIXMA MP800 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170d", ENV{libsane_matched}="yes" # Canon PIXMA MP800R ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170e", ENV{libsane_matched}="yes" # Canon PIXMA MP530 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1712", ENV{libsane_matched}="yes" # Canon PIXMA MP830 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1713", ENV{libsane_matched}="yes" # Canon PIXMA MP160 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1714", ENV{libsane_matched}="yes" # Canon PIXMA MP180 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1715", ENV{libsane_matched}="yes" # Canon PIXMA MP460 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1716", ENV{libsane_matched}="yes" # Canon PIXMA MP510 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1717", ENV{libsane_matched}="yes" # Canon PIXMA MP600 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1718", ENV{libsane_matched}="yes" # Canon PIXMA MP600R ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1719", ENV{libsane_matched}="yes" # Canon PIXMA MP810 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171a", ENV{libsane_matched}="yes" # Canon PIXMA MP960 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171b", ENV{libsane_matched}="yes" # Canon PIXMA MX7600 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171c", ENV{libsane_matched}="yes" # Canon PIXMA MP210 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1721", ENV{libsane_matched}="yes" # Canon PIXMA MP220 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1722", ENV{libsane_matched}="yes" # Canon PIXMA MP470 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1723", ENV{libsane_matched}="yes" # Canon PIXMA MP520 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1724", ENV{libsane_matched}="yes" # Canon PIXMA MP610 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1725", ENV{libsane_matched}="yes" # Canon PIXMA MP970 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1726", ENV{libsane_matched}="yes" # Canon PIXMA MX300 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1727", ENV{libsane_matched}="yes" # Canon PIXMA MX310 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1728", ENV{libsane_matched}="yes" # Canon PIXMA MX700 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1729", ENV{libsane_matched}="yes" # Canon PIXMA MP140 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172b", ENV{libsane_matched}="yes" # Canon PIXMA MX850 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172c", ENV{libsane_matched}="yes" # Canon PIXMA MP980 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172d", ENV{libsane_matched}="yes" # Canon PIXMA MP630 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172e", ENV{libsane_matched}="yes" # Canon PIXMA MP620 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172f", ENV{libsane_matched}="yes" # Canon PIXMA MP540 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1730", ENV{libsane_matched}="yes" # Canon PIXMA MP480 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1731", ENV{libsane_matched}="yes" # Canon PIXMA MP240 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1732", ENV{libsane_matched}="yes" # Canon PIXMA MP260 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1733", ENV{libsane_matched}="yes" # Canon PIXMA MP190 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1734", ENV{libsane_matched}="yes" # Canon PIXMA MX860 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1735", ENV{libsane_matched}="yes" # Canon PIXMA MX320 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1736", ENV{libsane_matched}="yes" # Canon PIXMA MX330 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1737", ENV{libsane_matched}="yes" # Canon PIXMA MP250 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173a", ENV{libsane_matched}="yes" # Canon PIXMA MP270 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173b", ENV{libsane_matched}="yes" # Canon PIXMA MP490 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173c", ENV{libsane_matched}="yes" # Canon PIXMA MP550 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173d", ENV{libsane_matched}="yes" # Canon PIXMA MP560 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", ENV{libsane_matched}="yes" # Canon PIXMA MP640 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173f", ENV{libsane_matched}="yes" # Canon PIXMA MP990 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1740", ENV{libsane_matched}="yes" # Canon PIXMA MX340 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1741", ENV{libsane_matched}="yes" # Canon PIXMA MX350 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1742", ENV{libsane_matched}="yes" # Canon PIXMA MX870 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1743", ENV{libsane_matched}="yes" # Canon PIXMA MP280 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1746", ENV{libsane_matched}="yes" # Canon PIXMA MP495 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1747", ENV{libsane_matched}="yes" # Canon PIXMA MG5100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1748", ENV{libsane_matched}="yes" # Canon PIXMA MG5200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1749", ENV{libsane_matched}="yes" # Canon PIXMA MG6100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174a", ENV{libsane_matched}="yes" # Canon PIXMA MG8100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174b", ENV{libsane_matched}="yes" # Canon PIXMA MX360 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174d", ENV{libsane_matched}="yes" # Canon PIXMA MX410 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174e", ENV{libsane_matched}="yes" # Canon PIXMA MX420 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174f", ENV{libsane_matched}="yes" # Canon PIXMA MX880 Series | Canon PIXMA MX882 | Canon PIXMA MX885 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1750", ENV{libsane_matched}="yes" # Canon PIXMA MG2100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1751", ENV{libsane_matched}="yes" # Canon PIXMA MG3100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1752", ENV{libsane_matched}="yes" # Canon PIXMA MG4100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1753", ENV{libsane_matched}="yes" # Canon PIXMA MG5300 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1754", ENV{libsane_matched}="yes" # Canon PIXMA MG6200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1755", ENV{libsane_matched}="yes" # Canon PIXMA MG8200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1756", ENV{libsane_matched}="yes" # Canon PIXMA MP493 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1757", ENV{libsane_matched}="yes" # Canon PIXMA E500 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1758", ENV{libsane_matched}="yes" # Canon PIXMA MX370 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1759", ENV{libsane_matched}="yes" # Canon PIXMA E600 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175a", ENV{libsane_matched}="yes" # Canon PIXMA MX430 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175b", ENV{libsane_matched}="yes" # Canon PIXMA MX510 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175c", ENV{libsane_matched}="yes" # Canon PIXMA MX710 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175d", ENV{libsane_matched}="yes" # Canon PIXMA MX890 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175e", ENV{libsane_matched}="yes" # Canon PIXMA MP230 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175f", ENV{libsane_matched}="yes" # Canon PIXMA MG2200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1760", ENV{libsane_matched}="yes" # Canon PIXMA E510 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1761", ENV{libsane_matched}="yes" # Canon PIXMA MG3200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1762", ENV{libsane_matched}="yes" # Canon PIXMA MG4200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1763", ENV{libsane_matched}="yes" # Canon PIXMA MG5400 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1764", ENV{libsane_matched}="yes" # Canon PIXMA MG6300 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1765", ENV{libsane_matched}="yes" # Canon PIXMA MX390 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1766", ENV{libsane_matched}="yes" # Canon PIXMA E610 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1767", ENV{libsane_matched}="yes" # Canon PIXMA MX450 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1768", ENV{libsane_matched}="yes" # Canon PIXMA MX520 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1769", ENV{libsane_matched}="yes" # Canon PIXMA MX720 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="176a", ENV{libsane_matched}="yes" # Canon PIXMA MX920 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="176b", ENV{libsane_matched}="yes" # Canon CanoScan 8800F ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1901", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 100 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1904", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 200 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1905", ENV{libsane_matched}="yes" # Canon CanoScan 700F ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1907", ENV{libsane_matched}="yes" # Canon CanoScan 9000F ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1908", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 110 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1909", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 210 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="190a", ENV{libsane_matched}="yes" # Canon CanoScan 9000F Mark II ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="190d", ENV{libsane_matched}="yes" # Canon CanoScan fb630u | Canon CanoScan fb636u ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2204", ENV{libsane_matched}="yes" # Canon CanoScan N650U/N656U ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2206", ENV{libsane_matched}="yes" # Canon CanoScan N1220U ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2207", ENV{libsane_matched}="yes" # Canon CanoScan D660U ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2208", ENV{libsane_matched}="yes" # Canon CanoScan N670U/N676U/LiDE20 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220d", ENV{libsane_matched}="yes" # Canon CanoScan N1240U/LiDE30 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220e", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 35 | Canon CanoScan LiDE 40 | Canon CanoScan LiDE 50 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2213", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 60 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="221c", ENV{libsane_matched}="yes" # Canon CanoScan LiDE25 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2220", ENV{libsane_matched}="yes" # Canon DR-1210C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2222", ENV{libsane_matched}="yes" # Canon PIXMA MP730 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="262f", ENV{libsane_matched}="yes" # Canon PIXMA MP700 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2630", ENV{libsane_matched}="yes" # Canon PIXMA MP360 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263c", ENV{libsane_matched}="yes" # Canon PIXMA MP370 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263d", ENV{libsane_matched}="yes" # Canon PIXMA MP390 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263e", ENV{libsane_matched}="yes" # Canon PIXMA MP375R ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263f", ENV{libsane_matched}="yes" # Canon PIXMA MP740 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264c", ENV{libsane_matched}="yes" # Canon PIXMA MP710 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264d", ENV{libsane_matched}="yes" # Canon imageCLASS MF5630 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264e", ENV{libsane_matched}="yes" # Canon laserBase MF5650 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264f", ENV{libsane_matched}="yes" # Canon imageCLASS MF8170c ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2659", ENV{libsane_matched}="yes" # Canon imageCLASS MF5730 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265d", ENV{libsane_matched}="yes" # Canon imageCLASS MF5750 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265e", ENV{libsane_matched}="yes" # Canon imageCLASS MF5770 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265f", ENV{libsane_matched}="yes" # Canon imageCLASS MF3110 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2660", ENV{libsane_matched}="yes" # Canon imageCLASS MF3240 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2684", ENV{libsane_matched}="yes" # Canon imageCLASS MF6500 series | Canon imageCLASS MF6550 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2686", ENV{libsane_matched}="yes" # Canon imageCLASS MF4120 | Canon imageCLASS MF4122 | Canon imageCLASS MF4140 # Canon imageCLASS MF4150 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26a3", ENV{libsane_matched}="yes" # Canon imageCLASS MF4660 | Canon imageCLASS MF4690 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b0", ENV{libsane_matched}="yes" # Canon imageCLASS MF4010 | Canon imageCLASS MF4018 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b4", ENV{libsane_matched}="yes" # Canon imageCLASS MF4270 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b5", ENV{libsane_matched}="yes" # Canon imageRUNNER 1020/1024/1025 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26e6", ENV{libsane_matched}="yes" # Canon imageCLASS MF4370dn | Canon imageCLASS MF4380dn ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ec", ENV{libsane_matched}="yes" # Canon imageCLASS D480 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ed", ENV{libsane_matched}="yes" # Canon I-SENSYS MF4320d | Canon I-SENSYS MF4330d | Canon imageCLASS MF4350d ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ee", ENV{libsane_matched}="yes" # Canon imageCLASS D420 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ef", ENV{libsane_matched}="yes" # Canon i-SENSYS MF5880dn ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26f9", ENV{libsane_matched}="yes" # Canon i-SENSYS MF6680dn ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26fa", ENV{libsane_matched}="yes" # Canon imageCLASS MF8030 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2707", ENV{libsane_matched}="yes" # Canon i-SENSYS MF4550d ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2736", ENV{libsane_matched}="yes" # Canon imageCLASS MF4410 | Canon imageCLASS MF4430 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2737", ENV{libsane_matched}="yes" # Canon i-SENSYS MF3010 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2759", ENV{libsane_matched}="yes" # Nikon LS 40 ED | Nikon LS 40 ED | Nikon Coolspan IV ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4000", ENV{libsane_matched}="yes" # Nikon LS 50 ED | Nikon Coolscan V ED | Nikon LS 50 ED # Nikon Coolscan V ED ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4001", ENV{libsane_matched}="yes" # Nikon Super Coolscan LS-5000 ED | Nikon Super Coolscan LS-5000 ED ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4002", ENV{libsane_matched}="yes" # Epson Perfection 636U | Epson GT-7000U | Epson Perfection 636U ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0101", ENV{libsane_matched}="yes" # Epson Perfection 610 | Epson GT-6600U | Epson Perfection 610 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0103", ENV{libsane_matched}="yes" # Epson Perfection 1200U | Epson Perfection 1200Photo | Epson GT-7600U # Epson GT-7600UF | Epson Perfection 1200U | Epson Perfection 1200U PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0104", ENV{libsane_matched}="yes" # Epson Stylus Scan 2000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0105", ENV{libsane_matched}="yes" # Epson Stylus Scan 2500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0106", ENV{libsane_matched}="yes" # Epson Expression 1600 | Epson ES-2000 | Epson Expression 1600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0107", ENV{libsane_matched}="yes" # Epson ES-8500 | Epson Expression 1640XL ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0109", ENV{libsane_matched}="yes" # Epson Perfection 1640 | Epson GT-8700 | Epson GT-8700F # Epson Perfection 1640SU | Epson Perfection 1640SU PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010a", ENV{libsane_matched}="yes" # Epson Perfection 1240 | Epson GT-7700U | Epson Perfection 1240U ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010b", ENV{libsane_matched}="yes" # Epson Perfection 640 | Epson GT-6700U | Epson Perfection 640U ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010c", ENV{libsane_matched}="yes" # Epson Expression 1680 | Epson ES-2200 | Epson Expression 1680 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010e", ENV{libsane_matched}="yes" # Epson Perfection 1250 | Epson Perfection 1250Photo ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010f", ENV{libsane_matched}="yes" # Epson Perfection 1650 | Epson GT-8200U | Epson GT-8200UF # Epson Perfection 1650 | Epson Perfection 1650 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0110", ENV{libsane_matched}="yes" # Epson Perfection 2450 | Epson GT-9700F | Epson Perfection 2450 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0112", ENV{libsane_matched}="yes" # Epson Perfection 660 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0114", ENV{libsane_matched}="yes" # Epson Perfection 2400 | Epson GT-9300UF | Epson Perfection 2400 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011b", ENV{libsane_matched}="yes" # Epson Perfection 3200 | Epson GT-9800F | Epson Perfection 3200 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011c", ENV{libsane_matched}="yes" # Epson Perfection 1260 | Epson Perfection 1260Photo ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011d", ENV{libsane_matched}="yes" # Epson Perfection 1660 | Epson GT-8300UF | Epson Perfection 1660 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011e", ENV{libsane_matched}="yes" # Epson Perfection 1670 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011f", ENV{libsane_matched}="yes" # Epson Perfection 1270 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0120", ENV{libsane_matched}="yes" # Epson Perfection 2480 | Epson Perfection 2580 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0121", ENV{libsane_matched}="yes" # Epson Perfection 3490 | Epson Perfection 3590 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0122", ENV{libsane_matched}="yes" # Epson ES-7000H | Epson GT-15000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0126", ENV{libsane_matched}="yes" # Epson Perfection 4870 | Epson GT-X700 | Epson Perfection 4870 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0128", ENV{libsane_matched}="yes" # Epson ES-10000G | Epson Expression 10000XL ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0129", ENV{libsane_matched}="yes" # Epson Perfection 4990 | Epson GT-X800 | Epson Perfection 4990 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012a", ENV{libsane_matched}="yes" # Epson ES-H300 | Epson GT-2500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012b", ENV{libsane_matched}="yes" # Epson V700 | Epson V750 | Epson GT-X900 # Epson Perfection V700 Photo | Epson Perfection V750 Photo ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012c", ENV{libsane_matched}="yes" # Epson GT-X970 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0135", ENV{libsane_matched}="yes" # Epson CX-5200 | Epson CX-5400 | Epson CC-600PX # Epson Stylus CX5100 | Epson Stylus CX5200 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0801", ENV{libsane_matched}="yes" # Epson CX-3200 | Epson CC-570L | Epson Stylus CX3100 # Epson Stylus CX3200 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0802", ENV{libsane_matched}="yes" # Epson CX-6300 | Epson CX-6400 | Epson Stylus CX6300 # Epson Stylus CX6400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0805", ENV{libsane_matched}="yes" # Epson RX-600 | Epson PM-A850 | Epson Stylus Photo RX600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0806", ENV{libsane_matched}="yes" # Epson RX-500 | Epson Stylus Photo RX500 | Epson Stylus Photo RX510 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0807", ENV{libsane_matched}="yes" # Epson CX-5400 | Epson Stylus CX5300 | Epson Stylus CX5400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0808", ENV{libsane_matched}="yes" # Epson Stylus CX-1500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080c", ENV{libsane_matched}="yes" # Epson CX-4600 | Epson Stylus CX4500 | Epson Stylus CX4600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080d", ENV{libsane_matched}="yes" # Epson CX-3600 | Epson CX-3650 | Epson PX-A550 # Epson Stylus CX3500 | Epson Stylus CX3600 | Epson Stylus CX3650 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080e", ENV{libsane_matched}="yes" # Epson RX-425 | Epson Stylus Photo RX420 | Epson Stylus Photo RX425 # Epson Stylus Photo RX430 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080f", ENV{libsane_matched}="yes" # Epson RX-700 | Epson PM-A900 | Epson Stylus Photo RX700 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0810", ENV{libsane_matched}="yes" # Epson RX-620 | Epson PM-A870 | Epson Stylus Photo RX620 # Epson Stylus Photo RX630 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0811", ENV{libsane_matched}="yes" # Epson CX-6500 | Epson CX-6600 | Epson Stylus CX6500 # Epson Stylus CX6600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0813", ENV{libsane_matched}="yes" # Epson PM-A700 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0814", ENV{libsane_matched}="yes" # Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson AcuLaser CX11 # Epson AcuLaser CX11NF | Epson LP-A500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0815", ENV{libsane_matched}="yes" # Epson LP-M5500 | Epson LP-M5500F ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0817", ENV{libsane_matched}="yes" # Epson DX-3850 | Epson CX-3700 | Epson CX-3800 # Epson DX-3800 | Epson Stylus CX3700 | Epson Stylus CX3800 # Epson Stylus DX3800 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0818", ENV{libsane_matched}="yes" # Epson CX-4800 | Epson PX-A650 | Epson Stylus CX4700 # Epson Stylus CX4800 | Epson Stylus DX4800 | Epson Stylus DX4850 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0819", ENV{libsane_matched}="yes" # Epson PM-A750 | Epson Stylus Photo RX520 | Epson Stylus Photo RX530 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081a", ENV{libsane_matched}="yes" # Epson PM-A890 | Epson Stylus Photo RX640 | Epson Stylus Photo RX650 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081c", ENV{libsane_matched}="yes" # Epson PM-A950 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081d", ENV{libsane_matched}="yes" # Epson Stylus CX7700 | Epson Stylus CX7800 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081f", ENV{libsane_matched}="yes" # Epson CX-4200 | Epson Stylus CX4100 | Epson Stylus CX4200 # Epson Stylus DX4200 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0820", ENV{libsane_matched}="yes" # Epson PM-A820 | Epson Stylus Photo RX560 | Epson Stylus Photo RX580 # Epson Stylus Photo RX590 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0827", ENV{libsane_matched}="yes" # Epson PM-A970 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0828", ENV{libsane_matched}="yes" # Epson PM-T990 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0829", ENV{libsane_matched}="yes" # Epson PM-A920 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082a", ENV{libsane_matched}="yes" # Epson CX-5000 | Epson DX-5000 | Epson DX-5050 # Epson Stylus CX4900 | Epson Stylus CX5000 | Epson Stylus DX5000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082b", ENV{libsane_matched}="yes" # Epson DX-6000 | Epson PX-A720 | Epson Stylus CX5900 # Epson Stylus CX6000 | Epson Stylus DX6000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082e", ENV{libsane_matched}="yes" # Epson DX-4050 | Epson PX-A620 | Epson Stylus CX3900 # Epson Stylus DX4000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082f", ENV{libsane_matched}="yes" # Epson ME 200 | Epson Stylus CX2800 | Epson Stylus CX2900 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0830", ENV{libsane_matched}="yes" # Epson LP-M5600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0833", ENV{libsane_matched}="yes" # Epson LP-M6000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0834", ENV{libsane_matched}="yes" # Epson AcuLaser CX21 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0835", ENV{libsane_matched}="yes" # Epson PM-T960 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0836", ENV{libsane_matched}="yes" # Epson PM-A940 | Epson Stylus Photo RX680 | Epson Stylus Photo RX685 # Epson Stylus Photo RX690 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0837", ENV{libsane_matched}="yes" # Epson DX-7400 | Epson PX-A640 | Epson Stylus CX7300 # Epson Stylus CX7400 | Epson Stylus DX7400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0838", ENV{libsane_matched}="yes" # Epson PX-A740 | Epson Stylus CX8300 | Epson Stylus CX8400 # Epson Stylus DX8400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0839", ENV{libsane_matched}="yes" # Epson PX-FA700 | Epson Stylus CX9300F | Epson Stylus CX9400Fax # Epson Stylus DX9400F ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083a", ENV{libsane_matched}="yes" # Epson PM-A840 | Epson PM-A840S | Epson Stylus Photo RX585 # Epson Stylus Photo RX595 | Epson Stylus Photo RX610 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083c", ENV{libsane_matched}="yes" # Epson ME 300 | Epson PX-401A | Epson Stylus NX100 # Epson Stylus SX100 | Epson Stylus TX100 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0841", ENV{libsane_matched}="yes" # Epson LP-M5000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0843", ENV{libsane_matched}="yes" # Epson Artisan 800 | Epson EP-901A | Epson EP-901F # Epson Stylus Photo PX800FW | Epson Stylus Photo TX800FW ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0844", ENV{libsane_matched}="yes" # Epson Artisan 700 | Epson EP-801A | Epson Stylus Photo PX700W # Epson Stylus Photo TX700W ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0846", ENV{libsane_matched}="yes" # Epson ME Office 700FW | Epson PX-601F | Epson Stylus Office BX600FW # Epson Stylus Office TX600FW | Epson Stylus SX600FW | Epson WorkForce 600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0847", ENV{libsane_matched}="yes" # Epson ME Office 600F | Epson Stylus Office BX300F | Epson Stylus Office TX300F # Epson Stylus NX300 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0848", ENV{libsane_matched}="yes" # Epson Stylus NX200 | Epson Stylus SX200 | Epson Stylus SX205 # Epson Stylus TX200 | Epson Stylus TX203 | Epson Stylus TX209 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0849", ENV{libsane_matched}="yes" # Epson PX-501A | Epson Stylus NX400 | Epson Stylus SX400 # Epson Stylus SX405 | Epson Stylus TX400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084a", ENV{libsane_matched}="yes" # Epson WorkForce 500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084c", ENV{libsane_matched}="yes" # Epson PX-402A | Epson Stylus NX110 Series | Epson Stylus SX110 Series # Epson Stylus TX110 Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084d", ENV{libsane_matched}="yes" # Epson ME OFFICE 510 | Epson Stylus NX210 Series | Epson Stylus SX210 Series # Epson Stylus TX210 Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084f", ENV{libsane_matched}="yes" # Epson Stylus NX410 Series | Epson Stylus SX410 Series | Epson Stylus TX410 Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0851", ENV{libsane_matched}="yes" # Epson ME OFFICE 650FN Series | Epson Stylus Office BX310FN Series | Epson Stylus Office TX510FN Series # Epson WorkForce 310 Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0854", ENV{libsane_matched}="yes" # Epson PX-502A | Epson Stylus NX510 Series | Epson Stylus SX510W Series # Epson Stylus TX550W Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0856", ENV{libsane_matched}="yes" # Epson Stylus SX125 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="085c", ENV{libsane_matched}="yes" # Fujitsu fi-4010CU ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1029", ENV{libsane_matched}="yes" # Fujitsu fi-4120C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1041", ENV{libsane_matched}="yes" # Fujitsu fi-4220C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1042", ENV{libsane_matched}="yes" # Fujitsu fi-4530C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1078", ENV{libsane_matched}="yes" # Fujitsu fi-5750C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1095", ENV{libsane_matched}="yes" # Fujitsu fi-5110EOX/2 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1096", ENV{libsane_matched}="yes" # Fujitsu fi-5110C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1097", ENV{libsane_matched}="yes" # Fujitsu fi-5650C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ad", ENV{libsane_matched}="yes" # Fujitsu fi-4120C2 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ae", ENV{libsane_matched}="yes" # Fujitsu fi-4220C2 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10af", ENV{libsane_matched}="yes" # Fujitsu fi-60F ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10c7", ENV{libsane_matched}="yes" # Fujitsu fi-4340C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10cf", ENV{libsane_matched}="yes" # Fujitsu fi-5120C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e0", ENV{libsane_matched}="yes" # Fujitsu fi-5220C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e1", ENV{libsane_matched}="yes" # Fujitsu fi-5530C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e2", ENV{libsane_matched}="yes" # Fujitsu fi-5110EOX3 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e6", ENV{libsane_matched}="yes" # Fujitsu fi-5900C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e7", ENV{libsane_matched}="yes" # Fujitsu fi-5015C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ef", ENV{libsane_matched}="yes" # Fujitsu fi-5110EOXM ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10f2", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S500 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10fe", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S500M ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1135", ENV{libsane_matched}="yes" # Fujitsu fi-5530C2 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114a", ENV{libsane_matched}="yes" # Fujitsu fi-6140 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114d", ENV{libsane_matched}="yes" # Fujitsu fi-6240 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114e", ENV{libsane_matched}="yes" # Fujitsu fi-6130 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114f", ENV{libsane_matched}="yes" # Fujitsu fi-6230 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1150", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S510 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1155", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S300 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1156", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S510M ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="116f", ENV{libsane_matched}="yes" # Fujitsu fi-6770 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1174", ENV{libsane_matched}="yes" # Fujitsu fi-6770A ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1175", ENV{libsane_matched}="yes" # Fujitsu fi-6670 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1176", ENV{libsane_matched}="yes" # Fujitsu fi-6670A ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1177", ENV{libsane_matched}="yes" # Fujitsu fi-6750S ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1178", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S300M ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="117f", ENV{libsane_matched}="yes" # Fujitsu fi-6800 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119d", ENV{libsane_matched}="yes" # Fujitsu fi-6800-CGA ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119e", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S1500 | Fujitsu ScanSnap S1500M ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11a2", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S1300 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11ed", ENV{libsane_matched}="yes" # Fujitsu fi-6140Z ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f1", ENV{libsane_matched}="yes" # Fujitsu fi-6240Z ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f2", ENV{libsane_matched}="yes" # Fujitsu fi-6130Z ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f3", ENV{libsane_matched}="yes" # Fujitsu fi-6230Z ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f4", ENV{libsane_matched}="yes" # Fujitsu fi-6110 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11fc", ENV{libsane_matched}="yes" # Fujitsu fi-5950 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1213", ENV{libsane_matched}="yes" # Fujitsu ScanSnap iX500 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="132b", ENV{libsane_matched}="yes" # Konica e-mini ATTRS{idVendor}=="04c8", ATTRS{idProduct}=="0722", ENV{libsane_matched}="yes" # Panasonic KV-S2026C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1000", ENV{libsane_matched}="yes" # Panasonic KV-S2046C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1001", ENV{libsane_matched}="yes" # Panasonic KV-S1025C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1006", ENV{libsane_matched}="yes" # Panasonic KV-S1020C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1007", ENV{libsane_matched}="yes" # Panasonic KV-S2048C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1009", ENV{libsane_matched}="yes" # Panasonic KV-S2028C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100a", ENV{libsane_matched}="yes" # Panasonic KV-S4085C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100c", ENV{libsane_matched}="yes" # Panasonic KV-S4065C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100d", ENV{libsane_matched}="yes" # Panasonic KV-S7075C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100e", ENV{libsane_matched}="yes" # Panasonic KV-SS080 ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100f", ENV{libsane_matched}="yes" # Panasonic KV-S1045C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1010", ENV{libsane_matched}="yes" # Samsung SCX-4x16 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3409", ENV{libsane_matched}="yes" # Samsung SCX-6x20 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="340d", ENV{libsane_matched}="yes" # Samsung MFP-560 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="340e", ENV{libsane_matched}="yes" # Samsung MFP-750 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="340f", ENV{libsane_matched}="yes" # Samsung SCX-4x20 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3412", ENV{libsane_matched}="yes" # Samsung SCX-4100 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3413", ENV{libsane_matched}="yes" # Samsung SCX-4x21 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3419", ENV{libsane_matched}="yes" # Samsung SCX-5x30 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341a", ENV{libsane_matched}="yes" # Samsung SCX-4200 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341b", ENV{libsane_matched}="yes" # Samsung CLX-3160 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341c", ENV{libsane_matched}="yes" # Samsung SCX-6x22 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341d", ENV{libsane_matched}="yes" # Samsung SCX4725 | Samsung SCX4725-FN ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341f", ENV{libsane_matched}="yes" # Samsung SCX-6x45 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3420", ENV{libsane_matched}="yes" # Samsung CLX-8380 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3421", ENV{libsane_matched}="yes" # Samsung CLX-2160 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3425", ENV{libsane_matched}="yes" # Samsung SCX-4500 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3426", ENV{libsane_matched}="yes" # Samsung CLX-6200 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3427", ENV{libsane_matched}="yes" # Samsung CLX-6240 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3428", ENV{libsane_matched}="yes" # Samsung SCX-6x55 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3429", ENV{libsane_matched}="yes" # Samsung CLX-3170fn (CLX-3170 Series) | Samsung CLX-3175FW ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342a", ENV{libsane_matched}="yes" # Samsung SCX-4500W ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", ENV{libsane_matched}="yes" # Samsung SCX-4824 (SCX-4x24 Series) ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342c", ENV{libsane_matched}="yes" # Samsung SCX-4828FN (SCX-4x28 Series) ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342d", ENV{libsane_matched}="yes" # Samsung SCX-4300 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342e", ENV{libsane_matched}="yes" # Samsung SCX-5835_5935 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342f", ENV{libsane_matched}="yes" # Samsung SCX-5635 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3430", ENV{libsane_matched}="yes" # Samsung SCX-4x26 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3432", ENV{libsane_matched}="yes" # Samsung SCX-4600 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3433", ENV{libsane_matched}="yes" # Samsung SCX-4623 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3434", ENV{libsane_matched}="yes" # Samsung MFP-65x ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3435", ENV{libsane_matched}="yes" # Samsung SCX-6545 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3437", ENV{libsane_matched}="yes" # Samsung CLX-8385 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3439", ENV{libsane_matched}="yes" # Samsung CLX-6220 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343a", ENV{libsane_matched}="yes" # Samsung CLX-6250 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343b", ENV{libsane_matched}="yes" # Samsung SCX-4825FN (SCX-4x25 Series) ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343c", ENV{libsane_matched}="yes" # Samsung CLX-3185 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343d", ENV{libsane_matched}="yes" # Samsung CLX-8540 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343f", ENV{libsane_matched}="yes" # Samsung SCX-4623FW ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3440", ENV{libsane_matched}="yes" # Samsung SCX-3205W (SCX-3200 Series) ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3441", ENV{libsane_matched}="yes" # Samsung SCX-6545X ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3442", ENV{libsane_matched}="yes" # Samsung SCX-6x55X ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3443", ENV{libsane_matched}="yes" # Samsung CLX-8385X ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3444", ENV{libsane_matched}="yes" # Samsung SCX-5835_5935X ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3446", ENV{libsane_matched}="yes" # Samsung SCX-4833FD | Samsung SCX-4835FD ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="344b", ENV{libsane_matched}="yes" # Samsung SCX-3400 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="344f", ENV{libsane_matched}="yes" # Samsung SF-760 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3450", ENV{libsane_matched}="yes" # Samsung SCX-4729FD ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3453", ENV{libsane_matched}="yes" # Samsung CLX-6260 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3455", ENV{libsane_matched}="yes" # Samsung CLX-3300 Series ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3456", ENV{libsane_matched}="yes" # Samsung SCX-470x ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3457", ENV{libsane_matched}="yes" # Samsung CLX-4190 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="345a", ENV{libsane_matched}="yes" # Samsung SCX-4650 4x21S Series ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="345b", ENV{libsane_matched}="yes" # Samsung M337x 387x 407x Series ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3460", ENV{libsane_matched}="yes" # Samsung M267x 287x Series ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3461", ENV{libsane_matched}="yes" # Samsung SCX-681x ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3466", ENV{libsane_matched}="yes" # Samsung C460 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3468", ENV{libsane_matched}="yes" # Pentax DSmobile 600 ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="2038", ENV{libsane_matched}="yes" # Aiptek Aiptek Pencam ATTRS{idVendor}=="0553", ATTRS{idProduct}=="0202", ENV{libsane_matched}="yes" # Mustek ScanExpress 1200 CU ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" # Mustek ScanExpress 600 CU ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" # Mustek ScanExpress 1200 UB | Trust Compact Scan USB 19200 ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0006", ENV{libsane_matched}="yes" # Mustek ScanExpress 1200 CU Plus ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0008", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 F ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" # Mustek ScanExpress A3 USB ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0210", ENV{libsane_matched}="yes" # Mustek BearPaw 2400 CS | Mustek BearPaw 2400 TA | Trust 240TH Easy Webscan Gold ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0218", ENV{libsane_matched}="yes" # Mustek BearPaw 2400 CS Plus | Mustek BearPaw 2400 TA Plus | Mustek Plug-n-Scan 2400 MT # Mustek Plug-n-Scan 2400 M | Packard Bell Diamond 2450 ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0219", ENV{libsane_matched}="yes" # Mustek BearPaw 2448 CS Plus | Mustek BearPaw 2448 TA Plus ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021a", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 CU Plus | Packard Bell Diamond 1200 Plus ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021b", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 CU Plus | Mustek BearPaw 1248 CU | Packard Bell Diamond 1200 Plus # Trust Direct WebScan 19200 ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021c", ENV{libsane_matched}="yes" # Mustek BearPaw 2400 CU Plus ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021d", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 CS | Mustek BearPaw 1200 TA ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021e", ENV{libsane_matched}="yes" # Mustek ScanExpress 1248 UB ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021f", ENV{libsane_matched}="yes" # Mustek BearPaw 2448TA Pro ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0409", ENV{libsane_matched}="yes" # Artec/Ultima Ultima 2000 | Artec/Ultima Ultima 2000 e+ | Boeder Sm@rtScan Slim Edition # Fujitsu 1200CUS | Googlegear 2000 | Medion/Lifetec/Tevion/Cytron MD 4394 # Medion/Lifetec/Tevion/Cytron MD/LT 9375 | Medion/Lifetec/Tevion/Cytron MD/LT 9385 | Medion/Lifetec/Tevion/Cytron LT 9452 # Medion/Lifetec/Tevion/Cytron MD 9458 | Mustek BearPaw 1200 CU | Mustek BearPaw 2400 CU # Mustek ScanExpress 1200 UB Plus | Mustek ScanExpress 2400 USB | Mustek ScanMagic 1200 UB Plus # Packard Bell Diamond 1200 | Trust Compact Scan USB 19200 | Trust Flat Scan USB 19200 ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4002", ENV{libsane_matched}="yes" # Artec/Ultima E+ 48U | Medion/Lifetec/Tevion/Cytron MD9693 | Medion/Lifetec/Tevion/Cytron MD9705 # Medion/Lifetec/Tevion/Cytron MD4394 | Microstar MR 9791 ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4003", ENV{libsane_matched}="yes" # Artec/Ultima E+ Pro ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4004", ENV{libsane_matched}="yes" # Memorex MEM 48U ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4005", ENV{libsane_matched}="yes" # Trust Easy Webscan 19200 ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4006", ENV{libsane_matched}="yes" # Trust 240H Easy Webscan Gold ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4007", ENV{libsane_matched}="yes" # UMAX AstraSlim SE ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4009", ENV{libsane_matched}="yes" # UMAX AstraSlim 1200 SE ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4010", ENV{libsane_matched}="yes" # Yakumo Scan50 ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4011", ENV{libsane_matched}="yes" # Microtek ScanMaker X6USB ATTRS{idVendor}=="05da", ATTRS{idProduct}=="0099", ENV{libsane_matched}="yes" # Microtek SlimScan C6 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="009a", ENV{libsane_matched}="yes" # Microtek ScanMaker V6USL ATTRS{idVendor}=="05da", ATTRS{idProduct}=="00a3", ENV{libsane_matched}="yes" # Microtek ScanMaker V6UPL ATTRS{idVendor}=="05da", ATTRS{idProduct}=="00b6", ENV{libsane_matched}="yes" # Microtek ScanMaker 4800 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="30cf", ENV{libsane_matched}="yes" # Microtek ScanMaker 3840 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="30d4", ENV{libsane_matched}="yes" # Microtek ScanMaker 3600 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40b3", ENV{libsane_matched}="yes" # Microtek ScanMaker 3700 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40b8", ENV{libsane_matched}="yes" # Microtek ScanMaker 3600 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40ca", ENV{libsane_matched}="yes" # Microtek ScanMaker 3700 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40cb", ENV{libsane_matched}="yes" # Microtek ScanMaker 3750 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40dd", ENV{libsane_matched}="yes" # Microtek ScanMaker 3600 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40ff", ENV{libsane_matched}="yes" # Microtek ScanMaker V6USL ATTRS{idVendor}=="05da", ATTRS{idProduct}=="80a3", ENV{libsane_matched}="yes" # iVina 1200U ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0268", ENV{libsane_matched}="yes" # Minolta Dimage Scan Dual II ATTRS{idVendor}=="0638", ATTRS{idProduct}=="026a", ENV{libsane_matched}="yes" # Avision AV600U ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a13", ENV{libsane_matched}="yes" # Minolta-QMS SC-110 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a15", ENV{libsane_matched}="yes" # Avision DS610CU Scancopier | Minolta-QMS SC-215 | OKI S700 Scancopier ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a16", ENV{libsane_matched}="yes" # Avision AV610 | Avision AV600U Plus ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a18", ENV{libsane_matched}="yes" # Avision AV220 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a23", ENV{libsane_matched}="yes" # Avision AV210 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a24", ENV{libsane_matched}="yes" # Avision AV210 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a25", ENV{libsane_matched}="yes" # Avision AV120 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a27", ENV{libsane_matched}="yes" # Avision AV220C2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2a", ENV{libsane_matched}="yes" # Avision AV220D2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2b", ENV{libsane_matched}="yes" # Avision AV220+ ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2c", ENV{libsane_matched}="yes" # Avision AV220C2-G ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2d", ENV{libsane_matched}="yes" # Avision AV220C2-B ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2e", ENV{libsane_matched}="yes" # Avision AV210C2-G ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2f", ENV{libsane_matched}="yes" # Avision AV122 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a33", ENV{libsane_matched}="yes" # Avision AV210C2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a3a", ENV{libsane_matched}="yes" # Avision AV121 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a3c", ENV{libsane_matched}="yes" # Avision AV8300 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a40", ENV{libsane_matched}="yes" # Avision AM3000 Series ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a41", ENV{libsane_matched}="yes" # Avision @V5100 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a45", ENV{libsane_matched}="yes" # Avision AV8050U ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4d", ENV{libsane_matched}="yes" # Avision AV3200SU ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4e", ENV{libsane_matched}="yes" # Avision AV3730SU ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4f", ENV{libsane_matched}="yes" # Avision AV610C2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a5e", ENV{libsane_matched}="yes" # Avision IT8300 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a61", ENV{libsane_matched}="yes" # Avision AV3750SU ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a65", ENV{libsane_matched}="yes" # Avision AV3850SU ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a66", ENV{libsane_matched}="yes" # Avision AV8350 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a68", ENV{libsane_matched}="yes" # Avision FB6080E ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a82", ENV{libsane_matched}="yes" # Avision FB2080E ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a84", ENV{libsane_matched}="yes" # Avision AV122 C2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a93", ENV{libsane_matched}="yes" # Avision AV220-G ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a94", ENV{libsane_matched}="yes" # Avision @V2500 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0aa1", ENV{libsane_matched}="yes" # Avision AV210D2+ ATTRS{idVendor}=="0638", ATTRS{idProduct}=="1a35", ENV{libsane_matched}="yes" # Minolta Elite II ATTRS{idVendor}=="0686", ATTRS{idProduct}=="4004", ENV{libsane_matched}="yes" # Minolta Dimage Scan Dual III ATTRS{idVendor}=="0686", ATTRS{idProduct}=="400d", ENV{libsane_matched}="yes" # Minolta Dimage Scan Elite 5400 ATTRS{idVendor}=="0686", ATTRS{idProduct}=="400e", ENV{libsane_matched}="yes" # AGFA SnapScan 1212U ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" # AGFA SnapScan 1236u ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" # Agfa Snapscan Touch ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0100", ENV{libsane_matched}="yes" # AGFA SnapScan 1212U_2 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2061", ENV{libsane_matched}="yes" # AGFA SnapScan e40 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="208d", ENV{libsane_matched}="yes" # AGFA SnapScan e50 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="208f", ENV{libsane_matched}="yes" # AGFA SnapScan e20 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2091", ENV{libsane_matched}="yes" # AGFA SnapScan e10 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2093", ENV{libsane_matched}="yes" # AGFA SnapScan e25 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2095", ENV{libsane_matched}="yes" # AGFA SnapScan e26 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2097", ENV{libsane_matched}="yes" # AGFA SnapScan e52 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="20fd", ENV{libsane_matched}="yes" # AGFA SnapScan e42 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="20ff", ENV{libsane_matched}="yes" # UMAX Astra 4900 ATTRS{idVendor}=="06dc", ATTRS{idProduct}=="0020", ENV{libsane_matched}="yes" # Plustek OpticPro U12 | Plustek OpticPro UT12 | Plustek OpticPro 1212U # RevScan RevScan Orange R48Ti | Genius ColorPage Vivid III USB ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" # Plustek OpticPro U12 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" # Plustek OpticPro U24 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0011", ENV{libsane_matched}="yes" # Plustek OpticPro UT12 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0013", ENV{libsane_matched}="yes" # Plustek OpticPro U24 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0015", ENV{libsane_matched}="yes" # Plustek OpticPro UT12 | Plustek OpticPro UT16 | Plustek OpticPro UT24 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0017", ENV{libsane_matched}="yes" # Plustek OpticPro 1248U | RevScan 19200i ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0400", ENV{libsane_matched}="yes" # Plustek OpticPro 1248U ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0401", ENV{libsane_matched}="yes" # Plustek OpticPro U16B ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0402", ENV{libsane_matched}="yes" # Plustek OpticPro U16B+ | Plustek OpticPro UT16B ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0403", ENV{libsane_matched}="yes" # Nortek MyScan 1200 | Plustek OpticPro S12 | Plustek OpticPro ST12 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="040b", ENV{libsane_matched}="yes" # Plustek OpticPro S24 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="040e", ENV{libsane_matched}="yes" # NeatReceipts Scanalizer Professional 2.5 | Plustek OpticSlim M12 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0412", ENV{libsane_matched}="yes" # Plustek OpticSlim 1200 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0413", ENV{libsane_matched}="yes" # Plustek OpticSlim 2400 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0422", ENV{libsane_matched}="yes" # Plustek OpticSlim 2400 plus ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0454", ENV{libsane_matched}="yes" # Plustek Iriscan Express 2 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="045f", ENV{libsane_matched}="yes" # NeatReceipts Mobile Scanner ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0462", ENV{libsane_matched}="yes" # Plustek OpticBook 3600 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0900", ENV{libsane_matched}="yes" # Corex 600c ATTRS{idVendor}=="08f0", ATTRS{idProduct}=="0002", ENV{libsane_matched}="yes" # Corex 800c ATTRS{idVendor}=="08f0", ATTRS{idProduct}=="0005", ENV{libsane_matched}="yes" # Xerox Phaser 6110MFP ATTRS{idVendor}=="0924", ATTRS{idProduct}=="3d5d", ENV{libsane_matched}="yes" # Xerox Phaser 3200MFP ATTRS{idVendor}=="0924", ATTRS{idProduct}=="3da4", ENV{libsane_matched}="yes" # Xerox WorkCentre 4118 Series ATTRS{idVendor}=="0924", ATTRS{idProduct}=="420c", ENV{libsane_matched}="yes" # Xerox WorkCentre 3119 Series ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4265", ENV{libsane_matched}="yes" # Xerox WorkCentre 3210 ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4293", ENV{libsane_matched}="yes" # Xerox WorkCentre 3220 ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4294", ENV{libsane_matched}="yes" # Pentax DSmobile 600 ATTRS{idVendor}=="0a17", ATTRS{idProduct}=="3210", ENV{libsane_matched}="yes" # Portable Peripheral Co., Ltd. Q-Scan USB001 (A4 portable scanner) ATTRS{idVendor}=="0a53", ATTRS{idProduct}=="1000", ENV{libsane_matched}="yes" # Portable Peripheral Co., Ltd. Q-Scan USB201 (A6 portable scanner) ATTRS{idVendor}=="0a53", ATTRS{idProduct}=="2000", ENV{libsane_matched}="yes" # Syscan TravelScan 460/464 | Ambir Visigo A4 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4600", ENV{libsane_matched}="yes" # Syscan DocketPort 465 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4802", ENV{libsane_matched}="yes" # Syscan DocketPort 665 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4803", ENV{libsane_matched}="yes" # Syscan DocketPort 685/ Ambir DS685 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="480c", ENV{libsane_matched}="yes" # Syscan DocketPort 485 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4810", ENV{libsane_matched}="yes" # Syscan TravelScan 662 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="6620", ENV{libsane_matched}="yes" # Canon CR-55 ATTRS{idVendor}=="1083", ATTRS{idProduct}=="160c", ENV{libsane_matched}="yes" # Canon DR-1210C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="160f", ENV{libsane_matched}="yes" # Canon DR-4010C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1614", ENV{libsane_matched}="yes" # Canon DR-2510C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1617", ENV{libsane_matched}="yes" # Canon DR-X10C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1618", ENV{libsane_matched}="yes" # Canon CR-25 ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161a", ENV{libsane_matched}="yes" # Canon DR-2010C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161b", ENV{libsane_matched}="yes" # Canon DR-3010C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161d", ENV{libsane_matched}="yes" # Canon DR-7090C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1620", ENV{libsane_matched}="yes" # Canon DR-9050C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1622", ENV{libsane_matched}="yes" # Canon DR-7550C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1623", ENV{libsane_matched}="yes" # Canon DR-6050C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1624", ENV{libsane_matched}="yes" # Canon DR-6010C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1626", ENV{libsane_matched}="yes" # Canon CR-190i ATTRS{idVendor}=="1083", ATTRS{idProduct}=="162b", ENV{libsane_matched}="yes" # Canon DR-6030C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1638", ENV{libsane_matched}="yes" # Canon CR-135i ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1639", ENV{libsane_matched}="yes" # Digital Dream l' espion XS ATTRS{idVendor}=="1183", ATTRS{idProduct}=="0001", ENV{libsane_matched}="yes" # KONICA MINOLTA magicolor 1690MF ATTRS{idVendor}=="132b", ATTRS{idProduct}=="2089", ENV{libsane_matched}="yes" # UMAX Astra 1220U ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0010", ENV{libsane_matched}="yes" # UMAX Astra 1600U | UMAX Astra 2000U ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0030", ENV{libsane_matched}="yes" # Umax UMAX 3400 ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0050", ENV{libsane_matched}="yes" # Umax UMAX 3400 | Umax UMAX Astranet ia101 | Umax UMAX 3450 ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0060", ENV{libsane_matched}="yes" # UMAX Astra 4400 | UMAX Astra 4450 ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0070", ENV{libsane_matched}="yes" # UMAX Astra 2100U ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0130", ENV{libsane_matched}="yes" # Umax UMAX 5400 ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0160", ENV{libsane_matched}="yes" # UMAX Astra 2200 (SU) ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0230", ENV{libsane_matched}="yes" # DCT DocketPort 487 ATTRS{idVendor}=="1dcc", ATTRS{idProduct}=="4810", ENV{libsane_matched}="yes" # Dell A920 ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5105", ENV{libsane_matched}="yes" # Dell Dell MFP Laser Printer 1815dn ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5124", ENV{libsane_matched}="yes" # Dell 1600n ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5250", ENV{libsane_matched}="yes" # The following rule will disable USB autosuspend for the device ENV{libsane_matched}=="yes", RUN+="/bin/sh -c 'if test -e /sys/$env{DEVPATH}/power/control; then echo on > /sys/$env{DEVPATH}/power/control; elif test -e /sys/$env{DEVPATH}/power/level; then echo on > /sys/$env{DEVPATH}/power/level; fi'" LABEL="libsane_usb_rules_end" SUBSYSTEMS=="scsi", GOTO="libsane_scsi_rules_begin" GOTO="libsane_scsi_rules_end" LABEL="libsane_scsi_rules_begin" # Generic: SCSI device type 6 indicates a scanner KERNEL=="sg[0-9]*", ATTRS{type}=="6", ENV{libsane_matched}="yes" # Some scanners advertise themselves as SCSI device type 3 # Wildcard: for some Epson SCSI scanners KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="SCANNER*", ENV{libsane_matched}="yes" # Epson Perfection 2450 | Epson Perfection 2450 PHOTO KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="GT-9700", ENV{libsane_matched}="yes" # Epson Perfection 3200 | Epson Perfection 3200 PHOTO KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="GT-9800", ENV{libsane_matched}="yes" # Epson Perfection 636S | Epson Perfection 1200S KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="Perfection1200", ENV{libsane_matched}="yes" # Epson Perfection 636 KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="Perfection636", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4p KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1130A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIc KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1750A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIp KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1790A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIcx KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C2500A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4c KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C2520A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5p KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C5110A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6200C KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C6270A", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6300C KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C7670A", ENV{libsane_matched}="yes" LABEL="libsane_scsi_rules_end" ENV{libsane_matched}=="yes", RUN+="/bin/setfacl -m g:scanner:rw $env{DEVNAME}" LABEL="libsane_rules_end" sane-backends-1.0.29/testsuite/tools/data/udev.ref0000666000000000000000000030173213615534521016752 00000000000000# This file was automatically created based on description files (*.desc) # by sane-desc 3.5 from sane-backends 1.0.24git on Wed Jul 31 07:52:48 2013 # # udev rules file for supported USB and SCSI devices # # The SCSI device support is very basic and includes only # scanners that mark themselves as type "scanner" or # SCSI-scanners from HP and other vendors that are entitled "processor" # but are treated accordingly. # # To add a USB device, add a rule to the list below between the # LABEL="libsane_usb_rules_begin" and LABEL="libsane_usb_rules_end" lines. # # To run a script when your device is plugged in, add RUN+="/path/to/script" # to the appropriate rule. # # If your scanner isn't listed below, you can add it as explained above. # # If your scanner is supported by some external backend (brother, epkowa, # hpaio, etc) please ask the author of the backend to provide proper # device detection support for your OS # # If the scanner is supported by sane-backends, please mail the entry to # the sane-devel mailing list (sane-devel@alioth-lists.debian.net). # ACTION!="add", GOTO="libsane_rules_end" ENV{DEVTYPE}=="usb_device", GOTO="libsane_create_usb_dev" SUBSYSTEMS=="scsi", GOTO="libsane_scsi_rules_begin" SUBSYSTEM=="usb_device", GOTO="libsane_usb_rules_begin" SUBSYSTEM!="usb_device", GOTO="libsane_usb_rules_end" # Kernel >= 2.6.22 jumps here LABEL="libsane_create_usb_dev" # For Linux >= 2.6.22 without CONFIG_USB_DEVICE_CLASS=y # If the following rule does not exist on your system yet, uncomment it # ENV{DEVTYPE}=="usb_device", MODE="0664", OWNER="root", GROUP="root" # Kernel < 2.6.22 jumps here LABEL="libsane_usb_rules_begin" # Hewlett-Packard ScanJet 4100C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0101", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4200C | Hewlett-Packard ScanJet 4200Cxi | Hewlett-Packard ScanJet 4200Cse ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0105", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6200C | Hewlett-Packard ScanJet 6250C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0201", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3300c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0205", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4300c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0305", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5200C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0401", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3400c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0405", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 2100C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0505", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6300C | Hewlett-Packard ScanJet 6350C | Hewlett-Packard ScanJet 6390C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0601", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 2200C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0605", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5300C | Hewlett-Packard ScanJet 5370C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0701", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard scanjet 4400c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0705", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 7400c | Hewlett-Packard ScanJet 7450c | Hewlett-Packard ScanJet 7490c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0801", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard scanjet 4470c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0805", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 2300C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0901", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 2400C | Hewlett-Packard ScanJet G2410 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0a01", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 8200 | Hewlett-Packard ScanJet 8250 | Hewlett-Packard ScanJet 8290 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0b01", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5400c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1005", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5470c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1105", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4500C | Hewlett-Packard ScanJet 5550C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1205", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4570C | Hewlett-Packard ScanJet 5500C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1305", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3670 | Hewlett-Packard ScanJet 3690C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1405", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5590 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1705", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 7650 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1805", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4850C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="1b05", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3530C | Hewlett-Packard ScanJet 3570C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2005", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3500C ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2205", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3970c ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2305", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4070 Photosmart ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2405", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 3800 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2605", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G2710 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2805", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 8300 | Hewlett-Packard ScanJet 8350 | Hewlett-Packard ScanJet 8390 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="3805", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 8270 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="3905", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard LaserJet M1005 MFP ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="3b17", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4370 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4105", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G3010 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4205", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G3110 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4305", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G4010 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4505", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet G4050 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4605", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet N6310 ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="4705", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard LaserJet M1120 MFP ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="5617", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard LaserJet M1120n MFP ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="5717", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 ATTRS{idVendor}=="0400", ATTRS{idProduct}=="1000", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 | Mustek BearPaw 2400 ATTRS{idVendor}=="0400", ATTRS{idProduct}=="1001", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 5100 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4025", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 5300 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4026", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 5500 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4027", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 5000 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4028", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 3300 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4031", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 5 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4032", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 7 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="403e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 9 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="403f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 5200 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4041", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 3200 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4043", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 4100 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4053", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 6100 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4054", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 7200 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4056", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP C110 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4057", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP C115 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4058", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 2150 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4059", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP C310 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="405d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP C315 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="405e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Advent AW10 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4060", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak Hero Office 6.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4062", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak Hero 7.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4063", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak Hero 5.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4064", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 9200 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4065", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak ESP 2170 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4066", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak Hero 9.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="4067", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak Hero 3.1 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="406d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak i30 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6001", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak i40 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6002", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak i50 | Kodak i55 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6003", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak i60 | Kodak i65 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6004", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kodak i80 ATTRS{idVendor}=="040a", ATTRS{idProduct}=="6005", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Creative WebCam Go Mini ATTRS{idVendor}=="041e", ATTRS{idProduct}=="4007", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Lexmark X70 | Lexmark X73 ATTRS{idVendor}=="043d", ATTRS{idProduct}=="002d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Lexmark X74 ATTRS{idVendor}=="043d", ATTRS{idProduct}=="0060", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Lexmark X1110 | Lexmark X1130 | Lexmark X1140 # Lexmark X1150 | Lexmark X1170 | Lexmark X1180 # Lexmark X1185 | Lexmark X1195 ATTRS{idVendor}=="043d", ATTRS{idProduct}=="007c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Lexmark X12xx ATTRS{idVendor}=="043d", ATTRS{idProduct}=="007d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius ColorPage HR6 V1 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2004", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage HR6 V2 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2007", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage HR6 V2 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2008", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage HR6A ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2009", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage Vivid3x | Genius Colorpage Vivid3 V2 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2011", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage HR7 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2013", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage Vivid4 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2014", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage HR7LE ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2015", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage HR6X ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2016", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage Vivid3xe ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2017", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage Vivid4xe ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage Vivid4x ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage Vivid 1200 X ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius ColorPage Slim 1200 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage Vivid 1200 XE ATTRS{idVendor}=="0458", ATTRS{idProduct}=="201f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Genius Colorpage SF600 ATTRS{idVendor}=="0458", ATTRS{idProduct}=="2021", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Medion/Lifetec/Tevion/Cytron MD5345 | Medion/Lifetec/Tevion/Cytron MD6228 | Medion/Lifetec/Tevion/Cytron MD6471 ATTRS{idVendor}=="0461", ATTRS{idProduct}=="0377", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox 2400 Onetouch ATTRS{idVendor}=="0461", ATTRS{idProduct}=="038b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Trust Office Scan USB 19200 ATTRS{idVendor}=="047b", ATTRS{idProduct}=="1000", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4300c/Silitek ATTRS{idVendor}=="047b", ATTRS{idProduct}=="1002", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Kyocera FS-1016MFP ATTRS{idVendor}=="0482", ATTRS{idProduct}=="0335", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Compaq S4-100 ATTRS{idVendor}=="049f", ATTRS{idProduct}=="001a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 310U ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="1a20", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 620U ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="1a2a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 320U | Benq (Acer) 340U | Mitsubishi Diamondview 648UT ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2022", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 620UT ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2040", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 640U | Guillemot / Hercules Maxi Scan A4 USB 640U | Guillemot / Hercules Maxi A4 36 bit ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2060", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 640bu ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="207e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 3300 | Benq (Acer) 4300 | Mitsubishi Diamondview 650U ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20b0", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 640BT ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20be", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 1240 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20c0", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 3300 | Benq (Acer) 4300 | Guillemot / Hercules Scan@home Touch 1248 (USB) ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20de", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 5000 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20f8", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 5000E | Benq (Acer) 5000U ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20fc", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 5300 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="20fe", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Benq (Acer) 5150 | Benq (Acer) 5250 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2137", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # BenQ 5550 ATTRS{idVendor}=="04a5", ATTRS{idProduct}=="2211", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Visioneer OneTouch 7100 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0229", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer 9650 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0390", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer 9320 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0420", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer 9450 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0421", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer 9550 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0422", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer 9750 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0423", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Strobe XP 450 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0424", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Strobe XP 200 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0426", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Strobe XP 100 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0427", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer OneTouch 7300 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0444", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate510 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0446", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate520 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0447", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate250 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0448", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate252 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0449", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate262 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="044c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Strobe XP 300 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0474", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate272 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0475", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate232 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0476", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate152 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0477", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate752 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0478", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Strobe XP 470 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0479", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer 9450-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="047a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer 9650-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="047b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate510-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="047c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate252-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="048c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate262-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="048d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate272-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="048e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Strobe XP 470-G | Visioneer Patriot 470 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="048f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate250-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0490", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Strobe XP 450-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0491", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate520-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0492", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer 9750-G ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0493", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Roadwarrior ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0494", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate512 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0495", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Patriot 430 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0497", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Patriot 680 | Xerox DocuMate632 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0498", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Patriot 780 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="0499", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate752 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="049a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Visioneer Strobe XP 100,r3 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="049b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate150 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="049c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate162 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="049d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox DocuMate262i ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="04a7", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox Travel Scanner 100 ATTRS{idVendor}=="04a7", ATTRS{idProduct}=="04ac", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-2080C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1601", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CR-180 | Canon CR-180II ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1602", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-9080C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1603", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-7080C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1604", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-5010C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1606", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-6080 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1607", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-2580C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1608", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-3080CII ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1609", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-2050C | Canon DR-2050SP ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="160a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-7580 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="160b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP750 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1706", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP780 | Canon PIXMA MP790 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1707", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP760 | Canon PIXMA MP770 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1708", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP150 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1709", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP170 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP450 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP500 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP800 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP800R ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="170e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP530 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1712", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP830 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1713", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP160 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1714", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP180 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1715", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP460 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1716", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP510 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1717", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP600 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1718", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP600R ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1719", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP810 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP960 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX7600 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="171c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP210 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1721", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP220 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1722", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP470 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1723", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP520 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1724", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP610 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1725", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP970 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1726", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX300 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1727", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX310 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1728", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX700 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1729", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP140 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX850 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP980 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP630 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP620 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="172f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP540 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1730", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP480 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1731", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP240 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1732", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP260 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1733", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP190 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1734", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX860 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1735", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX320 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1736", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX330 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1737", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP250 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP270 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP490 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP550 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP560 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP640 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="173f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP990 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1740", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX340 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1741", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX350 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1742", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX870 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1743", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP280 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1746", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP495 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1747", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG5100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1748", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG5200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1749", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG6100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG8100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX360 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX410 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX420 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="174f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX880 Series | Canon PIXMA MX882 | Canon PIXMA MX885 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1750", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG2100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1751", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG3100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1752", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG4100 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1753", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG5300 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1754", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG6200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1755", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG8200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1756", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP493 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1757", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA E500 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1758", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX370 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1759", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA E600 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX430 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX510 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX710 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX890 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP230 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="175f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG2200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1760", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA E510 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1761", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG3200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1762", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG4200 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1763", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG5400 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1764", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MG6300 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1765", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX390 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1766", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA E610 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1767", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX450 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1768", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX520 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1769", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX720 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="176a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MX920 Series ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="176b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan 8800F ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1901", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 100 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1904", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 200 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1905", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan 700F ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1907", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan 9000F ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1908", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 110 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="1909", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 210 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="190a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan 9000F Mark II ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="190d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan fb630u | Canon CanoScan fb636u ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2204", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan N650U/N656U ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2206", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan N1220U ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2207", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan D660U ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2208", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan N670U/N676U/LiDE20 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan N1240U/LiDE30 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="220e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 35 | Canon CanoScan LiDE 40 | Canon CanoScan LiDE 50 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2213", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan LiDE 60 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="221c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CanoScan LiDE25 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2220", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-1210C ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2222", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP730 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="262f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP700 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2630", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP360 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP370 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP390 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP375R ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="263f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP740 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon PIXMA MP710 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF5630 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon laserBase MF5650 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="264f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF8170c ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2659", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF5730 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF5750 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF5770 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="265f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF3110 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2660", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF3240 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2684", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF6500 series | Canon imageCLASS MF6550 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2686", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF4120 | Canon imageCLASS MF4122 | Canon imageCLASS MF4140 # Canon imageCLASS MF4150 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26a3", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF4660 | Canon imageCLASS MF4690 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b0", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF4010 | Canon imageCLASS MF4018 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b4", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF4270 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26b5", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageRUNNER 1020/1024/1025 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26e6", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF4370dn | Canon imageCLASS MF4380dn ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ec", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS D480 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ed", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon I-SENSYS MF4320d | Canon I-SENSYS MF4330d | Canon imageCLASS MF4350d ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ee", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS D420 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26ef", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon i-SENSYS MF5880dn ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26f9", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon i-SENSYS MF6680dn ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26fa", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF8030 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2707", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon i-SENSYS MF4550d ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2736", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon imageCLASS MF4410 | Canon imageCLASS MF4430 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2737", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon i-SENSYS MF3010 ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="2759", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Nikon LS 40 ED | Nikon LS 40 ED | Nikon Coolspan IV ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4000", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Nikon LS 50 ED | Nikon Coolscan V ED | Nikon LS 50 ED # Nikon Coolscan V ED ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4001", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Nikon Super Coolscan LS-5000 ED | Nikon Super Coolscan LS-5000 ED ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="4002", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 636U | Epson GT-7000U | Epson Perfection 636U ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0101", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 610 | Epson GT-6600U | Epson Perfection 610 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0103", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1200U | Epson Perfection 1200Photo | Epson GT-7600U # Epson GT-7600UF | Epson Perfection 1200U | Epson Perfection 1200U PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0104", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Stylus Scan 2000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0105", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Stylus Scan 2500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0106", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Expression 1600 | Epson ES-2000 | Epson Expression 1600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0107", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ES-8500 | Epson Expression 1640XL ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0109", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1640 | Epson GT-8700 | Epson GT-8700F # Epson Perfection 1640SU | Epson Perfection 1640SU PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1240 | Epson GT-7700U | Epson Perfection 1240U ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 640 | Epson GT-6700U | Epson Perfection 640U ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Expression 1680 | Epson ES-2200 | Epson Expression 1680 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1250 | Epson Perfection 1250Photo ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="010f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1650 | Epson GT-8200U | Epson GT-8200UF # Epson Perfection 1650 | Epson Perfection 1650 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0110", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 2450 | Epson GT-9700F | Epson Perfection 2450 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0112", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 660 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0114", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 2400 | Epson GT-9300UF | Epson Perfection 2400 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 3200 | Epson GT-9800F | Epson Perfection 3200 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1260 | Epson Perfection 1260Photo ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1660 | Epson GT-8300UF | Epson Perfection 1660 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1670 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="011f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 1270 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0120", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 2480 | Epson Perfection 2580 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0121", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 3490 | Epson Perfection 3590 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0122", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ES-7000H | Epson GT-15000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0126", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 4870 | Epson GT-X700 | Epson Perfection 4870 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0128", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ES-10000G | Epson Expression 10000XL ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0129", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 4990 | Epson GT-X800 | Epson Perfection 4990 PHOTO ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ES-H300 | Epson GT-2500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson V700 | Epson V750 | Epson GT-X900 # Epson Perfection V700 Photo | Epson Perfection V750 Photo ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="012c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson GT-X970 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0135", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-5200 | Epson CX-5400 | Epson CC-600PX # Epson Stylus CX5100 | Epson Stylus CX5200 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0801", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-3200 | Epson CC-570L | Epson Stylus CX3100 # Epson Stylus CX3200 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0802", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-6300 | Epson CX-6400 | Epson Stylus CX6300 # Epson Stylus CX6400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0805", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson RX-600 | Epson PM-A850 | Epson Stylus Photo RX600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0806", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson RX-500 | Epson Stylus Photo RX500 | Epson Stylus Photo RX510 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0807", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-5400 | Epson Stylus CX5300 | Epson Stylus CX5400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0808", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Stylus CX-1500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-4600 | Epson Stylus CX4500 | Epson Stylus CX4600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-3600 | Epson CX-3650 | Epson PX-A550 # Epson Stylus CX3500 | Epson Stylus CX3600 | Epson Stylus CX3650 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson RX-425 | Epson Stylus Photo RX420 | Epson Stylus Photo RX425 # Epson Stylus Photo RX430 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="080f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson RX-700 | Epson PM-A900 | Epson Stylus Photo RX700 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0810", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson RX-620 | Epson PM-A870 | Epson Stylus Photo RX620 # Epson Stylus Photo RX630 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0811", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-6500 | Epson CX-6600 | Epson Stylus CX6500 # Epson Stylus CX6600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0813", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A700 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0814", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson AcuLaser CX11 # Epson AcuLaser CX11NF | Epson LP-A500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0815", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson LP-M5500 | Epson LP-M5500F ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0817", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson DX-3850 | Epson CX-3700 | Epson CX-3800 # Epson DX-3800 | Epson Stylus CX3700 | Epson Stylus CX3800 # Epson Stylus DX3800 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0818", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-4800 | Epson PX-A650 | Epson Stylus CX4700 # Epson Stylus CX4800 | Epson Stylus DX4800 | Epson Stylus DX4850 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0819", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A750 | Epson Stylus Photo RX520 | Epson Stylus Photo RX530 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A890 | Epson Stylus Photo RX640 | Epson Stylus Photo RX650 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A950 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Stylus CX7700 | Epson Stylus CX7800 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="081f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-4200 | Epson Stylus CX4100 | Epson Stylus CX4200 # Epson Stylus DX4200 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0820", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A820 | Epson Stylus Photo RX560 | Epson Stylus Photo RX580 # Epson Stylus Photo RX590 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0827", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A970 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0828", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-T990 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0829", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A920 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson CX-5000 | Epson DX-5000 | Epson DX-5050 # Epson Stylus CX4900 | Epson Stylus CX5000 | Epson Stylus DX5000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson DX-6000 | Epson PX-A720 | Epson Stylus CX5900 # Epson Stylus CX6000 | Epson Stylus DX6000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson DX-4050 | Epson PX-A620 | Epson Stylus CX3900 # Epson Stylus DX4000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="082f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ME 200 | Epson Stylus CX2800 | Epson Stylus CX2900 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0830", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson LP-M5600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0833", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson LP-M6000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0834", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson AcuLaser CX21 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0835", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-T960 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0836", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A940 | Epson Stylus Photo RX680 | Epson Stylus Photo RX685 # Epson Stylus Photo RX690 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0837", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson DX-7400 | Epson PX-A640 | Epson Stylus CX7300 # Epson Stylus CX7400 | Epson Stylus DX7400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0838", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PX-A740 | Epson Stylus CX8300 | Epson Stylus CX8400 # Epson Stylus DX8400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0839", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PX-FA700 | Epson Stylus CX9300F | Epson Stylus CX9400Fax # Epson Stylus DX9400F ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PM-A840 | Epson PM-A840S | Epson Stylus Photo RX585 # Epson Stylus Photo RX595 | Epson Stylus Photo RX610 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="083c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ME 300 | Epson PX-401A | Epson Stylus NX100 # Epson Stylus SX100 | Epson Stylus TX100 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0841", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson LP-M5000 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0843", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Artisan 800 | Epson EP-901A | Epson EP-901F # Epson Stylus Photo PX800FW | Epson Stylus Photo TX800FW ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0844", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Artisan 700 | Epson EP-801A | Epson Stylus Photo PX700W # Epson Stylus Photo TX700W ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0846", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ME Office 700FW | Epson PX-601F | Epson Stylus Office BX600FW # Epson Stylus Office TX600FW | Epson Stylus SX600FW | Epson WorkForce 600 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0847", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ME Office 600F | Epson Stylus Office BX300F | Epson Stylus Office TX300F # Epson Stylus NX300 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0848", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Stylus NX200 | Epson Stylus SX200 | Epson Stylus SX205 # Epson Stylus TX200 | Epson Stylus TX203 | Epson Stylus TX209 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0849", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PX-501A | Epson Stylus NX400 | Epson Stylus SX400 # Epson Stylus SX405 | Epson Stylus TX400 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson WorkForce 500 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PX-402A | Epson Stylus NX110 Series | Epson Stylus SX110 Series # Epson Stylus TX110 Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ME OFFICE 510 | Epson Stylus NX210 Series | Epson Stylus SX210 Series # Epson Stylus TX210 Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="084f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Stylus NX410 Series | Epson Stylus SX410 Series | Epson Stylus TX410 Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0851", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson ME OFFICE 650FN Series | Epson Stylus Office BX310FN Series | Epson Stylus Office TX510FN Series # Epson WorkForce 310 Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0854", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson PX-502A | Epson Stylus NX510 Series | Epson Stylus SX510W Series # Epson Stylus TX550W Series ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0856", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Stylus SX125 ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="085c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-4010CU ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1029", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-4120C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1041", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-4220C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1042", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-4530C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1078", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5750C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1095", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5110EOX/2 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1096", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5110C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1097", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5650C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ad", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-4120C2 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ae", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-4220C2 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10af", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-60F ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10c7", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-4340C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10cf", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5120C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e0", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5220C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e1", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5530C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e2", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5110EOX3 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e6", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5900C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10e7", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5015C ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10ef", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5110EOXM ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10f2", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S500 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="10fe", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S500M ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1135", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5530C2 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6140 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6240 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6130 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="114f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6230 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1150", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S510 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1155", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S300 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1156", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S510M ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="116f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6770 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1174", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6770A ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1175", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6670 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1176", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6670A ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1177", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6750S ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1178", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S300M ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="117f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6800 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6800-CGA ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="119e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S1500 | Fujitsu ScanSnap S1500M ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11a2", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap S1300 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11ed", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6140Z ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f1", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6240Z ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f2", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6130Z ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f3", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6230Z ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11f4", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-6110 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="11fc", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu fi-5950 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="1213", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Fujitsu ScanSnap iX500 ATTRS{idVendor}=="04c5", ATTRS{idProduct}=="132b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Konica e-mini ATTRS{idVendor}=="04c8", ATTRS{idProduct}=="0722", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S2026C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1000", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S2046C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1001", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S1025C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1006", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S1020C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1007", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S2048C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1009", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S2028C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S4085C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S4065C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S7075C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-SS080 ATTRS{idVendor}=="04da", ATTRS{idProduct}=="100f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Panasonic KV-S1045C ATTRS{idVendor}=="04da", ATTRS{idProduct}=="1010", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4x16 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3409", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-6x20 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="340d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung MFP-560 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="340e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung MFP-750 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="340f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4x20 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3412", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4100 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3413", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4x21 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3419", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-5x30 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4200 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-3160 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-6x22 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX4725 | Samsung SCX4725-FN ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="341f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-6x45 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3420", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-8380 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3421", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-2160 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3425", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4500 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3426", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-6200 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3427", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-6240 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3428", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-6x55 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3429", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-3170fn (CLX-3170 Series) | Samsung CLX-3175FW ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4500W ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4824 (SCX-4x24 Series) ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4828FN (SCX-4x28 Series) ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4300 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-5835_5935 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-5635 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3430", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4x26 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3432", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4600 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3433", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4623 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3434", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung MFP-65x ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3435", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-6545 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3437", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-8385 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3439", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-6220 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-6250 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4825FN (SCX-4x25 Series) ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-3185 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-8540 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="343f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4623FW ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3440", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-3205W (SCX-3200 Series) ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3441", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-6545X ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3442", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-6x55X ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3443", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-8385X ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3444", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-5835_5935X ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3446", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4833FD | Samsung SCX-4835FD ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="344b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-3400 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="344f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SF-760 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3450", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4729FD ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3453", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-6260 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3455", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-3300 Series ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3456", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-470x ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3457", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung CLX-4190 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="345a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-4650 4x21S Series ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="345b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung M337x 387x 407x Series ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3460", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung M267x 287x Series ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3461", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung SCX-681x ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3466", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Samsung C460 ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="3468", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Pentax DSmobile 600 ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="2038", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Aiptek Aiptek Pencam ATTRS{idVendor}=="0553", ATTRS{idProduct}=="0202", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek ScanExpress 1200 CU ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0001", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek ScanExpress 600 CU ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0002", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek ScanExpress 1200 UB | Trust Compact Scan USB 19200 ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0006", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek ScanExpress 1200 CU Plus ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0008", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 F ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0010", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek ScanExpress A3 USB ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0210", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 2400 CS | Mustek BearPaw 2400 TA | Trust 240TH Easy Webscan Gold ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0218", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 2400 CS Plus | Mustek BearPaw 2400 TA Plus | Mustek Plug-n-Scan 2400 MT # Mustek Plug-n-Scan 2400 M | Packard Bell Diamond 2450 ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0219", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 2448 CS Plus | Mustek BearPaw 2448 TA Plus ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 CU Plus | Packard Bell Diamond 1200 Plus ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 CU Plus | Mustek BearPaw 1248 CU | Packard Bell Diamond 1200 Plus # Trust Direct WebScan 19200 ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 2400 CU Plus ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 1200 CS | Mustek BearPaw 1200 TA ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek ScanExpress 1248 UB ATTRS{idVendor}=="055f", ATTRS{idProduct}=="021f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Mustek BearPaw 2448TA Pro ATTRS{idVendor}=="055f", ATTRS{idProduct}=="0409", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Artec/Ultima Ultima 2000 | Artec/Ultima Ultima 2000 e+ | Boeder Sm@rtScan Slim Edition # Fujitsu 1200CUS | Googlegear 2000 | Medion/Lifetec/Tevion/Cytron MD 4394 # Medion/Lifetec/Tevion/Cytron MD/LT 9375 | Medion/Lifetec/Tevion/Cytron MD/LT 9385 | Medion/Lifetec/Tevion/Cytron LT 9452 # Medion/Lifetec/Tevion/Cytron MD 9458 | Mustek BearPaw 1200 CU | Mustek BearPaw 2400 CU # Mustek ScanExpress 1200 UB Plus | Mustek ScanExpress 2400 USB | Mustek ScanMagic 1200 UB Plus # Packard Bell Diamond 1200 | Trust Compact Scan USB 19200 | Trust Flat Scan USB 19200 ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4002", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Artec/Ultima E+ 48U | Medion/Lifetec/Tevion/Cytron MD9693 | Medion/Lifetec/Tevion/Cytron MD9705 # Medion/Lifetec/Tevion/Cytron MD4394 | Microstar MR 9791 ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4003", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Artec/Ultima E+ Pro ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4004", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Memorex MEM 48U ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4005", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Trust Easy Webscan 19200 ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4006", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Trust 240H Easy Webscan Gold ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4007", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # UMAX AstraSlim SE ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4009", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # UMAX AstraSlim 1200 SE ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4010", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Yakumo Scan50 ATTRS{idVendor}=="05d8", ATTRS{idProduct}=="4011", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker X6USB ATTRS{idVendor}=="05da", ATTRS{idProduct}=="0099", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek SlimScan C6 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="009a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker V6USL ATTRS{idVendor}=="05da", ATTRS{idProduct}=="00a3", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker V6UPL ATTRS{idVendor}=="05da", ATTRS{idProduct}=="00b6", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker 4800 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="30cf", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker 3840 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="30d4", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker 3600 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40b3", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker 3700 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40b8", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker 3600 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40ca", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker 3700 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40cb", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker 3750 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40dd", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker 3600 ATTRS{idVendor}=="05da", ATTRS{idProduct}=="40ff", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Microtek ScanMaker V6USL ATTRS{idVendor}=="05da", ATTRS{idProduct}=="80a3", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # iVina 1200U ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0268", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Minolta Dimage Scan Dual II ATTRS{idVendor}=="0638", ATTRS{idProduct}=="026a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV600U ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a13", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Minolta-QMS SC-110 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a15", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision DS610CU Scancopier | Minolta-QMS SC-215 | OKI S700 Scancopier ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a16", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV610 | Avision AV600U Plus ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a18", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV220 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a23", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV210 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a24", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV210 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a25", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV120 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a27", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV220C2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV220D2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV220+ ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV220C2-G ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV220C2-B ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV210C2-G ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a2f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV122 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a33", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV210C2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a3a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV121 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a3c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV8300 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a40", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AM3000 Series ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a41", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision @V5100 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a45", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV8050U ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV3200SU ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV3730SU ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a4f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV610C2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a5e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision IT8300 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a61", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV3750SU ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a65", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV3850SU ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a66", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV8350 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a68", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision FB6080E ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a82", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision FB2080E ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a84", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV122 C2 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a93", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV220-G ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0a94", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision @V2500 ATTRS{idVendor}=="0638", ATTRS{idProduct}=="0aa1", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Avision AV210D2+ ATTRS{idVendor}=="0638", ATTRS{idProduct}=="1a35", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Minolta Elite II ATTRS{idVendor}=="0686", ATTRS{idProduct}=="4004", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Minolta Dimage Scan Dual III ATTRS{idVendor}=="0686", ATTRS{idProduct}=="400d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Minolta Dimage Scan Elite 5400 ATTRS{idVendor}=="0686", ATTRS{idProduct}=="400e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan 1212U ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0001", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan 1236u ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0002", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Agfa Snapscan Touch ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="0100", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan 1212U_2 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2061", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan e40 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="208d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan e50 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="208f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan e20 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2091", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan e10 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2093", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan e25 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2095", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan e26 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="2097", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan e52 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="20fd", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # AGFA SnapScan e42 ATTRS{idVendor}=="06bd", ATTRS{idProduct}=="20ff", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # UMAX Astra 4900 ATTRS{idVendor}=="06dc", ATTRS{idProduct}=="0020", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro U12 | Plustek OpticPro UT12 | Plustek OpticPro 1212U # RevScan RevScan Orange R48Ti | Genius ColorPage Vivid III USB ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0001", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro U12 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0010", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro U24 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0011", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro UT12 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0013", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro U24 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0015", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro UT12 | Plustek OpticPro UT16 | Plustek OpticPro UT24 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0017", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro 1248U | RevScan 19200i ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0400", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro 1248U ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0401", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro U16B ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0402", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro U16B+ | Plustek OpticPro UT16B ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0403", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Nortek MyScan 1200 | Plustek OpticPro S12 | Plustek OpticPro ST12 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="040b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticPro S24 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="040e", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # NeatReceipts Scanalizer Professional 2.5 | Plustek OpticSlim M12 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0412", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticSlim 1200 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0413", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticSlim 2400 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0422", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticSlim 2400 plus ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0454", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek Iriscan Express 2 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="045f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # NeatReceipts Mobile Scanner ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0462", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Plustek OpticBook 3600 ATTRS{idVendor}=="07b3", ATTRS{idProduct}=="0900", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Corex 600c ATTRS{idVendor}=="08f0", ATTRS{idProduct}=="0002", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Corex 800c ATTRS{idVendor}=="08f0", ATTRS{idProduct}=="0005", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox Phaser 6110MFP ATTRS{idVendor}=="0924", ATTRS{idProduct}=="3d5d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox Phaser 3200MFP ATTRS{idVendor}=="0924", ATTRS{idProduct}=="3da4", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox WorkCentre 4118 Series ATTRS{idVendor}=="0924", ATTRS{idProduct}=="420c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox WorkCentre 3119 Series ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4265", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox WorkCentre 3210 ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4293", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Xerox WorkCentre 3220 ATTRS{idVendor}=="0924", ATTRS{idProduct}=="4294", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Pentax DSmobile 600 ATTRS{idVendor}=="0a17", ATTRS{idProduct}=="3210", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Portable Peripheral Co., Ltd. Q-Scan USB001 (A4 portable scanner) ATTRS{idVendor}=="0a53", ATTRS{idProduct}=="1000", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Portable Peripheral Co., Ltd. Q-Scan USB201 (A6 portable scanner) ATTRS{idVendor}=="0a53", ATTRS{idProduct}=="2000", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Syscan TravelScan 460/464 | Ambir Visigo A4 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4600", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Syscan DocketPort 465 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4802", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Syscan DocketPort 665 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4803", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Syscan DocketPort 685/ Ambir DS685 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="480c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Syscan DocketPort 485 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="4810", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Syscan TravelScan 662 ATTRS{idVendor}=="0a82", ATTRS{idProduct}=="6620", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CR-55 ATTRS{idVendor}=="1083", ATTRS{idProduct}=="160c", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-1210C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="160f", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-4010C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1614", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-2510C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1617", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-X10C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1618", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CR-25 ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161a", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-2010C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-3010C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="161d", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-7090C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1620", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-9050C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1622", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-7550C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1623", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-6050C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1624", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-6010C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1626", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CR-190i ATTRS{idVendor}=="1083", ATTRS{idProduct}=="162b", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon DR-6030C ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1638", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Canon CR-135i ATTRS{idVendor}=="1083", ATTRS{idProduct}=="1639", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Digital Dream l' espion XS ATTRS{idVendor}=="1183", ATTRS{idProduct}=="0001", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # KONICA MINOLTA magicolor 1690MF ATTRS{idVendor}=="132b", ATTRS{idProduct}=="2089", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # UMAX Astra 1220U ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0010", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # UMAX Astra 1600U | UMAX Astra 2000U ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0030", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Umax UMAX 3400 ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0050", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Umax UMAX 3400 | Umax UMAX Astranet ia101 | Umax UMAX 3450 ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0060", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # UMAX Astra 4400 | UMAX Astra 4450 ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0070", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # UMAX Astra 2100U ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0130", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Umax UMAX 5400 ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0160", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # UMAX Astra 2200 (SU) ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0230", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # DCT DocketPort 487 ATTRS{idVendor}=="1dcc", ATTRS{idProduct}=="4810", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Dell A920 ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5105", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Dell Dell MFP Laser Printer 1815dn ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5124", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Dell 1600n ATTRS{idVendor}=="413c", ATTRS{idProduct}=="5250", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # The following rule will disable USB autosuspend for the device ENV{libsane_matched}=="yes", RUN+="/bin/sh -c 'if test -e /sys/$env{DEVPATH}/power/control; then echo on > /sys/$env{DEVPATH}/power/control; elif test -e /sys/$env{DEVPATH}/power/level; then echo on > /sys/$env{DEVPATH}/power/level; fi'" LABEL="libsane_usb_rules_end" SUBSYSTEMS=="scsi", GOTO="libsane_scsi_rules_begin" GOTO="libsane_scsi_rules_end" LABEL="libsane_scsi_rules_begin" # Generic: SCSI device type 6 indicates a scanner KERNEL=="sg[0-9]*", ATTRS{type}=="6", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Some scanners advertise themselves as SCSI device type 3 # Wildcard: for some Epson SCSI scanners KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="SCANNER*", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 2450 | Epson Perfection 2450 PHOTO KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="GT-9700", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 3200 | Epson Perfection 3200 PHOTO KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="GT-9800", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 636S | Epson Perfection 1200S KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="Perfection1200", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Epson Perfection 636 KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="EPSON", ATTRS{model}=="Perfection636", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4p KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1130A", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIc KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1750A", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIp KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C1790A", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet IIcx KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C2500A", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 4c KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C2520A", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 5p KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C5110A", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6200C KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C6270A", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" # Hewlett-Packard ScanJet 6300C KERNEL=="sg[0-9]*", ATTRS{type}=="3", ATTRS{vendor}=="HP", ATTRS{model}=="C7670A", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes" LABEL="libsane_scsi_rules_end" ENV{libsane_matched}=="yes", MODE="664", GROUP="scanner" LABEL="libsane_rules_end" sane-backends-1.0.29/testsuite/tools/data/usermap.ref0000666000000000000000000024330613615534521017465 00000000000000# This file was automatically created based on description files (*.desc) # by sane-desc 3.5 from sane-backends 1.0.24git on Wed Jul 31 07:52:48 2013 # # The entries below are used to detect a USB device and change owner # and permissions on the "device node" used by libusb. # # The 0x0003 match flag means the device is matched by its vendor and # product IDs. # # Sample entry (replace 0xVVVV and 0xPPPP with vendor ID and product ID # respectively): # # libusbscanner 0x0003 0xVVVV 0xPPPP 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # usb module match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info # # If your scanner isn't listed below, you can add it as explained above. # # If your scanner is supported by some external backend (brother, epkowa, # hpaio, etc) please ask the author of the backend to provide proper # device detection support for your OS # # If the scanner is supported by sane-backends, please mail the entry to # the sane-devel mailing list (sane-devel@alioth-lists.debian.net). # # Hewlett-Packard ScanJet 4100C libusbscanner 0x0003 0x03f0 0x0101 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 4200C | Hewlett-Packard ScanJet 4200Cxi | Hewlett-Packard ScanJet 4200Cse libusbscanner 0x0003 0x03f0 0x0105 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 6200C | Hewlett-Packard ScanJet 6250C libusbscanner 0x0003 0x03f0 0x0201 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 3300c libusbscanner 0x0003 0x03f0 0x0205 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 4300c libusbscanner 0x0003 0x03f0 0x0305 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 5200C libusbscanner 0x0003 0x03f0 0x0401 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 3400c libusbscanner 0x0003 0x03f0 0x0405 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 2100C libusbscanner 0x0003 0x03f0 0x0505 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 6300C | Hewlett-Packard ScanJet 6350C | Hewlett-Packard ScanJet 6390C libusbscanner 0x0003 0x03f0 0x0601 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 2200C libusbscanner 0x0003 0x03f0 0x0605 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 5300C | Hewlett-Packard ScanJet 5370C libusbscanner 0x0003 0x03f0 0x0701 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard scanjet 4400c libusbscanner 0x0003 0x03f0 0x0705 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 7400c | Hewlett-Packard ScanJet 7450c | Hewlett-Packard ScanJet 7490c libusbscanner 0x0003 0x03f0 0x0801 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard scanjet 4470c libusbscanner 0x0003 0x03f0 0x0805 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 2300C libusbscanner 0x0003 0x03f0 0x0901 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 2400C | Hewlett-Packard ScanJet G2410 libusbscanner 0x0003 0x03f0 0x0a01 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 8200 | Hewlett-Packard ScanJet 8250 | Hewlett-Packard ScanJet 8290 libusbscanner 0x0003 0x03f0 0x0b01 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 5400c libusbscanner 0x0003 0x03f0 0x1005 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 5470c libusbscanner 0x0003 0x03f0 0x1105 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 4500C | Hewlett-Packard ScanJet 5550C libusbscanner 0x0003 0x03f0 0x1205 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 4570C | Hewlett-Packard ScanJet 5500C libusbscanner 0x0003 0x03f0 0x1305 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 3670 | Hewlett-Packard ScanJet 3690C libusbscanner 0x0003 0x03f0 0x1405 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 5590 libusbscanner 0x0003 0x03f0 0x1705 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 7650 libusbscanner 0x0003 0x03f0 0x1805 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 4850C libusbscanner 0x0003 0x03f0 0x1b05 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 3530C | Hewlett-Packard ScanJet 3570C libusbscanner 0x0003 0x03f0 0x2005 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 3500C libusbscanner 0x0003 0x03f0 0x2205 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 3970c libusbscanner 0x0003 0x03f0 0x2305 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 4070 Photosmart libusbscanner 0x0003 0x03f0 0x2405 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 3800 libusbscanner 0x0003 0x03f0 0x2605 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet G2710 libusbscanner 0x0003 0x03f0 0x2805 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 8300 | Hewlett-Packard ScanJet 8350 | Hewlett-Packard ScanJet 8390 libusbscanner 0x0003 0x03f0 0x3805 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 8270 libusbscanner 0x0003 0x03f0 0x3905 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard LaserJet M1005 MFP libusbscanner 0x0003 0x03f0 0x3b17 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 4370 libusbscanner 0x0003 0x03f0 0x4105 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet G3010 libusbscanner 0x0003 0x03f0 0x4205 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet G3110 libusbscanner 0x0003 0x03f0 0x4305 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet G4010 libusbscanner 0x0003 0x03f0 0x4505 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet G4050 libusbscanner 0x0003 0x03f0 0x4605 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet N6310 libusbscanner 0x0003 0x03f0 0x4705 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard LaserJet M1120 MFP libusbscanner 0x0003 0x03f0 0x5617 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard LaserJet M1120n MFP libusbscanner 0x0003 0x03f0 0x5717 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 1200 libusbscanner 0x0003 0x0400 0x1000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 1200 | Mustek BearPaw 2400 libusbscanner 0x0003 0x0400 0x1001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 5100 libusbscanner 0x0003 0x040a 0x4025 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 5300 libusbscanner 0x0003 0x040a 0x4026 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 5500 libusbscanner 0x0003 0x040a 0x4027 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 5000 libusbscanner 0x0003 0x040a 0x4028 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 3300 libusbscanner 0x0003 0x040a 0x4031 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 5 libusbscanner 0x0003 0x040a 0x4032 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 7 libusbscanner 0x0003 0x040a 0x403e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 9 libusbscanner 0x0003 0x040a 0x403f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 5200 libusbscanner 0x0003 0x040a 0x4041 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 3200 libusbscanner 0x0003 0x040a 0x4043 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 4100 libusbscanner 0x0003 0x040a 0x4053 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 6100 libusbscanner 0x0003 0x040a 0x4054 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 7200 libusbscanner 0x0003 0x040a 0x4056 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP C110 libusbscanner 0x0003 0x040a 0x4057 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP C115 libusbscanner 0x0003 0x040a 0x4058 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 2150 libusbscanner 0x0003 0x040a 0x4059 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP C310 libusbscanner 0x0003 0x040a 0x405d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP C315 libusbscanner 0x0003 0x040a 0x405e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Advent AW10 libusbscanner 0x0003 0x040a 0x4060 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak Hero Office 6.1 libusbscanner 0x0003 0x040a 0x4062 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak Hero 7.1 libusbscanner 0x0003 0x040a 0x4063 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak Hero 5.1 libusbscanner 0x0003 0x040a 0x4064 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 9200 libusbscanner 0x0003 0x040a 0x4065 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak ESP 2170 libusbscanner 0x0003 0x040a 0x4066 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak Hero 9.1 libusbscanner 0x0003 0x040a 0x4067 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak Hero 3.1 libusbscanner 0x0003 0x040a 0x406d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak i30 libusbscanner 0x0003 0x040a 0x6001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak i40 libusbscanner 0x0003 0x040a 0x6002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak i50 | Kodak i55 libusbscanner 0x0003 0x040a 0x6003 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak i60 | Kodak i65 libusbscanner 0x0003 0x040a 0x6004 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kodak i80 libusbscanner 0x0003 0x040a 0x6005 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Creative WebCam Go Mini libusbscanner 0x0003 0x041e 0x4007 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Lexmark X70 | Lexmark X73 libusbscanner 0x0003 0x043d 0x002d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Lexmark X74 libusbscanner 0x0003 0x043d 0x0060 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Lexmark X1110 | Lexmark X1130 | Lexmark X1140 | Lexmark X1150 | Lexmark X1170 | Lexmark X1180 | Lexmark X1185 | Lexmark X1195 libusbscanner 0x0003 0x043d 0x007c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Lexmark X12xx libusbscanner 0x0003 0x043d 0x007d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius ColorPage HR6 V1 libusbscanner 0x0003 0x0458 0x2004 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage HR6 V2 libusbscanner 0x0003 0x0458 0x2007 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage HR6 V2 libusbscanner 0x0003 0x0458 0x2008 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage HR6A libusbscanner 0x0003 0x0458 0x2009 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage Vivid3x | Genius Colorpage Vivid3 V2 libusbscanner 0x0003 0x0458 0x2011 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage HR7 libusbscanner 0x0003 0x0458 0x2013 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage Vivid4 libusbscanner 0x0003 0x0458 0x2014 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage HR7LE libusbscanner 0x0003 0x0458 0x2015 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage HR6X libusbscanner 0x0003 0x0458 0x2016 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage Vivid3xe libusbscanner 0x0003 0x0458 0x2017 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage Vivid4xe libusbscanner 0x0003 0x0458 0x201a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage Vivid4x libusbscanner 0x0003 0x0458 0x201b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage Vivid 1200 X libusbscanner 0x0003 0x0458 0x201d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius ColorPage Slim 1200 libusbscanner 0x0003 0x0458 0x201e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage Vivid 1200 XE libusbscanner 0x0003 0x0458 0x201f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Genius Colorpage SF600 libusbscanner 0x0003 0x0458 0x2021 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Medion/Lifetec/Tevion/Cytron MD5345 | Medion/Lifetec/Tevion/Cytron MD6228 | Medion/Lifetec/Tevion/Cytron MD6471 libusbscanner 0x0003 0x0461 0x0377 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox 2400 Onetouch libusbscanner 0x0003 0x0461 0x038b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Trust Office Scan USB 19200 libusbscanner 0x0003 0x047b 0x1000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Hewlett-Packard ScanJet 4300c/Silitek libusbscanner 0x0003 0x047b 0x1002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Kyocera FS-1016MFP libusbscanner 0x0003 0x0482 0x0335 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Compaq S4-100 libusbscanner 0x0003 0x049f 0x001a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 310U libusbscanner 0x0003 0x04a5 0x1a20 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 620U libusbscanner 0x0003 0x04a5 0x1a2a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 320U | Benq (Acer) 340U | Mitsubishi Diamondview 648UT libusbscanner 0x0003 0x04a5 0x2022 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 620UT libusbscanner 0x0003 0x04a5 0x2040 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 640U | Guillemot / Hercules Maxi Scan A4 USB 640U | Guillemot / Hercules Maxi A4 36 bit libusbscanner 0x0003 0x04a5 0x2060 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 640bu libusbscanner 0x0003 0x04a5 0x207e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 3300 | Benq (Acer) 4300 | Mitsubishi Diamondview 650U libusbscanner 0x0003 0x04a5 0x20b0 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 640BT libusbscanner 0x0003 0x04a5 0x20be 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 1240 libusbscanner 0x0003 0x04a5 0x20c0 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 3300 | Benq (Acer) 4300 | Guillemot / Hercules Scan@home Touch 1248 (USB) libusbscanner 0x0003 0x04a5 0x20de 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 5000 libusbscanner 0x0003 0x04a5 0x20f8 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 5000E | Benq (Acer) 5000U libusbscanner 0x0003 0x04a5 0x20fc 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 5300 libusbscanner 0x0003 0x04a5 0x20fe 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Benq (Acer) 5150 | Benq (Acer) 5250 libusbscanner 0x0003 0x04a5 0x2137 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # BenQ 5550 libusbscanner 0x0003 0x04a5 0x2211 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Visioneer OneTouch 7100 libusbscanner 0x0003 0x04a7 0x0229 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer 9650 libusbscanner 0x0003 0x04a7 0x0390 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer 9320 libusbscanner 0x0003 0x04a7 0x0420 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer 9450 libusbscanner 0x0003 0x04a7 0x0421 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer 9550 libusbscanner 0x0003 0x04a7 0x0422 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer 9750 libusbscanner 0x0003 0x04a7 0x0423 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Strobe XP 450 libusbscanner 0x0003 0x04a7 0x0424 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Strobe XP 200 libusbscanner 0x0003 0x04a7 0x0426 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Strobe XP 100 libusbscanner 0x0003 0x04a7 0x0427 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer OneTouch 7300 libusbscanner 0x0003 0x04a7 0x0444 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate510 libusbscanner 0x0003 0x04a7 0x0446 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate520 libusbscanner 0x0003 0x04a7 0x0447 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate250 libusbscanner 0x0003 0x04a7 0x0448 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate252 libusbscanner 0x0003 0x04a7 0x0449 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate262 libusbscanner 0x0003 0x04a7 0x044c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Strobe XP 300 libusbscanner 0x0003 0x04a7 0x0474 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate272 libusbscanner 0x0003 0x04a7 0x0475 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate232 libusbscanner 0x0003 0x04a7 0x0476 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate152 libusbscanner 0x0003 0x04a7 0x0477 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate752 libusbscanner 0x0003 0x04a7 0x0478 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Strobe XP 470 libusbscanner 0x0003 0x04a7 0x0479 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer 9450-G libusbscanner 0x0003 0x04a7 0x047a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer 9650-G libusbscanner 0x0003 0x04a7 0x047b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate510-G libusbscanner 0x0003 0x04a7 0x047c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate252-G libusbscanner 0x0003 0x04a7 0x048c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate262-G libusbscanner 0x0003 0x04a7 0x048d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate272-G libusbscanner 0x0003 0x04a7 0x048e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Strobe XP 470-G | Visioneer Patriot 470 libusbscanner 0x0003 0x04a7 0x048f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate250-G libusbscanner 0x0003 0x04a7 0x0490 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Strobe XP 450-G libusbscanner 0x0003 0x04a7 0x0491 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate520-G libusbscanner 0x0003 0x04a7 0x0492 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer 9750-G libusbscanner 0x0003 0x04a7 0x0493 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Roadwarrior libusbscanner 0x0003 0x04a7 0x0494 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate512 libusbscanner 0x0003 0x04a7 0x0495 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Patriot 430 libusbscanner 0x0003 0x04a7 0x0497 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Patriot 680 | Xerox DocuMate632 libusbscanner 0x0003 0x04a7 0x0498 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Patriot 780 libusbscanner 0x0003 0x04a7 0x0499 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate752 libusbscanner 0x0003 0x04a7 0x049a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Visioneer Strobe XP 100,r3 libusbscanner 0x0003 0x04a7 0x049b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate150 libusbscanner 0x0003 0x04a7 0x049c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate162 libusbscanner 0x0003 0x04a7 0x049d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox DocuMate262i libusbscanner 0x0003 0x04a7 0x04a7 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox Travel Scanner 100 libusbscanner 0x0003 0x04a7 0x04ac 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-2080C libusbscanner 0x0003 0x04a9 0x1601 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CR-180 | Canon CR-180II libusbscanner 0x0003 0x04a9 0x1602 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-9080C libusbscanner 0x0003 0x04a9 0x1603 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-7080C libusbscanner 0x0003 0x04a9 0x1604 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-5010C libusbscanner 0x0003 0x04a9 0x1606 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-6080 libusbscanner 0x0003 0x04a9 0x1607 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-2580C libusbscanner 0x0003 0x04a9 0x1608 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-3080CII libusbscanner 0x0003 0x04a9 0x1609 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-2050C | Canon DR-2050SP libusbscanner 0x0003 0x04a9 0x160a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-7580 libusbscanner 0x0003 0x04a9 0x160b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP750 libusbscanner 0x0003 0x04a9 0x1706 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP780 | Canon PIXMA MP790 libusbscanner 0x0003 0x04a9 0x1707 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP760 | Canon PIXMA MP770 libusbscanner 0x0003 0x04a9 0x1708 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP150 libusbscanner 0x0003 0x04a9 0x1709 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP170 libusbscanner 0x0003 0x04a9 0x170a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP450 libusbscanner 0x0003 0x04a9 0x170b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP500 libusbscanner 0x0003 0x04a9 0x170c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP800 libusbscanner 0x0003 0x04a9 0x170d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP800R libusbscanner 0x0003 0x04a9 0x170e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP530 libusbscanner 0x0003 0x04a9 0x1712 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP830 libusbscanner 0x0003 0x04a9 0x1713 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP160 libusbscanner 0x0003 0x04a9 0x1714 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP180 libusbscanner 0x0003 0x04a9 0x1715 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP460 libusbscanner 0x0003 0x04a9 0x1716 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP510 libusbscanner 0x0003 0x04a9 0x1717 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP600 libusbscanner 0x0003 0x04a9 0x1718 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP600R libusbscanner 0x0003 0x04a9 0x1719 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP810 libusbscanner 0x0003 0x04a9 0x171a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP960 libusbscanner 0x0003 0x04a9 0x171b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX7600 libusbscanner 0x0003 0x04a9 0x171c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP210 libusbscanner 0x0003 0x04a9 0x1721 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP220 libusbscanner 0x0003 0x04a9 0x1722 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP470 libusbscanner 0x0003 0x04a9 0x1723 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP520 libusbscanner 0x0003 0x04a9 0x1724 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP610 libusbscanner 0x0003 0x04a9 0x1725 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP970 libusbscanner 0x0003 0x04a9 0x1726 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX300 libusbscanner 0x0003 0x04a9 0x1727 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX310 libusbscanner 0x0003 0x04a9 0x1728 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX700 libusbscanner 0x0003 0x04a9 0x1729 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP140 libusbscanner 0x0003 0x04a9 0x172b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX850 libusbscanner 0x0003 0x04a9 0x172c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP980 libusbscanner 0x0003 0x04a9 0x172d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP630 libusbscanner 0x0003 0x04a9 0x172e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP620 libusbscanner 0x0003 0x04a9 0x172f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP540 libusbscanner 0x0003 0x04a9 0x1730 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP480 libusbscanner 0x0003 0x04a9 0x1731 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP240 libusbscanner 0x0003 0x04a9 0x1732 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP260 libusbscanner 0x0003 0x04a9 0x1733 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP190 libusbscanner 0x0003 0x04a9 0x1734 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX860 libusbscanner 0x0003 0x04a9 0x1735 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX320 libusbscanner 0x0003 0x04a9 0x1736 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX330 libusbscanner 0x0003 0x04a9 0x1737 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP250 libusbscanner 0x0003 0x04a9 0x173a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP270 libusbscanner 0x0003 0x04a9 0x173b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP490 libusbscanner 0x0003 0x04a9 0x173c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP550 libusbscanner 0x0003 0x04a9 0x173d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP560 libusbscanner 0x0003 0x04a9 0x173e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP640 libusbscanner 0x0003 0x04a9 0x173f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP990 libusbscanner 0x0003 0x04a9 0x1740 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX340 libusbscanner 0x0003 0x04a9 0x1741 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX350 libusbscanner 0x0003 0x04a9 0x1742 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX870 libusbscanner 0x0003 0x04a9 0x1743 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP280 libusbscanner 0x0003 0x04a9 0x1746 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP495 libusbscanner 0x0003 0x04a9 0x1747 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG5100 Series libusbscanner 0x0003 0x04a9 0x1748 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG5200 Series libusbscanner 0x0003 0x04a9 0x1749 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG6100 Series libusbscanner 0x0003 0x04a9 0x174a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG8100 Series libusbscanner 0x0003 0x04a9 0x174b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX360 libusbscanner 0x0003 0x04a9 0x174d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX410 libusbscanner 0x0003 0x04a9 0x174e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX420 libusbscanner 0x0003 0x04a9 0x174f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX880 Series | Canon PIXMA MX882 | Canon PIXMA MX885 libusbscanner 0x0003 0x04a9 0x1750 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG2100 Series libusbscanner 0x0003 0x04a9 0x1751 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG3100 Series libusbscanner 0x0003 0x04a9 0x1752 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG4100 Series libusbscanner 0x0003 0x04a9 0x1753 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG5300 Series libusbscanner 0x0003 0x04a9 0x1754 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG6200 Series libusbscanner 0x0003 0x04a9 0x1755 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG8200 Series libusbscanner 0x0003 0x04a9 0x1756 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP493 libusbscanner 0x0003 0x04a9 0x1757 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA E500 libusbscanner 0x0003 0x04a9 0x1758 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX370 Series libusbscanner 0x0003 0x04a9 0x1759 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA E600 libusbscanner 0x0003 0x04a9 0x175a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX430 Series libusbscanner 0x0003 0x04a9 0x175b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX510 Series libusbscanner 0x0003 0x04a9 0x175c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX710 Series libusbscanner 0x0003 0x04a9 0x175d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX890 Series libusbscanner 0x0003 0x04a9 0x175e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP230 libusbscanner 0x0003 0x04a9 0x175f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG2200 Series libusbscanner 0x0003 0x04a9 0x1760 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA E510 libusbscanner 0x0003 0x04a9 0x1761 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG3200 Series libusbscanner 0x0003 0x04a9 0x1762 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG4200 Series libusbscanner 0x0003 0x04a9 0x1763 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG5400 Series libusbscanner 0x0003 0x04a9 0x1764 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MG6300 Series libusbscanner 0x0003 0x04a9 0x1765 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX390 Series libusbscanner 0x0003 0x04a9 0x1766 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA E610 libusbscanner 0x0003 0x04a9 0x1767 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX450 Series libusbscanner 0x0003 0x04a9 0x1768 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX520 Series libusbscanner 0x0003 0x04a9 0x1769 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX720 Series libusbscanner 0x0003 0x04a9 0x176a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MX920 Series libusbscanner 0x0003 0x04a9 0x176b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan 8800F libusbscanner 0x0003 0x04a9 0x1901 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan LiDE 100 libusbscanner 0x0003 0x04a9 0x1904 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan LiDE 200 libusbscanner 0x0003 0x04a9 0x1905 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan 700F libusbscanner 0x0003 0x04a9 0x1907 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan 9000F libusbscanner 0x0003 0x04a9 0x1908 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan LiDE 110 libusbscanner 0x0003 0x04a9 0x1909 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan LiDE 210 libusbscanner 0x0003 0x04a9 0x190a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan 9000F Mark II libusbscanner 0x0003 0x04a9 0x190d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan fb630u | Canon CanoScan fb636u libusbscanner 0x0003 0x04a9 0x2204 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan N650U/N656U libusbscanner 0x0003 0x04a9 0x2206 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan N1220U libusbscanner 0x0003 0x04a9 0x2207 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan D660U libusbscanner 0x0003 0x04a9 0x2208 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan N670U/N676U/LiDE20 libusbscanner 0x0003 0x04a9 0x220d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan N1240U/LiDE30 libusbscanner 0x0003 0x04a9 0x220e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan LiDE 35 | Canon CanoScan LiDE 40 | Canon CanoScan LiDE 50 libusbscanner 0x0003 0x04a9 0x2213 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan LiDE 60 libusbscanner 0x0003 0x04a9 0x221c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CanoScan LiDE25 libusbscanner 0x0003 0x04a9 0x2220 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-1210C libusbscanner 0x0003 0x04a9 0x2222 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP730 libusbscanner 0x0003 0x04a9 0x262f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP700 libusbscanner 0x0003 0x04a9 0x2630 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP360 libusbscanner 0x0003 0x04a9 0x263c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP370 libusbscanner 0x0003 0x04a9 0x263d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP390 libusbscanner 0x0003 0x04a9 0x263e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP375R libusbscanner 0x0003 0x04a9 0x263f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP740 libusbscanner 0x0003 0x04a9 0x264c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon PIXMA MP710 libusbscanner 0x0003 0x04a9 0x264d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF5630 libusbscanner 0x0003 0x04a9 0x264e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon laserBase MF5650 libusbscanner 0x0003 0x04a9 0x264f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF8170c libusbscanner 0x0003 0x04a9 0x2659 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF5730 libusbscanner 0x0003 0x04a9 0x265d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF5750 libusbscanner 0x0003 0x04a9 0x265e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF5770 libusbscanner 0x0003 0x04a9 0x265f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF3110 libusbscanner 0x0003 0x04a9 0x2660 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF3240 libusbscanner 0x0003 0x04a9 0x2684 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF6500 series | Canon imageCLASS MF6550 libusbscanner 0x0003 0x04a9 0x2686 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF4120 | Canon imageCLASS MF4122 | Canon imageCLASS MF4140 | Canon imageCLASS MF4150 libusbscanner 0x0003 0x04a9 0x26a3 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF4660 | Canon imageCLASS MF4690 libusbscanner 0x0003 0x04a9 0x26b0 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF4010 | Canon imageCLASS MF4018 libusbscanner 0x0003 0x04a9 0x26b4 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF4270 libusbscanner 0x0003 0x04a9 0x26b5 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageRUNNER 1020/1024/1025 libusbscanner 0x0003 0x04a9 0x26e6 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF4370dn | Canon imageCLASS MF4380dn libusbscanner 0x0003 0x04a9 0x26ec 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS D480 libusbscanner 0x0003 0x04a9 0x26ed 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon I-SENSYS MF4320d | Canon I-SENSYS MF4330d | Canon imageCLASS MF4350d libusbscanner 0x0003 0x04a9 0x26ee 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS D420 libusbscanner 0x0003 0x04a9 0x26ef 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon i-SENSYS MF5880dn libusbscanner 0x0003 0x04a9 0x26f9 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon i-SENSYS MF6680dn libusbscanner 0x0003 0x04a9 0x26fa 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF8030 libusbscanner 0x0003 0x04a9 0x2707 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon i-SENSYS MF4550d libusbscanner 0x0003 0x04a9 0x2736 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon imageCLASS MF4410 | Canon imageCLASS MF4430 libusbscanner 0x0003 0x04a9 0x2737 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon i-SENSYS MF3010 libusbscanner 0x0003 0x04a9 0x2759 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Nikon LS 40 ED | Nikon LS 40 ED | Nikon Coolspan IV libusbscanner 0x0003 0x04b0 0x4000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Nikon LS 50 ED | Nikon Coolscan V ED | Nikon LS 50 ED | Nikon Coolscan V ED libusbscanner 0x0003 0x04b0 0x4001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Nikon Super Coolscan LS-5000 ED | Nikon Super Coolscan LS-5000 ED libusbscanner 0x0003 0x04b0 0x4002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 636U | Epson GT-7000U | Epson Perfection 636U libusbscanner 0x0003 0x04b8 0x0101 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 610 | Epson GT-6600U | Epson Perfection 610 libusbscanner 0x0003 0x04b8 0x0103 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1200U | Epson Perfection 1200Photo | Epson GT-7600U | Epson GT-7600UF | Epson Perfection 1200U | Epson Perfection 1200U PHOTO libusbscanner 0x0003 0x04b8 0x0104 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Stylus Scan 2000 libusbscanner 0x0003 0x04b8 0x0105 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Stylus Scan 2500 libusbscanner 0x0003 0x04b8 0x0106 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Expression 1600 | Epson ES-2000 | Epson Expression 1600 libusbscanner 0x0003 0x04b8 0x0107 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ES-8500 | Epson Expression 1640XL libusbscanner 0x0003 0x04b8 0x0109 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1640 | Epson GT-8700 | Epson GT-8700F | Epson Perfection 1640SU | Epson Perfection 1640SU PHOTO libusbscanner 0x0003 0x04b8 0x010a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1240 | Epson GT-7700U | Epson Perfection 1240U libusbscanner 0x0003 0x04b8 0x010b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 640 | Epson GT-6700U | Epson Perfection 640U libusbscanner 0x0003 0x04b8 0x010c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Expression 1680 | Epson ES-2200 | Epson Expression 1680 libusbscanner 0x0003 0x04b8 0x010e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1250 | Epson Perfection 1250Photo libusbscanner 0x0003 0x04b8 0x010f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1650 | Epson GT-8200U | Epson GT-8200UF | Epson Perfection 1650 | Epson Perfection 1650 PHOTO libusbscanner 0x0003 0x04b8 0x0110 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 2450 | Epson GT-9700F | Epson Perfection 2450 PHOTO libusbscanner 0x0003 0x04b8 0x0112 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 660 libusbscanner 0x0003 0x04b8 0x0114 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 2400 | Epson GT-9300UF | Epson Perfection 2400 PHOTO libusbscanner 0x0003 0x04b8 0x011b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 3200 | Epson GT-9800F | Epson Perfection 3200 PHOTO libusbscanner 0x0003 0x04b8 0x011c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1260 | Epson Perfection 1260Photo libusbscanner 0x0003 0x04b8 0x011d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1660 | Epson GT-8300UF | Epson Perfection 1660 PHOTO libusbscanner 0x0003 0x04b8 0x011e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1670 libusbscanner 0x0003 0x04b8 0x011f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 1270 libusbscanner 0x0003 0x04b8 0x0120 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 2480 | Epson Perfection 2580 libusbscanner 0x0003 0x04b8 0x0121 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 3490 | Epson Perfection 3590 libusbscanner 0x0003 0x04b8 0x0122 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ES-7000H | Epson GT-15000 libusbscanner 0x0003 0x04b8 0x0126 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 4870 | Epson GT-X700 | Epson Perfection 4870 PHOTO libusbscanner 0x0003 0x04b8 0x0128 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ES-10000G | Epson Expression 10000XL libusbscanner 0x0003 0x04b8 0x0129 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Perfection 4990 | Epson GT-X800 | Epson Perfection 4990 PHOTO libusbscanner 0x0003 0x04b8 0x012a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ES-H300 | Epson GT-2500 libusbscanner 0x0003 0x04b8 0x012b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson V700 | Epson V750 | Epson GT-X900 | Epson Perfection V700 Photo | Epson Perfection V750 Photo libusbscanner 0x0003 0x04b8 0x012c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson GT-X970 libusbscanner 0x0003 0x04b8 0x0135 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-5200 | Epson CX-5400 | Epson CC-600PX | Epson Stylus CX5100 | Epson Stylus CX5200 libusbscanner 0x0003 0x04b8 0x0801 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-3200 | Epson CC-570L | Epson Stylus CX3100 | Epson Stylus CX3200 libusbscanner 0x0003 0x04b8 0x0802 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-6300 | Epson CX-6400 | Epson Stylus CX6300 | Epson Stylus CX6400 libusbscanner 0x0003 0x04b8 0x0805 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson RX-600 | Epson PM-A850 | Epson Stylus Photo RX600 libusbscanner 0x0003 0x04b8 0x0806 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson RX-500 | Epson Stylus Photo RX500 | Epson Stylus Photo RX510 libusbscanner 0x0003 0x04b8 0x0807 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-5400 | Epson Stylus CX5300 | Epson Stylus CX5400 libusbscanner 0x0003 0x04b8 0x0808 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Stylus CX-1500 libusbscanner 0x0003 0x04b8 0x080c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-4600 | Epson Stylus CX4500 | Epson Stylus CX4600 libusbscanner 0x0003 0x04b8 0x080d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-3600 | Epson CX-3650 | Epson PX-A550 | Epson Stylus CX3500 | Epson Stylus CX3600 | Epson Stylus CX3650 libusbscanner 0x0003 0x04b8 0x080e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson RX-425 | Epson Stylus Photo RX420 | Epson Stylus Photo RX425 | Epson Stylus Photo RX430 libusbscanner 0x0003 0x04b8 0x080f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson RX-700 | Epson PM-A900 | Epson Stylus Photo RX700 libusbscanner 0x0003 0x04b8 0x0810 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson RX-620 | Epson PM-A870 | Epson Stylus Photo RX620 | Epson Stylus Photo RX630 libusbscanner 0x0003 0x04b8 0x0811 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-6500 | Epson CX-6600 | Epson Stylus CX6500 | Epson Stylus CX6600 libusbscanner 0x0003 0x04b8 0x0813 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A700 libusbscanner 0x0003 0x04b8 0x0814 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson AcuLaser CX11 | Epson AcuLaser CX11NF | Epson LP-A500 libusbscanner 0x0003 0x04b8 0x0815 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson LP-M5500 | Epson LP-M5500F libusbscanner 0x0003 0x04b8 0x0817 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson DX-3850 | Epson CX-3700 | Epson CX-3800 | Epson DX-3800 | Epson Stylus CX3700 | Epson Stylus CX3800 | Epson Stylus DX3800 libusbscanner 0x0003 0x04b8 0x0818 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-4800 | Epson PX-A650 | Epson Stylus CX4700 | Epson Stylus CX4800 | Epson Stylus DX4800 | Epson Stylus DX4850 libusbscanner 0x0003 0x04b8 0x0819 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A750 | Epson Stylus Photo RX520 | Epson Stylus Photo RX530 libusbscanner 0x0003 0x04b8 0x081a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A890 | Epson Stylus Photo RX640 | Epson Stylus Photo RX650 libusbscanner 0x0003 0x04b8 0x081c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A950 libusbscanner 0x0003 0x04b8 0x081d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Stylus CX7700 | Epson Stylus CX7800 libusbscanner 0x0003 0x04b8 0x081f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-4200 | Epson Stylus CX4100 | Epson Stylus CX4200 | Epson Stylus DX4200 libusbscanner 0x0003 0x04b8 0x0820 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A820 | Epson Stylus Photo RX560 | Epson Stylus Photo RX580 | Epson Stylus Photo RX590 libusbscanner 0x0003 0x04b8 0x0827 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A970 libusbscanner 0x0003 0x04b8 0x0828 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-T990 libusbscanner 0x0003 0x04b8 0x0829 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A920 libusbscanner 0x0003 0x04b8 0x082a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson CX-5000 | Epson DX-5000 | Epson DX-5050 | Epson Stylus CX4900 | Epson Stylus CX5000 | Epson Stylus DX5000 libusbscanner 0x0003 0x04b8 0x082b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson DX-6000 | Epson PX-A720 | Epson Stylus CX5900 | Epson Stylus CX6000 | Epson Stylus DX6000 libusbscanner 0x0003 0x04b8 0x082e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson DX-4050 | Epson PX-A620 | Epson Stylus CX3900 | Epson Stylus DX4000 libusbscanner 0x0003 0x04b8 0x082f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ME 200 | Epson Stylus CX2800 | Epson Stylus CX2900 libusbscanner 0x0003 0x04b8 0x0830 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson LP-M5600 libusbscanner 0x0003 0x04b8 0x0833 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson LP-M6000 libusbscanner 0x0003 0x04b8 0x0834 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson AcuLaser CX21 libusbscanner 0x0003 0x04b8 0x0835 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-T960 libusbscanner 0x0003 0x04b8 0x0836 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A940 | Epson Stylus Photo RX680 | Epson Stylus Photo RX685 | Epson Stylus Photo RX690 libusbscanner 0x0003 0x04b8 0x0837 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson DX-7400 | Epson PX-A640 | Epson Stylus CX7300 | Epson Stylus CX7400 | Epson Stylus DX7400 libusbscanner 0x0003 0x04b8 0x0838 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PX-A740 | Epson Stylus CX8300 | Epson Stylus CX8400 | Epson Stylus DX8400 libusbscanner 0x0003 0x04b8 0x0839 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PX-FA700 | Epson Stylus CX9300F | Epson Stylus CX9400Fax | Epson Stylus DX9400F libusbscanner 0x0003 0x04b8 0x083a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PM-A840 | Epson PM-A840S | Epson Stylus Photo RX585 | Epson Stylus Photo RX595 | Epson Stylus Photo RX610 libusbscanner 0x0003 0x04b8 0x083c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ME 300 | Epson PX-401A | Epson Stylus NX100 | Epson Stylus SX100 | Epson Stylus TX100 libusbscanner 0x0003 0x04b8 0x0841 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson LP-M5000 libusbscanner 0x0003 0x04b8 0x0843 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Artisan 800 | Epson EP-901A | Epson EP-901F | Epson Stylus Photo PX800FW | Epson Stylus Photo TX800FW libusbscanner 0x0003 0x04b8 0x0844 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Artisan 700 | Epson EP-801A | Epson Stylus Photo PX700W | Epson Stylus Photo TX700W libusbscanner 0x0003 0x04b8 0x0846 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ME Office 700FW | Epson PX-601F | Epson Stylus Office BX600FW | Epson Stylus Office TX600FW | Epson Stylus SX600FW | Epson WorkForce 600 libusbscanner 0x0003 0x04b8 0x0847 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ME Office 600F | Epson Stylus Office BX300F | Epson Stylus Office TX300F | Epson Stylus NX300 libusbscanner 0x0003 0x04b8 0x0848 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Stylus NX200 | Epson Stylus SX200 | Epson Stylus SX205 | Epson Stylus TX200 | Epson Stylus TX203 | Epson Stylus TX209 libusbscanner 0x0003 0x04b8 0x0849 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PX-501A | Epson Stylus NX400 | Epson Stylus SX400 | Epson Stylus SX405 | Epson Stylus TX400 libusbscanner 0x0003 0x04b8 0x084a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson WorkForce 500 libusbscanner 0x0003 0x04b8 0x084c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PX-402A | Epson Stylus NX110 Series | Epson Stylus SX110 Series | Epson Stylus TX110 Series libusbscanner 0x0003 0x04b8 0x084d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ME OFFICE 510 | Epson Stylus NX210 Series | Epson Stylus SX210 Series | Epson Stylus TX210 Series libusbscanner 0x0003 0x04b8 0x084f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Stylus NX410 Series | Epson Stylus SX410 Series | Epson Stylus TX410 Series libusbscanner 0x0003 0x04b8 0x0851 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson ME OFFICE 650FN Series | Epson Stylus Office BX310FN Series | Epson Stylus Office TX510FN Series | Epson WorkForce 310 Series libusbscanner 0x0003 0x04b8 0x0854 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson PX-502A | Epson Stylus NX510 Series | Epson Stylus SX510W Series | Epson Stylus TX550W Series libusbscanner 0x0003 0x04b8 0x0856 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Epson Stylus SX125 libusbscanner 0x0003 0x04b8 0x085c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-4010CU libusbscanner 0x0003 0x04c5 0x1029 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-4120C libusbscanner 0x0003 0x04c5 0x1041 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-4220C libusbscanner 0x0003 0x04c5 0x1042 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-4530C libusbscanner 0x0003 0x04c5 0x1078 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5750C libusbscanner 0x0003 0x04c5 0x1095 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5110EOX/2 libusbscanner 0x0003 0x04c5 0x1096 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5110C libusbscanner 0x0003 0x04c5 0x1097 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5650C libusbscanner 0x0003 0x04c5 0x10ad 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-4120C2 libusbscanner 0x0003 0x04c5 0x10ae 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-4220C2 libusbscanner 0x0003 0x04c5 0x10af 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-60F libusbscanner 0x0003 0x04c5 0x10c7 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-4340C libusbscanner 0x0003 0x04c5 0x10cf 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5120C libusbscanner 0x0003 0x04c5 0x10e0 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5220C libusbscanner 0x0003 0x04c5 0x10e1 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5530C libusbscanner 0x0003 0x04c5 0x10e2 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5110EOX3 libusbscanner 0x0003 0x04c5 0x10e6 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5900C libusbscanner 0x0003 0x04c5 0x10e7 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5015C libusbscanner 0x0003 0x04c5 0x10ef 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5110EOXM libusbscanner 0x0003 0x04c5 0x10f2 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap S500 libusbscanner 0x0003 0x04c5 0x10fe 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap S500M libusbscanner 0x0003 0x04c5 0x1135 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5530C2 libusbscanner 0x0003 0x04c5 0x114a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6140 libusbscanner 0x0003 0x04c5 0x114d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6240 libusbscanner 0x0003 0x04c5 0x114e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6130 libusbscanner 0x0003 0x04c5 0x114f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6230 libusbscanner 0x0003 0x04c5 0x1150 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap S510 libusbscanner 0x0003 0x04c5 0x1155 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap S300 libusbscanner 0x0003 0x04c5 0x1156 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap S510M libusbscanner 0x0003 0x04c5 0x116f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6770 libusbscanner 0x0003 0x04c5 0x1174 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6770A libusbscanner 0x0003 0x04c5 0x1175 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6670 libusbscanner 0x0003 0x04c5 0x1176 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6670A libusbscanner 0x0003 0x04c5 0x1177 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6750S libusbscanner 0x0003 0x04c5 0x1178 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap S300M libusbscanner 0x0003 0x04c5 0x117f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6800 libusbscanner 0x0003 0x04c5 0x119d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6800-CGA libusbscanner 0x0003 0x04c5 0x119e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap S1500 | Fujitsu ScanSnap S1500M libusbscanner 0x0003 0x04c5 0x11a2 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap S1300 libusbscanner 0x0003 0x04c5 0x11ed 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6140Z libusbscanner 0x0003 0x04c5 0x11f1 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6240Z libusbscanner 0x0003 0x04c5 0x11f2 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6130Z libusbscanner 0x0003 0x04c5 0x11f3 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6230Z libusbscanner 0x0003 0x04c5 0x11f4 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-6110 libusbscanner 0x0003 0x04c5 0x11fc 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu fi-5950 libusbscanner 0x0003 0x04c5 0x1213 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Fujitsu ScanSnap iX500 libusbscanner 0x0003 0x04c5 0x132b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Konica e-mini libusbscanner 0x0003 0x04c8 0x0722 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S2026C libusbscanner 0x0003 0x04da 0x1000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S2046C libusbscanner 0x0003 0x04da 0x1001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S1025C libusbscanner 0x0003 0x04da 0x1006 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S1020C libusbscanner 0x0003 0x04da 0x1007 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S2048C libusbscanner 0x0003 0x04da 0x1009 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S2028C libusbscanner 0x0003 0x04da 0x100a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S4085C libusbscanner 0x0003 0x04da 0x100c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S4065C libusbscanner 0x0003 0x04da 0x100d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S7075C libusbscanner 0x0003 0x04da 0x100e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-SS080 libusbscanner 0x0003 0x04da 0x100f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Panasonic KV-S1045C libusbscanner 0x0003 0x04da 0x1010 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4x16 libusbscanner 0x0003 0x04e8 0x3409 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-6x20 libusbscanner 0x0003 0x04e8 0x340d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung MFP-560 libusbscanner 0x0003 0x04e8 0x340e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung MFP-750 libusbscanner 0x0003 0x04e8 0x340f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4x20 libusbscanner 0x0003 0x04e8 0x3412 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4100 libusbscanner 0x0003 0x04e8 0x3413 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4x21 libusbscanner 0x0003 0x04e8 0x3419 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-5x30 libusbscanner 0x0003 0x04e8 0x341a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4200 libusbscanner 0x0003 0x04e8 0x341b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-3160 libusbscanner 0x0003 0x04e8 0x341c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-6x22 libusbscanner 0x0003 0x04e8 0x341d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX4725 | Samsung SCX4725-FN libusbscanner 0x0003 0x04e8 0x341f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-6x45 libusbscanner 0x0003 0x04e8 0x3420 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-8380 libusbscanner 0x0003 0x04e8 0x3421 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-2160 libusbscanner 0x0003 0x04e8 0x3425 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4500 libusbscanner 0x0003 0x04e8 0x3426 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-6200 libusbscanner 0x0003 0x04e8 0x3427 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-6240 libusbscanner 0x0003 0x04e8 0x3428 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-6x55 libusbscanner 0x0003 0x04e8 0x3429 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-3170fn (CLX-3170 Series) | Samsung CLX-3175FW libusbscanner 0x0003 0x04e8 0x342a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4500W libusbscanner 0x0003 0x04e8 0x342b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4824 (SCX-4x24 Series) libusbscanner 0x0003 0x04e8 0x342c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4828FN (SCX-4x28 Series) libusbscanner 0x0003 0x04e8 0x342d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4300 libusbscanner 0x0003 0x04e8 0x342e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-5835_5935 libusbscanner 0x0003 0x04e8 0x342f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-5635 libusbscanner 0x0003 0x04e8 0x3430 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4x26 libusbscanner 0x0003 0x04e8 0x3432 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4600 libusbscanner 0x0003 0x04e8 0x3433 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4623 libusbscanner 0x0003 0x04e8 0x3434 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung MFP-65x libusbscanner 0x0003 0x04e8 0x3435 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-6545 libusbscanner 0x0003 0x04e8 0x3437 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-8385 libusbscanner 0x0003 0x04e8 0x3439 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-6220 libusbscanner 0x0003 0x04e8 0x343a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-6250 libusbscanner 0x0003 0x04e8 0x343b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4825FN (SCX-4x25 Series) libusbscanner 0x0003 0x04e8 0x343c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-3185 libusbscanner 0x0003 0x04e8 0x343d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-8540 libusbscanner 0x0003 0x04e8 0x343f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4623FW libusbscanner 0x0003 0x04e8 0x3440 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-3205W (SCX-3200 Series) libusbscanner 0x0003 0x04e8 0x3441 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-6545X libusbscanner 0x0003 0x04e8 0x3442 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-6x55X libusbscanner 0x0003 0x04e8 0x3443 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-8385X libusbscanner 0x0003 0x04e8 0x3444 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-5835_5935X libusbscanner 0x0003 0x04e8 0x3446 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4833FD | Samsung SCX-4835FD libusbscanner 0x0003 0x04e8 0x344b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-3400 libusbscanner 0x0003 0x04e8 0x344f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SF-760 libusbscanner 0x0003 0x04e8 0x3450 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4729FD libusbscanner 0x0003 0x04e8 0x3453 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-6260 libusbscanner 0x0003 0x04e8 0x3455 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-3300 Series libusbscanner 0x0003 0x04e8 0x3456 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-470x libusbscanner 0x0003 0x04e8 0x3457 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung CLX-4190 libusbscanner 0x0003 0x04e8 0x345a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-4650 4x21S Series libusbscanner 0x0003 0x04e8 0x345b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung M337x 387x 407x Series libusbscanner 0x0003 0x04e8 0x3460 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung M267x 287x Series libusbscanner 0x0003 0x04e8 0x3461 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung SCX-681x libusbscanner 0x0003 0x04e8 0x3466 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Samsung C460 libusbscanner 0x0003 0x04e8 0x3468 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Pentax DSmobile 600 libusbscanner 0x0003 0x04f9 0x2038 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Aiptek Aiptek Pencam libusbscanner 0x0003 0x0553 0x0202 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek ScanExpress 1200 CU libusbscanner 0x0003 0x055f 0x0001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek ScanExpress 600 CU libusbscanner 0x0003 0x055f 0x0002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek ScanExpress 1200 UB | Trust Compact Scan USB 19200 libusbscanner 0x0003 0x055f 0x0006 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek ScanExpress 1200 CU Plus libusbscanner 0x0003 0x055f 0x0008 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 1200 F libusbscanner 0x0003 0x055f 0x0010 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek ScanExpress A3 USB libusbscanner 0x0003 0x055f 0x0210 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 2400 CS | Mustek BearPaw 2400 TA | Trust 240TH Easy Webscan Gold libusbscanner 0x0003 0x055f 0x0218 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 2400 CS Plus | Mustek BearPaw 2400 TA Plus | Mustek Plug-n-Scan 2400 MT | Mustek Plug-n-Scan 2400 M | Packard Bell Diamond 2450 libusbscanner 0x0003 0x055f 0x0219 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 2448 CS Plus | Mustek BearPaw 2448 TA Plus libusbscanner 0x0003 0x055f 0x021a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 1200 CU Plus | Packard Bell Diamond 1200 Plus libusbscanner 0x0003 0x055f 0x021b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 1200 CU Plus | Mustek BearPaw 1248 CU | Packard Bell Diamond 1200 Plus | Trust Direct WebScan 19200 libusbscanner 0x0003 0x055f 0x021c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 2400 CU Plus libusbscanner 0x0003 0x055f 0x021d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 1200 CS | Mustek BearPaw 1200 TA libusbscanner 0x0003 0x055f 0x021e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek ScanExpress 1248 UB libusbscanner 0x0003 0x055f 0x021f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Mustek BearPaw 2448TA Pro libusbscanner 0x0003 0x055f 0x0409 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Artec/Ultima Ultima 2000 | Artec/Ultima Ultima 2000 e+ | Boeder Sm@rtScan Slim Edition | Fujitsu 1200CUS | Googlegear 2000 | Medion/Lifetec/Tevion/Cytron MD 4394 | Medion/Lifetec/Tevion/Cytron MD/LT 9375 | Medion/Lifetec/Tevion/Cytron MD/LT 9385 | Medion/Lifetec/Tevion/Cytron LT 9452 | Medion/Lifetec/Tevion/Cytron MD 9458 | Mustek BearPaw 1200 CU | Mustek BearPaw 2400 CU | Mustek ScanExpress 1200 UB Plus | Mustek ScanExpress 2400 USB | Mustek ScanMagic 1200 UB Plus | Packard Bell Diamond 1200 | Trust Compact Scan USB 19200 | Trust Flat Scan USB 19200 libusbscanner 0x0003 0x05d8 0x4002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Artec/Ultima E+ 48U | Medion/Lifetec/Tevion/Cytron MD9693 | Medion/Lifetec/Tevion/Cytron MD9705 | Medion/Lifetec/Tevion/Cytron MD4394 | Microstar MR 9791 libusbscanner 0x0003 0x05d8 0x4003 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Artec/Ultima E+ Pro libusbscanner 0x0003 0x05d8 0x4004 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Memorex MEM 48U libusbscanner 0x0003 0x05d8 0x4005 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Trust Easy Webscan 19200 libusbscanner 0x0003 0x05d8 0x4006 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Trust 240H Easy Webscan Gold libusbscanner 0x0003 0x05d8 0x4007 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # UMAX AstraSlim SE libusbscanner 0x0003 0x05d8 0x4009 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # UMAX AstraSlim 1200 SE libusbscanner 0x0003 0x05d8 0x4010 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Yakumo Scan50 libusbscanner 0x0003 0x05d8 0x4011 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker X6USB libusbscanner 0x0003 0x05da 0x0099 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek SlimScan C6 libusbscanner 0x0003 0x05da 0x009a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker V6USL libusbscanner 0x0003 0x05da 0x00a3 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker V6UPL libusbscanner 0x0003 0x05da 0x00b6 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker 4800 libusbscanner 0x0003 0x05da 0x30cf 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker 3840 libusbscanner 0x0003 0x05da 0x30d4 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker 3600 libusbscanner 0x0003 0x05da 0x40b3 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker 3700 libusbscanner 0x0003 0x05da 0x40b8 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker 3600 libusbscanner 0x0003 0x05da 0x40ca 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker 3700 libusbscanner 0x0003 0x05da 0x40cb 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker 3750 libusbscanner 0x0003 0x05da 0x40dd 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker 3600 libusbscanner 0x0003 0x05da 0x40ff 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Microtek ScanMaker V6USL libusbscanner 0x0003 0x05da 0x80a3 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # iVina 1200U libusbscanner 0x0003 0x0638 0x0268 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Minolta Dimage Scan Dual II libusbscanner 0x0003 0x0638 0x026a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV600U libusbscanner 0x0003 0x0638 0x0a13 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Minolta-QMS SC-110 libusbscanner 0x0003 0x0638 0x0a15 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision DS610CU Scancopier | Minolta-QMS SC-215 | OKI S700 Scancopier libusbscanner 0x0003 0x0638 0x0a16 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV610 | Avision AV600U Plus libusbscanner 0x0003 0x0638 0x0a18 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV220 libusbscanner 0x0003 0x0638 0x0a23 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV210 libusbscanner 0x0003 0x0638 0x0a24 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV210 libusbscanner 0x0003 0x0638 0x0a25 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV120 libusbscanner 0x0003 0x0638 0x0a27 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV220C2 libusbscanner 0x0003 0x0638 0x0a2a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV220D2 libusbscanner 0x0003 0x0638 0x0a2b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV220+ libusbscanner 0x0003 0x0638 0x0a2c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV220C2-G libusbscanner 0x0003 0x0638 0x0a2d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV220C2-B libusbscanner 0x0003 0x0638 0x0a2e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV210C2-G libusbscanner 0x0003 0x0638 0x0a2f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV122 libusbscanner 0x0003 0x0638 0x0a33 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV210C2 libusbscanner 0x0003 0x0638 0x0a3a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV121 libusbscanner 0x0003 0x0638 0x0a3c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV8300 libusbscanner 0x0003 0x0638 0x0a40 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AM3000 Series libusbscanner 0x0003 0x0638 0x0a41 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision @V5100 libusbscanner 0x0003 0x0638 0x0a45 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV8050U libusbscanner 0x0003 0x0638 0x0a4d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV3200SU libusbscanner 0x0003 0x0638 0x0a4e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV3730SU libusbscanner 0x0003 0x0638 0x0a4f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV610C2 libusbscanner 0x0003 0x0638 0x0a5e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision IT8300 libusbscanner 0x0003 0x0638 0x0a61 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV3750SU libusbscanner 0x0003 0x0638 0x0a65 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV3850SU libusbscanner 0x0003 0x0638 0x0a66 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV8350 libusbscanner 0x0003 0x0638 0x0a68 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision FB6080E libusbscanner 0x0003 0x0638 0x0a82 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision FB2080E libusbscanner 0x0003 0x0638 0x0a84 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV122 C2 libusbscanner 0x0003 0x0638 0x0a93 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV220-G libusbscanner 0x0003 0x0638 0x0a94 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision @V2500 libusbscanner 0x0003 0x0638 0x0aa1 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Avision AV210D2+ libusbscanner 0x0003 0x0638 0x1a35 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Minolta Elite II libusbscanner 0x0003 0x0686 0x4004 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Minolta Dimage Scan Dual III libusbscanner 0x0003 0x0686 0x400d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Minolta Dimage Scan Elite 5400 libusbscanner 0x0003 0x0686 0x400e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan 1212U libusbscanner 0x0003 0x06bd 0x0001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan 1236u libusbscanner 0x0003 0x06bd 0x0002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Agfa Snapscan Touch libusbscanner 0x0003 0x06bd 0x0100 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan 1212U_2 libusbscanner 0x0003 0x06bd 0x2061 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan e40 libusbscanner 0x0003 0x06bd 0x208d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan e50 libusbscanner 0x0003 0x06bd 0x208f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan e20 libusbscanner 0x0003 0x06bd 0x2091 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan e10 libusbscanner 0x0003 0x06bd 0x2093 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan e25 libusbscanner 0x0003 0x06bd 0x2095 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan e26 libusbscanner 0x0003 0x06bd 0x2097 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan e52 libusbscanner 0x0003 0x06bd 0x20fd 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # AGFA SnapScan e42 libusbscanner 0x0003 0x06bd 0x20ff 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # UMAX Astra 4900 libusbscanner 0x0003 0x06dc 0x0020 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro U12 | Plustek OpticPro UT12 | Plustek OpticPro 1212U | RevScan RevScan Orange R48Ti | Genius ColorPage Vivid III USB libusbscanner 0x0003 0x07b3 0x0001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro U12 libusbscanner 0x0003 0x07b3 0x0010 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro U24 libusbscanner 0x0003 0x07b3 0x0011 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro UT12 libusbscanner 0x0003 0x07b3 0x0013 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro U24 libusbscanner 0x0003 0x07b3 0x0015 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro UT12 | Plustek OpticPro UT16 | Plustek OpticPro UT24 libusbscanner 0x0003 0x07b3 0x0017 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro 1248U | RevScan 19200i libusbscanner 0x0003 0x07b3 0x0400 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro 1248U libusbscanner 0x0003 0x07b3 0x0401 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro U16B libusbscanner 0x0003 0x07b3 0x0402 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro U16B+ | Plustek OpticPro UT16B libusbscanner 0x0003 0x07b3 0x0403 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Nortek MyScan 1200 | Plustek OpticPro S12 | Plustek OpticPro ST12 libusbscanner 0x0003 0x07b3 0x040b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticPro S24 libusbscanner 0x0003 0x07b3 0x040e 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # NeatReceipts Scanalizer Professional 2.5 | Plustek OpticSlim M12 libusbscanner 0x0003 0x07b3 0x0412 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticSlim 1200 libusbscanner 0x0003 0x07b3 0x0413 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticSlim 2400 libusbscanner 0x0003 0x07b3 0x0422 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticSlim 2400 plus libusbscanner 0x0003 0x07b3 0x0454 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek Iriscan Express 2 libusbscanner 0x0003 0x07b3 0x045f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # NeatReceipts Mobile Scanner libusbscanner 0x0003 0x07b3 0x0462 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Plustek OpticBook 3600 libusbscanner 0x0003 0x07b3 0x0900 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Corex 600c libusbscanner 0x0003 0x08f0 0x0002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Corex 800c libusbscanner 0x0003 0x08f0 0x0005 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox Phaser 6110MFP libusbscanner 0x0003 0x0924 0x3d5d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox Phaser 3200MFP libusbscanner 0x0003 0x0924 0x3da4 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox WorkCentre 4118 Series libusbscanner 0x0003 0x0924 0x420c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox WorkCentre 3119 Series libusbscanner 0x0003 0x0924 0x4265 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox WorkCentre 3210 libusbscanner 0x0003 0x0924 0x4293 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Xerox WorkCentre 3220 libusbscanner 0x0003 0x0924 0x4294 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Pentax DSmobile 600 libusbscanner 0x0003 0x0a17 0x3210 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Portable Peripheral Co., Ltd. Q-Scan USB001 (A4 portable scanner) libusbscanner 0x0003 0x0a53 0x1000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Portable Peripheral Co., Ltd. Q-Scan USB201 (A6 portable scanner) libusbscanner 0x0003 0x0a53 0x2000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Syscan TravelScan 460/464 | Ambir Visigo A4 libusbscanner 0x0003 0x0a82 0x4600 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Syscan DocketPort 465 libusbscanner 0x0003 0x0a82 0x4802 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Syscan DocketPort 665 libusbscanner 0x0003 0x0a82 0x4803 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Syscan DocketPort 685/ Ambir DS685 libusbscanner 0x0003 0x0a82 0x480c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Syscan DocketPort 485 libusbscanner 0x0003 0x0a82 0x4810 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Syscan TravelScan 662 libusbscanner 0x0003 0x0a82 0x6620 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CR-55 libusbscanner 0x0003 0x1083 0x160c 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-1210C libusbscanner 0x0003 0x1083 0x160f 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-4010C libusbscanner 0x0003 0x1083 0x1614 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-2510C libusbscanner 0x0003 0x1083 0x1617 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-X10C libusbscanner 0x0003 0x1083 0x1618 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CR-25 libusbscanner 0x0003 0x1083 0x161a 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-2010C libusbscanner 0x0003 0x1083 0x161b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-3010C libusbscanner 0x0003 0x1083 0x161d 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-7090C libusbscanner 0x0003 0x1083 0x1620 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-9050C libusbscanner 0x0003 0x1083 0x1622 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-7550C libusbscanner 0x0003 0x1083 0x1623 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-6050C libusbscanner 0x0003 0x1083 0x1624 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-6010C libusbscanner 0x0003 0x1083 0x1626 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CR-190i libusbscanner 0x0003 0x1083 0x162b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon DR-6030C libusbscanner 0x0003 0x1083 0x1638 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Canon CR-135i libusbscanner 0x0003 0x1083 0x1639 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Digital Dream l' espion XS libusbscanner 0x0003 0x1183 0x0001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # KONICA MINOLTA magicolor 1690MF libusbscanner 0x0003 0x132b 0x2089 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # UMAX Astra 1220U libusbscanner 0x0003 0x1606 0x0010 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # UMAX Astra 1600U | UMAX Astra 2000U libusbscanner 0x0003 0x1606 0x0030 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Umax UMAX 3400 libusbscanner 0x0003 0x1606 0x0050 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Umax UMAX 3400 | Umax UMAX Astranet ia101 | Umax UMAX 3450 libusbscanner 0x0003 0x1606 0x0060 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # UMAX Astra 4400 | UMAX Astra 4450 libusbscanner 0x0003 0x1606 0x0070 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # UMAX Astra 2100U libusbscanner 0x0003 0x1606 0x0130 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Umax UMAX 5400 libusbscanner 0x0003 0x1606 0x0160 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # UMAX Astra 2200 (SU) libusbscanner 0x0003 0x1606 0x0230 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # DCT DocketPort 487 libusbscanner 0x0003 0x1dcc 0x4810 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Dell A920 libusbscanner 0x0003 0x413c 0x5105 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Dell Dell MFP Laser Printer 1815dn libusbscanner 0x0003 0x413c 0x5124 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 # Dell 1600n libusbscanner 0x0003 0x413c 0x5250 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000 sane-backends-1.0.29/testsuite/tools/data/hal.ref0000666000000000000000000055344413615534521016564 00000000000000 scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary sane-backends-1.0.29/testsuite/tools/data/hal-new.ref0000666000000000000000000055345213615534521017352 00000000000000 scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary scanner proprietary sane-backends-1.0.29/testsuite/tools/Makefile.in0000644000000000000000000003755713615534557016465 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = testsuite/tools ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_CPPFLAGS = @AM_CPPFLAGS@ AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SANEDESC = ../../tools/sane-desc$(EXEEXT) TESTFILE = $(srcdir)/data/testfile.desc OUTFILES = *.res DEVICE = test EXTRA_DIST = data/testfile.desc data/ascii.ref data/db.ref data/hal-new.ref \ data/hal.ref data/html-backends-split.ref data/html-mfgs.ref \ data/hwdb.ref data/plist.ref data/statistics.ref \ data/udev+acl.ref data/udev+hwdb.ref data/udev.ref \ data/usermap.ref data/xml.ref CLEANFILES = $(OUTFILES) all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu testsuite/tools/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am .PRECIOUS: Makefile all: @echo "run 'make check' to run tests" all: help help: @echo "Use 'make check' to run the tests." check: check.local check.local: @echo "**** Testing $(SANEDESC) with $(TESTFILE)" @for mode in ascii html-backends-split html-mfgs xml statistics usermap db udev udev+acl udev+hwdb hwdb plist hal hal-new; \ do \ $(SANEDESC) -m $$mode -s $(srcdir)/data >$$mode.res ;\ if diff -I "[ 012][0-9]:[0-5][0-9]:[0-6][0-9] 20[0-9][0-9]" \ -I "sane-backends 1\.0\.[0-9]\+\([-0-9a-fgdirty]\+\)\?$$" \ $(srcdir)/data/$$mode.ref $$mode.res ; \ then \ echo "PASS: sane-desc -m $$mode -s $(srcdir)/data"; \ else \ echo "FAIL: sane-desc -m $$mode -s $(srcdir)/data"; \ exit 1 ;\ fi; \ done ;\ echo "================" ;\ echo "All tests passed" ;\ echo "================" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/testsuite/tools/README0000666000000000000000000000045113615534521015252 00000000000000TOOLS test suite ================ This directory contains test for tools programs. They are run by 'make check'. sane-desc --------- sane-desc is ran for all known modes, using a test 'desc' file. The output is compared to a reference file for the same mode. Test fails if they are different. sane-backends-1.0.29/testsuite/Makefile.in0000644000000000000000000005414213615534556015311 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = testsuite ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir distdir-am am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_CPPFLAGS = @AM_CPPFLAGS@ AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = backend sanei tools SCANIMAGE = ../frontend/scanimage$(EXEEXT) TESTFILE = $(srcdir)/testfile.pnm OUTFILE = outfile.pnm DEVICE = test OPTIONS = --mode Color --depth 16 --test-picture "Color pattern" --resolution 50 -y 20 -x 20 > $(OUTFILE) EXTRA_DIST = README testfile.pnm CLEANFILES = $(OUTFILE) all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu testsuite/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile all: help help: @echo "Use 'make test' to run the tests." test: test.local test.local: @echo "**** Testing $(SCANIMAGE) with device $(DEVICE)" @if echo "---> Trying flatbed scanner" && \ $(SCANIMAGE) -d $(DEVICE) -T && \ echo "<--- Flatbed scanner succeeded" && \ echo "---> Trying three pass flatbed scanner" && \ $(SCANIMAGE) -d $(DEVICE) --mode Color --three-pass=yes -T && \ echo "<--- Three pass scanner succeeded" && \ echo "---> Trying hand scanner" && \ $(SCANIMAGE) -d $(DEVICE) --hand-scanner=yes -T && \ echo "<--- Hand scanner succeeded" && \ echo "---> Checking 16 bit color mode" && \ $(SCANIMAGE) -d $(DEVICE) $(OPTIONS) && \ cmp -s $(TESTFILE) $(OUTFILE) && \ echo "<--- 16 bit color mode succeeded" && \ rm $(OUTFILE) ; \ then echo ; echo ; echo "**** All tests passed" ; \ else echo ; echo; \ echo "**** Something failed (maybe test backend not enabled by configure?)";\ exit 1; \ fi # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/testsuite/sanei/0000755000000000000000000000000013615535555014415 500000000000000sane-backends-1.0.29/testsuite/sanei/sanei_usb_test.c0000666000000000000000000005412713615534521017515 00000000000000#include "../../include/sane/config.h" #include #include #include #include #include #include #include #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_MKDIR #include #include #endif #include #define BACKEND_NAME sanei_usb #include "../../include/sane/sane.h" #include "../../include/sane/sanei.h" #include "../../include/sane/saneopts.h" #include "../../include/sane/sanei_backend.h" #include "../../include/sane/sanei_usb.h" #include "../../include/_stdint.h" /* * In order to avoid modifying sanei_usb.c to allow for unit tests * we include it so we can use its private variables and structures * and still test the code. */ #include "../../sanei/sanei_usb.c" /** test sanei_usb_init() * calls sanei_usb_init * @param expected expected use count * @return 1 on success, else 0 */ static int test_init (int expected) { /* initialize USB */ printf ("%s starting ...\n", __func__); sanei_usb_init (); if (initialized == 0) { printf ("ERROR: sanei_usb not initialized!\n"); return 0; } if (initialized != expected) { printf ("ERROR: incorrect use count, expected %d, got %d!\n", expected, initialized); return 0; } printf ("sanei_usb initialized, use count is %d ...\n", initialized); printf ("%s success\n\n", __func__); return 1; } /** test sanei_usb_exit() * calls sanei_usb_exit * @param expected use count after exit call * @return 1 on success, else 0 */ static int test_exit (int expected) { printf ("%s starting ...\n", __func__); /* end of USB use test */ sanei_usb_exit (); if (initialized != expected) { printf ("ERROR: incorrect use count, expected %d, got %d!\n", expected, initialized); return 0; } printf ("%s success\n\n", __func__); return 1; } /** count detected devices * count all detected devices and check it against expected value * @param expected detected count * @return 1 on success, else 0 */ static int count_detected (int expected) { int num = 0; int i; for (i = 0; i < device_number; i++) { if (devices[i].missing == 0 && devices[i].devname != NULL) { num++; } } if (num != expected) { printf ("ERROR: %d detected devices, expected %d!\n", num, expected); return 0; } printf ("%d devices still detected.\n", num); return 1; } /** create mock device * create a mock device entry * @param device device pointer to fill with mock data * @return nothing */ static void create_mock_device (char *devname, device_list_type * device) { memset (device, 0, sizeof (device_list_type)); device->devname = strdup (devname); device->vendor = 0xdead; device->product = 0xbeef; #if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB) device->method = sanei_usb_method_libusb; #endif #ifdef HAVE_USBCALLS device->method = sanei_usb_method_usbcalls; #endif #if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) && !defined(HAVE_USBCALLS) device->method == sanei_usb_method_scanner_driver; #endif } /** test store_device * test store_device for corner cases not covered by the * other regular use by sanei_usb_scan_devices * the startiing situation is that the mock device has never * put into device list. * @return 1 on success, else 0 */ static int test_store_device (void) { int current_number; int expected; int i; int found; device_list_type mock; create_mock_device ("mock", &mock); /* first test store when there is no more room * to store device */ current_number = device_number; device_number = MAX_DEVICES; /* give unused devices a name so strcmp() won't crash. */ for (i = current_number; i < MAX_DEVICES; i++) devices[i].devname = ""; store_device (mock); /* there should be no more devices */ if (device_number > MAX_DEVICES) { printf ("ERROR: store past end of device list!\n"); return 0; } /* walk device list to be sure mock device hasn't been stored */ for (i = 0; i < MAX_DEVICES; i++) { if (devices[i].devname && !strcmp (devices[i].devname, mock.devname)) { printf ("ERROR: device stored although there were no place for it!\n"); return 0; } } /* restore device_number */ device_number = current_number; /* reset unused devnames to NULL */ for (i = current_number; i < MAX_DEVICES; i++) devices[i].devname = NULL; expected = device_number + 1; /* store mock device */ store_device (mock); found = 0; for (i = 0; i < MAX_DEVICES && !found; i++) { if (devices[i].devname && !strcmp (devices[i].devname, mock.devname)) { found = 1; } } if (device_number != expected || !found) { printf ("ERROR: mock device not stored !\n"); return 0; } /* scan devices should mark it as missing, and device_number should decrease */ sanei_usb_scan_devices (); found = 0; for (i = 0; i < MAX_DEVICES && !found; i++) { if (devices[i].devname && devices[i].missing == 1 && !strcmp (devices[i].devname, mock.devname)) { found = 1; } } if (device_number != expected || !found) { printf ("ERROR: mock device still present !\n"); return 0; } /* second scan devices should mark missing to 2 */ sanei_usb_scan_devices (); found = 0; for (i = 0; i < MAX_DEVICES && !found; i++) { if (devices[i].devname && devices[i].missing == 2 && !strcmp (devices[i].devname, mock.devname)) { found = 1; } } if (device_number != expected || !found) { printf ("ERROR: mock device slot not reusable !\n"); return 0; } /* store mock device again, slot in devices should be reused * and device_number shouldn't change */ create_mock_device ("mock2", &mock); store_device (mock); found = 0; for (i = 0; i < MAX_DEVICES && !found; i++) { if (devices[i].devname && !strcmp (devices[i].devname, mock.devname)) { found = 1; } } if (device_number != expected || !found) { printf ("ERROR: mock device not stored !\n"); return 0; } /* last rescan to wipe mock device out */ sanei_usb_scan_devices (); return 1; } /** return count of opened devices * @return count of opened devices */ static int get_opened (void) { int num = 0; int i; for (i = 0; i < device_number; i++) { if (devices[i].missing == 0 && devices[i].devname != NULL && devices[i].open == SANE_TRUE) { num++; } } return num; } /** count opened devices * count all opended devices and check it against expected value * @param expected use opened count * @return 1 on success, else 0 */ static int count_opened (int expected) { int num = get_opened(); if (num != expected) { printf ("ERROR: %d opened devices, expected %d!\n", num, expected); return 0; } printf ("%d devices still opened.\n", num); return 1; } /** open all devices * loop on all existing devices and open them * @param dn array to store opened device number * @param expected number of devices to be opened * @return 1 on success, else 0 */ static int test_open_all (SANE_Int * dn, int expected) { int opened = 0; int i; int last; SANE_Status status; /* loop on detected devices and open them */ last = -1; for (i = 0; i < device_number; i++) { if (devices[i].missing == 0 && devices[i].devname != NULL) { /* open device */ status = sanei_usb_open (devices[i].devname, dn + opened); if (status == SANE_STATUS_GOOD) { opened++; last = i; } else { if (status == SANE_STATUS_ACCESS_DENIED || status == SANE_STATUS_DEVICE_BUSY) { expected--; } else { printf ("ERROR: couldn't open device %s!\n", devices[i].devname); return 0; } } } } printf ("opened %d devices\n", opened); /* try to reopen an opened device when there is one */ if (last >= 0) { status = sanei_usb_open (devices[last].devname, dn + opened); if (status == SANE_STATUS_GOOD) { printf ("ERROR: unexpected success when opening %s twice!\n", devices[last].devname); return 0; } } /* there should be as many opened devices than detected devices */ return count_opened (expected); } /** test opening invalid device * try to open an non existing device * @return 1 on success, else 0 */ static int test_open_invalid (void) { SANE_Status status; SANE_Int dn; status = sanei_usb_open ("invalid device", &dn); if (status == SANE_STATUS_GOOD) { printf ("ERROR: unexpected success opening invalid device!\n"); return 0; } return 1; } /** close all devices * loop on all opened devices and close them * @param dn array of opened device number * @param expected number of devices to be closed * @return 1 on success, else 0 */ static int test_close_all (SANE_Int * dn, int expected) { int closed = 0; int i; /* loop on detected devices and open them */ for (i = 0; i < expected; i++) { /* close device */ sanei_usb_close (dn[i]); closed++; } printf ("closed %d devices\n", closed); /* there should be any more opened devices */ return count_opened (0); } /** claim all open devices * loop on all opened devices and claim interface 0 * @param dn array of opened device number * @param expected number of devices to be claimed * @return 1 on success, else 0 */ static int test_claim_all (SANE_Int * dn, int expected) { int claimed = 0; int i; SANE_Status status; device_list_type mock; claimed = 0; for (i = 0; i < expected; i++) { status = sanei_usb_claim_interface (dn[i], devices[dn[i]].interface_nr); if (status != SANE_STATUS_GOOD) { printf ("ERROR: couldn't claim interface 0 on device %d!\n", dn[i]); } else { claimed++; } } if (claimed != expected) { printf ("ERROR: expected %d claimed interfaces, got %d!\n", expected, claimed); return 0; } printf ("%d devices claimed...\n\n", claimed); /* try to claim invalid device entry */ status = sanei_usb_claim_interface (device_number, 0); if (status == SANE_STATUS_GOOD) { printf ("ERROR: could claim interface 0 on invalid device!\n"); return 0; } /* create a mock device and make it missing by rescanning */ create_mock_device ("mock", &mock); store_device (mock); sanei_usb_scan_devices (); /* try to claim interface on missing device */ status = sanei_usb_claim_interface (device_number - 1, 0); if (status == SANE_STATUS_GOOD) { printf ("ERROR: could claim interface 0 on invalid device!\n"); return 0; } /* remove mock device */ device_number--; free (devices[device_number].devname); devices[device_number].devname = NULL; return 1; } /** release all claimed devices * loop on all opened devices and claim interface 0 * @param dn array of opened device number * @param expected number of devices to be claimed * @return 1 on success, else 0 */ static int test_release_all (SANE_Int * dn, int expected) { int released = 0; int i; SANE_Status status; device_list_type mock; released = 0; for (i = 0; i < expected; i++) { status = sanei_usb_release_interface (dn[i], devices[dn[i]].interface_nr); if (status != SANE_STATUS_GOOD) { printf ("ERROR: couldn't release interface 0 on device %d!\n", dn[i]); } else { released++; } } if (released != expected) { printf ("ERROR: expected %d released interfaces, got %d!\n", expected, released); return 0; } printf ("%d devices released...\n\n", released); /* try to release invalid device entry */ status = sanei_usb_release_interface (device_number, 0); if (status == SANE_STATUS_GOOD) { printf ("ERROR: could release interface 0 on invalid device!\n"); return 0; } /* create a mock device and make it missing by rescanning */ create_mock_device ("mock", &mock); store_device (mock); sanei_usb_scan_devices (); /* try to claim interface on missing device */ status = sanei_usb_release_interface (device_number - 1, 0); if (status == SANE_STATUS_GOOD) { printf ("ERROR: could release interface 0 on invalid device!\n"); return 0; } /* remove mock device */ device_number--; free (devices[device_number].devname); devices[device_number].devname = NULL; return 1; } /** get id for all devices names * loop on all existing devices and get vendor * and product id by name. * @param expected count * @return 1 on success, else 0 */ static int test_vendor_by_devname (void) { int i; SANE_Status status; SANE_Word vendor, product; device_list_type mock; /* loop on detected devices and open them */ for (i = 0; i < device_number; i++) { if (devices[i].missing == 0 && devices[i].devname != NULL) { /* get device id */ status = sanei_usb_get_vendor_product_byname (devices[i].devname, &vendor, &product); if (status != SANE_STATUS_GOOD) { printf ("ERROR: couldn't query device %s!\n", devices[i].devname); return 0; } if (vendor == 0 || product == 0) { printf ("ERROR: incomplete device id for %s!\n", devices[i].devname); return 0; } printf ("%s is %04x:%04x\n", devices[i].devname, vendor, product); } } /* add mock device */ create_mock_device ("mock", &mock); store_device (mock); status = sanei_usb_get_vendor_product_byname ("mock", &vendor, &product); if (status != SANE_STATUS_GOOD) { printf ("ERROR: getting vendor for mock devname!\n"); return 0; } if (vendor != mock.vendor || product != mock.product) { printf ("ERROR: wrong vendor/product for mock devname!\n"); return 0; } /* remove mock device */ device_number--; free (devices[device_number].devname); devices[device_number].devname = NULL; /* try go get id for an invalid devname */ status = sanei_usb_get_vendor_product_byname ("invalid devname", &vendor, &product); if (status == SANE_STATUS_GOOD) { printf ("ERROR: unexpected success getting id for invalid devname!\n"); return 0; } printf ("\n"); return 1; } /** get vendor for all devices id * loop on all existing devices and get vendor * and product id. * @param expected count * @return 1 on success, else 0 */ static int test_vendor_by_id (void) { int i; SANE_Status status; SANE_Word vendor, product; device_list_type mock; /* loop on detected devices and open them */ for (i = 0; i < device_number; i++) { if (devices[i].missing == 0 && devices[i].devname != NULL) { /* get device id */ status = sanei_usb_get_vendor_product (i, &vendor, &product); if (status != SANE_STATUS_GOOD) { printf ("ERROR: couldn't query device %d!\n", i); return 0; } if (vendor == 0 || product == 0) { printf ("ERROR: incomplete device id for %d!\n", i); return 0; } printf ("%d is %04x:%04x\n", i, vendor, product); } } /* add mock device */ create_mock_device ("mock", &mock); store_device (mock); status = sanei_usb_get_vendor_product (device_number - 1, &vendor, &product); if (status != SANE_STATUS_GOOD) { printf ("ERROR: getting vendor for mock devname!\n"); return 0; } if (vendor != mock.vendor || product != mock.product) { printf ("ERROR: wrong vendor/product for mock devname!\n"); return 0; } /* remove mock device */ device_number--; free (devices[device_number].devname); devices[device_number].devname = NULL; /* try go get id for an invalid id */ status = sanei_usb_get_vendor_product (device_number + 1, &vendor, &product); if (status == SANE_STATUS_GOOD) { printf ("ERROR: unexpected success getting vendor for invalid devname!\n"); return 0; } printf ("\n"); return 1; } /** test timeout functions : libusb only * @return 1 on success, else 0 */ static int test_timeout (void) { #if defined(HAVE_LIBUSB_LEGACY) || defined(HAVE_LIBUSB) int timeout = libusb_timeout; sanei_usb_set_timeout (5000); if (libusb_timeout != 5000) { printf ("ERROR: failed to set timeout\n"); return 1; } sanei_usb_set_timeout (timeout); #endif return 1; } /** test device scanning * call sanei_usb_scan_devices, since it has no return code, no real * assert can be done, but at least we can test it doesn't break * other functions or don't leak memory * @return always 1 */ static int test_scan_devices (int detected, int opened) { int rc; printf ("rescanning for devices ...\n"); sanei_usb_scan_devices (); rc = count_detected (detected); if (!rc) { printf ("ERROR: scanning devices change detected count!\n"); return 0; } rc = count_opened (opened); if (!rc) { printf ("ERROR: scanning devices change opened count!\n"); return 0; } printf ("\n"); return 1; } /** * flag for dummy attach */ static int dummy_flag; /** * expected device name during attach */ static char *expected_device; /** dummy attach function * dummy attach function * @return resturn SANE_STATUS_GOOD */ static SANE_Status dummy_attach (const char *dev) { dummy_flag = (strcmp (expected_device, dev) == 0); if (dummy_flag) { printf ("success attaching to %s...\n", dev); } else { printf ("failed attaching to %s...\n", dev); } return SANE_STATUS_GOOD; } /** test attaching usb device * create a mock device and attach to it, checking * if it is ok * @return 1 on success, else 0 */ static int test_attach (void) { device_list_type mock; /* add mock device and try ot attach to it */ dummy_flag = 0; create_mock_device ("mock", &mock); expected_device = mock.devname; store_device (mock); sanei_usb_attach_matching_devices ("usb 0xdead 0xbeef", dummy_attach); /* flag must be set */ if (dummy_flag != 1) { printf ("ERROR: couldn't attach to 'usb xdead 0xbeef' device!\n"); return 0; } /* attach by devname */ dummy_flag = 0; sanei_usb_attach_matching_devices (mock.devname, dummy_attach); /* flag must be set */ if (dummy_flag != 1) { printf ("ERROR: couldn't attach to 'mock' device!\n"); return 0; } /* attach to bogus device */ dummy_flag = 0; sanei_usb_attach_matching_devices ("usb 0x0001 0x0001", dummy_attach); /* flag must not be set */ if (dummy_flag != 0) { printf ("ERROR: shouldn't be attached to bogus device!\n"); return 0; } /* attach by bogus devname */ sanei_usb_attach_matching_devices ("bogus", dummy_attach); /* flag must not be set */ if (dummy_flag != 0) { printf ("ERROR: shouldn't be attached to bogus device!\n"); return 0; } /* remove mock device */ device_number--; free (devices[device_number].devname); devices[device_number].devname = NULL; dummy_flag = 0; return 1; } int main (int __sane_unused__ argc, char **argv) { int detected, opened, i; SANE_Int dn[MAX_DEVICES]; #ifdef HAVE_LIBUSB_LEGACY printf ("\n%s built with old libusb\n\n", argv[0]); #endif #ifdef HAVE_LIBUSB printf ("\n%s built with libusb-1.0\n\n", argv[0]); #endif #ifdef HAVE_USBCALLS printf ("\n%s built with usbcalls\n\n", argv[0]); #endif #if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) && !defined(HAVE_USBCALLS) printf ("\n%s relying on deprecated scanner kernel module\n", argv[0]); #endif /* start sanei_usb */ assert (test_init (1)); /* test timeout function */ assert (test_timeout ()); /* count available devices */ detected = 0; for (i = 0; i < device_number; i++) { if (devices[i].missing == 0 && devices[i].devname != NULL) { detected++; } } printf ("%d devices found.\n", detected); /* rescan devices : detected count shouldn't change */ assert (test_scan_devices (detected, 0)); /* test corner cases with mock device */ assert (test_store_device ()); /* get vendor/product id for all available devices devname */ assert (test_vendor_by_devname ()); /* get vendor/product id for all available devices id */ assert (test_vendor_by_id ()); /* open all available devices */ assert (test_open_all (dn, detected)); opened = get_opened(); /* rescan devices : detected and opened count shouldn't change */ assert (test_scan_devices (detected, opened)); /* try to open an inexisting device */ assert (test_open_invalid ()); /* increase sanei _sub use count */ assert (test_init (2)); /* there should be still as many detected devices */ assert (count_detected (detected)); /* there should be still as many opened devices */ assert (count_opened (opened)); assert (test_exit (1)); /* there should be still as many opened devices */ assert (count_opened (opened)); /* count devices again , sanei_usb_exit() shouldn't have * change the count */ assert (count_detected (detected)); /* claim all available devices */ assert (test_claim_all (dn, opened)); /* then release them all */ assert (test_release_all (dn, opened)); /* close all opened devices */ assert (test_close_all (dn, opened)); /* check there is no opened device */ assert (count_opened (0)); /* finally free resources */ assert (test_exit (0)); /* check there is no more devices */ assert (count_detected (0)); /* test attach matching device with a mock */ assert (test_attach ()); /* try to call sanei_usb_exit() when it not initialized */ assert (test_exit (0)); /* scan devices when sanei usb is not initialized */ assert (test_scan_devices (0, 0)); /* we re start use of sanei usb so we check we have left it * it he correct state after "closing" it. */ printf ("\n============================================================\n"); printf ("restart use of sanei usb after having freed all resources...\n\n"); assert (test_init (1)); /* we should have the same initial count of detected devices */ assert (count_detected (detected)); /* finally free resources */ assert (test_exit (0)); /* all the tests are OK ! */ return 0; } /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ sane-backends-1.0.29/testsuite/sanei/Makefile.am0000666000000000000000000000270413615534521016370 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2013 Stéphane Voltz and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. EXTRA_DIST = data/boolean.conf data/empty.conf data/fixed.conf data/int.conf \ data/snapscan.conf data/string.conf data/string-list.conf \ data/umax_pp.conf data/word-array.conf data/wrong-boolean.conf \ data/wrong-fixed.conf data/wrong-range.conf \ data/wrong-string-list.conf TEST_LDADD = ../../sanei/libsanei.la ../../lib/liblib.la \ $(MATH_LIB) $(USB_LIBS) $(XML_LIBS) $(PTHREAD_LIBS) check_PROGRAMS = sanei_usb_test test_wire sanei_check_test sanei_config_test sanei_constrain_test TESTS = $(check_PROGRAMS) AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include \ $(USB_CFLAGS) $(XML_CFLAGS) sanei_constrain_test_SOURCES = sanei_constrain_test.c sanei_constrain_test_LDADD = $(TEST_LDADD) sanei_config_test_SOURCES = sanei_config_test.c sanei_config_test_CPPFLAGS = $(AM_CPPFLAGS) -DTESTSUITE_SANEI_SRCDIR=$(srcdir) sanei_config_test_LDADD = $(TEST_LDADD) sanei_check_test_SOURCES = sanei_check_test.c sanei_check_test_LDADD = $(TEST_LDADD) sanei_usb_test_SOURCES = sanei_usb_test.c sanei_usb_test_LDADD = $(TEST_LDADD) test_wire_SOURCES = test_wire.c test_wire_LDADD = $(TEST_LDADD) clean-local: rm -f test_wire.out all: @echo "run 'make check' to run tests" sane-backends-1.0.29/testsuite/sanei/data/0000755000000000000000000000000013615535555015326 500000000000000sane-backends-1.0.29/testsuite/sanei/data/umax_pp.conf0000666000000000000000000000321213615534521017560 00000000000000# For documentation see sane-umax_pp(5) # GLOBAL # # size (in bytes) of scan buffer (default: 2 megabyte) option buffer 1048576 # DEVICES # # specify the port your scanner is connected to. # # the value 'auto' will make the backend find the correct value # by itself, it will scan ppdev, ppi device, then hardware address # 'safe-auto' will do the same but won't do direct hardware access # on linux systems, you may provide the device name of the ppdev character # device : /dev/parport0, /dev/parport1, ...... # # on *BSD, you may provide the device name of the ppi device: /dev/ppi0, # /dev/ppi1, ... # # Possible hardware addresses are 0x378 (lp0) # 0x278 (lp2) and 0x3c8 (lp1) # port safe-auto # the following options are local to this scanner # gain for red channel, if not given, will be automatically computed # must be between 0 and 15 option red-gain 1 # gain for green channel, if not given, will be automatically computed # must be between 0 and 15 option green-gain 2 # gain for blue channel, if not given, will be automatically computed # must be between 0 and 15 option blue-gain 3 # offset for red channel, if not given, will default to 0 # must be between 0 and 15 option red-offset 4 # offset for green channel, if not given, will default to 0 # must be between 0 and 15 option green-offset 5 # offset for blue channel, if not given, will default to 0 # must be between 0 and 15 option blue-offset 6 # # # model number # # valid values are 610, 1220, 1600 and 2000 # # by default, no model, we rely on autodetection # in case you have black or 'inverted' scans, # you may override detection by providing the # model number option astra 1600 sane-backends-1.0.29/testsuite/sanei/data/fixed.conf0000666000000000000000000000020713615534521017207 00000000000000# FIXED type options option height 29.7 some device option array-of-fixed 2.0 2.1 2.2 2.3 2.4 2.5 2.6 another device option width 21.0 sane-backends-1.0.29/testsuite/sanei/data/snapscan.conf0000666000000000000000000000427713615534521017731 00000000000000#------------------------------ General ----------------------------------- # Change to the fully qualified filename of your firmware file, if # firmware upload is needed by the scanner firmware /usr/share/sane/snapscan/your-firmwarefile.bin # If not automatically found you may manually specify a device name. # For USB scanners also specify bus=usb, e.g. # /dev/usb/scanner0 bus=usb # For SCSI scanners specify the generic device, e.g. /dev/sg0 on Linux. # /dev/sg0 #--------------------------------------------------------------------------- # No changes should be necessary below this line #--------------------------------------------------------------------------- #-------------------------- SCSI scanners ---------------------------------- # These SCSI devices will be probed automatically scsi AGFA * Scanner scsi COLOR * Scanner scsi Color * Scanner scsi ACERPERI * Scanner #--------------------------- USB scanners ----------------------------------- # These USB devices will be probed automatically # (This will currently work only on Linux) # Benq/Acer/Vuego 310U usb 0x04a5 0x1a20 usb 0x04a5 0x1a26 # Benq/Acer/Vuego 320U usb 0x04a5 0x2022 # Benq/Acer/Vuego 620U / 620UT usb 0x04a5 0x1a2a usb 0x04a5 0x2040 # Benq/Acer/Vuego 640U usb 0x04a5 0x2060 # Benq/Acer/Vuego 640BU usb 0x04a5 0x207e # Benq/Acer/Vuego 640BT usb 0x04a5 0x20be # Benq/Acer/Vuego 1240U usb 0x04a5 0x20c0 # Benq/Acer/Vuego 3300 / 4300 usb 0x04a5 0x20b0 # Benq/Acer/Vuego 4300 usb 0x04a5 0x20de # Benq 5000E / 5000U usb 0x04a5 0x20f8 # Benq 5000 usb 0x04a5 0x20fc # Benq/Acer 5300 usb 0x04a5 0x20fe # Benq 5250C usb 0x04a5 0x2137 # Agfa 1236U usb 0x06bd 0x0002 # Agfa 1212U usb 0x06bd 0x0001 usb 0x06bd 0x2061 # Agfa Snapscan e10 usb 0x06bd 0x2093 # Agfa Snapscan e20 usb 0x06bd 0x2091 # Agfa Snapscan e25 usb 0x06bd 0x2095 # Agfa Snapscan e26 usb 0x06bd 0x2097 # Agfa Snapscan e40 usb 0x06bd 0x208d # Agfa Snapscan e42 usb 0x06bd 0x20ff # Agfa Snapscan e50 usb 0x06bd 0x208f # Agfa Snapscan e52 usb 0x06bd 0x20fd # Epson Perfection 660 usb 0x04b8 0x0114 # Epson Perfection 1670 usb 0x04b8 0x011f # Epson Perfection 2480 usb 0x04b8 0x0121 # Epson Perfection 3490 usb 0x04b8 0x0122 # Epson Stylus CX-1500 usb 0x04b8 0x080c sane-backends-1.0.29/testsuite/sanei/data/word-array.conf0000666000000000000000000000010113615534521020170 00000000000000option numbers 1000 1100 1200 1300 1400 1500 1600 attach devname sane-backends-1.0.29/testsuite/sanei/data/empty.conf0000666000000000000000000000001713615534521017245 00000000000000attach devname sane-backends-1.0.29/testsuite/sanei/data/wrong-range.conf0000666000000000000000000000004613615534521020337 00000000000000option modelnumber 234 attach devname sane-backends-1.0.29/testsuite/sanei/data/string.conf0000666000000000000000000000007613615534521017422 00000000000000option modelname "my model" vendor "my vendor" attach devname sane-backends-1.0.29/testsuite/sanei/data/wrong-string-list.conf0000666000000000000000000000014413615534521021521 00000000000000# one choice from string1, string2, string3 and string4 option string-choice "wrong" attach devname sane-backends-1.0.29/testsuite/sanei/data/string-list.conf0000666000000000000000000000014613615534521020371 00000000000000# one choice from string1, string2, string3 and string4 option string-choice "string3" attach devname sane-backends-1.0.29/testsuite/sanei/data/wrong-boolean.conf0000666000000000000000000000012013615534521020653 00000000000000# true boolean value option booltrue true # false boolean value boolfalse buggy sane-backends-1.0.29/testsuite/sanei/data/wrong-fixed.conf0000666000000000000000000000005013615534521020335 00000000000000# value out of range option height 59.7 sane-backends-1.0.29/testsuite/sanei/data/int.conf0000666000000000000000000000004713615534521016704 00000000000000option modelnumber 1234 attach devname sane-backends-1.0.29/testsuite/sanei/data/boolean.conf0000666000000000000000000000020213615534521017522 00000000000000# true boolean value option booltrue true # false boolean value boolfalse false # boolean array option boolarray false true false sane-backends-1.0.29/testsuite/sanei/test_wire.c0000666000000000000000000001255413615534521016511 00000000000000#include "../include/sane/config.h" #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_wire.h" #include "../include/sane/sanei_codec_ascii.h" #include "../include/sane/sanei_codec_bin.h" static Wire w; static SANE_Word dpi_word_list[] = { 4, /* # of elements */ 3, 30, 300, -600 }; static SANE_String_Const mode_list[] = { "Lineart", "Grayscale", "Color", 0 }; static char *program_name; static char *default_codec = "bin"; static char *default_outfile = "test_wire.out"; static int usage (int code) { if (code == 0) { printf ("Usage: %s [OPTION]...\n\ \n\ Test the SANE wire manipulation library.\n\ \n\ --codec=CODEC set the codec [default=%s]\n\ --help display this message and exit\n\ -o, --output=FILE set the output file [default=%s]\n\ --readonly do not create FILE, just read it\n\ --version print version information\n\ \n\ Valid CODECs are: `ascii' `bin'\n", program_name, default_codec, default_outfile); } else { fprintf (stderr, "Type ``%s --help'' for more information.\n", program_name); } exit (code); } int main (int __sane_unused__ arg, char **argv) { SANE_Option_Descriptor desc[2], *desc_ptr; SANE_Word len; char *codec = default_codec; char *outfile = default_outfile; int readonly = 0; program_name = argv[0]; argv++; while (*argv != 0) { if (!strcmp (*argv, "--codec")) { if (argv[1] == 0) { fprintf (stderr, "%s: option `%s' requires an argument\n", program_name, *argv); usage (1); } argv++; codec = *argv; } else if (!strncmp (*argv, "--codec=", 8)) { codec = *argv + 8; } else if (!strcmp (*argv, "--help")) { usage (0); } else if (!strcmp (*argv, "-o") || !strcmp (*argv, "--output")) { if (argv[1] == 0) { fprintf (stderr, "%s: option `%s' requires an argument\n", program_name, *argv); usage (1); } argv++; outfile = *argv; } else if (!strncmp (*argv, "--output=", 9)) { outfile = *argv + 9; } else if (!strcmp (*argv, "--readonly")) { readonly = 1; } else if (!strcmp (*argv, "--version")) { printf ("test_wire (%s) %s\n", PACKAGE, VERSION); exit (0); } else if (**argv == '-') { fprintf (stderr, "%s: unrecognized option `%s'\n", program_name, *argv); usage (1); } else { fprintf (stderr, "%s: too many arguments\n", program_name); } argv++; } if (!strcmp (codec, "bin")) sanei_w_init (&w, sanei_codec_bin_init); else if (!strcmp (codec, "ascii")) sanei_w_init (&w, sanei_codec_ascii_init); else { fprintf (stderr, "%s: unknown codec type `%s'\n", program_name, codec); usage (1); } desc[0].name = "resolution"; desc[0].title = 0; desc[0].desc = "Determines scan resolution in dots/inch (\"DPI\")."; desc[0].type = SANE_TYPE_FIXED; desc[0].unit = SANE_UNIT_DPI; desc[0].size = sizeof (SANE_Word); desc[0].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; desc[0].constraint_type = SANE_CONSTRAINT_WORD_LIST; desc[0].constraint.word_list = dpi_word_list; desc[1].name = "mode"; desc[1].title = "Scan Mode"; desc[1].desc = "Determines scan mode."; desc[1].type = SANE_TYPE_STRING; desc[1].unit = SANE_UNIT_NONE; desc[1].size = 10; desc[1].cap = (SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_AUTOMATIC); desc[1].constraint_type = SANE_CONSTRAINT_STRING_LIST; desc[1].constraint.string_list = mode_list; { int flags; if (readonly) { printf ("reading %s output from %s\n", codec, outfile); flags = O_RDONLY; } else { printf ("creating %s\n", outfile); flags = O_RDWR | O_CREAT | O_TRUNC; } w.io.fd = open (outfile, flags, 0666); if (w.io.fd < 0) { perror (outfile); return -1; } } w.io.read = read; w.io.write = readonly ? 0 : write; if (!readonly) { sanei_w_set_dir (&w, WIRE_ENCODE); w.status = 0; len = NELEMS (desc); desc_ptr = desc; sanei_w_array (&w, &len, (void **) &desc_ptr, (WireCodecFunc) sanei_w_option_descriptor, sizeof (desc[0])); if (w.status == 0) printf ("%s encode successful\n", codec); else fprintf (stderr, "%s: %s encode error %d: %s\n", codec, program_name, w.status, strerror (w.status)); printf ("%s output written to %s\n", codec, outfile); } sanei_w_set_dir (&w, WIRE_DECODE); w.status = 0; if (!readonly) { printf ("reading %s output from %s\n", codec, outfile); lseek (w.io.fd, 0, SEEK_SET); } sanei_w_array (&w, &len, (void **) &desc_ptr, (WireCodecFunc) sanei_w_option_descriptor, sizeof (desc[0])); if (w.status == 0) printf ("%s decode successful\n", codec); else fprintf (stderr, "%s: %s decode error %d: %s\n", program_name, codec, w.status, strerror (w.status)); sanei_w_set_dir (&w, WIRE_FREE); w.status = 0; sanei_w_array (&w, &len, (void **) &desc_ptr, (WireCodecFunc) sanei_w_option_descriptor, sizeof (desc[0])); if (w.status == 0) printf ("free successful\n"); else fprintf (stderr, "%s: free error %d: %s\n", program_name, w.status, strerror (w.status)); close (w.io.fd); return 0; } sane-backends-1.0.29/testsuite/sanei/sanei_constrain_test.c0000666000000000000000000003725713615534521020731 00000000000000#include "../../include/sane/config.h" #include #include #include #include #include #include #include /* sane includes for the sanei functions called */ #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei.h" static SANE_Option_Descriptor none_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_INT, SANE_UNIT_NONE, sizeof (SANE_Word), 0, SANE_CONSTRAINT_NONE, {NULL} }; static SANE_Option_Descriptor none_bool_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), 0, SANE_CONSTRAINT_NONE, {NULL} }; /* range for int constraint */ static const SANE_Range int_range = { 3, /* minimum */ 18, /* maximum */ 3 /* quantization */ }; /* range for sane fixed constraint */ static const SANE_Range fixed_range = { SANE_FIX(1.0), /* minimum */ SANE_FIX(431.8), /* maximum */ SANE_FIX(0.01) /* quantization */ }; static SANE_Option_Descriptor int_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Word), 0, SANE_CONSTRAINT_RANGE, {NULL} }; static SANE_Option_Descriptor fixed_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Word), 0, SANE_CONSTRAINT_RANGE, {NULL} }; #define ARRAY_SIZE 7 static SANE_Option_Descriptor array_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Word) * ARRAY_SIZE, 0, SANE_CONSTRAINT_RANGE, {NULL} }; #define WORD_SIZE 9 static const SANE_Int dpi_list[] = { WORD_SIZE - 1, 100, 200, 300, 400, 500, 600, 700, 800 }; static SANE_Option_Descriptor word_array_opt = { SANE_NAME_SCAN_RESOLUTION, SANE_TITLE_SCAN_RESOLUTION, SANE_DESC_SCAN_RESOLUTION, SANE_TYPE_INT, SANE_UNIT_DPI, sizeof (SANE_Word) * WORD_SIZE, 100, SANE_CONSTRAINT_WORD_LIST, {NULL} }; static const SANE_String_Const string_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_HALFTONE, SANE_VALUE_SCAN_MODE_GRAY, "linelength", 0 }; static SANE_Option_Descriptor string_array_opt = { SANE_NAME_SCAN_MODE, SANE_TITLE_SCAN_MODE, SANE_DESC_SCAN_MODE, SANE_TYPE_STRING, SANE_UNIT_NONE, 8, 0, SANE_CONSTRAINT_STRING_LIST, {NULL} }; /******************************/ /* start of tests definitions */ /******************************/ /* * constrained int */ static void min_int_value (void) { SANE_Int value = int_range.min; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&int_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); assert (value == int_range.min); } static void max_int_value (void) { SANE_Int value = int_range.max; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&int_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); assert (value == int_range.max); } static void below_min_int_value (void) { SANE_Int value = int_range.min - 1; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&int_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == int_range.min); } /* rounded to lower value */ static void quant1_int_value (void) { SANE_Int value = int_range.min + 1; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&int_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == int_range.min); } /* rounded to higher value */ static void quant2_int_value (void) { SANE_Int value = int_range.min + int_range.quant - 1; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&int_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == int_range.min + int_range.quant); } static void in_range_int_value (void) { SANE_Int value = int_range.min + int_range.quant; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&int_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); assert (value == int_range.min + int_range.quant); } static void above_max_int_value (void) { SANE_Int value = int_range.max + 1; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&int_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == int_range.max); } /* * constrained fixed value */ static void min_fixed_value (void) { SANE_Int value = fixed_range.min; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&fixed_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); assert (value == fixed_range.min); } static void max_fixed_value (void) { SANE_Int value = fixed_range.max; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&fixed_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); assert (value == fixed_range.max); } static void below_min_fixed_value (void) { SANE_Int value = fixed_range.min - 1; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&fixed_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == fixed_range.min); } /* rounded to lower value */ static void quant1_fixed_value (void) { SANE_Int value = fixed_range.min + fixed_range.quant/3; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&fixed_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == fixed_range.min); } /* rounded to higher value */ static void quant2_fixed_value (void) { SANE_Int value = fixed_range.min + fixed_range.quant - fixed_range.quant/3; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&fixed_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == fixed_range.min + fixed_range.quant); } static void in_range_fixed_value (void) { SANE_Int value = fixed_range.min + fixed_range.quant; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&fixed_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); assert (value == fixed_range.min + fixed_range.quant); } static void above_max_fixed_value (void) { SANE_Int value = fixed_range.max + 1; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&fixed_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == fixed_range.max); } static void above_max_word (void) { SANE_Word value = 25000; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&word_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == 800); } static void below_max_word (void) { SANE_Word value = 1; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&word_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == 100); } static void closest_200_word (void) { SANE_Word value = 249; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&word_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == 200); } static void closest_300_word (void) { SANE_Word value = 251; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&word_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); assert (value == 300); } static void exact_400_word (void) { SANE_Word value = 400; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&word_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); assert (value == 400); } /* * constrained int array */ static void min_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Word info = 0; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min; } status = sanei_constrain_value (&array_opt, value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.min); } } static void max_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Word info = 0; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.max; } status = sanei_constrain_value (&array_opt, value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.max); } } static void below_min_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Word info = 0; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min - 1; } status = sanei_constrain_value (&array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.min); } } /* rounded to lower value */ static void quant1_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Word info = 0; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min + 1; } status = sanei_constrain_value (&array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.min); } } /* rounded to higher value */ static void quant2_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Word info = 0; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min + int_range.quant - 1; } status = sanei_constrain_value (&array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.min + int_range.quant); } } static void in_range_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Word info = 0; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min + int_range.quant; } status = sanei_constrain_value (&array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.min + int_range.quant); } } static void above_max_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Word info = 0; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.max + 1; } status = sanei_constrain_value (&array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == SANE_INFO_INEXACT); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.max); } } static void wrong_string_array (void) { SANE_Char value[9] = "wrong"; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&string_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_INVAL); assert (info == 0); } static void none_int (void) { SANE_Int value = 555; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&none_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); } static void none_bool_nok (void) { SANE_Bool value = 555; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&none_bool_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_INVAL); assert (info == 0); } static void none_bool_ok (void) { SANE_Bool value = SANE_FALSE; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&none_bool_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); } /** * several partial match */ static void string_array_several (void) { SANE_Char value[9] = "Line"; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&string_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_INVAL); assert (info == 0); } /** * unique partial match */ static void partial_string_array (void) { SANE_Char value[9] = "Linea"; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&string_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); } static void string_array_ignorecase (void) { SANE_Char value[9] = "lineart"; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&string_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); } static void string_array_ok (void) { SANE_Char value[9] = "Lineart"; SANE_Word info = 0; SANE_Status status; status = sanei_constrain_value (&string_array_opt, &value, &info); /* check results */ assert (status == SANE_STATUS_GOOD); assert (info == 0); } /** * run the test suite for sanei constrain related tests */ static void sanei_constrain_suite (void) { /* to be compatible with pre-C99 compilers */ int_opt.constraint.range = &int_range; fixed_opt.constraint.range = &fixed_range; array_opt.constraint.range = &int_range; word_array_opt.constraint.word_list = dpi_list; string_array_opt.constraint.string_list = string_list; /* tests for constrained int value */ min_int_value (); max_int_value (); below_min_int_value (); above_max_int_value (); quant1_int_value (); quant2_int_value (); in_range_int_value (); /* tests for sane fixed constrained value */ min_fixed_value (); max_fixed_value (); below_min_fixed_value (); above_max_fixed_value (); quant1_fixed_value (); quant2_fixed_value (); in_range_fixed_value (); /* tests for constrained int array */ min_int_array (); max_int_array (); below_min_int_array (); above_max_int_array (); quant1_int_array (); quant2_int_array (); in_range_int_array (); /* tests for word lists */ above_max_word (); below_max_word (); closest_200_word (); closest_300_word (); exact_400_word (); /* tests for string lists */ wrong_string_array (); partial_string_array (); string_array_ok (); string_array_ignorecase (); string_array_several (); /* constraint none tests */ none_int (); none_bool_nok (); none_bool_ok (); } /** * main function to run the test suites */ int main (void) { /* run suites */ sanei_constrain_suite (); return 0; } /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ sane-backends-1.0.29/testsuite/sanei/sanei_check_test.c0000666000000000000000000002076713615534521020004 00000000000000#include "../../include/sane/config.h" #include #include #include #include #include #include #include /* sane includes for the sanei functions called */ #include "../../include/sane/sane.h" #include "../../include/sane/saneopts.h" #include "../../include/sane/sanei.h" /* range for constraint */ static const SANE_Range int_range = { 3, /* minimum */ 18, /* maximum */ 3 /* quantization */ }; static SANE_Option_Descriptor int_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Word), 0, SANE_CONSTRAINT_RANGE, {NULL} }; #define ARRAY_SIZE 7 static SANE_Option_Descriptor array_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Word) * ARRAY_SIZE, 0, SANE_CONSTRAINT_RANGE, {NULL} }; static SANE_Option_Descriptor bool_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_BOOL, SANE_UNIT_MM, sizeof (SANE_Bool), 0, SANE_CONSTRAINT_NONE, {NULL} }; static SANE_Option_Descriptor bool_array_opt = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_BOOL, SANE_UNIT_MM, sizeof (SANE_Bool) * ARRAY_SIZE, 0, SANE_CONSTRAINT_NONE, {NULL} }; #define WORD_SIZE 9 static const SANE_Int dpi_list[] = { WORD_SIZE - 1, 100, 200, 300, 400, 500, 600, 700, 800 }; static SANE_Option_Descriptor word_array_opt = { SANE_NAME_SCAN_RESOLUTION, SANE_TITLE_SCAN_RESOLUTION, SANE_DESC_SCAN_RESOLUTION, SANE_TYPE_INT, SANE_UNIT_DPI, sizeof (SANE_Word) * WORD_SIZE, 100, SANE_CONSTRAINT_WORD_LIST, {NULL} }; /******************************/ /* start of tests definitions */ /******************************/ /* * constrained int */ static void min_int_value (void) { SANE_Int value = int_range.min; SANE_Status status; status = sanei_check_value (&int_opt, &value); /* check results */ assert (status == SANE_STATUS_GOOD); assert (value == int_range.min); } static void max_int_value (void) { SANE_Int value = int_range.max; SANE_Status status; status = sanei_check_value (&int_opt, &value); /* check results */ assert (status == SANE_STATUS_GOOD); assert (value == int_range.max); } static void below_min_int_value (void) { SANE_Int value = int_range.min - 1; SANE_Status status; status = sanei_check_value (&int_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } /* rounded to lower value */ static void quant1_int_value (void) { SANE_Int value = int_range.min + 1; SANE_Status status; status = sanei_check_value (&int_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } /* close to higher value */ static void quant2_int_value (void) { SANE_Int value = int_range.min + int_range.quant - 1; SANE_Status status; status = sanei_check_value (&int_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } static void in_range_int_value (void) { SANE_Int value = int_range.min + int_range.quant; SANE_Status status; status = sanei_check_value (&int_opt, &value); /* check results */ assert (status == SANE_STATUS_GOOD); assert (value == int_range.min + int_range.quant); } static void above_max_int_value (void) { SANE_Int value = int_range.max + 1; SANE_Status status; status = sanei_check_value (&int_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } /* * constrained int array */ static void min_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min; } status = sanei_check_value (&array_opt, value); /* check results */ assert (status == SANE_STATUS_GOOD); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.min); } } static void max_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.max; } status = sanei_check_value (&array_opt, value); /* check results */ assert (status == SANE_STATUS_GOOD); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.max); } } static void below_min_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min - 1; } status = sanei_check_value (&array_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } /* rounded to lower value */ static void quant1_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min + 1; } status = sanei_check_value (&array_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } /* rounded to higher value */ static void quant2_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min + int_range.quant - 1; } status = sanei_check_value (&array_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } static void in_range_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.min + int_range.quant; } status = sanei_check_value (&array_opt, &value); /* check results */ assert (status == SANE_STATUS_GOOD); for (i = 0; i < ARRAY_SIZE; i++) { assert (value[i] == int_range.min + int_range.quant); } } static void above_max_int_array (void) { SANE_Int value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) { value[i] = int_range.max + 1; } status = sanei_check_value (&array_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } static void bool_true (void) { SANE_Bool value = SANE_TRUE; SANE_Status status; status = sanei_check_value (&bool_opt, &value); /* check results */ assert (status == SANE_STATUS_GOOD); } static void bool_false (void) { SANE_Bool value = SANE_FALSE; SANE_Status status; status = sanei_check_value (&bool_opt, &value); /* check results */ assert (status == SANE_STATUS_GOOD); } static void wrong_bool (void) { SANE_Bool value = 2; SANE_Status status; status = sanei_check_value (&bool_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } static void bool_array (void) { SANE_Bool value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) value[i] = i % 2; status = sanei_check_value (&bool_array_opt, &value); /* check results */ assert (status == SANE_STATUS_GOOD); } static void word_array_ok (void) { SANE_Word value = 400; SANE_Status status; status = sanei_check_value (&word_array_opt, &value); /* check results */ assert (status == SANE_STATUS_GOOD); } static void word_array_nok (void) { SANE_Word value = 444; SANE_Status status; status = sanei_check_value (&word_array_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } static void wrong_bool_array (void) { SANE_Bool value[ARRAY_SIZE]; SANE_Status status; int i; for (i = 0; i < ARRAY_SIZE; i++) value[i] = i % 2; value[3] = 4; status = sanei_check_value (&bool_array_opt, &value); /* check results */ assert (status == SANE_STATUS_INVAL); } /** * run the test suite for sanei_check_value related tests */ static void sanei_check_suite (void) { /* to be compatible with pre-C99 compilers */ int_opt.constraint.range = &int_range; array_opt.constraint.range = &int_range; word_array_opt.constraint.word_list = dpi_list; /* tests for constrained int value */ min_int_value (); max_int_value (); below_min_int_value (); above_max_int_value (); quant1_int_value (); quant2_int_value (); in_range_int_value (); /* tests for constrained int array */ min_int_array (); max_int_array (); below_min_int_array (); above_max_int_array (); quant1_int_array (); quant2_int_array (); in_range_int_array (); /* tests for boolean value */ bool_true (); bool_false (); wrong_bool (); bool_array (); wrong_bool_array (); /* word array test */ word_array_ok (); word_array_nok (); } int main (void) { sanei_check_suite (); return 0; } /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ sane-backends-1.0.29/testsuite/sanei/sanei_config_test.c0000666000000000000000000005460013615534521020165 00000000000000#include "../../include/sane/config.h" #include #include #include #include #include #include #include /* sane includes for the sanei functions called */ #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_config.h" #define XSTR(s) STR(s) #define STR(s) #s #define CONFIG_PATH XSTR(TESTSUITE_SANEI_SRCDIR) /* * variables and functions used by the tests below */ /* range for constraint */ static const SANE_Range model_range = { 1000, /* minimum */ 2000, /* maximum */ 2 /* quantization */ }; /* range for memory buffer size constraint */ static const SANE_Range buffer_range = { 1024, /* minimum bytes */ 2048 * 1024, /* maximum bytes */ 1024 /* quantization */ }; /* range for int value in [0-15] */ static const SANE_Range value16_range = { 0, /* minimum */ 15, /* maximum */ 1 /* quantization */ }; /* range for fixed height value */ static const SANE_Range height_range = { SANE_FIX (0), /* minimum */ SANE_FIX (29.7), /* maximum */ 0 /* no quantization : hard to do for float values ... */ }; /* list of astra models */ static const SANE_String_Const astra_models[] = { "610", "1220", "1600", "2000", NULL }; /* string list */ static const SANE_String_Const string_list[] = { "string1", "string2", "string3", "string4", NULL }; /* last device name used for attach callback */ static char *lastdevname = NULL; static SANE_Status check_config_attach (SANEI_Config * config, const char *devname) { /* silence compiler warning for now */ if (config == NULL) { return SANE_STATUS_INVAL; } fprintf (stdout, "attaching with devname '%s'\n", devname); if (lastdevname != NULL) { free (lastdevname); } lastdevname = strdup (devname); return SANE_STATUS_GOOD; } /******************************/ /* start of tests definitions */ /******************************/ /* * non-existent config file */ static void inexistent_config (void) { SANE_Status status; SANEI_Config config; config.count = 0; config.descriptors = NULL; config.values = NULL; status = sanei_configure_attach (CONFIG_PATH "/data/inexistent.conf", &config, NULL); /* check results */ assert (status != SANE_STATUS_GOOD); } /* * no config struct */ static void null_config (void) { SANE_Status status; status = sanei_configure_attach (CONFIG_PATH "/data/umax_pp.conf", NULL, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); } /* * no attach function */ static void null_attach (void) { SANE_Status status; status = sanei_configure_attach (CONFIG_PATH "/data/umax_pp.conf", NULL, NULL); /* check results */ assert (status == SANE_STATUS_GOOD); } /* * empty config : backend has no configuration option */ static void empty_config (void) { SANE_Status status; SANEI_Config config; config.count = 0; config.descriptors = NULL; config.values = NULL; status = sanei_configure_attach (CONFIG_PATH "/data/empty.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); } /* * string option */ static void string_option (void) { SANE_Status status; SANEI_Config config; SANE_Char modelname[128]; SANE_Char vendor[128]; SANE_Option_Descriptor *options[2]; void *values[2]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "modelname"; options[i]->title = "model name"; options[i]->desc = "user provided scanner's model name"; options[i]->type = SANE_TYPE_STRING; options[i]->unit = SANE_UNIT_NONE; options[i]->size = 128; options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = modelname; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "vendor"; options[i]->title = "vendor name"; options[i]->desc = "user provided scanner's vendor name"; options[i]->type = SANE_TYPE_STRING; options[i]->unit = SANE_UNIT_NONE; options[i]->size = 128; options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = vendor; i++; config.count = i; config.descriptors = options; config.values = values; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/string.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); assert (strcmp (modelname, "my model") == 0); assert (strcmp (vendor, "my vendor") == 0); } /* * int option */ static void int_option (void) { SANE_Status status; SANEI_Config config; SANE_Word modelnumber; SANE_Option_Descriptor *options[1]; void *values[1]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "modelnumber"; options[i]->title = "model number"; options[i]->desc = "user provided scanner's model number"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &model_range; values[i] = &modelnumber; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/int.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); assert (modelnumber == 1234); } /* * int option out of range */ static void wrong_range_int_option (void) { SANE_Status status; SANEI_Config config; SANE_Word modelnumber = -1; SANE_Option_Descriptor *options[1]; void *values[1]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "modelnumber"; options[i]->title = "model number"; options[i]->desc = "user provided scanner's model number"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &model_range; values[i] = &modelnumber; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/wrong-range.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_INVAL); assert (modelnumber == -1); } /* * word array */ static void word_array_option (void) { SANE_Status status; SANEI_Config config; SANE_Word numbers[7]; SANE_Option_Descriptor *options[1]; void *values[1]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "numbers"; options[i]->title = "some numbers"; options[i]->desc = "an array of numbers"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word) * 7; options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &model_range; values[i] = numbers; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/word-array.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); for (i = 0; i < 7; i++) { assert (numbers[i] == 1000 + 100 * i); } } /* * string option with string list constraint */ static void string_list_option (void) { SANE_Status status; SANEI_Config config; SANE_Char choice[128]; SANE_Option_Descriptor *options[1]; void *values[1]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "string-choice"; options[i]->title = "string choice"; options[i]->desc = "one string among a fixed list"; options[i]->type = SANE_TYPE_STRING; options[i]->unit = SANE_UNIT_NONE; options[i]->size = 128; options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_STRING_LIST; options[i]->constraint.string_list = string_list; values[i] = choice; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/string-list.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); assert (strcmp (choice, "string3") == 0); } /* * string option with string list constraint */ static void wrong_string_list_option (void) { SANE_Status status; SANEI_Config config; SANE_Char choice[128]; SANE_Option_Descriptor *options[1]; void *values[1]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "string-choice"; options[i]->title = "string choice"; options[i]->desc = "one string among a fixed list"; options[i]->type = SANE_TYPE_STRING; options[i]->unit = SANE_UNIT_NONE; options[i]->size = 128; options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_STRING_LIST; options[i]->constraint.string_list = string_list; values[i] = choice; i++; config.descriptors = options; config.values = values; config.count = i; choice[0] = 0; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/wrong-string-list.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_INVAL); assert (strcmp (choice, "") == 0); } /* * real umax_pp confiugration file parsing */ static void umax_pp (void) { SANE_Status status; SANEI_Config config; SANE_Option_Descriptor *options[9]; void *values[9]; int i = 0; /* placeholders for options */ SANE_Word buffersize = -1; SANE_Word redgain = -1; SANE_Word greengain = -1; SANE_Word bluegain = -1; SANE_Word redoffset = -1; SANE_Word greenoffset = -1; SANE_Word blueoffset = -1; SANE_Char model[128]; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "buffer"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &buffer_range; values[i] = &buffersize; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "red-gain"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &value16_range; values[i] = &redgain; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "green-gain"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &value16_range; values[i] = &greengain; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "blue-gain"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &value16_range; values[i] = &bluegain; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "red-offset"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &value16_range; values[i] = &redoffset; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "green-offset"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &value16_range; values[i] = &greenoffset; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "blue-offset"; options[i]->type = SANE_TYPE_INT; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &value16_range; values[i] = &blueoffset; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "astra"; options[i]->type = SANE_TYPE_STRING; options[i]->unit = SANE_UNIT_NONE; options[i]->size = 128; options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_STRING_LIST; options[i]->constraint.string_list = astra_models; values[i] = &model; i++; config.descriptors = options; config.values = values; config.count = i; model[0] = 0; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/umax_pp.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); assert (buffersize == 1048576); assert (redgain == 1); assert (greengain == 2); assert (bluegain == 3); assert (redoffset == 4); assert (greenoffset == 5); assert (blueoffset == 6); assert (strcmp (model, "1600") == 0); assert (strcmp (lastdevname, "port safe-auto") == 0); /* free memory */ while (i > 0) { i--; free (options[i]); } } /* * boolean option */ static void wrong_bool_option (void) { SANE_Status status; SANEI_Config config; SANE_Option_Descriptor *options[2]; void *values[2]; SANE_Bool booltrue, boolfalse; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "booltrue"; options[i]->title = "boolean true"; options[i]->type = SANE_TYPE_BOOL; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Bool); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = &booltrue; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "boolfalse"; options[i]->title = "boolean false"; options[i]->type = SANE_TYPE_BOOL; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Bool); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = &boolfalse; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/wrong-boolean.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_INVAL); assert (booltrue == SANE_TRUE); } /* * boolean option */ static void bool_option (void) { SANE_Status status; SANEI_Config config; SANE_Option_Descriptor *options[3]; void *values[3]; SANE_Bool booltrue, boolfalse, boolarray[3]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "booltrue"; options[i]->title = "boolean true"; options[i]->type = SANE_TYPE_BOOL; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Bool); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = &booltrue; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "boolfalse"; options[i]->title = "boolean false"; options[i]->type = SANE_TYPE_BOOL; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Bool); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = &boolfalse; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "boolarray"; options[i]->title = "boolean array"; options[i]->type = SANE_TYPE_BOOL; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (boolarray); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = boolarray; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/boolean.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); assert (booltrue == SANE_TRUE); assert (boolfalse == SANE_FALSE); for (i = 0; i < 3; i++) { assert (boolarray[i] == (SANE_Bool) i % 2); } } /* * fixed option */ static void fixed_option (void) { SANE_Status status; SANEI_Config config; SANE_Word width, height, fixedarray[7]; SANE_Option_Descriptor *options[3]; void *values[3]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "width"; options[i]->title = "width"; options[i]->type = SANE_TYPE_FIXED; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = &width; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "height"; options[i]->title = "height"; options[i]->type = SANE_TYPE_FIXED; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = &height; i++; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "array-of-fixed"; options[i]->title = "array of fixed"; options[i]->type = SANE_TYPE_FIXED; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (fixedarray); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &height_range; values[i] = fixedarray; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/fixed.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); assert (width == SANE_FIX (21.0)); assert (height == SANE_FIX (29.7)); for (i = 0; i < 7; i++) { assert (fixedarray[i] == SANE_FIX (2.0 + 0.1 * ((float) i))); } } /* * fixed option with value out of range */ static void wrong_fixed_option (void) { SANE_Status status; SANEI_Config config; SANE_Word height; SANE_Option_Descriptor *options[1]; void *values[1]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "height"; options[i]->title = "height"; options[i]->type = SANE_TYPE_FIXED; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (SANE_Word); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_RANGE; options[i]->constraint.range = &height_range; values[i] = &height; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/wrong-fixed.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_INVAL); } static void snapscan (void) { SANE_Status status; SANEI_Config config; SANE_Char firmware[128]; SANE_Option_Descriptor *options[1]; void *values[1]; int i; i = 0; options[i] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[i]->name = "firmware"; options[i]->title = "scanner's firmware path"; options[i]->desc = "user provided scanner's full path"; options[i]->type = SANE_TYPE_STRING; options[i]->unit = SANE_UNIT_NONE; options[i]->size = sizeof (firmware); options[i]->cap = SANE_CAP_SOFT_SELECT; options[i]->constraint_type = SANE_CONSTRAINT_NONE; values[i] = firmware; i++; config.descriptors = options; config.values = values; config.count = i; /* configure and attach */ status = sanei_configure_attach (CONFIG_PATH "/data/snapscan.conf", &config, check_config_attach); /* check results */ assert (status == SANE_STATUS_GOOD); assert (strcmp (firmware, "/usr/share/sane/snapscan/your-firmwarefile.bin") == 0); /* TODO must test attach() done */ } /** * create the test suite for sanei config related tests */ static void sanei_config_suite (void) { /* tests */ inexistent_config (); empty_config (); null_config (); null_attach (); string_option (); int_option (); string_list_option (); word_array_option (); bool_option (); fixed_option (); wrong_range_int_option (); wrong_string_list_option (); wrong_bool_option (); wrong_fixed_option (); /* backend real conf inspired cases */ umax_pp (); snapscan (); } /** * main function to run the test suites */ int main (void) { /* set up config dir for local conf files */ putenv("SANE_CONFIG_DIR=.:/"); /* run suites */ sanei_config_suite (); return 0; } /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ sane-backends-1.0.29/testsuite/sanei/Makefile.in0000644000000000000000000012307613615534557016414 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ check_PROGRAMS = sanei_usb_test$(EXEEXT) test_wire$(EXEEXT) \ sanei_check_test$(EXEEXT) sanei_config_test$(EXEEXT) \ sanei_constrain_test$(EXEEXT) subdir = testsuite/sanei ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_sanei_check_test_OBJECTS = sanei_check_test.$(OBJEXT) sanei_check_test_OBJECTS = $(am_sanei_check_test_OBJECTS) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = ../../sanei/libsanei.la ../../lib/liblib.la \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) sanei_check_test_DEPENDENCIES = $(am__DEPENDENCIES_2) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_sanei_config_test_OBJECTS = \ sanei_config_test-sanei_config_test.$(OBJEXT) sanei_config_test_OBJECTS = $(am_sanei_config_test_OBJECTS) sanei_config_test_DEPENDENCIES = $(am__DEPENDENCIES_2) am_sanei_constrain_test_OBJECTS = sanei_constrain_test.$(OBJEXT) sanei_constrain_test_OBJECTS = $(am_sanei_constrain_test_OBJECTS) sanei_constrain_test_DEPENDENCIES = $(am__DEPENDENCIES_2) am_sanei_usb_test_OBJECTS = sanei_usb_test.$(OBJEXT) sanei_usb_test_OBJECTS = $(am_sanei_usb_test_OBJECTS) sanei_usb_test_DEPENDENCIES = $(am__DEPENDENCIES_2) am_test_wire_OBJECTS = test_wire.$(OBJEXT) test_wire_OBJECTS = $(am_test_wire_OBJECTS) test_wire_DEPENDENCIES = $(am__DEPENDENCIES_2) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/sane depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/sanei_check_test.Po \ ./$(DEPDIR)/sanei_config_test-sanei_config_test.Po \ ./$(DEPDIR)/sanei_constrain_test.Po \ ./$(DEPDIR)/sanei_usb_test.Po ./$(DEPDIR)/test_wire.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(sanei_check_test_SOURCES) $(sanei_config_test_SOURCES) \ $(sanei_constrain_test_SOURCES) $(sanei_usb_test_SOURCES) \ $(test_wire_SOURCES) DIST_SOURCES = $(sanei_check_test_SOURCES) \ $(sanei_config_test_SOURCES) $(sanei_constrain_test_SOURCES) \ $(sanei_usb_test_SOURCES) $(test_wire_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/test-driver README 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) $(XML_CFLAGS) AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = data/boolean.conf data/empty.conf data/fixed.conf data/int.conf \ data/snapscan.conf data/string.conf data/string-list.conf \ data/umax_pp.conf data/word-array.conf data/wrong-boolean.conf \ data/wrong-fixed.conf data/wrong-range.conf \ data/wrong-string-list.conf TEST_LDADD = ../../sanei/libsanei.la ../../lib/liblib.la \ $(MATH_LIB) $(USB_LIBS) $(XML_LIBS) $(PTHREAD_LIBS) TESTS = $(check_PROGRAMS) sanei_constrain_test_SOURCES = sanei_constrain_test.c sanei_constrain_test_LDADD = $(TEST_LDADD) sanei_config_test_SOURCES = sanei_config_test.c sanei_config_test_CPPFLAGS = $(AM_CPPFLAGS) -DTESTSUITE_SANEI_SRCDIR=$(srcdir) sanei_config_test_LDADD = $(TEST_LDADD) sanei_check_test_SOURCES = sanei_check_test.c sanei_check_test_LDADD = $(TEST_LDADD) sanei_usb_test_SOURCES = sanei_usb_test.c sanei_usb_test_LDADD = $(TEST_LDADD) test_wire_SOURCES = test_wire.c test_wire_LDADD = $(TEST_LDADD) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu testsuite/sanei/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu testsuite/sanei/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list sanei_check_test$(EXEEXT): $(sanei_check_test_OBJECTS) $(sanei_check_test_DEPENDENCIES) $(EXTRA_sanei_check_test_DEPENDENCIES) @rm -f sanei_check_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sanei_check_test_OBJECTS) $(sanei_check_test_LDADD) $(LIBS) sanei_config_test$(EXEEXT): $(sanei_config_test_OBJECTS) $(sanei_config_test_DEPENDENCIES) $(EXTRA_sanei_config_test_DEPENDENCIES) @rm -f sanei_config_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sanei_config_test_OBJECTS) $(sanei_config_test_LDADD) $(LIBS) sanei_constrain_test$(EXEEXT): $(sanei_constrain_test_OBJECTS) $(sanei_constrain_test_DEPENDENCIES) $(EXTRA_sanei_constrain_test_DEPENDENCIES) @rm -f sanei_constrain_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sanei_constrain_test_OBJECTS) $(sanei_constrain_test_LDADD) $(LIBS) sanei_usb_test$(EXEEXT): $(sanei_usb_test_OBJECTS) $(sanei_usb_test_DEPENDENCIES) $(EXTRA_sanei_usb_test_DEPENDENCIES) @rm -f sanei_usb_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(sanei_usb_test_OBJECTS) $(sanei_usb_test_LDADD) $(LIBS) test_wire$(EXEEXT): $(test_wire_OBJECTS) $(test_wire_DEPENDENCIES) $(EXTRA_test_wire_DEPENDENCIES) @rm -f test_wire$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_wire_OBJECTS) $(test_wire_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_check_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_config_test-sanei_config_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_constrain_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanei_usb_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_wire.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @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)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)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 $@ $< sanei_config_test-sanei_config_test.o: sanei_config_test.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sanei_config_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sanei_config_test-sanei_config_test.o -MD -MP -MF $(DEPDIR)/sanei_config_test-sanei_config_test.Tpo -c -o sanei_config_test-sanei_config_test.o `test -f 'sanei_config_test.c' || echo '$(srcdir)/'`sanei_config_test.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sanei_config_test-sanei_config_test.Tpo $(DEPDIR)/sanei_config_test-sanei_config_test.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sanei_config_test.c' object='sanei_config_test-sanei_config_test.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sanei_config_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sanei_config_test-sanei_config_test.o `test -f 'sanei_config_test.c' || echo '$(srcdir)/'`sanei_config_test.c sanei_config_test-sanei_config_test.obj: sanei_config_test.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sanei_config_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sanei_config_test-sanei_config_test.obj -MD -MP -MF $(DEPDIR)/sanei_config_test-sanei_config_test.Tpo -c -o sanei_config_test-sanei_config_test.obj `if test -f 'sanei_config_test.c'; then $(CYGPATH_W) 'sanei_config_test.c'; else $(CYGPATH_W) '$(srcdir)/sanei_config_test.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sanei_config_test-sanei_config_test.Tpo $(DEPDIR)/sanei_config_test-sanei_config_test.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='sanei_config_test.c' object='sanei_config_test-sanei_config_test.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sanei_config_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sanei_config_test-sanei_config_test.obj `if test -f 'sanei_config_test.c'; then $(CYGPATH_W) 'sanei_config_test.c'; else $(CYGPATH_W) '$(srcdir)/sanei_config_test.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: $(check_PROGRAMS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? sanei_usb_test.log: sanei_usb_test$(EXEEXT) @p='sanei_usb_test$(EXEEXT)'; \ b='sanei_usb_test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test_wire.log: test_wire$(EXEEXT) @p='test_wire$(EXEEXT)'; \ b='test_wire'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) sanei_check_test.log: sanei_check_test$(EXEEXT) @p='sanei_check_test$(EXEEXT)'; \ b='sanei_check_test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) sanei_config_test.log: sanei_config_test$(EXEEXT) @p='sanei_config_test$(EXEEXT)'; \ b='sanei_config_test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) sanei_constrain_test.log: sanei_constrain_test$(EXEEXT) @p='sanei_constrain_test$(EXEEXT)'; \ b='sanei_constrain_test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool clean-local \ mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/sanei_check_test.Po -rm -f ./$(DEPDIR)/sanei_config_test-sanei_config_test.Po -rm -f ./$(DEPDIR)/sanei_constrain_test.Po -rm -f ./$(DEPDIR)/sanei_usb_test.Po -rm -f ./$(DEPDIR)/test_wire.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/sanei_check_test.Po -rm -f ./$(DEPDIR)/sanei_config_test-sanei_config_test.Po -rm -f ./$(DEPDIR)/sanei_constrain_test.Po -rm -f ./$(DEPDIR)/sanei_usb_test.Po -rm -f ./$(DEPDIR)/test_wire.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ check-am clean clean-checkPROGRAMS clean-generic clean-libtool \ clean-local cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am recheck tags tags-am uninstall \ uninstall-am .PRECIOUS: Makefile clean-local: rm -f test_wire.out all: @echo "run 'make check' to run tests" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/testsuite/sanei/README0000666000000000000000000000177713615534521015225 00000000000000SANEI test suite ================ This directory contains test programs for sanei functions. They are compiled and run by 'make check'. sanei_usb_test --------------- Tests sanei_usb_* functions. No USB scanner needs to be plugged, but in this case less code is covered (open/close and claim/release of real devices). Function currently tested are: - sanei_usb_init() - sanei_usb_open(): valid, invalid devname, already opened - sanei_usb_get_vendor_product_byname(): valid and invalid devname - sanei_usb_get_vendor_product(): valid and invalid devname - sanei_usb_close() - sanei_usb_exit() - store_device() sanei_constrain_test -------------------- Tests for sanei_constrain_* functions Function currently tested are: - sanei_constrain_value() sanei_check_test ---------------- Tests for sanei_check_* functions Function currently tested are: - sanei_check_value() sanei_config_test ----------------- Tests for sanei_configure_* functions Function currently tested are: - sanei_configure_attach() sane-backends-1.0.29/testsuite/README0000666000000000000000000000112313615534521014107 00000000000000SANE test suite =============== Petter Reinholdtsen This is a test framework for the Scanner Access Now Easy project (SANE). Please add more tests. This framework should be able to test everything without installing, to make sure a new distribution is function properly before the old one is replaced. If it isn't, please fix the bug. :-) The current tests use the test backend to scan in flatbed, hand scanner and three pass mode. Also a 16 bit color image is created and compared to the "right" one. This test should detect any little/big endian issues in scanimage. sane-backends-1.0.29/README.openbsd0000666000000000000000000000476113615534521013522 00000000000000SANE and OpenBSD ---------------- Building: --------- Don't forget to use GNU make (gmake). E.g. "MAKE=gmake ./configure". SANE should compile and install out-of-the-box. If some libraries and headers (like libjpeg) are installed in /usr/local/, adding "-I/usr/local/include/ -L/usr/local/lib/" to the CPPFLAGS environment variable before running configure may be necessary to get them detected. Since release 3.9, SANE is available from OpenBSD ports. SCSI-scanners: -------------- SANE only supports the generic /dev/uk? devices. /dev/ss? won't work. If your scanner is detected by the ss driver, disable the driver with the "config" utility or compile a new kernel without ss. Set a link /dev/scanner to /dev/uk0 (or whatever you use) and/or edit your backend's config file appropriately. Don't forget to set up permissions to the device file correctly for access by a non-root user (read/write). USB-scanners: ------------- USB-Scanners are supported in principle since OpenBSD 2.9. The USB scanner driver "uscanner" and access over libusb is supported. To get your scanner detected by the uscanner driver, it may be necessary to add its vendor and device ids to the kernel and recompile (sys/devs/usb/uscanner.c). With OpenBSD 3.0 there is also a bug concerning uscanner that prevents accessing the /dev/uscanner devices. Get a newer kernel in this case. If your MAKEDEV won't make /dev/uscanner0 do it manually: "mknod /dev/uscanner0 c 77 0" for the first scanner. Edit your backend's configuration file appropriately. If you want to use libusb, your scanner should *not* be claimed by the uscanner driver. Also make sure that the ugen driver is NOT compiled with DIAGNOSTIC. If it is, you will get errors like "ugenioctl: USB_SET_TIMEOUT, no pipe". Make sure, that /dev/ugen* and /dev/usb* devices are available. Use /dev/MAKEDEV to create them, if necessary. For some backends you must use libusb. The uscanner driver won't work because automatic detection, control messages, or interrupt endpoints are needed. When using libusb, you need read/write permissions to ugen(4) (/dev/ugen*.*) and the usb(4) controller (/dev/usb*) your scanner is connected to. Consider adding a group usb and setting the device permissions using the hotplugd(8) attach and detach scripts. See tools/openbsd for an example. Parport-scanners: ----------------- I don't have any information about these. Please contact me or the SANE mailing list if you succeeded in using one of these. 2005-12-23 Henning Meier-Geinitz sane-backends-1.0.29/README.windows0000666000000000000000000000346413615534521013561 00000000000000SANE on Windows Prerequisites ============= To be able to compile sane-backends, you need to have either Cygwin or Mingw compilers and a suitable POSIX compatible environment. You can get the Cygwin POSIX compatible environment for Windows Windows and the Cygwin gcc compiler at http://www.cygwin.com You can get the MSYS POSIX compatible environment for Windows and the MinGW gcc compiler at http://www.mingw.org/wiki/MSYS The scanner must be detected by Windows and not be disabled. Check with the hardware manager. Building ======== See general README for build basics. If a given backend fails to compile, you can use the BACKENDS variable to limit compilation to backends your interested in: ./configure BACKENDS=epson2 Configuring =========== If you have more than one scanner, you should do the following: - run sane-find-scanner to get the device name of the scanner. The name for scsi devices is something like h0b0t6l0, meaning hba 0, bus 0, scsi id 6 and lun 0. - edit the config file for the backend (/path/to/sane/etc/sane.d/xxxx.conf) and add the scanner device name on an empty line. - Set environment variable SANE_CONFIG_DIR to point to the directory where the config files are located. Run "scanimage > out.pnm" to get a scan. xscanimage ans XSane have been reported to compile and run in the past under Cygwin. Notes ===== - Only SCSI, USB (with libusb-win32), and network scanners may work. No FireWire/Parallel. The Cygwin libusb port can be installed with Cygwin setup.exe or can be compiled manually under cygwin or mingw using the libusb-win32 port: http://sourceforge.net/apps/trac/libusb-win32/wiki - Tested on Windows XP, 7, and using Wine on Linux. - Some scanners' backend may not work because of requirement not supported by Cygwin or MinGW. 2011/10/08 sane-backends-1.0.29/lib/0000755000000000000000000000000013615535551012027 500000000000000sane-backends-1.0.29/lib/inet_ntop.c0000666000000000000000000000126613615534521014117 00000000000000#include "../include/sane/config.h" #ifndef HAVE_INET_NTOP #include #include #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #include #include #endif const char * inet_ntop (int af, const void *src, char *dst, size_t cnt) { struct in_addr in; char *text_addr; #ifdef HAVE_INET_NTOA if (af == AF_INET) { memcpy (&in.s_addr, src, sizeof (in.s_addr)); text_addr = inet_ntoa (in); if (text_addr && dst) { strncpy (dst, text_addr, cnt); return dst; } else return 0; } #endif /* HAVE_INET_NTOA */ return 0; } #endif /* !HAVE_INET_NTOP */ sane-backends-1.0.29/lib/sleep.c0000666000000000000000000000117713615534521013231 00000000000000#include "../include/sane/config.h" #ifndef HAVE_SLEEP #ifdef HAVE_WINDOWS_H #include #endif unsigned int sleep(unsigned int seconds) { #ifdef HAVE_WINDOWS_H Sleep(seconds*1000); return 0; #else int rc = 0; /* WARNING: Not all platforms support usleep() for more than 1 * second. Assuming if they do not have POSIX sleep then they * do not have POSIX usleep() either and are using our internal * version which can support it. If it fails, need to add an OS * specific replacement like Sleep for Windows. */ if (usleep(seconds*1000000)) rc = 1; return rc; #endif } #endif sane-backends-1.0.29/lib/strdup.c0000666000000000000000000000214713615534521013440 00000000000000/* Copyright (C) 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "../include/sane/config.h" #include #include #ifndef HAVE_STRDUP char * strdup (const char * s) { char *clone; size_t size; size = strlen (s) + 1; clone = malloc (size); memcpy (clone, s, size); return clone; } #endif /* !HAVE_STRDUP */ sane-backends-1.0.29/lib/Makefile.am0000666000000000000000000000071113615534521014002 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2009 Chris Bagwell and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. AM_CPPFLAGS += -I. -I$(top_builddir)/include -I$(top_srcdir)/include noinst_LTLIBRARIES = liblib.la liblib_la_SOURCES = md5.c liblib_la_CPPFLAGS = -I$(top_srcdir)/include liblib_la_LIBADD = $(LTALLOCA) $(LTLIBOBJS) sane-backends-1.0.29/lib/strcasestr.c0000666000000000000000000000566113615534521014320 00000000000000/* Return the offset of one string within another. Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * My personal strstr() implementation that beats most other algorithms. * Until someone tells me otherwise, I assume that this is the * fastest implementation of strstr() in C. * I deliberately chose not to comment it. You should have at least * as much fun trying to understand it, as I had to write it :-). * * Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */ /* added strcasestr support, davidm@lineo.com */ #include "../include/sane/config.h" #ifndef HAVE_STRCASESTR #if defined HAVE_STRING_H # include #endif typedef unsigned chartype; #include #define VAL(x) tolower(x) char * strcasestr ( const char *phaystack, const char *pneedle) { register const unsigned char *haystack, *needle; register chartype b, c; haystack = (const unsigned char *) phaystack; needle = (const unsigned char *) pneedle; b = *needle; if (b != '\0') { haystack--; /* possible ANSI violation */ do { c = *++haystack; if (c == '\0') goto ret0; } while (VAL(c) != VAL(b)); c = *++needle; if (c == '\0') goto foundneedle; ++needle; goto jin; for (;;) { register chartype a; register const unsigned char *rhaystack, *rneedle; do { a = *++haystack; if (a == '\0') goto ret0; if (VAL(a) == VAL(b)) break; a = *++haystack; if (a == '\0') goto ret0; shloop:;} while (VAL(a) != VAL(b)); jin:a = *++haystack; if (a == '\0') goto ret0; if (VAL(a) != VAL(c)) goto shloop; rhaystack = haystack-- + 1; rneedle = needle; a = *rneedle; if (VAL(*rhaystack) == VAL(a)) do { if (a == '\0') goto foundneedle; ++rhaystack; a = *++needle; if (VAL(*rhaystack) != VAL(a)) break; if (a == '\0') goto foundneedle; ++rhaystack; a = *++needle; } while (VAL(*rhaystack) == VAL(a)); needle = rneedle; /* took the register-poor approach */ if (a == '\0') break; } } foundneedle: return (char *) haystack; ret0: return 0; } #endif sane-backends-1.0.29/lib/alloca.c0000666000000000000000000003345313615534521013356 00000000000000/* alloca.c -- allocate automatically reclaimed memory (Mostly) portable public-domain implementation -- D A Gwyn This implementation of the PWB library alloca function, which is used to allocate space off the run-time stack so that it is automatically reclaimed upon procedure exit, was inspired by discussions with J. Q. Johnson of Cornell. J.Otto Tennant contributed the Cray support. There are some preprocessor constants that can be defined when compiling for your specific system, for improved efficiency; however, the defaults should be okay. The general concept of this implementation is to keep track of all alloca-allocated blocks, and reclaim any that are found to be deeper in the stack than the current invocation. This heuristic does not reclaim storage as soon as it becomes invalid, but it will do so eventually. As a special case, alloca(0) reclaims storage without allocating any. It is a good idea to use alloca(0) in your main control loop, etc. to force garbage collection. */ #ifdef HAVE_CONFIG_H #include "../include/sane/config.h" #endif #ifndef HAVE_ALLOCA #include "lalloca.h" #ifdef emacs #include "blockinput.h" #endif /* If compiling with GCC 2, this file's not needed. */ #if !defined (__GNUC__) || __GNUC__ < 2 /* If someone has defined alloca as a macro, there must be some other way alloca is supposed to work. */ #ifndef alloca #ifdef emacs #ifdef static /* actually, only want this if static is defined as "" -- this is for usg, in which emacs must undefine static in order to make unexec workable */ #ifndef STACK_DIRECTION you lose -- must know STACK_DIRECTION at compile-time #endif /* STACK_DIRECTION undefined */ #endif /* static */ #endif /* emacs */ /* If your stack is a linked list of frames, you have to provide an "address metric" ADDRESS_FUNCTION macro. */ #if defined (CRAY) && defined (CRAY_STACKSEG_END) long i00afunc (); #define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) #else #define ADDRESS_FUNCTION(arg) &(arg) #endif #if __STDC__ typedef void *pointer; #else typedef char *pointer; #endif #define NULL 0 /* Different portions of Emacs need to call different versions of malloc. The Emacs executable needs alloca to call xmalloc, because ordinary malloc isn't protected from input signals. On the other hand, the utilities in lib-src need alloca to call malloc; some of them are very simple, and don't have an xmalloc routine. Non-Emacs programs expect this to call xmalloc. Callers below should use malloc. */ extern pointer malloc (); /* Define STACK_DIRECTION if you know the direction of stack growth for your system; otherwise it will be automatically deduced at run-time. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #ifndef STACK_DIRECTION #define STACK_DIRECTION 0 /* Direction unknown. */ #endif #if STACK_DIRECTION != 0 #define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ #else /* STACK_DIRECTION == 0; need run-time code. */ static int stack_dir; /* 1 or -1 once known. */ #define STACK_DIR stack_dir static void find_stack_direction () { static char *addr = NULL; /* Address of first `dummy', once known. */ auto char dummy; /* To get stack address. */ if (addr == NULL) { /* Initial entry. */ addr = ADDRESS_FUNCTION (dummy); find_stack_direction (); /* Recurse once. */ } else { /* Second entry. */ if (ADDRESS_FUNCTION (dummy) > addr) stack_dir = 1; /* Stack grew upward. */ else stack_dir = -1; /* Stack grew downward. */ } } #endif /* STACK_DIRECTION == 0 */ /* An "alloca header" is used to: (a) chain together all alloca'ed blocks; (b) keep track of stack depth. It is very important that sizeof(header) agree with malloc alignment chunk size. The following default should work okay. */ #ifndef ALIGN_SIZE #define ALIGN_SIZE sizeof(double) #endif typedef union hdr { char align[ALIGN_SIZE]; /* To force sizeof(header). */ struct { union hdr *next; /* For chaining headers. */ char *deep; /* For stack depth measure. */ } h; } header; static header *last_alloca_header = NULL; /* -> last alloca header. */ /* Return a pointer to at least SIZE bytes of storage, which will be automatically reclaimed upon exit from the procedure that called alloca. Originally, this space was supposed to be taken from the current stack frame of the caller, but that method cannot be made to work for some implementations of C, for example under Gould's UTX/32. */ pointer alloca (size) unsigned size; { auto char probe; /* Probes stack depth: */ register char *depth = ADDRESS_FUNCTION (probe); #if STACK_DIRECTION == 0 if (STACK_DIR == 0) /* Unknown growth direction. */ find_stack_direction (); #endif /* Reclaim garbage, defined as all alloca'd storage that was allocated from deeper in the stack than currently. */ { register header *hp; /* Traverses linked list. */ #ifdef emacs BLOCK_INPUT; #endif for (hp = last_alloca_header; hp != NULL;) if ((STACK_DIR > 0 && hp->h.deep > depth) || (STACK_DIR < 0 && hp->h.deep < depth)) { register header *np = hp->h.next; free ((pointer) hp); /* Collect garbage. */ hp = np; /* -> next header. */ } else break; /* Rest are not deeper. */ last_alloca_header = hp; /* -> last valid storage. */ #ifdef emacs UNBLOCK_INPUT; #endif } if (size == 0) return NULL; /* No allocation required. */ /* Allocate combined header + user data storage. */ { register pointer new = malloc (sizeof (header) + size); /* Address of header. */ ((header *) new)->h.next = last_alloca_header; ((header *) new)->h.deep = depth; last_alloca_header = (header *) new; /* User storage begins just after header. */ return (pointer) ((char *) new + sizeof (header)); } } #if defined (CRAY) && defined (CRAY_STACKSEG_END) #ifdef DEBUG_I00AFUNC #include #endif #ifndef CRAY_STACK #define CRAY_STACK #ifndef CRAY2 /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ struct stack_control_header { long shgrow:32; /* Number of times stack has grown. */ long shaseg:32; /* Size of increments to stack. */ long shhwm:32; /* High water mark of stack. */ long shsize:32; /* Current size of stack (all segments). */ }; /* The stack segment linkage control information occurs at the high-address end of a stack segment. (The stack grows from low addresses to high addresses.) The initial part of the stack segment linkage control information is 0200 (octal) words. This provides for register storage for the routine which overflows the stack. */ struct stack_segment_linkage { long ss[0200]; /* 0200 overflow words. */ long sssize:32; /* Number of words in this segment. */ long ssbase:32; /* Offset to stack base. */ long:32; long sspseg:32; /* Offset to linkage control of previous segment of stack. */ long:32; long sstcpt:32; /* Pointer to task common address block. */ long sscsnm; /* Private control structure number for microtasking. */ long ssusr1; /* Reserved for user. */ long ssusr2; /* Reserved for user. */ long sstpid; /* Process ID for pid based multi-tasking. */ long ssgvup; /* Pointer to multitasking thread giveup. */ long sscray[7]; /* Reserved for Cray Research. */ long ssa0; long ssa1; long ssa2; long ssa3; long ssa4; long ssa5; long ssa6; long ssa7; long sss0; long sss1; long sss2; long sss3; long sss4; long sss5; long sss6; long sss7; }; #else /* CRAY2 */ /* The following structure defines the vector of words returned by the STKSTAT library routine. */ struct stk_stat { long now; /* Current total stack size. */ long maxc; /* Amount of contiguous space which would be required to satisfy the maximum stack demand to date. */ long high_water; /* Stack high-water mark. */ long overflows; /* Number of stack overflow ($STKOFEN) calls. */ long hits; /* Number of internal buffer hits. */ long extends; /* Number of block extensions. */ long stko_mallocs; /* Block allocations by $STKOFEN. */ long underflows; /* Number of stack underflow calls ($STKRETN). */ long stko_free; /* Number of deallocations by $STKRETN. */ long stkm_free; /* Number of deallocations by $STKMRET. */ long segments; /* Current number of stack segments. */ long maxs; /* Maximum number of stack segments so far. */ long pad_size; /* Stack pad size. */ long current_address; /* Current stack segment address. */ long current_size; /* Current stack segment size. This number is actually corrupted by STKSTAT to include the fifteen word trailer area. */ long initial_address; /* Address of initial segment. */ long initial_size; /* Size of initial segment. */ }; /* The following structure describes the data structure which trails any stack segment. I think that the description in 'asdef' is out of date. I only describe the parts that I am sure about. */ struct stk_trailer { long this_address; /* Address of this block. */ long this_size; /* Size of this block (does not include this trailer). */ long unknown2; long unknown3; long link; /* Address of trailer block of previous segment. */ long unknown5; long unknown6; long unknown7; long unknown8; long unknown9; long unknown10; long unknown11; long unknown12; long unknown13; long unknown14; }; #endif /* CRAY2 */ #endif /* not CRAY_STACK */ #ifdef CRAY2 /* Determine a "stack measure" for an arbitrary ADDRESS. I doubt that "lint" will like this much. */ static long i00afunc (long *address) { struct stk_stat status; struct stk_trailer *trailer; long *block, size; long result = 0; /* We want to iterate through all of the segments. The first step is to get the stack status structure. We could do this more quickly and more directly, perhaps, by referencing the $LM00 common block, but I know that this works. */ STKSTAT (&status); /* Set up the iteration. */ trailer = (struct stk_trailer *) (status.current_address + status.current_size - 15); /* There must be at least one stack segment. Therefore it is a fatal error if "trailer" is null. */ if (trailer == 0) abort (); /* Discard segments that do not contain our argument address. */ while (trailer != 0) { block = (long *) trailer->this_address; size = trailer->this_size; if (block == 0 || size == 0) abort (); trailer = (struct stk_trailer *) trailer->link; if ((block <= address) && (address < (block + size))) break; } /* Set the result to the offset in this segment and add the sizes of all predecessor segments. */ result = address - block; if (trailer == 0) { return result; } do { if (trailer->this_size <= 0) abort (); result += trailer->this_size; trailer = (struct stk_trailer *) trailer->link; } while (trailer != 0); /* We are done. Note that if you present a bogus address (one not in any segment), you will get a different number back, formed from subtracting the address of the first block. This is probably not what you want. */ return (result); } #else /* not CRAY2 */ /* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. Determine the number of the cell within the stack, given the address of the cell. The purpose of this routine is to linearize, in some sense, stack addresses for alloca. */ static long i00afunc (long address) { long stkl = 0; long size, pseg, this_segment, stack; long result = 0; struct stack_segment_linkage *ssptr; /* Register B67 contains the address of the end of the current stack segment. If you (as a subprogram) store your registers on the stack and find that you are past the contents of B67, you have overflowed the segment. B67 also points to the stack segment linkage control area, which is what we are really interested in. */ stkl = CRAY_STACKSEG_END (); ssptr = (struct stack_segment_linkage *) stkl; /* If one subtracts 'size' from the end of the segment, one has the address of the first word of the segment. If this is not the first segment, 'pseg' will be nonzero. */ pseg = ssptr->sspseg; size = ssptr->sssize; this_segment = stkl - size; /* It is possible that calling this routine itself caused a stack overflow. Discard stack segments which do not contain the target address. */ while (!(this_segment <= address && address <= stkl)) { #ifdef DEBUG_I00AFUNC fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); #endif if (pseg == 0) break; stkl = stkl - pseg; ssptr = (struct stack_segment_linkage *) stkl; size = ssptr->sssize; pseg = ssptr->sspseg; this_segment = stkl - size; } result = address - this_segment; /* If you subtract pseg from the current end of the stack, you get the address of the previous stack segment's end. This seems a little convoluted to me, but I'll bet you save a cycle somewhere. */ while (pseg != 0) { #ifdef DEBUG_I00AFUNC fprintf (stderr, "%011o %011o\n", pseg, size); #endif stkl = stkl - pseg; ssptr = (struct stack_segment_linkage *) stkl; size = ssptr->sssize; pseg = ssptr->sspseg; result += size; } return (result); } #endif /* not CRAY2 */ #endif /* CRAY */ #endif /* no alloca */ #endif /* not GCC version 2 */ #endif /* !HAVE_ALLOCA */ sane-backends-1.0.29/lib/usleep.c0000666000000000000000000000320713615534521013412 00000000000000/* Copyright (C) 1992 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "../include/sane/config.h" #ifndef HAVE_USLEEP #include #ifdef HAVE_SYS_TIME_H # include #endif #ifdef HAVE_SYS_SELECT_H # include #endif #ifdef apollo # include # include static time_$clock_t DomainTime100mS = { 0, 100000/4 }; static status_$t DomainStatus; #endif /* Sleep USECONDS microseconds, or until a previously set timer goes off. */ unsigned int usleep (unsigned int useconds) { #ifdef apollo /* The usleep function does not work under the SYS5.3 environment. Use the Domain/OS time_$wait call instead. */ time_$wait (time_$relative, DomainTime100mS, &DomainStatus); #else struct timeval delay; delay.tv_sec = 0; delay.tv_usec = useconds; select (0, 0, 0, 0, &delay); return 0; #endif } #endif /* !HAVE_USLEEP */ sane-backends-1.0.29/lib/strndup.c0000666000000000000000000000216613615534521013617 00000000000000/* Copyright (C) 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "../include/sane/config.h" #ifndef HAVE_STRNDUP #include #include #include char * strndup (const char * s, size_t n) { char *clone; clone = malloc (n + 1); strncpy (clone, s, n); clone[n] = '\0'; return clone; } #endif /* !HAVE_STRNDUP */ sane-backends-1.0.29/lib/Makefile.in0000644000000000000000000006060113615534556014023 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = lib ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) liblib_la_DEPENDENCIES = $(LTALLOCA) $(LTLIBOBJS) am_liblib_la_OBJECTS = liblib_la-md5.lo liblib_la_OBJECTS = $(am_liblib_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/sane depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = $(DEPDIR)/getenv.Plo $(DEPDIR)/getopt.Plo \ $(DEPDIR)/getopt1.Plo $(DEPDIR)/inet_ntop.Plo \ $(DEPDIR)/inet_pton.Plo $(DEPDIR)/sigprocmask.Plo \ $(DEPDIR)/sleep.Plo $(DEPDIR)/snprintf.Plo \ $(DEPDIR)/strcasestr.Plo $(DEPDIR)/strdup.Plo \ $(DEPDIR)/strndup.Plo $(DEPDIR)/strsep.Plo \ $(DEPDIR)/syslog.Plo $(DEPDIR)/usleep.Plo \ $(DEPDIR)/vsyslog.Plo ./$(DEPDIR)/alloca.Plo \ ./$(DEPDIR)/liblib_la-md5.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(liblib_la_SOURCES) DIST_SOURCES = $(liblib_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp alloca.c \ getenv.c getopt.c getopt1.c inet_ntop.c inet_pton.c \ sigprocmask.c sleep.c snprintf.c strcasestr.c strdup.c \ strndup.c strsep.c syslog.c usleep.c vsyslog.c DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_CPPFLAGS = @AM_CPPFLAGS@ -I. -I$(top_builddir)/include \ -I$(top_srcdir)/include AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = liblib.la liblib_la_SOURCES = md5.c liblib_la_CPPFLAGS = -I$(top_srcdir)/include liblib_la_LIBADD = $(LTALLOCA) $(LTLIBOBJS) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu lib/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } liblib.la: $(liblib_la_OBJECTS) $(liblib_la_DEPENDENCIES) $(EXTRA_liblib_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(liblib_la_OBJECTS) $(liblib_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getenv.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt1.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/inet_ntop.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/inet_pton.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sigprocmask.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sleep.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/snprintf.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasestr.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strdup.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strndup.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strsep.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/syslog.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/usleep.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vsyslog.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloca.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/liblib_la-md5.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @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)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)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 $@ $< liblib_la-md5.lo: md5.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT liblib_la-md5.lo -MD -MP -MF $(DEPDIR)/liblib_la-md5.Tpo -c -o liblib_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/liblib_la-md5.Tpo $(DEPDIR)/liblib_la-md5.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='md5.c' object='liblib_la-md5.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) $(liblib_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o liblib_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -f $(DEPDIR)/getenv.Plo -rm -f $(DEPDIR)/getopt.Plo -rm -f $(DEPDIR)/getopt1.Plo -rm -f $(DEPDIR)/inet_ntop.Plo -rm -f $(DEPDIR)/inet_pton.Plo -rm -f $(DEPDIR)/sigprocmask.Plo -rm -f $(DEPDIR)/sleep.Plo -rm -f $(DEPDIR)/snprintf.Plo -rm -f $(DEPDIR)/strcasestr.Plo -rm -f $(DEPDIR)/strdup.Plo -rm -f $(DEPDIR)/strndup.Plo -rm -f $(DEPDIR)/strsep.Plo -rm -f $(DEPDIR)/syslog.Plo -rm -f $(DEPDIR)/usleep.Plo -rm -f $(DEPDIR)/vsyslog.Plo -rm -f ./$(DEPDIR)/alloca.Plo -rm -f ./$(DEPDIR)/liblib_la-md5.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(DEPDIR)/getenv.Plo -rm -f $(DEPDIR)/getopt.Plo -rm -f $(DEPDIR)/getopt1.Plo -rm -f $(DEPDIR)/inet_ntop.Plo -rm -f $(DEPDIR)/inet_pton.Plo -rm -f $(DEPDIR)/sigprocmask.Plo -rm -f $(DEPDIR)/sleep.Plo -rm -f $(DEPDIR)/snprintf.Plo -rm -f $(DEPDIR)/strcasestr.Plo -rm -f $(DEPDIR)/strdup.Plo -rm -f $(DEPDIR)/strndup.Plo -rm -f $(DEPDIR)/strsep.Plo -rm -f $(DEPDIR)/syslog.Plo -rm -f $(DEPDIR)/usleep.Plo -rm -f $(DEPDIR)/vsyslog.Plo -rm -f ./$(DEPDIR)/alloca.Plo -rm -f ./$(DEPDIR)/liblib_la-md5.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-generic clean-libtool clean-noinstLTLIBRARIES \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/lib/strsep.c0000666000000000000000000000260313615534521013434 00000000000000/* Copyright (C) 1992, 1993, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "../include/sane/config.h" #include #ifndef HAVE_STRSEP char * strsep (char **stringp, const char *delim) { char *begin, *end; begin = *stringp; if (! begin || *begin == '\0') return NULL; /* Find the end of the token. */ end = strpbrk (begin, delim); if (end) { /* Terminate the token and set *STRINGP past NUL character. */ *end++ = '\0'; *stringp = end; } else /* No more delimiters; this is the last token. */ *stringp = NULL; return begin; } #endif /* !HAVE_STRSEP */ sane-backends-1.0.29/lib/sigprocmask.c0000666000000000000000000000273713615534521014446 00000000000000/* Copyright (C) 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "../include/sane/config.h" #include #ifndef HAVE_SIGPROCMASK #define sigprocmask SOMETHINGELSE #include #undef sigprocmask int sigprocmask (int how, int *new, int *old) { int o, n = *new; /* FIXME: Get this working on Windows. Probably should move to * POSIX sigaction API and emulate it before emulating this one. */ #ifndef WIN32 switch (how) { case 1: o = sigblock (n); break; case 2: o = sigsetmask (sigblock (0) & ~n); break; case 3: o = sigsetmask (n); break; default: errno = EINVAL; return -1; } if (old) *old = o; #endif return 0; } #endif /* !HAVE_SIGPROCMASK */ sane-backends-1.0.29/lib/getenv.c0000666000000000000000000000046413615534521013407 00000000000000#include "../include/sane/config.h" #ifndef HAVE_GETENV char * getenv(const char *name) { char *retval = 0; #ifdef HAVE_OS2_H if (0 != DosScanEnv (buf, &retval)) retval = 0; #else # error "Missing getenv() on this platform. Please implement." #endif return retval; } #endif /* !HAVE_GETENV */ sane-backends-1.0.29/lib/snprintf.c0000666000000000000000000010557713615534521013775 00000000000000#include "../include/sane/config.h" #ifndef HAVE_SNPRINTF /************************************************************************** * Copyright 1994-2003 Patrick Powell, San Diego, CA **************************************************************************/ /* Overview: snprintf( char *buffer, int len, const char *format,...) plp_unsafe_snprintf( char *buffer, int len, const char *format,...) its horribly unsafe companion that does NOT protect you from the printing of evil control characters, but may be necessary See the man page documentation below This version of snprintf was developed originally for printing on a motley collection of specialized hardware that had NO IO library. Due to contractual restrictions, a clean room implementation of the printf() code had to be developed. The method chosen for printf was to be as paranoid as possible, as these platforms had NO memory protection, and very small address spaces. This made it possible to try to print very long strings, i.e. - all of memory, very easily. To guard against this, all printing was done via a buffer, generous enough to hold strings, but small enough to protect against overruns, etc. Strangely enough, this proved to be of immense importance when SPRINTFing to a buffer on a stack... The rest, of course, is well known, as buffer overruns in the stack are a common way to do horrible things to operating systems, security, etc etc. This version of snprintf is VERY limited by modern standards. Revision History: First Released Version - 1994. This version had NO comments. First Released Version - 1994. This version had NO comments. Second Major Released Version - Tue May 23 10:43:44 PDT 2000 Configuration and other items changed. Read this doc. Treat this as a new version. Minor Revision - Mon Apr 1 09:41:28 PST 2002 - fixed up some constants and casts COPYRIGHT AND TERMS OF USE: You may use, copy, distribute, or otherwise incorporate this software and documentation into any product or other item, provided that the copyright in the documentation and source code as well as the source code generated constant strings in the object, executable or other code remain in place and are present in executable modules or objects. You may modify this code as appropriate to your usage; however the modified version must be identified by changing the various source and object code identification strings as is appropriately noted in the source code. You can use this with the GNU CONFIGURE utility. This should define the following macros appropriately: HAVE_STDARG_H - if the include file is available HAVE_VARARG_H - if the include file is available HAVE_STRERROR - if the strerror() routine is available. If it is not available, then examine the lines containing the tests below. HAVE_SYS_ERRLIST - have sys_errlist available HAVE_DECL_SYS_ERRLIST - sys_errlist declaration in include files HAVE_SYS_NERR - have sys_nerr available HAVE_DECL_SYS_NERR - sys_nerr declaration in include files HAVE_QUAD_T - if the quad_t type is defined HAVE_LONG_LONG - if the long long type is defined HAVE_LONG_DOUBLE - if the long double type is defined If you are using the GNU configure (autoconf) facility, add the following line to the configure.in file, to force checking for the quad_t and long long data types: AC_CHECK_HEADERS(stdlib.h,stdio.h,unistd.h,errno.h) AC_CHECK_FUNCS(strerror) AC_CACHE_CHECK(for errno, ac_cv_errno, [ AC_TRY_LINK(,[extern int errno; return (errno);], ac_cv_errno=yes, ac_cv_errno=no) ]) if test "$ac_cv_errno" = yes; then AC_DEFINE(HAVE_ERRNO) AC_CACHE_CHECK(for errno declaration, ac_cv_decl_errno, [ AC_TRY_COMPILE([ #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_ERRNO_H #include ],[return(sys_nerr);], ac_cv_decl_errno=yes, ac_cv_decl_errno=no) ]) if test "$ac_cv_decl_errno" = yes; then AC_DEFINE(HAVE_DECL_ERRNO) fi; fi AC_CACHE_CHECK(for sys_nerr, ac_cv_sys_nerr, [ AC_TRY_LINK(,[extern int sys_nerr; return (sys_nerr);], ac_cv_sys_nerr=yes, ac_cv_sys_nerr=no) ]) if test "$ac_cv_sys_nerr" = yes; then AC_DEFINE(HAVE_SYS_NERR) AC_CACHE_CHECK(for sys_nerr declaration, ac_cv_decl_sys_nerr, [ AC_TRY_COMPILE([ #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif],[return(sys_nerr);], ac_cv_decl_sys_nerr_def=yes, ac_cv_decl_sys_nerr_def=no) ]) if test "$ac_cv_decl_sys_nerr" = yes; then AC_DEFINE(HAVE_DECL_SYS_NERR) fi fi AC_CACHE_CHECK(for sys_errlist array, ac_cv_sys_errlist, [AC_TRY_LINK(,[extern char *sys_errlist[]; sys_errlist[0];], ac_cv_sys_errlist=yes, ac_cv_sys_errlist=no) ]) if test "$ac_cv_sys_errlist" = yes; then AC_DEFINE(HAVE_SYS_ERRLIST) AC_CACHE_CHECK(for sys_errlist declaration, ac_cv_sys_errlist_def, [AC_TRY_COMPILE([ #include #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_UNISTD_H #include #endif],[char *s = sys_errlist[0]; return(*s);], ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no) ]) if test "$ac_cv_decl_sys_errlist" = yes; then AC_DEFINE(HAVE_DECL_SYS_ERRLIST) fi fi AC_CACHE_CHECK(checking for long long, ac_cv_long_long, [ AC_TRY_COMPILE([ #include #include ], [printf("%d",sizeof(long long));], ac_cv_long_long=yes, ac_cv_long_long=no) ]) if test $ac_cv_long_long = yes; then AC_DEFINE(HAVE_LONG_LONG) fi AC_CACHE_CHECK(checking for long double, ac_cv_long_double, [ AC_TRY_COMPILE([ #include #include ], [printf("%d",sizeof(long double));], ac_cv_long_double=yes, ac_cv_long_double=no) ]) if test $ac_cv_long_double = yes; then AC_DEFINE(HAVE_LONG_DOUBLE) fi AC_CACHE_CHECK(checking for quad_t, ac_cv_quad_t, [ AC_TRY_COMPILE([ #include #include ], [printf("%d",sizeof(quad_t));], ac_cv_quad_t=yes, ac_cv_quad_t=no) ]) if test $ac_cv_quad_t = yes; then AC_DEFINE(HAVE_QUAD_T) fi NAME snprintf, plp_vsnprintf - formatted output conversion SYNOPSIS #include #include int snprintf(const char *format, size_t size, va_list ap); int plp_unsafe_snprintf(const char *format, size_t size, va_list ap); AKA snprintf and unsafe_snprintf in the documentation below int vsnprintf(char *str, size_t size, const char *format, va_list ap); int unsafe_vsnprintf(char *str, size_t size, const char *format, va_list ap); AKA vsnprintf and unsafe_vsnprintf in the documentation below (Multithreaded Safe) DESCRIPTION The printf() family of functions produces output according to a format as described below. Snprintf(), and vsnprintf() write to the character string str. These functions write the output under the control of a format string that specifies how subsequent arguments (or arguments accessed via the variable-length argument facilities of stdarg(3)) are converted for output. These functions return the number of characters printed (not including the trailing `\0' used to end output to strings). Snprintf() and vsnprintf() will write at most size-1 of the characters printed into the output string (the size'th character then gets the terminating `\0'); if the return value is greater than or equal to the size argument, the string was too short and some of the printed characters were discarded. The size or str may be given as zero to find out how many characters are needed; in this case, the str argument is ignored. By default, the snprintf function will not format control characters (except new line and tab) in strings. This is a safety feature that has proven to be extremely critical when using snprintf for secure applications and when debugging. If you MUST have control characters formatted or printed, then use the unsafe_snprintf() and unsafe_vsnprintf() and on your own head be the consequences. You have been warned. There is one exception to the comments above, and that is the "%c" (character) format. It brutally assumes that the user will have performed the necessary 'isprint()' or other checks and uses the integer value as a character. The format string is composed of zero or more directives: ordinary characters (not %), which are copied unchanged to the output stream; and conversion specifications, each of which results in fetching zero or more subsequent arguments. Each conversion specification is introduced by the character %. The arguments must correspond properly (after type promotion) with the conversion specifier. After the %, the following appear in sequence: o Zero or more of the following flags: - A zero `0' character specifying zero padding. For all conversions except n, the converted value is padded on the left with zeros rather than blanks. If a precision is given with a numeric conversion (d, i, o, u, i, x, and X), the `0' flag is ignored. - A negative field width flag `-' indicates the converted value is to be left adjusted on the field boundary. Except for n conversions, the converted value is padded on the right with blanks, rather than on the left with blanks or zeros. A `-' overrides a `0' if both are given. - A space, specifying that a blank should be left before a positive number produced by a signed conversion (d, e, E, f, g, G, or i). - A `+' character specifying that a sign always be placed before a number produced by a signed conversion. A `+' overrides a space if both are used. o An optional decimal digit string specifying a minimum field width. If the converted value has fewer characters than the field width, it will be padded with spaces on the left (or right, if the left-adjustment flag has been given) to fill out the field width. o An optional precision, in the form of a period `.' followed by an optional digit string. If the digit string is omitted, the precision is taken as zero. This gives the minimum number of digits to appear for d, i, o, u, x, and X conversions, the number of digits to appear after the decimal-point for e, E, and f conversions, the maximum number of significant digits for g and G conversions, or the maximum number of characters to be printed from a string for s conversions. o The optional character h, specifying that a following d, i, o, u, x, or X conversion corresponds to a short int or unsigned short int argument, or that a following n conversion corresponds to a pointer to a short int argument. o The optional character l (ell) specifying that a following d, i, o, u, x, or X conversion applies to a pointer to a long int or unsigned long int argument, or that a following n conversion corresponds to a pointer to a long int argument. o The optional character q, specifying that a following d, i, o, u, x, or X conversion corresponds to a quad_t or u_quad_t argument, or that a following n conversion corresponds to a quad_t argument. This value is always printed in HEX notation. Tough. quad_t's are an OS system implementation, and should not be allowed. o The character L specifying that a following e, E, f, g, or G conversion corresponds to a long double argument. o A character that specifies the type of conversion to be applied. A field width or precision, or both, may be indicated by an asterisk `*' instead of a digit string. In this case, an int argument supplies the field width or precision. A negative field width is treated as a left adjustment flag followed by a positive field width; a negative precision is treated as though it were missing. The conversion specifiers and their meanings are: diouxX The int (or appropriate variant) argument is converted to signed decimal (d and i), unsigned octal (o), unsigned decimal (u), or unsigned hexadecimal (x and X) notation. The letters abcdef are used for x conversions; the letters ABCDEF are used for X conversions. The precision, if any, gives the minimum number of digits that must appear; if the converted value requires fewer digits, it is padded on the left with zeros. eE The double argument is rounded and converted in the style [-]d.ddde+-dd where there is one digit before the decimal-point character and the number of digits after it is equal to the precision; if the precision is missing, it is taken as 6; if the precision is zero, no decimal-point character appears. An E conversion uses the letter E (rather than e) to introduce the exponent. The exponent always contains at least two digits; if the value is zero, the exponent is 00. f The double argument is rounded and converted to decimal notation in the style [-]ddd.ddd, where the number of digits after the decimal-point character is equal to the precision specification. If the precision is missing, it is taken as 6; if the precision is explicitly zero, no decimal-point character appears. If a decimal point appears, at least one digit appears before it. g The double argument is converted in style f or e (or E for G conversions). The precision specifies the number of significant digits. If the precision is missing, 6 digits are given; if the precision is zero, it is treated as 1. Style e is used if the exponent from its conversion is less than -4 or greater than or equal to the precision. Trailing zeros are removed from the fractional part of the result; a decimal point appears only if it is followed by at least one digit. c The int argument is converted to an unsigned char, and the resulting character is written. s The ``char *'' argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to (but not including) a terminating NUL character; if a precision is specified, no more than the number specified are written. If a precision is given, no null character need be present; if the precision is not specified, or is greater than the size of the array, the array must contain a terminating NUL character. % A `%' is written. No argument is converted. The complete conversion specification is `%%'. In no case does a non-existent or small field width cause truncation of a field; if the result of a conversion is wider than the field width, the field is expanded to contain the conversion result. EXAMPLES To print a date and time in the form `Sunday, July 3, 10:02', where weekday and month are pointers to strings: #include fprintf(stdout, "%s, %s %d, %.2d:%.2d\n", weekday, month, day, hour, min); To print pi to five decimal places: #include #include fprintf(stdout, "pi = %.5f\n", 4 * atan(1.0)); To allocate a 128 byte string and print into it: #include #include #include char *newfmt(const char *fmt, ...) { char *p; va_list ap; if ((p = malloc(128)) == NULL) return (NULL); va_start(ap, fmt); (void) vsnprintf(p, 128, fmt, ap); va_end(ap); return (p); } SEE ALSO printf(1), scanf(3) STANDARDS Turkey C Standardization and wimpy POSIX folks did not define snprintf or vsnprintf(). BUGS The conversion formats %D, %O, and %U are not standard and are provided only for backward compatibility. The effect of padding the %p format with zeros (either by the `0' flag or by specifying a precision), and the benign effect (i.e., none) of the `#' flag on %n and %p conversions, as well as other nonsensical combinations such as %Ld, are not standard; such combinations should be avoided. The typedef names quad_t and u_quad_t are infelicitous. */ #include #include #include #include #if defined(HAVE_STRING_H) # include #endif #if defined(HAVE_STRINGS_H) # include #endif #if defined(HAVE_ERRNO_H) #include #endif /* * For testing, define these values */ #if 0 #define HAVE_STDARG_H 1 #define TEST 1 #define HAVE_QUAD_T 1 #endif /**** ENDINCLUDE ****/ /************************************************* * KEEP THIS STRING - MODIFY AT THE END WITH YOUR REVISIONS * i.e. - the LOCAL REVISIONS part is for your use *************************************************/ static char *const _id = "plp_snprintf V2000.08.18 Copyright Patrick Powell 1988-2000 " "$Id: plp_snprintf.c,v 1.4 2005/04/14 20:05:19 papowell Exp $" " LOCAL REVISIONS: renamed plp_snprintf to snprintf, conditionalized everything on HAVE_SNPRINTF"; /* varargs declarations: */ # undef HAVE_STDARGS /* let's hope that works everywhere (mj) */ # undef VA_LOCAL_DECL # undef VA_START # undef VA_SHIFT # undef VA_END #if defined(HAVE_STDARG_H) # include # define HAVE_STDARGS /* let's hope that works everywhere (mj) */ # define VA_LOCAL_DECL va_list ap; # define VA_START(f) va_start(ap, f) # define VA_SHIFT(v,t) ; /* no-op for ANSI */ # define VA_END va_end(ap) #else # if defined(HAVE_VARARGS_H) # include # undef HAVE_STDARGS # define VA_LOCAL_DECL va_list ap; # define VA_START(f) va_start(ap) /* f is ignored! */ # define VA_SHIFT(v,t) v = va_arg(ap,t) # define VA_END va_end(ap) # else XX ** NO VARARGS ** XX # endif #endif union value { #if defined(HAVE_QUAD_T) quad_t qvalue; #endif #if defined(HAVE_LONG_LONG) long long value; #else long value; #endif double dvalue; }; #undef CVAL #define CVAL(s) (*((unsigned char *)s)) #define safestrlen(s) ((s)?strlen(s):0) static char * plp_Errormsg ( int err, char *buffer ); static void dopr( int visible_control, char **buffer, int *left, const char *format, va_list args ); static void fmtstr( int visible_control, char **buffer, int *left, char *value, int ljust, int len, int zpad, int precision ); static void fmtnum( char **buffer, int *left, union value *value, int base, int dosign, int ljust, int len, int zpad, int precision ); #if defined(HAVE_QUAD_T) static void fmtquad( char **buffer, int *left, union value *value, int base, int dosign, int ljust, int len, int zpad, int precision ); #endif static void fmtdouble( char **bufer, int *left, int fmt, double value, int ljust, int len, int zpad, int precision ); static void dostr( char **buffer, int *left, char *str ); static void dopr_outch( char **buffer, int *left, int c ); /* VARARGS3 */ #ifdef HAVE_STDARGS int plp_vsnprintf(char *str, size_t count, const char *fmt, va_list args) #else int plp_vsnprintf(char *str, size_t count, const char *fmt, va_list args) #endif { int left; char *buffer; if( (int)count < 0 ) count = 0; left = count; if( count == 0 ) str = 0; buffer = str; dopr( 1, &buffer, &left, fmt, args ); /* fprintf(stderr,"str 0x%x, buffer 0x%x, count %d, left %d\n", (int)str, (int)buffer, count, left ); */ if( str && count > 0 ){ if( left > 0 ){ str[count-left] = 0; } else { str[count-1] = 0; } } return(count - left); } /* VARARGS3 */ #ifdef HAVE_STDARGS int plp_unsafe_vsnprintf(char *str, size_t count, const char *fmt, va_list args) #else int plp_unsafe_vsnprintf(char *str, size_t count, const char *fmt, va_list args) #endif { int left; char *buffer; if( (int)count < 0 ) count = 0; left = count; if( count == 0 ) str = 0; buffer = str; dopr( 0, &buffer, &left, fmt, args ); /* fprintf(stderr,"str 0x%x, buffer 0x%x, count %d, left %d\n", (int)str, (int)buffer, count, left ); */ if( str && count > 0 ){ if( left > 0 ){ str[count-left] = 0; } else { str[count-1] = 0; } } return(count - left); } /* VARARGS3 */ #ifdef HAVE_STDARGS int snprintf (char *str,size_t count,const char *fmt,...) #else int snprintf (va_alist) va_dcl #endif { #ifndef HAVE_STDARGS char *str; size_t count; char *fmt; #endif int n = 0; VA_LOCAL_DECL VA_START (fmt); VA_SHIFT (str, char *); VA_SHIFT (count, size_t ); VA_SHIFT (fmt, char *); n = plp_vsnprintf ( str, count, fmt, ap); VA_END; return( n ); } /* VARARGS3 */ #ifdef HAVE_STDARGS int plp_unsafe_snprintf (char *str,size_t count,const char *fmt,...) #else int plp_unsafe_snprintf (va_alist) va_dcl #endif { #ifndef HAVE_STDARGS char *str; size_t count; char *fmt; #endif int n = 0; VA_LOCAL_DECL VA_START (fmt); VA_SHIFT (str, char *); VA_SHIFT (count, size_t ); VA_SHIFT (fmt, char *); n = plp_unsafe_vsnprintf ( str, count, fmt, ap); VA_END; return( n ); } static void dopr( int visible_control, char **buffer, int *left, const char *format, va_list args ) { int ch; union value value; int longflag = 0; int quadflag = 0; char *strvalue; int ljust; int len; int zpad; int precision; int set_precision; double dval; int err = errno; int base = 0; int signed_val = 0; while( (ch = *format++) ){ switch( ch ){ case '%': longflag = quadflag = ljust = len = zpad = base = signed_val = 0; precision = -1; set_precision = 0; nextch: ch = *format++; switch( ch ){ case 0: dostr( buffer, left, "**end of format**" ); return; case '-': ljust = 1; goto nextch; case '.': set_precision = 1; precision = 0; goto nextch; case '*': if( set_precision ){ precision = va_arg( args, int ); } else { len = va_arg( args, int ); } goto nextch; case '0': /* set zero padding if len not set */ if(len==0 && set_precision == 0 ) zpad = '0'; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if( set_precision ){ precision = precision*10 + ch - '0'; } else { len = len*10 + ch - '0'; } goto nextch; case 'l': ++longflag; goto nextch; case 'q': #if !defined( HAVE_QUAD_T ) dostr( buffer, left, "*no quad_t support *"); return; #endif quadflag = 1; goto nextch; case 'u': case 'U': if( base == 0 ){ base = 10; signed_val = 0; } case 'o': case 'O': if( base == 0 ){ base = 8; signed_val = 0; } case 'd': case 'D': if( base == 0 ){ base = 10; signed_val = 1; } case 'x': if( base == 0 ){ base = 16; signed_val = 0; } case 'X': if( base == 0 ){ base = -16; signed_val = 0; } #if defined( HAVE_QUAD_T ) if( quadflag ){ value.qvalue = va_arg( args, quad_t ); fmtquad( buffer, left, &value,base,signed_val, ljust, len, zpad, precision ); break; } else #endif if( longflag > 1 ){ #if defined(HAVE_LONG_LONG) if( signed_val ){ value.value = va_arg( args, long long ); } else { value.value = va_arg( args, unsigned long long ); } #else if( signed_val ){ value.value = va_arg( args, long ); } else { value.value = va_arg( args, unsigned long ); } #endif } else if( longflag ){ if( signed_val ){ value.value = va_arg( args, long ); } else { value.value = va_arg( args, unsigned long ); } } else { if( signed_val ){ value.value = va_arg( args, int ); } else { value.value = va_arg( args, unsigned int ); } } fmtnum( buffer, left, &value,base,signed_val, ljust, len, zpad, precision ); break; case 's': strvalue = va_arg( args, char *); fmtstr( visible_control, buffer, left, strvalue,ljust,len, zpad, precision ); break; case 'c': ch = va_arg( args, int ); { char b[2]; b[0] = ch; b[1] = 0; fmtstr( 0, buffer, left, b,ljust,len, zpad, precision ); } break; case 'f': case 'g': case 'e': dval = va_arg( args, double ); fmtdouble( buffer, left, ch, dval,ljust,len, zpad, precision ); break; case 'm': { char shortbuffer[32]; fmtstr( visible_control, buffer, left, plp_Errormsg(err, shortbuffer),ljust,len, zpad, precision ); } break; case '%': dopr_outch( buffer, left, ch ); continue; default: dostr( buffer, left, "???????" ); } longflag = 0; break; default: dopr_outch( buffer, left, ch ); break; } } } /* * Format '%[-]len[.precision]s' * - = left justify (ljust) * len = minimum length * precision = numbers of chars in string to use */ static void fmtstr( int visible_control, char **buffer, int *left, char *value, int ljust, int len, int zpad, int precision ) { int padlen, strlenv, i, c; /* amount to pad */ if( value == 0 ){ value = ""; } /* cheap strlen so you do not have library call */ for( strlenv = i = 0; (c=CVAL(value+i)); ++i ){ if( visible_control && iscntrl( c ) && c != '\t' && c != '\n' ){ ++strlenv; } ++strlenv; } if( precision > 0 && strlenv > precision ){ strlenv = precision; } padlen = len - strlenv; if( padlen < 0 ) padlen = 0; if( ljust ) padlen = -padlen; while( padlen > 0 ) { dopr_outch( buffer, left, ' ' ); --padlen; } /* output characters */ for( i = 0; i < strlenv && (c = CVAL(value+i)); ++i ){ if( visible_control && iscntrl( c ) && c != '\t' && c != '\n' ){ dopr_outch(buffer, left, '^'); c = ('@' | (c & 0x1F)); } dopr_outch(buffer, left, c); } while( padlen < 0 ) { dopr_outch( buffer, left, ' ' ); ++padlen; } } static void fmtnum( char **buffer, int *left, union value *value, int base, int dosign, int ljust, int len, int zpad, int precision ) { int signvalue = 0; #if defined(HAVE_LONG_LONG) unsigned long long uvalue; #else unsigned long uvalue; #endif char convert[sizeof( union value) * 8 + 16]; int place = 0; int padlen = 0; /* amount to pad */ int caps = 0; /* fprintf(stderr,"value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n", value, base, dosign, ljust, len, zpad );/ **/ uvalue = value->value; if( dosign ){ if( value->value < 0 ) { signvalue = '-'; uvalue = -value->value; } } if( base < 0 ){ caps = 1; base = -base; } do{ convert[place++] = (caps? "0123456789ABCDEF":"0123456789abcdef") [uvalue % (unsigned)base ]; uvalue = (uvalue / (unsigned)base ); }while(uvalue); convert[place] = 0; padlen = len - place; if( padlen < 0 ) padlen = 0; if( ljust ) padlen = -padlen; /* fprintf( stderr, "str '%s', place %d, sign %c, padlen %d\n", convert,place,signvalue,padlen); / **/ if( zpad && padlen > 0 ){ if( signvalue ){ dopr_outch( buffer, left, signvalue ); --padlen; signvalue = 0; } while( padlen > 0 ){ dopr_outch( buffer, left, zpad ); --padlen; } } while( padlen > 0 ) { dopr_outch( buffer, left, ' ' ); --padlen; } if( signvalue ) dopr_outch( buffer, left, signvalue ); while( place > 0 ) dopr_outch( buffer, left, convert[--place] ); while( padlen < 0 ){ dopr_outch( buffer, left, ' ' ); ++padlen; } } #if defined(HAVE_QUAD_T) static void fmtquad( char **buffer, int *left, union value *value, int base, int dosign, int ljust, int len, int zpad, int precision ) { int signvalue = 0; int place = 0; int padlen = 0; /* amount to pad */ int caps = 0; int i, c; union { quad_t qvalue; unsigned char qconvert[sizeof(quad_t)]; } vvalue; char convert[2*sizeof(quad_t)+1]; /* fprintf(stderr,"value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n", value, base, dosign, ljust, len, zpad );/ **/ vvalue.qvalue = value->qvalue; if( base < 0 ){ caps = 1; } for( i = 0; i < (int)sizeof(quad_t); ++i ){ c = vvalue.qconvert[i]; convert[2*i] = (caps? "0123456789ABCDEF":"0123456789abcdef")[ (c >> 4) & 0xF]; convert[2*i+1] = (caps? "0123456789ABCDEF":"0123456789abcdef")[ c & 0xF]; } convert[2*i] = 0; place = strlen(convert); padlen = len - place; if( padlen < 0 ) padlen = 0; if( ljust ) padlen = -padlen; /* fprintf( stderr, "str '%s', place %d, sign %c, padlen %d\n", convert,place,signvalue,padlen); / **/ if( zpad && padlen > 0 ){ if( signvalue ){ dopr_outch( buffer, left, signvalue ); --padlen; signvalue = 0; } while( padlen > 0 ){ dopr_outch( buffer, left, zpad ); --padlen; } } while( padlen > 0 ) { dopr_outch( buffer, left, ' ' ); --padlen; } if( signvalue ) dopr_outch( buffer, left, signvalue ); while( place > 0 ) dopr_outch( buffer, left, convert[--place] ); while( padlen < 0 ){ dopr_outch( buffer, left, ' ' ); ++padlen; } } #endif static void mystrcat(char *dest, char *src ) { if( dest && src ){ dest += safestrlen(dest); strcpy(dest,src); } } static void fmtdouble( char **buffer, int *left, int fmt, double value, int ljust, int len, int zpad, int precision ) { char convert[sizeof( union value) * 8 + 512]; char formatstr[128]; /* fprintf(stderr,"len %d, precision %d\n", len, precision ); */ if( len > 255 ){ len = 255; } if( precision > 255 ){ precision = 255; } if( precision >= 0 && len > 0 && precision > len ) precision = len; strcpy( formatstr, "%" ); /* 1 */ if( ljust ) mystrcat(formatstr, "-" ); /* 1 */ if( zpad ) mystrcat(formatstr, "0" ); /* 1 */ if( len >= 0 ){ sprintf( formatstr+strlen(formatstr), "%d", len ); /* 3 */ } if( precision >= 0 ){ sprintf( formatstr+strlen(formatstr), ".%d", precision ); /* 3 */ } /* format string will be at most 10 chars long ... */ sprintf( formatstr+strlen(formatstr), "%c", fmt ); /* this is easier than trying to do the portable dtostr */ /* fprintf(stderr,"format string '%s'\n", formatstr); */ sprintf( convert, formatstr, value ); dostr( buffer, left, convert ); } static void dostr( char **buffer, int *left, char *str ) { if(str)while(*str) dopr_outch( buffer, left, *str++ ); } static void dopr_outch( char **buffer, int *left, int c ) { if( *left > 0 ){ *(*buffer)++ = c; } *left -= 1; } /**************************************************************************** * static char *plp_errormsg( int err ) * returns a printable form of the * errormessage corresponding to the valie of err. * This is the poor man's version of sperror(), not available on all systems * Patrick Powell Tue Apr 11 08:05:05 PDT 1995 ****************************************************************************/ /****************************************************************************/ #if !defined(HAVE_STRERROR) # undef num_errors # if defined(HAVE_SYS_ERRLIST) # if !defined(HAVE_DECL_SYS_ERRLIST) extern const char *const sys_errlist[]; # endif # if defined(HAVE_SYS_NERR) # if !defined(HAVE_DECL_SYS_NERR) extern int sys_nerr; # endif # define num_errors (sys_nerr) # endif # endif # if !defined(num_errors) # define num_errors (-1) /* always use "errno=%d" */ # endif #endif static char * plp_Errormsg ( int err, char *buffer /* int maxlen = 32 */) { char *cp; #if defined(HAVE_STRERROR) cp = (void *)strerror(err); #else # if defined(HAVE_SYS_ERRLIST) if (err >= 0 && err < num_errors) { cp = (void *)sys_errlist[err]; } else # endif { (void) sprintf (buffer, "errno=%d", err); cp = buffer; } #endif return (cp); } #if defined(TEST) #include int main( void ) { char buffer[128]; char *t; char *test1 = "01234"; int n; errno = 1; buffer[0] = 0; n = snprintf( buffer, 0, (t="test")); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t="errno '%m'")); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%12s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%-12s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%12.2s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%-12.2s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%g"), 1.2345 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%12g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%12.1g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%12.2g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%12.3g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%0*d"), 6, 1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); #if defined(HAVE_LONG_LONG) n = snprintf( buffer, sizeof(buffer), (t = "%llx"), 1, 2, 3, 4 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%llx"), (long long)1, (long long)2 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%qx"), 1, 2, 3, 4 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%qx"), (quad_t)1, (quad_t)2 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); #endif n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), (char *)(0x01234567), (char *)0, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), (char *)(0x01234567), (char *)0x89ABCDEF, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), t, 0, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.2345 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%12f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%12.2f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%0.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%1.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%1.5f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); n = snprintf( buffer, sizeof(buffer), (t = "%5.5f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); return(0); } #endif #endif /* HAVE_SNPRINTF */ sane-backends-1.0.29/lib/getopt1.c0000666000000000000000000001124713615534521013503 00000000000000/* getopt_long and getopt_long_only entry points for GNU getopt. Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include #if !defined(HAVE_GETOPT_H) || !defined(HAVE_GETOPT_LONG) #ifdef HAVE_CONFIG_H #include #endif #ifdef _LIBC # include #else # include "../include/lgetopt.h" #endif #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif #ifndef NULL #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } # ifdef _LIBC libc_hidden_def (getopt_long) libc_hidden_def (getopt_long_only) # endif #endif /* Not ELIDE_CODE. */ #ifdef TEST #include int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == -1) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case 'd': printf ("option d with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ #endif /* HAVE_GETOPT_LONG */ sane-backends-1.0.29/lib/syslog.c0000666000000000000000000000031513615534521013432 00000000000000#include "../include/sane/config.h" #ifndef HAVE_SYSLOG #include void syslog(int priority, const char *format, va_list args) { printf("%d ", priority); printf(format, args); } #endif sane-backends-1.0.29/lib/vsyslog.c0000666000000000000000000000043613615534521013624 00000000000000#include "../include/sane/config.h" #ifndef HAVE_VSYSLOG #include #include void vsyslog(int priority, const char *format, va_list args) { char buf[1024]; vsnprintf(buf, sizeof(buf), format, args); syslog(priority, "%s", buf); } #endif /* !HAVE_VSYSLOG */ sane-backends-1.0.29/lib/getopt.c0000666000000000000000000010351713615534521013424 00000000000000/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to drepper@gnu.org before changing it! Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ # include #if !defined(HAVE_GETOPT_H) || !defined(HAVE_GETOPT_LONG) /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO # define _NO_PROTO #endif #if 0 #ifdef HAVE_CONFIG_H # include #endif #endif #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ # ifndef const # define const # endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 # include # if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION # define ELIDE_CODE # endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ # include # include #endif /* GNU C library. */ #ifdef VMS # include # if HAVE_STRING_H - 0 # include # endif #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. */ # if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC # include # ifndef _ # define _(msgid) gettext (msgid) # endif # else # define _(msgid) (msgid) # endif # if defined _LIBC && defined USE_IN_LIBIO # include # endif #endif #ifndef attribute_hidden # define attribute_hidden #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "../include/lgetopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized attribute_hidden; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ # include # define my_index strchr #else # if HAVE_STRING_H # include # else # include # endif /* Avoid depending on library functions or files whose names are inconsistent. */ #ifndef getenv extern char *getenv (); #endif static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ # if (!defined __STDC__ || !__STDC__) && !defined strlen /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); # endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Stored original parameters. XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ extern int __libc_argc; extern char **__libc_argv; /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ # ifdef USE_NONOPTION_FLAGS /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; # endif # ifdef USE_NONOPTION_FLAGS # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } # else # define SWAP_FLAGS(ch1, ch2) # endif #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined __STDC__ && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ #if defined _LIBC && defined USE_NONOPTION_FLAGS /* First make sure the handling of the `__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else { memset (__mempcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len), '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined __STDC__ && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #if defined _LIBC && defined USE_NONOPTION_FLAGS if (posixly_correct == NULL && argc == __libc_argc && argv == __libc_argv) { if (nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen (orig_str); if (nonoption_flags_max_len < argc) nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), '\0', nonoption_flags_max_len - len); } } nonoption_flags_len = nonoption_flags_max_len; } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { int print_errors = opterr; if (optstring[0] == ':') print_errors = 0; if (argc < 1) return -1; optarg = NULL; if (optind == 0 || !__getopt_initialized) { if (optind == 0) optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring); __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #if defined _LIBC && defined USE_NONOPTION_FLAGS # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && __getopt_nonoption_flags[optind] == '1')) #else # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else if (long_only || pfound->has_arg != p->has_arg || pfound->flag != p->flag || pfound->val != p->val) /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]) >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #else fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); #endif } nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; int n; #endif if (argv[optind - 1][1] == '-') { /* --option */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("\ %s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); #else fprintf (stderr, _("\ %s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); #endif } else { /* +option or -option */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("\ %s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); #else fprintf (stderr, _("\ %s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); #endif } #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #endif } nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("\ %s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]) >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #else fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); #endif } nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; int n; #endif if (argv[optind][1] == '-') { /* --option */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); #else fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); #endif } else { /* +option or -option */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); #else fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); #endif } #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #endif } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; int n; #endif if (posixly_correct) { /* 1003.2 specifies the format of this message. */ #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("%s: illegal option -- %c\n"), argv[0], c); #else fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); #endif } else { #if defined _LIBC && defined USE_IN_LIBIO n = __asprintf (&buf, _("%s: invalid option -- %c\n"), argv[0], c); #else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); #endif } #if defined _LIBC && defined USE_IN_LIBIO if (n >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #endif } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("%s: option requires an argument -- %c\n"), argv[0], c) >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #else fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); #endif } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]) >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #else fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); #endif } nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name) >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #else fprintf (stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); #endif } nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (print_errors) { #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("\ %s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]) >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #else fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); #endif } nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (print_errors) { /* 1003.2 specifies the format of this message. */ #if defined _LIBC && defined USE_IN_LIBIO char *buf; if (__asprintf (&buf, _("\ %s: option requires an argument -- %c\n"), argv[0], c) >= 0) { if (_IO_fwide (stderr, 0) > 0) __fwprintf (stderr, L"%s", buf); else fputs (buf, stderr); free (buf); } #else fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); #endif } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ #endif /* !HAVE_GETOPT_LONG */ sane-backends-1.0.29/lib/md5.c0000666000000000000000000003360613615534521012610 00000000000000/* Functions to compute MD5 message digest of files or memory blocks. according to the definition of MD5 in RFC 1321 from April 1992. Copyright (C) 1995,1996,1997,1999,2000,2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /* Written by Ulrich Drepper , 1995. */ #ifdef HAVE_CONFIG_H # include #endif #include #if STDC_HEADERS || defined _LIBC # include # include #else # ifndef HAVE_MEMCPY # define memcpy(d, s, n) bcopy ((s), (d), (n)) # endif #endif #include "md5.h" #ifdef _LIBC # include # if __BYTE_ORDER == __BIG_ENDIAN # define WORDS_BIGENDIAN 1 # endif /* We need to keep the namespace clean so define the MD5 function protected using leading __ . */ # define md5_init_ctx __md5_init_ctx # define md5_process_block __md5_process_block # define md5_process_bytes __md5_process_bytes # define md5_finish_ctx __md5_finish_ctx # define md5_read_ctx __md5_read_ctx # define md5_stream __md5_stream # define md5_buffer __md5_buffer #endif #ifdef WORDS_BIGENDIAN # define SWAP(n) \ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #else # define SWAP(n) (n) #endif /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; void md5_init_ctx (struct md5_ctx *ctx); void * md5_read_ctx (const struct md5_ctx *ctx, void *resbuf); void * md5_finish_ctx (struct md5_ctx *ctx, void *resbuf); int md5_stream (FILE *stream, void *resblock); void * md5_buffer (const char *buffer, size_t len, void *resblock); void md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx); void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx); /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ void md5_init_ctx (struct md5_ctx *ctx) { ctx->A = 0x67452301; ctx->B = 0xefcdab89; ctx->C = 0x98badcfe; ctx->D = 0x10325476; ctx->total[0] = ctx->total[1] = 0; ctx->buflen = 0; } /* Put result from CTX in first 16 bytes following RESBUF. The result must be in little endian byte order. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) { ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); return resbuf; } /* Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ md5_uint32 bytes = ctx->buflen; size_t pad; size_t offset; /* Now count remaining bytes. */ ctx->total[0] += bytes; if (ctx->total[0] < bytes) ++ctx->total[1]; pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ offset = (bytes + pad) / sizeof (md5_uint32); ((md5_uint32 *) ctx->buffer)[offset] = SWAP (ctx->total[0] << 3); offset = (bytes + pad + 4) / sizeof (md5_uint32); ((md5_uint32 *) ctx->buffer)[offset] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ md5_process_block (ctx->buffer, bytes + pad + 8, ctx); return md5_read_ctx (ctx, resbuf); } /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ int md5_stream (FILE *stream, void *resblock) { /* Important: BLOCKSIZE must be a multiple of 64. */ #define BLOCKSIZE 4096 struct md5_ctx ctx; char buffer[BLOCKSIZE + 72]; size_t sum; /* Initialize the computation context. */ md5_init_ctx (&ctx); /* Iterate over full file contents. */ while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the computation function processes the whole buffer so that with the next round of the loop another block can be read. */ size_t n; sum = 0; /* Read block. Take care for partial reads. */ do { n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream); sum += n; } while (sum < BLOCKSIZE && n != 0); if (n == 0 && ferror (stream)) return 1; /* If end of file is reached, end the loop. */ if (n == 0) break; /* Process buffer with BLOCKSIZE bytes. Note that BLOCKSIZE % 64 == 0 */ md5_process_block (buffer, BLOCKSIZE, &ctx); } /* Add the last bytes if necessary. */ if (sum > 0) md5_process_bytes (buffer, sum, &ctx); /* Construct result in desired memory. */ md5_finish_ctx (&ctx, resblock); return 0; } /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ void * md5_buffer (const char *buffer, size_t len, void *resblock) { struct md5_ctx ctx; /* Initialize the computation context. */ md5_init_ctx (&ctx); /* Process whole buffer but last len % 64 bytes. */ md5_process_bytes (buffer, len, &ctx); /* Put result in desired memory area. */ return md5_finish_ctx (&ctx, resblock); } void md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) { /* When we already have some bits in our internal buffer concatenate both inputs first. */ if (ctx->buflen != 0) { size_t left_over = ctx->buflen; size_t add = 128 - left_over > len ? len : 128 - left_over; memcpy (&ctx->buffer[left_over], buffer, add); ctx->buflen += add; if (ctx->buflen > 64) { md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); ctx->buflen &= 63; /* The regions in the following copy operation cannot overlap. */ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen); } buffer = (const char *) buffer + add; len -= add; } /* Process available complete blocks. */ if (len >= 64) { #if !_STRING_ARCH_unaligned /* To check alignment gcc has an appropriate operator. Other compilers don't. */ # if __GNUC__ >= 2 # define UNALIGNED_P(p) (((md5_uintptr) p) % __alignof__ (md5_uint32) != 0) # else # define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0) # endif if (UNALIGNED_P (buffer)) while (len > 64) { md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); buffer = (const char *) buffer + 64; len -= 64; } else #endif { md5_process_block (buffer, len & ~63, ctx); buffer = (const char *) buffer + (len & ~63); len &= 63; } } /* Move remaining bytes in internal buffer. */ if (len > 0) { size_t left_over = ctx->buflen; memcpy (&ctx->buffer[left_over], buffer, len); left_over += len; if (left_over >= 64) { md5_process_block (ctx->buffer, 64, ctx); left_over -= 64; memcpy (ctx->buffer, &ctx->buffer[64], left_over); } ctx->buflen = left_over; } } /* These are the four functions used in the four steps of the MD5 algorithm and defined in the RFC 1321. The first function is a little bit optimized (as found in Colin Plumbs public domain implementation). */ /* #define FF(b, c, d) ((b & c) | (~b & d)) */ #define FF(b, c, d) (d ^ (b & (c ^ d))) #define FG(b, c, d) FF (d, b, c) #define FH(b, c, d) (b ^ c ^ d) #define FI(b, c, d) (c ^ (b | ~d)) /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. */ void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) { md5_uint32 correct_words[16]; const md5_uint32 *words = buffer; size_t nwords = len / sizeof (md5_uint32); const md5_uint32 *endp = words + nwords; md5_uint32 A = ctx->A; md5_uint32 B = ctx->B; md5_uint32 C = ctx->C; md5_uint32 D = ctx->D; /* First increment the byte count. RFC 1321 specifies the possible length of the file up to 2^64 bits. Here we only compute the number of bytes. Do a double word increment. */ ctx->total[0] += len; if (ctx->total[0] < len) ++ctx->total[1]; /* Process all bytes in the buffer with 64 bytes in each round of the loop. */ while (words < endp) { md5_uint32 *cwp = correct_words; md5_uint32 A_save = A; md5_uint32 B_save = B; md5_uint32 C_save = C; md5_uint32 D_save = D; /* First round: using the given function, the context and a constant the next context is computed. Because the algorithms processing unit is a 32-bit word and it is determined to work on words in little endian byte order we perhaps have to change the byte order before the computation. To reduce the work for the next steps we store the swapped words in the array CORRECT_WORDS. */ #define OP(a, b, c, d, s, T) \ do \ { \ a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ ++words; \ CYCLIC (a, s); \ a += b; \ } \ while (0) /* It is unfortunate that C does not provide an operator for cyclic rotation. Hope the C compiler is smart enough. */ #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) /* Before we start, one word to the strange constants. They are defined in RFC 1321 as T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 */ /* Round 1. */ OP (A, B, C, D, 7, 0xd76aa478); OP (D, A, B, C, 12, 0xe8c7b756); OP (C, D, A, B, 17, 0x242070db); OP (B, C, D, A, 22, 0xc1bdceee); OP (A, B, C, D, 7, 0xf57c0faf); OP (D, A, B, C, 12, 0x4787c62a); OP (C, D, A, B, 17, 0xa8304613); OP (B, C, D, A, 22, 0xfd469501); OP (A, B, C, D, 7, 0x698098d8); OP (D, A, B, C, 12, 0x8b44f7af); OP (C, D, A, B, 17, 0xffff5bb1); OP (B, C, D, A, 22, 0x895cd7be); OP (A, B, C, D, 7, 0x6b901122); OP (D, A, B, C, 12, 0xfd987193); OP (C, D, A, B, 17, 0xa679438e); OP (B, C, D, A, 22, 0x49b40821); /* For the second to fourth round we have the possibly swapped words in CORRECT_WORDS. Redefine the macro to take an additional first argument specifying the function to use. */ #undef OP #define OP(f, a, b, c, d, k, s, T) \ do \ { \ a += f (b, c, d) + correct_words[k] + T; \ CYCLIC (a, s); \ a += b; \ } \ while (0) /* Round 2. */ OP (FG, A, B, C, D, 1, 5, 0xf61e2562); OP (FG, D, A, B, C, 6, 9, 0xc040b340); OP (FG, C, D, A, B, 11, 14, 0x265e5a51); OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); OP (FG, A, B, C, D, 5, 5, 0xd62f105d); OP (FG, D, A, B, C, 10, 9, 0x02441453); OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); OP (FG, D, A, B, C, 14, 9, 0xc33707d6); OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); OP (FG, B, C, D, A, 8, 20, 0x455a14ed); OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); OP (FG, C, D, A, B, 7, 14, 0x676f02d9); OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); /* Round 3. */ OP (FH, A, B, C, D, 5, 4, 0xfffa3942); OP (FH, D, A, B, C, 8, 11, 0x8771f681); OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); OP (FH, B, C, D, A, 14, 23, 0xfde5380c); OP (FH, A, B, C, D, 1, 4, 0xa4beea44); OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); OP (FH, B, C, D, A, 6, 23, 0x04881d05); OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); /* Round 4. */ OP (FI, A, B, C, D, 0, 6, 0xf4292244); OP (FI, D, A, B, C, 7, 10, 0x432aff97); OP (FI, C, D, A, B, 14, 15, 0xab9423a7); OP (FI, B, C, D, A, 5, 21, 0xfc93a039); OP (FI, A, B, C, D, 12, 6, 0x655b59c3); OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); OP (FI, C, D, A, B, 10, 15, 0xffeff47d); OP (FI, B, C, D, A, 1, 21, 0x85845dd1); OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); OP (FI, C, D, A, B, 6, 15, 0xa3014314); OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); OP (FI, A, B, C, D, 4, 6, 0xf7537e82); OP (FI, D, A, B, C, 11, 10, 0xbd3af235); OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); OP (FI, B, C, D, A, 9, 21, 0xeb86d391); /* Add the starting values of the context. */ A += A_save; B += B_save; C += C_save; D += D_save; } /* Put checksum in context given as argument. */ ctx->A = A; ctx->B = B; ctx->C = C; ctx->D = D; } sane-backends-1.0.29/lib/inet_pton.c0000666000000000000000000000163213615534521014114 00000000000000#include "../include/sane/config.h" #ifndef HAVE_INET_PTON #include #include #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #include #include #endif int inet_pton (int af, const char *src, void *dst) { if (af == AF_INET) { #if defined(HAVE_INET_ATON) int result; struct in_addr in; result = inet_aton (src, &in); if (result) { memcpy (dst, &in.s_addr, sizeof (in.s_addr)); return 1; } else return 0; #elif defined(HAVE_INET_ADDR) # if !defined(INADDR_NONE) # define INADDR_NONE -1 # endif /* !defined(INADDR_NONE) */ u_int32_t in; in = inet_addr (src); if (in != INADDR_NONE) { memcpy (dst, &in, sizeof (in)); return 1; } else return 0; #endif /* defined(HAVE_INET_ATON) */ } return -1; } #endif /* !HAVE_INET_PTON */ sane-backends-1.0.29/frontend/0000755000000000000000000000000013615535552013101 500000000000000sane-backends-1.0.29/frontend/sicc.h0000666000000000000000000000156613615534521014122 00000000000000/* Load an ICC profile for embedding in an output file Copyright (C) 2017 Aaron Muir Hamilton 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void * sanei_load_icc_profile (const char *path, size_t *size); sane-backends-1.0.29/frontend/saned.c0000666000000000000000000024570013615534521014266 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Andreas Beck Copyright (C) 2001 - 2004 Henning Meier-Geinitz Copyright (C) 2003, 2008 Julien BLACHE AF-independent + IPv6 code, standalone mode This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The SANE network daemon. This is the counterpart to the NET backend. */ #ifdef _AIX # include "../include/lalloca.h" /* MUST come first for AIX! */ #endif #include "../include/sane/config.h" #include "../include/lalloca.h" #include #if defined(HAVE_GETADDRINFO) && defined (HAVE_GETNAMEINFO) # define SANED_USES_AF_INDEP # ifdef HAS_SS_FAMILY # define SS_FAMILY(ss) ss.ss_family # elif defined(HAS___SS_FAMILY) # define SS_FAMILY(ss) ss.__ss_family # else /* fallback to the old, IPv4-only code */ # undef SANED_USES_AF_INDEP # undef ENABLE_IPV6 # endif #else # undef ENABLE_IPV6 #endif /* HAVE_GETADDRINFO && HAVE_GETNAMEINFO */ #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_LIBC_H # include /* NeXTStep/OpenStep */ #endif #ifdef HAVE_SYS_SELECT_H # include #endif #include #include #include #include #include #include #include #include #include #include #include "lgetopt.h" #if defined(HAVE_SYS_POLL_H) && defined(HAVE_POLL) # include #else /* * This replacement poll() using select() is only designed to cover * our needs in run_standalone(). It should probably be extended... */ struct pollfd { int fd; short events; short revents; }; #define POLLIN 0x0001 #define POLLERR 0x0002 int poll (struct pollfd *ufds, unsigned int nfds, int timeout); int poll (struct pollfd *ufds, unsigned int nfds, int timeout) { struct pollfd *fdp; fd_set rfds; fd_set efds; struct timeval tv; int maxfd = 0; unsigned int i; int ret; tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000; FD_ZERO (&rfds); FD_ZERO (&efds); for (i = 0, fdp = ufds; i < nfds; i++, fdp++) { fdp->revents = 0; if (fdp->events & POLLIN) FD_SET (fdp->fd, &rfds); FD_SET (fdp->fd, &efds); maxfd = (fdp->fd > maxfd) ? fdp->fd : maxfd; } maxfd++; ret = select (maxfd, &rfds, NULL, &efds, &tv); if (ret < 0) return ret; for (i = 0, fdp = ufds; i < nfds; i++, fdp++) { if (fdp->events & POLLIN) if (FD_ISSET (fdp->fd, &rfds)) fdp->revents |= POLLIN; if (FD_ISSET (fdp->fd, &efds)) fdp->revents |= POLLERR; } return ret; } #endif /* HAVE_SYS_POLL_H && HAVE_POLL */ #ifdef WITH_AVAHI # include # include # include # include # include # include # define SANED_SERVICE_DNS "_sane-port._tcp" # define SANED_NAME "saned" pid_t avahi_pid = -1; char *avahi_svc_name; static AvahiClient *avahi_client = NULL; static AvahiSimplePoll *avahi_poll = NULL; static AvahiEntryGroup *avahi_group = NULL; #endif /* WITH_AVAHI */ #ifdef HAVE_SYSTEMD #include #endif #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_net.h" #include "../include/sane/sanei_codec_bin.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_auth.h" #ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 #endif #ifndef IN_LOOPBACK # define IN_LOOPBACK(addr) (addr == 0x7f000001L) #endif #ifdef ENABLE_IPV6 # ifndef IN6_IS_ADDR_LOOPBACK # define IN6_IS_ADDR_LOOPBACK(a) \ (((const uint32_t *) (a))[0] == 0 \ && ((const uint32_t *) (a))[1] == 0 \ && ((const uint32_t *) (a))[2] == 0 \ && ((const uint32_t *) (a))[3] == htonl (1)) # endif # ifndef IN6_IS_ADDR_V4MAPPED # define IN6_IS_ADDR_V4MAPPED(a) \ ((((const uint32_t *) (a))[0] == 0) \ && (((const uint32_t *) (a))[1] == 0) \ && (((const uint32_t *) (a))[2] == htonl (0xffff))) # endif #endif /* ENABLE_IPV6 */ #ifndef MAXHOSTNAMELEN # define MAXHOSTNAMELEN 120 #endif #ifndef PATH_MAX # define PATH_MAX 1024 #endif struct saned_child { pid_t pid; struct saned_child *next; }; struct saned_child *children; int numchildren; #define SANED_CONFIG_FILE "saned.conf" #define SANED_PID_FILE "/var/run/saned.pid" #define SANED_SERVICE_NAME "sane-port" #define SANED_SERVICE_PORT 6566 #define SANED_SERVICE_PORT_S "6566" typedef struct { u_int inuse:1; /* is this handle in use? */ u_int scanning:1; /* are we scanning? */ u_int docancel:1; /* cancel the current scan */ SANE_Handle handle; /* backends handle */ } Handle; static SANE_Net_Procedure_Number current_request; static const char *prog_name; static int can_authorize; static Wire wire; static int num_handles; static int debug; static int run_mode; static int run_foreground; static int run_once; static int data_connect_timeout = 4000; static Handle *handle; static char *bind_addr; static union { int w; u_char ch; } byte_order; /* The default-user name. This is not used to imply any rights. All it does is save a remote user some work by reducing the amount of text s/he has to type when authentication is requested. */ static const char *default_username = "saned-user"; static char *remote_ip; /* data port range */ static in_port_t data_port_lo; static in_port_t data_port_hi; #ifdef SANED_USES_AF_INDEP static union { struct sockaddr_storage ss; struct sockaddr sa; struct sockaddr_in sin; #ifdef ENABLE_IPV6 struct sockaddr_in6 sin6; #endif } remote_address; static int remote_address_len; #else static struct in_addr remote_address; #endif /* SANED_USES_AF_INDEP */ #ifndef _PATH_HEQUIV # define _PATH_HEQUIV "/etc/hosts.equiv" #endif static const char *config_file_names[] = { _PATH_HEQUIV, SANED_CONFIG_FILE }; static SANE_Bool log_to_syslog = SANE_TRUE; /* forward declarations: */ static int process_request (Wire * w); #define SANED_RUN_INETD 0 #define SANED_RUN_ALONE 1 #define DBG_ERR 1 #define DBG_WARN 2 #define DBG_MSG 3 #define DBG_INFO 4 #define DBG_DBG 5 #define DBG saned_debug_call static void saned_debug_call (int level, const char *fmt, ...) { #ifndef NDEBUG va_list ap; va_start (ap, fmt); if (debug >= level) { if (log_to_syslog) { /* print to syslog */ vsyslog (LOG_DEBUG, fmt, ap); } else { /* print to stderr */ fprintf (stderr, "[saned] "); vfprintf (stderr, fmt, ap); } } va_end (ap); #endif } static void reset_watchdog (void) { if (!debug) alarm (3600); } static void auth_callback (SANE_String_Const res, SANE_Char *username, SANE_Char *password) { SANE_Net_Procedure_Number procnum; SANE_Authorization_Req req; SANE_Word word, ack = 0; memset (username, 0, SANE_MAX_USERNAME_LEN); memset (password, 0, SANE_MAX_PASSWORD_LEN); if (!can_authorize) { DBG (DBG_WARN, "auth_callback: called during non-authorizable RPC (resource=%s)\n", res); return; } if (wire.status) { DBG(DBG_ERR, "auth_callback: bad status %d\n", wire.status); return; } switch (current_request) { case SANE_NET_OPEN: { SANE_Open_Reply reply; memset (&reply, 0, sizeof (reply)); reply.resource_to_authorize = (char *) res; sanei_w_reply (&wire, (WireCodecFunc) sanei_w_open_reply, &reply); } break; case SANE_NET_CONTROL_OPTION: { SANE_Control_Option_Reply reply; memset (&reply, 0, sizeof (reply)); reply.resource_to_authorize = (char *) res; sanei_w_reply (&wire, (WireCodecFunc) sanei_w_control_option_reply, &reply); } break; case SANE_NET_START: { SANE_Start_Reply reply; memset (&reply, 0, sizeof (reply)); reply.resource_to_authorize = (char *) res; sanei_w_reply (&wire, (WireCodecFunc) sanei_w_start_reply, &reply); } break; default: DBG (DBG_WARN, "auth_callback: called for unexpected request %d (resource=%s)\n", current_request, res); break; } if (wire.status) { DBG(DBG_ERR, "auth_callback: bad status %d\n", wire.status); return; } reset_watchdog (); sanei_w_set_dir (&wire, WIRE_DECODE); sanei_w_word (&wire, &word); if (wire.status) { DBG(DBG_ERR, "auth_callback: bad status %d\n", wire.status); return; } procnum = word; if (procnum != SANE_NET_AUTHORIZE) { DBG (DBG_WARN, "auth_callback: bad procedure number %d " "(expected: %d, resource=%s)\n", procnum, SANE_NET_AUTHORIZE, res); return; } sanei_w_authorization_req (&wire, &req); if (wire.status) { DBG(DBG_ERR, "auth_callback: bad status %d\n", wire.status); return; } if (req.username) strcpy (username, req.username); if (req.password) strcpy (password, req.password); if (!req.resource || strcmp (req.resource, res) != 0) { DBG (DBG_MSG, "auth_callback: got auth for resource %s (expected resource=%s)\n", res, req.resource); } sanei_w_free (&wire, (WireCodecFunc) sanei_w_authorization_req, &req); sanei_w_reply (&wire, (WireCodecFunc) sanei_w_word, &ack); } static void quit (int signum) { static int running = 0; int i; if (signum) DBG (DBG_ERR, "quit: received signal %d\n", signum); if (running) { DBG (DBG_ERR, "quit: already active, returning\n"); return; } running = 1; for (i = 0; i < num_handles; ++i) if (handle[i].inuse) sane_close (handle[i].handle); sane_exit (); sanei_w_exit (&wire); if (handle) free (handle); DBG (DBG_WARN, "quit: exiting\n"); if (log_to_syslog) closelog (); exit (EXIT_SUCCESS); /* This is a nowait-daemon. */ } static SANE_Word get_free_handle (void) { # define ALLOC_INCREMENT 16 static int h, last_handle_checked = -1; if (num_handles > 0) { h = last_handle_checked + 1; do { if (h >= num_handles) h = 0; if (!handle[h].inuse) { last_handle_checked = h; memset (handle + h, 0, sizeof (handle[0])); handle[h].inuse = 1; return h; } ++h; } while (h != last_handle_checked); } /* we're out of handles---alloc some more: */ last_handle_checked = num_handles - 1; num_handles += ALLOC_INCREMENT; if (handle) handle = realloc (handle, num_handles * sizeof (handle[0])); else handle = malloc (num_handles * sizeof (handle[0])); if (!handle) return -1; memset (handle + last_handle_checked + 1, 0, ALLOC_INCREMENT * sizeof (handle[0])); return get_free_handle (); # undef ALLOC_INCREMENT } static void close_handle (int h) { if (h >= 0 && handle[h].inuse) { sane_close (handle[h].handle); handle[h].inuse = 0; } } static SANE_Word decode_handle (Wire * w, const char *op) { SANE_Word h; sanei_w_word (w, &h); if (w->status || (unsigned) h >= (unsigned) num_handles || !handle[h].inuse) { DBG (DBG_ERR, "decode_handle: %s: error while decoding handle argument " "(h=%d, %s)\n", op, h, strerror (w->status)); return -1; } return h; } /* Convert a number of bits to an 8-bit bitmask */ static unsigned int cidrtomask[9] = { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF }; #ifdef SANED_USES_AF_INDEP static SANE_Bool check_v4_in_range (struct sockaddr_in *sin, char *base_ip, char *netmask) { int cidr; int i, err; char *end; uint32_t mask; struct sockaddr_in *base; struct addrinfo hints; struct addrinfo *res; SANE_Bool ret = SANE_FALSE; cidr = -1; cidr = strtol (netmask, &end, 10); /* Sanity check on the cidr value */ if ((cidr < 0) || (cidr > 32) || (end == netmask)) { DBG (DBG_ERR, "check_v4_in_range: invalid CIDR value (%s) !\n", netmask); return SANE_FALSE; } mask = 0; cidr -= 8; /* Build a bitmask out of the CIDR value */ for (i = 3; cidr >= 0; i--) { mask |= (0xff << (8 * i)); cidr -= 8; } if (cidr < 0) mask |= (cidrtomask[cidr + 8] << (8 * i)); mask = htonl (mask); /* get a sockaddr_in representing the base IP address */ memset (&hints, 0, sizeof (struct addrinfo)); hints.ai_flags = AI_NUMERICHOST; hints.ai_family = PF_INET; err = getaddrinfo (base_ip, NULL, &hints, &res); if (err) { DBG (DBG_DBG, "check_v4_in_range: getaddrinfo() failed: %s\n", gai_strerror (err)); return SANE_FALSE; } base = (struct sockaddr_in *) res->ai_addr; /* * Check that the address belongs to the specified subnet, using the bitmask. * The address is represented by a 32bit integer. */ if ((base->sin_addr.s_addr & mask) == (sin->sin_addr.s_addr & mask)) ret = SANE_TRUE; freeaddrinfo (res); return ret; } # ifdef ENABLE_IPV6 static SANE_Bool check_v6_in_range (struct sockaddr_in6 *sin6, char *base_ip, char *netmask) { int cidr; int i, err; unsigned int mask[16]; char *end; struct sockaddr_in6 *base; struct addrinfo hints; struct addrinfo *res; SANE_Bool ret = SANE_TRUE; cidr = -1; cidr = strtol (netmask, &end, 10); /* Sanity check on the cidr value */ if ((cidr < 0) || (cidr > 128) || (end == netmask)) { DBG (DBG_ERR, "check_v6_in_range: invalid CIDR value (%s) !\n", netmask); return SANE_FALSE; } memset (mask, 0, (16 * sizeof (unsigned int))); cidr -= 8; /* Build a bitmask out of the CIDR value */ for (i = 0; cidr >= 0; i++) { mask[i] = 0xff; cidr -= 8; } if (cidr < 0) mask[i] = cidrtomask[cidr + 8]; /* get a sockaddr_in6 representing the base IP address */ memset (&hints, 0, sizeof (struct addrinfo)); hints.ai_flags = AI_NUMERICHOST; hints.ai_family = PF_INET6; err = getaddrinfo (base_ip, NULL, &hints, &res); if (err) { DBG (DBG_DBG, "check_v6_in_range: getaddrinfo() failed: %s\n", gai_strerror (err)); return SANE_FALSE; } base = (struct sockaddr_in6 *) res->ai_addr; /* * Check that the address belongs to the specified subnet. * The address is reprensented by an array of 16 8bit integers. */ for (i = 0; i < 16; i++) { if ((base->sin6_addr.s6_addr[i] & mask[i]) != (sin6->sin6_addr.s6_addr[i] & mask[i])) { ret = SANE_FALSE; break; } } freeaddrinfo (res); return ret; } # endif /* ENABLE_IPV6 */ #else /* !SANED_USES_AF_INDEP */ static SANE_Bool check_v4_in_range (struct in_addr *inaddr, struct in_addr *base, char *netmask) { int cidr; int i; char *end; uint32_t mask; SANE_Bool ret = SANE_FALSE; cidr = -1; cidr = strtol (netmask, &end, 10); /* sanity check on the cidr value */ if ((cidr < 0) || (cidr > 32) || (end == netmask)) { DBG (DBG_ERR, "check_v4_in_range: invalid CIDR value (%s) !\n", netmask); return SANE_FALSE; } mask = 0; cidr -= 8; /* Build a bitmask out of the CIDR value */ for (i = 3; cidr >= 0; i--) { mask |= (0xff << (8 * i)); cidr -= 8; } if (cidr < 0) mask |= (cidrtomask[cidr + 8] << (8 * i)); mask = htonl (mask); /* * Check that the address belongs to the specified subnet, using the bitmask. * The address is represented by a 32bit integer. */ if ((base->s_addr & mask) == (inaddr->s_addr & mask)) ret = SANE_TRUE; return ret; } #endif /* SANED_USES_AF_INDEP */ /* Access control */ #ifdef SANED_USES_AF_INDEP static SANE_Status check_host (int fd) { struct sockaddr_in *sin = NULL; #ifdef ENABLE_IPV6 struct sockaddr_in6 *sin6; #endif /* ENABLE_IPV6 */ struct addrinfo hints; struct addrinfo *res; struct addrinfo *resp; int j, access_ok = 0; int err; char text_addr[64]; #ifdef ENABLE_IPV6 SANE_Bool IPv4map = SANE_FALSE; char *remote_ipv4 = NULL; /* in case we have an IPv4-mapped address (eg ::ffff:127.0.0.1) */ char *tmp; struct addrinfo *remote_ipv4_addr = NULL; #endif /* ENABLE_IPV6 */ char config_line_buf[1024]; char *config_line; char *netmask; char hostname[MAXHOSTNAMELEN]; int len; FILE *fp; /* Get address of remote host */ remote_address_len = sizeof (remote_address.ss); if (getpeername (fd, &remote_address.sa, (socklen_t *) &remote_address_len) < 0) { DBG (DBG_ERR, "check_host: getpeername failed: %s\n", strerror (errno)); remote_ip = strdup ("[error]"); return SANE_STATUS_INVAL; } err = getnameinfo (&remote_address.sa, remote_address_len, hostname, sizeof (hostname), NULL, 0, NI_NUMERICHOST); if (err) { DBG (DBG_DBG, "check_host: getnameinfo failed: %s\n", gai_strerror(err)); remote_ip = strdup ("[error]"); return SANE_STATUS_INVAL; } else remote_ip = strdup (hostname); #ifdef ENABLE_IPV6 sin6 = &remote_address.sin6; if (IN6_IS_ADDR_V4MAPPED ((struct in6_addr *)sin6->sin6_addr.s6_addr)) { DBG (DBG_DBG, "check_host: detected an IPv4-mapped address\n"); remote_ipv4 = remote_ip + 7; IPv4map = SANE_TRUE; memset (&hints, 0, sizeof (struct addrinfo)); hints.ai_flags = AI_NUMERICHOST; hints.ai_family = PF_INET; err = getaddrinfo (remote_ipv4, NULL, &hints, &res); if (err) { DBG (DBG_DBG, "check_host: getaddrinfo() failed: %s\n", gai_strerror (err)); IPv4map = SANE_FALSE; /* we failed, remote_ipv4_addr points to nothing */ } else { remote_ipv4_addr = res; sin = (struct sockaddr_in *)res->ai_addr; } } #endif /* ENABLE_IPV6 */ DBG (DBG_WARN, "check_host: access by remote host: %s\n", remote_ip); /* Always allow access from local host. Do it here to avoid DNS lookups and reading saned.conf. */ #ifdef ENABLE_IPV6 if (IPv4map == SANE_TRUE) { if (IN_LOOPBACK (ntohl (sin->sin_addr.s_addr))) { DBG (DBG_MSG, "check_host: remote host is IN_LOOPBACK: access granted\n"); freeaddrinfo (remote_ipv4_addr); return SANE_STATUS_GOOD; } freeaddrinfo (remote_ipv4_addr); } #endif /* ENABLE_IPV6 */ sin = &remote_address.sin; switch (SS_FAMILY(remote_address.ss)) { case AF_INET: if (IN_LOOPBACK (ntohl (sin->sin_addr.s_addr))) { DBG (DBG_MSG, "check_host: remote host is IN_LOOPBACK: access granted\n"); return SANE_STATUS_GOOD; } break; #ifdef ENABLE_IPV6 case AF_INET6: if (IN6_IS_ADDR_LOOPBACK ((struct in6_addr *)sin6->sin6_addr.s6_addr)) { DBG (DBG_MSG, "check_host: remote host is IN6_LOOPBACK: access granted\n"); return SANE_STATUS_GOOD; } break; #endif /* ENABLE_IPV6 */ default: break; } DBG (DBG_DBG, "check_host: remote host is not IN_LOOPBACK" #ifdef ENABLE_IPV6 " nor IN6_LOOPBACK" #endif /* ENABLE_IPV6 */ "\n"); /* Get name of local host */ if (gethostname (hostname, sizeof (hostname)) < 0) { DBG (DBG_ERR, "check_host: gethostname failed: %s\n", strerror (errno)); return SANE_STATUS_INVAL; } DBG (DBG_DBG, "check_host: local hostname: %s\n", hostname); /* Get local addresses */ memset (&hints, 0, sizeof (hints)); hints.ai_flags = AI_CANONNAME; #ifdef ENABLE_IPV6 hints.ai_family = PF_UNSPEC; #else hints.ai_family = PF_INET; #endif /* ENABLE_IPV6 */ err = getaddrinfo (hostname, NULL, &hints, &res); if (err) { DBG (DBG_ERR, "check_host: getaddrinfo for local hostname failed: %s\n", gai_strerror (err)); /* Proceed even if the local hostname does not resolve */ if (err != EAI_NONAME) return SANE_STATUS_INVAL; } else { for (resp = res; resp != NULL; resp = resp->ai_next) { DBG (DBG_DBG, "check_host: local hostname(s) (from DNS): %s\n", resp->ai_canonname); err = getnameinfo (resp->ai_addr, resp->ai_addrlen, text_addr, sizeof (text_addr), NULL, 0, NI_NUMERICHOST); if (err) strncpy (text_addr, "[error]", 8); #ifdef ENABLE_IPV6 if ((strcasecmp (text_addr, remote_ip) == 0) || ((IPv4map == SANE_TRUE) && (strcmp (text_addr, remote_ipv4) == 0))) #else if (strcmp (text_addr, remote_ip) == 0) #endif /* ENABLE_IPV6 */ { DBG (DBG_MSG, "check_host: remote host has same addr as local: access granted\n"); freeaddrinfo (res); res = NULL; return SANE_STATUS_GOOD; } } freeaddrinfo (res); res = NULL; DBG (DBG_DBG, "check_host: remote host doesn't have same addr as local\n"); } /* must be a remote host: check contents of PATH_NET_CONFIG or /etc/hosts.equiv if former doesn't exist: */ for (j = 0; j < NELEMS (config_file_names); ++j) { DBG (DBG_DBG, "check_host: opening config file: %s\n", config_file_names[j]); if (config_file_names[j][0] == '/') fp = fopen (config_file_names[j], "r"); else fp = sanei_config_open (config_file_names[j]); if (!fp) { DBG (DBG_MSG, "check_host: can't open config file: %s (%s)\n", config_file_names[j], strerror (errno)); continue; } while (!access_ok && sanei_config_read (config_line_buf, sizeof (config_line_buf), fp)) { config_line = config_line_buf; /* from now on, use a pointer */ DBG (DBG_DBG, "check_host: config file line: `%s'\n", config_line); if (config_line[0] == '#') continue; /* ignore comments */ if (strchr (config_line, '=')) continue; /* ignore lines with an = sign */ len = strlen (config_line); if (!len) continue; /* ignore empty lines */ /* look for a subnet specification */ netmask = strchr (config_line, '/'); if (netmask != NULL) { *netmask = '\0'; netmask++; DBG (DBG_DBG, "check_host: subnet with base IP = %s, CIDR netmask = %s\n", config_line, netmask); } #ifdef ENABLE_IPV6 /* IPv6 addresses are enclosed in [] */ if (*config_line == '[') { config_line++; tmp = strchr (config_line, ']'); if (tmp == NULL) { DBG (DBG_ERR, "check_host: malformed IPv6 address in config file, skipping: [%s\n", config_line); continue; } *tmp = '\0'; } #endif /* ENABLE_IPV6 */ if (strcmp (config_line, "+") == 0) { access_ok = 1; DBG (DBG_DBG, "check_host: access granted from any host (`+')\n"); } /* compare remote_ip (remote IP address) to the config_line */ else if (strcasecmp (config_line, remote_ip) == 0) { access_ok = 1; DBG (DBG_DBG, "check_host: access granted from IP address %s\n", remote_ip); } #ifdef ENABLE_IPV6 else if ((IPv4map == SANE_TRUE) && (strcmp (config_line, remote_ipv4) == 0)) { access_ok = 1; DBG (DBG_DBG, "check_host: access granted from IP address %s (IPv4-mapped)\n", remote_ip); } /* handle IP ranges, take care of the IPv4map stuff */ else if (netmask != NULL) { if (strchr (config_line, ':') != NULL) /* is a v6 address */ { if (SS_FAMILY(remote_address.ss) == AF_INET6) { if (check_v6_in_range (sin6, config_line, netmask)) { access_ok = 1; DBG (DBG_DBG, "check_host: access granted from IP address %s (in subnet [%s]/%s)\n", remote_ip, config_line, netmask); } } } else /* is a v4 address */ { if (IPv4map == SANE_TRUE) { /* get a sockaddr_in representing the v4-mapped IP address */ memset (&hints, 0, sizeof (struct addrinfo)); hints.ai_flags = AI_NUMERICHOST; hints.ai_family = PF_INET; err = getaddrinfo (remote_ipv4, NULL, &hints, &res); if (err) DBG (DBG_DBG, "check_host: getaddrinfo() failed: %s\n", gai_strerror (err)); else sin = (struct sockaddr_in *)res->ai_addr; } if ((SS_FAMILY(remote_address.ss) == AF_INET) || (IPv4map == SANE_TRUE)) { if (check_v4_in_range (sin, config_line, netmask)) { DBG (DBG_DBG, "check_host: access granted from IP address %s (in subnet %s/%s)\n", ((IPv4map == SANE_TRUE) ? remote_ipv4 : remote_ip), config_line, netmask); access_ok = 1; } else { /* restore the old sin pointer */ sin = &remote_address.sin; } if (res != NULL) { freeaddrinfo (res); res = NULL; } } } } #else /* !ENABLE_IPV6 */ /* handle IP ranges */ else if (netmask != NULL) { if (check_v4_in_range (sin, config_line, netmask)) { access_ok = 1; DBG (DBG_DBG, "check_host: access granted from IP address %s (in subnet %s/%s)\n", remote_ip, config_line, netmask); } } #endif /* ENABLE_IPV6 */ else { memset (&hints, 0, sizeof (hints)); hints.ai_flags = AI_CANONNAME; #ifdef ENABLE_IPV6 hints.ai_family = PF_UNSPEC; #else hints.ai_family = PF_INET; #endif /* ENABLE_IPV6 */ err = getaddrinfo (config_line, NULL, &hints, &res); if (err) { DBG (DBG_DBG, "check_host: getaddrinfo for `%s' failed: %s\n", config_line, gai_strerror (err)); DBG (DBG_MSG, "check_host: entry isn't an IP address " "and can't be found in DNS\n"); continue; } else { for (resp = res; resp != NULL; resp = resp->ai_next) { err = getnameinfo (resp->ai_addr, resp->ai_addrlen, text_addr, sizeof (text_addr), NULL, 0, NI_NUMERICHOST); if (err) strncpy (text_addr, "[error]", 8); DBG (DBG_MSG, "check_host: DNS lookup returns IP address: %s\n", text_addr); #ifdef ENABLE_IPV6 if ((strcasecmp (text_addr, remote_ip) == 0) || ((IPv4map == SANE_TRUE) && (strcmp (text_addr, remote_ipv4) == 0))) #else if (strcmp (text_addr, remote_ip) == 0) #endif /* ENABLE_IPV6 */ access_ok = 1; if (access_ok) break; } freeaddrinfo (res); res = NULL; } } } fclose (fp); } if (access_ok) return SANE_STATUS_GOOD; return SANE_STATUS_ACCESS_DENIED; } #else /* !SANED_USES_AF_INDEP */ static SANE_Status check_host (int fd) { struct sockaddr_in sin; int j, access_ok = 0; struct hostent *he; char text_addr[64]; char config_line_buf[1024]; char *config_line; char *netmask; char hostname[MAXHOSTNAMELEN]; char *r_hostname; static struct in_addr config_line_address; int len; FILE *fp; /* Get address of remote host */ len = sizeof (sin); if (getpeername (fd, (struct sockaddr *) &sin, (socklen_t *) &len) < 0) { DBG (DBG_ERR, "check_host: getpeername failed: %s\n", strerror (errno)); remote_ip = strdup ("[error]"); return SANE_STATUS_INVAL; } r_hostname = inet_ntoa (sin.sin_addr); remote_ip = strdup (r_hostname); DBG (DBG_WARN, "check_host: access by remote host: %s\n", remote_ip); /* Save remote address for check of control and data connections */ memcpy (&remote_address, &sin.sin_addr, sizeof (remote_address)); /* Always allow access from local host. Do it here to avoid DNS lookups and reading saned.conf. */ if (IN_LOOPBACK (ntohl (sin.sin_addr.s_addr))) { DBG (DBG_MSG, "check_host: remote host is IN_LOOPBACK: access accepted\n"); return SANE_STATUS_GOOD; } DBG (DBG_DBG, "check_host: remote host is not IN_LOOPBACK\n"); /* Get name of local host */ if (gethostname (hostname, sizeof (hostname)) < 0) { DBG (DBG_ERR, "check_host: gethostname failed: %s\n", strerror (errno)); return SANE_STATUS_INVAL; } DBG (DBG_DBG, "check_host: local hostname: %s\n", hostname); /* Get local address */ he = gethostbyname (hostname); if (!he) { DBG (DBG_ERR, "check_host: gethostbyname for local hostname failed: %s\n", hstrerror (h_errno)); /* Proceed even if the local hostname doesn't resolve */ if (h_errno != HOST_NOT_FOUND) return SANE_STATUS_INVAL; } else { DBG (DBG_DBG, "check_host: local hostname (from DNS): %s\n", he->h_name); if ((he->h_length == 4) || (he->h_addrtype == AF_INET)) { if (!inet_ntop (he->h_addrtype, he->h_addr_list[0], text_addr, sizeof (text_addr))) strcpy (text_addr, "[error]"); DBG (DBG_DBG, "check_host: local host address (from DNS): %s\n", text_addr); if (memcmp (he->h_addr_list[0], &remote_address.s_addr, 4) == 0) { DBG (DBG_MSG, "check_host: remote host has same addr as local: " "access accepted\n"); return SANE_STATUS_GOOD; } } else { DBG (DBG_ERR, "check_host: can't get local address " "(only IPv4 is supported)\n"); } DBG (DBG_DBG, "check_host: remote host doesn't have same addr as local\n"); } /* must be a remote host: check contents of PATH_NET_CONFIG or /etc/hosts.equiv if former doesn't exist: */ for (j = 0; j < NELEMS (config_file_names); ++j) { DBG (DBG_DBG, "check_host: opening config file: %s\n", config_file_names[j]); if (config_file_names[j][0] == '/') fp = fopen (config_file_names[j], "r"); else fp = sanei_config_open (config_file_names[j]); if (!fp) { DBG (DBG_MSG, "check_host: can't open config file: %s (%s)\n", config_file_names[j], strerror (errno)); continue; } while (!access_ok && sanei_config_read (config_line_buf, sizeof (config_line_buf), fp)) { config_line = config_line_buf; /* from now on, use a pointer */ DBG (DBG_DBG, "check_host: config file line: `%s'\n", config_line); if (config_line[0] == '#') continue; /* ignore comments */ if (strchr (config_line, '=')) continue; /* ignore lines with an = sign */ len = strlen (config_line); if (!len) continue; /* ignore empty lines */ /* look for a subnet specification */ netmask = strchr (config_line, '/'); if (netmask != NULL) { *netmask = '\0'; netmask++; DBG (DBG_DBG, "check_host: subnet with base IP = %s, CIDR netmask = %s\n", config_line, netmask); } if (strcmp (config_line, "+") == 0) { access_ok = 1; DBG (DBG_DBG, "check_host: access accepted from any host (`+')\n"); } else { if (inet_pton (AF_INET, config_line, &config_line_address) > 0) { if (memcmp (&remote_address.s_addr, &config_line_address.s_addr, 4) == 0) access_ok = 1; else if (netmask != NULL) { if (check_v4_in_range (&remote_address, &config_line_address, netmask)) { access_ok = 1; DBG (DBG_DBG, "check_host: access granted from IP address %s (in subnet %s/%s)\n", remote_ip, config_line, netmask); } } } else { DBG (DBG_DBG, "check_host: inet_pton for `%s' failed\n", config_line); he = gethostbyname (config_line); if (!he) { DBG (DBG_DBG, "check_host: gethostbyname for `%s' failed: %s\n", config_line, hstrerror (h_errno)); DBG (DBG_MSG, "check_host: entry isn't an IP address " "and can't be found in DNS\n"); continue; } if (!inet_ntop (he->h_addrtype, he->h_addr_list[0], text_addr, sizeof (text_addr))) strcpy (text_addr, "[error]"); DBG (DBG_MSG, "check_host: DNS lookup returns IP address: %s\n", text_addr); if (memcmp (&remote_address.s_addr, he->h_addr_list[0], 4) == 0) access_ok = 1; } } } fclose (fp); if (access_ok) return SANE_STATUS_GOOD; } return SANE_STATUS_ACCESS_DENIED; } #endif /* SANED_USES_AF_INDEP */ static int init (Wire * w) { SANE_Word word, be_version_code; SANE_Init_Reply reply; SANE_Status status; SANE_Init_Req req; reset_watchdog (); status = check_host (w->io.fd); if (status != SANE_STATUS_GOOD) { DBG (DBG_WARN, "init: access by host %s denied\n", remote_ip); return -1; } else DBG (DBG_MSG, "init: access granted\n"); sanei_w_set_dir (w, WIRE_DECODE); if (w->status) { DBG (DBG_ERR, "init: bad status after sanei_w_set_dir: %d\n", w->status); return -1; } sanei_w_word (w, &word); /* decode procedure number */ if (w->status || word != SANE_NET_INIT) { DBG (DBG_ERR, "init: bad status=%d or procnum=%d\n", w->status, word); return -1; } sanei_w_init_req (w, &req); if (w->status) { DBG (DBG_ERR, "init: bad status after sanei_w_init_req: %d\n", w->status); return -1; } w->version = SANEI_NET_PROTOCOL_VERSION; if (req.username) default_username = strdup (req.username); sanei_w_free (w, (WireCodecFunc) sanei_w_init_req, &req); if (w->status) { DBG (DBG_ERR, "init: bad status after sanei_w_free: %d\n", w->status); return -1; } reply.version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, SANEI_NET_PROTOCOL_VERSION); DBG (DBG_WARN, "init: access granted to %s@%s\n", default_username, remote_ip); if (status == SANE_STATUS_GOOD) { status = sane_init (&be_version_code, auth_callback); if (status != SANE_STATUS_GOOD) DBG (DBG_ERR, "init: failed to initialize backend (%s)\n", sane_strstatus (status)); if (SANE_VERSION_MAJOR (be_version_code) != V_MAJOR) { DBG (DBG_ERR, "init: unexpected backend major version %d (expected %d)\n", SANE_VERSION_MAJOR (be_version_code), V_MAJOR); status = SANE_STATUS_INVAL; } } reply.status = status; if (status != SANE_STATUS_GOOD) reply.version_code = 0; sanei_w_reply (w, (WireCodecFunc) sanei_w_init_reply, &reply); if (w->status || status != SANE_STATUS_GOOD) return -1; return 0; } #ifdef SANED_USES_AF_INDEP static int start_scan (Wire * w, int h, SANE_Start_Reply * reply) { union { struct sockaddr_storage ss; struct sockaddr sa; struct sockaddr_in sin; #ifdef ENABLE_IPV6 struct sockaddr_in6 sin6; #endif /* ENABLE_IPV6 */ } data_addr; struct sockaddr_in *sin; #ifdef ENABLE_IPV6 struct sockaddr_in6 *sin6; #endif /* ENABLE_IPV6 */ SANE_Handle be_handle; int fd, len; in_port_t data_port; int ret = -1; be_handle = handle[h].handle; len = sizeof (data_addr.ss); if (getsockname (w->io.fd, &data_addr.sa, (socklen_t *) &len) < 0) { DBG (DBG_ERR, "start_scan: failed to obtain socket address (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } fd = socket (SS_FAMILY(data_addr.ss), SOCK_STREAM, 0); if (fd < 0) { DBG (DBG_ERR, "start_scan: failed to obtain data socket (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } switch (SS_FAMILY(data_addr.ss)) { case AF_INET: sin = &data_addr.sin; break; #ifdef ENABLE_IPV6 case AF_INET6: sin6 = &data_addr.sin6; break; #endif /* ENABLE_IPV6 */ default: break; } /* Try to bind a port between data_port_lo and data_port_hi for the data connection */ for (data_port = data_port_lo; data_port <= data_port_hi; data_port++) { switch (SS_FAMILY(data_addr.ss)) { case AF_INET: sin->sin_port = htons(data_port); break; #ifdef ENABLE_IPV6 case AF_INET6: sin6->sin6_port = htons(data_port); break; #endif /* ENABLE_IPV6 */ default: break; } DBG (DBG_INFO, "start_scan: trying to bind data port %d\n", data_port); ret = bind (fd, &data_addr.sa, len); if (ret == 0) break; } if (ret < 0) { DBG (DBG_ERR, "start_scan: failed to bind address (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } if (listen (fd, 1) < 0) { DBG (DBG_ERR, "start_scan: failed to make socket listen (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } if (getsockname (fd, &data_addr.sa, (socklen_t *) &len) < 0) { DBG (DBG_ERR, "start_scan: failed to obtain socket address (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } switch (SS_FAMILY(data_addr.ss)) { case AF_INET: sin = &data_addr.sin; reply->port = ntohs (sin->sin_port); break; #ifdef ENABLE_IPV6 case AF_INET6: sin6 = &data_addr.sin6; reply->port = ntohs (sin6->sin6_port); break; #endif /* ENABLE_IPV6 */ default: break; } DBG (DBG_MSG, "start_scan: using port %d for data\n", reply->port); reply->status = sane_start (be_handle); if (reply->status == SANE_STATUS_GOOD) { handle[h].scanning = 1; handle[h].docancel = 0; } return fd; } #else /* !SANED_USES_AF_INDEP */ static int start_scan (Wire * w, int h, SANE_Start_Reply * reply) { struct sockaddr_in sin; SANE_Handle be_handle; int fd, len; in_port_t data_port; int ret; be_handle = handle[h].handle; len = sizeof (sin); if (getsockname (w->io.fd, (struct sockaddr *) &sin, (socklen_t *) &len) < 0) { DBG (DBG_ERR, "start_scan: failed to obtain socket address (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } fd = socket (AF_INET, SOCK_STREAM, 0); if (fd < 0) { DBG (DBG_ERR, "start_scan: failed to obtain data socket (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } /* Try to bind a port between data_port_lo and data_port_hi for the data connection */ for (data_port = data_port_lo; data_port <= data_port_hi; data_port++) { sin.sin_port = htons(data_port); DBG(DBG_INFO, "start_scan: trying to bind data port %d\n", data_port); ret = bind (fd, (struct sockaddr *) &sin, len); if (ret == 0) break; } if (ret < 0) { DBG (DBG_ERR, "start_scan: failed to bind address (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } if (listen (fd, 1) < 0) { DBG (DBG_ERR, "start_scan: failed to make socket listen (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } if (getsockname (fd, (struct sockaddr *) &sin, (socklen_t *) &len) < 0) { DBG (DBG_ERR, "start_scan: failed to obtain socket address (%s)\n", strerror (errno)); reply->status = SANE_STATUS_IO_ERROR; return -1; } reply->port = ntohs (sin.sin_port); DBG (DBG_MSG, "start_scan: using port %d for data\n", reply->port); reply->status = sane_start (be_handle); if (reply->status == SANE_STATUS_GOOD) { handle[h].scanning = 1; handle[h].docancel = 0; } return fd; } #endif /* SANED_USES_AF_INDEP */ static int store_reclen (SANE_Byte * buf, size_t buf_size, int i, size_t reclen) { buf[i++] = (reclen >> 24) & 0xff; if (i >= (int) buf_size) i = 0; buf[i++] = (reclen >> 16) & 0xff; if (i >= (int) buf_size) i = 0; buf[i++] = (reclen >> 8) & 0xff; if (i >= (int) buf_size) i = 0; buf[i++] = (reclen >> 0) & 0xff; if (i >= (int) buf_size) i = 0; return i; } static void do_scan (Wire * w, int h, int data_fd) { int num_fds, be_fd = -1, reader, writer, bytes_in_buf, status_dirty = 0; SANE_Handle be_handle = handle[h].handle; struct timeval tv, *timeout = 0; fd_set rd_set, rd_mask, wr_set, wr_mask; SANE_Byte buf[8192]; SANE_Status status; long int nwritten; SANE_Int length; size_t nbytes; DBG (3, "do_scan: start\n"); FD_ZERO (&rd_mask); FD_SET (w->io.fd, &rd_mask); num_fds = w->io.fd + 1; FD_ZERO (&wr_mask); FD_SET (data_fd, &wr_mask); if (data_fd >= num_fds) num_fds = data_fd + 1; sane_set_io_mode (be_handle, SANE_TRUE); if (sane_get_select_fd (be_handle, &be_fd) == SANE_STATUS_GOOD) { FD_SET (be_fd, &rd_mask); if (be_fd >= num_fds) num_fds = be_fd + 1; } else { memset (&tv, 0, sizeof (tv)); timeout = &tv; } status = SANE_STATUS_GOOD; reader = writer = bytes_in_buf = 0; do { rd_set = rd_mask; wr_set = wr_mask; if (select (num_fds, &rd_set, &wr_set, 0, timeout) < 0) { if (be_fd >= 0 && errno == EBADF) { /* This normally happens when a backend closes a select filedescriptor when reaching the end of file. So pass back this status to the client: */ FD_CLR (be_fd, &rd_mask); be_fd = -1; /* only set status_dirty if EOF hasn't been already detected */ if (status == SANE_STATUS_GOOD) status_dirty = 1; status = SANE_STATUS_EOF; DBG (DBG_INFO, "do_scan: select_fd was closed --> EOF\n"); continue; } else { status = SANE_STATUS_IO_ERROR; DBG (DBG_ERR, "do_scan: select failed (%s)\n", strerror (errno)); break; } } if (bytes_in_buf) { if (FD_ISSET (data_fd, &wr_set)) { if (bytes_in_buf > 0) { /* write more input data */ nbytes = bytes_in_buf; if (writer + nbytes > sizeof (buf)) nbytes = sizeof (buf) - writer; DBG (DBG_INFO, "do_scan: trying to write %d bytes to client\n", nbytes); nwritten = write (data_fd, buf + writer, nbytes); DBG (DBG_INFO, "do_scan: wrote %ld bytes to client\n", nwritten); if (nwritten < 0) { DBG (DBG_ERR, "do_scan: write failed (%s)\n", strerror (errno)); status = SANE_STATUS_CANCELLED; handle[h].docancel = 1; break; } bytes_in_buf -= nwritten; writer += nwritten; if (writer == sizeof (buf)) writer = 0; } } } else if (status == SANE_STATUS_GOOD && (timeout || FD_ISSET (be_fd, &rd_set))) { int i; /* get more input data */ /* reserve 4 bytes to store the length of the data record: */ i = reader; reader += 4; if (reader >= (int) sizeof (buf)) reader -= sizeof(buf); assert (bytes_in_buf == 0); nbytes = sizeof (buf) - 4; if (reader + nbytes > sizeof (buf)) nbytes = sizeof (buf) - reader; DBG (DBG_INFO, "do_scan: trying to read %d bytes from scanner\n", nbytes); status = sane_read (be_handle, buf + reader, nbytes, &length); DBG (DBG_INFO, "do_scan: read %d bytes from scanner\n", length); reset_watchdog (); reader += length; if (reader >= (int) sizeof (buf)) reader = 0; bytes_in_buf += length + 4; if (status != SANE_STATUS_GOOD) { reader = i; /* restore reader index */ status_dirty = 1; DBG (DBG_MSG, "do_scan: status = `%s'\n", sane_strstatus(status)); } else store_reclen (buf, sizeof (buf), i, length); } if (status_dirty && sizeof (buf) - bytes_in_buf >= 5) { status_dirty = 0; reader = store_reclen (buf, sizeof (buf), reader, 0xffffffff); buf[reader] = status; bytes_in_buf += 5; DBG (DBG_MSG, "do_scan: statuscode `%s' was added to buffer\n", sane_strstatus(status)); } if (FD_ISSET (w->io.fd, &rd_set)) { DBG (DBG_MSG, "do_scan: processing RPC request on fd %d\n", w->io.fd); if(process_request (w) < 0) handle[h].docancel = 1; if (handle[h].docancel) break; } } while (status == SANE_STATUS_GOOD || bytes_in_buf > 0 || status_dirty); DBG (DBG_MSG, "do_scan: done, status=%s\n", sane_strstatus (status)); if(handle[h].docancel) sane_cancel (handle[h].handle); handle[h].docancel = 0; handle[h].scanning = 0; } static int process_request (Wire * w) { SANE_Handle be_handle; SANE_Word h, word; int i; DBG (DBG_DBG, "process_request: waiting for request\n"); sanei_w_set_dir (w, WIRE_DECODE); sanei_w_word (w, &word); /* decode procedure number */ if (w->status) { DBG (DBG_ERR, "process_request: bad status %d\n", w->status); return -1; } current_request = word; DBG (DBG_MSG, "process_request: got request %d\n", current_request); switch (current_request) { case SANE_NET_GET_DEVICES: { SANE_Get_Devices_Reply reply; reply.status = sane_get_devices ((const SANE_Device ***) &reply.device_list, SANE_TRUE); sanei_w_reply (w, (WireCodecFunc) sanei_w_get_devices_reply, &reply); } break; case SANE_NET_OPEN: { SANE_Open_Reply reply; SANE_Handle be_handle; SANE_String name, resource; sanei_w_string (w, &name); if (w->status) { DBG (DBG_ERR, "process_request: (open) error while decoding args (%s)\n", strerror (w->status)); return 1; } if (!name) { DBG (DBG_ERR, "process_request: (open) device_name == NULL\n"); reply.status = SANE_STATUS_INVAL; sanei_w_reply (w, (WireCodecFunc) sanei_w_open_reply, &reply); return 1; } can_authorize = 1; resource = strdup (name); if (strlen(resource) == 0) { const SANE_Device **device_list; DBG(DBG_DBG, "process_request: (open) strlen(resource) == 0\n"); free (resource); if ((i = sane_get_devices (&device_list, SANE_TRUE)) != SANE_STATUS_GOOD) { DBG(DBG_ERR, "process_request: (open) sane_get_devices failed\n"); memset (&reply, 0, sizeof (reply)); reply.status = i; sanei_w_reply (w, (WireCodecFunc) sanei_w_open_reply, &reply); break; } if ((device_list == NULL) || (device_list[0] == NULL)) { DBG(DBG_ERR, "process_request: (open) device_list[0] == 0\n"); memset (&reply, 0, sizeof (reply)); reply.status = SANE_STATUS_INVAL; sanei_w_reply (w, (WireCodecFunc) sanei_w_open_reply, &reply); break; } resource = strdup (device_list[0]->name); } if (strchr (resource, ':')) *(strchr (resource, ':')) = 0; if (sanei_authorize (resource, "saned", auth_callback) != SANE_STATUS_GOOD) { DBG (DBG_ERR, "process_request: access to resource `%s' denied\n", resource); free (resource); memset (&reply, 0, sizeof (reply)); /* avoid leaking bits */ reply.status = SANE_STATUS_ACCESS_DENIED; } else { DBG (DBG_MSG, "process_request: access to resource `%s' granted\n", resource); free (resource); memset (&reply, 0, sizeof (reply)); /* avoid leaking bits */ reply.status = sane_open (name, &be_handle); DBG (DBG_MSG, "process_request: sane_open returned: %s\n", sane_strstatus (reply.status)); } if (reply.status == SANE_STATUS_GOOD) { h = get_free_handle (); if (h < 0) reply.status = SANE_STATUS_NO_MEM; else { handle[h].handle = be_handle; reply.handle = h; } } can_authorize = 0; sanei_w_reply (w, (WireCodecFunc) sanei_w_open_reply, &reply); sanei_w_free (w, (WireCodecFunc) sanei_w_string, &name); } break; case SANE_NET_CLOSE: { SANE_Word ack = 0; h = decode_handle (w, "close"); close_handle (h); sanei_w_reply (w, (WireCodecFunc) sanei_w_word, &ack); } break; case SANE_NET_GET_OPTION_DESCRIPTORS: { SANE_Option_Descriptor_Array opt; h = decode_handle (w, "get_option_descriptors"); if (h < 0) return 1; be_handle = handle[h].handle; sane_control_option (be_handle, 0, SANE_ACTION_GET_VALUE, &opt.num_options, 0); opt.desc = malloc (opt.num_options * sizeof (opt.desc[0])); for (i = 0; i < opt.num_options; ++i) opt.desc[i] = (SANE_Option_Descriptor *) sane_get_option_descriptor (be_handle, i); sanei_w_reply (w,(WireCodecFunc) sanei_w_option_descriptor_array, &opt); free (opt.desc); } break; case SANE_NET_CONTROL_OPTION: { SANE_Control_Option_Req req; SANE_Control_Option_Reply reply; sanei_w_control_option_req (w, &req); if (w->status || (unsigned) req.handle >= (unsigned) num_handles || !handle[req.handle].inuse) { DBG (DBG_ERR, "process_request: (control_option) " "error while decoding args h=%d (%s)\n" , req.handle, strerror (w->status)); return 1; } /* Addresses CVE-2017-6318 (#315576, Debian BTS #853804) */ /* This is done here (rather than in sanei/sanei_wire.c where * it should be done) to minimize scope of impact and amount * of code change. */ if (w->direction == WIRE_DECODE && req.value_type == SANE_TYPE_STRING && req.action == SANE_ACTION_GET_VALUE) { if (req.value) { /* FIXME: If req.value contains embedded NUL * characters, this is wrong but we do not have * access to the amount of memory allocated in * sanei/sanei_wire.c at this point. */ w->allocated_memory -= (1 + strlen (req.value)); free (req.value); } req.value = malloc (req.value_size); if (!req.value) { w->status = ENOMEM; DBG (DBG_ERR, "process_request: (control_option) " "h=%d (%s)\n", req.handle, strerror (w->status)); return 1; } memset (req.value, 0, req.value_size); w->allocated_memory += req.value_size; } can_authorize = 1; memset (&reply, 0, sizeof (reply)); /* avoid leaking bits */ be_handle = handle[req.handle].handle; reply.status = sane_control_option (be_handle, req.option, req.action, req.value, &reply.info); reply.value_type = req.value_type; reply.value_size = req.value_size; reply.value = req.value; can_authorize = 0; sanei_w_reply (w, (WireCodecFunc) sanei_w_control_option_reply, &reply); sanei_w_free (w, (WireCodecFunc) sanei_w_control_option_req, &req); } break; case SANE_NET_GET_PARAMETERS: { SANE_Get_Parameters_Reply reply; h = decode_handle (w, "get_parameters"); if (h < 0) return 1; be_handle = handle[h].handle; reply.status = sane_get_parameters (be_handle, &reply.params); sanei_w_reply (w, (WireCodecFunc) sanei_w_get_parameters_reply, &reply); } break; case SANE_NET_START: { SANE_Start_Reply reply; int fd = -1, data_fd = -1; h = decode_handle (w, "start"); if (h < 0) return 1; memset (&reply, 0, sizeof (reply)); /* avoid leaking bits */ reply.byte_order = SANE_NET_LITTLE_ENDIAN; if (byte_order.w != 1) reply.byte_order = SANE_NET_BIG_ENDIAN; if (handle[h].scanning) reply.status = SANE_STATUS_DEVICE_BUSY; else fd = start_scan (w, h, &reply); sanei_w_reply (w, (WireCodecFunc) sanei_w_start_reply, &reply); #ifdef SANED_USES_AF_INDEP if (reply.status == SANE_STATUS_GOOD) { struct sockaddr_storage ss; char text_addr[64]; int len; int error; struct pollfd fds[1]; int ret; fds->fd = fd; fds->events = POLLIN; DBG (DBG_MSG, "process_request: waiting 4s for data connection\n"); if(data_connect_timeout) { while (1) { ret = poll (fds, 1, data_connect_timeout); if (ret < 0) { if (errno == EINTR) continue; else { DBG (DBG_ERR, "run_standalone: poll failed: %s\n", strerror (errno)); } break; } break; } } else ret = 0; if(ret >= 0) data_fd = accept (fd, 0, 0); close (fd); /* Get address of remote host */ len = sizeof (ss); if (getpeername (data_fd, (struct sockaddr *) &ss, (socklen_t *) &len) < 0) { DBG (DBG_ERR, "process_request: getpeername failed: %s\n", strerror (errno)); return 1; } error = getnameinfo ((struct sockaddr *) &ss, len, text_addr, sizeof (text_addr), NULL, 0, NI_NUMERICHOST); if (error) { DBG (DBG_ERR, "process_request: getnameinfo failed: %s\n", gai_strerror (error)); return 1; } DBG (DBG_MSG, "process_request: access to data port from %s\n", text_addr); if (strcmp (text_addr, remote_ip) != 0) { DBG (DBG_ERR, "process_request: however, only %s is authorized\n", text_addr); DBG (DBG_ERR, "process_request: configuration problem or attack?\n"); close (data_fd); data_fd = -1; return -1; } #else /* !SANED_USES_AF_INDEP */ if (reply.status == SANE_STATUS_GOOD) { struct sockaddr_in sin; int len; int ret; struct pollfd fds[1]; fds->fd = fd; fds->events = POLLIN; DBG (DBG_MSG, "process_request: waiting for data connection\n"); if(data_connect_timeout) { while (1) { ret = poll (fds, 1, data_connect_timeout); if (ret < 0) { if (errno == EINTR) continue; else { DBG (DBG_ERR, "run_standalone: poll failed: %s\n", strerror (errno)); } break; } break; } } else ret = 0; if(ret >= 0) data_fd = accept (fd, 0, 0); close (fd); /* Get address of remote host */ len = sizeof (sin); if (getpeername (data_fd, (struct sockaddr *) &sin, (socklen_t *) &len) < 0) { DBG (DBG_ERR, "process_request: getpeername failed: %s\n", strerror (errno)); return 1; } if (memcmp (&remote_address, &sin.sin_addr, sizeof (remote_address)) != 0) { DBG (DBG_ERR, "process_request: access to data port from %s\n", inet_ntoa (sin.sin_addr)); DBG (DBG_ERR, "process_request: however, only %s is authorized\n", inet_ntoa (remote_address)); DBG (DBG_ERR, "process_request: configuration problem or attack?\n"); close (data_fd); data_fd = -1; return -1; } else DBG (DBG_MSG, "process_request: access to data port from %s\n", inet_ntoa (sin.sin_addr)); #endif /* SANED_USES_AF_INDEP */ if (data_fd < 0) { sane_cancel (handle[h].handle); handle[h].scanning = 0; handle[h].docancel = 0; DBG (DBG_ERR, "process_request: accept failed! (%s)\n", strerror (errno)); return 1; } fcntl (data_fd, F_SETFL, 1); /* set non-blocking */ shutdown (data_fd, 0); do_scan (w, h, data_fd); close (data_fd); } } break; case SANE_NET_CANCEL: { SANE_Word ack = 0; h = decode_handle (w, "cancel"); if (h >= 0) { sane_cancel (handle[h].handle); handle[h].docancel = 1; } sanei_w_reply (w, (WireCodecFunc) sanei_w_word, &ack); } break; case SANE_NET_EXIT: return -1; break; case SANE_NET_INIT: case SANE_NET_AUTHORIZE: default: DBG (DBG_ERR, "process_request: received unexpected procedure number %d\n", current_request); return -1; } return 0; } static int wait_child (pid_t pid, int *status, int options) { struct saned_child *c; struct saned_child *p = NULL; int ret; ret = waitpid(pid, status, options); if (ret <= 0) return ret; #ifdef WITH_AVAHI if ((avahi_pid > 0) && (ret == avahi_pid)) { avahi_pid = -1; numchildren--; return ret; } #endif /* WITH_AVAHI */ for (c = children; (c != NULL) && (c->next != NULL); p = c, c = c->next) { if (c->pid == ret) { if (c == children) children = c->next; else if (p != NULL) p->next = c->next; free(c); numchildren--; break; } } return ret; } static int add_child (pid_t pid) { struct saned_child *c; c = (struct saned_child *) malloc (sizeof(struct saned_child)); if (c == NULL) { DBG (DBG_ERR, "add_child: out of memory\n"); return -1; } c->pid = pid; c->next = children; children = c; return 0; } static void handle_connection (int fd) { #ifdef TCP_NODELAY int on = 1; int level = -1; #endif DBG (DBG_DBG, "handle_connection: processing client connection\n"); wire.io.fd = fd; signal (SIGALRM, quit); signal (SIGPIPE, quit); #ifdef TCP_NODELAY # ifdef SOL_TCP level = SOL_TCP; # else /* !SOL_TCP */ /* Look up the protocol level in the protocols database. */ { struct protoent *p; p = getprotobyname ("tcp"); if (p == 0) { DBG (DBG_WARN, "handle_connection: cannot look up `tcp' protocol number"); } else level = p->p_proto; } # endif /* SOL_TCP */ if (level == -1 || setsockopt (wire.io.fd, level, TCP_NODELAY, &on, sizeof (on))) DBG (DBG_WARN, "handle_connection: failed to put socket in TCP_NODELAY mode (%s)", strerror (errno)); #endif /* !TCP_NODELAY */ if (init (&wire) < 0) return; while (1) { reset_watchdog (); if (process_request (&wire) < 0) break; } } static void handle_client (int fd) { pid_t pid; int i; DBG (DBG_DBG, "handle_client: spawning child process\n"); pid = fork (); if (pid == 0) { /* child */ if (log_to_syslog) closelog(); for (i = 3; i < fd; i++) close(i); if (log_to_syslog) openlog ("saned", LOG_PID | LOG_CONS, LOG_DAEMON); handle_connection (fd); quit (0); } else if (pid > 0) { /* parent */ add_child (pid); close(fd); } else { /* FAILED */ DBG (DBG_ERR, "handle_client: fork() failed: %s\n", strerror (errno)); close(fd); } } static void bail_out (int error) { DBG (DBG_ERR, "%sbailing out, waiting for children...\n", (error) ? "FATAL ERROR; " : ""); #ifdef WITH_AVAHI if (avahi_pid > 0) kill (avahi_pid, SIGTERM); #endif /* WITH_AVAHI */ while (numchildren > 0) wait_child (-1, NULL, 0); DBG (DBG_ERR, "bail_out: all children exited\n"); exit ((error) ? 1 : 0); } void sig_int_term_handler (int signum); void sig_int_term_handler (int signum) { /* unused */ signum = signum; signal (SIGINT, NULL); signal (SIGTERM, NULL); bail_out (0); } #ifdef WITH_AVAHI static void saned_avahi (struct pollfd *fds, int nfds); static void saned_create_avahi_services (AvahiClient *c); static void saned_avahi_callback (AvahiClient *c, AvahiClientState state, void *userdata); static void saned_avahi_group_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata); static void saned_avahi (struct pollfd *fds, int nfds) { struct pollfd *fdp = NULL; int error; avahi_pid = fork (); if (avahi_pid > 0) { numchildren++; return; } else if (avahi_pid < 0) { DBG (DBG_ERR, "saned_avahi: could not spawn Avahi process: %s\n", strerror (errno)); return; } signal (SIGINT, NULL); signal (SIGTERM, NULL); /* Close network fds */ for (fdp = fds; nfds > 0; nfds--, fdp++) close (fdp->fd); free(fds); avahi_svc_name = avahi_strdup(SANED_NAME); avahi_poll = avahi_simple_poll_new (); if (avahi_poll == NULL) { DBG (DBG_ERR, "saned_avahi: failed to create simple poll object\n"); goto fail; } avahi_client = avahi_client_new (avahi_simple_poll_get (avahi_poll), AVAHI_CLIENT_NO_FAIL, saned_avahi_callback, NULL, &error); if (avahi_client == NULL) { DBG (DBG_ERR, "saned_avahi: failed to create client: %s\n", avahi_strerror (error)); goto fail; } avahi_simple_poll_loop (avahi_poll); DBG (DBG_INFO, "saned_avahi: poll loop exited\n"); exit(EXIT_SUCCESS); /* NOT REACHED */ return; fail: if (avahi_client) avahi_client_free (avahi_client); if (avahi_poll) avahi_simple_poll_free (avahi_poll); avahi_free (avahi_svc_name); exit(EXIT_FAILURE); } static void saned_avahi_group_callback (AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) { char *n; /* unused */ userdata = userdata; if ((!g) || (g != avahi_group)) return; switch (state) { case AVAHI_ENTRY_GROUP_ESTABLISHED: /* The entry group has been established successfully */ DBG (DBG_INFO, "saned_avahi_group_callback: service '%s' successfully established\n", avahi_svc_name); break; case AVAHI_ENTRY_GROUP_COLLISION: /* A service name collision with a remote service * happened. Let's pick a new name */ n = avahi_alternative_service_name (avahi_svc_name); avahi_free (avahi_svc_name); avahi_svc_name = n; DBG (DBG_WARN, "saned_avahi_group_callback: service name collision, renaming service to '%s'\n", avahi_svc_name); /* And recreate the services */ saned_create_avahi_services (avahi_entry_group_get_client (g)); break; case AVAHI_ENTRY_GROUP_FAILURE : DBG (DBG_ERR, "saned_avahi_group_callback: entry group failure: %s\n", avahi_strerror (avahi_client_errno (avahi_entry_group_get_client (g)))); /* Some kind of failure happened while we were registering our services */ avahi_simple_poll_quit (avahi_poll); break; case AVAHI_ENTRY_GROUP_UNCOMMITED: case AVAHI_ENTRY_GROUP_REGISTERING: break; } } static void saned_create_avahi_services (AvahiClient *c) { char *n; char txt[32]; AvahiProtocol proto; int ret; if (!c) return; if (!avahi_group) { avahi_group = avahi_entry_group_new (c, saned_avahi_group_callback, NULL); if (avahi_group == NULL) { DBG (DBG_ERR, "saned_create_avahi_services: avahi_entry_group_new() failed: %s\n", avahi_strerror (avahi_client_errno (c))); goto fail; } } if (avahi_entry_group_is_empty (avahi_group)) { DBG (DBG_INFO, "saned_create_avahi_services: adding service '%s'\n", avahi_svc_name); snprintf(txt, sizeof (txt), "protovers=%x", SANE_VERSION_CODE (V_MAJOR, V_MINOR, SANEI_NET_PROTOCOL_VERSION)); #ifdef ENABLE_IPV6 proto = AVAHI_PROTO_UNSPEC; #else proto = AVAHI_PROTO_INET; #endif /* ENABLE_IPV6 */ ret = avahi_entry_group_add_service (avahi_group, AVAHI_IF_UNSPEC, proto, 0, avahi_svc_name, SANED_SERVICE_DNS, NULL, NULL, SANED_SERVICE_PORT, txt, NULL); if (ret < 0) { if (ret == AVAHI_ERR_COLLISION) { n = avahi_alternative_service_name (avahi_svc_name); avahi_free (avahi_svc_name); avahi_svc_name = n; DBG (DBG_WARN, "saned_create_avahi_services: service name collision, renaming service to '%s'\n", avahi_svc_name); avahi_entry_group_reset (avahi_group); saned_create_avahi_services (c); return; } DBG (DBG_ERR, "saned_create_avahi_services: failed to add %s service: %s\n", SANED_SERVICE_DNS, avahi_strerror (ret)); goto fail; } /* Tell the server to register the service */ ret = avahi_entry_group_commit (avahi_group); if (ret < 0) { DBG (DBG_ERR, "saned_create_avahi_services: failed to commit entry group: %s\n", avahi_strerror (ret)); goto fail; } } return; fail: avahi_simple_poll_quit (avahi_poll); } static void saned_avahi_callback (AvahiClient *c, AvahiClientState state, void *userdata) { int error; /* unused */ userdata = userdata; if (!c) return; switch (state) { case AVAHI_CLIENT_CONNECTING: DBG (DBG_INFO, "saned_avahi_callback: AVAHI_CLIENT_CONNECTING\n"); break; case AVAHI_CLIENT_S_RUNNING: DBG (DBG_INFO, "saned_avahi_callback: AVAHI_CLIENT_S_RUNNING\n"); saned_create_avahi_services (c); break; case AVAHI_CLIENT_S_COLLISION: DBG (DBG_INFO, "saned_avahi_callback: AVAHI_CLIENT_S_COLLISION\n"); if (avahi_group) avahi_entry_group_reset (avahi_group); break; case AVAHI_CLIENT_S_REGISTERING: DBG (DBG_INFO, "saned_avahi_callback: AVAHI_CLIENT_S_REGISTERING\n"); if (avahi_group) avahi_entry_group_reset (avahi_group); break; case AVAHI_CLIENT_FAILURE: DBG (DBG_INFO, "saned_avahi_callback: AVAHI_CLIENT_FAILURE\n"); error = avahi_client_errno (c); if (error == AVAHI_ERR_DISCONNECTED) { DBG (DBG_INFO, "saned_avahi_callback: AVAHI_ERR_DISCONNECTED\n"); /* Server disappeared - try to reconnect */ avahi_client_free (avahi_client); avahi_client = NULL; avahi_group = NULL; avahi_client = avahi_client_new (avahi_simple_poll_get (avahi_poll), AVAHI_CLIENT_NO_FAIL, saned_avahi_callback, NULL, &error); if (avahi_client == NULL) { DBG (DBG_ERR, "saned_avahi_callback: failed to create client: %s\n", avahi_strerror (error)); avahi_simple_poll_quit (avahi_poll); } } else { /* Another error happened - game over */ DBG (DBG_ERR, "saned_avahi_callback: client failure: %s\n", avahi_strerror (error)); avahi_simple_poll_quit (avahi_poll); } break; } } #endif /* WITH_AVAHI */ static void read_config (void) { char config_line[PATH_MAX]; const char *optval; char *endval; long val; FILE *fp; int len; DBG (DBG_INFO, "read_config: searching for config file\n"); fp = sanei_config_open (SANED_CONFIG_FILE); if (fp) { while (sanei_config_read (config_line, sizeof (config_line), fp)) { if (config_line[0] == '#') continue; /* ignore line comments */ optval = strchr (config_line, '='); if (optval == NULL) continue; /* only interested in options, skip hosts */ len = strlen (config_line); if (!len) continue; /* ignore empty lines */ /* * Check for saned options. * Anything that isn't an option is a client. */ if (strstr(config_line, "data_portrange") != NULL) { optval = sanei_config_skip_whitespace (++optval); if ((optval != NULL) && (*optval != '\0')) { val = strtol (optval, &endval, 10); if (optval == endval) { DBG (DBG_ERR, "read_config: invalid value for data_portrange\n"); continue; } else if ((val < 0) || (val > 65535)) { DBG (DBG_ERR, "read_config: data_portrange start port is invalid\n"); continue; } optval = strchr (endval, '-'); if (optval == NULL) { DBG (DBG_ERR, "read_config: no end port value for data_portrange\n"); continue; } optval = sanei_config_skip_whitespace (++optval); data_port_lo = val; val = strtol (optval, &endval, 10); if (optval == endval) { DBG (DBG_ERR, "read_config: invalid value for data_portrange\n"); data_port_lo = 0; continue; } else if ((val < 0) || (val > 65535)) { DBG (DBG_ERR, "read_config: data_portrange end port is invalid\n"); data_port_lo = 0; continue; } else if (val < data_port_lo) { DBG (DBG_ERR, "read_config: data_portrange end port is less than start port\n"); data_port_lo = 0; continue; } data_port_hi = val; DBG (DBG_INFO, "read_config: data port range: %d - %d\n", data_port_lo, data_port_hi); } } else if(strstr(config_line, "data_connect_timeout") != NULL) { optval = sanei_config_skip_whitespace (++optval); if ((optval != NULL) && (*optval != '\0')) { val = strtol (optval, &endval, 10); if (optval == endval) { DBG (DBG_ERR, "read_config: invalid value for data_connect_timeout\n"); continue; } else if ((val < 0) || (val > 65535)) { DBG (DBG_ERR, "read_config: data_connect_timeout is invalid\n"); continue; } data_connect_timeout = val; DBG (DBG_INFO, "read_config: data connect timeout: %d\n", data_connect_timeout); } } } fclose (fp); DBG (DBG_INFO, "read_config: done reading config\n"); } else DBG (DBG_ERR, "read_config: could not open config file (%s): %s\n", SANED_CONFIG_FILE, strerror (errno)); } #ifdef SANED_USES_AF_INDEP static void do_bindings_family (int family, int *nfds, struct pollfd **fds, struct addrinfo *res) { struct addrinfo *resp; struct pollfd *fdp; short sane_port; int fd = -1; int on = 1; int i; fdp = *fds; for (resp = res, i = 0; resp != NULL; resp = resp->ai_next, i++) { /* We're not interested */ if (resp->ai_family != family) continue; if (resp->ai_family == AF_INET) { sane_port = ntohs (((struct sockaddr_in *) resp->ai_addr)->sin_port); } #ifdef ENABLE_IPV6 else if (resp->ai_family == AF_INET6) { sane_port = ntohs (((struct sockaddr_in6 *) resp->ai_addr)->sin6_port); } #endif /* ENABLE_IPV6 */ else continue; DBG (DBG_DBG, "do_bindings: [%d] socket () using IPv%d\n", i, (family == AF_INET) ? 4 : 6); if ((fd = socket (resp->ai_family, SOCK_STREAM, 0)) < 0) { DBG (DBG_ERR, "do_bindings: [%d] socket failed: %s\n", i, strerror (errno)); continue; } DBG (DBG_DBG, "do_bindings: [%d] setsockopt ()\n", i); if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on))) DBG (DBG_ERR, "do_bindings: [%d] failed to put socket in SO_REUSEADDR mode (%s)\n", i, strerror (errno)); DBG (DBG_DBG, "do_bindings: [%d] bind () to port %d\n", i, sane_port); if (bind (fd, resp->ai_addr, resp->ai_addrlen) < 0) { /* * Binding a socket may fail with EADDRINUSE if we already bound * to an IPv6 addr returned by getaddrinfo (usually the first ones) * and we're trying to bind to an IPv4 addr now. * It can also fail because we're trying to bind an IPv6 socket and IPv6 * is not functional on this machine. * In any case, a bind() call returning an error is not necessarily fatal. */ DBG (DBG_WARN, "do_bindings: [%d] bind failed: %s\n", i, strerror (errno)); close (fd); continue; } DBG (DBG_DBG, "do_bindings: [%d] listen ()\n", i); if (listen (fd, 1) < 0) { DBG (DBG_ERR, "do_bindings: [%d] listen failed: %s\n", i, strerror (errno)); close (fd); continue; } fdp->fd = fd; fdp->events = POLLIN; (*nfds)++; fdp++; } *fds = fdp; } static void do_bindings (int *nfds, struct pollfd **fds) { struct addrinfo *res; struct addrinfo *resp; struct addrinfo hints; struct pollfd *fdp; int err; DBG (DBG_DBG, "do_bindings: trying to get port for service \"%s\" (getaddrinfo)\n", SANED_SERVICE_NAME); memset (&hints, 0, sizeof (struct addrinfo)); hints.ai_family = PF_UNSPEC; hints.ai_flags = AI_PASSIVE; hints.ai_socktype = SOCK_STREAM; err = getaddrinfo (bind_addr, SANED_SERVICE_NAME, &hints, &res); if (err) { DBG (DBG_WARN, "do_bindings: \" %s \" service unknown on your host; you should add\n", SANED_SERVICE_NAME); DBG (DBG_WARN, "do_bindings: %s %d/tcp saned # SANE network scanner daemon\n", SANED_SERVICE_NAME, SANED_SERVICE_PORT); DBG (DBG_WARN, "do_bindings: to your /etc/services file (or equivalent). Proceeding anyway.\n"); err = getaddrinfo (bind_addr, SANED_SERVICE_PORT_S, &hints, &res); if (err) { DBG (DBG_ERR, "do_bindings: getaddrinfo() failed even with numeric port: %s\n", gai_strerror (err)); bail_out (1); } } for (resp = res, *nfds = 0; resp != NULL; resp = resp->ai_next, (*nfds)++) ; *fds = malloc (*nfds * sizeof (struct pollfd)); if (fds == NULL) { DBG (DBG_ERR, "do_bindings: not enough memory for fds\n"); freeaddrinfo (res); bail_out (1); } fdp = *fds; *nfds = 0; /* bind IPv6 first, IPv4 second */ #ifdef ENABLE_IPV6 do_bindings_family (AF_INET6, nfds, &fdp, res); #endif do_bindings_family (AF_INET, nfds, &fdp, res); resp = NULL; freeaddrinfo (res); if (*nfds <= 0) { DBG (DBG_ERR, "do_bindings: couldn't bind an address. Exiting.\n"); bail_out (1); } } #else /* !SANED_USES_AF_INDEP */ static void do_bindings (int *nfds, struct pollfd **fds) { struct sockaddr_in sin; struct servent *serv; short port; int fd = -1; int on = 1; DBG (DBG_DBG, "do_bindings: trying to get port for service \"%s\" (getservbyname)\n", SANED_SERVICE_NAME); serv = getservbyname (SANED_SERVICE_NAME, "tcp"); if (serv) { port = serv->s_port; DBG (DBG_MSG, "do_bindings: port is %d\n", ntohs (port)); } else { port = htons (SANED_SERVICE_PORT); DBG (DBG_WARN, "do_bindings: \"%s\" service unknown on your host; you should add\n", SANED_SERVICE_NAME); DBG (DBG_WARN, "do_bindings: %s %d/tcp saned # SANE network scanner daemon\n", SANED_SERVICE_NAME, SANED_SERVICE_PORT); DBG (DBG_WARN, "do_bindings: to your /etc/services file (or equivalent). Proceeding anyway.\n"); } *nfds = 1; *fds = malloc (*nfds * sizeof (struct pollfd)); if (fds == NULL) { DBG (DBG_ERR, "do_bindings: not enough memory for fds\n"); bail_out (1); } memset (&sin, 0, sizeof (sin)); sin.sin_family = AF_INET; if(bind_addr) sin.sin_addr.s_addr = inet_addr(bind_addr); else sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = port; DBG (DBG_DBG, "do_bindings: socket ()\n"); fd = socket (AF_INET, SOCK_STREAM, 0); DBG (DBG_DBG, "do_bindings: setsockopt ()\n"); if (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on))) DBG (DBG_ERR, "do_bindings: failed to put socket in SO_REUSEADDR mode (%s)", strerror (errno)); DBG (DBG_DBG, "do_bindings: bind ()\n"); if (bind (fd, (struct sockaddr *) &sin, sizeof (sin)) < 0) { DBG (DBG_ERR, "do_bindings: bind failed: %s", strerror (errno)); bail_out (1); } DBG (DBG_DBG, "do_bindings: listen ()\n"); if (listen (fd, 1) < 0) { DBG (DBG_ERR, "do_bindings: listen failed: %s", strerror (errno)); bail_out (1); } (*fds)->fd = fd; (*fds)->events = POLLIN; } #endif /* SANED_USES_AF_INDEP */ static void runas_user (char *user) { uid_t runas_uid = 0; gid_t runas_gid = 0; struct passwd *pwent; gid_t *grplist = NULL; struct group *grp; int ngroups = 0; int ret; pwent = getpwnam(user); if (pwent == NULL) { DBG (DBG_ERR, "FATAL ERROR: user %s not found on system\n", user); bail_out (1); } runas_uid = pwent->pw_uid; runas_gid = pwent->pw_gid; /* Get group list for runas_uid */ grplist = (gid_t *)malloc(sizeof(gid_t)); if (grplist == NULL) { DBG (DBG_ERR, "FATAL ERROR: cannot allocate memory for group list\n"); exit (1); } ngroups = 1; grplist[0] = runas_gid; setgrent(); while ((grp = getgrent()) != NULL) { int i = 0; /* Already added current group */ if (grp->gr_gid == runas_gid) continue; while (grp->gr_mem[i]) { if (strcmp(grp->gr_mem[i], user) == 0) { int need_to_add = 1, j; /* Make sure its not already in list */ for (j = 0; j < ngroups; j++) { if (grp->gr_gid == grplist[i]) need_to_add = 0; } if (need_to_add) { grplist = (gid_t *)realloc(grplist, sizeof(gid_t)*ngroups+1); if (grplist == NULL) { DBG (DBG_ERR, "FATAL ERROR: cannot reallocate memory for group list\n"); exit (1); } grplist[ngroups++] = grp->gr_gid; } } i++; } } endgrent(); /* Drop privileges if requested */ if (runas_uid > 0) { ret = setgroups(ngroups, grplist); if (ret < 0) { DBG (DBG_ERR, "FATAL ERROR: could not set group list: %s\n", strerror(errno)); exit (1); } free(grplist); ret = setegid (runas_gid); if (ret < 0) { DBG (DBG_ERR, "FATAL ERROR: setegid to gid %d failed: %s\n", runas_gid, strerror (errno)); exit (1); } ret = seteuid (runas_uid); if (ret < 0) { DBG (DBG_ERR, "FATAL ERROR: seteuid to uid %d failed: %s\n", runas_uid, strerror (errno)); exit (1); } DBG (DBG_WARN, "Dropped privileges to uid %d gid %d\n", runas_uid, runas_gid); } } static void run_standalone (char *user) { struct pollfd *fds = NULL; struct pollfd *fdp = NULL; int nfds; int fd = -1; int i; int ret; FILE *pidfile; do_bindings (&nfds, &fds); if (run_foreground == SANE_FALSE) { DBG (DBG_MSG, "run_standalone: daemonizing now\n"); fd = open ("/dev/null", O_RDWR); if (fd < 0) { DBG (DBG_ERR, "FATAL ERROR: cannot open /dev/null: %s\n", strerror (errno)); exit (1); } ret = fork (); if (ret > 0) { _exit (0); } else if (ret < 0) { DBG (DBG_ERR, "FATAL ERROR: fork failed: %s\n", strerror (errno)); exit (1); } DBG (DBG_WARN, "Now daemonized\n"); /* Write out PID file */ pidfile = fopen (SANED_PID_FILE, "w"); if (pidfile) { fprintf (pidfile, "%d", getpid()); fclose (pidfile); } else DBG (DBG_ERR, "Could not write PID file: %s\n", strerror (errno)); chdir ("/"); dup2 (fd, STDIN_FILENO); dup2 (fd, STDOUT_FILENO); dup2 (fd, STDERR_FILENO); close (fd); setsid (); signal(SIGINT, sig_int_term_handler); signal(SIGTERM, sig_int_term_handler); } if (user) runas_user(user); #ifdef WITH_AVAHI DBG (DBG_INFO, "run_standalone: spawning Avahi process\n"); saned_avahi (fds, nfds); /* NOT REACHED (Avahi process) */ #endif /* WITH_AVAHI */ DBG (DBG_MSG, "run_standalone: waiting for control connection\n"); while (1) { ret = poll (fds, nfds, 500); if (ret < 0) { if (errno == EINTR) continue; else { DBG (DBG_ERR, "run_standalone: poll failed: %s\n", strerror (errno)); free (fds); bail_out (1); } } /* Wait for children */ while (wait_child (-1, NULL, WNOHANG) > 0) ; if (ret == 0) continue; for (i = 0, fdp = fds; i < nfds; i++, fdp++) { /* Error on an fd */ if (fdp->revents & (POLLERR | POLLHUP | POLLNVAL)) { for (i = 0, fdp = fds; i < nfds; i++, fdp++) close (fdp->fd); free (fds); DBG (DBG_WARN, "run_standalone: invalid fd in set, attempting to re-bind\n"); /* Reopen sockets */ do_bindings (&nfds, &fds); break; } else if (! (fdp->revents & POLLIN)) continue; fd = accept (fdp->fd, 0, 0); if (fd < 0) { DBG (DBG_ERR, "run_standalone: accept failed: %s", strerror (errno)); continue; } handle_client (fd); if (run_once == SANE_TRUE) break; /* We have handled the only connection we're going to handle */ } if (run_once == SANE_TRUE) break; } for (i = 0, fdp = fds; i < nfds; i++, fdp++) close (fdp->fd); free (fds); } static void run_inetd (char __sane_unused__ *sock) { int fd = -1; #ifdef HAVE_SYSTEMD int n; n = sd_listen_fds(0); if (n > 1) { DBG (DBG_ERR, "run_inetd: Too many file descriptors (sockets) received from systemd!\n"); return; } if (n == 1) { fd = SD_LISTEN_FDS_START + 0; DBG (DBG_INFO, "run_inetd: Using systemd socket %d!\n", fd); } #endif if (fd == -1) { int dave_null; /* Some backends really can't keep their dirty fingers off * stdin/stdout/stderr; we work around them here so they don't * mess up the network dialog and crash the remote net backend * by messing with the inetd socket. * For systemd this not an issue as systemd uses fd >= 3 for the * socket and can even redirect stdout and stderr to syslog. * We can even use this to get the debug logging */ do { /* get new fd for the inetd socket */ fd = dup (1); if (fd == -1) { DBG (DBG_ERR, "run_inetd: duplicating fd failed: %s", strerror (errno)); return; } } while (fd < 3); /* Our good'ole friend Dave Null to the rescue */ dave_null = open ("/dev/null", O_RDWR); if (dave_null < 0) { DBG (DBG_ERR, "run_inetd: could not open /dev/null: %s", strerror (errno)); return; } close (STDIN_FILENO); close (STDOUT_FILENO); close (STDERR_FILENO); dup2 (dave_null, STDIN_FILENO); dup2 (dave_null, STDOUT_FILENO); dup2 (dave_null, STDERR_FILENO); close (dave_null); } #ifdef HAVE_OS2_H /* under OS/2, the socket handle is passed as argument on the command line; the socket handle is relative to IBM TCP/IP, so a call to impsockethandle() is required to add it to the EMX runtime */ if (sock) { fd = _impsockhandle (atoi (sock), 0); if (fd == -1) perror ("impsockhandle"); } #endif /* HAVE_OS2_H */ handle_connection(fd); } static void usage(char *me, int err) { fprintf (stderr, "Usage: %s [OPTIONS]\n\n" " Options:\n\n" " -a, --alone[=user] equal to `-l -D -u user'\n" " -l, --listen run in standalone mode (listen for connection)\n" " -u, --user=user run as `user'\n" " -D, --daemonize run in background\n" " -o, --once exit after first client disconnects\n" " -d, --debug=level set debug level `level' (default is 2)\n" " -e, --stderr output to stderr\n" " -b, --bind=addr bind address `addr' (default all interfaces)\n" " -h, --help show this help message and exit\n", me); exit(err); } static int debug; static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, {"alone", optional_argument, 0, 'a'}, {"listen", no_argument, 0, 'l'}, {"user", required_argument, 0, 'u'}, {"daemonize", no_argument, 0, 'D'}, {"once", no_argument, 0, 'o'}, {"debug", required_argument, 0, 'd'}, {"stderr", no_argument, 0, 'e'}, {"bind", required_argument, 0, 'b'}, {0, 0, 0, 0 } }; int main (int argc, char *argv[]) { char options[64] = ""; char *user = NULL; char *sock = NULL; int c; int long_index = 0; debug = DBG_WARN; prog_name = strrchr (argv[0], '/'); if (prog_name) ++prog_name; else prog_name = argv[0]; numchildren = 0; run_mode = SANED_RUN_INETD; run_foreground = SANE_TRUE; run_once = SANE_FALSE; while((c = getopt_long(argc, argv,"ha::lu:Dod:eb:", long_options, &long_index )) != -1) { switch(c) { case 'a': run_mode = SANED_RUN_ALONE; run_foreground = SANE_FALSE; if (optarg) user = optarg; break; case 'l': run_mode = SANED_RUN_ALONE; break; case 'u': user = optarg; break; case 'D': run_foreground = SANE_FALSE; break; case 'o': run_once = SANE_TRUE; break; case 'd': debug = atoi(optarg); break; case 'e': log_to_syslog = SANE_FALSE; break; case 'b': bind_addr = optarg; break; case 'h': usage(argv[0], EXIT_SUCCESS); break; default: usage(argv[0], EXIT_FAILURE); break; } } if (log_to_syslog) openlog ("saned", LOG_PID | LOG_CONS, LOG_DAEMON); read_config (); byte_order.w = 0; byte_order.ch = 1; sanei_w_init (&wire, sanei_codec_bin_init); wire.io.read = read; wire.io.write = write; #ifdef SANED_USES_AF_INDEP strcat(options, "AF-indep"); # ifdef ENABLE_IPV6 strcat(options, "+IPv6"); #endif #else strcat(options, "IPv4 only"); #endif #ifdef HAVE_SYSTEMD if (sd_listen_fds(0) > 0) { strcat(options, "+systemd"); } #endif if (strlen(options) > 0) { DBG (DBG_WARN, "saned (%s) from %s starting up\n", options, PACKAGE_STRING); } else { DBG (DBG_WARN, "saned from %s ready\n", PACKAGE_STRING); } if (run_mode == SANED_RUN_ALONE) { run_standalone(user); } else { #ifdef HAVE_OS2_H if (argc == 2) sock = argv[1]; #endif run_inetd(sock); } DBG (DBG_WARN, "saned exiting\n"); return 0; } sane-backends-1.0.29/frontend/Makefile.am0000666000000000000000000000175513615534521015064 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2009 Chris Bagwell and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. EXTRA_PROGRAMS = test tstbackend bin_PROGRAMS = scanimage if COMPILE_SANED sbin_PROGRAMS = saned else EXTRA_PROGRAMS += saned endif AM_CPPFLAGS += -I. -I$(srcdir) -I$(top_builddir)/include -I$(top_srcdir)/include scanimage_SOURCES = scanimage.c sicc.c sicc.h stiff.c stiff.h scanimage_LDADD = ../backend/libsane.la ../sanei/libsanei.la ../lib/liblib.la \ $(PNG_LIBS) $(JPEG_LIBS) saned_SOURCES = saned.c saned_LDADD = ../backend/libsane.la ../sanei/libsanei.la ../lib/liblib.la \ $(SYSLOG_LIBS) $(SYSTEMD_LIBS) $(AVAHI_LIBS) test_SOURCES = test.c test_LDADD = ../lib/liblib.la ../backend/libsane.la tstbackend_SOURCES = tstbackend.c tstbackend_LDADD = ../lib/liblib.la ../backend/libsane.la clean-local: rm -f test tstbackend sane-backends-1.0.29/frontend/scanimage.c0000666000000000000000000021536713615534521015131 00000000000000/* scanimage -- command line scanning utility Uses the SANE library. Copyright (C) 2015 Rolf Bensch Copyright (C) 1996, 1997, 1998 Andreas Beck and David Mosberger Copyright (C) 1999 - 2009 by the SANE Project -- See AUTHORS and ChangeLog for details. For questions and comments contact the sane-devel mailinglist (see http://www.sane-project.org/mailing-lists.html). 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef _AIX # include "../include/lalloca.h" /* MUST come first for AIX! */ #endif #include "../include/sane/config.h" #include "../include/lalloca.h" #include #include "lgetopt.h" #include #include #include #include #include #include #include #include #include #ifdef HAVE_LIBPNG #include #endif #ifdef HAVE_LIBJPEG #include #endif #include "../include/_stdint.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "sicc.h" #include "stiff.h" #include "../include/md5.h" #ifndef PATH_MAX #define PATH_MAX 1024 #endif typedef struct { uint8_t *data; int width; /*WARNING: this is in bytes, get pixel width from param*/ int height; int x; int y; } Image; #define OPTION_FORMAT 1001 #define OPTION_MD5 1002 #define OPTION_BATCH_COUNT 1003 #define OPTION_BATCH_START_AT 1004 #define OPTION_BATCH_DOUBLE 1005 #define OPTION_BATCH_INCREMENT 1006 #define OPTION_BATCH_PROMPT 1007 #define OPTION_BATCH_PRINT 1008 #define BATCH_COUNT_UNLIMITED -1 static struct option basic_options[] = { {"device-name", required_argument, NULL, 'd'}, {"list-devices", no_argument, NULL, 'L'}, {"formatted-device-list", required_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, {"verbose", no_argument, NULL, 'v'}, {"progress", no_argument, NULL, 'p'}, {"output-file", required_argument, NULL, 'o'}, {"test", no_argument, NULL, 'T'}, {"all-options", no_argument, NULL, 'A'}, {"version", no_argument, NULL, 'V'}, {"buffer-size", optional_argument, NULL, 'B'}, {"batch", optional_argument, NULL, 'b'}, {"batch-count", required_argument, NULL, OPTION_BATCH_COUNT}, {"batch-start", required_argument, NULL, OPTION_BATCH_START_AT}, {"batch-double", no_argument, NULL, OPTION_BATCH_DOUBLE}, {"batch-increment", required_argument, NULL, OPTION_BATCH_INCREMENT}, {"batch-print", no_argument, NULL, OPTION_BATCH_PRINT}, {"batch-prompt", no_argument, NULL, OPTION_BATCH_PROMPT}, {"format", required_argument, NULL, OPTION_FORMAT}, {"accept-md5-only", no_argument, NULL, OPTION_MD5}, {"icc-profile", required_argument, NULL, 'i'}, {"dont-scan", no_argument, NULL, 'n'}, {0, 0, NULL, 0} }; #define OUTPUT_UNKNOWN 0 #define OUTPUT_PNM 1 #define OUTPUT_TIFF 2 #define OUTPUT_PNG 3 #define OUTPUT_JPEG 4 #define BASE_OPTSTRING "d:hi:Lf:o:B::nvVTAbp" #define STRIP_HEIGHT 256 /* # lines we increment image height */ static struct option *all_options; static int option_number_len; static int *option_number; static SANE_Handle device; static int verbose; static int progress = 0; static const char* output_file = NULL; static int test; static int all; static int output_format = OUTPUT_UNKNOWN; static int help; static int dont_scan = 0; static const char *prog_name; static int resolution_optind = -1, resolution_value = 0; /* window (area) related options */ static SANE_Option_Descriptor window_option[4]; /*updated descs for x,y,l,t*/ static int window[4]; /*index into backend options for x,y,l,t*/ static SANE_Word window_val[2]; /*the value for x,y options*/ static int window_val_user[2]; /* is x,y user-specified? */ static int accept_only_md5_auth = 0; static const char *icc_profile = NULL; static void fetch_options (SANE_Device * device); static void scanimage_exit (int); static SANE_Word tl_x = 0; static SANE_Word tl_y = 0; static SANE_Word br_x = 0; static SANE_Word br_y = 0; static SANE_Byte *buffer; static size_t buffer_size; static void auth_callback (SANE_String_Const resource, SANE_Char * username, SANE_Char * password) { char tmp[3 + 128 + SANE_MAX_USERNAME_LEN + SANE_MAX_PASSWORD_LEN], *wipe; unsigned char md5digest[16]; int md5mode = 0, len, query_user = 1; FILE *pass_file; struct stat stat_buf; char * uname = NULL; *tmp = 0; if (getenv ("HOME") != NULL) { if (strlen (getenv ("HOME")) < 500) { sprintf (tmp, "%s/.sane/pass", getenv ("HOME")); } } if ((strlen (tmp) > 0) && (stat (tmp, &stat_buf) == 0)) { if ((stat_buf.st_mode & 63) != 0) { fprintf (stderr, "%s has wrong permissions (use at least 0600)\n", tmp); } else { if ((pass_file = fopen (tmp, "r")) != NULL) { if (strstr (resource, "$MD5$") != NULL) len = (strstr (resource, "$MD5$") - resource); else len = strlen (resource); while (fgets (tmp, sizeof(tmp), pass_file)) { if ((strlen (tmp) > 0) && (tmp[strlen (tmp) - 1] == '\n')) tmp[strlen (tmp) - 1] = 0; if ((strlen (tmp) > 0) && (tmp[strlen (tmp) - 1] == '\r')) tmp[strlen (tmp) - 1] = 0; char *colon1 = strchr (tmp, ':'); if (colon1 != NULL) { char *tmp_username = tmp; *colon1 = '\0'; char *colon2 = strchr (colon1 + 1, ':'); if (colon2 != NULL) { char *tmp_password = colon1 + 1; *colon2 = '\0'; if ((strncmp (colon2 + 1, resource, len) == 0) && ((int) strlen (colon2 + 1) == len)) { if ((strlen (tmp_username) < SANE_MAX_USERNAME_LEN) && (strlen (tmp_password) < SANE_MAX_PASSWORD_LEN)) { strncpy (username, tmp_username, SANE_MAX_USERNAME_LEN); strncpy (password, tmp_password, SANE_MAX_PASSWORD_LEN); query_user = 0; break; } } } } } fclose (pass_file); } } } if (strstr (resource, "$MD5$") != NULL) { md5mode = 1; len = (strstr (resource, "$MD5$") - resource); if (query_user == 1) fprintf (stderr, "Authentication required for resource %*.*s. " "Enter username: ", len, len, resource); } else { if (accept_only_md5_auth != 0) { fprintf (stderr, "ERROR: backend requested plain-text password\n"); return; } else { fprintf (stderr, "WARNING: backend requested plain-text password\n"); query_user = 1; } if (query_user == 1) fprintf (stderr, "Authentication required for resource %s. Enter username: ", resource); } if (query_user == 1) uname = fgets (username, SANE_MAX_USERNAME_LEN, stdin); if (uname != NULL && (strlen (username)) && (username[strlen (username) - 1] == '\n')) username[strlen (username) - 1] = 0; if (query_user == 1) { #ifdef HAVE_GETPASS strcpy (password, (wipe = getpass ("Enter password: "))); memset (wipe, 0, strlen (password)); #else printf("OS has no getpass(). User Queries will not work\n"); #endif } if (md5mode) { sprintf (tmp, "%.128s%.*s", (strstr (resource, "$MD5$")) + 5, SANE_MAX_PASSWORD_LEN - 1, password); md5_buffer (tmp, strlen (tmp), md5digest); memset (password, 0, SANE_MAX_PASSWORD_LEN); sprintf (password, "$MD5$%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x", md5digest[0], md5digest[1], md5digest[2], md5digest[3], md5digest[4], md5digest[5], md5digest[6], md5digest[7], md5digest[8], md5digest[9], md5digest[10], md5digest[11], md5digest[12], md5digest[13], md5digest[14], md5digest[15]); } } static void sighandler (int signum) { static SANE_Bool first_time = SANE_TRUE; if (device) { fprintf (stderr, "%s: received signal %d\n", prog_name, signum); if (first_time) { first_time = SANE_FALSE; fprintf (stderr, "%s: trying to stop scanner\n", prog_name); sane_cancel (device); } else { fprintf (stderr, "%s: aborting\n", prog_name); _exit (0); } } } static void print_unit (SANE_Unit unit) { switch (unit) { case SANE_UNIT_NONE: break; case SANE_UNIT_PIXEL: fputs ("pel", stdout); break; case SANE_UNIT_BIT: fputs ("bit", stdout); break; case SANE_UNIT_MM: fputs ("mm", stdout); break; case SANE_UNIT_DPI: fputs ("dpi", stdout); break; case SANE_UNIT_PERCENT: fputc ('%', stdout); break; case SANE_UNIT_MICROSECOND: fputs ("us", stdout); break; } } static void print_option (SANE_Device * device, int opt_num, const SANE_Option_Descriptor *opt) { const char *str, *last_break, *start; SANE_Bool not_first = SANE_FALSE; int i, column; if (opt->type == SANE_TYPE_GROUP){ printf (" %s:\n", opt->title); return; } /* if both of these are set, option is invalid */ if(opt->cap & SANE_CAP_SOFT_SELECT && opt->cap & SANE_CAP_HARD_SELECT){ fprintf (stderr, "%s: invalid option caps, SS+HS\n", prog_name); return; } /* invalid to select but not detect */ if(opt->cap & SANE_CAP_SOFT_SELECT && !(opt->cap & SANE_CAP_SOFT_DETECT)){ fprintf (stderr, "%s: invalid option caps, SS!SD\n", prog_name); return; } /* standard allows this, though it makes little sense if(opt->cap & SANE_CAP_HARD_SELECT && !(opt->cap & SANE_CAP_SOFT_DETECT)){ fprintf (stderr, "%s: invalid option caps, HS!SD\n", prog_name); return; }*/ /* if one of these three is not set, option is useless, skip it */ if(!(opt->cap & (SANE_CAP_SOFT_SELECT | SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_DETECT) )){ return; } /* print the option */ if ( !strcmp (opt->name, "x") || !strcmp (opt->name, "y") || !strcmp (opt->name, "t") || !strcmp (opt->name, "l")) printf (" -%s", opt->name); else printf (" --%s", opt->name); /* print the option choices */ if (opt->type == SANE_TYPE_BOOL) { fputs ("[=(", stdout); if (opt->cap & SANE_CAP_AUTOMATIC) fputs ("auto|", stdout); fputs ("yes|no)]", stdout); } else if (opt->type != SANE_TYPE_BUTTON) { fputc (' ', stdout); if (opt->cap & SANE_CAP_AUTOMATIC) { fputs ("auto|", stdout); not_first = SANE_TRUE; } switch (opt->constraint_type) { case SANE_CONSTRAINT_NONE: switch (opt->type) { case SANE_TYPE_INT: fputs ("", stdout); break; case SANE_TYPE_FIXED: fputs ("", stdout); break; case SANE_TYPE_STRING: fputs ("", stdout); break; default: break; } if (opt->type != SANE_TYPE_STRING && opt->size > (SANE_Int) sizeof (SANE_Word)) fputs (",...", stdout); break; case SANE_CONSTRAINT_RANGE: if (opt->type == SANE_TYPE_INT) { if (!strcmp (opt->name, "x")) { printf ("%d..%d", opt->constraint.range->min, opt->constraint.range->max - tl_x); } else if (!strcmp (opt->name, "y")) { printf ("%d..%d", opt->constraint.range->min, opt->constraint.range->max - tl_y); } else { printf ("%d..%d", opt->constraint.range->min, opt->constraint.range->max); } print_unit (opt->unit); if (opt->size > (SANE_Int) sizeof (SANE_Word)) fputs (",...", stdout); if (opt->constraint.range->quant) printf (" (in steps of %d)", opt->constraint.range->quant); } else { if (!strcmp (opt->name, "x")) { printf ("%g..%g", SANE_UNFIX (opt->constraint.range->min), SANE_UNFIX (opt->constraint.range->max - tl_x)); } else if (!strcmp (opt->name, "y")) { printf ("%g..%g", SANE_UNFIX (opt->constraint.range->min), SANE_UNFIX (opt->constraint.range->max - tl_y)); } else { printf ("%g..%g", SANE_UNFIX (opt->constraint.range->min), SANE_UNFIX (opt->constraint.range->max)); } print_unit (opt->unit); if (opt->size > (SANE_Int) sizeof (SANE_Word)) fputs (",...", stdout); if (opt->constraint.range->quant) printf (" (in steps of %g)", SANE_UNFIX (opt->constraint.range->quant)); } break; case SANE_CONSTRAINT_WORD_LIST: for (i = 0; i < opt->constraint.word_list[0]; ++i) { if (not_first) fputc ('|', stdout); not_first = SANE_TRUE; if (opt->type == SANE_TYPE_INT) printf ("%d", opt->constraint.word_list[i + 1]); else printf ("%g", SANE_UNFIX (opt->constraint.word_list[i + 1])); } print_unit (opt->unit); if (opt->size > (SANE_Int) sizeof (SANE_Word)) fputs (",...", stdout); break; case SANE_CONSTRAINT_STRING_LIST: for (i = 0; opt->constraint.string_list[i]; ++i) { if (i > 0) fputc ('|', stdout); fputs (opt->constraint.string_list[i], stdout); } break; } } /* print current option value */ if (opt->type == SANE_TYPE_STRING || opt->size == sizeof (SANE_Word)) { if (SANE_OPTION_IS_ACTIVE (opt->cap)) { void *val = alloca (opt->size); sane_control_option (device, opt_num, SANE_ACTION_GET_VALUE, val, 0); fputs (" [", stdout); switch (opt->type) { case SANE_TYPE_BOOL: fputs (*(SANE_Bool *) val ? "yes" : "no", stdout); break; case SANE_TYPE_INT: if (strcmp (opt->name, "l") == 0) { tl_x = (*(SANE_Fixed *) val); printf ("%d", tl_x); } else if (strcmp (opt->name, "t") == 0) { tl_y = (*(SANE_Fixed *) val); printf ("%d", tl_y); } else if (strcmp (opt->name, "x") == 0) { br_x = (*(SANE_Fixed *) val); printf ("%d", br_x - tl_x); } else if (strcmp (opt->name, "y") == 0) { br_y = (*(SANE_Fixed *) val); printf ("%d", br_y - tl_y); } else printf ("%d", *(SANE_Int *) val); break; case SANE_TYPE_FIXED: if (strcmp (opt->name, "l") == 0) { tl_x = (*(SANE_Fixed *) val); printf ("%g", SANE_UNFIX (tl_x)); } else if (strcmp (opt->name, "t") == 0) { tl_y = (*(SANE_Fixed *) val); printf ("%g", SANE_UNFIX (tl_y)); } else if (strcmp (opt->name, "x") == 0) { br_x = (*(SANE_Fixed *) val); printf ("%g", SANE_UNFIX (br_x - tl_x)); } else if (strcmp (opt->name, "y") == 0) { br_y = (*(SANE_Fixed *) val); printf ("%g", SANE_UNFIX (br_y - tl_y)); } else printf ("%g", SANE_UNFIX (*(SANE_Fixed *) val)); break; case SANE_TYPE_STRING: fputs ((char *) val, stdout); break; default: break; } fputc (']', stdout); } } if (!SANE_OPTION_IS_ACTIVE (opt->cap)) fputs (" [inactive]", stdout); else if(opt->cap & SANE_CAP_HARD_SELECT) fputs (" [hardware]", stdout); else if(!(opt->cap & SANE_CAP_SOFT_SELECT) && opt->cap & SANE_CAP_SOFT_DETECT) fputs (" [read-only]", stdout); fputs ("\n ", stdout); column = 8; last_break = 0; start = opt->desc; for (str = opt->desc; *str; ++str) { ++column; if (*str == ' ') last_break = str; else if (*str == '\n'){ column=80; last_break = str; } if (column >= 79 && last_break) { while (start < last_break) fputc (*start++, stdout); start = last_break + 1; /* skip blank */ fputs ("\n ", stdout); column = 8 + (str - start); } } while (*start) fputc (*start++, stdout); fputc ('\n', stdout); } /* A scalar has the following syntax: V [ U ] V is the value of the scalar. It is either an integer or a floating point number, depending on the option type. U is an optional unit. If not specified, the default unit is used. The following table lists which units are supported depending on what the option's default unit is: Option's unit: Allowed units: SANE_UNIT_NONE: SANE_UNIT_PIXEL: pel SANE_UNIT_BIT: b (bit), B (byte) SANE_UNIT_MM: mm (millimeter), cm (centimeter), in or " (inches), SANE_UNIT_DPI: dpi SANE_UNIT_PERCENT: % SANE_UNIT_PERCENT: us */ static const char * parse_scalar (const SANE_Option_Descriptor * opt, const char *str, SANE_Word * value) { char *end; double v; if (opt->type == SANE_TYPE_FIXED) v = strtod (str, &end) * (1 << SANE_FIXED_SCALE_SHIFT); else v = strtol (str, &end, 10); if (str == end) { fprintf (stderr, "%s: option --%s: bad option value (rest of option: %s)\n", prog_name, opt->name, str); scanimage_exit (1); } str = end; switch (opt->unit) { case SANE_UNIT_NONE: case SANE_UNIT_PIXEL: break; case SANE_UNIT_BIT: if (*str == 'b' || *str == 'B') { if (*str++ == 'B') v *= 8; } break; case SANE_UNIT_MM: if (str[0] == '\0') v *= 1.0; /* default to mm */ else if (strcmp (str, "mm") == 0) str += sizeof ("mm") - 1; else if (strcmp (str, "cm") == 0) { str += sizeof ("cm") - 1; v *= 10.0; } else if (strcmp (str, "in") == 0 || *str == '"') { if (*str++ != '"') ++str; v *= 25.4; /* 25.4 mm/inch */ } else { fprintf (stderr, "%s: option --%s: illegal unit (rest of option: %s)\n", prog_name, opt->name, str); return 0; } break; case SANE_UNIT_DPI: if (strcmp (str, "dpi") == 0) str += sizeof ("dpi") - 1; break; case SANE_UNIT_PERCENT: if (*str == '%') ++str; break; case SANE_UNIT_MICROSECOND: if (strcmp (str, "us") == 0) str += sizeof ("us") - 1; break; } if(v < 0){ *value = v - 0.5; } else{ *value = v + 0.5; } return str; } /* A vector has the following syntax: [ '[' I ']' ] S { [','|'-'] [ '[' I ']' S } The number in brackets (I), if present, determines the index of the vector element to be set next. If I is not present, the value of last index used plus 1 is used. The first index value used is 0 unless I is present. S is a scalar value as defined by parse_scalar(). If two consecutive value specs are separated by a comma (,) their values are set independently. If they are separated by a dash (-), they define the endpoints of a line and all vector values between the two endpoints are set according to the value of the interpolated line. For example, [0]15-[255]15 defines a vector of 256 elements whose value is 15. Similarly, [0]0-[255]255 defines a vector of 256 elements whose value starts at 0 and increases to 255. */ static void parse_vector (const SANE_Option_Descriptor * opt, const char *str, SANE_Word * vector, size_t vector_length) { SANE_Word value, prev_value = 0; int index = -1, prev_index = 0; char *end, separator = '\0'; /* initialize vector to all zeroes: */ memset (vector, 0, vector_length * sizeof (SANE_Word)); do { if (*str == '[') { /* read index */ index = strtol (++str, &end, 10); if (str == end || *end != ']') { fprintf (stderr, "%s: option --%s: closing bracket missing " "(rest of option: %s)\n", prog_name, opt->name, str); scanimage_exit (1); } str = end + 1; } else ++index; if (index < 0 || index >= (int) vector_length) { fprintf (stderr, "%s: option --%s: index %d out of range [0..%ld]\n", prog_name, opt->name, index, (long) vector_length - 1); scanimage_exit (1); } /* read value */ str = parse_scalar (opt, str, &value); if (!str) scanimage_exit (1); if (*str && *str != '-' && *str != ',') { fprintf (stderr, "%s: option --%s: illegal separator (rest of option: %s)\n", prog_name, opt->name, str); scanimage_exit (1); } /* store value: */ vector[index] = value; if (separator == '-') { /* interpolate */ double v, slope; int i; v = (double) prev_value; slope = ((double) value - v) / (index - prev_index); for (i = prev_index + 1; i < index; ++i) { v += slope; vector[i] = (SANE_Word) v; } } prev_index = index; prev_value = value; separator = *str++; } while (separator == ',' || separator == '-'); if (verbose > 2) { int i; fprintf (stderr, "%s: value for --%s is: ", prog_name, opt->name); for (i = 0; i < (int) vector_length; ++i) if (opt->type == SANE_TYPE_FIXED) fprintf (stderr, "%g ", SANE_UNFIX (vector[i])); else fprintf (stderr, "%d ", vector[i]); fputc ('\n', stderr); } } static void fetch_options (SANE_Device * device) { const SANE_Option_Descriptor *opt; SANE_Int num_dev_options; int i, option_count; SANE_Status status; opt = sane_get_option_descriptor (device, 0); if (opt == NULL) { fprintf (stderr, "Could not get option descriptor for option 0\n"); scanimage_exit (1); } status = sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "Could not get value for option 0: %s\n", sane_strstatus (status)); scanimage_exit (1); } /* build the full table of long options */ option_count = 0; for (i = 1; i < num_dev_options; ++i) { opt = sane_get_option_descriptor (device, i); if (opt == NULL) { fprintf (stderr, "Could not get option descriptor for option %d\n",i); scanimage_exit (1); } /* create command line option only for settable options */ if (!SANE_OPTION_IS_SETTABLE (opt->cap) || opt->type == SANE_TYPE_GROUP) continue; option_number[option_count] = i; all_options[option_count].name = (const char *) opt->name; all_options[option_count].flag = 0; all_options[option_count].val = 0; if (opt->type == SANE_TYPE_BOOL) all_options[option_count].has_arg = optional_argument; else if (opt->type == SANE_TYPE_BUTTON) all_options[option_count].has_arg = no_argument; else all_options[option_count].has_arg = required_argument; /* Look for scan resolution */ if ((opt->type == SANE_TYPE_FIXED || opt->type == SANE_TYPE_INT) && opt->size == sizeof (SANE_Int) && (opt->unit == SANE_UNIT_DPI) && (strcmp (opt->name, SANE_NAME_SCAN_RESOLUTION) == 0)) resolution_optind = i; /* Keep track of top-left corner options (if they exist at all) and replace the bottom-right corner options by a width/height option (if they exist at all). */ if ((opt->type == SANE_TYPE_FIXED || opt->type == SANE_TYPE_INT) && opt->size == sizeof (SANE_Int) && (opt->unit == SANE_UNIT_MM || opt->unit == SANE_UNIT_PIXEL)) { if (strcmp (opt->name, SANE_NAME_SCAN_BR_X) == 0) { window[0] = i; all_options[option_count].name = "width"; all_options[option_count].val = 'x'; window_option[0] = *opt; window_option[0].title = "Scan width"; window_option[0].desc = "Width of scan-area."; window_option[0].name = "x"; } else if (strcmp (opt->name, SANE_NAME_SCAN_BR_Y) == 0) { window[1] = i; all_options[option_count].name = "height"; all_options[option_count].val = 'y'; window_option[1] = *opt; window_option[1].title = "Scan height"; window_option[1].desc = "Height of scan-area."; window_option[1].name = "y"; } else if (strcmp (opt->name, SANE_NAME_SCAN_TL_X) == 0) { window[2] = i; all_options[option_count].val = 'l'; window_option[2] = *opt; window_option[2].name = "l"; } else if (strcmp (opt->name, SANE_NAME_SCAN_TL_Y) == 0) { window[3] = i; all_options[option_count].val = 't'; window_option[3] = *opt; window_option[3].name = "t"; } } ++option_count; } memcpy (all_options + option_count, basic_options, sizeof (basic_options)); option_count += NELEMS (basic_options); memset (all_options + option_count, 0, sizeof (all_options[0])); /* Initialize width & height options based on backend default values for top-left x/y and bottom-right x/y: */ for (i = 0; i < 2; ++i) { if (window[i] && !window_val_user[i]) { sane_control_option (device, window[i], SANE_ACTION_GET_VALUE, &window_val[i], 0); if (window[i + 2]){ SANE_Word pos; sane_control_option (device, window[i + 2], SANE_ACTION_GET_VALUE, &pos, 0); window_val[i] -= pos; } } } } static void set_option (SANE_Handle device, int optnum, void *valuep) { const SANE_Option_Descriptor *opt; SANE_Status status; SANE_Word orig = 0; SANE_Int info = 0; opt = sane_get_option_descriptor (device, optnum); if (opt && (!SANE_OPTION_IS_ACTIVE (opt->cap))) { if (verbose > 0) fprintf (stderr, "%s: ignored request to set inactive option %s\n", prog_name, opt->name); return; } if (opt->size == sizeof (SANE_Word) && opt->type != SANE_TYPE_STRING) orig = *(SANE_Word *) valuep; status = sane_control_option (device, optnum, SANE_ACTION_SET_VALUE, valuep, &info); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: setting of option --%s failed (%s)\n", prog_name, opt->name, sane_strstatus (status)); scanimage_exit (1); } if ((info & SANE_INFO_INEXACT) && opt->size == sizeof (SANE_Word)) { if (opt->type == SANE_TYPE_INT) fprintf (stderr, "%s: rounded value of %s from %d to %d\n", prog_name, opt->name, orig, *(SANE_Word *) valuep); else if (opt->type == SANE_TYPE_FIXED) fprintf (stderr, "%s: rounded value of %s from %g to %g\n", prog_name, opt->name, SANE_UNFIX (orig), SANE_UNFIX (*(SANE_Word *) valuep)); } if (info & SANE_INFO_RELOAD_OPTIONS) fetch_options (device); } static void process_backend_option (SANE_Handle device, int optnum, const char *optarg) { static SANE_Word *vector = 0; static size_t vector_size = 0; const SANE_Option_Descriptor *opt; size_t vector_length; SANE_Status status; SANE_Word value; void *valuep; opt = sane_get_option_descriptor (device, optnum); if (!SANE_OPTION_IS_ACTIVE (opt->cap)) { fprintf (stderr, "%s: attempted to set inactive option %s\n", prog_name, opt->name); scanimage_exit (1); } if ((opt->cap & SANE_CAP_AUTOMATIC) && optarg && strncasecmp (optarg, "auto", 4) == 0) { status = sane_control_option (device, optnum, SANE_ACTION_SET_AUTO, 0, 0); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: failed to set option --%s to automatic (%s)\n", prog_name, opt->name, sane_strstatus (status)); scanimage_exit (1); } return; } valuep = &value; switch (opt->type) { case SANE_TYPE_BOOL: value = 1; /* no argument means option is set */ if (optarg) { if (strncasecmp (optarg, "yes", strlen (optarg)) == 0) value = 1; else if (strncasecmp (optarg, "no", strlen (optarg)) == 0) value = 0; else { fprintf (stderr, "%s: option --%s: bad option value `%s'\n", prog_name, opt->name, optarg); scanimage_exit (1); } } break; case SANE_TYPE_INT: case SANE_TYPE_FIXED: /* ensure vector is long enough: */ vector_length = opt->size / sizeof (SANE_Word); if (vector_size < vector_length) { vector_size = vector_length; vector = realloc (vector, vector_length * sizeof (SANE_Word)); if (!vector) { fprintf (stderr, "%s: out of memory\n", prog_name); scanimage_exit (1); } } parse_vector (opt, optarg, vector, vector_length); valuep = vector; break; case SANE_TYPE_STRING: valuep = malloc (opt->size); if (!valuep) { fprintf (stderr, "%s: out of memory\n", prog_name); scanimage_exit (1); } strncpy (valuep, optarg, opt->size); ((char *) valuep)[opt->size - 1] = 0; break; case SANE_TYPE_BUTTON: value = 0; /* value doesn't matter */ break; default: fprintf (stderr, "%s: duh, got unknown option type %d\n", prog_name, opt->type); return; } set_option (device, optnum, valuep); } static void write_pnm_header (SANE_Frame format, int width, int height, int depth, FILE *ofp) { /* The netpbm-package does not define raw image data with maxval > 255. */ /* But writing maxval 65535 for 16bit data gives at least a chance */ /* to read the image. */ switch (format) { case SANE_FRAME_RED: case SANE_FRAME_GREEN: case SANE_FRAME_BLUE: case SANE_FRAME_RGB: fprintf (ofp, "P6\n# SANE data follows\n%d %d\n%d\n", width, height, (depth <= 8) ? 255 : 65535); break; default: if (depth == 1) fprintf (ofp, "P4\n# SANE data follows\n%d %d\n", width, height); else fprintf (ofp, "P5\n# SANE data follows\n%d %d\n%d\n", width, height, (depth <= 8) ? 255 : 65535); break; } #ifdef __EMX__ /* OS2 - write in binary mode. */ _fsetmode (ofp, "b"); #endif } #ifdef HAVE_LIBPNG static void write_png_header (SANE_Frame format, int width, int height, int depth, int dpi, const char * icc_profile, FILE *ofp, png_structp* png_ptr, png_infop* info_ptr) { int color_type; /* PNG does not have imperial reference units, so we must convert to metric. */ /* There are nominally 39.3700787401575 inches in a meter. */ const double pixels_per_meter = dpi * 39.3700787401575; size_t icc_size = 0; void *icc_buffer; *png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!*png_ptr) { fprintf(stderr, "png_create_write_struct failed\n"); exit(1); } *info_ptr = png_create_info_struct(*png_ptr); if (!*info_ptr) { fprintf(stderr, "png_create_info_struct failed\n"); exit(1); } png_init_io(*png_ptr, ofp); switch (format) { case SANE_FRAME_RED: case SANE_FRAME_GREEN: case SANE_FRAME_BLUE: case SANE_FRAME_RGB: color_type = PNG_COLOR_TYPE_RGB; break; default: color_type = PNG_COLOR_TYPE_GRAY; break; } png_set_IHDR(*png_ptr, *info_ptr, width, height, depth, color_type, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_set_pHYs(*png_ptr, *info_ptr, pixels_per_meter, pixels_per_meter, PNG_RESOLUTION_METER); if (icc_profile) { icc_buffer = sanei_load_icc_profile(icc_profile, &icc_size); if (icc_size > 0) { /* libpng will abort if the profile and image colour spaces do not match*/ /* The data colour space field is at bytes 16 to 20 in an ICC profile */ /* see: ICC.1:2010 § 7.2.6 */ int is_gray_profile = strncmp((char *) icc_buffer + 16, "GRAY", 4) == 0; int is_rgb_profile = strncmp((char *) icc_buffer + 16, "RGB ", 4) == 0; if ((is_gray_profile && color_type == PNG_COLOR_TYPE_GRAY) || (is_rgb_profile && color_type == PNG_COLOR_TYPE_RGB)) { png_set_iCCP(*png_ptr, *info_ptr, basename(icc_profile), PNG_COMPRESSION_TYPE_BASE, icc_buffer, icc_size); } else { if (is_gray_profile) { fprintf(stderr, "Ignoring 'GRAY' space ICC profile because the image is RGB.\n"); } if (is_rgb_profile) { fprintf(stderr, "Ignoring 'RGB ' space ICC profile because the image is Grayscale.\n"); } } free(icc_buffer); } } png_write_info(*png_ptr, *info_ptr); } #endif #ifdef HAVE_LIBJPEG static void write_jpeg_header (SANE_Frame format, int width, int height, int dpi, FILE *ofp, struct jpeg_compress_struct *cinfo, struct jpeg_error_mgr *jerr) { cinfo->err = jpeg_std_error(jerr); jpeg_create_compress(cinfo); jpeg_stdio_dest(cinfo, ofp); cinfo->image_width = width; cinfo->image_height = height; switch (format) { case SANE_FRAME_RED: case SANE_FRAME_GREEN: case SANE_FRAME_BLUE: case SANE_FRAME_RGB: cinfo->in_color_space = JCS_RGB; cinfo->input_components = 3; break; default: cinfo->in_color_space = JCS_GRAYSCALE; cinfo->input_components = 1; break; } jpeg_set_defaults(cinfo); /* jpeg_set_defaults overrides density, be careful. */ cinfo->density_unit = 1; /* Inches */ cinfo->X_density = cinfo->Y_density = dpi; cinfo->write_JFIF_header = TRUE; jpeg_set_quality(cinfo, 75, TRUE); jpeg_start_compress(cinfo, TRUE); } #endif static void * advance (Image * image) { if (++image->x >= image->width) { image->x = 0; if (++image->y >= image->height || !image->data) { size_t old_size = 0, new_size; if (image->data) old_size = image->height * image->width; image->height += STRIP_HEIGHT; new_size = image->height * image->width; if (image->data) image->data = realloc (image->data, new_size); else image->data = malloc (new_size); if (image->data) memset (image->data + old_size, 0, new_size - old_size); } } if (!image->data) fprintf (stderr, "%s: can't allocate image buffer (%dx%d)\n", prog_name, image->width, image->height); return image->data; } static SANE_Status scan_it (FILE *ofp) { int i, len, first_frame = 1, offset = 0, must_buffer = 0; uint64_t hundred_percent = 0; SANE_Byte min = 0xff, max = 0; SANE_Parameters parm; SANE_Status status; Image image = { 0, 0, 0, 0, 0 }; static const char *format_name[] = { "gray", "RGB", "red", "green", "blue" }; uint64_t total_bytes = 0, expected_bytes; SANE_Int hang_over = -1; #ifdef HAVE_LIBPNG int pngrow = 0; png_bytep pngbuf = NULL; png_structp png_ptr; png_infop info_ptr; #endif #ifdef HAVE_LIBJPEG int jpegrow = 0; JSAMPLE *jpegbuf = NULL; struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; #endif do { if (!first_frame) { #ifdef SANE_STATUS_WARMING_UP do { status = sane_start (device); } while(status == SANE_STATUS_WARMING_UP); #else status = sane_start (device); #endif if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: sane_start: %s\n", prog_name, sane_strstatus (status)); goto cleanup; } } status = sane_get_parameters (device, &parm); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: sane_get_parameters: %s\n", prog_name, sane_strstatus (status)); goto cleanup; } if (verbose) { if (first_frame) { if (parm.lines >= 0) fprintf (stderr, "%s: scanning image of size %dx%d pixels at " "%d bits/pixel\n", prog_name, parm.pixels_per_line, parm.lines, parm.depth * (SANE_FRAME_RGB == parm.format ? 3 : 1)); else fprintf (stderr, "%s: scanning image %d pixels wide and " "variable height at %d bits/pixel\n", prog_name, parm.pixels_per_line, parm.depth * (SANE_FRAME_RGB == parm.format ? 3 : 1)); } fprintf (stderr, "%s: acquiring %s frame\n", prog_name, parm.format <= SANE_FRAME_BLUE ? format_name[parm.format]:"Unknown"); } if (first_frame) { switch (parm.format) { case SANE_FRAME_RED: case SANE_FRAME_GREEN: case SANE_FRAME_BLUE: assert (parm.depth == 8); must_buffer = 1; offset = parm.format - SANE_FRAME_RED; break; case SANE_FRAME_RGB: assert ((parm.depth == 8) || (parm.depth == 16)); case SANE_FRAME_GRAY: assert ((parm.depth == 1) || (parm.depth == 8) || (parm.depth == 16)); if (parm.lines < 0) { must_buffer = 1; offset = 0; } else switch(output_format) { case OUTPUT_TIFF: sanei_write_tiff_header (parm.format, parm.pixels_per_line, parm.lines, parm.depth, resolution_value, icc_profile, ofp); break; case OUTPUT_PNM: write_pnm_header (parm.format, parm.pixels_per_line, parm.lines, parm.depth, ofp); break; #ifdef HAVE_LIBPNG case OUTPUT_PNG: write_png_header (parm.format, parm.pixels_per_line, parm.lines, parm.depth, resolution_value, icc_profile, ofp, &png_ptr, &info_ptr); break; #endif #ifdef HAVE_LIBJPEG case OUTPUT_JPEG: write_jpeg_header (parm.format, parm.pixels_per_line, parm.lines, resolution_value, ofp, &cinfo, &jerr); break; #endif } break; default: break; } #ifdef HAVE_LIBPNG if(output_format == OUTPUT_PNG) pngbuf = malloc(parm.bytes_per_line); #endif #ifdef HAVE_LIBJPEG if(output_format == OUTPUT_JPEG) jpegbuf = malloc(parm.bytes_per_line); #endif if (must_buffer) { /* We're either scanning a multi-frame image or the scanner doesn't know what the eventual image height will be (common for hand-held scanners). In either case, we need to buffer all data before we can write the image. */ image.width = parm.bytes_per_line; if (parm.lines >= 0) /* See advance(); we allocate one extra line so we don't end up realloc'ing in when the image has been filled in. */ image.height = parm.lines - STRIP_HEIGHT + 1; else image.height = 0; image.x = image.width - 1; image.y = -1; if (!advance (&image)) { status = SANE_STATUS_NO_MEM; goto cleanup; } } } else { assert (parm.format >= SANE_FRAME_RED && parm.format <= SANE_FRAME_BLUE); offset = parm.format - SANE_FRAME_RED; image.x = image.y = 0; } hundred_percent = ((uint64_t)parm.bytes_per_line) * parm.lines * ((parm.format == SANE_FRAME_RGB || parm.format == SANE_FRAME_GRAY) ? 1:3); while (1) { double progr; status = sane_read (device, buffer, buffer_size, &len); total_bytes += (SANE_Word) len; progr = ((total_bytes * 100.) / (double) hundred_percent); if (progr > 100.) progr = 100.; if (progress) { if (parm.lines >= 0) fprintf(stderr, "Progress: %3.1f%%\r", progr); else fprintf(stderr, "Progress: (unknown)\r"); } if (status != SANE_STATUS_GOOD) { if (verbose && parm.depth == 8) fprintf (stderr, "%s: min/max graylevel value = %d/%d\n", prog_name, min, max); if (status != SANE_STATUS_EOF) { fprintf (stderr, "%s: sane_read: %s\n", prog_name, sane_strstatus (status)); return status; } break; } if (must_buffer) { switch (parm.format) { case SANE_FRAME_RED: case SANE_FRAME_GREEN: case SANE_FRAME_BLUE: for (i = 0; i < len; ++i) { image.data[offset + 3 * i] = buffer[i]; if (!advance (&image)) { status = SANE_STATUS_NO_MEM; goto cleanup; } } offset += 3 * len; break; case SANE_FRAME_RGB: for (i = 0; i < len; ++i) { image.data[offset + i] = buffer[i]; if (!advance (&image)) { status = SANE_STATUS_NO_MEM; goto cleanup; } } offset += len; break; case SANE_FRAME_GRAY: for (i = 0; i < len; ++i) { image.data[offset + i] = buffer[i]; if (!advance (&image)) { status = SANE_STATUS_NO_MEM; goto cleanup; } } offset += len; break; default: break; } } else /* ! must_buffer */ { #ifdef HAVE_LIBPNG if (output_format == OUTPUT_PNG) { int i = 0; int left = len; while(pngrow + left >= parm.bytes_per_line) { memcpy(pngbuf + pngrow, buffer + i, parm.bytes_per_line - pngrow); if(parm.depth == 1) { int j; for(j = 0; j < parm.bytes_per_line; j++) pngbuf[j] = ~pngbuf[j]; } #ifndef WORDS_BIGENDIAN /* SANE is endian-native, PNG is big-endian, */ /* see: https://www.w3.org/TR/2003/REC-PNG-20031110/#7Integers-and-byte-order */ if (parm.depth == 16) { int j; for (j = 0; j < parm.bytes_per_line; j += 2) { SANE_Byte LSB; LSB = pngbuf[j]; pngbuf[j] = pngbuf[j + 1]; pngbuf[j + 1] = LSB; } } #endif png_write_row(png_ptr, pngbuf); i += parm.bytes_per_line - pngrow; left -= parm.bytes_per_line - pngrow; pngrow = 0; } memcpy(pngbuf + pngrow, buffer + i, left); pngrow += left; } else #endif #ifdef HAVE_LIBJPEG if (output_format == OUTPUT_JPEG) { int i = 0; int left = len; while(jpegrow + left >= parm.bytes_per_line) { memcpy(jpegbuf + jpegrow, buffer + i, parm.bytes_per_line - jpegrow); if(parm.depth == 1) { int col1, col8; JSAMPLE *buf8 = malloc(parm.bytes_per_line * 8); for(col1 = 0; col1 < parm.bytes_per_line; col1++) for(col8 = 0; col8 < 8; col8++) buf8[col1 * 8 + col8] = jpegbuf[col1] & (1 << (8 - col8 - 1)) ? 0 : 0xff; jpeg_write_scanlines(&cinfo, &buf8, 1); free(buf8); } else { jpeg_write_scanlines(&cinfo, &jpegbuf, 1); } i += parm.bytes_per_line - jpegrow; left -= parm.bytes_per_line - jpegrow; jpegrow = 0; } memcpy(jpegbuf + jpegrow, buffer + i, left); jpegrow += left; } else #endif if ((output_format == OUTPUT_TIFF) || (parm.depth != 16)) fwrite (buffer, 1, len, ofp); else { #if !defined(WORDS_BIGENDIAN) int i, start = 0; /* check if we have saved one byte from the last sane_read */ if (hang_over > -1) { if (len > 0) { fwrite (buffer, 1, 1, ofp); buffer[0] = (SANE_Byte) hang_over; hang_over = -1; start = 1; } } /* now do the byte-swapping */ for (i = start; i < (len - 1); i += 2) { unsigned char LSB; LSB = buffer[i]; buffer[i] = buffer[i + 1]; buffer[i + 1] = LSB; } /* check if we have an odd number of bytes */ if (((len - start) % 2) != 0) { hang_over = buffer[len - 1]; len--; } #endif fwrite (buffer, 1, len, ofp); } } if (verbose && parm.depth == 8) { for (i = 0; i < len; ++i) if (buffer[i] >= max) max = buffer[i]; else if (buffer[i] < min) min = buffer[i]; } } first_frame = 0; } while (!parm.last_frame); if (must_buffer) { image.height = image.y; switch(output_format) { case OUTPUT_TIFF: sanei_write_tiff_header (parm.format, parm.pixels_per_line, image.height, parm.depth, resolution_value, icc_profile, ofp); break; case OUTPUT_PNM: write_pnm_header (parm.format, parm.pixels_per_line, image.height, parm.depth, ofp); break; #ifdef HAVE_LIBPNG case OUTPUT_PNG: write_png_header (parm.format, parm.pixels_per_line, image.height, parm.depth, resolution_value, icc_profile, ofp, &png_ptr, &info_ptr); break; #endif #ifdef HAVE_LIBJPEG case OUTPUT_JPEG: write_jpeg_header (parm.format, parm.pixels_per_line, parm.lines, resolution_value, ofp, &cinfo, &jerr); break; #endif } #if !defined(WORDS_BIGENDIAN) /* multibyte pnm file may need byte swap to LE */ /* FIXME: other bit depths? */ if (output_format != OUTPUT_TIFF && parm.depth == 16) { int i; for (i = 0; i < image.height * image.width; i += 2) { unsigned char LSB; LSB = image.data[i]; image.data[i] = image.data[i + 1]; image.data[i + 1] = LSB; } } #endif fwrite (image.data, 1, image.height * image.width, ofp); } #ifdef HAVE_LIBPNG if(output_format == OUTPUT_PNG) png_write_end(png_ptr, info_ptr); #endif #ifdef HAVE_LIBJPEG if(output_format == OUTPUT_JPEG) jpeg_finish_compress(&cinfo); #endif /* flush the output buffer */ fflush( ofp ); cleanup: #ifdef HAVE_LIBPNG if(output_format == OUTPUT_PNG) { png_destroy_write_struct(&png_ptr, &info_ptr); free(pngbuf); } #endif #ifdef HAVE_LIBJPEG if(output_format == OUTPUT_JPEG) { jpeg_destroy_compress(&cinfo); free(jpegbuf); } #endif if (image.data) free (image.data); expected_bytes = ((uint64_t)parm.bytes_per_line) * parm.lines * ((parm.format == SANE_FRAME_RGB || parm.format == SANE_FRAME_GRAY) ? 1 : 3); if (parm.lines < 0) expected_bytes = 0; if (total_bytes > expected_bytes && expected_bytes != 0) { fprintf (stderr, "%s: WARNING: read more data than announced by backend " "(%" PRIu64 "/%" PRIu64 ")\n", prog_name, total_bytes, expected_bytes); } else if (verbose) fprintf (stderr, "%s: read %" PRIu64 " bytes in total\n", prog_name, total_bytes); return status; } #define clean_buffer(buf,size) memset ((buf), 0x23, size) static void pass_fail (int max, int len, SANE_Byte * buffer, SANE_Status status) { if (status != SANE_STATUS_GOOD) fprintf (stderr, "FAIL Error: %s\n", sane_strstatus (status)); else if (buffer[len] != 0x23) { while (len <= max && buffer[len] != 0x23) ++len; fprintf (stderr, "FAIL Cheat: %d bytes\n", len); } else if (len > max) fprintf (stderr, "FAIL Overflow: %d bytes\n", len); else if (len == 0) fprintf (stderr, "FAIL No data\n"); else fprintf (stderr, "PASS\n"); } static SANE_Status test_it (void) { int i, len; SANE_Parameters parm; SANE_Status status; Image image = { 0, 0, 0, 0, 0 }; static const char *format_name[] = { "gray", "RGB", "red", "green", "blue" }; #ifdef SANE_STATUS_WARMING_UP do { status = sane_start (device); } while(status == SANE_STATUS_WARMING_UP); #else status = sane_start (device); #endif if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: sane_start: %s\n", prog_name, sane_strstatus (status)); goto cleanup; } status = sane_get_parameters (device, &parm); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: sane_get_parameters: %s\n", prog_name, sane_strstatus (status)); goto cleanup; } if (parm.lines >= 0) fprintf (stderr, "%s: scanning image of size %dx%d pixels at " "%d bits/pixel\n", prog_name, parm.pixels_per_line, parm.lines, parm.depth * (SANE_FRAME_RGB == parm.format ? 3 : 1)); else fprintf (stderr, "%s: scanning image %d pixels wide and " "variable height at %d bits/pixel\n", prog_name, parm.pixels_per_line, parm.depth * (SANE_FRAME_RGB == parm.format ? 3 : 1)); fprintf (stderr, "%s: acquiring %s frame, %d bits/sample\n", prog_name, parm.format <= SANE_FRAME_BLUE ? format_name[parm.format]:"Unknown", parm.depth); image.data = malloc (parm.bytes_per_line * 2); clean_buffer (image.data, parm.bytes_per_line * 2); fprintf (stderr, "%s: reading one scanline, %d bytes...\t", prog_name, parm.bytes_per_line); status = sane_read (device, image.data, parm.bytes_per_line, &len); pass_fail (parm.bytes_per_line, len, image.data, status); if (status != SANE_STATUS_GOOD) goto cleanup; clean_buffer (image.data, parm.bytes_per_line * 2); fprintf (stderr, "%s: reading one byte...\t\t", prog_name); status = sane_read (device, image.data, 1, &len); pass_fail (1, len, image.data, status); if (status != SANE_STATUS_GOOD) goto cleanup; for (i = 2; i < parm.bytes_per_line * 2; i *= 2) { clean_buffer (image.data, parm.bytes_per_line * 2); fprintf (stderr, "%s: stepped read, %d bytes... \t", prog_name, i); status = sane_read (device, image.data, i, &len); pass_fail (i, len, image.data, status); if (status != SANE_STATUS_GOOD) goto cleanup; } for (i /= 2; i > 2; i /= 2) { clean_buffer (image.data, parm.bytes_per_line * 2); fprintf (stderr, "%s: stepped read, %d bytes... \t", prog_name, i - 1); status = sane_read (device, image.data, i - 1, &len); pass_fail (i - 1, len, image.data, status); if (status != SANE_STATUS_GOOD) goto cleanup; } cleanup: sane_cancel (device); if (image.data) free (image.data); return status; } static int get_resolution (void) { const SANE_Option_Descriptor *resopt; int resol = 0; void *val; if (resolution_optind < 0) return 0; resopt = sane_get_option_descriptor (device, resolution_optind); if (!resopt) return 0; val = alloca (resopt->size); if (!val) return 0; sane_control_option (device, resolution_optind, SANE_ACTION_GET_VALUE, val, 0); if (resopt->type == SANE_TYPE_INT) resol = *(SANE_Int *) val; else resol = (int) (SANE_UNFIX (*(SANE_Fixed *) val) + 0.5); return resol; } static void scanimage_exit (int status) { if (device) { if (verbose > 1) fprintf (stderr, "Closing device\n"); sane_close (device); } if (verbose > 1) fprintf (stderr, "Calling sane_exit\n"); sane_exit (); if (all_options) free (all_options); if (option_number) free (option_number); if (verbose > 1) fprintf (stderr, "scanimage: finished\n"); exit (status); } /** @brief print device options to stdout * * @param device struct of the opened device to describe * @param num_dev_options number of device options * @param ro SANE_TRUE to print read-only options */ static void print_options(SANE_Device * device, SANE_Int num_dev_options, SANE_Bool ro) { int i, j; const SANE_Option_Descriptor *opt; for (i = 1; i < num_dev_options; ++i) { opt = 0; /* scan area uses modified option struct */ for (j = 0; j < 4; ++j) if (i == window[j]) opt = window_option + j; if (!opt) opt = sane_get_option_descriptor (device, i); if (ro || SANE_OPTION_IS_SETTABLE (opt->cap) || opt->type == SANE_TYPE_GROUP) print_option (device, i, opt); } if (num_dev_options) fputc ('\n', stdout); } static int guess_output_format(const char* output_file) { if (output_file == NULL) { fprintf(stderr, "Output format is not set, using pnm as a default.\n"); return OUTPUT_PNM; } // if the user passes us a path with a known extension then he won't be surprised if we figure // out correct --format option. No warning is necessary in that case. const char* extension = strrchr(output_file, '.'); if (extension != NULL) { struct { const char* extension; int output_format; } formats[] = { { ".pnm", OUTPUT_PNM }, { ".png", OUTPUT_PNG }, { ".jpg", OUTPUT_JPEG }, { ".jpeg", OUTPUT_JPEG }, { ".tiff", OUTPUT_TIFF }, { ".tif", OUTPUT_TIFF } }; for (unsigned i = 0; i < sizeof(formats) / sizeof(formats[0]); ++i) { if (strcmp(extension, formats[i].extension) == 0) return formats[i].output_format; } } // it would be very confusing if user makes a typo in the filename and the output format changes. // This is most likely not what the user wanted. fprintf(stderr, "Could not guess output format from the given path and no --format given.\n"); exit(1); } int main (int argc, char **argv) { int ch, i, index, all_options_len; const SANE_Device **device_list; SANE_Int num_dev_options = 0; const char *devname = 0; const char *defdevname = 0; const char *format = 0; char readbuf[2]; char *readbuf2; int batch = 0; int batch_print = 0; int batch_prompt = 0; int batch_count = BATCH_COUNT_UNLIMITED; int batch_start_at = 1; int batch_increment = 1; SANE_Status status; char *full_optstring; SANE_Int version_code; FILE *ofp = NULL; buffer_size = (32 * 1024); /* default size */ prog_name = strrchr (argv[0], '/'); if (prog_name) ++prog_name; else prog_name = argv[0]; defdevname = getenv ("SANE_DEFAULT_DEVICE"); sane_init (&version_code, auth_callback); /* make a first pass through the options with error printing and argument permutation disabled: */ opterr = 0; while ((ch = getopt_long (argc, argv, "-" BASE_OPTSTRING, basic_options, &index)) != EOF) { switch (ch) { case ':': case '?': break; /* may be an option that we'll parse later on */ case 'd': devname = optarg; break; case 'b': /* This may have already been set by the batch-count flag */ batch = 1; format = optarg; break; case 'h': help = 1; break; case 'i': /* icc profile */ icc_profile = optarg; break; case 'v': ++verbose; break; case 'p': progress = 1; break; case 'o': output_file = optarg; break; case 'B': if (optarg) buffer_size = 1024 * atoi(optarg); else buffer_size = (1024 * 1024); break; case 'T': test = 1; break; case 'A': all = 1; break; case 'n': dont_scan = 1; break; case OPTION_BATCH_PRINT: batch_print = 1; break; case OPTION_BATCH_PROMPT: batch_prompt = 1; break; case OPTION_BATCH_INCREMENT: batch_increment = atoi (optarg); break; case OPTION_BATCH_START_AT: batch_start_at = atoi (optarg); break; case OPTION_BATCH_DOUBLE: batch_increment = 2; break; case OPTION_BATCH_COUNT: batch_count = atoi (optarg); batch = 1; break; case OPTION_FORMAT: if (strcmp (optarg, "tiff") == 0) output_format = OUTPUT_TIFF; else if (strcmp (optarg, "png") == 0) { #ifdef HAVE_LIBPNG output_format = OUTPUT_PNG; #else fprintf(stderr, "PNG support not compiled in\n"); exit(1); #endif } else if (strcmp (optarg, "jpeg") == 0) { #ifdef HAVE_LIBJPEG output_format = OUTPUT_JPEG; #else fprintf(stderr, "JPEG support not compiled in\n"); exit(1); #endif } else if (strcmp (optarg, "pnm") == 0) { output_format = OUTPUT_PNM; } else { fprintf(stderr, "Unknown output image format '%s'.\n", optarg); fprintf(stderr, "Supported formats: pnm, tiff"); #ifdef HAVE_LIBPNG fprintf(stderr, ", png"); #endif #ifdef HAVE_LIBJPEG fprintf(stderr, ", jpeg"); #endif fprintf(stderr, ".\n"); exit(1); } break; case OPTION_MD5: accept_only_md5_auth = 1; break; case 'L': case 'f': { int i = 0; status = sane_get_devices (&device_list, SANE_FALSE); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: sane_get_devices() failed: %s\n", prog_name, sane_strstatus (status)); scanimage_exit (1); } if (ch == 'L') { for (i = 0; device_list[i]; ++i) { printf ("device `%s' is a %s %s %s\n", device_list[i]->name, device_list[i]->vendor, device_list[i]->model, device_list[i]->type); } } else { int i = 0, int_arg = 0; const char *percent, *start; const char *text_arg = 0; char ftype; for (i = 0; device_list[i]; ++i) { start = optarg; while (*start && (percent = strchr (start, '%'))) { int start_len = percent - start; percent++; if (*percent) { switch (*percent) { case 'd': text_arg = device_list[i]->name; ftype = 's'; break; case 'v': text_arg = device_list[i]->vendor; ftype = 's'; break; case 'm': text_arg = device_list[i]->model; ftype = 's'; break; case 't': text_arg = device_list[i]->type; ftype = 's'; break; case 'i': int_arg = i; ftype = 'i'; break; case 'n': text_arg = "\n"; ftype = 's'; break; case '%': text_arg = "%"; ftype = 's'; break; default: fprintf (stderr, "%s: unknown format specifier %%%c\n", prog_name, *percent); text_arg = "%"; ftype = 's'; } printf ("%.*s", start_len, start); switch (ftype) { case 's': printf ("%s", text_arg); break; case 'i': printf ("%i", int_arg); break; } start = percent + 1; } else { /* last char of the string is a '%', ignore it */ start++; break; } } if (*start) printf ("%s", start); } } if (i == 0 && ch != 'f') printf ("\nNo scanners were identified. If you were expecting " "something different,\ncheck that the scanner is plugged " "in, turned on and detected by the\nsane-find-scanner tool " "(if appropriate). Please read the documentation\nwhich came " "with this software (README, FAQ, manpages).\n"); if (defdevname) printf ("default device is `%s'\n", defdevname); scanimage_exit (0); break; } case 'V': printf ("scanimage (%s) %s; backend version %d.%d.%d\n", PACKAGE, VERSION, SANE_VERSION_MAJOR (version_code), SANE_VERSION_MINOR (version_code), SANE_VERSION_BUILD (version_code)); scanimage_exit (0); break; default: break; /* ignore device specific options for now */ } } if (help) { printf ("Usage: %s [OPTION]...\n\ \n\ Start image acquisition on a scanner device and write image data to\n\ standard output.\n\ \n\ Parameters are separated by a blank from single-character options (e.g.\n\ -d epson) and by a \"=\" from multi-character options (e.g. --device-name=epson).\n\ -d, --device-name=DEVICE use a given scanner device (e.g. hp:/dev/scanner)\n\ --format=pnm|tiff|png|jpeg file format of output file\n\ -i, --icc-profile=PROFILE include this ICC profile into TIFF file\n", prog_name); printf ("\ -L, --list-devices show available scanner devices\n\ -f, --formatted-device-list=FORMAT similar to -L, but the FORMAT of the output\n\ can be specified: %%d (device name), %%v (vendor),\n\ %%m (model), %%t (type), %%i (index number), and\n\ %%n (newline)\n\ -b, --batch[=FORMAT] working in batch mode, FORMAT is `out%%d.pnm' `out%%d.tif'\n\ `out%%d.png' or `out%%d.jpg' by default depending on --format\n\ This option is incompatible with --output-file."); printf ("\ --batch-start=# page number to start naming files with\n\ --batch-count=# how many pages to scan in batch mode\n\ --batch-increment=# increase page number in filename by #\n\ --batch-double increment page number by two, same as\n\ --batch-increment=2\n\ --batch-print print image filenames to stdout\n\ --batch-prompt ask for pressing a key before scanning a page\n"); printf ("\ --accept-md5-only only accept authorization requests using md5\n\ -p, --progress print progress messages\n\ -o, --output-file=PATH save output to the given file instead of stdout.\n\ This option is incompatible with --batch.\n\ -n, --dont-scan only set options, don't actually scan\n\ -T, --test test backend thoroughly\n\ -A, --all-options list all available backend options\n\ -h, --help display this help message and exit\n\ -v, --verbose give even more status messages\n\ -B, --buffer-size=# change input buffer size (in kB, default 32)\n"); printf ("\ -V, --version print version information\n"); } if (batch && output_file != NULL) { fprintf(stderr, "--batch and --output-file can't be used together.\n"); exit(1); } if (output_format == OUTPUT_UNKNOWN) output_format = guess_output_format(output_file); if (!devname) { /* If no device name was specified explicitly, we look at the environment variable SANE_DEFAULT_DEVICE. If this variable is not set, we open the first device we find (if any): */ devname = defdevname; if (!devname) { status = sane_get_devices (&device_list, SANE_FALSE); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: sane_get_devices() failed: %s\n", prog_name, sane_strstatus (status)); scanimage_exit (1); } if (!device_list[0]) { fprintf (stderr, "%s: no SANE devices found\n", prog_name); scanimage_exit (1); } devname = device_list[0]->name; } } status = sane_open (devname, &device); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: open of device %s failed: %s\n", prog_name, devname, sane_strstatus (status)); if (devname[0] == '/') fprintf (stderr, "\nYou seem to have specified a UNIX device name, " "or filename instead of selecting\nthe SANE scanner or " "image acquisition device you want to use. As an example,\n" "you might want \"epson:/dev/sg0\" or " "\"hp:/dev/usbscanner0\". If any supported\ndevices are " "installed in your system, you should be able to see a " "list with\n\"scanimage --list-devices\".\n"); if (help) device = 0; else scanimage_exit (1); } if (device) { const SANE_Option_Descriptor * desc_ptr; /* Good form to always get the descriptor once before value */ desc_ptr = sane_get_option_descriptor(device, 0); if (!desc_ptr) { fprintf (stderr, "%s: unable to get option count descriptor\n", prog_name); scanimage_exit (1); } /* We got a device, find out how many options it has */ status = sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0); if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: unable to determine option count\n", prog_name); scanimage_exit (1); } /* malloc global option lists */ all_options_len = num_dev_options + NELEMS (basic_options) + 1; all_options = malloc (all_options_len * sizeof (all_options[0])); option_number_len = num_dev_options; option_number = malloc (option_number_len * sizeof (option_number[0])); if (!all_options || !option_number) { fprintf (stderr, "%s: out of memory in main()\n", prog_name); scanimage_exit (1); } /* load global option lists */ fetch_options (device); { char *larg, *targ, *xarg, *yarg; larg = targ = xarg = yarg = ""; /* Maybe accept t, l, x, and y options. */ if (window[0]) xarg = "x:"; if (window[1]) yarg = "y:"; if (window[2]) larg = "l:"; if (window[3]) targ = "t:"; /* Now allocate the full option list. */ full_optstring = malloc (strlen (BASE_OPTSTRING) + strlen (larg) + strlen (targ) + strlen (xarg) + strlen (yarg) + 1); if (!full_optstring) { fprintf (stderr, "%s: out of memory\n", prog_name); scanimage_exit (1); } strcpy (full_optstring, BASE_OPTSTRING); strcat (full_optstring, larg); strcat (full_optstring, targ); strcat (full_optstring, xarg); strcat (full_optstring, yarg); } /* re-run argument processing with backend-specific options included * this time, enable error printing and arg permutation */ optind = 0; opterr = 1; while ((ch = getopt_long (argc, argv, full_optstring, all_options, &index)) != EOF) { switch (ch) { case ':': case '?': scanimage_exit (1); /* error message is printed by getopt_long() */ case 'd': case 'h': case 'p': case 'o': case 'v': case 'V': case 'T': case 'B': /* previously handled options */ break; case 'x': window_val_user[0] = 1; parse_vector (&window_option[0], optarg, &window_val[0], 1); break; case 'y': window_val_user[1] = 1; parse_vector (&window_option[1], optarg, &window_val[1], 1); break; case 'l': /* tl-x */ process_backend_option (device, window[2], optarg); break; case 't': /* tl-y */ process_backend_option (device, window[3], optarg); break; case 0: process_backend_option (device, option_number[index], optarg); break; } } if (optind < argc) { fprintf (stderr, "%s: argument without option: `%s'; ", prog_name, argv[argc - 1]); fprintf (stderr, "try %s --help\n", prog_name); scanimage_exit (1); } free (full_optstring); /* convert x/y to br_x/br_y */ for (index = 0; index < 2; ++index) if (window[index]) { SANE_Word pos = 0; SANE_Word val = window_val[index]; if (window[index + 2]) { sane_control_option (device, window[index + 2], SANE_ACTION_GET_VALUE, &pos, 0); val += pos; } set_option (device, window[index], &val); } /* output device-specific help */ if (help) { printf ("\nOptions specific to device `%s':\n", devname); print_options(device, num_dev_options, SANE_FALSE); } /* list all device-specific options */ if (all) { printf ("\nAll options specific to device `%s':\n", devname); print_options(device, num_dev_options, SANE_TRUE); scanimage_exit (0); } } /* output device list */ if (help) { printf ("\ Type ``%s --help -d DEVICE'' to get list of all options for DEVICE.\n\ \n\ List of available devices:", prog_name); status = sane_get_devices (&device_list, SANE_FALSE); if (status == SANE_STATUS_GOOD) { int column = 80; for (i = 0; device_list[i]; ++i) { if (column + strlen (device_list[i]->name) + 1 >= 80) { printf ("\n "); column = 4; } if (column > 4) { fputc (' ', stdout); column += 1; } fputs (device_list[i]->name, stdout); column += strlen (device_list[i]->name); } } fputc ('\n', stdout); scanimage_exit (0); } if (dont_scan) scanimage_exit (0); if (output_format != OUTPUT_PNM) resolution_value = get_resolution (); #ifdef SIGHUP signal (SIGHUP, sighandler); #endif #ifdef SIGPIPE signal (SIGPIPE, sighandler); #endif signal (SIGINT, sighandler); signal (SIGTERM, sighandler); if (test == 0) { int n = batch_start_at; if (batch && NULL == format) { switch(output_format) { case OUTPUT_TIFF: format = "out%d.tif"; break; case OUTPUT_PNM: format = "out%d.pnm"; break; #ifdef HAVE_LIBPNG case OUTPUT_PNG: format = "out%d.png"; break; #endif #ifdef HAVE_LIBJPEG case OUTPUT_JPEG: format = "out%d.jpg"; break; #endif } } if (!batch) { ofp = stdout; if (output_file != NULL) { ofp = fopen(output_file, "w"); if (ofp == NULL) { fprintf(stderr, "%s: could not open input file '%s', " "exiting\n", prog_name, output_file); scanimage_exit(1); } } } if (batch) { fputs("Scanning ", stderr); if (batch_count == BATCH_COUNT_UNLIMITED) fputs("infinity", stderr); else fprintf(stderr, "%d", batch_count); fprintf (stderr, " page%s, incrementing by %d, numbering from %d\n", batch_count == 1 ? "" : "s", batch_increment, batch_start_at); } else if(isatty(fileno(ofp))){ fprintf (stderr,"%s: output is not a file, exiting\n", prog_name); scanimage_exit (1); } buffer = malloc (buffer_size); do { char path[PATH_MAX]; char part_path[PATH_MAX]; if (batch) /* format is NULL unless batch mode */ { sprintf (path, format, n); /* love --(C++) */ strcpy (part_path, path); strcat (part_path, ".part"); } if (batch) { if (batch_prompt) { fprintf (stderr, "Place document no. %d on the scanner.\n", n); fprintf (stderr, "Press to continue.\n"); fprintf (stderr, "Press Ctrl + D to terminate.\n"); readbuf2 = fgets (readbuf, 2, stdin); if (readbuf2 == NULL) { if (ofp) { fclose (ofp); ofp = NULL; } break; /* get out of this loop */ } } fprintf (stderr, "Scanning page %d\n", n); } #ifdef SANE_STATUS_WARMING_UP do { status = sane_start (device); } while(status == SANE_STATUS_WARMING_UP); #else status = sane_start (device); #endif if (status != SANE_STATUS_GOOD) { fprintf (stderr, "%s: sane_start: %s\n", prog_name, sane_strstatus (status)); if (ofp) { fclose (ofp); ofp = NULL; } break; } /* write to .part file while scanning is in progress */ if (batch) { if (NULL == (ofp = fopen (part_path, "w"))) { fprintf (stderr, "cannot open %s\n", part_path); sane_cancel (device); return SANE_STATUS_ACCESS_DENIED; } } status = scan_it (ofp); if (batch) { fprintf (stderr, "Scanned page %d.", n); fprintf (stderr, " (scanner status = %d)\n", status); } switch (status) { case SANE_STATUS_GOOD: case SANE_STATUS_EOF: status = SANE_STATUS_GOOD; if (batch) { if (!ofp || 0 != fclose(ofp)) { fprintf (stderr, "cannot close image file\n"); sane_cancel (device); return SANE_STATUS_ACCESS_DENIED; } else { ofp = NULL; /* let the fully scanned file show up */ if (rename (part_path, path)) { fprintf (stderr, "cannot rename %s to %s\n", part_path, path); sane_cancel (device); return SANE_STATUS_ACCESS_DENIED; } if (batch_print) { fprintf (stdout, "%s\n", path); fflush (stdout); } } } else { if (output_file && ofp) { fclose(ofp); ofp = NULL; } } break; default: if (batch) { if (ofp) { fclose (ofp); ofp = NULL; } unlink (part_path); } else { if (output_file && ofp) { fclose(ofp); ofp = NULL; } unlink (output_file); } break; } /* switch */ n += batch_increment; } while ((batch && (batch_count == BATCH_COUNT_UNLIMITED || --batch_count)) && SANE_STATUS_GOOD == status); if (batch) { int num_pgs = (n - batch_start_at) / batch_increment; fprintf (stderr, "Batch terminated, %d page%s scanned\n", num_pgs, num_pgs == 1 ? "" : "s"); } if (batch && SANE_STATUS_NO_DOCS == status && (batch_count == BATCH_COUNT_UNLIMITED) && n > batch_start_at) status = SANE_STATUS_GOOD; sane_cancel (device); } else status = test_it (); scanimage_exit (status); /* the line below avoids compiler warnings */ return status; } sane-backends-1.0.29/frontend/stiff.c0000666000000000000000000003564613615534521014315 00000000000000/* Create SANE/tiff headers TIFF interfacing routines for SANE Copyright (C) 2000 Peter Kirchgessner Copyright (C) 2002 Oliver Rauch: added tiff ICC profile Copyright (C) 2017 Aaron Muir Hamilton 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Changes: 2000-11-19, PK: Color TIFF-header: write 3 values for bits per sample 2001-12-16, PK: Write fill order tag for b/w-images 2002-08-27, OR: Added tiff tag for ICC profile 2017-04-16, AMH: Separate ICC profile loading into a separate file */ #ifdef _AIX # include "../include/lalloca.h" /* MUST come first for AIX! */ #endif #include #include #include "../include/sane/config.h" #include "../include/sane/sane.h" #include "sicc.h" #include "stiff.h" typedef struct { int tag, typ, nvals, val; } IFD_ENTRY; typedef struct { int maxtags; int ntags; IFD_ENTRY *ifde; } IFD; #define IFDE_TYP_BYTE (1) #define IFDE_TYP_ASCII (2) #define IFDE_TYP_SHORT (3) #define IFDE_TYP_LONG (4) #define IFDE_TYP_RATIONAL (5) static IFD * create_ifd (void) { IFD *ifd; int maxtags = 10; ifd = (IFD *)malloc (sizeof (IFD)); if (ifd == NULL) return NULL; ifd->ifde = (IFD_ENTRY *)malloc (maxtags * sizeof (IFD_ENTRY)); if (ifd->ifde == NULL) { free (ifd); return NULL; } ifd->ntags = 0; ifd->maxtags = maxtags; return ifd; } static void free_ifd (IFD *ifd) { if (ifd == NULL) return; if (ifd->ifde != NULL) { free (ifd->ifde); ifd->ifde = NULL; } free (ifd); ifd = NULL; } static void add_ifd_entry (IFD *ifd, int tag, int typ, int nvals, int val) { IFD_ENTRY *ifde; int add_entries = 10; if (ifd == NULL) return; if (ifd->ntags == ifd->maxtags) { ifde = (IFD_ENTRY *)realloc (ifd->ifde, (ifd->maxtags+add_entries)*sizeof (IFD_ENTRY)); if (ifde == NULL) return; ifd->ifde = ifde; ifd->maxtags += add_entries; } ifde = &(ifd->ifde[ifd->ntags]); ifde->tag = tag; ifde->typ = typ; ifde->nvals = nvals; ifde->val = val; (ifd->ntags)++; } static void write_i2 (FILE *fptr, int val, int motorola) { if (motorola) { putc ((val >> 8) & 0xff, fptr); putc (val & 0xff, fptr); } else { putc (val & 0xff, fptr); putc ((val >> 8) & 0xff, fptr); } } static void write_i4 (FILE *fptr, int val, int motorola) { if (motorola) { putc ((val >> 24) & 0xff, fptr); putc ((val >> 16) & 0xff, fptr); putc ((val >> 8) & 0xff, fptr); putc (val & 0xff, fptr); } else { putc (val & 0xff, fptr); putc ((val >> 8) & 0xff, fptr); putc ((val >> 16) & 0xff, fptr); putc ((val >> 24) & 0xff, fptr); } } static void write_ifd (FILE *fptr, IFD *ifd, int motorola) {int k; IFD_ENTRY *ifde; if (!ifd) return; if (motorola) putc ('M', fptr), putc ('M', fptr); else putc ('I', fptr), putc ('I', fptr); write_i2 (fptr, 42, motorola); /* Magic */ write_i4 (fptr, 8, motorola); /* Offset to first IFD */ write_i2 (fptr, ifd->ntags, motorola); for (k = 0; k < ifd->ntags; k++) { ifde = &(ifd->ifde[k]); write_i2 (fptr, ifde->tag, motorola); write_i2 (fptr, ifde->typ, motorola); write_i4 (fptr, ifde->nvals, motorola); if ((ifde->typ == IFDE_TYP_SHORT) && (ifde->nvals == 1)) { write_i2 (fptr, ifde->val, motorola); write_i2 (fptr, 0, motorola); } else { write_i4 (fptr, ifde->val, motorola); } } write_i4 (fptr, 0, motorola); /* End of IFD chain */ } static void write_tiff_bw_header (FILE *fptr, int width, int height, int resolution) {IFD *ifd; int header_size = 8, ifd_size; int strip_offset, data_offset, data_size; int strip_bytecount; int ntags; int motorola; ifd = create_ifd (); strip_bytecount = ((width+7)/8) * height; /* the following values must be known in advance */ ntags = 12; data_size = 0; if (resolution > 0) { ntags += 3; data_size += 2*4 + 2*4; } ifd_size = 2 + ntags*12 + 4; data_offset = header_size + ifd_size; strip_offset = data_offset + data_size; /* New subfile type */ add_ifd_entry (ifd, 254, IFDE_TYP_LONG, 1, 0); /* image width */ add_ifd_entry (ifd, 256, (width > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT, 1, width); /* image length */ add_ifd_entry (ifd, 257, (height > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT, 1, height); /* bits per sample */ add_ifd_entry (ifd, 258, IFDE_TYP_SHORT, 1, 1); /* compression (uncompressed) */ add_ifd_entry (ifd, 259, IFDE_TYP_SHORT, 1, 1); /* photometric interpretation */ add_ifd_entry (ifd, 262, IFDE_TYP_SHORT, 1, 0); /* fill order */ add_ifd_entry (ifd, 266, IFDE_TYP_SHORT, 1, 1); /* strip offset */ add_ifd_entry (ifd, 273, IFDE_TYP_LONG, 1, strip_offset); /* orientation */ add_ifd_entry (ifd, 274, IFDE_TYP_SHORT, 1, 1); /* samples per pixel */ add_ifd_entry (ifd, 277, IFDE_TYP_SHORT, 1, 1); /* rows per strip */ add_ifd_entry (ifd, 278, IFDE_TYP_LONG, 1, height); /* strip bytecount */ add_ifd_entry (ifd, 279, IFDE_TYP_LONG, 1, strip_bytecount); if (resolution > 0) { /* x resolution */ add_ifd_entry (ifd, 282, IFDE_TYP_RATIONAL, 1, data_offset); data_offset += 2*4; /* y resolution */ add_ifd_entry (ifd, 283, IFDE_TYP_RATIONAL, 1, data_offset); data_offset += 2*4; } if (resolution > 0) { /* resolution unit (dpi) */ add_ifd_entry (ifd, 296, IFDE_TYP_SHORT, 1, 2); } /* I prefer motorola format. Its human readable. */ motorola = 1; write_ifd (fptr, ifd, motorola); /* Write x/y resolution */ if (resolution > 0) { write_i4 (fptr, resolution, motorola); write_i4 (fptr, 1, motorola); write_i4 (fptr, resolution, motorola); write_i4 (fptr, 1, motorola); } free_ifd (ifd); } static void write_tiff_grey_header (FILE *fptr, int width, int height, int depth, int resolution, const char *icc_profile) {IFD *ifd; int header_size = 8, ifd_size; int strip_offset, data_offset, data_size; int strip_bytecount; int ntags; int motorola, bps, maxsamplevalue; void *icc_buffer = NULL; size_t icc_size = 0; if (icc_profile) { icc_buffer = sanei_load_icc_profile(icc_profile, &icc_size); } ifd = create_ifd (); bps = (depth <= 8) ? 1 : 2; /* Bytes per sample */ maxsamplevalue = (depth <= 8) ? 255 : 65535; strip_bytecount = width * height * bps; /* the following values must be known in advance */ ntags = 13; data_size = 0; if (resolution > 0) { ntags += 3; data_size += 2*4 + 2*4; } if (icc_size > 0) /* if icc profile exists add memory for tag */ { ntags += 1; data_size += icc_size; } ifd_size = 2 + ntags*12 + 4; data_offset = header_size + ifd_size; strip_offset = data_offset + data_size; /* New subfile type */ add_ifd_entry (ifd, 254, IFDE_TYP_LONG, 1, 0); /* image width */ add_ifd_entry (ifd, 256, (width > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT, 1, width); /* image length */ add_ifd_entry (ifd, 257, (height > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT, 1, height); /* bits per sample */ add_ifd_entry (ifd, 258, IFDE_TYP_SHORT, 1, depth); /* compression (uncompressed) */ add_ifd_entry (ifd, 259, IFDE_TYP_SHORT, 1, 1); /* photometric interpretation */ add_ifd_entry (ifd, 262, IFDE_TYP_SHORT, 1, 1); /* strip offset */ add_ifd_entry (ifd, 273, IFDE_TYP_LONG, 1, strip_offset); /* orientation */ add_ifd_entry (ifd, 274, IFDE_TYP_SHORT, 1, 1); /* samples per pixel */ add_ifd_entry (ifd, 277, IFDE_TYP_SHORT, 1, 1); /* rows per strip */ add_ifd_entry (ifd, 278, IFDE_TYP_LONG, 1, height); /* strip bytecount */ add_ifd_entry (ifd, 279, IFDE_TYP_LONG, 1, strip_bytecount); /* min sample value */ add_ifd_entry (ifd, 280, IFDE_TYP_SHORT, 1, 0); /* max sample value */ add_ifd_entry (ifd, 281, IFDE_TYP_SHORT, 1, maxsamplevalue); if (resolution > 0) { /* x resolution */ add_ifd_entry (ifd, 282, IFDE_TYP_RATIONAL, 1, data_offset); data_offset += 2*4; /* y resolution */ add_ifd_entry (ifd, 283, IFDE_TYP_RATIONAL, 1, data_offset); data_offset += 2*4; } if (resolution > 0) { /* resolution unit (dpi) */ add_ifd_entry (ifd, 296, IFDE_TYP_SHORT, 1, 2); } if (icc_size > 0) /* add ICC-profile TAG */ { add_ifd_entry(ifd, 34675, 7, (int) icc_size, data_offset); data_offset += icc_size; } /* I prefer motorola format. Its human readable. But for 16 bit, */ /* the image format is defined by SANE to be the native byte order */ if (bps == 1) { motorola = 1; } else {int check = 1; motorola = ((*((char *)&check)) == 0); } write_ifd (fptr, ifd, motorola); /* Write x/y resolution */ if (resolution > 0) { write_i4 (fptr, resolution, motorola); write_i4 (fptr, 1, motorola); write_i4 (fptr, resolution, motorola); write_i4 (fptr, 1, motorola); } if (icc_size > 0) { fwrite(icc_buffer, icc_size, 1, fptr); } free(icc_buffer); free_ifd (ifd); } static void write_tiff_color_header (FILE *fptr, int width, int height, int depth, int resolution, const char *icc_profile) {IFD *ifd; int header_size = 8, ifd_size; int strip_offset, data_offset, data_size; int strip_bytecount; int ntags; int motorola, bps, maxsamplevalue; void *icc_buffer = NULL; size_t icc_size = 0; if (icc_profile) { icc_buffer = sanei_load_icc_profile(icc_profile, &icc_size); } ifd = create_ifd (); bps = (depth <= 8) ? 1 : 2; /* Bytes per sample */ maxsamplevalue = (depth <= 8) ? 255 : 65535; strip_bytecount = width * height * 3 * bps; /* the following values must be known in advance */ ntags = 13; data_size = 3*2 + 3*2 + 3*2; if (resolution > 0) { ntags += 3; data_size += 2*4 + 2*4; } if (icc_size > 0) /* if icc profile exists add memory for tag */ { ntags += 1; data_size += icc_size; } ifd_size = 2 + ntags*12 + 4; data_offset = header_size + ifd_size; strip_offset = data_offset + data_size; /* New subfile type */ add_ifd_entry (ifd, 254, IFDE_TYP_LONG, 1, 0); /* image width */ add_ifd_entry (ifd, 256, (width > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT, 1, width); /* image length */ add_ifd_entry (ifd, 257, (height > 0xffff) ? IFDE_TYP_LONG : IFDE_TYP_SHORT, 1, height); /* bits per sample */ add_ifd_entry (ifd, 258, IFDE_TYP_SHORT, 3, data_offset); data_offset += 3*2; /* compression (uncompressed) */ add_ifd_entry (ifd, 259, IFDE_TYP_SHORT, 1, 1); /* photometric interpretation */ add_ifd_entry (ifd, 262, IFDE_TYP_SHORT, 1, 2); /* strip offset */ add_ifd_entry (ifd, 273, IFDE_TYP_LONG, 1, strip_offset); /* orientation */ add_ifd_entry (ifd, 274, IFDE_TYP_SHORT, 1, 1); /* samples per pixel */ add_ifd_entry (ifd, 277, IFDE_TYP_SHORT, 1, 3); /* rows per strip */ add_ifd_entry (ifd, 278, IFDE_TYP_LONG, 1, height); /* strip bytecount */ add_ifd_entry (ifd, 279, IFDE_TYP_LONG, 1, strip_bytecount); /* min sample value */ add_ifd_entry (ifd, 280, IFDE_TYP_SHORT, 3, data_offset); data_offset += 3*2; /* max sample value */ add_ifd_entry (ifd, 281, IFDE_TYP_SHORT, 3, data_offset); data_offset += 3*2; if (resolution > 0) { /* x resolution */ add_ifd_entry (ifd, 282, IFDE_TYP_RATIONAL, 1, data_offset); data_offset += 2*4; /* y resolution */ add_ifd_entry (ifd, 283, IFDE_TYP_RATIONAL, 1, data_offset); data_offset += 2*4; } if (resolution > 0) { /* resolution unit (dpi) */ add_ifd_entry (ifd, 296, IFDE_TYP_SHORT, 1, 2); } if (icc_size > 0) /* add ICC-profile TAG */ { add_ifd_entry(ifd, 34675, 7, (int) icc_size, data_offset); data_offset += icc_size; } /* I prefer motorola format. Its human readable. But for 16 bit, */ /* the image format is defined by SANE to be the native byte order */ if (bps == 1) { motorola = 1; } else {int check = 1; motorola = ((*((char *)&check)) == 0); } write_ifd (fptr, ifd, motorola); /* Write bits per sample value values */ write_i2 (fptr, depth, motorola); write_i2 (fptr, depth, motorola); write_i2 (fptr, depth, motorola); /* Write min sample value values */ write_i2 (fptr, 0, motorola); write_i2 (fptr, 0, motorola); write_i2 (fptr, 0, motorola); /* Write max sample value values */ write_i2 (fptr, maxsamplevalue, motorola); write_i2 (fptr, maxsamplevalue, motorola); write_i2 (fptr, maxsamplevalue, motorola); /* Write x/y resolution */ if (resolution > 0) { write_i4 (fptr, resolution, motorola); write_i4 (fptr, 1, motorola); write_i4 (fptr, resolution, motorola); write_i4 (fptr, 1, motorola); } /* Write ICC profile */ if (icc_size > 0) { fwrite(icc_buffer, icc_size, 1, fptr); } free(icc_buffer); free_ifd (ifd); } void sanei_write_tiff_header (SANE_Frame format, int width, int height, int depth, int resolution, const char *icc_profile, FILE *ofp) { #ifdef __EMX__ /* OS2 - write in binary mode. */ _fsetmode(ofp, "b"); #endif switch (format) { case SANE_FRAME_RED: case SANE_FRAME_GREEN: case SANE_FRAME_BLUE: case SANE_FRAME_RGB: write_tiff_color_header (ofp, width, height, depth, resolution, icc_profile); break; default: if (depth == 1) write_tiff_bw_header (ofp, width, height, resolution); else write_tiff_grey_header (ofp, width, height, depth, resolution, icc_profile); break; } } sane-backends-1.0.29/frontend/test.c0000666000000000000000000001202613615534521014144 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Andreas Beck This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a simple SANE frontend (well it rather is a transport layer, but seen from libsane it is a frontend) which acts as a NETSANE server. The NETSANE specifications should have come with this package. Feel free to enhance this program ! It needs extension especially regarding crypto-support and authentication. */ #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" void auth_callback (SANE_String_Const domain, SANE_Char *username, SANE_Char *password) { printf ("Client '%s' requested authorization.\nUser:\n", domain); scanf ("%s", username); printf ("Password:\n"); scanf ("%s", password); return; } void testsane (const char *dev_name) { int hlp, x; SANE_Status bla; SANE_Int blubb; SANE_Handle hand; SANE_Parameters pars; const SANE_Option_Descriptor *sod; const SANE_Device **device_list; char buffer[2048]; bla = sane_init (&blubb, auth_callback); fprintf (stderr, "Init : stat=%d ver=%x\nPress Enter to continue...", bla, blubb); getchar (); if (bla != SANE_STATUS_GOOD) return; bla = sane_get_devices (&device_list, SANE_FALSE); fprintf (stderr, "GetDev : stat=%s\n", sane_strstatus (bla)); if (bla != SANE_STATUS_GOOD) return; bla = sane_open (dev_name, &hand); fprintf (stderr, "Open : stat=%s hand=%p\n", sane_strstatus (bla), hand); if (bla != SANE_STATUS_GOOD) return; bla = sane_set_io_mode (hand, 0); fprintf (stderr, "SetIoMode : stat=%s\n", sane_strstatus (bla)); for (hlp = 0; hlp < 9999; hlp++) { sod = sane_get_option_descriptor (hand, hlp); if (sod == NULL) break; fprintf (stderr, "Gopt(%d) : stat=%p\n", hlp, sod); fprintf (stderr, "name : %s\n", sod->name); fprintf (stderr, "title: %s\n", sod->title); fprintf (stderr, "desc : %s\n", sod->desc); fprintf (stderr, "type : %d\n", sod->type); fprintf (stderr, "unit : %d\n", sod->unit); fprintf (stderr, "size : %d\n", sod->size); fprintf (stderr, "cap : %d\n", sod->cap); fprintf (stderr, "ctyp : %d\n", sod->constraint_type); switch (sod->constraint_type) { case SANE_CONSTRAINT_NONE: break; case SANE_CONSTRAINT_STRING_LIST: fprintf (stderr, "stringlist:\n"); break; case SANE_CONSTRAINT_WORD_LIST: fprintf (stderr, "wordlist (%d) : ", sod->constraint.word_list[0]); for (x = 1; x <= sod->constraint.word_list[0]; x++) fprintf (stderr, " %d ", sod->constraint.word_list[x]); fprintf (stderr, "\n"); break; case SANE_CONSTRAINT_RANGE: fprintf (stderr, "range: %d-%d %d \n", sod->constraint.range->min, sod->constraint.range->max, sod->constraint.range->quant); break; } } bla = sane_get_parameters (hand, &pars); fprintf (stderr, "Parm : stat=%s form=%d,lf=%d,bpl=%d,pixpl=%d,lin=%d,dep=%d\n", sane_strstatus (bla), pars.format, pars.last_frame, pars.bytes_per_line, pars.pixels_per_line, pars.lines, pars.depth); if (bla != SANE_STATUS_GOOD) return; bla = sane_start (hand); fprintf (stderr, "Start : stat=%s\n", sane_strstatus (bla)); if (bla != SANE_STATUS_GOOD) return; do { bla = sane_read (hand, buffer, sizeof (buffer), &blubb); /*printf("Read : stat=%s len=%d\n",sane_strstatus (bla),blubb); */ if (bla != SANE_STATUS_GOOD) { if (bla == SANE_STATUS_EOF) break; return; } fwrite (buffer, 1, blubb, stdout); } while (1); sane_cancel (hand); fprintf (stderr, "Cancel.\n"); sane_close (hand); fprintf (stderr, "Close\n"); for (hlp = 0; hlp < 20; hlp++) fprintf (stderr, "STRS %d=%s\n", hlp, sane_strstatus (hlp)); fprintf (stderr, "Exit.\n"); } int main (int argc, char *argv[]) { if (argc != 2 && argc != 3) { fprintf (stderr, "Usage: %s devicename [hostname]\n", argv[0]); exit (0); } if (argc == 3) { char envbuf[1024]; sprintf (envbuf, "SANE_NET_HOST=%s", argv[2]); putenv (envbuf); } fprintf (stderr, "This is a SANE test application.\n" "Now connecting to device %s.\n", argv[1]); testsane (argv[1]); sane_exit (); return 0; } sane-backends-1.0.29/frontend/tstbackend.c0000666000000000000000000016152413615534521015317 00000000000000/* tstbackend -- backend test utility Uses the SANE library. Copyright (C) 2002 Frank Zago (sane at zago dot net) Copyright (C) 2013 Stéphane Voltz : sane_get_devices test 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define BUILD 19 /* 2013-03-29 */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" static struct option basic_options[] = { {"device-name", required_argument, NULL, 'd'}, {"level", required_argument, NULL, 'l'}, {"scan", no_argument, NULL, 's'}, {"recursion", required_argument, NULL, 'r'}, {"get-devices", required_argument, NULL, 'g'}, {"help", no_argument, NULL, 'h'} }; static void test_options (SANE_Device * device, int can_do_recursive); enum message_level { MSG, /* info message */ INF, /* non-urgent warning */ WRN, /* warning */ ERR, /* error, test can continue */ FATAL, /* error, test can't/mustn't continue */ BUG /* bug in tstbackend */ }; int message_number_wrn = 0; int message_number_err = 0; #ifdef HAVE_LONG_LONG long long checks_done = 0; #else /* It may overflow, but it's no big deal. */ long int checks_done = 0; #endif int test_level; int verbose_level; /* Maybe add that to sane.h */ #define SANE_OPTION_IS_GETTABLE(cap) (((cap) & (SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE)) == SANE_CAP_SOFT_DETECT) /*--------------------------------------------------------------------------*/ /* Display the message error statistics. */ static void display_stats(void) { #ifdef HAVE_LONG_LONG printf("warnings: %d error: %d checks: %lld\n", message_number_wrn, message_number_err, checks_done); #else printf("warnings: %d error: %d checks: %ld\n", message_number_wrn, message_number_err, checks_done); #endif } /* * If the condition is false, display a message with some headers * depending on the level. * * Returns the condition. * */ #ifdef __GNUC__ static int check(enum message_level, int condition, const char *format, ...) __attribute__ ((format (printf, 3, 4))); #endif static int check(enum message_level level, int condition, const char *format, ...) { char str[1000]; va_list args; if (level != MSG && level != INF) checks_done ++; if (condition != 0) return condition; va_start(args, format); vsprintf(str, format, args); va_end(args); switch(level) { case MSG: printf(" %s\n", str); break; case INF: /* info */ printf("info : %s\n", str); break; case WRN: /* warning */ printf("warning : %s\n", str); message_number_wrn ++; break; case ERR: /* error */ printf("ERROR : %s\n", str); message_number_err ++; break; case FATAL: /* fatal error */ printf("FATAL ERROR : %s\n", str); message_number_err ++; break; case BUG: /* bug in tstbackend */ printf("tstbackend BUG : %s\n", str); break; } if (level == FATAL || level == BUG) { /* Fatal error. Generate a core dump. */ display_stats(); abort(); } fflush(stdout); return(0); } /*--------------------------------------------------------------------------*/ #define GUARDS_SIZE 4 /* 4 bytes */ #define GUARD1 ((SANE_Word)0x5abf8ea5) #define GUARD2 ((SANE_Word)0xa58ebf5a) /* Allocate the requested memory plus enough room to store some guard bytes. */ static void *guards_malloc(size_t size) { unsigned char *ptr; size += 2*GUARDS_SIZE; ptr = malloc(size); assert(ptr); ptr += GUARDS_SIZE; return(ptr); } /* Free some memory allocated by guards_malloc. */ static void guards_free(void *ptr) { unsigned char *p = ptr; p -= GUARDS_SIZE; free(p); } /* Set the guards */ static void guards_set(void *ptr, size_t size) { SANE_Word *p; p = (SANE_Word *)(((unsigned char *)ptr) - GUARDS_SIZE); *p = GUARD1; p = (SANE_Word *)(((unsigned char *)ptr) + size); *p = GUARD2; } /* Check that the guards have not been tampered with. */ static void guards_check(void *ptr, size_t size) { SANE_Word *p; p = (SANE_Word *)(((unsigned char *)ptr) - GUARDS_SIZE); check(FATAL, (*p == GUARD1), "guard before the block has been tampered"); p = (SANE_Word *)(((unsigned char *)ptr) + size); check(FATAL, (*p == GUARD2), "guard after the block has been tampered"); } /*--------------------------------------------------------------------------*/ static void test_parameters (SANE_Device * device, SANE_Parameters *params) { SANE_Status status; SANE_Parameters p; status = sane_get_parameters (device, &p); check(FATAL, (status == SANE_STATUS_GOOD), "cannot get the parameters (error %s)", sane_strstatus(status)); check(FATAL, ((p.format == SANE_FRAME_GRAY) || (p.format == SANE_FRAME_RGB) || (p.format == SANE_FRAME_RED) || (p.format == SANE_FRAME_GREEN) || (p.format == SANE_FRAME_BLUE)), "parameter format is not a known SANE_FRAME_* (%d)", p.format); check(FATAL, ((p.last_frame == SANE_FALSE) || (p.last_frame == SANE_TRUE)), "parameter last_frame is neither SANE_FALSE or SANE_TRUE (%d)", p.last_frame); check(FATAL, ((p.depth == 1) || (p.depth == 8) || (p.depth == 16)), "parameter depth is neither 1, 8 or 16 (%d)", p.depth); if (params) { *params = p; } } /* Try to set every option in a word list. */ static void test_options_word_list (SANE_Device * device, int option_num, const SANE_Option_Descriptor *opt, int can_do_recursive) { SANE_Status status; int i; SANE_Int val_int; SANE_Int info; check(FATAL, (opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED), "type must be SANE_TYPE_INT or SANE_TYPE_FIXED (%d)", opt->type); if (!SANE_OPTION_IS_SETTABLE(opt->cap)) return; for (i=1; iconstraint.word_list[0]; i++) { info = 0x1010; /* garbage */ val_int = opt->constraint.word_list[i]; status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int, &info); check(FATAL, (status == SANE_STATUS_GOOD), "cannot set a settable option (status=%s)", sane_strstatus(status)); check(WRN, ((info & ~(SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS)) == 0), "sane_control_option set an invalid info (%d)", info); if ((info & SANE_INFO_RELOAD_OPTIONS) && can_do_recursive) { test_options(device, can_do_recursive-1); } if (info & SANE_INFO_RELOAD_PARAMS) { test_parameters(device, NULL); } /* The option might have become inactive or unsettable. Skip it. */ if (!SANE_OPTION_IS_ACTIVE(opt->cap) || !SANE_OPTION_IS_SETTABLE(opt->cap)) return; } } /* Try to set every option in a string list. */ static void test_options_string_list (SANE_Device * device, int option_num, const SANE_Option_Descriptor *opt, int can_do_recursive) { SANE_Int info; SANE_Status status; SANE_String val_string; int i; check(FATAL, (opt->type == SANE_TYPE_STRING), "type must be SANE_TYPE_STRING (%d)", opt->type); if (!SANE_OPTION_IS_SETTABLE(opt->cap)) return; for (i=0; opt->constraint.string_list[i] != NULL; i++) { val_string = strdup(opt->constraint.string_list[i]); assert(val_string); check(WRN, (strlen(val_string) < (size_t)opt->size), "string [%s] is longer than the max size (%d)", val_string, opt->size); info = 0xE1000; /* garbage */ status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, val_string, &info); check(FATAL, (status == SANE_STATUS_GOOD), "cannot set a settable option (status=%s)", sane_strstatus(status)); check(WRN, ((info & ~(SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS)) == 0), "sane_control_option set an invalid info (%d)", info); free(val_string); if ((info & SANE_INFO_RELOAD_OPTIONS) && can_do_recursive) { test_options(device, can_do_recursive-1); } if (info & SANE_INFO_RELOAD_PARAMS) { test_parameters(device, NULL); } /* The option might have become inactive or unsettable. Skip it. */ if (!SANE_OPTION_IS_ACTIVE(opt->cap) || !SANE_OPTION_IS_SETTABLE(opt->cap)) return; } } /* Test the consistency of the options. */ static void test_options (SANE_Device * device, int can_do_recursive) { SANE_Word info; SANE_Int num_dev_options; SANE_Status status; const SANE_Option_Descriptor *opt; int option_num; void *optval; /* value for the option */ size_t optsize; /* size of the optval buffer */ /* * Test option 0 */ opt = sane_get_option_descriptor (device, 0); check(FATAL, (opt != NULL), "cannot get option descriptor for option 0 (it must exist)"); check(INF, (opt->cap == SANE_CAP_SOFT_DETECT), "invalid capabilities for option 0 (%d)", opt->cap); check(ERR, (opt->type == SANE_TYPE_INT), "option 0 type must be SANE_TYPE_INT"); /* Get the number of options. */ status = sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0); check(FATAL, (status == SANE_STATUS_GOOD), "cannot get option 0 value"); /* Try to change the number of options. */ status = sane_control_option (device, 0, SANE_ACTION_SET_VALUE, &num_dev_options, &info); check(WRN, (status != SANE_STATUS_GOOD), "the option 0 value can be set"); /* * Test all options */ option_num = 0; for (option_num = 0; option_num < num_dev_options; option_num++) { /* Get the option descriptor */ opt = sane_get_option_descriptor (device, option_num); check(FATAL, (opt != NULL), "cannot get option descriptor for option %d", option_num); check(WRN, ((opt->cap & ~(SANE_CAP_SOFT_SELECT | SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_EMULATED | SANE_CAP_AUTOMATIC | SANE_CAP_INACTIVE | SANE_CAP_ADVANCED)) == 0), "invalid capabilities for option [%d, %s] (%x)", option_num, opt->name, opt->cap); check(WRN, (opt->title != NULL), "option [%d, %s] must have a title", option_num, opt->name); check(WRN, (opt->desc != NULL), "option [%d, %s] must have a description", option_num, opt->name); if (!SANE_OPTION_IS_ACTIVE (opt->cap)) { /* Option not active. Skip the remaining tests. */ continue; } if(verbose_level) { printf("checking option ""%s""\n",opt->title); } if (opt->type == SANE_TYPE_GROUP) { check(INF, (opt->name == NULL || *opt->name == 0), "option [%d, %s] has a name", option_num, opt->name); check(ERR, (!SANE_OPTION_IS_SETTABLE (opt->cap)), "option [%d, %s], group option is settable", option_num, opt->name); } else { if (option_num == 0) { check(ERR, (opt->name != NULL && *opt->name ==0), "option 0 must have an empty name (ie. \"\")"); } else { check(ERR, (opt->name != NULL && *opt->name !=0), "option %d must have a name", option_num); } } /* The option name must contain only "a".."z", "0".."9" and "-" and must start with "a".."z". */ if (opt->name && opt->name[0]) { const char *p = opt->name; check(ERR, (*p >= 'a' && *p <= 'z'), "name for option [%d, %s] must start with in letter in [a..z]", option_num, opt->name); p++; while(*p) { check(ERR, ((*p >= 'a' && *p <= 'z') || (*p == '-') || (*p >= '0' && *p <= '9')), "name for option [%d, %s] must only have the letters [-a..z0..9]", option_num, opt->name); p++; } } optval = NULL; optsize = 0; switch(opt->type) { case SANE_TYPE_BOOL: check(WRN, (opt->size == sizeof(SANE_Word)), "size of option %s is incorrect", opt->name); optval = guards_malloc(opt->size); optsize = opt->size; check(WRN, (opt->constraint_type == SANE_CONSTRAINT_NONE), "invalid constraint type for option [%d, %s] (%d)", option_num, opt->name, opt->constraint_type); break; case SANE_TYPE_INT: case SANE_TYPE_FIXED: check(WRN, (opt->size > 0 && (opt->size % sizeof(SANE_Word) == 0)), "invalid size for option %s", opt->name); optval = guards_malloc(opt->size); optsize = opt->size; check(WRN, (opt->constraint_type == SANE_CONSTRAINT_NONE || opt->constraint_type == SANE_CONSTRAINT_RANGE || opt->constraint_type == SANE_CONSTRAINT_WORD_LIST), "invalid constraint type for option [%d, %s] (%d)", option_num, opt->name, opt->constraint_type); break; case SANE_TYPE_STRING: check(WRN, (opt->size >= 1), "size of option [%d, %s] must be at least 1 for the NUL terminator", option_num, opt->name); check(INF, (opt->unit == SANE_UNIT_NONE), "unit of option [%d, %s] is not SANE_UNIT_NONE", option_num, opt->name); check(WRN, (opt->constraint_type == SANE_CONSTRAINT_STRING_LIST || opt->constraint_type == SANE_CONSTRAINT_NONE), "invalid constraint type for option [%d, %s] (%d)", option_num, opt->name, opt->constraint_type); optval = guards_malloc(opt->size); optsize = opt->size; break; case SANE_TYPE_BUTTON: case SANE_TYPE_GROUP: check(INF, (opt->unit == SANE_UNIT_NONE), "option [%d, %s], unit is not SANE_UNIT_NONE", option_num, opt->name); check(INF, (opt->size == 0), "option [%d, %s], size is not 0", option_num, opt->name); check(WRN, (opt->constraint_type == SANE_CONSTRAINT_NONE), "invalid constraint type for option [%d, %s] (%d)", option_num, opt->name, opt->constraint_type); break; default: check(ERR, 0, "invalid type %d for option %s", opt->type, opt->name); break; } if (optval) { /* This is an option with a value */ /* get with NULL info. * * The SANE standard is not explicit on that subject. I * consider that an inactive option shouldn't be read by a * frontend because its value is meaningless. I think * that, in that case, SANE_STATUS_INVAL is an appropriate * return. */ guards_set(optval, optsize); status = sane_control_option (device, option_num, SANE_ACTION_GET_VALUE, optval, NULL); guards_check(optval, optsize); if (SANE_OPTION_IS_GETTABLE (opt->cap)) { check(ERR, (status == SANE_STATUS_GOOD), "cannot get option [%d, %s] value, although it is active (%s)", option_num, opt->name, sane_strstatus(status)); } else { check(ERR, (status == SANE_STATUS_INVAL), "was able to get option [%d, %s] value, although it is not active", option_num, opt->name); } /* set with NULL info */ guards_set(optval, optsize); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, optval, NULL); guards_check(optval, optsize); if (SANE_OPTION_IS_SETTABLE (opt->cap) && SANE_OPTION_IS_ACTIVE (opt->cap)) { check(ERR, (status == SANE_STATUS_GOOD), "cannot set option [%d, %s] value, although it is active and settable (%s)", option_num, opt->name, sane_strstatus(status)); } else { check(ERR, (status == SANE_STATUS_INVAL), "was able to set option [%d, %s] value, although it is not active or settable", option_num, opt->name); } /* Get with invalid info. Since if is a get, info should be either * ignored or set to 0. */ info = 0xdeadbeef; guards_set(optval, optsize); status = sane_control_option (device, option_num, SANE_ACTION_GET_VALUE, optval, &info); guards_check(optval, optsize); if (SANE_OPTION_IS_GETTABLE (opt->cap)) { check(ERR, (status == SANE_STATUS_GOOD), "cannot get option [%d, %s] value, although it is active (%s)", option_num, opt->name, sane_strstatus(status)); } else { check(ERR, (status == SANE_STATUS_INVAL), "was able to get option [%d, %s] value, although it is not active", option_num, opt->name); } check(ERR, ((info == (SANE_Int)0xdeadbeef) || (info == 0)), "when getting option [%d, %s], info was set to %x", option_num, opt->name, info); /* Set with invalid info. Info should be reset by the backend. */ info = 0x10000; guards_set(optval, optsize); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, optval, &info); guards_check(optval, optsize); if (SANE_OPTION_IS_SETTABLE (opt->cap) && SANE_OPTION_IS_ACTIVE (opt->cap)) { check(ERR, (status == SANE_STATUS_GOOD), "cannot set option [%d, %s] value, although it is active and settable (%s)", option_num, opt->name, sane_strstatus(status)); check(ERR, ((info & ~(SANE_INFO_INEXACT | SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS)) == 0), "sane_control_option set some wrong bit in info (%d)", info); if (info & SANE_INFO_RELOAD_PARAMS) { test_parameters(device, NULL); } } else { check(ERR, (status == SANE_STATUS_INVAL), "was able to set option [%d, %s] value, although it is not active or settable", option_num, opt->name); } /* Ask the backend to set the option automatically. */ guards_set(optval, optsize); status = sane_control_option (device, option_num, SANE_ACTION_SET_AUTO, optval, &info); guards_check(optval, optsize); if (SANE_OPTION_IS_SETTABLE (opt->cap) && SANE_OPTION_IS_ACTIVE (opt->cap) && (opt->cap & SANE_CAP_AUTOMATIC)) { check(ERR, (status == SANE_STATUS_GOOD), "cannot set the option [%d, %s] automatically.", option_num, opt->name); } else { check(ERR, (status != SANE_STATUS_GOOD), "was able to automatically set option [%d, %s], although it is not active or settable or automatically settable", option_num, opt->name); } if (info & SANE_INFO_RELOAD_PARAMS) { test_parameters(device, NULL); } } if (optval) { guards_free(optval); optval = NULL; } /* Some capabilities checks. */ check(ERR, ((opt->cap & (SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_SELECT)) != (SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_SELECT)), "option [%d, %s], SANE_CAP_HARD_SELECT and SANE_CAP_SOFT_SELECT are mutually exclusive", option_num, opt->name); if (opt->cap & SANE_CAP_SOFT_SELECT) { check(ERR, ((opt->cap & SANE_CAP_SOFT_DETECT) != 0), "option [%d, %s], SANE_CAP_SOFT_DETECT must be set if SANE_CAP_SOFT_SELECT is set", option_num, opt->name); } if ((opt->cap & (SANE_CAP_SOFT_SELECT | SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_DETECT)) == SANE_CAP_SOFT_DETECT) { check(ERR, (!SANE_OPTION_IS_SETTABLE (opt->cap)), "option [%d, %s], must not be settable", option_num, opt->name); } if (!SANE_OPTION_IS_SETTABLE (opt->cap)) { /* Unsettable option. Ignore the rest of the test. */ continue; } /* Check that will sane_control_option copy the string * parameter and not just store a pointer to it. */ if (opt->type == SANE_TYPE_STRING) { SANE_String val_string2; char *optstr; optstr = guards_malloc(opt->size); val_string2 = guards_malloc(opt->size); /* Poison the current value. */ strncpy(optstr, "-pOiSoN-", opt->size-1); optstr[opt->size-1] = 0; /* Get the value */ guards_set(optstr, opt->size); status = sane_control_option (device, option_num, SANE_ACTION_GET_VALUE, optstr, NULL); guards_check(optstr, opt->size); check(FATAL, (status == SANE_STATUS_GOOD), "cannot get option [%d, %s] value", option_num, opt->name); check(FATAL, (strcmp(optstr, "-pOiSoN-") != 0), "sane_control_option did not set a value"); /* Set the value */ guards_set(optstr, opt->size); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, optstr, NULL); guards_check(optstr, opt->size); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option [%d, %s] value", option_num, opt->name); /* Poison the returned value. */ strncpy(optstr, "-pOiSoN-", opt->size-1); optstr[opt->size-1] = 0; /* Read again the value and compare. */ guards_set(val_string2, opt->size); status = sane_control_option (device, option_num, SANE_ACTION_GET_VALUE, val_string2, NULL); guards_check(val_string2, opt->size); check(ERR, (status == SANE_STATUS_GOOD), "cannot get option [%d, %s] value", option_num, opt->name); check(FATAL, (strcmp(optstr, val_string2) != 0), "sane_control_option did not copy the string parameter for option [%d, %s]", option_num, opt->name); guards_free(optstr); guards_free(val_string2); } /* Try both boolean options. */ if (opt->type == SANE_TYPE_BOOL) { SANE_Bool org_v; SANE_Bool v; status = sane_control_option (device, option_num, SANE_ACTION_GET_VALUE, &org_v, &info); check(ERR, (status == SANE_STATUS_GOOD), "cannot get boolean option [%d, %s] value (%s)", option_num, opt->name, sane_strstatus(status)); /* Invert the condition. */ switch(org_v) { case SANE_FALSE: v = SANE_TRUE; break; case SANE_TRUE: v = SANE_FALSE; break; default: check(ERR, 0, "invalid boolean value %d for option [%d, %s]", org_v, option_num, opt->name); } /* Set the opposite of the current value. */ status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &v, &info); check(ERR, (status == SANE_STATUS_GOOD), "cannot set boolean option [%d, %s] value (%s)", option_num, opt->name, sane_strstatus(status)); check(ERR, (v != org_v), "boolean values should be different"); if (info & SANE_INFO_RELOAD_PARAMS) { test_parameters(device, NULL); } /* Set the initial value. */ v = org_v; status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &v, &info); check(ERR, (status == SANE_STATUS_GOOD), "cannot set boolean option [%d, %s] value (%s)", option_num, opt->name, sane_strstatus(status)); check(ERR, (v == org_v), "boolean values should be the same"); if (info & SANE_INFO_RELOAD_PARAMS) { test_parameters(device, NULL); } } /* Try to set an invalid option. */ switch(opt->type) { case SANE_TYPE_BOOL: { SANE_Word v; /* should be SANE_Bool instead */ v = -1; /* invalid value. must be SANE_FALSE or SANE_TRUE */ status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &v, NULL); check(ERR, (status != SANE_STATUS_GOOD), "was able to set an invalid value for boolean option [%d, %s]", option_num, opt->name); v = 2; /* invalid value. must be SANE_FALSE or SANE_TRUE */ status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &v, NULL); check(ERR, (status != SANE_STATUS_GOOD), "was able to set an invalid value for boolean option [%d, %s]", option_num, opt->name); } break; case SANE_TYPE_FIXED: case SANE_TYPE_INT: { SANE_Int *v; unsigned int i; v = guards_malloc(opt->size); /* I can only think of a test for * SANE_CONSTRAINT_RANGE. This tests the behaviour of * sanei_constrain_value(). */ if (opt->constraint_type == SANE_CONSTRAINT_RANGE) { for(i=0; isize / sizeof(SANE_Int); i++) v[i] = opt->constraint.range->min - 1; /* invalid range */ guards_set(v, opt->size); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, v, &info); guards_check(v, opt->size); check(ERR, (status == SANE_STATUS_GOOD && (info & SANE_INFO_INEXACT) ), "incorrect return when setting an invalid range value for option [%d, %s] (status %s, info %x)", option_num, opt->name, sane_strstatus(status), info); /* Set the corrected value. */ guards_set(v, opt->size); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, v, &info); guards_check(v, opt->size); check(ERR, (status == SANE_STATUS_GOOD && !(info & SANE_INFO_INEXACT) ), "incorrect return when setting an invalid range value for option [%d, %s] (status %s, info %x)", option_num, opt->name, sane_strstatus(status), info); for(i=0; isize / sizeof(SANE_Int); i++) v[i] = opt->constraint.range->max + 1; /* invalid range */ guards_set(v, opt->size); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, v, &info); guards_check(v, opt->size); check(ERR, (status == SANE_STATUS_GOOD && (info & SANE_INFO_INEXACT) ), "incorrect return when setting an invalid range value for option [%d, %s] (status %s, info %x)", option_num, opt->name, sane_strstatus(status), info); /* Set the corrected value. */ guards_set(v, opt->size); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, v, &info); guards_check(v, opt->size); check(ERR, (status == SANE_STATUS_GOOD && !(info & SANE_INFO_INEXACT) ), "incorrect return when setting a valid range value for option [%d, %s] (status %s, info %x)", option_num, opt->name, sane_strstatus(status), info); } guards_free(v); } break; default: break; } /* TODO: button */ /* * Here starts all the recursive stuff. After the test, it is * possible that the value is not settable nor active * anymore. */ /* Try to set every option in a list */ switch(opt->constraint_type) { case SANE_CONSTRAINT_WORD_LIST: check(FATAL, (opt->constraint.word_list != NULL), "no constraint list for option [%d, %s]", option_num, opt->name); test_options_word_list (device, option_num, opt, can_do_recursive); break; case SANE_CONSTRAINT_STRING_LIST: check(FATAL, (opt->constraint.string_list != NULL), "no constraint list for option [%d, %s]", option_num, opt->name); test_options_string_list (device, option_num, opt, can_do_recursive); break; case SANE_CONSTRAINT_RANGE: check(FATAL, (opt->constraint.range != NULL), "no constraint range for option [%d, %s]", option_num, opt->name); check(FATAL, (opt->constraint.range->max >= opt->constraint.range->min), "incorrect range for option [%d, %s] (min=%d > max=%d)", option_num, opt->name, opt->constraint.range->min, opt->constraint.range->max); /* Recurse. */ if (can_do_recursive) { test_options(device, can_do_recursive-1); } break; case SANE_CONSTRAINT_NONE: check(INF, (opt->constraint.range == NULL), "option [%d, %s] has some constraint value set", option_num, opt->name); /* Recurse. */ if (can_do_recursive) { test_options(device, can_do_recursive-1); } break; } /* End of the test for that option. */ } /* test random non-existing options. */ opt = sane_get_option_descriptor (device, -1); check(ERR, (opt == NULL), "was able to get option descriptor for option -1"); opt = sane_get_option_descriptor (device, num_dev_options+1); check(ERR, (opt == NULL), "was able to get option descriptor for option %d", num_dev_options+1); opt = sane_get_option_descriptor (device, num_dev_options+2); check(ERR, (opt == NULL), "was able to get option descriptor for option %d", num_dev_options+2); opt = sane_get_option_descriptor (device, num_dev_options+50); check(ERR, (opt == NULL), "was able to get option descriptor for option %d", num_dev_options+50); } /* Get an option descriptor by the name of the option. */ static const SANE_Option_Descriptor *get_optdesc_by_name(SANE_Handle device, const char *name, int *option_num) { const SANE_Option_Descriptor *opt; SANE_Int num_dev_options; SANE_Status status; /* Get the number of options. */ status = sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0); check(FATAL, (status == SANE_STATUS_GOOD), "cannot get option 0 value (%s)", sane_strstatus(status)); for (*option_num = 0; *option_num < num_dev_options; (*option_num)++) { /* Get the option descriptor */ opt = sane_get_option_descriptor (device, *option_num); check(FATAL, (opt != NULL), "cannot get option descriptor for option %d", *option_num); if (opt->name && strcmp(opt->name, name) == 0) { return(opt); } } return(NULL); } /* Set the first value for an option. That equates to the minimum for a * range or the first element in a list. */ static void set_min_value(SANE_Handle device, int option_num, const SANE_Option_Descriptor *opt) { SANE_Status status; SANE_String val_string; SANE_Int val_int; int rc; check(BUG, (SANE_OPTION_IS_SETTABLE(opt->cap)), "option is not settable"); switch(opt->constraint_type) { case SANE_CONSTRAINT_WORD_LIST: rc = check(ERR, (opt->constraint.word_list[0] > 0), "no value in the list for option %s", opt->name); if (!rc) return; val_int = opt->constraint.word_list[1]; status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status)); break; case SANE_CONSTRAINT_STRING_LIST: rc = check(ERR, (opt->constraint.string_list[0] != NULL), "no value in the list for option %s", opt->name); if (!rc) return; val_string = strdup(opt->constraint.string_list[0]); assert(val_string); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, val_string, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to [%s] (%s)", opt->name, val_string, sane_strstatus(status)); free(val_string); break; case SANE_CONSTRAINT_RANGE: val_int = opt->constraint.range->min; status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status)); break; default: abort(); } } /* Set the last value for an option. That equates to the maximum for a * range or the last element in a list. */ static void set_max_value(SANE_Handle device, int option_num, const SANE_Option_Descriptor *opt) { SANE_Status status; SANE_String val_string; SANE_Int val_int; int i; int rc; check(BUG, (SANE_OPTION_IS_SETTABLE(opt->cap)), "option is not settable"); switch(opt->constraint_type) { case SANE_CONSTRAINT_WORD_LIST: rc = check(ERR, (opt->constraint.word_list[0] > 0), "no value in the list for option %s", opt->name); if (!rc) return; val_int = opt->constraint.word_list[opt->constraint.word_list[0]]; status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status)); break; case SANE_CONSTRAINT_STRING_LIST: rc = check(ERR, (opt->constraint.string_list[0] != NULL), "no value in the list for option %s", opt->name); if (!rc) return; for (i=1; opt->constraint.string_list[i] != NULL; i++); val_string = strdup(opt->constraint.string_list[i-1]); assert(val_string); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, val_string, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to [%s] (%s)", opt->name, val_string, sane_strstatus(status)); free(val_string); break; case SANE_CONSTRAINT_RANGE: val_int = opt->constraint.range->max; status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status)); break; default: abort(); } } /* Set a random value for an option amongst the possible values. */ static void set_random_value(SANE_Handle device, int option_num, const SANE_Option_Descriptor *opt) { SANE_Status status; SANE_String val_string; SANE_Int val_int; int i; int rc; check(BUG, (SANE_OPTION_IS_SETTABLE(opt->cap)), "option is not settable"); switch(opt->constraint_type) { case SANE_CONSTRAINT_WORD_LIST: rc = check(ERR, (opt->constraint.word_list[0] > 0), "no value in the list for option %s", opt->name); if (!rc) return; i=1+(rand() % opt->constraint.word_list[0]); val_int = opt->constraint.word_list[i]; status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status)); break; case SANE_CONSTRAINT_STRING_LIST: rc = check(ERR, (opt->constraint.string_list[0] != NULL), "no value in the list for option %s", opt->name); if (!rc) return; for (i=0; opt->constraint.string_list[i] != NULL; i++); i = rand() % i; val_string = strdup(opt->constraint.string_list[0]); assert(val_string); status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, val_string, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to [%s] (%s)", opt->name, val_string, sane_strstatus(status)); free(val_string); break; case SANE_CONSTRAINT_RANGE: i = opt->constraint.range->max - opt->constraint.range->min; i = rand() % i; val_int = opt->constraint.range->min + i; status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int, NULL); check(ERR, (status == SANE_STATUS_GOOD), "cannot set option %s to %d (%s)", opt->name, val_int, sane_strstatus(status)); break; default: abort(); } } /*--------------------------------------------------------------------------*/ /* Returns a string with the value of an option. */ static char *get_option_value(SANE_Handle device, const char *option_name) { const SANE_Option_Descriptor *opt; void *optval; /* value for the option */ int optnum; static char str[100]; SANE_Status status; opt = get_optdesc_by_name(device, option_name, &optnum); if (opt) { optval = guards_malloc(opt->size); status = sane_control_option (device, optnum, SANE_ACTION_GET_VALUE, optval, NULL); if (status == SANE_STATUS_GOOD) { switch(opt->type) { case SANE_TYPE_BOOL: if (*(SANE_Word*) optval == SANE_FALSE) { strcpy(str, "FALSE"); } else { strcpy(str, "TRUE"); } break; case SANE_TYPE_INT: sprintf(str, "%d", *(SANE_Word*) optval); break; case SANE_TYPE_FIXED: { int i; i = SANE_UNFIX(*(SANE_Word*) optval); sprintf(str, "%d", i); } break; case SANE_TYPE_STRING: strcpy(str, optval); break; default: str[0] = 0; } } else { /* Shouldn't happen. */ strcpy(str, "backend default"); } guards_free(optval); } else { /* The option does not exists. */ strcpy(str, "backend default"); } return(str); } /* Display the parameters that used for a scan. */ static char *display_scan_parameters(SANE_Handle device) { static char str[150]; char *p = str; *p = 0; p += sprintf(p, "scan mode=[%s] ", get_option_value(device, SANE_NAME_SCAN_MODE)); p += sprintf(p, "resolution=[%s] ", get_option_value(device, SANE_NAME_SCAN_RESOLUTION)); p += sprintf(p, "tl_x=[%s] ", get_option_value(device, SANE_NAME_SCAN_TL_X)); p += sprintf(p, "tl_y=[%s] ", get_option_value(device, SANE_NAME_SCAN_TL_Y)); p += sprintf(p, "br_x=[%s] ", get_option_value(device, SANE_NAME_SCAN_BR_X)); p += sprintf(p, "br_y=[%s] ", get_option_value(device, SANE_NAME_SCAN_BR_Y)); return(str); } /* Do a scan to test the correctness of the backend. */ static void test_scan(SANE_Handle device) { const SANE_Option_Descriptor *opt; SANE_Status status; int option_num; SANE_Int val_int; unsigned char *image = NULL; SANE_Parameters params; size_t to_read; SANE_Int len=0; int ask_len; int rc; int fd; /* Set the largest scan possible. * * For that test, the corner * position must exists and be SANE_CONSTRAINT_RANGE (this is not * a SANE requirement though). */ opt = get_optdesc_by_name(device, SANE_NAME_SCAN_TL_X, &option_num); if (opt) set_min_value(device, option_num, opt); opt = get_optdesc_by_name(device, SANE_NAME_SCAN_TL_Y, &option_num); if (opt) set_min_value(device, option_num, opt); opt = get_optdesc_by_name(device, SANE_NAME_SCAN_BR_X, &option_num); if (opt) set_max_value(device, option_num, opt); opt = get_optdesc_by_name(device, SANE_NAME_SCAN_BR_Y, &option_num); if (opt) set_max_value(device, option_num, opt); #define IMAGE_SIZE (512 * 1024) image = guards_malloc(IMAGE_SIZE); /* Try a read outside of a scan. */ status = sane_read (device, image, len, &len); check(ERR, (status != SANE_STATUS_GOOD), "it is possible to sane_read outside of a scan"); /* Try to set the I/O mode outside of a scan. */ status = sane_set_io_mode (device, SANE_FALSE); check(ERR, (status == SANE_STATUS_INVAL), "it is possible to sane_set_io_mode outside of a scan"); status = sane_set_io_mode (device, SANE_TRUE); check(ERR, (status == SANE_STATUS_INVAL || status == SANE_STATUS_UNSUPPORTED), "it is possible to sane_set_io_mode outside of a scan"); /* Test sane_get_select_fd outside of a scan. */ status = sane_get_select_fd(device, &fd); check(ERR, (status == SANE_STATUS_INVAL || status == SANE_STATUS_UNSUPPORTED), "sane_get_select_fd outside of a scan returned an invalid status (%s)", sane_strstatus (status)); if (test_level > 2) { /* Do a scan, reading byte per byte */ check(MSG, 0, "TEST: scan byte per byte - %s", display_scan_parameters(device)); test_parameters(device, ¶ms); status = sane_start (device); rc = check(ERR, (status == SANE_STATUS_GOOD), "cannot start the scan (%s)", sane_strstatus (status)); if (!rc) goto the_end; /* sane_set_io_mode with SANE_FALSE is always supported. */ status = sane_set_io_mode (device, SANE_FALSE); check(ERR, (status == SANE_STATUS_GOOD), "sane_set_io_mode with SANE_FALSE must return SANE_STATUS_GOOD"); /* test sane_set_io_mode with SANE_TRUE. */ status = sane_set_io_mode (device, SANE_TRUE); check(ERR, (status == SANE_STATUS_GOOD || status == SANE_STATUS_UNSUPPORTED), "sane_set_io_mode with SANE_TRUE returned an invalid status (%s)", sane_strstatus (status)); /* Put the backend back into blocking mode. */ status = sane_set_io_mode (device, SANE_FALSE); check(ERR, (status == SANE_STATUS_GOOD), "sane_set_io_mode with SANE_FALSE must return SANE_STATUS_GOOD"); /* Test sane_get_select_fd */ fd = 0x76575; /* won't exists */ status = sane_get_select_fd(device, &fd); check(ERR, (status == SANE_STATUS_GOOD || status == SANE_STATUS_UNSUPPORTED), "sane_get_select_fd returned an invalid status (%s)", sane_strstatus (status)); if (status == SANE_STATUS_GOOD) { check(ERR, (fd != 0x76575), "sane_get_select_fd didn't set the fd although it should have"); check(ERR, (fd >= 0), "sane_get_select_fd returned an invalid fd"); } /* Check that it is not possible to set an option. It is probably * a requirement stated indirectly in the section 4.4 on code * flow. */ status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int , NULL); check(WRN, (status != SANE_STATUS_GOOD), "it is possible to set a value during a scan"); test_parameters(device, ¶ms); if (params.bytes_per_line != 0 && params.lines != 0) { to_read = params.bytes_per_line * params.lines; while(SANE_TRUE) { len = 76457645; /* garbage */ guards_set(image, 1); status = sane_read (device, image, 1, &len); guards_check(image, 1); if (status == SANE_STATUS_EOF) { /* End of scan */ check(ERR, (len == 0), "the length returned is not 0"); break; } rc = check(ERR, (status == SANE_STATUS_GOOD), "scan stopped - status is %s", sane_strstatus (status)); if (!rc) { check(ERR, (len == 0), "the length returned is not 0"); break; } /* The scanner can only return 1. If it returns 0, we may * loop forever. */ rc = check(ERR, (len == 1), "backend returned 0 bytes - skipping test"); if (!rc) { break; } to_read -= len; } if (params.lines != -1) { check(ERR, (to_read == 0), "scan ended, but data was truncated"); } } sane_cancel(device); } /* Try a read outside a scan. */ ask_len = 1; guards_set(image, ask_len); status = sane_read (device, image, ask_len, &len); guards_check(image, ask_len); check(ERR, (status != SANE_STATUS_GOOD), "it is possible to sane_read outside a scan"); /* * Do a partial scan */ check(MSG, 0, "TEST: partial scan - %s", display_scan_parameters(device)); status = sane_start (device); rc = check(ERR, (status == SANE_STATUS_GOOD), "cannot start the scan (%s)", sane_strstatus (status)); if (!rc) goto the_end; test_parameters(device, ¶ms); if (params.bytes_per_line != 0 && params.lines != 0) { len = 10; guards_set(image, 1); status = sane_read (device, image, 1, &len); guards_check(image, 1); check(ERR, (len == 1), "sane_read() didn't return 1 byte as requested"); } sane_cancel(device); /* * Do a scan, reading random length. */ check(MSG, 0, "TEST: scan random length - %s", display_scan_parameters(device)); test_parameters(device, ¶ms); /* Try a read outside a scan. */ ask_len = 20; guards_set(image, ask_len); status = sane_read (device, image, ask_len, &len); guards_check(image, ask_len); check(ERR, (status != SANE_STATUS_GOOD), "it is possible to sane_read outside a scan"); status = sane_start (device); rc = check(ERR, (status == SANE_STATUS_GOOD), "cannot start the scan (%s)", sane_strstatus (status)); if (!rc) goto the_end; /* Check that it is not possible to set an option. */ status = sane_control_option (device, option_num, SANE_ACTION_SET_VALUE, &val_int , NULL); check(WRN, (status != SANE_STATUS_GOOD), "it is possible to set a value during a scan"); test_parameters(device, ¶ms); if (params.bytes_per_line != 0 && params.lines != 0) { to_read = params.bytes_per_line * params.lines; srandom(time(NULL)); while (SANE_TRUE) { ask_len = rand() & 0x7ffff; /* 0 to 512K-1 */ if (ask_len == 0) len = 1; len = ask_len + 4978; /* garbage */ guards_set(image, ask_len); status = sane_read (device, image, ask_len, &len); guards_check(image, ask_len); if (status == SANE_STATUS_EOF) { /* End of scan */ check(ERR, (len == 0), "the length returned is not 0"); break; } rc = check(ERR, (status == SANE_STATUS_GOOD), "scan stopped - status is %s", sane_strstatus (status)); if (!rc) { check(ERR, (len == 0), "the length returned is not 0"); break; } /* The scanner cannot return 0. If it returns 0, we may * loop forever. */ rc = check(ERR, (len > 0), "backend didn't return any data - skipping test"); if (!rc) { break; } rc = check(ERR, (len <= ask_len), "backend returned too much data (%d / %d) - skipping test", len, ask_len); if (!rc) { break; } to_read -= len; } if (params.lines != -1) { check(ERR, (to_read == 0), "scan ended, but data was truncated"); } } sane_cancel(device); /* Try a read outside a scan. */ ask_len = 30; guards_set(image, ask_len); status = sane_read (device, image, ask_len, &len); guards_check(image, ask_len); check(ERR, (status != SANE_STATUS_GOOD), "it is possible to sane_read outside a scan"); /* * Do a scan with a fixed size and a big buffer */ check(MSG, 0, "TEST: scan with a big max_len - %s", display_scan_parameters(device)); test_parameters(device, ¶ms); status = sane_start (device); rc = check(ERR, (status == SANE_STATUS_GOOD), "cannot start the scan (%s)", sane_strstatus (status)); if (!rc) goto the_end; test_parameters(device, ¶ms); if (params.bytes_per_line != 0 && params.lines != 0) { to_read = params.bytes_per_line * params.lines; while(SANE_TRUE) { ask_len = IMAGE_SIZE; len = rand(); /* garbage */ guards_set(image, ask_len); status = sane_read (device, image, ask_len, &len); guards_check(image, ask_len); if (status == SANE_STATUS_EOF) { /* End of scan */ check(ERR, (len == 0), "the length returned is not 0"); break; } rc = check(ERR, (status == SANE_STATUS_GOOD), "scan stopped - status is %s", sane_strstatus (status)); if (!rc) { check(ERR, (len == 0), "the length returned is not 0"); break; } /* If the scanner return 0, we may loop forever. */ rc = check(ERR, (len > 0), "backend didn't return any data - skipping test"); if (!rc) { break; } rc = check(ERR, (len <= ask_len), "backend returned too much data (%d / %d) - skipping test", len, ask_len); if (!rc) { break; } to_read -= len; } if (params.lines != -1) { check(ERR, (to_read == 0), "scan ended, but data was truncated"); } } sane_cancel(device); the_end: if (image) guards_free(image); } /* Do several scans at different scan mode and resolution. */ static void test_scans(SANE_Device * device) { const SANE_Option_Descriptor *scan_mode_opt; const SANE_Option_Descriptor *resolution_mode_opt; SANE_Status status; int scan_mode_optnum; int resolution_mode_optnum; SANE_String val_string; int i; int rc; /* For that test, the requirements are: * SANE_NAME_SCAN_MODE exists and is a SANE_CONSTRAINT_STRING_LIST * SANE_NAME_SCAN_RESOLUTION exists and is either a SANE_CONSTRAINT_WORD_LIST or a SANE_CONSTRAINT_RANGE. * * These are not a SANE requirement, though. */ scan_mode_opt = get_optdesc_by_name(device, SANE_NAME_SCAN_MODE, &scan_mode_optnum); if (scan_mode_opt) { rc = check(INF, (scan_mode_opt->type == SANE_TYPE_STRING), "option [%s] is not a SANE_TYPE_STRING - skipping test", SANE_NAME_SCAN_MODE); if (!rc) return; rc = check(INF, (scan_mode_opt->constraint_type == SANE_CONSTRAINT_STRING_LIST), "constraint for option [%s] is not SANE_CONSTRAINT_STRING_LIST - skipping test", SANE_NAME_SCAN_MODE); if (!rc) return; rc = check(INF, (SANE_OPTION_IS_SETTABLE(scan_mode_opt->cap)), "option [%s] is not settable - skipping test", SANE_NAME_SCAN_MODE); if (!rc) return; } resolution_mode_opt = get_optdesc_by_name(device, SANE_NAME_SCAN_RESOLUTION, &resolution_mode_optnum); if (resolution_mode_opt) { rc = check(INF, (SANE_OPTION_IS_SETTABLE(resolution_mode_opt->cap)), "option [%s] is not settable - skipping test", SANE_NAME_SCAN_RESOLUTION); if (!rc) return; } if (scan_mode_opt) { /* Do several scans, with several resolution. */ for (i=0; scan_mode_opt->constraint.string_list[i] != NULL; i++) { val_string = strdup(scan_mode_opt->constraint.string_list[i]); assert(val_string); status = sane_control_option (device, scan_mode_optnum, SANE_ACTION_SET_VALUE, val_string, NULL); check(FATAL, (status == SANE_STATUS_GOOD), "cannot set a settable option (status=%s)", sane_strstatus(status)); free(val_string); if (resolution_mode_opt) { set_min_value(device, resolution_mode_optnum, resolution_mode_opt); test_scan(device); set_max_value(device, resolution_mode_optnum, resolution_mode_opt); test_scan(device); set_random_value(device, resolution_mode_optnum, resolution_mode_opt); test_scan(device); } else { test_scan(device); } } } else { if (resolution_mode_opt) { set_min_value(device, resolution_mode_optnum, resolution_mode_opt); test_scan(device); set_max_value(device, resolution_mode_optnum, resolution_mode_opt); test_scan(device); set_random_value(device, resolution_mode_optnum, resolution_mode_opt); test_scan(device); } else { test_scan(device); } } } /** test sane_get_devices * test sane_get_device function, if time is greter than 0, * loop to let tester plug/unplug device to check for correct * hotplug detection * @param device_list device list to fill * @param time time to loop * @return 0 on success */ static int test_get_devices(const SANE_Device ***device_list, int time) { int loop=0; int i; const SANE_Device *dev; SANE_Status status; status = sane_get_devices (device_list, SANE_TRUE); check(FATAL, (status == SANE_STATUS_GOOD), "sane_get_devices() failed (%s)", sane_strstatus (status)); /* Verify that the SANE doc (or tstbackend) is up to date */ for (i=0; (*device_list)[i] != NULL; i++) { dev = (*device_list)[i]; check(FATAL, (dev->name != NULL), "device name is NULL"); check(FATAL, (dev->vendor != NULL), "device vendor is NULL"); check(FATAL, (dev->type != NULL), "device type is NULL"); check(FATAL, (dev->model != NULL), "device model is NULL"); check(INF, ((strcmp(dev->type, "flatbed scanner") == 0) || (strcmp(dev->type, "frame grabber") == 0) || (strcmp(dev->type, "handheld scanner") == 0) || (strcmp(dev->type, "still camera") == 0) || (strcmp(dev->type, "video camera") == 0) || (strcmp(dev->type, "virtual device") == 0) || (strcmp(dev->type, "film scanner") == 0) || (strcmp(dev->type, "multi-function peripheral") == 0) || (strcmp(dev->type, "sheetfed scanner") == 0)), "unknown device type [%s]. Update SANE doc section \"Type Strings\"", dev->type); check(INF, ( (strcmp(dev->vendor, "AGFA") == 0) || (strcmp(dev->vendor, "Abaton") == 0) || (strcmp(dev->vendor, "Acer") == 0) || (strcmp(dev->vendor, "Apple") == 0) || (strcmp(dev->vendor, "Artec") == 0) || (strcmp(dev->vendor, "Avision") == 0) || (strcmp(dev->vendor, "CANON") == 0) || (strcmp(dev->vendor, "Connectix") == 0) || (strcmp(dev->vendor, "Epson") == 0) || (strcmp(dev->vendor, "Fujitsu") == 0) || (strcmp(dev->vendor, "Gphoto2") == 0) || (strcmp(dev->vendor, "Hewlett-Packard") == 0) || (strcmp(dev->vendor, "IBM") == 0) || (strcmp(dev->vendor, "Kodak") == 0) || (strcmp(dev->vendor, "Lexmark") == 0) || (strcmp(dev->vendor, "Logitech") == 0) || (strcmp(dev->vendor, "Microtek") == 0) || (strcmp(dev->vendor, "Minolta") == 0) || (strcmp(dev->vendor, "Mitsubishi") == 0) || (strcmp(dev->vendor, "Mustek") == 0) || (strcmp(dev->vendor, "NEC") == 0) || (strcmp(dev->vendor, "Nikon") == 0) || (strcmp(dev->vendor, "Noname") == 0) || (strcmp(dev->vendor, "Plustek") == 0) || (strcmp(dev->vendor, "Polaroid") == 0) || (strcmp(dev->vendor, "Relisys") == 0) || (strcmp(dev->vendor, "Ricoh") == 0) || (strcmp(dev->vendor, "Sharp") == 0) || (strcmp(dev->vendor, "Siemens") == 0) || (strcmp(dev->vendor, "Tamarack") == 0) || (strcmp(dev->vendor, "UMAX") == 0)), "unknown device vendor [%s]. Update SANE doc section \"Vendor Strings\"", dev->vendor); } /* loop on detecting device to let time to plug/unplug scanners */ while(loopvendor, dev->name, dev->type, dev->model); } if(i==0) { check(MSG, 0, "\tnone..."); } sleep(1); (*device_list) = NULL; status = sane_get_devices (device_list, SANE_TRUE); check(FATAL, (status == SANE_STATUS_GOOD), "sane_get_devices() failed (%s)", sane_strstatus (status)); loop++; } return 0; } /** test test_default * test by scanning using default values * @param device device to use for the scan */ static void test_default(SANE_Device * device) { test_scan(device); } static void usage(const char *execname) { printf("Usage: %s [-d backend_name] [-l test_level] [-s] [-r recursion_level] [-g time (s)]\n", execname); printf("\t-v\tverbose level\n"); printf("\t-d\tbackend name\n"); printf("\t-l\tlevel of testing (0=some, 1=0+options, 2=1+scans, 3=longest tests)\n"); printf("\t-s\tdo a scan during open/close tests\n"); printf("\t-r\trecursion level for option testing (the higher, the longer)\n"); printf("\t-g\ttime to loop on sane_get_devices function to test scannet hotplug detection (time is in seconds).\n"); } int main (int argc, char **argv) { char *devname = NULL; SANE_Status status; SANE_Int version_code; SANE_Handle device; int ch; int index; int i; const SANE_Device **device_list; int rc; int recursion_level; int time; int default_scan; printf("tstbackend, Copyright (C) 2002 Frank Zago\n"); printf("tstbackend comes with ABSOLUTELY NO WARRANTY\n"); printf("This is free software, and you are welcome to redistribute it\n"); printf("under certain conditions. See COPYING file for details\n\n"); printf("This is tstbackend build %d\n\n", BUILD); /* Read the command line options. */ opterr = 0; recursion_level = 5; /* 5 levels or recursion should be enough */ test_level = 0; /* basic tests only */ time = 0; /* no get devices loop */ default_scan = 0; while ((ch = getopt_long (argc, argv, "-v:d:l:r:g:h:s", basic_options, &index)) != EOF) { switch(ch) { case 'v': verbose_level = atoi(optarg); break; case 'd': devname = strdup(optarg); break; case 'l': test_level = atoi(optarg); if (test_level < 0 || test_level > 4) { fprintf(stderr, "invalid test_level\n"); return(1); } break; case 's': default_scan = 1; break; case 'r': recursion_level = atoi(optarg); break; case 'g': time = atoi(optarg); break; case 'h': usage(argv[0]); return(0); case '?': fprintf(stderr, "invalid option\n"); return(1); default: fprintf(stderr, "bug in tstbackend\n"); return(1); } } /* First test */ check(MSG, 0, "TEST: init/exit"); for (i=0; i<10; i++) { /* Test 1. init/exit with a version code */ status = sane_init(&version_code, NULL); check(FATAL, (status == SANE_STATUS_GOOD), "sane_init failed with %s", sane_strstatus (status)); check(FATAL, (SANE_VERSION_MAJOR(version_code) == 1), "invalid SANE version linked"); sane_exit(); /* Test 2. init/exit without a version code */ status = sane_init(NULL, NULL); check(FATAL, (status == SANE_STATUS_GOOD), "sane_init failed with %s", sane_strstatus (status)); sane_exit(); /* Test 3. Init/get_devices/open invalid/exit */ status = sane_init(NULL, NULL); check(FATAL, (status == SANE_STATUS_GOOD), "sane_init failed with %s", sane_strstatus (status)); status = sane_get_devices (&device_list, SANE_TRUE); check(FATAL, (status == SANE_STATUS_GOOD), "sane_get_devices() failed (%s)", sane_strstatus (status)); status = sane_open ("opihndvses75bvt6fg", &device); check(WRN, (status == SANE_STATUS_INVAL), "sane_open() failed (%s)", sane_strstatus (status)); if (status == SANE_STATUS_GOOD) sane_close(device); sane_exit(); /* Test 4. Init/get_devices/open default/exit */ status = sane_init(NULL, NULL); check(FATAL, (status == SANE_STATUS_GOOD), "sane_init failed with %s", sane_strstatus (status)); status = sane_get_devices (&device_list, SANE_TRUE); check(FATAL, (status == SANE_STATUS_GOOD), "sane_get_devices() failed (%s)", sane_strstatus (status)); status = sane_open ("", &device); if (status == SANE_STATUS_GOOD) sane_close(device); sane_exit(); } status = sane_init (&version_code, NULL); check(FATAL, (status == SANE_STATUS_GOOD), "sane_init failed with %s", sane_strstatus (status)); /* Check the device list */ rc = test_get_devices(&device_list, time); if (rc) goto the_exit; if (!devname) { /* If no device name was specified explicitly, we look at the environment variable SANE_DEFAULT_DEVICE. If this variable is not set, we open the first device we find (if any): */ devname = getenv ("SANE_DEFAULT_DEVICE"); if (devname) devname = strdup(devname); } if (!devname) { if (device_list[0]) { devname = strdup(device_list[0]->name); } } rc = check(ERR, (devname != NULL), "no SANE devices found"); if (!rc) goto the_exit; check(MSG, 0, "using device %s", devname); /* Test open close */ check(MSG, 0, "TEST: open/close"); for (i=0; i<10; i++) { status = sane_open (devname, &device); rc = check(ERR, (status == SANE_STATUS_GOOD), "sane_open failed with %s for device %s", sane_strstatus (status), devname); if (!rc) goto the_exit; if (default_scan) { test_default (device); } sane_close (device); } if (test_level < 1) { sane_exit(); goto the_exit; } /* Test options */ check(MSG, 0, "TEST: options consistency"); status = sane_open (devname, &device); check(FATAL, (status == SANE_STATUS_GOOD), "sane_open failed with %s for device %s", sane_strstatus (status), devname); test_parameters(device, NULL); test_options(device, recursion_level); sane_close (device); sane_exit(); if (test_level < 2) { goto the_exit; } /* Test scans */ check(MSG, 0, "TEST: scan test"); status = sane_init (&version_code, NULL); check(FATAL, (status == SANE_STATUS_GOOD), "sane_init failed with %s", sane_strstatus (status)); status = sane_open (devname, &device); check(FATAL, (status == SANE_STATUS_GOOD), "sane_open failed with %s for device %s", sane_strstatus (status), devname); test_scans(device); sane_close (device); sane_exit(); the_exit: if (devname) free(devname); display_stats(); return(0); } sane-backends-1.0.29/frontend/Makefile.in0000644000000000000000000006632213615534556015102 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ EXTRA_PROGRAMS = test$(EXEEXT) tstbackend$(EXEEXT) $(am__EXEEXT_1) bin_PROGRAMS = scanimage$(EXEEXT) @COMPILE_SANED_TRUE@sbin_PROGRAMS = saned$(EXEEXT) @COMPILE_SANED_FALSE@am__append_1 = saned subdir = frontend ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @COMPILE_SANED_FALSE@am__EXEEXT_1 = saned$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" PROGRAMS = $(bin_PROGRAMS) $(sbin_PROGRAMS) am_saned_OBJECTS = saned.$(OBJEXT) saned_OBJECTS = $(am_saned_OBJECTS) am__DEPENDENCIES_1 = saned_DEPENDENCIES = ../backend/libsane.la ../sanei/libsanei.la \ ../lib/liblib.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_scanimage_OBJECTS = scanimage.$(OBJEXT) sicc.$(OBJEXT) \ stiff.$(OBJEXT) scanimage_OBJECTS = $(am_scanimage_OBJECTS) scanimage_DEPENDENCIES = ../backend/libsane.la ../sanei/libsanei.la \ ../lib/liblib.la $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_test_OBJECTS = test.$(OBJEXT) test_OBJECTS = $(am_test_OBJECTS) test_DEPENDENCIES = ../lib/liblib.la ../backend/libsane.la am_tstbackend_OBJECTS = tstbackend.$(OBJEXT) tstbackend_OBJECTS = $(am_tstbackend_OBJECTS) tstbackend_DEPENDENCIES = ../lib/liblib.la ../backend/libsane.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/sane depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/saned.Po ./$(DEPDIR)/scanimage.Po \ ./$(DEPDIR)/sicc.Po ./$(DEPDIR)/stiff.Po ./$(DEPDIR)/test.Po \ ./$(DEPDIR)/tstbackend.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(saned_SOURCES) $(scanimage_SOURCES) $(test_SOURCES) \ $(tstbackend_SOURCES) DIST_SOURCES = $(saned_SOURCES) $(scanimage_SOURCES) $(test_SOURCES) \ $(tstbackend_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp 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 AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ scanimage_SOURCES = scanimage.c sicc.c sicc.h stiff.c stiff.h scanimage_LDADD = ../backend/libsane.la ../sanei/libsanei.la ../lib/liblib.la \ $(PNG_LIBS) $(JPEG_LIBS) saned_SOURCES = saned.c saned_LDADD = ../backend/libsane.la ../sanei/libsanei.la ../lib/liblib.la \ $(SYSLOG_LIBS) $(SYSTEMD_LIBS) $(AVAHI_LIBS) test_SOURCES = test.c test_LDADD = ../lib/liblib.la ../backend/libsane.la tstbackend_SOURCES = tstbackend.c tstbackend_LDADD = ../lib/liblib.la ../backend/libsane.la all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu frontend/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu frontend/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ } \ ; done uninstall-sbinPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sbindir)" && rm -f $$files clean-sbinPROGRAMS: @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list saned$(EXEEXT): $(saned_OBJECTS) $(saned_DEPENDENCIES) $(EXTRA_saned_DEPENDENCIES) @rm -f saned$(EXEEXT) $(AM_V_CCLD)$(LINK) $(saned_OBJECTS) $(saned_LDADD) $(LIBS) scanimage$(EXEEXT): $(scanimage_OBJECTS) $(scanimage_DEPENDENCIES) $(EXTRA_scanimage_DEPENDENCIES) @rm -f scanimage$(EXEEXT) $(AM_V_CCLD)$(LINK) $(scanimage_OBJECTS) $(scanimage_LDADD) $(LIBS) test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES) $(EXTRA_test_DEPENDENCIES) @rm -f test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_OBJECTS) $(test_LDADD) $(LIBS) tstbackend$(EXEEXT): $(tstbackend_OBJECTS) $(tstbackend_DEPENDENCIES) $(EXTRA_tstbackend_DEPENDENCIES) @rm -f tstbackend$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tstbackend_OBJECTS) $(tstbackend_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/saned.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scanimage.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sicc.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stiff.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tstbackend.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @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)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)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 $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool clean-local \ clean-sbinPROGRAMS mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/saned.Po -rm -f ./$(DEPDIR)/scanimage.Po -rm -f ./$(DEPDIR)/sicc.Po -rm -f ./$(DEPDIR)/stiff.Po -rm -f ./$(DEPDIR)/test.Po -rm -f ./$(DEPDIR)/tstbackend.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-sbinPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/saned.Po -rm -f ./$(DEPDIR)/scanimage.Po -rm -f ./$(DEPDIR)/sicc.Po -rm -f ./$(DEPDIR)/stiff.Po -rm -f ./$(DEPDIR)/test.Po -rm -f ./$(DEPDIR)/tstbackend.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-binPROGRAMS clean-generic clean-libtool clean-local \ clean-sbinPROGRAMS cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-binPROGRAMS install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-sbinPROGRAMS install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-sbinPROGRAMS .PRECIOUS: Makefile clean-local: rm -f test tstbackend # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/frontend/stiff.h0000666000000000000000000000170413615534521014306 00000000000000/* Create SANE/tiff headers TIFF interfacing routines for SANE Copyright (C) 2000 Peter Kirchgessner 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ void sanei_write_tiff_header (SANE_Frame format, int width, int height, int depth, int resolution, const char *icc_profile, FILE *ofp); sane-backends-1.0.29/frontend/sicc.c0000666000000000000000000000344513615534521014113 00000000000000/* Load an ICC profile for embedding in an output file Copyright (C) 2017 Aaron Muir Hamilton 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "../include/sane/config.h" #include #include #include void * sanei_load_icc_profile (const char *path, size_t *size) { FILE *fd = NULL; size_t stated_size = 0; void *profile = NULL; struct stat s; fd = fopen(path, "r"); if (!fd) { fprintf(stderr, "Could not open ICC profile %s\n", path); } else { fstat(fileno(fd), &s); stated_size = 16777216 * fgetc(fd) + 65536 * fgetc(fd) + 256 * fgetc(fd) + fgetc(fd); rewind(fd); if (stated_size > (size_t) s.st_size) { fprintf(stderr, "Ignoring ICC profile because file %s is shorter than the profile\n", path); } else { profile = malloc(stated_size); if (fread(profile, stated_size, 1, fd) != 1) { fprintf(stderr, "Error reading ICC profile %s\n", path); free(profile); } else { fclose(fd); *size = stated_size; return profile; } } fclose(fd); } return NULL; } sane-backends-1.0.29/install-sh0000755000000000000000000003601013615534556013211 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2018-03-11.20; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dstbase=`basename "$src"` case $dst in */) dst=$dst$dstbase;; *) dst=$dst/$dstbase;; esac dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi case $dstdir in */) dstdirslash=$dstdir;; *) dstdirslash=$dstdir/;; esac obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) # Note that $RANDOM variable is not portable (e.g. dash); Use it # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 # Because "mkdir -p" follows existing symlinks and we likely work # directly in world-writeable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p' feature. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=${dstdirslash}_inst.$$_ rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: sane-backends-1.0.29/INSTALL0000644000000000000000000003661413615534556012250 00000000000000Installation Instructions ************************* Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell command './configure && make && make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the 'README' file for instructions specific to this package. Some packages provide this 'INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a 'Makefile' in each directory of the package. It may also create one or more '.h' files containing system-dependent definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, and a file 'config.log' containing compiler output (useful mainly for debugging 'configure'). It can also use an optional file (typically called 'config.cache' and enabled with '--cache-file=config.cache' or simply '-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how 'configure' could check whether to do them, and mail diffs or instructions to the address given in the 'README' so they can be considered for the next release. If you are using the cache, and at some point 'config.cache' contains results you don't want to keep, you may remove or edit it. The file 'configure.ac' (or 'configure.in') is used to create 'configure' by a program called 'autoconf'. You need 'configure.ac' if you want to change it or regenerate 'configure' using a newer version of 'autoconf'. The simplest way to compile this package is: 1. 'cd' to the directory containing the package's source code and type './configure' to configure the package for your system. Running 'configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type 'make' to compile the package. 3. Optionally, type 'make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type 'make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the 'make install' phase executed with root privileges. 5. Optionally, type 'make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior 'make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing 'make clean'. To also remove the files that 'configure' created (so you can compile the package for a different kind of computer), type 'make distclean'. There is also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type 'make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide 'make distcheck', which can by used by developers to test that all other targets like 'make install' and 'make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the 'configure' script does not know about. Run './configure --help' for details on some of the pertinent environment variables. You can give 'configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU 'make'. 'cd' to the directory where you want the object files and executables to go and run the 'configure' script. 'configure' automatically checks for the source code in the directory that 'configure' is in and in '..'. This is known as a "VPATH" build. With a non-GNU 'make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use 'make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple '-arch' options to the compiler but only a single '-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the 'lipo' tool if you have problems. Installation Names ================== By default, 'make install' installs the package's commands under '/usr/local/bin', include files under '/usr/local/include', etc. You can specify an installation prefix other than '/usr/local' by giving 'configure' the option '--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option '--exec-prefix=PREFIX' to 'configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like '--bindir=DIR' to specify different values for particular kinds of files. Run 'configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of '${prefix}', so that specifying just '--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to 'configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the 'make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, 'make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of '${prefix}'. Any directories that were specified during 'configure', but not in terms of '${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the 'DESTDIR' variable. For example, 'make install DESTDIR=/alternate/directory' will prepend '/alternate/directory' before all installation names. The approach of 'DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of '${prefix}' at 'configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving 'configure' the option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. Some packages pay attention to '--enable-FEATURE' options to 'configure', where FEATURE indicates an optional part of the package. They may also pay attention to '--with-PACKAGE' options, where PACKAGE is something like 'gnu-as' or 'x' (for the X Window System). The 'README' should mention any '--enable-' and '--with-' options that the package recognizes. For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, you can use the 'configure' options '--x-includes=DIR' and '--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of 'make' will be. For these packages, running './configure --enable-silent-rules' sets the default to minimal output, which can be overridden with 'make V=1'; while running './configure --disable-silent-rules' sets the default to verbose, which can be overridden with 'make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. HP-UX 'make' updates targets which have the same time stamps as their prerequisites, which makes it generally unusable when shipped generated files such as 'configure' are involved. Use GNU 'make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its '' header file. The option '-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put '/usr/ucb' early in your 'PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in '/usr/bin'. So, if you need '/usr/ucb' in your 'PATH', put it _after_ '/usr/bin'. On Haiku, software installed for all users goes in '/boot/common', not '/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features 'configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, 'configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the '--build=TYPE' option. TYPE can either be a short name for the system type, such as 'sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file 'config.sub' for the possible values of each field. If 'config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option '--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with '--host=TYPE'. Sharing Defaults ================ If you want to set default values for 'configure' scripts to share, you can create a site shell script called 'config.site' that gives default values for variables like 'CC', 'cache_file', and 'prefix'. 'configure' looks for 'PREFIX/share/config.site' if it exists, then 'PREFIX/etc/config.site' if it exists. Or, you can set the 'CONFIG_SITE' environment variable to the location of the site script. A warning: not all 'configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to 'configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the 'configure' command line, using 'VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified 'gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an Autoconf limitation. Until the limitation is lifted, you can use this workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash 'configure' Invocation ====================== 'configure' recognizes the following options to control how it operates. '--help' '-h' Print a summary of all of the options to 'configure', and exit. '--help=short' '--help=recursive' Print a summary of the options unique to this package's 'configure', and exit. The 'short' variant lists options used only in the top level, while the 'recursive' variant lists options also present in any nested packages. '--version' '-V' Print the version of Autoconf used to generate the 'configure' script, and exit. '--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally 'config.cache'. FILE defaults to '/dev/null' to disable caching. '--config-cache' '-C' Alias for '--cache-file=config.cache'. '--quiet' '--silent' '-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to '/dev/null' (any error messages will still be shown). '--srcdir=DIR' Look for the package's source code in directory DIR. Usually 'configure' can determine that directory automatically. '--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. '--no-create' '-n' Run the configure checks, but stop before creating any output files. 'configure' also accepts some other, not widely useful, options. Run 'configure --help' for more details. sane-backends-1.0.29/doc/0000755000000000000000000000000013615535553012030 500000000000000sane-backends-1.0.29/doc/mustek_usb2/0000755000000000000000000000000013615535552014272 500000000000000sane-backends-1.0.29/doc/mustek_usb2/mustek_usb2.TODO0000666000000000000000000000056613615534521017152 00000000000000.mustek_usb2.TODO -*-text-*- - Check if there is an easy way to avoid pthread - prepare for different scanners (and more than one scanner) - adjust debug levels (currently only DBG_FUNC is used in _high.c). - unify debug messages ("start"/"exit" functions etc.) - check all "HOLD"s in the code - check if 1200 x 2400 dpi modes can be added - try to add additional scanners sane-backends-1.0.29/doc/mustek_usb2/mustek_usb2.CHANGES0000666000000000000000000001230113615534521017443 00000000000000mustek_usb2.CHANGES -*-text-*- V 1.0-10 (2005-10-16) - Removed typedefs for DWORD, WORD and so on. Used int, unsigned short, ... directly in the code. V 1.0-9 (2005-10-02) - Removed global variables in mustek_usb2.c: Deleted the following variables (not necessary): m_bIsOpen Moved the following varaiables to Mustek_Scanner structure: m_bIsScanning m_bIsReading setpara getpara read_rows Scan_data_buf Scan_data_buf_start scan_buffer_len Used local variables instead: dpi_list; - Minor cleanups. - Fixed check for Scan_data_buf != NULL. - Moved check for Scan_data_buf to sane_close (). - Avoid typedef'ing to long int in mustek_usb2_asic.h. Used int instead. Fixed DBG messages accordingly. - Fixed some compilation warnings on 64 bit platforms. V 1.0-8 (2005-10-01) - Added/modified checks for libpthread in acinclude.m4/configure.in. Disable backend if it's not there. V 1.0-7 (2005-09-30) - Added usleep in Asic_ScanStop() to avoid freezes after cancellation of a scan. - Added sane_constrain_value call in sane_control_option(). - Test with tstbackend succeeded this. - Changed usage of perror to DBG. - Removed _Open and _Close. These functions didn't do much at all. - Removed (commented out) code that tries to read values from config file. V 1.0-6 (2005-09-29) - Commented out unused code. - Made all symbols that don't belong to the SANE API static. - Changed all fprintfs to DBG messages. - Used real device name. Used real model name. - Added manual page (sane-mustek_usb2). - Fixed backend name in AUTHORS. V 1.0-5 (2005-09-28) - Merged all asic-related code into mustek_usb2_asic.c and .h. - Merged function definitions from mustek_usb2_tarnsparent.h and mustek_usb2_refelective.h to their respective .c files. Filename changes are finished now. - Moved defines used in mustek_usb2_high.c to moustek_usb_high.h. - All license/comment headers name the right scanner now. - Fixed "already included check" of header files - Used indent -gnu on all files. - Fixed compilation warnings and several bugs ("=" instead of "==" and similar stuff) in mustek_usb2_asic.c, mustek_usb2_transparent.c, mustek_usb2_reflective.c, mustek_usb2_high.c, mustek_usb2.c. V 1.0-4 (2005-09-27) - Changed filenames (preliminary, may be changed again): mustek_a2nu2.c --> mustek_usb2.c mustek_a2nu2.h --> mustek_usb2.h a2nu2/spicall/MustScanner.c --> mustek_usb2_high.c a2nu2/spicall/MustScanner.h --> mustek_usb2_high.h a2nu2/spicall/ScannerDefine.h --> included in mustek_usb2_high.h a2nu2/spicall/ScannerReflective.c --> mustek_usb2_reflective.c a2nu2/spicall/ScannerReflective.h --> mustek_usb2_reflective.h a2nu2/spicall/ScannerTransparent.c --> mustek_usb2_transparent.c a2nu2/spicall/ScannerTransparent.h --> mustek_usb2_transparent.h a2nu2/spicall/spicall.c --> included in mustek_usb2.c a2nu2/spicall/spicall_ex.h a2nu2/spicall/spicall_g.h --> included in mustek_usb2_high.c a2nu2/include/asic.h --> included in mustek_usb2_asic_low.h a2nu2/include/debug.h --> removed a2nu2/include/ini.h a2nu2/include/msam.ini --> removed a2nu2/include/public.h --> included in mustek_usb2_typedef.h a2nu2/include/spicall.h --> included in mustek_usb2.h a2nu2/include/typedef.h --> mustek_usb2_asic_low.h a2nu2/conf/ini.c --> removed a2nu2/asic/asic.c --> mustek_usb2_asic.c a2nu2/asic/asic_libusb.c --> removed (used sanei_usb) a2nu2/asic/asic_libusb.h --> removed a2nu2/asic/asic_mid.c --> mustek_usb2_asic_mid.c a2nu2/asic/asic_mid.h --> included in mustek_usb2_asic_mid.c a2nu2/asic/asic_motor.c --> mustek_usb2_asic_motor.c a2nu2/asic/asic_motor.h --> mustek_usb2_asic_motor.h a2nu2/asic/asic_usb.c --> mustek_usb2_asic_low.c a2nu2/asic/asic_usb.h --> included in mustek_usb2_asic_low.h a2nu2/asic/DefineScanner.h --> mustek_usb2_asic_low.h a2nu2/asic/ScanRegDef.h --> included in mustek_usb2_asic_low.h - Changed backend name to mustek_usb2. - Used dos2unix to change dos line endings to unix. - Added mustek_usb2.TODO. - Changed several occurences of "//" to "/* */". - Used DBG instead of XDBG. - Defined DBG levels in mustek_usb2_asic_low.h. - Changed code to use sanei_usb instead of home-grown usb functions. V 1.0-3 (2005-08-31) - Updated code from Mustek, mostly changed // to /* */ - Enabled compilation warnings again. - Scanner is confirmed to work at least on Linux. V 1.0-2 (2005-08-30) - Initial version based on the code from Roy Zhou, Jack Xu, Vinci Cen. - This version is just to make it compile at all and to trim down the package size by removing all the unneeded backends. Before inclusion into SANE can be done, the sub directories, several libraries and the amount of files has to be fixed (and lots of other stuff). - Based everything on current CVS. - Fixed AUTHORS. - Added mustek_pro.CHANGES. - Fixed dll.conf. - Fixed .desc file. - Adjusted configure.in to build only test, net and mustek_a2nu2 backends. - Adjusted backend/Makefile.in. - Disabled compilation warnings, otherwise the "//" comments will cause errors. - Fixed several upper/lower case problems. - Removed definition of Option_Value. - Started renaming doc files to new backend name: msutek_usb2. - Added GPL+SANE exception to all remaining files. sane-backends-1.0.29/doc/sane-artec.man0000666000000000000000000001172413615534521014472 00000000000000.TH sane\-artec 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-artec .SH NAME sane\-artec \- SANE backend for Artec flatbed scanners .SH DESCRIPTION The .B sane\-artec library implements a SANE (Scanner Access Now Easy) backend that provides access to Artec/Ultima SCSI flatbed scanners. At present, the following scanners are known to work at least partially with this backend: .PP .RS * Artec A6000C .br * Artec A6000C PLUS .br * Artec ViewStation AT3 .br * BlackWidow BW4800SP (rebadged Artec AT3) .br * Artec ViewStation AT6 .br * Artec ViewStation AT12 .br * Artec AM12S .br * Plustek 19200S (rebadged Artec AM12S) .RE .PP Although this manual page is generally updated with each release, up-to-date information on new releases and extraneous helpful hints are available from the backend homepage: .br .br .RS .B http://www4.infi.net/~cpinkham/sane/ .RE .SH DOCUMENTATION .SH CONFIGURATION The contents of the .I artec.conf file are a list of device names that correspond to Artec scanners. Empty lines and lines starting with a hash mark (#) are ignored. See .I sane\-scsi(5) on details of what constitutes a valid device name. Sample file: .br .br .nf # artec.conf # # this is a comment. # # this line says search for any SCSI devices which are scanners and have # a vendor string of 'ULTIMA' scsi ULTIMA # # the next line forces the backend to assume the next scanner found has # the specified vendor string (useful for testing rebadged models). vendor ULTIMA # # the next line forces the backend to assume the next scanner found has # the specified model string (useful for testing rebadged models). model AT3 # # now a line that actually specifies a device. The backend is going to # assume this is an Artec/Ultima AT3 because we forced the vendor and # model above. /dev/scanner # # once we hit a scanner device line, the forced vendor and model # string are # 'forgotten', so the vendor and model for this next device will be # determined from the result of a SCSI inquiry. /dev/sge # .fi .SH SCSI ADAPTER TIPS Some Artec scanners come with an included SCSI adapter. If your scanner came with a DTC ISA scsi cards, you can probably use it with recent (>= 2.2.0) kernels using the generic NCR5380 support. You must pass the following boot argument to the kernel: "dtc3181e=0x2c0,0" .br I do not have any information on the PCI SCSI adapter included with some newer Artec scanners. .SH FILES .TP .I @CONFIGDIR@/artec.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-artec.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-artec.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi- colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working direc- tory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_ARTEC If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity: SANE_DEBUG_ARTEC values .ft CR .nf Number Remark \ 0 print important errors 1 print errors 2 print sense 3 print warnings 4 print scanner-inquiry 5 print information 6 print less important information 7 print major called procedures 8 print all called procedures 9 print procedure info/data messages 10 print called sane\-init-routines 11 print called sane\-procedures 12 print sane infos 13 print sane option-control messages \ 50 print verbose data/debug messages \ == 100 print software RGB calibration data == 101 print raw data from scanner to artec.data.raw file \ == 128 print out all messages .fi .ft R .PP Example: export SANE_DEBUG_ARTEC=13 .SH BUGS Known bugs in this release: A6000C+ users with firmware v1.92 or earlier have problems with the backend, the cause has not been determined. Sometimes the backend is not particularly robust, you can possibly lock up the SCSI bus (and/or machine) by not having patience enough when scanning. 3-channel gamma correction is not implemented and single-channel gamma correction is not totally working on models other than the AT3. .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHOR Chris Pinkham (cpinkham@corp.infi.net) sane-backends-1.0.29/doc/sane-plustek_pp.man0000666000000000000000000003262513615534521015565 00000000000000.TH sane\-plustek_pp 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-plustek_pp .SH NAME sane\-plustek_pp \- SANE backend for Plustek parallel port flatbed scanners .SH DESCRIPTION The .B sane\-plustek_pp library implements a SANE (Scanner Access Now Easy) backend that provides access to Plustek ASIC 9600[1/3] and P9800[1/3] based parallel port flatbed scanners. The access of the scanner is either done directly by the backend or via kernel module, called pt_drv which can be created out of the plustek_pp backend code \- see also section .B "BUILDING THE KERNEL MODULE" for further information. .SH "SUPPORTED DEVICES" At present, the following scanners should work with this backend and/or the kernel module: .PP .B "PLUSTEK SCANNERS" .PP .ft CR .nf Parallelport Model: ASIC: Properties: ---------------------- ----- ------------------------ OpticPro PT12 98003 600x1200 dpi 36bit 512Kb OpticPro P12 98003 600x1200 dpi 36bit 512Kb OpticPro 9636T/12000T 98001 600x1200 dpi 36bit 512Kb OpticPro 12000P Turbo 98001 600x1200 dpi 36bit 512Kb OpticPro 9636P+/Turbo 98001 600x1200 dpi 36bit 512Kb OpticPro 9636P 96003 600x1200 dpi 36bit 128Kb OpticPro 12000P/96000P 96003 600x1200 dpi 36bit 128Kb OpticPro 1236P 96003 600x1200 dpi 30bit 128Kb OpticPro 9600P 96003 600x1200 dpi 30bit 128Kb OpticPro 9630P/FBIV 96003 600x1200 dpi 30bit 128Kb OpticPro 9630PL (14") 96003 600x1200 dpi 30bit 128Kb OpticPro A3I 96003 400x800 dpi 36bit 128Kb OpticPro 600P/6000P 96003 300x600 dpi 30bit 32Kb OpticPro 4831P 96003 300x600 dpi 30bit 32Kb OpticPro 4830P/FBIII 96003 300x600 dpi 30bit 32Kb OpticPro 4800P/FBII 96001 300x600 dpi 24bit 32Kb .fi .ft R .PP .B "PRIMAX SCANNERS" There are some scanners sold by Primax, but they are in fact Plustek devices. These scanners are also supported. The following table will show the relationship: .PP .ft CR .nf Model: Plustek Model: Remarks: --------------------------- -------------- ------------ Colorado 4800 OpticPro 4800 not tested Compact 4800 Direct OpticPro 600 mov=2 Compact 4800 Direct 30bit OpticPro 4830 mov=7 Compact 9600 Direct 30bit OpticPro 9630 works .fi .ft R .PP .B "GENIUS SCANNERS" The following devices are sold as Genius Scanners, but are in fact Plustek devices. The table will show the relationship: .PP .ft CR .nf Model: Remarks: --------------------------- ---------------------------- Colorpage Vivid III V2 Like P12 but has two buttons and Wolfson DAC .fi .ft R .PP .B "ARIES SCANNERS" There's one scanner sold as Aries Scanner, but is in fact a Plustek device. The following table will show the relationship: .PP .ft CR .nf Model: Plustek Model: Remarks: --------------------------- -------------- ------------ Scan-It 4800 OpticPro 600 mov=2 .fi .ft R .PP .B "BrightScan SCANNERS" There's one scanner sold as BrightScan OpticPro Scanner, this is also a rebadged Plustek device. The following table will show the relationship: .PP .ft CR .nf Model: Remarks: --------------------------- ---------------------------- BrightScan OpticPro OpticPro P12 .fi .ft R .SH "DEVICE NAMES" This backend works in two modes, the so called "direct-mode" and the "kernel-mode". In direct-mode, the user-space backend is used, in kernel-mode, you should have a kernel-module named pt_drv loaded. This backends default device is: .PP .RS .I 0x378 .RE .PP This "default device" will be used, if no configuration file can be found. It is rather the base address of the parallel port on i386 machines. .PP As the backend supports up to four devices, it is possible to specify them in the configuration file .PP .RS .I @CONFIGDIR@/plustek_pp.conf .RE .PP See this file for examples. .PP .SH "CONFIGURATION" .PP This section describes the backends' configuration file entries. The file is located at: .I @CONFIGDIR@/plustek_pp.conf .PP For a proper setup, you will need at least two entries: .RS .I [direct] .br .I device 0x378 .RE .PP or .RS .I [kernel] .br .I device /dev/pt_drv .RE .PP .I direct tells the backend, that the following devicename (here .IR 0x378 ) has to be interpreted as parallel port scanner device. In fact it is the address to use, alternatively you can use .I /dev/parport0 if the backend has been compiled with libieee1284 support. .I kernel should only be used, when a kernel-module has been built out of the backend sources. See below for more instructions about this. .PP Further options: .PP option warmup t .RS .I t specifies the warmup period in seconds .RE .PP option lampOff t .RS .I t is the time in seconds for switching off the lamps in standby mode .RE .PP option lOffonEnd b .RS .I b specifies the behaviour when closing the backend, 1 --> switch lamps off, 0 --> do not change lamp status .RE .PP option mov m .RS .I m is the model override switch, which only works in direct mode. .TP .IR m " = 0" default: no override .TP .IR m " = 1" OpticPro 9630PL override (works if OP9630 has been detected) forces legal size (14") .TP .IR m " = 2" Primax 4800Direct override (works if OP600 has been detected) swaps red/green color .TP .IR m " = 3" OpticPro 9636 override (works if OP9636 has been detected) disables backends transparency/negative capabilities .TP .IR m " = 4" OpticPro 9636P override (works if OP9636 has been detected) disables backends transparency/negative capabilities .TP .IR m " = 5" OpticPro A3I override (works if OP12000 has been detected) enables A3 scanning .TP .IR m " = 6" OpticPro 4800P override (works if OP600 has been detected) swaps red/green color .TP .IR m " = 7" Primax 4800Direct 30bit override (works if OP4830 has been detected) .RE .PP See the plustek_pp.conf file for examples. .PP .SH "BUILDING THE KERNEL MODULE" As mentioned before, the plustek_pp backend code can also be compiled and installed as linux kernel module. To do so, you will need the source-files of this sane\-backend installation. Unpack this tar-ball and go to the directory: .br .I sane\-backends/doc/plustek .br Within this directory, you should find a script called: .br .I MakeModule.sh .br Now if your Linux kernelsources are installed correctly, it should be possible to build, install and load the module .B pt_drv. .B Please note, that the kernelsources need to be configured correctly. Refer to your distributions manual on how this is done. As root user, try .br .I ./MakeModule.sh .br the script will try and get all necessary information about your running kernel and will lead you through the whole installation process. .br .B Note: Installing and loading the can only be done as superuser. .PP .SH "KERNEL MODULE SETUP" The configuration of the kernel module is done by providing some or more options found below to the kernel module at load time. This can be done by invoking insmod with the appropriate parameters or appending the options to the file .B /etc/modules.conf (kernel < 2.6.x) or .B /etc/modprobe.conf (kernel >= 2.6.x) .PP .B The Options: .br lampoff=lll .RS The value .I lll tells the driver, after how many seconds to switch-off the lamp(s). The default value is 180. 0 will disable this feature. .br .B HINT: Do not use a value that is too small, because often switching on/off the lamps will reduce their lifetime. .RE .PP port=ppp .RS .I ppp specifies the port base address, where the scanner is connected to. The default value is 0x378, which is normally a standard. .RE .PP warmup=www .RS .I www specifies the time in seconds, how long a lamp has to be on, until the driver will start to scan. The default value is 30. .RE .PP lOffonEnd=e .RS .I e specifies the behaviour when unloading the driver, 1 --> switch lamps off, 0 --> do not change lamp status .RE .PP slowIO=s .RS .I s specifies which I/O functions the driver should use, 1 --> use delayed functions, 0 --> use the non-delayed ones .RE .PP forceMode=fm .RS .I fm specifies port mode which should be used, 0 --> autodetection, 1 --> use SPP mode and 2 --> use EPP mode .RE .PP mov=m .RS .TP .IR m " = 0" default: no override .TP .IR m " = 1" OpticPro 9630PL override (works if OP9630 has been detected) forces legal size (14") .TP .IR m " = 2" Primax 4800Direct override (works if OP600 has been detected) swaps red/green color .TP .IR m " = 3" OpticPro 9636 override (works if OP9636 has been detected) disables backends transparency/negative capabilities .TP .IR m " = 4" OpticPro 9636P override (works if OP9636 has been detected) disables backends transparency/negative capabilities .TP .IR m " = 5" OpticPro A3I override (works if OP12000 has been detected) enables A3 scanning .TP .IR m " = 6" OpticPro 4800P override (works if OP600 has been detected) swaps red/green color .TP .IR m " = 7" Primax 4800Direct 30bit override (works if OP4830 has been detected) .RE .PP Sample entry for file .B "/etc/modules.conf" : .br .I alias char\-major\-40 pt_drv .br .I pre-install pt_drv modprobe -k parport .br .I options pt_drv lampoff=180 warmup=15 port=0x378 lOffonEnd=0 mov=0 slowIO=0 forceMode=0 .PP For multidevice support, simply add values separated by commas to the different options .br .I options pt_drv port=0x378,0x278 mov=0,4 slowIO=0,1 forceMode=0,1 .PP Remember to call depmod after changing /etc/conf.modules. .PP .SH "PARALLEL PORT MODES" .PP The current driver works best, when the parallel port has been set to EPP-mode. When detecting any other mode such as ECP or PS/2 the driver tries to set to a faster, supported mode. If this fails, it will use the SPP mode, as this mode should work with all Linux supported parallel ports. If in doubt, enter your BIOS and set it to any mode except ECP. .PP Former Plustek scanner models (4830, 9630) supplied a ISA parallel port adapter card. This card is .BR not supported by the driver. .PP The ASIC 96001/3 based models have sometimes trouble with high resolution modes. If you encounter sporadic corrupted images (parts duplicated or shifted horizontally) kill all other applications before scanning and (if sufficient memory available) disable swapping. .PP See the plustek_pp.conf file for examples. .PP .SH FILES .TP .I @CONFIGDIR@/plustek_pp.conf The backend configuration file .TP .I @LIBDIR@/libsane\-plustek_pp.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-plustek_pp.so The shared library implementing this backend (present on systems that support dynamic loading). .TP .I /lib/modules//kernel/drivers/parport/pt_drv.o The Linux kernelmodule for kernels < 2.6.x. .TP .I /lib/modules//kernel/drivers/parport/pt_drv.ko The Linux kernelmodule for kernels >= 2.6.x. .PP .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_PLUSTEK_PP If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_PLUSTEK_PP=10 .SH "SEE ALSO" .BR sane (7), .br .I @DOCDIR@/plustek/Plustek\-PARPORT.changes .SH "CONTACT AND BUG-REPORTS" Please send any information and bug-reports to: .br .B SANE Mailing List .PP Additional info and hints can be obtained from our .br Mailing-List archive at: .br .B http://www.sane\-project.org/mailing\-lists.html .PP To obtain debug messages from the backend, please set the environment-variable .I SANE_DEBUG_PLUSTEK_PP before calling your favorite scan-frontend (i.e. xscanimage). .br .B i.e.: export SANE_DEBUG_PLUSTEK_PP=20 ; xscanimage .PP The value controls the verbosity of the backend. .PP .SH "KNOWN BUGS & RESTRICTIONS" .PP * The Halftoning works, but the quality is poor .PP * Printers (especially HP models) will start to print during scanning. This in fact is a problem to other printers too, using bidirectional protocol (see www.plustek.com (TAIWAN) page for further details) .PP * The driver does not support these manic scalings up to 16 times the physical resolution. The only scaling is done on resolutions between the physical resolution of the CCD-sensor and the stepper motor i.e. you have a 600x1200 dpi scanner and you are scanning using 800dpi, so scaling is necessary, because the sensor only delivers 600dpi but the motor is capable to perform 800dpi steps. .PP * On some devices, the pictures seems bluish .PP .I ASIC 98001 based models: .PP * The 300dpi transparency and negative mode does not work correctly. .PP * There is currently no way to distinguish a model with and without transparency unit. .PP * The scanned images seem to be too dark (P9636T) .PP .I ASIC 96003/1 based models: .PP * 30bit mode is currently not supported. .PP * On low end systems under heavy system load the driver may lose data, which can result in picture corruption or cause the sensor to hit the scan bed. .PP * The scanning speed on 600x1200 dpi models is slow. .PP * The scanning quality of the A3I is poor sane-backends-1.0.29/doc/sane-fujitsu.man0000666000000000000000000001667113615534521015073 00000000000000.TH sane\-fujitsu 5 "08 Apr 2017" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-fujitsu .SH NAME sane\-fujitsu \- SANE backend for Fujitsu flatbed and ADF scanners .SH DESCRIPTION The .B sane\-fujitsu library implements a SANE (Scanner Access Now Easy) backend which provides access to most Fujitsu flatbed and ADF scanners. This document describes backend version 134, which shipped with SANE 1.0.28. .SH SUPPORTED HARDWARE This version supports every known model which speaks the Fujitsu SCSI and SCSI\-over\-USB protocols. Specifically, the SCSI M309x and M409x series, the SCSI fi\-series, most of the USB fi\-series, the USB ScanSnap S5xx/S15xx, and the USB iX1xx/5xx series scanners are supported. Please see the list at http://www.sane\-project.org/sane\-supported\-devices.html for details. This backend may support other Fujitsu scanners. The best way to determine level of support is to test the scanner directly, or to collect a trace of the windows driver in action. Please contact the author for help or with test results. .SH UNSUPPORTED HARDWARE The following scanners are known NOT to work with this backend, either because they have a non\-fujitsu chipset, or an unsupported interface type. Some of these scanners may be supported by another backend. .PP .RS .ft CR .nf \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- SCSI: SERIAL: USB: \-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\- ScanStation M3093E/DE/EX fi\-4110EOX/2 ScanPartner M3096EX fi\-4010CU SP\-Jr M3097E+/DE S300/S300M SP\-10/10C M3099A/EH/EX S1300/S1100 SP\-15C/300C fi\-60F/65F SP\-600C/620C fi\-5015C SP\-2x/3x .fi .ft R .RE .P .SH OPTIONS Effort has been made to expose all hardware options, including: .PP source s .RS Selects the source for the scan. Options may include "Flatbed", "ADF Front", "ADF Back", "ADF Duplex". .RE .PP mode m .RS Selects the mode for the scan. Options may include "Lineart", "Halftone", "Gray", and "Color". .RE .PP resolution, y\-resolution .RS Controls scan resolution. Setting \-\-resolution also sets \-\-y\-resolution, though this behavior is overridden by some frontends. .RE .PP tl\-x, tl\-y, br\-x, br\-y .RS Sets scan area upper left and lower right coordinates. These are renamed t, l, x, y by some frontends. .RE .PP page\-width, page\-height .RS Sets paper size. Used by scanner to determine centering of scan coordinates when using ADF and to detect double feed errors. .RE .PP Other options will be available based on the capabilities of the scanner: machines with IPC or DTC will have additional enhancement options, those with CMP will have compression options, those with a printer will have a group of endorser options. Additionally, several 'software' options are exposed by the backend. These are reimplementations of features provided natively by larger scanners, but running on the host computer. This enables smaller machines to have similar capabilities. Please note that these features are somewhat simplistic, and may not perform as well as the native implementations. Note also that these features all require that the driver cache the entire image in memory. This will almost certainly result in a reduction of scanning speed. Use 'scanimage \-\-help' to get a list, but be aware that some options may be settable only when another option has been set, and that advanced options may be hidden by some frontend programs. .PP .SH CONFIGURATION FILE The configuration file "fujitsu.conf" is used to tell the backend how to look for scanners, and provide options controlling the operation of the backend. This file is read each time the frontend asks the backend for a list of scanners, generally only when the frontend starts. If the configuration file is missing, the backend will be unable to locate any scanners. .PP Scanners can be specified in the configuration file in 4 ways: .PP "scsi FUJITSU" .RS Requests backend to search all scsi busses in the system for a device which reports itself to be a scanner made by 'FUJITSU'. .RE .PP "scsi /dev/sg0" (or other scsi device file) .RS Requests backend to open the named scsi device. Only useful if you have multiple compatible scanners connected to your system, and need to specify one. Probably should not be used with the other "scsi" line above. .RE .PP "usb 0x04c5 0x1042" (or other vendor/product ids) .RS Requests backend to search all usb busses in the system for a device which uses that vendor and product id. The device will then be queried to determine if it is a Fujitsu scanner. .RE .PP "usb /dev/usb/scanner0" (or other device file) .RS Some systems use a kernel driver to access usb scanners. This method is untested. .RE .PP The only configuration option supported is "buffer\-size=xxx", allowing you to set the number of bytes in the data buffer to something other than the compiled\-in default, 65536 (64K). Some users report that their scanner will "hang" mid\-page, or fail to transmit the image if the buffer is not large enough. .PP Note: This option may appear multiple times in the configuration file. It only applies to scanners discovered by 'scsi/usb' lines that follow this option. .PP Note: The backend does not place an upper bound on this value, as some users required it to be quite large. Values above the default are not recommended, and may crash your OS or lockup your scsi card driver. You have been warned. .PP .SH ENVIRONMENT The backend uses a single environment variable, SANE_DEBUG_FUJITSU, which enables debugging output to stderr. Valid values are: .PP .RS 5 Errors .br 10 Function trace .br 15 Function detail .br 20 Option commands .br 25 SCSI/USB trace .br 30 SCSI/USB writes .br 31 SCSI/USB reads .br 35 Useless noise .RE .SH KNOWN ISSUES Flatbed units may fail to scan at maximum area, particularly at high resolution. .PP Any model that does not support VPD during inquiry will not function until an override is added to the backend. .PP CCITT Fax compression used by older scanners is not supported. .PP JPEG output is supported by the backend, but not by the SANE protocol, so is disabled in this release. It can be enabled if you rebuild from source. .SH CREDITS m3091 backend: Frederik Ramm .br m3096g backend: Randolph Bentson .br (with credit to the unnamed author of the coolscan driver) .br fujitsu backend, m3093, fi\-4340C, ipc, cmp, long\-time maintainer: .br Oliver Schirrmeister .br m3092: Mario Goppold .br fi\-4220C and basic USB support: Ron Cemer .br fi\-4120, fi\-series color, backend re\-write, jpeg, current maintainer: m. allan noah: JPEG output and low memory usage support funded by: Archivista GmbH www.archivista.ch Endorser support funded by: O A S Oilfield Accounting Service Ltd 1500, 840 \- 7th Avenue S.W. Calgary, Alberta T2P 3G2 Canada 1\-403\-263\-2600 www.oas.ca Automatic length detection support funded by: Martin G. Miller mgmiller at optonline.net Hardware donated, software image enhancement and fi-6/7xxx support funded by: Fujitsu Computer Products of America, Inc. www.fcpa.com iX500 support funded by: Prefix Computer Services www.prefixservice.com .SH "SEE ALSO" sane(7), sane\-scsi(5), sane\-usb(5), sane\-sp15c(5), sane\-avision(5), sane\-epjitsu(5) .SH AUTHOR m. allan noah: sane-backends-1.0.29/doc/sane-p5.man0000666000000000000000000001046013615534521013714 00000000000000.TH "sane\-p5" "5" "15 Feb 2010" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-p5 .SH "NAME" sane\-p5 \- SANE backend for the Primax PagePartner .SH "DESCRIPTION" The .B sane\-p5 library implements a SANE (Scanner Access Now Easy) backend that provides access to the Primax PagePartner parallel port sheet fed scanner. .PP This backend handles 100, 150, 200, 300 and 600 dpi scan resolutions, in color and gray modes. The 600 dpi is actually 300x600 with lines enlarged to match the vertical resolution. .PP .B EPP/ECP MODES ONLY The current version of the backend uses only EPP or ECP mode to communicate with the scanner. It is recommended that you set your parallel port to EPP in BIOS with the current version of this backend. ECPEPP will only work if you use a 2.4 or 2.6 kernel with ppdev character device support. .PP .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I port value .RE .PP Where \fBvalue\fR is : .RS .TP auto autodetect all parallel ports and probe them for scanner .TP /dev/parport0 uses linux ppdev device, depending on the number of available parallel port, you have to use /dev/parport1, /dev/parport2, ... .PP .RE You can rename any device using the .PP .RS .br .I option name my_name .RE .PP option. This option apply to the last port option. .SH "CONFIGURATION" Please make sure to edit dll.conf .B before you use the backend, since this backend isn't enabled by default. .PP .PP .SH "FILES" .TP .I @CONFIGDIR@/p5.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-p5.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-p5.so The shared library implementing this backend (present on systems that support dynamic loading). .SH "ENVIRONMENT" .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_P5 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 255 requests all debug output to be printed. Smaller levels reduce verbosity. .PP .RS .ft CR .nf level debug output \-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- 0 critical errors 1 errors 2 warnings & minor errors 4 information messages 8 start/stop of functions 16 tracing messages 32 I/O functions 64 I/O functions with traces 128 scanned/calibration data .fi .ft R .RE .PP .TP .PP .RS .ft CR .nf .PP .PP .SH "SEE ALSO" sane(7), sane\-net(5), saned(8) .SH "AUTHOR" St\['e]phane Voltz .SH "CREDITS" Support for the Prima PagePartner has been made possible thank to an hardware donation by S\['e]bastien Lange. .SH "BUG REPORTS" If something doesn't work mail sane-devel@alioth-lists.debian.net or submit an issue via https://gitlab.com/sane-project/backends/issues/new with a label of backend/p5. Please give as much information as you can. .TP .I SANE version run "scanimage \-V" to determine this .TP .I the backend version and your scanner hardware run "SANE_DEBUG_P5=255 scanimage \-L 2>log" as root. If you don't get any output from the p5 backend, make sure a line "p5" is included into your @CONFIGDIR@/dll.conf. If your scanner isn't detected, make sure you've defined the right port address, or the correct device in your p5.conf. .TP .I the name of your scanner/vendor also a worthy information. Please also include the optical resolution and lamp type of your scanner, both can be found in the manual of your scanner. .TP .I any further comments if you have comments about the documentation (what could be done better), or you think I should know something, please include it. sane-backends-1.0.29/doc/sane.png0000666000000000000000000002500113615534521013400 00000000000000‰PNG  IHDRZuOé…`PLTE¤'t{< êËÑ“}‚üôöüþü3 ôôôôÂÌÌ»¿¼,wBN‡"T¬£¥°,dâàà\G, ïëìœ$9-/lÍÍÍÊ3“$«8ÚÝ IDATxÚí]‹–Úº’å)Ë1F€áÿÿrê%©$›îäÎÜ™¹kwNNBÔÕÅöV½eVõ_\+øÏ¾ þÕÁeåÿn¿ññß\ü~¿[øï=À¢¾_?U]Ÿ¶›ÍkºÞÎc3îv‡ûp¿\ž°ØÂº®’Ån½~|àûíæõêڸؼءT×Ðâ~Áß…’_Ãí×-nޤúº ¬½šóù_ÜSt†«i‡Úö¤Ætö ùzH,¾\š£¾ïã›ÞžÁŸSSŸ®½’ ‹/—‹Gè|åI´ÅëõO rƒ‹ÏÃØìpñtY5´ø]OÇ÷ñxê5¾½Ïéä`q ‹Ïg'‹½_Yƒ‹} kA ‹'|êêíëåAðùì+\ oЮ.´øèjXÛw(ØàÚÔ€ÅtàÆ©&•°ø8 pëÂfpñ¶ܺ=Ü’±«éíùËŠ÷ý±÷ëu× Ïþ´Ýn&Æ ï*ÔÀàÅõWãáÍz¼jþ _kèôB÷ĺ¿`¨} áÈFà\‹ÿoè·ÚøLœ{âMéð[á¦<àÞ '䜽ÝΦFbt4nWÄ‹a‚oÀµk 3þÞáæŠd65Þ뮆·'kßõ¶E˜?¨ q¹;ǵuZÛ×GXûîp|àN5¸ö6$¹¶Åµ-v5R¨·ÀÍS[[ó!&ǵöbšph™ö®õpC>Thˆ›žßÛ¡½\ b6°Ç8ÌÄ»kˆ½Ýœ¬íº‹©`í»E®†\;Õvóò/$Û`ˆ?]mÌjZÕ@ßæˆÄlÖëõ󃋻ٴ Âml‘kwX[¾°®i–kb-2ÍYÞÏç3€s µmXÛ£AyZÔÕãZ#kÇq`-è`ù¾!ÕM¿¾L¸‹>,Ý>-Rx‚½1¢°Y­h-òm¨|U䤯ù5dcÔlˆ¤ÃÉ¿µ°d ß³lŠÞÆó¿Áþ@‘–þîà­lÉæ9Dÿ†@s÷kw?¸½ÀÇËÊ (w/âœÐèýä‡ök r;þIˆÑfƒ‚¿±\ÓÔ€,YC燑ä>[ÞoAϦj•\ðkûx±Â ë‹tut[Y.é‹w ~ú„ö¡û~O`ßG–k{ãY*Rº‰‚Q,p[“¾,÷Àïª rë$¡X.€ûœ Ë}|žþ¤ÏäI*íƒvV,ɽ£¾6wË­'%¹­›‰L€kö(÷ÊÇ‘!è¦=ÉÅ}pìy úH®E3ÙÝ„uãD*¸3.ôÝäžð=Úí¶p ØÛù9´¤ïNÔ½wã3d ׃e* £_d)>´[O¸sv³Ý€`’ ›üÖ Ý™ä,×Ý äZ¶ÕžnXÝ’û:‚Kè¡€&ÀÝpúˆ`¾eˆ­kX[Øh£CƒGêÐ’­¢Üzêžt™i2q3_fòéáuÝÔ8y±ƒ{W¸)üiªÿ­öì?L¬5ï··r5áß\¸øÿîëô'Ž8Äû( ’°™ìÍì_ï^Œ$[ùê´=±1ÛL{±é°ãínÇÛ¸k︉f®’=AflŠÆ/Ûó>fK†&ý$¦×xÙm¸SDê}tÓ]|E“Loç›VÄ6¹XŽ·Á§œ‚E練µE±ÁôÂv&„Vg• ¯kšw…ʺY3Á 7AYPw¸fb¤-XDÔ–Äzå&Øœ±Û4AÙ‡ø ´}uƒ¡ÍFbÉ_¢¶hi1>E±U xJÚšvèE*lãà~6Éýà&lÇ‘MBå1ŠÌ@ çƒðBT…>¸k­H ÷¬jAî‹ävÃ@¤mm}7‹ðº#k ÷ËÙàÔNtÏNƒßlÅ«]Ûá¦@؉X;NÓÈb}æÒüûèD¬’Æ7pr¾ ÜÌp¾E±&üùÒµ‹­’;€Iw¼Ð¥‰÷9Ñ=;uÓÄ‚º6iKæñà@êüÃÐ’XŸûöA<;¸v¦zJ| âEtí›+ùJãÃv;6îA*Š­¶ qÛ‚¯”½ô§Ö=Öì*éžÀšï1UDmoÏÉŽa—‘K; TLÍ¥‹`‘\pÏÚÝ3Ø ®!¿N{Áù‘ Æázà%VQ,ê׆hó7¢nÜ·yÇŽànÉù0² ¶Älcë´¶îÆwGþêÇ}Ï!) E‡†®7ƒk$º`ÝÄ¢Ð;Û„gkW‹A`ŽGÖöèÆàñˆœ0BC±Æ·¯, `sD,¬jWϽðÖa8J¡KEu™ƒMg,à=Û ­m½`‚Ûí-;_Ú¼“q²Ë`_a˜4±ÌþxxcChƒ÷Œ ‚Ä6+€‰öê–ñ6ŸÞ‰¶o@ª¶g¹ý謘.ãƒT¼gåNbñ ÓJhÃÚ¢Ô öHQE6—V"›G7|Bd÷LLms 6–·‹%©Z, 4‘PÜ]ï`¹†S ÷Œ÷-»1^BÄ­„a(–ã%{$51‹ ©' o×h¹®­‹b[ ¸:ŽÃF —€4‡xË|Çbå–1¦ôÓz:ûËur6ˆÝ8L­QFtíet­„a"–ß{?µ õütg+‹–ˇ qcš`»(ºG¬„ žÄÂþÛ++ö6ÄlҊδM]¥Ø­iÓ%ìL£8Ì Â Ó†oc{‹Ië@Õ”YtZ^®P‚á 7®‹/úlqÔü‡…vÿñ­Ç ÏÿÉ·ùòª~ùw¿ôê [ÐôŒÑ¤&ÇQ¾É¾mß³—( wå4¤âãæÜİ­k‡ÆïM ZVJˆ)8C@ —™Ø`”ê„kš|ÔÖªBì‹a0¹¶òwé07–@•ìÒ–$u-íL*EH•ÂA7øŽueϘ@Õí(ÞØ‘È›@Ũ-䧸OSi}3´™¶ÏR[ÛGt|]Q\¸šVÔM9lÛº++ O­-+.m»;黢ä4ik‹ûŽ2šI‡fO3ädòoÒ5êûù<2ü½‘¢”\œ1;?)e“¶@…X¥¡¸ ̘ 7 °¬­_ÖöÿRûö‹¶{ 4W ”¶þÑQÝ~»ú¾ä¹”zÚ¤­ðö žæ€ÚÖ¨¯@ Lè[ïÞ³Ë!¼‘G­­·=Ø\7™02 §íÉðaÚn£¶°Á@]ËÀrF±wj“A”ŸœxœïL`x\¼€-†ÿ`6 #TŲ™™4Y†DÒ•Õ‚ºZÛÝ.1BŽû˜Þ¸Ÿ°<{ùE[†·(BEm°ì†\ŒW7iŸÙ¡iš=ï± í£xÐÏ·¶¶a‹î[kŸï3³ Õ²º/8o¦”¶d àÇì>^'#fO-ØR›Ó–LíÓMC{.°Å]´=$l-¦NƵƒÓ6Tz/ë‹Â`·Ó~ß;Ô`ô-ÙZÎ39fOû ì-ÀÏê†-FÑõJÖ\¢-¥­¢­hKº<(ƒKÅ;äö*ó ¸Ûœk‡ÜÐÂ?pF,àræß”ûêz«° n Õí Þfö‹´e]1uBc¡Óà•çõí7x©í iØ+ÀÏÞEZ Û“#_ ø’ÙP«mIݲڂ!"¶ «Ô“˜³¨¦t_o.3Je¡î#±–ªœ2Ô±ü‚êšbÄðú@Qw¡íAr&Øeç#Ì´•h¨ Ã‘Æl¥v” %¯àZÜg YδžòÖ,{2¸1¾+ˆ€ìß½òeŠ´÷»x×q©nA[÷ž(Št8ò%ÿïÝÀßPÙËKû‰4 m… Vü¨;œ6¯„«/4» Û]¾Çî'8“°µSÓTI[0¯ˆ l(•5fµÑ¾2¼öºÆª[Üa§xÉ>³âİ`=ˆcÐÁâ“Õí´¶Áë$Nh kk!9u.Øv½¬Ã˨¾c߀ÕUîvýØ­žO3ÓVÀµ!žéà‡ì3ÖÞ‚5ðíh2m#´Á;T¾5«ÎØÞho=fÓÁ{¼¬ç›TpI «X°~à›-šx½:zÏVœØÃÄf¯ˆ ~a†{4Œ™¶÷\[ÚK¶Í£ÁôíȬúö.¿‚Þ®Óõx ?ûDÚ† Gbg7„7–”½F]±j€¯sÒj3\sm-W(°z›´•Îì‚wz‡Â$ïý¾_šSÙ`ÿµŸ`¼p ÄÒ’º· YÌïÏÉ•èè ÓÚebƒVA[…mÜþâc‡6+(±·½Ž1B,â•3pÚ’›”_Û¾½ê¸–K2]0ÎÁpq¾bœ°Z-k›n>*š)*ºÆ~Wg(è †€î?ú³ŽTÕú2Õ²Õz£8®`i‚²‘ ¤íÞR_ï²ÀnÆ…b6ª Ê"G[&Ášp%K€à*Êòõ¢ˆ$f7פîù¬Ô=³ºÄÛƒäcÜЃ_Èë([­¾hKÖê(öÊ[QuE;duôCÍeØQVNàÕ†Z¢›äqÉ©Å6f„—’¶»€+cg-¶[.KL¨[Ñ2QìËdºóxÁ•ÃÈfïº.ÝÄ1¸yZ5{µÉ¢DdàµÁtÏgZv€•i[;øHá5¹žÆtÝsÜÅò%¾”âÛ¡¥þgàBC臩m]Û‚O–îÞÔºü‚F3”/ã«5 $Y¥±a]À~|[ˆ†©X;ù,Ãÿ*ô¾uóÿ¦ðU5¤XóŸ_µûGÛ›¶D÷Õ¿Tý­ Z-¼\ý™°Em½µ­$b±wZøMñ*ëÊ++™ÎÿÙíAF;{-¬6Á ‰°RÛ4Eý6ÔÁ®ÌÊ·“_*1ê"c«—ØäÚbÙ®•È1Ï ¤~;Ž:Ù¹·S‹·âÎhé*›²rLg‹Ä7¤:_´Å±4§jv–=Û)èŠn ety±¹“Ð}ÌË÷;ø£1ÕšÉSL± w6jFÅŸ¢¢3¹¤­.?Nz‰®X Kä‡1¹É2ˆñÉaM-ÎÄ™© ÚrùvE¡T›UrŽuXJÏ~ÒV*ùB®¹Â¨Ê·í)TÆyEâÜát#mÏR“À0h£Œî°i†áµÝÛ²j_$ë—R[ÿŽÚ†¡´LÛ=ñ (à ¸‰ ¥¶atµõ¤®ªäGm󢲩ʹpï mëVcËíP]lö¦ì:¸Wš« ³_A[]EÞR`4™Ä[¬1JÎÛrO•ñ9êTXLÈ×ìO©ñµÅ<÷zUayÔvœk‹÷—ÛÒ%l÷n©ï  M—n®mf äÚv­Ïú§SQÉÇ |Ÿ%¾ ÛX]‚ï“è ¶zpk^Çw˼õq›õºŸwI+óX±:iX¹ÁÜ®3ÞîJ› ¬òmmnä­]*„ryI[ëßÈ6 Ö–Ó4]Þ>§¬Úû[²`#¿AšzŠV½CØIÝÄ[»T÷ªëPhÛƒßj\ìí…ä'ïé46n2™žÂ®>Vš“²vª§E 혴ýÆ„TçŠX¡-ÜQŸê6’?Š­8¤ŽNJ(ɈEæ& ê·»ÛºB.wÙb×|-ï´#jëu—Ä´ƒíóÔç³IÛŒš]m®í+”ñ7±¬ ìínLµñCÒ–[f—Ì‚}©áWq§il±Î>‹Ñâ¦mfqzkCL9÷}qjÉ&Äڸƶ¶ÃľȄÚ}ë耓0%h9ß™oÈ·™=5MCbStIà}ÒH{æyw±….çÔh/®2m¿5 |Í>M3¡bm[ïÊvÙG·t¦Ákp7±£Cý²sîËÒ&“Ò],Z·—U ù0kª?öŸ¨¹µÝ·4(Ôz—mQßs¼vûi'—Ì­¢m0bÔhl“¶‡¨­ÅQVˆ±IÌ\±µYVTH]µÝ©<ÞwÒ‹¯Ë%çäÍìöä\êî©¢ î³XdZÆ6jKÊ^pc‚º*bÞïŸvÚ±SÚJɶ٬ùjœq‡$'wHüþ¼¤m*‰’¶+{¡:oËí¿ô"‘ºÍÔ™¨­ç8CºwŸ¼nÜfiþ—z‘YÛTÆ\®8—Lˆ]Ô”½s/’Ê<ºVó½·GÑ…‹iŒ%†å\Þf݃J[4±ôì—j˜‘‡8Ï|Yªæ³¶ˆ,E`O²ü~ðUÔ¶­Øñ-K㈥ÂÞú„¥òDÑ7«P Ï&uN¯Üa³¸Ë‚+m…IŠ }±Ñ;‘×´]Ë6‹ tÕçM­H×ï3]o¤-y*Œ&mSHÃgH’²«H/¡S×´zþ'†XºÍ°ÕÝ2Ö–§®(†>oÆíÉX[K¹+5l «Ó„ºe町Ò}lï…žYÌVÔ|â,L'P¸H½²s‰í!ô È‚Åñª•DUeia§ñð°.„10´òæ¡»ýeãt#]é×kÖè•6o™é¤ŽÿÓÍ„â$Ÿì´v¦+þÞ;=S³fm{×îí£T7l3f†zOš’6 ›K¤­3_ykßTfÒêcgZS—›PkŒ¾ÐÕIâ‘Ú{²Í¬$$Á‘øKu#ÉCÌ´Uý=0ÔãÅ’˜`3mAl5ßi¡‹£«gÖÔ¼R¤BlJ³¶ ܬÎàžÇ§¶`A[‰)R”ÀPZQá0Ä`®%K5eоCW*Zý,aXçAˆ[Em·›µÐ3"¸Wn¡çÚÆèö~AþƒOÅ;xû\ÑHBŒ ¿*ë '.dº‡Gì²Vol¡Kº êx:sðЏæÝYk{нÞPO9ÅÁþ©‹U;,R÷˜HÀàÆù„½SÃÊé&p¯R‡ Á¹_=œ 9Ï'tFi«h{‘zÂà åí uÑË£q®z.û¶»4Ž%1‡{dKhÃ6³±HC“@ÚzqÚ0b1vòÞJÚ†ø¶Au;îöv™¶Gž¦ªý^m/iúûœ½š³Ä¡ nJæÚ[Oȵ Ó¡¾5JÛ¬éì6ª+­éÎdU»°õ‘ºVnQ"fÇÄš¶S»€ì'ßfjÈŽ¯wð0…Ð ßfV4p¹Ds‹ô.ö2¬ª3”M ÞMh£?Ó.ã[ÿ&ÃJ%nþõìÇÇjØ1P¿¿ ¤cqô#ÒL˜Þe4ûàFütJ–ikíEiÛ$&ˆK \èÙÀ‰ltŸM­QÐøY$®Ý¨dÚ^u•ùLÓù\M Å“MØ#²—¶ÊÐNã9•„í¢l`nfXU5©U²’x3”C@qÐŽf?2ï`»Ø.Ó}í ×<ôhÅz}颶ª.S@^4È·QØ4§Òf&!«QØÞ3la‡¥+çí1« A*äBBs…s5ZYžY*U0cHc5³'F«Ãp,Î,Ñl NÙwÆZ¤‚hûI{Œó›ÊÆÄ<”Äqf鬯4&¬Äëb—Œ,US5™¶l˜afQ´Å3gBUíàm¶/x@V?¿@åjϯã4µÈB4œó€µEs §€2&DŽ¢Þ¯Ù8_µ¹tl¿Rô-¥û–Z7ù„á²á³.×…‘¥1ÎWíB|ë|”wƒ] &„]¦uå‰%¸axõJ§N¬‹ñw1K´§lÐŽæÁàÕ8r‚CàîgÓ`;)ÚrŒ"pÛ]²q0-kšFé2qýY=;LÌ|ŸBÚ‡T’¨sµå' l1OÙ §cä!^g1i"‹ãKŸÆÁBTÓºË\ÛpÞ¡œCêB°ö:_èÀ" BáÐV>ù…lö®{޳W›M c‹icÓšn|>óÉ1²a ŠÅE<'ÖuÝSbÞËáÂÓw„ 4“çiðJTphq„¬38»Æ­¶pÆ2^raþ*Äô&ˆÇa&@"ƹ øþéZj¬ˆbÑÈfÅ<¥Ñôššp› Ÿ-¤‰@eRss>ç6,ÏÅVÃl­šýŠ ë¶t˜´QGÜÊiü7YV¼ϧ&yðÚ\ÀWÉuS¨DkUe‰g}è·êdªá«®ÿ;Ã{þî¦×þ¹þöÿZÿ@ÿÃÐVñK–žÞÖ^½ôåúƒ©RûëµÿÁÎÿÁ·ƒª•Høm]þƒþ@0|ÃÞþ «/ï 81NÛ›÷/ºÆ= 51S¦·îS…=dtô@ÏehŠL·Ù‰üM/1, ’yÉTÎÒ !ürZ]+³'Ô«Õqx©uaˆßÐÉA—Kq­ø ®$uµ€ë CŒ!T²¿@KñÔOÑÀÞ¦¬”`Ø&h?$Åÿ ­ÂvÇÍ^ñ¼ h¨ØBØF|ÏüÅèò ‰*ƒV°Í6 Èð&²½xï Ú€maU»Ð9ý<)†½ûZ^õo+>YòÒEÖ~( _¼C{Wæª<µU¬%lñ`5œsl Ø0¤LËš*A›x»ËÎê ´˜M¶íÐ^„"°­—}¿ÏÏ'%:˜FüíS+û#m×é+@óèf€åF8ÆÝw ¤U’¥ÂÀû½‹ÐÞæ´'ø­ïæÐîôlÚáÎߨš£-B!;9`Ƭi0KúZJ‹ýŽì­]÷º%®ç7ÚVí³âÛelCã›ô…]f‚¹½ÎÅ(B»ÄÚQÆsh¬bÐilW9´„Uy&cqNåÉÐÖ”®þ­1?³6LãDÆê–@°[VnALãí'+°dÐ[K…m² ŒmakÏ9´ÑÖ†iÚ0uúK‚¬@ )ðT€­C[²ödÉŒ:> éòWâ ´õdm2µTjïBe†í€Øn3hÕIŠíKfÍõ‹ Ð6‘µÉ„)‰ Za­Çƒ­XµIHnL U¬Ý[û‹‹Bp1cú.Cëë_-¹±uŸõà´/Ú$‹r[õ8«-B‚öJØúÁvÚÖFh!úÚ¬ÓøŒµ÷d!ޤ$`—¡µ¿EVor $÷›;ûmµ›£Uöâ¹WéÜõG[Á¶mîÄæCû Øž–½ØÜÖª vfèñŠú„4ï“Akr[ë‡öÝ“® MÛ›\tcnÙ Àž0xd´ªã9æu i3ƒ ýbYªfß–Ö`+.L÷7¶ m2¶¥­-⃃š@É M†ýY$h•­õÖ½¿à›&ú®jÑ}…¶d{y dÌØq-B¯ÜÒâÐö€Fè‘  ¨6µß"„ÝÌ (cÀOÒÊY[¿3*'v™„úÏ ÅÑqÇÄEK^X…o¬EkƒOaÀoõàÈÖóTì&ùyÒ˜Ù—0B0sR„mž/$h [Ø+ûv´%kw³„¡ˆ½r[Ëýlrm—"„÷^!T»9´mý~ ¾ É£)'Ja¬Ëð@?;Dz°Kñ×>aÛç–6Ë‚A lakfNì<–!'í,>ˆÁWaêhûšTž™C[ý1´)Æ%wæÒP惤åAxàÈ"äáq#3KÁúŽ:L`«ã® Úðp‘kJ2ÒŽ Zm¾@+Øæ÷ØáImÄ.AkæÙØc‰KÆ&b{L‰Èi¶Ç[~´`¿hi[)$T… “Agˆ‡©ì§LrU¾ á­É¯ÖάA‘0ÌY Àâ9Âë ÎŒßX»p&öWâVÜ %â¿oC)ñ´HÛ<:ø‰¶Ÿãï#¡×j7)ðJ§TbêUñkVžÉLBŒî )ƒör¡†3v¥Cð5ƒ¶Ù›÷ßw‰ ¸3t[®!`à& ù}Ú·6µœ´2_ºY0.í‰Ë¬`álm$lSx« m‚6cmIÛ%hs`ñà 1?‹•/_œÃþ[Ö¸ ±3„nÁÖ&Ò&h]nh×…û|qd–ŸÈæüþ¢ãc qÌ[cû#´e=Q{± ÚJ3– ) Ï•1aG¯tGlhßGÜÉ‹U âv õZÊB‘–-è°·ëõO†6Û2’³|ˆ=¼oçN,3´\>x†ÔA»±EƒPĵêq«ÊÖ6øŒ™,@+uÁ†Àu±Í=—ÆÿXŽýBÜŠ¿Ü™1sû¸O¤]Ú8LøÈ‘ýdО>§íÜ‘´[å-±-¯n(ÌPêþ¯M”ýÂÚx|8=¾ãb¯-3öžA+.ÁE_°ÐÀáøÏ±=RËŒ‰KÏájÅFh8Þ Ú×´l[ ëÆ3ÜsGÆÐ2o'Æ6»™#›Z7!¼m5i—êµóúAm€U¥Ú,ætéš®ÊL篈{äÌ·’o¥*Á¤] m÷4û˜™ƒtþ GVåÐÊl¬ðÖv‹!m í-†·sh«ehóþÂãZ“€ § ÚŘsÞ,ÿ^é$ƒ PIDATŽ]>'›â°z>-æmªÏR¹KL>æxÌâ®t²‡>ï¤Ì+ZßÞFl²sÒ⩵[øÚ-Ô’AÈYË'Û4°ªTû-¿_ñðÃbÉpéÌ)ž.H%›ÅºLÞÚæõïÏC{0þ:]»¢"nmjä2¶à÷?º0³àÄäÜZLÆí²­Ý-C+á®{ÿ %«Ðþ¬òAï¯eª@Z¡,¦`1´Ua×'»´3Ú*h·Raê`g–v-€›RyNéÜ ,C›N… ­5cÙÌ]]¾üR¢[eàþdŽé‹Oðô)󥸴ÜS¬›%°sG¡Å WÆ€,$d¯ùüÁ3¥ekëhÚiÖâÌp7‡ö[ nÛ&[Ù|oÝ)©MØò©Ó%â¦lA5Ãt”n+”Á@»)šïZ.yq5±-ë´ËS31ux-„ØË=ÈÜŒ:Iž … ÀU2’ÿZL=ºøêg«›ÎK»Ù\†vÝ/öoç•ÄOùØä"#h7R˜áÜB0·™U¼2&ÅÎWÛQ—gf¬7ÅäÜ&´òdöYðemí¾@‹ç·CÀr¬òIóí1?þF\$­†µ_/B;»"¼×g–‘Eh%½M©Ã܇]Ë™:Ñ,]&íb½6›GºkhÈŸEèæ¶“´çŠFð«huÁc…dqs«ŽœÑQ®‚¸–Ú` Ûþk…vfh?m«/ÐØ~÷a!Ã}†Ôá ´s#¯”AB@àš1Ƶ-9<ª;µÓTfˆÝ1¨JëöX˜ìz8!‡ØjâÂÏZÏÁb8ÓÛì ­@›hkm6>b?¦9´·k1| ØÆ®Wê–âÚÃî‹=¸çs^J´µ8/ÇÌf\9N§)}åv{íQ}ø@–¡}h£ ¤PÕÜÜnDZúÇã‘Yæ«ÂöEgÒ¤fœéPØJêPÔÔs#T1QÒ2ÂVC©¸6ZÚÝ‚¥½ëÊW(TƒG[]$ÿå£ð«®›ÕkuOW¥¯Ô6 Ówöà„^q~uÉïì­]&ìúLñJñ—v`§âð÷iY›“ö•°ì)e¸75AGȦ‚×-…·<4¬k_œØ!gm¥ÂÿÉ™'>i†cû‹õÚíQ7nÃÌÔG‘ªü,ú#>c+äý˜-ýÅðüü'ˆø!¥™=•àfŽÌZÝÄ}ñ'$l³‚×ui8‘>0‚±Ýc •f—­—³…™Óñ?…¨ðFä£0V«¥†6&Yï, lßÕ>6~ Ed¥¸KœÅ@«Þ[óÉãÙ‚±³øK BÑY©ƒÕõïåáDú,Ávpm:pˆaÉ…Å£Îôù ݆tÝéc¤±Ä¨¡=†øŠ~iw†1nþ•j`,C+,Ãw½ÎçbÄ%Ù¾-c®Ó]mZ5x@èv]Hâ®b`&–i1„Ò…ºÈÚCzÌræÃY+ãÞùÉò¥Ž®ÓÑ=‹$¶d®V=“$ãk:ß{¿¤ŸUˆ¡A¨ˆ÷,°v›gdÖ³´rv*ݾٷó¸kÚ‘ÃÛtS³¶¬Ì¨“ÎK#ÔoXý1´µâ—".²ÂöuÆYÞ§Í[‹° -F‚n)–- hkmÁÙ—š§ðv–‡•–vä§1˜²ä‘„]jÛ¤ú—y³\BÙK†í7ƒ%Y®j# qûðhÍXýa:n»ì±³¸`eÃ5ªÌ,B ñ—òŒ à2§LçBÛ¬$SŒ& kñ°\1v® =ìf‰ØE%ºñÛ*¶ùý¯ÐjObÝF oÖžKòÏ–V¥±ÈÙO°²1X´²ñ‚TuaT†Ê]1u0:.,@;Îú£ÖÎ'fÔ3è\HÎÚh 2sðÍ Ä˜5˶’UÀ¶¤I¨³§(Pæµb̬j‡3°ELæ¾Á"œ¾…áÄÂ)i оæ}Á–‡À#í8žËv1A{PðÚ&P¶K~‡vvõ¡60Ä®¸íËÀöêÉO”-¬¿–¹Ò §fÃ<ˠŨˆ´MÐ*ÎJ6†·]Ѧ/¬`›—‚»]Q;8(\ ÖRZ{)¬ìϡȱÄcSWÂqŽ+ÿ:Ë´ƒUÏ1Ë-Æå`/ú=©Ã Ñ‘Y»48Ç™B oO‹Ö Gv†­°6 i³È+A[‘ûÕ´rm·mŸÇÉ®êƒ qf#õ_Y mš£Ïa‰í†ƒ´½ýFÙ­p{5O±÷ ЦBbJËtÔu[°áQ.úhfí}xiƒ€GmÕ„ýå  ¦²fk˜Cª5i”pí·«0¡cS¿6?Y£ÛÚv§¯œ ‡l¶ajÅÚWÁYݱItÝ}ŸÆ³C•ÖæGruí ‡Ý—>‚wYdmikS4•E¬bZ;‰Ãb[f ,ó&¶ ò^ÂçÙ7ïµMçÄé´EØ¥û ¡£CCàK,±gžºa ÐU™0×q‘',3´Xâê~BV¦ ¨f¹€W*vZ+'ÅwÁoÊ?k°·^ð«ÙIó»Úÿe]·phŸŠüd®á—ü‘þDì"hé‘]êÁ`Ô«l²ñ›ôä°/?Q¢á’篋qmÅS–F©h¢f]\ˆÏÝú3¡N ÿýÉ·Èçg¶îw±U1=ƒq8nøõâawšuD|yà‘”ã7øï?^ü¤1Të{°VFÐaéú…Ç“Š ´*”þí`Gø_äNCÙÑÍ{–.Ÿý¯É>S±ª«oOá©ê¦ÂÏ=m¾\Ň¢òß¿¯L?µZZå“‚Z…¹ÐŠ~5¹Èe5*õ+ûŽïoªÉuøç9_ÿ¶ë¿œßAÉÝÅ_IEND®B`‚sane-backends-1.0.29/doc/sane-nec.man0000666000000000000000000000274113615534521014140 00000000000000.TH sane\-nec 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-nec .SH NAME sane\-nec \- SANE backend for NEC scanners .SH DESCRIPTION The .B sane\-nec library implements a SANE (Scanner Access Now Easy) backend that provides access to NEC SCSI scanners. This backend should be considered .B alpha-quality software! In the current state it is known to work with PC-IN500/4C scanners. Another MultiReader scanner series is not supported. PC-IN 500/4C and MultiReader scanner are only sold in Japan.(except Multi Reader PetiScan.) For other scanners, it may or may not work. .PP The backend has the following known problems: .RS \- ColorLineart mode is not supported. .br \- device name is fixed to /dev/scanner .RE .PP At present, the following scanners are known to work with this backend. .RS .ft CR .nf Vendor Product id ------ ----------- NEC PC-IN500/4C .fi .ft R .RE .SH FILES .TP .I @CONFIGDIR@/nec.conf The backend configuration file. .TP .I @LIBDIR@/libsane\-nec.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-nec.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_NEC If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHORS Kazuya Fukuda sane-backends-1.0.29/doc/sane-pieusb.man0000666000000000000000000000616013615534521014661 00000000000000.TH sane\-pieusb 5 "10 Aug 2015" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-pieusb .SH NAME sane\-pieusb \- SANE backend for USB-connected PIE PowerSlide and Reflecta DigitDia/CrystalScan/ProScan slide scanners .SH DESCRIPTION The .B sane\-pieusb library implements a SANE (Scanner Access Now Easy) backend that provides access to USB-connected PIE and Reflecta slide scanners. .br At present, the following scanners should work with this backend: .PP .ft CR .nf Model: Status ------------------------- ------ PIE PowerSlide 3600 Untested PIE PowerSlide 3650 Untested PIE PowerSlide 4000 Untested PIE PowerSlide 5000 Untested Reflecta CrystalScan 7200 Untested Reflecta ProScan 4000 Untested Reflecta ProScan 7200 Untested Reflecta DigitDia 3600 Untested Reflecta DigitDia 4000 Untested Reflecta DigitDia 5000 Untested Reflecta DigitDia 6000 Ok .fi .ft R .PP .SH "MULTIPLE SLIDES" Support for multiple slide scanners (like the PowerSlide or DigitDia series) is done by auto-advancing ('Advance slide' setting) the slide after each scan. However, for best results, it is recommended to do a preview for every slide since this sets gamma, brightness, and contrast to optimal values. Attention: SANE does not have an automatic landscape/portrait detection and re-orientation when scanning multiple slides. You have to put all slides into one orientation first ! .SH "DIRT REMOVAL" If available, pieusb supports infrared scans for dirt detection and removal. This must be enabled via the 'Clean image' setting. .SH "KNOWN PROBLEMS" The pieusb backend supports dirt removal based on infrared scan information. Since SANE does not provide post-processing in the backend, pieusb does the scanning and dirt removal during the setup phase. The 'scan' phase is only used to transfer the completed image. Therefore pieusb does not multi-thread making a typical frontend appear as 'blocked'. Also cancel requests are only honored between scans. .SH "ENVIRONMENT" .TP .B SANE_DEBUG_PIEUSB If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .PP .RS .ft CR .nf level debug output \-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- 0 nothing 1 errors 2 warnings & minor errors 5 additional information 7 SANE api calls 9 backend functions 11 scanner functions 13 usb functions 15 image buffer functions .fi .ft R .RE .PP .SH FILES .TP .I @CONFIGDIR@/pieusb.conf The backend configuration file .TP .I @LIBDIR@/libsane\-pieusb.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-pieusb.so The shared library implementing this backend (present on systems that support dynamic loading). .PP .SH SEE ALSO sane(7) .SH "CONTACT AND BUG-REPORTS" Please send any information and bug-reports to: .br .B Klaus Kämpf .SH AUTHORS The pieusb backend is based on work by Jan Vleeshouwers, Michael Rickmann, and Klaus Kämpf sane-backends-1.0.29/doc/sane-umax_pp.man0000666000000000000000000002057513615534521015051 00000000000000.TH "sane\-umax_pp" "5" "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-umax_pp .SH "NAME" sane\-umax_pp \- SANE backend for Umax Astra parallel port flatbed scanners .SH "DESCRIPTION" The .B sane\-umax_pp library implements a SANE (Scanner Access Now Easy) backend that provides access to Umax parallel port flatbed scanners. The following scanners work with this backend: .PP .RS Model: .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br Astra 610P .br Astra 1220P .br HP3200C .br Astra 1600P .br Astra 2000P .br Genius ColorPage-Life Pro .br .RE .PP This backend handles 75x75, 150x150, 300x300, 600x600 and 600x1200 for 1220P/1600P/2000P dpi scan resolutions, and 75x75, 150x150, 300x300 and 300x600 for 610P. In color and gray levels, there is a software lineart mode. .PP The new generation models share a newer version of the 610P ASIC embedded in an EPAT chip. Only parts such as CCD and ADC change from one to another. They even all reports being UMAX Astra 1220P via IEEE1284. There isn't software way to recognize them properly. Under windows, model is set by the driver installed, regardless of the hardware. .PP .TP .B EPP/ECP MODES ONLY The current version of the backend uses only EPP or ECP mode to communicate with the scanner. PS/2 mode isn't implemented. The 610P only use SPP. It is recommended that you set your parallel port to EPP in BIOS with the current version of this backend. You can leave it to ECP or ECP+EPP, but in this case you may not use ppdev but only direct hardware access if you have to use ECP. ECPEPP will only work if you use a 2.4 or 2.6 kernel with ppdev character device support. .PP This backend does support parport sharing only .I if you have a kernel with ppdev support. .I .PP Note that if you don't use the ppdev character device, the backend needs to run as root. To allow user access to the scanner run the backend through the network interface (See saned(8) and sane\-net(5)). A more relaxed solution (security wise) is to add suid bit to the frontend (See chmod(1)). The backend drop root privileges as soon as it can, right after gaining direct access to IO ports, which lessen risks when being root. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I port value .RE .PP Where \fBvalue\fR is : .RS .TP auto autodetect all parallel ports and probe them for scanner .TP safe\-auto autodetect all parallel ports and probe them for scanner, but does not try direct hardware access .TP /dev/ppi0 uses *BSD ppi device, depending on the number of available parallel port, you have to use /dev/ppi1, /dev/ppi2, ... .TP /dev/parport0 uses linux ppdev device, depending on the number of available parallel port, you have to use /dev/parport1, /dev/parport2, ... .TP 0x378 does direct hardware access on the given address. Usual values are 0x378, 0x278, 0x3BC In this case, you have to run the scanner as root (*BSD and linux), or with 'IOPL=yes' on OS/2 .PP .RE \fBNOTE:\fR in all cases, you must have sufficient privileges to get access to the chosen device or address. Depending on the security settings, devices may not be available for all users. You have to change permissions on the dev/ppi* or /dev/parport* devices. .PP .RE You can rename any device using the .PP .RS .I name devname .br .I model model .br .I vendor vendor .RE .PP options. These options apply to the last port option. .SH "CONFIGURATION" Please make sure to edit umax_pp.conf .B before you use the backend. .PP The contents of the .B umax_pp.conf file is a list of options and device names that correspond to Umax scanners. Empty lines and lines starting with a hash mark (#) are ignored. .PP The eight options supported are .BR red\-gain , .BR green\-gain , .BR blue\-gain , .BR red\-offset , .BR green\-offset , .BR blue\-offset , .BR astra , and .BR buffer . Options .B red\-gain , .B green\-gain and .B blue\-gain allow you to adjust the sensitivity of your scanner for the given color. Values range from 0 (lowest gain) to 15 (highest). If the advanced option "Gain" isn't checked in the frontend, the backend does automatic gain calibration, and do not use user provided values. .PP Options .B red\-offset , .B green\-offset and .B blue\-offset allow you to adjust the offset of your scanner for the given color. Values range from 0 (lowest offset) to 15 (highest). .PP Option .B astra allows you to change the model of your scanner. Current auto detection is based on side effects on scanning when using 1220P command set on other models, so it may fail on unknown hardware combination. Valid values are 610, 1220, 1600 and 2000. It is useful only when autodetection fails to detect properly your scanner model. If your scanner work properly but is reported wrongly, let it be that way. The only valid case to change the model is when your scanner produces "black" or "inverted" scans. In this case you can put the model. Be aware that it will prevent scanner model autodetection. .PP Option .B buffer allows you to change the size of the scan buffer. The size must be specified in bytes. The default value is 2 megabytes. Decreasing this value will improve the smoothness of progress bar in the frontend, but will stall the scan more often. .PP .SH "FILES" .TP .I @CONFIGDIR@/umax_pp.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-umax_pp.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-umax_pp.so The shared library implementing this backend (present on systems that support dynamic loading). .SH "ENVIRONMENT" .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_UMAX_PP If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .PP .RS .ft CR .nf level debug output \-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- 0 nothing 1 errors 2 warnings & minor errors 3 additional information 4 debug information 5 code flow (not supported yet) 6 special debug information .fi .ft R .RE .PP .TP .B SANE_DEBUG_UMAX_PP_LOW This variable sets the debug level for the SANE interface for the Umax ASIC. Note that enabling this will spam your terminal with some million lines of debug output. .PP .RS .ft CR .nf level debug output \-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- 0 nothing 1 errors 8 command blocks 16 detailed code flow 32 dump datafiles 255 everything .fi .ft R .RE .PP .PP .SH "SEE ALSO" sane(7), sane\-net(5), saned(8) .TP For latest bug fixes and information see .I http://umax1220p.sourceforge.net/ .SH "AUTHOR" St\['e]phane Voltz .SH "CREDITS" Support for the 610P has been made possible thank to an hardware donation by William Stuart. .SH "BUG REPORTS" If something doesn't work, please contact me. But I need some information about your scanner to be able to help you... .TP .I SANE version run "scanimage \-V" to determine this .TP .I the backend version and your scanner hardware run "SANE_DEBUG_UMAX_PP=255 scanimage \-L 2>log" as root. If you don't get any output from the umax_pp backend, make sure a line "umax_pp" is included into your @CONFIGDIR@/dll.conf. If your scanner isn't detected, make sure you've defined the right port address, or the correct device in your umax_pp.conf. .TP .I the name of your scanner/vendor also a worthy information. Please also include the optical resolution and lamp type of your scanner, both can be found in the manual of your scanner. .TP .I any further comments if you have comments about the documentation (what could be done better), or you think I should know something, please include it. sane-backends-1.0.29/doc/sane-kodak.man0000666000000000000000000001077413615534521014471 00000000000000.TH sane\-kodak 5 "10 Feb 2010" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-kodak .SH NAME sane\-kodak \- SANE backend for big Kodak flatbed and ADF scanners .SH DESCRIPTION The .B sane\-kodak library implements a SANE (Scanner Access Now Easy) backend which provides access to large Kodak flatbed and ADF scanners. This document describes backend version 7, which shipped with SANE 1.0.21. .SH SUPPORTED HARDWARE This version should support models which speak the Kodak SCSI and Firewire protocols. The i1860 was used to develop the backend, but other models may work with only minimal modifications. Please see the list at http://www.sane\-project.org/sane\-supported\-devices.html for an updated list. If you have a machine not on that list, or reported as 'untested': the best way to determine level of support is to test the scanner directly, or to collect a trace of the windows driver in action. Please contact the author for help or with test results. .SH UNSUPPORTED HARDWARE Most of the recent Kodak consumer or workgroup level machines are based on other chipsets and are not supported by this backend. Some of these scanners may be supported by another backend. .SH OPTIONS Effort has been made to expose the basic hardware options, including: .PP source s .RS Selects the source for the scan. Options may include "Flatbed", "ADF Front", "ADF Back", "ADF Duplex". .RE .PP mode m .RS Selects the mode for the scan. Options may include "Lineart", "Halftone", "Gray", and "Color". .RE .PP resolution .RS Controls scan resolution. Available choices may be limited by mode. .RE .PP tl\-x, tl\-y, br\-x, br\-y .RS Sets scan area upper left and lower right coordinates. These are renamed t, l, x, y by some frontends. .RE .PP page\-width, page\-height .RS Sets paper size. Used by scanner to determine centering of scan coordinates when using ADF and to detect double feed errors. .RE .PP Other options will be available based on the capabilities of the scanner. Use 'scanimage \-\-help' to get a list, but be aware that some options may be settable only when another option has been set, and that advanced options may be hidden by some frontend programs. .PP .SH CONFIGURATION FILE The configuration file "kodak.conf" is used to tell the backend how to look for scanners, and provide options controlling the operation of the backend. This file is read each time the frontend asks the backend for a list of scanners, generally only when the frontend starts. If the configuration file is missing, the backend will use a set of compiled defaults, which are identical to the default configuration file shipped with SANE. .PP Scanners can be specified in the configuration file in 2 ways: .PP "scsi KODAK" .RS Requests backend to search all scsi busses in the system for a device which reports itself to be a scanner made by 'KODAK'. .RE .PP "scsi /dev/sg0" (or other scsi device file) .RS Requests backend to open the named scsi device. Only useful if you have multiple compatible scanners connected to your system, and need to specify one. Probably should not be used with the other "scsi" line above. .RE .PP The only configuration option supported is "buffer\-size=xxx", allowing you to set the number of bytes in the data buffer to something other than the compiled\-in default, 32768 (32K). Some users report that their scanner will "hang" mid\-page, or fail to transmit the image if the buffer is not large enough. .PP Note: This option may appear multiple times in the configuration file. It only applies to scanners discovered by 'scsi/usb' lines that follow this option. .PP Note: The backend does not place an upper bound on this value, as some users required it to be quite large. Values above the default are not recommended, and may crash your OS or lockup your scsi card driver. You have been warned. .PP .SH ENVIRONMENT The backend uses a single environment variable, SANE_DEBUG_KODAK, which enables debugging output to stderr. Valid values are: .PP .RS 5 Errors .br 10 Function trace .br 15 Function detail .br 20 Option commands .br 25 SCSI trace .br 30 SCSI detail .br 35 Useless noise .RE .SH KNOWN ISSUES Most hardware options are either not supported or not exposed for control by the user, including: multifeed detection, image compression, autocropping, endorser, iThresholding, multi\-stream, etc. .PP .SH CREDITS The various authors of the sane\-fujitsu backend provided useful code. .br Kodak provided access to hardware, documentation and personnel. .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHOR m. allan noah: sane-backends-1.0.29/doc/sane-usb.man0000666000000000000000000001364213615534521014166 00000000000000.TH sane\-usb 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-usb .SH NAME sane\-usb \- USB configuration tips for SANE .SH DESCRIPTION This manual page contains information on how to access scanners with a USB interface. It focusses on two main topics: getting the scanner detected by the operating system kernel and using it with SANE. .PP This page applies to USB most backends and scanners, as they use the generic sanei_usb interface. However, there is one exceptions: USB Scanners supported by the microtek2 backend need a special USB kernel driver, see .BR sane\-microtek2 (5) for details. .SH "QUICK START" This is a short HOWTO-like section. For the full details, read the following sections. The goal of this section is to get the scanner detected by .BR sane\-find\-scanner (1). .PP Run sane\-find\-scanner. If it lists your scanner with the correct vendor and product ids, you are done. See section .B "SANE ISSUES" for details on how to go on. .PP sane\-find\-scanner doesn't list your scanner? Does it work as root? If yes, there is a permission issue. See the .B LIBUSB section for details. .PP Nothing is found even as root? Check that your kernel supports USB and that libusb is installed (see section .BR LIBUSB ). .SH "USB ACCESS METHODS" For accessing USB devices, the USB library libusb is used. There used to exist another method to access USB devices: the kernel scanner driver. The kernel scanner driver method is deprecated and shouldn't be used anymore. It may be removed from SANE at any time. In Linux, the kernel scanner driver has been removed in the 2.6.* kernel series. Only libusb access is documented in this manual page. .SH LIBUSB SANE can only use libusb 0.1.6 or newer. It needs to be installed at build-time. Modern Linux distributions and other operating systems come with libusb. .PP Libusb can only access your scanner if it's not claimed by the kernel scanner driver. If you want to use libusb, unload the kernel driver (e.g. rmmod scanner under Linux) or disable the driver when compiling a new kernel. For Linux, your kernel needs support for the USB filesystem (usbfs). For kernels older than 2.4.19, replace "usbfs" with "usbdevfs" because the name has changed. This filesystem must be mounted. That's done automatically at boot time, if /etc/fstab contains a line like this: .PP .RS none /proc/bus/usb usbfs defaults 0 0 .RE .PP The permissions for the device files used by libusb must be adjusted for user access. Otherwise only root can use SANE devices. For .IR Linux , the devices are located in /proc/bus/usb/ or in /dev/bus/usb, if you use udev. There are directories named e.g. "001" (the bus name) containing files "001", "002" etc. (the device files). The right device files can be found out by running scanimage \-L as root. Setting permissions with "chmod" is not permanent, however. They will be reset after reboot or replugging the scanner. .PP Usually udev or for older distributions the hotplug utilities are used, which support dynamic setting of access permissions. SANE comes with udev and hotplug scripts in the directory tools/udev and tools/hotplug. They can be used for setting permissions, see @DOCDIR@/README.linux, tools/README and the README in the tools/hotplug directory for more details. .PP For the .BR BSDs , the device files used by libusb are named .IR /dev/ugen* . Use chmod to apply appropriate permissions. .SH "SANE ISSUES" .PP This section assumes that your scanner is detected by sane\-find\-scanner. It doesn't make sense to go on, if this is not the case. While sane\-find\-scanner is able to detect any USB scanner, actual scanning will only work if the scanner is supported by a SANE backend. Information on the level of support can be found on the SANE webpage .RI ( http://www.sane\-project.org/ ), and the individual backend manpages. .PP Most backends can detect USB scanners automatically using "usb" configuration file lines. This method allows one to identify scanners by the USB vendor and product numbers. The syntax for specifying a scanner this way is: .PP .RS usb .I VENDOR PRODUCT .RE .PP where .I VENDOR is the USB vendor id, and .I PRODUCT is the USB product id of the scanner. Both ids are non-negative integer numbers in decimal or hexadecimal format. The correct values for these fields can be found by running sane\-find\-scanner, looking into the syslog (e.g., /var/log/messages) or under Linux by issuing the command "cat /proc/bus/usb/devices". This is an example of a config file line: .PP .RS usb 0x055f 0x0006 .RE .PP would have the effect that all USB devices in the system with a vendor id of 0x55f and a product id of 0x0006 would be probed and recognized by the backend. .PP If your scanner is not detected automatically, it may be necessary to edit the appropriate backend configuration file before using SANE for the first time. For a detailed description of each backend's configuration file, please refer to the relevant backend manual page (e.g. .BR sane\-mustek_usb (5) for Mustek USB scanners). .PP Do .B not create a symlink from .I /dev/scanner to the USB device because this link is used by the SCSI backends. The scanner may be confused if it receives SCSI commands. .SH ENVIRONMENT .TP .B SANE_DEBUG_SANEI_USB If the library was compiled with debug support enabled, this environment variable controls the debug level for the USB I/O subsystem. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. Values greater than 4 enable libusb debugging (if available). Example: export SANE_DEBUG_SANEI_USB=4. .PP .TP .B SANE_USB_WORKAROUND If your scanner does not work when plugged into a USB3 port, try setting the environment variable SANE_USB_WORKAROUND to 1. This may work around issues which happen with particular kernel versions. Example: export SANE_USB_WORKAROUND=1. .SH "SEE ALSO" .BR sane (7), .BR sane\-find\-scanner (1), .BR sane\-"backendname" (5), .BR sane\-scsi (5) .SH AUTHOR Henning Meier-Geinitz sane-backends-1.0.29/doc/sane-hpsj5s.man0000666000000000000000000000664113615534521014612 00000000000000.TH sane\-hpsj5s 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-hpsj5s .SH NAME sane\-hpsj5s \- SANE backend for HP ScanJet 5S sheet-fed scanner .SH DESCRIPTION The .B sane\-hpsj5s library implements a SANE (Scanner Access Now Easy) backend that provides access to a parallel port Hewlett-Packard ScanJet 5S scanner. .PP IMPORTANT: this is alpha code. Don't expect this to work correctly. Many functions are missing, others contain errors. In some cases, your computer might even hang. It cannot be excluded (although I consider it extremely improbable) that your scanner will be damaged. .PP LIMITATIONS: For now this backend works only on Linux. This limitation is due to dependence on the libieee1284 library. If your system supports libieee1284 too, this backend should work. If you ported libieee1284 for your platform, please let me know. Your system should support .B EPP (or .B EPP+ECP ) mode to operate this scanner. Future versions will support ECP and SPP (Nibble and Byte) modes also. It's planned to support scanners not only at daisy-chain position 0, but anywhere. Support for multiple scanners could be implemented too. .PP Current version implements only gray scale scanning. True Color and B/W modes are not supported for now. .PP That said, TESTERS ARE WELCOME. Send your bug reports and comments to Max Vorobiev . .PP .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the parallel port name in form, libieee1284 expects. It seems to be system dependent. Under Linux it's parport0, parport1, etc. .SH CONFIGURATION The contents of the .I hpsj5s.conf file is a list of parport names that correspond to HP ScanJet 5S scanners. Empty lines and lines starting with a hash mark (#) are ignored. Only one device name can be listed in .IR hpsj5s.conf for this moment. Future versions will support daisy chain selection. .SH TIPS .PP It seems that HP ScanJet 5S scanner uses software noise correction. This feature is not implemented for now. So does gamma correction and calibration. I'll handle it in future versions. Native resolution for this scanner is 300 DPI. Other modes could be jagged in some ways. .PP .SH FILES .TP .I @CONFIGDIR@/hpsj5s.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-hpsj5s.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-hpsj5s.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .SH "SEE ALSO" sane(7) .br http://hpsj5s.sourceforge.net .br http://cyberelk.net/tim/libieee1284 .br .SH AUTHOR Max Vorobiev .br Man page mostly based on canon.man sane-backends-1.0.29/doc/sane-dc25.man0000666000000000000000000000671413615534521014134 00000000000000.TH sane\-dc25 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-dc25 .SH NAME sane\-dc25 \- SANE backend for Kodak DC20/DC25 Digital Cameras .SH DESCRIPTION The .B sane\-dc25 library implements a SANE (Scanner Access Now Easy) backend that provides access to Kodak DC20 and DC25 cameras. At present, only the DC25 has been tested, but since the code is based on a DC20 interface program, it is likely to work for that model also. .SH "DEVICE NAMES" The current version of the backend only allows one camera to be connected. The device name is always "0". .SH CONFIGURATION The contents of the .I dc25.conf specify the serial port and baud rate to use. The baud rate specifies the maximum rate to use while downloading pictures. (The camera is always initialized using 9600 baud, then switches to the higher rate). On my 90MHz Pentium, I usually have no problems downloading at 115200 baud as long as the system is not excessively busy and the "interrupt-unmask flag" is set in the IDE driver (hdparm \-u1). Supported baud rates are: 9600, 19200, 38400, 57600, and 115200. .PP The dumpinquiry line causes some information about the camera to be printed to stderr during startup. Note: This is not compatible with saned, so make sure you don't have any dumpinquiry lines if you are using saned (i.e. scanning on a remote machine using a network). .PP Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS port=/dev/ttyS0 .br # this is a comment .br baud=115200 .br dumpinquiry .RE .PP .SH FILES .TP .I @CONFIGDIR@/dc25.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-dc25.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-dc25.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_DC25 If the library was compiled with debugging support enabled, this environment variable controls the debug level for this backend. A value of 128 requests maximally copious debug output; smaller levels reduce verbosity. .SH "SEE ALSO" sane(7) .SH AUTHOR Peter Fales, dc25\-devel@fales\-lorenz.net .SH BUGS Known bugs/limitations are: .PP I haven't figured out how to trigger an option reload following a "scan." This causes problems when a new picture is snapped for example, the slider that is used to select the picture from the camera may not be updated immediately. .PP More general comments, suggestions, and inquiries about frontends or SANE should go to the SANE Developers mailing list (see http://www.sane\-project.org/mailing\-lists.html for details). You must be subscribed to the list, otherwise your mail won't be sent to the subscribers. sane-backends-1.0.29/doc/sane-mustek_usb2.man0000666000000000000000000000510113615534521015627 00000000000000.TH sane\-mustek_usb2 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-mustek_usb2 .SH NAME sane\-mustek_usb2 \- SANE backend for SQ113 based USB flatbed scanners .SH DESCRIPTION The .B sane\-mustek_usb2 library implements a SANE (Scanner Access Now Easy) backend that provides access to USB flatbed scanners based on the Service & Quality SQ113 chipset. At the moment, only the Mustek BearPaw 2448 TA Pro is supported. It's planned to add support for other scanners that are based on the SQ113 and maybe SQ11 chip. For more details, see the mustek_usb2 backend homepage: .IR http://www.meier\-geinitz.de/sane/mustek_usb2\-backend/ . .PP This is BETA software. Especially if you test new or untested scanners, keep your hand at the scanner's plug and unplug it, if the head bumps at the end of the scan area. .PP If you own a scanner other than the ones listed on the mustek_usb2 homepage that works with this backend, please let me know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .I sane\-find\-scanner or syslog) to me. Even if the scanner's name is only slightly different from the models already listed as supported, please let me know. .PP .SH LIBUSB ISSUES Please use libusb-0.1.8 or later. Without libusb or with older libusb versions all kinds of trouble can be expected. The scanner should be found by sane\-find\-scanner without further actions. For setting permissions and general USB information looks at .BR sane\-usb (5). .PP .SH FILES .TP .I @LIBDIR@/libsane\-mustek_usb2.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-mustek_usb2.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_MUSTEK_USB2 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_MUSTEK_USB2=4 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .BR sane\-plustek (5), .BR sane\-ma1509 (5), .BR sane\-mustek_usb (5), .BR sane\-mustek (5), .BR sane\-mustek_pp (5) .br .I @DOCDIR@/mustek_usb2/mustek_usb2.CHANGES .br .I http://www.meier\-geinitz.de/sane/mustek_usb2\-backend/ .SH AUTHOR The driver has been written Roy Zhou, Jack Xu, and Vinci Cen from Mustek. Adjustments to SANE by Henning Meier-Geinitz. .SH BUGS Please contact me if you find a bug or missing feature: . Please send a debug log if your scanner isn't detected correctly (see SANE_DEBUG_MUSTEK_USB2 above). sane-backends-1.0.29/doc/sane-find-scanner.man0000666000000000000000000001001213615534521015730 00000000000000.TH sane\-find\-scanner 1 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-find\-scanner .SH NAME sane\-find\-scanner \- find SCSI and USB scanners and their device files .SH SYNOPSIS .B sane\-find\-scanner .RB [ \-? | \-h | \-\-help ] .RB [ \-v ] .RB [ \-q ] .RB [ \-p ] .RB [ \-f ] .RB [ \-F .IR filename ] .RI [ devname ] .SH DESCRIPTION .B sane\-find\-scanner is a command-line tool to find SCSI and USB scanners and determine their Unix device files. Its primary aim is to make sure that scanners can be detected by SANE backends. .PP For .B SCSI scanners, it checks the default generic SCSI device files (e.g., .IR /dev/sg0 ) and .IR /dev/scanner . The test is done by sending a SCSI inquiry command and looking for a device type of "scanner" or "processor" (some old HP scanners seem to send "processor"). So .B sane\-find\-scanner will find any SCSI scanner connected to those default device files even if it isn't supported by any SANE backend. .PP For .B USB scanners, first the USB kernel scanner device files (e.g. .IR /dev/usb/scanner0 ), .IR /dev/usb/scanner , and .IR /dev/usbscanner ) are tested. The files are opened and the vendor and device ids are determined, if the operating system supports this feature. Currently USB scanners are only found this way if they are supported by the Linux scanner module or the FreeBSD or OpenBSD uscanner driver. After that test, .B sane\-find\-scanner tries to scan for USB devices found by the USB library libusb (if available). There is no special USB class for scanners, so the heuristics used to distinguish scanners from other USB devices is not perfect. .B sane\-find\-scanner also tries to find out the type of USB chip used in the scanner. If detected, it will be printed after the vendor and product ids. .B sane\-find\-scanner will even find USB scanners, that are not supported by any SANE backend. .PP .B sane\-find\-scanner won't find most parallel port scanners, or scanners connected to proprietary ports. Some .B parallel port scanners may be detected by .B sane\-find\-scanner -p. At the time of writing this will only detect Mustek parallel port scanners. .SH OPTIONS .TP 8 .B \-?, \-h, \-\-help Prints a short usage message. .TP 8 .B \-v Verbose output. If used once, .B sane\-find\-scanner shows every device name and the test result. If used twice, SCSI inquiry information and the USB device descriptors are also printed. .TP 8 .B \-q Be quiet. Print only the devices, no comments. .TP 8 .B \-p Probe parallel port scanners. .TP 8 .B \-f Force opening all explicitly given devices as SCSI and USB devices. That's useful if .B sane\-find\-scanner is wrong in determining the device type. .TP 8 .B \-F filename filename is a file that contains USB descriptors in the format of /proc/bus/usb/devices as used by Linux. .B sane\-find\-scanner tries to identify the chipset(s) of all USB scanners found in such a file. This option is useful for developers when the output of "cat /proc/bus/usb/devices" is available but the scanner itself isn't. .TP 8 .B devname Test device file "devname". No other devices are checked if devname is given. .SH EXAMPLE .B sane\-find\-scanner \-v .br Check all SCSI and USB devices for available scanners and print a line for every device file. .PP .B sane\-find\-scanner /dev/scanner .br Look for a (SCSI) scanner only at /dev/scanner and print the result. .PP .B sane\-find\-scanner \-p .br Probe for parallel port scanners. .SH "SEE ALSO" .BR sane (7), .BR sane\-scsi (5), .BR sane\-usb (5), .BR scanimage (1), .BR xscanimage (1), .BR xsane (1), .BR sane\-"backendname" (5) .SH AUTHOR Oliver Rauch, Henning Meier-Geinitz and others .SH SUPPORTED PLATFORMS USB support is limited to Linux (kernel, libusb), FreeBSD (kernel, libusb), NetBSD (libusb), OpenBSD (kernel, libusb). Detecting the vendor and device ids only works with Linux or libusb. .PP SCSI support is available on Irix, EMX, Linux, Next, AIX, Solaris, FreeBSD, NetBSD, OpenBSD, and HP-UX. .SH BUGS No support for most parallel port scanners yet. .br Detection of USB chipsets is limited to a few chipsets. sane-backends-1.0.29/doc/sane-dc240.man0000666000000000000000000000741713615534521014214 00000000000000.TH sane\-dc240 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-dc240 .SH NAME sane\-dc240 \- SANE backend for Kodak DC240 Digital Camera .SH DESCRIPTION The .B sane\-dc240 library implements a SANE (Scanner Access Now Easy) backend that provides access to the Kodak DC240 camera. THIS IS EXTREMELY ALPHA CODE! USE AT YOUR OWN RISK!! .SH "DEVICE NAMES" The current version of the backend only allows one camera to be connected. The device name is always "0". .SH CONFIGURATION The contents of the .I dc240.conf specify the serial port and baud rate to use. The baud rate specifies the maximum rate to use while downloading pictures. (The camera is always initialized using 9600 baud, then switches to the higher rate). On a 450MHz Pentium, I usually have no problems downloading at 115200 baud, though the camera sometimes has to resend packets due to lost characters. Results are better when the "interrupt-unmask flag" is set in the IDE driver (hdparm \-u1). Supported baud rates are: 9600, 19200, 38400, 57600, and 115200. .PP The dumpinquiry line causes some information about the camera to be printed. .PP cmdrespause specifies how many usec (1,000,000ths of a) between writing the command and reading the result should be used. 125000 seems to be the lowest I could go reliably. .PP breakpause is the time in 1,000,000ths of a usec between sending the "back to default" break sending commands. .PP Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS port=/dev/ttyS0 .br # this is a comment .br baud=115200 .br dumpinquiry .br cmdrespause=125000 .br breakpause=1000000 .RE .PP .SH FILES .TP .I @CONFIGDIR@/dc240.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-dc240.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-dc240.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_DC240 If the library was compiled with debugging support enabled, this environment variable controls the debug level for this backend. A value of 128 requests maximally copious debug output; smaller levels reduce verbosity. .SH "SEE ALSO" sane(7) .SH AUTHOR Peter S. Fales .PP This backend borrows heavily from the dc210 backend by Brian J. Murrell which is based somewhat on the dc25 backend by Peter Fales. .PP The manpage was largely copied from the dc210 manpage. .SH BUGS The major limitation that I know of is that the backend assumes the directory in the camera is 100dc240. Once the camera has taken more than 9999 pictures, the directory will increment to 101dc240. Not only should we check for the additional directory, but pictures may actually be found in multiple directories. .PP More general comments, suggestions, and inquiries about frontends or SANE should go to the SANE Developers mailing list (see http://www.sane\-project.org/mailing\-lists.html for details). You must be subscribed to the list, otherwise your mail won't be sent to the subscribers. sane-backends-1.0.29/doc/sane-tamarack.man0000666000000000000000000000434013615534521015153 00000000000000.TH sane\-tamarack 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-tamarack .SH NAME sane\-tamarack \- SANE backend for Tamarack flatbed scanners .SH DESCRIPTION The .B sane\-tamarack library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Tamarack flatbed scanners: .PP .RS Artiscan 6000C .br Artiscan 8000C .br Artiscan 12000C .br .RE .PP .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the path-name for the special device that corresponds to a SCSI scanner. The special device name must be a generic SCSI device or a symlink to such a device. The program .IR sane\-find\-scanner helps to find out the correct device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. See sane\-scsi(5) for details. .SH FILES .TP .I @CONFIGDIR@/tamarack.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-tamarack.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-tamarack.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_TAMARACK If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_TAMARACK=4 .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHOR Roger Wolff sane-backends-1.0.29/doc/sane.tex0000666000000000000000000023051713615534521013426 00000000000000\documentclass[11pt]{report} \usepackage{times,graphicx,url} % Not Currently using changebar package so comment out to reduce % external dependencies. %\usepackage{changebar} \setlength{\parindent}{0pt} \setlength{\parskip}{1.5ex plus 0.5ex minus 0.5ex} \setlength{\textwidth}{6.5in} \setlength{\textheight}{8.5in} \setlength{\marginparwidth}{0pt} \setlength{\oddsidemargin}{0pt} \setlength{\evensidemargin}{0pt} \setlength{\marginparsep}{0pt} \addtolength{\topmargin}{-0.75in} \title{\huge SANE Standard Version 1.06} \author{} \date{2008-05-03} \makeindex \begin{document} \newcommand{\filename}[1]{{\tt #1}} \newcommand{\code}[1]{{\tt #1}} \newcommand{\var}[1]{{\it #1}} \newcommand{\defn}[1]{#1\index{#1}} % Uncomment if adding changebars to text %\begin{latexonly} % \setcounter{changebargrey}{0} % black change bars %\end{latexonly} \maketitle \tableofcontents \listoffigures \listoftables \chapter{Preface} The SANE standard is being developed by a group of free-software developers. The process is open to the public and comments as well as suggestions for improvements are welcome. Information on how to join the SANE development process can be found in Chapter \ref{chap:contact}. The SANE standard is intended to streamline software development by providing a standard application programming interface to access raster scanner hardware. This should reduce the number of different driver implementations, thereby reducing the need for reimplementing similar code. \section{About This Document} This document is intended for developers who are creating either an application that requires access to raster scanner hardware and for developers who are implementing a SANE driver. It does not cover specific implementations of SANE components. Its sole purpose is to describe and define the SANE application interface that will enable any application on any platform to interoperate with any SANE backend for that platform. The remainder of this document is organized as follows. Chapter~\ref{chap:intro} provides introductional material. Chapter~\ref{chap:environ} presents the environment SANE is designed for. Chapter~\ref{chap:api} details the SANE Application Programmer Interface. Chapter~\ref{chap:net} specifies the network protocol that can be used to implement the SANE API in a network transparent fashion. Finally, Chapter~\ref{chap:contact} gives information on how to join the SANE development process. \subsection{Typographic Conventions} Changes since the last revision of this document are highlighted like this: % \begin{changebar} % Paragraphs that changed since the last revision of the documention % are marked like this paragraph. % \end{changebar} \chapter{Introduction}\label{chap:intro} SANE is an application programming interface (API) that provides standardized access to any raster image scanner hardware. The standardized interface allows to write just one driver for each scanner device instead of one driver for each scanner and application. The reduction in the number of required drivers provides significant savings in development time. More importantly, SANE raises the level at which applications can work. As such, it will enable applications that were previously unheard of in the UNIX world. While SANE is primarily targeted at a UNIX environment, the standard has been carefully designed to make it possible to implement the API on virtually any hardware or operating system. SANE is an acronym for ``Scanner Access Now Easy.'' Also, the hope is that SANE is sane in the sense that it will allow easy implementation of the API while accommodating all features required by today's scanner hardware and applications. Specifically, SANE should be broad enough to accommodate devices such as scanners, digital still and video cameras, as well as virtual devices like image file filters. \section{Terminology} An application that uses the SANE interface is called a SANE {\em frontend}. A driver that implements the SANE interface is called a SANE {\em backend}. A {\em meta backend\/} provides some means to manage one or more other backends. \chapter{The SANE Environment}\label{chap:environ} SANE is defined as a C-callable library interface. Accessing a raster scanner device typically consists of two phases: first, various controls of the scanner need to be setup or queried. In the second phase, one or more images are acquired. Since the device controls are widely different from device to device, SANE provides a generic interface that makes it easy for a frontend to give a user access to all controls without having to understand each and every device control. The design principle used here is to abstract each device control into a SANE {\em option\/}. An option is a self-describing name/value pair. For example, the brightness control of a camera might be represented by an option called \code{brightness} whose value is an integer in the range from 0 to 255. With self-describing options, a backend need not be concerned with {\em presentation\/} issues: the backend simply provides a list of options that describe all the controls available in the device. Similarly, there are benefits to the frontend: it need not be concerned with the {\em meaning\/} of each option. It simply provides means to present and alter the options defined by the backend. \section{Attaching to a SANE backend} The process through which a SANE frontend connects to a backend is platform dependent. Several possibilities exist: \begin{itemize} \item {\bf Static linking:} A SANE backend may be linked directly into a frontend. While the simplest method of attaching to a backend, it is somewhat limited in functionality since the available devices is limited to the ones for which support has been linked in when the frontend was built. But even so static linking can be quite useful, particularly when combined with a backend that can access scanners via a network. Also, it is possible to support multiple backends simultaneously by implementing a meta backend that manages several backends that have been compiled in such a manner that they export unique function names. For example, a backend called \code{be} would normally export a function called \code{sane\_read()}. If each backend would provide such a function, static linking would fail due to multiple conflicting definitions of the same symbol. This can be resolved by having backend \code{be} include a header file that has lines of the form: \begin{quote} \begin{verbatim} #define sane_read be_sane_read \end{verbatim} \end{quote} With definitions of this kind, backend \code{be} will export function name \code{be\_sane\_read()}. Thus, all backends will export unique names. As long as a meta backend knows about these names, it is possible to combine several backends at link time and select and use them dynamically at runtime. \item {\bf Dynamic linking:} A simpler yet more powerful way to support multiple backends is to exploit dynamic linking on platforms that support it. In this case, a frontend is linked against a shared library that implements any SANE backend. Since each dynamically linked backend exports the same set of global symbols (all starting with the prefix \code{sane\_}), the dynamic library that gets loaded at runtime does not necessarily have to be the same one as one the frontend got linked against. In other words, it is possible to switch the backend by installing the appropriate backend dynamic library. More importantly, dynamic linking makes it easy to implement a meta backend that loads other backends {\em on demand}. This is a powerful mechanism since it allows adding new backends merely by installing a shared library and updating a configuration file. \item {\bf Network connection:} Arguably the ultimate way to attach to a scanner is by using the network to connect to a backend on a remote machine. This makes it possible to scan images from any host in the universe, as long as there is a network connection to that host and provided the user is permitted to access that scanner. \end{itemize} \begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[width=\textwidth]{figs/hierarchy} \caption{Example SANE Hiearchy} \label{fig:hierarchy} \end{center} \end{figure} The above discussion lists just a few ways for frontends to attach to a backend. It is of course possible to combine these solutions to provide an entire hierarchy of SANE backends. Such a hierarchy is depicted in Figure~\ref{fig:hierarchy}. The figure shows that machine A uses a dynamic-linking based meta backend called \code{dll} to access the backends called \code{pnm}, \code{mustek}, and \code{net}. The first two are real backends, whereas the last one is a meta backend that provides network transparent access to remote scanners. In the figure, machine B provides non-local access to its scanners through the SANE frontend called \code{saned}. The \code{saned} in turn has access to the \code{hp} and \code{autolum} backends through another instance of the \code{dll} backend. The \code{autolum} meta backend is used to automatically adjust the luminance (brightness) of the image data acquired by the camera backend called \code{qcam}. Note that a meta backend really is both a frontend and a backend at the same time. It is a frontend from the viewpoint of the backends that it manages and a backend from the viewpoint of the frontends that access it. The name ``meta backend'' was chosen primarily because the SANE standard describes the interface from the viewpoint of a (real) frontend. \section{Image Data Format}\label{sec:imageformat}\index{image data format} Arguably the most important aspect of an image acquisition system is how images are represented. The SANE approach is to define a simple yet powerful representation that is sufficient for vast majority of applications and devices. While the representation is simple, the interface has been defined carefully to allow extending it in the future without breaking backwards compatibility. Thus, it will be possible to accommodate future applications or devices that were not anticipated at the time this standard was created. A SANE image is a rectangular area. The rectangular area is subdivided into a number of rows and columns. At the intersection of each row and column is a quadratic pixel. A pixel consists of one or more sample values. Each sample value represents one channel (e.g., the red channel). Each sample value has a certain bit depth. The bit depth is fixed for the entire image and can be as small as one bit. Valid bit depths are 1, 8, or 16 bits per sample. If a device's natural bit depth is something else, it is up to the driver to scale the sample values appropriately (e.g., a 4 bit sample could be scaled by a factor of four to represent a sample value of depth 8). \subsection{Image Transmission} The SANE API transmits an image as a sequence of frames. Each frame covers the same rectangular area as the entire image, but may contain only a subset of the channels in the final image. For example, a red/green/blue image could either be transmitted as a single frame that contains the sample values for all three channels or it could be transmitted as a sequence of three frames: the first frame containing the red channel, the second the green channel, and the third the blue channel. Conceptually, each frame is transmitted a byte at a time. Each byte may contain 8 sample values (for an image bit depth of 1), one full sample value (for an image bit depth of 8), or a partial sample value (for an image bit depth of 16 or bigger). In the latter case, the bytes of each sample value are transmitted in the machine's native byte order. For depth 1, the leftmost pixel is stored in the most significant bit, and the rightmost pixel in the least significant bit. \begin{quote} \begin{center} {\bf Backend Implementation Note} \end{center} A network-based meta backend will have to ensure that the byte order in image data is adjusted appropriately if necessary. For example, when the meta backend attaches to the server proxy, the proxy may inform the backend of the server's byte order. The backend can then apply the adjustment if necessary. In essence, this implements a ``receiver-makes-right'' approach. \end{quote} \begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[width=0.5\textwidth]{figs/xfer} \caption{Transfer order of image data bytes} \label{fig:xfer} \end{center} \end{figure} The order in which the sample values in a frame are transmitted is illustrated in Figure~\ref{fig:xfer}. As can be seen, the values are transmitted row by row and each row is transmitted from left-most to right-most column. The left-to-right, top-to-bottom transmission order applies when the image is viewed in its normal orientation (as it would be displayed on a screen, for example). If a frame contains multiple channels, then the channels are transmitted in an interleaved fashion. Figure~\ref{fig:pixels} illustrates this for the case where a frame contains a complete red/green/blue image with a bit-depth of 8. For a bit depth of 1, each byte contains 8 sample values of a {\em single\/} channel. In other words, a bit depth 1 frame is transmitted in a byte interleaved fashion. \begin{figure}[htbp] \begin{center} \leavevmode \includegraphics[width=0.8\textwidth]{figs/image-data} \caption{Bit and byte order or image data} \label{fig:pixels} \end{center} \end{figure} When transmitting an image frame by frame, the frontend needs to know what part of the image a frame represents (and how many frames it should expect). For that purpose, the SANE API tags every frame with a type. This version of the SANE standard supports the following frame types: \begin{quote} \begin{description} \item[\code{\defn{SANE\_FRAME\_GRAY}}:] The frame contains a single channel of data that represents sample values from a spectral band that covers the human visual range. The image consists of this frame only. \item[\code{\defn{SANE\_FRAME\_RGB}}:] The frame contains three channels of data that represent sample values from the red, green, and blue spectral bands. The sample values are interleaved in the order red, green, and blue. The image consists of this frame only. \item[\code{\defn{SANE\_FRAME\_RED}}:] The frame contains one channel of data that represents sample values from the red spectral band. The complete image consists of three frames: \code{SANE\_\-FRA\-ME\_RED}, \code{SANE\_FRAME\_GREEN}, and \code{SANE\_FRAME\_BLUE}. The order in which the frames are transmitted chosen by the backend. \item[\code{\defn{SANE\_FRAME\_GREEN}}:] The frame contains one channel of data that represents sample values from the green spectral band. The complete image consists of three frames: \code{SANE\_\-FRA\-ME\_RED}, \code{SANE\_FRAME\_GREEN}, and \code{SANE\_FRAME\_BLUE}. The order in which the frames are transmitted chosen by the backend. \item[\code{\defn{SANE\_FRAME\_BLUE}}:] The frame contains one channel of data that represents sample values from the blue spectral band. The complete image consists of three frames: \code{SANE\_\-FRA\-ME\_RED}, \code{SANE\_FRAME\_GREEN}, and \code{SANE\_FRAME\_BLUE}. The order in which the frames are transmitted chosen by the backend. \end{description} \end{quote} In frames of type \code{SANE\_FRAME\_GRAY}, when the bit depth is 1 there are only two sample values possible, 1 represents minimum intensity (black) and 0 represents maximum intensity (white). For all other bit depth and frame type combinations, a sample value of 0 represents minimum intensity and larger values represent increasing intensity. The combination of bit depth 1 and \code{SANE\_FRAME\_RGB} (or \code{SANE\_FRAME\_RED}, \code{SANE\_FRAME\_GREEN}, \code{SANE\_FRAME\_BLUE}) is rarely used and may not be supported by every frontend. \chapter{The SANE Application Programmer Interface (API)}\label{chap:api} This Section defines version 1 of the SANE application programmer interface (API). Any SANE frontend must depend on the interface defined in this section only. Converseley, any SANE backend must implement its functionality in accordance with this specification. The interface as documented here is declared as a C callable interface in a file called \filename{sane/sane.h}. This file should normally be included via a C pre-processor directive of the form: \begin{verbatim} #include \end{verbatim} \section{Version Control} The SANE standard is expected to evolve over time. Whenever a change to the SANE standard is made that may render an existing frontend or backend incompatible with the new standard, the major version number must be increased. Thus, any frontend/backend pair is compatible provided the major version number of the SANE standard they implement is the same. A frontend may implement backwards compatiblity by allowing major numbers that are smaller than the expected major number (provided the frontend really can cope with the older version). In contrast, a backend always provides support for one and only one version of the standard. If a specific application does require that two different versions of the same backend are accessible at the same time, it is possible to do so by installing the two versions under different names. SANE version control also includes a minor version number and a build revision. While control of these numbers remains with the implementor of a backend, the recommended use is as follows. The minor version is incremented with each official release of a backend. The build revision is increased with each build of a backend. The SANE API provides the following five macros to manage version numbers. \begin{quote} \begin{description} \item[\code{\defn{SANE\_CURRENT\_MAJOR}}:] The value of this macro is the number of the SANE standard that the interface implements. \item[\code{\defn{SANE\_VERSION\_CODE}(\var{maj},\var{min},\var{bld})}:] \label{sec:saneversioncode} This macro can be used to build a monotonically increasing version code. A SANE version code consists of the SANE standard major version number (\var{maj}), the minor version number \var{min}, and the build revision of a backend (\var{bld}). The major and minor version numbers must be in the range 0\ldots255 and the build revision must be in the range 0\ldots65535. Version codes are monotonic in the sense that it is possible to apply relational operators (e.g., equality or less-than test) directly on the version code rather than individually on the three components of the version code. Note that the major version number alone determines whether a frontend/backend pair is compatible. The minor version and the build revision are used for informational and bug-fixing purposes only. \item[\code{\defn{SANE\_VERSION\_MAJOR}(\var{vc})}:] This macro returns the major version number component of the version code passed in argument \var{vc}. \item[\code{SANE\_VERSION\_MINOR(\var{vc})}:] This macro returns the minor version number component of the version code passed in argument \var{vc}. \item[\code{SANE\_VERSION\_BUILD(\var{vc})}:] This macro returns the build revision component of the version code passed in argument \var{vc}. \end{description} \end{quote} \section{Data Types} \subsection{Base Types} The SANE standard is based on just two SANE-specific base types: the SANE byte and word. \begin{quote} \code{typedef \var{some-scalar-type\/} \defn{SANE\_Byte};} \\ \code{typedef \var{some-scalar-type\/} \defn{SANE\_Word};} \end{quote} \verb|SANE_Byte| must correspond to some scalar C type that is capable of holding values in the range 0 to 255. \verb|SANE_Word| must be capable of holding any of the following: \begin{itemize} \item the truth values \verb|SANE_FALSE| and \verb|SANE_TRUE| \item signed integers in the range $-2^{31}\ldots2^{31}-1$ \item fixed point values in the range $-32768\ldots32767.9999$ with a resolution of $1/65536$ \item 32 bits (for bit sets) \end{itemize} Note that the SANE standard does not define what C type \verb|SANE_Byte| and \verb|SANE_Word| map to. For example, on some platforms, the latter may map to \verb|long int| whereas on others it may map to \verb|int|. A portable SANE frontend or backend must therefore not depend on a particular mapping. \subsection{Boolean Type} \code{\defn{SANE\_Bool}} is used for variables that can take one of the two truth values \code{\defn{SANE\_FALSE}} and \code{\defn{SANE\_TRUE}}. The former value is defined to be 0, whereas the latter is 1.\footnote{This is different from ANSI C where any non-zero integer value represents logical TRUE.} The C declarations for this type are given below. \begin{quote} \begin{verbatim} #define SANE_FALSE 0 #define SANE_TRUE 1 typedef SANE_Word SANE_Bool; \end{verbatim} \end{quote} Note that \verb|SANE_Bool| is simply an alias of \verb|SANE_Word|. It is therefore always legal to use the latter type in place of the former. However, for clarity, it is recommended to use \verb|SANE_Bool| whenever a given variable or formal argument has a fixed interpretation as a boolean object. \subsection{Integer Type} \code{\defn{SANE\_Int}} is used for variables that can take integer values in the range $-2^{32}$ to $2^{31}-1$. Its C declaration is given below. \begin{quote} \begin{verbatim} typedef SANE_Word SANE_Int; \end{verbatim} \end{quote} Note that \verb|SANE_Int| is simply an alias of \verb|SANE_Word|. It is therefore always legal to use the latter type in place of the former. However, for clarity, it is recommended to use \verb|SANE_Int| whenever a given variable or formal argument has a fixed interpretation as an integer object. \subsection{Fixed-point Type} \code{\defn{SANE\_Fixed}} is used for variables that can take fixed point values in the range $-32768$ to $32767.9999$ with a resolution of $1/65535$. The C declarations relating to this type are given below. \begin{quote} \begin{verbatim} #define SANE_FIXED_SCALE_SHIFT 16 typedef SANE_Word SANE_Fixed; \end{verbatim} \end{quote} The macro \code{\defn{SANE\_FIXED\_SCALE\_SHIFT}} gives the location of the fixed binary point. This standard defines that value to be 16, which yields a resolution of $1/65536$. Note that \verb|SANE_Fixed| is simply an alias of \verb|SANE_Word|. It is therefore always legal to use the latter type in place of the former. However, for clarity, it is recommended to use \verb|SANE_Fixed| whenever a given variable or formal argument has a fixed interpretation as a fixed-point object. For convenience, SANE also defines two macros that convert fixed-point values to and from C double floating point values. \begin{quote} \begin{description} \item[\code{\defn{SANE\_FIX}(\var{d})}:] Returns the largest SANE fixed-point value that is smaller than the double value \var{d}. No range checking is performed. If the value of \var{d} is out of range, the result is undefined. \item[\code{\defn{SANE\_UNFIX}(\var{w})}:] Returns the nearest double machine number that corresponds to fixed-point value \var{w}. \end{description} \end{quote} SANE does {\em not\/} require that the following two expressions hold true (even if the values of \var{w} and \var{d} are in range): \begin{quote} \begin{verbatim} SANE_UNFIX(SANE_FIX(d)) == d SANE_FIX(SANE_UNFIX(w)) == w \end{verbatim} \end{quote} In other words, conversion between fixed and double values may be lossy. It is therefore recommended to avoid repeated conversions between the two representations. \subsection{Text} \subsubsection{Character Type} Type \code{\defn{SANE\_Char}} represents a single text character or symbol. At present, this type maps directly to the underlying C \verb|char| type (typically one byte). The encoding for such characters is currently fixed as ISO LATIN-1. Future versions of this standard may map this type to a wider type and allow multi-byte encodings to support internationalization. As a result of this, care should be taken to avoid the assumption that \verb|sizeof(SANE_Char)==sizeof(char)|. \begin{quote} \begin{verbatim} typedef char SANE_Char; \end{verbatim} \end{quote} \subsubsection{String Type} Type \code{\defn{SANE\_String}} represents a text string as a sequence of C \verb|char| values. The end of the sequence is indicated by a \verb|'\0'| (\defn{NUL}) character. \begin{quote} \begin{verbatim} typedef SANE_Char *SANE_String; typedef const SANE_Char *SANE_String_Const; \end{verbatim} \end{quote} The type \code{\defn{SANE\_String\_Const}} is provided by SANE to enable declaring strings whose contents is unchangable. Note that in ANSI C, the declaration \begin{quote} \begin{verbatim} const SANE_String str; \end{verbatim} \end{quote} declares a string pointer that is constant (not a string pointer that points to a constant value). \subsection{Scanner Handle Type} Access to a scanner is provided through an opaque type called \code{\defn{SANE\_Handle}}. The C declaration of this type is given below. \begin{quote} \begin{verbatim} typedef void *SANE_Handle; \end{verbatim} \end{quote} While this type is declared to be a void pointer, an application must not attempt to interpret the value of a \verb|SANE_Handle|. In particular, SANE does not require that a value of this type is a legal pointer value. \subsection{Status Type} Most SANE operations return a value of type \code{\defn{SANE\_Status}} to indicate whether the completion status of the operation. If an operation completes successfully, \verb|SANE_STATUS_GOOD| is returned. In case of an error, a value is returned that indicates the nature of the problem. The complete list of available status codes is listed in Table \ref{tab:status}. It is recommended to use function \code{sane\_strstatus()} to convert status codes into a legible string. \begin{table}[htbp] \begin{center} \begin{tabular}{|l|r|l|} \hline \multicolumn{1}{|c|}{\bf Symbol} & \multicolumn{1}{c|}{\bf Code} & \multicolumn{1}{c|}{\bf Description} \\ \hline\hline \code{\defn{SANE\_STATUS\_GOOD}} & 0 & Operation completed succesfully. \\ \code{\defn{SANE\_STATUS\_UNSUPPORTED}} & 1 & Operation is not supported. \\ \code{\defn{SANE\_STATUS\_CANCELLED}} & 2 & Operation was cancelled. \\ \code{\defn{SANE\_STATUS\_DEVICE\_BUSY}} & 3 & Device is busy---retry later. \\ \code{\defn{SANE\_STATUS\_INVAL}} & 4 & Data or argument is invalid. \\ \code{\defn{SANE\_STATUS\_EOF}} & 5 & No more data available (end-of-file). \\ \code{\defn{SANE\_STATUS\_JAMMED}} & 6 & Document feeder jammed. \\ \code{\defn{SANE\_STATUS\_NO\_DOCS}} & 7 & Document feeder out of documents. \\ \code{\defn{SANE\_STATUS\_COVER\_OPEN}} & 8 & Scanner cover is open. \\ \code{\defn{SANE\_STATUS\_IO\_ERROR}} & 9 & Error during device I/O. \\ \code{\defn{SANE\_STATUS\_NO\_MEM}} & 10 & Out of memory. \\ \code{\defn{SANE\_STATUS\_ACCESS\_DENIED}} & 11 & Access to resource has been denied. \\ \hline \end{tabular} \caption{Status Codes}\label{tab:status} \end{center} \end{table} \subsection{Device Descriptor Type} Each SANE device is represented by a structure of type \code{\defn{SANE\_Device}}. The C declaration of this type is given below. \begin{quote} \begin{verbatim} typedef struct { SANE_String_Const name; SANE_String_Const vendor; SANE_String_Const model; SANE_String_Const type; } SANE_Device; \end{verbatim} \end{quote} \index{device-name} The structure provides the unique name of the scanner in member \code{name}. It is this unique name that should be passed in a call to \code{sane\_open()}. The format of this name is completely up to the backend. The only constraints are that the name is unique among all devices supported by the backend and that the name is a legal SANE text string. To simplify presentation of unique names, their length should not be excessive. It is {\em recommended\/} that backends keep unique names below 32 characters in length. However, applications {\em must\/} be able to cope with arbitrary length unique names. The remaining members in the device structure provide additional information on the device corresponding to the unique name. Specifically, members \code{vendor}, \code{model}, and \code{type} are single-line strings that give information on the vendor (manufacturer), model, and the type of the device. For consistency's sake, the following strings should be used when appropriate (the lists will be expanded as need arises): \begin{table}[htbp] \begin{center} \leavevmode \hspace{\fill} \begin{tabular}[t]{|ll|} \hline \multicolumn{2}{|c|}{\bf \defn{Vendor Strings}} \\ \hline\hline \code{AGFA} & \code{Microtek} \\ \code{Abaton} & \code{Minolta} \\ \code{Acer} & \code{Mitsubishi} \\ \code{Apple} & \code{Mustek} \\ \code{Artec} & \code{NEC} \\ \code{Avision} & \code{Nikon} \\ \code{CANON} & \code{Plustek} \\ \code{Connectix} & \code{Polaroid} \\ \code{Epson} & \code{Relisys} \\ \code{Fujitsu} & \code{Ricoh} \\ \code{Hewlett-Packard} & \code{Sharp} \\ \code{IBM} & \code{Siemens} \\ \code{Kodak} & \code{Tamarack} \\ \code{Lexmark} & \code{UMAX} \\ \code{Logitech} & \code{Noname} \\ \hline \end{tabular} \hspace{\fill} \begin{tabular}[t]{|l|} \hline \multicolumn{1}{|c|}{\bf \defn{Type Strings}} \\ \hline\hline \code{film scanner} \\ \code{flatbed scanner} \\ \code{frame grabber} \\ \code{handheld scanner} \\ \code{multi-function peripheral} \\ \code{sheetfed scanner} \\ \code{still camera} \\ \code{video camera} \\ \code{virtual device} \\ \hline \end{tabular} \hspace{\fill} \caption{Predefined Device Information Strings} \label{tab:devinfo} \end{center} \end{table} Note that vendor string \code{Noname} can be used for virtual devices that have no physical vendor associated. Also, there are no predefined model name strings since those are vendor specific and therefore completely under control of the respective backends. \subsection{Option Descriptor Type}\label{sec:odesc} Option descriptors are at the same time the most intricate and powerful type in the SANE standard. Options are used to control virtually all aspects of device operation. Much of the power of the SANE API stems from the fact that most device controls are completely described by their respective option descriptor. Thus, a frontend can control a scanner abstractly, without requiring knowledge as to what the purpose of any given option is. Conversely, a scanner can describe its controls without requiring knowledge of how the frontend operates. The C declaration of the \code{\defn{SANE\_Option\_Descriptor}} type is given below. \begin{quote} \begin{verbatim} typedef struct { SANE_String_Const name; SANE_String_Const title; SANE_String_Const desc; SANE_Value_Type type; SANE_Unit unit; SANE_Int size; SANE_Int cap; SANE_Constraint_Type constraint_type; union { const SANE_String_Const *string_list; const SANE_Word *word_list; const SANE_Range *range; } constraint; } SANE_Option_Descriptor; \end{verbatim} \end{quote} \subsubsection{Option Name} Member \code{name} is a string that uniquely identifies the option. The name must be unique for a given device (i.e., the option names across different backends or devices need not be unique). The option name must consist of lower-case ASCII letters (\code{a}--\code{z}), digits (\code{0}--\code{9}), or the dash character (\code{-}) only. The first character must be a lower-case ASCII character (i.e., not a digit or a dash). \subsubsection{Option Title} Member \code{title} is a single-line string that can be used by the frontend as a title string. This should typically be a short (one or two-word) string that is chosen based on the function of the option. \subsubsection{Option Description} Member \code{desc} is a (potentially very) long string that can be used as a help text to describe the option. It is the responsibility of the frontend to break the string into managable-length lines. Newline characters in this string should be interpreted as paragraph breaks. \subsubsection{Option Value Type} Member \code{type} specifies the type of the option value. The possible values for type \code{\defn{SANE\_Value\_Type}} are described in Table \ref{tab:valuetype}. \begin{table}[htbp] \begin{center} \leavevmode \begin{tabular}{|l|l|p{0.6\textwidth}|} \hline \multicolumn{1}{|c|}{\bf Symbol} & \multicolumn{1}{c|}{\bf Code} & \multicolumn{1}{c|}{\bf Description} \\ \hline\hline \code{\defn{SANE\_TYPE\_BOOL}} & 0 & Option value is of type \verb|SANE_Bool|. \\ \code{\defn{SANE\_TYPE\_INT}} & 1 & Option value is of type \verb|SANE_Int|. \\ \code{\defn{SANE\_TYPE\_FIXED}}&2 & Option value is of type \verb|SANE_Fixed|. \\ \code{\defn{SANE\_TYPE\_STRING}}&3 & Option value is of type \verb|SANE_String|. \\ \code{\defn{SANE\_TYPE\_BUTTON}} & 4 & An option of this type has no value. Instead, setting an option of this type has an option-specific side-effect. For example, a button-typed option could be used by a backend to provide a means to select default values or to the tell an automatic document feeder to advance to the next sheet of paper. \\ \code{\defn{SANE\_TYPE\_GROUP}} & 5 & An option of this type has no value. This type is used to group logically related options. A group option is in effect up to the point where another group option is encountered (or up to the end of the option list, if there are no other group options). For group options, only members \code{title} and \code{type} are valid in the option descriptor. \\ \hline \end{tabular} \caption{Option Value Types (\code{SANE\_Value\_Type})} \label{tab:valuetype} \end{center} \end{table} \subsubsection{Option Value Unit} Member \code{unit} specifies what the physical unit of the option value is. The possible values for type \code{\defn{SANE\_U\-nit}} are described in Table \ref{tab:units}. Note that the specified unit is what the SANE backend expects. It is entirely up to a frontend as to how these units a presented to the user. For example, SANE expresses all lengths in millimeters. A frontend is generally expected to provide appropriate conversion routines so that a user can express quantities in a customary unit (e.g., inches or centimeters). \begin{table}[htbp] \begin{center} \leavevmode \begin{tabular}{|l|l|l|} \hline \multicolumn{1}{|c|}{\bf Symbol} & \multicolumn{1}{|c|}{\bf Code} & \multicolumn{1}{|c|}{\bf Description} \\ \hline\hline \code{\defn{SANE\_UNIT\_NONE}} & 0 & Value is unit-less (e.g., page count).\\ \code{\defn{SANE\_UNIT\_PIXEL}} & 1 & Value is in number of pixels. \\ \code{\defn{SANE\_UNIT\_BIT}} & 2 & Value is in number of bits. \\ \code{\defn{SANE\_UNIT\_MM}} & 3 & Value is in millimeters. \\ \code{\defn{SANE\_UNIT\_DPI}} & 4 & Value is a resolution in dots/inch. \\ \code{\defn{SANE\_UNIT\_PERCENT}}& 5 & Value is a percentage. \\ \code{\defn{SANE\_UNIT\_MICROSECOND}}& 6 & Value is time in $\mu$-seconds. \\ \hline \end{tabular} \caption{Physical Units (\code{SANE\_Unit})} \label{tab:units} \end{center} \end{table} \subsubsection{Option Value Size}\label{sec:valuesize} Member \code{size} specifies the size of the option value (in bytes). This member has a slightly different interpretation depending on the type of the option value: \begin{quote} \begin{description} \item[\code{SANE\_TYPE\_STRING}:] The size is the maximum size of the string. For the purpose of string size calcuations, the terminating \code{NUL} character is considered to be part of the string. Note that the terminating \code{NUL} character must always be present in string option values. \item[\code{SANE\_TYPE\_INT}, \code{SANE\_TYPE\_FIXED}:] The size must be a positive integer multiple of the size of a \verb|SANE_Word|. The option value is a vector of length \[ \code{size}/\code{sizeof(SANE\_Word)}. \] \item[\code{SANE\_TYPE\_BOOL}:] The size must be set to \code{sizeof(SANE\_Word)}. \item[\code{SANE\_TYPE\_BUTTON}, \code{SANE\_TYPE\_GROUP}:] The option size is ignored. \end{description} \end{quote} \subsubsection{Option Capabilities} Member \code{cap} describes what capabilities the option posseses. This is a bitset that is formed as the inclusive logical OR of the capabilities described in Table \ref{tab:capabilities}. The SANE API provides the following to macros to test certain features of a given capability bitset: \begin{quote} \begin{description} \item[\code{\defn{SANE\_OPTION\_IS\_ACTIVE}(\var{cap})}:] This macro returns \code{SANE\_TRUE} if and only if the option with the capability set \var{cap} is currently active. \item[\code{\defn{SANE\_OPTION\_IS\_SETTABLE}(\var{cap})}:] This macro returns \code{SANE\_TRUE} if and only if the option with the capability set \var{cap} is software settable. \end{description} \end{quote} \begin{table}[htbp] \begin{center} \leavevmode \begin{tabular}{|l|r|p{0.59\textwidth}|} \hline \multicolumn{1}{|c|}{\bf Symbol} & \multicolumn{1}{c|}{\bf Code} & \multicolumn{1}{c|}{\bf Description} \\ \hline\hline \code{\defn{SANE\_CAP\_SOFT\_SELECT}} & 1 & The option value can be set by a call to \code{sane\_con\-trol\_opt\-ion()}.\\ \code{\defn{SANE\_CAP\_HARD\_SELECT}} & 2 & The option value can be set by user-intervention (e.g., by flipping a switch). The user-interface should prompt the user to execute the appropriate action to set such an option. This capability is mutually exclusive with SANE\_CAP\_SOFT\_SELECT (either one of them can be set, but not both simultaneously). \\ \code{\defn{SANE\_CAP\_SOFT\_DETECT}} & 4 & The option value can be detected by software. If \code{SANE\_\-CAP\_\-SO\-FT\_SEL\-ECT} is set, this capability {\em must\/} be set. If \code{SANE\_CAP\_HARD\_SELECT} is set, this capability may or may not be set. If this capability is set but neither \code{SANE\_CAP\_SO\-FT\_SEL\-ECT} nor \code{SANE\_CAP\_HA\-RD\_SEL\-ECT} are, then there is no way to control the option. That is, the option provides read-out of the current value only. \\ \code{\defn{SANE\_CAP\_EMULATED}} & 8 & If set, this capability indicates that an option is not directly supported by the device and is instead emulated in the backend. A sophisticated frontend may elect to use its own (presumably better) emulation in lieu of an emulated option. \\ \code{\defn{SANE\_CAP\_AUTOMATIC}} & 16 & If set, this capability indicates that the backend (or the device) is capable to picking a reasonable option value automatically. For such options, it is possible to select automatic operation by calling \code{sane\_control\_option()} with an action value of \code{SANE\_ACTION\_SET\_AUTO}. \\ \code{\defn{SANE\_CAP\_INACTIVE}} & 32 & If set, this capability indicates that the option is not currently active (e.g., because it's meaningful only if another option is set to some other value). \\ \code{\defn{SANE\_CAP\_ADVANCED}} & 64 & If set, this capability indicates that the option should be considered an ``advanced user option.'' A frontend typically displays such options in a less conspicuous way than regular options (e.g., a command line interface may list such options last or a graphical interface may make them available in a seperate ``advanced settings'' dialog). \\ \hline \end{tabular} \caption{Option Capabilities} \label{tab:capabilities} \end{center} \end{table} \subsubsection{Option Value Constraints} It is often useful to constrain the values that an option can take. For example, constraints can be used by a frontend to determine how to represent a given option. Member \code{constraint\_type} indicates what constraint is in effect for the option. The constrained values that are allowed for the option are described by one of the union members of member \code{constraint}. The possible values of type \code{\defn{SANE\_Constraint\_Type}} and the interpretation of the \code{constraint} union is described in Table~\ref{tab:constraints}. \begin{table}[htbp] \begin{center} \leavevmode \begin{tabular}{|l|r|p{0.5\textwidth}|} \hline \multicolumn{1}{|c|}{\bf Symbol} & \multicolumn{1}{|c|}{\bf Code} & \multicolumn{1}{|c|}{\bf Description} \\ \hline\hline \code{\defn{SANE\_CONSTRAINT\_NONE}} & 0 & The value is unconstrained. The option can take any of the values possible for the option's type. \\ \code{\defn{SANE\_CONSTRAINT\_RANGE}} & 1 & This constraint is applicable to integer and fixed-point valued options only. It constrains the option value to a possibly quantized range of numbers. Option descriptor member \code{constraint.range} points to a range of the type \code{\defn{SANE\_Range}}. This type is illustrated below: \begin{quote} \begin{verbatim} typedef struct { SANE_Word min; SANE_Word max; SANE_Word quant; } SANE_Range; \end{verbatim} \end{quote} All three members in this structure are interpreted according to the option value type (\verb|SANE_TYPE_INT| or \verb|SANE_TYPE_FIXED|). Members \code{min} and \code{max} specify the minimum and maximum values, respectively. If member \code{quant} is non-zero, it specifies the quantization value. If $l$ is the minimum value, $u$ the maximum value and $q$ the (non-zero) quantization of a range, then the legal values are $v=k\cdot q+l$ for all non-negative integer values of $k$ such that $v<=u$. \\ \code{\defn{SANE\_CONSTRAINT\_WORD\_LIST}} & 2 & This constraint is applicable to integer and fixed-point valued options only. It constrains the option value to a list of numeric values. Option descriptor member \code{constraint.word\_list} points to a list of words that enumerates the legal values. The first element in that list is an integer (\verb|SANE_Int|) that specifies the length of the list (not counting the length itself). The remaining elements in the list are interpreted according to the type of the option value (\verb|SANE_TYPE_INT| or \verb|SANE_TYPE_FIXED|). \\ \code{\defn{SANE\_CONSTRAINT\_STRING\_LIST}} & 3 & This constraint is applicable to string-valued options only. It constrains the option value to a list of strings. The option descriptor member \code{con\-strai\-nt.str\-ing\_list} points to a \code{NULL} terminated list of strings that enumerate the legal values for the option value. \\\hline \end{tabular} \caption{Option Value Constraints} \label{tab:constraints} \end{center} \end{table} \section{Operations} \subsection{\code{sane\_init}} This function must be called before any other SANE function can be called. The behavior of a SANE backend is undefined if this function is not called first or if the status code returned by \code{sane\_init} is different from \code{\defn{SANE\_STATUS\_GOOD}}. The version code of the backend is returned in the value pointed to by \code{version\_code}. If that pointer is \code{NULL}, no version code is returned. Argument \code{authorize} is either a pointer to a function that is invoked when the backend requires authentication for a specific resource or \code{NULL} if the frontend does not support authentication. \begin{quote}\index{sane\_init} \begin{verbatim} SANE_Status sane_init (SANE_Int * version_code, SANE_Authorization_Callback authorize); \end{verbatim} \end{quote} The authorization function may be called by a backend in response to any of the following calls: \begin{quote} \code{sane\_open}, \code{sane\_control\_option}, \code{sane\_start} \end{quote} If a backend was initialized without authorization function, then authorization requests that cannot be handled by the backend itself will fail automatically and the user may be prevented from accessing protected resources. Backends are encouraged to implement means of authentication that do not require user assistance. E.g., on a multi-user system that authenticates users through a login process a backend could automatically lookup the apporpriate password based on resource- and user-name. The authentication function type has the following declaration: \begin{quote}\index{SANE\_Authorization\_Callback} \index{domain}\index{username}\index{password} \begin{verbatim} #define SANE_MAX_USERNAME_LEN 128 #define SANE_MAX_PASSWORD_LEN 128 typedef void (*SANE_Authorization_Callback) (SANE_String_Const resource, SANE_Char username[SANE_MAX_USERNAME_LEN], SANE_Char password[SANE_MAX_PASSWORD_LEN]); \end{verbatim} \end{quote} Three arguments are passed to the authorization function: \code{resource} is a string specifying the name of the resource that requires authorization. A frontend should use this string to build a user-prompt requesting a username and a password. The \code{username} and \code{password} arguments are (pointers to) an array of \code{SANE\_MAX\_USERNAME\_LEN} and \code{SANE\_MAX\_PASSWORD\_LEN} characters, respectively. The authorization call should place the entered username and password in these arrays. The returned strings {\em must\/} be ASCII-NUL terminated. \subsection{\code{sane\_exit}} This function must be called to terminate use of a backend. The function will first close all device handles that still might be open (it is recommended to close device handles explicitly through a call to \code{sane\_clo\-se()}, but backends are required to release all resources upon a call to this function). After this function returns, no function other than \code{sane\_init()} may be called (regardless of the status value returned by \code{sane\_exit()}. Neglecting to call this function may result in some resources not being released properly. \begin{quote}\index{sane\_exit} \begin{verbatim} void sane_exit (void); \end{verbatim} \end{quote} \subsection{\code{sane\_get\_devices}} This function can be used to query the list of devices that are available. If the function executes successfully, it stores a pointer to a \code{NULL} terminated array of pointers to \verb|SANE_Device| structures in \code{*device\_list}. The returned list is guaranteed to remain unchanged and valid until (a) another call to this function is performed or (b) a call to \code{sane\_exit()} is performed. This function can be called repeatedly to detect when new devices become available. If argument \code{local\_only} is true, only local devices are returned (devices directly attached to the machine that SANE is running on). If it is false, the device list includes all remote devices that are accessible to the SANE library. \begin{quote}\index{sane\_get\_devices} \begin{verbatim} SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only); \end{verbatim} \end{quote} This function may fail with \code{SANE\_STATUS\_NO\_MEM} if an insufficient amount of memory is available. \begin{quote} \begin{center} {\bf Backend Implementation Note} \end{center} SANE does not require that this function is called before a \code{sane\_open()} call is performed. A device name may be specified explicitly by a user which would make it unnecessary and undesirable to call this function first. \end{quote} \subsection{\code{sane\_open}} This function is used to establish a connection to a particular device. The name of the device to be opened is passed in argument \code{name}. If the call completes successfully, a handle for the device is returned in \code{*h}. As a special case, specifying a zero-length string as the device requests opening the first available device (if there is such a device). \begin{quote}\index{sane\_open} \begin{verbatim} SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h); \end{verbatim} \end{quote} This function may fail with one of the following status codes. \begin{quote} \begin{description} \item[\code{SANE\_STATUS\_DEVICE\_BUSY}:] The device is currently busy (in use by somebody else). \item[\code{SANE\_STATUS\_INVAL}:] The device name is not valid. \item[\code{SANE\_STATUS\_IO\_ERROR}:] An error occured while communicating with the device. \item[\code{SANE\_STATUS\_NO\_MEM}:] An insufficent amount of memory is available. \item[\code{SANE\_STATUS\_ACCESS\_DENIED}:] Access to the device has been denied due to insufficient or invalid authentication. \end{description} \end{quote} \subsection{\code{sane\_close}} This function terminates the association between the device handle passed in argument \code{h} and the device it represents. If the device is presently active, a call to \code{sane\_cancel()} is performed first. After this function returns, handle \code{h} must not be used anymore. \begin{quote}\index{sane\_close} \begin{verbatim} void sane_close (SANE_Handle h); \end{verbatim} \end{quote} \subsection{\code{sane\_get\_option\_descriptor}} This function is used to access option descriptors. The function returns the option descriptor for option number \code{n} of the device represented by handle \code{h}. Option number 0 is guaranteed to be a valid option. Its value is an integer that specifies the number of options that are available for device handle \code{h} (the count includes option 0). If $n$ is not a valid option index, the function returns \code{NULL}. The returned option descriptor is guaranteed to remain valid (and at the returned address) until the device is closed. \begin{quote}\index{sane\_get\_option\_descriptor} \begin{verbatim} const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle h, SANE_Int n); \end{verbatim} \end{quote} \subsection{\code{sane\_control\_option}}\label{sec:control} This function is used to set or inquire the current value of option number \code{n} of the device represented by handle \code{h}. The manner in which the option is controlled is specified by parameter \code{a}. The possible values of this parameter are described in more detail below. The value of the option is passed through argument \code{v}. It is a pointer to the memory that holds the option value. The memory area pointed to by \code{v} must be big enough to hold the entire option value (determined by member \code{size} in the corresponding option descriptor). The only exception to this rule is that when setting the value of a string option, the string pointed to by argument \code{v} may be shorter since the backend will stop reading the option value upon encountering the first \code{NUL} terminator in the string. If argument \code{i} is not \code{NULL}, the value of \code{*i} will be set to provide details on how well the request has been met. The meaning of this argument is described in more detail below. \begin{quote}\index{sane\_control\_option} \begin{verbatim} SANE_Status sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int * i); \end{verbatim} \end{quote} The way the option is affected by a call to this function is controlled by parameter \code{a} which is a value of type \code{\defn{SANE\_Action}}. The possible values and their meaning is described in Table~\ref{tab:actions}. \begin{table}[h] \begin{center} \leavevmode \begin{tabular}{|l|r|p{0.5\textwidth}|} \hline \multicolumn{1}{|c|}{\bf Symbol} & \multicolumn{1}{|c|}{\bf Code} & \multicolumn{1}{|c|}{\bf Description} \\ \hline\hline \code{\defn{SANE\_ACTION\_GET\_VALUE}} & 0 & Get current option value. \\ \code{\defn{SANE\_ACTION\_SET\_VALUE}} & 1 & Set option value. The option value passed through argument \code{v} may be modified by the backend if the value cannot be set exactly. \\ \code{\defn{SANE\_ACTION\_SET\_AUTO}} & 2 & Turn on automatic mode. Backend or device will automatically select an appropriate value. This mode remains effective until overridden by an explicit set value request. The value of parameter \code{v} is completely ignored in this case and may be \code{NULL}. \\ \hline \end{tabular} \caption{Action Values (\code{SANE\_Action})} \label{tab:actions} \end{center} \end{table} After setting a value via an action value of \verb|SANE_ACTION_SET_VALUE|, additional information on how well the request has been met is returned in \code{*i} (if \code{i} is non-\code{NULL}). The returned value is a bitset that may contain any combination of the values described in Table~\ref{tab:info}. \begin{table}[htbp] \begin{center} \leavevmode \begin{tabular}{|l|r|p{0.5\textwidth}|} \hline \multicolumn{1}{|c|}{\bf Symbol} & \multicolumn{1}{|c|}{\bf Code} & \multicolumn{1}{|c|}{\bf Description} \\ \hline\hline \code{\defn{SANE\_INFO\_INEXACT}} & 1 & This value is returned when setting an option value resulted in a value being selected that does not exactly match the requested value. For example, if a scanner can adjust the resolution in increments of 30dpi only, setting the resolution to 307dpi may result in an actual setting of 300dpi. When this happens, the bitset returned in \code{*i} has this member set. In addition, the option value is modified to reflect the actual (rounded) value that was used by the backend. Note that inexact values are admissible for strings as well. A backend may choose to ``round'' a string to the closest matching legal string for a constrained string value. \\ \code{\defn{SANE\_INFO\_RELOAD\_OPTIONS}} & 2 & The setting of an option may affect the value or availability of one or more {\em other\/} options. When this happens, the SANE backend sets this member in \code{*i} to indicate that the application should reload all options. This member may be set if and only if at least one option changed. \\ \code{\defn{SANE\_INFO\_RELOAD\_PARAMS}} & 4 & The setting of an option may affect the parameter values (see \code{sane\_get\_parameters()}). If setting an option affects the parameter values, this member will be set in \code{*i}. Note that this member may be set even if the parameters did not actually change. However, it is guaranteed that the parameters never change without this member being set. \\ \hline \end{tabular} \caption{Additional Information Returned When Setting an Option} \label{tab:info} \end{center} \end{table} This function may fail with one of the following status codes. \begin{quote} \begin{description} \item[\code{SANE\_STATUS\_UNSUPPORTED}:] The operation is not supported for the specified handle and option number. \item[\code{SANE\_STATUS\_INVAL}:] The option value is not valid. \item[\code{SANE\_STATUS\_IO\_ERROR}:] An error occured while communicating with the device. \item[\code{SANE\_STATUS\_NO\_MEM}:] An insufficent amount of memory is available. \item[\code{SANE\_STATUS\_ACCESS\_DENIED}:] Access to the option has been denied due to insufficient or invalid authentication. \end{description} \end{quote} \subsection{\code{sane\_get\_parameters}} This function is used to obtain the current scan parameters. The returned parameters are guaranteed to be accurate between the time a scan has been started (\code{sane\_start()} has been called) and the completion of that request. Outside of that window, the returned values are best-effort estimates of what the parameters will be when \code{sane\_start()} gets invoked. Calling this function before a scan has actually started allows, for example, to get an estimate of how big the scanned image will be. The parameters passed to this function are the handle \code{h} of the device for which the parameters should be obtained and a pointer \code{p} to a parameter structure. The parameter structure is described in more detail below. \begin{quote}\index{sane\_get\_parameters} \begin{verbatim} SANE_Status sane_get_parameters (SANE_Handle h, SANE_Parameters * p); \end{verbatim} \end{quote} The scan parameters are returned in a structure of type \code{\defn{SANE\_Parameters}}. The C declaration of this structure is given below. \begin{quote} \begin{verbatim} typedef struct { SANE_Frame format; SANE_Bool last_frame; SANE_Int bytes_per_line; SANE_Int pixels_per_line; SANE_Int lines; SANE_Int depth; } SANE_Parameters; \end{verbatim} \end{quote} Member \code{format} specifies the format of the next frame to be returned. The possible values for type \code{\defn{SANE\_Frame}} are described in Table~\ref{tab:frameformat}. The meaning of these values is described in more detail in Section~\ref{sec:imageformat}. \begin{table}[htbp] \begin{center} \leavevmode \begin{tabular}{|l|r|l|} \hline \multicolumn{1}{|c|}{\bf Symbol} & \multicolumn{1}{|c|}{\bf Code} & \multicolumn{1}{|c|}{\bf Description} \\ \hline\hline \code{\defn{SANE\_FRAME\_GRAY}} & 0 & Band covering human visual range. \\ \code{\defn{SANE\_FRAME\_RGB}} & 1 & Pixel-interleaved red/green/blue bands. \\ \code{\defn{SANE\_FRAME\_RED}} & 2 & Red band of a red/green/blue image. \\ \code{\defn{SANE\_FRAME\_GREEN}} & 3 & Green band of a red/green/blue image. \\ \code{\defn{SANE\_FRAME\_BLUE}} & 4 & Blue band of a red/green/blue image. \\ \hline \end{tabular} \caption{Frame Format (\code{SANE\_Frame})} \label{tab:frameformat} \end{center} \end{table} Member \code{last\_frame} is set to \code{SANE\_TRUE} if and only if the frame that is currently being acquired (or the frame that will be acquired next if there is no current frame) is the last frame of a multi frame image (e.g., the current frame is the blue component of a red, green, blue image). Member \code{lines} specifies how many scan lines the frame is comprised of. If this value is -1, the number of lines is not known a priori and the frontend should call \code{sane\_read()} until it returns a status of \code{SANE\_STATUS\_EOF}. Member \code{bytes\_per\_line} specifies the number of bytes that comprise one scan line. Member \code{depth} specifies the number of bits per sample. Member \code{pixels\_per\_line} specifies the number of pixels that comprise one scan line. Assume $B$ is the number of channels in the frame, then the bit depth $d$ (as given by member \code{depth}) and the number of pixels per line $n$ (as given by this member \code{pixels\_per\_line}) are related to $c$, the number of bytes per line (as given by member \code{bytes\_per\_line}) as follows: \[ c >= \left\{ \begin{array}{ll} B\cdot \lfloor (n + 7) / 8\rfloor & \mbox{if $d=1$}\\ B\cdot n \cdot d / 8 & \mbox{if $d>1$} \end{array} \right. \] Note that the number of bytes per line can be larger than the minimum value imposed by the right side of this equation. A frontend must be able to properly cope with such ``padded'' image formats. \subsection{\code{sane\_start}} This function initiates aquisition of an image from the device represented by handle \code{h}. \begin{quote}\index{sane\_start} \begin{verbatim} SANE_Status sane_start (SANE_Handle h); \end{verbatim} \end{quote} This function may fail with one of the following status codes. \begin{quote} \begin{description} \item[\code{SANE\_STATUS\_CANCELLED}:] The operation was cancelled through a call to \code{sane\_cancel}. \item[\code{SANE\_STATUS\_DEVICE\_BUSY}:] The device is busy. The operation should be retried later. \item[\code{SANE\_STATUS\_JAMMED}:] The document feeder is jammed. \item[\code{SANE\_STATUS\_NO\_DOCS}:] The document feeder is out of documents. \item[\code{SANE\_STATUS\_COVER\_OPEN}:] The scanner cover is open. \item[\code{SANE\_STATUS\_IO\_ERROR}:] An error occurred while communicating with the device. \item[\code{SANE\_STATUS\_NO\_MEM}:] An insufficent amount of memory is available. \item[\code{SANE\_STATUS\_INVAL}:] The scan cannot be started with the current set of options. The frontend should reload the option descriptors, as if \code{\defn{SANE\_INFO\_RELOAD\_OPTIONS}} had been returned from a call to \code{sane\_control\_option()}, since the device's capabilities may have changed. \end{description} \end{quote} \subsection{\code{sane\_read}} This function is used to read image data from the device represented by handle \code{h}. Argument \code{buf} is a pointer to a memory area that is at least \code{maxlen} bytes long. The number of bytes returned is stored in \code{*len}. A backend must set this to zero when a status other than \code{SANE\_STA\-TUS\_GOOD} is returned. When the call succeeds, the number of bytes returned can be anywhere in the range from 0 to \code{maxlen} bytes. \begin{quote}\index{sane\_read} \begin{verbatim} SANE_Status sane_read (SANE_Handle h, SANE_Byte * buf, SANE_Int maxlen, SANE_Int * len); \end{verbatim} \end{quote} If this function is called when no data is available, one of two things may happen, depending on the I/O mode that is in effect for handle \code{h}. \begin{enumerate} \item If the device is in blocking I/O mode (the default mode), the call blocks until at least one data byte is available (or until some error occurs). \item If the device is in non-blocking I/O mode, the call returns immediately with status \code{SANE\_STA\-TUS\_GOOD} and with \code{*len} set to zero. \end{enumerate} The I/O mode of handle \code{h} can be set via a call to \code{sane\_set\_io\_mode()}. This function may fail with one of the following status codes. \begin{quote} \begin{description} \item[\code{SANE\_STATUS\_CANCELLED}:] The operation was cancelled through a call to \code{sane\_cancel}. \item[\code{SANE\_STATUS\_EOF}:] No more data is available for the current frame. \item[\code{SANE\_STATUS\_JAMMED}:] The document feeder is jammed. \item[\code{SANE\_STATUS\_NO\_DOCS}:] The document feeder is out of documents. \item[\code{SANE\_STATUS\_COVER\_OPEN}:] The scanner cover is open. \item[\code{SANE\_STATUS\_IO\_ERROR}:] An error occurred while communicating with the device. \item[\code{SANE\_STATUS\_NO\_MEM}:] An insufficent amount of memory is available. \item[\code{SANE\_STATUS\_ACCESS\_DENIED}:] Access to the device has been denied due to insufficient or invalid authentication. \end{description} \end{quote} \subsection{\code{sane\_cancel}} This function is used to immediately or as quickly as possible cancel the currently pending operation of the device represented by handle \code{h}. \begin{quote}\index{sane\_cancel} \begin{verbatim} void sane_cancel (SANE_Handle h); \end{verbatim} \end{quote} This function can be called at any time (as long as handle \code{h} is a valid handle) but usually affects long-running operations only (such as image is acquisition). It is safe to call this function asynchronously (e.g., from within a signal handler). It is important to note that completion of this operaton does {\em not\/} imply that the currently pending operation has been cancelled. It only guarantees that cancellation has been {\em initiated}. Cancellation completes only when the cancelled call returns (typically with a status value of \code{SANE\_STATUS\_CANCELLED}). Since the SANE API does not require any other operations to be re-entrant, this implies that a frontend must {\em not\/} call any other operation until the cancelled operation has returned. \subsection{\code{sane\_set\_io\_mode}} This function is used to set the I/O mode of handle \code{h}. The I/O mode can be either blocking or non-blocking. If argument \code{m} is \code{SANE\_TRUE}, the mode is set to non-blocking mode, otherwise it's set to blocking mode. This function can be called only after a call to \code{sane\_start()} has been performed. \begin{quote}\index{sane\_set\_io\_mode} \begin{verbatim} SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool m); \end{verbatim} \end{quote} By default, newly opened handles operate in blocking mode. A backend may elect not to support non-blocking I/O mode. In such a case the status value \code{SANE\_STATUS\_UNSUPPORTED} is returned. Blocking I/O must be supported by all backends, so calling this function with argument \code{m} set to \code{SANE\_FALSE} is guaranteed to complete successfully. This function may fail with one of the following status codes: \begin{quote} \begin{description} \item[\code{SANE\_STATUS\_INVAL}:] No image acquisition is pending. \item[\code{SANE\_STATUS\_UNSUPPORTED}:] The backend does not support the requested I/O mode. \end{description} \end{quote} \subsection{\code{sane\_get\_select\_fd}} This function is used to obtain a (platform-specific) file-descriptor for handle \code{h} that is readable if and only if image data is available (i.e., when a call to \code{sane\_read()} will return at least one byte of data). If the call completes successfully, the select file-descriptor is returned in \code{*fd}. \begin{quote}\index{sane\_get\_select\_fd} \begin{verbatim} SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int *fd); \end{verbatim} \end{quote} This function can be called only after a call to \code{sane\_start()} has been performed and the returned file-descriptor is guaranteed to remain valid for the duration of the current image acquisition (i.e., until \code{sane\_cancel()} or \code{sane\_start()} get called again or until \code{sane\_read()} returns with status \code{SANE\_STA\-TUS\_EOF}). Indeed, a backend must guarantee to close the returned select file descriptor at the point when the next \code{sane\_read()} call would return \code{SANE\_STA\-TUS\_EOF}. This is necessary to ensure the application can detect when this condition occurs without actually having to call \code{sane\_read()}. A backend may elect not to support this operation. In such a case, the function returns with status code \code{SANE\_STATUS\_UNSUPPORTED}. Note that the only operation supported by the returned file-descriptor is a host operating-system dependent test whether the file-descriptor is readable (e.g., this test can be implemented using \code{select()} or \code{poll()} under UNIX). If any other operation is performed on the file descriptor, the behavior of the backend becomes unpredictable. Once the file-descriptor signals ``readable'' status, it will remain in that state until a call to \code{sane\_read()} is performed. Since many input devices are very slow, support for this operation is strongly encouraged as it permits an application to do other work while image acquisition is in progress. This function may fail with one of the following status codes: \begin{quote} \begin{description} \item[\code{SANE\_STATUS\_INVAL}:] No image acquisition is pending. \item[\code{SANE\_STATUS\_UNSUPPORTED}:] The backend does not support this operation. \end{description} \end{quote} \subsection{\code{sane\_strstatus}} This function can be used to translate a SANE status code into a printable string. The returned string is a single line of text that forms a complete sentence, but without the trailing period (full-stop). The function is guaranteed to never return \code{NULL}. The returned pointer is valid at least until the next call to this function is performed. \begin{quote}\index{sane\_strstatus} \begin{verbatim} const SANE_String_Const sane_strstatus (SANE_Status status); \end{verbatim} \end{quote} \section{Code Flow}\index{code flow} The code flow for the SANE API is illustrated in Figure~\ref{fig:flow}. Functions \code{sane\_init()} and \code{sane\_exit()} initialize and exit the backend, respectively. All other calls must be performed after initialization and before exiting the backend. \begin{figure}[htb] \begin{center} \leavevmode \includegraphics[height=0.5\textheight]{figs/flow} \caption{Code flow} \label{fig:flow} \end{center} \end{figure} Function \code{sane\_get\_devices()} can be called any time after \code{sane\_init()} has been called. It returns the list of the devices that are known at the time of the call. This list may change over time since some devices may be turned on or off or a remote host may boot or shutdown between different calls. It should be noted that this operation may be relatively slow since it requires contacting all configured devices (some of which may be on remote hosts). A frontend may therefore want to provide the ability for a user to directly select a desired device without requiring a call to this function. Once a device has been chosen, it is opened using a call to \code{sane\_open()}. Multiple devices can be open at any given time. A SANE backend must not impose artificial constraints on how many devices can be open at any given time. An opened device can be setup through the corresponding device handle using functions \code{sane\_get\_opt\-ion\_desc\-riptor()} and \code{sane\_control\_option()}. While setting up a device, obtaining option descriptors and setting and reading of option values can be mixed freely. It is typical for a frontend to read out all available options at the beginning and then build a dialog (either graphical or a command-line oriented option list) that allows to control the available options. It should be noted that the number of options is fixed for a given handle. However, as options are set, other options may become active or inactive. Thus, after setting an option, it maybe necessary to re-read some or all option descriptors. While setting up the device, it is also admissible to call \code{sane\_get\_parameters()} to get an estimate of what the image parameters will look like once image acquisition begins. The device handle can be put in blocking or non-blocking mode by a call to \code{sane\_set\_io\_mode()}. Devices are required to support blocking mode (which is the default mode), but support for non-blocking I/O is strongly encouraged for operating systems such as UNIX. After the device is setup properly, image acquisition can be started by a call to \code{sane\_start()}. The backend calculates the exact image parameters at this point. So future calls to \code{sane\_get\_parameters()} will return the exact values, rather than estimates. Whether the physical image acquisition starts at this point or during the first call to \code{sane\_read()} is unspecified by the SANE API. If non-blocking I/O and/or a select-style interface is desired, the frontend may attempt to call \code{sane\_set\_io\_mode()} and/or \code{sane\_get\_select\_fd()} at this point. Either of these functions may fail if the backend does not support the requested operation. Image data is collected by repeatedly calling \code{sane\_read()}. Eventually, this function will return an end-of-file status (\code{SANE\_STATUS\_EOF}). This indicates the end of the current frame. If the frontend expects additional frames (e.g., the individual channels in of a red/green/blue image or multiple images), it can call \code{sane\_start()} again. Once all desired frames have been acquired, function \code{sane\_cancel()} must be called. This operation can also be called at any other time to cancel a pending operation. Note that \code{sane\_cancel()} must be called even if the last read operation returned \code{SANE\_STATUS\_EOF}. When done using the device, the handle should be closed by a call to \code{sane\_close()}. Finally, before exiting the application, function \code{sane\_exit()} must be called. It is important not to forget to call this function since otherwise some resources (e.g., temporary files or locks) may remain unclaimed. \section{Well-Known Options}\index{well-known options} While most backend options are completely self-describing, there are a cases where a user interface might want to special-case the handling of certain options. For example, the scan area is typically defined by four options that specify the top-left and bottom-right corners of the area. With a graphical user interface, it would be tedious to force the user to type in these four numbers. Instead, most such interfaces will want to present to the user a preview (low-resolution scan) of the scanner surface and let the user pick the scan area by dragging a rectangle into the desired position. For this reason, the SANE API specifies a small number of option names that have well-defined meanings. \subsection{Option Number Count}\index{option count} Option number 0 has an empty string as its name. The value of this option is of type \code{SANE\_TYPE\_INT} and it specifies the total number of options available for a given device (the count includes option number 0). This means that there are two ways of counting the number of options available: a frontend can either cycle through all option numbers starting at one until \code{sane\_get\_option\_descriptor()} returns \code{NULL}, or a frontend can directly read out the value of option number 0. \subsection{Scan Resolution Option}\index{scan resolution}\index{resolution option} Option \code{resolution} is used to select the resolution at which an image should be acquired. The type of this option is either \code{SANE\_TYPE\_INT} or \code{SANE\_TYPE\_FIXED}. The unit is \code{SANE\_UNIT\_DPI} (dots/inch). This option is not mandatory, but if a backend does support it, it must implement it in a manner consistent with the above definition. \subsection{Preview Mode Option}\index{preview mode} The boolean option \code{preview} is used by a frontend to inform the backend when image acquisition should be optimized for speed, rather than quality (``preview mode''). When set to \code{SANE\_TRUE}, preview mode is in effect, when set to \code{SANE\_FALSE} image acquisition should proceed in normal quality mode. The setting of this option \emph{must not\/} affect any other option. That is, as far as the other options are concerned, the preview mode is completely side effect free. A backend can assume that the frontend will take care of appropriately setting the scan resolution for preview mode (through option \code{resolution}). A backend is free to override the \code{resolution} value with its own choice for preview mode, but it is advised to leave this choice to the frontend wherever possible. This option is not mandatory, but if a backend does support it, it must implement it in a manner consistent with the above definition. \subsection{Scan Area Options}\index{scan area options} The four most important well-known options are the ones that define the scan area. The scan area is defined by two points (x/y coordinate pairs) that specify the top-left and the bottom-right corners. This is illustrated in Figure~\ref{fig:area}. Note that the origin of the coordinate system is at the top-left corner of the scan surface as seen by the sensor (which typically is a mirror image of the scan surface seen by the user). For this reason, the top-left corner is the corner for which the abscissa and ordinate values are simultaneously the {\em smallest} and the bottom-right corner is the corner for which the abscissa and ordinate values are simulatenously the {\em largest}. If this coordinate system is not natural for a given device, it is the job of the backend to perform the necessary conversions. \begin{figure}[tbp] \begin{center} \leavevmode \includegraphics[height=0.3\textheight]{figs/area} \caption{Scan area options} \label{fig:area} \end{center} \end{figure} The names of the four options that define the scan area are given in the table below: \begin{center} \begin{tabular}{ll} {\bf Name} & {\bf Description} \\ \code{\defn{tl-x}} & Top-left $x$ coordinate value \\ \code{\defn{tl-y}} & Top-left $y$ coordinate value \\ \code{\defn{br-x}} & Bottom-right $x$ coordinate value \\ \code{\defn{br-y}} & Bottom-right $y$ coordinate value \\ \end{tabular} \end{center} There are several rules that should be followed by front and backends regarding these options: \begin{itemize} \item Backends must attach a unit of either pixels (\code{SANE\_UNIT\_PIXEL}) or millimeters (\code{SANE\_UNIT\_MM}) to these options. The unit of all four options must be identical. \item Whenever meaningful, a backend should attach a range or a word-list constraint to these options. \item A frontend can determine the size of the scan surface by first checking that the options have range constraints associated. If a range or word-list constraints exist, the frontend can take the minimum and maximum values of one of the x and y option range-constraints to determine the scan surface size. \item A frontend must work properly with any or all of these options missing. \end{itemize} \input{net.tex} \chapter{Contact Information}\label{chap:contact} The SANE standard is discussed and evolved via a mailing list. Anybody with email access to the Internet can automatically join and leave the discussion group by sending mail to the following address. \begin{quote}\index{mailing list} \url{sane-devel-request@alioth-lists.debian.net} \end{quote} To subscribe, send a mail with the body ``\verb|subscribe sane-devel|'' to the above address. A complete list of commands supported can be obtained by sending a mail with a subject of ``\code{help}'' to the above address. The mailing list is archived and available through the SANE home page at URL: \begin{quote} \url{http://www.sane-project.org/} \end{quote} \newpage \input{sane.ind} \end{document} sane-backends-1.0.29/doc/sane-epjitsu.man0000666000000000000000000000753013615534521015057 00000000000000.TH sane\-epjitsu 5 "11 Apr 2017" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-epjitsu .SH NAME sane\-epjitsu \- SANE backend for Epson-based Fujitsu USB scanners. .SH DESCRIPTION The .B sane\-epjitsu library implements a SANE (Scanner Access Now Easy) backend which provides basic access the Fujitsu fi\-60F/fi\-65F and ScanSnap S300/S1300(i)/S1100(i) scanners. .SH HARDWARE SUPPORT These scanners are fairly limited, only supporting a couple of modes and resolutions, and always scanning full width. The backend supports missing modes (binary, grayscale) and intermediate resolutions in software, but provides only minimal scan area controls. See .B KNOWN ISSUES. This backend may support other scanners. If physical inspection reveals an Epson chipset, please contact the author for instructions on collecting a USB trace under Windows to verify. .SH OPTIONS A limited effort has been made to expose the standard options to the API. This allows a frontend to set resolution, color mode, and choose the ADF setting. The epjitsu backend supports the following basic options for most scanners: .PP source s .RS Selects the source for the scan. Options may include "Flatbed", "ADF Front", "ADF Back", "ADF Duplex". .RE .PP mode m .RS Selects the mode for the scan. Options may include "Lineart", "Gray", "Color". .RE .PP resolution, y\-resolution .RS Controls scan resolution. Setting \-\-resolution also sets \-\-y\-resolution, though this behavior is overridden by some frontends. .RE .PP Other options will be available based on the capabilities of the scanner. Use 'scanimage \-\-help' to get a list. Be aware that some options may appear only when another option has been set, and that advanced options may be hidden by the frontend. .PP .SH CONFIGURATION FILE The configuration file "@CONFIGDIR@/epjitsu.conf" is used to tell the backend how to look for scanners, and provide options controlling the operation of the backend. This file is read each time the frontend asks the backend for a list of scanners, generally only when the frontend starts. If the configuration file is missing, the backend will not work. .PP Scanners can be specified in the configuration file in two ways: .PP "usb 0x04c5 0x10c7" (or other vendor/product ids) .RS Requests backend to search all usb busses in the system for a device which uses that vendor and product id. The device will then be queried to determine if it is a supported scanner. .RE .PP "usb /dev/usb/scanner0" (or other device file) .RS Some systems use a kernel driver to access usb scanners. This method is untested. .RE .PP The only configuration option supported is "firmware /PATH/TO/FILE", allowing you to set the location of the firmware file you have extracted from the Windows driver. .PP .B Note: This firmware is a copyrighted work of Fujitsu, so cannot be provided by the backend or the author. Please do not ask. .PP .B Note: These scanners REQUIRE a firmware file to function. See the supplied configuration file for more detail. .PP .B Note: This option may appear multiple times in the configuration file. It only applies to scanners discovered by 'usb' lines that follow this option. .PP .SH ENVIRONMENT The backend uses a single environment variable, SANE_DEBUG_EPJITSU, which enables debugging output to stderr. Valid values are: .PP .RS 5 Errors .br 10 Function trace .br 15 Function detail .br 20 Option commands .br 25 USB trace .br 30 USB detail .br 35 Useless noise .RE .SH KNOWN ISSUES .PP .RS Only limited scan area options are exposed. .br .br fi\-60F and fi\-65F hardware grayscale mode is not used, because the calibration code is not finished. .RE .SH CREDITS S300 support funded by Microdea, Inc. and Archivista, GmbH. .br fi\-60F support funded by TrueCheck, Inc. .br Improved calibration code provided by Richard Goedeken. .SH "SEE ALSO" sane(7), sane\-usb(5) .SH AUTHOR m. allan noah: sane-backends-1.0.29/doc/sane-snapscan.man0000666000000000000000000000707513615534521015206 00000000000000.TH sane\-snapscan 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-snapscan .SH NAME sane\-snapscan \- SANE backend for AGFA SnapScan flatbed scanners .SH DESCRIPTION The .B sane\-snapscan library implements a SANE (Scanner Access Now Easy) backend that provides access to AGFA SnapScan flatbed scanners. At present, the following scanners are supported from this backend: AGFA SnapScan 300, 310, 600, and 1236s, 1236u, 1212u, e20, e25, e40, e50, e60, Vuego 310s, Acer 300f, 310s, 610s, 610plus, Prisa 620s, Prisa 620u, Prisa 620ut, Prisa 640u, Prisa 640bu, Prisa 1240, Prisa 3300, Prisa 4300, Prisa 5300 and Guillemot Maxi Scan A4 Deluxe (SCSI) (with varying success). .PP .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the path-name for the special device that corresponds to a SCSI scanner. For SCSI scanners, the special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. See sane\-scsi(5) for details. .P For USB scanners the devicename must contain the keyword "usb", as in .I /dev/usbscanner or .IR /dev/usb/scanner0 . For scanners that need a firmware upload before scanning add a line starting with "firmware" followed by the fully qualified path to your firmware file, e.g. .PP .RS firmware @DATADIR@/sane/snapscan/firmware.bin .RE .PP For further details read http://snapscan.sourceforge.net. .SH CONFIGURATION The contents of the .I snapscan.conf file is a list of device names that correspond to SnapScan scanners. Empty lines and lines starting with a hash mark (#) are ignored. See sane\-scsi(5) on details of what constitutes a valid device name. .SH FILES .TP .I @CONFIGDIR@/snapscan.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-snapscan.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-snapscan.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_SNAPSCAN If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 255 requests all debug output to be printed. Smaller levels reduce verbosity. .SH BUGS Man page doesn't provide much information yet. .SH "SEE ALSO" sane(7), sane\-scsi(5) .br http://www.cs.ualberta.ca/~charter/SnapScan/snapscan.html .br http://sourceforge.net/projects/snapscan/ (new development website) .SH AUTHOR Kevin Charter, Franck Schneider, Michel Roelofs, Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang, Wolfgang Goeller, Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Oliver Schwartz and Mikael Magnusson. .br Man page by Henning Meier-Geinitz (mostly based on the web pages and source code). sane-backends-1.0.29/doc/leo/0000755000000000000000000000000013615535552012606 500000000000000sane-backends-1.0.29/doc/leo/leo.txt0000666000000000000000000000624213615534521014051 00000000000000 BACKEND LEO Across Technologies FS-1130 (A rebadged LEO Technologies) 000: 06 31 14 01 1f 00 00 00 41 43 52 4f 53 53 20 20 .1......ACROSS 016: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 032: 31 2e 31 36 09 f6 0d b6 01 2c 01 2c 39 36 30 30 1.16.....,.,9600 LEO LEOScan S3: 000: 06 31 14 01 1F 00 00 00 4C 45 4F 20 20 20 20 20 .1......LEO 016: 4C 45 4F 53 63 61 6E 2D 53 33 20 20 20 20 20 20 LEOScan-S3 032: 33 2E 30 31 09 F6 0D B6 01 2C 01 2C 39 36 30 30 3.01.....,.,9600 or 000: 06 00 02 02 1f 00 00 00 4c 45 4f 00 00 00 00 00 ........LEO..... 016: 4c 45 4f 53 63 61 6e 2d 53 33 00 00 00 00 00 00 LEOScan-S3...... 032: 31 2e 31 30 1.10 Genius FS1130 000: 06 31 14 01 1f 00 00 00 4b 59 45 20 43 4f 52 50 .1......KYE CORP 016: 43 6f 6c 6f 72 50 61 67 65 2d 43 53 20 20 20 20 ColorPage-CS 032: 31 2e 31 34 1.14 /*--------------------------------------------------------------------------*/ SCSI commands supported by the FS-1130 TEST UNIT READY 00 00 00 00 00 00 INQUIRY 12 00 00 00 30 00 8-15: vendor name 16-31: product name 32-35: firmware level 36-37: scan area width in 1/300th of inches 38-39: scan area length in 1/300th of inches 40-41: max X resolution in dpi 42-43: max Y resolution in dpi 44-47: ? SCAN 1B 00 00 00 00 00 Start a scan SET WINDOW 24 00 00 00 00 00 30 00 00 00 Total length is 48 bytes 01 = 0x2E (may be 0x30 - 2, ie total length -2) 07 = length (48-8 = 40 = 0x28) 10-11 = X Resolution 12-13 = Y resolution 14-17 = X top left corner 18-21 = Y top left corner 22-25 = width (size in inches * 300) 26-29 = length (size in inches * 300) 31 = 0x80 ? 33 = scan mode 0x00 = black & white 0x01 = halftone 0x02 = grayscale 0x05 = color 34 = bit depth 1 or 8 37 = ? RIF + other 43 = ? 0x01 READ 28 00 00 00 00 00 00 0B 28 00 SEND 2A 00 03 00 00 01 00 03 00 00 2A 00 02 00 00 0F 00 01 00 00 2 = data type code 0x02 = halftone pattern 0x03 = gamma - 3 colors with 256 bytes each GET DATA BUFFER STATUS 34 00 00 00 00 00 00 00 10 00 7-8 allocation length returned buffer is 0x10 bytes long. 00 00 0D 00 00 00 03 D3 60 00 00 00 01 48 00 EE 0-2 = additional length (0x10-3 = 0x0D) 6-8 = (?) total scan length 9-11 = filled data buffer 12-13 = number of lines left (decrease during a scan) 14-15 = bytes per line (constant during a scan) /*--------------------------------------------------------------------------*/ Command sequence for the FS-1130 Setup the scan: TUR SET WINDOWS SEND gamma SEND haltone pattern (if halftone scan) SCAN TUR until scanner ready GET DATA BUFFER STATUS loop until all data read: GET DATA BUFFER STATUS READ park the CCD: SET WINDOWS TUR SCAN /*--------------------------------------------------------------------------*/ Command sequence for the S3 It seems similar to the FS-1130 except that no gamma nor halftone pattern is sent. Setup the scan: TUR SET WINDOWS SCAN TUR until scanner ready loop until all data read: GET DATA BUFFER STATUS READ park the CCD: SET WINDOWS SCAN sane-backends-1.0.29/doc/sane-kvs20xx.man0000666000000000000000000000145413615534521014720 00000000000000.TH sane\-kvs20xx 5 "09 Jun 2010" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-kvs20xx .SH NAME sane\-kvs20xx \- SANE backend for Panasonic KV-S20xxC USB/SCSI ADF scanners. .SH DESCRIPTION The .B sane\-kvs20xx library implements a SANE (Scanner Access Now Easy) backend which provides access to the Panasonic KV-S202xC and KV-S204xC scanners. .SH KNOWN ISSUES This document was written by the SANE project, which has no information regarding the capabilities or reliability of the backend. All information contained here is suspect. .SH CREDITS The backend was written by Panasonic Russia Ltd. The backend was ported to sane-backends 1.0.22 and downgraded to C89 by m. allan noah. .SH "SEE ALSO" sane(7), sane\-usb(5), sane\-scsi(5) .SH AUTHOR m. allan noah: sane-backends-1.0.29/doc/sane-hp3900.man0000666000000000000000000000727313615534521014323 00000000000000.TH sane\-hp3900 5 "06 Jan 2009" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-hp3900 .SH NAME sane\-hp3900 \- SANE backend for RTS8822 chipset based scanners .SH DESCRIPTION The .B sane\-hp3900 library implements a SANE (Scanner Access Now Easy) backend that provides access at least to the following USB flatbed scanners: .PP .RS .ft CR .nf Model: Chipset: ------ -------- HP ScanJet 3800 RTS8822BL-03A HP ScanJet 3970 RTS8822L-01H HP ScanJet 4070 Photosmart RTS8822L-01H HP ScanJet 4370 RTS8822L-02A HP ScanJet G2710 RTS8822BL-03A HP ScanJet G3010 RTS8822L-02A HP ScanJet G3110 RTS8822L-02A UMAX Astra 4900/4950 RTS8822L-01H * BenQ 5550 RTS8823L-01E * .fi .ft R .RE .PP More details can be found on the hp3900 backend homepage .IR http://sourceforge.net/projects/hp3900\-series/ . .PP This is ALPHA software. Keep your hand at the scanner's plug and unplug it, if scanner does not start to scan. See also the BUGS section. .PP If you own a scanner other than the ones listed above that works with this backend, please let us know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .IR /proc/bus/usb/devices , .I sane\-find\-scanner or syslog) to us. Even if the scanner's name is only slightly different from the models mentioned above, please let us know. .PP .SH CONFIGURATION The contents of the .I hp3900.conf file is a list of usb lines containing vendor and product ids that correspond to USB scanners. The file can also contain the names of device files that correspond to an HP 39XX scanner. Empty lines and lines starting with a hash mark (#) are ignored. The scanners are autodetected by .B usb vendor_id product_id statements which are already included into .IR hp3900.conf . "vendor_id" and "product_id" are hexadecimal numbers that identify the scanner. If autodetection does not work, add the device name of your scanner to the configuration file, .PP .SH FILES .TP .I @CONFIGDIR@/hp3900.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-hp3900.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-hp3900.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "/etc/sane.d" being searched (in this order). .TP .B SANE_DEBUG_HP3900 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_HP3900=4 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .br .I http://sourceforge.net/projects/hp3900\-series/ .I http://jkdsoftware.dyndns.org/drupal/?q=es/books/151 .SH AUTHOR Jonathan Bravo Lopez .SH BUGS Scanning is only tested with Linux/ix86/gcc. Be careful when testing on other operating systems and especially on big-endian platforms. The scanner may get wrong data. sane-backends-1.0.29/doc/sane-scsi.man0000666000000000000000000003025713615534521014337 00000000000000.TH sane\-scsi 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-scsi .SH NAME sane\-scsi \- SCSI adapter tips for scanners .SH DESCRIPTION This manual page contains various operating-system specific tips and tricks on how to get scanners with a SCSI interface working. .SH GENERAL INFO For scanners with a SCSI interface, it may be necessary to edit the appropriate backend configuration file before using SANE for the first time. For most systems, the configuration file should list the name of the generic SCSI device that the scanner is connected to (e.g., under Linux, .B /dev/sg4 or .B /dev/sge is such a generic SCSI device). It is customary to create a symlink from .B /dev/scanner to the generic SCSI device that the scanner is connected to. In this case, the configuration file simply lists the line .BR /dev/scanner . For a detailed description of each backend's configuration file, please refer to the relevant backend manual page (e.g., .BR sane\-epson (5) for Epson scanners, .BR sane\-hp (5) for HP scanners, etc.). .PP For some operating systems (e.g. Linux and OS/2), there is an alternate way of specifying scanner devices. This alternate way allows one to identify scanners by the SCSI vendor and model string and/or by the SCSI device address (consisting of bus number, channel number, id, and logical unit number). The syntax for specifying a scanner in this way is: .PP .RS scsi .I VENDOR MODEL TYPE BUS CHANNEL ID LUN .RE .PP where .I VENDOR is the SCSI vendor string, .I MODEL is the SCSI model string, .I TYPE is type SCSI device type string, .I BUS is the SCSI bus number (named "host" in /proc/scsi/scsi), .I CHANNEL is the SCSI channel number, .I ID is the SCSI id, and .I LUN is the logical unit number of the scanner device. The first two fields are strings which must be enclosed in double-quotes if they contain any whitespace. The remaining four fields are non-negative integer numbers. The correct values for these fields can be found by using operating system specific tools, e.g. for Linux by looking at the output of the command "cat /proc/scsi/scsi". To simplify configuration, a field's value can be replaced with an asterisk symbol (``*''). An asterisk has the effect that any value is allowed for that particular field. This can have the effect that a single scsi-line matches multiple devices. When this happens, each matching device will be probed by the backend one by one and registered if the backend thinks it is a compatible device. For example, the line .PP .RS scsi MUSTEK MFS\-06000CX Scanner 0 00 03 00 .RE .PP would attach the Mustek SCSI scanner with the following /proc/scsi/scsi entry: .PP .RS 2 .ft CR .nf Host: scsi0 Channel: 00 Id: 03 Lun: 00 Vendor: MUSTEK Model: MFS\-06000CX Rev: 4.04 Type: Scanner ANSI SCSI revision: 0 .fi .ft R .RE .PP Usually it's sufficient to use vendor and model strings only or even only the vendor string. The following example .PP .RS scsi MUSTEK * * * * * * .RE .PP would have the effect that all SCSI devices in the system with a vendor string of MUSTEK would be probed and recognized by the backend. .PP If the remainder of a scsi-string consists of asterisks only, the asterisks can be omitted. For example, the following line is equivalent to the one specified previously: .PP .RS scsi MUSTEK .RE .PP On some platforms (e.g., OpenStep), SANE device names take a special form. This is explained below in the relevant platform-specific section. .PP When using a SCSI scanner, ensure that the access permission for the generic SCSI device is set appropriately. We recommend to add a group "scanner" to /etc/group which contains all users that should have access to the scanner. The permission of the device should then be set to allow group read and write access. For example, if the scanner is at generic SCSI device .BR /dev/sg0 , then the following two commands would set the permission correctly: .PP .RS $ chgrp scanner /dev/sg0 .br $ chmod 660 /dev/sg0 .br .RE .PP When your system uses the device filesystem (devfs), you have to edit .BR /etc/devfs/perms. There you should search the line .PP .RS REGISTER ^sg[^/]* PERMISSIONS root.root 0600 .RE .PP and add a new line (eg. for changing permissions of sg4): .PP .RS REGISTER ^sg4 PERMISSIONS root.scanner 0660 .RE .PP .SH FREEBSD INFO Auto-configuration using the "scsi *" lines in the config files only works if the user running the frontend has read/write access to /dev/xpt0. Instead, you can also set a link .I /dev/scanner to the appropriate /dev/uk device. .RS .TP Adaptec AHA1542CF Reported to work fine under FreeBSD 2.2.2R with the .B aha driver. .TP Adaptec 2940 Reported to work fine under FreeBSD 2.2.2. .TP Adaptec 1522 The scanner probes ok but any attempt to access it .I hangs the entire system. It looks like something is disabling interrupts and then not re-enabling them, so it looks like a bug in the FreeBSD .B aic driver. .TP Adaptec 1505 Works on FreeBSD 2.2.5R and 3.0 using the .B aic driver, provided that Plug-and-Play support is disabled on the card. If there are no .I uk devices, just do a ``sh MAKEDEV uk0'' in the .B /dev directory. The scanner should then be accessible as .B /dev/uk0 if it was probed during boot. .TP Tekram DC390 Reported to work fine under FreeBSD 2.2.2R with the .B amd driver. .RE .SH LINUX INFO First, make sure your kernel has SCSI generic support enabled. In ``make xconfig'', this shows up under ``SCSI support->SCSI generic support''. .PP To keep scanning times to a minimum, it is strongly recommended to use a large buffer size for the generic SCSI driver. From SG driver version 2.0 on, the maximum buffer size can be changed at program run time, and there is no restriction in size. This driver version is part of the Linux kernels from version 2.2.7 on. If the new SG driver is available some backends (e.g. sane\-umax, sane\-mustek, sane\-sharp) automatically request larger scsi buffers. If a backend does not automatically request a larger scsi buffer, set the environment variable .B SANE_SG_BUFFERSIZE to the desired buffer size in bytes. It is not recommended to use more than 1 MB, because for large values the probability increases that the SG driver cannot allocate the necessary buffer(s). For ISA cards, even 1 MB might be a too large value. For a detailed discussion of memory issues of the SG driver, see http://www.torque.net/sg. .PP For Linux kernels before version 2.2.7 the size of the buffer is only 32KB. This works, but for many cheaper scanners this causes scanning to be slower by about a factor of four than when using a size of 127KB. Linux defines the size of this buffer by macro .B SG_BIG_BUFF in header file .IR /usr/include/scsi/sg.h . Unless a system is seriously short on memory, it is recommended to increase this value to the maximum legal value of 128*1024-512=130560 bytes. After changing this value, it is necessary to recompile both the kernel (or the SCSI generic module) and the SCSI backends. Keep in mind that this is only necessary with older Linux kernels. .PP A common issue with SCSI scanners is what to do when you booted the system while the scanner was turned off? In such a case, the scanner won't be recognized by the kernel and SANE won't be able to access it. Fortunately, Linux provides a simple mechanism to probe a SCSI device on demand. Suppose you have a scanner connected to SCSI bus 2 and the scanner has a SCSI id of 5. When the system is up and running and the scanner is turned on, you can issue the command: .PP .RS echo "scsi add\-single\-device 2 0 5 0" > /proc/scsi/scsi .RE .PP and the kernel will probe and recognize your scanner (this needs to be done as root). It's also possible to dynamically remove a SCSI device by using the ``remove\-single\-device'' command. For details, please refer to to the SCSI-2.4-HOWTO. .PP Scanners are known to work with the following SCSI adapters under Linux. This list isn't complete, usually any SCSI adapter supported by Linux should work. .PP .RS .TP Acard/Advance SCSI adapters Some old versions of the kernel driver (atp870u.c) cut the inquiry information. Therefore the scanner couldn't be detected correctly. Use a current kernel. .TP Adaptec AHA-1505/AHA-1542/AHA-2940 Reported to work fine with Linux since v2.0. If you encounter kernel freezes or other unexpected behaviour get the latest Linux kernel (2.2.17 seems to work) or reduce SCSI buffer size to 32 kB. .TP ASUS SC200 Reported to work fine with Linux v2.0. .TP BusLogic BT958 To configure the BusLogic card, you may need to follow these instructions (contributed by Jeremy ): During boot, when your BusLogic adapter is being initialized, press Ctrl-B to enter your BusLogic adapter setup. Choose the address which your BusLogic containing your scanner is located. Choose ``SCSI Device Configuration''. Choose ``Scan SCSI Bus''. Choose whatever SCSI id that contains your scanner and then choose ``View/Modify SCSI configuration''. Change ``Negotiation'' to ``async'' and change ``Disconnect'' to ``off''. Press Esc, save, and Esc again until you are asked to reboot. .TP NCR/Symbios 53c400/53c400a or Domex DTC3181E/L/LE (DTCT436/436P) ISA SCSI card This card is supplied by Mustek (and other vendors). It's supported since Linux 2.2. The SCSI cards are supported by the module g_NCR5380. It's necessary to tell the kernel the io port and type of card. Example for a 53c400a: ``modprobe g_NCR5380 ncr_addr=0x280 ncr_53c400a=1''. Once the kernel detects the card, it should work all right. However, while it should work, do not expect good performance out of this card---it has no interrupt line and therefore while a scan is in progress, the system becomes almost unusable. You may change the values of the USLEEP macros in drivers/scsi/g_NCR5380.c. Some documentation is in this file and NCR5380.c. .TP NCR/Symbios 810 For some scanners it may be necessary to disable disconnect/reconnect. To achieve this use the option ncr53c8xx="disc:n". Some people reported that their scanner only worked with the 53c7,8xx driver, not the ncr53c8xx. Try both if you have trouble. .br For Linux kernels before 2.0.33 it may be necessary to increase the SCSI timeout. The default timeout for the Linux kernels before 2.0.33 is 10 seconds, which is way too low when scanning large area. If you get messages of the form ``restart (ncr dead ?)'' in your /var/log/messages file or on the system console, it's an indication that the timeout is too short. In this case, find the line ``if (np->latetime>10)'' in file ncr53c8xx.c (normally in directory /usr/src/linux/drivers/scsi) and change the constant 10 to, say, 60 (one minute). Then rebuild the kernel/module and try again. .TP Tekram DC315 The driver can be downloaded from http://www.garloff.de/kurt/linux/dc395/. For some older scanners it may be necessary to disable all the more advanced features by using e.g. modprobe dc395x_trm dc395x_trm=7,5,1,32. .TP Tekram DC390 Version 1.11 of the Tekram driver seems to work fine mostly, except that the scan does not terminate properly (it causes a SCSI timeout after 10 minutes). The generic AM53C974 also seems to work fine and does not suffer from the timeout problems. .SH SOLARIS, OPENSTEP AND NEXTSTEP INFO Under Solaris, OpenStep and NeXTStep, the generic SCSI device name refers to a SCSI bus, not to an individual device. For example, .B /dev/sg0 refers to the first SCSI bus. To tell SANE which device to use, append the character 'a'+target-id to the special device name. For example, the SCSI device connected to the first SCSI controller and with target-id 0 would be called .BR /dev/sg0a , and the device with target-id 1 on that same bus would be called .BR /dev/sg0b, and so on. .SH ENVIRONMENT .TP .B SANE_DEBUG_SANEI_SCSI If the library was compiled with debug support enabled, this environment variable controls the debug level for the generic SCSI I/O subsystem. E.g., a value of 128 requests all debug output to be printed by the backend. A value of 255 also prints kernel messages from the SCSI subsystem (where available). Smaller levels reduce verbosity. .TP .B SANE_SCSICMD_TIMEOUT sets the timeout value for SCSI commands in seconds. Overriding the default value of 120 seconds should only be necessary for very slow scanners. .SH "SEE ALSO" .BR sane (7), .BR sane\-find\-scanner (1), .BR sane\-"backendname" (5), .BR sane\-usb (5) .SH AUTHOR David Mosberger sane-backends-1.0.29/doc/sane-dc210.man0000666000000000000000000000667613615534521014217 00000000000000.TH sane\-dc210 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-dc210 .SH NAME sane\-dc210 \- SANE backend for Kodak DC210 Digital Camera .SH DESCRIPTION The .B sane\-dc210 library implements a SANE (Scanner Access Now Easy) backend that provides access to the Kodak DC210 camera. THIS IS EXTREMELY ALPHA CODE! USE AT YOUR OWN RISK!! .SH "DEVICE NAMES" The current version of the backend only allows one camera to be connected. The device name is always "0". .SH CONFIGURATION The contents of the .I dc210.conf specify the serial port and baud rate to use. The baud rate specifies the maximum rate to use while downloading pictures. (The camera is always initialized using 9600 baud, then switches to the higher rate). On my 90MHz Pentium, I usually have no problems downloading at 115200 baud as long as the system is not excessively busy and the "interrupt-unmask flag" is set in the IDE driver (hdparm \-u1). Supported baud rates are: 9600, 19200, 38400, 57600, and 115200. .PP The dumpinquiry line causes some information about the camera to be printed. .PP cmdrespause specifies how many usec (1,000,000ths of a) between writing the command and reading the result should be used. 125000 seems to be the lowest I could go reliably. .PP breakpause is the time in 1,000,000ths of a usec between sending the "back to default" break sending commands. .PP Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS port=/dev/ttyS0 .br # this is a comment .br baud=115200 .br dumpinquiry .br cmdrespause=125000 .br breakpause=1000000 .RE .PP .SH FILES .TP .I @CONFIGDIR@/dc210.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-dc210.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-dc210.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_DC210 If the library was compiled with debugging support enabled, this environment variable controls the debug level for this backend. A value of 128 requests maximally copious debug output; smaller levels reduce verbosity. .SH "SEE ALSO" sane(7) .SH AUTHOR Brian J. Murrell .PP This backend is based somewhat on the dc25 backend included in this package by Peter Fales. .PP The manpage was copied from the dc25 backend and somewhat edited by Henning Meier-Geinitz. .SH BUGS Known bugs/limitations are: ? .PP More general comments, suggestions, and inquiries about frontends or SANE should go to the SANE Developers mailing list (see http://www.sane\-project.org/mailing\-lists.html for details). You must be subscribed to the list, otherwise your mail won't be sent to the subscribers. sane-backends-1.0.29/doc/sane-sm3600.man0000666000000000000000000000436213615534521014324 00000000000000.TH sane\-sm3600 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-sm3600 .SH NAME sane\-sm3600 \- SANE backend for Microtek scanners with M011 USB chip .SH DESCRIPTION The .B sane\-sm3600 library implements a SANE (Scanner Access Now Easy) backend that provides access to some Microtek scanners with the Toshiba M011 custom USB chip. This backend should be considered alpha. .PP There are also backends for Microtek scanners with SCSI command set. Refer to sane\-microtek(5) and sane\-microtek2(5) for details. .PP At present, the following scanners are known positively to work with this backend: .PP .RS .ft CR .nf Vendor Product id: Remark: -------- -------------- ----------- Microtek ScanMaker 3600 all modes ok Microtek ScanMaker 3700 reported to work Microtek ScanMaker 3750 reported to work .fi .ft R .RE .PP If you own a Microtek scanner with the M011 chip other than the ones listed above, it may or may not work with SANE! .SH "FRONTEND OPTIONS" This backend dynamically enables the options for the frontend, that are supported by the scanner in dependence of the scanning-mode and other options. Not supported options are disabled. .PP The following options are supported by the Microtek2-driver: .PP Color, grayscale, halftone and lineart scans. .PP contrast, brightness, control, gamma correction. .SH "DEVICE NAMES" This backend does not support device names in a standardized form. .SH CONFIGURATION This backend does not support a configuration file right now. .SH FILES .TP .I @LIBDIR@/libsane\-sm3600.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-sm3600.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_SM3600 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. To see error messages on stderr set SANE_DEBUG_SM3600 to 1. .br E.g. just say: .br export SANE_DEBUG_SM3600=5 .SH "SEE ALSO" sane\-microtek2(5), http://sm3600.sourceforge.net .SH AUTHOR .br Marian Eichholz (eichholz@computer.org) .br Glenn Ramsey (glenn@componic.com) .br sane-backends-1.0.29/doc/sane-umax1220u.man0000666000000000000000000000612513615534521015037 00000000000000.TH sane\-umax1220u 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-umax .SH NAME sane\-umax1220u \- SANE backend for the UMAX Astra 1220U and similar scanners .SH DESCRIPTION The .B sane\-umax1220 library implements a SANE (Scanner Access Now Easy) backend for the the UMAX Astra 1220U and similar scanners. For more information on this backend, please visit .IR http://umax1220u\-sane.sourceforge.net/ . .SH UMAX ASTRA 1600U/2000U/2100U SUPPORT This backend is also able to drive the UMAX Astra 1600U/2000U/2100U. The 2100U is confirmed to work. For the other scanners no reports have been received yet. Please contact us and tell us if your scanner works (sane\-devel@alioth-lists.debian.net). .SH CONFIGURATION Usually, no manual configuration is necessary. The configuration file for this backend resides in .IR @CONFIGDIR@/umax1220u.conf . Its contents is a list of device names that correspond to UMAX Astra scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .nf #usb vendor product usb 0x1606 0x0010 # Device list for non-linux systems /dev/scanner /dev/usb/scanner0 .fi See sane\-usb(5) for information on how to set the access permissions on the usb device files. .SH FILES .TP The backend configuration file: .I @CONFIGDIR@/umax1220u.conf .TP The static library implementing this backend: .I @LIBDIR@/libsane\-umax1220u.a .TP The shared library implementing this backend: .I @LIBDIR@/libsane\-umax1220u.so (present on systems that support dynamic loading) .SH ENVIRONMENT .TP .B SANE_DEBUG_UMAX1220U If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity: SANE_DEBUG_UMAX1220U values .ft CR .nf Number Remark \ 1 print failures 2 print information 3 print high-level function calls 4 print high-level function checkpoints 9 print mid-level function calls 10 print mid-level function checkpoints 80 print protocol-level function entry 90 print protocol-level function exit .fi .ft R .TP Example: export SANE_DEBUG_UMAX1220U=10 .SH KNOWN BUGS 600 dpi scanning may fail for large image sizes. If you keep getting I/O errors, try cycling the power on your scanner to reset it. There is no way to cancel a scan, since the driver ignores sane_cancel(). If you try scanning an image which is too small, you will get I/O errors. Be sure to adjust the scan area before doing a scan, since by default, the scan area is zero. .SH SEE ALSO sane(7), sane\-usb(5) .TP (Old) homepage: .I http://umax1220u\-sane.sourceforge.net/ .SH AUTHOR Marcio Luis Teixeira .SH EMAIL-CONTACT sane\-devel@alioth-lists.debian.net .SH REPORTING BUGS This backend isn't actively maintained. Nevertheless, bug reports and comments should be sent to the sane\-devel mailing list. When reporting bugs, please run the backend with SANE_DEBUG_UMAX1220U set to 10 and attach a copy of the log messages. sane-backends-1.0.29/doc/sane-agfafocus.man0000666000000000000000000001267713615534521015342 00000000000000.TH sane\-agfafocus 5 "10 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-agfafocus .SH NAME sane\-agfafocus \- SANE backend for AGFA Focus flatbed scanners .SH DESCRIPTION The .B sane\-agfafocus library implements a SANE (Scanner Access Now Easy) backend that provides access to AGFA Focus flatbed scanners. At present, the following scanners are supported from this backend: .PP .RS AGFA Focus GS Scanner (6 bit gray scale) (untested) .br AGFA Focus Lineart Scanner (lineart) (untested) .br AGFA Focus II (8 bit gray scale) (untested) .br AGFA Focus Color (24 bit color 3-pass) .br AGFA Focus Color Plus (24 bit color 3-pass) .br .PP Siemens S9036 (8 bit gray scale) (untested) .br .RE .PP The driver supports line art, 6bpp and 8bpp gray, 18bpp and 24bpp color scans. .PP If you own a scanner other than the ones listed above that works with this backend, please let us know by sending the scanner's model name, SCSI id, and firmware revision to .IR sane\-devel@alioth-lists.debian.net . Have a look at http://www.sane\-project.org/mailing\-lists.html concerning subscription to sane\-devel. .PP All of these scanners are pre-SCSI-2, and do not even report properly to SCSI Inquiry. This is typically evident in SCSI bus scans, where the scanner will come up with only garbage as vendor and models strings. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is either the path-name for the special device that corresponds to a SCSI scanner. For SCSI scanners, the special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. See sane\-scsi(5) for details. .SH CONFIGURATION The contents of the .I agfafocus.conf file is a list of device names that correspond to AGFA Focus scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS /dev/scanner .br # this is a comment .br /dev/sge .RE .PP .SH FILES .TP .I /etc/sane.d/agfafocus.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I /usr/lib/libsane\-agfafocus.a The static library implementing this backend. .TP .I /usr/lib/libsane\-agfafocus.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in /etc/sane.d. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "/etc/sane.d" being searched (in this order). .TP .B SANE_DEBUG_AGFAFOCUS If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. SANE_DEBUG_AGFAFOCUS values: .sp .ft CR .nf Number Remark \ 0 print important errors (printed each time) 1 print errors 2 print sense 3 print warnings 4 print scanner-inquiry 5 print information 6 print less important information 7 print called procedures 8 print reader_process messages 10 print called sane\-init-routines 11 print called sane\-procedures 12 print sane infos 13 print sane option-control messages .fi .ft R .SH MISSING FUNCTIONALITY Uploading of dither matrices and tonecurves has been implemented, but so far has not proven to be useful for anything. For this reason these options have been disabled. .SH BUGS The scanners that do not support disconnect have problems with SCSI timeouts if the SCSI bus gets loaded, eg. if you do a kernel build at the same time as scanning. To see if your scanner supports disconnect, run "SANE_DEBUG_AGFAFOCUS=128 scanimage \-L" in sh and look for the "disconnect:" line) .SH DEBUG If you have problems with SANE not detecting your scanner, make sure the Artec backend is disabled. Somehow, this backend causes at least my scanner not to respond correctly to SCSI inquiry commands. .PP If you encounter a bug please set the environment variable SANE_DEBUG_AGFAFOCUS to 128 and try to regenerate the problem. Then send me a report with the log attached. .PP If you encounter a SCSI bus error or trimmed and/or displaced images please also set the environment variable SANE_DEBUG_SANEI_SCSI to 128 before sending me the report. .SH TODO .TP .B More scanners? The AGFA ACS and ARCUS scanners are similar to the FOCUS scanners. The driver could probably be extended to support these scanners without too many changes. I do not have access to such scanners, and cannot add support for it. However, if you are in possession of such a scanner, I could be helpful in adding support for these scanners. The AGFA HORIZON scanners are SCSI-2 scanners, and it would probably be easier to support these scanners in a SCSI-2 compliant backend. .SH SEE ALSO sane(7), sane\-scsi(5) .SH AUTHOR Ingo Schneider and Karl Anders \[/O]ygard. sane-backends-1.0.29/doc/sane-rts8891.man0000666000000000000000000001054213615534521014533 00000000000000.TH "sane\-rts8891" "5" "8 Dec 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .SH "NAME" sane\-rts8891 \- SANE backend for rts8891 based scanners .SH "DESCRIPTION" The .B sane\-rts8891 library implements a SANE (Scanner Access Now Easy) backend that provides access to scanners based on the rts8891 ASIC. .PP The scanners that work with this backend are: .PP .RS .ft CR .nf Vendor Model status \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\- Umax Astra 4400 untested Umax Astra 4450 untested HP scanjet 4000c good HP scanjet 4470c good .fi .ft R .RE The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage or xsane. .br If you have any strange behavior, please report to the backend maintainer or to the SANE mailing list. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d rts8891 .RE .TP .B Scan Mode Options .TP .B \-\-mode selects the basic mode of operation of the scanner valid choices are .I R Color , .I Gray and .I Lineart The default mode is Color. The Lineart mode is black and white only (1 bit). Grayscale will produce 256 levels of gray (8 bits). Color mode allows for over 16 million different colors produced from 24 bits of color information. .TP .B \-\-resolution selects the resolution for a scan. The horizontal and vertical resolutions are set by the value of this option. The scanner is capable of the following resolutions for the specified option value: .PP .RS .ft CR .nf Value Hor. Resolution Vert. Resolution \-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- 75 75dpi 75dpi 150 150dpi 150dpi 300 300dpi 300dpi 600 600dpi 600dpi 1200 1200dpi 1200dpi .fi .ft R .RE .TP .B \-\-preview requests a preview scan. The resolution used for that scan is 75 dpi and the scan area and the scan mode are as specified through their options, or the default if not specified. The default value for preview mode is "no". .TP .B \-\-threshold selects the minimum\-brightness to get a white point. The threshold is only used with Lineart mode scans. It is specified as a percentage in the range 0..100% (in steps of 1). The default value of the threshold option is 50. .SH "CONFIGURATION FILE" The configuration file .B @CONFIGDIR@/rts8891.conf contains the usb device ids of supported scanners (eg usb 0x043d 0x007c) and scanner configuration options. Empty lines and lines starting with a hash mark (#) are ignored. .PP The options supported are .B allowsharing , .B modelnumber . Option .PP .B allowsharing enables or not the sharing of the scanner between multiple frontends at the same time. .PP .B modelnumber is used to force the reported model by the backend and is only useful in the case of a scanner which NVRAM has been erased. .RS .ft CR .nf 0 to report a HP4470c. 1 to report a HP4400c. 2 to report an Astra 4400. .fi .ft R .RE .PP .SH "FILES" .TP .I @LIBDIR@/libsane\-rts8891.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-rts8891.so The shared library implementing this backend (present on systems that support dynamic loading). .SH "ENVIRONMENT" .TP .B SANE_DEBUG_RTS8891 SANE_DEBUG_RTS8891_LOW SANE_DEBUG_RTS88XX_LIB If the library was compiled with debug support enabled, these environment variables controls the debug level for this backend. E.g., a value of 255 requests all debug output to be printed. Smaller levels reduce verbosity. .SH "LIMITATIONS" Scanners of the same model exist with different sensors, due to lack of data (ie USB logs) some sensors are better supported than others. At least 75 dpi mode is working for any model. Sharing the scanner between several frontends at the same time (allowsharing option) may not work on some USB controllers. .PP XPA is no (yet) supported. .SH "BUGS" .br No bugs currently known. .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1), sane(7) .SH "AUTHOR" .TP This backend has been developed by St\['e]phane Voltz. .I http://stef.dev.free.fr/sane/rts8891 .SH "CREDITS" .TP Many thanks go to: Laurent Fournier who donated me a HP4470c. Vladimir Sysoev and "TheUnruly Squash" for the time they spent recording USB activity and testing the experimental version on HP4400 models. sane-backends-1.0.29/doc/Makefile.am0000666000000000000000000003565213615534521014015 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2009 Chris Bagwell and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. man1_MANS = scanimage.1 sane-config.1 sane-find-scanner.1 gamma4scanimage.1 EXTRA_DIST = scanimage.man sane-config.man sane-find-scanner.man \ gamma4scanimage.man # Create a list of man pages for only backends that are compiled in so # that is all that gets installed. Also, build a complete list of all # backend man pages. This allows a user to optionally generate all # man pages in HTML form for things like posting to a web site. # # Backend man pages bypass standard automake man5_MANS because there is not # a man page for every supported backend. We could get rid of # custom install/uninstall if we required man pages for every backend. BACKEND_5MANS = sane-abaton.5 sane-agfafocus.5 sane-apple.5 sane-as6e.5 \ sane-dll.5 sane-dc25.5 sane-dmc.5 sane-epson.5 sane-epson2.5 sane-epsonds.5 \ sane-escl.5 sane-hp.5 sane-gphoto2.5 sane-leo.5 sane-lexmark.5 \ sane-matsushita.5 sane-microtek.5 sane-microtek2.5 sane-mustek.5 \ sane-nec.5 sane-net.5 sane-pie.5 sane-pieusb.5 sane-pint.5 sane-pnm.5 \ sane-umax.5 sane-qcam.5 sane-scsi.5 sane-artec.5 sane-kodak.5 sane-kodakaio.5 \ sane-fujitsu.5 sane-sharp.5 sane-s9036.5 sane-tamarack.5 \ sane-ricoh.5 sane-ricoh2.5 sane-avision.5 sane-plustek.5 sane-st400.5 \ sane-mustek_pp.5 sane-dc210.5 sane-v4l.5 sane-snapscan.5 \ sane-canon.5 sane-coolscan.5 sane-bh.5 sane-dc240.5 \ sane-umax_pp.5 sane-umax1220u.5 sane-sm3600.5 sane-usb.5 \ sane-mustek_usb.5 sane-sceptre.5 sane-canon_pp.5 sane-canon630u.5 \ sane-teco1.5 sane-teco2.5 sane-teco3.5 sane-test.5 sane-sp15c.5 \ sane-coolscan2.5 sane-hpsj5s.5 sane-gt68xx.5 sane-artec_eplus48u.5 \ sane-ma1509.5 sane-ibm.5 sane-hp5400.5 sane-plustek_pp.5 sane-u12.5 \ sane-niash.5 sane-sm3840.5 sane-genesys.5 sane-hp4200.5 \ sane-mustek_usb2.5 sane-hp3500.5 sane-pixma.5 sane-stv680.5 \ sane-hp5590.5 sane-hpljm1005.5 sane-cardscan.5 sane-hp3900.5 \ sane-epjitsu.5 sane-hs2p.5 sane-canon_dr.5 sane-xerox_mfp.5 \ sane-rts8891.5 sane-coolscan3.5 sane-kvs1025.5 sane-kvs20xx.5 \ sane-kvs40xx.5 sane-p5.5 sane-magicolor.5 EXTRA_DIST += sane-abaton.man sane-agfafocus.man sane-apple.man sane-as6e.man \ sane-dll.man sane-dc25.man sane-dmc.man sane-epson.man \ sane-epson2.man sane-epsonds.man sane-escl.man sane-hp.man sane-gphoto2.man \ sane-leo.man sane-lexmark.man sane-matsushita.man sane-microtek.man \ sane-microtek2.man sane-mustek.man sane-nec.man sane-net.man \ sane-pie.man sane-pieusb.man sane-pint.man sane-pnm.man sane-umax.man \ sane-qcam.man sane-scsi.man sane-artec.man sane-fujitsu.man \ sane-sharp.man sane-s9036.man sane-tamarack.man sane-kodak.man sane-kodakaio.man\ sane-ricoh.man sane-ricoh2.man sane-avision.man sane-plustek.man sane-st400.man \ sane-mustek_pp.man sane-dc210.man sane-v4l.man sane-snapscan.man \ sane-canon.man sane-coolscan.man sane-bh.man sane-dc240.man \ sane-umax_pp.man sane-umax1220u.man sane-sm3600.man sane-usb.man \ sane-mustek_usb.man sane-sceptre.man sane-canon_pp.man \ sane-canon630u.man sane-teco1.man sane-teco2.man \ sane-teco3.man sane-test.man sane-sp15c.man sane-coolscan2.man \ sane-hpsj5s.man sane-gt68xx.man sane-artec_eplus48u.man \ sane-ma1509.man sane-ibm.man sane-hp5400.man sane-plustek_pp.man \ sane-u12.man sane-niash.man sane-sm3840.man sane-genesys.man \ sane-hp4200.man sane-mustek_usb2.man sane-hp3500.man \ sane-pixma.man sane-stv680.man sane-hp5590.man sane-hpljm1005.man \ sane-cardscan.man sane-hp3900.man sane-epjitsu.man sane-hs2p.man \ sane-canon_dr.man sane-xerox_mfp.man sane-rts8891.man \ sane-coolscan3.man sane-kvs1025.man sane-kvs20xx.man sane-kvs40xx.man \ sane-p5.man sane-magicolor.man man7_MANS = sane.7 EXTRA_DIST += sane.man man8_MANS = saned.8 EXTRA_DIST += saned.man MANPAGES = $(man1_MANS) $(BACKEND_5MANS) $(man7_MANS) $(man8_MANS) if CROSS_COMPILING HTML_PAGES = else HTML_PAGES = sane-backends.html sane-backends-external.html \ sane-mfgs.html sane-mfgs-external.html endif doc_DATA = $(HTML_PAGES) all: bemans $(API_SPECS) html-pages dist_doc_DATA = backend-writing.txt nobase_dist_doc_DATA = $(BEDOCS) doc_DATA += $(API_SPECS) EXTRA_DIST += descriptions.txt releases.txt sane-logo2.jpg sane-logo.png \ sane.png MAN2HTML = nroff -c -man |\ man2html -compress -topm 6 -botm 6 -nodepage -title $${page} \ -cgiurl '$$title.$$section.html'|\ sed 's,,

,' %.1 %.5 %.7 %.8: %.man @echo "Generating manpage $@..."; @sed -e 's|@DATADIR@|$(datadir)|g' \ -e 's|@CONFIGDIR@|$(configdir)|g' \ -e 's|@DOCDIR@|$(docdir)|g' \ -e 's|@LIBDIR@|$(libdir)/sane|g' \ -e 's|@BINDIR@|$(bindir)|g' \ -e 's|@SBINDIR@|$(sbindir)|g' \ -e 's|@PACKAGEVERSION@|$(package_version)|g' $^ >$@ bemans: $(BACKEND_5MANS) beman5dir = $(mandir)/man5 install-beman5: $(BACKEND_5MANS) test -z "$(beman5dir)" || $(MKDIR_P) "$(DESTDIR)$(beman5dir)" @list="$(BACKEND_MANS_ENABLED) sane-dll.5 sane-scsi.5 sane-usb.5"; for man in $$list; do \ if test ! -r $${man}; then continue; fi; \ echo "installing $${man} in $(beman5dir)/$${man}..."; \ $(INSTALL_DATA) $${man} $(DESTDIR)$(beman5dir)/$${man} \ || exit 1; \ done BEDOCS = canon/canon.changes canon/canon.install2700F.txt BEDOCS += gt68xx/gt68xx.CHANGES gt68xx/gt68xx.TODO BEDOCS += leo/leo.txt BEDOCS += matsushita/matsushita.txt BEDOCS += mustek/mustek.CHANGES BEDOCS += mustek_usb/mustek_usb.CHANGES mustek_usb/mustek_usb.TODO BEDOCS += mustek_usb2/mustek_usb2.CHANGES mustek_usb2/mustek_usb2.TODO BEDOCS += niash/niash.TODO BEDOCS += plustek/FAQ plustek/MakeModule.sh plustek/Makefile.kernel24 \ plustek/Makefile.kernel26 plustek/Plustek-PARPORT-TODO.txt \ plustek/Plustek-PARPORT.changes plustek/Plustek-PARPORT.txt \ plustek/Plustek-USB-TODO.txt plustek/Plustek-USB.changes \ plustek/Plustek-USB.txt BEDOCS += sceptre/s1200.txt BEDOCS += teco/teco1.txt teco/teco2.txt teco/teco3.txt BEDOCS += u12/U12.changes u12/U12.todo BEDOCS += umax/negative-types.txt umax/sane-logo.jpg \ umax/sane-umax-advanced-options-doc.html \ umax/sane-umax-advanced.jpg umax/sane-umax-astra-doc.html \ umax/sane-umax-config-doc.html umax/sane-umax-doc.html \ umax/sane-umax-histogram.jpg umax/sane-umax-mirage-doc.html \ umax/sane-umax-not-listed-doc.html umax/sane-umax-others-doc.html \ umax/sane-umax-parport-doc.html umax/sane-umax-powerlook-doc.html \ umax/sane-umax-scanner-clones-doc.html umax/sane-umax-speed-doc.html \ umax/sane-umax-standard-options-doc.html \ umax/sane-umax-standard.jpg umax/sane-umax-text.jpg \ umax/sane-umax-text2.jpg umax/sane-umax-text4.jpg \ umax/sane-umax-uc-doc.html umax/sane-umax-vista-doc.html \ umax/sane-umax.jpg umax/umax.BUGS umax/umax.CHANGES umax/umax.FAQ \ umax/umax.TODO DESC_FILES = descriptions/abaton.desc descriptions/agfafocus.desc \ descriptions/apple.desc descriptions/artec.desc \ descriptions/artec_eplus48u.desc descriptions/as6e.desc \ descriptions/avision.desc descriptions/bh.desc descriptions/canon630u.desc \ descriptions/canon.desc descriptions/canon_dr.desc \ descriptions/canon_pp.desc descriptions/cardscan.desc \ descriptions/coolscan2.desc descriptions/coolscan.desc \ descriptions/coolscan3.desc \ descriptions/dc210.desc descriptions/dc240.desc descriptions/dc25.desc \ descriptions/dell1600n_net.desc descriptions/dll.desc descriptions/dmc.desc \ descriptions/epjitsu.desc descriptions/epson2.desc descriptions/epson.desc \ descriptions/epsonds.desc descriptions/escl.desc \ descriptions/fujitsu.desc descriptions/genesys.desc \ descriptions/gphoto2.desc descriptions/gt68xx.desc descriptions/hp3500.desc \ descriptions/hp3900.desc descriptions/hp4200.desc descriptions/hp5400.desc \ descriptions/hp5590.desc descriptions/hp.desc descriptions/hpljm1005.desc \ descriptions/hpsj5s.desc descriptions/hs2p.desc descriptions/ibm.desc \ descriptions/kodak.desc descriptions/kodakaio.desc descriptions/kvs1025.desc \ descriptions/kvs20xx.desc descriptions/kvs40xx.desc \ descriptions/leo.desc descriptions/lexmark.desc descriptions/ma1509.desc \ descriptions/magicolor.desc \ descriptions/matsushita.desc descriptions/microtek2.desc \ descriptions/microtek.desc descriptions/mustek.desc \ descriptions/mustek_pp.desc descriptions/mustek_usb2.desc \ descriptions/mustek_usb.desc descriptions/nec.desc descriptions/net.desc \ descriptions/niash.desc descriptions/pie.desc descriptions/pieusb.desc descriptions/pint.desc \ descriptions/p5.desc descriptions/pixma.desc descriptions/plustek.desc \ descriptions/plustek_pp.desc descriptions/pnm.desc descriptions/qcam.desc \ descriptions/ricoh.desc descriptions/ricoh2.desc \ descriptions/rts8891.desc descriptions/s9036.desc \ descriptions/sceptre.desc descriptions/sharp.desc descriptions/sm3600.desc \ descriptions/sm3840.desc descriptions/snapscan.desc descriptions/sp15c.desc \ descriptions/st400.desc descriptions/stv680.desc descriptions/tamarack.desc \ descriptions/teco1.desc descriptions/teco2.desc descriptions/teco3.desc \ descriptions/test.desc descriptions/u12.desc \ descriptions/umax1220u.desc descriptions/umax.desc \ descriptions/umax_pp.desc descriptions/unsupported.desc \ descriptions/v4l.desc descriptions/xerox_mfp.desc EXTRA_DIST += $(DESC_FILES) descriptions/template.desc. DESC_EXT_FILES = descriptions-external/brother2.desc \ descriptions-external/brother.desc \ descriptions-external/brother-mfc4600.desc \ descriptions-external/cs3200f.desc \ descriptions-external/epkowa.desc \ descriptions-external/geniusvp2.desc \ descriptions-external/hp3770.desc \ descriptions-external/hp8200.desc \ descriptions-external/hpaio.desc \ descriptions-external/hpoj.desc \ descriptions-external/kodak-twain.desc \ descriptions-external/lhii.desc \ descriptions-external/mustek_a3p1.desc \ descriptions-external/panamfs.desc \ descriptions-external/primascan.desc \ descriptions-external/primax.desc \ descriptions-external/samsung.desc \ descriptions-external/scangearmp2.desc \ descriptions-external/scanwit.desc \ descriptions-external/utsushi.desc \ descriptions-external/v4l2.desc \ descriptions-external/viceo.desc EXTRA_DIST += $(DESC_EXT_FILES) descriptions-external/template.desc. install-data-local: install-beman5 uninstall-local: rm -rf $(DESTDIR)$(beman5dir)/sane-*.5 ## SANE API specification format conversion support API_SPECS = if WITH_API_PS API_SPECS += sane.ps endif if WITH_API_PDF API_SPECS += sane.pdf endif if WITH_API_HTML API_SPECS += sane-html endif API_SPEC_INPUTS = $(srcdir)/sane.tex API_SPEC_INPUTS += $(srcdir)/net.tex EXTRA_DIST += $(API_SPEC_INPUTS) API_SPEC_TEX_FIGS = API_SPEC_TEX_FIGS += figs/area.fig API_SPEC_TEX_FIGS += figs/flow.fig API_SPEC_TEX_FIGS += figs/hierarchy.fig API_SPEC_TEX_FIGS += figs/image-data.fig API_SPEC_TEX_FIGS += figs/xfer.fig EXTRA_DIST += $(API_SPEC_TEX_FIGS) API_SPEC_EPS_FIGS = API_SPEC_EPS_FIGS += figs/area.eps API_SPEC_EPS_FIGS += figs/flow.eps API_SPEC_EPS_FIGS += figs/hierarchy.eps API_SPEC_EPS_FIGS += figs/image-data.eps API_SPEC_EPS_FIGS += figs/xfer.eps API_SPEC_PDF_FIGS = API_SPEC_PDF_FIGS += figs/area.pdf API_SPEC_PDF_FIGS += figs/flow.pdf API_SPEC_PDF_FIGS += figs/hierarchy.pdf API_SPEC_PDF_FIGS += figs/image-data.pdf API_SPEC_PDF_FIGS += figs/xfer.pdf ## These icons are referred to in the generated HTML output. API_SPEC_HTML_ICONS = API_SPEC_HTML_ICONS += icons/contents.gif API_SPEC_HTML_ICONS += icons/index.gif API_SPEC_HTML_ICONS += icons/next.gif icons/next_gr.gif API_SPEC_HTML_ICONS += icons/previous.gif icons/previous_gr.gif API_SPEC_HTML_ICONS += icons/references.gif icons/references_gr.gif API_SPEC_HTML_ICONS += icons/up.gif icons/up_gr.gif EXTRA_DIST += $(API_SPEC_HTML_ICONS) am_TEXINPUTS = TEXINPUTS="$(builddir):$(srcdir):$$TEXINPUTS" sane.ind: $(API_SPEC_INPUTS) @echo Generating index for $<... @touch sane.ind @$(am_TEXINPUTS) $(LATEX) $< /dev/null && \ $(MAKEINDEX) -q sane.idx && \ $(am_TEXINPUTS) $(LATEX) $< /dev/null .fig.eps: @test -d $(@D) || $(MKDIR_P) $(@D) $(FIG2DEV) -L eps $< $@ sane.dvi: $(API_SPEC_INPUTS) $(API_SPEC_EPS_FIGS) sane.ind @echo Generating $@ from $<... @$(am_TEXINPUTS) $(LATEX) $< /dev/null sane.ps: sane.dvi @echo Generating $@ from $<... @$(am_TEXINPUTS) $(DVIPS) -q $< -o $@ .fig.pdf: @test -d $(@D) || $(MKDIR_P) $(@D) $(FIG2DEV) -L pdf $< $@ sane.pdf: $(API_SPEC_INPUTS) $(API_SPEC_PDF_FIGS) sane.ind @echo Generating $@ from $<... @$(am_TEXINPUTS) $(PDFLATEX) $< >/dev/null sane-html: sane.dvi $(am_TEXINPUTS) $(DLH) $(srcdir)/sane.tex ## ^^ html-man: $(MANPAGES) @for page in $(MANPAGES); do \ echo "translating $${page} to $${page}.html..."; \ cat $${page} | $(MAN2HTML) > $${page}.html; \ done ../tools/sane-desc: cd ../tools ; $(MAKE) sane-desc sane-backends.html: $(DESC_FILES) ../tools/sane-desc @../tools/sane-desc -m html-backends-split -s ${srcdir}/descriptions \ -i "The following table summarizes the backends/drivers distributed \ with $(PACKAGE)-$(VERSION), and the hardware or software they \ support." -d 0 > sane-backends.html sane-backends-external.html: $(DESC_EXT_FILES) ../tools/sane-desc @../tools/sane-desc -m html-backends-split \ -s ${srcdir}/descriptions-external \ -i "The following table summarizes the backends/drivers that \ have not yet been included in the SANE distribution, and the \ hardware or software they support." \ -t "SANE: External Backends (Drivers)" -d 0 \ > sane-backends-external.html sane-mfgs.html: $(DESC_FILES) ../tools/sane-desc @../tools/sane-desc -m html-mfgs -s ${srcdir}/descriptions \ -i "The following table summarizes the devices supported \ by $(PACKAGE)-$(VERSION)." \ -d 0 > sane-mfgs.html sane-mfgs-external.html: $(DESC_EXT_FILES) ../tools/sane-desc @../tools/sane-desc -m html-mfgs -s ${srcdir}/descriptions-external \ -i "The following table summarizes the devices that \ are supported by external backends." \ -t "SANE: Devices Supported by External Backends" -d 0 \ > sane-mfgs-external.html descriptions.db: $(DESC_FILES) ../tools/sane-desc @../tools/sane-desc -m ascii -s ${srcdir}/descriptions \ > descriptions.db descriptions-external.db: $(DESC_EXT_FILES) ../tools/sane-desc @../tools/sane-desc -m ascii -s ${srcdir}/descriptions-external \ > descriptions-external.db html-pages: $(HTML_PAGES) html-local: html-pages html-man sane-html clean-local: rm -f *.toc *.aux *.log *.cp *.fn *.tp *.vr *.pg *.ky *.blg *.idx *.cb rm -f *.ilg rm -f $(API_SPEC_EPS_FIGS) $(API_SPEC_PDF_FIGS) -rmdir figs distclean-local: rm -f $(MANPAGES) rm -f *.lot *.lof *.ind rm -f sane.dvi sane.ps sane-backends.html sane-backends-external.html rm -f sane-mfgs.html sane-mfgs-external.html rm -f sane/*.html sane/*.gif rm -f doxygen-sanei.conf doxygen-genesys.conf -rm -rf sane sanei-html for manpage in $(MANPAGES) ; do \ rm -f $${manpage}.html ; \ done sane-backends-1.0.29/doc/sane-dmc.man0000666000000000000000000001132013615534521014127 00000000000000.TH sane\-dmc 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-dmc .SH NAME sane\-dmc \- SANE backend for the Polaroid Digital Microscope Camera .SH DESCRIPTION The .B sane\-dmc library implements a SANE (Scanner Access Now Easy) backend that provides access to the Polaroid Digital Microscope Camera. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the UNIX path-name for the special device that corresponds to the scanner. The special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. .SH IMAGING MODES The Polaroid DMC supports a number of imaging modes. This driver supports five of the imaging modes: .PP .TP .B Full Frame This mode corresponds to the 801-by-600 pixel full-color full-frame image. .TP .B Viewfinder This mode corresponds to the 270-by-201 pixel grey-scale viewfinder image. This image is acquired very quickly. .TP .B Raw This mode corresponds to the 1599-by-600 pixel "raw" image from the CCD. It is grey-scale, with pixels alternating horizontally between red, green and blue stripes. The pixels are twice as high as they are wide, so the image is distorted. .TP .B Thumbnail This mode corresponds to the 80-by-60 pixel full-color thumbnail image. .TP .B Super Resolution This image is a 1599-by-1200 pixel full-color image constructed by filtering and interpolating the "raw" image. The filtering and interpolation is done in software, so this mode is very slow. Also, this mode places restrictions on how the image is read which means that the "preview" mode of xscanimage does not work in Super Resolution mode. (xcam and the non-preview modes of scanimage and xscanimage work fine, however.) .PP .SH OTHER SETTINGS .TP .B ASA Setting This setting adjusts the camera's sensitivity. You can choose one of 25, 50, or 100 "equivalent" ASA. .TP .B Shutter Speed You can select a shutter speed from 8 to 1000 milliseconds. The shutter speed is quantized in units of 32 microseconds. .TP .B White Balance You can choose one of "Daylight", "Incandescent" or "Fluorescent" white balances. This setting more-or-less corresponds to the "Color Temperature" settings on Polaroid's Windows and Mac software. .SH CONFIGURATION The contents of the .I dmc.conf file is a list of device names that correspond to DMC scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS /dev/scanner .br # this is a comment .br /dev/sge .RE .SH FILES .TP .I @CONFIGDIR@/dmc.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-dmc.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-dmc.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_DMC If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH BUGS In the "Full Frame" and "Raw" modes, images must be read in units of entire lines. The driver performs no buffering in these modes; if you ask sane_read to read a non-integral number of lines, it may read less than you ask for. If you ask sane_read to read less than a single line, it returns SANE_STATUS_INVAL. .PP In the "Super Resolution" mode, images must be read in units of \fItwo\fR lines (3198 pixels or 9594 bytes.) If you try to read less than two lines, you get SANE_STATUS_INVAL. The Super Resolution mode is very slow. .PP In the "Viewfinder" and "Thumbnail" modes, the entire image must be read in one SCSI transfer. In this case, the driver performs buffering and you can read the image in as small an increment as you like. .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHOR David F. Skoll .PP The backend is derived from .BR sane\-hp by David Mosberger sane-backends-1.0.29/doc/sane-apple.man0000666000000000000000000002250413615534521014473 00000000000000.TH sane\-apple 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-apple .SH NAME sane\-apple \- SANE backend for Apple flatbed scanners .SH DESCRIPTION The .B sane\-apple library implements a SANE (Scanner Access Now Easy) backend that provides access to Apple flatbed scanners. At present, the following scanners are supported from this backend: .PP .br .ft CR .nf --------------- ----- ------------------ ------ AppleScanner 4bit 16 Shades of Gray OneScanner 8bit 256 Shades of Gray ColorOneScanner 24bit RGB color 3-pass .fi .ft R .PP If you own a Apple scanner other than the ones listed above that works with this backend, please let us know by sending the scanner's model name, SCSI id, and firmware revision to .IR sane\-devel@alioth-lists.debian.net . See http://www.sane\-project.org/mailing\-lists.html for details on how to subscribe to sane\-devel. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is either the path-name for the special device that corresponds to a SCSI scanner. For SCSI scanners, the special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. See sane\-scsi(5) for details. .SH CONFIGURATION The .I apple.conf file is a list of options and device names that correspond to Apple scanners. Empty lines and lines starting with a hash mark (#) are ignored. See sane\-scsi(5) on details of what constitutes a valid device name. .PP Options come in two flavors: global and positional ones. Global options apply to all devices managed by the backend, whereas positional options apply just to the most recently mentioned device. Note that this means that the order in which the options appear matters! .SH SCSI ADAPTER TIPS SCSI scanners are typically delivered with an ISA SCSI adapter. Unfortunately, that adapter is not worth much since it is not interrupt driven. It is sometimes possible to get the supplied card to work, but without an interrupt line, scanning will put so much load on the system that it becomes almost unusable for other tasks. .SH FILES .TP .I @CONFIGDIR@/apple.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-apple.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-apple.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable is list of directories where SANE looks for the configuration file. Under UNIX directory names are separated by a colon (`:'), under OS/2 by a semi-colon (`;'). If SANE_CONFIG_DIR is not set, SANE defaults to searching the current working directory (".") and then /etc/sane.d. If the value of $SANE_CONFIG_DIR ends with the separator character, the default directories are searched after the directory list. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in that order). .TP .B SANE_DEBUG_APPLE Controls the debug level. A value of 255 prints all debug output. Smaller values reduce verbosity. Requires a library compiled with debug support. .SH CURRENT STATUS The apple backend is now in version 0.3 (Tue Jul 21 1998). Since I only have the AppleScanner and not the other models (OneScanner, ColorOneScanner) I can only develop/test for the AppleScanner effectively. However with this release I almost completed the gui part of all scanners. Most of the functionality is there. At least OneScanner should scan at the AppleScanner's compatible modes (LineArt, HalfTone, Gray16). My personal belief is that with a slight touch of debugging the OneScanner could be actually usable. The ColorOneScanner needs more work. AppleScanner is of course almost fully supported. .SH MISSING FUNCTIONALITY Currently all three models lack upload/download support. .TP .B AppleScanner Cannot up/download a halftone pattern. .TP .B OneScanner Cannot up/download halftone patterns or calibration vectors. .TP .B ColorOneScanner Cannot up/download halftone patterns, calibration vectors, custom Color Correction Tables (CCT) and of course custom gamma tables. .TP .B Park/UnPark (OneScanner, ColorOneScanner) Some capabilities are missing. .PP The above functionalities are missing because I don't have the hardware to experiment on. Another reason is my lack of understanding as to how or if the SANE API provide means to describe any array type besides gamma. .SH UNSUPPORTED FEATURES The following "features" will never be supported, at least while I maintain the sane\-apple backend. .TP .B NoHome (AppleScanner) The scanner lamp stays on and the carriage assembly remains where it stops at the end of the scan. After two minutes, if the scanner does not receive another SCAN command, the lamp goes off and the carriage returns to the home position. .TP .B Compression (AppleScanner) The Scanner can compress data with CCITT Group III one dimensional algorithm (fax) and the Skip White Line algorithm. .TP .B Multiple Windows (AppleScanner) AppleScanner may support multiple windows. It would be a cool feature and a challenge for me to code if it could intermix different options for different windows (scan areas). This way it could scan a document in LineArt mode but the figures in it in Gray and at a different resolution. Unfortunately this is impossible. .TP .B Scan Direction (OneScanner) It controls the scan direction. (?) .TP .B Status/Reset Button (OneScanner) This option controls the status of the button on the OneScanner model. You can also reset the button status by software. .SH BUGS SANE backend bugs are divided in two classes. We have .B GUI bugs and .B scanner specific bugs. .PP We know we have a GUI bug when a parameter is not showing up when it should (active) or vice versa. Finding out which parameters are active across various Apple modes and models from the documentation .B ftp://ftpdev.info.apple.com/devworld/Technical_Documentation/Peripherals_Documentation/ is an interesting exercise. I may have missed some dependencies. For example of the threshold parameter the Apple Scanners Programming Guide says nothing. I had to assume it is valid only in LineArt mode. .PP Scanner specific bugs are mostly due to mandatory round-offs in order to scan. In the documentation in one place states that the width of the scan area should be a byte multiple. In another place it says that the width of the scan area should be an even byte multiple. Go figure... .PP Other sources of bugs are due to scsi communication, scsi connects and disconnects. However the classical bugs are still there. So you may encounter buffer overruns, null pointers, memory corruption and .B SANE API violations. .TP .B SIGSEGV on SliceBars When you try to modify the scan area from the slice bar you have a nice little cute core dump. I don't know why. If you select the scan area from the preview window or by hand typing the numbers everything is fine. The SIGSEGV happens deep in gtk library (gdk). I really cannot debug it. .TP .B Options too much It is possible, especially for the ColorOneScanner, for the backend's options panel to extend beyond your screen. It happens with mine and I am running my X Server at 1024x768. What can I say? Try smaller fonts in the X server, or virtual screens. .TP .B Weird SCSI behaviour I am quoting David Myers Here... >> OS: FreeBSD 2.2.6 .br >> CC: egcs-1.02 .br Just wanted to follow up on this... I recently changed my SCSI card from the Adaptec 2940UW to a dual-channel Symbios 786 chipset. When I started up SANE with your driver, I managed to scan line art drawings okay, but Gray16 scans led to a stream of SCSI error messages on the console, ultimately hanging with a message saying the scanner wasn't releasing the SCSI bus. This may be that the Symbios is simply less tolerant of ancient hardware, or may be bugs in your driver or in SANE itself... .SH DEBUG If you encounter a GUI bug please set the environmental variable SANE_DEBUG_APPLE to 255 and rerun the exact sequence of keystrokes and menu selections to reproduce it. Then send me a report with the log attached. .PP If you have an Apple Macintosh with the AppleScanners driver installed, reporting to me which options are grayed out (inactive) in what modes would be very helpful. .PP If you want to offer some help but you don't have a scanner, or you don't have the model you would like to help with, or you are a SANE developer and you just want to take a look at how the apple backend looks like, goto to apple.h and #define the NEUTRALIZE_BACKEND macro. You can select the scanner model through the APPLE_MODEL_SELECT macro. Available options are APPLESCANNER, ONESCANNER, COLORONESCANNER. .PP If you encounter a SCSI bus error or trimmed and/or displaced images please set the environment variable SANE_DEBUG_SANEI_SCSI to 255 before sending me the report. .SH TODO .TP .B Non Blocking Support Make sane\-apple a non blocking backend. Properly support .B sane_set_io_mode and .B sane_get_select_fd .TP .B Scan Make scanning possible for all models in all supported modes. .PP Add other missing functionality .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHOR The sane\-apple backend was written not entirely from scratch by Milon Firikis. It is mostly based on the mustek backend from David Mosberger and Andreas Czechanowski sane-backends-1.0.29/doc/gt68xx/0000755000000000000000000000000013615535552013177 500000000000000sane-backends-1.0.29/doc/gt68xx/gt68xx.CHANGES0000666000000000000000000006553413615534521015275 00000000000000gt68xx.CHANGES -*-text-*- V 1.0.84 (2007-08-19) * Added Artec Ultima 2000 e+, Nortek Myscan 1200, NeatReceipts Scanalizer Professional, Genius Colorpage Slim-1200. * Name and email address changes. V 1.0.83 (2007-01-28) * Added .conf entry for Plustek OpticPro S12 and S24. Updated .desc file. V 1.0.82 (2006-10-03) * Added support for Genius Colorpage SF600. V 1.0.81 (2006-05-21) * Added support for Plustek OpticPro S24 (some models). Added .conf entry for Plustek OpticPro S12. V 1.0.80 (2006-01-02) * Added Plustek OpticPro S(T)12 (product id 0x040b). Mostly untested. * Print warmup message 5 seconds after starting the warm-up. V 1.0.79 (2005-12-09) sane-backends 1.0.17 * Silenced warning when scan is cancelled. * Silenced often non-fatal check_result error messages. * Reduced timeout for cancelling a scan. Some scanners freeze for 30 seconds otherwise. Repeat is_moving test even if an error was received. * Run fix_descriptors before cancelling the scan. Without that, some gt6816 scanners are not detected anymore after closing the device. * Fixed wait_lamp_stable. Wait for a maximum time of 60 seconds. Print warming up message after 5 seconds. Print how long warming up took. * For Mustek ScanExpress A3 USB, use more intelligent warm-up mechanism. The brightness for this scanner first decreases and then increases again. With the previous logic the scanner always warmed up for at least 10 seconds even if it wasn't necessary. * Warm up lamp also when changing from flatbed to transparency. Without this the lamp may be too dark directly after changing the source. * Decreased scan width of Plustek OpticPro 1248U. This fixes some strange color artifacts and results in less backtracking in some modes. V 1.0.78 (2005-10-16) * Minor modifications to sheet-fed scanner support. V 1.0.77 (2005-09-29) * Added support for Plustek OpticSlim M12 (untested). Based on patch from Gerhard Jaeger . * Fixed gt68xx homepage links in man page. Changed minimum version of libusb to 0.1.8. V 1.0.76 (2005-09-18) * Fixed segfault that may happen with Mustek ScanExpress A3 USB. V 1.0.75 (2005-09-01) * Genius ColorPage Vivid 1200 X is reported to work. * Genius ColorPage Vivid 4 XE seems to be the same as 4 X, it just doesn't have buttons. * Cleanup of .desc file. * Fixed gain setting. * Mustek ScanExpress A3 USB 600 dpi color scanning works now. V 1.0.74 (2005-08-20) * Increased number limit of scanners that can work with this backend to 50. * Added support for Genius ColorPage Vivid 1200 X (untested). V 1.0.73 (2005-08-19) * Enabled GT68XX_FLAG_NO_STOP for Mustek BearPaw 2400 CU Plus. Some of these scanners don't seem to like that command. V 1.0.72 (2005-08-18) * Finally fixed the problem concerning scanning on *BSD. Scanning only worked once. After that, the scanner wasn't even detected anymore beacuse the config descriptor returned by the device was corrupted. This is a hardware bug. When filling the internal memory of the scanner completely, the config descriptor is overwritten. The work-around is to ask the scanner for the device descriptor before closing the device. This rewrites also the config descriptor to the memory of the scanner. * Fixed compilation warnings. V 1.0.71 (2005-07-10) Included in sane-backends 1.0.16 * Changed resolution from 75 to 100 dpi and changed 16 bit/color to 12 based on a user report for the Visioneer OneTouch 7300. Updated .desc. * Moved check for stable lamp to its own function. * Mustek ScanExpress A3 USB: Use CIS calibration. Use lamp warmup. * Fixed CCD on GT6801 scanning (color scanning was broken due to a change in motormode_2. V 1.0.70 (2005-05-29) * Start exposure with the settings from the scanner entry. * CIS Calibration and exposure uses a broader spectrum now. * Expsoure limit is increased to 50 loops. * Genius Vivid 4x is reported to work so the UNTESTED label is removed now. * Visioneer 7300 is reported to work so the UNTESTED label is removed now. * Genius ColorPage Vivid 1200XE: Removed UNTESTED label. Fixed resolutions. Adjusted margins. Fixed color order. Fixed linedistance. Adjusted AFE. * Mustek ScanExpress 1248 UB: Fixed margins. Adjusted AFE. Adjusted exposure. Adjusted gamma. Changed status to "complete". * Mustek BearPaw 2400 CU Plus: Adsusted exposure and AFE parameters. Hopefully stripes and similar trouble are gone now. * Mustek BearPaw 1200 CU: Increased exposure to avoid vertical lines. * Updated manual page. V 1.0.69 (2005-05-20) * Mustek BearPaw 1200 CU Plus model 0x21b works now. Fixed firmware and offset settings. Calibration is not completely ok yet, however. * Code cleanup for setup_scan (only one function for all chipsets). * Simplified line mode/pixel mode setting * Updated TODO. * Mustek BearPaw 2448 TA Plus is now only "basic". Too much trouble for "good". * Removed option "fast preview". By default for preview mode 8 bits/pixel are used. * Fixed indentation. * Full scan really scans from y=0 on gt6816 scanners now. V 1.0.68 (2005-05-07) * GT68XX_FLAG_NO_STOP is needed for BearPaw 2448 TA Plus. * Plustek OpticSlim 2400: Fixed list of resolutions. That fixed the preview. Removed "untested" warning. Adjusted scan area. * Updated gt68xx.TODO. * Find firmwares independent of capitalization (bug #301580). V 1.0.67 (2004-11-14) * Fixed test to move home sensor at the start of scan. * Fixed gray mode linemode test. That stopped e.g. the Plustek OpticPro U 16 B from working in gray mode. V 1.0.66 (2004-10-31) * Removed unused gain and offset options. V 1.0.65 (2004-10-11) * Used new lamp option from saneopts.h. * Fixed typos. * Added Packard Bell Diamond 2450 to .conf and changed status to "good". * Avoid error message when closing scanner. * Don't print max_white warning when debugging is not enabled. V 1.0.64 (2004-10-02) * Added Trust 240TH easy Webscan Gold to list of supported devices. * Changed status of Visioneer 7300 to basic. * Changed name of Genius 1200 EX to "XE". That seems to be the real name. Fixed firmware name. Changed status to "minimal." V 1.0.63 (2004-09-03) * Fixed firmware name for Mustek 1248 UB. Changed status to basic. Removed "unsupported" warning. * Added workaround for shared memory compilation problem on Windows. * It's now possible to add a new vendor/product id line to gt68xx.conf to test yet unsupported scanners without changing the source code. V 1.0.62 (2004-08-08) * Added detection for Mustek ScanExpress 1248 UB. It's untested however and I don't even know the name of the firmware. * Added new id for Mustek BearPaw 1200 CU Plus (0x021b). It's completely untested. V 1.0-61 (2004-06-18) * General: * Re-enabled forked reader process when fork is not disabled. That's faster with high resolutions and big scan widths. * In gray and lineart mode the color to be used can be selected now. * Resolution and depth lists are now in the "correct" order. * Fixed "move to the end" bug when full scan is enabled. * Used SANE_VALUE_SCAN_MODE_* macros. * Added debugging code for brightness/calibration. * Changed status of Genius Colorpage Vivid4x too good. * Removed special command set for U16B (and Genesys Vivid4) as those scanners are quite normal GT6816 devices. * Removed special test for gt6816, 600 dpi, 16 bits -> linemode. The other tests should change the settings to linemode if necessary. * Added flag to indicate that a scanner doesn't support linemode. Print an error if linemode is activated for that sort of scanners. * Adjusted various debug levels. * Added options to force backtracking and to set the number of lines to backtrack. * Increased default lamp-warmup time to 60 seconds. Also lamp-warmup doesn't stop if lamp brightness is 0. * reader_process returns an error now if read fails. * Added gt68xx.TODO. * Removed XDBG macros. Used DBG instead. * Checks for correct gain and offset are in gt68xx_generic now. * Fixed gain setting (including multiplier). * Check for status of read_scanned_data every 10 ms. Avoids short stops before scan data comes in. * Added resolution limit for using backtracking. * Reduced deafult CCD backtracking to 0x10 lines. * CCD coarse calibration: * Check if calib has succeeded per color now (fewer loops). * Added loop detection now. * Use the brightest CCD element as max_white now. * Added debugging DEFINE to check the position of the black mark. * Print which color is currently calibrated. * Changed debug messages. * CIS coarse calibration: * Removed offset multiplier. * Changed limits. * Changed debug messages. * Incresed exposure count. * Removed special lamp-warmup in CIS calibration. * CIS coarse calibration now does gain and offset at the same time similar to CCD calibration. This change should avoid loops. * Print which color is currently calibrated. * Mustek ScanExpress A3 USB: * Fixed black mark. * Use CCD calib now. * Use inverted offset. * Warm up for 10 seconds minimum. * Fixes for geometry. * Plustek OpticPro U16B (and Genius Vivid 4): * Linemode is not supported * Reduced vertical res to 600 dpi. * Mustek BearPaw 1200 TA: * Fixed position of black mark. * Mustek BearPaw 2448 TA Plus: * Fixed position of black mark. * Mustek BearPaw 1200 CU: * Increased start of white strip. V 1.0-60 (2004-04-19) * Mustek BearPaw 2448 TA PLUS: - Fixed resolution settings (added missing 200 dpi mode) - Fixed margins - Fixed black mark - Fixed TA margins - Removed untested flag - Changed status to "good" V 1.0-59 (2004-04-10) * Used 0, 4, 4 as linedistance for Mustek A3 USB. * Other mionor fixes for A3 USB. * Removed "unsupported scanner warning" from Mustek A3 USB. * Added Genius Colorpage Vivid4 to .conf file. Changed status to good. Added to man page. * Fixed black mark for Mustek BearPaw 2448 TA Plus. This one and the Mustek A3 fixes are from Jakub Dvořák . * Status of BearPaw 2448 TA/CS Plus is "basic" now. V 1.0-58 (2004-04-04) * Added BGR color order for pixel mode. Until now, only line mode worked in that mode. * Plustek U16B uses setup_scan for gt6816 now. * Fixed linedistance for Plustek U16B. * Enabled 16 bit mode for Plustek U16B. * Fixed margins for Plustek U16B. * Made 600 dpi mode for Mustek BearPaw 2400 TA Plus a bit faster. * Changed Mustek ScanExpress A3 linedistance correction to 1, 5, 5 (?). * Added detection of Visioneer Onetouch 7300. V 1.0-57 (2004-03-28) * Plustek U16B: Added GT68XX_FLAG_SE_2400. Fixed color order. * Increased debug level for setup_scan. * Fixed CCD ocarse calibration. V 1.0-56 (2004-03-19) * Genius Vivid 4xe now has color order RGB. * Removed 50 dpi for Mustek BearPaw 2448 as that resolution doesn't work. * Make sure that the lamp of the Mustek A3 USB gets warmed up. It's a CIS scanner with a lamp. That code is untested. * Full scan starts scanning from the start position of the white strip now. V 1.0-55 (2004-03-06) * Added detection for Genius Vivid 1200 EX. * Fixed product id of Mustek BearPaw 2448 TA Plus. * Other minor updates. V 1.0-54 (2004-02-10) * Added basic support for Plustek OpticSlim 2400. Thanks to Radoslaw Grzanka and Detlef Gausepohl for providing details and testing. * Fixed calibration debug output. V 1.0-53 (2004-01-19) * Debug options are only enabled if the debug level is 1 and higher. This may stop some people from activating dangerous options. * Added product id 0x0402 for Plustek U16B. V 1.0-52 (2004-01-01) * gt68xx_gt6801.c: Fixed a bug in the stop scan function for Plustek U16b. * Added support for Genius Vivid4xe. V 1.0-51 (2003-12-14) * Changed color order to RGB vor Genius Vivid 4x. Seems to work now. Updated manpage and .desc. * Set linedistance correction to 0, 4, 2 for ScanExpress A3 USB. Not perfect yet but better than before. * Added Genius Colorpage Vivid3 V2 and Googlegear 2000 as supported deviced to manpage and .desc. * Changed Genius Colorpage Vivid3x status to good as it seems to work now. * Changed status of Mustek BearPaw 2448 TA Plus to minimal as it seems to at least scan something. V 1.0-50 (2003-11-23) * Added Mustek BearPaw 2448 TA Plus. It's completely untested. * Added special command set for Plustek U16B. Changed stop scan command and download_firmware. Everything is untested. * Added Plug-n-Scan 2400 M(T) to list of devices. No positive report yet. * Used request for memory writes and reads instead of a fixed value of 0x04. * Set Genius Vivid4x to GT6816. Untested. V 1.0-49 (2003-09-30) * Fixed wrong test for allocation in gt68xx.c. * Added ScanMagic 1200 UB Plus to man page and .desc. * Added Settings for Plustek OpticSlim 1200 * Added detection of Genius Vivid 4x. It won't work out-of-the-box, however. * CCD coarse calib shouldn't run into an endless loop anymore. Plustek 1248U is much faster now. V 1.0-48 (2003-07-25) * Added RevScan 19200i to manpage and .desc file. * Updated .desc file to new :status system. * Added Fujitsu 1200CUS to man page, .conf and .desc. * Changed .conf file to be more readable. * Added RevScan 19200i to .conf file. * Added Plustek U16B to .desc and .conf, updated UT16B. V 1.0-47 (2003-06-05) * Don't check if the firmware is loaded. The check seems to confuse the USB system on some UHCI chips. V 1.0-46 (2003-04-27) - Added Genius 3x as working scanner, removed testing flag. - Added Artec 2000 e+ to manpage. - Added detection for the Plustek OpticPro U16B. V 1.0-45 (2003-04-11) - Updated Mustek BearPaw 1200 CU Plus white strip value. - Set Mustek ScanExpress A3 USB to CCD. Black mark may be still wrong. - Minor formatting changes in the manpage. - Decreased ScanExpress A3 USB status to alpha because of CIS/CCD change. V 1.0-44 (2003-03-13) - Added Packard Bell Diamond 1200 Plus to .desc and manpage. - New flag to avoid running stop_scan before doing a scan. The Windows firmware of the BearPaw 1200 CU Plus doesn't seem to like that. V 1.0-43 (2003-03-06) - Small requests are done with a response buffer of 8 bytes (instead of 64) now. Looks like GT-6816 based scanners return 8 bytes if the firmware is loaded and 64 bytes if it's not loaded. - Changed GT-6816 firmware check to ignore errors from above change. GT-6816 scanners work with the BSDs now (at least once). - Updated manpage concerning the BSDs. V 1.0-42 (2003-03-02) - Make sure that the firmware for plustek-like scanners is loaded. Didn't work for Genius vivid3xe. - Added both Genius scanners to man page. - Removed warning from Genius Vivid3xe. V 1.0-41 (2003-02-27) - Added Genius Colorpage Vivid3xe. - Added request_type and request fields to the command set. Request is 0x01 or 0x04. V 1.0-40 (2003-02-22) - Added vid/pid 0x07b3/0x0400 to gt68xx.conf also - Added indormation about Medion 4394. - Mention ma1509 backend. - Fix segfault when calling sane_open with an empty device name. - Explicitely initialize global variables to avoid segfaults when calling sane_init/sane_exit more than once. V 1.0-39 (2003-02-16) - Added BearPaw 2400 CS Plus as supported. - Make fast preview the default (otherwise BP 2400 TA Plus wouldn't work with 12/16 bits). - Added vid/pid 0x07b3/0x0400, that's another Plustek OpticPro 1248U. V 1.0-38 (2003-02-05) - Fixed resolutions for BearPaw 1200 TA (75 instead of 100). - Increase the lowest black for CCD coarse calibration to avoid too much black. - Adjusted internal gamma correction to avoid getting 0 for high gamma values. - CCD scanners use color mode for coarse+quality cal now. This fixes the problem with extremly high gains and terrible quality cal in gray mode at least for the BearPaw 1200 TA. --> Thanks to Alexei V. Mezin for reporting these bugs. - Preview isn't always in 8 bit mode now (can be selected by option). - Upper and lower limits for coarse calibration are unified now. - Added options for adjusting gain and offset. V 1.0-37 (2003-01-18) - Removed untested flag from A3 USB and Lexmark X70/X73. V 1.0-36 (2003-01-09) - Updated manpage and .desc concerning Lexmark X70. - Updated manpage concerning kernel 2.4.21-pre3 containing the 1-endpoint fix. - Fixed A3 USB resolution setting. - Updated A3 USB margins (Pedro Morais ). - Added detection of Genius Colorpage Vivid3x. It's unknown if it works. - Updated .desc file. - Don't print calib line warnings by default. V 1.0-35 (2002-12-23) - Added "afe" option for gt68xx.conf for selecting default afe values. - Removed AFE and exposure SANE options. - Added documentation for afe option in gt68xx.conf. V 1.0-34 (2002-12-18) - fixed gt68xx_gt6801 -> lamp control. - adjusted Plustek 1248U geometry and afe values. - CCD gross calibration changed: start with the default value from module struct. Is faster now for most cases. - Only 2.5 mm of calibration for GT-6801 scanners. V 1.0-33 (2002-12-10) - Updated ScanExpress 2400 USB values (from "Fan Dan" ). - Added implementation of gt6801 lamp control for CCD scanners. - Added flag for SE 2400 USB, added some quirks in gt68xx_gt6801.c. V 1.0-32 (2002-12-08) - "Coarse calibration for first scan only" is off by default now. As at least CIS calibration is faster now, it doesn't seem to be necessary and produces wrong images sometimes. - Added gamma table. - Setup gamma to 2.0 by default. - Fixed (hopefully) sigpipe when cancelling. - No geometry quantization anymore (not necessary). That should fix scanimage warnings. - Plustek 1248U: do linemode for every resolution, fix color correction. - Set SANE_CAP_EMULATED for gamma value. - Added comments for every Model member in gt68xx_devices. - Added Plustek UT16B and Genius Vivid3x to .desc. - Added implementation for inverted offset for CCD scanners. - Added Mustek ScanExpress 2400 USB. Well, at least it's detected. - Added NEW marker to .desc. V 1.0-31 (2002-11-21) - Changed 150 to 200 dpi for Mustek BearPaw 2400 TA. - Fixed warnings in gt68xx_low.c - Used DBG instead of XDBG in gt68xx_low.c - Minor manpage fixes. Added man page links to other backends. - gt68xx_low.h: Fixed __FUNCTION__ bug on non-gcc compilers. - Added more details about the BSDs in the manpage. - Fixed color order for ScanExpress A3 USB. V 1.0-30 (2002-11-13) - Added basic support for Plustek OpticPro 1248U (from Gerhard Jaeger ). Only gray mode without calib seems to work until now. - Removed 50 and 1200 dpi from Lexmark X73 (doesn't seem to work). Decreased height. - Backend status is BETA now. V 1.0-29 (2002-11-07) - Changed option titles and descriptions to make them better readable. - Added translation markers for all options. - Added German translation for backend options. - Updated manpage and .desc file concerning scanner status. - Added untested flag for Mustek ScanEpress A3 USB and Lexmark X73. V 1.0-28 (2002-10-31) - Reduce scan width of 2400 TA Plus: otherwise the black mark would create light vertical stripes. - Removed default parameters. Set AFE and exposure in every model struct. - Faster automatic gain setting for the CIS scanners. The default values from the model struct and the last values are used for calculation. - Set default AFE values for ScanExpress 1200 UB Plus, BearPaw 1200 CU, BearPaw 2400 CU Plus. V 1.0-27 (2002-10-25) - Bugfix: override applies to all devices found by the last usb line. - Individual resolutions + depth values for every scanner. - Bugfix: Mirroring code had an off-by-one error (garbage in the first column). - Artec Ultima 2000, MD 9385: Removed 1200 dpi mode (doesn't seem to work?), added 100 and 200 dpi modes. Renamed model to Artec Ultima 2000, because that's probably the "father" of all the clones. - Mustek BearPaw 1200 CU: Added 200 dpi mode. - Added manual page. - Removed override for Packard Bell (seems to be exact Bearpaw 1200 CU Plus clone). - Removed override for Trust Copmact Scan and Medion/Tevion/Lifetec LT 9452 (Mustek ScanExpress 1200 UB Plus clones). - Removed override for Tevion MD 9458 (seems to be an Artec Ultima 2000 (e +?) clone). V 1.0-26 (2002-10-22) - Several fixes for Medion MD-9385 and Artec Ultima 2000 based scanners. The Cytron MD 9385 works now. - Diabled Plustek-like firmware check again, didn't work for MD 9385. - Splitted flags for mirror_x and sset_home. V 1.0-25 (2002-10-20) - Fixed segfault for GT-6801 based scanners. - Added override for Medion MD9385. - Changed firmware detection code for Plustek scanners. - CIS autogain seraches max white and min black now (removed segment code). Hopefully no more vertical stripes. - Adjusted ScanExpress 1200 UB Plus and BearPaw 1200 CU geometry and white strip. V 1.0-24 (2002-10-12) - Added "override" keyword for gt68xx.conf. So model settings can be changed at run-time. If set up correctly, firmware lines aren't necessary any more. - Added support for the Mustek BearPaw 2400 CU. - Tevion hack (now enabled by override option) also mirrors coordinates. - Mustek BearPaw 1200 TA 1200 dpi is set up for the Windows firmware again. - Added some basic I18N markers. - Removed option backtrack (setup automatically now). V 1.0-23 (2002-10-10), - Added detection of Mustek BearPaw A3 USB. - Added auto-detection of lamp status for CCD scanners (from David Stevenson). No wait for the fixed time of 40 seconds any more. - The scan slider of the GT-6816 bsed scanners don't move home after calibration/gain. TA mode is faster therefore. - Added hack for Tevion MD 9458 to solve the mirror and "scan-slider doesn't come home" problems. - Fixed BearPaw 1200 TA 1200 dpi problem. - Fixed manual firmware selection in gt68xx.conf. - Added warning if power supply isn't ok. V 1.0-22 (2002-10-07), - Mustek Bearpaw 2400 CU Plus works in gray mode again - Line calibration uses the bit depth of the main scan now. - Vendor, product ids and other information is printed when debugging is active - Fixed segfault in attach (). - Fixed endianess issues (untested). - Code cleanup. V 1.0-21 (2002-10-07), - Added 12 bit modes for all scanners (Sergey Vlasov). - Fixed 2400 TA Plus in 12/16 bit modes in 1200/2400 dpi. - Disable depth option in lineart mode and for some scanners in gray mode. - Scan preview in 8 bit. V 1.0-20 (2002-10-06) - Calibration of the CCD scanners in gray mode should work better now. - Added 50 dpi mode for BearPaw 2400 TA Plus. Faster preview. - By default, /usr/local/share/sane/gt68xx/ is checked for firmware files. Manual adjustment is only necessary if the firmware name is different from default or at a different path. - Mixed and lower-case is tried when loading the firmware. - Adjusted geometry of BearPaw 1200 TA and 2400 TA. - Automatic gain fixes for TA mode. - Don't show "lamp off" option for CIS scanners. V 1.0-19 (2002-10-01) - Various minor fixes and adjustments concerning calibration. - Fixed sane_open detection of already known devices. - Added missing usleep for 2400 CU Plus. - Adjusted scan area for 1200 TA. - Removed detection of Artec Umltima 2000 (product id 0x4001) as this is not a GT-68xx based scanner. - Fixed some compilation warnings. - Minor misc fixes. V 1.0-18 (2002-10-01) - Added detection of Artec Ultima 2000. - Updated Lexmark X70 settings. - Fixed segfault that occured when no device was detected. - Changed test for loaded firmware for GT-6801 scanners. V 1.0-17 (2002-10-01) - Added support for the Lexmark X70 and X73 scanners - Fixed shifted columns problem for BearPaw 2400 TA Plus and maybe 2400 TA. - Fixed y-margin for the BearPaw 1200 TA (at least I hope so) - Fixed BearPaw 2400 CU Plus firmware name - Removed gt68xx_test program from distribution. Didn't work anymore anyway. V 1.0-16 (2002-09-29) - Added calibration and auto-gain support for transparency adapter mode. - In transparency adapter mode, only the usable scan area is shown. - Autogain is repeated when source was change.d - Fixed geometry of ScanExpress 1200 UB Plus. - Fixed freeze at the end of scan for GT-6801-based scanners. V 1.0-15 (2002-09-27) - Low level reading is done in a separate process now (shm is back). Some scanners should be faster therefore. - Added option "force backtracking". If disabled, no backtracking occurs (->faster, but lines are lost). - Fixed hang in reader_process. - Fixed "auto gain once" (which really worked only once :-/) V 1.0-14 (2002-09-25) - Added basic transaprency adapter support for the Mustek Bearpaw 2400 TA Plus. Other TA models may work also. No calibration or other nice features, just pure external lamp on, internal lamp of. - Support for the Mustek BearPaw 1200 Cu Plus (hopefully). - Added Lineart (black/white) mode. - Added warming-up for CCD lamps and an option to disable shutting off the lamp. - Print scanning time (debug level 3). - Removed "safe preview". Not longer necessary. V 1.0-13 (2002-09-25) - Major rewrite of the low level scan setup functions. Probably has broken some of the supported scanners. - Geometry in the model struct is in mm now. Values for most scanners are untested. - Added support for Mustek Bearpaw 2400 CU Plus. - CCD lamp is turned on when opening the frontend and turned off when leaving. - Auto gain is done only for the first scan. - Manual gain etc. options don't show up in automatic mode. - Faster automatic gain. - Bugfixes: gain/offset options, moving top-margin and exposure control. V 1.0-12 (2002-09-23) - Fixed bug concerning too little data transferred in sane_read. - Added detection of the Packard Bell Diamond 1200. - Changed some scanner names and added support for custom names in config file. - Use the size of the scan area in the model struct. This value may need some tweaking for the gt6816 scanners. - Fixed the size of scanarea for the BearPaw 1200 CU/ScanEpress 1200 UB Plus - Disabled 16 bit mode for GT-6801 scanners. This isn't even supported by the Windows driver. - General code cleanup. Removed gt68xx_mustek.c and SHM support. - Made the .tar.gz file size smaller. V 1.0-11 (2002-09-22) - 1200 dpi works now at least for the BearPaw 1200 CU. Maybe also for the other scanners. - Added manual and automatic offset/gain/exposure control for the CIS scanners. The image should be better now. - Added debug option to scan the full scan area including the calibration strip. V 1.0-10 (2002-09-18) - 50, 75, 150, 300, 600 work now for the GT6801 scanners - Preview is fast again (can be set to safe/slow mode) - Calibration can be disabled by option - Added some more safety checks for USB commands - The gt68xx_test program can be used again V 1.0-9 (2002-09-17) - Added option to disable automatic gain (->less ugly colors for GT-6801 based models) - Fixed segfault that occured when a scan was cancelled - Preview uses slow but safe (?) 300 dpi 8 bit modes now - Fixed bug concerning X0/Y0 coordinates - Started implementing dpeth option (doesn't work yet) - Internal changes (use high_scan's wait_for_positioning) V 1.0-8 (2002-09-16) - Fixed distortion problem in color mode - Selected safer default option values - Changed file names to be more appropriate for SANE V 1.0-7 (2002-09-16) - Initial version based on Sergey Vlasov's gt68xx backend v 0.0.6 - Added basic SANE interface in gt68xx.c - Added SANE options and SANE variables to gt68xx_high.h - Minor adjustments to gt68xx_low.h - Added support for Mustek BearPaw 2400 TA Plus sane-backends-1.0.29/doc/gt68xx/gt68xx.TODO0000666000000000000000000000762113615534521014763 00000000000000gt68xx.TODO -*-text-*- General: -------- - some sort of fixed lookup-table may be necessary to compensate for the non-linear CCD/CIS behaviour. A gamma value is not good enough. Or maybe line calibration can be used for that? - Some Plustek scanners are advertised with e.g. 1200x2400 but the maximum vertical resolution seems to be limited to the horizontal one. Check if that's really the case. - Keep a log of all gain/offset combinations already tested and break if one is repeated to avoid endless loops. - Print commands that are send to the scanner in clear text. - Try to implement non-blocking USB bulk reads, check libusb CVS. CCD: ---- Mustek BearPaw 2400 TA Plus: - some lines at the beginning of each image have wrong colors (linedistance?) This seems to happen with other scanners, too. - 600 dpi no backtrack, 1200, 2400 dpi backtrack (gray), check with windows for color - 600 dpi 12 bit seems to work in pixel mode only (but long lines are too big!) Mustek BearPaw 1200 TA: - similar color problem as 2400 TA Plus, doesn't always happen? Mustek BearPaw 2448 TA Plus: - all modes are slow (massive backtracking). If connected to a USB2 port, the backtracking ich much less despite this scanner can't do USB2. Strange. - Sometimes there is a USB protocol error when cancelling the scan? - top borders move with resolution (happened in the early days with 2400 TA!) - gray scans have different brightness - scan motor is bumpy and freezes sometimes, looks like accelaration is too big (firmware problem?) - vertical stripes - TA settings are wrong - no backtrack >= 600 dpi (also gray!) - don't move before and after scan - check jpeg output, maybe this can be used for faster scans Plustek 1248U: - Linedistance seems to have problems in the first few and the last lines. - Gain and offset values are quite high. Optimum values are not reached. Problem with coarse calib? Better algorithm needed. - Images in color mode sometimes look too redish (result of above problem). - quite slow when full width is selected. Lots of backtracking. - Check if pixel mode is possible. - Check again 600x1200 dpi. Plustek U16B: - 600 dpi 16 bit is limited to about half the size of the scan area because only pixel mode works and 16k is the maximum buffer size. - After scanning, a run of sane-find-scanner leads to a protocol error and scanning does no longer work. Genius ColorPage Vivid 1200XE - 16 bit per color is advertized but this mode doesn't seem to work (only 12 bit)? - 1200x1200 and 1200x2400 dpi doesn't seem to work despite being advertized - Y-positioning varies slightly with resolution (some mm) CIS: ---- - It may be necessary to do an additional exposure calibration before the offset/gain calibration to compensate for different intensities of the colored leds. Especially for the Mustek 2400 CU Plus. - Changing exposure doesn't seem to have any effect during calibration sometimes while it has an effect on the final image? Mustek BearPaw 1200 CU - ok Mustek BearPaw 1200 CU Plus (0x021b) - ok, but similar exposure problems as 2400 CU Plus Mustek BearPaw 2400 CU Plus - ok, but exposure setting may need to be done automatically if the intensity of the colors varies for different scanners. - calibration/exposure has sometimes sharp jumps in intensity. Reason is unknown. Mustek ScanExpress A3 USB - still slight vert. stripes - why is line distance setup necessary? - line distance varies with resolution (0,5,5 at 300 dpi, 0, 6, 7 with 150 dpi) - exposure doesn't seem to have any effect Mustek ScanExpress 1248 UB ok Plustek OpticSlim 2400 - only upto 1200 dpi vertical works - only 8 and 12 bit work, 16 doesn't (check Windows) - exposure is extremely high and seems to have similar problems as with other CIS scanners (reaches limit also) Mustek ScanExpress 2400 USB - make it work (nobody seems to have this device) Visioneer OneTouch 7300 - 16 bit doesn't seem to work despite beeing advertized sane-backends-1.0.29/doc/doxygen-sanei.conf.in0000666000000000000000000002521713615534521016003 00000000000000# Doxyfile 1.8.8 #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = SANEI PROJECT_NUMBER = @VERSION@ PROJECT_BRIEF = PROJECT_LOGO = OUTPUT_DIRECTORY = ./ CREATE_SUBDIRS = NO ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 ALIASES = TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES AUTOLINK_SUPPORT = YES BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = YES SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO INLINE_SIMPLE_STRUCTS = NO TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = NO EXTRACT_PRIVATE = NO EXTRACT_PACKAGE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = NO SHOW_GROUPED_MEMB_INC = NO FORCE_LOCAL_INCLUDES = NO INLINE_INFO = YES SORT_MEMBER_DOCS = NO SORT_BRIEF_DOCS = NO SORT_MEMBERS_CTORS_1ST = NO SORT_GROUP_NAMES = NO SORT_BY_SCOPE_NAME = NO STRICT_PROTO_MATCHING = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_FILES = YES SHOW_NAMESPACES = YES FILE_VERSION_FILTER = LAYOUT_FILE = CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = YES WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- INPUT = ../include/sane/ INPUT_ENCODING = UTF-8 FILE_PATTERNS = sanei*.h RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = ./ INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES REFERENCES_LINK_SOURCE = YES SOURCE_TOOLTIPS = YES USE_HTAGS = NO VERBATIM_HEADERS = YES CLANG_ASSISTED_PARSING = NO CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = ./sanei-html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_EXTRA_STYLESHEET = HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES HTML_DYNAMIC_SECTIONS = NO HTML_INDEX_NUM_ENTRIES = 100 GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project DOCSET_PUBLISHER_ID = org.doxygen.Publisher DOCSET_PUBLISHER_NAME = Publisher GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO CHM_INDEX_ENCODING = BINARY_TOC = NO TOC_EXPAND = NO GENERATE_QHP = NO QCH_FILE = QHP_NAMESPACE = org.doxygen.Project QHP_VIRTUAL_FOLDER = doc QHP_CUST_FILTER_NAME = QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = QHG_LOCATION = GENERATE_ECLIPSEHELP = NO ECLIPSE_DOC_ID = org.doxygen.Project DISABLE_INDEX = NO GENERATE_TREEVIEW = NO ENUM_VALUES_PER_LINE = 4 TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES USE_MATHJAX = NO MATHJAX_FORMAT = HTML-CSS MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest MATHJAX_EXTENSIONS = MATHJAX_CODEFILE = SEARCHENGINE = NO SERVER_BASED_SEARCH = NO EXTERNAL_SEARCH = NO SEARCHENGINE_URL = SEARCHDATA_FILE = searchdata.xml EXTERNAL_SEARCH_ID = EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = LATEX_FOOTER = LATEX_EXTRA_FILES = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_SUBDIR = MAN_LINKS = NO #--------------------------------------------------------------------------- # Configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # Configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration options related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = NO MSCGEN_PATH = DIA_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO DOT_NUM_THREADS = 0 DOT_FONTNAME = DOT_FONTSIZE = 10 DOT_FONTPATH = CLASS_GRAPH = YES COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO UML_LIMIT_NUM_FIELDS = 10 TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = NO CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png INTERACTIVE_SVG = NO DOT_PATH = DOTFILE_DIRS = MSCFILE_DIRS = DIAFILE_DIRS = PLANTUML_JAR_PATH = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES sane-backends-1.0.29/doc/sane-sm3840.man0000666000000000000000000000457213615534521014335 00000000000000.TH sane\-sm3840 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-sm3840 .SH NAME sane\-sm3840 \- SANE backend for Microtek scanners with SCAN08 USB chip .SH DESCRIPTION The .B sane\-sm3840 library implements a SANE (Scanner Access Now Easy) backend that provides access to some Microtek scanners with the SCAN08 USB chip. .PP There exist backends for Microtek scanners with SCSI command set. Refer to sane\-microtek(5) and sane\-microtek2(5) for details. .PP There also exists a Microtek 3600 series driver, see sane\-sm3600(5) for details. .PP At present, the following scanners are known positively to work with this backend: .PP .RS .ft CR .nf Vendor Product ID: Remark: -------- -------------- ----------- Microtek ScanMaker 3840 All modes OK Microtek ScanMaker 4800 All modes OK .fi .ft R .RE .PP If you own a Microtek scanner with the SCAN08 chip other than the ones listed above, it may or may not work with SANE. Feel free to contact the backend author (earle@ziplabel.com) to report results with scanners not on the list. .SH "FRONTEND OPTIONS" .PP The following options are supported by the sm3840-driver: .PP .B \-\-mode color|gray|lineart|halftone .br Color or grayscale mode. .B \-\-resolution 150|300|600|1200 .br Pixels per inch for scans. .B \-\-depth 8|16 .br Note that the least significant bits of 16bpp mode may be noise. .B \-\-brightness 1..4096 .br Higher numbers increase brightness of returned image. .B \-\-contrast 0.1..9.9 .br Larger numbers decrease contrast of returned image. .B \-\-lamp\-timeout 1..15 .br Time in minutes until the lamp is turned off after a scan. .SH CONFIGURATION This backend does not support a configuration file right now. .SH FILES .TP .I @LIBDIR@/libsane\-sm3840.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-sm3840.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_SM3840 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. To see error messages on stderr set SANE_DEBUG_SM3840 to 1. .SH "SEE ALSO" sane\-microtek2(5), sane\-sm3600(5), http://www.ziplabel.com/sm3840 .SH AUTHOR .br Earle F. Philhower III (earle@ziplabel.com) .br sane-backends-1.0.29/doc/descriptions.txt0000666000000000000000000001433413615534521015222 00000000000000SANE Backend specification files -------------------------------- The specification files (e.g. epson.desc) describe the capabilities of the backends. They provide information about the backend itself (e.g., name and version) and about the supported devices (e.g., manufacturer and product names). One file per backend should be used. Descriptions for backends included in the SANE distribution are located in `sane-backends/doc/descriptions/' while descriptions of external backends should be placed in `sane-backends/doc/descriptions-external/'. There is a special file `sane-backends/doc/descriptions/unsupported.desc' that doesn't belong to a backend but lists all (known) devices not supported by SANE. It may contain additional information about the device or links to non-SANE based programs. The specification files can be used to generate lists of backends and/or supported devices, hotplug/udev device lists, databases for search engines, and similar sources of information. Currently the creation of ASCII output and HTML lists is supported by `tools/sane-desc.c'. The generation of the HTML pages can be started by `make html-pages' in the doc/ directory. The file contents is basically emacs-lisp --- so ";" indicates comment to end of line. Empty lines are ignored. All syntactic elements are keyword tokens, followed by a string or keyword argument, as specified. All keyword tokens but ":backend" are optional. Backend-specific keyword tokens ------------------------------- The keyword `:backend' must be specified exactly once. It must be the first keyword in each specification file. It is followed by the name of the backend. Example: `:backend "epson"' The following backend-specific keyword tokens are optional. If they are used, they shouldn't be used more than once per file. `:version' has one string argument containing the backend's version number. The version should match the version used in the backend source code. Example: `:version: "12.3.5"'. If the backend isn't maintained, the version should be `unmaintained' or contain this tag together with the version number. `:new' indicates that the backend is brand-new in the latest SANE release if the keyword argument is `:yes'. Otherwise, `:no' should be used or `:new' should be omitted at all. Example: `:new :yes' The `:manpage' keyword token has one string argument that names the manual page for the backend. Example: `:manpage "sane-epson"' Device-specific keyword tokens ------------------------------ The keyword `:devicetype' starts a list of devices supported by the backend. It has one keyword argument. The following types are possible: `:scanner', `:stillcam' (still camera), `:vidcam' (video camera), `:meta' (meta backend like dll), `:api' (API like PINT). `:devicetype' can be used more than once. Each instance starts a new list of devices. Example: `:devicetype :scanner' `:mfg' has one string argument that defines the name of the manufacturer of the following devices. This keyword should be only used for hardware devicetypes (scanner, stillcam, vidcam). To avoid different spellings, the manufacturer list of the SANE standard should be used. `:mfg' can be used more than once. Example: `:mfg "Epson"'. The keyword token `:model' is used to specify the name of a hardware device in its string token. It must be preceded by a `:mfg' keyword. `:model' can be used more than once. Example: `:model "Perfection 636S"' `:interface' defines how the device is connected to the computer. Its string argument can be one or more of "SCSI", "USB", "Parport", "Serial port", "IEEE-1394", "JetDirect", "Ethernet", or "Proprietary". If neither one fits, please contact the SANE mailing list for advice. The "Parport" entries can be amended by "(SPP)", "(ECP)" and/or "(EPP)". The `:interface' keyword refers to the previous `:model', is optional and should be used only once per model. Example: `:interface "SCSI USB IEEE-1394"' `:usbid' defines the USB vendor and product ids of the device. It has two arguments which must be lower case hexadecimal (4 digits). The first one is the USB vendor id, the second one the USB product id. The keyword refers to the previous `:model', is optional, and applicable for devices with :interface "USB" only, and should be used only once per model. The special parameter "ignore" can be used if no vendor or product ids are given intentionally, e.g. for a group of scanners. Example: `:usbid "0x1234" "0x4321"' The keyword `:status' is an indication of the level of support for the model. It's followed by one of the following keyword arguments: `:unsupported', `:untested', `:minimal', `:basic', `:good', or `:complete'. The `:status' keyword refers to the previous `:model', is optional and should be used only once per model. `:unsupported' means the device is not supported at least by this backend. The keyword should only be used in the file `unsupported.desc', or to make clear that a specific scanner is not supported by a backend. `:untested' means the device may be supported but couldn't be tested. `:minimal' means that the device is detected and scans at least in one mode. But the quality is bad or important features won't work. `:basic' means it works at least in the most important modes but quality is not perfect. `:good' means the device is usable for day-to-day work. Some rather exotic features may be missing. `:complete' means the backends supports everything the device can do. Example: `:status :untested' The `:desc' keyword token is used for non-hardware devices (API and meta). Its string argument describes the meta backend or API. It should be used only once per device type. Example: `:desc "Scanners with the machine-independent PINT interface" Multi-level keyword tokens -------------------------- The following keyword tokens can be used after `:backend', `:mfg', `:model', and `:desc'. One or more `:url' keyword tokens can be used to point to more information about the entry the keyword refers to. The string argument contains a URL to e.g. a manufacturer's or backend's homepage. The most important URL should be listed first. Example: `:url "http://www.epson.com/"' `:comment' is used to add more information to one of the entries. The string argument can e.g. contain comments on the level of support for a model. Example: `:comment "US version of GT-5000"' sane-backends-1.0.29/doc/sane-pie.man0000666000000000000000000000267713615534521014160 00000000000000.TH sane\-pie 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-pie .SH NAME sane\-pie \- SANE backend for PIE, Devcom and AdLib SCSI flatbed scanners .SH DESCRIPTION The .B sane\-pie library implements a SANE (Scanner Access Now Easy) backend that provides access to PIE, Devcom and AdLib SCSI flatbed scanners. .br At present, the following scanners should work with this backend: .PP .ft CR .nf Model: Status ---------------------- ------ Devcom 9636PRO OK Devcom 9636S Untested Devcom 9630S Untested ScanAce 1236S Untested ScanAce 1230S Untested ScanAce II Untested ScanAce III OK ScanAce Plus Untested ScanAce II Plus Untested ScanAce III Plus Untested ScanAce V Untested ScanAce ScanMedia Untested ScanAce ScanMedia II Untested ScanAce 630S Untested ScanAce 636S Untested JetScan 630 OK JetScan 636PRO Untested .fi .ft R .PP .SH FILES .TP .I @CONFIGDIR@/pie.conf The backend configuration file .TP .I @LIBDIR@/libsane\-pie.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-pie.so The shared library implementing this backend (present on systems that support dynamic loading). .PP .SH SEE ALSO sane(7) .SH "CONTACT AND BUG-REPORTS" Please send any information and bug-reports to: .br .B Simon Munton sane-backends-1.0.29/doc/sane-sharp.man0000666000000000000000000003305413615534521014511 00000000000000.TH sane\-sharp 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-sharp .SH NAME sane\-sharp \- SANE backend for SHARP scanners .SH DESCRIPTION The .B sane\-sharp library implements a SANE (Scanner Access Now Easy) backend that provides access to Sharp SCSI scanners. This backend should be considered .B beta-quality software! In the current state it is known to work with JX-610 and JX-250 scanners. It is prepared for usage with the JX-330 series scanners, but we are not able to test it with these devices. .PP For other Sharp scanners, it may or may not work. .PP At present, the following scanners are known to work with this backend. .RS .PP .ft CR .nf Vendor Product id: ----- ----------- Sharp JX-610 Sharp JX-250 Sharp JX-320 Sharp JX-330 Sharp JX-350 .fi .ft R .RE .PP The following scanners are detected by the backend, but not tested: .PP .RS .ft CR .nf Vendor Product id: ----- ----------- Sharp JX-325 .fi .ft R .RE .SH DEVICE NAMES This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is either the path-name for the special device that corresponds to a SCSI scanner. The special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. See sane\-scsi(5) for details. .SH SCAN OPTIONS .B Scan Mode (parameter .B \-\-mode for scanimage). Possible settings: .RS .B Lineart (1 bit black & white scans), .br .B Gray (8 bit gray scale scans), .br .B Lineart Color (bi-level color scans), .br .B Color (8 bit RGB scans). .RE The default value is .B Color. .B Halftone Pattern (parameter .B \-\-halftone\-pattern for scanimage). Available only for the JX-330 series scanners. Possible settings: .RS .B none .br .B Dither Bayer .br .B Dither Spiral .br .B Dither Dispersed .br .B Error Diffusion .RE The default value is .B none. .B Paper Source (parameter .B \-\-source for scanimage). This option is only available, if an automatic document feeder or a transparency adapter is installed. Possible settings: .RS .B Flatbed .br .B Automatic Document Feeder .br .B Transparency Adapter .RE If an ADF or a transparency adapter is installed, using it is the default selection. .B Custom Gamma (parameter .B \-\-custom\-gamma for scanimage). This option determines whether a builtin or a custom gamma-table is used. Possible settings: .RS .B yes enables custom gamma tables .br .B no enables a built gamma table .RE .B Gamma (parameter .B \-\-Gamma for scanimage). This option is only available, if .B Custom Gamma is set to .B no. Possible values: .RS .B 1.0 .br .B 2.2 .RE The default value is 2.2. (The JX-250 and JX-350 have no built in gamma correction; for these scanner, a gamma table is downloaded to the scanner by the backend.) .B Gamma Table (parameter .B \-\-gamma\-table for scanimage). Allowed values: 0..255; 256 numbers must be defined. The default values are 0, 1, 2, .. 255 (i.e., gamma == 1). This table is only used for gray scale scans. .B Red Gamma Table (parameter .B \-\-red\-gamma\-table for scanimage). Allowed values: 0..255; 256 numbers must be defined. The default values are 0, 1, 2, .. 255 (i.e., gamma == 1). .B Green Gamma Table (parameter .B \-\-green\-gamma\-table for scanimage). Allowed values: 0..255; 256 numbers must be defined. The default values are 0, 1, 2, .. 255 (i.e., gamma == 1). .B Blue Gamma Table (parameter .B \-\-blue\-gamma\-table for scanimage). Allowed values: 0..255; 256 numbers must be defined. The default values are 0, 1, 2, .. 255 (i.e., gamma == 1). .B Resolution in pixel per inch (parameter .B \-\-resolution for scanimage). Selects the resolution of the scanned image. Allowed values: .RS .B 30..600 (JX-330, JX-350 and JX-610) resp. .B 30..400 (JX-250) .RE The default value is 150. .B Scan Window The possible settings depend on the scanner model and, for the JX-250 and the JX-350, also on the usage of the automatic document feeder resp. the transparency adapter. Please refer to the values allowed by xscanimage, or xsane. With scanimage, enter one of the following commands: .RS .I scanimage \-d sharp \-\-source """Automatic Document Feeder""" \-\-help .I scanimage \-d sharp \-\-source Flatbed \-\-help .I scanimage \-d sharp \-\-source """Transparency Adapter""" \-\-help .RE in order to see the allowed parameter values for the scan window. The scan window parameters are: .RS Top-left x position of scan area (parameter .B \-l for scanimage); .br Top-left y position of scan area (parameter .B \-t for scanimage); .br bottom right x position of scan area (parameter .B \-x for scanimage); .br bottom right y position of scan area (parameter .B \-y for scanimage); .RE .B Edge emphasis (parameter .B \-\-Edge emphasis for scanimage). This option is not available for the JX-250 and the JX-350. Possible settings: .RS .B None .br .B Middle .br .B Strong .br .B Blur .RE The default value is .B None. .B Threshold (parameter .B \-\-threshold for scanimage). Sets the threshold for black and white pixels in lineart mode. Possible values: .RS .B 1..255 .RE The default value is .B 128. This option is only available in scan mode lineart. .B Threshold Red (parameter .B \-\-threshold-red for scanimage). Sets the threshold for the red component of a pixel in in lineart color scan mode. Possible values: .RS .B 1..255 .RE The default value is .B 128. This option is only available in scan mode color lineart. .B Threshold Green (parameter .B \-\-threshold-green for scanimage). Sets the threshold for the green component of a pixel in in lineart color scan mode. Possible values: .RS .B 1..255 .RE The default value is .B 128. This option is only available in scan mode color lineart. .B Threshold Blue (parameter .B \-\-threshold-blue for scanimage). Sets the threshold for the blue component of a pixel in in lineart color scan mode. Possible values: .RS .B 1..255 .RE The default value is .B 128. This option is only available in scan mode color lineart. .B Light Color (parameter .B \-\-LightColor for scanimage). Sets the color of the light source. Possible values: .RS .B white .br .B red .br .B green .br .B blue .RE The default value is .B white. This option is only available in scan modes lineart color and color. .SH ADF USAGE If a paper jam occurred, the maintenance cover .I must be opened and closed, even if the jammed paper can be removed without opening the maintenance cover. Otherwise, the error condition cannot be cleared. .SH CONFIGURATION The contents of the .I sharp.conf file is a list of options and device names that correspond to Sharp scanners. Empty lines and lines beginning with a hash mark (#) are ignored. See sane\-scsi(5) for details about device names. .PP Lines setting an option start with the key word .B option, followed by the option's name and the option's value. At present, three options are defined: .B buffers, buffersize, and .B readqueue. .PP Options defined at the start of .I sharp.conf apply to all devices; options defined after a device name apply to this device. .PP The options .B buffers and .B readqueue are only significant if the backend has been compiled so that for each scan a second process is forked (switch .B USE_FORK in .I sharp.c ). This process reads the scan data from the scanner and writes this data into a block of shared memory. The parent process reads the data from this memory block and delivers it to the frontend. The options control the size and usage of this shared memory block. .PP .B option buffers defines the number of buffers used. The smallest number allowed is 2. .PP .B option buffersize defines the size of one buffer. Since each buffer is filled with a single read command sent to the scanner, its size is limited automatically to the size allowed by the operating system or by the Sane SCSI library for SCSI read commands. A buffer size of 128 kB or 256 kB is recommended for scan resolutions of 300 dpi and above. .PP .B option readqueue defines how many read commands to be sent to the scanner are queued. At present, the Sane SCSI library supports queued read commands only for for Linux. For other operating systems, .B option readqueue should be set to 0. For Linux, .B option readqueue should be set to 2. Larger values than 2 for .B option readqueue are not reasonable in most cases. .B option buffers should be greater than .B option readqueue. .SH Performance Considerations This section focuses on the problem of stops of the scanner's carriage during a scan. Carriage stops happen mainly with the JX-250. This scanner has obviously only a small internal buffer compared to its speed. That means that the backend must read the data as fast as possible from the scanner in order to avoid carriage stops. .PP Even the JX-250 needs only less than 10 seconds for a 400 dpi A4 gray scale scan, which results in a data transfer rate of more than 1.6 MB per second. This means that the data produced by the scanner must be processed fairly fast. Due to the small internal buffer of the JX-250, the backend must issue a read request for the next data block as soon as possible after reading a block of data in order to avoid carriage stops. .PP Stops of the carriage can be caused by the following reasons: .PP .RS \- too much "traffic" on the SCSI bus .br \- slow responses by the backend to the scanner, .br \- a program which processes the data acquired by the backend too slow. .PP .RE Too much "traffic" on the SCSI bus: This happens for example, if hard disks are connected to the same SCSI bus as the scanner, and when data transfer from/to these hard disks requires a considerable part of the SCSI bandwidth during a scan. If this is the case, you should consider to connect the scanner to a separate SCSI adapter. .PP Slow responses by the backend to the scanner: Unfortunately, Unix-like operating systems generally have no real time capabilities. Thus there is no guarantee that the backend is under any circumstances able to communicate with the scanner as fast as required. To minimize this problem, the backend should be compiled so that a separate reader process is forked: Make sure that .B USE_FORK is defined when you compile .I sharp.c. If slow responses of the backend remain to be problem, you could try to reduce the load of the system. Even while the backend and the reader process need only a minor amount of processor time, other running processes can cause an increase in the time delay between two time slices given to the reader process. On slower systems, such an increased delay can be enough to cause a carriage stop with the JX-250. For Linux, the usage of the SG driver version 2.1.36 or above is recommended, because it supports, in combination with the SCSI library of Sane version 1.0.2, command queueing within the kernel. This queueing implementation, combined with a buffer size of at least 128 kB, should avoid most carriage stops. .PP Slow processing of the scan data: An example for this situation is the access to the scanner via a 10 MBit Ethernet, which is definitely too slow to transfer the scan data as fast as they are produced by the scanner. If you have enough memory available, you can increase .B option buffers, so that an entire image can be stored in these buffers. .PP In order to see, if the backend is too slow or if the further processing of the data is too slow, set the environment variable .B SANE_DEBUG_SHARP to 1. When a scan is finished, the backend writes the line "buffer full conditions: .I nn" to stderr. If .I nn is zero, carriage stops are caused by too slow responses of the backend or too much "traffic" on the SCSI bus. If .I nn is greater than zero, the backend had to wait .I nn times until a buffer has been processed by the frontend. (Please note that .B option buffers must be greater than .B option readqueue in order to get useful output for "buffer full conditions".) .SH FILES .TP .I @CONFIGDIR@/sharp.conf The backend configuration file. .TP .I @LIBDIR@/libsane\-sharp.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-sharp.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_SHARP If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH KNOWN PROBLEMS 1. ADF Mode .RS After several ADF scans, the scanner moves the carriage back to the idle position and back to ADF scan position, before a scan starts. We do not know, if this is a problem of the scanner, or if this is a bug of the backend. At present, the scanner must power off and on to stop this annoying behaviour. .RE 2. Threshold level does not work (only JX-610) .PP 3. The maximum resolution is limited to 600 dpi(JX-610 supported to 1200 dpi) resp. 400 dpi (JX-250) .PP 4. If the JX250 is used with an ADF, the following situation can occur: After several scans, the scanner moves, after loading a new sheet of paper, the carriage to the idle position, and then back to the position used for ADF scans. This happens for .I every scan, in contrast to the calibration, which is done after 10 scans. (For the calibration, the carriage is also moved to the idle position.) We do not know, if this behavior is caused by the backend, or if it is a bug in the firmware of the scanner. .PP 5. Usage of a transparency adapter (film scan unit) is supported, but not tested. .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHORS Kazuya Fukuda, Abel Deuring .SH CREDITS The Sharp backend is based on the Canon backend written by Helmut Koeberle .PP Parts of this man page are a plain copy of sane\-mustek(5) by David Mosberger-Tang, Andreas Czechanowski and Andreas Bolsch sane-backends-1.0.29/doc/sane-hpljm1005.man0000666000000000000000000000214713615534521015013 00000000000000.TH sane\-hpljm1005 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-hpljm1005 .SH NAME sane\-hpljm1005 \- SANE backend for Hewlett-Packard LaserJet M1005 MFP Scanner .SH DESCRIPTION The .B sane\-hpljm1005 library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Hewlett-Packard scanner: .PP .RS LaserJet M1005 .RE .PP If you own a scanner other than the ones listed above that works with this backend, please let us know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .IR /proc/bus/usb/devices , .I sane\-find\-scanner or syslog) to us. Even if the scanner's name is only slightly different from the models mentioned above, please let us know. .SH CONFIGURATION None required. .SH FILES .TP .I @LIBDIR@/libsane\-hpljm1005.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-hpljm1005.so The shared library implementing this backend (present on systems that support dynamic loading). .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .SH AUTHOR Philippe R\['e]tornaz sane-backends-1.0.29/doc/sane-escl.man0000666000000000000000000000251513615534521014320 00000000000000.TH sane\-escl 5 "14 Dec 2019" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-escl .SH NAME sane\-escl \- SANE backend for eSCL scanners .SH DESCRIPTION The .B sane\-escl library implements a SANE (Scanner Access Now Easy) backend that provides access to eSCL protocol scanners. .PP The "escl" backend for SANE supports AirScan/eSCL devices that announce themselves on mDNS as _uscan._utcp or _uscans._utcp. If the device is available, the "escl" backend recovers these capacities. The user configures and starts scanning. A list of devices that use the eSCL protocol can be found at .IR https://support.apple.com/en-us/HT201311 . While these devices are expected to work, your mileage may vary. .SH FILES .TP .I @CONFIGDIR@/escl.conf The backend configuration file. .TP .I @LIBDIR@/libsane\-escl.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-escl.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_ESCL If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH "SEE ALSO" sane(7), scanimage(1), xscanimage(1), xsane(1) .SH AUTHORS Touboul Nathane, Thierry HUCHARD sane-backends-1.0.29/doc/umax/0000755000000000000000000000000013615535552013001 500000000000000sane-backends-1.0.29/doc/umax/sane-umax-text4.jpg0000666000000000000000000000621013615534521016365 00000000000000ÿØÿàJFIFÿþXCREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2) Quality = 75, Smoothing = 0 ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀ2È"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?÷ú(¢€ +Å-Ó¼)d“ß3<’6"‚<Rì=ƹË?ŠvÓørMf]"éc†àA*BÂM„Œ‚IǦ}HÒæGM<zSŒtnËÔô+ð·Ä=7ÅZŒ–6¶÷0Ì‘™zèO¨«Þ/ñ\>ÒῸ¶’â9&í€ •$uÿtÑuk“,5XÕö.>÷c¢¢¼çDøÁ¥k:Õ®›ö «v¹-$vR¡LýzWAã?CàÍ6 ë›9®a–_'÷LVÁ#¯°?•A<5XMS”lÙÓQ^[¦|pÑuRÞÉôû«a;ˆÄ²2•Rzgã8íUï>;é¶“Ú\èwé<4R&øÎÖS‚8>¢‹ xZÉÙÄõª+μ[ñwLð•í´ÚuÝÏÚ­í2 bÃ=þSUtŸzf±e©ÜÛèÚ‰þÏ€\Kì,cÎŽqÇûf‹™û)Úö=>Šó ühÐ|W¯Á£ÛYjO0;dM¤ŽqÃôŠd´ÖŒ(¢ŠQEQEQEQEQEQEy7Æ­:êX´ÍB8Ýí¡ß¬’Wn{ó‚=8µçÞñÐ5&Æ'Ón‡•y ‡Cߣ'õëÙ|sâ›}÷M³ÔmÒ}+PYcºK2´=GÌr?/ñ‡†›Ã¨…%ûEÂy¶·áÐö'¦GǨ8—OÔ¼3•yÂë$Ao)?,sm/6L¨éü|Ç&A Œ„W©ø×V{σ¾½ŽbfŽáÈ:‡DqŸ®EØy•/iZœ—Ÿù£È¦Im®9âš&*ÊÃk+È>„Ýñnuk=?ÄÉ—ûdbÞð์9ì7&ÖäüÕcÆé ñÓ¼IlSV„´ê¸nS\ wʶ{–& ð™:µ¦§á†Ú_Pͳݎ.cÉP áK ÉœŽ´üŒêÏ™*Ÿë÷¿?ä5áÿûÛÿèrTßµk YÖµ-Ná ³‚ÃtŽþ›×Œw$ðrj?‘=¿ˆô8$xôH‡¡ 5Kág…m–CàßÄ]¼±§ÊÁsÆ|¶çôÊøIÝ.up¬@m"ì6QåÒ§›cÐþˇï}çî;IXëÚF§;A§ê¶7rªï1ÛÜ$Œ gôÉÚþ¥Î°jµ…¤¬»Äw ÉÁ#ŒƒùWËÞ×fðï‰,µ¥dD,Àg ?0 u㟨‹µßøI|U¨jÁ<´¸“÷jFEW#' gœg8¥Ï å”rÕåæ÷m¿ŸcëHgŽâç‚D–:HŒYHÈ Ž ŠÍ³ñ>ƒ¨]%­–·¦ÜÜ>vE Üní“€OŸÂ¼wPñkè߬,’VkÍMZÕ7s¶òû¤&8?>GJòUºðþ³cªÛådĉƒË’ÏlŒÆ«˜ä§‚ç‹“}íæ}…¨jº~“Ï©_ZÙÂͱd¹™cRØ'bpÔEªé÷iÔ¡¾µ’À+9ºI”Äs¸ï99ã°õ=3Iø‰à´ŽP$µ¼‰f‚@0Ñ>8aèFOæAêkå;Ûûý.-KöګK¦¢dXdýÔå ãp¡Âžp0Û9éÒS[ê±4ÝsIÖ|ßì½RÊûÊÇ™ö[„—fsŒí'ÁühW™ü!ð\~ÐÆ¤e-ò+†FÈdÆAãƒ×LûšôÊf.×Ð(¢ŠQEy·Å k"M2]&Ô\›s"Ép­ómÁÀÇÊ{×;gá/j> »ðþ©¥m6ì“iÒÍ:þíù“å'‚¥±žçòöº*yUîwC0­ q¤­h»¯¾ç†hŸ üGi§j—s-ª^ÉjÐZÛ´™ûã#€v’¿^+ ÛáŒà¼‚uÒÔ4r+‚n=}!Eˆ¿íLG½vŸ1óLjþø®çÄZ…Õ­„RÃqpó#,ê0‹cœŒâ´.¾x²o†6ú1ÓÐÝÛêFuˆL¹1”#9Î:ŸZ÷z(åDK0­$“¶‡Ïº'Ã?ÜøkVе=8[#•»²•æV p¼`…nŒ¤¯·œV·ÂOYÞCuo§F³Bë"7Ú‚Gzú†ŠvD}r¦·¶§ˆüVøuâk:n©am…l £ó‚²HØõã0ïØÖ?ƒþüCðŒZ½ÞŸekýŸ‚’u;2ÙfdàsÛèj(±Š­.^Sço|/ñŽñMÖõkQäÇ+É<Í8v%•†O9$“^ãâ|GáËÝ)¥1yê6¸Ã+†@ϵlQE„ªJ2SŽ?/„£ u¯¢¨§ÊŒž2®Šû¥èt‡†-ìm‘'f_6I2ÂxÑvã$“óÀ'8#Jø«Þh7Í{"Zê l‡•b3Á=@9ëëŽ9ú:Š,fëÌòß„ºo‹ü7lú¹eöb{i•þh˜œ•#‚I9ê¨ SANE-umax - UMAX Mirage scanners
SANE-logo
UMAX-logo

UMAX Mirage scanners




UMAX scanners
 Mirage series:
Name
SCSI-ID
Versions
UTA
ADF
B/W
Gray
Color
Bits/pixel
Resolution
Mirage
Mirage D-16L
all (2.7)
incl
 
ok
ok
ok
1,8,10,24,30
400 x 800
800 x 1600*
Mirage II
Mirage II
all (1.6)
incl
 
ok
ok
ok
1,8,12,24,36
700 x 1400
1400 x 2800
Mirage IIse
Mirage IIse
?
incl
 
?
?
?
1,8,12,24,36
700 x 1400

* Mirage D-16L scanners allow scanning up to 800x800 / 1600x1600 dpi.

UTA = Umax Transparancy Adapter, ADF = Automatic Document Feeder
(X = supported by scanner, incl = is included)



This page has been changed on 12th. february 2001

Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-others-doc.html0000666000000000000000000001024713615534521017555 00000000000000 SANE-umax - other UMAX scanners
SANE-logo
UMAX-logo

Other UMAX scanners





The sane-umax library implements a SANE backend that provides access to several UMAX-SCSI-scanners. Parallel- and USB- scanners are not supported!
Here is a list of the UMAX-scanners:
UMAX scanners
 Other scanners:
Name
SCSI-ID
Versions
UTA
ADF
B/W
Gray
Color
Bits/pixel
Resolution
Gemini D-16
Gemini D-16
?
X
 
ok
ok
ok
1,8,10,24,30
400 x 800
800 x 1600
PageScan
PSD
all
--
 
ok
ok
ok
1,8,24
300 x 300

UTA = Umax Transparancy Adapter, ADF = Automatic Document Feeder
(X = supported by scanner, incl = is included)




This page has been changed on 12th. february 2001

Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/umax.CHANGES0000666000000000000000000011253513615534521014673 00000000000000CHANGES FOR UMAX BACKEND FOR SANE --------------------------------- umax -> sane-0.6: ----------------- * umax-sane-backend created: - umax.c splitted in: umax-cli.c, umax-scsi.c, umax-driver.c, umax-text.c - umax.h splitted in: umax-scanner.h, umax-scsi.h, umax-scsidef.h, umax-struct.h - outputs done by DBG(level,msg,args...) defined in debug.h - scsi-calls changed to sane-format (of sane-0.57) - created umax.c and umax.h for sane-backend * changed search-path for scsi.h and sg.h, now needs /usr/include/scsi * removed mistake in bound-function * added "Vista S-6E" as supported * added PowerLook-II (PL-II) as supported * added Astra 600S as supported sane-0.6 / 0.61 / 0.62 -> 0.63 ------------------------------ * added exception to gpl-licence: > 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; either version 2 of the > License, or (at your option) any later version. > > This program is distributed in the hope that it will be useful, but > WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > General Public License for more details. > > You should have received a copy of the GNU General Public License > along with this program; if not, write to the Free Software > Foundation, Inc., 59 Temple Place - Suite 330, Boston, > MA 02111-1307, USA. > > As a special exception, the authors of SANE give permission for > additional uses of the libraries contained in this release of SANE. > > The exception is that, if you link a SANE library with other files > to produce an executable, this does not by itself cause the > resulting executable to be covered by the GNU General Public > License. Your use of that executable is in no way restricted on > account of linking the SANE library code into it. > > This exception does not, however, invalidate any other reasons why > the executable file might be covered by the GNU General Public > License. > > If you submit changes to SANE to the maintainers to be included in > a subsequent release, you agree by submitting the changes that > those changes may be distributed with this exception intact. > > If you write modifications of your own for SANE, it is your choice > whether to permit this exception to apply to your modifications. > If you do not wish that, delete this exception notice. * split resolution in x-res and y-res, flag bind-resolution * only sane_... functions will be exported from umax-backend, all umax_... functions are made static * removed umax-emergency-routine for SANE * made program-flow (esp. with do_canel) SANE-specific * fixed missing 3-pass parts * made scanmodes, sources, analog gamma, gamma download, negative, quality calibration, highlight, shadow only selectable if they are available * calibration-mode selectable in advanced options if available * warmup selectable if available * changed umax-scsi.c like described from Gordon Matzigkeit in his diff/patch-file from 21.06.97 so that the umax-backend should compile on non-linux-systems now - thanks! * split highlight and shadow in R, G and B for color-mode. * reset adf and uta flag when not used (in sane_start) * added possibilty to change calibration-mode if available * added send_halftone_pattern to umax-scsi.c * changed umax-scsi.c like described from Gordon Matzigkeit in his diff/patch-file from 21.06.97 so that the umax-backend should compile on non-linux-systems now - thanks * added support for each color (R,G,B) for highlight and shadow * added "Astra 1200S" and "UC840" as supported * added bad bugfix for preview-problem with S6E (in umax-scsi.c function start_scan) * moved resolution-check from check_values to bound_scanarea, now no floatingpoint-exception will occur if no resolution is given! * changed range-check for width and height * removed bug in set_window for three-pass-rgb-mode -selected wrong buffer for some green and blue options -scanmode now is greyscale instead of rgb * changed start_scan(us) to better use with wid-list and added missing 3 wid-bytes in scan.cmd * removed parameter color in three_pass_function_headers, the color ist taken from us->three_pass_color now. sane-0.63/0.64/0.65 -> 0.66 --------------------------- * changed gamma-data-upload for 3-pass-color-scan * corrected wrong calculation for highlight and shadow selection for rgb-values * changed gamma data to use 8 bit (256 bytes) or 10 bit (1024 bytes) * included 10/30 bits per pixel mode * changed bug in sane_exit (free()) that sometimes made a segmentation-fault * made patches runtime-selectable * changed set_window_command to support 30 bits per pixel * changed send_gamma_data to support three_pass_gamma and 10/30 bpp * changed row_len in umax_bound_scanarea to 10/30 bit mode * added halftone-support for ug630, uc630 and uc840, but I don't know if all values are ok! * changed CBHS-50-range to 78-178 (from 103-153) * changed rangecheck for highlight and shadow * fixed get_cbhs_range-bug in umax-scsidef.h * added ADF-inquiry-bits to umax-scsidef.h * added color_line_arrangement_mode-inquiry-byte to umax-scsidef.h * added CCD_line_distance-inquiry-byte to umax-scsidef.h * added all most unused bits and bytes in inquiry to umax-scsidef.h * made patches runtime-selectable sane-0.66 -> 0.67 ----------------- * removed bug in sane_start: ADF and UTA flags have not been set correct * removed bug in init_options: value range for 10 gamma-input-bits corrected * made custom gamma available for lineart and halftone for nonlinear effects * added Vista-T630 as supported scanner * removed test_warmup in wait_scanner because adaptec 1542 has problems with request_sense-command in test_warmup it was only used for printing a message, so it was not important. * if a scanner has a full inquiry-block but is not known to be supported, the driver will print a warning and continue instead of aborting, option --continue (on umax-cli) will suppress the warning! * changed ugly definition char gamma[x] -> char *gamma; gamma=alloca(x); * removed bug (wrong length for 10 bit-gamma) in send_gamma_data * changed all buffer-definitions to unsigned char and insterted type conversions, so there are no more warnings because of typemismatches. * corrected bad definition of set_DCF2_gamma_output_bits sane-0.67 -> 0.68 ----------------- * changed open config to fp = sanei_config_open(UMAX_CONFIG_FILE) * changed all set OPT...BIND commands, endless-loop happend in sane-0.67 =>ane-0.67-umax-fix.diff.gz after that patch changed same for ten_bit_mode * changed some strdup() to (SANE_Char *)strdup() * added UMAX Astra 610S as supported scanner. it has the same problems in color-mode like the Astra 600S. sane-0.68 -> 0.69 ----------------- * changed maximum y-resolution from optical_res to y_res * changed sane_cancel (waitpid) like suggested by David Mosberger * added #include for AIX-support * replaced call to umax_wait_scanner with umax_do_calibration after umax_start_scan in umax.c * moved sense_handler to umax-scsi.c * removed call to umax_get_data_buffer_status in reader_process * added umax_send_shading_data, umax_send_gain_data and umax_read_shading_data, umax_read_gain_data * changed name: umax_read_data_block -> umax_read_image_data * changed length offest in do_inquiry from 5 to 4 and changed set_inquiry_length-offset from 5 to 4 * added calib_lines to structure US and added it to set_window - command in umax-scsi.c * changed in umax-scsi.c routine identify_scanner: vendor and product is tested for each model instead of vendor=="UMAX " and only model tested! Because of that the format of scanner_str has changed from product,product,... to vendor,product, vendor,product,... * added support for Linotype Hell Jade (LinoHell Office) * added empty routine umax_do_calibration in umax-scsi.c, it shall be called after umax_start_scan! * replaced all umax_*scsi with sanei_*scsi, so the umax-driver now directly calls the sanei_scsi-commands. * moved sense-handler from umax.c to umax-scsi.c and added detection for driver-calibration-request sense_handler got a new parameter (void *arg). * changed wait_scanner for SUN: usleep(0.1sec) -> sleep(1s) this is only a bad bugfix that will be replaced one day! sane-0.69 -> 0.70 ----------------- * moved reader_process to umax-scsi.c * changed include for _AIX and non-_AIX * added missing "," in definition line for UMAX Astra 1200S in umax-scanner.h * added in umax-scsi.c in function identify_scanner a test that only warnings and errors are printed if vendor="UMAX " * added routine umax_order_line_to_pixel and umax_order_line * moved reader_process from umax.c to umax-scsi.c and added routine for color ordering. * reset length offest in do_inquiry from 4 to 5 and set_inquiry_length-offset from 4 to 5 because umax-S6E didn't work with it! * corrected error in identify-scanner in vendor-test * changed end-detection of list of known scanners from #define known_scanners 15 to last item "END_OF_LIST" * added routine that corrects wrong inquiry-data from Astra 600S and Astra 610S * added test and selection for do_color_ordering in check_values * changed __sun-code in umax_wait_scanner because the scsi-driver answers with IOERROR instead of DEVICE_BUSY (this is only a bugfix for a little time) sane-0.70/0.71 -> 0.72 ---------------------- * inactivated selection of quality calibration (until it is supported by the driver) * changed maximum x_resolution from optical_res to max_x_res * reordered DBG-levels and defined them by symbols * changed all sizes that used type int to type size_t * changed wait_scanner for testing !sane_status_good, because testing sane_status_device_busy does not work with all scsi-drivers! * changed ccd-order in umax_order_line, the order is now specified by 9 values (before by 3 values), changed order tables and added a table for Astra 600S and another table for Astra 610S * changed ccd-order, now based on optical_resolution and added new routine umax_forget_line * added inquiry-block for UC1200S: NOT TESTED! * added inquiry-block for UC1260: NOT TESTED! * included print_inquiry into umax-scsi.c * added correction-routine for x_res > 600 dpi, phys_width is corrected in umax-scsi.c: bound_scanarea * changed umax-scsi: sense_handler: changed test for valid sense-block added test for button pressed * added output of sense-code and error-code in sense_handler * added options to select calibratin and scan exposure times * added options to select calibratin and scan lamp density * moved all option-names/titles/descr. to saneopts.h * combined bind for highlight, shadow, analog-gamma and new exposure time functions to rgb-bind * added set_WD_line_arrangement(buffer_r, WD_line_arrengement_by_driver); if driver is doing color-ordering from line to pixel * included umax-scsi.c into umax.c * included umax-struct.h into umax.h * included US-structure into Umax_Device-structure * added free(scanner->device->buffer) to sane_close * added free(scanner->device->pixelbuffer) to sane_cancel * added free(scanner->device->pixelbuffer) to do_cancel * added SANE_UNIT_MICROSECOND to exposure-times * added output of status-string in wait_scanner * moved some options for Scan-mode-block to Enhancemant-block sane-0.72 -> 0.73 ----------------- * disabled RGB_BIND if no such value is available * included readproc * included bound_scanarea into check_values, problem with wrong scanarea for UTA should be solved now! * all scanmode- and scansource-strings are #DEFINEd now sane-0.73 -> 0.74 ----------------- * added support for 12/36 bits per pixel (for Astra 1220S) * added support for Astra 1220S * included inquiry data for UG80 (Escom Image Scanner 256) * moved WAIT_SCANNER from umax_read_data to umax_read_image_data, umax_read_shading_data now works! * added umax_start_scan at the end of calibration by driver, the scanner does not hang any more if quality calibration is enabled! There must'nt be a "wait_scanner" in calibration by driver routine!!! * added usage of driver internal values for calibration by driver if the scanner does not give back the informations about the shading data: width = dev->width * dev->inquiry_optical_res ( * 3 in RGB-mode ) * added 2 calibration-routines: - use last line for shading data - calculate average value for shading data - prepared routine for complex calculation * added gamma download curve format type 0 and 1 * defined gamma DCF = 1 for UC1200S and UC1260 * defined gamma DCF = 0 for UC1200SE and ARCUS PLUS * changed sense_handler: if bad sense_key => DEVICE_BUSY problem with black area at top of scan for some SCSI-adapters is solved now * changed wait_scanner: waits 0.5 sec now * disabled quality calibration in preview mode * made upper_left_x and upper_left_y even values it looks like even resolutions > 600 dpi work now! (not ok!!!) * added sigterm_handler for umax_reader_process changed sane_canel, do_canel and do_eof(=close_pipe), cancel now works! * changed trim_rowbufsize that made problems with SGI, there has been an overflow because of big buffersize sane-0.74 -> 1.00 (build 0) --------------------------- * added output of umax-backend-version in sane_init * added support for Linotype Hell Jade2 (Vobis ScanBoostar Premium) SCSI-ID "LinoHell","Office2" * changed base of calculation of scanwidth and scanlegth from pixel to resolutionbase (1/300, 1/600 or 1/1200 inch) problem with wrong pixelcount at higher resolutions should be solved now * changed selection for calibration mode * changed calculation for width in pixels for lineart and halftone mode * added inquiry for UMAX UC1200SE * corrected 12/36-bit-mode in send_gamma_data and array in umax.h * added support for Gemini D-16 sane-1.00-build-0 -> build-1 ----------------------------- * added support for Nikon AX-210 * changed all grey to gray (David Mosberger asked for it) * changed bug in gray gamma table conversion * added Linotype Hell Saphir 2 as supported scanner * changed umax-uc1260.h * added "- 1" in umax_order_line: else if (dev->pixelline_opt_res < length * 3 - CCD_distance * 3 - 1) else if (dev->pixelline_opt_res < length * 3 - CCD_distance - 1) * changed all allloca() to malloc() + free() * removed options speed and smear, I got the info from umax that these values should never be changed! * removed ten_bit_mode and twelve_bit_mode options, added option bit_depth and added support for 9, 14 and 16 bpp * replaced u10_range and u12_range by dynamically set scanner.output_range * removed static allocation for gamma_table[0..3], this is done dynamically in sane_open and freed in sane_close now. * added an empty string to the end of scan_mode_list and source_list build-1 -> build-2 ------------------ * added "*info |= SANE_INFO_RELOAD_PARAMS;" in control_option set bit_depth * added inverted calibration modes for Astra 6X0S scanners. build-2 -> build-3 (sane-1.0.1) ------------------------------- * inversion of calibration is automatically set for Astra 6X0S and Vista S6E * check for machine endianess is done only at backend start now! * made umax_do request_sense static build-3 -> build-4 ------------------ * Added option name and parameter in debug output in option set value * Added option name in debug output in option get value * Changed calculation of pixels/line and lines, may be the problem with shaered images at resolutions>600 dpi is solved now later Remark: This error does still occur, but not so often! build-4 -> build-5 ------------------ * Changed calculation in umax_order_line, color images should have the correct length now for Astra 6X0S and Vista S6E * Added DOR resolutions and area build-5 -> build-6 ------------------ * Bits for ADF and UTA in driver internal inquiry block (old UMAX scanners) are set dynamically now. * Added Genius ColorPage-HR5 (vendor KYE) (=Astra 1200S) as supported scanner * Added Astra 2400S as experimentally supported scanner * Added pauses for Astra 2400S * Removed reposition_scanner at start of scan, Astra 2400S does not work with it! * changed debug output in correct_inquiry * for UMAX S12 the driver does not wait any more until scanner is repositioned this is experimental, it may work with other scanners too! build-6 -> build-7 ------------------ * changed some int -> unsigned int (resolution and scanwidth etc) * calculate_pixel is called with right values in UTA mode now. * if DOR resolution is not defined and DOR is available the DOR resolution is set to double standard resolution * removed wait_scanner after set_window-command * added Mirage D16-L as supported scanner * Astra 2400S works stable now build-7 -> build-8 ------------------ * for Mirage D-16L the driver does not wait any more until scanner is repositioned this is experimental, it may work with other scanners too! * Mirage D-16L does not give back informations for calibration by driver, added new modus that "guesses" the values for Mirage D-16L. * Added read_shading_data to 16 bit calibration routine and made a routine for averaging with low byte first and one for high byte first * Byte order (HBT) is set always (also in lineart and halftone) because it is used in driver calibration * Added relevant_*_res the is set to normal or double resolution values * Added test if scsi buffer is large enough for one shading line * selection for Calibration mode, Shading type and Speed/Smear are only compiled in if define is set in umax.h build-8 -> build-9 ------------------ * slow speed options is preset for Vista T-630 * speed/smear can be set now (forgotten #ifdef) * selection of exposure times now is only available if it is enabeld * gamma table is disabled in lineart and halftone modes * if image is transmitted completly sane_read (close_pipe) returns with SANE_STATUS_GOOD in adf mode and in any other case with SANE_STATUS_EOF build-9 -> build-10 ------------------- * removed change about sane_read returns SANE_STATUS_GOOD in ADF mode * transformed all gif files into jpeg format because of all the trouble about the gif licence. Will never use gif again! * added correction for inquiry-ADF-bit for Astra 2400S * added second test method to detect ADF error in sane_start: inquiry block is read and cover open, jammed and no paper is tested build-10 -> build-11 -------------------- * test for adf errors (sane_start) is now only done if adf is selected build-11 -> build-12 -------------------- * moved adf error tests from sane_start to umax_start_scan * sane_control_option: printing option name is set to "(none)" if pointer is NULL * added error message after each call of sanei_scsi_cmd * changed manipulation of ADF bit for Astra 2400S in umax_correct_inquiry from dev->adf to set_inquiry_sc_adf() build-12 -> build-13 -------------------- * changed inquiry data of UC1200SE * added set_inquiry_CBHS(50) in correct_inquiry for UC1200SE * correct_inquiry is called for scanners with short inquiry now * dev->inquiry_max_calib_lines is preset to 66, problem with Vist S6E V1.6 should be solved this way. * inquiry block parameters > 0x93 are only used if block is long enough build-13 -> build-14 -------------------- * changed inquiry_cbhs_[min,max] -> inquiry_[contrast, brightness, threshold, highlight, shadow]_[min,max] and set correct values for CBHS_255 and CBHS_50 * changed cbhs_str[CBHS_50] from "78-178" to "0-50" * changed umax-uc1200se.h inquiry byte 0x64 bit 5 to 0 (gamma download format != 2) and wdb len from 0x30 to 0x31 * disabled halftone pattern download, and halftone dimension selection - not ready preselected is a 8x8 built in halftone pattern * removed set_inquiry_CBHS(50) from correct_inquiry for UC1200SE * added "Astra 2200 " as supported scanner * added cast from (void *) to (unsigned char*) in umax_send_gamma_data build-14 -> build-15 -------------------- * add "(unsigned)" to option number test in sane_control_option * for Astra 1200 the driver does not wait any more until scanner is repositioned this is experimental, it may work with other scanners too! build-15 -> build-16 -------------------- * OPT_SOURCE: removed change of width/height and "*info |= SANE_INFO_RELOAD_PARAMS;" from get_value to set_value and added "*info |= SANE_INFO_RELOAD_OPTIONS;" build-16 -> build-17 -------------------- * changed calibration mode from SHADING_TYPE_AVERAGE_INVERT to SHADING_TYPE_AVERAGE for UMAX S-6E, UMAX S-6EG and Vista-S6E * changed several int -> unsigned int * added support for sanei_scsi_open_extended and variable scsi buffer size build-17 -> build-18 (sane-1.0.2) --------------------------------- * some cosmetic changes of the form if (..) {...} => if (..) { ... } * removed unnecessary SHADING_TYPE-handling routines for UMAX S-6E, UMAX S-6EG and Vista-S6E * scsi buffer is only reallocated when size has changed build-18 -> build-19 -------------------- * added UMAX PowerLook III as supported scanner * added EPSON Perfection600 as supported scanner (is a Astra 1200S) * type of option 0 (Option numbers) is set to SANE_TYPE_INT now (undefined before) * removed bug that mixed 12 bit and 14/16 bit gamma table when 14 or 16 bit are supported and changed value range of grey custom gamma table: - maximum output value is 255 for 8 bits/pixel - maximum output value is 65535 for 9-16 bits/pixel the custom gamma table does work now with 9-16 bits/pixel output mode * added routine that reverses bit order in lineart mode when scanner sends LSB first in lineart build-19 -> build-20 -------------------- * added variable calibration_width_offset, Mirage D-16L offset of 308 is defined there and added offset of 28 for PowerLook III * umax_do_calibration: guessed calibration data vaules use 2 bytes/color if scanner supports gamma input bit depth supports 2 bytes/color * calibration by driver now does work for PowerLook III * added function umax_set_rgb_bind() that sets the sensitivity of some options that make available different settings for RGB. This function now is called when scanmode is selected. * changed some int to unsigned int * made dev->pause_after_reposition = -1; as default, so as default sane-umax does not wait any more while the scanhead is moving back - this may break the support of some scanners so it may have to be changed (dev->pause_after_reposition = 0;) for some scanners. reported to work for: - Supervista S12 - PowerLook III - Astra 2200 build-20 -> build-21 (sane-1.0.3) --------------------------------- * Added Linotype "JADE" as supported scanner * Removed bug in sane_close that caused segfault when sane_close was called twice with the same scanner handle build-21 -> build-22 -------------------- * replaced fgets() by sanei_config_read() * added command queueing for scsi read commands - removed WAIT_SCANNER scsi command call after read command - the additional buffers are allocated in the reader process - the number of buffers can be defined in umax.conf with option scsi-maxqueue [1..8] default:2 (did some tests with Supervista S12 and PowerLook III on the same scsi controller (ncr53c810): command queueing works, it is possible to start both scanners at the same time. The scanner with the higher scsi-ID (=priority) does scan without stops, the other scanner has to wait long time between the scsi-read commands, it also is possible to give bothe scanners different scsi command queueing depth). * prepared replacement of pipe by sanei_ipc_* routines * added routines umax_get_lamp_status and umax_set_lamp_status * updated inquiry output (new bits from powerlook scsi protocol 1.0 X101) * added new (powerlook scsi protocol 1.0 X101) window descriptor block entries to umax-scsidef.h * added button protocol (3 buttons, from powerlook scsi protocol 1.0 X101) * added button "lamp off" to turn off scanner lamp (this option may be remoeved again in later version, may be it will be replaced by an autmatic lamp turn off function) * added options to umax.conf lamp-off-at-exit [01] default:0 lamp-off-time [10..720] (in minutes) default:30 * if lamp_off_at_exit == 1 and lamp_control_available == 1 the scanner lamp is turned off in sane_close * renamed umax-scanner.h and umax-"scannername".h to umax*.c because these files create data code build-22 -> build-23 -------------------- * scsi commands set/get lamp control are send with a command length of 10 bytes instead of 6 bytes and control bit #7 is in byte 0x03 and not in byte 0x04 (it is described incorrect in the umax doc) * enabled lamp control for Astra 2200 * removed umax.conf options lamp-off-at-exit and lamp-off-time * added frontend option lamp-off-at-exit * added frontend option lamp-on * forcing calibration_bytespp = 1 for Astra 2200 - quality calibration does work now * for Astra 2200 selection for different x/y resolutions is disabled build-23 -> build-24 (sane-1.0.4) -------------------- * forcing calibration_bytespp = 1 for Astra 2100S * Added Astra 2100S as supported scanner * enabled lamp control for Astra 2100S * Added warning in sane_control_option if option could not be set build-24 -> build-25 -------------------- * dev->lamp_control_available is preset to 0 * dev is erased (0) after it is allocated * added special options for PowerLook 3000: - calibration is done for each CCD pixel - calibration_bytespp is set to 1 the scanner still is not listed as supported scanner because the changes are not tested * added options that are read from umax.conf: - execute-request-sense: values: 0=disabled, 1=enabled, default=0 If set to 1 umax_do_request_sense is called in umax_do_calibration. This can hang the system (but has been enabled until this version) - scsi-buffer-size-min, scsi-buffer-size-max: values: 4096-1048576, default min=65536, max=131072 - scan-lines, preview-lines: values: 1-65535, default scan-lines=40, preview-lines=10 define the maximum number of lines that are scanned into one buffer - force-preview-bit-rgb: values: 0=disabled, 1=enabled, default=0 set preview bit in rgb real scan - slow-speed, care-about-smearing: values: -1=auto, 0=disabled, 1=enabled, default=-1 dangerous options, needed for some scanners - calibration-full-ccd: values: -1=auto, 0=disabled, 1=enabled, default=-1 do calibration for each pixel of ccd instead of selected image - calibration-width-offset: values: -1=disabled, >=0 set value add an offset width to the calculated with for image/ccd - calibration-bytes-pixel: values: -1=disabled, 0=not set, 1=1 byte/pixel, 2=x bytes/pixel use # bytes per pixel for calibration - invert-shading-data: values: -1=auto, 0=disabled, 1=enabled, default=-1 invert shading data before sending it back to the scanner - lamp-control-available: values: 0=automatically set by driver - if known, 1=available, default=0 * updated html-documentation * updated sane-umax.man * added pre focus options (PowerLook 3000): - FP - fix focus position - FDC - lens calibration in doc position - PF - disable pre focus - LCL - use 0.6/0.0mm holder focus position * added #define SANE_I18N(text) text to umax.c. This is to mark the backend specific texts that shall be translated by the frontend build-25 -> build-26 -------------------- * added umax.conf option handle-bad-sense-error # * added Mirage II as supported scanner * added routine umax_set_max_geometry that defines available surface and resolution in dependance of scansource and double optical resolution (before this bugfix the change of dor mode overwrote the settings of scansource and vice versa) * added ESCORT Galleria 600S as supported scanner, is an Astra 600S * removed if (config_line[len - 1] == '\n')... while reading config file * changed some static unsigned int to static int * sane_exit does free devlist * added some options for Powerlook 3000 - still is not completly supported build-26 -> build-27 -------------------- * added Linotype Saphir4 as supported scanner (is a Powerlook III) * increased length of vendor, product and version by 1 to make sure the string always ends with '\0' * changed default minimum scsi buffer size from 64KB to 32 KB build-27 -> build-28 -------------------- * removed "#include " from umax.c, assert() is never called * added UMAX Powerlook 3000 as supported scanner * bugfix for 3 pass scanning: reposition_scanner is called in sane_start for 2nd and 3rd pass of 3 pass scan * bugfix for UTA and DOR geometry offsets: - added inquiry_uta_x_off and inquiry_uta_y_off - geometry ranges are defined from xoff..xoff+dx, yoff..yoff+dx now - check_values also does test for this range - removed dev->maxwidth and dev->maxlength, values are calculated in place now * bugfix for DOR: - bottom-right edge keeps in position if possible when DOR is switched on * bugfix for Astra 600S and 610S color mode: - scale_y is set to 0.5 if y_resolutions is smaller than optical_res/2 this does fix the color scan problems for Astra 610S. * added Heidelberg Linoscan 1400 "HDM LS4H1S" as supported scanner build-28 -> build-29 -------------------- * removed bug in umax_set_max_geomentry: now left y keeps in position when possible * rgb bind keeps unchanged when scanmode != color (only gray selection active in this case) * in function static int umax_give_scanner(Umax_Device *dev) moved umax_reposition_scanner(dev); to the end of the function * set calibration area for astra 2200 to full ccd and calibration_bytespp to 2 * UC840 does wait in reposition_scanner until scan head stops moving * set minimum resolution to 5 (was 1 before what could make problems) build-29 -> build-30 -------------------- * added EDGE KTX-9600US as supported scanner * Changing scansource does not change lower left selection edge if not necessary build-30 -> build-31 (sane-1.0.6) --------------------------------- * sane-umax.man uses @LIBDIR@ and @CONFIGFIR@ * changed automatic calibration_width_offset marker from -1 to -99999 * changed dev->calibration_area to 1 and calibration_width_offset to -1 and inquiry_max_calibration_data_lines to 66 for UMAX Supervista S-12, LinoHell Office and LinHell JADE build-31 -> build-32 (sane-1.0.7) --------------------------------- * added Nikon AX-110 as supported scanner (Vista S6E) * added umax.conf option "gamma-lsb-padded" with options: -1 = auto 0 = inactive (msb padded) 1 = active (lsb padded) activated for astra 1220s, internal 12 bit gamma correction does work now build-32 -> build-33 -------------------- * added USB support for Astra 2200 thanks to Frank Zago for creating umax-usb.c and suggesting several changes to umax.c * added umax.conf option "connection-type", values: 1=scsi, 2=usb * added umax.conf device selection "usb 0x1606 0x0230" (usb vendor_id product_id) * removed #ifdef HAVE_SANEI_IPC parts (SANEI_IPC was never defined) build-33 -> build-34 (sane-backends-1.0.8) -------------------- * removed bug in reader_process / umax_queue_read_image_data: - the integer value that keeps the length information is kept valid as long a queued scsi command is still running now - when the scsi command returns with less data than requested then the routine does handle this correct now (before the routine handled this as if the requested amount of data was returned) * backend waits until scanhead has repositioned after scan for UMAX UC1260 * y_dpi quanitsation is set to 5 (same as x_dpi quantisation - was 1) build-34 -> build-35 -------------------- * changed ID string "LS4H1S " to "LS4H1S " (remove one space) * activated lamp control for Astra 1220S V1.5 build-35 -> build-36 -------------------- * added PowerLook 2100XL as supported scanner * settings for PowerLook 2100XL: calibration_width_offest = 52 (calibration_bytespp = 2, default) (calibration area = image, default) * force_quality_calibration defined for PowerLook 2100XL: (normal calibration mode expects different calibration_width_offsets for PowerLook 2100XL, so it is not possible to calculate the correct number of calibration pixels in normal calibration mode) - disable quality calibration option for frontend - always set quality calibration bit when scanning * changes for exposure times: - Inquiry does print correct maximum value now - changed variable type from SANE_FIXED to SANE_INT - exposure times setting for colormode does work correct now - as default there is only one common setting for exposure times in rgb mode, added umax.conf option exposure-time-rgb-bind to enable different settings for each color - added option select-calibration-exposure-time, disabled by default. if disabled then the calibration expousre times are the same as the scan exposure times * added UMAX PS-2400X as supported device * added batch scanning support: Options: --batch-scan-start: calibration, scan, scanhead is not moved into home position --batch-scan-loop: no calibration, scan, scanhead is not moved into home position --batch-scan-end: no calibration, scan, scanhead is moved into home position --batch-next-tl-y: defines the y start position of the bext batch scan - calibration for batch scan needs a different offset and always is done for full ccd. PowerLook 2100XL: calibration_width_offset_batch = 1052 Powerlook III: calibration_width_offset_batch = 828 build-36 -> build-37 -------------------- * added Linotype Hell SAPHIR3 as supported scanner * if batch-next-tl-y is not set then the backend uses br_y build-37 -> build-38 (sane-backends-1.0.9) -------------------- * added Power Look 2000 as supported scanner build-38 -> build-39 (sane-backends-1.0.10) -------------------- * Power Look 2000: corrected wrong calibration-width-offset from 52 to 22 and added calibration-width-offset-batch to 24 * initialized some global pointers and num_devices in sane_init * replaced fork() by thread for OS2 build-39 -> build-40 (sane-backends-1.0.12) -------------------- * UC630: dev->pause_after_reposition = 0 build-40 -> build-41 (sane-backends-1.0.13) -------------------- * Astra 2200 SU via USB connection: quality calibration is reset and not selectable build-41 -> build-42 -------------------- * replaced fork() routines by sanei_thread routines * added call sanei_scsi_req_flush_all(); to do_cancel - in threaded case this is not done when reader_process is cancled * in reader_process: marked freed scsi buffers as freed(NULL). This is necessary when reader_process is run as thread! * Backend is compatible to Mac OS-X now. build-42 -> build-43 -------------------- * DOR mode does test for non negative upper_left_x values, set to 0 if negative build-43 -> build-44 -------------------- * the sense_hanlder stores the sense data in buffer[0] when valid sense data is avialable * do_calibration: - corrected bug in reading calibration width from scanner (added /bytespp) - when additional request sense is not called then the buffer is not erased, the sense data from the sense_handler is used - when additional request sense is called then the buffer is erased at first build-44 -> build-45 -------------------- * added defualt options for Linotype Opal2 * changed bug in highlight-blue function (using green value) sane-backends-1.0.29/doc/umax/sane-umax-histogram.jpg0000666000000000000000000006272513615534521017327 00000000000000ÿØÿàJFIFÿþXCREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2) Quality = 75, Smoothing = 0 ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀq"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?ô-STM.8Ù¢B…cXQŽJÜ}k3þûùàð:<_ÿýbÿÑuçwñÝ[N·6ó±RÜÄïÇêz.¿LêO‘sZç^ ±5=—:‹{_fû_¡èŸð—ÛÿÏÿ€ñÑÿ }¿üð?øp¶—+zLŠãq±Iëê}½?ǦWˆ5Ûâ?’‚â&H2À0ŸT®Ç€ è¹É9öèsĉ­ê1G},P/ÙáÔfŽ{ƒ¾o&5Ûƒ°¾O''iÀñ@»ÿ }¿üð?øð—ÛÿÏÿ€ñ×’FúïXð̉y•r“Ü»FåWœäŒû2§9ÍG‹o>Ïgy44‘]H‘ *Ñù Cd }Ñ×ð _ÿ„¾ßþxüŽøKíÿçÿÀxëÆ®¼[ªÚ[hlØ:+Å![’ò*àŒñ€Äu=3žp.^ëšÅŒr¡§Ã0‚K…·Ž9gp£·yÈ/œg àЬÿÂ_oÿ<þÇGü%öÿóÀÿà/ÑQo'ò.<ýÐdùcàO<òO¶(Óÿá/·ÿžÿã£þûùàð:òÍ“]øƒ}íÛ-½Æû¹ÞRbQŒ}PaIõ8Ê÷$ñU~Ò÷kW×o¨2ZÜËn©eqåy1Æ3¿€'œœç¶(×á/·ÿžÿã£þûùàð:óg¼ÕŸOK½:®¢’Í$™¶LÒ±¶0¸Úr@Ç#šž(¹{t½¤“É{ Ìn qóy‘œ‚á°@=oþûùàð:?á/·ÿžÿã¯$µñ.¥sÙíw½¸ƒ« Æz䓨ã®ÓÒ´<<×>²šâY%•·îy³‡$Ð¥ÿÂ_oÿ<þÇGü%öÿóÀÿà#_ݸÁ8nŸ/Í’1ž‡DÖ¯üAg¬Ýß?Øš ?Øå1%¾Ww™!e K0»}Np{Åšâê¿5«‹R‚&µ`cA¸:ìAõæŠæâÿ’%wÿ^ ÿ¢ÒŠôY\_EVÑïp"b7Ç—ïõ®dxgT ©,FdN çüþUÞ7ü}úãþ‚´ú,5&¶<Ú?_Ãuöˆ­äŒ“ʬ©·éŒô¥ŸÁ7ÜM§î–[slíç˜ÉÉ^õë]ÞŸ¬iš·™ý›¨ÙÞyXó>Í:ɳ9Æv“ŒàþUv¦0Œ~k_V»N¬®Ò¶½/o‡{¶ƒ¥|¡#B‚ã á>àu݇ÇûY§Kðùæ’YM`dJÁ.v ÇÎl+p>aƒ×žMz\³EšDK*vbG=É RE>¨Äóþ£µt¥)j$XU¦ “ï‚ sœž¹©,¼ >'™m§°,Dî<¨:(,ÇØq^•EyÇ€dºûg¦nûnÏ´~ÿö}ÞÆ=±M?œ±a¦²9î<ĹÚáØaˆ`Ù@8ö¯N¢€<Ìø½µ¿öLb+\ùJ$Q´‚ÍÈ9äƒß5ü=’Í™p’,k,¾dqïûØŒ¾=ÀÇêPŒÙü0ÔÞåŸPÓm–f–Í E÷á·$0ÆÕdðÎo]x"âòá.'Ó÷J¨cÜ& ¹ ÉVÃ|Ëìr:úפQ@ZŸZÜ[ -ŒWP×Dî ÷FKäcÚ¯CàûØ/.nã±Û=Îß5¼àwmnÀãÒ½ŠóCáóê“™¯4Ö‘Ìb"EÎÜ ;€ 0žjiüqsq-ÄÚ~ée·6ÎÞpŒœ•á¿^µéP™Ëà&¼k¹4ÌÎÒÇ1o?øã!Æìp þ´]xKÝF û3}Ô|·óñ·iÈà6&½2Šó¿øCï´~ßöô¯+Éß繜ã±Ö«Ýx kɦ–[ Î%òîŒb@2`®pHçµzeÀÇáJ(Ö8ì•UUtК†oÞÏymw%Žéí·yMç·pÁãvµè”P™Åà;ˆ.xlçä”Ìá/X+99$¨|Ê7gžéî_Oo2@]·VP:PÀ7ƒÇ+Ò¨ 1‡ÆE &”¬°´ÃLîÈ{±ç¯½W¼ø}öVzlO3ÏÎ×7,]¶ð1.âê@èyÇ#šõj(Èô¿†×°[È/tØÚîK„H¤b1°Ë´`‚=â¶,|{¦ÙÇiicåÁv¯œ2I<–ÏRkÑ( þÝWþ}ò"ÿðŽê¿óëÿ‘ük¼¢€8{è¼YrðGÿÞ46¾Y€ÜÝnedP¡þæ¸Ï3Œžµ^{_ÜK$ÏáÍ\I·3‹£æyg»¶gç3^Eyž£¤ÝèŸ 5 ÔUš+=§k£ ýA¢ºˆ¿ò$k?õèÔPRßñô?ëŒú ÓbRí4,Ÿ,¥ݸ؇ž3ÕzsÇÐÿ®1ÿè+P—dŽ]§¹oýp6šV§e¡hË"j7Oý‹±·†‰ìNëmʾHG8˜¡%ÛÉÚ¤e³2Iâ }*ÞvmFå„&D†U.Œñ”Vç÷–û£mÌÌ\ÄŒr×kçÉýïÒ¹GÇQi~(–ÂêçÊ·ÊY7Ä[I™J‚z˜G>üw­)ÒFÔí¨›±µqm©ÚønÒ6šiµ{m%Ã@ÌÀn¹F•Tõò€.=`÷®{KµÖm­4ùKjæt¶Ó%q<ÓIûÙe)t1 â02§ˆþð I5Úùò{ô£Ï“ûߥf3„´mb9¼›ÅÕÓJyîb‰nÞX0’‰#–imFèÈWŠ¢J4†ñ Õõ„’^ê"¹•TI •Ü­äÂe‘£u‰1Œ|á€çʆkwWö¯ky76ïñMº6FA<€ |$[Á*E j#D ª `@\0©9óî†{+GôÊQä'üü^ßQÿñº­çÉýïÒ>Oï~”gÈOùø¼ÿ¾£ÿãty ÿ?Ÿ÷Ôün«yò{ô£Ï“ûߥYòþ~/?ï¨ÿøÝBÏÅçýõÿªÞ|ŸÞý(óäþ÷é@|„ÿŸ‹Ïûê?þ7GŸóñyÿ}GÿÆê·Ÿ'÷¿J<ù?½úPŸ!?çâóþúÿÑä'üü^ßQÿñº­çÉýïÒ>Oï~”gÈOùø¼ÿ¾£ÿãty ÿ?Ÿ÷Ôün«yò{ô£Ï“ûߥYòþ~/?ï¨ÿøÝBÏÅçýõÿªÞ|ŸÞý(óäþ÷é@|„ÿŸ‹Ïûê?þ7GŸóñyÿ}GÿÆê·Ÿ'÷¿J<ù?½úPŸ!?çâóþúÿÑä'üü^ßQÿñº­çÉýïÒ>Oï~”gÈOùø¼ÿ¾£ÿãty ÿ?Ÿ÷Ôün«yò{ô£Ï“ûߥYòþ~/?ï¨ÿøÝBÏÅçýõÿªÞ|ŸÞý(óäþ÷é@|„ÿŸ‹Ïûê?þ7GŸóñyÿ}GÿÆê·Ÿ'÷¿J<ù?½úPŸ!?çâóþúÿÒF»nJ &uòñ!S‚ÆÕ˜Õ>Oï~”ûWg¼}Ç8¶ý:ç>"ÿÈ‘¬ÿ×£QGÄ_ù5Ÿúôj(©oøúõÆ?ýj»ÿ«—þ¾[ÿEÅVþ>‡ýqÿAZ®ÿêåÿ¯–ÿÑqPUóωœÿÂgs ¦ðú”¥Ôã Šä°9ö¯}ÔnþÁ¦]Þló>Ï Ë³8ݵIÆ{t¯žà•µ<÷L^_&[À¹Û©#Ó’xï]TäéáªÔ]’“šRW]}]øâÁâM ùìæê&ýã¸Àvrí„õ ~Œ ýoYƒCÓÅÜêÎ Š«dó óŽ˜Íx›â+W²È u¸`‘œ)¢öù˜sÚ·ß_ºÖ´ˆ¡šBLL×R ì¸`s’äF8À® Ôj<Ö;¨áiº¼²–—^[ÿÁÓ¹ípω·(vBqŽUŠ‘ùƒRW‰ÚkZ¤›­î¤Þfó¾`2T·9ä†#ßðêZw‰-ït»{¹#0¼Îˆ"v Èc\<©'¸Ñ ªAŠÀʅEV§QEQEQEQEQEQEQEQEQEQEQET¶ñøÿõìÿúuKgÿÿ^Ïÿ¡Ç@÷Ä_ù5Ÿúôj(ø‹ÿ"F³ÿ^Eu-ÿCþ¸Çÿ ­Wõrÿ×Ë踪ÃÇÐÿ®1ÿè+Ußý\¿õòßú.*ÃñMÄVÞÕ$™¶©¶xÁÁ?3 ª8õ$ ð]3þFÿ¯7þuí¾>ÿ‘'Pÿ¶ú1kÈt„FûL ëû¶÷ù ç]5ZŽ]6úÊßt’u.ú&dYB“ø²Ê7Re$záä?Òœˆ ¬Ð*C+I<„v±Œ‚‹Œð0Å8Ç—Lÿ‘ÂËþÛÿèRÒGÿöÿõÖçÿBJËk7NOM?dÌ1¬[³íù2{½VmRšÔ²´cie’bT’ çnw½úT3x†æ=bâ$Ù +ÇŠ\až%b7`àÅ€çjþ¤Ëq-Â"³ym 60qå\ýˆ+øŠæõOøùÕ¿ëûúÉ\^ÅÂ\•#gmøqaëÔ«$¦õJÿrþ¾g¥øsǺÆkàû\P˜¡É@Ò¨X·º€HO îÉ5ƒªüEÖµ;›+òCngšo³FŸ³•A8°ÜžFIô4×"[f #\îÈu Ïò¬ÖÓ@¾šUÈŠXãË„s8¿÷–³UÑíýÀ:ñ8 ‘«(A^:Û}l“𷣨ï|)ãû™î š‰Hì^@ÊȤ±Y$‘WròoêW¶=9ôû{¨n¼/¹F9ÁT0ëìE|Áuu{¤ÛXÁžY{t‘×h<‰]—¨à‚kÔü-ãhm´Ûiï.¤•¤‰UgA8àu‡AëW(;n›<ÔçF\²ÚïåoøcÔ¨¬« ~ÂôÞ!¸†)­%•&‰¤¢£¼ç.0sÐgâ¹/x¦)¼7~©rË<×íieYbCR† Üóɽ*Xj“Ÿ%¬u¹$zç~×çÒü#QÃì¶’HËg†ÍÓóê?r8êy¯B!•¢¦EPÌ™äœ=äjkЕ)8°N㨢ŠÄaEPEPEPEPEPEPEPRÙÿÇãÿ׳ÿèqÔU-Ÿü~?ý{?þ‡sßäHÖëѨ£â/ü‰Ïýz5Ô·ü}úãþ‚µ]ÿÕËÿ_-ÿ¢â« ÿCþ¸Çÿ ­Wõrÿ×Ë踨ƒø¥ÿ"Í·ý~/þ€õæš'ú›ïúíÿ´«Òþ)ȳmÿ_‹ÿ =yÞ—¥œ¬£Éf÷; +£ÿ"Õþ/ó.’»“ì¿TbiŸò8YÛý ZHÿãÞßþºÜÿèIK¦Èáeÿmÿô)i#ÿ{úësÿ¡%gñÿðý¸Ãþöýå"å§2°íåÈqﱆSùÖ&±–Ú„…‡ïo›ÐãúÖ²;FÙS‚A?Ϋê/ wRNn}[ýkØÇ`½´ÝNÑün¿C*mƧ2ícNçý}Ÿýv?úÔâ54€|ì“ì3æj¬²o¸³é3?øãÔÓJ"Aõ\ŽÇòË QÔTí©öн5T¾ŸðNòÝ&¸d‹r¼H ž:3ƒøÒ±\iñÞå!!—j«N úmvú-«A_æ´^إŴ±¢eu.Aç\ž}‡é^„ù0jš»jÿ~ßu¾óÉ©‡xÞz‘èí¯–¿›-O<š‚Kv¯(šàÉæOïJAç“ò‚zóøb”³Kw:4Ϲ¶¤`à *¨Uéè¢ÆV‚í,¢AåZËcžYJ¼¬O=r•zÊÑÒk¬0hÝ£ÚOpåOoL~µ¾4†ã'ªø{ë²ùiý#dž’²¥'§2Þíýz‰§jÙØÜÁ *Æræ=ŽXÈÇ®%'=¶÷¯@ðwˆ ½ñ©=Ü« ׿3vP>\…@xËaÔ pk„h<•†çß ?û5R²¹–ÒîÒê43‰X R¤>•P©ý£9=’š{ÿà'£V,=ã¯2ßÑ­¾ÿÀú:±`¬ S†ô8ÎàGç^GÄ;KíœÎ^(¬fò²]Ù ¸g—æ8Œq†ÏéœñWµê ¬ÛÜY%–Ú¯/<ÇØš%R¬ u Rx‡sæUŸ³ø¶þ¬yu+Fæ;KÏÛZËqÁ+Ïœ÷`e‰¶žH$ôã§åZjVðßÃdKå`Âåd`IôýÓŽ=«ÉN²×ºµþ¡2Çld´»²ÿYÑ–¸p9¸AÇ]£ÉY|ay‰n58ÞIá3<ÅpÙÚ1"Æ;à(•¾PqüëÐÂ`å^Ÿ7_øk*ݽy¬ZÛØÞÜC47ZÅ+´I(É1Œ²œgeAôÈ£SÔ†6œ¨Žêì[± ’7#•Æ;– ?õ¯ Ó¯¾É)óZF‡ÉÈ $E3®Üûjê|kã$Ö>Ç™&-ãÙsæmd–9†áŒç:wèkªYcHÅjîÊçÐõº+Ïü¨^7‰šÁ®$kEÒ­¤XXåU„Qr=>ñé×<× W^‹¥.VüËNáEPÖ/dÓ죚%Ffº·„‡²L‘·ã†8÷¯=ð‡4ëßx„Kpñ[ßͲ Ä£²â€pC>Pãrp¹¬Fz]Ôÿf³žãnï*6}¹Æp3ŠK[•¹¶·”áh„7dã?\dW#qâgÔü-À v PÝìûÚ0î‚rnCÏU`}j/k’ ZÖÒàæ$ˆÃw›#ë÷@ô•Ë,JUyzÁ9%‰J¯*Ú߭އÄÚ´^rfŽâX\@á‹p¹ذ>¸ÉíVìu$¿ãeF¶ŠáKq&ì;co¯zóïë¶ÜzsYJÌcdFB¥3·ö=Lô®›Á·/un’8PEŒü¾‹$Ê?@+E;ÎÈ÷*a}žNK_ø?ð¦Š(­8*[?øüúöý:Š¥³ÿÇÿ¯gÿÐã {â/ü‰Ïýz5|Eÿ‘#Yÿ¯F¢€:–ÿ¡ÿ\cÿÐV«¿ú¹ëå¿ô\Ua¿ãè×ÿôªïþ®_úùoýy·Å{‰V×K¶ ˆdy$eÀå”(?FoθgH.I$Ë*óè7âºßŠ÷5Ö—l3F’H˃±P~ªß•s6¬zHT¿„ŸÔÖùŽ˜ K»¨éÞòkÓúûŽwLÿ‘ÂËþÛÿèRÒGÿöÿõÖçÿBJ]3þG /ûoÿ¡KIü{Ûÿ×[Ÿý )åŸÇÿÀöã,gûÛô_”‰i 0@#¯4´WÖ™BàM^8üóþ5ºF ðX‘Dd,ŠO@A4ÚçªÎ~_«gD«7ECÏôHšØ“p™ÿ ÜšÖ€…x’åN{ €ÿÊ»ßkÿnð/ˆ,' öˆ®¥Dn0ÉÌ?–¨;ç漜uªF#Ù\è‡c–¶ñƒ§…,ïo®%/Š ãÛÂ[% +ª‚q€î¤)=N}MqúÜé÷Ðjvò–19‰±’®‘ncø…3U{™"‰ k BBäa]áLŸÄF?ïšÜð­¢Íam9Lù7²+6z+DþgoùÍxÕjZŸ7õ±•JŸ»¿ÕúsO«wfÓÏ8Æ Û¹¥•Ǯֵ4I3«ÚH¼n¹‹¯¡”×3swŸŽ‘ç}ŠöÁàœ±<+RÞvˆÀªYYŠêØ*C“‘ŠóÜlÔ»Ùÿ™­ %é©%{û6ÿòiKð_qFº?Ï0ÔÎ%qµ"EÃÜÅ=Žãǹõ®r¯è_ò0i¿õõþ†+x»3ìëÇš›G¶ÑEè-Ÿü~?ý{?þ‡ERÙÿÇãÿ׳ÿèqÐ=ñþDgþ½Š>"ÿÈ‘¬ÿ×£Q@KÇÐÿ®1ÿè+Ußý\¿õòßú.*°ßñô?ëŒú ÕwÿW/ý|·þ‹Š€<[âEßÚ|]$[6ýš‹9Îìùöûøü*•²íÓ¶ç8føá§øûþGmCþÙÿ赤ƒþgòBò–6/$b2v©Èôãõ®š"³¼žU#åYâ1€û¤þ4È•¡½Ëà´Ë:)Faøæ¤ŸþB£ýõþ•Ã99;y‘ÓC ¥QÆKE%òäWûÓ_c”ñnñprE¼Œ­ž„ ¦+¢‚t’{P¬§¡\íÈ®wZ‹„SnûÖÓ.1ÓÇÿf«º$¾tº[mÆ!eÆ}ô­çÓ^Hõ”U(Ô§Ûo¹/ÉšDÔb¯h_ò0i¿õõþ†* ؼ™•wgä½?¥7?bÔ-®¶oò%Y6ç¶qŸÂ³„“³=*U–#ªCí#Ü’D‘K#«JåNy~Nª?üyIÿ_W?ú9êýz+T|¬×,š –Ïþ?þ½ŸÿCŽ¢©lÿãñÿëÙÿô8é’sßäHÖëѨ£â/ü‰Ïýz5Ô·ü}úãþ‚µ]ÿÕËÿ_-ÿ¢â« ÿCþ¸Çÿ ­g_Ïul¤A¤j7»çgÍ´@€6F,@<ƒÓ=qM+»âþ;PÞ:¾SИ‡þCJ†ÅŒº´Í÷¥Rì@J•¿â/ x—Yñ<úŒüpJÑàJ€…Pr>†™eà¯âZ[É¢Þ ck.·iÖ¯7|ôèÆÙt× )5—Ykégúž¦Èáeÿmÿô)i#ÿ{úësÿ¡%u?<]‰-näÐ/ æîm£Œ™ã9þ!ùÒ'ÿaS ^edœŸ”pŽþƯ.j¯-6ÿÛŒñIËä¶²ü™ÎÑ]/ü+ßÿÐóþùãGü+ßÿÐóþùã_QõšξôgÊÎjŠéá^ø·þ€7Ÿ÷Èÿ?á^ø·þ€7Ÿ÷Èÿ>³Cù×Þƒ•œý·ü|/ãü«Fµ øâÄ™Y´+À„\ÿ„Äÿô¼ÿ¾+æ3©*˜„᪷Mz³è²Š´éÐjrIß«òGšjò0Ý×ÿÑF©êŸñ÷ý{Aÿ¢’»{φž3—X¸<=xbxÙU°9&=¾¾µZÿᦸG÷Œ¢Ÿ”r±¨=ýA®(§uèyx¦¥UµÞ_š9cþCwÿõó'þ„kGOÿíþ½ŸÿC–·u/…þ6¸Õ.æ‹Ã·“;©ùFAbGz¹gðÛÆQ]éŽþ¼ .’”–ŽþŒ?:RO‘/ëc,/»R“}+7ü|/áüš†ÿ…ü?“WD| â“0oì;Ìqü_ñ øÅ&`ߨw˜ãø>¿ã[òùŸAíé2ø»œåŤw1ynX ±àú‚þ„j˱s“èä1[ßðƒxŸþ€—Ÿ÷ÅðƒxŸþ€—Ÿ÷Åp8ÎNíj®>e%Tröï‹I n¾b²õ'(üöÆV­Ú;Uº.ù&.A#,ÓÕë[oÃÿ[øªkÙt+Å·hö‡Ú8^ÙÏcZïàÏ>8†‹y½[$yZSE%Ê´ýOuo‹½ôrÝûÏÃáü'ÊWÔõIÿI…wã¶àêqøUûö&çN‡ø^6$÷â)õ­uðŠ…ì²ócFŠÎ඘©îüâyol$Mð¬Q°s³¡(Ãù‘WK;lŸßm?óÐqŠ…žûv¾Ÿ›9ûû§‚xÝB’úû;U‰w¥ú;>âó qŒ ûqúVž¡àOÎÈcÐïÉù1ÕÉ¡«rø3IJO ƒD¼8b tùóü«²­*j.D®Ü¹»ÚúzhpЩ;7'¯#_znßâyö¹þ¾ßþ¸ÜèrêÖX òHcF’,þ?1®·Uøyâ뙡ht Æ Ê~P0Y0;úÕM/áÇŒí<ƒ/‡/~Iƒœü¯gøwî<Y«ñÁ?ñ$¼÷ÿ‘늟ž#Âz}–Ÿ j·K}³Qºš 9$C•" j3>TÿË}¬37ÅÚ^£ ÖšÖ£§ÝYOª£=Äw0´Mö• J@` JË4 û†€;µøÖŸø’ÞûˆGÿÆ*EøÌŸø“^ûÿŒWEÞ¬EÞ€=m~0£gþ%ƒþßãÿã"ü]FÏüJoý¿GÿÆ+Ê"ïV"ï@¦¿³ÿ»ÁÿoÑÿñŠ‘~)£gþ%—ƒþßcÿãæw«w K_‰ÈÙÿ‰uàÿ·ÈÿøÍH¿Q³ÿûÁÿo‘ÿñšóˆ»Õˆ»Ðªhž-—\¼’Ú ÀÉ|ý®.ODÄ>ó”\öÝž€Õ%ø€Ÿô+Áÿoqÿñš4]þ×ÃЬnd{Í·2ºDÌ1ƒå®FAÂ’ÙóÓ•¬¿i“Új ,Cöà]ÖE*|Ñþ³¯©!ú7à}ÚØ_£gýðÛÔüf¤_#gýðÛÔüf¸ˆ»Õˆ»Ðf¾1FÏú5àÿ·˜ÿøÕH¾,FÏî/ý¼GÿÆ«‹½X‹½ukâtlþæðÛÄüj¤_£g÷wƒþÛÇÿÆ«˜‹½X‹½tk¯#gä¼öÞ?þ5R.²ž/ý¶ÿV]êÄ]èmuDlÿÇàÿ¶Ñÿñª‘oѳó^ûkÿ¬ˆ»Õˆ»ÐšÝ#gç¼öÒ?þ7R,ÈÙýíàÿ¶‘ÿñº¡z±z¶¥?¾¼ð8ÿøÝH±£g÷÷ƒþÿ¨"ïV"ï@[dlÿ¤Þøün¨i7–Ú­î¡mÅâ›Y0§tgÌMÌ…¿ÕŒbX¦LÓ<ôa˜¼C«&•¥o ±šîUµ†æwUHY³™ ”ìPÏ´‘»nÑË ­«ø‡ÁÚ]–“u¤øƒG#GAl-ãÔ#vk6 ®ƒ,I+²98ÛÊÚ>ù •tÄlÿ¦^Æ?þ"¤]!?é·ƒþýÿñf.õb.ôIt4lÿ§Þû÷ÿÄRK¤¥¤M9º¹—hû°ž;(ÂîÚ;h|­Šö0HFbF?3!'’zš÷Fÿ¡ÿ\cÿÐV¼/â'Ãÿë~;Ôµ7D¹¹³›ÊòåM¸lDŠzŸPGá@Àø£âïùþ³ÿÁe¯ÿ§Š-?òýgÿ‚Ë_þ7M ¼sÿBÝçþ;þ4áð¯Ç#þe»Ïüwüi2ãn¢‰þ,ÿŸë?üZÿñºpøâÃÿ/¶ø,µÿãtÑð³Çô.^ã¿ãN |n?æ\¼ÿÇƧSXòu>&ø¯þlÿðYkÿÆéÃâgŠÿçöÏÿ–ßünš>xßþ…ËÏüwüiÃá¿è]¼ÿÇÆ¥ÜÖ>Ï­‡‰~*?òùgÿ‚Ûoþ7J>%x§þ,ÿð[mÿÆéÃù—o?ñßñ¥ |kÿBíçä¿ãIóGØõ·à8|IñIÿ—Ë?üÛñºpø‘âùû³ÿÁm·ÿ¦†^4ó/^~Kþ4áðÏÆô/^~Cüj}óXý_­¿Ãâ?‰ÿçîÏÿ¶ßünœ>#xœÿËÝŸþ m¿øÝ4|4ñŸý ןÿpøkã!ÿ2ýçä?Æ¥óùšÇê½yGÄ_ÏÝŸþ m¿øÝ8|Dñ7üýYÿà¶ÛÿÓGÃoпyùñ§†þ1ÿ¡~óòãRý§™´~©×—ð>!ø”ÿËÕŸþ m¿øÝ8|Bñ'üýYÿàºÛÿÓGÃù—ï?!þ4áðçÆô¼ü‡øÔ¿iæk©uåüˆ>$?òógÿ‚ëoþ7J> xþ~lÿð]mÿÆéïù€^ß#üiGÿÐóþùãK÷¾f±ú‡^OÀpñÿˆ¿çæÏÿÖßünœ<}â#ÿ/ø.·ÿãtÑðóÅßô¼ÿ¾GøÓ‡Ãßù€Þß#üj_¶óüM£ýדÿ%<{âùø³ÿÁu¿ÿ§x€ÿËÅŸþ ­ÿøÝ4|>ñgýo?ï‘þ4áðÿŃþ`WŸ÷Èÿ—í¼ÿXÿfõäÿÉE;ñü÷³ÿÁu¿ÿ§kÿóÞÏÿöÿünš<â¿ú^ß"œ<â¿ú^ß5?¿óüMcý—×Ùÿ䣇Žuóÿ-ìÿð_oÿÄS‡Ž5ïùïgÿ‚ûþ"š<â¡ÿ0;Ïûâœ<âŸúÞß/Ûùþ&ÑþÉëìÿòQÃÆúéÿ–Öø/·ÿâ)Gµßùígÿ‚ûþ"xÅ#þ`wŸ÷Å(ð7Š?èyÿ|RXóüMcý×Ùÿ䣇uÏùígÿ‚ûþ"œ׬Í_ü¸—Üe,«ü¿Šÿ2Êw©W½S]kÂãþf‹?ü¹ÿãTñ®x`ÌÏgÿ€×?üj¡ðÖnÿæ_qœ²Œgò~1ÿ2òw©S½g.½áÿ35Ÿþ\ÿñªzø‡Ãþf[?ü¹ÿãU/…ó‡¶_q“ɱ¿ÉøÇüÍ4ïZZ'ü…àÿè&¹Õñ'†üÌ–øsÿÆ«[ÃzÞƒ{¯[[Úk–ÓÎÁöDN aõhÀíÜÕPá¬ÞXÕ©‡’ŒZmÛd·f¸<£ M9Ê)'¼{ú—¾"ÿÈ‘¬ÿ×£QGÄ_ù5Ÿúôj+é¾:–ÿ¡ÿ\cÿÐV¾fø³ÿ%7Wÿ¶?ú%+é–ÿ¡ÿ\cÿÐV¹cá¿…5ýRmOR±¹–òm¾c¥Ó 8P£€8à ù`RŠúcþ¿èyÿ­þ ð7ýo?ð5¿Â©;ó@¥ô¿ü*Ð6óÿ[ü(ÿ…CàoúÞàk…jª$+4ŠZúWþÿèyÿ­þ¢ð?ýo?ð5¿Â´Uâ…cæ¡J+éOøT^ÿ mçþ·øRÿ¢ð?ýo?ð5¿ÂµX¨.Œ\¬ù¬RŠúOþ‚?èyÿþ£ðGý¯?ð1¿Â´XÚk£V|Ú)E}#ÿ “Áô¼ÿÀÆÿ _øTžÿ uçþ7øV‹0¤º?ëæ.F|Ü)E}!ÿ —Á?ô¼ÿÀÆÿ ?áRø'þןøßáZ¬ÎŠèÿó#>p¢¾Žÿ…KàŸú^àc…/ü*oÿÐ:óÿü+E›P]áþaìÙ󈥯£áSx+þןøßáGü*oÐ:óÿü+UœÐ]áþbölùÈRŠú3þ?‚¿èyÿþ§ðWýï?ð1¿Â´Yæ}™~æ/dÏ(¯¢ÿáSø+þ÷ŸøßáGü*ÿÐ>óÿü+UŸá—Ù—Ü¿Ì^ÊG΢”WÑ?ðª<ÿ@ûÏü oð£þO‚ÿèyÿþ¢â,*û2û—ù‡±‘ó¸¥ôGü*ŸÐ>óÿøQÿ «ÁŸô¼ÿÀÃþªâ\"û2û—ù‹ØÈùàRŠúþWƒ?çÂóÿøQÿ «ÁŸóáyÿ‡ü+EÅ5öe÷/ó°‘óÕ¾†ÿ…WàÏùð¼ÿÀÃþ«ðoüø^àaÿ Ñq^ }™}Ëÿ’°‘óЮ»á—ü”=/þÚÿ觯Wÿ…Wàßùð¼ÿÀ³þwIð†4=N-FÆÊånb å³Ü–r•éŽx&³ÅñF¶¥(ÆW”ZÙuVî8Ð’i•¾"ÿÈ‘¬ÿ×£QGÄ_ù5Ÿúôj+àΣ©oøúõÆ?ýi#ó¥s"„I<°ž^IùTçvî>÷§jVÿ¡ÿ\cÿÐV¢4qÍ€9¹n¿õÎ:òÿ Kocá­>mRðÊê’Ac KûJ &Î"R\|Ä7 I åMoGý¥yãEÓ¿µ¦F²Žî¶y1™Ý ÙKýß,6é1„mÆNêì>Òþ‹Y÷ZÛC©ÙÙGå™%” T©Ê¡ŽVRLæ"??jq‹–Àqþ5ÕâÓ—QKĄͥùÒC+F.Ö†D–(ön1™vFä`]™6“ƒ[·ú¦¥¦êm§^kU±ò%¹ÔLQÇöQ"Üd.àQS|¨ÞþðÄ•#jÛÄ0\Mpžmº¬rªFÞ`"PÉÙ•Gê=kCí/è´8¸îsâ/Gª^ v¶™¡´g†Í¡‘$¸Å°H ØdPe;2Ò)ø'GÃ)uâa¢Õµ![+EŽïbã}Á#r‚HÜ §æV'£ûKú-iE¤áÝGV½²Ó#¬Öñ\Iod#‚a_ìô¹,ƒË8bàŒ¨V (8"7ñ–²#¶¾’I.,V±—n<Ƕó¢SÌ1´¦8ƒ]™çiƒö—ôZ>Òþ‹@߉5(î®môý~»û0þқ˅"W%˜Ì#hÎ^8ÓpB¼ìÀ|µwz{]Üévs\ÍW4ª¶Ï·yP[ÙYF{0ÈïÍTÓìíôÏ0Û¬Œòc|“Ï$Ò3½Ø¶Ñ’@Îb{š»ö—ôZŸÊ“þÿOÿ£Ê“þÿOÿ¨>Òþ‹GÚ_Ñh*OùüOü?ür*OùüOü?ür ûKú-iE  ü©?çñ?ðÿñÊ<©?çñ?ðÿñʃí/è´}¥ý€'ò¤ÿŸÄÿÀSÿÇ(ò¤ÿŸÄÿÀSÿÇ*´¿¢Ñö—ôZŸÊ“þÿOÿ£Ê“þÿOÿ¨>Òþ‹GÚ_Ñh*OùüOü?ür*OùüOü?ür ûKú-iE  ü©?çñ?ðÿñÊ<©?çñ?ðÿñʃí/è´}¥ý€'ò¤ÿŸÄÿÀSÿÇ(ò¤ÿŸÄÿÀSÿÇ*´¿¢Ñö—ôZŸÊ“þÿOÿ£Ê“þÿOÿ¨>Òþ‹GÚ_Ñh*OùüOü?ür*OùüOü?ür ûKú-iE  ü©?çñ?ðÿñÊ8¸1´Ë ò™ø‹fdÞ9ûÇò¨>Òþ‹N·‘¤¼lųôÿ~:æþ"ÿÈ‘¬ÿ×£QGÄ_ù5Ÿúôj(©oøúõÆ?ýj»ÿ«—þ¾[ÿEÅVþ>‡ýqÿAZ¡5Ò%Ø´!¼Éd–U=°©9÷ùÇëM+ì«‹Ó¤yµ]Y]žG´³fv9,Ly$÷5ÑSÌ’ÇÈO’{ÉmŸxäyk.HÁþô‘®kJÿ‡‡ÿëÎÏÿD]×U¸Âwíþd²ŽµŽõ%vÁÓ×nŸÖº#\7VFæì¢™kŽ<Èá=úòþ¢¸¦×4íßK}Bo*9ÖmfÚQ,X®9ùA9öÇzѰdY4øøV£‡Ø3üÅc‰­yµÛúבÑKªF÷³þ¬z Ä'ˆ®-ü;}~%_¶»[Ϊ˕ Åm¼zc2c±çн¹4woa¼ù†a"9äì7­)Ïm¥@ãŽ}«)Þå–á œ9Ö×±·i«Y^£4S.ÆI9vH=æCÃÖ¯W”¥ÅŶ„ÑG#G=d;x!Öð€Aê1¸ô®‚_j_ÈrŒ!—Pˆ+‚#UtÈdŒc>„÷9¬cU5©ÕSïznë_ÁµFÃU¶Ô"G¹U`-È矕¿CV¡ž;„/nPì„ã«#óµM3†P”wD”QE2BŠ( Š( Š( Š( Š( Š( Š( Š( Š( ¥³ÿÇÿ¯gÿÐ㨪[?øüúöý:ç¾"ÿÈ‘¬ÿ×£QGÄ_ù5Ÿúôj(©oøúõÆ?ýkëþF;_úçwü­+i¿ãè×ÿô¬[¯ùíëßò´«§¿ÉþBfE¯üÂÿì1yÿ·5€oÿ²í´ÝCËó~Ë¥ÛOåîÛ»mµãc<ã8­û_ù…ÿØbóÿnkÏ|x»¼lrFÛ-4ñ߉Çõ®ÉIF3oúÕ‰&Ý‘å3¸’âIpÌHϹ®ÓJñ×Ù,^iUN£¹ ¤¤…Mš¦Ns¶ÌÍœØóÈj1ˆu;¸€$Π/A†=*µp9sûÏ©iÙÞ,ôÏøKôé´†EŠGEb“{E‚9ä–´`ǧÔWl²“â6˜ó"OM­©éê×€ ]`xC~íÙ]†:úüë]üKx¾)Ÿ\¶-Ëxn¼ƒ!*x$ØÆåʯ§Ý+WSžNS]¾î¿õ²2p“¾º_™é )ðòË4ª´¬±Ü-w•üϦZu ‰"9ÿRLóÔC†ýEy—‡üA,‰um¨]ì·F°/ ¹I±3ÓÍ<ŸoAZ6~2ò´«Hå¹ ¨Iu<÷nÑuóZ,‘´F—ÐŒvã’ÓüM¥¥MsV’8]²9BèˆXzŒ3ãìžj¥×ˆ¾Ó©ë}¬¥ZÀ,o·Z _ öä× ¡õ¯Ñu N]?T¶K‰"’i|”Nã,d7U'UGéÏ5BfÔîµ!ª%ijj3Hfy%PôéŸéŽÀS|Îñlu0Õg~Mº~+óOð=ÏMñk_\Bbù÷&#q€„BG^2²`g¾O¥uÝ[Ü©¸Š^¿qÃtÆz}Gæ+ç/xt(ÌgH”Û•Ù^V±Œ Ä/¯ôõ/ jbr ¬ˆÑùdQœîš$oÃåëYª³§;KTÙ窵hÔq¨´lô+"ÓÄsZÙHò®ùæ[fÇ “/´çé×$ŠŸZÔ†—¥Ïp ùÂ) *Àα³àã¶út®èEÎÖêwFJK™Wžø§\ºÅÒØÙßMQéÒ´±£Q ¬§ë†SÇ î:˜<@“ßEh-ØH÷Ü àêOÙÏ·Mo<4ã>êãRFÍQ\ã (¢€ (¨§¸ŠÚ1$͵K¤`àŸ™˜*Ž=I„¯¢Z(¢€ (¢€ (ªöÒ¼“Þ+ˆæ £Ä?ÌšMØMÚÅŠ[)ãmVh~õ- ²ã iÿŽŸÊ’±|#ÿ‰ÿ`+_ý†õHÖ0¼e.Ã~"ÿÈ‘¬ÿ×£QGÄ_ù5Ÿúôj)™KÇÐÿ®1ÿè+X·_ò1Úÿ×;¿åi[MÿCþ¸Çÿ ­bÝÈÇkÿ\îÿ•¥]=þOò2-æÿa‹Ïý¹¯'ø‡þ£Eÿ° ú׬ZÿÌ/þßûs^Iñ @WG¯‡íÛ9ë™øWEghKúûLº_ÉþG¬Ènÿþ¾dÿÐR«ºÇü†ïÿëæOýÕ*â‡ÂŒ©ü Ð(¢Š¢ËvŸê&ÿ?ÀôûÈ[Ç 1Ž,œû7ø e§ú‰¿Ïð=Z¹@öŽrÂGþòãÓÎpM›`ûá+ÍöR•NE»Óð=úrŒiFréý(©w /É$j̱ÝqßÌÀü²k_L¿ÃZ\"MpeI!…w°o‰Û9è1R=I¬¹¤fÒ¦>k~;ž®^ÚG,+–ýã²Åþ|×dèÂ…4«+ó_î³_©æÖìs|›$¿oÈétùާáë{™s²òIØ2?vÀ·N¤'ÿZ«Ç©^Ç¡ÝË4¢gSmnú$Mo:·çÉÏ9ÄÓn.4û‹ˆŒm®÷–ˆ ^UÈCŸûjÞ™Ï~+nH€ðÕÔ2É´.£n»Êõý?JèÂãiÆ´¡´¬»m{iò<éà«P{hÿEëägèJ~Ý3v—Cÿ%ä­­+Å-böNñK$Ñ+3Ë!ÎéÒ1žrA7 “x=j O0Þy2K;Œ’>é0È?J˹S-ƒÃÄæµ«™CSÙA_™Ûåµþöváð”åiÍ{G›×WþV=wÀ÷+sáxOœe•e—ÍfÉ;™ËòO^û×G^!áU´i5[õm¦-;ñŸ/t‘®ì`çÎ;ãÙj~?†Ç\´X.’{ˆ¦9 òÆvEå3`g÷¡Œç¥rb)J•›w¿ë©É^¤Gm5;¤š9DŽDf‰¶H(ØÐàƒô"«>©l¶ÂáY¤ŒË_*ó™ …ëŽ>u?çæðøþÛÃ+ñ›ui$Š÷ÿhW$€B+äcøQK{àŽ:ÖoƒµÛ«}hµYƒ$—jJà³…YmTt?t!ÇtÅeE:“ŒWS/i{yž¾/-ÍçÙªgÚÌPrFݹϡùÓƒýáU5ßùÅÿ_–¿ú>:òk?ÞÆ×Ó]³Ks=¼©Ñâ68‰w8V FsõÈg…õ"ö8.îü»qä$jÇ6Ý$œöàOL‘šõV[8{×Úß1ó¦{_£kéÇh‘-Òuù¹`ÌÊp=ÑÏûCñ·^QwâiuˆÖdÞLBhìYã0š1>r8 ÇNÝÈ5ØxZ½×4 ./Ýdš;†‹xP¥†òù±Æ: 毃8)¿/Ä¥+»= ×PÛËo¯µîd1D0Næ Ïo•óé^cñ3ÆÚ¶‘=½¾•'٠ɥ1“Dà Œc÷ç‚*§Šâ(õJ©gÿZ‡ý|ý•ÍøsÅÑêú´†{Ëx ºµµ’ÎÜÊŸë\ÊŠÜ*v‚;z ÖrxžO´È&]ÑOw¤ pp:dáTséïšç«^0µüÿš­xůŸásº¹º‚ΚâU“ß±ÀêxàzV_„ãñ?ìkÿ¡×)â‹ÛI¼0°Eu “ Jg1¤€°Ròàãӑϸ®À·?k˜I³fÝ(ñœýÉ™søíÏãV§y¤{ìðî}ݾæMñþDgþ½Š>"ÿÈ‘¬ÿ×£QZœRßñô?ëŒú Ö-×üŒv¿õÎïùZVÓÇÐÿ®1ÿè+X·_ò1Úÿ×;¿åiWO“ü„Ì‹_ù…ÿØbóÿnkçýGP¹Õ®/å¹øö´ŽÞ5áQ4dñž§¶I=ëè _ù…ÿØbóÿnkç}¡eÖ”t‘ÿ‘’´ÄÊÊÞ«å̼—ÞA¬Ènÿþ¾dÿÐR«ºÇü†ïÿëæOýÕ*æ‡Â…Oà^EU[´ÿQ7ùþ«“ÿÈ9ÿëÞæj§ú‰¿Ïð=\ŸþAÏÿ^ðÿ3^¦øÒ_“!î[ƒýzÛoý TVác´˜³ñ!ÿ©©`ÿ^ŸöÛÿCÿÇœ¿õæŸÉ«¾qRŸgÿ¤¢c'uÐÒµ*./3€Z?_¼?ª[±"ÈÀ·8÷ÍOêãÞ$ÿÐV¶ÿ—Oú÷?û-*tc²Ÿwú¥¡µJ­Ó„{/Õ±X“¦Îo4ûé«bçý}Ÿýv?úÖ3È:ãþÚÿ6­›ŸõöõØÿè^Nr’öVìÏO(wS¿xþfW‰'xE¾Ã‚á†{Œ9ùµ´ýdj8³¸¸ÿJººK('\bvàã }N~¢±|Sÿ.Ÿð?ý–©Ù3$Ö¬¤« +‚8 í–¼•é§×Rqóå¯RO[%ú3Ò4B.µU¸WrÐ[O Œñ“ Ÿ|mçý£YšˆŽËkr›Öá’3“÷{çò\~5‘¦ërCa¨Ü‡*±Ém+˜I wm½zaHǹ¯k]ÃP‘–9ž6`Àà09÷ÝŒW<9©U‹ìÿÉž-lK†"pZGÞŠ·ÞŠ×72ézf±ocæÄ5ã'Žp3ïU£-s5Ñ–6Tš+sØ>@H”¨8(cÊ—\•5­JÚÝÃ$Q\Ï+Ã|¨„ú÷Ï኱e:‹(e•AX¬ó€;,j>+¾iÕj¥MÒ»ùmù~,ß IÕ¥õŠË¿Þ­÷hgë1ÈuOµÆ%–G‚h¥yX»;.ø·݈ñõ«yòiçÍŒb…A >_”«sשíÀ§LÌÛwíß™ mé“#·õ©ív=¤°<žXšXrpWs¶Oo•½zxxa0«%ª·ÝÌ“8¦8{ËUþäP€$ír åe•Ö0>ò`ŸÅÿ<>›¢BÑjó¾¨Ýg²,ÂO“`ÞgwC•Èúеl-亮…Ôl]ùÿPÍÓÛ?¥tà³u*T‹}ä½4_רÕEÎãó-hE`×´»‰Yc…o#%Ù€RIôë>kOgk{dK5Å»G/yV9#¾:ŸÃ­y×ÛƲ©*«rzðBþë$ûdãñÓøVe²¹ºº›!b…fdþ,Gwáƒßå8úŠºµéW¦î÷ý$Í#.þgã-j8.ü",îËu«Dñ2ë$%J9‘‚%þ‘Ó5â"Õn5ÿ^G ËÜÛK¨M%®þ ÞUW–ä ©ôµijÚÍÅæ«¥B³þëLÑâÆ7?#‹PåºðáûŒ‘{ŠÏ¹µŠËƶÖÐŒGÖê:dðœœw=M|ܪYòù\Òu9dãÖ×/xzþîÃLƒPŠP‚ÒbˆíŒ&é l`ÿÀÍu€Ÿ·¸Ï×ø®Fâ×ì^Õm€p±jWR¿.â0k£¶ºVDº;ŠºÄüõåø×ŸYs'%çúkN£†­ÆVﬣoëÌ­!f‘™† ߟ5è¿ '’[I²°Ú* ÇAæîÇæÇó¯<Ÿý`ÿqô]ÿÂøüÕÿëÙ?ô1[Pø‘ôø¶¥½º/ÐÝø‹ÿ"F³ÿ^EäHÖëѨ®ã祿ãè×ÿô¬[¯ùíëßò´­¦ÿ¡ÿ\cÿÐV±n¿äcµÿ®wÊÒ®žÿ'ù ™6ŠHÓ¦±xô¦¾q¶‘¥ƒT‘Î]à ÇÔ™c¯¡¤½LÒ¡¿™]¢¶Ôoæp€*¿i'ïÅ|ïeÿš—ý{ýN!·'~õ ŠÐºÛó cþCwÿõó'þ„j•]Ö?ä7ÿ_2èF©TCáDÓø QEE–í?ÔMþêäÿòú÷‡ùš§iþ¢oóüW'ÿsÿ×¼?Ìש‡þô—äÈ{–àÿ^ŸöÛÿCÿÇœ¿õæŸÉªX?×§ý¶ÿÐÅD¿ñç/ýy§òjô^ËÑÿé(‚ÚÿÇä¿õÍ?›T6ßòéÿ^çÿe©—þ?%ÿ®iüÚ¡¶ÿ—Oú÷?û-l÷^¯ÿJBÿuÇýµþm[7?ëìÿë±ÿб›þA×ö×ùµlÜÿ¯³ÿ®Çÿ@zð3Ÿùuè{yFÓõæcx§þ]?àû-R´ÿYoÿ^7ú µwÅ?òéÿÿÙj•§úËúñ¸ÿÐe¯.?ÂûÿSËøµ}?È“Mÿ‘g\ÿ¶ú©õ½PK¦Ziß?î¡·q1Ÿ-‰ç¯FOÈþ5,§X|;ª£LÏ.;³sø)¬ªjšsmô¢<ˆÓR¨äú?ÑPÿÊØFóÿAJ–6+¢±ìl?8Ö¤ý|Ÿö¸ÿÐ B¿òoúô?úÕaµRÿ =| Ôã~­þ…–Œ3Hqй?‡ÿ®¡ùÍÿÿÑU°‡|‹ÆNï×5»˜Q²¸Y ‡èbZôñx¥õ9A»ß–ß}ÿCn´ÚVï÷¤V×ÂOª_K'ñYÄUmZö9upªû.,¥(änˆšÔÔ"id¿U ­Ì žÍ½Ï>ß0®~íŒÖð•'mªIlà÷qo”þ•äa'É.ñ·ßoò0§—J*Zk÷>_ørx˜iQYdy·’4qžÀ±·aŸl Ù´¸š?ù-w[dít®IÚŒ8îEQÓ­žö[6Œ¨2Ç<›»©Ž21ïû¶ôê)š›á…Nâ{sùÛ/øS§W’¢õ×úûŽj”*û«fßãoò/>•™$°Ææ-%˜ü±›wÈsÍ]’ÂÚëU¿¾1æ{{¸J¹b0&xéЛK º|1ã%ÞeÈ< HëŸÍÅ]‰´ë—Úe8·"¹«sFM­¶OÊÿð Ü!V¯7w¿-bŸßg÷˜:ôŒÚF£“÷§¹òáÿŸK¹èÐuÎÔ^G÷AZ£Maª*7>ŸåT<7*™ü¬ʲ1ôÁ(?¡­³·cÙ¡BjÑ¥nžŸjÿäu3ÿ¬î/þ‚+¿øQÿš¿ý{'þ†+†¼RÝû€ü¿ýuÜü(ÿÍ_þ½“ÿC8wy#j•L»™y/¹Ûô7~"ÿÈ‘¬ÿ×£QGÄ_ù5Ÿúôj+¼ðN¥¿ãè×ÿô¬[¯ùíëßò´­¦ÿ¡ÿ\cÿÐV¹ÍZþÞÃ\¶–s&À·*|¸šB -±\…Œín}iI^V]Ÿä&s¾"]¾ »ÿ–Ú™ÿÇ.«Â­-öè÷·;³æFÑíÇM²BsŸøé^Û®ßÅuá‹«XcºyË^¸Ak'"Dœ&>^¤Èœuç8ò{}V_OÒïD‡ÌÂwÉËÁŽ1þË~GÒ¹êshßV‡‰kÝPÚÿ«15ù ßÿ×ÌŸúªU»ªè:Ìš½ë¦“~ÈÓÈU–ÙÈ#qäqU?áÖÿè¨à3ÿ…T>E?´V—ü#Úßýõüð£þíoþ€ú‡þ?øUAiþ¢oóüW'ÿsÿ×¼?ÌÔ¶º²°ÊI¿ôͳÿqý½ÅZ›CÕ̓¨ÒïKy }óNGJôèI*-_¤¿&CÜŽõéÿm¿ô1Q/üyËÿ^iüš´áѵA2¦Þûßù`ÝÜcµDº&­öIöeîMª®>ÎÝpÜtë]îq²×£ÿÒQ¿ñù/ýsOæÕ ·üº×¹ÿÙkMt}OírìëÌQŸ!½[Ú¢ƒFÕÙs¦Þ °sp~^:Vî¤.µêÿô¤+[þA×ö×ùµlÜÿ¯³ÿ®Çÿ@z¨tmSì¯ömæãæ`y “’qÚµ®4½A¦µ"Æä…”“ˆ[±‡¥x9ÃRöv×CÚÊd¢§wÖ?™Íø§þ]?àû-R´ÿYoÿ^7ú µ·âMUŸìÞN›y&ÝùÙtôR×CÕÕàÝ¥_ YΧ6ïÁ"\NGæ+ÍŠý×ßú˜æ-:µmÛüŒx¿ä uÿ_0ÿè2Õ*ÝAÖF‘r‡I¿Þgˆ…û3䀲dô÷Tÿ„{[ÿ >¡ÿ€Ïþ¬wgŸßõÑ ëäÿ°½Çþ€jÿ#סÿд“IÔDÒ§Ý`ê“Éþ¥¾éLéÐúÔK¤j_Øå?³®÷ý”®ß%³Š1Ó­FNkög§‚ia ŸvH¿ñðßòZ³ù1ñž1ŸÀëN]2ÿÏ'ì78çŸ)½Ú¤þ;ÿŸ+ûôßáQ‰»QK/Ôõà¨ÔSSkw×Óüˆ$2G|cq'‘‡Úc»ÍÛ—’|íÏÞi"Ç_lçð÷­ïìÛïùò¸ÿ¿MþŽ—¨#Ün±¹\Ä@Ì,2|ù§¡èksEhaŒœc*0ƒÒö~…{[/ì‹ë›3Íß'vݸº{úf²u{/G¹‡v|‰ 9ÇÞÄ(¿û6 êo´ë×Õäu³¸d0F˜Œ†|Žžãó¬_IÔ¥³Ô=>íË´[BÂÇ8HóŽ=åE.g$ß—èyXxB®*|N2oÕ;¯ÈÒ³O&ÒÜç?¼“ÿ˜†ÚiÎ{xÕFÙrÅQÉãßå­l/¤ m'9$ygÞ©þ\ÕK>ùä5•Ê–$ŒÂØ?+{{Šì8û­«¸½?ð/ÇvqRº”­ü×ù©IþˆÈºM–Z“g;Õ›éû°?¥sÚ ¾EÍÌÛwyvÌØÎ3‚ u÷z^ ÖWжE™(¶OËô®oLÐõx¾Ùæi7ë¾ÙÕslü“Ž:T¨hÒ]¿${xš‰V„“Úÿ›;ßøöµÿsú í¾Çæ¯ÿ^Éÿ¡Šã.­îd‚ÝRÎì”\7ú;ñÀö®ÛádCy«yÐKm—des󎙎HYÊ-oÐÆ•H,µÂê÷zuøÛü¯ˆ¿ò$k?õèÔQñþDgþ½Šì<éoøúõÆ?ýjuždP«+ªŽÁˆ¨þ>‡ýqÿAZ}Kö™ÿ缟÷Ù£í3ÿÏy?ï³\oŒ-’÷VðåœÍ0‚{©VAÏ` vrq•¯jÃëÿþŸ­ÝæiöWÑG,/{âËȾúoU$¦7c<zôï´Ïÿ=äÿ¾ÍiŸþ{Éÿ}šó];ÃVúÅÃ[é“è7Óªhí¼cw+È!PœdŽ}Åoø;H²‰n¯¬ÝÄÓÛ:µü×(­þ[2û;AÁÇs@_Úgÿžòßf´Ïÿ=äÿ¾ÍE\÷ޤx¼ ­I²H–®ÊÊpTŽ„Zé¾Ó?ü÷“þû4}¦ùï'ýökÅu»½+GÕï,ÿ³d1[H±ùÓø†æ-ÌÑ«ôçûÞ½«=5ý"GTM>&v8U_\’O â³u`´lë†4¥ï¶Ç½}¦ùï'ýöhûLÿóÞOûì×™x"×MÖµÖŽ}2âÝíÞP?µî.@ìÜ2±“A5éi©+£ž¥9Ò›„Õš%ûLÿóÞOûìÑö™ÿ缟÷Ù¨«Èm­¢– P,ç¼»»–ùÙ¤Õî-Ñ+€›‡FQÀ)Nq„\¤ì‘J‘§9»${Úgÿžòßf´Ïÿ=äÿ¾ÍxÅÌšmœíÔ:|.7G/‹.•†FFA\ô5zÎÆÖký:)ôÖ[{ç)öÞ!»—þY¼€à…sÞ±Ž*ŒšJ[ìam 5Ë}¼ÏYûLÿóÞOûìÑö™ÿ缟÷ÙªðÚÃemommŠ8c $ýÑÉ'’{’y'“O®ƒ¨—í3ÿÏy?ï³GÚgÿžòßf¼·Å¯o»¯ÞÝCqr¶–ö>TßKl»¥‘Ð’Pÿ»Ô•È7Š4tb­¥m`pAñ5È þU½,5Z«š èM¥¹ôÚgÿžòßf´Ïÿ=äÿ¾Í|ü|O¥˜%š=IV%,Â?\±ôö¯nÑ´›='LÙh’ó1f–g•ʼnrN=³ŽO©¥WR½¢µÁ4ö4þÓ?ü÷“þû4}¦ùï'ýöj*ä¼al—º·‡,æi„ÝJ²¦x‹°”ƒŒ¨={V#;/´Ïÿ=äÿ¾ÍiŸþ{Éÿ}šàŸÃžŽþ;–ð\È»–3©ÜäŽé§SµˆHF#;[ÓÁ:DŽRü“ÿQ;Ÿþ9@—Úgÿžòßf´Ïÿ=äÿ¾Í`h>ÓtË™îm£¸2ˆp ×rÌYyØ€{ds‚Gs[T/Úgÿžòßf´Ïÿ=äÿ¾ÍE^wáßéú®’o/ ëÎ÷W*Jß΃ ;ª€ªàÚ€='í3ÿÏy?ï³GÚgÿžòßf¸¿øC4oîßÿàÎçÿŽQÿfýÛÿüÜÿñÊí>Ó?ü÷“þû4<Î¥ZWe=‹PCk •µ½´ ¶(áŒ($“÷G$žIîIäžM>€9?ˆ¿ò$k?õèÔQñþDgþ½Šê[þ>‡ýqÿAZ}1¿ãè×ÿô§Ð1â_ùü-ÿ_sÿé<•ØxþI÷†ÿìkÿ¢–¸ÿÿÈÇáoúûŸÿIä§éšÞ£kàíGþÊñÍ•¬Ë=“X6ò‘… y²0ÚO?tNE^ø+ÿ$Cÿ¶ÿú>J<1þ§Wÿ°…ÿþ–ÉY¾ºÿ„>Â->ËLñmÆŸ 2ÅkrÚqT,Û‹WV'$õb9^Å Ép9®÷ÅÕµÞ\Ç¥\Ïnn⹆Hf…C…;ƒÕOj¥}ámsP¶òdÐoS ].-ƒ#Tùœñ®©óéëï>§ SõzªNËM5¶ëTÚõ:?…‘4:ýÜO!•Ò%i«Ór~µé5Âü=Òµ; ~îâþÂKD›ìÉ’HرVŸ¸Í¾½kº®š)¨$÷êÚ¥í­åçŒe–êÖ4ŽþŵÔ)%Ná $‚IÜyÏzõ›ùxÿ®_û2Ôµá»ì½?Ìó~ËefÝ»¶ì\ãœg£@yÇ…ãÿKÿ®Z·þ–G^^}áÝ ßi·qjvSÁ=üJöâ3¹^å‰:0ëôÅ/ü¹mÌKûcì¿hþ/'í¾G—é³gðôÝóýïšK8µH'ŸM•¯nõ ØWRMƒvÙ'ÄNw`.FÔî7¿±-¾Ûço—Èó<ÿ²dy>vsæcÎyÆvîùñ»æ¦C Á ú\‹‹†Š9¤¸†ÕŠùqJû·¸!w’|É8,GÎp:‰?åŸýrOýS)òË?úäŸú¦P'ñþDgþ½Š>"ÿÈ‘¬ÿ×£Q@KÇÐÿ®1ÿè+O¬ùõ[®¹¼¶Ü±¢eQ‚>¹ßíËùû¶ÿ¿Ë@šÞ .!žH"’Xrbi6ÂF èqÆzà‘ÜÔþgý3‡þü¯øVWöå‡üýÛßå£ûrÃþ~í¿ïòЯ™ÿLáÿ¿+þy§k(XÔ0ÁÛŒ÷ì++ûrÃþ~í¿ïòÑý¹aÿ?vß÷ùhJ¢¸¶‚ò‚æšáã‘C+B{ RþܰÿŸ»oûü´nXÏÝ·ýþZÕó?éœ?÷åÂ3þ™Ãÿ~Wü++ûrÃþ~í¿ïòÑý¹aÿ?vß÷ùhYf*Á•" A/¥GY¿Û–ó÷mÿ–íËùû¶ÿ¿Ë@TËX`²·X-­­ã‰rB¬+Ôœ’xä’I'©$š¡ý¹aÿ?vß÷ùhþܰÿŸ»oûü´«æÓ8ïÊÿ…gý3‡þü¯øVWöå‡üýÛßå£ûrÃþ~í¿ïòУ¹vÜØÎàc§ÚÍþܰÿŸ»oûü´nXÏÝ·ýþZ¿C<Ó¥¼tÛD’4JÌÁzHÎNNO©©¼Ïúgýù_ð¬¯íËùû¶ÿ¿ËGöå‡üýÛßå  _3þ™Ãÿ~Wü)BÊ @U ü¾•—ý¹aÿ?vß÷ùhþܰÿŸ»oûü´¥Qµ¼\Cén$²ËKj>^I±>Äw5Q’’ºØÊ½ П³¨­%ºìzü%öÿóÀÿàËý«ý›åí;ú}ýÙÇ^Û}³Þ€=_þûùàð:?á/·ÿžÿã¯$Ò¼I©_e £´Oíœ!Ec±£èÄÈí·=³»œ Ý7\¼´Ò´[‹‡k¢ñÞÊKÈáˆIØnA䃌2@=·þûùàð:?á/·ÿžÿ㯺ñf¥gdÎñÚI+éðÞÆV6U]ò*•#qÏÞë‘Ó¥^“\Õ啬61Oqg$EŒYm±º–8RAr1‚7dp:PªÿÂ_oÿ<þÇGü%öÿóÀÿà›«ØÜ=ܳ97ª•wTòŒr?½Ž¿6k=|Q©jZSªGR2{©K)áÙÓ´ŒnÏ9‘ñ%•ÅôQEm÷&#py~ÿZæG†uA!Ú’Ä`fDàzÏå]ãÇÐÿ®1ÿè+O¢ÃRkcÍ£ðUü7_hŠÞHÉ<ªÊ›~˜ÏJ—þûßí·ý‡ý+ÊòwùÃîg8Æìu¯D¢¦0Œ~k_V»N¬®Ò¶½-†é$“HÚB—œ¹”ùÿ~ ÏÍÏ ;‘ƒV‚'+f­¥ÆÂËgÝ"“ ?N½À=@¯H¢¨Äó;¯Éy4ÒϦni$ Oµd8Ü`‘ž äqŽ‚›ÃçŽ5tÖ!nEØ-s¸ù£ø‰-“øñ^EyŒ?ŒoM)HÕQæ ˆïBÅW=ðSSáÞÈdˆé^bI€ù·aŽB©f%@<ñŽ@ôêP›Ùx"ãOšy­tý’O·Ío8åz–ëÉÉêIÉɨÿá“íŸjþÌýç›çãÏù<Ìc~ÍÛw{ã=úצQ@Káï‡Z†“ciö‹žúãÌIAQ¹‰ÈŽq€N3Œâ­'Ã¥Žd•tx÷&ð Ê €ùܸݼŸ— ÉÀäרQ@[ÿ ày m-5ˆïº,B)ÈPKåFpp08©¦ð —O4ºfeãwq>rp¤ß)£é”PÙø>öŠÚÇb³—bf ÌÇ©$±$ûš«7ÃçŸPûtškƒ"J[í8ÐaNÐØà{zú×§Q@n|pn..?³ÿ{pñ<­ç˜ÆAC÷¸ÆN½ê8¼$7‹w™‰ÖY& çÿ€8ÝŽ@Ò½2Šó?ø@dþØþÖþÌÿNÿž¾û;znÇN:Uˆ|{åÍÜv;g¹Ûæ·œí£ØzW¢Q@c/ÃçšI]ôÖ"Y²F.q¸Ç,¶žƒ9÷­/øGu_ùõÿÈ‹þ5ÞQ@wÿ}ïöÛþÃþ•åy;üá÷3œcv:Õ{Üi¾X´³ž4;cûkÎ~Røî{W¦Q@c/Ãç§2i¬Và––1sˆÝˆÁb¶ç€sŒäg¯4é¼%ÄÓÍ.™™gxÝÜO†Üœ)7ÊG¨Åzeä÷õ[ag¤ZJ±ÊòH·3—æIÏBΣÓ~\A£ÚÚ_ØGq4QÞîºîû»1מy©´ÄÅWέgm–(ãżþ`CŒòþ!ë]åG?ú– –~!Èý¬×ý”QGÄ/ùµúïÿ²Š(êvÿ¡ÿ\cÿÐV‰Y•Wb†wuE p2Ì“ƒëCÇÐÿ®1ÿè+Cÿ¬·ÿ¯˜ôbÐ&©Þø‡NÓ.'™-ä´¹ÖÒæH‹:<*§zml#ñÓž‡Ö™âë‹™¬aÒí¦¸Ó—ËOy-•ç·Œ«üÿ½8¸œ§O›‚oj¶°Öö×3NÒÁn°ÆP¬‘]GjI ø`Í.ð¹L´±ÎñÕE£éÉ<‘iÖq½Ä‹4Ì(2:¶åf8åƒr äií¦Ø:25•³+,ˆÊbR ÈwHòÞ§­qwºþ¹ ‡S-m ·Ñõ)¥³#z¼°:(,RR çoË–)ó®âNF¼Úî§k­Úi71Ù­Íç’a*aù¦yÔrÛ"@ Ô¡€RèúdÑÁºuœ‰oC ¼ Dh˵•F8R¼8#Šy°‰µDÔ¦Ž‚5$mEf øõ,U3œã`Æ2r9[Œü¦×·Jàþ?!£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€¶çÖÏþþ¿ÿ£mÏ­Ÿýýþ7O¢€rÒ¬ž^csvïP?»úÒOþ¥©bÿ]uþì?ÎZIÿÔµ|³ñ þGícþ»ÿ좊>!Èý¬×ý”Q@S·ü}úãþ‚´?úËúù‡ÿF- ÿCþ¸Çÿ ­þ²ßþ¾aÿÑ‹@¢¹¿é¶ú]«ÞY[\4wöh4JåUîbW#€Ãƒê:×?¨k׺m…ð°¿Hî­–ö3¥¤Qm±‚æ0Ì.õˇ–%›Àù—‰EsF©¨ÝI¨%¥Ì:¯•.¯0û:$ÌÎ%„íF)°*Œ×~œ‚3ÏâÏútÿüþ=@UÊýŸÅŸô0éÿø*?üz³ø³þ†?ÿGÿPUEr¿gñgý :þ ÿ«~&—P·Žã_²hE,znÖ+ž@&RÇ|zß‹ýu×û°ÿ9i'ÿRÔ±®ºÿvç-$ÿêZ€>Yø…ÿ#ö±ÿ]ÿöQE¿ä~Ö?ë¿þÊ( ©Ûþ>‡ýqÿAZýe¿ý|Ãÿ£†ÿ¡ÿ\cÿÐV‡ÿYoÿ_0ÿèÅ Ô7–_ØÜYÝ'™oqE*dÊÃdr8=ªj(¢Š(¢Š(ªºvŸm¥iðXY«¥´ ²5yB«Øe‰8< À«TP&‰g‚H\¸Y©(å1Ã>àäS,í °±·³µO.ÞÞ5Š$É;UFÉäð;ÔÔPEP\׉>"ð°'í“é4µÒÒ«}èJ¸nß ü¨‡–ÿÜoÊ£¹ÕàÒ-Oo}+Êà¢ÚÙË9ã9ÎÅ!~ðëŒóŒâµþÓ?ü÷“þû4}¦ùï'ýöh˜ÿ„ÆÓþZ÷þ .?øšjx¾Ñd™Ž•¯aÄ`Ħãøwçø?ÚÔý¦ùï'ýöiß½ÄÏÛK Š$I7+)yP7ÿ §ýµïü\ñ5SÃ"Yæ×.Í¥Ü1Üê&X…Å»Ä̾LC;XÔøW_ ûÜAð]´°È¡ÒD“r²‘AE?í3ÿÏy?ï³@ž[ÿq¿*<·þã~U§ö™ÿ缟÷Ù£í3ÿÏy?ï³@ž[ÿq¿*<·þã~U§ö™ÿ缟÷Ù£í3ÿÏy?ï³@ž[ÿq¿*<·þã~U§ö™ÿ缟÷Ù£í3ÿÏy?ï³@ž[ÿq¿*<·þã~U§ö™ÿ缟÷Ù£í3ÿÏy?ï³@ž[ÿq¿*<·þã~U§ö™ÿ缟÷Ù£í3ÿÏy?ï³@ž[ÿq¿*³`Œ5 RñÚ­}¦ùï'ýöhûLÿóÞOûìÐx¿×]»ó–’õ-Kúë¯÷aþrÒOþ¥¨埈_ò?kõßÿeQñ þGícþ»ÿ좊ú¿ãè×ÿô¡ÿÖ[ÿ×Ì?ú1hoøúõÆ?ýhõ–ÿõóþŒZ«¨kf“åÿij6v~n|¿´Î±ïÆ3ÄgZ†h® Žx$Ia‘C¤ˆÁ•”Œ‚ꬿC,ú\) o# û'*ŠI ·13; >€äµÙµK{ Vx¤Õ"Ôc[÷¹“tËÛæ0ÉýÐaþþ¯çëŸã D¦¢YÒ" YÖ2Ãs( p .~£Ö¹½!u7“P[I¯!C;_V‰¤"çsùß.åÊíòñå‘s³¸¬ÿZxˆ\Ûȳ¤³­¤è×vr"ÇOi¼m3ز‘µƒ|¸ašìno-lü¯µ\à †/5ÂïsÑW=Xã€9§Ã4WG<$°È¡ÒD`ÊÊFAuW§h÷7¶=ôºŒ¥tëØšrÓ[áL±ˆÁQ!*Å Æã样Ο)cçi¿ ´é“í–ï§Û[Ü\¤ÞbJW™~yêÂ@Zìfš+x$žy(cRï#°UU$’z(†h® Žx$Ia‘C¤ˆÁ•”Œ‚ê®cTŠò/…ú¯ö¶É¥ÜËp¬û¼¹ÙäüªXªŒœ('­R¹‹Qnác­ ¹/Ñn O"D-Íâö0#ÈÎLG»Ìù±@Ýå­…«Ý^\Ãmn˜ß,Î'$ð9 ~55yÞ¥£oáýhLoŒéz²Ëö‡‘Ô¤ o÷‰ÚLEŽF ýã¸ó^‰@Q@W3â¹.ÛPЬ­u ›%»¹’9d·+¸¨…ܘÕGj騮Oûûþ†½sþúƒÿU‹O ]JÒyž*×Ê¢n½¸îüñ>´wÄVw÷ú|vÖQÛJ­:˜®&h„‘Jn Ü1  ¡aÆsU¼/ ÿ£iš¥–Ù[NHåãgMªª¥_*bÊö€ÈRiÿðŒÉÿC?ˆÿïý¿ÿ¤s/—ÿ ?ˆó°¿úë~€¨ÿží ŸÂ°Ëoàý ãx¦ŽÂxÝJ²°A„׬/øFdÿ¡ŸÄ÷þßÿŒV'ö}ìž&¿Ócñ>º°ÚÛ[Ë–x ‘¥Ï>V1„\q×>ÔÜQ\Ÿö÷ý zçýõÿ£ûûþ†½sþúƒÿPYErØßô5ëŸ÷Ôüjì ïúõÏûêþ5@eÉÿ`_Ð×®ßPñª?°/¿èk×?ï¨?øÕu”W'ý}ÿC^¹ÿ}AÿƨþÀ¾ÿ¡¯\ÿ¾ ÿãTÖQ\Ÿö÷ý zçýõÿ£ûûþ†½sþúƒÿPYErØßô5ëŸ÷Ôüj­iÞº:•·â]jhüÕ-¼!\g•%c§q@ñ®ºÿvç-$ÿêZ–/õ×_îÃü够ýKPË?¿ä~Ö?ë¿þÊ(£âüÚÇýwÿÙEõ;ÇÐÿ®1ÿè+Cÿ¬·ÿ¯˜ôbÐßñô?ëŒú Ðÿë-ÿëæý´údÐÅqOK ŠQãu ¬¤`‚PE>Š(¢Š)’ÃèhÒE ®ÔHe<÷=ú(“CÄAeëŠéh ?³ï?çÚOûæìûÏùö“þù©&š+x$žy(cRï#°UU$’z*®ŸªÚj~`·3+ÇñÏÈÎÇPÛN%HìhoìûÏùö“þù£û>óþ}¤ÿ¾j–¿a|,â‘ÜÚUK›) ÜªT1DPp]zzÖAýŸyÿ>Òß4gÞÏ´Ÿ÷ÍOEAýŸyÿ>Òß4gÞÏ´Ÿ÷ÍOEAýŸyÿ>Òß4gÞÏ´Ÿ÷ÍOEAýŸyÿ>Òß5=••ÔwÐ;Á Pà’W¥P"ÿ]uþì?ÎZIÿÔµ,_뮿݇ùËI?ú– –~!Èý¬×ý”QGÄ/ùµúïÿ²Š(êvÿ¡ÿ\cÿÐV‡ÿYoÿ_0ÿèÅ¡¿ãè×ÿô¡ÿÖ[ÿ×Ì?ú1h®¥ªÚi1Â÷foßIåD°Á$Îíµ›QIè¬zv©í.ྵK›gßç‚ à‚*À‚8 ‚¬_ØÏzºSEgyt–÷¦Y£³¹K·É•2¯½1ó:ç 8ÏZç¦ðÞ¤Ö“$š_Ú'žÙÓO”¼e´ÉZYœJìÍø’Ïöfˆ’X…,Ú>­cŸ¾|y1ÚÉò7Ë,›6/Nsæ§#žz]®RðÂËý¿ÃqçjÖw±á ÿHEò¼À70ù¸Ÿ;°˜y;A«xoRº·Ô¢·Òÿâa'ÛšMC|cíqKÂ(7nÞv™!py\•rè4W%iáÙ,<@—6vÛ[¦¢BB&Û3iÊ:'Ú mŸÞ;±Þ¦Õ¼=s§yWÔoÃÜÛŠS [Un#wuhÑ0Ula¾œâ€:D•dyUCƒmmÈT€x$|Ãr23‘ÔL‚î ™®b‰÷=´‚)†ÚÅñïòºž=k„Õ´èt}FâêúÚÍ4—¹hí!–ê;hÒCol±J¤‘åìòfPÉ™ªM3þ¼‡C¶»{Ré­ HØx¡H­Rl~BBJ¬8,#€;ë[¸/aimßz,’DNù‘Ê0çє¦®cFÒŽ•áZÎ=››ÇŽÏ÷KÚ³±Œq¡Dù€ÀÆ«ºu¦Ý]Gr~ÒZ8Jß3ò`01a™›jc “Ï™ÎçÞì¡c¨[j)3Ú³²Ã;ÀìѲ èv°€Üdddx«UÀè6muªÍr-Rù"¿¸Š9p¦ÂE¼ä'Ê]>áB¾ƒLÒü%w§ÚiþV™ öÚgÍJL%?l ƒ÷š0¡ˆûàócÛéú…¶©f·vŒí 3§ÏFÁ•а*ÀC)ŽÕj°¼!4Wω,2_ÞºHŒYMÔ¤GPEQñ}º^jž³•æXg»•dLñ  ÊAÆT½¨«¢¹øC´MCÿw?ürøC´MCÿw?ür€:ê+‘ÿ„;GôÔ?ðgsÿÇ(ÿ„;GôÔ?ðgsÿÇ(®¢¹øC´MCÿw?ürøC´MCÿw?ür€:MJÕo´»»G…'YàxŒO!\2‘´°¨9Æ@$Vƒem©_êw0j.×1ÛA¶òXZbQäËâ6òÕȼ. ØÇi'-vox~9äAky…bu[¿_úëPOá- yeûãlBØþÕ¼ÀÏüõ  Úe¤âûPÔoeÅÄžTivAaÈàî%äõnÓ÷EiÖ,¾ Ð#•Óì·‡kŸíKÎò-ax£ÃšFŸ¦Û=¬7±É5ý¬Æ©tp¯2àÈG*HüsÖ€;z+‘ÿ„;GôÔ?ðgsÿÇ(ÿ„;GôÔ?ðgsÿÇ(®¢¹øC´MCÿw?ürøC´MCÿw?ür€:ê+‘ÿ„;GôÔ?ðgsÿÇ(ÿ„;GôÔ?ðgsÿÇ(®¢¹øC´MCÿw?ür­éžÑÓTµ}—¯¶Um²j§8*\‚=ˆ ÐAúë¯÷aþrÒOþ¥©bÿ]uþì?ÎZIÿÔµ|³ñ þGícþ»ÿ좊>!Èý¬×ý”Q@S·ü}úãþ‚´?úËúù‡ÿF- ÿCþ¸Çÿ ­þ²ßþ¾aÿÑ‹@¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¬McMº¿×t -㠭IJÌìáB)…Ðu<üÌ£ŸÀÛ¢€"þΛûðÿßÕÿ?³¦þü?÷õÆ¥¢€"þΛûðÿßÕÿ?³¦þü?÷õÆ¥¢€"þΛûðÿßÕÿ?³¦þü?÷õƳ·u¨tÙt›èŒí ŽvhYPd¾Báz •ºƒ‚E ®<ºµÅ¾“}:ÛNMr‘£H€®¤áO|f€áüg-Ä’G§xy˜­ª»øùCùUy¡ñ¤ÐÉXøt+©SNLàúå]ˆíãy$g6ËN59?øÕQÔ4ë iݾ… ^Apï ìØŽEr1€rEu4P_ÙÓ~ûú¿ãGötß߇þþ¯øÔ´P_ÙÓ~ûú¿ãGötß߇þþ¯øÔ´P_ÙÓ~ûú¿ãGötß߇þþ¯øÔ´P_ÙÓ~ûú¿ãSZYÉ ä2;õ\ûÕÿJ(‘®ºÿvç-$ÿêZ–/õ×_îÃü够ýKPË?¿ä~Ö?ë¿þÊ(£âüÚÇýwÿÙEõ;ÇÐÿ®1ÿè+Cÿ¬·ÿ¯˜ôbÐßñô?ëŒú Ðÿë-ÿëæý´KUÕF–-³¹»šê"(­ö-±Üòì  ¨Ýéx‡L’VšîYndxc‚æEIT}Ž€gæ`ÿ/ËOBAÕñ>.±œ#²±½[k¿>Kkæ+‹åHv? ¸=;VCxWSK ÛHžÌ¦¥dl¦ +(²Bó2ˆ†Óæ*,ûBŸ,b%é» ©qã] ×íÞmô+ö+ج¦Ì¨0ï·Ÿ½÷F[9Á\œ|µ¦úÆ™ÕÅ«ê6kqmšxŒê$Ì3•\rxäV-Éý±ä-›}£Q´¿¶ó'eÝåy‘ð‡oúŽÝÝ9¥ªxWS¿ÓntÄ{5·^ÜA9•·»Ü$ê“nTܘ3°|£w=¦±¦_È‘Ùê6w.ñ™‘a\²ÚXy]ÀŒôÈÅZ–h @óH‘©e@ÎÀÌB¨ç¹$êH¬/ì+¯í϶ùù_ÚßmÆNv}‹ìøé÷·óéŽùâ£Ô|#kqbmá{™ƒÏnÒÇ}}=ÄmOŽ6ÈÌ2UéßšÔ[Ó¤岯ӤÈgŒ¬Î计0Ç$†õË?é—·okÜ>o™å ‹þ‘û¤—t|üêE9Ëšçµ}.çOÕouc71^I$A¶šàå†ÝK2FŒ[Øüœ 2êx,м#yiáÕ†hí¢½–}6YrÁ-ÒÜ23rAŠ\HùºŒšé4Ïéš¶™>£kw ´‚Ic–S"íO-ˆ,H$ nŸºAïZ 4R¼©ˆíl‘U(Ø ƒèpÀýõ¬(´‡O ën§Å½Ä—­ºÐ´’fw|…Ùà9@n@Æsгá«;ËM6Ô¶i\³\Ýí$s™ÉÈA¶0r~T°(Ó¼I§j|m2Zm>Ûä\ËÈ–ý¤`áqÎsÆyÁÈ©âÖôë´?`¼¶¾˜ÀÓÇ ´ñ³Ê€•ÊüÀcpÛ’@ÏŠâô ê7~ k%†Ú1y`9½ŠDš f¶¥ùFW>fNA*‚º ´{ˆ5Y57t0Gª@ª+;˜Å‘€¡I-»œ£ßŠÚÓoâÕ4»MBu†êÀ ”0Î3Î M,ðÁ6XãÏMìk3°Ëoàý ãx¦ŽÂxÝJ²°A„Êñ}¥µö±á›k»x® {ÉwE2Vż„d é>ßgÿ?pßÁGÛìÿçîûø+Ÿÿ„OÃô/é_øøQÿŸ†ÿè_Ò¿ð ?ð ƒíöó÷ýü}¾Ïþ~àÿ¿‚¹ÿøDü7ÿBþ•ÿ€Qÿ…iGáO %¬ðÞŠK!$¶ 'æ=ÊÐmü­^j7¶¬J¬ª²ƒåÄfëÑ™ÉÎ8*‘÷‘s`·z¼¦ÞàÉ ÒjËþ“Í¥â`2+)»r|¯‚§6×ü"þÿ¡kCÿÁlüM6/ xqàG>ÐòÅÁÆ›geÃè_û}ŸüýÁÿo³ÿŸ¸?ïà¬ÛŸ øvY¥_ he‘†tØq?Ý®sÃÐ.<'£M6‡¦I,–0;»ÚFY˜Æ $‘É4Úý¾Ïþ~àÿ¿‚·ÙÿÏÜ÷ðW?ÿŸ†ÿè_Ò¿ð ?ð£þ? ÿп¥àá@Ûìÿçîûø(û}ŸüýÁÿsÿð‰øoþ…ý+ÿ£ÿ ?áðßý úWþGþÐ}¾Ïþ~àÿ¿‚·ÙÿÏÜ÷ðW?ÿŸ†ÿè_Ò¿ð ?ð£þ? ÿп¥àá@Ûìÿçîûø(û}ŸüýÁÿsÿð‰øoþ…ý+ÿ£ÿ ?áðßý úWþGþÐ}¾Ïþ~àÿ¿‚·ÙÿÏÜ÷ðW?ÿŸ†ÿè_Ò¿ð ?ð«šW†Yø…ÿ#ö±ÿ]ÿöQE¿ä~Ö?ë¿þÊ( ©Ûþ>‡ýqÿAZýe¿ý|Ãÿ£†ÿ¡ÿ\cÿÐVœUXaÑ{«¨`Å-Ï"Ûþ|ìÿð?Â"Ûþ|ìÿð?€E3ȶÿŸ;?üOð£È¶ÿŸ;?üOð ÑLò-¿çÎÏÿ“ü(ò-¿çÎÏÿ“ü(ôS<‹oùó³ÿÀdÿ <‹oùó³ÿÀdÿ }Ï"Ûþ|ìÿð?Â"Ûþ|ìÿð?€E3ȶÿŸ;?üOð£È¶ÿŸ;?üOð ÖN©¤Í©k:-ÂIqYM$²—Ï Ä蜸=†öOȶÿŸ;?üOð£È¶ÿŸ;?üOð ì ÿ?qÿß-þ}?çî?ûå¿Â"Ûþ|ìÿð?Â"Ûþ|ìÿð?€°'üýÇÿ|·øV}þŸ®Í*‹i–¶è0ˆút’?©Ëy€Iè½kCȶÿŸ;?üOð£È¶ÿŸ;?üOð  _ìÿÐÙ¥ÿà¡ÿøí"èþ(Tvø ŸáG‘mÿ>vø Ÿá@Øþ~ãÿ¾[ü(ûÏÜ÷Ë…E·üùÙÿà2…E·üùÙÿà2…`Oùûþùoð£ì ÿ?qÿß-þyßóçgÿ€Éþyßóçgÿ€Éþ}?çî?ûå¿Â°'üýÇÿ|·øQä[ÏŸþ'øQä[ÏŸþ'øPöÿŸ¸ÿï–ÿ >ÀŸó÷ýòßáG‘mÿ>vø ŸáG‘mÿ>vø Ÿá@Øþ~ãÿ¾[ü*[kX๊SuÀ¿Â¢ò-¿çÎÏÿ“ü(ò-¿çÎÏÿ“ü(‹ýu×û°ÿ9i'ÿRÕ"„ Ç 1«HŽ%Lã8ι¨çÿRÔòÏÄ/ùµúïÿ²Š(ø…ÿ#ö±ÿ]ÿöQE}Nßñô?ëŒú Ò¼‰‘Õuf8‘¿ãè×ÿô¡ÿÖ[ÿ×Ì?ú1h7Z×ítm:;Ç+$o Qµ¸Úy »Høï³’*-SÄÖ:mÄv»¼Ë—¹‚ßf(idEÛ¿w…}û3¸¨Îæ¥Ôt(õmX_^ÜÝ(V ‰ hÉ9—`Ø‹ƒÀòÁMcÛx.{H~É­²Çí°Ýù?f¿rñùqn-÷qF½7]ň%HÑñš-mnY¥K«oµ@!¶’Gx²ƒpURßòÕ8Æyö8¼Y¢$‹^üæ13/”ù 2–q‘U‘ƒÀB0Ûr*ð¤N¬‘M°ßÈ®2¥•T9ÆëŸG˜°ã+)L€)Zx'ìšf³b·°¬Z‘´E†×bÁ¹¦v!w®ùÛjñ… 2NX€m?ˆt¤’â6ºÃAß»oœ† Dg¼`ä! ¸†!O$ ¥ªøÇJÓt‰ï–_9£¶yÖ=¬¸+¸‘¶þé™Ô ‚XEGsáVº±¼Óå½G°–v¹ŠÝíƒ1§Ÿ7'÷‹¼chÙò1“†®<#i—6VzŒ6Iydm.|›$UtŒ<¥\Ìàƒ¸•ÇÌ.@:w»¶‰ÊIq0ê¬àMû}ŸüýÁÿ\YæE ²º¨ìŠ_´Ïÿ=äÿ¾ÍRû}ŸüýÁÿo³ÿŸ¸?ïà«¿iŸþ{Éÿ}š>Ó?ü÷“þû4Kíöó÷ýü}¾Ïþ~àÿ¿‚®ý¦ùï'ýöhûLÿóÞOûìÐ/·ÙÿÏÜ÷ðQöû?ùûƒþþ »ö™ÿ缟÷Ù£í3ÿÏy?ï³@¾ßgÿ?pßÁGÛìÿçîûø*ïÚgÿžòßf´Ïÿ=äÿ¾ÍRû}ŸüýÁÿo³ÿŸ¸?ïà«¿iŸþ{Éÿ}š>Ó?ü÷“þû4Kíöó÷ýü}¾Ïþ~àÿ¿‚®ý¦ùï'ýöhûLÿóÞOûìÐ/·ÙÿÏÜ÷ðQöû?ùûƒþþ »ö™ÿ缟÷Ù£í3ÿÏy?ï³@¾ßgÿ?pßÁGÛìÿçîûø*ïÚgÿžòßf´Ïÿ=äÿ¾ÍRû}ŸüýÁÿo³ÿŸ¸?ïà«¿iŸþ{Éÿ}š>Ó?ü÷“þû4Kíöó÷ýü}¾Ïþ~àÿ¿‚®ý¦ùï'ýöhûLÿóÞOûìÐ/·ÙÿÏÜ÷ðQöû?ùûƒþþ »ö™ÿ缟÷Ù£í3ÿÏy?ï³@¾ßgÿ?pßÁGÛìÿçîûø*ïÚgÿžòßf´Ïÿ=äÿ¾ÍWŠh§ a•$ €Åg¦qô4“ÿ©jz»Éqt]ÙŽØFXç¼´ÉÿÔµ|³ñ þGícþ»ÿ좊>!Èý¬×ý”Q@S·ü}úãþ‚´?úËúù‡ÿF- ÿCþ¸Çÿ ­þ²ßþ¾aÿÑ‹@¢±|H&–ÞÎÚ ’Ü\ìùòAöŒFí³ÍŒwävmèÕÌA®jv­ªÝ[I¾ÛLÓ„³Ãy+LKE5Ò¼q‘·¯—´JÙl"V$àÐh®.ê0j“Ú,PÍÒ4VwF-…ÌVìó¤ÚÓsÄyòÎ2Ì%Õ­u»äG³¼¸¦Ý@¸“ÈÎí>"„æW$Å |Û€=Šäˆµ4¿ŸLy4帲ó¤žêUhá‘#HŒn&,‹€ ’àl'iÝ€_êZž¡à]Rµ¸†ÒîîM>IH™y,YPƒ·-È$år½ò:Ú+ˆ½ñýºßmŽÅ$ÓçTº[–h•VKÏ*['h0«»?Š6‚Eþ,Öln&°ŽÎÚîêͦ{‰“l1¼qLJ‰%PÅÀ÷>6´ç ÝÛ€×1À ýi~ÐÿÝþý/øQmÿPÿ¾¿Î²µ«ùtí7ÎPÌóÃn…Á*­,«b2|ã#8ÆFs@¿hîÇÿ~—ü(ûCÿv?ûô¿á\m׉5MBÎ lïI¢Ú>#2NÐ+ù Û–÷a$*Q”°ÈjËÓYø…ÿ#ö±ÿ]ÿöQE¿ä~Ö?ë¿þÊ( ©Ûþ>‡ýqÿAZýe¿ý|Ãÿ£†ÿ¡ÿ\cÿÐV•оÌ>®®nîUƒ23ÓÖ€#»³µ¿µ{[Ëhnmß♣`äd £m‚Àð +a À¶í‰v´@##¨ Ø9>µ?•'üþ'þŸþ9G•'üþ'þŸþ9@eÑôÉæšitë9%Ÿs¼ LŸ!O˜ãŸ‘™yìÄt4&¦G³ËÓ¬×fÝ»`Q·nÌcŽ1åGO-º1kÊ“þÿOÿ£Ê“þÿOÿ  ýSC¶Ô£PìÒ­ÊÝyÑA ¹‘WhoÞ# Àc#hâ¦Fý‘’öp˧ÅD¶ó/˜›SA œã¯¥Zò¤ÿŸÄÿÀSÿÇ(ò¤ÿŸÄÿÀSÿÇ(=ô+Y!I‹O{ì’dež7FAÓ@‰’'$±™4}2;[{TÓ¬ÖÞÚA4$N !”c Ù$äsÉ«^TŸóøŸø øåTŸóøŸø øåX¶ÿ¨ß_çT.'°š)m®e¶xÝLrE#) H=GlT“Z}¢ žxe†E(ñ½žåe#däYð…xwþ/þ ãÿâ¨ĶÚÑÁ°i’%¼m *é£.ÖU”¯⟠h–óÇ< §Å4p t‘+,@äFè öéU?á ðïý4_üÇÿÅQÿW‡è¢ÿàž?þ*€%‚ÃÃv°<öšL0ºº4qÇ«+€!‚®}vŒô§Åm A43E™°gÉtHÁä òžß"ªñÙ@è*¿ü!^ÿ F‹ÿ‚xÿøª?á ðïý4_üÇÿÅPûGÒl-RÖͬ­­Ó;"„¢"ääà$ŸÆ ‚Û@µ„Co™ Cf4@Úå×èä°ô$žµ_þ¯ÿÐ#EÿÁ<üUð…xwþ/þ ãÿâ¨ÜÉ¢\O$ó®Ÿ,Ò@mÞGÌÑ“'ª“Û¥i¢_º=âé÷ º#LÊ«®zQÖªÂáßúh¿ø'ÿŠ£þ¯ÿÐ#EÿÁ<üUEk£h–÷×—R]Aqö¯44RV0%*dE]û¶ %÷(ç“xntëx#‚ ­b†5‘£*ª¨ÐY¿ð…xwþ/þ ãÿâ¨ÿ„+ÿôÑðOÿ@¿o³ÿŸ¸?ïà£íöó÷ýü•ÿW‡è¢ÿàž?þ*øB¼;ÿ@ÿñÿñT«öû?ùûƒþþ >ßgÿ?pßÁY_ð…xwþ/þ ãÿâ¨ÿ„+ÿôÑðOÿ@¿o³ÿŸ¸?ïà£íöó÷ýü•ÿW‡è¢ÿàž?þ*øB¼;ÿ@ÿñÿñT«öû?ùûƒþþ >ßgÿ?pßÁY_ð…xwþ/þ ãÿâ¨ÿ„+ÿôÑðOÿ@¿o³ÿŸ¸?ïà¬ûû ꓬú…¦“w2®Á%ÄqÈÁrN2Aã$þuü!^ÿ F‹ÿ‚xÿøª?á ðïý4_üÇÿÅPaÑ<#o¦óãþ÷éGŸ÷¿Jùgþ‹è9sÿŽÿ…ð°¼[ÿAËŸüwü(êo>?ï~”yñÿ{ô¯–áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€>¦óãþ÷éGŸ÷¿Jùgþ‹è9sÿŽÿ…ð°¼[ÿAËŸüwü(êo>?ï~”yñÿ{ô¯–áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€>¦óãþ÷éGŸ÷¿Jùgþ‹è9sÿŽÿ…ð°¼[ÿAËŸüwü(êo>?ï~”yñÿ{ô¯–áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€>¦óãþ÷éGŸ÷¿Jùgþ‹è9sÿŽÿ…ð°¼[ÿAËŸüwü(êo>?ï~”yñÿ{ô¯–áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€>¦óãþ÷éGŸ÷¿Jùgþ‹è9sÿŽÿ…ð°¼[ÿAËŸüwü(êo>?ï~”yñÿ{ô¯–áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€>¦óãþ÷éGŸ÷¿Jùgþ‹è9sÿŽÿ…ð°¼[ÿAËŸüwü(êo>?ï~”yñÿ{ô¯–áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€>¦óãþ÷éGŸ÷¿Jùgþ‹è9sÿŽÿ…ð°¼[ÿAËŸüwü(êo>?ï~”yñÿ{ô¯–áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€>¦óãþ÷éGŸ÷¿Jùgþ‹è9sÿŽÿ…ð°¼[ÿAËŸüwü(êo>?ï~”yñÿ{ô¯–áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€>¦óãþ÷éL–ThÈ “ô¯—?áax·þƒ—?øïøQÿ Å¿ô¹ÿÇ€ˆ_ò?kõßÿeV õõΧ{-åä¦[‰N^B,qŽßJ(ÿÙsane-backends-1.0.29/doc/umax/sane-umax-vista-doc.html0000666000000000000000000002111513615534521017373 00000000000000 SANE-umax - UMAX Vista scanners
SANE-logo
UMAX-logo

UMAX Vista scanners





UMAX scanners
Vista series:
Name
SCSI-ID
Versions
UTA
ADF
B/W
Gray
Color
Bits/pixel
Resolution
Vista S6
Vista-S6
all
UTA-V6
X
ok
ok
ok
1,8,24
300 x 600
Vista S6E
Vista-S6E
all
UTA-V6
X
ok
ok
ok
1,8,24
300 x 600
Vista S6E
UMAX S-6E
all
UTA-V6
X
ok
ok
ok
1,8,24
300 x 600
Vista S6E
UMAX S-6EG
all
UTA-V6
X
ok
ok
ok
1,8,24
300 x 600
Vista S8
Vista-S8
all
UTA-V6?
X
ok
ok
ok
1,8,24
400 x 800
Supervista S12
Supervista S-12
all
UTA-V12
X
ok
ok
ok
1,8,24
600 x 1200*
Supervista S12
UMAX S-12G
all
UTA-V12
X
ok
ok
ok
1,8,24
600 x 1200*
Supervista S12
UMAX S-12
all
UTA-V12
X
ok
ok
ok
1,8,24
600 x 1200*
 Old Vista scanner:
Name/ID
Versions
UTA
ADF
Lineart
B/W
Gray
Color
Bits/pixel
Resolution
Vista VT600
? (try UC630 V2.8)
--
 
?
?
?
?
1,8,24
300 x 600
Vista T630
some
X#
 
ok
--
ok
ok, 3pass
1,8,24
300 x 600

* Supervista S12 scanners allow scanning up to 1200x1200 dpi.

UTA = Umax Transparancy Adapter, ADF = Automatic Document Feeder
(X = supported by scanner, incl = is included)

# There is no UTA available for the Vista T630, the UTA-V6 is limited supported, if you have problems with your Vista T630 scanner and you have a UTA-V6 connected, try without UTA!

## 10/30 bits/pixel are used internally, the output bit depth is 8/24 bits/pixel

Suggested firmware versions for old UMAX scanners
Name
suggested firmware version
(read on UMAX's german website)
last firmware version
Vista VT600
use the UC630 firmware (2.8)
?
Vista T630
--
1.5


Here you can find information about firmware versions of UMAX scanners.



This page has been changed on 12th. february 2001

Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-doc.html0000666000000000000000000000426113615534521016252 00000000000000 SANE-umax backend
SANE-logo
UMAX-logo

SANE-umax backend






Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-not-listed-doc.html0000666000000000000000000000567213615534521020341 00000000000000 SANE-umax - Not listed UMAX scanners
SANE-logo
UMAX-logo

Not listed UMAX scanners





The sane-umax library implements a SANE backend that provides access to several UMAX-SCSI-scanners. Parallel- and USB- scanners are not supported!

If you own a UMAX-SCSI-scanner that is not listed as supported, it may work with SANE. It depends on the information the scanner returns to the umax-backend. If the data-block is large enough, the backend prints a warning and continues, but it is possible that not everything works fine.

I suggest you hold one hand on the power-button of the scanner while you try the first scans!









This page has been changed on 12th. february 2001

Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-config-doc.html0000666000000000000000000002705713615534521017525 00000000000000 SANE-umax - Configuration
SANE-logo
UMAX-logo

Configuration





CONFIGURATION:

The configuration file for this backend resides in
/usr/local/etc/sane.d/umax.conf.
Its contents is a list of options and device names that correspond to UMAX scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below:
option scsi-buffer-size-min 65536
option scsi-buffer-size-max 131072
option scan-lines 40
option preview-lines 10
option scsi-maxqueue 2
option handle-bad-sense-error 0
option execute-request-sense 0
option force-preview-bit-rgb 0
option slow-speed -1
option care-about-smearing -1
option calibration-full-ccd -1
option calibration-width-offset -1
option calibration-bytes-pixel -1
option invert-shading-data -1
option lamp-control-available 0
#scsi Vendor Model Type Bus Channel ID LUN
scsi UMAX * Scanner * * * * *
/dev/scanner
# this is a comment
/dev/sge
The special device name must be a generic SCSI device or a symlink to such a device. To find out to which device your scanner is assigned and how you have to set the permissions of that device, have a look at sane-scsi.
When the generic scsi driver of the system supports selection of scsi buffer sizes the umax backend calculates the scsi buffer sizes in dependance of the numbers of bytes per scanline. With scsi-buffer-size-min and scsi-buffer-size-max the scsi buffer size can be defined in a range between 4KB and 1MB. Especially the minimum value is very important. If this value is set too small the backend is not able to send gamma tables to the scanner or to do a correct color calibration. This may result in strange color effects. If the minimum value is set too large then the backend is not able to allocate the requested scsi buffer size and aborts with out of memory error. The default is 32KB, for some scanners it should be increased to 64KB.

The option scan-lines defines the number of lines that shall be scanned with one scsi read command for a real scan. The number of lines that are read with one scsi command for preview scans are defined by the option preview-lines. Both have to be in the range between 1 and 65536.

With the option scsi-maxqueue you can define the number of scsi commands that shall be queued. UMAX scanners do not support command queueing - as far as I know. But some scsi controller drivers do support queueing in the kernel. In this case it does not make sense to queue more than 2 commands.

When you are able to do color previews but color scans do not work you can set the option force-preview-bit-rgb 1. This always sets the preview bit when acquiring a color scan. The image quality may be reduced.

Some scanners (especally very old scanners) may need the options slow-speed and/or care-about-smearing. The value -1 uses the value defined by the driver, 0 disables the feature, 1 enables the feature. Do not change these options unless you really know what you do, you can destroy your scanner by setting wrong values for this options!!!

Some scsi drivers (or may be some scanners) do return an invalid error code when a scsi command is executed. There are different ways to handle such bad error codes. You can define the behaviour of the umax-backend by setting the option handle-bad-sense-error in umax.conf. You can set the following values:

0 : handle as device busy
1 : handle as ok
2 : handle as i/o error
3 : ignore bad error code, continue sense handler
In most cases it does work when this condition is handled as a device busy state so this is the default (0).

The option execute-request-sense disables(0) or enables(1) the scsi command REQUEST_SENSE. The command can be called when the scanner asks the driver to do calibration. The driver does not know the required calibration parameters for all scanners. Some scanners return the needed parameters when the driver executes the REQUEST_SENSE command. But there is a problem with the REQUEST_SENSE command on some systems with some scsi controller drivers. This can cause a system hang. So the safe way is to disable the REQUEST_SENSE command, but the driver may not be able to do correct calibration in this case.

For some scanners the calibration has to be done by the driver. For this the driver has to know some values about the calibration data. When the REQUEST_SENSE command is disabled or the scanner does not return the correct data the driver needs to know the correct parameters. For some scanners the parameters are stored in the driver. When these values are not set correct the image might look very strange. To be sure that you have a problem with the calibration please enable debug output.

calibration-full-ccd:
The calibration can be done for each element of the CCD (1) or for each pixel of the requested image(0). The value -1 enables the value defined in the driver.

calibration-width-offset:
Some scanners use more pixels than calculated by image/CCD parameters. A value larger or equal 0 defines the offset. The value -1 enables the value defined in the driver.

calibration-bytes-pixel:
Some scanners use 1 byte calibration data although the scanner supports more than 8 bits/pixel. You can define 1 or 2 bytes per pixel calinration data. The value -1 enables the value defined in the driver.

invert-shading-data:
Some scanners need inverted shading data (1), others need original shading data (0). The value -1 enables the value defined in the driver.

SCSI ADAPTER TIPS:

The UMAX-scanners do block the scsi-bus for a few seconds while scanning. It is not necessary to connect the scanner to its own SCSI-adapter. But if you need short response time for your SCSI-harddisk (e.g. if your computer is a file-server), I suggest you use an own SCSI-adapter for your UMAX-scanner.
The SCSI-adapters that are shipped with some Umax-scanners are very simple ones. I suggest not to use them. If you really want to try: the UDS-IS11 uses a DTC3181E chip (compatible to NCR5380). On linux you may have the chance to get it work with the recent g_NCR5380-driver. The card does not have IRQ/DMA. Try the following option for kernel boot option:

        dtc_3181e=0x280,255

 or use the following command:

        insmod g_NCR5380 ncr_irq=255 ncr_addr=0x280 dtc_3181e=1

     - ncr_irq=255 : no IRQ, no DMA
     - ncr_irq=254 : autoprobe IRQ
     - ncr_addr : can be: 0x220 0x240 0x280 0x2A0 0x2C0 0x300 0x320 0x340
 

For information about the umax-scsi-cards take a look here.

See the relevant hardware FAQs and HOWTOs for your platform for more information.
See also: sane-scsi

FILES:

  • The backend configuration file: /usr/local/etc/sane.d/umax.conf
  • The static library implementing this backend: /usr/local/lib/sane/libsane-umax.a
  • The shared library implementing this backend : /usr/local/lib/sane/libsane-umax.so
    (present on systems that support dynamic loading)

ENVIRONMENT:

  • SANE_DEBUG_UMAX
If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity:
SANE_DEBUG_UMAX values
Number
Remark
0
print important errors (printed each time)
1
print errors
2 print sense
3
print warnings
4 print scanner-inquiry
5
print information
6 print less important information
7 print called procedures
8 print reader_process messages
10
print called sane-init-routines
11
print called sane-procedures
12
print sane-infos
13
print sane option control messages

Example:

export SANE_DEBUG_UMAX=8


This page has been changed on 27th. feburary 2001


Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-standard.jpg0000666000000000000000000003634313615534521017127 00000000000000ÿØÿàJFIFÿþXCREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2) Quality = 75, Smoothing = 0 ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀ5"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?êµMÃ:\q³xkG(V1…Ó c’€÷_­fnð§ý _þ ­ÿøšØñüzCõ‹ÿE×ßÇum:ÜÛÎÅKs¿©éüºý3©>EÍkx<2ÄÔö\ê-í}›í~‡Y»ÂŸô,iø*·ÿâhÝáOú4¿ü[ÿñ5ÎÚ\­é2+Œ!ÆÅ'¯©öôÿ”5ä¹’[%¶¹\ƒ#/´˜ç pÇ<qÓžHÅTd¤®¶2¯Bt'ìê+In»Žï б¥ÿàªßÿ‰£w…?èXÒÿðUoÿÄ×—=ýÜš}ƒYj7 6²!1ÜÆÂH²r#s¿.|žrF1Z—#¸·Õ£„ia{õ³)r™L§äÜTúg½Q‰Þîð§ý _þ ­ÿøš7xSþ…/ÿVÿüMyµ¯‹¯þÅcwumlÉuË„ˆ²a³“œgÇ>¹ç4×5Ô~×q=´a´e¹Uwu„38Á+ÉÈÎ02[‘œMÝáOú4¿ü[ÿñ4nð§ý _þ ­ÿøšói¼Y¨Ã,¶ñ[Eq4w@»¢x<Å‘Xãkœ©Êã'#œâ«ë:Ö·ý™¬[Êm šÄ@$’ÕÝI.ÙO^˜R=ÉÏbê;¼)ÿBÆ—ÿ‚«þ&Þÿ¡cKÿÁU¿ÿ\¦¹©M§Cf-Ö3-ÕÜvÊÒU7gæ ž2+jW•¾ž‘Úy­wsk$Œ¬ù`àgŽ¿w'8ê3è{¼)ÿBÆ—ÿ‚«þ&Þÿ¡cKÿÁU¿ÿ^mm¬ß꺇†.VU.„þl+¸«9äg8ã?túÔ:w‰¯äÓ#XRxôù¯]¥ó%ݶFP£/‘Ó©'¯N(Ó÷xSþ…/ÿVÿüM¼)ÿBÆ—ÿ‚«þ&¼ÚO_ˆ/îã¶¶ö±Ú˱‹"P¤®zù±Æ:ñ ÚÝü:òY]%µ¬rϲ”7ï£änY+»8; Ž g&€;Þÿ¡cKÿÁU¿ÿFï б¥ÿàªßÿ‰®3ijÍöG“,‘ùšœ(ûÊsqÔ{V¹yü%~]Üéä}“ÊÛ!^ìgo¦{â€=?w…?èXÒÿðUoÿÄѻŸô,iø*·ÿâk̯¼Cwws¢ÛÄKÈ’ÿËp6È]—ËáŽAØçuÎ:r0xàÐ_»ÂŸô,iø*·ÿâhÝáOú4¿ü[ÿñ5ÁIr‡ôf–{É®¥ vÐNQî\ ûÌ>`rN@NxÙF¡nþÑnï¤v¸ó Ìñ1G-w ×<Ž£&€;ýÞÿ¡cKÿÁU¿ÿFï б¥ÿàªßÿ‰®ÊâvmRÓMûJ^Àb>N§/™{‡fVfåFq“Î:sCkwðëÉet–Ö±Ë>ÈPß¾‘¹d®ìàì*:œšîwxSþ…/ÿVÿüM¼)ÿBÆ—ÿ‚«þ&¼Ú?_˜,.ä¶¶6÷QÝK±K Ä.zù±Îz scGÔ/ï‡ýqÿAZ}“[m‚¯áºûDVòFIåVTÛôÆzSï<w|Ñ4ö,^Lr$á20pÊÀŒŽ£5èÔTÆÂkâj×iÕ•ÚV×±æð€Éö?²ÿf~ïÍóóçüþfs¿~íÛ½óžÝ*3ðïïÒ¼µglŠãb«Œa•U€Vàr0zúšõ *ŒO1áñŠ;X×JR–¢E…Z`À >ø ·9Éëš~¢«ì…!àû;nŸvS ËvÀÁê0< õ*(ËÏö7Ü6#M«‡k²Ie$©l¿ÌFHçŽ:qN½ø|u%’ëJYP¢CçÝ·¡áºŽ™ë‚FqÅzuçwž½¿…b¹±ÞªáÔ‰‚²°èA >â±î~_>¥¦ÉŒkknóÉ0ió#»† œ–g$ä`c¥zåægÀ,mí­ÿ²cZçÊQ" Œ~nAÏ äù¨á\o ¥²"FÑ —EIF9*H|°ÎNG5êTP˜ÉðøËÔm¥(K¡Ì«0PDpŒ`tÅ;þ>Ùö¯ìÏÞy¾~<ÿ“ÌÆ7ìÝ·w¾3ß­zeçw޽Ԭ䴻±ó “—Î8 ŽCg¨WþóÿgÜX5šÞâO6Ukœ—|ƒ’ųÕGzôê(ÍæðEÅÇ—OÜÂánAó€ýâ¨Pß{Ð:Tð€Éýý“ý™þƒÿ<¼ÿö·uÝž¼õ¯L¢€<Ïþ?±ÿ²³?Ðç—ŸþÖמµbóÁ÷·ð¬W6;Õ\:‘0VV!ÜW¢Q@sgàË»• ±`ód‘çï–f$àt©§ð¶£so-¼Ö{¢• :ùª2Áô (ÌåðÓ-𵄋ö4)ncº(È€UÁèæ¤—Á7SÙ¥¬ÖRIn ÜåÕÈ!Ënß>Ý+Ò( 1‡Ï-½Ä2i¬épL^ç-&ÒJå‹dàž¹éÐNÿ„O¶}«û3÷žoŸ?äó1û7mÝïŒ÷ë^™ExݯÃmeuKYçÓlc‚ßÏ !“p˜Ic"€IÚ '“[^“O¸ºfÉ„^Nó>âS9幯öƒé”Pÿî«ÿ>¿ùÆøGu_ùõÿÈ‹þ5ÞQ@ü#º¯üúÿäEÿ?áÕç×ÿ"/ø×yEpðŽê¿óëÿ‘üjk]3]Ó&7VºtSN¨ê‰-¢’ÊW$Œž3žœãu®ÚŠàãÆpÜÏs‡44ž}¾t«tCI´aw¹8 ô¬ù|;âk¹´¸ßDÒìlì%y;)Æ>d`@] ulþué”P‚üpÿ®‘ÿ\ÿBQñÃþBºGýpýQ@îßñô?ëŒú Ñ+2ªìPÎŽY‚òp}hoøúõÆ?ýhõ–ÿõóþŒZÁñ 7ww–6pL+G,¦Ñ/§µ(<Ï:5Ýòïa7™ŸàŸeâ©n4éuym ¢KèɘÚ-ÏšDd![˜”ºÌcmt÷úm†©Á¨Y[]­¼GqÈ¡°FpAçþu'Øí~Ýöß³Cö¿/Éóö3fs·w]¹ç3@‡ˆ|C¨jk¤ýžÎÒí<ñ<·1·bÛº°%aȸÛ3ý¬Œl6µFóUðý…Ãé·Wí`ÑÈŸ9„Ë4_MÀÁŒƒÖ·m4}2ÂD’ÏN³¶tŒÂ …P¶â Âî$ã¦Njqgj-bµЋx¶yqa0: ¤=01@#ø“W}zÚô¯Ù šÙ¬ã³wó#K´[C$¬WöI+¦8Ȉ• IšÔ>"ÔÒþ}1äÓ–âËÎ’{©U£†D r1¸˜²..K°§vFÚmƒ£#Y[2²ÈŒ¦% ¬‡t€ñÑ-êzÓGÓ#µ·µM:Ímí¤ABDà’F0­’NG<šä¼%â]Vði6²Ûy–Ÿf·‚[©d]ï1´IËn/¹˜îÁ@‡»oà­vûn}lÿïëÿñº‚6ÂÞxç‚ÊÚ)£€[¤‰«,@äF(=ºUªfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>ŠfÛŸ[?ûúÿün·>¶÷õÿøÝ>Š`ó„Ñ$žF$,3ŒHÂ3t*?»Ž½éôÃÿv¿ïIÿ¢žŸ@ ñÃþBºGýpýQGÇù éõÁÿô!E{»ÇÐÿ®1ÿè+Cÿ¬·ÿ¯˜ôbÐßñô?ëŒú Ðÿë-ÿëæý´KXÖ-t;!wv³4fEˆc.Řá@QÉÉÀãÖ©éþ'·Ô¯£´ƒNÕÒGÎ}>H $³÷ç æé÷Z•¥„‘y’.£m3Á@D3I€× äÖÝ­¬°Í½ü°¡q"žªGc@º–²l/­¬âÓ¯/®.#’UKcÚ¨P1&GQÖE階èóZ5ÛjÐ[mYYæD Œ±°l•½Œa€9aÆ “KÄzº¦©§Ý/KÔá·‚xÚßPrªÚ"vüƒïUmÂWZ~½ ýíÄ7¾Dn«<™2³˜-bó9Îùç’pã““€ ÛýnÃN• štk–h€·GS&Ù%X•ö“»˜dý{ñO¼Õml.¡†íü”–9$ÈBÄ»%KÃm,Àz#Ÿá®JÓÁº®›a`N"Csay$ϸº< n±¼eb$>rw*3¸tzÖ‘.´ð[½ÃÃd«#ÈйY|ÜŒŽÂîgädt4;ëvú]¶¡¨Nšl7 ¤-ó¬,¬Ë»cdðÀg#ØÔÇR°[ij7¶ÂéÙ‘`2®ö`¡ˆ œ’•±½gê6zµö‰i’x»î(.$·Žc´†U•AxÔ1 !vžÖ.“àÛ­?HšÕ™¸7¶³¦s$Þ@ŽÜ†"'`¼€_<šé"Öì.5EÓíçIæ+1f‰Õ–6‰£WFÁá³*ñõÎ;²MvÖ+[ÉZ9·ÚÜ­«ÂÞÒ±QŽvüþdd@Æí¸8Èм9§jšl÷ÇÉÓô¶ÓVH·fPÑv$ #|œí$á›ww*Ïâ‹=Wjm†WËÆA‘¦Ëpýt -yj—Kj×0­ÃclEÀsÄ`uä#Ÿøz52K[{¤ÔlÚÞæA ‰Ô¤®ITç Ù`sÁ¬ÍOÃÚwÚÔ®ÐÇöý%tèæÙºH¹˜¹íòèp%yÆeËá¹t×!³ŠââI ¬÷—¼A‘q‘òg\F …ÕQþPq³,Ðßø‡L°Pßw ·Ïs=¬R+L¨«¸™ÈàŒg‘ëF§â3IÓ.oî.á1A²Isùmµ•A#,„Ç÷ˆMsÚ§…u;ý6çLG³[q%íÄ™[{½ÂN¡6áUMÁùƒ1;Ê7p]øWSud{?³Ée©C¦VÞÏw"È7.Ü*©d3ÁÀè:ñ“¼—3ê6pZ¬‹ÜKsŽBѬƒiÝÝ[ q‚ ²u+¼K3{l.™*ïf €¹É!YXû{×?¬[k“ëpÅc-ÌÌàÛ=Ë¢*¼VÊÇÌ’HkrÛÈ`rÅA§x2]7K–Ñ$¶’cw§¸¸ÚUž+e·71H@Éw^Mv4QEQEQEQEQEQEQEQEQE0ÿÇݯûÒè§§Óü}Úÿ½'þŠz}x/Çù éõÁÿô!E?ä+¤×ÿÐ…îíÿCþ¸Çÿ ­þ²ßþ¾aÿÑ‹CÇÐÿ®1ÿè+Cÿ¬·ÿ¯˜ôbÐè§"<‡ŒÇ®f’pmbón“åMÒ|£sª2{’@¤@ EC-å¬7PZËs w¼˜Ày6Œ¶ÑÔàrqÒŸÑN…á‘$PÌ…‘”•aÇpAЃ@¢Š†{Ë[\ý¢æqÌ|Ç „\nn„ddô5Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@ ?ñ÷kþôŸú)éôÃÿv¿ïIÿ¢žŸ@ ñÃþBºGýpýQGÇù éõÁÿô!E{»ÇÐÿ®1ÿè+Cÿ¬·ÿ¯˜ôbÐßñô?ëŒú Ðÿë-ÿëæý´:2¤7 Ää’xp®WÅ—pËc§¤7¹:­ŽåG#í ×ø­Ëý6ÃT`Ô,­®áVÞ#¸‰dPØ#8 ó‚:¥…|;oÒ[™gŠÚK7ÞwÞLò‰0ê‰û£2ê|¿›¯£Ñ@h²j†[{y?¶šæM.F¾ŽIfD"[a,‘evŽØÈF,g,Ôˈ5WµŠæA«É©C¤ê–ðMw)óeߌœ1ŒðX–, 12'‰k¦ØYOq=¥•µ¼×-¾y"‰Q¥l“– |Ç$õõ5j€9+ëo‰µ[¦?eŽâòÊRÇ2Ë*0Š&-ò2£™NÓÂoÉù«CÂqÝÇ¥Ê.nnnÏ&¸·’ µxÄ®òãvþ\çÐmÛ[´PEPEPEPEPEPEPEPEPEPEPEPEPEPü}Úÿ½'þŠz}0ÿÇݯûÒ觧Ђüpÿ®‘ÿ\ÿBQñÃþBºGýpýQ@îßñô?ëŒú ÓŠ« :#¯uu àx¦·ü}úãþ‚´¯"D…äuEYŽ ò-¿çÎÏÿ“ü(ò-¿çÎÏÿ“ü+^ñJh÷v0FÚfÛ¸æO}¨}š1å”Cll±ßÓºjůŠt«‰£¶7p›£å¬‚ ÒDŒè¬ƒÍÚkoãyàrþE·üùÙÿà2…E·üùÙÿà2…ai^0ÓuM" áç’Ù'ha‚IÍ´0M«ûÝŒÁX ;OÞÛS7‹4D‘ckßœÆ&eòŸ1¡fRÎ1ò*²0bØFnEkùßóçgÿ€Éþyßóçgÿ€Éþžþ!Ò’KˆÚë w~í¾r)œ~ñƒ„&â…<*ñfŒ²,h™˜Æ$;-em¹fP¬Bü®]1a·â€5ü‹oùó³ÿÀdÿ <‹oùó³ÿÀdÿ ÏOéO%¼ku–Ÿvß!,T ?vÅÁ@i, ŽAsãm!tÍRÆG¼X-ê5X¤Q2€>éÛÈ€ägË'æÅt>E·üùÙÿà2…E·üùÙÿà2…D·ÖÆ(äi–!"U›÷mƒÓ*Ø û‘GÛìÿçîûø(_"Ûþ|ìÿð?Â"Ûþ|ìÿð?¢û}ŸüýÁÿo³ÿŸ¸?ïà  |‹oùó³ÿÀdÿ <‹oùó³ÿÀdÿ ‹íöó÷ýü}¾Ïþ~àÿ¿‚€%ò-¿çÎÏÿ“ü(ò-¿çÎÏÿ“ü*/·ÙÿÏÜ÷ðQöû?ùûƒþþ —ȶÿŸ;?üOð£È¶ÿŸ;?üOð¨¾ßgÿ?pßÁGÛìÿçîûø(_"Ûþ|ìÿð?Â"Ûþ|ìÿð?¢û}ŸüýÁÿo³ÿŸ¸?ïà  |‹oùó³ÿÀdÿ <‹oùó³ÿÀdÿ ‹íöó÷ýü}¾Ïþ~àÿ¿‚€%ò-¿çÎÏÿ“ü(ò-¿çÎÏÿ“ü*/·ÙÿÏÜ÷ðQöû?ùûƒþþ —ȶÿŸ;?üOð£È¶ÿŸ;?üOð¨¾ßgÿ?pßÁGÛìÿçîûø(_"Ûþ|ìÿð?Â"Ûþ|ìÿð?¢û}ŸüýÁÿo³ÿŸ¸?ïà  |‹oùó³ÿÀdÿ <‹oùó³ÿÀdÿ ‹íöó÷ýü}¾Ïþ~àÿ¿‚€%ò-¿çÎÏÿ“ü(ò-¿çÎÏÿ“ü*/·ÙÿÏÜ÷ðQöû?ùûƒþþ —ȶÿŸ;?üOð£È¶ÿŸ;?üOð¨¾ßgÿ?pßÁGÛìÿçîûø(tH¢mÑÛ[FØ#r@ŠFF zRÔQÝ[Í H§‰Üä…WñÉ©hÁ~8ÈWHÿ®ÿ¡ (øáÿ!]#þ¸?þ„( woøúõÆ?ýhõ–ÿõóþŒZþ>‡ýqÿAZýe¿ý|Ãÿ£€3u];P»Õ­5+ûx'‚  aslÓ‡Y g´ˆAPîzÕsáéd‚ìOx5Õý­ó²BUCB Ê€XðÆ^7wÇ;´P0þߦivnÿ ;ì90åfù¡?:î呵“?2¹jOý“LÖlVö‹Q²6ˆ°ÚìX74ÎÄ.ã•ß;m^0¡FIË¶Šæî|*×V7š|·¨öÎ×1[½°aæ4âsæäþñwŒm>F ’pÁx= B©s `ýŒì‚ÕbL/9 ªp‹•’É,rOOEr±x&Þ=^-A¤¶–EåfšÍdth’u3åœÊUŽ l#4ù|!æh–ºoÛ±äh³i>g“÷¼Å‰|ÌnãWÝÏ9ëÇ==[Ku ¼i$ù(ó QY±É “í“õ5/Úgÿžòßf¢¢€%ûLÿóÞOûìÑö™ÿ缟÷Ù¨¨  ~Ó?ü÷“þû4}¦ùï'ýöj*(_´Ïÿ=äÿ¾ÍiŸþ{Éÿ}šŠŠ—í3ÿÏy?ï³GÚgÿžòßf¢¢€%ûLÿóÞOûìÑö™ÿ缟÷Ù¨¨  ~Ó?ü÷“þû4}¦ùï'ýöj*(_´Ïÿ=äÿ¾ÍiŸþ{Éÿ}šŠŠ—í3ÿÏy?ï³GÚgÿžòßf¢¢€%ûLÿóÞOûìÑö™ÿ缟÷Ù¨¨  ~Ó?ü÷“þû4}¦ùï'ýöiòÊceUXñ±O1©þíLûCÿv?ûô¿á@Úgÿžòßf´Ïÿ=äÿ¾ÍhîÇÿ~—ü(ûCÿv?ûô¿á@Úgÿžòßf´Ïÿ=äÿ¾ÍhîÇÿ~—ü*+›ÉaµšUX‹"3 ĸÈJidºµ#°Ý!Ã1?òÊJ+³Kqá¿ Ï<,ÒY#¼ŽÅ™˜Û1$“Ô“[Tà¿?ä+¤×ÿÐ…|pÿ®‘ÿ\ÿBP»·ü}úãþ‚´?úËúù‡ÿF- ÿCþ¸Çÿ ­þ²ßþ¾aÿÑ‹@÷‹–î_ì[kBå§¿(Ñ­ì–¢Eó6 ‘‚ÀeAàr@®sûOV’Ò[{kï*{{›(šIL’ã:„ИþúîQ±T¹¤Pw`°ÛÞß鶤 ¡emw ¶ñÄK"†ÁÁœùÓ$ÑôÉmZÖM:ÍíÚ4„ÄÐ)BˆIEÆ1µI$ƒfwÁBŸ•³Çaã=fßÉ2Ú¤ÐÚéjæâE&Kd.wdää:e·ðTz-Í­ç•ö«hgòdEæ mŽ:2ç£ ðG5JóÃÚeåůÙ!ƒÎ²k6ÕdHÆÅ8áFrLö oTÖ5‹‹SoíŒsyúmÊ\[+¼f)î6Á7€S%ø¬FÕÎjÖªêqÜ@·O ¶—zµõœ@–iWd—±8 [ÀÁÝü# }L’ÖâÕôë6·¹Í±[kï'wÙ¡DžáÖß2¥è%³xUT2ç5湫_‹„¶¸†Öâ ›^@²2¹û|Ð1 æªÆ0Hä•% uÓè6WZ¼š…Êùþe²Û½¼¨ÌÃ`®CbYó‚‚*i4}2[Vµ“N³{v!14 P¢QqŒmRI ÏKB.5DešDQX–V}­árq8]ÌÄÀÏ­ª¥a¦¥„×Ò‰æ™ïnMĆ]¿)بvò…E9>¤ÕÚ(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š–ãý`ÿq?ô\7…./ZûO’æy™59®ÕžååûF _¼do–Ý¿yþ®=Ëó‘Ÿ‘sÚ^\Á ʲÏlcC†p6ŠÍµMÊ{‰íO·šå·Ï$A¥l“–#ï“×ÔЕK¬qÏ#l#Î\#žj—Ûìÿçîûø*­úh𤠠º}Ü*ÛÄw$PØ#89çþtn}fíåxç³gT%WrqÀ¬}in>éÓÏ#Ë4šTNò;fc$’z’iŸðx3þ€úþCþ¡<öéR[[Kl‘¤8â”pÐvÅTðüŠžÿ¯¿ô•«v°¼ÿ"§…ÿëÂ/ý%jÝ øáÿ!]#þ¸?þ„(£ã‡ü…túàÿú¢€=Ý¿ãè×ÿô¡ÿÖ[ÿ×Ì?ú1hoøúõÆ?ýhõ–ÿõóþŒZ}$H¯¼³U\ð3ÜëT5JßI´†a¾W–ê eB»y’ULç' b}ñŽ3@è¬ÍKRº·¾¶°°´†âîxä˜ ç0Æ ù‚9Ý™ÆyÁcâk˜ÎÞEÄR,3D8WiÞÝpØåL‘°ã…ÍmQ\Þ¡ã+Ke–$rw8‘.ã–Ù¢U‚YC•dß´ù%rÿ2Tеeâ[K½VóOdš`½ûeâ ›ÉóN P:îxPs‡\€mQYï­éë¥ÛjBg{k¥V·òáwyC.á¶5‰Û“€2$ð RÔ¼W§ØØ]ÜD^v†Ñî¡ýÛ¤Wc2Žb»•ü¤œqÁÀíÍÇã-8ÈWHÿ®ÿ¡ (ÝÛþ>‡ýqÿAZýe¿ý|Ãÿ£†ÿ¡ÿ\cÿÐV‡ÿYoÿ_0ÿèÅ ¯og±³‘íôë‹ùl@Ñ©ç$»(Çã'‘ÅrÚ¤úæ¶,-†o-V=BÚw–K›vUT•Y‰ !=è v4PF±¤\_ÏÍâ[\ǶŤLr-ŽŒ­˜× Žxαð^£nˆ³êÐÊææ)nf6Ü܈îZä¡€‰‹É"Ÿ¾ FÞEv”P 7ß5fTÔaÍâ’AgûÉs4I$¿ç—ý!ÙÜýòpsw]ð¤ú’ê¬Û“Q½ŽPÈ¡ÕL" ÉbHmÑUù8gý¥ëh  ýWN–øZKmp]ZOçÂòFdMÅ3¹C)#lч8<ãžÖü Ú¼“Ju$óÞnn-D“)hL,7+(•gm€æ6ìã宯ŠäŸÁs–ÔU5m¶úŒrAs¶1É4ò¶Ó»!Àœ¨n@Á%[ -ÛŸ yú7Ø>Ñ âök½·þly’Hû$pÞ£ÌÈä|È­ÛÐQ@¬>–&%ÔPÛC” ¦Üï+kpe-¿*v·Ÿ˜`|´Gàù|»eÔQ¡ÓVlÂ[•aM „HwìEº À(c´äÕQ@¬tÿ±ÝêSù»þÛr'Û·1qã¯?êóž:ãµ]¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Šaÿ»_÷¤ÿÑOO¦øûµÿzOýôúð_ŽòÒ?ëƒÿèBŠ>8ÈWHÿ®ÿ¡ (ÝÛþ>‡ýqÿAZýe¿ý|Ãÿ£†ÿ¡ÿ\cÿÐV‡ÿYoÿ_0ÿèÅ  úާe¤Z½Bæ;kpÁL’('¦MgØø¿ÃÚìvv½­ÍÌ™ÙO¹›'è'ÐQxºÚ{»:+hdšOíKGÙ–;VUf8€Ÿ@ ­ë;[ˆî7¼ª„|–BÝ4GQÖ¬´¹à‚çí-4êïvö²ÎÅT¨cˆÕ°uëëV­®à¼ŒÉnþd\m±ÁPÀ«te!‡##¨ê sÞ$Óç¹ÖôÛµÓõ»xm®#q§Þ y¡+“æÆJጞqÇJÈÒ<ruˆ¿¶ìm®-cÕÂíò$"ÉîÆ]ÐË…+°–€;‹«¸,¡Ynb4‘Ä ùÂ(ãÕ˜ƪê:Õ–—<\ý¥¦]ãŽÞÖYت• q¶.½}k‹‡ÃºËA`o´ç¹ÔV}:i/žéwEb6"wns½$“oÜ;·_º}[E:§ˆ´éåûJÚÁir%½ÓÀÁÙá*2Œ¬AþÜsÚ€-\øƒM·ò±,×>lbdû´—?#}Ö>R¶°pOÁ¨çñ6‘o:D÷.á K6($’%‰ÉÛ#HªQTíc– `Ӛű²Öôè ì÷k«ÒͳÃÚÏ“q`~P¹”cb¿Ý?/@sï4]nû]Ø^M¨\è¶ÖÍøÎ0Ø&ð…”׉qö»ÄXî~Ñ*ɱI™fuåI*ò¢9É$m•ƒøFÞ;3W3µ¼-:9dT[@¬ŽŠ¬¨I¢‹—g9`Àm¼Eg=†¥y4W6‘é¬Ët.#Ã!XÖFàgpºŒƒŒ®AÒ¸ñŒ©wö.ú ,Ö'¸IÞ„k!p§{ʆSøXòÀu MÃÏ“ª[jÍçRF{”óÚN$‰‡™…'!3¨]ÛT¢©iþ¾’ê}CT¾š=A¼¯*xngŒÆ%Áh•VfM‚< nå˜f?Z\ɶËO¾»Ù#‚XÄj³»B³…]î¤)·e‚”Œç‘øÊÒæM¶Z}õÜnÉÆ#UÚœ*ïu ùM»,|¤g8};Âvg –ä¬j‰]”…Å¿ÙÕ:dªÇ€3ódIç&›á; .;D‚[–³¤é½”å–Ø[ à6 ÿ½íÅÞ,Ó®uk;Þ¦úžÎVxñ:.MÞbŒå‘FTŒçšçÄVv—‰4W"ÞÉXÜݬ{£‰„bR‡lì!³·o gqÛU¬¼!e§µŸÙ®ï-<¦D,„4‰‡Ì9\î1,€Bà’l0³sáÛ;»‹Çš[“oz¬.mM±ÊÆ1sŒ6v¸Ý·€q¸n  Òx²y£¶¸Òõ¯¤‘cKM‘¼‡zHÈÙG*ù2 –àŒ¶Õùª;ŸéÖ–sÝM ÌqGvöHÒùq,³#8eVvUÀ–ÜH [*-Aá¸Rþ û›ëËËÈdWMå‚B¤¨¨B"®ÑçHzg'’@žþ·ûAÍÌEw-ä7T¼RHÒÀe*F%uÁSÁõÐ-¼Mk~Äéö·—ùa–h£Ú1*ÇóUŠ2Xù€,ŠÌÒ|c%Õ‹ÜÙL×·vVÓGi 2<‚f;Y¤Û·l,À1Rä–;FÕ¶‡ù¹‚æñPáž1dyÄŒOÎͱT`±^cwÍYÖÞ ´´‚ÙbÔ/„ö°C½É1—‰b…ÀÙ´“:©ãï Ô7,Êó x<û¦.Ûd"H\îÁ(Ñ8!wêÆHÚÔõ}'M¸Ô.‹ {t2HTd…N+1|'`¶z·›rF£hmn²îl´®Î8ÀbÓÈOz`1Qx÷þD-sþ¼äþT/ü%ÿÐÄø&¸ÿâ*•®­•£[Ûé^(@×2\þƘœ¼¦V^cÆÒX¯LàõÏ5×ÜÿÇÔßï·óªw¬ÉapÊHaAää´Éí4¹â‘4Ï̶ðkHåÑæÛm +”]±ÃäN\±ùG<œé\xÆÒÒ/6çJסr¦ù4‹…˜…Q’½I R@®šà¹”@ë\dž•` 6«dQç¥'ü&¶?ô ×?ðS?ÿGü&¶?ô ×?ðS?ÿZ”P_ü&¶?ô ×?ðS?ÿGü&¶?ô ×?ðS?ÿZ”P_ü&¶?ô ×?ðS?ÿGü&¶?ô ×?ðS?ÿZ”P_ü&¶?ô ×?ðS?ÿGü&¶?ô ×?ðS?ÿZ”P_ü&¶?ô ×?ðS?ÿGü&¶?ô ×?ðS?ÿZ”P_ü&¶?ô ×?ðS?ÿGü&¶?ô ×?ðS?ÿZ”P_ü&¶?ô ×?ðS?ÿGü&¶?ô ×?ðS?ÿZ”P˜%3½„ÞT± C8IWk€ar2:ƒƒÐò;àÔôëùZ}þˆjmx/Çù éõÁÿô!E?ä+¤×ÿÐ…îíÿCþ¸Çÿ ­þ²ßþ¾aÿÑ‹CÇÐÿ®1ÿè+Cÿ¬·ÿ¯˜ôbÐè¦K4P(i¥HÔœeØŸÆ¢[û7`«w18H &€,QL3D³¤D:³¬e†æP@$à\ýG­Mè^E ÈYIVw}4ú(¢€ (¦C4WG<$°È¡ÒD`ÊÊFAuP袊(¢Š(¢Š*–¯¦C­iZmúAr†92=pH wÁúµ Ñ\AðH’Ã"‡Iƒ+)ÔL–¦Ö+¡s ·—g—(q±÷¡ÜH×#—/ƒ¼?4$±êò;rYõ›’Oã¾™ÿO‡?熩ÿƒ‹Ÿþ.·h  /øB|9ÿ<5Oü\ÿñtäð_†ãš)~˨;E"Ê‚MRw]ÊÁ”•f à€y«nŠ_*ÏþxIÿúÔyVóÂOûûÿÖ¤¢€ʳÿžßßþµUŸüð“þþÿõ©( ò¬ÿ焟÷÷ÿ­G•gÿ<$ÿ¿¿ýjJ(|«?ùá'ýýÿëQåYÿÏ ?ïïÿZ’Š_*ÏþxIÿúÔyVóÂOûûÿÖ¤¢€ʳÿžßßþµUŸüð“þþÿõ©( ò¬ÿ焟÷÷ÿ­G•gÿ<$ÿ¿¿ýjJ(™Ä—ö¬,'=!qE0ÿÇݯûÒ觧Ђüpÿ®‘ÿ\ÿBQñÃþBºGýpýQ@îßñô?ëŒú Ðÿë-ÿëæý´7ü}úãþ‚´?úËúù‡ÿF-s^;†;Æ£I"“T³GGPU”Ì ‚PjþáíÇSK›MO·M²ÃlˆË”`p@Èà‘[#‡W2œ« ã~Ô†âv¤ ðAc@ö­!±ñ©K ËÚÇisµ½»ÌÁÝáePÁ¿8ÀÇ'‘œ+X58n´çˆj1‰/ga²ÆÑKu#’Ä#˜1Y”’0±ì“qÕÊø*=a ¹:½Í̳2ÆeYmÞ5IðÞhRîÛ†vòbàl¶)XK¨Û[i—WZ-èÚ²ºI"™L¬žZ]×Ìh¸@b)NŽGoEpº$:´ÓèñÞI«“.w‰/™Ð`ùŸÌ ·w™€FpĶï,`çXè[ø^ÂãÖ¢¸G‰4èÕnmðó‚QÐ(o'wîöýß—uz]ç×6ºÌp^ÜBÚ¹¸òõK˜ÀšftSâÔÎ6”fÄ`mqŒ†ÀÇCâ/µ}ºËÚ?dòåÿ~|Ï´æ?'8ãn<ßõŸºÎ7ö®‚ªß鶤 ¡emw ¶ñÄK"†ÁÁœùИ½Çˆ[@¶¼´mPË.޾aí3´û¬ð²«(ç”]ª¾gÊ\¶ÒÕ¯¬Úë6VÚ ÓWb’Omo‰¦”ù&Å¥R7–ûAÀ“ïg>Zô(ˆžÓT³¼¹[8µK¨ÖîKXá{É€’ÜÙóŽÒg8çrœ(l µ¡áU»—MÔ,¯æ¼’#'ú<¯Å»˜Y8210q/W,8# Rºz(Í4øõ;'Ã&Ò RÜÛZ[ –Hî¤2ô„1îÚ…P1Ñ‹†U•Zf•g©Dµ[m\£±û|WhØGK›cÁ÷B¬bRvrgÏ^Er¾ XH.N¯ss,̱™V[wR|7š»¶á¼ X¸-ŽªŠ(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(‡þ>íÞ“ÿE=>˜ãî×ýé?ôSÓèÁ~8ÈWHÿ®ÿ¡ (øáÿ!]#þ¸?þ„( woøúõÆ?ýiÅU†׺º†ð SANE-umax - UMAX Astra scanners
SANE-logo
UMAX-logo

UMAX Astra scanners




UMAX scanners
 Astra series:
Name
SCSI-ID
Versions
UTA
ADF
B/W
Gray
Color
Bits/pixel
Resolution
Astra 600S
Astra 600S
all
UTA-2a
 
ok
ok
ok
1,8,24
300 x 600
Astra 610S
Astra 610S
all
--
 
ok
ok
ok
1,8,24
300 x 600
Astra 1200S
Astra 1200S
all but 2.9 *
UTA-2a
 
ok
ok
ok
1,8,10,24,30
600 x 1200
Astra 1220S
Astra 1220S
all
UTA-3a
 
ok
ok
ok
1,8,12,24,36
600 x 1200
Astra 2100S
Astra 2100S
all
UTC-2100
 
ok
ok
ok
1,8,12,24,36
600 x 1200
Astra 2200
Astra 2200
all (2.1) **
incl
 
ok
ok
ok
1,8,12,24,36
600 x 1200
Astra 2400S
Astra 2400S
all (1.1)
UTA-2400
X
ok
ok
ok
1,8,12,24,36
600 x 2400
Astra 6400
Astra 6400
? ***
X
 
?
?
?
1,8,14,24,42
600 x 1200
Astra 6450
Astra 6450
? ***
incl
 
?
?
?
1,8,14,24,42
600 x 1200
Astra MX3
Astra 2200
? **
UTC-2100?
 
ok
ok
ok
1,8,12,24,36
600 x 1200

* Astra 1200S-C with external power supply and Firmware Version 2.9 could make problems.
** Astra 2200 and MX3 are supported via SCSI. Connection via the USB bus not tested.
*** Astra 6400 and 6450 are firewire scanners: not tested.

UTA = Umax Transparancy Adapter, ADF = Automatic Document Feeder
(X = supported by scanner, incl = is included)



This page has been changed on 16th. december 2001

Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-advanced-options-doc.html0000666000000000000000000000761613615534521021515 00000000000000 SANE-umax - Advanced options
SANE-logo
UMAX-logo

SANE-umax advanced options





This backend dynamically enabeles the options that are supported by the scanner in dependence of the scanning-mode and other options. Here is an example of the frontend XSane:


sane-umax-advanced-options-screenshot


Advanced options Remark
Set exposure time Enable selection of exposure time, if not enabled, scanner uses default values. *
Cal. exposure time Define exposure time for calibration. *
Scan exposure time Define exposure time for scan. *
Set lamp density Enable selection of lamp density, if not enabled, scanner automatically selects a value. *
Cal. lamp density Define lamp density for calibration. *
Set scan lamp density Enable selection of lamp density for scan, if not enabled scanner uses the value that was used for calibration. *
Scan lamp density Define lamp density for scan. *
lamp on Turn on scanner lamp. *
lamp off Turn off scanner lamp. *
lamp off at exit Turn off scanner lamp when program exits (when sane_close is called) *

* only available for some scanners




This page has been changed on 5th. february 2001


Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-logo.jpg0000666000000000000000000001537413615534521015320 00000000000000ÿØÿàJFIFÿþhMade with GIMP CREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2) Quality = 75, Smoothing = 0 ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀ–€"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?÷ú(¨§-ãÞà‘žƒ­ Ø j).a„‘$¨¬vÜó§^Õs­–c;NpBóôçð¬F½™ãq¹rTa{tÇå\ò®–Ũw:ÆÕ-†pY†:犤úð*è‘ ˜2û€8ïÇ<×)xò°°~_¨=È5 º3À¼òzŽ?òk'^l¥tÒø–HˆÜ"íÚr?ZŒkÒ‘¹n ‰Ã*‚ ãõ5„ˆÌ’yŽ­¸‘’:Ž˜ü©—)´Ux_LƒÜƒþMG´Ÿqò£þ ˺,¥˜tG¥Vo_E,nnI“Ƽðzàg¿b:ÙÎ5¼lЀ0¤p{ŒTË•“Ì`Ù$GQÓùZ^Ò]ÇÊŽ†/ÎrÆdSÀPÅ=úç=½*ü>#°–c™!l€<ÅàçÜgŽ:×r»p ®6ñÆAH>œzmº;BJñÁ'‘ŽÕj¼Ðœé1Ëщ"ut=NAüiÕçP  •§†vŽ`Äy‰‘ŽààqúV•·Š¯l&Hµ8ÖâØ‘›˜Æ9%@ÁçÞ`csÆ:ã“Åliß ¼¦yžFi'™ßjÝsŒg§˜[o^ØÏè+O«÷dóœT:ö˜Æ¡ ru?ç4zÕ¤åcŠh{«wïÇã]ïü!¾ÿ¡oGÿÀ¿øš­yðÿ—ÏÉ¢[DÑgiµÍ¿\uòÊîéÆsŽqÔÑõ0ö‡/çÀì`ÒSŸóúÒÅ$œI=½søt­{‡V‘Ê$Òu ‹¼7”ãÎŒ¸À†ç¯,{ñÓŽŸ©Z´–·Öªä(Û,`˜Û#³c¨Áã¯áYN”¢R’eS;åÑI?Â{ðHÇãJÏ›&CǦîÏëQɺ7Ù {Ïùê)··†$…-íßh+á?.æäeAa‘œã' $fQD]ßøgR}GJQ*…Vº·lªJ™nø?0ì{gž©iZ¶³¥[j6º ˆÃ®H%}Tà‚3ÁW ·[W´Š%)´€‡œç’I<“žsÔ“š>_Ì­â E¥…ÒM<„áe òþ6•ßêísdñ `ù“#<åž™÷®ìB²ïêÍ€?Ú$ÿŸÖ£­+Ž­ã- ã Ž“sþZÎñŒúŽƒ}“÷’+(oè?ò+J¤I@W2þ·Nj3)|Dˆ£w¡üOÖ°EGÃë‹ü¦%…¬6i^L¶ÐŒ,R¯ßÉ<œ°,KÀžMtÕåzuãx[W–þÚ/6 ­©w ¹ðN}ÆOÁÉö#Ólï-õ H®í%Y`”nG^ÿà}»W}:ŠhÆQ±=QZQE#2 Ë0ÔšÇÕoákRªëì[¾Gÿ^µ'·Šæ&Žd ¬ ú¡¨®ZûáîŸq;Oi¨YÈcÚgó#ÝÏÌÁòǶ@aÓ·Z΢“VE+-Ìp¥Äžc«n%O^G@?ϽGr˜^BòP{}9þºuç‡|I¤ÆíƒR·LÔ—É;r0“‘Ç¥85k—dmËt‡cÆã AÓθ¥ GsTÓ,B…áùHRÌ{sÓÖ¡ø\IñŸŒÁ`ÅE˜Èöó…HTÀ¯!•WsŸ_çù[à¬?k“ÅZè˜u~¶¢ ¼/”»·g<çÎéŽ6ûñ®{Í“=W®GVÓ…¬â1BåâÆÑŽW8Ó×]TõK3}§M…ó æ=Çp铃ØñКè«x‘fqÃ4‘í ÞŸÖ©JL,²>Cc#Ÿ›üój«®j¶þ³y5ï+"?súç?Ö²4 ÅÿZ ¹IѼ;9WóØÿ¤\Dsþ­yÛœ[ W)ÊLÕÉ"Ö«âý&ÆXm“72Ê-áMò;žªÉ$ãñ©ü*> M¬G}§èk§i¹¤‹TœÂ³|ÁHòÀgG8Èb£…îuáïøoÁPgO´D¹uÛ%Ü¿¼¸›îƒ–ë‚UIUƒÈ´fÖ£T  'Lù‡¦~†º!OVõ3mÈÕ¨Úâb­4a‡ÉÜkþln²LŽ¥ˆäà8ÿ?…eÞjÙy‘—±È#©Ý=ÿÁ†ùå‹ ™2¥À³“íÌdbW†Ç ãå`G ¨ úéÕ ±-Ü(¢ŠÐF=ï…tMG[µÖ/4øæ¿´`ðÈÄáXtm¹ÚHìH$`c Å‹ÛËÅ,ldËl.Ì#T÷;¹ uÈÛ=+BŠMÅ^è^1Öa6¯¦éhµ´OrÏ×;·lÛŽ1Œõ=1Îe¯Âwx_û[źµÌåŽÔ$ ·‚¬“œœçÓŽ9ôŠlåÆÏ‚p3ŒŸnjy"ºìó†øCáûyb–ëZÖåŒ8o&K”Û.>b¸T rû¤Jv¥á_Ø£³Y7«6¥:éßy>½»W7ñ'âUä:³h: ¢Þ Ä÷'¥¾{ö¿Ïæ¶vrjÞ}¶YnnV˜I;n8S–ã¦Zô°9F#RŒ;¾¾„N¬a£Õž¹á BÎh’ÊîÊC Qqa¨¼åS*K~ðãÔ”ñÓžšOíþÓÏÓüC®I¹F̨¤0<‚¦ AïÈäz^7‹a¸·‘㕃|¡ŽÒ7axéÔ7=~_jìt^^Ì/,¤Xuë8òxÈ8ܬ?‰N#¶ ÷?çõ¯H®?W´HæeEˆùrç„ÆÐFq£X×…½äTCE×.<'¨Ggu'›£\8™€û+1å²x “ó àrGp}:¼ÇQ·ŠþÒ{WŒ9u )éZ¿ 5æÔ49´{’~Û£8·`F ˆƒå€WŸ“'­U ÝYŠk©ÜÑE`ë¾!·Òì䙤 "äÔÿœ:ÚRQWd¥sVëP³±…庹Ž(Óï³7ÝúÔn§ý«w6öò-”‰½'æsÁU%HÉÉÇðã äp ðüþ1‰|Oâ…ÙNû?I–3å,y#Í‘[‡f¯U†ä‘·Óè\ÏVÁXÞ'ÔLÐî®× °Âòn-Œ8Ç çô­šæ«*Dí ¶’ÑI*®Q]¥Œ…'Ôíb=vŸCXÐøŠžÇ¬êS<›ÕI†â:ëùà~5Ák°ÇªÅ4LªVBÃÆo3k‚p§’@9Ær+gL¼¾°ˆF·RlRªI ƒjôwxÉã©ÆTe€Ëc'¥6ßS·¸]¶ïg‘†ïߊõJæu/ø{Qù’Ïì3… ³XŸ(¨?t|¤õ œaŽya×CE>ç8d…ðY‹9ã8ûÞøÿ=è‰eŠO–C€qßÿ­’2j{Ÿ‡7𴯦ëÀªÐCwlîÇF‘HàžáxŽ*ŒÞñ½¥£È Ò¯™pgevÉ9uQÇ^HéëY:Es¢À½—îG·Ûß'Š‘®ÉÁ21~‡½Ïùü†4ï™Éá’Hî/ Ïþ‡éV¾ÃãTÿÂ&0yº·Ïç¾—²Ÿ`æF‚Ir’€f8xg¿øtæ£7.˱TO7~¦©½·0qá-Þ€Þ@?óÖsi'ºÉg f–öF:nm®Në€O £ÙMôdn³ÄÍó2p‹ž¸ÿõôéU'¼·ÓŽéî‘ ¶[¯áùTqü9ñ–¡ç CÄfž#gn×õÎKlÛŽ1Œç'§}»ƒþ‚èÜßµþ®áÑÑoî2ˆTçî U`xÈ`Àã뛎½ÄæŽ|Yy®\I§xSIŸU¹O¾ñ`E ‘½Îsµ±’2Gñ]ðŽKÝBWƺ’êSÆáÓO·è ‚q¼°ÌƒîœaFA0¯K±°³Ó,ã³°´‚ÒÖ<ì†Äh¹$œ(àd’±]§ìC“aEV„…cë>#³Ñ¯,l9îuÿ3ìvp(ß?–|3•EÚ§?3 ㌞+b¹øwÃ^3Õmô›û¹àÖôø…í¬–“´SÛ£H˜ŸÂ~h€'o €-ÇâÙ[Ót»ïk6¨<‰óˆ-ÈŒä3G+m%TàÎ:t•æ–7Þ+ðÿ´Oøž÷M×í57¸–Âü[.-Þ(AbUFÀ0Σ$9%€ùk³ñ¬êztpèzïö-ÒÊ®>È—;“Úç$ƒŸozجø›Kð–uM^&ÔKY±,Àp½[,@ÉÚ¬@8­Šóƒm©øÖòmphÚV£¡\Z=®–—×YÏ2“IŸÞ€»XDaq‚ÍC‚xn­â¸·–9 •Ç$l]HÈ Ž#œÔ•æ uKÏê÷ß|As‹»M³i&YŒžu«.|´soòðFqýà Çoâ=;YÔôèáÐõßì[¥”;\}‘.w&)µÎI>Þô¡}q-¥œ“Ãe=䋌A@ï’ÙW޼‘Ó׊æ<ñ+Ãþ=ûLz[Ï Õ¿/ktª’ãç1rqÁàã dg¯¯ðáñ/¯ ê–WÒi:þžó›MNò¯Ú%Ê:äB àžç±`À‡¬øÑtoØèo¡j·7WþgØÞo²-¾ Ê¥vƒü@gfºŠñ -w]½ø½àÅ^N·¤ý¸KsMäoÉ2të±²0#±Ê¯¯ëvšö‘=¶•ªeß>ß.óìë?—†üÁÈ{g=¨ÅõĶ–rO ”÷’.1¾He^:òGO^+ðçĨ¼[§I¡øg\»µŽS >mcÀ yÁèÃó®Þ¼3à•y}à[ÙmõýKOA©H¦+XíÙIò¢ù™œóޏàqÖ€=_Eñ Ö5MGM—IÔ´Û»…äKÕ²nÚQ‘Ø0ùc¨8ܬ½.F³+¤Þj’j:‚#ÎÒ´*åÍûE8ùGMûÃcR€ ÏÔô-[ò¿µt«ÿ'>_Ú­Ò]™Æq¸gòQ@Yé:nŸquqe§Ú[Ovûî$†F™²N\–9br}O­\¢Š¯}ag©ÙÉgiݬ˜ß ñ‰°ASÁÁþ›¤éº=»[éz}¥Œ åÚ;XV%-€2B€3€}…Py¼5 ÜêƒTŸDÓeÔ«‹·µF”2ãiÞFr00sÆjQEW¾°³Ôì䳿´‚îÖLo†xÄˆØ Œ©àà€ MÒtÝÝ­ô½>ÒÆrí¬+–À!@À>Š(I¬,î/-¯&´‚K«]ÞDÏ/á†ÚÇ•Èàã­X¢ŠŽx!º·–Þâ(æ‚T)$r(eu#x Ž1Xð‚øCþ…MÿÑñ4Q@f…£èžoöV•caçcÌû-ºE¿Ævœdþf´(¢€?ÿÙsane-backends-1.0.29/doc/umax/umax.TODO0000666000000000000000000000120213615534521014354 00000000000000TODO UMAX BACKEND FOR SANE ========================== * When depth>8 then it is necessary to create the gray gamma table with the correct depth * Astra 2200: enable option resolution bind for grayscale/lineart it must be disabled and set "true" for color mode * change set_window if (dev->do_color_ordering != 0) {..} one of the settings makes an error for Astra 6X0S scanners * include push-button function to SANE_START (?) * add builtin halftone pattern selection * add halftone pattern doenload, dimension selection - I will NOT add support for parallel-port and USB scanners to this backend! Don`t ask for it. sane-backends-1.0.29/doc/umax/sane-umax-speed-doc.html0000666000000000000000000001456013615534521017353 00000000000000 SANE-umax backend
SANE-logo
UMAX-logo

SANE-umax backend





Used System:
CPU AMD K6-III/400
RAM 128MB
SCSI-Controller NCR/Symbios logic 53C810
Scanner UMAX Supervista S12

RGB scan 24 bits/pixel
Resolution/dpi Size(h x v)/cm size/MB time/min:sec remark
      0:13 calibration
100 21.6 x 29.7 2.8 0:30  
200 21.6 x 29.7 11.3 0:30  
300 21.6 x 29.7 25.5 0:35  
400 21.6 x 29.7 45.5 1:00 some backtracks
>=500 21.6 x 29.7   too long not usable
500 9.0 x 13.0 12.9 0:30  
600 9.0 x 13.0 18.6 0:30  
700 9.0 x 13.0 25.4 0:55  
1200 9.0 x 13.0 74.4 5:20 lots of backtracks

Grayscale scan 8 bits/pixel
Resolution/dpi Size(h x v)/cm size/MB time/min:sec remark
      0:10 calibration
100 21.6 x 29.7 1.0 0:25  
200 21.6 x 29.7 3.7 0:30  
300 21.6 x 29.7 8.5 0:30  
400 21.6 x 29.7 15.0 0:30  
500 21.6 x 29.7 23.7 0:35  
600 21.6 x 29.7 34.1 0:45 some backtracks
700 21.6 x 29.7 46.4 0:50 some backtracks
800 21.6 x 29.7 60.6 1:20 some backtracks
900 21.6 x 29.7 76.8 1:35 some backtracks
1000 21.6 x 29.7 94.8 1:40 some backtracks
1100 21.6 x 29.7 114.7 1:40 some backtracks
1200 21.6 x 29.7 136.5 1:40 some backtracks

Lineart scan 1 bit/pixel
Resolution/dpi Size(h x v)/cm size/MB time/min:sec remark
      0:07 calibration
100 21.6 x 29.7 0.122 0:20  
1200 21.6 x 29.7 17.0 0:40  



This page has been changed on 12th. february 2001


Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-text2.jpg0000666000000000000000000000311713615534521016366 00000000000000ÿØÿàJFIFÿþXCREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2) Quality = 75, Smoothing = 0 ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀN"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?ôïøãþϰÄ»íŸkó?å¿—·nßöNs»ôªú·Ähtÿiþ#‚ÀÜ ©R€Í³ËbŒÇæÚs‚¸è3\ÇÇ/ùÛÇþÓ®gVÔl¥ø=¥YGy]ǨoxƒÌUÛ É^ r9÷›z³Ý¡¥:&ã~fï¿w÷·ü.Ï…_Y7ïõmM¿Ú»,vÏöHÆ?ßð7m¼i Èßcº·n`ó<Ì¡6í£¾F=½ë€#áÕÉ=õhôT•g©^éá­_Ëûe«Û¹*è˜á‡>¸#üæŽfkS-¡8IAYÞËV{mgÕâ¶¥¬“ˆü÷ºù• cq@‡œs€}³Þ»/øæÏÁšƒÁö¹®\$ÂP…Æ2X“’àJŽ3šù†ÙY5 pÃȇð$è¾'x’]Å .¶šjý’Ø‘ó/ØÉ,#U\ò(RÐç«¥í¢ ½Û]žÓà‰öþ7¾»²}èÏçwvþñ#x«Ã°j’X=Œ²ÝŸ~ÞN>l ä`ôã8í_!é3[Xk7Z„-˜pî‘‘¸¦H$g¸ÁÆqÓ·Zû;IûöM©ÓZ6²1)…£9V\pAïMW„a¢D惧ø‹O6ZŒX³¹OB‡¦Aìk…o‚Ú9¸V[ëê¤:(¢È˜b*Ó\°“KɳzëᾃsáÅÑDO"U›ÌVù÷€F"F=ë>o„š Æm§I%Áò;Ç.ï˜nÆG¿AEXJµH«)?¼eïÁÿÝÞEt$¸ŠDT£}â qø †Ûà·†íµºW¸!>Yc‚=(¢‹ ÛTµ¹½Kš×Â? kQÍjñän…ŽXzj•ßÁ_^Ám÷7²5¼~R;ÎìBHP “€1ÖŠ(©4¬™¥¨ü+ðÎ¥áû]&[]«lÛ£8pO^GcÇ8•±á/ Ûx?Jm6Êââ[o0º,Î[a=Bç Ï8õ$÷4QA7v±ÿÙsane-backends-1.0.29/doc/umax/negative-types.txt0000666000000000000000000000114413615534521016425 00000000000000 Negative ---- highlight ---- ------ shadow ------ Type red green blue red green blue --------------------------------------------------------------- standard 66% 33% 16% 7% 1% 0% --------------------------------------------------------------- fuji 64% 33% 16% 7% 1% 0% --------------------------------------------------------------- kodak 54% 18% 12% 9% 2% 0% --------------------------------------------------------------- konica 38% 21% 14% 3% 0% 0% --------------------------------------------------------------- agfa 61% 24% 13% 6% 2% 0% --------------------------------------------------------------- sane-backends-1.0.29/doc/umax/sane-umax-uc-doc.html0000666000000000000000000002272413615534521016663 00000000000000 SANE-umax - UMAX UC scanners
SANE-logo
UMAX-logo

UMAX UC scanners





UMAX scanners
 UMAX UC series:
Name/ID
Versions
UTA
ADF
Lineart
B/W
Gray
Color
Bits/pixel
Resolution
UC630
not 2.8
X
 
ok
?
bad
bad
1,8,24
600 x 600
UC630
2.8
X
 
ok
?
ok
ok, 3pass
1,8,24
600 x 600
UG630
all
 
 
ok
?
ok
--
1,8
600 x 600
UG80
all
--
 
ok
?
ok
--
1,8
300 x 300
UC840
not 1.6
X
 
ok
?
bad
bad
1,8,24
800 x 800
UC840
1.6
X
 
ok
?
ok
ok, 3pass
1,8,24
800 x 800
UC1200S
?
X
 
?
?
?
?
1,8,24
10,30##
600 x 1200
UC1200SE
<3.0
X
 
?
?
?
?
1,8,24
10,30##
600 x 1200
UC1200SE
3.0
X
 
ok
ok
ok
ok
1,8,24
10,30##
600 x 1200
UC1260
not 1.6
X
 
?
?
bad
bad
1,8,24
10,30##
600 x 1200
UC1260
1.6
X
 
ok
?
ok
ok
1,8,24
10,30##
600 x 1200

UTA = Umax Transparancy Adapter, ADF = Automatic Document Feeder
(X = supported by scanner, incl = is included)


The UC-series UMAX scanners often make problems. That may have to do with the firmware version. The first firmware versions are not compatible with Windows95, so I think they will not work with this driver too. UMAX suggests to use the following firmware versions for Windows 95:

Suggested firmware versions for old UMAX scanners
Name
suggested firmware version
(read on UMAX's german website)
last firmware version
UC630 ###
2.8
2.8
UC840
1.6
1.6
UC1200S
2.5
2.5
UC1200SE
--
3.3
UC1260
1.6
1.6

### The UC630 can not be upgraded if the last 4 digits of the serial number are less than 1000!


Here you can find information about firmware versions of UMAX scanners.
 



This page has been changed on 12th. february 2001

Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/umax.FAQ0000666000000000000000000001274113615534521014230 00000000000000------------------------------------------------------------------------------- Q: I am using an Astra 2200 Scanner and can do a preview scan but the scanner hangs or produces bad images when I start a final scan. A: Disable the option "quality calibration". This does not reduce the image quality, the scanner reports it can do a quality calibration but that is not true for the current firmware version. ------------------------------------------------------------------------------- Q: What scsi controller shall I use for UMAX scsi scanners? A: The controller cards that come with UMAX scanners are very simple ones and I suggest not to use this cards. I like the ncr53c8xx (=symbios-loigc53c8xx = lsi53c8xx) controllers because they are not too expensive and I had very good results with these cards. Especially the ncr53c810 is very interesting for scanning because this are fast scsi controllers which allow long scsi cables. The Adaptec 2904 controllers seem to make problems with UMAX scanners on linux. ------------------------------------------------------------------------------- Q: I want to use the scsi-card that comes with my umax scanner. What card is it and is it supported by my os? A: There are at least two kind of scsi controller cards that come with UMAX scanners. ISA-Card: The ISA-cards that come with the umax scanners are very simple cards. I suggest not to use these cards. If you really want to try: the UDS-IS11 ISA-card is a DTC3181E-card based on the NCR5380-chip. On linux you may have the chance to get it work with the recent g_NCR5380-driver. The card does not have IRQ/DMA. Try the following option for kernel: dtc3181e=0x280,255 or use the following command: insmod g_NCR5380 ncr_irq=255 ncr_addr=0x280 dtc3181e=1 - ncr_irq=255 : no IRQ, no DMA - ncr_irq=254 : autoprobe IRQ - ncr_addr : can be: 0x220 0x240 0x280 0x2A0 0x2C0 0x300 0x320 0x340 (Thanks to Colin Brough and Hans Schaefer for that tip) PCI-Card: Some UMAX Scanners come with a PCI SCSI controller card DOMEX DMX3191E. This card shall be compatible to the Advansys ABP940U (Chip: Advansys ASC3030). The card shall work without problems with the Advansys SCSI driver for linux. (Thanks to Volker Ossenkopf for that tip) ------------------------------------------------------------------------------- Q: I use linux with a NCR/Symbios logic SCSI-Controller, sane does not work right. A: There are two differen drivers in the linux Kernel/modules. Use the BSD-driver ncr53c8xx or sym53c8xx. ------------------------------------------------------------------------------- Q: I am using an AM53C974 based scsi card with a umax scanner, the system freezes when I start a scan, what can I do? A: Try the recent driver for the scsi card, take a look at: http://www.garloff.de/kurt/linux/dc390/index.html ------------------------------------------------------------------------------- Q: Will there be a support for the UMAX-parallel-port-scanners? A: Since sane-1.0.5 there is a separate sane-umax-pp backend that does support (some) umax parallel port scanners. ------------------------------------------------------------------------------- Q: Will there be a support for the UMAX-USB-scanners? A: UMAX published their SCSI-protocol for scanners. However they have not so far published USB protocols. This seems to be because they are using an ASIC that is produced by someone else and they had to subscribe an NDA. Without the protocol documentation it really is hard to write a driver. I will not work on a driver. The Astra 2200W does work when connected via SCSI. It could work with SCSI-via-USB-driver and connected via USB, but that is not tested. ------------------------------------------------------------------------------- Q: I get a black area at the top of the image. What's wrong? A: This is a problem of some scsi-drivers. Update the driver for your scsi-adapter or update the operating system/kernel. For advansys-scsi-cards update to a new kernel which includes at least the driver version 3.1E of the advansys-scsi-driver. Take a look at: http://www.advansys.com/linux.htm ------------------------------------------------------------------------------- Q: Does SANE and the umax backend work on LinuxPPC / big endian machine ? A: There are people using the sane-umax on a LinuxPPC (big endian) machine. Other people write that they can not scan on a LinuxPPC. It looks like this is a problem with the driver of the scsi card. The "MESH" SCSI card is reported to work. The NCR53C94 SCSI card seems not to work. ------------------------------------------------------------------------------- Q: SANE hangs or crashes when I start a frontend for sane, what can I do? A: Sometimes the backends that are not used make problems. Edit /usr/(local)/etc/sane.d/dll.conf and comment out everything but the backend you need. ------------------------------------------------------------------------------- Q: compiling sane aborts with error "virtual memory exhausted" on slackware linux with gcc. What goes wrong? A: The optimization set by "-O2" makes problems, try which one of the following calls work: make CFLAGS="-g -Wall -O1" make CFLAGS="-g -Wall -O" make CFLAGS="-g -Wall" ------------------------------------------------------------------------------- You find a lot of tips and informations in the internet. E.g. take a look at http://www.scantips.com sane-backends-1.0.29/doc/umax/sane-umax.jpg0000666000000000000000000005721613615534521015333 00000000000000ÿØÿàJFIFHHÿþCreated with The GIMPÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀ¹"ÿÄÿÄV !1"4AQTVr“”²ÑÒÓRSUs’•±#23Da‘£³$56Bq%Ctu´7Ebcd¡Áð‚ƒáÿÄÿÄ3!1AQa‘q¡±ð"2bÁ3BÑáñÿÚ ?Õ%J}¹E¦Šq„àhäû©@'2ã)'ü¥ ÏáMf †Q`#Nxér¿Ç…)øò!É—)¨«˜îà n™AÒTu) ñÏ“Àðè©Þº×´WKÿ~ñÉÜcº]éX=™H †ÓƒÿÚ“å ?->m>Êã~ÔË\iQÜ*aÀž# Œñâx÷éšå––QÉr_ÇüÄHm ÿ±¦­jþ¾¬´DO#þP“òÓæÓì¨ÛöÒȱÙ$ÜŠð`[ Js’N~ ¹F¬a¹IJb†œ #ó%Í “ÒwD€@$« äçîß®ŸVŸ]5êФ_Vµž“0æyB¿ùr?D+Î#ܯ¿—ôJ¼â=ʧl%‚Û´LÝâ\‘Ö¥¦Ö›Ó‹ÃP¾…‚¤¥[ÌéIp$ZálÞÎÈ¿Ü`¹²ï[¤*æˆÑ»:òb”¥)Ë!öÕ”¾à*XÎñ8Òœ‚g¹á\/BöÓšÚf¾Sž¾¿Æ38‰ŒÂ—¼ÆKþ\Ñ*óˆ÷+ïå¹_D«Î#ܤ6ga-’eÀ¶Þ-,ÃTù3ØJߜ법¹~ktÊt(`—3¨…1_Ù-]´0‹rÛ’v=7•IL…“¿N:NWYÈÆ4„Iò_eÂâþ­½ãf<üâW¬ç©Ïåµ_DŸ8rËbþ‰>qå4Û=”Ù«4- ‰ ¬Lµõ¦áÆS%nv`kë•YN­Z“§OÝJlÎÁØëCñ\w¤í|xϸҊë[°wj#ô“’{ɨ[c²‹J[¬uœuŒúöZ+\dãòÔ¿¢OœG¹_-.}|â=Ê„k˜ÇU‡äÛ¶ysãF¼HDv¾·h¸ÙZÒ€æ4¤¤$+Ot'Á«e°¿1–ö±ËÉôH²Ý$†%È;M­(QŽèJRÒ•©8!ˆ`äbÛ=­1Šõ>óž_N«|=8íõGŽ­ý«ùˆ÷+ïåÏ¢¿˜Ÿr«}R?9t²Léë»,Wõ/²uYIuóÃô𜌠pãu´ö[s°—1ÆÞÆÎô¡ú¦÷m:—5/ i*H9< ôÔ56º¤_Ã<â{ù-ð4¢±i>þHÿË+¿E1>å–GOþÕüÄû•õ›, êc²p’ˆ“B¥>Óî)!”¿‡ó©i Ps»Á¥tf¦.Ñ­ê½DÚXÛm›2Ã\};ÀÃÎ)h­8ZŽ3œ€pR{þkihÄâ"{ýñõR4vùdž{÷òåèËßE8Ÿr¾þXžú(yÄû”íq7îŠÖ̘¾[ÐåîpüÃiÊ´©Æû ½à JJ8¥«†8¦¥¶åÖ“j‡æë ¨ÚžBŠÃÉQÅ©D¼*ý$`h<1Ý2:tˆz´6[mKE|3ïôùç·—?EòÂ÷ÑcÎ'ܯ¿•÷þ‹q>å<ÙÙ7 .ÙlîLšmz¡Äq[Û}Å¥%Þ.´‚ V rTIÎ’Js€sVmñœ€dªñ ·t¨õªÐö𑜠†Ê2qòÇ8¨Z"´Ô´ÖÕžXé9ëŸ(ôþË÷åyÿ¢ÓçSîWßÊì¢ÓçSîTCò\“Ôq­âZ«àm;¶PÞ@Òt¨ÿñ“Ý4ãjn“m–g6vê÷^]ܸú @fÜ”'°m”¤…”‘©Iìpp3ÄÔ/i…tøVÒÖŠÅ'9˜ýÝ£žž¿hîü®H?ûZ|ê}ÊûùZ“ôZ|ê}Êy©múvr×w‘m¶.*ne¨É~#Ì–J–¥%J X'_dBòIÉáU[KKìÁUÏg祄ǵÍi.:ÛÄ(âÒ Hm N­ É8Ïz¡}KÄâ%M.ÃíOÒzDâ'ž&&c¬G–1<ý#)¿ÊÌŸ¢ÓçSîTÖÍmÌ¡›"?Z¢>å‚ö¬¥yìÒœcHùYÿj…“²Pb±w”í¥­¨°ŒfaL[­<^^‚ãG²t!Z€9ࡊ³Ûvnšù´ŽA·nb´ZŽÓÆJ•Œ¡¥©'¤ä©Jù šâššÓx‰Æ?ûÿO>óiÂé¡{iVÞ(Ž\ãý>¿Õ_$·(IùióiöQÊ~Z|Ú}”Ö¾­h/ÛiÀ„¡'z¥‚¢8€1áǧñ÷?,sÊ~Z|Ú}•ðÜ$i+F¬jÆí=#=ømMn)Bb™z÷RYp •“Ä4Gù‚s¤¨c ÈI›„€+@ém…|bäpnÊN½LH IRAàz2… ÷Ò{ÆuÌŸwíšê”­#ÃVLå–C;”´„µ‚4€œž´–—¯›=2ÛÖšuô€•¼HHÁŽ=Îõ[zæGÏ»öÍ2“´PáÎf «Ë K{¦”âòp4¤œœ‘ŽíV—šZ-a“Í5Ô§i˜‹"+Wûkq¤éß²‡ßwIÊu ÞƒÄg¢Ÿµ°›tħå5¶-7&FûÈ(-Ý# ÔteXz+cë™>ïÛ4ƒ·d±)ˆ®Ür$jÜ´·°·tŒ«HÎNŽŠûwÿï/Ÿ†sý1ùÚ=“:ÇF;©Æ×ÁŠbÄÚˆ‘ãÅ–eHB7€‚€Þ5”z{Þ¥^Ø ³’û¿µ‘ÝyÆ g\É*RÚ'%²J2ROùz+dë™>ïÛ4uÌŸwíšœñíÔÎf+í G&3#©Ö×L‚Ì[OølãuÙRÛxR[ÀÀÈîWÛwS½­´o97i¢BÞãyÖÒ¤7¯Æt¶3ŒŸã[/\Èù÷~Ù£®d|û¿lÔçnf<<±òw“ až¦ÛO†Øch ´Ëo‰(m$%)t  ðPæé§ Ø=±ràÝÁͪasšN†äªd’âÇ€VŒÙ¼÷ë_ë™>ïÛ4uÌŸw횸®½¹Î=”Åá‹Êêe´Så.TÛí¾L…ã[¯<úÖ¬ ’ÞOûS¶¶kØ·›{;RÃpŠTƒäÊUCNŒ`äç¿“Z±»$EvQ¸­{ÇKÝ‚4“œ ${Ø9¥¸.K ¾Äµ:ˉ CˆsRT’2 ñwjvâ:ÖŒN=ÆóR9rd©ÖÒ†`m-Ó Zo®ÒÚV0°‘»à Î:sÆ•^ÀíK±•Í¤Š¸êm •&AIB (N4c $:xV»×2>}ß¶hë™>ïÛ59ÞjO\)CZ<½™Ø-©äÞMç$^°ð^¹‘ºý-_¡£ïÛ4uÌŸwíšœÖ%×úæë9åìËYØÝ©ÚfŒÚ‚Ê%HJ‚µ€uqÿ^5Ë;´‘úÛs´Q›ë]]o¢Cãu«ô´aŽ{¸é­S®d|û¿lÑ×2>}ß¶js¡Yww«í îÉÝz{·;‹3˜ÈirpÓÀpÈ*-¨)$ ©' c©È±.ci¯‰²¡†§´”u´W ”© “ǾNÎ*Ñ×2>}ß¶hë™>ïÛ4®…+10Ž·ÜkE¢Ñã;réÚ:GO$=1×2>}ß¶kƒpZ_CZƒËJ––Ë’’’ gˆIÉýã¿V|¤U&ã(vCO¬eM ¡<’IP(ð÷’Lµp[è+fZœHRT‡2’JT8Aw43p\–}‰ju—‡椩$dAâîÐC8Êu—T0ëY X8:Nr“ßNNqÜ#†2s•õrþì³ýsž¨­Ã®d|û¿lלú£º·¶BÔëŠ*qwKŠ”£Ý&BÉ4Œ_éIò™õ VoésvªÖ¸òæBCp¥…ÈŒÛjâW%Ä)#8'£=î5+w¹J‚·Ñ.â㛳†iOù‹‹ONx`ƒœp¨Ž_¾ø›qô¸¿‚«"5üÍœî©ì2ãῸ}Ån&y@HiIpª?(•$žÃ9Ðí‚JmPÄÕ­rƒ-hJT¥é‰ % ç<#¼H¨n_¾ø›qô¸¿Ž_¾ø›qô¸¿‚ÇUyÖ7.ÛUrKò&3ozÛ‡›i( ÊäkmJRIІtÓÐi^_¾ø›qô¸¿Ž_¾ø›qô¸¿‚dKв­á2ä‚õÚ@’T‡SQRãû †ÚR\ÒTZ9AÕ‚2KiÒ•l¼¶íÆcNOmvæÞ}Ad:¾¸Ãm¯N -@¨è ¯&w—ï¾&Ü}./Ä£—ï¾&Ü}./Ä †‡h”Ì÷™rrKmáÔ[qò¹!¥jVTºqDस5¤´Ûns'B*áxU³w)Z‚_‰«Œ} QZÔðì·¤)*8P›àfy~ûâmÇÒâüJ9~ûâmÇÒâüJ(Ní#ö×^t]EýËzUh`f"Oç  ë|0üÞk…5zE­ÌËÃËL•ª."¼Ö³¥:P­n)Ôåzð·õ4;-h)ÝÕƒ—ï¾&Ü}./Ä£—ï¾&Ü}./Ä ±ÑUÎ_¾ø›qô¸¿Ž_¾ø›qô¸¿¼ËlÃq“hn:ͺá-©‹t~­¦Æ íôµ6225uÒΡy„±ÃÚ9¯Dfå>ë.ÛÚia-8–ÌD…,º¥èKò£úìþCÂÇË÷ßn>—âQË÷ßn>—âP3°òôÛÒÕsß0Ó. ֽ֖ءºZÖÛîã§ a]%B­õ\åûK‹ñ(åûK‹ñ(,tUs—ï¾&Ü}./Ä£—ï¾&Ü}./Ä ±ÑUÎ_¾ø›qô¸¿Ž_¾ø›qô¸¿‚ÇEW9~ûâmÇÒâüJ9~ûâmÇÒâüJ \åûK‹ñ(åûK‹ñ(,tUs—ï¾&Ü}./Ä£—ï¾&Ü}./Ä ±Õzñn—7j­k.d$7 X\ˆÍ¶®%qð‚\B’3‚z3Øþã\òý÷Ä󴁿”rý÷Ä󴁿”Ël- v†Ñ•=¸è–ò‘˜ªQ|™¯—T²•!´…4[9q$aYhjàZì¿*6Äx¿ñ„ÌŠå¹–š:„v#Æ2R¡Ð•h+8s†HÝözªÛË÷ßn>—âW Þo -Õ·±3§U­Å&TPV¬äþs‰Â@Ïxõš¼ëÕ ügÿ¹Ü?®ºÙù~ûâmÇÒâüJÇú¦C—d,¬Íލï™Ó-)IQH[ªZrRHÎ:  ô¸ï’TQC¸ï’TRn)ÀãM¶”8¢;5„•Àâ{Ô QUM¦–ìYî2ÔÙjL4"rÚ$ˆ-o4ïÐr4(ïì”1¥¢¿ùE NsÏ5´OM2^v3cÅQf[ª:œÝÑ`§têIt(¬@8@â„Ð[èª=®½Ì™ -CZå¸Ò˜˜ë¦ÜaÖ¤-.%°âÕÃq¨)%@é!¥K±µ÷WîŒDDVÓ.%™¯%%RŒ ÜY* ­A !u¢«WëìøÜŒA3j·¦{èuµ-RK½‚HPÝœ2{"úc‡cŬ-£ºL”¶„=r—lm(J–¶VÐyHqÎÈ•  | Ô3¤¾ŠÏ,7Ë¿[Ù`™ ¹6u¶%¾—”•·)ÂTçd­,’ I*ÔI$:;[y-]C076ˆ‹‘ ”¯Sêmé-©(ìÄ|‚J´gs9y¢ m׉’6ŽL Š#©ª"ÛV­[¥% ì9”J â¡7¦O~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sáѦO~sáÐwEq¦O~sá×.ÚmN-PÂR ‰Þ¹Àÿ®ZÆ:½ö§ë—ꦶ§Q»uhÎt¨Œ÷ñX¯W¾Ó´ýrýTÐlîvã¾J=Q\~×ÊsúNWnvã¾J=Q\~×ÊsúNP&ì8¯ï÷Ñ™s~Øeímƒ¼@Ïb¬ô§²Wò=úáËdn-\\…sšN†ä©¤—ž<±;#Ã÷žý.^i/¡‚êËJ––ʆ¥%$@î€TœŸÞ;ôÕËÍ­®³Þ\¡£¯qÖšŸHëŒã8öYÔžŒôŽýÝšÖ̤ÊjÛ âÞ¥„……¬µgÔ '¤ãv-ì¾!Fß0§Ë›¤êmN¬¤ãQ'$tç:¢¬«d ÏÇ~\(ÒŒ­l8ëIZšVAÊI‰ÈGxRû$ k«}–©*SÄÈZ\ÒãªuHÔtêYÀÿNï‘¢‚8X,É„¸BÓEZR…0##B’•€SŒ¥(ù'¤ÒâÙ,- 0el&2› 'JšH 6F8¤+ èâ{ô»¯4ÂÞu ¤©( Z€J!){¤î’+º‡‰OÊj3-È‘§|ênéN£Òp8 ôRôQ@QEQ@QE}JTµ¥%J= šùJÇýaòêš­¤|ÿ`ÑÖÒ>aß°iœ¹l@й2W¡¤c$I$à(’$’šâÆ5É…;K!*д8Ú›Z€p¤($àƒ‚A Šým#æû޶‘óýƒIQ@¯[Hù‡~Á£­¤|ÿ`ÒTP+ÖÒ>aß°hëi0ïØ4• õ´˜wì:ÚGÌ;ö p†ÖáÂ¥œ$f»ëi0ïØ4[Hù‡~Á¨ùn¶õ²Zšq+ C¨%'8Rr•õGp‚)Ã/5%†ßaÔ:ˉ CˆPRT’2#¤ݪÆË©K؉*Q%FDòIܧÀBS3¨œƒú(I `'£¯ÈÛîFu Û/éZBUÉ28Ð¥9åè«ÿÝ=Ê9åè«ÿÝ=Ê›(˱¶:ÆÃí-§›·°…¶´”©* ¤Aè ÷*/eÀÏý|ÿü‡iÇ<¡ýû¢G¹HìÃnµ°Î‡˜y•)É®<Ú›XJžuI%*Œ‚Ý ·Ií·¼µ~5‰õ{í;O×/ÕMm’{mï-_b}^ûNÓõËõSA³¹ÛŽù(õEqû\_)Ïé9]¹ÛŽù(õEqû\_)Ïé9AÝöFåo5• 8Æ“ßÍc×.­ Û¶Æ]‰v)¨×ÃSé—•— 5èéáœgýé3Žm­fÓ޲Õ(ªÅ§n­—››0#±1.»«Iq IïÛ4 QJõÌŸwíš:æGÏ»öÍTR½s#çÝûf޹‘óîý³@•7ŸýÝ+ê—ø{×2>}ß¶j¥³N­í‹–ëŠ*qrn Rt™h-²{mï-_b}^ûNÓõËõS[džÛ{ËWãXŸW¾Ó´ýrýTÐlîvã¾J=Q\~×ÊsúNWnvã¾J=Q\~×ÊsúNPQú¤uG¼u?äÎIî¾Þï:í V4hÆ4©?,ôç¹Q,ìdÝ ·7´Òì0«ƒBàëí% S¼¤ä•wIÉ«NØl¯mºË”Ÿ˜×ZkÝõ²ÒœëÓœêIù"§äFØvfx Y·²ãÎò·i*ÂМ x#SôLã<³åêÉ›Df“‰í>ªÌX"ÂÚ(²qâ´kÀR†8¡C½ûëE¬£cº™^¶{já]%Ê€¶ש-8²£© HÆPIÚÕë«pÝ>? O_ãDóÎ1ŽØÆgË?Êz:»ÝJç{«:–óŸ//|ûŠ(¢¹TQEQ@QEQ@QEQ@QE Éí·¼µ~5E‚ü¤ll;D;tÃ~·Ûwm)Øe-±! %Çm]—b J²ž)ÔDÌͼÙ$ÌxsŽØ®Ìœ¢JTø8¤9ý²^0Û¼ø ®NfêëÈ^Ï5u[ (®"§%â´JëI‰'ûGd•GWa“ÉU:Li’î±#Ûž¿3d\–ëyRîw2w ©ïÎìã<QÊ^H™çöÉxÃnóâŽl—Œ6ï>(,tUsŸÛ%㠻ϊ9ý²^0Û¼ø ž•xdˆì«…Áˆ-‘¡.<èld “ÄàPR:¤l÷[;¹Úˆ{ÝGö‘úXáÒkç?¶KÆwŸsûd¼a·yñ@ãc¿Àöûl馣öWü ÿ×ÏÿÈvœsûd¼a·yñMvEÄ=°.ºÒÒ¶Öìå%i9 C¸ ÷EÊOm½å«ñ¬O«ßiÚ~¹~ªkl“Ûoyjükê÷ÚvŸ®_ªš ÎÜwÉGª+ÚâùNIÊíÎÜwÉGª+ÚâùNIÊ袊Š( (¢ŠŠ( (¢ŠŠ( (¢ŠŠ( (¢ŠŠ)FP•¹…gHJ‰ÁÁà  NŠWTšwÎvQþiß8=Ú¨¥uGù§|à÷hÕæóƒÝ JŠWTšwÎvQþiß8=Ú¨¥uGù§|à÷hÕæóƒÝ J›Ïþî•õKü =ÕæóƒÝªý¾è»ÆÍK˜¤%r[HHù ºâŸß¥#?¿= =¶÷–¯Æ±>¯}§iúåú©­²Om½å«ñ¬O«ßiÚ~¹~ªh6w;qß%¨®?k‹å9ý'+·;qß%¨®?k‹å9ý'(ÝãN™kz=¶ãÉÒ×§w+r—´a@žÁ\@#ýóPê»m%© 7+.,¡.(È´:5“Øå‡ ”÷µœŒwE=ºÊ‚‹¬(·›€·YÝeçeºIl6ÖôS§„£»éÒ öírâ·™ê˜ÓQK©ZcóÅi@,FFx†ßÿçÿð&‚ÁmÚ+UÚSÑ"JþÖÇëb¼Ú™y 9-¬iì“ÇãÓR•œÁ°ì•»i¬SmÛGû~zn‡¤¢qyÒÒ`8•å;Åð.#V{šÂG+F (¢ŠŠ( (¢ŠŠ( (¢ŠŠ( (¢Š•úÃä/Õ4•+õ‡È_ªh+ûY.\+‚·‘!Rc4’Àl¹…¾Ú¼ì5¢®5Ýòïi—-·Õ&Z·–Ü[‘m/%KT€ ž´izÎJ°À $ŒW)qšÊZhKºHì°´žå$ö¦³,vùï¸ûì¯~´¶óo-µ¤ ¯N•$‚“ùÇRA!DŽI;Yuy÷%ÁgþäkT˜Í…'|¡"F•$¥@$)IÔž+Ât¤ƒÙ/fm³Ð^ë7lï=pmÇû÷§JÒÎ쥼©E/·IBs¨ ©G6FÆòT‡`ëiM¡’ÊYh¡—P´éJ‰ÀÆN‘Øð¥ËÚÂ\e¸”¥-ÇÜRÝÔR\YV§BR VJHBAHÀG+h'I½ZÛb.êÞýÉø…íâT§7M¾•¤Œ£.6 JJ²s§:M¢¢Ó³¶¤Ý¹¿ÚšqN´­â´¶¥%IYBs¥:µ¬¨áG$R” 2”(8¥…„ç 8îÿæ¹yè̲ãªiÒ”$¨áÁœþ”Î|WæE,1q•¨öNF •ò{4(œ€Æ¡U²’–’•meø¤ŒUyš ;÷n»9k¸¾”%éq}i@!!J@Q9á“P»+þëçÿä;Vd­V¨væµ3„0…,‚¢”¤$ŒqÀªöÊÿŸúùÿùÐ\$öÛÞZ¿Äú½ö§ë—ꦶÉ=¶÷–¯Æ±>¯}§iúåú© ÙÜíÇ|”z¢¸ý®/”çôœ®ÜíÇ|”z¢¸ý®/”çôœ kp³ZîÛ¾R¶Ã›ºÎï®XKš3ŒãP8Îð¦<ÎÙìþ‚×»VÀN5<ÚIà…wF{Õótkø+ÙA f¬6ùH• Ém!Ðë1…§# Ž÷©JWtkø+ÙL"Ïbd©ì0¢£ ñÅw ·hs‡îÀqÇhQEQ@QEQ@QEQ@QE%%§^Œ¶˜–ôG0d ­=ü¥Iâ28ƒÓßãJÑA\æ´Ïoÿn?Á£šÓ¯}§iúåú© ÙÜíÇ|”z¢¸ý®/”çôœ®ÜíÇ|”z¢¸ý®/”çôœ ŽÛEÈog&ª$•Æ‘¹l6ò:PN‘ŸÿÊÎù^çôŒ¿>¯mh›gþ•ä3ø¢©VË{ƒÐcªk­?-µ8 JBJǬòçvµ¥6n}ÊFÔBK· ¥À¶V² ³§ ñ=Ì¿÷U‹e¿¼6Ÿþî¯è3P¶Ûw$íÓPw»ÝÖ{=:s–‰èÉïÔÖËxm?ýÝ_Ðf±ƒföVÕ´sö’EÍ3q›ª™ow=öR”nYVP°:T£ÑÝ©ÿÉ®Ëø=Çïy«V»s·ïðþSˆÆÒ©ÙvþÀõÓ}dÚBt¸B‡Úð¢a‘Ù ÍìÕò*š ¶8ãRäA(Co4X¸»$!`¨pK.¡ ë¶@àHKÃØ-¸0§¢·qq´ºã$ò¬Á…¶µ6±ÅÎâ’¡ûñÃ…8üšì¿ƒÜ~÷—ñjU¬ìÿR­­€‹'Y%|¬¡¹ ¥¥–Û¸J¿GFí°1¨` !# ‘²ÒŸ‡pA°>Ä'zÝ.AbS­çÐ]ÞÈì´þ½m OéZ·zÈ B2“]—ð{Þòþ-“]—ð{Þòþ-Xm,Éf‚ÄÒÙ–ÜvÐñmÅ­%a + Y+PÎx¨’{¼iåKòk²þqûÞ_Å£òk²þqûÞ_Å«m/É®Ëø=ÇïyÉ®Ëø=Çïy­´PT¿&»/à÷½åüZ?&»/à÷½åüZ¶ÑARüšì¿ƒÜ~÷—ñhüšì¿ƒÜ~÷—ñjÛEKòk²þqûÞ_ŮјL³: Zi¤% ¨¨þˆâIâO|ž$ñ5jªÜÖ!¨ ÚùjüQ,Þà;s~Ü_CR›|°–ZR§”C¤ g*.'=î=Î5,®ÔoËWàš§½³sܽÜ^‹>áZžƒèLpÉ <0°¥6 S («**ÒÈÄȲ±ÖòY{-¡á»p+(^t«‡ùNAÁïW \à>²†fÆqAõF)C©$:T¦øÒSÒ5 ±v—m–§þ²\Pn0u²—¤†ÙJ³Ä”ïÂp§Wؤæ£í;&ฦw'­ã¾÷\¼ã®2ÀZ¤’QYN€4 E+Õ¤¤,'hm|¹ΙŒ®\†Ýq K©?«PJ“ŒçVupÇüµü“R•^…h¸Å¹YÝWY©ˆQ¥C^ƒ»!¥-²Ê’”£IV–’”‚Nž °ÐvÛjpœp9 ük®·_ÊkΧÛL¦Î~7Ý&{«L-´‘Ç9%Å$c†8xŽ"õ}~3¬ó>âh)Ï]Å8ÈÇÎÐX!Ëbá<Ø«ÞGÚ]ix#RT2À÷j·²¿àgþ¾þCµ/³Q·ì­ž¤näG„ËN£ éRPܨ•ÿ?õóÿò ¸Ií·¼µ~5‰õ{í;O×/ÕMm’{mï-_b}^ûNÓõËõSA³¹ÛŽù(õEqû\_)Ïé9]¹ÛŽù(õEqû\_)Ïé9A yÚKjÝzÖÛĦô†ÜÝZ¤)ƒ…hÁâ8àƒP­Ü¬,¸ÛY6‘ h¶¤À˜ Î@8áÒ‰«½Ö¯6V§‰É²í¥ù«¶ËYèÇtðáOvAN<»ôµF•¹72ëBK eJNå¡*ã ö5e¢;3 ÙŒõ2·”©ÒŒ§r¤à(¥(Àx (OtñÏú >S_}ß´Ÿv˜Q@ÿ”×ßwí'Ý£”×ßwí'ݦ¢µ9knäÌ­üW\SM*;juN©*RHBR —ú =ˆ<UÐ3Acå5÷ÝûI÷hå5÷ÝûI÷j²æÔZCK2VR´ëR’Ê §%$½„þd•\Ó‚…çôU‰zü¦¾û¿i>í¦¾û¿i>í0¢ÿ)¯¾ïÚO»G)¯¾ïÚO»L( Êkï»ö“îÑÊkï»ö“îÓ (òšûîý¤û´ršûîý¤û´ÂŠü¦¾û¿i>í3uaÇ50ç cÿÅqEuÖí:Zb†mÉYq—XBxc³pðïcˆãQ¼¿}ñ6ãéq~%Xè ®rý÷Ä󴁿”rý÷Ä󴁿•c¢‚¹Ë÷ßn>—âQË÷ßn>—âUŽŠ ç/ß|M¸ú\_‰G/ß|M¸ú\_‰V:(+œ¿}ñ6ãéq~%s³ðåÀØ·Y›Qß*–éiJJŠBÝqiÉI#8Pè&¬´Þ÷t¯ª_àhÉí·¼µ~5‰õ{í;O×/ÕMm’{mï-_b}^ûNÓõËõSA³¹ÛŽù(õEqû\_)Ïé9]¹ÛŽù(õEqû\_)Ïé9A•íßUÉ[/µ‚ÏÜËÈ‹ ËS䂿 •ilƒØö'ôˆ•¨ ãÉZB°Þ¥%åZÙYŽÛùL=Õ#gàJؾTJ¿AõøÎHFRŽ•8q<“¨ÍíD‰MõHÙ–šÚÖm̯:íª/ñýÃI×úY#(ʲ(-v댙³n,?k“ ¸†šyÒ’™)Ò´àž?‡wRS#Qv¸oƸ]vç2Z’ÛO¶ˆãB{Α©?¼dw?H,ªR€¢¨“-1oyxnj¥Ø‹M¥©n´V÷QÂ2N”ô÷©Ï3,¿&Þr~%ʪˆ¶\"B€ø†·œ‡y™1QÛZ5¸Ûª’¤©A9ÃÈV ‡ ÷x§a¶u lu¤ÅÚ &ë/$”‚æþúùÌð9zÌø´åX.íÁ¼°-ëqWÈ0’—[ÄE8ü—{*’œîõñBñžÇVUÖv.Àävœ\ ).!+À»L8 w£¸j'kvfËjÙ ¼è±¥¢K[KIgBôœ+ÒÇ ÅMæe—äÏûÎOÄ£™–_“?ï9?‚åESy™eù3þó“ñ(æe—äÏûÎOÄ ¹QTÞfY~Lÿ¼äüJ9™eù3þó“ñ(.TU7™–_“?ï9?ŽfY~Lÿ¼äüJ •Mæe—äÏûÎOÄ£™–_“?ï9?‚åESy™eù3þó“ñ(æe—äÏûÎOÄ ¹QTÞfY~Lÿ¼äüJ9™eù3þó“ñ(.TU7™–_“?ï9?ŽfY~Lÿ¼äüJ •Mæe—äÏûÎOÄ£™–_“?ï9?‚åMçÿwJú¥þª¼Ì²ü™ÿyÉø•mº¡ EšÛiJ”8”¥#¤öÛÞZ¿Äú½ö§ë—ꦶÉ=¶÷–¯Æ±>¯}§iúåú© ÙÜíÇ|”z¢¸ý®/”çôœ®ÜíÇ|”z¢¸ý®/”çôœ ‡¹Y'NÚ+]É‹ìÈ‘¡êßAi)ÝÈÏÊÏÿ|…pý'²¥çZ\™~´ÜS!”"û[kЇæ´„.ɼt?¥Ðk»Õòß³Öãpº<¶b¥A*q,­À’z3  ðÉá’Iɰ´Éa·Ønêë.$-"Ñ-IRHÈ †ø‚;´ìEDw¤º““!À⻌„£¤OŽ*Éîg½2´]àßmlÜ­¯ïâ=«væ…'8QIà H=Ê{A_‹hš­°¼ÏÝ$Fyˆ­6µ8”êR7…X熴ñèãûKò|Žó^yÚsE4ÅíDKep…=tV¥0 ¼ €8dã¾i íÏÑ›=÷¢þX( ¯çmÀJSjÙÄ%)J‘tsÒßxT}òÙ¶×»ë[v}¤ÊeM¦æ²S‘ŒãwÆ®P6äùæ¼ò=´r|Žó^yÚbô©ˆÛQÈë­ò-û-âdg£»œðÄ^ÑÜ¹bã¦ÑkDô6„ ¦BÉ{±sRIÓù”ŽÀ¤öJãÑ€±r|Žó^yÚ9>Gy¯¯}§iúåú© ÙÜíÇ|”z¢¸ý®/”çôœ®ÜíÇ|”z¢¸ý®/”çôœ ‡Ûð=ÿþÛ#új£c¿Àöûl馑ۙ gbî­5d·åFr3LÄaN¬©h)€8$g$ž÷t  rlͪÜì”Iqa6Û­Ë‚ë@ƒ…”é9Æ@8==ÛÞ¹J‰ ™o™èàác¸HHÎ:NOI&QEnáµ2£_$ÚáX¥Or;m¸âÚ}¤«Oé¨qìUÑžŠK¯çú\o‰IGÿÔ ÿý/Åê›­j'¯çú\o‰G:/^'Ïô¸ß¥¨ ‰çEëÄùþ—âWmmõ÷mìlò£“ÆlQÐ3Ýr¤éÕ¿¶Ç¿PÐA*eísšš­Š–d4ÚÚBùJ'¬¤¨c{Ž% þëL¥E¸Lp.FÄÜVx…ŽZ`RTU¡ÀÈJ”€¢‘V¾¿‡ályÁ\0ž}‚©1T†Ô¥«S©áØ(Äôê"±ŠÓM\˜¸™ÍìDàö¥-)7xÅ´-YÔ´¶^Е«*©Y=‘ÊÒ6ªïk0ÝÙ¡÷›[­¡3b«)AHQÈsiéïþãV.¿‡ályÁU©¯4÷T( iÄ8‘j’2•3½fNt^¼OŸéq¾%è½xŸ?Òã|J–¢µ¨žt^¼OŸéq¾%è½xŸ?Òã|J–¢‚'¯çú\o‰G:/^'Ïô¸ß¥¨ ‰çEëÄùþ—âQ΋׉óý.7Ä©j("yÑzñ>¥Æø”s¢õâ|ÿKñ*ZŠžt^¼OŸéq¾%è½xŸ?Òã|J–¢‚'¯çú\o‰G:/^'Ïô¸ß¥¨ ‰çEëÄùþ—âUŠà•¢¤8––r3ƒœΤ/?©¸y.~±‡{mï-_b}^ûNÓõËõS[džÛ{ËWãXŸW¾Ó´ýrýTÐlîvã¾J=Q\~×ÊsúNWnvã¾J=Q\~×ÊsúNPwE!&[7=p½×IQN£ú ž“Àg$’†‡´ñÜrâ¹ELÆmÀ¨Nî'®Ù(lkk#óÙqe#wœêF3©%A`¢Š(3n„ÍÂTþ¶JäÉJâÔµ~Š3¤5(÷øÿ¦èà}¥ûÔQ@hà}¥ûÔhà}¥ûÔQ@hà}¥ûÔŒ¨6éÑ—e²,†M<´«# œ ZŠ~gì—Š–_Ds?d¼T²ú ©Š(!ùŸ²^*Y}S˜6 ±âô ¶#ªN‚¶ݨ§ ã ôpŸÑ@hà}¥ûÔhà}¥ûÔQAíæÎÅÄAq¤‡µ% PmâÚ¬iBœ‚Trœ$N¤àvC2#ø#_i~õU&[. ¸ÎŒÜ5­™·H“Ó,-¶ÐÖãRT µê;…c #²NHã‹]¢?‚5ö—ïQ¢?‚5ö—ïQE¢?‚5ö—ïQ¢?‚5ö—ïQE¢?‚5ö—ïQ¢?‚5ö—ïQE¢?‚5ö—ïQ¢?‚5ö—ïQE¢?‚5ö—ïQ¢?‚5ö—ïQE¢?‚5ö—ïR75—!LYÆTÚÉÇúZ›Ïþî•õKü Ù=¶÷–¯Æ±>¯}§iúåú©­²Om½å«ñ¬O«ßiÚ~¹~ªh6w;qß%¨®?k‹å9ý'+·;qß%¨®?k‹å9ý'( ¯I”ܶ¸HŒöΉá":·Î¡I) *ׇð –ÂAZrœ/:9¶— sû6ÊX”ÂçÌvwà!/ÛÁYÆ€\H'ˆP^Œ(¸¯®2Ó«in4…©¥kmJH% ÁNGxáDg¼O~¢àìäRoNõ´e¦ìþõôn“»J ò!jãÝq]òH=€ÜöØP¸É!íY L¤'†µñÎxçý©ÕPQ&ZbÞ6òðÜÕJ-±*›KRÝh­î£„(d)éïSžfY~Lÿ¼äüJ’‹hš­°¼ÏÝ$Fyˆ­6µ8”êR7…X熴ñèãûKò|Žó^yÚÖªÜ̲ü™ÿyÉø”s2Ëògýç'âU§“äwšóÈöÑÉò;Íyä{h*Ü̲ü™ÿyÉø”s2Ëògýç'âU§“äwšóÈöÑÉò;Íyä{h*Ü̲ü™ÿyÉø”s2Ëògýç'âU§“äwšóÈöÑÉò;Íyä{h*Ü̲ü™ÿyÉø”s2Ëògýç'âU§“äwšóÈöÑÉò;Íyä{h+ж"Ää —ž¤éQÁ¹ÊÂIî9û©ß2vwÀåýë3âÔª£Üb¡NÃ÷ÂHKoKKI99P #“Ðz1æ¢s·?Fl÷Þ‹øuŒr½‹°B I%ÅÆí0`•úÞòk¾dìïËûÖgů‰;nm[8¥':Iº9ÀFWÞ&ŒíÏÑ›=÷¢þÇf­Úø6æ™šÓ !÷nrŽ¥Jz\$`)]:¿p§¼Ì²ü™ÿyÉø”î5—håm37K¤{Sf±Ò˜³·…EkmY:’œcAî÷EOr|Žó^yÚÖªÜ̲ü™ÿyÉø”s2Ëògýç'âU§“äwšóÈöÑÉò;Íyä{h*Ü̲ü™ÿyÉø”s2Ëògýç'âU§“äwšóÈöÑÉò;Íyä{h*Ü̲ü™ÿyÉø”s2Ëògýç'âU§“äwšóÈöÑÉò;Íyä{h*Ü̲ü™ÿyÉø”s2Ëògýç'âU§“äwšóÈöÑÉò;Íyä{h*Ü̲ü™ÿyÉø•mº¡ EšÛiJ”8”¥#Ÿ'Èï5ç‘í¥nä*<ò ¥ÂÿCXÙ=¶÷–¯Æ±>¯}§iúåú©­²Om½å«ñ¬O«ßiÚ~¹~ªh6w;qß%¨®?k‹å9ý'+·;qß%¨®?k‹å9ý'(;¨èû5Õõ1n»@˜òS¬·JPN@ÎO ‘Ç÷Ö)Õ¯kæH½¯f#¸¶ ÆJ% c|ác'Ò Õ§ôÔ8ö*èÏE%΋׉óý.7Ä ´ÑUnt^¼OŸéq¾%è½xŸ?Òã|J M\fý[ØÙØN*=?êçî4§+í‰Òþñ‡ñhìåÎá%û3’¦.BnöµÏ[kBc¬{ô¤?žPìÊbž=9µÕ>W+cêz.ÄNJ´è@]Þ2ÒÒ2†Ò§ˆm<Ø ا‡b1#ÊûEât¿¼aüZ ú*¤®º®L¨éÙÊv+§€™„¨¡+;ÌÅi<;ýüÒœè½xŸ?Òã|J MVçEëÄùþ—âQ΋׉óý.7Ä ´ÑUnt^¼OŸéq¾%è½xŸ?Òã|J MVçEëÄùþ—âQ΋׉óý.7Ä ´ÑUnt^¼OŸéq¾%è½xŸ?Òã|J MVçEëÄùþ—âQ΋׉óý.7Ä ´ÑUnt^¼OŸéq¾%è½xŸ?Òã|J MVçEëÄùþ—âQ΋׉óý.7Ä ´ÓyÿÝÒ¾©ª÷:/^'Ïô¸ß¬W­%!À´´° “‘œàð y'¶ÞòÕøÖ'Õï´í?\¿U5¶Ií·¼µ~5‰õ{í;O×/ÕMÎçn;ä£ÕÇíq|§?¤åvçn;ä£ÕÁá.7{'8$Oæœè¦ƒê¿Ôö}ÂãÎK4eÊS‰Crã2•-¡إĎ9Ò’á€xä‘7Ôi-¶‚×üõÜÜ[pc'xúÁi ¤~Š u«JéP­+Züg¢¹îÑ­~ 3Ñ\÷hZ#½6s{¹óÝ2¤£ îÔ@ o#Є¡½C´jé&¤+kðižŠç»Fµø4ÏEsÝ ªGÿÔ ÿý/Åꛥك›„©ü™)rd¥qjŽÿè£:@ÃRúaÎYú-ÿG~‚>ŠË?E¿èïÑ–~‹Ñß­kˆ®!¨2âÒ„…£*QÀ\õü? cÎ B}¦ÏtÝò†Í·3wq×4çÆAÆp?…3æ–Êø•î¥ûµŒH"L ëïªL\”¶„+z\5•œãŠýß_Ãð¶<à¨Îil¯‰P~ê_»G4¶WĨ?u/Ý ŠÙõ%w=¥RH)7RA†jv—ƒo¶[,ÀÙñ¥+YCm%X8§€þç,ýÿ£¿AEHeŸ¢ßôwèË?E¿èïÖµEHeŸ¢ßôwèË?E¿èïÐGÑRgè·ýú2ÏÑoú;ôôT†Yú-ÿG~Œ³ô[þŽý}!–~‹Ñߣ,ýÿ£¿AEHeŸ¢ßôwèË?E¿èïÐGÑRgè·ýú2ÏÑoú;ôõ!yýMÃÉsð4eŸ¢ßôwé“Ëvµª4¤•6²IŒà ÷Hà+}'¶ÞòÕøÖ'Õï´í?\¿U5¶Ií·¼µ~5‰õ{í;O×/ÕMÎçn;ä£ÕÇíq|§?¤åvçn;ä£ÕÇíq|§?¤åJRP’¥(%)$œ)¿)AðØþu>Ú._Ýrþ¥~©¬ºÉn³ò}¥‡6~ÎéU’<¥ºä4)jpéI$ãN{ù©êê×J“{t†ÌcNú©iùGV£ÊP|6?O¶ŽRƒá±üê}µŸrm“òÈ<Û²u¯%õî¾±F½{ÝÎ1Œ~ìç»JÛm6)›M|¶¹³vPÌ·Ý)0Q¨ëAQÕÃ#†¯M4mzÚÕÿŒf}â>ó ™ÃDJ’´…%AIPÈ ä]%*Z‚R’¥€M)'¶ÞòÕøÑõ‡È_ªj@ëi0ïØ4u´˜wìŠj|¤\®Ÿm1-qšµs\¦Ën^¤ä)xñ9$œŽi{Ú-¨‡"±s =¡Çn[MÇi“’¥ê$•`aX áŠùqÅô-¹ÿ)H™¾qË~yÇñÖ;š³]-9ÕÔœV;§J¢ÇvD„–Xin8àÒ”$ ’Iàs_+<¼ßîw½‹Ú·^´H·[Ó0žu+R•‚@àS£±ÆFxž8}\LuûÄý¦cêsïùòúO7Hmn! QéÂFk¾¶‘óýƒC_«È²k)¿uF¼Â¿»m³¦ÅIuÆËIˆöñ$å'²Â¸‘Þ<[Co}{Mhâ÷ŠFe«u´˜wìMðbµ½7-êJ5¹ØJ!)=ÒHwI²zª]WjvS¯ÙÐúp1_R••`äêwÆ3žŽ§sÚ –ÌÄwhm¦Û/—¡6–wKoS{æˆ$(œñ'ˆáÃ÷VjhN­Y˜ÍzÇçöR+jb|3Ò?:ù4*í 8æt!JÇN‘œWª{QÏ-?‚ª,m#æû޶‘óýƒITu‚{·]œµÜ_Jô¸>´ ¥ (œðÉ ‘{û2šKÿš.¯Ca}޵`«=' QÇxÜ¢«·õ(m6Ê''Išñ#< ëW½¦¬T¡—\CkPèÊRMuÖÒ>aß°i ÝuÈÎuŽç®ðîãÞ½#N¬qÓœgqY¾Îߺ£m5†5â{*Üy´%á ,iQIÈŽ”žíŸÖÒ>aß°ieô0éyÄ©hm\¤¤€¢t¤ä÷5ýQ&íÙlµ½ûÆÒE°È¶1 :›k%äêZS©!`¥XÔ{Sžø©§Ô£Õrt‹D’x¾cØ(,UÚuÁ”6µŒ¥$ת»Q¿-_‚h¶‘óýƒG[Hù‡~Áª^ÁíËako|×Z\ÒÞñÈä—¨§zÖIÝ$`÷ 6—nX³_-–XmuÔÙScǬÜT¸®Èÿ:’Ržð*< s„2út„<âT´6® RR@QºRr{š‡~ŸýÝ+ê—ø…}J=Qà''H´I g€;æ=‚¦§ÿwJú¥þìžÛ{ËWãXŸW¾Ó´ýrýTÖÙ'¶ÞòÕøÖ'Õï´í?\¿U4;¸ï’TWµÅòœþ“•Û¸ï’TWµÅòœþ“”Ü¿ºåýJýSTû½26>Å!¤ JM­†Â”8-´’‚qÀdpñâ2 Âåý×/êWêš®ì—ø2Åÿoý4×6¥oY­º:‰Æc´òŸXž°‡å6¹ðˆK7eÚ‚wKh¤ãz¡ÅxPH#¤`:JB,p-ÍÂSï«K“$¨.KáK„ Žâ@àNI$’c¹Oå—µµÖ¼—ÖZ2uëÞëÎ1Œc÷ç=ÊžªÒö®Ÿ‚?™óüûóòÇ1LIí·¼µ~4Gýaòêš$öÛÞZ¿#þ°ù õMp)½¤äͦSî&bÚ·0AhMÝGì€%Ť'* ¢R:@DÜn-¦–‰¶Ûî·SIµË- $ç|°…6uðB³£CJÿEíÏfÙºm4›£ómêdèÜ´]é)Hì—ÃŽtŽú\N4®›.zn0@V8ïxçÎqÇ t×Äâ[}-Å5xv†5#œÞs9™ëŠÚf½fg8ëÓü\¢":c³xtëÎÚ³¸ýüóŸœãèU¯Õ¿äY5mM±]n 2ÒLçÞ.¢1S‹R—€’¬’zp2{„ÖøÚ’†$)D†òI<Ô+=V̦EÞUÂUŠ[Î*:7üIQ ô~™‰îgºUζïu¶ˆ¾Û¯Ê'îçˆN¥tâtë6ô… &ÂÈë=rf6Ó¥$¡!‚VÁ$q JÆ¥iN0u$jV8Fá«~ÆÛcI¹½<"ù2· üÛaÖ‚Pœ“„Œp‡˜E›BJEÆECÒr{ŸëÿïJêÒ"Ù-ñÌ–_-B_æ—«±ß¶8÷kͶâ|_^Ó¥»ŸÑ<ÿmcŸnqú¾W ¿Æ7ðsíŸÊñJ§µòÓø*’®Ôâ‚êÜZP´eJ8‚«Þý"†m»UùE…)#u²"bàò!­¦^oR·m——©ÀuCN®%AA&"ÓoÚWŸØ¹LIdÚ“ii1ón"3û•º”ºŒêF´¥y jÓ¤¨éÂØó‚£¬‹VÎZíÏÍŠ§¢Di…©‚’¤ $‘œpÈ Žº&R/Û ™¯2ô2F·h¶ƒý™ìa%J#†;§ÿÅZª±zËûQ²»—[sÎ…ìÎÕžUv£~Z¿Ö ²[C¶–-‹³u¬k#vT´"á08Rʔ냔«)†5iÒ5'$qÆé5þ·µ…¤³¼Ô½ØyÍÚT­#«÷àÿ¡ª†ÄÚÓbØ–l‡íî·¨Piýãn¡j*:‚’>QqSÍ=Õ šq$Z$Œ¥@Œï˜ ³RªíFüµ~ ¤«ä×úÞÖ’ÎóR÷aç7iR´Œ¬߃þ†ƒ0Ø›chú‘YQ×BžÇ\*$øê)v:‹®A’8)9â;Äme–†Ý²0á¥d¦ˆã¯:­N>âµêqÅ™DôŸö ™Ø(+Ù­‹g¸Ì·©èÊpÇ‘­+J–WžÉ)ÁʈÇŒçŽgEï‘y6M°õ…É©îu̲ޭÞp¥ éÔx÷1ÐsÀ¿ÿ©0?í¬ÅMÏþî•õKü @©æžêM8‡-FR FwÌTôÿîé_T¿ÀÐ=“Ûoyjükê÷ÚvŸ®_ªšÛ$öÛÞZ¿Äú½ö§ë—ꦃgs·òQêŠáIs|˶\Ð¥’“‚…'üÄ• íÎÜwÉGª( MIyi)T%)* ¼É}º[®®6ÿ¤µï×4Pu×W›ÒZ÷è뫇Ϳé-{õÍ•IQ$ÅY'‰%ö½úo.nWm­c¯Úyl- ÁÈÈ+ÁâÿjuE3¶Å W£ÅöÑÌíŸñBÕèñ}µ=E3¶Å W£ÅöÔßö_žgß®è e>ÚÅÕ„±q³31”«XnAaÄ…`ŒáJÛìl¥µ§›PZC1R¤¨‚Wv¦¨ ãûG‚/Ï3ïÓ+…žÛwÊV(ÓwYÝõÈŽæŒã8Ô£Œà ¢‚™Û?â…«ÑâûhævÏø¡jôx¾Úž¢‚"&ÍZmò‘*ÌÀ!Ðë-ÆBÓ‘ƒ‚‘À‘þõ)ý£Áç™÷ëº("çØm×WÒýÇgaÌy)Јî('$ã*Qá’x~úkÌíŸñBÕèñ}µ=E3¶Å W£ÅöÓ¨u©õ?nÙØpÞRt#¢;j)È8ÊT8dº¥( ãûG‚/Ï3ïÔtû ºêú_¸ìì9%:’ÅäœeJ<2OßR”P@ó;güPµz<_mÎÙÿ-^ÛSÔPEÀ°Û­O©ûvÎÆò“ ¹ÛQNAÆR¡Ã pýÔòKržˆóIˆ ¥¡Iy¬d.œQ@¤‚%Ò ¬GúÖ)Õï´í?\¿U5³Ö1Õï´í?\¿U43Ͷ¹ŽïeÌ%Þ4•ã±+Äo‡èÍû+·;qß%¨¦»¢,–I—7[SÅhº¤$à:qûèn#x?FoÙFâ7Côfý•_åûK‹ñ(åûK‹ñ(,ˆÞÑ›öQ¸àPý¿eWù~ûâmÇÒâüJ9~ûâmÇÒâüJ â7Côfý”n#x?FoÙUþ_¾ø›qô¸¿Ž_¾ø›qô¸¿‚Á¸àPý¿eˆÞÑ›öU—ï¾&Ü}./Ä£—ï¾&Ü}./Ä °n#x?FoÙFâ7Côfý•_åûK‹ñ(åûK‹ñ(,ˆÞÑ›öQ¸àPý¿eWù~ûâmÇÒâüJ9~ûâmÇÒâüJ â7Côfý”n#x?FoÙUþ_¾ø›qô¸¿Ž_¾ø›qô¸¿‚Á¸àPý¿eˆÞÑ›öU—ï¾&Ü}./Ä£—ï¾&Ü}./Ä °n#x?FoÙFâ7Côfý•_åûK‹ñ(åûK‹ñ(,ˆÞÑ›öQ¸àPý¿eWù~ûâmÇÒâüJ9~ûâmÇÒâüJ â7Côfý”n#x?FoÙUþ_¾ø›qô¸¿¤­Sn3ÒòæYŸ·!²óí,¬œôÔ®ŒqÎ:F3ÇûqÀ¡ú3~Ê7¼ £7ì§;¶’Ú· Æp”Ý#¿û«æ˜ÿ:ï›õ}Äo‡èÍû(ÜFð(~Œß²œió®ù±ïQ¦?λæÇ½@ßqÀ¡ú3~Ê7¼ £7ì§cüë¾l{Ôió®ù±ïP7ÜFð(~Œß²Äo‡èÍû)Ƙÿ:ï›õGßnQ¬– …ÐïëHëx6R¬¥$„ç'<3ƒŒÐ8ÜFð(~Œß²±¾¯)JaZB„'|æ„„ا¸8VÏXÇW¾Ó´ýrýTÐlîvã¾J=QU;ÿ_èÜü*Æçn;ä£Õ\Ûïð÷þÏ‚ÇEP@í%Îåi`ÌÖÝlÒrP¶\qO+é+I a8OëW©#VH=”[ÛYrfl­ÜDJJ%¶á¶Ã‰R‹Ip§LŒ–ÝR‹xÝ!:Ó¬çõj©ë­‘mHvtÆ£ºÙfLv–܆Îr•$”äPR¢Oá³z踩S p㯵8†]t,-Ä­ 9¨ïéYYÀNœ¿.é:t5L‡®Ü`\#) ~2”ÚÂÉÆiÏ¥µƒŒ’ØN@Q5½‹ˆ¸F!¸OÜ¡2r×öf5!E¤öšTBNóY)Ïd#ùÙ5m¡ ›mKEÇÝÕ1–ìye)h¥¶›K™RÔ\Z@JÔIaxœ&R^ÐJüž¯háEg® ´NC8t'-ë 2p3ÞÎ1”ç!ѲÊ,!'hn»ô©DH€­$  §u»#)CŽ ·l1\±¿eK5or‚–PG摤§)QêÒ@쉈áÓîÿ=ÛVÎ].,% z$G_BV IRPTÆ8dT,í§—Èsnq†Rܶ"4Óñ][ÈÔò¥¸Ð)^JV–ÆF“žÏJl78 ]mS-Ï©if[ ajAA*II#9ãƒL®=y–¡&LeITwX(ì\ezÒà IGI$¥ Êæ6Šjlrn/¥—H—¸[ SR¥¯t²VÒU¥ZŠÃyó‰"ÑP26yKµH·¢JÞå®2$­Öô„¬a Ê„·Ø„àY*”õJ§µòÓø*’¥SÚŽyiü@;ú¶<ƒë*’¨»®Öìõ©æâνÀ%ÂÙ[é FI##9=ÃL9ý²^0Û¼ø ’¾=%‹C«†ê|©J”¤‚u-)!»á„v%e9ᚯ3x»¢U¢#n-Ò«¢¢ÍLíÛo¡=l§BºJ›QÆ<x•¨8—¶{>*ãI¿[–Òñ$`‚A¥@€A €AS$_v Æ@¾Ä&<‘-ë.BJu)eZ—Ø8Q#N@Xûq"L–á5iCÓ} ·¹°Â¶ÞZ\KŽ6IË ÉJHÒAIYìj^Ç:ã.ëfj Eš–£nÜÔBK-¯i(+¤ñQ ÀG»õ;‹6<¶oRôu3ý¹e(ÊJBBJ°”©a)Æ”jV5½µÛlÉlßà¥éŠJß̲R¥%! „“„ @ÀÎqAmªæß€/¿ôn~sûd¼a·yñP{g¶{5?bï1bß ºû±Km¥á•tßA¬c«ßiÚ~¹~ªkg¬c«ßiÚ~¹~ªh6w;qß%¨¤&5è®75 .2°CÀ(g¡@ð#÷—s·òQꊮm÷øûÿFçáA`åxÞùtr¼o ‡üº‡ævËø·gô½Ú9²þ-Ùý¯v‚c•ãxL?åÑÊñ¼&òê™Û/âÝŸÐZ÷hævËø·gô½Ú ŽWá0ÿ—G+Æð˜˪íÏg6JÕj™qfmJf# }iDŠŠR’¢@ãMm– ‰Ò OÙ yl6ÛÄ0Âl¡Â°žÈ¶ƒ«-¯#Æ8œÙÊñ¼&òèåxÞùuž#›m÷v&È”ÜXCöà–[QZVãM¤=ù±»9Ötï05ôàj”‹jÙQç"ç²öHе©I™»ˆ‡PK¹IÝ…(hZÊr0xþWá0ÿ—G+Æð˜˪ik©ò[uÇ,vÖRÓkqÍõœ·§BJÔ’Øìô½¤S٤斉oØY²‘«µ// !ëFë²:¶Æ¤jÐ{-=–4ñ ¶r¼o ‡üº9^7„Ãþ]Vœ²lKR•v+8C[®NFµ‚RR4åIÀQÔ2…ä Äuæß³–Çå†v:Èû6ø‚lÕ®;hRZ%xÝ€ÙÖ¬4¾ ~'våxÞùtr¼o ‡üº©Üìó¢À²ßmÇ€}„2ØCe]mgV\F1ŒñÅÅ/9¶¦ÆØË?&)È̸ã‘ÚKÉ[éiHÃa%#~ÞN°Ge€p5Êñ¼&òèåxÞùuSoØ[tãM‚Ú ¥ÒhÖT ’ÙJRT”§9QÀ’EMu>K‰oíªQl8tYÊ´åJ@Jˆo±YZ€ƒ… 8Õ‚åÊñ¼&òèåxÞùufvB|TI³Öu´¼à˜ ‚8 ‚œ¥@‚8 ‚RÜÎÙìþ‚×»A1Êñ¼&òèåxÞùuÌí—ñnÏè-{´s;eü[³ú ^íÇ+Æð˜Ë®“pjH-6û ÿ1Kzsþ¼?Ö¡y²þ-Ùý¯v¤í¶k]¦$ŽM¶Ã…½[{ζa-ëÀV3¤ ã'øÐ= RBu €sžœwî£tkø+ÙC¿«cÈ>²©*wHð†¿‚½”n‘á {)’”ûÒi§[e-! R–Ñp¨¬¨¤ãtôÒ/ÜÛˆ¢‰âæ´«VT ‘¬Ĥ={¤xC_Á^Ê7Hð†¿‚½”ÀÍ!{£@|”èeI R ñ8O,áDLjèËYw–Yk=pÛ q)XÁÎì¸NB¿Dg8Çs9áA3ºG„5üì¦wY‘¬ö‰—)¥LÄeo-(R‚A8dã$q§N£vêÑœéQïâ«;}þ¾ÿѹøPXëê÷ÚvŸ®_ªšÙëê÷ÚvŸ®_ªš ÎÜwÉGª*¹·ßà ïýŸ…XÜíÇ|”z¢›\ Fº@z Æ÷‘ŸN‡[ÔS­=Ñ‘Äg£† š)]ê<¯â¯mÔx;_Å^Ú¨¥w¨ðv¿Š½´oQàí{h\à5uµL·>¥¥™l-…©©%$ŒçŽ 2…kžÄ¹3äÎŒìçÒË*SQTÛa¦Ô¥`$¸£¨ïµcô{Tæõ×ñW¶ê<¯â¯m=ï[EaÛ’›sbÜS¤¡(q§^ìÎðæ;YÓ»È×Ñ‘¥êöuÙ+Ü)3P©Wt¸}¶JP…)¤´ PTNPžG'<@8=ê<¯â¯mÔx;_Å^Ú •çcùY«‚:ÿu×r\;Z5Â1qúC8μÿ·ï§¼ßÿ‹õÿ]î]£wÿÒu¾ŒçÿåŸöÇv¬Ôx;_Å^Ú7¨ðv¿Š½´oÙ]zâ¹ý|´ÉKíª:ÂN`iÞ3ŒáAxY$ŒåH?ñø£ÆwúŒ.ík¸Em¹ÉZŒhb c=ù¦ÝŽ6דW²GÖ”WÅ6—“é÷Ö÷¶²ywò,±>ÚÊr@ë_]xOÄx—ÃöÚŒd~ñrFG¸8î„îV' èYÞ÷7(®kÇ^¶ñ‡…æÓgÞ²+ ­äSÌr@8î0H ö'¡Á#ߨÝi—ÓY^ÀðÜÂÛdúƒþ{÷§r(ÐUWÅf}»E|ë¡üpÔ,|{c¨.uˆÐEauÁc¸¾L‚ L“’Ù¼ÕäsK=åÓË,’Oq3–wrY݉É$žI$Ò¸ÖZÝØûšŠñ‚Ú]Αâr.JµÌäœ6ÜíUƒq÷9>À{E3žI'¡‘â¿ùµ¿úðŸÿEµ|´kê¯[M{áVÖÝ7Í5œÑƹ,P€2xêkåycxdh¤FI•da‚¤uv¬êWò^ÎkÌöƒ?ê.Ïzâ>)ÿÉGÕ¿íþ‰JÖøoã='ÃQÝ&¦fO‘ &íätQèO¾‘\Ÿ‹õȼIâ«íZ^§eŽrÛUB‚qÜ…Î;g=hmr¡`°ÕiãêÔ”lõõw$ðWü6¿_ê*ŠÿäoÖÿëþýÕÁ(ÇÄö­ƒ·p÷Ȫ+ÿ‘¿[ÿ¯ùÿôcR ´xê–ìŒc]f£ã9o>ØøtWŽlÌUŠƒ "‘ü@’^ té\êÙI6™-â.VCž€àùŸÖ¨š…ÍS¬ÓþWøÿZ5£áÿù,ÿßþ†ª\ÀÖþP`At݃õ?áV¼=ÿ#—ûÿÐз9±R¡&¶³=Óâ—‰ÿ°~Ea bïUCn¼}ذ<ÃÈ#¡ ŽϑҾq'šê¾ ëÃ_ñdóE/™kl‰knp¸ÚƒœÔ.Àç¡AË+´r+©Ã)È8èGJ¦õ9°´}•º½Bâ -§xd2út?çŠõŸ‚+û£6ƒs."›÷n=ñ(Éüp÷yEÝä÷²‰geg "5\œg“îyééIa>—¨ÛßZ¶Ù péÉíØã±è}¨[‘Z›©K–[þ§Ûãßü'¦É¡|Ï¥Ü.3™óŸÝŒu=Ç=Hô ;ÅZkøA5û»´‚É!I3ä;qÔ“êI©¯™>!xÖãÆÞ$’÷3G§ÅòYÛHÃ÷i“Ææ#'¯a’U³ÉÃÓ“Ö–9#]¿Ão'ˆu6×# Äÿ ŸOsƒùW+•u>›%ìQ3Çù‚®p£«}øúSôPðÖ³©¦ÍåÜDzU׺°îÿ\`€jQÕWß‹IŸdèÚL6Ÿ¬ aG'Ö´+ž)Óü]¡Å©éÒîFùdCÃF㪰ìúÄpA­Ê£ÍjÛ‡ZóŸü4ƒYïlñÃrØþ#^EÒ«:Ræ¦ìÏœ¯>kvêX@Älæ›eðçW»Ã}™Àèwq_GÁÐ/@Ò—*:å™âåW7ýyž}á‡Qhò¥ÕÞQʨ\¿Œ~K>½sy§}¢Au+Í&ö\bIŽ™5íTSÑœÔñi6á+6y‚¾ÝYË]F6·128'`ò+¾øI}m¨2Û,’­ò— ä{ñ_@ÑE‘KY6Ôž»ž/®|(7ZM­ÄF·$b6XmÆIÎ1œóë\ýŸÂ½^ ´$ÈFFå`ÈÆAÇZú"Š,„±5Ty´>w½øCx³•µŽäÇêî¤ÿ!ZÞøSsËGx¬‘KdûW¹QE§ˆ«5iJèó{ï„zUÕŒ°e׃‚oÖ¼âçàÝüsºF“ºÃn^Gå_GÑA0«8+EØñ};áö¡7ƒäðýýΧ’HeX`‘Hsì$¨98õ>áø9~&ÊÃpP8ä{à úNŠí¦ºœƒ¼•bMäjeuÛ·(¯<ñ/Á=š´Òižy‚W.2s´ t«è (!M­ømà½cÁºÔ²(›ì÷*«21R3ƒÓ9nýëÙ(¢6Þ¬ÿÙsane-backends-1.0.29/doc/umax/umax.BUGS0000666000000000000000000000051313615534521014353 00000000000000BUGS FROM UMAX BACKEND FOR SANE ------------------------------- If you think that something is a bug and not a feature, please mail: Oliver Rauch KNOWN BUGS: * pixel count in x-direction is sometimes wrong if xres > 600dpi (Vista S12) * first scan with Astra 2400S produces wrong colors sane-backends-1.0.29/doc/umax/sane-umax-scanner-clones-doc.html0000666000000000000000000002732013615534521021163 00000000000000 SANE-umax - UMAX scanner clones
SANE-logo
UMAX-logo

UMAX scanner clones





The sane-umax library implements a SANE backend that provides access to several scanners that are compatible to the UMAX-SCSI-protocoll!
Here is a list of the UMAX-compatible scanners:
UMAX compatible Linotype Hell scanners
Name
Vendor
SCSI-ID
Versions
UTA
ADF
B/W
Grays
Color
Bits/pixel
Resolution
Jade
LinoHell
Office
all
X
X
ok
ok
ok
1,8,24
600 x 1200*
Jade
LinoHell
JADE
all
X
X
ok
ok
ok
1,8,24
600 x 1200*
Jade2
LinoHell
Office2
all
X
 
ok
ok
ok
1,8,10,24,30
600 x 1200
Saphir
LinoHell
unknown
 
incl
 
 
 
 
1,8,10,24,30
600 x 1200
Saphir2
LinoHell
SAPHIR2
all
incl
 
ok
ok
ok
1,8,12,24,36
600 x 1200
Saphir Ultra
LinoHell
unknown
 
incl
 
 
 
 
1,8,12,24,36
600 x 1200
Saphir Ultra II
LinoHell
unknown
 
incl
 
 
 
 
1,8,14,24,42
1200 x 2400
Saphir HiRes
LinoHell
unknown
 
incl
 
 
 
 
1,8,14,24,42
1220 x 3048
3048 x 3048
Opal
LinoHell
unknown
 
incl
 
 
 
 
1,8,10,24,30
700 x 1400
Opal2
LinoHell
OPAL2
 
incl
 
ok
ok
ok
1,8,12,24,36
700 x 1400
Opal Ultra
LinoHell
unknown
 
incl
 
 
 
 
1,8,12,24,36
700 x 1400
1400 x 2800
Linoscan 1400
HDM
LS4H1S
?
X
 
ok
ok
ok
1,8,12,14,24,36,42
1200 x 2400

* Scanner is able to scan up to 1200 x 1200 dpi.

UTA = Umax Transparancy Adapter, ADF = Automatic Document Feeder
(X = supported by scanner, incl = is included)



Other UMAX compatible scanners
Name
Vendor
SCSI-ID
Versions
UTA
ADF
B/W
Gray
Color
Bits/pixel
Resolution
Vobis/Highscreen
Scanboostar Premium
LinoHell
Office2
all
X
 
ok
ok
ok
1,8,10,24,30
600 x 1200
Escom
Image Scanner 256
UMAX
UG80
all
--
 
ok
ok
--
1,8
300 x 300
Nikon AX-210
Nikon
AX-210
all(?)
X
X
ok
ok
ok
1,8,24
600 x 1200*
Genius Colorpage HR5
(normal and Pro)
KYE
ColorPage-HR5
all(?)
X
 
ok
ok
ok
1,8,10,24,30
600 x 1200
Epson Perfection 600
EPSON
Perfection600
all(2.3)
X
 
ok
ok
ok
1,8,10,24,30
600 x 1200
Escort Galleria 600S
ESCORT
Galleria 600S
all(1.6)
X
 
??
??
??
1,8,24
300 x 600

* Scanner is able to scan up to 1200 x 1200 dpi.

UTA = Umax Transparancy Adapter, ADF = Automatic Document Feeder
(X = supported by scanner, incl = is included)




This page has been changed on 1st. october 2004


Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-powerlook-doc.html0000666000000000000000000001752213615534521020275 00000000000000 SANE-umax - UMAX PowerLook scanners
SANE-logo
UMAX-logo

UMAX PowerLook scanners




UMAX scanners
 Power Look series:
Name
SCSI-ID
Versions
UTA
ADF
B/W
Gray
Color
Bits/pixel
Optical resolution
PowerLook
PS-2400X
?
X
 
ok
ok
ok
1,8,10,24,30
600 x 1200
PowerLook II
PL-II
?
UTA-II
 
ok
ok
ok
1,8,12,24,36
600 x 1200
Power Look III
PowerLook III
all (1.7)
UTA-III
 
ok
ok
ok
1,8,12,14,24,36,42
1200 x 2400
PowerLook 270
Color Filmscanner____1
?
incl
 
bad
bad
bad
1,8,14,24,42
2700 x 2700
PowerLook 270plus
unknown
?
incl
 
bad
bad
bad
1,8,14,24,42
2700 x 2700
PowerLook 1100
unknown
? *
incl
 
?
?
?
1,8,14,24,42
1200 x 2400
PowerLook 2000
PowerLook 2000
?
UTA-2000
 
?
?
?
1,8,12,24,36
1000 x 2000
PowerLook 2100XL
unknown
?
UTA-2100XL
 
?
?
?
1,8,14,24,42
800 x 1600
PowerLook 3000
PowerLook 3000
all (2.0)
incl
 
ok
ok
ok
1,8,14,24,42
1220 x 3048
3048 x 3048

* Powerlook 1100 is a firewire scanner: not tested

UTA = Umax Transparancy Adapter, ADF = Automatic Document Feeder
(X = supported by scanner, incl = is included)



This page has been changed on 16th. decemnber 2001

Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-parport-doc.html0000666000000000000000000000514413615534521017740 00000000000000 SANE-umax - UMAX parallel port scanners
SANE-logo
UMAX-logo

UMAX parallel port scanners





The sane-umax library implements a SANE backend that provides access to several UMAX-SCSI-scanners. Parallel- and USB- scanners are not supported!

But there is an experimental parallel port driver for UMAX scanners.
Don't ask me about that driver - I do not know anything about this driver!

Author: Oliver Rauch
sane-backends-1.0.29/doc/umax/sane-umax-standard-options-doc.html0000666000000000000000000001446713615534521021552 00000000000000 SANE-umax backend
SANE-logo
UMAX-logo

SANE-umax backend





This backend dynamically enabeles the options that are supported by the scanner in dependence of the scanning-mode and other options. Here is an example of the frontend XSane:


main-window


The options Gamma, brightness, contrast and negative in the main window come from xsane that calculates a gamma table using this values. These values are corelated to highlight, midlight and shadow sliders in the Histogram window.

Scan modes:

Mode Remark
Lineart 1 bit/pixel black/white mode
Halftone 1 bit/pixel dithered black/white mode
Grayscale 8 / 9 / 10 / 12 / 14 / 16 bits/pixel gray mode
Color 24 / 27 / 30 / 36 / 42 / 48 bits/pixel RGB mode

Scan sources:

Scan sources
Flatbed
Transparency adapter (UTA)
Automatic document feeder (ADF)

Standard options:

sane-umax-standard-options-screenshot


Standard options Remark
Analog gamma correction Define the value for analog gamma correction. *
Value between 1.0 and 2.0 .
(Analog gamma correction doesn't reduce the number of used colors)
Highlight Define the intensity that shall be considered white. *
Shadow Define the intensity that shall be considered black. *
Contrast Define the contrast of the image - only available in halftone-mode.
Brightness Define the brightness of the image - only available in halftone-mode.
Threshold Define the minimum intensity to get a white point- only available in lineart-mode.
Use custom gamma table Use free definable scanner internal digital gamma table.
If you enable this option, the gamma correction is done inside the scanner. If you have a scanner with more than 8/24 bits/pixel, the image is scanned with the maximum available bit depth. The gamma correction does transform the image form the internal bit depth to the selected output bit depth (see below).
The frontends do handle the usage of the gamma table different. If you use xsane, you should enable this option to use the maximum available bit depth (otherwise xsane does the conversion with the selected output bit depth).
(Side-effect: digital gamma correction may reduce the number of used colors -especally if the used bit depth is low.)
Quality calibration Use quality white calibration. *
Double optical resolution Use lens 2 on high end scanners, this reduces the scanwidth and increases the maximum scanresolution. *
Negative scan Inverts color intensity - for scanning negatives.
Bit depth Image depth in bits/sample the scanner sends to the computer, normally 8 in grayscale and color mode. Some scanners support more than 8bits/sample, but only few file formats support it. If your scanner supports more than 8bis/sample you already get an improvement if you set the bit detpth to 8 and enable the option use custom gamma table (see above) because the scanner internal gamma correction is done with the maximum available bit depth!!!
*** There is normally no reason to use more than 8 bits/sample! ***
Lamp warmup Enable extended lamp-warmup. *

* only available for some scanners


Author: Oliver Rauch
sane-backends-1.0.29/doc/sane-sceptre.man0000666000000000000000000001005113615534521015031 00000000000000.TH sane\-sceptre 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-sceptre .SH NAME sane\-sceptre \- SANE backend for SCEPTRE scanners .SH DESCRIPTION The .B sane\-sceptre library implements a SANE (Scanner Access Now Easy) backend that provides access to Sceptre flatbed scanners. This backend should be considered .B beta-quality software! Please report any strange behavior to the maintainer of the backend or to the SANE mailing list. .PP At present, only one scanner is known to work with this backend: .PP .RS .ft CR .nf Model Connection Type --------------------------- ------------------- Sceptre VividScan S1200 SCSI .fi .ft R .RE The make of this scanner is KINPO, so other scanners from that manufacturer may also work (eg. the S600). .SH OPTIONS The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage or xsane. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d sceptre .RE .TP .B Scan Mode .TP .B \-\-mode selects the basic mode of operation of the scanner valid choices are .I Lineart, Halftone, Gray and Color. The Lineart and Halftone mode are black and white only (1 bit). Gray will produce 256 levels of gray (8 bits). Color will produce a 24 bits color image. The scanner supports 30 bits internally but it only exports 24. .TP .B \-\-resolution selects the resolution for a scan. The scanner can do several resolutions between 50 and 1200. .TP .B \-\-halftone\-pattern selects the pattern mode that is used in Halftone mode. Valid options are 1, 2, 3 and 4. .TP .B \-\-gamma\-correction controls the scanner internal gamma correction. Valid options are "Default", "User defined", "High density printing" "Low density printing" and "High contrast printing". .TP .B \-\-custom\-gamma (color mode only) allows the user to specify a gamma table (see the next 3 parameters). .TP .B \-\-red\-gamma\-table (color mode only) can be used to download a user defined gamma table for the red channel. The table must be 256 bytes long. .TP .B \-\-green\-gamma\-table (color mode only) can be used to download a user defined gamma table for the green channel. The table must be 256 bytes long. .TP .B \-\-blue\-gamma\-table (color mode only) can be used to download a user defined gamma table for the blue channel. The table must be 256 bytes long. .TP .B \-\-threshold sets the threshold for black and white pixels in lineart mode. Possible values are from 0 (darker) to 255 (lighter). .TP .B \-\-preview requests a preview scan. The resolution used for that scan is 30 dpi and the scan area is the maximum allowed. The scan mode is user selected. The default is "no". .TP .B The geometry options .TP .B \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters by default. .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/sceptre.conf supports only one information: the device name to use (eg /dev/scanner). .SH FILES .TP .I @LIBDIR@/libsane\-sceptre.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-sceptre.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_SCEPTRE If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH LIMITATIONS .TP .B Resolutions The windows TWAIN driver can be set to any resolution between 50 to 1200 (excluding software interpolation). This backend cannot. Only a handful of resolution are available, although they should be numerous enough. .SH BUGS None known. .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1), sane(7) .SH AUTHOR .TP The package is actively maintained by Frank Zago. .I http://www.zago.net/sane/#sceptre sane-backends-1.0.29/doc/sane-net.man0000666000000000000000000001063613615534521014163 00000000000000.TH sane\-net 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-net .SH NAME sane\-net \- SANE network backend .SH DESCRIPTION The .B sane\-net library implements a SANE (Scanner Access Now Easy) backend that provides access to image acquisition devices through a network connection. This makes it possible to control devices attached to a remote host and also provides a means to grant users access to protected resources. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .IR host : device .RE .PP Where .I host is the name (or IP address) of the (remote) host and .I device is the name of the device on this host that should be addressed. If the device name does not contain a colon (:), then the entire string is treated as the .I device string for the default host. The default host is the host listed last in the configuration file (see below). .PP An IPv6 address can be specified enclosed in square brackets: .PP .RS .IR [::1] : device .RE .SH CONFIGURATION The .IR net.conf file contains both backend options and a list of host names (or IP addresses) that should be contacted for scan requests. Anything that isn't one of the options listed below will be treated as an host name. .PP .TP .B connect_timeout = nsecs Timeout (in seconds) for the initial connection to the .I saned server. This will prevent the backend from blocking for several minutes trying to connect to an unresponsive .I saned host (network outage, host down, ...). The environment variable .B SANE_NET_TIMEOUT can also be used to specify the timeout at runtime. .PP Empty lines and lines starting with a hash mark (#) are ignored. Note that IPv6 addresses in this file do not need to be enclosed in square brackets. A sample configuration file is shown below: .PP .RS scan\-server.somedomain.firm .br 192.168.0.1 .br # this is a comment .br localhost .br ::1 .RE .PP The above list of hosts can be extended at run-time using environment variable .BR SANE_NET_HOSTS . This environment variable is a colon-separated list of hostnames or IP addresses that should be contacted in addition to the hosts mentioned in the configuration file. For example, a user could set the environment variable to the string: .PP .RS new.scanner.com:[::1]:192.168.0.2:scanner.univ.edu .RE .PP To request that hosts .I new.scanner.com , .I [::1] , .I 192.168.0.2 and .I scanner.univ.edu are contacted in addition to the hosts listed above. .PP For this backend to function properly, it is also necessary to define the .B sane\-port service in .IR /etc/services . The .B sane service should be defined using a line of the following form: .PP .RS sane\-port 6566/tcp # SANE network scanner daemon .RE .PP .SH FILES .TP .I @CONFIGDIR@/net.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-net.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-net.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_NET_HOSTS A colon-separated list of host names or IP addresses to be contacted by this backend. .TP .B SANE_NET_TIMEOUT Number of seconds to wait for a response from the .I saned server for the initial connection request. .TP .B SANE_DEBUG_NET If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH BUGS If saned has timed out, the net backend may loop with authorization requests. .SH "SEE ALSO" sane(7), saned(8), sane\-dll(5), scanimage(1) .I http://www.penguin-breeder.org/?page=sane\-net .SH AUTHOR David Mosberger and Andreas Beck sane-backends-1.0.29/doc/sane-microtek2.man0000666000000000000000000002352113615534521015271 00000000000000.TH sane\-microtek2 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .SH NAME sane\-microtek2 \- SANE backend for Microtek scanners with SCSI-2 command set .SH DESCRIPTION The .B sane\-microtek2 library implements a SANE (Scanner Access Now Easy) backend that provides access to Microtek scanners with a SCSI-2 command set. This backend can be considered alpha to beta. Some scanner models are reported to work well, others not. New development versions of this backend can be obtained from .B http://karstenfestag.gmxhome.de .PP There exists a different backend for Microtek scanners with SCSI-1 command set. Refer to sane\-microtek(5) for details. .PP And there is work in progress for the ScanMaker 3600. See .B http://sourceforge.net/projects/sm3600 .PP At present, the following scanners are known positively to work with this backend: .PP .ft CR .nf Vendor Product id Remark -------------------------------------------------------------------- Microtek E3+ Parport and SCSI Microtek X6 SCSI Microtek X6EL SCSI Microtek X6USB USB Microtek ScanMaker V300 Parport and SCSI Microtek ScanMaker V310 Parport and SCSI Microtek ScanMaker V600 Parport and SCSI Microtek ScanMaker 330 SCSI Microtek ScanMaker 630 SCSI Microtek ScanMaker 636 SCSI Microtek ScanMaker 9600XL SCSI; only flatbed mode? Microtek Phantom 330CX Parport Microtek SlimScan C3 Parport Microtek SlimScan C6 USB Microtek Phantom 636 SCSI Microtek Phantom 636CX Parport Microtek V6USL SCSI and USB Microtek V6UPL USB; not stable Microtek X12USL SCSI; only 8bit color, work in progress Vobis HighScan SCSI (E3+ based models) Scanport SQ300 Parport? Scanport SQ4836 SCSI Scanpaq SQ2030 Parport .fi .ft R .PP Additional information can be found at .BR http://www.sane\-project.org/ . .PP If you own a Microtek scanner other than the ones listed above, it may or may not work with SANE! Because equal scanners are sold under different names in different countries your model may be equivalent to one of the above. .PP The parport scanners work with the ppscsi + onscsi kernel modules. See .I http://cyberelk.net/tim/parport/ppscsi.html and .IR http://penguin-breeder.org/kernel/download/ . .PP The USB scanners work with the microtek kernel module. You may have to add the vendor and model codes to microtek.c if they aren't yet listed there. .PP Both parport and USB scanners need the generic SCSI support, so check if you have loaded the scsi_mod and sg modules! .PP If you try your scanner for the first time keep an eye on it. If it gets commands that it doesn't understand the scanhead may go beyond the scan area. The scanner then makes strange noises. In this case immediately switch off the scanner or disconnect its power cable to prevent damages! .PP If your scanner is a different one than the models mentioned above and it is working please tell the author about it. It would be nice if you add a logfile to this information (creation of the logfile: see below). .PP If your scanner is not working properly you also should create a logfile and send it to the author. He will use the information to improve the backend and possibly make your scanner work. .PP .br How to create the logfile? .TP \- put the line .br "option dump 2" into your .I microtek2.conf file or change the existing "option dump" to "2" .TP \- in a terminal (bash) type .br "export SANE_DEBUG_MICROTEK2=30" and then .br "scanimage \-l0 \-t0 \-x100 \-y20 2>scan.log >sout.pnm" .br You get two files: scan.log contains the logfile and sout.pnm the scanned image (if there was scanned something). Zip them before sending. .SH "FRONTEND OPTIONS" This backend dynamically enables the options for the frontend, that are supported by the scanner in dependence of the scanning-mode and other options. Not supported options are disabled. .PP The following options are supported by the Microtek2-driver: .PP Color, grayscale, halftone and lineart scans. .PP Highlight, midtone, shadow, contrast, brightness, exposure time control, gamma correction, threshold (dependent of the scan mode and the scanner capabilities) .PP Transparency media adapter, automatic document feeder .PP Additional options can be enabled or disabled in the .I microtek2.conf file. See the configuration section of this manpage. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the UNIX path-name for the special device that corresponds to the scanner. The special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .I /dev/sge for example. .SH "CONFIGURATION" The configuration file for this backend resides in .IR @CONFIGDIR@/microtek2.conf . Its contents is a list of device names that correspond to Microtek scanners with SCSI-2 interface. Empty lines and lines starting with a hash mark (#) are ignored. .PP The configuration file may also contain options. Global options that are valid for all devices are placed above the device names. Device-specific options are placed under the device name. Note that, except for option dump and option strip-height , the entry in the microtek2.conf file only enables the corresponding option for being showed in the frontend. There, in the frontend, you can switch the options on and off. Currently the following options are supported: .PP .RS option dump .br option strip\-height .br option no\-backtrack\-option .br option lightlid\-35 .br option toggle\-lamp .br option lineart\-autoadjust .br option backend\-calibration .br option colorbalance\-adjust .RE .PP .I option dump enables printing of additional information about the SCSI commands that are sent to the scanner to stderr. This option is primarily useful for debugging purpose. This option has to be a global option and is best placed at the top of the .I microtek2.conf file. .PP If n=1 the contents of the command blocks and the results for the INQUIRY and READ SCANNER ATTRIBUTES command are printed to stderr. .PP If n=2 the contents of the command blocks for all other SCSI commands are printed to stderr, too. If n=3 the contents of the gamma table is printed, too. If n=4 all scan data is additionally printed to stderr. .PP The default is n=1. .PP .I option strip\-height , where is a floating point number, limits the amount of data that is read from the scanner with one read command. The unit is inch and defaults to 1.0, if this option is not set in the configuration file. If less than inch of data fit into the SCSI buffer, then the smaller value is used and this option has no effect. .PP If your system has a big SCSI buffer and you want to make use of the whole buffer, increase the value for . For example, if is set to 14.0, no restrictions apply for scanners with a letter, legal or A4 sized scan area. .PP .PP The following options enable or disable additional frontend options. If an option is set to an appropriate option will appear in the frontend. .PP .I option no\-backtrack\-option prevents the scanner head from moving backwards between the read commands. This speeds up scanning. Try it. .PP .I option lightlid\-35 If you use the LightLid-35 transparency adapter you get an advanced option which switches off the flatbed lamp during the scan. .PP .I option toggle\-lamp You get a button in the frontend where you can switch on and off the flatbed lamp. .PP .I option lineart\-autoadjust You can tell the backend to try to determine a good value for the lineart threshold. .PP .I option backend\-calibration Some scanners (e.g. Phantom 330CX and 636CX) need to have calibrated the data by the backend. Try this option if you see vertical stripes in your pictures. .PP .I option colorbalance\-adjust Some scanners (e.g. Phantom 330CX and 636CX) need to have corrected the color balance. If this option is enabled you get advanced options where you can balance the colors. And you will have a button to use the values that the firmware of the scanner provides. .PP A sample configuration file is shown below: .PP .RS option dump 1 .br option strip\-height 1.0 .br /dev/scanner .br option no\-backtrack\-option on .br # this is a comment .br /dev/sge .br option lightlid\-35 on .RE This backend also supports the new configuration file format which makes it easier to detect scanners under Linux. If you have only one scanner it would be best to use the following configuration file for this backend: .PP .RS option dump 1 .br option strip\-height 14.0 .br option no\-backtrack\-option on .br option backend\-calibration on .br option lightlid\-35 on .br option toggle\-lamp on .br option lineart\-autoadjust on .br option colorbalance\-adjust off .br scsi * * Scanner .RE In this case all SCSI-Scanners should be detected automatically because of the .PP scsi * * Scanner .PP line. .SH "FILES" .TP .I @CONFIGDIR@/microtek2.conf The backend configuration file. .TP .I @LIBDIR@/libsane\-microtek2.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-microtek2.so The shared library implementing this backend (present on systems that support dynamic loading). .SH "ENVIRONMENT" .TP .B SANE_DEBUG_MICROTEK2 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 255 requests all debug output to be printed. Smaller levels reduce verbosity. To see error messages on stderr set SANE_DEBUG_MICROTEK2 to 1 (Remark: The whole debugging levels should be better revised). .br E.g. just say: .br export SANE_DEBUG_MICROTEK2=128 .SH "SEE ALSO" sane\-scsi(5), sane(7) .SH "AUTHORS" Bernd Schroeder (not active anymore) .br Karsten Festag karsten.festag@gmx.de sane-backends-1.0.29/doc/sane-bh.man0000666000000000000000000004552713615534521013775 00000000000000.TH sane\-bh 5 "10 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-bh .SH NAME sane\-bh \- SANE backend for Bell+Howell Copiscan II series document scanners .SH DESCRIPTION The .B sane\-bh library implements a SANE (Scanner Access Now Easy) backend that provides access to Bell+Howell Copiscan II series document scanners. The Copiscan II 6338 has been the primary scanner model used during development and testing, but since the programming interface for the entire series is consistent the backend should work for the following scanner models. .PP .RS COPISCAN II 6338 Duplex Scanner with ACE .br COPISCAN II 2135 Simplex Scanner .br COPISCAN II 2137(A) Simplex Scanner (with ACE) .br COPISCAN II 2138A Simplex Scanner with ACE .br COPISCAN II 3238 Simplex Scanner .br COPISCAN II 3338(A) Simplex Scanner (with ACE) .br .RE .PP If you have a Bell+Howell scanner and are able to test it with this backend, please contact .IR sane\-devel@alioth-lists.debian.net with the model number and testing results. Have a look at http://www.sane\-project.org/mailing\-lists.html concerning subscription to sane\-devel. Additionally, the author is curious as to the likelihood of using this backend with the newer 4000 and 8000 series scanners. If you have such a beast, please let me know. .PP The Bell+Howell Copiscan II series document scanners are high volume, high throughput scanners designed for document scanning applications. As such, they are lineart/grayscale scanners supporting a fixed number of fairly low resolutions (e.g. 200/240/300dpi). However, they do have a number of interesting and useful features suited to needs of document imaging applications. This backend attempts to support as many of these features as possible. .PP The main technical reference used in writing this backend is the .B Bell and Howell Copiscan II Remote SCSI Controller (RSC) OEM .B Technical Manual Version 1.5. The Linux SCSI programming HOWTO, the SANE API documentation, and SANE source code were also extremely valuable resources. .PP The latest backend release, additional information and helpful hints are available from the backend homepage: .br .RS .B http://www.martoneconsulting.com/sane\-bh.html .RE .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the path-name for the special device that corresponds to a SCSI scanner. For SCSI scanners, the special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name takes a format such as .I /dev/sga or .IR /dev/sg0 , for example. See sane\-scsi(5) for details. .SH CONFIGURATION The contents of the .I bh.conf file is a list of device names that correspond to Bell+Howell scanners. See sane\-scsi(5) on details of what constitutes a valid device name. Additionally, options can be specified; these lines begin with the word "option". Each option is described in detail below. Empty lines and lines starting with a hash mark (#) are ignored. .SH OPTIONS The following options can be specified in the .I bh.conf file. .TP .B disable\-optional\-frames This option prevents the backend from sending any optional frames. This option may be useful when dealing with frontends which do not support these optional frames. When this option is in effect, the data is sent in a SANE_FRAME_GRAY frame. The optional frames sent by this backend are: SANE_FRAME_G31D, SANE_FRAME_G32D, SANE_FRAME_G42D and SANE_FRAME_TEXT. These frames are generated based on the compression and barcode options. These frames are never sent in preview mode. .TP .B fake\-inquiry This option is used for debugging purposes and its use is not encouraged. Essentially, it allows the backend to initialize in the absence of a scanner. This is useful for development and not much else. This option must be specified earlier in the configuration file than the devices which are to be "faked". .SH FILES .TP .I @CONFIGDIR@/bh.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-bh.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-bh.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_BH If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 255 requests all debug output to be printed. Smaller levels reduce verbosity. .SH "SUPPORTED FEATURES" .TP .B ADF support With document scanners, automatic document feeder (ADF) support is a key feature. The backend supports the ADF by default and returns .B SANE_STATUS_NO_DOCS when the out-of-paper condition is detected. The SANE frontend .B scanadf is a command line frontend that supports multi-page scans. It has been used successfully with this backend. The SANE frontend .B xsane is an improved GUI frontend by Oliver Rauch. Support for multi-page scans is included in xsane version 0.35 and above. .TP .B Duplex scanning Some models, such as the COPISCAN II 6338, support duplex scanning. That is, they scan both sides of the document during a single pass through the scanner (the scanner has two cameras). This backend supports duplex scanning (with the .B \-\-duplex option). The front and back page images are delivered consecutively as if they were separately scanned pages. .TP .B Hardware compression The scanner is capable of compressing the data into several industry standard formats (CCITT G3, CCITT G3-2D, CCITT G4). This results in increased performance as less data is passed from the scanner to the host over the SCSI bus. The backend supports these compression formats via the .B \-\-g31d, \-\-g32d, \-\-g42d options, respectively. Many SANE frontends are not equipped to deal with these formats, however. The SANE frontend .B scanadf supports these optional frame formats. The compressed image data is written directly to a file and can then be processed by a scan-script using the .B \-\-scan\-script option. Examples of this are given on the scanadf homepage. .TP .B Automatic Border Detection The scanner can automatically detect the paper size and adjust the scanning window geometry appropriately. The backend supports this useful feature with the .B \-\-autoborder option. It is enabled by default. .TP .B Batch Mode Scanning The batch scan mode allows for maximum throughput. The Set Window parameters must remain constant during the entire batch. .TP .B Icon Generation The Icon function generates a thumbnail of the full page image, that can be transferred as if it were a separate page. This allows the host to quickly display a thumbnail representation during the scanning operation. Perhaps this would be a great way of implementing a preview scan, but since a normal scan is so quick, it might not be worth the trouble. .TP .B Multiple Sections Multiple sections (scanning sub-windows) can be defined for the front and back pages. Each section can have different characteristics (e.g. geometry, compression). The sections are returned as if they were separately scanned images. Additionally sections can be used to greatly enhance the accuracy and efficiency of the barcode/patchcode decoding process by limiting the search area to a small subset of the page. Most Copiscan II series scanners support up to 8 user-defined sections. .TP .B Support Barcode/Patchcode Decoding The RSC unit can recognize Bar and Patch Codes of various types embedded in the scanned image. The codes are decoded and the data is returned to the frontend as a text frame. The text is encoded in xml and contains a great deal of information about the decoded data such as the location where it was found, its orientation, and the time it took to find. Further information on the content of this text frame as well as some barcode decoding examples can be found on the backend homepage. .SH LIMITATIONS .TP .B Decoding a single barcode type per scan The RSC unit can search for up to six different barcode types at a time. While the code generally supports this as well, the .B \-\-barcode\-search\-bar option only allows the user to specify a single barcode type. Perhaps another option which allows a comma separated list of barcode type codes could be added to address this. .TP .B Scanning a fixed number of pages in batch mode The separation of front and back end functionality in SANE presents a problem in supporting the 'cancel batch' functionality in the scanner. In batch mode, the scanner is always a page ahead of the host. The host, knowing ahead of time which page will be the last, can cancel batch mode prior to initiating the last scan command. Currently, there is no mechanism available for the frontend to pass this knowledge to the backend. If batch mode is enabled and the \-\-end\-count terminates a scanadf session, an extra page will be pulled through the scanner, but is neither read nor delivered to the frontend. The issue can be avoided by specifying \-\-batch=no when scanning a fixed number of pages. .TP .B Revision 1.2 Patch detector There is an enhanced patchcode detection algorithm available in the RSC with revision 1.2 or higher that is faster and more reliable than the standard Bar/Patch code decoder. This is not currently supported. .SH OPTIONS .TP .B Scan Mode Options: .TP .B \-\-preview[=(yes|no)] [no] Request a preview-quality scan. When preview is set to yes image compression is disabled and the image is delivered in a SANE_FRAME_GRAY frame. .TP .B \-\-mode lineart|halftone [lineart] Selects the scan mode (e.g., lineart,monochrome, or color). .TP .B \-\-resolution 200|240|300dpi [200] Sets the resolution of the scanned image. Each scanner model supports a list of standard resolutions; only these resolutions can be used. .TP .B \-\-compression none|g31d|g32d|g42d [none] Sets the compression mode of the scanner. Determines the type of data returned from the scanner. Values are: .RS .br .B none \- uncompressed data \- delivered in a SANE_FRAME_GRAY frame .br .B g31d \- CCITT G3 1 dimension (MH) \- delivered in a SANE_FRAME_G31D frame .br .B g32d \- CCITT G3 2 dimensions (MR, K=4) \- delivered in a SANE_FRAME_G32D frame .br .B g42d \- CCITT G4 (MMR) \- delivered in a SANE_FRAME_G42D frame .br NOTE: The use of g31d, g32d, and g42d compression values causes the backend to generate optional frame formats which may not be supported by all SANE frontends. .RE .TP .B Geometry Options: .TP .B \-\-autoborder[=(yes|no)] [yes] Enable/Disable automatic image border detection. When enabled, the RSC unit automatically detects the image area and sets the window geometry to match. .TP .B \-\-paper\-size Custom|Letter|Legal|A3|A4|A5|A6|B4|B5 [Custom] Specify the scan window geometry by specifying the paper size of the documents to be scanned. .TP .B \-\-tl\-x 0..297.18mm [0] Top-left x position of scan area. .TP .B \-\-tl\-y 0..431.8mm [0] Top-left y position of scan area. .TP .B \-\-br\-x 0..297.18mm [297.18] Bottom-right x position of scan area. .TP .B \-\-br\-y 0..431.8mm [431.8] Bottom-right y position of scan area. .TP .B Feeder Options: .TP .B \-\-source Automatic Document Feeder|Manual Feed Tray [Automatic Document Feeder] Selects the scan source (such as a document feeder). This option is provided to allow multiple image scans with xsane; it has no other purpose. .TP .B \-\-batch[=(yes|no)] [no] Enable/disable batch mode scanning. Batch mode allows scanning at maximum throughput by buffering within the RSC unit. This option is recommended when performing multiple pages scans until the feeder is emptied. .TP .B \-\-duplex[=(yes|no)] [no] Enable duplex (dual-sided) scanning. The scanner takes an image of each side of the document during a single pass through the scanner. The front page is delivered followed by the back page. Most options, such as compression, affect both the front and back pages. .TP .B \-\-timeout\-adf 0..255 [0] Sets the timeout in seconds for the automatic document feeder (ADF). The value 0 specifies the hardware default value which varies based on the scanner model. .TP .B \-\-timeout\-manual 0..255 [0] Sets the timeout in seconds for semi-automatic feeder. The value 0 specifies the hardware default value which varies based on the scanner model. .TP .B \-\-check\-adf[=(yes|no)] [no] Check ADF Status prior to starting scan using the OBJECT POSITION command. Note that this feature requires RSC firmware level 1.5 or higher and dip switch 4 must be in the on position. NOTE: This option has not been tested extensively and may produce undesirable results. .TP .B Enhancement: .TP .B \-\-control\-panel[=(yes|no)] [yes] Enables the scanner's control panel for selecting image enhancement parameters. When the option is set to no the following options are used to control image enhancement. See the Bell+Howell scanner users' guide for complete information on ACE functionality. .TP .B \-\-ace\-function \-4..4 [3] Specify the Automatic Contrast Enhancement (ACE) Function. .TP .B \-\-ace\-sensitivity 0..9 [5] Specify the Automatic Contrast Enhancement (ACE) Sensitivity. .TP .B \-\-brightness 0..255 [0] Controls the brightness of the acquired image. Ignored for ACE capable scanners. .TP .B \-\-threshold 0..255 [0] Select minimum-brightness to get a white point. Ignored for ACE capable scanners. .TP .B \-\-contrast 0..255 [inactive] Controls the contrast of the acquired image. This option is not currently used by the scanner (and perhaps never will be). .TP .B \-\-negative[=(yes|no)] [no] Swap black and white, yielding a reverse-video image. .TP .B Icon: .TP .B \-\-icon\-width 0..3600pel (in steps of 8) [0] Width of icon (thumbnail) image in pixels. .TP .B \-\-icon\-length 0..3600pel (in steps of 8) [0] Length of icon (thumbnail) image in pixels. .TP .B Barcode Options: .TP .B \-\-barcode\-search\-bar [none] Specifies the barcode type to search for. If this option is not specified, or specified with a value of none, then the barcode decoding feature is completely disabled. The valid barcode type are: .RS .br .B none .br .B ean\-8 .br .B ean\-13 .br .B reserved\-ean\-add .br .B code39 .br .B code2\-5\-interleaved .br .B code2\-5\-3lines\-matrix .br .B code2\-5\-3lines\-datalogic .br .B code2\-5\-5lines\-industrial .br .B patchcode .br .B codabar .br .B codabar\-with\-start\-stop .br .B code39ascii .br .B code128 .br .B code2\-5\-5lines\-iata .br .RE .TP .B \-\-barcode\-search\-count 1..7 [3] Number of times that the RSC performs the decoding algorithm. Specify the smallest number possible to increase performance. If you are having trouble recognizing barcodes, it is suggested that you increase this option to its maximum value (7). .TP .B \-\-barcode\-search\-mode [horiz\-vert] Chooses the orientation of barcodes to be searched. The valid orientations are: .RS .br .B horiz\-vert .br .B horizontal .br .B vertical .br .B vert\-horiz .RE .TP .B \-\-barcode\-hmin 0..1660mm [5] Sets the barcode minimum height in millimeters (larger values increase recognition speed). Of course the actual barcodes in the document must be of sufficient size. .TP .B \-\-barcode\-search\-timeout 20..65535us [10000] Sets the timeout for barcode searching in milliseconds. When the timeout expires, the decoder will stop trying to decode barcodes. .TP .B \-\-section [] Specifies a series of image sections. A section can be used to gather a subset image or to provide a small area for barcode decoding. Each section is specified in the following format (units are in millimeters): .PP .B x++[:functioncode...] .PP Multiple sections can be specified by separating them with commas. .PP For example .B 76.2x25.4+50.8+0:frontbar identifies an area 3 inches wide and 1 inch high with a top left corner at the top of the page two inches from the left hand edge of the page. This section will be used for barcode decoding on the front page only. .PP For example .B 50.8x25.4+25.4+0:frontbar:front:g42d identifies an area 2 inches wide and 1 inch high with a top left corner at the top of the page one inch from the left hand edge of the page. This section will be used for barcode decoding on the front page as well as generating an image compressed in g42d format. .PP Ordinarily barcodes are searched in the entire image. However, when you specify sections all barcode searching is done within the specific sections identified. This can significantly speed up the decoding process. The following functioncodes are available: .RS .br .B front \- generate an image for the front page section .br .B back \- generate an image for the back page section .br .B frontbar \- perform barcode search in front page section .br .B backbar \- perform barcode search in back page section .br .B frontpatch \- perform patchcode search in front page section .br .B backpatch \- perform patchcode search in back page section .br .B none \- use no image compression .br .B g31d \- use Group 3 1 dimension image compression .br .B g32d \- use Group 3 2 dimensions image compression .br .B g42d \- use Group 4 2 dimensions image compression .br .RE .PP If you omit a compression functioncode, the full page compression setting is used. If you specify multiple compression functioncodes, only the last one is used. .TP .B \-\-barcode\-relmax 0..255 [0] Specifies the maximum relation from the widest to the smallest bar. .TP .B \-\-barcode\-barmin 0..255 [0] Specifies the minimum number of bars in Bar/Patch code. .TP .B \-\-barcode\-barmax 0..255 [0] Specifies the maximum number of bars in a Bar/Patch code. .TP .B \-\-barcode\-contrast 0..6 [3] Specifies the image contrast used in decoding. Use higher values when there are more white pixels in the code. .TP .B \-\-barcode\-patchmode 0..1 [0] Controls Patch Code detection. .SH BUGS This is a new backend; detailed bug reports are welcome -- and expected ;) .PP If you have found something that you think is a bug, please attempt to recreate it with the SANE_DEBUG_BH environment variable set to 255, and send a report detailing the conditions surrounding the bug to .IR sane\-devel@alioth-lists.debian.net . .SH "SEE ALSO" sane(7), sane\-scsi(5), scanimage(1), scanadf(1) .SH AUTHOR The sane\-bh backend was written by Tom Martone, based on the sane\-ricoh backend by Feico W. Dillema and the bnhscan program by Sean Reifschneider of tummy.com ltd. Some 8000 enhancements added by Mark Temple. sane-backends-1.0.29/doc/sane-teco3.man0000666000000000000000000000771013615534521014411 00000000000000.TH sane\-teco3 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-teco3 .SH NAME sane\-teco3 \- SANE backend for TECO / RELISYS scanners .SH DESCRIPTION The .B sane\-teco3 library implements a SANE (Scanner Access Now Easy) backend that provides access to some TECO SCSI flatbed scanners. This backend should be considered .B alpha-quality software! TECO scanners are sold under various brands like RELYSIS, PIOTECH, TRUST. This backend may or may not support yours. .PP The scanners that should work with this backend are: .PP .RS .ft CR .nf Vendor Model TECO model status --------------------------- ---------- ---------- Relisys Scorpio VM3552 tested Plustek OpticPro 2400SP VM3552 untested PIOTECH Splendeur 3024 VM3552 tested Trust Imagery 2400 SP VM3552 tested Trust Imagery 4800 SP+ VM3552 tested Trust Imagery 9600 SP VM3552 untested .fi .ft R .RE The TECO VM number can usually be found at the back of the scanner. It is also part of the FCC ID. The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage or xsane. .br If you have any success with a scanner not listed here, or if you have any strange behavior, please report to the backend maintainer or to the SANE mailing list. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d teco3 .RE .TP .B Scan Mode .TP .B \-\-mode selects the basic mode of operation of the scanner valid choices are .I Black & White , .I Grayscale and .I Color The Black & White mode is black and white only (1 bit). Grayscale will produce 256 levels of gray (8 bits). Color will produce a 24 bits color image. .TP .B \-\-resolution selects the resolution for a scan. The scanner can do all resolutions between 1 and 1200, in increments of 1. .TP .B Geometry options .TP .B \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters by default. .TP .B Enhancement options .TP .B \-\-custom\-gamma (color mode only) allows the user to specify a gamma table (see the next 3 parameters). .TP .B \-\-red\-gamma\-table (color mode only) can be used to download a user defined gamma table for the red channel. The table must be 1024 bytes long. .TP .B \-\-green\-gamma\-table (color mode only) can be used to download a user defined gamma table for the green channel. The table must be 1024 bytes long. .TP .B \-\-blue\-gamma\-table (color mode only) can be used to download a user defined gamma table for the blue channel. The table must be 1024 bytes long. .TP .B \-\-preview requests a preview scan. The resolution used for that scan is 22 dpi and the scan area is the maximum allowed. The scan mode is user selected. The default is "no". .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/teco3.conf supports only one information: the device name to use (eg /dev/scanner). .SH FILES .TP .I @LIBDIR@/libsane\-teco3.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-teco3.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_TECO3 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH LIMITATIONS The windows TWAIN driver has many more options than this SANE backend. However they are only software adjustments. This backend only implements what the scanner can support. .SH BUGS Not much. .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1), sane(7) .SH AUTHOR .TP The package is actively maintained by Frank Zago. .I http://www.zago.net/sane/#teco3 sane-backends-1.0.29/doc/sane-u12.man0000666000000000000000000001122513615534521013777 00000000000000.TH sane\-u12 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-u12 .SH NAME sane\-u12 \- SANE backend for Plustek USB flatbed scanners, based on older parport designs .SH DESCRIPTION The .B sane\-u12 library implements a SANE (Scanner Access Now Easy) backend that provides access to USB flatbed scanners based on Plusteks' ASIC 98003 (parallel-port ASIC) and a GeneSys Logics' USB-parport bridge chip. .SH "SUPPORTED DEVICES" The backend is able to support some early Plustek USB scanner based their old parport design around the ASIC 98003 and other rebadged Plustek devices. The following tables will give you a short overview. If your Plustek scanner has another Product ID, then the device is .B NOT supported by this backend. .br Vendor Plustek \- ID: 0x07B3 .br .ft CR .nf ---------------------------------------------------------- Model: Vendor-ID: Product-ID: ---------------------------------------------------------- OpticPro U12 0x07B3 0x0001 OpticPro U1212 0x07B3 0x0001 OpticPro UT12 0x07B3 0x0001 .fi .ft R .PP Vendor KYE/Genius .br .ft CR .nf -------------------------------------------------------- USB Model: Vendor-ID: Product-ID: -------------------------------------------------------- ColorPage Vivid III USB 0x07B3 0x0001 ColorPage HR6 V1 0x0458 0x2004 .fi .ft R .PP .SH "CONFIGURATION" To use your scanner with this backend, you need at least two entries in the configuration file .I @CONFIGDIR@/u12.conf .RS .I [usb] vendor-id product-id .br .I device /dev/usbscanner .RE .PP .I [usb] tells the backend, that the following devicename (here .IR /dev/usbscanner ) has to be interpreted as USB scanner device. If vendor- and product-id has not been specified, the backend tries to detect this by its own. If device is set to .I auto then the next matching device is used. .PP .B The Options: .PP option warmup t .RS .I t specifies the warmup period in seconds .RE .PP option lampOff t .RS .I t is the time in seconds for switching off the lamps in standby mode .RE .PP option lOffonEnd b .RS .I b specifies the behaviour when closing the backend, 1 --> switch lamps off, 0 --> do not change lamp status .RE .PP See the u12.conf file for examples. .PP .B Note: .br You have to make sure, that the USB subsystem is loaded correctly and you have access to the device-node. For more details see .B sane\-usb (5) manpage. You might use .B sane\-find\-scanner to check that you have access to your device. .PP .B Note: .br If there's no configuration file, the backend defaults to .B device auto .SH FILES .TP .I @CONFIGDIR@/u12.conf The backend configuration file .TP .I @LIBDIR@/libsane\-u12.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-u12.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_U12 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_U12=10 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .BR sane\-plustek (5), .br .I @DOCDIR@/u12/U12.changes .SH "CONTACT AND BUG-REPORTS" Please send any information and bug-reports to: .br .B SANE Mailing List .PP Additional info and hints can be obtained from our .br Mailing-List archive at: .br .B http://www.sane\-project.org/mailing\-lists.html .PP To obtain debug messages from the backend, please set the environment-variable .I SANE_DEBUG_U12 before calling your favorite scan-frontend (i.e. xscanimage). .br .B i.e.: export SANE_DEBUG_U12=20 ; xscanimage .PP The value controls the verbosity of the backend. .SH "KNOWN BUGS & RESTRICTIONS" * The driver is in alpha state, so please don't expect too much!!! .PP * When using libusb, it might be, that the backend hangs. In that case, reconnect the scanner. sane-backends-1.0.29/doc/sane-hs2p.man0000666000000000000000000001067513615534521014254 00000000000000.TH sane\-hs2p 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-hs2p .SH NAME sane\-hs2p \- SANE backend for Ricoh SCSI flatbed/ADF scanners .SH DESCRIPTION The .B sane\-hs2p library implements a SANE (Scanner Access Now Easy) backend that provides access to the Ricoh IS450 family of scanners. Should also work with the IS420, IS410, and IS430 scanners, but these are untested. Please contact the maintainer or the sane\-devel mailing list if you own such a scanner. .PP This backend is alpha-quality. It may have bugs and some scanners haven't been tested at all. Be careful and pull the plug if the scanner causes unusual noise. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is either the path-name for the special device that corresponds to a SCSI scanner. The program .I sane\-find\-scanner helps to find out the correct device. Under Linux, such a device name could be .I /dev/sg0 or .IR /dev/sga , for example. See .BR sane\-scsi (5) for details. .SH CONFIGURATION The contents of the .I hs2p.conf file is a list of device names that correspond to SCSI scanners. Empty lines and lines starting with a hash mark (#) are ignored. See .BR sane\-scsi (5) on details of what constitutes a valid device name. .SH FILES .TP .I @CONFIGDIR@/hs2p.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-hs2p.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-hs2p.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_HS2P If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. A value of 255 prints all debug output. Smaller values reduce verbosity. .SH CURRENT STATUS The hs2p backend is now in version 1.00. All major scanning-related features are supported, except for those features requiring the optional IPU. Scanning from the flatbed or ADF (either simplex or duplex) is supported. Lineart, halftone, 4-bit gray, and 8-bit gray are supported. Pre-set gamma tables and halftone patterns are supported, as well as brightness, threshold, contrast. Also supported is scan wait mode, binary and gray filtering, negative scanning, and absolute or relative white setting. Printing with the optional endorser also is supported. .SH PLANNED FUNCTIONALITY This scanner can scan from the ADF in continuous simplex mode. Surprisingly, many scanners scan an entire document from the ADF into memory before ejecting the sheet. Thus if the document is too long, the scanner cannot hold the entire image data in memory. But if the scanner would send its image data when its memory got full, and then read the next buffer's worth of data, continuous scanning could be achieved. .SH MISSING FUNCTIONALITY The SCSI commands for uploading (2AH) or downloading (28H) custom halftone patterns (02H) and gamma vectors (03H) should work, but require implementing the SANE Option-Value code to allow the user to create the tables to be uploaded to the scanner. No support for Maintenance Data (80H) is planned as this functionality is more suited to a stand-alone utility to be used by a technician when replacing the lamp or ADF unit. Nor is support for reading or changing IPU (93H) parameters and adjustments planned, since my IS450 lacks such a unit. The 31-byte Auto Photo/Letter struct and 21-byte Dynamic threshold struct are documented in the hs2p-scsi.h file should someone wish to use their IPU for image data processing. .SH "SEE ALSO" .BR sane (7), .BR sane\-find\-scanner (1), .BR sane\-scsi (5), .SH AUTHOR jeremy .br Maintained by Jeremy Johnson sane-backends-1.0.29/doc/sane-epson2.man0000666000000000000000000003130613615534521014600 00000000000000.TH sane\-epson2 5 "22 Jan 2009" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-epson2 .SH NAME sane\-epson2 \- SANE backend for EPSON scanners .SH DESCRIPTION The .B sane\-epson2 library implements a SANE (Scanner Access Now Easy) backend that provides access to Epson flatbed scanners. This library supports a similar set of scanners as the sane\-epson driver but was developed to support a wider range of connections to the scanner; include network access. .PP Because .B sane\-epson and .B sane\-epson2 drivers support many of the same devices, if one driver gives you problems you may try disabling it to try the other. This can be done by removing the driver name from the .I dll.conf or perhaps by commenting out the options in .I epson.conf or .I epson2.conf. .PP At present, the following scanners are known to work with this backend: .PP .RS .ft CR .nf Model: Connection Type --------------------------- ------------------- ActionScanner II SCSI, parallel AcuLaser CX11 Series USB, Network AcuLaser CX21 Series USB, Network CX-3200 USB CX-3600 USB CX-3650 USB CX-4050 USB CX-4600 USB CX-4800 USB CX-5000 USB CX-5200 USB CX-5400 USB CX-6300 USB CX-6400 USB CX-6500 USB CX-6600 USB DX-3800 USB DX-5000 USB DX-5050 USB DX-6000 USB DX-7400 USB ES-300C SCSI, parallel ES-300GS SCSI ES-600C parallel ES-1200C parallel Expression 636 SCSI Expression 800 SCSI Expression 1600 USB, SCSI, IEEE-1394 Expression 1680 USB, SCSI, IEEE-1394 FilmScan 200 SCSI GT-5000 SCSI, parallel GT-5500 SCSI GT-6000 parallel GT-6500 parallel GT-7000 SCSI GT-8000 SCSI GT-8500 SCSI Perfection 610 USB Perfection 636S SCSI Perfection 636U USB Perfection 640 USB Perfection 1200S SCSI Perfection 1200U USB Perfection 1240 USB, SCSI Perfection 1640 USB, SCSI Perfection 1650 USB Perfection 1660 USB Perfection 2400 USB Perfection 2450 USB, IEEE-1394 Perfection 3200 USB Perfection 4870 USB Perfection 4990 USB RX-425 USB RX-500 USB RX-600 USB RX-700 USB V700 USB, IEEE-1394 V750 USB, IEEE-1394 .fi .ft R and many more. The official list is on the Sane web site. .RE For other scanners the software may or may not work. Please send mail to the sane-backend mailing list to report success with scanners not on the list or problems with scanners that are listed. .SH OPTIONS The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in programs like xscanimage or xsane. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d epson2 .RE Not all devices support all options. .TP .I Scan Mode The .I \-\-mode switch selects the basic mode of operation of the scanner. Valid choices are Binary, Gray and Color. The Binary mode is black and white only, Gray will produce 256 levels of gray or more depending on the scanner and Color means 24 bit color mode or more depending on the scanner. Some scanners will internally use 36 bit color, their external interface however may only support 24 bits. The .I \-\-depth option selects the bit depth the scanner is using. This option is only available for scanners that support more than one bit depth. Older scanners will always transfer the image in 8bit mode. Newer scanners allow one to select either 8 bits, 12 or 14 bits per color channel. For a color scan this means an effective color depth of 36 or 42 bits over all three channels. The valid choices depend on the scanner model. The .I \-\-halftoning switch selects the mode that is used in Binary mode. Valid options are "None", "Halftone A (Hard Tone)", "Halftone B (Soft Tone)", "Halftone C (Net Screen)", "Dither A (4x4 Bayer)", "Dither B (4x4 Spiral)", "Dither C (4x4 Net Screen)", "Dither D (8x4 Net Screen)", "Text Enhanced Technology", "Download pattern A", and "Download pattern B". The .I \-\-dropout switch selects the so called dropout color. Valid options are None, Red, Green and Blue. The default is None. The dropout color is used for monochrome scanning and selects the color that is not scanned. This can be used to e.g. scan an original with a colored background. The .I \-\-brightness switch controls the brightness of the scan. Valid options are integer values from \-3 to 3. The default is 0. The larger the brightness value, the brighter the image gets. If a user defined table for the gamma correction is selected, the brightness parameter is not available. The .I \-\-sharpness switch sets the sharpness of the image data. Valid options are integer values from \-2 to 2, with \-2 meaning "Defocus", \-1 "Defocus slightly", 0 "Normal", 1 "Sharpen slightly" and 2 "Sharpen". The .I \-\-gamma\-correction switch controls the scanner's internal gamma correction. Valid options are "Default", "User defined", "High density printing" "Low density printing" and "High contrast printing". The .I \-\-color\-correction switch controls the scanner's internal color correction function. Valid options are "No Correction", "Impact\-dot printers", "Thermal printers", "Ink\-jet printers" and "CRT monitors". The default is "CRT monitors". The .I \-\-resolution switch selects the resolution for a scan. Some EPSON scanners will scan in any resolution between the lowest and highest possible value. The list reported by the scanner can be displayed using the "\-\-help \-d epson" parameters to scanimage. The .I \-\-threshold switch selects the minimum brightness to get a white point. The .I \-\-mirror option controls the way the image is scanned. By reading the image data from right to left the image is mirrored. Valid options are "yes" and "no". The default is "no". The .I \-\-auto\-area\-segmentation switch activates the automatic area segmentation for monochrome scans. The scanner will try to determine which areas are text and which contain images. The image areas will be halftoned, and the text will be improved. Valid options are "yes" and "no". The default is "yes". The .I \-\-red\-gamma\-table parameter can be used to download a user defined gamma table for the red channel. The valid options are the same as for \-\-gamma\-table. The .I \-\-green\-gamma\-table parameter can be used to download a user defined gamma table for the green channel. The valid options are the same as for \-\-gamma\-table. The .I \-\-blue\-gamma\-table parameter can be used to download a user defined gamma table for the blue channel. The valid options are the same as for \-\-gamma\-table. The .I --wait-for-button parameter can be used to wait until the button on the scanner is pressed to actually start the scan process. The color correction coefficients .I \-\-cct\-1 \-\-cct\-2 \-\-cct\-3 ... \-\-cct\-9 will install color correction coefficients for the user defined color correction. Values are specified as integers in the range \-127..127. The .I \-\-preview option requests a preview scan. The frontend software automatically selects a low resolution. Valid options are "yes" and "no". The default is "no". The geometry options .I \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters. The .I \-\-source option selects the scan source. Valid options depend on the installed options. The default is "Flatbed". The .I \-\-auto\-eject option will eject a page after scanning from the document feeder. The .I \-\-film\-type option will select the film type for scans with the transparency unit. This option is only activated if the TPU is selected as scan source. Valid options are "Negative Film" and "Positive Film". The .I \-\-focus\-position option selects the focus position for all scans. Valid options are "Focus 2.5mm above glass" and "Focus on glass". The focus on the 2.5mm point above the glass is necessary for scans with the transparency unit, so that the scanner can focus on the film if one of the film holders is used. This option is only functional for selected scanners, all other scanners will ignore this option. The .I \-\-bay option selects which bay to scan The .I \-\-eject option ejects the sheet in the ADF. The .I \-\-adf-mode option select the ADF mode (simplex/duplex). .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/epson2.conf specifies the device(s) that the backend will use. Possible connection types are: .TP .I SCSI This is the default, and if nothing else is specified the backend software will open a given path as SCSI device. More information about valid syntax for SCSI devices can be found in sane\-scsi(5). .br Usually SCSI scanners are configured with a line "scsi EPSON" in this file. In some cases it may be necessary to only use the string "scsi" (e.g. for the GT-6500). .TP .I PIO \- Parallel Interface The parallel interface can be configured in two ways: An integer value starting at the beginning of a line will be interpreted as the IO address of the parallel port. To make it clearer that a configured IO address is a parallel port the port address can be preceded by the string "PIO". The PIO connection does not use a special device file in the /dev directory. The IO address can be specified in hex mode (prefixed with "0x"). .TP .I USB For USB scanners not automatically detect, their VENDOR and PRODUCT ID can be specified manually in the config file. More information about valid syntax for USB devices can be found in sane\-usb(5). .TP .I Network Network scanners can be auto-discovered if .I autodiscovery is specified after .I net keyword. An IP address to connect to can also be used. .SH FILES .TP .I @LIBDIR@/libsane\-epson2.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-epson2.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_EPSON2 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .TP .B SANE_DEBUG_EPSON2_SCSI If the library was compiled with debug support enabled, this environment variable controls the SCSI related debug level for this backend. Only a value of 2 is supported. .TP .B SANE_DEBUG_EPSON2_NET If the library was compiled with debug support enabled, this environment variable controls the network related debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .TP .B SANE_EPSON2_CMD_LVL This allows one to override the function or command level that the backend uses to communicate with the scanner. The function level a scanner supports is determined during the initialization of the device. If the backend does not recognize the function level reported by the scanner it will default to function level B3. Valid function levels are A1, A2, B1, B2, B3, B4, B5, B6, B7, B8, D1 and F5. Use this feature only if you know what you are doing! .SH "SEE ALSO" sane\-scsi(5), sane\-usb(5), scanimage(1), xscanimage(1), xsane(1) .SH BUGS None :-) At least none are currently known. .SH UNSUPPORTED DEVICES The backend may be used with Epson scanners that are not yet listed under the list of supported devices. A scanner that is not recognized may default to the function level B3, which means that not all functions that the scanner may be capable of are accessible. If the scanner is not even recognized as an Epson scanner this is probably because the device name reported by the scanner is not in the correct format. Please send this information to the backend maintainer (email address is in the AUTHOR section of this man page or in the AUTHORS file of the SANE distribution). .SH AUTHOR The package is written by Alessandro Zummo and is based on previous work done by Karl Hienz Kremer in the epson package as well as based on work by Christian Bucher and Kazuhiro Sasayama sane-backends-1.0.29/doc/mustek/0000755000000000000000000000000013615535552013337 500000000000000sane-backends-1.0.29/doc/mustek/mustek.CHANGES0000666000000000000000000007456513615534521015601 00000000000000CHANGES for the SANE Mustek backend 2005-05-05: * Released Mustek backend 1.0-138 * Added options to set the time after which the lamp of the A3 Pro is shut off and to shut it off immediately. 2004-06-08 * Released Mustek backend 1.0-137 * Reduced scan area of Mustek Paragon 1200 A3 Pro. Removed warning message. Increased support level to complete. 2004-03-21 * Released Mustek backend 1.0-136 * Added detection of Mustek ScanExpress 1200 FS. 2003-12-25 * Released Mustek backend 1.0-135 * Added support for Mustek Paragon 600 II EP (SCSI-over-parallel port). This is based on a patch from James Perry. Support for libiee1284 is missing until now. 2003-10-29 * Added support for sanei_thread. * Removed OS/2 specific code. 2003-10-29 * Released Mustek backend 1.0-134 2003-10-29 * Added support for sanei_thread. * Removed OS/2 specific code. 2003-10-15 * Added more debug messages. 2003-09-21 * Released Mustek backend 1.0-133 2003-09-21 * Fixed check for single quotation marks. 2003-03-07 * Released Mustek backend 1.0-132 2003-03-07 * Minor debug message updates. 2003-02-27 * Fixed a little bug in sane_control_option (gamma control). * Removed the signal blocking again. That only hides the segfault in sanei_scsi. * Check if there are documents in ADF for Paragon 2. Otherwise return error. 2003-02-25 * Fix some minor issues in reading the config file. 2003-02-22 * Initialize global variables in sane_init. 2003-02-17 * Released Mustek backend 1.0-131 2003-02-17 * Make sure that the result of the reader_process is interpreted correctly. * Block signals when waiting for a SCSI request to finish. Otherwise we may get a segfault if the reader_process is terminated while waiting. 2002-11-29 * Released Mustek backend 1.0-130 2002-11-29 * PACKAGE_VERSION fix. 2002-11-18 * Fixed debug message in do_stop: really print exit status of reader process. 2002-11-17 * Fixed minor issues in mapage. Added links to plustek and gt68xx backends. 2002-11-09 * Added link to SCSI documentation to manpage. 2002-11-07 * Released Mustek backend 1.0-129 2002-11-05 * Upload linear gamma table for Pro models if custom gamma is off instead of uploading the composed gamma table. That avoids applying gamm twice. * Minor man page update. 2002-10-11 * Released Mustek backend 1.0-128 2002-10-10 * Fixed lamp off time (60 minutes) for the 1200 A3 Pro. 2002-07-30 * Released Mustek backend 1.0-127. 2002-07-30 * Fixed some warnings. 2002-07-07 * Released Mustek backend 1.0-126. 2002-07-07 * Increased width and height of Paragon 800 and 600. 2002-06-07 * Released Mustek backend 1.0-125. 2002-06-07 * Fixed some comments. * Use FORCE_GAMMA for Paragon 6000SP as 2.x versions otherwise produce solid black images. * Used my own address instead of sane-devel for bug reports. 2002-05-31 * Explicitely set some arrays to 0. 2002-05-28 * Released Mustek backend 1.0-124. 2002-05-28 * Set X minimum value to 0 for Paragon 6000SP. 2002-04-24: * Released Mustek backend 1.0-122. 2002-04-24: * Undef MIN and MAX if they are defined in mustek.h to avoid warnings. 2002-04-22: * Fixed debug output in sane_control_option and sane_get_device_descriptor. 2002-04-10: * Released Mustek backend 1.0-121. 2002-04-10: * Set freed variables to 0 at sane_exit. * Coding-style fixed. 2002-04-06: * Released Mustek backend 1.0-120. 2002-04-05: * For 3-pass scanners use area_wait_ready and inquiry_wait_ready. The first wait doesn't seem to be enough for some scanners. 2002-03-20: * Released Mustek backend 1.0-119. 2002-03-20: * Fix halftone pattern handling. The buffer was way too small. 2002-03-19: * Option 0 has an empty name. 2002-03-18: * Better debug output for dev_cmd. * Set size for group options to 0. * Set size of halftone pattern to non 0. 2002-02-14: * Fixed some problems with wrong formats in DBG statements. 2002-01-23: * Fixed undefined operation warnings. 2002-01-20: * Released Mustek backend 1.0-118. 2002-01-20 * Changes for 1200 Pro: Removed debug code. Calibration is done in every mode. Calibration is on by default. Added some scsi_sense_wait_ready commands to be sure. 2002-01-16 * Changed option names to use only "-" not "_". 2002-01-10 * OPT_CONTRAST_R is red, not blue. 2002-01-07 * Released Mustek backend 1.0-117. 2001-12-29 * Send start_stop_scan for Pro even if scan wasn't cancelled but less data than expected was send (e.g. scanimage -T). 2001-12-22 * Added Trust Imagery 1200 to man page and .desc. 2001-12-15 * Released Mustek backend 1.0-116. 2001-12-11 * Fixed possible segfault in sane_control_option. * Added debug output of SCSI commands in dev_cmd and dev_read_req_enter. 2001-11-29 * Released Mustek backend 1.0-115. 2001-11-29 * Removed empty test for pro models. * Added check for TL_X > BR_X or TL_Y > BR_Y. 2001-11-22 * Released Mustek backend 1.0-114. 2001-11-22 * Added OS/2 compatibility fixes from "Franz Bakan" . 2001-11-18 * The Primax Compact 4800 seems to bes also supported. Added .desc and manpage entries. 2001-09-10 * Released Mustek backend 1.0-113. 2001-09-10 * Fixed bug in gamma correction code that broke at least custom gamma for the Paragon 12000SP. 2001-08-26 * Released Mustek backend 1.0-112. 2001-08-10 * Don't close fds[1] in case of OS/2. 2001-08-01 * Send stop_scan only for ScanExpress scanners when the scan wasn't cancelled. 2001-07-18 * Released Mustek backend 1.0-111. 2001-07-18 * Added warning about Aashima (Trust) scanners. * Only call stop_scan if Scan was cancelled for Paragon scanners. 2001-07-15 * Added message in reader_process that's printed when the kernel SCSI buffer is too small for the selected buffer size. 2001-07-11 * Released Mustek backend 1.0-110. 2001-07-10 * Added debug output for the total amount of data transfered to the frontend. * Fixed bug in fix_line_distance_block which lead to too much data transferred to sane_read. 2001-07-09 * Released Mustek backend 1.0-109. 2001-07-09 * Fixed (hopefully) problem with black images (Paragon 6000 SP). 2001-07-08 * Fixed problem with double buffering/SCSI command queuing and Linux 2.4.x. Thaks to Abel Deuring for his help. * Added option to disable backtracking 2001-07-07 * Released Mustek backend 1.0-108. 2001-07-07 * added option to disable double-buffering * don't set any options by default in mustek.conf * updated manpage * fixed debug statement in scsi_inquiry_wait_ready 2001-05-06 * Fixed memory leak in sane_get_devices () 2001-04-29 * Fixed several memory leaks. 2001-04-27 * Released Mustek backend 1.0-107 (in CVS). 2001-04-23 * Add internationalization support (mark all strings that can be translated with SANE_I18N()). 2001-04-19 * Don't check for macro VERSION any longer in sane_init. Print out PACKAGE_VERSION instead. * Update email address and homepage. 2001-08-08 * Released Mustek backend 1.0-106 2001-04-08 * Backend status is "stable" now. Hopefully this doesn't mean that new bugs show up now :-) 2001-04-01 * Added detection of the Pro models TA (at least the 1200SP Pro). * Added warning about real (not relabeled) Trust scanners. 2001-03-31 * Removed comment about brightness and contrast in the description strings because you can't read them anyway in color mode (at least with xsane). 2001-03-31 * Released Mustek backend 1.0-105 2001-03-31 * Removed compilation warning in gamma_correction. * Fixed handling of tlx and brx when scanning with ADF (bug found by Andreas Rathgeber ). * Fixed bug in linedistance correction (ld_block) concerning ADF. With ADF the linedistance values are ordered in the other direction. * Fixed bug concerning ld correction for the 1200SP 1.00 (frontend hangs). Moved the do-nothing ld correction to its own function. With ADF this scanner doesn't really work in color mode but that's probably a firmware problem. 2001-03-18 * 600 II N: Gamma correction in gray mode now works. Length must be 768 bytes in gray mode also, cdb size is 6 bytes. Thanks to Jakub Bogusz who found out about that and wrote a patch. 2001-01-17 * Released Mustek backend 1.0-104 2001-01-17 * Pro: Do calibration only in Lineart, Gray and Color 24 modes. 2001-01-03 * Added 36 bit color mode for the Paragon Pro scanners. 2000-12-31 * Added function little_endian (from coolscan.c) to check the endianess of the current architecture (needed for 16 bit frames). * Added option for Gray fast * Added option for bit depth (8 and 12 bits for the Pro models) * Removed "special" modes from mode option * Removed 48 bit options for the SE Plus. This mode seems to use only interpolated information (but I may be wrong). 2000-12-31 * Released Mustek backend 1.0-103 2000-12-30 * Implemented calibration (color and gray mode) for the Paragon 1200 Pro. It's not perfect and needs lots of tests. It may work for the Paragon A3 also but is not tested. * SE 12000 SP Plus calibration is now better but not yet perfect. 2000-12-27 * Enabled fast_preview for the Pro scanners (30 dpi). * Increased scan width to 8.6" for 1200 Pro. 2000-12-26 * Added calibration for the SE 12000 SP Plus. Doesn't fully work until now (images are too dark and colored). 2000-12-23 * Added option for Legal format (because the ScanExpress 12000 SP A4 size scanner can't be distinguished from the Paragon 1200 LS Legal size scanner by software). 2000-12-21 * Added a few checks for Null-Pointers. * Removed old code for SE calibration. * Added option "quality calibration" for SE Plus scanners 2000-12-21 * sane-backends 1.0.4 was released (including Mustek backend 1.0.102). 2000-12-10 * Released Mustek backend 1.0-102 2000-12-09 * Fixed wrong comment in encode_resolution * Added missing test for return status in sane_start * Fixed wrong calculation of tlx and tly for Pro series scanners 2000-12-05 * Released Mustek backend 1.0-101 2000-12-05 * Fixed lamp setting (avoid problems with some SE scanners). 2000-12-01 * Reduced scan area for Paragon 1200 SP PRO (to avoid bumping the scan slider at the end). * Removed warning for 1200 SP PRO. 2000-11-26 * Released Mustek backend 1.0-100 2000-11-26 * Default for "fast preview" is "false" now because this option doesn't work for all SE scanners correctly. * Added more debug output for area_and_windows. * Added more debug output for set_window. * Set minimum tly for 8000SP to 0. * Don't use block mode for Paragon 8000 SP scanners because this breaks color mode with firmware 2.x. 2000-11-19 * Paragon 6000 SP doesn't use block mode any more. It's a bit faster now. * Updated sane-mustek.man concerning buffersize and blocksite. 2000-11-17 * Updated manpage concerning force-wait. Some minor corrections and additions * Added option force-wait to mustek.conf and did some minor changes. 2000-11-16 * With option force_wait set, the backend waits also before sending the inquiry command. This seems to be necessary for the 600 II N. 2000-11-12 * Use SANE_Int, SANE_Bool, SANE_Word for int wherever this seems to be appropriate. * Move macros to mustek.h. * Code cleanup. 2000-11-11 * OPT_GRAY_PREVIEW is now called OPT_FAST_PREVIEW. * For SE scanners use 36/38 dpi color for fast preview. * use include "../include/sane/" instead of "sane/" * go back to old scheme for SE scanners in color mode (faster scans couldn't be reproduced) 2000-11-10 * added more debug output in constrain_value 2000-11-05 * Released backend version 1.0-99. 2000-11-05 * Added support for TAIV for SE 12000 SP. Lamp is turned off while scanning (seems to work for firmware >= 2.00) * Adjusted transparency adapter support for all ScanExpress scanners. The 12000 A3 SP can only do A4 beacuse I don't have the right TA. * don't use u_int* types in mustek.h because the definitions for these types are not included 2000-11-04 * SE scanners can now scan 75, 100, 150, 200, 250, 300, 400, 500, 600, 900 and 1200 dpi in color mode (the 1200 dpi models). These are fixed resolutions, a resolution >= the wanted resolution is selected. This makes preview and some resolutions faster than before (at least for some scanners), because lower resolutions can be used. * Minimum scan resolution is 60 dpi in gray and lineart and 75 dpi in color mode for the SE scanners now. 2000-10-29 * Fixed a bug concerning block LD. Paragon 1 and 2 were exchanged. * Paragon 12000SP color mode works now without garbage at the end * Fixed Paragon 1200 SP Pro color mode > 600 dpi (rounding problem) * Temporarily disabled 48 bit color mode for release 2000-10-25 * Detect support for TA IV (transparency adapter for ScanExpress scanners) * TA IV supported now; lamp is turned off at least for SE 1200 SP Plus scanners * Adjusted scan area for TA: SE 12000SP Plus * Simplify enlarge x * Set tl-y to 0 for all ScanExpress scanners * First attempt to support 48 bits color mode (SE 12000 SP Plus) 2000-10-22 * Detect SE 12000 SP Plus properly * Cover sensor only checked for SE models that support this feature 2000-10-21 * Removed MAX_BLOCKSIZE macro (not used anymore). 2000-10-03 * Released backend version 1.0-98. 2000-10-03 * Fixed segmentation fault in sane_init (else statement was missing). Thanks to Oliver Rauch who spotted this problem. * Re-enabled double buffering. 2000-10-02 * Zero out inquiry memory block before reading inquiry. 2000-10-01 * Fixed fix_line_distance_block. * Adjusted Paragon 12000 SP to use block LD correction if necessary. * removed LD MFS (wasn't used anyway) 2000-09-30 * Set blockbuffer size to 2 MB for Paragon series II scanners. * Fix sane_cancel for Paragon series II scanners * Fix speed and grain for Paragon series II scanners * Backtracking is used for all scanners (removed option) * included stop_scan into do_stop * better integration of the wait_ready functions * check that size of buffer <= size of block buffer 2000-09-24 * Added more debug output in sane_get_option_descriptor. * Added more debug output in sane_control_option. * Added check for devicename and handle != 0 in sane_open * Added check for handle != 0 in sane_get_option_descriptor * Added check for handle != 0 in sane_get_parameters * Added check for handle and val != 0 in sane_control_option * Added check for handle != 0 in sane_start * Added check for handle, buf and len != 0 in sane_read * Added check for handle != 0 in sane_cancel * Added check for handle != 0 in sane_set_io_mode * Added check for handle != 0 in sane_get_select_fd * Output option title in sane_get_option_descriptor if name is null 2000-09-24 * Released backend version 1.0-97. 2000-09-24 * Added RGB brightness and contrast for 3pass scanners * Brightness and contrast is +-100% for 3pass scanners now 2000-09-23 * Paragon 12000CX uses pixel unit now. * Paragon 6000CX uses pixel unit now (MSF-06000CZ). * Option "force backtracking" is enabled by default now * Option "scan speed" is set to "fastest" by default now * Add option "force-wait" (for mustek.conf). If enabled, wait for scan head to return to start position after scan. * Make DBG output in sane_control_option() more readable * Better error handling and debug output in sane_get_option_descriptor() * Changed Halftone handling, removed grain size 2000-09-22 * Paragon 12000SP 1.06 uses LD_NORMAL now. 2000-09-19 * Return sane_status_cancelled in sane_read if last scan was cancelled. 2000-09-18 * Changed speed_code to use values between 1...5 for 3pass scanners. I don't know yet if these are correct for the other scanners, too. * Don't do a stop scan for 3pass scanners (only when cancelling). * Set bit 0 of first byte of area_and_windows for gray + color. * Paragon 6000CX uses pixel unit now (MFS-06000CX). * Pixel unit for 3pass scanners is now supported 2000-09-17 * changed maximum y range of MFS-800 II SP to 288 mm because of a report of scanner touching the end. 2000-09-10 * added some testing (result != null and arg !=0) in sense_handler (found by Martin Blasczyk) 2000-08-20 * Paragon series II is also using blockmode now. * Removed warning from mustek.c. * Fixed (maybe) problem in scsi_sense_wait_ready and added more debug output. 2000-08-18 * added new option blocksize to mustek.conf * 800 II SP works now in new block mode (get_image_status is needed before each block) 2000-08-17 * Removed some warnings from sanei_ab306.c. 2000-08-16 * Fixed some bugs in fix_linedistance_block. Paragon 600 models seem to work now. 800 II SP freezes, however. * Fixed segmentation fault for the 600 II N in ld correction code. 2000-08-15 * Changed handling of three pass scanners (MUSTEK_FLAG_THREE_PASS instead of !MUSTEK_FLAG_SINGLE_PASS). * Added flags for Paragon series I and II (MUSTEK_PLAG_PARAGON_1 and MUSTEK_PLAG_PARAGON_2). * Distinguish between three-pass, Paragon series 1, Paragon series 2, ScanExpress, Pro and N type scanners. * Added support for scanning the whole image in one block without backtracking for the Paragon series II scanners. * Added fix_linedistance_block: like linedistance_normal but broken up into several SCSI buffers. 2000-08-14 * Changed again linedistance correction for the Paragon 12000 SP 1.11. This seems to be a never ending story. * Set the minimum dpi value to 30. Some scanners (e.g. the MFS 8000SP v 2.04) block the SCSI bus with lower resolutions. 2000-08-12 * Added support for Paragon 1200 SP Pro. * Added support for ScanExpress A3 SP. * Removed detection for " C12" and " C04" (don't seem to exist). * Changed SCSI read request scheme. Now two requests with half of the maximum SCSI buffer size are entered. Standard buffer size is 128 kB, so the buffer sent to the scanner is 64 kB for all types of scanners. * sane_read now reads more than 4096 bytes from pipe (if available). 2000-08-12 * SANE 1.0.3 released (including Mustek backend 1.0.96). 2000-07-31 * Released backend version 1.0-96. 2000-07-30 * Fixed bug concerning inquiry of 3-pass scanners. ASCII values > 127 weren't interpreted correctly (char instead of unsigned char). 2000-07-30 * Released backend version 1.0-95 2000-07-30 * Removed while {wait ()} loop. Used waitpid() instead. Maybe this cures some reported freezes. It's cleaner anyway. * Removed dead code. 2000-07-28 * Released backend version 1.0-94 2000-07-29 * Use #include "sane/..." instead of #include . 2000-07-27 * Released backend version 1.0-93 2000-07-27 * removed warnings 2000-07-26 * fixed possible segfault pointer info was not checked for 0 (found by Petter Reinholdtsen) * Updated comment about Paragon 600 II N linedistance correction in man page 2000-07-25 * Fixed color scanning for Paragon 600 II N firmware < 2.00. 2000-07-25 * Released backend version 1.0-92 2000-07-24 * Fixed ADF handling (output was mirrored in x direction). Gray and lineart seems to work now. Color and halftone modes look somewhat crazy. * Removed comment about lack of testing of ADFs in manpage. They are tested to work now with most scanner at least basically. * removed braindead test for Pro series concerning gamma table length (discovered by Jan-Erik Karlsson). 2000-07-22 * Fixed margin positions of MFS 6000CX and removed warning. * Warning is printed with DBG level 0 again. 2000-07-18 * Released backend version 1.0-91 2000-07-18 * Removed again MUSTEK_FLAG_LD_NONE for MFS-08000SP. Maybe the automatical detection works now. 2000-07-15 * Released backend version 1.0-90 2000-07-15 * Added MUSTEK_FLAG_LD_NONE for MFS-08000SP and removed warning for this scanner. Added TA support. First report for this device from Roland Koebler. * Changed LD correction system. Some scanners (e.g. the 800 II SP) seem to need different LD correction depending on resolution. Now with LD_NORMAL max_value is checked and correction is only done if it is != 0. Hope this works for all scanners. * Moved the comment after the example port entry in mustek.conf to the next line. Now this line should work. * Updated manpage concerning PP scanners and 600 II N. 2000-06-30 * Released backend version 1.0-89 2000-06-30 * Fixed bug in do_stop. The scan slider didn't return after the scan in some situations. 2000-06-28 * Released backend version 1.0-88 2000-06-28 * Changed again linedistance handling for the Paragon 1200SP. This time version 1.07 seems to need a special treetment. Even with normal linedistance correction the image is corrupted at buffer boundaries in color mode. Maybe a firmware bug? Thanks to Michael Prechtl for all his tests. 2000-06-25 * added missing newline to mustek.conf 2000-06-25 * Released backend version 1.0-87 2000-06-25 * updated manpage concerning parport and USB scanners * added example for 600 II N to mustek.conf 2000-06-22 * fixed debug output bug in fix_linedistance_se (found by Jan-Erik Karlsson) 2000-06-21 * fixed dependancy of mustek.h on sane-backends.h 2000-06-19 * Fixed gamma correction in lineart mode for Paragon 1200 A3 2000-06-18 * Released backend version 1.0-86 2000-06-18 * added enlarging x resolution for Paragon 1200 A3 Pro * Paragon 1200 A3 PRO is fully functional now. Thanks to Heinrich Falk, who borrowed me this device. 2000-06-17 * added calibration for Paragon 1200 A3 Pro (only dummy, doesn't work yet) * adjusted options for Paragon 1200 A3 Pro * added lineart support for Paragon 1200 A4 Pro * removed support for color lineart and color halftone modes * added color support for Paragon 1200 A3 Pro * added scsi_wait_sense, this fixed 1200 A3 Pro hangs * fixed gamma correction for 1200 A3 Pro. At the moment only 8 bit and 24 bit per pixel are supported (12/36 are possible in hardware) 2000-06-16 * addded debugging output in sane_control_option * added gamma correction for Paragon 1200 A3 Pro (doesn't work correctly yet) 2000-06-15 * removed old config file reading system. 2000-06-14 * Preliminary support for the Mustek Paragon 1200 A3 Pro. Only grayscale mode works so far. Missing: Gamma correction and calibration. The scanner is locked after each scan. 2000-06-12 * Fixed bug in sane_control_option. option was not checked for negative values. Thanks to Jochen Eisinger. * Code cleanup and reorganization for inclusion of the Paragon 1200 A3 Pro. 2000-06-07 * Fixed bug in sane_close where the chain of handles got destroyed by closing the first device. This bug is in the backend since 3 1/2 years. Thanks to Jochen Eisinger for spotting this. 2000-06-05 * Fixed some debug messages in fix_linedistance_se 2000-06-04 * released backend version 1.0-85 2000-06-04 * changed (again) Paragon 12000 SP linedistance handling, now 1.02 uses normal LD corrections, all other use none. We'll see, if this works. Thanks to Reinhard Günzel who helped to debug this. * fixed some long lines (>80 chars) 2000-06-03 * released backend version 1.0-84 2000-06-03 * changed line-distance handling, removed ld.max_value magic (didn't work) * fixed (maybe) Paragon 12000 SP color stripes problems (v 1.11 and others) * simpler linedistance debug output, only for 1-pass Paragon scanners 2000-06-02 * removed code in dev_read_start which was never called (suggestion from Jan-Erik Karlsson) 2000-05-21 * added double buffering (trying to copy the scsi buffer to the frontend while getting a new one). This probably won't work on all platforms and with all SCSI host adapters but in this case performance shouldn't be worse than before. 2000-05-21 * released backend version 1.0-83 2000-05-21 * The Mustek Paragon 1200 A3 PRO is now detected. This is only a test release. Be carefull and read the PROBLEMS file if you want to try this scanner. 2000-05-19 * released backend version 1.0-82 2000-05-18 * set debug level for output of unknown Mustek scanner to 0 (suggestion from Thorben Kundinger) 2000-05-12 * fixed bug in distinguishing firmware formats * added shrinked image fix to ScanExpress 12000SP models <= v2.0 2000-05-08 * fixed remaining sane_cancel problems (in non_blocking mode) * fixed color stripes and segmentation fault for Paragon MFS-12000SP 1.00 (at least for me) * added more debug output to inquiry * added possibility to distinguish old and new firmware formats * added one more debug level (5) * added output of SANE version 2000-05-07 * released backend version 1.0-81 2000-05-06 * added transparency adapter support for the Paragon 600 II CD, 600S, 800 II SP, 600 II N, ScannExpress 6000SP and 12000SP * removed "color lineart" and "color halftone" for all scanners. These modes didn't work for any of my scanners. * added more debug output for ADF and TA * fixed bug when ADF is out of documents * Scan source option is only available if TA or ADF is present. For SE and N models TA is always available because it can't be detected by hardware * removed "backtrack", "speed" and "grain" from 600 II N options, the scanner doesn't support them * updated mustek.desc and mustek.man 2000-05-02 * Reduced scan area for the Paragon MFC-600S because of ugly noises at the end of the scan area 2000-04-29 * Adjusted scan area to the Windows driver defaults for ScanExpress 6000SP; added MUSTEK_FLAG_ENLARGE_X for this scanner * Added Warning for scanners that are not (fully) tested 2000-04-26 * changed sane_init to use sanei_config_read () and sanei_config_get_string () 2000-04-24 * released backend version 1.0-80 2000-04-23 * fixed lineart and color scanning >600 dpi for the SE 12000SP * added variable debug_level to be faster without debugging in attach () * fixed bug in mustek.conf handling; positional options were applied to the first device only * added an option to mustek.conf: "buffersize". This overwrites the default scan buffer sizes. The unit is kilobytes. * adjusted mustek.conf to more reasonable defaults * update manpage and mustek.desc to reflect the changes 2000-04-22 * fixed greyscale scanning >600 dpi for the SE 12000SP 2000-04-21 * added more debug output to sane_get_parameters 2000-04-20 * Output of scanning time now works with scanimage, too. * Adjusted scan area to the Windows driver defaults for Paragon MFS-6000CX * Added transparency adapter support for the Paragon MFS-6000CX and MFS-12000SP 2000-04-19 * Adjusted scan area to the Windows driver defaults for Paragon MFS-12000SP 2000-04-17 * added support for the sanei_scsi_open_extended method with variable buffersizes * removed support for SCSI queue. Couldn't find improvements for any scanner 2000-04-16 * removed "color lineart" and "color halftone" for single pass scanners. These modes didn't work for any of my scanners. * fixed problems in color mode for the MFS-8000SP (gamma table is now uploaded even if not selected) * Output "cover open" only for ScanExpress scanners (Paragon scanners don't have a cover sensor) * Added transparency adapter support for the Paragon MFS-6000SP and MFS-12000CX * Added output of transfer speed (kb/s) * maximum allocated memory for read request can be set by a #define * buffer size can be set on a per scanner basis * Adjusted scan area to the Windows driver defaults for Paragon 800 II SP * Added quotation marks to inquiry output 2000-04-15 * Adjusted scan area to the Windows driver defaults for Paragon 8000SP, ScanExpress 12000SP * Fixed scan area settings (TL-X and TL-Y) for transparency adapter (TA) * Added TA support for Paragon 8000SP 2000-04-13 * Added more debug output in sane_read and some other functions * removed warnings 2000-04-12 * Added more debug output concerning buffer handling 2000-04-10 * Adjusted scan area to the Windows driver defaults for Paragon 12000CX, 6000SP, 600 II CD, 600 II N 2000-04-09 * released backend version 1.0-79 2000-04-08 * added output of scanning time (debuglevel 2 and higher) * removed old code from sane_cancel 2000-04-07 * fixed line-distance correction for the 600 II N * rewrite of the 600 II N code * documentation update for the 600 II N 2000-04-06 * Rewrite of resolution encoding for 3-pass scanners * added more comments * some spelling errors corrected 2000-04-03 * output backend and version information * fixed resolution encoding for MFS12000cx * Changed version system to be compatible to the SANE standard (major, minor, build); 0.78 --> 1.0-78 2000-04-02 * released backend version 0.78 * added MUSTEK_FLAG_DOUBLE_RES for the MFS-12000CX 3-pass scanner, resolutions > 600 dpi should work now 2000-04-01 * reduced scan area for Paragon 800 S / II SP 2000-03-29 * released backend version 0.77 * inquiry is printed in full text at debug level 4 * more debug level tweaking * man page update * model name update 2000-03-25 * corrected some spelling errors 2000-03-24 * reduced scanarea for the MSF-6000SP * restructured scanner recognition 2000-03-18 * released backend version 0.76 2000-03-17 * removed some compiler warnings * changed the sane.model names (e.g. ScanExpress 12000SP instead of C06IDW...) * added SCSI information output to inquiry * adjusted debug levels and debug output 2000-03-15 * fixed typo in man page 2000-03-12 * released backend version 0.75 * man page update * mustek.desc update * test for option < 0 in sane_get_option_descriptor (thanks to Oliver Rauch) * added do_stop in sane_cancel (don't wait for next read that will possibly never happen) * fixed firmware version identification for newer ScanExpress models (patch from Marco G. Salvagno) * probably fixed linedistance correction at high resolutions for MFS-1200SP firmware 1.00 and possibly others (patch from Andreas Beck) * added check for ADF ready in sane_start (patch from Joerg Anders) * Bug fix in the STORE makros (patch from Norbert Mueller) 2000-03-06 * created mustek.CHANGES file * released backend version 0.74 * added linedistance correction for the 600 II N + documentation updates * added detection of newer ScanExpress models ("XC06" instead og " C06") * bugfix for 600 II N waiting 60 s before cancelling Henning Meier-Geinitz sane-backends-1.0.29/doc/sane-epsonds.man0000666000000000000000000000631513615534521015047 00000000000000.TH sane\-epsonds 5 "29 Mar 2015" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-epsonds .SH NAME sane\-epsonds \- SANE backend for EPSON ESC/I-2 scanners .SH DESCRIPTION The .B sane\-epsonds library implements a SANE (Scanner Access Now Easy) backend that provides access to Epson ESC/I-2 scanners. .PP Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d epsonds .RE Not all devices support all options. .TP .I Scan Mode The .I \-\-mode switch selects the basic mode of operation of the scanner. Valid choices are Lineart, Gray and Color. The Lineart mode is black and white only, Gray will produce 256 levels of gray or more depending on the scanner and Color means 24 bit color mode or more depending on the scanner. Some scanners will internally use 36 bit color, their external interface however may only support 24 bits. The .I \-\-depth option selects the bit depth the scanner is using. This option is only available for scanners that support more than one bit depth. Older scanners will always transfer the image in 8bit mode. Newer scanners allow one to select either 8 bits, 12 or 14 bits per color channel. For a color scan this means an effective color depth of 36 or 42 bits over all three channels. The valid choices depend on the scanner model. The .I \-\-resolution switch selects the resolution for a scan. Some EPSON scanners will scan in any resolution between the lowest and highest possible value. The list reported by the scanner can be displayed using the "\-\-help \-d epson" parameters to scanimage. The geometry options .I \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters. The .I \-\-source option selects the scan source. Valid options depend on the installed options. The default is "Flatbed". The .I \-\-eject option ejects the sheet in the ADF. The .I \-\-adf-mode option select the ADF mode (simplex/duplex). .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/epsonds.conf specifies the device(s) that the backend will use. Possible connection types are: .TP .I USB For not automatically detected USB scanners, their VENDOR and PRODUCT ID can be specified manually in the config file. More information about valid syntax for USB devices can be found in sane\-usb(5). .TP .I Network (not yet supported) Network scanners can be auto-discovered if .I autodiscovery is specified after .I net keyword. An IP address to connect to can also be used. .SH FILES .TP .I @LIBDIR@/libsane\-epsonds.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-epsonds.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_EPSONDS If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. Values around 11-16 will usuallybe enough for a bug report. .SH "SEE ALSO" sane\-usb(5), scanimage(1), xscanimage(1), xsane(1) .SH AUTHOR The package is written by Alessandro Zummo sane-backends-1.0.29/doc/sane-dll.man0000666000000000000000000001151013615534521014140 00000000000000.TH sane\-dll 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-dll .SH NAME sane\-dll \- SANE dynamic backend loader .SH DESCRIPTION The .B sane\-dll library implements a SANE (Scanner Access Now Easy) backend that provides access to an arbitrary number of other SANE backends. These backends may either be pre-loaded at the time the .B sane\-dll library is built or, on systems that support dynamic loading of shared libraries, the backends may be loaded at runtime. In the latter case, adding support for a new backend simply involves installing the relevant library in .I @LIBDIR@ and adding an entry to the .I dll.conf configuration file. In other words, no applications need to be modified or recompiled to add support for new devices. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .IR backend : device .RE .PP Where .I backend is the name of the backend and .I device is the name of the device in this backend that should be addressed. If the device name does not contain a colon (:), then the entire string is treated as the .I device string for the default backend. The default backend is the backend listed last in the configuration file (see below) or the first pre-loaded backend (if any). .SH CONFIGURATION The contents of the .I dll.conf file is a list of backend names that may be loaded dynamically upon demand. Empty lines are ignored, also everything after a hash mark (#). A sample configuration file is shown below: .PP .RS net .br # this is a comment .br pnm .br mustek .RE .PP It is also possible to add a file in .I @CONFIGDIR@/dll.d that contains the list of backends to be added. Backends mentioned in a file included in this directory will be added before any backends listed in .I dll.conf. Files in .I @CONFIGDIR@/dll.d can be freely named. They shall follow the format conventions as apply for .I dll.conf. .PP Note that backends that were pre-loaded when building this library do not have to be listed in this configuration file. That is, if a backend was preloaded, then that backend will always be present, regardless of whether it's listed in the configuration file or not. .PP The list of preloaded backends is determined by macro .B PRELOADABLE_BACKENDS in file backend/Makefile.in of the SANE source code distribution. After changing the value of this macro, it is necessary to reconfigure, rebuild, and reinstall SANE for the change to take effect. Aliases are defined in the config file .IR dll.aliases . It can contain entries of the form .PP .RS .br alias SomeName SaneDeviceName .br alias "Some Name" SaneDeviceName .br hide SaneDeviceName .RE .PP For example: .PP .RS .br alias Epson net:somehost:epson:/dev/sgX .br alias "Siemens ST400" st400:/dev/sgY .br hide net:somehost:pnm:0 .br hide net:somehost:pnm:1 .br alias "Read from file" pnm:0 .br hide pnm:1 .RE .PP Aliased device names are automatically hidden. The idea is that users don't have to deal with complicated device names (especially for networked devices), and to hide other exported devices which might confuse them. Note that a hidden device can still be accessed if the device name is known, it just doesn't appear on the list. .SH FILES .TP .I @CONFIGDIR@/dll.aliases The list of aliased or hidden backends. .TP .I @CONFIGDIR@/dll.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-dll.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-dll.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_DLL If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .ft CR .nf Value Description 0 print severe errors only 1 print normal errors and important messages 2 print normal messages 3 print debugging messages 4 print everything .fi .ft R Example: export SANE_DEBUG_DLL=3 .SH "SEE ALSO" .BR sane (7), .BR scanimage (1), .BR sane\-"backendname" (5) .SH AUTHOR David Mosberger sane-backends-1.0.29/doc/scanimage.man0000666000000000000000000003244113615534521014376 00000000000000.TH scanimage 1 "10 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX scanimage .SH NAME scanimage \- scan an image .SH SYNOPSIS .B scanimage .RB [ \-d | \-\-device\-name .IR dev ] .RB [ \-\-format .IR format ] .RB [ \-i | \-\-icc\-profile .IR profile ] .RB [ \-L | \-\-list\-devices ] .RB [ \-f | \-\-formatted\-device\-list .IR format ] .RB [ \-b | \-\-batch .RI [= format ]] .RB [ \-\-batch\-start .IR start ] .RB [ \-\-batch\-count .IR count ] .RB [ \-\-batch\-increment .IR increment ] .RB [ \-\-batch\-double ] .RB [ \-\-accept\-md5\-only ] .RB [ \-p | \-\-progress ] .RB [ \-o | \-\-output-file ] .RB [ \-n | \-\-dont\-scan ] .RB [ \-T | \-\-test ] .RB [ \-A | \-\-all-options ] .RB [ \-h | \-\-help ] .RB [ \-v | \-\-verbose ] .RB [ \-B | \-\-buffer-size .RI [= size ]] .RB [ \-V | \-\-version ] .RI [ device\-specific\-options ] .SH DESCRIPTION .B scanimage is a command-line interface to control image acquisition devices such as flatbed scanners or cameras. The device is controlled via command-line options. After command-line processing, .B scanimage normally proceeds to acquire an image. The image data is written to standard output in one of the PNM (portable aNyMaP) formats (PBM for black-and-white images, PGM for grayscale images, and PPM for color images), TIFF format (black-and-white, grayscale or color), PNG format, or JPEG format. .B scanimage accesses image acquisition devices through the .B SANE (Scanner Access Now Easy) interface and can thus support any device for which there exists a .B SANE backend (try .B apropos .I sane\- to get a list of available backends). .SH EXAMPLES To get a list of devices: scanimage \-L To scan with default settings to the file image.pnm: scanimage >image.pnm To scan 100x100 mm to the file image.tiff (\-x and \-y may not be available with all devices): scanimage \-x 100 \-y 100 \-\-format=tiff >image.tiff To print all available options: scanimage \-h .SH OPTIONS Parameters are separated by a blank from single-character options (e.g. \-d epson) and by a "=" from multi-character options (e.g. \-\-device\-name=epson). .PP The .B \-d or .B \-\-device\-name options must be followed by a .B SANE device-name like .RI ` epson:/dev/sg0 ' or .RI ` hp:/dev/usbscanner0 '. A (partial) list of available devices can be obtained with the .B \-\-list\-devices option (see below). If no device-name is specified explicitly, .B scanimage reads a device-name from the environment variable .BR SANE_DEFAULT_DEVICE . If this variable is not set, .B scanimage will attempt to open the first available device. .PP The .B \-\-format .I format option selects how image data is written to standard output or the file specified by the \-\-output\-file option. .I format can be .BR pnm , .BR tiff , .BR png , or .BR jpeg . If .B \-\-format is not specified, PNM is written by default. .PP The .B \-i or .B \-\-icc\-profile option is used to include an ICC profile into a TIFF file. .PP The .B \-L or .B \-\-list\-devices option requests a (partial) list of devices that are available. The list is not complete since some devices may be available, but are not listed in any of the configuration files (which are typically stored in directory .IR @CONFIGDIR@ ). This is particularly the case when accessing scanners through the network. If a device is not listed in a configuration file, the only way to access it is by its full device name. You may need to consult your system administrator to find out the names of such devices. .PP The .B \-f or .B \-\-formatted\-device\-list option works similar to .BR \-\-list\-devices , but requires a format string. .B scanimage replaces the placeholders .B %d %v %m %t %i %n with the device name, vendor name, model name, scanner type, an index number and newline respectively. The command .PP .RS .B scanimage \-f .I \*(lq scanner number %i device %d is a %t, model %m, produced by %v \*(rq .PP .RE will produce something like: .PP .RS scanner number 0 device sharp:/dev/sg1 is a flatbed scanner, model JX250 SCSI, produced by SHARP .RE .PP The .B \-\-batch* options provide the features for scanning documents using document feeders. .BR \-\-batch .RI [ format ] is used to specify the format of the filename that each page will be written to. Each page is written out to a single file. If .I format is not specified, the default of out%d.pnm (or out%d.tif for \-\-format tiff, out%d.png for \-\-format png or out%d.jpg for \-\- format jpeg) will be used. This option is incompatible with the \-\-output\-path option. .I format is given as a printf style string with one integer parameter. .B \-\-batch\-start .I start selects the page number to start naming files with. If this option is not given, the counter will start at 1. .B \-\-batch\-count .I count specifies the number of pages to attempt to scan. If not given, scanimage will continue scanning until the scanner returns a state other than OK. Not all scanners with document feeders signal when the ADF is empty, use this command to work around them. With .B \-\-batch\-increment .I increment you can change the amount that the number in the filename is incremented by. Generally this is used when you are scanning double-sided documents on a single-sided document feeder. A specific command is provided to aid this: .B \-\-batch\-double will automatically set the increment to 2. .B \-\-batch\-prompt will ask for pressing RETURN before scanning a page. This can be used for scanning multiple pages without an automatic document feeder. .PP The .B \-\-accept\-md5\-only option only accepts user authorization requests that support MD5 security. The .B SANE network daemon .RB ( saned ) is capable of doing such requests. See .BR saned (8). .PP The .B \-p or .B \-\-progress option requests that .B scanimage prints a progress counter. It shows how much image data of the current image has already been received by .B scanimage (in percent). .PP The .B \-o or .B \-\-output\-file option requests that .B scanimage saves the scanning output to the given path. This option is incompatible with the \-\-batch option. The program will try to guess \-\-format from the file name. If that is not possible, it will print an error message and exit. .PP The .B \-n or .B \-\-dont\-scan option requests that .B scanimage only sets the options provided by the user but doesn't actually perform a scan. This option can be used to e.g. turn off the scanner's lamp (if supported by the backend). .PP The .B \-T or .B \-\-test option requests that .B scanimage performs a few simple sanity tests to make sure the backend works as defined by the .B SANE API (in particular the .B sane_read function is exercised by this test). .PP The .B \-A or .B \-\-all-options option requests that .B scanimage lists all available options exposed the backend, including button options. The information is printed on standard output and no scan will be done. .PP The .B \-h or .B \-\-help options request help information. The information is printed on standard output and in this case, no attempt will be made to acquire an image. .PP The .B \-v or .B \-\-verbose options increase the verbosity of the operation of .B scanimage. The option may be specified repeatedly, each time increasing the verbosity level. .PP The .B \-B option without argument changes the input buffer size from the default 32KB to 1MB. For finer grained control, use .B \-\-buffer-size= followed by the number of KB. .PP The .B \-V or .B \-\-version option requests that .B scanimage prints the program and package name, the version number of the .B SANE distribution that it came with and the version of the backend that it loads. Usually that's the dll backend. If more information about the version numbers of the backends are necessary, the .B DEBUG variable for the dll backend can be used. Example: SANE_DEBUG_DLL=3 scanimage \-L. .PP As you might imagine, much of the power of .B scanimage comes from the fact that it can control any .B SANE backend. Thus, the exact set of command-line options depends on the capabilities of the selected device. To see the options for a device named .IR dev , invoke .B scanimage via a command-line of the form: .PP .RS .B scanimage \-\-help \-\-device\-name .I dev .RE .PP The documentation for the device-specific options printed by .B \-\-help is best explained with a few examples: \-l 0..218mm [0] .br Top-left x position of scan area. .PP .RS The description above shows that option .B \-l expects an option value in the range from 0 to 218 mm. The value in square brackets indicates that the current option value is 0 mm. Most backends provide similar geometry options for top-left y position (\-t), width (\-x) and height of scan-area (\-y). .RE \-\-brightness \-100..100% [0] .br Controls the brightness of the acquired image. .PP .RS The description above shows that option .B \-\-brightness expects an option value in the range from \-100 to 100 percent. The value in square brackets indicates that the current option value is 0 percent. .RE \-\-default\-enhancements .br Set default values for enhancement controls. .PP .RS The description above shows that option .B \-\-default\-enhancements has no option value. It should be thought of as having an immediate effect at the point of the command-line at which it appears. For example, since this option resets the .B \-\-brightness option, the option-pair .B \-\-brightness 50 \-\-default\-enhancements would effectively be a no-op. .RE \-\-mode Lineart|Gray|Color [Gray] .br Selects the scan mode (e.g., lineart or color). .PP .RS The description above shows that option .B \-\-mode accepts an argument that must be one of the strings .BR Lineart , .BR Gray , or .BR Color . The value in the square bracket indicates that the option is currently set to .BR Gray . For convenience, it is legal to abbreviate the string values as long as they remain unique. Also, the case of the spelling doesn't matter. For example, option setting .B \-\-mode col is identical to .BR "\-\-mode Color" . .RE \-\-custom\-gamma[=(yes|no)] [inactive] .br Determines whether a builtin or a custom gamma-table .br should be used. .PP .RS The description above shows that option .B \-\-custom\-gamma expects either no option value, a "yes" string, or a "no" string. Specifying the option with no value is equivalent to specifying "yes". The value in square-brackets indicates that the option is not currently active. That is, attempting to set the option would result in an error message. The set of available options typically depends on the settings of other options. For example, the .B \-\-custom\-gamma table might be active only when a grayscale or color scan-mode has been requested. Note that the .B \-\-help option is processed only after all other options have been processed. This makes it possible to see the option settings for a particular mode by specifying the appropriate mode-options along with the .B \-\-help option. For example, the command-line: .PP .B scanimage \-\-help \-\-mode .I color .PP would print the option settings that are in effect when the color-mode is selected. .RE \-\-gamma\-table 0..255,... .br Gamma-correction table. In color mode this option .br equally affects the red, green, and blue channels .br simultaneously (i.e., it is an intensity gamma table). .PP .RS The description above shows that option .B \-\-gamma\-table expects zero or more values in the range 0 to 255. For example, a legal value for this option would be "3,4,5,6,7,8,9,10,11,12". Since it's cumbersome to specify long vectors in this form, the same can be expressed by the abbreviated form "[0]3-[9]12". What this means is that the first vector element is set to 3, the 9-th element is set to 12 and the values in between are interpolated linearly. Of course, it is possible to specify multiple such linear segments. For example, "[0]3-[2]3-[6]7,[7]10-[9]6" is equivalent to "3,3,3,4,5,6,7,10,8,6". The program .B gamma4scanimage can be used to generate such gamma tables (see .BR gamma4scanimage (1) for details). .RE .br \-\-filename [/tmp/input.ppm] .br The filename of the image to be loaded. .PP .RS The description above is an example of an option that takes an arbitrary string value (which happens to be a filename). Again, the value in brackets show that the option is current set to the filename .BR /tmp/input.ppm . .RE .SH ENVIRONMENT .TP .B SANE_DEFAULT_DEVICE The default device-name. .SH FILES .TP .I @CONFIGDIR@ This directory holds various configuration files. For details, please refer to the manual pages listed below. .TP .I ~/.sane/pass This file contains lines of the form .PP .RS user:password:resource .PP scanimage uses this information to answer user authorization requests automatically. The file must have 0600 permissions or stricter. You should use this file in conjunction with the \-\-accept\-md5\-only option to avoid server-side attacks. The resource may contain any character but is limited to 127 characters. .SH "SEE ALSO" .BR sane (7), .BR gamma4scanimage (1), .BR xscanimage (1), .BR xcam(1) , .BR xsane(1) , .BR scanadf (1), .BR sane\-dll (5), .BR sane\-net (5), .BR sane\-"backendname" (5) .SH AUTHOR David Mosberger, Andreas Beck, Gordon Matzigkeit, Caskey Dickson, and many others. For questions and comments contact the sane\-devel mailinglist (see http://www.sane\-project.org/mailing\-lists.html). .SH BUGS For vector options, the help output currently has no indication as to how many elements a vector-value should have. sane-backends-1.0.29/doc/sane-canon630u.man0000666000000000000000000000724613615534521015114 00000000000000.TH sane\-canon630u 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-canon630u .SH NAME sane\-canon630u \- SANE backend for the Canon 630u USB flatbed scanner .SH DESCRIPTION The .B sane\-canon630u library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Canon flatbed scanners: .PP .RS CanoScan 630u .br CanoScan 636u .br .RE .PP Color scanning is supported at 75, 150, 300, and 600 dpi, and gamma and analog gain are adjustable. .PP TESTERS ARE WELCOME. Send your bug reports and comments to Nathan Rutman .PP .SH CONFIGURATION The contents of the .I canon630u.conf file is a list of device names that correspond to Canon USB scanners. Empty lines and lines starting with a hash mark (#) are ignored. Only one device name can be listed in .IR canon630u.conf . The program .IR sane\-find\-scanner helps to find out the correct device. Under Linux, such a device name could be .I /dev/usb/scanner0 for example. See sane\-usb(5) for details. .PP This product-specific scanner driver uses the lower-level kernel USB driver "scanner". Check for "Driver=usbscanner" under /proc/bus/usb/devices. If "Driver=(none)", try forcing it with "insmod scanner vendor=0x04a9 product=0x2204" .SH NOTES .PP Due to Canon's unwillingness to provide scanner documentation, this software was developed by analyzing the USB traffic of the Windows 2000 driver. So things like the calibration procedure I kind of made up; it seems to work for my scanner. If you have complaints, let me know. .PP This driver requires the ability to send USB Control Messages, available in kernel 2.4.12 or later. .PP Some users have reported that this driver doesn't work at all. This seems to be a hardware specific issue, although I don't know what exactly the problem is. If you are having problems, please send me the info in /proc/bus/usb/devices, /proc/pci, the kernel scanner.c driver version from /var/log/messages, and the output from "SANE_DEBUG_CANON630U=12 scanimage > /dev/null" .PP .SH FILES .TP .I @CONFIGDIR@/canon630u.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-canon630u.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-canon630u.so The shared library implementing this backend (present on systems that support dynamic loading). .TP .I /tmp/canon.cal The calibration file used to normalize pixel brightness. This is calculated every time the scanner is first used after it has lost power. Deleting this file will force recalibration. .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_CANON630U If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: .br SANE_DEBUG_CANON630U=12 scanimage > /dev/null .SH "SEE ALSO" sane(7), sane\-usb(5), sane\-find\-scanner(1) .br http://canon-fb630u.sourceforge.net/ .br .SH AUTHOR Nathan Rutman sane-backends-1.0.29/doc/canon/0000755000000000000000000000000013615535552013125 500000000000000sane-backends-1.0.29/doc/canon/canon.install2700F.txt0000666000000000000000000001143713615534521016775 00000000000000 ----------------------------------------------------------------------- How to install a CanoScan 2700F on a Linux box ? by Stephan Hegel . Date: Fri Jan 15 16:13:15 MEZ 1999 ----------------------------------------------------------------------- Here is a short description on how to install the CanoScan 2700F film and slide scanner on a Linux box. Actually it was just written as a reminder for myself but I think it is a good idea to add it to Manuel Panea's Canon backend package. Please remember that there is NO GUARANTEE that this step by step instruction works also for you. Corrections and suggestions are welcome, of course. Thank you. 1. How to install an Adaptec AVA-1502AP ? ----------------------------------------- The AVA-1502AP is is a small ISA Adaptec SCSI controller which is shipped with the CanoScan slide scanner. Per default is has the address 0x140, the IRQ 10 and the SCSI host id 7. Check first for conflicts with your already existing hardware. Install the controller into the computer. After starting the BIOS should detect the board as a PNP board. Boot the computer with the "SCSISelect" disk which is shipped with the scanner to check that the controller is detected. Don't change any settings except address, IRQ or SCSI id if necessary. Configure a new Linux kernel (version 2.0.30 or newer) with: SCSI Support (yes) SCSI Generic support (yes) Low level driver for aha152x (yes) Note: here you can try to compile the SCSI support as modules as long as you don't boot the computer from a SCSI disk. But this is not tested. Compile and install the new Linux kernel. Add "aha152x=0x140,10,7" to the "append" line to the already existing kernel parameters in lilo.conf, e.g: ------------------- # Linux bootable partition config begins image = /vmlinuz root = /dev/hdc1 label = linux append = "sbpcd=0x230,SoundBlaster aha152x=0x140,10,7" # Linux bootable partition config ends ------------------- Invoke lilo to activate the changes. Reboot the computer and watch the boot messages. The SCSI host adapter should be there now. 2. How to connect the scanner ? ------------------------------ Shutdown and turn off the computer, connect the scanner with the SCSI cable to the SCSI adapter. Set the SCSI Id with the turn-switch at the back of the scanner body. I'm using SCSI Id 1 with "termination on" since the scanner is the one and only device connected to my host adapter. Turn on the scanner first and wait for a few second. The scanner performs a short self test. Turn on the computer. Watch the boot messages, there should be a message indicating that the SCSI host adapter and the scanner are there. Now you can check again that the scanner device is there: cat /proc/scsi/scsi Should print something like that: Host: scsi0 Channel: 00 Id: 01 Lun: 00 Vendor: CANON Model: IX-27015C Rev: 1.17 Type: Scanner ANSI SCSI revision: 02 3. How to install SANE for the Canon 2700 film scanner ? -------------------------------------------------------- Fetch the latest SANE distribution from the SANE homepage at: http://www.sane-project.org/ Unpack and configure it. Get the latest canon backend from Manuel's homepage: http://www.rzg.mpg.de/~mpd/sane Put the files in the sane/backend directory as described in the README of the package. This overwrites the existing canon.* files with the latest version of these files. Compile and install SANE. Add the "canon" scanner to the /usr/local/etc/sane.d/dll.conf file: -------- cut here ------------ # enable the next line if you want to allow access through the network: #net pnm #mustek #hp #qcam #umax canon -------- cut here ------------ Add a "canon.conf" file to the /usr/local/etc/sane.d directory: -------- cut here ------------ scsi CANON -------- cut here ------------ Check the available scanners: scanimage -L This should give something like this: device `canon:/dev/sg0' is a CANON IX-27015C film scanner device `pnm:0' is a Noname PNM file reader virtual device device `pnm:1' is a Noname PNM file reader virtual device Invoke the frontend: xscanimage & NOTE: The "xscanimage" frontend is in the SANE distribution. There is also another SANE frontend available which is called "xsane" by Oliver Rauch. It is still under heavy development and can be grabbed from: http://www.wolfsburg.de/~rauch A dialog box appears, select the canon scanner and here we go ... Happy scanning !!! ----------------------------------------------------------------------- sane-backends-1.0.29/doc/canon/canon.changes0000666000000000000000000000246013615534521015476 00000000000000 Version 991108: * Negative mask removal. This is a major change. Negatives get scanned *a lot* better now, meaning that you get good-looking colors. * Select native scanning resolutions, contributed by Stefan Scherer . * Support for Automatic Document Feeder (ADF), contributed by Jonathan Adams . * Corrected some namings of variables which caused problems when using the backend with 'xsane' or with the command-line 'scanimage'. I have not tested it myself with 'xsane' yet. * For your information, and because some users had problems with the previous versions and some kernels, I use kernel 2.2.12 and have SCSI support as modules (the modules which I have to load before using the scanner are scsi_mod, aha152x and sg). =========================================================================== Version 990201: * New code for the transparency unit by Markus Mertinat. * "Manual focus" was there, but I had not noticed that it didn't really work. Now it does. * Changed the names of some options, because xscanimage worked ok, but not scanimage. * When using high resolutions, "Auto Exposure" for slides is now much faster because it sets the resolution down first. * I have included a new directory containing scripts I find useful. sane-backends-1.0.29/doc/sane-qcam.man0000666000000000000000000000611313615534521014311 00000000000000.TH sane\-qcam 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-qcam .SH NAME sane\-qcam \- SANE backend for Connectix QuickCam cameras .SH DESCRIPTION The .B sane\-qcam library implements a SANE (Scanner Access Now Easy) backend that provides access Connectix QuickCam cameras. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I port .RE .PP Where .I port is the I/O port address at which the device resides. This address is normally specified in hexadecimal using C syntax (e.g., 0x37b) and may be prefixed with the letter "u" (e.g., u0x37b) to force the backend to access the camera in uni-directional mode. .SH CONFIGURATION The contents of the .I qcam.conf file is a list port addresses that may be connected to a Connectix QuickCam. Empty lines and everything starting from a hash mark (#) up to the end of a line are ignored. A sample configuration file is shown below: .PP .RS 0x37b # /dev/lp0 .br 0x378 # /dev/lp1 .br u0x278 # /dev/lp2 forced in uni-directional mode .br 0x3bc # /dev/lp0 (alternate address) .RE .PP In general, it is safest to list only the port addresses that really correspond to a QuickCam. For example, if one of the listed addresses actually connect to a printer, then starting up this backend will cause the printer to perform a device reset (which is generally undesirable). .SH FILES .TP .I @CONFIGDIR@/qcam.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-qcam.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-qcam.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_QCAM If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH AUTHOR David Mosberger .SH BUGS Support is currently limited to the color version of the QuickCam. The black-and-white camera is starting to work too, but I don't believe it works in all cases yet. Reportedly, acquiring images of certain sizes work fine, but others result in shifted images (sounds like a problem due to byte-padding). .PP The program needs root-privileges since it needs to be able to access the camera's I/O ports. .SH SEE ALSO sane(7) sane-backends-1.0.29/doc/sane-pixma.man0000666000000000000000000003567513615534521014525 00000000000000.TH "sane\-pixma" "5" "28 Dec 2019" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-pixma .SH NAME sane\-pixma \- SANE backend for Canon Multi-Function Printers and CanoScan Scanners .SH DESCRIPTION The .B sane\-pixma library implements a SANE (Scanner Access Now Easy) backend that provides access to Canon PIXMA / i-SENSYS / imageCLASS / imageRUNNER multi-function devices (All-in-one printers) and the Canon CanoScan Flatbed/TPU scanners. The backend implements both the USB interface and network interface (using Canon's BJNP and MFNP protocols). The network interface supports scanners over IPv4 as well as IPv6 (MFNP over IPv6 is untested). .PP Currently, the following models work with this backend: .PP .RS PIXMA E510 .br PIXMA G2000, G2010, G2100 .br PIXMA MG2100, MG2200, MG2400, MG2500, MG2900, MG3000, MG3100 .br PIXMA MG3200, MG3500, MG3600, MG4200, MG5100, MG5200, MG5300 .br PIXMA MG5400, MG5500, MG5600, MG5700, MG6100, MG6200, MG6300 .br PIXMA MG6400, MG7100, MG7500, MG7700, MG8200 .br PIXMA MP140, MP150, MP160, MP170, MP180, MP190 .br PIXMA MP210, MP220, MP230, MP240, MP250, MP260, MP270, MP280 .br PIXMA MP360, MP370, MP390 .br PIXMA MP450, MP460, MP470, MP480, MP490 .br PIXMA MP500, MP510, MP520, MP530, MP540, MP550, MP560 .br PIXMA MP600, MP600R, MP610, MP620, MP630, MP640 .br PIXMA MP700, MP710, MP730, PIXMA MP750 (no grayscale) .br PIXMA MP800, MP800R, MP810, MP830 .br PIXMA MP960, MP970, MP980, MP990 .br PIXMA MX300, MX310, MX330, MX340, MX350, MX360, MX370 .br PIXMA MX410, MX420, MX470, MX510, MX520, MX530, MX700, MX720 .br PIXMA MX850, MX860, MX870, MX882, MX885, MX890, MX920, MX7600 .br PIXMA TS3100, TS5000, TS6100, TS6200, TS8000, TS8200 .br PIXUS MP10 .br imageCLASS MF634Cdw, MF733Cdw .br imageCLASS MF3110, MF3240, MF4010, MF4018 .br imageCLASS MF4120, MF4122, MF4140, MF4150 .br imageCLASS MF4270, MF4350d, MF4370dn, MF4380dn .br imageCLASS MF4410, MF4430, MF4570dw, MF4660, MF4690 .br imageCLASS MF5730, MF5770, MF6550, MPC200 .br imageCLASS D420, D480, D530, D570 .br i-SENSYS MF210, MF230, MF240, MF620, MF630, MF640, MF645C, MF730 .br i-SENSYS MF731/733, MF741/743, MF3010, MF4320d, MF4330d, MF4500 .br i-SENSYS MF4700, MF4800, MF6100, MF8030, MF8200C, MF8300 .br imageRUNNER 1020/1024/1025, 1133 .br CanoScan 8800F, 9000F, 9000F Mark II .br CanoScan LiDE 300, 400 .br MAXIFY MB2000, MB2100, MB2300, MB2700, MB5000, MB5400 .RE .PP The following models are not well tested and/or the scanner sometimes hangs and must be switched off and on. .PP .RS PIXMA MP760, MP770, MP780, MP790 .RE .PP The following models may use the same Pixma protocol as those listed above, but have not yet been reported to work (or not). They are declared in the backend so that they get recognized and activated. Feedback in the sane\-devel mailing list welcome. .PP .RS PIXMA E400, E410, E460, E470, E480, E500, E560, E600, E610 .br PIXMA E3100, E3300, E4200 .br PIXMA MG4100, MG6500, MG6600, MG6800, MG6900, MG8100 .br PIXMA MP375R, MP493, MP495, MP740 .br PIXMA MX320, MX390, MX430, MX450, MX490, MX710 .br PIXMA G3000, G3010, G4000, G4010, G6000, G6080 .br PIXMA TR4500, TR7500, TR7530, TR8500, TR8530, TR8580, TR9530 .br PIXMA TS5100, TS6000, TS6130, TS6180, TS6230, TS6280, TS6300 .br PIXMA TS6330, TS6380, TS7330, TS8100, TS8130, TS8180, TS8230 .br PIXMA TS8280,, TS8300, TS8330, TS8380, TS9000, TS9100, TS9180 .br PIXMA TS9500, TS9580 .br PIXUS MP5, XK50, XK60, XK70, XK80 .br imageCLASS MF810/820, MF5630, MF5650, MF5750, MF8170c .br imageCLASS MPC190, D550 .br i-SENSYS MF110, MF220, MF260, MF410, MF420, MF510, MF520, MF740 .br i-SENSYS MF5880dn, MF5900, MF6680dn, MF8500C .br MAXIFY MB5100, MB5300 .RE .PP The following models may use partly the same Pixma protocol as other devices listed above, but may still need some work. They are declared in the backend as experimental and need the environment variable PIXMA_EXPERIMENT=1 to get recognized and activated. Snoop logs are required to further investigate, please contact the sane\-devel mailing list. .PP .RS \-\- none \-\- .RE .PP The backend supports: .PP .RS * resolutions of 75, 150, 300, 600, 1200, 2400, 4800, and 9600 DPI (some maybe buggy), .br * color and grayscale mode, as well as lineart on certain models, .br * a custom gamma table, .br * Automatic Document Feeder, Simplex and Duplex. .br * Transparency Unit, 24 or 48 bits depth. Infrared channel on certain models. .RE .PP The device name for USB devices is in the form pixma:xxxxyyyy_zzzzz where x, y and z are vendor ID, product ID and serial number respectively. .PP Example: pixma:04A91709_123456 is a MP150. .PP Device names for BJNP/MFNP devices is in the form pixma:aaaa_bbbbb where aaaa is the scanners model and bbbb is the hostname or ip-adress. .PP Example: pixma:MF4800_192.168.1.45 is a MF4800 Series multi-function peripheral. .PP This backend, based on cloning original Canon drivers protocols, is in a production stage. Designed has been carried out without any applicable manufacturer documentation, probably never available. However, we have tested it as well as we could, but it may not work in all situations. You will find an up-to-date status at the project homepage. (See below). Users feedback is essential to help improve features and performances. .SH OPTIONS Besides "well-known" options (e.g. resolution, mode etc.) pixma backend also provides the following options, i.e. the options might change in the future. .br The button status can be polled i.e. with 'scanimage \-A'. .br Button scan is disabled on MAC OS X due to darwin libusb not handling timeouts in usb interrupt reads, but may work when using the network protocol. .TP .I adf\-wait This option enables and sets the time in seconds waiting for a document inserted into the .BR Automatic .BR Document .BR Feeder . The maximum allowed waiting time is 3600 sec (= 1 hour). .TP .I button\-controlled This option can be used by applications (like .BR scanadf (1) and .BR scanimage (1)) in batch mode, for example when you want to scan many photos or multiple-page documents. If it is enabled (i.e. is set to true or yes), the backend waits before every scan until the user presses the "SCAN" button (for MP150) or the color-scan button (for other models). Just put the first page in the scanner, press the button, then the next page, press the button and so on. When you finished, press the gray-scan button. (For MP150 you have to stop the frontend by pressing Ctrl-C for example.) .TP .I button\-update (deprecated) (write only) In the past this option was required to be set to force reading of the button status for .I button\-1 and .I button\-2. The .B sane\-pixma no longer requires this option to be used: if no fresh data is available, it will be now requested automatically from the scanner. This option is left for backward compatibility reasons. .TP .I button\-1 button\-2 (read only) These options will return the value of the respective buttons. value 0 means that the button was not pressed, 1 is returned when the button was pressed. Some scanners with more than two buttons send the button number as target. .TP .I original (read only) Returns the value of the type or size of original to be scanned if the scanner provides that data. Known values of type: 1 = document, 2 = foto, 5 = film. Known values of size: 1 = A4, 2 = Letter, 8 = 10x15, 9 = 13x18, b = auto. Not all scanners can provide this data. .TP .I target (read only) Returns the value of the target of the scan operation if the scanner provides that data. The values depend on the scanner type. Known values: 1 = save to disk, 2 = save to pdf, 3 = send to email, 4 = send to application or 1 = JPEG, 2 = TIFF, 3 = PDF, 4 = Compact PDF. For some scanners this value is equivalent to the number of the pressed button. Not all scanners can provide this data. .TP .I scan-resolution (read only) Returns the resolution of the scan operation if the scanner provides that data. Known values: 1 = 75 dpi, 2 = 150 dpi, 3 = 300 dpi, 4 = 600 dpi. Not all scanners can provide this data. .SH FILES .TP .I @LIBDIR@/libsane\-pixma.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-pixma.so The shared library implementing this backend (present on systems that support dynamic loading). .TP .I @CONFIGDIR@/pixma.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .RS .PP The file contains an optional list of networked scanners using the BJNP or MFNP protools (See below for datails on networking support for scanners). Normally only scanners that cannot be auto-detected because they are on a different subnet shall be listed here. If you do not use Linux and your OS does not allow enumeration of interfaces (i.e. it does not support the getifaddrs() function) you also may need to add your scanner here as well. .PP .I Scanners shall be listed in the configuration file as follows: .PP .RS .I ://[:port][/timeout=] .RE .PP where method indicates the protocol used (bjnp is used for inkjet multi-functionals and mfnp is used for laser multi-functionals). .PP host is the hostname or IP address of the scanner, e.g. bjnp://10.0.1.4 for IPv4, bjnp://[2001:888:118e:18e2:21e:8fff:fe36:b64a] for a literal IPv6-address or bjnp://myscanner.mydomain.org for a hostname. .PP The port number is optional and in normally implied by the method. Port 8610 is the standard port for mfnp, 8612 for bjnp. .PP A scanner specific timeout value for the network protocol can be set using the bjnp-timeout parameter. The value is in ms. .PP Define scanners each on a new line. .PP More globally applicable timeouts can be set using the bjnp-timeout parameter as follows: .PP .RS .I bjnp-timeout= .RE .PP A timeout defined using bjnp-timeout will apply to the following scanner definitions in the file. If required the bjnp-timeout setting can be defined multiple times, where each settng will apply only to the scanners that follow the setting. The last setting is used for the auto discovered scanners. If not explicitly set, the default 1000ms setting will apply. .PP Setting timeouts should only be required in exceptional cases. .PP .RE .PP If so desired networking can be disbled as follows: .RS .IP - If the first non-commented line contains .B networking=no all networking will be disabled. This will cause all further statements in the configuration file to be ignored. .IP - A line that contains .B auto_detection=no will cause auto-detection to be skipped. Explicitely defined network scanners will still be probed. .SH USB SUPPORT USB scanners will be auto-detected and require no configuration. .SH NETWORKING SUPPORT The pixma backend supports network scanners using the so called Canon BJNP and MFNP protocols. .PP Canon seems to be dropping support for these protocols in recent scanners. To verify if your scanner supports one of these protocols, check the content of the _scanner._tcp service entry in mDNS/DNS-SD (using for example avahi-discover). If that does not list port 8610 or 8612 your scanner probably does not support the mfmp or bjnp protols. .PP Both IPv4 and IPv6 are supported, but IPv6 is as yet untested with MFNP. Please report your results on the mailing list. .PP Configuration is normally not required. The pixma backend will auto-detect your scanner if it is within the same subnet as your computer if your OS does support this. .PP If your scanner can not be auto-detected, you can add it to the pixma configuration file (see above). .SH FIREWALLING FOR NETWORKED SCANNERS The sane pixma backend communicates with port 8610 for MFNP or port 8612 for BJNP on the scanner. So you will have to allow outgoing traffic TO port 8610 or 8612 on the common subnet for scanning. .PP Scanner detection is slightly more complicated. The pixma backend sends a broadcast on all direct connected subnets it can find (provided your OS allows for enumeration of all netowrk interfaces). The broadcast is sent FROM port 8612 TO port 8610 or 8612 on the broadcast address of each interface. The outgoing packets will be allowed by the rule described above. .PP Responses from the scanner are sent back to the computer TO port 8612. Connection tracking however does not see a match as the response does not come from the broadcast address but from the scanners own address. For automatic detection of your scanner, you will therefore have to allow incoming packets TO port 8612 on your computer. This applies to both MFNP and BJNP. .PP So in short: open the firewall for all traffic from your computer to port 8610 (for MFNP) or 8612 (for BJNP) AND to port 8612 (for both BJNP and MFNP) to your computer. .PP With the firewall rules above there is no need to add the scanner to the pixma.conf file, unless the scanner is on a network that is not directly connected to your computer. .SH ENVIRONMENT .TP .B SANE_DEBUG_PIXMA If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend itself. Higher value increases the verbosity and includes the information printed at the lower levels. .RS 0 print nothing (default) .br 1 print error and warning messages (recommended) .br 2 print informational messages .br 3 print debug-level messages .br 4 print verbose debug-level messages .br 11 dump USB traffic .br 21 full dump USB traffic .br .RE .TP .B SANE_DEBUG_BJNP If the library was compiled with debug support enabled, this environment variable controls the debug level for the .B BJNP and MFNP network protocols for this backend. Higher value increases the verbosity and includes the information printed at the lower levels. .RS 0 print nothing (default) .br 1 Print error and warning messages (recommended) .br 2 Print high level function tracing information .br 3 Print more detailed protocol tracing information .br 4 Print protocol headers .br 5 Print full protocol contents .RE .TP .B PIXMA_EXPERIMENT Setting to a non-zero value will enable the support for experimental models. You should also set SANE_DEBUG_PIXMA to 11. .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .SH "SEE ALSO" .BR sane (7), .BR sane\-dll (5), .PP In case of trouble with a recent Pixma model, try the latest code for the pixma backend, available in the Sane git repository at: .br .I https://gitlab.com/sane-project/backends.git .PP You can also post into the Sane-devel mailing list for support. .SH AUTHORS Wittawat Yamwong, Nicolas Martin, Dennis Lou, Louis Lagendijk, Rolf Bensch .PP We would like to thank all testers and helpers. Without them we could not be able to write subdrivers for models we don't have. See also the project homepage. sane-backends-1.0.29/doc/icons/0000755000000000000000000000000013615535553013143 500000000000000sane-backends-1.0.29/doc/icons/previous.gif0000666000000000000000000000033413615534521015424 00000000000000GIF89a?ñ¿¿¿çççooo[!ù,?­Œ©Ëí£œI€³Þ¼ûj‚„æ‰~ã•¶.¸–ïLq6äz ¼HÂir¿"æÖÛøŒ?$`)|J{»©ªÃ©ÄŒú\v­S­UM‚¡ß¬95£ã[0EÞâÜðrß5æô§WxE—øWeC˜—ö¨¦xÈæhyf¨ÉFf‰‡Y)ø¹'¸#ÆØˆÇÔ:ÈêÚê+ëHË4{[3Òëû ,ô®ËÍX6 Lø¹vbmbl2§Ñ'’ºœ^}WLvÈå…½ QPYÉ%óík²àârMæŽÏëñ½ÿ/P;sane-backends-1.0.29/doc/icons/contents.gif0000666000000000000000000000034113615534521015403 00000000000000GIF89aAñ¿¿¿çççooo[!ù,A²Œ©Ëí£œM€³Þ¼ûr‚„扆㕶®¹–ïLgñ6äCÍw–Îv/¢¤1b”(fS…\‚tÆnÄfÖì•ûÅü¸S)VH6›·ÄvÒMw”ntõ-O×Eq'zWEµ§§ÅÇ’‡¸¨†˜´5–HH©æG×ø'ÉÆ˜Wùøˆ)§ÅDõ§GÇi× Ù +[»Ak›‹›[»Ë3"N^n~þ‚®¾ÎÞ^;sane-backends-1.0.29/doc/icons/index.gif0000666000000000000000000000026413615534521014661 00000000000000GIF89a+ñ¿¿¿çççooo[!ù,+…Œ©Ëí—0 Ú‹³ÞVÌÀ…"çQãy– Ê’ß5°q ¨°Lׯ5Ÿ=kãUbƒ"ÌØ+¿^p8L ™³&”yyb·W+w[ÍoU¹¤b´á©÷w\Áå·¦]a_÷ç)ý«gƃt„Ç¥•Cƒ˜4ÇØhòز()¢â™©¹ÉÙ¹à*:Z;sane-backends-1.0.29/doc/icons/up.gif0000666000000000000000000000022113615534521014167 00000000000000GIF89añ¿¿¿çççooo[!ù,bŒ©Ë­b€œ´Z `¸üæØ…Ò·‰!9 –zjé*¢KÑœ Øó>ô®ËÍX6 Lø¹vbmbl2§Ñ'’ºœ^}WLvÈå…½ QPYÉ%óík²àârMæŽÏëñ½ÿ/P;sane-backends-1.0.29/doc/icons/references.gif0000666000000000000000000000036713615534521015677 00000000000000GIF87aQñ¿¿¿çççooo[,QÐŒ©Ëí£œ´2a€Þ¼û†â8 X@¦êÊ~fÖÆò¬½(碽 þOò醞fÀ†ÄfíÔë0ASçШf{À¬ò7E~»[²Wy4ƒ9Øj˜ùM˽ÜùØÏ“›ö: Ç·¸Gh¨eˆÒ6xÖ•÷ç&øAù†Ð8˜HèévÙ)*‚ÆiéQ)åȪúÔ¥ˆ¨÷Y;i×y{ëxªøw¬%ìü˜d†eµ¼¢Ìü¼# =Í(M} ƒ½mcâý .>N^n~þ‚®¾ÎÞ^;sane-backends-1.0.29/doc/icons/next.gif0000666000000000000000000000025413615534521014527 00000000000000GIF89a%ñ¿¿¿çççooo[!ù,%}Œ©Ëí¿„´Ú‹ó2èbÜ–ßè™êÖUö®bK ±+7€âûnÚõj:ËÍf#ú’”añùü)gŒy5Nq+÷Šdê¤]´˜ÍˆÏ^Ÿò’f›bj”ÛœÃXí¸L’£â$XBXrˆ¨¡¸8cÀ)9IYi`™©™Y;sane-backends-1.0.29/doc/sane-hp5590.man0000666000000000000000000002162113615534521014323 00000000000000.\" Automatically generated by Pandoc 2.7.2 .\" .TH "sane-hp5590" "5" "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .hy .SH NAME .PP sane-hp5590 - SANE backend for Hewlett-Packard 4500C/4570C/5500C/5550C/5590/7650 Workgroup/Document scanners .SH DESCRIPTION .PP The \f[B]sane-hp5590\f[R] library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Hewlett-Packard Workgroup/Document scanners: .IP \[bu] 2 ScanJet 4500C .IP \[bu] 2 ScanJet 4570C .IP \[bu] 2 ScanJet 5500C .IP \[bu] 2 ScanJet 5550C .IP \[bu] 2 ScanJet 5590 .IP \[bu] 2 ScanJet 7650 .PP If you own a scanner other than the ones listed above that works with this backend, please let us know this by sending the scanner\[cq]s exact model name and the USB vendor and device ids (e.g.\ from \f[I]/sys/bus/usb/devices\f[R], \f[I]sane-find-scanner\f[R] or syslog) to us. Even if the scanner\[cq]s name is only slightly different from the models mentioned above, please let us know. .SH OPTIONS .PP The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in \f[I]xscanimage\f[R] or \f[I]xsane\f[R]. Valid command line options and their syntax can be listed by using: .IP .nf \f[C] scanimage --help -d hp5590:interface:device \f[R] .fi .PP where \f[I]interface\f[R] and \f[I]device\f[R] specify the device in question, as in the configuration file. Add \f[I]--all-options\f[R] to also list the hardware read-out options. The -d parameter and its argument can be omitted to obtain information on the first scanner identified. .PP Use the command: .IP .nf \f[C] scanimage -L \f[R] .fi .PP to list all devices recognized by your SANE installation. .SH DEVICE SPECIFIC OPTIONS .TP .B -l \f[I]n\f[R] Top-left X position of scan area in \f[B]mm\f[R]. Allowed range: 0 .. 215.889. .TP .B -t \f[I]n\f[R] Top-left Y position of scan area in \f[B]mm\f[R]. Allowed range: 0 .. 297.699. .TP .B -x \f[I]n\f[R] X width of scan-area in \f[B]mm\f[R]. Allowed range: 0 .. 215.889. .TP .B -y \f[I]n\f[R] Y height of scan-area in \f[B]mm\f[R]. Allowed range: 0 .. 297.699. .PP By default, the maximum size will be scanned. .TP .B --mode \f[I]mode\f[R] Select color mode. \f[I]mode\f[R] must be one of: \[lq]Color\[rq], \[lq]Color (48 bits)\[rq], \[lq]Gray\[rq], \[lq]Lineart\[rq]. .RS .IP \[bu] 2 \[lq]Color\[rq] - Scanning is done with 3 * 8 bit RGB color values per pixel. .IP \[bu] 2 \[lq]Color (48 bits)\[rq] - Scanning is done with 3 * 16 bit RGB color values per pixel. .IP \[bu] 2 \[lq]Gray\[rq] - Scanning is done with 1 * 8 bit gray value per pixel. .IP \[bu] 2 \[lq]Lineart\[rq] - Scanning is done with 1 bit black and white value per pixel. .RE .TP .B --source \f[I]source\f[R] Select the source for scanning. \f[I]source\f[R] must be one of: \[lq]Flatbed\[rq], \[lq]ADF\[rq], \[lq]ADF Duplex\[rq], \[lq]TMA Slides\[rq], \[lq]TMA Negatives\[rq]. .RS .IP \[bu] 2 \[lq]Flatbed\[rq] - Scan document on the flat document glass. .IP \[bu] 2 \[lq]ADF\[rq] - Scan frontsides of documents with automatic document feeder. .IP \[bu] 2 \[lq]ADF Duplex\[rq] - Scan front- and backsides of documents with automatic document feeder. Note, the backside images must be rotated in a separate post process step. .IP \[bu] 2 \[lq]TMA Slides\[rq] - Slide scanning with transparent media adapter. (Not fully supported by hp5590 backend). .IP \[bu] 2 \[lq]TMA Negatives\[rq] - Negative film scanning with transparent media adapter. (Not fully supported by hp5590 backend). .RE .TP .B --resolution \f[I]res\f[R] Set the resolution of the scanned image in \f[B]dpi\f[R]. \f[I]res\f[R] must be one of: 100, 200, 300, 600, 1200, 2400. .PP Default settings: Lineart, Flatbed, 100dpi. .TP .B --extend-lamp-timeout[=yes|no] Extend lamp timeout period. no = 15 minutes, yes = 1 hour. (Default: no) .TP .B --wait-for-button[=yes|no] Wait for button press before scanning starts. (Default: no) .TP .B --preview[=yes|no] Request a preview-quality scan. (Default: no) .TP .B --hide-eop-pixel[=yes|no] Hide end-of-page indicator pixels and overwrite with color of next neighbor pixels. (Default: yes) .PD 0 .P .PD The scanner uses the last pixel in every scan line for storing the end-of-page status. This is needed to detect the end of the document sheet when the automatic document feeder (ADF) is used. Unfortunately the end-of-page pixels are also generated in flatbed scans. It is recommended to hide these pixels. .TP .B --trailing-lines-mode \f[I]mode\f[R] Filling mode of trailing lines after end of page when automatic document feeder (ADF) is used. \f[I]mode\f[R] must be one of: \[lq]last\[rq], \[lq]raw\[rq], \[lq]raster\[rq], \[lq]white\[rq], \[lq]black\[rq], \[lq]color\[rq]. (Default: \[lq]last\[rq]) .RS .IP \[bu] 2 \[lq]last\[rq] = repeat the last scan line (recommended), .IP \[bu] 2 \[lq]raw\[rq] = read raw scan data (not recommended), .IP \[bu] 2 \[lq]raster\[rq] = generate black and white pixel pattern, .IP \[bu] 2 \[lq]white\[rq] = white pixels, .IP \[bu] 2 \[lq]black\[rq] = black pixels, .IP \[bu] 2 \[lq]color\[rq] = RGB or gray colored pixels (see next option). .RE .TP .B --trailing-lines-color \f[I]n\f[R] Set color value for filling trailing scan lines in trailing lines mode \[lq]color\[rq] (see previous option). (Default color: violet) .PD 0 .P .PD The RGB color value must be specified and calculated as 65536 * r + 256 * g + b, with r, g, b being values in the range of 0 .. 255. .SH READ OUT OPTIONS .PP The following options allow reading out the button state, counter value, color setting, and the state of document in ADF. This can be used to programmatically control corresponding scanner options like switching between \f[I]flatbed\f[R] and \f[I]ADF\f[R] mode, or triggering prost processing tasks after scanning. .TP .B --button-pressed Get the id of the last button pressed. Id is one of \[lq]none\[rq], \[lq]power\[rq], \[lq]scan\[rq], \[lq]collect\[rq], \[lq]file\[rq], \[lq]email\[rq], \[lq]copy\[rq], \[lq]up\[rq], \[lq]down\[rq], \[lq]mode\[rq], \[lq]cancel\[rq]. .PD 0 .P .PD The scanner stores the id of the last button pressed until it is read. After read out, the state is reset and subsequent readings will return \[lq]none\[rq]. .TP .B --color-led Get the state of the color LED indicators. The state is either \[lq]color\[rq] or \[lq]black_white\[rq]. .TP .B --counter-value Get the counter value as shown on LCD. The value is in the range of 1 .. 99. .TP .B --doc-in-adf Get the state of the document-available indicator of the automatic document feeder (ADF). The state is either \[lq]yes\[rq] or \[lq]no\[rq]. .SH HINTS FOR USERS OF SCANBD .PP \f[I]Scanbd\f[R] is a scanner button daemon, which can read scanner buttons and trigger scan actions. .PP Do not use the old \f[I]scanbuttond\f[R] interface with hp5590. It is outdated and shall not be used any more. Scanbd\[cq]s regular interface is fully supported by the current version of the \f[I]hp5590\f[R] backend. .PP This example shows a minimum configuration file and the corresponding script file for scanbd to be included in \f[I]scanbd.conf\f[R]. .IP \[bu] 2 \f[B]hp5590.conf\f[R] .IP .nf \f[C] device hp5590 { # Device matching filter = \[dq]\[ha]hp5590.*\[dq] desc = \[dq]HP5590 Scanner Family\[dq] # Read out counter value and store in environment variable. function function_lcd_counter { filter = \[dq]\[ha]counter-value.*\[dq] desc = \[dq]hp5590: LCD counter\[dq] env = \[dq]SCANBD_FUNCTION_LCD_COUNTER\[dq] } # Run scan script when button is pressed. action do-scan { filter = \[dq]\[ha]button-pressed.*\[dq] desc = \[dq]hp5590: Scan button pressed\[dq] script = \[dq]scan_action.script\[dq] string-trigger { from-value = \[dq]none\[dq] to-value = \[dq]scan\[dq] } } } \f[R] .fi .IP \[bu] 2 \f[B]scan_action.script\f[R] .IP .nf \f[C] #!/bin/bash echo device = $SCANBD_DEVICE echo action = $SCANBD_ACTION echo counter = $SCANBD_FUNCTION_LCD_COUNTER scanfile=\[dq]$HOME/tmp/scans/scan-$(date +%s).pnm\[dq] case $SCANBD_ACTION in do-scan) scanimage -d \[dq]$SCANBD_DEVICE\[dq] > \[dq]$scanfile\[dq] ;; *) echo Warning: Unknown scanbd action: \[dq]$SCANBD_ACTION\[dq] ;; esac \f[R] .fi .SH FILES .TP .B \f[I]\[at]LIBDIR\[at]/libsane-hp5590.a\f[R] The static library implementing this backend. .TP .B \f[I]\[at]LIBDIR\[at]/libsane-hp5590.so\f[R] The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .PP If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. .PP \f[B]SANE_DEBUG_HP5590\f[R] .PP Higher debug levels increase the verbosity of the output: .IP .nf \f[C] 10 - generic processing 20 - verbose backend messages 40 - HP5590 high-level commands 50 - HP5590 low-level (USB-in-USB) commands \f[R] .fi .TP .B Example: export SANE_DEBUG_HP5590=50 .SH SEE ALSO .PP \f[B]sane\f[R](7), \f[B]sane-usb\f[R](5) .SH AUTHORS Ilia Sotnikov . sane-backends-1.0.29/doc/sane-gphoto2.man0000666000000000000000000000746013615534521014760 00000000000000.TH sane\-gphoto2 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-gphoto2 .SH NAME sane\-gphoto2 \- SANE backend for gphoto2 supported cameras .SH DESCRIPTION The .B sane\-gphoto2 library implements a SANE (Scanner Access Now Easy) backend that provides access to the digital cameras supported by gphoto2. This backend has only been tested with a handful of cameras so far. Patches to support other models are welcome. .PP Because of the limited testing of this backend, it is commented out in @CONFIGDIR@/dll.conf by default. Either the comment character must be removed or the backend must be called explicitly. E.g. `scanimage \-d gphoto2' or `xscanimage gphoto2'. .SH "DEVICE NAMES" The current version of the backend only allows one camera to be connected. The device name is always "0". .SH CONFIGURATION The contents of the .I gphoto2.conf specify the characteristics of the camera to be used. Resolutions (high resolution, low resolution, and thumbnail size) are required since they are needed by the sane frontends, but can't be obtained through the gphoto2 interface. Valid ports and cameras can be obtained by "gphoto2 \-\-list\-cameras" and "gphoto2 \-\-list\-ports". .PP The dumpinquiry line causes some information about the camera to be printed. .PP Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP The "topfolder" line specifies the "fixed" part of the file path. For example, on the Kodak DC-240, files are stored in the directory /DCIM/100DC240. The /DCIM portion is constant, but 100DC240 will change and must be read from the camera. In this case, the line would read "topfolder=/DCIM" .PP Some cameras don't implement a file structure and store all pictures in the "/" directory. This is indicated by setting "subdirs=0" with "topfolder=/" .PP .RS port=usb: .br camera=Kodak DC240 .br # this is a comment .br high_resolution=1280x960 .br low_resolution=640x480 .br thumb_resolution=160x120 .br dumpinquiry .RE .PP .SH FILES .TP .I @CONFIGDIR@/gphoto2.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-gphoto2.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-gphoto2.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_GPHOTO2 If the library was compiled with debugging support enabled, this environment variable controls the debug level for this backend. A value of 128 requests maximally copious debug output; smaller levels reduce verbosity. .TP .B GP_DEBUG Set to 1, 2, or 3, to enable various levels of debugging within the gphoto2 libraries. .SH "SEE ALSO" sane(7) .SH AUTHOR Peter S. Fales .PP The manpage was largely copied from the dc210 manpage. .SH BUGS Many, no doubt. .PP More general comments, suggestions, and inquiries about frontends or SANE should go to the SANE Developers mailing list (see http://www.sane\-project.org/mailing\-lists.html for details). You must be subscribed to the list, otherwise your mail won't be sent to the subscribers. sane-backends-1.0.29/doc/sane-hp.man0000666000000000000000000002304013615534521013775 00000000000000.TH sane\-hp 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-hp .SH NAME sane\-hp \- SANE backend for HP ScanJet scanners .SH DESCRIPTION The .B sane\-hp library implements a SANE (Scanner Access Now Easy) backend that provides access to HP ScanJet scanners which support SCL (Scanner Control Language by HP). The following scanners are known positively to work with this backend: .PP .RS .ft CR .nf Model: Product id: Interface: ---------- ----------- ---------- ScanJet Plus C9195A HP Parallel Interface Card ScanJet IIc C1750A 3226 SCSI ScanJet IIcx C2500A 3332 SCSI ScanJet IIp C1790A SCSI ScanJet 3C C2520A 3503 SCSI ScanJet 3P C2570A 3406 SCSI ScanJet 4C C2520A SCSI ScanJet 4P C1130A 3540 SCSI ScanJet 4100C C6290A USB ScanJet 5P C5110A SCSI ScanJet 5100C C5190A parallel port ScanJet 5200C C7190A 3846 parallel port/USB ScanJet 6100C C2520A 3644 SCSI ScanJet 6200C C6270A 3828 SCSI/USB ScanJet 6250C C6270A 3828 SCSI/USB ScanJet 6300C C7670A SCSI/USB ScanJet 6350C C7670A SCSI/USB ScanJet 6390C C7670A SCSI/USB PhotoSmart C5100A R029,R030,R032 SCSI .fi .ft R .RE .PP Support for models 5100C/5200C connected to the parallel port requires the ppSCSI driver available at .I http://cyberelk.net/tim/parport/ppscsi.html and .IR http://penguin-breeder.org/kernel/download/ . .PP Support for models 5200C/62X0C/63X0C connected to the USB require the kernel scanner driver or libusb. See .BR sane\-usb (5) for more details. .PP The "hp" backend no longer supports OfficeJet multi-function peripherals. For these devices use the external "hpoj" backend in version 0.90 and later of the "HP OfficeJet Linux driver", available at .br .IR http://hpoj.sourceforge.net . .PP Because Hewlett-Packard does no longer produce scanners that support SCL (beside the OfficeJets), the above list of supported scanners is complete. Other HP scanners are not supported by the "hp" backend, but might be supported by another one. See .IR http://www.sane\-project.org/ . You can also watch the sane\-devel mailing list at .IR http://www.sane\-project.org/mailing\-lists.html . .PP More details about the hp backend can be found on its homepage .IR http://www.kirchgessner.net/sane.html . .PP .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the UNIX path-name for the special device that corresponds to the scanner. For SCSI scanners the special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sg2 , for example. If the special device name contains "usb", "uscanner" or "ugen", it is assumed that the scanner is connected by USB. For the HP ScanJet Plus the special device name must be the device that corresponds to the parallel interface card that was shipped with the scanner. That is .IR /dev/hpscan . A special driver is required for this card. See ftp://rvs.ctrl\-c.liu.se/pub/wingel/hpscan for details. If the link does not work, try ftp://sunsite.unc.edu/pub/Linux/kernel/patches/scanners. .SH CONFIGURATION The contents of the .I hp.conf file is a list of options and device names that correspond to HP ScanJet scanners. Empty lines and lines starting with a hash mark (#) are ignored. See .BR sane\-scsi (5) and .BR sane\-usb (5) on details of what constitutes a valid device name. .PP Options specified in front of the first line that contains a device name are defaults for all devices. Options specified below a line that contains a device name apply just to the most recently mentioned device. .PP Supported options are .BR connect\-scsi , .BR connect\-device , .BR enable\-image\-buffering , and .BR dumb\-read . Option .B connect\-scsi specifies that the scanner is connected to the system by SCSI. Input/output is performed using SCSI-commands. This is the default. But if your SCSI device name contains "usb", "uscanner" or "ugen", option connect\-scsi must be specified. Otherwise it is assumed that the scanner is connected by USB. Option .B connect\-device specifies that the scanner is connected to the system by a special device. Input/output is performed by read()/write()-operations on the device. This option must be used for HP ScanJet Plus or scanners connected to USB which are accessed through a named device (e.g. /dev/usb/scanner0). For device names that contain "usb", "uscanner" or "ugen", it is not necessary to specify option connect\-device. Option .B enable\-image\-buffering stores the scanned image in memory before passing it to the frontend. Could be used in case of forward/backward moving scanner lamp. Option .B dumb\-read can be used to work around problems with "Error during device I/O". These problems may occur with certain SCSI-to-USB converters or Buslogic SCSI cards. The option should not be used for SCSI devices which are working correctly. Otherwise startup of frontends and changing parameters might be slower. .PP A sample configuration file is shown below: .PP .RS .ft CR .nf /dev/scanner # this is a comment /dev/hpscan option connect\-device .fi .ft R .RE .PP /dev/scanner is typically a symlink to the actual SCSI scanner device. .RE .SH FILES .TP .I @CONFIGDIR@/hp.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-hp.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-hp.so The shared library implementing this backend (present on systems that support dynamic loading). .TP .I $HOME/.sane/calib-hp:.dat Calibration data for HP PhotoSmart PhotoScanner that is retrieved from the scanner after calibration. The data is uploaded to the scanner at start of the backend if it is in media mode 'print media' or if the media mode is changed to 'print media'. .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_HP If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .TP .B SANE_HOME_HP Only used for OS/2 and along with use of HP PhotoSmart PhotoScanner. Must be set to the directory where the directory .sane is located. Is used to save and read the calibration file. .TP .B SANE_HP_KEEPOPEN_SCSI .TP .B SANE_HP_KEEPOPEN_USB .TP .B SANE_HP_KEEPOPEN_DEVICE For each type of connection (connect\-scsi, connect\-usb, connect\-device) it can be specified if the connection to the device should be kept open ("1") or not ("0"). Usually the connections are closed after an operation is performed. Keeping connection open to SCSI-devices can result in errors during device IO when the scanner has not been used for some time. By default, USB-connections are kept open. Other connections are closed. .TP .B SANE_HP_RDREDO Specifies number of retries for read operation before returning an EOF error. Only supported for non-SCSI devices. Default: 1 retry. Time between retries is 0.1 seconds. .SH BUGS .TP .B HP PhotoSmart PhotoScanner In media mode 'slide' and 'negative', scan resolutions are rounded to multiple of 300 dpi. The scanner does not scale the data correctly on other resolutions. Some newer models (firmware code R030 and later) do not support adjustment of contrast/intensity level and tone map. The backend will simulate this by software, but only for gray and 24 bit color. .TP .B Automatic Document Feeder (ADF) For use of the ADF with xscanimage(1), first place paper in the ADF and then change option scan source to 'ADF'. Press 'change document' to load a sheet. Then press 'scan' to start a scan. Maybe it is sufficient to press 'scan' without 'change document' for repeated scans. The use of the preview window is not recommended when working with the ADF. Setting a window to scan from ADF is not supported with xscanimage(1). Try xsane(1). .TP .B Immediate actions Some actions in xscanimage(1) (i.e. unload, select media, calibrate) have an immediate effect on the scanner without starting a scan. These options can not be used with scanimage. .SH TODO .TP .B HP PhotoSmart PhotoScanner PhotoScanners with firmware release R030 and up have no firmware support for contrast/brightness/gamma table. In the current backend this is simulated by software on 24 bits data. Simulation on 30 bits should give better results. .TP .B Data widths greater than 8 bits Custom gamma table does not work. .TP .B Parallel scanner support Beside the ScanJet Plus which came with its own parallel interface card, currently only the HP ScanJet 5100C/5200C are supported. These scanners are using an internal parallel-to-SCSI converter which is supported by the ppSCSI-driver (see above). .SH "SEE ALSO" sane(7), sane\-scsi(5), sane\-usb(5) .SH AUTHOR The sane\-hp backend was written by Geoffrey T. Dairiki. HP PhotoSmart PhotoScanner support by Peter Kirchgessner. sane-backends-1.0.29/doc/backend-writing.txt0000666000000000000000000005213613615534521015566 000000000000002019-08-26 Here are a few rules and tips that should help writing a SANE-conforming backend and including it into the SANE package: GETTING STARTED --------------- * You will need information about the protocol the scanner (or other image application device) is using. The easiest way is to ask the manufacturer about it. You should mention that the code will be open-source, however. * Read the SANE standard. * One approach is to write a stand-alone scanning program first. Debugging this program is usually easier than using the SANE libraries. However, keep in mind what you learned from the SANE standard. * Once your program works basically, insert its functions into a basically empty SANE backend. You can get one by removing everything but the SANE includes and SANE API function definitions from an existing backend (e.g. test.c). * If you have any information about the scanner you want to support that is not already mentioned in one of the .desc files, please contact the sane-devel mailing list. Especially if you have written code (e.g. a test program) or started writing a backend, contact us. * Keep other users informed about what you did and want to do. This way no work is done twice and you may get volunteers for coding or testing. Set up a website or at least write to sane-devel. If you have a website, a link to it can be included in the .desc file and users looking for that scanner will find it on the SANE website. * When you have a working backend but you don't want to have it included in the SANE distribution yet, at least the .desc file can be included (see below for details). So people will find a link to your backend at the SANE webpage. CONFIGURATION AND BUILD SYSTEM ------------------------------ Sane-backends uses the autoconf and automake tools. The configure script is generated from configure.ac and aclocal.m4 by running "autoreconf". Simple checks (e.g. for headers) should be placed into configure.ac while for more complex stuff acinclude.m4 is the right file. After changes in one of these files, "autoreconf" should be called. This will then call a chain of autotools, such as autoconf to generate configure, autoheader to generate include/sane/config.h.in, and automake to generate various Makefile.in's from Makefile.am's. When running configure, the Makefiles in the main and sub-directories are created from their respective Makefile.in files. Also include/sane/config.h which is included into to every c file is created from its .in file. Running "make" runs the respective targets in the sub directories recursively. The Makefile.am in each directory contains lists of files which are part of the distribution and which are therefore copied to the tar.gz archive, when a release is made. It's important that newly added files are also added to a variable that will cause them to be distributed (EXTRA_DIST at a minimum). For creating binaries and libraries libtool is used. The ltmain.sh script contains special modifications for SANE. These modifications ensure that the soname of each SANE backend library is "libsane.so". Without this change, backend libraries (like "libsane-epson.so") could not used as on-the-fly replacement for the dll backend. DIRECTORY OVERVIEW ------------------ This chapter explains some details about the files and directories used in the sane-backends distribution. sane-backends/ * acinclude.m4 aclocal.m4 compile config.guess config.sub configure configure.ac depcomp install-sh ltmain.sh Makefile.am Makefile.in missing mkinstalldirs: Part of the build system as explained above. * ChangeLog: The ChangeLog contains all the changes made since sane-backends-1.0.28 or a stub explaining how to create an up-to-date list of changes. ChangeLogs for all releases up to and including 1.0.28 can be found in the ChangeLogs/ directory. Please note that we skipped 1.0.26. * AUTHORS COPYING INSTALL LICENSE: General documentation + license. * NEWS: This is some kind of executive summary of the ChangeLog. It will be created before a release. * PROBLEMS: General (severe) problems that all SANE users should be aware. Backend-specific trouble should normally not mentioned there. * PROJECTS: Planned SANE-related development (e.g. ports, frontends). New backends won't be listed here but a new .desc file will be created for them (see below). * README: General building instructions. * README.aix README.beos (...): Platform-dependent building and usage instructions. sane-backends/backend/ This is where the actual backend code is placed. As an example the file structure for a backend named "newbackend" is listed below. Backend names must be unique and should not contain any special characters. Lower case letters, numbers and underscores "_" are ok. Backend documentation of any kind should not be placed here but in the doc/ directory. Code which is useful for more than one backend should be placed in sanei/ instead. * newbackend.c: The main backend file, usually contains the SANE API code. Mandatory. * newbackend.h: Header file, containing includes and so on. * newbackend.conf.in: Configuration file for the backend, newbackend.conf will be created by running "make" from this file. Some variables are substituted, e.g. for installation directories. This is especially useful for firmware directories. See Makefile.am for a list. * newbackend-low.c: Contains low level code for the "newbackend" backend. Depending on the complexity of the backend, splitting it to several files can be appropriate, the total number of files shouldn't exceed approx. 10, however. Other files: * Makefile.am, Makefile.in: Makefile.am contains rather complex rules for building the backends. For adding backends, special care should be taken concerning the FIRMWARE_DIRS (add your backend name here, if your scanner needs firmware files) and other variables (see build system description). There is some documentation inside of Makefile.am on what needs to be added and where. At a minimum, a convenience library of form lib${backend}.la and a installed library libsane-${backend}.la must be defined. Any sanei objects referenced should be listed in a libsane_${backend}_la_LIBADD line. * sane_strstatus.c: Contains the code for the sane_strstatus() function to avoid code duplication in every backend. sane-backends/doc/ Documentation for SANE. For some more details, see chapter DOCUMENTATION below. Again an example for "newbackend": * sane-newbackend.man: The manual page of the backend. From this file, "sane-newbackend.5" is generated by running "make". * newbackend/ (directory) Contains additional information about newbackend, e.g. READMEs or TODO files. General files: * Makefile.am: "sane-newbackend.5" must be added to variable BACKEND_5MANS and "sane-newbackend.man" to EXTRA_DIST. A backend documentation directory (if used) must be added to the BEDOCS variable. * backend-writing.txt: This file. * descriptions.txt: Describes the format of .desc files. * doxygen-sanei.conf.in: Used by doxygen to create the documentation of the sanei code. * releases.txt: Explains how to make releases of sane-backends. * sane.tex, net.tex: Contains the LaTeX source of the SANE standard. * descriptions/ (directory) Contains the .desc files for every backend that is included into sane-backends. * descriptions-external/ (directory) Contains the .desc files for backend that are not included into sane-backends yet (external backends). These files should only be created if the code it points to is really a SANE backend (and not just a command line program). sane-backends/frontend/ Contains the frontends scanimage, saned, and tstbackend. sane-backends/include/ Header files used by the SANE backends. The main directory contains the headers used for general librar functions like getopt, while the SANE-specific headers are located in include/sane/: * config.h.in: Main header file needed for portablility. config.h is created from this file and must be included by every backend. * sane.h: Official SANE API header file. Don't change this without discussion on the sane-devel mailing list. * saneopts.h: Defines several option NAMEs, TITLEs and DESCs that are (or should be) used by several backends. * sanei_*: Sanei (SANE internal) headers. Needed for code used in several backends like USB access. For more details, see the documentaion on the SANE website. sane-backends/japi/ Contains Java interface for SANE. See README.JAVA for details. sane-backends/lib/ Contains various library functions that may miss in the standard C library of some platforms. sane-backends/po/ Translations of SANEbackend options. See README for details. sane-backends/sanei/ Sanei (SANE internal) code. Needed for code used in several backends like USB access. For more details, see the documentaion on the SANE website. sane-backends/testsuite/ Testsuite for SANE. See README for details. sane-backends/tools/ Contains several tools for SANE. There are backend-specific and general command line tools as well as the hotplug support and .desc file generation code. See README for details. PROGRAMMING ----------- * A backend library is always only one file (libsane-backendname.so). Please do not use multiple libraries e.g. for lower and higher level code. * To add the backend to the existing SANE code, the following must be done at least: - add the backend name to ALL_BACKENDS in configure.ac (and run autoreconf) - Add new backend to BACKEND_CONFS, be_convenience_libs, be_dlopen_libs, and define _lib${backend}_la_SOURCES and nodist_libsane_${backend}_la_SOURCES; using an existing backend as a template. Any sanei reference code should be listed in libsane_${backend}_la_LIBADD as well as any external libraries required to resolve all symbols. - Add the source code files to the backend/ directories. All file names must start with the backend name (e.g. newbackend.c, newbackend.h and newbackend-usb.c). * Please follow the GNU coding standards. It's clear that the style outlined there is nobody's favorite, but it's much easier to maintain SANE if everybody follows more or less the same coding style. It also looks more professional. The GNU standards can be found at: http://www.gnu.org/prep/standards_toc.html ftp://ftp.gnu.org/pub/gnu/standards/standards.text Note that GNU emacs supports automatic indentation according to this standard. The command "indent -gnu" can be used to reformat existing sources according to this standard. * Please be courteous to programmer's with terminals that are 80 characters wide. It's not difficult to avoid long lines, so please do so. Note that in standard C you can split long strings into pieces separated by white space. For example, "this is an awfully long string" can be written as "this is an " "awfully long string". * Use only standard C for your backend. ISO C99 support will be enabled if supported by the compiler detected by configure. * Please do not depend on compiler specific features or, if you do, make the dependency conditional so other compilers will still be able to compile the files. In particular: - do not declare dynamically sized automatic arrays; instead, use alloca() after including "../include/lalloca.h". For example: void func (int n) { char buf[n]; } should be re-written as: #ifdef _AIX # include "../include/lalloca.h" /* MUST come first for AIX! */ #endif #include "../include/sane/config.h" #include "../include/lalloca.h" : void func (int n) { char *buf = alloca (n); } - Don't use any #pragma directives---they're completely compiler-dependent. * If you use headers or libraries that may not be available on all systems, write a check for configure.ac and include it conditionally. If your backend depends on these libraries or headers, compile the backend only if they are available (see pint for an example). * Use #include ".../include/sane/..." to include the sane header files instead of #include . Otherwise problems with different installed SANE versions may occur. Also this makes clear that the local files are used. * Don't forget to #include ".../include/sane/config.h" in your backend before any other includes. This must be done for any .c file that generates its own object file. If you use lalloca.h see above for the correct includes. * Include sanei_backend.h after the other includes. * It's no longer necessary to #define PATH_MAX (now in sanei_backend.h). If you define it, do so *after* the system includes. * Please use sanei functions whenever possible (e.g. sanei_config_read()). This makes porting to other os/platforms much easier. Most of these functions are documented in their respective header files in include/sane/sanei_*.h. For most of them there is also documentation in doxygen format: http://www.sane-project.org/sanei/. These HTML pages can be generated by calling "doxygen sanei-doxygen.conf" in the doc/ directory. * Initialize global variables explicitly in sane_init. Keep in mind that sane_init can be called more than once (if sane_exit is called everytime after sane_init). Therefore don't depend on automatic initialization to 0 / NULL. * Do make sure that your code is byte-order independent. This is particularly important for networking-related code and when dealing with non-textual data files. * Don't use printf, fprintf or perror to output debug or error messages. Use the DBG macro instead. If your backend can't detect a scanner for whatever reason it shouldn't output anything as long as SANE_DEBUG_BACKENDNAME isn't set. So don't use DBG(0, ...) in this case. * Please do not assume that `size_t' is `unsigned int'. On some systems, it's `unsigned long' and the size of this type may be bigger than that of an int (this is true for practically any of the 64-bit systems). To print a variable of type size_t portably, cast the variable to u_long and print it with the %lu specifier. E.g.: size_t len; DBG(3, "len=%lu\n", (u_long) len); * Please do not assume that `void *' has the same size as `int'. On some systems, it's `long' and the size of this type may be bigger than that of an int (this is true for practically any of the 64-bit systems). Where this comes up is with opaque handles. For example: int OpaqueHandle; MyScanner *s = (MyScanner *)OpaqueHandle; will FAIL on most 64 bit systems. Please use `void *' or better `SANE_Handle'. * Don't use exit() in your backend. You will exit the whole program, not only your backend. * If you use wait() or waitpid() in your backend, check its return value. This is important, if the status value is checked for e.g. WIFEXITED after the call of wait() or waitpid(). Both functions may fail if the frontend already did a wait for the children. * Please try to avoid compilation warnings. At least with "--disable-warnings" there shouldn't be warnings when compiling backends. It's not necessary to fix every "unused parameter" warning but take care that no warnings pointing to really existing problems or ambiguities are missed. Some programming techniques generating warnings on gcc may lead to errors on other systems. * To support translation of SANE options, please mark the descriptions (desc) and title of options with SANE_I18N() and add all files using SANE_I18N() to po/POTFILES. See po/README for details. * Please check for TL_X < BR_X and TL_Y < BR_Y to avoid segfaults or even scanner damage. This should NOT be done in sane_control_option, it should be possible to temporary set TL_X > BR_X or TL_ > BR, otherwise it is hard for a frontend to set the correct values. TESTING ------- * Please test a backend with "scanimage -T" (plus other options, as appropriate/necessary) as this will make sure that sane_read() always returns the correct amount of data etc. * You can also test a backend with tstbackend. tstbackend is not compiled nor installed by default. To do that, cd into frontend and run "make tstbackend". * Please test a backend not just with scanimage and xscanimage (+ other frontends), but also with saned. Based on past experience, it is often the case that remote scanning can uncover subtle bugs. Note that you don't have to use two different machines to test "remote" scanning---you can use one and the same machine to test a backend via saned (just be sure to enable the "net" backend in dll.conf and follow the steps described in saned(8)). * Please test on every available platform/os. Even if no scanner is attached to this system, test compilation and running scanimage. If you don't have access to other platforms, ask sane-devel. * Please make sure that all global symbols exported from a SANE backend start with the prefix "sane" or "sanei" to avoid clashes with exported symbols of other backends. Only symbols mentioned in the SANE standard should start with "sane_*". Make sure, the sanei_* symbols are unique, e.g. by using sanei_backendname_*. Only export symbols that are absolutely necessary. You can verify this by running GNU "nm" on the static library. For example: nm -g backend/.libs/libsane-hp.a would list all global symbols in the HP backend. "./configure; make; make libcheck" in the sane-backends root directory will name all backend libraries, that contain "illegal" symbols. DOCUMENTATION ------------- * Even if you haven't written a man-page for your backend yet, you *must* create a .desc file which describes it. Anytime you submit source code for your backend, you should include an update to the .desc file which reflects the new state of the backend. The .desc files are used to create the HTML lists of supported devices. These lists are updated automatically when you change a .desc file in git. See e.g. http://www.sane-project.org/lists/sane-mfgs-cvs.html for the results. * The .desc files are located in the directories "doc/descriptions" and "doc/descriptions-external" (for included and external backends). * "doc/descriptions.txt" describes the format of the ".desc" files. There is also a template for new .desc files: "template.desc.". The format of the files in the two directories is very similar. If you'd like to try parsing your creation to recreate the sane-backends webpages, cd into "tools/" and enter "make sane-desc". You can either use sane-desc directly (try "./sane-desc -h") or use "make html-pages" in "doc/". * For external backends, you don't need to supply :manpage and :version. The manpage link won't work anyway and version will be outdated soon. * When your backend is included in the SANE distribution, add an entry to doc/sane.man and AUTHORS. The sane.man entry should point to your documentation (man-page, website, readme). Also move your .desc file from "doc/descriptions-external" to "doc/descriptions" and update them. * In your manual page (backend.man), use @LIBDIR@ and the other macros for path names to the libraries, config files and documentation. Don't use fixed paths as they will be wrong if SANE is installed with a different prefix (e.g. /usr instead of /usr/local). * If you want to include READMEs, HTML files or other documentation, please create your own directory (doc/backendname) and store your files in this directory. If you only have a manual page a subdirectory isn't necessary. * Please keep your manpages and .desc files up-to-date especially regarding version numbers. CHECKLIST: SUBMITTING A NEW BACKEND ----------------------------------- In sane-backends/ * Add the author(s) name(s) to AUTHORS * Correct any related entries in the bug-tracking system In sane-backends/backend/ * Use the command "indent -gnu" to reformat your code according to the standard. * Add the backend name to dll.conf * Check that the SANE license is in the backend source files. * Add the source file names and the .conf file to BACKEND_CONFS in Makefile.am In sane-backends/doc/ * Add an entry for the man page in sane.man * Add the man page file in doc/Makefile.am * Move the description file from descriptions-external/ to doc/descriptions/ * Check that the description file is correct: "cd doc; make html-pages" and check the html pages result with a browser. * Check that the backend version is the same in the source and in the description file. In sane-backends/po/ * Add all files using SANE_I18N() to po/POTFILES INCLUDING INTO git ------------------ * If you want to include your backend into SANE's git tree use the latest git to make patches. Check the mailing list and the bug-tracking system for information about bugs to avoid. * If your backend isn't included yet in the SANE's git tree, write an email to the SANE mailing list (sane-devel) and ask for inclusion. Usually one of the developers will check the backend for common mistakes and test compilation. If everything is ok the backend will be added to the git tree. sane-backends-1.0.29/doc/sane-st400.man0000666000000000000000000001134313615534521014243 00000000000000.TH sane\-st400 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-st400 .SH NAME sane\-st400 \- SANE backend for Siemens ST/Highscan flatbed scanners .SH DESCRIPTION The .B sane\-st400 library implements a SANE (Scanner Access Now Easy) backend that provides access to Siemens ST400 flatbed scanners and compatibles. At present, the following scanners are supported by this backend: .PP .RS Siemens ST400 (6 bit gray scale) .br Siemens ST800 (6 bit gray scale) .br .RE .PP The driver supports line art and gray scans up to 8bpp. .PP The Siemens ST/Highscan series includes several more models, e.g. the ST300 and ST600. If you own one of these scanners, or a scanner other than the ones listed above that works with this backend, please let us know by sending the scanner's model name, SCSI ID, and firmware revision to .IR sane\-devel@alioth-lists.debian.net . Have a look at http://www.sane\-project.org/mailing\-lists.html concerning subscription to sane\-devel. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is either the path-name for the special device that corresponds to a SCSI scanner. For SCSI scanners, the special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. See sane\-scsi(5) for details. .SH CONFIGURATION The contents of the .I st400.conf file is a list of device names that correspond to Siemens scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS /dev/scanner .br # this is a comment .br /dev/sge .RE .PP The default configuration file that is distributed with SANE looks like this: .PP .RS scsi SIEMENS "ST 400" Scanner * * 3 0 .RE .PP In this configuration, the driver can only access the ST400 model at SCSI ID 3 LUN 0 (see section "BUGS" below for the reason). To use the driver with other scanner models, add an appropriate line to the configuration file. For example, to use it with an ST800 at SCSI ID 3 LUN 0, add the line: .PP .RS scsi SIEMENS "ST 800" Scanner * * 3 0 .RE .SH FILES .TP .I @CONFIGDIR@/st400.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-st400.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-st400.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in /etc/sane.d. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "/etc/sane.d" being searched (in this order). .TP .B SANE_DEBUG_ST400 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH MISSING FUNCTIONALITY Everything but the most basic stuff. .SH BUGS Currently, the backend does not check if the attached device really is a ST400. It will happily accept everything that matches the configuration entries. This makes it easy to test the backend with other scanners: Just add an appropriate line to the configuration file. The configuration file as distributed (see above) only works with the ST400. Be careful: If there is no config file at all, the backend defaults to /dev/scanner. .PP The ST400 answers on all eight SCSI LUNs. Normally this is not a problem, as LUN support is usually disabled in SCSI drivers, but if you are seeing multiple instances of the scanner in a device list, either disable LUNs in your SCSI setup or change the entry in the configuration file to match LUN 0 only. .SH DEBUG If you encounter a bug please set the environment variable SANE_DEBUG_ST400 to 128 and try to regenerate the problem. Then send me a report with the log attached. .PP If you encounter a SCSI bus error or trimmed and/or displaced images please also set the environment variable SANE_DEBUG_SANEI_SCSI to 128 before sending me the report. .SH "SEE ALSO" sane(7), sane\-scsi(5) .br http://www.informatik.uni-oldenburg.de/~ingo/sane/ .SH AUTHOR Ingo Wilken sane-backends-1.0.29/doc/sane-lexmark.man0000666000000000000000000001063713615534521015041 00000000000000.TH "sane\-lexmark" "5" "12 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-lexmark .SH "NAME" sane\-lexmark \- SANE backend for Lexmark X1100/X1200 Series scanners .SH "DESCRIPTION" The .B sane\-lexmark library implements a SANE (Scanner Access Now Easy) backend that provides access to the scanner part of Lexmark X1100/X1200 AIOs. This backend should be considered .B beta-quality software! .PP The scanners that should work with this backend are: .PP .RS .ft CR .nf Vendor Model status \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\- Lexmark X74 good Lexmark X1110 untested Lexmark X1140 untested Lexmark X1150 good Lexmark X1170 good Lexmark X1180 good Lexmark X1185 complete Lexmark X12xx good in USB1.1, not fully tested in USB2.0 Dell A920 good .fi .ft R .RE The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage or xsane. .br If you have any strange behavior, please report to the backend maintainer or to the SANE mailing list. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d lexmark:usb: .RE .TP .B Scan Mode Options .TP .B \-\-mode selects the basic mode of operation of the scanner valid choices are .IR Color , .I Gray and .I Lineart The default mode is Color. The Lineart mode is black and white only (1 bit). Grayscale will produce 256 levels of gray (8 bits). Color mode allows for over 16 million different colors produced from 24 bits of color information. .TP .B \-\-resolution selects the resolution for a scan. The horizontal and vertical resolutions are set by the value of this option. The scanner is capable of the following resolutions for the specified option value: .PP .RS .ft CR .nf Value Hor. Resolution Vert. Resolution \-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- 75 75dpi 75dpi 150 150dpi 150dpi 300 300dpi 300dpi 600 600dpi 600dpi 1200 600dpi 1200dpi (only for X11xx models with 'B2' sensor) .fi .ft R .RE .TP .B \-\-preview requests a preview scan. The resolution used for that scan is 75 dpi and the scan area and the scan mode are as specified through their options, or the default if not specified. The default value for preview mode is "no". .TP .B \-\-threshold selects the minimum-brightness to get a white point. The threshold is only used with Lineart mode scans. It is specified as a percentage in the range 0..100% (in steps of 1). The default value of the threshold option is 50. .SH "CONFIGURATION FILE" The configuration file @CONFIGDIR@/lexmark.conf contains only the usb device id (eg usb 0x043d 0x007c). .SH "FILES" .TP .I @LIBDIR@/libsane\-lexmark.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-lexmark.so The shared library implementing this backend (present on systems that support dynamic loading). .SH "ENVIRONMENT" .TP .B SANE_DEBUG_LEXMARK .B SANE_DEBUG_LEXMARK_LOW If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 255 requests all debug output to be printed. Smaller levels reduce verbosity. .SH "LIMITATIONS" The windows TWAIN driver has many more options than this SANE backend. However they are only software adjustments. This backend only implements what the scanner can support. For instance, shading correction (vertical stripes due to sensor variation across its width) is done in software. Head park position is also detected by software. The data compression isn't supported for the X1200 series on USB 1.1, leading to slow scans. .SH "BUGS" .br No bugs currently known. .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1), sane(7) .SH "AUTHOR" .TP The backend was originally written by Fred Odendaal. .I http://ca.geocities.com/freshshelf@rogers.com/ .TP The new version is currently developed by St\['e]phane Voltz. .I http://stef.dev.free.fr/sane/lexmark .TP X74 support was written by Torsten Houwaart () .SH "CREDITS" .TP Many thanks go to: Julien Furgerot who lend me a Dell A920. Robert Price, Dani Ele and Dalai Felinto for the time they spent recording USB activity and testing the experimental version. sane-backends-1.0.29/doc/descriptions-external/0000755000000000000000000000000013615535553016356 500000000000000sane-backends-1.0.29/doc/descriptions-external/panamfs.desc0000666000000000000000000000315013615534521020560 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "panamfs" ; name of backend ;:version "1.0.0" ; version of backend (or "unmaintained") ;:manpage "sane-template" ; name of manpage (if it exists) :url "http://panasonic.net/pcc/support/fax/common/table/linuxdriver.html" ; backend's web page :comment "External backend made by panasonic." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Panasonic" ; name a manufacturer :url "http://panasonic.net/" ; manufacturer's URL ;:comment "" ; comment about the manufacturer :model "DP-MC210" :status :untested :comment "No report yet." :model "DP-MB250" :status :untested :comment "No report yet." :model "DP-MB300 series" :status :untested :comment "No report yet." :model "KX-MB1500 series" :status :untested :comment "No report yet." :model "KX-MB2000 series" :status :untested :comment "No report yet." :model "KX-MB3000 series" :status :untested :comment "No report yet." :model "KX-MC6000 series" :status :untested :comment "No report yet." sane-backends-1.0.29/doc/descriptions-external/hpaio.desc0000666000000000000000000023724313615534521020247 00000000000000; ; SANE Backend specification file ; :backend "hpaio" ; name of backend :version "" ; version of backend :url "http://hpinkjet.sourceforge.net/" ; backend's web page :comment "This backend isn't included in SANE because it is included in the HPLIP software." :devicetype :scanner ; start of a list of devices.... :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/united-states/consumer/gateway/printing_multifunction.html" :model "HP 915 Inkjet All-in-one Printer" :status :good :model "HP cm8050 Color Multifunction Printer With Edgeline Technology" :status :good :model "HP cm8060 Color Multifunction Printer With Edgeline Technology" :status :good :model "HP Color LaserJet 2800 All-in-one Printer" :status :good :model "HP Color LaserJet 2820 All-in-one Printer" :status :good :model "HP Color LaserJet 2830 All-in-one Printer" :status :good :model "HP Color LaserJet 2840 All-in-one Printer" :status :good :model "HP Color LaserJet 4730 Multifunction Printer" :status :good :model "HP Color LaserJet 4730x Multifunction Printer" :status :good :model "HP Color LaserJet 4730xm Multifunction Printer" :status :good :model "HP Color LaserJet 4730xs Multifunction Printer" :status :good :model "HP Color LaserJet cm1015 Multifunction Printer" :status :good :model "HP Color LaserJet cm1017 Multifunction Printer" :status :good :model "HP Color LaserJet cm1312 Multifunction Printer" :status :good :model "HP Color LaserJet cm1312nfi Multifunction Printer" :status :good :model "HP Color LaserJet cm2320 Multifunction Printer" :status :good :model "HP Color LaserJet cm2320fxi Multifunction Printer" :status :good :model "HP Color LaserJet cm2320n Multifunction Printer" :status :good :model "HP Color LaserJet cm2320nf Multifunction Printer" :status :good :model "HP Color LaserJet cm4730 Multifunction Printer" :status :good :model "HP Color LaserJet cm4730f Multifunction Printer" :status :good :model "HP Color LaserJet cm4730fm Multifunction Printer" :status :good :model "HP Color LaserJet cm4730fsk Multifunction Printer" :status :good :model "HP Color LaserJet Enterprise Flow MFP m776z" :status :good :model "HP Color LaserJet Enterprise Flow MFP m776zs" :status :good :model "HP Color LaserJet Enterprise MFP m776dn" :status :good :model "HP Color LaserJet Managed Flow MFP e67560z" :status :good :model "HP Color LaserJet Managed Flow MFP e67660z" :status :good :model "HP Color LaserJet Managed Flow MFP e77822z" :status :good :model "HP Color LaserJet Managed Flow MFP e77825z" :status :good :model "HP Color LaserJet Managed Flow MFP e77830z" :status :good :model "HP Color LaserJet Managed Flow MFP e87640z" :status :good :model "HP Color LaserJet Managed Flow MFP e87650z" :status :good :model "HP Color LaserJet Managed Flow MFP e87660z" :status :good :model "HP Color LaserJet Managed MFP e67650dh" :status :good :model "HP Color LaserJet Managed MFP e77422a" :status :good :model "HP Color LaserJet Managed MFP e77422dn" :status :good :model "HP Color LaserJet Managed MFP e77422dv" :status :good :model "HP Color LaserJet Managed MFP e77428dn" :status :good :model "HP Color LaserJet Managed MFP e77822dn" :status :good :model "HP Color LaserJet Managed MFP e77825dn" :status :good :model "HP Color LaserJet Managed MFP e77830dn" :status :good :model "HP Color LaserJet Managed MFP e87640 Dn" :status :good :model "HP Color LaserJet Managed MFP e87640 Du" :status :good :model "HP Color LaserJet Managed MFP e87650dn" :status :good :model "HP Color LaserJet Managed MFP e87650du" :status :good :model "HP Color LaserJet Managed MFP e87660dn" :status :good :model "HP Color LaserJet Managed MFP e87660du" :status :good :model "HP Color LaserJet MFP m277c6" :status :good :model "HP Color LaserJet MFP m277dw" :status :good :model "HP Color LaserJet MFP m277n" :status :good :model "HP Color LaserJet MFP m377 Fnw" :status :good :model "HP Color LaserJet Pro MFP m178cn" :status :good :model "HP Color LaserJet Pro MFP m178n" :status :good :model "HP Color LaserJet Pro MFP m179cfw" :status :good :model "HP Color LaserJet Pro MFP m179fw" :status :good :model "HP Color LaserJet Pro MFP m180cn" :status :good :model "HP Color LaserJet Pro MFP m180n" :status :good :model "HP Color LaserJet Pro MFP m180nw" :status :good :model "HP Color LaserJet Pro MFP m181cfw" :status :good :model "HP Color LaserJet Pro MFP m181fnw" :status :good :model "HP Color LaserJet Pro MFP m181fw" :status :good :model "HP Color LaserJet Pro MFP m274n" :status :good :model "HP Color LaserJet Pro MFP m278cw" :status :good :model "HP Color LaserJet Pro MFP m278dn" :status :good :model "HP Color LaserJet Pro MFP m278nw" :status :good :model "HP Color LaserJet Pro MFP m279fdw" :status :good :model "HP Color LaserJet Pro MFP m280c2" :status :good :model "HP Color LaserJet Pro MFP m280cnw" :status :good :model "HP Color LaserJet Pro MFP m280nw" :status :good :model "HP Color LaserJet Pro MFP m281cdw" :status :good :model "HP Color LaserJet Pro MFP m281dne" :status :good :model "HP Color LaserJet Pro MFP m281fdn" :status :good :model "HP Color LaserJet Pro MFP m281fdw" :status :good :model "HP Color LaserJet Pro MFP m476dn" :status :good :model "HP Color LaserJet Pro MFP m476dw" :status :good :model "HP Color LaserJet Pro MFP m476nw" :status :good :model "HP Color LaserJet Pro MFP m477 Fdn" :status :good :model "HP Color LaserJet Pro MFP m477 Fdw" :status :good :model "HP Color LaserJet Pro MFP m477 Fnw" :status :good :model "HP Color LaserJet Pro MFP m478fcdn" :status :good :model "HP Color LaserJet Pro MFP m478fcdw" :status :good :model "HP Color LaserJet Pro MFP m479dw" :status :good :model "HP Color LaserJet Pro MFP m479fcdn" :status :good :model "HP Color LaserJet Pro MFP m479fcdw" :status :good :model "HP Color LaserJet Pro MFP m479fdn" :status :good :model "HP Color LaserJet Pro MFP m479fdw" :status :good :model "HP Color LaserJet Pro MFP m479fnw" :status :good :model "HP Color LaserJet Pro Mpf m176n" :status :good :model "HP Color LaserJet Pro Mpf m177fw" :status :good :model "HP Designjet 4500mfp" :status :good :model "HP Designjet 4520mfp" :status :good :model "HP Designjet t790ps 24in" :status :good :model "HP Deskjet 1050 j410 All-in-one Printer" :status :good :model "HP Deskjet 1051 All-in-one Printer" :status :good :model "HP Deskjet 1055 All-in-one Printer -j410e" :status :good :model "HP Deskjet 1056 All-in-one Printer -j410a" :status :good :model "HP Deskjet 1510 All-in-one Printer" :status :good :model "HP Deskjet 1511 All-in-one Printer" :status :good :model "HP Deskjet 1512 All-in-one Printer" :status :good :model "HP Deskjet 1513 All-in-one Printer" :status :good :model "HP Deskjet 1514 All-in-one Printer" :status :good :model "HP Deskjet 2050 j510 All-in-one Printer" :status :good :model "HP Deskjet 2130 All-in-one Printer Series" :status :good :model "HP Deskjet 2131 All-in-one Printer" :status :good :model "HP Deskjet 2132 All-in-one Printer" :status :good :model "HP Deskjet 2134 All-in-one Printer" :status :good :model "HP Deskjet 2200 All-in-one" :status :good :model "HP Deskjet 2510 All-in-one Printer" :status :good :model "HP Deskjet 2511 All-in-one Printer" :status :good :model "HP Deskjet 2512 All-in-one Printer" :status :good :model "HP Deskjet 2514 All-in-one Printer" :status :good :model "HP Deskjet 2540 All-in-one Printer" :status :good :model "HP Deskjet 2541 All-in-one Printer" :status :good :model "HP Deskjet 2542 All-in-one Printer" :status :good :model "HP Deskjet 2543 All-in-one Printer" :status :good :model "HP Deskjet 2544 All-in-one Printer" :status :good :model "HP Deskjet 2545 All-in-one Printer" :status :good :model "HP Deskjet 2546b All-in-one Printer" :status :good :model "HP Deskjet 2546p All-in-one Printer" :status :good :model "HP Deskjet 2546r All-in-one Printer" :status :good :model "HP Deskjet 2549 All-in-one Printer" :status :good :model "HP Deskjet 2620 All-in-one" :status :good :model "HP Deskjet 2621 All-in-one" :status :good :model "HP Deskjet 2622 All-in-one" :status :good :model "HP Deskjet 2623 All-in-one" :status :good :model "HP Deskjet 3050 j610 Series" :status :good :model "HP Deskjet 3050a j611 Series" :status :good :model "HP Deskjet 3051a E-all-in-one Printer j611h" :status :good :model "HP Deskjet 3052a E-all-in-one Printer j611e" :status :good :model "HP Deskjet 3052a E-all-in-one Printer j611f" :status :good :model "HP Deskjet 3052a E-all-in-one Printer j611g" :status :good :model "HP Deskjet 3054a E-all-in-one Printer j611c" :status :good :model "HP Deskjet 3054a E-all-in-one Printer j611d" :status :good :model "HP Deskjet 3054a E-all-in-one Printer j611j" :status :good :model "HP Deskjet 3055a E-all-in-one Printer j611n" :status :good :model "HP Deskjet 3056a E-all-in-one Printer" :status :good :model "HP Deskjet 3057a E-all-in-one Printer j611n" :status :good :model "HP Deskjet 3059a E-all-in-one Printer j611n" :status :good :model "HP Deskjet 3070 b611 Series" :status :good :model "HP Deskjet 3510 E-all-in-one" :status :good :model "HP Deskjet 3511 E-all-in-one" :status :good :model "HP Deskjet 3512 E-all-in-one" :status :good :model "HP Deskjet 3520 E-all-in-one Series" :status :good :model "HP Deskjet 3521 E-all-in-one Printer" :status :good :model "HP Deskjet 3522 E-all-in-one Printer" :status :good :model "HP Deskjet 3524 E-all-in-one Printer" :status :good :model "HP Deskjet 3526 E-all-in-one Printer" :status :good :model "HP Deskjet 3630 All-in-one Printer" :status :good :model "HP Deskjet 3632 All-in-one Printer" :status :good :model "HP Deskjet 3633 All-in-one Printer" :status :good :model "HP Deskjet 3634 All-in-one Printer" :status :good :model "HP Deskjet 3700 All-in-one" :status :good :model "HP Deskjet 3722 All-in-one" :status :good :model "HP Deskjet f2110 All-in-one Printer" :status :good :model "HP Deskjet f2120 All-in-one Printer" :status :good :model "HP Deskjet f2128 All-in-one Printer" :status :good :model "HP Deskjet f2140 All-in-one Printer" :status :good :model "HP Deskjet f2179 All-in-one Printer" :status :good :model "HP Deskjet f2180 All-in-one Printer" :status :good :model "HP Deskjet f2185 All-in-one Printer" :status :good :model "HP Deskjet f2187 All-in-one Printer" :status :good :model "HP Deskjet f2188 All-in-one Printer" :status :good :model "HP Deskjet f2210 All-in-one Printer" :status :good :model "HP Deskjet f2212 All-in-one Printer" :status :good :model "HP Deskjet f2214 All-in-one Printer" :status :good :model "HP Deskjet f2224 All-in-one Printer" :status :good :model "HP Deskjet f2235 All-in-one Printer" :status :good :model "HP Deskjet f2238 All-in-one Printer" :status :good :model "HP Deskjet f2240 All-in-one Printer" :status :good :model "HP Deskjet f2250 All-in-one Printer" :status :good :model "HP Deskjet f2275 All-in-one Printer" :status :good :model "HP Deskjet f2276 All-in-one Printer" :status :good :model "HP Deskjet f2280 All-in-one Printer" :status :good :model "HP Deskjet f2288 All-in-one Printer" :status :good :model "HP Deskjet f2290 All-in-one Printer" :status :good :model "HP Deskjet f2410 All-in-one Printer" :status :good :model "HP Deskjet f2418 All-in-one Printer" :status :good :model "HP Deskjet f2420 All-in-one Printer" :status :good :model "HP Deskjet f2423 All-in-one Printer" :status :good :model "HP Deskjet f2430 All-in-one Printer" :status :good :model "HP Deskjet f2440 All-in-one Printer" :status :good :model "HP Deskjet f2476 All-in-one Printer" :status :good :model "HP Deskjet f2480 All-in-one Printer" :status :good :model "HP Deskjet f2483 All-in-one Printer" :status :good :model "HP Deskjet f2488 All-in-one Printer" :status :good :model "HP Deskjet f2492 All-in-one Printer" :status :good :model "HP Deskjet f2493 All-in-one Printer" :status :good :model "HP Deskjet f310 All-in-one Printer" :status :good :model "HP Deskjet f325 All-in-one Printer" :status :good :model "HP Deskjet f335 All-in-one Printer" :status :good :model "HP Deskjet f340 All-in-one Printer" :status :good :model "HP Deskjet f350 All-in-one Printer" :status :good :model "HP Deskjet f370 All-in-one Printer" :status :good :model "HP Deskjet f375 All-in-one Printer" :status :good :model "HP Deskjet f378 All-in-one Printer" :status :good :model "HP Deskjet f379 All-in-one Printer" :status :good :model "HP Deskjet f380 All-in-one Printer" :status :good :model "HP Deskjet f385 All-in-one Printer" :status :good :model "HP Deskjet f388 All-in-one Printer" :status :good :model "HP Deskjet f390 All-in-one Printer" :status :good :model "HP Deskjet f394 All-in-one Printer" :status :good :model "HP Deskjet f4135 All-in-one Printer" :status :good :model "HP Deskjet f4140 All-in-one Printer" :status :good :model "HP Deskjet f4150 All-in-one Printer" :status :good :model "HP Deskjet f4172 All-in-one Printer" :status :good :model "HP Deskjet f4175 All-in-one Printer" :status :good :model "HP Deskjet f4180 All-in-one Printer" :status :good :model "HP Deskjet f4185 All-in-one Printer" :status :good :model "HP Deskjet f4188 All-in-one Printer" :status :good :model "HP Deskjet f4190 All-in-one Printer" :status :good :model "HP Deskjet f4194 All-in-one Printer" :status :good :model "HP Deskjet f4210 All-in-one Printer" :status :good :model "HP Deskjet f4213 All-in-one Printer" :status :good :model "HP Deskjet f4224 All-in-one Printer" :status :good :model "HP Deskjet f4230 All-in-one Printer" :status :good :model "HP Deskjet f4235 All-in-one Printer" :status :good :model "HP Deskjet f4238 All-in-one Printer" :status :good :model "HP Deskjet f4240 All-in-one Printer" :status :good :model "HP Deskjet f4250 All-in-one Printer" :status :good :model "HP Deskjet f4272 All-in-one Printer" :status :good :model "HP Deskjet f4273 All-in-one Printer" :status :good :model "HP Deskjet f4274 All-in-one Printer" :status :good :model "HP Deskjet f4275 All-in-one Printer" :status :good :model "HP Deskjet f4280 All-in-one Printer" :status :good :model "HP Deskjet f4283 All-in-one Printer" :status :good :model "HP Deskjet f4288 All-in-one Printer" :status :good :model "HP Deskjet f4292 All-in-one Printer" :status :good :model "HP Deskjet f4293 All-in-one Printer" :status :good :model "HP Deskjet f4294 All-in-one Printer" :status :good :model "HP Deskjet f4435 All-in-one Printer" :status :good :model "HP Deskjet f4440 All-in-one Printer" :status :good :model "HP Deskjet f4450 All-in-one Printer" :status :good :model "HP Deskjet f4470 All-in-one Printer" :status :good :model "HP Deskjet f4472 All-in-one Printer" :status :good :model "HP Deskjet f4473 All-in-one Printer" :status :good :model "HP Deskjet f4480 All-in-one Printer" :status :good :model "HP Deskjet f4483 All-in-one Printer" :status :good :model "HP Deskjet f4488 All-in-one Printer" :status :good :model "HP Deskjet f4492 All-in-one Printer" :status :good :model "HP Deskjet f4500 All-in-one Printer Series" :status :good :model "HP Deskjet f735 All-in-one Printer" :status :good :model "HP Deskjet Gt 5810 All-in-one Printer" :status :good :model "HP Deskjet Gt 5820 All-in-one Printer" :status :good :model "HP Deskjet Ink Adv 2060 k110" :status :good :model "HP Deskjet Ink Advantage 1510 All-in-one Printer Series" :status :good :model "HP Deskjet Ink Advantage 1515 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 1516 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 1518 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 2130 All-in One Printer" :status :good :model "HP Deskjet Ink Advantage 2135 All-in One Printer" :status :good :model "HP Deskjet Ink Advantage 2136 All-in One Printer" :status :good :model "HP Deskjet Ink Advantage 2138 All-in One Printer" :status :good :model "HP Deskjet Ink Advantage 2200 All-in-one" :status :good :model "HP Deskjet Ink Advantage 2510 All-in-one" :status :good :model "HP Deskjet Ink Advantage 2515 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 2516 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 2520hc All-in-one" :status :good :model "HP Deskjet Ink Advantage 2540 All-in-one Printer Series" :status :good :model "HP Deskjet Ink Advantage 2545 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 2546 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 2548 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 2635 All-in-one" :status :good :model "HP Deskjet Ink Advantage 2636 All-in-one" :status :good :model "HP Deskjet Ink Advantage 2645 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 2646 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 2675 All-in-one" :status :good :model "HP Deskjet Ink Advantage 2676 All-in-one" :status :good :model "HP Deskjet Ink Advantage 2677 All-in-one" :status :good :model "HP Deskjet Ink Advantage 2678 All-in-one" :status :good :model "HP Deskjet Ink Advantage 3515 E-all-in-one" :status :good :model "HP Deskjet Ink Advantage 3516 E-all-in-one" :status :good :model "HP Deskjet Ink Advantage 3525 E-all-in-one" :status :good :model "HP Deskjet Ink Advantage 3540 E-all-in-one Printer Series" :status :good :model "HP Deskjet Ink Advantage 3545 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 3546 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 3630 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 3635 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 3636 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 3638 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 3735 All-in-one" :status :good :model "HP Deskjet Ink Advantage 3789 All-in-one" :status :good :model "HP Deskjet Ink Advantage 3790 All-in-one" :status :good :model "HP Deskjet Ink Advantage 3830 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 3835 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 3836 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4515 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4518 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4530 All-in-one" :status :good :model "HP Deskjet Ink Advantage 4535 All-in-one" :status :good :model "HP Deskjet Ink Advantage 4536 All-in-one" :status :good :model "HP Deskjet Ink Advantage 4610 All-in-one Printer Series" :status :good :model "HP Deskjet Ink Advantage 4615 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4620 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4625 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4640 E-all-in-one Printer Series" :status :good :model "HP Deskjet Ink Advantage 4645 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4646 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4648 E-all-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 4670 All-in-one" :status :good :model "HP Deskjet Ink Advantage 4675 All-in-one" :status :good :model "HP Deskjet Ink Advantage 4676 All-in-one" :status :good :model "HP Deskjet Ink Advantage 5075 All-in-one" :status :good :model "HP Deskjet Ink Advantage 5275 All-in-one" :status :good :model "HP Deskjet Ink Advantage 5525 E-all-in-one" :status :good :model "HP Deskjet Ink Advantage 5570 All-in-one" :status :good :model "HP Deskjet Ink Advantage 5575 All-in-one" :status :good :model "HP Deskjet Ink Advantage 5640 All-in-one Printer Series" :status :good :model "HP Deskjet Ink Advantage 5645 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage 6525 E-all-in-one" :status :good :model "HP Deskjet Ink Advantage k209a All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage Ultra 2529 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage Ultra 4720 All-in-one Printer Series" :status :good :model "HP Deskjet Ink Advantage Ultra 4729 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage Ultra 5738 All-in-one Printer" :status :good :model "HP Deskjet Ink Advantage Ultra 5739 All-in-one Printer" :status :good :model "HP Digital Sender Flow 8500 fn2 Document Capture Workstation" :status :good :model "HP Envy 100 d410 Series" :status :good :model "HP Envy 110 E-all-in-one" :status :good :model "HP Envy 111 E-all-in-one" :status :good :model "HP Envy 114 E-all-in-one" :status :good :model "HP Envy 120 E-all-in-one" :status :good :model "HP Envy 121 E-all-in-one" :status :good :model "HP Envy 4500 E-all-in-one" :status :good :model "HP Envy 4501 E-all-in-one" :status :good :model "HP Envy 4502 E-all-in-one" :status :good :model "HP Envy 4503 E-all-in-one" :status :good :model "HP Envy 4504 E-all-in-one" :status :good :model "HP Envy 4505 E-all-in-one" :status :good :model "HP Envy 4507 E-all-in-one" :status :good :model "HP Envy 4508 E-all-in-one" :status :good :model "HP Envy 4510 All-in-one" :status :good :model "HP Envy 4512 All-in-one" :status :good :model "HP Envy 4516 All-in-one" :status :good :model "HP Envy 4520 All-in-one Printer" :status :good :model "HP Envy 4520 All-in-one Printer Series" :status :good :model "HP Envy 4522 All-in-one Printer" :status :good :model "HP Envy 4523 All-in-one Printer" :status :good :model "HP Envy 4524 All-in-one Printer" :status :good :model "HP Envy 5000 All-in-one" :status :good :model "HP Envy 5020 All-in-one" :status :good :model "HP Envy 5030 All-in-one" :status :good :model "HP Envy 5032 All-in-one" :status :good :model "HP Envy 5530 E-all-in-one Printer" :status :good :model "HP Envy 5531 E-all-in-one Printer" :status :good :model "HP Envy 5532 E-all-in-one Printer" :status :good :model "HP Envy 5534 E-all-in-one Printer" :status :good :model "HP Envy 5535 E-all-in-one Printer" :status :good :model "HP Envy 5536 E-all-in-one Printer" :status :good :model "HP Envy 5539 E-all-in-one Printer" :status :good :model "HP Envy 5540 All-in-one Printer" :status :good :model "HP Envy 5540 All-in-one Printer Series" :status :good :model "HP Envy 5542 E-all-in-one Printer" :status :good :model "HP Envy 5543 All-in-one Printer" :status :good :model "HP Envy 5544 All-in-one Printer" :status :good :model "HP Envy 5545 E-all-in-one Printer" :status :good :model "HP Envy 5546 All-in-one Printer" :status :good :model "HP Envy 5640 E-all-in-one" :status :good :model "HP Envy 5642 E-all-in-one" :status :good :model "HP Envy 5643 E-all-in-one" :status :good :model "HP Envy 5644 E-all-in-one" :status :good :model "HP Envy 5660 E-all-in-one" :status :good :model "HP Envy 5665 E-all-in-one" :status :good :model "HP Envy 7640 E-all-in-one" :status :good :model "HP Envy 7645 E-all-in-one" :status :good :model "HP Envy 8000 E-all-in-one" :status :good :model "HP Envy Photo 6200 All-in-one" :status :good :model "HP Envy Photo 6220 All-in-one" :status :good :model "HP Envy Photo 6230 All-in-one" :status :good :model "HP Envy Photo 6232 All-in-one" :status :good :model "HP Envy Photo 6234 All-in-one" :status :good :model "HP Envy Photo 7100 All-in-one" :status :good :model "HP Envy Photo 7120 All-in-one" :status :good :model "HP Envy Photo 7130 All-in-one" :status :good :model "HP Envy Photo 7134 All-in-one" :status :good :model "HP Envy Photo 7155 All-in-one" :status :good :model "HP Envy Photo 7164 All-in-one" :status :good :model "HP Envy Photo 7800 All-in-one" :status :good :model "HP Envy Photo 7820 All-in-one" :status :good :model "HP Envy Photo 7830 All-in-one" :status :good :model "HP Envy Photo 7855 All-in-one" :status :good :model "HP Hotspot LaserJet Pro m1218nfs MFP" :status :good :model "HP Ink Tank 310" :status :good :model "HP Ink Tank Wireless 410" :status :good :model "HP Laser Ns MFP 1005" :status :good :model "HP Laser Ns MFP 1005w" :status :good :model "HP LaserJet 100 Color MFP m175" :status :good :model "HP LaserJet 100 Color MFP m175a" :status :good :model "HP LaserJet 100 Color MFP m175b" :status :good :model "HP LaserJet 100 Color MFP m175c" :status :good :model "HP LaserJet 100 Color MFP m175e" :status :good :model "HP LaserJet 100 Color MFP m175nw" :status :good :model "HP LaserJet 100 Color MFP m175p" :status :good :model "HP LaserJet 100 Color MFP m175q" :status :good :model "HP LaserJet 100 Color MFP m175r" :status :good :model "HP LaserJet 1100 Printer" :status :good :model "HP LaserJet 1100a All-in-one Printer" :status :good :model "HP LaserJet 1100a Se All-in-one Printer" :status :good :model "HP LaserJet 1100a Xi All-in-one Printer" :status :good :model "HP LaserJet 1100se Printer" :status :good :model "HP LaserJet 1220 All-in-one Printer" :status :good :model "HP LaserJet 1220se All-in-one Printer" :status :good :model "HP LaserJet 200 Color MFP m275nw" :status :good :model "HP LaserJet 200 Color MFP m275s" :status :good :model "HP LaserJet 200 Color MFP m275t" :status :good :model "HP LaserJet 200 Color MFP m275u" :status :good :model "HP LaserJet 200 Colormfp m276b" :status :good :model "HP LaserJet 200 Colormfp m276e" :status :good :model "HP LaserJet 200 Colormfp m276g" :status :good :model "HP LaserJet 200 Colormfp m276j" :status :good :model "HP LaserJet 200 Colormfp m276k" :status :good :model "HP LaserJet 200 Colormfp m276p" :status :good :model "HP LaserJet 200 Colormfp m276q" :status :good :model "HP LaserJet 200 Colormfp m276r" :status :good :model "HP LaserJet 200 Colormfp m276u" :status :good :model "HP LaserJet 200 Colormfp m276v" :status :good :model "HP LaserJet 300 Color MFP m375nw" :status :good :model "HP LaserJet 3015 All-in-one Printer" :status :good :model "HP LaserJet 3020 All-in-one Printer" :status :good :model "HP LaserJet 3030 All-in-one Printer" :status :good :model "HP LaserJet 3050 All-in-one Printer" :status :good :model "HP LaserJet 3050z All-in-one Printer" :status :good :model "HP LaserJet 3052 All-in-one Printer" :status :good :model "HP LaserJet 3055 All-in-one Printer" :status :good :model "HP LaserJet 3100 All-in-one Printer" :status :good :model "HP LaserJet 3100se All-in-one Printer" :status :good :model "HP LaserJet 3100xi All-in-one Printer" :status :good :model "HP LaserJet 3150 All-in-one Printer" :status :good :model "HP LaserJet 3150se All-in-one Printer" :status :good :model "HP LaserJet 3150xi All-in-one Printer" :status :good :model "HP LaserJet 3200 All-in-one Printer" :status :good :model "HP LaserJet 3200se All-in-one Printer" :status :good :model "HP LaserJet 3300 Multifunction Printer" :status :good :model "HP LaserJet 3310 Digital Printer Copier" :status :good :model "HP LaserJet 3320 Multifunction Printer" :status :good :model "HP LaserJet 3320n Multifunction Printer" :status :good :model "HP LaserJet 3330 Multifunction Printer" :status :good :model "HP LaserJet 3380 All-in-one Printer" :status :good :model "HP LaserJet 3390 All-in-one Printer" :status :good :model "HP LaserJet 3392 All-in-one Printer" :status :good :model "HP LaserJet 400 Color MFP m475dn" :status :good :model "HP LaserJet 400 Color MFP m475dw" :status :good :model "HP LaserJet 400 MFP m425dn" :status :good :model "HP LaserJet 400 MFP m425dw" :status :good :model "HP LaserJet 4100 Multifunction Printer" :status :good :model "HP LaserJet 4101 Multifunction Printer" :status :good :model "HP LaserJet 4345 Multifunction Printer" :status :good :model "HP LaserJet 4345x Multifunction Printer" :status :good :model "HP LaserJet 4345xm Multifunction Printer" :status :good :model "HP LaserJet 4345xs Multifunction Printer" :status :good :model "HP LaserJet 8100 Multifunction Printer" :status :good :model "HP LaserJet 8150 Multifunction Printer" :status :good :model "HP LaserJet 9000 Multifunction Printer" :status :good :model "HP LaserJet 9000l Multifunction Printer" :status :good :model "HP LaserJet 9040 Multifunction Printer" :status :good :model "HP LaserJet 9050 Multifunction Printer" :status :good :model "HP LaserJet 9055 Multifunction Printer" :status :good :model "HP LaserJet 9065 Multifunction Printer" :status :good :model "HP LaserJet Enterprise Flow MFP m528c" :status :good :model "HP LaserJet Enterprise Flow MFP m528z" :status :good :model "HP LaserJet Enterprise Flow MFP m630h" :status :good :model "HP LaserJet Enterprise Flow MFP m630z" :status :good :model "HP LaserJet Enterprise MFP m528dn" :status :good :model "HP LaserJet Enterprise MFP m528f" :status :good :model "HP LaserJet Enterprise MFP m630dn" :status :good :model "HP LaserJet Enterprise MFP m630f" :status :good :model "HP LaserJet Enterprise MFP m630h" :status :good :model "HP LaserJet m1005 Multifunction Printer" :status :good :model "HP LaserJet m1120 Multifunction Printer" :status :good :model "HP LaserJet m1120n Multifunction Printer" :status :good :model "HP LaserJet m1210 MFP Series" :status :good :model "HP LaserJet m1319f Multifunction Printer" :status :good :model "HP LaserJet m1522 Multifunction Printer" :status :good :model "HP LaserJet m1522n Multifunction Printer" :status :good :model "HP LaserJet m1522nf Multifunction Printer" :status :good :model "HP LaserJet m1536dnf MFP" :status :good :model "HP LaserJet m1537dnf MFP" :status :good :model "HP LaserJet m1538dnf MFP" :status :good :model "HP LaserJet m1539dnf MFP" :status :good :model "HP LaserJet m2727 Multifunction Printer" :status :good :model "HP LaserJet m2727nf Multifunction Printer" :status :good :model "HP LaserJet m2727nfs Multifunction Printer" :status :good :model "HP LaserJet m3035 Multifunction Printer" :status :good :model "HP LaserJet m3035xs Multifunction Printer" :status :good :model "HP LaserJet m4345 Multifunction Printer" :status :good :model "HP LaserJet m4345x Multifunction Printer" :status :good :model "HP LaserJet m4345xm Multifunction Printer" :status :good :model "HP LaserJet m4345xs Multifunction Printer" :status :good :model "HP LaserJet m4349 MFP" :status :good :model "HP LaserJet m4555 MFP" :status :good :model "HP LaserJet m5035 Multifunction Printer" :status :good :model "HP LaserJet m5035x Multifunction Printer" :status :good :model "HP LaserJet m5035xs Multifunction Printer" :status :good :model "HP LaserJet m5039 Multifunction Printer" :status :good :model "HP LaserJet Managed Flow MFP e52645c" :status :good :model "HP LaserJet Managed Flow MFP e62665h" :status :good :model "HP LaserJet Managed Flow MFP e62665z" :status :good :model "HP LaserJet Managed Flow MFP e62675z" :status :good :model "HP LaserJet Managed Flow MFP e72525z" :status :good :model "HP LaserJet Managed Flow MFP e72530z" :status :good :model "HP LaserJet Managed Flow MFP e72535z" :status :good :model "HP LaserJet Managed Flow MFP e82540z" :status :good :model "HP LaserJet Managed Flow MFP e82550z" :status :good :model "HP LaserJet Managed Flow MFP e82560z" :status :good :model "HP LaserJet Managed MFP e52645dn" :status :good :model "HP LaserJet Managed MFP e62655dn" :status :good :model "HP LaserJet Managed MFP e62665hs" :status :good :model "HP LaserJet Managed MFP e72525dn" :status :good :model "HP LaserJet Managed MFP e72530dn" :status :good :model "HP LaserJet Managed MFP e72535dn" :status :good :model "HP LaserJet Managed MFP e82540dn" :status :good :model "HP LaserJet Managed MFP e82540du" :status :good :model "HP LaserJet Managed MFP e82550dn" :status :good :model "HP LaserJet Managed MFP e82550du" :status :good :model "HP LaserJet Managed MFP e82560dn" :status :good :model "HP LaserJet Managed MFP e82560du" :status :good :model "HP LaserJet MFP e72425a" :status :good :model "HP LaserJet MFP e72425dn" :status :good :model "HP LaserJet MFP e72425dv" :status :good :model "HP LaserJet MFP e72430dn" :status :good :model "HP LaserJet Pro 200 Color MFP m276n" :status :good :model "HP LaserJet Pro 200 Color MFP m276nw" :status :good :model "HP LaserJet Pro 500 Color MFP m570dn" :status :good :model "HP LaserJet Pro 500 Color MFP m570dw" :status :good :model "HP LaserJet Pro m521dn Multifunction Printer" :status :good :model "HP LaserJet Pro m521dw Multifunction Printer" :status :good :model "HP LaserJet Pro MFP m125a" :status :good :model "HP LaserJet Pro MFP m125nr" :status :good :model "HP LaserJet Pro MFP m125nw" :status :good :model "HP LaserJet Pro MFP m125r" :status :good :model "HP LaserJet Pro MFP m125rnw" :status :good :model "HP LaserJet Pro MFP m125s" :status :good :model "HP LaserJet Pro MFP m126a" :status :good :model "HP LaserJet Pro MFP m126nw" :status :good :model "HP LaserJet Pro MFP m127fn" :status :good :model "HP LaserJet Pro MFP m127fp" :status :good :model "HP LaserJet Pro MFP m127fs" :status :good :model "HP LaserJet Pro MFP m127fw" :status :good :model "HP LaserJet Pro MFP m128fn" :status :good :model "HP LaserJet Pro MFP m128fp" :status :good :model "HP LaserJet Pro MFP m128fw" :status :good :model "HP LaserJet Pro MFP m130a" :status :good :model "HP LaserJet Pro MFP m130fn" :status :good :model "HP LaserJet Pro MFP m130fw" :status :good :model "HP LaserJet Pro MFP m130nw" :status :good :model "HP LaserJet Pro MFP m132a" :status :good :model "HP LaserJet Pro MFP m132fn" :status :good :model "HP LaserJet Pro MFP m132fp" :status :good :model "HP LaserJet Pro MFP m132fw" :status :good :model "HP LaserJet Pro MFP m132nw" :status :good :model "HP LaserJet Pro MFP m132snw" :status :good :model "HP LaserJet Pro MFP m134a" :status :good :model "HP LaserJet Pro MFP m134fn" :status :good :model "HP LaserJet Pro MFP m148dw" :status :good :model "HP LaserJet Pro MFP m148fdw" :status :good :model "HP LaserJet Pro MFP m149dw" :status :good :model "HP LaserJet Pro MFP m149fdw" :status :good :model "HP LaserJet Pro MFP m225dn" :status :good :model "HP LaserJet Pro MFP m225dw" :status :good :model "HP LaserJet Pro MFP m225rdn" :status :good :model "HP LaserJet Pro MFP m226dn" :status :good :model "HP LaserJet Pro MFP m226dw" :status :good :model "HP LaserJet Pro MFP m227d" :status :good :model "HP LaserJet Pro MFP m227fdn" :status :good :model "HP LaserJet Pro MFP m227fdw" :status :good :model "HP LaserJet Pro MFP m227sdn" :status :good :model "HP LaserJet Pro MFP m25a" :status :good :model "HP LaserJet Pro MFP m25nw" :status :good :model "HP LaserJet Pro MFP m26a" :status :good :model "HP LaserJet Pro MFP m26nw" :status :good :model "HP LaserJet Pro MFP m27c" :status :good :model "HP LaserJet Pro MFP m27cnw" :status :good :model "HP LaserJet Pro MFP m28a" :status :good :model "HP LaserJet Pro MFP m29a" :status :good :model "HP LaserJet Pro MFP m30a" :status :good :model "HP LaserJet Pro MFP m30c" :status :good :model "HP LaserJet Pro MFP m31a" :status :good :model "HP LaserJet Pro MFP m31c" :status :good :model "HP LaserJet Pro MFP m329dn" :status :good :model "HP LaserJet Pro MFP m329dw" :status :good :model "HP LaserJet Pro MFP m426dw" :status :good :model "HP LaserJet Pro MFP m426fdn" :status :good :model "HP LaserJet Pro MFP m426fdw" :status :good :model "HP LaserJet Pro MFP m427dn" :status :good :model "HP LaserJet Pro MFP m427dw" :status :good :model "HP LaserJet Pro MFP m427fdw" :status :good :model "HP LaserJet Pro MFP m428c1" :status :good :model "HP LaserJet Pro MFP m428c2" :status :good :model "HP LaserJet Pro MFP m428c3" :status :good :model "HP LaserJet Pro MFP m428c4" :status :good :model "HP LaserJet Pro MFP m428dw" :status :good :model "HP LaserJet Pro MFP m428fdn" :status :good :model "HP LaserJet Pro MFP m428fdw" :status :good :model "HP LaserJet Pro MFP m428m" :status :good :model "HP LaserJet Pro MFP m429dw" :status :good :model "HP LaserJet Pro MFP m429fdn" :status :good :model "HP LaserJet Pro MFP m429fdw" :status :good :model "HP LaserJet Pro MFP m435nw" :status :good :model "HP LaserJet Professional cm1411fn" :status :good :model "HP LaserJet Professional cm1412fn" :status :good :model "HP LaserJet Professional cm1413fn" :status :good :model "HP LaserJet Professional cm1415fn" :status :good :model "HP LaserJet Professional cm1415fnw" :status :good :model "HP LaserJet Professional cm1416fnw" :status :good :model "HP LaserJet Professional cm1417fnw" :status :good :model "HP LaserJet Professional cm1418fnw" :status :good :model "HP LaserJet Professional m1132 Multifunction Printer" :status :good :model "HP LaserJet Professional m1132s Multifunction Printer" :status :good :model "HP LaserJet Professional m1136 Multifunction Printer" :status :good :model "HP LaserJet Professional m1137 Multifunction Printer" :status :good :model "HP LaserJet Professional m1138 Multifunction Printer" :status :good :model "HP LaserJet Professional m1139 Multifunction Printer" :status :good :model "HP LaserJet Professional m1212nf Multifunction Printer" :status :good :model "HP LaserJet Professional m1213nf Multifunction Printer" :status :good :model "HP LaserJet Professional m1214nfh Multifunction Printer" :status :good :model "HP LaserJet Professional m1216nfh MFP" :status :good :model "HP LaserJet Professional m1217nfw Multifunction Printer" :status :good :model "HP LaserJet Professional m1219nf MFP" :status :good :model "HP LaserJet Professional m1219nfg MFP" :status :good :model "HP LaserJet Professional m1219nfs MFP" :status :good :model "HP LaserJet Ultra MFP m230sdn" :status :good :model "HP Neverstop Laser MFP 1200a" :status :good :model "HP Neverstop Laser MFP 1200w" :status :good :model "HP Officejet 150 Mobile All-in-one" :status :good :model "HP Officejet 250 Mobile All-in-one" :status :good :model "HP Officejet 250c Mobile All-in-one" :status :good :model "HP Officejet 252 Mobile All-in-one" :status :good :model "HP Officejet 252c Mobile All-in-one" :status :good :model "HP Officejet 258 Mobile All-in-one" :status :good :model "HP Officejet 2620 All-in-one" :status :good :model "HP Officejet 2621 All-in-one" :status :good :model "HP Officejet 2622 All-in-one" :status :good :model "HP Officejet 3830 All-in-one Printer" :status :good :model "HP Officejet 3832 All-in-one Printer" :status :good :model "HP Officejet 3834 All-in-one Printer" :status :good :model "HP Officejet 4100 Series All-in-one Printer" :status :good :model "HP Officejet 4105 All-in-one Printer" :status :good :model "HP Officejet 4110 All-in-one Printer" :status :good :model "HP Officejet 4110v All-in-one Printer" :status :good :model "HP Officejet 4110xi All-in-one Printer" :status :good :model "HP Officejet 4115 All-in-one Printer" :status :good :model "HP Officejet 4200 All-in-one Printer" :status :good :model "HP Officejet 4211 All-in-one Printer" :status :good :model "HP Officejet 4212 All-in-one Printer" :status :good :model "HP Officejet 4215 All-in-one Printer" :status :good :model "HP Officejet 4215v All-in-one Printer" :status :good :model "HP Officejet 4215xi All-in-one Printer" :status :good :model "HP Officejet 4219 All-in-one Printer" :status :good :model "HP Officejet 4251 All-in-one Printer" :status :good :model "HP Officejet 4252 All-in-one Printer" :status :good :model "HP Officejet 4255 All-in-one Printer" :status :good :model "HP Officejet 4256 All-in-one Printer" :status :good :model "HP Officejet 4259 All-in-one Printer" :status :good :model "HP Officejet 4308 All-in-one Printer" :status :good :model "HP Officejet 4311 All-in-one Printer" :status :good :model "HP Officejet 4312 All-in-one Printer" :status :good :model "HP Officejet 4314 All-in-one Printer" :status :good :model "HP Officejet 4315 All-in-one Printer" :status :good :model "HP Officejet 4315v All-in-one Printer" :status :good :model "HP Officejet 4315xi All-in-one Printer" :status :good :model "HP Officejet 4317 All-in-one Printer" :status :good :model "HP Officejet 4319 All-in-one Printer" :status :good :model "HP Officejet 4338 All-in-one Printer" :status :good :model "HP Officejet 4352 All-in-one Printer" :status :good :model "HP Officejet 4353 All-in-one Printer" :status :good :model "HP Officejet 4355 All-in-one Printer" :status :good :model "HP Officejet 4357 All-in-one Printer" :status :good :model "HP Officejet 4359 All-in-one Printer" :status :good :model "HP Officejet 4400 k410 All-in-one Printer" :status :good :model "HP Officejet 4500 All-in-one Desktop Printer - g510b" :status :good :model "HP Officejet 4500 All-in-one Printer - g510g" :status :good :model "HP Officejet 4500 All-in-one Printer - g510h" :status :good :model "HP Officejet 4500 All-in-one Printer - k710" :status :good :model "HP Officejet 4500 Desktop All-in-one Printer - g510a" :status :good :model "HP Officejet 4500 g510n-z All-in-one Printer" :status :good :model "HP Officejet 4610 All-in-one Printer Series" :status :good :model "HP Officejet 4620 E-all-in-one Printer" :status :good :model "HP Officejet 4622 E-all-in-one Printer" :status :good :model "HP Officejet 4630 E-all-in-one Printer" :status :good :model "HP Officejet 4631 E-all-in-one Printer" :status :good :model "HP Officejet 4632 E-all-in-one Printer" :status :good :model "HP Officejet 4634 E-all-in-one Printer" :status :good :model "HP Officejet 4635 E-all-in-one Printer" :status :good :model "HP Officejet 4636 E-all-in-one Printer" :status :good :model "HP Officejet 4650 All-in-one Printer" :status :good :model "HP Officejet 4650 All-in-one Printer Series" :status :good :model "HP Officejet 4652 All-in-one Printer" :status :good :model "HP Officejet 4654 All-in-one Printer" :status :good :model "HP Officejet 4655 All-in-one Printer" :status :good :model "HP Officejet 5100 All-in-one Printer" :status :good :model "HP Officejet 5105 All-in-one Printer" :status :good :model "HP Officejet 5110 All-in-one Printer" :status :good :model "HP Officejet 5110v All-in-one Printer" :status :good :model "HP Officejet 5110xi All-in-one Printer" :status :good :model "HP Officejet 520 All-in-one Printer" :status :good :model "HP Officejet 5200 All-in-one" :status :good :model "HP Officejet 5220 All-in-one" :status :good :model "HP Officejet 5230 All-in-one" :status :good :model "HP Officejet 5232 All-in-one" :status :good :model "HP Officejet 5505 All-in-one Printer" :status :good :model "HP Officejet 5508 All-in-one Printer" :status :good :model "HP Officejet 5510 All-in-one Printer" :status :good :model "HP Officejet 5510v All-in-one Printer" :status :good :model "HP Officejet 5510xi All-in-one Printer" :status :good :model "HP Officejet 5515 All-in-one Printer" :status :good :model "HP Officejet 5600 Series All-in-one Printer" :status :good :model "HP Officejet 5605 All-in-one Printer" :status :good :model "HP Officejet 5607 All-in-one Printer" :status :good :model "HP Officejet 5608 All-in-one Printer" :status :good :model "HP Officejet 5609 All-in-one Printer" :status :good :model "HP Officejet 5610 All-in-one Printer" :status :good :model "HP Officejet 5610v All-in-one Printer" :status :good :model "HP Officejet 5610xi All-in-one Printer" :status :good :model "HP Officejet 5615 All-in-one Printer" :status :good :model "HP Officejet 5679 All-in-one Printer" :status :good :model "HP Officejet 5680 All-in-one Printer" :status :good :model "HP Officejet 570 All-in-one Printer" :status :good :model "HP Officejet 5740 E-all-in-one" :status :good :model "HP Officejet 5742 E-all-in-one" :status :good :model "HP Officejet 5744 E-all-in-one" :status :good :model "HP Officejet 5745 E-all-in-one" :status :good :model "HP Officejet 580 All-in-one Printer" :status :good :model "HP Officejet 590 All-in-one Printer" :status :good :model "HP Officejet 600 All-in-one Printer" :status :good :model "HP Officejet 610 All-in-one Printer" :status :good :model "HP Officejet 6105 All-in-one Printer" :status :good :model "HP Officejet 6110 All-in-one Printer" :status :good :model "HP Officejet 6110v All-in-one Printer" :status :good :model "HP Officejet 6110xi All-in-one Printer" :status :good :model "HP Officejet 6150 All-in-one Printer" :status :good :model "HP Officejet 6200 All-in-one Printer" :status :good :model "HP Officejet 6203 All-in-one Printer" :status :good :model "HP Officejet 6205 All-in-one Printer" :status :good :model "HP Officejet 6208 All-in-one Printer" :status :good :model "HP Officejet 6210 All-in-one Printer" :status :good :model "HP Officejet 6210v All-in-one Printer" :status :good :model "HP Officejet 6210xi All-in-one Printer" :status :good :model "HP Officejet 6213 All-in-one Printer" :status :good :model "HP Officejet 6215 All-in-one Printer" :status :good :model "HP Officejet 630 All-in-one Printer" :status :good :model "HP Officejet 6301 All-in-one Printer" :status :good :model "HP Officejet 6304 All-in-one Printer" :status :good :model "HP Officejet 6305 All-in-one Printer" :status :good :model "HP Officejet 6307 All-in-one Printer" :status :good :model "HP Officejet 6308 All-in-one Printer" :status :good :model "HP Officejet 6310 All-in-one Printer" :status :good :model "HP Officejet 6310v All-in-one Printer" :status :good :model "HP Officejet 6310xi All-in-one Printer" :status :good :model "HP Officejet 6313 All-in-one Printer" :status :good :model "HP Officejet 6315 All-in-one Printer" :status :good :model "HP Officejet 6318 All-in-one Printer" :status :good :model "HP Officejet 635 All-in-one Printer" :status :good :model "HP Officejet 6500 All-in-one Printer - e709a" :status :good :model "HP Officejet 6500 All-in-one Printer - e709c" :status :good :model "HP Officejet 6500 e710" :status :good :model "HP Officejet 6500 e710n-z" :status :good :model "HP Officejet 6500 Wireless All-in-one Printer - e709n" :status :good :model "HP Officejet 6500 Wireless All-in-one Printer - e709q" :status :good :model "HP Officejet 6600 E-all-in-one Printer - h711a" :status :good :model "HP Officejet 6700 Premium E-all-in-one printer-h711n" :status :good :model "HP Officejet 6800 E-all-in-one" :status :good :model "HP Officejet 6810 E-all-in-one Printer Series" :status :good :model "HP Officejet 6812 E-all-in-one Printer" :status :good :model "HP Officejet 6815 E-all-in-one Printer" :status :good :model "HP Officejet 6820 E-all-in-one Printer" :status :good :model "HP Officejet 6950 All-in-one" :status :good :model "HP Officejet 6960 All-in-one" :status :good :model "HP Officejet 700 All-in-one Printer" :status :good :model "HP Officejet 710 All-in-one Printer" :status :good :model "HP Officejet 7100 All-in-one Printer" :status :good :model "HP Officejet 7110 All-in-one Printer" :status :good :model "HP Officejet 7110xi All-in-one Printer" :status :good :model "HP Officejet 7115 All-in-one Printer" :status :good :model "HP Officejet 7130 All-in-one Printer" :status :good :model "HP Officejet 7130xi All-in-one Printer" :status :good :model "HP Officejet 7135xi All-in-one Printer" :status :good :model "HP Officejet 7140xi All-in-one Printer" :status :good :model "HP Officejet 720 All-in-one Printer" :status :good :model "HP Officejet 7205 All-in-one Printer" :status :good :model "HP Officejet 7208 All-in-one Printer" :status :good :model "HP Officejet 7210 All-in-one Printer" :status :good :model "HP Officejet 7210v All-in-one Printer" :status :good :model "HP Officejet 7210xi All-in-one Printer" :status :good :model "HP Officejet 7213 All-in-one Printer" :status :good :model "HP Officejet 7215 All-in-one Printer" :status :good :model "HP Officejet 725 All-in-one Printer" :status :good :model "HP Officejet 7310 All-in-one Printer" :status :good :model "HP Officejet 7310xi All-in-one Printer" :status :good :model "HP Officejet 7313 All-in-one Printer" :status :good :model "HP Officejet 7408 All-in-one Printer" :status :good :model "HP Officejet 7410 All-in-one Printer" :status :good :model "HP Officejet 7410xi All-in-one Printer" :status :good :model "HP Officejet 7413 All-in-one Printer" :status :good :model "HP Officejet 7500 e910" :status :good :model "HP Officejet 7510 Wide Format E-all-in-one Printer" :status :good :model "HP Officejet 7610 Wide Format E-all-in-one Printer" :status :good :model "HP Officejet 7612 Wide Format E-all-in-one Printer" :status :good :model "HP Officejet 8010 All-in-one Printer Series" :status :good :model "HP Officejet 8020 All-in-one Printer Series" :status :good :model "HP Officejet 8040 E-all-in-one" :status :good :model "HP Officejet 8702 All-in-one" :status :good :model "HP Officejet 9110 All-in-one Printer" :status :good :model "HP Officejet 9120 All-in-one Printer" :status :good :model "HP Officejet 9130 All-in-one Printer" :status :good :model "HP Officejet All-in-one 9010" :status :good :model "HP Officejet d125xi All-in-one Printer" :status :good :model "HP Officejet d135 All-in-one Printer" :status :good :model "HP Officejet d135xi All-in-one Printer" :status :good :model "HP Officejet d145 All-in-one Printer" :status :good :model "HP Officejet d145xi All-in-one Printer" :status :good :model "HP Officejet d155xi All-in-one Printer" :status :good :model "HP Officejet g55 All-in-one Printer" :status :good :model "HP Officejet g55xi All-in-one Printer" :status :good :model "HP Officejet g85 All-in-one Printer" :status :good :model "HP Officejet g85xi All-in-one Printer" :status :good :model "HP Officejet g95 All-in-one Printer" :status :good :model "HP Officejet j3508 All-in-one Printer" :status :good :model "HP Officejet j3608 All-in-one Printer" :status :good :model "HP Officejet j3625 All-in-one Printer" :status :good :model "HP Officejet j3635 All-in-one Printer" :status :good :model "HP Officejet j3640 All-in-one Printer" :status :good :model "HP Officejet j3650 All-in-one Printer" :status :good :model "HP Officejet j3680 All-in-one Printer" :status :good :model "HP Officejet j4524 All-in-one Printer" :status :good :model "HP Officejet j4525 All-in-one Printer" :status :good :model "HP Officejet j4535 All-in-one Printer" :status :good :model "HP Officejet j4540 All-in-one Printer" :status :good :model "HP Officejet j4550 All-in-one Printer" :status :good :model "HP Officejet j4560 All-in-one Printer" :status :good :model "HP Officejet j4580 All-in-one Printer" :status :good :model "HP Officejet j4580c All-in-one Printer" :status :good :model "HP Officejet j4585 All-in-one Printer" :status :good :model "HP Officejet j4660 All-in-one Printer" :status :good :model "HP Officejet j4680 All-in-one Printer" :status :good :model "HP Officejet j4680c All-in-one Printer" :status :good :model "HP Officejet j5505 All-in-one Printer" :status :good :model "HP Officejet j5508 All-in-one Printer" :status :good :model "HP Officejet j5510 All-in-one Printer" :status :good :model "HP Officejet j5510v All-in-one Printer" :status :good :model "HP Officejet j5510xi All-in-one Printer" :status :good :model "HP Officejet j5515 All-in-one Printer" :status :good :model "HP Officejet j5520 All-in-one Printer" :status :good :model "HP Officejet j5725 All-in-one Printer" :status :good :model "HP Officejet j5730 All-in-one Printer" :status :good :model "HP Officejet j5735 All-in-one Printer" :status :good :model "HP Officejet j5738 All-in-one Printer" :status :good :model "HP Officejet j5740 All-in-one Printer" :status :good :model "HP Officejet j5750 All-in-one Printer" :status :good :model "HP Officejet j5780 All-in-one Printer" :status :good :model "HP Officejet j5783 All-in-one Printer" :status :good :model "HP Officejet j5785 All-in-one Printer" :status :good :model "HP Officejet j5788 All-in-one Printer" :status :good :model "HP Officejet j5790 All-in-one Printer" :status :good :model "HP Officejet j6405 All-in-one Printer" :status :good :model "HP Officejet j6410 All-in-one Printer" :status :good :model "HP Officejet j6413 All-in-one Printer" :status :good :model "HP Officejet j6415 All-in-one Printer" :status :good :model "HP Officejet j6424 All-in-one Printer" :status :good :model "HP Officejet j6450 All-in-one Printer" :status :good :model "HP Officejet j6480 All-in-one Printer" :status :good :model "HP Officejet j6488 All-in-one Printer" :status :good :model "HP Officejet k60 All-in-one Printer" :status :good :model "HP Officejet k60xi All-in-one Printer" :status :good :model "HP Officejet k80 All-in-one Printer" :status :good :model "HP Officejet k80xi All-in-one Printer" :status :good :model "HP Officejet Pro 1150c All-in-one Printer" :status :good :model "HP Officejet Pro 1150cse All-in-one Printer" :status :good :model "HP Officejet Pro 1170c All-in-one Printer" :status :good :model "HP Officejet Pro 1170cse All-in-one Printer" :status :good :model "HP Officejet Pro 1170cxi All-in-one Printer" :status :good :model "HP Officejet Pro 1175c All-in-one Printer" :status :good :model "HP Officejet Pro 1175cse All-in-one Printer" :status :good :model "HP Officejet Pro 1175cxi All-in-one Printer" :status :good :model "HP Officejet Pro 276dw Multifunction Printer" :status :good :model "HP Officejet Pro 3610 Black And White E-all-in-one" :status :good :model "HP Officejet Pro 3620 Black And White E-all-in-one" :status :good :model "HP Officejet Pro 6830 E-all-in-one" :status :good :model "HP Officejet Pro 6835 E-all-in-one" :status :good :model "HP Officejet Pro 6960 All-in-one" :status :good :model "HP Officejet Pro 6968 All-in-one" :status :good :model "HP Officejet Pro 6970 All-in-one" :status :good :model "HP Officejet Pro 6975 All-in-one" :status :good :model "HP Officejet Pro 6978 All-in-one" :status :good :model "HP Officejet Pro 7720 Wide Format All-in-one" :status :good :model "HP Officejet Pro 7730 Wide Format All-in-one" :status :good :model "HP Officejet Pro 7740 Wide Format All-in-one" :status :good :model "HP Officejet Pro 8020 All-in-one Printer Series" :status :good :model "HP Officejet Pro 8030 All-in-one Printer Series" :status :good :model "HP Officejet Pro 8500 All-in-one Printer - a909a" :status :good :model "HP Officejet Pro 8500 Premier All-in-one Printer - a909n" :status :good :model "HP Officejet Pro 8500 Wireless All-in-one Printer - a909g" :status :good :model "HP Officejet Pro 8500a E-aio Printer - a910a" :status :good :model "HP Officejet Pro 8500a Plus E-aio Printer - a910g" :status :good :model "HP Officejet Pro 8500a Premium E-aio Printer - a910n" :status :good :model "HP Officejet Pro 8600 E-aio n911a" :status :good :model "HP Officejet Pro 8600 Plus E-aio n911g" :status :good :model "HP Officejet Pro 8600 Premium E-aio n911n" :status :good :model "HP Officejet Pro 8610 E-all-in-one Printer" :status :good :model "HP Officejet Pro 8615 E-all-in-one Printer" :status :good :model "HP Officejet Pro 8616 E-all-in-one Printer" :status :good :model "HP Officejet Pro 8620 E-all-in-one Printer" :status :good :model "HP Officejet Pro 8625 E-all-in-one Printer" :status :good :model "HP Officejet Pro 8630 E-all-in-one Printer" :status :good :model "HP Officejet Pro 8640 E-all-in-one Printer" :status :good :model "HP Officejet Pro 8660 E-all-in-one Printer" :status :good :model "HP Officejet Pro 8710 All-in-one Printer" :status :good :model "HP Officejet Pro 8715 All-in-one Printer" :status :good :model "HP Officejet Pro 8720 All-in-one Printer" :status :good :model "HP Officejet Pro 8725 All-in-one Printer" :status :good :model "HP Officejet Pro 8730" :status :good :model "HP Officejet Pro 8732 All-in-one Printer" :status :good :model "HP Officejet Pro 8740 All-in-one Printer" :status :good :model "HP Officejet Pro All-in-one 9010" :status :good :model "HP Officejet Pro All-in-one 9020" :status :good :model "HP Officejet Pro l7300 Series All-in-one Printer" :status :good :model "HP Officejet Pro l7380 All-in-one Printer" :status :good :model "HP Officejet Pro l7480 All-in-one Printer" :status :good :model "HP Officejet Pro l7500 Series All-in-one Printer" :status :good :model "HP Officejet Pro l7550 All-in-one Printer" :status :good :model "HP Officejet Pro l7555 All-in-one Printer" :status :good :model "HP Officejet Pro l7580 All-in-one Printer" :status :good :model "HP Officejet Pro l7590 All-in-one Printer" :status :good :model "HP Officejet Pro l7600 Series All-in-one Printer" :status :good :model "HP Officejet Pro l7650 All-in-one Printer" :status :good :model "HP Officejet Pro l7680 All-in-one Printer" :status :good :model "HP Officejet Pro l7681 All-in-one Printer" :status :good :model "HP Officejet Pro l7700 Series All-in-one Printer" :status :good :model "HP Officejet Pro l7710 All-in-one Printer" :status :good :model "HP Officejet Pro l7750 All-in-one Printer" :status :good :model "HP Officejet Pro l7780 All-in-one Printer" :status :good :model "HP Officejet Pro x476 Multifunction Printer Series" :status :good :model "HP Officejet Pro x476dn Multifunction Printer" :status :good :model "HP Officejet Pro x476dw Multifunction Printer" :status :good :model "HP Officejet Pro x576 Multifunction Printer Series" :status :good :model "HP Officejet Pro x576dw Multifunction Printer" :status :good :model "HP Officejet r40 All-in-one Printer" :status :good :model "HP Officejet r40xi All-in-one Printer" :status :good :model "HP Officejet r45 All-in-one Printer" :status :good :model "HP Officejet r60 All-in-one Printer" :status :good :model "HP Officejet r65 All-in-one Printer" :status :good :model "HP Officejet r80 All-in-one Printer" :status :good :model "HP Officejet r80xi All-in-one Printer" :status :good :model "HP Officejet t45 All-in-one Printer" :status :good :model "HP Officejet t45xi All-in-one Printer" :status :good :model "HP Officejet t65 All-in-one Printer" :status :good :model "HP Officejet t65xi All-in-one Printer" :status :good :model "HP Officejet v30 All-in-one Printer" :status :good :model "HP Officejet v40 All-in-one Printer" :status :good :model "HP Officejet v40s All-in-one Printer" :status :good :model "HP Officejet v40xi All-in-one Printer" :status :good :model "HP Officejet v45 All-in-one Printer" :status :good :model "HP Pagewide Managed MFP p57750dw" :status :good :model "HP Pagewide Managed MFP p77740zs" :status :good :model "HP Pagewide Managed MFP p77750z" :status :good :model "HP Pagewide Managed MFP p77750zs" :status :good :model "HP Pagewide MFP 377dw" :status :good :model "HP Pagewide Pro 477dn Multifunction Printer" :status :good :model "HP Pagewide Pro 477dw Multifunction Printer" :status :good :model "HP Pagewide Pro 577dw Multifunction Printer" :status :good :model "HP Pagewide Pro 577z Multifunction Printer" :status :good :model "HP Pagewide Pro MFP 772dw" :status :good :model "HP Photosmart 2570 All-in-one Printer" :status :good :model "HP Photosmart 2571 All-in-one Printer" :status :good :model "HP Photosmart 2573 All-in-one Printer" :status :good :model "HP Photosmart 2574 All-in-one Printer" :status :good :model "HP Photosmart 2575 All-in-one Printer" :status :good :model "HP Photosmart 2575a All-in-one Printer" :status :good :model "HP Photosmart 2575v All-in-one Printer" :status :good :model "HP Photosmart 2575xi All-in-one Printer" :status :good :model "HP Photosmart 2578 All-in-one Printer" :status :good :model "HP Photosmart 2605 All-in-one Printer" :status :good :model "HP Photosmart 2608 All-in-one Printer" :status :good :model "HP Photosmart 2610 All-in-one Printer" :status :good :model "HP Photosmart 2610v All-in-one Printer" :status :good :model "HP Photosmart 2610xi All-in-one Printer" :status :good :model "HP Photosmart 2613 All-in-one Printer" :status :good :model "HP Photosmart 2615 All-in-one Printer" :status :good :model "HP Photosmart 2710 All-in-one Printer" :status :good :model "HP Photosmart 2710xi All-in-one Printer" :status :good :model "HP Photosmart 2713 All-in-one Printer" :status :good :model "HP Photosmart 3108 All-in-one Printer" :status :good :model "HP Photosmart 3110 All-in-one Printer" :status :good :model "HP Photosmart 3110v All-in-one Printer" :status :good :model "HP Photosmart 3207 All-in-one Printer" :status :good :model "HP Photosmart 3210 All-in-one Printer" :status :good :model "HP Photosmart 3210a All-in-one Printer" :status :good :model "HP Photosmart 3210v All-in-one Printer" :status :good :model "HP Photosmart 3210xi All-in-one Printer" :status :good :model "HP Photosmart 3213 All-in-one Printer" :status :good :model "HP Photosmart 3214 All-in-one Printer" :status :good :model "HP Photosmart 3308 All-in-one Printer" :status :good :model "HP Photosmart 3310 All-in-one Printer" :status :good :model "HP Photosmart 3310xi All-in-one Printer" :status :good :model "HP Photosmart 3313 All-in-one Printer" :status :good :model "HP Photosmart 3314 All-in-one Printer" :status :good :model "HP Photosmart 5510 E-all-in-one" :status :good :model "HP Photosmart 5510d E-all-in-one" :status :good :model "HP Photosmart 5520 E-all-in-one" :status :good :model "HP Photosmart 5521 E-all-in-one Printer" :status :good :model "HP Photosmart 5522 E-all-in-one Printer" :status :good :model "HP Photosmart 5524 E-all-in-one Printer" :status :good :model "HP Photosmart 5525 E-all-in-one Printer" :status :good :model "HP Photosmart 6510 E-all-in-one" :status :good :model "HP Photosmart 6525 E All-in-one" :status :good :model "HP Photosmart 7510 E-all-in-one" :status :good :model "HP Photosmart 7520 E-all-in-one" :status :good :model "HP Photosmart 7525 E-all-in-one" :status :good :model "HP Photosmart All-in-one Printer - b010" :status :good :model "HP Photosmart b109a Series" :status :good :model "HP Photosmart c3110 All-in-one Printer" :status :good :model "HP Photosmart c3125 All-in-one Printer" :status :good :model "HP Photosmart c3135 All-in-one Printer" :status :good :model "HP Photosmart c3140 All-in-one Printer" :status :good :model "HP Photosmart c3150 All-in-one Printer" :status :good :model "HP Photosmart c3170 All-in-one Printer" :status :good :model "HP Photosmart c3173 All-in-one Printer" :status :good :model "HP Photosmart c3175 All-in-one Printer" :status :good :model "HP Photosmart c3180 All-in-one Printer" :status :good :model "HP Photosmart c3183 All-in-one Printer" :status :good :model "HP Photosmart c3188 All-in-one Printer" :status :good :model "HP Photosmart c3190 All-in-one Printer" :status :good :model "HP Photosmart c3193 All-in-one Printer" :status :good :model "HP Photosmart c3194 All-in-one Printer" :status :good :model "HP Photosmart c4110 All-in-one Printer" :status :good :model "HP Photosmart c4140 All-in-one Printer" :status :good :model "HP Photosmart c4150 All-in-one Printer" :status :good :model "HP Photosmart c4170 All-in-one Printer" :status :good :model "HP Photosmart c4173 All-in-one Printer" :status :good :model "HP Photosmart c4175 All-in-one Printer" :status :good :model "HP Photosmart c4180 All-in-one Printer" :status :good :model "HP Photosmart c4183 All-in-one Printer" :status :good :model "HP Photosmart c4188 All-in-one Printer" :status :good :model "HP Photosmart c4190 All-in-one Printer" :status :good :model "HP Photosmart c4193 All-in-one Printer" :status :good :model "HP Photosmart c4194 All-in-one Printer" :status :good :model "HP Photosmart c4205 All-in-one Printer" :status :good :model "HP Photosmart c4210 All-in-one Printer" :status :good :model "HP Photosmart c4235 All-in-one Printer" :status :good :model "HP Photosmart c4240 All-in-one Printer" :status :good :model "HP Photosmart c4250 All-in-one Printer" :status :good :model "HP Photosmart c4270 All-in-one Printer" :status :good :model "HP Photosmart c4272 All-in-one Printer" :status :good :model "HP Photosmart c4273 All-in-one Printer" :status :good :model "HP Photosmart c4275 All-in-one Printer" :status :good :model "HP Photosmart c4280 All-in-one Printer" :status :good :model "HP Photosmart c4283 All-in-one Printer" :status :good :model "HP Photosmart c4285 All-in-one Printer" :status :good :model "HP Photosmart c4288 All-in-one Printer" :status :good :model "HP Photosmart c4293 All-in-one Printer" :status :good :model "HP Photosmart c4294 All-in-one Printer" :status :good :model "HP Photosmart c4340 All-in-one Printer" :status :good :model "HP Photosmart c4342 All-in-one Printer" :status :good :model "HP Photosmart c4343 All-in-one Printer" :status :good :model "HP Photosmart c4344 All-in-one Printer" :status :good :model "HP Photosmart c4345 All-in-one Printer" :status :good :model "HP Photosmart c4348 All-in-one Printer" :status :good :model "HP Photosmart c4380 All-in-one Printer" :status :good :model "HP Photosmart c4383 All-in-one Printer" :status :good :model "HP Photosmart c4384 All-in-one Printer" :status :good :model "HP Photosmart c4385 All-in-one Printer" :status :good :model "HP Photosmart c4388 All-in-one Printer" :status :good :model "HP Photosmart c4410 All-in-one Printer" :status :good :model "HP Photosmart c4424 All-in-one Printer" :status :good :model "HP Photosmart c4435 All-in-one Printer" :status :good :model "HP Photosmart c4440 All-in-one Printer" :status :good :model "HP Photosmart c4450 All-in-one Printer" :status :good :model "HP Photosmart c4470 All-in-one Printer" :status :good :model "HP Photosmart c4472 All-in-one Printer" :status :good :model "HP Photosmart c4473 All-in-one Printer" :status :good :model "HP Photosmart c4480 All-in-one Printer" :status :good :model "HP Photosmart c4483 All-in-one Printer" :status :good :model "HP Photosmart c4485 All-in-one Printer" :status :good :model "HP Photosmart c4486 All-in-one Printer" :status :good :model "HP Photosmart c4488 All-in-one Printer" :status :good :model "HP Photosmart c4490 All-in-one Printer" :status :good :model "HP Photosmart c4493 All-in-one Printer" :status :good :model "HP Photosmart c4494 All-in-one Printer" :status :good :model "HP Photosmart c4540 All-in-one Printer" :status :good :model "HP Photosmart c4550 All-in-one Printer" :status :good :model "HP Photosmart c4570 All-in-one Printer" :status :good :model "HP Photosmart c4572 All-in-one Printer" :status :good :model "HP Photosmart c4573 All-in-one Printer" :status :good :model "HP Photosmart c4575 All-in-one Printer" :status :good :model "HP Photosmart c4580 All-in-one Printer" :status :good :model "HP Photosmart c4583 All-in-one Printer" :status :good :model "HP Photosmart c4585 All-in-one Printer" :status :good :model "HP Photosmart c4588 All-in-one Printer" :status :good :model "HP Photosmart c4593 All-in-one Printer" :status :good :model "HP Photosmart c4599 All-in-one Printer" :status :good :model "HP Photosmart c4610 All-in-one Printer" :status :good :model "HP Photosmart c4635 All-in-one Printer" :status :good :model "HP Photosmart c4640 All-in-one Printer" :status :good :model "HP Photosmart c4650 All-in-one Printer" :status :good :model "HP Photosmart c4670 All-in-one Printer" :status :good :model "HP Photosmart c4673 All-in-one Printer" :status :good :model "HP Photosmart c4680 All-in-one Printer" :status :good :model "HP Photosmart c4683 All-in-one Printer" :status :good :model "HP Photosmart c4688 All-in-one Printer" :status :good :model "HP Photosmart c4740 All-in-one Printer" :status :good :model "HP Photosmart c4750 All-in-one Printer" :status :good :model "HP Photosmart c4780 All-in-one Printer" :status :good :model "HP Photosmart c4783 All-in-one Printer" :status :good :model "HP Photosmart c4785 All-in-one Printer" :status :good :model "HP Photosmart c4788 All-in-one Printer" :status :good :model "HP Photosmart c4793 All-in-one Printer" :status :good :model "HP Photosmart c4795 All-in-one Printer" :status :good :model "HP Photosmart c4798 All-in-one Printer" :status :good :model "HP Photosmart c4799 All-in-one Printer" :status :good :model "HP Photosmart c5140 All-in-one Printer" :status :good :model "HP Photosmart c5150 All-in-one Printer" :status :good :model "HP Photosmart c5170 All-in-one Printer" :status :good :model "HP Photosmart c5173 All-in-one Printer" :status :good :model "HP Photosmart c5175 All-in-one Printer" :status :good :model "HP Photosmart c5180 All-in-one Printer" :status :good :model "HP Photosmart c5183 All-in-one Printer" :status :good :model "HP Photosmart c5185 All-in-one Printer" :status :good :model "HP Photosmart c5188 All-in-one Printer" :status :good :model "HP Photosmart c5194 All-in-one Printer" :status :good :model "HP Photosmart c5240 All-in-one Printer" :status :good :model "HP Photosmart c5250 All-in-one Printer" :status :good :model "HP Photosmart c5270 All-in-one Printer" :status :good :model "HP Photosmart c5273 All-in-one Printer" :status :good :model "HP Photosmart c5275 All-in-one Printer" :status :good :model "HP Photosmart c5280 All-in-one Printer" :status :good :model "HP Photosmart c5283 All-in-one Printer" :status :good :model "HP Photosmart c5288 All-in-one Printer" :status :good :model "HP Photosmart c5290 All-in-one Printer" :status :good :model "HP Photosmart c5293 All-in-one Printer" :status :good :model "HP Photosmart c5370 All-in-one Printer" :status :good :model "HP Photosmart c5373 All-in-one Printer" :status :good :model "HP Photosmart c5380 All-in-one Printer" :status :good :model "HP Photosmart c5383 All-in-one Printer" :status :good :model "HP Photosmart c5388 All-in-one Printer" :status :good :model "HP Photosmart c5390 All-in-one Printer" :status :good :model "HP Photosmart c5393 All-in-one Printer" :status :good :model "HP Photosmart c5540 All-in-one Printer" :status :good :model "HP Photosmart c5550 All-in-one Printer" :status :good :model "HP Photosmart c5570 All-in-one Printer" :status :good :model "HP Photosmart c5580 All-in-one Printer" :status :good :model "HP Photosmart c6150 All-in-one Printer" :status :good :model "HP Photosmart c6154 All-in-one Printer" :status :good :model "HP Photosmart c6170 All-in-one Printer" :status :good :model "HP Photosmart c6175 All-in-one Printer" :status :good :model "HP Photosmart c6180 All-in-one Printer" :status :good :model "HP Photosmart c6183 All-in-one Printer" :status :good :model "HP Photosmart c6185 All-in-one Printer" :status :good :model "HP Photosmart c6188 All-in-one Printer" :status :good :model "HP Photosmart c6190 All-in-one Printer" :status :good :model "HP Photosmart c6240 All-in-one Printer" :status :good :model "HP Photosmart c6245 All-in-one Printer" :status :good :model "HP Photosmart c6250 All-in-one Printer" :status :good :model "HP Photosmart c6260 All-in-one Printer" :status :good :model "HP Photosmart c6263 All-in-one Printer" :status :good :model "HP Photosmart c6268 All-in-one Printer" :status :good :model "HP Photosmart c6270 All-in-one Printer" :status :good :model "HP Photosmart c6275 All-in-one Printer" :status :good :model "HP Photosmart c6280 All-in-one Printer" :status :good :model "HP Photosmart c6283 All-in-one Printer" :status :good :model "HP Photosmart c6285 All-in-one Printer" :status :good :model "HP Photosmart c6286 All-in-one Printer" :status :good :model "HP Photosmart c6288 All-in-one Printer" :status :good :model "HP Photosmart c6324 All-in-one Printer" :status :good :model "HP Photosmart c6340 All-in-one Printer" :status :good :model "HP Photosmart c6350 All-in-one Printer" :status :good :model "HP Photosmart c6375 All-in-one Printer" :status :good :model "HP Photosmart c6380 All-in-one Printer" :status :good :model "HP Photosmart c6383 All-in-one Printer" :status :good :model "HP Photosmart c6388 All-in-one Printer" :status :good :model "HP Photosmart c7150 All-in-one Printer" :status :good :model "HP Photosmart c7154 All-in-one Printer" :status :good :model "HP Photosmart c7170 All-in-one Printer" :status :good :model "HP Photosmart c7180 All-in-one Printer" :status :good :model "HP Photosmart c7183 All-in-one Printer" :status :good :model "HP Photosmart c7185 All-in-one Printer" :status :good :model "HP Photosmart c7188 All-in-one Printer" :status :good :model "HP Photosmart c7190 All-in-one Printer" :status :good :model "HP Photosmart c7250 All-in-one Printer" :status :good :model "HP Photosmart c7275 All-in-one Printer" :status :good :model "HP Photosmart c7280 All-in-one Printer" :status :good :model "HP Photosmart c7283 All-in-one Printer" :status :good :model "HP Photosmart c7288 All-in-one Printer" :status :good :model "HP Photosmart c8150 All-in-one Printer" :status :good :model "HP Photosmart c8180 All-in-one Printer" :status :good :model "HP Photosmart c8183 All-in-one Printer" :status :good :model "HP Photosmart c8188 All-in-one Printer" :status :good :model "HP Photosmart d110 Series Printer" :status :good :model "HP Photosmart Estn c510 Series" :status :good :model "HP Photosmart Ink Adv k510" :status :good :model "HP Photosmart Plus All-in-one Printer - b209a" :status :good :model "HP Photosmart Plus All-in-one Printer - b209b" :status :good :model "HP Photosmart Plus All-in-one Printer - b209c" :status :good :model "HP Photosmart Plus b210 Series" :status :good :model "HP Photosmart Prem c310 Series" :status :good :model "HP Photosmart Prem c410 Series" :status :good :model "HP Photosmart Premium All-in-one Printer Series - c309g" :status :good :model "HP Photosmart Premium All-in-one Printer Series - c309h" :status :good :model "HP Photosmart Premium Fax All-in-one Printer - c309a" :status :good :model "HP Photosmart Premium Fax All-in-one Printer Series -c309a" :status :good :model "HP Photosmart Premium Fax All-in-one Printer Series -c309c" :status :good :model "HP Photosmart Wireless All-in-one Printer - b109n" :status :good :model "HP Photosmart Wireless All-in-one Printer - b109q" :status :good :model "HP Photosmart Wireless All-in-one Printer - b109qr" :status :good :model "HP Photosmart Wireless All-in-one Printer - b110" :status :good :model "HP Photsmart 6520 E All-in-one" :status :good :model "HP Printer Scanner Copier 300" :status :good :model "HP PSC 1000 Series" :status :good :model "HP PSC 1110 All-in-one Printer" :status :good :model "HP PSC 1110v All-in-one Printer" :status :good :model "HP PSC 1118 All-in-one Printer" :status :good :model "HP PSC 1200 All-in-one Printer" :status :good :model "HP PSC 1205 All-in-one Printer" :status :good :model "HP PSC 1209 All-in-one Printer" :status :good :model "HP PSC 1210 All-in-one Printer" :status :good :model "HP PSC 1210v All-in-one Printer" :status :good :model "HP PSC 1210xi All-in-one Printer" :status :good :model "HP PSC 1213 All-in-one Printer" :status :good :model "HP PSC 1215 All-in-one Printer" :status :good :model "HP PSC 1216 All-in-one Printer" :status :good :model "HP PSC 1217 All-in-one Printer" :status :good :model "HP PSC 1218 All-in-one Printer" :status :good :model "HP PSC 1219 All-in-one Printer" :status :good :model "HP PSC 1300 All-in-one Printer" :status :good :model "HP PSC 1310 All-in-one Printer" :status :good :model "HP PSC 1311 All-in-one Printer" :status :good :model "HP PSC 1312 All-in-one Printer" :status :good :model "HP PSC 1315 All-in-one Printer" :status :good :model "HP PSC 1315s All-in-one Printer" :status :good :model "HP PSC 1315v All-in-one Printer" :status :good :model "HP PSC 1315xi All-in-one Printer" :status :good :model "HP PSC 1317 All-in-one Printer" :status :good :model "HP PSC 1318 All-in-one Printer" :status :good :model "HP PSC 1340 All-in-one Printer" :status :good :model "HP PSC 1350 All-in-one Printer" :status :good :model "HP PSC 1350v All-in-one Printer" :status :good :model "HP PSC 1350xi All-in-one Printer" :status :good :model "HP PSC 1355 All-in-one Printer" :status :good :model "HP PSC 1358 Series" :status :good :model "HP PSC 1401 All-in-one Printer" :status :good :model "HP PSC 1402 All-in-one Printer" :status :good :model "HP PSC 1403 All-in-one Printer" :status :good :model "HP PSC 1406 All-in-one Printer" :status :good :model "HP PSC 1408 All-in-one Printer" :status :good :model "HP PSC 1410 All-in-one Printer" :status :good :model "HP PSC 1410v All-in-one Printer" :status :good :model "HP PSC 1410xi All-in-one Printer" :status :good :model "HP PSC 1415 All-in-one Printer" :status :good :model "HP PSC 1417 All-in-one Printer" :status :good :model "HP PSC 1508 All-in-one Printer" :status :good :model "HP PSC 1510 All-in-one Printer" :status :good :model "HP PSC 1510 Series" :status :good :model "HP PSC 1510s All-in-one Printer" :status :good :model "HP PSC 1510v All-in-one Printer" :status :good :model "HP PSC 1510xi All-in-one Printer" :status :good :model "HP PSC 1513 All-in-one Printer" :status :good :model "HP PSC 1513s All-in-one Printer" :status :good :model "HP PSC 1514 All-in-one Printer" :status :good :model "HP PSC 1600 All-in-one Printer" :status :good :model "HP PSC 1603 All-in-one Printer" :status :good :model "HP PSC 1605 All-in-one Printer" :status :good :model "HP PSC 1608 All-in-one Printer" :status :good :model "HP PSC 1610 All-in-one Printer" :status :good :model "HP PSC 1610v All-in-one Printer" :status :good :model "HP PSC 1610xi All-in-one Printer" :status :good :model "HP PSC 1613 All-in-one Printer" :status :good :model "HP PSC 1615 All-in-one Printer" :status :good :model "HP PSC 2105 All-in-one Printer" :status :good :model "HP PSC 2108 All-in-one Printer" :status :good :model "HP PSC 2110 All-in-one Printer" :status :good :model "HP PSC 2110v All-in-one Printer" :status :good :model "HP PSC 2110xi All-in-one Printer" :status :good :model "HP PSC 2115 All-in-one Printer" :status :good :model "HP PSC 2150 All-in-one Printer" :status :good :model "HP PSC 2170 All-in-one Printer" :status :good :model "HP PSC 2171 All-in-one Printer" :status :good :model "HP PSC 2175 All-in-one Printer" :status :good :model "HP PSC 2175v All-in-one Printer" :status :good :model "HP PSC 2175xi All-in-one Printer" :status :good :model "HP PSC 2179 All-in-one Printer" :status :good :model "HP PSC 2200 All-in-one Printer" :status :good :model "HP PSC 2210 All-in-one Printer" :status :good :model "HP PSC 2210v All-in-one Printer" :status :good :model "HP PSC 2210xi All-in-one Printer" :status :good :model "HP PSC 2300 Series All-in-one Printer" :status :good :model "HP PSC 2310 All-in-one Printer" :status :good :model "HP PSC 2350 All-in-one Printer" :status :good :model "HP PSC 2352 All-in-one Printer" :status :good :model "HP PSC 2353 All-in-one Printer" :status :good :model "HP PSC 2353p All-in-one Printer" :status :good :model "HP PSC 2355 All-in-one Printer" :status :good :model "HP PSC 2355p All-in-one Printer" :status :good :model "HP PSC 2355v All-in-one Printer" :status :good :model "HP PSC 2355xi All-in-one Printer" :status :good :model "HP PSC 2357 All-in-one Printer" :status :good :model "HP PSC 2358 All-in-one Printer" :status :good :model "HP PSC 2405 Photosmart All-in-one Printer" :status :good :model "HP PSC 2410 Photosmart All-in-one Printer" :status :good :model "HP PSC 2410v Photosmart All-in-one Printer" :status :good :model "HP PSC 2410xi Photosmart All-in-one Printer" :status :good :model "HP PSC 2420 Photosmart All-in-one Printer" :status :good :model "HP PSC 2450 Photosmart All-in-one Printer" :status :good :model "HP PSC 2500 Photosmart All-in-one Printer" :status :good :model "HP PSC 2510 Photosmart All-in-one Printer" :status :good :model "HP PSC 2510xi Photosmart All-in-one Printer" :status :good :model "HP PSC 2550 Photosmart All-in-one Printer" :status :good :model "HP PSC 500 All-in-one Printer" :status :good :model "HP PSC 500xi All-in-one Printer" :status :good :model "HP PSC 720 All-in-one Printer" :status :good :model "HP PSC 750 All-in-one Printer" :status :good :model "HP PSC 750xi All-in-one Printer" :status :good :model "HP PSC 760 All-in-one Printer" :status :good :model "HP PSC 780 All-in-one Printer" :status :good :model "HP PSC 780xi All-in-one Printer" :status :good :model "HP PSC 900 All-in-one Printer" :status :good :model "HP PSC 920 All-in-one Printer" :status :good :model "HP PSC 950 All-in-one Printer" :status :good :model "HP PSC 950vr All-in-one Printer" :status :good :model "HP PSC 950xi All-in-one Printer" :status :good :model "HP Scanjet Enterprise 7500" :status :good :model "HP Scanjet Enterprise Flow 5000 s4" :status :good :model "HP Scanjet Enterprise Flow 7000 s3" :status :good :model "HP Scanjet Enterprise Flow n9120 fn2 Document Scanner" :status :good :model "HP Scanjet Pro 3000 s3" :status :good :model "HP Scanjet Pro 3500 f1 Flatbed Scanner" :status :good :model "HP Scanjet Pro 4500 fn1" :status :good :model "HP Smart Tank 350" :status :good :model "HP Smart Tank 500 Series" :status :good :model "HP Smart Tank 510" :status :good :model "HP Smart Tank 530 Series" :status :good :model "HP Smart Tank 610" :status :good :model "HP Smart Tank Plus 550" :status :good :model "HP Smart Tank Plus 570 Series" :status :good :model "HP Smart Tank Plus 650" :status :good :model "HP Smart Tank Wireless 450" :status :good :model "HP Tango" :status :good :model "HP Tango X" :status :good sane-backends-1.0.29/doc/descriptions-external/cs3200f.desc0000666000000000000000000000215113615534521020213 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "cs3200f" ; name of backend ;:version "0" ; version of backend (or "unmaintained") ;:manpage "sane-cs3200f" ; name of manpage (if it exists) ;:url "http://www.luser.com/temp/" ; backend's web page :comment "Backend is in experimental CVS" ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Canon" :url "http://www.canon.com/" :model "CanoScan 3200F" :url "/unsupported/canon-3200f.html" :interface "USB" :usbid "0x04a9" "0x2216" :status :minimal :comment "Backend is in experimental CVS." sane-backends-1.0.29/doc/descriptions-external/scangearmp2.desc0000666000000000000000000001737413615534521021352 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon_pixma" ; name of backend ;:version "(external)" ; version of backend :url "https://github.com/Ordissimo/scangearmp2/blob/master/README.md" ; backend's web page :comment "External binary-only backend for Linux i386 and x86_64?. See the website for the latest release." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Canon" ; name a manufacturer :url "https://www.canon.com/" :comment "Multi Function Peripheral. External backend made by Canon. Please check the Canon website and/or contact us if you have a Canon device not mentioned here." ; ; Canon MFP2 conf file ; ; ---- V390 -------------------------- :model "G6000 series" :interface "USB WiFi" :usbid "0x04a9" "0x1865" :status :good :model "G6080 series" :interface "USB WiFi" :usbid "0x04a9" "0x1866" :status :good :model "TS5300 series" :interface "USB WiFi" :usbid "0x04a9" "0x188b" :status :good :model "TS5380 series" :interface "USB WiFi" :usbid "0x04a9" "0x188c" :status :good :model "TS6300 series" :interface "USB WiFi" :usbid "0x04a9" "0x188d" :status :good :model "TS6380 series" :interface "USB WiFi" :usbid "0x04a9" "0x188e" :status :good :model "TS7330 series" :interface "USB WiFi" :usbid "0x04a9" "0x188f" :status :good :model "TS8300 series" :interface "USB WiFi" :usbid "0x04a9" "0x1890" :status :good :model "TS8380 series" :interface "USB WiFi" :usbid "0x04a9" "0x1891" :status :good :model "TS8330 series" :interface "USB WiFi" :usbid "0x04a9" "0x1892" :status :good :model "XK60 series" :interface "USB WiFi" :usbid "0x04a9" "0x1893" :status :good :model "TS6330 series" :interface "USB WiFi" :usbid "0x04a9" "0x1894" :status :good :model "TS3300 series" :interface "USB WiFi" :usbid "0x04a9" "0x18a2" :status :good :model "E3300 series" :interface "USB WiFi" :usbid "0x04a9" "0x18a3" :status :good ; ---- V370 -------------------------- :model "TS8200 series" :interface "USB WiFi" :usbid "0x04a9" "0x1859" :status :good :model "XK80 series" :interface "USB WiFi" :usbid "0x04a9" "0x1873" :status :good :model "TS8230 series" :interface "USB WiFi" :usbid "0x04a9" "0x185b" :status :good :model "TS8280 series" :interface "USB WiFi" :usbid "0x04a9" "0x185a" :status :good :model "TS6200 series" :interface "USB WiFi" :usbid "0x04a9" "0x1856" :status :good :model "TS6230 series" :interface "USB WiFi" :usbid "0x04a9" "0x1858" :status :good :model "TS6280 series" :interface "USB WiFi" :usbid "0x04a9" "0x1857" :status :good :model "TS9500 series" :interface "USB WiFi" :usbid "0x04a9" "0x185c" :status :good :model "TR9530 series" :interface "USB WiFi" :usbid "0x04a9" "0x185e" :status :good :model "TS9580 series" :interface "USB WiFi" :usbid "0x04a9" "0x185d" :status :good :model "TR4500 series" :interface "USB WiFi" :usbid "0x04a9" "0x1854" :status :good :model "E4200 series" :interface "USB WiFi" :usbid "0x04a9" "0x1855" :status :good :model "LiDE 400" :interface "USB" :usbid "0x04a9" "0x1912" :status :good :model "LiDE 300" :interface "USB" :usbid "0x04a9" "0x1913" :status :good ; ---- V360 -------------------------- :model "G3010 series" :interface "USB WiFi" :usbid "0x04a9" "0x183b" :status :good :model "G4010 series" :interface "USB WiFi" :usbid "0x04a9" "0x183d" :status :good ; ---- V350 -------------------------- :model "TS9100 series" :interface "USB WiFi" :usbid "0x04a9" "0x1820" :status :good :model "TS8100 series" :interface "USB WiFi" :usbid "0x04a9" "0x1821" :status :good :model "TS6100 series" :interface "USB WiFi" :usbid "0x04a9" "0x1822" :status :good :model "TR8500 series" :interface "USB WiFi" :usbid "0x04a9" "0x1823" :status :good :model "TR7500 series" :interface "USB WiFi" :usbid "0x04a9" "0x1824" :status :good :model "TS5100 series" :interface "USB WiFi" :usbid "0x04a9" "0x1825" :status :good :model "TS3100 series" :interface "USB WiFi" :usbid "0x04a9" "0x1827" :status :good :model "E3100 series" :interface "USB WiFi" :usbid "0x04a9" "0x1828" :status :good :model "TS9180 series" :interface "USB WiFi" :usbid "0x04a9" "0x183e" :status :good :model "TS8180 series" :interface "USB WiFi" :usbid "0x04a9" "0x183f" :status :good :model "TS6180 series" :interface "USB WiFi" :usbid "0x04a9" "0x1840" :status :good :model "TR8580 series" :interface "USB WiFi" :usbid "0x04a9" "0x1841" :status :good :model "TS8130 series" :interface "USB WiFi" :usbid "0x04a9" "0x1842" :status :good :model "TS6130 series" :interface "USB WiFi" :usbid "0x04a9" "0x1843" :status :good :model "TR8530 series" :interface "USB WiFi" :usbid "0x04a9" "0x1844" :status :good :model "TR7530 series" :interface "USB WiFi" :usbid "0x04a9" "0x1845" :status :good :model "XK50 series" :interface "USB WiFi" :usbid "0x04a9" "0x1846" :status :good :model "XK70 series" :interface "USB WiFi" :usbid "0x04a9" "0x1847" :status :good ; ---- V340 -------------------------- :model "TS9000 series" :interface "USB WiFi" :usbid "0x04a9" "0x179f" :status :good :model "TS8000 series" :interface "USB WiFi" :usbid "0x04a9" "0x1800" :status :good :model "TS6000 series" :interface "USB WiFi" :usbid "0x04a9" "0x1801" :status :good :model "TS5000 series" :interface "USB WiFi" :usbid "0x04a9" "0x1802" :status :good :model "MG3000 series" :interface "USB WiFi" :usbid "0x04a9" "0x180b" :status :good :model "E470 series" :interface "USB" :usbid "0x04a9" "0x180c" :status :good :model "G4000 series" :interface "USB WiFi" :usbid "0x04a9" "0x181d" :status :good ; Network attached versions of the above :model "MB2100 series" :interface "USB WiFi" :usbid "0x04a9" "0x1793" :status :good :model "MB2700 series" :interface "USB WiFi" :usbid "0x04a9" "0x1792" :status :good :model "MB5100 series" :interface "USB WiFi" :usbid "0x04a9" "0x1790" :status :good :model "MB5400 series" :interface "USB WiFi" :usbid "0x04a9" "0x178f" :status :good ; ---- V330 -------------------------- :model "G3000 series" :interface "USB WiFi" :usbid "0x04a9" "0x1794" :status :good ; ---- V320 -------------------------- :model "MG7700 series" :interface "USB WiFi" :usbid "0x04a9" "0x178b" :status :good :model "MG6900 series" :interface "USB WiFi" :usbid "0x04a9" "0x178c" :status :good :model "MG6800 series" :interface "USB WiFi" :usbid "0x04a9" "0x178d" :status :good :model "MG5700 series" :interface "USB WiFi" :usbid "0x04a9" "0x178e" :status :good :model "MG3600 series" :interface "USB WiFi" :usbid "0x04a9" "0x178a" :status :good ; ---- V310 -------------------------- :model "MX490 series" :interface "USB WiFi" :usbid "0x04a9" "0x1787" :status :good :model "E480 series" :interface "USB" :usbid "0x04a9" "0x1789" :status :good ; ---- V300 -------------------------- :model "MG7500 series" :interface "USB WiFi" :usbid "0x04a9" "0x177c" :status :good :model "MG6600 series" :interface "USB WiFi" :usbid "0x04a9" "0x177e" :status :good :model "MG5600 series" :interface "USB WiFi" :usbid "0x04a9" "0x177f" :status :good :model "MG2900 series" :interface "USB WiFi" :usbid "0x04a9" "0x1780" :status :good :model "MB2000 series" :interface "USB WiFi" :usbid "0x04a9" "0x1778" :status :good :model "MB2300 series" :interface "USB WiFi" :usbid "0x04a9" "0x1779" :status :good :model "MB5000 series" :interface "USB WiFi" :usbid "0x04a9" "0x1776" :status :good :model "MB5300 series" :interface "USB WiFi" :usbid "0x04a9" "0x1777" :status :good :model "E460 series" :interface "USB" :usbid "0x04a9" "0x1788" :status :good sane-backends-1.0.29/doc/descriptions-external/lhii.desc0000666000000000000000000000420313615534521020060 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "lhii" ; name of backend ;:version "0.42" ; version of backend (or "unmaintained") ;:manpage "sane-template" ; name of manpage (if it exists) :url "http://www.sane-project.org/backends/lhii/lhii-v0.2.tgz" ; backend's web page :comment "This backend is for old handscanners with proprietary adapter cards. You also need a kernel driver. You may find such drivers at that page: http://www.willamowius.de/scanner.html ." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Mustek" ; name a manufacturer :comment "Other models may also be supported." :model "CG-6000" ; name models for above-specified mfg. :status :untested ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "Proprietary" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :url "http://www.sane-project.org/backends/lhii/gi1904-v0.2.tgz" ; model's URL :comment "Old handscanner. Hasn't been tested for a long time but once worked. See link for the linux kernel driver that's necessary to run the scanner." ; comment about the model ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; :status specifier is optional after :model and at the top-level sane-backends-1.0.29/doc/descriptions-external/utsushi.desc0000666000000000000000000004511013615534521020641 00000000000000;;; utsushi.desc -*- emacs-lisp -*- (sort of) ;;; Copyright (C) 2015-2019 Olaf Meeuwissen ;;; ;;; License: GPL-3.0+ ;;; Author : Olaf Meeuwissen ;;; ;;; This file is part of the 'Utsushi' package. ;;; This package 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, either version 3 of the License or, at ;;; your option, any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You ought to have received a copy of the GNU General Public License ;;; along with this package. If not, see . ;; Backend data ;; :backend "utsushi" :url "https://gitlab.com/utsushi/utsushi" ;; Device and manufacturer information. ;; :devicetype :scanner :mfg "EPSON" :url "http://www.epson.com/" ;; List of EPSON scanners and all-in-ones. :model "DS-40" :interface "USB" :usbid "0x04b8" "0x0152" :status :good :model "DS-70" :interface "USB" :status :good :comment "USB product ID one of 0x0160, 0x0166, 0x016c or 0x016e" :model "DS-80W" :interface "USB" :status :good :comment "USB product ID one of 0x0160, 0x0166, 0x016c or 0x016e" :model "DS-410" :interface "USB" :status :good :model "DS-510" :interface "USB" :usbid "0x04b8" "0x014c" :status :good :model "DS-520" :interface "USB" :usbid "0x04b8" "0x0154" :status :good :model "DS-530" :interface "USB" :usbid "0x04b8" "0x0155" :status :good :model "DS-535" :interface "USB" :status :good :model "DS-535H" :interface "USB" :usbid "0x04b8" "0x017a" :status :good :model "DS-560" :interface "USB" :usbid "0x04b8" "0x0150" :status :good :model "DS-575W" :interface "USB" :status :good :model "DS-760" :interface "USB" :usbid "0x04b8" "0x014d" :status :good :model "DS-775" :interface "USB" :status :good :model "DS-780N" :interface "USB" :usbid "0x04b8" "0x0164" :status :good :model "DS-860" :interface "USB" :usbid "0x04b8" "0x014d" :status :good :model "DS-1630" :interface "USB" :usbid "0x04b8" "0x015c" :status :good :model "DS-5500" :interface "USB" :usbid "0x04b8" "0x0145" :status :good :model "DS-6500" :interface "USB" :usbid "0x04b8" "0x0145" :status :good :model "DS-7500" :interface "USB" :usbid "0x04b8" "0x0145" :status :good :model "DS-50000" :interface "USB" :usbid "0x04b8" "0x0146" :status :good :model "DS-60000" :interface "USB" :usbid "0x04b8" "0x0146" :status :good :model "DS-70000" :interface "USB" :usbid "0x04b8" "0x0146" :status :good :model "EP-10VA" :interface "USB" :usbid "0x04b8" "0x1108" :status :good :model "EP-808A" :interface "USB" :usbid "0x04b8" "0x110a" :status :good :model "EP-978A3" :interface "USB" :usbid "0x04b8" "0x1109" :status :good :model "ES-50" :interface "USB" :status :good :comment "USB product ID one of 0x0160, 0x0166, 0x016c or 0x016e" :model "ES-55R" :interface "USB" :status :good :comment "USB product ID one of 0x016d or 0x016f" :model "ES-60W" :interface "USB" :status :good :comment "USB product ID one of 0x0160, 0x0166, 0x016c or 0x016e" :model "ES-65WR" :interface "USB" :status :good :comment "USB product ID one of 0x016d or 0x016f" :model "ES-400" :interface "USB" :usbid "0x04b8" "0x0156" :status :good :model "ES-8500" :interface "USB" :usbid "0x04b8" "0x0109" :status :basic :model "ET-2500" :interface "USB" :usbid "0x04b8" "0x1105" :status :good :model "ET-2550" :interface "USB" :usbid "0x04b8" "0x1106" :status :good :model "ET-3750" :interface "USB" :usbid "0x04b8" "0x1130" :status :good :model "ET-4500" :interface "USB" :usbid "0x04b8" "0x1107" :status :good :model "ET-4550" :interface "USB" :usbid "0x04b8" "0x1101" :status :good :model "Expression 1640XL" :interface "USB" :usbid "0x04b8" "0x0109" :status :basic :model "L220" :interface "USB" :usbid "0x04b8" "0x08d1" :status :good :model "L360" :interface "USB" :usbid "0x04b8" "0x08d1" :status :good :model "L365" :interface "USB" :usbid "0x04b8" "0x08d2" :status :good :model "L366" :interface "USB" :usbid "0x04b8" "0x08d2" :status :good :model "L380 Series" :interface "USB" :usbid "0x04b8" "0x1120" :status :good :model "L455" :interface "USB" :usbid "0x04b8" "0x08c2" :status :good :model "L565" :interface "USB" :usbid "0x04b8" "0x08d3" :status :good :model "L566" :interface "USB" :usbid "0x04b8" "0x08d3" :status :good :model "L655" :interface "USB" :usbid "0x04b8" "0x1101" :status :good :model "PX-M7050" :interface "USB" :usbid "0x04b8" "0x08bc" :status :good :model "PX-M7050FX" :interface "USB" :usbid "0x04b8" "0x08cc" :status :good :model "PX-M840FX" :interface "USB" :usbid "0x04b8" "0x08cd" :status :good :model "PX-M860F" :interface "USB" :usbid "0x04b8" "0x08ce" :status :good :model "PX-M884F" :interface "USB" :usbid "0x04b8" "0x112e" :status :good :model "WF-4720" :interface "USB" :usbid "0x04b8" "0x1125" :status :good :model "WF-6530" :interface "USB" :usbid "0x04b8" "0x08cd" :status :good :model "WF-6590" :interface "USB" :usbid "0x04b8" "0x08cf" :status :good :model "WF-8510" :interface "USB" :usbid "0x04b8" "0x08bc" :status :good :model "WF-8590" :interface "USB" :usbid "0x04b8" "0x08bc" :status :good :model "WF-R8590" :interface "USB" :usbid "0x04b8" "0x08cc" :status :good :model "XP-220" :interface "USB" :usbid "0x04b8" "0x08c0" :status :good :model "XP-230" :interface "USB" :usbid "0x04b8" "0x1102" :status :good :model "XP-235" :interface "USB" :usbid "0x04b8" "0x1102" :status :good :model "XP-322" :interface "USB" :usbid "0x04b8" "0x1103" :status :good :model "XP-335" :interface "USB" :usbid "0x04b8" "0x1103" :status :good :model "XP-430" :interface "USB" :usbid "0x04b8" "0x1104" :status :good :model "XP-432" :interface "USB" :usbid "0x04b8" "0x1104" :status :good :model "XP-435" :interface "USB" :usbid "0x04b8" "0x1104" :status :good :model "XP-530" :interface "USB" :usbid "0x04b8" "0x110c" :status :good :model "XP-540" :interface "USB" :usbid "0x04b8" "0x1117" :status :good :model "XP-630" :interface "USB" :usbid "0x04b8" "0x110c" :status :good :model "XP-640" :interface "USB" :usbid "0x04b8" "0x1117" :status :good :model "XP-830" :interface "USB" :usbid "0x04b8" "0x110b" :status :good :model "XP-960" :interface "USB" :usbid "0x04b8" "0x1109" :status :good ; These are models for which we don't know the model name yet. ; Upstream releases have stopped providing the information we ; need to fill out the :model fields :-( :model "PID 0157" :interface "USB" :usbid "0x04b8" "0x0157" :status :good :model "PID 0159" :interface "USB" :usbid "0x04b8" "0x0159" :status :good :model "PID 015A" :interface "USB" :usbid "0x04b8" "0x015a" :status :good :model "PID 015C" :interface "USB" :usbid "0x04b8" "0x015c" :status :good :model "PID 015D" :interface "USB" :usbid "0x04b8" "0x015d" :status :good :model "PID 015E" :interface "USB" :usbid "0x04b8" "0x015e" :status :good :model "PID 015F" :interface "USB" :usbid "0x04b8" "0x015f" :status :good :model "PID 0162" :interface "USB" :usbid "0x04b8" "0x0162" :status :good :model "PID 0163" :interface "USB" :usbid "0x04b8" "0x0163" :status :good :model "PID 0165" :interface "USB" :usbid "0x04b8" "0x0165" :status :good :comment "propably one of DS-410, DS-535, DS-575W, DS-775" :model "PID 0167" :interface "USB" :usbid "0x04b8" "0x0167" :status :good :comment "propably one of DS-410, DS-535, DS-575W, DS-775" :model "PID 0168" :interface "USB" :usbid "0x04b8" "0x0168" :status :good :comment "propably one of DS-410, DS-535, DS-575W, DS-775" :model "PID 0169" :interface "USB" :usbid "0x04b8" "0x0169" :status :good :comment "propably one of DS-410, DS-535, DS-575W, DS-775" :model "PID 016B" :interface "USB" :usbid "0x04b8" "0x016b" :status :good :comment "probably a FastFoto 680W, could be a WorkForce ES-300WR or ES-500WR" :model "PID 016D" :interface "USB" :usbid "0x04b8" "0x016d" :status :good :comment "propably one of ES-55R, ES-65WR" :model "PID 016F" :interface "USB" :usbid "0x04b8" "0x016f" :status :good :comment "propably one of ES-55R, ES-65WR" :model "PID 0176" :interface "USB" :usbid "0x04b8" "0x0176" :status :good :comment "probably a WorkForce ES-300WR or ES-500WR, could be a FastFoto 680W" :model "PID 0177" :interface "USB" :usbid "0x04b8" "0x0177" :status :good :comment "probably a WorkForce ES-500WR or ES-300WR, could be a FastFoto 680W" :model "PID 110D" :interface "USB" :usbid "0x04b8" "0x110d" :status :good :model "PID 110F" :interface "USB" :usbid "0x04b8" "0x110f" :status :good :model "PID 1112" :interface "USB" :usbid "0x04b8" "0x1112" :status :good :model "PID 1113" :interface "USB" :usbid "0x04b8" "0x1113" :status :good :model "PID 1114" :interface "USB" :usbid "0x04b8" "0x1114" :status :good :model "PID 1115" :interface "USB" :usbid "0x04b8" "0x1115" :status :good :model "PID 1116" :interface "USB" :usbid "0x04b8" "0x1116" :status :good :model "PID 1117" :interface "USB" :usbid "0x04b8" "0x1117" :status :good :model "PID 1118" :interface "USB" :usbid "0x04b8" "0x1118" :status :good :model "PID 1119" :interface "USB" :usbid "0x04b8" "0x1119" :status :good :model "PID 111A" :interface "USB" :usbid "0x04b8" "0x111a" :status :good :model "PID 111B" :interface "USB" :usbid "0x04b8" "0x111b" :status :good :comment "EP-879A?" :model "PID 111C" :interface "USB" :usbid "0x04b8" "0x111c" :status :good :model "PID 111D" :interface "USB" :usbid "0x04b8" "0x111d" :status :good :model "PID 111E" :interface "USB" :usbid "0x04b8" "0x111e" :status :good :model "PID 111F" :interface "USB" :usbid "0x04b8" "0x111f" :status :good :model "PID 1121" :interface "USB" :usbid "0x04b8" "0x1121" :status :good :model "PID 1122" :interface "USB" :usbid "0x04b8" "0x1122" :status :good :model "PID 1123" :interface "USB" :usbid "0x04b8" "0x1123" :status :good :comment "EP-30VA?" :model "PID 1125" :interface "USB" :usbid "0x04b8" "0x1125" :status :good :model "PID 1126" :interface "USB" :usbid "0x04b8" "0x1126" :status :good :model "PID 1127" :interface "USB" :usbid "0x04b8" "0x1127" :status :good :model "PID 1128" :interface "USB" :usbid "0x04b8" "0x1128" :status :good :comment "PX-Mxxxx?" :model "PID 1129" :interface "USB" :usbid "0x04b8" "0x1129" :status :good :comment "L61x0?" :model "PID 112A" :interface "USB" :usbid "0x04b8" "0x112a" :status :good :comment "L61x0?" :model "PID 112B" :interface "USB" :usbid "0x04b8" "0x112b" :status :good :comment "ET-77xx?" :model "PID 112C" :interface "USB" :usbid "0x04b8" "0x112c" :status :good :comment "ET-77xx?" :model "PID 112D" :interface "USB" :usbid "0x04b8" "0x112d" :status :good :model "PID 112F" :interface "USB" :usbid "0x04b8" "0x112f" :status :good :model "PID 1130" :interface "USB" :usbid "0x04b8" "0x1130" :status :good :comment "L61x0?" :model "PID 1131" :interface "USB" :usbid "0x04b8" "0x1131" :status :good :comment "EP-8xxA?" :model "PID 1132" :interface "USB" :usbid "0x04b8" "0x1132" :status :good :model "PID 1133" :interface "USB" :usbid "0x04b8" "0x1133" :status :good :comment "EP-810A?" :model "PID 1134" :interface "USB" :usbid "0x04b8" "0x1134" :status :good :comment "EP-710A?" :model "PID 1135" :interface "USB" :usbid "0x04b8" "0x1135" :status :good :comment "L61x0?" :model "PID 1136" :interface "USB" :usbid "0x04b8" "0x1136" :status :good :comment "L61x0?" :model "PID 1137" :interface "USB" :usbid "0x04b8" "0x1137" :status :good :comment "L61x0?" :model "PID 1138" :interface "USB" :usbid "0x04b8" "0x1138" :status :good :comment "L61x0?" :model "PID 1139" :interface "USB" :usbid "0x04b8" "0x1139" :status :good :model "PID 113A" :interface "USB" :usbid "0x04b8" "0x113a" :status :good :model "PID 113B" :interface "USB" :usbid "0x04b8" "0x113b" :status :good :comment "PX-Mxxxx?" :model "PID 113C" :interface "USB" :usbid "0x04b8" "0x113c" :status :good :comment "PX-Mxxxx?" :model "PID 113D" :interface "USB" :usbid "0x04b8" "0x113d" :status :good :model "PID 113E" :interface "USB" :usbid "0x04b8" "0x113e" :status :good :model "PID 113F" :interface "USB" :usbid "0x04b8" "0x113f" :status :good :model "PID 1140" :interface "USB" :usbid "0x04b8" "0x1140" :status :good :model "PID 1141" :interface "USB" :usbid "0x04b8" "0x1141" :status :good :model "PID 1142" :interface "USB" :usbid "0x04b8" "0x1142" :status :good :model "PID 1143" :interface "USB" :usbid "0x04b8" "0x1143" :status :good :comment "L3xxx?" :model "PID 1145" :interface "USB" :usbid "0x04b8" "0x1145" :status :good :comment "EP-81xA?" :model "PID 1146" :interface "USB" :usbid "0x04b8" "0x1146" :status :good :comment "EP-71xA?" :model "PID 1147" :interface "USB" :usbid "0x04b8" "0x1147" :status :good :comment "XP-7xxx?" :model "PID 1148" :interface "USB" :usbid "0x04b8" "0x1148" :status :good :comment "PX-M8xxFX?" :model "PID 1149" :interface "USB" :usbid "0x04b8" "0x1149" :status :good :comment "WF-37xx?" :model "PID 114A" :interface "USB" :usbid "0x04b8" "0x114a" :status :good :comment "L61x0?" :model "PID 114B" :interface "USB" :usbid "0x04b8" "0x114b" :status :good :comment "EP-8xxA?" :model "PID 114C" :interface "USB" :usbid "0x04b8" "0x114c" :status :good :comment "EP-8xxA?" :model "PID 114D" :interface "USB" :usbid "0x04b8" "0x114d" :status :good :comment "L5xxx" :model "PID 114E" :interface "USB" :usbid "0x04b8" "0x114e" :status :good :comment "XP21xx" :model "PID 114F" :interface "USB" :usbid "0x04b8" "0x114f" :status :good :comment "L5xxx" :model "PID 1150" :interface "USB" :usbid "0x04b8" "0x1150" :status :good :comment "L5xxx" :model "PID 1151" :interface "USB" :usbid "0x04b8" "0x1151" :status :good :comment "L5xxx" :model "PID 1152" :interface "USB" :usbid "0x04b8" "0x1152" :status :good :comment "PX-Mxxxx" :model "PID 1153" :interface "USB" :usbid "0x04b8" "0x1153" :status :good :comment "PX-Mxxxx" :model "PID 1154" :interface "USB" :usbid "0x04b8" "0x1154" :status :good :comment "L61x0" :model "PID 1155" :interface "USB" :usbid "0x04b8" "0x1155" :status :good :comment "L61x0" :model "PID 1156" :interface "USB" :usbid "0x04b8" "0x1156" :status :good :comment "L61x0" :model "PID 1157" :interface "USB" :usbid "0x04b8" "0x1157" :status :good :comment "L3xxx" :model "PID 1158" :interface "USB" :usbid "0x04b8" "0x1158" :status :good :comment "L3xxx" :model "PID 1159" :interface "USB" :usbid "0x04b8" "0x1159" :status :good :model "PID 115A" :interface "USB" :usbid "0x04b8" "0x115a" :status :good :comment "EP8xxA" :model "PID 115B" :interface "USB" :usbid "0x04b8" "0x115b" :status :good :comment "EP9xxA3" :model "PID 115C" :interface "USB" :usbid "0x04b8" "0x115c" :status :good :comment "EP7xxA" :model "PID 115D" :interface "USB" :usbid "0x04b8" "0x115c" :status :good :comment "EP9xxA3" :model "PID 1160" :interface "USB" :usbid "0x04b8" "0x1160" :status :good :comment "L5xxx" :model "PID 1161" :interface "USB" :usbid "0x04b8" "0x1161" :status :good :comment "LX-10xxx" :model "PID 1162" :interface "USB" :usbid "0x04b8" "0x1162" :status :good :comment "EWM7xxTR" :model "PID 1163" :interface "USB" :usbid "0x04b8" "0x1163" :status :good :comment "EPM5xxT" :model "PID 1164" :interface "USB" :usbid "0x04b8" "0x1164" :status :good :comment "L61x0" :model "PID 1165" :interface "USB" :usbid "0x04b8" "0x1165" :status :good :comment "L61x0" :model "PID 1166" :interface "USB" :usbid "0x04b8" "0x1166" :status :good :comment "L61x0" :model "PID 1167" :interface "USB" :usbid "0x04b8" "0x1167" :status :good :comment "ET-16xxx" :model "PID 1168" :interface "USB" :usbid "0x04b8" "0x1168" :status :good :comment "ET-16xxx" :model "PID 1169" :interface "USB" :usbid "0x04b8" "0x1169" :status :good :comment "EWM7xxTR" :model "PID 116A" :interface "USB" :usbid "0x04b8" "0x116a" :status :good :comment "EWM7xxTR" :model "PID 116B" :interface "USB" :usbid "0x04b8" "0x116b" :status :good :model "PID 116C" :interface "USB" :usbid "0x04b8" "0x116c" :status :good :comment "WFC8xxR" :model "PID 116D" :interface "USB" :usbid "0x04b8" "0x116d" :status :good :comment "WFC8xxR" :model "PID 116E" :interface "USB" :usbid "0x04b8" "0x116e" :status :good :comment "EWM7xxTR" :model "PID 116F" :interface "USB" :usbid "0x04b8" "0x116f" :status :good :comment "ET-16xxx" :model "PID 1170" :interface "USB" :usbid "0x04b8" "0x1170" :status :good :comment "ET-16xxx" :model "PID 1174" :interface "USB" :usbid "0x04b8" "0x1174" :status :good :comment "ET-58xx" :model "PID 1175" :interface "USB" :usbid "0x04b8" "0x1175" :status :good :comment "ET-58xx" :model "PID 1176" :interface "USB" :usbid "0x04b8" "0x1176" :status :good :comment "ET-58xx" :model "PID 1177" :interface "USB" :usbid "0x04b8" "0x1177" :status :good :comment "ET-16xxx" sane-backends-1.0.29/doc/descriptions-external/brother.desc0000666000000000000000000001730013615534521020602 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "brother" ; name of backend ;:version "1.0.0" ; version of backend (or "unmaintained") ;:manpage "sane-template" ; name of manpage (if it exists) :url "http://solutions.brother.com/linux/sol/printer/linux/sane_drivers.html" ; backend's web page :comment "External backend made by brother. As this software contains non-free parts, it can't be included into SANE. If you can't find your model here, please have a look at the brother website which contains the latest list." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Brother" ; name a manufacturer :url "http://www.brother.com/" ; manufacturer's URL ;:comment "" ; comment about the manufacturer ;data taken from Brother website and Brsane.ini :model "DCP-1000" :status :untested :interface "USB" :usbid "0x04f9" "0x0112" :comment "No report yet." :model "DCP-1000J" :status :untested :interface "USB" :usbid "0x04f9" "0x0153" :comment "No report yet." :model "DCP-1400" :status :untested :interface "USB" :usbid "0x04f9" "0x0116" :comment "No report yet." :model "DCP-3020C" :status :untested :interface "USB" :usbid "0x04f9" "0x014c" :comment "No report yet." :model "DCP-4020C" :status :untested :interface "USB" :usbid "0x04f9" "0x0144" :comment "No report yet." :model "DCP-8020" :status :untested :interface "USB" :usbid "0x04f9" "0x0140" :comment "No report yet." :model "DCP-8025D" :status :good :interface "USB" :usbid "0x04f9" "0x0141" :model "DCP-8025J" :status :good :interface "USB" :usbid "0x04f9" "0x014f" :comment "No report yet." :model "DCP-8040" :status :untested :interface "USB" :usbid "0x04f9" "0x015d" :comment "No report yet." :model "DCP-8045D" :status :good :interface "USB" :usbid "0x04f9" "0x015e" :model "DCP-8060" :status :good :interface "USB" :usbid "0x04f9" "0x01a3" :model "FAX1800C" :status :untested :interface "USB" :usbid "0x04f9" "0x0126" :comment "No report yet." :model "FAX1815C" :status :untested :interface "USB" :usbid "0x04f9" "0x014d" :comment "No report yet." :model "FAX1820C" :status :untested :interface "USB" :usbid "0x04f9" "0x0147" :comment "No report yet." :model "FAX1920CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0149" :comment "No report yet." :model "FAX-2850" :status :untested :interface "USB" :usbid "0x04f9" "0x0123" :comment "No report yet." :model "FAX-2900" :status :untested :interface "USB" :usbid "0x04f9" "0x0117" :comment "No report yet." :model "FAX-3800" :status :untested :interface "USB" :usbid "0x04f9" "0x0118" :comment "No report yet." :model "FAX-4100" :status :untested :interface "USB" :usbid "0x04f9" "0x012e" :comment "No report yet." :model "FAX-4750e" :status :untested :interface "USB" :usbid "0x04f9" "0x012f" :comment "No report yet." :model "FAX-5750e" :status :untested :interface "USB" :usbid "0x04f9" "0x0130" :comment "No report yet." :model "MFC-100" :status :untested :interface "USB" :usbid "0x04f9" "0x0135" :comment "No report yet." :model "MFC-150CL" :status :untested :interface "USB" :usbid "0x04f9" "0x0136" :comment "No report yet." :model "MFC-3100C" :status :untested :interface "USB" :usbid "0x04f9" "0x010e" :comment "No report yet." :model "MFC-3200C" :status :untested :interface "USB" :usbid "0x04f9" "0x013a" :comment "No report yet." :model "MFC-3220C" :status :untested :interface "USB" :usbid "0x04f9" "0x0146" :comment "No report yet." :model "MFC-3320CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0148" :comment "No report yet." :model "MFC-3420C" :status :good :interface "USB" :usbid "0x04f9" "0x014a" :model "MFC-3420J" :status :untested :interface "USB" :usbid "0x04f9" "0x0157" :comment "No report yet." :model "MFC-3820J" :status :untested :interface "USB" :usbid "0x04f9" "0x0158" :comment "No report yet." :model "MFC-3820CN" :status :good :interface "USB network" :usbid "0x04f9" "0x014b" :comment "Network connection is reported to work." :model "MFC-4420C" :status :untested :interface "USB" :usbid "0x04f9" "0x013e" :comment "No report yet." :model "MFC-4800" :status :good :interface "USB" :usbid "0x04f9" "0x0110" :model "MFC-4800J" :status :untested :interface "USB" :usbid "0x04f9" "0x0124" :comment "No report yet." :model "MFC-4820C" :status :good :interface "USB" :usbid "0x04f9" "0x013f" :model "MFC-5100C" :status :good :interface "USB" :usbid "0x04f9" "0x010f" :model "MFC-5100J" :status :untested :interface "USB" :usbid "0x04f9" "0x0122" :comment "No report yet." :model "MFC-5200C" :status :good :interface "USB" :usbid "0x04f9" "0x0132" :model "MFC-5200J" :status :untested :interface "USB" :usbid "0x04f9" "0x013d" :comment "No report yet." :model "MFC-580" :status :good :interface "USB" :usbid "0x04f9" "0x0120" :model "MFC-590" :status :good :interface "USB" :usbid "0x04f9" "0x0121" :model "MFC-6800" :status :untested :interface "USB" :usbid "0x04f9" "0x0111" :comment "No report yet." :model "MFC-6800J" :status :untested :interface "USB" :usbid "0x04f9" "0x0125" :comment "No report yet." :model "MFC-8210" :status :untested :interface "USB" :usbid "0x04f9" "0x0151" :comment "No report yet." :model "MFC-8220" :status :untested :interface "USB" :usbid "0x04f9" "0x0150" :comment "No report yet." :model "MFC-8420" :status :good :interface "USB" :usbid "0x04f9" "0x0142" :model "MFC-8440" :status :good :interface "USB" :usbid "0x04f9" "0x015f" :model "MFC-8500" :status :untested :interface "USB" :usbid "0x04f9" "0x0113" :comment "No report yet." :model "MFC-8500J" :status :untested :interface "USB" :usbid "0x04f9" "0x0128" :comment "No report yet." :model "MFC-8820D" :status :good :interface "USB" :usbid "0x04f9" "0x0143" :model "MFC-8820J" :status :untested :interface "USB" :usbid "0x04f9" "0x014e" :comment "No report yet." :model "MFC-8840D" :status :good :interface "USB" :usbid "0x04f9" "0x0160" :model "MFC-890" :status :good :interface "USB" :usbid "0x04f9" "0x013c" :model "MFC-9030" :status :untested :interface "USB" :usbid "0x04f9" "0x012b" :comment "No report yet." :model "MFC-9070" :status :untested :interface "USB" :usbid "0x04f9" "0x011d" :comment "No report yet." :model "MFC-9160" :status :good :interface "USB" :usbid "0x04f9" "0x011f" :comment "Is reported to work well with backend version 0.0.12." :model "MFC-9180" :status :good :interface "USB" :usbid "0x04f9" "0x011e" :comment "Reported to work well under openSUSE 10.2." :model "MFC-9660" :status :untested :interface "USB" :usbid "0x04f9" "0x0119" :comment "No report yet." :model "MFC-9700" :status :untested :interface "USB" :usbid "0x04f9" "0x0114" :comment "No report yet." :model "MFC-9760" :status :untested :interface "USB" :usbid "0x04f9" "0x011c" :comment "No report yet." :model "MFC-9800" :status :untested :interface "USB" :usbid "0x04f9" "0x0115" :comment "No report yet." :model "MFC-9800J" :status :untested :interface "USB" :usbid "0x04f9" "0x0127" :comment "No report yet." :model "MFC-9860" :status :untested :interface "USB" :usbid "0x04f9" "0x011a" :comment "No report yet." :model "MFC-9880" :status :unsupported :interface "USB" :usbid "0x04f9" "0x011b" :comment "There is a report that this scanner does not work with the brother backend (I/O errors)" sane-backends-1.0.29/doc/descriptions-external/mustek_a3p1.desc0000666000000000000000000000100013615534521021257 00000000000000:backend "mustek_a3p1" ;:version "1.0-3" ;:manpage "sane-mustek_a3p1" :url "http://www.meier-geinitz.de/sane/mustek_a3p1-backend/" :comment "Only Mustek P 3600 A3 Pro is supported at the moment" :devicetype :scanner :mfg "Mustek" :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "P 3600 A3 Pro" :interface "USB" :status :minimal :usbid "0x055f" "0x0401" :comment "Reports about scanning problems. 1800 dpi seems to work if only small scan areas are selected." sane-backends-1.0.29/doc/descriptions-external/kodak-twain.desc0000666000000000000000000000410113615534521021341 00000000000000:backend "kodak-twain" ; name of backend :version "unknown" ; version of backend (or "unmaintained") :url "http://www.kodak.com/go/scanonlinux" ; :comment "External backend developed by Kodak. Provides full access to the supported Kodak scanners by providing a SANE interface to the proprietary Kodak 32bit TWAIN stack. Several Linux distributions are supported." :devicetype :scanner ; start of a list of devices.... :mfg "Kodak" ; name a manufacturer :url "http://www.kodak.com/" ; manufacturer's URL :model "i1210" :status :untested :interface "USB" :usbid "0x040a" "0x600a" :comment "No report yet." :model "i1220" :status :untested :interface "USB" :usbid "0x040a" "0x600b" :comment "No report yet." :model "i1310" :status :untested :interface "USB" :usbid "0x040a" "0x600c" :comment "No report yet." :model "i1320" :status :untested :interface "USB" :usbid "0x040a" "0x600d" :comment "Reported to work on Fedora 12." :model "i1405" :status :untested :interface "USB" :usbid "0x040a" "0x601a" :comment "No report yet." :model "i1410" :status :untested :interface "USB" :usbid "0x040a" "0x600e" :comment "No report yet." :model "i1420" :status :untested :interface "USB" :usbid "0x040a" "0x600f" :comment "No report yet." :model "i1440" :status :untested :interface "USB" :usbid "0x040a" "0x6010" :comment "No report yet." :model "i2400" :status :untested :interface "USB" :usbid "0x040a" "0x601c" :comment "No report yet." :model "i2600" :status :untested :interface "USB" :usbid "0x040a" "0x601d" :comment "No report yet." :model "i2800" :status :untested :interface "USB" :usbid "0x040a" "0x601e" :comment "No report yet." :model "i1000 A3 accessory" :status :untested :interface "USB" :usbid "0x040a" "0x6012" :comment "Flatbed attachment for use with Kodak ADF scanner. Requires 12V power over usb cable. No report yet." :model "i1000 A4 accessory" :status :untested :interface "USB" :usbid "0x040a" "0x6011" :comment "Flatbed attachment for use with Kodak ADF scanner. Requires 12V power over usb cable. No report yet." sane-backends-1.0.29/doc/descriptions-external/primax.desc0000666000000000000000000000221413615534521020433 00000000000000:backend "primax" ; name of backend ;:version "1.1.beta1" ; version of backend ;:manpage "sane-primax" ; name of manpage (if it exists) :url "http://px-backend.sourceforge.net" ; backend's web page :comment "This backend is not included because it depends on the code of the primax command line program. Therefore the author wants to keep it in the primax CVS tree." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Primax" ; name a manufacturer :url "http://www.primax.nl/" :model "Colorado Direct 300" :interface "Parport" :status :good :model "Colorado Direct 600/30bit" :interface "Parport" :status :untested :mfg "Network" ; another manufacturer... :model "Scanny MM100" :interface "Parport" :status :good :mfg "Storm" :model "Totalscan" :interface "Parport" :status :untested :model "ImageWave" :interface "Parport" :status :untested :mfg "Genius" :model "Colorpage-Vivid+" :interface "Parport" :status :untested sane-backends-1.0.29/doc/descriptions-external/brother2.desc0000666000000000000000000001175613615534521020675 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "brother2" ; name of backend ;:version "1.0.0" ; version of backend (or "unmaintained") ;:manpage "sane-template" ; name of manpage (if it exists) :url "http://solutions.brother.com/linux/sol/printer/linux/sane_drivers.html" ; backend's web page :comment "External backend made by brother. As this software contains non-free parts, it can't be included into SANE. If you can't find your model here, please have a look at the brother website which contains the latest list." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Brother" ; name a manufacturer :url "http://www.brother.com/" ; manufacturer's URL ;:comment "" ; comment about the manufacturer ;data taken from Brother website and Brsane2.ini :model "DCP-110C" :status :good :interface "USB" :usbid "0x04f9" "0x0169" :model "DCP-115C" :status :good :interface "USB" :usbid "0x04f9" "0x018c" :model "DCP-116C" :status :untested :interface "USB" :usbid "0x04f9" "0x018d" :comment "No report yet." :model "DCP-117C" :status :good :interface "USB" :usbid "0x04f9" "0x018e" :model "DCP-120C" :status :good :interface "USB" :usbid "0x04f9" "0x0190" :model "DCP-310CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x016b" :comment "No report yet." :model "DCP-315CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0191" :comment "No report yet." :model "DCP-330C" :status :untested :interface "USB" :usbid "0x04f9" "0x01a9" :comment "No report yet." :model "DCP-340CW" :status :untested :interface "USB" :usbid "0x04f9" "0x0192" :comment "No report yet." :model "DCP-7010" :status :good :interface "USB" :usbid "0x04f9" "0x0182" :model "DCP-7020" :status :untested :interface "USB" :usbid "0x04f9" "0x0183" :comment "No report yet." :model "DCP-7025" :status :good :interface "USB" :usbid "0x04f9" "0x0184" :model "MFC-210C" :status :good :interface "USB" :usbid "0x04f9" "0x0161" :model "MFC-215C" :status :good :interface "USB" :usbid "0x04f9" "0x0193" :comment "brscan2-0.0.2 necessary" :model "MFC-240C" :status :good :interface "USB" :usbid "0x04f9" "0x01ab" :comment "Reportedly working." :model "MFC-3240C" :status :untested :interface "USB" :usbid "0x04f9" "0x0173" :comment "No report yet." :model "MFC-3340CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0174" :comment "No report yet." :model "MFC-410CN" :status :basic :interface "USB network" :usbid "0x04f9" "0x0163" :comment "Sometimes hangs and refuses to scan. A simple power off/on switch will fix things." :model "MFC-420CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0162" :comment "No report yet." :model "MFC-425CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0194" :comment "No report yet." :model "MFC-5440CN" :status :good :interface "USB network" :usbid "0x04f9" "0x016d" :model "MFC-5840CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x016e" :comment "No report yet." ;only in ini :model "MFC-610CLN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0166" :comment "No report yet." ;only in ini :model "MFC-610CLN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0168" :comment "No report yet." :model "MFC-620CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x0165" :comment "No report yet." :model "MFC-640CW" :status :untested :interface "USB" :usbid "0x04f9" "0x0197" :comment "No report yet." :model "MFC-7220" :status :untested :interface "USB" :usbid "0x04f9" "0x0185" :comment "No report yet." :model "MFC-7225N" :status :untested :interface "USB network" :usbid "0x04f9" "0x0186" :comment "No report yet." :model "MFC-7420" :status :good :interface "USB" :usbid "0x04f9" "0x0180" :comment "No report yet." :model "MFC-7820N" :status :good :interface "USB network" :usbid "0x04f9" "0x0181" :comment "Network connection reported to work." :model "MFC-7840W" :status :good :interface "USB" :usbid "0x04f9" "0x01e5" :comment "Reported to work with brscan3 driver." :model "MFC-820CW" :status :untested :interface "USB" :usbid "0x04f9" "0x0195" :comment "No report yet." :model "MFC-8460N" :status :untested :interface "USB" :usbid "0x04f9" "0x01a5" :comment "No report yet." :model "MFC-8860DN" :status :untested :interface "USB" :usbid "0x04f9" "0x01a6" :comment "No report yet." :model "MFC-9420CN" :status :untested :interface "USB network" :usbid "0x04f9" "0x018a" :comment "No report yet." sane-backends-1.0.29/doc/descriptions-external/geniusvp2.desc0000666000000000000000000000237713615534521021067 00000000000000; ; SANE Backend specification file ; :backend "geniusvp2" ; backend's name ;:version "0.2" ; backend's version (or "unmaintained") ;:manpage "sane-geniusvp2" ; manpage name :url "http://sourceforge.net/projects/geniusvp2/" ; backend's web page :comment "Supports color mode, bit depth of 8, 75-600 dpi resolution" ; comment about the backend :devicetype :scanner ; start of a list of devices.... :mfg "Genius" ; name a manufacturer :url "http://www.genius-kye.com/" ; manufacturer's URL :model "ColorPage-Vivid Pro II" ; name models for above-specified mfg. :status :basic ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "Parport (EPP)" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :comment "Similar to Primax Colorado Direct 9600, but with EICI 091000 ASIC" ; comment about the model sane-backends-1.0.29/doc/descriptions-external/hpoj.desc0000666000000000000000000000254713615534521020104 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hpoj" ; name of backend :version "(unmaintained)" ; version of backend :url "http://hpoj.sourceforge.net/" ; backend's web page :comment "HPOJ is not maintained anymore. It's recommended to use the hpaio (hplip) backend instead of HPOJ." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/go/all-in-one" ; name models for above-specified mfg. :model "Most HP OfficeJet, LaserJet, and PSC (Printer/Scanner/Copier) multi-function peripherals" :url "http://hpoj.sourceforge.net/suplist.shtml" :interface "Parport(ECP) USB JetDirect" :status :good :comment "HPOJ is not maintained anymore. It's recommended to use the hpaio (hplip) backend instead of hpoj." :usbid "ignore" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions-external/samsung.desc0000666000000000000000000000452313615534521020615 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "samsung" ; name of backend ;:version "(external)" ; version of backend :url "http://product.samsung.com/cgi-bin/nabc/support/b2c_support_product_results.jsp" ; backend's web page :comment "External binary-only backend for Linux i386 (and x86_64?). See the website for the latest release." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Samsung" ; name a manufacturer :url "http://www.samsung.com/" :comment "Multi Function Peripheral. External backend made by Samsung. Please check the Samsung website and/or contact us if you have a Samsung device not mentioned here." ; name models for above-specified mfg. :model "SCX-4016" :interface "Parport USB" :status :untested :comment "Please contact us if you use this device." :model "SCX-4100" :interface "Parport USB" :usbid "0x04e8" "0x3413" :status :good :comment "Is reported to work. " :model "SCX-4200" :interface "USB" :usbid "0x04e8" "0x341b" :status :good :comment "Is reported to work. The configuration applet must be run as root." :model "SCX-4216F" :interface "Parport USB" :usbid "0x04e8" "0x3409" :status :untested :comment "Please contact us if you use this device." :model "SCX-4521F" :interface "Parport USB" :usbid "0x04e8" "0x3419" :status :basic :comment "See bug report #304052" :model "SCX-4720F" :interface "Parport USB" :status :untested :comment "Please contact us if you use this device." :model "SCX-6220" :interface "Parport USB" :status :untested :comment "Please contact us if you use this device." :model "SCX-6320F" :interface "Parport USB" :status :untested :comment "Please contact us if you use this device." :model "SF-565P" :interface "Parport USB" :status :untested :comment "Please contact us if you use this device." :model "SF-755P" :interface "Parport USB" :status :untested :comment "Please contact us if you use this device." sane-backends-1.0.29/doc/descriptions-external/brother-mfc4600.desc0000666000000000000000000000222713615534521021661 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "brother-mfc4600" ; name of backend ;:version "0.42" ; version of backend (or "unmaintained") ;:manpage "sane-template" ; name of manpage (if it exists) :url "http://sourceforge.net/projects/brother-mfc" ;:comment "" ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Brother" :url "http://www.brother.com/" :model "MFC 4600" :status :basic :url "http://sourceforge.net/projects/brother-mfc" :interface "USB" :usbid "0x04f9" "0x0111" :comment "Only USB version of this scanner is supported. Please report how well it works. See link." sane-backends-1.0.29/doc/descriptions-external/template.desc.0000666000000000000000000000547113615534521021034 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "template" ; name of backend :version "0.42" ; version of backend (or "unmaintained") :manpage "sane-template" ; name of manpage (if it exists) :url "http://www.luser.com/temp/" ; backend's web page :url "http://www.luser.com/b/" ; another backend webpage :comment "This backend supports only the USB and SCSI models" ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "TemPlate" ; name a manufacturer :url "http://www.template.com/" ; manufacturer's URL :url "http://www.template.de/" ; another manufacturer URL :comment "TemPlate scanners are sometimes labeled \"TMP\"" ; comment about the manufacturer :model "Templ Z" ; name models for above-specified mfg. :status :untested ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "SCSI" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :usbid "0x1234" "0x4321" ; Vendor and product ids of an USB device :url "http://www.tmp.com/z.html" ; model's URL :comment "With Z-Axis scrolling" ; comment about the model :model "Templ ZS" :interface "USB" :usbid "0x1234" "0x4322" :status :unsupported :comment "No support yet, but we have docs." :model "Templ ZQ" :interface "USB" :usbid "0x1234" "0x4323" :status :minimal :model "Templ ZY" :interface "SCSI" :status :basic :model "Templ ZZ" :interface "SCSI" :status :good :mfg "ArmorPlate" ; another manufacturer... :url "http://www.armorplate.com/" :model "AmplScan II" :interface "SCSI" :status :complete :comment "AmplScan *II*, not AmplScan!" :devicetype :api ; specify a different type :desc "Interface to FrObYz API" ; describe a non-hardware device :comment "Only FrObYz version 2.0 is supported!" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; :status specifier is optional after :model and at the top-level sane-backends-1.0.29/doc/descriptions-external/viceo.desc0000666000000000000000000000432713615534521020247 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "viceo" ; name of backend :version "0.6" ; version of backend ;:manpage "sane-viceo" ; name of manpage (if it exists) :url "mailto:viceo@stevencherie.net" ; backend's web page :url "http://viceo.orcon.net.nz/" :comment "Supports E3 and E4 family USB scanners from Genius, Primax, IBM. The backend is not included because the license situation is unclear. Also it only works on Linux and needs a a patch for the kernel scanner driver which isn't available on 2.6." :devicetype :scanner :mfg "Genius" ; name a manufacturer :url "http://www.genius-kye.com/" :model "Vivid Pro USB" ; name models for above-specified mfg. :interface "USB" :usbid "0x0458" "0x2001" :status :basic :comment "Linux 2.4 only, needs a kernel patch." :mfg "Primax" :url "http://www.primax.nl/" :model "Colorado USB 19200" :interface "USB" :usbid "0x0461" "0x0360" :status :basic :comment "Linux 2.4 only, needs a kernel patch." :model "Colorado 2200 USB" :interface "USB" :usbid "0x0461" "0x0364" :status :untested :comment "Untested. See link for details. Linux 2.4 only, needs a kernel patch." :url "/unsupported/primax-colorado-2200-usb.html" :mfg "Visioneer" :model "OneTouch 6100" :interface "USB" :usbid "0x04a7" "0x0231" :status :basic :comment "Linux 2.4 only, needs a kernel patch." :model "OneTouch 7600" :interface "USB" :usbid "0x04a7" "0x0211" :status :basic :comment "Linux 2.4 only, needs a kernel patch." :model "OneTouch 8600" :interface "USB" :usbid "0x04a7" "0x0331" :status :basic :comment "Linux 2.4 only, needs a kernel patch." :mfg "IBM" :url "http://www.ibm.com/" :model "IdeaScan 2000 USB" :interface "USB" :status :basic :comment "Linux 2.4 only, needs a kernel patch." :mfg "LG Electronics" :model "Scanworks 600U" :interface "USB" :usbid "0x0461" "0x0364" :status :basic :comment "Linux 2.4 only, needs a kernel patch." sane-backends-1.0.29/doc/descriptions-external/hp8200.desc0000666000000000000000000000351213615534521020056 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "hp8200" ; name of backend ;:version "0.0" ; version of backend (or "unmaintained") ;:manpage "sane-template" ; name of manpage (if it exists) :url "http://www.cyberbaladeur.fr/telechargement.html" ; backend's web page :comment "This backend can't be added to the SANE distribution because it consists of binary-only code." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett Packard" ; name a manufacturer :url "http://www.hp.com/" ; manufacturer's URL :model "ScanJet 8200" ; name models for above-specified mfg. :status :good ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :usbid "0x03f0" "0x0b01" :url "http://ftp.cyberbaladeur.fr/82xxc%20Linux%20drivers.tar.gz" ; model's URL :comment "External backend. Binary-only Linux i386 code. Not supported by the SANE developers." sane-backends-1.0.29/doc/descriptions-external/epkowa.desc0000666000000000000000000030625013615534521020430 00000000000000;;; epkowa.desc -*- emacs-lisp -*- (eh, sort of) ;;; Copyright (C) 2004--2015 Olaf Meeuwissen ;;; ;;; This file is part of the "Image Scan!" documentation. ;;; ;;; The "Image Scan!" documentation 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; ;;; either version 2 of the License or at your option any later version. ;;; ;;; This program is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of FITNESS ;;; FOR A PARTICULAR PURPOSE or MERCHANTABILITY. ;;; See the GNU General Public License for more details. ;;; ;;; You should have received a verbatim copy of the GNU General Public ;;; License along with this program; if not, write to: ;;; ;;; Free Software Foundation, Inc. ;;; 59 Temple Place, Suite 330 ;;; Boston, MA 02111-1307 USA ;;; This list of devices has been compiled using the following sources: ;;; ;;; * iscan-data-$version (see :version field below) ;;; * iscan-2.24.0/NEWS ;;; * iscan-2.24.0/backend/usb (since moved to iscan-data) ;;; * sane-backends/backend/epson_usb.c (CVS 1.18) ;;; * sane-backends/doc/descriptions/epson.desc (CVS 1.26) ;;; * http://www.freecolormanagement.com/sane/supported.html ;;; * http://www.sane-project.org/lists/sane-mfgs-cvs.html#Z-EPSON ;;; * http://www.epsondevelopers.com/ ;;; * http://www.epson.com/ (several representative countries) ;;; * http://www.i-love-epson.co.jp/ ;;; * messages on the sane-devel and LinuxPrinting.org epson-list ;;; mailing lists ;;; ;;; Some of the above sources may have moved or may no longer exist. ;; Backend data. ;; :backend "epkowa" :version "iscan 2.30.1/iscan-data 1.36.0" :url "http://download.ebz.epson.net/dsc/search/01/search/?OSC=LX" ;; Device and manufacturer information. ;; :devicetype :scanner :mfg "EPSON" :url "http://www.epson.com/" :comment "" ; SEIKO EPSON CORPORATION's marketing division divides the world in ; Japan and several overseas regions. The same scanner is marketed ; under different names in the various regions. I have assumed the ; Japan-centric point of view that the scanner names for the models ; marketed in Japan are "canonical". All the other model names are ; considered overseas. ; I have marked the models for which I have been able to download a ; product specification with an indication of the site. ; ; JP = http://www.i-love-epson.co.jp/ (in Japanese) ; ; All command specs were downloaded from www.epsondevelopers.com. ; ; Note that the above location may have moved, may no longer exist ; or no longer provide (unfettered) access to the specifications. ; For the :comment sections I have tried to stick to the following ; ordering ; ; - support limitations ; - additional requirements ; - other backends that claim support ; - correspondence to other models ;; List of EPSON scanners and all-in-ones. ;; :model "AL-MX300DN Series" :interface "USB" :usbid "0x04b8" "0x08ac" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "AL-MX300DNF Series" :interface "USB" :usbid "0x04b8" "0x08ac" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Actionscanner II" :interface "parallel SCSI" :status :good :comment "overseas version of the GT-5000" :model "AcuLaser CX11" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :comment "overseas version of the LP-A500" :model "AcuLaser CX11NF" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :comment "network interface not supported
AcuLaser CX11 with network interface and fax" :model "AcuLaser CX21" :interface "USB" :usbid "0x04b8" "0x0835" :status :good :comment "network interface not supported" :model "AcuLaser MX20DN" :interface "USB" :usbid "0x04b8" "0x0866" :status :complete :comment "network interface not supported
business all-in-one" :model "AcuLaser MX20DNF" :interface "USB" :usbid "0x04b8" "0x0866" :status :complete :comment "network interface not supported
business all-in-one" :model "AcuLaser MX21DNF" :interface "USB" :usbid "0x04b8" "0x0866" :status :complete :comment "network interface not supported
business all-in-one" :model "Artisan 635" :interface "USB" :usbid "0x04b8" "0x0878" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-704A" :model "Artisan 700" :interface "USB" :usbid "0x04b8" "0x0846" :status :good :comment "network interface not supported
all-in-one
overseas version of the EP-801A" :model "Artisan 710 Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-802A" :model "Artisan 725" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-803A" :model "Artisan 730 Series" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-804A" :model "Artisan 800" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface not supported
all-in-one
overseas version of the EP-901A" :model "Artisan 810 Series" :interface "USB" :usbid "0x04b8" "0x0853" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-902A" :model "Artisan 835" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-903A" :model "Artisan 837" :interface "USB" :usbid "0x04b8" "0x0879" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-904F" :model "CC-500L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010d" :status :unsupported :comment "all-in-one" :model "CC-550L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011a" :status :unsupported :comment "all-in-one" :model "CC-570L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one" :model "CC-600PX" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one" :model "CC-700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0108" :status :unsupported :comment "all-in-one" :model "DS-30" :interface "USB" :usbid "0x04b8" "0x0147" :status :complete :comment "requires DFSG non-free iscan-plugin-ds-30" :model "EP-702A" :interface "USB" :usbid "0x04b8" "0x0850" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-703A" :interface "USB" :usbid "0x04b8" "0x0862" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-704A" :interface "USB" :usbid "0x04b8" "0x0878" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-705A" :interface "USB" :usbid "0x04b8" "0x089f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-706A" :interface "USB" :usbid "0x04b8" "0x08b7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-707A" :interface "USB" :usbid "0x04b8" "0x08c9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-774A" :interface "USB" :usbid "0x04b8" "0x0893" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-775A" :interface "USB" :usbid "0x04b8" "0x089e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-775AW" :interface "USB" :usbid "0x04b8" "0x089e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-776AB" :interface "USB" :usbid "0x04b8" "0x08b6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-776AW" :interface "USB" :usbid "0x04b8" "0x08b6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-777A" :interface "USB" :usbid "0x04b8" "0x08c8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-801A" :interface "USB" :usbid "0x04b8" "0x0846" :status :good :comment "network interface not supported
all-in-one" :model "EP-802A" :interface "USB" :usbid "0x04b8" "0x0852" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-803A" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-803AW" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-804A" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-804AR" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-804AW" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-805A" :interface "USB" :usbid "0x04b8" "0x089c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-805AR" :interface "USB" :usbid "0x04b8" "0x089c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-805AW" :interface "USB" :usbid "0x04b8" "0x089c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-806AB" :interface "USB" :usbid "0x04b8" "0x08b5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-806AR" :interface "USB" :usbid "0x04b8" "0x08b5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-806AW" :interface "USB" :usbid "0x04b8" "0x08b5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-807AB" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-807AR" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-807AW" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-901A" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface not supported
all-in-one" :model "EP-901F" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface not supported
all-in-one" :model "EP-902A" :interface "USB" :usbid "0x04b8" "0x0853" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-903A" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-903F" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-904A" :interface "USB" :usbid "0x04b8" "0x0879" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-904F" :interface "USB" :usbid "0x04b8" "0x0879" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-905A" :interface "USB" :usbid "0x04b8" "0x089b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-905F" :interface "USB" :usbid "0x04b8" "0x089a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-906F" :interface "USB" :usbid "0x04b8" "0x08b4" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-907F" :interface "USB" :usbid "0x04b8" "0x08c6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-976A3" :interface "USB" :usbid "0x04b8" "0x08b3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-977A3" :interface "USB" :usbid "0x04b8" "0x08c5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ES-300C" :interface "SCSI parallel" :status :good :comment "overseas version of the GT-6000" :model "ES-300GS" :interface "SCSI" :status :good :model "ES-600C" :interface "parallel" :status :good :comment "overseas version of the GT-5400" :model "ES-800C" :interface "SCSI" :status :good :comment "overseas version of the GT-8000" :model "ES-1000C" :status :unsupported :comment "overseas version of the GT-8500" :model "ES-1200C" :interface "parallel" :status :good :comment "overseas version of the GT-9000" :model "ES-2000" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0107" :status :complete :comment "IEEE1394 untested" :model "ES-2200" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010e" :status :complete :comment "IEEE1394 untested" :model "ES-6000" ; product spec (JP) :interface "SCSI" :status :good :model "ES-6000H" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-6000HS" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-7000H" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0126" :status :good :comment "network interface not supported
IEEE1394 untested" :model "ES-8000" :interface "SCSI" :status :untested :model "ES-8500" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0109" :status :good :comment "IEEE1394 untested" :model "ES-9000H" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-10000G" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0129" :status :good :comment "network interface not supported
IEEE1394 untested" :model "ES-D200" :interface "USB" :usbid "0x04b8" "0x0137" :status :good :comment "requires DFSG non-free esci-interpreter-gt-s80" :model "ES-D350" :interface "USB" :usbid "0x04b8" "0x0144" :status :good :comment "requires DFSG non-free esci-interpreter-gt-s80" :model "ES-D400" :interface "USB" :usbid "0x04b8" "0x0136" :status :good :comment "requires DFSG non-free esci-interpreter-gt-s80" :model "ES-G11000" :interface "USB" :usbid "0x04b8" "0x014b" :status :good :model "ES-H300" :interface "USB" :usbid "0x04b8" "0x012b" :status :good :comment "network interface not supported" :model "ES-H7200" :interface "USB Ethernet" :usbid "0x04b8" "0x0138" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package" :model "Expression 636" :interface "SCSI" :status :complete :comment "overseas version of the GT-9500" :model "Expression 800" ; command spec :interface "SCSI" :status :complete :comment "overseas version of the GT-9600" :scsi "EPSON" "Expression800" "processor" :model "Expression 836XL" ; command spec :interface "SCSI" :status :untested :comment "overseas version of the ES-8000" :model "Expression 1600" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0107" :status :complete :comment "IEEE1394 untested
overseas version of the ES-2000" :model "Expression 1640XL" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0109" :status :good :comment "IEEE1394 untested
overseas version of the ES-8500" :model "Expression 1680" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x010e" :status :complete :comment "IEEE1394 untested
overseas version of the ES-2200" :model "Expression 1680 Pro" :interface "SCSI USB" :status :untested :comment "IEEE1394 option" :model "Expression 1680XL Pro" :interface "SCSI USB" :status :untested :model "Expression 10000XL" ; command spec :interface "USB" :usbid "0x04b8" "0x0129" :status :good :comment "network interface not supported
IEEE1394 untested
overseas version of the ES-10000G" :model "Expression 10000XL Graphic Arts" :interface "USB IEEE1394" :status :untested :comment "network interface not supported" :model "Expression 10000XL Photo" :interface "USB IEEE1394" :status :untested :comment "network interface not supported" :model "Expression 11000XL" :interface "USB" :usbid "0x04b8" "0x014b" :status :good :comment "overseas version of the ES-G11000" :model "F-3200" ; product spec (JP) :interface "USB IEEE1394" :usbid "0x04b8" "0x080a" :status :unsupported :comment "Film scanner" :model "F-3200 Photo" :interface "USB IEEE1394" :status :unsupported :model "FilmScan 200" :interface "SCSI" :status :unsupported :comment "A better backend for the FilmScan 200 can be found at http://www.vjet.demon.co.uk/scanner/." :url "http://www.vjet.demon.co.uk/scanner/" :model "GT-1500" :interface "USB" :usbid "0x04b8" "0x0133" :status :good :comment "requires DFSG non-free iscan-plugin-gt-1500
overseas version of the GT-D1000" :model "GT-2200" :interface "USB" :usbid "0x04b8" "0x0102" :status :unsupported :model "GT-2500" :interface "USB" :usbid "0x04b8" "0x012b" :status :good :comment "network interface not supported
overseas version of the ES-H300" :model "GT-4000" :status :untested :model "GT-5000" :interface "parallel SCSI" :status :good :model "GT-5400" :interface "parallel" :status :good :model "GT-5500" :interface "SCSI" :status :good :model "GT-6000" :interface "SCSI Parport" :status :good :model "GT-6500" :interface "parallel" :status :good :comment "overseas version of the GT-5400" :model "GT-6600U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0103" :status :complete :model "GT-6700U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010c" :status :complete :model "GT-7000S" :interface "SCSI" :status :complete :scsi "EPSON" "SCANNER GT-7000" "processor" :model "GT-7000U" :interface "USB" :usbid "0x04b8" "0x0101" :status :complete :model "GT-7200U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010f" :status :good :comment "requires DFSG non-free iscan-plugin-gt-7200
also supported by the plustek backend" :model "GT-7300U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-7300
also supported by the plustek backend" :model "GT-7400U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0120" :status :unsupported :comment "supported by the snapscan backend" :model "GT-7600S" ; product spec (JP) :interface "SCSI" :status :complete :comment "SCSI version of the GT-7600U" :model "GT-7600U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "USB version of the GT-7600S" :model "GT-7600UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "GT-7600U with TPU option bundled" :model "GT-7700U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010b" :status :complete :model "GT-8000" :interface "SCSI" :status :good :model "GT-8200U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0110" :status :complete :model "GT-8200UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0110" :status :good :model "GT-8300UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011e" :status :complete :model "GT-8400UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :model "GT-8500" :status :untested :model "GT-8700" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :complete :model "GT-8700F" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :good :comment "GT-8700U with TPU option bundled" :model "GT-9000" :interface "parallel" :status :good :model "GT-9300UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011b" :status :complete :model "GT-9400UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0116" :status :good :comment "requires DFSG non-free iscan-plugin-gt-9400" :model "GT-9500" :interface "SCSI" :status :complete :model "GT-9600" :interface "SCSI" :status :complete :model "GT-9700F" ; product spec (JP) :interface "USB IEEE1394" :usbid "0x04b8" "0x0112" :scsi "EPSON" "GT-9700" "processor" :status :complete :model "GT-9800F" ; product spec (JP) :interface "USB IEEE1394" :usbid "0x04b8" "0x011c" :scsi "EPSON" "GT-9800" "processor" :status :complete :model "GT-10000" :interface "SCSI" :status :good :comment "overseas version of the ES-6000" :model "GT-10000+" ; command spec :interface "SCSI" :status :good :comment "IEEE1394 untested
overseas version of the ES-6000H" :model "GT-12000" :interface "SCSI" :status :untested :comment "overseas version of the ES-8000" :model "GT-15000" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0126" :status :good :comment "IEEE1394 untested
overseas version of the ES-7000H" :model "GT-20000" :interface "USB Ethernet" :usbid "0x04b8" "0x0138" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
overseas version of the ES-H7200" :model "GT-30000" ; command spec :interface "SCSI" :status :good :comment "IEEE1394 untested
overseas version of the ES-9000H" :model "GT-D1000" :interface "USB" :usbid "0x04b8" "0x0133" :status :good :comment "requires DFSG non-free iscan-plugin-gt-1500" :model "GT-F500" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0121" :status :good :comment "multi photo feeder not supported
requires DFSG non-free iscan-plugin-gt-f500
also supported by the snapscan backend" :model "GT-F520" :interface "USB" :usbid "0x04b8" "0x0122" :status :good :comment "multi photo feeder not supported
requires DFSG non-free iscan-plugin-gt-f520
also supported by the snapscan backend" :model "GT-F550" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0121" :status :good :comment "auto film loader not supported
requires DFSG non-free iscan-plugin-gt-f500
also supported by the snapscan backend" :model "GT-F570" :interface "USB" :usbid "0x04b8" "0x0122" :status :good :comment "auto film loader not supported
requires DFSG non-free iscan-plugin-gt-f520
also supported by the snapscan backend" :model "GT-F600" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0118" :status :good :comment "only scans up to 2400dpi
requires DFSG non-free iscan-plugin-gt-f600" :model "GT-F650" :interface "USB" :usbid "0x04b8" "0x012d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-s600
GT-S600 with TPU" :model "GT-F670" :interface "USB" :usbid "0x04b8" "0x012e" :status :good :comment "requires DFSG non-free iscan-plugin-gt-f670" :model "GT-F700" :interface "USB" :usbid "0x04b8" "0x012f" :status :good :comment "auto film loader not supported
requires DFSG non-free iscan-plugin-gt-f700" :model "GT-F720" :interface "USB" :usbid "0x04b8" "0x0131" :status :good :comment "requires DFSG non-free esci-interpreter-gt-f720
GT-S620 with TPU" :model "GT-F730" :interface "USB" :usbid "0x04b8" "0x0142" :status :good :comment "requires DFSG non-free esci-interpreter-perfection-v330
GT-S630 with TPU" :model "GT-F740" :interface "USB" :usbid "0x04b8" "0x014a" :status :good :comment "requires DFSG non-free iscan-plugin-perfection-v370
GT-S640 with TPU" :model "GT-S50" :interface "USB" :usbid "0x04b8" "0x0137" :status :good :comment "requires DFSG non-free esci-interpreter-gt-s80
overseas version of the ES-D200" :model "GT-S55" :interface "USB" :usbid "0x04b8" "0x0143" :status :good :comment "requires DFSG non-free esci-interpreter-gt-s80" :model "GT-S80" :interface "USB" :usbid "0x04b8" "0x0136" :status :good :comment "requires DFSG non-free esci-interpreter-gt-s80
overseas version of the ES-D400" :model "GT-S85" :interface "USB" :usbid "0x04b8" "0x0144" :status :good :comment "requires DFSG non-free esci-interpreter-gt-s80" :model "GT-S600" :interface "USB" :usbid "0x04b8" "0x012d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-s600" :model "GT-S620" :interface "USB" :usbid "0x04b8" "0x0131" :status :good :comment "requires DFSG non-free esci-interpreter-gt-f720" :model "GT-S630" :interface "USB" :usbid "0x04b8" "0x0142" :status :good :comment "requires DFSG non-free esci-interpreter-perfection-v330" :model "GT-S640" :interface "USB" :usbid "0x04b8" "0x014a" :status :good :comment "requires DFSG non-free iscan-plugin-perfection-v370" :model "GT-S650" :interface "USB" :usbid "0x04b8" "0x013d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-s650" :model "GT-X700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0128" :status :complete :comment "IEEE1394 untested" :model "GT-X750" :interface "USB" :usbid "0x04b8" "0x0119" :status :good :comment "requires DFSG non-free iscan-plugin-gt-x750" :model "GT-X770" :interface "USB" :usbid "0x04b8" "0x0130" :status :good :comment "requires DFSG non-free iscan-plugin-gt-x770" :model "GT-X800" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x012a" :status :complete :comment "film area guide mode not supported
IEEE1394 untested" :model "GT-X820" :interface "USB" :usbid "0x04b8" "0x013a" :status :good :comment "requires DFSG non-free iscan-plugin-gt-x820" :model "GT-X830" :interface "USB" :usbid "0x04b8" "0x0153" :status :good :comment "requires DFSG non-free iscan-plugin-gt-x830" :model "GT-X900" :interface "USB" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested" :scsi "EPSON" "GT-X900" "processor" :model "GT-X970" :interface "USB" :usbid "0x04b8" "0x0135" :status :good :comment "IEEE1394 untested" :model "GT-X980" :interface "USB" :usbid "0x04b8" "0x0151" :status :good :model "K200 Series" :interface "USB" :usbid "0x04b8" "0x0871" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "K300 Series" :interface "USB" :usbid "0x04b8" "0x0872" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "L200 Series" :interface "USB" :usbid "0x04b8" "0x0873" :status :complete :comment "all-in-one" :model "L210 Series" :interface "USB" :usbid "0x04b8" "0x08a1" :status :complete :comment "all-in-one" :model "L350" :interface "USB" :usbid "0x04b8" "0x08a1" :status :complete :comment "all-in-one" :model "L351" :interface "USB" :usbid "0x04b8" "0x08a1" :status :complete :comment "all-in-one" :model "L355" :interface "USB" :usbid "0x04b8" "0x08a8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "L358" :interface "USB" :usbid "0x04b8" "0x08a8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "L550 Series" :interface "USB" :usbid "0x04b8" "0x08a9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "L850 Series" :interface "USB" :usbid "0x04b8" "0x08ca" :status :complete :comment "all-in-one" :model "LP-7900CS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9000CCH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9000CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9000CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9500CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9500CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9500CH2" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9800CCH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9800CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9800CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-A500" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :comment "network interface not supported
business all-in-one" :model "LP-M5000" :interface "USB" :usbid "0x04b8" "0x0843" :status :good :comment "network interface not supported
business all-in-one" :model "LP-M5300 Series" :interface "USB" :usbid "0x04b8" "0x0894" :status :good :comment "network interface not supported
business all-in-one" :model "LP-M5500" :interface "USB" :usbid "0x04b8" "0x0817" :status :good :comment "network interface not supported
business all-in-one" :model "LP-M5500F" :interface "USB" :usbid "0x04b8" "0x0817" :status :good :comment "network interface not supported
business all-in-one
LP-M5500 with the fax option bundled" :model "LP-M5600" :interface "USB" :usbid "0x04b8" "0x0833" :status :good :comment "network interface not supported
business all-in-one" :model "LP-M6000" :interface "USB" :usbid "0x04b8" "0x0834" :status :good :comment "network interface not supported
business all-in-one" :model "LP-M8040" :interface "USB" :usbid "0x04b8" "0x08ad" :status :good :comment "network interface not supported
business all-in-one" :model "LP-M8040A" :interface "USB" :usbid "0x04b8" "0x08ad" :status :good :comment "network interface not supported
business all-in-one" :model "LP-M8040F" :interface "USB" :usbid "0x04b8" "0x08ad" :status :good :comment "network interface not supported
business all-in-one" :model "M200 Series" :interface "USB" :usbid "0x04b8" "0x08aa" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME 200" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "ME 300" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "ME 320 Series" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "ME 330 Series" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "ME 340 Series" :interface "USB" :usbid "0x04b8" "0x0883" :status :complete :comment "all-in-one" :model "ME OFFICE 510" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "ME OFFICE 520 Series" :interface "USB" :usbid "0x04b8" "0x0865" :status :complete :comment "all-in-one" :model "ME OFFICE 535" :interface "USB" :usbid "0x04b8" "0x0881" :status :complete :comment "all-in-one
overseas version of the PX-404A" :model "ME OFFICE 560W Series" :interface "USB" :usbid "0x04b8" "0x0864" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME OFFICE 570W Series" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-434A" :model "ME Office 600F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME OFFICE 620F Series" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME OFFICE 650FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "ME Office 700FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface not supported
all-in-one
overseas version of the PX-601F" :model "ME OFFICE 900WD Series" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "ME OFFICE 940FW Series" :interface "USB" :usbid "0x04b8" "0x0890" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME OFFICE 960FWD Series" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME-101" :interface "USB" :usbid "0x04b8" "0x08a0" :status :complete :comment "all-in-one" :model "ME-301" :interface "USB" :usbid "0x04b8" "0x0896" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME-303" :interface "USB" :usbid "0x04b8" "0x0897" :status :complete :comment "all-in-one
overseas version of the PX-405A" :model "ME-401" :interface "USB" :usbid "0x04b8" "0x0898" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-435A" :model "PM-A700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0814" :status :good :comment "all-in-one" :model "PM-A750" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one" :model "PM-A820" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one" :model "PM-A840" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one" :model "PM-A840S" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "network interface not supported
all-in-one" :model "PM-A850" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0806" :status :good :comment "all-in-one" :model "PM-A870" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one" :model "PM-A890" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one" :model "PM-A900" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0810" :status :good :comment "all-in-one" :model "PM-A920" :interface "USB" :usbid "0x04b8" "0x082a" :status :good :comment "all-in-one" :model "PM-A940" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one" :model "PM-A950" :interface "USB" :usbid "0x04b8" "0x081d" :status :good :comment "all-in-one" :model "PM-A970" :interface "USB" :usbid "0x04b8" "0x0828" :status :good :comment "all-in-one" :model "PM-T960" :interface "USB" :usbid "0x04b8" "0x0836" :status :good :comment "all-in-one" :model "PM-T990" :interface "USB" :usbid "0x04b8" "0x0829" :status :good :comment "all-in-one
PM-A970 with network interface" :model "PX-045A" :interface "USB" :usbid "0x04b8" "0x0895" :status :complete :comment "all-in-one" :model "PX-046A" :interface "USB" :usbid "0x04b8" "0x08ae" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-047A" :interface "USB" :usbid "0x04b8" "0x08c0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-1600F" :interface "USB" :usbid "0x04b8" "0x0869" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-1700F" :interface "USB" :usbid "0x04b8" "0x087c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-401A" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one" :model "PX-402A" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one" :model "PX-403A" :interface "USB" :usbid "0x04b8" "0x087f" :status :complete :comment "all-in-one" :model "PX-404A" :interface "USB" :usbid "0x04b8" "0x0881" :status :complete :comment "all-in-one" :model "PX-405A" :interface "USB" :usbid "0x04b8" "0x0897" :status :complete :comment "all-in-one" :model "PX-434A" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-435A" :interface "USB" :usbid "0x04b8" "0x0898" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-436A" :interface "USB" :usbid "0x04b8" "0x08af" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-437A" :interface "USB" :usbid "0x04b8" "0x08bf" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-501A" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface not supported
all-in-one" :model "PX-502A" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one" :model "PX-503A" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-504A" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-505F" :interface "USB" :usbid "0x04b8" "0x08a5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-535F" :interface "USB" :usbid "0x04b8" "0x08a6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-601F" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface not supported" :model "PX-602F" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-603F" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-605F" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-673F" :interface "USB" :usbid "0x04b8" "0x086a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-675F" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-A550" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one" :model "PX-A620" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one" :model "PX-A640" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one" :model "PX-A650" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one" :model "PX-A720" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one" :model "PX-A740" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one" :model "PX-B750F" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-FA700" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one" :model "PX-M350F" :interface "USB" :usbid "0x04b8" "0x08d0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M5040F" :interface "USB" :usbid "0x04b8" "0x08b9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M5041F" :interface "USB" :usbid "0x04b8" "0x08b9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M650A" :interface "USB" :usbid "0x04b8" "0x08c3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M650F" :interface "USB" :usbid "0x04b8" "0x08c3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M740F" :interface "USB" :usbid "0x04b8" "0x08b8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M741F" :interface "USB" :usbid "0x04b8" "0x08b8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M840F" :interface "USB" :usbid "0x04b8" "0x08bd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Perfection 600" :interface "SCSI" :status :unsupported :comment "supported by the umax backend
rebadged UMAX Astra 1200S" :model "Perfection 610" ; command spec :interface "USB" :usbid "0x04b8" "0x0103" :status :complete :comment "overseas version of the GT-6600U" :model "Perfection 636S" :interface "SCSI" :status :complete :comment "overseas version of the GT-7000S" :scsi "EPSON" "Perfection636" "processor" :model "Perfection 636U" ; command spec :interface "USB" :usbid "0x04b8" "0x0101" :status :complete :comment "overseas version of the GT-7000U" :model "Perfection 640U" ; command spec :interface "USB" :usbid "0x04b8" "0x010c" :status :complete :comment "overseas version of the GT-6700U" :model "Perfection 660" :interface "USB" :usbid "0x04b8" "0x0114" :status :unsupported :comment "supported by the snapscan backend" :model "Perfection 1200S" ; command spec :interface "SCSI" :status :complete :comment "overseas version of the GT-7600S" :scsi "EPSON" "Perfection1200" "processor" :model "Perfection 1200U" ; command spec :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "overseas version of the GT-7600U" :model "Perfection 1200U PHOTO" :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "Perfection 1200U with TPU option bundled
overseas version of the GT-7600UF" :model "Perfection 1240U" ; command spec :interface "USB" :usbid "0x04b8" "0x010b" :status :complete :comment "overseas version of the GT-7700U" :model "Perfection 1250" :interface "USB" :usbid "0x04b8" "0x010f" :status :good :comment "requires DFSG non-free iscan-plugin-gt-7200
also supported by the plustek backend
overseas version of the GT-7200U" :model "Perfection 1250 PHOTO" :interface "USB" :usbid "0x04b8" "0x010f" :status :good :comment "requires DFSG non-free iscan-plugin-gt-7200
also supported by the plustek backend
Perfection 1250 with TPU option bundled" :model "Perfection 1260" :interface "USB" :usbid "0x04b8" "0x011d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-7300
also supported by the plustek backend
overseas version of the GT-7300U" :model "Perfection 1260 PHOTO" :interface "USB" :usbid "0x04b8" "0x011d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-7300
also supported by the plustek backend
Perfection 1260 with TPU option bundled" :model "Perfection 1270" :interface "USB" :usbid "0x04b8" "0x0120" :status :unsupported :comment "supported by the snapscan backend
overseas version of the GT-7400" :model "Perfection 1600" :interface "SCSI" :status :unsupported :model "Perfection 1640SU" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :complete :comment "overseas version of the GT-8700" :model "Perfection 1640SU PHOTO" :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :good :comment "overseas version of the GT-8700F" :model "Perfection 1650" ; command spec :interface "USB" :usbid "0x04b8" "0x0110" :status :complete :comment "overseas version of the GT-8200U" :model "Perfection 1650 PHOTO" :interface "USB" :usbid "0x04b8" "0x0110" :status :good :comment "overseas version of the GT-8200UF" :model "Perfection 1660 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x011e" :status :complete :comment "overseas version of the GT-8300UF" :model "Perfection 1670" :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :comment "supported by the snapscan backend" :model "Perfection 1670 PHOTO" :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :comment "supported by the snapscan backend
overseas version of the GT-8400UF" :model "Perfection 2400 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x011b" :status :complete :comment "overseas version of the GT-9300UF" :model "Perfection 2450 PHOTO" ; command spec :interface "USB IEEE1394" :usbid "0x04b8" "0x0112" :scsi "EPSON" "GT-9700" "processor" :status :complete :comment "overseas version of the GT-9700F" :model "Perfection 2480 PHOTO" :interface "USB" :usbid "0x04b8" "0x0121" :status :good :comment "multi photo feeder not supported
requires DFSG non-free iscan-plugin-gt-f500
also supported by the snapscan backend
overseas version of the GT-F500" :model "Perfection 2580 PHOTO" :interface "USB" :usbid "0x04b8" "0x0121" :status :good :comment "auto film loader not supported
requires DFSG non-free iscan-plugin-gt-f500
also supported by the snapscan backend
overseas version of the GT-F550" :model "Perfection 3170 PHOTO" :interface "USB" :usbid "0x04b8" "0x0116" :status :good :comment "requires DFSG non-free iscan-plugin-gt-9400
overseas version of the GT-9400UF" :model "Perfection 3200 PHOTO" ; command spec :interface "USB IEEE1394" :usbid "0x04b8" "0x011c" :scsi "EPSON" "GT-9800" "processor" :status :complete :comment "overseas version of the GT-9800F" :model "Perfection 3490 PHOTO" :interface "USB" :usbid "0x04b8" "0x0122" :status :good :comment "multi photo feeder not supported
requires DFSG non-free iscan-plugin-gt-f520
also supported by the snapscan backend
overseas version of the GT-F520" :model "Perfection 3590 PHOTO" :interface "USB" :usbid "0x04b8" "0x0122" :status :good :comment "auto film loader not supported
requires DFSG non-free iscan-plugin-gt-f520
also supported by the snapscan backend
overseas version of the GT-F570" :model "Perfection 4180 PHOTO" :interface "USB" :usbid "0x04b8" "0x0118" :status :good :comment "only scans up to 2400dpi
requires DFSG non-free iscan-plugin-gt-f600
overseas version of the GT-F600" :model "Perfection 4490 PHOTO" :interface "USB" :usbid "0x04b8" "0x0119" :status :good :comment "requires DFSG non-free iscan-plugin-gt-x750
overseas version of the GT-X750" :model "Perfection 4870 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x0128" :status :complete :comment "IEEE1394 untested
overseas version of the GT-X700" :model "Perfection 4990 PHOTO" :interface "USB" :usbid "0x04b8" "0x012a" :status :good :comment "film area guide mode not supported
IEEE1394 untested
overseas version of the GT-X800" :model "Perfection 4990 Pro" :interface "USB IEEE1394" :status :untested :comment "seems to be a 4990 PHOTO with additional software" :model "Perfection V10" :interface "USB" :usbid "0x04b8" "0x012d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-s600
overseas version of the GT-S600" :model "Perfection V19" :interface "USB" :usbid "0x04b8" "0x013c" :status :good :comment "requires DFSG non-free iscan-plugin-gt-s650" :model "Perfection V30" :interface "USB" :usbid "0x04b8" "0x0131" :status :good :comment "requires DFSG non-free esci-interpreter-gt-f720
overseas version of the GT-S620" :model "Perfection V33" :interface "USB" :usbid "0x04b8" "0x0142" :status :good :comment "requires DFSG non-free esci-interpreter-perfection-v330
overseas version of the GT-S630" :model "Perfection V37" :interface "USB" :usbid "0x04b8" "0x014a" :status :good :comment "requires DFSG non-free iscan-plugin-perfection-v370
overseas version of the GT-S640" :model "Perfection V39" :interface "USB" :usbid "0x04b8" "0x013d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-s650
overseas version of the GT-S650" :model "Perfection V100 Photo" :interface "USB" :usbid "0x04b8" "0x012d" :status :good :comment "requires DFSG non-free iscan-plugin-gt-s600
overseas version of the GT-F650" :model "Perfection V200 Photo" :interface "USB" :usbid "0x04b8" "0x012e" :status :good :comment "requires DFSG non-free iscan-plugin-gt-f670
overseas version of the GT-F670" :model "Perfection V300 Photo" :interface "USB" :usbid "0x04b8" "0x0131" :status :good :comment "requires DFSG non-free esci-interpreter-gt-f720
overseas version of the GT-F720" :model "Perfection V330 Photo" :interface "USB" :usbid "0x04b8" "0x0142" :status :good :comment "requires DFSG non-free esci-interpreter-perfection-v330
overseas version of the GT-F730" :model "Perfection V370 Photo" :interface "USB" :usbid "0x04b8" "0x014a" :status :good :comment "requires DFSG non-free iscan-plugin-perfection-v370
overseas version of the GT-F740" :model "Perfection V350 Photo" :interface "USB" :usbid "0x04b8" "0x012f" :status :good :comment "auto film loader not supported
requires DFSG non-free iscan-plugin-gt-f700
overseas version of the GT-F700" :model "Perfection V500 Photo" :interface "USB" :usbid "0x04b8" "0x0130" :status :good :comment "requires DFSG non-free iscan-plugin-gt-x770
overseas version of the GT-X770" :model "Perfection V550 Photo" :interface "USB" :usbid "0x04b8" "0x013b" :status :good :comment "requires DFSG non-free iscan-plugin-perfection-v550" :model "Perfection V600 Photo" :interface "USB" :usbid "0x04b8" "0x013a" :status :good :comment "requires DFSG non-free iscan-plugin-gt-x820
overseas version of the GT-X820" :model "Perfection V700 Photo" :interface "USB" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested
overseas version of the GT-X900" :scsi "EPSON" "GT-X900" "processor" :model "Perfection V750 Photo" :interface "USB" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested
overseas version of the GT-X900" :scsi "EPSON" "GT-X900" "processor" :model "Perfection V800 Photo" :interface "USB" :usbid "0x04b8" "0x0151" :status :good :model "Perfection V850 Pro" :interface "USB" :usbid "0x04b8" "0x0151" :status :good :comment "overseas version of the GT-X980" :model "Stylus CX1500" ; Australia :interface "USB" :usbid "0x04b8" "0x080c" :status :unsupported :comment "supported by the snapscan backend
all-in-one" :model "Stylus CX2800" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "Stylus CX2900" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "Stylus CX3100" :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one
overseas version of the CC-570L" :model "Stylus CX3200" :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one
overseas version of the CC-570L" :model "Stylus CX3500" ; Australia :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one
overseas version of the PX-A550" :model "Stylus CX3600" ; UK :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one
overseas version of the PX-A550" :model "Stylus CX3650" ; France :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one" :model "Stylus CX3700" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus CX3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus CX3810" :interface "USB" :status :untested :comment "all-in-one" :model "Stylus CX3900" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one
overseas version of the PX-A620" :model "Stylus CX4100" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus CX4200" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus CX4300" :interface "USB" :usbid "0x04b8" "0x083f" :status :good :comment "all-in-one
requires DFSG non-free iscan-plugin-cx4400" :model "Stylus CX4400" :interface "USB" :usbid "0x04b8" "0x083f" :status :good :comment "all-in-one
requires DFSG non-free iscan-plugin-cx4400" :model "Stylus CX4500" :interface "USB" :usbid "0x04b8" "0x080d" :status :good :comment "all-in-one" :model "Stylus CX4600" :interface "USB" :usbid "0x04b8" "0x080d" :status :good :comment "all-in-one" :model "Stylus CX4700" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus CX4800" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus CX4900" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus CX5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus CX5100" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one
overseas version of the CC-600PX" :model "Stylus CX5200" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one
overseas version of the CC-600PX" :model "Stylus CX5300" :interface "USB" :usbid "0x04b8" "0x0808" :status :good :comment "all-in-one" :model "Stylus CX5400" :interface "USB" :usbid "0x04b8" "0x0808" :status :good :comment "all-in-one" :model "Stylus CX5500" :interface "USB" :usbid "0x04b8" "0x083f" :status :good :comment "all-in-one
requires DFSG non-free iscan-plugin-cx4400" :model "Stylus CX5600" :interface "USB" :usbid "0x04b8" "0x083f" :status :good :comment "all-in-one
requires DFSG non-free iscan-plugin-cx4400" :model "Stylus CX5700F" :interface "USB" :usbid "0x04b8" "0x0821" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX5800F" :interface "USB" :usbid "0x04b8" "0x0821" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX5900" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus CX6000" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus CX6300" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :comment "all-in-one
mistakenly thinks its a PX-A650" :model "Stylus CX6400" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :comment "all-in-one
mistakenly thinks its a PX-A650" :model "Stylus CX6500" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :comment "all-in-one" :model "Stylus CX6600" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :comment "all-in-one" :model "Stylus CX6900F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX7000F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX7300" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus CX7400" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus CX7700" :interface "USB" :usbid "0x04b8" "0x081f" :status :good :comment "all-in-one" :model "Stylus CX7800" :interface "USB" :usbid "0x04b8" "0x081f" :status :good :comment "all-in-one" :model "Stylus CX8300" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus CX8400" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus CX9300F" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus CX9400Fax" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus DX3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus DX3850" :interface "USB" ;:usbid "0x04b8" "0x0818" ; not confirmed :status :good :comment "all-in-one" :model "Stylus DX4000" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one
overseas version of the PX-A620" :model "Stylus DX4200" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus DX4400" :interface "USB" :usbid "0x04b8" "0x083f" :status :good :comment "all-in-one
requires DFSG non-free iscan-plugin-cx4400" :model "Stylus DX4800" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus DX4850" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
DX4800 + card reader" :model "Stylus DX5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus DX6000" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus DX7000F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus DX7400" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus DX8400" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus DX9400F" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus Office BX300F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX305F" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX305FW" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX305FW Plus" :interface "USB" :usbid "0x04b8" "0x0870" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX310FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "Stylus Office BX320FW Series" :interface "USB" :usbid "0x04b8" "0x085f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX535WD" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
overseas version of the PX-504A" :model "Stylus Office BX630FW Series" :interface "USB" :usbid "0x04b8" "0x0890" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX525WD" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "Stylus Office BX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface not supported
all-in-one
overseas version of the PX-601F" :model "Stylus Office BX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-602F" :model "Stylus Office BX625FWD" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX635FWD" :interface "USB" :usbid "0x04b8" "0x088f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX925FWD" :interface "USB" :usbid "0x04b8" "0x086a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-673F" :model "Stylus Office BX935FWD" :interface "USB" :usbid "0x04b8" "0x0892" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office TX300F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office TX320F Series" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office TX510FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "Stylus Office TX525FW" :interface "USB" :usbid "0x04b8" "0x085f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office TX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface not supported
all-in-one
overseas version of the PX-601F" :model "Stylus Office TX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-602F" :model "Stylus Office TX620FWD Series" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Photo PX650 Series" :interface "USB" :usbid "0x04b8" "0x0850" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-702A" :model "Stylus Photo PX660 Series" :interface "USB" :usbid "0x04b8" "0x0862" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-703A" :model "Stylus Photo PX700W" :interface "USB" :usbid "0x04b8" "0x0846" :status :good :comment "network interface not supported
all-in-one
overseas version of the EP-801A" :model "Stylus Photo PX710W Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-802A" :model "Stylus Photo PX720WD Series" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-803A" :model "Stylus Photo PX730WD Series" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-804A" :model "Stylus Photo PX800FW" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface not supported
all-in-one
overseas version of the EP-901A" :model "Stylus Photo PX810FW Series" :interface "USB" :usbid "0x04b8" "0x0853" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-902A" :model "Stylus Photo PX820FWD Series" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-903A" :model "Stylus Photo PX830FWD Series" :interface "USB" :usbid "0x04b8" "0x0879" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-904F" :model "Stylus Photo RX420" :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX425" ; France :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX430" ; Australia :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX500" :interface "USB" :usbid "0x04b8" "0x0807" :status :good :comment "all-in-one" :model "Stylus Photo RX510" :interface "USB" :usbid "0x04b8" "0x0807" :status :good :comment "all-in-one" :model "Stylus Photo RX520" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one
overseas version of the PM-A750" :model "Stylus Photo RX530" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one
overseas version of the PM-A750" :model "Stylus Photo RX560" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX585" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX580" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX595" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX590" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX600" :interface "USB" :usbid "0x04b8" "0x0806" :status :good :comment "all-in-one
overseas version of the PM-A850" :model "Stylus Photo RX610" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX620" :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one
overseas version of the PM-A870" :model "Stylus Photo RX630" :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one
overseas version of the PM-A870" :model "Stylus Photo RX640" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one
overseas version of the PM-A890" :model "Stylus Photo RX650" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one
overseas version of the PM-A890" :model "Stylus Photo RX680" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX685" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX690" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX700" :interface "USB" :usbid "0x04b8" "0x0810" :status :good :comment "all-in-one
overseas version of the PM-A900" :model "Stylus Photo TX650 Series" :interface "USB" :usbid "0x04b8" "0x0850" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-702A" :model "Stylus Photo TX700W" :interface "USB" :usbid "0x04b8" "0x0846" :status :good :comment "network interface not supported
all-in-one
overseas version of the EP-801A" :model "Stylus Photo TX710W Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-802A" :model "Stylus Photo TX720WD Series" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-803A" :model "Stylus Photo TX730WD Series" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-804A" :model "Stylus Photo TX800FW" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface not supported
all-in-one
overseas version of the EP-901A" :model "Stylus Photo TX820FWD Series" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-903A" :model "Stylus NX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus NX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus NX125" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "Stylus NX127" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "Stylus NX130 Series" :interface "USB" :usbid "0x04b8" "0x0883" :status :complete :comment "all-in-one" :model "Stylus NX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus NX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus NX220 Series" :interface "USB" :usbid "0x04b8" "0x0865" :status :complete :comment "all-in-one" :model "Stylus NX230 Series" :interface "USB" :usbid "0x04b8" "0x0885" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX300 Series" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX330 Series" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface not supported
all-in-one
overseas version of the PX-501A" :model "Stylus NX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface not supported
all-in-one" :model "Stylus NX420 Series" :interface "USB" :usbid "0x04b8" "0x0864" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX430W Series" :interface "USB" :usbid "0x04b8" "0x0884" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX510 Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "Stylus NX530 Series" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-504A" :model "Stylus NX625" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "Stylus NX635" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
overseas version of the PX-504A" :model "Stylus SX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus SX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus SX125" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "Stylus SX130 Series" :interface "USB" :usbid "0x04b8" "0x0883" :status :complete :comment "all-in-one" :model "Stylus SX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus SX205" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus SX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus SX218" :interface "USB" :usbid "0x04b8" "0x0865" :status :complete :comment "all-in-one" :model "Stylus SX230 Series" :interface "USB" :usbid "0x04b8" "0x0881" :status :complete :comment "all-in-one
overseas version of the PX-404A" :model "Stylus SX235W" :interface "USB" :usbid "0x04b8" "0x0885" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus SX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface not supported
all-in-one
overseas version of the PX-501A" :model "Stylus SX405" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "all-in-one" :model "Stylus SX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface not supported
all-in-one" :model "Stylus SX420W Series" :interface "USB" :usbid "0x04b8" "0x0864" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus SX430W Series" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus SX440W Series" :interface "USB" :usbid "0x04b8" "0x0884" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus SX510W Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "Stylus SX525WD" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "Stylus SX535WD" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
overseas version of the PX-504A" :model "Stylus SX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface not supported
all-in-one
overseas version of the PX-601F" :model "Stylus SX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-602F" :model "Stylus SX620FW Series" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Scan 2000" :interface "USB" :usbid "0x04b8" "0x0105" :status :untested :comment "apparently mostly the same as the Stylus Scan 2500" :model "Stylus Scan 2500" :interface "USB" :usbid "0x04b8" "0x0106" :status :untested :comment "scanner is apparently a GT-7000" :model "Stylus TX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus TX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus TX120 Series" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "Stylus TX130 Series" :interface "USB" :usbid "0x04b8" "0x0883" :status :complete :comment "all-in-one" :model "Stylus TX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX203" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX209" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus TX220 Series" :interface "USB" :usbid "0x04b8" "0x0865" :status :complete :comment "all-in-one" :model "Stylus TX230W Series" :interface "USB" :usbid "0x04b8" "0x0885" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus TX235" :interface "USB" :usbid "0x04b8" "0x0881" :status :complete :comment "all-in-one
overseas version of the PX-404A" :model "Stylus TX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface not supported
all-in-one
overseas version of the PX-501A" :model "Stylus TX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface not supported
all-in-one" :model "Stylus TX420W Series" :interface "USB" :usbid "0x04b8" "0x0864" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus TX430W Series" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus TX435W" :interface "USB" :usbid "0x04b8" "0x0884" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus TX550W Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "Stylus TX560WD Series" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "WF-2510 Series" :interface "USB" :usbid "0x04b8" "0x08a5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-505F" :model "WF-2520 Series" :interface "USB" :usbid "0x04b8" "0x08a6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-535F" :model "WF-2530 Series" :interface "USB" :usbid "0x04b8" "0x08a6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-535F" :model "WF-2540 Series" :interface "USB" :usbid "0x04b8" "0x08a6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-535F" :model "WF-2630 Series" :interface "USB" :usbid "0x04b8" "0x08c4" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-2650 Series" :interface "USB" :usbid "0x04b8" "0x08c3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-2660 Series" :interface "USB" :usbid "0x04b8" "0x08c3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-3520 Series" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-605F" :model "WF-3530 Series" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-675F" :model "WF-3540 Series" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-3620 Series" :interface "USB" :usbid "0x04b8" "0x08b8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M740F" :model "WF-3640 Series" :interface "USB" :usbid "0x04b8" "0x08b8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M741F" :model "WF-4630 Series" :interface "USB" :usbid "0x04b8" "0x08be" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-4640 Series" :interface "USB" :usbid "0x04b8" "0x08be" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-5620 Series" :interface "USB" :usbid "0x04b8" "0x08bd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M840F" :model "WF-5690 Series" :interface "USB" :usbid "0x04b8" "0x08bd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-7510 Series" :interface "USB" :usbid "0x04b8" "0x0869" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-1600F" :model "WF-7520 Series" :interface "USB" :usbid "0x04b8" "0x087c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-1700F" :model "WF-7610 Series" :interface "USB" :usbid "0x04b8" "0x08b9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M5040F" :model "WF-7620 Series" :interface "USB" :usbid "0x04b8" "0x08b9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M5041F" :model "WF-M1560 Series" :interface "USB" :usbid "0x04b8" "0x08ab" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-M5690 Series" :interface "USB" :usbid "0x04b8" "0x08d0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M350F" :model "WF-R4640 Series" :interface "USB" :usbid "0x04b8" "0x08cd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-R5690 Series" :interface "USB" :usbid "0x04b8" "0x08cd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WP-4511" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4515" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WP-4521" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4525" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4530 Series" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4540 Series" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4590 Series" :interface "USB" :usbid "0x04b8" "0x087e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 310 Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "WorkForce 320 Series" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
some models in the series have a built-in network interface
all-in-one" :model "WorkForce 435" :interface "USB" :usbid "0x04b8" "0x0870" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 500" :interface "USB" :usbid "0x04b8" "0x084c" :status :good :comment "all-in-one" :model "WorkForce 520 Series" :interface "USB" :usbid "0x04b8" "0x085f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 545" :interface "USB" :usbid "0x04b8" "0x0890" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 600" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface not supported
all-in-one
overseas version of the PX-601F" :model "WorkForce 610 Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-602F" :model "WorkForce 625" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "WorkForce 630 Series" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 645" :interface "USB" :usbid "0x04b8" "0x088f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 840 Series" :interface "USB" :usbid "0x04b8" "0x086a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-673F" :model "WorkForce 845" :interface "USB" :usbid "0x04b8" "0x0892" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce K301" :interface "USB" :usbid "0x04b8" "0x0872" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-100 Series" :interface "USB" :usbid "0x04b8" "0x0895" :status :complete :comment "all-in-one
overseas version of the PX-045A" :model "XP-200 Series" :interface "USB" :usbid "0x04b8" "0x0896" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-211" :interface "USB" :usbid "0x04b8" "0x08ae" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-046A" :model "XP-212" :interface "USB" :usbid "0x04b8" "0x08ae" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-046A" :model "XP-215" :interface "USB" :usbid "0x04b8" "0x08ae" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-046A" :model "XP-225" :interface "USB" :usbid "0x04b8" "0x08c0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-047A" :model "XP-300 Series" :interface "USB" :usbid "0x04b8" "0x0898" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-435A" :model "XP-310 Series" :interface "USB" :usbid "0x04b8" "0x08af" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-436A" :model "XP-320 Series" :interface "USB" :usbid "0x04b8" "0x08bf" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-437A" :model "XP-400 Series" :interface "USB" :usbid "0x04b8" "0x0898" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-435A" :model "XP-410 Series" :interface "USB" :usbid "0x04b8" "0x08b0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-420 Series" :interface "USB" :usbid "0x04b8" "0x08c1" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-600 Series" :interface "USB" :usbid "0x04b8" "0x089e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-775A" :model "XP-510 Series" :interface "USB" :usbid "0x04b8" "0x08b7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-706A" :model "XP-520 Series" :interface "USB" :usbid "0x04b8" "0x08c8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-777A" :model "XP-610 Series" :interface "USB" :usbid "0x04b8" "0x08b6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-776AB/EP-776AW" :model "XP-620 Series" :interface "USB" :usbid "0x04b8" "0x08c8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-777A" :model "XP-700 Series" :interface "USB" :usbid "0x04b8" "0x089d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-710 Series" :interface "USB" :usbid "0x04b8" "0x08b5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-806AB/EP-806AR/EP-806AW" :model "XP-720 Series" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-807AB/EP-807AR/EP-807AW" :model "XP-750 Series" :interface "USB" :usbid "0x04b8" "0x089c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-805A/EP-805AR/EP-805AW" :model "XP-760 Series" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-807AB/EP-807AR/EP-807AW" :model "XP-800 Series" :interface "USB" :usbid "0x04b8" "0x089b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-905A" :model "XP-810 Series" :interface "USB" :usbid "0x04b8" "0x08b4" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-906F" :model "XP-820 Series" :interface "USB" :usbid "0x04b8" "0x08c6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-907F" :model "XP-850 Series" :interface "USB" :usbid "0x04b8" "0x089a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-905F" :model "XP-860 Series" :interface "USB" :usbid "0x04b8" "0x08c6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-907F" :model "XP-950 Series" :interface "USB" :usbid "0x04b8" "0x08b3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-976A3" sane-backends-1.0.29/doc/descriptions-external/v4l2.desc0000666000000000000000000000173513615534521017731 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "v4l2" ; name of backend ;:version "(19991125)" ; version of backend ;:manpage "sane-v4l2" ; name of manpage (if it exists) :url "http://video.inodes.org/sane-v4l2/" ; backend's web page :comment "The status of this backend is unknown. It hasn't been updated for years. The v4l2 API is now in Linux 2.5 but it's not clear if the v4l2 backend is compatible to that API." :devicetype :api ; specify a different type :desc "Interface to Video For Linux 2 API" ; describe a non-hardware device ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions-external/hp3770.desc0000666000000000000000000000362413615534521020071 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "hp3770" ; name of backend ;:version "0.0" ; version of backend (or "unmaintained") ;:manpage "sane-template" ; name of manpage (if it exists) :url "http://www.cyberbaladeur.fr/telechargement.html" ; backend's web page :comment "This backend can't be added to the SANE distribution because it consists of binary-only code." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett Packard" ; name a manufacturer :url "http://www.hp.com/" ; manufacturer's URL :model "ScanJet 3770" ; name models for above-specified mfg. :status :basic ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :usbid "0x03f0" "0x2505" :url "http://ftp.cyberbaladeur.fr/3770.tar.gz" ; model's URL :comment "External backend. Binary-only Linux i386 code. Not supported by the SANE developers. Is reported to scan only a small area? Scanning of slides or negatives is not implemented." sane-backends-1.0.29/doc/descriptions-external/scanwit.desc0000666000000000000000000000170713615534521020611 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "scanwit" ; name of backend :url "ftp://ftp.mccme.ru/users/ushakov/scanwit" ;:version "(2001-10-10)" ; version of backend ; ;:manpage "sane-ibm" ; name of manpage (if it exists) :comment "The backend is not included because it lacks code for safe detection of the scanner and documentation." :devicetype :scanner :mfg "Benq (Acer)" ; name a manufacturer :url "http://www.benq.com" :comment "Formerly Acer Peripherals" :model "ScanWit 2720S" ; name models for above-specified mfg. :interface "SCSI" :status :basic :comment "Usable, but not complete" sane-backends-1.0.29/doc/descriptions-external/primascan.desc0000666000000000000000000000215413615534521021113 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "primascan" ; name of backend ;:version "0.42" ; version of backend (or "unmaintained") ;:manpage "sane-template" ; name of manpage (if it exists) :url "http://www.geocities.com/trsh0101/index.html" ; backend's web page :comment "SANE backend and stand-alone program" ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Primax" ; name a manufacturer :url "http://www.primax.nl/" :model "Colorado 2400U" :interface "USB" :usbid "0x0461" "0x0346" :status :minimal ;:comment "" sane-backends-1.0.29/doc/figs/0000755000000000000000000000000013615535553012760 500000000000000sane-backends-1.0.29/doc/figs/flow.fig0000666000000000000000000000376413615534521014346 00000000000000#FIG 3.1 Portrait Center Inches 1200 2 6 4200 7305 9945 7575 4 0 -1 0 0 17 18 0.0000 4 270 1500 4200 7515 - go back to\001 4 0 -1 0 0 16 18 0.0000 4 270 1440 5775 7515 sane_start()\001 4 0 -1 0 0 17 18 0.0000 4 210 2670 7275 7515 if more frames desired\001 -6 2 2 0 1 -1 7 10 0 19 0.000 0 0 -1 0 0 5 2700 600 10200 600 10200 9600 2700 9600 2700 600 2 2 0 1 -1 7 8 0 18 0.000 0 0 -1 0 0 5 3300 2400 10200 2400 10200 8925 3300 8925 3300 2400 2 2 0 1 -1 7 8 0 17 0.000 0 0 -1 0 0 5 3900 2925 10200 2925 10200 4650 3900 4650 3900 2925 2 2 0 1 -1 7 8 0 17 0.000 0 0 -1 0 0 5 3900 4800 10200 4800 10200 8250 3900 8250 3900 4800 2 1 0 1 -1 7 8 0 -1 0.000 0 0 -1 0 0 4 10350 3000 10425 3075 10425 4500 10350 4575 2 1 0 1 -1 7 8 0 -1 0.000 0 0 -1 0 0 4 10350 4875 10425 4950 10425 8100 10350 8175 4 0 -1 0 0 17 18 0.0000 4 150 735 4200 3300 - use:\001 4 0 -1 0 0 16 18 0.0000 4 270 1680 4200 5100 - sane_start()\001 4 0 -1 0 0 17 18 0.0000 4 270 4950 4500 4500 repeatedly to configure device as desired\001 4 0 -1 0 0 16 18 0.0000 4 270 2715 5400 4080 sane_control_option()\001 4 0 -1 0 0 16 18 0.0000 4 270 3660 5400 3600 sane_get_option_descriptor()\001 4 0 -1 0 0 17 18 0.0000 4 150 735 4200 5700 - use:\001 4 0 -1 0 0 17 18 0.0000 4 270 4080 4500 6900 repeatedly until read returns EOF\001 4 0 -1 0 0 16 18 0.0000 4 270 2805 5400 6000 sane_get_parameters()\001 4 0 -1 0 0 16 18 0.0000 4 270 1440 5400 6450 sane_read()\001 4 0 -1 0 0 16 18 0.0000 4 270 1935 4200 8100 - sane_cancel()\001 4 0 -1 0 0 16 18 0.0000 4 270 1500 3000 1200 - sane_init()\001 4 0 -1 0 0 16 18 0.0000 4 270 1590 3000 9300 - sane_exit()\001 4 0 -1 0 0 17 18 0.0000 4 270 4845 3600 1800 - pick desired device, possibly by using\001 4 0 -1 0 0 16 18 0.0000 4 270 1770 3600 2700 - sane_open()\001 4 0 -1 0 0 16 18 0.0000 4 270 1800 3600 8700 - sane_close()\001 4 0 -1 0 0 16 18 0.0000 4 270 2415 4800 2175 sane_get_devices()\001 4 0 -1 8 0 17 18 0.0000 4 270 2070 10575 6600 image acquisition\001 4 0 -1 8 0 17 18 0.0000 4 270 1500 10575 3825 device setup\001 sane-backends-1.0.29/doc/figs/hierarchy.fig0000666000000000000000000000605413615534521015350 00000000000000#FIG 3.1 Landscape Center Inches 1200 2 6 10500 4500 12300 5400 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 10650 4785 12150 4785 12150 5385 10650 5385 10650 4785 4 1 -1 0 0 16 18 0.0000 4 210 660 11399 5182 qcam\001 -6 6 7200 4500 9000 5400 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 7350 4785 8850 4785 8850 5385 7350 5385 7350 4785 4 1 -1 0 0 16 18 0.0000 4 270 315 8099 5182 hp\001 -6 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 2250 1185 3750 1185 3750 1785 2250 1785 2250 1185 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 450 2985 1950 2985 1950 3585 450 3585 450 2985 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 2250 2985 3750 2985 3750 3585 2250 3585 2250 2985 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 4050 2985 5550 2985 5550 3585 4050 3585 4050 2985 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 8850 1185 10350 1185 10350 1785 8850 1785 8850 1185 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 2700 1800 1200 3000 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 3000 1800 3000 3000 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 3300 1800 4800 3000 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9600 1800 9600 2100 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9450 2700 8100 4800 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11400 4200 11400 4800 2 2 0 0 0 0 10 0 2 0.000 0 0 -1 0 0 5 5700 3825 300 3825 300 300 5700 300 5700 3825 2 2 0 0 0 0 10 0 2 0.000 0 0 -1 0 0 5 12300 5550 7200 5550 7200 300 12300 300 12300 5550 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 1200 3600 1200 4200 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 3000 3600 3000 4125 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 7875 5400 7350 5850 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 8250 5400 8775 5850 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 11475 5400 11475 5850 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 8850 2100 10350 2100 10350 2700 8850 2700 8850 2100 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 10650 3600 12150 3600 12150 4200 10650 4200 10650 3600 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 9750 2700 11400 3600 3 2 0 1 -1 7 0 0 -1 0.000 0 0 0 7 4800 3600 4275 4500 5025 5475 6150 4575 6525 1350 9450 900 9600 1200 0.00 0.00 4390.23 4024.37 4258.98 4249.38 4300.21 4894.51 4554.60 5418.20 5575.94 5541.53 5962.09 4914.18 6573.46 3810.63 5758.15 2145.68 7223.99 624.74 8573.68 446.85 9524.49 938.52 9561.99 1013.52 0.00 0.00 4 1 -1 0 0 16 18 0.0000 4 210 525 1199 3382 pnm\001 4 1 -1 0 0 16 18 0.0000 4 210 870 2999 3382 mustek\001 4 1 -1 0 0 17 14 0.0000 4 210 855 1200 4425 pnm files\001 4 1 -1 0 0 17 14 0.0000 4 120 765 3000 4380 scanner\001 4 1 -1 0 0 17 14 0.0000 4 150 945 7350 6165 scanner 1\001 4 1 -1 0 0 17 14 0.0000 4 150 945 8925 6165 scanner 2\001 4 1 -1 0 0 17 14 0.0000 4 165 1290 11475 6135 video camera\001 4 1 -1 0 0 17 14 0.0000 4 165 1035 3000 600 machine A\001 4 1 -1 0 0 17 14 0.0000 4 165 1020 9600 630 machine B\001 4 1 -1 0 0 17 14 0.0000 4 165 1860 4725 5850 network connection\001 4 1 -1 0 0 16 18 0.0000 4 210 285 2999 1582 dll\001 4 1 -1 0 0 16 18 0.0000 4 195 390 4799 3382 net\001 4 1 -1 0 0 16 18 0.0000 4 210 735 9599 1582 saned\001 4 1 -1 0 0 16 18 0.0000 4 210 285 9599 2482 dll\001 4 1 -1 0 0 16 18 0.0000 4 210 960 11399 3982 autolum\001 sane-backends-1.0.29/doc/figs/xfer.fig0000666000000000000000000000140713615534521014333 00000000000000#FIG 3.1 Portrait Center Inches 1200 2 6 2325 3150 8175 3750 2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 2 1 2.00 120.00 240.00 2400 3300 8100 3300 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 2 1 2.00 120.00 240.00 8100 3375 2400 3675 -6 6 2325 3600 8175 4200 2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 2 1 2.00 120.00 240.00 2400 3750 8100 3750 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 2 1 2.00 120.00 240.00 8100 3825 2400 4125 -6 2 2 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 2250 3150 8250 3150 8250 6150 2250 6150 2250 3150 2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 2 1 2.00 120.00 240.00 2400 4200 8100 4200 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 2 1 2.00 120.00 240.00 8100 4275 2400 4575 2 1 0 2 -1 7 0 0 -1 0.000 0 0 -1 1 0 2 2 1 2.00 120.00 240.00 2400 4650 8100 4650 sane-backends-1.0.29/doc/figs/area.fig0000666000000000000000000000211113615534521014270 00000000000000#FIG 3.1 Portrait Center Inches 1200 2 6 1650 1650 1800 1800 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 1725 1650 1725 1800 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 1650 1725 1800 1725 -6 6 3300 2700 3450 2850 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 3375 2700 3375 2850 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 2 3300 2775 3450 2775 -6 6 1725 1725 3375 2775 2 2 0 0 7 7 10 0 18 0.000 0 0 -1 0 0 5 1725 1725 3375 1725 3375 2775 1725 2775 1725 1725 4 1 -1 10 0 16 12 0.0000 4 105 840 2550 2302 scan area\001 -6 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 1200 675 4275 675 4275 3375 1200 3375 1200 675 2 1 0 1 -1 7 10 0 16 0.000 0 0 -1 1 0 2 2 1 1.00 60.00 120.00 1200 525 1200 3825 2 1 0 1 -1 7 10 0 16 0.000 0 0 -1 1 0 2 2 1 1.00 60.00 120.00 1050 675 4650 675 4 1 -1 10 0 16 12 0.0000 4 180 1020 3375 3150 bottom-right\001 4 1 -1 10 0 16 12 0.0000 4 180 615 1725 1500 top-left\001 4 1 -1 10 0 16 12 0.0000 4 135 1080 2700 1050 scan surface\001 4 1 -1 10 0 16 12 0.0000 4 150 105 1050 3600 y\001 4 1 -1 10 0 16 12 0.0000 4 105 90 4425 525 x\001 4 1 -1 10 0 16 12 0.0000 4 135 105 1080 585 0\001 sane-backends-1.0.29/doc/figs/image-data.fig0000666000000000000000000000451313615534521015361 00000000000000#FIG 3.1 Portrait Center Inches 1200 2 6 1725 450 5925 1650 6 1800 975 3150 1350 2 2 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 1800 1200 3150 1200 3150 1350 1800 1350 1800 1200 4 0 -1 0 0 16 12 0.0000 4 135 1260 1875 1125 7 6 5 4 3 2 1 0\001 -6 6 3150 975 4500 1350 2 2 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 3150 1200 4500 1200 4500 1350 3150 1350 3150 1200 4 0 -1 0 0 16 12 0.0000 4 135 1260 3225 1125 7 6 5 4 3 2 1 0\001 -6 6 4500 975 5850 1350 2 2 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 4500 1200 5850 1200 5850 1350 4500 1350 4500 1200 4 0 -1 0 0 16 12 0.0000 4 135 1260 4575 1125 7 6 5 4 3 2 1 0\001 -6 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 1800 1200 5850 1200 5850 1350 1800 1350 1800 1200 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 7 1800 900 1950 825 3750 825 3825 750 3900 825 5700 825 5850 900 4 0 -1 0 0 16 12 0.0000 4 105 60 2475 1575 r\001 4 1 -1 0 0 16 12 0.0000 4 150 105 3825 1575 g\001 4 1 -1 0 0 16 12 0.0000 4 135 105 5175 1575 b\001 4 1 -1 0 0 16 12 0.0000 4 180 555 3825 600 pixel 0\001 -6 6 5850 975 7200 1350 2 2 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 5850 1200 7200 1200 7200 1350 5850 1350 5850 1200 4 0 -1 0 0 16 12 0.0000 4 135 1260 5925 1125 7 6 5 4 3 2 1 0\001 -6 6 7200 975 8550 1350 2 2 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 7200 1200 8550 1200 8550 1350 7200 1350 7200 1200 4 0 -1 0 0 16 12 0.0000 4 135 1260 7275 1125 7 6 5 4 3 2 1 0\001 -6 6 8550 975 9900 1350 2 2 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 8550 1200 9900 1200 9900 1350 8550 1350 8550 1200 4 0 -1 0 0 16 12 0.0000 4 135 1260 8625 1125 7 6 5 4 3 2 1 0\001 -6 2 2 0 2 -1 7 0 0 -1 0.000 0 0 -1 0 0 5 5850 1200 9900 1200 9900 1350 5850 1350 5850 1200 2 1 0 1 -1 7 0 0 -1 0.000 0 0 -1 0 0 7 5850 900 6000 825 7800 825 7875 750 7950 825 9750 825 9900 900 4 0 -1 0 0 16 12 0.0000 4 105 60 6525 1575 r\001 4 1 -1 0 0 16 12 0.0000 4 150 105 7875 1575 g\001 4 1 -1 0 0 16 12 0.0000 4 135 105 9225 1575 b\001 4 1 -1 0 0 16 12 0.0000 4 180 555 7875 600 pixel 1\001 4 1 -1 0 0 16 12 0.0000 4 180 525 9225 1950 byte 5\001 4 1 -1 0 0 16 12 0.0000 4 180 525 7875 1950 byte 4\001 4 1 -1 0 0 16 12 0.0000 4 180 525 6525 1950 byte 3\001 4 1 -1 0 0 16 12 0.0000 4 180 525 5175 1950 byte 2\001 4 1 -1 0 0 16 12 0.0000 4 180 465 3825 1950 byte1\001 4 1 -1 0 0 16 12 0.0000 4 180 465 2475 1950 byte0\001 4 1 -1 0 0 16 12 0.0000 4 15 180 10050 1275 ....\001 4 2 -1 0 0 16 12 0.0000 4 135 240 1725 1125 bit:\001 sane-backends-1.0.29/doc/sane-epson.man0000666000000000000000000002673713615534521014532 00000000000000.TH sane\-epson 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-epson .SH NAME sane\-epson \- SANE backend for EPSON scanners .SH DESCRIPTION The .B sane\-epson library implements a SANE (Scanner Access Now Easy) backend that provides access to Epson flatbed scanners. Some functions of this backend should be considered .B beta-quality software! Most functions have been stable for a long time, but of course new development can not and often times will not function properly from the very first day. Please report any strange behavior to the maintainer of the backend. .PP At present, the following scanners are known to work with this backend: .PP .RS .ft CR .nf Model: Connection Type --------------------------- ------------------- GT-5000 SCSI, parallel GT-6000 parallel GT-6500 SCSI (use only the line "scsi" in epson.conf) ActionScanner II SCSI, parallel GT-7000 SCSI Perfection 636 SCSI Perfection 636U USB Perfection 610 USB Perfection 640 USB Perfection 1200S SCSI Perfection 1200U USB Perfection 1240 USB, SCSI Perfection 1640 USB, SCSI Perfection 1650 USB Perfection 1660 USB Perfection 2400 USB Perfection 2450 USB, IEEE-1394 Expression 636 / GT-9500 SCSI Expression 1600 USB, SCSI, IEEE-1394 Expression 1680 USB, SCSI, IEEE-1394 CX-3200 USB CX-5200 USB .fi .ft R and many more. The official list is on the Sane web site. .RE For other scanners the software may or may not work. Please send mail to the backend author (khk@khk.net) to report success with scanners not on the list or problems with scanners that are listed. .SH OPTIONS The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in programs like xscanimage or xsane. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d epson .RE Not all devices support all options. .TP .I Scan Mode The .I \-\-mode switch selects the basic mode of operation of the scanner. Valid choices are Binary, Gray and Color. The Binary mode is black and white only, Gray will produce 256 levels of gray or more depending on the scanner and Color means 24 bit color mode or more depending on the scanner. Some scanners will internally use 36 bit color, their external interface however may only support 24 bits. The .I \-\-depth option selects the bit depth the scanner is using. This option is only available for scanners that support more than one bit depth. Older scanners will always transfer the image in 8bit mode. Newer scanners allow one to select either 8 bits, 12 or 14 bits per color channel. For a color scan this means an effective color depth of 36 or 42 bits over all three channels. The valid choices depend on the scanner model. The .I \-\-halftoning switch selects the mode that is used in Binary mode. Valid options are "None", "Halftone A (Hard Tone)", "Halftone B (Soft Tone)", "Halftone C (Net Screen)", "Dither A (4x4 Bayer)", "Dither B (4x4 Spiral)", "Dither C (4x4 Net Screen)", "Dither D (8x4 Net Screen)", "Text Enhanced Technology", "Download pattern A", and "Download pattern B". The .I \-\-dropout switch selects the so called dropout color. Valid options are None, Red, Green and Blue. The default is None. The dropout color is used for monochrome scanning and selects the color that is not scanned. This can be used to e.g. scan an original with a colored background. The .I \-\-brightness switch controls the brightness of the scan. Valid options are integer values from \-3 to 3. The default is 0. The larger the brightness value, the brighter the image gets. If a user defined table for the gamma correction is selected, the brightness parameter is not available. The .I \-\-sharpness switch sets the sharpness of the image data. Valid options are integer values from \-2 to 2, with \-2 meaning "Defocus", \-1 "Defocus slightly", 0 "Normal", 1 "Sharpen slightly" and 2 "Sharpen". The .I \-\-gamma\-correction switch controls the scanner's internal gamma correction. Valid options are "Default", "User defined", "High density printing" "Low density printing" and "High contrast printing". The .I \-\-color\-correction switch controls the scanner's internal color correction function. Valid options are "No Correction", "Impact\-dot printers", "Thermal printers", "Ink\-jet printers" and "CRT monitors". The default is "CRT monitors". The .I \-\-resolution switch selects the resolution for a scan. Some EPSON scanners will scan in any resolution between the lowest and highest possible value. The list reported by the scanner can be displayed using the "\-\-help \-d epson" parameters to scanimage. The .I \-\-mirror option controls the way the image is scanned. By reading the image data from right to left the image is mirrored. Valid options are "yes" and "no". The default is "no". The .I \-\-speed option can improve the scan speed in monochrome mode. Valid options are "yes" or "no", the "yes" option will speed up the scan if this option is supported. The .I \-\-auto\-area\-segmentation switch activates the automatic area segmentation for monochrome scans. The scanner will try to determine which areas are text and which contain images. The image areas will be halftoned, and the text will be improved. Valid options are "yes" and "no". The default is "yes". The .I \-\-gamma\-table parameter can be used to download a user defined gamma table. The option takes 256 values from the range 0-255. In color mode this option equally affects the red, green, and blue channel. The .I \-\-red\-gamma\-table parameter can be used to download a user defined gamma table for the red channel. The valid options are the same as for \-\-gamma\-table. The .I \-\-green\-gamma\-table parameter can be used to download a user defined gamma table for the green channel. The valid options are the same as for \-\-gamma\-table. The .I \-\-blue\-gamma\-table parameter can be used to download a user defined gamma table for the blue channel. The valid options are the same as for \-\-gamma\-table. The color correction coefficients .I \-\-cct\-1 \-\-cct\-2 \-\-cct\-3 ... \-\-cct\-9 will install color correction coefficients for the user defined color correction. Values are specified as integers in the range \-127..127. The .I \-\-preview option requests a preview scan. The frontend software automatically selects a low resolution. Valid options are "yes" and "no". The default is "no". The .I \-\-preview\-speed options will increase the scan speed if this is supported by the scanner. Valid options are "yes" and "no", the default is "no". The geometry options .I \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters. The .I \-\-quick\-format option lets the user select a scan area with predefined sizes. Valid parameters are "CD", "A5 portrait", "A5 landscape", "Letter", "A4" and "max". The default is "max", which selects the largest possible area. The .I \-\-source option selects the scan source. Valid options depend on the installed options. The default is "Flatbed". The .I \-\-auto\-eject option will eject a page after scanning from the document feeder. The .I \-\-film\-type option will select the film type for scans with the transparency unit. This option is only activated if the TPU is selected as scan source. Valid options are "Negative Film" and "Positive Film". The .I \-\-focus\-position option selects the focus position for all scans. Valid options are "Focus 2.5mm above glass" and "Focus on glass". The focus on the 2.5mm point above the glass is necessary for scans with the transparency unit, so that the scanner can focus on the film if one of the film holders is used. This option is only functional for selected scanners, all other scanners will ignore this option. .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/epson.conf specifies the device(s) that the backend will use. Possible connection types are: .TP .I SCSI This is the default, and if nothing else is specified the backend software will open a given path as SCSI device. More information about valid syntax for SCSI devices can be found in sane\-scsi(5). .br Usually SCSI scanners are configured with a line "scsi EPSON" in this file. In some cases it may be necessary to only use the string "scsi" (e.g. for the GT-6500). .TP .I PIO \- Parallel Interface The parallel interface can be configured in two ways: An integer value starting at the beginning of a line will be interpreted as the IO address of the parallel port. To make it clearer that a configured IO address is a parallel port the port address can be preceded by the string "PIO". The PIO connection does not use a special device file in the /dev directory. The IO address can be specified in hex mode (prefixed with "0x"). .TP .I USB A device file that is preceded by the string "USB" is treated as a scanner connected via the Universal Serial Bus. The correct special device file has to be created prior to using it with Sane. See the USB documentation for more information about how to set up the USB subsystem and the required device files. .SH FILES .TP .I @LIBDIR@/libsane\-epson.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-epson.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_EPSON If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .TP .B SANE_DEBUG_EPSON_SCSI If the library was compiled with debug support enabled, this environment variable controls the SCSI related debug level for this backend. Only a value of 2 is supported. .TP .B SANE_EPSON_CMD_LVL This allows one to override the function or command level that the backend uses to communicate with the scanner. The function level a scanner supports is determined during the initialization of the device. If the backend does not recognize the function level reported by the scanner it will default to function level B3. Valid function levels are A1, A2, B1, B2, B3, B4, B5, B6, B7, B8, D1 and F5. Use this feature only if you know what you are doing! .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1) .SH BUGS None :-) At least none are currently known. .SH UNSUPPORTED DEVICES The backend may be used with Epson scanners that are not yet listed under the list of supported devices. A scanner that is not recognized may default to the function level B3, which means that not all functions that the scanner may be capable of are accessible. If the scanner is not even recognized as an Epson scanner this is probably because the device name reported by the scanner is not in the correct format. Please send this information to the backend maintainer (email address is in the AUTHOR section of this man page or in the AUTHORS file of the SANE distribution). The Perfection 600, Perfection 650, Perfection 660, Perfection 1250 and Perfection 1260 are not supported by this backend. .SH AUTHOR The package is actively maintained by Karl Heinz Kremer (khk@khk.net). The software is based on work by Christian Bucher and Kazuhiro Sasayama sane-backends-1.0.29/doc/sane-avision.man0000666000000000000000000001270713615534521015046 00000000000000.TH sane\-avision 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-avision .SH NAME sane\-avision \- SANE backend for original Avision and Avision OEM scanners (HP, Minolta, Mitsubishi, UMAX and possibly more) flatbed and film scanners. .SH ABOUT THIS FILE This file is a short description for the avision-backend shipped with SANE. .SH DESCRIPTION The .B sane\-avision library implements a SANE (Scanner Access Now Easy) backend that provides access to various Avision scanners and the Avision OEM scanners labelled by HP, Minolta, Mitsubishi or Fujitsu. It is fully big-endian aware and in every-day use on PowerPC and SPARC systems. .B I suggest you hold one hand on the power-button of the scanner while you try the first scans \- especially with film-scanners! .SH CONFIGURATION The configuration file for this backend resides in .IR @CONFIGDIR@/avision.conf . Its contents is a list of device names that correspond to Avision and Avision compatible scanners and backend-options. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .nf # this is a comment \ option force\-a4 option force\-a3 option skip\-adf option disable\-gamma\-table option disable\-calibration \ #scsi Vendor Model Type Bus Channel ID LUN scsi AVISION scsi HP scsi /dev/scanner usb 0x03f0 0x0701 .fi .TP force\-a4: Forces the backend to overwrite the scanable area returned by the scanner to ISO A4. Scanner that are known to return bogus data are marked in the backend so if you need this option please report this to the backend maintainer. USE WITH CARE! .TP force\-a3: Forces the backend to overwrite the scanable area returned by the scanner to ISO A3. Scanner that are known to return bogus data are marked in the backend so if you need this option please report this to the backend maintainer. USE WITH CARE! .TP skip\-adf: Forces the backend to ignore an inconsistent ADF status returned by the scanner (ADF not present, but ADF model number non-zero). Without this option, the backend will make several attempts to reset the ADF and retry the query in this situation, and will fail with a "not supported" error if the ADF still doesn't respond. .TP disable\-gamma\-table: Disables the usage of the scanner's gamma-table. You might try this if your scans hang or only produces random garbage. .TP disable\-calibration: Disables the scanner's color calibration. You might try this if your scans hang or only produces random garbage. .TP Note: Any option above modifies the default code-flow for your scanner. The options should only be used when you encounter problems with the default be- haviour of the backend. Please report the need of options to the backend-author so the backend can be fixed as soon as possible. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I scsi scsi-spec .I usb usb-spec .RE .PP Where .I scsi-spec is the path-name to a special device or a device ID for the device that corresponds to a SCSI scanner. The special device name must be a generic SCSI device or a symlink to such a device, for example on Linux "/dev/sga" or "/dev/sg0". The device ID is the ID returned by the scanner, for example "HP" or "AVISION". See sane\-scsi(5) for details. .TP Note: Since the backend now includes native USB access, it is no longer needed \- even considered obsolete \- to access USB scanner via the SCSI emulation (named hpusbscsi on Linux) for Avision USB devices such as the HP 53xx, HP 74xx or Minolta film-scanners. .PP .I usb-spec is the USB device name, the vendor/product ID pair or the name used by libusb corresponding to the USB scanner. For example "0x03f0 0x0701" or "libusb:002:003". See sane\-usb(5) for details. The program .IR sane\-find\-scanner helps to find out the correct scsi or usb device name. A list with supported devices is built into the avision backend so normally specifying an ID should not be necessary. .SH FILES .TP .I @CONFIGDIR@/avision.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-avision.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-avision.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_AVISION If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. The debug level 7 is the author's preferred value to debug backend problems. Example: export SANE_DEBUG_AVISION=7 .SH "SEE ALSO" sane(7), sane\-scsi(5), sane\-usb(5) .br http://exactcode.com/site/open_source/saneavision/ .SH MAINTAINER Ren\['e] Rebe .SH AUTHOR Ren\['e] Rebe and Meino Christian Cramer sane-backends-1.0.29/doc/sane-test.man0000666000000000000000000002430413615534521014351 00000000000000.TH sane\-test 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-test .SH NAME sane\-test \- SANE backend for testing frontends .SH DESCRIPTION The .B sane\-test library implements a SANE (Scanner Access Now Easy) backend that allows testing the SANE installation and SANE frontends. It provides access to a (nearly) unlimited number of virtual devices. There is no support for real scanners or cameras. However, the backend simulates scanning and setting options. .PP The idea is not only to find bugs in frontends but also to show all capabilities of SANE. Therefore .B sane\-test implements functions and options that are not (or seldom) found in other backends. .PP The backend is commented out in @CONFIGDIR@/dll.conf, so either the comment character must be removed or the backend must be called explicitly. E.g. `scanimage \-d test' or `xscanimage test'. .SH SCAN MODE OPTIONS Option .B mode selects the scan mode (Gray or Color). .PP Option .B depth determines the number of bits per sample (1. 8, or 16). Keep in mind, that this value refers to the sample, not the pixel. So depth=16 results in 48 bits per pixel in color mode. The most usual combinations are mode=Gray, depth=1 for lineart, mode=Gray, depth=8 for gray and mode=Color, depth=8 for color mode. The combination of color and 1-bit mode is quite obscure (8 colors) but allowed in the SANE standard. However, the meaning of bits is not defined. Currently 1 = high intensity and 0 = low intensity is used. .PP Setting option .B hand\-scanner results in the test-backend behaving like a hand-scanner. Hand-scanners do not know the image height a priori. Instead, they return a height of \-1. Setting this option allows one to test whether a frontend can handle this correctly. This option also enables a fixed width of 11 cm. .PP Setting option .B three\-pass simulates a three-pass scanner. Older color scanners needed to scan the image once per color (reg/green/blue) to get the full image. Therefore, in this mode three single frames are transmitted in color mode. .PP Option .B three\-pass\-order provides support for changing the order of the three frames (see option three-pass above). A frontend should support all orders. .PP Option .B resolution sets the resolution of the image in dots per inch. .PP .PP Option .B source can be used to simulate an Automatic Document Feeder (ADF). After 10 scans, the ADF will be "empty". .PP .SH SPECIAL OPTIONS Option .B test\-picture allows one to set the image that's returned to the frontend. While "Solid white" and "Solid black" are quite obvious, the other options need some more explanation. Color patterns are used to determine if all modes and their colors are represented correctly by the frontend. The grid should look like the same in every mode and resolution. A table of all the test pictures can be found at: http://www.meier\-geinitz.de/sane/test\-backend/test\-pictures.html. .PP If option .B invert\-endianness is set, the upper and lower bytes of image data in 16 bit modes are exchanged. This option can be used to test the 16 bit modes of frontends, e.g. if the frontend uses the correct endianness. .PP If option .B read\-limit is set, the maximum amount of data transferred with each call to sane_read() is limited. .PP Option .B read\-limit\-size sets the limit for option read-limit. A low limit slows down scanning. It can be used to detect errors in frontend that occur because of wrong assumptions on the size of the buffer or timing problems. .PP Option .B read\-delay enables delaying data to the frontend. .PP Option .B read\-delay\-duration selects the number of microseconds the backends waits after each transfer of a buffer. This option is useful to find timing-related bugs, especially if used over the network. .PP If option .B read\-return\-value is different from "Default", the selected status will be returned by every call to sane_read(). This is useful to test the frontend's handling of the SANE statuses. .PP If option .B ppl\-loss is different from 0, it determines the number of pixels that are "lost" at the end of each line. That means, lines are padded with unused data. .PP Option .B fuzzy\-parameters selects that fuzzy (inexact) parameters are returned as long as the scan hasn't been started. This option can be used to test if the frontend uses the parameters it got before the start of the scan (which it shouldn't). .PP Option .B non\-blocking determines if non-blocking IO for sane_read() should be used if supported by the frontend. .PP If option .B select\-fd is set, the backend offers a select filedescriptor for detecting if sane_read() will return data. .PP If option .B enable\-test\-options is set, a fairly big list of options for testing the various SANE option types is enabled. .PP Option .B print\-options can be used to print a list of all options to standard error. .PP .SH GEOMETRY OPTIONS Option .B tl\-x determines the top-left x position of the scan area. .PP Option .B tl\-y determines the top-left y position of the scan area. .PP Option .B br\-x determines the bottom-right x position of the scan area. .PP Option .B br\-y determines the bottom-right y position of the scan area. .PP .SH BOOL TEST OPTIONS There are 6 bool test options in total. Each option is numbered. (3/6) means: this is option 3 of 6. The numbering scheme is intended for easier detection of options not displayed by the frontend (because of missing support or bugs). .PP Option .B bool\-soft\-select\-soft\-detect (1/6) is a bool test option that has soft select and soft detect (and advanced) capabilities. That's just a normal bool option. .PP Option .B bool\-hard\-select\-soft\-detect (2/6) is a bool test option that has hard select and soft detect (and advanced) capabilities. That means the option can't be set by the frontend but by the user (e.g. by pressing a button at the device). .PP Option .B bool\-hard\-select (3/6) is a bool test option that has hard select (and advanced) capabilities. That means the option can't be set by the frontend but by the user (e.g. by pressing a button at the device) and can't be read by the frontend. .PP Option .B bool\-soft\-detect (4/6) is a bool test option that has soft detect (and advanced) capabilities. That means the option is read-only. .PP Option .B bool\-soft\-select\-soft\-detect\-emulated (5/6) is a Bool test option that has soft select, soft detect, and emulated (and advanced) capabilities. .PP Option .B bool\-soft\-select\-soft\-detect\-auto (6/6) is a Bool test option that has soft select, soft detect, and automatic (and advanced) capabilities. This option can be automatically set by the backend. .PP .SH INT TEST OPTIONS There are 6 int test options in total. .PP Option .B int (1/6) is an int test option with no unit and no constraint set. .PP Option .B int\-constraint\-range (2/6) is an int test option with unit pixel and constraint range set. Minimum is 4, maximum 192, and quant is 2. .PP Option .B int\-constraint\-word\-list (3/6) is an int test option with unit bits and constraint word list set. .PP Option .B int\-constraint\-array (4/6) is an int test option with unit mm and using an array without constraints. .PP Option .B int\-constraint\-array\-constraint\-range (5/6) is an int test option with unit mm and using an array with a range constraint. Minimum is 4, maximum 192, and quant is 2. .PP Option .B int\-constraint\-array\-constraint\-word\-list (6/6) is an int test option with unit percent and using an array a word list constraint. .SH FIXED TEST OPTIONS There are 3 fixed test options in total. .PP Option .B fixed (1/3) is a fixed test option with no unit and no constraint set. .PP Option .B fixed\-constraint\-range (2/3) is a fixed test option with unit microsecond and constraint range set. Minimum is \-42.17, maximum 32767.9999, and quant is 2.0. .PP Option .B fixed\-constraint\-word\-list (3/3) is a Fixed test option with no unit and constraint word list set. .PP .SH STRING TEST OPTIONS There are 3 string test options in total. .PP Option .B string (1/3) is a string test option without constraint. .PP Option .B string\-constraint\-string\-list (2/3) is a string test option with string list constraint. .PP Option .B string\-constraint\-long\-string\-list (3/3) is a string test option with string list constraint. Contains some more entries... .PP .SH BUTTON TEST OPTION Option .B button (1/1) is a Button test option. Prints some text... .PP .SH FILES .TP .I @CONFIGDIR@/test.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). The initial values of most of the basic SANE options can be configured in this file. A template containing all the default values is provided together with this backend. One of the more interesting values may be .BR number_of_devices . It can be used to check the frontend's ability to show a long list of devices. The config values concerning resolution and geometry can be useful to test the handling of big file sizes. .TP .I @LIBDIR@/libsane\-test.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-test.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_TEST If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_TEST=4 .SH "SEE ALSO" sane(7), .IR http://www.meier\-geinitz.de/sane/test\-backend/ .SH AUTHOR Henning Meier-Geinitz .SH BUGS \- config file values aren't tested for correctness sane-backends-1.0.29/doc/doxygen-genesys.conf.in0000666000000000000000000002535313615534521016362 00000000000000# Doxyfile 1.8.8 #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = GENESYS PROJECT_NUMBER = @VERSION@ PROJECT_BRIEF = GENESYS backend documentation PROJECT_LOGO = OUTPUT_DIRECTORY = ./ CREATE_SUBDIRS = NO ALLOW_UNICODE_NAMES = NO OUTPUT_LANGUAGE = English BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = YES QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 ALIASES = TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES AUTOLINK_SUPPORT = YES BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = YES SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO INLINE_SIMPLE_STRUCTS = NO TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = YES EXTRACT_PRIVATE = NO EXTRACT_PACKAGE = NO EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = NO SHOW_GROUPED_MEMB_INC = NO FORCE_LOCAL_INCLUDES = NO INLINE_INFO = YES SORT_MEMBER_DOCS = NO SORT_BRIEF_DOCS = NO SORT_MEMBERS_CTORS_1ST = NO SORT_GROUP_NAMES = NO SORT_BY_SCOPE_NAME = NO STRICT_PROTO_MATCHING = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_FILES = YES SHOW_NAMESPACES = YES FILE_VERSION_FILTER = LAYOUT_FILE = CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = YES WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- INPUT = ../include/sane/ \ ../backend INPUT_ENCODING = UTF-8 FILE_PATTERNS = genesys*.[ch] RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = YES EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = ./ INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO FILTER_SOURCE_PATTERNS = USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES REFERENCES_LINK_SOURCE = YES SOURCE_TOOLTIPS = YES USE_HTAGS = NO VERBATIM_HEADERS = YES CLANG_ASSISTED_PARSING = NO CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = ./genesys-html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_EXTRA_STYLESHEET = HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES HTML_DYNAMIC_SECTIONS = NO HTML_INDEX_NUM_ENTRIES = 100 GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project DOCSET_PUBLISHER_ID = org.doxygen.Publisher DOCSET_PUBLISHER_NAME = Publisher GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO CHM_INDEX_ENCODING = BINARY_TOC = NO TOC_EXPAND = NO GENERATE_QHP = NO QCH_FILE = QHP_NAMESPACE = org.doxygen.Project QHP_VIRTUAL_FOLDER = doc QHP_CUST_FILTER_NAME = QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = QHG_LOCATION = GENERATE_ECLIPSEHELP = NO ECLIPSE_DOC_ID = org.doxygen.Project DISABLE_INDEX = NO GENERATE_TREEVIEW = NO ENUM_VALUES_PER_LINE = 4 TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES USE_MATHJAX = NO MATHJAX_FORMAT = HTML-CSS MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest MATHJAX_EXTENSIONS = MATHJAX_CODEFILE = SEARCHENGINE = NO SERVER_BASED_SEARCH = NO EXTERNAL_SEARCH = NO SEARCHENGINE_URL = SEARCHDATA_FILE = searchdata.xml EXTERNAL_SEARCH_ID = EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # Configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = LATEX_FOOTER = LATEX_EXTRA_FILES = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_SUBDIR = MAN_LINKS = NO #--------------------------------------------------------------------------- # Configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # Configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = ../backend INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration options related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = NO MSCGEN_PATH = DIA_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO DOT_NUM_THREADS = 0 DOT_FONTNAME = DOT_FONTSIZE = 10 DOT_FONTPATH = CLASS_GRAPH = YES COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO UML_LIMIT_NUM_FIELDS = 10 TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = NO CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png INTERACTIVE_SVG = NO DOT_PATH = DOTFILE_DIRS = MSCFILE_DIRS = DIAFILE_DIRS = PLANTUML_JAR_PATH = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES sane-backends-1.0.29/doc/sane-xerox_mfp.man0000666000000000000000000000406513615534521015403 00000000000000.TH sane\-xerox_mfp 5 "15 Dec 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-xerox_mfp .SH NAME sane\-xerox_mfp \- SANE backend for Xerox Phaser 3200MFP device et al. .SH DESCRIPTION The .B sane\-xerox_mfp library implements a SANE (Scanner Access Now Easy) backend that provides access to several Samsung-based Samsung, Xerox, and Dell scanners. Please see full list of supported devices at http://www.sane\-project.org/sane\-supported\-devices.html .SH CONFIGURATION .I @CONFIGDIR@/xerox_mfp.conf USB scanners do not need any configuration. For SCX\-4500W in network mode you need to specify .PP .RS .B tcp host_address [port] .RE .PP The .B host_address is passed through resolver, thus can be a dotted quad or a name from /etc/hosts or resolvable through DNS. .SH FILES .TP .I @CONFIGDIR@/xerox_mfp.conf The backend configuration file. By default all scanner types/models are enabled, you may want to comment out unwanted. .TP .I @LIBDIR@/libsane\-xerox_mfp.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-xerox_mfp.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .B SANE_DEBUG_XEROX_MFP If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_XEROX_MFP=4 .SH LIMITATIONS Multicast autoconfiguration for LAN scanners is not implemented yet. IPv6 addressing never been tested. .SH BUGS AND SUPPORT If you have found a bug or need support please follow open\-source way of acquiring support via mail\-lists http://www.sane\-project.org/mailing\-lists.html or SANE bug tracker http://www.sane\-project.org/bugs.html .SH AUTHORS Alex Belkin .br Samsung SCX\-4500W scan over network support by Alexander Kuznetsov .br Color scanning on Samsung M2870 model and Xerox Cognac 3215 & 3225 models by Laxmeesh Onkar Markod .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5) .br sane-backends-1.0.29/doc/sane-kodakaio.man0000666000000000000000000000270413615534521015154 00000000000000.TH sane\-kodakaio 5 "17 Jun 2012" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-kodakaio .SH NAME sane\-kodakaio \- SANE backend for Kodak aio printer / scanners .SH DESCRIPTION The .B sane\-kodakaio library implements a SANE (Scanner Access Now Easy) backend which provides access to Kodak aio printer / scanners, like the ESP and Hero series. This document describes backend version 2.4, which is the first candidate for incorporation in sane-backends. .SH SUPPORTED HARDWARE This version should support models of the Kodak ESP and Hero series, and possibly some Advent AiO scanners. The ESP 5250 and Hero 9.1 were used to develop the backend, but other models may work. Please see the desc file. If you have a model not on that list, or reported as 'untested': the best way to determine level of support is to test the scanner directly. .SH CONFIGURATION FILE The configuration file "kodakaio.conf" is used to tell the backend how to look for scanners, and provide options controlling the operation of the backend. This file is read each time the frontend asks the backend for a list of scanners, generally only when the frontend starts. .SH ENVIRONMENT The backend uses a single environment variable, SANE_DEBUG_KODAKAIO, which enables debugging output to stderr. .SH KNOWN ISSUES Most hardware options are either not supported or not exposed for control by the user, including: multifeed detection, image compression etc. .PP .SH AUTHOR P. Newall sane-backends-1.0.29/doc/sane-microtek.man0000666000000000000000000001272113615534521015207 00000000000000.TH sane\-microtek 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-microtek .SH NAME sane\-microtek \- SANE backend for Microtek scanners .SH DESCRIPTION The .B sane\-microtek library implements a SANE (Scanner Access Now Easy) backend that provides access to the "second generation" Microtek scanners. At present, the following hardware is known to work with this backend: .PP .RS Microtek ScanMaker E2, E3, E6 .br Microtek ScanMaker II, IIG, IIHR, IISP, III .br Microtek ScanMaker 35t, 35t+, 45t .br Microtek ScanMaker 600GS, 600ZS (see bug notes) .br Agfa StudioScan .br Agfa StudioScan II, StudioScan IIsi .br Agfa Arcus II (but not the "Arcus") .br Agfa DuoScan (preliminary) .br Vobis "Highscreen Realscan" .br Microtek Color PageWiz (preliminary) .br .PP Transparent Media Adapter .br Document AutoFeeder .br .RE .PP The driver supports line art, halftone, 8bpp gray, and 24bpp color scans at normal and "expanded" resolutions (i.e. 1200x1200 on an E6), fast scans for color previews, and downloadable gamma tables. .PP The supported scanners are all SCSI scanners. However, some parallel port models may work (under Linux), if they use a parport->scsi chip, and if you can find a scsi->parport driver. This is known to be the case for the Color PageWiz. .PP The driver does .B not support the newest Microtek scanners, such as the V330 and V660, which use a new and very different SCSI-II command set. For those, try the alternate .B microtek2 backend. Most non-SCSI scanners would use the new command set. Most scanners newer than the Scanmaker E6 would use the new command set. .PP If you own a Microtek scanner other than the ones listed above, tell us what happens --- see the .BR BUGS section at the end of this document. .PP Although this manual page is generally updated with each release, up-to-date information on new releases and extraneous helpful hints are available from the backend homepage: .br .RS .B http://www.mir.com/mtek/ .RE .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the UNIX path-name for the special device that corresponds to the scanner. The special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. .PP .SH CONFIGURATION The contents of the .I microtek.conf file is a list of device names that correspond to Microtek scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS /dev/scanner .br # this is a comment .br /dev/sge .RE .PP The configuration file may also contain the special tokens .I norealcal or .I noprecal. .I norealcal will disable the use of magic, undocumented scanner calibration commands which are known to work on the E6, but may not work with other models. .I noprecal will disable logic which tries to avoid scanner precalibration. This logic would only have been activated if the magic calibration code was turned off. .PP .SH FILES .TP .I @CONFIGDIR@/microtek.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-microtek.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-microtek.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_MICROTEK If the library was compiled with debugging support enabled, this environment variable controls the debug level for this backend. A value of 128 requests maximally copious debug output; smaller levels reduce verbosity. .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHOR Matt Marjanovic .SH BUGS Known bugs/limitations are: .PP .RS Brightness and contrast broken. .br The 600GS is grayscale only, and will lock up if you select color. (Unfortunately, the 600GS and 600ZS are indistinguishable by software.) .br .RE .PP i.e. don't complain about these --- but if brightness and/or contrast .B do work for you, please tell me. .PP If your scanner locks up, try setting the .I norealcal or .I noprecal option in the configuration file (first one, then both), and see if it helps. (If it does, report it.) .PP Send lengthy bug reports and new scanner information to .BR mtek\-bugs@mir.com . All bug reports and new scanner inquiries should include an error log file. You can generate copious stderr output by setting the SANE_DEBUG_MICROTEK environment variable described above. For example: .PP .RS setenv SANE_DEBUG_MICROTEK 128 .RE .PP More general comments, suggestions, and inquiries about frontends or SANE should go to .BR sane\-devel@alioth-lists.debian.net , the SANE Developers mailing list. Have a look at http://www.sane\-project.org/mailing\-lists.html concerning subscription to sane\-devel. sane-backends-1.0.29/doc/sane-hp5400.man0000666000000000000000000000655513615534521014322 00000000000000.TH sane\-hp5400 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-hp5400 .SH NAME sane\-hp5400 \- SANE backend for Hewlett-Packard 54XX scanners .SH DESCRIPTION The .B sane\-hp5400 library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Hewlett-Packard USB flatbed scanners: .PP .RS ScanJet 5400C .br ScanJet 5470C .br ScanJet 5490C .RE .PP More details can be found on the hp5400 backend homepage .IR http://hp5400backend.sourceforge.net/ . .PP This is ALPHA software. Keep your hand at the scanner's plug and unplug it, if the head bumps at the end of the scan area. See also the BUGS section. .PP If you own a scanner other than the ones listed above that works with this backend, please let us know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .IR /proc/bus/usb/devices , .I sane\-find\-scanner or syslog) to us. Even if the scanner's name is only slightly different from the models mentioned above, please let us know. .PP .SH CONFIGURATION The contents of the .I hp5400.conf file is a list of usb lines containing vendor and product ids that correspond to USB scanners. The file can also contain the names of device files that correspond to an HP 54XX scanner. Empty lines and lines starting with a hash mark (#) are ignored. The scanners are autodetected by .B usb vendor_id product_id statements which are already included into .IR hp5400.conf . "vendor_id" and "product_id" are hexadecimal numbers that identify the scanner. If autodetection does not work, add the device name of your scanner to the configuration file, e.g. .IR /dev/usb/scanner0 . .PP .SH FILES .TP .I @CONFIGDIR@/hp5400.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-hp5400.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-hp5400.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_HP5400 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_HP5400=4 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .br .I http://hp5400backend.sourceforge.net/ .SH AUTHOR Martijn van Oosterhout , Thomas Soumarmon . Manpage by Henning Meier-Geinitz . .SH BUGS Scanning is only tested with Linux/ix86/gcc. Be careful when testing on other operating systems and especially on big-endian platforms. The scanner may get wrong data. sane-backends-1.0.29/doc/sane-ricoh.man0000666000000000000000000000423413615534521014476 00000000000000.TH sane\-ricoh 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-ricoh .SH NAME sane\-ricoh \- SANE backend for Ricoh flatbed scanners .SH DESCRIPTION The .B sane\-ricoh library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Ricoh flatbed scanners: .PP .RS IS50 .br IS60 .br .RE .PP .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the path-name for the special device that corresponds to a SCSI scanner. The special device name must be a generic SCSI device or a symlink to such a device. The program .IR sane\-find\-scanner helps to find out the correct device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. See sane\-scsi(5) for details. .SH FILES .TP .I @CONFIGDIR@/ricoh.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-ricoh.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-ricoh.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_RICOH If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_RICOH=4 .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHOR Feico W. Dillema sane-backends-1.0.29/doc/sane-hp3500.man0000666000000000000000000000265713615534521014320 00000000000000.TH sane\-hp3500 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-hp3500 .SH NAME sane\-hp3500 \- SANE backend for Hewlett-Packard ScanJet 3500 series scanners .SH DESCRIPTION The .B sane\-hp3500 library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Hewlett-Packard USB flatbed scanners: .PP .RS ScanJet 3500C .br ScanJet 3530C .br ScanJet 3570C .RE .PP If you own a scanner other than the ones listed above that works with this backend, please let us know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .IR /proc/bus/usb/devices , .I sane\-find\-scanner or syslog) to us. Even if the scanner's name is only slightly different from the models mentioned above, please let us know. .SH CONFIGURATION None required. .SH FILES .TP .I @LIBDIR@/libsane\-hp3500.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-hp3500.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .B SANE_DEBUG_HP3500 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_HP3500=4 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .br .I http://projects.troy.rollo.name/rt-scanners/ .SH AUTHOR Troy Rollo sane-backends-1.0.29/doc/sane-abaton.man0000666000000000000000000001136613615534521014642 00000000000000.TH sane\-abaton 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-abaton .SH NAME sane\-abaton \- SANE backend for Abaton flatbed scanners .SH DESCRIPTION The .B sane\-abaton library implements a SANE (Scanner Access Now Easy) backend that provides access to Abaton flatbed scanners. At present, only the Scan 300/GS (8bit, 256 levels of gray) is fully supported, due to the absence of programming information. The Scan 300/S (black and white) is recognized, but support for it is untested. .PP If you own a Abaton scanner other than the ones listed above that works with this backend, or if you own an Abaton scanner that does not work with this backend, please contact .IR sane\-devel@alioth-lists.debian.net with the model number, so that arrangements can be made to include support for it. Have a look at http://www.sane\-project.org/mailing\-lists.html concerning subscription to sane\-devel. .PP Abaton is out of business, and these scanners are not supported by Everex (the parent company of Abaton), nor is there any programming information to be found. This driver is therefore based on information obtained by running Abaton's scanning desk accessory under MacsBug and tracing the MacOS SCSI Manager calls it made during image acquisition. .PP However, the protocol is very similar to, though not compatible with, the one used by the Apple scanners, therefore, if this backend is ever extended to support the other Abaton models (they also made a color flatbed scanner), it may be possible to fill in some "missing pieces" from the (quite detailed) Apple scanner documentation. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the path-name for the special device that corresponds to a SCSI scanner. For SCSI scanners, the special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name takes a format such as .I /dev/sga or .IR /dev/sg0 , for example. See sane\-scsi(5) for details. .SH CONFIGURATION The contents of the .I abaton.conf file is a list of device names that correspond to Abaton scanners. Empty lines and lines starting with a hash mark (#) are ignored. See sane\-scsi(5) on details of what constitutes a valid device name. .SH FILES .TP .I @CONFIGDIR@/abaton.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-abaton.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-abaton.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_ABATON If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 255 requests all debug output to be printed. Smaller levels reduce verbosity. .SH BUGS There are a few known ones, and definitely some unknown ones. .TP .B Scan area miscalculations For the sake of programmer efficiency, this backend handles all measurements in millimetres, and floors (rather than rounds) values to avoid possible damage to the scanner mechanism. Therefore, it may not be possible to scan to the extreme right or bottom edges of the page. .TP .B Cancelling the scan This might not work correctly, or it might abort the frontend. The former is more likely than the latter. .PP If you have found something that you think is a bug, please attempt to recreate it with the SANE_DEBUG_ABATON environment variable set to 255, and send a report detailing the conditions surrounding the bug to .IR sane\-devel@alioth-lists.debian.net . .SH TODO .TP .B Implement non-blocking support .TP .B Finish reverse-engineering the MacOS driver This will allow me to add support for other models with reasonable confidence that it will work, as well as to fully exploit the information returned by the INQUIRY command. .SH "SEE ALSO" sane(7), sane\-scsi(5), scanimage(1) .SH AUTHOR The sane\-abaton backend was partially written by David Huggins-Daines, based on the sane\-apple backend by Milon Firikis. sane-backends-1.0.29/doc/descriptions/0000755000000000000000000000000013615535552014535 500000000000000sane-backends-1.0.29/doc/descriptions/qcam.desc0000666000000000000000000000121213615534521016231 00000000000000:backend "qcam" ; name of backend :version "unmaintained" ; version of backend ; :url "" ; backend's homepage :manpage "sane-qcam" :devicetype :vidcam :mfg "Connectix" ; name a manufacturer ;:url "http://www.connectix.com/" ; doesn't exist any longer? :model "Color QuickCam" ; name models for above-specified mfg. :interface "Parport" :status :good :comment "Requires root privileges." :model "Greyscale QuickCam" ; name models for above-specified mfg. :interface "Parport" :status :minimal :comment "Requires root privileges. Partly working." sane-backends-1.0.29/doc/descriptions/coolscan2.desc0000666000000000000000000000276413615534521017210 00000000000000; ; SANE Backend specification file for coolscan2 ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "coolscan2" :version "0.1.8 (unmaintained)" :manpage "sane-coolscan2" :url "http://coolscan2.sourceforge.net/" :devicetype :scanner :mfg "Nikon" :url "http://www.nikon.com/" :model "LS 30" :interface "SCSI" :comment "working -- model available to developer" :status :complete :model "LS 2000" :interface "SCSI" :status :good :model "LS 40 ED" :interface "USB" :usbid "0x04b0" "0x4000" :status :complete :model "LS 4000 ED" :interface "IEEE-1394" :status :good :comment "needs linux kernel 2.4.19 or later" :model "LS 50 ED" ;:url "unsupported/nikon-ls50-ed.html" :interface "USB" :usbid "0x04b0" "0x4001" :status :minimal :model "Coolscan V ED" :url "unsupported/nikon-ls50-ed.html" :interface "USB" :usbid "0x04b0" "0x4001" :status :minimal :model "Super Coolscan LS-5000 ED" :url "unsupported/nikon-ls5000-ed.html" :interface "USB" :usbid "0x04b0" "0x4002" :status :untested :comment "May work, similar to LS 50 ED, but untested. Please tell us if it works." :model "LS 8000 ED" :interface "IEEE-1394" :status :good :comment "needs linux kernel 2.4.19 or later" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/leo.desc0000666000000000000000000000161613615534521016077 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "leo" ; name of backend :version "1.0-10 (unmaintained)" ; version of backend :manpage "sane-leo" ; name of manpage (if it exists) :url "http://www.zago.net/sane/#leo" ; backend's web page :devicetype :scanner ; start of a list of devices.... :mfg "LEO" :model "LEOScan S3" :interface "SCSI" :comment "FCC ID LUZFS1130" :status :good :mfg "Across Technologies" :model "FS-1130" :interface "SCSI" :comment "FCC ID LUZFS1130" :status :good :mfg "Genius" :model "FS-1130 Colorpage Scanner" :interface "SCSI" :status :good sane-backends-1.0.29/doc/descriptions/stv680.desc0000666000000000000000000000361613615534521016374 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "stv680" ; name of backend :version "1.0-1 (unmaintained)" ; version of backend :manpage "sane-stv680" :url "http://gkall.hobby.nl/stv680-aiptek.html" ; backend's web page :comment "This vidcam backend is for the stv0680 chipset, See the website for more info." :devicetype :vidcam ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Aiptek" ; name a manufacturer :url "http://www.aiptek.com.tw" ; name models for above-specified mfg. :model "Aiptek Pencam" :interface "USB" :usbid "0x0553" "0x0202" :status :minimal :comment "image is OK for CIF and QCIF, VGA and QVGA untested, streaming video is a problem" :mfg "Konica" ; name a manufacturer :url "http://www.konicaminolta.com" ; name models for above-specified mfg. :model "e-mini" :interface "USB" :usbid "0x04c8" "0x0722" :status :untested :comment " " :mfg "Digital Dream" ; name a manufacturer :url "http://www.digitaldreamco.com/en/index.shtml" ; name models for above-specified mfg. :model "l' espion XS" :interface "USB" :usbid "0x1183" "0x0001" :status :untested :comment " " :mfg "Creative" ; name a manufacturer :url "http://www.creative.com/" ; name models for above-specified mfg. :model "WebCam Go Mini" :interface "USB" :usbid "0x041e" "0x4007" :status :untested :comment " " ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/escl.desc0000666000000000000000000000037213615534521016244 00000000000000:backend "escl" :new :yes :manpage "sane-escl" :url "https://support.apple.com/en-us/HT201311" :comment "The eSCL backend for sane supports AirScan/eSCL devices that announce themselves on mDNS as _uscan._utcp or _uscans._utcp" :devicetype :scanner sane-backends-1.0.29/doc/descriptions/umax1220u.desc0000666000000000000000000000256213615534521016765 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "umax1220u" ; name of backend :version "unmaintained" ; version of backend ;:status :stable ; :alpha, :beta, :stable, :new :manpage "sane-umax1220u" ; name of manpage (if it exists) :url "http://sourceforge.net/projects/umax1220u-sane" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "UMAX" ; name a manufacturer :url "http://www.umax.com/" :model "Astra 1220U" ; name models for above-specified mfg. :interface "USB" :usbid "0x1606" "0x0010" :status :good :model "Astra 1600U" :interface "USB" :usbid "0x1606" "0x0030" :status :good :model "Astra 2000U" :interface "USB" :usbid "0x1606" "0x0030" :status :good :model "Astra 2100U" :interface "USB" :usbid "0x1606" "0x0130" :status :good ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/pixma.desc0000666000000000000000000011557113615534521016444 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "pixma" ; name of backend :version "0.27.0" ; version of backend (or "unmaintained") :manpage "sane-pixma" ; name of manpage (if it exists) ;:comment "Devices marked as experimantal are disabled by default. See the manual page for how to enable them." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" :model "PIXMA E400" :interface "USB" :usbid "0x04a9" "0x177a" :status :untested :comment "Testers needed!" :model "PIXMA E410 Series" :interface "USB" :usbid "0x04a9" "0x181e" :status :untested :comment "Testers needed!" :model "PIXMA E460 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1788" :status :untested :comment "Testers needed!" :model "PIXMA E470 Series" :interface "USB" :usbid "0x04a9" "0x180c" :status :untested :comment "Testers needed!" :model "PIXMA E480 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1789" :status :untested :comment "Testers needed!" :model "PIXMA E500" :interface "USB" :usbid "0x04a9" "0x1758" :status :untested :comment "Testers needed!" :model "PIXMA E510" :interface "USB" :usbid "0x04a9" "0x1761" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA E560" :interface "USB" :usbid "0x04a9" "0x177b" :status :untested :comment "Testers needed!" :model "PIXMA E600" :interface "USB" :usbid "0x04a9" "0x175a" :status :untested :comment "Testers needed!" :model "PIXMA E610" :interface "USB" :usbid "0x04a9" "0x1767" :status :untested :comment "Testers needed!" :model "PIXMA E3100 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1828" :status :untested :comment "Testers needed!" :model "PIXMA E3300 Series" :interface "USB" :usbid "0x04a9" "0x18a3" :status :untested :comment "Testers needed!" :model "PIXMA E4200 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1855" :status :untested :comment "Testers needed!" :model "PIXMA G2000" :interface "USB" :usbid "0x04a9" "0x1795" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "PIXMA G2010 Series" :interface "USB" :usbid "0x04a9" "0x183a" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "PIXMA G2100" :interface "USB" :usbid "0x04a9" "0x1795" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "PIXMA G3000 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1794" :status :untested :comment "Testers needed!" :model "PIXMA G3010 Series" :interface "USB WiFi" :usbid "0x04a9" "0x183b" :status :untested :comment "Testers needed!" :model "PIXMA G4000 Series" :interface "USB WiFi" :usbid "0x04a9" "0x181d" :status :untested :comment "Testers needed!" :model "PIXMA G4010 Series" :interface "USB WiFi" :usbid "0x04a9" "0x183d" :status :untested :comment "Testers needed!" :model "PIXMA G6000" :interface "USB WiFi" :usbid "0x04a9" "0x1865" :status :untested :comment "Testers needed!" :model "PIXMA G6080" :interface "USB WiFi" :usbid "0x04a9" "0x1866" :status :untested :comment "Testers needed!" :model "PIXMA MG2100 Series" :interface "USB" :usbid "0x04a9" "0x1751" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG2200 Series" :interface "USB" :usbid "0x04a9" "0x1760" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG2400 Series" :interface "USB" :usbid "0x04a9" "0x176c" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "PIXMA MG2500 Series" :interface "USB" :usbid "0x04a9" "0x176d" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "PIXMA MG2900 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1780" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "PIXMA MG3000 Series" :interface "USB WiFi" :usbid "0x04a9" "0x180b" :status :good :comment "All resolutions supported (up to 600DPI). WiFi not working." :model "PIXMA MG3100 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1752" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG3200 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1762" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG3500 Series" :interface "USB WiFi" :usbid "0x04a9" "0x176e" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG3600 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x178a" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG4100 Series" :interface "USB" :usbid "0x04a9" "0x1753" :status :untested :comment "Testers needed!" :model "PIXMA MG4200 Series" :interface "USB" :usbid "0x04a9" "0x1763" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG5100 Series" :interface "USB" :usbid "0x04a9" "0x1748" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG5200 Series" :interface "USB" :usbid "0x04a9" "0x1749" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG5300 Series" :interface "USB" :usbid "0x04a9" "0x1754" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MG5400 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1764" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MG5500 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1771" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG5600 Series" :interface "USB WiFi" :usbid "0x04a9" "0x177f" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG5700 Series" :interface "USB WiFi" :usbid "0x04a9" "0x178e" :status :complete :comment "All resolutions supported (up to 1200 DPI)." :model "PIXMA MG6100 Series" :interface "USB" :usbid "0x04a9" "0x174a" :status :complete :comment "All resolutions supported (up to 2400 DPI)" :model "PIXMA MG6200 Series" :interface "USB" :usbid "0x04a9" "0x1755" :status :complete :comment "All resolutions supported (up to 4800 DPI)" :model "PIXMA MG6300 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1765" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MG6400 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1770" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MG6500 Series" :interface "USB" :usbid "0x04a9" "0x176f" :status :untested :comment "Testers needed!" :model "PIXMA MG6600 Series" :interface "USB" :usbid "0x04a9" "0x177e" :status :untested :comment "Testers needed!" :model "PIXMA MG6800 Series" :interface "USB WiFi" :usbid "0x04a9" "0x178d" :status :untested :comment "Testers needed!" :model "PIXMA MG6900 Series" :interface "USB WiFi" :usbid "0x04a9" "0x178c" :status :untested :comment "Testers needed!" :model "PIXMA MG7100 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x1772" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MG7500 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x177c" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MG7700 Series" :interface "USB WiFi" :usbid "0x04a9" "0x178b" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MG8100 Series" :interface "USB" :usbid "0x04a9" "0x174b" :status :untested :comment "Testers needed!" :model "PIXMA MG8200 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1756" :status :complete :comment "All resolutions supported (up to 4800DPI)." :model "PIXMA MP140" :interface "USB" :usbid "0x04a9" "0x172b" :status :complete :comment "All resolutions supported (up to 600 DPI)" :model "PIXMA MP150" :interface "USB" :usbid "0x04a9" "0x1709" :status :good :model "PIXMA MP160" :interface "USB" :usbid "0x04a9" "0x1714" :status :basic :model "PIXMA MP170" :interface "USB" :usbid "0x04a9" "0x170a" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP180" :interface "USB" :usbid "0x04a9" "0x1715" :status :basic :model "PIXMA MP190" :interface "USB" :usbid "0x04a9" "0x1734" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "PIXMA MP210" :interface "USB" :usbid "0x04a9" "0x1721" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "PIXMA MP220" :interface "USB" :usbid "0x04a9" "0x1722" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP230" :interface "USB" :usbid "0x04a9" "0x175f" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "PIXMA MP240" :interface "USB" :usbid "0x04a9" "0x1732" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP250" :interface "USB" :usbid "0x04a9" "0x173a" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "PIXMA MP260" :interface "USB" :usbid "0x04a9" "0x1733" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP270" :interface "USB" :usbid "0x04a9" "0x173b" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP280" :interface "USB" :usbid "0x04a9" "0x1746" :status :good :comment "All resolutions supported (up to 600DPI)." :model "PIXMA MP360" :interface "USB" :usbid "0x04a9" "0x263c" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP370" :interface "USB" :usbid "0x04a9" "0x263d" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP375R" :interface "USB" :usbid "0x04a9" "0x263f" :status :untested :comment "Same protocol as Pixma MP360/370/390? Testers needed!" :model "PIXMA MP390" :interface "USB" :usbid "0x04a9" "0x263e" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP450" :interface "USB" :usbid "0x04a9" "0x170b" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP460" :interface "USB" :usbid "0x04a9" "0x1716" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP470" :interface "USB" :usbid "0x04a9" "0x1723" :status :complete :comment "All resolutions supported (up to 2400DPI)." :model "PIXMA MP480" :interface "USB" :usbid "0x04a9" "0x1731" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP490" :interface "USB" :usbid "0x04a9" "0x173c" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP493" :interface "USB" :usbid "0x04a9" "0x1757" :status :untested :comment "Testers needed!" :model "PIXMA MP495" :interface "USB" :usbid "0x04a9" "0x1747" :status :untested :comment "Same protocol as Pixma MP280? Testers needed!" :model "PIXMA MP500" :interface "USB" :usbid "0x04a9" "0x170c" :status :good :model "PIXMA MP510" :interface "USB" :usbid "0x04a9" "0x1717" :status :complete :comment "All resolutions supported (up to 1200DPI)." :model "PIXMA MP520" :interface "USB" :usbid "0x04a9" "0x1724" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP530" :interface "USB" :usbid "0x04a9" "0x1712" :status :good :model "PIXMA MP540" :interface "USB" :usbid "0x04a9" "0x1730" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP550" :interface "USB" :usbid "0x04a9" "0x173d" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP560" :interface "USB" :usbid "0x04a9" "0x173e" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP600" :interface "USB" :usbid "0x04a9" "0x1718" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP600R" :interface "USB Ethernet" :usbid "0x04a9" "0x1719" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP610" :interface "USB" :usbid "0x04a9" "0x1725" :status :complete :comment "All resolutions supported (up to 4800DPI)" :model "PIXMA MP620" :interface "USB Ethernet" :usbid "0x04a9" "0x172f" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "PIXMA MP630" :interface "USB" :usbid "0x04a9" "0x172e" :status :complete :comment "All resolutions supported (up to 4800DPI)" :model "PIXMA MP640" :interface "USB Ethernet" :usbid "0x04a9" "0x173f" :status :complete :comment "All resolutions supported (up to 4800DPI)" :model "PIXMA MP700" :interface "USB" :usbid "0x04a9" "0x2630" :status :complete :comment "All resolutions supported (flatbed color up to 1200DPI, grayscale up to 600DPI)." :model "PIXMA MP710" :interface "USB" :usbid "0x04a9" "0x264d" :status :complete :comment "All resolutions supported (up to 1200DPI)" :model "PIXMA MP730" :interface "USB" :usbid "0x04a9" "0x262f" :status :good :comment "Flatbed color up to 1200DPI, grayscale up to 600DPI. ADF scan to be confirmed." :model "PIXMA MP740" :interface "USB" :usbid "0x04a9" "0x264c" :status :untested :comment "Same protocol as Pixma MP710? Testers needed!" :model "PIXMA MP750" :interface "USB" :usbid "0x04a9" "0x1706" :status :minimal :comment "No grayscale. Canceling scan in ADF mode doesn't eject the paper!" :model "PIXMA MP760" :interface "USB" :usbid "0x04a9" "0x1708" :status :minimal :comment "No grayscale. The scanner sometimes hangs!" :model "PIXMA MP770" :interface "USB" :usbid "0x04a9" "0x1708" :status :minimal :comment "No grayscale. The scanner sometimes hangs!" :model "PIXMA MP780" :interface "USB" :usbid "0x04a9" "0x1707" :status :minimal :comment "No grayscale. The scanner sometimes hangs!" :model "PIXMA MP790" :interface "USB" :usbid "0x04a9" "0x1707" :status :minimal :comment "No grayscale. The scanner sometimes hangs!" :model "PIXMA MP800" :interface "USB" :usbid "0x04a9" "0x170d" :status :complete :comment "All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI." :model "PIXMA MP800R" :interface "USB" :usbid "0x04a9" "0x170e" :status :complete :comment "All resolutions supported up to 2400DPI. Full TPU support up to 2400DPI." :model "PIXMA MP810" :interface "USB" :usbid "0x04a9" "0x171a" :status :complete :comment "All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI." :model "PIXMA MP830" :interface "USB" :usbid "0x04a9" "0x1713" :status :complete :comment "All resolutions supported up to 2400DPI. Flatbed, ADF simplex and Duplex supported." :model "PIXMA MP960" :interface "USB" :usbid "0x04a9" "0x171b" :status :complete :comment "All resolutions supported up to 4800DPI. Full TPU support (negative and slides) up to 4800DPI." :model "PIXMA MP970" :interface "USB Ethernet" :usbid "0x04a9" "0x1726" :status :complete :comment "All resolutions supported (up to 4800DPI). Full TPU support (negative and slides) at 24 or 48 bits." :model "PIXMA MP980" :interface "USB Ethernet" :usbid "0x04a9" "0x172d" :status :complete :comment "Working fine at all resolutions." :model "PIXMA MP990" :interface "USB Ethernet" :usbid "0x04a9" "0x1740" :status :complete :comment "Working fine at all resolutions." :model "PIXMA MX300" :interface "USB" :usbid "0x04a9" "0x1727" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "PIXMA MX310" :interface "USB" :usbid "0x04a9" "0x1728" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)" :model "PIXMA MX320" :interface "USB" :usbid "0x04a9" "0x1736" :status :untested :comment "Same protocol as Pixma Generation 3? Testers needed!" :model "PIXMA MX330" :interface "USB" :usbid "0x04a9" "0x1737" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)" :model "PIXMA MX340" :interface "USB" :usbid "0x04a9" "0x1741" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)" :model "PIXMA MX350" :interface "USB Ethernet" :usbid "0x04a9" "0x1742" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)" :model "PIXMA MX360" :interface "USB" :usbid "0x04a9" "0x174d" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX370 Series" :interface "USB" :usbid "0x04a9" "0x1759" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX390 Series" :interface "USB" :usbid "0x04a9" "0x1766" :status :untested :comment "Testers needed!" :model "PIXMA MX410" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x174e" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX420" :interface "USB Ethernet" :usbid "0x04a9" "0x174f" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX430 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x175b" :status :untested :comment "Testers needed!" :model "PIXMA MX450 Series" :interface "USB" :usbid "0x04a9" "0x1768" :status :untested :comment "Testers needed!" :model "PIXMA MX470 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1774" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX490 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1787" :status :untested :comment "Testers needed!" :model "PIXMA MX510 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x175c" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX520 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x1769" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX530 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1775" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "PIXMA MX700" :interface "USB Ethernet" :usbid "0x04a9" "0x1729" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 2400DPI)" :model "PIXMA MX710 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x175d" :status :untested :comment "Testers needed!" :model "PIXMA MX720 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x176a" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX850" :interface "USB Ethernet" :usbid "0x04a9" "0x172c" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX860" :interface "USB Ethernet" :usbid "0x04a9" "0x1735" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX870" :interface "USB Ethernet" :usbid "0x04a9" "0x1743" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX880 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1750" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX882" :interface "USB Ethernet" :usbid "0x04a9" "0x1750" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX885" :interface "USB Ethernet" :usbid "0x04a9" "0x1750" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX890 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x175e" :status :complete :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX920 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x176b" :status :good :comment "All resolutions supported (up to 2400DPI). Flatbed, ADF simplex and Duplex supported." :model "PIXMA MX7600" :interface "USB Ethernet" :usbid "0x04a9" "0x171c" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 4800DPI)" :model "PIXMA TR4500 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1854" :status :untested :comment "Testers needed!" :model "PIXMA TR7500 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1824" :status :untested :comment "Testers needed!" :model "PIXMA TR7530 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1845" :status :untested :comment "Testers needed!" :model "PIXMA TR8500 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x1823" :status :untested :comment "Testers needed!" :model "PIXMA TR8530 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x1844" :status :untested :comment "Testers needed!" :model "PIXMA TR8580 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x1841" :status :untested :comment "Testers needed!" :model "PIXMA TR9530 Series" :interface "USB WiFi" :usbid "0x04a9" "0x185e" :status :untested :comment "Testers needed!" :model "PIXMA TS3100 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1827" :status :good :comment "All resolutions supported (up to 600DPI). WiFi not working." :model "PIXMA TS3300 Series" :interface "USB WiFi" :usbid "0x04a9" "0x18a2" :status :untested :comment "Testers needed!" :model "PIXMA TS5000 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1802" :status :good :comment "All resolutions supported (up to 1200DPI). WiFi not working." :model "PIXMA TS5100 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1825" :status :untested :comment "Testers needed!" :model "PIXMA TS5300 Series" :interface "USB WiFi" :usbid "0x04a9" "0x188b" :status :untested :comment "Testers needed!" :model "PIXMA TS5380 Series" :interface "USB WiFi" :usbid "0x04a9" "0x188c" :status :untested :comment "Testers needed!" :model "PIXMA TS6000 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1801" :status :untested :comment "Testers needed!" :model "PIXMA TS6100 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1822" :status :good :comment "All resolutions supported (up to 2400DPI). WiFi not working." :model "PIXMA TS6130 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1843" :status :untested :comment "Testers needed!" :model "PIXMA TS6180 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1840" :status :untested :comment "Testers needed!" :model "PIXMA TS6200 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1856" :status :good :comment "All resolutions supported (up to 1200DPI). WiFi not working." :model "PIXMA TS6230 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1858" :status :untested :comment "Testers needed!" :model "PIXMA TS6280 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1857" :status :untested :comment "Testers needed!" :model "PIXMA TS6300 Series" :interface "USB WiFi" :usbid "0x04a9" "0x188b" :status :good :comment "Testers needed!" :model "PIXMA TS6330 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1894" :status :untested :comment "Testers needed!" :model "PIXMA TS6380 Series" :interface "USB WiFi" :usbid "0x04a9" "0x188e" :status :untested :comment "Testers needed!" :model "PIXMA TS7330 Series" :interface "USB WiFi" :usbid "0x04a9" "0x188f" :status :untested :comment "Testers needed!" :model "PIXMA TS8000 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1800" :status :good :comment "All resolutions supported (up to 2400DPI). WiFi not working." :model "PIXMA TS8100 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1821" :status :untested :comment "Testers needed!" :model "PIXMA TS8130 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1842" :status :untested :comment "Testers needed!" :model "PIXMA TS8180 Series" :interface "USB WiFi" :usbid "0x04a9" "0x183f" :status :untested :comment "Testers needed!" :model "PIXMA TS8200 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1859" :status :good :comment "All resolutions supported (up to 1200DPI). WiFi not working." :model "PIXMA TS8230 Series" :interface "USB WiFi" :usbid "0x04a9" "0x185b" :status :untested :comment "Testers needed!" :model "PIXMA TS8280 Series" :interface "USB WiFi" :usbid "0x04a9" "0x185a" :status :untested :comment "Testers needed!" :model "PIXMA TS8300 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1890" :status :untested :comment "Testers needed!" :model "PIXMA TS8330 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1892" :status :untested :comment "Testers needed!" :model "PIXMA TS8380 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1891" :status :untested :comment "Testers needed!" :model "PIXMA TS9000 Series" :interface "USB WiFi" :usbid "0x04a9" "0x179f" :status :untested :comment "Testers needed!" :model "PIXMA TS9100 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x1820" :status :untested :comment "Testers needed!" :model "PIXMA TS9180 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x183e" :status :untested :comment "Testers needed!" :model "PIXMA TS9500 Series" :interface "USB WiFi" :usbid "0x04a9" "0x185c" :status :untested :comment "Testers needed!" :model "PIXMA TS9580 Series" :interface "USB WiFi" :usbid "0x04a9" "0x185d" :status :untested :comment "Testers needed!" :model "PIXUS MP5" :interface "USB" :usbid "0x04a9" "0x2635" :status :untested :comment "Testers needed! Identical with imageCLASS MPC190." :model "PIXUS MP10" :interface "USB" :usbid "0x04a9" "0x261f" :status :complete :comment "All resolutions supported (up to 600DPI). Identical with imageCLASS MPC200." :model "PIXUS XK50 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1846" :status :untested :comment "Testers needed!" :model "CanoScan XK 60" :interface "USB" :usbid "0x04a9" "0x1893" :status :untested :comment "Testers needed!" :model "PIXUS XK70 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1847" :status :untested :comment "Testers needed!" :model "PIXUS XK80 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1873" :status :untested :comment "Testers needed!" :model "imageCLASS D420" :interface "USB" :usbid "0x04a9" "0x26ef" :status :complete :comment "All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported." :model "imageCLASS D480" :interface "USB" :usbid "0x04a9" "0x26ed" :status :complete :comment "All resolutions supported (up to 600DPI). Flatbed, ADF simplex and Duplex supported." :model "imageCLASS D530" :interface "USB" :usbid "0x04a9" "0x2775" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS D550" :interface "USB" :usbid "0x04a9" "0x2738" :status :untested :comment "Testers needed!" :model "imageCLASS D570" :interface "USB" :usbid "0x04a9" "0x27e8" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "i-SENSYS MF110 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27ed" :status :untested :comment "Testers needed! WiFi only for w Types." :model "i-SENSYS MF210 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27a9" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). WiFi only for w Types." :model "i-SENSYS MF220 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27a8" :status :untested :comment "Testers needed!" :model "i-SENSYS MF230 Series" :interface "USB WiFi" :usbid "0x04a9" "0x27d1" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). WiFi only for w Types." :model "i-SENSYS MF240 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27d2" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI, ADF up to 300DPI). 216mm image width buggy, restricted to 215mm." :model "i-SENSYS MF260 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27f4" :status :untested :comment "Testers needed! Duplex only for MF269." :model "i-SENSYS MF410 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27c0" :status :untested :comment "Testers needed!" :model "i-SENSYS MF420 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27f1" :status :untested :comment "Testers needed!" :model "i-SENSYS MF510 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27c2" :status :untested :comment "Testers needed!" :model "i-SENSYS MF520 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27f0" :status :untested :comment "Testers needed!" :model "i-SENSYS MF620 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27b4" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF630 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27e1" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "imageCLASS MF634C" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27e2" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF640 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27fe" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF645C" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27fd" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF730 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27e4" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). Ethernet and WiFi not tested yet" :model "imageCLASS MF733Cdw" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27e5" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF731/733" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27e5" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF740 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27fb" :status :untested :comment "Testers needed!" :model "i-SENSYS MF741/743" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x27fc" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF810/820" :interface "USB Ethernet" :usbid "0x04a9" "0x27a6" :status :untested :comment "Testers needed!" :model "i-SENSYS MF3010" :interface "USB Ethernet" :usbid "0x04a9" "0x2759" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF3110" :interface "USB" :usbid "0x04a9" "0x2660" :status :complete :comment "All resolutions supported (up to 600DPI)." :model "imageCLASS MF3240" :interface "USB" :usbid "0x04a9" "0x2684" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4010" :interface "USB" :usbid "0x04a9" "0x26b4" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4018" :interface "USB" :usbid "0x04a9" "0x26b4" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4120" :interface "USB" :usbid "0x04a9" "0x26a3" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4122" :interface "USB" :usbid "0x04a9" "0x26a3" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4140" :interface "USB" :usbid "0x04a9" "0x26a3" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4150" :interface "USB" :usbid "0x04a9" "0x26a3" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF4270" :interface "USB" :usbid "0x04a9" "0x26b5" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "I-SENSYS MF4320d" :interface "USB" :usbid "0x04a9" "0x26ee" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "I-SENSYS MF4330d" :interface "USB" :usbid "0x04a9" "0x26ee" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF4350d" :interface "USB" :usbid "0x04a9" "0x26ee" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF4370dn" :interface "USB" :usbid "0x04a9" "0x26ec" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported" :model "imageCLASS MF4380dn" :interface "USB" :usbid "0x04a9" "0x26ec" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). Network not supported" :model "imageCLASS MF4410" :interface "USB" :usbid "0x04a9" "0x2737" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4430" :interface "USB" :usbid "0x04a9" "0x2737" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). ADF empty buggy." :model "i-SENSYS MF4500 Series" :interface "USB" :usbid "0x04a9" "0x2736" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "imageCLASS MF4570dw" :interface "USB" :usbid "0x04a9" "0x275a" :status :complete :comment "All resolutions supported (up to 600DPI)" :model "imageCLASS MF4660" :interface "USB" :usbid "0x04a9" "0x26b0" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF4690" :interface "USB" :usbid "0x04a9" "0x26b0" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "i-SENSYS MF4700 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x2774" :status :good :comment "Flatbed scan. All resolutions supported (up to 600DPI). ADF buggy." :model "i-SENSYS MF4800 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x2773" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). Ethernet buggy." :model "imageCLASS MF5630" :interface "USB" :usbid "0x04a9" "0x264e" :status :untested :comment "Testers needed!" :model "laserBase MF5650" :interface "USB" :usbid "0x04a9" "0x264f" :status :untested :comment "Testers needed!" :model "imageCLASS MF5730" :interface "USB" :usbid "0x04a9" "0x265d" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "imageCLASS MF5750" :interface "USB" :usbid "0x04a9" "0x265e" :status :untested :comment "Testers needed!" :model "imageCLASS MF5770" :interface "USB" :usbid "0x04a9" "0x265f" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF5880dn" :interface "USB" :usbid "0x04a9" "0x26f9" :status :untested :comment "Testers needed!" :model "i-SENSYS MF5900 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x2743" :status :untested :comment "Testers needed!" :model "i-SENSYS MF6100 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x278e" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). Note: document feeder does not have 600DPI capability." :model "imageCLASS MF6500 Series" :interface "USB" :usbid "0x04a9" "0x2686" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF6550" :interface "USB" :usbid "0x04a9" "0x2686" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "i-SENSYS MF6680dn" :interface "USB" :usbid "0x04a9" "0x26fa" :status :untested :comment "Testers needed!" :model "imageCLASS MF8030" :interface "USB" :usbid "0x04a9" "0x2707" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageCLASS MF8170c" :interface "USB" :usbid "0x04a9" "0x2659" :status :untested :comment "Testers needed!" :model "i-SENSYS MF8200C Series" :interface "USB Ethernet" :usbid "0x04a9" "0x2779" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI). Note: document feeder does not have 600DPI capability." :model "i-SENSYS MF8300 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x2708" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)." :model "i-SENSYS MF8500C Series" :interface "USB Ethernet" :usbid "0x04a9" "0x277a" :status :untested :comment "Same protocol as MF8200C Series? Testers needed!" :model "imageCLASS MPC190" :interface "USB" :usbid "0x04a9" "0x2635" :status :untested :comment "Testers needed! Identical with SmartBase MPC190 and PIXUS MP5." :model "imageCLASS MPC200" :interface "USB" :usbid "0x04a9" "0x261f" :status :complete :comment "All resolutions supported (up to 600DPI). Identical with SmartBase MPC200 and PIXUS MP10." :model "imageRUNNER 1020/1024/1025" :interface "USB" :usbid "0x04a9" "0x26e6" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "imageRUNNER 1133" :interface "USB" :usbid "0x04a9" "0x2742" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 600DPI)" :model "MAXIFY MB2000 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1778" :status :good :comment "Flatbed works, All resolutions supported (up to 1200DPI), ADF does not work" :model "MAXIFY MB2100 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1793" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "MAXIFY MB2300 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x1779" :status :good :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI), ADF does not work" :model "MAXIFY MB2700 Series" :interface "USB WiFi" :usbid "0x04a9" "0x1792" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "MAXIFY MB5000 Series" :interface "USB" :usbid "0x04a9" "0x1776" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "MAXIFY MB5100 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x1790" :status :untested :comment "Testers needed!" :model "MAXIFY MB5300 Series" :interface "USB Ethernet" :usbid "0x04a9" "0x1777" :status :good :comment "1200dpi scans do not work" :model "MAXIFY MB5400 Series" :interface "USB Ethernet WiFi" :usbid "0x04a9" "0x178f" :status :complete :comment "Flatbed and ADF scan. All resolutions supported (up to 1200DPI)." :model "CanoScan 8800F" :interface "USB" :usbid "0x04a9" "0x1901" :status :complete :comment "Flatbed scan. TPU for negatives and slides. All resolutions supported (up to 4800DPI)." :model "CanoScan 9000F" :interface "USB" :usbid "0x04a9" "0x1908" :status :complete :comment "Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI." :model "CanoScan 9000F Mark II" :interface "USB" :usbid "0x04a9" "0x190d" :status :complete :comment "Full flatbed support up to 4800DPI (Note: flatbed does not have 9600DPI capability). Full TPU support (negatives, slides and infrared) up to 9600DPI." :model "CanoScan LiDE 300" :interface "USB" :usbid "0x04a9" "0x1913" :status :complete :comment "All resolutions supported (up to 2400DPI)" :model "CanoScan LiDE 400" :interface "USB" :usbid "0x04a9" "0x1912" :status :complete :comment "All resolutions supported (up to 4800DPI)" sane-backends-1.0.29/doc/descriptions/epjitsu.desc0000666000000000000000000000476213615534521017010 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "epjitsu" ; name of backend :version "31" ; version of backend :manpage "sane-epjitsu" ; name of manpage (if it exists) :comment "Backend updated for SANE release 1.0.26, see sane-epjitsu manpage" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Fujitsu" ; name a manufacturer :url "http://www.fujitsu.com/" ;================================================== :model "fi-60F" :interface "USB" :status :good :usbid "0x04c5" "0x10c7" :comment "A6-size flatbed. Hardware provides 150/200/300/400/600 dpi in color. Software creates other resolutions, plus grayscale and binary modes. Hardware grayscale mode is not used due to poor calibration." :model "ScanSnap S300" :interface "USB" :status :good :usbid "0x04c5" "0x1156" :comment "Letter-size ADF. Hardware provides duplex, 150/225/300/600 dpi in color on AC or USB power. Software creates other resolutions, plus grayscale and binary modes. All buttons and sensors are exposed. Scanner always scans in _triplex_ color, fast USB required." :model "ScanSnap S300M" :interface "USB" :status :good :usbid "0x04c5" "0x117f" :comment "Same as S300, with different usb id" :model "fi-65F" :interface "USB" :status :good :usbid "0x04c5" "0x11bd" :comment "Same as fi-60f, with different usb id. Button support untested." :model "ScanSnap S1300" :interface "USB" :status :good :usbid "0x04c5" "0x11ed" :comment "Same as S300, with different usb id" :model "ScanSnap S1100" :interface "USB" :status :good :usbid "0x04c5" "0x1200" :comment "Letter-size ADF. Hardware provides simplex, 300/600 dpi in color on USB power. Software creates other resolutions, plus grayscale and binary modes. All buttons and sensors are exposed. Scanner always scans in _triplex_ color, fast USB required." :model "ScanSnap S1300i" :interface "USB" :status :good :usbid "0x04c5" "0x128d" :comment "Same as S300, with different usb id" :model "ScanSnap S1100i" :interface "USB" :status :good :usbid "0x04c5" "0x1447" :comment "Same as S1100, with different usb id" sane-backends-1.0.29/doc/descriptions/canon_pp.desc0000666000000000000000000000336313615534521017116 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon_pp" ; name of backend :manpage "sane-canon_pp" :version "0.33 (unmaintained)" ; version of backend :url "http://canon-fb330p.sourceforge.net" ; backend home page :devicetype :scanner :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" :model "CanoScan FB310P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :unsupported :comment "Rebadged Avision, different command set" :model "CanoScan FB610P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :unsupported :comment "Rebadged Avision, different command set" :model "CanoScan FB320P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :basic :comment "Newly added support" :model "CanoScan FB620P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :basic :comment "Newly added support" :model "CanoScan FB330P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :model "CanoScan FB630P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :model "CanoScan N340P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :model "CanoScan N640P" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :model "CanoScan N640P ex" ; name models for above-specified mfg. :interface "Parport (ECP)" :status :good :comment "Just an N640P in a different box?" sane-backends-1.0.29/doc/descriptions/ma1509.desc0000666000000000000000000000227413615534521016235 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "ma1509" ; name of backend :version "1.0-3 (unmaintained)" ; version of backend :manpage "sane-ma1509" ; name of manpage (if it exists) :url "http://www.meier-geinitz.de/sane/ma1509-backend/" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Mustek" ; name a manufacturer :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "BearPaw 1200 F" :interface "USB" :usbid "0x055f" "0x0010" :status :good :comment "Works upto 600 dpi. No support for TA and ADF yet." :mfg "Fujitsu" ; name a manufacturer :url "http://www.fujitsu.com/" :model "fi-4110EOX/2/3" :interface "USB" :usbid "0x04c5" "0x1040" :status :unsupported :comment "Uses ma1509 chip, but very different from other scanners supported by the ma1509 backend" sane-backends-1.0.29/doc/descriptions/epson2.desc0000666000000000000000000030753313615534521016535 00000000000000; ; SANE Backend specification file for the epson2 backend ; ; Copyright (C) 2009-10 Alessandro Zummo ; Released under GPLv2 ; ; This file is derived from epkowa.desc, Copyright (C) Olaf Meeuwissen, ; distributed with "Image Scan!" and released under GPL. :backend "epson2" :version "1.0.124 (unmaintained)" :new :no :manpage "sane-epson2" :devicetype :scanner :mfg "Epson" :url "http://www.epson.com/" :model "AL-MX300DN Series" :interface "USB" :usbid "0x04b8" "0x08ac" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :url "http://www.epson.com/" :model "AL-MX300DNF Series" :interface "USB" :usbid "0x04b8" "0x08ac" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Actionscanner II" :interface "parallel SCSI" :status :good :comment "overseas version of the GT-5000" :model "AcuLaser CX11" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :comment "overseas version of the LP-A500" :model "AcuLaser CX11NF" :interface "USB Network" :usbid "0x04b8" "0x0815" :status :good :comment "network interface supported
AcuLaser CX11 with network interface and fax" :model "AcuLaser CX21" :interface "USB Network" :usbid "0x04b8" "0x0835" :status :good :comment "network interface supported" :model "AcuLaser MX20DN" :interface "USB" :usbid "0x04b8" "0x0866" :status :complete :comment "network interface probably supported
business all-in-one" :model "AcuLaser MX20DNF" :interface "USB" :usbid "0x04b8" "0x0866" :status :complete :comment "network interface probably supported
business all-in-one" :model "AcuLaser MX21DNF" :interface "USB" :usbid "0x04b8" "0x0866" :status :complete :comment "network interface probably supported
business all-in-one" :model "Artisan 635" :interface "USB" :usbid "0x04b8" "0x0878" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-704A" :model "Artisan 700" :interface "USB Network" :usbid "0x04b8" "0x0846" :status :good :comment "network interface supported
all-in-one
overseas version of the EP-801A" :model "Artisan 710 Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-802A" :model "Artisan 725" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-803A" :model "Artisan 730 Series" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-804A" :model "Artisan 800" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one
overseas version of the EP-901A" :model "Artisan 810 Series" :interface "USB" :usbid "0x04b8" "0x0853" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-902A" :model "Artisan 835" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-903A" :model "Artisan 837" :interface "USB" :usbid "0x04b8" "0x0879" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-904F" :model "CC-500L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010d" :status :unsupported :comment "all-in-one" :model "CC-550L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011a" :status :unsupported :comment "all-in-one" :model "CC-570L" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one" :model "CC-600PX" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one" :model "CC-700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0108" :status :unsupported :comment "all-in-one" :model "DS-30" :interface "USB" :usbid "0x04b8" "0x0147" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "DS-G20000" :interface "USB" :usbid "0x04b8" "0x015b" :status :good :model "EP-702A" :interface "USB" :usbid "0x04b8" "0x0850" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-703A" :interface "USB" :usbid "0x04b8" "0x0862" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-704A" :interface "USB" :usbid "0x04b8" "0x0878" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-705A" :interface "USB" :usbid "0x04b8" "0x089f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-706A" :interface "USB" :usbid "0x04b8" "0x08b7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-707A" :interface "USB" :usbid "0x04b8" "0x08c9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-774A" :interface "USB" :usbid "0x04b8" "0x0893" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-775A" :interface "USB" :usbid "0x04b8" "0x089e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-775AW" :interface "USB" :usbid "0x04b8" "0x089e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-776AB" :interface "USB" :usbid "0x04b8" "0x08b6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-776AW" :interface "USB" :usbid "0x04b8" "0x08b6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-777A" :interface "USB" :usbid "0x04b8" "0x08c8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-801A" :interface "USB Network" :usbid "0x04b8" "0x0846" :status :good :comment "network interface supported
all-in-one" :model "EP-802A" :interface "USB" :usbid "0x04b8" "0x0852" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-803A" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-803AW" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-804A" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-804AR" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-804AW" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-805A" :interface "USB" :usbid "0x04b8" "0x089c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-805AR" :interface "USB" :usbid "0x04b8" "0x089c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-805AW" :interface "USB" :usbid "0x04b8" "0x089c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-806AB" :interface "USB" :usbid "0x04b8" "0x08b5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-806AR" :interface "USB" :usbid "0x04b8" "0x08b5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-806AW" :interface "USB" :usbid "0x04b8" "0x08b5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-807AB" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-807AR" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-807AW" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-901A" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one" :model "EP-901F" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one" :model "EP-902A" :interface "USB" :usbid "0x04b8" "0x0853" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-903A" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-903F" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-904A" :interface "USB" :usbid "0x04b8" "0x0879" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-904F" :interface "USB" :usbid "0x04b8" "0x0879" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-905A" :interface "USB" :usbid "0x04b8" "0x089b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-905F" :interface "USB" :usbid "0x04b8" "0x089a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-906F" :interface "USB" :usbid "0x04b8" "0x08b4" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-907F" :interface "USB" :usbid "0x04b8" "0x08c6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-976A3" :interface "USB" :usbid "0x04b8" "0x08b3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "EP-977A3" :interface "USB" :usbid "0x04b8" "0x08c5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ES-300C" :interface "SCSI parallel" :status :good :comment "overseas version of the GT-6000" :model "ES-300GS" :interface "SCSI" :status :good :model "ES-600C" :interface "parallel" :status :good :comment "overseas version of the GT-5400" :model "ES-800C" :interface "SCSI" :status :good :comment "overseas version of the GT-8000" :model "ES-1000C" :status :unsupported :comment "overseas version of the GT-8500" :model "ES-1200C" :interface "parallel" :status :good :comment "overseas version of the GT-9000" :model "ES-2000" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0107" :status :complete :comment "IEEE1394 untested" :model "ES-2200" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010e" :status :complete :comment "IEEE1394 untested" :model "ES-6000" ; product spec (JP) :interface "SCSI" :status :good :model "ES-6000H" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-6000HS" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-7000H" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0126" :status :good :comment "network interface probably supported
IEEE1394 untested" :model "ES-8000" :interface "SCSI" :status :untested :model "ES-8500" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x0109" :status :good :comment "IEEE1394 untested" :model "ES-9000H" ; product spec (JP) :interface "SCSI" :status :good :comment "IEEE1394 untested" :model "ES-10000G" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0129" :status :good :comment "network interface probably supported
IEEE1394 untested" :model "ES-D200" :interface "USB" :usbid "0x04b8" "0x0137" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "ES-D350" :interface "USB" :usbid "0x04b8" "0x0144" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "ES-D400" :interface "USB" :usbid "0x04b8" "0x0136" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "ES-G11000" :interface "USB" :usbid "0x04b8" "0x014b" :status :good :model "ES-H300" :interface "USB" :usbid "0x04b8" "0x012b" :status :good :comment "network interface probably supported" :model "ES-H7200" :interface "USB Ethernet" :usbid "0x04b8" "0x0138" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package" :model "ET-2650" :interface "USB Ethernet" :usbid "0x04b8" "0x1121" :status :good :model "Expression 636" :interface "SCSI" :status :complete :comment "overseas version of the GT-9500" :model "Expression 800" ; command spec :interface "SCSI" :scsi "EPSON" "Expression800" "processor" :status :complete :comment "overseas version of the GT-9600" :model "Expression 836XL" ; command spec :interface "SCSI" :status :untested :comment "overseas version of the ES-8000" :model "Expression 1600" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0107" :status :complete :comment "IEEE1394 untested
overseas version of the ES-2000" :model "Expression 1640XL" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0109" :status :good :comment "IEEE1394 untested
overseas version of the ES-8500" :model "Expression 1680" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x010e" :status :complete :comment "IEEE1394 untested
overseas version of the ES-2200" :model "Expression 1680 Pro" :interface "SCSI USB" :status :untested :comment "IEEE1394 option" :model "Expression 1680XL Pro" :interface "SCSI USB" :status :untested :model "Expression 10000XL" ; command spec :interface "USB" :usbid "0x04b8" "0x0129" :status :good :comment "network interface probably supported
IEEE1394 untested
overseas version of the ES-10000G" :model "Expression 10000XL Graphic Arts" :interface "USB IEEE1394" :status :untested :comment "network interface probably supported" :model "Expression 10000XL Photo" :interface "USB IEEE1394" :status :untested :comment "network interface probably supported" :model "Expression 11000XL" :interface "USB" :usbid "0x04b8" "0x014b" :status :good :comment "overseas version of the ES-G11000" :model "Expression 12000XL" :interface "USB" :usbid "0x04b8" "0x015b" :status :good :comment "overseas version of the DS-G20000" :model "F-3200" ; product spec (JP) :interface "USB IEEE1394" :usbid "0x04b8" "0x080a" :status :unsupported :comment "Film scanner" :model "F-3200 Photo" :interface "USB IEEE1394" :status :unsupported :model "FilmScan 200" :interface "SCSI" :status :minimal :comment "missing documentation" :model "GT-1500" :interface "USB" :usbid "0x04b8" "0x0133" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-2200" :interface "USB" :usbid "0x04b8" "0x0102" :status :unsupported :model "GT-2500" :interface "USB" :usbid "0x04b8" "0x012b" :status :good :comment "network interface probably supported
overseas version of the ES-H300" :model "GT-4000" :status :untested :model "GT-5000" :interface "parallel SCSI" :status :good :model "GT-5400" :interface "parallel" :status :good :model "GT-5500" :interface "SCSI" :scsi "EPSON" "SCANNER GT-5500" "processor" :status :good :model "GT-6000" :interface "SCSI Parport" :status :good :model "GT-6500" :interface "parallel" :status :good :comment "overseas version of the GT-5400" :model "GT-6600U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0103" :status :complete :model "GT-6700U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010c" :status :complete :model "GT-7000S" :interface "SCSI" :scsi "EPSON" "SCANNER GT-7000" "processor" :status :complete :model "GT-7000U" :interface "USB" :usbid "0x04b8" "0x0101" :status :complete :model "GT-7200U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-7300U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-7400U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0120" :status :unsupported :comment "supported by the snapscan backend" :model "GT-7600S" ; product spec (JP) :interface "SCSI" :status :complete :comment "SCSI version of the GT-7600U" :model "GT-7600U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "USB version of the GT-7600S" :model "GT-7600UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "GT-7600U with TPU option bundled" :model "GT-7700U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x010b" :status :complete :model "GT-8000" :interface "SCSI" :status :good :model "GT-8200U" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0110" :status :complete :model "GT-8200UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0110" :status :good :model "GT-8300UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011e" :status :complete :model "GT-8400UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :model "GT-8500" :status :untested :model "GT-8700" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :complete :model "GT-8700F" ; product spec (JP) :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :good :comment "GT-8700U with TPU option bundled" :model "GT-9000" :interface "parallel" :status :good :model "GT-9300UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x011b" :status :complete :model "GT-9400UF" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0116" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-9500" :interface "SCSI" :status :complete :model "GT-9600" :interface "SCSI" :status :complete :model "GT-9700F" ; product spec (JP) :interface "USB IEEE1394" :scsi "EPSON" "GT-9700" "processor" :usbid "0x04b8" "0x0112" :status :complete :model "GT-9800F" ; product spec (JP) :interface "USB IEEE1394" :scsi "EPSON" "GT-9800" "processor" :usbid "0x04b8" "0x011c" :status :complete :model "GT-10000" :interface "SCSI" :status :good :comment "overseas version of the ES-6000" :model "GT-10000+" ; command spec :interface "SCSI" :status :good :comment "IEEE1394 untested
overseas version of the ES-6000H" :model "GT-12000" :interface "SCSI" :status :untested :comment "overseas version of the ES-8000" :model "GT-15000" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x0126" :status :good :comment "IEEE1394 untested
overseas version of the ES-7000H" :model "GT-20000" :interface "USB Ethernet" :usbid "0x04b8" "0x0138" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
overseas version of the ES-H7200" :model "GT-30000" ; command spec :interface "SCSI" :status :good :comment "IEEE1394 untested
overseas version of the ES-9000H" :model "GT-D1000" :interface "USB" :usbid "0x04b8" "0x0133" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F500" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0121" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F520" :interface "USB" :usbid "0x04b8" "0x0122" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F550" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0121" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F570" :interface "USB" :usbid "0x04b8" "0x0122" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F600" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0118" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F650" :interface "USB" :usbid "0x04b8" "0x012d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F670" :interface "USB" :usbid "0x04b8" "0x012e" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F700" :interface "USB" :usbid "0x04b8" "0x012f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F720" :interface "USB" :usbid "0x04b8" "0x0131" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F730" :interface "USB" :usbid "0x04b8" "0x0142" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-F740" :interface "USB" :usbid "0x04b8" "0x014a" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S50" :interface "USB" :usbid "0x04b8" "0x0137" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S55" :interface "USB" :usbid "0x04b8" "0x0143" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S80" :interface "USB" :usbid "0x04b8" "0x0136" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S85" :interface "USB" :usbid "0x04b8" "0x0144" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S600" :interface "USB" :usbid "0x04b8" "0x012d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S620" :interface "USB" :usbid "0x04b8" "0x0131" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S630" :interface "USB" :usbid "0x04b8" "0x0142" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S640" :interface "USB" :usbid "0x04b8" "0x014a" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-S650" :interface "USB" :usbid "0x04b8" "0x013d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-X700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0128" :status :complete :comment "IEEE1394 untested" :model "GT-X750" :interface "USB" :usbid "0x04b8" "0x0119" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-X770" :interface "USB" :usbid "0x04b8" "0x0130" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-X800" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x012a" :status :complete :comment "film area guide mode not supported
IEEE1394 untested" :model "GT-X820" :interface "USB" :usbid "0x04b8" "0x013a" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-X830" :interface "USB" :usbid "0x04b8" "0x0153" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "GT-X900" :interface "USB" :scsi "EPSON" "GT-X900" "processor" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested" :model "GT-X970" :interface "USB" :usbid "0x04b8" "0x0135" :status :good :comment "IEEE1394 untested" :model "GT-X980" :interface "USB" :usbid "0x04b8" "0x0151" :status :good :model "K200 Series" :interface "USB" :usbid "0x04b8" "0x0871" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "K300 Series" :interface "USB" :usbid "0x04b8" "0x0872" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "L200 Series" :interface "USB" :usbid "0x04b8" "0x0873" :status :complete :comment "all-in-one" :model "L210 Series" :interface "USB" :usbid "0x04b8" "0x08a1" :status :complete :comment "all-in-one" :model "L350" :interface "USB" :usbid "0x04b8" "0x08a1" :status :complete :comment "all-in-one" :model "L351" :interface "USB" :usbid "0x04b8" "0x08a1" :status :complete :comment "all-in-one" :model "L355" :interface "USB" :usbid "0x04b8" "0x08a8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "L358" :interface "USB" :usbid "0x04b8" "0x08a8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "L380" :interface "USB" :usbid "0x04b8" "0x1120" :status :good :model "L495" :interface "USB Ethernet" :usbid "0x04b8" "0x1121" :status :good :model "L550 Series" :interface "USB" :usbid "0x04b8" "0x08a9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "L850 Series" :interface "USB" :usbid "0x04b8" "0x08ca" :status :complete :comment "all-in-one" :model "LP-7900CS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9000CCH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9000CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9000CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9500CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9500CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9500CH2" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9800CCH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-9800CCS" :status :untested :comment "business all-in-one; scanner is a ES-7000H" :model "LP-9800CFH" :status :untested :comment "business all-in-one; scanner is a ES-9000H" :model "LP-A500" :interface "USB Network" :usbid "0x04b8" "0x0815" :status :good :comment "network interface supported
business all-in-one" :model "LP-M5000" :interface "USB" :usbid "0x04b8" "0x0843" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M5300 Series" :interface "USB" :usbid "0x04b8" "0x0894" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M5500" :interface "USB" :usbid "0x04b8" "0x0817" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M5500F" :interface "USB" :usbid "0x04b8" "0x0817" :status :good :comment "network interface probably supported
business all-in-one
LP-M5500 with the fax option bundled" :model "LP-M5600" :interface "USB" :usbid "0x04b8" "0x0833" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M6000" :interface "USB" :usbid "0x04b8" "0x0834" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M8040" :interface "USB" :usbid "0x04b8" "0x08ad" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M8040A" :interface "USB" :usbid "0x04b8" "0x08ad" :status :good :comment "network interface probably supported
business all-in-one" :model "LP-M8040F" :interface "USB" :usbid "0x04b8" "0x08ad" :status :good :comment "network interface probably supported
business all-in-one" :model "M200 Series" :interface "USB" :usbid "0x04b8" "0x08aa" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME 200" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "ME 300" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "ME 320 Series" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "ME 330 Series" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "ME 340 Series" :interface "USB" :usbid "0x04b8" "0x0883" :status :complete :comment "all-in-one" :model "ME OFFICE 510" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "ME OFFICE 520 Series" :interface "USB" :usbid "0x04b8" "0x0865" :status :complete :comment "all-in-one" :model "ME OFFICE 535" :interface "USB" :usbid "0x04b8" "0x0881" :status :complete :comment "all-in-one
overseas version of the PX-404A" :model "ME OFFICE 560W Series" :interface "USB" :usbid "0x04b8" "0x0864" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME OFFICE 570W Series" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-434A" :model "ME Office 600F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME OFFICE 620F Series" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME OFFICE 650FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "ME Office 700FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "ME OFFICE 900WD Series" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "ME OFFICE 940FW Series" :interface "USB" :usbid "0x04b8" "0x0890" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME OFFICE 960FWD Series" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME-101" :interface "USB" :usbid "0x04b8" "0x08a0" :status :complete :comment "all-in-one" :model "ME-301" :interface "USB" :usbid "0x04b8" "0x0896" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "ME-303" :interface "USB" :usbid "0x04b8" "0x0897" :status :complete :comment "all-in-one
overseas version of the PX-405A" :model "ME-401" :interface "USB" :usbid "0x04b8" "0x0898" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-435A" :model "PM-A700" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0814" :status :good :comment "all-in-one" :model "PM-A750" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one" :model "PM-A820" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one" :model "PM-A840" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one" :model "PM-A840S" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "network interface probably supported
all-in-one" :model "PM-A850" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0806" :status :good :comment "all-in-one" :model "PM-A870" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one" :model "PM-A890" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one" :model "PM-A900" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x0810" :status :good :comment "all-in-one" :model "PM-A920" :interface "USB" :usbid "0x04b8" "0x082a" :status :good :comment "all-in-one" :model "PM-A940" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one" :model "PM-A950" :interface "USB" :usbid "0x04b8" "0x081d" :status :good :comment "all-in-one" :model "PM-A970" :interface "USB" :usbid "0x04b8" "0x0828" :status :good :comment "all-in-one" :model "PM-T960" :interface "USB" :usbid "0x04b8" "0x0836" :status :good :comment "all-in-one" :model "PM-T990" :interface "USB" :usbid "0x04b8" "0x0829" :status :good :comment "all-in-one
PM-A970 with network interface" :model "PX-045A" :interface "USB" :usbid "0x04b8" "0x0895" :status :complete :comment "all-in-one" :model "PX-046A" :interface "USB" :usbid "0x04b8" "0x08ae" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-047A" :interface "USB" :usbid "0x04b8" "0x08c0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-1600F" :interface "USB" :usbid "0x04b8" "0x0869" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-1700F" :interface "USB" :usbid "0x04b8" "0x087c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-401A" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one" :model "PX-402A" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one" :model "PX-403A" :interface "USB" :usbid "0x04b8" "0x087f" :status :complete :comment "all-in-one" :model "PX-404A" :interface "USB" :usbid "0x04b8" "0x0881" :status :complete :comment "all-in-one" :model "PX-405A" :interface "USB" :usbid "0x04b8" "0x0897" :status :complete :comment "all-in-one" :model "PX-434A" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-435A" :interface "USB" :usbid "0x04b8" "0x0898" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-436A" :interface "USB" :usbid "0x04b8" "0x08af" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-437A" :interface "USB" :usbid "0x04b8" "0x08bf" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-501A" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface probably supported
all-in-one" :model "PX-502A" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one" :model "PX-503A" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-504A" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-505F" :interface "USB" :usbid "0x04b8" "0x08a5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-535F" :interface "USB" :usbid "0x04b8" "0x08a6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-601F" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported" :model "PX-602F" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-603F" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-605F" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-673F" :interface "USB" :usbid "0x04b8" "0x086a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-675F" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-A550" ; product spec (JP) :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one" :model "PX-A620" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one" :model "PX-A640" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one" :model "PX-A650" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one" :model "PX-A720" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one" :model "PX-A740" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one" :model "PX-B750F" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-FA700" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one" :model "PX-M350F" :interface "USB" :usbid "0x04b8" "0x08d0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M5040F" :interface "USB" :usbid "0x04b8" "0x08b9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M5041F" :interface "USB" :usbid "0x04b8" "0x08b9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M650A" :interface "USB" :usbid "0x04b8" "0x08c3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M650F" :interface "USB" :usbid "0x04b8" "0x08c3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M740F" :interface "USB" :usbid "0x04b8" "0x08b8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M741F" :interface "USB" :usbid "0x04b8" "0x08b8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "PX-M840F" :interface "USB" :usbid "0x04b8" "0x08bd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Perfection 600" :interface "SCSI" :status :unsupported :comment "supported by the umax backend
rebadged UMAX Astra 1200S" :model "Perfection 610" ; command spec :interface "USB" :usbid "0x04b8" "0x0103" :status :basic :comment "overseas version of the GT-6600U" :model "Perfection 636S" :interface "SCSI" :scsi "EPSON" "Perfection636" "processor" :status :complete :comment "overseas version of the GT-7000S" :model "Perfection 636U" ; command spec :interface "USB" :usbid "0x04b8" "0x0101" :status :complete :comment "overseas version of the GT-7000U" :model "Perfection 640U" ; command spec :interface "USB" :usbid "0x04b8" "0x010c" :status :complete :comment "overseas version of the GT-6700U" :model "Perfection 660" :interface "USB" :usbid "0x04b8" "0x0114" :status :unsupported :comment "supported by the snapscan backend" :model "Perfection 1200S" ; command spec :interface "SCSI" :scsi "EPSON" "Perfection1200" "processor" :status :complete :comment "overseas version of the GT-7600S" :model "Perfection 1200U" ; command spec :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "overseas version of the GT-7600U" :model "Perfection 1200U PHOTO" :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :comment "Perfection 1200U with TPU option bundled
overseas version of the GT-7600UF" :model "Perfection 1240U" ; command spec :interface "USB" :usbid "0x04b8" "0x010b" :status :complete :comment "overseas version of the GT-7700U" :model "Perfection 1250" :interface "USB" :usbid "0x04b8" "0x010f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 1250 PHOTO" :interface "USB" :usbid "0x04b8" "0x010f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 1260" :interface "USB" :usbid "0x04b8" "0x011d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 1260 PHOTO" :interface "USB" :usbid "0x04b8" "0x011d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 1270" :interface "USB" :usbid "0x04b8" "0x0120" :status :unsupported :comment "supported by the snapscan backend
overseas version of the GT-7400" :model "Perfection 1600" :interface "SCSI" :status :unsupported :model "Perfection 1640SU" ; command spec :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :complete :comment "overseas version of the GT-8700" :model "Perfection 1640SU PHOTO" :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :good :comment "overseas version of the GT-8700F" :model "Perfection 1650" ; command spec :interface "USB" :usbid "0x04b8" "0x0110" :status :complete :comment "overseas version of the GT-8200U" :model "Perfection 1650 PHOTO" :interface "USB" :usbid "0x04b8" "0x0110" :status :good :comment "overseas version of the GT-8200UF" :model "Perfection 1660 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x011e" :status :complete :comment "overseas version of the GT-8300UF" :model "Perfection 1670" :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :comment "supported by the snapscan backend" :model "Perfection 1670 PHOTO" :interface "USB" :usbid "0x04b8" "0x011f" :status :unsupported :comment "supported by the snapscan backend
overseas version of the GT-8400UF" :model "Perfection 2400 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x011b" :status :complete :comment "overseas version of the GT-9300UF" :model "Perfection 2450 PHOTO" ; command spec :interface "USB IEEE1394" :scsi "EPSON" "GT-9700" "processor" :usbid "0x04b8" "0x0112" :status :complete :comment "overseas version of the GT-9700F" :model "Perfection 2480 PHOTO" :interface "USB" :usbid "0x04b8" "0x0121" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 2580 PHOTO" :interface "USB" :usbid "0x04b8" "0x0121" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 3170 PHOTO" :interface "USB" :usbid "0x04b8" "0x0116" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 3200 PHOTO" ; command spec :interface "USB IEEE1394" :scsi "EPSON" "GT-9800" "processor" :usbid "0x04b8" "0x011c" :status :complete :comment "overseas version of the GT-9800F" :model "Perfection 3490 PHOTO" :interface "USB" :usbid "0x04b8" "0x0122" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 3590 PHOTO" :interface "USB" :usbid "0x04b8" "0x0122" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 4180 PHOTO" :interface "USB" :usbid "0x04b8" "0x0118" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 4490 PHOTO" :interface "USB" :usbid "0x04b8" "0x0119" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection 4870 PHOTO" ; command spec :interface "USB" :usbid "0x04b8" "0x0128" :status :complete :comment "IEEE1394 untested
overseas version of the GT-X700" :model "Perfection 4990 PHOTO" :interface "USB" :usbid "0x04b8" "0x012a" :status :good :comment "film area guide mode not supported
IEEE1394 untested
overseas version of the GT-X800" :model "Perfection 4990 Pro" :interface "USB IEEE1394" :status :untested :comment "seems to be a 4990 PHOTO with additional software" :model "Perfection V10" :interface "USB" :usbid "0x04b8" "0x012d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V19" :interface "USB" :usbid "0x04b8" "0x013c" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V30" :interface "USB" :usbid "0x04b8" "0x0131" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V33" :interface "USB" :usbid "0x04b8" "0x0142" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V37" :interface "USB" :usbid "0x04b8" "0x014a" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V39" :interface "USB" :usbid "0x04b8" "0x013d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V100 Photo" :interface "USB" :usbid "0x04b8" "0x012d" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V200 Photo" :interface "USB" :usbid "0x04b8" "0x012e" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V300 Photo" :interface "USB" :usbid "0x04b8" "0x0131" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V330 Photo" :interface "USB" :usbid "0x04b8" "0x0142" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V370 Photo" :interface "USB" :usbid "0x04b8" "0x014a" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V350 Photo" :interface "USB" :usbid "0x04b8" "0x012f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V500 Photo" :interface "USB" :usbid "0x04b8" "0x0130" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V550 Photo" :interface "USB" :usbid "0x04b8" "0x013b" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V600 Photo" :interface "USB" :usbid "0x04b8" "0x013a" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Perfection V700 Photo" :interface "USB" :scsi "EPSON" "GT-X900" "processor" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested
overseas version of the GT-X900" :model "Perfection V750 Photo" :interface "USB" :scsi "EPSON" "GT-X900" "processor" :usbid "0x04b8" "0x012c" :status :good :comment "IEEE1394 untested
overseas version of the GT-X900" :model "Perfection V800 Photo" :interface "USB" :usbid "0x04b8" "0x0151" :status :good :model "Perfection V850 Pro" :interface "USB" :usbid "0x04b8" "0x0151" :status :good :comment "overseas version of the GT-X980" :model "Stylus CX1500" ; Australia :interface "USB" :usbid "0x04b8" "0x080c" :status :unsupported :comment "supported by the snapscan backend
all-in-one" :model "Stylus CX2800" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "Stylus CX2900" :interface "USB" :usbid "0x04b8" "0x0830" :status :good :comment "all-in-one" :model "Stylus CX3100" :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one
overseas version of the CC-570L" :model "Stylus CX3200" :interface "USB" :usbid "0x04b8" "0x0802" :status :good :comment "all-in-one
overseas version of the CC-570L" :model "Stylus CX3500" ; Australia :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one
overseas version of the PX-A550" :model "Stylus CX3600" ; UK :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one
overseas version of the PX-A550" :model "Stylus CX3650" ; France :interface "USB" :usbid "0x04b8" "0x080e" :status :good :comment "all-in-one" :model "Stylus CX3700" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus CX3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus CX3810" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus CX3900" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one
overseas version of the PX-A620" :model "Stylus CX4100" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus CX4200" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus CX4300" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus CX4400" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus CX4500" :interface "USB" :usbid "0x04b8" "0x080d" :status :good :comment "all-in-one" :model "Stylus CX4600" :interface "USB" :usbid "0x04b8" "0x080d" :status :good :comment "all-in-one" :model "Stylus CX4700" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus CX4800" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus CX4900" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus CX5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus CX5100" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one
overseas version of the CC-600PX" :model "Stylus CX5200" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :comment "all-in-one
overseas version of the CC-600PX" :model "Stylus CX5300" :interface "USB" :usbid "0x04b8" "0x0808" :status :good :comment "all-in-one" :model "Stylus CX5400" :interface "USB" :usbid "0x04b8" "0x0808" :status :good :comment "all-in-one" :model "Stylus CX5500" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus CX5600" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus CX5700F" :interface "USB" :usbid "0x04b8" "0x0821" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX5800F" :interface "USB" :usbid "0x04b8" "0x0821" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX5900" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus CX6000" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus CX6300" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :comment "all-in-one
mistakenly thinks its a PX-A650" :model "Stylus CX6400" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :comment "all-in-one
mistakenly thinks its a PX-A650" :model "Stylus CX6500" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :comment "all-in-one" :model "Stylus CX6600" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :comment "all-in-one" :model "Stylus CX6900F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX7000F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus CX7300" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus CX7400" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus CX7700" :interface "USB" :usbid "0x04b8" "0x081f" :status :good :comment "all-in-one" :model "Stylus CX7800" :interface "USB" :usbid "0x04b8" "0x081f" :status :good :comment "all-in-one" :model "Stylus CX8300" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus CX8400" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus CX9300F" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus CX9400Fax" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus DX3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :comment "all-in-one" :model "Stylus DX3850" :interface "USB" :status :good :comment "all-in-one" :model "Stylus DX4000" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :comment "all-in-one
overseas version of the PX-A620" :model "Stylus DX4200" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :comment "all-in-one" :model "Stylus DX4400" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "supported by the epkowa backend plus non-free interpreter" :model "Stylus DX4800" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
overseas version of the PX-A650" :model "Stylus DX4850" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :comment "all-in-one
DX4800 + card reader" :model "Stylus DX5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :comment "all-in-one" :model "Stylus DX6000" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :comment "all-in-one
overseas version of the PX-A720" :model "Stylus DX7000F" :interface "USB" :usbid "0x04b8" "0x0831" :status :unsupported :comment "may work with the snapscan backend
all-in-one with FAX" :model "Stylus DX7400" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :comment "all-in-one
overseas version of the PX-A640" :model "Stylus DX8400" :interface "USB" :usbid "0x04b8" "0x0839" :status :good :comment "all-in-one
overseas version of the PX-A740" :model "Stylus DX9400F" :interface "USB" :usbid "0x04b8" "0x083a" :status :good :comment "all-in-one
overseas version of the PX-FA700" :model "Stylus Office BX300F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX305F" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX305FW" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX305FW Plus" :interface "USB" :usbid "0x04b8" "0x0870" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX310FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "Stylus Office BX320FW Series" :interface "USB" :usbid "0x04b8" "0x085f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX535WD" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
overseas version of the PX-504A" :model "Stylus Office BX630FW Series" :interface "USB" :usbid "0x04b8" "0x0890" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX525WD" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "Stylus Office BX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "Stylus Office BX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-602F" :model "Stylus Office BX625FWD" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX635FWD" :interface "USB" :usbid "0x04b8" "0x088f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office BX925FWD" :interface "USB" :usbid "0x04b8" "0x086a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-673F" :model "Stylus Office BX935FWD" :interface "USB" :usbid "0x04b8" "0x0892" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office TX300F" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office TX320F Series" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office TX510FN Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "Stylus Office TX525FW" :interface "USB" :usbid "0x04b8" "0x085f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Office TX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "Stylus Office TX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-602F" :model "Stylus Office TX620FWD Series" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Photo PX650 Series" :interface "USB" :usbid "0x04b8" "0x0850" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-702A" :model "Stylus Photo PX660 Series" :interface "USB" :usbid "0x04b8" "0x0862" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-703A" :model "Stylus Photo PX700W" :interface "USB Network" :usbid "0x04b8" "0x0846" :status :good :comment "network interface supported
all-in-one
overseas version of the EP-801A" :model "Stylus Photo PX710W Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-802A" :model "Stylus Photo PX720WD Series" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-803A" :model "Stylus Photo PX730WD Series" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-804A" :model "Stylus Photo PX800FW" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one
overseas version of the EP-901A" :model "Stylus Photo PX810FW Series" :interface "USB" :usbid "0x04b8" "0x0853" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-902A" :model "Stylus Photo PX820FWD Series" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-903A" :model "Stylus Photo PX830FWD Series" :interface "USB" :usbid "0x04b8" "0x0879" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-904F" :model "Stylus Photo RX420" :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX425" ; France :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX430" ; Australia :interface "USB" :usbid "0x04b8" "0x080f" :status :good :comment "all-in-one" :model "Stylus Photo RX500" :interface "USB" :usbid "0x04b8" "0x0807" :status :good :comment "all-in-one" :model "Stylus Photo RX510" :interface "USB" :usbid "0x04b8" "0x0807" :status :good :comment "all-in-one" :model "Stylus Photo RX520" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one
overseas version of the PM-A750" :model "Stylus Photo RX530" :interface "USB" :usbid "0x04b8" "0x081a" :status :good :comment "all-in-one
overseas version of the PM-A750" :model "Stylus Photo RX560" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX585" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX580" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX595" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX590" :interface "USB" :usbid "0x04b8" "0x0827" :status :good :comment "all-in-one
overseas version of the PM-A820" :model "Stylus Photo RX600" :interface "USB" :usbid "0x04b8" "0x0806" :status :good :comment "all-in-one
overseas version of the PM-A850" :model "Stylus Photo RX610" :interface "USB" :usbid "0x04b8" "0x083c" :status :good :comment "all-in-one
overseas version of the PM-A840" :model "Stylus Photo RX620" :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one
overseas version of the PM-A870" :model "Stylus Photo RX630" :interface "USB" :usbid "0x04b8" "0x0811" :status :good :comment "all-in-one
overseas version of the PM-A870" :model "Stylus Photo RX640" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one
overseas version of the PM-A890" :model "Stylus Photo RX650" :interface "USB" :usbid "0x04b8" "0x081c" :status :good :comment "all-in-one
overseas version of the PM-A890" :model "Stylus Photo RX680" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX685" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX690" :interface "USB" :usbid "0x04b8" "0x0837" :status :good :comment "all-in-one
overseas version of the PM-A940" :model "Stylus Photo RX700" :interface "USB" :usbid "0x04b8" "0x0810" :status :good :comment "all-in-one
overseas version of the PM-A900" :model "Stylus Photo TX650 Series" :interface "USB" :usbid "0x04b8" "0x0850" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-702A" :model "Stylus Photo TX700W" :interface "USB" :usbid "0x04b8" "0x0846" :status :good :comment "network interface probably supported
all-in-one
overseas version of the EP-801A" :model "Stylus Photo TX710W Series" :interface "USB" :usbid "0x04b8" "0x0852" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-802A" :model "Stylus Photo TX720WD Series" :interface "USB" :usbid "0x04b8" "0x0861" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-803A" :model "Stylus Photo TX730WD Series" :interface "USB" :usbid "0x04b8" "0x087b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-804A" :model "Stylus Photo TX800FW" :interface "USB" :usbid "0x04b8" "0x0844" :status :good :comment "network interface probably supported
all-in-one
overseas version of the EP-901A" :model "Stylus Photo TX820FWD Series" :interface "USB" :usbid "0x04b8" "0x0860" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-903A" :model "Stylus NX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus NX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus NX125" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "Stylus NX127" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "Stylus NX130 Series" :interface "USB" :usbid "0x04b8" "0x0883" :status :complete :comment "all-in-one" :model "Stylus NX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus NX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus NX220 Series" :interface "USB" :usbid "0x04b8" "0x0865" :status :complete :comment "all-in-one" :model "Stylus NX230 Series" :interface "USB" :usbid "0x04b8" "0x0885" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX300 Series" :interface "USB" :usbid "0x04b8" "0x0848" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX330 Series" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-501A" :model "Stylus NX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface probably supported
all-in-one" :model "Stylus NX420 Series" :interface "USB" :usbid "0x04b8" "0x0864" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX430W Series" :interface "USB" :usbid "0x04b8" "0x0884" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus NX510 Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "Stylus NX530 Series" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-504A" :model "Stylus NX625" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "Stylus NX635" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
overseas version of the PX-504A" :model "Stylus SX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus SX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus SX125" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "Stylus SX130 Series" :interface "USB" :usbid "0x04b8" "0x0883" :status :complete :comment "all-in-one" :model "Stylus SX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus SX205" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus SX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus SX218" :interface "USB" :usbid "0x04b8" "0x0865" :status :complete :comment "all-in-one" :model "Stylus SX230 Series" :interface "USB" :usbid "0x04b8" "0x0881" :status :complete :comment "all-in-one
overseas version of the PX-404A" :model "Stylus SX235W" :interface "USB" :usbid "0x04b8" "0x0885" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus SX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-501A" :model "Stylus SX405" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "all-in-one" :model "Stylus SX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface probably supported
all-in-one" :model "Stylus SX420W Series" :interface "USB" :usbid "0x04b8" "0x0864" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus SX430W Series" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus SX440W Series" :interface "USB" :usbid "0x04b8" "0x0884" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus SX510W Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "Stylus SX525WD" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "Stylus SX535WD" :interface "USB" :usbid "0x04b8" "0x0891" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
overseas version of the PX-504A" :model "Stylus SX600FW" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "Stylus SX610FW Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-602F" :model "Stylus SX620FW Series" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus Scan 2000" :interface "USB" :usbid "0x04b8" "0x0105" :status :untested :comment "apparently mostly the same as the Stylus Scan 2500" :model "Stylus Scan 2500" :interface "USB" :usbid "0x04b8" "0x0106" :status :untested :comment "scanner is apparently a GT-7000" :model "Stylus TX100" :interface "USB" :usbid "0x04b8" "0x0841" :status :good :comment "all-in-one
overseas version of the PX-401A" :model "Stylus TX110 Series" :interface "USB" :usbid "0x04b8" "0x084d" :status :good :comment "all-in-one
overseas version of the PX-402A" :model "Stylus TX120 Series" :interface "USB" :usbid "0x04b8" "0x085c" :status :complete :comment "all-in-one" :model "Stylus TX130 Series" :interface "USB" :usbid "0x04b8" "0x0883" :status :complete :comment "all-in-one" :model "Stylus TX200" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX203" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX209" :interface "USB" :usbid "0x04b8" "0x0849" :status :good :comment "all-in-one" :model "Stylus TX210 Series" :interface "USB" :usbid "0x04b8" "0x084f" :status :good :comment "all-in-one" :model "Stylus TX220 Series" :interface "USB" :usbid "0x04b8" "0x0865" :status :complete :comment "all-in-one" :model "Stylus TX230W Series" :interface "USB" :usbid "0x04b8" "0x0885" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus TX235" :interface "USB" :usbid "0x04b8" "0x0881" :status :complete :comment "all-in-one
overseas version of the PX-404A" :model "Stylus TX400" :interface "USB" :usbid "0x04b8" "0x084a" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-501A" :model "Stylus TX410 Series" :interface "USB" :usbid "0x04b8" "0x0851" :status :good :comment "network interface probably supported
all-in-one" :model "Stylus TX420W Series" :interface "USB" :usbid "0x04b8" "0x0864" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus TX430W Series" :interface "USB" :usbid "0x04b8" "0x0880" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus TX435W" :interface "USB" :usbid "0x04b8" "0x0884" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "Stylus TX550W Series" :interface "USB" :usbid "0x04b8" "0x0856" :status :good :comment "all-in-one
overseas version of the PX-502A" :model "Stylus TX560WD Series" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "WF-2510 Series" :interface "USB" :usbid "0x04b8" "0x08a5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-505F" :model "WF-2520 Series" :interface "USB" :usbid "0x04b8" "0x08a6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-535F" :model "WF-2530 Series" :interface "USB" :usbid "0x04b8" "0x08a6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-535F" :model "WF-2540 Series" :interface "USB" :usbid "0x04b8" "0x08a6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-535F" :model "WF-2630 Series" :interface "USB" :usbid "0x04b8" "0x08c4" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-2650 Series" :interface "USB" :usbid "0x04b8" "0x08c3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-2660 Series" :interface "USB" :usbid "0x04b8" "0x08c3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-3520 Series" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-605F" :model "WF-3530 Series" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-675F" :model "WF-3540 Series" :interface "USB" :usbid "0x04b8" "0x0899" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-3620 Series" :interface "USB" :usbid "0x04b8" "0x08b8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M740F" :model "WF-3640 Series" :interface "USB" :usbid "0x04b8" "0x08b8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M741F" :model "WF-4630 Series" :interface "USB" :usbid "0x04b8" "0x08be" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-4640 Series" :interface "USB" :usbid "0x04b8" "0x08be" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-5620 Series" :interface "USB" :usbid "0x04b8" "0x08bd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M840F" :model "WF-5690 Series" :interface "USB" :usbid "0x04b8" "0x08bd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-7510 Series" :interface "USB" :usbid "0x04b8" "0x0869" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-1600F" :model "WF-7520 Series" :interface "USB" :usbid "0x04b8" "0x087c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-1700F" :model "WF-7610 Series" :interface "USB" :usbid "0x04b8" "0x08b9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M5040F" :model "WF-7620 Series" :interface "USB" :usbid "0x04b8" "0x08b9" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M5041F" :model "WF-M1560 Series" :interface "USB" :usbid "0x04b8" "0x08ab" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-M5690 Series" :interface "USB" :usbid "0x04b8" "0x08d0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-M350F" :model "WF-R4640 Series" :interface "USB" :usbid "0x04b8" "0x08cd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WF-R5690 Series" :interface "USB" :usbid "0x04b8" "0x08cd" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WP-4511" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4515" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WP-4521" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4525" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4530 Series" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4540 Series" :interface "USB" :usbid "0x04b8" "0x087d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-B750F" :model "WP-4590 Series" :interface "USB" :usbid "0x04b8" "0x087e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 310 Series" :interface "USB" :usbid "0x04b8" "0x0854" :status :good :comment "all-in-one" :model "WorkForce 320 Series" :interface "USB" :usbid "0x04b8" "0x0863" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
some models in the series have a built-in network interface
all-in-one" :model "WorkForce 435" :interface "USB" :usbid "0x04b8" "0x0870" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 500" :interface "USB" :usbid "0x04b8" "0x084c" :status :good :comment "all-in-one" :model "WorkForce 520 Series" :interface "USB" :usbid "0x04b8" "0x085f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 545" :interface "USB" :usbid "0x04b8" "0x0890" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 600" :interface "USB" :usbid "0x04b8" "0x0847" :status :good :comment "network interface probably supported
all-in-one
overseas version of the PX-601F" :model "WorkForce 610 Series" :interface "USB" :usbid "0x04b8" "0x0855" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-602F" :model "WorkForce 625" :interface "USB" :usbid "0x04b8" "0x085e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-503A" :model "WorkForce 630 Series" :interface "USB" :usbid "0x04b8" "0x085d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 645" :interface "USB" :usbid "0x04b8" "0x088f" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce 840 Series" :interface "USB" :usbid "0x04b8" "0x086a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-673F" :model "WorkForce 845" :interface "USB" :usbid "0x04b8" "0x0892" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "WorkForce K301" :interface "USB" :usbid "0x04b8" "0x0872" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-100 Series" :interface "USB" :usbid "0x04b8" "0x0895" :status :complete :comment "all-in-one
overseas version of the PX-045A" :model "XP-200 Series" :interface "USB" :usbid "0x04b8" "0x0896" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-211" :interface "USB" :usbid "0x04b8" "0x08ae" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-046A" :model "XP-212" :interface "USB" :usbid "0x04b8" "0x08ae" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-046A" :model "XP-215" :interface "USB" :usbid "0x04b8" "0x08ae" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-046A" :model "XP-225" :interface "USB" :usbid "0x04b8" "0x08c0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-047A" :model "XP-243 245 247 Series" :interface "USB" :usbid "0x04b8" "0x1116" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-255" :interface "USB" :usbid "0x04b8" "0x113d" :status :good :model "XP-300 Series" :interface "USB" :usbid "0x04b8" "0x0898" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-435A" :model "XP-310 Series" :interface "USB" :usbid "0x04b8" "0x08af" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-436A" :model "XP-320 Series" :interface "USB" :usbid "0x04b8" "0x08bf" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-437A" :model "XP-400 Series" :interface "USB" :usbid "0x04b8" "0x0898" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the PX-435A" :model "XP-410 Series" :interface "USB" :usbid "0x04b8" "0x08b0" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-420 Series" :interface "USB" :usbid "0x04b8" "0x08c1" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-427" :interface "USB" :usbid "0x04b8" "0x1116" :status :good :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-600 Series" :interface "USB" :usbid "0x04b8" "0x089e" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-775A" :model "XP-510 Series" :interface "USB" :usbid "0x04b8" "0x08b7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-706A" :model "XP-520 Series" :interface "USB" :usbid "0x04b8" "0x08c8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-777A" :model "XP-610 Series" :interface "USB" :usbid "0x04b8" "0x08b6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-776AB/EP-776AW" :model "XP-620 Series" :interface "USB" :usbid "0x04b8" "0x08c8" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-777A" :model "XP-700 Series" :interface "USB" :usbid "0x04b8" "0x089d" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one" :model "XP-710 Series" :interface "USB" :usbid "0x04b8" "0x08b5" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-806AB/EP-806AR/EP-806AW" :model "XP-720 Series" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-807AB/EP-807AR/EP-807AW" :model "XP-750 Series" :interface "USB" :usbid "0x04b8" "0x089c" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-805A/EP-805AR/EP-805AW" :model "XP-760 Series" :interface "USB" :usbid "0x04b8" "0x08c7" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-807AB/EP-807AR/EP-807AW" :model "XP-800 Series" :interface "USB" :usbid "0x04b8" "0x089b" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-905A" :model "XP-810 Series" :interface "USB" :usbid "0x04b8" "0x08b4" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-906F" :model "XP-820 Series" :interface "USB" :usbid "0x04b8" "0x08c6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-907F" :model "XP-850 Series" :interface "USB" :usbid "0x04b8" "0x089a" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-905F" :model "XP-860 Series" :interface "USB" :usbid "0x04b8" "0x08c6" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-907F" :model "XP-950 Series" :interface "USB" :usbid "0x04b8" "0x08b3" :status :complete :comment "network interface supported via DFSG non-free iscan-network-nt package
all-in-one
overseas version of the EP-976A3" :model "Epson ME 350" :interface "USB" :usbid "0x04b8" "0x088d" :status :good :model "WP-M4525, WP-M4521, PX-K751F, WP-M4595" :interface "USB" :usbid "0x04b8" "0x08a7" :status :good sane-backends-1.0.29/doc/descriptions/gphoto2.desc0000666000000000000000000000135313615534521016700 00000000000000;gphoto2 backend .desc file by Peter S. Fales :backend "gphoto2" ; name of backend :version "0.0 (unmaintained)" ; version of backend :manpage "sane-gphoto2" ; name of manpage (if it exists) :url "mailto:peter@fales-lorenz.net" ; backend's web page :devicetype :api ; start of a list of devices.... :desc "Multiple cameras supported by the gphoto2 libraries" :url "http://www.gphoto.org" ;:interface "USB, serial port" :comment "The long-term plan is to support all the cameras supported by the gphoto2 libraries (currently over 140 models). However, at this stage, only a handful of cameras are definitely known to work with SANE. Other cameras will probably work if the native file format is EXIF or JPEG. Testers welcome!" sane-backends-1.0.29/doc/descriptions/gt68xx.desc0000666000000000000000000002602513615534521016471 00000000000000:backend "gt68xx" :version "1.0-84 (unmaintained)" :manpage "sane-gt68xx" :url "http://www.meier-geinitz.de/sane/gt68xx-backend/" :comment "Only the USB scanners mentioned below are supported. For other Mustek BearPaws, look at the Plustek and the MA-1509 backend." :devicetype :scanner ; ----------------------------------------------------------------------------- :mfg "Artec/Ultima" :url "http://www.artecusa.com/" :model "Ultima 2000" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Works, only product id 0x4002 is supported" :model "Ultima 2000 e+" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Works, however 12 bit mode doesn't seem to be supported" ; ----------------------------------------------------------------------------- :mfg "Boeder" :model "Sm@rtScan Slim Edition" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Artec Ultima 2000" ; ----------------------------------------------------------------------------- :mfg "Fujitsu" :url "http://www.fujitsu.com/" :model "1200CUS" :interface "USB" :usbid "0x05d8" "0x4002" :status :basic :comment "Works, but is slow. Probably a Mustek BearPaw 2400 CU clone." ; ----------------------------------------------------------------------------- :mfg "Genius" :url "http://www.genius-kye.com/" :model "ColorPage Slim 1200" ;:url "unsupported/genius-colorpage-slim-1200.html" :interface "USB" :usbid "0x0458" "0x201e" :status :untested :comment "Untested but should work." :model "Colorpage SF600" :interface "USB" :usbid "0x0458" "0x2021" :status :basic :model "Colorpage Vivid3x" :interface "USB" :usbid "0x0458" "0x2011" :status :good :model "Colorpage Vivid3 V2" :interface "USB" :usbid "0x0458" "0x2011" :status :good :comment "Same as Colorpage Vivid3x" :model "Colorpage Vivid3xe" :interface "USB" :usbid "0x0458" "0x2017" :status :good :model "Colorpage Vivid4" :usbid "0x0458" "0x2014" :interface "USB" :status :good :model "Colorpage Vivid4x" :usbid "0x0458" "0x201b" :interface "USB" :status :good :model "Colorpage Vivid4xe" :usbid "0x0458" "0x201a" :interface "USB" :status :good :model "Colorpage Vivid 1200 X" :interface "USB" :usbid "0x0458" "0x201d" :status :good :model "Colorpage Vivid 1200 XE" :interface "USB" :usbid "0x0458" "0x201f" :status :good ; ----------------------------------------------------------------------------- :mfg "Googlegear" :model "2000" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Same as Artec Ultima 2000." ; ----------------------------------------------------------------------------- :mfg "Lexmark" :url "http://www.lexmark.com/" :model "X70" :interface "USB" :usbid "0x043d" "0x002d" :status :good :comment "Works, some resolutions fail at 16 bit" :model "X73" :interface "USB" :usbid "0x043d" "0x002d" :status :good :comment "Works, some resolutions fail at 16 bit, same as X70" ; ----------------------------------------------------------------------------- :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.com" :comment "Sold by Aldi and Tchibo." :model "MD 4394" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Product id 0x4002. If you have 0x4003, use artec_eplus48u backend." :model "MD/LT 9375" :interface "USB" :usbid "0x05d8" "0x4002" :status :untested :comment "Untested, but is reported to have the same ids as the Artec Ultima 2000. Please test." :model "MD/LT 9385" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Artec Ultima 2000" :model "LT 9452" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Mustek ScanExpress 1200 UB Plus" :model "MD 9458" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Artec Ultima 2000 (e+?)" ; ----------------------------------------------------------------------------- :mfg "Mustek" :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "BearPaw 1200 CS" :interface "USB" :usbid "0x055f" "0x021e" :status :good :model "BearPaw 1200 CU" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :model "BearPaw 1200 CU Plus" :interface "USB" :usbid "0x055f" "0x021b" :status :good :model "BearPaw 1200 CU Plus" :interface "USB" :usbid "0x055f" "0x021c" :status :good :model "BearPaw 1200 TA" :interface "USB" :usbid "0x055f" "0x021e" :status :good :comment "Transparency adapter supported" :model "BearPaw 1248 CU" :interface "USB" :usbid "0x055f" "0x021c" :status :good :comment "Seems to use the same ids as BearPaw 1200 CU Plus." :model "BearPaw 2400 CS" :interface "USB" :usbid "0x055f" "0x0218" :status :untested :comment "Probably works, reports are welcome" :model "BearPaw 2400 CS Plus" :interface "USB" :usbid "0x055f" "0x0219" :status :good :comment "Works, problems with 12/16 bit modes?" :model "BearPaw 2400 CU" :interface "USB" :usbid "0x05d8" "0x4002" :status :basic :comment "Works, but is slow" :model "BearPaw 2400 CU Plus" :interface "USB" :usbid "0x055f" "0x021d" :status :good :model "BearPaw 2400 TA" :interface "USB" :usbid "0x055f" "0x0218" :status :good :comment "Transparency adapter supported" :model "BearPaw 2400 TA Plus" :interface "USB" :usbid "0x055f" "0x0219" :status :good :comment "Transparency adapter supported" :model "BearPaw 2448 CS Plus" :interface "USB" :usbid "0x055f" "0x021a" :status :basic :comment "Slow. Same as 2448 TA Plus, but without TA." :model "BearPaw 2448 TA Plus" :interface "USB" :usbid "0x055f" "0x021a" :status :basic :comment "Slow. Transparency adapter supported. Slow. Brightness depends on resolution?" :model "Plug-n-Scan 2400 MT" :interface "USB" :usbid "0x055f" "0x0219" :status :good :comment "Works but is slow in high resolutions. Same as BearPaw 2400 TA Plus." :model "Plug-n-Scan 2400 M" :interface "USB" :usbid "0x055f" "0x0219" :status :good :comment "Works but is slow in high resolutions. Same as BearPaw 2400 CS Plus." :model "ScanExpress 1200 UB Plus" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :model "ScanExpress 1248 UB" :interface "USB" :usbid "0x055f" "0x021f" :status :complete :model "ScanExpress 2400 USB" :interface "USB" :usbid "0x05d8" "0x4002" :status :minimal :comment "Should be detected but may need some more work in the code. Testers welcome. Please contact me if you own this scanner." :model "ScanExpress A3 USB" :interface "USB" :usbid "0x055f" "0x0210" :status :basic :comment "Still some vertical stripes." :model "ScanMagic 1200 UB Plus" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Same as ScanExpress 1200 UB Plus" ; ----------------------------------------------------------------------------- :mfg "NeatReceipts" :model "Scanalizer Professional 2.5" :interface "USB" :usbid "0x07b3" "0x0412" :status :untested :comment "Similar to Plustek OpticSlim M12. Please tell us if this scanner works." :model "Mobile Scanner" :interface "USB" :usbid "0x07b3" "0x0462" :status :basic :comment "Similar to Plustek OpticSlim M12." ; ----------------------------------------------------------------------------- :mfg "Nortek" :model "MyScan 1200" :interface "USB" :usbid "0x07b3" "0x040b" :status :untested :comment "Untested. Please test. Similar to Plustek OpticPro S12?" ; ----------------------------------------------------------------------------- :mfg "Packard Bell" :model "Diamond 1200" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Mustek BearPaw 1200 (Plus)" :model "Diamond 1200 Plus" :interface "USB" :usbid "0x055f" "0x021c" :status :good :comment "Similar to Mustek BearPaw 1200 Plus" :model "Diamond 1200 Plus" :interface "USB" :usbid "0x055f" "0x021b" :status :good :comment "Similar to Mustek BearPaw 1200 Plus" :model "Diamond 2450" :interface "USB" :usbid "0x055f" "0x0219" :status :good ; ----------------------------------------------------------------------------- :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticPro 1248U" :interface "USB" :usbid "0x07b3" "0x0400" :status :good :model "OpticPro 1248U" :interface "USB" :usbid "0x07b3" "0x0401" :status :good :model "OpticPro U16B" :interface "USB" :usbid "0x07b3" "0x0402" :status :good :model "OpticPro U16B+" :interface "USB" :usbid "0x07b3" "0x0403" :status :good :model "OpticPro UT16B" :interface "USB" :usbid "0x07b3" "0x0403" :status :untested :comment "Probably works. Transparency adapter not supported yet. Please contact me if you own such a device. " :model "OpticPro S12" :interface "USB" :usbid "0x07b3" "0x040b" :status :good :comment "Product ID 0x040b only." :model "OpticPro S24" :interface "USB" :usbid "0x07b3" "0x040e" :status :good :comment "Product ID 0x040e only. Is reported to work." :model "OpticPro ST12" :interface "USB" :usbid "0x07b3" "0x040b" :status :untested :comment "Product ID 0x040b only. Needs testing. Transparency adapter completely untested. Please contact me if you own such a scanner." :model "OpticSlim 1200" :interface "USB" :usbid "0x07b3" "0x0413" :status :good :model "OpticSlim 2400" :interface "USB" :usbid "0x07b3" "0x0422" :status :good :comment "Works up to 1200 dpi." :model "OpticSlim 2400 plus" :interface "USB" :usbid "0x07b3" "0x0454" :status :good :comment "Same as OpticSlim 2400." :model "OpticSlim 500 plus" :interface "USB" :usbid "0x07b3" "0x046e" :status :good :comment "Need firmware from windows driver. Image is upside down because hardware in this model is upside down. Buttons not tested." :model "Iriscan Express 2" :interface "USB" :usbid "0x07b3" "0x045f" :status :complete :comment "Works up to 1200 dpi. Calibration with external calibration sheet supported" ; ----------------------------------------------------------------------------- :model "OpticSlim M12" :interface "USB" :usbid "0x07b3" "0x0412" :status :complete :comment "Works up to 1200 dpi. Calibration with external calibration sheet supported" ; ----------------------------------------------------------------------------- :mfg "RevScan" ;:url "" :model "19200i" :interface "USB" :usbid "0x07b3" "0x0400" :status :good :comment "Similar to Plustek OpticPro 1248U" ; ----------------------------------------------------------------------------- :mfg "Trust" :url "http://www.trust-site.com" :model "240TH Easy Webscan Gold" :interface "USB" :usbid "0x055f" "0x0218" :status :good :comment "Same as Mustek Bearpaw 2400 TA plus." :model "Compact Scan USB 19200" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Works, if you have vendor id 0x055f and product id 0x0006, use the mustek_usb backend instead, similar to Mustek ScanExpress 1200 UB (Plus)" :model "Direct WebScan 19200" :interface "USB" :usbid "0x055f" "0x021c" :status :good :comment "Same as Mustek BearPaw 1200 CU Plus (0x021c)." :model "Flat Scan USB 19200" :interface "USB" :usbid "0x05d8" "0x4002" :status :good :comment "Similar to Artec Ultima 2000" ; ----------------------------------------------------------------------------- :mfg "Visioneer" :url "http://www.visioneer.com/" :model "OneTouch 7300" :interface "USB" :usbid "0x04a7" "0x0444" :status :good :comment "Works upto 1200 dpi and 12 bits/color." ; ----------------------------------------------------------------------------- sane-backends-1.0.29/doc/descriptions/u12.desc0000666000000000000000000000246013615534521015725 00000000000000; ; SANE Backend description file for U12 backend ; :backend "u12" :version "0.02" :manpage "sane-u12" :devicetype :scanner ;* Plustek ********************************************************************************** :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticPro U12" :interface "USB" :usbid "0x07b3" "0x0001" :status :basic :comment "Note: Only devices with product ID 0x0001 are supported!" :model "OpticPro UT12" :interface "USB" :usbid "0x07b3" "0x0001" :status :basic :comment "Note: Only devices with product ID 0x0001 are supported!" :model "OpticPro 1212U" :interface "USB" :usbid "0x07b3" "0x0001" :status :basic ;* RevScan ********************************************************************************** :mfg "RevScan" :model "RevScan Orange R48Ti" :interface "USB" :usbid "0x07b3" "0x0001" :status :basic :comment "Rebadged Plustek OpticPro UT12" ;* Genius/KYE ******************************************************************************************* :mfg "Genius" :url "http://www.geniusnet.com.tw/" :model "ColorPage HR6 V1" :interface "USB" :usbid "0x0458" "0x2004" :status :basic :model "ColorPage Vivid III USB" :interface "USB" :usbid "0x07b3" "0x0001" :status :untested :comment "Note: Device has Plustek vendor and product ID (0x07b3/0x0001)" sane-backends-1.0.29/doc/descriptions/hp5590.desc0000666000000000000000000000321213615534521016244 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "hp5590" :version "1.0.5" :manpage "sane-hp5590" :devicetype :scanner :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "ScanJet 4500C" :interface "USB" :usbid "0x03f0" "0x1205" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives" :model "ScanJet 4570C" :interface "USB" :usbid "0x03f0" "0x1305" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives" :model "ScanJet 5500C" :interface "USB" :usbid "0x03f0" "0x1305" :status :untested :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/TMA slides/TMA negatives" :model "ScanJet 5550C" :interface "USB" :usbid "0x03f0" "0x1205" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives" :model "ScanJet 5590" :interface "USB" :usbid "0x03f0" "0x1705" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives" :model "ScanJet 7650" :interface "USB" :usbid "0x03f0" "0x1805" :status :complete :comment "Lineart/grayscale/color (24 bit), 100/200/300/600/1200/2400 DPI, flatbed/ADF/ADF duplex/TMA slides/TMA negatives" sane-backends-1.0.29/doc/descriptions/canon_dr.desc0000666000000000000000000002263613615534521017110 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon_dr" ; name of backend :url "http://www.thebility.com/canon/" :version "57" ; version of backend :manpage "sane-canon_dr" ; name of manpage (if it exists) :comment "Backend updated for SANE release 1.0.28, see sane-canon_dr manpage" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" ;================================================== :model "CR-25" :interface "USB" :usbid "0x1083" "0x161a" :status :untested :comment "Please test!" :model "CR-50" :interface "USB" ;:usbid "0x1083" "0x" :status :untested :comment "Please test!" :model "CR-55" :interface "USB" :usbid "0x1083" "0x160c" :status :untested :comment "Please test!" :model "CR-80" :interface "USB" ;:usbid "0x1083" "0x" :status :untested :comment "Please test!" :model "CR-135i" :interface "USB SCSI" :usbid "0x1083" "0x1639" :status :untested :comment "Please test!" :model "CR-180" :interface "USB SCSI" :usbid "0x04a9" "0x1602" :status :untested :comment "Please test!" :model "CR-180II" :interface "USB SCSI" :usbid "0x04a9" "0x1602" :status :untested :comment "Same as CR-180? Please test!" :model "CR-190i" :interface "USB SCSI" :usbid "0x1083" "0x162b" :status :untested :comment "Please test!" :model "DR-1210C" :interface "USB" :usbid "0x04a9" "0x2222" :status :untested :comment "Older version? Please test!" :model "DR-1210C" :interface "USB" :usbid "0x1083" "0x160f" :status :untested :comment "Later version? Please test!" :model "DR-2010C" :interface "USB" :usbid "0x1083" "0x161b" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions." :model "DR-2010M" :interface "USB" :status :complete :comment "DR-2010C with a different label, same USB IDs" :model "DR-2050C" :interface "USB" :usbid "0x04a9" "0x160a" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration." :model "DR-2050SP" :interface "USB" :usbid "0x04a9" "0x160a" :status :untested :comment "Same as DR-2050C? Please test!" :model "DR-2080C" :interface "USB SCSI" :usbid "0x04a9" "0x1601" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration" :model "DR-2510C" :interface "USB" :usbid "0x1083" "0x1617" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width, 300/600dpi horizontal. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration, other resolutions" :model "DR-2510M" :interface "USB" :status :untested :comment "Mac version of DR-2510C? Please test!" :model "DR-2580C" :interface "USB SCSI" :usbid "0x04a9" "0x1608" :status :complete :comment "Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration" :model "DR-3010C" :interface "USB" :usbid "0x1083" "0x161d" :status :good :comment "Minimal testing, settings copied from DR-2510C" :model "DR3020" :interface "SCSI" :status :untested :comment "Please test!" :model "DR-3020C" :interface "SCSI" :status :untested :comment "Please test!" :model "DR-3060" :interface "SCSI" :status :untested :comment "Please test!" :model "DR-3080C" :interface "SCSI" :status :untested :comment "Almost works, need to investigate traces from windows driver" :model "DR-3080CII" :interface "USB SCSI" :usbid "0x04a9" "0x1609" :status :untested :comment "Almost works, need to investigate traces from windows driver" :model "DR-4010C" :interface "USB" :usbid "0x1083" "0x1614" :status :good :comment "Binary/HT/Gray/Color, Simplex/Duplex working. Multistream unsupported." :model "DR4080U" :interface "USB" ;:usbid "0x1083" "0x1614" :status :untested :comment "Please test!" :model "DR-4580U" :interface "USB" ;:usbid "0x1083" "0x1614" :status :untested :comment "Please test!" :model "DR-5010C" :interface "USB" :usbid "0x04a9" "0x1606" :status :basic :comment "ADF and Duplex work, needs more testing" :model "DR-5020" :interface "SCSI" :status :good :comment "LineArt, Duplex working, cannot read buttons or screen?" :model "DR-5060F" :interface "SCSI" :status :basic :comment "Grayscale works, LineArt might" :model "DR-5080C" :interface "SCSI" :status :untested :comment "Please test!" :model "DR-6010C" :interface "USB SCSI" :usbid "0x1083" "0x1626" :status :untested :comment "Please test!" :model "DR-6030C" :interface "USB SCSI" :usbid "0x1083" "0x1638" :status :untested :comment "Please test!" :model "DR-6050C" :interface "USB SCSI" :usbid "0x1083" "0x1624" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode" :model "DR-6080" :interface "USB SCSI" :usbid "0x04a9" "0x1607" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported" :model "DR-7080C" :interface "USB SCSI" :usbid "0x04a9" "0x1604" :status :good :comment "ADF and flatbed work" :model "DR-7090C" :interface "USB SCSI" :usbid "0x1083" "0x1620" :status :good :comment "ADF and flatbed work" :model "DR-7550C" :interface "USB SCSI" :usbid "0x1083" "0x1623" :status :untested :comment "Assumed compatible with DR-6050C" :model "DR-7580" :interface "USB SCSI" :usbid "0x04a9" "0x160b" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported" :model "DR-9050C" :interface "USB SCSI" :usbid "0x1083" "0x1622" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray working. Can't wake from stand-by mode" :model "DR-9080C" :interface "USB SCSI" :usbid "0x04a9" "0x1603" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray/color, async mode, dropout-color, multifeed/staple detection, deskew, buttons and JPEG working. Imprinter, barcode, custom gamma and multistream unsupported" :model "DR-X10C" :interface "USB SCSI" :usbid "0x1083" "0x1618" :status :good :comment "Simplex, duplex, all resolutions, binary/ht/gray/color, async mode, dropout-color, multifeed/staple detection, deskew, autocrop working. Imprinter, barcode, custom gamma and multistream unsupported" :model "DR-C120" :interface "USB" :usbid "0x1083" "0x1651" :status :untested :model "DR-C125" :interface "USB" :usbid "0x1083" "0x1640" :status :good :model "DR-C130" :interface "USB" :usbid "0x1083" "0x164a" :status :untested :model "DR-C225" :interface "USB" :usbid "0x1083" "0x1658" :status :untested :comment "" :model "DR-F120" :interface "USB" :usbid "0x1083" "0x1654" :status :basic :comment "Flatbed not working. ADF working. Simplex+duplex, all resolutions <= 600, gray/color, calibration poor." :model "DR-G1100" :interface "USB" :usbid "0x1083" "0x1650" :status :good :model "DR-G1130" :interface "USB" :usbid "0x1083" "0x164f" :status :untested :model "DR-M140" :interface "USB" :usbid "0x1083" "0x163f" :status :good :model "DR-M160" :interface "USB" :usbid "0x1083" "0x163e" :status :good :model "DR-M160II" :interface "USB" ;:usbid "0x1083" "0x" :status :untested :model "DR-M1060" :interface "USB" :usbid "0x1083" "0x1657" :status :untested :model "P-150" :interface "USB" ;:usbid "0x1083" "0x162c" :status :untested :comment "Same as P-150M?" :model "P-150M" :interface "USB" :usbid "0x1083" "0x162c" :status :good :model "P-201" :interface "USB" :usbid "0x1083" "0x1652" :status :untested :model "DR-P208" :interface "USB" :usbid "0x1083" "0x164b" :status :untested :comment "Same as P-208?" :model "P-208" :interface "USB" :usbid "0x1083" "0x164c" :status :basic :comment "All modes and resolutions working, but calibration is poor." :model "P-208" :interface "USB" :usbid "0x1083" "0x164e" :status :basic :comment "This is the same device as the 0x164c P-208, but the mode switch on the scanner is in the wrong position, you must move the switch." :model "DR-P208II" :interface "USB" :usbid "0x1083" "0x165d" :status :untested :model "P-208II" :interface "USB" :usbid "0x1083" "0x165f" :status :untested :model "DR-P215" :interface "USB" :usbid "0x1083" "0x1641" :status :untested :comment "Same as P-215?" :model "P-215" :interface "USB" :usbid "0x1083" "0x1646" :status :basic :comment "All modes and resolutions working, but calibration is poor. Card reader slot not working." :model "P-215" :interface "USB" :usbid "0x1083" "0x1647" :status :basic :comment "This is the same device as the 0x1646 P-215, but the mode switch on the scanner is in the wrong position, you must move the switch." :model "DR-P215II" :interface "USB" :usbid "0x1083" "0x1659" :status :untested :model "P-215II" :interface "USB" :usbid "0x1083" "0x165b" :status :untested :model "FSU-201" :interface "USB" :usbid "0x1083" "0x1648" :status :untested sane-backends-1.0.29/doc/descriptions/pieusb.desc0000666000000000000000000000522613615534521016610 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "pieusb" ; name of backend :version "1.0 (unmaintained)" ; version of backend :new :no :manpage "sane-pieusb" ; name of manpage (if it exists) :url "https://github.com/kkaempf/sane-backends" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "PIE" :url "http://www.scanace.com" :model "PowerSlide 3600" :interface "USB" :usbid "0x05e3" "0x0142" :status :untested :comment "Identical to Reflecta DigitDia 3600" :model "PowerSlide 3650" :interface "USB" :usbid "0x05e3" "0x0142" :status :basic :comment "Identical to Reflecta DigitDia 4000" :model "PowerSlide 4000" :interface "USB" :usbid "0x05e3" "0x0142" :status :basic :comment "Identical to Reflecta DigitDia 5000" :model "PowerSlide 5000" :interface "USB" :usbid "0x05e3" "0x0142" :status :basic :comment "Identical to Reflecta DigitDia 6000" :mfg "Reflecta" :url "https://reflecta.de" :model "Reflecta ProScan 10T" :interface "USB" :usbid "0x05e3" "0x0145" :status :basic :model "Reflecta ProScan 7200" :interface "USB" :usbid "0x05e3" "0x0145" :status :good :comment "Similar to PrimeFilm 7250 scanner from Pacific Image Electronics" :model "CrystalScan 3600" :interface "USB" :usbid 0x05e3 0x0145 :status :basic :model "CrystalScan 7200" :interface "USB" :status :untested :model "Reflecta CrystalScan 7250" :interface "USB" :usbid "0x05e3" "0x0145" :status :basic :comment "Similar to PrimeFilm 7250 scanner from Pacific Image Electronics" :model "DigitDia 3600" :interface "USB" :usbid "0x05e3" "0x0142" :status :untested :comment "Identical to Pacific Image Electronics PowerSlide 3600 scanner" :model "DigitDia 4000" :interface "USB" :usbid "0x05e3" "0x0142" :status :basic :comment "Identical to Pacific Image Electronics PowerSlide 3650 scanner" :model "DigitDia 5000" :interface "USB" :usbid "0x05e3" "0x0142" :status :untested :comment "Identical to Pacific Image Electronics PowerSlide 4000 scanner" :model "Reflecta DigitDia 6000 Multiple Slide Scanner" :interface "USB" :usbid "0x05e3" "0x0142" :status :good :comment "Identical to Pacific Image Electronics PowerSlide 5000 scanner" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/sm3600.desc0000666000000000000000000000233413615534521016246 00000000000000; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "sm3600" ; name of backend :version "0.1 (unmaintained)" ; version of backend :manpage "sane-sm3600" ; name of manpage (if it exists) :url "http://sm3600.sourceforge.net/" ; backend's web page :devicetype :scanner ; start of a list of devices.... :mfg "Microtek" :url "http://www.microtek.com/" :model "ScanMaker 3600" :interface "USB" :usbid "0x05da" "0x40b3" :comment "works" :status :basic :model "ScanMaker 3600" :interface "USB" :usbid "0x05da" "0x40ca" :comment "works" :status :basic :model "ScanMaker 3600" :interface "USB" :usbid "0x05da" "0x40ff" :comment "works" :status :basic :model "ScanMaker 3700" :interface "USB" :usbid "0x05da" "0x40b8" :comment "works" :status :basic :model "ScanMaker 3700" :interface "USB" :usbid "0x05da" "0x40cb" :comment "works" :status :basic :model "ScanMaker 3750" :interface "USB" :usbid "0x05da" "0x40dd" :comment "works (told)" :status :basic sane-backends-1.0.29/doc/descriptions/niash.desc0000666000000000000000000000247613615534521016427 00000000000000; $Id$ ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "niash" :version "0.3 (unmaintained)" :manpage "sane-niash" :url "http://sourceforge.net/projects/hp3300backend" :devicetype :scanner :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "ScanJet 3300c" :interface "USB" :usbid "0x03f0" "0x0205" :status :complete :model "ScanJet 3400c" :interface "USB" :usbid "0x03f0" "0x0405" :comment "If you use Linux 2.6, version 2.6.8 or newer is necessary." :status :complete :model "ScanJet 4300c" :interface "USB" :usbid "0x03f0" "0x0305" :comment "If you use Linux 2.6, version 2.6.8 or newer is necessary." :status :complete :model "ScanJet 4300c/Silitek" :interface "USB" :usbid "0x047b" "0x1002" :comment "If you use Linux 2.6, version 2.6.8 or newer is necessary." :status :complete :mfg "Agfa" :url "http://www.agfa.com" :model "Snapscan Touch" :interface "USB" :usbid "0x06bd" "0x0100" :status :complete :mfg "Trust" :url "http://www.trust.com" :model "Office Scan USB 19200" :interface "USB" :usbid "0x047b" "0x1000" :status :complete sane-backends-1.0.29/doc/descriptions/avision.desc0000666000000000000000000003473213615534521016775 00000000000000; SANE Backend specification file ; ; THIS FILE IS GENERATED FROM THE "avision.c" FILE AUTOMATICALLY - DO NOT EDIT ; THIS FILE MANUALLY !!! ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; name of backend :backend "avision" ; version of backend :version "Build: 296 (unmaintained)" ;status: alpha, beta, stable, new ;:status :stable ; backend's web page :url "http://exactcode.com/site/open_source/saneavision/" ; name of manpage (if it exists) :manpage "sane-avision" :devicetype :scanner :mfg "Avision" :url "http://www.avision.com" :model "AV100CS" :interface "SCSI" :status :untested :model "AV100IIICS" :interface "SCSI" :status :untested :model "AV100S" :interface "SCSI" :status :untested :model "AV120" :interface "USB" :usbid "0x0638" "0x0a27" :comment "sheetfed scanner" :status :complete :model "AV121" :interface "USB" :usbid "0x0638" "0x0a3c" :comment "sheetfed scanner" :status :good :model "AV122" :interface "USB" :usbid "0x0638" "0x0a33" :comment "sheetfed duplex scanner" :status :good :model "AV122 C2" :interface "USB" :usbid "0x0638" "0x0a93" :comment "sheetfed duplex scanner" :status :good :model "AV210" :interface "USB" :usbid "0x0638" "0x0a24" :comment "sheetfed scanner" :status :complete :model "AV210" :interface "USB" :usbid "0x0638" "0x0a25" :comment "sheetfed scanner" :status :complete :model "AV210C2" :interface "USB" :usbid "0x0638" "0x0a3a" :comment "sheetfed scanner" :status :complete :model "AV210C2-G" :interface "USB" :usbid "0x0638" "0x0a2f" :comment "sheetfed scanner" :status :complete :model "AV210D2+" :interface "USB" :usbid "0x0638" "0x1a35" :comment "sheetfed scanner" :status :complete :model "AV220" :interface "USB" :usbid "0x0638" "0x0a23" :comment "duplex! sheetfed scanner" :status :complete :model "AV220C2" :interface "USB" :usbid "0x0638" "0x0a2a" :comment "duplex! sheetfed scanner" :status :complete :model "AV220D2" :interface "USB" :usbid "0x0638" "0x0a2b" :comment "duplex! sheetfed scanner" :status :basic :model "AV220D2" :interface "USB" :usbid "0x0638" "0x1a31" :comment "duplex! sheetfed scanner" :status :untested :model "AV220+" :interface "USB" :usbid "0x0638" "0x0a2c" :comment "duplex! sheetfed scanner" :status :complete :model "AV220C2-G" :interface "USB" :usbid "0x0638" "0x0a2d" :comment "duplex! sheetfed scanner" :status :complete :model "AV220C2-B" :interface "USB" :usbid "0x0638" "0x0a2e" :comment "duplex! sheetfed scanner" :status :complete :model "AV220-G" :interface "USB" :usbid "0x0638" "0x0a94" :comment "duplex! sheetfed scanner" :status :complete :model "AV240SC" :interface "SCSI" :status :untested :model "AV260CS" :interface "SCSI" :status :untested :model "AV360CS" :interface "SCSI" :status :untested :model "AV363CS" :interface "SCSI" :status :untested :model "AV420CS" :interface "SCSI" :status :untested :model "AV6120" :interface "SCSI" :status :untested :model "AV610" :interface "USB" :usbid "0x0638" "0x0a18" :status :good :model "AV600U Plus" :interface "USB" :usbid "0x0638" "0x0a18" :status :good :model "AV610C2" :interface "USB" :usbid "0x0638" "0x0a5e" :status :good :model "AM3000 Series" :interface "USB" :usbid "0x0638" "0x0a41" :comment "MFD" :status :basic :model "DS610CU Scancopier" :interface "USB" :usbid "0x0638" "0x0a16" :comment "1 pass, 600 dpi, A4" :status :good :model "AV620CS" :interface "SCSI" :comment "1 pass, 600 dpi" :status :complete :model "AV620CS Plus" :interface "SCSI" :comment "1 pass, 1200 dpi" :status :complete :model "AV630CS" :interface "SCSI" :comment "1 pass, 1200 dpi" :status :complete :model "AV630CSL" :interface "SCSI" :comment "1 pass, 1200 dpi" :status :untested :model "AV6240" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV600U" :interface "USB" :usbid "0x0638" "0x0a13" :comment "1 pass, 600 dpi" :status :good :model "AV660S" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV680S" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV690U" :interface "SCSI" :comment "1 pass, 2400 dpi" :status :untested :model "AV800S" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV810C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV820" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV820C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV820C Plus" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV830C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV830C Plus" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV880" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV880C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :untested :model "AV3200C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV3200SU" :interface "USB" :usbid "0x0638" "0x0a4e" :comment "1 pass, ??? dpi" :status :complete :model "AV3730SU" :interface "USB" :usbid "0x0638" "0x0a4f" :comment "1 pass, ??? dpi" :status :complete :model "AV3750SU" :interface "USB" :usbid "0x0638" "0x0a65" :comment "1 pass, ??? dpi" :status :complete :model "AV3800C" :interface "SCSI" :comment "1 pass, ??? dpi" :status :complete :model "AV3850SU" :interface "USB" :usbid "0x0638" "0x0a66" :comment "1 pass, ??? dpi" :status :complete :model "FB6000E" :interface "SCSI" :comment "1 pass, 1200 dpi, A3 - duplex! - zero edge!" :status :complete :model "FB6080E" :interface "USB" :usbid "0x0638" "0x0a82" :comment "1 pass, 1200 dpi, A3 - duplex! - zero edge!" :status :complete :model "FB2080E" :interface "USB" :usbid "0x0638" "0x0a84" :comment "1 pass, 600 dpi, zero-edge" ASIC 7 :status :basic :model "AV8000S" :interface "SCSI" :comment "1 pass, 1200 dpi, A3" :status :complete :model "AV8050U" :interface "USB" :usbid "0x0638" "0x0a4d" :comment "1 pass, 1200 dpi, A3 - duplex!" :status :complete :model "AV8300" :interface "USB" :usbid "0x0638" "0x0a40" :comment "1 pass, 1200 dpi, A3 - duplex!" :status :complete :model "AV8350" :interface "USB" :usbid "0x0638" "0x0a68" :comment "1 pass, 1200 dpi, A3 - duplex!" :status :complete :model "IT8300" :interface "USB" :usbid "0x0638" "0x0a61" :comment "1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors" :status :good :model "@V2500" :interface "USB" :usbid "0x0638" "0x0aa1" :status :untested :model "@V5100" :interface "USB" :usbid "0x0638" "0x0a45" :comment "1 pass, 1200 dpi, A3 - duplex!, LCD screen, paper sensors" :status :good :model "AVA3" :interface "SCSI" :comment "1 pass, 600 dpi, A3" :status :basic :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "ScanJet 5300C" :interface "USB" :usbid "0x03f0" "0x0701" :comment "1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi" :status :complete :model "ScanJet 5370C" :interface "USB" :usbid "0x03f0" "0x0701" :comment "1 pass, 2400 dpi - some FW revisions have x-axis image scaling problems over 1200 dpi" :status :good :model "ScanJet 7400c" :interface "USB" :usbid "0x03f0" "0x0801" :comment "1 pass, 2400 dpi - dual USB/SCSI interface" :status :good :model "ScanJet 7450c" :interface "USB" :usbid "0x03f0" "0x0801" :comment "1 pass, 2400 dpi - dual USB/SCSI interface" :status :good :model "ScanJet 7490c" :interface "USB" :usbid "0x03f0" "0x0801" :comment "1 pass, 1200 dpi - dual USB/SCSI interface" :status :good :model "ScanJet 8200" :interface "USB" :usbid "0x03f0" "0x0b01" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8250" :interface "USB" :usbid "0x03f0" "0x0b01" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8270" :interface "USB" :usbid "0x03f0" "0x3905" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8290" :interface "USB" :usbid "0x03f0" "0x0b01" :comment "1 pass, 4800 (?) dpi - USB 2.0 and SCSI - only SCSI tested so far" :status :good :model "ScanJet 8300" :interface "USB" :usbid "0x03f0" "0x3805" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8350" :interface "USB" :usbid "0x03f0" "0x3805" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :model "ScanJet 8390" :interface "USB" :usbid "0x03f0" "0x3805" :comment "1 pass, 4800 (?) dpi - USB 2.0" :status :good :mfg "Minolta" :url "http://www.minolta.com" :model "Dimage Scan Dual I" :interface "SCSI" :status :basic :model "Scan Multi Pro" :interface "SCSI" :status :untested :model "Dimage Scan Dual II" :interface "USB" :usbid "0x0638" "0x026a" :comment "1 pass, film-scanner" :status :good :model "Elite II" :interface "USB" :usbid "0x0686" "0x4004" :comment "1 pass, film-scanner" :status :untested :model "Dimage Scan Dual III" :interface "USB" :usbid "0x0686" "0x400d" :comment "1 pass, film-scanner" :status :good :model "Dimage Scan Elite 5400" :interface "USB" :usbid "0x0686" "0x400e" :comment "1 pass, film-scanner" :status :good :mfg "Minolta-QMS" :model "SC-110" :interface "USB" :usbid "0x0638" "0x0a15" :status :untested :model "SC-215" :interface "USB" :usbid "0x0638" "0x0a16" :status :good :mfg "Mitsubishi" :model "MCA-ADFC" :interface "SCSI" :status :untested :model "S1200C" :interface "SCSI" :status :untested :model "S600C" :interface "SCSI" :status :untested :model "SS600" :interface "SCSI" :status :good :mfg "Fujitsu" :url "http://www.fujitsu.com" :model "ScanPartner" :interface "SCSI" :status :untested :model "ScanPartner 10" :interface "SCSI" :status :untested :model "ScanPartner 10C" :interface "SCSI" :status :untested :model "ScanPartner 15C" :interface "SCSI" :status :untested :model "ScanPartner 300C" :interface "SCSI" :status :untested :model "ScanPartner 600C" :interface "SCSI" :status :untested :model "ScanPartner 620C" :interface "SCSI" :status :good :model "ScanPartner Jr" :interface "SCSI" :status :untested :model "ScanStation" :interface "SCSI" :status :untested :model "fi-4010CU" :interface "USB" :usbid "0x04c5" "0x1029" :status :untested :model "fi-5015C" :interface "USB" :usbid "0x04c5" "0x10ef" :status :good :mfg "Kodak" :url "http://www.kodak.com" :model "i30" :interface "USB" :usbid "0x040a" "0x6001" :status :untested :model "i40" :interface "USB" :usbid "0x040a" "0x6002" :status :basic :model "i50" :interface "USB" :usbid "0x040a" "0x6003" :status :untested :model "i55" :interface "USB" :usbid "0x040a" "0x6003" :status :untested :model "i60" :interface "USB" :usbid "0x040a" "0x6004" :status :untested :model "i65" :interface "USB" :usbid "0x040a" "0x6004" :status :untested :model "i80" :interface "USB" :usbid "0x040a" "0x6005" :status :good :mfg "iVina" :model "1200U" :interface "USB" :usbid "0x0638" "0x0268" :status :untested :mfg "Visioneer" :model "Strobe XP 450" :interface "USB" :usbid "0x04a7" "0x0424" :comment "sheetfed scanner" :status :complete :model "Strobe XP 450-G" :interface "USB" :usbid "0x04a7" "0x0491" :comment "sheetfed scanner" :status :complete :model "Strobe XP 470" :interface "USB" :usbid "0x04a7" "0x0479" :comment "sheetfed scanner" :status :complete :model "Strobe XP 470-G" :interface "USB" :usbid "0x04a7" "0x048f" :comment "sheetfed scanner" :status :complete :model "9320" :interface "USB" :usbid "0x04a7" "0x0420" :comment "sheetfed scanner" :status :complete :model "9450" :interface "USB" :usbid "0x04a7" "0x0421" :comment "sheetfed scanner" :status :complete :model "9450-G" :interface "USB" :usbid "0x04a7" "0x047a" :comment "sheetfed scanner" :status :complete :model "9550" :interface "USB" :usbid "0x04a7" "0x0422" :comment "sheetfed scanner" :status :complete :model "9650" :interface "USB" :usbid "0x04a7" "0x0390" :comment "sheetfed scanner" :status :complete :model "9650-G" :interface "USB" :usbid "0x04a7" "0x047b" :comment "sheetfed scanner" :status :complete :model "9750" :interface "USB" :usbid "0x04a7" "0x0423" :comment "sheetfed scanner" :status :complete :model "9750-G" :interface "USB" :usbid "0x04a7" "0x0493" :comment "sheetfed scanner" :status :complete :model "Patriot 430" :interface "USB" :usbid "0x04a7" "0x0497" :comment "sheetfed scanner" :status :complete :model "Patriot 470" :interface "USB" :usbid "0x04a7" "0x048f" :comment "sheetfed scanner" :status :complete :model "Patriot 680" :interface "USB" :usbid "0x04a7" "0x0498" :comment "sheetfed scanner" :status :complete :model "Patriot 780" :interface "USB" :usbid "0x04a7" "0x0499" :comment "sheetfed scanner" :status :complete :mfg "Xerox" :model "DocuMate150" :interface "USB" :usbid "0x04a7" "0x049c" :status :good :model "DocuMate152" :interface "USB" :usbid "0x04a7" "0x0477" :status :good :model "DocuMate162" :interface "USB" :usbid "0x04a7" "0x049d" :status :good :model "DocuMate250" :interface "USB" :usbid "0x04a7" "0x0448" :status :good :model "DocuMate250-G" :interface "USB" :usbid "0x04a7" "0x0490" :status :good :model "DocuMate252" :interface "USB" :usbid "0x04a7" "0x0449" :status :good :model "DocuMate252-G" :interface "USB" :usbid "0x04a7" "0x048c" :status :good :model "DocuMate232" :interface "USB" :usbid "0x04a7" "0x0476" :status :good :model "DocuMate262" :interface "USB" :usbid "0x04a7" "0x044c" :status :good :model "DocuMate262-G" :interface "USB" :usbid "0x04a7" "0x048d" :status :good :model "DocuMate262i" :interface "USB" :usbid "0x04a7" "0x04a7" :status :good :model "DocuMate272" :interface "USB" :usbid "0x04a7" "0x0475" :status :untested :model "DocuMate272-G" :interface "USB" :usbid "0x04a7" "0x048e" :status :untested :model "DocuMate510" :interface "USB" :usbid "0x04a7" "0x0446" :status :untested :model "DocuMate512" :interface "USB" :usbid "0x04a7" "0x0495" :status :untested :model "DocuMate510-G" :interface "USB" :usbid "0x04a7" "0x047c" :status :untested :model "DocuMate520" :interface "USB" :usbid "0x04a7" "0x0447" :status :untested :model "DocuMate520-G" :interface "USB" :usbid "0x04a7" "0x0492" :status :untested :model "DocuMate632" :interface "USB" :usbid "0x04a7" "0x0498" :status :untested :model "DocuMate752" :interface "USB" :usbid "0x04a7" "0x0478" :status :untested :model "DocuMate752" :interface "USB" :usbid "0x04a7" "0x049a" :status :untested :mfg "OKI" :model "S700 Scancopier" :interface "USB" :usbid "0x0638" "0x0a16" :comment "1 pass, 600 dpi, A4" :status :good :mfg "Bell+Howell" :model "2000F" :interface "SCSI" :comment "1 pass, ??? dpi, A4" :status :basic :mfg "Kyocera" :model "FS-1016MFP" :interface "USB" :usbid "0x0482" "0x0335" :comment "1 pass, ??? dpi, A4" :status :untested sane-backends-1.0.29/doc/descriptions/dll.desc0000666000000000000000000000032213615534521016064 00000000000000:backend "dll" ; name of backend :version "1.0.13 (unmaintained)" :manpage "sane-dll" :url "mailto:henning@meier-geinitz.de" :devicetype :meta :desc "Dynamic loading of shared-library backends." sane-backends-1.0.29/doc/descriptions/hpsj5s.desc0000666000000000000000000000225713615534521016536 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hpsj5s" ; name of backend :version "0.03 (unmaintained)" ; version of backend ;:status :alpha ; :alpha, :beta, :stable, :new :manpage "sane-hpsj5s" ; name of manpage (if it exists) :url "http://hpsj5s.sourceforge.net/" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "ScanJet 5s" ; name models for above-specified mfg. :interface "Parport (EPP)" :comment "Requires libieee1284 library. Only gray mode." :status :minimal ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/teco1.desc0000666000000000000000000000501213615534521016325 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "teco1" ; name of backend :version "1.0-10 (unmaintained)" ; version of backend :manpage "sane-teco1" ; name of manpage (if it exists) :url "http://www.zago.net/sane/#teco" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Relisys" :url "http://www.relisys.com/" :url "http://www.tecoimage.com.tw/" :model "RELI 2412" :interface "SCSI" :comment "sub model VM3530+" :status :complete :model "AVEC 2400" :interface "SCSI" :comment "sub model VM3520" :status :complete :model "RELI 4830" :interface "SCSI" :comment "sub model VM4542" :status :good :model "AVEC 2412" :comment "sub model VM3520+" :interface "SCSI" :status :complete :model "AVEC 4800" :comment "sub model VM4530" :interface "SCSI" :status :untested :model "AVEC 4816" :comment "sub model VM4530+" :interface "SCSI" :status :untested :model "RELI DS6" :comment "sub model VM3420" :interface "SCSI" :status :untested :model "RELI DS15" :comment "sub model VM3440" :interface "SCSI" :status :untested :model "RELI 2400" :comment "sub model VM3530" :interface "SCSI" :status :untested :model "RELI 4816" :comment "sub model VM4540" :interface "SCSI" :status :complete :model "RELI 9600" :comment "sub model VM6530" :interface "SCSI" :status :untested :model "RELI 9612" :comment "sub model VM6530*" :interface "SCSI" :status :untested :model "RELI 9624" :comment "sub model VM6530+" :interface "SCSI" :status :untested :model "RELI 9630" :comment "sub model VM6540" :interface "SCSI" :status :untested :mfg "Actown" :model "ACT Scan I 30" :comment "sub model VM3520A" :interface "SCSI" :status :untested :mfg "Dextra" :model "DF-600P" :comment "sub model VM3510" :interface "SCSI" :status :good :model "DF-1200T+" :comment "sub model VM3530+" :interface "SCSI" :status :untested :model "DF-4830T" :comment "sub model VM4542" :interface "SCSI" :status :untested :model "DF-9624" :comment "sub model VM6530+" :interface "SCSI" :status :untested ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/apple.desc0000666000000000000000000000161113615534521016414 00000000000000;Apple backend .desc file by Milon Firikis. :backend "apple" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-apple" ; name of manpage (if it exists) ;:url "http://no.www.page.yet/" ; backend's web page :devicetype :scanner ; start of a list of devices.... :mfg "Apple" :url "http://developer.apple.com/" :model "Apple Scanner" :interface "SCSI" :status :good ; :alpha, :beta, :stable, :new :comment "4bit, 16 shades of gray" :model "OneScanner" :interface "SCSI" :comment "8bit, 256 shades of gray. The backend needs work especially in the quantization code but it may work." :status :basic ; :alpha, :beta, :stable, :new :model "Color OneScanner" :interface "SCSI" :status :minimal ; :alpha, :beta, :stable, :new :comment "truecolor (needs much work) but it scans in non color modes." sane-backends-1.0.29/doc/descriptions/hs2p.desc0000666000000000000000000000347013615534521016174 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hs2p" ; name of backend :url "http://www.acjlaw.net:8080/~jeremy/Ricoh/" :version "1.00 (unmaintained)" ; version of backend ; :manpage "sane-hs2p" ; name of manpage (if it exists) :comment "This backend has been tested with the IS450DE (Duplex/Endorser). All major functions necessary for scanning are supported. This backend should work with all Ricoh scanners in the IS450 family as well as the IS420 series, but the IS420 has not yet been tested. Features provided by the optional Image Processing Unit (IPU) are not yet integrated into the backend, as my scanner lacks the IPU." :devicetype :scanner :mfg "Ricoh" ; name a manufacturer :url "http://www.ricoh.com/" :model "IS450" ; name models for above-specified mfg. :interface "SCSI" :status :complete :comment "All major scanning-related features are supported (except for IPU). Certain non-scanning features, such as those related to scanner maintenance, are not supported. Such features would be better implemented in a separate stand-alone tool. For instance, if you replace the ADF Unit, you must recalibrate the scanner optics using a Ricoh Test Sheet and reset the E^2PROM registers. Reports are welcome." :model "IS-410" :interface "SCSI" :status :untested :comment "Untested, please report!" :model "IS-420" :interface "SCSI" :status :untested :comment "Untested, please report!" :model "IS-430" :interface "SCSI" :status :untested :comment "Untested, please report!" sane-backends-1.0.29/doc/descriptions/kodak.desc0000666000000000000000000000656213615534521016416 00000000000000:backend "kodak" :url "http://www.thebility.com/kodak/" :version "7" :manpage "sane-kodak" :comment "New backend for SANE release 1.0.21, see sane-kodak manpage" :devicetype :scanner :mfg "Kodak" :url "http://www.kodak.com/" ;====================================== ; workgroup machines, old :model "Scanner 1500" :interface "SCSI" :status :untested :comment "Please test!" ;====================================== ; departmental machines, old :model "Scanner 2500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 3500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 3510" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 3520" :interface "SCSI" :status :untested :comment "Please test!" :model "Color Scanner 3590C" :interface "SCSI" :status :untested :comment "Please test!" :model "Color Scanner 4500" :interface "SCSI" :status :untested :comment "Please test!" ;====================================== ; departmental machines, recent :model "i150 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i160 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i250 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i260 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i280 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" ;====================================== ; production machines, old :model "Scanner 900" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 923" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 5500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 7500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 7520" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 9500" :interface "SCSI" :status :untested :comment "Please test!" :model "Scanner 9520" :interface "SCSI" :status :untested :comment "Please test!" ;====================================== ; production machines, recent :model "i610 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i620 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i640 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i660 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i730 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i750 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i780 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i810 Scanner" :interface "SCSI" :status :untested :comment "Please test!" :model "i820 Scanner" :interface "SCSI" :status :untested :comment "Please test!" :model "i830 Scanner" :interface "SCSI" :status :untested :comment "Please test!" :model "i840 Scanner" :interface "SCSI" :status :untested :comment "Please test!" :model "i1840 Scanner" :interface "IEEE-1394" :status :untested :comment "Please test!" :model "i1860 Scanner" :interface "IEEE-1394" :status :basic :comment "Uncompressed B&W, Gray and Color, some automatic features supported" :model "s1740" :interface "SCSI" :status :untested :comment "Please test!" sane-backends-1.0.29/doc/descriptions/mustek_usb2.desc0000666000000000000000000000064413615534521017563 00000000000000:backend "mustek_usb2" :version "1.0-10 (unmaintained)" :manpage "sane-mustek_usb2" :url "http://www.meier-geinitz.de/sane/mustek_usb2-backend/" :comment "Only BearPaw 2448TA Pro is supported at the moment" :devicetype :scanner :mfg "Mustek" :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "BearPaw 2448TA Pro" :interface "USB" :usbid "0x055f" "0x0409" :status :good sane-backends-1.0.29/doc/descriptions/kvs40xx.desc0000666000000000000000000000171213615534521016644 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "kvs40xx" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-kvs40xx" ; name of manpage (if it exists) :comment "New backend for SANE release 1.0.23, see sane-kvs40xx manpage" :devicetype :scanner ; start of a list of devices.... :mfg "Panasonic" ; name a manufacturer :url "http://www.panasonic.com/" :model "KV-S4065C" :interface "USB" :usbid "0x04da" "0x100d" :status :untested :model "KV-S4085C" :interface "USB" :usbid "0x04da" "0x100c" :status :untested :model "KV-S7075C" :interface "USB" :usbid "0x04da" "0x100e" :status :untested sane-backends-1.0.29/doc/descriptions/tamarack.desc0000666000000000000000000000205513615534521017101 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "tamarack" ; name of backend :version "unmaintained" ; version of backend ; :manpage "sane-tamarack" ; name of manpage (if it exists) :devicetype :scanner :mfg "Tamarack" ; name a manufacturer ;:url "http://www.tamarack.net/" ; doesn't exist anymore? :model "Artiscan 6000C" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "3 pass, 300 DPI" :model "Artiscan 8000C" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "3 pass, 400 DPI" :model "Artiscan 12000C" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "3 pass, 600 DPI" sane-backends-1.0.29/doc/descriptions/dell1600n_net.desc0000666000000000000000000000054013615534521017566 00000000000000; ; dell1600n_net backend ; Jon Chambers , 2006-05-29 ; :backend "dell1600n_net" :version "unmaintained" :devicetype :scanner :mfg "Dell" :url "http://www.dell.com/" :model "1600n" :interface "Ethernet USB" :usbid "0x413c" "0x5250" :status :basic :comment "Supports colour and monochrome scans over ethernet (USB not supported)" sane-backends-1.0.29/doc/descriptions/ibm.desc0000666000000000000000000000241013615534521016060 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "ibm" ; name of backend :url "http://www.meier-geinitz.de/sane/ibm-backend/" :version "1.0-4 (unmaintained)" ; version of backend ; :manpage "sane-ibm" ; name of manpage (if it exists) :comment "This backend has had only limited testing. It needs more work especially for the Ricoh scanners. Patches are welcome." :devicetype :scanner :mfg "IBM" ; name a manufacturer :url "http://www.ibm.com/" :model "2456" ; name models for above-specified mfg. :interface "SCSI" :status :basic :comment "Was reported to work long time ago. Reports are welcome." :mfg "Ricoh" ; name a manufacturer :model "IS-410" :interface "SCSI" :status :untested :comment "Untested, please report!" :model "IS-420" :interface "SCSI" :status :basic :comment "Works at least in flatbed mode." :model "IS-430" :interface "SCSI" :status :untested :comment "Untested, please report!" sane-backends-1.0.29/doc/descriptions/hp5400.desc0000666000000000000000000000303113615534521016231 00000000000000; Copied from hp3300 testtools - Martijn van Oosterhout 22/02/2003 ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hp5400" ; name of backend :version "1.0-2 (unmaintained)" ; version of backend :manpage "sane-hp5400" ; name of manpage (if it exists) :url "http://sourceforge.net/projects/hp5400backend" ; backend's web page :comment "HP5400 and HP5470 scanners. Prototype backend available" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com" :model "ScanJet 5400c" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port" or "Propretiary". :usbid "0x03f0" "0x1005"" :status :basic :model "ScanJet 5470c" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: :usbid "0x03f0" "0x1105" :status :basic :model "ScanJet 5490c" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: :usbid "0x03f0" "0x1105" :status :basic ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/rts8891.desc0000666000000000000000000000306013615534521016455 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "rts8891" ; name of backend :version "1.0-0 (unmaintained)" ; version of backend (or "unmaintained") :manpage "sane-rts8891" ; name of manpage (if it exists) :url "http://stef.dev.free.fr/sane/rts8891/index.html" ; backend's web page :comment "This backend supports Realtek RTS8891 ASIC bases scanners." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "UMAX" ; name a manufacturer :url "http://www.umax.com.tw/" ; manufacturer's URL :model "Astra 4400" :interface "USB" :usbid "0x1606" "0x0070" :status :good :comment "Supports 75, 150, 300, 600 and 1200 dpi" :model "Astra 4450" :interface "USB" :usbid "0x1606" "0x0070" :status :untested :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "scanjet 4470c" :interface "USB" :usbid "0x03f0" "0x0805" :status :good :comment "re-branded Astra 4400" :model "scanjet 4400c" :interface "USB" :usbid "0x03f0" "0x0705" :status :good :comment "exists with 2 different sensors of which only one works" sane-backends-1.0.29/doc/descriptions/mustek_usb.desc0000666000000000000000000000173313615534521017501 00000000000000:backend "mustek_usb" :version "1.0-18 (unmaintained)" :manpage "sane-mustek_usb" :url "http://www.meier-geinitz.de/sane/mustek_usb-backend/" :comment "Only the USB scanners mentioned below are supported. For BearPaws, look at the Plustek, MA-1509, and gt68xx backends." :devicetype :scanner :mfg "Mustek" :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "ScanExpress 600 CU" :interface "USB" :usbid "0x055f" "0x0002" :status :complete :model "ScanExpress 1200 CU" :interface "USB" :usbid "0x055f" "0x0001" :status :complete :model "ScanExpress 1200 CU Plus" :interface "USB" :usbid "0x055f" "0x0008" :status :complete :model "ScanExpress 1200 UB" :interface "USB" :usbid "0x055f" "0x0006" :status :complete :comment "For the UB Plus, see gt68xx backend" :mfg "Trust" :url "http://www.trust-site.com" :model "Compact Scan USB 19200" :interface "USB" :usbid "0x055f" "0x0006" :status :complete :comment "Mustek 1200 UB compatible" sane-backends-1.0.29/doc/descriptions/dc25.desc0000666000000000000000000000121713615534521016052 00000000000000;Kodak DC25 backend .desc file by Peter Fales :backend "dc25" ; name of backend :version "1.2 (unmaintained)" ; version of backend :manpage "sane-dc25" ; name of manpage (if it exists) :url "mailto:peter@fales-lorenz.net"; :devicetype :stillcam ; start of a list of devices.... :mfg "Kodak" ; Manufacturer :url "http://www.kodak.com/global/en/service/digCam/dc25/dc25.shtml"; :model "DC25" ; :status :complete ; untested, minimal, basic, complete :interface "Serial port" :model "DC20" ; :status :basic ; untested, minimal, basic, complete :interface "Serial port" :comment "DC-20 untested by author but reported to work" sane-backends-1.0.29/doc/descriptions/coolscan.desc0000666000000000000000000000267613615534521017130 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "coolscan" ; name of backend :version "0.4.3 (unmaintained)" ; version of backend :url "http://andreas.rick.free.fr/sane/" ; backend's web page :manpage "sane-coolscan" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Nikon" ; name a manufacturer :url "http://www.nikon.com/" :model "LS-20" ; name models for above-specified mfg. :interface "SCSI" :comment "The LS-20 has been replaced by the LS-30" :status :basic :model "LS-30" ; name models for above-specified mfg. :interface "SCSI" :comment "alpha: only 24/30 bit RGB + 32/40 bit RGBI" :status :basic :model "LS-2000" ; name models for above-specified mfg. :interface "SCSI" :comment "alpha: only 24/36 bit + RGB 32/48 bit RGBI" :status :basic :model "LS-1000" :interface "SCSI" :comment "Doesn't support gamma correction" :status :basic ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/epson.desc0000666000000000000000000001435513615534521016450 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "epson" ; name of backend :version "0.2.42 (unmaintained)" ; version of backend :new :no :manpage "sane-epson" ; name of manpage (if it exists) :url "http://www.khk.net/sane" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Epson" ; name a manufacturer :url "http://www.epson.com/" :model "GT-5000" ; name models for above-specified mfg. :interface "SCSI Parport" :status :good :model "Actionscanner II" :comment "US version of GT-5000" :interface "SCSI Parport" :status :good :model "GT-6000" :interface "SCSI Parport" :status :good :model "ES-300C" :comment "US version of GT-6000" :interface "SCSI Parport" :status :good :model "ES-300GS" :interface "SCSI" :status :good :model "GT-5500" :interface "SCSI" :status :good :model "GT-6500" :interface "Parport" :status :good :model "ES-600C" :comment "US version of GT-6500" :interface "Parport" :status :good :model "ES-1200C" :comment "US version of GT-9000" :interface "Parport" :status :good :model "GT-7000" :interface "SCSI" :scsi "EPSON" "SCANNER GT-7000" "processor" :status :good :model "GT-8000" :interface "SCSI" :status :good :model "ES-8500" :interface "SCSI" :status :good :model "Perfection 636S" :comment "US version of GT-7000" :interface "SCSI" :scsi "EPSON" "Perfection1200" "processor" :status :complete :model "Perfection 636" :interface "SCSI" :scsi "EPSON" "Perfection636" "processor" :status :complete :model "Perfection 636U" :interface "USB" :usbid "0x04b8" "0x0101" :status :complete :model "Perfection 610" :interface "USB" :usbid "0x04b8" "0x0103" :status :complete :model "Perfection 640" :interface "USB" :usbid "0x04b8" "0x010c" :status :complete :model "Perfection 1200S" :interface "SCSI" :scsi "EPSON" "Perfection1200" "processor" :status :complete :model "Perfection 1200U" :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :model "Perfection 1200Photo" :comment "with TPU" :interface "USB" :usbid "0x04b8" "0x0104" :status :complete :model "Perfection 1240" :interface "SCSI USB" :usbid "0x04b8" "0x010b" :status :complete :model "Perfection 1640" :interface "SCSI USB" :usbid "0x04b8" "0x010a" :status :complete :model "Perfection 1650" :interface "USB" :usbid "0x04b8" "0x0110" :status :complete :model "Perfection 1660" :interface "USB" :usbid "0x04b8" "0x011e" :status :complete :model "Perfection 2400" :interface "USB" :usbid "0x04b8" "0x011b" :status :complete :model "Perfection 2450" :interface "USB IEEE-1394" :usbid "0x04b8" "0x0112" :scsi "EPSON" "GT-9700" "processor" :status :complete :model "Perfection 3200" :comment "US version of the GT-9800" :interface "USB IEEE-1394" :usbid "0x04b8" "0x011c" :scsi "EPSON" "GT-9800" "processor" :status :complete :model "Perfection 4870" :comment "US version of the GT-X700" :interface "USB" :usbid "0x04b8" "0x0128" :status :complete :model "Perfection 4990" :comment "US version of the GT-X800" :interface "USB" :usbid "0x04b8" "0x012a" :status :complete :model "Expression 636" :comment "US version of GT-9500" :interface "SCSI" :status :complete :model "Expression 800" :interface "SCSI" :status :complete :scsi "EPSON" "Expression800" "processor" :model "Expression 1600" :interface "SCSI USB IEEE-1394" :usbid "0x04b8" "0x0107" :status :complete :model "Expression 1680" :interface "SCSI USB IEEE-1394" :usbid "0x04b8" "0x010e" :status :complete :model "FilmScan 200" :interface "SCSI" :status :unsupported :model "CX-3200" :interface "USB" :usbid "0x04b8" "0x0802" :status :good :model "CX-3600" :interface "USB" :usbid "0x04b8" "0x080e" :status :good :model "CX-3650" :interface "USB" :usbid "0x04b8" "0x080e" :status :good :model "CX-4600" :interface "USB" :usbid "0x04b8" "0x080d" :status :good :model "CX-4800" :interface "USB" :usbid "0x04b8" "0x0819" :status :good :model "CX-5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :model "CX-5200" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :model "CX-5400" :interface "USB" :usbid "0x04b8" "0x0801" :status :good :model "CX-5400" :interface "USB" :usbid "0x04b8" "0x0808" :status :good :model "CX-6300" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :model "CX-6400" :interface "USB" :usbid "0x04b8" "0x0805" :status :good :model "CX-6500" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :model "CX-6600" :interface "USB" :usbid "0x04b8" "0x0813" :status :good :model "RX-500" :interface "USB" :usbid "0x04b8" "0x0807" :status :good :model "RX-600" :interface "USB" :usbid "0x04b8" "0x0806" :status :good :model "RX-425" :interface "USB" :usbid "0x04b8" "0x080f" :status :good :model "RX-700" :interface "USB" :usbid "0x04b8" "0x0810" :status :good :model "RX-620" :interface "USB" :usbid "0x04b8" "0x0811" :status :good :model "DX-3850" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :model "CX-3700" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :model "CX-3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :model "CX-4200" :interface "USB" :usbid "0x04b8" "0x0820" :status :good :model "DX-3800" :interface "USB" :usbid "0x04b8" "0x0818" :status :good :model "DX-5000" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :model "DX-5050" :interface "USB" :usbid "0x04b8" "0x082b" :status :good :model "DX-6000" :interface "USB" :usbid "0x04b8" "0x082e" :status :good :model "DX-7400" :interface "USB" :usbid "0x04b8" "0x0838" :status :good :model "DX-4050" :interface "USB" :usbid "0x04b8" "0x082f" :status :good :model "AcuLaser CX11" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :model "AcuLaser CX11NF" :interface "USB" :usbid "0x04b8" "0x0815" :status :good :model "V700" :interface "USB IEEE-1394" :usbid "0x04b8" "0x012c" :status :good :model "V750" :interface "USB IEEE-1394" :usbid "0x04b8" "0x012c" :status :good sane-backends-1.0.29/doc/descriptions/pie.desc0000666000000000000000000000371613615534521016100 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "pie" ; name of backend :version "1.0 (unmaintained)" ; version of backend :manpage "sane-pie" ; name of manpage (if it exists) :url "http://www.munton.demon.co.uk/sane" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Devcom" :url "http://www.blackwidow.co.uk/" :model "9636PRO" :interface "SCSI" :status :good :model "9636S" :interface "SCSI" :status :untested :model "9630S" :interface "SCSI" :status :untested :mfg "PIE" ; name a manufacturer :url "http://www.scanace.com/" :model "ScanAce 1236S" :interface "SCSI" :status :good :model "ScanAce 1230S" :interface "SCSI" :status :good :model "ScanAce II" :interface "SCSI" :status :untested :model "ScanAce III" :interface "SCSI" :status :good :model "ScanAce Plus" :interface "SCSI" :status :untested :model "ScanAce II Plus" :interface "SCSI" :status :untested :model "ScanAce III Plus" :interface "SCSI" :status :untested :model "ScanAce V" :interface "SCSI" :status :untested :model "ScanAce ScanMedia" :interface "SCSI" :status :untested :model "ScanAce ScanMedia II" :interface "SCSI" :status :untested :model "ScanAce 630S" :interface "SCSI" :status :untested :model "ScanAce 636S" :interface "SCSI" :status :untested :mfg "Adlib" :model "JetScan630" :interface "SCSI" :status :good :model "JetScan636PRO" :interface "SCSI" :status :untested ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/canon.desc0000666000000000000000000000333213615534521016413 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon" ; name of backend :manpage "sane-canon" :version "1.12 (unmaintained)" ; version of backend ;:status :good ; :alpha, :beta, :stable, :new :url "http://www.rzg.mpg.de/~mpd/sane/" ; backend home page :devicetype :scanner :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" :model "CanoScan 300" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :model "CanoScan 600" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :model "CanoScan 620S" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :model "CanoScan 1200S" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :model "CanoScan 2700F" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; film scanner" :status :good :model "CanoScan 2710S" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; 36bit film scanner" :status :good :model "IX-4015" ; name models for above-specified mfg. :interface "SCSI" :comment "1 pass; flatbed scanner" :status :good :mfg "Apple" ; name a manufacturer :url "http://www.apple.com/" :model "Color OneScanner 600/27" ; name models for above-specified mfg. :interface "SCSI" :comment "Rebadged CanoScan 300" :status :good sane-backends-1.0.29/doc/descriptions/ricoh.desc0000666000000000000000000000153313615534521016422 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "ricoh" ; name of backend :version "unmaintained" ; version of backend ; :manpage "sane-ricoh" ; name of manpage (if it exists) :devicetype :scanner :mfg "Ricoh" ; name a manufacturer :url "http://www.ricoh.com/" :model "Ricoh IS50" ; name models for above-specified mfg. :interface "SCSI" :status :basic ;:comment "?" :model "Ricoh IS60" ; name models for above-specified mfg. :interface "SCSI" :status :basic ;:comment "?" sane-backends-1.0.29/doc/descriptions/hp4200.desc0000666000000000000000000000275513615534521016242 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "hp4200" ; name of backend :version "1.0-2 (unmaintained)" ; version of backend :manpage "sane-hp4200" ; name of manpage (if it exists) :url "http://hp4200-backend.sourceforge.net" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "ScanJet 4200C" ; name models for above-specified mfg. :interface "USB" :usbid "0x03f0" "0x0105" :status :basic :comment "8bpp color, 75/150/300/600 dpi only" :model "ScanJet 4200Cxi" ; name models for above-specified mfg. :interface "USB" :usbid "0x03f0" "0x0105" :status :basic :comment "8bpp color, 75/150/300/600 dpi only" :model "ScanJet 4200Cse" ; name models for above-specified mfg. :interface "USB" :usbid "0x03f0" "0x0105" :status :basic :comment "8bpp color, 75/150/300/600 dpi only" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/as6e.desc0000666000000000000000000000243713615534521016160 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "as6e" ; name of backend :version "0.5 (unmaintained)" ; version of backend :manpage "sane-as6e" ; name of manpage (if it exists) :url "http://as6edriver.sourceforge.net/" :devicetype :scanner :mfg "Artec/Ultima" ; name a manufacturer :url "http://www.artecusa.com/" :model "AS6E" :interface "Parport" :status :basic :comment "Requires the program 'as6edriver' to run." :mfg "Trust" ; name a manufacturer :url "http://www.trust-site.com" :comment "Carefully check the model names. Trust uses similar names for completely different hardware." :model "Easy Scan 9600 Plus" :interface "Parport" :status :basic :comment "Requires the program 'as6edriver' to run." :mfg "Dexxa" ; name a manufacturer :url "http://www.dexxa.com" :model "4800" :interface "Parport" :status :basic :comment "Requires the program 'as6edriver' to run." ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/artec.desc0000666000000000000000000000347513615534521016423 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "artec" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-artec" ; name of manpage (if it exists) :url "http://www4.infi.net/~cpinkham/sane/sane-artec-doc.html" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Artec/Ultima" ; name a manufacturer :url "http://www.artecusa.com/" ;; name models for above-specified mfg. :model "AT3" :interface "SCSI" :status :complete :comment "all modes working" :model "A6000C" :interface "SCSI" :status :complete :comment "all modes working" :model "A6000C PLUS" :interface "SCSI" :status :complete :comment "f/w <= v1.92 basic, f/w >= v1.93 OK" :model "AT6" :status :good :interface "SCSI" :comment "Scan head needs to return home before another scan can be started." :model "AT12" :interface "SCSI" :status :complete :comment "all modes working" :model "AM12S" :interface "SCSI" :status :complete :comment "all modes working" :mfg "BlackWidow" :url "http://www.blackwidow.co.uk/" :model "BW4800SP" :interface "SCSI" :status :complete :comment "rebadged Artec AT3" :mfg "Plustek" :url "http://www.plustek.com/" :model "OpticPro 19200S" :interface "SCSI" :status :complete :comment "rebadged Artec AM12S" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/teco2.desc0000666000000000000000000000314413615534521016332 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "teco2" ; name of backend :version "1.0-9 (unmaintained)" ; version of backend :manpage "sane-teco2" :url "http://gkall.hobby.nl/teco2.html" ; backend's web page :devicetype :scanner :mfg "Relisys" :url "http://www.relisys.com/" :model "AVEC Super 3" :interface "SCSI" :comment "sub model VM3575" :status :untested :model "AVEC II S3" :interface "SCSI" :comment "sub model VM3564" :status :good :model "SCORPIO Super 3" :comment "sub model VM3575" :interface "SCSI" :status :good :model "APOLLO Express 3" :comment "sub model VM356A" :interface "SCSI" :status :basic :model "APOLLO Express 6" :comment "sub model VM6565" ; aka VM656A :interface "SCSI" :status :good :model "SCORPIO Pro" :comment "sub model VM6575" :interface "SCSI" :status :good :model "SCORPIO Pro-S" :comment "sub model VM6586" :interface "SCSI" :status :untested :mfg "Primax" :url "http://www.primax.nl/" :model "Jewel 4800" :comment "sub model VM356A" :interface "SCSI" :status :good :model "Profi 9600" :comment "sub model VM6575" :interface "SCSI" :status :basic :model "Profi 19200" :comment "sub model VM6586" :interface "SCSI" :status :good :mfg "Mustek" :url "http://www.mustek.com/" :model "ScanMagic 4830S" :comment "sub model VM3575" :interface "SCSI" :status :untested sane-backends-1.0.29/doc/descriptions/net.desc0000666000000000000000000000047113615534521016104 00000000000000:backend "net" ; name of backend :version "1.0.14 (unmaintained)" :manpage "sane-net" :url "http://www.penguin-breeder.org/?page=sane-net" :devicetype :meta :desc "Network access to saned servers" :comment "Can be used to access any scanner supported by SANE over the net. Supports IPv4 and IPv6." sane-backends-1.0.29/doc/descriptions/plustek_pp.desc0000666000000000000000000000665713615534521017520 00000000000000; ; SANE Backend description file for Plustek_pp backend ; :backend "plustek_pp" :version "0.43" :manpage "sane-plustek_pp" :devicetype :scanner ;* Plustek ********************************************************************************** :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" ;name models for above-specified mfg. :model "OpticPro 4800P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 4830P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 600P/6000P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 4831P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 9630P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 9630PL" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=1" :model "OpticPro 9600P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 1236P" :interface "Parport (SPP, EPP)" :status :complete :comment "reported as OpticPro 12000P/96000P" :model "OpticPro 12000P/96000P" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 9636P" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=4" :model "OpticPro 9636P+/Turbo" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=3" :model "OpticPro 9636T" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro 12000T" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro AI3" :interface "Parport (SPP, EPP)" :status :basic :comment "use driver-switch mov=5, poor picture quality" :model "OpticPro P8" :interface "Parport" :status :untested :model "OpticPro P12" :interface "Parport (SPP, EPP)" :status :complete :model "OpticPro PT12" :interface "Parport (SPP, EPP)" :status :complete ;* Primax *********************************************************************************** :mfg "Primax" ; name of manufacturer :url "http://www.primax.nl/" ;name models for above-specified mfg. :model "Colorado 4800" :interface "Parport (SPP, EPP)" :status :untested :comment "same as OpticPro 4800P" :model "Compact 4800 Direct" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=2" :model "Compact 4800 Direct-30" :interface "Parport (SPP, EPP)" :status :complete :comment "same as OpticPro 4830P, use driver-switch mov=7" :model "Compact 9600 Direct-30" :interface "Parport (SPP, EPP)" :status :complete :comment "same as OpticPro 9630P" ;* Genius/KYE ******************************************************************************************* :mfg "Genius" :url "http://www.geniusnet.com.tw/" :model "Colorpage Vivid III V2" :interface "Parport (SPP, EPP)" :status :complete :comment "Reported as PT12" :model "Colorpage Vivid Pro II Film" :interface "Parport (SPP, EPP)" :status :complete :comment "Reported as OP9636T/12000T" :model "Colorpage HR6X EPP" :interface "Parport (SPP, EPP)" :status :good :comment "Negative scanning does not work correctly" ;******************************************************************************************** :mfg "Aries" :model "Scan-It Pro 4800" :interface "Parport (SPP, EPP)" :status :complete :comment "use driver-switch mov=2" ;******************************************************************************************** :mfg "BrightScan" :model "BrighScan OpticPro" :interface "Parport (SPP, EPP)" :status :complete :comment "Reported as P12" sane-backends-1.0.29/doc/descriptions/v4l.desc0000666000000000000000000000206013615534521016017 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "v4l" ; name of backend :version "1.0-3 (unmaintained)" ; version of backend :manpage "sane-v4l" ; name of manpage (if it exists) :url "mailto:henning@meier-geinitz.de" ; backend's web page :devicetype :api ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :desc "Interface to Video For Linux API" ; describe a non-hardware device :comment "Supports video cameras and other devices accessed by the v4l kernel API, e.g. bttv devices. Quite a lot of known bugs." ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/coolscan3.desc0000666000000000000000000000316513615534521017205 00000000000000; ; SANE Backend specification file for coolscan2 ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "coolscan3" :version "1.0.0 (unmaintained)" :manpage "sane-coolscan3" :devicetype :scanner :mfg "Nikon" :url "http://www.nikon.com/" :model "LS 30" :interface "SCSI" :status :complete :model "Coolscan III" :interface "SCSI" :status :complete :comment "Rebadged LS 30?" :model "LS 40 ED" :interface "USB" :usbid "0x04b0" "0x4000" :status :complete :model "Coolspan IV" :interface "USB" :usbid "0x04b0" "0x4000" :status :complete :comment "Rebadged LS 40?" :model "LS 50 ED" :url "unsupported/nikon-ls50-ed.html" :interface "USB" :usbid "0x04b0" "0x4001" :status :minimal :model "Coolscan V ED" :url "unsupported/nikon-ls50-ed.html" :interface "USB" :usbid "0x04b0" "0x4001" :status :minimal :comment "Rebadged LS 50?" :model "LS 2000" :interface "SCSI" :status :good :model "LS 4000 ED" :interface "IEEE-1394" :status :good :comment "needs linux kernel 2.4.19 or later" :model "Super Coolscan LS-5000 ED" :url "unsupported/nikon-ls5000-ed.html" :interface "USB" :usbid "0x04b0" "0x4002" :status :untested :comment "May work, similar to LS 50 ED, but untested. Please tell us if it works." :model "LS 8000 ED" :interface "IEEE-1394" :status :good :comment "needs linux kernel 2.4.19 or later" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/hp3500.desc0000666000000000000000000000265613615534521016244 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hp3500" ; name of backend :version "1.1 (unmaintained)" ; version of backend :manpage "sane-hp3500" ; name of manpage (if it exists) :url "http://projects.troy.rollo.name/rt-scanners/" ; backend's web page :comment "HP3500 series scanners." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com" :model "ScanJet 3500C" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port" or "Propretiary". :usbid "0x03f0" "0x2205" :status :good :model "ScanJet 3530C" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: :usbid "0x03f0" "0x2005" :status :good :model "ScanJet 3570C" ; name models for above-specified mfg. :interface "USB" ; interface type of the device: :usbid "0x03f0" "0x2005" :status :good ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/dc210.desc0000666000000000000000000000071613615534521016131 00000000000000;Kodak DC210 backend .desc file by Brian J. Murrell :backend "dc210" ; name of backend :version "0.0 (unmaintained)" ; version of backend :manpage "sane-dc210" ; name of manpage (if it exists) :url "mailto:peter@fales-lorenz.net" ; backend's web page :devicetype :stillcam ; start of a list of devices.... :mfg "Kodak" :url "http://www.kodak.com/global/en/service/digCam/dc210/dc210.shtml" :model "DC210" :interface "Serial port" :status :basic sane-backends-1.0.29/doc/descriptions/sceptre.desc0000666000000000000000000000140313615534521016757 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "sceptre" :version "1.0-10 (unmaintained)" ; version of backend :manpage "sane-sceptre" ; name of manpage :url "http://www.zago.net/sane/" ; backend's web page :devicetype :scanner :mfg "Sceptre" :url "http://www.sceptre.com/" :model "Vividscan S1200" :interface "SCSI" :status :basic :mfg "Komodo" :url "http://www.komodo.com/" :model "S1200" :interface "SCSI" :status :untested :comment "rebadged Sceptre S1200" sane-backends-1.0.29/doc/descriptions/sp15c.desc0000666000000000000000000000214713615534521016253 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "sp15c" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-sp15c" ; name of manpage (if it exists) ;:url "http://www.aa.net/~bentson/sane.html" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Fujitsu" ; name a manufacturer :url "http://www.fcpa.fujitsu.com/products/scanners/" :url "http://www.fujitsu.com/" :model "ScanPartner 15C" ; name models for above-specified mfg. :interface "SCSI" :status :good :model "ScanPartner 600C" ; name models for above-specified mfg. :interface "SCSI" :status :good sane-backends-1.0.29/doc/descriptions/pint.desc0000666000000000000000000000056713615534521016276 00000000000000:backend "pint" ; name of backend :version "unmaintained" ; version of backend ; :url "" ; backend's homepage :manpage "sane-pint" :devicetype :api ; name models for above-specified mfg. :desc "Scanners with the machine-independent PINT interface" :comment "Haven't been tested for a long time. Handle with care." sane-backends-1.0.29/doc/descriptions/epsonds.desc0000666000000000000000000000337613615534521017000 00000000000000; ; SANE Backend specification file for the epsonds backend ; ; Copyright (C) 2015 Alessandro Zummo ; Released under GPLv2 ; :backend "epsonds" :version "1.0.18 (unmaintained)" :new :no :manpage "sane-epsonds" :devicetype :scanner :mfg "Epson" :url "http://www.epson.com/" :model "DS-5500" :interface "USB" :usbid "0x04b8" "0x0145" :status :untested :model "DS-6500" :interface "USB" :usbid "0x04b8" "0x0145" :status :untested :model "DS-7500" :interface "USB" :usbid "0x04b8" "0x0145" :status :untested :model "DS-50000" :interface "USB" :usbid "0x04b8" "0x0146" :status :untested :model "DS-60000" :interface "USB" :usbid "0x04b8" "0x0146" :status :good :model "DS-70000" :interface "USB" :usbid "0x04b8" "0x0146" :status :untested :model "DS-510" :interface "USB" :usbid "0x04b8" "0x014c" :status :good :model "DS-560" :interface "USB" :usbid "0x04b8" "0x014d" :status :untested :model "DS-40" :interface "USB" :usbid "0x04b8" "0x0150" :status :untested :model "DS-760" :interface "USB" :usbid "0x04b8" "0x0152" :status :untested :model "DS-860" :interface "USB" :usbid "0x04b8" "0x0152" :status :untested :model "DS-520" :interface "USB" :usbid "0x04b8" "0x0154" :status :untested :model "PX-M7050 Series" :interface "USB" :usbid "0x04b8" "0x08bc" :status :untested :model "WF-8510/8590 Series" :interface "USB" :usbid "0x04b8" "0x08bc" :status :untested :model "PX-M7050FX Series" :interface "USB" :usbid "0x04b8" "0x08cc" :status :untested :model "WF-R8590 Series" :interface "USB" :usbid "0x04b8" "0x08cc" :status :untested sane-backends-1.0.29/doc/descriptions/s9036.desc0000666000000000000000000000062513615534521016103 00000000000000:backend "s9036" ; name of backend :version "unmaintained" ; version of backend ; :url "" ; backend's homepage :manpage "sane-s9036" :devicetype :scanner :mfg "Siemens" ; name a manufacturer :url "http://www.siemens.com/" :model "9036 Flatbed scanner" ; name models for above-specified mfg. :interface "SCSI" :status :basic ; :comment "" sane-backends-1.0.29/doc/descriptions/unsupported.desc0000666000000000000000000022546013615534521017715 00000000000000 ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "unsupported" ; name of backend :version "2010-06-09" ; version of backend :url "contrib.html" ;:manpage "sane-mustek" ; name of manpage (if it exists) :comment "The devices mentioned here are not supported by any SANE backend. However, there may be links to information about them or stand-alone programs." :devicetype :scanner ;******************************************************************************************** :mfg "Agfa" :model "DuoScan f40" :url "unsupported/agfa-duoscan-f40.html" :interface "USB IEEE-1394" :usbid "0x06bd" "0x02bf" :status :unsupported :comment "Unsupported. See link for details." :model "DuoScan T2000XL" :url "unsupported/agfa-duoscan-t2000xl.html" :interface "SCSI" :status :unsupported :comment "Unsupported. Same as Microtek ArtixScan 2020?" :model "DuoScan T2500" :interface "SCSI IEEE-1384" :status :unsupported :comment "Unsupported. Same as Microtek Artixscan 2500f" :model "SnapScan 310P" :url "unsupported/acer-parport.html" :interface "Parport" :status :unsupported :comment "Unsupported, see link for details." :model "SnapScan EZ" :url "unsupported/acer-parport.html" :interface "Parport" :status :unsupported :comment "Unsupported, see link for details." :model "SnapScan 1200P" :url "unsupported/acer-parport.html" :interface "Parport" :status :unsupported :comment "Unsupported, see link for details." :model "SnapScan 1212P" :url "unsupported/acer-parport.html" :interface "Parport" :status :unsupported :comment "Unsupported, see link for details." ;******************************************************************************************** :mfg "Artec/Ultima" :url "http://www.artecusa.com/" :model "1236 USB" :url "unsupported/artec_1236usb.html" :interface "USB" :usbid "0x05d8" "0x4001" :status :unsupported :comment "Unsupported. See link for details." :model "AM12e+" :status :unsupported :interface "Parport" :comment "Unsupported. Chips found inside: AT015, AD9816JS. Maybe similar to SCSI version or as6e?" :model "Ultima 2000 (0x4001)" :url "unsupported/artec-ultima-2000-2.html" :interface "USB" :usbid "0x05d8" "0x4001" :status :unsupported :comment "Same name, but different ids: This scanner is not supported. The scanner with product id 0x4002 is supported by the gt68xx backend, however." ;******************************************************************************************** :mfg "Avigramm" :model "Minidoc" :url "unsupported/trust-combiscan-19200.html" :interface "USB Parport" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** :mfg "Avision" :url "http://www.avision.com/" :model "DS310F" :interface "Parport" :status :unsupported :comment "Probably not supported. Scanner/printer/copier combination." :model "iVina FB2400" :interface "USB" :status :unsupported :comment "Not supported. No chipset information available. Same as UMAX Astra 6700." :model "iVina 1600" :url "unsupported/umax-astra-4500.html" :interface "USB" :usbid "0x0638" "0x0a10" :status :unsupported :comment "GL646 based, to be added to genesys backend. Same as UMAX Astra 4500." :model "iVina FB1800" :url "unsupported/umax-astra-4700.html" :interface "USB" :usbid "0x0638" "0x0a20" :status :unsupported :comment "GL646/GL660 based. Same as UMAX Astra 4700." ;******************************************************************************************** :mfg "Benq (Acer)" :url "http://www.benq.com" :comment "Formerly Acer Peripherals" :model "310P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "320P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "340P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "610P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "610PT" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "620P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "620PT" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "640P" :url "unsupported/acer-parport.html" :status :unsupported :interface "Parport" :comment "Unsupported, see link for details." :model "5450" :interface "USB" :usbid "0x04a5" "0x211e" :status :unsupported :comment "Unsupported." :model "5550" :url "unsupported/benq-5550.html" :interface "USB" :usbid "0x04a5" "0x2211" :status :unsupported :comment "Unsupported, see link for details." :model "5560" :interface "USB" :usbid "0x04a5" "0x2311" :status :unsupported :url "http://alioth-lists.debian.net/pipermail/sane-devel/2009-January/023447.html" :model "7400UT" :url "unsupported/benq-7400ut.html" :interface "USB" :usbid "0x04a5" "0x2202" :status :unsupported ;******************************************************************************************** :mfg "Boeder" :model "Sm@rtScan Office" :url "unsupported/trust-combiscan-19200.html" :interface "Parport USB" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Brother" :url "http://www.brother.com/" :model "MFC 2500" :url "unsupported/brother-mfc-2500.html" :interface "USB" :usbid "0x04f9" "0x000a" :status :unsupported :comment "Not supported. See link for details." :model "MFC 4600" :status :unsupported :url "http://sourceforge.net/projects/brother-mfc" :interface "Parport" :comment "The parport 200x400dpi grayscale version of this scanner is unsupported. Dmitri Katchalov did some investigations on this scanner. If you want to write a backend, contact him (see link)." :model "MFC 7300c" :url "unsupported/brother-mfc-7300.html" :interface "Parport USB" :usbid "0x04f9" "0x0106" :status :unsupported :model "MFC 9600" :url "unsupported/brother-mfc-9600.html" :interface "USB" :usbid "0x04f9" "0x0101" :status :unsupported ;******************************************************************************************** :mfg "C-Channel" :url "http://www.c-channel.ch/" :model "MyPen Pro" :url "unsupported/c-channel-mypen-pro.html" :interface "USB" ;:usbid "" "" :status :unsupported :comment "Probably unsupported. See link for details." :model "MyPen Light" :interface "USB" :usbid "0x0a93" "0x0005" :status :unsupported :comment "See bug #306792 for details." :model "MoneyPen II" ;:url "unsupported/c-channel-mypen-pro.html" :interface "USB" ;:usbid "" "" :status :unsupported :comment "Probably unsupported." ;******************************************************************************************** :mfg "Canon" :url "http://www.canon.com/" :model "CanoScan 3000" :url "unsupported/canon-3000.html" :interface "USB" :usbid "0x04a9" "0x2215" :status :unsupported :comment "GL660+GL646 based." :model "CanoScan 3000ex" :url "unsupported/canon-3000.html" :interface "USB" :usbid "0x04a9" "0x2215" :status :unsupported :comment "GL660+GL646 based." :model "CanoScan 3000F" :url "unsupported/canon-3000.html" :interface "USB" :usbid "0x04a9" "0x2215" :status :unsupported :comment "GL660+GL646 based, to be added to genesys backend" :model "CanoScan 4200F" :url "unsupported/canon-4200f.html" :interface "USB" :usbid "0x04a9" "0x221b" :status :unsupported :comment "Probably unsupported. See link." :model "CanoScan 5000F" :url "unsupported/canon-5000f.html" :interface "USB" :usbid "0x04a9" "0x2212" :status :unsupported :comment "Unsupported. See link for details." :model "CanoScan 5200F" :url "unsupported/canon-5200f.html" :interface "USB" :usbid "0x04a9" "0x2217" :status :unsupported :comment "Probably unsupported. See link for details." :model "CanoScan 8000F" :url "unsupported/canon-8000f.html" :interface "USB" :usbid "0x04a9" "0x220f" :status :unsupported :comment "Not supported. See link for more information. With transparency adapter." :model "CanoScan 9900F" :url "unsupported/canon-9900f.html" :interface "USB" :usbid "0x04a9" "0x2210" :status :unsupported :comment "Probably unsupported, similar to 8000F. 3200x6400 dpi USB2. With transparency adapter." :model "CanoScan 9950F" :url "unsupported/canon-9950f.html" :interface "USB" :usbid "0x04a9" "0x2219" :status :unsupported :comment "Probably unsupported." :model "CanoScan D646U" :url "unsupported/canon-d646u.html" :interface "USB" :usbid "0x04a9" "0x220b" :status :unsupported :comment "Probably not supported. See link for more information and test program." :model "CanoScan D646U ex" :url "unsupported/canon-d646u.html" :interface "USB" :usbid "0x04a9" "0x220b" :status :unsupported :comment "Probably not supported. See D646." :model "CanoScan D1230U" :url "unsupported/canon-d1230u.html" :interface "USB" :usbid "0x04a9" "0x2209" :status :unsupported :comment "Probably not supported. " :model "CanoScan D1250U2" :url "unsupported/canon-d1250u2.html" :interface "USB" :usbid "0x04a9" "0x220c" :status :unsupported :comment "Not supported. However, someone started working on this scanner and some information is available (see link)." :model "CanoScan D2400UF" :url "unsupported/canon-d2400uf.html" :interface "USB" :usbid "0x04a9" "0x220a" :status :unsupported :comment "Not supported. See link." :model "CanoScan FB320U" :interface "USB" :usbid "0x04a9" "0x2201" :status :unsupported :comment "Probably not supported. No details known." :model "CanoScan FB620U" :url "unsupported/canon-fb620u.html" :interface "USB" :usbid "0x04a9" "0x2202" :status :unsupported :comment "Probably not supported. Some information is available." :model "CanoScan FB1210U" :url "http://sourceforge.net/projects/canonscanner/" :interface "USB" :usbid "0x04a9" "0x2205" :status :unsupported :comment "Not supported. However, a stand-alone program for FreeBSD is available." :model "CanoScan LiDE 70" :url "http://www.juergen-ernst.de/info_sane.html" :interface "USB" :usbid "0x04a9" "0x2225" :status :unsupported :comment "Philips chip. Backend started, see link" :model "CanoScan LiDE 90" :url "unsupported/canon-lide-90.html" :interface "USB" :usbid "0x04a9" "0x1900" :status :unsupported :comment "Unsupported. See link for details." :model "CanoScan LiDE 500F" :url "unsupported/canon-canoscan-lide-500f.html" :interface "USB" :usbid "0x04a9" "0x221f" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "CanoScan LiDE 600" :interface "USB" :url "http://www.juergen-ernst.de/info_sane.html" :usbid "0x04a9" "0x2224" :status :unsupported :comment "Philips chip. Backend started, see link" :model "CanoScan LiDE 600F" :interface "USB" :url "http://www.juergen-ernst.de/info_sane.html" :usbid "0x04a9" "0x2224" :status :unsupported :comment "Philips chip. Backend started, see link" :model "FS4000" :url "unsupported/canon-fs4000.html" :interface "USB SCSI" :usbid "0x04a9" "0x3042" :status :unsupported :comment "Not supported. See link for more details." :model "IS 12" :url "unsupported/canon-is-12.html" :interface "USB" :status :unsupported :comment "Probably not supported. Scanner cardridge for Canon inkjet printers." :model "IS 22" :url "unsupported/canon-is-22.html" :interface "Parport" :status :unsupported :comment "Probably not supported. Scanner cardridge for Canon inkjet printers." :model "IS 32" :url "unsupported/canon-is-32.html" :interface "USB" :usbid "0x04a9" "0x105d" :status :unsupported :comment "Probably not supported. Scanner cardridge for Canon inkjet printers." :model "IS 52" :url "unsupported/canon-is-52.html" :interface "USB" :status :unsupported :comment "Probably not supported. Scanner cardridge for Canon inkjet printers." :model "ImageRunner iR1018" :url "unsupported/canon-imagerunner.html" :interface "USB" :usbid "0x04a9" "0x269d" :status :unsupported :comment "Probably not supported. See link for details." :model "ImageRunner iR1022" :url "unsupported/canon-imagerunner.html" :interface "USB" :usbid "0x04a9" "0x269d" :status :unsupported :comment "Probably not supported. See link for details." :model "ImageRunner iR1023" :url "unsupported/canon-imagerunner.html" :interface "USB" :usbid "0x04a9" "0x269d" :status :unsupported :comment "Probably not supported. See link for details." :model "PIXMA MP110" :url "unsupported/canon-pixma-mp110.html" :interface "USB" :usbid "0x04a9" "0x1700" :status :unsupported :comment "Probably not supported. See link for details." :model "PIXMA MP130" :url "unsupported/canon-pixma-mp130.html" :interface "USB" :usbid "0x04a9" "0x1701" :status :unsupported :comment "Probably not supported. See link for details." :model "DR-2020U" :interface "USB" :status :unsupported :comment "GL84x?" ;******************************************************************************************** :mfg "Chinon" :model "DS-3000" :url "unsupported/chinon-ds3000.html" :interface "Parport Serial Port" :status :unsupported :comment "Unsupported at the moment, but a backend is in preparation. See link." ;******************************************************************************************** :mfg "Compaq" :url "http://www.compaq.com/" :model "S200" :interface "USB" :usbid "0x049f" "0x0021" :status :unsupported :comment "Not supported. 2400x1200 dpi. One bulk-in, one bulk-out and one interrupt endpoint. Type-number: U0001-HB21, another type nr on the inside: 75100512-00" ;******************************************************************************************** :mfg "Compeye" :model "Simplex 1236C" :url "unsupported/trust-combiscan-19200.html" :interface "Parport USB" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Corex" :url "http://www.cardscan.com/" :model "Cardscan 500" :url "unsupported/corex-cardscan-500.html" :interface "USB" :usbid "0x08f0" "0x0001" :status :unsupported :comment "Probably not supported. Businesscard reader." :model "Cardscan 700 C" :url "unsupported/corex-cardscan-700.html" :interface "USB" :usbid "0x08f0" "0x0004" :status :unsupported :comment "Probably not supported." ;******************************************************************************************** :mfg "Dell" :url "http://www.dell.com/" :model "A940" :interface "USB" :usbid "0x413c" "0x5106" :status :unsupported :comment "Probably rebadged Lexmark X5150. May work with sane-lexmark? See bug #312130" :model "A960" :url "unsupported/dell-a960.html" :interface "USB" :usbid "0x413c" "0x5107" :status :unsupported :comment "Probably not supported. See link for details." :model "922" :url "unsupported/dell-922.html" :interface "USB" :usbid "0x413c" "0x5109" :status :unsupported :comment "Probably not supported. See link for details." ;******************************************************************************************** :mfg "Epson" :url "http://www.epson.com/" :model "GT-2200" :interface "USB" :usbid "0x04b8" "0x0102" :status :unsupported :comment "Probably unsupported. No details known." :model "StylusScan 2000" :interface "USB" :usbid "0x04b8" "0x0105" :status :unsupported :comment "Probably unsupported. No details known." :model "Stylus DX4450" :url "unsupported/epson-stylus-dx4450.html" :interface "USB" :usbid "0x04b8" "0x083f" :status :unsupported :comment "Probably unsupported. See link for details." :model "Stylus CX-5800" :interface "USB" :status :unsupported :comment "Probably unsupported at the moment. Not compatible to snapscan backend. It's not known if it may work with epson or epkowa backend." ;******************************************************************************************** :mfg "EDT (Electronic Document Technology)" :url "http://www.bizcardreader.com/" :model "BizCardReader 900C" :url "unsupported/edt-900c.html" :interface "USB" :usbid "0x0a53" "0x5001" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "E-Lux" :comment "E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX" :model "j-6121" :interface "Parport" :status :unsupported :comment "Probably unsupported. Sold 1998. Same as E-Lux j-6121." ;******************************************************************************************** :mfg "Enhans" :comment "E-Lux and Enhans seem to have been purchased by dysan, now known as MEMOREX" :model "j-6121" :interface "Parport" :status :unsupported :comment "Probably unsupported. Sold 1998. Same as E-Lux j-6121." :model "M-3630 A" :interface "Parport" :status :unsupported :comment "Probably unsupported. " ;******************************************************************************************** :mfg "Fujitsu" :url "http://www.fujitsu.com/" :model "SP1120" :interface "USB" :usbid "0x04c5" "0x1473" :status :unsupported :comment "Genesys GL310 chipset, not supported by sane-genesys backend." :model "SP1125" :interface "USB" :usbid "0x04c5" "0x1475" :status :unsupported :comment "Genesys GL310 chipset, not supported by sane-genesys backend." :model "SP1130" :interface "USB" :usbid "0x04c5" "0x1476" :status :unsupported :comment "Genesys GL310 chipset, not supported by sane-genesys backend." :model "ScanPartner SP25" :interface "USB" :status :unsupported :usbid "0x04c5" "0x1409" :comment "Possibly Genesys protocol?" :model "ScanPartner SP30" :interface "USB" :status :unsupported :usbid "0x04c5" "0x140a" :comment "Possibly Genesys protocol?" :model "ScanPartner SP30F" :interface "USB" :status :unsupported :usbid "0x04c5" "0x140c" :comment "Possibly Genesys protocol?" ;******************************************************************************************** :mfg "Genius" :url "http://www.geniusnet.com.tw/" :url "http://www.genius-kye.com/" :model "ColorPage CS" :url "unsupported/genius-colorpage-cs.html" :interface "SCSI" :status :unsupported :comment "Probably unsupported, see link for details." :model "ColorPage-Slim 1200 USB2" :url "unsupported/genius-colorpage-slim-1200-usb2.html" :interface "USB" :usbid "0x0458" "0x2020" :status :unsupported :comment "GL841 based, to be added to genesys backend." :model "ColorPage HR6X Slim" :url "unsupported/genius-colorpage-hr6x.html" :interface "USB" :usbid "0x0458" "0x2019" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "ColorPage HR7X" :url "unsupported/genius-colorpage-hr7x.html" :interface "USB" :usbid "0x0458" "0x2018" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "ColorPage HR7XE" :url "unsupported/genius-colorpage-hr7xe.html" :interface "USB" :usbid "0x06dc" "0x0012" :status :unsupported :comment "Unsuported. See link for details." :model "ColorPage HR8" :url "unsupported/genius-colorpage-hr8.html" :interface "USB" :usbid "0x0458" "0x201c" :status :unsupported :comment "GL841 based, to be added to genesys backend" ;******************************************************************************************** :mfg "Guillemot" ; name a manufacturer :model "SCAN@HOME 48 USB" :url "unsupported/teco-vm6509.html" :interface "USB" :usbid "0x080d" "0x0102" :status :unsupported :comment "Probably unsupported. See link for details." :model "Maxi Scan A4 Parallel 36 bit" :interface "Parport" :status :unsupported :comment "Probably unsupported. Identical to the Benq Prisa 620P." ;******************************************************************************************** :mfg "Hercules" ; name a manufacturer :model "SCAN@HOME 48 USB" :url "unsupported/teco-vm6509.html" :interface "USB" :usbid "0x080d" "0x0102" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "Photo Scanner 1000" :url "unsupported/hp-photo-1000.html" :interface "USB" :usbid "0x03f0" "0x1001" :status :unsupported :comment "Not supported by SANE. However, it's detected as mass storage device so just mounting it is reported to work. See link for device data." :model "Photosmart 1200 Photo" :interface "USB" :status :unsupported :comment "Probably not supported by SANE. No details known. 10x15 cm. Maybe similar to Photo Scanner 1000?" :model "Photosmart S20 (C5101A)" :url "unsupported/hp-photosmart-s20xi.html" :interface "USB" :usbid "0x03f0" "0x0102" :status :unsupported :comment "Not supported yet by SANE. See link for details." :model "Photosmart S20xi (C7150A)" :url "unsupported/hp-photosmart-s20xi.html" :interface "USB" :usbid "0x03f0" "0x0102" :status :unsupported :comment "Not supported yet by SANE. See link for details." :model "Photosmart C5100 series" :url "unsupported/hp-photosmart-5100.html" :interface "USB" :usbid "0x03f0" "0x5811" :status :unsupported :comment "Not supported yet by SANE. See link for details." :model "Photosmart C3180" :url "unsupported/hp-photosmart-3180.html" :interface "USB" :usbid "0x03f0" "0x5611" :status :unsupported :comment "Not supported yet by SANE. See link for details." :model "ScanJet 3770" :status :unsupported :interface "USB" :usbid "0x03f0" "0x2505" :comment "While an external binary-only backend exists, it works only on Linux i386. Therefore the scanner is unsupported on other platforms." :model "ScanJet 4600" :url "unsupported/hp-scanjet-4600.html" :interface "USB" :usbid "0x03f0" "0x3005" :comment "Not supported. See link for details, or http://www.chmil.org/hp4600linux/ for code" :status :unsupported :model "ScanJet 4670" :interface "USB" :usbid "0x03f0" "0x3005" :comment "Not supported. See ScanJet 4600 entry." :status :unsupported :model "ScanJet 4890C" :url "unsupported/hp-scanjet-4850.html" :interface "USB" :usbid "0x03f0" "0x1b05" :comment "GL843, maybe can be added to genesys backend " :status :unsupported :model "ScanJet 5530C Photosmart" :url "unsupported/hp-scanjet-5530.html" :interface "USB" :usbid "0x03f0" "0x1605" :comment "Maybe GL841_HP, but not confirmed, maybe can be added to genesys backend" :status :unsupported :model "ScanJet 8390" :url "unsupported/hp-scanjet-8390.html" :interface "USB" :usbid "0x03f0" "0x3805" :comment "Probably not supported. See link for details." :status :unsupported :model "ScanJet G4000" :url "unsupported/hp-g4000.html" :interface "USB" :usbid "0x03f0" "0x4505" :comment "Probably not supported. See link for details." :status :unsupported ;******************************************************************************************** :mfg "IBM" :url "http://www.ibm.com" :model "ADF Color Scanner" :interface "Proprietary" :status :unsupported :comment "Unsupported. Uses proprietary ISA card. Maybe the same as the Plustek Spectra ADF?" ;******************************************************************************************** :mfg "IOMagic" :url "http://www.iomagic.com/" :model "MobileScan USB" :url "unsupported/trust-combiscan-19200.html" :interface "USB Parport" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Iris" :url "http://irislink.com/" :model "IriScan" :url "unsupported/iris-iriscan.html" :interface "USB" :usbid "0x0a53" "0x1000" :status :unsupported :comment "Unsupported. LM9832/3. See link for details." :model "IRISPen Translator Executive" :url "unsupported/iris-irispen-translator.html" :interface "USB" :usbid "0x0f43" "0x015a" :status :unsupported :comment "Unsupported. See link for details." :model "IRISCard Pro (IBCR II)" :url "unsupported/iris-business.html" :interface "USB" :usbid "0x0a38" "0x0301" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Kodak" :url "http://www.kodak.com" :model "Snapshot Photo Scanner 1" :interface "Parport" :status :unsupported :comment "Unsupported. FCC ID HWF96PHS" ;******************************************************************************************** :mfg "Lexmark" :url "http://www.lexmark.com/" :model "P6250" :url "unsupported/lexmark-p6250.html" :interface "USB" :usbid "0x043d" "0x0097" :status :unsupported :comment "Unsupported. See link for details." :model "Photo 3150" :url "unsupported/lexmark-3150.html" :interface "USB" :usbid "0x043d" "0x007d" :status :unsupported :comment "Unsupported. See link for details." :model "X74" :url "unsupported/lexmark-x75.html" :interface "USB" :usbid "0x043d" "0x0060" :status :unsupported :comment "Unsupported. See link for details." :model "X75" :url "unsupported/lexmark-x75.html" :interface "USB" :usbid "0x043d" "0x0060" :status :unsupported :comment "Unsupported. See link for details." :model "X75 PrinTrio" :url "unsupported/lexmark-x75.html" :interface "USB" :usbid "0x043d" "0x0060" :status :unsupported :comment "Unsupported. See link for details." :model "X83" :url "unsupported/lexmark-x83.html" :interface "USB" :usbid "0x043d" "0x003d" :status :unsupported :comment "Unsupported. GL640." :model "X2330" :url "unsupported/lexmark-x2330.html" :interface "USB" :usbid "0x043d" "0x00bb" :status :unsupported :comment "Unsupported. See link for details." :model "X3450" :url "unsupported/lexmark-x3450.html" :interface "USB" :usbid "0x043d" "0x00f6" :status :unsupported :comment "Unsupported. See link for details." :model "X5130" :url "unsupported/lexmark-x5130.html" :interface "USB" :usbid "0x043d" "0x0065" :status :unsupported :comment "Unsupported." :model "X5150" :url "unsupported/lexmark-x5130.html" :interface "USB" :usbid "0x043d" "0x0065" :status :unsupported :comment "Probably unsupported. See link for details." :model "X5250" :url "unsupported/lexmark-x5250.html" :interface "USB" :usbid "0x043d" "0x0093" :status :unsupported :comment "Unsupported." :model "X6170" :url "unsupported/lexmark-x6170.html" :interface "USB" :usbid "0x043d" "0x0072" :status :unsupported :comment "Unsupported. See link for details." :model "X7170" :interface "USB" :usbid "0x043d" "0x0098" :status :unsupported :comment "Unsupported. See bug #310889 for details." :model "X7350" :url "unsupported/lexmark-x7350.html" :interface "USB" :usbid "0x043d" "0x00b8" :status :unsupported :comment "Unsupported. See link for details." :model "X8350" :url "unsupported/lexmark-x8350.html" :interface "USB" :usbid "0x043d" "0x00b9" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Logitech" :model "PageScan Color" :interface "Parport" :status :unsupported :comment "Most probably unsupported." :model "PageScan USB" :url "unsupported/logitech-pagescan-usb.html" :interface "USB" :usbid "0x046d" "0x040f" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.com/" :url "http://www.medion.de/" :model "MD 6190" :url "unsupported/medion-md6190.html" :interface "USB" :usbid "0x0461" "0x0392" :status :unsupported :comment "Probably unsupported. There seem to exist two different scanners with that name. See link for details." :model "MD 6190" :url "unsupported/medion-md6190.html" :interface "USB" :usbid "0x0461" "0x037b" :status :unsupported :comment "Probably unsupported. There seem to exist two different scanners with that name. See link for details." :model "MD 40420" :url "unsupported/tevion-md40420.html" :interface "USB" :usbid "0x05da" "0x3008" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 41260" :url "unsupported/medion-md6190.html" :interface "USB" :usbid "0x0461" "0x037b" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 41985" :url "unsupported/medion-md6190.html" :interface "USB" :usbid "0x0461" "0x037b" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 42666" :url "unsupported/tevion-md40420.html" :interface "USB" :usbid "0x05da" "0x3008" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 85264" :url "http://gkall.hobby.nl/authentec.html" :interface "USB" :usbid "0x08ff" "0x2580" :status :unsupported :comment "Fingerprint sensor. See link for details." :model "MD 90009" :url "unsupported/tevion-md90009.html" :interface "USB" :usbid "0x05da" "0x30e5" :status :unsupported :comment "Probably unsupported. See link for details." :model "MD 90070" :url "unsupported/tevion-md90070.html" :interface "USB" :usbid "0x05da" "0x3022" :status :unsupported :comment "Unsupported. See link for details." :model "MD 90090" :url "unsupported/tevion-md90070.html" :interface "USB" :usbid "0x05da" "0x3022" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Memorex" :url "http://www.memorex.com/" :model "6136u" :url "unsupported/memorex-maxx-6136u.html" :interface "USB" :usbid "0x0461" "0x0346" :status :unsupported :comment "Probably unsupported." :model "6142u" :url "unsupported/visioneer-onetouch4400.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Probably unsupported. Same as Visioneer Onetouch 4400. See link for details." :model "MaxxScan 6122" :url "unsupported/trust-combiscan-19200.html" :interface "USB Parport" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." :model "SCF 9612P" :url "unsupported/memorex-scf-9612p.html" :interface "Parport" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Microtek" :url "http://www.microtek.com/" :model "ArtixScan 2020" :interface "SCSI" :status :unsupported :comment "Unsupported. Same as Agfa DuoScan T2000XL?" :model "ArtixScanDI 2020" :url "unsupported/microtek-artixscan-2020.html" :interface "USB" :usbid "0x05da" "0x202e" :status :unsupported :comment "Unsupported. See link for details." :model "Artixscan 2500f" :interface "SCSI IEEE-1384" :status :unsupported :comment "Unsupported. Same as Agfa DuoScan T2500?" :model "ArtixScan 4000tf" :interface "USB" :status :unsupported :comment "Unsupported. Uses ALI M5611B." :model "FilmScan 35" :url "unsupported/microtek-filmscan-35.html" :interface "USB" :usbid "0x05e3" "0x0120" :status :unsupported :comment "Probably unsupported. See link for details." :model "ScanMaker 336 CX" :interface "SCSI" :status :unsupported :comment "Probably unsupported. Seems to be similar to the Microtek 330 CX and is detected by the microtek2 backend. Scanning doesn't seem to work however." :model "Scanmaker 1850S" :url "unsupported/microtek-scanmaker-1850s.html" :interface "SCSI" :status :unsupported :comment "Unsupported. See link for details." :model "ScanMaker 3630" :url "unsupported/microtek-scanmaker-3630.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Unsupported. Doesn't seem to be compatible to 3600 series, see link." :model "ScanMaker 3800" :url "unsupported/microtek-scanmaker-3800.html" :interface "USB" :usbid "0x05da" "0x30ce" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 3830" :url "unsupported/microtek-scanmaker-3830.html" :interface "USB" :usbid "0x05da" "0x30ce" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 3860" :url "unsupported/microtek-scanmaker-3880.html" :interface "USB" :usbid "0x05da" "0x3023" :status :unsupported :comment "Unsupported. See link for more details. Appears to be similar to ScanMaker 3880." :model "ScanMaker 3880" :url "unsupported/microtek-scanmaker-3880.html" :interface "USB" :usbid "0x05da" "0x3021" :status :unsupported :comment "Unsupported. SQ113 chip. See link for more details." :model "ScanMaker 4600" :url "unsupported/microtek-scanmaker-4600.html" :interface "USB" :usbid "0x05da" "0x40c7" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 4700" :url "unsupported/microtek-scanmaker-4700.html" :interface "USB" :usbid "0x05da" "0x20b4" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 4850" :url "unsupported/microtek-scanmaker-4900.html" :interface "USB" :usbid "0x05da" "0x30d9" :status :unsupported :comment "Probably unsupported. See link for details." :model "ScanMaker 4850 II" :url "unsupported/microtek-scanmaker-4850-2.html" :interface "USB" :usbid "0x05da" "0x3008" :status :unsupported :comment "Probably unsupported. See link for details." :model "ScanMaker 4900" :url "unsupported/microtek-scanmaker-4900.html" :interface "USB" :usbid "0x05da" "0x30b9" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 5" :url "unsupported/microtek-scanmaker-5600.html" :interface "SCSI" :status :unsupported :comment "Probably unsupported. See link for more details." :model "ScanMaker 5600" :url "unsupported/microtek-scanmaker-5600.html" :interface "USB" :usbid "0x05da" "0x20a7" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 5700" :interface "USB" :usbid "0x05da" "0x20bd" :status :unsupported :comment "Unsupported. Uses ALI M5615 like the ScanMaker 4700." :model "ScanMaker 5800" :url "unsupported/microtek-scanmaker-5800.html" :interface "USB" :usbid "0x05da" "0x3008" :status :unsupported :comment "Unsupported. See link for details." :model "ScanMaker 5800" :url "unsupported/microtek-scanmaker-5800.html" :interface "USB" :usbid "0x05da" "0x30d8" :status :unsupported :comment "Unsupported. See link for details." :model "ScanMaker 5900" :url "unsupported/microtek-scanmaker-5900.html" :interface "USB" :usbid "0x05da" "0x30d8" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 5950" :url "unsupported/microtek-scanmaker-5950.html" :interface "USB" :usbid "0x05da" "0x30d8" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 6000" :url "unsupported/microtek-scanmaker-6000.html" :interface "USB" :usbid "0x05da" "0x30e5" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 6100" :url "unsupported/microtek-scanmaker-6100.html" :interface "USB" :usbid "0x05da" "0x30e5" :status :unsupported :comment "Unsupported. See link for more details." :model "ScanMaker 6700" :url "unsupported/microtek-scanmaker-6700.html" :interface "USB IEEE-1394" :usbid "0x05da" "0x20c9" :status :unsupported :comment "Unsupported. See link." :model "ScanMaker 8700" :status :unsupported :url "unsupported/microtek-scanmaker-8700.html" :interface "USB IEEE-1394" :usbid "0x05da" "0x20b1" :comment "Unsupported. See link for details. USB vendor and product ids to be checked." :model "ScanMaker 9600XL" :interface "USB IEEE-1394" :usbid "0x05da" "0x20de" :status :unsupported :comment "Probably unsupported. SCSI seems to work with microtek2 backend." :model "ScanMaker 9800XL" :url "unsupported/microtek-scanmaker-9800.html" :interface "USB SCSI" :usbid "0x05da" "0x20de" :status :unsupported :comment "Partly unsupported. IEEE-1394 works with microtek2 backend. See link." :model "ScanMaker i320" :url "unsupported/microtek-scanmaker-i320.html" :interface "USB" :usbid "0x05da" "0x30e6" :status :unsupported :comment "Unsupported. See link." :model "ScanMaker s400" :url "unsupported/microtek-scanmaker-s400.html" :interface "USB" :usbid "0x05da" "0x201c" :status :unsupported :comment "Unsupported. See link." :model "ScanMaker S400" :url "unsupported/microtek-scanmaker-s400.html" :interface "USB" :usbid "0x05da" "0x300b" :status :unsupported :comment "Unsupported. See link." :model "ScanPort 3000" :url "unsupported/microtek-scanport-3000.html" :interface "USB" :usbid "0x04a7" "0x0224" :status :unsupported :comment "Unsupported. Vendor/Product ids: 0x04a7/0x0224. Realtek RTS8801B?. See link for details." ;******************************************************************************************** :mfg "Konica Minolta" :url "http://www.konicaminolta.com/" :model "Dual Scan III" :url "unsupported/minolta-dual-scan-III.html" :interface "USB" :usbid "0x0686" "0x400d" :status :unsupported :comment "Unsupported. May work with vuescan. See link for details." :model "Dual Scan IV" :url "unsupported/minolta-dual-scan-IV.html" :interface "USB" :usbid "0x132b" "0x000a" :status :unsupported :comment "Unsupported. Works with vuescan. See link for details." :model "DiMAGE Scan Elite 5400" :url "unsupported/minolta-dse-5400.html" :interface "USB IEEE-1394" :usbid "0x0686" "0x400e" :status :unsupported :comment "Probably unsupported. May work with vuescan. See link for details." :model "DiMAGE Scan Elite 5400 2" :url "unsupported/minolta-dse-5400-2.html" :interface "USB" :usbid "0x132b" "0x0012" :status :unsupported :comment "Probably unsupported. See link for details." :model "DiMAGE Scan Multi Pro" :url "unsupported/minolta-dimage-scan-multi-pro.html" :interface "IEEE-1394" :status :unsupported :comment "Probably unsupported. See link for details." :model "magicolor 2480MF" :interface "USB Network" :status :unsupported :comment "Uses a different scanning protocol than the magicolor 1690MF" ;******************************************************************************************** :mfg "Mustek" ; name a manufacturer :url "http://www.mustek.com/" :url "http://www.mustek.de/" :url "http://www.mustek.com.tw/" :model "1200 III EP" :interface "Parport" :status :unsupported :comment "Probably not supported. quarlewm at jmu dot edu offers to temporarily loan such a scanner to anyone who is interested in writing a driver." :model "2400 M" :interface "USB" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :status :unsupported :comment "Probably unsupported. No details known." :model "BearPaw 2400 TA Pro" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x0400" :comment "Not supported. May be supported by mustek_usb2 backend later. See link for some information." :status :unsupported :model "BearPaw 2448 CU Pro" :url "unsupported/mustek-bearpaw-2448-cu-pro.html" :usbid "0x055f" "0x0408" :interface "USB" :comment "Not supported. May be supported by mustek_usb2 backend later. See link for some information." :status :unsupported :model "BearPaw 4800 TA Pro" :url "unsupported/mustek-bearpaw-4800ta-pro.html" :interface "USB" :usbid "0x055f" "0x1000" :comment "Not supported. See link for some information." :status :unsupported :model "BearPaw 4800 TA Pro II" :url "unsupported/mustek-bearpaw-4800ta-pro-ii.html" :interface "USB" :usbid "0x055f" "0x040a" :comment "Not supported. May be supported by mustek_usb2 backend later. See link for some information." :status :unsupported :model "BearPaw 6400 TA Pro" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x040b" :comment "Not supported. May be supported by mustek_usb2 backend later. See link for some information." :status :unsupported :model "Paragon 800 II EP" :interface "Parport" :status :unsupported :comment "Not supported. Maybe similar to 600 II EP (SCSI_over-parport)? In this case it could be supported by the mustek SCSI backend." :model "ScanExpress 600 USB" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x0873" :status :unsupported :comment "Unsupported. Programming information is available." :model "ScanExpress 1200 USB" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x0003" :status :unsupported :comment "Unsupported. Programming information is available." :model "ScanExpress 1200 USB Plus" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :usbid "0x055f" "0x0007" :status :unsupported :comment "Unsupported." :model "ScanExpress 12000 P" :url "http://penguin-breeder.org/?page=mustek_pp" :interface "Parport" :status :unsupported :comment "Not supported. Asic 1505/05." :model "ScanExpress A3 EP" :interface "Parport" :status :unsupported :comment "Not supported. Maybe it will be supported by the mustek_pp backend in future." :model "ScanExpress CardSmart" :url "http://www.meier-geinitz.de/sane/misc/mustek-scanners.html#UNSUPPORTED" :interface "USB" :status :unsupported :comment "Probably unsupported. USB business card scanner. Maybe works as USB storage device?" :model "ScanMagic 9636P" :url "http://alioth-lists.debian.net/pipermail/sane-devel/2003-May/007682.html" :interface "Parport" :status :unsupported :comment "Probably not supported. Same as Mustek 12000 P?. ASIC 1505." ;******************************************************************************************** :mfg "NEC" :url "http://www.nevt.co.jp/" :model "Petiscan" :url "unsupported/nec-petiscan.html" :interface "USB" :usbid "0x0475" "0x0100" :status :unsupported :comment "Most probably unsupported. See link for details. Vendor ID is Relisys/Teco. Not known if it is similar to other Relisys/Teco USB scanners." ;******************************************************************************************** :mfg "Nikon" :url "http://www.nikon.com/" :model "LS-9000 ED" :url "unsupported/nikon-ls9000-ed.html" :interface "IEEE-1394" :status :unsupported :comment "Probably not supported. See link for details. Possibly similar to LS-8000 ED." ;******************************************************************************************** :mfg "Olivetti" :url "http://www.olivetti.com" :model "Job-Jet M400" :url "unsupported/olivetti-job-jet-m400.html" :interface "USB" :usbid "0x0b3c" "0xa880" :status :unsupported :comment "Probably not supported. See link for details." ;******************************************************************************************** :mfg "Olympus" :url "http://www.olympus.com" :model "ES-10P" :url "http://alioth-lists.debian.net/pipermail/sane-devel/2008-December/023326.html" :interface "Parport" :status :unsupported :model "ES-10S" :url "unsupported/olympus-es10s.html" :interface "SCSI" :status :unsupported :comment "Probably not supported. See link for details." ;******************************************************************************************** :mfg "Optoelectronics" :model "Barcode scanner" :interface "USB" :usbid "0x065a" "0x0001" :status :unsupported :comment "Probably not supported." ;******************************************************************************************** :mfg "Optrox" :model "PhotoMaker 3C" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Parport" :status :unsupported :model "PhotoMaker 3E" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Parport" :status :unsupported :model "PhotoMaker 3F" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Proprietary" :status :unsupported :comment "Special ISA card" :model "PhotoMaker 3S" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Parport" :status :unsupported :model "PhotoMaker 6E" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Parport" :status :unsupported :model "PhotoMaker 6F" :url "http://www.df.lth.se/~triad/krad/optrox/" :interface "Proprietary" :status :unsupported :comment "Special ISA card" ;******************************************************************************************** :mfg "Panasonic" :model "KV-SS905C" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool." :model "KV-S2055W" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S2055L" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S2065W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S3065CW" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S3065CL" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S3085" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S3105C" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend. See http://code.google.com/p/kvss905c/ for a standalone scanning tool." :model "KV-S6040W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S6045W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S6050W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S6055W" :interface "SCSI" :status :unsupported :comment "might be supported by matsushita backend." :model "KV-S7065C" :interface "USB SCSI" :status :unsupported :comment "might be supported by matsushita backend." ;******************************************************************************************** :mfg "Pentax" :model "DSmobile USB" :url "unsupported/syscan-travelscan-pro.html" :interface "USB" :usbid "0x0a82" "0x2000" :status :unsupported :comment "Probably not supported. Some information is available." ;******************************************************************************************** :mfg "PIE" :url "http://www.scanace.com/" :comment "Pacific Image Electronics" :model "Primefilm 1800u" :url "unsupported/pie-1800u.html" :interface "USB" :usbid "0x05e3" "0x0120" :status :unsupported :comment "Not supported. See link for details." :model "Primefilm 2700" :interface "USB" :status :unsupported :url "http://alioth-lists.debian.net/pipermail/sane-devel/2009-January/023442.html" :model "Primefilm 3600PRO" :interface "USB IEEE-1394" :status :unsupported :comment "Probably not supported. " :model "Powerslide 3600" :url "unsupported/reflecta-digitdia-3600.html" :interface "USB IEEE-1394" :usbid "0x05e3" "0x0142" :status :unsupported :comment "Probably unsupported. Film scanner that can scan directly from the magazine." :model "PF3650 Pro3 Film Scanner" :url "unsupported/pie-pf3650.html" :interface "USB IEEE-1394" :usbid "0x05e3" "0x0143" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** ;:mfg "Packard Bell" ;******************************************************************************************** :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticFilm 7200" :url "unsupported/plustek-opticfilm-7200.html" :interface "USB" :usbid "0x07b3" "0x0807" :status :unsupported :comment "GL842 based, maybe to be added to genesys backend" :model "OpticPro A3U" :interface "USB" :status :unsupported :comment "Uses Plustek ASIC P99002" :model "OpticPro S6" :interface "USB" :status :unsupported :comment "Uses RealTek chipset (RTL8801D)" :model "OpticPro S12" :url "unsupported/plustek-opticpro-st12.html" :interface "USB" :usbid "0x07b3" "0x0600" :status :unsupported :comment "Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend." :model "OpticPro ST12" :url "unsupported/plustek-opticpro-st12.html" :interface "USB" :usbid "0x07b3" "0x0600" :status :unsupported :comment "Product id 0x0600 is unsupported but may be supported by the genesys backend in future. Product id 0x040b is supported by the gt68xx backend." :model "OpticPro ST16" :url "unsupported/plustek-opticpro-st16.html" :interface "USB" :usbid "0x07b3" "0x0600" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "OpticPro UA18" :interface "USB" :status :unsupported :comment "Probably LM983x based." :model "OpticPro S24" :url "unsupported/plustek-opticpro-st24.html" :interface "USB" :usbid "0x07b3" "0x0601" :status :unsupported :comment "Product id 0x0601 is unsupported but may be supported by the genesys backend in future /GL646). Product id 0x040e is supported by the gt68xx backend." :model "OpticPro ST24" :url "unsupported/plustek-opticpro-st24.html" :interface "USB" :usbid "0x07b3" "0x0601" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "OpticPro S28" :interface "USB" :url "unsupported/plustek-opticpro-s28.html" :usbid "0x07b3" "0x0801" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticPro ST28" :url "unsupported/plustek-opticpro-s28.html" :interface "USB" :usbid "0x07b3" "0x0801" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticPro ST28" :url "unsupported/plustek-opticpro-st28.html" :interface "USB" :usbid "0x07b3" "0x0802" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "Umax AstraScan 4750" :url "unsupported/umax-astrscan-4750.html" :interface "USB" :usbid "0x07b3" "0x0802" :status :unsupported :comment "GL841 based, to be added to genesys backend, rebadged Plustek ST28" :model "OpticPro ST48" :url "unsupported/plustek-opticpro-st48.html" :interface "USB" :usbid "0x07b3" "0x0800" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticPro ST64" :url "unsupported/plustek-opticpro-st64.html" :interface "USB" :usbid "0x07b3" "0x0c00" :status :unsupported :comment "GL843 based, maybe to be added to genesys backend" :model "OpticPro ST64+" :url "unsupported/plustek-opticpro-st64plus.html" :interface "USB" :usbid "0x07b3" "0x0c03" :status :unsupported :comment "GL843 based. See link for more details." :model "PL 806" :url "unsupported/plustek-pl806.html" :interface "USB" :usbid "0x07b3" "0x0c0c" :status :unsupported :comment "Unsupported. See link for more details." :model "SmartOffice PL 812" :url "unsupported/plustek-pl812.html" :interface "USB" :usbid "0x07b3" "0x0c0d" :status :unsupported :comment "Unsupported. See link for more details." :model "OpticSlim 500" :url "unsupported/plustek-opticslim-500.html" :interface "USB" :usbid "0x07b3" "0x0458" :status :unsupported :comment "Unsupported. See link for more details." :model "OpticSlim 2420" :url "unsupported/plustek-opticslim-2420.html" :interface "USB" :usbid "0x07b3" "0x0806" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticSlim 2420+" :url "unsupported/plustek-opticslim-2420plus.html" :interface "USB" :usbid "0x07b3" "0x0914" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "OpticWorks 2000" :interface "Parport" :status :unsupported :comment "Multifunction device. No further information available." :model "OptiCard 600+" :interface "USB" :status :unsupported :comment "Business card reader. No further information available." :model "ScanCopy 115" :url "unsupported/plustek-scancopy-115.html" :interface "USB" :usbid "0x07b3" "0x081c" :status :unsupported :comment "GL841 based, to be added to genesys backend" :model "Spectra ADF" :interface "Proprietary" :status :unsupported :comment "Unsupported. Uses proprietary ISA card that also provides power and is labelled GPS-1 PAGE-A from Taiwan. Other labels on the scanner include ADF Color Scanner and SF600AS. Maybe the same as the IBM ADF Color Scanner?" :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0005" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0007" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x000f" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0012" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0014" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." :model "Unknown Plustek Device" :interface "USB" :usbid "0x07b3" "0x0016" :status :unsupported :comment "Probably unsupported. Scanner name not known yet." ;******************************************************************************************** :mfg "PLANon" :url "http://www.planon.com/" :model "DocuPen RC800" :interface "USB" :usbid "0x18dd" "0x1000" :status :unsupported :comment "Probably not supported. No details known." :model "DocuPen R700" :url "unsupported/planon-docupen-r700.html" :interface "USB" :usbid "0x10c4" "0xea60" :status :unsupported :comment "Probably not supported. See link for details." :model "DocuPen (DPEN-BW)" :interface "USB" :status :unsupported :comment "Probably not supported. No details known." ;******************************************************************************************** :mfg "Primax" :url "http://www.primax.nl/" :model "Colorado 600U" :url "unsupported/primax-colorado-600u.html" :interface "USB" :usbid "0x0461" "0x0341" :status :unsupported :comment "Not supported. Some information is available." :model "Colorado 1200p" :interface "Parport" :url "http://home2.swipnet.se/~w-25069/pxscan.html" :status :unsupported :comment "Unsupported by SANE. But is reported to partly work with pxscan. See link." :model "Colorado 1200u" :interface "USB" :usbid "0x0461" "0x0361" :status :unsupported :comment "Probably unsupported. No details known." :model "Primascan Colorado 2600u" :url "unsupported/visioneer-onetouch4400.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Unsupported. Same as Visioneer Onetouch 4400. See link for details." :model "Colorado Direct 600" :url "http://home2.swipnet.se/~w-25069/pxscan.html" :interface "Parport" :status :unsupported :comment "Not supported. However, a stand-alone program is available." :model "Colorado Direct 9600" :url "http://home2.swipnet.se/~w-25069/pxscan.html" :interface "Parport" :status :unsupported :comment "Not supported. However, a stand-alone program is available." :model "Colorado USB 9600" :url "unsupported/primax-colorado-usb-9600.html" :interface "USB" :usbid "0x0461" "0x0340" :status :unsupported :comment "Not supported. See link for details." :model "G2-300" :interface "USB" :usbid "0x0461" "0x0300" :status :unsupported :comment "Probably unsupported. No details known." :model "G2-300 #2" :interface "USB" :usbid "0x0461" "0x0302" :status :unsupported :comment "Probably unsupported. No details known." :model "G2E-300" :interface "USB" :usbid "0x0461" "0x0301" :status :unsupported :comment "Probably unsupported. No details known." :model "G2E-300 #2" :usbid "0x0461" "0x0303" :interface "USB" :status :unsupported :comment "Probably unsupported. No details known." :model "G2-600" :usbid "0x0461" "0x0380" :interface "USB" :status :unsupported :comment "Probably unsupported. No details known." :model "G2-600 #2" :interface "USB" :usbid "0x0461" "0x0382" :status :unsupported :comment "Probably unsupported. No details known." :model "G2E-600" :usbid "0x0461" "0x0383" :interface "USB" :status :unsupported :comment "Probably unsupported. No details known." :model "OneTouch 5300" :interface "Parport" :status :unsupported :comment "Not supported." :model "ReadyScan 636i" :usbid "0x0461" "0x0381" :interface "USB" :status :unsupported :comment "Probably unsupported. No details known." :model "Slim-Line 1200" :interface "USB" :status :unsupported :comment "Maybe GL646. Maybe similar to Medion MD 6228?" :model "Onetouch 8920" :url "unsupported/visioneer-onetouch8920.html" :interface "USB" :usbid "0x0461" "0x0371" :status :unsupported :comment "Not supported. Look similar to Visioneer Onetouch 8920 (same USB product id)." ;******************************************************************************************** :mfg "Prolink" :url "http://www.fida.com/" :model "Winscan Pro 2448U" :url "unsupported/prolink-2448u.html" :interface "USB" :usbid "0x06dc" "0x0014" :status :unsupported :comment "Not supported. Some information is available. RealTek RTS8801." :model "Winscan Pro 2000" :interface "USB Parport" :status :unsupported :comment "Not supported. No further information available." ;******************************************************************************************** :mfg "Quato" :url "http://www.quato.de/" :model "X-Finity" :interface "SCSI" :status :unsupported :comment "Probably not supported. No details yet. Originally manufactured by PFU?" :model "X-Finity Ultra" :interface "USB IEEE-1394" :status :unsupported :comment "Probably not supported. No details yet." ;******************************************************************************************** :mfg "Reflecta" :model "DigitDia 3600" :url "unsupported/reflecta-digitdia-3600.html" :interface "USB IEEE-1394" :usbid "0x05e3" "0x0142" :status :unsupported :comment "Film scanner that can scan directly from the magazine." :model "iScan 1800" :url "unsupported/reflecta-iscan-1800.html" :interface "USB" :usbid "0x05e3" "0x0120" :status :unsupported :comment "Probably unsupported. See link for details." :model "ProScan 4000" :url "unsupported/reflecta-proscan-4000.html" :interface "USB IEEE-1394" :usbid "0x05e3" "0x0143" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Relisys" :model "Eclipse 1200U" :url "unsupported/relisys-eclipse-1200u.html" :interface "USB" :usbid "0x0475" "0x0103" :status :unsupported :comment "Probably unsupported. See link for details." :model "Scorpio Ultra 3" :url "unsupported/relisys-scorpio-ultra3.html" :interface "USB" :usbid "0x0475" "0x0210" :status :unsupported :comment "Probably unsupported. See link for details." :model "Episode" :url "unsupported/relisys-episode.html" :interface "USB" :usbid "0x0475" "0x0103" :status :unsupported :comment "Probably unsupported. See link for details." :model "AVEC II E3" :interface "Parport" :status :unsupported :comment "Parport version of AVEC II S3?. See bug #304992 for details" ;******************************************************************************************** :mfg "Samsung" :model "SCX-4725FN" :url "unsupported/samsung-scx-4725.html" :interface "USB" :usbid "0x04e8" "0x341f" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** :mfg "Scanshell" :model "800N" :url "unsupported/scanshell-800n.html" :interface "USB" :usbid "0x0a82" "0x6605" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** :mfg "Sicos" :model "DMS 2000" :url "mailto:ehaase@inf.fu-berlin.de" :interface "proprietary" :status :unsupported :comment "Not supported until now. Work on a backend has started, contact the author for details (see link)" ;******************************************************************************************** :mfg "Siemens" ; name a manufacturer :url "http://www.siemens.com/" :model "ID Mouse Professional" :interface "USB" :usbid "0x0681" "0x0005" :status :unsupported :comment "Not supported." :model "Cherry FingerTIP ID Board - Sensor" :interface "USB" :usbid "0x0681" "0x0010" :status :unsupported :comment "Not supported." ;******************************************************************************************** :mfg "SmartDisk" :model "SmartScan 3600" :interface "USB IEEE-1394" :status :unsupported :comment "Probably not supported. Same as PIE Primefilm 2600 PRO." ;******************************************************************************************** :mfg "Spot Technology" :comment "Spot seems have gone out of business." :model "Maxiscan A4" :url "http://www.el-profesor.net/spoonset/" :interface "proprietary" :status :unsupported :comment "Not supported until now. Work on a backend has started, see link for more information." :model "ScanTak 2c" :url "http://www.el-profesor.net/spoonset" :interface "proprietary" :status :unsupported :comment "Not supported. Work on a backend has started, see link for more information." :model "ScanTak 3c" :url "http://www.el-profesor.net/spoonset" :interface "proprietary" :status :unsupported :comment "Not supported. Work on a backend has started, see link for more information." ;******************************************************************************************** :mfg "Syscan" :model "TravelScan FS-531" :url "unsupported/syscan-travelscan-fs531.html" :interface "USB" :usbid "0x0a82" "0x0530" :status :unsupported :comment "Not supported. May work with the Plustek backend in future. See link for details." :model "TravelScan Pro" :url "unsupported/syscan-travelscan-pro.html" :interface "USB" :usbid "0x0a82" "0x2000" :status :unsupported :comment "Probably not supported. Some information is available." ;******************************************************************************************** :mfg "Tamarack" :model "Artiscan 9600" ; name models for above-specified mfg. :interface "Parport" :status :unsupported :url "http://www.autistici.org/tamarhack/" :comment "Unsupported at the moment. See link for a project for that scanner taht may support it in future." :model "Artiscan 9600 pro 36" ; name models for above-specified mfg. :interface "Parport" :status :unsupported :url "http://www.autistici.org/tamarhack/" :comment "Unsupported at the moment. See link for a project for that scanner." :model "Artiscan 2400FS" :url "unsupported/tamarack-artiscan-2400.html" :interface "USB" :usbid "0x05e3" "0x0100" :status :unsupported :comment "Unsupported. See link for more information." ;******************************************************************************************** :mfg "TCE" :comment "Brasilian vendor." :url "http://www.tce.com.br/" :model "MK600U" :url "unsupported/memorex-maxx-6136u.html" :interface "USB" :usbid "0x0461" "0x0346" :status :unsupported :comment "Not supported. Some information is available." :model "S450" :url "http://home2.swipnet.se/~w-25069/pxscan.html" :interface "Parport" :status :unsupported :comment "Not supported by SANE but is reported to work with pxscan (see link)." ;******************************************************************************************** :mfg "Teco" :url "http://www.tecoimage.com.tw/" :model "VM6509F" :url "unsupported/teco-vm6509.html" :interface "USB" :usbid "0x080d" "0x0102" :status :unsupported :comment "Probably unsupported. See link for details." ;******************************************************************************************** :mfg "Tiny" :model "FU661E" :url "unsupported/visioneer-onetouch4400.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "Trust" :url "http://www.trust-site.com" :model "CombiScan 19200" :url "unsupported/trust-combiscan-19200.html" :interface "Parport USB" :usbid "0x05cb" "0x1483" :status :unsupported :comment "Unsupported. See link for details." :model "EasyScan 19200" :url "http://alioth-lists.debian.net/pipermail/sane-devel/2008-October/022955.html" :interface "Parport" :status :unsupported :model "SCSI Scan 19200 -Excellence Series-" :url "unsupported/trust-scsi-scan-19200.html" :interface "SCSI" :status :unsupported :comment "Unsupported. See link for details." ;******************************************************************************************** :mfg "UMAX" :url "http://www.umax.com/" :model "Astra 2500" :url "unsupported/umax-astra-2500.html" :interface "USB" :usbid "0x0461" "0x0374" :status :unsupported :comment "Probably not supported. See link for details." :model "Astra 2850" :url "unsupported/plustek-opticpro-st24.html" :interface "USB" :usbid "0x07b3" "0x0601" :status :unsupported :comment "Probably not supported. Same IDs as Plustek OpticPro ST24. See link for details." :model "Astra 3000" :url "unsupported/umax-astra-3000.html" :interface "USB" :usbid "0x0461" "0x038a" :status :unsupported :comment "Probably not supported. See link for details." :model "Astra 3600" :url "unsupported/umax-astra-3600.html" :interface "USB" :usbid "0x0461" "0x038a" :status :unsupported :comment "Probably not supported. See link for details." :model "Astra 4000" :url "unsupported/umax-astra-4000.html" :interface "USB" :usbid "0x1606" "0x1030" :status :unsupported :comment "Not supported. See link for details." :model "Astra 4100" :url "unsupported/umax-astra-4100.html" :interface "USB" :usbid "0x0461" "0x038c" :status :unsupported :comment "Not supported, to be added to genesys backend." :model "Astra 4500" :url "unsupported/umax-astra-4500.html" :interface "USB" :usbid "0x0638" "0x0a10" :status :unsupported :comment "GL646 based, to be added to genesys backend. Avision iVina FB1600 clone" :model "Astra 4600" :interface "USB" :status :unsupported :comment "Probably not supported, no details known." :model "Astra 4700" :url "unsupported/umax-astra-4700.html" :interface "USB" :usbid "0x0638" "0x0a20" :status :unsupported :comment "GL646/GL660 based. Avision iVina FB1800 clone." :model "Astra 6700" :interface "USB" :usbid "0x0638" "0x0a30" :status :unsupported :comment "Not supported. No chipset information available. Same as Avision iVina FB2400." :model "AstraSlim" :url "unsupported/umax-astraslim.html" :usbid "0x080d" "0x0104" :interface "USB" :status :unsupported :comment "Probably not supported currently. See link for more details." :model "AstraSlim 1200" :url "unsupported/umax-astraslim-1200.html" :interface "USB" :usbid "0x080d" "0x0110" :status :unsupported :comment "See link for more details." :model "AstraSlim 6000" :url "unsupported/umax-astraslim-6000.html" :interface "USB" :usbid "0x080d" "0x0104" :status :unsupported :comment "Probably not supported currently. See link for more details." :model "Nete3470'" :interface "Parport" :status :unsupported :comment "Probably not supported. No details known.." :model "Powerlook 180" :url "unsupported/umax-powerlook-180.html" :interface "USB" ;:usbid "0x3902" "0xc470" #correct? :status :unsupported :comment "Probably not supported. See link for details." :model "Powerlook 1000 USB" :interface "USB" :status :unsupported :comment "Probably not supported. No further information available." ;******************************************************************************************** :mfg "Vantas" :model "3000" :url "unsupported/visioneer-onetouch4800.html" :interface "USB" :usbid "0x04a7" "0x0224" :status :unsupported :comment "Not supported. See link for more details." ;******************************************************************************************** :mfg "Visioneer" :url "http://www.visioneer.com/" :model "6200" :interface "USB" :usbid "0x0461" "0x0345" :status :unsupported :comment "Not supported. Is reported to use the E5 chipset. Uses a Primax ID. Looks similar to Primascan Colorado 2600u." :model "6200 EPP/USB" :interface "USB" :usbid "0x04a7" "0x0311" :status :unsupported :comment "Not supported. Id is from Primax? Yet another scanner with the same name?" :model "9420" :url "unsupported/visioneer-9420.html" :interface "USB" :usbid "0x0461" "0x03a8" :status :unsupported :comment "Unsupported. See link for details." :model "9450 USB" :url "unsupported/visioneer-9450-usb.html" :interface "USB" :usbid "0x04a7" "0x0421" :status :unsupported :comment "Unsupported. See link for details." :model "Onetouch 4400" :url "unsupported/visioneer-onetouch4400.html" :interface "USB" :usbid "0x0461" "0x0347" :status :unsupported :comment "Not supported. E5 chipset? See link for more details." :model "OneTouch 4800 USB" :url "unsupported/visioneer-onetouch4800.html" :interface "USB" :usbid "0x04a7" "0x0224" :status :unsupported :comment "Unsupported. Seems to use Realtek RTS8801B. Same as Microtek Scanport 3000. See link for details." :model "OneTouch 5300 USB" :url "unsupported/visioneer-onetouch5300.html" :interface "USB" :usbid "0x04a7" "0x0226" :status :unsupported :comment "Not supported. Chipset is RTS8801B(?). See link for output of /proc/bus/usb/devices." :model "OneTouch 5300" :interface "USB" :usbid "0x04a7" "0x0221" :status :unsupported :comment "Not supported. Yet another scanner with this name?" :model "OneTouch 5800 USB" :url "unsupported/visioneer-onetouch5800.html" :interface "USB" :usbid "0x04a7" "0x0226" :status :unsupported :comment "Unsupported. 48 bit scanner, doesn't work with viceo backend. RTS8801C." :model "OneTouch 6600" :url "unsupported/visioneer-onetouch6600.html" :interface "USB" :usbid "0x04a7" "0x022a" :status :unsupported :comment "Unsupported. See link for details." :model "Onetouch 7100" :url "unsupported/visioneer-onetouch7100.html" :interface "USB" :usbid "0x04a7" "0x0229" :status :unsupported :comment "GL646 based, to be added to genesys backend" :model "Onetouch 7700" :url "unsupported/visioneer-onetouch7700.html" :interface "USB" :usbid "0x04a7" "0x0380" :status :unsupported :comment "LM9832/3 based, to be added to plustek backend" :model "OneTouch 8100" :url "unsupported/visioneer-onetouch8100.html" :interface "USB" :usbid "0x04a7" "0x0321" :status :unsupported :comment "Unsupported. See link for details." :model "Onetouch 8700" :url "unsupported/visioneer-onetouch8920.html" :interface "USB" :usbid "0x04a7" "0x0371" :status :unsupported :comment "Not supported. See link for details." :model "Onetouch 8900" :url "unsupported/visioneer-onetouch8920.html" :interface "USB" :usbid "0x04a7" "0x0371" :status :unsupported :comment "Not supported. Same as 8920 but without TA?" :model "Onetouch 8920" :url "unsupported/visioneer-onetouch8920.html" :interface "USB" :usbid "0x04a7" "0x0371" :status :unsupported :comment "Not supported. Same as 8700 and 8900 but includes a TA. Uses a Primax ID. Chipset is RTS8801C. See link for output of /proc/bus/usb/devices." :model "Onetouch 9000" :url "unsupported/visioneer-onetouch9020.html" :interface "USB" :usbid "0x04a7" "0x022c" :status :unsupported :comment "Not supported. See link for details." :model "Onetouch 9020" :url "unsupported/visioneer-onetouch9020.html" :interface "USB" :usbid "0x04a7" "0x022c" :status :unsupported :comment "Not supported. See link for details." :model "Onetouch 9320" :url "unsupported/visioneer-onetouch9320.html" :interface "USB" :usbid "0x04a7" "0x0362" :status :unsupported :comment "Probably not supported. See link for details." :model "Onetouch Pro 8800" :url "unsupported/visioneer-onetouch8820.html" :interface "USB" :usbid "0x04a7" "0x0410" :status :unsupported :comment "Probably not supported. See link for details." :model "Onetouch Pro 8820" :url "unsupported/visioneer-onetouch8820.html" :interface "USB" :usbid "0x04a7" "0x0410" :status :unsupported :comment "Probably not supported. See link for details." :model "PaperPort 3100b" :url "unsupported/visioneer-paperport-3100b.html" :interface "Parport" :status :unsupported :comment "Most probably not supported. See link for details." :model "PaperPort 6100" :interface "Parport" :status :unsupported :comment "Most probably not supported. More details would be appreciated." :model "PaperPort OneTouch" :url "unsupported/visioneer-paperport-onetouch.html" :interface "Parport" :status :unsupported :comment "Most probably not supported. See link for details." :model "Strobe Pro USB" :url "unsupported/visioneer-strobe-pro-usb.html" :interface "USB" :usbid "0x04a7" "0x0102" :status :unsupported :comment "Not supported. See link for details." ;******************************************************************************************** :model "4800 One Touch" :url "unsupported/xerox-4800-onetouch.html" :interface "USB" :usbid "0x04a7" "0x03a0" :status :unsupported :comment "Unsupported. See link for details. Different id compared to One Touch 4800?" :model "DocuImage 620S" :url "unsupported/xerox-docuimage-620s.html" :interface "SCSI" :status :unsupported :comment "Not supported. See link for more details." :model "DocuMate 510" :url "unsupported/xerox-documate-510.html" :interface "USB" :status :unsupported :usbid "0x04a7" "0x0446" :comment "Not supported. See link for more details." :model "DocuMate 510" :url "unsupported/xerox-documate-510.html" :interface "USB" :status :unsupported :usbid "0x04a7" "0x047c" :comment "Not supported. See link for more details. Yet another USB id." :model "One Touch 4800" :url "unsupported/visioneer-onetouch4800.html" :interface "USB" :usbid "0x04a7" "0x0224" :status :unsupported :comment "Unsupported. See link for details. Different id compared to 4800 One Touch?" :model "WorkCentre 470cx" :url "unsupported/xerox-workcentre-470cx.html" :interface "Parport" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre M15i" :url "unsupported/xerox-workcentre-m15i.html" :interface "USB" :usbid "0x0924" "0xffef" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre XK35c" :url "unsupported/xerox-workcentre-xk35c.html" :interface "USB Parport" :usbid "0x043d" "0x0020" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre XK50cx" :url "unsupported/xerox-workcentre-xk50cx.html" :interface "USB" :usbid "0x04e8" "0x3903" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre Pro 412" :url "unsupported/xerox-workcentre-pro412.html" :interface "USB Parport" :usbid "0x043d" "0x4303" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre PE16" :url "unsupported/xerox-workcentre-pe16.html" :interface "USB Parport" :usbid "0x0924" "0x4220" :status :unsupported :comment "Not supported. See link for more details." :model "WorkCentre PE120i" :url "unsupported/xerox-workcentre-pe120i.html" :interface "USB" :usbid "0x0924" "0x4237" :status :unsupported :comment "Not supported. See link for more details." ;******************************************************************************************** ;******************************************************************************************** ;******************************************************************************************** :devicetype :vidcam :mfg "Biolux" :model "654 (micrOcular)" :url "unsupported/biolux-654.html" :interface "USB" :usbid "0x0923" "0x010f" :status :unsupported :comment "Not supported yet. See link for more details." ;******************************************************************************************** :mfg "Grandtek Scopecam" :model "8x30 Binocular & Digital Camera" :url "unsupported/grandtech-scopecam.html" :interface "USB" :usbid "0x0797" "0x801c" :status :unsupported :comment "Not Supported yet. See link for more details." ;******************************************************************************************** ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/pnm.desc0000666000000000000000000000034113615534521016104 00000000000000:backend "pnm" :version "1.0.8 (unmaintained)" :manpage "sane-pnm" :url "mailto:henning@meier-geinitz.de" :devicetype :api :desc "Reads PNM files" :comment "Used for debugging frontends. Obsolete, use test backend instead." sane-backends-1.0.29/doc/descriptions/xerox_mfp.desc0000666000000000000000000001566313615534521017336 00000000000000:backend "xerox_mfp" :version "1.0-13" :manpage "sane-xerox_mfp" :devicetype :scanner :mfg "Xerox" :url "http://www.office.xerox.com/" :model "Phaser 3200MFP" :interface "USB" :usbid "0x0924" "0x3da4" :comment "All these models are turned out to be rebranded Samsungs." :status :complete :url "http://www.office.xerox.com/multifunction-printer/multifunction-under-30ppm/phaser-3200mfp/spec-enus.html" :model "Phaser 6110MFP" :interface "USB" :usbid "0x0924" "0x3d5d" :status :good :model "WorkCentre 3119 Series" :interface "USB" :usbid "0x0924" "0x4265" :status :good :model "WorkCentre 4118 Series" :interface "USB" :usbid "0x0924" "0x420c" :status :good :model "WorkCentre 3210" :interface "USB" :usbid "0x0924" "0x4293" :status :good :model "WorkCentre 3220" :interface "USB" :usbid "0x0924" "0x4294" :status :good :mfg "Dell" :url "http://www.dell.com/" :model "Dell MFP Laser Printer 1815dn" :interface "USB" :usbid "0x413c" "0x5124" :status :good :model "Dell 1235cn" :interface "USB" :usbid "0x413c" "0x5310" :status :good :mfg "Samsung" :url "http://www.samsung.com" :model "X4300 Series" :interface "USB" :usbid "0x04e8" "0x3324" :status :untested :model "K4350 Series" :interface "USB" :usbid "0x04e8" "0x3325" :status :untested :model "X7600 Series" :interface "USB" :usbid "0x04e8" "0x3326" :status :untested :model "K7600 Series" :interface "USB" :usbid "0x04e8" "0x3327" :status :untested :model "K703 Series" :interface "USB" :usbid "0x04e8" "0x3331" :status :untested :model "X703 Series" :interface "USB" :usbid "0x04e8" "0x3332" :status :untested :model "SCX-4x16" :interface "USB" :usbid "0x04e8" "0x3409" :status :unsupported :model "SCX-6x20" :interface "USB" :usbid "0x04e8" "0x340d" :status :untested :model "MFP-560" :interface "USB" :usbid "0x04e8" "0x340e" :status :untested :model "MFP-750" :interface "USB" :usbid "0x04e8" "0x340f" :status :untested :model "SCX-4x20" :interface "USB" :usbid "0x04e8" "0x3412" :status :untested :model "SCX-4100" :interface "USB" :usbid "0x04e8" "0x3413" :status :good :model "SCX-4x21" :interface "USB" :usbid "0x04e8" "0x3419" :status :untested :model "SCX-5x30" :interface "USB" :usbid "0x04e8" "0x341a" :status :untested :model "SCX-4200" :interface "USB" :usbid "0x04e8" "0x341b" :status :good :model "CLX-3160" :interface "USB" :usbid "0x04e8" "0x341c" :status :untested :model "SCX-6x22" :interface "USB" :usbid "0x04e8" "0x341d" :status :untested :model "SCX4725" :interface "USB" :usbid "0x04e8" "0x341f" :status :untested :model "SCX4725-FN" :interface "USB" :usbid "0x04e8" "0x341f" :status :good :model "SCX-6x45" :interface "USB" :usbid "0x04e8" "0x3420" :status :untested :model "CLX-8380" :interface "USB" :usbid "0x04e8" "0x3421" :status :untested :model "CLX-2160" :interface "USB" :usbid "0x04e8" "0x3425" :status :good :model "SCX-4500" :interface "USB" :usbid "0x04e8" "0x3426" :status :good :model "CLX-6200" :interface "USB" :usbid "0x04e8" "0x3427" :status :untested :model "CLX-6240" :interface "USB" :usbid "0x04e8" "0x3428" :status :untested :model "SCX-6x55" :interface "USB" :usbid "0x04e8" "0x3429" :status :good :model "CLX-3170fn (CLX-3170 Series)" :interface "USB" :usbid "0x04e8" "0x342a" :status :good :model "CLX-3175FW" :interface "USB" :usbid "0x04e8" "0x342a" :status :good :model "SCX-4500W" :interface "USB Ethernet" :usbid "0x04e8" "0x342b" :status :basic :model "SCX-4824 (SCX-4x24 Series)" :interface "USB" :usbid "0x04e8" "0x342c" :status :good :model "SCX-4828FN (SCX-4x28 Series)" :interface "USB" :usbid "0x04e8" "0x342d" :status :good :model "SCX-4300" :interface "USB" :usbid "0x04e8" "0x342e" :status :good :model "SCX-5835_5935" :interface "USB" :usbid "0x04e8" "0x342f" :status :good :model "SCX-5635" :interface "USB" :usbid "0x04e8" "0x3430" :status :untested :model "SCX-4x26" :interface "USB" :usbid "0x04e8" "0x3432" :status :untested :model "SCX-4600" :interface "USB" :usbid "0x04e8" "0x3433" :status :good :model "SCX-4623" :interface "USB" :usbid "0x04e8" "0x3434" :status :good :model "MFP-65x" :interface "USB" :usbid "0x04e8" "0x3435" :status :untested :model "SCX-6545" :interface "USB" :usbid "0x04e8" "0x3437" :status :good :model "CLX-8385" :interface "USB" :usbid "0x04e8" "0x3439" :status :untested :model "CLX-6220" :interface "USB" :usbid "0x04e8" "0x343a" :status :good :model "CLX-6250" :interface "USB" :usbid "0x04e8" "0x343b" :status :untested :model "SCX-4825FN (SCX-4x25 Series)" :interface "USB" :usbid "0x04e8" "0x343c" :status :good :model "CLX-3185" :interface "USB" :usbid "0x04e8" "0x343d" :status :good :model "CLX-8540" :interface "USB" :usbid "0x04e8" "0x343f" :status :untested :model "SCX-4623FW" :interface "USB Ethernet" :usbid "0x04e8" "0x3440" :status :good :model "SCX-3205W (SCX-3200 Series)" :interface "USB Ethernet" :usbid "0x04e8" "0x3441" :status :good :model "SCX-6545X" :interface "USB" :usbid "0x04e8" "0x3442" :status :good :model "SCX-6x55X" :interface "USB" :usbid "0x04e8" "0x3443" :status :good :model "CLX-8385X" :interface "USB" :usbid "0x04e8" "0x3444" :status :good :model "SCX-5835_5935X" :interface "USB" :usbid "0x04e8" "0x3446" :status :good :model "SCX-4833FD" :interface "USB" :usbid "0x04e8" "0x344b" :status :good :model "SCX-4835FD" :interface "Ethernet" :usbid "0x04e8" "0x344b" :status :good :model "SCX-3405W" :interface "Ethernet" :status :good :model "SCX-3400" :interface "USB" :usbid "0x04e8" "0x344f" :status :good :model "SF-760" :interface "USB" :usbid "0x04e8" "0x3450" :status :untested :model "SCX-4729FD" :interface "USB" :usbid "0x04e8" "0x3453" :status :good :model "CLX-6260" :interface "USB" :usbid "0x04e8" "0x3455" :status :good :model "CLX-3300 Series" :interface "USB" :usbid "0x04e8" "0x3456" :status :good :model "SCX-470x" :interface "USB" :usbid "0x04e8" "0x3457" :status :untested :model "CLX-4190" :interface "USB" :usbid "0x04e8" "0x345a" :status :good :model "SCX-4650 4x21S Series" :interface "USB" :usbid "0x04e8" "0x345b" :status :untested :model "M337x 387x 407x Series" :interface "USB" :usbid "0x04e8" "0x3460" :status :good :model "M267x 287x Series" :interface "USB" :usbid "0x04e8" "0x3461" :status :unsupported :model "SCX-681x" :interface "USB" :usbid "0x04e8" "0x3466" :status :untested :model "C460" :interface "USB" :usbid "0x04e8" "0x3468" :status :untested :model "M2070" :interface "USB" :usbid "0x04e8" "0x3469" :status :good :model "C1860FW" :interface "USB" :usbid "0x04e8" "0x346b" :status :untested :model "M458x Series" :interface "USB" :usbid "0x04e8" "0x346f" :status :untested :model "M4370 5370 Series" :interface "USB" :usbid "0x04e8" "0x3471" :status :untested :model "X401 Series" :interface "USB" :usbid "0x04e8" "0x3477" :status :untested :model "K401 Series" :interface "USB" :usbid "0x04e8" "0x3478" :status :untested :model "C480W" :interface "USB" :usbid "0x04e8" "0x347e" :status :untested :model "K3250 Series" :interface "USB" :usbid "0x04e8" "0x3481" :status :untested :model "X3220 Series" :interface "USB" :usbid "0x04e8" "0x3482" :status :untested sane-backends-1.0.29/doc/descriptions/sm3840.desc0000666000000000000000000000511413615534521016253 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "sm3840" ; name of backend :version "1.1 (unmaintained)" ; version of backend (or "unmaintained") :manpage "sane-sm3840" ; name of manpage (if it exists) :url "http://www.ziplabel.com/sm3840/" ; backend's web page :comment "This reverse-engineered backend supports the USB ScanMaker 3840 model" ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Microtek" ; name a manufacturer :url "http://www.microtek.com/" ; manufacturer's URL :comment "Microtek makes a wide variety of devices." ; comment about the manufacturer :model "ScanMaker 3840" ; name models for above-specified mfg. :status :good ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :usbid "0x05da" "0x30d4" :comment "8 and 16 bit, color and grayscale" ; comment about the model :model "ScanMaker 4800" ; name models for above-specified mfg. :status :good ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "USB" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :usbid "0x05da" "0x30cf" :comment "Same hardware as SM3840, different color box" ; comment ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; :status specifier is optional after :model and at the top-level sane-backends-1.0.29/doc/descriptions/genesys.desc0000666000000000000000000002016213615534521016772 00000000000000:backend "genesys" :version "1.0-63" :manpage "sane-genesys" :comment "Only the USB scanners mentioned below are currently supported." :url "http://www.meier-geinitz.de/sane/genesys-backend/" :devicetype :scanner ; ----------------------------------------------------------------------------- :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticBook 3600" :interface "USB" :usbid "0x07b3" "0x0900" :status :basic :comment "Has a Primax USB ID" :model "OpticFilm 7200i" :interface "USB" :usbid "0x07b3" "0x0c04" :status :basic :model "OpticFilm 7300" :interface "USB" :usbid "0x07b3" "0x0c12" :status :basic :model "OpticFilm 7500i" :interface "USB" :usbid "0x07b3" "0x0c13" :status :basic ; ----------------------------------------------------------------------------- :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.com/" :url "http://www.medion.de/" :model "MD5345" :interface "USB" :usbid "0x0461" "0x0377" :status :good :comment "Has a Primax USB ID" :model "MD6228" :interface "USB" :usbid "0x0461" "0x0377" :status :good :comment "Has a Primax USB ID. Same as MD5345" :model "MD6471" :interface "USB" :usbid "0x0461" "0x0377" :status :complete :comment "Has a Primax USB ID. Same as MD5345" ; ----------------------------------------------------------------------------- :mfg "Hewlett-Packard" :url "http://www.hp.com/" :model "ScanJet 2300C" :interface "USB" :usbid "0x03f0" "0x0901" :status :complete :comment "600x1200 dpi max" :model "ScanJet 2400C" :interface "USB" :usbid "0x03f0" "0x0a01" :status :complete :comment "1200x1200 dpi max" :model "ScanJet G2410" :interface "USB" :usbid "0x03f0" "0x0a01" :status :basic :comment "clone of the HP 2400C" :model "ScanJet 3670" :interface "USB" :usbid "0x03f0" "0x1405" :status :complete :comment "1200x1200 dpi max, complete transparency adaptor support" :model "ScanJet 3690C" :interface "USB" :usbid "0x03f0" "0x1405" :status :complete :comment "1200x1200 dpi max, same as HP 3670" :model "ScanJet 4850C" :interface "USB" :usbid "0x03f0" "0x1b05" :status :good :comment "resolution from 100 to 2400 supported, UTA not supported yet" :model "ScanJet G4010" :interface "USB" :usbid "0x03f0" "0x4505" :status :good :comment "resolution from 100 to 2400 supported, UTA not supported yet" :model "ScanJet G4050" :interface "USB" :usbid "0x03f0" "0x4605" :status :good :comment "resolution from 100 to 2400 supported, UTA not supported yet" :model "ScanJet N6310" :interface "USB" :usbid "0x03f0" "0x4705" :status :untested :comment "Not supported yet" ; ----------------------------------------------------------------------------- :mfg "Canon" :url "http://www.canon.com/" :model "CanoScan LiDE 35" :interface "USB" :usbid "0x04a9" "0x2213" :status :good :comment "Same ids as LiDE 50." :model "CanoScan LiDE 40" :interface "USB" :usbid "0x04a9" "0x2213" :status :good :comment "Same ids as LiDE 50." :model "CanoScan LiDE 50" :interface "USB" :usbid "0x04a9" "0x2213" :status :good :model "CanoScan LiDE 60" :interface "USB" :usbid "0x04a9" "0x221c" :status :good :model "CanoScan LiDE 80" :interface "USB" :usbid "0x04a9" "0x2214" :status :basic :comment "No 2400 dpi support, slow speed at lower resolution" :model "CanoScan LiDE 100" :interface "USB" :usbid "0x04a9" "0x1904" :status :complete :comment "GL847 based, resolution from 75 to 2400 dpi" :model "CanoScan LiDE 110" :interface "USB" :usbid "0x04a9" "0x1909" :status :complete :comment "GL124 based, resolution from 75 to 2400 dpi" :model "CanoScan LiDE 120" :interface "USB" :usbid "0x04a9" "0x190e" :status :complete :comment "GL124+ based, resolution from 75 to 2400 dpi" :model "CanoScan LiDE 200" :interface "USB" :usbid "0x04a9" "0x1905" :status :complete :comment "GL847 based, resolution from 75 to 4800 dpi" :model "CanoScan LiDE 210" :interface "USB" :usbid "0x04a9" "0x190a" :status :complete :comment "GL124 based, resolution from 75 to 4800 dpi" :model "CanoScan LiDE 220" :interface "USB" :usbid "0x04a9" "0x190f" :status :complete :comment "GL124+ based, resolution from 75 to 4800 dpi" :model "CanoScan 4400F" :interface "USB" :usbid "0x04a9" "0x2228" :status :basic :comment "GL843 based" :model "CanoScan 5600F" :interface "USB" :usbid "0x04a9" "0x1906" :status :unsupported :comment "GL847 based, to be added to the genesys backend" :model "CanoScan 8400F" :url "unsupported/canon-8400f.html" :interface "USB" :usbid "0x04a9" "0x221e" :status :basic :comment "GL841 based, to be added to genesys backend" :model "CanoScan 8600F" :url "unsupported/canon-8600.html" :interface "USB" :usbid "0x04a9" "0x2229" :status :basic :comment "normal and transparency scans work up to 1200 dpi resolution" :model "CanoScan 700F" :interface "USB" :usbid "0x04a9" "0x1907" :status :good :comment "GL847 based, resolution from 75 to 4800 dpi" :model "Canon Image Formula 101" :interface "USB" :usbid "0x1083" "0x162e" :status :unsupported :comment "GL846 based, work in progress" ; ----------------------------------------------------------------------------- :mfg "Visioneer" :url "http://www.visioneer.com/" :model "Strobe XP 100,r3" :interface "USB" :usbid "0x04a7" "0x049b" :status :good :comment "All resolution and mode supported, calibration is available" :model "Strobe XP 200" :interface "USB" :usbid "0x04a7" "0x0426" :status :good :comment "All resolution and mode supported, calibration is available" :model "Strobe XP 300" :interface "USB" :usbid "0x04a7" "0x0474" :status :good :comment "All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally." :model "Roadwarrior" :interface "USB" :usbid "0x04a7" "0x0494" :status :basic :comment "All resolution and mode supported, calibration is available" :model "Visioneer OneTouch 7100" :interface "USB" :usbid "0x04a7" "0x0229" :status :complete :comment "Same as MD5345" ; ----------------------------------------------------------------------------- :mfg "Pentax" :url "http://www.pentaxtech.com/" :url "http://mobilesolutions.brother-usa.com/" :model "DSmobile 600" :interface "USB" :usbid "0x0a17" "0x3210" :status :good :comment "All resolution and mode supported, calibration is available" :model "DSmobile 600" :interface "USB" :usbid "0x04f9" "0x2038" :status :good :comment "All resolution and mode supported, calibration is available" ; ----------------------------------------------------------------------------- :mfg "DCT" :url "http://www.docucap.com/" :comment "Successor of Syscan in the USA" :model "DocketPort 487" :interface "USB" :usbid "0x1dcc" "0x4810" :status :basic :comment "All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally." ; ----------------------------------------------------------------------------- :mfg "Syscan" :model "DocketPort 485" :interface "USB" :usbid "0x0a82" "0x4810" :status :basic :comment "All resolution and mode supported, front- and backside side-by-side, with backside mirrored horizontally." :model "DocketPort 465" :interface "USB" :usbid "0x0a82" "0x4802" :status :untested :comment "All resolution and mode should be supported, but uncorrected scans" :model "DocketPort 665" :interface "USB" :usbid "0x0a82" "0x4803" :status :basic :comment "All resolution and mode supported, calibration is available" :model "DocketPort 685/ Ambir DS685" :interface "USB" :usbid "0x0a82" "0x480c" :status :good :comment "All resolution and mode supported, calibration is available, front- and backside side-by-side, with backside mirrored horizontally." :mfg "Xerox" :url "http://www.xerox.com/" :model "Travel Scanner 100" :interface "USB" :usbid "0x04a7" "0x04ac" :status :good :comment "All resolution and mode supported, calibration is available" :model "2400 Onetouch" :interface "USB" :usbid "0x0461" "0x038b" :status :complete :comment "GL646 based, resolution from 75 to 2400 dpi" ; ----------------------------------------------------------------------------- :mfg "Panasonic" :model "KV-SS080" :interface "USB" :usbid "0x04da" "0x100f" :status :complete :comment "All resolution and mode supported, calibration is available. Support sponsored by cncsolutions (http://www.cncsolutions.com.br)" sane-backends-1.0.29/doc/descriptions/nec.desc0000666000000000000000000000070013615534521016056 00000000000000:backend "nec" ; name of backend :version "0.12 (unmaintained)" ; version of backend :url "http://www5a.biglobe.ne.jp/~saetaka/" ; backend's homepage :manpage "sane-nec" :devicetype :scanner :mfg "NEC" ; name a manufacturer :url "http://www.nevt.co.jp/" :model "PC-IN500/4C" ; name models for above-specified mfg. :interface "SCSI" :comment "PC-IN500/4C was sold only in JAPAN" :status :good sane-backends-1.0.29/doc/descriptions/test.desc0000666000000000000000000000157013615534521016276 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "test" ; name of backend :version "1.0-28 (unmaintained)" ; version of backend :manpage "sane-test" ; name of manpage (if it exists) :url "http://www.meier-geinitz.de/sane/test-backend/" ; backend's web page :devicetype :api ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :desc "Frontend-tester" :comment "Backend for testing frontends. Also serves as example for SANE backend options." sane-backends-1.0.29/doc/descriptions/sharp.desc0000666000000000000000000000207213615534521016432 00000000000000:backend "sharp" ; name of backend :version "0.32 (unmaintained)" ; version of backend ;:status :beta ; :alpha, :beta, :stable, :new :url "http://www.satzbau-gmbh.de/staff/abel/sane-sharp.html" ; backend's homepage :manpage "sane-sharp" :devicetype :scanner :mfg "Sharp" ; name a manufacturer :url "http://sharp-world.com/" :model "JX-610" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" :model "JX-250" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" :model "JX-320" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" :model "JX-325" ; name models for above-specified mfg. :interface "SCSI" :status :untested :comment "" :model "JX-330" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" :model "JX-350" ; name models for above-specified mfg. :interface "SCSI" :status :good :comment "" sane-backends-1.0.29/doc/descriptions/teco3.desc0000666000000000000000000000275713615534521016344 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "teco3" ; name of backend :version "1.0-1 (unmaintained)" ; version of backend :manpage "sane-teco3" ; name of manpage (if it exists) :url "http://www.zago.net/sane/#teco3" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Relisys" :url "http://www.tecoimage.com.tw/" :model "Infinity Scorpio" :comment "sub model VM3552" :interface "SCSI" :status :good :mfg "Plustek" :model "OpticPro 2400SP" :comment "sub model VM3552" :interface "SCSI" :status :untested :mfg "PIOTECH" :url "http://www.image-land.com/" :model "Splendeur 3024" :comment "sub model VM3552" :interface "SCSI" :status :good :mfg "Trust" :model "Imagery 2400 SP" :comment "sub model VM3552" :interface "SCSI" :status :good :model "Imagery 4800 SP+" :comment "sub model VM3552" :interface "SCSI" :status :good :model "Imagery 9600 SP" :comment "sub model VM3552" :interface "SCSI" :status :untested ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/template.desc.0000666000000000000000000000566613615534521017222 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "template" ; name of backend :version "0.42" ; version of backend (or "unmaintained") :new :yes ; Is the backend new to this SANE release? ; :yes or :no :manpage "sane-template" ; name of manpage (if it exists) :url "http://www.luser.com/temp/" ; backend's web page :url "http://www.luser.com/b/" ; another backend webpage :comment "This backend supports only the USB and SCSI models" ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "TemPlate" ; name a manufacturer :url "http://www.template.com/" ; manufacturer's URL :url "http://www.template.de/" ; another manufacturer URL :comment "TemPlate scanners are sometimes labeled \"TMP\"" ; comment about the manufacturer :model "Templ Z" ; name models for above-specified mfg. :status :untested ; :minimal, :basic, :good, :complete ; :untested, or :unsupported :interface "SCSI" ; interface type of the device: ; "SCSI", "USB", "Parport (EPP)", ; "Parport (SPP)", "Parport (ECP)", ; "Serial port", "IEEE-1394", "JetDirect", ; or "Proprietary". :usbid "0x1234" "0x4321" ; Vendor and product ids of an USB device :url "http://www.tmp.com/z.html" ; model's URL :comment "With Z-Axis scrolling" ; comment about the model :model "Templ ZS" :interface "USB" :usbid "0x1234" "0x4322" :status :unsupported :comment "No support yet, but we have docs." :model "Templ ZQ" :interface "USB" :usbid "0x1234" "0x4323" :status :minimal :model "Templ ZY" :interface "SCSI" :status :basic :model "Templ ZZ" :interface "SCSI" :status :good :mfg "ArmorPlate" ; another manufacturer... :url "http://www.armorplate.com/" :model "AmplScan II" :interface "SCSI" :status :complete :comment "AmplScan *II*, not AmplScan!" :devicetype :api ; specify a different type :desc "Interface to FrObYz API" ; describe a non-hardware device :comment "Only FrObYz version 2.0 is supported!" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. ; :status specifier is optional after :model and at the top-level sane-backends-1.0.29/doc/descriptions/kodakaio.desc0000666000000000000000000000632713615534521017106 00000000000000:backend "kodakaio" :url "http://sourceforge.net/projects/cupsdriverkodak/" :version "2.7.2" :manpage "sane-kodakaio" :comment "Backend for Kodak AiO ESP and Hero printers. Also possibly Advent AWL10" :devicetype :scanner :mfg "Kodak" :url "http://www.kodak.com/" ;====================================== ; ESP series :model "ESP 2150" :interface "USB" :usbid "0x040a" "0x4059" :status :untested :comment "Please test!" :model "ESP 2170" :interface "USB" :usbid "0x040a" "0x4066" :status :basic :comment "Tested with network" :model "ESP 3200" :interface "USB" :usbid "0x040a" "0x4043" :status :untested :comment "Please test!" :model "ESP 3300" :interface "USB" :usbid "0x040a" "0x4031" :status :untested :comment "Please test!" :model "ESP 4100" :interface "USB" :usbid "0x040a" "0x4053" :status :untested :comment "Please test!" :model "ESP 5000" :interface "USB" :usbid "0x040a" "0x4028" :status :untested :comment "Please test!" :model "ESP 5100" :interface "USB" :usbid "0x040a" "0x4025" :status :untested :comment "Please test!" :model "ESP 5200" :interface "USB Ethernet" :usbid "0x040a" "0x4041" :status :complete :comment "USB good, Network good" :model "ESP 5300" :interface "USB" :usbid "0x040a" "0x4026" :status :untested :comment "Please test!" :model "ESP 5500" :interface "USB" :usbid "0x040a" "0x4027" :status :untested :comment "Please test!" :model "ESP 6100" :interface "USB" :usbid "0x040a" "0x4054" :status :untested :comment "Please test!" :model "ESP 7200" :interface "USB" :usbid "0x040a" "0x4056" :status :untested :comment "Please test!" :model "ESP 9200" :interface "USB" :usbid "0x040a" "0x4065" :status :untested :comment "Please test!" :model "ESP 5" :interface "USB" :usbid "0x040a" "0x4032" :status :untested :comment "Please test!" :model "ESP 7" :interface "USB" :usbid "0x040a" "0x403e" :status :untested :comment "Please test!" :model "ESP 9" :interface "USB" :usbid "0x040a" "0x403f" :status :untested :comment "Please test!" :model "ESP C110" :interface "USB" :usbid "0x040a" "0x4057" :status :untested :comment "Please test!" :model "ESP C115" :interface "USB" :usbid "0x040a" "0x4058" :status :untested :comment "Please test!" :model "ESP C310" :interface "USB" :usbid "0x040a" "0x405d" :status :untested :comment "Please test!" :model "ESP C315" :interface "USB" :usbid "0x040a" "0x405e" :status :untested :comment "Please test!" ;====================================== ; Hero series :model "Hero 3.1" :interface "USB" :usbid "0x040a" "0x406d" :status :untested :comment "Please test!" :model "Hero 4.1" :interface "USB" :usbid "0x040a" "0x4069" :status :untested :comment "Please test!" :model "Hero 5.1" :interface "USB" :usbid "0x040a" "0x4064" :status :untested :comment "Please test!" :model "Hero Office 6.1" :interface "USB" :usbid "0x040a" "0x4062" :status :basic :comment "Does the adf work?" :model "Hero 7.1" :interface "USB" :usbid "0x040a" "0x4063" :status :untested :comment "Please test!" :model "Hero 9.1" :interface "USB Ethernet" :usbid "0x040a" "0x4067" :status :complete :comment "USB good, Network good" ;=================================== :mfg "Advent" :url "http://www.adventcomputers.co.uk" :model "AW10" :interface "USB" :usbid "0x040a" "0x4060" :status :untested :comment "Please test!" sane-backends-1.0.29/doc/descriptions/agfafocus.desc0000666000000000000000000000117413615534521017255 00000000000000:backend "agfafocus" :version "unmaintained" :manpage "sane-agfafocus" :devicetype :scanner :mfg "AGFA" :url "http://www.agfa.com/" :model "Focus GS Scanner" :interface "SCSI" :status :untested :comment "6 bit gray" :model "Focus Lineart Scanner" :interface "SCSI" :status :untested :comment "Lineart only? Untested." :model "Focus II" :interface "SCSI" :status :untested :comment "gray only" :model "Focus Color" :interface "SCSI" :status :good :comment "3-pass" :model "Focus Color Plus" :interface "SCSI" :status :good :comment "3-pass" :mfg "Siemens" :model "S9036" :interface "SCSI" :status :untested :comment "gray only" sane-backends-1.0.29/doc/descriptions/hp.desc0000666000000000000000000000615013615534521015725 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "hp" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-hp" ; name of manpage (if it exists) :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Hewlett-Packard" ; name a manufacturer :url "http://www.hp.com/" :model "ScanJet Plus" ; name models for above-specified mfg. :interface "Propietary" :status :complete :comment "Driver for HP parallel interface card required" :model "ScanJet IIc" :interface "SCSI" :status :complete :scsi "HP" "C1750A" "processor" :model "ScanJet IIp" :interface "SCSI" :status :complete :scsi "HP" "C1790A" "processor" :model "ScanJet IIcx" :interface "SCSI" :status :complete :scsi "HP" "C2500A" "processor" :model "ScanJet 3c" :interface "SCSI" :status :complete :model "ScanJet 3p" :interface "SCSI" :status :complete :model "ScanJet 4c" :interface "SCSI" :status :complete :scsi "HP" "C2520A" "processor" :model "ScanJet 4p" :interface "SCSI" :status :complete :scsi "HP" "C1130A" "processor" :comment "Buttons may not work on some scanners" :model "ScanJet 4100C" :interface "USB" :usbid "0x03f0" "0x0101" :status :complete :comment "Buttons may not work on some scanners" :model "ScanJet 5p" :interface "SCSI" :status :complete :scsi "HP" "C5110A" "processor" :comment "Buttons may not work on some scanners" :model "ScanJet 5100C" :interface "Parport" :status :complete :comment "Requires ppscsi driver and epst module. Buttons may not work on some scanners" :model "ScanJet 5200C" :interface "Parport USB" :usbid "0x03f0" "0x0401" :status :complete :comment "Parallel interface requires ppscsi driver and epst module. Buttons may not work on some scanners" :model "ScanJet 6100C" :interface "SCSI" :status :complete :model "ScanJet 6200C" :interface "SCSI USB" :scsi "HP" "C6270A" "processor" :usbid "0x03f0" "0x0201" :status :complete :comment "Buttons may not work on some scanners" :model "ScanJet 6250C" :interface "SCSI USB" :usbid "0x03f0" "0x0201" :status :complete :comment "Buttons may not work on some scanners" :model "ScanJet 6300C" :interface "SCSI USB" :scsi "HP" "C7670A" "processor" :usbid "0x03f0" "0x0601" :status :complete :comment "Buttons may not work on some scanners" :model "ScanJet 6350C" :interface "SCSI USB" :usbid "0x03f0" "0x0601" :status :complete :comment "Buttons may not work on some scanners" :model "ScanJet 6390C" :interface "SCSI USB" :usbid "0x03f0" "0x0601" :status :complete :comment "Buttons may not work on some scanners" :model "PhotoSmart PhotoScanner" :interface "SCSI" :status :complete ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/cardscan.desc0000666000000000000000000000257613615534521017104 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "cardscan" ; name of backend :url "http://www.thebility.com/cardscan/" :version "3" ; version of backend :manpage "sane-cardscan" ; name of manpage (if it exists) :comment "Backend updated for SANE release 1.0.21, see sane-cardscan manpage" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Corex/Dymo" ; name a manufacturer :url "http://www.cardscan.com/" :model "800c" :interface "USB" :usbid "0x08f0" "0x0005" :status :good :comment "4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner" :model "600c" :interface "USB" :usbid "0x08f0" "0x0002" :status :basic :comment "4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner" :mfg "Sanford" ; name a manufacturer :model "800c" :interface "USB" :usbid "0x0451" "0x6250" :status :good :comment "4 inch wide 8bit Gray or 24bit Color simplex card/receipt scanner" sane-backends-1.0.29/doc/descriptions/umax_pp.desc0000666000000000000000000000324313615534521016767 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "umax_pp" ; name of backend :version "1 (unmaintained)" ; version of backend :manpage "sane-umax_pp" ; name of manpage (if it exists) ; backend's web page :url "http://umax1220p.sourceforge.net/" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "UMAX" ; name a manufacturer :url "http://www.umax.com.tw/" ; These scanners are known to have the same ASIC family. :model "Astra 1220P" :interface "Parport (EPP/ECP)" :status :good :model "Astra 2000P" :interface "Parport (EPP/ECP)" :status :good :model "Astra 1600P" :interface "Parport (EPP/ECP)" :status :good :model "Astra 600P" :interface "Parport (SPP/ECP)" :status :unsupported :comment "untested, but should be close to 610P" :model "Astra 610P" :interface "Parport (SPP/ECP)" :status :good :mfg "Hewlett-Packard" :model "Scanjet 3200C" :interface "Parport (EPP/ECP)" :status :good :comment "works (relabelled 1220P and 2000P)" :mfg "Genius" :model "ColorPage-Life Pro" :interface "Parport (EPP/ECP)" :status :good :comment "works (relabelled 1220P and 2000P)" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/lexmark.desc0000666000000000000000000000442013615534521016757 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "lexmark" ; name of backend :version "1.0-0 (unmaintained)" ; version of backend (or "unmaintained") :manpage "sane-lexmark" ; name of manpage (if it exists) :url "http://stef.dev.free.fr/sane/lexmark" ; backend's web page :comment "This backend supports lexmark x1100 series scanners." ; comment about the backend :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Lexmark" ; name a manufacturer :url "http://www.lexmark.com/" ; manufacturer's URL :model "X1110" :interface "USB" :usbid "0x043d" "0x007c" :status :untested :model "X1130" :interface "USB" :usbid "0x043d" "0x007c" :status :good :comment "Supports 75, 150, 300, 600 dpi" :model "X1140" :interface "USB" :usbid "0x043d" "0x007c" :status :untested :model "X1150" :interface "USB" :usbid "0x043d" "0x007c" :status :good :comment "Supports 75, 150, 300, 600 dpi" :model "X1170" :interface "USB" :usbid "0x043d" "0x007c" :status :good :comment "Supports 75, 150, 300, 600 dpi" :model "X1180" :interface "USB" :usbid "0x043d" "0x007c" :status :good :model "X1185" :interface "USB" :usbid "0x043d" "0x007c" :status :good :comment "Tested with xscanimage. Supports 75, 150, 300, 600, 1200(600x1200) dpi resolutions. Does grayscale or colour scans in the following sizes: wallet, 3x5, 4x6, 5x7, 8x10, letter." :model "X1195" :interface "USB" :usbid "0x043d" "0x007c" :status :untested :model "X74" :interface "USB" :usbid "0x043d" "0x0060" :status :good :comment "Supports 75, 150, 300, 600 dpi" :model "X12xx" :interface "USB" :usbid "0x043d" "0x007d" :status :good :comment "USB1.1 is OK, USB2.0 needs testing" :mfg "Dell" ; name a manufacturer :model "A920" :interface "USB" :usbid "0x413c" "0x5105" :status :good :comment "Relabelled X11xx model" sane-backends-1.0.29/doc/descriptions/abaton.desc0000666000000000000000000000060713615534521016563 00000000000000:backend "abaton" :version "unmaintained" :manpage "sane-abaton" ;:url "http://aix2.uottawa.ca/~s1204672/sane/" :devicetype :scanner :mfg "Abaton" ;:url "http://www.everex.com/" ;dead? :model "Scan 300/GS" :interface "SCSI" :status :complete :comment "All known modes and functions supported" :model "Scan 300/S" :interface "SCSI" :status :untested :comment "Untested, use with caution" sane-backends-1.0.29/doc/descriptions/kvs1025.desc0000666000000000000000000000167613615534521016441 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "kvs1025" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-kvs1025" ; name of manpage (if it exists) :comment "New backend for SANE release 1.0.21, see sane-kvs1025 manpage" :devicetype :scanner ; start of a list of devices.... :mfg "Panasonic" ; name a manufacturer :url "http://www.panasonic.com/" :model "KV-S1020C" :interface "USB" :usbid "0x04da" "0x1007" :status :good :model "KV-S1025C" :interface "USB" :usbid "0x04da" "0x1006" :status :good :model "KV-S1045C" :interface "USB" :usbid "0x04da" "0x1010" :status :good sane-backends-1.0.29/doc/descriptions/dc240.desc0000666000000000000000000000105713615534521016133 00000000000000;Kodak DC240 backend .desc file by Peter S. Fales :backend "dc240" ; name of backend :version "0.0 (unmaintained)" ; version of backend :manpage "sane-dc240" ; name of manpage (if it exists) :url "mailto:peter@fales-lorenz.net" ; backend's web page :devicetype :stillcam ; start of a list of devices.... :mfg "Kodak" :url "http://www.kodak.com/global/en/service/products/ekn006568.jhtml" :model "DC240" :status :good ; minimal, basic, good, complete :interface "Serial port" :comment "Use gphoto2 backend to get USB support" sane-backends-1.0.29/doc/descriptions/hpljm1005.desc0000666000000000000000000000165213615534521016740 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). :backend "hpljm1005" :version "0 (unmaintained)" :manpage "sane-hpljm1005" :devicetype :scanner :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "LaserJet M1005 MFP" :interface "USB" :usbid "0x03f0" "0x3b17" :status :good :comment "grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI" :model "LaserJet M1120 MFP" :interface "USB" :usbid "0x03f0" "0x5617" :status :good :comment "grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI" :model "LaserJet M1120n MFP" :interface "USB" :usbid "0x03f0" "0x5717" :status :good :comment "grayscale/color (24 bit), 75/100/150/200/300/600/1200 DPI" sane-backends-1.0.29/doc/descriptions/canon630u.desc0000666000000000000000000000230113615534521017024 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "canon630u" ; name of backend :manpage "sane-canon630u" :version "0.1 (unmaintained)" ; version of backend ;:status :beta :url "http://canon-fb630u.sourceforge.net/" ; backend home page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Canon" ; name a manufacturer :url "http://www.canon.com/" :model "CanoScan fb630u" ; name models for above-specified mfg. :interface "USB" :usbid "0x04a9" "0x2204" :comment "OK" :status :good :model "CanoScan fb636u" ; name models for above-specified mfg. :interface "USB" :usbid "0x04a9" "0x2204" :status :good :comment "OK" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/umax.desc0000666000000000000000000001632713615534521016277 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "umax" ; name of backend :version "1.0-41 (unmaintained)" ; version of backend :manpage "sane-umax" ; name of manpage (if it exists) :url "http://www.rauch-domain.de/sane-umax/index.html" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "UMAX" ; name a manufacturer :url "http://www.umax.com/" :url "http://www.umax.com.tw/" :url "http://www.umax.de/en" :url "http://www.umax-europe.com" :url "http://www.umaxjapan.co.jp" :url "http://www.umax.com.cn" :model "Vista S6" :interface "SCSI" :status :good :comment "OK" :model "Vista S6E" :interface "SCSI" :status :good :comment "OK" :model "UMAX S-6E" :interface "SCSI" :status :good :comment "OK" :model "UMAX S-6EG" :interface "SCSI" :status :good :comment "OK" :model "Vista-S8" :interface "SCSI" :status :good :comment "OK" :model "Supervista S-12" :interface "SCSI" :status :good :comment "OK" :model "UMAX S-12" :interface "SCSI" :status :good :comment "OK" :model "UMAX S-12G" :interface "SCSI" :status :good :comment "OK" :model "Astra 600S" :interface "SCSI" :status :good :comment "OK" :model "Astra 610S" :interface "SCSI" :status :good :comment "OK" :model "Astra 1200S" :interface "SCSI" :status :good :comment "OK" :model "Astra 1220S" :interface "SCSI" :status :good :comment "OK" :model "Astra 2100S" :interface "SCSI" :status :good :comment "OK" :model "Astra 2200 (SU)" :interface "SCSI" :status :good :comment "OK" :model "Astra 2200 (SU)" :interface "USB" :usbid "0x1606" "0x0230" :status :good :comment "OK, needs USB control messages" :model "Astra 2400S" :interface "SCSI" :status :good :comment "OK" :model "Astra 6400" :interface "IEEE-1394" :status :unsupported :comment "will probably work one day" :model "Astra 6450" :interface "IEEE-1394" :status :unsupported :comment "will probably work one day" :model "Astra MX3" :interface "SCSI" :status :good :comment "OK" :model "Astra MX3" :interface "USB" :status :good :comment "OK, needs USB control messages" :model "Mirage D-16L" :interface "SCSI" :status :good :comment "OK" :model "Mirage II" :interface "SCSI" :status :good :comment "OK" :model "Mirage IIse" :interface "SCSI" :status :good :comment "OK" :model "PSD" :interface "SCSI" :status :good :comment "OK" :model "PowerLook" :interface "SCSI" :status :good :comment "OK, SCSI-ID=PS-2400X" :model "PL-II" :interface "SCSI" :status :good :comment "OK" :model "PowerLook III" :interface "SCSI" :status :good :comment "OK" :model "PowerLook 270" :interface "SCSI" :status :unsupported :comment "incompatible" :model "PowerLook 270plus" :interface "SCSI" :status :unsupported :comment "incompatible" :model "PowerLook 1100" :interface "IEEE-1394" :status :unsupported :comment "will probably work one day" :model "PowerLook 2000" :interface "SCSI" :status :good :comment "OK" :model "PowerLook 2100XL" :interface "SCSI" :status :good :comment "OK" :model "PowerLook 3000" :interface "SCSI" :status :good :comment "OK" :model "Gemini D-16" :interface "SCSI" :status :good :comment "OK" :model "UMAX VT600" :interface "SCSI" :status :untested :comment "may work, please test and give feedback" :model "Vista-T630" :interface "SCSI" :status :good :comment "OK for some firmwareversions, on others only lineart OK" :model "UC 630" :interface "SCSI" :status :good :comment "Version 2.8 OK, others only lineart OK" :model "UG 630" :interface "SCSI" :status :good :comment "OK" :model "UG 80" :interface "SCSI" :status :good :comment "OK" :model "UC 840" :interface "SCSI" :status :good :comment "Version 1.6 OK, others only lineart OK" :model "UC 1200S" :interface "SCSI" :status :untested :comment "may work, please test and give feedback" :model "UC 1200SE" :interface "SCSI" :status :good :comment "Version 3.0 OK, others unknown" :model "UC 1260" :interface "SCSI" :status :good :comment "Version 1.6 OK, others unknown" :mfg "Linotype Hell" ; another manufacturer... :url "http://www.heidelberg.com/" :model "Jade" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell Office" :model "Jade" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell JADE" :model "Jade2" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell Office2" :model "Saphir" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Saphir2" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell SAPHIR2" :model "Saphir3" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell SAPHIR3" :model "Saphir Ultra" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Saphir Ultra II" :interface "SCSI" :status :good :comment "OK, SCSI-ID=Linotype SAPHIR4" :model "Saphir HiRes" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Opal" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Opal2" :interface "SCSI" :status :good :comment "OK; SCSI-ID=LinoHell OPAL2" :model "Opal Ultra" :interface "SCSI" :status :untested :comment "support disabled until tested - please contact author" :model "Linoscan 1400" :interface "SCSI" :status :good :comment "OK, SCSI-ID=HDM LS4H1S" :mfg "Vobis" :url "http://www.vobis.de/" :model "Highscreen Scanboostar Premium" :interface "SCSI" :status :good :comment "OK, SCSI-ID=LinoHell Office2" :mfg "EDGE" ; another manufacturer... ; :url "http://???/" :model "KTX-9600US" :interface "SCSI" :status :untested :comment "no feedback" :mfg "Epson" ; another manufacturer... :url "http://www.epson.com/" :model "Perfection 600" :interface "SCSI" :status :good :comment "OK, SCSI-ID=EPSON Perfection600" :mfg "Escom" ; another manufacturer... :model "Image Scanner 256" :interface "SCSI" :status :good :comment "OK, SCSI-ID=UMAX UG 80" :mfg "Escort" ; another manufacturer... :model "Galleria 600" :interface "SCSI" :status :untested :comment "untested, SCSI-ID=ESCORT Galleria 600S" :mfg "Genius" ; another manufacturer... ;:url "http://www.genius.kye.de/" :model "ColorPage-HR5 (Pro)" :interface "SCSI" :status :good :comment "OK, SCSI-ID=KYE ColorPage-HR5" :mfg "Nikon" ; another manufacturer... :url "http://www.nikon.com/" :model "AX-110 / Scantouch 110" :interface "SCSI" :status :untested :comment "may work, please test and give feedback" :model "AX-210" :interface "SCSI" :status :good :comment "OK" :mfg "TriGem" ; another manufacturer... :url "http://www.nikon.com/" :model "PowerScanII" :interface "SCSI" :status :good :comment "OK" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/fujitsu.desc0000666000000000000000000003377313615534521017022 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "fujitsu" ; name of backend :url "http://www.thebility.com/fujitsu/" :version "134" ; version of backend :manpage "sane-fujitsu" ; name of manpage (if it exists) :comment "Backend updated for SANE release 1.0.28, see sane-fujitsu manpage" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Fujitsu" ; name a manufacturer :url "http://www.fujitsu.com/" ;================================================== ; DISCONTINUED OLDER MODELS, SMALL :model "M3091DC" :interface "SCSI" :url "http://www.remote.org/frederik/projects/software/sane/" :status :complete :comment "small, old, discontinued" :model "M3092DC" :interface "SCSI" :status :complete :comment "small, old, discontinued" ;================================================== ; DISCONTINUED NEWER MODELS, SMALL :model "fi-4120C" :interface "SCSI USB" :usbid "0x04c5" "0x1041" :status :complete :comment "small, recent, discontinued, usb 1.1" :model "fi-4120C2" :interface "SCSI USB" :usbid "0x04c5" "0x10ae" :status :complete :comment "small, recent, discontinued, usb 2.0" :model "fi-4220C" :interface "SCSI USB" :usbid "0x04c5" "0x1042" :status :complete :comment "small, recent, discontinued, usb 1.1" :model "fi-4220C2" :interface "SCSI USB" :usbid "0x04c5" "0x10af" :status :complete :comment "small, recent, discontinued, usb 2.0" :model "fi-5110C" :interface "USB" :status :complete :usbid "0x04c5" "0x1097" :comment "small, recent, discontinued" :model "fi-5110EOX/2" :interface "USB" :status :complete :usbid "0x04c5" "0x1096" :comment "small, recent, discontinued" :model "fi-5110EOX3" :interface "USB" :status :complete :usbid "0x04c5" "0x10e6" :comment "small, recent, discontinued" :model "fi-5110EOXM" :interface "USB" :usbid "0x04c5" "0x10f2" :status :complete :comment "small, recent, discontinued" :model "fi-5120C" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x10e0" :comment "small, recent, discontinued" :model "fi-5220C" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x10e1" :comment "small, recent, discontinued" :model "fi-5000N" :interface "Ethernet" :status :untested :comment "Not a scanner, rather a scanner to ethernet interface" :model "fi-6000NS" :interface "Ethernet" :status :untested :comment "small, recent, discontinued, integrated touchscreen and keyboard" :model "ScanSnap S500" :interface "USB" :status :complete :usbid "0x04c5" "0x10fe" :comment "small, recent, discontinued" :model "ScanSnap S500M" :interface "USB" :status :complete :usbid "0x04c5" "0x1135" :comment "small, recent, discontinued" :model "ScanSnap S510" :interface "USB" :status :complete :usbid "0x04c5" "0x1155" :comment "small, recent, discontinued" :model "ScanSnap S510M" :interface "USB" :status :complete :usbid "0x04c5" "0x116f" :comment "small, recent, discontinued" :model "fi-6130" :interface "USB" :status :complete :usbid "0x04c5" "0x114f" :comment "small, recent, discontinued" :model "fi-6230" :interface "USB" :status :complete :usbid "0x04c5" "0x1150" :comment "small, recent, discontinued" :model "fi-6130Z" :interface "USB" :status :complete :usbid "0x04c5" "0x11f3" :comment "small, recent, discontinued" :model "fi-6230Z" :interface "USB" :status :complete :usbid "0x04c5" "0x11f4" :comment "small, recent, discontinued" :model "fi-6120ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x146d" :comment "small, recent, discontinued, expected to work" :model "fi-6220ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x146e" :comment "small, recent, discontinued, expected to work" :model "fi-6125ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x1463" :comment "small, recent, discontinued, expected to work" :model "fi-6225ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x1464" :comment "small, recent, discontinued, expected to work" :model "fi-6130ZLA" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x1461" :comment "small, recent, discontinued" :model "fi-6230ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x1462" :comment "small, recent, discontinued, expected to work" :model "ScanSnap S1500" :interface "USB" :status :complete :usbid "0x04c5" "0x11a2" :comment "small, discontinued" :model "ScanSnap S1500M" :interface "USB" :status :complete :usbid "0x04c5" "0x11a2" :comment "small, discontinued, same as S1500" :model "ScanSnap N1800" :interface "Ethernet" :status :untested :comment "small, discontinued, integrated touchscreen and keyboard" ;================================================== ; CURRENT MODELS, SMALL :model "ScanSnap N7100" :interface "Ethernet" :status :untested :comment "small, current, integrated touchscreen and keyboard" :model "ScanSnap fi-6010N" :interface "Ethernet" :status :untested :comment "small, current, integrated touchscreen and keyboard" :model "fi-6110" :interface "USB" :status :complete :usbid "0x04c5" "0x11fc" :comment "small, current" :model "fi-7160" :interface "USB" :status :complete :usbid "0x04c5" "0x132e" :comment "small, current" :model "fi-7260" :interface "USB" :status :complete :usbid "0x04c5" "0x132f" :comment "small, current" :model "ScanSnap iX500" :interface "USB WiFi" :status :good :usbid "0x04c5" "0x132b" :comment "small, current, WiFi not supported. Hardware only scans in color. Backend generates binary and grayscale modes." :model "ScanSnap iX100" :interface "USB WiFi" :status :good :usbid "0x04c5" "0x13f4" :comment "small, current, WiFi not supported." :model "ScanSnap SV600" :interface "USB" :status :untested :usbid "0x04c5" "0x128e" :comment "Also has a second USB VID 0x13ba. Will require some gymnastics to support." ;================================================== ; DISCONTINUED OLDER MODELS, MEDIUM :model "M3093E" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3093DE" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3093DG" :interface "SCSI" :status :complete :comment "medium, old, discontinued" :model "M3093EX" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3093GX" :interface "SCSI" :status :complete :comment "medium, old, discontinued" :model "M3096EX" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3096GX" :interface "SCSI" :status :complete :comment "medium, old, discontinued" :model "M3097E+" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3097G+" :interface "SCSI" :status :complete :comment "medium, old, discontinued" :model "M3097DE" :interface "RS232C/Video" :status :unsupported :comment "medium, old, discontinued" :model "M3097DG" :interface "SCSI" :status :complete :comment "medium, old, discontinued" ;================================================== ; DISCONTINUED NEWER MODELS, MEDIUM :model "fi-4340C" :interface "SCSI USB" :usbid "0x04c5" "0x10cf" :status :complete :comment "medium, current" :model "fi-4530C" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x1078" :comment "medium, recent, discontinued" :model "fi-4640S" :interface "SCSI" :status :complete :comment "medium, recent, discontinued" :model "fi-4750C" :interface "SCSI" :status :complete :comment "medium, recent, discontinued" :model "fi-5530C" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x10e2" :comment "medium, recent, discontinued" :model "fi-6140" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x114d" :comment "medium, recent, discontinued" :model "fi-6240" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x114e" :comment "medium, recent, discontinued" :model "fi-6140Z/fi-6140ZLA" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x11f1" :comment "medium, recent, discontinued" :model "fi-6240Z" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x11f2" :comment "medium, recent, discontinued" :model "fi-6135ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x146b" :comment "medium, recent, discontinued, expected to work" :model "fi-6235ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x146c" :comment "medium, recent, discontinued, expected to work" :model "fi-6140ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x145f" :comment "medium, recent, discontinued, expected to work" :model "fi-6240ZLA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x1460" :comment "medium, recent, discontinued, expected to work" ;================================================== ; CURRENT MODELS, MEDIUM :model "fi-5530C2" :interface "SCSI USB" :status :complete :usbid "0x04c5" "0x114a" :comment "medium, current" :model "fi-7180" :interface "USB" :status :complete :usbid "0x04c5" "0x132c" :comment "medium, current" :model "fi-7280" :interface "USB" :status :complete :usbid "0x04c5" "0x132d" :comment "medium, current" ;================================================== ; DISCONTINUED OLDER MODELS, BIG :model "M3099A" :interface "RS232C/Video" :status :unsupported :comment "big, old, discontinued" :model "M3099G" :interface "SCSI" :status :complete :comment "big, old, discontinued" :model "M3099EH" :interface "RS232C/Video" :status :unsupported :comment "big, old, discontinued" :model "M3099GH" :interface "SCSI" :status :complete :comment "big, old, discontinued" :model "M3099EX" :interface "RS232C/Video" :status :unsupported :comment "big, old, discontinued" :model "M3099GX" :interface "SCSI" :status :complete :comment "big, old, discontinued" :model "M4097D" :interface "SCSI" :status :complete :comment "big, old, discontinued" :model "M4099D" :interface "SCSI" :status :complete :comment "big, old, discontinued" ;================================================== ; DISCONTINUED NEWER MODELS, BIG :model "fi-4750L" :interface "SCSI" :status :complete :comment "big, recent, discontinued" :model "fi-4860C" :interface "SCSI" :status :complete :comment "big, recent, discontinued" :model "fi-4860C2" :interface "SCSI" :status :complete :comment "big, recent, discontinued" :model "fi-4990C" :interface "SCSI" :status :complete :comment "big, recent, discontinued" :model "fi-5650C" :interface "SCSI USB" :usbid "0x04c5" "0x10ad" :status :complete :comment "big, recent, discontinued" :model "fi-5750C" :interface "SCSI USB" :usbid "0x04c5" "0x1095" :status :complete :comment "big, recent, discontinued" :model "fi-5900C" :interface "SCSI USB" :usbid "0x04c5" "0x10e7" :status :good :comment "big, recent, discontinued. Independent ultrasonic control and multistream unsupported" :model "fi-6750S" :interface "USB" :status :untested :usbid "0x04c5" "0x1178" :comment "Simplex, USB only version of fi-6770, won't wakeup via software, discontinued" ;================================================== ; CURRENT MODELS, BIG :model "fi-5950" :interface "SCSI USB" :usbid "0x04c5" "0x1213" :status :untested :comment "big, current. Faster version of fi-5900?" :model "fi-6670" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x1176" :comment "big, current, won't wakeup via software" :model "fi-6670A" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x1177" :comment "big, current, VRS CGA board unsupported, won't wakeup via software" :model "fi-6770" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x1174" :comment "big, current, won't wakeup via software" :model "fi-6770A" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x1175" :comment "big, current, VRS CGA board unsupported, won't wakeup via software" :model "fi-6800" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x119d" :comment "big, current. Independent ultrasonic control and multistream unsupported" :model "fi-6800-CGA" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x119e" :comment "big, current. VRS CGA board unsupported, Independent ultrasonic control and multistream unsupported" :model "fi-6400" :interface "SCSI USB" :status :good :usbid "0x04c5" "0x14ac" ;================================================== ; 2015/2016/2017 NEW MODELS, UNORDERED :model "fi-6420" :interface "SCSI USB" :status :untested :usbid "0x04c5" "0x14bd" :model "ScanSnap iX500EE" :interface "USB" :status :untested :usbid "0x04c5" "0x13f3" :model "N7100" :interface "USB Ethernet" :status :untested :usbid "0x04c5" "0x146f" :model "fi-7480" :interface "USB" :status :good :usbid "0x04c5" "0x14b8" :model "fi-7460" :interface "USB" :status :good :usbid "0x04c5" "0x14be" :model "fi-7140" :interface "USB" :status :untested :usbid "0x04c5" "0x14df" :model "fi-7240" :interface "USB" :status :untested :usbid "0x04c5" "0x14e0" :model "fi-7135" :interface "USB" :status :untested :usbid "0x04c5" "0x14e1" :model "fi-7235" :interface "USB" :status :untested :usbid "0x04c5" "0x14e2" :model "fi-7130" :interface "USB" :status :untested :usbid "0x04c5" "0x14e3" :model "fi-7230" :interface "USB" :status :untested :usbid "0x04c5" "0x14e4" :model "fi-7125" :interface "USB" :status :untested :usbid "0x04c5" "0x14e5" :model "fi-7225" :interface "USB" :status :untested :usbid "0x04c5" "0x14e6" :model "fi-7120" :interface "USB" :status :untested :usbid "0x04c5" "0x14e7" :model "fi-7220" :interface "USB" :status :untested :usbid "0x04c5" "0x14e8" :model "fi-400F" :interface "USB" :status :untested :usbid "0x04c5" "0x151e" :model "fi-7030" :interface "USB" :status :good :usbid "0x04c5" "0x151f" :model "fi-7700" :interface "USB" :status :good :usbid "0x04c5" "0x1520" :model "fi-7600" :interface "USB" :status :good :usbid "0x04c5" "0x1521" :model "fi-7700S" :interface "USB" :status :untested :usbid "0x04c5" "0x1522" :model "ScanSnap iX1500" :interface "USB WiFi" :status :good :usbid "0x04c5" "0x159f" :comment "small, current, WiFi not supported." sane-backends-1.0.29/doc/descriptions/ricoh2.desc0000666000000000000000000000234513615534521016506 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "ricoh2" ; name of backend :version "1.0" ; version of backend (or "unmaintained") :manpage "sane-ricoh2" ; name of manpage (if it exists) :url "http://www.ricoh.com/" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Ricoh" ; name a manufacturer :url "http://www.ricoh.com/" ; manufacturer's URL :model "SG-3100SFNw" :status :basic :interface "USB" :usbid "0x05ca" "0x0439" :model "SG-3100SNw" :status :basic :interface "USB" :usbid "0x05ca" "0x0438" :model "SP-100SU" :status :untested :interface "USB" :usbid "0x05ca" "0x042c" :model "SP-111SU/SP-112SU" :status :basic :interface "USB" :usbid "0x05ca" "0x0448" sane-backends-1.0.29/doc/descriptions/dmc.desc0000666000000000000000000000214113615534521016055 00000000000000; $Id$ ; ; SANE Backend specification file (Matto Marjanovic's format) ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "dmc" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-dmc" ; name of manpage (if it exists) :devicetype :stillcam ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Polaroid" ; name a manufacturer :url "http://www.polaroid.com/" :model "DMC" ; name models for above-specified mfg. :interface "SCSI" ;:url "http://digitalimage.polaroid.com/products/digital_imaging/digital_cameras/dmcsuite/dmc/" :status :good ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/snapscan.desc0000666000000000000000000001577013615534521017134 00000000000000; $Id$ ; ; SANE Backend specification file (Matto Marjanovic's format) ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "SnapScan" ; name of backend :version "1.4" ; version of backend :manpage "sane-snapscan" ; name of manpage (if it exists) :url "http://snapscan.sourceforge.net/" ; backend's web page :comment "Supported bit depths: 24 bit (color), 48 bit (color, Epson) 8 bit (gray)" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api ;----------------------------------------------------------------------------- :mfg "AGFA" ; name a manufacturer :url "http://www.agfa.com/" :model "SnapScan" ; name models for above-specified mfg. :interface "SCSI" :status :good :model "SnapScan 300" :interface "SCSI" :status :good :model "SnapScan 310" :interface "SCSI" :status :good :model "SnapScan 600" :interface "SCSI" :status :good :comment "Optional ADF supported." :model "Arcus 1200" :interface "SCSI" :status :good :comment "Optional transparency unit supported." :model "SnapScan 1236s" :interface "SCSI" :status :good :comment "Optional ADF and transparency unit supported." :model "SnapScan 1236u" :interface "USB" :status :good :usbid "0x06bd" "0x0002" :comment "Optional ADF and transparency unit supported." :model "SnapScan 1212U" :interface "USB" :usbid "0x06bd" "0x0001" :status :good :model "SnapScan 1212U_2" :interface "USB" :usbid "0x06bd" "0x2061" :status :good :model "SnapScan e10" :interface "USB" :usbid "0x06bd" "0x2093" :status :good :model "SnapScan e20" :interface "USB" :usbid "0x06bd" "0x2091" :status :good :model "SnapScan e25" :interface "USB" :usbid "0x06bd" "0x2095" :status :good :model "SnapScan e26" :interface "USB" :usbid "0x06bd" "0x2097" :status :good :model "SnapScan e40" :interface "USB" :usbid "0x06bd" "0x208d" :status :good :model "SnapScan e42" :interface "USB" :usbid "0x06bd" "0x20ff" :status :good :model "SnapScan e50" :interface "USB" :status :good :usbid "0x06bd" "0x208f" :comment "Optional tranparency unit supported" :model "SnapScan e52" :interface "USB" :status :good :usbid "0x06bd" "0x20fd" :comment "Optional tranparency unit supported" :model "SnapScan e60" :interface "USB" :status :untested ;------------------------------------------------------------------------------ :mfg "Acer Peripherals" :comment "Company was renamed to Benq." :mfg "Vuego" :comment "Company was renamed to Benq." :mfg "Benq (Acer)" :url "http://www.benq.com" :comment "Formerly Acer Peripherals" :model "300f" :interface "SCSI" :status :good :model "310s" :interface "SCSI" :status :good :model "610s" :interface "SCSI" :status :good :model "610plus" :interface "SCSI" :status :good :model "620s" :interface "SCSI" :status :good :model "ScanWit 2720s" :interface "SCSI" :status :good :model "310U" :interface "USB" :usbid "0x04a5" "0x1a20" :status :good :model "320U" :interface "USB" :usbid "0x04a5" "0x2022" :status :good :model "340U" :interface "USB" :usbid "0x04a5" "0x2022" :status :good :model "620U" :interface "USB" :usbid "0x04a5" "0x1a2a" :status :good :comment "Optional tranparency unit supported" :model "620UT" :interface "USB" :usbid "0x04a5" "0x2040" :status :good :comment "Optional tranparency unit supported" :model "640U" :interface "USB" :usbid "0x04a5" "0x2060" :status :good :comment "Optional tranparency unit supported" :model "640bu" :interface "USB" :usbid "0x04a5" "0x207e" :status :good :model "640BT" :interface "USB" :usbid "0x04a5" "0x20be" :status :good :comment "Optional tranparency unit supported" :model "1240" :interface "USB" :usbid "0x04a5" "0x20c0" :status :good :comment "Optional tranparency unit supported" :model "3300" :interface "USB" :usbid "0x04a5" "0x20b0" :status :good :model "3300" :interface "USB" :usbid "0x04a5" "0x20de" :status :good :model "4300" :interface "USB" :usbid "0x04a5" "0x20b0" :status :good :model "4300" :interface "USB" :usbid "0x04a5" "0x20de" :status :good :model "5000E" :interface "USB" :usbid "0x04a5" "0x20fc" :status :basic :comment "Same as 5000U, working up to 600 DPI" :model "5000U" :interface "USB" :usbid "0x04a5" "0x20fc" :status :basic :comment "Same as 5000E, working up to 600 DPI" :model "5000" :interface "USB" :usbid "0x04a5" "0x20f8" :status :good :comment "USB ID 0x04a5,0x20f8: Color / grayscale scans working up to 1200 DPI" :model "5150" :interface "USB" :usbid "0x04a5" "0x2137" :status :basic :comment "Calibration algorithm unknown" :model "5250" :interface "USB" :usbid "0x04a5" "0x2137" :status :basic :comment "Same hardware as 5150 (?), Calibration algorithm unknown" :model "5300" :interface "USB" :usbid "0x04a5" "0x20fe" :status :basic :comment "Problems with firmware upload reported" ;------------------------------------------------------------------------------ :mfg "Guillemot / Hercules" :url "http://www.guillemot.com" :model "Maxi Scan A4 Deluxe (SCSI)" :interface "SCSI" :status :good :comment "Rebadged SnapScan 310s." :model "Scan@home Touch 1248 (USB)" :interface "USB" :usbid "0x04a5" "0x20de" :status :good :comment "Rebadged Benq 3300." :model "Maxi Scan A4 USB 640U" :interface "USB" :usbid "0x04a5" "0x2060" :status :good :comment "Rebadged Benq 640U." :model "Maxi A4 36 bit" :interface "USB" :usbid "0x04a5" "0x2060" :status :good :comment "Rebadged Benq 620U, needs Benq firmware file u96v???.bin" ;------------------------------------------------------------------------------ :mfg "Mitsubishi" :url "http://www.mitsubishi.com" :model "Diamondview 648UT" :interface "USB" :usbid "0x04a5" "0x2022" :status :good :comment "Rebadged Benq 320u." :model "Diamondview 650U" :interface "USB" :usbid "0x04a5" "0x20b0" :status :good :comment "Rebadged Benq 4300." ;------------------------------------------------------------------------------ :mfg "Epson" :url "http://www.epson.com" :model "Perfection 660" :interface "USB" :usbid "0x04b8" "0x0114" :status :good :model "Perfection 1270" :interface "USB" :usbid "0x04b8" "0x0120" :status :good :model "Perfection 1670" :interface "USB" :usbid "0x04b8" "0x011f" :status :good :model "Perfection 2480" :interface "USB" :usbid "0x04b8" "0x0121" :status :good :model "Perfection 2580" :interface "USB" :status :basic :usbid "0x04b8" "0x0121" :comment "Film scanning unit unsupported" :model "Perfection 3490" :interface "USB" :usbid "0x04b8" "0x0122" :status :good :model "Perfection 3590" :interface "USB" :usbid "0x04b8" "0x0122" :status :basic :comment "Film scanning unit unsupported" :model "Stylus CX-1500" :interface "USB" :usbid "0x04b8" "0x080c" :status :good ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/mustek_pp.desc0000666000000000000000000000714613615534521017333 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "mustek_pp" ; name of backend :version "13 (unmaintained)" ; version of backend :manpage "sane-mustek_pp" ; name of manpage (if it exists) ; backend's web page :url "http://penguin-breeder.org/sane/mustek_pp/" :comment "Supports CIS and CCD type parallel port scanners from Mustek." :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Mustek" ; name a manufacturer :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "ScanExpress 6000 P" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "ScanExpress 600 SEP" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "ScanMagic 4800 P" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "600 III EP Plus" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "96 CP" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :model "ScanExpress 600 CP" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :model "ScanMagic 600 CP" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :model "ScanExpress 1200 CP" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :model "ScanExpress 1200 CP+" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.de/" :comment "Those scanners are also known as \"Aldi Scanner\" or \"Tchibo Scanners\"" :model "MD 9848" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "MD 9806" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :model "MD/LT 935x" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :model "MD/LT 985x" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :model "MD/LT 9890" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :mfg "Targa" :model "Funline TS12 EP" :interface "Parport (EPP)" :status :good :comment "600x1200 dpi CIS scanner" :model "Funline TS6 EP" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :mfg "Trust" :url "http://www.trust-site.com/home/" :model "Easy Connect 9600+" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :model "Easy Connect 19200+" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" :mfg "Viviscan" :model "Compact II" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :mfg "Cybercom" :model "9352" :interface "Parport (EPP)" :status :good :comment "CIS scanner" :mfg "Gallery" :model "4800" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :mfg "Network" :model "Easy Plus 30 Bit" :interface "Parport (EPP)" :status :good :comment "300 dpi CCD scanner" :mfg "Micromaxx" :model "MM-9851" :interface "Parport (EPP)" :status :good :comment "300x600 dpi CIS scanner" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/bh.desc0000666000000000000000000000320313615534521015703 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "bh" ; name of backend :version "1.0-4 (unmaintained)" ; version of backend :manpage "sane-bh" ; name of manpage (if it exists) :url "http://www.martoneconsulting.com/sane-bh.html" ; backend's web page :comment "Supports Copiscan II scanners with Remote SCSI Controller (RSC) interface" :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "Bell and Howell" ; name a manufacturer :url "http://www.bhscanners.com/" :model "COPISCAN II 6338" :interface "SCSI" :status :good :comment "Duplex Scanner with ACE - development model" :model "COPISCAN II 2135" :status :untested :interface "SCSI" :comment "Simplex Scanner" :model "COPISCAN II 2137(A)" :interface "SCSI" :status :good :comment "Simplex Scanner (with ACE) - limited testing" :model "COPISCAN II 2138A" :status :untested :interface "SCSI" :comment "Simplex Scanner with ACE" :model "COPISCAN II 3238" :status :untested :interface "SCSI" :comment "Simplex Scanner" :model "COPISCAN II 3338(A)" :status :untested :interface "SCSI" :comment "Simplex Scanner (with ACE)" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/p5.desc0000666000000000000000000000216313615534521015642 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "p5" ; name of backend :version "1 (unmaintained)"; version of backend :manpage "sane-p5" ; name of manpage (if it exists) :comment "New backend for SANE release 1.0.21, see sane-p5 manpage" :url "http://www.sane-project.org/" ; backend's web page :devicetype :scanner ; start of a list of devices.... ; other types: :stillcam, :vidcam, ; :meta, :api :mfg "PRIMAX" ; name a manufacturer :url "http://www.primax.com.tw" :model "PagePartner" :interface "Parport (EPP/ECP)" :status :basic :comment "Sheetfed scanner, work in gray and color, but uncalibrated scans" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/kvs20xx.desc0000666000000000000000000000222413615534521016641 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "kvs20xx" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-kvs20xx" ; name of manpage (if it exists) :comment "New backend for SANE release 1.0.22, see sane-kvs20xx manpage" :devicetype :scanner ; start of a list of devices.... :mfg "Panasonic" ; name a manufacturer :url "http://www.panasonic.com/" :model "KV-S2025C" :interface "SCSI" :status :untested :model "KV-S2026C" :interface "USB SCSI" :usbid "0x04da" "0x1000" :status :untested :model "KV-S2028C" :interface "USB" :usbid "0x04da" "0x100a" :status :untested :model "KV-S2045C" :interface "SCSI" :status :untested :model "KV-S2046C" :interface "USB SCSI" :usbid "0x04da" "0x1001" :status :untested :model "KV-S2048C" :interface "USB" :usbid "0x04da" "0x1009" :status :untested sane-backends-1.0.29/doc/descriptions/matsushita.desc0000666000000000000000000000317013615534521017477 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "matsushita" ; name of backend :version "1.0-7 (unmaintained)" ; version of backend :manpage "sane-matsushita" ; name of manpage :url "http://www.zago.net/sane" ; backend's web page :devicetype :scanner ; start of a list of devices.... :mfg "Panasonic" ; name a manufacturer :url "http://www.panasonic.com/" :model "KV-SS25" :interface "SCSI" :status :complete :model "KV-SS25D" :interface "SCSI" :status :complete :model "KV-SS50" :interface "SCSI" :status :untested :model "KV-SS55" :interface "SCSI" :status :untested :model "KV-SS50EX" :interface "SCSI" :status :untested :model "KV-SS55EX" :interface "SCSI" :status :minimal :comment "no color, no high resolution, no automatic cropping" :model "KV-SS850" :interface "SCSI" :status :untested :model "KV-SS855" :interface "SCSI" :status :untested :model "KV-S2025C" :interface "SCSI" :status :minimal :comment "no color, no high resolution, no automatic cropping" :model "KV-S2045C" :interface "SCSI" :status :minimal :comment "no color, no high resolution, no automatic cropping" :model "KV-S2065L" :interface "SCSI" :status :minimal :comment "no color, no high resolution, no automatic cropping" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/hp3900.desc0000666000000000000000000000346313615534521016245 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; ; See doc/descriptions.txt for details. :backend "hp3900" :version "0.12 (unmaintained)" :manpage "sane-hp3900" :url "http://sourceforge.net/projects/hp3900-series/" :comment "Still Beta" :devicetype :scanner ; ----------------------------------------------------- :mfg "Hewlett-Packard" :url "http://www.hp.com" :model "ScanJet 3800" :interface "USB" :status :basic :usbid "0x03f0" "0x2605" :comment "Works with resolutions equal and less than 600dpi" :model "ScanJet 3970c" :interface "USB" :status :good :usbid "0x03f0" "0x2305" :model "ScanJet 4070 Photosmart" :interface "USB" :status :good :usbid "0x03f0" "0x2405" :model "ScanJet 4370" :interface "USB" :usbid "0x03f0" "0x4105" :status :basic :comment "Works with resolutions lower than 1200dpi" :model "ScanJet G2710" :interface "USB" :usbid "0x03f0" "0x2805" :status :basic :comment "Similar to hp scanjet 3800" :model "ScanJet G3010" :interface "USB" :usbid "0x03f0" "0x4205" :status :basic :comment "Similar to hp scanjet 4370" :model "ScanJet G3110" :interface "USB" :usbid "0x03f0" "0x4305" :status :basic :comment "Similar to hp scanjet 4370" ; ----------------------------------------------------- :mfg "UMAX" :url "http://www.umax.com" :model "Astra 4900" :interface "USB" :usbid "0x06dc" "0x0020" :status :minimal :comment "developing yet" ; ----------------------------------------------------- :mfg "BenQ" :url "http://www.benq.com/" :model "5550" :interface "USB" :usbid "0x04a5" "0x2211" :status :minimal :comment "developing yet" sane-backends-1.0.29/doc/descriptions/mustek.desc0000666000000000000000000000765113615534521016635 00000000000000; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "mustek" ; name of backend :version "1.0-138 (unmaintained)" ; version of backend :manpage "sane-mustek" ; name of manpage (if it exists) :url "http://www.meier-geinitz.de/sane/mustek-backend/" :comment "Most Mustek SCSI scanners are supported by this backend. For USB scanners, look at the mustek_usb backend." :devicetype :scanner :mfg "Mustek" ; name a manufacturer :url "http://www.mustek.com/" :url "http://www.mustek.com.tw/" :url "http://www.mustek.de/" :model "Paragon MFS-6000CX" :interface "SCSI" :comment "3-pass" :status :good :model "Paragon MFS-12000CX" :interface "SCSI" :comment "3-pass" :status :good :model "Paragon MFC-600S" :interface "SCSI" :status :complete :model "Paragon 600 II CD" :interface "SCSI" :status :complete :model "Paragon 600 II ED" :interface "Parport" :status :untested :comment "Completely untested. If it's the same as the 600 II EP, it may work. Please contact me if you own such a device." :model "Paragon 600 II EP" :interface "Parport" :status :minimal :comment "Works, however only low resolutions and quality in color mode is bad." :model "ScanMagic 600 II SP" :interface "SCSI" :status :complete :model "TwainScan II SP" :interface "SCSI" :status :complete :model "Paragon MFC-800S" :interface "SCSI" :status :complete :model "Paragon 800 II SP" :interface "SCSI" :status :complete :model "Paragon MFS-6000SP" :interface "SCSI" :status :complete :model "Paragon MFS-8000SP" :interface "SCSI" :status :complete :model "Paragon MFS-1200SP" :interface "SCSI" :status :complete :model "Paragon MFS-12000SP" :interface "SCSI" :status :complete :model "ScanExpress 6000SP" :interface "SCSI" :status :complete :model "ScanExpress 12000SP" :interface "SCSI" :status :complete :model "ScanExpress 1200 FS" :interface "SCSI" :status :untested :comment "One report that it crashes the computer. SCSI driver issue? Please contact me if you own such a device." :model "ScanExpress 12000SP Plus" :interface "SCSI" :status :complete :model "Paragon 1200 III SP" :interface "SCSI" :status :complete :model "Paragon 1200 LS" :interface "SCSI" :status :complete :model "ScanMagic 9636S" :interface "SCSI" :status :complete :model "ScanMagic 9636S Plus" :interface "SCSI" :status :complete :model "ScanExpress A3 SP" :interface "SCSI" :comment "Please test!" :status :basic :model "Paragon 1200 SP Pro" :interface "SCSI" :status :good :model "Paragon 1200 A3 Pro" :interface "SCSI" :status :complete :comment "ADF and TA untested. Please contact me if you own such equipment." :model "Paragon 600 II N" :interface "Proprietary" :status :basic :comment "Resolutions above 300 dpi may cause trouble." :mfg "Trust" ; name a manufacturer :url "http://www.trust-site.com" :comment "Carefully check the model names. Trust uses similar names for completely different hardware." :model "Imagery 1200" :interface "SCSI" :status :good :comment "3-pass, Mustek Paragon MFS-6000CX compatible" :model "Imagery 1200 SP" :interface "SCSI" :status :complete :comment "Mustek Paragon MFS-6000SP compatible" :model "Imagery 4800 SP" :interface "SCSI" :status :complete :comment "Mustek Paragon 600 II CD compatible" :model "SCSI Connect 19200" :interface "SCSI" :status :complete :comment "Mustek ScanExpress 12000SP compatible" :model "SCSI excellence series 19200" :interface "SCSI" :status :complete :comment "Mustek ScanExpress 12000SP compatible" :mfg "Primax" ; name a manufacturer :url "http://www.primax.nl/" :model "Compact 4800 SCSI" :interface "SCSI" :status :complete :comment "Mustek 600 II CD compatible" ; :comment and :url specifiers are optional after :mfg, :model, :desc, ; and at the top-level. sane-backends-1.0.29/doc/descriptions/st400.desc0000666000000000000000000000076113615534521016172 00000000000000; ST400 backend .desc by Ingo Wilken :backend "st400" ; name of backend :version "1.6 (unmaintained)" ; version number :manpage "sane-st400" ; name of manpage (if it exists) :url "http://www.informatik.uni-oldenburg.de/~ingo/sane/" ; backend's web page :devicetype :scanner ; start of a list of devices :mfg "Siemens" :url "http://www.siemens.de/" :model "ST400" :interface "SCSI" :comment "6 bit gray" :status :basic :model "ST800" :interface "SCSI" :comment "6 bit gray" :status :basic sane-backends-1.0.29/doc/descriptions/magicolor.desc0000666000000000000000000000234713615534521017276 00000000000000; ; SANE Backend specification file for the magicolor backend ; ; Copyright (C) 2010-11 Reinhold Kainhofer ; Released under GPLv2 ; :backend "magicolor" :version "1.0.0 (unmaintained)" :manpage "sane-magicolor" :url "http://wiki.kainhofer.com/hardware/magicolor_scan" :devicetype :scanner :mfg "KONICA MINOLTA" :url "http://www.konicaminolta.com/" :model "magicolor 1690MF" :interface "USB Network" :usbid "0x132b" "0x2089" :status :good :comment "Multi-function color laser printer with fax, scanner and network interface" :url "http://www.konicaminolta.eu/business-solutions/products/laser-printers/all-in-one/magicolor-1690mf/key-features.html" :model "magicolor 4690MF" :interface "USB Network" :usbid "0x132b" "0x2079" :status :good :comment "Multi-function color laser printer with fax, scanner and network interface" :model "BizHub 162/132" :interface "USB Network" :usbid "ignore" :status :unsupported :comment "Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov." :model "DiMage 1611" :interface "USB Network" :usbid "ignore" :status :unsupported :comment "Uses a similar protocol as the magicolor 1690MF, according to Ilia Sotnikov." sane-backends-1.0.29/doc/descriptions/plustek.desc0000666000000000000000000001464313615534521017013 00000000000000; ; SANE Backend description file for Plustek backend (USB only) ; :backend "plustek" :version "0.52" :manpage "sane-plustek" :devicetype :scanner ;* Plustek ********************************************************************************** :mfg "Plustek" :url "http://www.plustek.de/" :url "http://www.plustek.com/" :model "OpticPro U12" :interface "USB" :usbid "0x07b3" "0x0010" :status :complete :comment "NOTE: Devices with product ID 0x0001 are not supported!" :model "OpticPro UT12" :interface "USB" :usbid "0x07b3" "0x0013" :status :complete :model "OpticPro UT12" :interface "USB" :usbid "0x07b3" "0x0017" :status :complete :comment "Note: Devices with product ID 0x0001 are not supported!" :model "OpticPro UT16" :interface "USB" :usbid "0x07b3" "0x0017" :status :complete :model "OpticPro U24" :interface "USB" :usbid "0x07b3" "0x0011" :status :complete :model "OpticPro U24" :interface "USB" :usbid "0x07b3" "0x0015" :status :complete :model "OpticPro UT24" :interface "USB" :usbid "0x07b3" "0x0017" :status :complete ;* Genius/KYE ******************************************************************************************* :mfg "Genius" :url "http://www.geniusnet.com.tw/" :model "Colorpage HR6 V2" :interface "USB" :usbid "0x0458" "0x2007" :status :complete :model "Colorpage HR6 V2" :interface "USB" :usbid "0x0458" "0x2008" :status :complete :model "Colorpage HR7" :interface "USB" :usbid "0x0458" "0x2013" :status :complete :model "Colorpage HR6A" :interface "USB" :usbid "0x0458" "0x2009" :status :untested :model "Colorpage HR7LE" :interface "USB" :usbid "0x0458" "0x2015" :status :untested :model "Colorpage HR6X" :interface "USB" :usbid "0x0458" "0x2016" :status :untested ;* MUSTEK *********************************************************************************** :mfg "Mustek" :url "http://www.mustek.com/" :model "BearPaw 1200" :interface "USB" :usbid "0x0400" "0x1000" :status :complete :comment "both product versions are supported, see backends' man-page" :model "BearPaw 1200" :interface "USB" :usbid "0x0400" "0x1001" :status :complete :comment "both product versions are supported, see backends' man-page" :model "BearPaw 2400" :interface "USB" :usbid "0x0400" "0x1001" :status :complete ;* Hewlett-Packard ************************************************************************** :mfg "Hewlett-Packard" :url "http://www.hp.com/" :model "ScanJet 2100C" :interface "USB" :usbid "0x03f0" "0x0505" :status :complete :model "ScanJet 2200C" :interface "USB" :usbid "0x03f0" "0x0605" :status :complete ;* EPSON ******************************************************************************************* :mfg "Epson" :url "http://www.epson.com/" :model "Perfection 1250" :interface "USB" :usbid "0x04b8" "0x010f" :status :complete :model "Perfection 1250Photo" :interface "USB" :usbid "0x04b8" "0x010f" :status :good :comment "TPA scans not perfect" :model "Perfection 1260" :interface "USB" :usbid "0x04b8" "0x011d" :status :complete :model "Perfection 1260Photo" :interface "USB" :usbid "0x04b8" "0x011d" :status :good :comment "TPA scans not perfect" ;* UMAX ************************************************************************************* :mfg "Umax" :url "http://www.umax.com/" :model "UMAX 3400" :interface "USB" :usbid "0x1606" "0x0050" :status :complete :comment "there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x" :model "UMAX 3400" :interface "USB" :usbid "0x1606" "0x0060" :status :complete :comment "there are some UMAX 3400 outside the U.S. which are not supported, as they use another chipset than the LM983x" :model "UMAX Astranet ia101" :interface "USB" :usbid "0x1606" "0x0060" :status :complete :comment "seems to be a renamed UMAX 3400" :model "UMAX 3450" :interface "USB" :usbid "0x1606" "0x0060" :status :complete :model "UMAX 5400" :interface "USB" :usbid "0x1606" "0x0160" :status :complete ;* COMPAQ ****************************************************************************************** :mfg "Compaq" :url "http://www.compaq.com/" :model "S4-100" :interface "USB" :usbid "0x049f" "0x001a" :status :complete :comment "Identical to UMAX 3400" ;* CANON ******************************************************************************************* :mfg "Canon" :url "http://www.canon.com/" :model "CanoScan N650U" :interface "USB" :usbid "0x04a9" "0x2206" :status :complete :model "CanoScan N656U" :interface "USB" :usbid "0x04a9" "0x2206" :status :complete :comment "Identical to CanoScan N650U" :model "CanoScan N1220U" :interface "USB" :usbid "0x04a9" "0x2207" :status :complete :model "CanoScan N670U" :interface "USB" :usbid "0x04a9" "0x220d" :status :complete :model "CanoScan N676U" :interface "USB" :usbid "0x04a9" "0x220d" :status :complete :comment "Identical to CanoScan N670U" :model "CanoScan LiDE 20" :interface "USB" :usbid "0x04a9" "0x220d" :status :complete :comment "Identical to CanoScan N670U" :model "CanoScan N1240U" :interface "USB" :usbid "0x04a9" "0x220e" :status :complete :model "CanoScan LiDE 30" :interface "USB" :usbid "0x04a9" "0x220e" :status :complete :comment "Identical to CanoScan N1240U" :model "CanoScan LiDE 25" :interface "USB" :usbid "0x04a9" "0x2220" :status :good :model "CanoScan D660U" :interface "USB" :usbid "0x04a9" "0x2208" :status :good :comment "TPA scans not perfect" ;* SYSCAN ******************************************************************************************* :mfg "Syscan" :url "http://www.syscaninc.com/" :model "TravelScan 460/464" :interface "USB" :usbid "0x0a82" "0x4600" :status :complete :model "TravelScan 662" :interface "USB" :usbid "0x0a82" "0x6620" :status :complete ;* SYSCAN ******************************************************************************************* :mfg "Ambir" :model "Visigo A4" :interface "USB" :usbid "0x0a82" "0x4600" :status :complete :comment "Rebaged Travelscan 464" ;* Portable Peripheral Co., Ltd. ******************************************************************** :mfg "Portable Peripheral Co., Ltd." :url "http://www.pandp.com.tw/" :model "Q-Scan USB001 (A4 portable scanner)" :interface "USB" :usbid "0x0a53" "0x1000" :status :complete :model "Q-Scan USB201 (A6 portable scanner)" :interface "USB" :usbid "0x0a53" "0x2000" :status :good ;* Visioneer **************************************************************************************** :mfg "Visioneer" :url "http://www.visioneer.com/" :model "Strobe XP 100" :interface "USB" :usbid "0x04a7" "0x0427" :status :basic sane-backends-1.0.29/doc/descriptions/microtek.desc0000666000000000000000000000416213615534521017134 00000000000000:backend "microtek" :version "0.13.1 (unmaintained)" :manpage "sane-microtek" :url "http://www.mir.com/mtek/" :devicetype :scanner :mfg "Microtek" :url "http://www.microtek.com/" :model "Scanmaker E6" :interface "SCSI" :status :good :model "Scanmaker E3" :interface "SCSI" :status :good :model "Scanmaker E2" :interface "SCSI" :comment "3-pass" :status :good :model "Scanmaker 35t+" :interface "SCSI" :comment "slide-scanner" :status :good :model "Scanmaker 45t" :interface "SCSI" :comment "slide-scanner" :status :good :model "Scanmaker 35" :interface "SCSI" :comment "slide-scanner" :status :good :model "Scanmaker III" :interface "SCSI" :status :good :model "Scanmaker IISP" :interface "SCSI" :status :good :model "Scanmaker IIHR" :interface "SCSI" :comment "3-pass" :status :good :model "Scanmaker IIG" :interface "SCSI" :comment "gray only" :status :good :model "Scanmaker II" :interface "SCSI" :comment "3-pass" :status :good :model "Scanmaker 600Z(S)" :interface "SCSI" :status :untested :model "Scanmaker 600G(S)" :interface "SCSI" :comment "gray only (see manpage)" :status :basic :model "Color PageWiz" :interface "SCSI (Parport)" :comment "sheet-fed (preliminary, see mapage)" :status :basic :mfg "Agfa" :url "http://www.agfa.com/" :model "Arcus II" :interface "SCSI" :comment "Arcus *II*, not Arcus!" :status :good :model "StudioScan" :interface "SCSI" :status :good :model "StudioScan II" :interface "SCSI" :status :good :model "StudioScan IIsi" :interface "SCSI" :status :good :model "Studiostar" :interface "SCSI" :status :minimal :comment "Is detected but scans are very dark" :model "DuoScan" :interface "SCSI" :status :basic :mfg "Vobis" :url "http://www.vobis.de/" :model "Highscreen Realscan" :interface "SCSI" :status :good :mfg "Genius" :url "http://www.genius-kye.com/" :model "Colorpage-SP2" :interface "SCSI" :comment "Same as Microtek Scanmaker E3" :status :good sane-backends-1.0.29/doc/descriptions/artec_eplus48u.desc0000666000000000000000000000373713615534521020175 00000000000000; ; SANE Backend specification file ; :backend "artec_eplus48u" :version "unmaintained" :manpage "sane-artec_eplus48u" ;:url "http://www.angelfire.com/linux/crapsite/" :devicetype :scanner :mfg "Artec/Ultima" :url "http://www.artecusa.com/" :model "E+ 48U" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :comment "CIS scanner based on the GT6816 chip. Apparently all other devices are re-badged Artec scanners." :model "E+ Pro" :status :minimal :interface "USB" :usbid "0x05d8" "0x4004" :comment "Works up to 600dpi, but not 1200. Needs better calibration. See bug #310490" :mfg "Medion/Lifetec/Tevion/Cytron" :url "http://www.medion.com" :comment "Sold by Aldi and Tchibo." :model "MD9693" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :model "MD9705" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :model "MD4394" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :comment "Only scanners with product id 0x4003 will work; try the gt68xx backend, if your scanner has product id 0x4002 " :mfg "Trust" :url "http://www.trust-site.com" :model "Easy Webscan 19200" :status :good :interface "USB" :usbid "0x05d8" "0x4006" :model "240H Easy Webscan Gold" :status :basic :interface "USB" :usbid "0x05d8" "0x4007" :comment "Works up to 600 dpi" :mfg "Memorex" :url "http://www.artecusa.com/" :model "MEM 48U" :status :good :interface "USB" :usbid "0x05d8" "0x4005" :mfg "Microstar" :url "http://www.microstar.de/" :model "MR 9791" :status :good :interface "USB" :usbid "0x05d8" "0x4003" :mfg "UMAX" :url "http://www.umax.com/" :url "http://www.umax.com.tw/" :url "http://www.umax.de/en" :url "http://www.umax-europe.com" :url "http://www.umaxjapan.co.jp" :url "http://www.umax.com.cn" :model "AstraSlim SE" :status :good :interface "USB" :usbid "0x05d8" "0x4009" :model "AstraSlim 1200 SE" :status :good :interface "USB" :usbid "0x05d8" "0x4010" :mfg "Yakumo" :url "http://www.yakumo.com/" :model "Scan50" :status :good :interface "USB" :usbid "0x05d8" "0x4011" sane-backends-1.0.29/doc/descriptions/microtek2.desc0000666000000000000000000000631013615534521017213 00000000000000; ; SANE Backend specification file ; ; It's basically emacs-lisp --- so ";" indicates comment to end of line. ; All syntactic elements are keyword tokens, followed by a string or ; keyword argument, as specified. ; ; ":backend" *must* be specified. ; All other information is optional (but what good is the file without it?). ; :backend "microtek2" ; name of backend :version "unmaintained" ; version of backend :manpage "sane-microtek2" ; name of manpage (if it exists) :url "http://karstenfestag.gmxhome.de/linux.html" :devicetype :scanner ; start of a list of devices.... :mfg "Microtek" ; name a manufacturer :url "http://www.microtek.com/" :model "ScanMaker E3plus" :interface "Parport" :status :complete :model "ScanMaker E3plus" ; name models for above-specified mfg. :interface "SCSI" :status :complete :model "ScanMaker X6" :interface "SCSI" :status :complete :model "ScanMaker X6EL" :interface "SCSI" :status :basic :model "ScanMaker X6USB" :interface "USB" :usbid "0x05da" "0x0099" :status :good :model "ScanMaker V300" :interface "SCSI" :status :good :model "ScanMaker V300" :interface "Parport" :status :good :model "ScanMaker V310" :interface "SCSI" :status :basic :model "ScanMaker V310" :interface "Parport" :status :basic :model "ScanMaker V600" :interface "SCSI" :status :basic :model "ScanMaker V600" :interface "Parport" :status :basic :model "ScanMaker 330" :interface "SCSI" :status :basic :model "ScanMaker 630" :interface "SCSI" :status :basic :model "ScanMaker 636" :interface "SCSI" :status :complete :model "ScanMaker 6400XL" :interface "SCSI" :status :complete :model "ScanMaker 9600XL" :interface "SCSI" :comment "only flatbed mode ?" :status :good :model "ScanMaker 9800XL" :url "unsupported/microtek-scanmaker-9800.html" :interface "IEEE-1394" :status :minimal :comment "IEEE-1394 seems to work. See link. More reports welcome." :model "Phantom 330CX" :interface "Parport" :status :complete :model "SlimScan C3" :interface "Parport" :status :complete :model "Phantom 636" :interface "SCSI" :status :complete :model "Phantom 636CX" :interface "Parport" :status :complete :model "SlimScan C6" :interface "USB" :usbid "0x05da" "0x009a" :status :complete :model "ScanMaker V6UPL" :interface "USB" :usbid "0x05da" "0x00b6" :status :basic :comment "Sometimes scan speed goes to fast and results look badly smudged." :model "ScanMaker V6USL" :interface "SCSI" :status :complete :model "ScanMaker V6USL" :interface "USB" :usbid "0x05da" "0x00a3" :status :complete :model "ScanMaker V6USL" :interface "USB" :usbid "0x05da" "0x80a3" :status :complete :model "ScanMaker X12USL" :interface "SCSI" :comment "only Flatbed mode ?" :status :good :mfg "Vobis" :url "http://www.vobis.de/" :model "HighScan" ; name models for above-specified mfg. :interface "SCSI" :comment "only E3plus based models" :status :complete :mfg "Scanport" :url "http://www.scanport.com/" :model "SQ300" :interface "Parport?" :status :basic :model "SQ2030" :interface "Parport" :status :basic :model "SQ4836" :interface "SCSI" :status :basic :mfg "Genius" :url "http://www.geniusmouse.co.uk/" :model "ColorPage-EP" :interface "Parport" :status :good sane-backends-1.0.29/doc/u12/0000755000000000000000000000000013615535552012436 500000000000000sane-backends-1.0.29/doc/u12/U12.changes0000666000000000000000000000157713615534521014270 00000000000000U12.changes - Gerhard Jäger ================================================ V 0.01-1 (2004-09-01) --------------------- - initial version V 0.02-1 (2004-10-01) --------------------- - fixed autodetection problem - enabled additional scan-modes - enabled TPA scanning - fixed corrupted picture problem V 0.02-4 (2004-19-01) --------------------- - activated cancel function - added lamp off timer function V 0.02-6 (2004-21-01) --------------------- - compilation fixes - changes to some structures V 0.02-9 (2004-06-10) --------------------- - using now SANE definitions for scanmodes V 0.02-10 (2006-14-02) ---------------------- - SoftwareReset is now disabled in cancelSequence when the device is a Genius (reported by Jose Alberto Reguero ) V 0.02-11 (2006-09-08) ---------------------- - Changed sane.type to "flatbed scanner" only sane-backends-1.0.29/doc/u12/U12.todo0000666000000000000000000000040013615534521013605 00000000000000U12.todo (2004-19-01) Gerhard Jäger ========================================================= OPEN: ----- - 1200dpi modes - spurious I/O stall - binary mode inverted - preview mode - TPA does not work - reopen after lamp off on end sane-backends-1.0.29/doc/sane-niash.man0000666000000000000000000000363113615534521014474 00000000000000.\" $Id$ .TH sane\-niash 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-niash .SH NAME sane\-niash \- SANE backend for scanners based on the NIASH chipset. .SH DESCRIPTION The .B sane\-niash implements a SANE (Scanner Access Now Easy) backend that provides access to NIASH chipset based scanners. This backend will try to support the following models: .ft CR .nf MANUFACTURER: MODEL: USB ID: --------------- ---------------- --------- Agfa Snapscan Touch 06BD-0100 (1)(a) Trust Office Scan 19200 047B-1000 (1)(a) Hewlett-Packard Scanjet 3300c 03F0-0205 (1)(a)(b) Hewlett-Packard Scanjet 3400c 03F0-0405 (2)(b) Hewlett-Packard Scanjet 4300c 03F0-0305 (2)(a) Silitek ScanJet 4300c 047B-1002 (2)(b) .fi .ft R .PP .br ASIC: (1) \- NIASH00012/00013/00014 / (2) \- NIASH00019 .br ANALOG FRONT-END: (a) \- ESIC ES8100QA / (b) \- WM8143-12 .br .SH CONFIGURATION The .I niash.conf file is meant for future configuration options. Empty lines and lines starting with a hash mark (#) are ignored. Currently no configuration options exist. .SH FILES .TP .I @LIBDIR@/libsane\-niash.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-niash.so The shared library implementing this backend (present on systems that support dynamic loading). .SH CAVEATS If you use a .br Hewlett-Packard Scanjet 3400c or .br Hewlett-Packard Scanjet 4300c .br together with Linux kernel .BR 2.6 , kernel version .B 2.6.8 or newer is necessary. .SH ENVIRONMENT .TP .B SANE_DEBUG_NIASH If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_NIASH=255 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5) .br http://www.sourceforge.net/projects/hp3300backend .SH AUTHOR Bertrik Sikken sane-backends-1.0.29/doc/sane-teco2.man0000666000000000000000000001537313615534521014414 00000000000000.TH sane\-teco2 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-teco2 .SH NAME sane\-teco2 \- SANE backend for TECO / RELISYS scanners .SH DESCRIPTION The .B sane\-teco2 library implements a SANE (Scanner Access Now Easy) backend that provides access to some TECO SCSI flatbed scanners. This backend should be considered .B beta-quality software! TECO scanners are sold under various brands like Mustek, Relisys, Piotech, Primax, TRUST. This backend may or may not support yours. .PP The scanners that should work with this backend are: .PP .RS .ft CR .nf Vendor Model TECO model status ---------------------- -------------- ----------- Mustek ScanMagic 4830S VM3575 untested Primax Jewel 4800 VM356A good Primax Profi 9600 VM6575 basic Primax Profi 19200 VM6586 good Relisys APOLLO Express 3 VM356A basic Relisys APOLLO Express 6 VM6565 good Relisys APOLLO Express 12 ? untested Relisys AVEC II S3 VM3564 good Relisys AVEC Super 3 VM3575 basic Relisys SCORPIO Pro VM6575 good Relisys SCORPIO Pro-S VM6586 untested Relisys SCORPIO Super 3 VM3575 good .fi .ft R .RE For all these scanners, lineart and gray mode work well. However, most of them do not support more than a handful of resolutions in color mode. See the backend home page (under AUTHOR) for the exact status of each scanner. Note that the untested scanner will not be directly supported. You should contact the author for that. The TECO VM number can usually be found at the back of the scanner. It is also part of the FCC ID. The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage, xsane, quiteinsane or kooka. .br If you have any success with a scanner not listed here, or if you have any strange behavior, please report to the backend maintainer or to the SANE mailing list. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d teco2 .RE .TP .B Scan Mode .TP .B \-\-mode selects the basic mode of operation of the scanner valid choices are .I Lineart , .I Gray and .I Color The Lineart mode is black and white only (1 bit). Gray mode will produce 256 levels of gray (8 bits). Color will produce a 24 bits color image. .TP .B \-\-resolution Lineart and Gray selects the resolution for a scan. The scanner can do all resolutions between 1 and 600, in increments of 1. Color selects the resolution for a scan. The scanner can do only the resolutions listed. All values with ydpi > 300 (300 x 600) or 600 (600 x 1200) result in a wrong proportion for the scan. The proportion can be adjusted with the following imagemagick command: convert \-geometry (dpi/max_xdpi * 100%)x100% max_xdpi is for the vm3575 constant with 300 dpi e.g. 600dpi adjust with: convert \-geometry 200%x100% .TP .B Geometry options .TP .B \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters by default. .TP .B Enhancement options .TP .B \-\-custom\-gamma (no custom gamma option for the VM3564 and VM356A) (color mode only) allows the user to specify a gamma table (see the next 3 parameters). .TP .B \-\-red\-gamma\-table (color mode only) can be used to download a user defined gamma table for the red channel. The table must be 256 bytes long. .TP .B \-\-green\-gamma\-table (color mode only) can be used to download a user defined gamma table for the green channel. The table must be 256 bytes long. .TP .B \-\-blue\-gamma\-table (color mode only) can be used to download a user defined gamma table for the blue channel. The table must be 256 bytes long. .TP .B \-\-white\-level\-r (VM3564, VM356A, VM3575 and VM6575 only) Selects what red radiance level should be considered "white", when scanning some sheets by changing the calibration value loaded into the scanner. Scale 0..64 in steps of 1. .TP .B \-\-white\-level\-g (VM3564, VM356A, VM3575 and VM6575 only) Selects what green radiance level should be considered "white", when scanning some sheets by changing the calibration i value loaded into the scanner. Scale 0..64 in steps of 1. .TP .B \-\-white\-level\-b (VM3564, VM356A, VM3575 and VM6575 only) Selects what blue radiance level should be considered "white", when scanning some sheets by changing the calibration value loaded into the scanner. Scale 0..64 in steps of 1. .TP .B \-\-preview requests a preview scan. The resolution used for that scan is 50 dpi (for VM356A and VM6575 75 dpi) and the scan area is the maximum allowed. The scan mode is user selected. The default is "no". .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/teco2.conf supports only one information: the device name to use (eg /dev/scanner). .SH FILES .TP .I @LIBDIR@/libsane\-teco2.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-teco2.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_TECO2 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .TP .B SANE_TECO2_CAL_ALGO Either 0 or 1. Selects the algorithm for the calibration. A value of 1 seems to give better scans on the VM356A, VM3575. Feedback on it is welcome. For VM3564, VM356A, VM3575, VM6575 default 1. For other supported types default 0. .SH LIMITATIONS The windows TWAIN driver has many more options than this SANE backend. However they are only software adjustments. This backend only implements what the scanner can support. .SH BUGS Plenty. Parts of this backend are still under development. .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1), sane(7) .SH AUTHORS .TP Frank Zago .I http://www.zago.net/sane/#teco2 .TP The package is actively maintained by Gerard Klaver. .I http://gkall.hobby.nl/teco2.html .SH CREDITS Thanks to: .TP Gerard Klaver for his relentless VM3575 testings and contributed a patch to support the VM3564 and VM356A. .TP Mark Plowman for providing the first SCSI traces from a VM3575. .TP Andreas Klaedtke for providing the first SCSI traces from a VM6586 and for his testing, and to Stefan von Dombrowski for his testing. .TP Nicolas Peyresaubes for providing the first SCSI traces from a VM656A and for his testing. .TP Dave Parker for testing the support for the VM6575. .TP Michael Hoeller for testing the support for the VM356A. .TP Christoph.Hoeffner for testing the support for the VM3564 (Relisys AVEC II S3 firmware 1.09). sane-backends-1.0.29/doc/sane-leo.man0000666000000000000000000000722513615534521014154 00000000000000.TH sane\-leo 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-leo .SH NAME sane\-leo \- SANE backend for LEO Technologies scanners .SH DESCRIPTION The .B sane\-leo library implements a SANE (Scanner Access Now Easy) backend that provides access to some LEO SCSI flatbed scanners. This backend should be considered .B beta-quality software! LEO scanners were also sold under the Across Technologies brand. .PP The scanners that should work with this backend are: .PP .RS .ft CR .nf Vendor Model status ---------------------- ----------- Across FS-1130 tested Leo S3 tested .fi .ft R .RE The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage or xsane. .br If you have any strange behavior, please report to the backend maintainer or to the SANE mailing list. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d leo .RE .TP .B Scan Mode .TP .B \-\-mode selects the basic mode of operation of the scanner valid choices are .I Black & White , .I Grayscale and .I Color The Black & White mode is black and white only (1 bit). Grayscale will produce 256 levels of gray (8 bits). Color will produce a 24 bits color image. .TP .B \-\-resolution selects the resolution for a scan. The scanner can do all resolutions between 1 and 300, in increments of 1. .TP .B Geometry options .TP .B \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters by default. .TP .B Enhancement options .TP .B \-\-custom\-gamma (grayscale and color mode only) allows the user to specify a gamma table (see the next 3 parameters). .TP .B \-\-red\-gamma\-table (color mode only) can be used to download a user defined gamma table for the red channel. The table must be 256 bytes long. .TP .B \-\-green\-gamma\-table (color mode only) can be used to download a user defined gamma table for the green channel. The table must be 256 bytes long. .TP .B \-\-blue\-gamma\-table (color mode only) can be used to download a user defined gamma table for the blue channel. The table must be 256 bytes long. .TP .B \-\-halftone (Black & White only) select the halftone mask to use. Possible values are .I Diamond , .I 8x8 Coarse Fatting , .I 8x8 Fine Fatting , .I 8x8 Bayer and .I 8x8 Vertical Line .TP .B \-\-preview requests a preview scan. The resolution used for that scan is 28 dpi and the scan area is the maximum allowed. The scan mode is user selected. The default is "no". .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/leo.conf supports only one information: the device name to use (eg /dev/scanner). .SH FILES .TP .I @LIBDIR@/libsane\-leo.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-leo.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_LEO If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH LIMITATIONS The windows TWAIN driver has many more options than this SANE backend. However they are only software adjustments. This backend only implements what the scanner can support. .SH BUGS None known. .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1), sane(7) .SH AUTHOR .TP The package is actively maintained by Frank Zago. .I http://www.zago.net/sane/#leo sane-backends-1.0.29/doc/niash/0000755000000000000000000000000013615535552013131 500000000000000sane-backends-1.0.29/doc/niash/niash.TODO0000666000000000000000000000406213615534521014643 00000000000000To do: ====== - implement coarse calibration to determine settings for analog-front-end All CCDs encountered so far seem to need about the same settings however. - Store analog calibration data somewhere. Use currently used values as default. - Suggestions by Marcin Cieslak: - clean up structures - clean up namespace - clean up source formatting ('indent --gnu' ?) - implement real calibration, using 12 bit data at 600 dpi instead of 8 bit data.at 150 dpi. -> is now at 600 dpi, not yet at 12 bit - design a mechanism to set the scan and calibration areas a) part of HWProps structure, or b) set by user at first scan - further investigate scanner registers a) study backtracking register more b) identify bits in bit-oriented registers. - add more error checking ('sanity checking') on parameters - figure out what the USB interrupts mean that sometimes occur. Done ==== - Get rid of mytypes.h / fix types Now an int is implicitly assumed to be 32 bit. - make backend comply with tstbackend -> all externs and publics removed when compiling towards sane - implement sane_cancel properly -> done by ullsig - implement timing mechanism for scanner lamp so scanning can only start if the lamp was already on for 30 seconds Possible implementation: On startup: if lamp is off, turn it on and start timer On scan: if lamp is off, turn it on and start timer. Wait for timer expiry. On exit: if scanner chip is niash00012 then turn off lamp, otherwise let the scanner turn it off automatically -> Implemented by Ullrich Sigwanz - try out parallel port scanning on HP3400/4300 -> parallel port support will be dropped, no people to test/develop it - investigate vertical resolution setting of hp3400/4300. -> experiment with the motor table, formula is already known to generate it -> 600 dpi is possible by doubling most values in the table -> 150 dpi can be done by using register 0x06 to skip every other line - Add separate gamma tables for R, G, B. This should be easy (look at how other backends do it) but is not really required yet. -> not required sane-backends-1.0.29/doc/Makefile.in0000644000000000000000000011447013615534556014026 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @WITH_API_PS_TRUE@am__append_1 = sane.ps @WITH_API_PDF_TRUE@am__append_2 = sane.pdf @WITH_API_HTML_TRUE@am__append_3 = sane-html subdir = doc ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(dist_doc_DATA) \ $(nobase_dist_doc_DATA) $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = doxygen-sanei.conf doxygen-genesys.conf CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man7dir)" \ "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(docdir)" \ "$(DESTDIR)$(docdir)" "$(DESTDIR)$(docdir)" man7dir = $(mandir)/man7 man8dir = $(mandir)/man8 NROFF = nroff MANS = $(man1_MANS) $(man7_MANS) $(man8_MANS) DATA = $(dist_doc_DATA) $(doc_DATA) $(nobase_dist_doc_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in \ $(srcdir)/doxygen-genesys.conf.in \ $(srcdir)/doxygen-sanei.conf.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_CPPFLAGS = @AM_CPPFLAGS@ AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ man1_MANS = scanimage.1 sane-config.1 sane-find-scanner.1 gamma4scanimage.1 EXTRA_DIST = scanimage.man sane-config.man sane-find-scanner.man \ gamma4scanimage.man sane-abaton.man sane-agfafocus.man \ sane-apple.man sane-as6e.man sane-dll.man sane-dc25.man \ sane-dmc.man sane-epson.man sane-epson2.man sane-epsonds.man \ sane-escl.man sane-hp.man sane-gphoto2.man sane-leo.man \ sane-lexmark.man sane-matsushita.man sane-microtek.man \ sane-microtek2.man sane-mustek.man sane-nec.man sane-net.man \ sane-pie.man sane-pieusb.man sane-pint.man sane-pnm.man \ sane-umax.man sane-qcam.man sane-scsi.man sane-artec.man \ sane-fujitsu.man sane-sharp.man sane-s9036.man \ sane-tamarack.man sane-kodak.man sane-kodakaio.man \ sane-ricoh.man sane-ricoh2.man sane-avision.man \ sane-plustek.man sane-st400.man sane-mustek_pp.man \ sane-dc210.man sane-v4l.man sane-snapscan.man sane-canon.man \ sane-coolscan.man sane-bh.man sane-dc240.man sane-umax_pp.man \ sane-umax1220u.man sane-sm3600.man sane-usb.man \ sane-mustek_usb.man sane-sceptre.man sane-canon_pp.man \ sane-canon630u.man sane-teco1.man sane-teco2.man \ sane-teco3.man sane-test.man sane-sp15c.man sane-coolscan2.man \ sane-hpsj5s.man sane-gt68xx.man sane-artec_eplus48u.man \ sane-ma1509.man sane-ibm.man sane-hp5400.man \ sane-plustek_pp.man sane-u12.man sane-niash.man \ sane-sm3840.man sane-genesys.man sane-hp4200.man \ sane-mustek_usb2.man sane-hp3500.man sane-pixma.man \ sane-stv680.man sane-hp5590.man sane-hpljm1005.man \ sane-cardscan.man sane-hp3900.man sane-epjitsu.man \ sane-hs2p.man sane-canon_dr.man sane-xerox_mfp.man \ sane-rts8891.man sane-coolscan3.man sane-kvs1025.man \ sane-kvs20xx.man sane-kvs40xx.man sane-p5.man \ sane-magicolor.man sane.man saned.man descriptions.txt \ releases.txt sane-logo2.jpg sane-logo.png sane.png \ $(DESC_FILES) descriptions/template.desc. $(DESC_EXT_FILES) \ descriptions-external/template.desc. $(API_SPEC_INPUTS) \ $(API_SPEC_TEX_FIGS) $(API_SPEC_HTML_ICONS) # Create a list of man pages for only backends that are compiled in so # that is all that gets installed. Also, build a complete list of all # backend man pages. This allows a user to optionally generate all # man pages in HTML form for things like posting to a web site. # # Backend man pages bypass standard automake man5_MANS because there is not # a man page for every supported backend. We could get rid of # custom install/uninstall if we required man pages for every backend. BACKEND_5MANS = sane-abaton.5 sane-agfafocus.5 sane-apple.5 sane-as6e.5 \ sane-dll.5 sane-dc25.5 sane-dmc.5 sane-epson.5 sane-epson2.5 sane-epsonds.5 \ sane-escl.5 sane-hp.5 sane-gphoto2.5 sane-leo.5 sane-lexmark.5 \ sane-matsushita.5 sane-microtek.5 sane-microtek2.5 sane-mustek.5 \ sane-nec.5 sane-net.5 sane-pie.5 sane-pieusb.5 sane-pint.5 sane-pnm.5 \ sane-umax.5 sane-qcam.5 sane-scsi.5 sane-artec.5 sane-kodak.5 sane-kodakaio.5 \ sane-fujitsu.5 sane-sharp.5 sane-s9036.5 sane-tamarack.5 \ sane-ricoh.5 sane-ricoh2.5 sane-avision.5 sane-plustek.5 sane-st400.5 \ sane-mustek_pp.5 sane-dc210.5 sane-v4l.5 sane-snapscan.5 \ sane-canon.5 sane-coolscan.5 sane-bh.5 sane-dc240.5 \ sane-umax_pp.5 sane-umax1220u.5 sane-sm3600.5 sane-usb.5 \ sane-mustek_usb.5 sane-sceptre.5 sane-canon_pp.5 sane-canon630u.5 \ sane-teco1.5 sane-teco2.5 sane-teco3.5 sane-test.5 sane-sp15c.5 \ sane-coolscan2.5 sane-hpsj5s.5 sane-gt68xx.5 sane-artec_eplus48u.5 \ sane-ma1509.5 sane-ibm.5 sane-hp5400.5 sane-plustek_pp.5 sane-u12.5 \ sane-niash.5 sane-sm3840.5 sane-genesys.5 sane-hp4200.5 \ sane-mustek_usb2.5 sane-hp3500.5 sane-pixma.5 sane-stv680.5 \ sane-hp5590.5 sane-hpljm1005.5 sane-cardscan.5 sane-hp3900.5 \ sane-epjitsu.5 sane-hs2p.5 sane-canon_dr.5 sane-xerox_mfp.5 \ sane-rts8891.5 sane-coolscan3.5 sane-kvs1025.5 sane-kvs20xx.5 \ sane-kvs40xx.5 sane-p5.5 sane-magicolor.5 man7_MANS = sane.7 man8_MANS = saned.8 MANPAGES = $(man1_MANS) $(BACKEND_5MANS) $(man7_MANS) $(man8_MANS) @CROSS_COMPILING_FALSE@HTML_PAGES = sane-backends.html sane-backends-external.html \ @CROSS_COMPILING_FALSE@ sane-mfgs.html sane-mfgs-external.html @CROSS_COMPILING_TRUE@HTML_PAGES = doc_DATA = $(HTML_PAGES) $(API_SPECS) dist_doc_DATA = backend-writing.txt nobase_dist_doc_DATA = $(BEDOCS) MAN2HTML = nroff -c -man |\ man2html -compress -topm 6 -botm 6 -nodepage -title $${page} \ -cgiurl '$$title.$$section.html'|\ sed 's,,

,' beman5dir = $(mandir)/man5 BEDOCS = canon/canon.changes canon/canon.install2700F.txt \ gt68xx/gt68xx.CHANGES gt68xx/gt68xx.TODO leo/leo.txt \ matsushita/matsushita.txt mustek/mustek.CHANGES \ mustek_usb/mustek_usb.CHANGES mustek_usb/mustek_usb.TODO \ mustek_usb2/mustek_usb2.CHANGES mustek_usb2/mustek_usb2.TODO \ niash/niash.TODO plustek/FAQ plustek/MakeModule.sh \ plustek/Makefile.kernel24 plustek/Makefile.kernel26 \ plustek/Plustek-PARPORT-TODO.txt \ plustek/Plustek-PARPORT.changes plustek/Plustek-PARPORT.txt \ plustek/Plustek-USB-TODO.txt plustek/Plustek-USB.changes \ plustek/Plustek-USB.txt sceptre/s1200.txt teco/teco1.txt \ teco/teco2.txt teco/teco3.txt u12/U12.changes u12/U12.todo \ umax/negative-types.txt umax/sane-logo.jpg \ umax/sane-umax-advanced-options-doc.html \ umax/sane-umax-advanced.jpg umax/sane-umax-astra-doc.html \ umax/sane-umax-config-doc.html umax/sane-umax-doc.html \ umax/sane-umax-histogram.jpg umax/sane-umax-mirage-doc.html \ umax/sane-umax-not-listed-doc.html \ umax/sane-umax-others-doc.html umax/sane-umax-parport-doc.html \ umax/sane-umax-powerlook-doc.html \ umax/sane-umax-scanner-clones-doc.html \ umax/sane-umax-speed-doc.html \ umax/sane-umax-standard-options-doc.html \ umax/sane-umax-standard.jpg umax/sane-umax-text.jpg \ umax/sane-umax-text2.jpg umax/sane-umax-text4.jpg \ umax/sane-umax-uc-doc.html umax/sane-umax-vista-doc.html \ umax/sane-umax.jpg umax/umax.BUGS umax/umax.CHANGES \ umax/umax.FAQ umax/umax.TODO DESC_FILES = descriptions/abaton.desc descriptions/agfafocus.desc \ descriptions/apple.desc descriptions/artec.desc \ descriptions/artec_eplus48u.desc descriptions/as6e.desc \ descriptions/avision.desc descriptions/bh.desc descriptions/canon630u.desc \ descriptions/canon.desc descriptions/canon_dr.desc \ descriptions/canon_pp.desc descriptions/cardscan.desc \ descriptions/coolscan2.desc descriptions/coolscan.desc \ descriptions/coolscan3.desc \ descriptions/dc210.desc descriptions/dc240.desc descriptions/dc25.desc \ descriptions/dell1600n_net.desc descriptions/dll.desc descriptions/dmc.desc \ descriptions/epjitsu.desc descriptions/epson2.desc descriptions/epson.desc \ descriptions/epsonds.desc descriptions/escl.desc \ descriptions/fujitsu.desc descriptions/genesys.desc \ descriptions/gphoto2.desc descriptions/gt68xx.desc descriptions/hp3500.desc \ descriptions/hp3900.desc descriptions/hp4200.desc descriptions/hp5400.desc \ descriptions/hp5590.desc descriptions/hp.desc descriptions/hpljm1005.desc \ descriptions/hpsj5s.desc descriptions/hs2p.desc descriptions/ibm.desc \ descriptions/kodak.desc descriptions/kodakaio.desc descriptions/kvs1025.desc \ descriptions/kvs20xx.desc descriptions/kvs40xx.desc \ descriptions/leo.desc descriptions/lexmark.desc descriptions/ma1509.desc \ descriptions/magicolor.desc \ descriptions/matsushita.desc descriptions/microtek2.desc \ descriptions/microtek.desc descriptions/mustek.desc \ descriptions/mustek_pp.desc descriptions/mustek_usb2.desc \ descriptions/mustek_usb.desc descriptions/nec.desc descriptions/net.desc \ descriptions/niash.desc descriptions/pie.desc descriptions/pieusb.desc descriptions/pint.desc \ descriptions/p5.desc descriptions/pixma.desc descriptions/plustek.desc \ descriptions/plustek_pp.desc descriptions/pnm.desc descriptions/qcam.desc \ descriptions/ricoh.desc descriptions/ricoh2.desc \ descriptions/rts8891.desc descriptions/s9036.desc \ descriptions/sceptre.desc descriptions/sharp.desc descriptions/sm3600.desc \ descriptions/sm3840.desc descriptions/snapscan.desc descriptions/sp15c.desc \ descriptions/st400.desc descriptions/stv680.desc descriptions/tamarack.desc \ descriptions/teco1.desc descriptions/teco2.desc descriptions/teco3.desc \ descriptions/test.desc descriptions/u12.desc \ descriptions/umax1220u.desc descriptions/umax.desc \ descriptions/umax_pp.desc descriptions/unsupported.desc \ descriptions/v4l.desc descriptions/xerox_mfp.desc DESC_EXT_FILES = descriptions-external/brother2.desc \ descriptions-external/brother.desc \ descriptions-external/brother-mfc4600.desc \ descriptions-external/cs3200f.desc \ descriptions-external/epkowa.desc \ descriptions-external/geniusvp2.desc \ descriptions-external/hp3770.desc \ descriptions-external/hp8200.desc \ descriptions-external/hpaio.desc \ descriptions-external/hpoj.desc \ descriptions-external/kodak-twain.desc \ descriptions-external/lhii.desc \ descriptions-external/mustek_a3p1.desc \ descriptions-external/panamfs.desc \ descriptions-external/primascan.desc \ descriptions-external/primax.desc \ descriptions-external/samsung.desc \ descriptions-external/scangearmp2.desc \ descriptions-external/scanwit.desc \ descriptions-external/utsushi.desc \ descriptions-external/v4l2.desc \ descriptions-external/viceo.desc API_SPECS = $(am__append_1) $(am__append_2) $(am__append_3) API_SPEC_INPUTS = $(srcdir)/sane.tex $(srcdir)/net.tex API_SPEC_TEX_FIGS = figs/area.fig figs/flow.fig figs/hierarchy.fig \ figs/image-data.fig figs/xfer.fig API_SPEC_EPS_FIGS = figs/area.eps figs/flow.eps figs/hierarchy.eps \ figs/image-data.eps figs/xfer.eps API_SPEC_PDF_FIGS = figs/area.pdf figs/flow.pdf figs/hierarchy.pdf \ figs/image-data.pdf figs/xfer.pdf API_SPEC_HTML_ICONS = icons/contents.gif icons/index.gif \ icons/next.gif icons/next_gr.gif icons/previous.gif \ icons/previous_gr.gif icons/references.gif \ icons/references_gr.gif icons/up.gif icons/up_gr.gif am_TEXINPUTS = TEXINPUTS="$(builddir):$(srcdir):$$TEXINPUTS" all: all-am .SUFFIXES: .SUFFIXES: .eps .fig .pdf $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu doc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): doxygen-sanei.conf: $(top_builddir)/config.status $(srcdir)/doxygen-sanei.conf.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ doxygen-genesys.conf: $(top_builddir)/config.status $(srcdir)/doxygen-genesys.conf.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-man1: $(man1_MANS) @$(NORMAL_INSTALL) @list1='$(man1_MANS)'; \ list2=''; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-man7: $(man7_MANS) @$(NORMAL_INSTALL) @list1='$(man7_MANS)'; \ list2=''; \ test -n "$(man7dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man7dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man7dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.7[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man7dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man7dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man7dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man7dir)" || exit $$?; }; \ done; } uninstall-man7: @$(NORMAL_UNINSTALL) @list='$(man7_MANS)'; test -n "$(man7dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^7][0-9a-z]*$$,7,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man7dir)'; $(am__uninstall_files_from_dir) install-man8: $(man8_MANS) @$(NORMAL_INSTALL) @list1='$(man8_MANS)'; \ list2=''; \ test -n "$(man8dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.8[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \ done; } uninstall-man8: @$(NORMAL_UNINSTALL) @list='$(man8_MANS)'; test -n "$(man8dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir) install-dist_docDATA: $(dist_doc_DATA) @$(NORMAL_INSTALL) @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ done uninstall-dist_docDATA: @$(NORMAL_UNINSTALL) @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) install-docDATA: $(doc_DATA) @$(NORMAL_INSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ done uninstall-docDATA: @$(NORMAL_UNINSTALL) @list='$(doc_DATA)'; test -n "$(docdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) install-nobase_dist_docDATA: $(nobase_dist_doc_DATA) @$(NORMAL_INSTALL) @list='$(nobase_dist_doc_DATA)'; test -n "$(docdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ fi; \ $(am__nobase_list) | while read dir files; do \ xfiles=; for file in $$files; do \ if test -f "$$file"; then xfiles="$$xfiles $$file"; \ else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ test -z "$$xfiles" || { \ test "x$$dir" = x. || { \ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)/$$dir'"; \ $(MKDIR_P) "$(DESTDIR)$(docdir)/$$dir"; }; \ echo " $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(docdir)/$$dir'"; \ $(INSTALL_DATA) $$xfiles "$(DESTDIR)$(docdir)/$$dir" || exit $$?; }; \ done uninstall-nobase_dist_docDATA: @$(NORMAL_UNINSTALL) @list='$(nobase_dist_doc_DATA)'; test -n "$(docdir)" || list=; \ $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(MANS) $(DATA) installdirs: for dir in "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man7dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(docdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-local dvi: dvi-am dvi-am: html: html-am html-am: html-local info: info-am info-am: install-data-am: install-data-local install-dist_docDATA \ install-docDATA install-man install-nobase_dist_docDATA install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-man7 install-man8 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-dist_docDATA uninstall-docDATA uninstall-local \ uninstall-man uninstall-nobase_dist_docDATA uninstall-man: uninstall-man1 uninstall-man7 uninstall-man8 .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ clean-local cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distclean-local distdir dvi dvi-am html \ html-am html-local info info-am install install-am \ install-data install-data-am install-data-local \ install-dist_docDATA install-docDATA install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-man1 install-man7 install-man8 \ install-nobase_dist_docDATA install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ uninstall-am uninstall-dist_docDATA uninstall-docDATA \ uninstall-local uninstall-man uninstall-man1 uninstall-man7 \ uninstall-man8 uninstall-nobase_dist_docDATA .PRECIOUS: Makefile all: bemans $(API_SPECS) html-pages %.1 %.5 %.7 %.8: %.man @echo "Generating manpage $@..."; @sed -e 's|@DATADIR@|$(datadir)|g' \ -e 's|@CONFIGDIR@|$(configdir)|g' \ -e 's|@DOCDIR@|$(docdir)|g' \ -e 's|@LIBDIR@|$(libdir)/sane|g' \ -e 's|@BINDIR@|$(bindir)|g' \ -e 's|@SBINDIR@|$(sbindir)|g' \ -e 's|@PACKAGEVERSION@|$(package_version)|g' $^ >$@ bemans: $(BACKEND_5MANS) install-beman5: $(BACKEND_5MANS) test -z "$(beman5dir)" || $(MKDIR_P) "$(DESTDIR)$(beman5dir)" @list="$(BACKEND_MANS_ENABLED) sane-dll.5 sane-scsi.5 sane-usb.5"; for man in $$list; do \ if test ! -r $${man}; then continue; fi; \ echo "installing $${man} in $(beman5dir)/$${man}..."; \ $(INSTALL_DATA) $${man} $(DESTDIR)$(beman5dir)/$${man} \ || exit 1; \ done install-data-local: install-beman5 uninstall-local: rm -rf $(DESTDIR)$(beman5dir)/sane-*.5 sane.ind: $(API_SPEC_INPUTS) @echo Generating index for $<... @touch sane.ind @$(am_TEXINPUTS) $(LATEX) $< /dev/null && \ $(MAKEINDEX) -q sane.idx && \ $(am_TEXINPUTS) $(LATEX) $< /dev/null .fig.eps: @test -d $(@D) || $(MKDIR_P) $(@D) $(FIG2DEV) -L eps $< $@ sane.dvi: $(API_SPEC_INPUTS) $(API_SPEC_EPS_FIGS) sane.ind @echo Generating $@ from $<... @$(am_TEXINPUTS) $(LATEX) $< /dev/null sane.ps: sane.dvi @echo Generating $@ from $<... @$(am_TEXINPUTS) $(DVIPS) -q $< -o $@ .fig.pdf: @test -d $(@D) || $(MKDIR_P) $(@D) $(FIG2DEV) -L pdf $< $@ sane.pdf: $(API_SPEC_INPUTS) $(API_SPEC_PDF_FIGS) sane.ind @echo Generating $@ from $<... @$(am_TEXINPUTS) $(PDFLATEX) $< >/dev/null sane-html: sane.dvi $(am_TEXINPUTS) $(DLH) $(srcdir)/sane.tex html-man: $(MANPAGES) @for page in $(MANPAGES); do \ echo "translating $${page} to $${page}.html..."; \ cat $${page} | $(MAN2HTML) > $${page}.html; \ done ../tools/sane-desc: cd ../tools ; $(MAKE) sane-desc sane-backends.html: $(DESC_FILES) ../tools/sane-desc @../tools/sane-desc -m html-backends-split -s ${srcdir}/descriptions \ -i "The following table summarizes the backends/drivers distributed \ with $(PACKAGE)-$(VERSION), and the hardware or software they \ support." -d 0 > sane-backends.html sane-backends-external.html: $(DESC_EXT_FILES) ../tools/sane-desc @../tools/sane-desc -m html-backends-split \ -s ${srcdir}/descriptions-external \ -i "The following table summarizes the backends/drivers that \ have not yet been included in the SANE distribution, and the \ hardware or software they support." \ -t "SANE: External Backends (Drivers)" -d 0 \ > sane-backends-external.html sane-mfgs.html: $(DESC_FILES) ../tools/sane-desc @../tools/sane-desc -m html-mfgs -s ${srcdir}/descriptions \ -i "The following table summarizes the devices supported \ by $(PACKAGE)-$(VERSION)." \ -d 0 > sane-mfgs.html sane-mfgs-external.html: $(DESC_EXT_FILES) ../tools/sane-desc @../tools/sane-desc -m html-mfgs -s ${srcdir}/descriptions-external \ -i "The following table summarizes the devices that \ are supported by external backends." \ -t "SANE: Devices Supported by External Backends" -d 0 \ > sane-mfgs-external.html descriptions.db: $(DESC_FILES) ../tools/sane-desc @../tools/sane-desc -m ascii -s ${srcdir}/descriptions \ > descriptions.db descriptions-external.db: $(DESC_EXT_FILES) ../tools/sane-desc @../tools/sane-desc -m ascii -s ${srcdir}/descriptions-external \ > descriptions-external.db html-pages: $(HTML_PAGES) html-local: html-pages html-man sane-html clean-local: rm -f *.toc *.aux *.log *.cp *.fn *.tp *.vr *.pg *.ky *.blg *.idx *.cb rm -f *.ilg rm -f $(API_SPEC_EPS_FIGS) $(API_SPEC_PDF_FIGS) -rmdir figs distclean-local: rm -f $(MANPAGES) rm -f *.lot *.lof *.ind rm -f sane.dvi sane.ps sane-backends.html sane-backends-external.html rm -f sane-mfgs.html sane-mfgs-external.html rm -f sane/*.html sane/*.gif rm -f doxygen-sanei.conf doxygen-genesys.conf -rm -rf sane sanei-html for manpage in $(MANPAGES) ; do \ rm -f $${manpage}.html ; \ done # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/doc/sane-mustek_usb.man0000666000000000000000000001405413615534521015554 00000000000000.TH sane\-mustek_usb 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-mustek_usb .SH NAME sane\-mustek_usb \- SANE backend for Mustek USB flatbed scanners .SH DESCRIPTION The .B sane\-mustek_usb library implements a SANE (Scanner Access Now Easy) backend that provides access to Mustek USB flatbed scanners (including a clone from Trust). At present, the following scanners are known to work more or less with this backend: .PP .RS Mustek 600 CU .br Mustek 1200 UB .br Mustek 1200 CU .br Mustek 1200 CU Plus .br Trust Compact Scan USB 19200 .br .RE .PP More details can be found on the Mustek USB backend homepage .IR http://www.meier\-geinitz.de/sane/mustek_usb\-backend/ . .PP The Mustek BearPaw 1200 and 2400 scanners are supported by the plustek backend. See .BR sane\-plustek (5) for details. The Mustek BearPaw 1200F is supported by the MA-1509 backend. See .BR sane\-ma1509 (5) for details. Other Mustek USB scanners are supported by the gt68xx backend, see .BR sane\-gt68xx (5). .PP This backend can only work with scanners that are already detected by the operating system. See .BR sane\-usb (5) for details. .PP If you own a Mustek (or Trust) scanner other than the ones listed above that works with this backend, please let me know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .I /proc/bus/usb/devices or syslog) to me. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is a path-name for the special device that corresponds to a USB scanner. With Linux, such a device name could be .I /dev/usb/scanner0 or .IR /dev/usbscanner1 , for example. .PP For FreeBSD use .IR /dev/uscanner0 . .SH CONFIGURATION The contents of the .I mustek_usb.conf file is a list of options and device names that correspond to Mustek USB scanners. Empty lines and lines starting with a hash mark (#) are ignored. If a device name is placed in .IR mustek_usb.conf , it must be followed by a line containing the keyword .B option and an option specifying the scanner type. The following options can be used: .BR 600cu , .BR 1200cu , .BR 1200cu_plus , .BR 1200ub . For the Trust Compact Scan USB 19200 use `option 1200ub'. .PP Instead of using the device name, the scanner can be autodetected by .B "usb vendor_id product_id" statements which are already included into .IR mustek_usb.conf . This is only supported with Linux 2.4.8 and higher and all systems that support libsub. "vendor_id" and "product_id" are hexadecimal numbers that identify the scanner. If this doesn't work, a device name and the option specifying the scanner type must be placed in .I mustek_usb.conf as described above. .PP The global .B option max_block_size can be used to limit the amount of data acquired in one turn from the USB system. It may be worth trying, if USB errors occur. .PP A sample configuration file is shown below: .PP .RS # Comment .br option max_block_size 1024 .br usb 0x055f 0x0001 .br /dev/usb/scanner0 .br option 600cu .RE .PP The first line is ignored. The second line sets the buffer size to a maximum of 1024 bytes. The third line tries to autodetect a scanner with vendor id 0x055f and product id 0x0001 (Mustek 1200 CU). The fourth line tells the backend to attach to .I /dev/usb/scanner0 and the fifth line specifies that .I /dev/usb/scanner0 is a Mustek 600 CU. .SH FILES .TP .I @CONFIGDIR@/mustek_usb.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-mustek_usb.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-mustek_usb.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_MUSTEK_USB If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. .ft CR .nf Value Description 0 no output 1 print fatal errors 2 print important messages 3 print non-fatal errors and less important messages 4 print all but debugging messages 5 print high level debugging messages 6 print medium level debugging messages 7 print low level debugging messages .fi .ft R Example: export SANE_DEBUG_MUSTEK_USB=4 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .BR sane\-mustek (5), .BR sane\-mustek_pp (5), .BR sane\-plustek (5), .BR sane\-gt68xx (5), .BR sane\-ma1509 (5) .br .IR @DOCDIR@/mustek_usb/mustek_usb.CHANGES , .br .I @DOCDIR@/mustek_usb/mustek_usb.TODO .br .I http://www.meier\-geinitz.de/sane/mustek_usb\-backend/ .SH AUTHOR Henning Meier-Geinitz .br This backend is based on the Mustek 1200ub backend from Mustek, maintained by Tom Wang. .SH BUGS These devices have a hardware bug: Once data is written to them, they can't be reset (toggle = DATA0). That means, any operation that tries to reset the device will result in running into timeouts. In earlier versions this backend failed when it was loaded the second time in some configurations. The only choice was to replug the scanner in this case. The backend uses a workaround for that bug now but it's only tested on Linux. Reports for other operating systems are appreciated. .PP More detailed bug information is available at the Mustek backend homepage .IR http://www.meier\-geinitz.de/sane/mustek_usb\-backend/ . sane-backends-1.0.29/doc/sane-canon.man0000666000000000000000000000647113615534521014475 00000000000000.TH sane\-canon 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-canon .SH NAME sane\-canon \- SANE backend for Canon SCSI scanners .SH DESCRIPTION The .B sane\-canon library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Canon flatbed and film scanners: .PP .RS CanoScan 300 .br CanoScan 600 .br CanoScan FB620S .br CanoScan FB1200S .br CanoScan FS2700F .br CanoScan FS2710S .br .RE .PP Parallel port and USB scanners are not supported by this backend; see the manual pages for sane\-canon_pp and sane\-canon630u for further information. .PP IMPORTANT: This is beta code. We tested the code on the scanners listed above, using the computers and operating systems available to us, but we cannot guarantee that the backend will work smoothly with future operating systems, SCSI adapters, SANE frontend programs, or Canon scanners not contained in the list above. In some cases your computer might even hang. It cannot be excluded (although we consider it extremely unlikely) that your scanner will be damaged. .PP That said, TESTERS ARE WELCOME. Send your bug reports and comments to Manuel Panea ; for questions concerning the FB620 and FB1200S contact Mitsuru Okaniwa , for the FS2710S Ulrich Deiters . .PP .SH TIPS (FS2700F) .PP Scanning either slides or negatives has been found to require rather large gamma corrections of about 2.2 to 2.4 (same value for red, green, and blue). It is recommended to use the automatic exposure controls of the frontend xsane for best results. .PP The "Auto Focus" function triggers a special pass to determine the focus value. After that, the real scanning pass takes place. .PP Even with "Auto Focus" turned on, the scanned image is often a bit too blurred. Using the GIMP to do a "Filter->Enhance->Sharpen" at about 40 to 60 improves the image considerably. .PP .SH TIPS (FS2710S) .PP Gamma corrections are done not by the scanner, but by the backend. The scanner is always run in 12-bit mode. In "color" mode the image data are corrected for gamma, shadow point, etc., and then truncated to 8-bit intensities; the default gamma value is 2.0. In "raw" mode the image data are exported without corrections as 16-bit intensities; this mode can be recommended if extensive adjustments have to be made to a picture (and if the frontend can handle 16-bit intensities). .PP Negatives are handled by simple color inversion and may require manual removal of blue discoloration. .PP .SH FILES .TP .I @LIBDIR@/libsane\-canon.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-canon.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_CANON If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_CANON=4 .SH "SEE ALSO" sane\-scsi(5) .br http://www.rzg.mpg.de/~mpd/sane/ .br doc/canon.install2700F.txt (installation of a CanoScan 2700F .br .SH AUTHOR Helmut Koeberle, Manuel Panea, and Markus Mertinat; FB620S and FB1200S support by Mitsuru Okaniwa; FS2710S support by Ulrich Deiters .br Man page by Henning Meier-Geinitz (mostly based on canon.README) sane-backends-1.0.29/doc/gamma4scanimage.man0000666000000000000000000000354613615534521015471 00000000000000.TH gamma4scanimage 1 "10 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX gamma4scanimage .SH NAME gamma4scanimage \- create a gamma table for scanimage .SH SYNOPSIS .B gamma4scanimage .I gamma .RI [ shadow .RI [ highlight .RI [ maxin .RI [ maxout ]]]] .SH DESCRIPTION The tool .B gamma4scanimage creates a gamma table in the format expected by scanimage. You can define a .BR gamma, a .BR shadow and a .BR highlight value. You also can specify the size .RB ( maxin ) and maximum output value .RB ( maxout ) of the gamma table. .PP .BR gamma is a floating point value, neutral value is 1.0, if the value is larger than 1.0 then the image gets brighter. .PP .BR shadow defines the minimum input value that is necessary to create an output value larger than zero. shadow has to be in the range [0..maxin]. Its default value is 0. .PP .BR highlight defines the maximum input value that produces an output value smaller than maxout. highlight has to be in the range [0..maxin], highlight has to be larger than shadow. Its default value is the same as maxin (16383 if not set). .PP .BR maxin defines the size of the gamma table. The size depends on the scanner/backend. If the scanner uses 8 bits gamma input then maxin has to be set to 255, for 10 bits 1023, for 12 bits 4095, for 14 bits 16383. The default is 16383. To find out what value maxin has to be call scanimage with a very large gamma table [0]0-[99999]255 then scanimage prints an error message with the needed size of the gamma table. .PP .BR maxout defines the maximum output value. Take a look at the output of scanimage \-h to find out what maxout has to be. The default value is 255. .PP .SH EXAMPLE .B scanimage \-\-custom\-gamma=yes \-\-gamma\-table .I `gamma4scanimage 1.8 0 11500 16383 255` >image.pnm .SH SEE ALSO .BR scanimage (1) .SH AUTHOR Oliver Rauch .SH EMAIL-CONTACT Oliver.Rauch@Rauch-Domain.DE sane-backends-1.0.29/doc/sane-canon_pp.man0000666000000000000000000002037113615534521015167 00000000000000.TH sane\-canon_pp 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-canon_pp .SH NAME sane\-canon_pp \- SANE backend for Canon CanoScan Parallel Port flatbed scanners .SH DESCRIPTION The .B sane\-canon_pp library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Canon flatbed scanners: .PP .RS CanoScan FB320P .br CanoScan FB620P .br CanoScan FB330P .br CanoScan FB630P .br CanoScan N340P .br CanoScan N640P .br CanoScan N640P ex .br .RE .PP No USB scanners are supported and there are no plans to support them in the future. Other projects are working on support for USB scanners. See the .B PROJECTS file for more detail. The FB310P and FB610P are re-badged Avision scanners which use a different command set, so are unlikely to be supported by this backend in the future. .PP IMPORTANT: this is alpha code. While we have made every effort to make it as reliable as possible, it will not always work as expected. Feedback is still appreciated. Please send any bug reports to the maintainers as listed on the web page (listed in .B SEE ALSO below). .PP . .PP .SH "DEVICE NAMES" This backend expects device names of the form presented by libieee1284. These names are highly dependent on operating system and version. On Linux 2.4 kernels this will be of the form .I "parport0" or older (2.2 and before) kernels may produce names like .IR "0x378" (the base address of your port) or simply .IR "0" depending on your module configuration. Check the contents of .I /proc/parport if it exists. If you don't want to specify a default port (or don't know its name), the backend should be able to detect which port your scanner is on. .SH CONFIGURATION The contents of the .I canon_pp.conf file is a list of options for the driver to use. Empty lines and lines starting with a hash mark (#) are ignored. .PP The supported options are currently .BR ieee1284 , .BR calibrate , .BR init_mode , and .BR force_nibble Option .B ieee1284 .IR port-name defines which port to use. The format of port-name is OS dependent, based on the names presented by libieee1284. Please only have one of these lines, or all but one will be ignored. Option .B calibrate .IR cal-file .IR [port-name] defines which calibration file to use on a per-port basis. If you only have one parport, the port-name argument may be omitted \- but be careful as this will cause problems on multi-scanner systems. You may have as many of these lines as you like, as long as each has a unique port name. The tilde (`~') character is acceptable and will be expanded to the value of the HOME environment. Option .B init_mode .IR .IR [portname] defines which initialisation (wake-up) mode to use on a per-port basis. If you only have one parport, the portname argument may be omitted \- but be careful as this may cause problems on multi-scanner systems. You may have as many of these lines as you like, as long as each has a unique port name. The valid initialisation modes are FB620P (which strobes 10101010 and 01010101 on the data pins), FB630P (which strobes 11001100 and 00110011 on the data pins) and AUTO, which will try FB630P mode first then FB620P mode second. The FB620P mode is also used by the FB320P. The FB630P mode is used by the FB330P, N340P, and N640P. Option .B force_nibble forces the driver to use nibble mode even if ECP mode is reported to work by libieee1284. This works-around the rare issue of ECP mode being reported to work by the library, then not working. .SH TIPS .PP Hit the "Calibrate" button before scanning. It vastly improves the quality of scans. .PP To enable automatic detection of your scanner, uncomment the "canon_pp" line from .I @CONFIGDIR@/dll.conf .PP .SH FILES .TP .I @CONFIGDIR@/canon_pp.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-canon_pp.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-canon_pp.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_CANON_PP If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_CANON_PP=4 .SH NOTES .B Features available in the Windows interface .TP .B Brightness and Contrast These are not implemented, and probably never will be. These appear to be implemented entirely in software. Use GIMP or a similar program if you need these features. .TP .B Descreen Mode This appears on our first analysis to be just oversampling with an anti-aliasing filter. Again, it seems to be implemented entirely in software, so GIMP is your best bet for now. .TP .B Gamma Tables This is under investigation, but for now only a simple gamma profile (ie: the one returned during calibration) will be loaded. .PP .B Communication Problems .PP ECP mode in libieee1284 doesn't always work properly, even with new hardware. We believe that this is a ppdev problem. If you change the configuration file to include .B force_nibble , the problem will go away, but you will only be able to scan in nibble mode. .PP Sometimes the scanner can be left in a state where our code cannot revive it. If the backend reports no scanner present, try unplugging the power and plugging it back in. Also try unplugging printers from the pass-through port. .PP The scanner will not respond correctly to our commands when you first plug in the power. You may find if you try a scan very soon after plugging in the power that the backend will incorrectly report that you have no scanner present. To avoid this, give it about 10 seconds to reset itself before attempting any scans. .PP .B Repeated Lines .PP Sometimes at high resolutions (ie. 600dpi) you will notice lines which appear twice. These lines correspond to points where the scanner head has stopped during the scan (it stops every time the internal 64kb buffer is full). Basically it's a mechanical problem inside the scanner, that the tolerance of movement for a start/stop event is greater than 1/600 inches. I've never tried the windows driver so I'm not sure how (or if) it works around this problem, but as we don't know how to rewind the scanner head to do these bits again, there's currently no nice way to deal with the problem. .PP .B Grey-scale Scans .PP Be aware that the scanner uses the green LEDs to read grey-scale scans, meaning green coloured things will appear lighter than normal, and red and blue coloured items will appear darker than normal. For high-accuracy grey-scale scans of colour items, it's best just to scan in colour and convert to grey-scale in graphics software such as the GIMP. .PP .B FB620P/FB320P Caveats .PP These models can not be reset in the same way as the others. The windows driver doesn't know how to reset them either \- when left with an inconsistent scanner, it will start scanning half way down the page! .PP Aborting is known to work correctly on the FB*30P models, and is known to be broken on the FB*20P models. The FB620P which I tested on simply returns garbage after a scan has been aborted using the method we know. Aborting is able to leave the scanner in a state where it can be shut down, but not where another scan can be made. .SH "SEE ALSO" sane(7), sane\-dll(5) .BR http://canon\-fb330p.sourceforge.net/ .SH AUTHOR This backend is primarily the work of Simon Krix (Reverse Engineering), and Matthew Duggan (SANE interface). .PP Many thanks to Kevin Easton for his comments and help, and Kent A. Signorini for his help with the N340P. sane-backends-1.0.29/doc/sane-config.man0000666000000000000000000000272413615534521014641 00000000000000.TH sane\-config 1 "10 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .SH NAME sane\-config \- get information about the installed version of libsane .SH SYNOPSIS .B sane\-config [\-\-prefix] [\-\-exec\-prefix] [\-\-libs] [\-\-cflags] [\-\-ldflags] [\-\-version] [\-\-help \fI[OPTION]\fP] .SH DESCRIPTION .PP .B sane\-config is a tool that is used to determine the compiler and linker flags that should be used to compile and link .B SANE frontends to a .B SANE backend library (libsane). . .SH OPTIONS .B sane\-config accepts the following options (you can't use more than one option at the same time): .TP 8 .B \-\-version Print the currently installed version of libsane on the standard output. .TP 8 .B \-\-help OPTION Print a short usage message. If OPTION is specified, help for that option (e.g. \-\-libs) is printed (if available). .TP 8 .B \-\-libs Print the additional libraries that are necessary to link a .B SANE frontend to libsane. .TP 8 .B \-\-ldflags Print the linker flags that are necessary to link a .B SANE frontend to libsane. .TP 8 .B \-\-cflags Print the compiler flags that are necessary to compile a .B SANE frontend. .TP 8 .B \-\-prefix Print the prefix used during compilation of libsane. .TP 8 .B \-\-exec\-prefix Print the exec\-prefix used during compilation of libsane. .SH "SEE ALSO" .BR sane (7) .SH AUTHOR This manual page was written by Julien BLACHE , for the Debian GNU/Linux system (but may be used by others). sane-backends-1.0.29/doc/sceptre/0000755000000000000000000000000013615535552013474 500000000000000sane-backends-1.0.29/doc/sceptre/s1200.txt0000666000000000000000000000566613615534521014736 00000000000000Scanner overview - One pass scanner - 10 DPI minimum. Max X=600 dpi, max Y=1200 dpi. - A4 size /*--------------------------------------------------------------------------*/ Components: - Weltrend WT8616 - TEMIC TSC 80C31 (CMOS 0 to 44 MHz Single-Chip 8 Bit Microcontroller) /*--------------------------------------------------------------------------*/ SCSI overview - the SCSI implementation in this scanner is non-standard but simple. - there is no REQUEST SENSE command. - since there is no sense, it is impossible to know if a command has succeeded. /*--------------------------------------------------------------------------*/ SCSI commands: TEST UNIT READY 00 00 00 00 01 00 Returns 1 byte of data: 00 = scanner ready ff = scanner not ready Vendor Spec 02 00 00 00 04 00 Get 4 bytes of status. Used to check the button. Default result when the button is not pressed 06 00 00 00 INQUIRY result: 06 00 02 02 30 00 00 10 4b 49 4e 50 4f 20 20 20 ....0...KINPO 56 69 76 69 64 73 63 61 6e 20 53 31 32 30 20 20 Vividscan S120 53 31 33 20 20 20 20 20 02 01 00 00 4a 45 46 46 S13 ....JEFF ... MODE SEL 15 10 00 00 18 00 SCAN 1B 00 00 00 00 00 RECEIVE DIAG 1C 00 00 00 03 00 SEND DIAG 1D 00 80 00 00 00 SET WINDOW 24 00 00 00 00 00 00 00 52 00 The window size is always 0x52 bytes. The parameters look standard: - X/Y resolution | - Upper left X,Y |- all three coded in 600 dpi units - Width, Length | The supported scan modes are: - lineart image comp=0, halftone=0, depth=1 - halftone image comp=0, haltone=1 to 4, depth=1 - grayscale image comp=2, halftone=0, depth=8 - color image comp=5, halftone=0, depth=24 Y resolution is not used (X is also used for Y) X resolution is limited to 600 (if above, scanner defaults to 600) Y resolution is limited to 1200 (if above, scanner defaults to 1200) Image composition is byte 33, halftone is byte 36, depth is byte 34 READ (10) 28 00 00 00 00 00 00 FE 9A 00 SEND (10) 2A 00 03 00 00 02 00 03 00 00 Sends 300h bytes of gamma. 100h bytes per color. What is the color order? GET DATA BUFFER STATUS 34 01 00 00 00 00 00 00 10 00 Returns: - byte 0 to 7: ? (these bytes looks rather standard) - byte 8 to 11: total size left to read - byte 12 to 13: number of lines (constant during a scan) - byte 14 to 15: pixels per line (constant during a scan) /*--------------------------------------------------------------------------*/ Color shifts Color order returned by the scanner is Red, then Green, then Blue. There is a color shift, meaning the raster for the Red is not followed by the Green raster for the same line. The shifts are: dpi lines per color 1200 16 1125 15 1050 14 900 12 750 10 600 8 450 6 300 4 150 2 90 1 75 1 50 0 Some resolution give garbage. However that table might not be complete. sane-backends-1.0.29/doc/sane-v4l.man0000666000000000000000000000551313615534521014100 00000000000000.TH sane\-v4l 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-v4l .SH NAME sane\-v4l \- SANE interface for Video for Linux API .SH DESCRIPTION The .B sane\-v4l library implements a SANE (Scanner Access Now Easy) backend that provides generic access to video cameras and similar equipment using the V4L (Video for Linux) API. .PP This is ALPHA software. Really! Important features are missing and there are lots of bugs. The code is currently only tested on a Linux 2.4 system with a Hauppauge WinTV video card. .PP .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the UNIX path-name for the special device that corresponds to the v4l device. The special device name must be a v4l device or a symlink to such a device. For example, such a device name could be .I /dev/video0 or .IR /dev/bttv0 . .SH CONFIGURATION The contents of the .I v4l.conf file is a list of device names that correspond to v4l devices. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS /dev/bttv0 .br # this is a comment .br /dev/video3 .RE .SH FILES .TP .I @CONFIGDIR@/v4l.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-v4l.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-v4l.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_V4L If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH AUTHOR Juergen G. Schimmer, Henning Meier-Geinitz .SH BUGS: If more than one video card is present, a crash may occur. Frequency and geometry selection is missing. .br Send bug reports to the SANE mailing list: sane\-devel@alioth-lists.debian.net. You must be subscribed to the list to send mail. See http://www.sane\-project.org/mailing\-lists.html for details. .SH SEE ALSO sane(7), xcam(1). sane-backends-1.0.29/doc/sane-matsushita.man0000666000000000000000000001165313615534521015557 00000000000000.TH sane\-matsushita 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-matsushita .SH NAME sane\-matsushita \- SANE backend for Panasonic KV-SS high speed scanners .SH DESCRIPTION The .B sane\-matsushita library implements a SANE (Scanner Access Now Easy) backend that provides access to some Panasonic KV-SS high speed scanners. This backend is stable. .PP At present, the following scanners are known to work with this backend: .PP .RS .ft CR .nf Product id -------------- KV-SS25 KV-SS25D KV-SS55EX (*) KV-S2025C (*) KV-S2045C (*) KV-S2065L (*) .fi .ft R .RE .PP (*) WARNING: None of the advanced options of these scanners are available (ie no color, no high resolution, no automatic cropping). Basically, the driver does no more than what it does for the KV-SS25. I don't have access to such scanners, and thus cannot add these options. Other Panasonic high speed scanners may or may not work with that backend. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d matsushita .RE .TP .B Scan Mode .TP .B \-\-mode selects the basic mode of operation of the scanner. .TP .B \-\-resolution selects the resolution for a scan. Each model supports all or a subset of these resolutions: 100, 150, 200, 240, 300, 360, 400. .TP .B \-\-duplex indicates whether to scan both side of the sheet. .TP .B \-\-feeder\-mode selects the number of pages to scan (one or until the tray is empty). .TP .B Geometry .TP .B \-\-paper\-size A4|...|Legal|Letter [A4] options selects the area to scan. It adjust the .B \-l \-t \-x \-y options accordingly. It does not need to be the real size of the paper. .TP .B \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters. It is possible to use the option .I \-\-paper\-size instead. .TP .B Enhancement .TP .B \-\-brightness controls the brightness of the acquired image. The value varies from 1 to 255, or less, depending on the scanner model. .TP .B \-\-contrast controls the contrast of the acquired image. Some models do not support that option. .TP .B \-\-automatic\-threshold automatically sets brightness, contrast, white level, gamma, noise reduction and image emphasis. These options are not available when automatic\-threshold is in use. .TP .B \-\-halftone\-pattern option sets the tonal gradation for the halftone mode. Pattern downloading is not implemented by the backend. .TP .B \-\-autoseparation provides automatic separation of text and images. .TP .B \-\-white\-level option indicate the source of the white base. .TP .B \-\-noise\-reduction reduces the isolated dot noise. This option is not supported by all scanners. .TP .B \-\-image\-emphasis option sets the image emphasis. Some selection are not available on all scanners. .TP .B \-\-gamma options set the gamma curve. It is only valid for Gray modes, and is not available on all scanners. Gamma downloading is not implemented by the backend. .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/matsushita.conf supports the device name to use (eg /dev/scanner) and the SCSI option to auto-detect the scanners supported. .SH FILES .TP .I @LIBDIR@/libsane\-matsushita.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-matsushita.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_MATSUSHITA If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH LIMITATIONS .TP .B Memory in the KV-SS 25 The KV-SS 25 has not enough internal memory to scan a whole A4 page in duplex mode at high resolution. The frontend will return a memory error in that case. Apparently, the KV-SS 25D has not that problem. .TP .B Pattern and gamma downloading The scanner, with the proper firmware, can download a halftone pattern and a gamma table. This is not implemented. .TP .B Sub-areas The scanner can support up to 3 sub-areas on each side to define some more precise enhancement options. This is not implemented. .TP .B Duplex mode The backend does not support the setting of different options for each side. The scan will occur with the same options (halftone pattern, brightness, image emphasis) for both sides. .SH SCANNING EXAMPLE To date, the only frontend capable of using this scanner at full speed is .B scanadf. A scanadf command line would be: scanadf \-d matsushita \-\-output\-file scan%04d.pbm \-\-start\-count 0 \-\-duplex \-\-resolution 300 \-\-feeder\-mode="All pages" \-\-paper\-size="A4" .SH BUGS None known. .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1), sane(7) .SH AUTHOR .TP The package is actively maintained by Frank Zago. .I http://www.zago.net/sane/#matsushita sane-backends-1.0.29/doc/sane-gt68xx.man0000666000000000000000000001673713615534521014555 00000000000000.TH sane\-gt68xx 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-gt68xx .SH NAME sane\-gt68xx \- SANE backend for GT-68XX based USB flatbed scanners .SH DESCRIPTION The .B sane\-gt68xx library implements a SANE (Scanner Access Now Easy) backend that provides access to USB flatbed scanners based on the Grandtech GT-6801 and GT-6816 chips. A list of supported scanners can be found on the gt68xx backend homepage: .IR http://www.meier\-geinitz.de/sane/gt68xx\-backend/ . .PP This is BETA software. Especially if you test new or untested scanners, keep your hand at the scanner's plug and unplug it, if the head bumps at the end of the scan area. .PP If you own a scanner other than the ones listed on the gt68xx homepage that works with this backend, please let me know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .I sane\-find\-scanner or syslog) to me. Even if the scanner's name is only slightly different from the models already listed as supported, please let me know. .PP If you own a scanner that isn't detected by the gt68xx backend but has a GT-6801 or GT-6816 chipset, you can try to add it to the backend. Have a look at the following web page: .I http://www.meier\-geinitz.de/sane/gt68xx\-backend/adding.html .PP .SH LIBUSB ISSUES Please use libusb-0.1.8 or later. Without libusb or with older libusb versions all kinds of trouble can be expected. The scanner should be found by sane\-find\-scanner without further actions. For setting permissions and general USB information looks at .BR sane\-usb (5). .PP .SH FIRMWARE FILE You need a firmware file for your scanner. That's a small file containing software that will be uploaded to the scanner's memory. It's usually named *.usb, e.g. .IR PS1fw.usb . It comes on the installation CD that was provided by the manufacturer, but it may be packaged together with the installation program in an .exe file. For Mustek scanners, the file can be downloaded from the gt68xx backend homepage. For other scanners, check the CD for .usb files. If you only find *.cab files, try cabextract to unpack. If everything else fails, you must install the Windows driver and get the firmware from there (usually in the .I windows/system or .I system32 directories). Put that firmware file into .IR @DATADIR@/sane/gt68xx/ . Make sure that it's readable by everyone. .SH CONFIGURATION The contents of the .I gt68xx.conf file is a list of usb lines containing vendor and product ids that correspond to USB scanners. The file can also contain option lines. Empty lines and lines starting with a hash mark (#) are ignored. The scanners are autodetected by .B usb vendor_id product_id statements which are already included into .IR gt68xx.conf . "vendor_id" and "product_id" are hexadecimal numbers that identify the scanner. .PP The .BR override , .BR firmware , .BR vendor , .BR model , and .B afe options must be placed after the .B usb line they refer to. .PP Option .B override is used to override the default model parameters. That's necessary for some scanners that use the same vendor/product ids but are different. For these scanners there are already commented out override lines in the configuration file. .B override "mustek\-scanexpress\-1200\-ub\-plus" is necessary for the Mustek Scanexpress 1200 UB Plus, the Medion/Lifetec/Tevion LT 9452, and the Trust Compact Scan USB 19200. .B override "artec\-ultima\-2000" is used for the Artec Ultima 2000, the Boeder SmartScan Slim Edition, the Medion/ Lifetec/ Tevion/ Cytron MD/LT 9385, the Medion/ Lifetec/ Tevion MD 9458, and the Trust Flat Scan USB 19200. .B override "mustek\-bearpaw\-2400\-cu" is necessary for the Mustek BearPaw 2400 CU and the Fujitsu 1200CUS. The .B override option must be the first one after the .B usb line. .PP Option .B firmware selects the name and path of the firmware file. It's only necessary if the default (or override) doesn't work. The default firmware directory is .IR @DATADIR@/sane/gt68xx/ . You may need to create this directory. If you want to place the firmware files at a different path, use a .B firmware line. .PP The .B vendor and .B model options are not absolutely necessary but for convenience. Quite a lot of scanners from different manufacturers share the same vendor/product ids so you can set the "correct" name here. .PP The .B afe option allows one to set custom offset and gain values for the Analog FrontEnd of the scanner. This option can be either used to select the AFE values if automatic coarse calibration is disabled, or to make automatic coarse calibration faster. For the latter usage, enable debug level 3 (see below), scan an image and look for debug line string with "afe". Copy this line to .IR gt68xx.conf . The option has six parameters: red offset, red gain, green offset, green gain, blue offset, and blue gain. .PP A sample configuration file is shown below: .PP .RS usb 0x05d8 0x4002 .br override "mustek\-scanexpress\-1200\-ub\-plus" .br firmware "/opt/gt68xx/SBfw.usb" .br vendor "Trust" .br model "Compact Scan USB 19200" .br afe 0x20 0x02 0x22 0x03 0x1f 0x04 .RE .SH FILES .TP .I @CONFIGDIR@/gt68xx.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-gt68xx.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-gt68xx.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_GT68XX If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. If the debug level is set to 1 or higher, some debug options become available that are normally hidden. Handle them with care. Example: export SANE_DEBUG_GT68XX=4 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .BR sane\-artec_eplus48u (5) .BR sane\-plustek (5), .BR sane\-ma1509 (5), .BR sane\-mustek_usb (5), .BR sane\-mustek (5), .BR sane\-mustek_pp (5) .br .I @DOCDIR@/gt68xx/gt68xx.CHANGES .br .I http://www.meier\-geinitz.de/sane/gt68xx .SH AUTHOR Henning Meier-Geinitz .br The original gt68xx driver was written by Sergey Vlasov, Andreas Nowack, and David Stevenson. Thanks for sending patches and answering questions to them and all the other contributors. .SH BUGS The first few lines of the image are garbage for the 2400 TA Plus. .PP Interpolation should be used instead of just copying data, when the X- and Y-resolution differ. .PP Support for buttons is missing. .PP More detailed bug information is available at the gt68xx backend homepage .IR http://www.meier\-geinitz.de/sane/gt68xx\-backend/ . Please contact us if you find a bug or missing feature: . Please send a debug log if your scanner isn't detected correctly (see SANE_DEBUG_GT68XX above). sane-backends-1.0.29/doc/sane-canon_dr.man0000666000000000000000000001600013615534521015147 00000000000000.TH sane\-canon_dr 5 "31 Aug 2015" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-canon_dr .SH NAME sane\-canon_dr \- SANE backend for Canon DR-series scanners .SH DESCRIPTION The .B sane\-canon_dr library implements a SANE (Scanner Access Now Easy) backend which provides access to some Canon DR-series scanners. This document describes backend version 57, which shipped with SANE 1.0.28. .SH SUPPORTED HARDWARE This version has only been tested with a few scanner models. Please see http://www.sane\-project.org/sane\-supported\-devices.html for the most recent list. This backend may support other Canon scanners. The best way to determine level of support is to test the scanner directly, or to collect a trace of the windows driver in action. Please contact the author for help or with test results. In general, the larger machines (DR-4000 and up) which have been tested use a fairly complete protocol, with hardware support for many modes, resolutions and features. The smaller machines have many limitations, like missing horizontal resolutions, missing binary mode, always scanning full-width, etc. There is code in the backend to address these problems, but there seems to be no way to detect if they are required, so they must be hard-coded. .SH OPTIONS Effort has been made to expose most hardware options, including: .PP source s .RS Selects the source for the scan. Options may include "Flatbed", "ADF Front", "ADF Back", "ADF Duplex". .RE .PP mode m .RS Selects the mode for the scan. Options may include "Lineart", "Halftone", "Gray", and "Color". .RE .PP resolution .RS Controls scan resolution. .RE .PP tl\-x, tl\-y, br\-x, br\-y .RS Sets scan area upper left and lower right coordinates. These are renamed t, l, x, y by some frontends. .RE .PP page\-width, page\-height .RS Sets paper size. Used by scanner to determine centering of scan coordinates when using ADF and to detect double feed errors. .RE .PP Other options will be available based on the capabilities of the scanner: enhancement, compression, buttons and sensors, etc. .PP Additionally, several 'software' options are exposed by the backend. These are reimplementations of features provided natively by larger scanners, but running on the host computer. This enables smaller machines to have similar capabilities. Please note that these features are somewhat simplistic, and may not perform as well as the native implementations. Note also that these features all require that the driver cache the entire image in memory. This will almost certainly result in a reduction of scanning speed. .PP swcrop .RS Requests the driver to detect the extremities of the paper within the larger image, and crop the empty edges. .RE .PP swdeskew .RS Requests the driver to detect the rotation of the paper within the larger image, and counter the rotation. .RE .PP swdespeck X .RS Requests the driver to find and remove dots of X diameter or smaller from the image, and fill the space with the average surrounding color. .RE Use 'scanimage \-\-help' to get a list, but be aware that some options may be settable only when another option has been set, and that advanced options may be hidden by some frontend programs. .PP .SH CONFIGURATION FILE The configuration file "canon_dr.conf" is used to tell the backend how to look for scanners, and provide options controlling the operation of the backend. This file is read each time the frontend asks the backend for a list of scanners, generally only when the frontend starts. If the configuration file is missing, the backend will fail to run. .PP Scanners can be specified in the configuration file in 4 ways: .PP "scsi CANON DR" .RS Requests backend to search all scsi busses in the system for a device which reports itself to be a scanner made by 'CANON', with a model name starting with 'DR'. .RE .PP "scsi /dev/sg0" (or other scsi device file) .RS Requests backend to open the named scsi device. Only useful if you have multiple compatible scanners connected to your system, and need to specify one. Probably should not be used with the other "scsi" line above. .RE .PP "usb 0x04a9 0x1603" (or other vendor/product ids) .RS Requests backend to search all usb busses in the system for a device which uses that vendor and product id. The device will then be queried to determine if it is a Canon scanner. .RE .PP "usb /dev/usb/scanner0" (or other device file) .RS Some systems use a kernel driver to access usb scanners. This method is untested. .RE .PP Besides the 'scsi' and 'usb' lines, the configuration file supports the following 'option' lines: .PP "option buffer-size [number of bytes]" .RS Set the number of bytes in the data buffer to something other than the compiled\-in default of 4MB. Large values may cause timeouts or hangs, small values may cause slow scans. .PP Note: The backend does not place an upper bound on this value, as some users required it to be quite large. Values above the default are not recommended, and may crash your OS or lockup your scsi card driver. You have been warned. .RE .PP "option vendor-name [string of text]" .br "option model-name [string of text]" .br "option version-name [string of text]" .RS These options can be used collectively to override the values provided by the scanner, or to provide the values when the scanner cannot. .RE .PP "option padded-read [0|1]" .RS Some scanners prepend all data transmitted to host with 12 bytes. Enable this option if the scanner fails to respond to commands. .RE .PP "option duplex-offset [integer]" .RS Some scanners pad the upper edge of one side of a duplex scan. There is some variation in the amount of padding. Modify this option if your unit shows an unwanted band of image data on only one side. .RE .PP Note: 'option' lines may appear multiple times in the configuration file. They only apply to scanners discovered by the next 'scsi/usb' line. .PP .SH ENVIRONMENT The backend uses a single environment variable, SANE_DEBUG_CANON_DR, which enables debugging output to stderr. Valid values are: .PP .RS 5 Errors .br 10 Function trace .br 15 Function detail .br 20 Option commands .br 25 SCSI/USB trace .br 30 SCSI/USB detail .br 35 Useless noise .RE .SH KNOWN ISSUES This backend was entirely reverse engineered from usb traces of the proprietary driver. Various advanced features of the machines may not be enabled. Many machines have not been tested. Their protocol is unknown. .SH CREDITS The various authors of the sane\-fujitsu backend provided useful code .br Yabarana Corp. www.yabarana.com provided significant funding .br EvriChart, Inc. www.evrichart.com provided funding and loaned equipment .br Canon, USA. www.usa.canon.com loaned equipment .br HPrint hprint.com.br provided funding and testing for DR-2510 support .br Stone-IT www.stone-it.com provided funding for DR-2010 and DR-2050 support .br Gerhard Pfeffer provided access and testing for P-208 and P-215 .br Special thanks to: Alejandro Imass, Andre Shimakawa, Martijn van Brummelen, Thanos Diacakis and Junren Shi for testing and feedback. .SH "SEE ALSO" sane(7), sane\-scsi(5), sane\-usb(5) .SH AUTHOR m. allan noah: sane-backends-1.0.29/doc/sane-mustek.man0000666000000000000000000003416313615534521014706 00000000000000.TH sane\-mustek 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-mustek .SH NAME sane\-mustek \- SANE backend for Mustek SCSI flatbed scanners (and some other devices) .SH DESCRIPTION The .B sane\-mustek library implements a SANE (Scanner Access Now Easy) backend that provides access to Mustek (and some relabeled Trust and Primax) SCSI and parport flatbed scanners. At present, the following scanners are known to work more or less with this backend: .PP .RS Paragon MFS-6000CX .br Paragon MFS-12000CX .br Paragon MFC-600S, 600 II CD, ScanMagic 600 II SP .br Paragon MFC-800S, 800 II SP .br Paragon MFS-6000SP .br Paragon MFS-8000SP .br Paragon MFS-1200SP, MFS-12000SP .br ScanExpress 6000SP .br ScanExpress 12000SP, 12000SP Plus, Paragon 1200 III SP, ScanMagic 9636S, 9636S Plus .br Paragon 1200 LS .br ScanExpress A3 SP .br Paragon 1200 SP Pro .br Paragon 1200 A3 Pro .br Paragon 600 II EP .br Paragon 600 II N .br Trust Imagery 1200 .br Trust Imagery 1200 SP .br Trust Imagery 4800 SP .br Trust SCSI Connect 19200 .br Primax Compact 4800 SCSI .br .RE .PP More details can be found on the Mustek SCSI backend homepage .IR http://www.meier\-geinitz.de/sane/mustek\-backend/ . .PP Don't mix up MFS (Paragon), Pro and ScanExpress models! They're completely different. Check the exact model name! .PP Note that most of the above scanners come with a SCSI interface. The only non-SCSI scanners that have some support at this point is the 600 II N and 600 II EP scanners. The former one comes with its own parallel port adapter (i.e., it does .I not attach to the printer port). Both scanners use the SCSI protocol internally, too. More info on how to use these parallel port scanners can be found below in section .BR "PARALLEL PORT SCANNERS" . Other parallel port scanners are not supported by this backend but you may be successful using the Mustek parallel port backend mustek_pp, see .BR sane\-mustek_pp (5). USB scanners are also not supported by this backend but the ma1509, mustek_usb, gt68xx, and plustek backends include support for some of them, see .BR sane\-ma1509 (5), .BR sane\-mustek_usb (5), .BR sane\-gt68xx "(5), and" .BR sane\-plustek (5). .PP Mustek scanners have no protection against exceeding the physical scan area height. That is, if a scan is attempted with a height that exceeds the height of the scan surface, the scanner begins making loud noises and the scan mechanism may be damaged. Thus, if you hear such a noise, IMMEDIATELY turn off the scanner. This shouldn't happen if your scanner is in the list of known scanners. There is more information in the .I @DOCDIR@/PROBLEMS file. .PP If you own a Mustek (or Trust) scanner other than the ones listed above that works with this backend, please let us know by sending the scanner's exact model name (look at the front and back of the scanner) and a debug output to .IR sane\-devel@alioth-lists.debian.net . You can get the debug output by setting the environment variable .B SANE_DEBUG_MUSTEK to 5 and showing the list of available scanners with scanimage \-L. Please send all of it to the mailing list. You must be subscribed to sane\-devel before you can send mail to the list. See .I http://www.sane\-project.org/mailing\-lists.html for details. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is either the path-name for the special device that corresponds to a SCSI scanner or the port number at which the parallel port scanners can be found (see section .B "PARALLEL PORT SCANNERS" below). For SCSI scanners, the special device name must be a generic SCSI device or a symlink to such a device. The program .I sane\-find\-scanner helps to find out the correct device. Under Linux, such a device name could be .I /dev/sg0 or .IR /dev/sg3 , for example. See .BR sane\-scsi (5) for details. .SH CONFIGURATION The contents of the .I mustek.conf file is a list of options and device names that correspond to Mustek scanners. Empty lines and lines starting with a hash mark (#) are ignored. See .BR sane\-scsi (5) on details of what constitutes a valid device name. .PP The supported options are .BR linedistance\-fix , .BR lineart\-fix , .BR legal\-size , .BR buffersize , .BR blocksize , .BR strip\-height , .BR disable\-double\-buffering , .BR disable\-backtracking , and .BR force\-wait . .PP Options come in two flavors: global and positional ones. Global options apply to all devices managed by the backend whereas positional options apply just to the most recently mentioned device. Note that this means that the order in which the options appear matters! .PP Option .B linedistance\-fix is positional and works around a problem that occurs with some SCSI controllers (notably the ncr810 controller under Linux). If color scans have horizontal stripes and/or the colors are off, then it's likely that your controller suffers from this problem. Turning on this option usually fixes the problem. .PP Option .B lineart\-fix is positional and works around a timing problem that seems to exist with certain MFS-12000SP scanners. The problem manifests itself in dropped lines when scanning in lineart mode. Turning on this option should fix the problem but may slow down scanning a bit. .PP Option .B legal\-size is positional and sets the size of the scan area to Legal format. Set this option if you own a Paragon 12000 LS. It can't be distinguished by software from a ScanExpress 12000 SP (ISO A4 format). .PP Option .B buffersize is a positional option that overrides the default value set for the size of the SCSI buffer. The buffer size is specified in kilobytes. The default value is 128. Because of double buffering the buffer actually sent to the scanner is half the size of this value. Try to increase this value to achieve higher scan speeds. Note that some ScanExpress scanners don't like buffer sizes above 64 kb (buffersize = 128). If your sg driver can't set SCSI buffer sizes at runtime you may have to change that value, too. See sane\-scsi(5) for details. .PP Option .B blocksize is a positional option that overrides the default value set for the maximum amount of data scanned in one block. The buffer size is specified in kilobytes. Some scanners freeze if this value is bigger than 2048. The default value is 1 GB (so effectively no limit) for most scanners. Don't change this value if you don't know exactly what you do. .PP Option .B strip\-height is a global option that limits the maximum height of the strip scanned with a single SCSI read command. The height is specified in inches and may contain a fractional part (e.g., 1.5). Setting the strip\-height to a small value (one inch, for example) reduces the likelihood of encountering problems with SCSI driver timeouts and/or timeouts with other devices on the same SCSI bus. Unfortunately, it also increases scan times. With current SCSI adapters and drivers this option shouldn't be needed any more. .PP Option .B disable\-double\-buffering is a global option. If set, the backend will only send one buffer at a time to the scanner. Try this option if you have trouble while scanning, e.g. SCSI errors, freezes, or the first few cm are repeated over and over again in your image. .PP Option .B disable\-backtracking is a positional option. If set, the scanner will not move back its slider after each SCSI buffer is filled (`backtracking'). Setting this option will lead to faster scans but may also produce horizontal stripes. This option doesn't work with every scanner (only some of the paragon models can modify backtracking). .PP Finally, .B force\-wait is a global option. If set, the backend will wait until the device is ready before sending the inquiry command. Further more the backend will force the scan slider to return to its starting position (not implemented for all scanners). This option may be necessary with the 600 II N or when scanimage is used multiple times (e.g. in scripts). The default is off (not set). .PP A sample configuration file is shown below: .PP .RS # limit strip height of all scanners to 1.5 inches: .br option strip\-height 1.5 .br .br /dev/scanner # first Mustek scanner .br # 1 MB buffer for /dev/scanner: .br option buffersize 1024 .br /dev/sge # second Mustek scanner .br # turn on fixes for /dev/sge: .br option lineart\-fix .br option linedistance\-fix .RE .SH "SCSI ADAPTER TIPS" .PP You need a SCSI adapter for the SCSI scanners. Even if the connector is the same as that of parallel port scanners, connecting it to the computers parallel port will NOT work. .PP Mustek SCSI scanners are typically delivered with an ISA SCSI adapter. Unfortunately, that adapter is not worth much since it is not interrupt driven. It is (sometimes) possible to get the supplied card to work, but without interrupt line, scanning will be very slow and put so much load on the system, that it becomes almost unusable for other tasks. .PP If you already have a working SCSI controller in your system, you should consider that Mustek scanners do not support the SCSI-2 disconnect/reconnect protocol and hence tie up the SCSI bus while a scan is in progress. This means that no other SCSI device on the same bus can be accessed while a scan is in progress. .PP Because the Mustek-supplied adapter is not worth much and because Mustek scanners do not support the SCSI-2 disconnect/reconnect protocol, it is recommended to install a separate (cheap) SCSI controller for Mustek scanners. For example, ncr810 based cards are known to work fine and cost as little as fifty US dollars. .PP For Mustek scanners, it is typically necessary to configure the low-level SCSI driver to disable synchronous transfers (sync negotiation), tagged command queuing, and target disconnects. See .BR sane\-scsi (5) for driver- and platform-specific information. .PP The ScanExpress models have sometimes trouble with high resolution color mode. If you encounter sporadic corrupted images (parts duplicated or shifted horizontally) kill all other applications before scanning and (if sufficient memory is available) disable swapping. .PP Details on how to get the Mustek SCSI adapters and other cards running can be found at .IR http://www.meier\-geinitz.de/sane/mustek\-backend/#SCSI . .SH "PARALLEL PORT SCANNERS" This backend has support for the Paragon 600 II EP and Paragon 600 II N parallel port scanners. Note that the latter scanner comes with its own ISA card that implements a funky parallel port (in other words, the scanner does not connected to the printer parallel port). .PP These scanners can be configured by listing the port number of the adapter or the parallel port in the mustek.conf file. Valid port numbers for the 600 II N are .IR 0x26b ", " 0x2ab ", " 0x2eb ", " 0x22b ", " 0x32b ", " 0x36b ", " .IR 0x3ab ", " 0x3eb . For the 600 II EP use one of these: .IR parport0 ", " parport1 ", " parport2 ", " 0x378 ", " 0x278 ", " 0x3bc . Pick one that doesn't conflict with the other hardware in your computer. Put only one number on a single line. Example: .PP .RS .I 0x3eb .RE .PP Note that for these scanners usually root privileges are required to access the I/O ports. Thus, either make frontends such as .BR scanimage (1) and .BR xscanimage (1) setuid root (generally not recommended for safety reasons) or, alternatively, access this backend through the network daemon .BR saned (8). .PP If the Mustek backend blocks while sending the inquiry command to the scanner, add the option .B force\-wait to .IR mustek.conf . .PP Also note that after a while of no activity, some scanners themselves (not the SANE backend) turns off their CCFL lamps. This shutdown is not always perfect with the result that the lamp sometimes continues to glow dimly at one end. This doesn't appear to be dangerous since as soon as you use the scanner again, the lamp turns back on to the normal high brightness. However, the first image scanned after such a shutdown may have stripes and appear to be over-exposed. When this happens, just take another scan, and the image will be fine. .SH FILES .TP .I @CONFIGDIR@/mustek.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-mustek.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-mustek.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_MUSTEK If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. .ft CR .nf Value Description 0 no output 1 print fatal errors 2 print important messages 3 print non-fatal errors and less important messages 4 print all but debugging messages 5 print everything .fi .ft R Example: export SANE_DEBUG_MUSTEK=4 .SH "SEE ALSO" .BR sane (7), .BR sane\-find\-scanner (1), .BR sane\-scsi (5), .BR sane\-mustek_usb (5), .BR sane\-gt68xx (5), .BR sane\-plustek (5), .BR sane\-mustek_pp (5) .br .I @DOCDIR@/mustek/mustek.CHANGES .br .I http://www.meier\-geinitz.de/sane/mustek\-backend/ .SH AUTHOR David Mosberger, Andreas Czechanowski, Andreas Bolsch (SE extensions), Henning Meier-Geinitz, James Perry (600 II EP). .SH BUGS Scanning with the SCSI adapters supplied by Mustek is very slow at high resolutions and wide scan areas. .PP Some scanners (e.g. Paragon 1200 A3 + Pro, SE A3) need more testing. .PP The gamma table supports only 256 colors, even if some scanners can do more. .PP More detailed bug information is available at the Mustek backend homepage: .IR http://www.meier\-geinitz.de/sane/mustek\-backend/ . sane-backends-1.0.29/doc/sane-logo2.jpg0000666000000000000000000001537413615534521014430 00000000000000ÿØÿàJFIFÿþhMade with GIMP CREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2) Quality = 75, Smoothing = 0 ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀ–€"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?÷ú(¨§-ãÞà‘žƒ­ Ø j).a„‘$¨¬vÜó§^Õs­–c;NpBóôçð¬F½™ãq¹rTa{tÇå\ò®–Ũw:ÆÕ-†pY†:犤úð*è‘ ˜2û€8ïÇ<×)xò°°~_¨=È5 º3À¼òzŽ?òk'^l¥tÒø–HˆÜ"íÚr?ZŒkÒ‘¹n ‰Ã*‚ ãõ5„ˆÌ’yŽ­¸‘’:Ž˜ü©—)´Ux_LƒÜƒþMG´Ÿqò£þ ˺,¥˜tG¥Vo_E,nnI“Ƽðzàg¿b:ÙÎ5¼lЀ0¤p{ŒTË•“Ì`Ù$GQÓùZ^Ò]ÇÊŽ†/ÎrÆdSÀPÅ=úç=½*ü>#°–c™!l€<ÅàçÜgŽ:×r»p ®6ñÆAH>œzmº;BJñÁ'‘ŽÕj¼Ðœé1Ëщ"ut=NAüiÕçP  •§†vŽ`Äy‰‘ŽààqúV•·Š¯l&Hµ8ÖâØ‘›˜Æ9%@ÁçÞ`csÆ:ã“Åliß ¼¦yžFi'™ßjÝsŒg§˜[o^ØÏè+O«÷dóœT:ö˜Æ¡ ru?ç4zÕ¤åcŠh{«wïÇã]ïü!¾ÿ¡oGÿÀ¿øš­yðÿ—ÏÉ¢[DÑgiµÍ¿\uòÊîéÆsŽqÔÑõ0ö‡/çÀì`ÒSŸóúÒÅ$œI=½søt­{‡V‘Ê$Òu ‹¼7”ãÎŒ¸À†ç¯,{ñÓŽŸ©Z´–·Öªä(Û,`˜Û#³c¨Áã¯áYN”¢R’eS;åÑI?Â{ðHÇãJÏ›&CǦîÏëQɺ7Ù {Ïùê)··†$…-íßh+á?.æäeAa‘œã' $fQD]ßøgR}GJQ*…Vº·lªJ™nø?0ì{gž©iZ¶³¥[j6º ˆÃ®H%}Tà‚3ÁW ·[W´Š%)´€‡œç’I<“žsÔ“š>_Ì­â E¥…ÒM<„áe òþ6•ßêísdñ `ù“#<åž™÷®ìB²ïêÍ€?Ú$ÿŸÖ£­+Ž­ã- ã Ž“sþZÎñŒúŽƒ}“÷’+(oè?ò+J¤I@W2þ·Nj3)|Dˆ£w¡üOÖ°EGÃë‹ü¦%…¬6i^L¶ÐŒ,R¯ßÉ<œ°,KÀžMtÕåzuãx[W–þÚ/6 ­©w ¹ðN}ÆOÁÉö#Ólï-õ H®í%Y`”nG^ÿà}»W}:ŠhÆQ±=QZQE#2 Ë0ÔšÇÕoákRªëì[¾Gÿ^µ'·Šæ&Žd ¬ ú¡¨®ZûáîŸq;Oi¨YÈcÚgó#ÝÏÌÁòǶ@aÓ·Z΢“VE+-Ìp¥Äžc«n%O^G@?ϽGr˜^BòP{}9þºuç‡|I¤ÆíƒR·LÔ—É;r0“‘Ç¥85k—dmËt‡cÆã AÓθ¥ GsTÓ,B…áùHRÌ{sÓÖ¡ø\IñŸŒÁ`ÅE˜Èöó…HTÀ¯!•WsŸ_çù[à¬?k“ÅZè˜u~¶¢ ¼/”»·g<çÎéŽ6ûñ®{Í“=W®GVÓ…¬â1BåâÆÑŽW8Ó×]TõK3}§M…ó æ=Çp铃ØñКè«x‘fqÃ4‘í ÞŸÖ©JL,²>Cc#Ÿ›üój«®j¶þ³y5ï+"?súç?Ö²4 ÅÿZ ¹IѼ;9WóØÿ¤\Dsþ­yÛœ[ W)ÊLÕÉ"Ö«âý&ÆXm“72Ê-áMò;žªÉ$ãñ©ü*> M¬G}§èk§i¹¤‹TœÂ³|ÁHòÀgG8Èb£…îuáïøoÁPgO´D¹uÛ%Ü¿¼¸›îƒ–ë‚UIUƒÈ´fÖ£T  'Lù‡¦~†º!OVõ3mÈÕ¨Úâb­4a‡ÉÜkþln²LŽ¥ˆäà8ÿ?…eÞjÙy‘—±È#©Ý=ÿÁ†ùå‹ ™2¥À³“íÌdbW†Ç ãå`G ¨ úéÕ ±-Ü(¢ŠÐF=ï…tMG[µÖ/4øæ¿´`ðÈÄáXtm¹ÚHìH$`c Å‹ÛËÅ,ldËl.Ì#T÷;¹ uÈÛ=+BŠMÅ^è^1Öa6¯¦éhµ´OrÏ×;·lÛŽ1Œõ=1Îe¯Âwx_û[źµÌåŽÔ$ ·‚¬“œœçÓŽ9ôŠlåÆÏ‚p3ŒŸnjy"ºìó†øCáûyb–ëZÖåŒ8o&K”Û.>b¸T rû¤Jv¥á_Ø£³Y7«6¥:éßy>½»W7ñ'âUä:³h: ¢Þ Ä÷'¥¾{ö¿Ïæ¶vrjÞ}¶YnnV˜I;n8S–ã¦Zô°9F#RŒ;¾¾„N¬a£Õž¹á BÎh’ÊîÊC Qqa¨¼åS*K~ðãÔ”ñÓžšOíþÓÏÓüC®I¹F̨¤0<‚¦ AïÈäz^7‹a¸·‘㕃|¡ŽÒ7axéÔ7=~_jìt^^Ì/,¤Xuë8òxÈ8ܬ?‰N#¶ ÷?çõ¯H®?W´HæeEˆùrç„ÆÐFq£X×…½äTCE×.<'¨Ggu'›£\8™€û+1å²x “ó àrGp}:¼ÇQ·ŠþÒ{WŒ9u )éZ¿ 5æÔ49´{’~Û£8·`F ˆƒå€WŸ“'­U ÝYŠk©ÜÑE`ë¾!·Òì䙤 "äÔÿœ:ÚRQWd¥sVëP³±…庹Ž(Óï³7ÝúÔn§ý«w6öò-”‰½'æsÁU%HÉÉÇðã äp ðüþ1‰|Oâ…ÙNû?I–3å,y#Í‘[‡f¯U†ä‘·Óè\ÏVÁXÞ'ÔLÐî®× °Âòn-Œ8Ç çô­šæ«*Dí ¶’ÑI*®Q]¥Œ…'Ôíb=vŸCXÐøŠžÇ¬êS<›ÕI†â:ëùà~5Ák°ÇªÅ4LªVBÃÆo3k‚p§’@9Ær+gL¼¾°ˆF·RlRªI ƒjôwxÉã©ÆTe€Ëc'¥6ßS·¸]¶ïg‘†ïߊõJæu/ø{Qù’Ïì3… ³XŸ(¨?t|¤õ œaŽya×CE>ç8d…ðY‹9ã8ûÞøÿ=è‰eŠO–C€qßÿ­’2j{Ÿ‡7𴯦ëÀªÐCwlîÇF‘HàžáxŽ*ŒÞñ½¥£È Ò¯™pgevÉ9uQÇ^HéëY:Es¢À½—îG·Ûß'Š‘®ÉÁ21~‡½Ïùü†4ï™Éá’Hî/ Ïþ‡éV¾ÃãTÿÂ&0yº·Ïç¾—²Ÿ`æF‚Ir’€f8xg¿øtæ£7.˱TO7~¦©½·0qá-Þ€Þ@?óÖsi'ºÉg f–öF:nm®Në€O £ÙMôdn³ÄÍó2p‹ž¸ÿõôéU'¼·ÓŽéî‘ ¶[¯áùTqü9ñ–¡ç CÄfž#gn×õÎKlÛŽ1Œç'§}»ƒþ‚èÜßµþ®áÑÑoî2ˆTçî U`xÈ`Àã뛎½ÄæŽ|Yy®\I§xSIŸU¹O¾ñ`E ‘½Îsµ±’2Gñ]ðŽKÝBWƺ’êSÆáÓO·è ‚q¼°ÌƒîœaFA0¯K±°³Ó,ã³°´‚ÒÖ<ì†Äh¹$œ(àd’±]§ìC“aEV„…cë>#³Ñ¯,l9îuÿ3ìvp(ß?–|3•EÚ§?3 ㌞+b¹øwÃ^3Õmô›û¹àÖôø…í¬–“´SÛ£H˜ŸÂ~h€'o €-ÇâÙ[Ót»ïk6¨<‰óˆ-ÈŒä3G+m%TàÎ:t•æ–7Þ+ðÿ´Oøž÷M×í57¸–Âü[.-Þ(AbUFÀ0Σ$9%€ùk³ñ¬êztpèzïö-ÒÊ®>È—;“Úç$ƒŸozجø›Kð–uM^&ÔKY±,Àp½[,@ÉÚ¬@8­Šóƒm©øÖòmphÚV£¡\Z=®–—×YÏ2“IŸÞ€»XDaq‚ÍC‚xn­â¸·–9 •Ç$l]HÈ Ž#œÔ•æ uKÏê÷ß|As‹»M³i&YŒžu«.|´soòðFqýà Çoâ=;YÔôèáÐõßì[¥”;\}‘.w&)µÎI>Þô¡}q-¥œ“Ãe=䋌A@ï’ÙW޼‘Ó׊æ<ñ+Ãþ=ûLz[Ï Õ¿/ktª’ãç1rqÁàã dg¯¯ðáñ/¯ ê–WÒi:þžó›MNò¯Ú%Ê:äB àžç±`À‡¬øÑtoØèo¡j·7WþgØÞo²-¾ Ê¥vƒü@gfºŠñ -w]½ø½àÅ^N·¤ý¸KsMäoÉ2të±²0#±Ê¯¯ëvšö‘=¶•ªeß>ß.óìë?—†üÁÈ{g=¨ÅõĶ–rO ”÷’.1¾He^:òGO^+ðçĨ¼[§I¡øg\»µŽS >mcÀ yÁèÃó®Þ¼3à•y}à[ÙmõýKOA©H¦+XíÙIò¢ù™œóޏàqÖ€=_Eñ Ö5MGM—IÔ´Û»…äKÕ²nÚQ‘Ø0ùc¨8ܬ½.F³+¤Þj’j:‚#ÎÒ´*åÍûE8ùGMûÃcR€ ÏÔô-[ò¿µt«ÿ'>_Ú­Ò]™Æq¸gòQ@Yé:nŸquqe§Ú[Ovûî$†F™²N\–9br}O­\¢Š¯}ag©ÙÉgiݬ˜ß ñ‰°ASÁÁþ›¤éº=»[éz}¥Œ åÚ;XV%-€2B€3€}…Py¼5 ÜêƒTŸDÓeÔ«‹·µF”2ãiÞFr00sÆjQEW¾°³Ôì䳿´‚îÖLo†xÄˆØ Œ©àà€ MÒtÝÝ­ô½>ÒÆrí¬+–À!@À>Š(I¬,î/-¯&´‚K«]ÞDÏ/á†ÚÇ•Èàã­X¢ŠŽx!º·–Þâ(æ‚T)$r(eu#x Ž1Xð‚øCþ…MÿÑñ4Q@f…£èžoöV•caçcÌû-ºE¿Ævœdþf´(¢€?ÿÙsane-backends-1.0.29/doc/sane-ricoh2.man0000666000000000000000000000236213615534521014560 00000000000000.TH sane\-ricoh2 5 "04 Sep 2019" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-ricoh2 .SH NAME sane\-ricoh2 \- SANE backend for Ricoh flatbed scanners .SH DESCRIPTION The .B sane\-ricoh2 library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Ricoh flatbed scanners: .PP .RS SG-3110SFNw .br SG-3100SNw .br SP-100SU .br SP-111SU (SP-112SU) .RE .PP .SH FILES .TP .I @LIBDIR@/libsane\-ricoh2.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-ricoh2.so The shared library implementing this backend (present on systems that support dynamic loading). .SH OPTIONS The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in programs like xscanimage or xsane. .PP The following options are supported by ricoh2: .B \-\-mode color|gray .RS Color or grayscale mode. .RE .B \-\-resolution 300|600 .RS DPI resolution. .RE .SH ENVIRONMENT .TP .B SANE_DEBUG_RICOH2 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. .SH "SEE ALSO" sane(7), sane\-usb(5) .SH AUTHOR Stanislav Yuzvinsky sane-backends-1.0.29/doc/plustek/0000755000000000000000000000000013615535552013516 500000000000000sane-backends-1.0.29/doc/plustek/MakeModule.sh0000666000000000000000000000516113615534521016017 00000000000000#!/bin/bash #****************************************************************************** # # Bash-Script to create Plustek-Scannerdriver modules for Kernel 2.4, 2.6 and 3.x # out of the backend sources... # BUILD_DIR=$PWD/build SRC_DIR=$PWD/../../backend MAKEFILE=$PWD/Makefile.kernel26 KERNEL_V=`uname -r` OSMINOR=`uname -r | cut -b 3` OSMAJOR=`uname -r | cut -b 1` # # some intro ;-) # echo "This script will try and build a suitable kernel-module for your system." echo "If you'd like to make the module WITH debug output, restart this script" echo "with as follows:" echo "./MakeModule.sh DEBUG=y" echo "Press to continue or to cancel." read # # we need to be root user... # echo -n "Check for root..." if [ $EUID -ne 0 ]; then echo -e "\b\b\b - failed" echo "Please retry as root user." exit -1 fi echo -e "\b\b\b - done." # # Version checks... # echo -e "\nCheck for kernelversion:" if [ "$OSMAJOR" == "3" ];then echo "Using makefile for kernel 2.6.x - okay for kernel 3 as well..." MAKEFILE=$PWD/Makefile.kernel26 elif [ "$OSMINOR" == "6" ]; then echo "Using makefile for kernel 2.6.x" MAKEFILE=$PWD/Makefile.kernel26 elif [ "$OSMINOR" == "4" ]; then echo "Using makefile for kernel 2.4.x" MAKEFILE=$PWD/Makefile.kernel24 else echo "Your kernelversion >"$OSMAJOR"."$OSMINOR"< is probably not supported" exit -2 fi # # Setup... # echo -e "Build-directory: \n"$BUILD_DIR echo -n "Removing build-directory..." rm -rf $BUILD_DIR echo -e "\b\b\b - done." echo -n "Creating build-directory..." mkdir $BUILD_DIR cd $BUILD_DIR echo -e "\b\b\b - done.\n" echo -n "Linking source files..." C_FILES=`ls $SRC_DIR/plustek-pp_*.c` H_FILES=`ls $SRC_DIR/plustek-pp_*.h` for F in $C_FILES $H_FILES $SRC_DIR/plustek-pp.h $SRC_DIR/plustek_pp.c; do ln -s $F . done echo -e "\b\b\b - done." echo -n "Copying Makefile to build-directory..." cp $MAKEFILE Makefile echo -e "\b\b\b - done." # # Building the module... # echo "Making the module..." if [ "$OSMAJOR" == "2" -a "$OSMINOR" == "4" ]; then make all $1 else make -C /lib/modules/$KERNEL_V/build/ SUBDIRS=$BUILD_DIR modules $1 fi RES=$? cd .. if [ $RES != 0 ]; then echo "There were some build errors..." exit -1 fi echo "done." echo "Should I install the module?" echo "Press to continue or to cancel." read make -C $BUILD_DIR install echo "Should I try and load the module?" echo "If this step fails, check the kernel-log." echo "Press to continue or to cancel." read make -C $BUILD_DIR load echo "done." echo "Should I remove the build directory?" echo "Press to continue or to cancel." read rm -rf $BUILD_DIR echo "done." sane-backends-1.0.29/doc/plustek/Plustek-USB.txt0000666000000000000000000003631713615534521016266 00000000000000Plustek-USB.txt (2005-08-08) Gerhard Jäger =============================================================== NOTE: ----- ALL YOU NEED TO RUN YOUR USB SCANNER IS ALREADY INCLUDED. THERE'S NO NEED TO INSTALL THE KERNEL MODULE pt_drv. THIS ONE IS ONLY NEEDED FOR THE PLUSTEK PARALLELPORT SCANNER. List of all currently implemented devices ----------------------------------------- Quite a lot of them are not tested or even identified. Please send me the ids of your device... PLUSTEK ======= Vendor ID: 0x07B3 Product ID Device-description and status 0x0005 not identified yet 0x0007 not identified yet 0x000F not identified yet 0x0010 U12 - working 0x0011 U24 (LM9831) - working 0x0012 not identified yet 0x0013 UT12 (LM9831) - working 0x0014 not identified yet 0x0015 U24 (LM9832) - working 0x0016 not identified yet 0x0017 UT12 - working, UT16 - working, UT24 - working MUSTEK ====== BearPaw vendor ID: 0x0400 (They use the NationalSemiconductors ID!!!) Product ID Device-description and status 0x1000 BearPaw 1200 (LM9831) - working 0x1001 BearPaw 1200 (LM9832) - not tested 0x1001 BearPaw 2400 (LM9832) - mostly working KYE (Genius) ============ Vendor ID: 0x0458 Product ID Device-description and status 0x2007 ColorPage-HR6 V2 - working 0x2008 ColorPage-HR6 V2 - not tested 0x2009 ColorPage-HR6A - not tested 0x2013 ColorPage-HR7 - working 0x2015 ColorPage-HR7LE - not tested 0x2016 ColorPage-HR6X - not tested Hewlett Packard =============== Vendor ID: 0x03F0 Product ID Device-description and status 0x0505 HP Scanjet 2100c - working 0x0605 HP Scanjet 2200c - working EPSON ===== Vendor ID: 0x04b8 Product ID Device-description and status 0x010F EPSON Perfection 1250/Photo - working 0x011D EPSON Perfection 1260/Photo - working UMAX ==== Vendor ID: 0x1606 Product ID Device-description and status 0x0050 UMAX 3400 - working 0x0060 UMAX 3400/3450 - working 0x0160 UMAX 5400 - working COMPAQ ====== Vendor ID: 0x049F Product ID Device-description and status 0x001A S4-100 - working, identical with UMAX 3400 CANON ===== Vendor ID: 0x04A9 Product ID Device-description and status 0x???? FB620U - not integrated 0x2206 N650U - working 0x2207 N1220U - working 0x2208 D660U - working 0x220D N670U/LiDE20 - working 0x2220 LiDE25 - working 0x220E N1240U/LiDE30 - working How to use and configure the Plustek USB backend ------------------------------------------------ Please note, that the following is only needed, if you need to upgrade a SANE version... Preparations ------------ What do we need ? a SANE backends archive (i.e. sane-backends-1.0.9.tar.gz) a driver archive (i.e. plustek-sane-0.45-1.tar.gz) The latest SANE archive can be obtained at: http://www.sane-project.org and the latest backend at: http://www.gjaeger.de/scanner/plustek.html Assumptions ----------- Our starting point is your home-directory: :~> The packages (here sane-backends-1.0.9.tar.gz und plustek-sane-0.45-1.tar.gz) are in the /tmp directory. Let's go: --------- Change to your home directory and create a sane directory cd ~ mkdir sane unpack your sane tar-ball (here "sane-backends-1.0.9.tar.gz") to this "sane" directory cd sane tar xvzf /tmp/sane-backends-1.0.9.tar.gz Now unpack your plustek-sane tarball (here "plustek-sane-0.45-1.tar.gz") to the backends directory: cd sane-backends-1.0.9 tar xvzf /tmp/plustek-sane-0.45-1.tar.gz Now do the ./configure step... Especially for SuSE with a preinstalled SANE-RPM: ./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man --infodir=/usr/share/info Then do the make step and after that as root user perform the make install step. That's all! Before using, make sure that the USB scanner device driver is loaded: modprobe scanner or modprobe scanner vendor=0x7b3 product=0x17 You might need to add the following line to /etc/modules.conf, if the scanner is not supported directly - vendor and product must match your device! options scanner vendor=0x7b3 product=0x17 If you're not sure about the vendor and product id of your device, simply load the USB subsystem and plug in your scanner. Then do a cat /proc/bus/usb/devices and look for the scanner Now you have to configure the backend. Edit the file /etc/sane.d/plustek.conf and fill in the appropriate vendor and product id (see there for examples) This is it... Autoloading scanner.o --------------------- To perform an automatic load of the scanner module, you might add the modprobe line to your boot.local file. i.e. on SuSE system > 7.x /etc/init.d/boot.local An alternative way is to use the hotplug utilities. Using hotplug utilities and libusb ---------------------------------- When using libusb with SANE, then you should also use the hotplug utilities to automatically setup your device nodes (at least the permissions) and prevent scanner.o from loading. Assuming, that these utilites are properly installed on your box, you have to tweak and add some files. In directory (where of course the config files reside): /etc/hotplug Append the line scanner to file blacklist This prevents the scanner module from the usb-subsystem to be loaded. Next thing is to add a new line in usb.usermap: usbscanner 0x0003 0x1606 0x0160 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00 000000 The example line shows the vendor ID of UMAX 0x1606 and the product ID of the 5400 0x0160 - these values must match the ones of your scanner. Last step is adding a script in /etc/hotplug/usb/ It is called "usbscanner" (don't forget the executable rights) ------------------------------------------------- # !/bin/bash if [ "${ACTION}" = add ] && [ -f "${DEVICE}" ] then chgrp users "${DEVICE}" chmod ug+rw "${DEVICE}" fi ------------------------------------------------- This script will correct the access right to your scanner device when the device is plugged in. Debugging your USB scanner (written by Kev Green) ------------------------------------------------- Firstly, are you running the latest version of SANE, and the Plustek USB driver? Double check at http://www.gjaeger.de/scanner/plustek.html (Plustek USB driver) and http://www.sane-project.org (SANE Suite) to make sure you are. Now, in order to test and utilise your scanner with the Scanner Access Now Easy (SANE) system, there are basically two programs that you will need to use from the sane-frontends (versions post 1.0.3) or sane (versions pre 1.0.3) packages. Firstly, the sane-find-scanner program will allow you to locate your scanner, and help you work out if sane knows where it is. This is not definite however, as (you'll see this too when using sane-find-scanner) it will find all the scanners on your USB and SCSI bus, whereas sane will only work when you have the relevant sane backend installed and configured correctly for the relevant scanner. So, if sane-find-scanner can find your scanner, but scanimage doesn't work, then you need to check, double check, and even triple-check your SANE configuration file for plustek scanners (plustek.conf, usually in /etc/sane.d or maybe in /usr/local/sane/ or somewhere, a "find" will be able to tell you where. It may take a while though!). If sane-find-scanner doesn't find your scanner, then you should check to see if the kernel recognises it at all, which you can do with the following command, as mentioned above: cat /proc/bus/usb/devices If your scanner doesn't appear in there, then the kernel has not recognised it. There may however be a crypic-looking entry in there which doesn't name itself as plustek, in which case it is recognised as being there by the kernel, but is not know to the kernel's USB device database, in which case this should be mentioned on the plustek list (), from where the "powers that be" will deal with it. If that file does not exist in the /proc filesystem, then you don't have the "Preliminary USB filesystem" option set in your kernel, and you will need to recompile your kernel to allow you to do this step in debugging. If it exists, but is empty, you will have to make sure (use the kernel configure help information and the details of your motherboard to ascertain this!) you have the right one of UHCI or OHCI USB modules installed or compiled into your kernel. Once you've established that the kernel has recognised your scanner, you can start pointing the finger at SANE, or simply the "scanner" module. You will need to have selected the "USB Scanner" option in your kernel compilation as a module, or compiled into the kernel. If you have done neither, then SANE will simply not be able to recognise your scanner. Rectify that, if you are missing it. If you have carried out all of the above steps, then sane-find-scanner should be able to recognise your scanner correctly. sane-find-scanner probes all of the devices on the SCSI and USB busses, and so you may find that it outputs "unable to get minor data" errors or similar to your terminal, or to your error logs, you can safely ignore these as long as it does that, and has recognised your scanner. Once you have found your scanner okay using sane-find-scanner, then you are ready to start messing around with the actual scanimage program to attempt to scan an image in. Obviously (although this may turn out to be premature) you should now have something in your scanner ready to scan for verification. At this stage, you should begin to be warey, because while the USB stuff for Plustek scanners is in development it may (like any kernel/module related software) crash your system with a kernel panic, or simply just segfault, so for your own sake, close down all the applications you are running and ONLY use text console, rather than X-Windows at this point, as you will certainly want to avoid any potential filesystem corruption. At this point it's probably also good to ensure that you have selected the "Magic SysRq Key" option in the kernel hacking section of the kernel config, and done: echo 1 > /proc/sys/kernel/sysrq And of course read the readme for that in /usr/src/linux/Documentation, as that should allow you to avoid filesystem corruption during any crashes that might happen. Now, before running scanimage, you should enable the maximum levels of debugging possible in both the SANE core and in the Plustek scanner backend. To do this you should do: export SANE_DEBUG_PLUSTEK=12 export SANE_DEBUG_DLL=12 Now, if you run scanimage, you should be able to see the maximum debugging messages. If those messages don't tell you what is wrong, then take note of your scanner type, the contents of /proc/bus/usb/devices, and the contents of your error log, as well as (where possible) the output of the scanimage command (if you can't capture it directly, an as-accurate-as-possible description is MUCH better than nothing!), and try and get all of the activity that your scanner did as well (light came on? didnt? motors came on? etc?) and email that to the plustek list (). For the particularly adventurous only... You might want to try running the scanimage program through strace or gdb to see if you can go some or all of the way to debugging the problem yourself, and post the relevant (ie. last!) parts of those utilities output to the plustek-help list. If you don't know what strace or gdb are, then you should probably not try that. It's probably safe to run your scanner in a normal operating environment under Linux once you have got it working once in a text console. How to add a new LM9831/2 based device description -------------------------------------------------- If you have a LM9831 or LM9832 based scanner and your vendor and product id did not appear in the list above and you're willing to do some experiments, then simply add your device to the file plustek-devs.c at the end of the list. See the list at the end of the file how this works... Thanx guys for helping: ----------------------- Henning Meier-Geinitz henning@meier-geinitz.de for Mustek Bearpaw testing, ideas and patches Stefan Nilsen stefan.nilsen@telia.com for HP2200c testing and patches Kev Green kyrian@ore.org for Documentation, UT12 testing and RPMS. Holger Bischof bischof@cs.tu-berlin.de for OpticPro U12 testing Abhijit Sovakar a.sovakar@gmx.de for OpticPro UT24 testing Peter Koellner peter@mezzo.net for OpticPro U24 testing Gene Heskett gene_heskett@iolinc.net for EPSON 1250 testing and patches Tasnim Ahmed tasnim_ahmed@yahoo.com for KYE Colorpage HR6 testing Reinhard Max max@suse.de for EPSON 1250 testing and patches Allan N. Hessenflow allan@kallisti.com for UMAX 3400 testing and patches Craig Smoothey craig@smoothey.org for HP2100c testing and patches Till Kamppeter till.kamppeter@gmx.net for EPSON1260 testing Christopher Montgomery monty@xiph.org for CanoScan calibration works Olaf Leidinger leidola@newcon.de for CanoScan LiDE25 testing and a lot of other guys not named here... Some equations which are used to calculate some stuff ----------------------------------------------------- The stuff is used in plustek_usbscan.c to get the correct register settings out of the hardware descriptions: Crystalfrequency is 48MHz Pixel Period (seconds/pixel) ---------------------------- MCLK_DIV x 8 x CM PixelPeriod = ----------------- 48MHz Integration Time (seconds) -------------------------- Tint = PixelPeriod X LineLength MCLK_DIV x 8 x CM X LineLength Tint = ------------------------------ 48MHz Ideal MCLK Divider ------------------ 48MHz (DataPixelsEnd - DataPixelStart) MCLK_DIV = --------------------------- x -------------------------------- HostIORate x 8 x LineLength HDPI_ADJ x PP 48MHz (DataPixelsEnd - DataPixelStart) CM = ------------------------------- x -------------------------------- x ---- BytesPerSecond x 8 x LineLength HDPI_ADJ x PP CM 48MHz 1 = --------------------------- x Tint x --------- 8 x LineLength CM 48MHz (Tint * 1000) = ----------------------- x -------------------- 1000 x 8 x LineLength CM Ideal Scan Speed (inches/second) 1 1 1 ScanSpeed = ----------- x -------- x -------- PixelPeriod FSPI x 4 StepSize 48MHz 1 1 ScanSpeed = ----------------- x -------- x -------- MCLK_DIV x 8 x CM FSPI x 4 StepSize 48MHz MCLK_DIV = ------------------------------------------ ScanSpeed x 8 x CM x FSPI x 4 x StepSize ---------------- Symbols: CM - Color Mode (unitless), 3 for channel pixel rate color, else 1 ------------------------- sane-backends-1.0.29/doc/plustek/Plustek-USB.changes0000666000000000000000000002037713615534521017056 00000000000000Plustek.changes - Gerhard Jaeger ===================================================== Note: All other not mentioned builds have never been released. V 0.52-11 (2013-02-13) --------------------- Added support for Q-Scan A6 scanner (see report #312073) V 0.52-10 (2012-03-19) --------------------- Fixed batch scanning V 0.52-9 (2009-04-27) --------------------- Tweaked highspeed settings for Epson 1260 V 0.52-8 (2008-08-25) --------------------- Added preliminary support for Visioneer XP100 Tweaked entry for LM9831 version of Plustek UT12 V 0.52-7 (2007-12-13) --------------------- Fixed alignment issues for archs like XScale/ARM Fixed dumppic function to get valid grayscale pictures V 0.52-6 (2007-11-23) --------------------- Tweaked TravelScan464 settings. Improved AFE gain calculation for CIS devices. This should avoid stripes in the scanned images. V 0.52-4 (2007-11-16) --------------------- Tweaked TravelScan464 settings Added possibility to disable dark-calibration with lamp on (touches devices like CanoScan1220 etc) Use attribute packed for data access structs V 0.52-4 (2007-11-07) --------------------- Added support for Syscan TravelScan464 V 0.52-3 (2007-07-26) --------------------- Checked UMAX3400/3450 models Force output bit set (MIO), when lamp is switched V 0.52-2 (2007-07-10) --------------------- Added flag to allow only 1- and 8-bit scanmodes. The Q-Scan does not seem to support 14-bit modes. V 0.52-1 (2007-06-29) --------------------- Added sheetfed device Q-Scan USB001 from Portable Peripherals Fixed Mustek Bearpaw and did some speedup (bugreports #304343 and #301763) Fixed calibration for senororders other that RGB V 0.51-16 (2007-03-05) ---------------------- Added CanoScan to all Canon device strings. Identified one more Plustek device as U24. Fixed button handling for Plustek/KYE devices and added some more debug messages. V 0.51-15 (2006-11-22) ---------------------- Fixed option descriptors (bugreport #303786) V 0.51-14 (2006-08-11) ---------------------- Lowered speed for LiDE20/30 models in low resolution mode (<75dpi) V 0.51-13 (2006-08-09) ---------------------- Changed sane.type to "flatbed scanner" only Fixed motorsettings for LiDE30 (bugreport #303722) Fixed LiDE20 settings. Got some reports of non-working devs, although my N670U is working fine. Lowered the max speeds and increased the MCLK-div for fast movement. (bugreport #303695) V 0.51-12 (2006-06-30) ---------------------- Fixed bit-depth selection V 0.51-11 (2006-06-08) ---------------------- Fixed calibration: All modes will be coarse calibrated now, fine calibration will be done only for 8 bit modes. Fixed paper eject during startup. V 0.51-10 (2006-05-28) --------------------- Released V 0.51-8 (2006-04-09) --------------------- Added cache for fine calibration (CIS devices only) Added support for sheet-fed scanner (CIS devices only) Added support for Syscan TravelScan662 V 0.50-10 (2006-01-31) --------------------- Fixed CanoScan N1220U settings. V 0.50-9 (2006-01-19) --------------------- Added high-speed setting for HP2200. Fixed constraint_type for OPT_BUTTON. V 0.50-8 (2006-01-18) --------------------- Fixed CanoScan N670U settings (bugreport #302433). V 0.50-7 (2005-10-28) --------------------- Changed high-speed setting for UMAX 3400, due to bugreport #302317. Added disable speeup feature (as option). Fixed CanoScan N650U settings (bugreport #302433). V 0.50-6 (2005-10-25) --------------------- Fixed segfault in fine calibration for CIS devices. Tweaked LiDE25 settings (thanks to Gerd Cendelin for lending me his LiDE25). Let 1200DPI CIS devices use now the green-channel for gray scans. V 0.50-5 (2005-10-21) --------------------- Fixed high-speed feature of CanoScan D660U. V 0.50-4 (2005-10-02) --------------------- Updated motor settings for Canoscan LiDE25, thanks to Stephan February for providing these values. V 0.50-3 (2005-08-22) --------------------- Fixed problem, when trying to scan at resolutions beyond the optical one (sensor stops too early) V 0.50-2 (2005-08-19) --------------------- More cleanup. Removed obsolete _WAF_BLACKFINE. LiDE20 does not seem to have a reliable black calibration area, so the devices now will switch off the lamp for dark calibration. Fixed line statistics and added calibration data output. V 0.50-1 (2005-08-15) --------------------- Cleanup Activated IPC between reader-process and parent Added button support for Plustek/Genius devices Did some whitespace cleanup and removed those *p typedefs Tried to improve CIS calibration (somewhat back to 1.0.13) Added _TWEAK_GAIN definition to allow CIS calibration increase gain values during basic lamp setup phase Added call to speedtest to CIS calibration Fixed CanoScan startup problem (the way misc I/Os will be set after power-up has done the trick) V 0.49-8 (2005-08-08) --------------------- Added LiDE25 settings V 0.49-7 (2005-07-21) --------------------- Bugfix release - fixed lampsettings for CIS calibration V 0.49-6 (2005-07-07) --------------------- Bugfix release - calibration and segfault :( V 0.49-5 (2005-07-04) --------------------- Added IPC between reader-process and parent process to be pepared for sharing calibration info. Added button support for backend V 0.49-4 (2005-06-27) --------------------- Fixed "double free" problem during sane_exit. V 0.49-3 (2005-04-18) --------------------- Fixed backtracking problem, when sensor-speedup is active. V 0.49-2 (2005-01-12) --------------------- Tweaked some device settings Updated copyright info Using now PhyDpi.y as selector for the motor MCLK range V 0.49-1 (2004-11-19) --------------------- Improved multi-device capability V 0.48-10 (2004-10-30) ---------------------- - Fixed a bug in buffer calculation for CIS devices V 0.48-9 (2004-10-19) --------------------- - Use the same option names for RGB gain as umax_pp backend V 0.48-8 (2004-10-06) --------------------- - split scanmodes & bit-depths V 0.48-7 (2004-10-04) --------------------- - changed some strings according to bug #300963 V 0.48-6 (2004-09-07) --------------------- - fixed UMAX lamp-off bug V 0.48-4 (2004-07-26) --------------------- - added speedup parameters for UMAX3400/3450 - added disableSpeedup option - added UMAX3400/3450 TPA autodetection V 0.48-3 (2004-07-16) --------------------- - improved autowarmup feature - improved speedup feature V 0.48-2 (2004-07-07) --------------------- - fixed binary mode for CanoScan D660U V 0.48-1 (2004-07-02) --------------------- - added more options to the frontend interface - added UMAX 3400 with product ID 0x0050 - added support for the UMAX 3450 - added autowarmup for CFL (most CCD-scanner) - added speedup for sensor for some devices - fixed lamp switching problem for D660U - fixed negative scanning lamp problem - fixed Gray 16 mode for CanoScan D660U - code cleanup V 0.47-11 (2004-04-21) ---------------------- - minor fixes, esp. for MacOSX - added lamp-off and warmup options to be configurable by backends V 0.47-8 - 0.47-10 ------------------ - never released V 0.47-7 (2004-02-08) --------------------- - fixed bypass calibration function for CIS devices - added lampoff stuff to config file V 0.47-6 (2004-01-21) --------------------- - Cleanup work - Changed lamp off timer for non-setitimer systems V 0.47-5 (2004-01-09) --------------------- - Added big-endian code to support also PPC architectures - Added mov (model override) to support various devices using the same product ID (namely Mustek BearPaw 1200) - Added per-model gamma values - Fixed a bug in the coarse CIS-lamp calibration - Cleanup work V 0.47-1 - 0.47-4 ----------------- - never released V 0.46-9 (2003-11-03) --------------------- - Added alternate calibration for CIS devices - Added coarse calibration data-cache - Moved parallelport code to extra backend file plustek_pp - Fixed some minor bugs - Fixed problem with CIS devices using FreeBSD V 0.46-1 - 0.46-8 ----------------- - never released V 0.45 (2003-08-05) ------------------- - Starting this changelog - Updates since V 0.44: * better CIS device support * added CanoScan N1220U, N1240U * made CanoScan N650U and N670U work * fixed EPSON 1260 motor killer-bug * improved TPA scanning * fixed TPA warmup bug on EPSON 1260/Photo * fixed Genius device detection problem * Added Compaq S4-100 (identical to UMAX3400) sane-backends-1.0.29/doc/plustek/Makefile.kernel240000666000000000000000000001430313615534521016523 00000000000000# Makefile for the plustek scanner driver (kernel-module) # ############################################################################### # # define the directories # HOME_DIR := . SRC_DIR := $(HOME_DIR) INC_DIR := $(SRC_DIR) OBJ_DIR := $(HOME_DIR)/obj DOC_DIR := $(HOME_DIR)/doc BACKEND := $(SRC_DIR) # # define the used tools # MD = mkdir -p CC = gcc TAR = tar REF = cxref # # Comment/uncomment the following line to disable/enable debugging # can also be set by commandline parameter: make all DEBUG=y # #DEBUG = y # # common compiler options # OPT = -fomit-frame-pointer -D_PTDRV_VERSTR=\"$(VERSIONSTR)\" # # cxref options # REFOPT = -xref-all -index-all -html32 # # Comment out if you are not running SMP. Someone take this out of here # when the SMP stuff gets moved out of the kernel Makefile. # SMP = 1 # SMP_PROF = 1 # # add the following to get assembly listing # -Wa,-alh,-L -g # # get some version numbers # ifeq ($(LINUXVERSION),) LINUXVERSION = $(shell uname -r) endif VERSIONSTR = $(shell grep "define BACKEND_VERSION" $(SRC_DIR)/plustek_pp.c | cut -b25-50 ) # Change it here or specify it on the "make" commandline ifeq ($(HEADER_PATH),) MACHTYPE = $(shell env | grep debian-linux | wc -l | sed 's/ //g') ifeq ($(MACHTYPE),1) # debian HEADER_PATH = /usr/src/kernel-headers-$(LINUXVERSION)/include else # redhat, slackware HEADER_PATH = /usr/src/linux/include endif # HEADER_PATH = /usr/include endif ifeq ($(DEBUG),y) DEBFLAGS = -O -g -DDEBUG # "-O" is needed to expand inlines else DEBFLAGS = -O2 endif # # the new style reference # K24_HEADER_PATH = /lib/modules/$(LINUXVERSION)/build/include # # try to autodetect if we can use the new style header include references # KERNEL_HEADERS = $(shell if test -d $(K24_HEADER_PATH); then \ echo $(K24_HEADER_PATH); \ else \ echo $(HEADER_PATH); \ fi; ) # # seems to be necessary for kernels 2.4.x # MODVERFILE = $(shell if [ -e $(KERNEL_HEADERS)/linux/modversions.h ]; then \ echo $(KERNEL_HEADERS)/linux/modversions.h ; \ else \ echo $(KERNEL_HEADERS)/linux/modsetver.h ; \ fi ) MODFLAGS = -DMODULE # # set MODVERSIONS if the kernel uses it # VERSUSED = $(shell grep 'define CONFIG_MODVERSIONS' \ $(KERNEL_HEADERS)/linux/autoconf.h | wc -l | sed 's/ //g') ifeq ($(VERSUSED),1) MODFLAGS += -DMODVERSIONS -include $(MODVERFILE) endif WARNFLAGS = -Wall -Wstrict-prototypes CFLAGS = $(WARNFLAGS) $(OPT) -D__KERNEL__ -I$(KERNEL_HEADERS) -I$(INC_DIR) -I$(BACKEND) $(DEBFLAGS) $(MODFLAGS) MODLIB = /lib/modules/$(LINUXVERSION) ifdef SMP CFLAGS += -D__SMP__ ifdef SMP_PROF CFLAGS += -D__SMP_PROF__ endif endif TARGET = pt_drv OBJ = $(TARGET).o NAMES := dac detect genericio image map misc models io procfs NAMES := $(NAMES) motor p9636 ptdrv scale tpa p48xx p12 p12ccd NAMES := $(addprefix plustek-pp_, $(NAMES)) SRCS := $(addprefix $(SRC_DIR)/, $(NAMES)) SRCS := $(addsuffix .c, $(SRCS)) OBJS := $(addprefix $(OBJ_DIR)/, $(NAMES)) OBJS := $(addsuffix .o, $(OBJS)) INCS := scan dbg types scandata procs hwdefs sysdep INCS := $(addsuffix .h, $(INCS)) HDRS = $(addprefix $(INC_DIR)/plustek-pp_, $(INCS)) # # the header files we need from the backend # BACKINCS := plustek-pp.h BACKINCS := $(addprefix $(BACKEND)/, $(BACKINCS)) group = "root" mode = "644" INST_DIR = /lib/modules/$(LINUXVERSION)/kernel/drivers/char info: @clear @echo "Makefile to create the Plustek-Scanner kernel-module:" @echo "all ... builds the module" @echo "all DEBUG=y ... builds the module with debug-messages enabled" @echo "clean ... cleans up the show" @echo "install ... installs the module to the library path" @echo "uninstall ... removes the module from the library path" @echo "load ... tries to load the module and creates device nodes" @echo "unload ... unloads the module" all: .depend chkdir $(OBJ) # # create object directory # .PHONY : chkdir chkdir: @-$(MD) $(OBJ_DIR) @-$(MD) $(DOC_DIR) $(OBJ): $(OBJS) $(LD) -r $^ -o $@ $(OBJS): Makefile $(HDRS) $(BACKINCS) $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c $(CC) $(CFLAGS) -c $< -o $@ $(OBJ_DIR)/$(OBJ): VERSION1 VERSION0 # # copy the driver to the modules directory # install: mkdir -p $(INST_DIR) install -c -m $(mode) $(OBJ) $(INST_DIR) /sbin/depmod -a # # remove it # uninstall: rm -f $(INST_DIR)/$(OBJ) # # use modprobe to load the driver, remember to set the # parameter in /etc/modules.conf (see sane-plustek_pp.man for more details) # load: $(INST_DIR)/$(OBJ) # invoke modprobe with all arguments we got /sbin/modprobe $(TARGET) || exit 1 # Remove stale nodes and replace them, then give gid and perms rm -f /dev/$(TARGET)* # when using the devfs support, we check the /dev/scanner entries # and only create links to the devfs nodes # at least we create one link @if [ -e /dev/scanner/$(TARGET)* ]; then \ ln -s /dev/scanner/$(TARGET)0 /dev/$(TARGET); \ for name in `ls /dev/scanner | grep $(TARGET)`; do \ ln -s /dev/scanner/$$name /dev/$$name ; \ done \ else \ mknod /dev/$(TARGET) c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0; \ mknod /dev/$(TARGET)0 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0; \ mknod /dev/$(TARGET)1 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 1; \ mknod /dev/$(TARGET)2 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 2; \ mknod /dev/$(TARGET)3 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 3; \ \ chgrp $(group) /dev/$(TARGET)*; \ chmod $(mode) /dev/$(TARGET)*; \ fi # # unload the driver # unload: /sbin/modprobe -r $(TARGET) || exit 1 # Remove stale nodes rm -f /dev/$(TARGET)* # # create reference docu # doc: chkdir $(REF) $(REFOPT) $(INC_DIR)/*.h $(SRC_DIR)/*.c $(BACKEND)/plustek-share.h \ -D__KERNEL__ -I$(KERNEL_HEADERS) -I$(INC_DIR) -I$(BACKEND) $(MODFLAGS) \ -D_PTDRV_V1=$(VERSION1) -D_PTDRV_V0=$(VERSION0) -D_PTDRV_BUILD=$(BUILD) -O$(DOC_DIR) clean: @-rm -f $(OBJ_DIR)/*.o .depend depend dep $(REF).* *.html $(TARGET).o @-rm -rf $(OBJ_DIR) @-rm -rf $(DOC_DIR) depend .depend dep: $(CC) $(CFLAGS) -M $(SRCS) > $@ ifeq (.depend,$(wildcard .depend)) #include .depend endif sane-backends-1.0.29/doc/plustek/Plustek-USB-TODO.txt0000666000000000000000000000520413615534521017020 00000000000000Plustek-USB-TODO.txt (2007-12-13) Gerhard Jaeger ===================================================================== TODO (in general): - more documentation/comments for the different functions - replace mclk_fast stuff and use instead values from 75DPI grayscale KNOWN BUGS/Limitations: Model Description Workaround ------------------------------------------------------------------------------ HP 2100c Straight Line Bug none Bearpaw1200 works only once restart backend each time All with TPA Negative Scanning quality bad none CIS devices Skip calibration does not work none ********************************* DONE *************************************** all add plustek.conf presettings to done interface for frontends all Auto-warmup done all Sensor movement speedup ffw/rev done Canon fine calibration does not work fixed Canon 650 color modes >=600 dpi too dark fixed Canon 660 add support done Canon 1220 image quality not very good fixed Canon 1240 gray mode too bright fixed HP 2100c hits against scan-bed fixed Genius Devices not recognized fixed EPSON Photo Permanently warmup on TPA scanning fixed EPSON Photo Transparency mode does not work fixed correctly all binary mode does not work correctly done Canon 16bit gray mode does not work done EPSON 1250/60 Motor control settings are wrong fixed CanoScan 1240 added EPSON + HP vertical line bug fixed HP blooming on 42bit >=400dpi fixed UMAX5400 bad picture quality fixed UMAX3400 Straight Line Bug fixed all problems on ARM and XScale fixed Make the color modes > 8bit work correctly done make mono/gray modes work on Canon scanners done copy picture line by line to backend done cancel function does not work correctly in large resolutions fixed Move documents to its correct SANE place done sane-backends-1.0.29/doc/plustek/FAQ0000666000000000000000000003135113615534521013772 00000000000000Plustek-Driver TROUBLESHOOTING/FAQ - 19.04.2001 ----------------------------------------------- The driver exists now since March 2000, this is the first trial to setup a FAQ. This leads into the following: First we have a part, which is more a troubleshooting section and the second one is the FAQ. To search through this text, search for "SYMPTOM" or "Q:". If you have some more FAQ entries, let me know THANKS to Jochen , who roamed through the mailing-list and gathered the different questions. ******************************************************************************* * TROUBLE-SHOOTING * * * * DRIVER TOPICS * ******************************************************************************* SYMPTOM: "kernel-module version mismatch" -------- "When I try to "make load" I get an error" /sbin/modprobe pt_drv || exit 1 /lib/modules/2.2.14-6.0.6/misc/pt_drv.o: kernel-module version mismatch /lib/modules/2.2.14-6.0.1/misc/pt_drv.o was compiled for kernel version 2.2.14-5.0 while this kernel is version 2.2.14-6.0.1. PROBLEM: -------- You're using the wrong Kernel-header files. The path /usr/include/linux is a link to /usr/src/linux/include/linux and /usr/src/linux is normally a link to your current kernel, i.e: /usr/src/linux-2.2.14 If you now upgrade your kernel and you have forgotten to correct the link /usr/src/linux, then every kernel-module you build outside the kernelsource structure will include the wrong version information. SOLUTION: --------- Set the link /usr/src/linux to your current kernel-source tree before recompiling kernel-modules like pt_drv, then your version mismatch problem should be solved. SYMPTOM: "Device or resource busy" -------- Any attempt to "modprobe" or "make load" the driver leads to this message. PROBLEM: -------- The driver refuses to load. During startup, the driver performs some tests according to the parallel port and the connected scanners. If the parallel port is not supported or the scanner cannot be found, the driver returns an error and the system will report "device or resource busy" SOLUTION: --------- There's no way to provide a general solution. First of all you should check your connections and the parallel port. Also check power for your scanner. If the problem still exists, enable the debug-messages of the pt_drv module (see INSTALL). Then check the messages after loading or send the output to the mailing list. Most of these problems are related to HW-problems. Before giving up, check the scanner under Windows (not really a good advice I know, but it helps to find HW-damage). There was also one case were the internal plugs of the parport connection were wrong... SYMPTOM: "Unresolved symbols" -------- "make load" or "modprobe pt_drv" produces this message: /sbin/modprobe pt_drv || exit 1 /lib/modules/2.2.14-5.0/misc/pt_drv.o: unresolved symbol parport_unregister_device /lib/modules/2.2.14-5.0/misc/pt_drv.o: unresolved symbol parport_enumerate /lib/modules/2.2.14-5.0/misc/pt_drv.o: unresolved symbol parport_register_device /lib/modules/2.2.14-5.0/misc/pt_drv.o: unresolved symbol parport_claim /lib/modules/2.2.14-5.0/misc/pt_drv.o: unresolved symbol parport_release /lib/modules/2.2.14-5.0/misc/pt_drv.o: insmod /lib/modules/2.2.14-5.0/misc/pt_drv.o failed PROBLEM: -------- The driver needs at least the parport_pc and the parport modules to work. They MUST be loaded prior to pt_drv. If these modules are not loaded you get this message. SOLUTION: --------- Simply load the parport module. You can add this dependency to your /etc/modules.conf (or /etc/conf.modules) file (see INSTALL). Then everytime you load pt_drv with modprobe, parport will be loaded automatically. After modifying this file, call depmod -va SYMPTOM: Scanner makes awful noise -------- PROBLEM: -------- This can have two major causes: - You have an ASIC96001/3 based scanner, then the sensor hits the scanbed: !!! TURN OFF SCANNER POWER !!! - You have an ASIC98001 based scanner, then the motor control does not work correctly --> hit the cancel button SOLUTION: --------- For the first case (ASIC 96001/3), there's no solution available. This happens, when the driver can't keep track of the stepper motor. The image you get is normally unusable. The second case is often reported when the printer driver lp.o is already loaded. So remove lp.o before loading pt_drv. SYMPTOM: Printer starts to print while scanning -------- PROBLEM: -------- It has been reported, that some printers (esp. HP printers) start to print, even during startup of the driver. This is a problem to printers which use a bidirectional protocol for talking with the system. SOLUTION: --------- There is no possibility to handle this problem inside the driver. One possibility is to switch off the bidirectional communication of the printer. The other one is to connect the printer to another parallel port. ******************************************************************************* * SANE-topics * ******************************************************************************* Here you will not find how to setup xscanimage to work with GIMP or how to compile sane to obtain xscanimage, for such questions, please refer to the mailing lists at SANE (http://www.sane-project.org) SYMPTOM: error in loading shared libraries: libsane.so.1: cannot open -------- shared object file: No such file or directory PROBLEM: -------- The shared libraries for SANE have been installed to a directory which is not in your "library path" SOLUTION: --------- SANE installs its shared libraries to PREFIX/lib/sane. PREFIX is in general /usr or /usr/local. You should either add the path to your /etc/ld.so.conf file or set links to the libraries from a wellknown lib-path. (i.e. ln -s /usr/lib/sane/libsane.so.1 /usr/lib/libsane.so.1) In any case you should run "ldconfig -v" SYMPTOM: "no SANE devices found" -------- While testing with "scanimage -L" nothing happens. And when starting scanimage this message is displayed. PROBLEM: -------- The frontend cannot find any sane-device, this might have several causes: - the driver is not loaded - you have no access to the driver - the backend is not enabled - the driver is not specified - version conflict between the loaded driver and the backend SOLUTION: --------- Driver not loaded: check "cat /proc/pt_drv" if this does not exist, load the driver (see INSTALL) No access to the driver: check "ls -l /dev/pt_drv*" and you should get crw-rw-r-- 1 root root 40, 0 Aug 29 15:18 /dev/pt_drv crw-rw-r-- 1 root root 40, 0 Aug 29 15:18 /dev/pt_drv0 crw-rw-r-- 1 root root 40, 1 Aug 29 15:18 /dev/pt_drv1 crw-rw-r-- 1 root root 40, 2 Aug 29 15:18 /dev/pt_drv2 crw-rw-r-- 1 root root 40, 3 Aug 29 15:18 /dev/pt_drv3 If not, call "make load" in the driver source directory. This call sometimes fails, so you might create the entries by using mknod: mknod -m 0664 /dev/pt_drv c 40 0 mknod -m 0664 /dev/pt_drv0 c 40 0 mknod -m 0664 /dev/pt_drv1 c 40 1 mknod -m 0664 /dev/pt_drv2 c 40 2 mknod -m 0664 /dev/pt_drv3 c 40 3 The backend is not enabled: Check the SANE configuration in /etc/sane.d, /usr/etc/sane.d or /usr/local/etc/sane.d (depending on your installation). Your dll.conf MUST include an enabled "plustek" entry (no "#" in front of that line) The driver is not specified: Check the sane configuration (see above) for the file plustek.conf and make sure that it contains at least /dev/pt_drv as entry. Version conflict: After enabling the SANE debug messages you will get something like upon starting scanimage: ioctl PT_DRV_OPEN_DEVICE failed(-9019) Version problem, please recompile driver! In this case, you MUST recompile the backend AND the driver and reinstall both. This feature makes sure, that both always will use the same ioctl interface. PROBLEM: -------- I have SANE-1.0.4 and there's no backend-directory after unpacking, so what to do? SOLUTION: --------- You're wrong there is a backend directory!!! Since SANE-1.0.4, there are two packages: sane-backends sane-frontends For the installation, you need the backend tarball. This should give you something like: sane-1.0.4/sane-backends and there below sane-backends is the backend directory. So you have to unpack the plustek-sane...tgz in sane-backends. ******************************************************************************* * F A Q * ******************************************************************************* Q: What does "Turbo" mean ? A: Turbo does not mean, that the scanner is faster ;-) There are currently three OpticPro9636P Scanners. OP9636P OP9636P+ OP9636PTurbo The + and the Turbo models are quite the same and the difference between the Turbo and the non-Turbo is the scan-sensor. The Turbo uses the same like the newer OP9636T/12000T and the non-Turbo uses the older ones from the OP9630.... Q: Is it possible to use the front-button of my Plustek 9630P ? A: It is possible since version 0.37. After loading the driver, use the proc filesystem to get the button value: cat /proc/pt_drv/device0/button0 Q: Is it possible to use the scanner in gimp ? A: You should be able to use xscanimage with gimp: 1. Login as root 2. Go into the gimp plug-in directory (on SuSE it is: /usr/lib/gimp/1.1/plug-ins/ ) 3. Find xscanimage : which xscanimage 4. Create a symbolic link to xscanimage : ln -s "/path/to/"xscanimage xscanimage 5. logout as root Now call gimp, in the xtns menu you should find now the Acquire Image menu entry. That's all. If not, start gimp from an xterm and have a look at the output. Q: Is there any way to load the plustek_driver at bootup-time? A: Normally, there is no need to do so, because once you altered your /etc/conf.modules file (or /etc/modules.conf) and added the suggested stuff (see INSTALL file), you won't have to worry about loading the driver. It happens automagically. ;-) The driver will be loaded when needed (and eventually removed after a specific time of not using it). Nevertheless, another possibility is to do a modprobe pt_drv in the /etc/rc.d/boot.local (using SuSE) or /etc/rc.d/rc.local (using RedHat or Mandrake) file So the driver will be loaded at bootup-time... !!! YOUR SCANNER MUST BE ONLINE during power-up then !!! Q: I wonder if Mandrake 7.1's sane rpm file has this support already built in. My scanner light is coming on yet Xscanimage seems to report that there is no scanner present. A: The backend code will be included in Version 1.0.3 of sane and AFAIK Mandrake 7.1 only includes 1.0.2. Anyway go to the plustek-driver download page at http://home.t-online.de/home/g-jaeger/plustek.html download and install the driver. Q: Mandrake installs sane by default at install-time. Is there a way to install the driver with the preinstalled sane or should the preinstalled sane be removed first? If so, how do I remove the preinstalled sane? A: I recommend to uninstall the previous one. I think Mandrake uses RPM for managing the packages. To remove sane do the following (as root) Ask for all installed packages and filter sane: rpm -qa | grep sane you should get something like this: sane-1.0.1-94 Now remove this package: rpm -e sane-1.0.1-94 After theses steps, sane should be removed. I'm not sure, but you might have to remove the /etc/sane.d manually... Now got to your sane-1.0.3 stuff and reinstall this as described. Before using, you might have a look at the dll.conf and enable only the plustek backend. Q: Now that there's a sane 1.0.3, how do i uninstall sane 1.0.2? Or can i install it over? A: In general you can install it over. BUT this has caused quite a lot of trouble, so I recommend to remove the 1.0.2 completely and install 1.0.3... try the rpm-tool: Get a list of the installed packages and filter out sane: rpm -qa | grep sane You should get something like: sane-1.0.2-48 Then use rpm to remove sane: rpm -e sane-1.0.2-48 The other way is: rm -rf /etc/sane.d rm -rf /usr/lib/sane rm -rf /usr/lib/libsane* rm -rf /usr/include/sane rm -rf /usr/etc/sane.d rm -rf /usr/share/sane* rm -rf /usr/local/lib/sane rm -rf /usr/local/lib/libsane* rm -rf /usr/local/include/sane rm -rf /usr/local/etc/sane.d rm -rf /usr/local/share/sane* This should cover all the directories where maybe some sane files are installed... sane-backends-1.0.29/doc/plustek/Plustek-PARPORT.changes0000666000000000000000000001460413615534521017550 00000000000000Version 0.1 10/20/98 1.0 Initial release Version 0.2 10/26/98 1.0 Fix Red/Green swap, optimize ppm output for black and white. Version 0.3 10/28/98 1.0 Merge code with SANE 2.0 Put GPL/SANE license info in all files Version 0.4 10/31/98 1.0 Have driver report ASIC ID up to backend. 2.0 Put NT stuff back in so that driver may be built under NT, try to test build under NT but run out of memory in link. Version 0.5 10/31/98 1.0 Fix parameters not getting reflected from crop. Version 0.6 11/1/98 1.0 Take out unused stuff from ioctl_pt_drv.h. 2.0 Put in VERSION info in Makefile and archiver. Version 0.7 11/4/98 1.0 Fix model string when -L option is given. Add in driver version string to model. 2.0 Change Makefile so it builds without MODVERSIONS on distributions that don't have it (Slackware). Version 0.8 11/5/98 1.0 Change output when -L option is given to add status byte to try to determine any differences between the 4830 and the 9630. Version 0.9 11/6/98 1.0 Fix 4800 problem of inverse image when not in Binary mode. 2.0 Put more debug stuff in, print out all read reg's. Version 0.10 11/6/98 1.0 Get halftone working. 2.0 Put in hooks for kernel 2.1 Version 0.11 11/17/98 1.0 Put in sysdep-2.1.h to Makefile distrib Version 0.20 3/7/99 1.0 Lots of changes to support 9630/12000. ------------------------------------------------------------------------------- Version 0.3 02/29/2000 1.0 Completely rewritten, does now support Plustek OpticPro 9636T scanner Version 0.31 03/20/2000 1.0 Fix a bug in the autodetection routine 2.0 Enhanced backend, to reflect the different modes the OpticPro 9636T supports Version 0.32 - never released 1.0 Corrected warmup-behaviour 2.0 Fixed "first picture corrupted"-bug for transparency mode 3.0 Fixed a bug that causes seg-faults when using cat /dev/pt_drv 4.0 Added SCALE.C 5.0 Made 4830P work Version 0.33 - never released 1.0 Now using parport-module info for par-mode detection 2.0 Made 9630P work Version 0.34 05/10/2000 1.0 Data-recovery code for heavy load systems Version 0.35 05/19/2000 1.0 Made 12000P/96000P work 2.0 Merged parallel port code from Kevin Sisson 3.0 Added new parameter "legal" Version 0.36 07/22/2000 1.0 Improved data-recovery mechanism for ASIC96001/3 based models 2.0 Added code for OP4800 shading 3.0 Improved backend code to allow canceling the scan process 4.0 OP600 and Primax 4800 Direct are working now 5.0 Added new parameter "mov" (Model OVerride) 6.0 Removed parameter "legal", use now "mov" 7.0 Moved common headers for backend and driver to backend directory and prepared the backend for SANE distribution 8.0 OP6000 is working 9.0 added man-page 10.0 added multi-device support 11.0 added support for 12-bit scans (SANE-1.0.3 and scanimage!!) Version 0.37 11/09/2000 1.0 Added file io.c for parallel port I/O 2.0 Added file procfs.c for proc-filesystem support 3.0 Code cleanup 4.0 Added A3I support 5.0 Added Michaels backend patches Version 0.38 11/30/2000 1.0 Started integration of ASIC98003 specific stuff 2.0 renamed file transform.c tpa.c 3.0 removed portmode stuff (I decided to support SPP/BPP and EPP, that's all) 4.0 again code-cleanup 5.0 PT12 is working 6.0 Removed gray-mode scanning for TPA modes 7.0 some minor changes according to kernel 2.4.x Version 0.39 08/11/2001 1.0 Added slowIO switch 2.0 Fixed some minor bugs 3.0 Added forceMode switch 4.0 Fixed a problem in the PT12 code that causes I/O timeouts 5.0 Added Genius Colorpage Vivivd III V2 stuff 6.0 Added A3I stuff aquired from Plustek 7.0 Fixed a bug, that causes some seg-faults Version 0.40 12/17/2001 1.0 The USB stuff has been included 2.0 Fixed some minor problems 3.0 Added Kernel 2.4.17 specific stuff 4.0 Disabled A3I stuff as this refuses ASIC96003 based devices to work Version 0.41 01/10/2002 1.0 Changed IOCTL interface to the kernel module to allow adjustment of some driver internal variables 2.0 Changed plustek.conf configuration fileformat to reflect the enhanced capabilites Version 0.42 02/12/2002 1.0 Added custom gamma table support 2.0 Added configuration-file options to preset some stuff 3.0 Changed all eMail entries to gerhard@gjaeger.de Version 0.42-11 09/17/2003 1.0 Some Kernel 2.6.x additions 2.0 Added Primax 4800Direct 30Bit override switch Somewhere on the way to 0.43 I decided to split parport & usb backends, so the parport backend now is also able to run complete in userspace by using either direct port I/O or libieee1248 Version 0.43-2 04/15/2004 1.0 Fixed some kernel 2.6 issues Version 0.43-3 07/14/2004 1.0 User-space code has now the same version as the module code Version 0.43-4 07/15/2004 1.0 DevFS support for kernel 2.6 2.0 Removed floating point operations (Thanx to Rafal Rzepecki) 3.0 More cleanup work 4.0 bumped up build number Version 0.43-5 10/06/2004 1.0 Change some scanmode definitions to match the SANE predefined ones Version 0.43-6 04/25/2005 1.0 Removed inline stuff from kernel module code, as GCC3.4 will make some trouble Version 0.43-7 05/11/2005 1.0 Fixed timer issues in user-space (Thanx to Rod Roark) Version 0.43-8 08/10/2005 1.0 Fixed problem on ASIC96003/1 based devices, when scanning lineart at 200 and 300 dpi Version 0.43-9 11/14/2005 1.0 Fixed sizeof(long) issue for 64bit platforms, see bug #302195 Version 0.43-10 02/16/2006 1.0 Fixed bug, that prevents backend from working, when the device is connected to parport1 or higher, parport0 works. Bug spotted by Christoph Steinbruchel. Version 0.43-11 08/09/2006 1.0 Changed sane.type to "flatbed scanner" only Version 0.43-12 08/29/2006 1.0 Fixed "not homing" problem, the sensor did not return when the driver gets the _IOCTL_STOP command 2.0 Fixed compilation issue for kernels > 2.6.15 3.0 Fixed compiler warning conditions Version 0.43-13 06/18/2007 1.0 Removed DEVFS stuff for Kernels > 2.6.15 2.0 Added class stuff Version 0.44-1 02/13/2013 1.0 Fixed issues for Kernels > 2.6.35 2.0 Define ULong and friends to uint32_t to make the driver work in a 64 bit environment sane-backends-1.0.29/doc/plustek/Makefile.kernel260000666000000000000000000000562213615534521016531 00000000000000# Makefile for the plustek scanner driver (kernel-module) # ############################################################################### # # retrieve the version numbers # ifeq ($(LINUXVERSION),) LINUXVERSION = $(shell uname -r) endif LINUXRELEASE = $(shell uname -r | cut -d'.' -f3) ifeq ($(VERSIONSTR),) ifeq ($(SUBDIRS),) VERSIONSTR = $(shell grep "define BACKEND_VERSION" $(M)/plustek_pp.c | cut -b25-50 ) else VERSIONSTR = $(shell grep "define BACKEND_VERSION" $(SUBDIRS)/plustek_pp.c | cut -b25-50 ) endif endif # # extra flags # EXTRA_CFLAGS += -D_PTDRV_VERSTR=\"$(VERSIONSTR)\" ifeq ($(DEBUG),y) EXTRA_CFLAGS += -DDEBUG endif # # the module name # TARGET := pt_drv MODULE := $(TARGET).ko # # our files... # NAMES := dac detect genericio image map misc models io procfs NAMES := $(NAMES) motor p9636 ptdrv scale tpa p48xx p12 p12ccd NAMES := $(addprefix plustek-pp_, $(NAMES)) OBJS := $(addsuffix .o, $(NAMES)) # # now the kernel magic # ifneq ($(KERNELRELEASE),) obj-m := $(TARGET).o $(TARGET)-objs := $(OBJS) else KDIR := /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) default: $(MAKE) -C $(KDIR) M=$(PWD) modules endif # # the installation stuff # group = "root" mode = "644" INST_DIR = /lib/modules/$(LINUXVERSION)/kernel/drivers/parport # # copy the driver to the modules directory # install: mkdir -p $(INST_DIR) install -c -m $(mode) $(MODULE) $(INST_DIR) /sbin/depmod -a # # # uninstall: rm -f $(INST_DIR)/$(MODULE) # # use modprobe to load the driver, remember to set the # parameter in /etc/conf.modules (see INSTALL for more details) # load: $(INST_DIR)/$(MODULE) # invoke modprobe with all arguments we got /sbin/modprobe $(TARGET) || exit 1 # Remove stale nodes and replace them, then give gid and perms rm -f /dev/$(TARGET)* # when using the devfs support, we check the /dev/scanner entries # and only create links to the devfs nodes # at least we create one link @if [ -e /dev/scanner/$(TARGET)* ]; then \ ln -s /dev/scanner/$(TARGET)0 /dev/$(TARGET); \ for name in `ls /dev/scanner | grep $(TARGET)`; do \ ln -s /dev/scanner/$$name /dev/$$name ; \ done \ else \ mknod /dev/$(TARGET) c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0; \ mknod /dev/$(TARGET)0 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 0; \ mknod /dev/$(TARGET)1 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 1; \ mknod /dev/$(TARGET)2 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 2; \ mknod /dev/$(TARGET)3 c `cat /proc/devices | sed -ne "s/\([0-9]*\) pt_drv/\1/p"` 3; \ \ chgrp $(group) /dev/$(TARGET)*; \ chmod $(mode) /dev/$(TARGET)*; \ fi # # unload the driver # unload: /sbin/modprobe -r $(TARGET) || exit 1 # Remove stale nodes rm -f /dev/$(TARGET)* # # cleanup the show # clean: @-rm -f *.o .depend depend dep $(MODULE) $(TARGET).o $(TARGET).mod.c .*.cmd sane-backends-1.0.29/doc/plustek/Plustek-PARPORT.txt0000666000000000000000000000313613615534521016755 00000000000000Plustek-PARPRORT.txt (2004-03-28) Gerhard Jäger ==================================================================== Beginning with SANE-1.0.13, there's a backend called plustek_pp. This is for controlling Plustek parallel-port scanner and compatible devices. For a full listing, see plustek_pp.desc. This code formerly was available for creating the Linux kernelmodule pt_drv. This should no longer be necessary. You should be able to use the backend out of the box. The kernel module ----------------- As it might be helpful to create and use the kernel-module, this way still exists. It's possible to create this module out of the backend sources in sane-backends/backend. Simply do (as root user) ./MakeModule.sh Then the module should be compiled, installed and loaded. Add the following three lines to file /etc/modules.conf alias char-major-40 pt_drv pre-install pt_drv modprobe -k parport options pt_drv lampoff=180 warmup=15 port=0x378 lOffonEnd=0 mov=0 slowIO=1 See man page for sane-plustek_pp ("man sane-plustek_pp") for explanation of these options. Now "scanimage -L" should show something like this: device `plustek:/dev/pt_drv' is a Plustek 9630P flatbed scanner Known Problems: --------------- Sometimes it is necessary to change the ioctl-interface between the driver and the backend, in this case the version number of the communication protocol will be changed and newer drivers won't work with older backends and vice versa. In this case (error -9019 in the SANE debug output!!) you have to recompile SANE AND the driver (have a look at the installation procedure above). sane-backends-1.0.29/doc/plustek/Plustek-PARPORT-TODO.txt0000666000000000000000000000306613615534521017522 00000000000000Plustek-PARPORT-TODO.txt (2003-29-10) Gerhard Jäger ======================================================================== TODO (in general): - more documentation/comments on the different functions - remove/check the CHECK marks - add additional button handler - adding adjustment of the scan area - checking timeout conditions (MiscCheckTimer !) and handle them correctly - let the 96001/3 based models work with the highest available phys. resolution - Create the modes out of the capability list of each device (USER-MODE): - line by line feedback to the backend KNOWN BUGS/Limitations: Model Description Workaround ------------------------------------------------------------------------------ OpticPro P9636 detected as OP12000 none Genius VividPro II Film Halftone/Gray > 450 dpi didn't work none OpticPro P4830 binary scanning does not work none OpticPro A3I bad picture quality none Genius HR6 negative scanning not okay none ********************************* DONE *************************************** - PS/2 bidi does not work (libieee1284) - Update the IOCTL interface and remove some old structs (CmdBlk) ******************************** SKIPPED ************************************* better dither maps nobody needs halftone scanning make the backtrace work for ASIC 96001/3 not possible due to ASIC limits based models sane-backends-1.0.29/doc/sane-plustek.man0000666000000000000000000003230213615534521015056 00000000000000.TH sane\-plustek 5 "03 Nov 2017" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-plustek .SH NAME sane\-plustek \- SANE backend for LM983[1/2/3] based USB flatbed scanners .SH DESCRIPTION The .B sane\-plustek library implements a SANE (Scanner Access Now Easy) backend that provides access to USB flatbed scanners based on National Semiconductor Merlin chipsets (LM9831, 9832 and 9833). If you're looking for parallel-port support for Plustek scanner please refer to the .B sane\-plustek_pp backend. .SH "SUPPORTED DEVICES" The Backend is able to support USB scanner based on the National Semiconductor chipsets LM9831, LM9832 and LM9833. The following tables show various devices which are currently reported to work. If your Plustek scanner has another Product ID, then the device is .B NOT supported by this backend. .br Vendor Plustek \- ID: 0x07B3 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- OpticPro U12 LM9831 600x1200dpi 42bit 512Kb 0x0010 OpticPro UT12 LM9831 600x1200dpi 42bit 512Kb 0x0013 OpticPro UT12 LM9832 600x1200dpi 42bit 512Kb 0x0017 OpticPro UT16 LM9832 600x1200dpi 42bit 512Kb 0x0017 OpticPro U24 LM9831 1200x2400dpi 42bit 2Mb 0x0011 OpticPro U24 LM9832 1200x2400dpi 42bit 2Mb 0x0015 OpticPro UT24 LM9832 1200x2400dpi 42bit 2Mb 0x0017 .fi .ft R .PP Vendor KYE/Genius \- ID: 0x0458 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- Colorpage HR6 V2 LM9832 600x1200dpi 42bit 512Kb 0x2007 Colorpage HR6 V2 LM9832 600x1200dpi 42bit 512Kb 0x2008 Colorpage HR6A LM9832 600x1200dpi 42bit 512Kb 0x2009 Colorpage HR7 LM9832 600x1200dpi 42bit 512Kb 0x2013 Colorpage HR7LE LM9832 600x1200dpi 42bit 512Kb 0x2015 Colorpage HR6X LM9832 600x1200dpi 42bit 512Kb 0x2016 .fi .ft R .PP Vendor Hewlett-Packard \- ID: 0x03F0 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- ScanJet 2100C LM9831 600x1200dpi 42bit 512Kb 0x0505 ScanJet 2200C LM9832 600x1200dpi 42bit 512Kb 0x0605 .fi .ft R .PP Vendor Mustek \- ID: 0x0400 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- BearPaw 1200 LM9831 600x1200dpi 42bit 512Kb 0x1000 BearPaw 1200 LM9832 600x1200dpi 42bit 512Kb 0x1001* BearPaw 2400 LM9832 1200x2400dpi 42bit 2Mb 0x1001 .fi .ft R * see also description for model override switch below! .PP Vendor UMAX \- ID: 0x1606 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- UMAX 3400 LM9832 600x1200dpi 42bit 512Kb 0x0050 UMAX 3400/3450 LM9832 600x1200dpi 42bit 512Kb 0x0060 UMAX 5400 LM9832 1200x2400dpi 42bit 512Kb 0x0160 .fi .ft R .PP Vendor COMPAQ \- ID: 0x049F .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- S4-100 LM9832 600x1200dpi 42bit 512Kb 0x001A .fi .ft R .PP Vendor Epson \- ID: 0x04B8 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- Perfection 1250 LM9832 1200x2400dpi 42bit 512Kb 0x010F Perfection 1260 LM9832 1200x2400dpi 42bit 512Kb 0x011D .fi .ft R .PP Vendor CANON \- ID: 0x04A9 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- CanoScan N650/656U LM9832 600x1200dpi 42bit 512Kb 0x2206 CanoScan N1220U LM9832 1200x2400dpi 42bit 512Kb 0x2207 CanoScan D660U LM9832 600x1200dpi 42bit 512Kb 0x2208 CanoScan N670/676U LM9833 600x1200dpi 48bit 512Kb 0x220D CanoScan N1240U LM9833 1200x2400dpi 48bit 512Kb 0x220E CanoScan LIDE20 LM9833 600x1200dpi 48bit 512Kb 0x220D CanoScan LIDE25 LM9833 1200x2400dpi 48bit 512Kb 0x2220 CanoScan LIDE30 LM9833 1200x2400dpi 48bit 512Kb 0x220E .fi .ft R .PP Vendor Syscan \- ID: 0x0A82 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- Travelscan 662 LM9833 600x1200dpi 48bit 512Kb 0x6620 Travelscan 464 LM9833 600x1200dpi 48bit 512Kb 0x4600 .fi .ft R .PP Vendor Portable Peripheral Co., Ltd. \- ID: 0x0A53 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- Q-Scan USB001 LM9832 300x600dpi 42bit 512Kb 0x1000 Q-Scan USB201 LM9832 300x600dpi 42bit 512Kb 0x2000 .fi .ft R .PP Vendor Visioneer \- ID: 0x04A7 .br .ft CR .nf ---------------------------------------------------------- USB Model: ASIC: Properties: Prod-ID ---------------------------------------------------------- Strobe XP100 LM9833 600x1200dpi 48bit 512Kb 0x0427 .fi .ft R .PP .SH "OTHER PLUSTEK SCANNERS" For parallelport device support see the .B plustek_pp backend. .br The SCSI scanner OpticPro 19200S is a rebadged Artec AM12S scanner and is supported by the .B Artec backend. .br Only the National Semiconductor LM983[1/2/] based devices of Plustek are supported by this backend. Older versions of the U12, the UT12, the U1212 and U1248 (GrandTech chipset) are not supported. .PP .ft CR .nf Model Chipset backend ------------------------------------ U1248 GrandTech gt68xx UT16B GrandTech gt68xx OpticSlim 1200 GrandTech gt68xx OpticSlim 2400 GrandTech gt68xx U12 P98003 u12 UT12 P98003 u12 1212U P98003 u12 .fi .ft R For a more complete and up to date list see: .B http://www.sane\-project.org/sane\-supported\-devices.html .SH "CONFIGURATION" To use your scanner with this backend, you need at least two entries in the configuration file .I @CONFIGDIR@/plustek.conf .RS .I [usb] vendor-id product-id .br .I device /dev/usbscanner .RE .PP .I [usb] tells the backend, that the following devicename (here .IR /dev/usbscanner ) has to be interpreted as USB scanner device. If vendor- and product-id has not been specified, the backend tries to detect this by its own. If device is set to .I auto then the next matching device is used. .br The following options can be used for a default setup of your device. Most of them are also available through the frontend. .PP .B The Options: .PP option warmup t .RS .I t specifies the warmup period in seconds, if set to \-1, the automatic warmup function will be used .RE .PP option lampOff t .RS .I t is the time in seconds for switching off the lamps in standby mode .RE .PP option lOffonEnd b .RS .I b specifies the behaviour when closing the backend, 1 --> switch lamps off, 0 --> do not change lamp status .RE .PP option mov m .RS .I m is the model override switch. It works only with Mustek BearPaw devices. .br .br .ft CR .nf m/PID | 0x1000 | 0x1001 ------+--------------+-------------- 0 | BearPaw 1200 | BearPaw 2400 1 | no function | BearPaw 1200 .fi .ft R .RE .PP option invertNegatives b .RS .I b 0 --> do not invert the picture during negativ scans, .br 1 --> invert picture .RE .PP option cacheCalData b .RS .I b 0 --> do not save calibration results, .br 1 --> save results of calibration in ~/.sane/ directory .RE .PP option altCalibration b .RS .I b 0 --> use standard calibration routines, .br 1 --> use alternate calibration (only non Plustek devices, standard for CIS devices) .RE .PP option skipFine b .RS .I b 0 --> perform fine calibration, .br 1 --> skip fine calibration (only non Plustek devices) .RE .PP option skipFineWhite b .RS .I b 0 --> perform white fine calibration, .br 1 --> skip white fine calibration (only non Plustek devices) .RE .PP option skipDarkStrip b .RS .I b 0 --> perform dark calibration, with enabled lamp using the dark calibration strip of the scanner. If the scanner does not have such a strip, the alternative way is to switch off the lamp during this step. .br 1 --> always switch off the lamp for dark calibration, even a black strip is available .RE .PP option skipCalibration b .RS .I b 0 --> perform calibration, .br 1 --> skip calibration (only non Plustek devices) .RE .PP option enableTPA b .RS .I b 0 --> default behaviour, specified by the internal tables, .br 1 --> override internal tables and allow TPA mode (EPSON/UMAX only) .RE .PP option posOffX x .br option posOffY y .br option tpaOffX x .br option tpaOffY y .br option negOffX x .br option negOffY y .RS .I x y By using this settings, the user can adjust the given image positions. .B Please note, that there's no internal range checking for .B this feature. .RE .PP option posShadingY p .br option tpaShadingY p .br option negShadingY p .RS .I p overrides the internal shading position. The values are in steps. .B Please note, that there's no internal range checking for .B this feature. .RE .PP option redGamma r .br option greenGamma g .br option blueGamma b .br option grayGamma gr .RS .I r g b gr .RE By using these values, the internal linear gamma table (r,g,b,gr = 1.0) can be adjusted. .PP option red_gain r .br option red_offset ro .br option green_gain g .br option green_offset go .br option blue_gain b .br option blue_offset bo .RS .I r g b ro go bo These values can be used to set the gain and offset values of the AFE for each channel. The range is between 0 and 63. \-1 means autocalibration. .RE .PP See the plustek.conf file for examples. .PP .B Note: .br You have to make sure, that the USB subsystem is loaded correctly and you have access to the device-node. For more details see .B sane\-usb (5) manpage. You might use .B sane\-find\-scanner to check that you have access to your device. .PP .B Note: .br If there's no configuration file, the backend defaults to .B device auto .SH FILES .TP .I @CONFIGDIR@/plustek.conf The backend configuration file .TP .I @LIBDIR@/libsane\-plustek.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-plustek.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_PLUSTEK If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_PLUSTEK=10 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .BR sane\-u12 (5), .BR sane\-gt68xx (5), .br .I @DOCDIR@/plustek/Plustek-USB.changes .SH "CONTACT AND BUG-REPORTS" Please send any information and bug-reports to: .br .B SANE Mailing List .PP Additional info and hints can be obtained from our .br Mailing-List archive at: .br .B http://www.sane\-project.org/mailing\-lists.html .PP To obtain debug messages from the backend, please set the environment-variable .I SANE_DEBUG_PLUSTEK before calling your favorite scan-frontend (i.e. scanimage). .br .B i.e.: export SANE_DEBUG_PLUSTEK=20 ; scanimage .PP The value controls the verbosity of the backend. Please note, that values greater than 24 force the backend to output raw data files, which could be rather large. The ending of these files is ".raw". For problem reports it should be enough the set the verbosity to 13. .SH "KNOWN BUGS & RESTRICTIONS" .PP * The driver does not support these manic scalings up to 16 times the physical resolution. The only scaling is done on resolutions between the physical resolution of the CCD-/CIS-sensor and the stepper motor i.e. you have a 600x1200 dpi scanner and you are scanning using 800dpi, so scaling is necessary, because the sensor only delivers 600dpi but the motor is capable to perform 1200dpi steps. .PP * Plusteks' model policy is somewhat inconsistent. They sell technically different devices under the same product name. Therefore it is possible that some devices like the UT12 or U12 won't work \- please check the model list above and compare the product-id to the one your device has. .PP * Negative/Slide scanning quality is poor. sane-backends-1.0.29/doc/net.tex0000666000000000000000000004734113615534521013267 00000000000000\chapter{Network Protocol}\label{chap:net} The SANE interface has been designed to facilitate network access to image acquisition devices. In particular, most SANE implementations are expected to support a network backend (net client) and a corresponding network daemon (net server) that allows accessing image acquisition devices through a network connection. Network access is useful in several situations: \begin{itemize} \item To provide controlled access to resources that are inaccessible to a regular user. For example, a user may want to access a device on a host where she has no account on. With the network protocol, it is possible to allow certain users to access scanners without giving them full access to the system. Controlling access through the network daemon can be useful even in the local case: for example, certain backends may require root privileges to access a device. Rather than installing each frontend as setuid-root, a system administrator could instead install the SANE network daemon as setuid-root. This enables regular users to access the privileged device through the SANE daemon (which, presumably, supports a more fine-grained access control mechanism than the simple setuid approach). This has the added benefit that the system administrator only needs to trust the SANE daemon, not each and every frontend that may need access to the privileged device. \item Network access provides a sense of ubiquity of the available image acquisition devices. For example, in a local area network environment, this allows a user to log onto any machine and have convenient access to any resource available to any machine on the network (subject to permission constraints). \item For devices that do not require physical access when used (e.g., video cameras), network access allows a user to control and use these devices without being in physical proximity. Indeed, if such devices are connected to the Internet, access from any place in the world is possible. \end{itemize} The network protocol described in this chapter has been design with the following goals in mind: \begin{enumerate} \item Image transmission should be efficient (have low encoding overhead). \item Accessing option descriptors on the client side must be efficient (since this is a very common operation). \item Other operations, such as setting or inquiring the value of an option are less performance critical since they typically require explicit user action. \item The network protocol should be simple and easy to implement on any host architecture and any programming language. \end{enumerate} The SANE protocol can be run across any transport protocol that provides reliable data delivery. While SANE does not specify a specific transport protocol, it is expected that TCP/IP will be among the most commonly used protocols. \section{Data Type Encoding} \subsection{Primitive Data Types} The four primitive types of the SANE standard are encoded as follows: \begin{description} \item[\code{\defn{SANE\_Byte}}:] A byte is encoded as an 8 bit value. Since the transport protocol is assumed to be byte-orientd, the bit order is irrelevant. \item[\code{\defn{SANE\_Word}}:] A word is encoded as 4 bytes (32 bits). The bytes are ordered from most-significant to least-significant byte (big-endian byte-order). \item[\code{\defn{SANE\_Char}}:] A character is currently encoded as an 8-bit ISO LATIN-1 value. An extension to support wider character sets (16 or 32 bits) is planned for the future, but not supported at this point. \item[\code{\defn{SANE\_String}}:] A string pointer is encoded as a \code{SANE\_Char} array. The trailing NUL byte is considered part of the array and a \code{NULL} pointer is encoded as a zero-length array. \item[\code{\defn{SANE\_Handle}}:] A handle is encoded like a word. The network backend needs to take care of converting these integer values to the opaque pointer values that are presented to the user of the network backend. Similarly, the SANE daemon needs to take care of converting the opaque pointer values it receives from its backends into 32-bit integers suitable for use for network encoding. \item[{\em\defn{enumeration types}}:] Enumeration types are encoded like words. \end{description} \subsection{Type Constructors} Closely following the type constructors of the C language, the SANE network protocol supports the following four constructors: \begin{description} \item[{\em\defn{pointer}}:] A pointer is encoded by a word that indicates whether the pointer is a NULL-pointer which is then followed by the value that the pointer points to (in the case of a non-NULL pointer; in the case of a NULL pointer, no bytes are encoded for the pointer value). \item[{\em\defn{array}}:] An array is encoded by a word that indicates the length of the array followed by the values of the elements in the array. The length may be zero in which case no bytes are encoded for the element values. \item[{\em\defn{structure}}:] A structure is encoded by simply encoding the structure members in the order in which they appear in the corresponding C type declaration. \item[{\em\defn{union}}:] A union must always be accompanied by a tag value that indicates which of the union members is the currently the active one. For this reason, the union itself is encoded simply by encoding the value of the currently active member. \end{description} Note that for type constructors, the pointer, element, or member values themselves may have a constructed type. Thus, the above rules should be applied recursively until a sequence of primitive types has been found. Also SANE had no need for encoding of circular structures. This greatly simplifies the network protocol. \section{Remote Procedure Call Requests} The SANE network protocol is a client/server-style remote procedure call (RPC) protocol. This means that all activity is initiated by the client side (the network backend)---a server is restricted to answering requests sent by the client. The data transferred from the client to the server is comprised of the RPC code (as a \code{SANE\_WORD}), followed by arguments defined in the {\bf request} column below. The format of the server's answer is given in the {\bf reply} column. \subsection{\code{\defn{SANE\_NET\_INIT}}} RPC Code: 0 This RPC establishes a connection to a particular SANE network daemon. It must be the first call in a SANE network session. The parameter and reply arguments for this call are shown in the table below: \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_Word version\_code} & \code{SANE\_Word status} \\ \code{SANE\_String user\_name} & \code{SANE\_Word version\_code} \\ \end{tabular} \end{center} The \code{version\_code} argument in the request is the SANE version-code of the network backend that is contacting the network daemon (see Section~\ref{sec:saneversioncode}). The ``build-revision'' in the version code is used to hold the network protocol version. The SANE network daemon receiving such a request must make sure that the network protocol version corresponds to a supported version since otherwise the encoding of the network stream may be incompatible (even though the SANE interface itself may be compatible). The \code{user\_name} argument is the name of the user on whose behalf this call is being performed. If the network backend cannot determine a user-name, it passes a \code{NULL} pointer for this argument. No trust should be placed in the authenticity of this user-name. The intent of this string is to provide more convenience to the user. E.g., it could be used as the default-user name in subsequent authentication calls. In the reply, \code{status} indicates the completion status. If the value is anything other than \code{SANE\_STA\-TUS\_GOOD}, the remainder of the reply has undefined values.\footnote{The sane network daemon should be careful not to leak information in the undefined portion of the reply.} The \code{version\_code} argument returns the SANE version-code that the network daemon supports. See the comments in the previous paragraph on the meaning of the build-revision in this version code. \subsection{\code{\defn{SANE\_NET\_GET\_DEVICES}}} RPC Code: 1 This RPC is used to obtain the list of devices accessible by the SANE daemon. \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{void} & \code{SANE\_Word status} \\ & \code{SANE\_Device ***device\_list} \\ \end{tabular} \end{center} There are no arguments in the request for this call. In the reply, \code{status} indicates the completion status. If the value is anything other than \code{SANE\_STA\-TUS\_GOOD}, the remainder of the reply has undefined values. The \code{device\_list} argument is a pointer to a \code{NULL}-terminated array of \code{SANE\_Device} pointers. \subsection{\code{\defn{SANE\_NET\_OPEN}}} RPC Code: 2 This RPC is used to open a connection to a remote SANE device. \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_String device\_name} & \code{SANE\_Word status} \\ & \code{SANE\_Word handle} \\ & \code{SANE\_String resource} \\ \end{tabular} \end{center} The \code{device\_name} argument specifies the name of the device to open. In the reply, \code{status} indicates the completion status. If the value is anything other than \code{SANE\_STA\-TUS\_GOOD}, the remainder of the reply has undefined values. The \code{handle} argument specifies the device handle that uniquely identifies the connection. The \code{resource} argument is used to request authentication. If it has a non-\code{NULL} value, the network backend should authenticate the specified resource and then retry this operation (see Section~\ref{sec:authorization} for details on how to authorize a resource). \subsection{\code{\defn{SANE\_NET\_CLOSE}}} RPC Code: 3 This RPC is used to close a connection to a remote SANE device. \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_Word handle} & \code{SANE\_Word dummy} \\ \end{tabular} \end{center} The \code{handle} argument identifies the connection that should be closed. In the reply, the \code{dummy} argument is unused. Its purpose is to ensure proper synchronization (without it, a net client would not be able to determine when the RPC has completed). \subsection{\code{\defn{SANE\_NET\_GET\_OPTION\_DESCRIPTORS}}} RPC Code: 4 This RPC is used to obtain {\em all\/} the option descriptors for a remote SANE device. \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_Word handle} & \code{Option\_Descriptor\_Array odesc} \\ \end{tabular} \end{center} The \code{handle} argument identifies the remote device whose option descriptors should be obtained. In the reply, the \code{odesc} argument is used to return the array of option descriptors. The option descriptor array has the following structure: \begin{quote}\index{Option\_Descriptor\_Array} \begin{verbatim} struct Option_Descriptor_Array { SANE_Word num_options; SANE_Option_Descriptor **desc; }; \end{verbatim} \end{quote} \subsection{\code{\defn{SANE\_NET\_CONTROL\_OPTION}}} RPC Code: 5 This RPC is used to control (inquire, set, or set to automatic) a specific option of a remote SANE device. \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_Word handle} & \code{SANE\_Status status} \\ \code{SANE\_Word option} & \code{SANE\_Word info} \\ \code{SANE\_Word action} & \code{SANE\_Word value\_type} \\ \code{SANE\_Word value\_type} & \code{SANE\_Word value\_size} \\ \code{SANE\_Word value\_size} & \code{void *value} \\ \code{void *value} & \code{SANE\_String *resource} \\ \end{tabular} \end{center} The \code{handle} argument identifies the remote device whose option should be controlled. Argument \code{option} is the number (index) of the option that should be controlled. Argument \code{action} specifies what action should be taken (get, set, or set automatic). Argument \code{value\_type} specifies the type of the option value (must be one of \code{SANE\_TYPE\_BOOL}, \code{SANE\_TYPE\_INT}, \code{SANE\_TYPE\_FIXED}, \code{SANE\_TYPE\_STR\-ING}, \code{SANE\_TYPE\_BUTTON}). Argument \code{value\_size} specifies the size of the option value in number of bytes (see Section~\ref{sec:valuesize} for the precise meaning of this value). Finally, argument \code{value} is a pointer to the option value. It must be a writeable area that is at least \code{value\_size} bytes large. (Note that this area must be writable even if the action is to set the option value. This is because the backend may not be able to set the exact option value, in which case the option value is used to return the next best value that the backend has chosen.) In the reply, argument \code{resource} is set to the name of the resource that must be authorized before this call can be retried. If this value is non-\code{NULL}, all other arguments have undefined values (see Section~\ref{sec:authorization} for details on how to authorize a resource). Argument \code{status} indicates the completion status. If the value is anything other than \code{SANE\_STA\-TUS\_GOOD}, the remainder of the reply has undefined values. The \code{info} argument returns the information on how well the backend was able to satisfy the request. For details, see the description of the corresponding argument in Section~\ref{sec:control}. Arguments \code{value\_type} and \code{value\_size} have the same values as the arguments by the same name in corresponding request. The values are repeated here to ensure that both the request and the reply are self-contained (i.e., they can be encoded and decoded independently). Argument \code{value} is holds the value of the option that has become effective as a result of this RPC. \subsection{\code{\defn{SANE\_NET\_GET\_PARAMETERS}}} RPC Code: 6 This RPC is used to obtain the scan parameters of a remote SANE device. \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_Word handle} & \code{SANE\_Status status} \\ & \code{SANE\_Parameters params} \\ \end{tabular} \end{center} The \code{handle} argument identifies the connection to the remote device whose scan parameters should be returned. In the reply, \code{status} indicates the completion status. If the value is anything other than \code{SANE\_STA\-TUS\_GOOD}, the remainder of the reply has undefined values. The argument \code{params} is used to return the scan parameters. \subsection{\code{\defn{SANE\_NET\_START}}} RPC Code: 7 This RPC is used to start image acquisition (scanning). \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_Word handle} & \code{SANE\_Status status} \\ & \code{SANE\_Word port} \\ & \code{SANE\_Word byte\_order} \\ & \code{SANE\_String resource} \\ \end{tabular} \end{center} The \code{handle} argument identifies the connection to the remote device from which the image should be acquired. In the reply, argument \code{resource} is set to the name of the resource that must be authorized before this call can be retried. If this value is non-\code{NULL}, all other arguments have undefined values (see Section~\ref{sec:authorization} for details on how to authorize a resource). Argument, \code{status} indicates the completion status. If the value is anything other than \code{SANE\_STA\-TUS\_GOOD}, the remainder of the reply has undefined values. The argument \code{port} returns the port number from which the image data will be available. To read the image data, a network client must connect to the remote host at the indicated port number. Through this port, the image data is transmitted as a sequence of data records. Each record starts with the data length in bytes. The data length is transmitted as a sequence of four bytes. These bytes should be interpreted as an unsigned integer in big-endian format. The four length bytes are followed by the number of data bytes indicated by the length. Except for byte-order, the data is in the same format as defined for \code{sane\_read()}. Since some records may contain no data at all, a length value of zero is perfectly valid. The special length value of \code{0xffffffff} is used to indicate the end of the data stream. That is, after receiving a record length of \code{0xffffffff}, the network client should close the data connection and stop reading data. Argument \code{byte\_order} specifies the byte-order of the image data. A value of 0x1234 indicates little-endian format, a value of 0x4321 indicates big-endian format. All other values are presently undefined and reserved for future enhancements of this protocol. The intent is that a network server sends data in its own byte-order and the client is responsible for adjusting the byte-order, if necessary. This approach causes no unnecessary overheads in the case where the server and client byte-order match and puts the extra burden on the client side when there is a byte-order mismatch. Putting the burden on the client-side improves the scalability properties of this protocol. \subsection{\code{\defn{SANE\_NET\_CANCEL}}} RPC Code: 8 This RPC is used to cancel the current operation of a remote SANE device. \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_Word handle} & \code{SANE\_Word dummy} \\ \end{tabular} \end{center} The \code{handle} argument identifies the connection whose operation should be cancelled. In the reply, the \code{dummy} argument is unused. Its purpose is to ensure proper synchronization (without it, a net client would not be able to determine when the RPC has completed). \subsection{\code{\defn{SANE\_NET\_AUTHORIZE}}}\label{sec:authorization} \index{network authorization} RPC Code: 9 This RPC is used to pass authorization data from the net client to the net server. \begin{center} \begin{tabular}{ll} {\bf request:} & {\bf reply:} \\ \code{SANE\_String resource} & \code{SANE\_Word dummy} \\ \code{SANE\_String username} & \\ \code{SANE\_String password} & \\ \end{tabular} \end{center} The \code{resource} argument specifies the name of the resource to be authorized. This argument should be set to the string returned in the \code{resource} argument of the RPC reply that required this authorization call. The \code{username} and \code{password} are the name of the user that is accessing the resource and the password for the specified resource/user pair. Since the password is not encrypted during network transmission, it is recommended to use the following extension: If the server adds the string `\code{\$MD5\$}' to the resource-name followed by a random string not longer then 128 bytes, the client may answer with the MD5 digest of the concatenation of the password and the random string. To differentiate between the MD5 digest and a strange password the client prepends the MD5 digest with the string `\code{\$MD5\$}'. In the reply, \code{dummy} is completely unused. Note that there is no direct failure indication. This is unnecessary since a net client will retry the RPC that resulted in the authorization request until that call succeeds (or until the request is cancelled). The RPC that resulted in the authorization request continues after the reply from the client and may fail with \code{SANE\_STATUS\_ACCESS\_DENIED}. \subsection{\code{\defn{SANE\_NET\_EXIT}}} RPC Code: 10 This RPC is used to disconnect a net client from a net server. There are no request or reply arguments in this call. As a result of this call, the connection between the client and the server that was established by the \code{SANE\_NET\_INIT} call will be closed. % Local Variables: % mode: latex % TeX-master: "sane.tex" % End: sane-backends-1.0.29/doc/sane-umax.man0000666000000000000000000001611113615534521014341 00000000000000.TH sane\-umax 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-umax .SH NAME sane\-umax \- SANE backend for UMAX scanners .SH ABOUT THIS FILE This file only is a short description of the umax-backend for sane! For detailed information take a look at sane\-umax\-doc.html (it is included in the sane source directory and in the xsane online help)! .SH DESCRIPTION The .B sane\-umax library implements a SANE backend that provides access to several UMAX-SCSI-scanners and some Linotye Hell SCSI-scanners, parallel- and USB-scanners are not (and probably will never be) supported! .B I suggest you hold one hand on the power-button of the scanner while you try the first scans! .SH CONFIGURATION The configuration file for this backend resides in .IR @CONFIGDIR@/umax.conf . Its contents is a list of device names that correspond to UMAX and UMAX compatible scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .nf # this is a comment # option scsi\-maxqueue 4 option scsi\-buffer\-size\-min 65536 option scsi\-buffer\-size\-max 131072 option scan\-lines 40 option preview\-lines 10 option scsi\-maxqueue 2 option execute\-request\-sense 0 option force\-preview\-bit\-rgb 0 option slow\-speed \-1 option care\-about\-smearing \-1 option calibration\-full\-ccd \-1 option calibration\-width\-offset \-1 option calibration\-bytes\-pixel \-1 option exposure\-time\-rgb\-bind \-1 option invert\-shading\-data \-1 option lamp\-control\-available 0 option gamma\-lsb\-padded 0 /dev/sge \ #scsi Vendor Model Type Bus Channel ID LUN # The following scanner supports lamp control option lamp\-control\-available 1 scsi UMAX * Scanner * * * * * \ # scanner on /dev/scanner does not support lamp control option lamp\-control\-available 0 /dev/scanner .fi .TP execute\-request\-sense: values: 0 = disabled, 1 = enabled .br default = 0 .br If set to 1 umax_do_request_sense is called in umax_do_calibration. This can hang the system (but has been enabled until this version) .TP scsi\-buffer\-size\-min, scsi\-buffer\-size\-max: values: 4096-1048576 .br default min = 32768, max = 131072 .br Especially the minimum value is very important. If this value is set too small the backend is not able to send gamma tables to the scanner or to do a correct color calibration. This may result in strange color effects. If the minimum value is set too large then the backend is not able to allocate the requested scsi buffer size and aborts with out of memory error. The default is 32KB, for some scanners it should be increased to 64KB. .TP scan\-lines, preview\-lines: values: 1-65535 .br default: scan\-lines = 40, preview\-lines = 10 .br define the maximum number of lines that are scanned into one buffer .TP force\-preview\-bit\-rgb: values: 0 = disabled, 1 = enabled .br default = 0 .br set preview bit in rgb real scan .TP slow\-speed, care\-about\-smearing: values: \-1 = auto, 0 = disabled, 1 = enabled .br default = \-1 .br dangerous options, needed for some scanners do not changed these options until you really know what you do, you may destroy your scanner when you define wrong values for this options .TP calibration\-full\-ccd: values: \-1 = auto, 0 = disabled, 1 = enabled .br default = \-1 .br do calibration for each pixel of ccd instead of selected image .TP calibration\-width\-offset: values: \-99999 = auto, > \-99999 set value .br add an offset width to the calculated with for image/ccd .TP calibration\-bytes\-pixel: values: \-1 = disabled, 0 = not set, 1 = 1 byte/pixel, 2 = 2 bytes/pixel .br use # bytes per pixel for calibration .TP exposure\-time\-rgb\-bind: values: \-1 = automatically set by driver \- if known, 0 = disabled (own selection for red, green and blue), 1 = enabled (same values for red, green and blue) .TP invert\-shading\-data: values: \-1 = automatically set by driver \- if known, 0 = disabled, 1 = enabled .br default = \-1 .br invert shading data before sending it back to the scanner .TP lamp\-control\-available: values: 0 = automatically set by driver \- if known, 1 = available .br default = 0 .TP gamma\-lsb\-padded: values: \-1 = automatically set by driver \- if known, 0 = gamma data is msb padded, 1 = gamma data is lsb padded .br default = \-1 .TP handle\-bad\-sense\-error: values: 0 = handle as device busy, 1 = handle as ok, 2 = handle as i/o error, 3 = ignore bad error code \- continue sense handler .br default = 0 .TP scsi\-maxqueue: values: 1..# (maximum defined at compile time) .br default = 2 .br most scsi drivers allow internal command queueing with a depth of 2 commands. In most cases it does not mprove anything when you increase this value. When your scsi driver does not support any command queueing you can try to set this value to 1. .PP The special device name must be a generic SCSI device or a symlink to such a device. To find out to which device your scanner is assigned and how you have to set the permissions of that device, have a look at sane\-scsi. .SH SCSI ADAPTER TIPS The ISA-SCSI-adapters that are shipped with some Umax-scanners are not supported very well by Linux (I suggest not to use it), the PCI-SCSI-adapters that come with some Umax-scanners are not supported at all (as far as I know). On other platforms these SCSI-adapters are not supported. So you typically need to purchase another SCSI-adapter that is supported by your platform. See the relevant hardware FAQs and HOWTOs for your platform for more information. The UMAX-scanners do block the scsi-bus for a few seconds while scanning. It is not necessary to connect the scanner to its own SCSI-adapter. But if you need short response time for your SCSI-harddisk (e.g. if your computer is a file-server) or other scsi devices, I suggest you use an own SCSI-adapter for your UMAX-scanner. If you have any problems with your Umax scanner, check your scsi chain (cable length, termination, ...). See also: sane\-scsi(5) .SH FILES .TP The backend configuration file: .I @CONFIGDIR@/umax.conf .TP The static library implementing this backend: .I @LIBDIR@/libsane\-umax.a .TP The shared library implementing this backend: .I @LIBDIR@/libsane\-umax.so (present on systems that support dynamic loading) .SH ENVIRONMENT .TP .B SANE_DEBUG_UMAX If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity: SANE_DEBUG_UMAX values .ft CR .nf Number Remark \ 0 print important errors (printed each time) 1 print errors 2 print sense 3 print warnings 4 print scanner-inquiry 5 print information 6 print less important information 7 print called procedures 8 print reader_process messages 10 print called sane\-init-routines 11 print called sane\-procedures 12 print sane infos 13 print sane option-control messages .fi .ft R .TP Example: export SANE_DEBUG_UMAX=8 .SH BUGS X-resolutions greater than 600 dpi sometimes make problems .SH SEE ALSO sane(7) .SH AUTHOR Oliver Rauch .SH EMAIL-CONTACT Oliver.Rauch@Rauch-Domain.DE sane-backends-1.0.29/doc/mustek_usb/0000755000000000000000000000000013615535552014210 500000000000000sane-backends-1.0.29/doc/mustek_usb/mustek_usb.TODO0000666000000000000000000000044313615534521017000 000000000000002004-03-02 * Support more scanners - 1200 USB - 600 USB These are both CCD scanners. Several people tried to add support until now but I have never heard from the again ... * Remove/replace _word variables from usb_low * Check if low resolutions can be made faster. * Check fixmes. sane-backends-1.0.29/doc/mustek_usb/mustek_usb.CHANGES0000666000000000000000000003036613615534521017312 00000000000000CHANGES for the SANE Mustek USB backend 2004-03-02 * Release of version 1.0-18. 2004-03-02 * Added workaround for data0 toggle bug. I think this is a bug in the chipset. The chipset doesn't set the toggle to data0 when the endpoints are reset. As this is done whenever the device files/libusb is closed, this backend worked ony once. Now we count the number of URBs and just read/write some crap if the number is odd. 2003-09-21 * Release of version 1.0-17. 2003-09-21 * Fixed check for single quotation marks. 2003-02-22: * Release of version 1.0-16. 2003-02-22: * Iniatialize global variables explicitely. * Mention ma1509. 2002-11-20: * Man page updated concerning The BSDs. 2002-11-19: * Added desc file hint to the gt68xx backend. 2002-11-17: * Fixed minor issues in the man page. Removed beta status. Added links to other backends for Mustek scanners. 2002-07-17: * Release of version 1.0-15. 2002-07-17: * Added manufacturer comment in mustek_usb.desc. * Changed brightness to threshold. * Fixed some warnings. * Really check the status in usb_low_open. 2002-04-24: * Release of version 1.0-14. 2002-04-24: * Undef MIN and MAX if they are defined in mustek_usb_low.h to avoid warnings. 2002-04-23: * Free devlist in sane_exit. 2002-04-10: * Release of version 1.0-13. 2002-04-10: * sane_set_io_mode must return SANE_STAUS_GOOD if non_blocking is false. Check if scanning. * sane_get_select_fd: Check if scanning. * sane_control_option: Cleanup. Avoid segfaults. Catch unknown options. * sane_exit: set freed variable to 0. 2002-03-20: * Release of version 1.0-12. 2002-03-19: * Option 0 has an empty name now. * Group options have size 0 now. * Checked also for SANE_ACTION_SET_AUTO. * Removed buggy output in sane_control_option. * Added more debug output in sane_control_option. 2002-03-17: * Release of version 1.0-11. 2002-03-16: * mustek_usb.c: Fixed segfault when opening device again after closing. * mustek_usb.c: Fixed possible segfault when name="". * mustek_usb.c: Type for option 0 must be set to SANE_TYPE_INT explicitely. 2002-02-14: * Fixed some problems with wrong formats in DBG statements. 2002-02-09 * Fixed wrong output in usb_low_read_reg(). 2002-01-23: * Fixed undefined operation warnings. 2002-01-11 * Release of version 1.0-10. 2002-01-11 * mustek_usb_high.(c|h), mustek_usb_mid.(c|h): commented out unused CCD code. * mustek_usb_mid.h: Fixed OFFSET_TABLE_SIZE. * mustek_usb.c: Fixed bug concerning opening with empty name. * mustek_usb.c, mustek_usb_high.c: Make sure usb_low_exit is only called once per device. Fixed segfault. 2002-01-10 * mustek_usb.desc: Status is "beta" now. 2002-01-03 * Added link to plustek to manual page. 2001-12-08 * Release of version 1.0-9. 2001-12-08 * Added option max_block_size to limit amount of data acquired in one turn. 2001-12-07 * usb_low_read_rows: Retry until all the data is received. Set maximum size of data acquired in one turn. 2001-11-15 * Release of version 1.0-8. 2001-11-15 * Updated manual page concerning FreeBSD and kernel configuration. 2001-11-14 * Added 600 USB detection. No support at all yet. * Removed unneccessary calls to usb_low_open and usb_low_close. This fixed the FreeBSD problems. * Updated all SANE comments ("1200UB and similar"). 2001-11-11 * Added function usb_high_scan_adjust_mono_600_exposure. 2001-10-14 * Added start values for the 1200USB. * Removed load_private_profile (now in usb_high_scan_init). 2001-10-07 * Release of version 1.0-7. 2001-10-07 * usb_low: fixed output if scanner has wrong vendor/product id. * usb_high: Added the detection of 300&600 sensor again. Mustek seems to have used both sensors in the Mustek 1200 UB, so we must distinguish them. * Disabled 1200 USB for release. 2001-09-30 * 1200CU_Plus has Canon600 sensor (fixed). 2001-09-15 * Added functions for sensor nec600 (1200 USB) in mustek_usb_mid. * Changed init_asic and exposure times for 1200 USB. 2001-09-13 * Release of version 1.0-6. 2001-09-13 * Added check for negative width and height. * Changed status to NEW (internaly: beta). * Added check for too high gamma values (xscanimage is buggy). * Return SANE_STATUS_CANCELLED in sane_read if scan was cancelled. * Updated manual page. 2001-09-12 * Added support for fitting lines (recalculation of resolution) for color mode * Added support for fitting lines (recalculation of resolution) for lineart mode * Better debug output for unmatched dpi in mustek_usb_mid. * Changed default mode to "gray". * Added gamma table support (software) for color + gray, stayed with brightness for lineart. * Added output of total bytes scanned (+ check). * Decreased maximum width and height to avoid freezing the scanner. * Added check for unknown options in mustek_usb. * Code cleanup in mustek_usb, mustek_usb_high. * Added SANE_I18N macro. 2001-09-11 * Added support for idependent x and y resolution. * Changed option resolution to constraint_range. * Increased motor speed when returning back home for 600 dpi motor. * Increased resolution to 1200 dpi for 1200CU, 1200CU Plus and 1200 UB. * Increased resolution to 600 dpi for 600CU. * Added support for fitting lines (recalculation of resolution) for gray mode 2001-09-10 * Release of version 1.0-5. 2001-09-10 * mustek_usb_mid: Added functions for 300 dpi sensor. * mustek_usb_mid: Fixed 200 dpi mode. * mustek_usb_mid: added general sensor functions. 2001-09-09 * mustek_usb_mid: Added functions for 600 dpi motor. * mustek_usb_mid, usb_high: Added functions for selecting the motor functions. 2001-09-06 * Release of version 1.0-4. 2001-09-06 * usb_high: use only lower case for functions. * mustek_usb: use only lower case for variables and functions. * mustek_usb: remove unnecessary functions. 2001-09-01 * usb_high: removed unnecessary macros and types. * usb_high: use only lower case for variables and upper/lower mixed for types. 2001-08-30 * usb_low, usb_mid: use only lower case for functions. Fixed some spellings and debug messages. 2001-08-29 * usb_low: use only lower case for variables and upper/lower mixed for types. remove unnecessary types. 2001-08-28 * Also include sane-usb man page in tar.gz file to avoid make errors. * Only use arrays of SANE_Byte for data transfer to scanner in usb_low. 2001-08-26 * Check the result of all mallocs. * Sensor is now only in mustek_usb_low. * Removed gamma functions from code (weren't used anyway). * Contrast is only active for color and gray scans. 2001-08-26 * Release of version 1.0-3. 2001-08-26 * Set up motor600 functions using the motor1200 with double dpi. This doesn't work for 200 dpi, however. Removed 200 dpi from list until I understand what's going on. * Updated manual page * Updated .conf file 2001-08-25 * Used proper SANE_Status return values in mustek_usb_mid for all functions. * Used proper SANE_Status return values in mustek_usb for all functions. * Added Trust scanner to mustek_usb.desc. * Removed Mono4 and Mono1 functions. 2001-08-23 * Removed ifdefs in mustek_usb_mid. 2001-08-22 * Removed GREENGRAY macro and included code (didn't work anyway). * Removed 36 and 48 bit calibration. * Added RIE (return if error) macro. 2001-08-19 * Removed io functions in mustek_usb_low. * Used proper SANE_Status return values in mustek_usb_low for all functions. * Fixed lots of debug output in mustek_usb_low. * Formatting update in mustek_usb_low. * Used proper SANE_Status return values in mustek_usb_high for all functions. * Fixed lots of debug output in mustek_usb_high. * removed unnecessary modes in mustek_usb_high. 2001-08-18 * Added manual selection of scanner type in mustek_usb.conf * It's checked now if the scanner was autodetected or manually selected * Set maximum resolution to 300 for 600 CU. * Changed nUSBPipe to fd, which is more appropriate. * Removed #ifdef 0 code from mustek_usb_high * Used proper SANE_Status return values in mustek_usb_low for - io_Open - Open - io_WriteReg - io_ReadReg 2001-08-08 * Fixed some format issues * Better debug output * Added support for CANON300 sensor (for 600 CU) 2001-08-07 * Added support for sanei_usb v2. * Check vendor/product directly after sane_open. 2001-08-06 * Added scan buffer. It's used if the buffer suplied with sane_read is smaller than one scan line. 2001-08-06 * Released mustek_usb-backend 1.0-2. 2001-08-05 * Support more than one scanner in the .conf file * Use sanei_usb functions * Allow usb vendor device in .conf * Only use usb statements in .conf for all three scanners, comment out device files * Now the correct names are returned if autodetection works * Manual page updates 2001-08-05 * Released mustek_usb-backend 1.0-1. 2001-08-04 * mustek_usb_low: - fixed compilation warnings - fixed compilation problems - fixed C++ to C transition issues (e.g. "initializer element is not computable at load time") - fixed debug output - adjusted some names - removed MEMFREE, MALLOC, LP* * mustek_usb_mid: - fixed compilation warnings - changed printf to DBG - fixed debug output - reformatted * mustek_usb_high: - fixed some DBG statements - fixed compilation warnings - moved global variable to Mustek_Usb_Device - reformatted * mustek_usb: - fixed compilation warnings --> compile runs successfully for the first time since restructuring - removed DWORDS etc. - moved CScanner into Mustek_Usb_device - removed global variables * mustek_usb.conf: updated * removed references to "WORD" * ifdefed unused functions * fixed bug concerning wrong x-resolution after the first scan for low resolutions (e.g. preview). This also fixed the problems with 1200 CU. --> Scanning works with 1200 UB, 1200 CU and probably 1200 CU Plus. * added manual page * updated mustek_usb.desc 2001-08-02 * mustek_usb_high: - fixed lots of compilation problems. - removed LP..., huge*, far* - removed MEMFREE, MEMALLOC - added several "return SANE_TRUE" to SANE_Bool functions - changed printf to DBG - changed Sleep to usleep 2001-07-22 * mustek_usb_low: Only one data structure: ma1017. * mustek_usb_mid: - removed // - remove SANE disclaimers - use SANE types - changed to use new usb_low style - made everything static - renamed functions to usb_mid_* * mustek_usb_high: - removed remaining // - reformatted - used SANE types - made everything static - renamed * Fixed quite some compilation errors 2001-07-08 * mustek_usb_low: - renamed functions to usb_low/usb_low_io - made all functions static - used DBG instead of printf - moved all status information from global to struct ma1017 - rename constructor/destructor - included io constructor/destructor in usb_low 2001-07-01 * Added more debug output in attach () when device file couldn't be opened. * Added some tests for NULL pointers in attach () * fixed segfault in sane_exit () * indented all files * fixed mustek_usb_high: - changed // to /* */ - reformatted * fixed mustek_usb_low: - changed // to /* */ - reformatted - removed most non-standard types 2001-05-26 * Started working based on the Mustek source code from their FTP server. * Renamed backend to mustek_usb. All files start with this name. * Created: - mustek_usb(.c .h) from 1200ub(.c .h) - mustek_usb_low from ma1017 and ma1017io - mustek_usb_mid from ada* - mustek_usb_high from scanner and calibrator * Used "../include/sane" in #include statements * Used /dev/usbscanner in mustek_usb.conf * Fixed mustek_usb.desc * Fixed mustek_usb.*: - use correct names - no leading "_" - use only C-style comments - moved defines to .h, - reformatted using GNU style - use /dev/usbscanner as default - Fixed DBG output - don't use printf - added more DBG output - added "static" to internal functions - commented out all references to c_scanner - removed references to WORD and other non-standard types - moved read_rows from global to Mustek_Usb_Scanner --> mustek_usb.* compiles sane-backends-1.0.29/doc/sane-genesys.man0000666000000000000000000002602013615534521015044 00000000000000.TH "sane\-genesys" "5" "4 Jul 2012" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-genesys .SH "NAME" sane\-genesys \- SANE backend for GL646, GL841, GL843, GL847 and GL124 based USB flatbed scanners .SH "DESCRIPTION" The .B sane\-genesys library implements a SANE (Scanner Access Now Easy) backend that provides access to USB flatbed scanners based on the Genesys GL646, GL841, GL843, GL847 and GL124 chips. At present, the following scanners are known to work with this backend: .PP .RS Canon LiDE 35/40/50/60/100/110/120/200/210/220/700 .br Hewlett-Packard HP2300C/HP2400/HP3670/HP3690/G4010/G4050 .br Medion MD5345/MD6228/MD6274 .br Panasonic KV-SS080 .br Plustek OpticBook 3600 .br Pentax DSmobile 600 .br Syscan/Ambir DocketPORT 467/485/487/665/685 .br Visioneer OneTouch 7100/Strobe XP100 (rev3)/XP200/XP300/Roadwarrior .br Xerox Travel Scanner 100, OneTouch 2400 .RE .PP This is stable software for supported models. But if you test new or untested scanners, keep your hand at the scanner's plug and unplug it, if the head bumps at the end of the scan area. .PP If you own a scanner other than the ones listed above that works with this backend, please let me know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .IR /proc/bus/usb/devices , .I sane\-find\-scanner or syslog) to the sane\-devel mailing list. Even if the scanner's name is only slightly different from the models mentioned above, please let me know. .PP If you own a scanner that isn't detected by the genesys backend but has a GL646, GL841, GL843, GL847 or GL124 chipset, you can try to add it to the backend. .PP .SH "CALIBRATION" To give correct image quality, sheet fed scanners need to be calibrated using the calibration sheet sold with the scanner. To do calibration, you must insert this target in the feeder then start calibration either by passing the \-\-calibrate option to scanimage or by clicking on the available 'calibrate' button in the 'advanced options' in a graphical frontend. The result of the calibration is stored in a file in the home directory of the user doing it. If you plug the scanner in another machine or use it with another account, calibration will have to be redone, unless you use the \-\-calibration\-file option. If no home directory is defined, USERAPPPROFILE will be used, then TMPDIR or TMP. If none of these directories exist, the backend will try to write in the current working directory. Flatbed scanners also make use of the calibration file as a cache to avoid calibration before each scan. Calibration file name is the name of the scanner model if only one scanner is detected. In the case of several identical model, the file name will be the name of the logical USB device name. The expiration time manages the time a calibration is valid in cache. A value of -1 means forever, 0 means no cache. .SH EXTRAS SCAN OPTIONS .B \-\-lamp\-off\-time number .RS The lamp will be turned off after the given time (in minutes). A value of 0 means that the lamp won't be turned off. .RE .B \-\-threshold percent .RS 0..100% (in steps of 1). Select minimum brightness to get a white point. Pixels with brightness below that value will be scanned as black. .RE .B \-\-brightness value .RS \-100..100 (in steps of 1). Set the brightness enhancement. 0 for no enhancement, negative values to decrease brigthness, and positive values to increase it. .RE .B \-\-contrast value .RS \-100..100 (in steps of 1). Set the contrast enhancement. 0 for no enhancement, negative values to decrease contrast, and positive values to increase it. .RE .B \-\-disable-interpolation yes|no .RS When using high resolutions where the horizontal resolution is smaller than vertical resolution, data is expanded by software to preserve picture geometry. This can be disabled by this option to get real scanned data. .RE .B \-\-disable-dynamic-lineart yes|no .RS Disable use of a software adaptive algorithm to generate lineart and rely on hardware lineart. .RE .B \-\-color-filter None|Red|Green|Blue .RS When using gray or lineart this option selects the used color. Using a color filter will give a monochrome scan. CIS based scanners can to true gray when no filter (None value) is selected. .RE .B \-\-lamp\-off\-scan .RS The lamp will be turned off during the scan. Calibration is still done with lamp on. .RE .B \-\-clear\-calibration .RS Clear calibration cache data, triggering a new calibration for the device when the next scan will happen. .RE .B \-\-calibration\-file .RS Specify the calibration file name to use. At least the directory containing the file must exist, since it won't be created. This option is disabled if the backend is ran as root. It maybe used in case of sheet-fed scanners to share a calibration file for several users. .RE .B \-\-expiration\-time .RS Specify the time (in minutes) a cached calibration is considered valid. If older than the given value, a new calibration is done. A value of -1 means no expiration and cached value are kept forever unless cleared by userwith the calibration clear option. A value of 0 means cache is disabled. .RE .PP Additionally, several 'software' options are exposed by the backend. These are reimplementations of features provided natively by larger scanners, but running on the host computer. This enables smaller machines to have similar capabilities. Please note that these features are somewhat simplistic, and may not perform as well as the native implementations. Note also that these features all require that the driver cache the entire image in memory. This will almost certainly result in a reduction of scanning speed. .PP .B \-\-swcrop .RS Requests the driver to detect the extremities of the paper within the larger image, and crop the empty edges. .RE .PP .B \-\-swdeskew .RS Requests the driver to detect the rotation of the paper within the larger image, and counter the rotation. .RE .PP .B \-\-swdespeck \-\-despeck X .RS Requests the driver to find and remove dots of X diameter or smaller from the image, and fill the space with the average surrounding color. .RE .PP .B \-\-swskip 0..100% (in steps of 1) [0] .RS Request driver to discard pages with low numbers of dark pixels. .RE .PP .B \-\-swderotate[=(yes|no)] [no] .RS Request driver to detect and correct 90 degree image rotation. .PP .SH "SYSTEM ISSUES" This backend needs libusb-0.1.6 or later installed, and hasn't tested in other configuration than a linux kernel 2.6.9 or higher. However, it should work any system with libusb where the SANE package can be compiled. For setting permissions and general USB information look at .BR sane\-usb (5). .SH "CONFIGURATION" The contents of the .I genesys.conf file is a list of usb lines containing vendor and product ids that correspond to USB scanners. The file can also contain option lines. Empty lines and lines starting with a hash mark (#) are ignored. The scanners are autodetected by .B usb vendor_id product_id statements which are already included into .IR genesys.conf . "vendor_id" and "product_id" are hexadecimal numbers that identify the scanner. .PP .SH "FILES" .TP .I @CONFIGDIR@/genesys.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-genesys.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-genesys.so The shared library implementing this backend (present on systems that support dynamic loading). .SH "ENVIRONMENT" .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_GENESYS If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. If the debug level is set to 1 or higher, some debug options become available that are normally hidden. Handle them with care. This will print messages related to core genesys functions. .TP .B SANE_DEBUG_GENESYS_LOW This environment variable controls the debug level for low level functions common to all genesys ASICs. .TP .B SANE_DEBUG_GENESYS_GL646 This environment variable controls the debug level for the specific GL646 code part. .TP .B SANE_DEBUG_GENESYS_GL841 This environment variable controls the debug level for the specific GL841 code part. .TP .B SANE_DEBUG_GENESYS_GL843 This environment variable controls the debug level for the specific GL843 code part. .TP .B SANE_DEBUG_GENESYS_GL847 This environment variable controls the debug level for the specific GL847 code part. .TP .B SANE_DEBUG_GENESYS_GL124 This environment variable controls the debug level for the specific GL124 code part. Example (full and highly verbose output for gl646): .br export SANE_DEBUG_GENESYS=255 .br export SANE_DEBUG_GENESYS_LOW=255 .br export SANE_DEBUG_GENESYS_GL646=255 .SH CREDITS Jack McGill for donating several sheetfed and flatbed scanners, which made possible to add support for them in the genesys backend: .RS Hewlett-Packard HP3670 .br Visioneer Strobe XP100 (rev3)/XP200/XP300/Roadwarrior .br Canon LiDE 200 .br Pentax DSmobile 600 .br Syscan/Ambir DocketPORT 467/485/487/665/685 .br Xerox Travel Scanner 100, Onetouch 2400 .RE .TP cncsolutions (http://www.cncsolutions.com.br) sponsored and supported the work on the Panasonic KV-SS080. .br .TP Brian Paavo from Benthic Science Limited for donating a Canoscan LiDE 700F. .br .TP Dany Qumsiyeh for donating a Canoscan LiDE 210 and a LiDE 220. .br .TP Luc Verhaegen for donating a Canoscan LiDE 120. .br .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5) .br .SH "AUTHOR" Oliver Rauch .br Henning Meier-Geinitz .br Gerhard Jaeger .br St\['e]phane Voltz .br Philipp Schmid .br Pierre Willenbrock .br Alexey Osipov for HP2400 final support .SH "LIMITATIONS" Powersaving isn't implemented for gl646 based scanner. Dynamic (emulated from gray data and with dithering) isn't enabled for gl646 scanners. Hardware lineart is limited up to 600 dpi for gl847 based scanners, due to the way image sensors are built. .br .TP This backend will be much slower if not using libusb\-1.0. So be sure that sane\-backends is built with the \-\-enable-libusb_1_0 option. .br .SH "BUGS" For the LiDE 200, the scanned data at 4800 dpi is obtained "as is" from sensor. It seems the windows driver does some digital processing to improve it, which is not implemented in the backend. .PP sane-backends-1.0.29/doc/sane-artec_eplus48u.man0000666000000000000000000001250313615534521016237 00000000000000.TH sane\-artec_eplus48u 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE" .SH NAME sane\-artec_eplus48u \- SANE backend for the scanner Artec E+ 48U and re-badged models .SH DESCRIPTION The .B sane\-artec_eplus48u library implements a SANE (Scanner Access Now Easy) backend that provides access to several USB flatbed scanners using the GT6816 chipset like the Artec E+ 48U. These scanners have a contact image sensor (CIS) and an USB interface. .PP A complete list of supported devices can be found on .IR http://www.sane\-project.org/sane\-supported\-devices.html . .PP This is ALPHA software. Especially if you test new or untested scanners, keep your hand at the scanner's plug and unplug it, if the head bumps at the end of the scan area. .PP If you own a scanner other than the ones mentioned on the list that works with this backend, please let us know this by sending the scanner's exact model name and the USB vendor and product ids (e.g. from /proc/bus/usb/devices, sane\-find\-scanner or syslog) to me. Even if the scanner's name is only slightly different from the models mentioned above, please let me know. .PP .SH KERNEL ISSUES If libusb-0.1.6 or later is installed, this section can be skipped. The scanner should be found by sane\-find\-scanner without further actions. For setting permissions and general USB information look at sane\-usb(5). .PP When you are using the scanner module, a Linux kernel 2.4.12 or newer is required. .SH FIRMWARE FILE You need a firmware file for your scanner. That's a small file containing software that will be uploaded to the scanner's memory. For the scanners mentioned above, it's usually named Artec48.usb or 1200.usb. You can find it on the installation CD that was provided by the manufacturer, normally in the directory Win98, WinMe or similar. If the Windows-driver is installed on your computer, then you can also find the firmware file under c:\\windows\\system32\\drivers. .SH CONFIGURATION The contents of the .I artec_eplus48u.conf file is a list of usb lines containing vendor and product ids that correspond to USB scanners. The file can also contain option lines. Empty lines and lines starting with a hash mark (#) are ignored. The scanners are autodetected by .I usb vendor_id product_id statements which are already included into .I artec_eplus48u.conf . "vendor_id" and "product_id" are hexadecimal numbers that identify the .B scanner. .PP Every usb section can have additional options .TP .B artecFirmwareFile @DATADIR@/sane/artec_eplus48u/Artec48.usb The path to the firmware file. This option is required. .TP .B redGamma 1.0 .TP .B greenGamma 1.0 .TP .B blueGamma 1.0 .TP .B masterGamma 1.9 These are the default gamma values. If you set the "Defaults" option with a frontend, then the gamma options are reset to the values specified here. .TP .B redOffset 0x28 .TP .B greenOffset 0x2f .TP .B blueOffset 0x2f .TP .B redExposure 0xa7 .TP .B greenExposure 0x116 .TP .B blueExposure 0xdc These are the default values for offset and exposure time. You can e.g. change them to speed up calibration, if you don't want to save the calibration data to disk. .TP .B vendorString "Artec" .TP .B modelString "E+ 48U" By default, the scanner is reported as "Artec E+ 48U". If you don't like this, e.g. because you have an Tevion MD 9693, then change the options accordingly. .SH FILES .TP .I /usr/local/etc/sane.d/artec_eplus48u.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I /usr/local/lib/sane/libsane\-artec_eplus48u.a The static library implementing this backend. .TP .I /usr/local/lib/sane/libsane\-artec_eplus48u.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in /usr/local/etc/sane.d. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "/usr/local/etc/sane.d" being searched (in this order). .TP .B SANE_DEBUG_ARTEC_EPLUS48U If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_ARTEC_EPLUS48U=3 .SH "SEE ALSO" sane(7), sane\-usb(5) .SH AUTHOR Michael Herder .br This backend is based on the gt68xx test-program written by Sergey Vlasov, Andreas Nowack, and David Stevenson. Thanks to everyone who tested the backend or reported bugs. .br This man page is based on man sane\-gt68xx, written by Henning Meier-Geinitz. .SH BUGS This backend has been tested on Linux only. If you are using it on a different platform, please contact us. .PP Interpolation with 1200 dpi is weak. .PP Support for buttons is missing due to missing support in SANE. .PP Please contact us if you find a bug: .IR http://www.sane\-project.org/bugs.html . sane-backends-1.0.29/doc/sane-mustek_pp.man0000666000000000000000000003532613615534521015407 00000000000000.TH sane\-mustek_pp 5 "13 Jul 2008" .de EX .sp .nf .ft CW .. .de EE .ft R .fi .sp .. .IX sane\-mustek_pp .SH NAME sane\-mustek_pp \- SANE backend for Mustek parallel port flatbed scanners .SH DESCRIPTION The .B sane\-mustek_pp library implements a SANE (Scanner Access Now Easy) backend that provides access to Mustek parallel port flatbed scanners and OEM versions. There are 2 classes of Mustek parallel port scanners: regular .B CCD (cold cathode device) scanners and .B CIS (contact image sensor) scanners. .P The current version of this backend supports both CCD type scanners and CIS type scanners. .P The following scanners might work with this backend: .SS "CCD scanners" .EX Model: ASIC ID: CCD Type: works: -------------------------------------------------------------- SE 6000 P 1013 00 yes SM 4800 P 1013/1015 04/01 yes SE 1200 ED Plus 1015 01 no SM 1200 ED Plus 1015 01 no SE 12000 P 1505 05 no 600 III EP Plus 1013/1015 00/01 yes SE 600 SEP 1013 ?? yes 600 II EP ???? ?? no MD9848 1015 00 yes Gallery 4800 ???? ?? yes Viviscan Compact II 1013 00 yes .EE .SS CIS scanners .EX Model: ASIC ID: works: ----------------------------------------------- Mustek 600 CP & 96 CP 1015 yes (*) Mustek 1200 CP 1015 yes Mustek 1200 CP+ 1015 yes .EE .EX OEM versions Original works -------------------------------------------------- Medion/LifeTec/Tevion MD/LT 9350/9351 1200 CP yes MD/LT 9850/9851 1200 CP maybe (**) MD/LT 9858 1200 CP probably MD/LT 9890/9891 1200 CP yes Targa Funline TS12EP 1200 CP yes Funline TS6EP 600 CP yes Trust Easy Connect 9600+ 600 CP yes Cybercom 9352 1200 CP yes (***) .EE .HP (*) Calibration problems existed with earlier version of this driver. They seem to be solved now. .HP (**) Problems have been reported in the past for the MD/LT9850 type (striped scans, head moving in wrong direction at some resolutions). It is not known whether the current version of the driver still has these problems. .PP .B IF YOU HEAR LOUD CLICKING NOISES, IMMEDIATELY UNPLUG THE SCANNER ! (This holds for any type of scanner). .HP (***) Possibly, the engine_delay parameter has to be set to 1 ms for accurate engine movements. .PP Please note that this backend is still under construction. Certain models are currently not supported and some may never be because the communication protocol is still unknown (eg., SE 12000 P). .PP Some scanners work faster when .B EPP/ECP is enabled in the BIOS. EPP mode however may lead to hard-locks on some Linux systems. If that is the case for you, you can either disable ECP/EPP in your BIOS or disable it in the backend itself (see GLOBAL OPTIONS). .PP Note that the backend needs to run as root or has to have appropriate access rights to /dev/parport* if libieee1284 support is compiled in. To allow user access to the scanner run the backend through the network interface (See saned(8) and sane\-net(5)). Note also that the backend .I does not support .IR "parport sharing" , i.e. if you try printing while scanning, your computer may crash. To enable parport sharing, you have to enable libieee1284 at compile time. This backend also conflicts with the .I sane\-musteka4s2 backend. You can only enable one of them in your dll.conf. However, you have to enable the backend explicitly in your dll.conf, just remove the hash mark in the line "mustek_pp". .SH "DEVICE DEFINITION" This backend allows multiple devices being defined and configured via the .B mustek_pp.conf file (even simultaneously, provided that they are connected to different parallel ports). Please make sure to edit this file .B before you use the backend. .PP A device can be defined as follows: .PP .RS .I scanner .RE .PP where .HP .B is an arbitrary name for the device, optionally enclosed by double quotes, for instance "LifeTec 9350". .HP .B is the name of the parallel port to which the device is connected. In case libieee1284 is used for communication with the port .I (default .IR setup) , valid port names are .BR parport0 , .BR parport1 , and .BR parport2 . .PP In case the backend is configured for raw IO .I (old .IR setup) , port addresses have to be used instead of port names: .BR 0x378 , .BR 0x278 , or .BR 0x3BC . The mapping of parallel ports (lp0, lp1, and lp2) to these addresses can be different for different Linux kernel versions. For instance, if you are using a Kernel 2.2.x or better and you have only one parallel port, this port is named lp0 regardless of the base address. However, this backend requires the base address of your port. If you are not sure which port your scanner is connected to, have a look at your /etc/conf.modules, /etc/modules.conf and/or /proc/ioports. .PP If you are unsure which port to use, you can use the magic value .BR * to probe for your scanner. .PP .HP .B is the driver to use for this device. Currently available drivers are: .IP .BR cis600 " : for 600 CP, 96 CP & OEM versions" .br .BR cis1200 " : for 1200 CP & OEM versions" .br .BR cis1200+ " : for 1200 CP+ & OEM versions" .br .BR ccd300 " : for 600 IIIE P & OEM version" .IP .B Choosing the wrong driver can damage your scanner! .br Especially, using the 1200CP settings on a 600CP can be harmful. If the scanner starts making a loud noise, turn it off immediately !!! .PP Using the cis600 driver on a 1200CP or a 1200CP+ is probably not dangerous. The cis1200+ driver also works for the 1200CP, and using the cis1200 driver on a 1200CP+ will typically result in scans that cover only half of the width of the scan area (also not dangerous). .PP If unsure about the exact model of your OEM version, check the optical resolution in the manual or on the box: the 600CP has a maximum optical resolution of 300x600 DPI, whereas the 1200CP and 1200CP+ have a maximum optical resolution of 600x1200 DPI. .PP Examples: .PP .RS scanner "LifeTec 9350" 0x378 cis1200 .PP scanner Mustek_600CP 0x378 cis600 .PP scanner Mustek_600IIIEP * ccd300 .RE If in doubt which port you have to use, or whether your scanner is detected at all, you can use .B sane\-find\-scanner \-p to probe all configured ports. .SH CONFIGURATION .PP The contents of the .B mustek_pp.conf file is a list of device definitions and device options that correspond to Mustek scanners. Empty lines and lines starting with a hash mark (#) are ignored. Options have the following format: .PP .RS .I option [] .RE .PP Depending on the nature of the option, a value may or may not be present. Options always apply to the scanner definition that precedes them. There are no global options. Options are also driver-specific: not all drivers support all possible options. .SS Common options .TP .B bw Black/white discrimination value to be used during lineart scanning. Pixel values below this value are assumed to be black, values above are assumed to be white. .br Default value: 127 .br Minimum: 0 .br Maximum: 255 .sp Example: option bw 150 .SS CIS driver options .TP .B top_adjust Vertical adjustment of the origin, expressed in millimeter (floating point). This option can be used to calibrate the position of the origin, within certain limits. Note that CIS scanners are probably temperature sensitive, and that a certain inaccuracy may be hard to avoid. Differences in offset between runs in the order of 1 to 2 mm are not unusual. .br Default value: 0.0 .br Minimum: \-5.0 .br Maximum: 5.0 .br .sp Example: option top_adjust \-2.5 .TP .B slow_skip Turns fast skipping to the start of the scan region off. When the region to scan does not start at the origin, the driver will try to move the scanhead to the start of the scan area at the fastest possible speed. On some models, this may not work, resulting in large inaccuracies (up to centimeters). By setting this option, the driver is forced to use normal speed during skipping, which can circumvent the accuracy problems. Currently, there are no models for which these inaccuracy problems are known to occur. .sp By default, fast skipping is used. .sp Example: option slow_skip .TP .B engine_delay Under normal circumstances, it is sufficient for the driver to wait for the scanner signaling that the engine is stable, before a new engine command can be transmitted. In rare cases, certain scanners and/or parallel port chipsets appear to prevent reliable detection of the engine state. As a result, engine commands are transmitted too soon and the movement of the scanner head becomes unreliable. Inaccuracies ranging up to 10 cm over the whole vertical scan range have been reported. To work around this problem, the engine_delay option can be set. If it is set, the driver waits an additional amount of time after every engine command, equal to the engine_delay parameter, expressed in milliseconds. It practice an engine_delay of 1 ms is usually sufficient. The maximum delay is 100 ms. .sp Note that every additional ms of delay can add up to 14 seconds to the total scanning time (highest resolution), so an as small as possible value is preferred. .sp Default value: 0 .br Minimum: 0 .br Maximum: 100 .sp Example: option engine_delay 1 .SS CCD driver options .TP .B top Number of scanlines to skip to the start of the scan area. The number can be any positive integer. Values known to me are 47 and 56. .sp Default value: 47 .br Minimum: 0 .br Maximum: none .br .sp Example: option top 56 .TP .B waitbank The number of usecs to wait for a bank change. You should not touch this value actually. May be any positive integer .sp Default value: 700 .br Minimum: 0 .br Maximum: none .sp Example: option waitbank 700 .PP A sample configuration file is shown below: .PP .EX # # LifeTec/Medion 9350 on port 0x378 # scanner "LifeTec 9350" 0x378 cis1200 # Some calibration options (examples!). option bw 127 option top_skip \-0.8 # # A Mustek 600CP on port 0x3BC # scanner "Mustek 600CP" 0x3BC cis600 # Some calibration options (examples!). option bw 120 option top_skip 1.2 # # A Mustek 1200CP+ on port 0x278 # scanner "Mustek 1200CP plus" 0x278 cis1200+ # Some calibration options (examples!). option bw 130 option top_skip 0.2 # # A Mustek 600 III EPP on port parport0 # scanner "Mustek 600 III EPP" parport0 ccd300 # Some calibration options (examples!). option bw 130 option top 56 .EE .SH GLOBAL OPTIONS .PP You can control the overall behaviour of the mustek_pp backend by global options which precede any scanner definition in the mustek_pp.conf file. .sp Currently, there is only one global option: .SS Global options .TP .B no_epp Disable parallel port mode EPP: works around a known bug in the Linux parport code. Enable this option, if the backend hangs when trying to access the parallel port in EPP mode. .sp Default value: use EPP .sp Example: option no_epp .SH FILES .TP .I @CONFIGDIR@/mustek_pp.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-mustek_pp.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-mustek_pp.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_MUSTEK_PP If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .EX level debug output -------------------------------------- 0 nothing 1 errors 2 warnings & minor errors 3 additional information 4 debug information 5 code flow (not supported yet) 6 special debug information .EE .TP .B SANE_DEBUG_SANEI_PA4S2 This variable sets the debug level for the SANE interface for the Mustek chipset A4S2. Note that enabling this will spam your terminal with some million lines of debug output. .EX level debug output ---------------------------- 0 nothing 1 errors 2 warnings 3 things nice to know 4 code flow 5 detailed code flow 6 everything .EE .SH "SEE ALSO" sane(7), sane\-mustek(5), sane\-net(5), saned(8), sane\-find\-scanner(1) .TP For latest bug fixes and information see .I http://www.penguin\-breeder.org/sane/mustek_pp/ .TP For additional information on the CIS driver, see .I http://home.scarlet.be/eddy_de_greef/ .SH AUTHORS .nf Jochen Eisinger Eddy De Greef .fi .SH BUGS Too many... please send bug reports to .I sane\-devel@alioth-lists.debian.net (note that you have to subscribe first to the list before you can send emails... see http://www.sane\-project.org/mailing\-lists.html) .SH BUG REPORTS If something doesn't work, please contact us (Jochen for the CCD scanners, Eddy for the CIS scanners). But we need some information about your scanner to be able to help you... .TP .I SANE version run "scanimage \-V" to determine this .TP .I the backend version and your scanner hardware run "SANE_DEBUG_MUSTEK_PP=128 scanimage \-L" as root. If you don't get any output from the mustek_pp backend, make sure a line "mustek_pp" is included into your @CONFIGDIR@/dll.conf. If your scanner isn't detected, make sure you've defined the right port address in your mustek_pp.conf. .TP .I the name of your scanner/vendor also a worthy information. Please also include the optical resolution and lamp type of your scanner, both can be found in the manual of your scanner. .TP .I any further comments if you have comments about the documentation (what could be done better), or you think I should know something, please include it. sane-backends-1.0.29/doc/sane-magicolor.man0000666000000000000000000000534113615534521015346 00000000000000.\" .IX sane-magicolor .TH "sane-magicolor" "5" "10 Jan 2011" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .SH "NAME" sane\-magicolor \- SANE backend for KONICA MINOLTA magicolor scanners .SH "DESCRIPTION" The .B sane\-magicolor backend supports KONICA MINOLTA magicolor scanners connected via USB or LAN. Currently, only the magicolor 1690MF device is supported, no other devices with the same scanning protocol are known. .SH "SUPPORTED DEVICES" The following scanner should work with this backend: Device Details .br \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- .br Vendor: KONICA MINOLTA .br Model: magicolor 1690MF .SH "CONFIGURATION" .PP This section describes the backend's configuration file entries. The file is located at: .IP .I @CONFIGDIR@/magicolor.conf .PP For a proper setup, at least one of the following entries are needed: .IP .I net autodiscovery .br .I net [IP ADDRESS] [DEVICE-ID] .br .I usb .br .I usb [VENDOR-ID] [DEVICE-ID] .SH "FILES" .TP .I @CONFIGDIR@/magicolor.conf The backend configuration file .TP .I @LIBDIR@/libsane\-magicolor.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-magicolor.so The shared library implementing this backend (present on systems that support dynamic loading). .SH "ENVIRONMENT" .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi\-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "/tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_MAGICOLOR If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_MAGICOLOR=127 To obtain debug messages from the backend, set this environment variable before calling your favorite frontend (e.g. xscanimage). Example: SANE_DEBUG_MAGICOLOR=65 xscanimage .SH "KNOWN BUGS AND RESTRICTIONS" .PP Large color scans may sometimes timeout due to unknown reasons (the scanner simply stops returning data) .PP Cancelling large scans may lock up the scanner. .SH "SEE ALSO" .BR sane (7), .br .I http://wiki.kainhofer.com/hardware/magicolor_scan .SH "AUTHOR" .PP Reinhold Kainhofer sane-backends-1.0.29/doc/sane-cardscan.man0000666000000000000000000000612313615534521015147 00000000000000.TH sane\-cardscan 5 "10 Feb 2010" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-cardscan .SH NAME sane\-cardscan \- SANE backend for Corex CardScan usb scanners .SH DESCRIPTION The .B sane\-cardscan library implements a SANE (Scanner Access Now Easy) backend which provides access to the Corex CardScan 800c & 600c small-format scanners. The backend supports only grayscale and color modes and media of (theoretically) infinite length. This backend may support other scanners. The best way to determine level of support is to get a trace of the windows driver in action, and send it to the author. .SH OPTIONS The cardscan backend supports the following options: .PP mode m .RS Selects the mode for the scan. Options are "Gray" and "Color". .RE .PP .SH CONFIGURATION FILE The configuration file "cardscan.conf" is used to tell the backend how to look for scanners, and provide options controlling the operation of the backend. This file is read each time the frontend asks the backend for a list of scanners, generally only when the frontend starts. If the configuration file is missing, the backend will use a set of compiled defaults, which are identical to the default configuration file shipped with SANE. .PP Scanners can be specified in the configuration file in 2 ways: .PP "usb 0x04c5 0x1042" (or other vendor/product ids) .RS Requests backend to search all usb busses in the system for a device which uses that vendor and product id. The device will then be queried to determine if it is a cardscan scanner. .RE .PP "usb /dev/usb/scanner0" (or other device file) .RS Some systems use a kernel driver to access usb scanners. This method is untested. .RE Additionally, there are two configuration options that control the protocol used by the backend: .PP "lines_per_block 16" (or other number from 1 to 32) .RS Controls the number of lines of image data which will be acquired in each pass. Older scanners will require this number set lower, often 1. .RE .PP "has_cal_buffer 1" (1 or 0) .RS Causes the backend to get calibration data from scanner during initialization. Older scanners do not support this request, and must be set to 0. .RE .SH ENVIRONMENT The backend uses a single environment variable, SANE_DEBUG_CARDSCAN, which enables debugging output to stderr. Valid values are: .PP .RS 5 Errors .br 10 Function trace .br 15 Function detail .br 20 Option commands .br 25 SCSI/USB trace .br 30 SCSI/USB detail .br 35 Useless noise .RE .SH KNOWN ISSUES .PP .RS The scanner does not seem to have much control possible, so the backend cannot set x/y coordinate values, resolutions, etc. These things could be simulated in the backend, but there are plenty of command line tools. .br .br The backend also does not send all the commands that the windows driver does, so it may not function the same. .br .br The backend does not have the calibration or ejection options of the windows driver. .br .br .RE .SH CREDITS The hardware to build this driver was provided to the author by: Jeff Kowalczyk .SH "SEE ALSO" sane(7), sane\-usb(5) .SH AUTHOR m. allan noah: sane-backends-1.0.29/doc/sane-coolscan3.man0000666000000000000000000001500313615534521015252 00000000000000.TH sane\-coolscan3 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-coolscan3 .SH NAME sane\-coolscan3 \- SANE backend for Nikon Coolscan film scanners .SH DESCRIPTION The .B sane\-coolscan3 library implements a SANE (Scanner Access Now Easy) backend that provides access to Nikon Coolscan film scanners. Some functions of this backend should be considered .B beta-quality software. Most functions have been stable for a long time, but of course new development can not and will not function properly from the very first day. .PP At present, the following scanners are known to work with this backend: .PP .RS .ft CR .nf Model: Connection Type --------------------------- ------------------- LS-30 (Coolscan III) SCSI LS-40 ED (Coolscan IV) USB LS-50 ED (Coolscan V) USB LS-2000 SCSI LS-4000 ED IEEE 1394 LS-8000 ED IEEE 1394 .fi .ft R .RE Please send mail to sane-devel@alioth-lists.debian.net to report successes or failures. .SH OPTIONS The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage or xsane. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d coolscan3:: .RE where and specify the device in question, as in the configuration file (see next section). The \-d parameter and its argument can be omitted to obtain information on the first scanner identified. Use the command .RS scanimage \-L .RE to list all devices recognized by your SANE installation. The options should be fully described by the description or tooltips given by frontend. Here is a description of some of the most important options, in the syntax with which they must be supplied to scanimage: .TP .I \-\-frame This option specifies which frame to operate on, if a motorized film strip feeder or APS adapter are used. The frame number .I ranges from 1 to the number of frames available, which is sensed each time the backend is initialized (usually each time you start the frontend). .TP .I \-\-subframe This option shifts the scan window by the specified amount (default unit is mm). .TP .I \-\-infrared=yes/no If set to "yes", the scanner will read the infrared channel, thus allowing defect removal in software. The infrared image is read during a second scan, with no options altered. The backend must not be restarted between the scans. If you use scanimage, perform a batch scan with batch\-count=2 to obtain the IR information. .TP .I \-\-depth Here can either be 8 or the maximum number of bits supported by the scanner (10, 12, or 14). It specifies whether or not the scanner reduces the scanned data to 8 bits before sending it to the backend. If 8 bits are used, some information and thus image quality is lost, but the amount of data is smaller compared to higher depths. Also, many imaging programs and image formats cannot handle depths greater than 8 bits. .TP .I \-\-autofocus Perform autofocus operation. Unless otherwise specified by the other options ( .I \-\-focus\-on\-centre and friends), focusing is performed on the centre of the selected scan area. .TP .I \-\-ae\-wb .TP .I \-\-ae Perform a pre-scan to calculate exposure values automatically. .I \-\-ae\-wb will maintain the white balance, while .I \-\-ae will adjust each channel separately. .TP .I \-\-exposure Multiply all exposure times with this value. This allows exposure correction without modifying white balance. .TP .I \-\-load Load the next slide when using the slide loader. .TP .I \-\-eject Eject the film strip or mounted slide when using the slide loader. .TP .I \-\-reset Reset scanner. The scanner will perform the same action as when power is turned on: it will eject the film strip and calibrate itself. Use this whenever the scanner refuses to load a film strip properly, as a result of which .I \-\-eject does not work. .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/coolscan3.conf specifies the device(s) that the backend will use. Owing to the nature of the supported connection types SCSI, USB, and IEEE 1394, the default configuration file supplied with the SANE distribution should work without being edited. Each line in the configuration file is either of the following, where all entries are case-sensitive: .TP .I blank or starting with a '#' character These lines are ignored, thus '#' can be used to include comments. .TP .I containing only the word """auto""" This instructs the backend to probe for a scanner by scanning the buses for devices with know identifiers. This is the action taken when no configuration file is present. .TP .I a line of the form : Here can be one of "scsi" or "usb", and is the device file of the scanner. Note that IEEE 1394 devices are handled by the SBP-2 module in the kernel and appear to SANE as SCSI devices. .SH FILES .TP .I @LIBDIR@/libsane\-coolscan3.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-coolscan3.so The shared library implementing this backend (present on systems that support dynamic loading). .TP .I @CONFIGDIR@/coolscan3.conf Configuration file for this backend, read each time the backend is initialized. .SH ENVIRONMENT .TP .B SANE_DEBUG_COOLSCAN3 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH "SEE ALSO" sane\-scsi(5), sane\-usb(5), scanimage(1), xscanimage(1), xsane(1) .SH BUGS Currently, the SANE protocol does not allow automatically updating options whenever the hardware changes. Thus the number of choices for the .B \-\-frame option will be fixed when the backend is initialized (usually when the user runs the frontend). In particular, if there is no film strip in the automatic film strip feeder when the backend is initialized, the frame option will not appear at all. Also, restarting the frontend after swapping film adapters is strongly recommended. Linux kernels prior to 2.4.19 had a patch that truncated INQUIRY data from IEEE 1394 scanners to 36 bytes, discarding vital information about the scanner. The IEEE 1394 models therefore only work with 2.4.19 or later. No real bugs currently known, please report any to the SANE developers' list. .SH AUTHORS coolscan3 written by A. Zummo (a.zummo@towertech.it), based heavily on coolscan2 written by Andr\['a]s Major (andras@users.sourceforge.net). sane-backends-1.0.29/doc/teco/0000755000000000000000000000000013615535552012761 500000000000000sane-backends-1.0.29/doc/teco/teco1.txt0000666000000000000000000001255713615534521014466 00000000000000 BACKEND TECO1 Relisys RELI 2412 (no ADF, no transparency adapter) single pass scanner - 300*1200 dpi - 8.5*14 Inquiry: 000: 06 00 02 02 30 00 00 10 52 45 4c 49 53 59 53 20 ....0...RELISYS 016: 56 4d 33 35 33 30 2b 20 20 20 20 20 20 20 20 20 VM3530+ 032: 31 2e 30 38 31 2e 30 38 02 00 54 45 43 4f 20 56 1.081.08..TECO V 048: 4d 33 35 33 41 M353A Inquiry page 0x82 000: 06 82 00 12 11 54 45 43 4f 20 56 4d 33 35 33 41 .....TECO VM353A 016: 20 56 31 2e 30 36 V1.06 AVEC Colour 2412 three pass scanner - 300*600 dpi - 8.5*14 000: 06 00 02 02 30 00 00 10 20 20 20 20 20 20 20 20 ....0... 016: 49 6d 61 67 65 20 53 63 61 6e 6e 65 72 20 20 20 Image Scanner 032: 31 2e 30 38 31 2e 30 38 02 00 54 45 43 4f 20 56 1.081.08..TECO V 048: 4d 33 35 32 41 M352A Avec Color Office 2400 (no ADF, no transparency adapter) three pass scanner - 300*600 dpi - 8.5*14 Inquiry: 000: 06 00 02 02 30 00 00 10 20 20 20 20 20 20 20 20 ....0... 016: 49 6d 61 67 65 20 53 63 61 6e 6e 65 72 20 20 20 Image Scanner 032: 32 2e 30 34 32 2e 30 34 02 00 54 45 43 4f 20 56 2.042.04..TECO V 048: 4d 33 35 32 30 M3520 Inquiry page 0x82 000: 06 82 00 12 11 54 45 43 4f 20 56 4d 33 35 32 30 .....TECO VM3520 016: 20 56 32 2e 30 34 V2.04 RELI 4830 (no ADF, with transparency adapter) 000: 06 00 02 02 30 00 00 10 52 45 4c 49 53 59 53 20 ....0...RELISYS 016: 52 45 4c 49 20 34 38 33 30 20 20 20 20 20 20 20 RELI 4830 032: 31 2e 30 33 31 2e 30 33 02 00 54 45 43 4f 20 56 1.031.03..TECO V 048: 4d 34 35 34 32 M4542 Inquiry page 0x82 000: 06 82 00 12 11 54 45 43 4f 20 56 4d 34 35 34 32 .....TECO VM4542 016: 20 56 31 2e 30 33 V1.03 Dextra DF-600P - VM3510 000: 06 00 02 02 24 00 00 10 44 46 2D 36 30 30 4D 20 ....$...DF-600M 016: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 032: 31 2E 31 37 31 2E 31 37 02 1.171.17. /*--------------------------------------------------------------------------*/ SCSI commands supported by the RELISYS VM3530+: TEST UNIT READY 00 00 00 00 00 00 REQ SENSE 03 00 00 00 12 00 VENDOR-09 09 00 00 78 00 00 3-4 = length of data to receive. Always 30720 bytes. Probably 12 lines of calibration at 300dpi. 8.5*300*12=30600 VENDOR-0E (?) 0E 00 00 00 00 00 Always follows VENDOR-09 command INQUIRY: 12 00 00 00 35 00 12 01 82 00 21 00 standard inquiry 52 bytes - appears to never change 32-39: firmware version 42-52: real scanner name page 0x82 (vendor specific) - real scanner name with version 0-3 = page header 4 = string length 5-21 = real scanner name with version MODE SELECT 15 10 00 00 18 00 always sends: 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 01 03 06 02 00 00 01 00 00 SCAN 1B 00 00 00 00 00 SET WINDOW 24 00 00 00 00 00 00 00 63 00 Total length is 99 07 = length (99-8 = 91) 10-11 = X Resolution 12-13 = Y resolution 14-17 = X top left corner 18-21 = Y top left corner 22-25 = width (size in inches * 300) 26-29 = length (size in inches * 300) 31 = 0x80 ? 33 = scan mode 0x00 = black & white 0x02 = grayscale 0x05 = color 34 = bit depth? - invariants, always 8 36 = dither pattern - only for B&W 0x00 = line art 0x01 = 2 X 2 0x02 = 3 X 3 0x03 = 4 X 4 Bayer 0x04 = 4 X 4 Smooth 0x05 = 8 X 8 Bayer 0x06 = 8 X 8 Smooth 0x07 = 8 X 8 Horizontal 0x08 = 8 X 8 Vertical 37 = 0x80 = RIF (VM353A only?) 63 = calibration? 0x00 yes 0x02 no 81 = ??? transparency adapter 0x00 no 0x01 yes 93 = 0x80 = ? (seems to activate a contrast value on VM353A) 37, 55, 57, 59, 61, 65, 67, 69, 71, 73, 75, 77, 79 = 0x80 85, 89, 93, 97 = 0xff READ 28 00 00 00 00 00 00 00 3E 00 6-8 = length SEND 2A 00 03 00 00 02 00 04 00 00 2 = data type code 0x03 = gamma - 4*256 bytes GET DATA BUFFER STATUS 34 01 00 00 00 00 00 00 12 00 1 = bit 1 is wait 7-8 allocation length returned buffer is 0x10 bytes long. 0-2 = additional length (0x10-3 = 0x0D) 3 = reserved(?) 8 = ? 9-11 = filled data buffer 12-13 = number of lines (constant during a scan) 14-15 = bytes per line (constant during a scan) /*--------------------------------------------------------------------------*/ Command sequence (simplified, since the TWAIN driver seems to be quite stupid) Get some info: INQUIRY INQUIRY page 0x82 Setup the scan: TUR MODE SELECT SET WINDOWS GET BUFFER STATUS VENDOR-09 VENDOR-0E SEND(10) SET WINDOWS (same as the first one) SCAN loop until all data read: GET BUFFER STATUS READ(10) if any data available park the CCD: SET WINDOWS SCAN /*--------------------------------------------------------------------------*/ The vendor specific command 0x09 and 0x0e are issued by the windows driver to the AVEC 2400, but the scanner rejects them. /*--------------------------------------------------------------------------*/ The Dextra DF600-P is a VM3510. It's older than the other scanner and is a little more primitive. The driver recognizes its scsi id and fake a more evolved one. The scan sequence is also simplified. The rest is identical. sane-backends-1.0.29/doc/teco/teco3.txt0000666000000000000000000001076313615534521014465 00000000000000 BACKEND TECO3 This scanner capabilities are in the middle of the 3520 and 3575, sharing features of both. Hence a third backend. PIOTECH 3024 (TECO Scorpio/Taurus Infinity VM3552): 000: 06 00 02 02 43 00 00 10 20 20 20 20 20 20 20 20 ....C... 016: 46 6c 61 74 2d 62 65 64 20 73 63 61 6e 6e 65 72 Flat-bed scanner 032: 35 2e 30 38 35 2e 30 38 03 02 54 45 43 4f 20 56 5.085.08..TECO V 048: 4d 33 35 35 32 20 00 01 01 2c 00 01 04 b0 09 f6 M3552 ...,...... 064: 10 68 01 2c 00 00 00 01 .h.,.... RELISYS INFINiTY SCORPIO: 000: 06 00 02 02 43 00 00 10 52 45 4c 49 53 59 53 20 ....C...RELISYS 016: 53 63 6f 72 70 69 6f 20 20 20 20 20 20 20 20 20 Scorpio 032: 31 2e 30 34 31 2e 30 34 03 02 54 45 43 4f 20 56 1.041.04..TECO V 048: 4d 33 35 35 32 20 00 01 01 2c 00 01 04 b0 09 f6 M3552 ...,...... 064: 10 68 01 2c 00 00 00 00 .h.,.... Trust Imagery 2400SP: 000: 06 00 02 02 43 00 00 10 41 61 73 68 69 6d 61 20 ....C...Aashima 016: 49 4d 41 47 45 52 59 20 32 34 30 30 53 50 20 20 IMAGERY 2400SP 032: 31 2e 30 30 31 2e 30 30 03 02 54 45 43 4f 20 56 1.001.00..TECO V 048: 4d 33 35 35 32 20 00 01 01 2c 00 01 04 b0 09 f6 M3552 ...,...... 064: 10 68 01 2c 00 00 00 01 .h.,.... Trust Imagery 4800 SP +: 000: 06 00 02 02 43 00 00 10 41 61 73 68 69 6d 61 20 ....C...Aashima 016: 49 4d 41 47 45 52 59 20 34 38 30 30 53 50 20 2b IMAGERY 4800SP + 032: 35 2e 30 38 35 2e 30 38 03 02 54 45 43 4f 20 56 5.085.08..TECO V 048: 4d 33 35 35 32 20 00 01 01 2c 00 01 04 b0 09 f6 M3552 ...,...... 064: 10 68 01 2c 00 00 00 00 .h.,.... /*--------------------------------------------------------------------------*/ SCSI commands supported by the RELISYS VM3530+: TEST UNIT READY 00 00 00 00 00 00 REQ SENSE 03 00 00 00 12 00 VENDOR-09 09 00 00 78 00 00 3-4 = length of data to receive. Always 30720 bytes. Probably 12 lines of calibration at 300dpi. 8.5*300*12=30600 VENDOR-0E (?) 0E 00 00 00 00 00 Always follows VENDOR-09 command INQUIRY: 12 00 00 00 35 00 standard inquiry 52 bytes - appears to never change 32-39: firmware version 42-52: real scanner name SCAN 1B 00 00 00 00 00 SET WINDOW 24 00 00 00 00 00 00 00 45 00 (3552) Total length is 99 07 = length (99-8 = 91) 10-11 = X Resolution 12-13 = Y resolution 14-17 = X top left corner 18-21 = Y top left corner 22-25 = width (size in inches * 300) 26-29 = length (size in inches * 300) 31 = 0x80 ? 33 = scan mode 0x00 = black & white 0x02 = grayscale 0x05 = color 34 = bit depth? - invariants, always 8 36 = dither pattern - only for B&W 0x00 = line art 0x01 = 2 X 2 0x02 = 3 X 3 0x03 = 4 X 4 Bayer 0x04 = 4 X 4 Smooth 0x05 = 8 X 8 Bayer 0x06 = 8 X 8 Smooth 0x07 = 8 X 8 Horizontal 0x08 = 8 X 8 Vertical 37 = 0x80 = RIF ? 48 = color channel to use if scan mode is 0 or 2: 0x00 = red 0x01 = green 0x02 = blue if scan mode is 05 -> ignored TWAIN leaves 0x02 50: calibration 00 = yes 02 = no 53, 57, 61, 65: 0xff READ 28 00 00 00 00 00 00 00 3E 00 6-8 = length SEND 2A 00 03 00 00 02 00 04 00 00 2 = data type code 0x03 = gamma - 4*256 bytes OBJECT POSITION 31 00 00 00 00 00 00 00 00 00 Park the CCD. GET DATA BUFFER STATUS 34 01 00 00 00 00 00 00 12 00 1 = bit 1 is wait 7-8 allocation length returned buffer is 0x10 bytes long. 0-2 = additional length (0x10-3 = 0x0D) 3 = reserved(?) 6-8 = scanner memory (with no RAM, it is 32KB on the VM3552) 9-11 = filled data buffer 12-13 = number of lines (constant during a scan) 14-15 = bytes per line (constant during a scan) 16 = ? 17 = in color mode, 0x07 seems to means to the colors are shifted and given by rasters. 0x00 seems to mean that there is no color shifting and that each pixel is coded by 3 consecutive bytes. /*--------------------------------------------------------------------------*/ Command sequence (simplified, since the TWAIN driver seems to be quite stupid) Get some info: INQUIRY Setup the scan: TUR SET WINDOWS GET BUFFER STATUS VENDOR-09 VENDOR-0E SEND(10) SET WINDOWS (same as the first one) SCAN loop until all data read: GET BUFFER STATUS READ(10) if any data available park the CCD: OBJECT POSITION /*--------------------------------------------------------------------------*/ sane-backends-1.0.29/doc/teco/teco2.txt0000666000000000000000000001730313615534521014461 00000000000000 BACKEND TECO2 INQUIRY TECO VM3564 (1) 000: 06 00 02 02 43 00 00 10 52 45 4c 49 53 59 53 20 ....C...RELISYS 016: 41 56 45 43 20 49 49 20 53 33 20 20 20 20 20 20 AVEC II S3 032: 31 2e 30 37 31 2e 30 37 00 01 54 45 43 4f 20 56 1.071.07..TECO V 048: 4d 33 35 36 34 20 00 01 01 2c 00 01 02 58 09 f6 M3564 ...,...X.. 064: 0d af 01 2c 00 08 01 00 ...,.... TECO VM3564 (2) 000: 06 00 02 02 43 00 00 10 52 45 4c 49 53 59 53 20 ....C...RELISYS 016: 41 56 45 43 20 49 49 20 53 33 20 20 20 20 20 20 AVEC II S3 032: 31 2e 30 39 31 2e 30 39 00 01 54 45 43 4f 20 56 1.091.09..TECO V 048: 4d 33 35 36 34 20 00 01 01 2c 00 01 02 58 09 f6 M3564 ...,...X.. 064: 0d af 01 2c 00 08 01 00 ...,.... TECO VM356A (1) 000: 06 00 02 02 43 00 00 00 52 45 4c 49 53 59 53 20 ....C...RELISYS 016: 41 50 4f 4c 4c 4f 20 45 78 70 72 65 73 73 20 33 APOLLO Express 3 032: 31 2e 30 33 31 2e 30 33 00 01 54 45 43 4f 20 56 1.031.03..TECO V 048: 4d 33 35 36 41 20 00 01 01 2c 00 01 02 58 09 f6 M356A ...,...X.. 064: 0d af 01 2c 00 08 01 00 ...,.... TECO VM356A (2) 000: 06 00 02 02 43 00 00 10 50 72 69 6d 61 78 20 20 ....C...Primax 016: 4a 65 77 65 6c 20 20 20 20 20 20 20 20 20 20 20 Jewel 032: 31 2e 30 31 31 2e 30 31 00 01 54 45 43 4f 20 56 1.011.01..TECO V 048: 4d 33 35 36 41 20 00 01 01 2c 00 01 02 58 09 f6 M356A ...,...X.. 064: 0d af 01 2c 00 08 01 00 ...,.... TECO VM3575 000: 06 00 02 02 43 00 00 00 20 20 20 20 20 20 20 20 ....C... 016: 46 6c 61 74 62 65 64 20 53 63 61 6e 6e 65 72 20 Flatbed Scanner 032: 31 2e 30 33 31 2e 30 33 00 01 54 45 43 4f 20 56 1.031.03..TECO V 048: 4d 33 35 37 35 20 00 01 01 2c 00 01 02 58 09 f6 M3575 ...,...X.. 064: 0d af 01 2c 00 08 01 00 ...,.... TECO VM656A 000: 06 00 02 02 43 00 00 00 52 45 4c 49 53 59 53 20 ....C...RELISYS 016: 41 50 4f 4c 4c 4f 20 45 78 70 72 65 73 73 20 36 APOLLO Express 6 032: 31 2e 30 33 31 2e 30 33 00 01 54 45 43 4f 20 56 1.031.03..TECO V 048: 4d 36 35 36 41 00 01 01 2c 00 01 02 58 09 f6 0d M656A...,...X... 064: af 01 2c 00 08 01 00 00 ..,..... TECO VM6575 000: 06 00 02 02 43 00 00 10 52 45 4c 49 53 59 53 20 ....C...RELISYS 016: 53 43 4f 52 50 49 4f 20 50 72 6f 20 20 20 20 20 SCORPIO Pro 032: 31 2e 30 31 31 2e 30 31 00 01 54 45 43 4f 20 56 1.011.01..TECO V 048: 4d 36 35 37 35 20 00 01 01 2c 00 01 02 58 09 f6 M6575 ...,...X.. 064: 0d af 01 2c 00 08 01 00 ...,.... TECO VM6586 000: 06 00 02 02 43 00 00 00 20 20 20 20 20 20 20 20 ....C... 016: 46 6c 61 74 62 65 64 20 53 63 61 6e 6e 65 72 20 Flatbed Scanner 032: 33 2e 30 31 33 2e 30 31 00 01 54 45 43 4f 20 56 3.013.01..TECO V 048: 4d 36 35 38 36 20 00 01 01 2c 00 01 02 58 09 f6 M6586 ...,...X.. 064: 0d af 01 2c 00 08 01 00 ...,.... /*--------------------------------------------------------------------------*/ SCSI Commands supported by the TECO VM3575: REQUEST SENSE 03 00 00 00 12 00 VENDOR-06 ??? Receives 4 bytes of data VENDOR-9 Get calibration lines - 12 lines 2 = ? 0x00 color scan 0x01 grayscal scan 0x02 b&w scan Returns 6 bytes per pixel, probably 2 bytes per color in little endian order. (2550 * 6 = 15300) VENDOR-0C ??? Unsupported? VENDOR-0E Set calibration. Apparently the line is computed from the calibration lines. It is not an average though. INQUIRY 12 00 00 00 48 00 standard inquiry 72 bytes 32-39: firmware version 42-52: real scanner name 54-55: min X resolution 56-57: max X resolution 58-59: min Y resolution 60-61: max Y resolution 62-63: scan area length 64-65: scan area width 66-67: unit for scan area (eg 300th of inch) eg if 62-63 = 2550 and 66-67 = 300, the length is 2550/300=8.5 inches. SCAN 1B 00 00 00 00 00 VENDOR-1C 1c 00 00 00 00 00 (Same opcode as RECEIVE DIAGNOSTIC RESULTS) sends 4 bytes of data. SET WINDOW 24 00 00 00 00 00 00 00 35 00 (VM3575) 24 00 00 00 00 00 00 00 38 00 (VM6586) Total length is 07 = length VM3575 53-8 = 45 VM6586 56-8 = 48 VM3552 69-8 = 61 10-11 = X Resolution 12-13 = Y resolution 14-17 = X top left corner 18-21 = Y top left corner 22-25 = width (size in inches * 300) 26-29 = length (size in inches * 300) 31 = 0x80 ? 33 = scan mode 0x00 = black & white 0x02 = grayscale 0x05 = color 34 = bit depth? - invariant, always 8 36 = (vm6586 only ?) halftone pattern ? 1 = type 1 dithering 37 = 0x80 = RIF? 48 = color channel to use if scan mode is 0 or 2: 0x00 = red 0x01 = green 0x02 = blue if scan mode is 05 -> ignored TWAIN leaves 0x02 50 = ? VM6585 only: 52-53 = size of a line expected? 54-55 = number of lines expected? READ 28 00 00 00 00 19 00 1f 0e 00 5 = number of lines to read 7-8 = buffer size. Always number of lines to read * size of a line. 0x2000 appears to be the upper limit SEND 2A 00 03 00 00 04 00 0C 00 00 2 = data type code 0x03 = gamma 4-5 = data type qualifier (?) 6-8 = length (0xc00 = 3276 = 3*2^10) or: 5-6: length of each gamma 7-8: length of all gamma OBJECT POSITION 31 00 00 00 00 00 00 00 00 00 Park the CCD. GET DATA BUFFER STATUS 34 01 00 00 00 00 00 00 12 00 1 = bit 1 is wait 7-8 = allocation length returned buffer is 0x12 bytes long. 00 00 0f 00 00 00 00 14 00 00 00 80 1b 6c 09 f6 05 05 0-2 = additional length (0x12-3 = 0x0F) 7 = ? always 0x14 11 = bit 7 - (maybe) scanner is ready to send data 12-13 = number of lines (constant during a scan) 14-15 = bytes per line (constant during a scan) 16-17 = garbage (the command only returns 0x10 bytes) /*--------------------------------------------------------------------------*/ Scan sequence Get some info: INQUIRY Setup the scan: REQUEST SENSE TUR SET WINDOWS GET BUFFER STATUS VENDOR-0C VENDOR-09 (read calibration) VENDOR-0E (send new calibration) REQUEST SENSE SEND(10) SET WINDOWS (same as the first one) COMMAND 06 RECEIVE DIAGNOSTIC RESULTS SCAN GET BUFFER STATUS loop until all data read: READ(10) park the CCD: OBJECT POSITION /*--------------------------------------------------------------------------*/ calibration TECO VM3575 reads 12 lines of calibration TECO VM656A reads 8 lines of calibration TECO VM6586 ?? Algorithms used (text from Alex Wulms): The old algorithm was based on the assumption that the calibration value needs to be an offset, to go from the value obtained during input to the average value (0x800). E.g., if the input value is 0x800, the calibration value must be 0x800 (0x1000 - 0x800). Likewise, if the input value is 0x700, the calibration value must be 0x900 (0x1000 - 0x700) And if the input value is 0x600, the calibration value must be 0xA00 The new algorithm is based on the assumption that the calibration needs to be a multiplication factor, to compensate for the too strong or too weak pixel in the sensor. Again, we want to obtain the average value (approximately 0x800) for every pixel read during calibration. E.g., if the input value is 0x800, the calibration value must be 0x800 (0x800*0x800 / 0x800). Likewise, if the input value is 0x700, the calibration value must be 0x924 (0x800*0x800 / 0x700). And if the input value is 0x600, the calibration value must 0xAAA (0x800*0x800 / 0x600) Though, carefull comparison with scans done under windows has shown that the factor is slightly different from 0x800*0x800(=0x400000) but in stead it seems to be approximately 0x40302f (which would mean that the average value is approximately 0x803 in stead of 0x800). Hope this is clarifies the new algorithm. sane-backends-1.0.29/doc/sane.man0000666000000000000000000006347313615534521013406 00000000000000.TH sane 7 "03 Jan 2020" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane .SH NAME sane \- Scanner Access Now Easy: API for accessing scanners .SH DESCRIPTION .B SANE is an application programming interface (API) that provides standardized access to any raster image scanner hardware. The standardized interface makes it possible to write just one driver for each scanner device instead of one driver for each scanner and application. While .B SANE is primarily targeted at a UNIX environment, the standard has been carefully designed to make it possible to implement the API on virtually any hardware or operating system. .PP This manual page provides a summary of the information available about .BR SANE . .PP If you have trouble getting your scanner detected, read the PROBLEMS section. .SH TERMINOLOGY An application that uses the .B SANE interface is called a .B SANE frontend. A driver that implements the .B SANE interface is called a .B SANE backend. A .B meta backend provides some means to manage one or more other backends. .SH "SOFTWARE PACKAGES" The package .RB ` sane\-backends ' contains a lot of backends, documentation (including the .B SANE standard), networking support, and the command line frontend .RB ` scanimage '. The frontends .RB ` xscanimage "', `" xcam "', and `" scanadf ' are included in the package .RB ` sane\-frontends '. Both packages can be downloaded from the .B SANE homepage .RI ( http://www.sane\-project.org/ ). Information about other frontends and backends can also be found on the .B SANE homepage. .SH "GENERAL INFORMATION" The following sections provide short descriptions and links to more information about several aspects of .B SANE. A name with a number in parenthesis (e.g. .RB ` sane\-dll (5)') points to a manual page. In this case .RB ` "man 5 sane\-dll" ' will display the page. Entries like .RI ` @DOCDIR@/sane.tex ' are references to text files that were copied to the .B SANE documentation directory .RI ( @DOCDIR@/ ) during installation. Everything else is a URL to a resource on the web. .TP 2 .B SANE homepage Information on all aspects of SANE including a tutorial and a link to the SANE FAQ can be found on the SANE homepage: .IR http://www.sane\-project.org/ . .TP .B SANE device lists The .B SANE device lists contain information about the status of .B SANE support for a specific device. If your scanner is not listed there (either supported or unsupported), please contact us. See section HOW CAN YOU HELP SANE for details. There are lists for specific releases of SANE, for the current development version and a search engine: .IR http://www.sane\-project.org/sane\-supported\-devices.html . The lists are also installed on your system at @DOCDIR@/. .TP .B SANE mailing list There is a mailing list for the purpose of discussing the SANE standard and its implementations: sane\-devel. Despite its name, the list is not only intended for developers, but also for users. There are also some more lists for special topics, however, for users, sane\-devel is the right list. How to subscribe and unsubscribe: .IR http://www.sane\-project.org/mailing\-lists.html . .TP .B SANE IRC channel The IRC (Internet Relay Chat) channel #sane can be found on the Freenode network (irc.freenode.net). It's for discussing .B SANE problems, talking about development and general .B SANE related chatting. Before asking for help, please read the other documentation mentioned in this manual page. The channel's topic is also used for announcements of problems with SANE infrastructure (mailing lists, web server, etc.). .TP .B Compiling and installing SANE Look at .I @DOCDIR@/README and the os-dependent README files for information about compiling and installing .B SANE. .TP .B SCSI configuration For information about various systems and SCSI controllers see .BR sane\-scsi (5). .TP .B USB configuration For information about USB configuration see .BR sane\-usb (5). .SH "FRONTENDS AND MISCELLANEOUS PROGRAMS" .TP 2 .B scanimage Command-line frontend. See .BR scanimage (1). .TP .B saned .B SANE network daemon that allows remote clients to access image acquisition devices available on the local host. See .BR saned (8). .TP .B sane\-find\-scanner Command-line tool to find SCSI and USB scanners and determine their Unix device files. See .BR sane\-find\-scanner (1). .PP Also, have a look at the .B sane\-frontends package (including .BR xscanimage ", " xcam ", and " scanadf ) and the frontend information page at .IR http://www.sane\-project.org/sane\-frontends.html . .SH "BACKENDS FOR SCANNERS" .TP 2 .B abaton The SANE backend for Abaton flatbed scanners supports the Scan 300/GS (8bit, 256 levels of gray) and the Scan 300/S (black and white, untested). See .BR sane\-abaton (5) for details. .TP .B agfafocus This backend supports AGFA Focus scanners and the Siemens S9036 (untested). See .BR sane\-agfafocus (5) for details. .TP .B apple The SANE backend for Apple flatbed scanners supports the following scanners: AppleScanner, OneScanner and ColorOneScanner. See .BR sane\-apple (5) for details. .TP .B artec The SANE Artec backend supports several Artec/Ultima SCSI flatbed scanners as well as the BlackWidow BW4800SP and the Plustek 19200S. See .BR sane\-artec (5) for details. .TP .B artec_eplus48u The SANE artec_eplus48u backend supports the scanner Artec E+ 48U and re-badged models like Tevion MD 9693, Medion MD 9693, Medion MD 9705 and Trust Easy Webscan 19200. See .BR sane\-artec_eplus48u (5) for details. .TP .B as6e This is a SANE backend for using the Artec AS6E parallel port interface scanner. See .BR sane\-as6e (5) for details. .TP .B avision This backend supports several Avision based scanners. This includes the original Avision scanners (like AV 630, AV 620, ...) as well as the HP ScanJet 53xx and 74xx series, Fujitsu ScanPartner, some Mitsubishi and Minolta film-scanners. See .BR sane\-avision (5) for details. .TP .B bh The bh backend provides access to Bell+Howell Copiscan II series document scanners. See .BR sane\-bh (5) for details. .TP .B canon The canon backend supports the CanoScan 300, CanoScan 600, and CanoScan 2700F SCSI flatbed scanners. See .BR sane\-canon (5) for details. .TP .B canon630u The canon630u backend supports the CanoScan 630u and 636u USB scanners. See .BR sane\-canon630u (5) for details. .TP .B canon_dr The canon_dr backend supports the Canon DR-Series ADF SCSI and USB scanners. See .BR sane\-canon_dr (5) for details. .TP .B canon_pp The canon_pp backend supports the CanoScan FB330P, FB630P, N340P and N640P parallel port scanners. See .BR sane\-canon_pp (5) for details. .TP .B cardscan This backend provides support for Corex Cardscan USB scanners. See .BR sane\-cardscan (5) for details. .TP .B coolscan This is a SANE backend for Nikon Coolscan film-scanners. See .BR sane\-coolscan (5) for details. .TP .B coolscan2 This is a SANE backend for Nikon Coolscan film-scanners. See .BR sane\-coolscan2 (5) for details. .TP .B epjitsu The epjitsu backend provides support for Epson-based Fujitsu USB scanners. See .BR sane\-epjitsu (5) for details. .TP .B epson The SANE epson backend provides support for Epson SCSI, parallel port and USB flatbed scanners. See .BR sane\-epson (5) for details. .TP .B fujitsu The fujitsu backend provides support for most Fujitsu SCSI and USB, flatbed and adf scanners. See .BR sane\-fujitsu (5) for details. .TP .B genesys The genesys backend provides support for several scanners based on the Genesys Logic GL646, GL841, GL843, GL847 and GL124 chips like the Medion 6471 and Hewlett-Packard 2300c. See .BR sane\-genesys (5) for details. .TP .B gt68xx The gt68xx backend provides support for scanners based on the Grandtech GT-6801 and GT-6816 chips like the Artec Ultima 2000 and several Mustek BearPaw CU and TA models. Some Genius, Lexmark, Medion, Packard Bell, Plustek, and Trust scanners are also supported. See .BR sane\-gt68xx (5) for details. .TP .B hp The SANE hp backend provides access to Hewlett-Packard ScanJet scanners which support SCL (Scanner Control Language by HP). See .BR sane\-hp (5) for details. .TP .B hpsj5s The SANE backend for the Hewlett-Packard ScanJet 5S scanner. See .BR sane\-hpsj5s (5) for details. .TP .B hp3500 The SANE backend for the Hewlett-Packard ScanJet 3500 series. See .BR sane\-hp3500 (5) for details. .TP .B hp3900 The SANE backend for the Hewlett-Packard ScanJet 3900 series. See .BR sane\-hp3900 (5) for details. .TP .B hp4200 The SANE backend for the Hewlett-Packard ScanJet 4200 series. See .BR sane\-hp4200 (5) for details. .TP .B hp5400 The SANE backend for the Hewlett-Packard ScanJet 54XXC series. See .BR sane\-hp5400 (5) for details. .TP .B hpljm1005 The SANE backend for the Hewlett-Packard LaserJet M1005 scanner. See .BR sane\-hpljm1005(5) for details. .TP .B hs2p The SANE backend for the Ricoh IS450 family of SCSI scanners. See .BR sane\-hs2p (5) for details. .TP .B ibm The SANE backend for some IBM and Ricoh SCSI scanners. See .BR sane\-ibm (5) for details. .TP .B kodak The SANE backend for some large Kodak scanners. See .BR sane\-kodak (5) for details. .TP .B kodakaio The SANE backend for Kodak AiO printer/scanners. See .BR sane\-kodakaio (5) for details. .TP .B kvs1025 The SANE backend for Panasonic KV-S102xC scanners. See .BR sane\-kvs1025 (5) for details. .TP .B leo This backend supports the Leo S3 and the Across FS-1130, which is a re-badged LEO FS-1130 scanner. See .BR sane\-leo (5) for details. .TP .B lexmark This backend supports the Lexmark X1100 series of USB scanners. See .BR sane\-lexmark (5) for details. .TP .B ma1509 The ma1509 backend supports the Mustek BearPaw 1200F USB flatbed scanner. See .BR sane\-ma1509 (5) for details. .TP .B magicolor The magicolor backend supports the KONICA MINOLTA magicolor 1690MF multi-function printer/scanner/fax. See .BR sane\-magicolor (5) for details. .TP .B matsushita This backend supports some Panasonic KVSS high speed scanners. See .BR sane\-matsushita (5) for details. .TP .B microtek The microtek backend provides access to the "second generation" Microtek scanners with SCSI-1 command set. See .BR sane\-microtek (5) for details. .TP .B microtek2 The microtek2 backend provides access to some Microtek scanners with a SCSI-2 command set. See .BR sane\-microtek2 (5) for details. .TP .B mustek The SANE mustek backend supports most Mustek SCSI flatbed scanners including the Paragon and ScanExpress series and the 600 II N and 600 II EP (non-SCSI). Some Trust scanners are also supported. See .BR sane\-mustek (5) for details. .TP .B mustek_pp The mustek_pp backend provides access to Mustek parallel port flatbed scanners. See .BR sane\-mustek_pp (5) for details. .TP .B mustek_usb The mustek_usb backend provides access to some Mustek ScanExpress USB flatbed scanners. See .BR sane\-mustek_usb (5) for details. .TP .B mustek_usb2 The mustek_usb2 backend provides access to scanners using the SQ113 chipset like the Mustek BearPaw 2448 TA Pro USB flatbed scanner. See .BR sane\-mustek_usb2 (5) for details. .TP .B nec The SANE nec backend supports the NEC PC-IN500/4C SCSI scanner. See .BR sane\-nec (5) for details. .TP .B niash The niash backend supports the Agfa Snapscan Touch and the HP ScanJet 3300c, 3400c, and 4300c USB flatbed scanners. See .BR sane\-niash (5) for details. .TP .B p5 The SANE backend for Primax PagePartner. See .BR sane\-p5 (5) for details. .TP .B pie The pie backend provides access to Pacific Image Electronics (PIE) and Devcom SCSI flatbed scanners. See .BR sane\-pie (5) for details. .TP .B pixma The pixma backend supports Canon PIXMA MP series (multi-function devices), Canon imageCLASS series (laser devices), Canon MAXIFY series and some Canon CanoScan series. See .BR sane\-pixma (5) for details. .TP .B plustek The SANE plustek backend supports USB flatbed scanners that use the National Semiconductor LM983[1/2/3] chipset aka Merlin. Scanners using this LM983x chips include some models from Plustek, KYE/Genius, Hewlett-Packard, Mustek, Umax, Epson, and Canon. See .BR sane\-plustek (5) for details. .TP .B plustek_pp The SANE plustek_pp backend supports Plustek parallel port flatbed scanners. Scanners using the Plustek ASIC P96001, P96003, P98001 and P98003 include some models from Plustek, KYE/Genius, Primax. See .BR sane\-plustek_pp (5) for details. .TP .B ricoh The ricoh backend provides access to the following Ricoh flatbed scanners: IS50 and IS60. See .BR sane\-ricoh (5) for details. .TP .B ricoh2 The ricoh2 backend provides access to the following Ricoh flatbed scanners: SG-3100SNw, SP-100SU, and SP-111SU. See .BR sane\-ricoh2 (5) for details. .TP .B s9036 The s9036 backend provides access to Siemens 9036 flatbed scanners. See .BR sane\-s9036 (5) for details. .TP .B sceptre The sceptre backend provides access to the Sceptre S1200 flatbed scanner. See .BR sane\-sceptre (5) for details. .TP .B sharp The SANE sharp backend supports Sharp SCSI scanners. See .BR sane\-sharp (5) for details. .TP .B sm3600 The SANE sm3600 backend supports the Microtek ScanMaker 3600 USB scanner. See .BR sane\-sm3600 (5) for details. .TP .B sm3840 The SANE sm3840 backend supports the Microtek ScanMaker 3840 USB scanner. See .BR sane\-sm3840 (5) for details. .TP .B snapscan The snapscan backend supports AGFA SnapScan flatbed scanners. See .BR sane\-snapscan (5) for details. .TP .B sp15c This backend supports the Fujitsu FCPA ScanPartner 15C flatbed scanner. See .BR sane\-sp15c (5) for details. .TP .B st400 The sane\-st400 backend provides access to Siemens ST400 and ST800. See .BR sane\-st400 (5) for details. .TP .B tamarack The SANE tamarack backend supports Tamarack Artiscan flatbed scanners. See .BR sane\-tamarack (5) for details. .TP .B teco1 teco2 teco3 The SANE teco1, teco2 and teco3 backends support some TECO scanners, usually sold under the Relisys, Trust, Primax, Piotech, Dextra names. See .BR sane\-teco1 "(5), " sane\-teco2 "(5) and " sane\-teco3 (5) for details. .TP .B u12 The sane\-u12 backend provides USB flatbed scanners based on Plustek's ASIC 98003 (parallel-port ASIC) and a GeneSys Logics' USB-parport bridge chip like the Plustek OpticPro U(T)12. See .BR sane\-u12 (5) for details. .TP .B umax The sane\-umax backend provides access to several UMAX-SCSI-scanners and some Linotype Hell SCSI-scanners. See .BR sane\-umax (5) for details. .TP .B umax_pp The sane\-umax_pp backend provides access to Umax parallel port flatbed scanners and the HP 3200C. See .BR sane\-umax_pp (5) for details. .TP .B umax1200u The sane\-umax1220u backend supports the UMAX Astra 1220U (USB) flatbed scanner (and also the UMAX Astra 2000U, sort of). See .BR sane\-umax1220u (5) for details. .TP .B xerox_mfp The sane\-xerox_mfp backend supports multiple Samsung-based Samsung, Xerox, and Dell scanners. See .BR sane\-xerox_mfp (5) for details. .PP Also, have a look at the backend information page at .I http://www.sane\-project.org/sane\-supported\-devices.html and the list of projects in .IR @DOCDIR@/PROJECTS . .SH "BACKENDS FOR DIGITAL CAMERAS" .TP 2 .B dc210 Backend for Kodak DC210 Digital Camera. See .BR sane\-dc210 (5). .TP .B dc240 Backend for Kodak DC240 Digital Camera. See .BR sane\-dc240 (5). .TP .B dc25 Backend for Kodak DC20/DC25 Digital Cameras. See .BR sane\-dc25 (5). .TP .B dmc Backend for the Polaroid Digital Microscope Camera. See .BR sane\-dmc (5). .TP .B gphoto2 Backend for digital cameras supported by the gphoto2 library package. (See .I http://www.gphoto.org for more information and a list of supported cameras.) Gphoto2 supports over 140 different camera models. However, please note that more development and testing is needed before all of these cameras will be supported by .B SANE backend. See .BR sane\-gphoto2 (5). .TP .B qcam Backend for Connectix QuickCam cameras. See .BR sane\-qcam (5). .TP .B stv680 The sane\-stv680 backend provides access to webcams with a stv680 chip. See .BR sane\-stv680 (5) for details. .PP Also, have a look at the backend information page at .I http://www.sane\-project.org/sane\-supported\-devices.html and the list of projects in .IR @DOCDIR@/PROJECTS . .SH "MISCELLANEOUS BACKENDS" .TP 2 .B dll The sane\-dll library implements a .B SANE backend that provides access to an arbitrary number of other .B SANE backends by dynamic loading. See .BR sane\-dll (5). .TP .B net The .B SANE network daemon saned provides access to scanners located on different computers in connection with the net backend. See .BR sane\-net "(5) and " saned (8). .TP .B pnm PNM image reader pseudo-backend. The purpose of this backend is primarily to aid in debugging of .B SANE frontends. See .BR sane\-pnm (5). .TP .B pint Backend for scanners that use the .B PINT (Pint Is Not Twain) device driver. The .B PINT driver is being actively developed on the OpenBSD platform, and has been ported to a few other *nix-like operating systems. See .BR sane\-pint (5). .TP .B test The .B SANE test backend is for testing frontends and the .B SANE installation. It provides test pictures and various test options. See .BR sane\-test (5). .TP .B v4l The sane\-v4l library implements a .B SANE backend that provides generic access to video cameras and similar equipment using the .B V4L (Video for Linux) API. See .BR sane\-v4l (5) . .PP Also, have a look at the backend information page at .I http://www.sane\-project.org/sane\-supported\-devices.html and the list of projects in .IR @DOCDIR@/PROJECTS . .SH "CHANGING THE TOP-LEVEL BACKEND" By default, all .B SANE backends (drivers) are loaded dynamically by the .B sane\-dll meta backend. If you have any questions about the dynamic loading, read .BR sane\-dll (5). .B SANE frontend can also be linked to other backends directly by copying or linking a backend to .B libsane.so in .IR @LIBDIR@ . .PP .SH "DEVELOPER'S DOCUMENTATION" It's not hard to write a .B SANE backend. It can take some time, however. You should have basic knowledge of C and enough patience to work through the documentation and find out how your scanner works. Appended is a list of some documents that help to write backends and frontends. .PP The .B SANE standard defines the application programming interface (API) that is used to communicate between frontends and backends. It can be found at .I @DOCDIR@/sane.ps (if latex is installed on your system) and on the .B SANE website: .I http://www.sane\-project.org/html/ (HTML), or .I http://www.sane\-project.org/sane.ps (Postscript). .PP There is some more information for programmers in .IR @DOCDIR@/backend\-writing.txt . Most of the internal .B SANE routines .RB ( sanei ) are documented using doxygen: .IR http://www.sane\-project.org/sanei/ . Before a new backend or frontend project is started, have a look at .I @DOCDIR@/PROJECTS for projects that are planned or not yet included into the .B SANE distribution and at our bug-tracking system: .IR http://www.http://www.sane\-project.org/bugs.html . .PP There are some links on how to find out about the protocol of a scanner: .IR http://www.meier\-geinitz.de/sane/misc/develop.html . .PP If you start writing a backend or frontend or any other part of .BR SANE, please contact the sane\-devel mailing list for coordination so the same work isn't done twice. .SH "FILES" .TP .I @CONFIGDIR@/*.conf The backend configuration files. .TP .I @LIBDIR@/libsane\-*.a The static libraries implementing the backends. .TP .I @LIBDIR@/libsane\-*.so The shared libraries implementing the backends (present on systems that support dynamic loading). .TP .I @DOCDIR@/* .B SANE documentation: The standard, READMEs, text files for backends etc. .SH "PROBLEMS" If your device isn't found but you know that it is supported, make sure that it is detected by your operating system. For SCSI and USB scanners, use the .B sane\-find\-scanner tool (see .BR sane\-find\-scanner (1) for details). It prints one line for each scanner it has detected and some comments (#). If .B sane\-find\-scanner finds your scanner only as root but not as normal user, the permissions for the device files are not adjusted correctly. If the scanner isn't found at all, the operating system hasn't detected it and may need some help. Depending on the type of your scanner, read .BR sane\-usb (5) or .BR sane\-scsi (5). If your scanner (or other device) is not connected over the SCSI bus or USB, read the backend's manual page for details on how to set it up. .PP Now your scanner is detected by the operating system but not by .BR SANE ? Try .BR "scanimage \-L" . If the scanner is not found, check that the backend's name is mentioned in .IR @CONFIGDIR@/dll.conf . Some backends are commented out by default. Remove the comment sign for your backend in this case. Also some backends aren't compiled at all if one of their prerequisites are missing. Examples include dc210, dc240, canon_pp, hpsj5s, gphoto2, pint, qcam, v4l, net, sm3600, snapscan, pnm. If you need one of these backends and they aren't available, read the build instructions in the .B README file and the individual manual pages of the backends. .PP Another reason for not being detected by .B scanimage \-L may be a missing or wrong configuration in the backend's configuration file. While .B SANE tries to automatically find most scanners, some can't be setup correctly without the intervention of the administrator. Also on some operating systems auto-detection may not work. Check the backend's manual page for details. .PP If your scanner is still not found, try setting the various environment variables that are available to assist in debugging. The environment variables are documented in the relevant manual pages. For example, to get the maximum amount of debug information when testing a Mustek SCSI scanner, set environment variables .BR SANE_DEBUG_DLL ", " SANE_DEBUG_MUSTEK ", and " SANE_DEBUG_SANEI_SCSI to 128 and then invoke .B scanimage .B \-L . The debug messages for the dll backend tell if the mustek backend was found and loaded at all. The mustek messages explain what the mustek backend is doing while the SCSI debugging shows the low level handling. If you can't find out what's going on by checking the messages carefully, contact the sane\-devel mailing list for help (see REPORTING BUGS below). .PP Now that your scanner is found by .BR "scanimage \-L" , try to do a scan: .BR "scanimage >image.pnm" . This command starts a scan for the default scanner with default settings. All the available options are listed by running .BR "scanimage \-\-help" . If scanning aborts with an error message, turn on debugging as mentioned above. Maybe the configuration file needs some tuning, e.g. to setup the path to a firmware that is needed by some scanners. See the backend's manual page for details. If you can't find out what's wrong, contact sane\-devel. .PP To check that the .B SANE libraries are installed correctly you can use the test backend, even if you don't have a scanner or other .B SANE device: .IP .B scanimage \-d .I test .B \-T .PP You should get a list of PASSed tests. You can do the same with your backend by changing "test" to your backend's name. .PP So now scanning with .B scanimage works and you want to use one of the graphical frontends like .BR xsane , .BR xscanimage ", or" .B quiteinsane but those frontends don't detect your scanner? One reason may be that you installed two versions of .BR SANE . E.g. the version that was installed by your distribution in .I /usr and one you installed from source in .IR /usr/local/ . Make sure that only one version is installed. Another possible reason is, that your system's dynamic loader can't find the .B SANE libraries. For Linux, make sure that .I /etc/ld.so.conf contains .I /usr/local/lib and does .B not contain .IR /usr/local/lib/sane . See also the documentation of the frontends. .PP .SH "HOW CAN YOU HELP SANE" We appreciate any help we can get. Please have a look at our web page about contributing to .BR SANE : .I http://www.sane\-project.org/contrib.html .PP .SH "CONTACT" For reporting bugs or requesting new features, please use our bug-tracking system: .IR http://www.sane\-project.org/bugs.html . You can also contact the author of your backend directly. Usually the email address can be found in the .I @DOCDIR@/AUTHORS file or the backend's manpage. For general discussion about SANE, please use the .B SANE mailing list sane\-devel (see .I http://www.sane\-project.org/mailing\-lists.html for details). .PP .SH "SEE ALSO" .BR saned (8), .BR sane\-find\-scanner (1), .BR scanimage (1), .BR sane\-abaton (5), .BR sane\-agfafocus (5), .BR sane\-apple (5), .BR sane\-artec (5), .BR sane\-artec_eplus48u (5), .BR sane\-as6e (5), .BR sane\-avision (5), .BR sane\-bh (5), .BR sane\-canon (5), .BR sane\-canon630u (5), .BR sane\-canon_dr (5), .BR sane\-canon_pp (5), .BR sane\-cardscan (5), .BR sane\-coolscan2 (5), .BR sane\-coolscan (5), .BR sane\-dc210 (5), .BR sane\-dc240 (5), .BR sane\-dc25 (5), .BR sane\-dll (5), .BR sane\-dmc (5), .BR sane\-epson (5), .BR sane\-fujitsu (5), .BR sane\-genesys (5), .BR sane\-gphoto2 (5), .BR sane\-gt68xx (5), .BR sane\-hp (5), .BR sane\-hpsj5s (5), .BR sane\-hp3500 (5), .BR sane\-hp3900 (5), .BR sane\-hp4200 (5), .BR sane\-hp5400 (5), .BR sane\-hpljm1005 (5), .BR sane\-ibm (5), .BR sane\-kodak (5), .BR sane\-leo (5), .BR sane\-lexmark (5), .BR sane\-ma1509 (5), .BR sane\-matsushita (5), .BR sane\-microtek2 (5), .BR sane\-microtek (5), .BR sane\-mustek (5), .BR sane\-mustek_pp (5), .BR sane\-mustek_usb (5), .BR sane\-mustek_usb2 (5), .BR sane\-nec (5), .BR sane\-net (5), .BR sane\-niash (5), .BR sane\-pie (5), .BR sane\-pint (5), .BR sane\-plustek (5), .BR sane\-plustek_pp (5), .BR sane\-pnm (5), .BR sane\-qcam (5), .BR sane\-ricoh (5), .BR sane\-ricoh2 (5), .BR sane\-s9036 (5), .BR sane\-sceptre (5), .BR sane\-scsi (5), .BR sane\-sharp (5), .BR sane\-sm3600 (5), .BR sane\-sm3840 (5), .BR sane\-snapscan (5), .BR sane\-sp15c (5), .BR sane\-st400 (5), .BR sane\-stv680 (5), .BR sane\-tamarack (5), .BR sane\-teco1 (5), .BR sane\-teco2 (5), .BR sane\-teco3 (5), .BR sane\-test (5), .BR sane\-u12 (5), .BR sane\-umax1220u (5), .BR sane\-umax (5), .BR sane\-umax_pp (5), .BR sane\-usb (5), .BR sane\-v4l (5), .BR sane\-xerox_mfp (5) .SH AUTHOR David Mosberger-Tang and many many more (see .I @DOCDIR@/AUTHORS for details). This man page was written by Henning Meier-Geinitz. Quite a lot of text was taken from the .B SANE standard, several man pages, and README files. sane-backends-1.0.29/doc/sane-as6e.man0000666000000000000000000000207213615534521014226 00000000000000.TH sane\-as6e 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .SH NAME sane\-as6e \- SANE backend for using the Artec AS6E parallel port interface scanner. .SH DESCRIPTION The .B sane\-as6e library implements a SANE (Scanner Access Now Easy) backend that provides access to Artec AS6E flatbed scanner. .B It requires the as6edriver program in order to operate. The as6edriver program is .B not included with the SANE package. It can be found at .BR http://as6edriver.sourceforge.net. See the as6edriver documentation for technical information. .PP The .I as6edriver program must be in the path for executables ($PATH). Especially if you run .I saned (the SANE network scanning daemon), take care to setup the path for .I inetd or .I xinetd correctly or place the program in a directory that is in the path. .PP .SH FILES .B as6edriver \- driver program that controls the scanner. .SH SEE ALSO .BR sane (7), .BR as6edriver (5), .BR saned (8), .B http://as6edriver.sourceforge.net .SH AUTHOR Eugene S. Weiss .SH EMAIL-CONTACT yossarian@users.sourceforge.net sane-backends-1.0.29/doc/sane-teco1.man0000666000000000000000000001214113615534521014401 00000000000000.TH sane\-teco1 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-teco1 .SH NAME sane\-teco1 \- SANE backend for TECO / RELISYS scanners .SH DESCRIPTION The .B sane\-teco1 library implements a SANE (Scanner Access Now Easy) backend that provides access to some TECO SCSI flatbed scanners. This backend should be considered .B beta-quality software! TECO scanners are sold under various brands like RELISYS, PIOTECH, TRUST. This backend may or may not support yours. .PP The scanners that should work with this backend are: .PP .RS .ft CR .nf Vendor Model TECO model status ---------------------- -------------- ----------- Relisys AVEC 2400 VM3520 tested Relisys AVEC 2412 VM3520+ tested Relisys AVEC 4800 VM4530 untested Relisys AVEC 4816 VM4530+ untested Relisys RELI 2400 VM3530 untested Relisys RELI 2412 VM3530+ tested Relisys RELI 2412 VM3530+ untested Relisys RELI 4816 VM4540 tested Relisys RELI 4830 VM4542 tested Relisys RELI 9600 VM6530 untested Relisys RELI 9612 VM6530* untested Relisys RELI 9624 VM6530+ untested Relisys RELI 9630 VM6540 untested Relisys RELI DS15 VM3440 untested Relisys RELI DS6 VM3420 untested Dextra DF-600P VM3510 tested Dextra DF-4830T VM4542 untested Dextra DF-1200T+ VM3530+ untested Dextra DF-9624 VM6530+ untested .fi .ft R .RE Note that the untested scanner will not be directly supported. You should contact the author for that. The TECO VM number can usually be found at the back of the scanner. It is also part of the FCC ID. "sane\-find\-scanner \-v" will also show the scsi inquiry, and if it is a TECO scanner, the name will be there too. The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage or xsane. .br If you have any success with a scanner not listed here, or if you have any strange behavior, please report to the backend maintainer or to the SANE mailing list. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d teco1 .RE .TP .B Scan Mode .TP .B \-\-mode selects the basic mode of operation of the scanner valid choices are .I Black & White , .I Grayscale and .I Color The Black & White mode is black and white only (1 bit). Grayscale will produce 256 levels of gray (8 bits). Color will produce a 24 bits color image. .TP .B \-\-resolution selects the resolution for a scan. The scanner can do all resolutions between 1 and 600, in increments of 1. .TP .B Geometry options .TP .B \-l \-t \-x \-y control the scan area: \-l sets the top left x coordinate, \-t the top left y coordinate, \-x selects the width and \-y the height of the scan area. All parameters are specified in millimeters by default. .TP .B Enhancement options .TP .B \-\-custom\-gamma (color mode only) allows the user to specify a gamma table (see the next 3 parameters). .TP .B \-\-red\-gamma\-table (color mode only) can be used to download a user defined gamma table for the red channel. The table must be 256 bytes long. .TP .B \-\-green\-gamma\-table (color mode only) can be used to download a user defined gamma table for the green channel. The table must be 256 bytes long. .TP .B \-\-blue\-gamma\-table (color mode only) can be used to download a user defined gamma table for the blue channel. The table must be 256 bytes long. .TP .B \-\-dither (Black & White only) select the dither mask to use. Possible values are .I Line art , .I 2x2 , .I 3x3 , .I 4x4 bayer , .I 4x4 smooth , .I 8x8 bayer , .I 8x8 smooth , .I 8x8 horizontal and .I 8x8 vertical .TP .B \-\-preview requests a preview scan. The resolution used for that scan is 22 dpi and the scan area is the maximum allowed. The scan mode is user selected. The default is "no". .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/teco1.conf supports only one information: the device name to use (eg /dev/scanner). .SH FILES .TP .I @LIBDIR@/libsane\-teco1.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-teco1.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_TECO1 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH LIMITATIONS The windows TWAIN driver has many more options than this SANE backend. However they are only software adjustments. This backend only implements what the scanner can support. .SH BUGS None known. .SH "SEE ALSO" sane\-scsi(5), scanimage(1), xscanimage(1), xsane(1), sane(7) .SH AUTHOR .TP The package is actively maintained by Frank Zago. .I http://www.zago.net/sane/#teco .SH CREDITS Thanks to Gerard Delafond for the VM4542 support. Thanks to Jean-Yves Simon for the VM3510 support. sane-backends-1.0.29/doc/sane-sp15c.man0000666000000000000000000000433413615534521014326 00000000000000.TH sane\-sp15c 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .SH NAME sane\-sp15c \- SANE backend for Fujitsu ScanPartner 15C flatbed scanner .SH DESCRIPTION The .B sane\-sp15c library implements a SANE (Scanner Access Now Easy) backend which provides access to the Fujitsu flatbed scanners. At present, the following scanner is known to work with these backend: .PP .RS .ft CR .nf Vendor: Model: Rev: -------- ---------------- ----- FCPA ScanPartner 15C 1.01 .fi .ft R .RE .P The ScanPartner 15C driver supports lineart (1-bit), halftone (1-bit), grayscale (4-bit and 8-bit), and color (3 x 8-bit) scanning. Other scanners in these families may work. The ScanPartner 15C seems to be a repackaging of the ScanPartner 600C. People are encouraged to try these driver with the other scanners and to contact the author with test results. .SH CONFIGURATION A modest effort has been made to expose the standard options to the API. This allows frontends such as xscanimage to set scanning region, resolution, bit-depth (and color), and enable the automatic document feeder. .SH "SEE ALSO" sane(7), sane\-scsi(5), sane\-fujitsu(5) .br Fujitsu ScanPartner 15C OEM Manual, Doc. No. 250-0081-0 .br Fujitsu M3096G OEM Manual, part number 50FH5028E-05 .br Fujitsu M3096GX/M3093GX/M3093DG OEM Manual, part number C150-E015...03 .SH AUTHOR Randolph Bentson , with credit to the unnamed author of the coolscan driver .SH LIMITATIONS Testing limited to a Linux 2.2.5 kernel .br Can't quite get the scan page/minute performance in ADF modes. This may be due to limited system buffer size. .SH BUGS I'm sure there are plenty, and not too well hidden, but I haven't seen them yet. .br Both scanners claim to have separate control of resolution in X and Y directions. I confess I haven't tested this yet. I have found that xsane doesn't even display this capability. .br Threshold settings on the SP15C don't seem to affect the results of lineart mode scans. .br It might be possible to merge these two drivers without much effort since the SP15C driver was derived from the M3096G driver. They were split so as to keep the second driver development from breaking the working first driver. Watch this space for changes. sane-backends-1.0.29/doc/sane-kvs40xx.man0000666000000000000000000000157113615534521014722 00000000000000.TH sane\-kvs40xx 5 "03 Jun 2011" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-kvs40xx .SH NAME sane\-kvs40xx \- SANE backend for Panasonic KV-S40xxC USB/SCSI ADF scanners. .SH DESCRIPTION The .B sane\-kvs40xx library implements a SANE (Scanner Access Now Easy) backend which provides access to the Panasonic KV-S40xxC and KV-S70xxC scanners. .SH KNOWN ISSUES This document was written by the SANE project, which has no information regarding the capabilities or reliability of the backend. All information contained here is suspect. The backend uses pthreads directly, and so requires pthreads to be enabled. .SH CREDITS The backend was written by Panasonic Russia Ltd. The backend was ported to sane-backends 1.0.23 and downgraded to C89 by m. allan noah. .SH "SEE ALSO" sane(7), sane\-usb(5), sane\-scsi(5) .SH AUTHOR m. allan noah: sane-backends-1.0.29/doc/sane-pnm.man0000666000000000000000000000330513615534521014162 00000000000000.TH sane\-pnm 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-pnm .SH NAME sane\-pnm \- SANE PNM image reader pseudo-backend .SH DESCRIPTION The .B sane\-pnm library implements a SANE (Scanner Access Now Easy) backend that provides access to PNM (Portable aNyMap files, which covers PBM bitmap files, PGM grayscale files, and PPM pixmap files). The purpose of this backend is primarily to aid in debugging of SANE frontends. It also serves as an illustrative example of a minimal SANE backend. .SH "DEVICE NAMES" This backend provides two devices called .B 0 and .BR 1. .SH CONFIGURATION No configuration required. .SH FILES .TP .I @LIBDIR@/libsane\-pnm.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-pnm.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_PNM If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH BUGS If the pnm backend is installed and saned is used to allow users on remote computers to scan on the local machine, pnm files can be read by the remote user. This is limited to the files saned can access (usually it's running as user "sane"). All pnm files can be read if saned runs as root which isn't recommended anyway. The pnm backend is disabled by default. If you want to use it, enable it with configure (see configure \-\-help for details). Be sure that only trusted users can access the pnm backend over saned. .SH AUTHOR Andreas Beck, Gordon Matzigkeit, and David Mosberger .SH SEE ALSO sane(7) sane-backends-1.0.29/doc/sane-pint.man0000666000000000000000000001045613615534521014347 00000000000000.TH sane\-pint 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-pint .SH NAME sane\-pint \- SANE backend for scanners that use the PINT device driver .SH DESCRIPTION The .B sane\-pint library implements a SANE (Scanner Access Now Easy) backend that provides generic access to hand-held and flatbed scanners using the PINT (PINT Is Not Twain) device driver. The PINT driver is being actively developed on the OpenBSD platform, and has been ported to a few other *nix-like operating systems. .PP PINT is designed to provide an .BR ioctl (2) interface to many different scanner types. However, this backend has only been tested with flatbed single-pass scanners, and more work will probably be required to get it to use other scanner types successfully. .PP If have successfully used the PINT driver with your scanner, but it does not work using this SANE backend, please let us know. To do this, send a mail with the relevant information for your scanner to .IR sane\-devel@alioth-lists.debian.net . Have a look at http://www.sane\-project.org/mailing\-lists.html concerning subscription to sane\-devel. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the UNIX path-name for the special device that corresponds to the scanner. The special device name must be a PINT device or a symlink to such a device. For example, under NetBSD or OpenBSD, such a device name could be .I /dev/ss0 or .IR /dev/scan0 . .SH CONFIGURATION The contents of the .IR pint.conf . file is a list of device names that correspond to PINT scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .PP .RS /dev/scanner .br # this is a comment .br /dev/ss1 .RE .SH FILES .TP .I @CONFIGDIR@/pint.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-pint.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-pint.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_PINT If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH SEE ALSO sane(7) .SH AUTHOR Gordon Matzigkeit, adapted from existing backends written by David Mosberger. .SH BUGS There are minor roundoff errors when adjusting the ranges, since PINT uses units of 1/1200 of an inch, and SANE normally uses millimeters. Symptoms of these errors are skewed images. This should really be fixed (no pun intended) as soon as possible, but I just don't know/care enough about fixed-point representation and roundoff errors to do this correctly. Workaround: use inches as the scanning unit, and everything usually works fine. The PINT 0.5e interface does not provide a way to determine valid ranges for DPI, modes, and scan sizes. So, the SANE backend queries the PINT device, and dynamically discovers valid ranges by doing a binary search. This means that the driver takes longer to initialize than seems necessary. Resetting the scanner does not seem to work (at least not on my HP ScanJet 4p). For that reason, the driver sends a SCIOCRESTART, then gobbles up any remaining input until it hits EOF. Not all of the scanners have been identified (i.e. whether they are flatbed or handheld). X and Y resolutions are assumed to be the same. No testing has been done on three-pass or handheld scanners, or with Automatic Document Feeder support. sane-backends-1.0.29/doc/saned.man0000666000000000000000000002517013615534521013542 00000000000000.TH saned 8 "29 Sep 2017" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX saned .SH NAME saned \- SANE network daemon .SH SYNOPSIS .B saned .B [ \-a .I [ username ] .B ] .B [ \-u .I username .B ] .B [ \-b .I address .B ] .B [ \-l ] .B [ \-D ] .B [ \-o ] .B [ \-d .I n .B ] .B [ \-e ] .B [ \-h ] .SH DESCRIPTION .B saned is the SANE (Scanner Access Now Easy) daemon that allows remote clients to access image acquisition devices available on the local host. .SH OPTIONS .PP The .B \-l flag requests that .B saned run in standalone daemon mode. In this mode, .B saned will listen for incoming client connections; .B inetd is not required for .B saned operations in this mode. The .B \-b flag tells .B saned to bind to the .I address given. The .B \-u flag requests that .B saned drop root privileges and run as the user (and group) associated with .I username after binding. The .B \-D flag will request .B saned to detach from the console and run in the background. The flag .B \-a is equivalent to the combination of .B \-l \-B \-u .I username options. .PP The .B \-d flag sets the level of .B saned debug output. When compiled with debugging enabled, this flag may be followed by a number to request more or less debug info. The larger the number, the more verbose the debug output. E.g., .B \-d128 will request output of all debug info. A level of 0 produces no output at all. The default value is 2. .PP The .B \-e flag will divert .B saned debug output to stderr instead of the syslog default. .PP The .B \-o flag requests that .B saned exits after the first client disconnects. This is useful for debugging. .PP The .B \-h flag displays a short help message. .PP If .B saned is run from other programs such as inetd, xinetd and systemd, check that program's documentation on how to pass command-line options. .SH CONFIGURATION First and foremost: .B saned is not intended to be exposed to the internet or other non-trusted networks. Make sure that access is limited by tcpwrappers and/or a firewall setup. Don't depend only on .BR saned 's own authentication. Don't run .B saned as root if it's not necessary. And do .B not install .B saned as setuid root. .PP The .I saned.conf configuration file contains both options for the daemon and the access list. .TP \fBdata_portrange\fP = \fImin_port\fP - \fImax_port\fP Specify the port range to use for the data connection. Pick a port range between 1024 and 65535; don't pick a too large port range, as it may have performance issues. Use this option if your \fBsaned\fP server is sitting behind a firewall. If that firewall is a Linux machine, we strongly recommend using the Netfilter \fInf_conntrack_sane\fP module instead. .TP \fBdata_connect_timeout\fP = \fItimeout\fP Specify the time in milliseconds that saned will wait for a data connection. Without this option, if the data connection is not done before the scanner reaches the end of scan, the scanner will continue to scan past the end and may damage it depending on the backend. Specify zero to have the old behavior. The default is 4000ms. .PP The access list is a list of host names, IP addresses or IP subnets (CIDR notation) that are permitted to use local SANE devices. IPv6 addresses must be enclosed in brackets, and should always be specified in their compressed form. Connections from localhost are always permitted. Empty lines and lines starting with a hash mark (#) are ignored. A line containing the single character ``+'' is interpreted to match any hostname. This allows any remote machine to use your scanner and may present a security risk, so this shouldn't be used unless you know what you're doing. .PP A sample configuration file is shown below: .PP .RS # Daemon options .br data_portrange = 10000 - 10100 .br # Access list .br scan\-client.somedomain.firm .br # this is a comment .br 192.168.0.1 .br 192.168.2.12/29 .br [::1] .br [2001:db8:185e::42:12]/64 .RE .PP The case of the host names does not matter, so AHost.COM is considered identical to ahost.com. .SH SERVER DAEMON CONFIGURATION For .B saned to work properly in its default mode of operation, it is also necessary to add the appropriate configuration for .I (x)inetd or systemd. (see below). Note that your inetd must support IPv6 if you want to connect to saned over IPv6 ; xinetd, openbsd-inetd and systemd are known to support IPv6, check the documentation for your inetd daemon. .PP In the sections below the configuration for .I inetd, xinetd and .I systemd are described in more detail. .PP For the configurations below it is necessary to add a line of the following form to .IR /etc/services : .PP .RS sane\-port 6566/tcp # SANE network scanner daemon .RE .PP The official IANA short name for port 6566 is "sane\-port". The older name "sane" is now deprecated. .SH INETD CONFIGURATION It is required to add a single line to the inetd configuration file .IR (/etc/inetd.conf) . .PP The configuration line normally looks like this: .PP .RS sane\-port stream tcp nowait saned.saned @SBINDIR@/saned saned .RE .PP However, if your system uses .BR tcpd (8) for additional security screening, you may want to disable saned access control by putting ``+'' in .IR saned.conf and use a line of the following form in .IR /etc/inetd.conf instead: .PP .RS sane\-port stream tcp nowait saned.saned /usr/sbin/tcpd @SBINDIR@/saned .RE .PP Note that both examples assume that there is a .B saned group and a .B saned user. If you follow this example, please make sure that the access permissions on the special device are set such that .B saned can access the scanner (the program generally needs read and write access to scanner devices). .SH XINETD CONFIGURATION If xinetd is installed on your system instead of inetd the following example for .I /etc/xinetd.conf may be helpful: .PP .RS .ft CR .nf # default: off # description: The sane server accepts requests # for network access to a local scanner via the # network. service sane\-port { port = 6566 socket_type = stream wait = no user = saned group = saned server = @SBINDIR@/saned } .fi .ft R .RE .SH SYSTEMD CONFIGURATION Saned can be compiled with explicit systemd support. This will allow logging debugging information to be forwarded to the systemd journal. The systemd support requires compilation with the systemd-devel package installed on the system. this is the preferred option. Saned can be used wih systemd without the systemd integration compiled in, but then logging of debug information is not supported. The systemd configuration is different for the 2 options, so both are described below. .SH Systemd configuration for saned with systemd support compiled in for the systemd configuration we need to add 2 configuration files in .I /etc/systemd/system. .PP The first file we need to add here is called .I saned.socket. It shall have the following contents: .PP .RS .ft CR .nf [Unit] Description=saned incoming socket [Socket] ListenStream=6566 Accept=yes MaxConnections=1 [Install] WantedBy=sockets.target .fi .ft R .RE .PP The second file to be added is .I saned@.service with the following contents: .PP .RS .ft CR .nf [Unit] Description=Scanner Service Requires=saned.socket [Service] ExecStart=/usr/sbin/saned User=saned Group=saned StandardInput=null StandardOutput=syslog StandardError=syslog Environment=SANE_CONFIG_DIR=@CONFIGDIR@ # If you need to debug your configuration uncomment the next line and # change it as appropriate to set the desired debug options # Environment=SANE_DEBUG_DLL=255 SANE_DEBUG_BJNP=5 [Install] Also=saned.socket .fi .ft R .RE .PP You need to set an environment variable for .B SANE_CONFIG_DIR pointing to the directory where saned can find its configuration files. you will have to remove the # on the last line and set the variables for the desired debugging information if required. Multiple variables can be set by separating the assignments by spaces as shown in the example above. .PP Unlike .I (x)inetd , systemd allows debugging output from backends set using .B SANE_DEBUG_XXX to be captured. See the man-page for your backend to see what options are supported. With the service unit as described above, the debugging output is forwarded to the system log. .SH Systemd configuration when saned is compiled without systemd support This configuration will also work when Saned is compiled WITH systemd integration support, but it does not allow debugging information to be logged. .PP for systemd configuration for saned, we need to add 2 configuration files in .I /etc/systemd/system. .PP The first file we need to add here is called .I saned.socket. It is identical to the version for systemd with the support compiled in. It shall have the following contents: .PP .RS .ft CR .nf [Unit] Description=saned incoming socket [Socket] ListenStream=6566 Accept=yes MaxConnections=1 [Install] WantedBy=sockets.target .fi .ft R .RE .PP The second file to be added is .I saned@.service This one differes from the sersion with systemd integration compiled in: .PP .RS .ft CR .nf [Unit] Description=Scanner Service Requires=saned.socket [Service] ExecStart=/usr/sbin/saned User=saned Group=saned StandardInput=socket Environment=SANE_CONFIG_DIR=/etc/sane.d [Install] Also=saned.socket .fi .ft R .RE .PP .SH FILES .TP .I /etc/hosts.equiv The hosts listed in this file are permitted to access all local SANE devices. Caveat: this file imposes serious security risks and its use is not recommended. .TP .I @CONFIGDIR@/saned.conf Contains a list of hosts permitted to access local SANE devices (see also description of .B SANE_CONFIG_DIR below). .TP .I @CONFIGDIR@/saned.users If this file contains lines of the form user:password:backend access to the listed backends is restricted. A backend may be listed multiple times for different user/password combinations. The server uses MD5 hashing if supported by the client. .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .SH "SEE ALSO" .BR sane (7), .BR scanimage (1), .BR xscanimage (1), .BR xcam (1), .BR sane\-dll (5), .BR sane\-net (5), .BR sane\-"backendname" (5) .br .I http://www.penguin-breeder.org/?page=sane\-net .SH AUTHOR David Mosberger sane-backends-1.0.29/doc/sane-kvs1025.man0000666000000000000000000000160713615534521014506 00000000000000.TH sane\-kvs1025 5 "16 Apr 2010" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-kvs1025 .SH NAME sane\-kvs1025 \- SANE backend for Panasonic KV-S102xC USB ADF scanners. .SH DESCRIPTION The .B sane\-kvs1025 library implements a SANE (Scanner Access Now Easy) backend which provides access to the Panasonic KV-S1020C/1025C and KV-S1045C scanners. .SH KNOWN ISSUES This document was written by the SANE project, which has no information regarding the capabilities or reliability of the backend. All information contained here is suspect. .SH CREDITS The backend was written by Tao Zhang / Panasonic Russia Ltd. The backend was ported to sane-backends 1.0.21 and updated to use sanei_usb instead of libusb by m. allan noah. The backend was tested on KV-S1025C and 1045C by Tiago Zaniquelli. .SH "SEE ALSO" sane(7), sane\-usb(5) .SH AUTHOR m. allan noah: sane-backends-1.0.29/doc/sane-coolscan2.man0000666000000000000000000001504413615534521015256 00000000000000.TH sane\-coolscan2 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-coolscan2 .SH NAME sane\-coolscan2 \- SANE backend for Nikon Coolscan film scanners .SH DESCRIPTION The .B sane\-coolscan2 library implements a SANE (Scanner Access Now Easy) backend that provides access to Nikon Coolscan film scanners. Some functions of this backend should be considered .B beta-quality software. Most functions have been stable for a long time, but of course new development can not and will not function properly from the very first day. Please report any strange behaviour to the maintainer of the backend. .PP At present, the following scanners are known to work with this backend: .PP .RS .ft CR .nf Model: Connection Type --------------------------- ------------------- LS-30 (Coolscan III) SCSI LS-2000 SCSI LS-40 ED (Coolscan IV) USB LS-4000 ED IEEE 1394 LS-8000 ED IEEE 1394 .fi .ft R .RE Please send mail to the backend author (andras@users.sourceforge.net) to report successes or failures. .SH OPTIONS The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xscanimage or xsane. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d coolscan2:: .RE where and specify the device in question, as in the configuration file (see next section). The \-d parameter and its argument can be omitted to obtain information on the first scanner identified. Use the command .RS scanimage \-L .RE to list all devices recognized by your SANE installation. The options should be fully described by the description or tooltips given by frontend. Here is a description of some of the most important options, in the syntax with which they must be supplied to scanimage: .TP .I \-\-frame This option specifies which frame to operate on, if a motorized film strip feeder or APS adapter are used. The frame number .I ranges from 1 to the number of frames available, which is sensed each time the backend is initialized (usually each time you start the frontend). .TP .I \-\-subframe This option shifts the scan window by the specified amount (default unit is mm). .TP .I \-\-infrared=yes/no If set to "yes", the scanner will read the infrared channel, thus allowing defect removal in software. The infrared image is read during a second scan, with no options altered. The backend must not be restarted between the scans. If you use scanimage, perform a batch scan with batch\-count=2 to obtain the IR information. .TP .I \-\-depth Here can either be 8 or the maximum number of bits supported by the scanner (10, 12, or 14). It specifies whether or not the scanner reduces the scanned data to 8 bits before sending it to the backend. If 8 bits are used, some information and thus image quality is lost, but the amount of data is smaller compared to higher depths. Also, many imaging programs and image formats cannot handle depths greater than 8 bits. .TP .I \-\-autofocus Perform autofocus operation. Unless otherwise specified by the other options ( .I \-\-focus\-on\-centre and friends), focusing is performed on the centre of the selected scan area. .TP .I \-\-ae\-wb .TP .I \-\-ae Perform a pre-scan to calculate exposure values automatically. .I \-\-ae\-wb will maintain the white balance, while .I \-\-ae will adjust each channel separately. .TP .I \-\-exposure Multiply all exposure times with this value. This allows exposure correction without modifying white balance. .TP .I \-\-load Load the next slide when using the slide loader. .TP .I \-\-eject Eject the film strip or mounted slide when using the slide loader. .TP .I \-\-reset Reset scanner. The scanner will perform the same action as when power is turned on: it will eject the film strip and calibrate itself. Use this whenever the scanner refuses to load a film strip properly, as a result of which .I \-\-eject does not work. .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/coolscan2.conf specifies the device(s) that the backend will use. Owing to the nature of the supported connection types SCSI, USB, and IEEE 1394, the default configuration file supplied with the SANE distribution should work without being edited. Each line in the configuration file is either of the following, where all entries are case-sensitive: .TP .I blank or starting with a '#' character These lines are ignored, thus '#' can be used to include comments. .TP .I containing only the word """auto""" This instructs the backend to probe for a scanner by scanning the buses for devices with know identifiers. This is the action taken when no configuration file is present. .TP .I a line of the form : Here can be one of "scsi" or "usb", and is the device file of the scanner. Note that IEEE 1394 devices are handled by the SBP-2 module in the kernel and appear to SANE as SCSI devices. .SH FILES .TP .I @LIBDIR@/libsane\-coolscan2.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-coolscan2.so The shared library implementing this backend (present on systems that support dynamic loading). .TP .I @CONFIGDIR@/coolscan2.conf Configuration file for this backend, read each time the backend is initialized. .SH ENVIRONMENT .TP .B SANE_DEBUG_COOLSCAN2 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH "SEE ALSO" sane\-scsi(5), sane\-usb(5), scanimage(1), xscanimage(1), xsane(1) .SH BUGS Currently, the SANE protocol does not allow automatically updating options whenever the hardware changes. Thus the number of choices for the .B \-\-frame option will be fixed when the backend is initialized (usually when the user runs the frontend). In particular, if there is no film strip in the automatic film strip feeder when the backend is initialized, the frame option will not appear at all. Also, restarting the frontend after swapping film adapters is strongly recommended. Linux kernels prior to 2.4.19 had a patch that truncated INQUIRY data from IEEE 1394 scanners to 36 bytes, discarding vital information about the scanner. The IEEE 1394 models therefore only work with 2.4.19 or later. No real bugs currently known, please report any to the backend maintainer or the SANE developers' email list. .SH AUTHORS The backend is written and maintained by Andr\['a]s Major (andras@users.sourceforge.net). sane-backends-1.0.29/doc/sane-ibm.man0000666000000000000000000000532013615534521014136 00000000000000.TH sane\-ibm 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-ibm .SH NAME sane\-ibm \- SANE backend for IBM and Ricoh SCSI flatbed scanners .SH DESCRIPTION The .B sane\-ibm library implements a SANE (Scanner Access Now Easy) backend that provides access to the IBM 2456 and the Ricoh IS-410, IS-420, and IS-430 flatbed scanners. Support for the IS-410 and IS-430 is untested. Please contact the maintainer or the sane\-devel mailing list if you own such a scanner. .PP This backend is alpha-quality. It may have bugs and some scanners haven't been tested at all. Be careful and pull the plug if the scanner causes unusual noise. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is either the path-name for the special device that corresponds to a SCSI scanner. The program .I sane\-find\-scanner helps to find out the correct device. Under Linux, such a device name could be .I /dev/sg0 or .IR /dev/sga , for example. See .BR sane\-scsi (5) for details. .SH CONFIGURATION The contents of the .I ibm.conf file is a list of device names that correspond to SCSI scanners. Empty lines and lines starting with a hash mark (#) are ignored. See .BR sane\-scsi (5) on details of what constitutes a valid device name. .SH FILES .TP .I @CONFIGDIR@/ibm.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-ibm.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-ibm.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_IBM If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. .SH "SEE ALSO" .BR sane (7), .BR sane\-find\-scanner (1), .BR sane\-scsi (5), .SH AUTHOR mf .br Maintained by Henning Meier-Geinitz sane-backends-1.0.29/doc/sane-hp4200.man0000666000000000000000000000661213615534521014311 00000000000000.TH sane\-hp4200 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-hp4200 .SH NAME sane\-hp4200 \- SANE backend for Hewlett-Packard 4200 scanners .SH DESCRIPTION The .B sane\-hp4200 library implements a SANE (Scanner Access Now Easy) backend that provides access to the following Hewlett-Packard USB flatbed scanners: .PP .RS ScanJet 4200 C .br ScanJet 4200 Cxi .br ScanJet 4200 Cse .RE .PP More details can be found on the hp4200 backend homepage .IR http://hp4200\-backend.sourceforge.net/ . .PP This is BETA software. Keep your hand at the scanner's plug and unplug it, if the head bumps at the end of the scan area. .PP If you own a scanner other than the ones listed above that works with this backend, please let us know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .IR /proc/bus/usb/devices , .I sane\-find\-scanner or syslog) to us. Even if the scanner's name is only slightly different from the models mentioned above, please let us know. .PP .SH CONFIGURATION The contents of the .I hp4200.conf file is a list of usb lines containing vendor and product ids that correspond to USB scanners. The file can also contain the names of device files that correspond to an HP 4200 scanner. Empty lines and lines starting with a hash mark (#) are ignored. The scanners are autodetected by .B usb vendor_id product_id statements which are already included into .IR hp4200.conf . "vendor_id" and "product_id" are hexadecimal numbers that identify the scanner. If autodetection does not work, add the device name of your scanner to the configuration file, e.g. .IR /dev/usb/scanner0 . .PP .SH FILES .TP .I @CONFIGDIR@/hp4200.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-hp4200.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-hp4200.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_HP4200 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_HP4200=4 .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .br .I http://hp4200\-backend.sourceforge.net/ .SH AUTHOR Adrian Perez Jorge, Andrew John Lewis, Arnar Mar Hrafnkelsson, Frank Zago, Henning Meier-Geinitz. Current maintainer: Henning Meier-Geinitz . .SH BUGS Tested only with Linux. .PP Only 8 bit color mode works. .PP Scanning is slow due to backtracking. .PP Send bug reports to the sane\-devel mailing list: sane\-devel@alioth-lists.debian.net. sane-backends-1.0.29/doc/releases.txt0000666000000000000000000000451613615534521014320 000000000000002019-08-24 This text summarizes some points to pay attention to when a new release of sane-backends is planned. Timetable (approximate periods): Day 0: Announcement of upcoming release on sane-devel including timetable and pointer to the GitLab milestone Day 14: Feature freeze (only bugfixes + documentation updates) Day 28: Code freeze (only fixes for bugs that can destroy hardware, can cause compilation problems or render a backend completely unusable, and documentation updates are allowed) Day 35: Release Before the release: * set :new :yes on any new backend .desc files, by looking for added files: version=1.0.27 git ls-files -- backend | while read f; do git log --follow --diff-filter=A --find-renames=40% \ --format="%ai $f" $version..HEAD -- "$f" done | cat * NEWS: update and enter date of release, etc Get list of heavily change backends via: git diff --stat $version..HEAD Get list of details from: git log $version..HEAD * git commit -a * git push origin master Making the release: * temporarily set a PRIVATE_TOKEN variable in the GitLab CI/CD variables. You have to create one in your own Settings > Access Tokens. Set it to expire the next day to avoid abuse. Better yet, remove it from the CI/CD variables when the job is finished. * git tag -a -s 1.0.28 -m Release * git push --tags origin master * trigger the manual 'release' stage of the build via the web UI when this becomes possible. This requires a valid PRIVATE_TOKEN. Updating the website and announcing the release: * checkout the sane/website.git module and: * copy sane-backends.html to sane-backends-"old-version".html * update sane-supported-devices.html with link to above "old" file * rebuild sane-backends.html and sane-mfgs.html (make -C doc html-pages) * [TBD] use man2html from http://hydra.nac.uci.edu/indiv/ehood/man2html.html to rebuild html man pages (make -C doc html-man) (no other version works) * update announcement to index.html * git commit -a && git push * check that website's pipeline succeeded * announce release on sane-announce mailing list (and Cc: sane-devel). Ping the sane-announce list's moderator (m. allan noah) to get your post approved ASAP. After the release: * remove the ':new' tag from all doc/descriptions*/*.desc files * git add new and changed files and commit * git push sane-backends-1.0.29/doc/sane-s9036.man0000666000000000000000000000417113615534521014156 00000000000000.TH sane\-s9036 5 "14 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-s9036 .SH NAME sane\-s9036 \- SANE backend for Siemens 9036 flatbed scanners .SH DESCRIPTION The .B sane\-s9036 library implements a SANE (Scanner Access Now Easy) backend that provides access to Siemens 9036 flatbed scanners. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is the path-name for the special device that corresponds to a SCSI scanner. The special device name must be a generic SCSI device or a symlink to such a device. The program .IR sane\-find\-scanner helps to find out the correct device. Under Linux, such a device name could be .I /dev/sga or .IR /dev/sge , for example. See sane\-scsi(5) for details. .SH FILES .TP .I @CONFIGDIR@/s9036.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-s9036.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-s9036.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_S9036 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. Example: export SANE_DEBUG_S9036=4 .SH "SEE ALSO" sane(7), sane\-scsi(5) .SH AUTHOR Ingo Schneider sane-backends-1.0.29/doc/sane-ma1509.man0000666000000000000000000001017713615534521014311 00000000000000.TH sane\-ma1509 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-ma1509 .SH NAME sane\-ma1509 \- SANE backend for Mustek BearPaw 1200F USB scanner .SH DESCRIPTION The .B sane\-ma1509 library implements a SANE (Scanner Access Now Easy) backend that provides access to the Mustek BearPaw 1200F USB flatbed scanner. This scanner is based on the MA-1509 chipset. Other scanners that use this chip (if they exist) may also work. .PP This backend is ALPHA software. Be careful and remove the power plug immediately if your hear unusual noises. .PP More details can be found on the ma1509 backend homepage .IR http://www.meier\-geinitz.de/sane/ma1509\-backend/ . .PP Other Mustek USB scanners are supported by the gt68xx, mustek_usb and the plustek backends. See .BR sane\-mustek_usb (5), .BR sane\-gt68xx (5) and .BR sane\-plustek (5) for details. .PP This backend can only work with scanners that are already detected by the operating system. See .BR sane\-usb (5) for details. .PP If you own a scanner other than the Mustek BearPaw 1200F that works with this backend, please let me know this by sending the scanner's exact model name and the USB vendor and device ids (e.g. from .I /proc/bus/usb/devices or syslog) to me. .SH "DEVICE NAMES" This backend expects device names of the form: .PP .RS .I special .RE .PP Where .I special is a path-name for the special device that corresponds to a USB scanner. With Linux, such a device name could be .I /dev/usb/scanner0 or .IR libusb:001:002 , for example. .PP .SH CONFIGURATION The contents of the .I ma1509.conf file is a list of options and device names that correspond to Mustek BearPaw 1200F scanners. Empty lines and lines starting with a hash mark (#) are ignored. .PP Instead of using the device name, the scanner can be autodetected by .B "usb vendor_id product_id" statements which are already included into .IR ma1509.conf . This is only supported with Linux 2.4.8 and higher and all systems that support libsub. "vendor_id" and "product_id" are hexadecimal numbers that identify the scanner. If this doesn't work, a device name must be placed in .I ma1509.conf as described above. .PP To set the time the lamp needs for warm-up, use .B option .B warmup-time in .IR ma1509.conf . The time is given in seconds after the option. The default is 30 seconds. .SH FILES .TP .I @CONFIGDIR@/ma1509.conf The backend configuration file (see also description of .B SANE_CONFIG_DIR below). .TP .I @LIBDIR@/libsane\-ma1509.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-ma1509.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configuration file is searched in two default directories: first, the current working directory (".") and then in @CONFIGDIR@. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explicitly specified directories. For example, setting .B SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "@CONFIGDIR@" being searched (in this order). .TP .B SANE_DEBUG_MA1509 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. Higher debug levels increase the verbosity of the output. .SH "SEE ALSO" .BR sane (7), .BR sane\-usb (5), .BR sane\-gt68xx (5), .BR sane\-plustek (5), .BR sane\-mustek_usb (5), .BR sane\-mustek (5), .BR sane\-mustek_pp (5), .br .I http://www.meier\-geinitz.de/sane/ma1509\-backend/ .SH AUTHOR Henning Meier-Geinitz .SH BUGS Resolutions higher than 600 dpi don't work .br Transparency adapter and automatic document feeder is not supported yet .br No support for "high-speed" mode (jpeg) .PP More detailed bug information is available at the MA-1509 backend homepage .IR http://www.meier\-geinitz.de/sane/ma1509-backend/ . sane-backends-1.0.29/doc/sane-stv680.man0000666000000000000000000001107413615534521014444 00000000000000.TH sane\-stv680 5 "11 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-stv680 .SH NAME sane\-stv680 \- SANE backend for STV680 camera's .SH DESCRIPTION The .B sane\-stv680 library implements a SANE (Scanner Access Now Easy) backend that provides access to some STV680 cameras. This backend should be considered .B beta-quality software! STV680 cameras are sold under various brands like Aiptek. This backend may or may not support yours. .PP The cameras that should work with this backend are: .PP .ft CR .nf Vendor Model USB vendor id USB product id status ------------------------ ------------- -------------- -------- AIPTEK stv680 0x0553 0x0202 basic Konica e-mini 0x04c8 0x0722 untested DigitalDream l'espion XS 0x1183 0x0001 untested Creative WebCam Go mini 0x041e 0x4007 untested .fi .ft R For all these cameras, see the backend home page (under AUTHOR) for the exact status of each camera. For startup of this backend check that if present the stv680 kernel module is removed or disabled. .br Also before using, enable the backend by editing the /etc/sane.d/dll.conf file, change #stv680 to stv680. For problems with the untested cameras, you should contact the author for that. The options the backend supports can either be selected through command line options to programs like scanimage or through GUI elements in xcam. For both programs use the \-B option needed for size buffer. Some frontends examples: .br xcam .RS xcam \-B .RE scanimage: for writing in batch mode to a file or to a new file each time. .RS scanimage \-B \-d stv680:libusb:001:002 \-\-batch=out.ppm \-\-batch-count 5 \-\-mode "Color RGB" .RE .RS scanimage \-B \-d stv680:libusb:001:002 \-\-batch=out%d.ppm \-\-batch-count 5 \-\-mode "Color RGB" .RE .br If you have any success with a camera not listed here, or if you have any strange behavior, please report to the backend maintainer or to the SANE mailing list. Valid command line options and their syntax can be listed by using .RS scanimage \-\-help \-d stv680 .RE .TP .B Scan Mode .TP .B \-\-mode selects the basic mode of operation of the webcams valid choices. The read resolution mode is 8 bits, output resolution is 24 bits. Selects the resolution for a scan. The camera can do only the resolutions listed. .TP .B \-\-Raw In this mode raw data is displayed .TP .B \-\-Color In this mode the bayer unshuffle is done but no color correction .TP .B \-\-Color_RGB Bayer unshuffle, color correction .TP .B \-\-Color_RGB_TXT Bayer unshuffle, color correction, textline with date and time is added .TP .B Enhancement options .TP .B \-\-white\-level\-r Selects what red radiance level should be considered "white", when scanning some sheets by changing the calibration value loaded into the scanner. Scale \-32 .. 0 .. +32 in steps of 1. .TP .B \-\-white\-level\-g Selects what green radiance level should be considered "white", when scanning some sheets by changing the calibration i value loaded into the scanner. Scale \-32 .. 0 .. +32 in steps of 1. .TP .B \-\-white\-level\-b Selects what blue radiance level should be considered "white", when scanning some sheets by changing the calibration value loaded into the scanner. Scale \-32 .. 0 .. +32 in steps of 1. .SH CONFIGURATION FILE The configuration file @CONFIGDIR@/stv680.conf supports only one information: the device name to use (eg usb 0x.... 0x....). .SH FILES .TP .I @LIBDIR@/libsane\-stv680.a The static library implementing this backend. .TP .I @LIBDIR@/libsane\-stv680.so The shared library implementing this backend (present on systems that support dynamic loading). .SH ENVIRONMENT .TP .B SANE_DEBUG_STV680 If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity. .SH LIMITATIONS The windows TWAIN driver has many more options than this SANE backend. However they are only software adjustments. This backend only implements what the webcam can support. .SH BUGS .TP Plenty. Parts of this backend are still under development. 1. Some untested cameras. .br 2. Video streaming slow and stops sometimes (scanimage). .br 3. Sometimes 1/3 of image is NOK (xcam). .SH "SEE ALSO" sane\-usb(5), scanimage(1), xcam(1), sane(7) .SH AUTHORS Gerard Klaver http://gkall.hobby.nl/stv680-aiptek.html .SH CREDITS .TP Thanks to developers of the other stv680 programs: STV680 kernel module .br pencam2 program .br libghoto2 program (camlib stv0680) sane-backends-1.0.29/doc/matsushita/0000755000000000000000000000000013615535552014211 500000000000000sane-backends-1.0.29/doc/matsushita/matsushita.txt0000666000000000000000000001201413615534521017051 00000000000000Made by Kyushu Matsushita Electric, a.k.a. Panasonic http://www.kme.panasonic.co.jp/ http://panasonic.com/ The same twain driver handle these scanners: Same family as KV-SS25, KV-SS50, KV-SS55, KV-SS50EX, KV-SS55EX, KV-SS850, KV-SS855. Another driver handle the KV-S2055L, KV-S2055W. However all these scanner show similarities. /*--------------------------------------------------------------------------*/ SCSI commands supported by the KV-SS25: TEST UNIT READY: 00 00 00 00 00 00 REQUEST SENSE: 03 00 00 00 0E 00 a return after a short read is: f0 00 60 00 00 00 02 0a 00 00 00 00 00 00 00 00 a return after a jam (sure?) f0 00 03 00 00 00 00 0a 00 00 00 00 80 01 00 00 no paper f0 00 03 00 00 00 00 0a 00 00 00 00 3a 00 00 00 jam door open: f0 00 02 00 00 00 00 0a 00 00 00 00 04 81 00 00 paper jam f0 00 03 00 00 00 00 0a 00 00 00 00 80 04 00 00 after a power cycle f0 00 06 00 00 00 00 0a 00 00 00 00 29 00 00 00 after ???? f0 00 05 00 00 00 00 0a 00 00 00 00 2c 02 00 00 out of memory (scan data too big for scanner) f0 00 05 00 00 00 00 0a 00 00 00 00 2c 80 00 00 INQUIRY: 12 00 00 00 60 00 result: 06 00 02 02 5B 00 00 10 4B 2E 4D 2E 45 2E 20 20 4B 56 2D 53 53 32 35 41 20 20 20 20 20 20 20 20 31 2E 30 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 SET WINDOWS: 24 00 00 00 00 00 00 00 00 00 reset (?) 24 00 00 00 00 00 00 00 48 00 72 bytes. 6-7 = 0x40 = window descriptor length Window Descriptor Block: 0 = page side 0x00 = front 0x80 = back 2-3 = X resolution 4-5 = Y Resolution 14-17 = width (size in inches * 1200) 18-21 = length (size in inches * 1200) 22 = 255 - brightness 23 = same as 22 24 = contrast 25 = image composition 0x00 = black&white (1 bit) 0x01 = black&white with halftone pattern 0x02 = grayscale 26 = bits/pixel 0x01, if image comp == 0 0x04, if image comp == (0x01 || 0x02) -> grayscale 4 bits 0x08, if image comp == 0x02 -> grayscale 8 bits 28 = haltone pattern 0x00 = Bayer 64 0x01 = Bayer 16 0x02 = Dot 32 0x03 = Dot 64 0x04 = Error diffusion 0x80 = User downloaded pattern 29 = reverse image 0x00 = no reverse 0x80 = reverse 43 = image emphasis 0x80 smooth 0x00 none 0x01 low 0x30 medium (twain default) 0x50 high 44 = gamma (Gray 4/8 only) 0x00 normal 0x01 from CRT 0x80 gamma table 0 (previously downloaded) 0x81 gamma table 1 (previously downloaded) 0x82 gamma table 2 (previously downloaded) 0x83 gamma table 3 (previously downloaded) 47 = ? (only used by the ISIS driver) bit 7 = ? set by the ISIS driver bit 6 = length control bit 2 = ? set by the ISIS driver bit 1 = ? set by the ISIS driver 48-51 = width (again?, maybe paper size) 52-55 = length (again?, maybe paper size) 57 = feeder mode 0x00 = one page other = number of pages to read (TWAIN driver defaults to 0xff) 58 = auto threshold 0x00 = none (twain default) 0x80 = mode 1 0x81 = mode 2 0x82 = mode 3 59 = automatic separation 0x00 = no (twain default) 0x80 = yes 60 = white level 0x00 = from white stick (twain default) 0x80 = from paper 0x81 = automatic 61 = noise reduction 0x00 = none (twain default) 0x01 = 1x1 0x02 = 2x2 0x03 = 3x3 0x04 = 4x4 0x05 = 5x5 READ: 28 00 80 00 00 00 00 00 10 00 28 00 00 00 00 00 00 80 00 00 2 = data type code 0x00 image data The TWAIN driver always reads 0x8000 bytes at the time, except for the last packet where it read the size left plus 2 more bytes (and thus generating a check condition). 5: page side 0x00 = front 0x80 = back 0x80 image size in dots 3(?)-4: number of the page to read. Multipage mode. returns 16 bytes: 0-3: length in pixels 4-7: width in lines SEND(10): 2A 00 03 00 00 01 00 01 0A 00 2 = data type code 0x02 = halftone pattern data is 10 bytes of header + 64 bytes for the matrix 0x03 = gamma table data is 10 bytes of header + 256 bytes for the table 5 = gamma table number (data type code is 2) the scanner can store 4 gamma tables (from 0 to 3) 7-8 = length SET AREA (?) C0 00 00 00 00 00 00 00 58 00 Total message length = 88 bytes 7 = length -> 0x40 = 64 bytes 14-17 = area 1 X 18-21 = area 1 Y 22-25 = area 1 width 26-29 = area 1 length 33 = image composition 1 = halftone 36 = haltone pattern (if image composition == 1) 0x00 = Bayer 64 0x01 = Bayer 16 0x02 = Dot 32 0x03 = Dot 64 0x04 = Error diffusion 50-53 = area 2 X 54-57 = area 2 Y 58-61 = area 2 width 62-65 = area 2 length 68-71 = area 3 X 72-75 = area 3 Y 76-79 = area 3 width 80-83 = area 3 length Other supported commands: 16 RESERVE UNIT 17 RELEASE UNIT 1D SEND DIAGNOSTIC 31 OBJECT POSITION 3B WRITE BUFFER sane-backends-1.0.29/doc/sane-logo.png0000666000000000000000000002614713615534521014352 00000000000000‰PNG  IHDRÀáÞõz0ÌPLTEÿÿf™f33f™™™Ìÿ™3ÿffÿ™Ìÿ333ff™fÌ™™ÿÿ™Ì3fÌÌÌÿ33f3f™™f3ÌÿÌÿ333f™3Ì™f™3f™ÌÌÌ3ÿ3f33™™33™ff™™Ì™ÿÌÌ33ÿf™ÿ33f3ff™f™ÌÌ™3Ìf3ÿ™™ÿÌÿÿ3ffff™ÌfÿÌ™33ÌÌ™ÿÿÿÿ33f3™ffÌÌf3™ÌÿÌ33ff333™f™™Ì™ÌÿÿÌÿ3fÿ’s tRNS@æØf IDATxÚí}‹bÛȱ¥<-Q²ÚY9}Û˜€b2Iïí €ZJ@(è^ˆÿÿO[§ªI"=Ö$»kxìáìg½ëTãââ+qÎ-®¢÷iã´ÖÖiã´rN¹p³¦ûtj1[Wþ¿¯èNG?ÐVkg ‡o2j\;Åòûš~OÿÅè6Õ&îõˆÝüââ“£~'Ýçk4­ç¸ÃÚqɇáçÔ“(\5¸Ž¶{b ¿ÏD™,q\§&¶.C§àZe…ìרyý;"ª7AL㽑Íoˆ³¢ý»éSKSÑî›tš9ב0Ö<*!*Z­ƒuKXzh•G÷Óuc¦õãùvÅ]f´‹Äº$óþJy—¬—¼M4ÇTæeð-Íúv SWFó핚ÓV|¨!J0ÚÃd¥¢9í™ë5J?¨ 3<¿,z_Í6$þÖSÆ ¦•©d>N³Õõh:Û¸vžÛQ÷¶}éÇÓ )ÍÕêz1kLg!Çû»Ö‰î .›ŒÇ£ÑÝjv=¾&qgÛ8eìpζPpõÕ {:}÷cg‰8ƒM‚E7ºGeŠ­hDä@aU‰ðŸÃ Öx>sà®À&iÖ°²Œå¶i¿$AŒVRëü±ÑÄÛØl¢›!N‰êÜ€ó ˜,U`¤V•“7ÅÑÃ×ÍÅ÷»âÁ7ý¡ì«þ/ã×ÿºË¸e“%Y>-߸õS’Ø%8ÞyÞLsć~Ò±–lÈØ /È,`3𾓻¨ñ¢ÐÓE…÷$`v~’±u¯Y:‘öí ê…t_d—Ld,_D?µj@â^üëTw¿hmA¥ì[-]¡ô YæíÎæÝlq‹27Gãů¬)ˆT  4U È{kïk8櫺S(u©x…Yó© e¾tkU™2Ú!þ¨–é¹NÊ$.‡ ÂGõ ‰ë¥à)šV-¤ÌÓÚôÈ)Û™¹7÷УµöÀ2¶mTûò‚*§÷,ÀŽdÙAÜSûI+-K? Ï¡‡YÙÓ:^Áü7 2†[QhWE­ÑJø/ì!QÚpqÊDTºÀ9¦¤}-ã‹Ö7aÓ*­>È^i·ŒŽ)˜V»Ü“ˆIÏd²Ý—ŸÔø}c"ÌàTÉýW2ÐÞ²WD¯ÁDl’¥J)ÆH|S[o¯o/õt”4o’6žã° ι½]•ù4KS–d¥ÿ9Êá~‚ä*#jÚ,GRMæÏ;ÔMJ Ž ¦Û#ξß±Ýöz§É({H@]\&åüžÌå>ùò„&ÈYÅãÑx:þÍô‘±Û ›E1iÜé.toK0ÁàÖó)Ý»Xlè'½A¸”XhÒÜjŸ\Åt4R]IJ÷Ö0ìLRÂ6ùºZ}½ÛL–}ã¤gÃu/]ô:F«ÕÝb6Êæ´«TîZ'ݘz:šáÔA¯‡†mfÿƒõ§¾‰ë¾Œ7›»¯×w£Í«*Û9È@™Ã*Ù"WÔÙ\ãß,£ßÉd›sMÙüÙL³ºsÈü¶¶§á+ÖØ¸×ׯß@;»a£Y3õ’ yåšDFÌ bSrßʸç³ÎhGVßê¿2jÒª`&âÛíí:DM ©õºI\`=UÆ}'Ûˆ"D¤J`ã»ýp1û+cXnpK•i®ª”#)$}Ô…‰|Õ„ÿ&U*M+]¨zÐ&›Ô¬?i…„)Äô;ê¡Fl÷ñ¥a^ÏO1”n¼Í÷/5ªâ-¯úbËo72w>?`$z—¼~êûð¾‹AË5>ÐßÞÝû­ïØ­qü¯5]ÿHY dbª$Yg>Ì(¬i„ËohXe s(ÛvüŠ ,±5‰# ±ˆo”Èð·9µm—‘ò•b‘` È ÅáÄ–`¡"С%HÂÜjöuÿîÕd£æÁÈÔµ CÏy°òÆÑ>ð¶s‘¦Þ"õîÜA{é z éÚªJÃ/}h_k%i’b˜Ulýk½„?œ×Cfæ2c˺‚Ø“QbeMiòT[-Q73Â7†¿G(…fª š«|Âqø£û]4 ¤!¾YÇ•xJ¼Þ’ºñ’qRYZpÃ;Ì&•¶:¥ŸyƒžÆSN¶º€ü‹a(,Aayö•óR³Fh”ÿ%³ › CBWVú®`;+w®œì´Ï¨_eã|¸ yE÷÷q|¿/²'už›0.Ì…É6ÅPémmÙXºÒܹB@ŠtI=Ÿ"Rj„ªJyÒåÀ ÙE\b@ÙŽyHTÙ¾ËôÇ'Ò²²#ç¡¶~ÔzOh‹ŠŠ¼1ŽtšŸŽsPžtI£Rs¦œw±O87¬ˆawÐfØz~Fó K&cP†)Š´ØjÉ¢"’Lž|åõ©²¥i²L6‚K·¤b:ƒAVMüyÃñë”\áúÔeª'b`øÌŒÄx˜ÈS·‹$‹Ñ~ÊŽ<1šàIM=9gjvÑŽuøÓºPžR­ö²·Âè?D¢Ë§ó6›œ ìWíFƒ]Èé…Y65$W}®2)™õöL6×íþ)ظ¬'Ÿ¿E}«”¼ÚÝŸñÀ%ÕÄQ¼|r³{Ñ SÌò2qÁQ!KœÞÕhõPÁrVƒ¼Ï·‡Ñ½Î²ÆO0HWI·#$¹{æ}}ÀYspK·¤DFƒ^ºní8y,ïRqÿKÉ0²=KrÞ]àtTþØ}m–¢‰+ØŒº€¤ÿv#òüµÉ’²¯t»Š&%S!E+5;a'™C6¬-‘#¶Bf :©kœþÐÒ§•89l£Ú=SÂÂh.¾u/ÆR#@±_»æ`QåÃKœÐ6²œ ÷ÌÒ6 =´¯4­0µç–¼}P¡Y¶L^wÛy)gŠóù;f£ª*NºðoؘTmŠ`ìšv‚’þ€£¦$~È1¦c"./ ‡Ë ŸÓJ+ÅÎŽEŠQìgËþxI =PCôž”PtŠ¿Rf„‘W¶ î/§ºÈÑd)Ã릦ÀlÉ@Ä«„)r†Æ*]ÂeäŠp$­<„D(,H¯üDGë`hΛ“ÉŒ¸˜0'&0/nþ¿ ýqÁÄIâ8>yŒ‡ï‡£•ñT÷þqèc¸ƒø”h?–¸÷qÀÑA­G|`™~þï‘ÿq•Ú¤\H}}j•ùïmÙÁEsËd¹ôÉèö¥ëÒÔN¥æÛ&•›}j>‘Ø´º¬ AÙÒ`Îî†BÖdë$ Ñjš÷É#íÁlíŠÑGÓdÍ%7KjF·W0klá#ž)ÏqVËŠŒ‘â¤Öu"ëÎnV…à¦n1'HÂU08,çWÀ­ †‚TæÍ@<­w’´ó® ÌBd`“ñTt‰îÃÔ©ŒÏ¤q(êèJ)硈VR]X!ʼnuÀ=–lÁÒÜÁDt ÚÖð•ôgþ¬}Ã;Ú†;*M+Ôî>Å‚×7Žð‰u½U„…q ýu ëûÀZè@ð‚2¡«ðFWå½c$8¢|ÖüõÃpû™_ ²Ã¥tñraAxÜbÛrЇ£¸Ò`e}ÂAØ›ˆÊ-SÃ%#ÉS6å%ê ø1‡ìZX£´tœ ®ñaÍʯ’Éwc}«U¶ç4G{w°ÆeIaìi€Œˆ)&$%Æraöb¢É:ñÛ ë=ÅÒWe­óÓÐ0ñ,/ Ù£Ì_t#ñM…7¬~›þgêíšÆÛßX^T±«5/9IMÉZp@ î#£~,ïBÊ.ã¸1Þ0üÔZomð’æÅËÉ|iÎઠksCqLr9^åÈ1Õ#0Ä(*+(Ÿ­EâØ3G/Sì\ª¶k™Ã †,Ü'¶Fç1ýß³½Zs¸K8̤ŒwÄÀ²gVÔ Á4»¼cNŒY˜utsss?%­?”ˆRË ZÚð É}·Bkú{¶5V˜¥a5¡'䳈èCÌPÚºJ»P ÇC v`,¼¡7÷ó(Kb2žRÞJš%!_›2ñ 4Ýœjý×al¼á&—¬*{I¢Rõ²zgxŒÏÓ€Œ- óÕƒ˜Ñ hYU‚ç=ËöS^P*+i7x’ªë€“˜`FžƒÍσ¢BÀÇè>V¥i¿ƒe¼ŽœUÎÂæó³:h>9S‰¦v\ý±ÙuÐHt)`E£oÏ «6…âL䈋^DM=U&X'êœÐ°då[8ª‘˜”îPs†5[±EÂÆDQœVõV‚.huÜV‡”­XÅ1GH0—§ån|‹¦à_±Pu\Ê£ímñ‚!¨fáõHß›òTË6 ÑÚd¶n*I^”©;±>ÛÚ§ÎÁw™xÒqLQE¾FS’”·¬ÑHÊ+H£³¢܇×q$9·L¼I!É%܆¼ø‡3shœqdÕ ór+ªæ÷–m]*@¥ˆ1g{˜…eÄ‚Íï÷:`íD}FIqãÙyÀ¼4ÁV\9°B¥®EkXs>rE4ËnÜ‘ã}6Äâ¤nǦd×ç§{Àgi¾£M$š‰©–a*Pùg‘Úù†ê ¼ŠØš„-Io©ÌääP‘﯒ÙW(ž¹£‚¿Á$á\•kúLJ¢rçÎH~€$È¥„¦Ì°ó&ã?L >®íX²åÜ ¥ `ù¥Iʽðj’eËìÒe]J[k.êaÐrÙâzæÌ fµÁ Øjž–îrÍþ8* d¦MƒÄ26š=Å3‡®U9éÇoi]¨ñ%ë<ÃŒ>…oAlÄ\z`2TåÑ.Ph°…9Ñ´2!±Á6O>º‡‰ª[îâ.ŽebIUö’°*<3¦ÿÖû;¾ƒ‚eƒ¶O–+b8ªHúI^¡K£uIp-×SŽ$² 5•‡jÖµ§a8µ©:¦H&[šÜ”¡F;_]özBŽ‚€Ça#£‡Ôyãñeè>¢ãÅ›ˆ§•ç·’™{Q¿Ø•|r®„LÈR¯Oj C¡H«œn>7úù‘1 WÓÅt:c|ÂÕ•ÜèÒ™ž¼F?•ÀiØñÕõh´@2™Þ>'78m+ئÖD§ùy&©â—)£6¦Ó¯‹ÿ½˜ù½F.~(.ðYkÕS|â å(¡6׋Åׯ×#Z§Íl¶yè {Y}…š­”ûÑkí¢GÉ„«¯ Ì×¼NÔA4à¯i£¸V î€]¾C£ÑÞ×Ñu‹{¸Ç¡’ýmæÈœ7Ô?<9\{Ä·6ñßxWG×_}û_ï3ÚÕìc®W™‡¢'”ó=ø¤÷Ñ*‰ù,°ŠÍâk‹ Y,f³Ñ­]>àqê” ½×A“ ÖzÏ¿p×½ö™-~MÔÞ¬¸Ø_#"ªëçíæI <ÇCÚ!ú'¨†ÆzLK´.÷'vVðŒz+ö‡9Ø– C6×¼_ïfŒÿ™&É.VÅaŠxží7—±¼$+wiæÀlŒ6£kÐÑìn¶råÆíÍÖ‰ó1go·Y_Bü v`–:úeÌS 9±øJ›1Ap•Æûáo%ÅÎÛxÉš­ÌCÐW<3ƺoˆ_GÀH½>4ÉÎ’JøÞ8ñÑL’HÐî€p"«³þ2½€Îf41 ­éãNûËÎÑÛvÒš&C¤7?ŒÎ¡6ÌmÔÃë+€jÄÛÊ:‹•½±~k¶Œ°D!~OˆµÙ-5UÙ6øGp¢Ú·®*½E2>r}0yñÁ¦´C¯¯²JÔÑ9$ýö/?0¼üÜÖ|;’à3@å°[\"nþ,=~IšÄmã·Îñíq;Ä_PB¥Í0`42¶ìèÐþöÆ—dd Ù!ºO·H(¸ŠÀ(!F«sU¹/Ü‚¯ØsáT’0‘kF:#ª[X·×þ…u;€¤|RƒUÃaj‹jö×I³”c4ºb÷}€S· äµ9S:ç]®ºØ3¤;Ë¡*5[rúIËÑ|Æ3×ã"sjv™¶‰EÁÛ#0¿ãQg¨ÿÉhñƒèi“an`}„N8" JÑyKIJ'™`¾ÉÑ”åÈÖkÚÓËÄÇg”²J¢ÊøÕ愉ãµÎúÈ#â‡äçyPžf÷¾Mýrd&ñe>:„|¾­>‘bx°U‚£f’н¼WH0ôQì0 ø.Ôa—õ1k‹TÒeR’ B…Ñ!2i°ç³fÆÒeŸñxx¦”¤uSøL "xrÒ@@÷ƒM×¥%.æ ‹ŒÏœqã—)IË–Oï²Ò\!Ö›ª*ØpÊgƒËúIJr³oiÖH%+Ÿ§Ó)Ç!+-Ð΂qòÈ .‡ÔœǪù%LW\±aCMxHŠ×+D&}¦ Ž~t.ÚëéIBŶ²‚÷¡‰Ê“ò¥©A„ÐõûoÂ’‘7Éèöºôõ£)*ÝéÎÑFERÄô;!ÇQIŽ¿yþD~=Ÿ?Ï¿ n~ï!|_wÿñóãºâx8Àu(¸ýƒ8\ƒíníXoßûÖWñ)ÄgvpqÔ±ûôŒ¶Ð”ÛUàûŸ·ŸÆÛ Ù‚³ˆ‡ÇÕ~|Î †nˆü.Þ›óÛ›Ê?®׿υ2e²îÉ1O–È’µŸ¡:?‘ó<œ1å¿ÓpMúßì–ÐP½ƒ²\/É+jóéýÛ5œ—Äõ0ŒòF™Ñ ÉŽÏhy³Ëì’†»Î°ÖλXþ”‚~ØÅ%þ€21kuŒÉN†ùƒ&b˜2’OI¶¦Ñ6’ñ•ôo ü`ð„ NíÒc/;$2'Yƒ³Ùy0ß­~¿y€ .yGkéÏÌЉàO¯ëÏS 8UÆÑôÖ¼Ài›<þÊŸç‹…ØçÔ¿*¾¬[‚×dDÇÓîÒ Rr°R-XíQ‚œ²×…¯+•ƒR]µ€[¿ãÓOƒ‰|Rp`ù}fe§»ËÌ“I{¾g¬"ŸãS!îcg¬+qºðÉvO1®=Ç(œÖ§mJ‹@Sä´ž®ðŽ·…¦¡~g(×¶éjß%ÏÊ£QÖƒ|ufF«S^г?×ÐHìH%Ä ™ˆo‚ƒÃJKœÌÌGús[ø`Ùo¹ŽÙTª(éÿŶ԰šAȦjS1>¸…|ÏKÎgt¶ÔËíÜSñ‘ÒJX£åmeLy&öH—~J²Þé8•r[ fAÁ+V-QTˆmð /uˆªåZí²p¢?‰%„㨡-xÀòÓ7"϶‡l‹œ® DÐʯ"DgÛ —§‘¸•’ñóO;tŠobUÂ'&,Ò•ò¥¡m„‘¶á¶<í\"?i¡Ê¨Ê쾬3maIÁ¨ jU`Ø-¦P•&lqfŠ ŒòG·ŠÌ¯o*¨ÊcøëmV§j·7E0o?Y5B÷|ôŽ5¼Êa¯ZJ"ª×$©É˜ÉÊ´Pû06ƒÓG«^ùHX€qº^Ð/Ž%úVÏ?GPd«lµöˆ*ͤèH¶ðDÓ BèÞŸ&š­"t_ÇÒ|Õ.2ŸÏ+ÒŽíZ¤W7kÌ´àâ×~°8»çpî>i~nXWÉiÏB†ÚKM£[$g•zHLàAÁÓr#"¦d=¤L ˜·ásZ˜g™w Ý˜X¼fHEµy=‚åø[?Õ“ˆÁTí¡²“ Ÿúqd4­'GŽˆ—z3„W‡A;ÌC¬0µ8Skh$=ÃÉhª¯nxåY|WйÊ#D•WМeå’ áŒâùM|sÿßyß7sÃDd_œU­mhå|0ü«·Ãq†^Z…-ØÇ$žþ[¶w­Jª¤ÊÅÄFìÁ->A­It?ž.À,Ânp¿I«Ú4?ý# ¦jÏió'úNö¶À°Õ#øBº_T¹ñV±XñV±ì¤<Š剱vç{7sËNØVKRŸ,"0•i§Úd v‘.[/Y³(Im9Ƭû]«ø™&Äyl¿ÑØiÉo¾g|æ)÷3`!j‚úó’õJ`¾JÔ1éí$ÚÁ,ɽ‚ÉaTWñÅrßäìÕ þæþ]bKeÕó4aØÂ(a›šºõßâÌÆ;Çz8ÈMð‰*6Í…q:~´Žæïƒ×”¸V½x¿OÅH;ÕÆLmòh'³Ë"Ô»ÜÎC8´·ÑÅ»àÌp½gX˜LPo‘·Âj”LÙÔèl¶ |ö“-ÖeP%• ž2æï˜RpZÑ»xkÊ[ÖŽŸ”!gR4·S’å¼ðž´¿Áœƒ9cøü÷|Eï5þdMÄ®µbrimW¶±lýÁ.1ù×&k¸îæ-;G…Ôaúro-Îâ%ø]Èg ÖeÞkëj&Å‹&TKIÞÞ á2/øq¾¢é§^©zš|÷уvöaƒ éÛ³^µ¥> ÀÎÁ3ºO.ɒֹœTkNxÆnE^×=@¯Ë໦Bµ6¼ˆH!ê¡ZÕ¦†ˆË£€¡#öOˆTr° Dè‚ï¹ %LÔÓ–r´ ÕàŸƒ€#yc„‚Ä!c|”D¬@¯Òt>’ EpߎÈX}šxÄjÚ·±¨ ó€šFrPœÈŠ,ò;Jü~Š[£øXWT çï!¸ÂÙûº³R‡øX:™ µlOš(|Ö¶QZñÈÄ¦à ™‘“÷Ó °S½™ â '³×&zxH¡úð <–BwÕý|&ûÝìxÀC‚q‹‚ð÷ …c/P~gL¥æ¬ÝÌA˜Œ\Ên9{ŠEkOs´ÁC¼ˆËØkcÃôúð¤NQÿ…ñ8lÐè%`kÝéÈ]”Ð1SUÊ;IÍ©þ€)\À_(¬i9jP¶AÁ-UŸ'wô> QB~Š#­QôÞs¨åÙ)bÕ×G b×;åµèâS`g6òtËÓì’çr–V4ï)\+Çd˜·pb½ÃiD•ñs]`Ë¥rL±Ä Jû$zžsâ\%0>ÆáÄ)p„ìm‹¾;! q8yv8ÄšÌÙ CW\¬íû |µ&o×ßõÿ =IDAT6icv<·hÊèþÍN[7 Y—ð:õ)^øèþøØiÈI¶æ|`æi)Ͱ0j{&Á}©òÈ&Ô'•Ô¡Xˆhäé“èèÑqN¢K´¢ÈK–[‡,æÖ!€ìž”½‘™~¾’Hö¬ûDƇg+QeðæØ>L5*»Ìh‘á”|jsÚ*¤ ‚Qßý…¹úi0yä‹{+Ée—ê“y>¤Ø7ÝÜ¢ÎsêU²Ý½C†Ê“( GK 8BVS·‚îA9>ÚìG¦ÙoV3…¨o´‘ $r8 gtqV¡Ÿ>æÇq HVm–µÍTi'hDsênë­éåãRUšoM¸6^˃%©4Þ¦a_ºéžnæ“)¢¬SæzdSðAIÎçûª.%Ì3U|ÒNÝî‚í’¹¾"øÛÔ=ˆ2Ÿ FáÁº¦…CXŽÅú á2ØÂU¯%´n÷†M3Åàõ'®øÞ<ï)œK“HêJ$÷7YRRW­±ð—,šnié`32Æ÷©Žð§So/òUžê `Ç9ÿ)ó6eÀ!±ª&-¦ÃQ¤> ûl_ Ÿ“û£¿?ßDóçû›x›<Çß|ž·g…‹ÿUOòäƒå¼MeÏÛ†ÏQ¥QÆ ‰ú÷º² v­JNÜß|—ïO…v…ÏCôëø¤€pIš²ü6B’Kܰ“­¶[ðZ2d$NÿæTˆÊ@{„ë zIn¨oe…‹­gÃ*"¼Î|†Á„Ȇ®Þ¦âÞZ£ •7>1n¾é¸s!"(f F< ò@¼D²Ä ÁÉ3VBb$Öp*Sq\ú{Ç¥¶{$šYrÙ±wüüøùË—/¿|þÂ)±œË²´)OÛ\R©^Œ_!ÁôN‹€Ÿã YüåO¨3Ü ÞUÜxñÓGšçÛO?N@{Ëĺ –Á;8PÁUýÇã/ÿ1¾¢?£Íh*uç£ÍÕ˜‹?æÈrÛÓÉÀ1/ù|_ÅrIJÿÞg“¥<ÒP_§4þ1ž€bÉ͈'ÂGÖO_p–:}qà:bЪ÷ˆ‘7Ô‘yº‰¿LÇ~ÕÇãñh6 ØøñÓ7ÿ,ÄéOÒ#îSŠK]HSã—ù÷A³â"ëÇ_°ørš®Ù‚Èhƒóü7xÌ>'ZúíÏœw?Ñ·ò™yˆ®‘³Ê‡ò¬¿/¹Òȃ2þÄ´Ïe¼r$ÂÝb6›]/6#™Ö¦AßÿF܉{ :Uƒw‚K„ØÐ÷äcèÛ’Æ?õçRðØgÄ›»ÕÝ×»Õ‚f@Ô$Ô5Âõâ–8—0:iY‹Dch£6çeœÒäi„Tœ¸=®™…S—Œ”U½†2oˆ!Ô?ü–èùíÌ6žT^ßÄ¿yÙɧ!,ö&ðõZÆ?ÚüRÏé QúüÖ°MYøs<¹òËcœ7*µOÃEH ?þ…Ÿ¨3£^ƒäï¶—ŸøxÁ’‰Íùí?רܷÈÖ,&€—1'Ž:bL~^5wlŸ ëà'ñGZ\!q9ænÕãâŸéýhÚîÑôAeäo ’lµ’ó¡%^Wи6‡b¼k¿úî­g}lE/Èd$.~| ŠrfC_¡p„ 14Æ¿á¹1Ÿ< $æ­.²U&‘`B8+Ò1Þù`°¤Å}d‡9†Ø…fðùÕ?–É›ô‡‡ÄÏh³€šXBa/I³<ð„Þ¾z•c‘O™â<àá hVžàÔiµò[1.H«Çé4ØAXmHSbˆ»klÊbÙäM¢Žúø+r©=ÄxZ+I;ÉÙ1tt`°ü˜rÆ^Ot΃ƒ'ŒOÈ‰ŠÆÁ˜úMƒ–6ØýØoÀ¯GE¾$”ç0p «¼°ÃiJ¦ÉÕ§ð8γWý‘˜ÓÞžÀh7Y÷W>jŸ?8‘?Г.×ù­K6x^€ÀÖ=ÖÀb0gÍ€#Ê ½Ÿ+wZç‚É W¿m,]ùt0¬”tUF>8Çë_ éáñ_$áM¶8TtVö±æÈ¹)o£ÿá=a?‹¿‹ì!;ûá/zM6©Ÿ%ª9ÔÍ´ÂèhÕVÀ¤g08{Á¸úº$enËÿy"‚ý]lqÃËŸÆì¼Œ½Ü§xù5IHª' q`ÃO+Îåu6ü¸NåÚ'e¥ºWÝ*2€ Ô§x®OÉÙ_Xñüý}‰&ãM°)-Àv’B ¤ó éÊ…~)S‡Ä£º*EdækF=Ï?ßüñ'ÖZ€ú¯=úxÿ‚ﻺÉÒô+)K®›«±“ ¦Dáñßᬠ.{BÀÇ6îcÝÌŸªxüqDÐëÇõãú÷êDó©úåTa¾O>^ï℃ì†~Ÿ:®Óo<}L{Ð}ã2½ùƒS÷*ŽwGuÞΠ¡áY v¸¯}‚Ù]¢ãuÆ\OÙîág[ÇG–ëÀzSxÇ œFMñÎu mµý$´·gÝŸ×v|îâ3eâ›Rî¼{“ÆÞ£§ õo“E?®×ÿ¥×ÿFô¸„ªk+­IEND®B`‚sane-backends-1.0.29/doc/sane-coolscan.man0000666000000000000000000000572013615534521015174 00000000000000.TH sane\-coolscan 5 "13 Jul 2008" "@PACKAGEVERSION@" "SANE Scanner Access Now Easy" .IX sane\-coolscan .SH NAME sane\-coolscan \- SANE backend for Nikon film-scanners .SH ABOUT THIS FILE This file is a short description of the coolscan-backend for sane! .SH DESCRIPTION The .B sane\-coolscan library implements a SANE backend that provides the interface to the following Nikon Coolscan Film scanners: Nikon LS20, LS30, LS1000, LS2000. .B Even though the backend has worked for a number of people, there are still some problems, especially in combination with some SCSI card/drivers (AHA-1505/aha152x.o) and the autofocus command. You should consider this backend 'alpha' and be careful when using it the first time. .SH CONFIGURATION The configuration file for this backend resides in .IR @CONFIGDIR@/coolscan.conf . Its contents is a list of device names that correspond to Nikon Coolscan scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: .nf #scsi Vendor Model Type scsi Nikon * Scanner /dev/scanner .fi The special device name must be a generic SCSI device or a symlink to such a device. To find out to which device your scanner is assigned and how you have to set the permissions of that device, have a look at sane\-scsi. .SH SCSI ADAPTER TIPS Some SCSI-adapters and low-level SCSI drivers do not work correctly with this backend and the Coolscan scanners. These systems hang when the autofocus command is send to the Scanner. To see a list of which card/driver combinations work or don't work have a look at: http://andreas.rick.free.fr/sane/autofocus.html. .SH FILES .TP The backend configuration file: .I @CONFIGDIR@/coolscan.conf .TP The static library implementing this backend: .I @LIBDIR@/libsane\-coolscan.a .TP The shared library implementing this backend: .I @LIBDIR@/libsane\-coolscan.so (present on systems that support dynamic loading) .SH ENVIRONMENT .TP .B SANE_DEBUG_COOLSCAN If the library was compiled with debug support enabled, this environment variable controls the debug level for this backend. E.g., a value of 128 requests all debug output to be printed. Smaller levels reduce verbosity: SANE_DEBUG_COOLSCAN values Examples: on bash: .br export SANE_DEBUG_COOLSCAN=8 on csh: .br setenv SANE_DEBUG_COOLSCAN 8 .SH BUGS The autofocus command does not work with some SCSI card/driver combinations .PP The gamma table is not implemented for the LS1000 yet. .PP The dust-removal is not working yet .SH SEE ALSO .TP .I http://andreas.rick.free.fr/sane/ The homepage of this backend .TP .I http://www.sema.be/coolscan/ The original version of the coolscan backend by Didier .PP sane(7), sane\-scsi(5) .SH THANKS TO .PP Didier Carlier \- For writing the original Coolscan backend (without it I would not have started this) .PP Oliver Rauch \- For adapting xsane so quickly to the infrared stuff. .PP All the other people working on SANE. .SH AUTHOR Andreas Rick .SH EMAIL-CONTACT andreas.rick@free.fr sane-backends-1.0.29/aclocal.m40000644000000000000000000031225213615534553013047 00000000000000# generated automatically by aclocal 1.16.1 -*- Autoconf -*- # Copyright (C) 1996-2018 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_create_stdint_h.html # =========================================================================== # # SYNOPSIS # # AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])] # # DESCRIPTION # # the "ISO C9X: 7.18 Integer types " section requires the # existence of an include file that defines a set of typedefs, # especially uint8_t,int32_t,uintptr_t. Many older installations will not # provide this file, but some will have the very same definitions in # . In other environments we can use the inet-types in # which would define the typedefs int8_t and u_int8_t # respectively. # # This macros will create a local "_stdint.h" or the headerfile given as # an argument. In many cases that file will just "#include " or # "#include ", while in other environments it will provide the # set of basic 'stdint's definitions/typedefs: # # int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t # int_least32_t.. int_fast32_t.. intmax_t # # which may or may not rely on the definitions of other files, or using # the AC_CHECK_SIZEOF macro to determine the actual sizeof each type. # # if your header files require the stdint-types you will want to create an # installable file mylib-int.h that all your other installable header may # include. So if you have a library package named "mylib", just use # # AX_CREATE_STDINT_H(mylib-int.h) # # in configure.ac and go to install that very header file in Makefile.am # along with the other headers (mylib.h) - and the mylib-specific headers # can simply use "#include " to obtain the stdint-types. # # Remember, if the system already had a valid , the generated # file will include it directly. No need for fuzzy HAVE_STDINT_H things... # (oops, GCC 4.2.x has deliberately disabled its stdint.h for non-c99 # compilation and the c99-mode is not the default. Therefore this macro # will not use the compiler's stdint.h - please complain to the GCC # developers). # # LICENSE # # Copyright (c) 2008 Guido U. Draheim # # 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; either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 19 AC_DEFUN([AX_CHECK_DATA_MODEL],[ AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(void*) ac_cv_char_data_model="" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short" ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int" ac_cv_long_data_model="" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long" ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp" AC_MSG_CHECKING([data model]) case "$ac_cv_char_data_model/$ac_cv_long_data_model" in 122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;; 122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;; 122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;; 124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;; 124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;; 124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;; 124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;; 128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;; 128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;; 222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;; 333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;; 444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;; 666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;; 888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;; 222/*|333/*|444/*|666/*|888/*) : ac_cv_data_model="iDSP" ; n="unusual dsptype" ;; *) ac_cv_data_model="none" ; n="very unusual model" ;; esac AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)]) ]) dnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF]) AC_DEFUN([AX_CHECK_HEADER_STDINT_X],[ AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[ ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h) AC_MSG_RESULT([(..)]) for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h sys/types.h]) do unset ac_cv_type_uintptr_t unset ac_cv_type_uint64_t AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>]) AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>]) m4_ifvaln([$2],[$2]) break done AC_MSG_CHECKING([for stdint uintptr_t]) ]) ]) AC_DEFUN([AX_CHECK_HEADER_STDINT_O],[ AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[ ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h) AC_MSG_RESULT([(..)]) for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h sys/types.h stdint.h]) do unset ac_cv_type_uint32_t unset ac_cv_type_uint64_t AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>]) AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>]) m4_ifvaln([$2],[$2]) break break; done AC_MSG_CHECKING([for stdint uint32_t]) ]) ]) AC_DEFUN([AX_CHECK_HEADER_STDINT_U],[ AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[ ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h) AC_MSG_RESULT([(..)]) for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do unset ac_cv_type_u_int32_t unset ac_cv_type_u_int64_t AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>]) AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>]) m4_ifvaln([$2],[$2]) break break; done AC_MSG_CHECKING([for stdint u_int32_t]) ]) ]) AC_DEFUN([AX_CREATE_STDINT_H], [# ------ AX CREATE STDINT H ------------------------------------- AC_MSG_CHECKING([for stdint types]) ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)` # try to shortcircuit - if the default include path of the compiler # can find a "stdint.h" header then we assume that all compilers can. AC_CACHE_VAL([ac_cv_header_stdint_t],[ old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS="" old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="" old_CFLAGS="$CFLAGS" ; CFLAGS="" AC_TRY_COMPILE([#include ],[int_least32_t v = 0;], [ac_cv_stdint_result="(assuming C99 compatible system)" ac_cv_header_stdint_t="stdint.h"; ], [ac_cv_header_stdint_t=""]) if test "$GCC" = "yes" && test ".$ac_cv_header_stdint_t" = "."; then CFLAGS="-std=c99" AC_TRY_COMPILE([#include ],[int_least32_t v = 0;], [AC_MSG_WARN(your GCC compiler has a defunct stdint.h for its default-mode)]) fi CXXFLAGS="$old_CXXFLAGS" CPPFLAGS="$old_CPPFLAGS" CFLAGS="$old_CFLAGS" ]) v="... $ac_cv_header_stdint_h" if test "$ac_stdint_h" = "stdint.h" ; then AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)]) elif test "$ac_stdint_h" = "inttypes.h" ; then AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)]) elif test "_$ac_cv_header_stdint_t" = "_" ; then AC_MSG_RESULT([(putting them into $ac_stdint_h)$v]) else ac_cv_header_stdint="$ac_cv_header_stdint_t" AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)]) fi if test "_$ac_cv_header_stdint_t" = "_" ; then # cannot shortcircuit.. dnl .....intro message done, now do a few system checks..... dnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type, dnl therefore we use the autoconf implementation detail CHECK_TYPE_NEW dnl instead that is triggered with 3 or more arguments (see types.m4) inttype_headers=`echo $2 | sed -e 's/,/ /g'` ac_cv_stdint_result="(no helpful system typedefs seen)" AX_CHECK_HEADER_STDINT_X(dnl stdint.h inttypes.h sys/inttypes.h $inttype_headers, ac_cv_stdint_result="(seen uintptr_t$and64 in $i)") if test "_$ac_cv_header_stdint_x" = "_" ; then AX_CHECK_HEADER_STDINT_O(dnl, inttypes.h sys/inttypes.h stdint.h $inttype_headers, ac_cv_stdint_result="(seen uint32_t$and64 in $i)") fi if test "_$ac_cv_header_stdint_x" = "_" ; then if test "_$ac_cv_header_stdint_o" = "_" ; then AX_CHECK_HEADER_STDINT_U(dnl, sys/types.h inttypes.h sys/inttypes.h $inttype_headers, ac_cv_stdint_result="(seen u_int32_t$and64 in $i)") fi fi dnl if there was no good C99 header file, do some typedef checks... if test "_$ac_cv_header_stdint_x" = "_" ; then AC_MSG_CHECKING([for stdint datatype model]) AC_MSG_RESULT([(..)]) AX_CHECK_DATA_MODEL fi if test "_$ac_cv_header_stdint_x" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_x" elif test "_$ac_cv_header_stdint_o" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_o" elif test "_$ac_cv_header_stdint_u" != "_" ; then ac_cv_header_stdint="$ac_cv_header_stdint_u" else ac_cv_header_stdint="stddef.h" fi AC_MSG_CHECKING([for extra inttypes in chosen header]) AC_MSG_RESULT([($ac_cv_header_stdint)]) dnl see if int_least and int_fast types are present in _this_ header. unset ac_cv_type_int_least32_t unset ac_cv_type_int_fast32_t AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>]) AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>]) AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>]) fi # shortcircuit to system "stdint.h" # ------------------ PREPARE VARIABLES ------------------------------ if test "$GCC" = "yes" ; then ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1` else ac_cv_stdint_message="using $CC" fi AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl $ac_cv_stdint_result]) dnl ----------------------------------------------------------------- # ----------------- DONE inttypes.h checks START header ------------- AC_CONFIG_COMMANDS([$ac_stdint_h],[ AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h) ac_stdint=$tmp/_stdint.h echo "#ifndef" $_ac_stdint_h >$ac_stdint echo "#define" $_ac_stdint_h "1" >>$ac_stdint echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint if test "_$ac_cv_header_stdint_t" != "_" ; then echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint echo "#include " >>$ac_stdint echo "#endif" >>$ac_stdint echo "#endif" >>$ac_stdint else cat >>$ac_stdint < #else #include /* .................... configured part ............................ */ STDINT_EOF echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint if test "_$ac_cv_header_stdint_x" != "_" ; then ac_header="$ac_cv_header_stdint_x" echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint fi echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint if test "_$ac_cv_header_stdint_o" != "_" ; then ac_header="$ac_cv_header_stdint_o" echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint fi echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint if test "_$ac_cv_header_stdint_u" != "_" ; then ac_header="$ac_cv_header_stdint_u" echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint else echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint fi echo "" >>$ac_stdint if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then echo "#include <$ac_header>" >>$ac_stdint echo "" >>$ac_stdint fi fi echo "/* which 64bit typedef has been found */" >>$ac_stdint if test "$ac_cv_type_uint64_t" = "yes" ; then echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint fi if test "$ac_cv_type_u_int64_t" = "yes" ; then echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint fi echo "" >>$ac_stdint echo "/* which type model has been detected */" >>$ac_stdint if test "_$ac_cv_char_data_model" != "_" ; then echo "#define _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint echo "#define _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint else echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint fi echo "" >>$ac_stdint echo "/* whether int_least types were detected */" >>$ac_stdint if test "$ac_cv_type_int_least32_t" = "yes"; then echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint fi echo "/* whether int_fast types were detected */" >>$ac_stdint if test "$ac_cv_type_int_fast32_t" = "yes"; then echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint fi echo "/* whether intmax_t type was detected */" >>$ac_stdint if test "$ac_cv_type_intmax_t" = "yes"; then echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint else echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint fi echo "" >>$ac_stdint cat >>$ac_stdint <= 199901L #define _HAVE_UINT64_T #define _HAVE_LONGLONG_UINT64_T typedef long long int64_t; typedef unsigned long long uint64_t; #elif !defined __STRICT_ANSI__ #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ #define _HAVE_UINT64_T typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__ /* note: all ELF-systems seem to have loff-support which needs 64-bit */ #if !defined _NO_LONGLONG #define _HAVE_UINT64_T #define _HAVE_LONGLONG_UINT64_T typedef long long int64_t; typedef unsigned long long uint64_t; #endif #elif defined __alpha || (defined __mips && defined _ABIN32) #if !defined _NO_LONGLONG typedef long int64_t; typedef unsigned long uint64_t; #endif /* compiler/cpu type to define int64_t */ #endif #endif #endif #if defined _STDINT_HAVE_U_INT_TYPES /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */ typedef u_int8_t uint8_t; typedef u_int16_t uint16_t; typedef u_int32_t uint32_t; /* glibc compatibility */ #ifndef __int8_t_defined #define __int8_t_defined #endif #endif #ifdef _STDINT_NEED_INT_MODEL_T /* we must guess all the basic types. Apart from byte-addressable system, */ /* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */ /* (btw, those nibble-addressable systems are way off, or so we assume) */ dnl /* have a look at "64bit and data size neutrality" at */ dnl /* http://unix.org/version2/whatsnew/login_64bit.html */ dnl /* (the shorthand "ILP" types always have a "P" part) */ #if defined _STDINT_BYTE_MODEL #if _STDINT_LONG_MODEL+0 == 242 /* 2:4:2 = IP16 = a normal 16-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef long int32_t; #endif #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444 /* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */ /* 4:4:4 = ILP32 = a normal 32-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif #elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488 /* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */ /* 4:8:8 = LP64 = a normal 64-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif /* this system has a "long" of 64bit */ #ifndef _HAVE_UINT64_T #define _HAVE_UINT64_T typedef unsigned long uint64_t; typedef long int64_t; #endif #elif _STDINT_LONG_MODEL+0 == 448 /* LLP64 a 64-bit system derived from a 32-bit system */ typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifndef __int8_t_defined #define __int8_t_defined typedef char int8_t; typedef short int16_t; typedef int int32_t; #endif /* assuming the system has a "long long" */ #ifndef _HAVE_UINT64_T #define _HAVE_UINT64_T #define _HAVE_LONGLONG_UINT64_T typedef unsigned long long uint64_t; typedef long long int64_t; #endif #else #define _STDINT_NO_INT32_T #endif #else #define _STDINT_NO_INT8_T #define _STDINT_NO_INT32_T #endif #endif /* * quote from SunOS-5.8 sys/inttypes.h: * Use at your own risk. As of February 1996, the committee is squarely * behind the fixed sized types; the "least" and "fast" types are still being * discussed. The probability that the "fast" types may be removed before * the standard is finalized is high enough that they are not currently * implemented. */ #if defined _STDINT_NEED_INT_LEAST_T typedef int8_t int_least8_t; typedef int16_t int_least16_t; typedef int32_t int_least32_t; #ifdef _HAVE_UINT64_T typedef int64_t int_least64_t; #endif typedef uint8_t uint_least8_t; typedef uint16_t uint_least16_t; typedef uint32_t uint_least32_t; #ifdef _HAVE_UINT64_T typedef uint64_t uint_least64_t; #endif /* least types */ #endif #if defined _STDINT_NEED_INT_FAST_T typedef int8_t int_fast8_t; typedef int int_fast16_t; typedef int32_t int_fast32_t; #ifdef _HAVE_UINT64_T typedef int64_t int_fast64_t; #endif typedef uint8_t uint_fast8_t; typedef unsigned uint_fast16_t; typedef uint32_t uint_fast32_t; #ifdef _HAVE_UINT64_T typedef uint64_t uint_fast64_t; #endif /* fast types */ #endif #ifdef _STDINT_NEED_INTMAX_T #ifdef _HAVE_UINT64_T typedef int64_t intmax_t; typedef uint64_t uintmax_t; #else typedef long intmax_t; typedef unsigned long uintmax_t; #endif #endif #ifdef _STDINT_NEED_INTPTR_T #ifndef __intptr_t_defined #define __intptr_t_defined /* we encourage using "long" to store pointer values, never use "int" ! */ #if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484 typedef unsigned int uintptr_t; typedef int intptr_t; #elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444 typedef unsigned long uintptr_t; typedef long intptr_t; #elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T typedef uint64_t uintptr_t; typedef int64_t intptr_t; #else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */ typedef unsigned long uintptr_t; typedef long intptr_t; #endif #endif #endif /* The ISO C99 standard specifies that in C++ implementations these should only be defined if explicitly requested. */ #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS #ifndef UINT32_C /* Signed. */ # define INT8_C(c) c # define INT16_C(c) c # define INT32_C(c) c # ifdef _HAVE_LONGLONG_UINT64_T # define INT64_C(c) c ## L # else # define INT64_C(c) c ## LL # endif /* Unsigned. */ # define UINT8_C(c) c ## U # define UINT16_C(c) c ## U # define UINT32_C(c) c ## U # ifdef _HAVE_LONGLONG_UINT64_T # define UINT64_C(c) c ## UL # else # define UINT64_C(c) c ## ULL # endif /* Maximal type. */ # ifdef _HAVE_LONGLONG_UINT64_T # define INTMAX_C(c) c ## L # define UINTMAX_C(c) c ## UL # else # define INTMAX_C(c) c ## LL # define UINTMAX_C(c) c ## ULL # endif /* literalnumbers */ #endif #endif /* These limits are merrily those of a two complement byte-oriented system */ /* Minimum of signed integral types. */ # define INT8_MIN (-128) # define INT16_MIN (-32767-1) # define INT32_MIN (-2147483647-1) # define INT64_MIN (-__INT64_C(9223372036854775807)-1) /* Maximum of signed integral types. */ # define INT8_MAX (127) # define INT16_MAX (32767) # define INT32_MAX (2147483647) # define INT64_MAX (__INT64_C(9223372036854775807)) /* Maximum of unsigned integral types. */ # define UINT8_MAX (255) # define UINT16_MAX (65535) # define UINT32_MAX (4294967295U) # define UINT64_MAX (__UINT64_C(18446744073709551615)) /* Minimum of signed integral types having a minimum size. */ # define INT_LEAST8_MIN INT8_MIN # define INT_LEAST16_MIN INT16_MIN # define INT_LEAST32_MIN INT32_MIN # define INT_LEAST64_MIN INT64_MIN /* Maximum of signed integral types having a minimum size. */ # define INT_LEAST8_MAX INT8_MAX # define INT_LEAST16_MAX INT16_MAX # define INT_LEAST32_MAX INT32_MAX # define INT_LEAST64_MAX INT64_MAX /* Maximum of unsigned integral types having a minimum size. */ # define UINT_LEAST8_MAX UINT8_MAX # define UINT_LEAST16_MAX UINT16_MAX # define UINT_LEAST32_MAX UINT32_MAX # define UINT_LEAST64_MAX UINT64_MAX /* shortcircuit*/ #endif /* once */ #endif #endif STDINT_EOF fi if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then AC_MSG_NOTICE([$ac_stdint_h is unchanged]) else ac_dir=`AS_DIRNAME(["$ac_stdint_h"])` AS_MKDIR_P(["$ac_dir"]) rm -f $ac_stdint_h mv $ac_stdint $ac_stdint_h fi ],[# variables for create stdint.h replacement PACKAGE="$PACKAGE" VERSION="$VERSION" ac_stdint_h="$ac_stdint_h" _ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h) ac_cv_stdint_message="$ac_cv_stdint_message" ac_cv_header_stdint_t="$ac_cv_header_stdint_t" ac_cv_header_stdint_x="$ac_cv_header_stdint_x" ac_cv_header_stdint_o="$ac_cv_header_stdint_o" ac_cv_header_stdint_u="$ac_cv_header_stdint_u" ac_cv_type_uint64_t="$ac_cv_type_uint64_t" ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t" ac_cv_char_data_model="$ac_cv_char_data_model" ac_cv_long_data_model="$ac_cv_long_data_model" ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t" ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t" ac_cv_type_intmax_t="$ac_cv_type_intmax_t" ]) ]) # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and # CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) # or '14' (for the C++14 standard). # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with # preference for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is # required and that the macro should error out if no mode with that # support is found. If specified 'optional', then configuration proceeds # regardless, after defining HAVE_CXX${VERSION} if and only if a # supporting mode is found. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik # Copyright (c) 2012 Zack Weinberg # Copyright (c) 2013 Roy Stogner # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler # Copyright (c) 2016 Krzesimir Nowak # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 7 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). AX_REQUIRE_DEFINED([AC_MSG_WARN]) AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], [$1], [14], [ax_cxx_compile_alternatives="14 1y"], [$1], [17], [ax_cxx_compile_alternatives="17 1z"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], [$2], [noext], [], [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], [$3], [optional], [ax_cxx_compile_cxx$1_required=false], [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl ac_success=no AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, ax_cv_cxx_compile_cxx$1, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [ax_cv_cxx_compile_cxx$1=yes], [ax_cv_cxx_compile_cxx$1=no])]) if test x$ax_cv_cxx_compile_cxx$1 = xyes; then ac_success=yes fi m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do switch="-std=gnu++${alternative}" cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" CXX="$CXX $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [eval $cachevar=yes], [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done fi]) m4_if([$2], [ext], [], [dnl if test x$ac_success = xno; then dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" for alternative in ${ax_cxx_compile_alternatives}; do for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" CXX="$CXX $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [eval $cachevar=yes], [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done if test x$ac_success = xyes; then break fi done fi]) AC_LANG_POP([C++]) if test x$ax_cxx_compile_cxx$1_required = xtrue; then if test x$ac_success = xno; then AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) fi fi if test x$ac_success = xno; then HAVE_CXX$1=0 AC_MSG_NOTICE([No compiler with C++$1 support was found]) else HAVE_CXX$1=1 AC_DEFINE(HAVE_CXX$1,1, [define if the compiler supports basic C++$1 syntax]) fi AC_SUBST(HAVE_CXX$1) m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])]) ]) dnl Test body for checking C++11 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ) dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 ) dnl Tests for new features in C++11 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ // If the compiler admits that it is not ready for C++11, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201103L #error "This is not a C++11 compiler" #else namespace cxx11 { namespace test_static_assert { template struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; } namespace test_final_override { struct Base { virtual void f() {} }; struct Derived : public Base { virtual void f() override {} }; } namespace test_double_right_angle_brackets { template < typename T > struct check {}; typedef check single_type; typedef check> double_type; typedef check>> triple_type; typedef check>>> quadruple_type; } namespace test_decltype { int f() { int a = 1; decltype(a) b = 2; return a + b; } } namespace test_type_deduction { template < typename T1, typename T2 > struct is_same { static const bool value = false; }; template < typename T > struct is_same { static const bool value = true; }; template < typename T1, typename T2 > auto add(T1 a1, T2 a2) -> decltype(a1 + a2) { return a1 + a2; } int test(const int c, volatile int v) { static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); static_assert(is_same::value == false, ""); auto ac = c; auto av = v; auto sumi = ac + av + 'x'; auto sumf = ac + av + 1.0; static_assert(is_same::value == true, ""); static_assert(is_same::value == true, ""); static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); static_assert(is_same::value == true, ""); return (sumf > 0.0) ? sumi : add(c, v); } } namespace test_noexcept { int f() { return 0; } int g() noexcept { return 0; } static_assert(noexcept(f()) == false, ""); static_assert(noexcept(g()) == true, ""); } namespace test_constexpr { template < typename CharT > unsigned long constexpr strlen_c_r(const CharT *const s, const unsigned long acc) noexcept { return *s ? strlen_c_r(s + 1, acc + 1) : acc; } template < typename CharT > unsigned long constexpr strlen_c(const CharT *const s) noexcept { return strlen_c_r(s, 0UL); } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("1") == 1UL, ""); static_assert(strlen_c("example") == 7UL, ""); static_assert(strlen_c("another\0example") == 7UL, ""); } namespace test_rvalue_references { template < int N > struct answer { static constexpr int value = N; }; answer<1> f(int&) { return answer<1>(); } answer<2> f(const int&) { return answer<2>(); } answer<3> f(int&&) { return answer<3>(); } void test() { int i = 0; const int c = 0; static_assert(decltype(f(i))::value == 1, ""); static_assert(decltype(f(c))::value == 2, ""); static_assert(decltype(f(0))::value == 3, ""); } } namespace test_uniform_initialization { struct test { static const int zero {}; static const int one {1}; }; static_assert(test::zero == 0, ""); static_assert(test::one == 1, ""); } namespace test_lambdas { void test1() { auto lambda1 = [](){}; auto lambda2 = lambda1; lambda1(); lambda2(); } int test2() { auto a = [](int i, int j){ return i + j; }(1, 2); auto b = []() -> int { return '0'; }(); auto c = [=](){ return a + b; }(); auto d = [&](){ return c; }(); auto e = [a, &b](int x) mutable { const auto identity = [](int y){ return y; }; for (auto i = 0; i < a; ++i) a += b--; return x + identity(a + b); }(0); return a + b + c + d + e; } int test3() { const auto nullary = [](){ return 0; }; const auto unary = [](int x){ return x; }; using nullary_t = decltype(nullary); using unary_t = decltype(unary); const auto higher1st = [](nullary_t f){ return f(); }; const auto higher2nd = [unary](nullary_t f1){ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; }; return higher1st(nullary) + higher2nd(nullary)(unary); } } namespace test_variadic_templates { template struct sum; template struct sum { static constexpr auto value = N0 + sum::value; }; template <> struct sum<> { static constexpr auto value = 0; }; static_assert(sum<>::value == 0, ""); static_assert(sum<1>::value == 1, ""); static_assert(sum<23>::value == 23, ""); static_assert(sum<1, 2>::value == 3, ""); static_assert(sum<5, 5, 11>::value == 21, ""); static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); } // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function // because of this. namespace test_template_alias_sfinae { struct foo {}; template using member = typename T::member_type; template void func(...) {} template void func(member*) {} void test(); void test() { func(0); } } } // namespace cxx11 #endif // __cplusplus >= 201103L ]]) dnl Tests for new features in C++14 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ // If the compiler admits that it is not ready for C++14, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201402L #error "This is not a C++14 compiler" #else namespace cxx14 { namespace test_polymorphic_lambdas { int test() { const auto lambda = [](auto&&... args){ const auto istiny = [](auto x){ return (sizeof(x) == 1UL) ? 1 : 0; }; const int aretiny[] = { istiny(args)... }; return aretiny[0]; }; return lambda(1, 1L, 1.0f, '1'); } } namespace test_binary_literals { constexpr auto ivii = 0b0000000000101010; static_assert(ivii == 42, "wrong value"); } namespace test_generalized_constexpr { template < typename CharT > constexpr unsigned long strlen_c(const CharT *const s) noexcept { auto length = 0UL; for (auto p = s; *p; ++p) ++length; return length; } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("x") == 1UL, ""); static_assert(strlen_c("test") == 4UL, ""); static_assert(strlen_c("another\0test") == 7UL, ""); } namespace test_lambda_init_capture { int test() { auto x = 0; const auto lambda1 = [a = x](int b){ return a + b; }; const auto lambda2 = [a = lambda1(x)](){ return a; }; return lambda2(); } } namespace test_digit_separators { constexpr auto ten_million = 100'000'000; static_assert(ten_million == 100000000, ""); } namespace test_return_type_deduction { auto f(int& x) { return x; } decltype(auto) g(int& x) { return x; } template < typename T1, typename T2 > struct is_same { static constexpr auto value = false; }; template < typename T > struct is_same { static constexpr auto value = true; }; int test() { auto x = 0; static_assert(is_same::value, ""); static_assert(is_same::value, ""); return x; } } } // namespace cxx14 #endif // __cplusplus >= 201402L ]]) dnl Tests for new features in C++17 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ // If the compiler admits that it is not ready for C++17, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus <= 201402L #error "This is not a C++17 compiler" #else #if defined(__clang__) #define REALLY_CLANG #else #if defined(__GNUC__) #define REALLY_GCC #endif #endif #include #include #include namespace cxx17 { #if !defined(REALLY_CLANG) namespace test_constexpr_lambdas { // TODO: test it with clang++ from git constexpr int foo = [](){return 42;}(); } #endif // !defined(REALLY_CLANG) namespace test::nested_namespace::definitions { } namespace test_fold_expression { template int multiply(Args... args) { return (args * ... * 1); } template bool all(Args... args) { return (args && ...); } } namespace test_extended_static_assert { static_assert (true); } namespace test_auto_brace_init_list { auto foo = {5}; auto bar {5}; static_assert(std::is_same, decltype(foo)>::value); static_assert(std::is_same::value); } namespace test_typename_in_template_template_parameter { template typename X> struct D; } namespace test_fallthrough_nodiscard_maybe_unused_attributes { int f1() { return 42; } [[nodiscard]] int f2() { [[maybe_unused]] auto unused = f1(); switch (f1()) { case 17: f1(); [[fallthrough]]; case 42: f1(); } return f1(); } } namespace test_extended_aggregate_initialization { struct base1 { int b1, b2 = 42; }; struct base2 { base2() { b3 = 42; } int b3; }; struct derived : base1, base2 { int d; }; derived d1 {{1, 2}, {}, 4}; // full initialization derived d2 {{}, {}, 4}; // value-initialized bases } namespace test_general_range_based_for_loop { struct iter { int i; int& operator* () { return i; } const int& operator* () const { return i; } iter& operator++() { ++i; return *this; } }; struct sentinel { int i; }; bool operator== (const iter& i, const sentinel& s) { return i.i == s.i; } bool operator!= (const iter& i, const sentinel& s) { return !(i == s); } struct range { iter begin() const { return {0}; } sentinel end() const { return {5}; } }; void f() { range r {}; for (auto i : r) { [[maybe_unused]] auto v = i; } } } namespace test_lambda_capture_asterisk_this_by_value { struct t { int i; int foo() { return [*this]() { return i; }(); } }; } namespace test_enum_class_construction { enum class byte : unsigned char {}; byte foo {42}; } namespace test_constexpr_if { template int f () { if constexpr(cond) { return 13; } else { return 42; } } } namespace test_selection_statement_with_initializer { int f() { return 13; } int f2() { if (auto i = f(); i > 0) { return 3; } switch (auto i = f(); i + 4) { case 17: return 2; default: return 1; } } } #if !defined(REALLY_CLANG) namespace test_template_argument_deduction_for_class_templates { // TODO: test it with clang++ from git template struct pair { pair (T1 p1, T2 p2) : m1 {p1}, m2 {p2} {} T1 m1; T2 m2; }; void f() { [[maybe_unused]] auto p = pair{13, 42u}; } } #endif // !defined(REALLY_CLANG) namespace test_non_type_auto_template_parameters { template struct B {}; B<5> b1; B<'a'> b2; } #if !defined(REALLY_CLANG) namespace test_structured_bindings { // TODO: test it with clang++ from git int arr[2] = { 1, 2 }; std::pair pr = { 1, 2 }; auto f1() -> int(&)[2] { return arr; } auto f2() -> std::pair& { return pr; } struct S { int x1 : 2; volatile double y1; }; S f3() { return {}; } auto [ x1, y1 ] = f1(); auto& [ xr1, yr1 ] = f1(); auto [ x2, y2 ] = f2(); auto& [ xr2, yr2 ] = f2(); const auto [ x3, y3 ] = f3(); } #endif // !defined(REALLY_CLANG) #if !defined(REALLY_CLANG) namespace test_exception_spec_type_system { // TODO: test it with clang++ from git struct Good {}; struct Bad {}; void g1() noexcept; void g2(); template Bad f(T*, T*); template Good f(T1*, T2*); static_assert (std::is_same_v); } #endif // !defined(REALLY_CLANG) namespace test_inline_variables { template void f(T) {} template inline T g(T) { return T{}; } template<> inline void f<>(int) {} template<> int g<>(int) { return 5; } } } // namespace cxx17 #endif // __cplusplus <= 201402L ]]) # ============================================================================= # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html # ============================================================================= # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the C++11 # standard; if necessary, add switches to CXX and CXXCPP to enable # support. # # This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX # macro with the version set to C++11. The two optional arguments are # forwarded literally as the second and third argument respectively. # Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for # more information. If you want to use this macro, you also need to # download the ax_cxx_compile_stdcxx.m4 file. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik # Copyright (c) 2012 Zack Weinberg # Copyright (c) 2013 Roy Stogner # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 18 AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX]) AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])]) dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- dnl serial 11 (pkg-config-0.29) dnl dnl Copyright © 2004 Scott James Remnant . dnl Copyright © 2012-2015 Dan Nicholson dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a dnl configuration script generated by Autoconf, you may include it under dnl the same distribution terms that you use for the rest of that dnl program. dnl PKG_PREREQ(MIN-VERSION) dnl ----------------------- dnl Since: 0.29 dnl dnl Verify that the version of the pkg-config macros are at least dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's dnl installed version of pkg-config, this checks the developer's version dnl of pkg.m4 when generating configure. dnl dnl To ensure that this macro is defined, also add: dnl m4_ifndef([PKG_PREREQ], dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) dnl dnl See the "Since" comment for each macro you use to see what version dnl of the macros you require. m4_defun([PKG_PREREQ], [m4_define([PKG_MACROS_VERSION], [0.29]) m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) ])dnl PKG_PREREQ dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) dnl ---------------------------------- dnl Since: 0.16 dnl dnl Search for the pkg-config tool and set the PKG_CONFIG variable to dnl first found in the path. Checks that the version of pkg-config found dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is dnl used since that's the first version where most current features of dnl pkg-config existed. AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])dnl PKG_PROG_PKG_CONFIG dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------------------------------- dnl Since: 0.18 dnl dnl Check to see whether a particular set of modules exists. Similar to dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl only at the first occurence in configure.ac, so if the first place dnl it's called might be skipped (such as if it is within an "if", you dnl have to call PKG_CHECK_EXISTS manually AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) dnl --------------------------------------------- dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting dnl pkg_failed based on the result. m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])dnl _PKG_CONFIG dnl _PKG_SHORT_ERRORS_SUPPORTED dnl --------------------------- dnl Internal check to see if pkg-config supports short errors. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])dnl _PKG_SHORT_ERRORS_SUPPORTED dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl -------------------------------------------------------------- dnl Since: 0.4.0 dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES might not happen, you should be sure to include an dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])dnl PKG_CHECK_MODULES dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], dnl [ACTION-IF-NOT-FOUND]) dnl --------------------------------------------------------------------- dnl Since: 0.29 dnl dnl Checks for existence of MODULES and gathers its build flags with dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags dnl and VARIABLE-PREFIX_LIBS from --libs. dnl dnl Note that if there is a possibility the first call to dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to dnl include an explicit call to PKG_PROG_PKG_CONFIG in your dnl configure.ac. AC_DEFUN([PKG_CHECK_MODULES_STATIC], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl _save_PKG_CONFIG=$PKG_CONFIG PKG_CONFIG="$PKG_CONFIG --static" PKG_CHECK_MODULES($@) PKG_CONFIG=$_save_PKG_CONFIG[]dnl ])dnl PKG_CHECK_MODULES_STATIC dnl PKG_INSTALLDIR([DIRECTORY]) dnl ------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable pkgconfigdir as the location where a module dnl should install pkg-config .pc files. By default the directory is dnl $libdir/pkgconfig, but the default can be changed by passing dnl DIRECTORY. The user can override through the --with-pkgconfigdir dnl parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_INSTALLDIR dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) dnl -------------------------------- dnl Since: 0.27 dnl dnl Substitutes the variable noarch_pkgconfigdir as the location where a dnl module should install arch-independent pkg-config .pc files. By dnl default the directory is $datadir/pkgconfig, but the default can be dnl changed by passing DIRECTORY. The user can override through the dnl --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ])dnl PKG_NOARCH_INSTALLDIR dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl ------------------------------------------- dnl Since: 0.28 dnl dnl Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR # Copyright (C) 2002-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.16.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.16.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # Copyright (C) 2011-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_AR([ACT-IF-FAIL]) # ------------------------- # Try to determine the archiver interface, and trigger the ar-lib wrapper # if it is needed. If the detection of archiver interface fails, run # ACT-IF-FAIL (default is to abort configure with a proper error message). AC_DEFUN([AM_PROG_AR], [AC_BEFORE([$0], [LT_INIT])dnl AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([ar-lib])dnl AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false]) : ${AR=ar} AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface], [AC_LANG_PUSH([C]) am_cv_ar_interface=ar AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])], [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([am_ar_try]) if test "$ac_status" -eq 0; then am_cv_ar_interface=ar else am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([am_ar_try]) if test "$ac_status" -eq 0; then am_cv_ar_interface=lib else am_cv_ar_interface=unknown fi fi rm -f conftest.lib libconftest.a ]) AC_LANG_POP([C])]) case $am_cv_ar_interface in ar) ;; lib) # Microsoft lib, so override with the ar-lib wrapper script. # FIXME: It is wrong to rewrite AR. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__AR in this case, # and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something # similar. AR="$am_aux_dir/ar-lib $AR" ;; unknown) m4_default([$1], [AC_MSG_ERROR([could not determine $AR interface])]) ;; esac AC_SUBST([AR])dnl ]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. AS_CASE([$CONFIG_FILES], [*\'*], [eval set x "$CONFIG_FILES"], [*], [set x $CONFIG_FILES]) shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`AS_DIRNAME(["$am_mf"])` am_filepart=`AS_BASENAME(["$am_mf"])` AM_RUN_LOG([cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles]) || am_rc=$? done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments for automatic dependency tracking. Try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi AS_UNSET([am_dirpart]) AS_UNSET([am_filepart]) AS_UNSET([am_mf]) AS_UNSET([am_rc]) rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking is enabled. # This creates each '.Po' and '.Plo' makefile fragment that we'll need in # order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. # Default is to disable them, unless 'enable' is passed literally. # For symmetry, 'disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), [enable], [m4_define([am_maintainer_other], [disable])], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], am_maintainer_other[ make rules and dependencies not useful (and sometimes confusing) to the casual installer])], [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check whether make has an 'include' directive that can support all # the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], [AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) AS_CASE([$?:`cat confinc.out 2>/dev/null`], ['0:this is the am__doit target'], [AS_CASE([$s], [BSD], [am__include='.include' am__quote='"'], [am__include='include' am__quote=''])]) if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* AC_MSG_RESULT([${_am_result}]) AC_SUBST([am__include])]) AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/gettext.m4]) m4_include([m4/iconv.m4]) m4_include([m4/intlmacosx.m4]) m4_include([m4/lib-ld.m4]) m4_include([m4/lib-link.m4]) m4_include([m4/lib-prefix.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) m4_include([m4/nls.m4]) m4_include([m4/po.m4]) m4_include([m4/progtest.m4]) m4_include([acinclude.m4]) sane-backends-1.0.29/ar-lib0000755000000000000000000001330313615534556012301 00000000000000#! /bin/sh # Wrapper for Microsoft lib.exe me=ar-lib scriptversion=2012-03-01.08; # UTC # Copyright (C) 2010-2018 Free Software Foundation, Inc. # Written by Peter Rosin . # # 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; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . # func_error message func_error () { echo "$me: $1" 1>&2 exit 1 } file_conv= # func_file_conv build_file # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv in mingw) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin) file=`cygpath -m "$file" || echo "$file"` ;; wine) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_at_file at_file operation archive # Iterate over all members in AT_FILE performing OPERATION on ARCHIVE # for each of them. # When interpreting the content of the @FILE, do NOT use func_file_conv, # since the user would need to supply preconverted file names to # binutils ar, at least for MinGW. func_at_file () { operation=$2 archive=$3 at_file_contents=`cat "$1"` eval set x "$at_file_contents" shift for member do $AR -NOLOGO $operation:"$member" "$archive" || exit $? done } case $1 in '') func_error "no command. Try '$0 --help' for more information." ;; -h | --h*) cat <, 1996. # 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; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=https://www.perl.org/ flex_URL=https://github.com/westes/flex gnu_software_URL=https://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: sane-backends-1.0.29/PROJECTS0000666000000000000000000000177713615534521012371 00000000000000PROJECTS (2005-10-03) Here is a list of projects that various people have expressed interest in. Before starting working on one of these projects, it may be a good idea to get in touch with the relevant people. Please also read the files AUTHORS and README for projects that are included into the SANE-package. For frontends, look at the sane-frontends package. For backends or stand-alone drivers, add a .desc file or add an entry to unsupported.desc. Status description --------- ---------------------------------------------------------------- wanted Somebody would like to have this feature but can't do it himself. planned Only plans but no code yet. wip Work in progress. There is (more or less) working code. For details, look at the web page or contact the author. SANE on non-Unix platforms: ---------------------------- OS/2 support (wip) http://home.tiscalinet.de/fbakan/sane-os2.htm Misc: ----- TWAIN interface for xsane-win32 (planned) Oliver Rauch sane-backends-1.0.29/NEWS0000666000000000000000000014144513615534521011711 00000000000000 ## New with 1.0.29 (upcoming release) ### Backends - adds an `escl` backend (theoretically supporting *all* AirPrint devices with a scan unit) - adds support for 23 new scanner models via existing backends - significantly changes `genesys` and `pixma` backends - fixes bugs in `canon_dr`, `fujitsu`, `hp3900`, `mustek_usb2`, `plustek` and `xerox_mfp` backends - fixes *all* compiler warnings on Debian 10 (#120) - fixes portability issues for uClibc-ng and MacOS builds - adds support to record and replay USB I/O traffic - adds timestamps to debug logs ### Frontends - fixes a 32-bit arithmetic overflow issue in `scanimage` ### Documentation - updates translations for British English, Catalan, German, Ukrainian, Valencian - adds `scangearmp2` external backend descriptions - updates `hpaio` and `utsushi` external backend descriptions - adds the `ChangeLogs/` directory to the source tarball (#103) ### Build - additionally requires `libcurl` and `libxml2` to build the `escl` backend - requires `libxml2` for USB I/O recording and replay functionality - re-enables pthread support for backends that use its API directly, irrespective of the `pthread_t` type (#153) - moves the `genesys` and `pixma` backends to a directory of their own ## New with 1.0.28 (released 2019-07-31) ### Backends - adds a `ricoh2` backend - adds support for 40+ new scanner models - significantly changes `canon_dr`, `fujitsu`, `genesys`, `gt68xx`, `hp5590` and, `pixma` backends - fixes bugs in `as6e`, `avision`, `mustek` and `plustek` backends - fixes scores of compiler warnings ### Frontends - adds, changes and removes options for `saned` (see `man 8 saned` for details) - adds: `-l` (listen), `-D` (daemonize), `-o` (once), `-e` (stderr), `-u` (user) - removes: `-s` (syslog). Use `-a -d level -o -f` for the old behavior - changes: `-d` (debug). Use `-a -d level -o -f -e` for the old behavior - `saned` now cancels scans if the data connections appears to have gone away (after 4 seconds by default, configurable in `saned.conf`) - adds `--output-file` option to `scanimage` - adds `--help` option to `scan-find-scanner` - changes `sane-desc` to create relative hyperlinks ### Documentation - adds translations for Catalan, Hebrew and Valencian - updates translations for British English, Dutch, German and Ukrainian - marks unmaintained backends as such - documents USB workaround in `sane-usb` manual page ### Build - requires a C++11 compatible compiler for the `genesys` backend - requires a JPEG library when building the `pixma` backend - fixes unneeded linking when not using preloadable backend support - disables pthread support for systems with non-integral `pthread_t` type - fixes USB support detection on BeOS and OS/2 at `./configure` time - normalizes trailing whitespace in source code files. If you have local patches that no longer apply, have a look at the whitespace ignoring options of `patch` and `git apply`. New with 1.0.27 (see Note 1), released 2017-05-22: * Significant enhancements to canon_dr, epjitsu, epsonds, fujitsu, genesys, hp3500, pixma and xerox-mfp backends. * Minor updates, bugfixes or scanners added in several backends. * 30+ new scanner models supported. * Made libusb-1.0 the default for USB support (see Note 2). * Switched code from C90 to C99 (Thanks to Volker Diels-Grabsch). * Updated Linux USB3 workaround (see Note 3). * Documentation and translation updates. * Bugfixes (Avahi, threading, USB, ICC/PNG/JPEG, etc). * Reduced compiler warnings, improved code (see Note 4). Note 1: There is no 1.0.26 release of sane-backends. That number was skipped so that our development version numbers would more clearly be an extension of the prior release. This should make packaging a little easier for our downstream users. Note 2: On all systems, the --enable-libusb* flags are now ignored. Instead, the --with-usb and --without-usb flags now control support. When neither is given, USB support will be enabled if possible and disabled otherwise. If --with-usb is requested but not possible, ./configure will fail. There is no support to prefer libusb-0.1 over libusb-1.0. When libusb-1.0 is not found, libusb-0.1 will be tried. Note 3: The Linux USB3 workaround which was added in version 1.0.25 is now disabled by default. If you have difficulty using a scanner which previously worked, or intermittent scanner availability, try setting the new environment variable SANE_USB_WORKAROUND=1 before starting your frontend. Note 4: A special thanks goes to Olaf Meeuwissen for picking up the janitorial duties in sane-backends. He has found and fixed a large number of long-standing bugs, curated our bug tracker, improved our build scripts and docs, and provided user support. Thank you Olaf! New with 1.0.25, released 2015-10-03: * New backends: epsonds (Epson DS, PX and WF series), pieusb (PIE and Reflecta film/slide scanners). * Support for JPG and PNG output format in scanimage. * Significant enhancements to avision, canon_dr, epjitsu, fujitsu, genesys, kodakaio and pixma backends. * Minor updates, bugfixes or scanners added in several backends. * 300 new scanner models supported. * Workaround for USB3 problems in Linux kernel. * Added code for IR functionality. * Documentation and translation updates. * Bugfixes (threading, networking, udev rules). New with 1.0.24, released 2013-09-30: * Significant enhancements to pixma, genesys, kodakaio, fujitsu, canon_dr. * Minor updates, bugfixes or scanners added in several backends. * Added new testsuite * 51 new scanner models supported. * USB support improvements. * Improved build system (mingw64, bug fixes, default pthread on Linux). * Documentation updates. * Bugfixes. New with 1.0.23, released 2012-08-19: * New backends: kvs40xx (Panasonic KV-S40xx), kodakaio (Kodak AiO ESP and Hero) * Significant enhancements to several backends. * 30 new scanner models supported. * V4L support improvements. * Improvements for builds on multiple platforms. * Improved udev rules. * Updated software deskew algorithm. * Documentation updates. * Bugfixes. New with 1.0.22, released 2011-02-13: * New backends: kvs20xx (Panasonic KV-S20xx), magicolor (Konica-Minolta ) * Significant enhancements to several backends. * More than 80 new scanner models supported. * Support many more networked scanners. * Added -A option to scanimage * Improved build system. * Improved USB support. * Improved udev rules. * Documentation updates. * Bugfixes. New with 1.0.21, released 2010-04-25: * New backends: kodak (Kodak i18xx), kvs1025 (Panasonic KV-S10xx), p5 (Primax PagePartner) * 224 more scanner models supported. * Many backends updated. * Improved compilation on uncommon platforms. * More consistent option naming. * Scanimage no longer writes image to tty. * Modern translation infrastructure. * Improved saned network daemon. * Internal SCSI, USB, threading, TCP & UDP code updates. * Updated HAL and udev support. * New sanei_magic image processing library. * Documentation updates. * Bugfixes. New with 1.0.20, released 2009-05-03: * New backends: canon_dr (Canon DR-series), coolscan3 (Nikon LS & Coolscan), rts8891 (Umax & HP 44xx), xerox_mfp (Samsung/Xerox/Dell MFPs) * Many backends updated. * 75 more scanner models supported. * New build system (thanks Chris and Olaf). * Avahi support (thanks Julien). * More network scanners supported * Epson backend deprecated, use epson2 * Coolscan2 backend deprecated, use coolscan3 * Internal SCSI, USB, threading, TCP & UDP code updates. * Updated HAL and udev support. * Improved saned configuration. * Scanimage updates. * Updated translations. * Documentation updates. * Bugfixes. New with 1.0.19, released 2008-02-10: * New backends: cardscan (Corex Cardscan 800c), epjitsu (Epson-based Fujitsu), epson2 (various Epson scanners), hp3900 (HP ScanJet 3970 and more), hp5590 (HP ScanJet 5590 and more), hpljm1005 (HP LaserJet M1005 and more), hs2p (Ricoh IS400 series) * Updated backends: abaton, agfafocus, apple, artec, artec_eplus48u, as6e, avision, canon, coolscan, coolscan2, dc25, dell1600n_net, dll, epson, fujitsu, genesys, gt68xx, hp3500, ibm, lexmark, microtek, microtek2, mustek, nec, net, pie, pint, pixma, plustek, plustek_pp, ricoh, s9036, sm3600, sm3840, snapscan, sp15c, st400, tamarack, teco2, test, u12, umax, umax1220u, umax_pp * Scanimage detects more chipsets. * Internal scsi, usb, tcp and udp code updates. * Basic HAL .fdi creation support * Build system updates. * Updated translations. * Documentation updates. * Bugfixes. New with 1.0.18, released 2006-07-02: * New backends: dell1600n_net (Dell 1600n), hp3500 (HP ScanJet 3500 series), pixma (Canon Pixma series), stv680 (Aiptek Pencam and similar). * Updated backends: avision, canon, dll, epson, fujitsu, genesys, gt68xx, microtek2, mustek_pp, niash, plustek, snapscan, sp15c, test, u12, umax1220u. * Scanimage batch mode fixes. * Scanner lists contain USB vendor/product ids and some statistics now. * Udev/hotplug lists are generated autmatically from the .desc files now. * Portability fixes (especially for DragonFlyBSD and HP/UX). * Build system updates. * Updated translations. * Documentation updates. * Bugfixes. New with 1.0.17, released 2005-12-18: * New backends: hp4200 (HP ScanJet 4200), lexmark (Lexmark X1100 series), mustek_usb2 (Mustek BearPaw 2448 TA Pro) * Updated backends: artec_eplus48u, avision, canon, epson, fujitsu, genesys, gt68xx, microtek2, mustek_pp, plustek, plustek_pp, sm3600, snapscan, umax_pp. * Hotplug/udev updates. * scanimage fixes. * sane-find-scanner finds more chipsets. * Build system fixes/updates. make now calls makedepend. * Several fixes in SANE internal functions (sanei). * Portability fixes (especially for MacOSX, FreeBSD, OpenBSD, OS/2). * Updated translations. * Documentation updates. * Bugfixes. New with 1.0.16, released 2005-08-07: * New backends: genesys, sm3840 * Updated backends: avision, canon, coolscan, epson, gphoto2, gt68xx, mustek, mustek_pp, niash, plustek, plustek_pp, qcam, sm3600, snapscan, teco2, umax_pp, v4l. * More functionality/fixes for sanei_usb and sanei_pp. * Added sanei_access to allow locking of SANE devices. * Hotplug updates. * scanimage updates. * Portability fixes (especially for OS/2, 64bit platforms, BeOS+ZETA). * Added Polish translation. Updated other translations. Fixed format strings. * Documentation updates. * Bugfixes. New with 1.0.15, released 2004-11-07: * New backends: niash. * Updated backends: agfafocus, artec_eplus48u.c, avision, canon, canon_pp, coolscan, dll, epson, fujitsu, gt68xx, hp, hp5400, leo, microtek2, mustek, mustek_pp, net, pie, plustek, plustek_pp, snapscan, sp15c, tamarack, teco2, umax, umax_pp, u12, v4l. * Portability fixes (especially for MacOS X, NetBSD, OS/2, 64 bit platforms). * sane-find-scanner detects more chipsets now. * Added Finnish translation. Updated other translations. * Several saned fixes. * Build system updates. * Documentation updates. * Bugfixes. New with 1.0.14, released 2004-05-01: * New backends: u12 * Updated backends: artec, artec_eplus48u, as6e, avision, canon630u, canon_pp, epson, fujitsu, gphoto2, gt68xx, hp, matsushita, mustek, mustek_pp, mustek_usb, plustek, plustek_pp, sm3600, snapscan, teco1, teco2, u12, umax, umax_pp, v4l. * Added scripts for USB hotplugging (Linux) * Added Danish translation. Updated other translations. * sane-find-scanner knows about more chipsets now. * Portability fixes (especially for MacOS X, NetBSD, OpenBSD, and OS/2). * Build system fixes. * Documentation updates. * Bugfixes. New with 1.0.13, released 2003-11-22: * New backends: mustek_pp_ccd (for Mustek parport CCD scanners), plustek_pp (for Plustek parport scanners, splitted from the plustek backend). * Updated backends: avision, canon630u, coolscan, epson, fujitsu, gphoto2, gt68xx, hp, hp5400, mustek, mustek_pp, pie, plustek, snapscan, teco2, test, umax, umax_pp. * New internal interface for parport scanners. * Networking (IPv6 + subnet support) fixes + updates. * sane-find-scanner can detect some USB scanner chipsets now. * Better support for threading. * Port to MS Windows (Cygwin). * Portability fixes (especially for FreeBSD, MacOS X, OS/2). * Build system improvements. * Added new (Bulgarian, Czech and Italian) and updated existing translations. * The level of support for scanners is now: unsupported, minimal, basic, good, complete or untested (instead of alpha, beta, stable). * Documentation updates. * Bugfixes. New with 1.0.12, released 2003-05-25: * New backends: hp5400 (Hewlett Packard 54XX series), ibm (IBM 2456, Ricoh IS-410, IS-420, and IS-430), and ma1509 (Mustek BearPaw 1200F). * Updated backends: apple, artec_eplus48u, as6e, avision, canon (FB1200S), canon630u, dc210, dc240, dll, epson, fujitsu (fi4220), gphoto2, gt68xx, hp, mustek, mustek_pp, mustek_usb, net, pie, plustek, snapscan (Agfa Arcus 1200, Epson Perfection 660), teco2 (Relisys AVEC II S3, Relisys APOLLO Express 3 and Primax Jewel 4800), test, umax, umax_pp. * Added IPv6 support for saned and net backend. * Added SCSI support for MacOS X. * Build system improvements. * USB access improvements. * Portability fixes (especially for Irix, MacOS X, OS/2 and Linux/m68k). * Added new (nl, no) and updated existing translations. * Documentation updates. * Bugfixes. New with 1.0.11, released 2003-02-09: * Security fixes for saned. New with 1.0.10, released 2003-02-01: * New backends: artec_eplus48u (Artec E+ 48U, Tevion/Medion MD 9693, Medion MD 9705, Trust Easy Webscan 19200), gt68xx (Artec Ultima 2000, some Mustek BearPaws and other GT6801/GT6816 based scanners). * Updated backends: avision, canon, coolscan2, canon_pp, dc210, dc240, dc25, dll, epson, gphoto2, hp, hpsj5s, microtek2, mustek, mustek_pp, plustek, sharp, snapscan, test, umax, umax_pp. * Improved SCSI and USB handling. * Portability fixes (especially for Linux/sparc64, MacOS X, OS/2, Tru64). * New translation system. All backends have translations for the standard options now. Added translations for Portuguese, Russian and Swedish. * Build system updates. * Various documentation updates. * Bugfixes. New with 1.0.9, released 2002-10-24: * New backends: hpsj5s (Hewlett-Packard ScanJet 5S parport scanner), teco2 (some Relisys/Primax SCSI flatbed scanners, models VM3575, VM6565, VM6586 and VM6575), teco3 (some Relisys/Piotech/Trust/Plustek SCSI flatbed scanners, model VM3552). * Updated backends: avision, canon_pp, coolscan2, dc240, dc25, epson, fujitsu, hp, leo, microtek, mustek, mustek_usb, pie, plustek, snapscan, teco1, test, umax, umax_pp, v4l. * sane-find-scanner finds more scanners and has more verbosity options now. * New tool to create gamma tables (gamma4scanimage). * Support for ICC profiles for scanimage. * USB scanner should work on all systems supported by libusb now. * Portability fixes (especially for big-endian sytems, Irix, OpenStep, OS/2, Solaris). * New and updated translations for various backends. * New system for generating lists of manufacturers/backends. * Various documentation updates. * Bugfixes. New with 1.0.8, released 2002-05-27: * New backends: canon_pp (Canon parport scanners), canon630u (CanoScan 630u + 636u), coolscan2 (Nikon Coolscan LS-30, LS-40 ED, LS-4000 ED, and LS-8000 ED), fujitsu (M3091, M3093, M3096 and similar scanners), leo (Leo/Across FS-1130 scanner), matsushita (Panasonic KV-SS scanners), sceptre (Sceptre VividScan S1200), teco1 (some Teco/Relisys flatbed scanners), test (test frontends and SANE installation). * Updated backends: avision, canon, dc240, dll, epson, gphoto2, mustek, mustek_pp, mustek_usb, nec, net, plustek, pnm, sharp, sm3600, snapscan, umax, umax_pp, v4l. * New translations for several backends (de, es, fr). * Networking supports hosts without working DNS now. * SCSI system ignores USB files and doesn't block (Linux). * New test frontend and backend for testing SANE. * Several build system improvements (e.g., new libtool, better make distclean, build only shared libs by default). * Portability fixes (especially for AIX, Linux (2.2, hppa, sparc), HP-UX, NetBSD, OPENSTEP, OS/2). * Better documentation of internal functions (sanei). * Various Documentation updates. * Bugfixes. New with 1.0.7, released 2002-02-04: * New backend: umax1220u (for UMAX Astra 1220U and 2000U scanners). * Updated backends: avision (v 1.0.15), dc240 (v 0.0), dc25 (v 1.2), dll (v 1.0.5), epson (v 1.0.219), gphoto2 (v 0.0), microtek2 (v 0.95), mustek (1.0.118), mustek_usb (v 1.0.10), plustek (v 0.41), pnm (v 1.0.4), sharp (v 0.32), snapscan (v 1.4.7), st400 (v 1.6), umax (v 1.0-32), umax_pp (v 1.0.6). * Added support for translating backend options. * Added support for USB control messages and lm983x and pv6830 chipsets. * Better documentation of internal functions (sanei). * Fixed several security issues with temporary files. * Fixed several issues in the networking code. * Portability fixes (especially for OS/2, FreeBSD, and OpenBSD). * Scanimage fixes concerning TIFF output and signal handling. * Documentation updates. * Bugfixes. New with 1.0.6, released 2001-11-05: * New backends: gphoto2 (backend for gphoto2 supported cameras), mustek_usb (for Mustek USB scanners 600CU, 1200CU(+), 1200UB). * Updated backends: dc240 (v 0.0), epson (v 0.2.12), hp (0.95), m3096g (v 1.11), microtek2 (v 0.95), mustek (v1.0-113), net (v 1.0.5), pie (1.0-7), pnm (1.0-2), snapscan (v 1.4.0), umax (1.0-31), umax_pp (1). * Added generic support for USB devices. * Added USB support to sane-find-scanner. * Code and documentation updates for HP UX compatibility. * Documentation updates. * Bugfixes. New with 1.0.5, released 2001-07-01: * New backends: bh (Bell+Howell Copiscan II series), dc240 (Kodak DC240 Digital Camera), sm3600 (Microtek ScanMaker 3600), umax_pp (Umax paralell port scanners). * Updated backends: artec (v0.5.16), dc25 (v1.2), dll (v1.0.3), epson (v0.2.08), hp (v0.94), microtek (v0.12.3), microtek2(v0.9), mustek (v1.0-107), nec (v0.12), net (v1.0.3), plustek (v0.39), pnm (v1.0.1), snapscan (v1.2), tamarack (v0.5), umax (v1.0-28). * Fixed security bug in saned.c that allowed access to scanner without password. * pnm isn't installed by default anymore due to security risks * Linux-part of sanei_scsi.c was updated concerning buffersizes, devfs, and kernel 2.4. More debug output. * sanei_scsi_find_devices works on FreeBSD now. * Added support for Solaris sgen SCSI driver. * find-scanner was renamed to sane-find-scanner and is installed now. Further more it has a man page now. * There is a testsuite for sane, but only one test is implemented yet. * Better output about versions of backends and frontends. * There is a man page for SANE now (sane(7)). * Install all available documentation. * Bugfixes. New with 1.0.4, released 2000-12-21: * New backends: as6e, nec, pie. * Updated backends: artec (v0.5.15), avision (v0.2.1), epson (v0.1.39), hp (v0.93), mustek (v1.0-102), mustek_pp (v0.9-devel), plustek (v0.38), sharp (v0.32), umax (v1.0-21). * Moved frontends xscanimage and xcam to a new package (sane-frontends). * Added authentification with encrypted passwords. * Installation of shared libraries on AIX is supported now. * Fixed compilation bugs on Irix and FreeBSD. * Better debug output on platforms not supporting vararg macros. * Better documentation about SANE devicenames. * Bugfixes. New with 1.0.3, released 2000-08-12: * New backends: mustek_pp, plustek, st400, v4l. * Updated backends: Artec (v0.5.14), Coolscan (v0.4.3), Epson (v0.1.33), HP (v0.88), Mustek (v1.0-96), Sharp (v0.31), UMAX (v1.0-21). * Removed backend info sagitta.desc due to lack of interest. * Installing no longer depends on 'rev'. * Added and structured documentation. * Every backend has a man page now. * Debug messages are now sent to syslog if stderr is a socket. * New 16 bit support to scanimage. * Bugfixes. New with 1.0.2, released 2000-03-06: * Aliased and hidden backend support. * Port to UnixWare 2.x and UnixWare 7. * New script 'sane-config' to help frontend developers. * Added Ricoh IS50 support. * Updated backends: Artec (v0.5.13), CANON (v991108), DC-25 (1.2), HP (v0.86), Microtek (0.12.0), Microtek2 (v0.8), UMAX (v1.0-build-18), Epson (v0.1.15), Sharp (v0.30), sp15c (1.12) and m3096g (1.11). * Automatic document feeder support for scanimage. * New backend for Avision AV 630 CS. * New Linux SCSI Generic driver. * Upgraded to libtool 1.3.4 * GIMP compatibility patch. * OS/2 patches. * Bugfixes. New with 1.01: * Miscellaneous o configure --disable-shared works again o scanimage -T testing option added (by Nick Lamb) o in dll.conf, the pnm, dc25, and dc210 backends are now disabled (commented out) by default. The net backend is now enabled by default. The pnm backend has been disabled as it often proved confusing to novice users. The dc25 and dc210 backends were disabled because they initialize very slowly if no camera is attached. o Downgraded PNM backend to the version shipped with SANE 0.74. The scan area options as implemented in SANE 1.00 were incorrectly implemented which made the backend unreliable. * New tool to turn off Mustek 600 II N scanner (by Andreas Czechanowski) o the new binary tools/mustk600iin-off allows to turn off a Mustek 600 II N scanner (note: you'll need to install this tool manually if you want it) * New backend for Sharp scanners (by FUKUDA Kazuya & Abel Deuring) o supports the Sharp JX-610, JX-250, and JX-330 SCSI scanner o preview/lineart/haftone/threshold are untested * Updated Kodak DC25 backend (by Peter Fales). * Updated HP backend (by Peter Kirchgessner) o New features: - Option 'unload after scan' for PhotoScanner - Manual page sane-hp updated - hp.desc updated o Bugfixes: - Adjustable scan size for scan from ADF - No blanks in command line options - Segmentation fault for starting scanimage -d hp:/dev/sg0 without /dev/sgo in hp.conf Scanning from the ADF therefore should work now. * Updated Microtek backend (by Matto Marjanovic) o Fixed off-by-1 error in revision-number parsing. o dump_inquiry() now prints the "Vendor Specific String". o Added model code/vendor name for the other 600ZS. o Made get_scan_status() retry delay increase with each try (will this help the poor 600ZS?). o Corrected base resolution for Agfa StudioScan II/IIsi (400dpi). o Disabled backend's clever aspect-ratio correction code for expanded-mode scans with StudioScan II/IIsi (scanner handles it internally - smart scanner.) o Fixed gamma LUT code parsing stupidity: now correctly determines maximum allowed LUT size, and uses it. (Especially necessary for StudioScan II/IIsi.) o The E6 claims to only support 256-byte LUT's, but the backend now ignores that misinformation (and uses 1024). o Now ignores denial of expanded-mode by older E6's (model code 0x63), in addition to newer E6's. * Updated Microtek2 backend (by Bernd Schroeder) o Added support for non-blocking I/O. o Preliminary support for a strip and a slide mode. o For people, who are annoyed, if the the scanhead moves back and fourth during a scan (backtracking): There is a new option 'disable backtracking'. At present this option must be activated by uncommenting the respective entry in the included microtek2.conf file. This is an advanced option. o The X6EL should no longer produce pixel junk after one successful scan. * Updated Mustek backend (by Andreas Bolsch) o larger buffer acquired (speeds up scanning slightly) o for SE models minimal resolution increased from 60 dpi to 75 dpi o for SE models 75 dpi in color mode is no longer used as the newer firware version seems to be even more buggy o bug in calculation of gamma table corrected (applies only to SE models, NOT related to the overflow problem which was corrected via CLIP( ) ) o default resolution is now set according to the minimal resolution (firmware dependent) o for SE models all unsupported options (speed, ... ) explicitly disabled * Updated Nikon Coolscan backend (by Didier Carlier) o Reverse the pixel order for the LS-1000. * Updated snapscan backend to v0.6 (by Kevin Charter and Petter Reinholdtsen) o Fixes the versioning problem. o Add support for SnapScan 1236s (should also work for SnapScan 600). * Updated UMAX backend (by Oliver Rauch) o Added support for Linotype Hell Saphir 2 o Changed bug in gray gamma data conversion o Added support for Nikon AX-210 o Added "Vista S-6E" as supported o Added PowerLook-II (PL-II) as supported o Added Astra 600S as supported New with 1.00: * Upgraded to libtool-1.2. This reportedly gets SANE to build on Solaris versions with a broken printf. * saned Matching of hostnames is no longer case-sensitive. * New Abaton backend (by David Huggins-Daines) Supports "Scan 300/GS" and may work with "Scan 300/S" but the latter is untested. * New Agfa Focus backend (by Karl Anders Øygard) Supports: o AGFA Focus GS (6 bit gray scale) (untested) o AGFA Focus Lineart (lineart) (untested) o AGFA Focus II (8 bit gray scale) (untested) o Siemens S9036 (8 bit gray scale) (untested) o AGFA Focus Color (24 bit color 3-pass) o AGFA Focus Color Plus (24 bit color 3-pass) * New Kodak DC210 still camera backend (by Brian J. Murrell) * New Ricoh backend (by Feico Dillema). * New HP backend. The backend formerly known as "xhp" is now the default HP backend. This backend should support HP scanners much better and was contributed by Geoffrey Dairiki and Peter Kirchgessner. - Added support for HP 6200C - Suppress halftone mode on photosmart (it is not supported) - Show calibrate button on photoscanner only for print media - Add media selection for photoscanner - Cleanup hp_scsi_s structure * Updated apple backend (by Milon Firikis). Now you should be able to scan from ColorOneScanners (in non color modes) and maybe from OneScanners (untested). * Updated Artec backend (by Chris Pinkham). * Updated Kodak DC25 backend (by Peter Fales). * Updated Microtek backend (by Matto Marjanovic). - Fix segfault on exit due to unnecessary free() in sane_close(). - Fix to red channel shift bug (which crept in during rewrite of color-handling code). - Addition of "patch level" to version codes. * Updated Microtek2 backend - Added support for ScanMaker 330, ScanMaker 636, ScanMaker E3plus, ScanMaker X6 and Phantom 636. - Other improvements (this includes support for automatic document feeders and transparency adapters, missing option descriptions were added). - Updated the manual page. * Updated Mustek backend (patches by Andreas Bolsch and Heiko Schroeder) - Heiko's patch should make resolutions >300dpi work for MFS-6000CX. Andreas's patches: - Should work with ScanExpress 6000SP, 12000SP as well as older models - Bug with MFS-12000SP corrected (poined out by Daniel Deckers) - Bug which caused xscanimage to crash after color preview corrected - Improvement(?) in high resolution Important Notes for ScanExpress models: - Resolutions below 60 dpi don't work (firmware problem). - Resolutions >300 dpi (6000 SP) or >600 dpi (12000 SP) result in different x/y-resolution as 6000 SP and 12000 SP have in fact only 300 dpi and 600 dpi CCD sensors, respectively. - Resolutions >300dpi in color mode sometimes result in corrupted images (parts duplicated/shifted *HORIZONTALLY*) depending on hardware configuration. Killing all other applications and disabling swap (if sufficient physical memory available) may help. I added some code which writes to every page of the buffer prior to scanning to fool the memory management and scanned a full page color scan with 600dpi * 1200dpi. Very slow but image seemed ok after pnmscale. - Max. scan area: 0-216mm (hor.), 2.5-294.5mm (ver.) The scanners can't scan the first 2.5mm (ver.), so you *MUST* specify the scan area according to this restriction! - The scanners support only lineart (1 bpp), gray (8 bpp), color (24 bpp). Although the scanners have 10 bit (6000 SP) or 12 bit (12000 SP) A/D-converters, they can send only 8 bit values to the host. The higher resolution may only be used via gamma table. - For compatibility only 256 entry gamma tables may be specified, the actual gamma table sent to the scanner is linearly interpolated from it. - In lineart mode only brightness may be adjusted. - Cover open/closed reported only via debug output and ignored otherwise. - Use of SCSI card supplied with scanner is *NOT* recommended. (Don't forget termination!) * Updated UMAX backend (by Oliver Rauch) - added output of umax-backend-version in sane_init - added Linotype Hell Jade2 (Vobis ScanBoostar Premium) SCSI-ID "LinoHell","Office2" as supported scanner - changed base of calculation of scanwidth and scanlegth from pixel to resolutionbase (1/300, 1/600 or 1/1200 inch) - changed calculation for width in pixels for lineart mode - changed selection for calibration mode - added inquiry for UMUX UC1200SE - corrected 12/36-bit-mode in send_gamma_data and array in umax.h * Updated SnapScan backend to v0.5 (by Kevin Charter) - bug fixes (Wolfgang, David) - addition of threshold control for lineart mode (Mikko) - Vuego 310S support (Wolfgang) - default scan area now maximal (Kevin) New with 0.74: * GIMP auto-detection should work again. * Service name for remote scanning changed from "saned" to "sane". Be sure to update your /etc/services and /etc/inetd.conf if you use remote scanning! We generally try to avoid such incompatible changes, but the name "saned" was definitely wrong, so it seemed better to change it now. * Thanks to Matto Marjanovic work, each backend now comes with a .desc file that describes exactly what devices it supports. These description files can be automatically translated into various other formats, such as HTML. See: http://www.mostang.com/sane/sane-backends.html for an example as to what this can do for you. * New backend for Kodak DC25 digital cameras (by Peter Fales). * Updated Artec backend (by Chris Pinkham). * Updated Microtek backend (by Matthew Marjanovic) o Complete rewrite of bit-shuffling, buffering, and color-handling code. o Improved rescaling algorithm for expanded resolution scans. o Support for 600GS (and maybe ZS, too) (thanks to Oliver Neukum). o Support for document autofeeder and IIG (thanks to Ross Crawford). o Fixed sane_cancel. o sane_get_parameters size estimates are now accurate to the last bit. o get_scan_status timeout increased (for 600GS), status code fixed. o Fixed parsing of 3-pass bit in INQUIRY data. o Stopped sending gamma tables to scanners that don't want them. o Made precalibration a bit more robust (always attempt at least one scan line now). o Much, much code clean-up. o Tested & working with saned. (Atrocious hack so sane_read handles buffers smaller than one scanline.) o Auto-expand pre/post hold buffers as necessary (fixes some problems with single-pass color scans). o Added configuration file option to disable precalibration logic. o Fixed document size calculations. o Added more informative scsi-II note. o Remove misnomer "Highscan" from manpage. o Updated man-page. * Updated Microtek2 backend (by Bernd Schroeder) o changed the code for gamma calculation and added a custom gamma table to the options. In some cases this requires an additional memcpy(), but the code is now leaner and cleaner. o fixed the bugs that the backend didn't compile with non gcc compilers. o added an option to control exposure times. o rewrote the code that processes the data that is received from the scanner and transfers it into the frontend buffer. The smallest unit of data that can be copied into the frontend buffer is now a pixel, no longer a complete line. o added (a yet) undocumented option "strip-height" that allows to control the number of lines that is read from the scanner with one "read image". o fixed a bug that caused scanimage to sigsegv when calling sane_exit() without having written all data into the output file. o added code to support scanners with more than 8 bit output per color. Due to the lack of such a scanner this functionality is COMPLETELY UNTESTED and there are some potential sources of bugs, but at least one could give it try. o added sanei_config_attach_matching_devices() o improved the code for the check if it really is Microtek SCSI-II scanner o fixed the "lineart inverted" bug o The threshold option in lineart mode is now in the enhancement group o changed the default for the resolution o The values for the SANE_Params struct are calculated more precisely o dito the number of scan lines that fit into the frontend buffer o changed some return stati ( replaced SANE_STATUS_INVAL with SANE_STATUS_IO_ERROR where the first one is not allowed) o completely rewrote the end of scan and cancel scan handling o fixed another bug that caused xscanimage to crash with sigsegv under some circumstances (check of the inquiry result was wrong) o added model code for a Vobis Highscan o support for new format of configuration file (including "option ") * Updated Nikon Coolscan backend (by Didier Carlier). * Updated UMAX backend (by Oliver Rauch): o Cancelling a scan now works, cancelling a preview still makes problems! o Preview fix is activated for Astra 600S, Astra 610S and Vista S6E scanners. (calibration by driver still does not work for these scanners). - removed button for preview patch o Quality calibration / calibration by driver now works for same scanners. - added selection for type of shading data calculation o Solved problem with black area at top of the image (happend only with some SCSI-adapters). o Added gamma download format type 0 and type 1 for older scanners. o Added Astra 1220S as supported scanner: - added 36 gamma input bits support for Astra 1220S - added 36 output bits support, but there is no frontend that can handle it! o Added inquiry for Escom Image Scanner 256 (UMAX UG80). * OS/2 (by Yuri Dario): o Updated SCSI support so sanei_scsi_find_devices is supported now. o Epson parallel support added (by Rocco Caputo ) New with 0.73: * In xscanimage, the selection box now gets updated again when changing the geometry option sliders---really! * On Linux, it is now possible to specify SCSI device names by entering their SCSI ids. For example, instead of "/dev/scanner", one can now specify "scsi MUSTEK" to get all scanners manufactured by Mustek. This feature is currently supported by the all SCSI backends except microtek2. This feature is courtesy of Oliver Rauch. * Backend libraries are now installed in $(libdir)/sane (/usr/local/lib/sane/, by default). * Updated Microtek backend (Matto Marjanovic): - ScanMaker 600ZS, Agfa Arcus II, StudioScan, and StudioScan II now supported (or recognized, at least ;-). - Fixed 3-pass scanning. - Various bug-fixes (see ChangeLog for details). * New Microtek2 backend (Bernd Schroeder) This backend supports the ScanMaker 630 and possibly other newer scanners that are not supported by the "old" Microtek backend. Additional info by Bernd: This is the very first release of this backend, so consider this software to be in alpha state. The backend was developed on a Pentium (60 Mhz) with Linux 2.0.29 and a ScanMaker 630 attached to the Adaptec AHA1505E that shipped with the scanner. As frontend xscanimage was used. It is intended to work with other models, too, but there are no experiences yet. The following options are supported: - 8-bit color, 8-bit grayscale, halftone and lineart scans. - brightness, contrast, shadow, midtone and highlight control - scalar gamma correction. Options that are not yet supported include: - 3-pass scanners - more than 8 bit per color output data. Provisions are made here and there in the code, to support more than 8 bit, but that's uncomplete. * configure --disable-static should now work as expected. New with 0.72: * New backend for Artec scanners. This backend is known to work with Artec AT3, but others may work too (A6000C should work). * Updated DMC and Microtek backend. * Updated UMAX backend: ** added exposure time adjustment (for high-end scanners) ** added lamp density control (for high-end scanners) ** UMAX Astra 6X0S works in color-mode now, you have to enable preview_patch! ** added support for UMAX UC1200S and UC1260, but it will not work fine! ** enabled x-resolution greater than 600 dpi if supported by scanner (e.g. UMAX S12) but it sometimes still does not work right! * Updated SnapScan backend: There is now support for the SnapScan 310 and 600 scanner models. * OS/2 and FreeBSD support should be working again. * New backend writer's guide to SANE File backend/GUIDE outlines a few rules that should help in writing a new backend. New with 0.71: * Polaroid Digital Microscope Camera (DMC) backend Written by David Skoll . * Apple scanner backend Written by Milon Firikis . This backend supports AppleScanner and has preliminary support for OneScanner and ColorOneScanner. * Nikon CoolScan backend Written by Didier Carlier . * Apollo Domain/OS support Contributed by Paul Walker . New with 0.70: * Preliminary version of AGFA SnapScan backend is now included. This backend is know to work with AGFA SnapScan scanners but is unlikely to work with any other AGFA See scanner.http://www.cs.ualberta.ca/~charter/snapscan.html for details. * Various minor bug fixes that prevented SANE from building on non-Linux platforms. * xscanimage now honors WM_DELETE message. * Updated UMAX backend. New between 0.6 and 0.69: * Mustek backend now supports the Transparency Adapter on the Paragon 1200SP (MFS-12000SP). * New backend for Canon scanners. This backend was written by Helmut Koeberle . It is known to work with the CanonScan 600 though not all features are supported yet. * Solaris SCSI support now exists. Thanks to Martin Huber , the SCSI backends are now usable under Solaris, too. See README.solaris for details. * AIX SCSI support now exists. Thanks to Fred Hucht & Michael Staats, the SCSI backends are now usable under AIX, too. * New backend for Tamarack and ESCOM scanners. This backend was written by Roger Wolff of BitWizard. * New backend for Siemens S9036 scanner. This backend was written by Ingo Schneider . * find-scanner (by Oliver Rauch) SANE now comes with a program called find-scanner (in the tools subdirectory) that can be used to find the device name of attaches SCSI scanners. Note that this program is not normally installed as part of the normal SANE installation as this program is not something an end-user should ever have to use. * The Mustek backend has preliminary support for the Paragon 600 II N scanner. This scanner attaches directly to a Mustek-supplied ISA card which implements a funky parallel port. For details, see the section entitled PARALLEL PORT SCANNERS in sane-mustek(5). Use at your own risk! * The location of the configuration files can now be overridden with environment variable SANE_CONFIG_DIR (see also man-pages for the backends and programs). * When preloading backends into dll, they now appear in the same order as if they had been loaded dynamically (i.e., in reverse order in which they're listed in dll.conf). * Java frontend (by Jeff Freedman) SANE now includes a Java frontend for SANE. However, the Java files are not built by default. See japi/README.JAVA for details. * There is a Java API for SANE now. See japi/README.JAVA for details. This code is courtesy of Jeff Freedman . * UMAX updates (by Oliver Rauch): - the umax backend is now fully runtime configuable---there are no longer any build-time configuration options. - Umax T630, Astra 610S, and Linotype Hell Office scanners are now supported - gamma-data now works on Astra 1200 S with 30 bits/pixel Note: None of the SANE frontends presently support 30 bits/pixel. If you're interested in fixing this, send mail to sane-devel@mostang.com. * The Mustek backend is now fully runtime configurable---there are no longer any build-time configuration options. To this end, the mustek.conf configuration file now supports options linedistance-fix, lineart-fix, and strip-height (see sane-mustek(5) for details). * New backend for Epson scanners An alpha-quality backend for Epson scanners is now included with SANE thanks to the efforts of Kazuhiro Sasayama . * OS/2 Support Thanks to Jeff Freedman SANE now supports OS/2. * New backend for Microtek scanners Thanks to the excellent work of Matthew Marjanovic , the Microtek is now taking shape. * Irix SCSI support Thanks to the work of Michael Sweet , there is now SCSI support for Irix! * Improvements to the UMAX backend (by Oliver Rauch): ** workaround for preview-bit-problem in RGB-mode (UMAX S6E ...) ** unsupported options are disabled ** now three_pass_scan should work ** new supported scanners: *** UC840 *** Astra 1200S * The Mustek configuration file (mustek.conf) now supports a configuration option to limit the height of the strip that is scanned with a single SCSI read command. The syntax is: option strip-height HEIGHT where HEIGHT is a floating point number that gives the maximum strip height in inches. This option should be set to a small value (e.g., 1 inch) when the scanner is connected to a SCSI bus shared with other devices or when using a broken SCSI driver whose timeouts expire prematurely. For best scan performance, the strip-height should be set to a large value or the option should be removed completely. See the sane-scsi(5) man-page for details on how drivers with premature timeouts can be fixed (the Linux ncr810 driver is the only known driver with this problem at this point). * The preview window now properly draws the initial window-selection. * Mustek backend now uses a SCSI command queue to avoid performance problems with three pass scanners. This can reduce scantimes from 15 minutes down to 3 minutes! * Mustek backend will now wait for up to 1 minute for a scanner to become ready if the scanner name is specified explicitly. E.g., "scanimage -d mustek" will timeout almost right away (since the Mustek device name is not specified explicitly) whereas "scanimage -d mustek:/dev/scanner" will wait for up to a minute. * HP backend now uses pixel-unit commands to accommodate ScanJet 5P. * Platform-specific SCSI setup info is now in sanei-scsi(5). * xscanimage(1) now has a section on how to run it under GIMP. * B&W qcam support should now work (reports on how well it works are welcome). * Exiting xscanimage with preview window open should no longer cause an error. * Support for OpenStep/NeXTStep added (xscanimage and xcam require an X server and the GTK+ libraries, though). User-level SCSI is supported. * SCSI support for NetBSD and FreeBSD should work now. Thanks to NOGAYA Shigeki and Amancio Hasty for relevant patches. * New man-page sane-scsi(5) with platform-specific SCSI tips and tricks. * SANE now builds on HP-UX (SCSI support untested) and IRIX (no SCSI support), too. New in 0.6: * UMAX scanners are now supported! Kudos to Oliver Rauch and Michael K. Johnson . * scan got renamed to scanimage to avoid a nameclash with an MH program by the same name. For consistency, xscan also got renamed to xscanimage. * Man-pages! There finally are at least a few man-pages. At present, the following is covered: saned.1 scanimage.1 xscanimage.1 sane-dll.5 sane-hp.5 sane-mustek.5 sane-net.5 sane-pint.5 sane-pnm.5 sane-qcam.5 sane-umax.5 * SANE no longer insists on using GCC. GCC works best, but other ANSI C compilers will now also produce usable executables. * xscanimage now supports vector options (such as gamma-tables which are also known as intensity or tonemaps). * The gamma-table (intensity/tone-map) handling changed in the Mustek backend. As a result, when using scanimage it is now necessary to specify option --custom-gamma before gamma-tables can be specified. Also, the handling of the intensity table is now handled better in color mode (it no longer overrides the color tables; instead the composition of the intensity and the color channel table is used). * The SANE header files are now isolated in the include/sane directory and those files get now installed as part of "make install". Thanks to Michael K. Johnson for this patch! * xscanimage now displays the options' documentation strings as tooltips (can be disabled via the "Preferences" menu). * scanimage now supports three-pass scanning and scanning of images whose height is not known a priori (e.g., hand-held scanners). * The Mustek backend now supports an option to force preview scans to be monochrome (good to save time on three-pass scanners). * configure can now be run from any directory, as it's supposed to (makes it easier to build SANE for multiple platforms from the same source tree). * xcam and xscanimage should now build on Solaris, too (thanks to Tristan Tarrant). * copyright info in various files have been adjusted. See LICENSE for the general idea behind SANE licensing. * Many, many bugfixes. New in 0.5: * The same xscan binary can now function as a standalone frontend or as a gimp extension. If installed as a GIMP extension, xscan will attach itself as Extensions->Acquire Image. * The pnm backend now has an option to simulate a three-pass scanner. Good for testing. * xscan now supports previewing and (persistent) preferences. * The build process should be much more robust now. It requires GNU make and gcc but should be completely unproblematic otherwise. A simple "configure" should result in a working SANE environment even on systems where dynamic loading is unavailable. Various options are available to tailor the SANE setup. See README for details. * A first implementation of the HP backend now exists (for ScanJet scanners). * A first implementation of the net backend and saned (network daemon) now exists. So it is now possible to scan across the network! See backend/net.README and frontend/saned.README for details. * xcam, a camera frontend is now included. See frontend/xcam.README for details. * Renamed metadl to dll. New in 0.4: * A first implementation of the Connectix quickcam backend now exists. At present, only color cameras are known to work, though it shouldn't be too hard to get the b&w versions to work as well. * Improvements for the command-line frontend scan: ** Option settings are now applied _before_ the help info is printed. This allows to see what the available options are with certain options in effect. ** It can now deal with SANE_INFO_RELOAD_OPTIONS. ** It now prints the current option values in the help message (except for vectors). New in 0.33: * sane_get_devices() now takes a second argument of boolean type. If it's SANE_TRUE, then the backend must return local (non-remote) devices only. * scan now uses the default-unit of `mm' (millimeters) again for lengths. Using `cm' (centimeter) proved confusing since the help messages print length values in millimeters. * Debugging can now be controlled on a per-backend basis. The debug-level of backend is set by environment variable SANE_DEBUG_. For example, to see all debug messages of the metadl backend, set SANE_DEBUG_METADL to a large value (say 128). The sanei.h file provides three macros to assist in using this debug facility: DBG_DECL to declare the integer variable that holds the debug level, DBG_INIT to initialize debugging, and DBG to print a debug message. See backend/sanei.h and backend/metadl.c for details and examples. * scan now supports setting options to "auto" mode (e.g., --brightness=auto would ask the backend to select brightness automatically if that option supports automatic mode * scan now allows abbreviating the values of a string-lists. Case is ignored and the best matches is used (either longest unique match or exact match when ignoring case) New in 0.32: * xscan improved much. See frontend/xscan.README and frontend/xscan.BUGS for details. New in 0.31: * xscan has improved much. See frontend/xscan.CHANGES for details. New in 0.3: * The location of the SANE configuration files moved from /etc/saneconf to ${prefix}/etc/sane.d. This normally expands into /usr/local/etc/sane.d. * Real build environment. It's GNU autoconf based so all you should have to say is: ./configure make make install sane-backends-1.0.29/README.os20000666000000000000000000001726313615534521012574 000000000000002002-01-03 Look at http://home.tiscalinet.de/fbakan/sane-os2.htm for information about compiling SANE on OS/2 (from Franz Bakan). The following text was for 1.0.3, but it may help nevertheless. SANE 1.03 for OS/2 - build 1 ---------------------------- 09 Jul 2000, Yuri Dario WARNING: -------- This release of has been compiled with EMX 0.9D, so it doesn't work with the previous runtime. You must upgrade to the latest runtime before running SANE (actually EMX 0.9D fix 03). SANE (Scanner Access Now Easy) ------------------------------ For more info about the SANE Project, please visit http://www.sane-project.org/ You should also check the main site for an updated list of supported scanners. Note that I can't say you if your scanner is supported; check SANE homepage instead. SUPPORT ------- I'm sorry to tell you that it is hard for me to help you: if your scanner doesn't work or your problem can't be reproduced on my pc, there are high choices that I can't fix the bug. Most problems are specific to same PC/scanner combinations, and can't be solved without having a full developement enviroment and programming experience. I have setup a mailing list for users, where I hope most people can find an answer to their questions. You will find that I answer only sometimes, because I'm too busy. To subscribe please visit http://www.egroups.com and look for sane-os2, or fill the form available on my site. DOCUMENTATION ------------- To read docs with correct format, you should type more < doc\sane-epson.txt If someone has more ideas on how to get a correct .txt starting from a .man file, he is welcome (actually I'm using groff). INSTALLATION ------------ If you already didn't it, install the correct driver for your scsi adapter. The drivers has usually a .ADD extension and looks like BASEDEV=AHA154X.ADD Then you need the ASPI driver: this driver is already in your OS2\BOOT directory, so you have only to add BASEDEV=OS2ASPI.DMD /ALL The /ALL switch is required only if you need to use other devices with aspirout.sys, e.g. if you have a CD-RW and CDRecord/2 installed. Last, add aspirout.sys to your config.sys DEVICE=D:\OS2\BOOT\ASPIROUT.SYS N.B. you can change the path to other directories. Now reboot. To run scanimage.exe you need also to download the latest EMX runtime, available on Hobbes or Leo as emxrt.zip. find-scanner.exe can be used to recognize a scanner on the scsi bus. Then you should edit your xxx.conf file and add the scanner address, a string like b0t4l0. This can be simplified using autodetection: with autodetection you can use a string like scsi EPSON in your xxx.conf file; the autodection will enable the backend that recognize 'EPSON' in the scanner id. To test scanimage, run scanimage --help you should see your scanner following the list of internal devices: List of available devices: pnm:0 pnm:1 If it is not present, check your scsi driver, the aspi driver OS2ASPI.DMD and aspirout.sys; on Warp4 you can use the Hardware Manager to check scanner presence. Then look at your xxx.conf, maybe there is something wrong in the text. USAGE: ------ Once configured your system, create a proper .conf file (edit one of the supplied templates) and run scanimage -L The output should be like device `umax:b0t3l0' is a UMAX Vista-S8 flatbed scanner device `pnm:0' is a Noname PNM file reader virtual device device `pnm:1' is a Noname PNM file reader virtual device The pnm devices are always available, while on the first line you should read the id of your scanner. A simple scan scanimage -d umax > test.pnm will do a scan with default parameters. Run scanimage -d umax --help to get a full list of available switches. SANED: ------ In this release the SANE network daemon can be used (with a limit). First edit your \mptn\etc\services and add sane 6566/tcp # SANE network scanner daemon (maybe a reboot is required to apply that change). Create a saned.conf in the same directory of saned.exe and add a list of valid client addresses; the clients are allowed to access the local scanner. Now run the server in debug mode saned -d On the client side, you need to create a net.conf file in the same directory of scanimage.exe: here you have to add a list of valid saned servers. Run scanimage -L The output is like this device `umax:b0t3l0' is a UMAX Vista-S8 flatbed scanner device `pnm:0' is a Noname PNM file reader virtual device device `pnm:1' is a Noname PNM file reader virtual device device `net:pippo.intranet:umax:b0t3l0' is a UMAX Vista-S8 flatbed scanner device `net:pippo.intranet:pnm:0' is a Noname PNM file reader virtual device device `net:pippo.intranet:pnm:1' is a Noname PNM file reader virtual device Then saned will quit. To run it forever, you have to configure the INETD daemon: create a \mptn\etc\inetd.lst with the following line sane tcp /rd/sane/sane-1.0.1/frontend/saned.exe Be aware that this configuration shouldn't work: I have been unable to get it working on my PC without running saned under the debugger PMGDB. The correct syntax for running scanimage over the net is scanimage -d net:HOSTNAME:umax:b0t3l0 > test.pnm where HOSTNAME is a valid DNS host name. You can log server access using syslogd: if syslogd is running, saned will send to it all messages. HOW TO COMPILE: --------------- To compile SANE with emx, you need - EMX 0.9D - GNU Make 3.75 (rename to make.exe) - GNU Patch 2.5 - KSH 5.2.13 (rename to sh.exe) - GNU Bison - GNU File utilities - GNU SED (stream editor) - Autoconf 2.13 Steps: - untar the original Unix distribution; - unzip this file somewhere; - copy src\* into sane-1.0.1; - enter sane-1.0.1 directory; - apply patches to original distribution: [...\sane-1.0.1]gnupatch -p 0 < patch.os2 - run autoconf to rebuild the configure script - edit configure and change autoconf default optimization flags; search for -O2 -m486 and change to your preferred settings; - add the following line after :${LDFLAGS="...."} : ${LIBS="-lsocket"} - run configure.os2 to build all installation files; - add -Zexe to LDFLAGS in frontend\Makefile and tools\Makefile; - run make (compiler warnings are ok); - wait to complete all makes; Remember to install a Unix like shell in your path; I use ksh.exe renamed to sh.exe, and saved in d:\bin (that's because most unix scripts uses SHELL=/bin/sh) You need also a compatible dl.a and syslog.a library; look in .\contrib for a couple of simple sources. Flags needed under EMX: -Zsysv-signals enables signal management as in SystemV, otherwise emx convention is used (and it is different from sysv). -Zcrtdll link dynamically with EMXLIBCM.DLL; PARALLEL PORT ------------- This release has support for parallel port enabled: actually only the Epson backend makes uses of such support; the Epson GT-300 can be recognized, but scanning can't be completed. Also HP-5100C parallel scanner can be run under OS/2: you need to download the EPST driver from Shuttle Tech. homepage (www.shuttletech.com); follow the instruction for installation. Then the scanner is seen as a scsi HP, so the HP backend can work with it. The Quickcam backend is also included with lpt support, but I can't say how it is working. History: -------- 09 Jul 2000 release 1.03 20 Jun 1999 release 1.01 - changed runtime to EMX 0.9D - fixed: find-scanner should now work correctly. - added: how to compile instructions. 07 Mar 1999 release 1.01 pre-test3 no OS/2 specific fixes 20 Oct 1998 release 0.74 fixed fork()ing backends with new sanei_thread api. fixed scsi autodetection added parallel port support =============================================================================== Yuri Dario http://www.quasarbbs.com/yuri sane-backends-1.0.29/LICENSE0000666000000000000000000000372113615534521012211 00000000000000Sat Apr 23 2005 This files attempts to clarify the licensing situation for the SANE distribution. In case of doubt, the copyright information contained in each file overrides what is said here. SANE consists of three parts each of which has its own licensing terms: * The frontend programs. These programs are generally protected by the GNU General Public License. (See file COPYING.) * The backend libraries. Most backend libraries are protected by the GNU General Public License (see file COPYING), but as an exception, it is permissible to link against such a library without affecting the licensing status of the program that uses the libraries. For details, see the copyright notice at the head of the backend files (e.g., backend/dll.c). Note that not all of the backends apply the exception and that some have additional licensing constraints. E.g., the DC210 backend uses JPG code that is licensed as described in README.djpeg. * The SANE API and network protocol as put forth in the standard document. The standard is considered to be in the public domain. Anyone is free to implement SANE interface conforming applications or libraries in any way he or she sees fit. Frequently Asked Questions about the SANE licensing: * Why don't you use the GNU LPGL ? The reason SANE isn't licensed under the GNU LGPL is very simple: the GNU LGPL didn't exist at the time SANE was first released. So, the SANE Exception was added to the GNU GPL. * Why don't you relicense SANE, now that the GNU LGPL is available ? To relicense the various pieces of code composing SANE, each and every copyright holder needs to agree with the relicensing. Unfortunately, some of the (original) backend authors cannot be contacted any longer, for various reasons; not to mention each and every contributor who sent in a patch. This effectively makes it impossible for the SANE Project to relicense SANE. sane-backends-1.0.29/include/0000755000000000000000000000000013615535551012704 500000000000000sane-backends-1.0.29/include/lassert.h0000666000000000000000000000453213615534521014456 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001 by Henning Meier-Geinitz This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Choose suitable implementation of assert. */ #ifndef lassert_h #define lassert_h /* The idea is from the gcc header file assert.h. */ #if defined __GNUC__ && defined _AIX /* The implementation of assert of gcc on AIX is in libgcc.a. This doesn't work with shared libraries. So let's make our own assert(). */ #define assert(arg) \ ((void) ((arg) ? 0 : lassert (arg, __FILE__, __LINE__))) #define lassert(arg, file, lineno) \ (printf ("%s:%u: failed assertion\n", file, lineno), \ abort (), 0) #else # include #endif #endif /* lassert_h */ sane-backends-1.0.29/include/sane/0000755000000000000000000000000013615535551013632 500000000000000sane-backends-1.0.29/include/sane/sanei_debug.h0000666000000000000000000000753613615534521016203 00000000000000/** @file sanei_debug.h * Support for printing debug messages. * * Use the functions of this header file to print debug or warning messages. */ #ifndef _SANEI_DEBUG_H #define _SANEI_DEBUG_H #include #ifdef __cplusplus extern "C" { #endif /** @name Public macros * These macros can be used in backends and other SANE-related * code. * * Before including sanei_debug.h, the following macros must be set: * * - BACKEND_NAME - The name of your backend without double-quotes (must be set in any case) * - STUBS - If this is defined, no macros will be included. Used in * backends consisting of more than one .c file. * - DEBUG_DECLARE_ONLY - Generates prototypes instead of functions. Used in * backends consisting of more than one .c file. * - DEBUG_NOT_STATIC - Doesn't generate static functions. Used in header files if * they are include in more than one .c file. * * @{ */ /** @def DBG_INIT() * Initialize sanei_debug. * * Call this function before you use any DBG function. */ /** @def DBG(level, fmt, ...) * Print a message at debug level `level' or higher using a printf-like * function. Example: DBG(1, "sane_open: opening fd \%d\\n", fd). * * @param level debug level * @param fmt format (see man 3 printf for details) * @param ... additional arguments */ /** @def IF_DBG(x) * Compile code only if debugging is enabled. * * Expands to x if debug support is enabled at compile-time. If NDEBUG is * defined at compile-time this macro expands to nothing. * * @param x code to expand when debugging is enabled */ /** * @def DBG_LEVEL * Current debug level. * * You can only read this "variable". */ /** @def ENTRY(name) * Expands to sane_BACKEND_NAME_name. * * Example: ENTRY(init) in mustek.c will expand to sane_mustek_init. */ /* @} */ /** @hideinitializer*/ #define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name) #ifdef NDEBUG extern void sanei_debug_ndebug (int level, const char *msg, ...); # define DBG_LEVEL (0) # define DBG_INIT() # define DBG sanei_debug_ndebug # define IF_DBG(x) #else /* !NDEBUG */ /** @hideinitializer*/ # define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME) # if defined(BACKEND_NAME) && !defined(STUBS) # ifdef DEBUG_DECLARE_ONLY extern int DBG_LEVEL; # else /* !DEBUG_DECLARE_ONLY */ int DBG_LEVEL = 0; # endif /* DEBUG_DECLARE_ONLY */ # endif /* BACKEND_NAME && !STUBS */ /** @hideinitializer*/ # define DBG_INIT() \ sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL) /** @hideinitializer*/ # define DBG_LOCAL PASTE(DBG_LEVEL,_call) # ifndef STUBS # ifdef DEBUG_DECLARE_ONLY extern void DBG_LOCAL (int level, const char *msg, ...) #ifdef __GNUC__ __attribute__ ((format (printf, 2, 3))) #endif ; # else /* !DEBUG_DECLARE_ONLY */ # include extern void sanei_debug_msg (int level, int max_level, const char *be, const char *fmt, va_list ap); #ifdef __GNUC__ # ifndef DEBUG_NOT_STATIC static # endif /* !DEBUG_NOT_STATIC */ void DBG_LOCAL (int level, const char *msg, ...) __attribute__ ((format (printf, 2, 3))); #endif /* __GNUC__ */ # ifndef DEBUG_NOT_STATIC static # endif /* !DEBUG_NOT_STATIC */ void DBG_LOCAL (int level, const char *msg, ...) { va_list ap; va_start (ap, msg); sanei_debug_msg (level, DBG_LEVEL, STRINGIFY(BACKEND_NAME), msg, ap); va_end (ap); } # endif /* DEBUG_DECLARE_ONLY */ # endif /* !STUBS */ /** @hideinitializer*/ # define DBG DBG_LOCAL extern void sanei_init_debug (const char * backend, int * debug_level_var); /** @hideinitializer*/ # define IF_DBG(x) x #endif /* NDEBUG */ #ifdef __cplusplus } // extern "C" #endif #endif /* _SANEI_DEBUG_H */ sane-backends-1.0.29/include/sane/sanei_magic.h0000666000000000000000000001730713615534521016172 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2009 m. allan noah This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_magic.h * This file provides an interface to simple image post-processing functions * * Currently, three operations are provided: * - Deskew (correct rotated scans, by detecting media edges) * - Autocrop (reduce image size to minimum rectangle containing media) * - Despeckle (replace dots of significantly different color with background) * - Blank detection (check if density is over a threshold) * - Rotate (detect and correct 90 degree increment rotations) * * Note that these functions are simplistic, and are expected to change. * Patches and suggestions are welcome. */ #ifndef SANEI_MAGIC_H #define SANEI_MAGIC_H #ifdef __cplusplus extern "C" { #endif /** Initialize sanei_magic. * * Call this before any other sanei_magic function. */ extern void sanei_magic_init( void ); /** Update the image buffer, replacing dots with surrounding background color * * @param params describes image * @param buffer contains image data * @param diam maximum dot diameter to remove * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_INVAL - invalid image parameters */ extern SANE_Status sanei_magic_despeck (SANE_Parameters * params, SANE_Byte * buffer, SANE_Int diam); /** Find the skew of the media inside the image, via edge detection. * * @param params describes image * @param buffer contains image data * @param dpiX horizontal resolution * @param dpiY vertical resolution * @param[out] centerX horizontal coordinate of center of rotation * @param[out] centerY vertical coordinate of center of rotation * @param[out] finSlope slope of rotation * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - not enough memory * - SANE_STATUS_INVAL - invalid image parameters * - SANE_STATUS_UNSUPPORTED - slope angle too shallow to detect */ extern SANE_Status sanei_magic_findSkew(SANE_Parameters * params, SANE_Byte * buffer, int dpiX, int dpiY, int * centerX, int * centerY, double * finSlope); /** Correct the skew of the media inside the image, via simple rotation * * @param params describes image * @param buffer contains image data * @param centerX horizontal coordinate of center of rotation * @param centerY vertical coordinate of center of rotation * @param slope slope of rotation * @param bg_color the replacement color for edges exposed by rotation * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - not enough memory * - SANE_STATUS_INVAL - invalid image parameters */ extern SANE_Status sanei_magic_rotate (SANE_Parameters * params, SANE_Byte * buffer, int centerX, int centerY, double slope, int bg_color); /** Find the edges of the media inside the image, parallel to image edges * * @param params describes image * @param buffer contains image data * @param dpiX horizontal resolution * @param dpiY vertical resolution * @param[out] top vertical offset to upper edge of media * @param[out] bot vertical offset to lower edge of media * @param[out] left horizontal offset to left edge of media * @param[out] right horizontal offset to right edge of media * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - not enough memory * - SANE_STATUS_UNSUPPORTED - edges could not be detected */ extern SANE_Status sanei_magic_findEdges(SANE_Parameters * params, SANE_Byte * buffer, int dpiX, int dpiY, int * top, int * bot, int * left, int * right); /** Crop the image, parallel to image edges * * @param params describes image * @param buffer contains image data * @param top vertical offset to upper edge of crop * @param bot vertical offset to lower edge of crop * @param left horizontal offset to left edge of crop * @param right horizontal offset to right edge of crop * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - not enough memory * - SANE_STATUS_INVAL - invalid image parameters */ extern SANE_Status sanei_magic_crop(SANE_Parameters * params, SANE_Byte * buffer, int top, int bot, int left, int right); /** Determine if image is blank * * @param params describes image * @param buffer contains image data * @param thresh maximum % density for blankness (0-100) * * @return * - SANE_STATUS_GOOD - page is not blank * - SANE_STATUS_NO_DOCS - page is blank * - SANE_STATUS_NO_MEM - not enough memory * - SANE_STATUS_INVAL - invalid image parameters */ extern SANE_Status sanei_magic_isBlank(SANE_Parameters * params, SANE_Byte * buffer, double thresh); /** Determine if image is blank, enhanced version * * @param params describes image * @param buffer contains image data * @param dpiX horizontal resolution * @param dpiY vertical resolution * @param thresh maximum % density for blankness (0-100) * * @return * - SANE_STATUS_GOOD - page is not blank * - SANE_STATUS_NO_DOCS - page is blank * - SANE_STATUS_NO_MEM - not enough memory * - SANE_STATUS_INVAL - invalid image parameters */ extern SANE_Status sanei_magic_isBlank2(SANE_Parameters * params, SANE_Byte * buffer, int dpiX, int dpiY, double thresh); /** Determine coarse image rotation (90 degree increments) * * @param params describes image * @param buffer contains image data * @param dpiX horizontal resolution * @param dpiY vertical resolution * @param[out] angle amount of rotation recommended * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - not enough memory * - SANE_STATUS_INVAL - invalid image parameters */ extern SANE_Status sanei_magic_findTurn(SANE_Parameters * params, SANE_Byte * buffer, int dpiX, int dpiY, int * angle); /** Coarse image rotation (90 degree increments) * * @param params describes image * @param buffer contains image data * @param angle amount of rotation requested (multiple of 90) * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - not enough memory * - SANE_STATUS_INVAL - invalid image or angle parameters */ extern SANE_Status sanei_magic_turn(SANE_Parameters * params, SANE_Byte * buffer, int angle); #ifdef __cplusplus } // extern "C" #endif #endif /* SANEI_MAGIC_H */ sane-backends-1.0.29/include/sane/sanei_backend.h0000666000000000000000000001161713615534521016477 00000000000000/** @file sanei_backend.h * Compatibility header file for backends * * This file provides some defines for macros missing on some platforms. * It also has the SANE API entry points. sanei_backend.h must be included * by every backend. * * @sa sanei.h sanei_thread.h */ /** @name Compatibility macros * @{ */ #include #if __STDC_VERSION__ >= 199901L /* __func__ is provided */ #elif __GNUC__ >= 5 /* __func__ is provided */ #elif __GNUC__ >= 2 # define __func__ __FUNCTION__ #else # define __func__ "(unknown)" #endif #ifdef HAVE_SYS_HW_H /* OS/2 i/o-port access compatibility macros: */ # define inb(p) _inp8 (p) # define outb(v,p) _outp8 ((p),(v)) # define ioperm(b,l,o) _portaccess ((b),(b)+(l)-1) # define HAVE_IOPERM 1 #endif #ifndef HAVE_OS2_H #include #ifndef O_NONBLOCK # ifdef O_NDELAY # define O_NONBLOCK O_NDELAY # else # ifdef FNDELAY # define O_NONBLOCK FNDELAY /* last resort */ # endif # endif #endif #endif /* HAVE_OS2_H */ #include #ifndef PATH_MAX # define PATH_MAX 1024 #endif #ifndef M_PI #define M_PI 3.14159265358979323846 #endif #ifndef MM_PER_INCH #define MM_PER_INCH 25.4 #endif #ifdef HAVE_SIGPROCMASK # define SIGACTION sigaction #else /* Just enough backwards compatibility that we get by in the backends without making handstands. */ # ifdef sigset_t # undef sigset_t # endif # ifdef sigemptyset # undef sigemptyset # endif # ifdef sigfillset # undef sigfillset # endif # ifdef sigaddset # undef sigaddset # endif # ifdef sigdelset # undef sigdelset # endif # ifdef sigprocmask # undef sigprocmask # endif # ifdef SIG_BLOCK # undef SIG_BLOCK # endif # ifdef SIG_UNBLOCK # undef SIG_UNBLOCK # endif # ifdef SIG_SETMASK # undef SIG_SETMASK # endif # define sigset_t int # define sigemptyset(set) do { *(set) = 0; } while (0) # define sigfillset(set) do { *(set) = ~0; } while (0) # define sigaddset(set,signal) do { *(set) |= sigmask (signal); } while (0) # define sigdelset(set,signal) do { *(set) &= ~sigmask (signal); } while (0) # define sigaction(sig,new,old) sigvec (sig,new,old) /* Note: it's not safe to just declare our own "struct sigaction" since some systems (e.g., some versions of OpenStep) declare that structure, but do not implement sigprocmask(). Hard to believe, aint it? */ # define SIGACTION sigvec # define SIG_BLOCK 1 # define SIG_UNBLOCK 2 # define SIG_SETMASK 3 #endif /* !HAVE_SIGPROCMASK */ /* @} */ /** @name Declaration of entry points: * @{ */ #ifdef __cplusplus extern "C" { #endif extern SANE_Status ENTRY(init) (SANE_Int *, SANE_Auth_Callback); extern SANE_Status ENTRY(get_devices) (const SANE_Device ***, SANE_Bool); extern SANE_Status ENTRY(open) (SANE_String_Const, SANE_Handle *); extern const SANE_Option_Descriptor * ENTRY(get_option_descriptor) (SANE_Handle, SANE_Int); extern SANE_Status ENTRY(control_option) (SANE_Handle, SANE_Int, SANE_Action, void *, SANE_Word *); extern SANE_Status ENTRY(get_parameters) (SANE_Handle, SANE_Parameters *); extern SANE_Status ENTRY(start) (SANE_Handle); extern SANE_Status ENTRY(read) (SANE_Handle, SANE_Byte *, SANE_Int, SANE_Int *); extern SANE_Status ENTRY(set_io_mode) (SANE_Handle, SANE_Bool); extern SANE_Status ENTRY(get_select_fd) (SANE_Handle, SANE_Int *); extern void ENTRY(cancel) (SANE_Handle); extern void ENTRY(close) (SANE_Handle); extern void ENTRY(exit) (void); #ifdef __cplusplus } // extern "C" #endif #ifndef STUBS /* Now redirect sane_* calls to backend's functions: */ #define sane_init(a,b) ENTRY(init) (a,b) #define sane_get_devices(a,b) ENTRY(get_devices) (a,b) #define sane_open(a,b) ENTRY(open) (a,b) #define sane_get_option_descriptor(a,b) ENTRY(get_option_descriptor) (a,b) #define sane_control_option(a,b,c,d,e) ENTRY(control_option) (a,b,c,d,e) #define sane_get_parameters(a,b) ENTRY(get_parameters) (a,b) #define sane_start(a) ENTRY(start) (a) #define sane_read(a,b,c,d) ENTRY(read) (a,b,c,d) #define sane_set_io_mode(a,b) ENTRY(set_io_mode) (a,b) #define sane_get_select_fd(a,b) ENTRY(get_select_fd) (a,b) #define sane_cancel(a) ENTRY(cancel) (a) #define sane_close(a) ENTRY(close) (a) #define sane_exit(a) ENTRY(exit) (a) #endif /* STUBS */ /* @} */ /** Internationalization for SANE backends * * Add SANE_I18N() to all texts that can be translated. * E.g. out_txt = SANE_I18N("Hello"); */ #ifndef SANE_I18N #define SANE_I18N(text) text #endif /** Option_Value union * * Convenience union to access option values given to the backend */ #ifndef SANE_OPTION typedef union { SANE_Bool b; /**< bool */ SANE_Word w; /**< word */ SANE_Word *wa; /**< word array */ SANE_String s; /**< string */ } Option_Value; #define SANE_OPTION 1 #endif sane-backends-1.0.29/include/sane/sanei.h0000666000000000000000000001315713615534521015031 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996 David Mosberger-Tang and Andreas Beck Copyright (C) 2002, 2003 Henning Meier-Geinitz This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei.h * Convenience macros and function declarations for backends * @sa sanei_backend.h sanei_thread.h */ /* Doxygen documentation */ /** @mainpage SANEI (SANE internal routines) documentation * * @image html sane-logo2.jpg * @section intro Introduction * * The header files in the include/sane/ directory named sanei_*.h provide * function declarations and macros that can be used by every SANE backend. * Their implementations can be found in the sanei/ directory. The code aims * to be platform-independent to avoid lots of \#ifdef code in the backends. * Please use the SANEI functions wherever possible. * * This documentation was created by the use of doxygen, the * doc/doxygen-sanei.conf configuration file and documentation in the sanei_*.h * files. * * This documentation is far from complete. Any help is appreciated. * * @section additional Additional documentation * - The SANE standard can be found at the SANE webserver, * though the PostScript version produced from the source may be more recent. * - Information on how to write a backend: backend-writing.txt. * - General SANE documentation is on the SANE documentation * page. * * @section contact Contact * * The common way to contact the developers of SANE is the sane-devel * mailing list. See the mailing list webpage * for details. That's the place to ask questions, report bugs, or announce * a new backend. * */ #ifndef sanei_h #define sanei_h #include #ifdef __cplusplus extern "C" { #endif /** @name Public macros and functions * @{ */ /** @def __sane_unused__ * Mark parameters as potentially unused. */ /** @def STRINGIFY(x) * Turn parameter into string. */ /** @def PASTE(x,y) * Concatenate parameters. * */ /** @def NELEMS(a) * Return number of elements of an array. * */ /** @fn extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt, void * value); * Check the constraints of a SANE option. * * @param opt option to check * @param value value of the option * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if the value doesn't fit inside the constraint * or any other error occured * @sa sanei_constrain_value() */ /** @fn extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt, void * value, SANE_Word * info); * Check the constraints of a SANE option and adjust its value if necessary. * * Depending on the type of the option and constraint, value is modified * to fit inside constraint. * * @param opt option to check * @param value value of the option * @param info info is set to SANE_INFO_INEXACT if value was changed * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if the function wasn't able to fit value into the * constraint or any other error occured * @sa sanei_check_value() */ /* @} */ /* A few convenience macros: */ /** @hideinitializer */ #ifdef __GNUC__ #define __sane_unused__ __attribute__((unused)) #else #define __sane_unused__ #endif /** @hideinitializer */ #define NELEMS(a) ((int)(sizeof (a) / sizeof (a[0]))) /** @hideinitializer */ #define STRINGIFY1(x) #x /** @hideinitializer */ #define STRINGIFY(x) STRINGIFY1(x) /** @hideinitializer */ #define PASTE1(x,y) x##y /** @hideinitializer */ #define PASTE(x,y) PASTE1(x,y) extern SANE_Status sanei_check_value (const SANE_Option_Descriptor * opt, void * value); extern SANE_Status sanei_constrain_value (const SANE_Option_Descriptor * opt, void * value, SANE_Word * info); #ifdef __cplusplus } // extern "C" #endif #endif /* sanei_h */ sane-backends-1.0.29/include/sane/sanei_ir.h0000666000000000000000000003333313615534521015521 00000000000000/** @file sanei_ir.h * * This file provides an interface to the * sanei_ir functions for utilizing the infrared plane * * Copyright (C) 2012 Michael Rickmann * * This file is part of the SANE package. * * Essentially three things have to be done: * - 1) reduce red spectral overlap from the infrared (ired) plane * - 2) find the dirt * - 3) replace the dirt * * - 1) is mainly adressed by sanei_ir_spectral_clean * - 2) by sanei_ir_filter_madmean * - 3) by sanei_ir_dilate_mean */ #ifndef SANEI_IR_H #define SANEI_IR_H #include #define SAMPLE_SIZE 40000 /**< maximal for random sampling */ #define HISTOGRAM_SHIFT 8 /**< standard histogram size */ #define HISTOGRAM_SIZE (1 << HISTOGRAM_SHIFT) #define SAFE_LOG(x) ( ((x) > 0.0) ? log ((x)) : (0.0) ) /**< define log (0) = 0 */ #define MAD_WIN2_SIZE(x) ( (((x) * 4) / 3) | 1 ) /**< MAD filter: 2nd window size */ typedef uint16_t SANE_Uint; /** * @brief Pointer to access values of different bit depths */ typedef union { uint8_t *b8; /**< <= 8 bits */ uint16_t *b16; /**< > 8, <= 16 bits */ } SANEI_IR_bufptr; /** Initialize sanei_ir. * * Call this before any other sanei_ir function. */ extern void sanei_ir_init (void); /** * @brief Create the normalized histogram of a grayscale image * * @param[in] params describes image * @param[in] img_data image pointer { grayscale } * @param[out] histogram an array of double with histogram * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * * @note * histogram has to be freed by calling routine */ extern SANE_Status sanei_ir_create_norm_histogram (const SANE_Parameters * params, const SANE_Uint *img_data, double ** histogram); /** * @brief Implements Yen's thresholding method * * @param[in] params describes image * @param[in] norm_histo points to a normalized histogram * @param[out] thresh found threshold * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * * -# Yen J.C., Chang F.J., and Chang S. (1995) "A New Criterion * for Automatic Multilevel Thresholding" IEEE Trans. on Image * Processing, 4(3): 370-378 * -# Sezgin M. and Sankur B. (2004) "Survey over Image Thresholding * Techniques and Quantitative Performance Evaluation" Journal of * Electronic Imaging, 13(1): 146-165 * -# M. Emre Celebi, 06.15.2007, fourier_0.8, * http://sourceforge.net/projects/fourier-ipal/ * -# ImageJ Multithresholder plugin, * http://rsbweb.nih.gov/ij/plugins/download/AutoThresholder.java */ extern SANE_Status sanei_ir_threshold_yen (const SANE_Parameters * params, double * norm_histo, int *thresh); /** * @brief Implements Otsu's thresholding method * * @param[in] params describes image * @param[in] norm_histo points to a normalized histogram * @param[out] thresh found threshold * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * * -# Otsu N. (1979) "A Threshold Selection Method from Gray Level Histograms" * IEEE Trans. on Systems, Man and Cybernetics, 9(1): 62-66 * -# M. Emre Celebi, 06.15.2007, fourier_0.8 * http://sourceforge.net/projects/fourier-ipal/ */ extern SANE_Status sanei_ir_threshold_otsu (const SANE_Parameters * params, double * norm_histo, int *thresh); /** * @brief Implements a Maximum Entropy thresholding method * * @param[in] params describes image * @param[in] norm_histo points to a normalized histogram * @param[out] thresh found threshold * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * * -# Kapur J.N., Sahoo P.K., and Wong A.K.C. (1985) "A New Method for * Gray-Level Picture Thresholding Using the Entropy of the Histogram" * Graphical Models and Image Processing, 29(3): 273-285 * -# M. Emre Celebi, 06.15.2007, fourier_0.8 * http://sourceforge.net/projects/fourier-ipal/ * -# ImageJ Multithresholder plugin, * http://rsbweb.nih.gov/ij/plugins/download/AutoThresholder.java */ extern SANE_Status sanei_ir_threshold_maxentropy (const SANE_Parameters * params, double * norm_histo, int *thresh); /** * @brief Generate gray scale luminance image from separate R, G, B images * * @param params points to image description * @param[in] in_img pointer to at least 3 planes of image data * @param[out] out_img newly allocated image * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * - SANE_STATUS_UNSUPPORTED - wrong input bit depth * * @note out_img has to be freed by the calling routine. * @note on input params describe a single color plane, * on output params are updated if image depth is scaled */ SANE_Status sanei_ir_RGB_luminance (SANE_Parameters * params, const SANE_Uint **in_img, SANE_Uint **out_img); /** * @brief Convert image from >8 bit depth to an 8 bit image. * * @param[in] params pimage description * @param[in] in_img points to input image data * @param[out] out_params if != NULL * receives description of new image * @param[out] out_img newly allocated 8-bit image * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * - SANE_STATUS_UNSUPPORTED - wrong input bit depth * * @note * out_img has to be freed by the calling routine, */ extern SANE_Status sanei_ir_to_8bit (SANE_Parameters * params, const SANE_Uint *in_img, SANE_Parameters * out_params, SANE_Uint **out_img); /** * @brief Allocate and initialize logarithmic lookup table * * @param[in] len length of table, usually 1 << depth * @param[out] lut_ln adress of pointer to allocated table * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * * @note natural logarithms are provided */ SANE_Status sanei_ir_ln_table (int len, double **lut_ln); /** * @brief Reduces red spectral overlap from an infrared image plane * * @param[in] params pointer to image description * @param[in] lut_ln pointer lookup table * if NULL it is dynamically handled * @param[in] red_data pointer to red image plane * @param ir_data pointer to ir image plane * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * * This routine is based on the observation that the relation beween the infrared value * ired and the red value red of an image point can be described by ired = b + a * ln (red). * First points are randomly sampled to calculate the linear regression coefficent a. * Then ired' = ired - a * ln (red) is calculated for each pixel. Finally, the ir' image * is scaled between 0 and maximal value. For the logarithms a lookup table is used. * Negative films show very little spectral overlap but positive film usually has to be * cleaned. As we do a statistical measure of the film here dark margins and lumps of * dirt have to be excluded. * * @note original ired data are replaced by the cleaned ones */ extern SANE_Status sanei_ir_spectral_clean (const SANE_Parameters * params, double *lut_ln, const SANE_Uint *red_data, SANE_Uint *ir_data); /** * @brief Optimized mean filter * * @param[in] params pointer to image description * @param[in] in_img Pointer to grey scale image data * @param[out] out_img Pointer to grey scale image data * @param[in] win_rows Height of filtering window, odd * @param[in] win_cols Width of filtering window, odd * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * - SANE_STATUS_INVAL - wrong window size * * @note At the image margins the size of the filtering window * is adapted. So there is no need to pad the image. * @note Memory for the output image has to be allocated before */ extern SANE_Status sanei_ir_filter_mean (const SANE_Parameters * params, const SANE_Uint *in_img, SANE_Uint *out_img, int win_rows, int win_cols); /** * @brief Find noise by adaptive thresholding * * @param[in] params pointer to image description * @param[in] in_img pointer to grey scale image * @param[out] out_img address of pointer to newly allocated binary image * @param[in] win_size Size of filtering window * @param[in] a_val Parameter, below is definetly clean * @param[in] b_val Parameter, above is definetly noisy * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * * This routine follows the concept of Crnojevic's MAD (median of the absolute deviations * from the median) filter. The first median filter step is replaced with a mean filter. * The dirty pixels which we wish to remove are always darker than the real signal. But * at high resolutions the scanner may generate some noise and the ired cleaning step can * reverse things. So a maximum filter will not do. * The second median is replaced by a mean filter to reduce computation time. Inspite of * these changes Crnojevic's recommendations for the choice of the parameters "a" and "b" * are still valid when scaled to the color depth. * * @reco Crnojevic recommends 10 < a_val < 30 and 50 < b_val < 100 for 8 bit color depth * * @note a_val, b_val are scaled by the routine according to bit depth * @note "0" in the mask output is regarded "dirty", 255 "clean" * * -# Crnojevic V. (2005) "Impulse Noise Filter with Adaptive Mad-Based Threshold" * Proc. of the IEEE Int. Conf. on Image Processing, 3: 337-340 */ extern SANE_Status sanei_ir_filter_madmean (const SANE_Parameters * params, const SANE_Uint *in_img, SANE_Uint ** out_img, int win_size, int a_val, int b_val); /** * @brief Add dark pixels to mask from static threshold * * @param[in] params pointer to image description * @param[in] in_img pointer to grey scale image * @param mask_img pointer to binary image (0, 255) * @param[in] threshold below which the pixel is set 0 */ void sanei_ir_add_threshold (const SANE_Parameters * params, const SANE_Uint *in_img, SANE_Uint * mask_img, int threshold); /** * @brief Calculates minimal Manhattan distances for an image mask * * @param[in] params pointer to image description * @param[in] mask_img pointer to binary image (0, 255) * @param[out] dist_map integer pointer to map of closest distances * @param[out] idx_map integer pointer to indices of closest pixels * @param[in] erode == 0: closest pixel has value 0, != 0: is 255 * * manhattan_dist takes a mask image consisting of 0 or 255 values. Given that * a 0 represents a dirty pixel and erode != 0, manhattan_dist will calculate the * shortest distance to a clean (255) pixel and record which pixel that was so * that the clean parts of the image can be dilated into the dirty ones. Thresholding * can be done on the distance. Conversely, if erode == 0 the distance of a clean * pixel to the closest dirty one is calculated which can be used to dilate the mask. * * @ref extended and C version of * http://ostermiller.org/dilate_and_erode.html */ void sanei_ir_manhattan_dist (const SANE_Parameters * params, const SANE_Uint * mask_img, unsigned int *dist_map, unsigned int *idx_map, unsigned int erode); /** * @brief Dilate or erode a mask image * * @param[in] params pointer to image description * @param mask_img pointer to binary image (0, 255) * @param dist_map integer pointer to map of closest distances * @param idx_map integer pointer to indices of closest pixels * @param[in] by number of pixels, > 0 dilate, < 0 erode * * @note by > 0 will enlarge the 0 valued area */ void sanei_ir_dilate (const SANE_Parameters * params, SANE_Uint * mask_img, unsigned int *dist_map, unsigned int *idx_map, int by); /** * @brief Suggest cropping for dark margins of positive film * * @param[in] params pointer to image description * @param[in] dist_map integer pointer to map of closest distances * @param[in] inner crop within (!=0) or outside (==0) the image's edges * @param[out] edges pointer to array holding top, bottom, left * and right edges * * The distance map as calculated by sanei_ir_manhattan_dist contains * distances to the next clean pixel. Dark margins are detected as dirt. * So the first/last rows/columns tell us how to crop. This is rather * fast if the distance map has been calculated anyhow. */ void sanei_ir_find_crop (const SANE_Parameters * params, unsigned int * dist_map, int inner, int * edges); /** * @brief Dilate clean image parts into dirty ones and smooth int inner, * * @param[in] params pointer to image description * @param in_img array of pointers to color planes of image * @param[in] mask_img pointer to dirt mask image * @param[in] dist_max threshold up to which dilation is done * @param[in] expand the dirt mask before replacing the pixels * @param[in] win_size size of adaptive mean filtering window * @param[in] smooth triangular filter whole image for grain removal * @param[in] inner find crop within or outside the image's edges * @param[out] crop array of 4 integers, if non-NULL, top, bottom, * left and right values for cropping are returned. * * @return * - SANE_STATUS_GOOD - success * - SANE_STATUS_NO_MEM - if out of memory * * The main purpose of this routine is to replace dirty pixels. * As spin-off it obtains half of what is needed for film grain * smoothening and most of how to crop positive film. * To speed things up these functions are also implemented. */ SANE_Status sanei_ir_dilate_mean (const SANE_Parameters * params, SANE_Uint **in_img, SANE_Uint *mask_img, int dist_max, int expand, int win_size, SANE_Bool smooth, int inner, int *crop); #endif /* not SANEI_IR_H */ sane-backends-1.0.29/include/sane/sanei_config.h0000666000000000000000000001445513615534521016360 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Jeffrey S. Freedman 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_config.h * Generic configuration support. * * Use the functions of this header file if you want to read and analyze * configuration files. */ #ifndef sanei_config_h #define sanei_config_h 1 #include #include #ifdef __cplusplus extern "C" { #endif /** Search configuration file \a name along directory list and return file * pointer if such a file exists. * * The following directory list is used: * 1st: SANE_CONFIG_DIR environment variable. * 2nd: PATH_SANE_CONFIG_DIR set during configuration. * 3rd: Current directory. * @param name filename with extension but without path (such as "mustek.conf") * * @return file pointer, or NULL if not found * */ extern FILE *sanei_config_open (const char *name); /** Read a line from configuration file. * * Strips all unwanted chars. Use this instead of fgets() to remove * line ending chars on all known platforms. * * @param str points to the buffer for the line * @param n size of the buffer * @param stream file pointer * * @return \a str on success and NULL on error */ extern char *sanei_config_read (char *str, int n, FILE *stream); /** Remove all whitespace from the beginning of a string. * * @param str string * * @return string without leading whitespace * */ extern const char *sanei_config_skip_whitespace (const char *str); /** Scan a string constant from a line of text and return a malloced copy * of it. * * It's the responsibility of the caller to free the returned string constant * at an appropriate time. Whitespace in front of the string constant is * ignored. Whitespace can be included in the string constant by enclosing it * in double-quotes. * * @param str line of text to scan for a string constant * @param string_const copy of the string constant * * @return a pointer to the position in str where the scan stopped */ extern const char *sanei_config_get_string (const char *str, char **string_const); /** Expand device name patterns into a list of devices. * * Apart from a normal device name (such as /dev/sdb), this function currently * supports SCSI device specifications of the form: * * scsi VENDOR MODEL TYPE BUS CHANNEL ID LUN * * Where VENDOR is the desired vendor name. MODEL is the desired model name. * TYPE is the desired device type. All of these can be set to * to match * anything. To include whitespace in these strings, enclose them in * double-quotes ("). BUS, ID, and LUN are the desired SCSI bus, id, and * logical-unit numbers. These can be set to * or simply omitted to match * anything. * * @param name device name pattern * @param attach attach function */ extern void sanei_config_attach_matching_devices (const char *name, SANE_Status (*attach) (const char *dev)); /** this structure holds the description of configuration options. There is * a list for options and another for their values. * These lists are used when the configuration file is * parsed. Read values are stored in Option_Value. Helpers functions are * provided to access values easily */ typedef struct { /** number of options */ SANE_Int count; /** NULL terminated list of configuration option */ SANE_Option_Descriptor **descriptors; /** values for the configuration options */ void **values; } SANEI_Config; /** Parse configuration file, reading configuration options and trying to * attach devices found in file. * * The option are gathered in a single configuration structure. Each time * a line holds a value that is not an option, the attach function is called * with the name found and the configuration structure with it's current values. * * @param config_file name of the configuration file to read * @param config configuration structure to be filled during configuration * parsing and passed to the attach callback function * @param config_attach attach with config callback function * * @return SANE_STATUS_GOOD if no errors * SANE_STATUS_ACCESS_DENIED if configuration file can't be opened */ extern SANE_Status sanei_configure_attach ( const char *config_file, SANEI_Config *config, SANE_Status (*config_attach)(SANEI_Config *config, const char *devname) ); /** Return the list of config directories, extracted from the SANE_CONFIG_DIR * environment variable and the default paths. * @return a string containing the configuration paths, separated by the * operating system's path separator */ extern const char *sanei_config_get_paths (void); #ifdef __cplusplus } // extern "C" #endif #endif /* sanei_config_h */ sane-backends-1.0.29/include/sane/config.h.in0000644000000000000000000004451113615534555015605 00000000000000/* include/sane/config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to 1 if the system supports IPv6 */ #undef ENABLE_IPV6 /* Define to 1 if device locking should be enabled. */ #undef ENABLE_LOCKING /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS /* Define if GPLogFunc does not take a va_list. */ #undef GPLOGFUNC_NO_VARGS /* Define to 1 if struct sockaddr_storage has an ss_family member */ #undef HAS_SS_FAMILY /* Define to 1 if struct sockaddr_storage has __ss_family instead of ss_family */ #undef HAS___SS_FAMILY /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file. */ #undef HAVE_APOLLO_SCSI_H /* Define to 1 if you have the header file. */ #undef HAVE_ASM_IO_H /* Define to 1 if you have the header file. */ #undef HAVE_ASM_TYPES_H /* Define to 1 if you have the `atexit' function. */ #undef HAVE_ATEXIT /* Define to 1 if you have the header file. */ #undef HAVE_BE_KERNEL_OS_H /* Define to 1 if you have the header file. */ #undef HAVE_BSD_DEV_SCSIREG_H /* Define to 1 if you have the header file. */ #undef HAVE_CAMLIB_H /* Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework. */ #undef HAVE_CFLOCALECOPYCURRENT /* Define to 1 if you have the `cfmakeraw' function. */ #undef HAVE_CFMAKERAW /* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework. */ #undef HAVE_CFPREFERENCESCOPYAPPVALUE /* define if the compiler supports basic C++11 syntax */ #undef HAVE_CXX11 /* Define if the GNU dcgettext() function is already present or preinstalled. */ #undef HAVE_DCGETTEXT /* Define to 1 if you have the header file. */ #undef HAVE_DDK_NTDDSCSI_H /* Define to 1 if you have the header file. */ #undef HAVE_DEV_PPBUS_PPI_H /* Is /dev/urandom available? */ #undef HAVE_DEV_URANDOM /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the `dlopen' function. */ #undef HAVE_DLOPEN /* Define to 1 if you have the header file. */ #undef HAVE_DL_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `getaddrinfo' function. */ #undef HAVE_GETADDRINFO /* Define to 1 if you have the `getenv' function. */ #undef HAVE_GETENV /* Define to 1 if you have the `getnameinfo' function. */ #undef HAVE_GETNAMEINFO /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H /* Define to 1 if you have the `getopt_long' function. */ #undef HAVE_GETOPT_LONG /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE /* Define to 1 if you have the `getpass' function. */ #undef HAVE_GETPASS /* Define if the GNU gettext() function is already present or preinstalled. */ #undef HAVE_GETTEXT /* Define to 1 if you have the `getuid' function. */ #undef HAVE_GETUID /* Define to 1 if you have the `gp_camera_init' function. */ #undef HAVE_GP_CAMERA_INIT /* Define to 1 if you have the `gp_port_info_get_path' function. */ #undef HAVE_GP_PORT_INFO_GET_PATH /* Define to 1 if you have the header file. */ #undef HAVE_GSCDDS_H /* Define to 1 if you have the `i386_set_ioperm' function. */ #undef HAVE_I386_SET_IOPERM /* Define if you have the iconv() function and it works. */ #undef HAVE_ICONV /* Define to 1 if you have the header file. */ #undef HAVE_IFADDRS_H /* Define to 1 if you have the `inet_addr' function. */ #undef HAVE_INET_ADDR /* Define to 1 if you have the `inet_aton' function. */ #undef HAVE_INET_ATON /* Define to 1 if you have the `inet_ntoa' function. */ #undef HAVE_INET_NTOA /* Define to 1 if you have the `inet_ntop' function. */ #undef HAVE_INET_NTOP /* Define to 1 if you have the `inet_pton' function. */ #undef HAVE_INET_PTON /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_IOKIT_CDB_IOSCSILIB_H /* Define to 1 if you have the header file. */ #undef HAVE_IOKIT_SCSI_COMMANDS_SCSICOMMANDOPERATIONCODES_H /* Define to 1 if you have the header file. */ #undef HAVE_IOKIT_SCSI_SCSICOMMANDOPERATIONCODES_H /* Define to 1 if you have the header file. */ #undef HAVE_IOKIT_SCSI_SCSITASKLIB_H /* Define to 1 if you have the `ioperm' function. */ #undef HAVE_IOPERM /* Define to 1 if you have the `iopl' function. */ #undef HAVE_IOPL /* Define to 1 if you have the header file. */ #undef HAVE_IO_CAM_CAM_H /* Define to 1 if libcurl is available */ #undef HAVE_LIBCURL /* Define to 1 if you have the header file. */ #undef HAVE_LIBC_H /* Define to 1 if you have the `ieee1284' library (-lcam). */ #undef HAVE_LIBIEEE1284 /* Define to 1 if you have the libjpeg library. */ #undef HAVE_LIBJPEG /* Define to 1 if you have the libpng library. */ #undef HAVE_LIBPNG /* Define to 1 if you have the net-snmp library. */ #undef HAVE_LIBSNMP /* Define to 1 if you have libusb-1.0 */ #undef HAVE_LIBUSB /* Define to 1 if you have libusb-0.1 */ #undef HAVE_LIBUSB_LEGACY /* Define to 1 if libxml2 is available */ #undef HAVE_LIBXML2 /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_PPDEV_H /* Define if the long long type is available. */ #undef HAVE_LONG_LONG /* Define to 1 if you have the header file. */ #undef HAVE_LUSB0_USB_H /* Define to 1 if you have the header file. */ #undef HAVE_MACHINE_CPUFUNC_H /* Define to 1 if you have the header file. */ #undef HAVE_MACH_O_DYLD_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have a working `mmap' system call. */ #undef HAVE_MMAP /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the `NSLinkModule' function. */ #undef HAVE_NSLINKMODULE /* Define to 1 if you have the header file. */ #undef HAVE_NTDDSCSI_H /* Define to 1 if you have the header file. */ #undef HAVE_OS2_H /* Define to 1 if you have the `poll' function. */ #undef HAVE_POLL /* Define to 1 if you have the `pthread_cancel' function. */ #undef HAVE_PTHREAD_CANCEL /* Define to 1 if you have the `pthread_create' function. */ #undef HAVE_PTHREAD_CREATE /* Define to 1 if you have the `pthread_detach' function. */ #undef HAVE_PTHREAD_DETACH /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_H /* Define to 1 if you have the `pthread_join' function. */ #undef HAVE_PTHREAD_JOIN /* Define to 1 if you have the `pthread_kill' function. */ #undef HAVE_PTHREAD_KILL /* Define to 1 if you have the `pthread_testcancel' function. */ #undef HAVE_PTHREAD_TESTCANCEL /* Define to 1 if you have the header file. */ #undef HAVE_PWD_H /* define if you have the resmgr library */ #undef HAVE_RESMGR /* Define to 1 if you have the `scsireq_enter' function. */ #undef HAVE_SCSIREQ_ENTER /* Define if SCSITaskSGElement is available. */ #undef HAVE_SCSITASKSGELEMENT /* Define to 1 if you have the header file. */ #undef HAVE_SCSI_H /* Define to 1 if you have the header file. */ #undef HAVE_SCSI_SG_H /* Define to 1 if you have the `setitimer' function. */ #undef HAVE_SETITIMER /* Define if sg_header.target_status is available. */ #undef HAVE_SG_TARGET_STATUS /* Define to 1 if you have the `shl_load' function. */ #undef HAVE_SHL_LOAD /* Define to 1 if you have the `sigprocmask' function. */ #undef HAVE_SIGPROCMASK /* Define to 1 if you have the `sleep' function. */ #undef HAVE_SLEEP /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strcasestr' function. */ #undef HAVE_STRCASESTR /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strftime' function. */ #undef HAVE_STRFTIME /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strncasecmp' function. */ #undef HAVE_STRNCASECMP /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP /* Define to 1 if you have the `strsep' function. */ #undef HAVE_STRSEP /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the `strtod' function. */ #undef HAVE_STRTOD /* Define if struct flock is available. */ #undef HAVE_STRUCT_FLOCK /* Define to 1 if you have the `syslog' function. */ #undef HAVE_SYSLOG /* Is /usr/include/systemd/sd-daemon.h available? */ #undef HAVE_SYSTEMD /* Define to 1 if you have the header file. */ #undef HAVE_SYS_DSREQ_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_HW_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IPC_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PASSTHRUDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_POLL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCANIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCSICMD_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCSIIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCSI_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCSI_SCSI_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCSI_SGDEFS_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SCSI_TARGETS_SCGIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SDI_COMM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SEM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SHM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the `tcsendbreak' function. */ #undef HAVE_TCSENDBREAK /* Define to 1 if you have the header file. */ #undef HAVE_TIFFIO_H /* Define if union semun is available. */ #undef HAVE_UNION_SEMUN /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have usbcall.dll. */ #undef HAVE_USBCALLS /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP /* Define to 1 if the system has the type `u_char'. */ #undef HAVE_U_CHAR /* Define to 1 if the system has the type `u_int'. */ #undef HAVE_U_INT /* Define to 1 if the system has the type `u_long'. */ #undef HAVE_U_LONG /* Define to 1 if the system has the type `u_short'. */ #undef HAVE_U_SHORT /* Define to 1 if you have the `vsyslog' function. */ #undef HAVE_VSYSLOG /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Define to 1 if you have the `_portaccess' function. */ #undef HAVE__PORTACCESS /* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define if pthread_t is integer. */ #undef PTHREAD_T_IS_INTEGER /* SANE DLL revision number */ #undef SANE_DLL_V_BUILD /* SANE DLL major number */ #undef SANE_DLL_V_MAJOR /* SANE DLL minor number */ #undef SANE_DLL_V_MINOR /* Define to 1 if you have the providing inb,outb. */ #undef SANE_HAVE_SYS_IO_H_WITH_INB_OUTB /* SCSI command buffer size */ #undef SCSIBUFFERSIZE /* The size of `char', as computed by sizeof. */ #undef SIZEOF_CHAR /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* The size of `void*', as computed by sizeof. */ #undef SIZEOF_VOIDP /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if pthreads should be used instead of forked processes. */ #undef USE_PTHREAD /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Version number of package */ #undef VERSION /* define if Avahi support is enabled for saned and the net backend */ #undef WITH_AVAHI /* define if USB record replay is enabled */ #undef WITH_USB_RECORD_REPLAY /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to `int' if does not define. */ #undef pid_t /* Define scsireq_t as \'struct scsireq\' if necessary. */ #undef scsireq_t /* Define to `unsigned int' if does not define. */ #undef size_t /* Define socklen_t as \'int\' if necessary. */ #undef socklen_t /* Define to `int' if does not define. */ #undef ssize_t /* Define for OS/2 only */ #undef strcasecmp /* Define for OS/2 only */ #undef strncasecmp #if defined(__MINGW32__) #define _BSDTYPES_DEFINED #endif #ifndef HAVE_U_CHAR #define u_char unsigned char #endif #ifndef HAVE_U_SHORT #define u_short unsigned short #endif #ifndef HAVE_U_INT #define u_int unsigned int #endif #ifndef HAVE_U_LONG #define u_long unsigned long #endif /* Prototype for getenv */ #ifndef HAVE_GETENV #define getenv sanei_getenv char * getenv(const char *name); #endif /* Prototype for inet_ntop */ #ifndef HAVE_INET_NTOP #define inet_ntop sanei_inet_ntop #include const char * inet_ntop (int af, const void *src, char *dst, size_t cnt); #endif /* Prototype for inet_pton */ #ifndef HAVE_INET_PTON #define inet_pton sanei_inet_pton int inet_pton (int af, const char *src, void *dst); #endif /* Prototype for sigprocmask */ #ifndef HAVE_SIGPROCMASK #define sigprocmask sanei_sigprocmask int sigprocmask (int how, int *new, int *old); #endif /* Prototype for snprintf */ #ifndef HAVE_SNPRINTF #define snprintf sanei_snprintf #include int snprintf (char *str,size_t count,const char *fmt,...); #endif /* Prototype for strcasestr */ #ifndef HAVE_STRCASESTR #define strcasestr sanei_strcasestr char * strcasestr (const char *phaystack, const char *pneedle); #endif /* Prototype for strdup */ #ifndef HAVE_STRDUP #define strdup sanei_strdup char *strdup (const char * s); #endif /* Prototype for strndup */ #ifndef HAVE_STRNDUP #define strndup sanei_strndup #include char *strndup(const char * s, size_t n); #endif /* Prototype for strsep */ #ifndef HAVE_STRSEP #define strsep sanei_strsep char *strsep(char **stringp, const char *delim); #endif /* Prototype for usleep */ #ifndef HAVE_USLEEP #define usleep sanei_usleep unsigned int usleep (unsigned int useconds); #endif /* Prototype for vsyslog */ #ifndef HAVE_VSYSLOG #include void vsyslog(int priority, const char *format, va_list args); #endif sane-backends-1.0.29/include/sane/sanei_codec_ascii.h0000666000000000000000000000467713615534521017345 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996 David Mosberger-Tang and Andreas Beck This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_codec_ascii.h * ASCII codec for network and file transmissions * * Instead translating data to a byte stream this codec uses ASCII hex numbers. * Therefore it can be used for streams that are not 8-bit clean or which can * only use printable characters. It's currently used for saving/restoring * data to/from disk. * * @sa sanei_codec_bin.h sanei_net.h sanei_wire.h */ #ifndef sanei_codec_ascii_h #define sanei_codec_ascii_h /** Initialize the ascii codec * * Set the i/o functions of the Wire to those of the ASCII codec. * * @param w Wire */ extern void sanei_codec_ascii_init (Wire *w); #endif /* sanei_codec_ascii_h */ sane-backends-1.0.29/include/sane/sanei_pv8630.h0000666000000000000000000000665713615534521016066 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000 Adrian Perez Jorge Copyright (C) 2001 Frank Zago Copyright (C) 2001 Marcio Teixeira 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Interface files for the PowerVision 8630 chip, a USB to parallel converter used in many scanners. */ #ifndef sanei_pv8630_h #define sanei_pv8630_h #include "../include/sane/config.h" #include "../include/sane/sane.h" typedef enum { PV8630_REQ_READBYTE = 0x00, PV8630_REQ_WRITEBYTE = 0x01, PV8630_REQ_EPPBULKREAD = 0x02, PV8630_REQ_EPPBULKWRITE = 0x03, PV8630_REQ_FLUSHBUFFER = 0x04, PV8630_REQ_ENABLEINTERRUPT = 0x05, PV8630_REQ_DISABLEINTERRUPT = 0x06, PV8630_REQ_READWORD = 0x08, PV8630_REQ_WRITEWORD = 0x09 } SANEI_PV_Request; typedef enum { PV8630_RDATA = 0x00, PV8630_REPPADDRESS = 0x01, PV8630_UNKNOWN = 0x02, PV8630_RMODE = 0x03, PV8630_RSTATUS = 0x04 } SANEI_PV_Index; extern void sanei_pv8630_init (void); extern SANE_Status sanei_pv8630_write_byte (int fd, SANEI_PV_Index index, SANE_Byte byte); extern SANE_Status sanei_pv8630_read_byte (int fd, SANEI_PV_Index index, SANE_Byte * byte); extern SANE_Status sanei_pv8630_prep_bulkread (int fd, int len); extern SANE_Status sanei_pv8630_prep_bulkwrite (int fd, int len); extern SANE_Status sanei_pv8630_flush_buffer (int fd); extern SANE_Status sanei_pv8630_bulkwrite (int fd, const void *data, size_t * len); extern SANE_Status sanei_pv8630_bulkread (int fd, void *data, size_t * len); extern SANE_Status sanei_pv8630_xpect_byte (int fd, SANEI_PV_Index index, SANE_Byte value, SANE_Byte mask); extern SANE_Status sanei_pv8630_wait_byte (int fd, SANEI_PV_Index index, SANE_Byte value, SANE_Byte mask, int timeout); #endif /* sanei_pv8630_h */ sane-backends-1.0.29/include/sane/sanei_scsi.h0000666000000000000000000003041513615534521016046 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996, 1997 David Mosberger-Tang This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_scsi.h * Generic interface to SCSI drivers. * @sa sanei_usb.h, sanei_ab306.h,sanei_lm983x.h, sanei_pa4s2.h, sanei_pio.h, * and man sane-scsi(5) for user-oriented documentation */ #ifndef sanei_scsi_h #define sanei_scsi_h #include #include #include /** Sense handler * * The sense handler can be implemented in backends. It's for deciding * which sense codes should be considered an error and which shouldn't. * * @param fd file descriptor * @param sense_buffer pointer to buffer containing sense codes * @param arg pointer to data buffer * * @return * - SANE_STATUS_GOOD - on success (sense isn't regarded as error) * - any other status if sense code is regarded as error */ typedef SANE_Status (*SANEI_SCSI_Sense_Handler) (int fd, u_char *sense_buffer, void *arg); /** Maximum size of a SCSI request */ extern int sanei_scsi_max_request_size; /** Find SCSI devices. * * Find each SCSI device that matches the pattern specified by the * arguments. String arguments can be "omitted" by passing NULL, * integer arguments can be "omitted" by passing -1. * * Example: vendor="HP" model=NULL, type=NULL, bus=3, id=-1, lun=-1 would * attach all HP devices on SCSI bus 3. * * @param vendor * @param model * @param type * @param bus * @param channel * @param id * @param lun * @param attach callback invoked once for each device, dev is the real devicename (passed to attach callback) * */ extern void sanei_scsi_find_devices (const char *vendor, const char *model, const char *type, int bus, int channel, int id, int lun, SANE_Status (*attach) (const char *dev)); /** Open a SCSI device * * Opens a SCSI device by its device filename and returns a file descriptor. * If it's necessary to adjust the SCSI buffer size, use * sanei_scsi_open_extended(). * * @param device_name name of the devicefile, e.g. "/dev/sg0" * @param fd file descriptor * @param sense_handler called whenever the SCSI driver returns a sense buffer * @param sense_arg pointer to data for the sense handler * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_ACCESS_DENIED - if the file couldn't be accessed due to * permissions * - SANE_STATUS_NO_MEM - if malloc failed (not enough memory) * - SANE_STATUS_INVAL - if the filename was invalid or an unknown error occured * * @sa sanei_scsi_open_extended(), HAVE_SANEI_SCSI_OPEN_EXTENDED */ extern SANE_Status sanei_scsi_open (const char * device_name, int * fd, SANEI_SCSI_Sense_Handler sense_handler, void *sense_arg); /** Open a SCSI device and set the buffer size * * The extended open call allows a backend to ask for a specific buffer * size. sanei_scsi_open_extended() tries to allocate a buffer of the size * given by *buffersize upon entry to this function. If * sanei_scsi_open_extended returns successfully, *buffersize contains the * available buffer size. This value may be both smaller or larger than the * value requested by the backend; it can even be zero. The backend must * decide, if it got enough buffer memory to work. * * Note that the value of *buffersize may differ for different files. * * @param device_name name of the devicefile, e.g. "/dev/sg0" * @param fd file descriptor * @param sense_handler called whenever the SCSI driver returns a sense buffer * @param sense_arg pointer to data for the sense handler * @param buffersize size of the SCAI request buffer (in bytes) * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_ACCESS_DENIED - if the file couldn't be accessed due to * permissions * - SANE_STATUS_NO_MEM - if malloc failed (not enough memory) * - SANE_STATUS_INVAL - if the filename was invalid or an unknown error occured * * @sa sanei_scsi_open(), HAVE_SANEI_SCSI_OPEN_EXTENDED */ extern SANE_Status sanei_scsi_open_extended ( const char * device_name, int * fd, SANEI_SCSI_Sense_Handler sense_handler, void *sense_arg, int *buffersize); /** Do we have sanei_scsi_open_extended()? * * Let backends decide, which open call to use: if * HAVE_SANEI_SCSI_OPEN_EXTENDED is defined, sanei_scsi_open_extended may be * used. May also be used to decide, if sanei_scsi_req_flush_all or * sanei_scsi_req_flush_all_extended() should be used. * * @sa sanei_scsi_open(), sanei_scsi_open_extended() */ #define HAVE_SANEI_SCSI_OPEN_EXTENDED /** Enqueue SCSI command * * One or more scsi commands can be enqueued by calling sanei_scsi_req_enter(). * * NOTE: Some systems may not support multiple outstanding commands. On such * systems, sanei_scsi_req_enter() may block. In other words, it is not proper * to assume that enter() is a non-blocking routine. * * @param fd file descriptor * @param src pointer to the SCSI command and associated write data (if any) * @param src_size length of the command and data * @param dst pointer to a buffer in which data is returned; NULL if no data is * returned * @param dst_size on input, the size of the buffer pointed to by dst, on exit, * set to the number of bytes returned in the buffer (which is less than or equal * to the buffer size; may be NULL if no data is expected * @param idp pointer to a void* that uniquely identifies the entered request * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - if an error was received from the SCSI driver * - SANE_STATUS_NO_MEM - if malloc failed (not enough memory) * - SANE_STATUS_INVAL - if a locking or an unknown error occured * @sa sanei_scsi_req_enter2() * */ extern SANE_Status sanei_scsi_req_enter (int fd, const void * src, size_t src_size, void * dst, size_t * dst_size, void **idp); /** Enqueue SCSI command and separated data * * Same as sanei_scsi_req_enter(), but with separate buffers for the SCSI * command and for the data to be sent to the device. * * With sanei_scsi_req_enter(), the length of te SCSI command block must be * guessed. While that works in most cases, Canon scanners for example use the * vendor specific commands 0xd4, 0xd5 and 0xd6. The Canon scanners want to * get 6 byte command blocks for these commands, but sanei_scsi_req_enter() and * sanei_scsi_cmd() send 12 bytes. * * If dst_size and *dst_size are non-zero, a "read command" (ie, data transfer * from the device to the host) is assumed. * * @param fd file descriptor * @param cmd pointer to SCSI command * @param cmd_size size of the command * @param src pointer to the buffer with data to be sent to the scanner * @param src_size size of src buffer * @param dst pointer to a buffer in which data is returned; NULL if no data is * returned * @param dst_size on input, the size of the buffer pointed to by dst, on exit, * set to the number of bytes returned in the buffer (which is less than or equal * to the buffer size; may be NULL if no data is expected * @param idp pointer to a void* that uniquely identifies the entered request * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - if an error was received from the SCSI driver * - SANE_STATUS_NO_MEM - if malloc failed (not enough memory) * - SANE_STATUS_INVAL - if a locking or an unknown error occured * @sa sanei_scsi_req_enter() */ extern SANE_Status sanei_scsi_req_enter2 (int fd, const void * cmd, size_t cmd_size, const void * src, size_t src_size, void * dst, size_t * dst_size, void **idp); /** Wait for SCSI command * * Wait for the completion of the SCSI command with id ID. * * @param id id used in sanei_scsi_req_enter() * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_DEVICE_BUSY - if the device is busy (try again later) * - SANE_STATUS_IO_ERROR - if an error was received from the SCSI driver */ extern SANE_Status sanei_scsi_req_wait (void *id); /** Send SCSI command * * This is a convenience function that is equivalent to a pair of * sanei_scsi_req_enter()/sanei_scsi_req_wait() calls. * * @param fd file descriptor * @param src pointer to the SCSI command and associated write data (if any) * @param src_size length of the command and data * @param dst pointer to a buffer in which data is returned; NULL if no data is * returned * @param dst_size on input, the size of the buffer pointed to by dst, on exit, * set to the number of bytes returned in the buffer (which is less than or equal * to the buffer size; may be NULL if no data is expected * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - if an error was received from the SCSI driver * - SANE_STATUS_NO_MEM - if malloc failed (not enough memory) * - SANE_STATUS_INVAL - if a locking or an unknown error occured * * @sa sanei_scsi_cmd2(), sanei_scsi_req_enter(), sanei_scsi_req_wait() */ extern SANE_Status sanei_scsi_cmd (int fd, const void * src, size_t src_size, void * dst, size_t * dst_size); /** Send SCSI command and separated data * * This is a convenience function that is equivalent to a pair of * sanei_scsi_req_enter2()/sanei_scsi_req_wait() calls. * * @param fd file descriptor * @param cmd pointer to SCSI command * @param cmd_size size of the command * @param src pointer to the buffer with data to be sent to the scanner * @param src_size size of src buffer * @param dst pointer to a buffer in which data is returned; NULL if no data is * returned * @param dst_size on input, the size of the buffer pointed to by dst, on exit, * set to the number of bytes returned in the buffer (which is less than or equal * to the buffer size; may be NULL if no data is expected * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - if an error was received from the SCSI driver * - SANE_STATUS_NO_MEM - if malloc failed (not enough memory) * - SANE_STATUS_INVAL - if a locking or an unknown error occured * * @sa sanei_scsi_cmd(), sanei_scsi_req_enter(), sanei_scsi_req_wait() */ extern SANE_Status sanei_scsi_cmd2 (int fd, const void * cmd, size_t cmd_size, const void * src, size_t src_size, void * dst, size_t * dst_size); /** Flush queue * * Flush all pending SCSI commands. This function work only, if zero or one * SCSI file handles are open. * * @sa sanei_scsi_req_flush_all_extended() */ extern void sanei_scsi_req_flush_all (void); /** Flush queue for handle * * Flush all SCSI commands pending for one handle * * @param fd file descriptor * * @sa sanei_scsi_req_flush_all() */ extern void sanei_scsi_req_flush_all_extended (int fd); /** Close a SCSI device * * @param fd file descriptor * */ extern void sanei_scsi_close (int fd); #endif /* sanei_scsi_h */ sane-backends-1.0.29/include/sane/sanei_auth.h0000666000000000000000000000677713615534521016064 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000 Jochen Eisinger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_auth.h * Interface for authorization of resources * * This file implements an interface for user authorization. The authorization * call is forwarded to the frontend which asks for a username and password. * An MD5 digest is used if supported by the frontend. * * @sa sanei.h sanei_backend.h */ #ifndef sanei_auth_h #define sanei_auth_h #include "../include/sane/sane.h" /** Check authorization for a resource * * This function looks for the file SANE_CONFIG_DIR/backend.users. * If this file doesn't exist, sanei_authorize always returns SANE_STATUS_GOOD. * The file backend.users contains a list of usernames, passwords, and * resources: * * username:password:resource * username:password:resource * * If the requested resource isn't listed in this file, sanei_authorize * return SANE_SATUS_GOOD. In all other cases, sanei_authorize sends a * challenge to the frontend of the form * * resource$MD5$randomstring * * where randomstring consists of the PID, the time, and some random * characters. It accepts two forms of answers * * std: username:password * md5: username:$MD5$m5digest * * where md5digest is md5(randomstring password). * * If this username/password/resource triple is listed in backend.users * sanei_authorize returns SANE_STATUS_GOOD, in all other cases it returns * SANE_STATUS_ACCESS_DENIED. * * @param resource resource to authorize * @param backend backend name * @param authorize auth callback * * @return * - SANE_STATUS_GOOD - access is granted * - SANE_STATUS_ACCESS_DENIED - access is denied */ SANE_Status sanei_authorize (const char *resource, const char *backend, SANE_Auth_Callback authorize); #endif /* sanei_auth_h */ sane-backends-1.0.29/include/sane/sanei_udp.h0000666000000000000000000000263213615534521015675 00000000000000/* sane - Scanner Access Now Easy. * Copyright (C) 2007 Tower Technologies * Author: Alessandro Zummo * This file is part of the SANE package. * * This file is in the public domain. You may use and modify it as * you see fit, as long as this copyright message is included and * that there is an indication as to what modifications have been * made (if any). * * SANE is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. * * Header file for UDP/IP communications. */ #ifndef sanei_udp_h #define sanei_udp_h #include #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif extern SANE_Status sanei_udp_open(const char *host, int port, int *fdp); extern SANE_Status sanei_udp_open_broadcast(int *fdp); extern void sanei_udp_close(int fd); extern void sanei_udp_set_nonblock(int fd, SANE_Bool nonblock); extern ssize_t sanei_udp_write(int fd, const u_char * buf, int count); extern ssize_t sanei_udp_read(int fd, u_char * buf, int count); extern ssize_t sanei_udp_write_broadcast(int fd, int port, const u_char * buf, int count); extern ssize_t sanei_udp_recvfrom(int fd, u_char * buf, int count, char **fromp); #endif /* sanei_udp_h */ sane-backends-1.0.29/include/sane/sanei_codec_bin.h0000666000000000000000000000451013615534521017007 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996 David Mosberger-Tang and Andreas Beck This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_codec_bin.h * Binary codec for network transmissions * * Transtale data to a byte stream while taking byte order problems into * account. This codec is currently used for saned and the network backend. * * @sa sanei_codec_ascii.h sanei_net.h sanei_wire.h */ #ifndef sanei_codec_bin_h #define sanei_codec_bin_h /** Initialize the binary codec * * Set the i/o functions of the Wire to those of the binary codec. * * @param w Wire */ extern void sanei_codec_bin_init (Wire *w); #endif /* sanei_codec_bin_h */ sane-backends-1.0.29/include/sane/sanei_wire.h0000666000000000000000000001105013615534521016045 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 David Mosberger-Tang This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Support routines to translate internal datatypes into a wire-format (used for RPCs and to save/restore options). */ #ifndef sanei_wire_h #define sanei_wire_h #include #define MAX_MEM (1024 * 1024) typedef enum { WIRE_ENCODE = 0, WIRE_DECODE, WIRE_FREE } WireDirection; struct Wire; typedef void (*WireCodecFunc) (struct Wire *w, void *val_ptr); typedef ssize_t (*WireReadFunc) (int fd, void * buf, size_t len); typedef ssize_t (*WireWriteFunc) (int fd, const void * buf, size_t len); typedef struct Wire { int version; /* protocol version in use */ WireDirection direction; int status; int allocated_memory; struct { WireCodecFunc w_byte; WireCodecFunc w_char; WireCodecFunc w_word; WireCodecFunc w_string; } codec; struct { size_t size; char *curr; char *start; char *end; } buffer; struct { int fd; WireReadFunc read; WireWriteFunc write; } io; } Wire; extern void sanei_w_init (Wire *w, void (*codec_init)(Wire *)); extern void sanei_w_exit (Wire *w); extern void sanei_w_space (Wire *w, size_t howmuch); extern void sanei_w_void (Wire *w, void *); extern void sanei_w_byte (Wire *w, SANE_Byte *v); extern void sanei_w_char (Wire *w, SANE_Char *v); extern void sanei_w_word (Wire *w, SANE_Word *v); extern void sanei_w_bool (Wire *w, SANE_Bool *v); extern void sanei_w_ptr (Wire *w, void **v, WireCodecFunc w_value, size_t value_size); extern void sanei_w_string (Wire *w, SANE_String *v); extern void sanei_w_status (Wire *w, SANE_Status *v); extern void sanei_w_constraint_type (Wire *w, SANE_Constraint_Type *v); extern void sanei_w_value_type (Wire *w, SANE_Value_Type *v); extern void sanei_w_unit (Wire *w, SANE_Unit *v); extern void sanei_w_action (Wire *w, SANE_Action *v); extern void sanei_w_frame (Wire *w, SANE_Frame *v); extern void sanei_w_range (Wire *w, SANE_Range *v); extern void sanei_w_range_ptr (Wire *w, SANE_Range **v); extern void sanei_w_device (Wire *w, SANE_Device *v); extern void sanei_w_device_ptr (Wire *w, SANE_Device **v); extern void sanei_w_option_descriptor (Wire *w, SANE_Option_Descriptor *v); extern void sanei_w_option_descriptor_ptr (Wire *w, SANE_Option_Descriptor **v); extern void sanei_w_parameters (Wire *w, SANE_Parameters *v); extern void sanei_w_array (Wire *w, SANE_Word *len, void **v, WireCodecFunc w_element, size_t element_size); extern void sanei_w_set_dir (Wire *w, WireDirection dir); extern void sanei_w_call (Wire *w, SANE_Word proc_num, WireCodecFunc w_arg, void *arg, WireCodecFunc w_reply, void *reply); extern void sanei_w_reply (Wire *w, WireCodecFunc w_reply, void *reply); extern void sanei_w_free (Wire *w, WireCodecFunc w_reply, void *reply); #endif /* sanei_wire_h */ sane-backends-1.0.29/include/sane/sanei_jpeg.h0000666000000000000000000000347713615534521016042 00000000000000/* * cdjpeg.h * * Copyright (C) 1994-1996, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file contains common declarations for the sample applications * cjpeg and djpeg. It is NOT used by the core JPEG library. */ #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ #include "sane/sanei_jinclude.h" #include "jpeglib.h" #include "jerror.h" /* get library error codes too */ #include "sane/sanei_cderror.h" /* get application-specific error codes */ /* * Object interface for djpeg's output file encoding modules */ typedef struct djpeg_dest_struct * djpeg_dest_ptr; struct djpeg_dest_struct { /* start_output is called after jpeg_start_decompress finishes. * The color map will be ready at this time, if one is needed. */ JMETHOD(void, start_output, (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)); /* Emit the specified number of pixel rows from the buffer. */ JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied, char *data)); /* Finish up at the end of the image. */ JMETHOD(void, finish_output, (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)); /* Target file spec; filled in by djpeg.c after object is created. */ FILE * output_file; /* Output pixel-row buffer. Created by module init or start_output. * Width is cinfo->output_width * cinfo->output_components; * height is buffer_height. */ JSAMPARRAY buffer; JDIMENSION buffer_height; }; /* Module selection routines for I/O modules. */ EXTERN(djpeg_dest_ptr) sanei_jpeg_jinit_write_ppm JPP((j_decompress_ptr cinfo)); /* miscellaneous useful macros */ sane-backends-1.0.29/include/sane/sanei_pa4s2.h0000666000000000000000000001531413615534521016037 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000-2003 Jochen Eisinger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_pa4s2.h * This file implements an interface for the Mustek PP chipset A4S2 * * @sa sanei_usb.h, sanei_ab306.h, sanei_lm983x.h, sanei_scsi.h, sanei_pio.h */ #ifndef sanei_pa4s2_h #define sanei_pa4s2_h #include #include /** @name Options to control interface operations */ /* @{ */ #define SANEI_PA4S2_OPT_DEFAULT 0 /* normal mode */ #define SANEI_PA4S2_OPT_TRY_MODE_UNI 1 /* enable UNI protocoll */ #define SANEI_PA4S2_OPT_ALT_LOCK 2 /* use alternative lock cmd */ #define SANEI_PA4S2_OPT_NO_EPP 4 /* do not try to use EPP */ /* @} */ /** Get list of possibly available devices * * Returns a list of arguments accepted as *dev by sanei_pa4s2_open * * @return * - array of known *devs. The last entry is marked as NULL pointer. The * user has to make sure, the array, but not the entries are freed. * * @sa sanei_pa4s2_open * */ extern const char ** sanei_pa4s2_devices(void); /** Open pa4s2 device * * Opens *dev as pa4s2 device. * * @param dev IO port address ("0x378", "0x278", or "0x3BC") * @param fd file descriptor * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if no scanner was found or the port number was wrong * - SANE_STATUS_DEVICE_BUSY - if the device is already in use * - SANE_STATUS_IO_ERROR - if the port couldn't be accessed * */ extern SANE_Status sanei_pa4s2_open (const char *dev, int *fd); /** Open pa4s2 SCSI-over-parallel device * * Opens *dev as pa4s2 SCSI-over-parallel device. * * @param dev IO port address ("0x378", "0x278", or "0x3BC") * @param fd file descriptor * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if no scanner was found or the port number was wrong * - SANE_STATUS_DEVICE_BUSY - if the device is already in use * - SANE_STATUS_IO_ERROR - if the port couldn't be accessed * */ extern SANE_Status sanei_pa4s2_scsi_pp_open (const char *dev, int *fd); /** Close pa4s2 device * * @param fd file descriptor */ extern void sanei_pa4s2_close (int fd); /** Set/get options * * Sets/gets interface options. Options will be taken over, when set is * SANE_TRUE. These options should be set before the first device is opened * * @param options pointer to options * @param set set (SANE_TRUE) or get (SANE_FALSE) options * * @return * - SANE_STATUS_GOOD - on success */ extern SANE_Status sanei_pa4s2_options (u_int * options, int set); /** Enables/disable device * * When the device is disabled, the printer can be accessed, when it's enabled * data can be read/written. * * @param fd file descriptor * @param enable enable (SANE_TRUE) or disable (SANE_FALSE) device * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if fd is invalid or device not in use */ extern SANE_Status sanei_pa4s2_enable (int fd, int enable); /** Select a register * * The function to read a register is split up in three parts, so a register * can be read more than once. * * @param fd file descriptor * @param reg register * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if fd is invalid or device not in use * * @sa sanei_pa4s2_readbyte(), sanei_pa4s2_readend() */ extern SANE_Status sanei_pa4s2_readbegin (int fd, u_char reg); /** Return port status information * * @param fd file descriptor * @param status variable to receive status * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if fd is invalid or device not in use */ extern SANE_Status sanei_pa4s2_scsi_pp_get_status (int fd, u_char *status); /** Selects a register number on a SCSI-over-parallel scanner * * @param fd file descriptor * @param reg register number * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if fd is invalid */ extern SANE_Status sanei_pa4s2_scsi_pp_reg_select (int fd, int reg); /** Read a register * * The function to read a register is split up in three parts, so a register * can be read more than once. * * @param fd file descriptor * @param val pointer to value * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if fd is invalid or device not in use * * @sa sanei_pa4s2_readbegin(), sanei_pa4s2_readend() */ extern SANE_Status sanei_pa4s2_readbyte (int fd, u_char * val); /** Terminate reading sequence * * The function to read a register is split up in three parts, so a register * can be read more than once. * * @param fd file descriptor * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if fd is invalid or device not in use * @sa sanei_pa4s2_readbegin(), sanei_pa4s2_readbyte() */ extern SANE_Status sanei_pa4s2_readend (int fd); /** Write a register * * @param fd file descriptor * @param reg register * @param val value to be written * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_INVAL - if fd is invalid or device not in use */ extern SANE_Status sanei_pa4s2_writebyte (int fd, u_char reg, u_char val); #endif sane-backends-1.0.29/include/sane/sanei_usb.h0000666000000000000000000004430013615534521015674 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001, 2002 Henning Meier-Geinitz Copyright (C) 2003, 2005 Rene Rebe (sanei_read_int,sanei_set_timeout) Copyright (C) 2008 m. allan noah (sanei_usb_clear_halt) Copyright (C) 2011 Reinhold Kainhofer (sanei_usb_set_endpoint) This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_usb.h * This file provides a generic USB interface. * * Currently, two access methods to USB devices are provided: * - Access to device * files as used by the Linux kernel USB scanner driver is supported. FreeBSD * and OpenBSD with their uscanner drivers also work this way. However, * detection and control messages aren't supported on these platforms. * - Access using libusb (where available). * * A general remark: Do not mix sanei_usb functions with "normal" file-related * libc functions like open() or close. The device numbers used in sanei_usb * are not file descriptors. * * @sa sanei_lm983x.h, sanei_pa4s2.h, sanei_pio.h, sanei_scsi.h, and man sane-usb(5) * for user-oriented documentation */ #ifndef sanei_usb_h #define sanei_usb_h #include "../include/sane/config.h" #include "../include/sane/sane.h" #include /* for size_t */ #ifdef __cplusplus extern "C" { #endif /* USB spec defines */ #ifndef USB_CLASS_PER_INTERFACE /* Also defined in libusb */ /** @name Device and/or interface class codes */ /* @{ */ #define USB_CLASS_PER_INTERFACE 0x00 #define USB_CLASS_AUDIO 0x01 #define USB_CLASS_COMM 0x02 #define USB_CLASS_HID 0x03 #define USB_CLASS_PRINTER 0x07 #define USB_CLASS_MASS_STORAGE 0x08 #define USB_CLASS_HUB 0x09 #define USB_CLASS_DATA 0x0a #define USB_CLASS_VENDOR_SPEC 0xff /* @} */ /** @name USB descriptor types */ /* @{ */ #define USB_DT_DEVICE 0x01 #define USB_DT_CONFIG 0x02 #define USB_DT_STRING 0x03 #define USB_DT_INTERFACE 0x04 #define USB_DT_ENDPOINT 0x05 #define USB_DT_HID 0x21 #define USB_DT_REPORT 0x22 #define USB_DT_PHYSICAL 0x23 #define USB_DT_HUB 0x29 /* @} */ /** @name Descriptor sizes per descriptor type */ /* @{ */ #define USB_DT_DEVICE_SIZE 18 #define USB_DT_CONFIG_SIZE 9 #define USB_DT_INTERFACE_SIZE 9 #define USB_DT_ENDPOINT_SIZE 7 #define USB_DT_ENDPOINT_AUDIO_SIZE 9 #define USB_DT_HUB_NONVAR_SIZE 7 /* @} */ /** @name Endpoint descriptors */ /* @{ */ #define USB_ENDPOINT_ADDRESS_MASK 0x0f #define USB_ENDPOINT_DIR_MASK 0x80 #define USB_ENDPOINT_TYPE_MASK 0x03 #define USB_ENDPOINT_TYPE_CONTROL 0 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 1 #define USB_ENDPOINT_TYPE_BULK 2 #define USB_ENDPOINT_TYPE_INTERRUPT 3 /* @} */ /** @name Standard requests */ /* @{ */ #define USB_REQ_GET_STATUS 0x00 #define USB_REQ_CLEAR_FEATURE 0x01 #define USB_REQ_SET_FEATURE 0x03 #define USB_REQ_SET_ADDRESS 0x05 #define USB_REQ_GET_DESCRIPTOR 0x06 #define USB_REQ_SET_DESCRIPTOR 0x07 #define USB_REQ_GET_CONFIGURATION 0x08 #define USB_REQ_SET_CONFIGURATION 0x09 #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME 0x0C /* @} */ /** @name USB types */ /* @{ */ #define USB_TYPE_STANDARD (0x00 << 5) #define USB_TYPE_CLASS (0x01 << 5) #define USB_TYPE_VENDOR (0x02 << 5) #define USB_TYPE_RESERVED (0x03 << 5) /* @} */ /** @name USB recipients */ /* @{ */ #define USB_RECIP_DEVICE 0x00 #define USB_RECIP_INTERFACE 0x01 #define USB_RECIP_ENDPOINT 0x02 #define USB_RECIP_OTHER 0x03 /* @} */ #endif /* not USB_CLASS_PER_INTERFACE */ /* Not defined in libsub */ /** @name USB Masks */ /* @{ */ #define USB_TYPE_MASK (0x03 << 5) #define USB_RECIP_MASK 0x1f /* @} */ /** @name USB directions */ /* @{ */ #define USB_DIR_OUT 0x00 #define USB_DIR_IN 0x80 /* @} */ /** */ struct sanei_usb_dev_descriptor { SANE_Byte desc_type; unsigned int bcd_usb; unsigned int bcd_dev; SANE_Byte dev_class; SANE_Byte dev_sub_class; SANE_Byte dev_protocol; SANE_Byte max_packet_size; }; /** Initialize sanei_usb for replay testing. Initializes sanei_usb for testing by mocking whole USB stack. This function must be called before sanei_usb_init(). The sanei_usb subsystem also implements a "development mode". It modifies the XML data file with the actual commands of the test run and attemps to proceed testing until a mismatching input command is found for which input data is required. A node in the data XML file will cause sanei_usb not to continue to the subsequent command in the XML file and instead it will prepend all output commands before that node before an output command is encountered. @param path Path to the XML data file. @param development_mode Enables development mode. */ extern SANE_Status sanei_usb_testing_enable_replay(SANE_String_Const path, int development_mode); /** Initialize sanei_usb for recording. * * Initializes sanei_usb for recording communication with the scanner. This * function must be called before sanei_usb_init(). * * @param path Path to the XML data file. * @param be_name The name of the backend to enable recording for. */ extern SANE_Status sanei_usb_testing_enable_record(SANE_String_Const path, SANE_String_Const be_name); /** Returns backend name for testing. * * Returns backend name for the file registered in sanei_usb_testing_enable. * The caller is responsible for freeing it. */ extern SANE_String sanei_usb_testing_get_backend(); /** Returns SANE_TRUE if replay testing mode is enabled, i.e. whether we are working with fake * scan data. */ extern SANE_Bool sanei_usb_is_replay_mode_enabled(); /** Records a debug message in the captured USB data if testing mode is enabled. If testing mode * is not enabled, this function does nothing. * * @param msg Message to record */ extern void sanei_usb_testing_record_message(SANE_String_Const message); /** Initialize sanei_usb. * * Call this before any other sanei_usb function. */ extern void sanei_usb_init (void); /** End sanei_usb use, freeing resources when needed. * * When the use count of sanei_usb reach 0, free resources and end * sanei_usb use. */ extern void sanei_usb_exit (void); /** Search for USB devices. * * Search USB busses for scanner devices. */ extern void sanei_usb_scan_devices (void); /** Get the vendor and product ids by device name. * * @param devname * @param vendor vendor id * @param product product id * * @return * - SANE_STATUS_GOOD - if the ids could be determined * - SANE_STATUS_INVAL - if the device is not found * - SANE_STATUS_UNSUPPORTED - if this method is not supported with the current * access method */ SANE_Status sanei_usb_get_vendor_product_byname (SANE_String_Const devname, SANE_Word * vendor, SANE_Word * product); /** Get the vendor and product ids. * * Currently, only libusb devices and scanners supported by the Linux USB * scanner module can be found. For the latter method, the Linux version * must be 2.4.8 or higher. * * @param dn device number of an already sanei_usb_opened device * @param vendor vendor id * @param product product id * * @return * - SANE_STATUS_GOOD - if the ids could be determined * - SANE_STATUS_UNSUPPORTED - if the OS doesn't support detection of ids */ extern SANE_Status sanei_usb_get_vendor_product (SANE_Int dn, SANE_Word * vendor, SANE_Word * product); /** Find devices that match given vendor and product ids. * * For limitations, see function sanei_usb_get_vendor_product(). * The function attach is called for every device which has been found. * * @param vendor vendor id * @param product product id * @param attach attach function * * @return SANE_STATUS_GOOD - on success (even if no scanner was found) */ extern SANE_Status sanei_usb_find_devices (SANE_Int vendor, SANE_Int product, SANE_Status (*attach) (SANE_String_Const devname)); /** Open a USB device. * * The device is opened by its name devname and the device number is * returned in dn on success. * * Device names can be either device file names for direct access over * kernel drivers (like /dev/usb/scanner) or libusb names. The libusb format * looks like this: "libusb:bus-id:device-id". Bus-id and device-id are * platform-dependent. An example could look like this: "libusb:001:002" * (Linux). * * @param devname name of the device to open * @param dn device number * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_ACCESS_DENIED - if the file couldn't be accessed due to * permissions * - SANE_STATUS_INVAL - on every other error */ extern SANE_Status sanei_usb_open (SANE_String_Const devname, SANE_Int * dn); /** Set the endpoint for the USB communication * * Allows to switch to a different endpoint for the USB communication than * the default (auto-detected) endpoint. This function can only be called * after sanei_usb_open. * * @param dn device number * @param ep_type type of endpoint to set (bitwise or of USB_DIR_IN/OUT and * USB_ENDPOINT_TYPE_BULK/CONTROL/INTERRUPT/ISOCHRONOUS * @param ep endpoint to use for the given type * */ extern void sanei_usb_set_endpoint (SANE_Int dn, SANE_Int ep_type, SANE_Int ep); /** Retrieve the endpoint used for the USB communication * * Returns the endpoint used for the USB communication of the given type. * This function can only be called after sanei_usb_open. * * @param dn device number * @param ep_type type of endpoint to retrieve (bitwise or of USB_DIR_IN/OUT * and USB_ENDPOINT_TYPE_BULK/CONTROL/INTERRUPT/ISOCHRONOUS * @return endpoint used for the given type * */ extern SANE_Int sanei_usb_get_endpoint (SANE_Int dn, SANE_Int ep_type); /** Close a USB device. * * @param dn device number */ extern void sanei_usb_close (SANE_Int dn); /** Set the libusb timeout for bulk and interrupt reads. * * @param timeout the new timeout in ms */ extern void sanei_usb_set_timeout (SANE_Int timeout); /** Check if sanei_usb_set_timeout() is available. */ #define HAVE_SANEI_USB_SET_TIMEOUT /** Clear halt condition on bulk endpoints * * @param dn device number */ extern SANE_Status sanei_usb_clear_halt (SANE_Int dn); /** Check if sanei_usb_clear_halt() is available. */ #define HAVE_SANEI_USB_CLEAR_HALT /** Reset device * * @param dn device number */ extern SANE_Status sanei_usb_reset (SANE_Int dn); /** Initiate a bulk transfer read. * * Read up to size bytes from the device to buffer. After the read, size * contains the number of bytes actually read. * * @param dn device number * @param buffer buffer to store read data in * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_usb_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size); /** Initiate a bulk transfer write. * * Write up to size bytes from buffer to the device. After the write size * contains the number of bytes actually written. * * @param dn device number * @param buffer buffer to write to device * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_IO_ERROR - if an error occured during the write * - SANE_STATUS_INVAL - on every other error */ extern SANE_Status sanei_usb_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size); /** Send/receive a control message to/from a USB device. * * This function is only supported for libusb devices and kernel acces with * Linux 2.4.13 and newer. * For a detailed explanation of the parameters, have a look at the USB * specification at the * www.usb.org developers information page. * * @param dn device number * @param rtype specifies the characteristics of the request (e.g. data * direction) * @param req actual request * @param value parameter specific to the request * @param index parameter specific to the request (often used to select * endpoint) * @param len length of data to send/receive * @param data buffer to send/receive data * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - on error * - SANE_STATUS_UNSUPPORTED - if the feature is not supported by the OS or * SANE. */ extern SANE_Status sanei_usb_control_msg (SANE_Int dn, SANE_Int rtype, SANE_Int req, SANE_Int value, SANE_Int index, SANE_Int len, SANE_Byte * data); /** Initiate a interrupt transfer read. * * Read up to size bytes from the interrupt endpoint from the device to * buffer. After the read, size contains the number of bytes actually read. * * @param dn device number * @param buffer buffer to store read data in * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_usb_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size); /** Expand device name patterns into a list of devices. * * Apart from a normal device name (such as /dev/usb/scanner0 or * libusb:002:003), this function currently supports USB device * specifications of the form: * * usb VENDOR PRODUCT * * VENDOR and PRODUCT are non-negative integer numbers in decimal or * hexadecimal format. A similar function for SCSI devices can be found * in include/sane/config.h. * * @param name device name pattern * @param attach attach function * */ extern void sanei_usb_attach_matching_devices (const char *name, SANE_Status (*attach) (const char *dev)); /** Initiate set configuration. * * Change set configuration * * @param dn device number * @param configuration, configuration nummber * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_usb_set_configuration (SANE_Int dn, SANE_Int configuration); /** Initiate claim interface. * * Change claim interface * * @param dn device number * @param interface_number interface number * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_usb_claim_interface (SANE_Int dn, SANE_Int interface_number); /** Initiate release interface. * * Change release interface * * @param dn device number * @param interface_number interface number * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_usb_release_interface (SANE_Int dn, SANE_Int interface_number); /** Initiate a set altinterface. * * Change set alternate * * @param dn device number * @param alternate, alternate nummber * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate); /** Get some information from the device descriptor * * Sometimes it's useful to know something about revisions and * other stuff reported by the USB system * * @param dn device number * @param desc where to put the information to * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_UNSUPPORTED - if the feature is not supported by the OS or * SANE. * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc ); #ifdef __cplusplus } // extern "C" #endif /*------------------------------------------------------*/ #endif /* sanei_usb_h */ sane-backends-1.0.29/include/sane/sanei_ab306.h0000666000000000000000000000452013615534521015716 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Andreas Czechanowski 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef sanei_ab306_h #define sanei_ab306_h #include #include SANE_Status sanei_ab306_open (const char *dev, int *fd); void sanei_ab306_close (int fd); void sanei_ab306_exit (void); SANE_Status sanei_ab306_get_io_privilege (int fd); SANE_Status sanei_ab306_test_ready (int fd); SANE_Status sanei_ab306_cmd (int fd, const void *src, size_t src_size, void *dst, size_t *dst_size); SANE_Status sanei_ab306_rdata (int fd, int planes, SANE_Byte *buf, int lines, int bpl); #endif /* sanei_ab306_h */ sane-backends-1.0.29/include/sane/sanei_jinclude.h0000666000000000000000000000626213615534521016705 00000000000000/* * jinclude.h * * Copyright (C) 1991-1994, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file exists to provide a single place to fix any problems with * including the wrong system include files. (Common problems are taken * care of by the standard jconfig symbols, but on really weird systems * you may have to edit this file.) * * NOTE: this file is NOT intended to be included by applications using the * JPEG library. Most applications need only include jpeglib.h. */ /* Include auto-config file to find out which system include files we need. */ #include "jconfig.h" /* auto configuration options */ #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ /* * We need the NULL macro and size_t typedef. * On an ANSI-conforming system it is sufficient to include . * Otherwise, we get them from or ; we may have to * pull in as well. * Note that the core JPEG library does not require ; * only the default error handler and data source/destination modules do. * But we must pull it in because of the references to FILE in jpeglib.h. * You can remove those references if you want to compile without . */ #ifdef HAVE_STDDEF_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef NEED_SYS_TYPES_H #include #endif #include /* * We need memory copying and zeroing functions, plus strncpy(). * ANSI and System V implementations declare these in . * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). * Some systems may declare memset and memcpy in . * * NOTE: we assume the size parameters to these functions are of type size_t. * Change the casts in these macros if not! */ #ifdef NEED_BSD_STRINGS #include #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) #else /* not BSD, assume ANSI/SysV string lib */ #include #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) #endif /* * In ANSI C, and indeed any rational implementation, size_t is also the * type returned by sizeof(). However, it seems there are some irrational * implementations out there, in which sizeof() returns an int even though * size_t is defined as long or unsigned long. To ensure consistent results * we always use this SIZEOF() macro in place of using sizeof() directly. */ #define SIZEOF(object) ((size_t) sizeof(object)) /* * The modules that use fread() and fwrite() always invoke them through * these macros. On some systems you may need to twiddle the argument casts. * CAUTION: argument order is different from underlying functions! */ #define JFREAD(file,buf,sizeofbuf) \ ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) #define JFWRITE(file,buf,sizeofbuf) \ ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) sane-backends-1.0.29/include/sane/saneopts.h0000666000000000000000000004711013615534521015562 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996, 1997 David Mosberger-Tang and Andreas Beck This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file declares common option names, titles, and descriptions. A backend is not limited to these options but for the sake of consistency it's better to use options declared here when appropriate. */ /* This file defines several option NAMEs, TITLEs and DESCs that are (or should be) used by several backends. All well known options should be listed here. But this does not mean that all options that are listed here are well known options. To find out if an option is a well known option and how well known options have to be defined please take a look at the sane standard!!! */ #ifndef saneopts_h #define saneopts_h #ifndef SANE_I18N #define SANE_I18N(text) text #endif /* This _must_ be the first option (index 0): */ #define SANE_NAME_NUM_OPTIONS "" /* never settable */ /* The common option groups */ #define SANE_NAME_STANDARD "standard" #define SANE_NAME_GEOMETRY "geometry" #define SANE_NAME_ENHANCEMENT "enhancement" #define SANE_NAME_ADVANCED "advanced" #define SANE_NAME_SENSORS "sensors" #define SANE_NAME_PREVIEW "preview" #define SANE_NAME_GRAY_PREVIEW "preview-in-gray" #define SANE_NAME_BIT_DEPTH "depth" #define SANE_NAME_SCAN_MODE "mode" #define SANE_NAME_SCAN_SPEED "speed" #define SANE_NAME_SCAN_SOURCE "source" #define SANE_NAME_BACKTRACK "backtrack" /* Most user-interfaces will let the user specify the scan area as the top-left corner and the width/height of the scan area. The reason the backend interface uses the top-left/bottom-right corner is so that the scan area values can be properly constraint independent of any other option value. */ #define SANE_NAME_SCAN_TL_X "tl-x" #define SANE_NAME_SCAN_TL_Y "tl-y" #define SANE_NAME_SCAN_BR_X "br-x" #define SANE_NAME_SCAN_BR_Y "br-y" #define SANE_NAME_SCAN_RESOLUTION "resolution" #define SANE_NAME_SCAN_X_RESOLUTION "x-resolution" #define SANE_NAME_SCAN_Y_RESOLUTION "y-resolution" #define SANE_NAME_PAGE_WIDTH "page-width" #define SANE_NAME_PAGE_HEIGHT "page-height" #define SANE_NAME_CUSTOM_GAMMA "custom-gamma" #define SANE_NAME_GAMMA_VECTOR "gamma-table" #define SANE_NAME_GAMMA_VECTOR_R "red-gamma-table" #define SANE_NAME_GAMMA_VECTOR_G "green-gamma-table" #define SANE_NAME_GAMMA_VECTOR_B "blue-gamma-table" #define SANE_NAME_BRIGHTNESS "brightness" #define SANE_NAME_CONTRAST "contrast" #define SANE_NAME_GRAIN_SIZE "grain" #define SANE_NAME_HALFTONE "halftoning" #define SANE_NAME_BLACK_LEVEL "black-level" #define SANE_NAME_WHITE_LEVEL "white-level" #define SANE_NAME_WHITE_LEVEL_R "white-level-r" #define SANE_NAME_WHITE_LEVEL_G "white-level-g" #define SANE_NAME_WHITE_LEVEL_B "white-level-b" #define SANE_NAME_SHADOW "shadow" #define SANE_NAME_SHADOW_R "shadow-r" #define SANE_NAME_SHADOW_G "shadow-g" #define SANE_NAME_SHADOW_B "shadow-b" #define SANE_NAME_HIGHLIGHT "highlight" #define SANE_NAME_HIGHLIGHT_R "highlight-r" #define SANE_NAME_HIGHLIGHT_G "highlight-g" #define SANE_NAME_HIGHLIGHT_B "highlight-b" #define SANE_NAME_HUE "hue" #define SANE_NAME_SATURATION "saturation" #define SANE_NAME_FILE "filename" #define SANE_NAME_HALFTONE_DIMENSION "halftone-size" #define SANE_NAME_HALFTONE_PATTERN "halftone-pattern" #define SANE_NAME_RESOLUTION_BIND "resolution-bind" #define SANE_NAME_NEGATIVE "negative" #define SANE_NAME_QUALITY_CAL "quality-cal" #define SANE_NAME_DOR "double-res" #define SANE_NAME_RGB_BIND "rgb-bind" #define SANE_NAME_THRESHOLD "threshold" #define SANE_NAME_ANALOG_GAMMA "analog-gamma" #define SANE_NAME_ANALOG_GAMMA_R "analog-gamma-r" #define SANE_NAME_ANALOG_GAMMA_G "analog-gamma-g" #define SANE_NAME_ANALOG_GAMMA_B "analog-gamma-b" #define SANE_NAME_ANALOG_GAMMA_BIND "analog-gamma-bind" #define SANE_NAME_WARMUP "warmup" #define SANE_NAME_CAL_EXPOS_TIME "cal-exposure-time" #define SANE_NAME_CAL_EXPOS_TIME_R "cal-exposure-time-r" #define SANE_NAME_CAL_EXPOS_TIME_G "cal-exposure-time-g" #define SANE_NAME_CAL_EXPOS_TIME_B "cal-exposure-time-b" #define SANE_NAME_SCAN_EXPOS_TIME "scan-exposure-time" #define SANE_NAME_SCAN_EXPOS_TIME_R "scan-exposure-time-r" #define SANE_NAME_SCAN_EXPOS_TIME_G "scan-exposure-time-g" #define SANE_NAME_SCAN_EXPOS_TIME_B "scan-exposure-time-b" #define SANE_NAME_SELECT_EXPOSURE_TIME "select-exposure-time" #define SANE_NAME_CAL_LAMP_DEN "cal-lamp-density" #define SANE_NAME_SCAN_LAMP_DEN "scan-lamp-density" #define SANE_NAME_SELECT_LAMP_DENSITY "select-lamp-density" #define SANE_NAME_LAMP_OFF_AT_EXIT "lamp-off-at-exit" /* well known options from 'SENSORS' group*/ #define SANE_NAME_SCAN "scan" #define SANE_NAME_EMAIL "email" #define SANE_NAME_FAX "fax" #define SANE_NAME_COPY "copy" #define SANE_NAME_PDF "pdf" #define SANE_NAME_CANCEL "cancel" #define SANE_NAME_PAGE_LOADED "page-loaded" #define SANE_NAME_COVER_OPEN "cover-open" #define SANE_TITLE_NUM_OPTIONS SANE_I18N("Number of options") #define SANE_TITLE_STANDARD SANE_I18N("Standard") #define SANE_TITLE_GEOMETRY SANE_I18N("Geometry") #define SANE_TITLE_ENHANCEMENT SANE_I18N("Enhancement") #define SANE_TITLE_ADVANCED SANE_I18N("Advanced") #define SANE_TITLE_SENSORS SANE_I18N("Sensors") #define SANE_TITLE_PREVIEW SANE_I18N("Preview") #define SANE_TITLE_GRAY_PREVIEW SANE_I18N("Force monochrome preview") #define SANE_TITLE_BIT_DEPTH SANE_I18N("Bit depth") #define SANE_TITLE_SCAN_MODE SANE_I18N("Scan mode") #define SANE_TITLE_SCAN_SPEED SANE_I18N("Scan speed") #define SANE_TITLE_SCAN_SOURCE SANE_I18N("Scan source") #define SANE_TITLE_BACKTRACK SANE_I18N("Force backtracking") #define SANE_TITLE_SCAN_TL_X SANE_I18N("Top-left x") #define SANE_TITLE_SCAN_TL_Y SANE_I18N("Top-left y") #define SANE_TITLE_SCAN_BR_X SANE_I18N("Bottom-right x") #define SANE_TITLE_SCAN_BR_Y SANE_I18N("Bottom-right y") #define SANE_TITLE_SCAN_RESOLUTION SANE_I18N("Scan resolution") #define SANE_TITLE_SCAN_X_RESOLUTION SANE_I18N("X-resolution") #define SANE_TITLE_SCAN_Y_RESOLUTION SANE_I18N("Y-resolution") #define SANE_TITLE_PAGE_WIDTH SANE_I18N("Page width") #define SANE_TITLE_PAGE_HEIGHT SANE_I18N("Page height") #define SANE_TITLE_CUSTOM_GAMMA SANE_I18N("Use custom gamma table") #define SANE_TITLE_GAMMA_VECTOR SANE_I18N("Image intensity") #define SANE_TITLE_GAMMA_VECTOR_R SANE_I18N("Red intensity") #define SANE_TITLE_GAMMA_VECTOR_G SANE_I18N("Green intensity") #define SANE_TITLE_GAMMA_VECTOR_B SANE_I18N("Blue intensity") #define SANE_TITLE_BRIGHTNESS SANE_I18N("Brightness") #define SANE_TITLE_CONTRAST SANE_I18N("Contrast") #define SANE_TITLE_GRAIN_SIZE SANE_I18N("Grain size") #define SANE_TITLE_HALFTONE SANE_I18N("Halftoning") #define SANE_TITLE_BLACK_LEVEL SANE_I18N("Black level") #define SANE_TITLE_WHITE_LEVEL SANE_I18N("White level") #define SANE_TITLE_WHITE_LEVEL_R SANE_I18N("White level for red") #define SANE_TITLE_WHITE_LEVEL_G SANE_I18N("White level for green") #define SANE_TITLE_WHITE_LEVEL_B SANE_I18N("White level for blue") #define SANE_TITLE_SHADOW SANE_I18N("Shadow") #define SANE_TITLE_SHADOW_R SANE_I18N("Shadow for red") #define SANE_TITLE_SHADOW_G SANE_I18N("Shadow for green") #define SANE_TITLE_SHADOW_B SANE_I18N("Shadow for blue") #define SANE_TITLE_HIGHLIGHT SANE_I18N("Highlight") #define SANE_TITLE_HIGHLIGHT_R SANE_I18N("Highlight for red") #define SANE_TITLE_HIGHLIGHT_G SANE_I18N("Highlight for green") #define SANE_TITLE_HIGHLIGHT_B SANE_I18N("Highlight for blue") #define SANE_TITLE_HUE SANE_I18N("Hue") #define SANE_TITLE_SATURATION SANE_I18N("Saturation") #define SANE_TITLE_FILE SANE_I18N("Filename") #define SANE_TITLE_HALFTONE_DIMENSION SANE_I18N("Halftone pattern size") #define SANE_TITLE_HALFTONE_PATTERN SANE_I18N("Halftone pattern") #define SANE_TITLE_RESOLUTION_BIND SANE_I18N("Bind X and Y resolution") #define SANE_TITLE_NEGATIVE SANE_I18N("Negative") #define SANE_TITLE_QUALITY_CAL SANE_I18N("Quality calibration") #define SANE_TITLE_DOR SANE_I18N("Double Optical Resolution") #define SANE_TITLE_RGB_BIND SANE_I18N("Bind RGB") #define SANE_TITLE_THRESHOLD SANE_I18N("Threshold") #define SANE_TITLE_ANALOG_GAMMA SANE_I18N("Analog gamma correction") #define SANE_TITLE_ANALOG_GAMMA_R SANE_I18N("Analog gamma red") #define SANE_TITLE_ANALOG_GAMMA_G SANE_I18N("Analog gamma green") #define SANE_TITLE_ANALOG_GAMMA_B SANE_I18N("Analog gamma blue") #define SANE_TITLE_ANALOG_GAMMA_BIND SANE_I18N("Bind analog gamma") #define SANE_TITLE_WARMUP SANE_I18N("Warmup lamp") #define SANE_TITLE_CAL_EXPOS_TIME SANE_I18N("Cal. exposure-time") #define SANE_TITLE_CAL_EXPOS_TIME_R SANE_I18N("Cal. exposure-time for red") #define SANE_TITLE_CAL_EXPOS_TIME_G SANE_I18N("Cal. exposure-time for " \ "green") #define SANE_TITLE_CAL_EXPOS_TIME_B SANE_I18N("Cal. exposure-time for blue") #define SANE_TITLE_SCAN_EXPOS_TIME SANE_I18N("Scan exposure-time") #define SANE_TITLE_SCAN_EXPOS_TIME_R SANE_I18N("Scan exposure-time for red") #define SANE_TITLE_SCAN_EXPOS_TIME_G SANE_I18N("Scan exposure-time for " \ "green") #define SANE_TITLE_SCAN_EXPOS_TIME_B SANE_I18N("Scan exposure-time for blue") #define SANE_TITLE_SELECT_EXPOSURE_TIME SANE_I18N("Set exposure-time") #define SANE_TITLE_CAL_LAMP_DEN SANE_I18N("Cal. lamp density") #define SANE_TITLE_SCAN_LAMP_DEN SANE_I18N("Scan lamp density") #define SANE_TITLE_SELECT_LAMP_DENSITY SANE_I18N("Set lamp density") #define SANE_TITLE_LAMP_OFF_AT_EXIT SANE_I18N("Lamp off at exit") /* well known options from 'SENSORS' group*/ #define SANE_TITLE_SCAN "Scan button" #define SANE_TITLE_EMAIL "Email button" #define SANE_TITLE_FAX "Fax button" #define SANE_TITLE_COPY "Copy button" #define SANE_TITLE_PDF "PDF button" #define SANE_TITLE_CANCEL "Cancel button" #define SANE_TITLE_PAGE_LOADED "Page loaded" #define SANE_TITLE_COVER_OPEN "Cover open" /* Descriptive/help strings for above options: */ #define SANE_DESC_NUM_OPTIONS \ SANE_I18N("Read-only option that specifies how many options a specific " \ "device supports.") #define SANE_DESC_STANDARD SANE_I18N("Source, mode and resolution options") #define SANE_DESC_GEOMETRY SANE_I18N("Scan area and media size options") #define SANE_DESC_ENHANCEMENT SANE_I18N("Image modification options") #define SANE_DESC_ADVANCED SANE_I18N("Hardware specific options") #define SANE_DESC_SENSORS SANE_I18N("Scanner sensors and buttons") #define SANE_DESC_PREVIEW \ SANE_I18N("Request a preview-quality scan.") #define SANE_DESC_GRAY_PREVIEW \ SANE_I18N("Request that all previews are done in monochrome mode. On a " \ "three-pass scanner this cuts down the number of passes to one and on a " \ "one-pass scanner, it reduces the memory requirements and scan-time of the " \ "preview.") #define SANE_DESC_BIT_DEPTH \ SANE_I18N("Number of bits per sample, typical values are 1 for \"line-art\" " \ "and 8 for multibit scans.") #define SANE_DESC_SCAN_MODE \ SANE_I18N("Selects the scan mode (e.g., lineart, monochrome, or color).") #define SANE_DESC_SCAN_SPEED \ SANE_I18N("Determines the speed at which the scan proceeds.") #define SANE_DESC_SCAN_SOURCE \ SANE_I18N("Selects the scan source (such as a document-feeder).") #define SANE_DESC_BACKTRACK \ SANE_I18N("Controls whether backtracking is forced.") #define SANE_DESC_SCAN_TL_X \ SANE_I18N("Top-left x position of scan area.") #define SANE_DESC_SCAN_TL_Y \ SANE_I18N("Top-left y position of scan area.") #define SANE_DESC_SCAN_BR_X \ SANE_I18N("Bottom-right x position of scan area.") #define SANE_DESC_SCAN_BR_Y \ SANE_I18N("Bottom-right y position of scan area.") #define SANE_DESC_SCAN_RESOLUTION \ SANE_I18N("Sets the resolution of the scanned image.") #define SANE_DESC_SCAN_X_RESOLUTION \ SANE_I18N("Sets the horizontal resolution of the scanned image.") #define SANE_DESC_SCAN_Y_RESOLUTION \ SANE_I18N("Sets the vertical resolution of the scanned image.") #define SANE_DESC_PAGE_WIDTH \ SANE_I18N("Specifies the width of the media. Required for automatic " \ "centering of sheet-fed scans.") #define SANE_DESC_PAGE_HEIGHT \ SANE_I18N("Specifies the height of the media.") #define SANE_DESC_CUSTOM_GAMMA \ SANE_I18N("Determines whether a builtin or a custom gamma-table should be " \ "used.") #define SANE_DESC_GAMMA_VECTOR \ SANE_I18N("Gamma-correction table. In color mode this option equally " \ "affects the red, green, and blue channels simultaneously (i.e., it is an " \ "intensity gamma table).") #define SANE_DESC_GAMMA_VECTOR_R \ SANE_I18N("Gamma-correction table for the red band.") #define SANE_DESC_GAMMA_VECTOR_G \ SANE_I18N("Gamma-correction table for the green band.") #define SANE_DESC_GAMMA_VECTOR_B \ SANE_I18N("Gamma-correction table for the blue band.") #define SANE_DESC_BRIGHTNESS \ SANE_I18N("Controls the brightness of the acquired image.") #define SANE_DESC_CONTRAST \ SANE_I18N("Controls the contrast of the acquired image.") #define SANE_DESC_GRAIN_SIZE \ SANE_I18N("Selects the \"graininess\" of the acquired image. Smaller values " \ "result in sharper images.") #define SANE_DESC_HALFTONE \ SANE_I18N("Selects whether the acquired image should be halftoned (dithered).") #define SANE_DESC_BLACK_LEVEL \ SANE_I18N("Selects what radiance level should be considered \"black\".") #define SANE_DESC_WHITE_LEVEL \ SANE_I18N("Selects what radiance level should be considered \"white\".") #define SANE_DESC_WHITE_LEVEL_R \ SANE_I18N("Selects what red radiance level should be considered \"white\".") #define SANE_DESC_WHITE_LEVEL_G \ SANE_I18N("Selects what green radiance level should be considered \"white\".") #define SANE_DESC_WHITE_LEVEL_B \ SANE_I18N("Selects what blue radiance level should be considered \"white\".") #define SANE_DESC_SHADOW \ SANE_I18N("Selects what radiance level should be considered \"black\".") #define SANE_DESC_SHADOW_R \ SANE_I18N("Selects what red radiance level should be considered \"black\".") #define SANE_DESC_SHADOW_G \ SANE_I18N("Selects what green radiance level should be considered \"black\".") #define SANE_DESC_SHADOW_B \ SANE_I18N("Selects what blue radiance level should be considered \"black\".") #define SANE_DESC_HIGHLIGHT \ SANE_I18N("Selects what radiance level should be considered \"white\".") #define SANE_DESC_HIGHLIGHT_R \ SANE_I18N("Selects what red radiance level should be considered \"full red\".") #define SANE_DESC_HIGHLIGHT_G \ SANE_I18N("Selects what green radiance level should be considered \"full " \ "green\".") #define SANE_DESC_HIGHLIGHT_B \ SANE_I18N("Selects what blue radiance level should be considered \"full " \ "blue\".") #define SANE_DESC_HUE \ SANE_I18N("Controls the \"hue\" (blue-level) of the acquired image.") #define SANE_DESC_SATURATION \ SANE_I18N("The saturation level controls the amount of \"blooming\" that " \ "occurs when acquiring an image with a camera. Larger values cause more " \ "blooming.") #define SANE_DESC_FILE \ SANE_I18N("The filename of the image to be loaded.") #define SANE_DESC_HALFTONE_DIMENSION \ SANE_I18N("Sets the size of the halftoning (dithering) pattern used when " \ "scanning halftoned images.") #define SANE_DESC_HALFTONE_PATTERN \ SANE_I18N("Defines the halftoning (dithering) pattern for scanning " \ "halftoned images.") #define SANE_DESC_RESOLUTION_BIND \ SANE_I18N("Use same values for X and Y resolution") #define SANE_DESC_NEGATIVE \ SANE_I18N("Swap black and white") #define SANE_DESC_QUALITY_CAL \ SANE_I18N("Do a quality white-calibration") #define SANE_DESC_DOR \ SANE_I18N("Use lens that doubles optical resolution") #define SANE_DESC_RGB_BIND \ SANE_I18N("In RGB-mode use same values for each color") #define SANE_DESC_THRESHOLD \ SANE_I18N("Select minimum-brightness to get a white point") #define SANE_DESC_ANALOG_GAMMA \ SANE_I18N("Analog gamma-correction") #define SANE_DESC_ANALOG_GAMMA_R \ SANE_I18N("Analog gamma-correction for red") #define SANE_DESC_ANALOG_GAMMA_G \ SANE_I18N("Analog gamma-correction for green") #define SANE_DESC_ANALOG_GAMMA_B \ SANE_I18N("Analog gamma-correction for blue") #define SANE_DESC_ANALOG_GAMMA_BIND \ SANE_I18N("In RGB-mode use same values for each color") #define SANE_DESC_WARMUP \ SANE_I18N("Warm up lamp before scanning") #define SANE_DESC_CAL_EXPOS_TIME \ SANE_I18N("Define exposure-time for calibration") #define SANE_DESC_CAL_EXPOS_TIME_R \ SANE_I18N("Define exposure-time for red calibration") #define SANE_DESC_CAL_EXPOS_TIME_G \ SANE_I18N("Define exposure-time for green calibration") #define SANE_DESC_CAL_EXPOS_TIME_B \ SANE_I18N("Define exposure-time for blue calibration") #define SANE_DESC_SCAN_EXPOS_TIME \ SANE_I18N("Define exposure-time for scan") #define SANE_DESC_SCAN_EXPOS_TIME_R \ SANE_I18N("Define exposure-time for red scan") #define SANE_DESC_SCAN_EXPOS_TIME_G \ SANE_I18N("Define exposure-time for green scan") #define SANE_DESC_SCAN_EXPOS_TIME_B \ SANE_I18N("Define exposure-time for blue scan") #define SANE_DESC_SELECT_EXPOSURE_TIME \ SANE_I18N("Enable selection of exposure-time") #define SANE_DESC_CAL_LAMP_DEN \ SANE_I18N("Define lamp density for calibration") #define SANE_DESC_SCAN_LAMP_DEN \ SANE_I18N("Define lamp density for scan") #define SANE_DESC_SELECT_LAMP_DENSITY \ SANE_I18N("Enable selection of lamp density") #define SANE_DESC_LAMP_OFF_AT_EXIT \ SANE_I18N("Turn off lamp when program exits") /* well known options from 'SENSORS' group*/ #define SANE_DESC_SCAN SANE_I18N("Scan button") #define SANE_DESC_EMAIL SANE_I18N("Email button") #define SANE_DESC_FAX SANE_I18N("Fax button") #define SANE_DESC_COPY SANE_I18N("Copy button") #define SANE_DESC_PDF SANE_I18N("PDF button") #define SANE_DESC_CANCEL SANE_I18N("Cancel button") #define SANE_DESC_PAGE_LOADED SANE_I18N("Page loaded") #define SANE_DESC_COVER_OPEN SANE_I18N("Cover open") /* Typical values for stringlists (to keep the backends consistent) */ #define SANE_VALUE_SCAN_MODE_COLOR SANE_I18N("Color") #define SANE_VALUE_SCAN_MODE_COLOR_LINEART SANE_I18N("Color Lineart") #define SANE_VALUE_SCAN_MODE_COLOR_HALFTONE SANE_I18N("Color Halftone") #define SANE_VALUE_SCAN_MODE_GRAY SANE_I18N("Gray") #define SANE_VALUE_SCAN_MODE_HALFTONE SANE_I18N("Halftone") #define SANE_VALUE_SCAN_MODE_LINEART SANE_I18N("Lineart") #endif /* saneopts_h */ sane-backends-1.0.29/include/sane/sane.h0000666000000000000000000001736713615534521014667 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997-1999 David Mosberger-Tang and Andreas Beck This file is part of the SANE package. This file is in the public domain. You may use and modify it as you see fit, as long as this copyright message is included and that there is an indication as to what modifications have been made (if any). SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This file declares SANE application interface. See the SANE standard for a detailed explanation of the interface. */ #ifndef sane_h #define sane_h #ifdef __cplusplus extern "C" { #endif /* * SANE types and defines */ #define SANE_CURRENT_MAJOR 1 #define SANE_CURRENT_MINOR 0 #define SANE_VERSION_CODE(major, minor, build) \ ( (((SANE_Word) (major) & 0xff) << 24) \ | (((SANE_Word) (minor) & 0xff) << 16) \ | (((SANE_Word) (build) & 0xffff) << 0)) #define SANE_VERSION_MAJOR(code) ((((SANE_Word)(code)) >> 24) & 0xff) #define SANE_VERSION_MINOR(code) ((((SANE_Word)(code)) >> 16) & 0xff) #define SANE_VERSION_BUILD(code) ((((SANE_Word)(code)) >> 0) & 0xffff) #define SANE_FALSE 0 #define SANE_TRUE 1 typedef unsigned char SANE_Byte; typedef int SANE_Word; typedef SANE_Word SANE_Bool; typedef SANE_Word SANE_Int; typedef char SANE_Char; typedef SANE_Char *SANE_String; typedef const SANE_Char *SANE_String_Const; typedef void *SANE_Handle; typedef SANE_Word SANE_Fixed; #define SANE_FIXED_SCALE_SHIFT 16 #define SANE_FIX(v) ((SANE_Word) ((v) * (1 << SANE_FIXED_SCALE_SHIFT))) #define SANE_UNFIX(v) ((double)(v) / (1 << SANE_FIXED_SCALE_SHIFT)) typedef enum { SANE_STATUS_GOOD = 0, /* everything A-OK */ SANE_STATUS_UNSUPPORTED, /* operation is not supported */ SANE_STATUS_CANCELLED, /* operation was cancelled */ SANE_STATUS_DEVICE_BUSY, /* device is busy; try again later */ SANE_STATUS_INVAL, /* data is invalid (includes no dev at open) */ SANE_STATUS_EOF, /* no more data available (end-of-file) */ SANE_STATUS_JAMMED, /* document feeder jammed */ SANE_STATUS_NO_DOCS, /* document feeder out of documents */ SANE_STATUS_COVER_OPEN, /* scanner cover is open */ SANE_STATUS_IO_ERROR, /* error during device I/O */ SANE_STATUS_NO_MEM, /* out of memory */ SANE_STATUS_ACCESS_DENIED /* access to resource has been denied */ } SANE_Status; /* following are for later sane version, older frontends wont support */ #if 0 #define SANE_STATUS_WARMING_UP 12 /* lamp not ready, please retry */ #define SANE_STATUS_HW_LOCKED 13 /* scanner mechanism locked for transport */ #endif typedef enum { SANE_TYPE_BOOL = 0, SANE_TYPE_INT, SANE_TYPE_FIXED, SANE_TYPE_STRING, SANE_TYPE_BUTTON, SANE_TYPE_GROUP } SANE_Value_Type; typedef enum { SANE_UNIT_NONE = 0, /* the value is unit-less (e.g., # of scans) */ SANE_UNIT_PIXEL, /* value is number of pixels */ SANE_UNIT_BIT, /* value is number of bits */ SANE_UNIT_MM, /* value is millimeters */ SANE_UNIT_DPI, /* value is resolution in dots/inch */ SANE_UNIT_PERCENT, /* value is a percentage */ SANE_UNIT_MICROSECOND /* value is micro seconds */ } SANE_Unit; typedef struct { SANE_String_Const name; /* unique device name */ SANE_String_Const vendor; /* device vendor string */ SANE_String_Const model; /* device model name */ SANE_String_Const type; /* device type (e.g., "flatbed scanner") */ } SANE_Device; #define SANE_CAP_SOFT_SELECT (1 << 0) #define SANE_CAP_HARD_SELECT (1 << 1) #define SANE_CAP_SOFT_DETECT (1 << 2) #define SANE_CAP_EMULATED (1 << 3) #define SANE_CAP_AUTOMATIC (1 << 4) #define SANE_CAP_INACTIVE (1 << 5) #define SANE_CAP_ADVANCED (1 << 6) #define SANE_OPTION_IS_ACTIVE(cap) (((cap) & SANE_CAP_INACTIVE) == 0) #define SANE_OPTION_IS_SETTABLE(cap) (((cap) & SANE_CAP_SOFT_SELECT) != 0) #define SANE_INFO_INEXACT (1 << 0) #define SANE_INFO_RELOAD_OPTIONS (1 << 1) #define SANE_INFO_RELOAD_PARAMS (1 << 2) typedef enum { SANE_CONSTRAINT_NONE = 0, SANE_CONSTRAINT_RANGE, SANE_CONSTRAINT_WORD_LIST, SANE_CONSTRAINT_STRING_LIST } SANE_Constraint_Type; typedef struct { SANE_Word min; /* minimum (element) value */ SANE_Word max; /* maximum (element) value */ SANE_Word quant; /* quantization value (0 if none) */ } SANE_Range; typedef struct { SANE_String_Const name; /* name of this option (command-line name) */ SANE_String_Const title; /* title of this option (single-line) */ SANE_String_Const desc; /* description of this option (multi-line) */ SANE_Value_Type type; /* how are values interpreted? */ SANE_Unit unit; /* what is the (physical) unit? */ SANE_Int size; SANE_Int cap; /* capabilities */ SANE_Constraint_Type constraint_type; union { const SANE_String_Const *string_list; /* NULL-terminated list */ const SANE_Word *word_list; /* first element is list-length */ const SANE_Range *range; } constraint; } SANE_Option_Descriptor; typedef enum { SANE_ACTION_GET_VALUE = 0, SANE_ACTION_SET_VALUE, SANE_ACTION_SET_AUTO } SANE_Action; typedef enum { SANE_FRAME_GRAY, /* band covering human visual range */ SANE_FRAME_RGB, /* pixel-interleaved red/green/blue bands */ SANE_FRAME_RED, /* red band only */ SANE_FRAME_GREEN, /* green band only */ SANE_FRAME_BLUE /* blue band only */ } SANE_Frame; /* push remaining types down to match existing backends */ /* these are to be exposed in a later version of SANE */ /* most front-ends will require updates to understand them */ #if 0 #define SANE_FRAME_TEXT 0x0A /* backend specific textual data */ #define SANE_FRAME_JPEG 0x0B /* complete baseline JPEG file */ #define SANE_FRAME_G31D 0x0C /* CCITT Group 3 1-D Compressed (MH) */ #define SANE_FRAME_G32D 0x0D /* CCITT Group 3 2-D Compressed (MR) */ #define SANE_FRAME_G42D 0x0E /* CCITT Group 4 2-D Compressed (MMR) */ #define SANE_FRAME_IR 0x0F /* bare infrared channel */ #define SANE_FRAME_RGBI 0x10 /* red+green+blue+infrared */ #define SANE_FRAME_GRAYI 0x11 /* gray+infrared */ #define SANE_FRAME_XML 0x12 /* undefined schema */ #endif typedef struct { SANE_Frame format; SANE_Bool last_frame; SANE_Int bytes_per_line; SANE_Int pixels_per_line; SANE_Int lines; SANE_Int depth; } SANE_Parameters; struct SANE_Auth_Data; #define SANE_MAX_USERNAME_LEN 128 #define SANE_MAX_PASSWORD_LEN 128 typedef void (*SANE_Auth_Callback) (SANE_String_Const resource, SANE_Char *username, SANE_Char *password); extern SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize); extern void sane_exit (void); extern SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only); extern SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle); extern void sane_close (SANE_Handle handle); extern const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option); extern SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info); extern SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params); extern SANE_Status sane_start (SANE_Handle handle); extern SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length); extern void sane_cancel (SANE_Handle handle); extern SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking); extern SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd); extern SANE_String_Const sane_strstatus (SANE_Status status); #ifdef __cplusplus } #endif #endif /* sane_h */ sane-backends-1.0.29/include/sane/sanei_lm983x.h0000666000000000000000000001240413615534521016147 00000000000000/* sane - Scanner Access Now Easy. based on sources acquired from Plustek Inc. Copyright (C) 2002-2003 Gerhard Jaeger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_lm983x.h * Interface files for the NS LM9831/2/3 USB chip. * * The National Semiconductor LM9831, LM9832, and LM9833 chips are used in * many USB scanners. Examples include Plustek and Mustek devices. * * @sa sanei_usb.h */ #ifndef sanei_lm983x_h #define sanei_lm983x_h #include "../include/sane/config.h" #include "../include/sane/sane.h" /** * Read one data byte from a specific LM983x register. * * @param fd - device file descriptor (SANE_Int) * @param reg - number of register (SANE_Byte) * @param value - byte value to be written (SANE_Byte *) * * @return The SANE status code for the operation (SANE_Status): * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - system write function failed * - SANE_STATUS_INVAL - register out of range */ #define sanei_lm983x_read_byte(fd, reg, value) \ sanei_lm983x_read (fd, reg, value, 1, 0) /** * Initialize sanei_lm983x. * * Currently, this function only enables the debugging functionality. */ extern void sanei_lm983x_init( void ); /** * Write one data byte to a specific LM983x register. * * @param fd - device file descriptor * @param reg - number of register * @param value - byte value to be written * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - system write function failed * - SANE_STATUS_INVAL - register out of range */ extern SANE_Status sanei_lm983x_write_byte( SANE_Int fd, SANE_Byte reg, SANE_Byte value ); /** * Write one or more data bytes to one or more specific LM983x * registers. * * @param fd - device file descriptor * @param reg - number of start-register * @param buffer - buffer to be written * @param len - number of bytes to be written * @param increment - SANE_TRUE enables the autoincrement of the register * value during the write cycle, SANE_FALSE disables this * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - system read function failed * - SANE_STATUS_INVAL - register out of range or len field was 0 */ extern SANE_Status sanei_lm983x_write( SANE_Int fd, SANE_Byte reg, SANE_Byte *buffer, SANE_Word len, SANE_Bool increment ); /** * Read one or more data bytes from one ore more specific LM983x * registers. * * @param fd - device file descriptor * @param reg - number of start-register * @param buffer - buffer to receive the data * @param len - number of bytes to receive * @param increment - SANE_TRUE enables the autoincrement of the register * value during the read cylce, SANE_FALSE disables this * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_IO_ERROR - system read function failed * - SANE_STATUS_INVAL - register out of range * - SANE_STATUS_EOF - if nothing can't be read */ extern SANE_Status sanei_lm983x_read( SANE_Int fd, SANE_Byte reg, SANE_Byte *buffer, SANE_Word len, SANE_Bool increment ); /** * Reset the LM983x chip. * * @param fd - device file descriptor * @return * - SANE_TRUE - reset successfuly done * - SANE_FALSE - reset failed */ extern SANE_Bool sanei_lm983x_reset( SANE_Int fd ); #endif /* sanei_lm983x_h */ sane-backends-1.0.29/include/sane/sanei_tcp.h0000666000000000000000000000212713615534521015672 00000000000000/* sane - Scanner Access Now Easy. * Copyright (C) 2006 Tower Technologies * Author: Alessandro Zummo * This file is part of the SANE package. * * This file is in the public domain. You may use and modify it as * you see fit, as long as this copyright message is included and * that there is an indication as to what modifications have been * made (if any). * * SANE is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. * * Header file for TCP/IP communications. */ #ifndef sanei_tcp_h #define sanei_tcp_h #include #ifdef HAVE_WINSOCK2_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #include #endif #include extern SANE_Status sanei_tcp_open(const char *host, int port, int *fdp); extern void sanei_tcp_close(int fd); extern ssize_t sanei_tcp_write(int fd, const u_char * buf, int count); extern ssize_t sanei_tcp_read(int fd, u_char * buf, int count); #endif /* sanei_tcp_h */ sane-backends-1.0.29/include/sane/sanei_net.h0000666000000000000000000000641013615534521015671 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997-1999 David Mosberger-Tang and Andreas Beck This file is part of the SANE package. This file is in the public domain. You may use and modify it as you see fit, as long as this copyright message is included and that there is an indication as to what modifications have been made (if any). SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This file declares SANE application interface. See the SANE standard for a detailed explanation of the interface. */ #ifndef sanei_net_h #define sanei_net_h #include #include #define SANEI_NET_PROTOCOL_VERSION 3 typedef enum { SANE_NET_LITTLE_ENDIAN = 0x1234, SANE_NET_BIG_ENDIAN = 0x4321 } SANE_Net_Byte_Order; typedef enum { SANE_NET_INIT = 0, SANE_NET_GET_DEVICES, SANE_NET_OPEN, SANE_NET_CLOSE, SANE_NET_GET_OPTION_DESCRIPTORS, SANE_NET_CONTROL_OPTION, SANE_NET_GET_PARAMETERS, SANE_NET_START, SANE_NET_CANCEL, SANE_NET_AUTHORIZE, SANE_NET_EXIT } SANE_Net_Procedure_Number; typedef struct { SANE_Word version_code; SANE_String username; } SANE_Init_Req; typedef struct { SANE_Status status; SANE_Word version_code; } SANE_Init_Reply; typedef struct { SANE_Status status; SANE_Device **device_list; } SANE_Get_Devices_Reply; typedef struct { SANE_Status status; SANE_Word handle; SANE_String resource_to_authorize; } SANE_Open_Reply; typedef struct { SANE_Word num_options; SANE_Option_Descriptor **desc; } SANE_Option_Descriptor_Array; typedef struct { SANE_Word handle; SANE_Word option; SANE_Word action; SANE_Word value_type; SANE_Word value_size; void *value; } SANE_Control_Option_Req; typedef struct { SANE_Status status; SANE_Word info; SANE_Word value_type; SANE_Word value_size; void *value; SANE_String resource_to_authorize; } SANE_Control_Option_Reply; typedef struct { SANE_Status status; SANE_Parameters params; } SANE_Get_Parameters_Reply; typedef struct { SANE_Status status; SANE_Word port; SANE_Word byte_order; SANE_String resource_to_authorize; } SANE_Start_Reply; typedef struct { SANE_String resource; SANE_String username; SANE_String password; } SANE_Authorization_Req; extern void sanei_w_init_req (Wire *w, SANE_Init_Req *req); extern void sanei_w_init_reply (Wire *w, SANE_Init_Reply *reply); extern void sanei_w_get_devices_reply (Wire *w, SANE_Get_Devices_Reply *reply); extern void sanei_w_open_reply (Wire *w, SANE_Open_Reply *reply); extern void sanei_w_option_descriptor_array (Wire *w, SANE_Option_Descriptor_Array *opt); extern void sanei_w_control_option_req (Wire *w, SANE_Control_Option_Req *req); extern void sanei_w_control_option_reply (Wire *w, SANE_Control_Option_Reply *reply); extern void sanei_w_get_parameters_reply (Wire *w, SANE_Get_Parameters_Reply *reply); extern void sanei_w_start_reply (Wire *w, SANE_Start_Reply *reply); extern void sanei_w_authorization_req (Wire *w, SANE_Authorization_Req *req); #endif /* sanei_net_h */ sane-backends-1.0.29/include/sane/sanei_pio.h0000666000000000000000000000426513615534521015700 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1998 Christian Bucher Copyright (C) 1998 Kling & Hautzinger GmbH 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef sanei_pio_h #define sanei_pio_h #include #include extern SANE_Status sanei_pio_open (const char * dev, int * fd); extern void sanei_pio_close (int fd); extern int sanei_pio_read (int fd, u_char * buf, int n); extern int sanei_pio_write (int fd, const u_char * buf, int n); #endif /* sanei_pio_h */ sane-backends-1.0.29/include/sane/sanei_pp.h0000666000000000000000000001316213615534521015524 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2003 Gerhard Jaeger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_pp.h * This file implements an interface for accessing the parallel-port * * @sa sanei_pp.h */ #ifndef sanei_pp_h #define sanei_pp_h #include #include /** some modes, we'd like to see/use. */ enum sanei_pp_mode { SANEI_PP_MODE_SPP = (1<<1), /**< SPP */ SANEI_PP_MODE_BIDI = (1<<2), /**< BIDI */ SANEI_PP_MODE_EPP = (1<<4), /**< EPP */ SANEI_PP_MODE_ECP = (1<<8) /**< ECP */ }; #define SANEI_PP_DATAIN 1 #define SANEI_PP_DATAOUT 0 /* @{ */ /** Parallelport Control-Register definitions */ #define SANEI_PP_CTRL_STROBE 0x01 #define SANEI_PP_CTRL_AUTOLF 0x02 #define SANEI_PP_CTRL_NOT_INIT 0x04 #define SANEI_PP_CTRL_SELECT_IN 0x08 #define SANEI_PP_CTRL_ENABLE_IRQ 0x10 #define SANEI_PP_CTRL_DIRECTION 0x20 #define SANEI_PP_CTRL_RESERVED 0xc0 /* @} */ /** Initialize sanei_pp. * * This function must be called before any other sanei_pp function. */ extern SANE_Status sanei_pp_init( void ); /** Open a parport device. * * @param dev - name of device to open. * @param fd - pointer to variable that should revceive the handle. * @return */ extern SANE_Status sanei_pp_open( const char *dev, int *fd ); /* Close a previously opened parport device. * * @param fd - handle of the device to close */ extern void sanei_pp_close( int fd ); /** Claim a parport device * * @param fd - handle of the device to claim * @return */ extern SANE_Status sanei_pp_claim( int fd ); /** Release a previously claimed device * * @param fd - handle of the device to release * @return */ extern SANE_Status sanei_pp_release( int fd ); /** Set the data direction * * @param fd - handle of the device, where to change the direction. * @param rev - * @return SANE_STATUS_GOOD on success */ extern SANE_Status sanei_pp_set_datadir( int fd, int rev ); /** Check whether for libieee1284 usage. * * This function can be used to check if the lib uses libieee1284 or * in/out functions directly. * * @return SANE_TRUE if we use direct access, SANE_FALSE if the lib uses * libieee1284 functions. */ extern SANE_Bool sanei_pp_uses_directio( void ); /** Determine the available parallel port modes for a given device. * * @param fd - handle of the device, whose modes shall be checked for. * @param mode - pointer to variable, which should receive the modes. * @return SANE_STATUS_GOOD on success. */ extern SANE_Status sanei_pp_getmodes( int fd, int *mode ); /** Set the operation mode for a given device. * * @param fd - handle of the device, whose modes shall be set. * @param mode - mode to set, see sanei_pp_mode. * @return SANE_STATUS_GOOD on success. */ extern SANE_Status sanei_pp_setmode( int fd, int mode ); /** Write data to ports (spp-data, ctrl, epp-address and epp-data) * * @param fd - handle of device to which shall be written to. * @param val - data to write. * @return SANE_STATUS_GOOD on success. */ extern SANE_Status sanei_pp_outb_data( int fd, SANE_Byte val ); extern SANE_Status sanei_pp_outb_ctrl( int fd, SANE_Byte val ); extern SANE_Status sanei_pp_outb_addr( int fd, SANE_Byte val ); extern SANE_Status sanei_pp_outb_epp ( int fd, SANE_Byte val ); /** Read data from ports (spp-data, status, ctrl and epp-data) * @param fd - handle of device who should be read from. * @return value got from port */ extern SANE_Byte sanei_pp_inb_data( int fd ); extern SANE_Byte sanei_pp_inb_stat( int fd ); extern SANE_Byte sanei_pp_inb_ctrl( int fd ); extern SANE_Byte sanei_pp_inb_epp ( int fd ); /** Delay execution for some micro-seconds. * Please not, that the accuracy highly depends on your system architechture * and the time to delay. It is internally implemented as system calls to * gettimeofday(). * * @param usec - number of micro-seconds to delay */ extern void sanei_pp_udelay( unsigned long usec ); #endif sane-backends-1.0.29/include/sane/sanei_access.h0000666000000000000000000000700713615534521016347 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2005 Gerhard Jaeger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_access.h * Interface file for the sanei_access functions. * * The idea is to provide some simple locking/unlocking mecanism, which * can be used to protect device access from more than one frontend * simultaneously. */ #ifndef sanei_access_h #define sanei_access_h #include "../include/sane/config.h" #include "../include/sane/sane.h" /** Initialize sanei_access. * * This function must be called before any other sanei_access function. * * @param backend - backend name, who uses this lib */ extern void sanei_access_init( const char * backend ); /** Set a lock. * * The function tries to open/create exclusively a lock file in * $PATH_SANE_LOCK_DIR. * If the file could be created successfully, the function fills in the * process ID. * The complete filename of the lockfile is created as follows: * $PATH_SANE_LOCK_DIR/LCK..<devicename> * If the lock could not be set, the function tries it until the timeout * period has been elapsed. * * @param devicename - unique part of the lockfile name * @param timeout - time in seconds to try to set a lock * @return * - SANE_STATUS_GOOD - if the lock has been successfully set * - SANE_STATUS_ACCESS_DENIED - the lock could not set */ extern SANE_Status sanei_access_lock( const char * devicename, SANE_Word timeout ); /** Unlock a previously set lock. * * The function tries to unlock a previously created lock. The lockfile will be * closed and removed. * * @param devicename - part of the lockfile name, use for sanei_acess_lock() * @return * - SANE_STATUS_GOOD - currently the one and only return value */ extern SANE_Status sanei_access_unlock( const char * devicename ); #endif /* sanei_access_h */ sane-backends-1.0.29/include/sane/sanei_thread.h0000666000000000000000000001451213615534521016354 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1998-2001 Yuri Dario Copyright (C) 2002-2003 Henning Meier-Geinitz (documentation) Copyright (C) 2003-2004 Gerhard Jaeger (pthread/process support) This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_thread.h * Support for forking processes and threading. * * Backends should not use fork() directly because fork() does not work * correctly on some platforms. Use the functions provided by sanei_thread * instead. The build system decides if fork() or threads are used. * * Please keep in mind that the behaviour of the child process depends * on if it's a process or thread especially concerning variables. * * In this file we use "task" as an umbrella term for process and thread. * * @sa sanei.h sanei_backend.h */ #ifndef sanei_thread_h #define sanei_thread_h #include "../include/sane/config.h" #ifdef USE_PTHREAD #include typedef pthread_t SANE_Pid; #else typedef int SANE_Pid; #endif /** Initialize sanei_thread. * * This function must be called before any other sanei_thread function. */ extern void sanei_thread_init (void); /** Do we use processes or threads? * * This function can be used to check if processes or threads are used. * * @return * - SANE_TRUE - if processes are used (fork) * - SANE_FALSE - i threads are used */ extern SANE_Bool sanei_thread_is_forked (void); /** Is SANE_Pid valid pid? * * This function can be used to check if thread/fork creation worked * regardless of SANE_Pid's data type. * * @return * - SANE_TRUE - if pid is a valid process * - SANE_FALSE - if pid is not a valid process */ extern SANE_Bool sanei_thread_is_valid (SANE_Pid pid); /** Invalidate a SANE_Pid * * This "function" should be used to invalidate a SANE_Pid in a * portable manner. * * @note * When using pthreads, this only works for those implementations * that opted to make pthread_t an arithmatic type. This is *not* * required by the POSIX threads specification. The choice to do * SANE_Pid invalidation by means of a macro rather than a proper * function circumvents to need to pass a pointer. * If we decide to implement SANE_Pid with a void* in the future, * this can be changed into a proper function without the need to * change existing code. * * For details on the pthread_t type, see in particular Issue 6 of * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html */ #define sanei_thread_invalidate(pid) ((pid) = (SANE_Pid)(-1)) /** Initialize a SANE_Pid * * This "function" should be used to initialize a SANE_Pid in a * portable manner. * * @note * This is at present just an alias of sanei_thread_invalidate. * It seemed misleading to use the latter when intent clearly has * initialization written all over it, hence the alias. */ #define sanei_thread_initialize sanei_thread_invalidate /** Spawn a new task. * * This function should be used to start a new task. * * @param func() function to call as child task * @param args argument of the function (only one!) * * @return * - task id * - -1 if creating the new task failed */ extern SANE_Pid sanei_thread_begin (int (*func) (void *args), void *args); /** Terminate spawned task. * * This function terminates the task that was created with sanei_thread_begin. * * For processes, SIGTERM is sent. If threads are used, pthread_cancel() * terminates the task. * * @param pid - the id of the task * * @return * - 0 on success * - any other value if an error occured while terminating the task */ extern int sanei_thread_kill (SANE_Pid pid); /** Send a signal to a task. * * This function can be used to send a signal to a task. * * For terminating the task, sanei_thread_kill() should be used. * * @param pid - the id of the task * @param sig - the signal to send * * @return * - 0 - on success * - any other value - if an error occured while sending the signal */ extern int sanei_thread_sendsig (SANE_Pid pid, int sig); /** Wait for task termination. * * This function waits until a task that has been terminated by * sanei_thread_kill(), sanei_thread_sendsys() or by any other means * is finished. * * @param pid - the id of the task * @param status - status of the task that has just finished * * @return * - the pid of the task we have been waiting for */ extern SANE_Pid sanei_thread_waitpid (SANE_Pid pid, int *status); /** Check the current status of the spawned task * * * @param pid - the id of the task * * @return * - SANE_STATUS_GOOD - if the task finished without errors * - any other value - if the task finished unexpectantly or hasn't finished yet */ extern SANE_Status sanei_thread_get_status (SANE_Pid pid); #endif /* sanei_thread_h */ sane-backends-1.0.29/include/sane/sanei_cderror.h0000666000000000000000000001217013615534521016543 00000000000000/* * cderror.h * * Copyright (C) 1994, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file defines the error and message codes for the cjpeg/djpeg * applications. These strings are not needed as part of the JPEG library * proper. * Edit this file to add new codes, or to translate the message strings to * some other language. */ /* * To define the enum list of message codes, include this file without * defining macro JMESSAGE. To create a message string table, include it * again with a suitable JMESSAGE definition (see jerror.c for an example). */ #ifndef JMESSAGE #ifndef CDERROR_H #define CDERROR_H /* First time through, define the enum list */ #define JMAKE_ENUM_LIST #else /* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ #define JMESSAGE(code,string) #endif /* CDERROR_H */ #endif /* JMESSAGE */ #ifdef JMAKE_ENUM_LIST typedef enum { #define JMESSAGE(code,string) code , #endif /* JMAKE_ENUM_LIST */ JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ #ifdef BMP_SUPPORTED JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") #endif /* BMP_SUPPORTED */ #ifdef GIF_SUPPORTED JMESSAGE(JERR_GIF_BUG, "GIF output got confused") JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") JMESSAGE(JERR_GIF_NOT, "Not a GIF file") JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") JMESSAGE(JTRC_GIF_BADVERSION, "Warning: unexpected GIF version number '%c%c%c'") JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") #endif /* GIF_SUPPORTED */ #ifdef PPM_SUPPORTED JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") JMESSAGE(JERR_PPM_NOT, "Not a PPM file") JMESSAGE(JTRC_PGM, "%ux%u PGM image") JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") JMESSAGE(JTRC_PPM, "%ux%u PPM image") JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") #endif /* PPM_SUPPORTED */ #ifdef RLE_SUPPORTED JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") JMESSAGE(JERR_RLE_NOT, "Not an RLE file") JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") #endif /* RLE_SUPPORTED */ #ifdef TARGA_SUPPORTED JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") #else JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") #endif /* TARGA_SUPPORTED */ JMESSAGE(JERR_BAD_CMAP_FILE, "Color map file is invalid or of unsupported format") JMESSAGE(JERR_TOO_MANY_COLORS, "Output file format cannot handle %d colormap entries") JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") #ifdef TARGA_SUPPORTED JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format --- perhaps you need -targa") #else JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") #endif JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") #ifdef JMAKE_ENUM_LIST JMSG_LASTADDONCODE } ADDON_MESSAGE_CODE; #undef JMAKE_ENUM_LIST #endif /* JMAKE_ENUM_LIST */ /* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ #undef JMESSAGE sane-backends-1.0.29/include/Makefile.am0000666000000000000000000000160713615534521014664 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2009 Chris Bagwell and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. nobase_include_HEADERS = sane/sane.h sane/saneopts.h EXTRA_DIST = lalloca.h lassert.h lgetopt.h md5.h font_6x11.h EXTRA_DIST += sane/config.h.in sane/sanei.h sane/sanei_ab306.h \ sane/sanei_access.h sane/sanei_auth.h sane/sanei_backend.h \ sane/sanei_cderror.h sane/sanei_codec_ascii.h sane/sanei_codec_bin.h \ sane/sanei_config.h sane/sanei_debug.h sane/sanei_jinclude.h \ sane/sanei_jpeg.h sane/sanei_lm983x.h sane/sanei_net.h sane/sanei_pa4s2.h \ sane/sanei_pio.h sane/sanei_pp.h sane/sanei_pv8630.h sane/sanei_scsi.h \ sane/sanei_tcp.h sane/sanei_thread.h sane/sanei_udp.h sane/sanei_usb.h \ sane/sanei_wire.h sane/sanei_magic.h sane/sanei_ir.h sane-backends-1.0.29/include/lalloca.h0000666000000000000000000000464713615534521014417 00000000000000/* sane - Scanner Access Now Easy. This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Choose suitable implementation of alloca. */ #ifndef lalloca_h #define lalloca_h /* The idea how to do this is from the autoconf documenation */ /* AIX requires this to be the first thing in the file. */ #if defined(__GNUC__) # define alloca __builtin_alloca #else # if HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ /* Remap to internal version name as not to conflict with * other libraries that also add as util to their libraries. */ #define alloca sanei_alloca # if __STDC__ void *alloca (); # else char *alloca (); # endif # endif # endif # endif #endif #endif /* lalloca_h */ sane-backends-1.0.29/include/font_6x11.h0000666000000000000000000020452113615534521014526 00000000000000/**********************************************/ /* */ /* Font file generated by rthelen */ /* */ /**********************************************/ static unsigned char fontdata[] = { /* 0 0x00 '^A' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 1 0x01 '^B' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 2 0x02 '^C' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 3 0x03 '^D' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 4 0x04 '^E' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 5 0x05 '^F' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 6 0x06 '^G' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 7 0x07 '^H' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 8 0x08 '^I' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 9 0x09 '^J' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 10 0x0a '^K' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 11 0x0b '^L' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 12 0x0c '^M' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 13 0x0d '^N' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 14 0x0e '^O' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 15 0x0f '^P' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 16 0x10 '^Q' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 17 0x11 '^R' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x54, /* 0 0 0 00 */ 0x38, /* 00 000 */ 0x54, /* 0 0 0 00 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 18 0x12 '^S' */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x50, /* 0 0 0000 */ 0x50, /* 0 0 0000 */ 0x20, /* 00 00000 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 19 0x13 '^T' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x7c, /* 0 00 */ 0x38, /* 00 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 20 0x14 '^U' */ 0x18, /* 000 000 */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x7c, /* 0 00 */ 0x78, /* 0 000 */ 0x78, /* 0 000 */ 0x7c, /* 0 00 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 21 0x15 '^V' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 22 0x16 '^W' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 23 0x17 '^X' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 24 0x18 '^Y' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 25 0x19 '^Z' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 26 0x1a '^[' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 27 0x1b '^\' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 28 0x1c '^]' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 29 0x1d '^^' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 30 0x1e '^_' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 31 0x1f '^`' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 32 0x20 ' ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 33 0x21 '!' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 34 0x22 '"' */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 35 0x23 '#' */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x7c, /* 0 00 */ 0x28, /* 00 0 000 */ 0x7c, /* 0 00 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 36 0x24 '$' */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x54, /* 0 0 0 00 */ 0x50, /* 0 0 0000 */ 0x38, /* 00 000 */ 0x14, /* 000 0 00 */ 0x54, /* 0 0 0 00 */ 0x38, /* 00 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 37 0x25 '%' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x54, /* 0 0 0 00 */ 0x58, /* 0 0 000 */ 0x28, /* 00 0 000 */ 0x34, /* 00 0 00 */ 0x54, /* 0 0 0 00 */ 0x48, /* 0 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 38 0x26 '&' */ 0x00, /* 00000000 */ 0x30, /* 00 0000 */ 0x48, /* 0 00 000 */ 0x50, /* 0 0 0000 */ 0x20, /* 00 00000 */ 0x54, /* 0 0 0 00 */ 0x48, /* 0 00 000 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 39 0x27 ''' */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 40 0x28 '(' */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x04, /* 00000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 41 0x29 ')' */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 42 0x2a '*' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x54, /* 0 0 0 00 */ 0x38, /* 00 000 */ 0x54, /* 0 0 0 00 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 43 0x2b '+' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x7c, /* 0 00 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 44 0x2c ',' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x30, /* 00 0000 */ 0x30, /* 00 0000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ /* 45 0x2d '-' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 46 0x2e '.' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 000 000 */ 0x18, /* 000 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 47 0x2f '/' */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x20, /* 00 00000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x00, /* 00000000 */ /* 48 0x30 '0' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x54, /* 0 0 0 00 */ 0x64, /* 0 00 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 49 0x31 '1' */ 0x00, /* 00000000 */ 0x08, /* 0000 000 */ 0x18, /* 000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x1c, /* 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 50 0x32 '2' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 51 0x33 '3' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x04, /* 00000 00 */ 0x18, /* 000 000 */ 0x04, /* 00000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 52 0x34 '4' */ 0x00, /* 00000000 */ 0x08, /* 0000 000 */ 0x18, /* 000 000 */ 0x28, /* 00 0 000 */ 0x48, /* 0 00 000 */ 0x7c, /* 0 00 */ 0x08, /* 0000 000 */ 0x1c, /* 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 53 0x35 '5' */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x78, /* 0 000 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 54 0x36 '6' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x40, /* 0 000000 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 55 0x37 '7' */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 56 0x38 '8' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 57 0x39 '9' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x3c, /* 00 00 */ 0x04, /* 00000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 58 0x3a ':' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x18, /* 000 000 */ 0x18, /* 000 000 */ 0x00, /* 00000000 */ 0x18, /* 000 000 */ 0x18, /* 000 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 59 0x3b ';' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x30, /* 00 0000 */ 0x30, /* 00 0000 */ 0x00, /* 00000000 */ 0x30, /* 00 0000 */ 0x30, /* 00 0000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ /* 60 0x3c '<' */ 0x00, /* 00000000 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x04, /* 00000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 61 0x3d '=' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 62 0x3e '>' */ 0x00, /* 00000000 */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 63 0x3f '?' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 64 0x40 '@' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x74, /* 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x78, /* 0 000 */ 0x40, /* 0 000000 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 65 0x41 'A' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 66 0x42 'B' */ 0x00, /* 00000000 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x78, /* 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 67 0x43 'C' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 68 0x44 'D' */ 0x00, /* 00000000 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x78, /* 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 69 0x45 'E' */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x78, /* 0 000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 70 0x46 'F' */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x78, /* 0 000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 71 0x47 'G' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x40, /* 0 000000 */ 0x4c, /* 0 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 72 0x48 'H' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 73 0x49 'I' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 74 0x4a 'J' */ 0x00, /* 00000000 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 75 0x4b 'K' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x48, /* 0 00 000 */ 0x50, /* 0 0 0000 */ 0x60, /* 0 00000 */ 0x50, /* 0 0 0000 */ 0x48, /* 0 00 000 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 76 0x4c 'L' */ 0x00, /* 00000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 77 0x4d 'M' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x6c, /* 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 78 0x4e 'N' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x64, /* 0 00 00 */ 0x54, /* 0 0 0 00 */ 0x4c, /* 0 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 79 0x4f 'O' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 80 0x50 'P' */ 0x00, /* 00000000 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x78, /* 0 000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 81 0x51 'Q' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x54, /* 0 0 0 00 */ 0x38, /* 00 000 */ 0x04, /* 00000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 82 0x52 'R' */ 0x00, /* 00000000 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 83 0x53 'S' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x40, /* 0 000000 */ 0x38, /* 00 000 */ 0x04, /* 00000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 84 0x54 'T' */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 85 0x55 'U' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 86 0x56 'V' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x28, /* 00 0 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 87 0x57 'W' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x6c, /* 0 0 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 88 0x58 'X' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x28, /* 00 0 000 */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 89 0x59 'Y' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x28, /* 00 0 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 90 0x5a 'Z' */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x40, /* 0 000000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 91 0x5b '[' */ 0x0c, /* 0000 00 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x0c, /* 0000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 92 0x5c '\' */ 0x20, /* 00 00000 */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x02, /* 000000 0 */ 0x02, /* 000000 0 */ 0x00, /* 00000000 */ /* 93 0x5d ']' */ 0x30, /* 00 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x30, /* 00 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 94 0x5e '^' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 95 0x5f '_' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 0 0 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 96 0x60 '`' */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 97 0x61 'a' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 98 0x62 'b' */ 0x00, /* 00000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x78, /* 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 99 0x63 'c' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x40, /* 0 000000 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 100 0x64 'd' */ 0x00, /* 00000000 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 101 0x65 'e' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 102 0x66 'f' */ 0x00, /* 00000000 */ 0x0c, /* 0000 00 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 103 0x67 'g' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x3c, /* 00 00 */ 0x04, /* 00000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ /* 104 0x68 'h' */ 0x00, /* 00000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 105 0x69 'i' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x30, /* 00 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 106 0x6a 'j' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x30, /* 00 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x60, /* 0 00000 */ 0x00, /* 00000000 */ /* 107 0x6b 'k' */ 0x00, /* 00000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x48, /* 0 00 000 */ 0x50, /* 0 0 0000 */ 0x70, /* 0 0000 */ 0x48, /* 0 00 000 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 108 0x6c 'l' */ 0x00, /* 00000000 */ 0x30, /* 00 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 109 0x6d 'm' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x78, /* 0 000 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 110 0x6e 'n' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x58, /* 0 0 000 */ 0x64, /* 0 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 111 0x6f 'o' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 112 0x70 'p' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x78, /* 0 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x78, /* 0 000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x00, /* 00000000 */ /* 113 0x71 'q' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x3c, /* 00 00 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x00, /* 00000000 */ /* 114 0x72 'r' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x58, /* 0 0 000 */ 0x64, /* 0 00 00 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 115 0x73 's' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x40, /* 0 000000 */ 0x38, /* 00 000 */ 0x04, /* 00000 00 */ 0x78, /* 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 116 0x74 't' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x0c, /* 0000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 117 0x75 'u' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 118 0x76 'v' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x28, /* 00 0 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 119 0x77 'w' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 120 0x78 'x' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x28, /* 00 0 000 */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 121 0x79 'y' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x3c, /* 00 00 */ 0x04, /* 00000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ /* 122 0x7a 'z' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 123 0x7b '{' */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x04, /* 00000 00 */ 0x00, /* 00000000 */ /* 124 0x7c '|' */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 125 0x7d '}' */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ /* 126 0x7e '~' */ 0x00, /* 00000000 */ 0x34, /* 00 0 00 */ 0x58, /* 0 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 127 0x7f '^?' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 128 0x80 '\200' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 129 0x81 '\201' */ 0x28, /* 00 0 000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 130 0x82 '\202' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 131 0x83 '\203' */ 0x10, /* 000 0000 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x78, /* 0 000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 132 0x84 '\204' */ 0x58, /* 0 0 000 */ 0x44, /* 0 000 00 */ 0x64, /* 0 00 00 */ 0x54, /* 0 0 0 00 */ 0x4c, /* 0 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 133 0x85 '\205' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 134 0x86 '\206' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 135 0x87 '\207' */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 136 0x88 '\210' */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 137 0x89 '\211' */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 138 0x8a '\212' */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 139 0x8b '\213' */ 0x34, /* 00 0 00 */ 0x58, /* 0 0 000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 140 0x8c '\214' */ 0x18, /* 000 000 */ 0x24, /* 00 00 00 */ 0x18, /* 000 000 */ 0x3c, /* 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 141 0x8d '\215' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x3c, /* 00 00 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ /* 142 0x8e '\216' */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 143 0x8f '\217' */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 144 0x90 '\220' */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 145 0x91 '\221' */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x40, /* 0 000000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 146 0x92 '\222' */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 147 0x93 '\223' */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 148 0x94 '\224' */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 149 0x95 '\225' */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 150 0x96 '\226' */ 0x34, /* 00 0 00 */ 0x58, /* 0 0 000 */ 0x00, /* 00000000 */ 0x58, /* 0 0 000 */ 0x64, /* 0 00 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 151 0x97 '\227' */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 152 0x98 '\230' */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 153 0x99 '\231' */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 154 0x9a '\232' */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 155 0x9b '\233' */ 0x34, /* 00 0 00 */ 0x58, /* 0 0 000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 156 0x9c '\234' */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 157 0x9d '\235' */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 158 0x9e '\236' */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 159 0x9f '\237' */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x34, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 160 0xa0 '\240' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 161 0xa1 '\241' */ 0x18, /* 000 000 */ 0x24, /* 00 00 00 */ 0x24, /* 00 00 00 */ 0x18, /* 000 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 162 0xa2 '\242' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x54, /* 0 0 0 00 */ 0x50, /* 0 0 0000 */ 0x54, /* 0 0 0 00 */ 0x38, /* 00 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 163 0xa3 '\243' */ 0x30, /* 00 0000 */ 0x48, /* 0 00 000 */ 0x40, /* 0 000000 */ 0x70, /* 0 0000 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x44, /* 0 000 00 */ 0x78, /* 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 164 0xa4 '\244' */ 0x44, /* 0 000 00 */ 0x24, /* 00 00 00 */ 0x50, /* 0 0 0000 */ 0x48, /* 0 00 000 */ 0x24, /* 00 00 00 */ 0x14, /* 000 0 00 */ 0x48, /* 0 00 000 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 165 0xa5 '\245' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x7c, /* 0 00 */ 0x7c, /* 0 00 */ 0x7c, /* 0 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 166 0xa6 '\246' */ 0x3c, /* 00 00 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x3c, /* 00 00 */ 0x14, /* 000 0 00 */ 0x14, /* 000 0 00 */ 0x14, /* 000 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 167 0xa7 '\247' */ 0x18, /* 000 000 */ 0x24, /* 00 00 00 */ 0x44, /* 0 000 00 */ 0x48, /* 0 00 000 */ 0x48, /* 0 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x58, /* 0 0 000 */ 0x40, /* 0 000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 168 0xa8 '\250' */ 0x00, /* 00000000 */ 0x70, /* 0 0000 */ 0x08, /* 0000 000 */ 0x64, /* 0 00 00 */ 0x54, /* 0 0 0 00 */ 0x64, /* 0 00 00 */ 0x58, /* 0 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 169 0xa9 '\251' */ 0x00, /* 00000000 */ 0x70, /* 0 0000 */ 0x08, /* 0000 000 */ 0x34, /* 00 0 00 */ 0x44, /* 0 000 00 */ 0x34, /* 00 0 00 */ 0x08, /* 0000 000 */ 0x70, /* 0 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 170 0xaa '\252' */ 0x00, /* 00000000 */ 0x7a, /* 0 0 0 */ 0x2e, /* 00 0 0 */ 0x2e, /* 00 0 0 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 171 0xab '\253' */ 0x00, /* 00000000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 172 0xac '\254' */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 173 0xad '\255' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x08, /* 0000 000 */ 0x7c, /* 0 00 */ 0x10, /* 000 0000 */ 0x7c, /* 0 00 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 174 0xae '\256' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x50, /* 0 0 0000 */ 0x50, /* 0 0 0000 */ 0x78, /* 0 000 */ 0x50, /* 0 0 0000 */ 0x50, /* 0 0 0000 */ 0x5c, /* 0 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 175 0xaf '\257' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x4c, /* 0 00 00 */ 0x54, /* 0 0 0 00 */ 0x64, /* 0 00 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 176 0xb0 '\260' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x6c, /* 0 0 00 */ 0x54, /* 0 0 0 00 */ 0x6c, /* 0 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 177 0xb1 '\261' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x7c, /* 0 00 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 178 0xb2 '\262' */ 0x00, /* 00000000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 179 0xb3 '\263' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x04, /* 00000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x1c, /* 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 180 0xb4 '\264' */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x28, /* 00 0 000 */ 0x7c, /* 0 00 */ 0x10, /* 000 0000 */ 0x7c, /* 0 00 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 181 0xb5 '\265' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x48, /* 0 00 000 */ 0x48, /* 0 00 000 */ 0x48, /* 0 00 000 */ 0x48, /* 0 00 000 */ 0x74, /* 0 0 00 */ 0x40, /* 0 000000 */ 0x40, /* 0 000000 */ 0x00, /* 00000000 */ /* 182 0xb6 '\266' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x0c, /* 0000 00 */ 0x14, /* 000 0 00 */ 0x24, /* 00 00 00 */ 0x24, /* 00 00 00 */ 0x18, /* 000 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 183 0xb7 '\267' */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x24, /* 00 00 00 */ 0x10, /* 000 0000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x24, /* 00 00 00 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 184 0xb8 '\270' */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 185 0xb9 '\271' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 186 0xba '\272' */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x60, /* 0 00000 */ 0x00, /* 00000000 */ /* 187 0xbb '\273' */ 0x00, /* 00000000 */ 0x1c, /* 000 00 */ 0x24, /* 00 00 00 */ 0x24, /* 00 00 00 */ 0x1c, /* 000 00 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 188 0xbc '\274' */ 0x00, /* 00000000 */ 0x18, /* 000 000 */ 0x24, /* 00 00 00 */ 0x24, /* 00 00 00 */ 0x18, /* 000 000 */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 189 0xbd '\275' */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x28, /* 00 0 000 */ 0x6c, /* 0 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 190 0xbe '\276' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x54, /* 0 0 0 00 */ 0x5c, /* 0 0 00 */ 0x50, /* 0 0 0000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 191 0xbf '\277' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x4c, /* 0 00 00 */ 0x54, /* 0 0 0 00 */ 0x64, /* 0 00 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 192 0xc0 '\300' */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x20, /* 00 00000 */ 0x40, /* 0 000000 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 193 0xc1 '\301' */ 0x00, /* 00000000 */ 0x08, /* 0000 000 */ 0x00, /* 00000000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x08, /* 0000 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 194 0xc2 '\302' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x04, /* 00000 00 */ 0x04, /* 00000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 195 0xc3 '\303' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x0c, /* 0000 00 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x50, /* 0 0 0000 */ 0x20, /* 00 00000 */ 0x20, /* 00 00000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 196 0xc4 '\304' */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x60, /* 0 00000 */ 0x00, /* 00000000 */ /* 197 0xc5 '\305' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x04, /* 00000 00 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x40, /* 0 000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 198 0xc6 '\306' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 199 0xc7 '\307' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x24, /* 00 00 00 */ 0x48, /* 0 00 000 */ 0x48, /* 0 00 000 */ 0x24, /* 00 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 200 0xc8 '\310' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x48, /* 0 00 000 */ 0x24, /* 00 00 00 */ 0x24, /* 00 00 00 */ 0x48, /* 0 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 201 0xc9 '\311' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x54, /* 0 0 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 202 0xca '\312' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 203 0xcb '\313' */ 0x10, /* 000 0000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 204 0xcc '\314' */ 0x58, /* 0 0 000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x7c, /* 0 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 205 0xcd '\315' */ 0x58, /* 0 0 000 */ 0x38, /* 00 000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 206 0xce '\316' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x50, /* 0 0 0000 */ 0x50, /* 0 0 0000 */ 0x58, /* 0 0 000 */ 0x50, /* 0 0 0000 */ 0x50, /* 0 0 0000 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 207 0xcf '\317' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x54, /* 0 0 0 00 */ 0x5c, /* 0 0 00 */ 0x50, /* 0 0 0000 */ 0x2c, /* 00 0 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 208 0xd0 '\320' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 209 0xd1 '\321' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 0 0 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 210 0xd2 '\322' */ 0x00, /* 00000000 */ 0x14, /* 000 0 00 */ 0x28, /* 00 0 000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 211 0xd3 '\323' */ 0x00, /* 00000000 */ 0x14, /* 000 0 00 */ 0x14, /* 000 0 00 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 212 0xd4 '\324' */ 0x00, /* 00000000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x18, /* 000 000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 213 0xd5 '\325' */ 0x00, /* 00000000 */ 0x18, /* 000 000 */ 0x08, /* 0000 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 214 0xd6 '\326' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x7c, /* 0 00 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 215 0xd7 '\327' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x10, /* 000 0000 */ 0x28, /* 00 0 000 */ 0x44, /* 0 000 00 */ 0x28, /* 00 0 000 */ 0x10, /* 000 0000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 216 0xd8 '\330' */ 0x00, /* 00000000 */ 0x28, /* 00 0 000 */ 0x00, /* 00000000 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x44, /* 0 000 00 */ 0x3c, /* 00 00 */ 0x04, /* 00000 00 */ 0x38, /* 00 000 */ 0x00, /* 00000000 */ /* 217 0xd9 '\331' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x7e, /* 0 0 */ 0x00, /* 00000000 */ 0x7e, /* 0 0 */ 0x00, /* 00000000 */ 0x7e, /* 0 0 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 218 0xda '\332' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 219 0xdb '\333' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 220 0xdc '\334' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 221 0xdd '\335' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 222 0xde '\336' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 223 0xdf '\337' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 224 0xe0 '\340' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 225 0xe1 '\341' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 226 0xe2 '\342' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 227 0xe3 '\343' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 228 0xe4 '\344' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 229 0xe5 '\345' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 230 0xe6 '\346' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 231 0xe7 '\347' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 232 0xe8 '\350' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 233 0xe9 '\351' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 234 0xea '\352' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 235 0xeb '\353' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 236 0xec '\354' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 237 0xed '\355' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 238 0xee '\356' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 239 0xef '\357' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 240 0xf0 '\360' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 241 0xf1 '\361' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 242 0xf2 '\362' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 243 0xf3 '\363' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 244 0xf4 '\364' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 245 0xf5 '\365' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 246 0xf6 '\366' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 247 0xf7 '\367' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 248 0xf8 '\370' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 249 0xf9 '\371' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 250 0xfa '\372' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 251 0xfb '\373' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 252 0xfc '\374' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 253 0xfd '\375' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 254 0xfe '\376' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ /* 255 0xff '\377' */ 0x00, /* 00000000 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x3c, /* 00 00 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ }; sane-backends-1.0.29/include/lgetopt.h0000666000000000000000000001463313615534521014462 00000000000000/* Declarations for getopt. Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #if defined(HAVE_GETOPT_H) && defined(HAVE_GETOPT_LONG) #include #else #ifndef _GETOPT_H #ifndef __need_getopt # define _GETOPT_H 1 #endif /* If __GNU_LIBRARY__ is not already defined, either we are being used standalone, or this is the first header included in the source file. If we are being used with glibc, we need to include , but that does not exist if we are standalone. So: if __GNU_LIBRARY__ is not defined, include , which will pull in for us if it's from glibc. (Why ctype.h? It's guaranteed to exist and it doesn't flood the namespace with stuff the way some other headers do.) */ #if !defined __GNU_LIBRARY__ # include #endif #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; #ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { # if (defined __STDC__ && __STDC__) || defined __cplusplus const char *name; # else char *name; # endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ # define no_argument 0 # define required_argument 1 # define optional_argument 2 #endif /* need getopt */ /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. Return the option character from OPTS just read. Return -1 when there are no more options. For unrecognized options, or options missing arguments, `optopt' is set to the option letter, and '?' is returned. The OPTS string is a list of characters which are recognized option letters, optionally followed by colons, specifying that that letter takes an argument, to be placed in `optarg'. If a letter in OPTS is followed by two colons, its argument is optional. This behavior is specific to the GNU `getopt'. The argument `--' causes premature termination of argument scanning, explicitly telling `getopt' that there are no more options. If OPTS begins with `--', then non-option arguments are treated as arguments to the option '\0'. This behavior is specific to the GNU `getopt'. */ #if (defined __STDC__ && __STDC__) || defined __cplusplus # ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); # else /* not __GNU_LIBRARY__ */ extern int getopt (); # endif /* __GNU_LIBRARY__ */ # ifndef __need_getopt extern int getopt_long (int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind); extern int getopt_long_only (int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only); # endif #else /* not __STDC__ */ extern int getopt (); # ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); # endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif /* Make sure we later can get all the definitions and declarations. */ #undef __need_getopt #endif /* lgetopt.h */ #endif /* !external getopt.h */ sane-backends-1.0.29/include/Makefile.in0000644000000000000000000004741513615534556014710 00000000000000# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = include ACLOCAL_M4 = $(top_srcdir)/aclocal.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/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(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/byteorder.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(nobase_include_HEADERS) \ $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/sane/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(includedir)" HEADERS = $(nobase_include_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_CPPFLAGS = @AM_CPPFLAGS@ AM_CXXFLAGS = @AM_CXXFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_LDFLAGS = @AM_LDFLAGS@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ BACKENDS = @BACKENDS@ BACKEND_CONFS_ENABLED = @BACKEND_CONFS_ENABLED@ BACKEND_LIBS_ENABLED = @BACKEND_LIBS_ENABLED@ BACKEND_MANS_ENABLED = @BACKEND_MANS_ENABLED@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLH = @DLH@ DLLTOOL = @DLLTOOL@ DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ DVIPS = @DVIPS@ DYNAMIC_FLAG = @DYNAMIC_FLAG@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ 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_CXX11 = @HAVE_CXX11@ HAVE_GPHOTO2 = @HAVE_GPHOTO2@ 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@ 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 = @LIBTOOL@ LIBV4L_CFLAGS = @LIBV4L_CFLAGS@ LIBV4L_LIBS = @LIBV4L_LIBS@ LIPO = @LIPO@ LN_S = @LN_S@ LOCKPATH_GROUP = @LOCKPATH_GROUP@ LTALLOCA = @LTALLOCA@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MATH_LIB = @MATH_LIB@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ 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@ RANLIB = @RANLIB@ RESMGR_LIBS = @RESMGR_LIBS@ SANEI_SANEI_JPEG_LO = @SANEI_SANEI_JPEG_LO@ SANEI_THREAD_LIBS = @SANEI_THREAD_LIBS@ SANE_CONFIG_PATH = @SANE_CONFIG_PATH@ SCSI_LIBS = @SCSI_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SNMP_CFLAGS = @SNMP_CFLAGS@ SNMP_CONFIG_PATH = @SNMP_CONFIG_PATH@ SNMP_LIBS = @SNMP_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_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@ XML_CFLAGS = @XML_CFLAGS@ XML_LIBS = @XML_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ configdir = @configdir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ effective_target = @effective_target@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libcurl_CFLAGS = @libcurl_CFLAGS@ libcurl_LIBS = @libcurl_LIBS@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ locksanedir = @locksanedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ nobase_include_HEADERS = sane/sane.h sane/saneopts.h EXTRA_DIST = lalloca.h lassert.h lgetopt.h md5.h font_6x11.h \ sane/config.h.in sane/sanei.h sane/sanei_ab306.h \ sane/sanei_access.h sane/sanei_auth.h sane/sanei_backend.h \ sane/sanei_cderror.h sane/sanei_codec_ascii.h \ sane/sanei_codec_bin.h sane/sanei_config.h sane/sanei_debug.h \ sane/sanei_jinclude.h sane/sanei_jpeg.h sane/sanei_lm983x.h \ sane/sanei_net.h sane/sanei_pa4s2.h sane/sanei_pio.h \ sane/sanei_pp.h sane/sanei_pv8630.h sane/sanei_scsi.h \ sane/sanei_tcp.h sane/sanei_thread.h sane/sanei_udp.h \ sane/sanei_usb.h sane/sanei_wire.h sane/sanei_magic.h \ sane/sanei_ir.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu include/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-nobase_includeHEADERS: $(nobase_include_HEADERS) @$(NORMAL_INSTALL) @list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ $(am__nobase_list) | while read dir files; do \ xfiles=; for file in $$files; do \ if test -f "$$file"; then xfiles="$$xfiles $$file"; \ else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ test -z "$$xfiles" || { \ test "x$$dir" = x. || { \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)/$$dir"; }; \ echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(includedir)/$$dir'"; \ $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(includedir)/$$dir" || exit $$?; }; \ done uninstall-nobase_includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \ $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-nobase_includeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-nobase_includeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool cscopelist-am ctags ctags-am distclean \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man \ install-nobase_includeHEADERS install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-nobase_includeHEADERS .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: sane-backends-1.0.29/include/md5.h0000666000000000000000000001236413615534521013470 00000000000000/* Declaration of functions and data types used for MD5 sum computing library functions. Copyright (C) 1995,1996,1997,1999,2000,2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef _MD5_H #define _MD5_H 1 #include #if defined HAVE_LIMITS_H || _LIBC # include #endif /* The following contortions are an attempt to use the C preprocessor to determine an unsigned integral type that is 32 bits wide. An alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but doing that would require that the configure script compile and *run* the resulting executable. Locally running cross-compiled executables is usually not possible. */ #ifdef _LIBC # include typedef uint32_t md5_uint32; typedef uintptr_t md5_uintptr; #else # if defined __STDC__ && __STDC__ # define UINT_MAX_32_BITS 4294967295U # else # define UINT_MAX_32_BITS 0xFFFFFFFF # endif /* If UINT_MAX isn't defined, assume it's a 32-bit type. This should be valid for all systems GNU cares about because that doesn't include 16-bit systems, and only modern systems (that certainly have ) have 64+-bit integral types. */ # ifndef UINT_MAX # define UINT_MAX UINT_MAX_32_BITS # endif # if UINT_MAX == UINT_MAX_32_BITS typedef unsigned int md5_uint32; # else # if USHRT_MAX == UINT_MAX_32_BITS typedef unsigned short md5_uint32; # else # if ULONG_MAX == UINT_MAX_32_BITS typedef unsigned long md5_uint32; # else /* The following line is intended to evoke an error. Using #error is not portable enough. */ "Cannot determine unsigned 32-bit data type." # endif # endif # endif /* We have to make a guess about the integer type equivalent in size to pointers which should always be correct. */ typedef unsigned long int md5_uintptr; #endif #undef __P #if defined (__STDC__) && __STDC__ # define __P(x) x #else # define __P(x) () #endif #define __md5_buffer md5_buffer #if defined __GNUC__ #define ALIGN __attribute__ ((__aligned__ (4))) #else #define ALIGN #endif /* Structure to save state of computation between the single steps. */ struct md5_ctx { md5_uint32 A; md5_uint32 B; md5_uint32 C; md5_uint32 D; md5_uint32 total[2]; md5_uint32 buflen; char buffer[128] ALIGN; }; /* * The following three functions are build up the low level used in * the functions `md5_stream' and `md5_buffer'. */ /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ extern void __md5_init_ctx __P ((struct md5_ctx *ctx)); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void __md5_process_block __P ((const void *buffer, size_t len, struct md5_ctx *ctx)); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void __md5_process_bytes __P ((const void *buffer, size_t len, struct md5_ctx *ctx)); /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ extern void *__md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf)); /* Put result from CTX in first 16 bytes following RESBUF. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ extern void *__md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf)); /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ extern int __md5_stream __P ((FILE *stream, void *resblock)); /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ extern void *__md5_buffer __P ((const char *buffer, size_t len, void *resblock)); #endif /* md5.h */ sane-backends-1.0.29/config.guess0000755000000000000000000012637313615534556013541 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2018 Free Software Foundation, Inc. timestamp='2018-02-24' # This file 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; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval "$set_cc_for_build" cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" # If ldd exists, use it to detect musl libc. if command -v ldd >/dev/null && \ ldd --version 2>&1 | grep -q ^musl then LIBC=musl fi ;; esac # Note: order is significant - the case branches are not exclusive. case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ "/sbin/$sysctl" 2>/dev/null || \ "/usr/sbin/$sysctl" 2>/dev/null || \ echo unknown)` case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` machine="${arch}${endian}"-unknown ;; *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "$machine-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" exit ;; *:MidnightBSD:*:*) echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) echo "$UNAME_MACHINE"-unknown-sortix exit ;; *:Redox:*:*) echo "$UNAME_MACHINE"-unknown-redox exit ;; mips:OSF1:*.*) echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval "$set_cc_for_build" SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ [ "$TARGET_BINARY_INTERFACE"x = x ] then echo m88k-dg-dgux"$UNAME_RELEASE" else echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` case "$UNAME_MACHINE" in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if [ "$HP_ARCH" = "" ]; then eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ "$HP_ARCH" = hppa2.0w ] then eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo "$UNAME_MACHINE"-unknown-osf1mk else echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) case "$UNAME_MACHINE" in x86) echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; i*:UWIN*:*) echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; i*86:Minix:*:*) echo "$UNAME_MACHINE"-pc-minix exit ;; aarch64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) eval "$set_cc_for_build" if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval "$set_cc_for_build" sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; mips64el:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-"$LIBC" exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) if objdump -f /bin/sh | grep -q elf32-x86-64; then echo "$UNAME_MACHINE"-pc-linux-"$LIBC"x32 else echo "$UNAME_MACHINE"-pc-linux-"$LIBC" fi exit ;; xtensa*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv"$UNAME_RELEASE" else echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval "$set_cc_for_build" if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_PPC >/dev/null then UNAME_PROCESSOR=powerpc fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk"$UNAME_RELEASE" exit ;; NSV-*:NONSTOP_KERNEL:*:*) echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) echo "$UNAME_MACHINE"-pc-aros exit ;; x86_64:VMkernel:*:*) echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; esac echo "$0: unable to guess system type" >&2 case "$UNAME_MACHINE:$UNAME_SYSTEM" in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <&2 </dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = "$UNAME_MACHINE" UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: # eval: (add-hook 'write-file-functions 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: sane-backends-1.0.29/AUTHORS0000666000000000000000000002324313615534521012255 00000000000000Authors of the SANE standard: Andreas Beck and David Mosberger Backends: abaton: David Huggins-Daines agfafocus: Karl Anders Øygard apple: Milon Firikis artec: Chris Pinkham artec_eplus48u:Sergey Vlasov, Andreas Nowack, David Stevenson, and Michael Herder as6e: Eugene S. Weiss avision: Meino Christian Cramer, René Rebe bh: Tom Martone canon: Helmut Koeberle, Manuel Panea, and Markus Mertinat Mitsuru Okaniwa, Ulrich Deiters canon630u: Nathan Rutman canon_dr: m. allan noah (*) canon_pp: Matthew Duggan, Simon Krix cardscan: m. allan noah (*) coolscan: Didier Carlier, Andreas Rick coolscan2: Andras Major coolscan3: Alessandro Zummo dc25: Peter Fales dc210: Brian J. Murrell dc240: Peter Fales dell1600n_net: Jon Chambers dll: David Mosberger dmc: David F. Skoll epjitsu: m. allan noah (*) epson: Karl Heinz Kremer epson2: Alessandro Zummo epsonds: Alessandro Zummo escl: Touboul Nathane, Thierry HUCHARD (*) fujitsu: Randolph Bentson, Frederik Ramm, Oliver Schirrmeister, m. allan noah (*) genesys: Henning Geinitz, Gerhard Jaeger (*), Stéphane Voltz, Pierre Willenbrock, Povilas Kanapickas (*) gphoto2: Peter Fales gt68xx: Sergey Vlasov, Andreas Nowack, David Stevenson, and Henning Geinitz hp: Peter Kirchgessner Geoffrey Dairiki hp3500: Troy Rollo hp3900: Jonathan Bravo Lopez hp4200: Adrian Perez Jorge, Andrew John Lewis, Arnar Mar Hrafnkelsson, Frank Zago, Henning Geinitz hp5400: Martijn van Oosterhout, Thomas Soumarmon hp5590: Ilia Sotnikov (*) hpljm1005: Philippe Rétornaz hpsj5s: Max Vorobiev hs2p: Jeremy Johnson ibm: M.F., Henning Geinitz kodak: m. allan noah (*) kodakaio: Paul Newall (*) kvs1025: Tao Zhang, m. allan noah (*) kvs20xx: unknown, m. allan noah (*) kvs40xx: unknown, m. allan noah (*) leo: Frank Zago lexmark: Fred Odendaal, Stéphane Voltz ma1509: Henning Geinitz magicolor: Reinhold Kainhofer(based on epson2 backend) matsushita: Frank Zago microtek: Matthew Marjanovic microtek2: Bernd Schroeder, Karsten Festag mustek: Andreas Bolsch, David Mosberger, Andreas Czechanowski, Henning Geinitz, and James Perry. mustek_pp: Jochen Eisinger, Eddy De Greef mustek_usb: Tom Wang and Henning Geinitz mustek_usb2: Roy Zhou, Jack Xu, Vinci Cen, and Henning Geinitz nec: Kazuya Fukuda net: Andreas Beck, David Mosberger, Julien Blache niash: Ullrich Sigwanz, Bertrik Sikken p5: Stéphane Voltz pie: Simon Munton pieusb: Jan Vleeshouwers, Michael Rickmann, Klaus Kämpf (*) pint: Gordon Matzigkeit pixma: Wittawat Yamwong Nicolas Martin Louis Lagendijk (*) Dennis Lou Rolf Bensch (*) plustek: Gerhard Jaeger (*) plustek_pp: Rick Bronson (former pp driver-code), Gerhard Jaeger (*) pnm: Andreas Beck, Gordon Matzigkeit, David Mosberger, Michael Herder, and Henning Geinitz qcam: Scott Laird (original driver), David Mosberger (SANE backend), despeckling filter by Patrick Reynolds, B&W fixes by Andrew Kuchling ricoh: Feico W. Dillema ricoh2: Stanislav Yuzvinsky (*) rts8891: Stéphane Voltz s9036: Ingo Schneider sceptre: Frank Zago sharp: Kazuya Fukuda and Abel Deuring sm3600: Marian Eichholz and Glenn Ramsey sm3840: Earle F. Philhower III snapscan: Kevin Charter, Franck Schneider, Michel Roelofs, Sebastien Sable, Henrik Johansson, Chris Bagwell, and Oliver Schwartz (*) sp15c: Randolph Bentson st400: Ingo Wilken stv680: Gerard Klaver tamarack: Rogier Wolff teco1: Frank Zago teco2: Frank Zago, Gerard Klaver teco3: Frank Zago test: Henning Geinitz u12: Gerhard Jaeger (*) umax: Oliver Rauch and Michael K. Johnson umax1220u: Marcio L. Teixeira, Patrick Lessard umax_pp: Stéphane Voltz v4l: Juergen G. Schimmer, and Henning Geinitz xerox_mfp: Alex Belkin (*) Frontends: jscanimage: Jeff Freedman and Guido Muesch saned: Andreas Beck, David Mosberger, Julien Blache scanimage: Andreas Beck, David Mosberger, Gordon Matzigkeit, m. allan noah (*), Julien Blache, Stéphane Voltz tstbackend: Frank Zago Sanei internal code: Adrian Perez Jorge, Andreas Beck, Andreas Czechanowski, Christian Bucher, David Mosberger-Tang, Frank Zago, Henning Geinitz, Jeff Freedman, Jochen Eisinger, Marcio Teixeira, Yuri Dario, Gerhard Jaeger (*), m. allan noah (*) Java API: Jeff Freedman Miscellaneous coding: Julien Blache, Mattias Ellert, Petter Reinholdtsen, Chris Bagwell, Olaf Meeuwissen (*) Translators: Giuseppe Sacco (*) (*) Maintainer with Git repository write access Please also read the file PROJECTS for projects that are planned or not yet included into the SANE distribution. Email addresses: Abel Deuring Alessandro Zummo Alex Belkin Andras Major Andreas Beck Andreas Bolsch Andreas Czechanowski Andreas Nowack Andreas Rick Andrew Kuchling Bernd Schroeder Bertrik Sikken Brian J. Murrell Chris Bagwell Chris Pinkham Christian Bucher David Etherton David F. Skoll David Huggins-Daines David Mosberger David Stevenson Didier Carlier Earle F. Philhower III Eddy De Greef Eugene S. Weiss Feico W. Dillema Franck Schneider Frank Zago Fred Odendaal Frederik Ramm Gerard Klaver Gerhard Jaeger Giuseppe Sacco Glenn Ramsey Gordon Matzigkeit Guido Muesch Helmut Koeberle Henning Geinitz Henrik Johansson Ilia Sotnikov Ingo Schneider Ingo Wilken James Perry Jeff Freedman Jochen Eisinger Jon Chambers Jonathan Bravo Lopez Juergen G. Schimmer Julien Blache Jan Vleeshouwers Karl Anders Øygard Karl Heinz Kremer Karsten Festag Kazuhiro Sasayama Kazuya Fukuda Kevin Charter Klaus Kämpf Louis Lagendijk M.F. Manuel Panea Marcio Teixeira Marian Eichholz Markus Mertinat Martijn van Oosterhout Matthew Duggan Matthew Marjanovic Mattias Ellert Max Vorobiev Meino Christian Cramer Michael Herder Michael K. Johnson Michael Rickmann Michel Roelofs Milon Firikis Mitsuru Okaniwa Nathan Rutman Nicolas Martin Olaf Meeuwissen Oliver Rauch Oliver Schirrmeister Oliver Schwartz Patrick Lessard Patrick Reynolds Paul Newall Peter Fales Peter Kirchgessner Petter Reinholdtsen Pierre Willenbrock Randolph Bentson Reinhold Kainhofer Rene Rebe Roger Wolff Rolf Bensch Roy Zhou Sebastien Sable Sergey Vlasov Simon Krix Simon Munton Stéphane Voltz Thierry HUCHARD Thomas Soumarmon Tom Martone Tom Wang Touboul Nathane Tristan Tarrant Troy Rollo Ullrich Sigwanz Ulrich Deiters Wittawat Yamwong m. allan noah sane-backends-1.0.29/acinclude.m40000666000000000000000000005204713615534521013402 00000000000000dnl dnl Contains the following macros dnl SANE_SET_AM_CFLAGS(is_release) dnl SANE_CHECK_MISSING_HEADERS dnl SANE_SET_AM_LDFLAGS dnl SANE_CHECK_DLL_LIB dnl SANE_EXTRACT_LDFLAGS(LIBS, LDFLAGS) dnl SANE_CHECK_JPEG dnl SANE_CHECK_IEEE1284 dnl SANE_CHECK_PTHREAD dnl SANE_CHECK_LOCKING dnl JAPHAR_GREP_AM_CFLAGS(flag, cmd_if_missing, cmd_if_present) dnl SANE_CHECK_U_TYPES dnl SANE_CHECK_GPHOTO2 dnl SANE_CHECK_IPV6 dnl SANE_CHECK_BACKENDS dnl SANE_PROTOTYPES dnl AC_PROG_LIBTOOL dnl # SANE_SET_AM_CFLAGS(is_release) # Set default AM_CFLAGS if gcc is used. Enable/disable additional # compilation warnings. The extra warnings are enabled by default # during the development cycle but disabled for official releases. # The argument is_release is either yes or no. AC_DEFUN([SANE_SET_AM_CFLAGS], [ if test "${ac_cv_c_compiler_gnu}" = "yes"; then DEFAULT_WARNINGS="\ -Wall" EXTRA_WARNINGS="\ -Wextra \ -pedantic" for flag in $DEFAULT_WARNINGS; do JAPHAR_GREP_AM_CFLAGS($flag, [ AM_CFLAGS="$AM_CFLAGS $flag" ]) JAPHAR_GREP_AM_CXXFLAGS($flag, [ AM_CXXFLAGS="$AM_CXXFLAGS $flag" ]) done AC_ARG_ENABLE(warnings, AS_HELP_STRING([--enable-warnings], [turn on tons of compiler warnings (GCC only)]), [ if eval "test x$enable_warnings = xyes"; then for flag in $EXTRA_WARNINGS; do JAPHAR_GREP_AM_CFLAGS($flag, [ AM_CFLAGS="$AM_CFLAGS $flag" ]) JAPHAR_GREP_AM_CXXFLAGS($flag, [ AM_CXXFLAGS="$AM_CXXFLAGS $flag" ]) done fi ], [if test x$1 = xno; then # Warnings enabled by default (development) for flag in $EXTRA_WARNINGS; do JAPHAR_GREP_AM_CFLAGS($flag, [ AM_CFLAGS="$AM_CFLAGS $flag" ]) JAPHAR_GREP_AM_CXXFLAGS($flag, [ AM_CXXFLAGS="$AM_CXXFLAGS $flag" ]) done fi]) fi # ac_cv_c_compiler_gnu ]) dnl SANE_CHECK_MISSING_HEADERS dnl Do some sanity checks. It doesn't make sense to proceed if those headers dnl aren't present. AC_DEFUN([SANE_CHECK_MISSING_HEADERS], [ MISSING_HEADERS= if test "${ac_cv_header_fcntl_h}" != "yes" ; then MISSING_HEADERS="${MISSING_HEADERS}\"fcntl.h\" " fi if test "${ac_cv_header_sys_time_h}" != "yes" ; then MISSING_HEADERS="${MISSING_HEADERS}\"sys/time.h\" " fi if test "${ac_cv_header_unistd_h}" != "yes" ; then MISSING_HEADERS="${MISSING_HEADERS}\"unistd.h\" " fi if test "${ac_cv_header_stdc}" != "yes" ; then MISSING_HEADERS="${MISSING_HEADERS}\"ANSI C headers\" " fi if test "${MISSING_HEADERS}" != "" ; then echo "*** The following essential header files couldn't be found:" echo "*** ${MISSING_HEADERS}" echo "*** Maybe the compiler isn't ANSI C compliant or not properly installed?" echo "*** For details on what went wrong see config.log." AC_MSG_ERROR([Exiting now.]) fi ]) # SANE_SET_AM_LDFLAGS # Add special AM_LDFLAGS AC_DEFUN([SANE_SET_AM_LDFLAGS], [ # Define stricter linking policy on GNU systems. This is not # added to global LDFLAGS because we may want to create convenience # libraries that don't require such strick linking. if test "$GCC" = yes; then case ${host_os} in linux* | solaris*) STRICT_LDFLAGS="-Wl,-z,defs" ;; esac fi AC_SUBST(STRICT_LDFLAGS) case "${host_os}" in aix*) #enable .so libraries, disable archives AM_LDFLAGS="$AM_LDFLAGS -Wl,-brtl" ;; darwin*) #include frameworks LIBS="$LIBS -framework CoreFoundation -framework IOKit" ;; esac ]) # SANE_CHECK_DLL_LIB # Find dll library AC_DEFUN([SANE_CHECK_DLL_LIB], [ dnl Checks for dll libraries: dl DL_LIBS="" if test "${enable_dynamic}" = "auto"; then # default to disabled unless library found. enable_dynamic=no # dlopen AC_CHECK_HEADERS(dlfcn.h, [AC_CHECK_LIB(dl, dlopen, DL_LIBS=-ldl) saved_LIBS="${LIBS}" LIBS="${LIBS} ${DL_LIBS}" AC_CHECK_FUNCS(dlopen, enable_dynamic=yes,) LIBS="${saved_LIBS}" ],) # HP/UX DLL handling AC_CHECK_HEADERS(dl.h, [AC_CHECK_LIB(dld,shl_load, DL_LIBS=-ldld) saved_LIBS="${LIBS}" LIBS="${LIBS} ${DL_LIBS}" AC_CHECK_FUNCS(shl_load, enable_dynamic=yes,) LIBS="${saved_LIBS}" ],) if test -z "$DL_LIBS" ; then # old Mac OS X/Darwin (without dlopen) AC_CHECK_HEADERS(mach-o/dyld.h, [AC_CHECK_FUNCS(NSLinkModule, enable_dynamic=yes,) ],) fi fi AC_SUBST(DL_LIBS) DYNAMIC_FLAG= if test "${enable_dynamic}" = yes ; then DYNAMIC_FLAG=-module fi AC_SUBST(DYNAMIC_FLAG) ]) # # Separate LIBS from LDFLAGS to link correctly on HP/UX (and other # platforms who care about the order of params to ld. It removes all # non '-l..'-params from passed in $1(LIBS), and appends them to $2(LDFLAGS). # # Use like this: SANE_EXTRACT_LDFLAGS(PKGNAME_LIBS, PKGNAME_LDFLAGS) AC_DEFUN([SANE_EXTRACT_LDFLAGS], [ tmp_LIBS="" for param in ${$1}; do case "${param}" in -l*) tmp_LIBS="${tmp_LIBS} ${param}" ;; *) $2="${$2} ${param}" ;; esac done $1="${tmp_LIBS}" unset tmp_LIBS unset param ]) # # # Checks for ieee1284 library, needed for canon_pp backend. AC_DEFUN([SANE_CHECK_IEEE1284], [ AC_CHECK_HEADER(ieee1284.h, [ AC_CACHE_CHECK([for libieee1284 >= 0.1.5], sane_cv_use_libieee1284, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ struct parport p; char *buf; ieee1284_nibble_read(&p, 0, buf, 1); ]])], [sane_cv_use_libieee1284="yes"; IEEE1284_LIBS="-lieee1284" ],[sane_cv_use_libieee1284="no"]) ],) ],) if test "$sane_cv_use_libieee1284" = "yes" ; then AC_DEFINE(HAVE_LIBIEEE1284,1,[Define to 1 if you have the `ieee1284' library (-lcam).]) fi AC_SUBST(IEEE1284_LIBS) ]) # # Checks for pthread support AC_DEFUN([SANE_CHECK_PTHREAD], [ case "${host_os}" in linux* | darwin* | mingw*) # enabled by default on Linux, MacOS X and MINGW use_pthread=yes ;; *) use_pthread=no esac have_pthread=no # # now that we have the systems preferences, we check # the user AC_ARG_ENABLE([pthread], AS_HELP_STRING([--enable-pthread], [use pthread instead of fork (default=yes for Linux/MacOS X/MINGW, no for everything else)]), [ if test $enableval = yes ; then use_pthread=yes else use_pthread=no fi ]) if test $use_pthread = yes ; then AC_CHECK_HEADERS(pthread.h, [ AC_CHECK_LIB(pthread, pthread_create, PTHREAD_LIBS="-lpthread") have_pthread=yes save_LIBS="$LIBS" LIBS="$LIBS $PTHREAD_LIBS" AC_CHECK_FUNCS([pthread_create pthread_kill pthread_join pthread_detach pthread_cancel pthread_testcancel], ,[ have_pthread=no; use_pthread=no ]) LIBS="$save_LIBS" ],[ have_pthread=no; use_pthread=no ]) fi # Based on a similar test for pthread_key_t from the Python project. # See https://bugs.python.org/review/25658/patch/19209/75870 AC_MSG_CHECKING(whether pthread_t is integer) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include ]], [[pthread_t k; k * 1;]])], [ac_pthread_t_is_integer=yes], [ac_pthread_t_is_integer=no] ) AC_MSG_RESULT($ac_pthread_t_is_integer) if test "$ac_pthread_t_is_integer" = yes ; then AC_DEFINE(PTHREAD_T_IS_INTEGER, 1, [Define if pthread_t is integer.]) else # Until the sanei_thread implementation is fixed. use_pthread=no fi if test "$have_pthread" = "yes" ; then AM_CPPFLAGS="${AM_CPPFLAGS} -D_REENTRANT" fi AC_SUBST(PTHREAD_LIBS) if test $use_pthread = yes ; then AC_DEFINE_UNQUOTED(USE_PTHREAD, "$use_pthread", [Define if pthreads should be used instead of forked processes.]) SANEI_THREAD_LIBS=$PTHREAD_LIBS else SANEI_THREAD_LIBS="" fi AC_SUBST(SANEI_THREAD_LIBS) AC_MSG_CHECKING([whether to enable pthread support]) AC_MSG_RESULT([$have_pthread]) AC_MSG_CHECKING([whether to use pthread instead of fork]) AC_MSG_RESULT([$use_pthread]) ]) # # Checks for jpeg library >= v6B (61), needed for DC210, DC240, # GPHOTO2 and dell1600n_net backends. AC_DEFUN([SANE_CHECK_JPEG], [ AC_CHECK_LIB(jpeg,jpeg_start_decompress, [ AC_CHECK_HEADER(jconfig.h, [ AC_MSG_CHECKING([for jpeglib - version >= 61 (6a)]) AC_EGREP_CPP(sane_correct_jpeg_lib_version_found, [ #include #if JPEG_LIB_VERSION >= 61 sane_correct_jpeg_lib_version_found #endif ], [sane_cv_use_libjpeg="yes"; JPEG_LIBS="-ljpeg"; AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)]) ],) ],) if test "$sane_cv_use_libjpeg" = "yes" ; then AC_DEFINE(HAVE_LIBJPEG,1,[Define to 1 if you have the libjpeg library.]) fi AC_SUBST(JPEG_LIBS) ]) # Checks for tiff library dell1600n_net backend. AC_DEFUN([SANE_CHECK_TIFF], [ AC_CHECK_LIB(tiff,TIFFFdOpen, [ AC_CHECK_HEADER(tiffio.h, [sane_cv_use_libtiff="yes"; TIFF_LIBS="-ltiff"],) ],) AC_SUBST(TIFF_LIBS) ]) AC_DEFUN([SANE_CHECK_PNG], [ AC_CHECK_LIB(png,png_init_io, [ AC_CHECK_HEADER(png.h, [sane_cv_use_libpng="yes"; PNG_LIBS="-lpng"],) ],) if test "$sane_cv_use_libpng" = "yes" ; then AC_DEFINE(HAVE_LIBPNG,1,[Define to 1 if you have the libpng library.]) fi AC_SUBST(PNG_LIBS) ]) # # Checks for pthread support AC_DEFUN([SANE_CHECK_LOCKING], [ LOCKPATH_GROUP=uucp use_locking=yes case "${host_os}" in os2* ) use_locking=no ;; esac # # we check the user AC_ARG_ENABLE( [locking], AS_HELP_STRING([--enable-locking], [activate device locking (default=yes, but only used by some backends)]), [ if test $enableval = yes ; then use_locking=yes else use_locking=no fi ]) if test $use_locking = yes ; then AC_ARG_WITH([group], AS_HELP_STRING([--with-group], [use the specified group for lock dir @<:@default=uucp@:>@]), [LOCKPATH_GROUP="$withval"] ) # check if the group does exist lasterror="" touch sanetest.file chgrp $LOCKPATH_GROUP sanetest.file 2>/dev/null || lasterror=$? rm -f sanetest.file if test ! -z "$lasterror"; then AC_MSG_WARN([Group $LOCKPATH_GROUP does not exist on this system.]) AC_MSG_WARN([Locking feature will be disabled.]) use_locking=no fi fi if test $use_locking = yes ; then INSTALL_LOCKPATH=install-lockpath AC_DEFINE([ENABLE_LOCKING], 1, [Define to 1 if device locking should be enabled.]) else INSTALL_LOCKPATH= fi AC_MSG_CHECKING([whether to enable device locking]) AC_MSG_RESULT([$use_locking]) if test $use_locking = yes ; then AC_MSG_NOTICE([Setting lockdir group to $LOCKPATH_GROUP]) fi AC_SUBST(INSTALL_LOCKPATH) AC_SUBST(LOCKPATH_GROUP) ]) dnl dnl JAPHAR_GREP_AM_CFLAGS(flag, cmd_if_missing, cmd_if_present) dnl dnl From Japhar. Report changes to japhar@hungry.com dnl AC_DEFUN([JAPHAR_GREP_AM_CFLAGS], [case "$AM_CFLAGS" in "$1" | "$1 "* | *" $1" | *" $1 "* ) ifelse($#, 3, [$3], [:]) ;; *) $2 ;; esac ]) dnl dnl JAPHAR_GREP_AM_CXXFLAGS(flag, cmd_if_missing, cmd_if_present) dnl AC_DEFUN([JAPHAR_GREP_AM_CXXFLAGS], [case "$AM_CXXFLAGS" in "$1" | "$1 "* | *" $1" | *" $1 "* ) ifelse($#, 3, [$3], [:]) ;; *) $2 ;; esac ]) dnl dnl SANE_CHECK_U_TYPES dnl AC_DEFUN([SANE_CHECK_U_TYPES], [ dnl Use new style of check types that doesn't take default to use. dnl The old style would add an #undef of the type check on platforms dnl that defined that type... That is not portable to platform that dnl define it as a #define. AC_CHECK_TYPES([u_char, u_short, u_int, u_long],,,) ]) # # Checks for gphoto2 libs, needed by gphoto2 backend AC_DEFUN([SANE_CHECK_GPHOTO2], [ AC_ARG_WITH(gphoto2, AS_HELP_STRING([--with-gphoto2], [include the gphoto2 backend @<:@default=yes@:>@]), [# If --with-gphoto2=no or --without-gphoto2, disable backend # as "$with_gphoto2" will be set to "no"]) # If --with-gphoto2=yes (or not supplied), first check if # pkg-config exists, then use it to check if libgphoto2 is # present. If all that works, then see if we can actually link # a program. And, if that works, then add the -l flags to # GPHOTO2_LIBS and any other flags to GPHOTO2_LDFLAGS to pass to # sane-config. if test "$with_gphoto2" != "no" ; then AC_CHECK_TOOL(HAVE_GPHOTO2, pkg-config, false) if test ${HAVE_GPHOTO2} != "false" ; then if pkg-config --exists libgphoto2 ; then with_gphoto2="`pkg-config --modversion libgphoto2`" GPHOTO2_CPPFLAGS="`pkg-config --cflags libgphoto2`" GPHOTO2_LIBS="`pkg-config --libs libgphoto2`" saved_CPPFLAGS="${CPPFLAGS}" CPPFLAGS="${GPHOTO2_CPPFLAGS}" saved_LIBS="${LIBS}" LIBS="${LIBS} ${GPHOTO2_LIBS}" # Make sure we an really use the library AC_CHECK_FUNCS(gp_camera_init, HAVE_GPHOTO2=true, HAVE_GPHOTO2=false) if test "${HAVE_GPHOTO2}" = "true"; then AC_CHECK_FUNCS(gp_port_info_get_path) fi CPPFLAGS="${saved_CPPFLAGS}" LIBS="${saved_LIBS}" else HAVE_GPHOTO2=false fi if test "${HAVE_GPHOTO2}" = "false"; then GPHOTO2_CPPFLAGS="" GPHOTO2_LIBS="" else SANE_EXTRACT_LDFLAGS(GPHOTO2_LIBS, GPHOTO2_LDFLAGS) if pkg-config --atleast-version=2.5.0 libgphoto2; then AC_DEFINE([GPLOGFUNC_NO_VARGS], [1], [Define if GPLogFunc does not take a va_list.]) fi fi fi fi AC_SUBST(GPHOTO2_CPPFLAGS) AC_SUBST(GPHOTO2_LIBS) AC_SUBST(GPHOTO2_LDFLAGS) ]) # # Check for AF_INET6, determines whether or not to enable IPv6 support # Check for ss_family member in struct sockaddr_storage AC_DEFUN([SANE_CHECK_IPV6], [ AC_MSG_CHECKING([whether to enable IPv6]) AC_ARG_ENABLE(ipv6, AS_HELP_STRING([--disable-ipv6],[disable IPv6 support]), [ if test "$enableval" = "no" ; then AC_MSG_RESULT([no, manually disabled]) ipv6=no fi ]) if test "$ipv6" != "no" ; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define INET6 #include #include ]], [[ /* AF_INET6 available check */ if (socket(AF_INET6, SOCK_STREAM, 0) < 0) exit(1); else exit(0); ]])],[ AC_MSG_RESULT(yes) AC_DEFINE([ENABLE_IPV6], 1, [Define to 1 if the system supports IPv6]) ipv6=yes ],[ AC_MSG_RESULT([no (couldn't compile test program)]) ipv6=no ]) fi if test "$ipv6" != "no" ; then AC_MSG_CHECKING([whether struct sockaddr_storage has an ss_family member]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define INET6 #include #include ]], [[ /* test if the ss_family member exists in struct sockaddr_storage */ struct sockaddr_storage ss; ss.ss_family = AF_INET; exit (0); ]])], [ AC_MSG_RESULT(yes) AC_DEFINE([HAS_SS_FAMILY], 1, [Define to 1 if struct sockaddr_storage has an ss_family member]) ], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define INET6 #include #include ]], [[ /* test if the __ss_family member exists in struct sockaddr_storage */ struct sockaddr_storage ss; ss.__ss_family = AF_INET; exit (0); ]])], [ AC_MSG_RESULT([no, but __ss_family exists]) AC_DEFINE([HAS___SS_FAMILY], 1, [Define to 1 if struct sockaddr_storage has __ss_family instead of ss_family]) ], [ AC_MSG_RESULT([no]) ipv6=no ]) ]) fi ]) # # Verifies that values in $BACKENDS and updates FILTERED_BACKEND # with either backends that can be compiled or fails the script. AC_DEFUN([SANE_CHECK_BACKENDS], [ if test "${user_selected_backends}" = "yes"; then DISABLE_MSG="aborting" else DISABLE_MSG="disabling" fi FILTERED_BACKENDS="" for be in ${BACKENDS}; do backend_supported="yes" case $be in plustek_pp) case "$host_os" in gnu*) echo "*** $be backend not supported on GNU/Hurd - $DISABLE_MSG" backend_supported="no" ;; esac ;; dc210|dc240|pixma) if test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; canon_pp|hpsj5s) if test "${sane_cv_use_libieee1284}" != "yes"; then echo "*** $be backend requires libieee1284 library - $DISABLE_MSG" backend_supported="no" fi ;; genesys) if test "${HAVE_CXX11}" != "1"; then echo "*** $be backend requires C++11 support - $DISABLE_MSG" backend_supported="no" fi ;; mustek_pp) if test "${sane_cv_use_libieee1284}" != "yes" && test "${enable_parport_directio}" != "yes"; then echo "*** $be backend requires libieee1284 or parport-directio libraries - $DISABLE_MSG" backend_supported="no" fi ;; dell1600n_net) if test "${sane_cv_use_libjpeg}" != "yes" || test "${sane_cv_use_libtiff}" != "yes"; then echo "*** $be backend requires JPEG and TIFF library - $DISABLE_MSG" backend_supported="no" fi ;; epsonds) if test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; escl) if test "x${enable_avahi}" != "xyes"; then echo "*** $be backend requires AVAHI library - $DISABLE_MSG" backend_supported="no" fi if test "x${with_libcurl}" != "xyes"; then echo "*** $be backend requires cURL library - $DISABLE_MSG" backend_supported="no" fi if test "x${have_libxml}" != "xyes"; then echo "*** $be backend requires XML library - $DISABLE_MSG" backend_supported="no" fi # FIXME: Remove when PNG and/or PDF support have been added. if test "x${sane_cv_use_libjpeg}" != "xyes"; then echo "*** $be backend currently requires JPEG library - $DISABLE_MSG" backend_supported="no" fi ;; gphoto2) if test "${HAVE_GPHOTO2}" != "true" \ || test "${sane_cv_use_libjpeg}" != "yes"; then echo "*** $be backend requires gphoto2 and JPEG libraries - $DISABLE_MSG" backend_supported="no" fi ;; pint) if test "${ac_cv_header_sys_scanio_h}" = "no"; then echo "*** $be backend requires sys/scanio.h - $DISABLE_MSG" backend_supported="no" fi ;; qcam) if ( test "${ac_cv_func_ioperm}" = "no" || test "${sane_cv_have_sys_io_h_with_inb_outb}" = "no" )\ && test "${ac_cv_func__portaccess}" = "no"; then echo "*** $be backend requires (ioperm, inb and outb) or portaccess functions - $DISABLE_MSG" backend_supported="no" fi ;; v4l) if test "${have_linux_ioctl_defines}" != "yes" \ || test "${have_libv4l1}" != "yes"; then echo "*** $be backend requires v4l libraries - $DISABLE_MSG" backend_supported="no" fi ;; net) if test "${ac_cv_header_sys_socket_h}" = "no"; then echo "*** $be backend requires sys/socket.h - $DISABLE_MSG" backend_supported="no" fi ;; mustek_usb2|kvs40xx) if test "${have_pthread}" != "yes"; then echo "*** $be backend requires pthread library - $DISABLE_MSG" backend_supported="no" fi ;; esac if test "${backend_supported}" = "no"; then if test "${user_selected_backends}" = "yes"; then exit 1 fi else FILTERED_BACKENDS="${FILTERED_BACKENDS} $be" fi done ]) # # Generate prototypes for functions not available on the system AC_DEFUN([SANE_PROTOTYPES], [ AH_BOTTOM([ #if defined(__MINGW32__) #define _BSDTYPES_DEFINED #endif #ifndef HAVE_U_CHAR #define u_char unsigned char #endif #ifndef HAVE_U_SHORT #define u_short unsigned short #endif #ifndef HAVE_U_INT #define u_int unsigned int #endif #ifndef HAVE_U_LONG #define u_long unsigned long #endif /* Prototype for getenv */ #ifndef HAVE_GETENV #define getenv sanei_getenv char * getenv(const char *name); #endif /* Prototype for inet_ntop */ #ifndef HAVE_INET_NTOP #define inet_ntop sanei_inet_ntop #include const char * inet_ntop (int af, const void *src, char *dst, size_t cnt); #endif /* Prototype for inet_pton */ #ifndef HAVE_INET_PTON #define inet_pton sanei_inet_pton int inet_pton (int af, const char *src, void *dst); #endif /* Prototype for sigprocmask */ #ifndef HAVE_SIGPROCMASK #define sigprocmask sanei_sigprocmask int sigprocmask (int how, int *new, int *old); #endif /* Prototype for snprintf */ #ifndef HAVE_SNPRINTF #define snprintf sanei_snprintf #include int snprintf (char *str,size_t count,const char *fmt,...); #endif /* Prototype for strcasestr */ #ifndef HAVE_STRCASESTR #define strcasestr sanei_strcasestr char * strcasestr (const char *phaystack, const char *pneedle); #endif /* Prototype for strdup */ #ifndef HAVE_STRDUP #define strdup sanei_strdup char *strdup (const char * s); #endif /* Prototype for strndup */ #ifndef HAVE_STRNDUP #define strndup sanei_strndup #include char *strndup(const char * s, size_t n); #endif /* Prototype for strsep */ #ifndef HAVE_STRSEP #define strsep sanei_strsep char *strsep(char **stringp, const char *delim); #endif /* Prototype for usleep */ #ifndef HAVE_USLEEP #define usleep sanei_usleep unsigned int usleep (unsigned int useconds); #endif /* Prototype for vsyslog */ #ifndef HAVE_VSYSLOG #include void vsyslog(int priority, const char *format, va_list args); #endif ]) ]) m4_include([m4/byteorder.m4]) sane-backends-1.0.29/README.netbsd0000666000000000000000000000410513615534521013337 00000000000000SANE and NetBSD ---------------- Building: --------- Don't forget to use GNU make (gmake). E.g. "MAKE=gmake ./configure". SANE should compile and install out-of-the-box. SCSI-scanners: -------------- SANE only supports the generic /dev/uk? devices. /dev/ss? won't work. If your scanner is detected by the ss driver, disable the driver with the "config" utility or compile a new kernel without ss. Set a link /dev/scanner to /dev/uk0 (or whatever you use) and/or edit your backend's config file appropriately. Don't forget to set up permissions to the device file correctly for access by a non-root user (read/write). Auto-configuration using the "scsi *" lines in the config files doesn't work. Scanners with higher resolutions need bigger SCSI buffers. Therefore, edit sanei/sanei_scsi.c and look for these lines: #ifndef MAX_DATA # define MAX_DATA (32*1024) #endif Increase the buffer size to e.g. 128 * 1024. Recompile. USB-scanners: ------------- USB-Scanners are supported in principle. Using libusb is recommended. Problems when using libusb: Older kernels may need to be compiled WITHOUT DIAGNOSTIC. Disable it in the config file or use a GENERIC kernel without DIAGNOSTIC. If it is, you will get errors like "ugenioctl: USB_SET_TIMEOUT, no pipe". When using libusb, make sure, that /dev/ugen* and /dev/usb* devices are available. Use /dev/MAKEDEV to create them, if necessary. If you want to use libusb, disable the uscanner driver. Problems with uscanner driver: The uscanner driver also works (tested with the plustek backend). As the uscanner driver can't detect the vendor and product ids automatically, it's necessary to add the name of the device file to the backends's configuration file. Some backends also need the vendor and product id of the scanner. Some backends won't work with the uscanner driver becasue they need USB control messages. Use libusb instead. Parport-scanners: ----------------- I don't have any information about these. Please contact me or the SANE mailing list if you succeeded in using one of these. 2003-04-24 Henning Meier-Geinitz sane-backends-1.0.29/PROBLEMS0000666000000000000000000000205713615534521012353 00000000000000Last update: 2006-01-05 - Avoiding damage on flatbed scanners Most flatbed scanners have no protection against exceeding the physical scan area height. That is, if a scan is attempted with a height that exceeds the height of the scan surface, the scanner begins making loud noises and the scan mechanism may be damaged. Thus, if you hear such a noise, IMMEDIATELY turn off the scanner. Normally, the backend will ensure that the maximum scan height is not exceeded. However, if your scanner model has not been tested yet this safety-guard may not work. Please report errors like this to the author of the backend or the sane-devel mailing list. - Security problems with saned (SANE network scanning daemon) saned is not intended to be exposed to the internet or other non-trusted networks. Make sure that access is limited by tcpwrappers and/or a firewall setup. Don't depend only on saned's own authentification. Don't run saned as root if it's not necessary. And do not install saned as setuid root. Read man saned(8) for details. sane-backends-1.0.29/compile0000755000000000000000000001632713615534556012574 00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2018-03-07.03; # UTC # Copyright (C) 1999-2018 Free Software Foundation, Inc. # Written by Tom Tromey . # # 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; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: sane-backends-1.0.29/COPYING0000666000000000000000000004312713615534521012243 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. sane-backends-1.0.29/backend/0000755000000000000000000000000013615535552012651 500000000000000sane-backends-1.0.29/backend/epson.c0000666000000000000000000053233413615534521014072 00000000000000/* epson.c - SANE library for Epson flatbed scanners. Based on Kazuhiro Sasayama previous Work on epson.[ch] file from the SANE package. Original code taken from sane-0.71 Copyright (C) 1997 Hypercore Software Design, Ltd. modifications Copyright (C) 1998-1999 Christian Bucher Copyright (C) 1998-1999 Kling & Hautzinger GmbH Copyright (C) 1999 Norihiko Sawa Copyright (C) 2000 Mike Porter (mjp) Copyright (C) 2003 EPSON KOWA Corporation Copyright (C) 1999-2005 Karl Heinz Kremer Copyright (C) 2006 Claus Boje */ #define SANE_EPSON_VERSION "SANE Epson Backend v0.2.47 - 2006-08-21" #define SANE_EPSON_BUILD 247 /* 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* 2006-08-21 Fix buffer overflow error (submitted by Johannes Meixner) 2006-06-11 Applied patch from Henning. Fixed a number of compiler warnings 2006-03-12 Added support for perfetion 4990 photo 4800 dpi 2005-01-09 "flaming hack to get USB scanners working without timeouts under linux" submitted by "Steve" (in comment to bug #300830) 2004-12-18 Added USB IDs for CX-4600 and CX-3650 2004-10-16 Added USB ID for Expression 10000XL 2004-05-08 Disable feed() for Perfection1640 2004-02-08 Reformat all source code with "indent -bli0" 2004-02-01 Added D7 function level as copy of D1 for CX-6400 Added IDs for CX-6400 and Perfection 4870 2003-10-27 Replaced DBG(0, ... with DBG(1, ... 2003-09-12 Increment only once in loop to find USB scanners Fix rounding problem when determining number of lines to scan 2003-08-21 Removed '//' comments - again ... Added EPSON Kowa copyright message 2003-08-15 Added support for GT-30000, with support for the ADF in simplex mode Borrowed some code from the EPSON Kowa IScan version of the backend Use sanei_scsi_cmd2() to send commands. This makes this backend useable for SBP-2 under FreeBSD 2003-05-11 Initialize OPT_LIMIT_RESOLUTION before first call to filter_resolution_list() Fix memory problem in get_identity_information(). Both problems were reported to the Debian bug database. 2003-03-26 Fixed two warnings reported by der Mouse 2003-02-16 Code cleanup, use more descriptive variable names. 2003-02-15 Move sanei_usb_init() to sane_init(). Thanks to Ron Cemer for providing the patch. 2003-02-15 Fix problem with "usb syntax in config file 2002-12-28 Added advanced option to display only short resolution list for displays that can not show the complete list. 2002-11-23 Fixed problem with dropout color. 2002-11-03 Full libusb support. 2002-10-05 Fixed problem with incorrect response to sane_get_parameters() in certain situations. 2002-09-01 USB scanners are now using libsane-usb funtions 2002-08-17 Fixed typo in variable name. Fixed IEEE-1394 problem with Perfection-2450. Fixed problem with older B3 level SCSI scanners that do not support the extended status request. 2002-04-22 Declare close_scanner() and open_scanner() before they are used. 2002-04-13 Check if scanner needs to be opened for the reset call. (Thanks to Thomas Wenrich for pointing this out) Added product IDs for Perfection 1650 and 2450 2002-01-18 Recognize GT-xxxx type scanners also when using the SCSI or IEEE-1394 interface 2002-01-06 Disable TEST_IOCTL again, which was enabled by accident. Also protect the ioctl portion with an #ifdef __linux__ 2002-01-05 Version 0.2.17 Check for and set s->fd to -1 when device is closed. Removed black gamma table - only use RGB even for grayscale 2002-01-01 Do not call access() for OS/2 systems 2001-11-13 Version 0.2.16 Do not call access() for parallel port scanners. 2001-11-11 Version 0.2.15 Fixed "wait-for-button" functionality, accidentially merged back wrong version after code freeze. Corrected "need-strange-reorder" recognition. Added IOCTL support to header file. 2001-11-10 Version 0.2.14 Added "wait-for-button" functionality 2001-10-30 I18N patches (Stefan Roellin) 2001-10-28 Fixed bug with 1650 recognition 2001-06-09 Version 0.2.09 Changed debug level for sense handler from 0 to 2 2001-05-25 Version 0.2.07 Allow more than 8 bit color depth even for preview mode since Xsane can handle this. Some code cleanup. 2001-05-24 Removed ancient code that was used to determine the resolution back when the backend still had a slider for the resolution selection. 2001-05-22 Version 0.2.06 Added sense_handler to support the GT-8000 scanner. Thanks to Matthias Trute for figuring out the details. Also added experimental code to use USB scanner probing. Need kernel patch for this. 2001-05-19 Version 0.2.05 fixed the year in the recent change log entries - I now that it's 2001... Finally fixed the TPU problem with B4 level scanners 2001-05-13 Version 0.2.04 Removed check for '\n' before end of line Free memory malloced in sane_get_devices() in sane_exit() again 2001-04-22 Version 0.2.03 Check first if the scanner does support the set film type and set focus position before the GUI elements are displayed. This caused problems with older (B4 level) scanners when a TPU was connected. 2001-03-31 Version 0.2.02 2001-03-17 Next attempt to get the reported number of lines correct for the "color shuffling" part. Added more comments. 2000-12-25 Version 0.2.01 Fixed problem with bilevel scanning with Perfection610: The line count has to be an even number with this scanner. Several initialization fixes regarding bit depth selection. This version goes back into the CVS repository, the 1.0.4 release is out and therefore the code freeze is over. Some general cleanup, added more comments. 2000-12-09 Version 0.2.00 Cleaned up printing of gamma table data. 16 elements are now printed in one line without the [epson] in between the values. Values are only printed for Debug levels >= 10. 2000-12-04 We've introduced the concept of inverting images when scanning from a TPU. This is fine, but the user supplied gamma tables no longer work. This is because the data a frontend is going to compute a gamma table for is not what the scanner actually sent. So, we have to back into the proper gamma table. I think this works. See set_gamma_table. (mjp) 2000-12-03 added the 12/14/16 bit support again. 2000-12-03 Version 0.1.38 removed changes regarding 12/14 bit support because of SANE feature freeze for 1.0.4. The D1 fix for reading the values from the scanner instead of using hardcoded values and the fix for the off-by-one error in the reorder routine are still in the code base. Also force reload after change of scan mode. The full backend can be downloaded from my web site at http://www.freecolormanagement.com/sane 2000-12-03 Fixed off-by-one error in color reordering function. 2000-12-02 Read information about optical resolution and line distance from scanner instead of hardcoded values. Add support for color depth > 8 bits per channel. 2000-11-23 Display "Set Focus" control only for scanners that can actually handle the command. 2000-11-19 Added support for the "set focus position" command, this is necessary for the Expression1600. 2000-07-28 Changed #include <...> to #include "..." for the sane/... include files. 2000-07-26 Fixed problem with Perfection610: The variable s->color_shuffle_line was never correctly initialized 2000-06-28 When closing the scanner device the data that's still in the scanner, waiting to be transferred is flushed. This fixes the problem with scanimage -T 2000-06-13 Invert image when scanning negative with TPU, Show film type only when TPU is selected 2000-06-13 Initialize optical_res to 0 (Dave Hill) 2000-06-07 Fix in sane_close() - found by Henning Meier-Geinitz 2000-06-01 Threshhold should only be active when scan depth is 1 and halftoning is off. (mjp) 2000-05-28 Turned on scanner based color correction. Dependancies between many options are now being enforced. For instance, auto area seg (AAS) should only be on when scan depth == 1. Added some routines to active and deactivate options. Routines report if option changed. Help prevent extraneous option reloads. Split sane_control_option in getvalue and setvalue. Further split up setvalue into several different routines. (mjp) 2000-05-21 In sane_close use close_scanner instead of just the SCSI close function. 2000-05-20 ... finally fixed the problem with the 610 Added resolution_list to Epson_Device structure in epson.h - this fixes a bug that caused problems when more than one EPSON scanner was connected. 2000-05-13 Fixed the color problem with the Perfection 610. The few lines with "garbage" at the beginning of the scan are not yet removed. 2000-05-06 Added support for multiple EPSON scanners. At this time this may not be bug free, but it's a start and it seems to work well with just one scanner. 2000-04-06 Did some cleanup on the gamma correction part. The user defined table is now initialized to gamma=1, the gamma handling is also no longer depending on platform specific tables (handled instead by pointers to the actual tables) 2000-03-27 Disable request for push button status 2000-03-22 Removed free() calls to static strings to remove compile warnings. These were introduced to apparently fix an OS/2 bug. It now turned out that they are not necessary. The real fix was in the repository for a long time (2000-01-25). 2000-03-19 Fixed problem with A4 level devices - they use the line mode instead of the block mode. The routine to handle this was screwed up pretty bad. Now I have a solid version that handles all variations of line mode (automatically deals with the order the color lines are sent). 2000-03-06 Fixed occasional crash after warm up when the "in warmup state" went away in between doing ESC G and getting the extended status message. 2000-03-02 Code cleanup, disabled ZOOM until I have time to deal with all the side effects. 2000-03-01 More D1 fixes. In the future I have to come up with a more elegant solution to destinguish between different function levels. The level > n does not work anymore with D1. Added support for "set threshold" and "set zoom". 2000-02-23 First stab at level D1 support, also added a test for valid "set halftone" command to enable OPT_HALFTONE 2000-02-21 Check for "warming up" in after sane_start. This is IMHO a horrible hack, but that's the only way without a major redesign that will work. (KHK) 2000-02-20 Added some cleanup on error conditions in attach() Use new sanei_config_read() instead of fgets() for compatibility with OS/2 (Yuri Dario) 2000-02-19 Changed some "int" to "size_t" types Removed "Preview Resolution" Implemented resolution list as WORD_LIST instead of a RANGE (KHK) 2000-02-11 Default scan source is always "Flatbed", regardless of installed options. Corrected some typos. (KHK) 2000-02-03 Gamma curves now coupled with gamma correction menu. Only when "User defined" is selected are the curves selected. (Dave Hill) Renamed "Contrast" to "Gamma Correction" (KHK) 2000-02-02 "Brown Paper Bag Release" Put the USB fix finally into the CVS repository. 2000-02-01 Fixed problem with USB scanner not being recognized because of hte changes to attach a few days ago. (KHK) 2000-01-29 fixed core dump with xscanimage by moving the gamma curves to the standard interface (no longer advanced) Removed pragma pack() from source code to make it easier to compile on non-gcc compilers (KHK) 2000-01-26 fixed problem with resolution selection when using the resolution list in xsane (KHK) 2000-01-25 moved the section where the device name is assigned in attach. This avoids the core dump of frontend applications when no scanner is found (Dave Hill) 2000-01-24 reorganization of SCSI related "helper" functions started support for user defined color correction - this is not yet available via the UI (Christian Bucher) 2000-01-24 Removed C++ style comments '//' (KHK) */ /* #define TEST_IOCTL */ /* DON'T CHANGE THE NEXT LINE ! */ /* #undef FORCE_COLOR_SHUFFLE */ #ifdef _AIX #include /* MUST come first for AIX! */ #endif /* --------------------- SANE INTERNATIONALISATION ------------------ */ #ifndef SANE_I18N #define SANE_I18N(text) (text) #endif #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_pio.h" #define BACKEND_NAME epson #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "epson.h" #include "epson_scsi.h" #include "epson_usb.h" #define EPSON_CONFIG_FILE "epson.conf" #ifndef PATH_MAX #define PATH_MAX (1024) #endif #define walloc(x) (x *)malloc(sizeof(x)) #define walloca(x) (x *)alloca(sizeof(x)) #ifndef XtNumber #define XtNumber(x) ( sizeof(x)/ sizeof(x[0]) ) #define XtOffset(p_type,field) ((size_t)&(((p_type)NULL)->field)) #define XtOffsetOf(s_type,field) XtOffset(s_type*,field) #endif #define NUM_OF_HEX_ELEMENTS (16) /* number of hex numbers per line for data dump */ #define DEVICE_NAME_LEN (16) /* length of device name in extended status */ /* NOTE: you can find these codes with "man ascii". */ #define STX 0x02 #define ACK 0x06 #define NAK 0x15 #define CAN 0x18 #define ESC 0x1B #define PF 0x19 #define S_ACK "\006" #define S_CAN "\030" #define STATUS_FER 0x80 /* fatal error */ #define STATUS_AREA_END 0x20 /* area end */ #define STATUS_OPTION 0x10 /* option installed */ #define EXT_STATUS_FER 0x80 /* fatal error */ #define EXT_STATUS_FBF 0x40 /* flat bed scanner */ #define EXT_STATUS_WU 0x02 /* warming up */ #define EXT_STATUS_PB 0x01 /* scanner has a push button */ #define EXT_STATUS_IST 0x80 /* option detected */ #define EXT_STATUS_EN 0x40 /* option enabled */ #define EXT_STATUS_ERR 0x20 /* other error */ #define EXT_STATUS_PE 0x08 /* no paper */ #define EXT_STATUS_PJ 0x04 /* paper jam */ #define EXT_STATUS_OPN 0x02 /* cover open */ #define EPSON_LEVEL_A1 0 #define EPSON_LEVEL_A2 1 #define EPSON_LEVEL_B1 2 #define EPSON_LEVEL_B2 3 #define EPSON_LEVEL_B3 4 #define EPSON_LEVEL_B4 5 #define EPSON_LEVEL_B5 6 #define EPSON_LEVEL_B6 7 #define EPSON_LEVEL_B7 8 #define EPSON_LEVEL_B8 9 #define EPSON_LEVEL_F5 10 #define EPSON_LEVEL_D1 11 #define EPSON_LEVEL_D7 12 #define EPSON_LEVEL_D8 13 /* there is also a function level "A5", which I'm igoring here until somebody can convince me that this is still needed. The A5 level was for the GT-300, which was (is) a monochrome only scanner. So if somebody really wants to use this scanner with SANE get in touch with me and we can work something out - khk */ #define EPSON_LEVEL_DEFAULT EPSON_LEVEL_B3 static EpsonCmdRec epson_cmd[] = { /* * request identity * | request identity2 * | | request status * | | | request condition * | | | | set color mode * | | | | | start scanning * | | | | | | set data format * | | | | | | | set resolution * | | | | | | | | set zoom * | | | | | | | | | set scan area * | | | | | | | | | | set brightness * | | | | | | | | | | | set gamma * | | | | | | | | | | | | set halftoning * | | | | | | | | | | | | | set color correction * | | | | | | | | | | | | | | initialize scanner * | | | | | | | | | | | | | | | set speed * | | | | | | | | | | | | | | | | set lcount * | | | | | | | | | | | | | | | | | mirror image * | | | | | | | | | | | | | | | | | | set gamma table * | | | | | | | | | | | | | | | | | | | set outline emphasis * | | | | | | | | | | | | | | | | | | | | set dither * | | | | | | | | | | | | | | | | | | | | | set color correction coefficients * | | | | | | | | | | | | | | | | | | | | | | request extension status * | | | | | | | | | | | | | | | | | | | | | | | control an extension * | | | | | | | | | | | | | | | | | | | | | | | | forward feed / eject * | | | | | | | | | | | | | | | | | | | | | | | | | feed * | | | | | | | | | | | | | | | | | | | | | | | | | | request push button status * | | | | | | | | | | | | | | | | | | | | | | | | | | | control auto area segmentation * | | | | | | | | | | | | | | | | | | | | | | | | | | | | set film type * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set exposure time * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set bay * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set threshold * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set focus position * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | request focus position * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | */ {"A1", 'I', 0, 'F','S', 0, 'G', 0, 'R', 0, 'A', 0, {0,0,0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {"A2", 'I', 0, 'F','S', 0, 'G','D','R','H','A','L',{-3,3,0}, 'Z','B', 0, '@', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {"B1", 'I', 0, 'F','S','C','G','D','R', 0, 'A', 0, {0,0,0}, 0, 'B', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {"B2", 'I', 0, 'F','S','C','G','D','R','H','A','L',{-3,3,0}, 'Z','B', 0, '@', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {"B3", 'I', 0, 'F','S','C','G','D','R','H','A','L',{-3,3,0}, 'Z','B','M','@', 0, 0, 0, 0, 0, 0, 'm','f','e', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {"B4", 'I', 0, 'F','S','C','G','D','R','H','A','L',{-3,3,0}, 'Z','B','M','@','g','d', 0, 'z','Q','b','m','f','e', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {"B5", 'I', 0, 'F','S','C','G','D','R','H','A','L',{-3,3,0}, 'Z','B','M','@','g','d','K','z','Q','b','m','f','e', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {"B6", 'I', 0, 'F','S','C','G','D','R','H','A','L',{-3,3,0}, 'Z','B','M','@','g','d','K','z','Q','b','m','f','e', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {"B7", 'I', 0, 'F','S','C','G','D','R','H','A','L',{-4,3,0}, 'Z','B','M','@','g','d','K','z','Q','b','m','f','e','\f', 0, '!','s','N', 0, 0, 't', 0, 0}, {"B8", 'I', 0, 'F','S','C','G','D','R','H','A','L',{-4,3,0}, 'Z','B','M','@','g','d','K','z','Q','b','m','f','e','\f', 0x19,'!','s','N', 0, 0, 0, 'p','q'}, {"F5", 'I', 0, 'F','S','C','G','D','R','H','A','L',{-3,3,0}, 'Z', 0, 'M','@','g','d','K','z','Q', 0, 'm','f','e','\f', 0, 0, 0, 'N','T','P', 0, 0, 0}, {"D1", 'I','i','F', 0, 'C','G','D','R', 0, 'A', 0, {0,0,0}, 'Z', 0, 0, '@','g','d', 0, 'z', 0, 0, 0, 'f', 0, 0, 0, '!', 0, 0, 0, 0, 0, 0, 0}, {"D7", 'I', 0, 'F', 0, 'C','G','D','R', 0, 'A', 0, {0,0,0}, 'Z', 0, 0, '@','g','d', 0, 'z', 0, 0, 0, 'f', 0, 0, 0, '!', 0, 0, 0, 0, 0, 0, 0}, {"D8", 'I','i','F', 0, 'C','G','D','R', 0, 'A', 0, {0,0,0}, 'Z', 0, 0, '@','g','d', 0, 'z', 0, 0, 0, 'f','e', 0, 0, '!', 0, 0, 0, 0, 0, 0, 0}, }; /* * Definition of the mode_param struct, that is used to * specify the valid parameters for the different scan modes. * * The depth variable gets updated when the bit depth is modified. */ struct mode_param { int color; int mode_flags; int dropout_mask; int depth; }; static struct mode_param mode_params[] = { {0, 0x00, 0x30, 1}, {0, 0x00, 0x30, 8}, {1, 0x02, 0x00, 8} }; static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, NULL }; static const SANE_String_Const adf_mode_list[] = { SANE_I18N ("Simplex"), SANE_I18N ("Duplex"), NULL }; /* * Define the different scan sources: */ #define FBF_STR SANE_I18N("Flatbed") #define TPU_STR SANE_I18N("Transparency Unit") #define ADF_STR SANE_I18N("Automatic Document Feeder") /* * source list need one dummy entry (save device settings is crashing). * NOTE: no const - this list gets created while exploring the capabilities * of the scanner. */ static SANE_String_Const source_list[] = { FBF_STR, NULL, NULL, NULL }; /* some defines to make handling the TPU easier: */ #define FILM_TYPE_POSITIVE (0) #define FILM_TYPE_NEGATIVE (1) static const SANE_String_Const film_list[] = { SANE_I18N ("Positive Film"), SANE_I18N ("Negative Film"), NULL }; static const SANE_String_Const focus_list[] = { SANE_I18N ("Focus on glass"), SANE_I18N ("Focus 2.5mm above glass"), NULL }; /* * TODO: add some missing const. */ #define HALFTONE_NONE 0x01 #define HALFTONE_TET 0x03 static int halftone_params[] = { HALFTONE_NONE, 0x00, 0x10, 0x20, 0x80, 0x90, 0xa0, 0xb0, HALFTONE_TET, 0xc0, 0xd0 }; static const SANE_String_Const halftone_list[] = { SANE_I18N ("None"), SANE_I18N ("Halftone A (Hard Tone)"), SANE_I18N ("Halftone B (Soft Tone)"), SANE_I18N ("Halftone C (Net Screen)"), NULL }; static const SANE_String_Const halftone_list_4[] = { SANE_I18N ("None"), SANE_I18N ("Halftone A (Hard Tone)"), SANE_I18N ("Halftone B (Soft Tone)"), SANE_I18N ("Halftone C (Net Screen)"), SANE_I18N ("Dither A (4x4 Bayer)"), SANE_I18N ("Dither B (4x4 Spiral)"), SANE_I18N ("Dither C (4x4 Net Screen)"), SANE_I18N ("Dither D (8x4 Net Screen)"), NULL }; static const SANE_String_Const halftone_list_7[] = { SANE_I18N ("None"), SANE_I18N ("Halftone A (Hard Tone)"), SANE_I18N ("Halftone B (Soft Tone)"), SANE_I18N ("Halftone C (Net Screen)"), SANE_I18N ("Dither A (4x4 Bayer)"), SANE_I18N ("Dither B (4x4 Spiral)"), SANE_I18N ("Dither C (4x4 Net Screen)"), SANE_I18N ("Dither D (8x4 Net Screen)"), SANE_I18N ("Text Enhanced Technology"), SANE_I18N ("Download pattern A"), SANE_I18N ("Download pattern B"), NULL }; static int dropout_params[] = { 0x00, /* none */ 0x10, /* red */ 0x20, /* green */ 0x30 /* blue */ }; static const SANE_String_Const dropout_list[] = { SANE_I18N ("None"), SANE_I18N ("Red"), SANE_I18N ("Green"), SANE_I18N ("Blue"), NULL }; /* * Color correction: * One array for the actual parameters that get sent to the scanner (color_params[]), * one array for the strings that get displayed in the user interface (color_list[]) * and one array to mark the user defined color correction (dolor_userdefined[]). */ static int color_params[] = { 0x00, 0x01, 0x10, 0x20, 0x40, 0x80 }; static SANE_Bool color_userdefined[] = { SANE_FALSE, SANE_TRUE, SANE_FALSE, SANE_FALSE, SANE_FALSE, SANE_FALSE }; static const SANE_String_Const color_list[] = { SANE_I18N ("No Correction"), SANE_I18N ("User defined"), SANE_I18N ("Impact-dot printers"), SANE_I18N ("Thermal printers"), SANE_I18N ("Ink-jet printers"), SANE_I18N ("CRT monitors"), NULL }; /* * Gamma correction: * The A and B level scanners work differently than the D level scanners, therefore * I define two different sets of arrays, plus one set of variables that get set to * the actally used params and list arrays at runtime. */ static int gamma_params_ab[] = { 0x01, 0x03, 0x00, 0x10, 0x20 }; static const SANE_String_Const gamma_list_ab[] = { SANE_I18N ("Default"), SANE_I18N ("User defined"), SANE_I18N ("High density printing"), SANE_I18N ("Low density printing"), SANE_I18N ("High contrast printing"), NULL }; static SANE_Bool gamma_userdefined_ab[] = { SANE_FALSE, SANE_TRUE, SANE_FALSE, SANE_FALSE, SANE_FALSE, }; static int gamma_params_d[] = { 0x03, 0x04 }; static const SANE_String_Const gamma_list_d[] = { SANE_I18N ("User defined (Gamma=1.0)"), SANE_I18N ("User defined (Gamma=1.8)"), NULL }; static SANE_Bool gamma_userdefined_d[] = { SANE_TRUE, SANE_TRUE }; static SANE_Bool *gamma_userdefined; static int *gamma_params; /* flaming hack to get USB scanners working without timeouts under linux */ /* (cribbed from fujitsu.c) */ static unsigned int r_cmd_count = 0; static unsigned int w_cmd_count = 0; /* Bay list: * this is used for the FilmScan */ static const SANE_String_Const bay_list[] = { " 1 ", " 2 ", " 3 ", " 4 ", " 5 ", " 6 ", NULL }; /* * minimum, maximum, quantization. */ static const SANE_Range u8_range = { 0, 255, 0 }; static const SANE_Range s8_range = { -127, 127, 0 }; static const SANE_Range zoom_range = { 50, 200, 0 }; /* * The "switch_params" are used for several boolean choices */ static int switch_params[] = { 0, 1 }; #define mirror_params switch_params #define speed_params switch_params #define film_params switch_params static const SANE_Range outline_emphasis_range = { -2, 2, 0 }; /* static const SANE_Range gamma_range = { -2, 2, 0 }; */ struct qf_param { SANE_Word tl_x; SANE_Word tl_y; SANE_Word br_x; SANE_Word br_y; }; /* gcc don't like to overwrite const field */ static /*const */ struct qf_param qf_params[] = { {0, 0, SANE_FIX (120.0), SANE_FIX (120.0)}, {0, 0, SANE_FIX (148.5), SANE_FIX (210.0)}, {0, 0, SANE_FIX (210.0), SANE_FIX (148.5)}, {0, 0, SANE_FIX (215.9), SANE_FIX (279.4)}, /* 8.5" x 11" */ {0, 0, SANE_FIX (210.0), SANE_FIX (297.0)}, {0, 0, 0, 0} }; static const SANE_String_Const qf_list[] = { SANE_I18N ("CD"), SANE_I18N ("A5 portrait"), SANE_I18N ("A5 landscape"), SANE_I18N ("Letter"), SANE_I18N ("A4"), SANE_I18N ("Max"), NULL }; static SANE_Word *bitDepthList = NULL; /* * List of pointers to devices - will be dynamically allocated depending * on the number of devices found. */ static const SANE_Device **devlist = 0; /* * Some utility functions */ static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; i++) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } typedef struct { u_char code; u_char status; u_char count1; u_char count2; u_char buf[1]; } EpsonHdrRec, *EpsonHdr; typedef struct { u_char code; u_char status; u_char count1; u_char count2; u_char type; u_char level; u_char buf[1]; } EpsonIdentRec, *EpsonIdent; typedef union { EpsonHdrRec hdr; EpsonIdentRec ident; } EpsonHdrUnionRec, *EpsonHdrUnion; typedef struct { u_char code; u_char status; u_short count; u_char buf[1]; } EpsonParameterRec, *EpsonParameter; typedef struct { u_char code; u_char status; u_char buf[4]; } EpsonDataRec, *EpsonData; /* * * */ static EpsonHdrUnion command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, SANE_Status * status); static SANE_Status get_identity_information (SANE_Handle handle); static SANE_Status get_identity2_information (SANE_Handle handle); static int send (Epson_Scanner * s, void *buf, size_t buf_size, SANE_Status * status); static ssize_t receive (Epson_Scanner * s, void *buf, ssize_t buf_size, SANE_Status * status); static SANE_Status color_shuffle (SANE_Handle handle, int *new_length); static SANE_Status request_focus_position (SANE_Handle handle, u_char * position); static SANE_Bool request_push_button_status (SANE_Handle handle, SANE_Bool * theButtonStatus); static void activateOption (Epson_Scanner * s, SANE_Int option, SANE_Bool * change); static void deactivateOption (Epson_Scanner * s, SANE_Int option, SANE_Bool * change); static void setOptionState (Epson_Scanner * s, SANE_Bool state, SANE_Int option, SANE_Bool * change); static void close_scanner (Epson_Scanner * s); static SANE_Status open_scanner (Epson_Scanner * s); SANE_Status sane_auto_eject (Epson_Scanner * s); static SANE_Status attach_one_usb (SANE_String_Const devname); static void filter_resolution_list (Epson_Scanner * s); static void get_size (char c1, char c2, double *w, double *h); static void scan_finish (Epson_Scanner * s); /* * * */ static int send (Epson_Scanner * s, void *buf, size_t buf_size, SANE_Status * status) { DBG (3, "send buf, size = %lu\n", (u_long) buf_size); #if 1 { unsigned int k; const u_char *s = buf; for (k = 0; k < buf_size; k++) { DBG (125, "buf[%d] %02x %c\n", k, s[k], isprint (s[k]) ? s[k] : '.'); } } #endif if (s->hw->connection == SANE_EPSON_SCSI) { return sanei_epson_scsi_write (s->fd, buf, buf_size, status); } else if (s->hw->connection == SANE_EPSON_PIO) { size_t n; if (buf_size == (n = sanei_pio_write (s->fd, buf, buf_size))) *status = SANE_STATUS_GOOD; else *status = SANE_STATUS_INVAL; return n; } else if (s->hw->connection == SANE_EPSON_USB) { size_t n; n = buf_size; *status = sanei_usb_write_bulk (s->fd, buf, &n); w_cmd_count++; DBG (5, "w_cmd_count = %d\n",w_cmd_count); DBG (5, "r_cmd_count = %d\n",r_cmd_count); return n; } return SANE_STATUS_INVAL; /* never reached */ } /* * * */ static ssize_t receive (Epson_Scanner * s, void *buf, ssize_t buf_size, SANE_Status * status) { ssize_t n = 0; if (s->hw->connection == SANE_EPSON_SCSI) { n = sanei_epson_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; } 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 (5, "w_cmd_count = %d\n",w_cmd_count); DBG (5, "r_cmd_count = %d\n",r_cmd_count); if (n > 0) *status = SANE_STATUS_GOOD; } DBG (7, "receive buf, expected = %lu, got = %ld\n", (u_long) buf_size, (long) n); #if 1 if (n > 0) { int k; const u_char *s = buf; for (k = 0; k < n; k++) { DBG (127, "buf[%d] %02x %c\n", k, s[k], isprint (s[k]) ? s[k] : '.'); } } #else { int i; ssize_t k; ssize_t hex_start = 0; const u_char *s = buf; char hex_str[NUM_OF_HEX_ELEMENTS * 3 + 1]; char tmp_str[NUM_OF_HEX_ELEMENTS * 3 + 1]; char ascii_str[NUM_OF_HEX_ELEMENTS * 2 + 1]; hex_str[0] = '\0'; ascii_str[0] = '\0'; for (k = 0; k < buf_size; k++) { /* write out the data in lines of 16 bytes */ /* add the next hex value to the hex string */ sprintf (tmp_str, "%s %02x", hex_str, s[k]); strcpy (hex_str, tmp_str); /* add the character to the ascii string */ sprintf (tmp_str, "%s %c", ascii_str, isprint (s[k]) ? s[k] : '.'); strcpy (ascii_str, tmp_str); if ((k % (NUM_OF_HEX_ELEMENTS)) == 0) { if (k != 0) /* don't do this the first time */ { for (i = strlen (hex_str); i < (NUM_OF_HEX_ELEMENTS * 3); i++) { hex_str[i] = ' '; } hex_str[NUM_OF_HEX_ELEMENTS + 1] = '\0'; DBG (125, "recv buf[%05d]: %s %s\n", hex_start, hex_str, ascii_str); hex_start = k; hex_str[0] = '\0'; ascii_str[0] = '\0'; } } } for (i = strlen (hex_str); i < NUM_OF_HEX_ELEMENTS * 3; i++) { hex_str[i] = ' '; } hex_str[NUM_OF_HEX_ELEMENTS + 1] = '\0'; DBG (125, "recv buf[%05d]: %s %s\n", hex_start, hex_str, ascii_str); } #endif return n; } /* * * */ static SANE_Status expect_ack (Epson_Scanner * s) { u_char result[1]; size_t len; SANE_Status status; len = sizeof (result); receive (s, result, len, &status); if (SANE_STATUS_GOOD != status) return status; if (ACK != result[0]) return SANE_STATUS_INVAL; return SANE_STATUS_GOOD; } /* * * */ static SANE_Status set_cmd (Epson_Scanner * s, u_char cmd, int val) { SANE_Status status; u_char params[2]; if (!cmd) return SANE_STATUS_UNSUPPORTED; params[0] = ESC; params[1] = cmd; send (s, params, 2, &status); if (SANE_STATUS_GOOD != (status = expect_ack (s))) return status; params[0] = val; send (s, params, 1, &status); status = expect_ack (s); return status; } /* A little helper function to correct the extended status reply gotten from scanners with known buggy firmware. */ static void fix_up_extended_status_reply (const char *model, u_char * buf) { if (0 == strncmp (model, "ES-9000H", strlen ("ES-9000H")) || 0 == strncmp (model, "GT-30000", strlen ("GT-30000"))) { DBG (1, "Fixing up buggy ADF max scan dimensions.\n"); buf[2] = 0xB0; buf[3] = 0x6D; buf[4] = 0x60; buf[5] = 0x9F; } } static void print_params (const SANE_Parameters params) { DBG (5, "params.format = %d\n", params.format); DBG (5, "params.last_frame = %d\n", params.last_frame); DBG (5, "params.bytes_per_line = %d\n", params.bytes_per_line); DBG (5, "params.pixels_per_line = %d\n", params.pixels_per_line); DBG (5, "params.lines = %d\n", params.lines); DBG (5, "params.depth = %d\n", params.depth); } /* * * */ #define set_focus_position(s,v) set_cmd( s,(s)->hw->cmd->set_focus_position,v) #define set_color_mode(s,v) set_cmd( s,(s)->hw->cmd->set_color_mode,v) #define set_data_format(s,v) set_cmd( s,(s)->hw->cmd->set_data_format, v) #define set_halftoning(s,v) set_cmd( s,(s)->hw->cmd->set_halftoning, v) #define set_gamma(s,v) set_cmd( s,(s)->hw->cmd->set_gamma, v) #define set_color_correction(s,v) set_cmd( s,(s)->hw->cmd->set_color_correction, v) #define set_lcount(s,v) set_cmd( s,(s)->hw->cmd->set_lcount, v) #define set_bright(s,v) set_cmd( s,(s)->hw->cmd->set_bright, v) #define mirror_image(s,v) set_cmd( s,(s)->hw->cmd->mirror_image, v) #define set_speed(s,v) set_cmd( s,(s)->hw->cmd->set_speed, v) #define set_outline_emphasis(s,v) set_cmd( s,(s)->hw->cmd->set_outline_emphasis, v) #define control_auto_area_segmentation(s,v) set_cmd( s,(s)->hw->cmd->control_auto_area_segmentation, v) #define set_film_type(s,v) set_cmd( s,(s)->hw->cmd->set_film_type, v) #define set_exposure_time(s,v) set_cmd( s,(s)->hw->cmd->set_exposure_time, v) #define set_bay(s,v) set_cmd( s,(s)->hw->cmd->set_bay, v) #define set_threshold(s,v) set_cmd( s,(s)->hw->cmd->set_threshold, v) #define control_extension(s,v) set_cmd( s,(s)->hw->cmd->control_an_extension, v) /*#define (s,v) set_cmd( s,(s)->hw->cmd->, v) */ static SANE_Status set_zoom (Epson_Scanner * s, int x_zoom, int y_zoom) { SANE_Status status; u_char cmd[2]; u_char params[2]; if (!s->hw->cmd->set_zoom) return SANE_STATUS_GOOD; cmd[0] = ESC; cmd[1] = s->hw->cmd->set_zoom; send (s, cmd, 2, &status); status = expect_ack (s); if (status != SANE_STATUS_GOOD) return status; params[0] = x_zoom; params[1] = y_zoom; send (s, params, 2, &status); status = expect_ack (s); return status; } static SANE_Status set_resolution (Epson_Scanner * s, int xres, int yres) { SANE_Status status; u_char params[4]; if (!s->hw->cmd->set_resolution) return SANE_STATUS_GOOD; params[0] = ESC; params[1] = s->hw->cmd->set_resolution; send (s, params, 2, &status); status = expect_ack (s); if (status != SANE_STATUS_GOOD) return status; params[0] = xres; params[1] = xres >> 8; params[2] = yres; params[3] = yres >> 8; send (s, params, 4, &status); status = expect_ack (s); return status; } /* * set_scan_area() * * Sends the "set scan area" command to the scanner with the currently selected * scan area. This scan area is already corrected for "color shuffling" if * necessary. */ static SANE_Status set_scan_area (Epson_Scanner * s, int x, int y, int width, int height) { SANE_Status status; u_char params[8]; DBG (1, "set_scan_area: %p %d %d %d %d\n", (void *) s, x, y, width, height); if (!s->hw->cmd->set_scan_area) { DBG (1, "set_scan_area not supported\n"); return SANE_STATUS_GOOD; } /* verify the scan area */ if (x < 0 || y < 0 || width <= 0 || height <= 0) return SANE_STATUS_INVAL; params[0] = ESC; params[1] = s->hw->cmd->set_scan_area; send (s, params, 2, &status); status = expect_ack (s); if (status != SANE_STATUS_GOOD) return status; params[0] = x; params[1] = x >> 8; params[2] = y; params[3] = y >> 8; params[4] = width; params[5] = width >> 8; params[6] = height; params[7] = height >> 8; send (s, params, 8, &status); status = expect_ack (s); return status; } /* * set_color_correction_coefficients() * * Sends the "set color correction coefficients" command with the currently selected * parameters to the scanner. */ static SANE_Status set_color_correction_coefficients (Epson_Scanner * s) { SANE_Status status; u_char cmd = s->hw->cmd->set_color_correction_coefficients; u_char params[2]; const int length = 9; signed char cct[9]; DBG (1, "set_color_correction_coefficients: starting.\n"); if (!cmd) return SANE_STATUS_UNSUPPORTED; params[0] = ESC; params[1] = cmd; send (s, params, 2, &status); if (SANE_STATUS_GOOD != (status = expect_ack (s))) return status; cct[0] = s->val[OPT_CCT_1].w; cct[1] = s->val[OPT_CCT_2].w; cct[2] = s->val[OPT_CCT_3].w; cct[3] = s->val[OPT_CCT_4].w; cct[4] = s->val[OPT_CCT_5].w; cct[5] = s->val[OPT_CCT_6].w; cct[6] = s->val[OPT_CCT_7].w; cct[7] = s->val[OPT_CCT_8].w; cct[8] = s->val[OPT_CCT_9].w; DBG (1, "set_color_correction_coefficients: %d,%d,%d %d,%d,%d %d,%d,%d.\n", cct[0], cct[1], cct[2], cct[3], cct[4], cct[5], cct[6], cct[7], cct[8]); send (s, cct, length, &status); status = expect_ack (s); DBG (1, "set_color_correction_coefficients: ending=%d.\n", status); return status; } /* * * */ static SANE_Status set_gamma_table (Epson_Scanner * s) { SANE_Status status; u_char cmd = s->hw->cmd->set_gamma_table; u_char params[2]; const int length = 257; u_char gamma[257]; int n; int table; /* static const char gamma_cmds[] = { 'M', 'R', 'G', 'B' }; */ static const char gamma_cmds[] = { 'R', 'G', 'B' }; DBG (1, "set_gamma_table: starting.\n"); if (!cmd) return SANE_STATUS_UNSUPPORTED; params[0] = ESC; params[1] = cmd; /* * Print the gamma tables before sending them to the scanner. */ if (DBG_LEVEL > 0) { int c, i, j; DBG (1, "set_gamma_table()\n"); for (c = 0; c < 3; c++) { for (i = 0; i < 256; i += 16) { char gammaValues[16 * 3 + 1], newValue[4]; gammaValues[0] = '\0'; for (j = 0; j < 16; j++) { sprintf (newValue, " %02x", s->gamma_table[c][i + j]); strcat (gammaValues, newValue); } DBG (10, "Gamma Table[%d][%d] %s\n", c, i, gammaValues); } } } /* * TODO: &status in send makes no sense like that. */ /* * When handling inverted images, we must also invert the user * supplied gamma function. This is *not* just 255-gamma - * this gives a negative image. */ for (table = 0; table < 3; table++) { gamma[0] = gamma_cmds[table]; if (s->invert_image) { for (n = 0; n < 256; ++n) { gamma[n + 1] = 255 - s->gamma_table[table][255 - n]; } } else { for (n = 0; n < 256; ++n) { gamma[n + 1] = s->gamma_table[table][n]; } } send (s, params, 2, &status); if (SANE_STATUS_GOOD != (status = expect_ack (s))) return status; send (s, gamma, length, &status); if (SANE_STATUS_GOOD != (status = expect_ack (s))) return status; } DBG (1, "set_gamma_table: complete = %d.\n", status); return status; } void get_size (char c1, char c2, double *w, double *h) { int ind; unsigned char flag; double wsizetbl[] = { 11.60, /* A3V */ 11.00, /* WLT */ 10.12, /* B4V */ 8.50, /* LGV */ 8.27, /* A4V */ 11.69, /* A4H */ 8.50, /* LTV */ 11.00, /* LTH */ 7.17, /* B5V */ 10.12, /* B5H */ 5.83, /* A5V */ 8.27, /* A5H */ 7.25, /* EXV */ 10.50, /* EXH */ 11.69, /* unknown */ 11.69, /* unknown */ 11.69, /* unknown */ }; double hsizetbl[] = { 16.54, /* A3V */ 17.00, /* WLT */ 14.33, /* B4V */ 14.00, /* LGV */ 11.69, /* A4V */ 8.27, /* A4H */ 11.00, /* LTV */ 8.50, /* LTH */ 10.12, /* B5V */ 7.17, /* B5H */ 8.27, /* A5V */ 5.83, /* A5H */ 10.50, /* EXV */ 7.25, /* EXH */ 17.00, /* unknown */ 17.00, /* unknown */ 17.00, /* unknown */ }; flag = c1; for (ind = 0; ind < 8; ind++) { if (flag & 0x80) goto DetectSize; flag = flag << 1; } flag = c2; for (; ind < 16; ind++) { if (flag & 0x80) goto DetectSize; flag = flag << 1; } DetectSize: *w = wsizetbl[ind]; *h = hsizetbl[ind]; DBG (10, "detected width: %f\n", *w); DBG (10, "detected height: %f\n", *h); } /* * check_ext_status() * * Requests the extended status flag from the scanner. The "warming up" condition * is reported as a warning (only visible if debug level is set to 10 or greater) - * every other condition is reported as an error. * * This function only gets called when we are dealing with a scanner that supports the * "warming up" code, so it's not a problem for B3 level scanners, that don't handle * request extended status commands. */ static SANE_Status check_ext_status (Epson_Scanner * s, int *max_x, int *max_y) { SANE_Status status; u_char cmd = s->hw->cmd->request_extended_status; u_char params[2]; u_char *buf; EpsonHdr head; *max_x = 0; *max_y = 0; if (cmd == 0) return SANE_STATUS_UNSUPPORTED; params[0] = ESC; params[1] = cmd; head = (EpsonHdr) command (s, params, 2, &status); if (NULL == head) { DBG (1, "Extended status flag request failed\n"); return status; } buf = &head->buf[0]; if (buf[0] & EXT_STATUS_WU) { DBG (10, "option: warming up\n"); status = SANE_STATUS_DEVICE_BUSY; } if (buf[0] & EXT_STATUS_FER) { DBG (1, "option: fatal error\n"); status = SANE_STATUS_INVAL; } if (s->hw->ADF && s->hw->use_extension && s->hw->cmd->feed) { fix_up_extended_status_reply (s->hw->sane.model, buf); *max_x = buf[3] << 8 | buf[2]; *max_y = buf[5] << 8 | buf[4]; if (0 == strcmp ("ES-9000H", s->hw->sane.model) || 0 == strcmp ("GT-30000", s->hw->sane.model)) { /* set size of current sheet, but don't clobber zoom settings (which should always be smaller than the detected sheet size) */ double w, h; get_size (buf[16], buf[17], &w, &h); w = SANE_FIX (w * MM_PER_INCH); h = SANE_FIX (h * MM_PER_INCH); if (w < s->val[OPT_BR_X].w) s->val[OPT_BR_X].w = w; if (h < s->val[OPT_BR_Y].w) s->val[OPT_BR_Y].w = h; } } if (buf[1] & EXT_STATUS_ERR) { DBG (1, "ADF: other error\n"); status = SANE_STATUS_INVAL; } if (buf[1] & EXT_STATUS_PE) { DBG (1, "ADF: no paper\n"); status = SANE_STATUS_NO_DOCS; return status; } if (buf[1] & EXT_STATUS_PJ) { DBG (1, "ADF: paper jam\n"); status = SANE_STATUS_JAMMED; } if (buf[1] & EXT_STATUS_OPN) { DBG (1, "ADF: cover open\n"); status = SANE_STATUS_COVER_OPEN; } if (buf[6] & EXT_STATUS_ERR) { DBG (1, "TPU: other error\n"); status = SANE_STATUS_INVAL; } /* return the max. scan area for the ADF */ if (buf[6] & EXT_STATUS_IST) { *max_x = buf[8] << 8 | buf[7]; *max_y = buf[10] << 8 | buf[9]; } /* return the max. scan area for the flatbed */ if (s->hw->devtype == 3 && s->hw->use_extension == 0) { double w, h; get_size (buf[18], buf[19], &w, &h); *max_x = (int) (w * s->hw->dpi_range.max); *max_y = (int) (h * s->hw->dpi_range.max); } free (head); return status; } /* * reset() * * Send the "initialize scanner" command to the device and reset it. * */ static SANE_Status reset (Epson_Scanner * s) { SANE_Status status; u_char param[2]; SANE_Bool needToClose = SANE_FALSE; DBG (5, "reset()\n"); if (!s->hw->cmd->initialize_scanner) return SANE_STATUS_GOOD; param[0] = ESC; param[1] = s->hw->cmd->initialize_scanner; if (s->fd == -1) { needToClose = SANE_TRUE; DBG (5, "reset calling open_scanner\n"); if ((status = open_scanner (s)) != SANE_STATUS_GOOD) return status; } send (s, param, 2, &status); status = expect_ack (s); if (needToClose) { close_scanner (s); } return status; } /* * close_scanner() * * Close the open scanner. Depending on the connection method, a different * close function is called. */ static void close_scanner (Epson_Scanner * s) { DBG (5, "close_scanner(fd = %d)\n", s->fd); if (s->fd == -1) return; if (r_cmd_count % 2) { /* send a request_status. This toggles w_cmd_count and r_cmd_count */ u_char param[3]; u_char result[5]; SANE_Status status; param[0] = ESC; param[1] = s->hw->cmd->request_status; param[2]='\0'; send(s,param,2,&status); receive(s,result,4,&status); } DBG (5, "w_cmd_count = %d\n",w_cmd_count); DBG (5, "r_cmd_count = %d\n",r_cmd_count); if (w_cmd_count % 2) { int junk1,junk2; /* check extended status. This toggles w_cmd_count%2 only */ check_ext_status (s,&junk1,&junk2); } DBG (5, "w_cmd_count = %d\n",w_cmd_count); DBG (5, "r_cmd_count = %d\n",r_cmd_count); if (s->hw->connection == SANE_EPSON_SCSI) { sanei_scsi_close (s->fd); } else if (s->hw->connection == SANE_EPSON_PIO) { sanei_pio_close (s->fd); } else if (s->hw->connection == SANE_EPSON_USB) { sanei_usb_close (s->fd); } s->fd = -1; return; } /* * open_scanner() * * Open the scanner device. Depending on the connection method, * different open functions are called. */ static SANE_Status open_scanner (Epson_Scanner * s) { SANE_Status status = 0; DBG (5, "open_scanner()\n"); if (s->fd != -1) { DBG (5, "scanner is already open: fd = %d\n", s->fd); return SANE_STATUS_GOOD; /* no need to open the scanner */ } /* don't do this for OS2: */ #ifndef HAVE_OS2_H #if 0 /* test the device name */ if ((s->hw->connection != SANE_EPSON_PIO) && (access (s->hw->sane.name, R_OK | W_OK) != 0)) { DBG (1, "sane_start: access(%s, R_OK | W_OK) failed\n", s->hw->sane.name); return SANE_STATUS_ACCESS_DENIED; } #endif #endif if (s->hw->connection == SANE_EPSON_SCSI) { status = sanei_scsi_open (s->hw->sane.name, &s->fd, sanei_epson_scsi_sense_handler, NULL); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: %s open failed: %s\n", s->hw->sane.name, sane_strstatus (status)); return status; } } else if (s->hw->connection == SANE_EPSON_PIO) { status = sanei_pio_open (s->hw->sane.name, &s->fd); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: %s open failed: %s\n", s->hw->sane.name, sane_strstatus (status)); return status; } } else if (s->hw->connection == SANE_EPSON_USB) { status = sanei_usb_open (s->hw->sane.name, &s->fd); return status; } return SANE_STATUS_GOOD; } /* * feed ( ) */ static SANE_Status feed (Epson_Scanner * s) { SANE_Status status; u_char params[2]; u_char cmd = s->hw->cmd->feed; DBG (5, "feed()\n"); if (!cmd) { DBG (5, "feed() is not supported\n"); return SANE_STATUS_UNSUPPORTED; } params[0] = cmd; send (s, params, 1, &status); if (SANE_STATUS_GOOD != (status = expect_ack (s))) { close_scanner (s); return status; } return status; } /* * eject() * * Eject the current page from the ADF. The scanner is opened prior to * sending the command and closed afterwards. * */ static SANE_Status eject (Epson_Scanner * s) { SANE_Status status; u_char params[2]; u_char cmd = s->hw->cmd->eject; SANE_Bool needToClose = SANE_FALSE; DBG (5, "eject()\n"); if (!cmd) return SANE_STATUS_UNSUPPORTED; if (s->fd == -1) { needToClose = SANE_TRUE; if (SANE_STATUS_GOOD != (status = open_scanner (s))) return status; } params[0] = cmd; send (s, params, 1, &status); if (SANE_STATUS_GOOD != (status = expect_ack (s))) { close_scanner (s); return status; } if (needToClose) close_scanner (s); return status; } /* * * */ static int num_devices = 0; /* number of EPSON scanners attached to backend */ static Epson_Device *first_dev = NULL; /* first EPSON scanner in list */ static Epson_Scanner *first_handle = NULL; static EpsonHdrUnion command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, SANE_Status * status) { EpsonHdrUnion hdrunion, hdrunion_bak; EpsonHdr head; u_char *buf; int count; if (NULL == (hdrunion = walloc (EpsonHdrUnionRec))) { DBG (1, "out of memory (line %d)\n", __LINE__); *status = SANE_STATUS_NO_MEM; return (EpsonHdrUnion) 0; } head = &(hdrunion->hdr); send (s, cmd, cmd_size, status); if (SANE_STATUS_GOOD != *status) { /* this is necessary for the GT-8000. I don't know why, but it seems to fix the problem. It should not have any ill effects on other scanners. */ *status = SANE_STATUS_GOOD; send (s, cmd, cmd_size, status); if (SANE_STATUS_GOOD != *status) return (EpsonHdrUnion) 0; } buf = (u_char *) head; if (s->hw->connection == SANE_EPSON_SCSI) { receive (s, buf, 4, status); buf += 4; } else if (s->hw->connection == SANE_EPSON_USB) { int bytes_read; bytes_read = receive (s, buf, 4, status); buf += bytes_read; } else { receive (s, buf, 1, status); buf += 1; } if (SANE_STATUS_GOOD != *status) return (EpsonHdrUnion) 0; DBG (4, "code %02x\n", (int) head->code); switch (head->code) { case NAK: /* fall through */ /* !!! is this really sufficient to report an error ? */ case ACK: break; /* no need to read any more data after ACK or NAK */ case STX: if (s->hw->connection == SANE_EPSON_SCSI) { /* nope */ } else if (s->hw->connection == SANE_EPSON_USB) { /* we've already read the complete data */ } else { receive (s, buf, 3, status); /* buf += 3; */ } if (SANE_STATUS_GOOD != *status) return (EpsonHdrUnion) 0; DBG (4, "status %02x\n", (int) head->status); count = head->count2 * 255 + head->count1; DBG (4, "count %d\n", count); hdrunion_bak = hdrunion; if (NULL == (hdrunion = realloc (hdrunion, sizeof (EpsonHdrUnionRec) + count))) { free(hdrunion_bak); DBG (1, "out of memory (line %d)\n", __LINE__); *status = SANE_STATUS_NO_MEM; return (EpsonHdrUnion) 0; } head = &(hdrunion->hdr); buf = head->buf; receive (s, buf, count, status); if (SANE_STATUS_GOOD != *status) return (EpsonHdrUnion) 0; break; default: if (0 == head->code) DBG (1, "Incompatible printer port (probably bi/directional)\n"); else if (cmd[cmd_size - 1] == head->code) DBG (1, "Incompatible printer port (probably not bi/directional)\n"); DBG (2, "Illegal response of scanner for command: %02x\n", head->code); break; } return hdrunion; } /* * static SANE_Status attach() * * Attach one device with name *dev_name to the backend. */ static SANE_Status attach (const char *dev_name, Epson_Device * *devp, int type) { SANE_Status status; Epson_Scanner *s = walloca (Epson_Scanner); char *str; struct Epson_Device *dev; SANE_String_Const *source_list_add = source_list; int port; DBG (1, "%s\n", SANE_EPSON_VERSION); DBG (5, "attach(%s, %d)\n", dev_name, type); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, dev_name) == 0) { if (devp) { *devp = dev; } return SANE_STATUS_GOOD; } } dev = malloc (sizeof (*dev)); if (!dev) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } /* check for PIO devices */ /* can we convert the device name to an integer? This is only possible with PIO devices */ port = atoi (dev_name); if (port != 0) { type = SANE_EPSON_PIO; } if (strncmp (dev_name, SANE_EPSON_CONFIG_PIO, strlen (SANE_EPSON_CONFIG_PIO)) == 0) { /* we have a match for the PIO string and adjust the device name */ dev_name += strlen (SANE_EPSON_CONFIG_PIO); dev_name = sanei_config_skip_whitespace (dev_name); type = SANE_EPSON_PIO; } /* * set dummy values. */ s->hw = dev; s->hw->sane.name = NULL; s->hw->sane.type = "flatbed scanner"; s->hw->sane.vendor = "Epson"; s->hw->sane.model = NULL; s->hw->optical_res = 0; /* just to have it initialized */ s->hw->color_shuffle = SANE_FALSE; s->hw->extension = SANE_FALSE; s->hw->use_extension = SANE_FALSE; s->hw->need_color_reorder = SANE_FALSE; s->hw->need_double_vertical = SANE_FALSE; s->hw->cmd = &epson_cmd[EPSON_LEVEL_DEFAULT]; /* default function level */ s->hw->connection = type; DBG (3, "attach: opening %s\n", dev_name); s->hw->last_res = 0; s->hw->last_res_preview = 0; /* set resolution to safe values */ /* * decide if interface is USB, SCSI or parallel. */ /* * if interface is SCSI do an inquiry. */ if (s->hw->connection == SANE_EPSON_SCSI) { u_char buf[INQUIRY_BUF_SIZE + 1]; size_t buf_size = INQUIRY_BUF_SIZE; status = sanei_scsi_open (dev_name, &s->fd, sanei_epson_scsi_sense_handler, NULL); if (SANE_STATUS_GOOD != status) { DBG (1, "attach: open failed: %s\n", sane_strstatus (status)); return status; } DBG (3, "attach: sending INQUIRY\n"); status = sanei_epson_scsi_inquiry (s->fd, 0, buf, &buf_size); if (SANE_STATUS_GOOD != status) { DBG (1, "attach: inquiry failed: %s\n", sane_strstatus (status)); close_scanner (s); return status; } buf[INQUIRY_BUF_SIZE] = 0; DBG (1, ">%s<\n", buf + 8); /* * For USB and PIO scanners this will be done later, once * we have communication established with the device. */ if (buf[0] != TYPE_PROCESSOR || strncmp ((char *) (buf + 8), "EPSON", 5) != 0 || (strncmp ((char *) buf + 16, "SCANNER ", 8) != 0 && strncmp ((char *) buf + 14, "SCANNER ", 8) != 0 && strncmp ((char *) buf + 14, "Perfection", 10) != 0 && strncmp ((char *) buf + 16, "Perfection", 10) != 0 && strncmp ((char *) buf + 16, "Expression", 10) != 0 && strncmp ((char *) buf + 16, "GT", 2) != 0)) { DBG (1, "attach: device doesn't look like an EPSON scanner\n"); close_scanner (s); return SANE_STATUS_INVAL; } } /* use the SANEI functions to handle a PIO device */ else if (s->hw->connection == SANE_EPSON_PIO) { if (SANE_STATUS_GOOD != (status = sanei_pio_open (dev_name, &s->fd))) { DBG (1, "Cannot open %s as a parallel-port device: %s\n", dev_name, sane_strstatus (status)); return status; } } /* use the SANEI functions to handle a USB device */ else if (s->hw->connection == SANE_EPSON_USB) { SANE_Word vendor; SANE_Word product; SANE_Bool isLibUSB; isLibUSB = (strncmp (dev_name, "libusb:", strlen ("libusb:")) == 0); if ((!isLibUSB) && (strlen (dev_name) == 0)) { int i; int numIds; numIds = sanei_epson_getNumberOfUSBProductIds (); for (i = 0; i < numIds; i++) { product = sanei_epson_usb_product_ids[i]; vendor = 0x4b8; status = sanei_usb_find_devices (vendor, product, attach_one_usb); } return SANE_STATUS_INVAL; /* return - the attach_one_usb() will take care of this */ } status = sanei_usb_open (dev_name, &s->fd); if (SANE_STATUS_GOOD != status) { return status; } /* if the sanei_usb_get_vendor_product call is not supported, then we just ignore this and rely on the user to config the correct device. */ if (sanei_usb_get_vendor_product (s->fd, &vendor, &product) == SANE_STATUS_GOOD) { int i; /* loop variable */ int numIds; SANE_Bool is_valid; /* check the vendor ID to see if we are dealing with an EPSON device */ if (vendor != SANE_EPSON_VENDOR_ID) { /* this is not a supported vendor ID */ DBG (1, "The device at %s is not manufactured by EPSON (vendor id=0x%x)\n", dev_name, vendor); sanei_usb_close (s->fd); s->fd = -1; return SANE_STATUS_INVAL; } numIds = sanei_epson_getNumberOfUSBProductIds (); is_valid = SANE_FALSE; i = 0; /* check all known product IDs to verify that we know about the device */ while (i != numIds && !is_valid) { if (product == sanei_epson_usb_product_ids[i]) is_valid = SANE_TRUE; i++; } if (is_valid == SANE_FALSE) { DBG (1, "The device at %s is not a supported EPSON scanner (product id=0x%x)\n", dev_name, product); sanei_usb_close (s->fd); s->fd = -1; return SANE_STATUS_INVAL; } DBG (1, "Found valid EPSON scanner: 0x%x/0x%x (vendorID/productID)\n", vendor, product); } else { DBG (1, "Cannot use IOCTL interface to verify that device is a scanner - will continue\n"); } } /* * Initialize the scanner (ESC @). */ reset (s); /* * Identification Request (ESC I). */ if (s->hw->cmd->request_identity != 0) { status = get_identity_information (s); if (status != SANE_STATUS_GOOD) return status; } /* request identity */ /* * Check for "Request Identity 2" command. If this command is available * get the information from the scanner and store it in dev */ if (s->hw->cmd->request_identity2 != 0) { status = get_identity2_information (s); if (status != SANE_STATUS_GOOD) return status; } /* request identity 2 */ /* * Check for the max. supported color depth and assign * the values to the bitDepthList. */ bitDepthList = malloc (sizeof (SANE_Word) * 4); if (bitDepthList == NULL) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } bitDepthList[0] = 1; /* we start with one element in the list */ bitDepthList[1] = 8; /* 8bit is the default */ if (set_data_format (s, 16) == SANE_STATUS_GOOD) { s->hw->maxDepth = 16; bitDepthList[0]++; bitDepthList[bitDepthList[0]] = 16; } else if (set_data_format (s, 14) == SANE_STATUS_GOOD) { s->hw->maxDepth = 14; bitDepthList[0]++; bitDepthList[bitDepthList[0]] = 14; } else if (set_data_format (s, 12) == SANE_STATUS_GOOD) { s->hw->maxDepth = 12; bitDepthList[0]++; bitDepthList[bitDepthList[0]] = 12; } else { s->hw->maxDepth = 8; /* the default depth is already in the list */ } DBG (1, "Max. supported color depth = %d\n", s->hw->maxDepth); /* * Check for "request focus position" command. If this command is * supported, then the scanner does also support the "set focus * position" command. */ if (request_focus_position (s, &s->currentFocusPosition) == SANE_STATUS_GOOD) { DBG (1, "Enabling 'Set Focus' support\n"); s->hw->focusSupport = SANE_TRUE; s->opt[OPT_FOCUS].cap &= ~SANE_CAP_INACTIVE; /* reflect the current focus position in the GUI */ if (s->currentFocusPosition < 0x4C) { /* focus on glass */ s->val[OPT_FOCUS].w = 0; } else { /* focus 2.5mm above glass */ s->val[OPT_FOCUS].w = 1; } } else { DBG (1, "Disabling 'Set Focus' support\n"); s->hw->focusSupport = SANE_FALSE; s->opt[OPT_FOCUS].cap |= SANE_CAP_INACTIVE; s->val[OPT_FOCUS].w = 0; /* on glass - just in case */ } /* * Set defaults for no extension. */ dev->x_range = &dev->fbf_x_range; dev->y_range = &dev->fbf_y_range; /* * Correct for a firmware bug in some Perfection 1650 scanners: * Firmware version 1.08 reports only half the vertical scan area, we have * to double the number. To find out if we have to do this, we just compare * is the vertical range is smaller than the horizontal range. */ if ((dev->x_range->max - dev->x_range->min) > (dev->y_range->max - dev->y_range->min)) { dev->y_range->max += (dev->y_range->max - dev->y_range->min); dev->need_double_vertical = SANE_TRUE; dev->need_color_reorder = SANE_TRUE; } /* * Extended status flag request (ESC f). * this also requests the scanner device name from the scanner */ /* * because we are also using the device name from this command, * we have to run this block even if the scanner does not report * an extension. The extensions are only reported if the ADF or * the TPU are actually detected. */ if (s->hw->cmd->request_extended_status != 0) { u_char *buf; u_char params[2]; EpsonHdr head; params[0] = ESC; params[1] = s->hw->cmd->request_extended_status; if (NULL == (head = (EpsonHdr) command (s, params, 2, &status))) { DBG (1, "Extended status flag request failed\n"); dev->sane.model = strdup ("Unknown model"); *source_list_add++ = FBF_STR; } else { buf = &head->buf[0]; /* * Add the flatbed option to the source list */ *source_list_add++ = FBF_STR; s->hw->devtype = buf[11] >> 6; /* * Get the device name and copy it to dev->sane.model. * The device name starts at buf[0x1A] and is up to 16 bytes long * We are overwriting whatever was set previously! */ { char device_name[DEVICE_NAME_LEN + 1]; char *end_ptr; int len; /* make sure that the end of string is marked */ device_name[DEVICE_NAME_LEN] = '\0'; /* copy the string to an area where we can work with it */ memcpy (device_name, buf + 0x1A, DEVICE_NAME_LEN); end_ptr = strchr (device_name, ' '); if (end_ptr != NULL) { *end_ptr = '\0'; } len = strlen (device_name); str = malloc (len + 1); str[len] = '\0'; dev->sane.model = (char *) memcpy (str, device_name, len); } /* * ADF */ if (dev->extension && (buf[1] & EXT_STATUS_IST)) { DBG (1, "ADF detected\n"); /* the GT-30000 does not report the ADF scan area */ if ((strcmp (dev->sane.model, "GT-30000") == 0) || (strcmp (dev->sane.model, "ES-9000H") == 0)) { fix_up_extended_status_reply ((const char *) buf + 26, buf); dev->duplexSupport = (buf[0] & 0x10) != 0; if (dev->duplexSupport) { DBG (1, "Found DUPLEX ADF\n"); } } if (buf[1] & EXT_STATUS_EN) { DBG (1, "ADF is enabled\n"); dev->x_range = &dev->adf_x_range; dev->y_range = &dev->adf_y_range; } dev->adf_x_range.min = 0; dev->adf_x_range.max = SANE_FIX ((buf[3] << 8 | buf[2]) * 25.4 / dev->dpi_range.max); dev->adf_x_range.quant = 0; dev->adf_max_x = buf[3] << 8 | buf[2]; dev->adf_y_range.min = 0; dev->adf_y_range.max = SANE_FIX ((buf[5] << 8 | buf[4]) * 25.4 / dev->dpi_range.max); dev->adf_y_range.quant = 0; dev->adf_max_y = buf[5] << 8 | buf[4]; DBG (5, "adf tlx %f tly %f brx %f bry %f [mm]\n", SANE_UNFIX (dev->adf_x_range.min), SANE_UNFIX (dev->adf_y_range.min), SANE_UNFIX (dev->adf_x_range.max), SANE_UNFIX (dev->adf_y_range.max)); *source_list_add++ = ADF_STR; dev->ADF = SANE_TRUE; } /* * TPU */ if (dev->extension && (buf[6] & EXT_STATUS_IST)) { DBG (1, "TPU detected\n"); if (buf[6] & EXT_STATUS_EN) { DBG (1, "TPU is enabled\n"); dev->x_range = &dev->tpu_x_range; dev->y_range = &dev->tpu_y_range; } dev->tpu_x_range.min = 0; dev->tpu_x_range.max = SANE_FIX ((buf[8] << 8 | buf[7]) * 25.4 / dev->dpi_range.max); dev->tpu_x_range.quant = 0; dev->tpu_y_range.min = 0; dev->tpu_y_range.max = SANE_FIX ((buf[10] << 8 | buf[9]) * 25.4 / dev->dpi_range.max); dev->tpu_y_range.quant = 0; /* * Check for Perfection 4990 photo/GT-X800 scanner. * This scanner only report 3200 dpi back. * The scanner fysical supports 4800 dpi. * This is simulated here... * Futher details read: * EPSON Programming guide for EPSON Color Image Scanner Perfection 4990 */ if (strncmp((char *) buf + 0x1A,"GT-X800",7) == 0) { dev->tpu_x_range.max = (dev->tpu_x_range.max/32)*48; dev->tpu_y_range.max = (dev->tpu_y_range.max/32)*48; DBG (5, "dpi_range.max %x \n", dev->dpi_range.max); } DBG (5, "tpu tlx %f tly %f brx %f bry %f [mm]\n", SANE_UNFIX (dev->tpu_x_range.min), SANE_UNFIX (dev->tpu_y_range.min), SANE_UNFIX (dev->tpu_x_range.max), SANE_UNFIX (dev->tpu_y_range.max)); *source_list_add++ = TPU_STR; dev->TPU = SANE_TRUE; } /* * Get the device name and copy it to dev->sane.model. * The device name starts at buf[0x1A] and is up to 16 bytes long * We are overwriting whatever was set previously! */ { char device_name[DEVICE_NAME_LEN + 1]; char *end_ptr; int len; /* make sure that the end of string is marked */ device_name[DEVICE_NAME_LEN] = '\0'; /* copy the string to an area where we can work with it */ memcpy (device_name, buf + 0x1A, DEVICE_NAME_LEN); end_ptr = strchr (device_name, ' '); if (end_ptr != NULL) { *end_ptr = '\0'; } len = strlen (device_name); str = malloc (len + 1); str[len] = '\0'; /* finally copy the device name to the structure */ dev->sane.model = (char *) memcpy (str, device_name, len); } } } else /* command is not known */ { dev->sane.model = strdup ("EPSON Scanner"); } *source_list_add = NULL; /* add end marker to source list */ DBG (1, "scanner model: %s\n", dev->sane.model); /* establish defaults */ s->hw->need_reset_on_source_change = SANE_FALSE; if (strcmp ("ES-9000H", dev->sane.model) == 0 || strcmp ("GT-30000", dev->sane.model) == 0) { s->hw->cmd->set_focus_position = 0; s->hw->cmd->feed = 0x19; } else if (strcmp ("GT-8200", dev->sane.model) == 0 || strcmp ("Perfection1650", dev->sane.model) == 0 || strcmp ("Perfection1640", dev->sane.model) == 0 || strcmp ("GT-8700", dev->sane.model) == 0) { s->hw->cmd->feed = 0; s->hw->cmd->set_focus_position = 0; s->hw->need_reset_on_source_change = SANE_TRUE; } /* * Set values for quick format "max" entry. */ qf_params[XtNumber (qf_params) - 1].tl_x = dev->x_range->min; qf_params[XtNumber (qf_params) - 1].tl_y = dev->y_range->min; qf_params[XtNumber (qf_params) - 1].br_x = dev->x_range->max; qf_params[XtNumber (qf_params) - 1].br_y = dev->y_range->max; /* * Now we can finally set the device name: */ str = malloc (strlen (dev_name) + 1); dev->sane.name = strcpy (str, dev_name); close_scanner (s); /* * we are done with this one, prepare for the next scanner: */ ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) { *devp = dev; } return SANE_STATUS_GOOD; } /* * attach_one() * * Part of the SANE API: Attaches the scanner with the device name in *dev. */ static SANE_Status attach_one (const char *dev) { DBG (5, "attach_one(%s)\n", dev); return attach (dev, 0, SANE_EPSON_SCSI); } SANE_Status attach_one_usb (SANE_String_Const devname) { int len = strlen (devname); char *attach_string; DBG (5, "attach_one_usb(%s)\n", devname); attach_string = alloca (len + 5); if (attach_string == NULL) return SANE_STATUS_NO_MEM; return attach (devname, 0, SANE_EPSON_USB); } /* * sane_init() * * */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { size_t len; FILE *fp; authorize = authorize; /* get rid of compiler warning */ /* sanei_authorization(devicename, STRINGIFY(BACKEND_NAME), auth_callback); */ DBG_INIT (); #if defined PACKAGE && defined VERSION DBG (2, "sane_init: " PACKAGE " " VERSION "\n"); #endif if (version_code != NULL) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, SANE_EPSON_BUILD); sanei_usb_init (); /* default to /dev/scanner instead of insisting on config file */ if ((fp = sanei_config_open (EPSON_CONFIG_FILE))) { char line[PATH_MAX]; while (sanei_config_read (line, sizeof (line), fp)) { int vendor, product; DBG (4, "sane_init, >%s<\n", line); if (line[0] == '#') /* ignore line comments */ continue; len = strlen (line); if (!len) continue; /* ignore empty lines */ if (sscanf (line, "usb %i %i", &vendor, &product) == 2) { int numIds; /* add the vendor and product IDs to the list of known devices before we call the attach function */ numIds = sanei_epson_getNumberOfUSBProductIds (); if (vendor != 0x4b8) continue; /* this is not an EPSON device */ sanei_epson_usb_product_ids[numIds - 1] = product; sanei_usb_attach_matching_devices (line, attach_one_usb); } else if (strncmp (line, "usb", 3) == 0) { const char *dev_name; /* remove the "usb" sub string */ dev_name = sanei_config_skip_whitespace (line + 3); attach_one_usb (dev_name); } else { sanei_config_attach_matching_devices (line, attach_one); } } fclose (fp); } /* read the option section and assign the connection type to the scanner structure - which we don't have at this time. So I have to come up with something :-) */ return SANE_STATUS_GOOD; } /* * void sane_exit(void) * * Clean up the list of attached scanners. */ void sane_exit (void) { Epson_Device *dev, *next; for (dev = first_dev; dev; dev = next) { next = dev->next; free ((void *) dev->sane.name); free ((void *) dev->sane.model); free (dev); } free (devlist); } /* * * */ SANE_Status sane_get_devices (const SANE_Device * **device_list, SANE_Bool local_only) { Epson_Device *dev; int i; DBG (5, "sane_get_devices()\n"); local_only = local_only; /* just to get rid of the compiler warning */ if (devlist) { free (devlist); } devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) { devlist[i++] = &dev->sane; } devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } /* * * */ static SANE_Status init_options (Epson_Scanner * s) { int i; SANE_Bool dummy; DBG (5, "init_options()\n"); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Scan Mode" group: */ s->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].w = 0; /* Binary */ /* bit depth */ s->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; s->opt[OPT_BIT_DEPTH].unit = SANE_UNIT_NONE; s->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_BIT_DEPTH].constraint.word_list = bitDepthList; s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; s->val[OPT_BIT_DEPTH].w = bitDepthList[1]; /* the first "real" element is the default */ if (bitDepthList[0] == 1) /* only one element in the list -> hide the option */ s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; /* halftone */ s->opt[OPT_HALFTONE].name = SANE_NAME_HALFTONE; s->opt[OPT_HALFTONE].title = SANE_TITLE_HALFTONE; s->opt[OPT_HALFTONE].desc = SANE_I18N ("Selects the halftone."); s->opt[OPT_HALFTONE].type = SANE_TYPE_STRING; s->opt[OPT_HALFTONE].size = max_string_size (halftone_list_7); s->opt[OPT_HALFTONE].constraint_type = SANE_CONSTRAINT_STRING_LIST; if (s->hw->level >= 7) s->opt[OPT_HALFTONE].constraint.string_list = halftone_list_7; else if (s->hw->level >= 4) s->opt[OPT_HALFTONE].constraint.string_list = halftone_list_4; else s->opt[OPT_HALFTONE].constraint.string_list = halftone_list; s->val[OPT_HALFTONE].w = 1; /* Halftone A */ if (!s->hw->cmd->set_halftoning) { s->opt[OPT_HALFTONE].cap |= SANE_CAP_INACTIVE; } /* dropout */ s->opt[OPT_DROPOUT].name = "dropout"; s->opt[OPT_DROPOUT].title = SANE_I18N ("Dropout"); s->opt[OPT_DROPOUT].desc = SANE_I18N ("Selects the dropout."); s->opt[OPT_DROPOUT].type = SANE_TYPE_STRING; s->opt[OPT_DROPOUT].size = max_string_size (dropout_list); s->opt[OPT_DROPOUT].cap |= SANE_CAP_ADVANCED; s->opt[OPT_DROPOUT].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_DROPOUT].constraint.string_list = dropout_list; s->val[OPT_DROPOUT].w = 0; /* None */ /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_I18N ("Selects the brightness."); s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &s->hw->cmd->bright_range; s->val[OPT_BRIGHTNESS].w = 0; /* Normal */ if (!s->hw->cmd->set_bright) { s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; } /* sharpness */ s->opt[OPT_SHARPNESS].name = "sharpness"; s->opt[OPT_SHARPNESS].title = SANE_I18N ("Sharpness"); s->opt[OPT_SHARPNESS].desc = ""; s->opt[OPT_SHARPNESS].type = SANE_TYPE_INT; s->opt[OPT_SHARPNESS].unit = SANE_UNIT_NONE; s->opt[OPT_SHARPNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_SHARPNESS].constraint.range = &outline_emphasis_range; s->val[OPT_SHARPNESS].w = 0; /* Normal */ if (!s->hw->cmd->set_outline_emphasis) { s->opt[OPT_SHARPNESS].cap |= SANE_CAP_INACTIVE; } /* gamma */ s->opt[OPT_GAMMA_CORRECTION].name = SANE_NAME_GAMMA_CORRECTION; s->opt[OPT_GAMMA_CORRECTION].title = SANE_TITLE_GAMMA_CORRECTION; s->opt[OPT_GAMMA_CORRECTION].desc = SANE_DESC_GAMMA_CORRECTION; s->opt[OPT_GAMMA_CORRECTION].type = SANE_TYPE_STRING; s->opt[OPT_GAMMA_CORRECTION].constraint_type = SANE_CONSTRAINT_STRING_LIST; /* * special handling for D1 function level - at this time I'm not * testing for D1, I'm just assuming that all D level scanners will * behave the same way. This has to be confirmed with the next D-level * scanner */ if (s->hw->cmd->level[0] == 'D') { s->opt[OPT_GAMMA_CORRECTION].size = max_string_size (gamma_list_d); s->opt[OPT_GAMMA_CORRECTION].constraint.string_list = gamma_list_d; s->val[OPT_GAMMA_CORRECTION].w = 1; /* Default */ gamma_userdefined = gamma_userdefined_d; gamma_params = gamma_params_d; } else { s->opt[OPT_GAMMA_CORRECTION].size = max_string_size (gamma_list_ab); s->opt[OPT_GAMMA_CORRECTION].constraint.string_list = gamma_list_ab; s->val[OPT_GAMMA_CORRECTION].w = 0; /* Default */ gamma_userdefined = gamma_userdefined_ab; gamma_params = gamma_params_ab; } if (!s->hw->cmd->set_gamma) { s->opt[OPT_GAMMA_CORRECTION].cap |= SANE_CAP_INACTIVE; } /* gamma vector */ /* s->opt[ OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; s->opt[ OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; s->opt[ OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; s->opt[ OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; s->opt[ OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; s->opt[ OPT_GAMMA_VECTOR].size = 256 * sizeof (SANE_Word); s->opt[ OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[ OPT_GAMMA_VECTOR].constraint.range = &u8_range; s->val[ OPT_GAMMA_VECTOR].wa = &s->gamma_table [ 0] [ 0]; */ /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_R].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_R].wa = &s->gamma_table[0][0]; /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_G].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_G].wa = &s->gamma_table[1][0]; /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_B].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_B].wa = &s->gamma_table[2][0]; if (s->hw->cmd->set_gamma_table && gamma_userdefined[s->val[OPT_GAMMA_CORRECTION].w] == SANE_TRUE) { /* s->opt[ OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; */ s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } else { /* s->opt[ OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; */ s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } /* initialize the Gamma tables */ memset (&s->gamma_table[0], 0, 256 * sizeof (SANE_Word)); memset (&s->gamma_table[1], 0, 256 * sizeof (SANE_Word)); memset (&s->gamma_table[2], 0, 256 * sizeof (SANE_Word)); /* memset(&s->gamma_table[3], 0, 256 * sizeof(SANE_Word)); */ for (i = 0; i < 256; i++) { s->gamma_table[0][i] = i; s->gamma_table[1][i] = i; s->gamma_table[2][i] = i; /* s->gamma_table[3][i] = i; */ } /* color correction */ s->opt[OPT_COLOR_CORRECTION].name = "color-correction"; s->opt[OPT_COLOR_CORRECTION].title = SANE_I18N ("Color correction"); s->opt[OPT_COLOR_CORRECTION].desc = SANE_I18N ("Sets the color correction table for the selected output device."); s->opt[OPT_COLOR_CORRECTION].type = SANE_TYPE_STRING; s->opt[OPT_COLOR_CORRECTION].size = 32; s->opt[OPT_COLOR_CORRECTION].cap |= SANE_CAP_ADVANCED; s->opt[OPT_COLOR_CORRECTION].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_COLOR_CORRECTION].constraint.string_list = color_list; s->val[OPT_COLOR_CORRECTION].w = 5; /* scanner default: CRT monitors */ if (!s->hw->cmd->set_color_correction) { s->opt[OPT_COLOR_CORRECTION].cap |= SANE_CAP_INACTIVE; } /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_RESOLUTION].constraint.word_list = s->hw->resolution_list; s->val[OPT_RESOLUTION].w = s->hw->dpi_range.min; /* threshold */ s->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; s->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; s->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; s->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &u8_range; s->val[OPT_THRESHOLD].w = 0x80; if (!s->hw->cmd->set_threshold) { s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; } s->opt[OPT_CCT_GROUP].title = SANE_I18N ("Color correction coefficients"); s->opt[OPT_CCT_GROUP].desc = SANE_I18N ("Matrix multiplication of RGB"); s->opt[OPT_CCT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_CCT_GROUP].cap = SANE_CAP_ADVANCED; /* color correction coefficients */ s->opt[OPT_CCT_1].name = "cct-1"; s->opt[OPT_CCT_2].name = "cct-2"; s->opt[OPT_CCT_3].name = "cct-3"; s->opt[OPT_CCT_4].name = "cct-4"; s->opt[OPT_CCT_5].name = "cct-5"; s->opt[OPT_CCT_6].name = "cct-6"; s->opt[OPT_CCT_7].name = "cct-7"; s->opt[OPT_CCT_8].name = "cct-8"; s->opt[OPT_CCT_9].name = "cct-9"; s->opt[OPT_CCT_1].title = SANE_I18N ("Green"); s->opt[OPT_CCT_2].title = SANE_I18N ("Shift green to red"); s->opt[OPT_CCT_3].title = SANE_I18N ("Shift green to blue"); s->opt[OPT_CCT_4].title = SANE_I18N ("Shift red to green"); s->opt[OPT_CCT_5].title = SANE_I18N ("Red"); s->opt[OPT_CCT_6].title = SANE_I18N ("Shift red to blue"); s->opt[OPT_CCT_7].title = SANE_I18N ("Shift blue to green"); s->opt[OPT_CCT_8].title = SANE_I18N ("Shift blue to red"); s->opt[OPT_CCT_9].title = SANE_I18N ("Blue"); s->opt[OPT_CCT_1].desc = SANE_I18N ("Controls green level"); s->opt[OPT_CCT_2].desc = SANE_I18N ("Adds to red based on green level"); s->opt[OPT_CCT_3].desc = SANE_I18N ("Adds to blue based on green level"); s->opt[OPT_CCT_4].desc = SANE_I18N ("Adds to green based on red level"); s->opt[OPT_CCT_5].desc = SANE_I18N ("Controls red level"); s->opt[OPT_CCT_6].desc = SANE_I18N ("Adds to blue based on red level"); s->opt[OPT_CCT_7].desc = SANE_I18N ("Adds to green based on blue level"); s->opt[OPT_CCT_8].desc = SANE_I18N ("Adds to red based on blue level"); s->opt[OPT_CCT_9].desc = SANE_I18N ("Controls blue level"); s->opt[OPT_CCT_1].type = SANE_TYPE_INT; s->opt[OPT_CCT_2].type = SANE_TYPE_INT; s->opt[OPT_CCT_3].type = SANE_TYPE_INT; s->opt[OPT_CCT_4].type = SANE_TYPE_INT; s->opt[OPT_CCT_5].type = SANE_TYPE_INT; s->opt[OPT_CCT_6].type = SANE_TYPE_INT; s->opt[OPT_CCT_7].type = SANE_TYPE_INT; s->opt[OPT_CCT_8].type = SANE_TYPE_INT; s->opt[OPT_CCT_9].type = SANE_TYPE_INT; s->opt[OPT_CCT_1].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_2].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_3].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_4].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_5].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_6].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_7].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_8].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_9].cap |= SANE_CAP_ADVANCED; s->opt[OPT_CCT_1].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_2].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_3].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_4].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_5].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_6].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_7].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_8].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_9].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_1].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_2].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_3].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_4].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_5].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_6].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_7].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_8].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_9].unit = SANE_UNIT_NONE; s->opt[OPT_CCT_1].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_2].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_3].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_4].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_5].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_6].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_7].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_8].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_9].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CCT_1].constraint.range = &s8_range; s->opt[OPT_CCT_2].constraint.range = &s8_range; s->opt[OPT_CCT_3].constraint.range = &s8_range; s->opt[OPT_CCT_4].constraint.range = &s8_range; s->opt[OPT_CCT_5].constraint.range = &s8_range; s->opt[OPT_CCT_6].constraint.range = &s8_range; s->opt[OPT_CCT_7].constraint.range = &s8_range; s->opt[OPT_CCT_8].constraint.range = &s8_range; s->opt[OPT_CCT_9].constraint.range = &s8_range; s->val[OPT_CCT_1].w = 32; s->val[OPT_CCT_2].w = 0; s->val[OPT_CCT_3].w = 0; s->val[OPT_CCT_4].w = 0; s->val[OPT_CCT_5].w = 32; s->val[OPT_CCT_6].w = 0; s->val[OPT_CCT_7].w = 0; s->val[OPT_CCT_8].w = 0; s->val[OPT_CCT_9].w = 32; if (!s->hw->cmd->set_color_correction_coefficients) { s->opt[OPT_CCT_1].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_2].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_3].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_4].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_5].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_6].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_7].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_8].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CCT_9].cap |= SANE_CAP_INACTIVE; } /* "Advanced" group: */ s->opt[OPT_ADVANCED_GROUP].title = SANE_I18N ("Advanced"); s->opt[OPT_ADVANCED_GROUP].desc = ""; s->opt[OPT_ADVANCED_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ADVANCED_GROUP].cap = SANE_CAP_ADVANCED; /* mirror */ s->opt[OPT_MIRROR].name = "mirror"; s->opt[OPT_MIRROR].title = SANE_I18N ("Mirror image"); s->opt[OPT_MIRROR].desc = SANE_I18N ("Mirror the image."); s->opt[OPT_MIRROR].type = SANE_TYPE_BOOL; s->val[OPT_MIRROR].w = SANE_FALSE; if (!s->hw->cmd->mirror_image) { s->opt[OPT_MIRROR].cap |= SANE_CAP_INACTIVE; } /* speed */ s->opt[OPT_SPEED].name = SANE_NAME_SCAN_SPEED; s->opt[OPT_SPEED].title = SANE_TITLE_SCAN_SPEED; s->opt[OPT_SPEED].desc = SANE_DESC_SCAN_SPEED; s->opt[OPT_SPEED].type = SANE_TYPE_BOOL; s->val[OPT_SPEED].w = SANE_FALSE; if (!s->hw->cmd->set_speed) { s->opt[OPT_SPEED].cap |= SANE_CAP_INACTIVE; } /* preview speed */ s->opt[OPT_PREVIEW_SPEED].name = "preview-speed"; s->opt[OPT_PREVIEW_SPEED].title = SANE_I18N ("Fast preview"); s->opt[OPT_PREVIEW_SPEED].desc = ""; s->opt[OPT_PREVIEW_SPEED].type = SANE_TYPE_BOOL; s->val[OPT_PREVIEW_SPEED].w = SANE_FALSE; if (!s->hw->cmd->set_speed) { s->opt[OPT_PREVIEW_SPEED].cap |= SANE_CAP_INACTIVE; } /* auto area segmentation */ s->opt[OPT_AAS].name = "auto-area-segmentation"; s->opt[OPT_AAS].title = SANE_I18N ("Auto area segmentation"); s->opt[OPT_AAS].desc = ""; s->opt[OPT_AAS].type = SANE_TYPE_BOOL; s->val[OPT_AAS].w = SANE_TRUE; if (!s->hw->cmd->control_auto_area_segmentation) { s->opt[OPT_AAS].cap |= SANE_CAP_INACTIVE; } /* limit resolution list */ s->opt[OPT_LIMIT_RESOLUTION].name = "short-resolution"; s->opt[OPT_LIMIT_RESOLUTION].title = SANE_I18N ("Short resolution list"); s->opt[OPT_LIMIT_RESOLUTION].desc = SANE_I18N ("Display short resolution list"); s->opt[OPT_LIMIT_RESOLUTION].type = SANE_TYPE_BOOL; s->val[OPT_LIMIT_RESOLUTION].w = SANE_FALSE; /* zoom */ s->opt[OPT_ZOOM].name = "zoom"; s->opt[OPT_ZOOM].title = SANE_I18N ("Zoom"); s->opt[OPT_ZOOM].desc = SANE_I18N ("Defines the zoom factor the scanner will use"); s->opt[OPT_ZOOM].type = SANE_TYPE_INT; s->opt[OPT_ZOOM].unit = SANE_UNIT_NONE; s->opt[OPT_ZOOM].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_ZOOM].constraint.range = &zoom_range; s->val[OPT_ZOOM].w = 100; /* if( ! s->hw->cmd->set_zoom) */ { s->opt[OPT_ZOOM].cap |= SANE_CAP_INACTIVE; } /* "Preview settings" group: */ s->opt[OPT_PREVIEW_GROUP].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW_GROUP].desc = ""; s->opt[OPT_PREVIEW_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_PREVIEW_GROUP].cap = SANE_CAP_ADVANCED; /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_PREVIEW].w = SANE_FALSE; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = s->hw->x_range; s->val[OPT_TL_X].w = 0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = s->hw->y_range; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = s->hw->x_range; s->val[OPT_BR_X].w = s->hw->x_range->max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = s->hw->y_range; s->val[OPT_BR_Y].w = s->hw->y_range->max; /* Quick format */ s->opt[OPT_QUICK_FORMAT].name = "quick-format"; s->opt[OPT_QUICK_FORMAT].title = SANE_I18N ("Quick format"); s->opt[OPT_QUICK_FORMAT].desc = ""; s->opt[OPT_QUICK_FORMAT].type = SANE_TYPE_STRING; s->opt[OPT_QUICK_FORMAT].size = max_string_size (qf_list); s->opt[OPT_QUICK_FORMAT].cap |= SANE_CAP_ADVANCED; s->opt[OPT_QUICK_FORMAT].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_QUICK_FORMAT].constraint.string_list = qf_list; s->val[OPT_QUICK_FORMAT].w = XtNumber (qf_params) - 1; /* max */ /* "Optional equipment" group: */ s->opt[OPT_EQU_GROUP].title = SANE_I18N ("Optional equipment"); s->opt[OPT_EQU_GROUP].desc = ""; s->opt[OPT_EQU_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_EQU_GROUP].cap = SANE_CAP_ADVANCED; /* source */ s->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_SOURCE].type = SANE_TYPE_STRING; s->opt[OPT_SOURCE].size = max_string_size (source_list); s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].constraint.string_list = source_list; if (!s->hw->extension) { s->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; } s->val[OPT_SOURCE].w = 0; /* always use Flatbed as default */ /* film type */ s->opt[OPT_FILM_TYPE].name = "film-type"; s->opt[OPT_FILM_TYPE].title = SANE_I18N ("Film type"); s->opt[OPT_FILM_TYPE].desc = ""; s->opt[OPT_FILM_TYPE].type = SANE_TYPE_STRING; s->opt[OPT_FILM_TYPE].size = max_string_size (film_list); s->opt[OPT_FILM_TYPE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_FILM_TYPE].constraint.string_list = film_list; s->val[OPT_FILM_TYPE].w = 0; deactivateOption (s, OPT_FILM_TYPE, &dummy); /* default is inactive */ /* focus position */ s->opt[OPT_FOCUS].name = SANE_EPSON_FOCUS_NAME; s->opt[OPT_FOCUS].title = SANE_EPSON_FOCUS_TITLE; s->opt[OPT_FOCUS].desc = SANE_EPSON_FOCUS_DESC; s->opt[OPT_FOCUS].type = SANE_TYPE_STRING; s->opt[OPT_FOCUS].size = max_string_size (focus_list); s->opt[OPT_FOCUS].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_FOCUS].constraint.string_list = focus_list; s->val[OPT_FOCUS].w = 0; s->opt[OPT_FOCUS].cap |= SANE_CAP_ADVANCED; if (s->hw->focusSupport == SANE_TRUE) { s->opt[OPT_FOCUS].cap &= ~SANE_CAP_INACTIVE; } else { s->opt[OPT_FOCUS].cap |= SANE_CAP_INACTIVE; } #if 0 if ((!s->hw->TPU) && (!s->hw->cmd->set_bay)) { /* Hack: Using set_bay to indicate. */ SANE_Bool dummy; deactivateOption (s, OPT_FILM_TYPE, &dummy); } #endif /* forward feed / eject */ s->opt[OPT_EJECT].name = "eject"; s->opt[OPT_EJECT].title = SANE_I18N ("Eject"); s->opt[OPT_EJECT].desc = SANE_I18N ("Eject the sheet in the ADF"); s->opt[OPT_EJECT].type = SANE_TYPE_BUTTON; if ((!s->hw->ADF) && (!s->hw->cmd->set_bay)) { /* Hack: Using set_bay to indicate. */ s->opt[OPT_EJECT].cap |= SANE_CAP_INACTIVE; } /* auto forward feed / eject */ s->opt[OPT_AUTO_EJECT].name = "auto-eject"; s->opt[OPT_AUTO_EJECT].title = SANE_I18N ("Auto eject"); s->opt[OPT_AUTO_EJECT].desc = SANE_I18N ("Eject document after scanning"); s->opt[OPT_AUTO_EJECT].type = SANE_TYPE_BOOL; s->val[OPT_AUTO_EJECT].w = SANE_FALSE; if (!s->hw->ADF) { s->opt[OPT_AUTO_EJECT].cap |= SANE_CAP_INACTIVE; } s->opt[OPT_ADF_MODE].name = "adf_mode"; s->opt[OPT_ADF_MODE].title = SANE_I18N ("ADF Mode"); s->opt[OPT_ADF_MODE].desc = SANE_I18N ("Selects the ADF mode (simplex/duplex)"); s->opt[OPT_ADF_MODE].type = SANE_TYPE_STRING; s->opt[OPT_ADF_MODE].size = max_string_size (adf_mode_list); s->opt[OPT_ADF_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_ADF_MODE].constraint.string_list = adf_mode_list; s->val[OPT_ADF_MODE].w = 0; /* simplex */ if ((!s->hw->ADF) || (s->hw->duplexSupport == SANE_FALSE)) { s->opt[OPT_ADF_MODE].cap |= SANE_CAP_INACTIVE; } /* select bay */ s->opt[OPT_BAY].name = "bay"; s->opt[OPT_BAY].title = SANE_I18N ("Bay"); s->opt[OPT_BAY].desc = SANE_I18N ("Select bay to scan"); s->opt[OPT_BAY].type = SANE_TYPE_STRING; s->opt[OPT_BAY].size = max_string_size (bay_list); s->opt[OPT_BAY].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_BAY].constraint.string_list = bay_list; s->val[OPT_BAY].w = 0; /* Bay 1 */ if (!s->hw->cmd->set_bay) { s->opt[OPT_BAY].cap |= SANE_CAP_INACTIVE; } s->opt[OPT_WAIT_FOR_BUTTON].name = SANE_EPSON_WAIT_FOR_BUTTON_NAME; s->opt[OPT_WAIT_FOR_BUTTON].title = SANE_EPSON_WAIT_FOR_BUTTON_TITLE; s->opt[OPT_WAIT_FOR_BUTTON].desc = SANE_EPSON_WAIT_FOR_BUTTON_DESC; s->opt[OPT_WAIT_FOR_BUTTON].type = SANE_TYPE_BOOL; s->opt[OPT_WAIT_FOR_BUTTON].unit = SANE_UNIT_NONE; s->opt[OPT_WAIT_FOR_BUTTON].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_WAIT_FOR_BUTTON].constraint.range = NULL; s->opt[OPT_WAIT_FOR_BUTTON].cap |= SANE_CAP_ADVANCED; if (!s->hw->cmd->request_push_button_status) { s->opt[OPT_WAIT_FOR_BUTTON].cap |= SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; } /* * * */ SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Epson_Device *dev; Epson_Scanner *s; DBG (5, "sane_open(%s)\n", devicename); /* search for device */ if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { break; } } if (!dev) { #if 0 status = attach (devicename, &dev, SANE_EPSON_); if (status != SANE_STATUS_GOOD) { return status; } #endif DBG (1, "Error opening the device"); return SANE_STATUS_INVAL; } } else { dev = first_dev; } if (!dev) { return SANE_STATUS_INVAL; } s = calloc (sizeof (Epson_Scanner), 1); if (!s) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } s->fd = -1; s->hw = dev; init_options (s); /* insert newly opened handle into list of open handles */ s->next = first_handle; first_handle = s; *handle = (SANE_Handle) s; open_scanner (s); return SANE_STATUS_GOOD; } /* * * */ void sane_close (SANE_Handle handle) { Epson_Scanner *s, *prev; /* * Test if there is still data pending from * the scanner. If so, then do a cancel */ s = (Epson_Scanner *) handle; /* 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) { DBG (1, "close: invalid handle (0x%p)\n", handle); return; } if (prev) prev->next = s->next; else first_handle = s->next; if (s->fd != -1) close_scanner (s); free (s); } /* * * */ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Epson_Scanner *s = (Epson_Scanner *) handle; if (option < 0 || option >= NUM_OPTIONS) return NULL; return (s->opt + option); } /* * * */ static const SANE_String_Const * search_string_list (const SANE_String_Const * list, SANE_String value) { while (*list != NULL && strcmp (value, *list) != 0) { ++list; } return ((*list == NULL) ? NULL : list); } /* * * */ /* Activate, deactivate an option. Subroutines so we can add debugging info if we want. The change flag is set to TRUE if we changed an option. If we did not change an option, then the value of the changed flag is not modified. */ static void activateOption (Epson_Scanner * s, SANE_Int option, SANE_Bool * change) { if (!SANE_OPTION_IS_ACTIVE (s->opt[option].cap)) { s->opt[option].cap &= ~SANE_CAP_INACTIVE; *change = SANE_TRUE; } } static void deactivateOption (Epson_Scanner * s, SANE_Int option, SANE_Bool * change) { if (SANE_OPTION_IS_ACTIVE (s->opt[option].cap)) { s->opt[option].cap |= SANE_CAP_INACTIVE; *change = SANE_TRUE; } } static void setOptionState (Epson_Scanner * s, SANE_Bool state, SANE_Int option, SANE_Bool * change) { if (state) { activateOption (s, option, change); } else { deactivateOption (s, option, change); } } /** End of activateOption, deactivateOption, setOptionState. **/ static SANE_Status getvalue (SANE_Handle handle, SANE_Int option, void *value) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Option_Descriptor *sopt = &(s->opt[option]); Option_Value *sval = &(s->val[option]); switch (option) { /* case OPT_GAMMA_VECTOR: */ case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (value, sval->wa, sopt->size); break; case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_MIRROR: case OPT_SPEED: case OPT_PREVIEW_SPEED: case OPT_AAS: case OPT_PREVIEW: case OPT_BRIGHTNESS: case OPT_SHARPNESS: case OPT_AUTO_EJECT: case OPT_CCT_1: case OPT_CCT_2: case OPT_CCT_3: case OPT_CCT_4: case OPT_CCT_5: case OPT_CCT_6: case OPT_CCT_7: case OPT_CCT_8: case OPT_CCT_9: case OPT_THRESHOLD: case OPT_ZOOM: case OPT_BIT_DEPTH: case OPT_WAIT_FOR_BUTTON: case OPT_LIMIT_RESOLUTION: *((SANE_Word *) value) = sval->w; break; case OPT_MODE: case OPT_ADF_MODE: case OPT_HALFTONE: case OPT_DROPOUT: case OPT_QUICK_FORMAT: case OPT_SOURCE: case OPT_FILM_TYPE: case OPT_GAMMA_CORRECTION: case OPT_COLOR_CORRECTION: case OPT_BAY: case OPT_FOCUS: strcpy ((char *) value, sopt->constraint.string_list[sval->w]); break; #if 0 case OPT_MODEL: strcpy (value, sval->s); break; #endif default: return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /** End of getvalue. **/ static void handle_depth_halftone (Epson_Scanner * s, SANE_Bool * reload) /* This routine handles common options between OPT_MODE and OPT_HALFTONE. These options are TET (a HALFTONE mode), AAS - auto area segmentation, and threshold. Apparently AAS is some method to differentiate between text and photos. Or something like that. AAS is available when the scan color depth is 1 and the halftone method is not TET. Threshold is available when halftone is NONE, and depth is 1. */ { int hti = s->val[OPT_HALFTONE].w; int mdi = s->val[OPT_MODE].w; SANE_Bool aas = SANE_FALSE; SANE_Bool thresh = SANE_FALSE; if (!s->hw->cmd->control_auto_area_segmentation) return; if (mode_params[mdi].depth == 1) { if (halftone_params[hti] != HALFTONE_TET) { aas = SANE_TRUE; } if (halftone_params[hti] == HALFTONE_NONE) { thresh = SANE_TRUE; } } setOptionState (s, aas, OPT_AAS, reload); setOptionState (s, thresh, OPT_THRESHOLD, reload); } /** End of handle_depth_halftone. **/ static void handle_source (Epson_Scanner * s, SANE_Int optindex, char *value) /* Handles setting the source (flatbed, transparency adapter (TPU), or auto document feeder (ADF)). For newer scanners it also sets the focus according to the glass / TPU settings. */ { int force_max = SANE_FALSE; SANE_Bool dummy; /* reset the scanner when we are changing the source setting - this is necessary for the Perfection 1650 */ if (s->hw->need_reset_on_source_change) reset (s); s->focusOnGlass = SANE_TRUE; /* this is the default */ if (s->val[OPT_SOURCE].w == optindex) return; s->val[OPT_SOURCE].w = optindex; if (s->val[OPT_TL_X].w == s->hw->x_range->min && s->val[OPT_TL_Y].w == s->hw->y_range->min && s->val[OPT_BR_X].w == s->hw->x_range->max && s->val[OPT_BR_Y].w == s->hw->y_range->max) { force_max = SANE_TRUE; } if (strcmp (ADF_STR, value) == 0) { s->hw->x_range = &s->hw->adf_x_range; s->hw->y_range = &s->hw->adf_y_range; s->hw->use_extension = SANE_TRUE; /* disable film type option */ deactivateOption (s, OPT_FILM_TYPE, &dummy); s->val[OPT_FOCUS].w = 0; if (s->hw->duplexSupport) { activateOption (s, OPT_ADF_MODE, &dummy); } else { deactivateOption (s, OPT_ADF_MODE, &dummy); s->val[OPT_ADF_MODE].w = 0; } } else if (strcmp (TPU_STR, value) == 0) { s->hw->x_range = &s->hw->tpu_x_range; s->hw->y_range = &s->hw->tpu_y_range; s->hw->use_extension = SANE_TRUE; /* enable film type option only if the scanner supports it */ if (s->hw->cmd->set_film_type != 0) { activateOption (s, OPT_FILM_TYPE, &dummy); } else { deactivateOption (s, OPT_FILM_TYPE, &dummy); } /* enable focus position if the scanner supports it */ if (s->hw->cmd->set_focus_position != 0) { s->val[OPT_FOCUS].w = 1; s->focusOnGlass = SANE_FALSE; } deactivateOption (s, OPT_ADF_MODE, &dummy); deactivateOption (s, OPT_EJECT, &dummy); deactivateOption (s, OPT_AUTO_EJECT, &dummy); } else /* neither ADF nor TPU active */ { s->hw->x_range = &s->hw->fbf_x_range; s->hw->y_range = &s->hw->fbf_y_range; s->hw->use_extension = SANE_FALSE; /* disable film type option */ deactivateOption (s, OPT_FILM_TYPE, &dummy); s->val[OPT_FOCUS].w = 0; deactivateOption (s, OPT_ADF_MODE, &dummy); } qf_params[XtNumber (qf_params) - 1].tl_x = s->hw->x_range->min; qf_params[XtNumber (qf_params) - 1].tl_y = s->hw->y_range->min; qf_params[XtNumber (qf_params) - 1].br_x = s->hw->x_range->max; qf_params[XtNumber (qf_params) - 1].br_y = s->hw->y_range->max; s->opt[OPT_BR_X].constraint.range = s->hw->x_range; s->opt[OPT_BR_Y].constraint.range = s->hw->y_range; if (s->val[OPT_TL_X].w < s->hw->x_range->min || force_max) s->val[OPT_TL_X].w = s->hw->x_range->min; if (s->val[OPT_TL_Y].w < s->hw->y_range->min || force_max) s->val[OPT_TL_Y].w = s->hw->y_range->min; if (s->val[OPT_BR_X].w > s->hw->x_range->max || force_max) s->val[OPT_BR_X].w = s->hw->x_range->max; if (s->val[OPT_BR_Y].w > s->hw->y_range->max || force_max) s->val[OPT_BR_Y].w = s->hw->y_range->max; setOptionState (s, s->hw->ADF && s->hw->use_extension, OPT_AUTO_EJECT, &dummy); setOptionState (s, s->hw->ADF && s->hw->use_extension, OPT_EJECT, &dummy); #if 0 BAY is part of the filmscan device.We are not sure if we are really going to support this device in this code.Is there an online manual for it ? setOptionState (s, s->hw->ADF && s->hw->use_extension, OPT_BAY, &reload); #endif } /** End of handle_source. **/ static SANE_Status setvalue (SANE_Handle handle, SANE_Int option, void *value, SANE_Int * info) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Option_Descriptor *sopt = &(s->opt[option]); Option_Value *sval = &(s->val[option]); SANE_Status status; const SANE_String_Const *optval; int optindex; SANE_Bool reload = SANE_FALSE; DBG (5, "setvalue(option = %d, value = %p)\n", option, value); status = sanei_constrain_value (sopt, value, info); if (status != SANE_STATUS_GOOD) return status; s->option_has_changed = SANE_TRUE; optval = NULL; optindex = 0; if (sopt->constraint_type == SANE_CONSTRAINT_STRING_LIST) { optval = search_string_list (sopt->constraint.string_list, (char *) value); if (optval == NULL) return SANE_STATUS_INVAL; optindex = optval - sopt->constraint.string_list; } switch (option) { /* case OPT_GAMMA_VECTOR: */ case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (sval->wa, value, sopt->size); /* Word arrays */ break; case OPT_CCT_1: case OPT_CCT_2: case OPT_CCT_3: case OPT_CCT_4: case OPT_CCT_5: case OPT_CCT_6: case OPT_CCT_7: case OPT_CCT_8: case OPT_CCT_9: sval->w = *((SANE_Word *) value); /* Simple values */ break; case OPT_DROPOUT: case OPT_FILM_TYPE: case OPT_BAY: case OPT_FOCUS: sval->w = optindex; /* Simple lists */ break; case OPT_EJECT: /* return eject( s ); */ eject (s); break; case OPT_RESOLUTION: sval->w = *((SANE_Word *) value); reload = SANE_TRUE; break; case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: sval->w = *((SANE_Word *) value); DBG (1, "set = %f\n", SANE_UNFIX (sval->w)); if (NULL != info) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_SOURCE: handle_source (s, optindex, (char *) value); reload = SANE_TRUE; break; case OPT_MODE: { SANE_Bool isColor = mode_params[optindex].color; SANE_Bool userDefined = color_userdefined[s->val[OPT_COLOR_CORRECTION].w]; sval->w = optindex; if (s->hw->cmd->set_halftoning != 0) { setOptionState (s, mode_params[optindex].depth == 1, OPT_HALFTONE, &reload); } setOptionState (s, !isColor, OPT_DROPOUT, &reload); if (s->hw->cmd->set_color_correction) { setOptionState (s, isColor, OPT_COLOR_CORRECTION, &reload); } if (s->hw->cmd->set_color_correction_coefficients) { setOptionState (s, isColor && userDefined, OPT_CCT_1, &reload); setOptionState (s, isColor && userDefined, OPT_CCT_2, &reload); setOptionState (s, isColor && userDefined, OPT_CCT_3, &reload); setOptionState (s, isColor && userDefined, OPT_CCT_4, &reload); setOptionState (s, isColor && userDefined, OPT_CCT_5, &reload); setOptionState (s, isColor && userDefined, OPT_CCT_6, &reload); setOptionState (s, isColor && userDefined, OPT_CCT_7, &reload); setOptionState (s, isColor && userDefined, OPT_CCT_8, &reload); setOptionState (s, isColor && userDefined, OPT_CCT_9, &reload); } /* if binary, then disable the bit depth selection */ if (optindex == 0) { s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; } else { if (bitDepthList[0] == 1) s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; else { s->opt[OPT_BIT_DEPTH].cap &= ~SANE_CAP_INACTIVE; s->val[OPT_BIT_DEPTH].w = mode_params[optindex].depth; } } handle_depth_halftone (s, &reload); reload = SANE_TRUE; break; } case OPT_ADF_MODE: sval->w = optindex; break; case OPT_BIT_DEPTH: sval->w = *((SANE_Word *) value); mode_params[s->val[OPT_MODE].w].depth = sval->w; reload = SANE_TRUE; break; case OPT_HALFTONE: sval->w = optindex; handle_depth_halftone (s, &reload); break; case OPT_COLOR_CORRECTION: { SANE_Bool f = color_userdefined[optindex]; sval->w = optindex; setOptionState (s, f, OPT_CCT_1, &reload); setOptionState (s, f, OPT_CCT_2, &reload); setOptionState (s, f, OPT_CCT_3, &reload); setOptionState (s, f, OPT_CCT_4, &reload); setOptionState (s, f, OPT_CCT_5, &reload); setOptionState (s, f, OPT_CCT_6, &reload); setOptionState (s, f, OPT_CCT_7, &reload); setOptionState (s, f, OPT_CCT_8, &reload); setOptionState (s, f, OPT_CCT_9, &reload); break; } case OPT_GAMMA_CORRECTION: { SANE_Bool f = gamma_userdefined[optindex]; sval->w = optindex; /* setOptionState(s, f, OPT_GAMMA_VECTOR, &reload ); */ setOptionState (s, f, OPT_GAMMA_VECTOR_R, &reload); setOptionState (s, f, OPT_GAMMA_VECTOR_G, &reload); setOptionState (s, f, OPT_GAMMA_VECTOR_B, &reload); setOptionState (s, !f, OPT_BRIGHTNESS, &reload); /* Note... */ break; } case OPT_MIRROR: case OPT_SPEED: case OPT_PREVIEW_SPEED: case OPT_AAS: case OPT_PREVIEW: /* needed? */ case OPT_BRIGHTNESS: case OPT_SHARPNESS: case OPT_AUTO_EJECT: case OPT_THRESHOLD: case OPT_ZOOM: case OPT_WAIT_FOR_BUTTON: sval->w = *((SANE_Word *) value); break; case OPT_LIMIT_RESOLUTION: sval->w = *((SANE_Word *) value); filter_resolution_list (s); reload = SANE_TRUE; break; case OPT_QUICK_FORMAT: sval->w = optindex; s->val[OPT_TL_X].w = qf_params[sval->w].tl_x; s->val[OPT_TL_Y].w = qf_params[sval->w].tl_y; s->val[OPT_BR_X].w = qf_params[sval->w].br_x; s->val[OPT_BR_Y].w = qf_params[sval->w].br_y; if (s->val[OPT_TL_X].w < s->hw->x_range->min) s->val[OPT_TL_X].w = s->hw->x_range->min; if (s->val[OPT_TL_Y].w < s->hw->y_range->min) s->val[OPT_TL_Y].w = s->hw->y_range->min; if (s->val[OPT_BR_X].w > s->hw->x_range->max) s->val[OPT_BR_X].w = s->hw->x_range->max; if (s->val[OPT_BR_Y].w > s->hw->y_range->max) s->val[OPT_BR_Y].w = s->hw->y_range->max; reload = SANE_TRUE; break; default: return SANE_STATUS_INVAL; } if (reload && info != NULL) { *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; } /** End of setvalue. **/ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { if (option < 0 || option >= NUM_OPTIONS) return SANE_STATUS_INVAL; if (info != NULL) *info = 0; switch (action) { case SANE_ACTION_GET_VALUE: return (getvalue (handle, option, value)); case SANE_ACTION_SET_VALUE: return (setvalue (handle, option, value, info)); default: return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /* * sane_get_parameters() * * This function is part of the SANE API and gets called when the front end * requests information aobut the scan configuration (e.g. color depth, mode, * bytes and pixels per line, number of lines. This information is returned * in the SANE_Parameters structure. * * Once a scan was started, this routine has to report the correct values, if * it is called before the scan is actually started, the values are based on * the current settings. * */ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Epson_Scanner *s = (Epson_Scanner *) handle; int ndpi; int bytes_per_pixel; DBG (5, "sane_get_parameters()\n"); /* * If sane_start was already called, then just retrieve the parameters * from the scanner data structure */ if (!s->eof && s->ptr != NULL) { DBG (5, "Returning saved params structure\n"); if (params != NULL) { DBG(1, "Restoring parameters from saved parameters\n"); *params = s->params; } DBG (3, "Preview = %d\n", s->val[OPT_PREVIEW].w); DBG (3, "Resolution = %d\n", s->val[OPT_RESOLUTION].w); DBG (1, "get para %p %p tlx %f tly %f brx %f bry %f [mm]\n", (void *) s, (void *) s->val, SANE_UNFIX (s->val[OPT_TL_X].w), SANE_UNFIX (s->val[OPT_TL_Y].w), SANE_UNFIX (s->val[OPT_BR_X].w), SANE_UNFIX (s->val[OPT_BR_Y].w)); print_params (s->params); return SANE_STATUS_GOOD; } /* otherwise initialize the params structure and gather the data */ memset (&s->params, 0, sizeof (SANE_Parameters)); ndpi = s->val[OPT_RESOLUTION].w; 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 = SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) / 25.4 * ndpi + 0.5; /* * Make sure that the number of lines is correct for color shuffling: * The shuffling alghorithm produces 2xline_distance lines at the * beginning and the same amount at the end of the scan that are not * useable. If s->params.lines gets negative, 0 lines are reported * back to the frontend. */ if (s->hw->color_shuffle) { s->params.lines -= 4 * s->line_distance; if (s->params.lines < 0) { s->params.lines = 0; } DBG (1, "Adjusted params.lines for color_shuffle by %d to %d\n", 4 * s->line_distance, s->params.lines); } DBG (3, "Preview = %d\n", s->val[OPT_PREVIEW].w); DBG (3, "Resolution = %d\n", s->val[OPT_RESOLUTION].w); DBG (1, "get para %p %p tlx %f tly %f brx %f bry %f [mm]\n", (void *) s, (void *) s->val, SANE_UNFIX (s->val[OPT_TL_X].w), SANE_UNFIX (s->val[OPT_TL_Y].w), SANE_UNFIX (s->val[OPT_BR_X].w), SANE_UNFIX (s->val[OPT_BR_Y].w)); /* * Calculate bytes_per_pixel and bytes_per_line for * any color depths. * * 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_BIT_DEPTH].w; } if (s->params.depth > 8) { s->params.depth = 16; /* * The frontends can only handle 8 or 16 bits * for gray or color - so if it's more than 8, * it gets automatically set to 16. This works * as long as EPSON does not come out with a * scanner that can handle more than 16 bits * per color channel. */ } bytes_per_pixel = s->params.depth / 8; /* this works because it can only be set to 1, 8 or 16 */ if (s->params.depth % 8) /* just in case ... */ { bytes_per_pixel++; } /* pixels_per_line is rounded to the next 8bit boundary */ s->params.pixels_per_line = s->params.pixels_per_line & ~7; s->params.last_frame = SANE_TRUE; if (mode_params[s->val[OPT_MODE].w].color) { s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line = 3 * s->params.pixels_per_line * bytes_per_pixel; } else { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8; } if (NULL != params) *params = s->params; print_params (s->params); return SANE_STATUS_GOOD; } /* * sane_start() * * This function is part of the SANE API and gets called from the front end to * start the scan process. * */ SANE_Status sane_start (SANE_Handle handle) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Status status; SANE_Bool button_status; const struct mode_param *mparam; u_char params[4]; int ndpi; int left, top; int lcount; int i, j; /* loop counter */ DBG (5, "sane_start()\n"); open_scanner (s); /* * There is some undocumented special behavior with the TPU enable/disable. * TPU power ESC e status * on 0 NAK * on 1 ACK * off 0 ACK * off 1 NAK * * It makes no sense to scan with TPU powered on and source flatbed, because * light will come from both sides. */ if (s->hw->extension) { int max_x, max_y; int extensionCtrl; extensionCtrl = (s->hw->use_extension ? 1 : 0); if (s->hw->use_extension && (s->val[OPT_ADF_MODE].w == 1)) extensionCtrl = 2; status = control_extension (s, extensionCtrl); if (SANE_STATUS_GOOD != status) { DBG (1, "You may have to power %s your TPU\n", s->hw->use_extension ? "on" : "off"); DBG (1, "Also you may have to restart the Sane frontend.\n"); close_scanner (s); return status; } if (s->hw->cmd->request_extended_status != 0) { status = check_ext_status (s, &max_x, &max_y); if (SANE_STATUS_GOOD != status && SANE_STATUS_DEVICE_BUSY != status) { close_scanner (s); return status; } } if (s->hw->ADF && s->hw->use_extension && s->hw->cmd->feed) { status = feed (s); if (SANE_STATUS_GOOD != status) { close_scanner (s); return status; } check_ext_status (s, &max_x, &max_y); s->hw->adf_max_x = max_x; s->hw->adf_max_y = max_y; } /* * set the focus position according to the extension used: * if the TPU is selected, then focus 2.5mm above the glass, * otherwise focus on the glass. Scanners that don't support * this feature, will just ignore these calls. */ if (s->hw->focusSupport == SANE_TRUE) { if (s->val[OPT_FOCUS].w == 0) { DBG (1, "Setting focus to glass surface\n"); set_focus_position (s, 0x40); } else { DBG (1, "Setting focus to 2.5mm above glass\n"); set_focus_position (s, 0x59); } } } /* use the flatbed size for the max. scansize for the GT-30000 and similar scanners if the ADF is not enabled */ if (s->hw->devtype == 3 && s->hw->use_extension == 0) { int max_x, max_y; status = check_ext_status (s, &max_x, &max_y); if (SANE_STATUS_GOOD != status && SANE_STATUS_DEVICE_BUSY != status) { close_scanner (s); return status; } s->hw->fbf_max_x = max_x; s->hw->fbf_max_y = max_y; } mparam = mode_params + s->val[OPT_MODE].w; DBG (1, "sane_start: Setting data format to %d bits\n", mparam->depth); status = set_data_format (s, mparam->depth); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_data_format failed: %s\n", sane_strstatus (status)); return status; } /* * The byte sequence mode was introduced in B5, for B[34] we need line sequence mode */ if ((s->hw->cmd->level[0] == 'D' || (s->hw->cmd->level[0] == 'B' && s->hw->level >= 5)) && mparam->mode_flags == 0x02) { status = set_color_mode (s, 0x13); } else { status = set_color_mode (s, mparam->mode_flags | (mparam->dropout_mask & dropout_params[s-> val [OPT_DROPOUT]. w])); } if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_color_mode failed: %s\n", sane_strstatus (status)); return status; } if (s->hw->cmd->set_halftoning && SANE_OPTION_IS_ACTIVE (s->opt[OPT_HALFTONE].cap)) { status = set_halftoning (s, halftone_params[s->val[OPT_HALFTONE].w]); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_halftoning failed: %s\n", sane_strstatus (status)); return status; } } if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_BRIGHTNESS].cap)) { status = set_bright (s, s->val[OPT_BRIGHTNESS].w); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_bright failed: %s\n", sane_strstatus (status)); return status; } } if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_MIRROR].cap)) { status = mirror_image (s, mirror_params[s->val[OPT_MIRROR].w]); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: mirror_image failed: %s\n", sane_strstatus (status)); return status; } } if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_SPEED].cap)) { if (s->val[OPT_PREVIEW].w) status = set_speed (s, speed_params[s->val[OPT_PREVIEW_SPEED].w]); else status = set_speed (s, speed_params[s->val[OPT_SPEED].w]); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_speed failed: %s\n", sane_strstatus (status)); return status; } } /* * use of speed_params is ok here since they are false and true. * NOTE: I think I should throw that "params" stuff as long w is already the value. */ if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_AAS].cap)) { status = control_auto_area_segmentation (s, speed_params[s->val[OPT_AAS].w]); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: control_auto_area_segmentation failed: %s\n", sane_strstatus (status)); return status; } } s->invert_image = SANE_FALSE; /* default: to not inverting the image */ if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_FILM_TYPE].cap)) { s->invert_image = (s->val[OPT_FILM_TYPE].w == FILM_TYPE_NEGATIVE); status = set_film_type (s, film_params[s->val[OPT_FILM_TYPE].w]); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_film_type failed: %s\n", sane_strstatus (status)); return status; } } if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_BAY].cap)) { status = set_bay (s, s->val[OPT_BAY].w); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_bay: %s\n", sane_strstatus (status)); return status; } } if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_SHARPNESS].cap)) { status = set_outline_emphasis (s, s->val[OPT_SHARPNESS].w); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_outline_emphasis failed: %s\n", sane_strstatus (status)); return status; } } if (s->hw->cmd->set_gamma && SANE_OPTION_IS_ACTIVE (s->opt[OPT_GAMMA_CORRECTION].cap)) { int val; if (s->hw->cmd->level[0] == 'D') { /* * The D1 level has only the two user defined gamma * settings. */ val = gamma_params[s->val[OPT_GAMMA_CORRECTION].w]; } else { val = gamma_params[s->val[OPT_GAMMA_CORRECTION].w]; /* * If "Default" is selected then determine the actual value * to send to the scanner: If bilevel mode, just send the * value from the table (0x01), for grayscale or color mode * add one and send 0x02. */ /* if( s->val[ OPT_GAMMA_CORRECTION].w <= 1) { */ if (s->val[OPT_GAMMA_CORRECTION].w == 0) { val += mparam->depth == 1 ? 0 : 1; } } DBG (1, "sane_start: set_gamma( s, 0x%x ).\n", val); status = set_gamma (s, val); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_gamma failed: %s\n", sane_strstatus (status)); return status; } } if (s->hw->cmd->set_gamma_table && gamma_userdefined[s->val[OPT_GAMMA_CORRECTION].w]) { /* user defined. */ status = set_gamma_table (s); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_gamma_table failed: %s\n", sane_strstatus (status)); return status; } } /* * TODO: think about if SANE_OPTION_IS_ACTIVE is a good criteria to send commands. */ if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_COLOR_CORRECTION].cap)) { int val = color_params[s->val[OPT_COLOR_CORRECTION].w]; DBG (1, "sane_start: set_color_correction( s, 0x%x )\n", val); status = set_color_correction (s, val); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_color_correction failed: %s\n", sane_strstatus (status)); return status; } } if (1 == s->val[OPT_COLOR_CORRECTION].w) { /* user defined. */ status = set_color_correction_coefficients (s); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_color_correction_coefficients failed: %s\n", sane_strstatus (status)); return status; } } if (s->hw->cmd->set_threshold != 0 && SANE_OPTION_IS_ACTIVE (s->opt[OPT_THRESHOLD].cap)) { status = set_threshold (s, s->val[OPT_THRESHOLD].w); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_threshold(%d) failed: %s\n", s->val[OPT_THRESHOLD].w, sane_strstatus (status)); return status; } } ndpi = s->val[OPT_RESOLUTION].w; status = set_resolution (s, ndpi, ndpi); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_resolution(%d, %d) failed: %s\n", ndpi, ndpi, sane_strstatus (status)); return status; } status = sane_get_parameters (handle, NULL); if (status != SANE_STATUS_GOOD) return status; /* set the zoom */ if (s->hw->cmd->set_zoom != 0 && SANE_OPTION_IS_ACTIVE (s->opt[OPT_ZOOM].cap)) { status = set_zoom (s, s->val[OPT_ZOOM].w, s->val[OPT_ZOOM].w); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: set_zoom(%d) failed: %s\n", s->val[OPT_ZOOM].w, sane_strstatus (status)); return status; } } /* * Now s->params is initialized. */ /* * If WAIT_FOR_BUTTON is active, then do just that: Wait until the button is * pressed. If the button was already pressed, then we will get the button * Pressed event right away. */ if (s->val[OPT_WAIT_FOR_BUTTON].w == SANE_TRUE) { s->hw->wait_for_button = SANE_TRUE; while (s->hw->wait_for_button == SANE_TRUE) { if (s->canceling == SANE_TRUE) { s->hw->wait_for_button = SANE_FALSE; } /* get the button status from the scanner */ else if (request_push_button_status (s, &button_status) == SANE_STATUS_GOOD) { if (button_status == SANE_TRUE) { s->hw->wait_for_button = SANE_FALSE; } else { sleep (1); } } else { /* we run into an eror condition, just continue */ s->hw->wait_for_button = SANE_FALSE; } } } /* * in file:frontend/preview.c * * The preview strategy is as follows: * * 1) A preview always acquires an image that covers the entire * scan surface. This is necessary so the user can see not * only what is, but also what isn't selected. */ left = SANE_UNFIX (s->val[OPT_TL_X].w) / 25.4 * ndpi + 0.5; top = SANE_UNFIX (s->val[OPT_TL_Y].w) / 25.4 * ndpi + 0.5; /* * Calculate correction for line_distance in D1 scanner: * Start line_distance lines earlier and add line_distance lines at the end * * Because the actual line_distance is not yet calculated we have to do this * first. */ s->hw->color_shuffle = SANE_FALSE; s->current_output_line = 0; s->lines_written = 0; s->color_shuffle_line = 0; if ((s->hw->optical_res != 0) && (mparam->depth == 8) && (mparam->mode_flags != 0)) { s->line_distance = s->hw->max_line_distance * ndpi / s->hw->optical_res; if (s->line_distance != 0) { s->hw->color_shuffle = SANE_TRUE; } else s->hw->color_shuffle = SANE_FALSE; } /* * for debugging purposes: */ #ifdef FORCE_COLOR_SHUFFLE DBG (1, "Test mode: FORCE_COLOR_SHUFFLE = TRUE\n"); s->hw->color_shuffle = SANE_TRUE; #endif /* * Modify the scan area: If the scanner requires color shuffling, then we try to * scan more lines to compensate for the lines that will be removed from the scan * due to the color shuffling alghorithm. * At this time we add two times the line distance to the number of scan lines if * this is possible - if not, then we try to calculate the number of additional * lines according to the selected scan area. */ if (s->hw->color_shuffle == SANE_TRUE) { /* start the scan 2*line_distance earlier */ top -= 2 * s->line_distance; if (top < 0) { top = 0; } /* scan 4*line_distance lines more */ s->params.lines += 4 * s->line_distance; } /* * If (top + s->params.lines) is larger than the max scan area, reset * the number of scan lines: */ if (SANE_UNFIX (s->val[OPT_BR_Y].w) / 25.4 * ndpi < (s->params.lines + top)) { s->params.lines = ((int) SANE_UNFIX (s->val[OPT_BR_Y].w) / 25.4 * ndpi + 0.5) - top; } status = set_scan_area (s, left, top, s->params.pixels_per_line, s->params.lines); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_scan_area failed: %s\n", sane_strstatus (status)); return status; } s->block = SANE_FALSE; lcount = 1; /* * The set line count commands needs to be sent for certain scanners in * color mode. The D1 level requires it, we are however only testing for * 'D' and not for the actual numeric level. */ if (((s->hw->cmd->level[0] == 'B') && ((s->hw->level >= 5) || ((s->hw->level >= 4) && (!mode_params[s->val[OPT_MODE].w].color)))) || (s->hw->cmd->level[0] == 'D')) { s->block = SANE_TRUE; lcount = sanei_scsi_max_request_size / s->params.bytes_per_line; if (lcount >= 255) { lcount = 255; } if (s->hw->TPU && s->hw->use_extension && lcount > 32) { lcount = 32; } /* * The D1 series of scanners only allow an even line number * for bi-level scanning. If a bit depth of 1 is selected, then * make sure the next lower even number is selected. */ if (s->hw->cmd->level[0] == 'D') { if (lcount % 2) { lcount -= 1; } } if (lcount == 0) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } status = set_lcount (s, lcount); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: set_lcount(%d) failed: %s\n", lcount, sane_strstatus (status)); return status; } } if (s->hw->cmd->request_extended_status != 0 && SANE_TRUE == s->hw->extension) { u_char result[4]; u_char *buf; size_t len; params[0] = ESC; params[1] = s->hw->cmd->request_extended_status; send (s, params, 2, &status); /* send ESC f (request extended status) */ if (SANE_STATUS_GOOD == status) { len = 4; /* receive header */ receive (s, result, len, &status); if (SANE_STATUS_GOOD != status) return status; len = result[3] << 8 | result[2]; buf = alloca (len); receive (s, buf, len, &status); /* receive actual status data */ if (buf[0] & 0x80) { close_scanner (s); return SANE_STATUS_INVAL; } } else { DBG (1, "Extended status flag request failed\n"); } } /* * for debug purpose * check scanner conditions */ #if 1 if (s->hw->cmd->request_condition != 0) { u_char result[4]; u_char *buf; size_t len; params[0] = ESC; params[1] = s->hw->cmd->request_condition; send (s, params, 2, &status); /* send request condition */ if (SANE_STATUS_GOOD != status) return status; len = 4; receive (s, result, len, &status); if (SANE_STATUS_GOOD != status) return status; len = result[3] << 8 | result[2]; buf = alloca (len); receive (s, buf, len, &status); if (SANE_STATUS_GOOD != status) return status; #if 0 DBG (10, "SANE_START: length=%d\n", len); for (i = 1; i <= len; i++) { DBG (10, "SANE_START: %d: %c\n", i, buf[i - 1]); } #endif DBG (5, "SANE_START: Color: %d\n", (int) buf[1]); DBG (5, "SANE_START: Resolution (x, y): (%d, %d)\n", (int) (buf[4] << 8 | buf[3]), (int) (buf[6] << 8 | buf[5])); DBG (5, "SANE_START: Scan area(pixels) (x0, y0), (x1, y1): (%d, %d), (%d, %d)\n", (int) (buf[9] << 8 | buf[8]), (int) (buf[11] << 8 | buf[10]), (int) (buf[13] << 8 | buf[12]), (int) (buf[15] << 8 | buf[14])); DBG (5, "SANE_START: Data format: %d\n", (int) buf[17]); DBG (5, "SANE_START: Halftone: %d\n", (int) buf[19]); DBG (5, "SANE_START: Brightness: %d\n", (int) buf[21]); DBG (5, "SANE_START: Gamma: %d\n", (int) buf[23]); DBG (5, "SANE_START: Zoom (x, y): (%d, %d)\n", (int) buf[26], (int) buf[25]); DBG (5, "SANE_START: Color correction: %d\n", (int) buf[28]); DBG (5, "SANE_START: Sharpness control: %d\n", (int) buf[30]); DBG (5, "SANE_START: Scanning mode: %d\n", (int) buf[32]); DBG (5, "SANE_START: Mirroring: %d\n", (int) buf[34]); DBG (5, "SANE_START: Auto area segmentation: %d\n", (int) buf[36]); DBG (5, "SANE_START: Threshold: %d\n", (int) buf[38]); DBG (5, "SANE_START: Line counter: %d\n", (int) buf[40]); DBG (5, "SANE_START: Option unit control: %d\n", (int) buf[42]); DBG (5, "SANE_START: Film type: %d\n", (int) buf[44]); } #endif /* set the retry count to 0 */ s->retry_count = 0; if (s->hw->color_shuffle == SANE_TRUE) { /* initialize the line buffers */ for (i = 0; i < s->line_distance * 2 + 1; i++) { if (s->line_buffer[i] != NULL) free (s->line_buffer[i]); s->line_buffer[i] = malloc (s->params.bytes_per_line); if (s->line_buffer[i] == NULL) { /* free the memory we've malloced so far */ for (j = 0; j < i; j++) { free (s->line_buffer[j]); s->line_buffer[j] = NULL; } DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } } } params[0] = ESC; params[1] = s->hw->cmd->start_scanning; send (s, params, 2, &status); if (SANE_STATUS_GOOD != status) { DBG (1, "sane_start: start failed: %s\n", sane_strstatus (status)); return status; } s->eof = SANE_FALSE; s->buf = realloc (s->buf, lcount * s->params.bytes_per_line); s->ptr = s->end = s->buf; s->canceling = SANE_FALSE; return SANE_STATUS_GOOD; } /* sane_start */ /* * * TODO: clean up the eject and direct cmd mess. */ SANE_Status sane_auto_eject (Epson_Scanner * s) { DBG (5, "sane_auto_eject()\n"); if (s->hw->ADF && s->hw->use_extension && s->val[OPT_AUTO_EJECT].w) { /* sequence! */ SANE_Status status; u_char params[1]; u_char cmd = s->hw->cmd->eject; if (!cmd) return SANE_STATUS_UNSUPPORTED; params[0] = cmd; send (s, params, 1, &status); if (SANE_STATUS_GOOD != (status = expect_ack (s))) { return status; } } return SANE_STATUS_GOOD; } /* * * */ static SANE_Status read_data_block (Epson_Scanner * s, EpsonDataRec * result) { SANE_Status status; u_char param[3]; receive (s, result, s->block ? 6 : 4, &status); if (SANE_STATUS_GOOD != status) return status; if (STX != result->code) { DBG (1, "code %02x\n", (int) result->code); DBG (1, "error, expected STX\n"); return SANE_STATUS_INVAL; } if (result->status & STATUS_FER) { int dummy_x, dummy_y; DBG (1, "fatal error - Status = %02x\n", result->status); status = check_ext_status (s, &dummy_x, &dummy_y); /* * Hack Alert!!! * If the status is SANE_STATUS_DEVICE_BUSY then we need to * re-issue the command again. We can assume that the command that * caused this problem was ESC G, so in a loop with a sleep 1 we * are testing this over and over and over again, until the lamp * "thinks" it is ready. * * TODO: Store the last command and execute what was actually used * as the last command. For all situations this error may occur * ESC G is very very likely to be the command in question, but * we better make sure that this is the case. * */ /* * let's safe some stack space: If this is not the first go around, * then just return the status and let the loop handle this - otherwise * we would run this function recursively. */ if ((status == SANE_STATUS_DEVICE_BUSY && s->retry_count > 0) || (status == SANE_STATUS_GOOD && s->retry_count > 0)) { return SANE_STATUS_DEVICE_BUSY; /* return busy even if we just read OK so that the following loop can end gracefully */ } while (status == SANE_STATUS_DEVICE_BUSY) { if (s->retry_count > SANE_EPSON_MAX_RETRIES) { DBG (1, "Max retry count exceeded (%d)\n", s->retry_count); return SANE_STATUS_INVAL; } sleep (1); /* wait one second for the next attempt */ DBG (1, "retrying ESC G - %d\n", ++(s->retry_count)); param[0] = ESC; param[1] = s->hw->cmd->start_scanning; send (s, param, 2, &status); if (SANE_STATUS_GOOD != status) { DBG (1, "read_data_block: start failed: %s\n", sane_strstatus (status)); return status; } status = read_data_block (s, result); } } return status; } /* * * */ void scan_finish (Epson_Scanner * s) { SANE_Status status; int i, x, y; DBG (5, "scan_finish()\n"); free (s->buf); s->buf = NULL; status = check_ext_status (s, &x, &y); if (SANE_STATUS_NO_DOCS == status && s->hw->ADF && s->hw->use_extension) sane_auto_eject (s); for (i = 0; i < s->line_distance; i++) { if (s->line_buffer[i] != NULL) { free (s->line_buffer[i]); s->line_buffer[i] = NULL; } } } #define GET_COLOR(x) ((x.status>>2) & 0x03) SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Status status; int index = 0; SANE_Bool reorder = SANE_FALSE; SANE_Bool needStrangeReorder = SANE_FALSE; START_READ: DBG (5, "sane_read: begin\n"); if (s->ptr == s->end) { EpsonDataRec result; size_t buf_len; if ((s->fd != -1) && s->eof) { if (s->hw->color_shuffle) { DBG (1, "Written %d lines after color shuffle\n", s->lines_written); DBG (1, "Lines requested: %d\n", s->params.lines); } *length = 0; scan_finish (s); return SANE_STATUS_EOF; } DBG (5, "sane_read: begin scan1\n"); if (SANE_STATUS_GOOD != (status = read_data_block (s, &result))) { *length = 0; scan_finish (s); return status; } buf_len = result.buf[1] << 8 | result.buf[0]; DBG (5, "sane_read: buf len = %lu\n", (u_long) buf_len); if (s->block) { buf_len *= (result.buf[3] << 8 | result.buf[2]); DBG (5, "sane_read: buf len (adjusted) = %lu\n", (u_long) buf_len); } if (!s->block && SANE_FRAME_RGB == s->params.format) { /* * Read color data in line mode */ /* * read the first color line - the number of bytes to read * is already known (from last call to read_data_block() * We determine where to write the line from the color information * in the data block. At the end we want the order RGB, but the * way the data is delivered does not guarantee this - actually it's * most likely that the order is GRB if it's not RGB! */ switch (GET_COLOR (result)) { case 1: index = 1; break; case 2: index = 0; break; case 3: index = 2; break; } receive (s, s->buf + index * s->params.pixels_per_line, buf_len, &status); if (SANE_STATUS_GOOD != status) return status; /* * send the ACK signal to the scanner in order to make * it ready for the next data block. */ send (s, S_ACK, 1, &status); /* * ... and request the next data block */ if (SANE_STATUS_GOOD != (status = read_data_block (s, &result))) return status; buf_len = result.buf[1] << 8 | result.buf[0]; /* * this should never happen, because we are already in * line mode, but it does not hurt to check ... */ if (s->block) buf_len *= (result.buf[3] << 8 | result.buf[2]); DBG (5, "sane_read: buf len2 = %lu\n", (u_long) buf_len); switch (GET_COLOR (result)) { case 1: index = 1; break; case 2: index = 0; break; case 3: index = 2; break; } receive (s, s->buf + index * s->params.pixels_per_line, buf_len, &status); if (SANE_STATUS_GOOD != status) { scan_finish (s); *length = 0; return status; } send (s, S_ACK, 1, &status); /* * ... and the last data block */ if (SANE_STATUS_GOOD != (status = read_data_block (s, &result))) { *length = 0; scan_finish (s); return status; } buf_len = result.buf[1] << 8 | result.buf[0]; if (s->block) buf_len *= (result.buf[3] << 8 | result.buf[2]); DBG (5, "sane_read: buf len3 = %lu\n", (u_long) buf_len); switch (GET_COLOR (result)) { case 1: index = 1; break; case 2: index = 0; break; case 3: index = 2; break; } receive (s, s->buf + index * s->params.pixels_per_line, buf_len, &status); if (SANE_STATUS_GOOD != status) { *length = 0; scan_finish (s); return status; } } else { /* * Read data in block mode */ /* do we have to reorder the data ? */ if (GET_COLOR (result) == 0x01) { reorder = SANE_TRUE; } receive (s, s->buf, buf_len, &status); if (SANE_STATUS_GOOD != status) { *length = 0; scan_finish (s); return status; } } if (result.status & STATUS_AREA_END) { s->eof = SANE_TRUE; } else { if (s->canceling) { send (s, S_CAN, 1, &status); expect_ack (s); *length = 0; scan_finish (s); return SANE_STATUS_CANCELLED; } else send (s, S_ACK, 1, &status); } s->end = s->buf + buf_len; s->ptr = s->buf; /* * if we have to re-order the color components (GRB->RGB) we * are doing this here: */ /* * Some scaners (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 Perfection1640. * If the scanner name is one of these, and the scan mode is * RGB then swap the colors. */ needStrangeReorder = (strstr (s->hw->sane.model, "GT-2200") || ((strstr (s->hw->sane.model, "1640") && strstr (s->hw->sane.model, "Perfection")) || strstr (s->hw->sane.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 * with the half vertical scanning area. When we corrected this, * we also set the variable s->hw->need_color_reorder */ if (s->hw->need_color_reorder) { needStrangeReorder = SANE_TRUE; } if (needStrangeReorder) reorder = SANE_FALSE; /* reordering once is enough */ if (s->params.format != SANE_FRAME_RGB) reorder = SANE_FALSE; /* don't reorder for BW or gray */ if (reorder) { SANE_Byte *ptr; ptr = s->buf; while (ptr < s->end) { if (s->params.depth > 8) { SANE_Byte tmp; /* R->G G->R */ tmp = ptr[0]; ptr[0] = ptr[2]; /* first Byte G */ ptr[2] = tmp; /* first Byte R */ tmp = ptr[1]; ptr[1] = ptr[3]; /* second Byte G */ ptr[3] = tmp; /* second Byte R */ ptr += 6; /* go to next pixel */ } else { /* R->G G->R */ SANE_Byte tmp; tmp = ptr[0]; ptr[0] = ptr[1]; /* G */ ptr[1] = tmp; /* R */ /* B stays the same */ ptr += 3; /* go to next pixel */ } } } /* * Do the color_shuffle if everything else is correct - at this time * most of the stuff is hardcoded for the Perfection 610 */ if (s->hw->color_shuffle) { int new_length = 0; status = color_shuffle (s, &new_length); /* * If no bytes are returned, check if the scanner is already done, if so, * we'll probably just return, but if there is more data to process get * the next batch. */ if (new_length == 0 && s->end != s->ptr) { goto START_READ; } s->end = s->buf + new_length; s->ptr = s->buf; } DBG (5, "sane_read: begin scan2\n"); } /* * copy the image data to the data memory area */ if (!s->block && SANE_FRAME_RGB == s->params.format) { max_length /= 3; if (max_length > s->end - s->ptr) max_length = s->end - s->ptr; *length = 3 * max_length; if (s->invert_image == SANE_TRUE) { while (max_length-- != 0) { /* invert the three values */ *data++ = (u_char) ~ (s->ptr[0]); *data++ = (u_char) ~ (s->ptr[s->params.pixels_per_line]); *data++ = (u_char) ~ (s->ptr[2 * s->params.pixels_per_line]); ++s->ptr; } } else { while (max_length-- != 0) { *data++ = s->ptr[0]; *data++ = s->ptr[s->params.pixels_per_line]; *data++ = s->ptr[2 * s->params.pixels_per_line]; ++s->ptr; } } } else { if (max_length > s->end - s->ptr) max_length = s->end - s->ptr; *length = max_length; if (1 == s->params.depth) { if (s->invert_image == SANE_TRUE) { while (max_length-- != 0) *data++ = *s->ptr++; } else { while (max_length-- != 0) *data++ = ~*s->ptr++; } } else { if (s->invert_image == SANE_TRUE) { int i; for (i = 0; i < max_length; i++) { data[i] = (u_char) ~ (s->ptr[i]); } } else { memcpy (data, s->ptr, max_length); } s->ptr += max_length; } } DBG (5, "sane_read: end\n"); return SANE_STATUS_GOOD; } static SANE_Status color_shuffle (SANE_Handle handle, int *new_length) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Byte *buf = s->buf; int length = s->end - s->buf; if (s->hw->color_shuffle == SANE_TRUE) { SANE_Byte *data_ptr; /* ptr to data to process */ SANE_Byte *data_end; /* ptr to end of processed data */ SANE_Byte *out_data_ptr; /* ptr to memory when writing data */ int i; /* loop counter */ /* * It looks like we are dealing with a scanner that has an odd way * of dealing with colors... The red and blue scan lines are shifted * up or down by a certain number of lines relative to the green line. */ DBG (5, "sane_read: color_shuffle\n"); /* * Initialize the variables we are going to use for the * copying of the data. data_ptr is the pointer to * the currently worked on scan line. data_end is the * end of the data area as calculated from adding *length * to the start of data. * out_data_ptr is used when writing out the processed data * and always points to the beginning of the next line to * write. */ data_ptr = out_data_ptr = buf; data_end = data_ptr + length; /* * The image data is in *buf, we know that the buffer contains s->end - s->buf ( = length) * bytes of data. The width of one line is in s->params.bytes_per_line */ /* * The buffer area is supposed to have a number of full scan * lines, let's test if this is the case. */ if (length % s->params.bytes_per_line != 0) { DBG (1, "ERROR in size of buffer: %d / %d\n", length, s->params.bytes_per_line); return SANE_STATUS_INVAL; } while (data_ptr < data_end) { SANE_Byte *source_ptr, *dest_ptr; int loop; /* copy the green information into the current line */ source_ptr = data_ptr + 1; dest_ptr = s->line_buffer[s->color_shuffle_line] + 1; for (i = 0; i < s->params.bytes_per_line / 3; i++) { *dest_ptr = *source_ptr; dest_ptr += 3; source_ptr += 3; } /* copy the red information n lines back */ if (s->color_shuffle_line >= s->line_distance) { source_ptr = data_ptr + 2; dest_ptr = s->line_buffer[s->color_shuffle_line - s->line_distance] + 2; /* while (source_ptr < s->line_buffer[s->color_shuffle_line] + s->params.bytes_per_line) */ for (loop = 0; loop < s->params.bytes_per_line / 3; loop++) { *dest_ptr = *source_ptr; dest_ptr += 3; source_ptr += 3; } } /* copy the blue information n lines forward */ source_ptr = data_ptr; dest_ptr = s->line_buffer[s->color_shuffle_line + s->line_distance]; /* while (source_ptr < s->line_buffer[s->color_shuffle_line] + s->params.bytes_per_line) */ for (loop = 0; loop < s->params.bytes_per_line / 3; loop++) { *dest_ptr = *source_ptr; dest_ptr += 3; source_ptr += 3; } data_ptr += s->params.bytes_per_line; if (s->color_shuffle_line == s->line_distance) { /* * we just finished the line in line_buffer[0] - write it to the * output buffer and continue. */ /* * The ouput buffer ist still "buf", but because we are * only overwriting from the beginning of the memory area * we are not interfering with the "still to shuffle" data * in the same area. */ /* * Strip the first and last n lines and limit to */ if ((s->current_output_line >= s->line_distance) && (s->current_output_line < s->params.lines + s->line_distance)) { memcpy (out_data_ptr, s->line_buffer[0], s->params.bytes_per_line); out_data_ptr += s->params.bytes_per_line; s->lines_written++; } s->current_output_line++; /* * Now remove the 0-entry and move all other * lines up by one. There are 2*line_distance + 1 * buffers, * therefore the loop has to run from 0 * to * 2*line_distance, and because we want to * copy every n+1st entry to n the loop runs * from - to 2*line_distance-1! */ free (s->line_buffer[0]); for (i = 0; i < s->line_distance * 2; i++) { s->line_buffer[i] = s->line_buffer[i + 1]; } /* * and create one new buffer at the end */ s->line_buffer[s->line_distance * 2] = malloc (s->params.bytes_per_line); if (s->line_buffer[s->line_distance * 2] == NULL) { int i; for (i = 0; i < s->line_distance * 2; i++) { free (s->line_buffer[i]); s->line_buffer[i] = NULL; } DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } } else { s->color_shuffle_line++; /* increase the buffer number */ } } /* * At this time we've used up all the new data from the scanner, some of * it is still in the line_buffers, but we are ready to return some of it * to the front end software. To do so we have to adjust the size of the * data area and the *new_length variable. */ *new_length = out_data_ptr - buf; } return SANE_STATUS_GOOD; } /* * static SANE_Status get_identity_information ( SANE_Handle handle) * * Request Identity information from scanner and fill in information * into dev and/or scanner structures. */ static SANE_Status get_identity_information (SANE_Handle handle) { Epson_Scanner *s = (Epson_Scanner *) handle; Epson_Device *dev = s->hw; EpsonIdent ident; u_char param[3]; SANE_Status status; u_char *buf; DBG (5, "get_identity_information()\n"); if (!s->hw->cmd->request_identity) return SANE_STATUS_INVAL; param[0] = ESC; param[1] = s->hw->cmd->request_identity; param[2] = '\0'; if (NULL == (ident = (EpsonIdent) command (s, param, 2, &status))) { DBG (1, "ident failed\n"); return SANE_STATUS_INVAL; } DBG (1, "type %3c 0x%02x\n", ident->type, ident->type); DBG (1, "level %3c 0x%02x\n", ident->level, ident->level); { char *force = getenv ("SANE_EPSON_CMD_LVL"); if (force) { ident->type = force[0]; ident->level = force[1]; DBG (1, "type %3c 0x%02x\n", ident->type, ident->type); DBG (1, "level %3c 0x%02x\n", ident->level, ident->level); DBG (1, "forced\n"); } } /* * check if option equipment is installed. */ if (ident->status & STATUS_OPTION) { DBG (1, "option equipment is installed\n"); dev->extension = SANE_TRUE; } else { DBG (1, "no option equipment installed\n"); dev->extension = SANE_FALSE; } dev->TPU = SANE_FALSE; dev->ADF = SANE_FALSE; /* * set command type and level. */ { int n; for (n = 0; n < NELEMS (epson_cmd); n++) { char type_level[3]; sprintf(type_level, "%c%c", ident->type, ident->level); if (!strncmp (type_level, epson_cmd[n].level, 2)) break; } if (n < NELEMS (epson_cmd)) { dev->cmd = &epson_cmd[n]; } else { dev->cmd = &epson_cmd[EPSON_LEVEL_DEFAULT]; DBG (1, "Unknown type %c or level %c, using %s\n", ident->type, ident->level, dev->cmd->level); } s->hw->level = dev->cmd->level[1] - '0'; } /* set comand type and level */ /* * Setting available resolutions and xy ranges for sane frontend. */ s->hw->res_list_size = 0; s->hw->res_list = (SANE_Int *) calloc (s->hw->res_list_size, sizeof (SANE_Int)); if (NULL == s->hw->res_list) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } { int n, k; int x = 0, y = 0; int count = ident->count2 * 255 + ident->count1; /* we need to correct for the difference in size between the EpsonIdentRec and the EpsonHdrRec */ int correction = sizeof (EpsonIdentRec) - sizeof (EpsonHdrRec); for (n = (count - correction), buf = ident->buf; n; n -= k, buf += k) { switch (*buf) { case 'R': { int val = buf[2] << 8 | buf[1]; s->hw->res_list_size++; s->hw->res_list = (SANE_Int *) realloc (s->hw->res_list, s->hw->res_list_size * sizeof (SANE_Int)); if (NULL == s->hw->res_list) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } s->hw->res_list[s->hw->res_list_size - 1] = (SANE_Int) val; DBG (1, "resolution (dpi): %d\n", val); k = 3; continue; } case 'A': { x = buf[2] << 8 | buf[1]; y = buf[4] << 8 | buf[3]; DBG (1, "maximum scan area: x %d y %d\n", x, y); k = 5; /* * Check for Perfection 4990 photo/GT-X800 scanner. * This scanner only report 3200 dpi back. * The scanner fysical supports 4800 dpi. * This is simulated here... * Futher details read: * EPSON Programming guide for EPSON Color Image Scanner Perfection 4990 */ if (s->hw->cmd->request_extended_status != 0) { u_char *buf; u_char params[2]; EpsonHdr head; params[0] = ESC; params[1] = s->hw->cmd->request_extended_status; if (NULL != (head = (EpsonHdr) command (s, params, 2, &status))) { buf = &head->buf[0x1A]; DBG (1, "product name %x %x %x %x %x %x %x %x \n", buf[0], buf[1],buf[2],buf[3],buf[4], buf[5],buf[6], buf[7] ); if (strncmp((char *) buf,"GT-X800",7) == 0) { int val = 0x12 << 8 | 0xC0; s->hw->res_list_size++; s->hw->res_list = (SANE_Int *) realloc (s->hw->res_list, s->hw->res_list_size * sizeof (SANE_Int)); if (NULL == s->hw->res_list) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } s->hw->res_list[s->hw->res_list_size - 1] = (SANE_Int) val; x = (x/32)*48; y = (y/32)*48; DBG (1, "resolution (dpi): %d\n", val); DBG (1, "maximum scan area GT-X800: x %d y %d\n", x, y); } } } continue; } default: break; } /* case */ break; } /* for */ dev->dpi_range.min = s->hw->res_list[0]; dev->dpi_range.max = s->hw->res_list[s->hw->res_list_size - 1]; dev->dpi_range.quant = 0; dev->fbf_x_range.min = 0; dev->fbf_x_range.max = SANE_FIX (x * 25.4 / dev->dpi_range.max); dev->fbf_x_range.quant = 0; dev->fbf_y_range.min = 0; dev->fbf_y_range.max = SANE_FIX (y * 25.4 / dev->dpi_range.max); dev->fbf_y_range.quant = 0; DBG (5, "fbf tlx %f tly %f brx %f bry %f [mm]\n", SANE_UNFIX (dev->fbf_x_range.min), SANE_UNFIX (dev->fbf_y_range.min), SANE_UNFIX (dev->fbf_x_range.max), SANE_UNFIX (dev->fbf_y_range.max)); } /* * Copy the resolution list to the resolution_list array so that the frontend can * display the correct values */ s->hw->resolution_list = malloc ((s->hw->res_list_size + 1) * sizeof (SANE_Word)); if (s->hw->resolution_list == NULL) { DBG (1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } *(s->hw->resolution_list) = s->hw->res_list_size; memcpy (&(s->hw->resolution_list[1]), s->hw->res_list, s->hw->res_list_size * sizeof (SANE_Word)); /* filter the resolution list */ /* the option is not yet initialized, for now just set it to false */ s->val[OPT_LIMIT_RESOLUTION].w = SANE_FALSE; filter_resolution_list (s); return SANE_STATUS_GOOD; } /* request identity */ /* * static SANE_Status get_identity2_information ( SANE_Handle handle) * * Request Identity2 information from scanner and fill in information * into dev and/or scanner structures. */ static SANE_Status get_identity2_information (SANE_Handle handle) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Status status; int len; u_char param[3]; u_char result[4]; u_char *buf; DBG (5, "get_identity2_information()\n"); if (s->hw->cmd->request_identity2 == 0) return SANE_STATUS_UNSUPPORTED; param[0] = ESC; param[1] = s->hw->cmd->request_identity2; param[2] = '\0'; send (s, param, 2, &status); if (SANE_STATUS_GOOD != status) return status; len = 4; /* receive header */ receive (s, result, len, &status); if (SANE_STATUS_GOOD != status) return status; len = result[3] << 8 | result[2]; buf = alloca (len); receive (s, buf, len, &status); /* reveive actual status data */ /* the first two bytes of the buffer contain the optical resolution */ s->hw->optical_res = buf[1] << 8 | buf[0]; /* * the 4th and 5th byte contain the line distance. Both values have to * be identical, otherwise this software can not handle this scanner. */ if (buf[4] != buf[5]) { close_scanner (s); return SANE_STATUS_INVAL; } s->hw->max_line_distance = buf[4]; return SANE_STATUS_GOOD; } /* * void sane_cancel(SANE_Handle handle) * * Set the cancel flag to true. The next time the backend requests data * from the scanner the CAN message will be sent. */ void sane_cancel (SANE_Handle handle) { Epson_Scanner *s = (Epson_Scanner *) handle; /* * If the s->ptr pointer is not NULL, then a scan operation * was started and if s->eof is FALSE, it was not finished. */ if (s->buf != NULL) { u_char *dummy; int len; /* malloc one line */ dummy = malloc (s->params.bytes_per_line); if (dummy == NULL) { DBG (1, "Out of memory\n"); return; } else { /* there is still data to read from the scanner */ s->canceling = SANE_TRUE; while (!s->eof && SANE_STATUS_CANCELLED != sane_read (s, dummy, s->params.bytes_per_line, &len)) { /* empty body, the while condition does the processing */ } free (dummy); } } } static SANE_Status request_focus_position (SANE_Handle handle, u_char * position) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Status status; int len; u_char param[3]; u_char result[4]; u_char *buf; DBG (5, "request_focus_position()\n"); if (s->hw->cmd->request_focus_position == 0) return SANE_STATUS_UNSUPPORTED; param[0] = ESC; param[1] = s->hw->cmd->request_focus_position; param[2] = '\0'; send (s, param, 2, &status); if (SANE_STATUS_GOOD != status) return status; len = 4; /* receive header */ receive (s, result, len, &status); if (SANE_STATUS_GOOD != status) return status; len = result[3] << 8 | result[2]; buf = alloca (len); receive (s, buf, len, &status); /* reveive actual status data */ *position = buf[1]; DBG (1, "Focus position = 0x%x\n", buf[1]); return SANE_STATUS_GOOD; } /* * Request the push button status * returns SANE_TRUE if the button was pressed * and SANE_FALSE if the button was not pressed * it also returns SANE_TRUE in case of an error. * This is necessary so that a process that waits for * the button does not block indefinitely. */ static SANE_Bool request_push_button_status (SANE_Handle handle, SANE_Bool * theButtonStatus) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Status status; int len; u_char param[3]; u_char result[4]; u_char *buf; DBG (5, "request_push_button_status()\n"); if (s->hw->cmd->request_push_button_status == 0) { DBG (1, "push button status unsupported\n"); return SANE_STATUS_UNSUPPORTED; } param[0] = ESC; param[1] = s->hw->cmd->request_push_button_status; param[2] = '\0'; send (s, param, 2, &status); if (SANE_STATUS_GOOD != status) { DBG (1, "error sending command\n"); return status; } len = 4; /* receive header */ receive (s, result, len, &status); if (SANE_STATUS_GOOD != status) return status; len = result[3] << 8 | result[2]; /* this should be 1 for scanners with one button */ buf = alloca (len); receive (s, buf, len, &status); /* reveive actual status data */ DBG (1, "Push button status = %d\n", buf[0] & 0x01); *theButtonStatus = ((buf[0] & 0x01) != 0); return (SANE_STATUS_GOOD); } static void filter_resolution_list (Epson_Scanner * s) { /* re-create the list */ if (s->val[OPT_LIMIT_RESOLUTION].w == SANE_TRUE) { /* copy the short list */ /* filter out all values that are not 300 or 400 dpi based */ int i; int new_size = 0; SANE_Bool is_correct_resolution = SANE_FALSE; for (i = 1; i <= s->hw->res_list_size; i++) { SANE_Word res; res = s->hw->res_list[i]; if ((res < 100) || (0 == (res % 300)) || (0 == (res % 400))) { /* add the value */ new_size++; s->hw->resolution_list[new_size] = s->hw->res_list[i]; /* check for a valid current resolution */ if (res == s->val[OPT_RESOLUTION].w) { is_correct_resolution = SANE_TRUE; } } } s->hw->resolution_list[0] = new_size; if (is_correct_resolution == SANE_FALSE) { for (i = 1; i <= new_size; i++) { if (s->val[OPT_RESOLUTION].w < s->hw->resolution_list[i]) { s->val[OPT_RESOLUTION].w = s->hw->resolution_list[i]; i = new_size + 1; } } } } else { /* copy the full list */ s->hw->resolution_list[0] = s->hw->res_list_size; memcpy (&(s->hw->resolution_list[1]), s->hw->res_list, s->hw->res_list_size * sizeof (SANE_Word)); } } /**********************************************************************************/ /* * SANE_Status sane_set_io_mode() * * not supported - for asynchronous I/O */ SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { /* get rid of compiler warning */ handle = handle; non_blocking = non_blocking; return SANE_STATUS_UNSUPPORTED; } /* * SANE_Status sane_get_select_fd() * * not supported - for asynchronous I/O */ SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { /* get rid of compiler warnings */ handle = handle; fd = fd; return SANE_STATUS_UNSUPPORTED; } /* vim:ts=2:sw=2:cindent: */ sane-backends-1.0.29/backend/epson2-ops.c0000666000000000000000000016223513615534521014752 00000000000000/* * epson2.c - SANE library for Epson scanners. * * Based on Kazuhiro Sasayama previous * Work on epson.[ch] file from the SANE package. * Please see those files for additional copyrights. * * Copyright (C) 2006-09 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" #include /* sleep */ #ifdef HAVE_SYS_SELECT_H #include #endif #include "byteorder.h" #include "epson2.h" #include "epson2-ops.h" #include "epson2-io.h" #include "epson2-commands.h" /* * request identity * | request identity2 * | | request status * | | | request condition * | | | | set color mode * | | | | | start scanning * | | | | | | set data format * | | | | | | | set resolution * | | | | | | | | set zoom * | | | | | | | | | set scan area * | | | | | | | | | | set brightness * | | | | | | | | | | | set gamma * | | | | | | | | | | | | set halftoning * | | | | | | | | | | | | | set color correction * | | | | | | | | | | | | | | initialize scanner * | | | | | | | | | | | | | | | set speed * | | | | | | | | | | | | | | | | set lcount * | | | | | | | | | | | | | | | | | mirror image * | | | | | | | | | | | | | | | | | | set gamma table * | | | | | | | | | | | | | | | | | | | set outline emphasis * | | | | | | | | | | | | | | | | | | | | set dither * | | | | | | | | | | | | | | | | | | | | | set color correction coefficients * | | | | | | | | | | | | | | | | | | | | | | request extension status * | | | | | | | | | | | | | | | | | | | | | | | control an extension * | | | | | | | | | | | | | | | | | | | | | | | | forward feed / eject * | | | | | | | | | | | | | | | | | | | | | | | | | feed * | | | | | | | | | | | | | | | | | | | | | | | | | | request push button status * | | | | | | | | | | | | | | | | | | | | | | | | | | | control auto area segmentation * | | | | | | | | | | | | | | | | | | | | | | | | | | | | set film type * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set exposure time * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set bay * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set threshold * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set focus position * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | request focus position * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | request extended identity * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | request scanner status * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | */ static struct EpsonCmd epson_cmd[] = { {"A1",'I', 0 ,'F','S', 0 ,'G', 0 ,'R', 0 ,'A', 0 ,{ 0, 0, 0}, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {"A2",'I', 0 ,'F','S', 0 ,'G','D','R','H','A','L',{-3, 3, 0},'Z','B', 0 ,'@', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {"B1",'I', 0 ,'F','S','C','G','D','R', 0 ,'A', 0 ,{ 0, 0, 0}, 0 ,'B', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {"B2",'I', 0 ,'F','S','C','G','D','R','H','A','L',{-3, 3, 0},'Z','B', 0 ,'@', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {"B3",'I', 0 ,'F','S','C','G','D','R','H','A','L',{-3, 3, 0},'Z','B','M','@', 0 , 0 , 0 , 0 , 0 , 0 ,'m','f','e', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {"B4",'I', 0 ,'F','S','C','G','D','R','H','A','L',{-3, 3, 0},'Z','B','M','@','g','d', 0 ,'z','Q','b','m','f','e', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {"B5",'I', 0 ,'F','S','C','G','D','R','H','A','L',{-3, 3, 0},'Z','B','M','@','g','d','K','z','Q','b','m','f','e', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {"B6",'I', 0 ,'F','S','C','G','D','R','H','A','L',{-3, 3, 0},'Z','B','M','@','g','d','K','z','Q','b','m','f','e', 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }, {"B7",'I', 0 ,'F','S','C','G','D','R','H','A','L',{-4, 3, 0},'Z','B','M','@','g','d','K','z','Q','b','m','f','e','\f', 0 ,'!','s','N', 0 , 0 ,'t', 0 , 0 ,'I','F'}, {"B8",'I', 0 ,'F','S','C','G','D','R','H','A','L',{-4, 3, 0},'Z','B','M','@','g','d','K','z','Q','b','m','f','e','\f', 0x19,'!','s','N', 0 , 0 ,'t','p','q','I','F'}, /* XXX 'f' probably not supported on F5 */ {"F5",'I', 0 ,'F','S','C','G','D','R','H','A','L',{-3, 3, 0},'Z', 0 ,'M','@','g','d','K','z','Q', 0 ,'m','f','e','\f', 0 , 0 , 0 ,'N','T','P', 0 , 0 , 0 , 0 , 0 }, {"D1",'I','i','F', 0 ,'C','G','D','R', 0 ,'A', 0 ,{ 0, 0, 0},'Z', 0 , 0 ,'@','g','d', 0 ,'z', 0 , 0 , 0 ,'f', 0 , 0 , 0 ,'!', 0 , 0 , 0 , 0 ,'t', 0 , 0 , 0 , 0 }, {"D2",'I','i','F', 0 ,'C','G','D','R', 0 ,'A', 0 ,{ 0, 0, 0},'Z', 0 , 0 ,'@','g','d', 0 ,'z', 0 , 0 , 0 ,'f','e', 0 , 0 ,'!', 0 ,'N', 0 , 0 ,'t', 0 , 0 , 0 , 0 }, {"D7",'I','i','F', 0 ,'C','G','D','R', 0 ,'A', 0 ,{ 0, 0, 0},'Z', 0 , 0 ,'@','g','d', 0 ,'z', 0 , 0 , 0 ,'f','e','\f', 0 ,'!', 0 ,'N', 0 , 0 ,'t', 0 , 0 , 0 , 0 }, {"D8",'I','i','F', 0 ,'C','G','D','R', 0 ,'A', 0 ,{ 0, 0, 0},'Z', 0 , 0 ,'@','g','d', 0 ,'z', 0 , 0 , 0 ,'f','e','\f', 0 ,'!', 0 ,'N', 0 , 0 ,'t', 0 , 0 , 0 , 0 }, }; extern struct mode_param mode_params[]; /* Define the different scan sources */ #define FBF_STR SANE_I18N("Flatbed") #define TPU_STR SANE_I18N("Transparency Unit") #define TP2_STR SANE_I18N("TPU8x10") #define ADF_STR SANE_I18N("Automatic Document Feeder") /* * source list need one dummy entry (save device settings is crashing). * NOTE: no const - this list gets created while exploring the capabilities * of the scanner. */ extern SANE_String_Const source_list[]; static int film_params[] = { 0, 1, 2, 3 }; extern const int halftone_params[]; static const int dropout_params[] = { 0x00, /* none */ 0x10, /* red */ 0x20, /* green */ 0x30 /* blue */ }; /* * Color correction: * One array for the actual parameters that get sent to the scanner (color_params[]), * one array for the strings that get displayed in the user interface (correction_list[]) * and one array to mark the user defined color correction (correction_userdefined[]). */ static const int correction_params[] = { 0x00, /* None */ 0x01, /* Auto */ 0x01, /* User defined */ }; void e2_dev_init(Epson_Device *dev, const char *devname, int conntype) { DBG(5, "%s\n", __func__); dev->name = NULL; dev->model = NULL; dev->connection = conntype; dev->model_id = 0; dev->sane.name = devname; dev->sane.model = NULL; dev->sane.type = "flatbed scanner"; dev->sane.vendor = "Epson"; dev->optical_res = 0; /* just to have it initialized */ dev->color_shuffle = SANE_FALSE; dev->extension = SANE_FALSE; dev->use_extension = SANE_FALSE; dev->need_color_reorder = SANE_FALSE; dev->need_double_vertical = SANE_FALSE; dev->cct_profile = &epson_cct_profiles[0]; /* default profile */ dev->cmd = &epson_cmd[EPSON_LEVEL_DEFAULT]; /* Change default level when using a network connection */ if (dev->connection == SANE_EPSON_NET) dev->cmd = &epson_cmd[EPSON_LEVEL_B7]; dev->last_res = 0; dev->last_res_preview = 0; /* set resolution to safe values */ dev->res_list_size = 0; dev->res_list = NULL; } SANE_Status e2_dev_post_init(struct Epson_Device *dev) { int i, last; DBG(5, "%s\n", __func__); /* find cct model id */ for (i = 0; epson_cct_models[i].name != NULL; i++) { if (strcmp(epson_cct_models[i].name, dev->model) == 0) { dev->model_id = epson_cct_models[i].id; break; } } /* find cct profile */ for (i = 0; epson_cct_profiles[i].model != 0xFF; i++) { if (epson_cct_profiles[i].model == dev->model_id) { dev->cct_profile = &epson_cct_profiles[i]; break; } } DBG(1, "CCT model id is 0x%02x, profile offset %d\n", dev->model_id, i); /* If we have been unable to obtain supported resolutions * due to the fact we are on the network transport, * add some convenient ones */ if (dev->res_list_size == 0) { int val = (dev->dpi_range.min < 150) ? 150 : dev->dpi_range.min; DBG(1, "cannot obtain resolution list, faking (%d-%d)\n", dev->dpi_range.min, dev->dpi_range.max); if (dev->dpi_range.min <= 25) e2_add_resolution(dev, 25); if (dev->dpi_range.min <= 50) e2_add_resolution(dev, 50); if (dev->dpi_range.min <= 75) e2_add_resolution(dev, 75); if (dev->dpi_range.min <= 100) e2_add_resolution(dev, 100); while (val <= dev->dpi_range.max) { e2_add_resolution(dev, val); val *= 2; } } /* try to expand the resolution list where appropriate */ last = dev->res_list[dev->res_list_size - 1]; DBG(1, "highest available resolution: %d\n", last); if (dev->optical_res > last) { DBG(1, "adding optical resolution (%d)\n", dev->optical_res); e2_add_resolution(dev, dev->optical_res); } /* add missing resolutions for known scanners */ if (e2_dev_model(dev, "GT-X800") || e2_dev_model(dev, "GT-X700")) { DBG(1, "known scanner, integrating resolution list\n"); e2_add_resolution(dev, 4800); e2_add_resolution(dev, 6400); e2_add_resolution(dev, 9600); e2_add_resolution(dev, 12800); last = dev->res_list[dev->res_list_size - 1]; } /* guess for the others */ if (dev->dpi_range.max > last && dev->dpi_range.max != dev->optical_res) { int val = last + last; DBG(1, "integrating resolution list (%d-%d)\n", val, dev->dpi_range.max); while (val <= dev->dpi_range.max) { e2_add_resolution(dev, val); val += last; } } /* * Copy the resolution list to the resolution_list array so that the frontend can * display the correct values */ dev->resolution_list = malloc((dev->res_list_size + 1) * sizeof(SANE_Word)); if (dev->resolution_list == NULL) return SANE_STATUS_NO_MEM; *(dev->resolution_list) = dev->res_list_size; memcpy(&(dev->resolution_list[1]), dev->res_list, dev->res_list_size * sizeof(SANE_Word)); /* establish defaults */ dev->need_reset_on_source_change = SANE_FALSE; if (e2_dev_model(dev, "ES-9000H") || e2_dev_model(dev, "GT-30000")) { dev->cmd->set_focus_position = 0; dev->cmd->feed = 0x19; } if (e2_dev_model(dev, "GT-8200") || e2_dev_model(dev, "Perfection1650") || e2_dev_model(dev, "Perfection1640") || e2_dev_model(dev, "GT-8700")) { dev->cmd->feed = 0; dev->cmd->set_focus_position = 0; dev->need_reset_on_source_change = SANE_TRUE; } return SANE_STATUS_GOOD; } SANE_Bool e2_dev_model(Epson_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; } void e2_set_cmd_level(SANE_Handle handle, unsigned char *level) { Epson_Scanner *s = (Epson_Scanner *) handle; Epson_Device *dev = s->hw; int n; DBG(1, "%s: %c%c\n", __func__, level[0], level[1]); /* set command type and level */ for (n = 0; n < NELEMS(epson_cmd); n++) { char type_level[3]; sprintf(type_level, "%c%c", level[0], level[1]); if (!strncmp(type_level, epson_cmd[n].level, 2)) break; } if (n < NELEMS(epson_cmd)) { dev->cmd = &epson_cmd[n]; } else { dev->cmd = &epson_cmd[EPSON_LEVEL_DEFAULT]; DBG(1, " unknown type %c or level %c, using %s\n", level[0], level[1], dev->cmd->level); } s->hw->level = dev->cmd->level[1] - '0'; } SANE_Status e2_set_model(Epson_Scanner * s, unsigned char *model, size_t len) { unsigned char *buf; unsigned char *p; struct Epson_Device *dev = s->hw; buf = malloc(len + 1); if (buf == NULL) return SANE_STATUS_NO_MEM; memcpy(buf, model, len); buf[len] = '\0'; p = &buf[len - 1]; while (*p == ' ') { *p = '\0'; p--; } if (dev->model) free(dev->model); dev->model = strndup((const char *) buf, len); dev->sane.model = dev->model; DBG(10, "%s: model is '%s'\n", __func__, dev->model); free(buf); return SANE_STATUS_GOOD; } SANE_Status e2_add_resolution(Epson_Device *dev, int r) { dev->res_list_size++; dev->res_list = (SANE_Int *) realloc(dev->res_list, dev->res_list_size * sizeof(SANE_Word)); DBG(10, "%s: add (dpi): %d\n", __func__, r); if (dev->res_list == NULL) return SANE_STATUS_NO_MEM; dev->res_list[dev->res_list_size - 1] = (SANE_Int) r; return SANE_STATUS_GOOD; } void e2_set_fbf_area(Epson_Scanner * s, int x, int y, int unit) { struct Epson_Device *dev = s->hw; if (x == 0 || y == 0) return; dev->fbf_x_range.min = 0; dev->fbf_x_range.max = SANE_FIX(x * MM_PER_INCH / unit); dev->fbf_x_range.quant = 0; dev->fbf_y_range.min = 0; dev->fbf_y_range.max = SANE_FIX(y * MM_PER_INCH / unit); dev->fbf_y_range.quant = 0; DBG(5, "%s: %f,%f %f,%f %d [mm]\n", __func__, SANE_UNFIX(dev->fbf_x_range.min), SANE_UNFIX(dev->fbf_y_range.min), SANE_UNFIX(dev->fbf_x_range.max), SANE_UNFIX(dev->fbf_y_range.max), unit); } void e2_set_adf_area(struct Epson_Scanner *s, int x, int y, int unit) { struct Epson_Device *dev = s->hw; dev->adf_x_range.min = 0; dev->adf_x_range.max = SANE_FIX(x * MM_PER_INCH / unit); dev->adf_x_range.quant = 0; dev->adf_y_range.min = 0; dev->adf_y_range.max = SANE_FIX(y * MM_PER_INCH / unit); dev->adf_y_range.quant = 0; DBG(5, "%s: %f,%f %f,%f %d [mm]\n", __func__, SANE_UNFIX(dev->adf_x_range.min), SANE_UNFIX(dev->adf_y_range.min), SANE_UNFIX(dev->adf_x_range.max), SANE_UNFIX(dev->adf_y_range.max), unit); } void e2_set_tpu_area(struct Epson_Scanner *s, int x, int y, int unit) { struct Epson_Device *dev = s->hw; dev->tpu_x_range.min = 0; dev->tpu_x_range.max = SANE_FIX(x * MM_PER_INCH / unit); dev->tpu_x_range.quant = 0; dev->tpu_y_range.min = 0; dev->tpu_y_range.max = SANE_FIX(y * MM_PER_INCH / unit); dev->tpu_y_range.quant = 0; DBG(5, "%s: %f,%f %f,%f %d [mm]\n", __func__, SANE_UNFIX(dev->tpu_x_range.min), SANE_UNFIX(dev->tpu_y_range.min), SANE_UNFIX(dev->tpu_x_range.max), SANE_UNFIX(dev->tpu_y_range.max), unit); } void e2_set_tpu2_area(struct Epson_Scanner *s, int x, int y, int unit) { struct Epson_Device *dev = s->hw; dev->tpu2_x_range.min = 0; dev->tpu2_x_range.max = SANE_FIX(x * MM_PER_INCH / unit); dev->tpu2_x_range.quant = 0; dev->tpu2_y_range.min = 0; dev->tpu2_y_range.max = SANE_FIX(y * MM_PER_INCH / unit); dev->tpu2_y_range.quant = 0; DBG(5, "%s: %f,%f %f,%f %d [mm]\n", __func__, SANE_UNFIX(dev->tpu2_x_range.min), SANE_UNFIX(dev->tpu2_y_range.min), SANE_UNFIX(dev->tpu2_x_range.max), SANE_UNFIX(dev->tpu2_y_range.max), unit); } void e2_add_depth(Epson_Device *dev, SANE_Int depth) { DBG(10, "%s: add (bpp): %d\n", __func__, depth); if (depth > dev->maxDepth) dev->maxDepth = depth; dev->depth_list[0]++; dev->depth_list[dev->depth_list[0]] = depth; } /* A little helper function to correct the extended status reply * gotten from scanners with known buggy firmware. */ static void fix_up_extended_status_reply(Epson_Scanner * s, unsigned char *buf) { if (e2_model(s, "ES-9000H") || e2_model(s, "GT-30000")) { DBG(1, "fixing up buggy ADF max scan dimensions.\n"); buf[2] = 0xB0; buf[3] = 0x6D; buf[4] = 0x60; buf[5] = 0x9F; } } SANE_Status e2_discover_capabilities(Epson_Scanner *s) { SANE_Status status; unsigned char scanner_status; Epson_Device *dev = s->hw; SANE_String_Const *source_list_add = source_list; DBG(5, "%s\n", __func__); /* always add flatbed */ *source_list_add++ = FBF_STR; /* ESC I, request identity * this must be the first command on the FilmScan 200 */ if (dev->connection != SANE_EPSON_NET) { unsigned int n, k, x = 0, y = 0; unsigned char *buf, *area; size_t len; status = esci_request_identity(s, &buf, &len); if (status != SANE_STATUS_GOOD) return status; e2_set_cmd_level(s, &buf[0]); /* Setting available resolutions and xy ranges for sane frontend. */ /* cycle thru the resolutions, saving them in a list */ for (n = 2, k = 0; n < len; n += k) { area = buf + n; switch (*area) { case 'R': { int val = area[2] << 8 | area[1]; status = e2_add_resolution(s->hw, val); k = 3; continue; } case 'A': { x = area[2] << 8 | area[1]; y = area[4] << 8 | area[3]; DBG(1, "maximum scan area: %dx%d\n", x, y); k = 5; continue; } default: break; } } /* min and max dpi */ dev->dpi_range.min = dev->res_list[0]; dev->dpi_range.max = dev->res_list[dev->res_list_size - 1]; dev->dpi_range.quant = 0; e2_set_fbf_area(s, x, y, dev->dpi_range.max); free(buf); } /* ESC F, request status */ status = esci_request_status(s, &scanner_status); if (status != SANE_STATUS_GOOD) return status;; /* set capabilities */ if (scanner_status & STATUS_OPTION) dev->extension = SANE_TRUE; if (scanner_status & STATUS_EXT_COMMANDS) dev->extended_commands = 1; /* * Extended status flag request (ESC f). * this also requests the scanner device name from the scanner. * It seems unsupported on the network transport (CX11NF/LP-A500). */ if (dev->cmd->request_extended_status && dev->connection != SANE_EPSON_NET) { unsigned char *es; size_t es_len; DBG(1, "detection with request_extended_status\n"); status = esci_request_extended_status(s, &es, &es_len); if (status != SANE_STATUS_GOOD) return status; /* * Get the device name and copy it to dev->sane.model. * The device name starts at es[0x1A] and is up to 16 bytes long * We are overwriting whatever was set previously! */ if (es_len == CMD_SIZE_EXT_STATUS) /* 42 */ e2_set_model(s, es + 0x1A, 16); if (es[0] & EXT_STATUS_LID) DBG(1, "LID detected\n"); if (es[0] & EXT_STATUS_PB) DBG(1, "push button detected\n"); else dev->cmd->request_push_button_status = 0; /* Flatbed */ e2_set_fbf_area(s, es[13] << 8 | es[12], es[15] << 8 | es[14], dev->dpi_range.max); /* ADF */ if (dev->extension && (es[1] & EXT_STATUS_IST)) { DBG(1, "ADF detected\n"); fix_up_extended_status_reply(s, es); dev->duplex = (es[0] & EXT_STATUS_ADFS) != 0; if (dev->duplex) DBG(1, "ADF supports duplex\n"); if (es[1] & EXT_STATUS_EN) { DBG(1, "ADF is enabled\n"); dev->x_range = &dev->adf_x_range; dev->y_range = &dev->adf_y_range; } e2_set_adf_area(s, es[3] << 8 | es[2], es[5] << 8 | es[4], dev->dpi_range.max); *source_list_add++ = ADF_STR; dev->ADF = SANE_TRUE; } /* TPU */ if (dev->extension && (es[6] & EXT_STATUS_IST)) { DBG(1, "TPU detected\n"); if (es[6] & EXT_STATUS_EN) { DBG(1, "TPU is enabled\n"); dev->x_range = &dev->tpu_x_range; dev->y_range = &dev->tpu_y_range; } e2_set_tpu_area(s, (es[8] << 8 | es[7]), (es[10] << 8 | es[9]), dev->dpi_range.max); *source_list_add++ = TPU_STR; dev->TPU = SANE_TRUE; } free(es); *source_list_add = NULL; /* add end marker to source list */ } /* FS I, request extended identity (B7/B8) */ if (dev->extended_commands && dev->cmd->request_extended_identity) { unsigned char buf[80]; DBG(1, "detection with request_extended_identity\n"); status = esci_request_extended_identity(s, buf); if (status != SANE_STATUS_GOOD) return status; e2_set_cmd_level(s, &buf[0]); dev->maxDepth = buf[67]; /* set model name. it will probably be * different than the one reported by request_identity * for the same unit (i.e. LP-A500 vs CX11) . */ e2_set_model(s, &buf[46], 16); dev->optical_res = le32atoh(&buf[4]); dev->dpi_range.min = le32atoh(&buf[8]); dev->dpi_range.max = le32atoh(&buf[12]); /* Flatbed */ e2_set_fbf_area(s, le32atoh(&buf[20]), le32atoh(&buf[24]), dev->optical_res); /* ADF */ if (le32atoh(&buf[28]) > 0) { e2_set_adf_area(s, le32atoh(&buf[28]), le32atoh(&buf[32]), dev->optical_res); if (!dev->ADF) { *source_list_add++ = ADF_STR; dev->ADF = SANE_TRUE; } if (buf[44] & EXT_IDTY_CAP1_ADFS) { dev->duplex = SANE_TRUE; } } /* TPU */ if (le32atoh(&buf[36]) > 0 && !dev->TPU) { e2_set_tpu_area(s, le32atoh(&buf[36]), le32atoh(&buf[40]), dev->optical_res); *source_list_add++ = TPU_STR; dev->TPU = SANE_TRUE; } /* TPU2 */ if (e2_model(s, "GT-X800") || e2_model(s, "GT-X900") || e2_model(s, "GT-X980")) { if (le32atoh(&buf[68]) > 0 ) { e2_set_tpu2_area(s, le32atoh(&buf[68]), le32atoh(&buf[72]), dev->optical_res); *source_list_add++ = TP2_STR; } } *source_list_add = NULL; /* add end marker to source list */ } else { DBG(1, "no command available to detect capabilities\n"); } /* * request identity 2 (ESC i), if available will * get the information from the scanner and store it in dev */ if (dev->cmd->request_identity2 && dev->connection != SANE_EPSON_NET) { unsigned char *buf; status = esci_request_identity2(s, &buf); if (status != SANE_STATUS_GOOD) return status; /* the first two bytes of the buffer contain the optical resolution */ dev->optical_res = buf[1] << 8 | buf[0]; /* * the 4th and 5th byte contain the line distance. Both values have to * be identical, otherwise this software can not handle this scanner. */ if (buf[4] != buf[5]) { status = SANE_STATUS_INVAL; return status; } dev->max_line_distance = buf[4]; } /* * Check for the max. supported color depth and assign * the values to the bitDepthList. */ dev->depth_list = malloc(sizeof(SANE_Int) * (4 + 1)); if (dev->depth_list == NULL) { DBG(1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } dev->depth_list[0] = 0; /* maximum depth discovery */ DBG(3, "discovering max depth, NAKs are expected\n"); /* add default depth */ e2_add_depth(dev, 8); if (dev->maxDepth >= 12 || dev->maxDepth == 0) { if (esci_set_data_format(s, 12) == SANE_STATUS_GOOD) e2_add_depth(dev, 12); } if (dev->maxDepth >= 14 || dev->maxDepth == 0) { if (esci_set_data_format(s, 14) == SANE_STATUS_GOOD) e2_add_depth(dev, 14); } if (dev->maxDepth >= 16 || dev->maxDepth == 0) { if (esci_set_data_format(s, 16) == SANE_STATUS_GOOD) e2_add_depth(dev, 16); } DBG(1, "maximum supported color depth: %d\n", dev->maxDepth); /* * Check for "request focus position" command. If this command is * supported, then the scanner does also support the "set focus * position" command. * XXX ??? */ if (esci_request_focus_position(s, &s->currentFocusPosition) == SANE_STATUS_GOOD) { DBG(1, "setting focus is supported\n"); dev->focusSupport = SANE_TRUE; s->opt[OPT_FOCUS].cap &= ~SANE_CAP_INACTIVE; /* reflect the current focus position in the GUI */ if (s->currentFocusPosition < 0x4C) { /* focus on glass */ s->val[OPT_FOCUS].w = 0; } else { /* focus 2.5mm above glass */ s->val[OPT_FOCUS].w = 1; } } else { DBG(1, "setting focus is not supported\n"); dev->focusSupport = SANE_FALSE; s->opt[OPT_FOCUS].cap |= SANE_CAP_INACTIVE; s->val[OPT_FOCUS].w = 0; /* on glass - just in case */ } /* Set defaults for no extension. */ dev->x_range = &dev->fbf_x_range; dev->y_range = &dev->fbf_y_range; /* * Correct for a firmware bug in some Perfection 1650 scanners: * Firmware version 1.08 reports only half the vertical scan area, we have * to double the number. To find out if we have to do this, we just compare * is the vertical range is smaller than the horizontal range. */ if ((dev->x_range->max - dev->x_range->min) > (dev->y_range->max - dev->y_range->min)) { DBG(1, "found buggy scan area, doubling it.\n"); dev->y_range->max += (dev->y_range->max - dev->y_range->min); dev->need_double_vertical = SANE_TRUE; dev->need_color_reorder = SANE_TRUE; } /* FS F, request scanner status */ if (dev->extended_commands) { unsigned char buf[16]; status = esci_request_scanner_status(s, buf); if (status != SANE_STATUS_GOOD) return status; } return status; } SANE_Status e2_set_extended_scanning_parameters(Epson_Scanner * s) { unsigned char buf[64]; const struct mode_param *mparam; DBG(1, "%s\n", __func__); mparam = &mode_params[s->val[OPT_MODE].w]; memset(buf, 0x00, sizeof(buf)); /* ESC R, resolution */ htole32a(&buf[0], s->val[OPT_RESOLUTION].w); htole32a(&buf[4], s->val[OPT_RESOLUTION].w); /* ESC A, scanning area */ htole32a(&buf[8], s->left); htole32a(&buf[12], s->top); htole32a(&buf[16], s->params.pixels_per_line); htole32a(&buf[20], s->params.lines); /* * The byte sequence mode was introduced in B5, *for B[34] we need line sequence mode */ /* ESC C, set color */ if ((s->hw->cmd->level[0] == 'D' || (s->hw->cmd->level[0] == 'B' && s->hw->level >= 5)) && mparam->flags == 0x02) { buf[24] = 0x13; } else { buf[24] = mparam->flags | (mparam->dropout_mask & dropout_params[s-> val[OPT_DROPOUT]. w]); } /* ESC D, set data format */ mparam = &mode_params[s->val[OPT_MODE].w]; buf[25] = mparam->depth; /* ESC e, control option */ if (s->hw->extension) { char extensionCtrl; extensionCtrl = (s->hw->use_extension ? 1 : 0); if (s->hw->use_extension && (s->val[OPT_ADF_MODE].w == 1)) { extensionCtrl = 2; } /* Test for TPU2 * Epson Perfection 4990 Command Specifications * JZIS-0075 Rev. A, page 31 */ if (s->hw->use_extension && s->hw->TPU2) { extensionCtrl = 5; } if (s->val[OPT_MODE].w == MODE_INFRARED) { /* only infrared in TPU mode (NOT in TPU2 or flatbeth) * XXX investigate this ... only tested on GT-X800 */ if (extensionCtrl == 1) /* test for TPU */ extensionCtrl = 3; else return SANE_STATUS_UNSUPPORTED; } /* ESC e */ buf[26] = extensionCtrl; /* XXX focus */ } /* ESC g, scanning mode (normal or high speed) */ if (s->val[OPT_PREVIEW].w) buf[27] = 1; /* High speed */ else buf[27] = 0; /* ESC d, block line number */ buf[28] = s->lcount; /* ESC Z, set gamma correction */ buf[29] = 0x01; /* default */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_GAMMA_CORRECTION].cap)) { char val; if (s->hw->cmd->level[0] == 'D') { /* The D1 level has only the two user defined gamma * settings. */ val = gamma_params[s->val[OPT_GAMMA_CORRECTION].w]; } else { val = gamma_params[s->val[OPT_GAMMA_CORRECTION].w]; /* * If "Default" is selected then determine the actual value * to send to the scanner: If bilevel mode, just send the * value from the table (0x01), for grayscale or color mode * add one and send 0x02. */ if (s->val[OPT_GAMMA_CORRECTION].w == 0) { val += mparam->depth == 1 ? 0 : 1; } } buf[29] = val; } /* ESC L, set brightness */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_BRIGHTNESS].cap)) buf[30] = s->val[OPT_BRIGHTNESS].w; /* ESC B, set halftoning mode / halftone processing */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_HALFTONE].cap)) buf[32] = halftone_params[s->val[OPT_HALFTONE].w]; /* ESC s, auto area segmentation */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_AAS].cap)) buf[34] = s->val[OPT_AAS].w; /* ESC Q, set sharpness / sharpness control */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_SHARPNESS].cap)) buf[35] = s->val[OPT_SHARPNESS].w; /* ESC K, set data order / mirroring */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_MIRROR].cap)) buf[36] = s->val[OPT_MIRROR].w; /* ESC N, film type */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_FILM_TYPE].cap)) buf[37] = film_params[s->val[OPT_FILM_TYPE].w]; /* ESC M, color correction */ buf[31] = correction_params[s->val[OPT_COLOR_CORRECTION].w]; /* ESC t, threshold */ buf[33] = s->val[OPT_THRESHOLD].w; return esci_set_scanning_parameter(s, buf); } SANE_Status e2_set_scanning_parameters(Epson_Scanner * s) { SANE_Status status; struct mode_param *mparam = &mode_params[s->val[OPT_MODE].w]; unsigned char color_mode; DBG(1, "%s\n", __func__); /* * There is some undocumented special behavior with the TPU enable/disable. * TPU power ESC e status * on 0 NAK * on 1 ACK * off 0 ACK * off 1 NAK * * It makes no sense to scan with TPU powered on and source flatbed, because * light will come from both sides. */ if (s->hw->extension) { int extensionCtrl; extensionCtrl = (s->hw->use_extension ? 1 : 0); if (s->hw->use_extension && (s->val[OPT_ADF_MODE].w == 1)) extensionCtrl = 2; status = esci_control_extension(s, extensionCtrl); if (status != SANE_STATUS_GOOD) { DBG(1, "you may have to power %s your TPU\n", s->hw->use_extension ? "on" : "off"); DBG(1, "and you may also have to restart the SANE frontend.\n"); return status; } /* XXX use request_extended_status and analyze * buffer to set the scan area for * ES-9000H and GT-30000 */ /* * set the focus position according to the extension used: * if the TPU is selected, then focus 2.5mm above the glass, * otherwise focus on the glass. Scanners that don't support * this feature, will just ignore these calls. */ if (s->hw->focusSupport == SANE_TRUE) { if (s->val[OPT_FOCUS].w == 0) { DBG(1, "setting focus to glass surface\n"); esci_set_focus_position(s, 0x40); } else { DBG(1, "setting focus to 2.5mm above glass\n"); esci_set_focus_position(s, 0x59); } } } /* ESC C, Set color */ color_mode = mparam->flags | (mparam->dropout_mask & dropout_params[s->val[OPT_DROPOUT]. w]); /* * The byte sequence mode was introduced in B5, for B[34] we need line sequence mode * XXX Check what to do for the FilmScan 200 */ if ((s->hw->cmd->level[0] == 'D' || (s->hw->cmd->level[0] == 'B' && s->hw->level >= 5)) && mparam->flags == 0x02) color_mode = 0x13; status = esci_set_color_mode(s, color_mode); if (status != SANE_STATUS_GOOD) return status; /* ESC D, set data format */ DBG(1, "%s: setting data format to %d bits\n", __func__, mparam->depth); status = esci_set_data_format(s, mparam->depth); if (status != SANE_STATUS_GOOD) return status; /* ESC B, set halftoning mode */ if (s->hw->cmd->set_halftoning && SANE_OPTION_IS_ACTIVE(s->opt[OPT_HALFTONE].cap)) { status = esci_set_halftoning(s, halftone_params[s-> val [OPT_HALFTONE]. w]); if (status != SANE_STATUS_GOOD) return status; } /* ESC L, set brightness */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_BRIGHTNESS].cap)) { status = esci_set_bright(s, s->val[OPT_BRIGHTNESS].w); if (status != SANE_STATUS_GOOD) return status; } if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_AAS].cap)) { status = esci_set_auto_area_segmentation(s, s->val[OPT_AAS].w); if (status != SANE_STATUS_GOOD) return status; } if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_FILM_TYPE].cap)) { status = esci_set_film_type(s, film_params[s->val[OPT_FILM_TYPE].w]); if (status != SANE_STATUS_GOOD) return status; } if (s->hw->cmd->set_gamma && SANE_OPTION_IS_ACTIVE(s->opt[OPT_GAMMA_CORRECTION].cap)) { int val; if (s->hw->cmd->level[0] == 'D') { /* * The D1 level has only the two user defined gamma * settings. */ val = gamma_params[s->val[OPT_GAMMA_CORRECTION].w]; } else { val = gamma_params[s->val[OPT_GAMMA_CORRECTION].w]; /* * If "Default" is selected then determine the actual value * to send to the scanner: If bilevel mode, just send the * value from the table (0x01), for grayscale or color mode * add one and send 0x02. */ /* if( s->val[ OPT_GAMMA_CORRECTION].w <= 1) { */ if (s->val[OPT_GAMMA_CORRECTION].w == 0) { val += mparam->depth == 1 ? 0 : 1; } } status = esci_set_gamma(s, val); if (status != SANE_STATUS_GOOD) return status; } if (s->hw->cmd->set_threshold != 0 && SANE_OPTION_IS_ACTIVE(s->opt[OPT_THRESHOLD].cap)) { status = esci_set_threshold(s, s->val[OPT_THRESHOLD].w); if (status != SANE_STATUS_GOOD) return status; } /* XXX ESC Z here */ /* ESC M, set color correction */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_COLOR_CORRECTION].cap)) { status = esci_set_color_correction(s, correction_params[s->val[OPT_COLOR_CORRECTION].w]); if (status != SANE_STATUS_GOOD) return status; } /* ESC Q, set sharpness */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_SHARPNESS].cap)) { status = esci_set_sharpness(s, s->val[OPT_SHARPNESS].w); if (status != SANE_STATUS_GOOD) return status; } /* ESC g, set scanning mode */ if (s->val[OPT_PREVIEW].w) status = esci_set_speed(s, 1); else status = esci_set_speed(s, 0); if (status != SANE_STATUS_GOOD) return status; /* ESC K, set data order */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_MIRROR].cap)) { status = esci_mirror_image(s, s->val[OPT_MIRROR].w); if (status != SANE_STATUS_GOOD) return status; } /* ESC R */ status = esci_set_resolution(s, s->val[OPT_RESOLUTION].w, s->val[OPT_RESOLUTION].w); if (status != SANE_STATUS_GOOD) return status; /* ESC H, set zoom */ /* not implemented */ /* ESC A, set scanning area */ /* * Modify the scan area: If the scanner requires color shuffling, then we try to * scan more lines to compensate for the lines that will be removed from the scan * due to the color shuffling algorithm. */ if (s->hw->color_shuffle == SANE_TRUE) { unsigned int lines = s->params.lines + (2 * s->line_distance); int top = s->top - (1 * s->line_distance); if (top < 0) top = 0; status = esci_set_scan_area(s, s->left, top, s->params.pixels_per_line, lines); } else { status = esci_set_scan_area(s, s->left, s->top, s->params.pixels_per_line, s->params.lines); } if (status != SANE_STATUS_GOOD) return status; /* ESC d, set block line number / set line counter */ status = esci_set_lcount(s, s->lcount); if (status != SANE_STATUS_GOOD) return status; return SANE_STATUS_GOOD; } void e2_setup_block_mode(Epson_Scanner * s) { int maxreq; DBG(5, "%s\n", __func__); s->block = SANE_TRUE; if (s->hw->connection == SANE_EPSON_SCSI) maxreq = sanei_scsi_max_request_size; else if (s->hw->connection == SANE_EPSON_USB) maxreq = 128 * 1024; else maxreq = 32 * 1024; /* XXX verify if this can b extended to other models */ if (s->hw->connection == SANE_EPSON_NET && e2_model(s, "LP-A500")) maxreq = 64 * 1024; s->lcount = maxreq / s->params.bytes_per_line; DBG(1, "max req size: %d, line count: %d\n", maxreq, s->lcount); /* XXX investigate this */ if (s->lcount < 3 && (e2_model(s, "GT-X800") || e2_model(s, "GT-X900") || e2_model(s, "GT-X980"))) { s->lcount = 21; DBG(17, "%s: set lcount = %i bigger than sanei_scsi_max_request_size\n", __func__, s->lcount); } if (s->lcount >= 255) s->lcount = 255; /* XXX why this? */ if (s->hw->TPU && s->hw->use_extension && s->lcount > 32) s->lcount = 32; /* * The D1 series of scanners only allow an even line number * for bi-level scanning. If a bit depth of 1 is selected, then * make sure the next lower even number is selected. */ /* XXX check bith depth? */ if (s->hw->cmd->level[0] == 'D' && s->lcount > 3 && s->lcount % 2) s->lcount -= 1; DBG(1, "final line count is %d\n", s->lcount); } SANE_Status e2_init_parameters(Epson_Scanner * s) { int dpi, bytes_per_pixel; struct mode_param *mparam; DBG(5, "%s\n", __func__); memset(&s->params, 0, sizeof(SANE_Parameters)); dpi = s->val[OPT_RESOLUTION].w; 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; s->left = ((SANE_UNFIX(s->val[OPT_TL_X].w) / MM_PER_INCH) * s->val[OPT_RESOLUTION].w) + 0.5; s->top = ((SANE_UNFIX(s->val[OPT_TL_Y].w) / MM_PER_INCH) * s->val[OPT_RESOLUTION].w) + 0.5; s->params.pixels_per_line = ((SANE_UNFIX(s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) / MM_PER_INCH) * dpi) + 0.5; s->params.lines = ((SANE_UNFIX(s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) / MM_PER_INCH) * dpi) + 0.5; DBG(1, "%s: resolution = %d, preview = %d\n", __func__, s->val[OPT_RESOLUTION].w, s->val[OPT_PREVIEW].w); DBG(1, "%s: %p %p tlx %f tly %f brx %f bry %f [mm]\n", __func__, (void *) s, (void *) s->val, SANE_UNFIX(s->val[OPT_TL_X].w), SANE_UNFIX(s->val[OPT_TL_Y].w), SANE_UNFIX(s->val[OPT_BR_X].w), SANE_UNFIX(s->val[OPT_BR_Y].w)); /* * Calculate bytes_per_pixel and bytes_per_line for * any color depths. * * 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_BIT_DEPTH].w; if (s->params.depth > 8) { s->params.depth = 16; /* * The frontends can only handle 8 or 16 bits * for gray or color - so if it's more than 8, * it gets automatically set to 16. This works * as long as EPSON does not come out with a * scanner that can handle more than 16 bits * per color channel. */ } /* 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 ... */ bytes_per_pixel++; } /* pixels_per_line is rounded to the next 8bit boundary */ s->params.pixels_per_line = s->params.pixels_per_line & ~7; s->params.last_frame = SANE_TRUE; switch (s->val[OPT_MODE].w) { case MODE_BINARY: case MODE_GRAY: s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8; break; case MODE_COLOR: s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line = 3 * s->params.pixels_per_line * bytes_per_pixel; break; #ifdef SANE_FRAME_IR case MODE_INFRARED: s->params.format = SANE_FRAME_IR; s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8; break; #endif } if (s->params.bytes_per_line == 0) return SANE_STATUS_INVAL; /* * Calculate correction for line_distance in D1 scanner: * Start line_distance lines earlier and add line_distance lines at the end * * Because the actual line_distance is not yet calculated we have to do this * first. */ s->hw->color_shuffle = SANE_FALSE; s->lines_written = 0; s->color_shuffle_line = 0; s->current_output_line = 0; if ((s->hw->optical_res != 0) && (mparam->depth == 8) && (mparam->flags != 0)) { s->line_distance = s->hw->max_line_distance * dpi / s->hw->optical_res; if (s->line_distance != 0) { s->hw->color_shuffle = SANE_TRUE; DBG(1, "%s: color shuffling required\n", __func__); } } /* * If (s->top + s->params.lines) is larger than the max scan area, reset * the number of scan lines: * XXX: precalculate the maximum scanning area elsewhere (use dev max_y) */ if (SANE_UNFIX(s->val[OPT_BR_Y].w) / MM_PER_INCH * dpi < (s->params.lines + s->top)) { s->params.lines = ((int) SANE_UNFIX(s->val[OPT_BR_Y].w) / MM_PER_INCH * dpi + 0.5) - s->top; } s->block = SANE_FALSE; s->lcount = 1; /* * The set line count commands needs to be sent for certain scanners in * color mode. The D1 level requires it, we are however only testing for * 'D' and not for the actual numeric level. */ if ((s->hw->cmd->level[0] == 'B') && (s->hw->level >= 5)) /* >= B5 */ e2_setup_block_mode(s); else if ((s->hw->cmd->level[0] == 'B') && (s->hw->level == 4) /* B4 !color */ && (!mode_params[s->val[OPT_MODE].w].color)) e2_setup_block_mode(s); else if (s->hw->cmd->level[0] == 'D') /* Dx */ e2_setup_block_mode(s); return (s->params.lines > 0) ? SANE_STATUS_GOOD : SANE_STATUS_INVAL; } void e2_wait_button(Epson_Scanner * s) { DBG(5, "%s\n", __func__); s->hw->wait_for_button = SANE_TRUE; while (s->hw->wait_for_button == SANE_TRUE) { unsigned char button_status = 0; if (s->canceling == SANE_TRUE) s->hw->wait_for_button = SANE_FALSE; /* get the button status from the scanner */ else if (esci_request_push_button_status(s, &button_status) == SANE_STATUS_GOOD) { if (button_status) s->hw->wait_for_button = SANE_FALSE; else sleep(1); } else { /* we run into an error condition, just continue */ s->hw->wait_for_button = SANE_FALSE; } } } /* SANE_Status e2_check_extended_status(Epson_Scanner *s) { SANE_Status status = esci_request_scanner_status(s, buf); if (status != SANE_STATUS_GOOD) return status; if (buf[0] & FSF_STATUS_MAIN_WU) main -> 0 fbf -> 3 adf -> 1, 10 tpu -> 2 } */ SANE_Status e2_check_warm_up(Epson_Scanner * s, SANE_Bool * wup) { SANE_Status status; DBG(5, "%s\n", __func__); *wup = SANE_FALSE; if (s->hw->extended_commands) { unsigned char buf[16]; status = esci_request_scanner_status(s, buf); if (status != SANE_STATUS_GOOD) return status; if (buf[0] & FSF_STATUS_MAIN_WU) *wup = SANE_TRUE; } else { unsigned char *es; /* this command is not available on some scanners */ if (!s->hw->cmd->request_extended_status) return SANE_STATUS_GOOD; status = esci_request_extended_status(s, &es, NULL); if (status != SANE_STATUS_GOOD) return status; if (es[0] & EXT_STATUS_WU) *wup = SANE_TRUE; free(es); } return status; } SANE_Status e2_wait_warm_up(Epson_Scanner * s) { SANE_Status status; SANE_Bool wup; DBG(5, "%s\n", __func__); s->retry_count = 0; while (1) { if (s->canceling) return SANE_STATUS_CANCELLED; status = e2_check_warm_up(s, &wup); if (status != SANE_STATUS_GOOD) return status; if (wup == SANE_FALSE) break; s->retry_count++; if (s->retry_count > SANE_EPSON_MAX_RETRIES) { DBG(1, "max retry count exceeded (%d)\n", s->retry_count); return SANE_STATUS_DEVICE_BUSY; } sleep(5); } return SANE_STATUS_GOOD; } SANE_Status e2_check_adf(Epson_Scanner * s) { SANE_Status status; DBG(5, "%s\n", __func__); if (s->hw->use_extension == SANE_FALSE) return SANE_STATUS_GOOD; if (s->hw->extended_commands) { unsigned char buf[16]; status = esci_request_scanner_status(s, buf); if (status != SANE_STATUS_GOOD) return status; if (buf[1] & FSF_STATUS_ADF_PE) return SANE_STATUS_NO_DOCS; if (buf[1] & FSF_STATUS_ADF_PJ) return SANE_STATUS_JAMMED; } else { unsigned char *buf, t; status = esci_request_extended_status(s, &buf, NULL); if (status != SANE_STATUS_GOOD) return status;; t = buf[1]; free(buf); if (t & EXT_STATUS_PE) return SANE_STATUS_NO_DOCS; if (t & EXT_STATUS_PJ) return SANE_STATUS_JAMMED; } return SANE_STATUS_GOOD; } SANE_Status e2_start_std_scan(Epson_Scanner * s) { SANE_Status status; unsigned char params[2]; DBG(5, "%s\n", __func__); /* ESC g */ params[0] = ESC; params[1] = s->hw->cmd->start_scanning; e2_send(s, params, 2, 6 + (s->lcount * s->params.bytes_per_line), &status); return status; } SANE_Status e2_start_ext_scan(Epson_Scanner * s) { SANE_Status status; unsigned char params[2]; unsigned char buf[14]; DBG(5, "%s\n", __func__); params[0] = FS; params[1] = 'G'; status = e2_txrx(s, params, 2, buf, 14); if (status != SANE_STATUS_GOOD) return status; if (buf[0] != STX) return SANE_STATUS_INVAL; if (buf[1] & 0x80) { DBG(1, "%s: fatal error\n", __func__); return SANE_STATUS_IO_ERROR; } s->ext_block_len = le32atoh(&buf[2]); s->ext_blocks = le32atoh(&buf[6]); s->ext_last_len = le32atoh(&buf[10]); s->ext_counter = 0; DBG(5, " status : 0x%02x\n", buf[1]); DBG(5, " block size : %u\n", (unsigned int) le32atoh(&buf[2])); DBG(5, " block count : %u\n", (unsigned int) le32atoh(&buf[6])); DBG(5, " last block size: %u\n", (unsigned int) le32atoh(&buf[10])); if (s->ext_last_len) { s->ext_blocks++; DBG(1, "adjusted block count: %d\n", s->ext_blocks); } /* adjust block len if we have only one block to read */ if (s->ext_block_len == 0 && s->ext_last_len) s->ext_block_len = s->ext_last_len; return status; } void e2_scan_finish(Epson_Scanner * s) { DBG(5, "%s\n", __func__); free(s->buf); s->buf = NULL; if (s->hw->ADF && s->hw->use_extension && s->val[OPT_AUTO_EJECT].w) if (e2_check_adf(s) == SANE_STATUS_NO_DOCS) esci_eject(s); } void e2_copy_image_data(Epson_Scanner * s, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { if (!s->block && s->params.format == SANE_FRAME_RGB) { max_length /= 3; if (max_length > s->end - s->ptr) max_length = s->end - s->ptr; *length = 3 * max_length; while (max_length-- != 0) { *data++ = s->ptr[0]; *data++ = s->ptr[s->params.pixels_per_line]; *data++ = s->ptr[2 * s->params.pixels_per_line]; ++s->ptr; } } else { if (max_length > s->end - s->ptr) max_length = s->end - s->ptr; *length = max_length; if (s->params.depth == 1) { while (max_length-- != 0) *data++ = ~*s->ptr++; } else { memcpy(data, s->ptr, max_length); s->ptr += max_length; } } } SANE_Status e2_ext_read(struct Epson_Scanner *s) { struct Epson_Device *dev = s->hw; SANE_Status status = SANE_STATUS_GOOD; ssize_t buf_len = 0, read; DBG(18, "%s: begin\n", __func__); /* did we passed everything we read to sane? */ if (s->ptr == s->end) { if (s->eof) return SANE_STATUS_EOF; s->ext_counter++; /* sane has already got the data, read some more, the final * error byte must not be included in buf_len */ buf_len = s->ext_block_len; if (s->ext_counter == s->ext_blocks && s->ext_last_len) buf_len = s->ext_last_len; DBG(18, "%s: block %d/%d, size %lu\n", __func__, s->ext_counter, s->ext_blocks, (unsigned long) buf_len); /* receive image data + error code */ read = e2_recv(s, s->buf, buf_len + 1, &status); DBG(18, "%s: read %lu bytes, status: %d\n", __func__, (unsigned long) read, status); if (status != SANE_STATUS_GOOD) { e2_cancel(s); return status; } if (e2_dev_model(dev, "GT-8200") || e2_dev_model(dev, "Perfection1650")) { /* See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=597922#127 */ s->buf[buf_len] &= 0xc0; } if (s->buf[buf_len] & FSG_STATUS_CANCEL_REQ) { DBG(0, "%s: cancel request received\n", __func__); e2_cancel(s); return SANE_STATUS_CANCELLED; } if (s->buf[buf_len] & (FSG_STATUS_FER | FSG_STATUS_NOT_READY)) return SANE_STATUS_IO_ERROR; /* ack every block except the last one */ if (s->ext_counter < s->ext_blocks) { size_t next_len = s->ext_block_len; if (s->ext_counter == (s->ext_blocks - 1)) next_len = s->ext_last_len; if (s->canceling) { e2_cancel(s); return SANE_STATUS_CANCELLED; } status = e2_ack_next(s, next_len + 1); } else s->eof = SANE_TRUE; s->end = s->buf + buf_len; s->ptr = s->buf; } return status; } /* XXXX use routine from sane-evolution */ typedef struct { unsigned char code; unsigned char status; unsigned char buf[4]; } EpsonDataRec; /* XXX this routine is ugly and should be avoided */ static SANE_Status read_info_block(Epson_Scanner * s, EpsonDataRec * result) { SANE_Status status; unsigned char params[2]; retry: e2_recv(s, result, s->block ? 6 : 4, &status); if (status != SANE_STATUS_GOOD) return status; if (result->code != STX) { DBG(1, "error: got %02x, expected STX\n", result->code); return SANE_STATUS_INVAL; } /* XXX */ if (result->status & STATUS_FER) { unsigned char *ext_status; DBG(1, "fatal error, status = %02x\n", result->status); if (s->retry_count > SANE_EPSON_MAX_RETRIES) { DBG(1, "max retry count exceeded (%d)\n", s->retry_count); return SANE_STATUS_INVAL; } /* if the scanner is warming up, retry after a few secs */ status = esci_request_extended_status(s, &ext_status, NULL); if (status != SANE_STATUS_GOOD) return status; if (ext_status[0] & EXT_STATUS_WU) { free(ext_status); sleep(5); /* for the next attempt */ DBG(1, "retrying ESC G - %d\n", ++(s->retry_count)); params[0] = ESC; params[1] = s->hw->cmd->start_scanning; e2_send(s, params, 2, 0, &status); if (status != SANE_STATUS_GOOD) return status; goto retry; } else free(ext_status); } return status; } static SANE_Status color_shuffle(SANE_Handle handle, int *new_length) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Byte *buf = s->buf; int length = s->end - s->buf; SANE_Byte *data_ptr; /* ptr to data to process */ SANE_Byte *data_end; /* ptr to end of processed data */ SANE_Byte *out_data_ptr; /* ptr to memory when writing data */ int i; /* loop counter */ /* * It looks like we are dealing with a scanner that has an odd way * of dealing with colors... The red and blue scan lines are shifted * up or down by a certain number of lines relative to the green line. */ DBG(5, "%s\n", __func__); /* * Initialize the variables we are going to use for the * copying of the data. data_ptr is the pointer to * the currently worked on scan line. data_end is the * end of the data area as calculated from adding *length * to the start of data. * out_data_ptr is used when writing out the processed data * and always points to the beginning of the next line to * write. */ data_ptr = out_data_ptr = buf; data_end = data_ptr + length; /* * The image data is in *buf, we know that the buffer contains s->end - s->buf ( = length) * bytes of data. The width of one line is in s->params.bytes_per_line * * The buffer area is supposed to have a number of full scan * lines, let's test if this is the case. */ if (length % s->params.bytes_per_line != 0) { DBG(1, "error in buffer size: %d / %d\n", length, s->params.bytes_per_line); return SANE_STATUS_INVAL; } while (data_ptr < data_end) { SANE_Byte *source_ptr, *dest_ptr; int loop; /* copy the green information into the current line */ source_ptr = data_ptr + 1; dest_ptr = s->line_buffer[s->color_shuffle_line] + 1; for (i = 0; i < s->params.bytes_per_line / 3; i++) { *dest_ptr = *source_ptr; dest_ptr += 3; source_ptr += 3; } /* copy the red information n lines back */ if (s->color_shuffle_line >= s->line_distance) { source_ptr = data_ptr + 2; dest_ptr = s->line_buffer[s->color_shuffle_line - s->line_distance] + 2; /* while (source_ptr < s->line_buffer[s->color_shuffle_line] + s->params.bytes_per_line) */ for (loop = 0; loop < s->params.bytes_per_line / 3; loop++) { *dest_ptr = *source_ptr; dest_ptr += 3; source_ptr += 3; } } /* copy the blue information n lines forward */ source_ptr = data_ptr; dest_ptr = s->line_buffer[s->color_shuffle_line + s->line_distance]; /* while (source_ptr < s->line_buffer[s->color_shuffle_line] + s->params.bytes_per_line) */ for (loop = 0; loop < s->params.bytes_per_line / 3; loop++) { *dest_ptr = *source_ptr; dest_ptr += 3; source_ptr += 3; } data_ptr += s->params.bytes_per_line; if (s->color_shuffle_line == s->line_distance) { /* * We just finished the line in line_buffer[0] - write it to the * output buffer and continue. * * The ouput buffer ist still "buf", but because we are * only overwriting from the beginning of the memory area * we are not interfering with the "still to shuffle" data * in the same area. */ /* * Strip the first and last n lines and limit to */ if ((s->current_output_line >= s->line_distance) && (s->current_output_line < s->params.lines + s->line_distance)) { memcpy(out_data_ptr, s->line_buffer[0], s->params.bytes_per_line); out_data_ptr += s->params.bytes_per_line; s->lines_written++; } s->current_output_line++; /* * Now remove the 0-entry and move all other * lines up by one. There are 2*line_distance + 1 * buffers, * therefore the loop has to run from 0 * to * 2*line_distance, and because we want to * copy every n+1st entry to n the loop runs * from - to 2*line_distance-1! */ free(s->line_buffer[0]); for (i = 0; i < s->line_distance * 2; i++) { s->line_buffer[i] = s->line_buffer[i + 1]; } /* * and create one new buffer at the end */ s->line_buffer[s->line_distance * 2] = malloc(s->params.bytes_per_line); if (s->line_buffer[s->line_distance * 2] == NULL) { DBG(1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } } else { s->color_shuffle_line++; /* increase the buffer number */ } } /* * At this time we've used up all the new data from the scanner, some of * it is still in the line_buffers, but we are ready to return some of it * to the front end software. To do so we have to adjust the size of the * data area and the *new_length variable. */ *new_length = out_data_ptr - buf; return SANE_STATUS_GOOD; } static inline int get_color(int status) { switch ((status >> 2) & 0x03) { case 1: return 1; case 2: return 0; case 3: return 2; default: return 0; /* required to make the compiler happy */ } } SANE_Status e2_block_read(struct Epson_Scanner *s) { SANE_Status status; SANE_Bool reorder = SANE_FALSE; START_READ: DBG(18, "%s: begin\n", __func__); if (s->ptr == s->end) { EpsonDataRec result; unsigned int buf_len; if (s->eof) { if (s->hw->color_shuffle) { DBG(1, "written %d lines after color shuffle\n", s->lines_written); DBG(1, "lines requested: %d\n", s->params.lines); } return SANE_STATUS_EOF; } status = read_info_block(s, &result); if (status != SANE_STATUS_GOOD) { return status; } buf_len = result.buf[1] << 8 | result.buf[0]; buf_len *= (result.buf[3] << 8 | result.buf[2]); DBG(18, "%s: buf len = %u\n", __func__, buf_len); { /* do we have to reorder the data ? */ if (get_color(result.status) == 0x01) reorder = SANE_TRUE; e2_recv(s, s->buf, buf_len, &status); if (status != SANE_STATUS_GOOD) { return status; } } if (result.status & STATUS_AREA_END) { DBG(1, "%s: EOF\n", __func__); s->eof = SANE_TRUE; } else { if (s->canceling) { e2_cancel(s); return SANE_STATUS_CANCELLED; } else { status = e2_ack(s); } } s->end = s->buf + buf_len; s->ptr = s->buf; /* * if we have to re-order the color components (GRB->RGB) we * are doing this here: */ /* * Certain Perfection 1650 also need this re-ordering of the two * color channels. These scanners are identified by the problem * with the half vertical scanning area. When we corrected this, * we also set the variable s->hw->need_color_reorder */ if (s->hw->need_color_reorder) reorder = SANE_FALSE; /* reordering once is enough */ if (reorder && s->params.format == SANE_FRAME_RGB) { SANE_Byte *ptr; ptr = s->buf; while (ptr < s->end) { if (s->params.depth > 8) { SANE_Byte tmp; /* R->G G->R */ tmp = ptr[0]; ptr[0] = ptr[2]; /* first Byte G */ ptr[2] = tmp; /* first Byte R */ tmp = ptr[1]; ptr[1] = ptr[3]; /* second Byte G */ ptr[3] = tmp; /* second Byte R */ ptr += 6; /* go to next pixel */ } else { /* R->G G->R */ SANE_Byte tmp; tmp = ptr[0]; ptr[0] = ptr[1]; /* G */ ptr[1] = tmp; /* R */ /* B stays the same */ ptr += 3; /* go to next pixel */ } } } /* * Do the color_shuffle if everything else is correct - at this time * most of the stuff is hardcoded for the Perfection 610 */ if (s->hw->color_shuffle) { int new_length = 0; status = color_shuffle(s, &new_length); /* XXX check status here */ /* * If no bytes are returned, check if the scanner is already done, if so, * we'll probably just return, but if there is more data to process get * the next batch. */ if (new_length == 0 && s->end != s->ptr) goto START_READ; s->end = s->buf + new_length; s->ptr = s->buf; } DBG(18, "%s: begin scan2\n", __func__); } DBG(18, "%s: end\n", __func__); return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/dll.c0000666000000000000000000011170213615534521013511 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996, 1997 David Mosberger-Tang 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a dynamic linking based SANE meta backend. It allows managing an arbitrary number of SANE backends by using dynamic linking to load backends on demand. */ /* Please increase version number with every change (don't forget to update dll.desc) */ #define DLL_VERSION "1.0.13" #ifdef _AIX # include "lalloca.h" /* MUST come first for AIX! */ #endif #ifdef __BEOS__ #include #include #include #include #endif #include "../include/sane/config.h" #include "lalloca.h" #include #include #include #include #include #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 /* Similar to the above, GCC also warns about conversion between pointers to functions. The ISO C standard says that invoking a converted pointer to a function whose type is not compatible with the pointed-to type, the behavior is undefined. Although GCC is correct to warn about this, the dll backend has been using these conversions without issues for a very long time already. Rather than push/pop around every use, which would get very ugly real fast, ignore this particular warning for the remainder of the file. */ # pragma GCC diagnostic ignored "-Wpragmas" /* backward compatibility */ # pragma GCC diagnostic ignored "-Wcast-function-type" /* 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 both macros as 1 to play it safe. */ # ifndef RTLD_NOW # define RTLD_NOW 1 # endif # ifndef RTLD_LAZY # define RTLD_LAZY 1 # endif # define HAVE_DLL #endif /* HP/UX DLL support */ #if defined (HAVE_SHL_LOAD) && defined(HAVE_DL_H) # include # define HAVE_DLL #endif /* Mac OS X/Darwin support */ #if defined (HAVE_NSLINKMODULE) && defined(HAVE_MACH_O_DYLD_H) # include # define HAVE_DLL #endif #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #define BACKEND_NAME dll #include "../include/sane/sanei_backend.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #if defined(_WIN32) || defined(HAVE_OS2_H) # define DIR_SEP ";" #else # define DIR_SEP ":" #endif #include "../include/sane/sanei_config.h" #define DLL_CONFIG_FILE "dll.conf" #define DLL_ALIASES_FILE "dll.aliases" #include "../include/sane/sanei_usb.h" enum SANE_Ops { OP_INIT = 0, OP_EXIT, OP_GET_DEVS, OP_OPEN, OP_CLOSE, OP_GET_OPTION_DESC, OP_CTL_OPTION, OP_GET_PARAMS, OP_START, OP_READ, OP_CANCEL, OP_SET_IO_MODE, OP_GET_SELECT_FD, NUM_OPS }; typedef SANE_Status (*op_init_t) (SANE_Int *, SANE_Auth_Callback); typedef void (*op_exit_t) (void); typedef SANE_Status (*op_get_devs_t) (const SANE_Device ***, SANE_Bool); typedef SANE_Status (*op_open_t) (SANE_String_Const, SANE_Handle *); typedef void (*op_close_t) (SANE_Handle); typedef const SANE_Option_Descriptor * (*op_get_option_desc_t) (SANE_Handle, SANE_Int); typedef SANE_Status (*op_ctl_option_t) (SANE_Handle, SANE_Int, SANE_Action, void *, SANE_Int *); typedef SANE_Status (*op_get_params_t) (SANE_Handle, SANE_Parameters *); typedef SANE_Status (*op_start_t) (SANE_Handle); typedef SANE_Status (*op_read_t) (SANE_Handle, SANE_Byte *, SANE_Int, SANE_Int *); typedef void (*op_cancel_t) (SANE_Handle); typedef SANE_Status (*op_set_io_mode_t) (SANE_Handle, SANE_Bool); typedef SANE_Status (*op_get_select_fd_t) (SANE_Handle, SANE_Int *); struct backend { struct backend *next; char *name; u_int permanent:1; /* is the backend preloaded? */ u_int loaded:1; /* are the functions available? */ u_int inited:1; /* has the backend been initialized? */ void *handle; /* handle returned by dlopen() */ void *(*op[NUM_OPS]) (void); }; #define BE_ENTRY(be,func) sane_##be##_##func #define PRELOAD_DECL(name) \ extern SANE_Status BE_ENTRY(name,init) (SANE_Int *, SANE_Auth_Callback); \ extern void BE_ENTRY(name,exit) (void); \ extern SANE_Status BE_ENTRY(name,get_devices) (const SANE_Device ***, SANE_Bool); \ extern SANE_Status BE_ENTRY(name,open) (SANE_String_Const, SANE_Handle *); \ extern void BE_ENTRY(name,close) (SANE_Handle); \ extern const SANE_Option_Descriptor *BE_ENTRY(name,get_option_descriptor) (SANE_Handle, SANE_Int); \ extern SANE_Status BE_ENTRY(name,control_option) (SANE_Handle, SANE_Int, SANE_Action, void *, SANE_Int *); \ extern SANE_Status BE_ENTRY(name,get_parameters) (SANE_Handle, SANE_Parameters *); \ extern SANE_Status BE_ENTRY(name,start) (SANE_Handle); \ extern SANE_Status BE_ENTRY(name,read) (SANE_Handle, SANE_Byte *, SANE_Int, SANE_Int *); \ extern void BE_ENTRY(name,cancel) (SANE_Handle); \ extern SANE_Status BE_ENTRY(name,set_io_mode) (SANE_Handle, SANE_Bool); \ extern SANE_Status BE_ENTRY(name,get_select_fd) (SANE_Handle, SANE_Int *); #define PRELOAD_DEFN(name) \ { \ 0 /* next */, #name, \ 1 /* permanent */, \ 1 /* loaded */, \ 0 /* inited */, \ 0 /* handle */, \ { \ BE_ENTRY(name,init), \ BE_ENTRY(name,exit), \ BE_ENTRY(name,get_devices), \ BE_ENTRY(name,open), \ BE_ENTRY(name,close), \ BE_ENTRY(name,get_option_descriptor), \ BE_ENTRY(name,control_option), \ BE_ENTRY(name,get_parameters), \ BE_ENTRY(name,start), \ BE_ENTRY(name,read), \ BE_ENTRY(name,cancel), \ BE_ENTRY(name,set_io_mode), \ BE_ENTRY(name,get_select_fd) \ } \ } #ifndef __BEOS__ #ifdef ENABLE_PRELOAD #include "dll-preload.h" #else static struct backend preloaded_backends[] = { { 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }} }; #endif #endif struct meta_scanner { struct backend *be; SANE_Handle handle; }; struct alias { struct alias *next; char *oldname; char *newname; }; /* * List of available devices, allocated by sane_get_devices, released * by sane_exit() */ static SANE_Device **devlist = NULL; static int devlist_size = 0, devlist_len = 0; static struct alias *first_alias; static SANE_Auth_Callback auth_callback; static struct backend *first_backend; #ifndef __BEOS__ static const char *op_name[] = { "init", "exit", "get_devices", "open", "close", "get_option_descriptor", "control_option", "get_parameters", "start", "read", "cancel", "set_io_mode", "get_select_fd" }; #else static const char *op_name[] = { "sane_init", "sane_exit", "sane_get_devices", "sane_open", "sane_close", "sane_get_option_descriptor", "sane_control_option", "sane_get_parameters", "sane_start", "sane_read", "sane_cancel", "sane_set_io_mode", "sane_get_select_fd" }; #endif /* __BEOS__ */ static void * op_unsupported (void) { DBG (1, "op_unsupported: call to unsupported backend operation\n"); return (void *) (long) SANE_STATUS_UNSUPPORTED; } static SANE_Status add_backend (const char *name, struct backend **bep) { struct backend *be, *prev; DBG (3, "add_backend: adding backend `%s'\n", name); if (strcmp (name, "dll") == 0) { DBG (0, "add_backend: remove the dll-backend from your dll.conf!\n"); return SANE_STATUS_GOOD; } for (prev = 0, be = first_backend; be; prev = be, be = be->next) if (strcmp (be->name, name) == 0) { DBG (1, "add_backend: `%s' is already there\n", name); /* move to front so we preserve order that we'd get with dynamic loading: */ if (prev) { prev->next = be->next; be->next = first_backend; first_backend = be; } if (bep) *bep = be; return SANE_STATUS_GOOD; } be = calloc (1, sizeof (*be)); if (!be) return SANE_STATUS_NO_MEM; be->name = strdup (name); if (!be->name) return SANE_STATUS_NO_MEM; be->next = first_backend; first_backend = be; if (bep) *bep = be; return SANE_STATUS_GOOD; } #if defined(HAVE_NSLINKMODULE) static const char *dyld_get_error_str (); static const char * dyld_get_error_str () { NSLinkEditErrors c; int errorNumber; const char *fileName; const char *errorString; NSLinkEditError (&c, &errorNumber, &fileName, &errorString); return errorString; } #endif #ifdef __BEOS__ #include static SANE_Status load (struct backend *be) { /* use BeOS kernel function to load scanner addons from ~/config/add-ons/SANE */ char path[PATH_MAX]; image_id id = -1; int i, w; directory_which which[3] = { B_USER_ADDONS_DIRECTORY, B_COMMON_ADDONS_DIRECTORY, B_BEOS_ADDONS_DIRECTORY }; /* look for config files in SANE/conf */ for (w = 0; (w < 3) && (id < 0) && (find_directory(which[w],0,true,path,PATH_MAX) == 0); w++) { strcat(path,"/SANE/"); strcat(path,be->name); DBG(1, "loading backend %s\n", be->name); /* initialize all ops to "unsupported" so we can "use" the backend even if the stuff later in this function fails */ be->loaded = 1; be->handle = 0; for (i = 0; i < NUM_OPS; ++i) be->op[i] = op_unsupported; DBG(2, "dlopen()ing `%s'\n", path); id=load_add_on(path); if (id < 0) { continue; /* try next path */ } be->handle=(void *)id; for (i = 0; i < NUM_OPS; ++i) { void *(*op) (); op = NULL; /* Look for the symbol */ if ((get_image_symbol(id, op_name[i],B_SYMBOL_TYPE_TEXT,(void **)&op) < 0) || !op) DBG(2, "unable to find %s\n", op_name[i]); else be->op[i]=op; } } if (id < 0) { DBG(2, "load: couldn't find %s\n",path); return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } #else static SANE_Status load (struct backend *be) { #ifdef HAVE_DLL int mode = 0; char *funcname, *src, *orig_src = 0, *dir, *path = 0; char libname[PATH_MAX]; int i; int src_len; FILE *fp = 0; #if defined(HAVE_DLOPEN) # define PREFIX "libsane-" # ifdef __hpux # define POSTFIX ".sl.%u" # define ALT_POSTFIX ".so.%u" # elif defined (HAVE_WINDOWS_H) # undef PREFIX # define PREFIX "cygsane-" # define POSTFIX "-%u.dll" # elif defined (HAVE_OS2_H) # undef PREFIX # define PREFIX "" # define POSTFIX ".dll" # elif defined (__APPLE__) && defined (__MACH__) # define POSTFIX ".%u.so" # else # define POSTFIX ".so.%u" # endif mode = getenv ("LD_BIND_NOW") ? RTLD_NOW : RTLD_LAZY; #elif defined(HAVE_SHL_LOAD) # define PREFIX "libsane-" # define POSTFIX ".sl.%u" mode = BIND_DEFERRED; #elif defined(HAVE_NSLINKMODULE) # define PREFIX "libsane-" # define POSTFIX ".%u.so" mode = NSLINKMODULE_OPTION_RETURN_ON_ERROR + NSLINKMODULE_OPTION_PRIVATE; #else # error "Tried to compile unsupported DLL." #endif /* HAVE_DLOPEN */ /* initialize all ops to "unsupported" so we can "use" the backend even if the stuff later in this function fails */ be->loaded = 1; be->handle = 0; for (i = 0; i < NUM_OPS; ++i) be->op[i] = op_unsupported; path = getenv ("LD_LIBRARY_PATH"); if (!path) path = getenv ("SHLIB_PATH"); /* for HP-UX */ if (!path) path = getenv ("LIBPATH"); /* for AIX */ if (path) { 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%s", path, DIR_SEP, LIBDIR); } else { src = LIBDIR; src = strdup (src); if (!src) { DBG (1, "load: strdup failed: %s\n", strerror (errno)); return SANE_STATUS_NO_MEM; } } DBG (3, "load: searching backend `%s' in `%s'\n", be->name, src); dir = strsep (&src, DIR_SEP); while (dir) { #ifdef HAVE_OS2_H /* only max 7.3 names work with dlopen() for DLLs on OS/2 */ snprintf (libname, sizeof (libname), "%s/" PREFIX "%.2s%.5s" POSTFIX, dir, be->name, strlen(be->name)>7 ? (be->name)+strlen(be->name)-5 : (be->name)+2, V_MAJOR); #else snprintf (libname, sizeof (libname), "%s/" PREFIX "%s" POSTFIX, dir, be->name, V_MAJOR); #endif DBG (4, "load: trying to load `%s'\n", libname); fp = fopen (libname, "r"); if (fp) break; DBG (4, "load: couldn't open `%s' (%s)\n", libname, strerror (errno)); #ifdef ALT_POSTFIX /* Some platforms have two ways of storing their libraries, try both postfixes */ snprintf (libname, sizeof (libname), "%s/" PREFIX "%s" ALT_POSTFIX, dir, be->name, V_MAJOR); DBG (4, "load: trying to load `%s'\n", libname); fp = fopen (libname, "r"); if (fp) break; DBG (4, "load: couldn't open `%s' (%s)\n", libname, strerror (errno)); #endif dir = strsep (&src, DIR_SEP); } if (orig_src) free (orig_src); if (!fp) { DBG (1, "load: couldn't find backend `%s' (%s)\n", be->name, strerror (errno)); return SANE_STATUS_INVAL; } fclose (fp); DBG (3, "load: dlopen()ing `%s'\n", libname); #ifdef HAVE_DLOPEN be->handle = dlopen (libname, mode); #elif defined(HAVE_SHL_LOAD) be->handle = (shl_t) shl_load (libname, mode, 0L); #elif defined(HAVE_NSLINKMODULE) { NSObjectFileImage objectfile_img = NULL; if (NSCreateObjectFileImageFromFile (libname, &objectfile_img) == NSObjectFileImageSuccess) { be->handle = NSLinkModule (objectfile_img, libname, mode); NSDestroyObjectFileImage (objectfile_img); } } #else # error "Tried to compile unsupported DLL." #endif /* HAVE_DLOPEN */ if (!be->handle) { #ifdef HAVE_DLOPEN DBG (1, "load: dlopen() failed (%s)\n", dlerror ()); #elif defined(HAVE_NSLINKMODULE) DBG (1, "load: dyld error (%s)\n", dyld_get_error_str ()); #else DBG (1, "load: dlopen() failed (%s)\n", strerror (errno)); #endif return SANE_STATUS_INVAL; } /* all is dandy---lookup and fill in backend ops: */ funcname = alloca (strlen (be->name) + 64); for (i = 0; i < NUM_OPS; ++i) { void *(*op) (void); sprintf (funcname, "_sane_%s_%s", be->name, op_name[i]); /* First try looking up the symbol without a leading underscore. */ #ifdef HAVE_DLOPEN op = posix_dlsym (be->handle, funcname + 1); #elif defined(HAVE_SHL_LOAD) shl_findsym ((shl_t *) & (be->handle), funcname + 1, TYPE_UNDEFINED, &op); #elif defined(HAVE_NSLINKMODULE) { NSSymbol *nssym = NSLookupSymbolInModule (be->handle, funcname); if (!nssym) { DBG (15, "dyld error: %s\n", dyld_get_error_str ()); } else { op = (void *(*)(void)) NSAddressOfSymbol (nssym); } } #else # error "Tried to compile unsupported DLL." #endif /* HAVE_DLOPEN */ if (op) be->op[i] = op; else { /* Try again, with an underscore prepended. */ #ifdef HAVE_DLOPEN op = posix_dlsym (be->handle, funcname); #elif defined(HAVE_SHL_LOAD) shl_findsym (be->handle, funcname, TYPE_UNDEFINED, &op); #elif defined(HAVE_NSLINKMODULE) { NSSymbol *nssym = NSLookupSymbolInModule (be->handle, funcname); if (!nssym) { DBG (15, "dyld error: %s\n", dyld_get_error_str ()); } else { op = (void *(*)(void)) NSAddressOfSymbol (nssym); } } #else # error "Tried to compile unsupported DLL." #endif /* HAVE_DLOPEN */ if (op) be->op[i] = op; } if (NULL == op) DBG (1, "load: unable to find %s\n", funcname); } return SANE_STATUS_GOOD; # undef PREFIX # undef POSTFIX #else /* HAVE_DLL */ DBG (1, "load: ignoring attempt to load `%s'; compiled without dl support\n", be->name); return SANE_STATUS_UNSUPPORTED; #endif /* HAVE_DLL */ } #endif /* __BEOS__ */ static SANE_Status init (struct backend *be) { SANE_Status status; SANE_Int version; if (!be->loaded) { status = load (be); if (status != SANE_STATUS_GOOD) return status; } DBG (3, "init: initializing backend `%s'\n", be->name); status = (*(op_init_t)be->op[OP_INIT]) (&version, auth_callback); if (status != SANE_STATUS_GOOD) return status; if (SANE_VERSION_MAJOR (version) != SANE_CURRENT_MAJOR) { DBG (1, "init: backend `%s' has a wrong major version (%d instead of %d)\n", be->name, SANE_VERSION_MAJOR (version), SANE_CURRENT_MAJOR); return SANE_STATUS_INVAL; } DBG (4, "init: backend `%s' is version %d.%d.%d\n", be->name, SANE_VERSION_MAJOR (version), SANE_VERSION_MINOR (version), SANE_VERSION_BUILD (version)); be->inited = 1; return SANE_STATUS_GOOD; } static void add_alias (const char *line_param) { #ifndef __BEOS__ const char *command; enum { CMD_ALIAS, CMD_HIDE } cmd; const char *oldname, *oldend, *newname; size_t oldlen, newlen; struct alias *alias; char *line; command = sanei_config_skip_whitespace (line_param); if (!*command) return; line = strchr (command, '#'); if (line) *line = '\0'; line = strpbrk (command, " \t"); if (!line) return; *line++ = '\0'; if (strcmp (command, "alias") == 0) cmd = CMD_ALIAS; else if (strcmp (command, "hide") == 0) cmd = CMD_HIDE; else return; newlen = 0; newname = NULL; if (cmd == CMD_ALIAS) { char *newend; newname = sanei_config_skip_whitespace (line); if (!*newname) return; if (*newname == '\"') { ++newname; newend = strchr (newname, '\"'); } else newend = strpbrk (newname, " \t"); if (!newend) return; newlen = newend - newname; line = (char *) (newend + 1); } oldname = sanei_config_skip_whitespace (line); if (!*oldname) return; oldend = oldname + strcspn (oldname, " \t"); oldlen = oldend - oldname; alias = malloc (sizeof (struct alias)); if (alias) { alias->oldname = malloc (oldlen + newlen + 2); if (alias->oldname) { strncpy (alias->oldname, oldname, oldlen); alias->oldname[oldlen] = '\0'; if (cmd == CMD_ALIAS) { alias->newname = alias->oldname + oldlen + 1; strncpy (alias->newname, newname, newlen); alias->newname[newlen] = '\0'; } else alias->newname = NULL; alias->next = first_alias; first_alias = alias; return; } free (alias); } return; #endif } static void read_config (const char *conffile) { FILE *fp; char config_line[PATH_MAX]; char *backend_name; fp = sanei_config_open (conffile); if (!fp) { DBG (1, "sane_init/read_config: Couldn't open config file (%s): %s\n", conffile, strerror (errno)); return; /* don't insist on config file */ } DBG (5, "sane_init/read_config: reading %s\n", conffile); while (sanei_config_read (config_line, sizeof (config_line), fp)) { char *comment; SANE_String_Const cp; cp = sanei_config_get_string (config_line, &backend_name); /* ignore empty lines */ if (!backend_name || cp == config_line) { if (backend_name) free (backend_name); continue; } /* ignore line comments */ if (backend_name[0] == '#') { free (backend_name); continue; } /* ignore comments after backend names */ comment = strchr (backend_name, '#'); if (comment) *comment = '\0'; add_backend (backend_name, 0); free (backend_name); } fclose (fp); } static void read_dlld (void) { DIR *dlld; struct dirent *dllconf; struct stat st; char dlldir[PATH_MAX]; char conffile[PATH_MAX + strlen("/") + NAME_MAX]; size_t len, plen; const char *dir_list; char *copy, *next, *dir; dir_list = sanei_config_get_paths (); if (!dir_list) { DBG(2, "sane_init/read_dlld: Unable to detect configuration directories\n"); return; } copy = strdup (dir_list); for (next = copy; (dir = strsep (&next, DIR_SEP)) != NULL;) { snprintf (dlldir, sizeof (dlldir), "%s%s", dir, "/dll.d"); DBG(4, "sane_init/read_dlld: attempting to open directory `%s'\n", dlldir); dlld = opendir (dlldir); if (dlld) { /* length of path to parent dir of dll.d/ */ plen = strlen (dir) + 1; DBG(3, "sane_init/read_dlld: using config directory `%s'\n", dlldir); break; } } free (copy); if (dlld == NULL) { DBG (1, "sane_init/read_dlld: opendir failed: %s\n", strerror (errno)); return; } while ((dllconf = readdir (dlld)) != NULL) { /* dotfile (or directory) */ if (dllconf->d_name[0] == '.') continue; len = strlen (dllconf->d_name); /* backup files */ if ((dllconf->d_name[len-1] == '~') || (dllconf->d_name[len-1] == '#')) continue; snprintf (conffile, sizeof(conffile), "%s/%s", dlldir, dllconf->d_name); DBG (5, "sane_init/read_dlld: considering %s\n", conffile); if (stat (conffile, &st) != 0) continue; if (!S_ISREG (st.st_mode)) continue; /* expects a path relative to PATH_SANE_CONFIG_DIR */ read_config (conffile+plen); } closedir (dlld); DBG (5, "sane_init/read_dlld: done.\n"); } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { #ifndef __BEOS__ char config_line[PATH_MAX]; size_t len; FILE *fp; int i; #else DIR *dir; struct dirent *dirent; char path[1024]; directory_which which[3] = { B_USER_ADDONS_DIRECTORY, B_COMMON_ADDONS_DIRECTORY, B_BEOS_ADDONS_DIRECTORY }; int i; #endif DBG_INIT (); auth_callback = authorize; DBG (1, "sane_init: SANE dll backend version %s from %s\n", DLL_VERSION, PACKAGE_STRING); #ifndef __BEOS__ /* chain preloaded backends together: */ for (i = 0; i < NELEMS (preloaded_backends); ++i) { if (!preloaded_backends[i].name) continue; DBG (3, "sane_init: adding backend `%s' (preloaded)\n", preloaded_backends[i].name); preloaded_backends[i].next = first_backend; first_backend = &preloaded_backends[i]; } /* Return the version number of the sane-backends package to allow the frontend to print them. This is done only for net and dll, because these backends are usually called by the frontend. */ if (version_code) *version_code = SANE_VERSION_CODE (SANE_DLL_V_MAJOR, SANE_DLL_V_MINOR, SANE_DLL_V_BUILD); /* * Read dll.conf & dll.d * Read dll.d first, so that the extras backends will be tried last */ read_dlld (); read_config (DLL_CONFIG_FILE); fp = sanei_config_open (DLL_ALIASES_FILE); if (!fp) return SANE_STATUS_GOOD; /* don't insist on aliases file */ DBG (5, "sane_init: reading %s\n", DLL_ALIASES_FILE); while (sanei_config_read (config_line, sizeof (config_line), fp)) { if (config_line[0] == '#') /* ignore line comments */ continue; len = strlen (config_line); if (!len) continue; /* ignore empty lines */ add_alias (config_line); } fclose (fp); #else /* no ugly config files, just get scanners from their ~/config/add-ons/SANE */ /* look for drivers */ for (i = 0; i < 3; i++) { if (find_directory(which[i],0,true,path,1024) < B_OK) continue; strcat(path,"/SANE/"); dir=opendir(path); if(!dir) continue; while((dirent=readdir(dir))) { if((strcmp(dirent->d_name,".")==0) || (strcmp(dirent->d_name,"..")==0)) continue; if((strcmp(dirent->d_name,"dll")==0)) continue; add_backend(dirent->d_name,0); } closedir(dir); } #endif /* __BEOS__ */ return SANE_STATUS_GOOD; } void sane_exit (void) { struct backend *be, *next; struct alias *alias; DBG (2, "sane_exit: exiting\n"); for (be = first_backend; be; be = next) { next = be->next; if (be->loaded) { if (be->inited) { DBG (3, "sane_exit: calling backend `%s's exit function\n", be->name); (*(op_exit_t)be->op[OP_EXIT]) (); } #ifdef __BEOS__ /* use BeOS kernel functions to unload add-ons */ if(be->handle) unload_add_on((image_id)be->handle); #else #ifdef HAVE_DLL #ifdef HAVE_DLOPEN if (be->handle) dlclose (be->handle); #elif defined(HAVE_SHL_LOAD) if (be->handle) shl_unload (be->handle); #elif defined(HAVE_NSLINKMODULE) if (be->handle) NSUnLinkModule (be->handle, NSUNLINKMODULE_OPTION_NONE # ifdef __ppc__ | NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES # endif ); #else # error "Tried to compile unsupported DLL." #endif /* HAVE_DLOPEN */ #endif /* HAVE_DLL */ #endif /* __BEOS__ */ } if (!be->permanent) { if (be->name) free ((void *) be->name); free (be); } else { be->inited = 0; } } first_backend = 0; while ((alias = first_alias) != NULL) { first_alias = first_alias->next; free (alias->oldname); free (alias); } if (NULL != devlist) { /* Release memory allocated by sane_get_devices(). */ int i = 0; while (devlist[i]) free (devlist[i++]); free (devlist); devlist = NULL; devlist_size = 0; devlist_len = 0; } DBG (3, "sane_exit: finished\n"); } /* Note that a call to get_devices() implies that we'll have to load all backends. To avoid this, you can call sane_open() directly (assuming you know the name of the backend/device). This is appropriate for the command-line interface of SANE, for example. */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { const SANE_Device **be_list; struct backend *be; SANE_Status status; char *full_name; int i, num_devs; size_t len; #define ASSERT_SPACE(n) \ { \ if (devlist_len + (n) > devlist_size) \ { \ devlist_size += (n) + 15; \ if (devlist) \ devlist = realloc (devlist, devlist_size * sizeof (devlist[0])); \ else \ devlist = malloc (devlist_size * sizeof (devlist[0])); \ if (!devlist) \ return SANE_STATUS_NO_MEM; \ } \ } DBG (3, "sane_get_devices\n"); if (devlist) for (i = 0; i < devlist_len; ++i) free ((void *) devlist[i]); devlist_len = 0; for (be = first_backend; be; be = be->next) { if (!be->inited) if (init (be) != SANE_STATUS_GOOD) continue; status = (*(op_get_devs_t)be->op[OP_GET_DEVS]) (&be_list, local_only); if (status != SANE_STATUS_GOOD || !be_list) continue; /* count the number of devices for this backend: */ for (num_devs = 0; be_list[num_devs]; ++num_devs); ASSERT_SPACE (num_devs); for (i = 0; i < num_devs; ++i) { SANE_Device *dev; char *mem; struct alias *alias; for (alias = first_alias; alias != NULL; alias = alias->next) { len = strlen (be->name); if (strlen (alias->oldname) <= len) continue; if (strncmp (alias->oldname, be->name, len) == 0 && alias->oldname[len] == ':' && strcmp (&alias->oldname[len + 1], be_list[i]->name) == 0) break; } if (alias) { if (!alias->newname) /* hidden device */ continue; len = strlen (alias->newname); mem = malloc (sizeof (*dev) + len + 1); if (!mem) return SANE_STATUS_NO_MEM; full_name = mem + sizeof (*dev); strcpy (full_name, alias->newname); } else { /* create a new device entry with a device name that is the sum of the backend name a colon and the backend's device name: */ len = strlen (be->name) + 1 + strlen (be_list[i]->name); mem = malloc (sizeof (*dev) + len + 1); if (!mem) return SANE_STATUS_NO_MEM; full_name = mem + sizeof (*dev); strcpy (full_name, be->name); strcat (full_name, ":"); strcat (full_name, be_list[i]->name); } dev = (SANE_Device *) mem; dev->name = full_name; dev->vendor = be_list[i]->vendor; dev->model = be_list[i]->model; dev->type = be_list[i]->type; devlist[devlist_len++] = dev; } } /* terminate device list with NULL entry: */ ASSERT_SPACE (1); devlist[devlist_len++] = 0; *device_list = (const SANE_Device **) devlist; DBG (3, "sane_get_devices: found %d devices\n", devlist_len - 1); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const full_name, SANE_Handle * meta_handle) { char *be_name; const char *dev_name; struct meta_scanner *s; SANE_Handle handle; struct backend *be; SANE_Status status; struct alias *alias; DBG (3, "sane_open: trying to open `%s'\n", full_name); for (alias = first_alias; alias != NULL; alias = alias->next) { if (!alias->newname) continue; if (strcmp (alias->newname, full_name) == 0) { full_name = alias->oldname; break; } } dev_name = strchr (full_name, ':'); int is_fakeusb = 0, is_fakeusbdev = 0, is_fakeusbout = 0; if (dev_name) { is_fakeusb = strncmp(full_name, "fakeusb", dev_name - full_name) == 0 && dev_name - full_name == 7; is_fakeusbdev = strncmp(full_name, "fakeusbdev", dev_name - full_name) == 0 && dev_name - full_name == 10; is_fakeusbout = strncmp(full_name, "fakeusbout", dev_name - full_name) == 0 && dev_name - full_name == 10; } if (is_fakeusb || is_fakeusbdev) { ++dev_name; // skip colon status = sanei_usb_testing_enable_replay(dev_name, is_fakeusbdev); if (status != SANE_STATUS_GOOD) return status; be_name = sanei_usb_testing_get_backend(); if (be_name == NULL) { DBG (0, "%s: unknown backend for testing\n", __func__); return SANE_STATUS_ACCESS_DENIED; } } else { char* fakeusbout_path = NULL; if (is_fakeusbout) { ++dev_name; // skip colon const char* path_end = strchr(dev_name, ':'); if (path_end == NULL) { DBG (0, "%s: the device name does not contain path\n", __func__); return SANE_STATUS_INVAL; } fakeusbout_path = strndup(dev_name, path_end - dev_name); full_name = path_end + 1; // skip colon dev_name = strchr(full_name, ':'); } if (dev_name) { be_name = strndup(full_name, dev_name - full_name); ++dev_name; /* skip colon */ } else { /* if no colon interpret full_name as the backend name; an empty backend device name will cause us to open the first device of that backend. */ be_name = strdup(full_name); dev_name = ""; } if (is_fakeusbout) { status = sanei_usb_testing_enable_record(fakeusbout_path, be_name); free(fakeusbout_path); if (status != SANE_STATUS_GOOD) return status; } } if (!be_name) return SANE_STATUS_NO_MEM; if (!be_name[0]) be = first_backend; else for (be = first_backend; be; be = be->next) if (strcmp (be->name, be_name) == 0) break; if (!be) { status = add_backend (be_name, &be); if (status != SANE_STATUS_GOOD) { free(be_name); return status; } } free(be_name); if (!be->inited) { status = init (be); if (status != SANE_STATUS_GOOD) return status; } status = (*(op_open_t)be->op[OP_OPEN]) (dev_name, &handle); if (status != SANE_STATUS_GOOD) return status; s = calloc (1, sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; s->be = be; s->handle = handle; *meta_handle = s; DBG (3, "sane_open: open successful\n"); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { struct meta_scanner *s = handle; DBG (3, "sane_close(handle=%p)\n", handle); (*(op_close_t)s->be->op[OP_CLOSE]) (s->handle); free (s); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct meta_scanner *s = handle; DBG (3, "sane_get_option_descriptor(handle=%p,option=%d)\n", handle, option); return (*(op_get_option_desc_t)s->be->op[OP_GET_OPTION_DESC]) (s->handle, option); } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Word * info) { struct meta_scanner *s = handle; DBG (3, "sane_control_option(handle=%p,option=%d,action=%d,value=%p,info=%p)\n", handle, option, action, value, (void *) info); return (*(op_ctl_option_t)s->be->op[OP_CTL_OPTION]) (s->handle, option, action, value, info); } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { struct meta_scanner *s = handle; DBG (3, "sane_get_parameters(handle=%p,params=%p)\n", handle, (void *) params); return (*(op_get_params_t)s->be->op[OP_GET_PARAMS]) (s->handle, params); } SANE_Status sane_start (SANE_Handle handle) { struct meta_scanner *s = handle; DBG (3, "sane_start(handle=%p)\n", handle); return (*(op_start_t)s->be->op[OP_START]) (s->handle); } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { struct meta_scanner *s = handle; DBG (3, "sane_read(handle=%p,data=%p,maxlen=%d,lenp=%p)\n", handle, data, max_length, (void *) length); return (*(op_read_t)s->be->op[OP_READ]) (s->handle, data, max_length, length); } void sane_cancel (SANE_Handle handle) { struct meta_scanner *s = handle; DBG (3, "sane_cancel(handle=%p)\n", handle); (*(op_cancel_t)s->be->op[OP_CANCEL]) (s->handle); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { struct meta_scanner *s = handle; DBG (3, "sane_set_io_mode(handle=%p,nonblocking=%d)\n", handle, non_blocking); return (*(op_set_io_mode_t)s->be->op[OP_SET_IO_MODE]) (s->handle, non_blocking); } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { struct meta_scanner *s = handle; DBG (3, "sane_get_select_fd(handle=%p,fdp=%p)\n", handle, (void *) fd); return (*(op_get_select_fd_t)s->be->op[OP_GET_SELECT_FD]) (s->handle, fd); } sane-backends-1.0.29/backend/epsonds.conf.in0000666000000000000000000000041713615534521015521 00000000000000# epsonds.conf # # here are some examples for how to configure the epsonds backend # USB usb # For libusb support for unknown scanners use the following command # usb # e.g.: # usb 0x4b8 0x14c # Network # # net 192.168.1.123 net autodiscovery sane-backends-1.0.29/backend/artec_eplus48u.c0000666000000000000000000036761113615534521015621 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002 Michael Herder ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ This backend is based on the "gt68xxtest" program written by the following persons: Sergey Vlasov - Main backend code. Andreas Nowack - Support for GT6801 (Mustek ScanExpress 1200 UB Plus). David Stevenson - Automatic AFE gain and offset setting. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Please note: The calibration code from the gt68xxtest program isn't used here, since I couldn't get it working. I'm using my own calibration code, which is based on wild assumptions based on the USB logs from the windoze driver. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ It also contains code from the plustek backend Copyright (C) 2000-2002 Gerhard Jaeger and from the mustek_usb backend Copyright (C) 2000 Mustek. Maintained by Tom Wang Updates (C) 2001 by Henning Meier-Geinitz. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define BUILD 12 #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #define BACKEND_NAME artec_eplus48u #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "artec_eplus48u.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #define _DEFAULT_DEVICE "/dev/usbscanner" #define ARTEC48U_CONFIG_FILE "artec_eplus48u.conf" #define _SHADING_FILE_BLACK "artec48ushading_black" #define _SHADING_FILE_WHITE "artec48ushading_white" #define _EXPOSURE_FILE "artec48uexposure" #define _OFFSET_FILE "artec48uoffset" #define _BYTE 3 #define _STRING 2 #define _FLOAT 1 #define _INT 0 /*for calibration*/ #define WHITE_MIN 243*257 #define WHITE_MAX 253*257 #define BLACK_MIN 8*257 #define BLACK_MAX 18*257 #define EXPOSURE_STEP 280 static Artec48U_Device *first_dev = 0; static Artec48U_Scanner *first_handle = 0; static SANE_Int num_devices = 0; static char devName[PATH_MAX]; static char firmwarePath[PATH_MAX]; static char vendor_string[PATH_MAX]; static char model_string[PATH_MAX]; static SANE_Bool cancelRead; static int isEPro; static int eProMult; static SANE_Auth_Callback auth = NULL; static double gamma_master_default = 1.7; static double gamma_r_default = 1.0; static double gamma_g_default = 1.0; static double gamma_b_default = 1.0; static SANE_Word memory_read_value = 0x200c; /**< Memory read - wValue */ static SANE_Word memory_write_value = 0x200b; /**< Memory write - wValue */ static SANE_Word send_cmd_value = 0x2010; /**< Send normal command - wValue */ static SANE_Word send_cmd_index = 0x3f40; /**< Send normal command - wIndex */ static SANE_Word recv_res_value = 0x2011; /**< Receive normal result - wValue */ static SANE_Word recv_res_index = 0x3f00; /**< Receive normal result - wIndex */ static SANE_Word send_small_cmd_value = 0x2012; /**< Send small command - wValue */ static SANE_Word send_small_cmd_index = 0x3f40; /**< Send small command - wIndex */ static SANE_Word recv_small_res_value = 0x2013; /**< Receive small result - wValue */ static SANE_Word recv_small_res_index = 0x3f00; /**< Receive small result - wIndex */ static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, NULL }; static SANE_Word resbit_list[] = { 6, 50, 100, 200, 300, 600, 1200 }; static SANE_Range brightness_contrast_range = { -127, 127, 0 }; static SANE_Range blacklevel_range = { 20, 240, 1 }; static SANE_Range gamma_range = { 0, /* minimum */ SANE_FIX (4.0), /* maximum */ 0 /* quantization */ }; static SANE_Range scan_range_x = { 0, /* minimum */ SANE_FIX (216.0), /* maximum */ 0 /* quantization */ }; static SANE_Range scan_range_y = { 0, /* minimum */ SANE_FIX (297.0), /* maximum */ 0 /* quantization */ }; static SANE_Word bitdepth_list[] = { 2, 8, 16 }; static SANE_Word bitdepth_list2[] = { 1, 8 }; static Artec48U_Exposure_Parameters exp_params; static Artec48U_Exposure_Parameters default_exp_params = { 0x009f, 0x0109, 0x00cb }; static Artec48U_AFE_Parameters afe_params; static Artec48U_AFE_Parameters default_afe_params = { 0x28, 0x0a, 0x2e, 0x03, 0x2e, 0x03 }; static SANE_Status download_firmware_file (Artec48U_Device * chip) { SANE_Status status = SANE_STATUS_GOOD; SANE_Byte *buf = NULL; int size = -1; FILE *f; XDBG ((2, "Try to open firmware file: \"%s\"\n", chip->firmware_path)); f = fopen (chip->firmware_path, "rb"); if (!f) { XDBG ((2, "Cannot open firmware file \"%s\"\n", firmwarePath)); status = SANE_STATUS_INVAL; } if (status == SANE_STATUS_GOOD) { fseek (f, 0, SEEK_END); size = ftell (f); fseek (f, 0, SEEK_SET); if (size == -1) { XDBG ((2, "Error getting size of firmware file \"%s\"\n", chip->firmware_path)); status = SANE_STATUS_INVAL; } } if (status == SANE_STATUS_GOOD) { XDBG ((3, "firmware size: %d\n", size)); buf = (SANE_Byte *) malloc (size); if (!buf) { XDBG ((2, "Cannot allocate %d bytes for firmware\n", size)); status = SANE_STATUS_NO_MEM; } } if (status == SANE_STATUS_GOOD) { int bytes_read = fread (buf, 1, size, f); if (bytes_read != size) { XDBG ((2, "Problem reading firmware file \"%s\"\n", chip->firmware_path)); status = SANE_STATUS_INVAL; } } if (f) fclose (f); if (status == SANE_STATUS_GOOD) { status = artec48u_download_firmware (chip, buf, size); if (status != SANE_STATUS_GOOD) { XDBG ((2, "Firmware download failed\n")); } } if (buf) free (buf); return status; } static SANE_Status init_calibrator (Artec48U_Scanner * s) { XDBG ((2, "Init calibrator size %d\n",30720 * s->dev->epro_mult)); s->shading_buffer_w = (unsigned char *) malloc (30720 * s->dev->epro_mult); /*epro*/ s->shading_buffer_b = (unsigned char *) malloc (30720 * s->dev->epro_mult); /*epro*/ s->shading_buffer_white[0] = (unsigned int *) malloc (5120 * s->dev->epro_mult * sizeof(unsigned int));/*epro*/ s->shading_buffer_black[0] = (unsigned int *) malloc (5120 * s->dev->epro_mult * sizeof (unsigned int));/*epro*/ s->shading_buffer_white[1] = (unsigned int *) malloc (5120 * s->dev->epro_mult * sizeof (unsigned int));/*epro*/ s->shading_buffer_black[1] = (unsigned int *) malloc (5120 * s->dev->epro_mult * sizeof (unsigned int));/*epro*/ s->shading_buffer_white[2] = (unsigned int *) malloc (5120 * s->dev->epro_mult * sizeof (unsigned int));/*epro*/ s->shading_buffer_black[2] = (unsigned int *) malloc (5120 * s->dev->epro_mult * sizeof (unsigned int));/*epro*/ if (!s->shading_buffer_w || !s->shading_buffer_b || !s->shading_buffer_white[0] || !s->shading_buffer_black[0] || !s->shading_buffer_white[1] || !s->shading_buffer_black[1] || !s->shading_buffer_white[2] || !s->shading_buffer_black[2]) { if (s->shading_buffer_w) free (s->shading_buffer_w); if (s->shading_buffer_b) free (s->shading_buffer_b); if (s->shading_buffer_white[0]) free (s->shading_buffer_white[0]); if (s->shading_buffer_black[0]) free (s->shading_buffer_black[0]); if (s->shading_buffer_white[1]) free (s->shading_buffer_white[1]); if (s->shading_buffer_black[1]) free (s->shading_buffer_black[1]); if (s->shading_buffer_white[2]) free (s->shading_buffer_white[2]); if (s->shading_buffer_black[2]) free (s->shading_buffer_black[2]); return SANE_STATUS_NO_MEM; } return SANE_STATUS_GOOD; } static void init_shading_buffer (Artec48U_Scanner * s) { unsigned int i, j; for (i = 0; i < 5120 * s->dev->epro_mult; i++) /*epro*/ { for (j = 0; j < 3; j++) { s->temp_shading_buffer[j][i] = 0; } } } static void add_to_shading_buffer (Artec48U_Scanner * s, unsigned int **buffer_pointers) { unsigned int i, j; for (i = 0; i < 5120 * s->dev->epro_mult; i++) /*epro*/ { for (j = 0; j < 3; j++) { s->temp_shading_buffer[j][i] += buffer_pointers[j][i]; } } } static void finish_shading_buffer (Artec48U_Scanner * s, SANE_Bool white) { unsigned int i, j, cnt, c, div; unsigned long max_r; unsigned long max_g; unsigned long max_b; unsigned char *shading_buffer; cnt = 0; if (white) { shading_buffer = s->shading_buffer_w; div = s->dev->shading_lines_w; } else { shading_buffer = s->shading_buffer_b; div = s->dev->shading_lines_b; } for (i = 0; i < 5120 * s->dev->epro_mult; i++) /*epro*/ { for (j = 0; j < 3; j++) { int value = s->temp_shading_buffer[j][i] / (div); shading_buffer[cnt] = (SANE_Byte) (value & 0xff); ++cnt; shading_buffer[cnt] = (SANE_Byte) ((value >> 8) & 0xff); ++cnt; } } max_r = 0; max_g = 0; max_b = 0; for (c = 0; c < (30720 * s->dev->epro_mult) - 5; c += 6) /*epro*/ { i = (int) shading_buffer[c] + ((int) shading_buffer[c + 1] << 8); max_r += i; i = (int) shading_buffer[c + 2] + ((int) shading_buffer[c + 3] << 8); max_g += i; i = (int) shading_buffer[c + 4] + ((int) shading_buffer[c + 5] << 8); max_b += i; } } static void finish_exposure_buffer (Artec48U_Scanner * s, int *avg_r, int *avg_g, int *avg_b) { unsigned int i, j, cnt, c, div; unsigned int max_r; unsigned int max_g; unsigned int max_b; unsigned char *shading_buffer; cnt = 0; shading_buffer = s->shading_buffer_w; div = s->dev->shading_lines_w; for (i = 0; i < 5120 * s->dev->epro_mult; i++) /*epro*/ { for (j = 0; j < 3; j++) { int value = s->temp_shading_buffer[j][i] / (div); shading_buffer[cnt] = (SANE_Byte) (value & 0xff); ++cnt; shading_buffer[cnt] = (SANE_Byte) ((value >> 8) & 0xff); ++cnt; } } max_r = 0; max_g = 0; max_b = 0; for (c = 0; c < (30720 * s->dev->epro_mult) - 5; c += 6) /*epro*/ { i = (int) shading_buffer[c] + ((int) shading_buffer[c + 1] << 8); if (i > max_r) max_r = i; i = (int) shading_buffer[c + 2] + ((int) shading_buffer[c + 3] << 8); if (i > max_g) max_g = i; i = (int) shading_buffer[c + 4] + ((int) shading_buffer[c + 5] << 8); if (i > max_b) max_b = i; } *avg_r = max_r; *avg_g = max_g; *avg_b = max_b; } static void finish_offset_buffer (Artec48U_Scanner * s, int *avg_r, int *avg_g, int *avg_b) { unsigned int i, j, cnt, c, div; unsigned int min_r; unsigned int min_g; unsigned int min_b; unsigned char *shading_buffer; cnt = 0; shading_buffer = s->shading_buffer_b; div = s->dev->shading_lines_b; for (i = 0; i < 5120 * s->dev->epro_mult; i++) /*epro*/ { for (j = 0; j < 3; j++) { int value = s->temp_shading_buffer[j][i] / (div); shading_buffer[cnt] = (SANE_Byte) (value & 0xff); ++cnt; shading_buffer[cnt] = (SANE_Byte) ((value >> 8) & 0xff); ++cnt; } } min_r = 65535; min_g = 65535; min_b = 65535; for (c = 0; c < (30720 * s->dev->epro_mult) - 5; c += 6) /*epro*/ { i = (int) shading_buffer[c] + ((int) shading_buffer[c + 1] << 8); if (i < min_r) min_r = i; i = (int) shading_buffer[c + 2] + ((int) shading_buffer[c + 3] << 8); if (i < min_g) min_g = i; i = (int) shading_buffer[c + 4] + ((int) shading_buffer[c + 5] << 8); if (i < min_b) min_b = i; } *avg_r = min_r; *avg_g = min_g; *avg_b = min_b; } static SANE_Status artec48u_wait_for_positioning (Artec48U_Device * chip) { SANE_Status status; SANE_Bool moving; while (SANE_TRUE) { status = artec48u_is_moving (chip, &moving); if (status != SANE_STATUS_GOOD) return status; if (!moving) break; usleep (100000); } return SANE_STATUS_GOOD; } static void copy_scan_line (Artec48U_Scanner * s) { /*For resolution of 1200 dpi we have to interpolate horizontally, because the optical horizontal resolution is limited to 600 dpi. We simply use the avarage value of two pixels. */ int cnt, i, j; int xs = s->params.pixel_xs; int interpolate = 0; int value; int value1; int value2; if ((s->reader->params.ydpi == 1200) && (s->dev->is_epro == 0)) /*epro*/ interpolate = 1; cnt = 0; if (s->params.color) { if (s->params.depth > 8) { for (i = xs - 1; i >= 0; i--) { for (j = 0; j < 3; j++) { value = s->buffer_pointers[j][i]; s->line_buffer[cnt] = LOBYTE (value); ++cnt; s->line_buffer[cnt] = HIBYTE (value); ++cnt; } if (interpolate == 1) /*1200 dpi */ cnt += 6; } if (interpolate == 1) { for (i = 0; i < (xs * 12) - 12; i += 12) { value1 = (int) s->line_buffer[i]; value1 += (int) (s->line_buffer[i + 1] << 8); value2 = (int) s->line_buffer[i + 12]; value2 += (int) (s->line_buffer[i + 13] << 8); value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 65535) value = 65535; s->line_buffer[i + 6] = LOBYTE (value); s->line_buffer[i + 7] = HIBYTE (value); value1 = (int) s->line_buffer[i + 2]; value1 += (int) (s->line_buffer[i + 3] << 8); value2 = (int) s->line_buffer[i + 14]; value2 += (int) (s->line_buffer[i + 15] << 8); value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 65535) value = 65535; s->line_buffer[i + 8] = LOBYTE (value); s->line_buffer[i + 9] = HIBYTE (value); value1 = (int) s->line_buffer[i + 4]; value1 += (int) (s->line_buffer[i + 5] << 8); value2 = (int) s->line_buffer[i + 16]; value2 += (int) (s->line_buffer[i + 17] << 8); value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 65535) value = 65535; s->line_buffer[i + 10] = LOBYTE (value); s->line_buffer[i + 11] = HIBYTE (value); } } } else { for (i = xs - 1; i >= 0; i--) { for (j = 0; j < 3; j++) { value = s->buffer_pointers[j][i]; s->line_buffer[cnt] = (SANE_Byte) (value / 257); cnt += 1; } if (interpolate == 1) /*1200 dpi */ cnt += 3; } if (interpolate == 1) { for (i = 0; i < (xs * 6) - 6; i += 6) { value1 = (int) s->line_buffer[i]; value2 = (int) s->line_buffer[i + 6]; value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 255) value = 255; s->line_buffer[i + 3] = (SANE_Byte) (value); value1 = (int) s->line_buffer[i + 1]; value2 = (int) s->line_buffer[i + 7]; value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 255) value = 255; s->line_buffer[i + 4] = (SANE_Byte) (value); value1 = (int) s->line_buffer[i + 2]; value2 = (int) s->line_buffer[i + 8]; value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 255) value = 255; s->line_buffer[i + 5] = (SANE_Byte) (value); } } } } else { if (s->params.depth > 8) { for (i = xs - 1; i >= 0; --i) { value = s->buffer_pointers[0][i]; s->line_buffer[cnt] = LOBYTE (value); ++cnt; s->line_buffer[cnt] = HIBYTE (value); ++cnt; if (interpolate == 1) /*1200 dpi */ cnt += 2; } if (interpolate == 1) { for (i = 0; i < (xs * 4) - 4; i += 4) { value1 = (int) s->line_buffer[i]; value1 += (int) (s->line_buffer[i + 1] << 8); value2 = (int) s->line_buffer[i + 4]; value2 += (int) (s->line_buffer[i + 5] << 8); value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 65535) value = 65535; s->line_buffer[i + 2] = LOBYTE (value); s->line_buffer[i + 3] = HIBYTE (value); } } } else { if (s->params.lineart == SANE_FALSE) { for (i = xs - 1; i >= 0; --i) { value = s->buffer_pointers[0][i]; s->line_buffer[cnt] = (SANE_Byte) (value / 257); ++cnt; if (interpolate == 1) /*1200 dpi */ ++cnt; } if (interpolate == 1) { for (i = 0; i < (xs * 2) - 2; i += 2) { value1 = (int) s->line_buffer[i]; value2 = (int) s->line_buffer[i + 2]; value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 255) value = 255; s->line_buffer[i + 1] = (SANE_Byte) (value); } } } else { int cnt2; int bit_cnt = 0; int black_level = s->val[OPT_BLACK_LEVEL].w; /*copy to lineart_buffer */ for (i = xs - 1; i >= 0; --i) { s->lineart_buffer[cnt] = (SANE_Byte) (s->buffer_pointers[0][i] / 257); ++cnt; if (interpolate == 1) /*1200 dpi */ ++cnt; } cnt2 = cnt - 1; cnt = 0; if (interpolate == 1) { for (i = 0; i < cnt2 - 2; i += 2) { value1 = (int) s->lineart_buffer[i]; value2 = (int) s->lineart_buffer[i + 2]; value = (value1 + value2) / 2; if (value < 0) value = 0; if (value > 255) value = 255; s->lineart_buffer[i + 1] = (SANE_Byte) (value); } } /* in this case, every value in buffer_pointers represents a bit */ for (i = 0; i < cnt2; i++) { SANE_Byte temp; if (bit_cnt == 0) s->line_buffer[cnt] = 0; /*clear */ temp = s->lineart_buffer[i]; if (temp <= black_level) s->line_buffer[cnt] |= 1 << (7 - bit_cnt); ++bit_cnt; if (bit_cnt > 7) { bit_cnt = 0; ++cnt; } } } } } } /*............................................................................. * attach a device to the backend */ static SANE_Status attach (const char *dev_name, Artec48U_Device ** devp) { SANE_Status status; Artec48U_Device *dev; XDBG ((1, "attach (%s, %p)\n", dev_name, (void *) devp)); if (!dev_name) { XDBG ((1, "attach: devname == NULL\n")); return SANE_STATUS_INVAL; } /* already attached ? */ for (dev = first_dev; dev; dev = dev->next) { if (0 == strcmp (dev->name, dev_name)) { if (devp) *devp = dev; XDBG ((3, "attach: device %s already attached\n", dev_name)); return SANE_STATUS_GOOD; } } XDBG ((3, "attach: device %s NOT attached\n", dev_name)); /* allocate some memory for the device */ artec48u_device_new (&dev); if (NULL == dev) return SANE_STATUS_NO_MEM; dev->fd = -1; dev->name = strdup (dev_name); dev->sane.name = strdup (dev_name); /* * go ahead and open the scanner device */ status = artec48u_device_open (dev); if (status != SANE_STATUS_GOOD) { XDBG ((3, "Could not open device!!\n")); artec48u_device_free (dev); return status; } /*limit the size of vendor and model string to 40 */ vendor_string[40] = 0; model_string[40] = 0; /* assign all the stuff we need fo this device... */ dev->sane.vendor = strdup (vendor_string); XDBG ((3, "attach: setting vendor string: %s\n", vendor_string)); dev->sane.model = strdup (model_string); XDBG ((3, "attach: setting model string: %s\n", model_string)); dev->sane.type = "flatbed scanner"; dev->firmware_path = strdup (firmwarePath); dev->epro_mult = eProMult; dev->is_epro = isEPro; XDBG ((1, "attach eProMult %d\n", eProMult)); XDBG ((1, "attach isEPro %d\n", isEPro)); dev->optical_xdpi = 600 * dev->epro_mult; /*epro*/ dev->optical_ydpi = 1200 * dev->epro_mult; /*epro*/ dev->base_ydpi = 600 * dev->epro_mult; /*epro*/ dev->xdpi_offset = 0; /* in optical_xdpi units */ dev->ydpi_offset = 280 * dev->epro_mult; /* in optical_ydpi units */ dev->x_size = 5120 * dev->epro_mult; /*epro*/ /* in optical_xdpi units */ dev->y_size = 14100 * dev->epro_mult; /*epro*/ /* in optical_ydpi units */ dev->shading_offset = 10 * dev->epro_mult; dev->shading_lines_b = 70 * dev->epro_mult; dev->shading_lines_w = 70 * dev->epro_mult; dev->gamma_master = gamma_master_default; dev->gamma_r = gamma_r_default; dev->gamma_g = gamma_g_default; dev->gamma_b = gamma_b_default; dev->afe_params.r_offset = afe_params.r_offset; dev->afe_params.g_offset = afe_params.g_offset; dev->afe_params.b_offset = afe_params.b_offset; dev->afe_params.r_pga = default_afe_params.r_pga; dev->afe_params.g_pga = default_afe_params.g_pga; dev->afe_params.b_pga = default_afe_params.b_pga; dev->exp_params.r_time = exp_params.r_time; dev->exp_params.g_time = exp_params.g_time; dev->exp_params.b_time = exp_params.b_time; ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = first_dev; status = artec48u_device_close (dev); return SANE_STATUS_GOOD; } static SANE_Status attach_one_device (SANE_String_Const devname) { Artec48U_Device *dev; SANE_Status status; status = attach (devname, &dev); if (SANE_STATUS_GOOD != status) return status; return SANE_STATUS_GOOD; } /** * function to decode an value and give it back to the caller. * @param src - pointer to the source string to check * @param opt - string that keeps the option name to check src for * @param what - _FLOAT or _INT * @param result - pointer to the var that should receive our result * @param def - default value that result should be in case of any error * @return The function returns SANE_TRUE if the option has been found, * if not, it returns SANE_FALSE */ static SANE_Bool decodeVal (char *src, char *opt, int what, void *result, void *def) { char *tmp, *tmp2; const char *name; /* skip the option string */ name = (const char *) &src[strlen ("option")]; /* get the name of the option */ name = sanei_config_get_string (name, &tmp); if (tmp) { /* on success, compare wiht the given one */ if (0 == strcmp (tmp, opt)) { XDBG ((1, "Decoding option >%s<\n", opt)); if (_INT == what) { /* assign the default value for this option... */ *((int *) result) = *((int *) def); if (*name) { /* get the configuration value and decode it */ name = sanei_config_get_string (name, &tmp2); if (tmp2) { *((int *) result) = strtol (tmp2, 0, 0); free (tmp2); } } free (tmp); return SANE_TRUE; } else if (_FLOAT == what) { /* assign the default value for this option... */ *((double *) result) = *((double *) def); if (*name) { /* get the configuration value and decode it */ name = sanei_config_get_string (name, &tmp2); if (tmp2) { *((double *) result) = strtod (tmp2, 0); free (tmp2); } } free (tmp); return SANE_TRUE; } else if (_BYTE == what) { /* assign the default value for this option... */ *((SANE_Byte *) result) = *((SANE_Byte *) def); if (*name) { /* get the configuration value and decode it */ name = sanei_config_get_string (name, &tmp2); if (tmp2) { *((SANE_Byte *) result) = (SANE_Byte) strtol (tmp2, 0, 0); free (tmp2); } } free (tmp); return SANE_TRUE; } else if (_STRING == what) { if (*name) { /* get the configuration value and decode it */ sanei_config_get_string (name, &tmp2); if (tmp2) { strcpy ((char *) result, (char *) tmp2); free (tmp2); } } free (tmp); return SANE_TRUE; } } free (tmp); } return SANE_FALSE; } /** * function to retrive the device name of a given string * @param src - string that keeps the option name to check src for * @param dest - pointer to the string, that should receive the detected * devicename * @return The function returns SANE_TRUE if the devicename has been found, * if not, it returns SANE_FALSE */ static SANE_Bool decodeDevName (char *src, char *dest) { char *tmp; const char *name; if (0 == strncmp ("device", src, 6)) { name = (const char *) &src[strlen ("device")]; name = sanei_config_skip_whitespace (name); XDBG ((1, "Decoding device name >%s<\n", name)); if (*name) { name = sanei_config_get_string (name, &tmp); if (tmp) { strcpy (dest, tmp); free (tmp); return SANE_TRUE; } } } return SANE_FALSE; } #ifdef ARTEC48U_USE_BUTTONS static SANE_Status artec48u_check_buttons (Artec48U_Device * dev, SANE_Int * value) { SANE_Status status; Artec48U_Packet req; memset (req, 0, sizeof (req)); req[0] = 0x74; req[1] = 0x01; status = artec48u_device_small_req (dev, req, req); if (status != SANE_STATUS_GOOD) return status; *value = (SANE_Int) req[2]; return SANE_STATUS_GOOD; } #endif #define MAX_DOWNLOAD_BLOCK_SIZE 64 static SANE_Status artec48u_generic_start_scan (Artec48U_Device * dev) { Artec48U_Packet req; memset (req, 0, sizeof (req)); req[0] = 0x43; req[1] = 0x01; return artec48u_device_req (dev, req, req); } static SANE_Status artec48u_generic_read_scanned_data (Artec48U_Device * dev, SANE_Bool * ready) { SANE_Status status; Artec48U_Packet req; memset (req, 0, sizeof (req)); req[0] = 0x35; req[1] = 0x01; status = artec48u_device_req (dev, req, req); if (status != SANE_STATUS_GOOD) return status; if (req[1] == 0x35) { if (req[0] == 0) *ready = SANE_TRUE; else *ready = SANE_FALSE; } else return SANE_STATUS_IO_ERROR; return SANE_STATUS_GOOD; } static SANE_Status artec48u_download_firmware (Artec48U_Device * dev, SANE_Byte * data, SANE_Word size) { SANE_Status status; SANE_Byte download_buf[MAX_DOWNLOAD_BLOCK_SIZE]; SANE_Byte check_buf[MAX_DOWNLOAD_BLOCK_SIZE]; SANE_Byte *block; SANE_Word addr, bytes_left; Artec48U_Packet boot_req; SANE_Word block_size = MAX_DOWNLOAD_BLOCK_SIZE; CHECK_DEV_ACTIVE ((Artec48U_Device *) dev, (char *) "artec48u_device_download_firmware"); for (addr = 0; addr < size; addr += block_size) { bytes_left = size - addr; if (bytes_left > block_size) block = data + addr; else { memset (download_buf, 0, block_size); memcpy (download_buf, data + addr, bytes_left); block = download_buf; } status = artec48u_device_memory_write (dev, addr, block_size, block); if (status != SANE_STATUS_GOOD) return status; status = artec48u_device_memory_read (dev, addr, block_size, check_buf); if (status != SANE_STATUS_GOOD) return status; if (memcmp (block, check_buf, block_size) != 0) { XDBG ((3, "artec48u_device_download_firmware: mismatch at block 0x%0x\n", addr)); return SANE_STATUS_IO_ERROR; } } memset (boot_req, 0, sizeof (boot_req)); boot_req[0] = 0x69; boot_req[1] = 0x01; boot_req[2] = LOBYTE (addr); boot_req[3] = HIBYTE (addr); status = artec48u_device_req (dev, boot_req, boot_req); if (status != SANE_STATUS_GOOD) return status; return SANE_STATUS_GOOD; } static SANE_Status artec48u_is_moving (Artec48U_Device * dev, SANE_Bool * moving) { SANE_Status status; Artec48U_Packet req; memset (req, 0, sizeof (req)); req[0] = 0x17; req[1] = 0x01; status = artec48u_device_req (dev, req, req); if (status != SANE_STATUS_GOOD) return status; if (req[0] == 0x00 && req[1] == 0x17) { if (req[2] == 0 && (req[3] == 0 || req[3] == 2)) *moving = SANE_FALSE; else *moving = SANE_TRUE; } else return SANE_STATUS_IO_ERROR; return SANE_STATUS_GOOD; } static SANE_Status artec48u_carriage_home (Artec48U_Device * dev) { Artec48U_Packet req; memset (req, 0, sizeof (req)); req[0] = 0x24; req[1] = 0x01; return artec48u_device_req (dev, req, req); } static SANE_Status artec48u_stop_scan (Artec48U_Device * dev) { Artec48U_Packet req; memset (req, 0, sizeof (req)); req[0] = 0x41; req[1] = 0x01; return artec48u_device_small_req (dev, req, req); } static SANE_Status artec48u_setup_scan (Artec48U_Scanner * s, Artec48U_Scan_Request * request, Artec48U_Scan_Action action, SANE_Bool calculate_only, Artec48U_Scan_Parameters * params) { DECLARE_FUNCTION_NAME ("artec48u_setup_scan") SANE_Status status; SANE_Int xdpi, ydpi; SANE_Bool color; SANE_Int depth; SANE_Int pixel_x0, pixel_y0, pixel_xs, pixel_ys; SANE_Int pixel_align; SANE_Int abs_x0, abs_y0, abs_xs, abs_ys, base_xdpi, base_ydpi; SANE_Int scan_xs, scan_ys, scan_bpl; SANE_Int bits_per_line; SANE_Byte color_mode_code; /*If we scan a black line, we use these exposure values */ Artec48U_Exposure_Parameters exp_params_black = { 4, 4, 4 }; XDBG ((6, "%s: enter\n", function_name)); XDBG ((1,"setup scan is_epro %d\n",s->dev->is_epro)); XDBG ((1,"setup scan epro_mult %d\n",s->dev->epro_mult)); xdpi = request->xdpi; ydpi = request->ydpi; color = request->color; depth = request->depth; switch (action) { case SA_CALIBRATE_SCAN_WHITE: { /*move a bit inside scan mark - the value for the offset was found by trial and error */ pixel_y0 = s->dev->shading_offset; pixel_ys = s->dev->shading_lines_w; pixel_x0 = 0; pixel_xs = 5120 * s->dev->epro_mult; /*epro*/ xdpi = ydpi = 600 * s->dev->epro_mult; /*epro*/ color = SANE_TRUE; depth = 8; break; } case SA_CALIBRATE_SCAN_OFFSET_1: case SA_CALIBRATE_SCAN_OFFSET_2: { pixel_y0 = s->dev->shading_offset; pixel_ys = s->dev->shading_lines_b; pixel_x0 = 0; pixel_xs = 5120 * s->dev->epro_mult; /*epro*/ xdpi = ydpi = 600 * s->dev->epro_mult; /*epro*/ color = SANE_TRUE; depth = 8; break; } case SA_CALIBRATE_SCAN_EXPOSURE_1: case SA_CALIBRATE_SCAN_EXPOSURE_2: { pixel_y0 = s->dev->shading_offset; pixel_ys = s->dev->shading_lines_w; pixel_x0 = 0; pixel_xs = 5120 * s->dev->epro_mult; /*epro*/ xdpi = ydpi = 600 * s->dev->epro_mult; /*epro*/ color = SANE_TRUE; depth = 8; break; } case SA_CALIBRATE_SCAN_BLACK: { pixel_y0 = s->dev->shading_offset; pixel_ys = s->dev->shading_lines_w; pixel_x0 = 0; pixel_xs = 5120 * s->dev->epro_mult; /*epro*/ xdpi = ydpi = 600 * s->dev->epro_mult; /*epro*/ color = SANE_TRUE; depth = 8; break; } case SA_SCAN: { SANE_Fixed x0 = request->x0 + s->dev->xdpi_offset; SANE_Fixed y0; /*epro*/ if ((ydpi == 1200) && (s->dev->is_epro == 0)) xdpi = 600; y0 = request->y0 + s->dev->ydpi_offset; pixel_ys = SANE_UNFIX (request->ys) * ydpi / MM_PER_INCH + 0.5; pixel_x0 = SANE_UNFIX (x0) * xdpi / MM_PER_INCH + 0.5; pixel_y0 = SANE_UNFIX (y0) * ydpi / MM_PER_INCH + 0.5; pixel_xs = SANE_UNFIX (request->xs) * xdpi / MM_PER_INCH + 0.5; break; } default: XDBG ((6, "%s: invalid action=%d\n", function_name, (int) action)); return SANE_STATUS_INVAL; } XDBG ((6, "%s: xdpi=%d, ydpi=%d\n", function_name, xdpi, ydpi)); XDBG ((6, "%s: color=%s, depth=%d\n", function_name, color ? "TRUE" : "FALSE", depth)); XDBG ((6, "%s: pixel_x0=%d, pixel_y0=%d\n", function_name, pixel_x0, pixel_y0)); XDBG ((6, "%s: pixel_xs=%d, pixel_ys=%d\n", function_name, pixel_xs, pixel_ys)); switch (depth) { case 8: color_mode_code = color ? 0x84 : 0x82; break; case 16: color_mode_code = color ? 0xa4 : 0xa2; break; default: XDBG ((6, "%s: unsupported depth=%d\n", function_name, depth)); return SANE_STATUS_UNSUPPORTED; } base_xdpi = s->dev->optical_xdpi; base_ydpi = s->dev->base_ydpi; XDBG ((6, "%s: base_xdpi=%d, base_ydpi=%d\n", function_name, base_xdpi, base_ydpi)); abs_x0 = pixel_x0 * base_xdpi / xdpi; abs_y0 = pixel_y0 * base_ydpi / ydpi; /* Calculate minimum number of pixels which span an integral multiple of 64 * bytes. */ pixel_align = 32; /* best case for depth = 16 */ while ((depth * pixel_align) % (64 * 8) != 0) pixel_align *= 2; XDBG ((6, "%s: pixel_align=%d\n", function_name, pixel_align)); if (pixel_xs % pixel_align == 0) scan_xs = pixel_xs; else scan_xs = (pixel_xs / pixel_align + 1) * pixel_align; scan_ys = pixel_ys; XDBG ((6, "%s: scan_xs=%d, scan_ys=%d\n", function_name, scan_xs, scan_ys)); abs_xs = scan_xs * base_xdpi / xdpi; abs_ys = scan_ys * base_ydpi / ydpi; XDBG ((6, "%s: abs_xs=%d, abs_ys=%d\n", function_name, abs_xs, abs_ys)); bits_per_line = depth * scan_xs; if (bits_per_line % 8) /* impossible */ { XDBG ((1, "%s: BUG: unaligned bits_per_line=%d\n", function_name, bits_per_line)); return SANE_STATUS_INVAL; } scan_bpl = bits_per_line / 8; if (scan_bpl % 64) /* impossible */ { XDBG ((1, "%s: BUG: unaligned scan_bpl=%d\n", function_name, scan_bpl)); return SANE_STATUS_INVAL; } if (scan_bpl > 15600) { XDBG ((6, "%s: scan_bpl=%d, too large\n", function_name, scan_bpl)); return SANE_STATUS_INVAL; } XDBG ((6, "%s: scan_bpl=%d\n", function_name, scan_bpl)); if (!calculate_only) { Artec48U_Packet req; char motor_mode_1, motor_mode_2; switch (action) { case SA_CALIBRATE_SCAN_WHITE: motor_mode_1 = 0x01; motor_mode_2 = 0x00; break; case SA_CALIBRATE_SCAN_BLACK: motor_mode_1 = 0x04; motor_mode_2 = 0x00; break; case SA_SCAN: motor_mode_1 = 0x01; motor_mode_2 = 0x00; break; default: XDBG ((6, "%s: invalid action=%d\n", function_name, (int) action)); return SANE_STATUS_INVAL; } /* Fill in the setup command */ memset (req, 0, sizeof (req)); req[0x00] = 0x20; req[0x01] = 0x01; req[0x02] = LOBYTE (abs_y0); req[0x03] = HIBYTE (abs_y0); req[0x04] = LOBYTE (abs_ys); req[0x05] = HIBYTE (abs_ys); req[0x06] = LOBYTE (abs_x0); req[0x07] = HIBYTE (abs_x0); req[0x08] = LOBYTE (abs_xs); req[0x09] = HIBYTE (abs_xs); req[0x0a] = color_mode_code; req[0x0b] = 0x60; req[0x0c] = LOBYTE (xdpi); req[0x0d] = HIBYTE (xdpi); req[0x0e] = 0x12; req[0x0f] = 0x00; req[0x10] = LOBYTE (scan_bpl); req[0x11] = HIBYTE (scan_bpl); req[0x12] = LOBYTE (scan_ys); req[0x13] = HIBYTE (scan_ys); req[0x14] = motor_mode_1; req[0x15] = motor_mode_2; req[0x16] = LOBYTE (ydpi); req[0x17] = HIBYTE (ydpi); req[0x18] = 0x00; status = artec48u_device_req (s->dev, req, req); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: setup request failed: %s\n", function_name, sane_strstatus (status))); return status; } if (action == SA_SCAN) { artec48u_calculate_shading_buffer (s, pixel_x0, pixel_xs + pixel_x0, xdpi, color); artec48u_generic_set_exposure_time (s->dev, &(s->dev-> artec_48u_exposure_params)); artec48u_generic_set_afe (s->dev, &(s->dev->artec_48u_afe_params)); } else if (action == SA_CALIBRATE_SCAN_BLACK) { artec48u_generic_set_exposure_time (s->dev, &exp_params_black); artec48u_generic_set_afe (s->dev, &(s->dev->afe_params)); } else if (action == SA_CALIBRATE_SCAN_WHITE) { artec48u_generic_set_exposure_time (s->dev, &(s->dev->exp_params)); artec48u_generic_set_afe (s->dev, &(s->dev->afe_params)); } } /* Fill in calculated values */ params->xdpi = xdpi; params->ydpi = ydpi; params->depth = depth; params->color = color; params->pixel_xs = pixel_xs; params->pixel_ys = pixel_ys; params->scan_xs = scan_xs; params->scan_ys = scan_ys; params->scan_bpl = scan_bpl; XDBG ((6, "%s: leave: ok\n", function_name)); return SANE_STATUS_GOOD; } static SANE_Status artec48u_generic_set_afe (Artec48U_Device * dev, Artec48U_AFE_Parameters * params) { Artec48U_Packet req; memset (req, 0, sizeof (req)); req[0] = 0x22; req[1] = 0x01; req[2] = params->r_offset; req[3] = params->r_pga; req[4] = params->g_offset; req[5] = params->g_pga; req[6] = params->b_offset; req[7] = params->b_pga; return artec48u_device_req (dev, req, req); } static SANE_Status artec48u_generic_set_exposure_time (Artec48U_Device * dev, Artec48U_Exposure_Parameters * params) { Artec48U_Packet req; memset (req, 0, sizeof (req)); req[0] = 0x76; req[1] = 0x01; req[2] = req[6] = req[10] = 0x04; req[4] = LOBYTE (params->r_time); req[5] = HIBYTE (params->r_time); req[8] = LOBYTE (params->g_time); req[9] = HIBYTE (params->g_time); req[12] = LOBYTE (params->b_time); req[13] = HIBYTE (params->b_time); return artec48u_device_req (dev, req, req); } static SANE_Status artec48u_device_new (Artec48U_Device ** dev_return) { DECLARE_FUNCTION_NAME ("artec48u_device_new") Artec48U_Device *dev; XDBG ((7, "%s: enter\n", function_name)); if (!dev_return) return SANE_STATUS_INVAL; dev = (Artec48U_Device *) malloc (sizeof (Artec48U_Device)); if (!dev) { XDBG ((3, "%s: couldn't malloc %lu bytes for device\n", function_name, (u_long) sizeof (Artec48U_Device))); *dev_return = 0; return SANE_STATUS_NO_MEM; } *dev_return = dev; memset (dev, 0, sizeof (Artec48U_Device)); dev->fd = -1; dev->active = SANE_FALSE; dev->read_buffer = NULL; dev->requested_buffer_size = 32768; XDBG ((7, "%s: leave: ok\n", function_name)); return SANE_STATUS_GOOD; } static SANE_Status artec48u_device_free (Artec48U_Device * dev) { DECLARE_FUNCTION_NAME ("artec48u_device_free") XDBG ((7, "%s: enter: dev=%p\n", function_name, (void *) dev)); if (dev) { if (dev->active) artec48u_device_deactivate (dev); if (dev->fd != -1) artec48u_device_close (dev); XDBG ((7, "%s: freeing dev\n", function_name)); free (dev); } XDBG ((7, "%s: leave: ok\n", function_name)); return SANE_STATUS_GOOD; } static SANE_Status artec48u_device_open (Artec48U_Device * dev) { DECLARE_FUNCTION_NAME ("artec48u_device_open") SANE_Status status; SANE_Int fd; XDBG ((7, "%s: enter: dev=%p\n", function_name, (void *) dev)); CHECK_DEV_NOT_NULL (dev, function_name); if (dev->fd != -1) { XDBG ((3, "%s: device already open\n", function_name)); return SANE_STATUS_INVAL; } status = sanei_usb_open (dev->sane.name, &fd); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: sanei_usb_open failed: %s\n", function_name, sane_strstatus (status))); return status; } dev->fd = fd; XDBG ((7, "%s: leave: ok\n", function_name)); return SANE_STATUS_GOOD; } static SANE_Status artec48u_device_close (Artec48U_Device * dev) { DECLARE_FUNCTION_NAME ("artec48u_device_close") XDBG ((7, "%s: enter: dev=%p\n", function_name, (void *) dev)); CHECK_DEV_OPEN (dev, function_name); if (dev->active) artec48u_device_deactivate (dev); sanei_usb_close (dev->fd); dev->fd = -1; XDBG ((7, "%s: leave: ok\n", function_name)); return SANE_STATUS_GOOD; } static SANE_Status artec48u_device_activate (Artec48U_Device * dev) { DECLARE_FUNCTION_NAME ("artec48u_device_activate") CHECK_DEV_OPEN (dev, function_name); if (dev->active) { XDBG ((3, "%s: device already active\n", function_name)); return SANE_STATUS_INVAL; } XDBG ((7, "%s: model \"%s\"\n", function_name, dev->sane.model)); dev->xdpi_offset = SANE_FIX (dev->xdpi_offset * MM_PER_INCH / dev->optical_xdpi); dev->ydpi_offset = SANE_FIX (dev->ydpi_offset * MM_PER_INCH / dev->optical_ydpi); dev->active = SANE_TRUE; return SANE_STATUS_GOOD; } static SANE_Status artec48u_device_deactivate (Artec48U_Device * dev) { DECLARE_FUNCTION_NAME ("artec48u_device_deactivate") SANE_Status status = SANE_STATUS_GOOD; CHECK_DEV_ACTIVE (dev, function_name); if (dev->read_active) artec48u_device_read_finish (dev); dev->active = SANE_FALSE; return status; } static SANE_Status artec48u_device_memory_write (Artec48U_Device * dev, SANE_Word addr, SANE_Word size, SANE_Byte * data) { DECLARE_FUNCTION_NAME ("artec48u_device_memory_write") SANE_Status status; XDBG ((8, "%s: dev=%p, addr=0x%x, size=0x%x, data=%p\n", function_name, (void *) dev, addr, size, (void *) data)); CHECK_DEV_ACTIVE (dev, function_name); status = sanei_usb_control_msg (dev->fd, 0x40, 0x01, memory_write_value, addr, size, data); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: sanei_usb_control_msg failed: %s\n", function_name, sane_strstatus (status))); } return status; } static SANE_Status artec48u_device_memory_read (Artec48U_Device * dev, SANE_Word addr, SANE_Word size, SANE_Byte * data) { DECLARE_FUNCTION_NAME ("artec48u_device_memory_read") SANE_Status status; XDBG ((8, "%s: dev=%p, addr=0x%x, size=0x%x, data=%p\n", function_name, (void *) dev, addr, size, data)); CHECK_DEV_ACTIVE (dev, function_name); status = sanei_usb_control_msg (dev->fd, 0xc0, 0x01, memory_read_value, addr, size, data); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: sanei_usb_control_msg failed: %s\n", function_name, sane_strstatus (status))); } return status; } static SANE_Status artec48u_device_generic_req (Artec48U_Device * dev, SANE_Word cmd_value, SANE_Word cmd_index, SANE_Word res_value, SANE_Word res_index, Artec48U_Packet cmd, Artec48U_Packet res) { DECLARE_FUNCTION_NAME ("artec48u_device_generic_req") SANE_Status status; XDBG ((7, "%s: command=0x%02x\n", function_name, cmd[0])); CHECK_DEV_ACTIVE (dev, function_name); status = sanei_usb_control_msg (dev->fd, 0x40, 0x01, cmd_value, cmd_index, ARTEC48U_PACKET_SIZE, cmd); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: writing command failed: %s\n", function_name, sane_strstatus (status))); return status; } memset (res, 0, sizeof (Artec48U_Packet)); status = sanei_usb_control_msg (dev->fd, 0xc0, 0x01, res_value, res_index, ARTEC48U_PACKET_SIZE, res); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: reading response failed: %s\n", function_name, sane_strstatus (status))); return status; } return status; } static SANE_Status artec48u_device_req (Artec48U_Device * dev, Artec48U_Packet cmd, Artec48U_Packet res) { return artec48u_device_generic_req (dev, send_cmd_value, send_cmd_index, recv_res_value, recv_res_index, cmd, res); } static SANE_Status artec48u_device_small_req (Artec48U_Device * dev, Artec48U_Packet cmd, Artec48U_Packet res) { Artec48U_Packet fixed_cmd; int i; for (i = 0; i < 8; ++i) memcpy (fixed_cmd + i * 8, cmd, 8); return artec48u_device_generic_req (dev, send_small_cmd_value, send_small_cmd_index, recv_small_res_value, recv_small_res_index, fixed_cmd, res); } static SANE_Status artec48u_device_read_raw (Artec48U_Device * dev, SANE_Byte * buffer, size_t * size) { DECLARE_FUNCTION_NAME ("artec48u_device_read_raw") SANE_Status status; CHECK_DEV_ACTIVE (dev, function_name); XDBG ((7, "%s: enter: size=0x%lx\n", function_name, (unsigned long) *size)); status = sanei_usb_read_bulk (dev->fd, buffer, size); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: bulk read failed: %s\n", function_name, sane_strstatus (status))); return status; } XDBG ((7, "%s: leave: size=0x%lx\n", function_name, (unsigned long) *size)); return SANE_STATUS_GOOD; } static SANE_Status artec48u_device_set_read_buffer_size (Artec48U_Device * dev, size_t buffer_size) { DECLARE_FUNCTION_NAME ("gt68xx_device_set_read_buffer_size") CHECK_DEV_NOT_NULL (dev, function_name); if (dev->read_active) { XDBG ((3, "%s: BUG: read already active\n", function_name)); return SANE_STATUS_INVAL; } buffer_size = (buffer_size + 63UL) & ~63UL; if (buffer_size > 0) { dev->requested_buffer_size = buffer_size; return SANE_STATUS_GOOD; } XDBG ((3, "%s: bad buffer size\n", function_name)); return SANE_STATUS_INVAL; } static SANE_Status artec48u_device_read_prepare (Artec48U_Device * dev, size_t expected_count) { DECLARE_FUNCTION_NAME ("artec48u_device_read_prepare") CHECK_DEV_ACTIVE (dev, function_name); if (dev->read_active) { XDBG ((3, "%s: read already active\n", function_name)); return SANE_STATUS_INVAL; } dev->read_buffer = (SANE_Byte *) malloc (dev->requested_buffer_size); if (!dev->read_buffer) { XDBG ((3, "%s: not enough memory for the read buffer (%lu bytes)\n", function_name, (unsigned long) dev->requested_buffer_size)); return SANE_STATUS_NO_MEM; } dev->read_active = SANE_TRUE; dev->read_pos = dev->read_bytes_in_buffer = 0; dev->read_bytes_left = expected_count; return SANE_STATUS_GOOD; } static void reader_process_sigterm_handler (int signal) { XDBG ((1, "reader_process: terminated by signal %d\n", signal)); _exit (SANE_STATUS_GOOD); } static void usb_reader_process_sigterm_handler (int signal) { XDBG ((1, "reader_process (usb): terminated by signal %d\n", signal)); cancelRead = SANE_TRUE; } static SANE_Status artec48u_device_read_start (Artec48U_Device * dev) { CHECK_DEV_ACTIVE (dev, "artec48u_device_read_start"); return SANE_STATUS_GOOD; } static SANE_Status artec48u_device_read (Artec48U_Device * dev, SANE_Byte * buffer, size_t * size) { DECLARE_FUNCTION_NAME ("artec48u_device_read") SANE_Status status; size_t byte_count = 0; size_t left_to_read = *size; size_t transfer_size, block_size, raw_block_size; CHECK_DEV_ACTIVE (dev, function_name); if (!dev->read_active) { XDBG ((3, "%s: read not active\n", function_name)); return SANE_STATUS_INVAL; } while (left_to_read > 0) { if (dev->read_bytes_in_buffer == 0) { block_size = dev->requested_buffer_size; if (block_size > dev->read_bytes_left) block_size = dev->read_bytes_left; if (block_size == 0) break; raw_block_size = (block_size + 63UL) & ~63UL; status = artec48u_device_read_raw (dev, dev->read_buffer, &raw_block_size); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: read failed\n", function_name)); return status; } dev->read_pos = 0; dev->read_bytes_in_buffer = block_size; dev->read_bytes_left -= block_size; } transfer_size = left_to_read; if (transfer_size > dev->read_bytes_in_buffer) transfer_size = dev->read_bytes_in_buffer; if (transfer_size > 0) { memcpy (buffer, dev->read_buffer + dev->read_pos, transfer_size); dev->read_pos += transfer_size; dev->read_bytes_in_buffer -= transfer_size; byte_count += transfer_size; left_to_read -= transfer_size; buffer += transfer_size; } } *size = byte_count; if (byte_count == 0) return SANE_STATUS_EOF; else return SANE_STATUS_GOOD; } static SANE_Status artec48u_device_read_finish (Artec48U_Device * dev) { DECLARE_FUNCTION_NAME ("artec48u_device_read_finish") CHECK_DEV_ACTIVE (dev, function_name); if (!dev->read_active) { XDBG ((3, "%s: read not active\n", function_name)); return SANE_STATUS_INVAL; } XDBG ((7, "%s: read_bytes_left = %ld\n", function_name, (long) dev->read_bytes_left)); free (dev->read_buffer); dev->read_buffer = NULL; dev->read_active = SANE_FALSE; return SANE_STATUS_GOOD; } static SANE_Status artec48u_delay_buffer_init (Artec48U_Delay_Buffer * delay, SANE_Int pixels_per_line) { DECLARE_FUNCTION_NAME ("artec48u_delay_buffer_init") SANE_Int bytes_per_line; SANE_Int line_count, i; if (pixels_per_line <= 0) { XDBG ((3, "%s: BUG: pixels_per_line=%d\n", function_name, pixels_per_line)); return SANE_STATUS_INVAL; } bytes_per_line = pixels_per_line * sizeof (unsigned int); delay->line_count = line_count = 1; delay->read_index = 0; delay->write_index = 0; delay->mem_block = (SANE_Byte *) malloc (bytes_per_line * line_count); if (!delay->mem_block) { XDBG ((3, "%s: no memory for delay block\n", function_name)); return SANE_STATUS_NO_MEM; } delay->lines = (unsigned int **) malloc (sizeof (unsigned int *) * line_count); if (!delay->lines) { free (delay->mem_block); XDBG ((3, "%s: no memory for delay line pointers\n", function_name)); return SANE_STATUS_NO_MEM; } for (i = 0; i < line_count; ++i) delay->lines[i] = (unsigned int *) (delay->mem_block + i * bytes_per_line); return SANE_STATUS_GOOD; } static SANE_Status artec48u_delay_buffer_done (Artec48U_Delay_Buffer * delay) { if (delay->lines) { free (delay->lines); delay->lines = NULL; } if (delay->mem_block) { free (delay->mem_block); delay->mem_block = NULL; } return SANE_STATUS_GOOD; } #define DELAY_BUFFER_WRITE_PTR(delay) ( (delay)->lines[(delay)->write_index] ) #define DELAY_BUFFER_READ_PTR(delay) ( (delay)->lines[(delay)->read_index ] ) #define DELAY_BUFFER_STEP(delay) \ do { \ (delay)->read_index = ((delay)->read_index + 1) % (delay)->line_count; \ (delay)->write_index = ((delay)->write_index + 1) % (delay)->line_count; \ } while (SANE_FALSE) static inline void unpack_8_mono (SANE_Byte * src, unsigned int *dst, SANE_Int pixels_per_line) { XDBG ((3, "unpack_8_mono\n")); for (; pixels_per_line > 0; ++src, ++dst, --pixels_per_line) { *dst = (((unsigned int) *src) << 8) | *src; } } static inline void unpack_16_le_mono (SANE_Byte * src, unsigned int *dst, SANE_Int pixels_per_line) { XDBG ((3, "unpack_16_le_mono\n")); for (; pixels_per_line > 0; src += 2, dst++, --pixels_per_line) { *dst = (((unsigned int) src[1]) << 8) | src[0]; } } static SANE_Status line_read_gray_8 (Artec48U_Line_Reader * reader, unsigned int **buffer_pointers_return) { SANE_Status status; size_t size; unsigned int *buffer; XDBG ((3, "line_read_gray_8\n")); size = reader->params.scan_bpl; status = artec48u_device_read (reader->dev, reader->pixel_buffer, &size); if (status != SANE_STATUS_GOOD) return status; buffer = DELAY_BUFFER_READ_PTR (&reader->g_delay); buffer_pointers_return[0] = buffer; unpack_8_mono (reader->pixel_buffer, buffer, reader->pixels_per_line); return SANE_STATUS_GOOD; } static SANE_Status line_read_gray_16 (Artec48U_Line_Reader * reader, unsigned int **buffer_pointers_return) { SANE_Status status; size_t size; unsigned int *buffer; XDBG ((3, "line_read_gray_16\n")); size = reader->params.scan_bpl; status = artec48u_device_read (reader->dev, reader->pixel_buffer, &size); if (status != SANE_STATUS_GOOD) return status; buffer = DELAY_BUFFER_READ_PTR (&reader->g_delay); buffer_pointers_return[0] = buffer; unpack_16_le_mono (reader->pixel_buffer, buffer, reader->pixels_per_line); return SANE_STATUS_GOOD; } static SANE_Status line_read_bgr_8_line_mode (Artec48U_Line_Reader * reader, unsigned int **buffer_pointers_return) { SANE_Status status; size_t size; SANE_Int pixels_per_line; SANE_Byte *pixel_buffer = reader->pixel_buffer; XDBG ((3, "line_read_bgr_8_line_mode\n")); size = reader->params.scan_bpl * 3; status = artec48u_device_read (reader->dev, pixel_buffer, &size); if (status != SANE_STATUS_GOOD) return status; pixels_per_line = reader->pixels_per_line; unpack_8_mono (pixel_buffer, DELAY_BUFFER_WRITE_PTR (&reader->b_delay), pixels_per_line); pixel_buffer += reader->params.scan_bpl; unpack_8_mono (pixel_buffer, DELAY_BUFFER_WRITE_PTR (&reader->g_delay), pixels_per_line); pixel_buffer += reader->params.scan_bpl; unpack_8_mono (pixel_buffer, DELAY_BUFFER_WRITE_PTR (&reader->r_delay), pixels_per_line); buffer_pointers_return[0] = DELAY_BUFFER_READ_PTR (&reader->r_delay); buffer_pointers_return[1] = DELAY_BUFFER_READ_PTR (&reader->g_delay); buffer_pointers_return[2] = DELAY_BUFFER_READ_PTR (&reader->b_delay); DELAY_BUFFER_STEP (&reader->r_delay); DELAY_BUFFER_STEP (&reader->g_delay); DELAY_BUFFER_STEP (&reader->b_delay); return SANE_STATUS_GOOD; } static SANE_Status line_read_bgr_16_line_mode (Artec48U_Line_Reader * reader, unsigned int **buffer_pointers_return) { SANE_Status status; size_t size; SANE_Int pixels_per_line; SANE_Byte *pixel_buffer = reader->pixel_buffer; XDBG ((3, "line_read_bgr_16_line_mode\n")); size = reader->params.scan_bpl * 3; status = artec48u_device_read (reader->dev, pixel_buffer, &size); if (status != SANE_STATUS_GOOD) return status; pixels_per_line = reader->pixels_per_line; unpack_16_le_mono (pixel_buffer, DELAY_BUFFER_WRITE_PTR (&reader->b_delay), pixels_per_line); pixel_buffer += reader->params.scan_bpl; unpack_16_le_mono (pixel_buffer, DELAY_BUFFER_WRITE_PTR (&reader->g_delay), pixels_per_line); pixel_buffer += reader->params.scan_bpl; unpack_16_le_mono (pixel_buffer, DELAY_BUFFER_WRITE_PTR (&reader->r_delay), pixels_per_line); buffer_pointers_return[0] = DELAY_BUFFER_READ_PTR (&reader->r_delay); buffer_pointers_return[1] = DELAY_BUFFER_READ_PTR (&reader->g_delay); buffer_pointers_return[2] = DELAY_BUFFER_READ_PTR (&reader->b_delay); DELAY_BUFFER_STEP (&reader->r_delay); DELAY_BUFFER_STEP (&reader->g_delay); DELAY_BUFFER_STEP (&reader->b_delay); return SANE_STATUS_GOOD; } static SANE_Status artec48u_line_reader_init_delays (Artec48U_Line_Reader * reader) { SANE_Status status; if (reader->params.color) { status = artec48u_delay_buffer_init (&reader->r_delay, reader->params.pixel_xs); if (status != SANE_STATUS_GOOD) return status; status = artec48u_delay_buffer_init (&reader->g_delay, reader->params.pixel_xs); if (status != SANE_STATUS_GOOD) { artec48u_delay_buffer_done (&reader->r_delay); return status; } status = artec48u_delay_buffer_init (&reader->b_delay, reader->params.pixel_xs); if (status != SANE_STATUS_GOOD) { artec48u_delay_buffer_done (&reader->g_delay); artec48u_delay_buffer_done (&reader->r_delay); return status; } } else { status = artec48u_delay_buffer_init (&reader->g_delay, reader->params.pixel_xs); if (status != SANE_STATUS_GOOD) return status; } reader->delays_initialized = SANE_TRUE; return SANE_STATUS_GOOD; } static void artec48u_line_reader_free_delays (Artec48U_Line_Reader * reader) { if (!reader) { return; } if (reader->delays_initialized) { if (reader->params.color) { artec48u_delay_buffer_done (&reader->b_delay); artec48u_delay_buffer_done (&reader->g_delay); artec48u_delay_buffer_done (&reader->r_delay); } else { artec48u_delay_buffer_done (&reader->g_delay); } reader->delays_initialized = SANE_FALSE; } } static SANE_Status artec48u_line_reader_new (Artec48U_Device * dev, Artec48U_Scan_Parameters * params, Artec48U_Line_Reader ** reader_return) { DECLARE_FUNCTION_NAME ("artec48u_line_reader_new") SANE_Status status; Artec48U_Line_Reader *reader; SANE_Int image_size; SANE_Int scan_bpl_full; XDBG ((6, "%s: enter\n", function_name)); XDBG ((6, "%s: enter params xdpi: %i\n", function_name, params->xdpi)); XDBG ((6, "%s: enter params ydpi: %i\n", function_name, params->ydpi)); XDBG ((6, "%s: enter params depth: %i\n", function_name, params->depth)); XDBG ((6, "%s: enter params color: %i\n", function_name, params->color)); XDBG ((6, "%s: enter params pixel_xs: %i\n", function_name, params->pixel_xs)); XDBG ((6, "%s: enter params pixel_ys: %i\n", function_name, params->pixel_ys)); XDBG ((6, "%s: enter params scan_xs: %i\n", function_name, params->scan_xs)); XDBG ((6, "%s: enter params scan_ys: %i\n", function_name, params->scan_ys)); XDBG ((6, "%s: enter params scan_bpl: %i\n", function_name, params->scan_bpl)); *reader_return = NULL; reader = (Artec48U_Line_Reader *) malloc (sizeof (Artec48U_Line_Reader)); if (!reader) { XDBG ((3, "%s: cannot allocate Artec48U_Line_Reader\n", function_name)); return SANE_STATUS_NO_MEM; } memset (reader, 0, sizeof (Artec48U_Line_Reader)); reader->dev = dev; memcpy (&reader->params, params, sizeof (Artec48U_Scan_Parameters)); reader->pixel_buffer = 0; reader->delays_initialized = SANE_FALSE; reader->read = NULL; status = artec48u_line_reader_init_delays (reader); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: cannot allocate line buffers: %s\n", function_name, sane_strstatus (status))); free (reader); return status; } reader->pixels_per_line = reader->params.pixel_xs; if (!reader->params.color) { XDBG ((2, "!reader->params.color\n")); if (reader->params.depth == 8) reader->read = line_read_gray_8; else if (reader->params.depth == 16) reader->read = line_read_gray_16; } else { XDBG ((2, "reader line mode\n")); if (reader->params.depth == 8) { XDBG ((2, "depth 8\n")); reader->read = line_read_bgr_8_line_mode; } else if (reader->params.depth == 16) { XDBG ((2, "depth 16\n")); reader->read = line_read_bgr_16_line_mode; } } if (reader->read == NULL) { XDBG ((3, "%s: unsupported bit depth (%d)\n", function_name, reader->params.depth)); artec48u_line_reader_free_delays (reader); free (reader); return SANE_STATUS_UNSUPPORTED; } scan_bpl_full = reader->params.scan_bpl; if (reader->params.color) scan_bpl_full *= 3; reader->pixel_buffer = malloc (scan_bpl_full); if (!reader->pixel_buffer) { XDBG ((3, "%s: cannot allocate pixel buffer\n", function_name)); artec48u_line_reader_free_delays (reader); free (reader); return SANE_STATUS_NO_MEM; } artec48u_device_set_read_buffer_size (reader->dev, scan_bpl_full /* 200 */ ); image_size = scan_bpl_full * reader->params.scan_ys; status = artec48u_device_read_prepare (reader->dev, image_size); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: artec48u_device_read_prepare failed: %s\n", function_name, sane_strstatus (status))); free (reader->pixel_buffer); artec48u_line_reader_free_delays (reader); free (reader); return status; } XDBG ((6, "%s: leave: ok\n", function_name)); *reader_return = reader; return SANE_STATUS_GOOD; } static SANE_Status artec48u_line_reader_free (Artec48U_Line_Reader * reader) { DECLARE_FUNCTION_NAME ("artec48u_line_reader_free") SANE_Status status; XDBG ((6, "%s: enter\n", function_name)); if (!reader) { return SANE_STATUS_GOOD; } artec48u_line_reader_free_delays (reader); if (reader->pixel_buffer) { free (reader->pixel_buffer); reader->pixel_buffer = NULL; } status = artec48u_device_read_finish (reader->dev); if (status != SANE_STATUS_GOOD) { XDBG ((3, "%s: artec48u_device_read_finish failed: %s\n", function_name, sane_strstatus (status))); } if (reader) free (reader); XDBG ((6, "%s: leave\n", function_name)); return status; } static SANE_Status artec48u_line_reader_read (Artec48U_Line_Reader * reader, unsigned int **buffer_pointers_return) { return (*reader->read) (reader, buffer_pointers_return); } static SANE_Status artec48u_scanner_new (Artec48U_Device * dev, Artec48U_Scanner ** scanner_return) { DECLARE_FUNCTION_NAME ("artec48u_scanner_new") Artec48U_Scanner *s; *scanner_return = NULL; s = (Artec48U_Scanner *) malloc (sizeof (Artec48U_Scanner)); if (!s) { XDBG ((5, "%s: no memory for Artec48U_Scanner\n", function_name)); return SANE_STATUS_NO_MEM; } s->dev = dev; s->reader = NULL; s->scanning = SANE_FALSE; s->line_buffer = NULL; s->lineart_buffer = NULL; s->next = NULL; s->pipe_handle = NULL; s->buffer_pointers[0] = NULL; s->buffer_pointers[1] = NULL; s->buffer_pointers[2] = NULL; s->shading_buffer_w = NULL; s->shading_buffer_b = NULL; s->shading_buffer_white[0] = NULL; s->shading_buffer_white[1] = NULL; s->shading_buffer_white[2] = NULL; s->shading_buffer_black[0] = NULL; s->shading_buffer_black[1] = NULL; s->shading_buffer_black[2] = NULL; *scanner_return = s; return SANE_STATUS_GOOD; } static SANE_Status artec48u_scanner_read_line (Artec48U_Scanner * s, unsigned int **buffer_pointers, SANE_Bool shading) { DECLARE_FUNCTION_NAME ("artec48u_scanner_read_line") SANE_Status status; int i, j, c; status = artec48u_line_reader_read (s->reader, buffer_pointers); if (status != SANE_STATUS_GOOD) { XDBG ((5, "%s: artec48u_line_reader_read failed: %s\n", function_name, sane_strstatus (status))); return status; } if (shading != SANE_TRUE) return status; c = s->reader->pixels_per_line; if (s->reader->params.color == SANE_TRUE) { for (i = c - 1; i >= 0; i--) { for (j = 0; j < 3; j++) { int new_value; unsigned int value = buffer_pointers[j][i]; if (value < s->shading_buffer_black[j][i]) value = s->shading_buffer_black[j][i]; if (value > s->shading_buffer_white[j][i]) value = s->shading_buffer_white[j][i]; new_value = (double) (value - s->shading_buffer_black[j][i]) * 65535.0 / (double) (s->shading_buffer_white[j][i] - s->shading_buffer_black[j][i]); if (new_value < 0) new_value = 0; if (new_value > 65535) new_value = 65535; new_value = s->gamma_array[j + 1][s->contrast_array[s-> brightness_array [new_value]]]; new_value = s->gamma_array[0][new_value]; buffer_pointers[j][i] = new_value; } } } else { for (i = c - 1; i >= 0; i--) { int new_value; unsigned int value = buffer_pointers[0][i]; new_value = (double) (value - s->shading_buffer_black[1][i]) * 65535.0 / (double) (s->shading_buffer_white[1][i] - s->shading_buffer_black[1][i]); if (new_value < 0) new_value = 0; if (new_value > 65535) new_value = 65535; new_value = s->gamma_array[0][s-> contrast_array[s->brightness_array[new_value]]]; buffer_pointers[0][i] = new_value; } } return status; } static SANE_Status artec48u_scanner_free (Artec48U_Scanner * s) { DECLARE_FUNCTION_NAME ("artec48u_scanner_free") if (!s) { XDBG ((5, "%s: scanner==NULL\n", function_name)); return SANE_STATUS_INVAL; } if (s->reader) { artec48u_line_reader_free (s->reader); s->reader = NULL; } free (s->shading_buffer_w); free (s->shading_buffer_b); free (s->shading_buffer_white[0]); free (s->shading_buffer_black[0]); free (s->shading_buffer_white[1]); free (s->shading_buffer_black[1]); free (s->shading_buffer_white[2]); free (s->shading_buffer_black[2]); if (s->line_buffer) free (s->line_buffer); if (s->lineart_buffer) free (s->lineart_buffer); free (s); return SANE_STATUS_GOOD; } static SANE_Status artec48u_scanner_internal_start_scan (Artec48U_Scanner * s) { DECLARE_FUNCTION_NAME ("artec48u_scanner_internal_start_scan") SANE_Status status; SANE_Bool ready; SANE_Int repeat_count; status = artec48u_wait_for_positioning (s->dev); if (status != SANE_STATUS_GOOD) { XDBG ((2, "%s: artec48u_scanner_wait_for_positioning error: %s\n", function_name, sane_strstatus (status))); return status; } status = artec48u_generic_start_scan (s->dev); if (status != SANE_STATUS_GOOD) { XDBG ((2, "%s: artec48u_device_start_scan error: %s\n", function_name, sane_strstatus (status))); return status; } for (repeat_count = 0; repeat_count < 30 * 10; ++repeat_count) { status = artec48u_generic_read_scanned_data (s->dev, &ready); if (status != SANE_STATUS_GOOD) { XDBG ((2, "%s: artec48u_device_read_scanned_data error: %s\n", function_name, sane_strstatus (status))); return status; } if (ready) break; usleep (100000); } if (!ready) { XDBG ((2, "%s: scanner still not ready - giving up\n", function_name)); return SANE_STATUS_DEVICE_BUSY; } status = artec48u_device_read_start (s->dev); if (status != SANE_STATUS_GOOD) { XDBG ((2, "%s: artec48u_device_read_start error: %s\n", function_name, sane_strstatus (status))); return status; } return SANE_STATUS_GOOD; } static SANE_Status artec48u_scanner_start_scan_extended (Artec48U_Scanner * s, Artec48U_Scan_Request * request, Artec48U_Scan_Action action, Artec48U_Scan_Parameters * params) { DECLARE_FUNCTION_NAME ("artec48u_scanner_start_scan_extended") SANE_Status status; status = artec48u_wait_for_positioning (s->dev); if (status != SANE_STATUS_GOOD) { XDBG ((2, "%s: artec48u_scanner_wait_for_positioning error: %s\n", function_name, sane_strstatus (status))); return status; } if (action == SA_SCAN) status = artec48u_setup_scan (s, request, action, SANE_FALSE, params); if (status != SANE_STATUS_GOOD) { XDBG ((2, "%s: artec48u_device_setup_scan failed: %s\n", function_name, sane_strstatus (status))); return status; } status = artec48u_line_reader_new (s->dev, params, &s->reader); if (status != SANE_STATUS_GOOD) { XDBG ((2, "%s: artec48u_line_reader_new failed: %s\n", function_name, sane_strstatus (status))); return status; } status = artec48u_scanner_internal_start_scan (s); if (status != SANE_STATUS_GOOD) { XDBG ((2, "%s: artec48u_scanner_internal_start_scan failed: %s\n", function_name, sane_strstatus (status))); return status; } return SANE_STATUS_GOOD; } static SANE_Status artec48u_scanner_start_scan (Artec48U_Scanner * s, Artec48U_Scan_Request * request, Artec48U_Scan_Parameters * params) { return artec48u_scanner_start_scan_extended (s, request, SA_SCAN, params); } static SANE_Status artec48u_scanner_stop_scan (Artec48U_Scanner * s) { XDBG ((1, "artec48u_scanner_stop_scan begin: \n")); artec48u_line_reader_free (s->reader); s->reader = NULL; return artec48u_stop_scan (s->dev); } static void calculateGamma (Artec48U_Scanner * s) { double d; int gval; unsigned int i; double gamma = SANE_UNFIX (s->val[OPT_GAMMA].w); d = 65536.0 / pow (65536.0, 1.0 / gamma); for (i = 0; i < 65536; i++) { gval = (int) (pow ((double) i, 1.0 / gamma) * d); s->gamma_array[0][i] = gval; } } static void calculateGammaRed (Artec48U_Scanner * s) { double d; int gval; unsigned int i; double gamma = SANE_UNFIX (s->val[OPT_GAMMA_R].w); d = 65536.0 / pow (65536.0, 1.0 / gamma); for (i = 0; i < 65536; i++) { gval = (int) (pow ((double) i, 1.0 / gamma) * d); s->gamma_array[1][i] = gval; } } static void calculateGammaGreen (Artec48U_Scanner * s) { double d; int gval; unsigned int i; double gamma = SANE_UNFIX (s->val[OPT_GAMMA_G].w); d = 65536.0 / pow (65536.0, 1.0 / gamma); for (i = 0; i < 65536; i++) { gval = (int) (pow ((double) i, 1.0 / gamma) * d); s->gamma_array[2][i] = gval; } } static void calculateGammaBlue (Artec48U_Scanner * s) { double d; int gval; unsigned int i; double gamma = SANE_UNFIX (s->val[OPT_GAMMA_B].w); d = 65536.0 / pow (65536.0, 1.0 / gamma); for (i = 0; i < 65536; i++) { gval = (int) (pow ((double) i, 1.0 / gamma) * d); s->gamma_array[3][i] = gval; } } static SANE_Status artec48u_calculate_shading_buffer (Artec48U_Scanner * s, int start, int end, int resolution, SANE_Bool color) { int i; int c; int bpp; c = 0; bpp = 6; switch (resolution) { case 50: bpp = 72; break; case 100: bpp = 36; break; case 200: bpp = 18; break; case 300: bpp = 12; break; case 600: bpp = 6; break; case 1200: if(s->dev->is_epro == 0) bpp = 6; else bpp = 3; } for (i = start * bpp; i < end * bpp; i += bpp) { if (color) { s->shading_buffer_white[0][c] = (unsigned int) s->shading_buffer_w[i] + ((((unsigned int) s->shading_buffer_w[i + 1]) << 8)); s->shading_buffer_white[2][c] = (unsigned int) s->shading_buffer_w[i + 4] + ((((unsigned int) s->shading_buffer_w[i + 5]) << 8)); s->shading_buffer_black[0][c] = (unsigned int) s->shading_buffer_b[i] + ((((unsigned int) s->shading_buffer_b[i + 1]) << 8)); s->shading_buffer_black[2][c] = (unsigned int) s->shading_buffer_b[i + 4] + ((((unsigned int) s->shading_buffer_b[i + 5]) << 8)); } s->shading_buffer_white[1][c] = (unsigned int) s->shading_buffer_w[i + 2] + ((((unsigned int) s->shading_buffer_w[i + 3]) << 8)); s->shading_buffer_black[1][c] = (unsigned int) s->shading_buffer_b[i + 2] + ((((unsigned int) s->shading_buffer_b[i + 3]) << 8)); ++c; } return SANE_STATUS_GOOD; } static size_t max_string_size (const SANE_String_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; } static SANE_Status init_options (Artec48U_Scanner * s) { int i; XDBG ((5, "init_options: scanner %p\n", (void *) s)); XDBG ((5, "init_options: start\n")); XDBG ((5, "init_options: num options %i\n", NUM_OPTIONS)); memset (s->val, 0, sizeof (s->val)); memset (s->opt, 0, sizeof (s->opt)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].unit = SANE_UNIT_NONE; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->opt[OPT_NUM_OPTS].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; s->opt[OPT_MODE_GROUP].name = "scanmode-group"; s->opt[OPT_MODE_GROUP].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].size = 0; s->opt[OPT_MODE_GROUP].unit = SANE_UNIT_NONE; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_SCAN_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_SCAN_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_SCAN_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_SCAN_MODE].type = SANE_TYPE_STRING; s->opt[OPT_SCAN_MODE].size = max_string_size (mode_list); s->opt[OPT_SCAN_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SCAN_MODE].constraint.string_list = mode_list; s->val[OPT_SCAN_MODE].s = strdup (mode_list[1]); s->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; s->opt[OPT_BIT_DEPTH].unit = SANE_UNIT_NONE; s->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_BIT_DEPTH].constraint.word_list = bitdepth_list; s->val[OPT_BIT_DEPTH].w = bitdepth_list[1]; /* black level (lineart only) */ s->opt[OPT_BLACK_LEVEL].name = SANE_NAME_BLACK_LEVEL; s->opt[OPT_BLACK_LEVEL].title = SANE_TITLE_BLACK_LEVEL; s->opt[OPT_BLACK_LEVEL].desc = SANE_DESC_BLACK_LEVEL; s->opt[OPT_BLACK_LEVEL].type = SANE_TYPE_INT; s->opt[OPT_BLACK_LEVEL].unit = SANE_UNIT_NONE; s->opt[OPT_BLACK_LEVEL].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BLACK_LEVEL].constraint.range = &blacklevel_range; s->opt[OPT_BLACK_LEVEL].cap |= SANE_CAP_INACTIVE; s->val[OPT_BLACK_LEVEL].w = 127; s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_RESOLUTION].constraint.word_list = resbit_list; s->val[OPT_RESOLUTION].w = resbit_list[1]; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].name = "enhancement-group"; s->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].size = 0; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &brightness_contrast_range; s->val[OPT_BRIGHTNESS].w = 0; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_INT; s->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &brightness_contrast_range; s->val[OPT_CONTRAST].w = 0; /* master analog gamma */ s->opt[OPT_GAMMA].name = SANE_NAME_ANALOG_GAMMA; s->opt[OPT_GAMMA].title = SANE_TITLE_ANALOG_GAMMA; s->opt[OPT_GAMMA].desc = SANE_DESC_ANALOG_GAMMA; s->opt[OPT_GAMMA].type = SANE_TYPE_FIXED; s->opt[OPT_GAMMA].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA].constraint.range = &gamma_range; s->val[OPT_GAMMA].w = SANE_FIX (s->dev->gamma_master); s->opt[OPT_GAMMA].size = sizeof (SANE_Word); /* red analog gamma */ s->opt[OPT_GAMMA_R].name = SANE_NAME_ANALOG_GAMMA_R; s->opt[OPT_GAMMA_R].title = SANE_TITLE_ANALOG_GAMMA_R; s->opt[OPT_GAMMA_R].desc = SANE_DESC_ANALOG_GAMMA_R; s->opt[OPT_GAMMA_R].type = SANE_TYPE_FIXED; s->opt[OPT_GAMMA_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_R].constraint.range = &gamma_range; s->val[OPT_GAMMA_R].w = SANE_FIX (s->dev->gamma_r); /* green analog gamma */ s->opt[OPT_GAMMA_G].name = SANE_NAME_ANALOG_GAMMA_G; s->opt[OPT_GAMMA_G].title = SANE_TITLE_ANALOG_GAMMA_G; s->opt[OPT_GAMMA_G].desc = SANE_DESC_ANALOG_GAMMA_G; s->opt[OPT_GAMMA_G].type = SANE_TYPE_FIXED; s->opt[OPT_GAMMA_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_G].constraint.range = &gamma_range; s->val[OPT_GAMMA_G].w = SANE_FIX (s->dev->gamma_g); /* blue analog gamma */ s->opt[OPT_GAMMA_B].name = SANE_NAME_ANALOG_GAMMA_B; s->opt[OPT_GAMMA_B].title = SANE_TITLE_ANALOG_GAMMA_B; s->opt[OPT_GAMMA_B].desc = SANE_DESC_ANALOG_GAMMA_B; s->opt[OPT_GAMMA_B].type = SANE_TYPE_FIXED; s->opt[OPT_GAMMA_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_B].constraint.range = &gamma_range; s->val[OPT_GAMMA_B].w = SANE_FIX (s->dev->gamma_b); s->opt[OPT_DEFAULT_ENHANCEMENTS].name = "default-enhancements"; s->opt[OPT_DEFAULT_ENHANCEMENTS].title = SANE_I18N ("Defaults"); s->opt[OPT_DEFAULT_ENHANCEMENTS].desc = SANE_I18N ("Set default values for enhancement controls."); s->opt[OPT_DEFAULT_ENHANCEMENTS].size = 0; s->opt[OPT_DEFAULT_ENHANCEMENTS].type = SANE_TYPE_BUTTON; s->opt[OPT_DEFAULT_ENHANCEMENTS].unit = SANE_UNIT_NONE; s->opt[OPT_DEFAULT_ENHANCEMENTS].constraint_type = SANE_CONSTRAINT_NONE; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].name = "geometry-group"; s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].size = 0; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = 0; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &scan_range_x; s->val[OPT_TL_X].w = SANE_FIX (0.0); /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &scan_range_y; s->val[OPT_TL_Y].w = SANE_FIX (0.0); /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &scan_range_x; s->val[OPT_BR_X].w = SANE_FIX (50.0); /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &scan_range_y; s->val[OPT_BR_Y].w = SANE_FIX (50.0); /* "Calibration" group: */ s->opt[OPT_CALIBRATION_GROUP].name = "calibration-group"; s->opt[OPT_CALIBRATION_GROUP].title = SANE_I18N ("Calibration"); s->opt[OPT_CALIBRATION_GROUP].desc = ""; s->opt[OPT_CALIBRATION_GROUP].size = 0; s->opt[OPT_CALIBRATION_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_CALIBRATION_GROUP].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_CALIBRATION_GROUP].cap = 0; /* calibrate */ s->opt[OPT_CALIBRATE].name = "calibration"; s->opt[OPT_CALIBRATE].title = SANE_I18N ("Calibrate before next scan"); s->opt[OPT_CALIBRATE].desc = SANE_I18N ("If enabled, the device will be calibrated before the " "next scan. Otherwise, calibration is performed " "only before the first start."); s->opt[OPT_CALIBRATE].type = SANE_TYPE_BOOL; s->opt[OPT_CALIBRATE].unit = SANE_UNIT_NONE; s->opt[OPT_CALIBRATE].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_CALIBRATE].w = SANE_FALSE; /* calibrate */ s->opt[OPT_CALIBRATE_SHADING].name = "calibration-shading"; s->opt[OPT_CALIBRATE_SHADING].title = SANE_I18N ("Only perform shading-correction"); s->opt[OPT_CALIBRATE_SHADING].desc = SANE_I18N ("If enabled, only the shading correction is " "performed during calibration. The default values " "for gain, offset and exposure time, " "either built-in or from the configuration file, " "are used."); s->opt[OPT_CALIBRATE_SHADING].type = SANE_TYPE_BOOL; s->opt[OPT_CALIBRATE_SHADING].unit = SANE_UNIT_NONE; s->opt[OPT_CALIBRATE_SHADING].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_CALIBRATE_SHADING].w = SANE_FALSE; #ifdef ARTEC48U_USE_BUTTONS s->opt[OPT_BUTTON_STATE].name = "button-state"; s->opt[OPT_BUTTON_STATE].title = SANE_I18N ("Button state"); s->opt[OPT_BUTTON_STATE].type = SANE_TYPE_INT; s->opt[OPT_BUTTON_STATE].unit = SANE_UNIT_NONE; s->opt[OPT_BUTTON_STATE].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_BUTTON_STATE].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_BUTTON_STATE].w = 0; #endif return SANE_STATUS_GOOD; } static void calculate_brightness (Artec48U_Scanner * s) { long cnt; double bright; bright = (double) s->val[OPT_BRIGHTNESS].w; bright *= 257.0; for (cnt = 0; cnt < 65536; cnt++) { if (bright < 0.0) s->brightness_array[cnt] = (int) (((double) cnt * (65535.0 + bright)) / 65535.0); else s->brightness_array[cnt] = (int) ((double) cnt + ((65535.0 - (double) cnt) * bright) / 65535.0); if (s->brightness_array[cnt] > 65535) s->brightness_array[cnt] = 65535; if (s->brightness_array[cnt] < 0) s->brightness_array[cnt] = 0; } } static void calculate_contrast (Artec48U_Scanner * s) { int val; double p; int cnt; double contr; contr = (double) s->val[OPT_CONTRAST].w; contr *= 257.0; for (cnt = 0; cnt < 65536; cnt++) { if (contr < 0.0) { val = (int) (cnt > 32769) ? (65535 - cnt) : cnt; val = (int) (32769.0 * pow ((double) (val ? val : 1) / 32769.0, (32769.0 + contr) / 32769.0)); s->contrast_array[cnt] = (cnt > 32769) ? (65535 - val) : val; if (s->contrast_array[cnt] > 65535) s->contrast_array[cnt] = 65535; if (s->contrast_array[cnt] < 0) s->contrast_array[cnt] = 0; } else { val = (cnt > 32769) ? (65535 - cnt) : cnt; p = ((int) contr == 32769) ? 32769.0 : 32769.0 / (32769.0 - contr); val = (int) (32769.0 * pow ((double) val / 32769.0, p)); s->contrast_array[cnt] = (cnt > 32639) ? (65535 - val) : val; if (s->contrast_array[cnt] > 65535) s->contrast_array[cnt] = 65535; if (s->contrast_array[cnt] < 0) s->contrast_array[cnt] = 0; } } } /* The calibration function Disclaimer: the following might be complete crap :-) -Gain, offset, exposure time It seems, that the gain values are actually constants. The windows driver always uses the values 0x0a,0x03,0x03, during calibration as well as during a normal scan. The exposure values are set to 0x04 for black calibration. It's not necessary to move the scan head during this stage. Calibration starts with default values for offset/exposure. These values are increased/decreased until the white and black values are within a specific range, defined by WHITE_MIN, WHITE_MAX, BLACK_MIN and BLACK_MAX. -White shading correction The scanning head is moved some lines over the calibration strip. Some lines are scanned at 600dpi/16bit over the full width. The average values are used for the shading buffer. The normal exposure values are used. -Black shading correction Works like the white shading correction, with the difference, that the red-, green- and blue exposure time is set to 0x04 (the value is taken from the windoze driver). -Since we do this over the whole width of the image with the maximal optical resolution, we can use the shading data for every scan, independend of the size, position or resolution, because we have the shading values for every sensor/LED. Note: For a CIS device, it's sufficient to determine those values once. It's not necessary, to repeat the calibration sequence before every new scan. The windoze driver even saves the values to various files to avoid the quite lengthy calibration sequence. This backend can also save the values to files. For this purpose, the user has to create a hidden directory called .artec-eplus48u in his/her home directory. If the user insists on calibration before every new scan, he/she can enable a specific option in the backend. */ static SANE_Status calibrate_scanner (SANE_Handle handle) { Artec48U_Scanner *s = handle; unsigned int *buffer_pointers[3]; int avg_black[3]; int avg_white[3]; int exp_off; int c; int finish = 0; int noloop = 0; if ((s->val[OPT_CALIBRATE].w == SANE_TRUE) && (s->val[OPT_CALIBRATE_SHADING].w == SANE_FALSE)) { while (finish == 0) { finish = 1; /*get black values */ artec48u_carriage_home (s->dev); artec48u_wait_for_positioning (s->dev); s->reader = NULL; s->scanning = SANE_TRUE; init_shading_buffer (s); artec48u_setup_scan (s, &(s->request), SA_CALIBRATE_SCAN_BLACK, SANE_FALSE, &(s->params)); artec48u_scanner_start_scan_extended (s, &(s->request), SA_CALIBRATE_SCAN_OFFSET_1, &(s->params)); for (c = 0; c < s->dev->shading_lines_b; c++) { artec48u_scanner_read_line (s, buffer_pointers, SANE_FALSE); /* we abuse the shading buffer for the offset calculation */ add_to_shading_buffer (s, buffer_pointers); } artec48u_scanner_stop_scan (s); finish_offset_buffer (s, &avg_black[0], &avg_black[1], &avg_black[2]); s->scanning = SANE_FALSE; XDBG ((1, "avg_r: %i, avg_g: %i, avg_b: %i\n", avg_black[0], avg_black[1], avg_black[2])); /*adjust offset */ for (c = 0; c < 3; c++) { if (c == 0) { if (avg_black[c] < BLACK_MIN) { s->dev->afe_params.r_offset -= 1; finish = 0; XDBG ((1, "adjust offset r: -1\n")); } else if (avg_black[c] > BLACK_MAX) { s->dev->afe_params.r_offset += 1; finish = 0; XDBG ((1, "adjust offset r: +1\n")); } } if (c == 1) { if (avg_black[c] < BLACK_MIN) { s->dev->afe_params.g_offset -= 1; finish = 0; XDBG ((1, "adjust offset g: -1\n")); } else if (avg_black[c] > BLACK_MAX) { s->dev->afe_params.g_offset += 1; finish = 0; XDBG ((1, "adjust offset g: +1\n")); } } if (c == 2) { if (avg_black[c] < BLACK_MIN) { s->dev->afe_params.b_offset -= 1; finish = 0; XDBG ((1, "adjust offset b: -1\n")); } else if (avg_black[c] > BLACK_MAX) { s->dev->afe_params.b_offset += 1; finish = 0; XDBG ((1, "adjust offset b: +1\n")); } } } /*adjust exposure */ /*get white values */ artec48u_carriage_home (s->dev); artec48u_wait_for_positioning (s->dev); s->reader = NULL; s->scanning = SANE_TRUE; init_shading_buffer (s); artec48u_setup_scan (s, &(s->request), SA_CALIBRATE_SCAN_WHITE, SANE_FALSE, &(s->params)); artec48u_scanner_start_scan_extended (s, &(s->request), SA_CALIBRATE_SCAN_EXPOSURE_1, &(s->params)); for (c = 0; c < s->dev->shading_lines_w; c++) { artec48u_scanner_read_line (s, buffer_pointers, SANE_FALSE); /* we abuse the shading buffer for the exposure calculation */ add_to_shading_buffer (s, buffer_pointers); } artec48u_scanner_stop_scan (s); finish_exposure_buffer (s, &avg_white[0], &avg_white[1], &avg_white[2]); s->scanning = SANE_FALSE; XDBG ((1, "avg_r: %i, avg_g: %i, avg_b: %i\n", avg_white[0], avg_white[1], avg_white[2])); for (c = 0; c < 3; c++) { if (c == 0) { if (avg_white[c] < WHITE_MIN) { exp_off = ((WHITE_MAX + WHITE_MIN) / 2 - avg_white[c]) / EXPOSURE_STEP; if (exp_off < 1) exp_off = 1; s->dev->exp_params.r_time += exp_off; finish = 0; XDBG ((1, "adjust exposure r: ++\n")); } else if (avg_white[c] > WHITE_MAX) { exp_off = (avg_white[c] - (WHITE_MAX + WHITE_MIN) / 2) / EXPOSURE_STEP; if (exp_off < 1) exp_off = 1; s->dev->exp_params.r_time -= exp_off; finish = 0; XDBG ((1, "adjust exposure r: --\n")); } } else if (c == 1) { if (avg_white[c] < WHITE_MIN) { exp_off = ((WHITE_MAX + WHITE_MIN) / 2 - avg_white[c]) / EXPOSURE_STEP; if (exp_off < 1) exp_off = 1; s->dev->exp_params.g_time += exp_off; finish = 0; XDBG ((1, "adjust exposure g: ++\n")); } else if (avg_white[c] > WHITE_MAX) { exp_off = (avg_white[c] - (WHITE_MAX + WHITE_MIN) / 2) / EXPOSURE_STEP; if (exp_off < 1) exp_off = 1; s->dev->exp_params.g_time -= exp_off; finish = 0; XDBG ((1, "adjust exposure g: --\n")); } } else if (c == 2) { if (avg_white[c] < WHITE_MIN) { exp_off = ((WHITE_MAX + WHITE_MIN) / 2 - avg_white[c]) / EXPOSURE_STEP; if (exp_off < 1) exp_off = 1; s->dev->exp_params.b_time += exp_off; finish = 0; XDBG ((1, "adjust exposure b: ++\n")); } else if (avg_white[c] > WHITE_MAX) { exp_off = (avg_white[c] - (WHITE_MAX + WHITE_MIN) / 2) / EXPOSURE_STEP; if (exp_off < 1) exp_off = 1; s->dev->exp_params.b_time -= exp_off; finish = 0; XDBG ((1, "adjust exposure b: --\n")); } } } XDBG ((1, "time_r: %x, time_g: %x, time_b: %x\n", s->dev->exp_params.r_time, s->dev->exp_params.g_time, s->dev->exp_params.b_time)); XDBG ((1, "offset_r: %x, offset_g: %x, offset_b: %x\n", s->dev->afe_params.r_offset, s->dev->afe_params.g_offset, s->dev->afe_params.b_offset)); ++noloop; if (noloop > 10) break; } } XDBG ((1, "option redOffset 0x%x\n", s->dev->afe_params.r_offset)); XDBG ((1, "option greenOffset 0x%x\n", s->dev->afe_params.g_offset)); XDBG ((1, "option blueOffset 0x%x\n", s->dev->afe_params.b_offset)); XDBG ((1, "option redExposure 0x%x\n", s->dev->exp_params.r_time)); XDBG ((1, "option greenExposure 0x%x\n", s->dev->exp_params.g_time)); XDBG ((1, "option blueExposure 0x%x\n", s->dev->exp_params.b_time)); s->dev->artec_48u_afe_params.r_offset = s->dev->afe_params.r_offset; s->dev->artec_48u_afe_params.g_offset = s->dev->afe_params.g_offset; s->dev->artec_48u_afe_params.b_offset = s->dev->afe_params.b_offset; /*don't forget the gain */ s->dev->artec_48u_afe_params.r_pga = s->dev->afe_params.r_pga; s->dev->artec_48u_afe_params.g_pga = s->dev->afe_params.g_pga; s->dev->artec_48u_afe_params.b_pga = s->dev->afe_params.b_pga; s->dev->artec_48u_exposure_params.r_time = s->dev->exp_params.r_time; s->dev->artec_48u_exposure_params.g_time = s->dev->exp_params.g_time; s->dev->artec_48u_exposure_params.b_time = s->dev->exp_params.b_time; /******************************* *get the black shading values * *******************************/ artec48u_carriage_home (s->dev); artec48u_wait_for_positioning (s->dev); s->reader = NULL; s->scanning = SANE_TRUE; init_shading_buffer (s); artec48u_setup_scan (s, &(s->request), SA_CALIBRATE_SCAN_BLACK, SANE_FALSE, &(s->params)); artec48u_scanner_start_scan_extended (s, &(s->request), SA_CALIBRATE_SCAN_BLACK, &(s->params)); for (c = 0; c < s->dev->shading_lines_b; c++) { artec48u_scanner_read_line (s, buffer_pointers, SANE_FALSE); add_to_shading_buffer (s, buffer_pointers); } artec48u_scanner_stop_scan (s); finish_shading_buffer (s, SANE_FALSE); s->scanning = SANE_FALSE; /******************************* *get the white shading values * *******************************/ artec48u_carriage_home (s->dev); artec48u_wait_for_positioning (s->dev); s->reader = NULL; s->scanning = SANE_TRUE; init_shading_buffer (s); artec48u_setup_scan (s, &(s->request), SA_CALIBRATE_SCAN_WHITE, SANE_FALSE, &(s->params)); artec48u_scanner_start_scan_extended (s, &(s->request), SA_CALIBRATE_SCAN_WHITE, &(s->params)); for (c = 0; c < s->dev->shading_lines_w; c++) { artec48u_scanner_read_line (s, buffer_pointers, SANE_FALSE); add_to_shading_buffer (s, buffer_pointers); } artec48u_scanner_stop_scan (s); finish_shading_buffer (s, SANE_TRUE); s->scanning = SANE_FALSE; save_calibration_data (s); return SANE_STATUS_GOOD; } static SANE_Status close_pipe (Artec48U_Scanner * s) { if (s->pipe >= 0) { XDBG ((1, "close_pipe\n")); close (s->pipe); s->pipe = -1; } return SANE_STATUS_EOF; } static void sigalarm_handler (int __sane_unused__ signal) { XDBG ((1, "ALARM!!!\n")); cancelRead = SANE_TRUE; } static void sig_chldhandler (int signo) { XDBG ((1, "Child is down (signal=%d)\n", signo)); } static int reader_process (void * data) { Artec48U_Scanner * s = (Artec48U_Scanner *) data; int fd = s->reader_pipe; SANE_Status status; struct SIGACTION act; sigset_t ignore_set; ssize_t bytes_written = 0; XDBG ((1, "reader process...\n")); if (sanei_thread_is_forked()) close (s->pipe); sigfillset (&ignore_set); sigdelset (&ignore_set, SIGTERM); sigdelset (&ignore_set, SIGUSR1); #if defined (__APPLE__) && defined (__MACH__) sigdelset (&ignore_set, SIGUSR2); #endif sigprocmask (SIG_SETMASK, &ignore_set, 0); memset (&act, 0, sizeof (act)); sigaction (SIGTERM, &act, 0); sigaction (SIGUSR1, &act, 0); cancelRead = SANE_FALSE; if (sigemptyset (&(act.sa_mask)) < 0) XDBG ((2, "(child) reader_process: sigemptyset() failed\n")); act.sa_flags = 0; act.sa_handler = reader_process_sigterm_handler; if (sigaction (SIGTERM, &act, 0) < 0) XDBG ((2, "(child) reader_process: sigaction(SIGTERM,...) failed\n")); act.sa_handler = usb_reader_process_sigterm_handler; if (sigaction (SIGUSR1, &act, 0) < 0) XDBG ((2, "(child) reader_process: sigaction(SIGUSR1,...) failed\n")); XDBG ((2, "(child) reader_process: s=%p, fd=%d\n", (void *) s, fd)); /*read line by line into buffer */ /*copy buffer pointers to line_buffer */ XDBG ((2, "(child) reader_process: byte_cnt %d\n", (int) s->byte_cnt)); s->eof = SANE_FALSE; while (s->lines_to_read > 0) { if (cancelRead == SANE_TRUE) { XDBG ((2, "(child) reader_process: cancelRead == SANE_TRUE\n")); s->scanning = SANE_FALSE; s->eof = SANE_FALSE; return SANE_STATUS_CANCELLED; } if (s->scanning != SANE_TRUE) { XDBG ((2, "(child) reader_process: scanning != SANE_TRUE\n")); return SANE_STATUS_CANCELLED; } status = artec48u_scanner_read_line (s, s->buffer_pointers, SANE_TRUE); if (status != SANE_STATUS_GOOD) { XDBG ((2, "(child) reader_process: scanner_read_line failed\n")); return SANE_STATUS_IO_ERROR; } copy_scan_line (s); s->lines_to_read -= 1; bytes_written = write (fd, s->line_buffer, s->sane_params.bytes_per_line); if (bytes_written < 0) { XDBG ((2, "(child) reader_process: write returned %s\n", strerror (errno))); s->eof = SANE_FALSE; return SANE_STATUS_IO_ERROR; } XDBG ((2, "(child) reader_process: lines to read %i\n", s->lines_to_read)); } s->eof = SANE_TRUE; close (fd); return SANE_STATUS_GOOD; } static SANE_Status do_cancel (Artec48U_Scanner * s, SANE_Bool closepipe) { struct SIGACTION act; SANE_Pid res; XDBG ((1, "do_cancel\n")); s->scanning = SANE_FALSE; if (sanei_thread_is_valid (s->reader_pid)) { /*parent */ XDBG ((1, "killing reader_process\n")); /* tell the driver to stop scanning */ sigemptyset (&(act.sa_mask)); act.sa_flags = 0; act.sa_handler = sigalarm_handler; if (sigaction (SIGALRM, &act, 0) == -1) XDBG ((1, "sigaction() failed !\n")); /* kill our child process and wait until done */ alarm (10); if (sanei_thread_kill (s->reader_pid) < 0) XDBG ((1, "sanei_thread_kill() failed !\n")); res = sanei_thread_waitpid (s->reader_pid, 0); alarm (0); if (res != s->reader_pid) { XDBG ((1, "sanei_thread_waitpid() failed !\n")); } sanei_thread_invalidate (s->reader_pid); XDBG ((1, "reader_process killed\n")); } if (SANE_TRUE == closepipe) { close_pipe (s); XDBG ((1, "pipe closed\n")); } artec48u_scanner_stop_scan (s); artec48u_carriage_home (s->dev); if (s->line_buffer) { XDBG ((2, "freeing line_buffer\n")); free (s->line_buffer); s->line_buffer = NULL; } if (s->lineart_buffer) { XDBG ((2, "freeing lineart_buffer\n")); free (s->lineart_buffer); s->lineart_buffer = NULL; } return SANE_STATUS_CANCELLED; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { static const SANE_Device **devlist = 0; Artec48U_Device *dev; SANE_Int dev_num; XDBG ((5, "sane_get_devices: start: local_only = %s\n", local_only == SANE_TRUE ? "true" : "false")); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; dev_num = 0; for (dev = first_dev; dev_num < num_devices; dev = dev->next) { devlist[dev_num] = &dev->sane; XDBG ((3, "sane_get_devices: name %s\n", dev->sane.name)); XDBG ((3, "sane_get_devices: vendor %s\n", dev->sane.vendor)); XDBG ((3, "sane_get_devices: model %s\n", dev->sane.model)); ++dev_num; } devlist[dev_num] = 0; ++dev_num; *device_list = devlist; XDBG ((5, "sane_get_devices: exit\n")); return SANE_STATUS_GOOD; } static SANE_Status load_calibration_data (Artec48U_Scanner * s) { SANE_Status status = SANE_STATUS_GOOD; FILE *f = 0; size_t cnt; char path[PATH_MAX]; char filename[PATH_MAX]; s->calibrated = SANE_FALSE; path[0] = 0; /* return SANE_STATUS_INVAL if HOME environment variable is not set */ if (getenv ("HOME") == NULL) { XDBG ((1, "Environment variable HOME not set\n")); return SANE_STATUS_INVAL; } if (strlen (getenv ("HOME")) < (PATH_MAX - 1)) strcat (path, getenv ("HOME")); else return SANE_STATUS_INVAL; if (strlen (path) < (PATH_MAX - 1 - strlen ("/.artec_eplus48u/"))) strcat (path, "/.artec_eplus48u/"); else return SANE_STATUS_INVAL; /*try to load black shading file */ strcpy (filename, path); if (strlen (filename) < (PATH_MAX - 1 - strlen ("artec48ushading_black"))) strcat (filename, "artec48ushading_black"); else return SANE_STATUS_INVAL; XDBG ((1, "Try to read black shading file: \"%s\"\n", filename)); f = fopen (filename, "rb"); if (!f) return SANE_STATUS_INVAL; /*read values */ cnt = fread (s->shading_buffer_b, sizeof (unsigned char), 30720*s->dev->epro_mult, f); /*epro*/ if (cnt != (30720*s->dev->epro_mult)) /*epro*/ { fclose (f); XDBG ((1, "Could not load black shading file\n")); return SANE_STATUS_INVAL; } fclose (f); /*try to load white shading file */ strcpy (filename, path); if (strlen (filename) < (PATH_MAX - 1 - strlen ("artec48ushading_white"))) strcat (filename, "artec48ushading_white"); else return SANE_STATUS_INVAL; XDBG ((1, "Try to read white shading file: \"%s\"\n", filename)); f = fopen (filename, "rb"); if (!f) return SANE_STATUS_INVAL; /*read values */ cnt = fread (s->shading_buffer_w, sizeof (unsigned char), 30720*s->dev->epro_mult, f);/*epro*/ if (cnt != (30720*s->dev->epro_mult)) /*epro*/ { fclose (f); XDBG ((1, "Could not load white shading file\n")); return SANE_STATUS_INVAL; } fclose (f); /*try to load offset file */ strcpy (filename, path); if (strlen (filename) < (PATH_MAX - 1 - strlen ("artec48uoffset"))) strcat (filename, "artec48uoffset"); else return SANE_STATUS_INVAL; XDBG ((1, "Try to read offset file: \"%s\"\n", filename)); f = fopen (filename, "rb"); if (!f) return SANE_STATUS_INVAL; /*read values */ cnt = fread (&s->dev->artec_48u_afe_params, sizeof (Artec48U_AFE_Parameters), 1, f); if (cnt != 1) { fclose (f); XDBG ((1, "Could not load offset file\n")); return SANE_STATUS_INVAL; } fclose (f); /*load exposure file */ strcpy (filename, path); if (strlen (filename) < (PATH_MAX - 1 - strlen ("artec48uexposure"))) strcat (filename, "artec48uexposure"); else return SANE_STATUS_INVAL; XDBG ((1, "Try to read exposure file: \"%s\"\n", filename)); f = fopen (filename, "rb"); if (!f) return SANE_STATUS_INVAL; /*read values */ cnt = fread (&s->dev->artec_48u_exposure_params, sizeof (Artec48U_Exposure_Parameters), 1, f); if (cnt != 1) { fclose (f); XDBG ((1, "Could not load exposure file\n")); return SANE_STATUS_INVAL; } fclose (f); s->calibrated = SANE_TRUE; return status; } static SANE_Status save_calibration_data (Artec48U_Scanner * s) { SANE_Status status = SANE_STATUS_GOOD; FILE *f = 0; size_t cnt; char path[PATH_MAX]; char filename[PATH_MAX]; mode_t mode = S_IRUSR | S_IWUSR; path[0] = 0; /* return SANE_STATUS_INVAL if HOME environment variable is not set */ if (getenv ("HOME") == NULL) { XDBG ((1, "Environment variable HOME not set\n")); return SANE_STATUS_INVAL; } if (strlen (getenv ("HOME")) < (PATH_MAX - 1)) strcat (path, getenv ("HOME")); else return SANE_STATUS_INVAL; if (strlen (path) < (PATH_MAX - 1 - strlen ("/.artec_eplus48u/"))) strcat (path, "/.artec_eplus48u/"); else return SANE_STATUS_INVAL; /*try to save black shading file */ strcpy (filename, path); if (strlen (filename) < (PATH_MAX - 1 - strlen ("artec48ushading_black"))) strcat (filename, "artec48ushading_black"); else return SANE_STATUS_INVAL; XDBG ((1, "Try to save black shading file: \"%s\"\n", filename)); f = fopen (filename, "w"); if (!f) { XDBG ((1, "Could not save artec48ushading_black\n")); return SANE_STATUS_INVAL; } if (chmod (filename, mode) != 0) return SANE_STATUS_INVAL; /*read values */ cnt = fwrite (s->shading_buffer_b, sizeof (unsigned char), 30720*s->dev->epro_mult, f); /*epro*/ XDBG ((1, "Wrote %li bytes to black shading buffer \n", (u_long) cnt)); if (cnt != (30720*s->dev->epro_mult))/*epro*/ { fclose (f); XDBG ((1, "Could not write black shading buffer\n")); return SANE_STATUS_INVAL; } fclose (f); /*try to save white shading file */ strcpy (filename, path); if (strlen (filename) < (PATH_MAX - 1 - strlen ("artec48ushading_white"))) strcat (filename, "artec48ushading_white"); else return SANE_STATUS_INVAL; XDBG ((1, "Try to save white shading file: \"%s\"\n", filename)); f = fopen (filename, "w"); if (!f) return SANE_STATUS_INVAL; if (chmod (filename, mode) != 0) return SANE_STATUS_INVAL; /*read values */ cnt = fwrite (s->shading_buffer_w, sizeof (unsigned char), 30720*s->dev->epro_mult, f);/*epro*/ if (cnt != (30720*s->dev->epro_mult)) /*epro*/ { fclose (f); XDBG ((1, "Could not write white shading buffer\n")); return SANE_STATUS_INVAL; } fclose (f); /*try to save offset file */ strcpy (filename, path); if (strlen (filename) < (PATH_MAX - 1 - strlen ("artec48uoffset"))) strcat (filename, "artec48uoffset"); else return SANE_STATUS_INVAL; XDBG ((1, "Try to write offset file: \"%s\"\n", filename)); f = fopen (filename, "w"); if (!f) return SANE_STATUS_INVAL; if (chmod (filename, mode) != 0) return SANE_STATUS_INVAL; /*read values */ cnt = fwrite (&s->dev->artec_48u_afe_params, sizeof (Artec48U_AFE_Parameters), 1, f); if (cnt != 1) { fclose (f); XDBG ((1, "Could not write afe values\n")); return SANE_STATUS_INVAL; } fclose (f); /*try to write exposure file */ strcpy (filename, path); if (strlen (filename) < (PATH_MAX - 1 - strlen ("artec48uexposure"))) strcat (filename, "artec48uexposure"); else return SANE_STATUS_INVAL; XDBG ((1, "Try to write exposure file: \"%s\"\n", filename)); f = fopen (filename, "w"); if (!f) return SANE_STATUS_INVAL; if (chmod (filename, mode) != 0) return SANE_STATUS_INVAL; /*read values */ cnt = fwrite (&s->dev->artec_48u_exposure_params, sizeof (Artec48U_Exposure_Parameters), 1, f); if (cnt != 1) { fclose (f); XDBG ((1, "Could not write exposure values\n")); return SANE_STATUS_INVAL; } fclose (f); return status; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { SANE_Status status = SANE_STATUS_INVAL; Artec48U_Device *dev = 0; Artec48U_Scanner *s = 0; if (!devicename) return SANE_STATUS_INVAL; XDBG ((2, "sane_open: devicename = \"%s\"\n", devicename)); if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { XDBG ((2, "sane_open: found matching device %s\n", dev->sane.name)); break; } } if (!dev) { status = attach (devicename, &dev); if (status != SANE_STATUS_GOOD) XDBG ((2, "sane_open: attach failed %s\n", devicename)); } } else { /* empty devicename -> use first device */ XDBG ((2, "sane_open: empty devicename\n")); dev = first_dev; } if (!dev) return SANE_STATUS_INVAL; status = artec48u_device_open (dev); if (status != SANE_STATUS_GOOD) { XDBG ((3, "could not open device\n")); return status; } XDBG ((2, "sane_open: opening device `%s', handle = %p\n", dev->sane.name, (void *) dev)); XDBG ((1, "sane_open - %s\n", dev->sane.name)); XDBG ((2, "sane_open: try to open %s\n", dev->sane.name)); status = artec48u_device_activate (dev); if (status != SANE_STATUS_GOOD) { XDBG ((3, "could not activate device\n")); return status; } /* We do not check anymore, whether the firmware is already loaded */ /* because that caused problems after rebooting; furthermore, loading */ /* of the firmware is fast, therefore the test doesn't make much sense */ status = download_firmware_file (dev); if (status != SANE_STATUS_GOOD) { XDBG ((3, "download_firmware_file failed\n")); return status; } /* If a scan is interrupted without sending stop_scan, bad things happen. * Send the stop scan command now just in case. */ artec48u_stop_scan (dev); artec48u_wait_for_positioning (dev); artec48u_scanner_new (dev, &s); init_calibrator (s); s->next = first_handle; first_handle = s; *handle = s; status = init_options (s); if (status != SANE_STATUS_GOOD) return status; /*Try to load the calibration values */ status = load_calibration_data (s); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Artec48U_Scanner *s; XDBG ((5, "sane_close: start\n")); /* remove handle from list of open handles: */ for (s = first_handle; s; s = s->next) { if (s == handle) break; } if (!s) { XDBG ((5, "close: invalid handle %p\n", handle)); return; } artec48u_device_close (s->dev); artec48u_scanner_free (s); XDBG ((5, "sane_close: exit\n")); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Artec48U_Scanner *s = handle; if ((unsigned) option >= NUM_OPTIONS) return 0; XDBG ((5, "sane_get_option_descriptor: option = %s (%d)\n", s->opt[option].name, option)); return s->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { Artec48U_Scanner *s = handle; #ifdef ARTEC48U_USE_BUTTONS SANE_Int button_state; #endif SANE_Status status; XDBG ((8, "sane_control_option: handle=%p, opt=%d, act=%d, val=%p, info=%p\n", (void *) handle, option, action, (void *) value, (void *) info)); if (info) *info = 0; if (option < 0 || option >= NUM_OPTIONS) return SANE_STATUS_INVAL; /* Unknown option ... */ if (!SANE_OPTION_IS_ACTIVE (s->opt[option].cap)) return SANE_STATUS_INVAL; switch (action) { case SANE_ACTION_SET_VALUE: if (s->scanning == SANE_TRUE) return SANE_STATUS_INVAL; if (!SANE_OPTION_IS_SETTABLE (s->opt[option].cap)) return SANE_STATUS_INVAL; status = sanei_constrain_value (s->opt + option, value, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { case OPT_RESOLUTION: if(s->dev->is_epro != 0) { if((s->val[option].w == 1200) && (*(SANE_Word *) value < 1200)) { s->opt[OPT_BIT_DEPTH].constraint.word_list = bitdepth_list; *info |= SANE_INFO_RELOAD_OPTIONS; } else if((s->val[option].w < 1200) && (*(SANE_Word *) value == 1200)) { s->opt[OPT_BIT_DEPTH].constraint.word_list = bitdepth_list2; if(s->val[OPT_BIT_DEPTH].w > 8) s->val[OPT_BIT_DEPTH].w = 8; *info |= SANE_INFO_RELOAD_OPTIONS; } } s->val[option].w = *(SANE_Word *) value; if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } break; /* fall through */ case OPT_BIT_DEPTH: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: s->val[option].w = *(SANE_Word *) value; if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; /* fall through */ case OPT_BLACK_LEVEL: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_GAMMA: case OPT_GAMMA_R: case OPT_GAMMA_G: case OPT_GAMMA_B: case OPT_CALIBRATE: case OPT_CALIBRATE_SHADING: s->val[option].w = *(SANE_Word *) value; return SANE_STATUS_GOOD; case OPT_DEFAULT_ENHANCEMENTS: s->val[OPT_GAMMA].w = SANE_FIX (s->dev->gamma_master); if (strcmp (s->val[OPT_SCAN_MODE].s, mode_list[2]) == 0) { s->val[OPT_GAMMA_R].w = SANE_FIX (s->dev->gamma_r); s->val[OPT_GAMMA_G].w = SANE_FIX (s->dev->gamma_g); s->val[OPT_GAMMA_B].w = SANE_FIX (s->dev->gamma_b); } s->val[OPT_BRIGHTNESS].w = 0; s->val[OPT_CONTRAST].w = 0; if (info) *info |= SANE_INFO_RELOAD_OPTIONS; break; case OPT_SCAN_MODE: if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (value); if (strcmp (s->val[OPT_SCAN_MODE].s, mode_list[0]) == 0) { s->opt[OPT_GAMMA_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BLACK_LEVEL].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; } else if (strcmp (s->val[OPT_SCAN_MODE].s, mode_list[1]) == 0) { s->opt[OPT_GAMMA_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BLACK_LEVEL].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BIT_DEPTH].cap &= ~SANE_CAP_INACTIVE; } else { s->opt[OPT_GAMMA_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_B].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_BLACK_LEVEL].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BIT_DEPTH].cap &= ~SANE_CAP_INACTIVE; } if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; } break; case SANE_ACTION_GET_VALUE: switch (option) { /* word options: */ case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_BIT_DEPTH: case OPT_BLACK_LEVEL: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_GAMMA: case OPT_GAMMA_R: case OPT_GAMMA_G: case OPT_GAMMA_B: case OPT_CALIBRATE: case OPT_CALIBRATE_SHADING: *(SANE_Word *) value = (SANE_Word) s->val[option].w; return SANE_STATUS_GOOD; /* string options: */ case OPT_SCAN_MODE: strcpy (value, s->val[option].s); return SANE_STATUS_GOOD; #ifdef ARTEC48U_USE_BUTTONS case OPT_BUTTON_STATE: status = artec48u_check_buttons (s->dev, &button_state); if (status == SANE_STATUS_GOOD) { s->val[option].w = button_state; *(SANE_Int *) value = (SANE_Int) s->val[option].w; } else { s->val[option].w = 0; *(SANE_Int *) value = 0; } return SANE_STATUS_GOOD; #endif } break; default: return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Artec48U_Scanner *s = handle; SANE_Status status; SANE_Word resx; /* int scan_mode;*/ SANE_String str = s->val[OPT_SCAN_MODE].s; int tlx; int tly; int brx; int bry; int tmp; XDBG ((2, "sane_get_params: string %s\n", str)); XDBG ((2, "sane_get_params: enter\n")); tlx = s->val[OPT_TL_X].w; tly = s->val[OPT_TL_Y].w; brx = s->val[OPT_BR_X].w; bry = s->val[OPT_BR_Y].w; /*make sure, that tlx < brx and tly < bry this will NOT change the options */ if (tlx > brx) { tmp = tlx; tlx = brx; brx = tmp; } if (tly > bry) { tmp = tly; tly = bry; bry = tmp; } resx = s->val[OPT_RESOLUTION].w; str = s->val[OPT_SCAN_MODE].s; s->request.color = SANE_TRUE; if ((strcmp (str, mode_list[0]) == 0) || (strcmp (str, mode_list[1]) == 0)) s->request.color = SANE_FALSE; else s->request.color = SANE_TRUE; s->request.depth = s->val[OPT_BIT_DEPTH].w; if (strcmp (str, mode_list[0]) == 0) s->request.depth = 8; s->request.y0 = tly; /**< Top boundary */ s->request.x0 = SANE_FIX (216.0) - brx; /**< left boundary */ s->request.xs = brx - tlx; /**< Width */ s->request.ys = bry - tly; /**< Height */ s->request.xdpi = resx; /**< Horizontal resolution */ s->request.ydpi = resx; /**< Vertical resolution */ /*epro*/ if ((resx == 1200) && (s->dev->is_epro == 0)) s->request.xdpi = 600;/**< Vertical resolution */ status = artec48u_setup_scan (s, &(s->request), SA_SCAN, SANE_TRUE, &(s->params)); if (status != SANE_STATUS_GOOD) return SANE_STATUS_INVAL; /*DBG(1, "sane_get_params: scan_mode %i\n",scan_mode);*/ params->depth = s->params.depth; s->params.lineart = SANE_FALSE; if (s->params.color == SANE_TRUE) { params->format = SANE_FRAME_RGB; params->bytes_per_line = s->params.pixel_xs * 3; } else { params->format = SANE_FRAME_GRAY; params->bytes_per_line = s->params.pixel_xs; if (strcmp (str, mode_list[0]) == 0) { params->depth = 1; params->bytes_per_line = (s->params.pixel_xs + 7) / 8; s->params.lineart = SANE_TRUE; } } if ((resx == 1200) && (s->dev->is_epro == 0)) { if (params->depth == 1) params->bytes_per_line = (s->params.pixel_xs * 2 + 7) / 8; else params->bytes_per_line *= 2; } if (params->depth == 16) params->bytes_per_line *= 2; params->last_frame = SANE_TRUE; params->pixels_per_line = s->params.pixel_xs; if ((resx == 1200) && (s->dev->is_epro == 0)) params->pixels_per_line *= 2; params->lines = s->params.pixel_ys; return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Artec48U_Scanner *s = handle; SANE_Status status; int fds[2]; if (s->scanning) { return SANE_STATUS_DEVICE_BUSY; } if (sane_get_parameters (handle, &s->sane_params) != SANE_STATUS_GOOD) return SANE_STATUS_INVAL; if ((s->calibrated != SANE_TRUE) || (s->val[OPT_CALIBRATE].w == SANE_TRUE)) { XDBG ((1, "Must calibrate scanner\n")); status = calibrate_scanner (s); if (status != SANE_STATUS_GOOD) return status; s->calibrated = SANE_TRUE; } if (sane_get_parameters (handle, &s->sane_params) != SANE_STATUS_GOOD) return SANE_STATUS_INVAL; calculate_brightness (s); calculate_contrast (s); calculateGamma (s); calculateGammaRed (s); calculateGammaGreen (s); calculateGammaBlue (s); artec48u_carriage_home (s->dev); artec48u_wait_for_positioning (s->dev); s->reader = NULL; s->scanning = SANE_TRUE; s->byte_cnt = 0; s->lines_to_read = s->params.pixel_ys; /*allocate a buffer, that can hold a complete scan line */ /*If resolution is 1200 dpi and we are scanning in lineart mode, then we also allocate a lineart_buffer, which can hold a complete scan line in 8 bit/gray. This makes interpolation easier. */ if ((s->params.ydpi == 1200) && (s->dev->is_epro == 0)) { if (s->request.color == SANE_TRUE) { s->line_buffer = (SANE_Byte *) malloc (s->params.scan_bpl * 8); } else { s->line_buffer = (SANE_Byte *) malloc (s->params.scan_bpl * 4); /*lineart ? */ if (strcmp (s->val[OPT_SCAN_MODE].s, mode_list[0]) == 0) s->lineart_buffer = (SANE_Byte *) malloc (s->params.pixel_xs * 2); } } else { if (s->request.color == SANE_TRUE) s->line_buffer = (SANE_Byte *) malloc (s->params.scan_bpl * 4); else { s->line_buffer = (SANE_Byte *) malloc (s->params.scan_bpl * 2); /*lineart ? */ if (strcmp (s->val[OPT_SCAN_MODE].s, mode_list[0]) == 0) s->lineart_buffer = (SANE_Byte *) malloc (s->params.pixel_xs * 2); } } if (pipe (fds) < 0) { s->scanning = SANE_FALSE; XDBG ((2, "sane_start: pipe failed (%s)\n", strerror (errno))); return SANE_STATUS_IO_ERROR; } status = artec48u_scanner_start_scan (s, &s->request, &s->params); if (status != SANE_STATUS_GOOD) { XDBG ((2, "sane_start: could not start scan\n")); return status; } s->pipe = fds[0]; s->reader_pipe = fds[1]; s->reader_pid = sanei_thread_begin (reader_process, s); cancelRead = SANE_FALSE; if (!sanei_thread_is_valid (s->reader_pid)) { s->scanning = SANE_FALSE; XDBG ((2, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno))); return SANE_STATUS_NO_MEM; } signal (SIGCHLD, sig_chldhandler); if (sanei_thread_is_forked()) close (s->reader_pipe); XDBG ((1, "sane_start done\n")); return SANE_STATUS_GOOD; /* parent */ } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { Artec48U_Scanner *s = handle; ssize_t nread; *length = 0; /* here we read all data from the driver... */ nread = read (s->pipe, data, max_length); XDBG ((3, "sane_read - read %ld bytes\n", (long) nread)); if (cancelRead == SANE_TRUE) { return do_cancel (s, SANE_TRUE); } if (nread < 0) { if (EAGAIN == errno) { /* if we already had read the picture, so it's okay and stop */ if (s->eof == SANE_TRUE) { sanei_thread_waitpid (s->reader_pid, 0); sanei_thread_invalidate (s->reader_pid); artec48u_scanner_stop_scan (s); artec48u_carriage_home (s->dev); return close_pipe (s); } /* else force the frontend to try again */ return SANE_STATUS_GOOD; } else { XDBG ((4, "ERROR: errno=%d\n", errno)); do_cancel (s, SANE_TRUE); return SANE_STATUS_IO_ERROR; } } *length = nread; s->byte_cnt += nread; /* nothing read means that we're finished OR we had a problem... */ if (0 == nread) { if (0 == s->byte_cnt) { s->exit_code = sanei_thread_get_status (s->reader_pid); if (SANE_STATUS_GOOD != s->exit_code) { close_pipe (s); return s->exit_code; } } return close_pipe (s); } return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Artec48U_Scanner *s = handle; XDBG ((2, "sane_cancel: handle = %p\n", handle)); if (s->scanning) do_cancel (s, SANE_FALSE); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Artec48U_Scanner *s = (Artec48U_Scanner *) handle; XDBG ((1, "sane_set_io_mode: non_blocking=%d\n", non_blocking)); if (!s->scanning) { XDBG ((4, "ERROR: not scanning !\n")); return SANE_STATUS_INVAL; } if (-1 == s->pipe) { XDBG ((4, "ERROR: not supported !\n")); return SANE_STATUS_UNSUPPORTED; } if (fcntl (s->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) { XDBG ((4, "ERROR: can?t set to non-blocking mode !\n")); return SANE_STATUS_IO_ERROR; } XDBG ((1, "sane_set_io_mode done\n")); return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Artec48U_Scanner *s = (Artec48U_Scanner *) handle; XDBG ((1, "sane_get_select_fd\n")); if (!s->scanning) { XDBG ((4, "ERROR: not scanning !\n")); return SANE_STATUS_INVAL; } *fd = s->pipe; XDBG ((1, "sane_get_select_fd done\n")); return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { Artec48U_Device *device = 0; SANE_Status status; char str[PATH_MAX] = _DEFAULT_DEVICE; char temp[PATH_MAX]; size_t len; FILE *fp; double gamma_m = 1.9; double gamma_r = 1.0; double gamma_g = 1.0; double gamma_b = 1.0; int epro_default = 0; DBG_INIT (); eProMult = 1; isEPro = 0; temp[0] = 0; strcpy (vendor_string, "Artec"); strcpy (model_string, "E+ 48U"); sanei_usb_init (); sanei_thread_init (); /* do some presettings... */ auth = authorize; if (version_code != NULL) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (ARTEC48U_CONFIG_FILE); /* default to _DEFAULT_DEVICE instead of insisting on config file */ if (NULL == fp) { status = attach (_DEFAULT_DEVICE, &device); return status; } while (sanei_config_read (str, sizeof (str), fp)) { XDBG ((1, "sane_init, >%s<\n", str)); /* ignore line comments */ if (str[0] == '#') continue; len = strlen (str); /* ignore empty lines */ if (0 == len) continue; /* check for options */ if (0 == strncmp (str, "option", 6)) { if(decodeVal (str,"ePlusPro",_INT, &isEPro,&epro_default) == SANE_TRUE) { eProMult = 1; if(isEPro != 0) { eProMult = 2; XDBG ((3, "Is Artec E Pro\n")); } else XDBG ((3, "Is Artec E+ 48U\n")); } decodeVal (str, "masterGamma", _FLOAT, &gamma_master_default, &gamma_m); decodeVal (str, "redGamma", _FLOAT, &gamma_r_default, &gamma_r); decodeVal (str, "greenGamma", _FLOAT, &gamma_g_default, &gamma_g); decodeVal (str, "blueGamma", _FLOAT, &gamma_b_default, &gamma_b); decodeVal (str, "redOffset", _BYTE, &afe_params.r_offset, &default_afe_params.r_offset); decodeVal (str, "greenOffset", _BYTE, &afe_params.g_offset, &default_afe_params.g_offset); decodeVal (str, "blueOffset", _BYTE, &afe_params.b_offset, &default_afe_params.b_offset); decodeVal (str, "redExposure", _INT, &exp_params.r_time, &default_exp_params.r_time); decodeVal (str, "greenExposure", _INT, &exp_params.g_time, &default_exp_params.g_time); decodeVal (str, "blueExposure", _INT, &exp_params.b_time, &default_exp_params.b_time); decodeVal (str, "modelString", _STRING, model_string, model_string); decodeVal (str, "vendorString", _STRING, vendor_string, vendor_string); decodeVal (str, "artecFirmwareFile", _STRING, firmwarePath, firmwarePath); } else if (0 == strncmp (str, "usb", 3)) { if (temp[0] != 0) { XDBG ((3, "trying to attach: %s\n", temp)); XDBG ((3, " vendor: %s\n", vendor_string)); XDBG ((3, " model: %s\n", model_string)); sanei_usb_attach_matching_devices (temp, attach_one_device); } /*save config line in temp */ strcpy (temp, str); } else if (0 == strncmp (str, "device", 6)) { if (SANE_TRUE == decodeDevName (str, devName)) { if (devName[0] != 0) sanei_usb_attach_matching_devices (devName, attach_one_device); temp[0] = 0; } } else { /* ignore other stuff... */ XDBG ((1, "ignoring >%s<\n", str)); } } if (temp[0] != 0) { XDBG ((3, "trying to attach: %s\n", temp)); XDBG ((3, " vendor: %s\n", vendor_string)); XDBG ((3, " model: %s\n", model_string)); sanei_usb_attach_matching_devices (temp, attach_one_device); temp[0] = 0; } fclose (fp); return SANE_STATUS_GOOD; } void sane_exit (void) { Artec48U_Device *dev, *next; XDBG ((5, "sane_exit: start\n")); for (dev = first_dev; dev; dev = next) { next = dev->next; /*function will check, whether device is really open */ artec48u_device_close (dev); artec48u_device_free (dev); } XDBG ((5, "sane_exit: exit\n")); return; } sane-backends-1.0.29/backend/agfafocus.c0000666000000000000000000015462613615534521014710 00000000000000/* sane - Scanner Access Now Easy. This file (C) 1997 Ingo Schneider (C) 1998 Karl Anders Øygard This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for AGFA Focus flatbed scanners. */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_config.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_thread.h" #define BACKEND_NAME agfafocus #include "../include/sane/sanei_backend.h" #include "agfafocus.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #undef Byte #define Byte SANE_Byte static const SANE_Device **devlist = 0; static int num_devices; static AgfaFocus_Device *agfafocus_devices; static const SANE_String_Const focus_mode_list[] = { "Lineart", "Gray (6 bit)", 0 }; static const SANE_String_Const focusii_mode_list[] = { "Lineart", "Gray (6 bit)", "Gray (8 bit)", 0 }; static const SANE_String_Const focuscolor_mode_list[] = { "Lineart", "Gray (6 bit)", "Gray (8 bit)", "Color (18 bit)", "Color (24 bit)", 0 }; static const SANE_String_Const halftone_list[] = { "None", "Dispersed dot 4x4", "Round (Clustered dot 4x4)", "Diamond (Clustered dot 4x4)", 0 }; static const SANE_String_Const halftone_upload_list[] = { "None", "Dispersed dot 4x4", "Round (Clustered dot 4x4)", "Diamond (Clustered dot 4x4)", 0 }; static const SANE_String_Const source_list[] = { "Opaque/Normal", "Transparency", 0 }; static const SANE_String_Const quality_list[] = { "Low", "Normal", "High", 0 }; static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; DBG (11, ">> max_string_size\n"); for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } DBG (11, "<< max_string_size\n"); return max_size; } /* sets loc_s bytes long value at offset loc in scsi command to value size */ static void set_size (Byte * loc, int loc_s, size_t size) { int i; for (i = 0; i < loc_s; i++) { loc[loc_s - i - 1] = (size >> (i * 8)) & 0xff; } } /* gets loc_s bytes long value from loc in scsi command */ static int get_size (Byte * loc, int loc_s) { int i; int j = 0; for (i = 0; i < loc_s; i++) { j = (j << 8) + (loc[i] & 0xff); } return j; } static long reserve_unit (int fd) { struct { /* Command */ Byte cmd; Byte lun; Byte res[2]; Byte tr_len; Byte ctrl; } scsi_reserve; memset (&scsi_reserve, 0, sizeof (scsi_reserve)); scsi_reserve.cmd = 0x16; /* RELEASE */ DBG (3, "reserve_unit()\n"); return sanei_scsi_cmd (fd, &scsi_reserve, sizeof (scsi_reserve), 0, 0); } static long release_unit (int fd) { struct { /* Command */ Byte cmd; Byte lun; Byte res[2]; Byte tr_len; Byte ctrl; } scsi_release; memset (&scsi_release, 0, sizeof (scsi_release)); scsi_release.cmd = 0x17; /* RELEASE */ DBG (3, "release_unit()\n"); return sanei_scsi_cmd (fd, &scsi_release, sizeof (scsi_release), 0, 0); } static SANE_Status test_ready (int fd) { SANE_Status status; int try; struct { /* Command */ Byte cmd; Byte lun; Byte res[2]; Byte tr_len; Byte ctrl; } scsi_test_ready; memset (&scsi_test_ready, 0, sizeof (scsi_test_ready)); scsi_test_ready.cmd = 0x00; /* TEST UNIT READY */ for (try = 0; try < 1000; ++try) { DBG (3, "test_ready: sending TEST_UNIT_READY\n"); status = sanei_scsi_cmd (fd, &scsi_test_ready, sizeof (scsi_test_ready), 0, 0); switch (status) { case SANE_STATUS_DEVICE_BUSY: usleep (100000); /* retry after 100ms */ break; case SANE_STATUS_GOOD: return status; default: DBG (1, "test_ready: test unit ready failed (%s)\n", sane_strstatus (status)); return status; } } DBG (1, "test_ready: timed out after %d attempts\n", try); return SANE_STATUS_IO_ERROR; } static SANE_Status sense_handler (int scsi_fd, u_char *result, void *arg) { scsi_fd = scsi_fd; /* silence gcc */ arg = arg; /* silence gcc */ if (result[0]) { DBG (0, "sense_handler() : sense code = %02x\n", result[0]); return SANE_STATUS_IO_ERROR; } else { return SANE_STATUS_GOOD; } } static SANE_Status stop_scan (int fd) { fd = fd; /* silence gcc */ /* XXX don't know how to stop the scanner. To be tested ! */ #if 0 const Byte scsi_rewind[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 }; DBG (1, "Trying to stop scanner...\n"); return sanei_scsi_cmd (fd, scsi_rewind, sizeof (scsi_rewind), 0, 0); #else return SANE_STATUS_GOOD; #endif } static SANE_Status start_scan (int fd, SANE_Bool cont) { struct { /* Command */ Byte cmd; Byte lun; Byte res[2]; Byte tr_len; Byte ctrl; /* Data */ Byte wid; } scsi_start_scan; memset (&scsi_start_scan, 0, sizeof (scsi_start_scan)); scsi_start_scan.cmd = 0x1b; /* SCAN */ scsi_start_scan.tr_len = 1; scsi_start_scan.wid = 0; scsi_start_scan.ctrl = (cont == SANE_TRUE) ? 0x80 : 0x00; DBG (1, "Starting scanner ...\n"); return sanei_scsi_cmd (fd, &scsi_start_scan, sizeof (scsi_start_scan), 0, 0); } static void wait_ready (int fd) { struct { Byte bytes[2]; /* Total # of bytes */ Byte scan[2]; /* ms to complete - driver sleep time */ } result; size_t size = sizeof (result); SANE_Status status; struct { Byte cmd; Byte lun; Byte data_type; Byte re1[3]; Byte tr_len[3]; Byte ctrl; } cmd; memset (&cmd, 0, sizeof (cmd)); cmd.cmd = 0x28; /* READ */ cmd.data_type = 0x80; /* get scan time */ set_size (cmd.tr_len, 3, sizeof (result)); while (1) { status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), &result, &size); if (status != SANE_STATUS_GOOD || size != sizeof (result)) { /* Command failed, the assembler code of the windows scan library ignores this condition, and so do I */ break; } else { /* left is the amount of seconds left till the scanner is ready * 100 */ int left = get_size (result.scan, 2); DBG (1, "wait_ready() : %d left...\n", left); if (!left) break; /* We delay only for half the given time */ else if (left < 200) usleep (left * 5000); else sleep (left / 200); } } return; } static SANE_Status get_read_sizes (int fd, int *lines_available, int *bpl, int *total_lines) { struct { Byte reserved1[8]; Byte line_width[2]; Byte total_lines[2]; Byte cur_line[2]; Byte lines_this_block[2]; Byte reserved[8]; } read_sizes; const Byte scsi_read[] = { 0x28, 0x00, /* opcode, lun */ 0x81, /* data type 81 == read time left */ 0x00, 0x00, 0x00, /* reserved */ 0x00, 0x00, sizeof (read_sizes), /* transfer length */ 0x00, /* control byte */ }; size_t size = sizeof (read_sizes); SANE_Status status; status = sanei_scsi_cmd (fd, scsi_read, sizeof (scsi_read), &read_sizes, &size); if (status != SANE_STATUS_GOOD || size != sizeof (read_sizes)) { /* Command failed */ return SANE_STATUS_IO_ERROR; } else { *lines_available = get_size (read_sizes.lines_this_block, 2); *bpl = get_size (read_sizes.cur_line, 2); if (total_lines) *total_lines = get_size (read_sizes.total_lines, 2); } DBG (1, "get_read_sizes() : %d of %d, %d\n", *lines_available, total_lines ? *total_lines : -1, *bpl); return SANE_STATUS_GOOD; } static SANE_Status set_window (AgfaFocus_Scanner * s) /* This function sets and sends the window for scanning */ { double pixels_per_mm = (double) s->val[OPT_RESOLUTION].w / MM_PER_INCH; SANE_Bool auto_bright = s->val[OPT_AUTO_BRIGHTNESS].b; SANE_Bool auto_contr = s->val[OPT_AUTO_CONTRAST].b; /* ranges down 255 (dark) down to 1(bright) */ int brightness = auto_bright ? 0 : (SANE_UNFIX (s->val[OPT_BRIGHTNESS].w) * -1.27 + 128.5); /* ranges from 1 (little contrast) up to 255 (much contrast) */ int contrast = auto_contr ? 0 : (SANE_UNFIX (s->val[OPT_CONTRAST].w) * 1.27 + 128.5); int width; /* ranges from 40 (dark) down to 0 (bright) */ int bright_adjust = (SANE_UNFIX (s->val[OPT_BRIGHTNESS].w) * -20.0) / 100.0 + 20.0; /* ranges from 20 (little contrast) down to -20 = 235 (much contrast) */ int contr_adjust = (SANE_UNFIX (s->val[OPT_CONTRAST].w) * -20.0) / 100.0; /* Warning ! The following structur SEEMS to be a valid SCSI-2 SET_WINDOW command. But e.g. the limits for the window are only 2 Bytes instead of 4. The scanner was built at about 1990, so SCSI-2 wasn't available for development... */ struct { Byte cmd; Byte lun; Byte re1[4]; Byte tr_len[3]; Byte ctrl; Byte re2[6]; Byte wd_len[2]; struct { Byte wid; /* Window ID */ Byte autobit; /* Window creation */ Byte x_axis_res[2]; /* X resolution */ Byte y_axis_res[2]; /* X resolution */ Byte x_axis_ul[2]; /* X upper left */ Byte y_axis_ul[2]; /* Y upper left */ Byte wwidth[2]; /* Width */ Byte wlength[2]; /* Length */ Byte contrast; /* Contrast */ Byte dummy1; Byte intensity; /* Intensity */ Byte image_comp; /* Image composition (0, 2, 5) */ Byte bpp; /* Bits per pixel */ Byte tonecurve; /* Tone curve (0 - 8) */ Byte ht_pattern; /* Halftone pattern */ Byte paddingtype; /* Padding type */ Byte bitordering[2]; /* Bit ordering (0 = left to right) */ Byte comprtype; /* Compression type */ Byte comprarg; /* Compression argument */ Byte dummy2[6]; Byte edge; /* Sharpening (0 - 7) */ Byte dummy3; Byte bright_adjust; /* */ Byte contr_adjust; /* */ Byte imagewidthtruncation; /* */ Byte dummy4; Byte quality_type; /* 0 normal, 1 high, 255 low */ Byte red_att; Byte green_att; Byte blue_att; Byte dummy5[5]; Byte color_planes; Byte orig_type; Byte fixturetype; Byte exposure[2]; Byte defocus[2]; Byte dummy6[4]; Byte descreen_factor; Byte packing_word_length; Byte packing_number_of_pixels; Byte packing_color_mode; Byte strokenab; Byte rotatenab; Byte autostrokenab; Byte dummy7; } wd; } cmd; memset (&cmd, 0, sizeof (cmd)); cmd.cmd = 0x24; /* SET WINDOW PARAMETERS */ switch (s->hw->type) { case AGFAGRAY64: case AGFALINEART: case AGFAGRAY256: set_size (cmd.tr_len, 3, 36 + 8); set_size (cmd.wd_len, 2, 36); break; case AGFACOLOR: set_size (cmd.tr_len, 3, 65 + 8); set_size (cmd.wd_len, 2, 65); break; } /* Resolution. Original comment in German: Aufloesung */ set_size (cmd.wd.x_axis_res, 2, s->val[OPT_RESOLUTION].w); set_size (cmd.wd.y_axis_res, 2, s->val[OPT_RESOLUTION].w); /* Scan window position/size. Original comment in German: Fensterposition / Groesse */ set_size (cmd.wd.x_axis_ul, 2, SANE_UNFIX (s->val[OPT_TL_X].w) * pixels_per_mm + 0.5); set_size (cmd.wd.y_axis_ul, 2, SANE_UNFIX (s->val[OPT_TL_Y].w) * pixels_per_mm + 0.5); width = (SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) * pixels_per_mm) + 0.5; if (s->bpp == 1 && width % 8) width += 8 - width % 8; set_size (cmd.wd.wwidth, 2, width); set_size (cmd.wd.wlength, 2, SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) * pixels_per_mm + 0.5); cmd.wd.bpp = s->bpp; if (s->mode == COLOR18BIT || s->mode == COLOR24BIT) { cmd.wd.paddingtype = 3; cmd.wd.ht_pattern = 3; cmd.wd.red_att = s->r_att; cmd.wd.blue_att = s->g_att; cmd.wd.green_att = s->b_att; cmd.wd.color_planes = 0x0e; set_size (cmd.wd.exposure, 2, s->exposure); cmd.wd.packing_word_length = 1; cmd.wd.packing_number_of_pixels = 1; cmd.wd.packing_color_mode = 2; if (s->bpp == 6) cmd.wd.edge = s->edge; DBG (3, "Setting parameters: imc %d, bpp %d, res %d, exp %d, attenuation [%d, %d, %d], edge %d\n", s->image_composition, s->bpp, s->val[OPT_RESOLUTION].w, s->exposure, cmd.wd.red_att, cmd.wd.blue_att, cmd.wd.green_att, s->edge); } else { if (s->bpp == 1) cmd.wd.ht_pattern = s->halftone; else cmd.wd.ht_pattern = 3; cmd.wd.intensity = brightness; cmd.wd.contrast = contrast; cmd.wd.contr_adjust = contr_adjust; cmd.wd.bright_adjust = bright_adjust; cmd.wd.tonecurve = s->tonecurve; cmd.wd.paddingtype = 3; cmd.wd.edge = s->edge; if (s->lin_log) cmd.wd.dummy3 = 0x02; DBG (3, "Setting parameters: imc %d, bpp %d, res %d, bri %d, con %d, bad %d, cad %d, ht %d, edge %d\n", s->image_composition, s->bpp, s->val[OPT_RESOLUTION].w, brightness, contrast, bright_adjust, contr_adjust, s->halftone, s->edge); } cmd.wd.image_comp = s->image_composition; cmd.wd.quality_type = s->quality; cmd.wd.orig_type = s->original; return sanei_scsi_cmd (s->fd, &cmd, sizeof (cmd), 0, 0); } /* Tell scanner to scan more data. */ static SANE_Status request_more_data (AgfaFocus_Scanner * s) { SANE_Status status; int lines_available; int bytes_per_line; status = start_scan (s->fd, SANE_TRUE); if (status != SANE_STATUS_GOOD) return status; if (!s->hw->disconnect) wait_ready (s->fd); status = get_read_sizes (s->fd, &lines_available, &bytes_per_line, 0); if (!lines_available) return SANE_STATUS_INVAL; s->lines_available = lines_available; return SANE_STATUS_GOOD; } static SANE_Status upload_dither_matrix (AgfaFocus_Scanner * s, int rows, int cols, int *dither_matrix) { struct { Byte cmd; Byte lun; Byte data_type; Byte re1[3]; Byte tr_len[3]; Byte ctrl; struct { Byte nrrows[2]; Byte nrcols[2]; struct { Byte data[2]; } element[256]; } wd; } cmd; SANE_Status status; int i; memset (&cmd, 0, sizeof (cmd)); cmd.cmd = 0x2a; /* WRITE */ cmd.data_type = 0x81; /* upload dither matrix */ set_size (cmd.tr_len, 3, 4 + (2 * rows * cols)); set_size (cmd.wd.nrrows, 2, rows); set_size (cmd.wd.nrcols, 2, cols); for (i = 0; i < cols * rows; ++i) set_size (cmd.wd.element[i].data, 2, dither_matrix[i]); status = sanei_scsi_cmd (s->fd, &cmd, sizeof (cmd), 0, 0); if (status != SANE_STATUS_GOOD) /* Command failed */ return SANE_STATUS_IO_ERROR; DBG (1, "upload_dither_matrix(): uploaded dither matrix: %d, %d\n", rows, cols); return SANE_STATUS_GOOD; } #if 0 static SANE_Status upload_tonecurve (AgfaFocus_Scanner * s, int color_type, int input, int output, int dither_matrix[256]) { struct { Byte cmd; Byte lun; Byte re1[4]; Byte tr_len[3]; Byte ctrl; Byte re2[6]; Byte wd_len[2]; struct { Byte color_type[2]; Byte nrinput[2]; Byte nroutput[2]; struct { Byte data[2]; } outputval[256]; } wd; } cmd; SANE_Status status; int i, j; memset (&cmd, 0, sizeof (cmd)); cmd.cmd = 0x80; set_size (cmd.tr_len, 3, sizeof (cmd.wd)); set_size (cmd.wd.nrrows, 2, rows); set_size (cmd.wd.nrrows, 2, cols); for (i = 0; i < cols; ++i) for (j = 0; j < rows; ++j) set_size (cmd.wd.element[j + i * rows].data, 2, dither_matrix[j + i * rows]); status = sanei_scsi_cmd (s->fd, &cmd, sizeof (cmd), 0, 0); if (status != SANE_STATUS_GOOD) /* * Command failed * */ return SANE_STATUS_IO_ERROR; DBG (1, "upload_dither_matrix(): uploaded dither matrix\n"); return SANE_STATUS_GOOD; } #endif /* May only be called when there is at least one row of data to be read. Original comment in German: Darf nur aufgerufen werden, wenn wirklich noch Zeilen zu scannen/lesen sind ! */ static SANE_Status read_data (AgfaFocus_Scanner * s, SANE_Byte *buf, int lines, int bpl) { struct { Byte cmd; Byte lun; Byte re1[4]; Byte tr_len[3]; Byte ctrl; } cmd; SANE_Status status; size_t size; unsigned int i; memset (&cmd, 0, sizeof (cmd)); cmd.cmd = 0x28; /* READ */ set_size (cmd.tr_len, 3, lines); size = lines * bpl; status = sanei_scsi_cmd (s->fd, &cmd, sizeof (cmd), buf, &size); if (status != SANE_STATUS_GOOD) { DBG (1, "sanei_scsi_cmd() = %d\n", status); return SANE_STATUS_IO_ERROR; } if (size != ((unsigned int) lines * bpl)) { DBG (1, "sanei_scsi_cmd(): got %lu bytes, expected %d\n", (u_long) size, lines * bpl); return SANE_STATUS_INVAL; } DBG (1, "Got %lu bytes\n", (u_long) size); /* Reverse: */ if (s->bpp != 1) { if (s->bpp != 6) for (i = 0; i < size; i++) buf[i] = 255 - buf[i]; else for (i = 0; i < size; i++) buf[i] = 255 - ((buf[i] * 256.0f) / 64.0f); } s->lines_available -= lines; return SANE_STATUS_GOOD; } static SANE_Status attach (const char *devname, AgfaFocus_Device ** devp) { #define ATTACH_SCSI_INQ_LEN 55 const Byte scsi_inquiry[] = { 0x12, 0x00, 0x00, 0x00, ATTACH_SCSI_INQ_LEN, 0x00 }; Byte result[ATTACH_SCSI_INQ_LEN]; int fd; AgfaFocus_Device *dev; SANE_Status status; size_t size; int i; for (dev = agfafocus_devices; dev; dev = dev->next) if (strcmp (dev->sane.name, devname) == 0) { if (devp) *devp = dev; return SANE_STATUS_GOOD; } DBG (3, "attach: opening %s\n", devname); status = sanei_scsi_open (devname, &fd, sense_handler, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: open failed (%s)\n", sane_strstatus (status)); return SANE_STATUS_INVAL; } DBG (4, "attach: sending INQUIRY\n"); size = sizeof (result); status = sanei_scsi_cmd (fd, scsi_inquiry, sizeof (scsi_inquiry), result, &size); if (status != SANE_STATUS_GOOD || size != ATTACH_SCSI_INQ_LEN) { DBG (1, "attach: inquiry failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (fd); return status; } status = test_ready (fd); sanei_scsi_close (fd); if (status != SANE_STATUS_GOOD) return status; /* The structure send by the scanner after inquiry is not SCSI-2 compatible. The standard manufacturer/model fields are no ASCII strings, but ? At offset 36 my SIEMENS scanner identifies as an AGFA one ?! */ if (result[0] != 6 || strncmp ((char *)result + 36, "AGFA0", 5)) { DBG (1, "attach: device doesn't look like a Siemens 9036 scanner\n"); return SANE_STATUS_INVAL; } DBG (4, "Inquiry data:\n"); DBG (4, "-----------\n"); for (i = 5; i < 55; i += 10) DBG (4, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", result[i], result[i + 1], result[i + 2], result[i + 3], result[i + 4], result[i + 5], result[i + 6], result[i + 7], result[i + 8], result[i + 9]); dev = malloc (sizeof (*dev)); if (!dev) return SANE_STATUS_NO_MEM; memset (dev, 0, sizeof (*dev)); dev->sane.name = strdup (devname); if (!strncmp ((char *)result + 36, "AGFA01", 6)) { dev->sane.vendor = "AGFA"; dev->sane.model = "Focus GS Scanner (6 bit)"; dev->upload_user_defines = SANE_TRUE; dev->type = AGFAGRAY64; } else if (!strncmp ((char *)result + 36, "AGFA02", 6)) { dev->sane.vendor = "AGFA"; dev->sane.model = "Focus Lineart Scanner"; dev->upload_user_defines = SANE_FALSE; dev->type = AGFALINEART; } else if (!strncmp ((char *)result + 36, "AGFA03", 6)) { dev->sane.vendor = "AGFA"; dev->sane.model = "Focus II"; dev->upload_user_defines = SANE_TRUE; dev->type = AGFAGRAY256; } else if (!strncmp ((char *)result + 36, "AGFA04", 6)) { dev->sane.vendor = "AGFA"; dev->sane.model = "Focus Color"; dev->upload_user_defines = SANE_TRUE; dev->type = AGFACOLOR; } else { free (dev); DBG (1, "attach: device looks like an AGFA scanner, but wasn't recognised\n"); return SANE_STATUS_INVAL; } dev->sane.type = "flatbed scanner"; dev->transparent = result[45] & 0x80 ? SANE_TRUE : SANE_FALSE; dev->analoglog = result[46] & 0x80 ? SANE_TRUE : SANE_FALSE; dev->tos5 = result[46] & 0x05 ? SANE_TRUE : SANE_FALSE; dev->quality = result[47] & 0x40 ? SANE_TRUE : SANE_FALSE; dev->disconnect = result[47] & 0x80 ? SANE_TRUE : SANE_FALSE; DBG (4, "\n"); DBG (4, "scan modes:\n"); DBG (4, "-----------\n"); DBG (4, "three pass color mode: %s\n", dev->type >= AGFACOLOR ? "yes" : "no"); DBG (4, "8 bit gray mode: %s\n", dev->type >= AGFAGRAY64 ? "yes" : "no"); DBG (4, "uploadable matrices: %s\n", dev->upload_user_defines ? "yes" : "no"); DBG (4, "transparency: %s\n", dev->transparent ? "yes" : "no"); DBG (4, "disconnect: %s\n", dev->disconnect ? "yes" : "no"); DBG (4, "quality calibration: %s\n", dev->quality ? "yes" : "no"); dev->handle = 0; DBG (3, "attach: found AgfaFocus scanner model\n"); ++num_devices; dev->next = agfafocus_devices; agfafocus_devices = dev; if (devp) *devp = dev; return SANE_STATUS_GOOD; } static SANE_Status do_eof (AgfaFocus_Scanner *s) { if (s->pipe >= 0) { close (s->pipe); s->pipe = -1; } return SANE_STATUS_EOF; } static SANE_Status do_cancel (AgfaFocus_Scanner * s) { s->scanning = SANE_FALSE; s->pass = 0; do_eof (s); if (sanei_thread_is_valid (s->reader_pid)) { int exit_status; /* ensure child knows it's time to stop: */ sanei_thread_kill (s->reader_pid); sanei_thread_waitpid (s->reader_pid, &exit_status); sanei_thread_invalidate(s->reader_pid); } if (s->fd >= 0) { stop_scan (s->fd); release_unit (s->fd); sanei_scsi_close (s->fd); s->fd = -1; } return SANE_STATUS_CANCELLED; } static SANE_Status init_options (AgfaFocus_Scanner * s) { int i; /* Hardware Limitations: must be static ! */ static const SANE_Int dpi_list[] = {8, 100, 200, 300, 400, 500, 600, 700, 800}; static const SANE_Range percentage_range = { SANE_FIX(-100), /* minimum */ SANE_FIX(100), /* maximum */ SANE_FIX(1) /* quantization */ }; static const SANE_Range sharpen_range = {0, 7, 1}; static const SANE_Range exposure_range = {0, 100, 0}; static const SANE_Range attenuation_range = { SANE_FIX(0), /* minimum */ SANE_FIX(100), /* maximum */ SANE_FIX(1) /* quantization */ }; static const SANE_Range x_range = {0, SANE_FIX (8.27 * MM_PER_INCH), 0}; static const SANE_Range y_range = {0, SANE_FIX (12.72 * MM_PER_INCH), 0}; /* ------ */ memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = "Scan Mode"; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; switch (s->hw->type) { case AGFACOLOR: s->opt[OPT_MODE].size = max_string_size (focuscolor_mode_list); s->opt[OPT_MODE].constraint.string_list = focuscolor_mode_list; s->val[OPT_MODE].s = strdup (focuscolor_mode_list[0]); break; case AGFAGRAY256: s->opt[OPT_MODE].size = max_string_size (focusii_mode_list); s->opt[OPT_MODE].constraint.string_list = focusii_mode_list; s->val[OPT_MODE].s = strdup (focusii_mode_list[0]); break; default: s->opt[OPT_MODE].size = max_string_size (focus_mode_list); s->opt[OPT_MODE].constraint.string_list = focus_mode_list; s->val[OPT_MODE].s = strdup (focus_mode_list[0]); break; } s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_RESOLUTION].constraint.word_list = dpi_list; s->val[OPT_RESOLUTION].w = 100; s->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_SOURCE].type = SANE_TYPE_STRING; s->opt[OPT_SOURCE].unit = SANE_UNIT_NONE; if (!s->hw->transparent) s->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; else s->opt[OPT_SOURCE].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].constraint.string_list = source_list; s->opt[OPT_SOURCE].size = max_string_size (source_list); s->val[OPT_SOURCE].s = strdup (source_list[0]); /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &x_range; s->val[OPT_TL_X].w = 0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &y_range; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &x_range; s->val[OPT_BR_X].w = x_range.max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &y_range; s->val[OPT_BR_Y].w = y_range.max; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* exposure */ s->opt[OPT_EXPOSURE].name = "exposure"; s->opt[OPT_EXPOSURE].title = "Exposure"; s->opt[OPT_EXPOSURE].desc = "Analog exposure control."; s->opt[OPT_EXPOSURE].type = SANE_TYPE_INT; s->opt[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_EXPOSURE].unit = SANE_UNIT_PERCENT; s->opt[OPT_EXPOSURE].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_EXPOSURE].constraint.range = &exposure_range; s->val[OPT_EXPOSURE].w = 23; /* brightness automatic correct */ s->opt[OPT_AUTO_BRIGHTNESS].name = "adjust-bright"; s->opt[OPT_AUTO_BRIGHTNESS].title = "Automatic brightness correction"; s->opt[OPT_AUTO_BRIGHTNESS].desc = "Turns on automatic brightness correction of " "the acquired image. This makes the scanner do a two pass scan to analyse the " "brightness of the image before it's scanned."; s->opt[OPT_AUTO_BRIGHTNESS].type = SANE_TYPE_BOOL; s->val[OPT_AUTO_BRIGHTNESS].b = SANE_FALSE; /* contrast automatic correct */ s->opt[OPT_AUTO_CONTRAST].name = "adjust-contr"; s->opt[OPT_AUTO_CONTRAST].title = "Automatic contrast correction"; s->opt[OPT_AUTO_CONTRAST].desc = "Turns on automatic contrast correction of " "the acquired image. This makes the scanner do a two pass scan to analyse " "the contrast of the image to be scanned."; s->opt[OPT_AUTO_CONTRAST].type = SANE_TYPE_BOOL; s->val[OPT_AUTO_CONTRAST].b = SANE_FALSE; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = "Controls the brightness of the acquired image. " "When automatic brightness is enabled, this can be used to adjust the selected brightness."; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_FIXED; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_PERCENT; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &percentage_range; s->val[OPT_BRIGHTNESS].w = 0; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = "Controls the contrast of the acquired image. " "When automatic contrast is enabled, this can be used to adjust the selected contrast."; s->opt[OPT_CONTRAST].type = SANE_TYPE_FIXED; s->opt[OPT_CONTRAST].unit = SANE_UNIT_PERCENT; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &percentage_range; s->val[OPT_CONTRAST].w = 0; /* halftone patterns */ s->opt[OPT_HALFTONE_PATTERN].name = SANE_NAME_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].title = SANE_TITLE_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].desc = SANE_DESC_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].type = SANE_TYPE_STRING; s->opt[OPT_HALFTONE_PATTERN].size = 32; s->opt[OPT_HALFTONE_PATTERN].constraint_type = SANE_CONSTRAINT_STRING_LIST; if (s->hw->upload_user_defines) { s->opt[OPT_HALFTONE_PATTERN].constraint.string_list = halftone_upload_list; s->val[OPT_HALFTONE_PATTERN].s = strdup (halftone_upload_list[0]); } else { s->opt[OPT_HALFTONE_PATTERN].constraint.string_list = halftone_list; s->val[OPT_HALFTONE_PATTERN].s = strdup (halftone_list[0]); } /* red-attenuation */ s->opt[OPT_ATTENUATION_RED].name = "red-attenuation"; s->opt[OPT_ATTENUATION_RED].title = "Red attenuation"; s->opt[OPT_ATTENUATION_RED].desc = "Controls the red attenuation of the acquired image. " "Higher values mean less impact on scanned image."; s->opt[OPT_ATTENUATION_RED].type = SANE_TYPE_FIXED; s->opt[OPT_ATTENUATION_RED].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_RED].unit = SANE_UNIT_PERCENT; s->opt[OPT_ATTENUATION_RED].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_ATTENUATION_RED].constraint.range = &attenuation_range; s->val[OPT_ATTENUATION_RED].w = SANE_FIX (50.0); /* green-attenuation */ s->opt[OPT_ATTENUATION_GREEN].name = "green-attenuation"; s->opt[OPT_ATTENUATION_GREEN].title = "Green attenuation"; s->opt[OPT_ATTENUATION_GREEN].desc = "Controls the green attenuation of the acquired image. " "Higher values mean less impact on scanned image."; s->opt[OPT_ATTENUATION_GREEN].type = SANE_TYPE_FIXED; s->opt[OPT_ATTENUATION_GREEN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_GREEN].unit = SANE_UNIT_PERCENT; s->opt[OPT_ATTENUATION_GREEN].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_ATTENUATION_GREEN].constraint.range = &attenuation_range; s->val[OPT_ATTENUATION_GREEN].w = SANE_FIX (50.0); /* blue-attenuation */ s->opt[OPT_ATTENUATION_BLUE].name = "blue-attenuation"; s->opt[OPT_ATTENUATION_BLUE].title = "Blue attenuation"; s->opt[OPT_ATTENUATION_BLUE].desc = "Controls the blue attenuation of the acquired image. " "Higher values mean less impact on scanned image."; s->opt[OPT_ATTENUATION_BLUE].type = SANE_TYPE_FIXED; s->opt[OPT_ATTENUATION_BLUE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_BLUE].unit = SANE_UNIT_PERCENT; s->opt[OPT_ATTENUATION_BLUE].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_ATTENUATION_BLUE].constraint.range = &attenuation_range; s->val[OPT_ATTENUATION_BLUE].w = SANE_FIX (50.0); /* quality-calibration */ s->opt[OPT_QUALITY].name = SANE_NAME_QUALITY_CAL; s->opt[OPT_QUALITY].title = SANE_TITLE_QUALITY_CAL; s->opt[OPT_QUALITY].desc = "Controls the calibration that will be done in the " "scanner. Less calibration result in faster scanner times."; s->opt[OPT_QUALITY].type = SANE_TYPE_STRING; s->opt[OPT_QUALITY].size = 32; if (!s->hw->quality) s->opt[OPT_QUALITY].cap |= SANE_CAP_INACTIVE; else s->opt[OPT_QUALITY].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_QUALITY].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_QUALITY].constraint.string_list = quality_list; s->val[OPT_QUALITY].s = strdup (quality_list[1]); /* sharpening */ s->opt[OPT_SHARPEN].name = "sharpen"; s->opt[OPT_SHARPEN].title = "Sharpening"; s->opt[OPT_SHARPEN].desc = "Controls the sharpening that will be " "done by the video processor in the scanner."; s->opt[OPT_SHARPEN].type = SANE_TYPE_INT; s->opt[OPT_SHARPEN].unit = SANE_UNIT_NONE; s->opt[OPT_SHARPEN].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_SHARPEN].constraint.range = &sharpen_range; s->val[OPT_SHARPEN].w = 1; return SANE_STATUS_GOOD; } static SANE_Status attach_one (const char *dev) { attach (dev, 0); return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char dev_name[PATH_MAX]; size_t len; FILE *fp; authorize = authorize; /* silence gcc */ DBG_INIT (); sanei_thread_init (); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open ("agfafocus.conf"); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ attach ("/dev/scanner", 0); return SANE_STATUS_GOOD; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ sanei_config_attach_matching_devices (dev_name, attach_one); } fclose (fp); return SANE_STATUS_GOOD; } void sane_exit (void) { AgfaFocus_Device *dev, *next; for (dev = agfafocus_devices; dev; dev = next) { next = dev->next; if (dev->handle) sane_close (dev->handle); free (dev); } if (devlist) free (devlist); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { AgfaFocus_Device *dev; int i; local_only = local_only; /* silence gcc */ if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; for (dev = agfafocus_devices, i = 0; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { AgfaFocus_Device *dev; SANE_Status status; AgfaFocus_Scanner *s; if (devicename[0]) { status = attach (devicename, &dev); if (status != SANE_STATUS_GOOD) return status; } else { /* empty devicname -> use first device */ dev = agfafocus_devices; } if (!dev) return SANE_STATUS_INVAL; if (dev->handle) return SANE_STATUS_DEVICE_BUSY; s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->scanning = SANE_FALSE; s->fd = -1; s->hw = dev; s->hw->handle = s; init_options (s); *handle = s; return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { AgfaFocus_Scanner *s = handle; if (s->scanning) do_cancel (handle); s->hw->handle = 0; free (handle); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { AgfaFocus_Scanner *s = handle; if ((unsigned) option >= NUM_OPTIONS) return 0; return s->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { AgfaFocus_Scanner *s = handle; SANE_Status status; if (info) *info = 0; if (s->scanning) return SANE_STATUS_DEVICE_BUSY; if (option >= NUM_OPTIONS || !SANE_OPTION_IS_ACTIVE (s->opt[option].cap)) return SANE_STATUS_UNSUPPORTED; if (action == SANE_ACTION_GET_VALUE) { switch (option) { case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_SHARPEN: case OPT_EXPOSURE: case OPT_ATTENUATION_RED: case OPT_ATTENUATION_GREEN: case OPT_ATTENUATION_BLUE: *(SANE_Word *) val = s->val[option].w; break; case OPT_AUTO_BRIGHTNESS: case OPT_AUTO_CONTRAST: *(SANE_Bool *) val = s->val[option].b; break; case OPT_MODE: case OPT_HALFTONE_PATTERN: case OPT_QUALITY: case OPT_SOURCE: strcpy (val, s->val[option].s); return (SANE_STATUS_GOOD); default: return SANE_STATUS_UNSUPPORTED; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (s->opt[option].cap)) return SANE_STATUS_UNSUPPORTED; status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: if (info) *info |= SANE_INFO_RELOAD_PARAMS; // fall through case OPT_SHARPEN: case OPT_EXPOSURE: case OPT_ATTENUATION_RED: case OPT_ATTENUATION_GREEN: case OPT_ATTENUATION_BLUE: case OPT_BRIGHTNESS: case OPT_CONTRAST: s->val[option].w = *(SANE_Word *) val; break; case OPT_AUTO_BRIGHTNESS: case OPT_AUTO_CONTRAST: s->val[option].b = *(SANE_Bool *) val; break; case OPT_MODE: if (strcmp (s->val[option].s, (SANE_String) val)) { if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); if (strcmp (s->val[option].s, "Gray (6 bit)") == 0) s->mode = GRAY6BIT; else if (strcmp (s->val[option].s, "Gray (8 bit)") == 0) s->mode = GRAY8BIT; else if (strcmp (s->val[option].s, "Color (18 bit)") == 0) s->mode = COLOR18BIT; else if (strcmp (s->val[option].s, "Color (24 bit)") == 0) s->mode = COLOR24BIT; else s->mode = LINEART; switch (s->mode) { case LINEART: s->opt[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_SHARPEN].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_RED].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_GREEN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_BLUE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_AUTO_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_AUTO_CONTRAST].cap &= ~SANE_CAP_INACTIVE; break; case GRAY6BIT: s->opt[OPT_SHARPEN].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_RED].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_GREEN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_BLUE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_AUTO_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_AUTO_CONTRAST].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; break; case GRAY8BIT: s->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_AUTO_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_AUTO_CONTRAST].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_RED].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_GREEN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_BLUE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SHARPEN].cap |= SANE_CAP_INACTIVE; break; case COLOR18BIT: s->opt[OPT_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_RED].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_GREEN].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_BLUE].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_AUTO_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_AUTO_CONTRAST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SHARPEN].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; break; case COLOR24BIT: s->opt[OPT_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_RED].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_GREEN].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_ATTENUATION_BLUE].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_AUTO_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_AUTO_CONTRAST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SHARPEN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; break; } } break; case OPT_SOURCE: case OPT_QUALITY: case OPT_HALFTONE_PATTERN: if (info && strcmp (s->val[option].s, (SANE_String) val)) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); break; default: return SANE_STATUS_UNSUPPORTED; } } else { return SANE_STATUS_UNSUPPORTED; } return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { AgfaFocus_Scanner *s = handle; if (!s->scanning) { double width, height, dpi; const char *quality; const char *original; memset (&s->params, 0, sizeof (s->params)); width = SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w); height = SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w); dpi = s->val[OPT_RESOLUTION].w; /* make best-effort guess at what parameters will look like once scanning starts. */ if (dpi > 0.0 && width > 0.0 && height > 0.0) { double dots_per_mm = dpi / MM_PER_INCH; s->params.pixels_per_line = width * dots_per_mm + 0.5; s->params.lines = height * dots_per_mm + 0.5; } /* Should we specify calibration quality? */ if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_QUALITY].cap)) { DBG(3, " -------------- setting quality\n"); quality = s->val[OPT_QUALITY].s; if (strcmp (quality, "Low") == 0 ) s->quality = 255; else if (strcmp (quality, "High") == 0) s->quality = 1; else s->quality = 0; } else s->quality = 0; /* Should we select source type? */ if (SANE_OPTION_IS_ACTIVE (s->opt[OPT_SOURCE].cap)) { DBG(3, " -------------- setting source\n"); original = s->val[OPT_SOURCE].s; if (strcmp (original, "Transparency") == 0) s->original = 0; else s->original = 1; } else s->original = 0; s->exposure = ((s->val[OPT_EXPOSURE].w * (255.0f - 80.0f)) / 100.0f) + 80.0f; s->r_att = (SANE_UNFIX (s->val[OPT_ATTENUATION_RED].w) * 20.0f) / 100.0f; s->g_att = (SANE_UNFIX (s->val[OPT_ATTENUATION_GREEN].w) * 20.0f) / 100.0f; s->b_att = (SANE_UNFIX (s->val[OPT_ATTENUATION_BLUE].w) * 20.0f) / 100.0f; s->tonecurve = 0; switch (s->mode) { case LINEART: { const char *halftone; s->image_composition = 0; /* in 1 bpp mode, lines need to be 8 pixel length */ if (s->params.pixels_per_line % 8) s->params.pixels_per_line += 8 - (s->params.pixels_per_line % 8); s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line / 8; s->bpp = s->params.depth = 1; halftone = s->val[OPT_HALFTONE_PATTERN].s; if (strcmp (halftone, "1") == 0 ) s->halftone = 1; else if (strcmp (halftone, "Dispersed dot 4x4") == 0) s->halftone = 2; else if (strcmp (halftone, "Round (Clustered dot 4x4)") == 0) s->halftone = 3; else if (strcmp (halftone, "Diamond (Clustered dot 4x4)") == 0) s->halftone = 4; else if (strcmp (halftone, "User defined") == 0) s->halftone = 5; else s->halftone = 0; s->edge = s->val[OPT_SHARPEN].w; } break; case GRAY6BIT: s->image_composition = 2; s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->bpp = 6; s->params.depth = 8; s->edge = s->val[OPT_SHARPEN].w; break; case GRAY8BIT: s->image_composition = 2; s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->bpp = s->params.depth = 8; break; case COLOR18BIT: s->image_composition = 5; s->params.format = SANE_FRAME_RED; s->params.bytes_per_line = s->params.pixels_per_line; s->bpp = 6; s->params.depth = 8; s->edge = s->val[OPT_SHARPEN].w; break; case COLOR24BIT: s->image_composition = 5; s->params.format = SANE_FRAME_RED; s->params.bytes_per_line = s->params.pixels_per_line; s->bpp = s->params.depth = 8; break; } s->pass = 0; /*s->params.bytes_per_line = (s->params.pixels_per_line + (8 - s->params.depth)) / (8 / s->params.depth);*/ } else if (s->mode == COLOR18BIT || s->mode == COLOR24BIT) s->params.format = SANE_FRAME_RED + s->pass; s->params.last_frame = (s->params.format != SANE_FRAME_RED && s->params.format != SANE_FRAME_GREEN); if (params) *params = s->params; return SANE_STATUS_GOOD; } /* This function is executed as a child process. The reason this is executed as a subprocess is because some (most?) generic SCSI interfaces block a SCSI request until it has completed. With a subprocess, we can let it block waiting for the request to finish while the main process can go about to do more important things (such as recognizing when the user presses a cancel button). WARNING: Since this is executed as a subprocess, it's NOT possible to update any of the variables in the main process (in particular the scanner state cannot be updated). */ static int reader_process (void *scanner) { AgfaFocus_Scanner *s = (AgfaFocus_Scanner *) scanner; int fd = s->reader_pipe; SANE_Status status; SANE_Byte *data; int lines_read = 0; int lines_per_buffer; int bytes_per_line = 0, total_lines = 0; int i; sigset_t sigterm_set; sigset_t ignore_set; struct SIGACTION act; if (sanei_thread_is_forked()) close (s->pipe); sigfillset (&ignore_set); sigdelset (&ignore_set, SIGTERM); #if defined (__APPLE__) && defined (__MACH__) sigdelset (&ignore_set, SIGUSR2); #endif sigprocmask (SIG_SETMASK, &ignore_set, 0); memset (&act, 0, sizeof (act)); sigaction (SIGTERM, &act, 0); sigemptyset (&sigterm_set); sigaddset (&sigterm_set, SIGTERM); if (!s->hw->disconnect) wait_ready (s->fd); status = get_read_sizes (s->fd, &s->lines_available, &bytes_per_line, &total_lines); if (status != SANE_STATUS_GOOD) { DBG (1, "open: get_read_sizes() failed: %s\n", sane_strstatus (status)); do_cancel (s); close (fd); return 1; } if (!s->lines_available || !bytes_per_line || !total_lines || bytes_per_line < s->params.bytes_per_line) { DBG (1, "open: invalid sizes: %d, %d, %d\n", s->lines_available, bytes_per_line, total_lines); do_cancel (s); close (fd); return 1; } lines_per_buffer = sanei_scsi_max_request_size / bytes_per_line; if (!lines_per_buffer) { close (fd); return 2; /* resolution is too high */ } data = malloc (lines_per_buffer * bytes_per_line); if (!data) { DBG (1, "open malloc(%lu) failed.\n", (u_long) lines_per_buffer * bytes_per_line); do_cancel (s); close (fd); return 1; } while (lines_read < s->params.lines) { int lines = lines_per_buffer; if (s->lines_available == 0) { /* No lines in scanner? Scan some more */ status = request_more_data (s); if (status != SANE_STATUS_GOOD) { close (fd); return 1; } } /* We only request as many lines as there are already scanned */ if (lines > s->lines_available) lines = s->lines_available; DBG (1, "Requesting %d lines, in scanner: %d, total: %d\n", lines, s->lines_available, s->params.lines); status = read_data (s, data, lines, bytes_per_line); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_read: read_data() failed (%s)\n", sane_strstatus (status)); do_cancel (s); close (fd); return 1; } /* Sometimes the scanner will return more bytes per line than requested, so we copy only what we wanted. */ for (i = 0; i < lines; i++) if (write (fd, data + i * bytes_per_line, s->params.bytes_per_line) != s->params.bytes_per_line) { do_cancel (s); close (fd); return 1; } lines_read += lines; } close (fd); return 0; } SANE_Status sane_start (SANE_Handle handle) { AgfaFocus_Scanner *s = handle; SANE_Status status; int fds[2]; /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; /* don't initialise scanner if we're doing a three-pass scan */ if (s->pass == 0) { if (s->fd < 0) { status = sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "open: open of %s failed: %s\n", s->hw->sane.name, sane_strstatus (status)); s->fd = -1; return status; } } status = test_ready (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "open: test_ready() failed: %s\n", sane_strstatus (status)); sanei_scsi_close (s->fd); s->fd = -1; return status; } status = reserve_unit (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "open: reserve_unit() failed: %s\n", sane_strstatus (status)); sanei_scsi_close (s->fd); s->fd = -1; return status; } status = set_window (s); if (status != SANE_STATUS_GOOD) { DBG (1, "open: set_window() failed: %s\n", sane_strstatus (status)); release_unit (s->fd); sanei_scsi_close (s->fd); s->fd = -1; return status; } { int matrix[256] = { 2, 60, 16, 56, 3, 57, 13, 53, 34, 18, 48, 32, 35, 19, 45, 29, 10, 50, 6, 63, 11, 51, 7, 61, 42, 26, 38, 22, 43, 27, 39, 23, 4, 58, 14, 54, 1, 59, 15, 55, 36, 20, 46, 30, 33, 17, 47, 31, 12, 52, 8, 62, 9, 49, 5, 63, 44, 28, 40, 24, 41, 25, 37, 21 }; status = upload_dither_matrix (s, 8, 8, matrix); if (status != SANE_STATUS_GOOD) { DBG (1, "open: upload_dither_matrix() failed: %s\n", sane_strstatus (status)); release_unit (s->fd); sanei_scsi_close (s->fd); s->fd = -1; return status; } } s->scanning = SANE_TRUE; status = start_scan (s->fd, SANE_FALSE); if (status != SANE_STATUS_GOOD) { DBG (1, "open: start_scan() failed: %s\n", sane_strstatus (status)); do_cancel (s); return status; } } else { /* continue three-pass scan */ status = start_scan (s->fd, SANE_TRUE); if (status != SANE_STATUS_GOOD) { DBG (1, "open: start_scan() failed: %s\n", sane_strstatus (status)); do_cancel (s); return status; } } if (pipe (fds) < 0) return SANE_STATUS_IO_ERROR; s->pipe = fds[0]; s->reader_pipe = fds[1]; s->reader_pid = sanei_thread_begin (reader_process, (void *) s); if (sanei_thread_is_forked()) close (s->reader_pipe); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { AgfaFocus_Scanner *s = handle; ssize_t nread; *len = 0; nread = read (s->pipe, buf, max_len); DBG (3, "read %ld bytes\n", (long) nread); if (!s->scanning) return do_cancel (s); if (nread < 0) { if (errno == EAGAIN) { return SANE_STATUS_GOOD; } else { do_cancel (s); return SANE_STATUS_IO_ERROR; } } *len = nread; if (nread == 0) { s->pass++; return do_eof (s); } return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { AgfaFocus_Scanner *s = handle; if (sanei_thread_is_valid (s->reader_pid)) sanei_thread_kill (s->reader_pid); s->scanning = SANE_FALSE; } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { AgfaFocus_Scanner *s = handle; if (!s->scanning) return SANE_STATUS_INVAL; if (fcntl (s->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) return SANE_STATUS_IO_ERROR; return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { AgfaFocus_Scanner *s = handle; if (!s->scanning) return SANE_STATUS_INVAL; *fd = s->pipe; return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/v4l-frequencies.h0000666000000000000000000001070313615534521015756 00000000000000/* * Worldwide channel/frequency list * * Nathan Laredo (laredo@broked.net) * * Frequencies are given in kHz */ #define NTSC_AUDIO_CARRIER 4500 #define PAL_AUDIO_CARRIER_I 6000 #define PAL_AUDIO_CARRIER_BGHN 5500 #define PAL_AUDIO_CARRIER_MN 4500 #define PAL_AUDIO_CARRIER_D 6500 #define SEACAM_AUDIO_DKK1L 6500 #define SEACAM_AUDIO_BG 5500 /* NICAM 728 32-kHz, 14-bit digital stereo audio is transmitted in 1ms frames containing 8 bits frame sync, 5 bits control, 11 bits additional data, and 704 bits audio data. The bit rate is reduced by transmitting only 10 bits plus parity of each 14 bit sample, the largest sample in a frame determines which 10 bits are transmitted. The parity bits for audio samples also specify the scaling factor used for that channel during that frame. The companeded audio data is interleaved to reduce the influence of dropouts and the whole frame except for sync bits is scrambled for spectrum shaping. Data is modulated using QPSK, at below following subcarrier freqs */ #define NICAM728_PAL_BGH 5850 #define NICAM728_PAL_I 6552 /* COMPREHENSIVE LIST OF FORMAT BY COUNTRY (M) NTSC used in: Antigua, Aruba, Bahamas, Barbados, Belize, Bermuda, Bolivia, Burma, Canada, Chile, Colombia, Costa Rica, Cuba, Curacao, Dominican Republic, Ecuador, El Salvador, Guam Guatemala, Honduras, Jamaica, Japan, South Korea, Mexico, Montserrat, Myanmar, Nicaragua, Panama, Peru, Philippines, Puerto Rico, St Christopher and Nevis, Samoa, Suriname, Taiwan, Trinidad/Tobago, United States, Venezuela, Virgin Islands (B) PAL used in: Albania, Algeria, Australia, Austria, Bahrain, Bangladesh, Belgium, Bosnia-Herzegovinia, Brunei Darussalam, Cambodia, Cameroon, Croatia, Cyprus, Denmark, Egypt, Ethiopia, Equatorial Guinea, Finland, Germany, Ghana, Gibraltar, Greenland, Iceland, India, Indonesia, Israel, Italy, Jordan, Kenya, Kuwait, Liberia, Libya, Luxembourg, Malaysa, Maldives, Malta, Nepal, Netherlands, New Zeland, Nigeria, Norway, Oman, Pakistan, Papua New Guinea, Portugal, Qatar, Sao Tome and Principe, Saudi Arabia, Seychelles, Sierra Leone, Singapore, Slovenia, Somali, Spain, Sri Lanka, Sudan, Swaziland, Sweden, Switzeland, Syria, Thailand, Tunisia, Turkey, Uganda, United Arab Emirates, Yemen (N) PAL used in: (Combination N = 4.5MHz audio carrier, 3.58MHz burst) Argentina (Combination N), Paraguay, Uruguay (M) PAL (525/60, 3.57MHz burst) used in: Brazil (G) PAL used in: Albania, Algeria, Austria, Bahrain, Bosnia/Herzegovinia, Cambodia, Cameroon, Croatia, Cyprus, Denmark, Egypt, Ethiopia, Equatorial Guinea, Finland, Germany, Gibraltar, Greenland, Iceland, Israel, Italy, Jordan, Kenya, Kuwait, Liberia, Libya, Luxembourg, Malaysia, Monaco, Mozambique, Netherlands, New Zealand, Norway, Oman, Pakistan, Papa New Guinea, Portugal, Qatar, Romania, Sierra Leone, Singapore, Slovenia, Somalia, Spain, Sri Lanka, Sudan, Swaziland, Sweeden, Switzerland, Syria, Thailand, Tunisia, Turkey, United Arab Emirates, Yemen, Zambia, Zimbabwe (D) PAL used in: China, North Korea, Romania, Czech Republic (H) PAL used in: Belgium (I) PAL used in: Angola, Botswana, Gambia, Guinea-Bissau, Hong Kong, Ireland, Lesotho, Malawi, Nambia, Nigeria, South Africa, Tanzania, United Kingdom, Zanzibar (B) SECAM used in: Djibouti, Greece, Iran, Iraq, Lebanon, Mali, Mauritania, Mauritus, Morocco (D) SECAM used in: Afghanistan, Armenia, Azerbaijan, Belarus, Bulgaria, Estonia, Georgia, Hungary, Zazakhstan, Lithuania, Mongolia, Moldova, Poland, Russia, Slovak Republic, Ukraine, Vietnam (G) SECAM used in: Greecem Iran, Iraq, Mali, Mauritus, Morocco, Saudi Arabia (K) SECAM used in: Armenia, Azerbaijan, Bulgaria, Estonia, Georgia, Hungary, Kazakhstan, Lithuania, Madagascar, Moldova, Poland, Russia, Slovak Republic, Ukraine, Vietnam (K1) SECAM used in: Benin, Burkina Faso, Burundi, Chad, Cape Verde, Central African Republic, Comoros, Congo, Gabon, Madagascar, Niger, Rwanda, Senegal, Togo, Zaire (L) SECAM used in: France */ /* --------------------------------------------------------------------- */ struct CHANLIST { char *name; int freq; }; struct CHANLISTS { char *name; struct CHANLIST *list; int count; }; #define CHAN_COUNT(x) (sizeof(x)/sizeof(struct CHANLIST)) /* --------------------------------------------------------------------- */ extern struct CHANLISTS chanlists[]; extern struct STRTAB chanlist_names[]; extern int chantab; extern struct CHANLIST *chanlist; extern int chancount; sane-backends-1.0.29/backend/kodakaio.h0000666000000000000000000001143613615534521014530 00000000000000/* * kodakaio.c - SANE library for Kodak ESP Aio scanners. * * Copyright (C) 2011-2013 Paul Newall * * Based on the Magicolor sane backend: * Based on the epson2 sane backend: * Based on Kazuhiro Sasayama previous * work on epson.[ch] file from the SANE package. * Please see those files for additional copyrights. * Author: Paul Newall * * * 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. 29/12/12 added KodakAio_Scanner.ack 2/1/13 added KodakAio_Scanner.background[] */ #ifndef kodakaio_h #define kodakaio_h #undef BACKEND_NAME #define BACKEND_NAME kodakaio #define DEBUG_NOT_STATIC #include #ifdef HAVE_STDDEF_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef NEED_SYS_TYPES_H #include #endif #include #include "../include/sane/sane.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" /* Silence the compiler for unused arguments */ #define NOT_USED(x) ( (void)(x) ) #define KODAKAIO_CONFIG_FILE "kodakaio.conf" #define NUM_OF_HEX_ELEMENTS (16) /* number of hex numbers per line for data dump */ #define DEVICE_NAME_LEN (16) /* length of device name in extended status */ #define CAP_DEFAULT 0 /* Structure holding the device capabilities */ struct KodakaioCap { SANE_Word id; /* USB pid */ const char *cmds; /* may be used for different command sets in future */ const char *model; SANE_Int out_ep, in_ep; /* USB bulk out/in endpoints */ SANE_Int optical_res; /* optical resolution */ SANE_Range dpi_range; /* max/min resolutions */ SANE_Int *res_list; /* list of resolutions */ SANE_Int res_list_size; /* number of entries in this list */ SANE_Int maxDepth; /* max. color depth */ SANE_Word *depth_list; /* list of color depths */ /* SANE_Range brightness; brightness range */ SANE_Range fbf_x_range; /* flattbed x range */ SANE_Range fbf_y_range; /* flattbed y range */ SANE_Bool ADF; /* ADF is installed */ SANE_Bool adf_duplex; /* does the ADF handle duplex scanning */ SANE_Range adf_x_range; /* autom. document feeder x range */ SANE_Range adf_y_range; /* autom. document feeder y range */ }; /* Options:OPT_BRIGHTNESS, used to be after BIT_DEPTH */ enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_THRESHOLD, OPT_BIT_DEPTH, OPT_RESOLUTION, OPT_TRIALOPT, /* for debuggging */ OPT_PREVIEW, OPT_SOURCE, OPT_ADF_MODE, OPT_PADDING, /* Selects padding of adf pages to the specified length */ OPT_GEOMETRY_GROUP, OPT_TL_X, OPT_TL_Y, OPT_BR_X, OPT_BR_Y, NUM_OPTIONS }; typedef enum { /* hardware connection to the scanner */ SANE_KODAKAIO_NODEV, /* default, no HW specified yet */ SANE_KODAKAIO_USB, /* USB interface */ SANE_KODAKAIO_NET /* network interface */ } Kodakaio_Connection_Type; /* Structure holding the hardware description */ struct Kodak_Device { struct Kodak_Device *next; int missing; char *name; char *model; SANE_Device sane; SANE_Range *x_range; /* x range w/out extension */ SANE_Range *y_range; /* y range w/out extension */ Kodakaio_Connection_Type connection; struct KodakaioCap *cap; }; typedef struct Kodak_Device Kodak_Device; /* Structure holding an instance of a scanner (i.e. scanner has been opened) */ struct KodakAio_Scanner { struct KodakAio_Scanner *next; struct Kodak_Device *hw; int fd; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Parameters params; SANE_Bool ack; /* scanner has finished a page (happens early with adf and padding) */ SANE_Bool eof; /* backend has finished a page (after padding with adf) */ SANE_Byte *buf, *end, *ptr; SANE_Bool canceling; SANE_Bool scanning; /* scan in progress */ SANE_Bool adf_loaded; /* paper in adf */ SANE_Int background[3]; /* stores background RGB components for padding */ SANE_Int left, top; /* in optres units? */ SANE_Int width, height; /* in optres units? */ /* SANE_Int threshold; 0..255 for lineart*/ /* image block data */ SANE_Int data_len; SANE_Int block_len; SANE_Int last_len; /* to be phased out */ SANE_Int blocks; /* to be phased out */ SANE_Int counter; SANE_Int bytes_unread; /* to track when to stop */ /* Used to store how many bytes of the current pixel line we have already * read in previous read attempts. Since each line will be padded * to multiples of 512 bytes, this is needed to know which bytes * to ignore. NOT NEEDED FOR KODAKAIO */ SANE_Int bytes_read_in_line; SANE_Byte *line_buffer; /* How many bytes are scanned per line */ SANE_Int scan_bytes_per_line; }; typedef struct KodakAio_Scanner KodakAio_Scanner; struct mode_param { int flags; int colors; int depth; }; enum { MODE_COLOR, MODE_GRAY, MODE_LINEART }; #endif sane-backends-1.0.29/backend/kodakaio.c0000666000000000000000000033457313615534521014535 00000000000000/* * kodakaio.c - SANE library for Kodak ESP Aio scanners. * * Copyright (C) 2011-2017 Paul Newall * * Based on the Magicolor sane backend: * Based on the epson2 sane backend: * Based on Kazuhiro Sasayama previous * work on epson.[ch] file from the SANE package. * Please see those files for additional copyrights. * Author: Paul Newall * * 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. * Modified 30/12/14 to fix bug where network connection was broken after 30s of idle time. * The connection is now made in sane_start and ended in sane_cancel. * 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 */ /* Packages to add to a clean ubuntu install libavahi-common-dev libusb-dev libsnmp-dev convenient lines to paste export SANE_DEBUG_KODAKAIO=20 for ubuntu prior to 12.10 ./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 --without-api-spec 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 */ /* SANE-FLOW-DIAGRAM Kodakaio commands in [] brackets - sane_init() : initialize backend, attach scanners(devicename,0) . - sane_get_devices() : query list of scanner-devices . - sane_open() : open a particular scanner-device and attach_scanner(devicename,&dev) . . - sane_set_io_mode : set blocking-mode . . - sane_get_select_fd : get scanner-fd . . - sane_get_option_descriptor() : get option informations . . - sane_control_option() : change option values . . . . - sane_start() : start image aquisition [V,L,F,S,C,D,O,Z] first time or after cancel. [(F),E,G] every time . . - sane_get_parameters() : returns actual scan-parameters . . - sane_read() : read image-data (from pipe) . . - sane_cancel() : cancel operation, kill reader_process [(F), U] . - sane_close() : close opened scanner-device, do_cancel, free buffer and handle - sane_exit() : terminate use of backend, free devicename and device-struture */ /* FUNCTION-TREE sane_init sane_open device_detect k_dev_init open_scanner close_scanner sane_get_devices init_options (open_scanner - moved to sane_start 27/12/14 ) sane_control_option getvalue setvalue search_string_list change_source activateOption deactivateOption sane_start open_scanner k_init_parametersta k_lock_scanner k_hello k_set_scanning_parameters print_params k_start_scan cmd_start_scan print_status k_send kodakaio_txrxack sane_get_parameters print_params sane_read k_read cmd_read_data (reads one block) k_recv cmp_array sane_cancel cmd_cancel_scan close_scanner sane_close (close_scanner - moved to sane_cancel 27/12/14) sane_exit free_devices k_recv kodakaio_net_read dump_hex_buffer_dense k_send sanei_kodakaio_net_write_raw dump_hex_buffer_dense open_scanner sanei_kodakaio_net_open close_scanner k_scan_finish cmd_cancel_scan sanei_kodakaio_net_close or sanei_usb_close detect_usb kodakaio_getNumberOfUSBProductIds attach_one_config - (Passed to sanei_configure_attach) kodakaio_getNumberOfUSBProductIds kodak_network_discovery client_callback browse_callback resolve_callback ProcessAvahiDevice attach_one_net attach_one_net attach device_detect attach_one_usb - (passed to sanei_usb_find_devices) attach device_detect k_lock_scanner kodakaio_txrx k_send k_recv kodakaio_txrxack k_send k_recv cmd_set_color_curve kodakaio_expect_ack k_recv cmd_cancel_scan kodakaio_txrxack cmd_set_scanning_parameters kodakaio_txrxack device_detect k_dev_init */ #define KODAKAIO_VERSION 02 #define KODAKAIO_REVISION 7 #define KODAKAIO_BUILD 3 /* for usb (but also used for net though it's not required). */ #define MAX_BLOCK_SIZE 32768 #define SCANNER_READ_TIMEOUT 15 /* POLL_ITN_MS sets the individual poll timeout for network discovery */ #define POLL_ITN_MS 20 /* debugging levels: In terminal use: export SANE_DEBUG_KODAKAIO=40 to set the level to 40 or whatever level you want. Then you can scan with scanimage or simple-scan from terminal and see debug info use these defines to promote certain functions that you are interested in define low values to make detail of a section appear when DBG level is low define a high value eg 99 to get normal behaviour. */ #define DBG_READ 99 #define DBG_AUTO 99 /* for autodiscovery */ /* normal levels. This system is a plan rather than a reality * * 127 recv buffer * 125 send buffer * 35 fine-grained status and progress * 30 sane_read * 25 setvalue, getvalue, control_option * 20 low-level (I/O) functions * 15 mid-level functions * 10 high-level functions * 7 open/close/attach * 6 print_params * 5 basic functions * 3 status info and progress * 2 sane api * 1 errors & warnings */ #include "sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #if WITH_AVAHI /* used for auto detecting network printers */ #include #include #include #include #include #include #endif #include "../include/sane/saneopts.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_tcp.h" #include "../include/sane/sanei_udp.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_backend.h" #include "kodakaio.h" /* vendor and product ids that are allowed */ #define SANE_KODAKAIO_VENDOR_ID (0x040a) #define min(x,y) (((x)<(y))?(x):(y)) /* I think these timeouts (ms) are defaults, overridden by any timeouts in the kodakaio.conf file */ static int K_SNMP_Timeout = 3000; /* used for any auto detection method */ static int K_Scan_Data_Timeout = 10000; static int K_Request_Timeout = 5000; /* static int bitposn=0; was used to pack bits into bytes in lineart mode */ /* This file is used to store directly the raster returned by the scanner for debugging If RawScanPath has no length it will not be created */ FILE *RawScan = NULL; /* example: char RawScanPath[] = "TestRawScan.pgm"; */ char RawScanPath[] = ""; /* empty path means no raw scan file is made */ /* * Devices supported by this backend */ /* kodak command strings */ static unsigned char KodakEsp_V[] = {0x1b,'S','V',0,0,0,0,0}; /* version?? */ static unsigned char KodakEsp_v[] = {0x1b,'s','v',0,0,0,0,0}; /* reply to version?? */ static unsigned char KodakEsp_Lock[] = {0x1b,'S','L',0,0,0,0,0}; /* Locks scanner */ static unsigned char KodakEsp_UnLock[] = {0x1b,'S','U',0,0,0,0,0}; /* Unlocks scanner */ static unsigned char KodakEsp_Ack[] = {0x1b,'S','S',0,0,0,0,0}; /* Acknowledge for all commands */ /* the bytes after esc S S 0 may indicate status: S S 0 1 = docs in adf */ static unsigned char KodakEsp_F[] = {0x1b,'S','F',0,0,0,0,0}; /* Purpose not known? colour balance?*/ static unsigned char KodakEsp_Comp[] = {0x1b,'S','C',3,8,3,0,0}; /* 3,8,3,1,0 does compression. */ /* The compression method is unknown */ /* static unsigned char KodakEsp_E[] = {0x1b,'S','E',1,0,0,0,0}; NET Purpose not known */ /* the extra 1 below could be despeckle option? maybe only for Hero 9.1 but no errors with ESP5250 */ static unsigned char KodakEsp_E[] = {0x1b,'S','E',1,1,0,0,0}; static unsigned char KodakEsp_Go[] = {0x1b,'S','G',0,0,0,0,0}; /* Starts the scan */ /* Other commands are: D (resolution), O (top left), Z (bottom right), R, G, B (curves) */ /* What is the relationship between these and the ranges in cap? */ static SANE_Int kodakaio_resolution_list[] = {75, 150, 300, 600, 1200}; static SANE_Int kodakaio_depth_list[] = {1,8}; /* The first value is the number of following entries */ /* strings to try and match the model ';' separator static unsigned char SupportedMatchString[] = "KODAK ESP;KODAK HERO;KODAK OFFICE HERO;ADVENT WiFi AIO;"; */ static struct KodakaioCap kodakaio_cap[] = { /* usbid,commandtype, modelname, USBoutEP, USBinEP, opticalres, {dpi range}, pointer to res list, res list size max depth, pointer to depth list, flatbed x range, flatbed y range, adf present, adf duplex, adf x range, adf y range (y range should be set a little shorter than the paper being scanned) The following are not used but may be in future commandtype, max depth, pointer to depth list */ /* list of cap data the first scanner is the default */ /* KODAK AIO DEFAULT, */ { 0x9999, "esp", "KODAK AIO DEFAULT", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(100), 0}, {0, SANE_FIX(100), 0} /* ADF x/y ranges (TODO!) */ }, /* KODAK ESP 5100, */ { 0x4025, "esp", "KODAK ESP 5100 AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 5300, */ { 0x4026, "esp", "KODAK ESP 5300 AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 5500, */ { 0x4027, "esp", "KODAK ESP 5500 AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 5000, */ { 0x4028, "esp", "KODAK ESP 5000 Series AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 3300, */ { 0x4031, "esp", "KODAK ESP 3300 Series AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP5, */ { 0x4032, "esp", "KODAK ESP 5 AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP7, */ { 0x403E, "esp", "KODAK ESP 7 AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP9, */ { 0x403F, "esp", "KODAK ESP 9 AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP5210 or 5250, */ { 0x4041, "esp", "KODAK ESP 5200 Series AiO", -1, 0x82, /* USBoutEP, USBinEP (-1 means find one) */ 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP3200 , */ { 0x4043, "esp", "KODAK ESP 3200 Series AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP4100 , */ { 0x4053, "esp", "KODAK ESP Office 4100 Series AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP6100 , */ { 0x4054, "esp", "KODAK ESP Office 6100 Series AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_TRUE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP7200 , */ { 0x4056, "esp", "KODAK ESP 7200 Series AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP C110 , */ { 0x4057, "esp", "KODAK ESP C110 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP C115 , */ { 0x4058, "esp", "KODAK ESP C115 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP 2150 , */ { 0x4059, "esp", "KODAK ESP Office 2150 Series", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_TRUE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP C310 , */ { 0x405D, "esp", "KODAK ESP C310 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP C315 , */ { 0x405E, "esp", "KODAK ESP C315 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* ADVENT AW10, */ { 0x4060, "esp", "ADVENT WiFi AIO AW10", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, {from, to, 0} 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_TRUE, SANE_FALSE, /* ADF, duplex. */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK HERO 6.1, */ { 0x4062, "esp", "KODAK OFFICE HERO 6.1 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, {from, to, 0} 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_TRUE, SANE_FALSE, /* ADF, duplex. */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK HERO 7.1, */ { 0x4063, "esp", "KODAK HERO 7.1 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, {from, to, 0} 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_TRUE, /* ADF, duplex. */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK HERO 5.1, */ { 0x4064, "esp", "KODAK HERO 5.1 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, {from, to, 0} 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_TRUE, /* ADF, duplex.*/ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP9200 , */ { 0x4065, "esp", "KODAK ESP 9200 Series AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_TRUE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK ESP2170 , */ { 0x4066, "esp", "KODAK ESP Office 2170 Series", -1, 0x82, 1200, {75, 1200, 0}, kodakaio_resolution_list, 5, /* 1200 dpi optical, {from, to, 0} 5 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_TRUE, SANE_FALSE, /* ADF, duplex */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK HERO 9.1, */ { 0x4067, "esp", "KODAK HERO 9.1 AiO", -1, 0x82, 1200, {75, 1200, 0}, kodakaio_resolution_list, 5, /* 1200 dpi optical, {from, to, 0} 5 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_TRUE, SANE_FALSE, /* ADF, duplex. */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK HERO 4.1, */ { 0x4069, "esp", "KODAK HERO 4.1 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, {from, to, 0} 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_TRUE, SANE_FALSE, /* ADF, duplex.*/ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* KODAK HERO 3.1, */ { 0x406D, "esp", "KODAK HERO 3.1 AiO", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, {from, to, 0} 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_TRUE, /* ADF, duplex. */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ }, /* spare use for specified usbid */ { 0, "esp", "specified", -1, 0x82, 600, {75, 600, 0}, kodakaio_resolution_list, 4, /* 600 dpi max, {from, to, 0} 4 resolutions */ 8, kodakaio_depth_list, /* color depth max 8, list above */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(11.7 * MM_PER_INCH), 0}, /* FBF x/y ranges */ SANE_FALSE, SANE_TRUE, /* ADF, duplex. */ {0, SANE_FIX(8.5 * MM_PER_INCH), 0}, {0, SANE_FIX(14 * MM_PER_INCH), 0} /* 14 ADF x/y ranges */ } }; /**************************************************************************** * General configuration parameter definitions ****************************************************************************/ /* * Definition of the mode_param struct, that is used to * specify the valid parameters for the different scan modes. * * The depth variable gets updated when the bit depth is modified. */ /* could be affecting what data sane delivers */ static struct mode_param mode_params[] = { {0x03, 3, 24}, /* Color, 3 colors, 24 bit */ {0x02, 1, 8}, /* Grayscale, 1 color, 8 bit */ {0x00, 1, 1} /* Lineart, 1 color, 8 bit (was 8 bit) */ }; static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_COLOR, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_LINEART, NULL }; static const SANE_String_Const adf_mode_list[] = { SANE_I18N("Simplex"), SANE_I18N("Duplex"), NULL }; /* Define the different scan sources */ #define FBF_STR SANE_I18N("Flatbed") #define ADF_STR SANE_I18N("Automatic Document Feeder") /* * source list need one dummy entry (save device settings is crashing). * NOTE: no const - this list gets created while exploring the capabilities * of the scanner. Here space is reserved for 3 entries + NULL ? */ static SANE_String_Const source_list[] = { FBF_STR, NULL, NULL, NULL }; static const SANE_Range percent_range_fixed = {SANE_FIX(0.0), SANE_FIX(100.0), SANE_FIX(1.0)}; /*static const SANE_Range percent_range_int = {0, 100, 1};*/ /* prototypes */ 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 */ static size_t max_string_size(const SANE_String_Const strings[]) { /* returns the length of the longest string in an array of strings */ size_t size, max_size = 0; int i; for (i = 0; strings[i]; i++) { size = strlen(strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } static void print_params(const SANE_Parameters params, int level) { DBG(level, "formats: binary=?, grey=%d, colour=%d\n",SANE_FRAME_GRAY, SANE_FRAME_RGB ); DBG(level, "params.format = %d\n", params.format); DBG(level, "params.last_frame = %d\n", params.last_frame); DBG(level, "params.bytes_per_line = %d\n", params.bytes_per_line); DBG(level, "params.pixels_per_line = %d\n", params.pixels_per_line); DBG(level, "params.lines = %d\n", params.lines); DBG(level, "params.depth = %d\n", params.depth); } static void print_status(KodakAio_Scanner *s,int level) { DBG(level, "print_status with level %d\n", level); DBG(level, "s->bytes_unread = %d\n", s->bytes_unread); /* DBG(level, "params.last_frame = %d\n", params.last_frame); DBG(level, "params.bytes_per_line = %d\n", params.bytes_per_line); DBG(level, "params.pixels_per_line = %d\n", params.pixels_per_line); DBG(level, "params.lines = %d\n", params.lines); DBG(level, "params.depth = %d\n", params.depth); */ } /**************************************************************************** * Low-level Network communication functions ****************************************************************************/ static int kodakaio_net_read(struct KodakAio_Scanner *s, unsigned char *buf, size_t wanted, SANE_Status * status) /* there seems to be a condition where this returns no error and no data without detecting a timeout That is probably if the scanner disconnected the network connection */ { size_t size, read = 0; struct pollfd fds[1]; int pollreply; *status = SANE_STATUS_GOOD; /* poll for data-to-be-read (using K_Request_Timeout) */ fds[0].fd = s->fd; fds[0].events = POLLIN; fds[0].revents = 0; if ((pollreply = poll (fds, 1, K_Request_Timeout)) <= 0) { if (pollreply == 0) DBG(1, "net poll timeout\n"); else /* pollreply is -ve */ DBG(1, "net poll error\n"); *status = SANE_STATUS_IO_ERROR; return read; } else if((fds[0].revents & POLLIN) && !(fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))) { while (read < wanted) { DBG(50, "reading: read %lu, wanted %lu\n",read, wanted); size = sanei_tcp_read(s->fd, buf + read, wanted - read); if (size == 0) { DBG(1, "No data read. Scanner may have disconnected\n"); break; } read += size; } if (read == 0) *status = SANE_STATUS_IO_ERROR; 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; } else DBG(1, "Unknown problem with poll\n"); return read; } static int sanei_kodakaio_net_write_raw(struct KodakAio_Scanner *s, const unsigned char *buf, size_t buf_size, SANE_Status *status) { DBG(32, "net write:%x,%x,%x,%x,%x,%x,%x,%x\n",buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]); sanei_tcp_write(s->fd, buf, buf_size); /* TODO: Check whether sending failed... */ *status = SANE_STATUS_GOOD; return buf_size; } static SANE_Status sanei_kodakaio_net_open(struct KodakAio_Scanner *s) { struct timeval tv; tv.tv_sec = 5; tv.tv_usec = 0; DBG(5, "%s\n", __func__); setsockopt(s->fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); return SANE_STATUS_GOOD; } static SANE_Status sanei_kodakaio_net_close(struct KodakAio_Scanner *s) { NOT_USED(s); /* Does nothing - maybe should close the socket ? */ return SANE_STATUS_GOOD; } /**************************************************************************** * Low-level USB communication functions ****************************************************************************/ static int kodakaio_getNumberOfUSBProductIds (void) { return sizeof (kodakaio_cap) / sizeof (struct KodakaioCap); } /**************************************************************************** * low-level communication commands ****************************************************************************/ static void dump_hex_buffer_dense (int level, const unsigned char *buf, size_t buf_size) { size_t k; char msg[1024], fmt_buf[1024]; memset (&msg[0], 0x00, 1024); memset (&fmt_buf[0], 0x00, 1024); for (k = 0; k < min(buf_size, 80); k++) { if (k % 16 == 0) { if (k>0) { DBG (level, "%s\n", msg); memset (&msg[0], 0x00, 1024); } sprintf (fmt_buf, " 0x%04lx ", (unsigned long)k); strcat (msg, fmt_buf); } if (k % 8 == 0) { strcat (msg, " "); } sprintf (fmt_buf, " %02x" , buf[k]); strcat (msg, fmt_buf); } if (msg[0] != 0 ) { DBG (level, "%s\n", msg); } } /* changing params to char seems to cause a stack problem */ void kodakaio_com_str(unsigned char *buf, char *fmt_buf) { /* returns a printable string version of the first 8 bytes assuming they are a kodakaio command*/ if(buf[0] == 0x1b) { sprintf (fmt_buf, "esc %c %c %02x %02x %02x %02x %02x", buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); } else { sprintf (fmt_buf, "%02x %02x %02x %02x %02x %02x %02x %02x", buf[0],buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); } } static int k_send(KodakAio_Scanner * s, void *buf, size_t buf_size, SANE_Status * status) { char fmt_buf[25]; kodakaio_com_str(buf, fmt_buf); DBG(15, "%s: size = %lu :%s\n", __func__, (u_long) buf_size, fmt_buf); if (DBG_LEVEL >= 125) { const unsigned char *s = buf; DBG(125, "complete buffer:\n"); dump_hex_buffer_dense (125, s, buf_size); } if (s->hw->connection == SANE_KODAKAIO_NET) { return sanei_kodakaio_net_write_raw(s, buf, buf_size, status); } else if (s->hw->connection == SANE_KODAKAIO_USB) { size_t n; n = buf_size; *status = sanei_usb_write_bulk(s->fd, buf, &n); DBG(50, "USB: wrote %lu bytes, status: %s\n", (unsigned long)n, sane_strstatus(*status)); return n; } *status = SANE_STATUS_INVAL; return 0; } static ssize_t k_recv(KodakAio_Scanner * s, void *buf, ssize_t buf_size, SANE_Status * status) { /* requests and receives data this function makes the split between USB and NET this function called by a number of others In USB mode, this function will wait until data is available for a maximum of SCANNER_READ_TIMEOUT seconds. In NET mode the timeout is in kodakaio_net_read */ ssize_t n = 0; char fmt_buf[25]; time_t time_start; time_t time_now; struct timespec usb_delay, usb_rem; usb_delay.tv_sec = 0; usb_delay.tv_nsec = 300000000; /* 0.3 sec */ if (s->hw->connection == SANE_KODAKAIO_NET) { 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 %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)); } } else if (s->hw->connection == SANE_KODAKAIO_USB) { /* Start the clock for USB timeout */ time(&time_start); /* Loop until we have data */ while (n == 0) { n = buf_size; /* but what if the data is an exact number of blocks? */ DBG(min(16,DBG_READ), "[%ld] %s: usb req size = %ld ", (long) time_start, __func__, (long) n); *status = sanei_usb_read_bulk(s->fd, (SANE_Byte *) buf, (size_t *) & n); DBG(min(16,DBG_READ), "returned %ld\n", (long) n); if(*status != SANE_STATUS_GOOD) { DBG(min(16,DBG_READ), "sanei_usb_read_bulk gave %s\n", sane_strstatus(*status)); if (*status == SANE_STATUS_EOF) { /* If we have EOF status, wait for more data */ time(&time_now); if (difftime(time_now, time_start) < SCANNER_READ_TIMEOUT) { nanosleep(&usb_delay, &usb_rem); } else { /* Timeout */ return n; } } else { /* If we've encountered another type of error, return */ return n; } } } } if (n == 8) { kodakaio_com_str(buf, fmt_buf); DBG(min(14,DBG_READ), "%s: size = %ld, got %s\n", __func__, (long int)n, fmt_buf); } /* dump buffer if appropriate */ if (DBG_LEVEL >= 127 && n > 0) { const unsigned char* b=buf; dump_hex_buffer_dense (125, b, buf_size); } return n; } static SANE_Status kodakaio_expect_ack(KodakAio_Scanner *s, unsigned char *rxbuf) /* gets 8 byte reply, checks reply is an Ack and returns appropriate status */ { SANE_Status status; k_recv(s, rxbuf, 8, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: rx err, %s\n", __func__, sane_strstatus(status)); return status; } /* strncmp ignores diffent possible responses like escSS00000 and escSS02000 */ if (strncmp((char *)KodakEsp_Ack,(char *)rxbuf,4)!=0) { DBG (1, "No Ack received, Expected 0x%2x %2x %2x %2x... got 0x%2x %2x %2x %2x...\n", KodakEsp_Ack[0], KodakEsp_Ack[1], KodakEsp_Ack[2], KodakEsp_Ack[3],rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3]); return SANE_STATUS_IO_ERROR; } return status; } static SANE_Status kodakaio_txrx(KodakAio_Scanner *s, unsigned char *txbuf, unsigned char *rxbuf) /* Sends 8 byte data to scanner and returns reply and appropriate status. */ { SANE_Status status; ssize_t n = 0; k_send(s, txbuf, 8, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: tx err, %s\n", __func__, sane_strstatus(status)); return status; } n = k_recv(s, rxbuf, 8, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: %s gave rx err, %s\n", __func__, "txvalue", sane_strstatus(status)); return status; } if (n == 0) { DBG(1, "%s: try 1 k_recv returned 0 bytes with status %s\n", __func__, sane_strstatus(status)); n = k_recv(s, rxbuf, 8, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: %s gave rx err, %s\n", __func__, "txvalue", sane_strstatus(status)); return status; } if (n == 0) { DBG(1, "%s: try 2 k_recv returned 0 bytes with status %s\n", __func__, sane_strstatus(status)); return status; } } return status; } static SANE_Status kodakaio_txrxack(KodakAio_Scanner *s, unsigned char *txbuf, unsigned char *rxbuf) /* Sends 8 byte data to scanner, gets 8 byte reply, checks reply is an Ack and returns appropriate status */ { SANE_Status status; k_send(s, txbuf, 8, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: tx err, %s\n", __func__, sane_strstatus(status)); return status; } k_recv(s, rxbuf, 8, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: %s gave rx err, %s\n", __func__, "txvalue", sane_strstatus(status)); return status; } /* strncmp ignores different possible responses like escSS00000 and escSS02000 */ if (strncmp((char *)KodakEsp_Ack,(char *)rxbuf,3) == 0) { /* was 4 byte comp */ if (rxbuf[4] == 0x01 && s->adf_loaded == SANE_FALSE) { s->adf_loaded = SANE_TRUE; DBG(5, "%s: News - docs in ADF\n", __func__); } else if (rxbuf[4] != 0x01 && s->adf_loaded == SANE_TRUE) { s->adf_loaded = SANE_FALSE; DBG(5, "%s: News - ADF is empty\n", __func__); } } else { DBG (1, "No Ack received, Sent 0x%2x %2x %2x %2x... got 0x%2x %2x %2x %2x...\n", txbuf[0], txbuf[1], txbuf[2], txbuf[3],rxbuf[0], rxbuf[1], rxbuf[2], rxbuf[3]); return SANE_STATUS_IO_ERROR; } return status; } /* unused function static ssize_t kodakaio_rxflush(KodakAio_Scanner *s) Tries to get 64 byte reply and returns number of bytes read { SANE_Status status; unsigned char rxbuf[64]; ssize_t n = 0; n = k_recv(s, rxbuf, 64, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: %s gave rx err, %s\n", __func__, "status", sane_strstatus(status)); } DBG(5, "%s: flushed, %d bytes\n", __func__, (int)n); return n; } */ /* * high-level communication commands */ static SANE_Status k_hello (KodakAio_Scanner * s) { SANE_Status status; unsigned char reply[8]; char fmt_buf[25]; DBG(5, "%s\n", __func__); /* check that there is nothing already in the input buffer before starting kodakaio_rxflush(s); */ /* preset the reply, so I can see if it gets changed */ reply[0] = 0; reply[1] = 1; reply[2] = 2; reply[3] = 3; reply[4] = 4; reply[5] = 5; reply[6] = 6; reply[7] = 7; if((status = kodakaio_txrx(s, KodakEsp_V, reply))!= SANE_STATUS_GOOD) { DBG(1, "%s: KodakEsp_V failure, %s\n", __func__, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } if (strncmp((char *) reply, (char *) KodakEsp_v, 3)!=0) { kodakaio_com_str(reply, fmt_buf); DBG(1, "%s: KodakEsp_v err, got %s\n", __func__, fmt_buf); return SANE_STATUS_IO_ERROR; } DBG(5, "%s: OK %s\n", __func__, sane_strstatus(status)); return status; } /* Start scan command */ static SANE_Status cmd_start_scan (SANE_Handle handle, size_t expect_total) /* expect_total is the expected total no of bytes just for info -ve value not a problem? or is it for size_t? */ { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; SANE_Status status = SANE_STATUS_GOOD; unsigned char reply[8]; /*send the start command here */ print_status(s, 5); /*adf added 20/2/12, apparently an extra KodakEsp_F is sent when the adf is used */ if (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) == 0) { /* adf is in use */ if (! s->adf_loaded) return SANE_STATUS_CANCELLED; /* was SANE_STATUS_NO_DOCS; */ if (kodakaio_txrxack(s, KodakEsp_F, reply)!= SANE_STATUS_GOOD) { DBG(1, "%s: Did not get a good reply to KodakEsp_F\n", __func__); return SANE_STATUS_IO_ERROR; } } if (kodakaio_txrxack(s, KodakEsp_E, reply)!= SANE_STATUS_GOOD) { DBG(1, "%s: Did not get a good reply to KodakEsp_E\n", __func__); return SANE_STATUS_IO_ERROR; } 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) DBG(1, "%s: KodakEsp_Go command NOT successfully sent\n", __func__); else { DBG(30, "%s: KodakEsp_Go command successfully sent\n", __func__); s->scanning = SANE_TRUE; } return status; } static SANE_Status cmd_cancel_scan (SANE_Handle handle) { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; unsigned char reply[8]; /* adf added 20/2/12 should it be adf? or adf with paper in? */ if (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) == 0) { /* adf */ if (kodakaio_txrxack(s, KodakEsp_F, reply)!= SANE_STATUS_GOOD) { DBG(1, "%s: KodakEsp_F command failed\n", __func__); return SANE_STATUS_IO_ERROR; } if (kodakaio_txrxack(s, KodakEsp_UnLock, reply)!= SANE_STATUS_GOOD) { DBG(1, "%s: KodakEsp_UnLock command failed\n", __func__); return SANE_STATUS_IO_ERROR; } DBG(5, "%s unlocked the scanner with adf F U\n", __func__); } else { /* no adf */ if (kodakaio_txrxack(s, KodakEsp_UnLock, reply)!= SANE_STATUS_GOOD) { DBG(1, "%s: KodakEsp_UnLock command failed\n", __func__); return SANE_STATUS_IO_ERROR; } DBG(5, "%s unlocked the scanner U\n", __func__); } s->scanning = SANE_FALSE; return SANE_STATUS_GOOD; } static SANE_Status cmd_get_scanning_parameters(SANE_Handle handle, SANE_Frame *format, SANE_Int *depth, SANE_Int *data_pixels, SANE_Int *pixels_per_line, SANE_Int *lines) { /* data_pixels is per line. Old mc cmd read this stuff from the scanner. I don't think kodak can do that easily */ KodakAio_Scanner *s = (KodakAio_Scanner *) handle; SANE_Status status = SANE_STATUS_GOOD; NOT_USED (format); NOT_USED (depth); DBG(10, "%s\n", __func__); /* Calculate returned values */ *lines = s->params.lines; *pixels_per_line = s->params.pixels_per_line; *data_pixels = s->params.pixels_per_line; DBG (20, "%s: data_pixels = %u, lines = %u, " "pixels_per_line = %u)\n", __func__, *data_pixels, *lines, *pixels_per_line); return status; } /* Set color curve command, low level, sends commands to the scanner*/ static SANE_Status cmd_set_color_curve(SANE_Handle handle, unsigned char col) { /* sends the color curve data for one color*/ KodakAio_Scanner *s = (KodakAio_Scanner *) handle; SANE_Status status = SANE_STATUS_GOOD; unsigned char tx_col[8]; unsigned char rx[8]; unsigned char tx_curve[256]; int i; /* 7/9/14 was unsigned char and that stopped the loop that made the linear curve from going to 255 */ DBG(32, "%s: start\n", __func__); tx_col[0]=0x1b; tx_col[1]='S'; tx_col[2]='K'; tx_col[3]=col; tx_col[4]=0; tx_col[5]=0; tx_col[6]=0; tx_col[7]=0; /* linear curve now but could send tailor made curves in future */ for(i=0;i<=255;++i) tx_curve[i]=i; /* 7/9/14 was i<255 the missing elements caused speckles */ k_send(s, tx_col, 8, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: tx err, %s\n", __func__, "curve command"); return status; } k_send(s, tx_curve, 256, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: tx err, %s\n", __func__, "curve data"); return status; } if (kodakaio_expect_ack(s, rx) != SANE_STATUS_GOOD) return SANE_STATUS_IO_ERROR; DBG(10, "%s: sent curve OK, \n", __func__); return status; } /* Set scanning parameters command, low level, sends commands to the scanner*/ static SANE_Status cmd_set_scanning_parameters(SANE_Handle handle, int resolution, int tl_x, int tl_y, int width, int height, unsigned char source) /* NB. here int tl_x, int tl_y, int width, int height are in DPI units, not optres units! */ /* sends params to scanner, but should we store them too? */ { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; SANE_Status status = SANE_STATUS_GOOD; unsigned char tx_S[8]; unsigned char tx_dpi[8]; unsigned char tx_topleft[8]; unsigned char tx_widthheight[8]; unsigned char bufread[8]; int i; /*don't know the purpose of F yet. windows USB repeated 4 x why? does it affect the colour balance?*/ DBG(8, "%s\n", __func__); for(i=0;i<4;++i) { kodakaio_txrxack(s, KodakEsp_F, bufread); sleep(1); } /* kodakaio_txrxack(s, KodakEsp_F, bufread); for net, just once */ /* Source? bed /ADF */ tx_S[0]=0x1b; tx_S[1]='S'; tx_S[2]='S'; tx_S[3]=source; tx_S[4]=0; tx_S[5]=0; tx_S[6]=0; tx_S[7]=0; kodakaio_txrxack(s, tx_S, bufread); /* Compression */ kodakaio_txrxack(s, KodakEsp_Comp, bufread); /* DPI resolution */ tx_dpi[0]=0x1b; tx_dpi[1]='S'; tx_dpi[2]='D'; tx_dpi[3]=resolution & 0xff; tx_dpi[4]=(resolution >> 8) & 0xff; tx_dpi[5]=resolution & 0xff; tx_dpi[6]=(resolution >> 8) & 0xff; tx_dpi[7]=0; kodakaio_txrxack(s, tx_dpi, bufread); /* colour curves don't seem to be sent for usb preview but it seems to do no harm to send them */ cmd_set_color_curve(s, 'R'); cmd_set_color_curve(s, 'G'); cmd_set_color_curve(s, 'B'); /* Origin top left s->tl_x and s->tl_y are in optres units this command needs actual DPI units*/ DBG(20, "%s: left (DPI)=%d, top (DPI)=%d\n", __func__, tl_x , tl_y); tx_topleft[0]=0x1b; tx_topleft[1]='S'; tx_topleft[2]='O'; tx_topleft[3]=(tl_x) & 0xff; tx_topleft[4]=((tl_x) >> 8) & 0xff; tx_topleft[5]=(tl_y) & 0xff; tx_topleft[6]=((tl_y) >> 8) & 0xff; tx_topleft[7]=0; kodakaio_txrxack(s, tx_topleft, bufread); /* Z width height note the s->width and s->height are in optres units this command needs actual DPI units*/ tx_widthheight[0]=0x1b; tx_widthheight[1]='S'; tx_widthheight[2]='Z'; tx_widthheight[3]=(width) & 0xff; tx_widthheight[4]=((width) >> 8) & 0xff; tx_widthheight[5]=(height) & 0xff; tx_widthheight[6]=((height) >> 8) & 0xff; tx_widthheight[7]=0; kodakaio_txrxack(s, tx_widthheight, bufread); if (status != SANE_STATUS_GOOD) DBG(1, "%s: Data NOT successfully sent\n", __func__); else DBG(20, "%s: Data successfully sent\n", __func__); return status; } int cmparray (unsigned char *array1, unsigned char *array2, size_t len) { /* compares len bytes of the arrays returns 0 if they match returns the first missmatch position if they don't match */ unsigned int i; for(i=0; iack and do padding if the padding option is selected if no padding option return EOF */ KodakAio_Scanner *s = (KodakAio_Scanner *) handle; SANE_Status status; int oldtimeout = K_Request_Timeout; size_t bytecount; unsigned char *Last8; /* will point to the last 8 chars in buf */ int i, line, lines; if (s->ack && s->val[OPT_PADDING].w) { /* do padding of whole block*/ /* memset(buf, 0x80, *len); need to work out the background colour for this */ lines = *len / s->params.bytes_per_line; for (line=0; line < lines; ++line) { for (i=0; i< s->params.pixels_per_line; ++i) { buf[line * s->params.bytes_per_line + i] = s->background[0]; /*red */ buf[line * s->params.bytes_per_line + s->params.pixels_per_line + i] = s->background[1]; /*green */ buf[line * s->params.bytes_per_line + 2 * s->params.pixels_per_line + i] = s->background[2]; /*blue */ } } s->bytes_unread -= *len; if (s->bytes_unread < 0) s->bytes_unread = 0; return SANE_STATUS_GOOD; } if (s->ack && !s->val[OPT_PADDING].w) { s->bytes_unread = 0; s->eof = SANE_TRUE; return SANE_STATUS_EOF; } /* Temporarily set the poll timeout long instead of short, * because a color scan needs >5 seconds to initialize. Is this needed for kodak? maybe */ K_Request_Timeout = K_Scan_Data_Timeout; sanei_usb_set_timeout (K_Scan_Data_Timeout); bytecount = k_recv(s, buf, *len, &status); K_Request_Timeout = oldtimeout; sanei_usb_set_timeout (oldtimeout); /* We may need to do some special thing with the block request size to cope with usb blocks of any length in order to keep the ack bytes, when using adf, at the end of one block ie not split between blocks. But it seems that the scanner takes care of that, and gives you the ack as a separate 8 byte block */ if (bytecount >= 8) { /* it may be the last block from the scanner so look for Ack response in last 8 bytes */ Last8 = buf + bytecount - 8; /* 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 %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 %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 %lu bytes of %lu\n", __func__, (unsigned long) bytecount, (unsigned long) *len); return SANE_STATUS_IO_ERROR; } 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? */ s->background[0] = 0; s->background[1] = 0; s->background[2] = 0; for (line=0; line < lines; ++line) { for (i=0; i< s->params.pixels_per_line; ++i) { s->background[0] += buf[line * s->params.bytes_per_line + i]; /*red */ s->background[1] += buf[line * s->params.bytes_per_line + s->params.pixels_per_line + i]; /*green */ s->background[2] += buf[line * s->params.bytes_per_line + 2 * s->params.pixels_per_line + i]; /*blue */ } } s->background[0] = s->background[0] / (lines * s->params.pixels_per_line); s->background[1] = s->background[1] / (lines * s->params.pixels_per_line); s->background[2] = s->background[2] / (lines * s->params.pixels_per_line); } if (status == SANE_STATUS_GOOD) if (s->bytes_unread <= 0) DBG(min(2,DBG_READ), "%s: Page fully read %d blocks, %ld bytes unread\n", __func__, s->counter, (long) s->bytes_unread); else DBG(min(20,DBG_READ), "%s: Image data successfully read %ld bytes, %ld bytes unread\n", __func__, (long) bytecount, (long) s->bytes_unread); else if (s->ack) /* was (status == SANE_STATUS_EOF) */ DBG(min(2,DBG_READ), "%s: scanner data read ended %d blocks %ld bytes, %ld bytes unread\n", __func__, s->counter, (long) bytecount, (long) s->bytes_unread); else DBG(min(1,DBG_READ), "%s: Image data read stopped with %s after %d blocks %ld bytes, %ld bytes unread\n", __func__, sane_strstatus(status), s->counter, (long) bytecount, (long) s->bytes_unread); return status; } /**************************************************************************** * kodakaio backend high-level operations ****************************************************************************/ static void k_dev_init(Kodak_Device *dev, const char *devname, int conntype) { DBG(5, "%s for %s\n", __func__,devname); dev->name = NULL; dev->model = NULL; dev->connection = conntype; dev->sane.name = devname; dev->sane.model = NULL; dev->sane.type = "flatbed scanner"; dev->sane.vendor = "Kodak"; dev->cap = &kodakaio_cap[CAP_DEFAULT]; } static SANE_Status k_set_model(KodakAio_Scanner * s, const char *model, size_t len) { unsigned char *buf; unsigned char *p; struct Kodak_Device *dev = s->hw; if (len<1) return SANE_STATUS_INVAL; /* to handle missing model */ buf = malloc(len + 1); if (buf == NULL) return SANE_STATUS_NO_MEM; memcpy(buf, model, len); buf[len] = '\0'; p = &buf[len - 1]; while (*p == ' ') { *p = '\0'; p--; } if (dev->model) free(dev->model); dev->model = strndup((const char *) buf, len); dev->sane.model = dev->model; DBG(10, "%s: model is '%s'\n", __func__, dev->model); free(buf); return SANE_STATUS_GOOD; } static void k_set_device (SANE_Handle handle, SANE_Word device) { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; Kodak_Device *dev = s->hw; int n; DBG(10, "%s: 0x%x\n", __func__, device); for (n = 0; n < NELEMS (kodakaio_cap); n++) { if (kodakaio_cap[n].id == device) break; } if (n < NELEMS(kodakaio_cap)) { dev->cap = &kodakaio_cap[n]; } else { dev->cap = &kodakaio_cap[CAP_DEFAULT]; DBG(1, " unknown device 0x%x, using default %s\n", device, dev->cap->model); } k_set_model (s, dev->cap->model, strlen (dev->cap->model)); } static SANE_Status k_discover_capabilities(KodakAio_Scanner *s) { SANE_Status status = SANE_STATUS_GOOD; Kodak_Device *dev = s->hw; SANE_String_Const *source_list_add = source_list; DBG(10, "%s\n", __func__); /* always add flatbed */ *source_list_add++ = FBF_STR; /* TODO: How can I check for existence of an ADF??? */ if (dev->cap->ADF == SANE_TRUE) { *source_list_add++ = ADF_STR; DBG(10, "%s: added adf to list\n", __func__); } /* TODO: Is there any capability that we can extract from the * device by some scanner command? So far, it looks like * the device does not support any reporting. */ dev->x_range = &dev->cap->fbf_x_range; dev->y_range = &dev->cap->fbf_y_range; DBG(10, " x-range: %f %f\n", SANE_UNFIX(dev->x_range->min), SANE_UNFIX(dev->x_range->max)); DBG(10, " y-range: %f %f\n", SANE_UNFIX(dev->y_range->min), SANE_UNFIX(dev->y_range->max)); DBG(5, "End of %s, status:%s\n", __func__, sane_strstatus(status)); *source_list_add = NULL; /* add end marker to source list */ return status; } static SANE_Status k_setup_block_mode (KodakAio_Scanner *s) { /* works for USB and for net changing to make block size = a number of complete lines 28/12/12 */ s->block_len = MAX_BLOCK_SIZE / s->scan_bytes_per_line * s->scan_bytes_per_line; s->bytes_unread = s->data_len; s->counter = 0; s->bytes_read_in_line = 0; if (s->line_buffer) free(s->line_buffer); s->line_buffer = malloc(s->scan_bytes_per_line); if (s->line_buffer == NULL) { DBG(1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } DBG (10, " %s: Setup block mode - scan_bytes_per_line=%d, pixels_per_line=%d, depth=%d, data_len=%d, block_len=%d, blocks=%d, last_len=%d\n", __func__, s->scan_bytes_per_line, s->params.pixels_per_line, s->params.depth, s->data_len, s->block_len, s->blocks, s->last_len); return SANE_STATUS_GOOD; } /* Call the commands to set scanning parameters In the Kodak Aio the parameters are: (x1b,"S","F",0,0,0,0,0) (x1b,"S","S",1,0,0,0,0) #It looks like the 4th param byte of the C command is compression 1=compress, 0=no compression #1st (or 3rd) param could be channels, 2nd could be bits per channel (x1b,"S","C",3,8,3,0,0) #3,8,3,1,0) was what the kodak software used with compression (x1b,"S","D",LowByte(Res),HighByte(Res),LowByte(Res),HighByte(Res),0) #resolution in DPI SendColour(tcpCliSock,"R") SendColour(tcpCliSock,"G") SendColour(tcpCliSock,"B") (x1b,"S","O",LowByte(x0*Res),HighByte(x0*Res),LowByte(y0*Res),HighByte(y0*Res),0) #top left in pixels (x1b,"S","Z",LowByte(x1*Res),HighByte(x1*Res),LowByte(y1*Res),HighByte(y1*Res),0) #bot right in pixels (x1b,"S","E",1,0,0,0,0) */ static SANE_Status k_lock_scanner (KodakAio_Scanner * s) { SANE_Status status; unsigned char reply[8]; status = k_hello(s); if(status != SANE_STATUS_GOOD) { DBG(1, "%s k_hello failed with %s\n", __func__, sane_strstatus(status)); return status; } if (kodakaio_txrxack(s, KodakEsp_Lock, reply)!= SANE_STATUS_GOOD) { DBG(1, "%s Could not lock scanner\n", __func__); return SANE_STATUS_IO_ERROR; } if (s->adf_loaded) DBG(5, "%s scanner locked, with docs in adf\n", __func__); else DBG(5, "%s scanner locked, with no docs in adf\n", __func__); return SANE_STATUS_GOOD; } static SANE_Status k_set_scanning_parameters(KodakAio_Scanner * s) { SANE_Status status; unsigned char rs, source; SANE_Int scan_pixels_per_line = 0; int dpi, optres; dpi = s->val[OPT_RESOLUTION].w; optres = s->hw->cap->optical_res; /* Find the resolution in the res list and assign the index (rs) */ for (rs=0; rs < s->hw->cap->res_list_size; rs++ ) { if ( dpi == s->hw->cap->res_list[rs] ) break; } /* ADF used? */ if (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) == 0) { source = 0x00; } else { source = 0x01; } /* TODO: Any way to set PREVIEW??? */ /* Remaining bytes unused */ status = cmd_set_scanning_parameters(s, dpi, s->left * dpi / optres, s->top * dpi / optres, /* top/left start (dpi units)*/ s->params.pixels_per_line, s->params.lines, /* extent was s->width, s->height*/ source); /* source */ if (status != SANE_STATUS_GOOD) DBG (1, "%s: Command cmd_set_scanning_parameters failed, %s\n", __func__, sane_strstatus(status)); /* Now query the scanner for the current image parameters */ status = cmd_get_scanning_parameters (s, &s->params.format, &s->params.depth, &scan_pixels_per_line, &s->params.pixels_per_line, &s->params.lines); if (status != SANE_STATUS_GOOD) { DBG (1, "%s: Command cmd_get_scanning_parameters failed, %s\n", __func__, sane_strstatus(status)); return status; } /* Calculate how many bytes are really used per line */ s->params.bytes_per_line = ceil (s->params.pixels_per_line * s->params.depth / 8.0); if (s->val[OPT_MODE].w == MODE_COLOR) s->params.bytes_per_line *= 3; /* Calculate how many bytes per line will be returned by the scanner. magicolor needed this because it uses padding so scan bytes per line != image bytes per line. * The values needed for this are returned by get_scanning_parameters */ s->scan_bytes_per_line = 3 * ceil (scan_pixels_per_line); /* we always scan in colour 8 bit */ s->data_len = s->scan_bytes_per_line * floor (s->height * dpi / optres + 0.5); /* NB this is the length for a full scan */ DBG (5, "Check: scan_bytes_per_line = %d s->params.bytes_per_line = %d \n", s->scan_bytes_per_line, s->params.bytes_per_line); /* k_setup_block_mode at the start of each page for adf to work */ status = k_setup_block_mode (s); if (status != SANE_STATUS_GOOD) DBG (1, "%s: Command k_setup_block_mode failed, %s\n", __func__, sane_strstatus(status)); DBG (18, "%s: bytes_read_in_line: %d\n", __func__, s->bytes_read_in_line); return status; } static SANE_Status k_check_adf(KodakAio_Scanner * s) { /* 20/2/12 detect paper in the adf? acknowledge esc S S 00 01.. ?*/ if (! s->adf_loaded) { DBG(5, "%s: NO DOCS\n", __func__); return SANE_STATUS_NO_DOCS; } else { /* TODO: Check for jam in ADF */ DBG(5, "%s: DOCS IN ADF\n", __func__); return SANE_STATUS_GOOD; } } static SANE_Status k_scan_finish(KodakAio_Scanner * s) { SANE_Status status = SANE_STATUS_GOOD; DBG(10, "%s called\n", __func__); /* If we have not yet read all data, cancel the scan */ if (s->buf && !s->eof) status = cmd_cancel_scan (s); if (s->line_buffer) free (s->line_buffer); s->line_buffer = NULL; free(s->buf); s->buf = s->end = s->ptr = NULL; return status; } static void k_copy_image_data(KodakAio_Scanner * s, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) /* copies the read data from s->line_buffer to the position in data pointer to by s->ptr uncompressed data is RRRR...GGGG...BBBB per line */ { SANE_Int bytes_available; SANE_Int threshold; DBG (min(18,DBG_READ), "%s: bytes_read in line: %d\n", __func__, s->bytes_read_in_line); *length = 0; threshold = 255 - (int) (SANE_UNFIX(s->val[OPT_THRESHOLD].w) * 255.0 / 100.0 + 0.5); /* 255 - for the grey scale version */ DBG (20, "%s: threshold: %d\n", __func__, threshold); while ((max_length >= s->params.bytes_per_line) && (s->ptr < s->end)) { SANE_Int bytes_to_copy = s->scan_bytes_per_line - s->bytes_read_in_line; /* First, fill the line buffer for the current line: */ bytes_available = (s->end - s->ptr); /* Don't copy more than we have buffer and available */ if (bytes_to_copy > bytes_available) bytes_to_copy = bytes_available; if (bytes_to_copy > 0) { memcpy (s->line_buffer + s->bytes_read_in_line, s->ptr, bytes_to_copy); s->ptr += bytes_to_copy; s->bytes_read_in_line += bytes_to_copy; } /* We have filled as much as possible of the current line * with data from the scanner. If we have a complete line, * copy it over. line points to the current byte in the input s->line_buffer data points to the output buffer*/ if ((s->bytes_read_in_line >= s->scan_bytes_per_line) && (s->params.bytes_per_line <= max_length)) { SANE_Int i; SANE_Byte *line = s->line_buffer; *length += s->params.bytes_per_line; for (i=0; i< s->params.pixels_per_line; ++i) { /* different behaviour for each mode */ if (s->val[OPT_MODE].w == MODE_COLOR){ /*interlace was subtracting from 255 until 6/9/14 */ *data++ = 255-line[0]; /*red */ *data++ = 255-line[s->params.pixels_per_line]; /*green */ *data++ = 255-line[2 * s->params.pixels_per_line]; /*blue */ } else if (s->val[OPT_MODE].w == MODE_LINEART) { /* gives 1 bit output */ /*output image location*/ int offset = i % 8; unsigned char mask = 0x80 >> offset; /*set if any colour is over the threshold */ if (line[0] < threshold || line[s->params.pixels_per_line] < threshold || line[2 * s->params.pixels_per_line] < threshold) *data &= ~mask; /* white clear the bit in mask */ else *data |= mask; /* black set the bit in mask */ if (offset == 7 || i == s->params.pixels_per_line-1) data++; /* move on a byte if the byte is full or the line is complete */ } else { /* greyscale - Average the 3 colours */ *data++ = (255-line[0] +255-line[s->params.pixels_per_line] +255-line[2 * s->params.pixels_per_line]) / 3; } line++; } /*debug file The same for color or grey because the scan is colour */ if (RawScan != NULL) { for (i=0; i< s->scan_bytes_per_line; ++i) fputc(s->line_buffer[i],RawScan); } max_length -= s->params.bytes_per_line; s->bytes_read_in_line -= s->scan_bytes_per_line; } } } static SANE_Status k_init_parametersta(KodakAio_Scanner * s) { int dpi, optres; /* struct mode_param *mparam; */ DBG(10, "%s\n", __func__); memset(&s->params, 0, sizeof(SANE_Parameters)); dpi = s->val[OPT_RESOLUTION].w; optres = s->hw->cap->optical_res; /* mparam = &mode_params[s->val[OPT_MODE].w];does this get used? */ if (SANE_UNFIX(s->val[OPT_BR_Y].w) == 0 || SANE_UNFIX(s->val[OPT_BR_X].w) == 0) return SANE_STATUS_INVAL; /* TODO: Use OPT_RESOLUTION or fixed 600dpi for left/top/width/height? */ s->left = ((SANE_UNFIX(s->val[OPT_TL_X].w) / MM_PER_INCH) * optres) + 0.5; s->top = ((SANE_UNFIX(s->val[OPT_TL_Y].w) / MM_PER_INCH) * optres) + 0.5; /* width in pixels */ s->width = ((SANE_UNFIX(s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) / MM_PER_INCH) * optres) + 0.5; s->height = ((SANE_UNFIX(s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) / MM_PER_INCH) * optres) + 0.5; DBG(20, "%s: s->width = %d, s->height = %d optres units\n", __func__, s->width, s->height); s->params.pixels_per_line = s->width * dpi / optres + 0.5; /* ADF used without padding? added 30/12/12 */ if (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) == 0 && !s->val[OPT_PADDING].w) s->params.lines = -1; else s->params.lines = s->height * dpi / optres + 0.5; DBG(20, "%s: resolution = %d, preview = %d\n", __func__, dpi, s->val[OPT_PREVIEW].w); DBG(20, "%s: %p %p tlx %f tly %f brx %f bry %f [mm]\n", __func__, (void *) s, (void *) s->val, SANE_UNFIX(s->val[OPT_TL_X].w), SANE_UNFIX(s->val[OPT_TL_Y].w), SANE_UNFIX(s->val[OPT_BR_X].w), SANE_UNFIX(s->val[OPT_BR_Y].w)); /* * 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_BIT_DEPTH].w; } DBG(20, "%s: bit depth = s->params.depth = %d\n", __func__,s->params.depth); s->params.last_frame = SANE_TRUE; s->params.bytes_per_line = 3 * ceil (s->params.depth * s->params.pixels_per_line / 8.0); /* kodak only scans in color and conversion to grey or lineart is done in the driver s->params.format = SANE_FRAME_RGB; */ DBG(20, "%s: s->val[OPT_MODE].w = %d (color is %d)\n", __func__,s->val[OPT_MODE].w, MODE_COLOR); if (s->val[OPT_MODE].w == MODE_COLOR) s->params.format = SANE_FRAME_RGB; else if (s->val[OPT_MODE].w == MODE_LINEART) s->params.format = SANE_FRAME_GRAY; else s->params.format = SANE_FRAME_GRAY; DBG(20, "%s: format=%d, bytes_per_line=%d, lines=%d\n", __func__, s->params.format, s->params.bytes_per_line, s->params.lines); return (s->params.lines >= -1) ? SANE_STATUS_GOOD : SANE_STATUS_INVAL; } static SANE_Status k_start_scan(KodakAio_Scanner * s) { SANE_Status status; status = cmd_start_scan (s, s->data_len); if (status != SANE_STATUS_GOOD ) { DBG (1, "%s: starting the scan failed (%s)\n", __func__, sane_strstatus(status)); } return status; } static SANE_Status k_read(struct KodakAio_Scanner *s) { unsigned char rx[8]; /* monitors progress of blocks and calls cmd_read_data to get each block you don't know how many blocks there will be in advance because their size may be determined by the scanner*/ SANE_Status status = SANE_STATUS_GOOD; size_t buf_len = 0; /* have we passed everything we read to sane? */ if (s->ptr == s->end) { if (s->eof) return SANE_STATUS_EOF; s->counter++; if (s->bytes_unread >= s->block_len) buf_len = s->block_len; else buf_len = s->bytes_unread; DBG(min(20,DBG_READ), "%s: block %d, size %lu\n", __func__, s->counter, (unsigned long) buf_len); /* receive image data + error code */ status = cmd_read_data (s, s->buf, &buf_len); if (status != SANE_STATUS_GOOD && status != SANE_STATUS_EOF) { /* was just GOOD 20/2/12 */ DBG (1, "%s: Receiving image data failed (%s)\n", __func__, sane_strstatus(status)); cmd_cancel_scan(s); return status; } DBG(min(14,DBG_READ), "%s: success %lu bytes of block %d, %d remain\n", __func__, (unsigned long) buf_len, s->counter, s->bytes_unread); if (s->bytes_unread > 0) { if (s->canceling) { cmd_cancel_scan(s); return SANE_STATUS_CANCELLED; } if (status == SANE_STATUS_EOF) { /* page ended prematurely. */ } } else { /* s->bytes_unread <=0 This is the end of a page */ s->eof = SANE_TRUE; DBG(min(10,DBG_READ), "%s: set EOF after %d blocks\n=============\n", __func__, s->counter); /* look for the terminating ack if required */ if (!s->ack) { if (kodakaio_expect_ack(s, rx) == SANE_STATUS_GOOD) { s->ack = SANE_TRUE; } else { DBG(min(1,DBG_READ), "%s: Did not get expected ack at end of page\n", __func__); return SANE_STATUS_IO_ERROR; } } } s->end = s->buf + buf_len; s->ptr = s->buf; } else { DBG(min(20,DBG_READ), "%s: data left in buffer\n", __func__); } return status; } /* * 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", (unsigned int *)&vidnum) == EOF) { DBG(5, "could not convert hex vid <%s>\n", vid); return NULL; } if(sscanf(pid, "%x", (unsigned int *)&pidnum) == EOF) { DBG(5, "could not convert hex pid <%s>\n", pid); return NULL; } for (n = 0; n < NELEMS (kodakaio_cap); n++) { if (strcmp (kodakaio_cap[n].model, ident)==0) { DBG(20, "matched <%s> & <%s>\n", kodakaio_cap[n].model, ident); return &kodakaio_cap[n]; } else if (kodakaio_cap[n].id == pidnum && 0x040A == vidnum) { DBG(20, "matched <%s> & <%s:%s>\n", kodakaio_cap[n].model, vid, pid); return &kodakaio_cap[n]; } else { DBG(20, "not found <%s> & <%s>\n", kodakaio_cap[n].model, pid); } } return NULL; } #endif /* WITH_AVAHI */ /* * close_scanner() * * Close the open scanner. Depending on the connection method, a different * close function is called. */ static void close_scanner(KodakAio_Scanner *s) { DBG(7, "%s: fd = %d\n", __func__, s->fd); if (s->fd == -1) return; k_scan_finish(s); if (s->hw->connection == SANE_KODAKAIO_NET) { sanei_kodakaio_net_close(s); sanei_tcp_close(s->fd); } else if (s->hw->connection == SANE_KODAKAIO_USB) { sanei_usb_close(s->fd); } s->fd = -1; } static SANE_Bool split_scanner_name (const char *name, char * IP, unsigned int *model) { const char *device = name; const char *qm; *model = 0; /* cut off leading net: */ if (strncmp(device, "net:", 4) == 0) device = &device[4]; qm = strchr(device, '?'); if (qm != NULL) { size_t len = qm-device; strncpy (IP, device, len); IP[len] = '\0'; qm++; if (strncmp(qm, "model=", 6) == 0) { qm += 6; if (!sscanf(qm, "0x%x", model)) sscanf(qm, "%x", model); } } else { strcpy (IP, device); } return SANE_TRUE; } /* * open_scanner() * * Open the scanner device. Depending on the connection method, * different open functions are called. */ static SANE_Status open_scanner(KodakAio_Scanner *s) { SANE_Status status = 0; DBG(7, "%s: %s\n", __func__, s->hw->sane.name); if (s->fd != -1) { DBG(10, "scanner is already open: fd = %d\n", s->fd); return SANE_STATUS_GOOD; /* no need to open the scanner */ } if (s->hw->connection == SANE_KODAKAIO_NET) { /* device name has the form net:ipaddr?model=... */ char IP[1024]; unsigned int model = 0; if (!split_scanner_name (s->hw->sane.name, IP, &model)) return SANE_STATUS_INVAL; DBG(10, "split_scanner_name OK model=0x%x\n",model); /* normal with IP */ status = sanei_tcp_open(IP, 9101, &s->fd); /* (host,port,file pointer) */ if (status != SANE_STATUS_GOOD ) DBG(1, "Is network scanner switched on?\n"); if (model>0) k_set_device (s, model); if (status == SANE_STATUS_GOOD) { status = sanei_kodakaio_net_open (s); } else DBG(1, "status was not good at net open\n"); } else if (s->hw->connection == SANE_KODAKAIO_USB) { DBG(7, "trying to open usb\n"); status = sanei_usb_open(s->hw->sane.name, &s->fd); if (s->hw->cap->out_ep>0) sanei_usb_set_endpoint (s->fd, USB_DIR_OUT | USB_ENDPOINT_TYPE_BULK, s->hw->cap->out_ep); if (s->hw->cap->in_ep>0) sanei_usb_set_endpoint (s->fd, USB_DIR_IN | USB_ENDPOINT_TYPE_BULK, s->hw->cap->in_ep); } if (status == SANE_STATUS_ACCESS_DENIED) { DBG(1, "please check that you have permissions on the device.\n"); DBG(1, "if this is a multi-function device with a printer,\n"); DBG(1, "disable any conflicting driver (like usblp).\n"); } if (status != SANE_STATUS_GOOD) DBG(1, "%s open failed: %s\n", s->hw->sane.name, sane_strstatus(status)); else DBG(3, "scanner opened\n"); /* add check here of usb properties? */ /*sanei_usb_get_descriptor( SANE_Int dn, struct sanei_usb_dev_descriptor *desc );*/ return status; } static SANE_Status detect_usb(struct KodakAio_Scanner *s) { SANE_Status status; SANE_Word vendor, product; int i, numIds; SANE_Bool is_valid; /* if the sanei_usb_get_vendor_product call is not supported, * then we just ignore this and rely on the user to config * the correct device. */ status = sanei_usb_get_vendor_product(s->fd, &vendor, &product); if (status != SANE_STATUS_GOOD) { DBG(1, "the device cannot be verified - will continue\n"); return SANE_STATUS_GOOD; } /* check the vendor ID to see if we are dealing with a kodak device */ if (vendor != SANE_KODAKAIO_VENDOR_ID) { /* this is not a supported vendor ID */ DBG(1, "not a Kodak Aio device at %s (vendor id=0x%x)\n", s->hw->sane.name, vendor); return SANE_STATUS_INVAL; } numIds = kodakaio_getNumberOfUSBProductIds(); is_valid = SANE_FALSE; i = 0; /* check all known product IDs to verify that we know * about the device */ while (i != numIds && !is_valid) { /* if (product == kodakaio_usb_product_ids[i]) */ if (product == kodakaio_cap[i].id) is_valid = SANE_TRUE; i++; } if (is_valid == SANE_FALSE) { DBG(1, "the device at %s is not a supported (product id=0x%x)\n", s->hw->sane.name, product); return SANE_STATUS_INVAL; } DBG(2, "found valid usb Kodak Aio scanner: 0x%x/0x%x (vendorID/productID)\n", vendor, product); k_set_device(s, product); /* added 21/12/11 to try and get a name for the device */ return SANE_STATUS_GOOD; } /* * used by attach* and sane_get_devices * a ptr to a single-linked list of Kodak_Device structs * a ptr to a null term array of ptrs to SANE_Device structs */ static int num_devices; /* number of scanners attached to backend */ static Kodak_Device *first_dev; /* first scanner in list */ static const SANE_Device **devlist = NULL; static struct KodakAio_Scanner * scanner_create(struct Kodak_Device *dev, SANE_Status *status) { struct KodakAio_Scanner *s; s = malloc(sizeof(struct KodakAio_Scanner)); if (s == NULL) { *status = SANE_STATUS_NO_MEM; return NULL; } memset(s, 0x00, sizeof(struct KodakAio_Scanner)); s->fd = -1; s->hw = dev; return s; } static struct KodakAio_Scanner * device_detect(const char *name, int type, SANE_Status *status) { struct KodakAio_Scanner *s; struct Kodak_Device *dev; /* try to find the device in our list */ for (dev = first_dev; dev; dev = dev->next) { if (strcmp(dev->sane.name, name) == 0) { dev->missing = 0; DBG (10, "%s: Device %s already attached!\n", __func__, name); return scanner_create(dev, status); } } if (type == SANE_KODAKAIO_NODEV) { *status = SANE_STATUS_INVAL; return NULL; } /* alloc and clear our device structure */ dev = malloc(sizeof(*dev)); if (!dev) { *status = SANE_STATUS_NO_MEM; return NULL; } memset(dev, 0x00, sizeof(struct Kodak_Device)); s = scanner_create(dev, status); if (s == NULL) return NULL; k_dev_init(dev, name, type); *status = open_scanner(s); if (*status != SANE_STATUS_GOOD) { free(s); free(dev); return NULL; } /* from now on, close_scanner() must be called */ /* USB requires special care */ if (dev->connection == SANE_KODAKAIO_USB) { *status = detect_usb(s); } if (*status != SANE_STATUS_GOOD) goto close; /* set name and model (if not already set) */ if (dev->model == NULL) k_set_model(s, "generic", 7); dev->name = strdup(name); dev->sane.name = dev->name; /* do we need to discover capabilities here? */ *status = k_discover_capabilities(s); if (*status != SANE_STATUS_GOOD) goto close; if (source_list[0] == NULL || dev->cap->dpi_range.min == 0) { DBG(1, "something is wrong in the discovery process, aborting.\n"); *status = SANE_STATUS_IO_ERROR; goto close; } /* add this scanner to the device list */ num_devices++; dev->missing = 0; dev->next = first_dev; first_dev = dev; return s; close: close_scanner(s); free(dev); free(s); return NULL; } #if WITH_AVAHI /* ProcessAvahiDevice is called to process each discovered device in turn */ void ProcessAvahiDevice(const char *device_id, const char *vid, const char *pid, const char *ip_addr) { struct KodakaioCap *cap; DBG(min(10,DBG_AUTO),"device_id = <%s> vid:pid = <%s:%s>\n", device_id,vid,pid); /* check if it is a model likely to be supported: "KODAK ESP" or "KODAK HERO" DBG(min(10,DBG_AUTO),"look up model <%s>\n", device_model); */ cap = get_device_from_identification("", vid, pid); if (cap == NULL) { return; } DBG(min(10,DBG_AUTO), "%s: Found autodiscovered device: %s (type 0x%x)\n", __func__, cap->model, cap->id); attach_one_net (ip_addr, cap->id); } static void resolve_callback( AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char *type, const char *domain, const char *host_name, const AvahiAddress *address, uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, AVAHI_GCC_UNUSED void* userdata) { AvahiStringList *vid_pair_list = NULL, *pid_pair_list = NULL; char *pidkey, *pidvalue; char *vidkey, *vidvalue; size_t valuesize; NOT_USED (flags); assert(r); /* Called whenever a service has been resolved successfully or timed out */ switch (event) { case AVAHI_RESOLVER_FAILURE: DBG(min(1,DBG_AUTO), "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r)))); break; case AVAHI_RESOLVER_FOUND: { char a[AVAHI_ADDRESS_STR_MAX]; avahi_address_snprint(a, sizeof(a), address); /* Output short for Kodak ESP */ DBG(min(10,DBG_AUTO), "%s:%u %s\n", a,port,host_name); vid_pair_list = avahi_string_list_find(txt, "vid"); if(vid_pair_list != NULL) { avahi_string_list_get_pair(vid_pair_list, &vidkey, &vidvalue, &valuesize); DBG(min(10,DBG_AUTO), "%s=%s ", vidkey, vidvalue); } else DBG(min(10,DBG_AUTO), "failed to find key vid\n"); pid_pair_list = avahi_string_list_find(txt, "pid"); if(pid_pair_list != NULL) { avahi_string_list_get_pair(pid_pair_list, &pidkey, &pidvalue, &valuesize); DBG(min(10,DBG_AUTO), "%s=%s\n", pidkey, pidvalue); } else DBG(min(10,DBG_AUTO), "failed to find key pid\n"); if(pid_pair_list != NULL && vid_pair_list != NULL) { ProcessAvahiDevice(name, vidvalue, pidvalue, a); } else DBG(min(10,DBG_AUTO), "didn't call ProcessAvahiDevice\n"); if(vid_pair_list != NULL) { avahi_free(vidkey); avahi_free(vidvalue); DBG(min(15,DBG_AUTO), "vidkey and vidvalue freed\n"); } if(pid_pair_list != NULL) { avahi_free(pidkey); avahi_free(pidvalue); DBG(min(15,DBG_AUTO), "pidkey and pidvalue freed\n"); } } } DBG(min(10,DBG_AUTO), "ending resolve_callback\n"); avahi_service_resolver_free(r); } static void browse_callback( AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { AvahiSimplePoll *simple_poll = userdata; 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) { case AVAHI_BROWSER_FAILURE: DBG(min(1,DBG_AUTO), "(Browser) %s\n", avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b)))); avahi_simple_poll_quit(simple_poll); return; case AVAHI_BROWSER_NEW: DBG(min(5,DBG_AUTO), "(Browser) NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain); /* We ignore the returned resolver object. In the callback function we free it. If the server is terminated before the callback function is called the server will free the resolver for us. */ if (!(avahi_service_resolver_new(c, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, c))) DBG(min(1,DBG_AUTO), "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_client_errno(c))); break; case AVAHI_BROWSER_REMOVE: DBG(min(1,DBG_AUTO), "(Browser) REMOVE: service '%s' of type '%s' in domain '%s'\n", name, type, domain); break; case AVAHI_BROWSER_ALL_FOR_NOW: case AVAHI_BROWSER_CACHE_EXHAUSTED: DBG(min(5,DBG_AUTO), "(Browser) %s\n", event == AVAHI_BROWSER_CACHE_EXHAUSTED ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); break; } } static void client_callback(AvahiClient *c, AvahiClientState state, void * userdata) { AvahiSimplePoll *simple_poll = userdata; assert(c); /* Called whenever the client or server state changes */ if (state == AVAHI_CLIENT_FAILURE) { DBG(min(1,DBG_AUTO), "Server connection failure: %s\n", avahi_strerror(avahi_client_errno(c))); avahi_simple_poll_quit(simple_poll); } } static int 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; int i, ret = 1; NOT_USED(host); DBG(2, "%s: called\n", __func__); /* Allocate main loop object */ if (!(simple_poll = avahi_simple_poll_new())) { DBG(min(1,DBG_AUTO), "Failed to create simple poll object.\n"); goto fail; } /* Allocate a new client */ 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) { DBG(min(1,DBG_AUTO), "Failed to create client: %s\n", avahi_strerror(error)); goto fail; } /* Create the service browser */ 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;i 0) { snprintf(name, 1024, "net:%s?model=0x%x", dev, model); } else { snprintf(name, 1024, "net:%s", dev); } return attach(name, SANE_KODAKAIO_NET); } static SANE_Status attach_one_config(SANEI_Config __sane_unused__ *config, const char *line) { int vendor, product, timeout; int len = strlen(line); DBG(7, "%s: len = %d, line = %s\n", __func__, len, line); if (sscanf(line, "usb %i %i", &vendor, &product) == 2) { /* add the vendor and product IDs to the list of * known devices before we call the attach function */ int numIds = kodakaio_getNumberOfUSBProductIds(); if (vendor != SANE_KODAKAIO_VENDOR_ID) { DBG(7, "Wrong vendor: numIds = %d, vendor = %d\n", numIds, vendor); return SANE_STATUS_INVAL; /* this is not a Kodak device */ } /* kodakaio_usb_product_ids[numIds - 1] = product; */ kodakaio_cap[numIds - 1].id = product; sanei_usb_attach_matching_devices(line, attach_one_usb); } else if (strncmp(line, "usb", 3) == 0 && len == 3) { int i, numIds; /* auto detect ? */ numIds = kodakaio_getNumberOfUSBProductIds(); for (i = 0; i < numIds; i++) { /* sanei_usb_find_devices(SANE_KODAKAIO_VENDOR_ID, kodakaio_usb_product_ids[i], attach_one_usb); */ sanei_usb_find_devices(SANE_KODAKAIO_VENDOR_ID, kodakaio_cap[i].id, attach_one_usb); } } else if (strncmp(line, "net", 3) == 0) { /* remove the "net" sub string */ const char *name = sanei_config_skip_whitespace(line + 3); char IP[1024]; unsigned int model = 0; if (strncmp(name, "autodiscovery", 13) == 0) { #if WITH_AVAHI DBG (30, "%s: Initiating network autodiscovery via avahi\n", __func__); kodak_network_discovery(NULL); #else DBG (20, "%s: Network autodiscovery not done because not configured with avahi.\n", __func__); #endif } else if (sscanf(name, "%s %x", IP, &model) == 2) { DBG(30, "%s: Using network device on IP %s, forcing model 0x%x\n", __func__, IP, model); attach_one_net(IP, model); } else { DBG(1, "%s: net entry %s may be a host name?\n", __func__, name); attach_one_net(name, 0); } } else if (sscanf(line, "snmp-timeout %i\n", &timeout)) { /* Timeout for auto network discovery */ DBG(50, "%s: network auto-discovery timeout set to %d\n", __func__, timeout); K_SNMP_Timeout = timeout; } else if (sscanf(line, "scan-data-timeout %i\n", &timeout)) { /* Timeout for scan data requests */ DBG(50, "%s: Scan data timeout set to %d\n", __func__, timeout); K_Scan_Data_Timeout = timeout; } else if (sscanf(line, "request-timeout %i\n", &timeout)) { /* Timeout for all other read requests */ DBG(50, "%s: Request timeout set to %d\n", __func__, timeout); K_Request_Timeout = timeout; } else { /* TODO: Warning about unparsable line! */ } return SANE_STATUS_GOOD; } static void free_devices(void) { Kodak_Device *dev, *next; DBG(5, "%s\n", __func__); for (dev = first_dev; dev; dev = next) { next = dev->next; free(dev->name); free(dev->model); free(dev); } if (devlist) free(devlist); devlist = NULL; first_dev = NULL; } SANE_Status sane_init(SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize) { DBG_INIT(); DBG(1, "========================================== \n"); DBG(2, "%s: " PACKAGE " " VERSION "\n", __func__); DBG(1, "kodakaio backend, version %i.%i.%i\n", KODAKAIO_VERSION, KODAKAIO_REVISION, KODAKAIO_BUILD); DBG(2, "%s: called\n", __func__); if (version_code != NULL) *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, KODAKAIO_BUILD); sanei_usb_init(); #if WITH_AVAHI DBG(min(3,DBG_AUTO), "avahi detected\n"); #else DBG(min(3,DBG_AUTO), "avahi not detected\n"); #endif return SANE_STATUS_GOOD; } /* Clean up the list of attached scanners. */ void sane_exit(void) { DBG(5, "%s\n", __func__); free_devices(); } SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool __sane_unused__ local_only) { Kodak_Device *dev, *s, *prev=0; int i; DBG(2, "%s: called\n", __func__); sanei_usb_init(); /* mark all existing scanners as missing, attach_one will remove mark */ for (s = first_dev; s; s = s->next) { s->missing = 1; } /* Read the config, mark each device as found, possibly add new devs */ sanei_configure_attach(KODAKAIO_CONFIG_FILE, NULL, attach_one_config); /*delete missing scanners from list*/ for (s = first_dev; s;) { if (s->missing) { DBG (5, "%s: missing scanner %s\n", __func__, s->name); /*splice s out of list by changing pointer in prev to next*/ if (prev) { prev->next = s->next; free (s); s = prev->next; num_devices--; } else { /*remove s from head of list */ first_dev = s->next; free(s); s = first_dev; prev=NULL; num_devices--; } } else { prev = s; s = prev->next; } } DBG (15, "%s: found %d scanner(s)\n", __func__, num_devices); for (s = first_dev; s; s=s->next) { DBG (15, "%s: found scanner %s\n", __func__, s->name); } if (devlist) free (devlist); devlist = malloc((num_devices + 1) * sizeof(devlist[0])); if (!devlist) { DBG(1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } DBG(5, "%s - results:\n", __func__); for (i = 0, dev = first_dev; i < num_devices && dev; dev = dev->next, i++) { DBG(5, " %d (%d): %s\n", i, dev->connection, dev->model); devlist[i] = &dev->sane; } devlist[i] = NULL; if(device_list){ *device_list = devlist; } return SANE_STATUS_GOOD; } static SANE_Status init_options(KodakAio_Scanner *s) { int i; SANE_Word *res_list; DBG(5, "%s: called\n", __func__); for (i = 0; i < NUM_OPTIONS; i++) { s->opt[i].size = sizeof(SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Scan Mode" group: */ s->opt[OPT_MODE_GROUP].name = SANE_NAME_STANDARD; s->opt[OPT_MODE_GROUP].title = SANE_TITLE_STANDARD; s->opt[OPT_MODE_GROUP].desc = SANE_DESC_STANDARD; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = max_string_size(mode_list); s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].w = MODE_COLOR; /* default */ DBG(20, "%s: mode_list has first entry %s, default mode is %s\n", __func__, mode_list[0],mode_list[s->val[OPT_MODE].w]); /* theshold the sane std says should be SANE_TYPE_FIXED 0..100 but all other backends seem to use INT 0..255 */ s->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; s->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; s->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; s->opt[OPT_THRESHOLD].type = SANE_TYPE_FIXED; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; s->opt[OPT_THRESHOLD].size = sizeof(SANE_Word); s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &percent_range_fixed; s->val[OPT_THRESHOLD].w = SANE_FIX(50.0); DBG(20, "%s: threshold initialised to fixed %f\n", __func__, SANE_UNFIX(s->val[OPT_THRESHOLD].w)); /* theshold the sane std says should be SANE_TYPE_FIXED 0..100 but all other backends seem to use INT 0..255 s->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; s->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; s->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; s->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; s->opt[OPT_THRESHOLD].size = sizeof(SANE_Word); s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &percent_range_int; s->val[OPT_THRESHOLD].w = 51; DBG(20, "%s: threshold initialised to int %d\n", __func__, s->val[OPT_THRESHOLD].w); */ /* bit depth */ s->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; s->opt[OPT_BIT_DEPTH].unit = SANE_UNIT_NONE; s->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_BIT_DEPTH].constraint.word_list = s->hw->cap->depth_list; s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; s->val[OPT_BIT_DEPTH].w = s->hw->cap->depth_list[1]; /* the first "real" element is the default */ DBG(20, "%s: depth list has depth_list[0] = %d entries\n", __func__, s->hw->cap->depth_list[0]); if (s->hw->cap->depth_list[0] == 1) { /* only one element in the list -> hide the option */ s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; DBG(20, "%s: Only one depth in list so inactive option\n", __func__); } /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; res_list = malloc((s->hw->cap->res_list_size + 1) * sizeof(SANE_Word)); if (res_list == NULL) { return SANE_STATUS_NO_MEM; } *(res_list) = s->hw->cap->res_list_size; memcpy(&(res_list[1]), s->hw->cap->res_list, s->hw->cap->res_list_size * sizeof(SANE_Word)); s->opt[OPT_RESOLUTION].constraint.word_list = res_list; s->val[OPT_RESOLUTION].w = s->hw->cap->dpi_range.min; /* trial option for debugging s->opt[OPT_TRIALOPT].name = "trialoption"; s->opt[OPT_TRIALOPT].title = "trialoption"; s->opt[OPT_TRIALOPT].desc = "trialoption"; s->opt[OPT_TRIALOPT].type = SANE_TYPE_INT; s->opt[OPT_TRIALOPT].unit = SANE_UNIT_NONE; s->opt[OPT_TRIALOPT].size = sizeof(SANE_Word); s->opt[OPT_TRIALOPT].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TRIALOPT].constraint.range = &percent_range_int; s->val[OPT_TRIALOPT].w = 1; */ /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_PREVIEW].w = SANE_FALSE; for(i=0;source_list[i]!=NULL;++i) DBG(18, "source_list: %s\n",source_list[i]); /* source */ s->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_SOURCE].type = SANE_TYPE_STRING; s->opt[OPT_SOURCE].size = max_string_size(source_list); s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].constraint.string_list = source_list; s->val[OPT_SOURCE].w = 0; /* always use Flatbed as default */ if ((!s->hw->cap->ADF)) { DBG(9, "device with no adf detected source option inactive\n"); s->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; } /* Are there any ESP scanners that are duplex? */ s->opt[OPT_ADF_MODE].name = "adf-mode"; s->opt[OPT_ADF_MODE].title = SANE_I18N("ADF Mode"); s->opt[OPT_ADF_MODE].desc = SANE_I18N("Selects the ADF mode (simplex/duplex)"); s->opt[OPT_ADF_MODE].type = SANE_TYPE_STRING; s->opt[OPT_ADF_MODE].size = max_string_size(adf_mode_list); s->opt[OPT_ADF_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_ADF_MODE].constraint.string_list = adf_mode_list; s->val[OPT_ADF_MODE].w = 0; /* simplex */ if ((!s->hw->cap->ADF) || (!s->hw->cap->adf_duplex)) s->opt[OPT_ADF_MODE].cap |= SANE_CAP_INACTIVE; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].name = SANE_NAME_GEOMETRY; s->opt[OPT_GEOMETRY_GROUP].title = SANE_TITLE_GEOMETRY; s->opt[OPT_GEOMETRY_GROUP].desc = SANE_DESC_GEOMETRY; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = s->hw->x_range; s->val[OPT_TL_X].w = 0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = s->hw->y_range; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = s->hw->x_range; s->val[OPT_BR_X].w = s->hw->x_range->max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = s->hw->y_range; s->val[OPT_BR_Y].w = s->hw->y_range->max; /* padding short pages in adf */ s->opt[OPT_PADDING].name = "adf-padding"; s->opt[OPT_PADDING].title = "pad short adf pages"; s->opt[OPT_PADDING].desc = "Selects whether to make short pages up to full length"; s->opt[OPT_PADDING].type = SANE_TYPE_BOOL; s->val[OPT_PADDING].w = SANE_FALSE; if ((!s->hw->cap->ADF) || (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) != 0)) { DBG(9, "adf not source so padding option off and inactive\n"); s->opt[OPT_PADDING].cap |= SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; } SANE_Status sane_open(SANE_String_Const name, SANE_Handle *handle) { SANE_Status status; KodakAio_Scanner *s = NULL; int l = strlen(name); DBG(2, "%s: name = %s\n", __func__, name); /* probe if empty device name provided */ if (l == 0) { status = sane_get_devices(NULL,0); if (status != SANE_STATUS_GOOD) { return status; } if (first_dev == NULL) { DBG(1, "no device detected\n"); return SANE_STATUS_INVAL; } s = device_detect(first_dev->sane.name, first_dev->connection, &status); if (s == NULL) { DBG(1, "cannot open a perfectly valid device (%s)," " please report to the authors\n", name); return SANE_STATUS_INVAL; } } else { if (strncmp(name, "net:", 4) == 0) { s = device_detect(name, SANE_KODAKAIO_NET, &status); if (s == NULL) return status; } else if (strncmp(name, "libusb:", 7) == 0) { s = device_detect(name, SANE_KODAKAIO_USB, &status); if (s == NULL) return status; } else { /* as a last resort, check for a match * in the device list. This should handle platforms without libusb. */ if (first_dev == NULL) { status = sane_get_devices(NULL,0); if (status != SANE_STATUS_GOOD) { return status; } } s = device_detect(name, SANE_KODAKAIO_NODEV, &status); if (s == NULL) { DBG(1, "invalid device name: %s\n", name); return SANE_STATUS_INVAL; } } } /* s is always valid here */ DBG(10, "handle obtained\n"); status = k_discover_capabilities(s); /* added 27/12/11 to fix source list problem maybe we should only be rebuilding the source list here? */ if (status != SANE_STATUS_GOOD) return status; init_options(s); *handle = (SANE_Handle) s; /* moving the open scanner section below to sane_start 27/12/14 status = open_scanner(s); if (status != SANE_STATUS_GOOD) { free(s); return status; } */ return status; } void sane_close(SANE_Handle handle) { KodakAio_Scanner *s; /* * XXX Test if there is still data pending from * the scanner. If so, then do a cancel */ s = (KodakAio_Scanner *) handle; DBG(2, "%s: called\n", __func__); /* moving the close scanner section below to sane_cancel 27/12/14 */ if (s->fd != -1) close_scanner(s); /* end of section */ if(RawScan != NULL) fclose(RawScan); RawScan = NULL; free(s); } const SANE_Option_Descriptor * sane_get_option_descriptor(SANE_Handle handle, SANE_Int option) { /* this may be a sane call, but it happens way too often to have DBG level 2 */ KodakAio_Scanner *s = (KodakAio_Scanner *) handle; DBG(30, "%s: called for option %d\n", __func__, option); if (option < 0 || option >= NUM_OPTIONS) return NULL; return s->opt + option; } static const SANE_String_Const * search_string_list(const SANE_String_Const *list, SANE_String value) { while (*list != NULL && strcmp(value, *list) != 0) list++; return ((*list == NULL) ? NULL : list); } /* Activate, deactivate an option. Subroutines so we can add debugging info if we want. The change flag is set to TRUE if we changed an option. If we did not change an option, then the value of the changed flag is not modified. */ static void activateOption(KodakAio_Scanner *s, SANE_Int option, SANE_Bool *change) { if (!SANE_OPTION_IS_ACTIVE(s->opt[option].cap)) { s->opt[option].cap &= ~SANE_CAP_INACTIVE; *change = SANE_TRUE; } } static void deactivateOption(KodakAio_Scanner *s, SANE_Int option, SANE_Bool *change) { if (SANE_OPTION_IS_ACTIVE(s->opt[option].cap)) { s->opt[option].cap |= SANE_CAP_INACTIVE; *change = SANE_TRUE; } } static SANE_Status getvalue(SANE_Handle handle, SANE_Int option, void *value) { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; SANE_Option_Descriptor *sopt = &(s->opt[option]); Option_Value *sval = &(s->val[option]); DBG(17, "%s: option = %d\n", __func__, option); switch (option) { case OPT_NUM_OPTS: case OPT_BIT_DEPTH: /* case OPT_TRIALOPT: */ case OPT_RESOLUTION: case OPT_PREVIEW: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: *((SANE_Word *) value) = sval->w; DBG(20, "%s: got option %d as %d\n", __func__, option, *((SANE_Word *) value)); break; case OPT_THRESHOLD: *((SANE_Word *) value) = sval->w; DBG(20, "%s: got option %d as %f\n", __func__, option, SANE_UNFIX(*((SANE_Word *) value))); /*DBG(20, "%s: got option %d as %d\n", __func__, option, *((SANE_Word *) value));*/ break; case OPT_MODE: case OPT_SOURCE: case OPT_ADF_MODE: strcpy((char *) value, sopt->constraint.string_list[sval->w]); break; case OPT_PADDING: *((SANE_Bool *) value) = sval->w; break; default: DBG(20, "%s: returning inval\n", __func__); return SANE_STATUS_INVAL; } DBG(20, "%s: returning good\n", __func__); return SANE_STATUS_GOOD; } /* * Handles setting the source (flatbed, or auto document feeder (ADF)). * */ static void change_source(KodakAio_Scanner *s, SANE_Int optindex, char *value) { int force_max = SANE_FALSE; SANE_Bool dummy; DBG(5, "%s: optindex = %d, source = '%s'\n", __func__, optindex, value); if (s->val[OPT_SOURCE].w == optindex) return; s->val[OPT_SOURCE].w = optindex; if (s->val[OPT_TL_X].w == s->hw->x_range->min && s->val[OPT_TL_Y].w == s->hw->y_range->min && s->val[OPT_BR_X].w == s->hw->x_range->max && s->val[OPT_BR_Y].w == s->hw->y_range->max) { force_max = SANE_TRUE; } if (strcmp(ADF_STR, value) == 0) { s->hw->x_range = &s->hw->cap->adf_x_range; s->hw->y_range = &s->hw->cap->adf_y_range; if (s->hw->cap->adf_duplex) { activateOption(s, OPT_ADF_MODE, &dummy); } else { deactivateOption(s, OPT_ADF_MODE, &dummy); s->val[OPT_ADF_MODE].w = 0; } activateOption(s, OPT_PADDING, &dummy); DBG(5, "adf activated flag = %d\n",s->hw->cap->adf_duplex); } else { /* ADF not active */ s->hw->x_range = &s->hw->cap->fbf_x_range; s->hw->y_range = &s->hw->cap->fbf_y_range; deactivateOption(s, OPT_ADF_MODE, &dummy); deactivateOption(s, OPT_PADDING, &dummy); } s->opt[OPT_BR_X].constraint.range = s->hw->x_range; s->opt[OPT_BR_Y].constraint.range = s->hw->y_range; if (s->val[OPT_TL_X].w < s->hw->x_range->min || force_max) s->val[OPT_TL_X].w = s->hw->x_range->min; if (s->val[OPT_TL_Y].w < s->hw->y_range->min || force_max) s->val[OPT_TL_Y].w = s->hw->y_range->min; if (s->val[OPT_BR_X].w > s->hw->x_range->max || force_max) s->val[OPT_BR_X].w = s->hw->x_range->max; if (s->val[OPT_BR_Y].w > s->hw->y_range->max || force_max) s->val[OPT_BR_Y].w = s->hw->y_range->max; } static SANE_Status setvalue(SANE_Handle handle, SANE_Int option, void *value, SANE_Int *info) { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; SANE_Option_Descriptor *sopt = &(s->opt[option]); Option_Value *sval = &(s->val[option]); SANE_Status status; const SANE_String_Const *optval = NULL; int optindex = 0; SANE_Bool reload = SANE_FALSE; DBG(17, "%s: option = %d, value = %p, as word: %d\n", __func__, option, value, *(SANE_Word *) value); status = sanei_constrain_value(sopt, value, info); if (status != SANE_STATUS_GOOD) return status; if (info && value && (*info & SANE_INFO_INEXACT) && sopt->type == SANE_TYPE_INT) DBG(17, "%s: constrained val = %d\n", __func__, *(SANE_Word *) value); if (sopt->constraint_type == SANE_CONSTRAINT_STRING_LIST) { optval = search_string_list(sopt->constraint.string_list, (char *) value); if (optval == NULL) return SANE_STATUS_INVAL; optindex = optval - sopt->constraint.string_list; } switch (option) { case OPT_MODE: { sval->w = optindex; /* if binary, then disable the bit depth selection and enable threshold */ if (optindex == MODE_LINEART) { DBG(17, "%s: binary mode setting depth to 1\n", __func__); s->val[OPT_BIT_DEPTH].w = 1; s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; s->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; } else { if (s->hw->cap->depth_list[0] == 1) { /* only one entry in the list ? */ DBG(17, "%s: non-binary mode but only one depth available\n", __func__); s->val[OPT_BIT_DEPTH].w = s->hw->cap->depth_list[1]; s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; } else { /* there is a list to choose from ? */ DBG(17, "%s: non-binary mode and depth list available\n", __func__); s->opt[OPT_BIT_DEPTH].cap &= ~SANE_CAP_INACTIVE; s->val[OPT_BIT_DEPTH].w = mode_params[optindex].depth; s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; /* does not work in xsane ? */ } } reload = SANE_TRUE; break; } case OPT_BIT_DEPTH: sval->w = *((SANE_Word *) value); mode_params[s->val[OPT_MODE].w].depth = sval->w; reload = SANE_TRUE; break; case OPT_THRESHOLD: sval->w = *((SANE_Word *) value); DBG(17, "setting threshold to %f\n", SANE_UNFIX(sval->w)); /*DBG(17, "setting threshold to %d\n", sval->w);*/ /*reload = SANE_TRUE; what does this do?*/ break; case OPT_RESOLUTION: sval->w = *((SANE_Word *) value); DBG(17, "setting resolution to %d\n", sval->w); reload = SANE_TRUE; break; case OPT_BR_X: case OPT_BR_Y: if (SANE_UNFIX(*((SANE_Word *) value)) == 0) { DBG(17, "invalid br-x or br-y\n"); return SANE_STATUS_INVAL; } // fall through case OPT_TL_X: case OPT_TL_Y: sval->w = *((SANE_Word *) value); DBG(17, "setting size to %f\n", SANE_UNFIX(sval->w)); if (NULL != info) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_SOURCE: change_source(s, optindex, (char *) value); reload = SANE_TRUE; break; case OPT_ADF_MODE: sval->w = optindex; /* Simple lists */ break; case OPT_PADDING: sval->w = *((SANE_Word *) value); break; /* case OPT_TRIALOPT: */ case OPT_PREVIEW: /* needed? */ sval->w = *((SANE_Word *) value); break; default: return SANE_STATUS_INVAL; } if (reload && info != NULL) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; DBG(17, "%s: end\n", __func__); return SANE_STATUS_GOOD; } SANE_Status sane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int *info) { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; if (option < 0 || option >= NUM_OPTIONS) { DBG(1, "%s: option num = %d out of range (0..%d)\n", __func__, option, NUM_OPTIONS - 1); return SANE_STATUS_INVAL; } DBG(5, "%s: action = %x, option = %d %s\n", __func__, action, option, s->opt[option].name); if (info != NULL) *info = 0; switch (action) { case SANE_ACTION_GET_VALUE: return getvalue(handle, option, value); case SANE_ACTION_SET_VALUE: return setvalue(handle, option, value, info); default: return SANE_STATUS_INVAL; } return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters(SANE_Handle handle, SANE_Parameters *params) { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; DBG(2, "%s: called\n", __func__); if (params == NULL) DBG(1, "%s: params is NULL\n", __func__); /* * If sane_start was already called, then just retrieve the parameters * from the scanner data structure */ if (!s->eof && s->ptr != NULL) { DBG(5, "scan in progress, returning saved params structure\n"); } else { /* otherwise initialize the params structure and gather the data */ k_init_parametersta(s); } if (params != NULL) *params = s->params; print_params(s->params,20); return SANE_STATUS_GOOD; } /* * This function is part of the SANE API and gets called from the front end to * start the scan process. */ SANE_Status sane_start(SANE_Handle handle) { KodakAio_Scanner *s = (KodakAio_Scanner *) handle; SANE_Status status; DBG(2, "%s: called\n", __func__); if(! s->scanning) { /* calc scanning parameters */ status = k_init_parametersta(s); if (status != SANE_STATUS_GOOD) return status; /* set scanning parameters; also query the current image * parameters from the sanner and save * them to s->params Only set scanning params the first time, or after a cancel try change 22/2/12 take lock scanner out of k_set_scanning_parameters */ /* moved open_scanner here 27/12/14 from sane_open */ status = open_scanner(s); if (status != SANE_STATUS_GOOD) { free(s); return status; } /* end of open scanner section */ status = k_lock_scanner(s); if (status != SANE_STATUS_GOOD) { DBG(1, "could not lock scanner\n"); return status; } } status = k_set_scanning_parameters(s); if (status != SANE_STATUS_GOOD) return status; print_params(s->params, 5); /* if we scan from ADF, check if it is loaded */ if (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) == 0) { status = k_check_adf(s); if (status != SANE_STATUS_GOOD) { /* returning SANE_STATUS_NO_DOCS seems not to cause simple-scan to end the adf scan, so we cancel */ status = SANE_STATUS_CANCELLED; DBG(10, "%s: returning %s\n", __func__, sane_strstatus(status)); return status; } } /* prepare buffer here so that a memory allocation failure * will leave the scanner in a sane state. */ s->buf = realloc(s->buf, s->block_len); if (s->buf == NULL) return SANE_STATUS_NO_MEM; s->eof = SANE_FALSE; /* page not finished */ s->ack = SANE_FALSE; /* page from scanner not finished */ s->ptr = s->end = s->buf; s->canceling = SANE_FALSE; if (strlen(RawScanPath) > 0 && s->params.lines > 0) RawScan = fopen(RawScanPath, "wb");/* open the debug file if it has a name */ if(RawScan) fprintf(RawScan, "P5\n%d %d\n%d\n",s->scan_bytes_per_line, s->params.lines, 255); /* start scanning */ DBG(2, "%s: scanning...\n", __func__); status = k_start_scan(s); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: start failed: %s\n", __func__, sane_strstatus(status)); return status; } return status; } /* this moves data from our buffers to SANE */ SANE_Status sane_read(SANE_Handle handle, SANE_Byte *data, SANE_Int max_length, SANE_Int *length) { SANE_Status status; KodakAio_Scanner *s = (KodakAio_Scanner *) handle; if (s->buf == NULL || s->canceling) return SANE_STATUS_CANCELLED; *length = 0; DBG(18, "sane-read, bytes unread %d\n",s->bytes_unread); status = k_read(s); if (status == SANE_STATUS_CANCELLED) { k_scan_finish(s); return status; } k_copy_image_data(s, data, max_length, length); DBG(18, "%d lines read, status: %s\n", *length / s->params.bytes_per_line, sane_strstatus(status)); /* continue reading if appropriate */ if (status == SANE_STATUS_GOOD) return status; /* not sure if we want to finish (unlock scanner) here or in sane_close */ /* k_scan_finish(s); */ return status; } void sane_cancel(SANE_Handle handle) { SANE_Status status; KodakAio_Scanner *s = (KodakAio_Scanner *) handle; DBG(2, "%s: called\n", __func__); status = cmd_cancel_scan(s); if (status != SANE_STATUS_GOOD) DBG(1, "%s: cmd_cancel_scan failed: %s\n", __func__, sane_strstatus(status)); /* moved from close scanner section 27/12/14 */ if (s->fd != -1) close_scanner(s); /* end of section */ } /* * SANE_Status sane_set_io_mode() * * not supported - for asynchronous I/O */ SANE_Status sane_set_io_mode(SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { return SANE_STATUS_UNSUPPORTED; } /* * SANE_Status sane_get_select_fd() * * not supported - for asynchronous I/O */ SANE_Status sane_get_select_fd(SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ *fd) { return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/test.conf.in0000666000000000000000000000341713615534521015030 00000000000000# test backend configuration file ######################################## # number of test devices number_of_devices 2 # Initial option values and ranges ######################################## # Scan mode (Color, Gray) mode Gray # Bit depth (1, 8, 16) depth 8 # Hand-scanner mode (true, false) hand-scanner false # Three-pass mode (true, false) three-pass false # Three-pass order (RGB, RBG, GBR, GRB, BGR, BRG) three-pass-order RGB # Resolution (dpi) resolution_min 1.0 resolution_max 1200.0 resolution_quant 1.0 resolution 50.0 # Draw test picture ("Solid black", "Solid white", "Color pattern", "Grid") test-picture "Solid black" # Invert upper and lower byte in 16 bit modes invert-endianess false # Read-limit (true, false) read-limit false # Read-limit size (1 - 65536 bytes) read-limit-size 1 # Read-delay (true, false) read-delay false # Read-delay duration (1000 - 200,000 microseconds) read-delay-duration 1000 # Status code (return-value) of sane_read() ("Default", # "SANE_STATUS_UNSUPPORTED", # "SANE_STATUS_CANCELLED", "SANE_STATUS_DEVICE_BUSY", "SANE_STATUS_INVAL", # "SANE_STATUS_EOF", "SANE_STATUS_JAMMED", "SANE_STATUS_NO_DOCS", # "SANE_STATUS_COVER_OPEN", "SANE_STATUS_IO_ERROR", "SANE_STATUS_NO_MEM", # "SANE_STATUS_ACCESS_DENIED" read-status-code "Default" # Fuzzy parameters (true, false) fuzzy-parameters false # Loss of pixels per line (pixels) ppl-loss 0 # Non-blocking io (true, false) non-blocking false # Support select fd (true, false) select-fd false # Enable test options (true, false) enable-test-options false # Geometry (mm) geometry_min 0.0 geometry_max 200.0 geometry_quant 1.0 # Top-left x position (mm) tl_x 0.0 # Top-left y position (mm) tl_y 0.0 # Bottom-right x position (mm) br_x 80.0 # Bottom-right y position (mm) br_y 100.0 sane-backends-1.0.29/backend/hs2p-scsi.c0000666000000000000000000021104413615534521014551 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2007 Jeremy Johnson This file is part of a SANE backend for Ricoh IS450 and IS420 family of HS2P Scanners using the SCSI controller. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include #include "hs2p.h" static SANE_String_Const print_devtype (SANE_Byte devtype) { int i = devtype; static SANE_String devtypes[] = { "disk", "tape", "printer", "processor", "CD-writer", "CD-drive", "scanner", "optical-drive", "jukebox", "communicator" }; return (i >= 0 && i < NELEMS (devtypes)) ? devtypes[i] : "unknown-device"; } static void print_bytes (const void *buf, size_t bufsize) { const SANE_Byte *bp; unsigned i; for (i = 0, bp = buf; i < bufsize; i++, bp++) DBG (DBG_error, "%3d: 0x%02x %d\n", i, *bp, *bp); } static void ScannerDump (HS2P_Scanner * s) { int i; HS2P_Info *info; SANE_Device *sdev; info = &s->hw->info; sdev = &s->hw->sane; DBG (DBG_info, "\n\n"); DBG (DBG_info, ">> ScannerDump:\n"); DBG (DBG_info, "SANE Device: '%s' Vendor: '%s' Model: '%s' Type: '%s'\n", sdev->name, sdev->vendor, sdev->model, sdev->type); DBG (DBG_info, "Type: '%s' Vendor: '%s' Product: '%s' Revision: '%s'\n", print_devtype (info->devtype), info->vendor, info->product, info->revision); DBG (DBG_info, "Automatic Document Feeder: %s%s%s%s\n", info->hasADF ? "Installed " : "Not Installed ", info->hasSimplex ? "simplex" : "", info->hasDuplex ? "duplex" : "", info->hasARDF ? "reverse double-sided" : ""); DBG (DBG_info, "Endorser :%s\n", info->hasEndorser ? " " : " "); DBG (DBG_info, "Image Processing Unit:%s\n", info->hasIPU ? " " : " "); DBG (DBG_info, "Extended Board :%s\n", info->hasXBD ? " " : " "); DBG (DBG_info, "\n"); DBG (DBG_info, "Image Composition Support\n"); DBG (DBG_info, "Line Art (B/W) Support : %s\n", info->supports_lineart ? "Yes" : "No"); DBG (DBG_info, "Dithering (Halftone) Support: %s\n", info->supports_dithering ? "Yes" : "No"); DBG (DBG_info, "Error Diffusion Support : %s\n", info->supports_errordiffusion ? "Yes" : "No"); DBG (DBG_info, "Color Support : %s\n", info->supports_color ? "Yes" : "No"); DBG (DBG_info, "4 Bit Gray Support : %s\n", info->supports_4bitgray ? "Yes" : "No"); DBG (DBG_info, "5-8 Bit Gray Support : %s\n", info->supports_8bitgray ? "Yes" : "No"); DBG (DBG_info, "Image Data processing:%s%s%s%s%s%s\n", info->supports_whiteframing ? " " : "", info->supports_blackframing ? " " : "", info->supports_edgeextraction ? " " : "", info->supports_noiseremoval ? " " : "", info->supports_smoothing ? " " : "", info->supports_linebolding ? " " : ""); DBG (DBG_info, "Image Compression:%s%s%s%s\n", info->supports_MH ? " " : "", info->supports_MR ? " " : "", info->supports_MMR ? " " : "", info->supports_MHB ? " " : ""); DBG (DBG_info, "Marker Recognition: %s\n", info->supports_markerrecognition ? "" : ""); DBG (DBG_info, "Size Recognition : %s\n", info->supports_sizerecognition ? "" : ""); DBG (DBG_info, "X Maximum Output Pixels = %d\n", info->xmaxoutputpixels); /* DBG (DBG_info, "Optional Features:%s%s%s%s\n", info->canBorderRecog ? " " : "", info->canBarCode ? " " : "", info->canIcon ? " " : "", info->canSection ? "
" : ""); */ DBG (DBG_info, "Max bytes per scan-line: %d (%d pixels)\n", info->xmaxoutputpixels / 8, info->xmaxoutputpixels); DBG (DBG_info, "Basic resolution (X/Y) : %d/%d\n", info->resBasicX, info->resBasicY); DBG (DBG_info, "Maximum resolution (X/Y) : %d/%d\n", info->resMaxX, info->resMaxY); DBG (DBG_info, "Minimum resolution (X/Y) : %d/%d\n", info->resMinX, info->resMinY); DBG (DBG_info, "Standard Resolutions:\n"); for (i = 1; i <= info->resStdList[0]; i++) DBG (DBG_info, " %d\n", info->resStdList[i]); DBG (DBG_info, "Window Width/Height (in basic res) %d/%d (%.2f/%.2f inches)\n", info->winWidth, info->winHeight, (info->resBasicX != 0) ? ((float) info->winWidth) / info->resBasicX : 0.0, (info->resBasicY) ? ((float) info->winHeight) / info->resBasicY : 0.0); /* DBG (DBG_info, "Summary:%s%s%s\n", info->canDuplex ? "Duplex Scanner" : "Simplex Scanner", info->canACE ? " (ACE capable)" : "", info->canCheckADF ? " (ADF Paper Sensor capable)" : ""); */ DBG (DBG_info, "Buffer Full Ratio = %#02x\n", info->cxn.buffer_full_ratio); DBG (DBG_info, "Buffer Empty Ratio = %#02x\n", info->cxn.buffer_empty_ratio); DBG (DBG_info, "Bus Inactive Limit = %#02x\n", info->cxn.bus_inactive_limit[0] << 8 | info->cxn. bus_inactive_limit[1]); DBG (DBG_info, "Disconnect Time Limit = %#04x\n", info->cxn.disconnect_time_limit[0] << 8 | info->cxn. disconnect_time_limit[1]); DBG (DBG_info, "Connect Time Limit = %#02x\n", info->cxn.connect_time_limit[0] << 8 | info->cxn. connect_time_limit[1]); DBG (DBG_info, "Maximum Burst Size = %#04x\n", info->cxn.maximum_burst_size[0] << 8 | info->cxn. maximum_burst_size[1]); DBG (DBG_info, "DTDC = %#02x\n", info->cxn.dtdc & 0x03); DBG (DBG_info, "White Balance is %s\n", info->white_balance == 1 ? "Absolute" : "Relative"); DBG (DBG_info, "Medium Wait Timer is \n"); /* get_medium_wait_timer(fd) */ DBG (DBG_info, "Scan Wait Mode is %s\n", info->scan_wait_mode == 0 ? "OFF" : "ON"); DBG (DBG_info, "Service Mode is in Select %s Mode\n", info->service_mode == 0 ? "Self-Diagnostics" : "Optical Adjustment"); sprintf (info->inquiry_data, "Vendor: %s Product: %s Rev: %s %s%s\n", info->vendor, info->product, info->revision, info->hasADF && info->hasDuplex ? "Duplex Scanner" : "", info->hasADF && info->hasSimplex ? "Simplex Scanner" : ""); DBG (DBG_info, "duplex_default=%d\n", info->default_duplex); /* DBG (DBG_info, "autoborder_default=%d\n", info->autoborder_default); DBG (DBG_info, "batch_default=%d\n", info->batch_default); DBG (DBG_info, "deskew_default=%d\n", info->deskew_default); DBG (DBG_info, "check_adf_default=%d\n", info->check_adf_default); DBG (DBG_info, "timeout_adf_default=%d\n", info->timeout_adf_default); DBG (DBG_info, "timeout_manual_default=%d\n", info->timeout_manual_default); DBG (DBG_info, "control_panel_default=%d\n", info->control_panel_default); */ DBG (DBG_info, "bmu = %d\n", info->bmu); DBG (DBG_info, "mud = %d\n", info->mud); DBG (DBG_info, "white balance = %#0x\n", info->white_balance); DBG (DBG_info, "adf control = %#0x\n", info->adf_control); DBG (DBG_info, "adf mode control = %#0x\n", info->adf_mode_control); DBG (DBG_info, "endorser control = %#0x\n", info->endorser_control); DBG (DBG_info, "endorser string = %s\n", info->endorser_string); DBG (DBG_info, "scan wait mode = %#0x\n", info->scan_wait_mode); DBG (DBG_info, "service mode = %#0x\n", info->service_mode); DBG (DBG_info, "BasicXRes = %d\n", info->resBasicX); DBG (DBG_info, "BasicYRes = %d\n", info->resBasicY); DBG (DBG_info, "XResStep = %d\n", info->resXstep); DBG (DBG_info, "YResStep = %d\n", info->resYstep); DBG (DBG_info, "MaxXres = %d\n", info->resMaxX); DBG (DBG_info, "MaxYres = %d\n", info->resMaxY); DBG (DBG_info, "MinXres = %d\n", info->resMinX); DBG (DBG_info, "MinYres = %d\n", info->resMinY); DBG (DBG_info, "Width = %d\n", info->winWidth); DBG (DBG_info, "Height = %d\n", info->winHeight); DBG (DBG_info, "<< ScannerDump\n"); } static void print_vpd_info (struct inquiry_vpd_data *vbuf) { DBG (DBG_info, "VPD IDENTIFIER C0H\n"); DBG (DBG_info, "[00] Peripheral %#02x\n", vbuf->devtype); DBG (DBG_info, "[01] Page Code %#02x\n", vbuf->pagecode); DBG (DBG_info, "[02] reserved %#02x\n", vbuf->byte2); DBG (DBG_info, "[03] Page Length %#02x\n", vbuf->pagelength); DBG (DBG_info, "[04] ADF ID %#02x\n", vbuf->adf_id); DBG (DBG_info, "[05] Endorser ID %#02x\n", vbuf->end_id); DBG (DBG_info, "[06] Image Processing Unit %#02x\n", vbuf->ipu_id); DBG (DBG_info, "[07] Image Composition %#02x\n", vbuf->imagecomposition); DBG (DBG_info, "[08] Image Data Processing %lu\n", _2btol (&vbuf->imagedataprocessing[0])); DBG (DBG_info, "[10] Compression %#02x\n", vbuf->compression); DBG (DBG_info, "[11] Marker Recognition %#02x\n", vbuf->markerrecognition); DBG (DBG_info, "[12] Size Recognition %#02x\n", vbuf->sizerecognition); DBG (DBG_info, "[13] reserved %#02x\n", vbuf->byte13); DBG (DBG_info, "[14] X Maximum Output Pixel %lu\n", _2btol (&vbuf->xmaxoutputpixels[0])); } static void print_jis_info (struct inquiry_jis_data *jbuf) { DBG (DBG_info, "JIS IDENTIFIER F0H\n"); DBG (DBG_info, "[00] devtype %#02x\n", jbuf->devtype); DBG (DBG_info, "[01] Page Code %#02x\n", jbuf->pagecode); DBG (DBG_info, "[02] JIS Ver %#02x\n", jbuf->jisversion); DBG (DBG_info, "[03] reserved1 %#02x\n", jbuf->reserved1); DBG (DBG_info, "[04] Page Len %#02x\n", jbuf->alloclen); DBG (DBG_info, "[05] BasicXRes %lu\n", _2btol (&jbuf->BasicRes.x[0])); DBG (DBG_info, "[07] BasicYRes %lu\n", _2btol (&jbuf->BasicRes.y[0])); DBG (DBG_info, "[09] Resolution step %#02x\n", jbuf->resolutionstep); DBG (DBG_info, "[10] MaxXRes %lu\n", _2btol (&jbuf->MaxRes.x[0])); DBG (DBG_info, "[12] MaxYRes %lu\n", _2btol (&jbuf->MaxRes.y[0])); DBG (DBG_info, "[14] MinXRes %lu\n", _2btol (&jbuf->MinRes.x[0])); DBG (DBG_info, "[16] MinYRes %lu\n", _2btol (&jbuf->MinRes.y[0])); DBG (DBG_info, "[18] Std Res %#0x\n", (jbuf->standardres[0] << 8) | jbuf->standardres[1]); DBG (DBG_info, "[20] Win Width %lu\n", _4btol (&jbuf->Window.width[0])); /* Manual says 4787/12B3H pixels @400dpi = 12in */ DBG (DBG_info, "[24] Win Len %lu\n", _4btol (&jbuf->Window.length[0])); /* Manual says 6803/1A93H pixels @400dpi = 17in) */ DBG (DBG_info, "[28] function %#02x\n", jbuf->functions); DBG (DBG_info, "[29] reserved %#02x\n", jbuf->reserved2); } /* 1-3-1 TEST UNIT READY Byte0: | 0x00 | Byte1: | 7-5 Logical Unit Number | Reserved | Byte2: | Reserved | Byte3: | Reserved | Byte4: | Reserved | Byte5: | 7-6 Vendor Unique | 5-2 Reserved | 1 Flag | 0 Link | */ static SANE_Status test_unit_ready (int fd) { static SANE_Byte cmd[6]; SANE_Status status; DBG (DBG_proc, ">> test_unit_ready\n"); memset (cmd, 0, sizeof (cmd)); cmd[0] = HS2P_SCSI_TEST_UNIT_READY; status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), 0, 0); DBG (DBG_proc, "<< test_unit_ready\n"); return (status); } /* 1-3-2 REQUEST SENSE Byte0: | 0x00 | Byte1: | 7-5 Logical Unit Number | Reserved | Byte2: | Reserved | Byte3: | Reserved | Byte4: | Allocation Length | Byte5: | 7-6 Vendor Unique | 5-2 Reserved | 1 Flag | 0 Link | */ #if 0 static SANE_Status get_sense_data (int fd, SENSE_DATA * sense_data) { SANE_Status status; DBG (DBG_sane_proc, ">> get_sense_data\n"); static SANE_Byte cmd[6]; size_t len; len = sizeof (*sense_data); memset (sense_data, 0, len); memset (cmd, 0, sizeof (cmd)); cmd[0] = HS2P_SCSI_REQUEST_SENSE; cmd[4] = len; status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), sense_data, &len); DBG (DBG_proc, "<< get_sense_data\n"); return (status); } #endif static SANE_Status print_sense_data (int dbg_level, SENSE_DATA * data) { SANE_Status status = SANE_STATUS_GOOD; SANE_Byte *bp, *end; SANE_Int i; DBG (DBG_sane_proc, ">> print_sense_data\n"); bp = (SANE_Byte *) data; end = bp + (SANE_Byte) sizeof (SENSE_DATA); for (i = 0; bp < end; bp++, i++) { DBG (dbg_level, "Byte #%2d is %3d, 0x%02x\n", i, *bp, *bp); } DBG (dbg_level, "Valid=%1d, ErrorCode=%#x\n", (data->error_code & 0x80) >> 7, data->error_code & 0x7F); DBG (dbg_level, "Segment number = %d\n", data->segment_number); DBG (dbg_level, "F-mark=%1d, EOM=%1d, ILI=%1d, Reserved=%1d, SenseKey=%#x\n", (data->sense_key & 0x80) >> 7, (data->sense_key & 0x40) >> 6, (data->sense_key & 0x20) >> 5, (data->sense_key & 0x10) >> 4, (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 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", data->sense_code_qualifier); DBG (DBG_proc, "<< print_sense_data\n"); return (status); } static struct sense_key * lookup_sensekey_errmsg (int code) { int i; struct sense_key *k = &sensekey_errmsg[0]; for (i = 0; i < 16; i++, k++) if (k->key == code) return k; return NULL; } static struct ASCQ * lookup_ascq_errmsg (unsigned int code) { unsigned int i; struct ASCQ *k = &ascq_errmsg[0]; for (i = 0; i < 74; i++, k++) if (k->codequalifier == code) return k; return NULL; } /* a sensible sense handler arg is a pointer to the associated HS2P_Scanner structure SENSE DATA FORMAT: 14 bytes bits[7-0] Byte 0: [7]:valid [6-0]:Error Code Byte 1: Segment Number Byte 2: [7]: F-mark; [6]:EOM; [5]:ILI; [4]:reserved; [3-0]:Sense Key Byte 3: Information Byte Byte 4: Information Byte Byte 5: Information Byte Byte 6: Information Byte Byte 7: Additional Sense Length (n-7) Byte 8: Command Specific Information Byte 9: Command Specific Information Byte 10: Command Specific Information Byte 11: Command Specific Information Byte 12: Additional Sense Code Byte 13: Additional Sense Code Qualifier */ static SANE_Status sense_handler (int __sane_unused__ scsi_fd, u_char * sense_buffer, void *sd) { u_char sense, asc, ascq, EOM, ILI, ErrorCode, ValidData; u_long MissingBytes; char *sense_str = ""; struct sense_key *skey; struct ASCQ *ascq_key; SENSE_DATA *sdp = (SENSE_DATA *) sd; SANE_Int i; SANE_Status status = SANE_STATUS_INVAL; SANE_Char print_sense[(16 * 3) + 1]; DBG (DBG_proc, ">> sense_handler\n"); if (DBG_LEVEL >= DBG_info) print_sense_data (DBG_LEVEL, (SENSE_DATA *) sense_buffer); /* store sense_buffer */ DBG (DBG_info, ">> copying %lu bytes from sense_buffer[] to sense_data\n", (u_long) sizeof (SENSE_DATA)); memcpy (sdp, sense_buffer, sizeof (SENSE_DATA)); if (DBG_LEVEL >= DBG_info) print_sense_data (DBG_LEVEL, sdp); ErrorCode = sense_buffer[0] & 0x7F; ValidData = (sense_buffer[0] & 0x80) != 0; sense = sense_buffer[2] & 0x0f; /* Sense Key */ asc = sense_buffer[12]; /* Additional Sense Code */ ascq = sense_buffer[13]; /* Additional Sense Code Qualifier */ EOM = (sense_buffer[2] & 0x40) != 0; /* End Of Media */ ILI = (sense_buffer[2] & 0x20) != 0; /* Invalid Length Indicator */ MissingBytes = ValidData ? _4btol (&sense_buffer[3]) : 0; DBG (DBG_sense, "sense_handler: sense_buffer=%#x, sense=%#x, asc=%#x, ascq=%#x\n", sense_buffer[0], sense, asc, ascq); DBG (DBG_sense, "sense_handler: ErrorCode %02x ValidData: %d " "EOM: %d ILI: %d MissingBytes: %lu\n", ErrorCode, ValidData, EOM, ILI, MissingBytes); memset (print_sense, '\0', sizeof (print_sense)); for (i = 0; i < 16; i++) sprintf (print_sense + strlen (print_sense), "%02x ", sense_buffer[i]); DBG (DBG_sense, "sense_handler: sense=%s\n", print_sense); if (ErrorCode != 0x70 && ErrorCode != 0x71) { DBG (DBG_error, "sense_handler: error code is invalid.\n"); return SANE_STATUS_IO_ERROR; /* error code is invalid */ } skey = lookup_sensekey_errmsg (sense); /* simple sequential search */ DBG (DBG_sense, "sense_handler: sense_key=%#x '%s - %s'\n", skey->key, skey->meaning, skey->description); DBG (DBG_sense, "Looking up ascq=(%#x,%#x)=%#x\n", asc, ascq, (asc << 8) | ascq); ascq_key = lookup_ascq_errmsg ((asc << 8) | ascq); /* simple sequential search */ DBG (DBG_sense, "sense_handler: ascq=(%#x,%#x): %#x '%s'\n", asc, ascq, ascq_key->codequalifier, ascq_key->description); /* handle each sense key: Translate from HS2P message to SANE_STATUS_ message * SANE_STATUS_GOOD, _ACCESS_DEINIED, _NO_MEM, _INVAL, _IO_ERROR, _DEVICE_BUSY, * _EOF, _UNSUPPORTED, _CANCELLED, _JAMMED, _NO_DOCS, _COVER_OPEN */ switch (sense) { case 0x00: /* no sense */ status = SANE_STATUS_GOOD; break; case 0x01: /* recovered error */ status = SANE_STATUS_INVAL; break; case 0x02: /* not ready */ status = SANE_STATUS_DEVICE_BUSY; break; case 0x03: /* medium error */ status = SANE_STATUS_JAMMED; break; case 0x04: /* hardware error */ status = SANE_STATUS_IO_ERROR; break; case 0x05: /* illegal request */ status = SANE_STATUS_INVAL; break; case 0x06: /* unit attention */ status = SANE_STATUS_GOOD; break; case 0x07: /* data protect */ status = SANE_STATUS_INVAL; break; case 0x08: /* blank check */ status = SANE_STATUS_INVAL; break; case 0x09: /* vendor specific */ status = SANE_STATUS_INVAL; break; case 0x0A: /* copy aborted */ status = SANE_STATUS_CANCELLED; break; case 0x0B: /* aborted command */ status = SANE_STATUS_CANCELLED; break; case 0x0C: /* equal */ status = SANE_STATUS_INVAL; break; case 0x0D: /* volume overflow */ status = SANE_STATUS_INVAL; break; case 0x0E: /* miscompare */ status = SANE_STATUS_INVAL; break; case 0x0F: /* reserved */ status = SANE_STATUS_INVAL; break; } if (ErrorCode == 0x70) /* Additional Sense Codes available */ switch ((asc << 8) | ascq) { case 0x0000: /* No additional Information */ status = SANE_STATUS_GOOD; break; case 0x0002: /* End of Medium */ status = SANE_STATUS_NO_DOCS; break; case 0x0005: /* End of Data */ status = SANE_STATUS_EOF; break; case 0x0400: /* LUN not ready */ status = SANE_STATUS_DEVICE_BUSY; break; case 0x0401: /* LUN becoming ready */ status = SANE_STATUS_DEVICE_BUSY; break; case 0x0403: /* LUN not ready. Manual intervention needed */ status = SANE_STATUS_IO_ERROR; break; case 0x0500: /* LUN doesn't respond to selection */ status = SANE_STATUS_INVAL; break; case 0x0700: /* Multiple peripheral devices selected */ status = SANE_STATUS_INVAL; break; case 0x1100: /* Unrecovered read error */ status = SANE_STATUS_IO_ERROR; break; case 0x1101: /* Read retries exhausted */ status = SANE_STATUS_IO_ERROR; break; case 0x1501: /* Mechanical positioning error */ status = SANE_STATUS_IO_ERROR; break; case 0x1A00: /* Parameter list length error */ status = SANE_STATUS_INVAL; break; case 0x2000: /* Invalid command operation code */ status = SANE_STATUS_INVAL; break; case 0x2400: /* Invalid field in CDB (check field pointer) */ status = SANE_STATUS_INVAL; break; case 0x2500: /* LUN not supported */ status = SANE_STATUS_UNSUPPORTED; break; case 0x2600: /* Invalid field in parameter list (check field pointer) */ status = SANE_STATUS_INVAL; break; case 0x2900: /* Power on, reset, or BUS DEVICE RESET occurred */ status = SANE_STATUS_GOOD; break; case 0x2A01: /* (MODE parameter changed) */ status = SANE_STATUS_INVAL; break; case 0x2C00: /* Command sequence error */ status = SANE_STATUS_INVAL; break; case 0x2C01: /* Too many windows specified */ status = SANE_STATUS_INVAL; break; case 0x2C02: /* Invalid combination of windows specified */ status = SANE_STATUS_INVAL; break; case 0x3700: /* (Rounded paramter) */ status = SANE_STATUS_INVAL; break; case 0x3900: /* (Saving parameters not supported) */ status = SANE_STATUS_INVAL; break; case 0x3A00: /* Medium not present */ status = SANE_STATUS_NO_DOCS; break; case 0x3B09: /* Read past end of medium */ status = SANE_STATUS_EOF; break; case 0x3B0B: /* Position past end of medium */ status = SANE_STATUS_EOF; break; case 0x3D00: /* Invalid bits in IDENTIFY message */ status = SANE_STATUS_INVAL; break; case 0x4300: /* Message error */ status = SANE_STATUS_INVAL; break; case 0x4500: /* Select/Reselect failure */ status = SANE_STATUS_IO_ERROR; break; case 0x4700: /* (SCSI parity error) */ status = SANE_STATUS_IO_ERROR; break; case 0x4800: /* Initiator detected error message received */ status = SANE_STATUS_IO_ERROR; break; case 0x4900: /* Invalid message error */ status = SANE_STATUS_INVAL; break; case 0x4B00: /* Data phase error */ status = SANE_STATUS_IO_ERROR; break; case 0x5300: /* (Media Load/Eject failed) */ status = SANE_STATUS_IO_ERROR; break; case 0x6000: /* Lamp failure */ status = SANE_STATUS_IO_ERROR; break; case 0x6001: /* Shading error */ status = SANE_STATUS_IO_ERROR; break; case 0x6002: /* White adjustment error */ status = SANE_STATUS_IO_ERROR; break; case 0x6010: /* Reverse Side Lamp Failure */ status = SANE_STATUS_IO_ERROR; break; case 0x6200: /* Scan head positioning error */ status = SANE_STATUS_IO_ERROR; break; case 0x6300: /* Document Waiting Cancel */ status = SANE_STATUS_CANCELLED; break; case 0x8000: /* (PSU over heate) */ status = SANE_STATUS_IO_ERROR; break; case 0x8001: /* (PSU 24V fuse down) */ status = SANE_STATUS_IO_ERROR; break; case 0x8002: /* (ADF 24V fuse down) */ status = SANE_STATUS_IO_ERROR; break; case 0x8003: /* (5V fuse down) */ status = SANE_STATUS_IO_ERROR; break; case 0x8004: /* (-12V fuse down) */ status = SANE_STATUS_IO_ERROR; break; case 0x8100: /* (ADF 24V power off) */ status = SANE_STATUS_IO_ERROR; break; case 0x8102: /* (Base 12V power off) */ status = SANE_STATUS_IO_ERROR; break; case 0x8103: /* Lamp cover open (Lamp 24V power off) */ status = SANE_STATUS_IO_ERROR; break; case 0x8104: /* (-12V power off) */ status = SANE_STATUS_IO_ERROR; break; case 0x8105: /* (Endorser 6V power off) */ status = SANE_STATUS_IO_ERROR; break; case 0x8106: /* SCU 3.3V power down error */ status = SANE_STATUS_IO_ERROR; break; case 0x8107: /* RCU 3.3V power down error */ status = SANE_STATUS_IO_ERROR; break; case 0x8108: /* OIPU 3.3V power down error */ status = SANE_STATUS_IO_ERROR; break; case 0x8200: /* Memory Error (Bus error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8210: /* Reverse-side memory error (Bus error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8300: /* (Image data processing LSI error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8301: /* (Interface LSI error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8302: /* (SCSI controller error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8303: /* (Compression unit error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8304: /* (Marker detect unit error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8400: /* Endorser error */ status = SANE_STATUS_IO_ERROR; break; case 0x8500: /* (Origin Positioning error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8600: /* Mechanical Time Out error (Pick Up Roller error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8700: /* (Heater error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8800: /* (Thermistor error) */ status = SANE_STATUS_IO_ERROR; break; case 0x8900: /* ADF cover open */ status = SANE_STATUS_COVER_OPEN; break; case 0x8901: /* (ADF lift up) */ status = SANE_STATUS_COVER_OPEN; break; case 0x8902: /* Document jam error for ADF */ status = SANE_STATUS_JAMMED; break; case 0x8903: /* Document misfeed for ADF */ status = SANE_STATUS_JAMMED; break; case 0x8A00: /* (Interlock open) */ status = SANE_STATUS_COVER_OPEN; break; case 0x8B00: /* (Not enough memory) */ status = SANE_STATUS_NO_MEM; break; case 0x8C00: /* Size Detection failed */ status = SANE_STATUS_IO_ERROR; break; default: /* Should never get here */ status = SANE_STATUS_INVAL; DBG (DBG_sense, "sense_handler: 'Undocumented code': ascq=(%#x,%#x)\n", asc & 0xFF00, ascq & 0x00FF); break; } DBG (DBG_proc, "sense_handler %s: '%s'-'%s' '%s' return:%d\n", sense_str, skey->meaning, skey->description, ascq_key->description, status); return status; } /* VPD IDENTIFIER Page Code 0x00 * A list of all Page Codes supported by scanner is returned as data * Byte0 => bit7-5: Peripheral Qualifier, bits4-0: Peripheral Device Type * Byte1 => Page Code of CDB is set as Page Code 0 * Byte2 => Reserved * Byte3 => Page Length is 2 because scanner supports just two page codes: C0H and F0H * Byte4 => First Support Page Code * Byte5 => Second Support Page Code */ #if 0 static SANE_Status vpd_indentifier_00H (int fd) { static SANE_Byte cmd[6]; SANE_Status status; DBG (DBG_proc, ">> vpd_identifier_00H\n"); cmd[0] = HS2P_SCSI_REQUEST_SENSE; memset (cmd, 0, sizeof (cmd)); status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), 0, 0); DBG (DBG_proc, "<< vpd_identifier_00H\n"); return (status); } #endif #if 0 static SANE_Status vpd_identifier_C0H (int fd) { static SANE_Byte cmd[6]; SANE_Status status; DBG (DBG_proc, ">> vpd_identifier_C0H\n"); cmd[0] = HS2P_SCSI_REQUEST_SENSE; memset (cmd, 0, sizeof (cmd)); status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), 0, 0); DBG (DBG_proc, "<< vpd_identifier_C0H\n"); return (status); } #endif /* 1-3-3 INQUIRY : 6 bytes: * Byte0 => 0x12 * Byte1 => bits7-5: Logical Unit number * bits4-1: Reserved * bit0: EVPD * Byte2 => Page Code * Byte3 => Reserved * Byte4 => Allocation Length * Byte5 => bits7-6: Vendor Unique * bits5-2: Reserved * bit1: Flag * bit0: Link */ static SANE_Status inquiry (int fd, void *buf, size_t * buf_size, SANE_Byte evpd, SANE_Byte page_code) { static SANE_Byte cmd[6]; SANE_Status status; DBG (DBG_proc, ">> inquiry\n"); memset (cmd, 0, sizeof (cmd)); cmd[0] = HS2P_SCSI_INQUIRY; cmd[1] = evpd; cmd[2] = page_code; /*cmd[3] Reserved */ cmd[4] = *buf_size; /*cmd[5] vendorunique+reserved+flag+link */ status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), buf, buf_size); DBG (DBG_proc, "<< inquiry\n"); return (status); } /* 1-3-6 MODE SELECT -- sets various operation mode parameters for scanner */ static SANE_Status mode_select (int fd, MP * settings) { static struct { SELECT cmd; /* Mode page Select command */ MP mp; /* Hdr + Parameters */ } msc; /* Mode Select Command */ SANE_Status status; size_t npages; DBG (DBG_proc, ">> mode_select\n"); memset (&msc, 0, sizeof (msc)); /* Fill struct with zeros */ msc.cmd.opcode = HS2P_SCSI_MODE_SELECT; /* choose Mode Select Command */ msc.cmd.byte1 &= ~SMS_SP; /* unset bit0 SavePage to 0 */ msc.cmd.byte1 |= SMS_PF; /* set bit4 PageFormat to 1 */ npages = (settings->page.code == 2) ? 16 : 8; msc.cmd.len = sizeof (msc.mp.hdr) + npages; /* either 4+8 or 4+20 */ memcpy (&msc.mp, settings, msc.cmd.len); /* Copy hdr+pages from Settings to msc.mp */ memset (&msc.mp.hdr, 0, sizeof (msc.mp.hdr)); /* make sure the hdr is all zeros */ /* msc.hdr.data_len = 0x00; msc.hdr.medium_type = 0x00; msc.hdr.dev_spec = 0x00; msc.hdr.blk_desc_len = 0x00; */ /* Now execute the whole command */ if ((status = sanei_scsi_cmd (fd, &msc, sizeof (msc.cmd) + msc.cmd.len, 0, 0)) != SANE_STATUS_GOOD) { DBG (DBG_error, "ERROR: mode_select: %s\n", sane_strstatus (status)); DBG (DBG_error, "PRINTING CMD BLOCK:\n"); print_bytes (&msc.cmd, sizeof (msc.cmd)); DBG (DBG_error, "PRINTING MP HEADER:\n"); print_bytes (&msc.mp.hdr, sizeof (msc.mp.hdr)); DBG (DBG_error, "PRINTING MP PAGES:\n"); print_bytes (&msc.mp.page, msc.cmd.len); } DBG (DBG_proc, "<< mode_select\n"); return (status); } /* 1-3-7 MODE SENSE -- gets various operation mode parameters from scanner */ static SANE_Status mode_sense (int fd, MP * buf, SANE_Byte page_code) { SANE_Status status; SENSE cmd; /* 6byte cmd */ MP msp; /* Mode Sense Page * 4byte hdr + {2bytes +14 bytes} * buffer to hold mode sense data gotten from scanner */ size_t nbytes; DBG (DBG_proc, ">>>>> mode_sense: fd=%d, page_code=%#02x\n", fd, page_code); nbytes = sizeof (msp); DBG (DBG_info, ">>>>> mode_sense: Zero'ing ModeSenseCommand msc and msp structures\n"); memset (&cmd, 0, sizeof (cmd)); /* Fill cmd struct with zeros */ memset (&msp, 0, sizeof (msp)); /* Fill msp struct with zeros */ /* set up Mode Sense Command */ DBG (DBG_info, ">>>>> mode_sense: Initializing Mode Sense cmd\n"); cmd.opcode = HS2P_SCSI_MODE_SENSE; cmd.dbd &= ~(1 << 3); /* Disable Block Description (bit3) is set to 0 */ cmd.pc = (page_code & 0x3F); /* bits 5-0 */ cmd.pc &= ~(0x03 << 6); /* unset PC Field (bits7-6) * 00 Curent Value is the only effective value * 01 Changeable Value * 10 Default Value * 11 Saved Value */ /* cmd.len = ??? Allocation Length */ /* Now execute the whole command and store results in msc */ DBG (DBG_info, ">>>>> mode_sense: sanei_scsi_cmd\n"); DBG (DBG_info, ">>>>> cmd.opcode=%#0x cmd.dbd=%#02x, cmd.pc=%#02x\n", cmd.opcode, cmd.dbd, cmd.pc); nbytes = (page_code == 2) ? 20 : 12; DBG (DBG_info, ">>>>> sizeof(cmd)=%lu sizeof(msp)=%lu sizeof(hdr)=%lu sizeof(page)=%lu requesting %lu bytes\n", (u_long) sizeof (cmd), (u_long) sizeof (msp), (u_long) sizeof (msp.hdr), (u_long) sizeof (msp.page), (u_long) nbytes); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), &msp, &nbytes); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "ERROR mode_sense: sanei_scsi_cmd error \"%s\"\n", sane_strstatus (status)); DBG (DBG_error, ">>>>> mode sense: number of bytes received from scanner: %lu\n", (u_long) nbytes); DBG (DBG_error, "PRINTING CMD BLOCK:\n"); print_bytes (&cmd, sizeof (cmd)); DBG (DBG_error, "PRINTING MP HEADER:\n"); print_bytes (&msp.hdr, sizeof (msp.hdr)); DBG (DBG_error, "PRINTING MP PAGES:\n"); print_bytes (&msp.page, sizeof (msp.page)); } else { /* nbytes = (page_code==2)? 14 : 6; */ DBG (DBG_info, ">> >> got %lu bytes from scanner\n", (u_long) nbytes); nbytes -= 4; /* we won't copy 4 byte hdr */ DBG (DBG_info, ">>>>> copying from msp to calling function's buf\n" ">>>>> msp.page_size=%lu bytes=%lu buf_size=%lu\n", (u_long) sizeof (msp.page), (u_long) nbytes, (u_long) sizeof (*buf)); memcpy (buf, &(msp.page), nbytes); } DBG (DBG_proc, "<<<<< mode_sense\n"); return (status); } static SANE_Status set_window (int fd, SWD * swd) { static struct { struct set_window_cmd cmd; struct set_window_data swd; } win; SANE_Status status; static size_t wdl, tl; /*window descriptor length, transfer length */ DBG (DBG_proc, ">> set_window\n"); /* initialize our struct with zeros */ memset (&win, 0, sizeof (win)); /* fill in struct with opcode */ win.cmd.opcode = HS2P_SCSI_SET_WINDOW; /* bytes 1-5 are reserved */ /* Transfer length is header + window data */ tl = sizeof (*swd); _lto3b (tl, &win.cmd.len[0]); /* 8 + (2*320) = 648 */ DBG (DBG_info, "set_window: SET WINDOW COMMAND Transfer Length = %lu (should be 648)\n", (unsigned long) tl); /* Copy data from swd (including 8-byte header) to win.swd */ DBG (DBG_info, "set_window: COPYING %lu bytes from settings to Set Window Command (%lu)\n", (u_long) sizeof (*swd), (u_long) sizeof (win.swd)); if (!memcpy (&(win.swd), swd, sizeof (*swd))) { DBG (DBG_error, "set_window: error with memcpy\n"); } /* Set Window Data Header: 0-5:reserved; 6-7:Window Descriptor Lenght=640 */ wdl = sizeof (win.swd) - sizeof (win.swd.hdr); _lto2b (wdl, &win.swd.hdr.len[0]); DBG (DBG_info, "set_window: SET WINDOW COMMAND Window Descriptor Length = %lu (should be 640)\n", (unsigned long) wdl); /* Now execute command */ DBG (DBG_info, "set_window: calling sanei_scsi_cmd(%d,&win,%lu, NULL, NULL)\n", fd, (u_long) sizeof (win)); status = sanei_scsi_cmd (fd, &win, sizeof (win), NULL, NULL); /* status = sanei_scsi_cmd2 (fd, &win.cmd, sizeof(win.cmd), &win.swd, sizeof(win.swd), NULL, NULL); */ if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "*********************\n"); DBG (DBG_error, "ERROR: set_window: %s\n", sane_strstatus (status)); DBG (DBG_error, "PRINTING SWD CMD BLK:\n"); print_bytes (&win.cmd, sizeof (win.cmd)); DBG (DBG_error, "PRINTING SWD HEADER:\n"); print_bytes (&win.swd.hdr, sizeof (win.swd.hdr)); DBG (DBG_error, "PRINTING SWD DATA[0]:\n"); print_bytes (&win.swd.data[0], sizeof (win.swd.data[0])); DBG (DBG_error, "PRINTING SWD DATA[1]:\n"); print_bytes (&win.swd.data[1], sizeof (win.swd.data[1])); DBG (DBG_error, "*********************\n"); } DBG (DBG_proc, "<< set_window\n"); return (status); } static SANE_Status get_window (int fd, GWD * gwd) { struct get_window_cmd cmd; SANE_Status status; static size_t gwd_size; DBG (DBG_proc, ">> get_window\n"); gwd_size = sizeof (*gwd); DBG (DBG_info, ">> get_window datalen = %lu\n", (unsigned long) gwd_size); /* fill in get_window_cmd */ memset (&cmd, 0, sizeof (cmd)); /* CLEAR cmd */ cmd.opcode = HS2P_SCSI_GET_WINDOW; cmd.byte1 &= ~0x01; /* unset single bit 0 */ cmd.win_id = 0x00; /* either 0 or 1 */ _lto3b (gwd_size, cmd.len); /* Transfer Length is byte length of DATA to be returned */ status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), gwd, &gwd_size); DBG (DBG_proc, "<< get_window, datalen = %lu\n", (unsigned long) gwd_size); return (status); } static void print_window_data (SWD * buf) { int i, j, k; struct hs2p_window_data *data; struct window_section *ws; DBG (DBG_proc, ">> print_window_data\n"); DBG (DBG_info, "HEADER\n"); for (i = 0; i < 6; i++) DBG (DBG_info, "%#02x\n", buf->hdr.reserved[i]); DBG (DBG_info, "Window Descriptor Length=%lu\n\n", _2btol (buf->hdr.len)); for (i = 0; i < 2; i++) { data = &buf->data[i]; DBG (DBG_info, "Window Identifier = %d\n", data->window_id); DBG (DBG_info, "AutoBit = %#x\n", data->auto_bit); DBG (DBG_info, "X-Axis Resolution = %lu\n", _2btol (data->xres)); DBG (DBG_info, "Y-Axis Resolution = %lu\n", _2btol (data->yres)); DBG (DBG_info, "X-Axis Upper Left = %lu\n", _4btol (data->ulx)); DBG (DBG_info, "Y-Axis Upper Left = %lu\n", _4btol (data->uly)); DBG (DBG_info, "Window Width = %lu\n", _4btol (data->width)); DBG (DBG_info, "Window Length = %lu\n", _4btol (data->length)); DBG (DBG_info, "Brightness = %d\n", data->brightness); DBG (DBG_info, "Threshold = %d\n", data->threshold); DBG (DBG_info, "Contrast = %d\n", data->contrast); DBG (DBG_info, "Image Composition = %#0x\n", data->image_composition); DBG (DBG_info, "Bits per Pixel = %d\n", data->bpp); DBG (DBG_info, "Halftone Code = %#0x\n", data->halftone_code); DBG (DBG_info, "Halftone Id = %#0x\n", data->halftone_id); DBG (DBG_info, "Byte29 = %#0x RIF=%d PaddingType=%d\n", data->byte29, data->byte29 & 0x80, data->byte29 & 0x7); DBG (DBG_info, "Bit Ordering = %lu\n", _2btol (data->bit_ordering)); DBG (DBG_info, "Compression Type = %#x\n", data->compression_type); DBG (DBG_info, "Compression Arg = %#x\n", data->compression_arg); for (j = 0; j < 6; j++) DBG (DBG_info, "Reserved=%#x\n", data->reserved2[j]); DBG (DBG_info, "Ignored = %#x\n", data->ignored1); DBG (DBG_info, "Ignored = %#x\n", data->ignored2); DBG (DBG_info, "Byte42 = %#x MRIF=%d Filtering=%d GammaID=%d\n", data->byte42, data->byte42 & 0x80, data->byte42 & 0x70, data->byte42 & 0x0F); DBG (DBG_info, "Ignored = %#x\n", data->ignored3); DBG (DBG_info, "Ignored = %#x\n", data->ignored4); DBG (DBG_info, "Binary Filtering = %#x\n", data->binary_filtering); DBG (DBG_info, "Ignored = %#x\n", data->ignored5); DBG (DBG_info, "Ignored = %#x\n", data->ignored6); DBG (DBG_info, "Automatic Separation = %#x\n", data->automatic_separation); DBG (DBG_info, "Ignored = %#x\n", data->ignored7); DBG (DBG_info, "Automatic Binarization = %#x\n", data->automatic_binarization); for (j = 0; j < 13; j++) DBG (DBG_info, "Ignored = %#x\n", data->ignored8[j]); for (k = 0; k < 8; k++) { ws = &data->sec[k]; DBG (DBG_info, "\n\n"); DBG (DBG_info, "SECTION %d\n", k); DBG (DBG_info, "Section Enable Flat (sef bit) = %#x\n", ws->sef); DBG (DBG_info, "ignored = %d\n", ws->ignored0); DBG (DBG_info, "Upper Left X = %lu\n", _4btol (ws->ulx)); DBG (DBG_info, "Upper Left Y = %lu\n", _4btol (ws->uly)); DBG (DBG_info, "Width = %lu\n", _4btol (ws->width)); DBG (DBG_info, "Length = %lu\n", _4btol (ws->length)); DBG (DBG_info, "Binary Filtering = %#x\n", ws->binary_filtering); DBG (DBG_info, "ignored = %d\n", ws->ignored1); DBG (DBG_info, "Threshold = %#x\n", ws->threshold); DBG (DBG_info, "ignored = %d\n", ws->ignored2); DBG (DBG_info, "Image Composition = %#x\n", ws->image_composition); DBG (DBG_info, "Halftone Id = %#x\n", ws->halftone_id); DBG (DBG_info, "Halftone Code = %#x\n", ws->halftone_code); for (j = 0; j < 7; j++) DBG (DBG_info, "ignored = %d\n", ws->ignored3[j]); } } DBG (DBG_proc, "<< print_window_data\n"); } static SANE_Status read_data (int fd, void *buf, size_t * buf_size, SANE_Byte dtc, u_long dtq) { static struct scsi_rs_scanner_cmd cmd; SANE_Status status; DBG (DBG_proc, ">> read_data buf_size=%lu dtc=0x%2.2x dtq=%lu\n", (unsigned long) *buf_size, (int) dtc, dtq); if (fd < 0) { DBG (DBG_error, "read_data: scanner is closed!\n"); return SANE_STATUS_INVAL; } memset (&cmd, 0, sizeof (cmd)); /* CLEAR */ cmd.opcode = HS2P_SCSI_READ_DATA; cmd.dtc = dtc; _lto2b (dtq, cmd.dtq); _lto3b (*buf_size, cmd.len); DBG (DBG_info, "read_data ready to send scsi cmd\n"); DBG (DBG_info, "opcode=0x%2.2x, dtc=0x%2.2x, dtq=%lu, transfer len =%d\n", cmd.opcode, cmd.dtc, _2btol (cmd.dtq), _3btol (cmd.len)); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), buf, buf_size); if (status != SANE_STATUS_GOOD) DBG (DBG_error, "read_data: %s\n", sane_strstatus (status)); DBG (DBG_proc, "<< read_data %lu\n", (unsigned long) *buf_size); return (status); } #if 0 static SANE_Status send_data (int fd, void *buf, size_t * buf_size) { static struct scsi_rs_scanner_cmd cmd; SANE_Status status; DBG (DBG_proc, ">> send_data %lu\n", (unsigned long) *buf_size); memset (&cmd, 0, sizeof (cmd)); /* CLEAR */ memcpy (&cmd, buf, sizeof (*buf)); /* Fill in our struct with set values */ cmd.opcode = HS2P_SCSI_SEND_DATA; _lto3b (*buf_size, cmd.len); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), buf, buf_size); DBG (DBG_proc, "<< send_data %lu\n", (unsigned long) *buf_size); return (status); } #endif static SANE_Bool is_valid_endorser_character (char c) { int i = (int) c; /* 44 characters can be printed by endorser */ if (i >= 0x30 && i <= 0x3A) return SANE_TRUE; /* 0123456789: */ if (i == 0x23) return SANE_TRUE; /* # */ if (i == 0x27) return SANE_TRUE; /* ` */ if (i >= 0x2C && i <= 0x2F) return SANE_TRUE; /* '-./ */ if (i == 0x20) return SANE_TRUE; /* space */ if (i >= 0x41 && i <= 0x5A) return SANE_TRUE; /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */ if (i >= 0x61 && i <= 0x7A) return SANE_TRUE; /* abcdefghijklmnopqrstuvwxyz */ return SANE_FALSE; } static SANE_Status set_endorser_string (int fd, SANE_String s) { struct { struct scsi_rs_scanner_cmd cmd; SANE_Byte endorser[19]; } out; char *t; int i, len; SANE_Status status; DBG (DBG_proc, ">> set_endorser_string %s\n", s); for (i = 0, t = s; *t != '\0' && i < 19; i++) { DBG (DBG_info, "CHAR=%c\n", *t); if (!is_valid_endorser_character (*t++)) return SANE_STATUS_INVAL; } len = strlen (s); memset (&out, 0, sizeof (out)); /* CLEAR */ out.cmd.opcode = HS2P_SCSI_SEND_DATA; /* 2AH */ out.cmd.dtc = 0x80; /* Endorser Data */ _lto3b (len, &out.cmd.len[0]); /* 19 bytes max */ memset (&out.endorser[0], ' ', 19); /* fill with spaces */ memcpy (&out.endorser[0], s, len); status = sanei_scsi_cmd (fd, &out, sizeof (out), NULL, NULL); DBG (DBG_proc, "<< set_endorser_string s=\"%s\" len=%d\n", s, len); return (status); } static SANE_Status hs2p_send_gamma (HS2P_Scanner * s) { SANE_Status status; struct { struct scsi_rs_scanner_cmd cmd; SANE_Byte gamma[2 + GAMMA_LENGTH]; } out; int i; size_t len = sizeof (out.gamma); DBG (DBG_proc, ">> teco_send_gamma\n"); memset (&out, 0, sizeof (out)); /* CLEAR */ out.cmd.opcode = HS2P_SCSI_SEND_DATA; /* 2AH */ out.cmd.dtc = 0x03; /* Gamma Function Data */ _lto3b (len, &out.cmd.len[0]); /* 19 bytes max */ out.gamma[0] = 0x08; /* Gamma ID for Download table */ out.gamma[1] = 0x08; /* The Number of gray scale (M) = 8 */ for (i = 0; i < GAMMA_LENGTH; i++) { out.gamma[i + 2] = s->gamma_table[i]; } status = sanei_scsi_cmd (s->fd, &out, sizeof (out), NULL, NULL); DBG (DBG_proc, "<< teco_send_gamma\n"); return (status); } #if 0 static SANE_Status clear_maintenance_data (int fd, int code, char XorY, int number) { struct { struct scsi_rs_scanner_cmd cmd; char string[20]; } out; SANE_Status status; DBG (DBG_proc, ">> set_maintenance data\n"); memset (&out, 0, sizeof (out)); /* CLEAR */ out.cmd.opcode = HS2P_SCSI_SEND_DATA; /* 2AH */ out.cmd.dtc = 0x85; /* Maintenance Data */ _lto3b (20, out.cmd.len); /* 20 bytes */ switch (code) { case 1: strcpy (out.string, "EEPROM ALL ALL RESET"); break; case 2: strcpy (out.string, "EEPROM ALL RESET"); break; case 3: strcpy (out.string, "ADF RESET"); break; case 4: strcpy (out.string, "FLATBED RESET"); break; case 5: strcpy (out.string, "LAMP RESET"); break; case 6: sprintf (out.string, "EEPROM ADF %c %+4.1d", XorY, number); break; case 7: sprintf (out.string, "EEPROM BOOK %c %4.1d", XorY, number); break; case 8: sprintf (out.string, "WHITE ADJUST DATA %3d", number); break; case 9: strcpy (out.string, "EEPROM FIRST WHITE ODD"); break; case 10: strcpy (out.string, "EEPROM FIRST WHITE EVEN"); break; case 11: strcpy (out.string, "R ADF RESET"); break; case 12: strcpy (out.string, "R LAMP RESET"); break; case 13: sprintf (out.string, "EEPROM R ADF %c %4.1d", XorY, number); break; case 14: strcpy (out.string, "ENDORSER RESET"); break; } status = sanei_scsi_cmd (fd, &out, sizeof (out), NULL, NULL); DBG (DBG_proc, "<< set_maintenance data\n"); return (status); } #endif #if 0 static SANE_Status read_halftone_mask (int fd, SANE_Byte halftone_id, void *buf, size_t * buf_size) { static struct scsi_rs_scanner_cmd cmd; SANE_Status status; SANE_Int len; DBG (DBG_proc, ">> read_halftone_mask\n"); memset (&cmd, 0, sizeof (cmd)); /* CLEAR */ cmd.opcode = HS2P_SCSI_READ_DATA; cmd.dtc = DATA_TYPE_HALFTONE; _lto2b (halftone_id, cmd.dtq); /* Each cell of an NxM dither pattern is 1 byte from the set {2,3,4,6,8,16} */ switch (halftone_id) { case 0x01: len = 32; break; /* 8x4, 45 degree */ case 0x02: len = 36; break; /* 6x6, spiral */ case 0x03: len = 16; break; /* 4x4, spiral */ case 0x04: len = 64; break; /* 8x8, 90 degree */ case 0x05: len = 70; break; /* 70 lines */ case 0x06: len = 95; break; /* 95 lines */ case 0x07: len = 180; break; /* 180 lines */ case 0x08: len = 128; break; /* 16x8, 45 degree */ case 0x09: len = 256; break; /* 16x16, 90 degree */ case 0x0A: len = 64; break; /* 8x8, Bayer */ default: return SANE_STATUS_INVAL; /* Reserved */ } _lto3b (len, cmd.len); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), buf, buf_size); DBG (DBG_proc, "<< read_halftone_mask\n"); return (status); } #endif #if 0 static SANE_Status set_halftone_mask (int fd, SANE_Byte halftone_id, void *buf, size_t * buf_size) { static struct scsi_rs_scanner_cmd cmd; SANE_Status status; DBG (DBG_proc, ">> set_halftone_mask\n"); memset (&cmd, 0, sizeof (cmd)); /* CLEAR */ cmd.opcode = HS2P_SCSI_READ_DATA; cmd.dtc = DATA_TYPE_HALFTONE; _lto2b (halftone_id, cmd.dtq); /* Each cell of an NxM dither pattern is 1 byte from the set {2,3,4,6,8,16} * 0x80, 0x81 are User definable custom dither patterns */ if (halftone_id != 0x80 && halftone_id != 0x81) return SANE_STATUS_INVAL; _lto3b (*buf_size, cmd.len); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), buf, buf_size); DBG (DBG_proc, "<< set_halftone_mask\n"); return (status); } #endif #if 0 static SANE_Status read_gamma_function (int fd) { SANE_Status status = SANE_STATUS_GOOD; return (status); } static SANE_Status read_endorser_data (int fd) { SANE_Status status = SANE_STATUS_GOOD; return (status); } static SANE_Status read_size_data (int fd) { SANE_Status status = SANE_STATUS_GOOD; return (status); } #endif #if 0 static SANE_Status read_maintenance_data (int fd) { SANE_Status status = SANE_STATUS_GOOD; return (status); } #endif /* Bit0: is 0 if document on ADF; else 1 * Bit1: is 0 if ADF cover is closed; else 1 * Bit2: reserved * Bits7-3: reserved */ #if 0 static SANE_Status read_adf_status (int fd, SANE_Byte * adf_status_byte) { SANE_Status status = SANE_STATUS_GOOD; struct scsi_rs_scanner_cmd cmd; static size_t len = 1; DBG (DBG_proc, ">> read_adf_status\n"); memset (&cmd, 0, sizeof (cmd)); cmd.opcode = HS2P_SCSI_READ_DATA; cmd.dtc = DATA_TYPE_ADF_STATUS; _lto3b (0x01, cmd.len); /* convert 0x01 into 3-byte Transfer Length */ if ((status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), adf_status_byte, &len)) != SANE_STATUS_GOOD) { DBG (DBG_error, "read_adf_status ERROR: %s\n", sane_strstatus (status)); } DBG (DBG_proc, "<< read_adf_status\n"); return (status); } #endif /* * read_ipu_photoletter_parameters * read_ipu_threshold_parameters * read_sensor_data (WHAT DATA TYPE CODE?) */ /* SEND CMD */ /* * send_halftone_mask * send_gamma_function * send_endorser_data * send_maintenance_data * EPROM All Clear * EPROM Counter Clear * ADF Counter Clear * Flatbed Counter Clear * Lamp Counter Clear * ADF Register Data * Flatbed Register Data * White Adjustment Data * White level first Data (ODD) * White level first Data (EVEN) * Reverse side ADF Counter Clear * Reverse side Lamp Counter Clear * Reverse side ADF Register Data * Endorser Character Counter Clear * send_ipu_parameters */ /* OBJECT POSITION */ /* GET DATA BUFFER STATUS */ /* 1-3-4 MODE SELECT */ /* 1-3-5 Reserve Unit: 0x16 * 1-3-6 Release Unit: 0x17 */ static SANE_Status unit_cmd (int fd, SANE_Byte opcode) { static struct { SANE_Byte opcode; /* 16H: Reserve Unit 17H: Release Unit */ SANE_Byte byte1; /* 7-5: LUN; 4: 3rd Party; 3-1: 3rd Party Device; 0: Reserved */ SANE_Byte reserved[3]; SANE_Byte control; /* 7-6: Vendor Unique; 5-2: Reserved; 1: Flag; 0: Link */ } cmd; SANE_Byte LUN = (0x00 & 0x07) << 5; SANE_Status status; DBG (DBG_proc, ">> unit_cmd\n"); cmd.opcode = opcode; cmd.byte1 = LUN & 0xE1; /* Mask=11100001 3rd Party and 3rd Party Device must be 0 */ memset (&cmd, 0, sizeof (cmd)); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), 0, 0); DBG (DBG_proc, "<< unit_cmd\n"); return (status); } /* The OBJECT POSITION command is used for carriage control or * document feed and eject with ADF * * Position Function: Byte1 bits2-0 * 000 Unload instructs document eject * 001 Load instructs document feed to scan start position * 010 Absolute Positioning - instructs carriage to move to carriage lock position * The carriage moves in the Y-axis direction as the amount set in Count when * count>0 * (Not supported in IS420) * */ static SANE_Status object_position (int fd, int load) { static struct scsi_object_position_cmd cmd; SANE_Status status; DBG (DBG_proc, ">> object_position\n"); /* byte 0 opcode * byte 1 position function * bytes 2-4 reserved * bytes 5-8 reserved * byte 9 control */ memset (&cmd, 0, sizeof (cmd)); cmd.opcode = HS2P_SCSI_OBJECT_POSITION; if (load) cmd.position_func = OBJECT_POSITION_LOAD; else cmd.position_func = OBJECT_POSITION_UNLOAD; status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), 0, 0); DBG (DBG_proc, "<< object_position\n"); return (status); } static SANE_Status get_data_status (int fd, STATUS_DATA * dbs) { static GET_DBS_CMD cmd; static STATUS_BUFFER buf; /* hdr + data */ size_t bufsize = sizeof (buf); SANE_Status status; DBG (DBG_proc, ">> get_data_status %lu\n", (unsigned long) bufsize); /* Set up GET DATA BUFFER STATUS cmd */ memset (&cmd, 0, sizeof (cmd)); /* CLEAR cmd */ cmd.opcode = HS2P_SCSI_GET_BUFFER_STATUS; cmd.wait &= ~0x01; /* unset Wait bit0 */ _lto2b (bufsize, cmd.len); /* Now execute cmd, and put returned results in buf */ status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), &buf, &bufsize); /* Now copy from buf.data to dbs */ memcpy (dbs, &buf.data, sizeof (*dbs)); if (status == SANE_STATUS_GOOD && ((unsigned int) _3btol (buf.hdr.len) <= sizeof (*dbs) || _3btol (buf.data.filled) == 0)) { DBG (DBG_info, "get_data_status: busy\n"); status = SANE_STATUS_DEVICE_BUSY; } DBG (DBG_proc, "<< get_data_status %lu\n", (unsigned long) bufsize); return (status); } /* 1-3-7 MODE SENSE */ /* 1-3-8 SCAN */ /* 1-3-9 Receive Diagnostic * Byte0: 1CH * Byte1: 7-5 LUN; 4-0: reserved * Byte2: Reserved * Byte3-4: Allocation Length * Byte5: 7-6: Vendor Unique; 5-2: Reserved; 1: Flag; 0: Link * * This command is treated as a dummy command * Return GOOD unless there is an error in command in which case it returns CHECK */ /* * The IS450 performs 7 self-diagnostics tests * 1) Home position error check * 2) Exposure lamp error check * 3) White level error check * 4) Document table error check * 5) SCU error check * 6) RCU error check * 7) Memory error check * * and uses the lights on the scanner to indicate the result * * PowerOn MachineBusy DocumentInPlace Error * (green) (green) (green) (red) * * SCU error check Blinking Blinking * RCU error check Blinking On Blinking * Home position error check Blinking Blinking Blinking On * Exposure lamp error check Blinking Blinking On On * White level error check Blinking Blinking * Memory Error (Simplex) Blinking * Memory Error (Duplex) Blinking * */ #if 0 static SANE_Status receive_diagnostic (int fd) { static SANE_Byte cmd[6]; SANE_Status status; DBG (DBG_proc, ">> receive_diagnostic\n"); cmd[0] = HS2P_SCSI_RECEIVE_DIAGNOSTICS; memset (cmd, 0, sizeof (cmd)); status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), 0, 0); DBG (DBG_proc, "<< receive_diagnostic\n"); return (status); } #endif /* 1-3-10 Send Diagnostic * Byte0: 1DH * Byte1: 7-5 LUN; 4: PF; 3: Reserved; 2: S-Test; 1: DevOfl; 0: U-Ofl * Byte2: Reserved * Byte3-4: Parameter List Length * Byte5: 7-6: Vendor Unique; 5-2: Reserved; 1: Flag; 0: Link * This command executes self-diagnostic and optical-adjustment * PF, DevOfl, and Parameter List Length must be 0 or CHECK condition is returned. */ #if 0 static SANE_Status send_diagnostic (int fd) { static SANE_Byte cmd[6]; SANE_Status status; DBG (DBG_proc, ">> send_diagnostic\n"); cmd[0] = HS2P_SCSI_SEND_DIAGNOSTICS; cmd[1] = 0x00 & (1 << 2) & 0xED; /* Set Self-Test bit and clear PF, DevOfl bits */ cmd[3] = 0x00; cmd[4] = 0x00; /* Parameter list (bytes3-4) must be 0x00 */ memset (cmd, 0, sizeof (cmd)); status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), 0, 0); DBG (DBG_proc, "<< send_diagnostic\n"); return (status); } #endif /* 1-3-8 SCAN command is used to instruct scanner to start scanning */ static SANE_Status trigger_scan (HS2P_Scanner * s) { static struct { START_SCAN cmd; SANE_Byte wid[2]; /* scanner supports up to 2 windows */ } scan; SANE_Status status; DBG (DBG_proc, ">> trigger scan\n"); memset (&scan, 0, sizeof (scan)); /* CLEAR scan */ scan.cmd.opcode = HS2P_SCSI_START_SCAN; /* Transfer length is the byte length of Window List transferred * Window List is a list of Window Identifier created by SET WINDOW command * Since only 1 Window is supported by SCAN command, 0 or 1 is used for Window Identifier * and 1 or 2 for length status = sanei_scsi_cmd (s->fd, &trigger, sizeof (trigger), &window_id_list[0], &wl_size); */ scan.cmd.len = (s->val[OPT_DUPLEX].w == SANE_TRUE) ? 2 : 1; DBG (DBG_info, "trigger_scan: sending %d Window Id to scanner\n", scan.cmd.len); status = sanei_scsi_cmd (s->fd, &scan, sizeof (scan.cmd) + scan.cmd.len, NULL, NULL); DBG (DBG_proc, "<< trigger scan\n"); return (status); } #define MAX_WAITING_TIME 15 static SANE_Status hs2p_wait_ready (HS2P_Scanner * s) { STATUS_DATA dbs; /* Status Buffer Status DATA */ time_t now, start; SANE_Status status; start = time (NULL); while (1) { status = get_data_status (s->fd, &dbs); switch (status) { default: /* Ignore errors while waiting for scanner to become ready. Some SCSI drivers return EIO while the scanner is returning to the home position. */ DBG (DBG_error, "scsi_wait_ready: get datat status failed (%s)\n", sane_strstatus (status)); /* fall through */ case SANE_STATUS_DEVICE_BUSY: now = time (NULL); if (now - start >= MAX_WAITING_TIME) { DBG (DBG_error, "hs2p_wait_ready: timed out after %lu seconds\n", (u_long) (now - start)); return SANE_STATUS_INVAL; } break; case SANE_STATUS_GOOD: DBG (DBG_proc, "hs2p_wait_ready: %d bytes ready\n", _3btol (dbs.filled)); return status; break; } usleep (1000000); /* retry after 100ms */ } return SANE_STATUS_INVAL; } /* MODE PAGES GET/SET */ static SANE_Status connection_parameters (int fd, MP_CXN * settings, SANE_Bool flag) { SANE_Status status; MP_CXN buf; size_t nbytes; DBG (DBG_proc, ">> connection_parameters\n"); nbytes = sizeof (buf); if (flag) { /* GET */ DBG (DBG_info, ">> GET connection_parameters >> calling mode_sense\n"); status = mode_sense (fd, (MP *) & buf, (SANE_Byte) PAGE_CODE_CONNECTION); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "get_connection_parameters: MODE_SELECT failed with status=%d\n", status); return (status); } memcpy (settings, &buf, nbytes); } else { /* SET */ DBG (DBG_info, ">> SET connection_parameters >> calling mode_select\n"); /* Fill in struct then hand off to mode_select */ memset (&buf, 0, sizeof (buf)); /* Fill struct with zeros */ memcpy (&buf, settings, nbytes); /* Make sure calling function didn't change these bytes */ memset (&buf.hdr, 0, sizeof (buf.hdr)); /* Make sure 4bytes are 0 */ buf.code = PAGE_CODE_CONNECTION; /* bits5-0: Page Code 02H */ buf.code &= ~(1 << 7); /* Bit7 PS is set to 0 */ buf.len = 0x0E; /* This is the only page with 14 bytes */ status = mode_select (fd, (MP *) & buf); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "set_connection_parameters: MODE_SELECT failed with status=%d\n", status); return (-1); } } DBG (DBG_proc, "<< connection_parameters\n"); return (status); } static SANE_Status get_basic_measurement_unit (int fd, SANE_Int * bmu, SANE_Int * mud) { SANE_Status status; MP_SMU buf; DBG (DBG_proc, ">> get_basic_measurement_unit: fd=\"%d\"\n", fd); status = mode_sense (fd, (MP *) & buf, (SANE_Byte) PAGE_CODE_SCANNING_MEASUREMENTS); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "set_basic_measurement_unit: MODE_SELECT failed with status=%d\n", status); return (SANE_STATUS_INVAL); } *bmu = buf.bmu; *mud = ((buf.mud[0] << 8) | buf.mud[1]); DBG (DBG_proc, "<< get_basic_measurement_unit: bmu=%d mud=%d\n", *bmu, *mud); return (status); } static SANE_Status set_basic_measurement_unit (int fd, SANE_Byte bmu) { MP_SMU buf; /* Mode Page Scanning Measurements Page Code */ SANE_Status status; SANE_Int mud; size_t bufsize = sizeof (buf); DBG (DBG_proc, ">> set_basic_measurement_unit: %d\n", bmu); /* Set up buf */ memset (&buf, 0, bufsize); /* CLEAR buf */ buf.code = PAGE_CODE_SCANNING_MEASUREMENTS; /* bits5-0: Page Code */ buf.code &= ~(1 << 7); /* Bit7 PS is set to 0 */ buf.len = 0x06; buf.bmu = bmu; /* Power on default is POINTS */ mud = (bmu == INCHES) ? DEFAULT_MUD : 1; DBG (DBG_info, "SET_BASIC_MEASUREMENT_UNIT: bmu=%d mud=%d\n", bmu, mud); _lto2b (mud, &buf.mud[0]); /* buf.mud[0] = (mud >> 8) & 0xff; buf.mud[1] = (mud & 0xff); */ status = mode_select (fd, (MP *) & buf); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "set_basic_measurement_unit: MODE_SELECT failed with status=%d\n", status); status = SANE_STATUS_INVAL; } DBG (DBG_proc, "<< set_basic_measurement_unit: opcode=%d len=%d bmu=%d mud=%ld\n", buf.code, buf.len, buf.bmu, _2btol (&buf.mud[0])); return (status); } static SANE_Status adf_control (int fd, SANE_Bool flag, SANE_Byte * adf_control, SANE_Byte * adf_mode, SANE_Byte * mwt) { SANE_Status status; MP_ADF buf; size_t bufsize = sizeof (buf); DBG (DBG_proc, ">> adf_control\n"); memset (&buf, 0, bufsize); /* Fill struct with zeros */ if (flag) { /* GET */ DBG (DBG_info, ">> GET ADF_control>> calling mode_sense\n"); status = mode_sense (fd, (MP *) & buf, (SANE_Byte) PAGE_CODE_ADF_CONTROL); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "get_adf_control: MODE_SELECT failed\n"); return (status); } *adf_control = buf.adf_control; *adf_mode = buf.adf_mode_control; *mwt = buf.medium_wait_timer; } else { /* SET */ /* Fill in struct then hand off to mode_select */ buf.code = PAGE_CODE_ADF_CONTROL; /* bits5-0: Page Code */ buf.code &= ~(1 << 7); /* Bit7 PS is set to 0 */ buf.len = 0x06; /* Byte2: adf_control: 7-2:reserved; 1-0:adf_control: Default 00H Flatbed, 01H Simplex, 02H Duplex */ /* Byte3: adf_mode_control: 7-3:reserved; 2: Prefeed Mode: 0 invalid, 1 valid; 1-0: ignored */ /* Byte4: medium_wait_timer: timeout period. Not supported */ buf.adf_control = (*adf_control & 0x03); buf.adf_mode_control = (*adf_mode & 0x04); buf.medium_wait_timer = *mwt; status = mode_select (fd, (MP *) & buf); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "set_adf_control: MODE_SELECT failed with status=%d\n", status); return (status); } } DBG (DBG_proc, ">> adf_control\n"); return (status); } static SANE_Status white_balance (int fd, int *val, SANE_Bool flag) { SANE_Status status; MP_WhiteBal buf; /* White Balance Page Code */ size_t bufsize = sizeof (buf); memset (&buf, 0, bufsize); if (flag) { /* GET */ DBG (DBG_proc, ">> GET white_balance>> calling mode_sense\n"); status = mode_sense (fd, (MP *) & buf, (SANE_Byte) PAGE_CODE_WHITE_BALANCE); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "get_white_balance: MODE_SELECT failed with status=%d\n", status); return (status); } *val = buf.white_balance; } else { /* SET */ /* Fill in struct then hand off to mode_select */ memset (&buf, 0, sizeof (buf)); /* Fill struct with zeros */ buf.code = PAGE_CODE_WHITE_BALANCE; /* bits5-0: Page Code */ buf.code &= ~(1 << 7); /* Bit7 PS is set to 0 */ buf.len = 0x06; buf.white_balance = *val; /* Power on default is RELATIVE_WHITE */ status = mode_select (fd, (MP *) & buf); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "set_white_balance: MODE_SELECT failed with status=%d\n", status); return (status); } } DBG (DBG_proc, "<< white balance: buf.white_balance=%#02x\n", buf.white_balance); return (status); } #if 0 static SANE_Int lamp_timer (int fd, int val, SANE_Bool flag) { SANE_Status status; MP_LampTimer buf; /* Lamp Timer Page Code */ DBG (DBG_proc, ">> lamp timer\n"); if (flag) { /* GET */ DBG (DBG_info, ">> GET lamp_timer>> calling mode_sense\n"); if ((status = mode_sense (fd, (MP *) & buf, (SANE_Byte) PAGE_CODE_LAMP_TIMER_SET)) != SANE_STATUS_GOOD) { DBG (DBG_error, "get_lamp_timer: MODE_SELECT failed\n"); return (-1); } } else { /* SET */ /* Fill in struct then hand off to mode_select */ memset (&buf, 0, sizeof (buf)); /* Fill struct with zeros */ buf.code = PAGE_CODE_LAMP_TIMER_SET; /* bits5-0: Page Code */ buf.code &= ~(1 << 7); /* Bit7 PS is set to 0 */ buf.len = 0x06; buf.time_on = val; /* time lamp has been on */ if ((status = mode_select (fd, (MP *) & buf)) != SANE_STATUS_GOOD) { DBG (DBG_error, "set_lamp_timer: MODE_SELECT failed with status=%d\n", status); return (-1); } } DBG (DBG_proc, "<< lamp timer\n"); return (buf.time_on); } #endif static SANE_Status endorser_control (int fd, int *val, SANE_Bool flag) { SANE_Status status; MP_EndCtrl buf; /* MPHdr (4bytes) + MPP (8bytes) */ SANE_Byte mask = 0x7; /* 7-3:reserved; 2-0: Endorser Control */ size_t bufsize = sizeof (buf); DBG (DBG_proc, ">> endorser_control: fd=%d val=%d flag=%d\n", fd, *val, flag); memset (&buf, 0, bufsize); /* Fill struct with zeros */ if (flag) { /* GET */ DBG (DBG_info, ">> GET endorser control >> calling mode_sense\n"); status = mode_sense (fd, (MP *) & buf, (SANE_Byte) PAGE_CODE_ENDORSER_CONTROL); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "get_endorser_control: MODE_SELECT failed with status=%d\n", status); return (status); } *val = buf.endorser_control & mask; } else { /* SET */ DBG (DBG_info, ">> SET endorser control >> calling mode_select\n"); /* Fill in struct then hand off to mode_select */ memset (&buf, 0, sizeof (buf)); /* Fill struct with zeros */ buf.code = PAGE_CODE_ENDORSER_CONTROL; /* bits5-0: Page Code */ buf.code &= ~(1 << 7); /* Bit7 PS is set to 0 */ buf.len = 0x06; buf.endorser_control = *val & mask; /* Power on default is OFF */ status = mode_select (fd, (MP *) & buf); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "set_endorser_control: MODE_SELECT failed with status=%d\n", status); return (status); } } DBG (DBG_proc, "<< endorser_control: endorser_control=%#02x\n", buf.endorser_control); return (status); } /* When SCAN, READ, or LOAD (in ADF mode) is issued, scanner waits until operator panel start button is pressed */ static SANE_Status scan_wait_mode (int fd, int val, SANE_Bool flag) { SANE_Status status; MP_SWM buf; /* Scan Wait Mode Page Code */ DBG (DBG_proc, ">> scan_wait_mode\n"); if (flag) { /* GET */ DBG (DBG_info, ">> GET scan_wait_mode >> calling mode_sense\n"); status = mode_sense (fd, (MP *) & buf, (SANE_Byte) PAGE_CODE_SCAN_WAIT_MODE); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "get_scan_wait_mode: MODE_SELECT failed with status=%d\n", status); return (-1); } } else { /* SET */ /* Fill in struct then hand off to mode_select */ memset (&buf, 0, sizeof (buf)); /* Fill struct with zeros */ buf.code = PAGE_CODE_SCAN_WAIT_MODE; /* bits5-0: Page Code */ buf.code &= ~(1 << 7); /* Bit7 PS is set to 0 */ buf.len = 0x06; buf.swm = 0x00; if (val == 1) buf.swm |= 1; /* set bit 1 if scan_wait_mode ON */ else buf.swm &= ~1; /* unset bit 1 if scan_wait_mode OFF */ DBG (DBG_info, ">> SET scan_wait_mode >> calling mode_sense\n"); if ((status = mode_select (fd, (MP *) & buf)) != SANE_STATUS_GOOD) { DBG (DBG_error, "mode_select ERROR %s\n", sane_strstatus (status)); } } DBG (DBG_proc, "<< scan_wait_mode: buf.swm=%#02x\n", buf.swm); return (status); } /* Selectable when Send Diagnostics command is performed */ static SANE_Int service_mode (int fd, int val, SANE_Bool flag) { SANE_Status status; MP_SRV buf; /* Service Mode Page Code */ DBG (DBG_proc, ">> service_mode\n"); if (flag) { /* GET */ DBG (DBG_info, ">> GET service_mode >> calling mode_sense\n"); status = mode_sense (fd, (MP *) & buf, (SANE_Byte) PAGE_CODE_SERVICE_MODE_SELECT); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "get_service_mode: MODE_SELECT failed with status=%d\n", status); return (-1); } } else { /* SET */ /* Fill in struct then hand off to mode_select */ memset (&buf, 0, sizeof (buf)); /* Fill struct with zeros */ buf.code = PAGE_CODE_SERVICE_MODE_SELECT; /* bits5-0: Page Code */ buf.code &= ~(1 << 7); /* Bit7 PS is set to 0 */ buf.len = 0x06; /* 0H: Self-Diagnostics Mode, 1H: Optical Adjustment Mode */ buf.service = val & 0x01; status = mode_select (fd, (MP *) & buf); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "set_service_mode: MODE_SELECT failed with status=%d\n", status); return (-1); } } DBG (DBG_proc, "<< service_mode\n"); return (buf.service & 0x01); } sane-backends-1.0.29/backend/fujitsu.conf.in0000666000000000000000000000630713615534521015543 00000000000000# NOTE: any 'option' lines only apply to # scanners discovered later in this file # to set data buffer size, in bytes # the value ranges from 4096 - infinity # but old scanners may have scanning problems # with a value larger than 65536 (the default) # NOTE: this option is set to a larger value # later in this file, for more recent scanners option buffer-size 65536 # To search for all FUJITSU scsi devices scsi FUJITSU # To use a specific scsi device #scsi /dev/sg1 # For Fujitsu scanners connected via USB on a known device (kernel driver): #usb /dev/usb/scanner0 # For Fujitsu scanners connected via USB using vendor and device ids (libusb): #usb VENDORID PRODUCTID # NOTE: if you have to add your device here- please send the id and model # to the author via email, so it can be included in next version. kitno455 at # gmail dot com - with Fujitsu in the subject line #fi-4x20C usb 0x04c5 0x1041 usb 0x04c5 0x1042 #fi-4530C usb 0x04c5 0x1078 #fi-5750C usb 0x04c5 0x1095 #fi-5110eox/2 usb 0x04c5 0x1096 #fi-5110C usb 0x04c5 0x1097 #fi-5650C usb 0x04c5 0x10ad #fi-4x20C2 usb 0x04c5 0x10ae usb 0x04c5 0x10af #fi-4340C usb 0x04c5 0x10cf #fi-5x20C usb 0x04c5 0x10e0 usb 0x04c5 0x10e1 #fi-5530C usb 0x04c5 0x10e2 #fi-5110eox3 usb 0x04c5 0x10e6 #fi-5900C usb 0x04c5 0x10e7 #fi-5110EOXM usb 0x04c5 0x10f2 #ScanSnap S500 usb 0x04c5 0x10fe #ScanSnap S500M usb 0x04c5 0x1135 #fi-5530C2 usb 0x04c5 0x114a # More recent scanners need a larger buffer for maximum speed option buffer-size 262144 #fi-6140 usb 0x04c5 0x114d #fi-6240 usb 0x04c5 0x114e #fi-6130 usb 0x04c5 0x114f #fi-6230 usb 0x04c5 0x1150 #ScanSnap S510 usb 0x04c5 0x1155 #ScanSnap S510M usb 0x04c5 0x116f #fi-6770 usb 0x04c5 0x1174 #fi-6770A usb 0x04c5 0x1175 #fi-6670 usb 0x04c5 0x1176 #fi-6670A usb 0x04c5 0x1177 #fi-6750S usb 0x04c5 0x1178 #fi-6800 usb 0x04c5 0x119d #fi-6800-CGA usb 0x04c5 0x119e #S1500 & S1500M usb 0x04c5 0x11a2 #fi-6140Z/fi-6160ZLA usb 0x04c5 0x11f1 #fi-6240Z usb 0x04c5 0x11f2 #fi-6130Z usb 0x04c5 0x11f3 #fi-6230Z usb 0x04c5 0x11f4 #fi-6110 usb 0x04c5 0x11fc #fi-5950 usb 0x04c5 0x1213 #ScanSnap SV600 usb 0x04c5 0x128e #ScanSnap iX500 usb 0x04c5 0x132b #fi-7180 usb 0x04c5 0x132c #fi-7280 usb 0x04c5 0x132d #fi-7160 usb 0x04c5 0x132e #fi-7260 usb 0x04c5 0x132f #ScanSnap iX500EE usb 0x04c5 0x13f3 #ScanSnap iX100 usb 0x04c5 0x13f4 #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 #ScanSnap iX1500 usb 0x04c5 0x159f sane-backends-1.0.29/backend/hp3900.c0000666000000000000000000000463113615534521013663 00000000000000/* HP Scanjet 3900 series - Stand-alone/SANE Backend controller Copyright (C) 2005-2008 Jonathan Bravo Lopez 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* Backend info */ #define BACKEND_NAME hp3900 #define BACKEND_VRSN "0.12" #define BACKEND_AUTHOR "Jonathan Bravo Lopez (JKD)" #define BACKEND_EMAIL "jkdsoft@gmail.com" #define BACKEND_URL "http://jkdsoftware.dyndns.org" #define BACKEND_LICENSE "General Public License (GPL)" /* if you want to compile this one as a sane backend then comment next line */ /* Caution: Sources included in SANE project don't provide hp3900_stdalone.c */ /*#define STANDALONE*/ #ifdef STANDALONE #include "hp3900_stdalone.c" #else #include "hp3900_sane.c" #endif sane-backends-1.0.29/backend/fujitsu.c0000666000000000000000000112427013615534521014434 00000000000000/* sane - Scanner Access Now Easy. This file is part of the SANE package, and implements a SANE backend for various Fujitsu scanners. Copyright (C) 2000 Randolph Bentson Copyright (C) 2001 Frederik Ramm Copyright (C) 2001-2004 Oliver Schirrmeister Copyright (C) 2003-2019 m. allan noah JPEG output and low memory usage support funded by: Archivista GmbH, www.archivista.ch Endorser support funded by: O A S Oilfield Accounting Service Ltd, www.oas.ca Automatic length detection support funded by: Martin G. Miller, mgmiller at optonline.net Software image enhancement routines and recent scanner support funded by: Fujitsu Computer Products of America, Inc. www.fcpa.com -------------------------------------------------------------------------- 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. -------------------------------------------------------------------------- The source code is divided in sections which you can easily find by searching for the tag "@@". Section 1 - Boilerplate: Init & static stuff Section 2 - Init: sane_init, _get_devices, _open ... Section 3 - Options: sane_*_option functions Section 4 - Scanning: sane_start, _get_param, _read ... Section 5 - Cleanup: sane_cancel, ... Section 6 - Misc: sense_handler, hexdump, ... Section 7 - Image processing: deskew, crop, despeck Changes: v1, 2002-05-05, OS - release memory allocated by sane_get_devices - several bugfixes - supports the M3097 - get threshold, contrast and brightness from vpd - imprinter support - get_hardware_status now works before calling sane_start - avoid unnecessary reload of options when using source=fb v2, 2002-08-08, OS - bugfix. Imprinter didn't print the first time after switching on the scanner - bugfix. reader_generic_passthrough ignored the number of bytes returned by the scanner v3, 2002-09-13, OS - 3092 support (mgoppold a t tbz-pariv.de) - tested 4097 support - changed some functions to receive compressed data v4, 2003-02-13, OS - fi-4220C support (ron a t roncemer.com) - SCSI over USB support (ron a t roncemer.com) v5, 2003-02-20, OS - set availability of options THRESHOLD und VARIANCE - option RIF is available for 3091 and 3092 v6, 2003-03-04, OS - renamed some variables - bugfix: duplex scanning now works when disconnect is enabled v7, 2003-03-10, OS - displays the offending byte in the window descriptor block v8, 2003-03-28, OS - fi-4120C support, MAN - display information about gamma in vital_product_data v9 2003-06-04, MAN - separated the 4120 and 4220 into another model - color support for the 4x20 v10 2003-06-04, MAN - removed SP15 code - sane_open actually opens the device you request v11 2003-06-11, MAN - fixed bug in that code when a scanner is disconnected v12 2003-10-06, MAN - added code to support color modes of more recent scanners v13 2003-11-07, OS - Bugfix. If a scanner returned a color image in format rr...r gg...g bb...b the reader process crashed - Bugfix. Disable option gamma was for the fi-4120 v14 2003-12-15, OS - Bugfix: set default threshold range to 0..255 There is a problem with the M3093 when you are not allows to set the threshold to 0 - Bugfix: set the allowable x- and y-DPI values from VPD. Scanning with x=100 and y=100 dpi with an fi4120 resulted in an image with 100,75 dpi - Bugfix: Set the default value of gamma to 0x80 for all scanners that don't have built in gamma patterns - Bugfix: fi-4530 and fi-4210 don't support standard paper size v15 2003-12-16, OS - Bugfix: pagewidth and pageheight were disabled for the fi-4530C v16 2004-02-20, OS - merged the 3092-routines with the 3091-routines - inverted the image in mode color and grayscale - jpg hardware compression support (fi-4530C) v17 2004-03-04, OS - enabled option dropoutcolor for the fi-4530C, and fi-4x20C v18 2004-06-02, OS - bugfix: can read duplex color now v19 2004-06-28, MAN - 4220 use model code not strcmp (stan a t saticed.me.uk) v20 2004-08-24, OS - bugfix: 3091 did not work since 15.12.2003 - M4099 supported (bw only) v21 2006-05-01, MAN - Complete rewrite, half code size - better (read: correct) usb command support - basic support for most fi-series - most scanner capabilities read from VPD - reduced model-specific code - improved scanner detection/initialization - improved SANE_Option handling - basic button support - all IPC and Imprinter options removed temporarily - duplex broken temporarily v22 2006-05-04, MAN - do_scsi_cmd gets basic looping capability - reverse now divided by mode - re-write sane_fix/unfix value handling - fix several bugs in options code - some options' ranges modified by other options vals - added advanced read-only options for all known hardware sensors and buttons - rewrote hw status function - initial testing with M3091dc- color mode broken v23 2006-05-14, MAN - initial attempt to recover duplex mode - fix bad usb prodID when config file missing v24 2006-05-17, MAN - sane_read must set len=0 when return != good - simplify do_cmd() calls by removing timeouts - lengthen most timeouts, shorten those for wait_scanner() v25 2006-05-19, MAN - rename scsi-buffer-size to buffer-size, usb uses it too - default buffer-size increased to 64k - use sanei_scsi_open_extended() to set buffer size - fix some compiler warns: 32&64 bit gcc v26 2006-05-23, MAN - dont send scanner control (F1) if unsupported v27 2006-05-30, MAN - speed up hexdump (adeuring A T gmx D O T net) - duplex request same size block from both sides - dont #include or call sanei_thread - split usb/scsi command DBG into 25 and 30 v28 2006-06-01, MAN - sane_read() usleep if scanner is busy - do_*_cmd() no looping (only one caller used it), remove unneeded casts, cleanup/add error messages - scanner_control() look at correct has_cmd_* var, handles own looping on busy v29 2006-06-04, MAN - M3091/2 Color mode support (duplex still broken) - all sensors option names start with 'button-' - rewrite sane_read and helpers to use buffers, currently an extreme waste of ram, but should work with saned and scanimage -T - merge color conversion funcs into read_from_buf() - compare bytes tx v/s rx instead of storing EOFs - remove scanner cmd buf, use buf per func instead - print color and duplex raster offsets (inquiry) - print EOM, ILI, and info bytes (request sense) v30 2006-06-06, MAN - M3091/2 duplex support, color/gray/ht/lineart ok - sane_read helpers share code, report more errors - add error msg if VPD missing or non-extended - remove references to color_lineart and ht units - rework init_model to support more known models - dont send paper size data if using flatbed v31 2006-06-13, MAN - add 5220C usb id - dont show ink level buttons if no imprinter - run ghs/rs every second instead of every other v32 2006-06-14, MAN - add 4220C2 usb id v33 2006-06-14, MAN (SANE v1.0.18) - add Fi-5900 usb id and init_model section v34 2006-07-04, MAN - add S500 usb id - gather more data from inq and vpd - allow background color setting v35 2006-07-05, MAN - allow double feed sensor settings - more consistent naming of global strings v36 2006-07-06, MAN - deal with fi-5900 even bytes problem - less verbose calculateDerivedValues() v37 2006-07-14, MAN - mode sense command support - detect mode page codes instead of hardcoding - send command support - brightness/contrast support via LUT - merge global mode page buffers v38 2006-07-15, MAN - add 'useless noise' debug level (35) - move mode sense probe errors to DBG 35 v39 2006-07-17, MAN - rewrite contrast slope math for readability v40 2006-08-26, MAN - rewrite brightness/contrast more like xsane - initial gamma support - add fi-5530 usb id - rewrite do_*_cmd functions to handle short reads and to use ptr to return read in length - new init_user function split from init_model - init_vpd allows short vpd block for older models - support MS buffer (s.scipioni AT harvardgroup DOT it) - support MS prepick - read only 1 byte of mode sense output v41 2006-08-28, MAN - do_usb_cmd() returns io error on cmd/out/status/rs EOF - fix bug in MS buffer/prepick scsi data block v42 2006-08-31, MAN - fix bug in get_hardware_status (#303798) v43 2006-09-19, MAN - add model-specific code to init_vpd for M3099 v44 2007-01-26, MAN - set SANE_CAP_HARD_SELECT on all buttons/sensors - disable sending gamma LUT, seems wrong on some units? - support MS overscan - clamp the scan area to the pagesize on ADF v45 2007-01-28, MAN - update overscan code to extend max scan area v46 2007-03-08, MAN - tweak fi-4x20c2 and M3093 settings - add fi-5110EOXM usb id - add M3093 non-alternating duplex code v47 2007-04-13, MAN - change window_gamma determination - add fi-5650C usb id and color mode v48 2007-04-16, MAN - re-enable brightness/contrast for built-in models v49 2007-06-28, MAN - add fi-5750C usb id and color mode v50 2007-07-10, MAN - updated overscan and bgcolor option descriptions - added jpeg output support - restructured usb reading code to use RS len for short reads - combined calcDerivedValues with sane_get_params v51 2007-07-26, MAN - fix bug in jpeg output support v52 2007-07-27, MAN - remove unused jpeg function - reactivate look-up-table based brightness and contrast options - change range of hardware brightness/contrast to match LUT versions - call send_lut() from sane_control_option instead of sane_start v53 2007-11-18, MAN - add S510 usb id - OPT_NUM_OPTS type is SANE_TYPE_INT (jblache) v54 2007-12-29, MAN - disable SANE_FRAME_JPEG support until SANE 1.1.0 v55 2007-12-29, MAN (SANE v1.0.19) - add S500M usb id v56 2008-02-14, MAN - sanei_config_read has already cleaned string (#310597) v57 2008-02-24, MAN - fi-5900 does not (initially) interlace colors - add mode sense for color interlacing? (page code 32) - more debug output in init_ms() v58 2008-04-19, MAN - page code 32 is not color interlacing, rename to 'unknown' - increase number of bytes in response buffer of init_ms() - protect debug modification code in init_ms() if NDEBUG is set - proper async sane_cancel support - re-enable JPEG support - replace s->img_count with s->side - sane_get_parameters(): dont round up larger than current paper size - sane_start() rewritten, shorter, more clear - return values are SANE_Status, not int - hide unused functions v59 2008-04-22, MAN - add fi-6140 usb ID, and fi-6x40 color mode v60 2008-04-27, MAN - move call to sanei_usb_init() from sane_init() to find_scanners - free sane_devArray before calloc'ing a new one v61 2008-05-11, MAN - minor cleanups to init_ms() - add fi-5530C2 usb id - merge find_scanners into sane_get_devices - inspect correct bool to enable prepick mode option v62 2008-05-20, MAN - check for all supported scsi commands - use well-known option group strings from saneopts.h - rename pagewidth to page-width, to meet sane 1.1.0, same for height - add unused get_window() v63 2008-05-21, MAN - use sane 1.1.0 well-known option names for some buttons - remove 'button-' from other buttons and sensors v64 2008-05-28, MAN - strcpy device_name[] instead of strdup/free *device_name - add send/read diag commands to get scanner serial number - use model and serial to build sane.name (idea from Ryan Duryea) - allow both serial_name and device_name to sane_open scanner - correct mode select/sense 6 vs 10 booleans - rename product_name to model_name - simulate missing VPD data for M3097G - hide get_window - improve handling of vendor unique section of set_window - add init_interlace to detect proper color mode without hardcoding - add ascii output to hexdump v65 2008-06-24, MAN - detect endorser type during init_inquiry() - add endorser options - add send_endorser() and call from sane_control_option() - add endorser() and call from sane_start() - convert set_window() to use local cmd and payload copies - remove get_window() - mode_select_buff() now clears the buffer, and called in sane_close() - fi-4990 quirks added, including modified even_scan_line code v66 2008-06-26, MAN - restructure double feed detection options for finer-grained control - add endorser side option - prevent init_interlace() from overriding init_model() - simplify sane_start() and fix interlaced duplex jpeg support - simplify sane_read() and add non-interlaced duplex jpeg support - removed unused code v67 2008-07-01, MAN - add IPC/DTC/SDTC options - call check_for_cancel() in sane_cancel, unless s->reader flag is set v68 2008-07-02, MAN - add halftone type and pattern options - support M3097G with IPC and CMP options via modified VPD response v69 2008-07-03, MAN - support hot-unplugging scanners v70 2008-07-05, MAN - fix bug in sane_get_parameters (failed to copy values) - autodetect jpeg duplex interlacing mode by inspecting scan width v71 2008-07-13, MAN - disable overscan option if vpd does not tell overscan size - fi-5110EOX crops scan area based on absolute maximum, not paper - fi-5530C/2 and fi-5650C can't handle 10 bit LUT via USB - fi-5900 has background color, though it reports otherwise v72 2008-07-13, MAN - use mode_sense to determine background color support - remove fi-5900 background color override v73 2008-07-14, MAN - correct overscan dimension calculation - provide correct overscan size overrides for fi-5110C and fi-4x20C2 - add fi-6130 usb ID - fi-5750C can't handle 10 bit LUT via USB v74 2008-08-02, MAN - replace global scsi blocks with local ones in each function v75 2008-08-07, ReneR - added fi-6230 usb ID v76 2008-08-13, MAN - add independent maximum area values for flatbed - override said values for fi-4220C, fi-4220C2 and fi-5220C v77 2008-08-26, MAN - override flatbed maximum area for fi-6230C and fi-6240C - set PF bit in all mode_select(6) CDB's - set SANE_CAP_INACTIVE on all disabled options - fix bug in mode_select page for sleep timer v78 2008-08-26, MAN - recent model names (fi-6xxx) dont end in 'C' - simplify flatbed area overrides - call scanner_control to change source during sane_start v79 2008-10-01, MAN - add usb ids for several models - print additional hardware capability bits - detect front-side endorser - disable endorser-side controls if only one side installed - add quirks for fi-6x70 v80 2008-10-08, MAN - front-side endorser uses data ID 0x80 v81 2008-10-20, MAN - increase USB timeouts - enable get_pixelsize() to update scan params after set_window() - remove even_scan_line hack v82 2008-10-31, MAN - improved front-side endorser vpd detection - send scanner_control_ric during sane_read of each side - add fi-6770A and fi-6670A USB ID's v83 2008-11-06, MAN - round binary bpl and Bpl up to byte boundary - use s->params instead of user data in set_window() - read_from_scanner() only grabs an even number of lines v84 2008-11-07, MAN - round lines down to even number to get even # of total bytes - round binary bpl and Bpl down to byte boundary v85 2008-12-10, MAN - round pixels_per_line down to arbitrary limits for fi-4990 & fi-4860 - fi-4860 returns random garbage to serial number queries - initialize *info to 0 in sane_control_option() v86 2008-12-18, MAN - get_pixelsize() sets back window ID for back side scans v87 2008-12-21, MAN - accept null pointer as empty device name - track frontend reading sensor/button values to reload - deactivate double feed options if df-action == default v88 2009-01-21, MAN - dont export private symbols v89 2009-02-20, MAN - fi-4750 returns random garbage to serial number queries v90 2009-02-23, MAN - added ScanSnap S510M usb ids v91 2009-03-20, MAN - remove unused temp file code v92 2009-04-12, MAN - disable SANE_FRAME_JPEG support (again) v93 2009-04-14, MAN (SANE 1.0.20) - return cmd status for reads on sensors - ignore errors in scanner_control(), M3091 has not worked since sane 1.0.19, due to this. - copy_buffer needs to count lines, or M309[12] cannot duplex v94 2009-05-22, MAN - add side option to show which duplex image is being transferred - convert front and simplex buffers to use much less ram - add lowmemory option which makes duplex back buffer small too - refactor image handling code to track eof's instead of lengths - do color deinterlacing after reading from scanner, before buffering v95 2009-06-02, MAN - scanner_control_ric should return a subset of the possible errors v96 2009-08-07, MAN - split sane_get_parameters into two functions - remove unused code from get_pixelsize - support hardware based auto length detection v97 2009-09-14, MAN - use sanei_magic to provide software deskew, autocrop and despeckle v98 2010-02-09, MAN (SANE 1.0.21) - clean up #include lines and copyright - add SANE_I18N to static strings - don't fail if scsi buffer is too small - disable bg_color for S1500 - enable flatbed for M3092 v99 2010-05-14, MAN - sense_handler(): collect rs_info for any ILI, not just EOM - do_usb_cmd(): use rs_info whenever set, not just EOF - read_from_*(): better handling of EOF from lower level functions - sane_read(): improve duplexing logic v100 2010-06-01, MAN - store more Request Sense data in scanner struct - clear Request Sense data at start of every do_cmd() call - track per-side ILI and global EOM flags - set per-side EOF flag if ILI and EOM are set v101 2010-06-23, MAN - fix compilation bug when jpeg is enabled v102 2010-09-22, MAN - fix infinite loop when scan is an odd number of lines v103 2010-11-23, MAN - remove compiled-in default config file - initial support for new fi-6xxx machines v104 2010-11-24, MAN - never request more than s->buffer_size from scanner - silence noisy set_window() calls from init_interlace() v105 2010-12-02, MAN - backup and restore image params around image processing code - cache software crop/deskew parameters for use on backside of duplex - fi-6110 does not support bgcolor or prepick v106 2011-01-30, MAN (SANE 1.0.22) - dont call mode_select with a page code the scanner does not support v107 2011-11-03, MAN - M3091 does not support scanner_control(adf) - Correct buffer overflow in read_from_3091duplex() - sane_read() now always calls read_from_*() - read_from_*() are callable when there is no data, and read to eof - sane_read() will keep alternate duplex reads to similar length - Added debugging statements - Corrected comments - Updated Copyright v108 2011-11-21, MAN - merged x/y resolution options - moved page width/height to start of geometry group - use mode to pick resolution list v/s range - improved M3091 resolution choices v109 2011-12-20, MAN - added some MS and INQ information - increased default buffer size for later machines in config file - renamed new fi-6xx0Z models v110 2012-05-09, MAN - correct max_y_fb for fi-62x0 series - add must_fully_buffer helper routine - add hwdeskewcrop option, with fallback to software versions - add 'actual' param to get_pixelsize for post-scan - add recent model VPD params - only set params->lines = -1 when using ald without buffering - fix bugs in background color when using software deskew v111 2012-05-10, MAN (SANE 1.0.23) - call send_* and mode_select_* from sane_start - split read payloads into new debug level - add paper-protect, staple-detect and df-recovery options v112 2013-02-22, MAN - some scanners (fi-6x70 and later) don't enable IPC by default v113 2013-02-24, MAN - support for ScanSnap iX500 - fix bug with jpeg de-interlacing code - allow has_MS_* and has_pixelsize to be set in init_model - fix use of uninitialized buffer in send_lut - add send_q_table() - allow wait_scanner() to be bypassed in object_position - moved send_lut() to after set_window v114 2013-03-01, MAN - support resolutions > 300 for iX500 using diag_preread() - remove most communication with scanner during sane_control_option() v115 2013-03-09, MAN - separate s->mode into s_mode and u_mode - separate s->params into s_params and u_params - generate grayscale and binary in software if required (iX500) v116 2013-03-23, MAN - call set_mode() in init_interlace - add swskip option v117 2013-06-11, MAN (SANE 1.0.24) - default buffer-mode to off - improved error handling in sane_start - image width must be multiple of 8 when swcrop is used before binarization (iX500) - check hopper sensor before calling object_position(load) on iX500 v118 2013-12-09, MAN - support fi-7160, fi-7260, fi-7180 and fi-7280 - remove unused var from do_scsi_cmd() - added more request_sense options - add adv_paper_protect option - enable paper protection by default - increase max_x_fb for fi-6240 and fi-6230 v119 2013-12-18, MAN - call get_pixelsize after start_scan, not before - extend get_pixelsize to request backside data - stop using backup/restore_params - don't use extended get_pixelsize on M3091 or M3092 - call software crop code on backside images too v120 2014-01-29, MAN - only call hopper_before_op code at batch start - remove unused backup/restore_params v121 2014-04-07, MAN - add JFIF APP0 marker with resolution to jpeg images - improve jpeg duplex parsing code - simplify jpeg ifdefs - add offtimer option for more recent scanners - don't print 0 length line in hexdump v122 2014-10-28, MAN - add support for object_position halt - call object_position halt in check_for_cancel when requested v123 2014-11-06, MAN - workaround Linux USB3 bugs by adding command counting code and sending an even number of reads and writes during disconnect_fd v124 2014-12-09, MAN - support resolution controlled max page-height (fi-6/7xxx scanners) - reorder scanner sections in init_model chronologically v125 2014-12-16, MAN - remove USB packet counting code from v123, fix sanei_usb instead v126 2015-08-23, MAN - initial support for iX100 - add late_lut support for iX500/iX100 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 v134 2019-02-23, MAN - rewrite init_vpd for scanners which fail to report overscan correctly v135 2019-11-10, MAN - set has_MS_lamp=0 for fi-72x0, bug #134 SANE FLOW DIAGRAM - sane_init() : initialize backend . - sane_get_devices() : query list of scanner devices . - sane_open() : open a particular scanner device . . - sane_set_io_mode : set blocking mode . . - sane_get_select_fd : get scanner fd . . . . - sane_get_option_descriptor() : get option information . . - sane_control_option() : change option values . . - sane_get_parameters() : returns estimated scan parameters . . - (repeat previous 3 functions) . . . . - sane_start() : start image acquisition . . - sane_get_parameters() : returns actual scan parameters . . - sane_read() : read image data (from pipe) . . (sane_read called multiple times; after sane_read returns EOF, . . loop may continue with sane_start which may return a 2nd page . . when doing duplex scans, or load the next page from the ADF) . . . . - sane_cancel() : cancel operation . - sane_close() : close opened scanner device - sane_exit() : terminate use of backend */ /* * @@ Section 1 - Boilerplate */ #include "../include/sane/config.h" #include /*memcpy...*/ #include /*isspace*/ #include /*tan*/ #include /*usleep*/ #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_magic.h" #include "fujitsu-scsi.h" #include "fujitsu.h" #define DEBUG 1 #define BUILD 134 /* values for SANE_DEBUG_FUJITSU env var: - errors 5 - function trace 10 - function detail 15 - get/setopt cmds 20 - scsi/usb trace 25 - scsi/usb writes 30 - scsi/usb reads 31 - useless noise 35 */ /* ------------------------------------------------------------------------- */ /* if JPEG support is not enabled in sane.h, we setup our own defines */ #ifndef SANE_FRAME_JPEG #define SANE_FRAME_JPEG 0x0B #define SANE_JPEG_DISABLED 1 #endif /* ------------------------------------------------------------------------- */ #define STRING_FLATBED SANE_I18N("Flatbed") #define STRING_ADFFRONT SANE_I18N("ADF Front") #define STRING_ADFBACK SANE_I18N("ADF Back") #define STRING_ADFDUPLEX SANE_I18N("ADF Duplex") #define STRING_LINEART SANE_VALUE_SCAN_MODE_LINEART #define STRING_HALFTONE SANE_VALUE_SCAN_MODE_HALFTONE #define STRING_GRAYSCALE SANE_VALUE_SCAN_MODE_GRAY #define STRING_COLOR SANE_VALUE_SCAN_MODE_COLOR #define STRING_DEFAULT SANE_I18N("Default") #define STRING_ON SANE_I18N("On") #define STRING_OFF SANE_I18N("Off") #define STRING_DTC SANE_I18N("DTC") #define STRING_SDTC SANE_I18N("SDTC") #define STRING_DITHER SANE_I18N("Dither") #define STRING_DIFFUSION SANE_I18N("Diffusion") #define STRING_RED SANE_I18N("Red") #define STRING_GREEN SANE_I18N("Green") #define STRING_BLUE SANE_I18N("Blue") #define STRING_WHITE SANE_I18N("White") #define STRING_BLACK SANE_I18N("Black") #define STRING_NONE SANE_I18N("None") #define STRING_JPEG SANE_I18N("JPEG") #define STRING_CONTINUE SANE_I18N("Continue") #define STRING_STOP SANE_I18N("Stop") #define STRING_10MM SANE_I18N("10mm") #define STRING_15MM SANE_I18N("15mm") #define STRING_20MM SANE_I18N("20mm") #define STRING_HORIZONTAL SANE_I18N("Horizontal") #define STRING_HORIZONTALBOLD SANE_I18N("Horizontal bold") #define STRING_HORIZONTALNARROW SANE_I18N("Horizontal narrow") #define STRING_VERTICAL SANE_I18N("Vertical") #define STRING_VERTICALBOLD SANE_I18N("Vertical bold") #define STRING_TOPTOBOTTOM SANE_I18N("Top to bottom") #define STRING_BOTTOMTOTOP SANE_I18N("Bottom to top") #define STRING_FRONT SANE_I18N("Front") #define STRING_BACK SANE_I18N("Back") #define max(a,b) (((a)>(b))?(a):(b)) /* Also set via config file. */ static int global_buffer_size = 64 * 1024; /* * used by attach* and sane_get_devices * a ptr to a null term array of ptrs to SANE_Device structs * a ptr to a single-linked list of fujitsu structs */ static const SANE_Device **sane_devArray = NULL; static struct fujitsu *fujitsu_devList = NULL; /* * @@ Section 2 - SANE & scanner init code */ /* * Called by SANE initially. * * From the SANE spec: * This function must be called before any other SANE function can be * called. The behavior of a SANE backend is undefined if this * function is not called first. The version code of the backend is * returned in the value pointed to by version_code. If that pointer * is NULL, no version code is returned. Argument authorize is either * a pointer to a function that is invoked when the backend requires * authentication for a specific resource or NULL if the frontend does * not support authentication. */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { authorize = authorize; /* get rid of compiler warning */ DBG_INIT (); DBG (10, "sane_init: start\n"); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (5, "sane_init: fujitsu backend %d.%d.%d, from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); sanei_magic_init(); DBG (10, "sane_init: finish\n"); return SANE_STATUS_GOOD; } /* * Called by SANE to find out about supported devices. * * From the SANE spec: * This function can be used to query the list of devices that are * available. If the function executes successfully, it stores a * pointer to a NULL terminated array of pointers to SANE_Device * structures in *device_list. The returned list is guaranteed to * remain unchanged and valid until (a) another call to this function * is performed or (b) a call to sane_exit() is performed. This * function can be called repeatedly to detect when new devices become * available. If argument local_only is true, only local devices are * returned (devices directly attached to the machine that SANE is * running on). If it is false, the device list includes all remote * devices that are accessible to the SANE library. * * SANE does not require that this function is called before a * sane_open() call is performed. A device name may be specified * explicitly by a user which would make it unnecessary and * undesirable to call this function first. */ /* * Read the config file, find scanners with help from sanei_* * and store in global device structs */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { SANE_Status ret = SANE_STATUS_GOOD; struct fujitsu * s; struct fujitsu * prev = NULL; char line[PATH_MAX]; const char *lp; FILE *fp; int num_devices=0; int i=0; local_only = local_only; /* get rid of compiler warning */ DBG (10, "sane_get_devices: start\n"); /* mark all existing scanners as missing, attach_one will remove mark */ for (s = fujitsu_devList; s; s = s->next) { s->missing = 1; } sanei_usb_init(); /* set this to 64K before reading the file */ global_buffer_size = 64 * 1024; fp = sanei_config_open (FUJITSU_CONFIG_FILE); if (fp) { DBG (15, "sane_get_devices: reading config file %s\n", FUJITSU_CONFIG_FILE); while (sanei_config_read (line, PATH_MAX, fp)) { lp = line; /* ignore comments */ if (*lp == '#') continue; /* skip empty lines */ if (*lp == 0) continue; if ((strncmp ("option", lp, 6) == 0) && isspace (lp[6])) { lp += 6; lp = sanei_config_skip_whitespace (lp); /* we allow setting buffersize too big */ if ((strncmp (lp, "buffer-size", 11) == 0) && isspace (lp[11])) { int buf; lp += 11; lp = sanei_config_skip_whitespace (lp); buf = atoi (lp); if (buf < 4096) { DBG (5, "sane_get_devices: config option \"buffer-size\" (%d) is < 4096, ignoring!\n", buf); continue; } if (buf > 64*1024) { DBG (5, "sane_get_devices: config option \"buffer-size\" (%d) is > %d, warning!\n", buf, 64*1024); } DBG (15, "sane_get_devices: setting \"buffer-size\" to %d\n", buf); global_buffer_size = buf; } else { DBG (5, "sane_get_devices: config option \"%s\" unrecognized - ignored.\n", lp); } } else if ((strncmp ("usb", lp, 3) == 0) && isspace (lp[3])) { DBG (15, "sane_get_devices: looking for '%s'\n", lp); sanei_usb_attach_matching_devices(lp, attach_one_usb); } else if ((strncmp ("scsi", lp, 4) == 0) && isspace (lp[4])) { DBG (15, "sane_get_devices: looking for '%s'\n", lp); sanei_config_attach_matching_devices (lp, attach_one_scsi); } else{ DBG (5, "sane_get_devices: config line \"%s\" unrecognized - ignored.\n", lp); } } fclose (fp); } else { DBG (5, "sane_get_devices: missing required config file '%s'!\n", FUJITSU_CONFIG_FILE); } /*delete missing scanners from list*/ for (s = fujitsu_devList; s;) { if(s->missing){ DBG (5, "sane_get_devices: missing scanner %s\n",s->device_name); /*splice s out of list by changing pointer in prev to next*/ if(prev){ prev->next = s->next; free(s); s=prev->next; } /*remove s from head of list, using prev to cache it*/ else{ prev = s; s = s->next; free(prev); prev=NULL; /*reset head to next s*/ fujitsu_devList = s; } } else{ prev = s; s=prev->next; } } for (s = fujitsu_devList; s; s=s->next) { DBG (15, "sane_get_devices: found scanner %s\n",s->device_name); num_devices++; } DBG (15, "sane_get_devices: found %d scanner(s)\n",num_devices); if (sane_devArray) free (sane_devArray); sane_devArray = calloc (num_devices + 1, sizeof (SANE_Device*)); if (!sane_devArray) return SANE_STATUS_NO_MEM; for (s = fujitsu_devList; s; s=s->next) { sane_devArray[i++] = (SANE_Device *)&s->sane; } sane_devArray[i] = 0; if(device_list){ *device_list = sane_devArray; } DBG (10, "sane_get_devices: finish\n"); return ret; } /* callbacks used by sane_get_devices */ static SANE_Status attach_one_scsi (const char *device_name) { return attach_one(device_name,CONNECTION_SCSI); } static SANE_Status attach_one_usb (const char *device_name) { return attach_one(device_name,CONNECTION_USB); } /* build the scanner struct and link to global list * unless struct is already loaded, then pretend */ static SANE_Status attach_one (const char *device_name, int connType) { struct fujitsu *s; int ret; DBG (10, "attach_one: start\n"); DBG (15, "attach_one: looking for '%s'\n", device_name); for (s = fujitsu_devList; s; s = s->next) { if (strcmp (s->device_name, device_name) == 0){ DBG (10, "attach_one: already attached!\n"); s->missing = 0; return SANE_STATUS_GOOD; } } /* build a fujitsu struct to hold it */ if ((s = calloc (sizeof (*s), 1)) == NULL) return SANE_STATUS_NO_MEM; /* scsi command/data buffer */ s->buffer_size = global_buffer_size; /* copy the device name */ strcpy (s->device_name, device_name); /* connect the fd */ s->connection = connType; s->fd = -1; ret = connect_fd(s); if(ret != SANE_STATUS_GOOD){ free (s); return ret; } /* Now query the device to load its vendor/model/version */ ret = init_inquire (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); DBG (5, "attach_one: inquiry failed\n"); return ret; } /* load detailed specs/capabilities from the device */ ret = init_vpd (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); DBG (5, "attach_one: vpd 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); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); DBG (5, "attach_one: model failed\n"); return ret; } /* see what mode pages device supports */ ret = init_ms (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); DBG (5, "attach_one: ms failed\n"); return ret; } /* sets SANE option 'values' to good defaults */ ret = init_user (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); DBG (5, "attach_one: user failed\n"); return ret; } ret = init_options (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); DBG (5, "attach_one: options failed\n"); return ret; } ret = init_interlace (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s); DBG (5, "attach_one: interlace failed\n"); return ret; } /* load strings into sane_device struct */ s->sane.name = s->device_name; s->sane.vendor = s->vendor_name; s->sane.model = s->model_name; s->sane.type = "scanner"; /* change name in sane_device struct if scanner has serial number */ ret = init_serial (s); if (ret == SANE_STATUS_GOOD) { s->sane.name = s->serial_name; } else{ DBG (5, "attach_one: serial number unsupported?\n"); } /* we close the connection, so that another backend can talk to scanner */ disconnect_fd(s); /* store this scanner in global vars */ s->next = fujitsu_devList; fujitsu_devList = s; DBG (10, "attach_one: finish\n"); return SANE_STATUS_GOOD; } /* * connect the fd in the scanner struct */ static SANE_Status connect_fd (struct fujitsu *s) { SANE_Status ret; int buffer_size = s->buffer_size; DBG (10, "connect_fd: start\n"); if(s->fd > -1){ DBG (5, "connect_fd: already open\n"); ret = SANE_STATUS_GOOD; } else if (s->connection == CONNECTION_USB) { DBG (15, "connect_fd: opening USB device\n"); ret = sanei_usb_open (s->device_name, &(s->fd)); } else { DBG (15, "connect_fd: opening SCSI device\n"); ret = sanei_scsi_open_extended (s->device_name, &(s->fd), sense_handler, s, &s->buffer_size); if(!ret && buffer_size != s->buffer_size){ DBG (5, "connect_fd: cannot get requested buffer size (%d/%d)\n", buffer_size, s->buffer_size); } } if(ret == SANE_STATUS_GOOD){ /* first generation usb scanners can get flaky if not closed * properly after last use. very first commands sent to device * must be prepared to correct this- see wait_scanner() */ ret = wait_scanner(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "connect_fd: could not wait_scanner\n"); disconnect_fd(s); } } else{ DBG (5, "connect_fd: could not open device: %d\n", ret); } DBG (10, "connect_fd: finish\n"); return ret; } /* * This routine will check if a certain device is a Fujitsu scanner * It also copies interesting data from INQUIRY into the handle structure */ static SANE_Status init_inquire (struct fujitsu *s) { int i; SANE_Status ret; unsigned char cmd[INQUIRY_len]; size_t cmdLen = INQUIRY_len; unsigned char in[INQUIRY_std_len]; size_t inLen = INQUIRY_std_len; DBG (10, "init_inquire: start\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, INQUIRY_code); set_IN_return_size (cmd, inLen); set_IN_evpd (cmd, 0); set_IN_page_code (cmd, 0); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if (ret != SANE_STATUS_GOOD){ return ret; } if (get_IN_periph_devtype (in) != IN_periph_devtype_scanner){ DBG (5, "The device at '%s' is not a scanner.\n", s->device_name); return SANE_STATUS_INVAL; } get_IN_vendor (in, s->vendor_name); get_IN_product (in, s->model_name); get_IN_version (in, s->version_name); s->vendor_name[8] = 0; s->model_name[16] = 0; s->version_name[4] = 0; /* gobble trailing spaces */ for (i = 7; s->vendor_name[i] == ' ' && i >= 0; i--) s->vendor_name[i] = 0; for (i = 15; s->model_name[i] == ' ' && i >= 0; i--) s->model_name[i] = 0; for (i = 3; s->version_name[i] == ' ' && i >= 0; i--) s->version_name[i] = 0; if (strcmp ("FUJITSU", s->vendor_name)) { DBG (5, "The device at '%s' is reported to be made by '%s'\n", s->device_name, s->vendor_name); DBG (5, "This backend only supports Fujitsu products.\n"); return SANE_STATUS_INVAL; } DBG (15, "init_inquire: Found %s scanner %s version %s at %s\n", s->vendor_name, s->model_name, s->version_name, s->device_name); /*some scanners list random data here*/ DBG (15, "inquiry options\n"); s->color_raster_offset = get_IN_color_offset(in); DBG (15, " color offset: %d lines\n",s->color_raster_offset); /* FIXME: we dont store all of these? */ DBG (15, " long gray scan: %d\n",get_IN_long_gray(in)); DBG (15, " long color scan: %d\n",get_IN_long_color(in)); DBG (15, " emulation mode: %d\n",get_IN_emulation(in)); DBG (15, " CMP/CGA: %d\n",get_IN_cmp_cga(in)); DBG (15, " background back: %d\n",get_IN_bg_back(in)); DBG (15, " background front: %d\n",get_IN_bg_front(in)); DBG (15, " background fb: %d\n",get_IN_bg_fb(in)); DBG (15, " back only scan: %d\n",get_IN_has_back(in)); s->duplex_raster_offset = get_IN_duplex_offset(in); DBG (15, " duplex offset: %d lines\n",s->duplex_raster_offset); DBG (10, "init_inquire: finish\n"); return SANE_STATUS_GOOD; } /* * Use INQUIRY VPD to setup more detail about the scanner */ static SANE_Status init_vpd (struct fujitsu *s) { SANE_Status ret; unsigned char cmd[INQUIRY_len]; size_t cmdLen = INQUIRY_len; unsigned char in[INQUIRY_vpd_len]; size_t inLen = INQUIRY_vpd_len; int payload_len, payload_off; DBG (10, "init_vpd: start\n"); /* get EVPD */ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, INQUIRY_code); set_IN_return_size (cmd, inLen); set_IN_evpd (cmd, 1); set_IN_page_code (cmd, 0xf0); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); /*FIXME no vpd, set some defaults? */ if (ret != SANE_STATUS_GOOD && ret != SANE_STATUS_EOF) { DBG (5, "init_vpd: Your scanner does not support VPD?\n"); DBG (5, "init_vpd: Please contact kitno455 at gmail dot com\n"); DBG (5, "init_vpd: with details of your scanner model.\n"); return ret; } /* In byte 4, the scanner sends the length of the remainder of * the payload. But, this value is often bogus. */ payload_len = get_IN_page_length(in); DBG (15, "init_vpd: length=%0x\n", payload_len); /* M3099 gives all data, but wrong length */ if (strstr (s->model_name, "M3099") && payload_len == 0x19){ DBG (5, "init_vpd: M3099 repair\n"); payload_len = 0x5f; } /* M3097G has short vpd, fill in missing part */ else if (strstr (s->model_name, "M3097G") && payload_len == 0x19){ unsigned char vpd3097g[] = { 0, 0, 0xc2, 0x08, 0, 0, 0, 0, 0, 0, 0xed, 0xbf, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0, 0x45, 0x35, 0, 0xe0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; DBG (5, "init_vpd: M3097G repair\n"); payload_len = 0x5f; memcpy(in+0x1e,vpd3097g,sizeof(vpd3097g)); /*IPC*/ if(strstr (s->model_name, "i")){ DBG (5, "init_vpd: M3097G IPC repair\n"); /*subwin cmd*/ in[0x2b] = 1; /*rif/dtc/sdtc/outline/emph/sep/mirr/wlf*/ in[0x58] = 0xff; /*subwin/diffusion*/ in[0x59] = 0xc0; } /*CMP*/ if(strstr (s->model_name, "m")){ DBG (5, "init_vpd: M3097G CMP repair\n"); /*4megs*/ in[0x23] = 0x40; /*mh/mr/mmr*/ in[0x5a] = 0xe0; } } /* all other known scanners have at least 0x5f, * less would require software changes like above */ else if (payload_len < 0x5f) { DBG (5, "init_vpd: Your scanner supports only partial VPD?\n"); DBG (5, "init_vpd: Please contact kitno455 at gmail dot com\n"); DBG (5, "init_vpd: with details of your scanner model.\n"); return SANE_STATUS_INVAL; } /* Special case- some scanners will under-report the amount of * valid vpd that they send, and return the default length. * Adding 4 more bytes allows us to include the overscan info. * Scanners that don't support overscan seem to have all zeros * in these bytes, so no harm is done. * This may be an 'off-by-four' error in the firmware. */ else if (payload_len == 0x5f){ payload_len += 4; } /* Having an offset from the beginning of the payload * is more useful than from byte 4, as that matches the * documentation more closely. */ payload_off = payload_len + 4; /* everything that appears in bytes 0 to 0x1d */ DBG (15, "standard options\n"); s->basic_x_res = get_IN_basic_x_res (in); DBG (15, " basic x res: %d dpi\n",s->basic_x_res); s->basic_y_res = get_IN_basic_y_res (in); DBG (15, " basic y res: %d dpi\n",s->basic_y_res); s->step_x_res[MODE_LINEART] = get_IN_step_x_res (in); DBG (15, " step x res: %d dpi\n", s->step_x_res[MODE_LINEART]); s->step_y_res[MODE_LINEART] = get_IN_step_y_res (in); DBG (15, " step y res: %d dpi\n", s->step_y_res[MODE_LINEART]); s->max_x_res = get_IN_max_x_res (in); DBG (15, " max x res: %d dpi\n", s->max_x_res); s->max_y_res = get_IN_max_y_res (in); DBG (15, " max y res: %d dpi\n", s->max_y_res); s->min_x_res = get_IN_min_x_res (in); DBG (15, " min x res: %d dpi\n", s->min_x_res); s->min_y_res = get_IN_min_y_res (in); DBG (15, " min y res: %d dpi\n", s->min_y_res); /* some scanners list B&W resolutions. */ s->std_res[0] = get_IN_std_res_60 (in); DBG (15, " 60 dpi: %d\n", s->std_res[0]); s->std_res[1] = get_IN_std_res_75 (in); DBG (15, " 75 dpi: %d\n", s->std_res[1]); s->std_res[2] = get_IN_std_res_100 (in); DBG (15, " 100 dpi: %d\n", s->std_res[2]); s->std_res[3] = get_IN_std_res_120 (in); DBG (15, " 120 dpi: %d\n", s->std_res[3]); s->std_res[4] = get_IN_std_res_150 (in); DBG (15, " 150 dpi: %d\n", s->std_res[4]); s->std_res[5] = get_IN_std_res_160 (in); DBG (15, " 160 dpi: %d\n", s->std_res[5]); s->std_res[6] = get_IN_std_res_180 (in); DBG (15, " 180 dpi: %d\n", s->std_res[6]); s->std_res[7] = get_IN_std_res_200 (in); DBG (15, " 200 dpi: %d\n", s->std_res[7]); s->std_res[8] = get_IN_std_res_240 (in); DBG (15, " 240 dpi: %d\n", s->std_res[8]); s->std_res[9] = get_IN_std_res_300 (in); DBG (15, " 300 dpi: %d\n", s->std_res[9]); s->std_res[10] = get_IN_std_res_320 (in); DBG (15, " 320 dpi: %d\n", s->std_res[10]); s->std_res[11] = get_IN_std_res_400 (in); DBG (15, " 400 dpi: %d\n", s->std_res[11]); s->std_res[12] = get_IN_std_res_480 (in); DBG (15, " 480 dpi: %d\n", s->std_res[12]); s->std_res[13] = get_IN_std_res_600 (in); DBG (15, " 600 dpi: %d\n", s->std_res[13]); s->std_res[14] = get_IN_std_res_800 (in); DBG (15, " 800 dpi: %d\n", s->std_res[14]); s->std_res[15] = get_IN_std_res_1200 (in); DBG (15, " 1200 dpi: %d\n", s->std_res[15]); /* maximum window width and length are reported in basic units.*/ s->max_x_basic = get_IN_window_width(in); DBG(15, " max width: %2.2f inches\n",(float)s->max_x_basic/s->basic_x_res); s->max_y_basic = get_IN_window_length(in); DBG(15, " max length: %2.2f inches\n",(float)s->max_y_basic/s->basic_y_res); /* known modes */ s->can_overflow = get_IN_overflow(in); DBG (15, " overflow: %d\n", s->can_overflow); s->can_mode[MODE_LINEART] = get_IN_monochrome (in); DBG (15, " monochrome: %d\n", s->can_mode[MODE_LINEART]); s->can_mode[MODE_HALFTONE] = get_IN_half_tone (in); DBG (15, " halftone: %d\n", s->can_mode[MODE_HALFTONE]); s->can_mode[MODE_GRAYSCALE] = get_IN_multilevel (in); DBG (15, " grayscale: %d\n", s->can_mode[MODE_GRAYSCALE]); DBG (15, " color_monochrome: %d\n", get_IN_monochrome_rgb(in)); DBG (15, " color_halftone: %d\n", get_IN_half_tone_rgb(in)); s->can_mode[MODE_COLOR] = get_IN_multilevel_rgb (in); DBG (15, " color_grayscale: %d\n", s->can_mode[MODE_COLOR]); /* now we look at vendor specific data in bytes 0x1e onward */ DBG (15, "vendor options\n"); s->has_adf = get_IN_adf(in); DBG (15, " adf: %d\n", s->has_adf); s->has_flatbed = get_IN_flatbed(in); DBG (15, " flatbed: %d\n", s->has_flatbed); s->has_transparency = get_IN_transparency(in); DBG (15, " transparency: %d\n", s->has_transparency); s->has_duplex = get_IN_duplex(in); s->has_back = s->has_duplex; DBG (15, " duplex: %d\n", s->has_duplex); s->has_endorser_b = get_IN_endorser_b(in); DBG (15, " back endorser: %d\n", s->has_endorser_b); s->has_barcode = get_IN_barcode(in); DBG (15, " barcode: %d\n", s->has_barcode); s->has_operator_panel = get_IN_operator_panel(in); DBG (15, " operator panel: %d\n", s->has_operator_panel); s->has_endorser_f = get_IN_endorser_f(in); DBG (15, " front endorser: %d\n", s->has_endorser_f); DBG (15, " multi-purpose stacker: %d\n", get_IN_mp_stacker(in)); DBG (15, " prepick: %d\n", get_IN_prepick(in)); DBG (15, " mf detect: %d\n", get_IN_mf_detect(in)); s->has_paper_protect = get_IN_paperprot(in); DBG (15, " paper protection: %d\n", s->has_paper_protect); s->adbits = get_IN_adbits(in); DBG (15, " A/D bits: %d\n",s->adbits); s->buffer_bytes = get_IN_buffer_bytes(in); DBG (15, " buffer bytes: %d\n",s->buffer_bytes); DBG (15, "Standard commands\n"); /* std scsi command support byte 26*/ s->has_cmd_msen10 = get_IN_has_cmd_msen10(in); DBG (15, " mode_sense_10 cmd: %d\n", s->has_cmd_msen10); s->has_cmd_msel10 = get_IN_has_cmd_msel10(in); DBG (15, " mode_select_10 cmd: %d\n", s->has_cmd_msel10); /* std scsi command support byte 27*/ s->has_cmd_lsen = get_IN_has_cmd_lsen(in); DBG (15, " log_sense cmd: %d\n", s->has_cmd_lsen); s->has_cmd_lsel = get_IN_has_cmd_lsel(in); DBG (15, " log_select cmd: %d\n", s->has_cmd_lsel); s->has_cmd_change = get_IN_has_cmd_change(in); DBG (15, " change cmd: %d\n", s->has_cmd_change); s->has_cmd_rbuff = get_IN_has_cmd_rbuff(in); DBG (15, " read_buffer cmd: %d\n", s->has_cmd_rbuff); s->has_cmd_wbuff = get_IN_has_cmd_wbuff(in); DBG (15, " write_buffer cmd: %d\n", s->has_cmd_wbuff); s->has_cmd_cav = get_IN_has_cmd_cav(in); DBG (15, " copy_and_verify cmd: %d\n", s->has_cmd_cav); s->has_cmd_comp = get_IN_has_cmd_comp(in); DBG (15, " compare cmd: %d\n", s->has_cmd_comp); s->has_cmd_gdbs = get_IN_has_cmd_gdbs(in); DBG (15, " get_d_b_status cmd: %d\n", s->has_cmd_gdbs); /* std scsi command support byte 28*/ s->has_cmd_op = get_IN_has_cmd_op(in); DBG (15, " object_pos cmd: %d\n", s->has_cmd_op); s->has_cmd_send = get_IN_has_cmd_send(in); DBG (15, " send cmd: %d\n", s->has_cmd_send); s->has_cmd_read = get_IN_has_cmd_read(in); DBG (15, " read cmd: %d\n", s->has_cmd_read); s->has_cmd_gwin = get_IN_has_cmd_gwin(in); DBG (15, " get_window cmd: %d\n", s->has_cmd_gwin); s->has_cmd_swin = get_IN_has_cmd_swin(in); DBG (15, " set_window cmd: %d\n", s->has_cmd_swin); s->has_cmd_sdiag = get_IN_has_cmd_sdiag(in); DBG (15, " send_diag cmd: %d\n", s->has_cmd_sdiag); s->has_cmd_rdiag = get_IN_has_cmd_rdiag(in); DBG (15, " read_diag cmd: %d\n", s->has_cmd_rdiag); s->has_cmd_scan = get_IN_has_cmd_scan(in); DBG (15, " scan cmd: %d\n", s->has_cmd_scan); /* std scsi command support byte 29*/ s->has_cmd_msen6 = get_IN_has_cmd_msen6(in); DBG (15, " mode_sense_6 cmd: %d\n", s->has_cmd_msen6); s->has_cmd_copy = get_IN_has_cmd_copy(in); DBG (15, " copy cmd: %d\n", s->has_cmd_copy); s->has_cmd_rel = get_IN_has_cmd_rel(in); DBG (15, " release cmd: %d\n", s->has_cmd_rel); s->has_cmd_runit = get_IN_has_cmd_runit(in); DBG (15, " reserve_unit cmd: %d\n", s->has_cmd_runit); s->has_cmd_msel6 = get_IN_has_cmd_msel6(in); DBG (15, " mode_select_6 cmd: %d\n", s->has_cmd_msel6); s->has_cmd_inq = get_IN_has_cmd_inq(in); DBG (15, " inquiry cmd: %d\n", s->has_cmd_inq); s->has_cmd_rs = get_IN_has_cmd_rs(in); DBG (15, " request_sense cmd: %d\n", s->has_cmd_rs); s->has_cmd_tur = get_IN_has_cmd_tur(in); DBG (15, " test_unit_ready cmd: %d\n", s->has_cmd_tur); /* vendor added scsi command support */ /* FIXME: there are more of these... */ DBG (15, "Vendor commands\n"); s->has_cmd_subwindow = get_IN_has_cmd_subwindow(in); DBG (15, " subwindow cmd: %d\n", s->has_cmd_subwindow); s->has_cmd_endorser = get_IN_has_cmd_endorser(in); DBG (15, " endorser cmd: %d\n", s->has_cmd_endorser); s->has_cmd_hw_status = get_IN_has_cmd_hw_status (in); DBG (15, " hardware status cmd: %d\n", s->has_cmd_hw_status); s->has_cmd_hw_status_2 = get_IN_has_cmd_hw_status_2 (in); DBG (15, " hardware status 2 cmd: %d\n", s->has_cmd_hw_status_2); s->has_cmd_hw_status_3 = get_IN_has_cmd_hw_status_3 (in); DBG (15, " hardware status 3 cmd: %d\n", s->has_cmd_hw_status_3); s->has_cmd_scanner_ctl = get_IN_has_cmd_scanner_ctl(in); DBG (15, " scanner control cmd: %d\n", s->has_cmd_scanner_ctl); s->has_cmd_device_restart = get_IN_has_cmd_device_restart(in); DBG (15, " device restart cmd: %d\n", s->has_cmd_device_restart); /* get threshold, brightness and contrast ranges. */ s->brightness_steps = get_IN_brightness_steps(in); DBG (15, " brightness steps: %d\n", s->brightness_steps); s->threshold_steps = get_IN_threshold_steps(in); DBG (15, " threshold steps: %d\n", s->threshold_steps); s->contrast_steps = get_IN_contrast_steps(in); DBG (15, " contrast steps: %d\n", s->contrast_steps); /* dither/gamma patterns */ s->num_internal_gamma = get_IN_num_gamma_internal (in); DBG (15, " built in gamma patterns: %d\n", s->num_internal_gamma); s->num_download_gamma = get_IN_num_gamma_download (in); DBG (15, " download gamma patterns: %d\n", s->num_download_gamma); s->num_internal_dither = get_IN_num_dither_internal (in); DBG (15, " built in dither patterns: %d\n", s->num_internal_dither); s->num_download_dither = get_IN_num_dither_download (in); DBG (15, " download dither patterns: %d\n", s->num_download_dither); /* ipc functions */ s->has_rif = get_IN_ipc_bw_rif (in); DBG (15, " RIF: %d\n", s->has_rif); s->has_dtc = get_IN_ipc_dtc(in); DBG (15, " DTC (AutoI): %d\n", s->has_dtc); s->has_sdtc = get_IN_ipc_sdtc(in); DBG (15, " SDTC (AutoII): %d\n", s->has_sdtc); s->has_outline = get_IN_ipc_outline_extraction (in); DBG (15, " outline extraction: %d\n", s->has_outline); s->has_emphasis = get_IN_ipc_image_emphasis (in); DBG (15, " image emphasis: %d\n", s->has_emphasis); s->has_autosep = get_IN_ipc_auto_separation (in); DBG (15, " automatic separation: %d\n", s->has_autosep); s->has_mirroring = get_IN_ipc_mirroring (in); DBG (15, " mirror image: %d\n", s->has_mirroring); s->has_wl_follow = get_IN_ipc_wl_follow (in); DBG (15, " white level follower: %d\n", s->has_wl_follow); /* byte 58 */ s->has_subwindow = get_IN_ipc_subwindow (in); DBG (15, " subwindow: %d\n", s->has_subwindow); s->has_diffusion = get_IN_ipc_diffusion (in); DBG (15, " diffusion: %d\n", s->has_diffusion); s->has_ipc3 = get_IN_ipc_ipc3 (in); DBG (15, " ipc3: %d\n", s->has_ipc3); s->has_rotation = get_IN_ipc_rotation (in); DBG (15, " rotation: %d\n", s->has_rotation); s->has_hybrid_crop_deskew = get_IN_ipc_hybrid_crop_deskew(in); DBG (15, " hybrid crop deskew: %d\n", s->has_hybrid_crop_deskew); /* this one is weird, overrides the payload length from scanner */ DBG (15, " vpd extends to byte 6f: %d\n", get_IN_vpd_thru_byte_6f(in)); if(get_IN_vpd_thru_byte_6f(in) && payload_off < 0x6f){ payload_off = 0x6f; } /* compression modes */ s->has_comp_MH = get_IN_compression_MH (in); DBG (15, " compression MH: %d\n", s->has_comp_MH); s->has_comp_MR = get_IN_compression_MR (in); DBG (15, " compression MR: %d\n", s->has_comp_MR); s->has_comp_MMR = get_IN_compression_MMR (in); DBG (15, " compression MMR: %d\n", s->has_comp_MMR); s->has_comp_JBIG = get_IN_compression_JBIG (in); DBG (15, " compression JBIG: %d\n", s->has_comp_JBIG); s->has_comp_JPG1 = get_IN_compression_JPG_BASE (in); DBG (15, " compression JPG1: %d\n", s->has_comp_JPG1); #ifdef SANE_JPEG_DISABLED DBG (15, " (Disabled)\n"); #endif s->has_comp_JPG2 = get_IN_compression_JPG_EXT (in); DBG (15, " compression JPG2: %d\n", s->has_comp_JPG2); s->has_comp_JPG3 = get_IN_compression_JPG_INDEP (in); DBG (15, " compression JPG3: %d\n", s->has_comp_JPG3); /* FIXME: we dont store these? */ DBG (15, " back endorser mech: %d\n", get_IN_endorser_b_mech(in)); DBG (15, " back endorser stamp: %d\n", get_IN_endorser_b_stamp(in)); DBG (15, " back endorser elec: %d\n", get_IN_endorser_b_elec(in)); DBG (15, " endorser max id: %d\n", get_IN_endorser_max_id(in)); DBG (15, " front endorser mech: %d\n", get_IN_endorser_f_mech(in)); DBG (15, " front endorser stamp: %d\n", get_IN_endorser_f_stamp(in)); DBG (15, " front endorser elec: %d\n", get_IN_endorser_f_elec(in)); s->endorser_type_b = get_IN_endorser_b_type(in); DBG (15, " back endorser type: %d\n", s->endorser_type_b); s->endorser_type_f = get_IN_endorser_f_type(in); DBG (15, " back endorser type: %d\n", s->endorser_type_f); DBG (15, " connection type: %d\n", get_IN_connection(in)); DBG (15, " endorser ext: %d\n", get_IN_endorser_type_ext(in)); DBG (15, " endorser pr_b: %d\n", get_IN_endorser_pre_back(in)); DBG (15, " endorser pr_f: %d\n", get_IN_endorser_pre_front(in)); DBG (15, " endorser po_b: %d\n", get_IN_endorser_post_back(in)); DBG (15, " endorser po_f: %d\n", get_IN_endorser_post_front(in)); s->os_x_basic = get_IN_x_overscan_size(in); DBG (15, " horizontal overscan: %d\n", s->os_x_basic); s->os_y_basic = get_IN_y_overscan_size(in); DBG (15, " vertical overscan: %d\n", s->os_y_basic); /* not all scanners go this far */ if (payload_off >= 0x68) { DBG (15, " default bg adf b: %d\n", get_IN_default_bg_adf_b(in)); DBG (15, " default bg adf f: %d\n", get_IN_default_bg_adf_f(in)); DBG (15, " default bg fb: %d\n", get_IN_default_bg_fb(in)); } if (payload_off >= 0x69) { DBG (15, " auto color: %d\n", get_IN_auto_color(in)); DBG (15, " blank skip: %d\n", get_IN_blank_skip(in)); DBG (15, " multi image: %d\n", get_IN_multi_image(in)); DBG (15, " f b type indep: %d\n", get_IN_f_b_type_indep(in)); DBG (15, " f b res indep: %d\n", get_IN_f_b_res_indep(in)); } if (payload_off >= 0x6a) { DBG (15, " dropout spec: %d\n", get_IN_dropout_spec(in)); DBG (15, " dropout non: %d\n", get_IN_dropout_non(in)); DBG (15, " dropout white: %d\n", get_IN_dropout_white(in)); } if (payload_off >= 0x6d) { 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); } /* this one is weird, overrides the payload length from scanner, * but the enlarged area is just null bytes, so we ignore this */ if (payload_off >= 0x6f) { DBG (15, " extra evpd length: %d\n", get_IN_evpd_len(in)); } if (payload_off >= 0x70) { 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)); 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)); DBG (15, " hq print: %d\n", get_IN_hq_print(in)); } if (payload_off >= 0x71) { DBG (15, " ext GHS len: %d\n", get_IN_ext_GHS_len(in)); } if (payload_off >= 0x72) { DBG (15, " smbc func: %d\n", get_IN_smbc_func(in)); 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)); s->has_df_recovery = get_IN_mf_recover_lvl(in); DBG (15, " mf recover lvl: %d\n", s->has_df_recovery); } if (payload_off >= 0x73) { DBG (15, " first read time: %d\n", get_IN_first_read_time(in)); DBG (15, " div scanning: %d\n", get_IN_div_scanning(in)); DBG (15, " start job: %d\n", get_IN_start_job(in)); DBG (15, " lifetime log: %d\n", get_IN_lifetime_log(in)); DBG (15, " imff save rest: %d\n", get_IN_imff_save_rest(in)); DBG (15, " wide scsi type: %d\n", get_IN_wide_scsi_type(in)); } if (payload_off >= 0x74) { DBG (15, " lut hybrid crop: %d\n", get_IN_lut_hybrid_crop(in)); DBG (15, " over under amt: %d\n", get_IN_over_under_amt(in)); DBG (15, " rgb lut: %d\n", get_IN_rgb_lut(in)); DBG (15, " num lut dl: %d\n", get_IN_num_lut_dl(in)); } /* Various items below are poorly documented or missing */ if (payload_off >= 0x76) { s->has_off_mode = get_IN_erp_lot6_supp(in); DBG (15, " ErP Lot6 (power off timer): %d\n", s->has_off_mode); DBG (15, " sync next feed: %d\n", get_IN_sync_next_feed(in)); } if (payload_off >= 0x79) { DBG (15, " battery: %d\n", get_IN_battery(in)); DBG (15, " battery save: %d\n", get_IN_battery_save(in)); DBG (15, " object position reverse: %d\n", get_IN_op_reverse(in)); } if (payload_off >= 0x7a) { s->has_op_halt = get_IN_op_halt(in); DBG (15, " object position halt: %d\n", s->has_op_halt); } DBG (10, "init_vpd: finish\n"); return SANE_STATUS_GOOD; } static SANE_Status init_ms(struct fujitsu *s) { int ret; int oldDbg=0; unsigned char cmd[MODE_SENSE_len]; size_t cmdLen = MODE_SENSE_len; unsigned char in[MODE_SENSE_data_len]; size_t inLen = MODE_SENSE_data_len; DBG (10, "init_ms: start\n"); if(!s->has_cmd_msen6){ DBG (10, "init_ms: unsupported\n"); return SANE_STATUS_GOOD; } /* some of the following probes will produce errors */ /* so we reduce the dbg level to reduce the noise */ /* however, if user builds with NDEBUG, we can't do that */ /* so we protect the code with the following macro */ IF_DBG( oldDbg=DBG_LEVEL; ) IF_DBG( if(DBG_LEVEL < 35){ DBG_LEVEL = 0; } ) memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SENSE_code); set_MSEN_xfer_length (cmd, inLen); if(s->has_MS_autocolor){ DBG (35, "init_ms: autocolor\n"); set_MSEN_pc(cmd, MS_pc_autocolor); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_autocolor=0; } } if(s->has_MS_prepick){ DBG (35, "init_ms: prepick\n"); set_MSEN_pc(cmd, MS_pc_prepick); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_prepick=0; } } if(s->has_MS_sleep){ DBG (35, "init_ms: sleep\n"); set_MSEN_pc(cmd, MS_pc_sleep); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_sleep=0; } } if(s->has_MS_duplex){ DBG (35, "init_ms: duplex\n"); set_MSEN_pc(cmd, MS_pc_duplex); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_duplex=0; } } if(s->has_MS_rand){ DBG (35, "init_ms: rand\n"); set_MSEN_pc(cmd, MS_pc_rand); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_rand=0; } } if(s->has_MS_bg){ DBG (35, "init_ms: bg\n"); set_MSEN_pc(cmd, MS_pc_bg); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_bg=0; } } if(s->has_MS_df){ DBG (35, "init_ms: df\n"); set_MSEN_pc(cmd, MS_pc_df); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_df=0; } } if(s->has_MS_dropout){ DBG (35, "init_ms: dropout\n"); set_MSEN_pc(cmd, MS_pc_dropout); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_dropout=0; } } if(s->has_MS_buff){ DBG (35, "init_ms: buffer\n"); set_MSEN_pc(cmd, MS_pc_buff); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_buff=0; } } if(s->has_MS_auto){ DBG (35, "init_ms: auto\n"); set_MSEN_pc(cmd, MS_pc_auto); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_auto=0; } } if(s->has_MS_lamp){ DBG (35, "init_ms: lamp\n"); set_MSEN_pc(cmd, MS_pc_lamp); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_lamp=0; } } if(s->has_MS_jobsep){ DBG (35, "init_ms: jobsep\n"); set_MSEN_pc(cmd, MS_pc_jobsep); inLen = MODE_SENSE_data_len; ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if(ret != SANE_STATUS_GOOD){ s->has_MS_jobsep=0; } } IF_DBG (DBG_LEVEL = oldDbg;) DBG (15, " autocolor: %d\n", s->has_MS_autocolor); DBG (15, " prepick: %d\n", s->has_MS_prepick); DBG (15, " sleep: %d\n", s->has_MS_sleep); DBG (15, " duplex: %d\n", s->has_MS_duplex); DBG (15, " rand: %d\n", s->has_MS_rand); DBG (15, " bg: %d\n", s->has_MS_bg); DBG (15, " df: %d\n", s->has_MS_df); DBG (15, " dropout: %d\n", s->has_MS_dropout); DBG (15, " buff: %d\n", s->has_MS_buff); DBG (15, " auto: %d\n", s->has_MS_auto); DBG (15, " lamp: %d\n", s->has_MS_lamp); DBG (15, " jobsep: %d\n", s->has_MS_jobsep); DBG (10, "init_ms: finish\n"); return SANE_STATUS_GOOD; } /* * get model specific info that is not in vpd, and correct * errors in vpd data. struct is already initialized to 0. */ static SANE_Status init_model (struct fujitsu *s) { int i; DBG (10, "init_model: start\n"); /* for most scanners these are good defaults */ if(s->can_mode[MODE_LINEART] || s->can_mode[MODE_HALFTONE] || s->can_mode[MODE_GRAYSCALE] ){ s->has_vuid_mono = 1; } if(s->can_mode[MODE_COLOR]){ s->has_vuid_color = 1; } for(i=MODE_HALFTONE;i<=MODE_COLOR;i++){ s->step_x_res[i] = s->step_x_res[MODE_LINEART]; s->step_y_res[i] = s->step_y_res[MODE_LINEART]; } s->reverse_by_mode[MODE_LINEART] = 0; s->reverse_by_mode[MODE_HALFTONE] = 0; s->reverse_by_mode[MODE_GRAYSCALE] = 1; s->reverse_by_mode[MODE_COLOR] = 1; s->ppl_mod_by_mode[MODE_LINEART] = 8; s->ppl_mod_by_mode[MODE_HALFTONE] = 8; s->ppl_mod_by_mode[MODE_GRAYSCALE] = 1; s->ppl_mod_by_mode[MODE_COLOR] = 1; /* 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, */ /* the scanner will fall back to the brightness/contrast LUT */ if (!s->num_internal_gamma && s->num_download_gamma){ s->window_gamma = 0x80; } /* endorser type tells string length (among other things) */ if(s->has_endorser_b){ /*old-style is 40 bytes*/ if(s->endorser_type_b == ET_OLD){ s->endorser_string_len = 40; } /*short new style is 60 bytes*/ else if(s->endorser_type_b == ET_30){ s->endorser_string_len = 60; } /*long new style is 80 bytes*/ else if(s->endorser_type_b == ET_40){ s->endorser_string_len = 80; } } else if(s->has_endorser_f){ /*old-style is 40 bytes*/ if(s->endorser_type_f == ET_OLD){ s->endorser_string_len = 40; } /*short new style is 60 bytes*/ else if(s->endorser_type_f == ET_30){ s->endorser_string_len = 60; } /*long new style is 80 bytes*/ else if(s->endorser_type_f == ET_40){ s->endorser_string_len = 80; } } /* convert to 1200dpi units */ s->max_x = s->max_x_basic * 1200 / s->basic_x_res; s->max_y = s->max_y_basic * 1200 / s->basic_y_res; /* setup the list with a single choice, in 1200dpi units, at max res */ s->max_y_by_res[0].res = s->max_y_res; s->max_y_by_res[0].len = s->max_y; /* assume these are same as adf, override below */ s->max_x_fb = s->max_x; s->max_y_fb = s->max_y; /* assume we can do these. we will disable * them at runtime if they cannot */ s->has_pixelsize = 1; s->has_MS_autocolor = 1; s->has_MS_prepick = 1; s->has_MS_sleep = 1; s->has_MS_duplex = 1; s->has_MS_rand = 1; s->has_MS_bg = 1; s->has_MS_df = 1; s->has_MS_dropout = 1; s->has_MS_buff = 1; s->has_MS_auto = 1; s->has_MS_lamp = 1; s->has_MS_jobsep = 1; /* these two scanners lie about their capabilities, * and/or differ significantly from most other models */ if (strstr (s->model_name, "M3091") || strstr (s->model_name, "M3092")) { /* lies */ s->has_rif = 1; s->has_back = 0; s->adbits = 8; if (strstr (s->model_name, "M3092")) s->has_flatbed = 1; /*actually does have res range in non-color modes */ for(i=MODE_LINEART;istep_x_res[i] = 1; s->step_y_res[i] = 1; } /*but the color mode y list is very limited, only 75, 150, 300 (and 600)*/ for(i=0;i<16;i++){ s->std_res[i] = 0; } s->std_res[1] = 1; s->std_res[4] = 1; s->std_res[9] = 1; /* weirdness */ s->has_vuid_3091 = 1; s->has_vuid_color = 0; s->has_vuid_mono = 0; s->has_short_pixelsize = 1; s->color_interlace = COLOR_INTERLACE_3091; s->duplex_interlace = DUPLEX_INTERLACE_3091; s->ghs_in_rs = 1; s->window_gamma = 0; s->reverse_by_mode[MODE_LINEART] = 1; s->reverse_by_mode[MODE_HALFTONE] = 1; s->reverse_by_mode[MODE_GRAYSCALE] = 0; s->reverse_by_mode[MODE_COLOR] = 0; } else if (strstr (s->model_name, "M3093")){ /* lies */ s->has_back = 0; s->adbits = 8; /* weirdness */ s->duplex_interlace = DUPLEX_INTERLACE_NONE; } else if ( strstr (s->model_name, "M309") || strstr (s->model_name, "M409")){ /* weirdness */ s->broken_diag_serial = 1; /* lies */ s->adbits = 8; } else if (strstr (s->model_name, "fi-4120C2") || strstr (s->model_name, "fi-4220C2") ) { /* missing from vpd */ s->os_x_basic = 118; s->os_y_basic = 118; s->max_y_fb = 14032; } else if (strstr (s->model_name, "fi-4220C")){ /* missing from vpd */ s->max_y_fb = 14032; } else if (strstr (s->model_name,"fi-4340") || strstr (s->model_name, "fi-4750") ) { /* weirdness */ s->broken_diag_serial = 1; } /* some firmware versions use capital f? */ else if (strstr (s->model_name, "Fi-4860") || strstr (s->model_name, "fi-4860") ) { /* weirdness */ s->broken_diag_serial = 1; s->ppl_mod_by_mode[MODE_LINEART] = 32; s->ppl_mod_by_mode[MODE_HALFTONE] = 32; s->ppl_mod_by_mode[MODE_GRAYSCALE] = 4; s->ppl_mod_by_mode[MODE_COLOR] = 4; } /* some firmware versions use capital f? */ else if (strstr (s->model_name, "Fi-4990") || strstr (s->model_name, "fi-4990") ) { /* weirdness */ s->duplex_interlace = DUPLEX_INTERLACE_NONE; s->color_interlace = COLOR_INTERLACE_RRGGBB; s->ppl_mod_by_mode[MODE_LINEART] = 32; s->ppl_mod_by_mode[MODE_HALFTONE] = 32; s->ppl_mod_by_mode[MODE_GRAYSCALE] = 4; s->ppl_mod_by_mode[MODE_COLOR] = 4; } else if (strstr (s->model_name,"fi-5110C")){ /* missing from vpd */ s->os_x_basic = 147; s->os_y_basic = 147; } else if (strstr (s->model_name,"fi-5110EOX")){ /* weirdness */ s->cropping_mode = CROP_ABSOLUTE; } else if (strstr (s->model_name,"fi-5220C")){ /* missing from vpd */ s->max_x_fb = 10764; s->max_y_fb = 14032; } else if (strstr (s->model_name,"fi-5530") || strstr (s->model_name,"fi-5650") || strstr (s->model_name,"fi-5750")){ /* lies - usb only */ if(s->connection == CONNECTION_USB) s->adbits = 8; } else if (strstr (s->model_name,"S1500")){ /*lies*/ s->has_MS_bg=0; s->has_MS_prepick=0; } /* also includes the 'Z' models */ else if (strstr (s->model_name,"fi-6130") || strstr (s->model_name,"fi-6140")){ /* weirdness */ /* these machines have longer max paper at lower res */ s->max_y_by_res[1].res = 200; s->max_y_by_res[1].len = 151512; } /* also includes the 'Z' models */ else if (strstr (s->model_name,"fi-6230") || strstr (s->model_name,"fi-6240")){ /* weirdness */ /* these machines have longer max paper at lower res */ s->max_y_by_res[1].res = 200; s->max_y_by_res[1].len = 151512; /* missing from vpd */ s->max_x_fb = 10764; /* was previously 10488 */ s->max_y_fb = 14032; /* some scanners can be slightly more? */ } else if (strstr (s->model_name,"fi-6110")){ /* weirdness */ /* these machines have longer max paper at lower res */ s->max_y_by_res[1].res = 200; s->max_y_by_res[1].len = 151512; /*lies*/ s->has_MS_bg=0; s->has_MS_prepick=0; } else if (strstr (s->model_name,"fi-6800") || strstr (s->model_name,"fi-5900")){ /* do not need overrides */ } else if (strstr (s->model_name,"iX500")){ /* locks up scanner if we try to auto detect */ s->has_MS_lamp = 0; /* weirdness */ s->need_q_table = 1; s->late_lut = 1; s->need_diag_preread = 1; s->ppl_mod_by_mode[MODE_COLOR] = 2; s->hopper_before_op = 1; s->no_wait_after_op = 1; /* lies */ s->adbits = 8; /* we have to simulate these in software*/ s->can_mode[MODE_LINEART] = 2; s->can_mode[MODE_GRAYSCALE] = 2; /* dont bother with this one */ s->can_mode[MODE_HALFTONE] = 0; } /*mostly copied from iX500*/ else if (strstr (s->model_name,"iX100")){ /* locks up scanner if we try to auto detect */ s->has_MS_lamp = 0; /* weirdness */ s->need_q_table = 1; s->late_lut = 1; s->need_diag_preread = 1; s->ppl_mod_by_mode[MODE_COLOR] = 2; s->hopper_before_op = 1; s->no_wait_after_op = 1; /* lies */ s->adbits = 8; /* dont bother with this one */ s->can_mode[MODE_HALFTONE] = 0; } 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 */ 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-7280") || strstr (s->model_name,"fi-7260")){ /* locks up scanner if we try to auto detect */ s->has_MS_lamp = 0; /* 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; /* missing from vpd */ 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; } static SANE_Status set_mode (struct fujitsu *s, int mode) { int i; /* give the user what they asked for */ s->u_mode = mode; /* give the scanner the closest mode */ for(i=MODE_COLOR;i>=mode;i--){ if(s->can_mode[i] == 1){ s->s_mode = i; } } return SANE_STATUS_GOOD; } /* * set good default user values. * struct is already initialized to 0. */ static SANE_Status init_user (struct fujitsu *s) { DBG (10, "init_user: start\n"); /* source */ if(s->has_flatbed) s->source = SOURCE_FLATBED; else if(s->has_adf) s->source = SOURCE_ADF_FRONT; /* scan mode */ if(s->can_mode[MODE_LINEART]) set_mode(s,MODE_LINEART); else if(s->can_mode[MODE_HALFTONE]) set_mode(s,MODE_HALFTONE); else if(s->can_mode[MODE_GRAYSCALE]) set_mode(s,MODE_GRAYSCALE); else if(s->can_mode[MODE_COLOR]) set_mode(s,MODE_COLOR); /*x res*/ s->resolution_x = s->basic_x_res; /*y res*/ s->resolution_y = s->basic_y_res; if(s->resolution_y > s->resolution_x){ s->resolution_y = s->resolution_x; } /* page width US-Letter */ s->page_width = 8.5 * 1200; if(s->page_width > s->max_x){ s->page_width = s->max_x; } /* page height US-Letter */ s->page_height = 11 * 1200; set_max_y(s); if(s->page_height > s->max_y){ s->page_height = s->max_y; } /* bottom-right x */ s->br_x = s->page_width; /* bottom-right y */ s->br_y = s->page_height; /* gamma ramp exponent */ s->gamma = 1; /* safe endorser settings */ s->u_endorser_bits=16; s->u_endorser_step=1; s->u_endorser_side=ED_back; if(s->has_endorser_f){ s->u_endorser_side=ED_front; } s->u_endorser_dir=DIR_TTB; strcpy((char *)s->u_endorser_string,"%05ud"); /* more recent machines default to this being 'on', * * which causes the scanner to ingest multiple pages * * even when the user only wants one */ s->buff_mode = MSEL_OFF; /* useful features of newer scanners which we turn on, * even though the scanner defaults to off */ if(s->has_paper_protect){ s->paper_protect = MSEL_ON; } if(s->has_staple_detect){ s->staple_detect = MSEL_ON; } if(s->has_df_recovery){ s->df_recovery = MSEL_ON; } if(s->has_adv_paper_prot){ s->adv_paper_prot = MSEL_ON; } s->off_time = 240; DBG (10, "init_user: finish\n"); return SANE_STATUS_GOOD; } /* * This function presets the "option" array to blank */ static SANE_Status init_options (struct fujitsu *s) { int i; DBG (10, "init_options: start\n"); memset (s->opt, 0, sizeof (s->opt)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].name = "filler"; s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_INACTIVE; } /* go ahead and setup the first opt, because * frontend may call control_option on it * before calling get_option_descriptor */ s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; DBG (10, "init_options: finish\n"); return SANE_STATUS_GOOD; } /* * send set window repeatedly to color scanners, * searching for valid color interlacing mode */ static SANE_Status init_interlace (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; int curr_mode = s->u_mode; int oldDbg=0; DBG (10, "init_interlace: start\n"); if(s->color_interlace != COLOR_INTERLACE_UNK){ DBG (10, "init_interlace: already loaded\n"); return SANE_STATUS_GOOD; } if(!s->has_vuid_color){ DBG (10, "init_interlace: color unsupported\n"); return SANE_STATUS_GOOD; } /* set to color mode first */ set_mode(s,MODE_COLOR); /* load our own private copy of scan params */ ret = update_params(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "init_interlace: ERROR: cannot update params\n"); return ret; } /*loop thru all the formats we support*/ for(s->color_interlace = COLOR_INTERLACE_RGB; s->color_interlace <= COLOR_INTERLACE_RRGGBB; s->color_interlace++){ /* some of the following probes will produce errors */ /* so we reduce the dbg level to reduce the noise */ /* however, if user builds with NDEBUG, we can't do that */ /* so we protect the code with the following macro */ IF_DBG( oldDbg=DBG_LEVEL; ) IF_DBG( if(DBG_LEVEL < 35){ DBG_LEVEL = 0; } ) ret = set_window(s); IF_DBG (DBG_LEVEL = oldDbg;) if (ret == SANE_STATUS_GOOD){ break; } else{ DBG (15, "init_interlace: not %d\n", s->color_interlace); } } if (ret != SANE_STATUS_GOOD){ DBG (5, "init_interlace: no valid interlacings\n"); return SANE_STATUS_INVAL; } DBG (15, "init_interlace: color_interlace: %d\n",s->color_interlace); /* restore mode */ set_mode(s,curr_mode); DBG (10, "init_interlace: finish\n"); return SANE_STATUS_GOOD; } /* * send diag query for serial number, and read result back * use it to build a unique name for scanner in s->serial_name */ static SANE_Status init_serial (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned int sn = 0; unsigned char cmd[SEND_DIAGNOSTIC_len]; /*also big enough for READ_DIAG*/ size_t cmdLen = SEND_DIAGNOSTIC_len; unsigned char out[SD_gdi_len]; size_t outLen = SD_gdi_len; unsigned char in[RD_gdi_len]; size_t inLen = RD_gdi_len; DBG (10, "init_serial: start\n"); if (!s->has_cmd_sdiag || !s->has_cmd_rdiag || s->broken_diag_serial){ DBG (5, "init_serial: send/read diag not supported, returning\n"); return SANE_STATUS_INVAL; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SEND_DIAGNOSTIC_code); set_SD_slftst(cmd, 0); set_SD_xferlen(cmd, outLen); memcpy(out,SD_gdi_string,outLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); if (ret != SANE_STATUS_GOOD){ DBG (5, "init_serial: send diag error: %d\n", ret); return ret; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, READ_DIAGNOSTIC_code); set_RD_xferlen(cmd, inLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if (ret != SANE_STATUS_GOOD){ DBG (5, "init_serial: read diag error: %d\n", ret); return ret; } sn = get_RD_id_serial(in); DBG (15, "init_serial: found sn %d\n",sn); sprintf(s->serial_name, "%s:%d", s->model_name, sn); DBG (15, "init_serial: serial_name: %s\n",s->serial_name); DBG (10, "init_serial: finish\n"); return SANE_STATUS_GOOD; } /* * From the SANE spec: * This function is used to establish a connection to a particular * device. The name of the device to be opened is passed in argument * name. If the call completes successfully, a handle for the device * is returned in *h. As a special case, specifying a zero-length * string as the device requests opening the first available device * (if there is such a device). */ SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle) { struct fujitsu *dev = NULL; struct fujitsu *s = NULL; SANE_Status ret; DBG (10, "sane_open: start\n"); if(fujitsu_devList){ DBG (15, "sane_open: searching currently attached scanners\n"); } else{ DBG (15, "sane_open: no scanners currently attached, attaching\n"); ret = sane_get_devices(NULL,0); if(ret != SANE_STATUS_GOOD){ return ret; } } if(!name || !name[0]){ DBG (15, "sane_open: no device requested, using default\n"); s = fujitsu_devList; } else{ DBG (15, "sane_open: device %s requested\n", name); for (dev = fujitsu_devList; dev; dev = dev->next) { if (strcmp (dev->sane.name, name) == 0 || strcmp (dev->device_name, name) == 0) { /*always allow sanei devname*/ s = dev; break; } } } if (!s) { DBG (5, "sane_open: no device found\n"); return SANE_STATUS_INVAL; } DBG (15, "sane_open: device %s found\n", s->sane.name); *handle = s; /* connect the fd so we can talk to scanner */ ret = connect_fd(s); if(ret != SANE_STATUS_GOOD){ return ret; } DBG (10, "sane_open: finish\n"); return SANE_STATUS_GOOD; } /* * @@ Section 3 - SANE Options functions */ /* * Returns the options we know. * * From the SANE spec: * This function is used to access option descriptors. The function * returns the option descriptor for option number n of the device * represented by handle h. Option number 0 is guaranteed to be a * valid option. Its value is an integer that specifies the number of * options that are available for device handle h (the count includes * option 0). If n is not a valid option index, the function returns * NULL. The returned option descriptor is guaranteed to remain valid * (and at the returned address) until the device is closed. */ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct fujitsu *s = handle; int i,j; SANE_Option_Descriptor *opt = &s->opt[option]; DBG (20, "sane_get_option_descriptor: %d\n", option); if ((unsigned) option >= NUM_OPTIONS) return NULL; /* "Mode" group -------------------------------------------------------- */ if(option==OPT_STANDARD_GROUP){ opt->name = SANE_NAME_STANDARD; opt->title = SANE_TITLE_STANDARD; opt->desc = SANE_DESC_STANDARD; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* source */ if(option==OPT_SOURCE){ i=0; if(s->has_flatbed){ s->source_list[i++]=STRING_FLATBED; } if(s->has_adf){ s->source_list[i++]=STRING_ADFFRONT; if(s->has_back){ s->source_list[i++]=STRING_ADFBACK; } if(s->has_duplex){ s->source_list[i++]=STRING_ADFDUPLEX; } } s->source_list[i]=NULL; opt->name = SANE_NAME_SCAN_SOURCE; opt->title = SANE_TITLE_SCAN_SOURCE; opt->desc = SANE_DESC_SCAN_SOURCE; opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->source_list; opt->size = maxStringSize (opt->constraint.string_list); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* scan mode */ if(option==OPT_MODE){ i=0; if(s->can_mode[MODE_LINEART]){ s->mode_list[i++]=STRING_LINEART; } if(s->can_mode[MODE_HALFTONE]){ s->mode_list[i++]=STRING_HALFTONE; } if(s->can_mode[MODE_GRAYSCALE]){ s->mode_list[i++]=STRING_GRAYSCALE; } if(s->can_mode[MODE_COLOR]){ s->mode_list[i++]=STRING_COLOR; } s->mode_list[i]=NULL; opt->name = SANE_NAME_SCAN_MODE; opt->title = SANE_TITLE_SCAN_MODE; opt->desc = SANE_DESC_SCAN_MODE; opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->mode_list; opt->size = maxStringSize (opt->constraint.string_list); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* resolution */ /* some scanners only support fixed res * build a list of possible choices */ if(option==OPT_RES){ opt->name = SANE_NAME_SCAN_RESOLUTION; opt->title = SANE_TITLE_SCAN_RESOLUTION; opt->desc = SANE_DESC_SCAN_RESOLUTION; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_DPI; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->step_x_res[s->s_mode] && s->step_y_res[s->s_mode]){ s->res_range.min = s->min_x_res; s->res_range.max = s->max_x_res; s->res_range.quant = s->step_x_res[s->s_mode]; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->res_range; } else{ int reses[] = {60,75,100,120,150,160,180,200,240,300,320,400,480,600,800,1200}; i=0; for(j=0;j<16;j++){ if(s->std_res[j] && s->max_x_res >= reses[j] && s->min_x_res <= reses[j] && s->max_y_res >= reses[j] && s->min_y_res <= reses[j] ){ s->res_list[++i] = reses[j]; } } s->res_list[0] = i; opt->constraint_type = SANE_CONSTRAINT_WORD_LIST; opt->constraint.word_list = s->res_list; } } /* "Geometry" group ---------------------------------------------------- */ if(option==OPT_GEOMETRY_GROUP){ opt->name = SANE_NAME_GEOMETRY; opt->title = SANE_TITLE_GEOMETRY; opt->desc = SANE_DESC_GEOMETRY; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* top-left x */ if(option==OPT_TL_X){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->tl_x_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_x); s->tl_x_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_width(s)); s->tl_x_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_TL_X; opt->title = SANE_TITLE_SCAN_TL_X; opt->desc = SANE_DESC_SCAN_TL_X; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->tl_x_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* top-left y */ if(option==OPT_TL_Y){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->tl_y_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_y); s->tl_y_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_height(s)); s->tl_y_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_TL_Y; opt->title = SANE_TITLE_SCAN_TL_Y; opt->desc = SANE_DESC_SCAN_TL_Y; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->tl_y_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* bottom-right x */ if(option==OPT_BR_X){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->br_x_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_x); s->br_x_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_width(s)); s->br_x_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_BR_X; opt->title = SANE_TITLE_SCAN_BR_X; opt->desc = SANE_DESC_SCAN_BR_X; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->br_x_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* bottom-right y */ if(option==OPT_BR_Y){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->br_y_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_y); s->br_y_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_height(s)); s->br_y_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_BR_Y; opt->title = SANE_TITLE_SCAN_BR_Y; opt->desc = SANE_DESC_SCAN_BR_Y; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->br_y_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* page width */ if(option==OPT_PAGE_WIDTH){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->paper_x_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_x); s->paper_x_range.max = SCANNER_UNIT_TO_FIXED_MM(s->max_x); s->paper_x_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_PAGE_WIDTH; opt->title = SANE_TITLE_PAGE_WIDTH; opt->desc = SANE_DESC_PAGE_WIDTH; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->paper_x_range; if(s->has_adf){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->source == SOURCE_FLATBED){ opt->cap |= SANE_CAP_INACTIVE; } } else{ opt->cap = SANE_CAP_INACTIVE; } } /* page height */ if(option==OPT_PAGE_HEIGHT){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->paper_y_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_y); s->paper_y_range.max = SCANNER_UNIT_TO_FIXED_MM(s->max_y); s->paper_y_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_PAGE_HEIGHT; opt->title = SANE_TITLE_PAGE_HEIGHT; opt->desc = SANE_DESC_PAGE_HEIGHT; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->paper_y_range; if(s->has_adf){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->source == SOURCE_FLATBED){ opt->cap |= SANE_CAP_INACTIVE; } } else{ opt->cap = SANE_CAP_INACTIVE; } } /* "Enhancement" group ------------------------------------------------- */ if(option==OPT_ENHANCEMENT_GROUP){ opt->name = SANE_NAME_ENHANCEMENT; opt->title = SANE_TITLE_ENHANCEMENT; opt->desc = SANE_DESC_ENHANCEMENT; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* brightness */ if(option==OPT_BRIGHTNESS){ opt->name = SANE_NAME_BRIGHTNESS; opt->title = SANE_TITLE_BRIGHTNESS; opt->desc = SANE_DESC_BRIGHTNESS; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->brightness_range; s->brightness_range.quant=1; /* some have hardware brightness (always 0 to 255?) */ /* some use LUT or GT (-127 to +127)*/ if (s->brightness_steps || s->num_download_gamma){ s->brightness_range.min=-127; s->brightness_range.max=127; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } else{ opt->cap = SANE_CAP_INACTIVE; } } /* contrast */ if(option==OPT_CONTRAST){ opt->name = SANE_NAME_CONTRAST; opt->title = SANE_TITLE_CONTRAST; opt->desc = SANE_DESC_CONTRAST; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->contrast_range; s->contrast_range.quant=1; /* some have hardware contrast (always 0 to 255?) */ /* some use LUT or GT (-127 to +127)*/ if (s->contrast_steps || s->num_download_gamma){ s->contrast_range.min=-127; s->contrast_range.max=127; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } else { opt->cap = SANE_CAP_INACTIVE; } } /* gamma */ if(option==OPT_GAMMA){ opt->name = "gamma"; 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; opt->constraint.range = &s->gamma_range; /* value ranges from .3 to 5, should be log scale? */ s->gamma_range.quant=SANE_FIX(0.01); s->gamma_range.min=SANE_FIX(0.3); s->gamma_range.max=SANE_FIX(5); /* scanner has gamma via LUT or GT */ /*if (s->num_download_gamma){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } else { opt->cap = SANE_CAP_INACTIVE; }*/ opt->cap = SANE_CAP_INACTIVE; } /*threshold*/ if(option==OPT_THRESHOLD){ opt->name = SANE_NAME_THRESHOLD; opt->title = SANE_TITLE_THRESHOLD; opt->desc = SANE_DESC_THRESHOLD; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->threshold_range; s->threshold_range.min=0; s->threshold_range.max=s->threshold_steps; s->threshold_range.quant=1; if (s->threshold_steps){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->u_mode != MODE_LINEART){ opt->cap |= SANE_CAP_INACTIVE; } } else { opt->cap = SANE_CAP_INACTIVE; } } /* =============== common ipc params ================================ */ if(option==OPT_RIF){ opt->name = "rif"; 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) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_HT_TYPE){ i=0; s->ht_type_list[i++]=STRING_DEFAULT; s->ht_type_list[i++]=STRING_DITHER; s->ht_type_list[i++]=STRING_DIFFUSION; s->ht_type_list[i]=NULL; opt->name = "ht-type"; 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; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->ht_type_list; opt->size = maxStringSize (opt->constraint.string_list); if(s->has_diffusion){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->s_mode != MODE_HALFTONE){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_HT_PATTERN){ opt->name = "ht-pattern"; 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; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->ht_pattern_range; s->ht_pattern_range.min=0; s->ht_pattern_range.max=s->num_internal_dither - 1; s->ht_pattern_range.quant=1; if (s->num_internal_dither){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->s_mode != MODE_HALFTONE){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_OUTLINE){ opt->name = "outline"; 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) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_EMPHASIS){ opt->name = "emphasis"; 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; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->emphasis_range; s->emphasis_range.min=-128; s->emphasis_range.max=127; s->emphasis_range.quant=1; if (s->has_emphasis) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_SEPARATION){ opt->name = "separation"; 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) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_MIRRORING){ opt->name = "mirroring"; 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) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_WL_FOLLOW){ i=0; s->wl_follow_list[i++]=STRING_DEFAULT; s->wl_follow_list[i++]=STRING_ON; s->wl_follow_list[i++]=STRING_OFF; s->wl_follow_list[i]=NULL; opt->name = "wl-follow"; 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; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->wl_follow_list; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_wl_follow) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; 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 = 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(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_SMOOTHING){ opt->name = "smoothing"; 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(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_GAMMA_CURVE){ opt->name = "gamma-curve"; 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; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->gamma_curve_range; s->gamma_curve_range.min=0; s->gamma_curve_range.max=3; s->gamma_curve_range.quant=1; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_THRESHOLD_CURVE){ opt->name = "threshold-curve"; 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; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->threshold_curve_range; s->threshold_curve_range.min=0; s->threshold_curve_range.max=7; s->threshold_curve_range.quant=1; if ( s->has_dtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_THRESHOLD_WHITE){ opt->name = "threshold-white"; 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(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_NOISE_REMOVAL){ opt->name = "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(get_ipc_mode(s) == WD_ipc_SDTC){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_MATRIX_5){ opt->name = "matrix-5x5"; 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){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_MATRIX_4){ opt->name = "matrix-4x4"; 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){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_MATRIX_3){ opt->name = "matrix-3x3"; 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){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_MATRIX_2){ opt->name = "matrix-2x2"; 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){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } /* =============== SDTC param ================================ */ /* enabled when in sdtc mode (manually or by default) */ /* called variance with ipc2, sensitivity with ipc3 */ if(option==OPT_VARIANCE){ opt->name = "variance"; 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; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->variance_range; s->variance_range.min=0; s->variance_range.max=255; s->variance_range.quant=1; if ( s->has_sdtc ){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(get_ipc_mode(s) == WD_ipc_DTC){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } /* "Advanced" group ------------------------------------------------------ */ if(option==OPT_ADVANCED_GROUP){ opt->name = SANE_NAME_ADVANCED; opt->title = SANE_TITLE_ADVANCED; opt->desc = SANE_DESC_ADVANCED; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /*automatic width detection */ if(option==OPT_AWD){ opt->name = "awd"; 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; /* this option is useless by itself? */ if (0 && s->has_MS_auto && s->has_hybrid_crop_deskew){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; } else opt->cap = SANE_CAP_INACTIVE; } /*automatic length detection */ if(option==OPT_ALD){ opt->name = "ald"; 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; if (s->has_MS_auto){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; } else opt->cap = SANE_CAP_INACTIVE; } /*image compression*/ if(option==OPT_COMPRESS){ i=0; s->compress_list[i++]=STRING_NONE; if(s->has_comp_JPG1){ #ifndef SANE_JPEG_DISABLED s->compress_list[i++]=STRING_JPEG; #endif } s->compress_list[i]=NULL; opt->name = "compression"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (i > 1){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if ( must_downsample(s) || s->s_mode < MODE_GRAYSCALE ){ opt->cap |= SANE_CAP_INACTIVE; } } else opt->cap = SANE_CAP_INACTIVE; } /*image compression arg*/ if(option==OPT_COMPRESS_ARG){ opt->name = "compression-arg"; 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; opt->constraint.range = &s->compress_arg_range; s->compress_arg_range.quant=1; 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; } } else opt->cap = SANE_CAP_INACTIVE; } /*double feed detection*/ if(option==OPT_DF_ACTION){ s->df_action_list[0] = STRING_DEFAULT; s->df_action_list[1] = STRING_CONTINUE; s->df_action_list[2] = STRING_STOP; s->df_action_list[3] = NULL; opt->name = "df-action"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_df) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*double feed by skew*/ if(option==OPT_DF_SKEW){ opt->name = "df-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; if (s->has_MS_df){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->df_action) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; } /*double feed by thickness */ if(option==OPT_DF_THICKNESS){ opt->name = "df-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; if (s->has_MS_df){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->df_action) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; } /*double feed by length*/ if(option==OPT_DF_LENGTH){ opt->name = "df-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; if (s->has_MS_df){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->df_action) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; } /*double feed length difference*/ if(option==OPT_DF_DIFF){ s->df_diff_list[0] = STRING_DEFAULT; s->df_diff_list[1] = STRING_10MM; s->df_diff_list[2] = STRING_15MM; s->df_diff_list[3] = STRING_20MM; s->df_diff_list[4] = NULL; opt->name = "df-diff"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_df){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->df_action || !s->df_diff) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; } /*df_recovery*/ if(option==OPT_DF_RECOVERY){ s->df_recovery_list[0] = STRING_DEFAULT; s->df_recovery_list[1] = STRING_OFF; s->df_recovery_list[2] = STRING_ON; s->df_recovery_list[3] = NULL; opt->name = "df-recovery"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_df && s->has_df_recovery) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*paper_protect*/ if(option==OPT_PAPER_PROTECT){ s->paper_protect_list[0] = STRING_DEFAULT; s->paper_protect_list[1] = STRING_OFF; s->paper_protect_list[2] = STRING_ON; s->paper_protect_list[3] = NULL; opt->name = "paper-protect"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_df && s->has_paper_protect) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*adv_paper_prot*/ if(option==OPT_ADV_PAPER_PROT){ s->adv_paper_prot_list[0] = STRING_DEFAULT; s->adv_paper_prot_list[1] = STRING_OFF; s->adv_paper_prot_list[2] = STRING_ON; s->adv_paper_prot_list[3] = NULL; opt->name = "adv-paper-protect"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_df && s->has_adv_paper_prot) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*staple detection*/ if(option==OPT_STAPLE_DETECT){ s->staple_detect_list[0] = STRING_DEFAULT; s->staple_detect_list[1] = STRING_OFF; s->staple_detect_list[2] = STRING_ON; s->staple_detect_list[3] = NULL; opt->name = "staple-detect"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_df && s->has_staple_detect) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*background color*/ if(option==OPT_BG_COLOR){ s->bg_color_list[0] = STRING_DEFAULT; s->bg_color_list[1] = STRING_WHITE; s->bg_color_list[2] = STRING_BLACK; s->bg_color_list[3] = NULL; opt->name = "bgcolor"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_bg) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*dropout color*/ if(option==OPT_DROPOUT_COLOR){ s->do_color_list[0] = STRING_DEFAULT; s->do_color_list[1] = STRING_RED; s->do_color_list[2] = STRING_GREEN; s->do_color_list[3] = STRING_BLUE; s->do_color_list[4] = NULL; opt->name = "dropoutcolor"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_dropout || s->has_vuid_3091 || must_downsample(s)){ opt->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED; if(s->u_mode == MODE_COLOR) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; } /*buffer mode*/ if(option==OPT_BUFF_MODE){ s->buff_mode_list[0] = STRING_DEFAULT; s->buff_mode_list[1] = STRING_OFF; s->buff_mode_list[2] = STRING_ON; s->buff_mode_list[3] = NULL; opt->name = "buffermode"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_buff) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*prepick*/ if(option==OPT_PREPICK){ s->prepick_list[0] = STRING_DEFAULT; s->prepick_list[1] = STRING_OFF; s->prepick_list[2] = STRING_ON; s->prepick_list[3] = NULL; opt->name = "prepick"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_prepick) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*overscan*/ if(option==OPT_OVERSCAN){ s->overscan_list[0] = STRING_DEFAULT; s->overscan_list[1] = STRING_OFF; s->overscan_list[2] = STRING_ON; s->overscan_list[3] = NULL; opt->name = "overscan"; 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; opt->size = maxStringSize (opt->constraint.string_list); if (s->has_MS_auto && (s->os_x_basic || s->os_y_basic)) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*sleep_time*/ if(option==OPT_SLEEP_TIME){ s->sleep_time_range.min = 0; s->sleep_time_range.max = 60; s->sleep_time_range.quant = 1; opt->name = "sleeptimer"; 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; opt->constraint.range=&s->sleep_time_range; if(s->has_MS_sleep) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*off_time*/ if(option==OPT_OFF_TIME){ s->off_time_range.min = 0; s->off_time_range.max = 960; s->off_time_range.quant = 1; opt->name = "offtimer"; 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; opt->constraint.range=&s->off_time_range; if(s->has_off_mode) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } /*duplex offset*/ if(option==OPT_DUPLEX_OFFSET){ s->duplex_offset_range.min = -16; s->duplex_offset_range.max = 16; s->duplex_offset_range.quant = 1; opt->name = "duplexoffset"; 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; opt->constraint.range = &s->duplex_offset_range; if(s->duplex_interlace == DUPLEX_INTERLACE_3091) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_GREEN_OFFSET){ s->green_offset_range.min = -16; s->green_offset_range.max = 16; s->green_offset_range.quant = 1; opt->name = "greenoffset"; 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; opt->constraint.range = &s->green_offset_range; if(s->color_interlace == COLOR_INTERLACE_3091) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_BLUE_OFFSET){ s->blue_offset_range.min = -16; s->blue_offset_range.max = 16; s->blue_offset_range.quant = 1; opt->name = "blueoffset"; 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; opt->constraint.range = &s->blue_offset_range; if(s->color_interlace == COLOR_INTERLACE_3091) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_LOW_MEM){ opt->name = "lowmemory"; 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); if (1) opt->cap= SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_NONE; } if(option==OPT_SIDE){ opt->name = "side"; 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); opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; opt->constraint_type = SANE_CONSTRAINT_NONE; } /*deskew and crop by hardware*/ if(option==OPT_HWDESKEWCROP){ opt->name = "hwdeskewcrop"; 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; else opt->cap = SANE_CAP_INACTIVE; } /*deskew by software*/ if(option==OPT_SWDESKEW){ opt->name = "swdeskew"; 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; else opt->cap = SANE_CAP_INACTIVE; } /*software despeckle radius*/ if(option==OPT_SWDESPECK){ opt->name = "swdespeck"; 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; opt->constraint.range = &s->swdespeck_range; s->swdespeck_range.quant=1; if(1){ s->swdespeck_range.min=0; s->swdespeck_range.max=9; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } else opt->cap = SANE_CAP_INACTIVE; } /*crop by software*/ if(option==OPT_SWCROP){ opt->name = "swcrop"; 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; else 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; } /*halt scanner feeder when cancelling*/ if(option==OPT_HALT_ON_CANCEL){ opt->name = "halt-on-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; else opt->cap = SANE_CAP_INACTIVE; } /* "Endorser" group ------------------------------------------------------ */ if(option==OPT_ENDORSER_GROUP){ opt->name = "endorser-options"; 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; /*flaming hack to get scanimage to hide group*/ if ( !(s->has_endorser_f || s->has_endorser_b) ) opt->type = SANE_TYPE_BOOL; } if(option==OPT_ENDORSER){ opt->name = "endorser"; 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); if (s->has_endorser_f || s->has_endorser_b) opt->cap= SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_NONE; } if(option==OPT_ENDORSER_BITS){ opt->name = "endorser-bits"; 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); /*old type cant do this?*/ if ((s->has_endorser_f && s->endorser_type_f != ET_OLD) || (s->has_endorser_b && s->endorser_type_b != ET_OLD)){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->u_endorser) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->endorser_bits_range; s->endorser_bits_range.min = 16; s->endorser_bits_range.max = 24; s->endorser_bits_range.quant = 8; } if(option==OPT_ENDORSER_VAL){ opt->name = "endorser-val"; 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); if (s->has_endorser_f || s->has_endorser_b){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->u_endorser) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->endorser_val_range; s->endorser_val_range.min = 0; s->endorser_val_range.max = (1 << s->u_endorser_bits)-1; s->endorser_val_range.quant = 1; } if(option==OPT_ENDORSER_STEP){ opt->name = "endorser-step"; 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); if (s->has_endorser_f || s->has_endorser_b){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->u_endorser) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->endorser_step_range; s->endorser_step_range.min = -2; s->endorser_step_range.max = 2; s->endorser_step_range.quant = 1; } if(option==OPT_ENDORSER_Y){ opt->name = "endorser-y"; 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); if (s->has_endorser_f || s->has_endorser_b){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->u_endorser) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->endorser_y_range); /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->endorser_y_range.min = SCANNER_UNIT_TO_FIXED_MM(0); s->endorser_y_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_height(s)); s->endorser_y_range.quant = MM_PER_UNIT_FIX; } if(option==OPT_ENDORSER_FONT){ opt->name = "endorser-font"; opt->title = SANE_I18N ("Endorser font"); opt->desc = SANE_I18N ("Endorser printing font."); opt->type = SANE_TYPE_STRING; opt->unit = SANE_UNIT_NONE; /*only newest can do this?*/ if ((s->has_endorser_f && s->endorser_type_f == ET_40) || (s->has_endorser_b && s->endorser_type_b == ET_40)){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->u_endorser) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->endorser_font_list; s->endorser_font_list[0] = STRING_HORIZONTAL; s->endorser_font_list[1] = STRING_HORIZONTALBOLD; s->endorser_font_list[2] = STRING_HORIZONTALNARROW; s->endorser_font_list[3] = STRING_VERTICAL; s->endorser_font_list[4] = STRING_VERTICALBOLD; s->endorser_font_list[5] = NULL; opt->size = maxStringSize (opt->constraint.string_list); } if(option==OPT_ENDORSER_DIR){ opt->name = "endorser-dir"; opt->title = SANE_I18N ("Endorser direction"); opt->desc = SANE_I18N ("Endorser printing direction."); opt->type = SANE_TYPE_STRING; opt->unit = SANE_UNIT_NONE; if (s->has_endorser_f || s->has_endorser_b){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->u_endorser) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->endorser_dir_list; s->endorser_dir_list[0] = STRING_TOPTOBOTTOM; s->endorser_dir_list[1] = STRING_BOTTOMTOTOP; s->endorser_dir_list[2] = NULL; opt->size = maxStringSize (opt->constraint.string_list); } if(option==OPT_ENDORSER_SIDE){ opt->name = "endorser-side"; 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; /* only show if both endorsers are installed */ if (s->has_endorser_f && s->has_endorser_b){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->u_endorser) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->endorser_side_list; s->endorser_side_list[0] = STRING_FRONT; s->endorser_side_list[1] = STRING_BACK; s->endorser_side_list[2] = NULL; opt->size = maxStringSize (opt->constraint.string_list); } if(option==OPT_ENDORSER_STRING){ opt->name = "endorser-string"; 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; if (s->has_endorser_f || s->has_endorser_b){ opt->cap=SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if(!s->u_endorser) opt->cap |= SANE_CAP_INACTIVE; } else opt->cap = SANE_CAP_INACTIVE; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* "Sensor" group ------------------------------------------------------ */ if(option==OPT_SENSOR_GROUP){ opt->name = SANE_NAME_SENSORS; opt->title = SANE_TITLE_SENSORS; opt->desc = SANE_DESC_SENSORS; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } if(option==OPT_TOP){ opt->name = "top-edge"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_A3){ opt->name = "a3-paper"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_B4){ opt->name = "b4-paper"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_A4){ opt->name = "a4-paper"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_B5){ opt->name = "b5-paper"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_HOPPER){ opt->name = SANE_NAME_PAGE_LOADED; opt->title = SANE_TITLE_PAGE_LOADED; opt->desc = SANE_DESC_PAGE_LOADED; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status || s->ghs_in_rs) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_OMR){ opt->name = "omr-df"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_ADF_OPEN){ opt->name = SANE_NAME_COVER_OPEN; opt->title = SANE_TITLE_COVER_OPEN; opt->desc = SANE_DESC_COVER_OPEN; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status || s->ghs_in_rs) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_SLEEP){ opt->name = "power-save"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_SEND_SW){ opt->name = SANE_NAME_EMAIL; opt->title = SANE_TITLE_EMAIL; opt->desc = SANE_DESC_EMAIL; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status || s->ghs_in_rs) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_MANUAL_FEED){ opt->name = "manual-feed"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_SCAN_SW){ opt->name = SANE_NAME_SCAN; opt->title = SANE_TITLE_SCAN; opt->desc = SANE_DESC_SCAN; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_cmd_hw_status || s->ghs_in_rs) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_FUNCTION){ opt->name = "function"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_INK_EMPTY){ opt->name = "ink-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)) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_DOUBLE_FEED){ opt->name = "double-feed"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_ERROR_CODE){ opt->name = "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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_SKEW_ANGLE){ opt->name = "skew-angle"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_INK_REMAIN){ opt->name = "ink-remain"; 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)) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_DENSITY_SW){ opt->name = "density"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_DUPLEX_SW){ opt->name = "duplex"; 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) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } return opt; } /** * Gets or sets an option value. * * From the SANE spec: * This function is used to set or inquire the current value of option * number n of the device represented by handle h. The manner in which * the option is controlled is specified by parameter action. The * possible values of this parameter are described in more detail * below. The value of the option is passed through argument val. It * is a pointer to the memory that holds the option value. The memory * area pointed to by v must be big enough to hold the entire option * value (determined by member size in the corresponding option * descriptor). * * The only exception to this rule is that when setting the value of a * string option, the string pointed to by argument v may be shorter * since the backend will stop reading the option value upon * encountering the first NUL terminator in the string. If argument i * is not NULL, the value of *i will be set to provide details on how * well the request has been met. */ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { struct fujitsu *s = (struct fujitsu *) handle; SANE_Int dummy = 0; SANE_Status ret = SANE_STATUS_GOOD; /* Make sure that all those statements involving *info cannot break (better * than having to do "if (info) ..." everywhere!) */ if (info == 0) info = &dummy; /*blast info in case frontend forgot*/ *info = 0; if (option >= NUM_OPTIONS) { DBG (5, "sane_control_option: %d too big\n", option); return SANE_STATUS_INVAL; } if (!SANE_OPTION_IS_ACTIVE (s->opt[option].cap)) { DBG (5, "sane_control_option: %d inactive\n", option); return SANE_STATUS_INVAL; } /* * SANE_ACTION_GET_VALUE: We have to find out the current setting and * return it in a human-readable form (often, text). */ if (action == SANE_ACTION_GET_VALUE) { SANE_Word * val_p = (SANE_Word *) val; DBG (20, "sane_control_option: get value for '%s' (%d)\n", s->opt[option].name,option); switch (option) { case OPT_NUM_OPTS: *val_p = NUM_OPTIONS; return SANE_STATUS_GOOD; case OPT_SOURCE: if(s->source == SOURCE_FLATBED){ strcpy (val, STRING_FLATBED); } else if(s->source == SOURCE_ADF_FRONT){ strcpy (val, STRING_ADFFRONT); } else if(s->source == SOURCE_ADF_BACK){ strcpy (val, STRING_ADFBACK); } else if(s->source == SOURCE_ADF_DUPLEX){ strcpy (val, STRING_ADFDUPLEX); } return SANE_STATUS_GOOD; case OPT_MODE: if(s->u_mode == MODE_LINEART){ strcpy (val, STRING_LINEART); } else if(s->u_mode == MODE_HALFTONE){ strcpy (val, STRING_HALFTONE); } else if(s->u_mode == MODE_GRAYSCALE){ strcpy (val, STRING_GRAYSCALE); } else if(s->u_mode == MODE_COLOR){ strcpy (val, STRING_COLOR); } return SANE_STATUS_GOOD; case OPT_RES: *val_p = s->resolution_x; return SANE_STATUS_GOOD; case OPT_TL_X: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->tl_x); return SANE_STATUS_GOOD; case OPT_TL_Y: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->tl_y); return SANE_STATUS_GOOD; case OPT_BR_X: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->br_x); return SANE_STATUS_GOOD; case OPT_BR_Y: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->br_y); return SANE_STATUS_GOOD; case OPT_PAGE_WIDTH: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->page_width); return SANE_STATUS_GOOD; case OPT_PAGE_HEIGHT: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->page_height); return SANE_STATUS_GOOD; case OPT_BRIGHTNESS: *val_p = s->brightness; return SANE_STATUS_GOOD; case OPT_CONTRAST: *val_p = s->contrast; return SANE_STATUS_GOOD; case OPT_GAMMA: *val_p = SANE_FIX(s->gamma); return SANE_STATUS_GOOD; case OPT_THRESHOLD: *val_p = s->threshold; return SANE_STATUS_GOOD; /* IPC */ case OPT_RIF: *val_p = s->rif; return SANE_STATUS_GOOD; case OPT_HT_TYPE: switch (s->ht_type) { case WD_ht_type_DEFAULT: strcpy (val, STRING_DEFAULT); break; case WD_ht_type_DITHER: strcpy (val, STRING_DITHER); break; case WD_ht_type_DIFFUSION: strcpy (val, STRING_DIFFUSION); break; } return SANE_STATUS_GOOD; case OPT_HT_PATTERN: *val_p = s->ht_pattern; return SANE_STATUS_GOOD; case OPT_OUTLINE: *val_p = s->outline; return SANE_STATUS_GOOD; case OPT_EMPHASIS: *val_p = s->emphasis; return SANE_STATUS_GOOD; case OPT_SEPARATION: *val_p = s->separation; return SANE_STATUS_GOOD; case OPT_MIRRORING: *val_p = s->mirroring; return SANE_STATUS_GOOD; case OPT_WL_FOLLOW: switch (s->wl_follow) { case WD_wl_follow_DEFAULT: strcpy (val, STRING_DEFAULT); break; case WD_wl_follow_ON: strcpy (val, STRING_ON); break; case WD_wl_follow_OFF: strcpy (val, STRING_OFF); break; } return SANE_STATUS_GOOD; /* DTC params*/ case OPT_BP_FILTER: *val_p = s->bp_filter; return SANE_STATUS_GOOD; case OPT_SMOOTHING: *val_p = s->smoothing; return SANE_STATUS_GOOD; case OPT_GAMMA_CURVE: *val_p = s->gamma_curve; return SANE_STATUS_GOOD; case OPT_THRESHOLD_CURVE: *val_p = s->threshold_curve; return SANE_STATUS_GOOD; case OPT_THRESHOLD_WHITE: *val_p = s->threshold_white; return SANE_STATUS_GOOD; case OPT_NOISE_REMOVAL: *val_p = s->noise_removal; return SANE_STATUS_GOOD; case OPT_MATRIX_5: *val_p = s->matrix_5; return SANE_STATUS_GOOD; case OPT_MATRIX_4: *val_p = s->matrix_4; return SANE_STATUS_GOOD; case OPT_MATRIX_3: *val_p = s->matrix_3; return SANE_STATUS_GOOD; case OPT_MATRIX_2: *val_p = s->matrix_2; return SANE_STATUS_GOOD; /* SDTC params*/ case OPT_VARIANCE: *val_p = s->variance; return SANE_STATUS_GOOD; /* Advanced Group */ case OPT_AWD: *val_p = s->awd; return SANE_STATUS_GOOD; case OPT_ALD: *val_p = s->ald; return SANE_STATUS_GOOD; case OPT_COMPRESS: if(s->compress == COMP_JPEG){ strcpy (val, STRING_JPEG); } else{ strcpy (val, STRING_NONE); } return SANE_STATUS_GOOD; case OPT_COMPRESS_ARG: *val_p = s->compress_arg; return SANE_STATUS_GOOD; case OPT_DF_ACTION: switch (s->df_action) { case DF_DEFAULT: strcpy (val, STRING_DEFAULT); break; case DF_CONTINUE: strcpy (val, STRING_CONTINUE); break; case DF_STOP: strcpy (val, STRING_STOP); break; } return SANE_STATUS_GOOD; case OPT_DF_SKEW: *val_p = s->df_skew; return SANE_STATUS_GOOD; case OPT_DF_THICKNESS: *val_p = s->df_thickness; return SANE_STATUS_GOOD; case OPT_DF_LENGTH: *val_p = s->df_length; return SANE_STATUS_GOOD; case OPT_DF_DIFF: switch (s->df_diff) { case MSEL_df_diff_DEFAULT: strcpy (val, STRING_DEFAULT); break; case MSEL_df_diff_10MM: strcpy (val, STRING_10MM); break; case MSEL_df_diff_15MM: strcpy (val, STRING_15MM); break; case MSEL_df_diff_20MM: strcpy (val, STRING_20MM); break; } return SANE_STATUS_GOOD; case OPT_DF_RECOVERY: switch (s->df_recovery) { case MSEL_DEFAULT: strcpy (val, STRING_DEFAULT); break; case MSEL_ON: strcpy (val, STRING_ON); break; case MSEL_OFF: strcpy (val, STRING_OFF); break; } return SANE_STATUS_GOOD; case OPT_PAPER_PROTECT: switch (s->paper_protect) { case MSEL_DEFAULT: strcpy (val, STRING_DEFAULT); break; case MSEL_ON: strcpy (val, STRING_ON); break; case MSEL_OFF: strcpy (val, STRING_OFF); break; } return SANE_STATUS_GOOD; case OPT_ADV_PAPER_PROT: switch (s->adv_paper_prot) { case MSEL_DEFAULT: strcpy (val, STRING_DEFAULT); break; case MSEL_ON: strcpy (val, STRING_ON); break; case MSEL_OFF: strcpy (val, STRING_OFF); break; } return SANE_STATUS_GOOD; case OPT_STAPLE_DETECT: switch (s->staple_detect) { case MSEL_DEFAULT: strcpy (val, STRING_DEFAULT); break; case MSEL_ON: strcpy (val, STRING_ON); break; case MSEL_OFF: strcpy (val, STRING_OFF); break; } return SANE_STATUS_GOOD; case OPT_BG_COLOR: switch (s->bg_color) { case COLOR_DEFAULT: strcpy (val, STRING_DEFAULT); break; case COLOR_WHITE: strcpy (val, STRING_WHITE); break; case COLOR_BLACK: strcpy (val, STRING_BLACK); break; } return SANE_STATUS_GOOD; case OPT_DROPOUT_COLOR: switch (s->dropout_color) { case COLOR_DEFAULT: strcpy (val, STRING_DEFAULT); break; case COLOR_RED: strcpy (val, STRING_RED); break; case COLOR_GREEN: strcpy (val, STRING_GREEN); break; case COLOR_BLUE: strcpy (val, STRING_BLUE); break; } return SANE_STATUS_GOOD; case OPT_BUFF_MODE: switch (s->buff_mode) { case MSEL_DEFAULT: strcpy (val, STRING_DEFAULT); break; case MSEL_ON: strcpy (val, STRING_ON); break; case MSEL_OFF: strcpy (val, STRING_OFF); break; } return SANE_STATUS_GOOD; case OPT_PREPICK: switch (s->prepick) { case MSEL_DEFAULT: strcpy (val, STRING_DEFAULT); break; case MSEL_ON: strcpy (val, STRING_ON); break; case MSEL_OFF: strcpy (val, STRING_OFF); break; } return SANE_STATUS_GOOD; case OPT_OVERSCAN: switch (s->overscan) { case MSEL_DEFAULT: strcpy (val, STRING_DEFAULT); break; case MSEL_ON: strcpy (val, STRING_ON); break; case MSEL_OFF: strcpy (val, STRING_OFF); break; } return SANE_STATUS_GOOD; case OPT_SLEEP_TIME: *val_p = s->sleep_time; return SANE_STATUS_GOOD; case OPT_OFF_TIME: *val_p = s->off_time; return SANE_STATUS_GOOD; case OPT_DUPLEX_OFFSET: *val_p = s->duplex_offset; return SANE_STATUS_GOOD; case OPT_GREEN_OFFSET: *val_p = s->green_offset; return SANE_STATUS_GOOD; case OPT_BLUE_OFFSET: *val_p = s->blue_offset; return SANE_STATUS_GOOD; case OPT_LOW_MEM: *val_p = s->low_mem; return SANE_STATUS_GOOD; case OPT_SIDE: *val_p = s->side; return SANE_STATUS_GOOD; case OPT_HWDESKEWCROP: *val_p = s->hwdeskewcrop; return SANE_STATUS_GOOD; case OPT_SWDESKEW: *val_p = s->swdeskew; return SANE_STATUS_GOOD; case OPT_SWDESPECK: *val_p = s->swdespeck; return SANE_STATUS_GOOD; case OPT_SWCROP: *val_p = s->swcrop; return SANE_STATUS_GOOD; case OPT_SWSKIP: *val_p = SANE_FIX(s->swskip); return SANE_STATUS_GOOD; case OPT_HALT_ON_CANCEL: *val_p = s->halt_on_cancel; return SANE_STATUS_GOOD; /* Endorser Group */ case OPT_ENDORSER: *val_p = s->u_endorser; return SANE_STATUS_GOOD; case OPT_ENDORSER_BITS: *val_p = s->u_endorser_bits; return SANE_STATUS_GOOD; case OPT_ENDORSER_VAL: *val_p = s->u_endorser_val; return SANE_STATUS_GOOD; case OPT_ENDORSER_STEP: *val_p = s->u_endorser_step; return SANE_STATUS_GOOD; case OPT_ENDORSER_Y: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->u_endorser_y); return SANE_STATUS_GOOD; case OPT_ENDORSER_FONT: switch (s->u_endorser_font) { case FONT_H: strcpy (val, STRING_HORIZONTAL); break; case FONT_HB: strcpy (val, STRING_HORIZONTALBOLD); break; case FONT_HN: strcpy (val, STRING_HORIZONTALNARROW); break; case FONT_V: strcpy (val, STRING_VERTICAL); break; case FONT_VB: strcpy (val, STRING_VERTICALBOLD); break; } return SANE_STATUS_GOOD; case OPT_ENDORSER_DIR: switch (s->u_endorser_dir) { case DIR_TTB: strcpy (val, STRING_TOPTOBOTTOM); break; case DIR_BTT: strcpy (val, STRING_BOTTOMTOTOP); break; } return SANE_STATUS_GOOD; case OPT_ENDORSER_SIDE: switch (s->u_endorser_side) { case ED_front: strcpy (val, STRING_FRONT); break; case ED_back: strcpy (val, STRING_BACK); break; } return SANE_STATUS_GOOD; case OPT_ENDORSER_STRING: strncpy( (SANE_String)val, (SANE_String)s->u_endorser_string, s->endorser_string_len+1 ); return SANE_STATUS_GOOD; /* Sensor Group */ case OPT_TOP: ret = get_hardware_status(s,option); *val_p = s->hw_top; return ret; case OPT_A3: ret = get_hardware_status(s,option); *val_p = s->hw_A3; return ret; case OPT_B4: ret = get_hardware_status(s,option); *val_p = s->hw_B4; return ret; case OPT_A4: ret = get_hardware_status(s,option); *val_p = s->hw_A4; return ret; case OPT_B5: ret = get_hardware_status(s,option); *val_p = s->hw_B5; return ret; case OPT_HOPPER: ret = get_hardware_status(s,option); *val_p = s->hw_hopper; return ret; case OPT_OMR: ret = get_hardware_status(s,option); *val_p = s->hw_omr; return ret; case OPT_ADF_OPEN: ret = get_hardware_status(s,option); *val_p = s->hw_adf_open; return ret; case OPT_SLEEP: ret = get_hardware_status(s,option); *val_p = s->hw_sleep; return ret; case OPT_SEND_SW: ret = get_hardware_status(s,option); *val_p = s->hw_send_sw; return ret; case OPT_MANUAL_FEED: ret = get_hardware_status(s,option); *val_p = s->hw_manual_feed; return ret; case OPT_SCAN_SW: ret = get_hardware_status(s,option); *val_p = s->hw_scan_sw; return ret; case OPT_FUNCTION: ret = get_hardware_status(s,option); *val_p = s->hw_function; return ret; case OPT_INK_EMPTY: ret = get_hardware_status(s,option); *val_p = s->hw_ink_empty; return ret; case OPT_DOUBLE_FEED: ret = get_hardware_status(s,option); *val_p = s->hw_double_feed; return ret; case OPT_ERROR_CODE: ret = get_hardware_status(s,option); *val_p = s->hw_error_code; return ret; case OPT_SKEW_ANGLE: ret = get_hardware_status(s,option); *val_p = s->hw_skew_angle; return ret; case OPT_INK_REMAIN: ret = get_hardware_status(s,option); *val_p = s->hw_ink_remain; return ret; case OPT_DENSITY_SW: ret = get_hardware_status(s,option); *val_p = s->hw_density_sw; return ret; case OPT_DUPLEX_SW: ret = get_hardware_status(s,option); *val_p = s->hw_duplex_sw; return ret; } } 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); if ( s->started ) { DBG (5, "sane_control_option: cant set, device busy\n"); return SANE_STATUS_DEVICE_BUSY; } if (!SANE_OPTION_IS_SETTABLE (s->opt[option].cap)) { DBG (5, "sane_control_option: not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (5, "sane_control_option: bad value\n"); 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 * exactly one of those values because that's what * sanei_constrain_value does. Hence no "else: invalid" branches * below. */ switch (option) { /* Mode Group */ case OPT_SOURCE: if (!strcmp (val, STRING_ADFFRONT)) { tmp = SOURCE_ADF_FRONT; } else if (!strcmp (val, STRING_ADFBACK)) { tmp = SOURCE_ADF_BACK; } else if (!strcmp (val, STRING_ADFDUPLEX)) { tmp = SOURCE_ADF_DUPLEX; } else{ tmp = SOURCE_FLATBED; } if (s->source == tmp) return SANE_STATUS_GOOD; s->source = tmp; *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_MODE: if (!strcmp (val, STRING_LINEART)) { tmp = MODE_LINEART; } else if (!strcmp (val, STRING_HALFTONE)) { tmp = MODE_HALFTONE; } else if (!strcmp (val, STRING_GRAYSCALE)) { tmp = MODE_GRAYSCALE; } else{ tmp = MODE_COLOR; } if (tmp == s->u_mode) return SANE_STATUS_GOOD; set_mode(s,tmp); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_RES: if (s->resolution_x == val_c) return SANE_STATUS_GOOD; s->resolution_x = val_c; s->resolution_y = val_c; set_max_y(s); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; /* Geometry Group */ case OPT_TL_X: if (s->tl_x == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->tl_x = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_TL_Y: if (s->tl_y == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->tl_y = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_BR_X: if (s->br_x == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->br_x = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_BR_Y: if (s->br_y == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->br_y = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_PAGE_WIDTH: 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; case OPT_PAGE_HEIGHT: 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; /* Enhancement Group */ case OPT_BRIGHTNESS: s->brightness = val_c; return SANE_STATUS_GOOD; case OPT_CONTRAST: s->contrast = val_c; return SANE_STATUS_GOOD; case OPT_GAMMA: s->gamma = SANE_UNFIX(val_c); return SANE_STATUS_GOOD; case OPT_THRESHOLD: s->threshold = val_c; return SANE_STATUS_GOOD; /* IPC */ case OPT_RIF: s->rif = val_c; return SANE_STATUS_GOOD; case OPT_HT_TYPE: if (!strcmp(val, STRING_DEFAULT)) s->ht_type = WD_ht_type_DEFAULT; else if (!strcmp(val, STRING_DITHER)) s->ht_type = WD_ht_type_DITHER; else if (!strcmp(val, STRING_DIFFUSION)) s->ht_type = WD_ht_type_DIFFUSION; return SANE_STATUS_GOOD; case OPT_HT_PATTERN: s->ht_pattern = val_c; return SANE_STATUS_GOOD; case OPT_OUTLINE: s->outline = val_c; return SANE_STATUS_GOOD; case OPT_EMPHASIS: s->emphasis = val_c; return SANE_STATUS_GOOD; case OPT_SEPARATION: s->separation = val_c; return SANE_STATUS_GOOD; case OPT_MIRRORING: s->mirroring = val_c; return SANE_STATUS_GOOD; case OPT_WL_FOLLOW: if (!strcmp(val, STRING_DEFAULT)) s->wl_follow = WD_wl_follow_DEFAULT; else if (!strcmp(val, STRING_ON)) s->wl_follow = WD_wl_follow_ON; else if (!strcmp(val, STRING_OFF)) s->wl_follow = WD_wl_follow_OFF; 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: s->noise_removal = val_c; *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_MATRIX_5: s->matrix_5 = val_c; return SANE_STATUS_GOOD; case OPT_MATRIX_4: s->matrix_4 = val_c; return SANE_STATUS_GOOD; case OPT_MATRIX_3: s->matrix_3 = val_c; return SANE_STATUS_GOOD; case OPT_MATRIX_2: 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 */ case OPT_AWD: s->awd = val_c; *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_ALD: s->ald = val_c; *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_COMPRESS: if (!strcmp (val, STRING_JPEG)) { tmp = COMP_JPEG; } else{ tmp = COMP_NONE; } if (tmp == s->compress) return SANE_STATUS_GOOD; s->compress = tmp; return SANE_STATUS_GOOD; case OPT_COMPRESS_ARG: s->compress_arg = val_c; return SANE_STATUS_GOOD; case OPT_DF_ACTION: if (!strcmp(val, STRING_DEFAULT)) s->df_action = DF_DEFAULT; else if (!strcmp(val, STRING_CONTINUE)) s->df_action = DF_CONTINUE; else if (!strcmp(val, STRING_STOP)) s->df_action = DF_STOP; *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_DF_SKEW: s->df_skew = val_c; return SANE_STATUS_GOOD; case OPT_DF_THICKNESS: s->df_thickness = val_c; return SANE_STATUS_GOOD; case OPT_DF_LENGTH: s->df_length = val_c; return SANE_STATUS_GOOD; case OPT_DF_DIFF: if (!strcmp(val, STRING_DEFAULT)) s->df_diff = MSEL_df_diff_DEFAULT; else if (!strcmp(val, STRING_10MM)) s->df_diff = MSEL_df_diff_10MM; else if (!strcmp(val, STRING_15MM)) s->df_diff = MSEL_df_diff_15MM; else if (!strcmp(val, STRING_20MM)) s->df_diff = MSEL_df_diff_20MM; return SANE_STATUS_GOOD; case OPT_DF_RECOVERY: if (!strcmp(val, STRING_DEFAULT)) s->df_recovery = MSEL_DEFAULT; else if (!strcmp(val, STRING_ON)) s->df_recovery = MSEL_ON; else if (!strcmp(val, STRING_OFF)) s->df_recovery = MSEL_OFF; return SANE_STATUS_GOOD; case OPT_PAPER_PROTECT: if (!strcmp(val, STRING_DEFAULT)) s->paper_protect = MSEL_DEFAULT; else if (!strcmp(val, STRING_ON)) s->paper_protect = MSEL_ON; else if (!strcmp(val, STRING_OFF)) s->paper_protect = MSEL_OFF; return SANE_STATUS_GOOD; case OPT_ADV_PAPER_PROT: if (!strcmp(val, STRING_DEFAULT)) s->adv_paper_prot = MSEL_DEFAULT; else if (!strcmp(val, STRING_ON)) s->adv_paper_prot = MSEL_ON; else if (!strcmp(val, STRING_OFF)) s->adv_paper_prot = MSEL_OFF; return SANE_STATUS_GOOD; case OPT_STAPLE_DETECT: if (!strcmp(val, STRING_DEFAULT)) s->staple_detect = MSEL_DEFAULT; else if (!strcmp(val, STRING_ON)) s->staple_detect = MSEL_ON; else if (!strcmp(val, STRING_OFF)) s->staple_detect = MSEL_OFF; return SANE_STATUS_GOOD; case OPT_BG_COLOR: if (!strcmp(val, STRING_DEFAULT)) s->bg_color = COLOR_DEFAULT; else if (!strcmp(val, STRING_WHITE)) s->bg_color = COLOR_WHITE; else if (!strcmp(val, STRING_BLACK)) s->bg_color = COLOR_BLACK; return SANE_STATUS_GOOD; case OPT_DROPOUT_COLOR: if (!strcmp(val, STRING_DEFAULT)) s->dropout_color = COLOR_DEFAULT; else if (!strcmp(val, STRING_RED)) s->dropout_color = COLOR_RED; else if (!strcmp(val, STRING_GREEN)) s->dropout_color = COLOR_GREEN; else if (!strcmp(val, STRING_BLUE)) s->dropout_color = COLOR_BLUE; return SANE_STATUS_GOOD; case OPT_BUFF_MODE: if (!strcmp(val, STRING_DEFAULT)) s->buff_mode = MSEL_DEFAULT; else if (!strcmp(val, STRING_ON)) s->buff_mode= MSEL_ON; else if (!strcmp(val, STRING_OFF)) s->buff_mode= MSEL_OFF; return SANE_STATUS_GOOD; case OPT_PREPICK: if (!strcmp(val, STRING_DEFAULT)) s->prepick = MSEL_DEFAULT; else if (!strcmp(val, STRING_ON)) s->prepick = MSEL_ON; else if (!strcmp(val, STRING_OFF)) s->prepick = MSEL_OFF; return SANE_STATUS_GOOD; case OPT_OVERSCAN: if (!strcmp(val, STRING_DEFAULT)) s->overscan = MSEL_DEFAULT; else if (!strcmp(val, STRING_ON)) s->overscan = MSEL_ON; else if (!strcmp(val, STRING_OFF)) s->overscan = MSEL_OFF; *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_SLEEP_TIME: s->sleep_time = val_c; return set_sleep_mode(s); case OPT_OFF_TIME: /* do our own constrain, because we want to round up */ s->off_time = (val_c + 14)/15*15; if(s->off_time != val_c){ *info |= SANE_INFO_INEXACT; } return set_off_mode(s); case OPT_DUPLEX_OFFSET: s->duplex_offset = val_c; return SANE_STATUS_GOOD; case OPT_GREEN_OFFSET: s->green_offset = val_c; return SANE_STATUS_GOOD; case OPT_BLUE_OFFSET: s->blue_offset = val_c; return SANE_STATUS_GOOD; case OPT_LOW_MEM: s->low_mem = val_c; return SANE_STATUS_GOOD; case OPT_HWDESKEWCROP: s->hwdeskewcrop = val_c; return SANE_STATUS_GOOD; case OPT_SWDESKEW: s->swdeskew = val_c; return SANE_STATUS_GOOD; case OPT_SWDESPECK: s->swdespeck = val_c; return SANE_STATUS_GOOD; case OPT_SWCROP: s->swcrop = val_c; return SANE_STATUS_GOOD; case OPT_SWSKIP: s->swskip = SANE_UNFIX(val_c); return SANE_STATUS_GOOD; case OPT_HALT_ON_CANCEL: s->halt_on_cancel = val_c; return SANE_STATUS_GOOD; /* Endorser Group */ case OPT_ENDORSER: s->u_endorser = val_c; *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_ENDORSER_BITS: s->u_endorser_bits = val_c; return SANE_STATUS_GOOD; /*this val not used in send_endorser*/ case OPT_ENDORSER_VAL: s->u_endorser_val = val_c; return SANE_STATUS_GOOD; case OPT_ENDORSER_STEP: s->u_endorser_step = val_c; return SANE_STATUS_GOOD; case OPT_ENDORSER_Y: s->u_endorser_y = FIXED_MM_TO_SCANNER_UNIT(val_c); return SANE_STATUS_GOOD; case OPT_ENDORSER_FONT: if (!strcmp (val, STRING_HORIZONTAL)){ s->u_endorser_font = FONT_H; } else if (!strcmp (val, STRING_HORIZONTALBOLD)){ s->u_endorser_font = FONT_HB; } else if (!strcmp (val, STRING_HORIZONTALNARROW)){ s->u_endorser_font = FONT_HN; } else if (!strcmp (val, STRING_VERTICAL)){ s->u_endorser_font = FONT_V; } else if (!strcmp (val, STRING_VERTICALBOLD)){ s->u_endorser_font = FONT_VB; } return SANE_STATUS_GOOD; case OPT_ENDORSER_DIR: if (!strcmp (val, STRING_TOPTOBOTTOM)){ s->u_endorser_dir = DIR_TTB; } else if (!strcmp (val, STRING_BOTTOMTOTOP)){ s->u_endorser_dir = DIR_BTT; } return SANE_STATUS_GOOD; /*this val not used in send_endorser*/ case OPT_ENDORSER_SIDE: if (!strcmp (val, STRING_FRONT)){ s->u_endorser_side = ED_front; } else if (!strcmp (val, STRING_BACK)){ s->u_endorser_side = ED_back; } return SANE_STATUS_GOOD; case OPT_ENDORSER_STRING: strncpy( (SANE_String)s->u_endorser_string, (SANE_String)val, s->endorser_string_len+1 ); return SANE_STATUS_GOOD; } /* switch */ } /* else */ return SANE_STATUS_INVAL; } static SANE_Status set_sleep_mode(struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[MODE_SELECT_len]; size_t cmdLen = MODE_SELECT_len; unsigned char out[MSEL_header_len + MSEL_data_min_len]; size_t outLen = MSEL_header_len + MSEL_data_min_len; unsigned char * page = out+MSEL_header_len; DBG (10, "set_sleep_mode: start\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SELECT_code); set_MSEL_pf(cmd, 1); set_MSEL_xferlen(cmd, outLen); memset(out,0,outLen); set_MSEL_pc(page, MS_pc_sleep); set_MSEL_page_len(page, MSEL_data_min_len-2); set_MSEL_sleep_mode(page, s->sleep_time); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "set_sleep_mode: finish\n"); return ret; } static SANE_Status set_off_mode(struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[SEND_DIAGNOSTIC_len]; /*also big enough for READ_DIAG*/ size_t cmdLen = SEND_DIAGNOSTIC_len; unsigned char out[SD_powoff_len]; size_t outLen = SD_powoff_len; DBG (10, "set_off_mode: start\n"); if (!s->has_cmd_sdiag || !s->has_cmd_rdiag || !s->has_off_mode){ DBG (5, "set_off_mode: not supported, returning\n"); return ret; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SEND_DIAGNOSTIC_code); set_SD_slftst(cmd, 0); set_SD_xferlen(cmd, outLen); memcpy(out,SD_powoff_string,SD_powoff_stringlen); set_SD_powoff_disable(out,!s->off_time); set_SD_powoff_interval(out,s->off_time/15); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); if (ret != SANE_STATUS_GOOD){ DBG (5, "set_off_mode: send diag error: %d\n", ret); return ret; } DBG (10, "set_off_mode: finish\n"); return SANE_STATUS_GOOD; } static SANE_Status get_hardware_status (struct fujitsu *s, SANE_Int option) { SANE_Status ret = SANE_STATUS_GOOD; DBG (10, "get_hardware_status: start\n"); /* only run this if frontend has already read the last time we got it */ /* or if we don't care for such bookkeeping (private use) */ if (!option || s->hw_read[option-OPT_TOP]) { DBG (15, "get_hardware_status: running\n"); /* mark all values as unread */ memset(s->hw_read,0,sizeof(s->hw_read)); if (s->has_cmd_hw_status){ unsigned char cmd[GET_HW_STATUS_len]; size_t cmdLen = GET_HW_STATUS_len; unsigned char in[GHS_data_len]; size_t inLen = GHS_data_len; memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, GET_HW_STATUS_code); set_GHS_allocation_length(cmd, inLen); DBG (15, "get_hardware_status: calling ghs\n"); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if (ret == SANE_STATUS_GOOD || ret == SANE_STATUS_EOF) { s->hw_top = get_GHS_top(in); s->hw_A3 = get_GHS_A3(in); s->hw_B4 = get_GHS_B4(in); s->hw_A4 = get_GHS_A4(in); s->hw_B5 = get_GHS_B5(in); s->hw_hopper = get_GHS_hopper(in); s->hw_omr = get_GHS_omr(in); s->hw_adf_open = get_GHS_adf_open(in); s->hw_sleep = get_GHS_sleep(in); s->hw_send_sw = get_GHS_send_sw(in); s->hw_manual_feed = get_GHS_manual_feed(in); s->hw_scan_sw = get_GHS_scan_sw(in); s->hw_function = get_GHS_function(in); s->hw_ink_empty = get_GHS_ink_empty(in); s->hw_double_feed = get_GHS_double_feed(in); s->hw_error_code = get_GHS_error_code(in); s->hw_skew_angle = get_GHS_skew_angle(in); if(inLen > 9){ s->hw_ink_remain = get_GHS_ink_remain(in); } ret = SANE_STATUS_GOOD; } } /* 3091/2 put hardware status in RS data */ else if (s->ghs_in_rs){ unsigned char cmd[REQUEST_SENSE_len]; size_t cmdLen = REQUEST_SENSE_len; unsigned char in[RS_return_size]; size_t inLen = RS_return_size; memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, REQUEST_SENSE_code); set_RS_return_size(cmd, inLen); DBG(15,"get_hardware_status: calling rs\n"); ret = do_cmd( s,0,0, cmd, cmdLen, NULL,0, in, &inLen ); /* parse the rs data */ if(ret == SANE_STATUS_GOOD){ if(get_RS_sense_key(in)==0 && get_RS_ASC(in)==0x80){ s->hw_adf_open = get_RS_adf_open(in); s->hw_send_sw = get_RS_send_sw(in); s->hw_scan_sw = get_RS_scan_sw(in); s->hw_duplex_sw = get_RS_duplex_sw(in); s->hw_top = get_RS_top(in); s->hw_hopper = get_RS_hopper(in); s->hw_function = get_RS_function(in); s->hw_density_sw = get_RS_density(in); } else{ DBG (10, "get_hardware_status: unexpected RS values\n"); } } } } if(option) s->hw_read[option-OPT_TOP] = 1; DBG (10, "get_hardware_status: finish\n"); return ret; } static SANE_Status send_endorser(struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[SEND_len]; size_t cmdLen = SEND_len; size_t strLen = strlen(s->u_endorser_string); unsigned char out[S_e_data_max_len]; /*we probably send less below*/ size_t outLen = S_e_data_min_len + strLen; /*fi-5900 might want 1 more byte?*/ DBG (10, "send_endorser: start\n"); if (!s->has_endorser_f && !s->has_endorser_b){ DBG (10, "send_endorser: unsupported\n"); return ret; } /*build the payload*/ memset(out,0,outLen); /*fi-5900 front side uses 0x80, assume all others*/ if(s->u_endorser_side == ED_front){ set_S_endorser_data_id(out,0x80); } else{ set_S_endorser_data_id(out,0); } set_S_endorser_stamp(out,0); set_S_endorser_elec(out,0); if(s->u_endorser_step < 0){ set_S_endorser_decr(out,S_e_decr_dec); } else{ set_S_endorser_decr(out,S_e_decr_inc); } if(s->u_endorser_bits == 24){ set_S_endorser_lap24(out,S_e_lap_24bit); } else{ set_S_endorser_lap24(out,S_e_lap_16bit); } set_S_endorser_ctstep(out,abs(s->u_endorser_step)); set_S_endorser_ulx(out,0); set_S_endorser_uly(out,s->u_endorser_y); switch (s->u_endorser_font) { case FONT_H: set_S_endorser_font(out,S_e_font_horiz); set_S_endorser_bold(out,0); break; case FONT_HB: set_S_endorser_font(out,S_e_font_horiz); set_S_endorser_bold(out,1); break; case FONT_HN: set_S_endorser_font(out,S_e_font_horiz_narrow); set_S_endorser_bold(out,0); break; case FONT_V: set_S_endorser_font(out,S_e_font_vert); set_S_endorser_bold(out,0); break; case FONT_VB: set_S_endorser_font(out,S_e_font_vert); set_S_endorser_bold(out,1); break; } set_S_endorser_size(out,0); set_S_endorser_revs(out,0); if(s->u_endorser_dir == DIR_BTT){ set_S_endorser_dirs(out,S_e_dir_bottom_top); } else{ set_S_endorser_dirs(out,S_e_dir_top_bottom); } set_S_endorser_string_length(out, strLen); set_S_endorser_string(out, s->u_endorser_string, strLen); /*build the command*/ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SEND_code); set_S_xfer_datatype (cmd, S_datatype_endorser_data); set_S_xfer_length (cmd, outLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "send_endorser: finish %d\n", ret); return ret; } /* instead of internal brightness/contrast/gamma most scanners use a 256x256 or 1024x256 LUT default is linear table of slope 1 or 1/4 resp. brightness and contrast inputs are -127 to +127 contrast rotates slope of line around central input val high low . x . . x . xx out . x . xxxxxxxx . x xx ....x....... ............ in in then brightness moves line vertically, and clamps to 8bit bright dark . xxxxxxxx . . x . out x . x . . x ............ xxxxxxxx.... in in */ static SANE_Status send_lut (struct fujitsu *s) { int i, j, bytes = 1 << s->adbits; double b, slope, offset; SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[SEND_len]; size_t cmdLen = SEND_len; unsigned char out[S_lut_header_len + S_lut_data_max_len]; size_t outLen = S_lut_header_len + S_lut_data_max_len; unsigned char * p = out + S_lut_header_len; DBG (10, "send_lut: start\n"); if(!s->num_download_gamma || !s->adbits){ DBG (10, "send_lut: unsupported\n"); return ret; } /* contrast is converted to a slope [0,90] degrees: * first [-127,127] to [0,254] then to [0,1] * then multiply by PI/2 to convert to radians * then take the tangent to get slope (T.O.A) * then multiply by the normal linear slope * because the table may not be square, i.e. 1024x256*/ slope = tan(((double)s->contrast+127)/254 * M_PI/2) * 256/bytes; /* contrast slope must stay centered, so figure * out vertical offset at central input value */ offset = 127.5-(slope*bytes/2); /* convert the user brightness setting (-127 to +127) * into a scale that covers the range required * to slide the contrast curve entirely off the table */ b = ((double)s->brightness/127) * (256 - offset); DBG (15, "send_lut: %d %f %d %f %f\n", s->brightness, b, s->contrast, slope, offset); outLen = S_lut_header_len + bytes; memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SEND_code); set_S_xfer_datatype (cmd, S_datatype_lut_data); set_S_xfer_length (cmd, outLen); memset(out,0,outLen); set_S_lut_order (out, S_lut_order_single); set_S_lut_ssize (out, bytes); set_S_lut_dsize (out, 256); for(i=0;i255){ j=255; } *p=j; p++; } ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "send_lut: finish\n"); return ret; } static SANE_Status send_q_table (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[SEND_len]; size_t cmdLen = SEND_len; unsigned char out[S_q_table_header_len + S_q_table_y_len + S_q_table_uv_len]; size_t outLen = S_q_table_header_len + S_q_table_y_len + S_q_table_uv_len; unsigned char * yp = out + S_q_table_header_len; unsigned char * uvp = out + S_q_table_header_len + S_q_table_y_len; /* FIXME: generate these instead of hardcode */ unsigned char ydata[] = { 0x04, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x04, 0x03, 0x04, 0x05, 0x05, 0x04, 0x05, 0x07, 0x0c, 0x07, 0x07, 0x06, 0x06, 0x07, 0x0e, 0x0a, 0x0b, 0x08, 0x0c, 0x11, 0x0f, 0x12, 0x12, 0x11, 0x0f, 0x10, 0x10, 0x13, 0x15, 0x1b, 0x17, 0x13, 0x14, 0x1a, 0x14, 0x10, 0x10, 0x18, 0x20, 0x18, 0x1a, 0x1c, 0x1d, 0x1e, 0x1f, 0x1e, 0x12, 0x17, 0x21, 0x24, 0x21, 0x1e, 0x24, 0x1b, 0x1e, 0x1e, 0x1d }; unsigned char uvdata[] = { 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x0e, 0x07, 0x07, 0x0e, 0x1d, 0x13, 0x10, 0x13, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d, 0x1d }; DBG (10, "send_q_table: start\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SEND_code); set_S_xfer_datatype (cmd, S_datatype_jpg_q_table); set_S_xfer_length (cmd, outLen); memset(out,0,outLen); set_S_q_table_y_len (out, S_q_table_y_len); set_S_q_table_uv_len (out, S_q_table_uv_len); memcpy (yp, ydata, S_q_table_y_len); memcpy (uvp, uvdata, S_q_table_uv_len); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "send_q_table: finish\n"); return ret; } /* only used by iX500? */ #if 0 static SANE_Status mode_select_unk (struct fujitsu *s, int foo) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[MODE_SELECT_len]; size_t cmdLen = MODE_SELECT_len; unsigned char out[MSEL_header_len + MSEL_data_min_len]; size_t outLen = MSEL_header_len + MSEL_data_min_len; unsigned char * page = out+MSEL_header_len; DBG (10, "mode_select_unk: start\n"); /*if (!s->has_MS_unk){ DBG (10, "mode_select_unk: unsupported\n"); return SANE_STATUS_GOOD; }*/ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SELECT_code); set_MSEL_pf(cmd, 1); set_MSEL_xferlen(cmd, outLen); memset(out,0,outLen); set_MSEL_pc(page, MS_pc_unk); set_MSEL_page_len(page, MSEL_data_min_len-2); *(page + 0x02) = foo; ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "mode_select_unk: finish\n"); return ret; } #endif /* only used by iX500? */ static SANE_Status diag_preread (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[SEND_DIAGNOSTIC_len]; /*also big enough for READ_DIAG*/ size_t cmdLen = SEND_DIAGNOSTIC_len; unsigned char out[SD_preread_len]; size_t outLen = SD_preread_len; DBG (10, "diag_preread: start\n"); if (!s->has_cmd_sdiag || !s->has_cmd_rdiag || !s->need_diag_preread){ DBG (5, "diag_preread: not supported, returning\n"); return ret; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SEND_DIAGNOSTIC_code); set_SD_slftst(cmd, 0); set_SD_xferlen(cmd, outLen); memcpy(out,SD_preread_string,SD_preread_stringlen); set_SD_preread_xres(out,s->resolution_x); set_SD_preread_yres(out,s->resolution_y); /* call helper function, scanner wants lies about paper width */ set_SD_preread_paper_width(out, get_page_width(s)); /* dont call helper function, scanner wants actual length? */ set_SD_preread_paper_length(out, s->page_height); set_SD_preread_composition(out, s->s_mode); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); if (ret != SANE_STATUS_GOOD){ DBG (5, "diag_preread: send diag error: %d\n", ret); return ret; } DBG (10, "diag_preread: finish\n"); return SANE_STATUS_GOOD; } static SANE_Status mode_select_df (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[MODE_SELECT_len]; size_t cmdLen = MODE_SELECT_len; unsigned char out[MSEL_header_len + MSEL_data_min_len]; size_t outLen = MSEL_header_len + MSEL_data_min_len; unsigned char * page = out+MSEL_header_len; DBG (10, "mode_select_df: start\n"); if(!s->has_MS_df){ DBG (10, "mode_select_df: unsupported\n"); return SANE_STATUS_GOOD; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SELECT_code); set_MSEL_pf(cmd, 1); set_MSEL_xferlen(cmd, outLen); memset(out,0,outLen); set_MSEL_pc(page, MS_pc_df); set_MSEL_page_len(page, MSEL_data_min_len-2); /* continue/stop */ if(s->df_action != DF_DEFAULT){ set_MSEL_df_enable (page, 1); /* continue */ if(s->df_action == DF_CONTINUE){ set_MSEL_df_continue (page, 1); } /* skew */ if(s->df_skew){ set_MSEL_df_skew (page, 1); } /* thickness */ if(s->df_thickness){ set_MSEL_df_thickness (page, 1); } /* length */ if(s->df_length){ set_MSEL_df_length (page, 1); set_MSEL_df_diff (page, s->df_diff); } } set_MSEL_df_paperprot(page,s->paper_protect); set_MSEL_df_stapledet(page,s->staple_detect); set_MSEL_df_recovery(page,s->df_recovery); set_MSEL_df_paperprot2(page,s->adv_paper_prot); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "mode_select_df: finish\n"); return ret; } static SANE_Status mode_select_bg (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[MODE_SELECT_len]; size_t cmdLen = MODE_SELECT_len; unsigned char out[MSEL_header_len + MSEL_data_min_len]; size_t outLen = MSEL_header_len + MSEL_data_min_len; unsigned char * page = out+MSEL_header_len; DBG (10, "mode_select_bg: start\n"); if(!s->has_MS_bg){ DBG (10, "mode_select_bg: unsupported\n"); return SANE_STATUS_GOOD; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SELECT_code); set_MSEL_pf(cmd, 1); set_MSEL_xferlen(cmd, outLen); memset(out,0,outLen); set_MSEL_pc(page, MS_pc_bg); set_MSEL_page_len(page, MSEL_data_min_len-2); if(s->bg_color != COLOR_DEFAULT){ set_MSEL_bg_enable (page, 1); if(s->bg_color == COLOR_BLACK){ set_MSEL_bg_front (page, 1); set_MSEL_bg_back (page, 1); set_MSEL_bg_fb (page, 1); } } ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "mode_select_bg: finish\n"); return ret; } static SANE_Status mode_select_dropout (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[MODE_SELECT_len]; size_t cmdLen = MODE_SELECT_len; unsigned char out[MSEL_header_len + MSEL_data_max_len]; size_t outLen = MSEL_header_len + MSEL_data_max_len; unsigned char * page = out+MSEL_header_len; DBG (10, "mode_select_dropout: start\n"); if(!s->has_MS_dropout){ DBG (10, "mode_select_dropout: unsupported\n"); return SANE_STATUS_GOOD; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SELECT_code); set_MSEL_pf(cmd, 1); set_MSEL_xferlen(cmd, outLen); memset(out,0,outLen); set_MSEL_pc(page, MS_pc_dropout); set_MSEL_page_len(page, MSEL_data_max_len-2); set_MSEL_dropout_front (page, s->dropout_color); set_MSEL_dropout_back (page, s->dropout_color); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "mode_select_dropout: finish\n"); return ret; } static SANE_Status mode_select_buff (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[MODE_SELECT_len]; size_t cmdLen = MODE_SELECT_len; unsigned char out[MSEL_header_len + MSEL_data_min_len]; size_t outLen = MSEL_header_len + MSEL_data_min_len; unsigned char * page = out+MSEL_header_len; DBG (10, "mode_select_buff: start\n"); if (!s->has_MS_buff){ DBG (10, "mode_select_buff: unsupported\n"); return SANE_STATUS_GOOD; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SELECT_code); set_MSEL_pf(cmd, 1); set_MSEL_xferlen(cmd, outLen); memset(out,0,outLen); set_MSEL_pc(page, MS_pc_buff); set_MSEL_page_len(page, MSEL_data_min_len-2); set_MSEL_buff_mode(page, s->buff_mode); set_MSEL_buff_clear(page, 3); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "mode_select_buff: finish\n"); return ret; } static SANE_Status mode_select_prepick (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[MODE_SELECT_len]; size_t cmdLen = MODE_SELECT_len; unsigned char out[MSEL_header_len + MSEL_data_min_len]; size_t outLen = MSEL_header_len + MSEL_data_min_len; unsigned char * page = out+MSEL_header_len; DBG (10, "mode_select_prepick: start\n"); if (!s->has_MS_prepick){ DBG (10, "mode_select_prepick: unsupported\n"); return SANE_STATUS_GOOD; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SELECT_code); set_MSEL_pf(cmd, 1); set_MSEL_xferlen(cmd, outLen); memset(out,0,outLen); set_MSEL_pc(page, MS_pc_prepick); set_MSEL_page_len(page, MSEL_data_min_len-2); set_MSEL_prepick(page, s->prepick); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "mode_select_prepick: finish\n"); return ret; } static SANE_Status mode_select_auto (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[MODE_SELECT_len]; size_t cmdLen = MODE_SELECT_len; unsigned char out[MSEL_header_len + MSEL_data_min_len]; size_t outLen = MSEL_header_len + MSEL_data_min_len; unsigned char * page = out+MSEL_header_len; DBG (10, "mode_select_auto: start\n"); if(!s->has_MS_auto){ DBG (10, "mode_select_auto: unsupported\n"); return SANE_STATUS_GOOD; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, MODE_SELECT_code); set_MSEL_pf(cmd, 1); set_MSEL_xferlen(cmd, outLen); memset(out,0,outLen); set_MSEL_pc(page, MS_pc_auto); set_MSEL_page_len(page, MSEL_data_min_len-2); set_MSEL_overscan(page, s->overscan); set_MSEL_ald(page, s->ald || s->hwdeskewcrop); set_MSEL_awd(page, s->awd || s->hwdeskewcrop); set_MSEL_req_driv_crop(page, s->hwdeskewcrop && (s->swcrop || s->swdeskew)); set_MSEL_deskew(page, s->hwdeskewcrop); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "mode_select_auto: finish\n"); return ret; } /* * @@ Section 4 - SANE scanning functions */ /* * Called by SANE to retrieve information about the type of data * that the current scan will return. * * From the SANE spec: * This function is used to obtain the current scan parameters. The * returned parameters are guaranteed to be accurate between the time * a scan has been started (sane_start() has been called) and the * completion of that request. Outside of that window, the returned * values are best-effort estimates of what the parameters will be * when sane_start() gets invoked. * * Calling this function before a scan has actually started allows, * for example, to get an estimate of how big the scanned image will * be. The parameters passed to this function are the handle h of the * device for which the parameters should be obtained and a pointer p * to a parameter structure. */ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { SANE_Status ret = SANE_STATUS_GOOD; struct fujitsu *s = (struct fujitsu *) handle; DBG (10, "sane_get_parameters: start\n"); /* not started? update param data from user settings */ if(!s->started){ ret = update_params(s); if(ret) return ret; } params->format = s->u_params.format; params->last_frame = s->u_params.last_frame; params->lines = s->u_params.lines; params->depth = s->u_params.depth; params->pixels_per_line = s->u_params.pixels_per_line; params->bytes_per_line = s->u_params.bytes_per_line; /* we wont know the end until we get to it */ if(s->ald && !must_fully_buffer(s)){ DBG (15, "sane_get_parameters: hand-scanner mode\n"); params->lines = -1; } DBG (10, "sane_get_parameters: finish\n"); return ret; } /* set s_params and u_params data based on user settings * and scanner capabilities. */ SANE_Status update_params (struct fujitsu * s) { SANE_Status ret = SANE_STATUS_GOOD; SANE_Parameters * params = &(s->s_params); DBG (10, "update_params: start\n"); /* first, we setup s_params to describe the image to the scanner */ /* this backend only sends single frame images */ params->last_frame = 1; /* initial ppl from user settings */ params->pixels_per_line = s->resolution_x * (s->br_x - s->tl_x) / 1200; /* some scanners require even number of bytes in each transfer block, * so we round to even # of total lines, to ensure last block is even */ params->lines = s->resolution_y * (s->br_y - s->tl_y) / 1200; params->lines -= params->lines % 2; if (s->s_mode == MODE_COLOR) { params->depth = 8; /* jpeg requires 8x8 squares */ if(s->compress == COMP_JPEG){ params->format = SANE_FRAME_JPEG; params->pixels_per_line -= params->pixels_per_line % 8; params->lines -= params->lines % 8; } else{ params->format = SANE_FRAME_RGB; params->pixels_per_line -= params->pixels_per_line % max(s->ppl_mod_by_mode[s->s_mode], s->ppl_mod_by_mode[s->u_mode]); } params->bytes_per_line = params->pixels_per_line * 3; } else if (s->s_mode == MODE_GRAYSCALE) { params->depth = 8; /* jpeg requires 8x8 squares */ if(s->compress == COMP_JPEG){ params->format = SANE_FRAME_JPEG; params->pixels_per_line -= params->pixels_per_line % 8; params->lines -= params->lines % 8; } else{ params->format = SANE_FRAME_GRAY; params->pixels_per_line -= params->pixels_per_line % max(s->ppl_mod_by_mode[s->s_mode], s->ppl_mod_by_mode[s->u_mode]); } params->bytes_per_line = params->pixels_per_line; } else { params->depth = 1; params->format = SANE_FRAME_GRAY; params->pixels_per_line -= params->pixels_per_line % max(s->ppl_mod_by_mode[s->s_mode], s->ppl_mod_by_mode[s->u_mode]); params->bytes_per_line = params->pixels_per_line / 8; } DBG(15,"update_params: x: max=%d, page=%d, gpw=%d, res=%d\n", s->max_x, s->page_width, get_page_width(s), s->resolution_x); DBG(15,"update_params: y: max=%d, page=%d, gph=%d, res=%d\n", s->max_y, s->page_height, get_page_height(s), s->resolution_y); DBG(15,"update_params: area: tlx=%d, brx=%d, tly=%d, bry=%d\n", s->tl_x, s->br_x, s->tl_y, s->br_y); DBG(15,"update_params: params: ppl=%d, Bpl=%d, lines=%d\n", params->pixels_per_line, params->bytes_per_line, params->lines); DBG(15,"update_params: params: format=%d, depth=%d, last=%d\n", params->format, params->depth, params->last_frame); /* second, we setup u_params to describe the image to the user */ /* use a helper function cause it is called elsewhere */ ret = update_u_params(s); DBG (10, "update_params: finish\n"); return ret; } /* set u_param data based on user settings, and s_params */ SANE_Status update_u_params (struct fujitsu * s) { SANE_Status ret = SANE_STATUS_GOOD; SANE_Parameters * params = &(s->u_params); DBG (10, "update_u_params: start\n"); /* for most machines, it is the same, so we just copy */ memcpy(&(s->u_params), &(s->s_params), sizeof(SANE_Parameters)); /* some scanners don't support the user's mode, so params differ */ /* but not in jpeg mode. we don't support that. */ if(must_downsample(s)){ /* making gray from a color scan */ if (s->u_mode == MODE_GRAYSCALE) { params->format = SANE_FRAME_GRAY; params->bytes_per_line = params->pixels_per_line; } /* making binary from a gray or color scan */ else if (s->u_mode == MODE_LINEART) { params->depth = 1; params->format = SANE_FRAME_GRAY; params->bytes_per_line = params->pixels_per_line / 8; } DBG(15,"update_u_params: x: max=%d, page=%d, gpw=%d, res=%d\n", s->max_x, s->page_width, get_page_width(s), s->resolution_x); DBG(15,"update_u_params: y: max=%d, page=%d, gph=%d, res=%d\n", s->max_y, s->page_height, get_page_height(s), s->resolution_y); DBG(15,"update_u_params: area: tlx=%d, brx=%d, tly=%d, bry=%d\n", s->tl_x, s->br_x, s->tl_y, s->br_y); DBG(15,"update_u_params: params: ppl=%d, Bpl=%d, lines=%d\n", params->pixels_per_line, params->bytes_per_line, params->lines); DBG(15,"update_u_params: params: format=%d, depth=%d, last=%d\n", params->format, params->depth, params->last_frame); } DBG (10, "update_u_params: finish\n"); return ret; } /* * Called by SANE when a page acquisition operation is to be started. * commands: scanner control (lampon), send (lut), send (dither), * set window, object pos, and scan * * this will be called between sides of a duplex scan, * and at the start of each page of an adf batch. * hence, we spend alot of time playing with s->started, etc. */ SANE_Status sane_start (SANE_Handle handle) { struct fujitsu *s = handle; SANE_Status ret = SANE_STATUS_GOOD; DBG (10, "sane_start: start\n"); DBG (15, "started=%d, side=%d, source=%d\n", s->started, s->side, s->source); /* undo any prior sane_cancel calls */ s->cancelled=0; /* protect this block from sane_cancel */ s->reading=1; /* not finished with current side, error */ if (s->started && !s->eof_tx[s->side]) { DBG(5,"sane_start: previous transfer not finished?"); ret = SANE_STATUS_INVAL; goto errors; } /* low mem mode messes up the side marker, reset it */ if(s->source == SOURCE_ADF_DUPLEX && s->low_mem && s->eof_tx[SIDE_FRONT] && s->eof_tx[SIDE_BACK] ){ s->side = SIDE_BACK; } /* batch start? initialize struct and scanner */ if(!s->started){ /* load side marker */ if(s->source == SOURCE_ADF_BACK){ s->side = SIDE_BACK; } else{ s->side = SIDE_FRONT; } /* load our own private copy of scan params */ ret = update_params(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot update params\n"); goto errors; } /* switch source */ if(s->source == SOURCE_FLATBED){ ret = scanner_control(s, SC_function_fb); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot control fb, ignoring\n"); } } else{ ret = scanner_control(s, SC_function_adf); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot control ADF, ignoring\n"); } } /* required for hi res scans on iX500? */ ret = diag_preread(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot diag_preread %d\n", ret); /* enable overscan/auto detection */ ret = mode_select_auto(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot mode_select_auto %d\n", ret); /* enable double feed detection */ ret = mode_select_df(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot mode_select_df %d\n", ret); /* enable background color setting */ ret = mode_select_bg(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot mode_select_bg %d\n", ret); /* enable dropout color setting */ ret = mode_select_dropout(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot mode_select_dropout %d\n", ret); /* enable buffering setting */ ret = mode_select_buff(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot mode_select_buff %d\n", ret); /* enable prepick setting */ ret = mode_select_prepick(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot mode_select_prepick %d\n", ret); /* send endorser config */ ret = send_endorser(s); 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, * 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); } /* set window command */ ret = set_window(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot set window\n"); goto errors; } /* 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); } /* some scanners need the q table sent, even when not scanning jpeg */ if (s->need_q_table){ ret = send_q_table(s); if (ret != SANE_STATUS_GOOD) DBG (5, "sane_start: WARNING: cannot send_q_table %d\n", ret); } /* start/stop endorser */ ret = endorser(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot start/stop endorser\n"); goto errors; } /* turn lamp on */ ret = scanner_control(s, SC_function_lamp_on); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: WARNING: cannot start lamp, ignoring\n"); } /* iX500 errors if op is called with no paper * at the beginning of a batch, so we check */ if(s->hopper_before_op && s->source != SOURCE_FLATBED){ ret = get_hardware_status(s,0); if(!s->hw_hopper){ ret = SANE_STATUS_NO_DOCS; DBG (5, "sane_start: ERROR: hopper empty\n"); goto errors; } } } /* if already running, duplex needs to switch sides */ else if(s->source == SOURCE_ADF_DUPLEX){ s->side = !s->side; } /* set clean defaults with new sheet of paper */ /* dont reset the transfer vars on backside of duplex page */ /* otherwise buffered back page will be lost */ /* ingest paper with adf (no-op for fb) */ /* dont call object pos or scan on back side of duplex scan */ if(s->side == SIDE_FRONT || s->source == SOURCE_ADF_BACK){ s->bytes_rx[0]=0; s->bytes_rx[1]=0; s->lines_rx[0]=0; s->lines_rx[1]=0; s->eof_rx[0]=0; s->eof_rx[1]=0; s->ili_rx[0]=0; s->ili_rx[1]=0; s->eom_rx=0; s->bytes_tx[0]=0; s->bytes_tx[1]=0; s->eof_tx[0]=0; s->eof_tx[1]=0; s->buff_rx[0]=0; s->buff_rx[1]=0; s->buff_tx[0]=0; s->buff_tx[1]=0; /* reset jpeg just in case... */ s->jpeg_stage = JPEG_STAGE_NONE; s->jpeg_ff_offset = -1; s->jpeg_front_rst = 0; s->jpeg_back_rst = 0; ret = object_position (s, OP_Feed); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot load page\n"); goto errors; } ret = start_scan (s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot start_scan\n"); goto errors; } /* try to read scan size from scanner */ ret = get_pixelsize(s,0); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot get pixelsize\n"); goto errors; } /* store the number of front bytes */ if ( s->source != SOURCE_ADF_BACK ){ s->bytes_tot[SIDE_FRONT] = s->s_params.bytes_per_line * s->s_params.lines; s->buff_tot[SIDE_FRONT] = s->buffer_size; /* the front buffer is normally very small, but some scanners or * option combinations can't handle it, so we make a big one */ if( (s->s_mode == MODE_COLOR && s->color_interlace == COLOR_INTERLACE_3091) || must_fully_buffer(s) ){ s->buff_tot[SIDE_FRONT] = s->bytes_tot[SIDE_FRONT]; } } else{ s->bytes_tot[SIDE_FRONT] = 0; s->buff_tot[SIDE_FRONT] = 0; } /* store the number of back bytes */ if ( s->source == SOURCE_ADF_DUPLEX || s->source == SOURCE_ADF_BACK ){ s->bytes_tot[SIDE_BACK] = s->s_params.bytes_per_line * s->s_params.lines; s->buff_tot[SIDE_BACK] = s->bytes_tot[SIDE_BACK]; /* the back buffer is normally very large, but some scanners or * option combinations dont need it, so we make a small one */ if(s->low_mem || s->source == SOURCE_ADF_BACK || s->duplex_interlace == DUPLEX_INTERLACE_NONE) s->buff_tot[SIDE_BACK] = s->buffer_size; } else{ s->bytes_tot[SIDE_BACK] = 0; s->buff_tot[SIDE_BACK] = 0; } /* first page of batch */ /* make large buffer to hold the images */ /* and set started flag */ if(!s->started){ ret = setup_buffers(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot load buffers\n"); goto errors; } s->started=1; } } else{ /* try to read scan size from scanner */ ret = get_pixelsize(s,0); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot get pixelsize\n"); goto errors; } } DBG (15, "started=%d, side=%d, source=%d\n", s->started, s->side, s->source); /* certain options require the entire image to * be collected from the scanner before we can * 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( must_fully_buffer(s) ){ /* get image */ while(!s->eof_rx[s->side] && !ret){ SANE_Int len = 0; ret = sane_read((SANE_Handle)s, NULL, 0, &len); } /* check for errors */ if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot buffer image\n"); goto errors; } DBG (5, "sane_start: OK: done buffering\n"); /* hardware deskew will tell image size after transfer */ ret = get_pixelsize(s,1); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot get final pixelsize\n"); goto errors; } /* finished buffering, adjust image as required */ if(s->swdeskew && (!s->hwdeskewcrop || s->req_driv_crop)){ buffer_deskew(s,s->side); } if(s->swcrop && (!s->hwdeskewcrop || s->req_driv_crop)){ buffer_crop(s,s->side); } 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->bytes_tx[s->side] = s->bytes_rx[s->side]; s->eof_tx[s->side] = 1; return sane_start(handle); } } } /* check if user cancelled during this start */ ret = check_for_cancel(s); /* unprotect this block from sane_cancel */ s->reading=0; DBG (10, "sane_start: finish %d\n", ret); return ret; errors: DBG (10, "sane_start: error %d\n", ret); /* if we are started, but something went wrong, * chances are there is image data inside scanner, * which should be discarded via cancel command */ if(s->started){ s->cancelled = 1; check_for_cancel(s); } s->started = 0; s->cancelled = 0; s->reading = 0; return ret; } static SANE_Status endorser(struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[ENDORSER_len]; size_t cmdLen = ENDORSER_len; unsigned char out[ED_max_len]; size_t outLen = ED_max_len; DBG (10, "endorser: start\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, ENDORSER_code); memset(out,0,outLen); if (s->has_endorser_f || s->has_endorser_b){ /*fi-5900 front side uses 0x80, assume all others*/ if(s->u_endorser_side == ED_front){ set_ED_endorser_data_id(out,0x80); } else{ set_ED_endorser_data_id(out,0); } if(s->u_endorser){ set_ED_stop(out,ED_start); } else{ set_ED_stop(out,ED_stop); } set_ED_side(out,s->u_endorser_side); if(s->u_endorser_bits == 24){ set_ED_lap24(out,ED_lap_24bit); set_ED_initial_count_24(out,s->u_endorser_val); } else{ outLen = ED_min_len; set_ED_lap24(out,ED_lap_16bit); set_ED_initial_count_16(out,s->u_endorser_val); } set_E_xferlen(cmd, outLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); } DBG (10, "endorser: finish %d\n", ret); return ret; } static SANE_Status scanner_control (struct fujitsu *s, int function) { SANE_Status ret = SANE_STATUS_GOOD; int tries = 0; unsigned char cmd[SCANNER_CONTROL_len]; size_t cmdLen = SCANNER_CONTROL_len; DBG (10, "scanner_control: start\n"); if(s->has_cmd_scanner_ctl){ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SCANNER_CONTROL_code); set_SC_function (cmd, function); DBG (15, "scanner_control: function %d\n",function); /* don't really need to ask for adf if that's the only option */ /* doing so causes the 3091 to complain */ if(function == SC_function_adf && !s->has_flatbed){ DBG (10, "scanner_control: adf function not required\n"); return ret; } /* extremely long retry period */ while(tries++ < 120){ ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, NULL, NULL ); if(ret == SANE_STATUS_GOOD || function != SC_function_lamp_on){ break; } usleep(500000); } if(ret == SANE_STATUS_GOOD){ DBG (15, "scanner_control: success, tries %d, ret %d\n",tries,ret); } else{ DBG (5, "scanner_control: error, tries %d, ret %d\n",tries,ret); } } DBG (10, "scanner_control: finish\n"); return ret; } static SANE_Status scanner_control_ric (struct fujitsu *s, int bytes, int side) { SANE_Status ret = SANE_STATUS_GOOD; int tries = 0; unsigned char cmd[SCANNER_CONTROL_len]; size_t cmdLen = SCANNER_CONTROL_len; DBG (10, "scanner_control_ric: start\n"); if(s->has_cmd_scanner_ctl){ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SCANNER_CONTROL_code); set_SC_ric(cmd, 1); if (side == SIDE_BACK) { set_SC_ric_dtq(cmd, WD_wid_back); } else{ set_SC_ric_dtq(cmd, WD_wid_front); } set_SC_ric_len(cmd, bytes); DBG (15, "scanner_control_ric: %d %d\n",bytes,side); /* extremely long retry period */ while(tries++ < 120){ ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, NULL, NULL ); if(ret != SANE_STATUS_DEVICE_BUSY){ break; } usleep(500000); } if(ret == SANE_STATUS_GOOD){ DBG (15, "scanner_control_ric: success, tries %d, ret %d\n",tries,ret); } /* some errors pass thru unchanged */ else if(ret == SANE_STATUS_CANCELLED || ret == SANE_STATUS_JAMMED || ret == SANE_STATUS_NO_DOCS || ret == SANE_STATUS_COVER_OPEN ){ DBG (5, "scanner_control_ric: error, tries %d, ret %d\n",tries,ret); } /* other errors are ignored, since scanner may not support RIC */ else{ DBG (5, "scanner_control_ric: ignoring, tries %d, ret %d\n",tries,ret); ret = SANE_STATUS_GOOD; } } DBG (10, "scanner_control_ric: finish\n"); return ret; } /* * callocs a buffer to hold the scan data */ static SANE_Status setup_buffers (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; int side; DBG (10, "setup_buffers: start\n"); for(side=0;side<2;side++){ /* free old mem */ if (s->buffers[side]) { DBG (15, "setup_buffers: free buffer %d.\n",side); free(s->buffers[side]); s->buffers[side] = NULL; } if(s->buff_tot[side]){ s->buffers[side] = calloc (1,s->buff_tot[side]); if (!s->buffers[side]) { DBG (5, "setup_buffers: Error, no buffer %d.\n",side); return SANE_STATUS_NO_MEM; } } } DBG (10, "setup_buffers: finish\n"); return ret; } /* * This routine issues a SCSI SET WINDOW command to the scanner, using the * values currently in the scanner data structure. */ static SANE_Status set_window (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; /* The command specifies the number of bytes in the data phase * the data phase has a header, followed by 1 or 2 window desc blocks * the header specifies the number of bytes in 1 window desc block */ unsigned char cmd[SET_WINDOW_len]; size_t cmdLen = SET_WINDOW_len; /*this is max size, we might send less below*/ unsigned char out[SW_header_len + SW_desc_len + SW_desc_len]; size_t outLen = SW_header_len + SW_desc_len + SW_desc_len; unsigned char * header = out; /*header*/ unsigned char * desc1 = out + SW_header_len; /*1st desc*/ unsigned char * desc2 = out + SW_header_len + SW_desc_len; /*2nd desc*/ int length = 0; DBG (10, "set_window: start\n"); /*build the payload*/ memset(out,0,outLen); /* set window desc size in header */ set_WPDB_wdblen(header, SW_desc_len); /* init the window block */ if (s->source == SOURCE_ADF_BACK) { set_WD_wid (desc1, WD_wid_back); } else{ set_WD_wid (desc1, WD_wid_front); } set_WD_Xres (desc1, s->resolution_x); set_WD_Yres (desc1, s->resolution_y); set_WD_ULX (desc1, s->tl_x); /* low-end scanners ignore paper-size, * so we have to center the window ourselves */ if(s->cropping_mode == CROP_ABSOLUTE){ set_WD_ULX (desc1, s->tl_x + (s->max_x - s->page_width) / 2); } set_WD_ULY (desc1, s->tl_y); set_WD_width (desc1, s->s_params.pixels_per_line * 1200/s->resolution_x); length = s->s_params.lines * 1200/s->resolution_y; /* stupid trick. 3091/2 require reading extra lines, * because they have a gap between R G and B */ if(s->s_mode == MODE_COLOR && s->color_interlace == COLOR_INTERLACE_3091){ length += (s->color_raster_offset+s->green_offset) * 1200/300 * 2; DBG(5,"set_window: Increasing length to %d\n",length); } set_WD_length (desc1, length); set_WD_brightness (desc1, 0); if(s->brightness_steps){ /*convert our common -127 to +127 range into HW's range *FIXME: this code assumes hardware range of 0-255 */ set_WD_brightness (desc1, s->brightness+128); } set_WD_threshold (desc1, s->threshold); set_WD_contrast (desc1, 0); if(s->contrast_steps){ /*convert our common -127 to +127 range into HW's range *FIXME: this code assumes hardware range of 0-255 */ set_WD_contrast (desc1, s->contrast+128); } set_WD_composition (desc1, s->s_mode); set_WD_bitsperpixel (desc1, s->s_params.depth); if(s->s_mode == MODE_HALFTONE){ set_WD_ht_type(desc1, s->ht_type); set_WD_ht_pattern(desc1, s->ht_pattern); } set_WD_rif (desc1, s->rif); set_WD_compress_type(desc1, COMP_NONE); set_WD_compress_arg(desc1, 0); /* some scanners support jpeg image compression, for color/gs only */ if(s->s_params.format == SANE_FRAME_JPEG){ set_WD_compress_type(desc1, COMP_JPEG); set_WD_compress_arg(desc1, s->compress_arg); } /* the remainder of the block varies based on model and mode, * except for gamma and paper size, those are in the same place */ /*vuid c0*/ if(s->has_vuid_3091){ set_WD_vendor_id_code (desc1, WD_VUID_3091); set_WD_gamma (desc1, s->window_gamma); if (s->s_mode != MODE_COLOR){ switch (s->dropout_color) { case COLOR_RED: set_WD_lamp_color (desc1, WD_LAMP_RED); break; case COLOR_GREEN: set_WD_lamp_color (desc1, WD_LAMP_GREEN); break; case COLOR_BLUE: set_WD_lamp_color (desc1, WD_LAMP_BLUE); break; default: set_WD_lamp_color (desc1, WD_LAMP_DEFAULT); break; } } /*set_WD_quality(desc1,s->quality);*/ } /*vuid c1*/ else if(s->s_mode == MODE_COLOR && s->has_vuid_color){ set_WD_vendor_id_code (desc1, WD_VUID_COLOR); set_WD_gamma (desc1, s->window_gamma); if(s->color_interlace == COLOR_INTERLACE_RGB){ set_WD_scanning_order (desc1, WD_SCAN_ORDER_DOT); set_WD_scanning_order_arg (desc1, WD_SCAN_ARG_RGB); } else if(s->color_interlace == COLOR_INTERLACE_BGR){ set_WD_scanning_order (desc1, WD_SCAN_ORDER_DOT); set_WD_scanning_order_arg (desc1, WD_SCAN_ARG_BGR); } else if(s->color_interlace == COLOR_INTERLACE_RRGGBB){ set_WD_scanning_order (desc1, WD_SCAN_ORDER_LINE); set_WD_scanning_order_arg (desc1, WD_SCAN_ARG_RGB); } else{ DBG (5,"set_window: unknown color interlacing\n"); return SANE_STATUS_INVAL; } /*scanner emphasis ranges from 0 to 7f and smoothing from 80 to ff*/ /* but we expose them to user as a single linear range smooth->emphasis */ /* flip the smooth part over, and tack it onto the upper end of emphasis */ if(s->emphasis < 0) set_WD_c1_emphasis(desc1,127-s->emphasis); else set_WD_c1_emphasis(desc1,s->emphasis); set_WD_c1_mirroring(desc1,s->mirroring); set_WD_wl_follow(desc1,s->wl_follow); } /*vuid 00*/ else if(s->has_vuid_mono){ set_WD_vendor_id_code (desc1, WD_VUID_MONO); set_WD_gamma (desc1, s->window_gamma); set_WD_outline(desc1,s->outline); /*scanner emphasis ranges from 0 to 7f and smoothing from 80 to ff*/ /* but we expose them to user as a single linear range smooth->emphasis */ /* flip the smooth part over, and tack it onto the upper end of emphasis */ if(s->emphasis < 0) set_WD_emphasis(desc1,127-s->emphasis); else set_WD_emphasis(desc1,s->emphasis); set_WD_separation(desc1,s->separation); set_WD_mirroring(desc1,s->mirroring); if (get_ipc_mode(s) == WD_ipc_SDTC) set_WD_variance(desc1,s->variance); 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); if(s->noise_removal){ set_WD_matrix5x5(desc1,s->matrix_5); set_WD_matrix4x4(desc1,s->matrix_4); set_WD_matrix3x3(desc1,s->matrix_3); set_WD_matrix2x2(desc1,s->matrix_2); } set_WD_background(desc1,s->threshold_white); } set_WD_wl_follow(desc1,s->wl_follow); set_WD_subwindow_list(desc1,0); set_WD_ipc_mode(desc1,get_ipc_mode(s)); } else{ DBG (5,"set_window: no vuid to send?\n"); return SANE_STATUS_INVAL; } /* common to all vuids */ if(s->source == SOURCE_FLATBED){ set_WD_paper_selection(desc1,WD_paper_SEL_UNDEFINED); } else{ set_WD_paper_selection (desc1, WD_paper_SEL_NON_STANDARD); /* call helper function, scanner wants lies about paper width */ set_WD_paper_width_X (desc1, get_page_width(s)); /* dont call helper function, scanner wants actual length? */ set_WD_paper_length_Y (desc1, s->page_height); } /* when in duplex mode, copy first desc block into second */ if (s->source == SOURCE_ADF_DUPLEX) { memcpy (desc2, desc1, SW_desc_len); set_WD_wid (desc2, WD_wid_back); /* FIXME: do we really need these on back of page? */ set_WD_paper_selection (desc2, WD_paper_SEL_UNDEFINED); set_WD_paper_width_X (desc2, 0); set_WD_paper_length_Y (desc2, 0); } /* output shorter if not using duplex */ else{ outLen -= SW_desc_len; } /*build the command*/ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SET_WINDOW_code); set_SW_xferlen(cmd, outLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "set_window: finish\n"); return ret; } /* update s_params with actual data size scanner reports */ /* then copy as required to the u_params to send to user */ static SANE_Status get_pixelsize(struct fujitsu *s, int actual) { SANE_Status ret; unsigned char cmd[READ_len]; size_t cmdLen = READ_len; unsigned char in[R_PSIZE_len]; size_t inLen = R_PSIZE_len; DBG (10, "get_pixelsize: start %d\n",actual); if (!s->has_pixelsize){ DBG (10, "get_pixelsize: unsupported\n"); return SANE_STATUS_GOOD; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, READ_code); set_R_datatype_code (cmd, R_datatype_pixelsize); if(s->side == SIDE_BACK){ set_R_window_id (cmd, WD_wid_back); } else{ set_R_window_id (cmd, WD_wid_front); } set_R_xfer_length (cmd, inLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if (ret == SANE_STATUS_GOOD){ /* 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); } else{ s->s_params.pixels_per_line = get_PSIZE_num_x(in); } /* stupid trick. 3091/2 require reading extra lines, * because they have a gap between R G and B * we only want to report the shorter value to the frontend */ if(s->s_mode == MODE_COLOR && s->color_interlace == COLOR_INTERLACE_3091){ DBG(5,"get_pixelsize: Ignoring length %d\n",get_PSIZE_num_y(in)); } /* 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); } else{ s->s_params.lines = get_PSIZE_num_y(in); } /* bytes per line differs by mode */ if (s->s_mode == MODE_COLOR) { s->s_params.bytes_per_line = s->s_params.pixels_per_line * 3; } else if (s->s_mode == MODE_GRAYSCALE) { s->s_params.bytes_per_line = s->s_params.pixels_per_line; } else { s->s_params.bytes_per_line = s->s_params.pixels_per_line / 8; } /* some scanners can request that the driver clean img */ if(!s->has_short_pixelsize && get_PSIZE_req_driv_valid(in)){ s->req_driv_crop = get_PSIZE_req_driv_crop(in); s->req_driv_lut = get_PSIZE_req_driv_lut(in); DBG(5,"get_pixelsize: scanner requests: crop=%d, lut=%d\n", s->req_driv_crop,s->req_driv_lut); } DBG (15, "get_pixelsize: scan_x=%d, Bpl=%d, scan_y=%d\n", s->s_params.pixels_per_line, s->s_params.bytes_per_line, s->s_params.lines ); /* the user params are usually the same */ s->u_params.pixels_per_line = s->s_params.pixels_per_line; s->u_params.lines = s->s_params.lines; /* bytes per line differs by mode */ if (s->u_mode == MODE_COLOR) { s->u_params.bytes_per_line = s->u_params.pixels_per_line * 3; } else if (s->u_mode == MODE_GRAYSCALE) { s->u_params.bytes_per_line = s->u_params.pixels_per_line; } else { s->u_params.bytes_per_line = s->u_params.pixels_per_line / 8; } } else{ DBG (10, "get_pixelsize: got bad status %d, ignoring\n", ret); s->has_pixelsize = 0; ret = SANE_STATUS_GOOD; } DBG (10, "get_pixelsize: finish\n"); return ret; } /* * Issues the SCSI OBJECT POSITION command if an ADF is in use. */ static SANE_Status object_position (struct fujitsu *s, int action) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[OBJECT_POSITION_len]; size_t cmdLen = OBJECT_POSITION_len; DBG (10, "object_position: start %d\n", action); if (s->source == SOURCE_FLATBED && action < OP_Halt) { DBG (10, "object_position: flatbed no-op\n"); return SANE_STATUS_GOOD; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, OBJECT_POSITION_code); set_OP_action (cmd, action); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, NULL, NULL ); if (ret != SANE_STATUS_GOOD) return ret; if(!s->no_wait_after_op) wait_scanner (s); DBG (10, "object_position: finish\n"); return ret; } /* * Issues SCAN command. * * (This doesn't actually read anything, it just tells the scanner * to start scanning.) */ static SANE_Status start_scan (struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[SCAN_len]; size_t cmdLen = SCAN_len; unsigned char out[] = {WD_wid_front, WD_wid_back}; size_t outLen = 2; DBG (10, "start_scan: start\n"); if (s->source != SOURCE_ADF_DUPLEX) { outLen--; if(s->source == SOURCE_ADF_BACK) { out[0] = WD_wid_back; } } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, SCAN_code); set_SC_xfer_length (cmd, outLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, outLen, NULL, NULL ); DBG (10, "start_scan: finish\n"); return ret; } /* checks started and cancelled flags in scanner struct, * sends cancel command to scanner if required. don't call * this function asyncronously, wait for pending operation */ static SANE_Status check_for_cancel(struct fujitsu *s) { SANE_Status ret=SANE_STATUS_GOOD; DBG (10, "check_for_cancel: start %d %d\n",s->started,s->cancelled); if(s->started && s->cancelled){ /* halt scan */ if(s->halt_on_cancel){ DBG (15, "check_for_cancel: halting\n"); ret = object_position (s, OP_Halt); } /* cancel scan */ else{ DBG (15, "check_for_cancel: cancelling\n"); ret = scanner_control(s, SC_function_cancel); } if (ret == SANE_STATUS_GOOD || ret == SANE_STATUS_CANCELLED) { ret = SANE_STATUS_CANCELLED; } else{ DBG (5, "check_for_cancel: ERROR: cannot cancel\n"); } s->started = 0; s->cancelled = 0; } else if(s->cancelled){ DBG (15, "check_for_cancel: already cancelled\n"); ret = SANE_STATUS_CANCELLED; s->cancelled = 0; } DBG (10, "check_for_cancel: finish %d\n",ret); return ret; } /* * Called by SANE to read data. * * From the SANE spec: * This function is used to read image data from the device * represented by handle h. Argument buf is a pointer to a memory * area that is at least maxlen bytes long. The number of bytes * returned is stored in *len. A backend must set this to zero when * the call fails (i.e., when a status other than SANE_STATUS_GOOD is * returned). * * When the call succeeds, the number of bytes returned can be * anywhere in the range from 0 to maxlen bytes. */ SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { struct fujitsu *s = (struct fujitsu *) handle; SANE_Status ret=SANE_STATUS_GOOD; DBG (10, "sane_read: start\n"); *len=0; /* maybe cancelled? */ if(!s->started){ DBG (5, "sane_read: not started, call sane_start\n"); return SANE_STATUS_CANCELLED; } /* sane_start required between sides */ if(s->eof_rx[s->side] && s->bytes_tx[s->side] == s->bytes_rx[s->side]){ DBG (15, "sane_read: returning eof\n"); s->eof_tx[s->side] = 1; /* swap sides if user asked for low-mem mode, we are duplexing, * and there is data waiting on the other side */ if(s->low_mem && s->source == SOURCE_ADF_DUPLEX && (s->bytes_rx[!s->side] > s->bytes_tx[!s->side] || (s->eof_rx[!s->side] && !s->eof_tx[!s->side]) ) ){ s->side = !s->side; } return SANE_STATUS_EOF; } /* protect this block from sane_cancel */ s->reading = 1; /* ---------------------------------------------- * try to read some data from scanner into buffer * these functions are expected not to overrun */ /* 3091/2 are on crack, get their own duplex reader function */ if(s->source == SOURCE_ADF_DUPLEX && s->duplex_interlace == DUPLEX_INTERLACE_3091 ){ ret = read_from_3091duplex(s); if(ret){ DBG(5,"sane_read: 3091 returning %d\n",ret); return ret; } } /* end 3091 */ /* alternating jpeg duplex interlacing */ else if(s->source == SOURCE_ADF_DUPLEX && s->s_params.format == SANE_FRAME_JPEG && s->jpeg_interlace == JPEG_INTERLACE_ALT ){ ret = read_from_JPEGduplex(s); if(ret){ DBG(5,"sane_read: jpeg duplex returning %d\n",ret); return ret; } } /* end alt jpeg */ /* alternating pnm duplex interlacing */ else if(s->source == SOURCE_ADF_DUPLEX && s->s_params.format != SANE_FRAME_JPEG && s->duplex_interlace == DUPLEX_INTERLACE_ALT ){ /* buffer front side */ ret = read_from_scanner(s, SIDE_FRONT); if(ret){ DBG(5,"sane_read: front returning %d\n",ret); return ret; } /* buffer back side, but don't get too far ahead of the front! */ if(s->bytes_rx[SIDE_BACK] < s->bytes_rx[SIDE_FRONT] + s->buffer_size){ ret = read_from_scanner(s, SIDE_BACK); if(ret){ DBG(5,"sane_read: back returning %d\n",ret); return ret; } } } /* end alt pnm */ /* simplex or non-alternating duplex */ else{ ret = read_from_scanner(s, s->side); if(ret){ DBG(5,"sane_read: side %d returning %d\n",s->side,ret); return ret; } } /*end simplex*/ /* uncommon case, downsample and copy a block from buffer to frontend */ if(must_downsample(s)){ ret = downsample_from_buffer(s,buf,max_len,len,s->side); } /* common case, memcpy a block from buffer to frontend */ else{ ret = read_from_buffer(s,buf,max_len,len,s->side); } /*finished sending small buffer, reset it*/ if(s->buff_tx[s->side] == s->buff_rx[s->side] && s->buff_tot[s->side] < s->bytes_tot[s->side] ){ DBG (15, "sane_read: reset buffers\n"); s->buff_rx[s->side] = 0; s->buff_tx[s->side] = 0; } /* check if user cancelled during this read */ ret = check_for_cancel(s); /* swap sides if user asked for low-mem mode, we are duplexing, * and there is data waiting on the other side */ if(s->low_mem && s->source == SOURCE_ADF_DUPLEX && (s->bytes_rx[!s->side] > s->bytes_tx[!s->side] || (s->eof_rx[!s->side] && !s->eof_tx[!s->side]) ) ){ s->side = !s->side; } /* unprotect this block from sane_cancel */ s->reading = 0; DBG (10, "sane_read: finish %d\n", ret); return ret; } /* bare jpeg images dont contain resolution, but JFIF APP0 does, so we add */ static SANE_Status inject_jfif_header(struct fujitsu *s, int side) { SANE_Status ret=SANE_STATUS_GOOD; unsigned char out[] = { 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x01, 0x00, 0x48, 0x00, 0x48, 0x00, 0x00 }; size_t outLen=JFIF_APP0_LENGTH; DBG (10, "inject_jfif_header: start %d\n", side); putnbyte(out + 12, s->resolution_x, 2); putnbyte(out + 14, s->resolution_y, 2); memcpy(s->buffers[side]+s->buff_rx[side], out, outLen); s->buff_rx[side] += outLen; s->bytes_rx[side] += outLen; DBG (10, "inject_jfif_header: finish %d\n", ret); return ret; } static SANE_Status read_from_JPEGduplex(struct fujitsu *s) { SANE_Status ret=SANE_STATUS_GOOD; unsigned char cmd[READ_len]; size_t cmdLen = READ_len; unsigned char * in; size_t inLen = 0; int bytes = s->buffer_size; int i = 0; DBG (10, "read_from_JPEGduplex: start\n"); if(s->eof_rx[SIDE_FRONT] && s->eof_rx[SIDE_BACK]){ DBG (10, "read_from_JPEGduplex: already have eofs, done\n"); return ret; } /* we don't know if the following read will give us front or back data * so we only get enough to fill whichever is smaller (and not yet done) */ if(!s->eof_rx[SIDE_FRONT]){ int avail = s->buff_tot[SIDE_FRONT] - s->buff_rx[SIDE_FRONT]; if(bytes > avail){ bytes = avail; /* leave space for JFIF header at start of image */ if(s->bytes_rx[SIDE_FRONT] < 2) bytes -= JFIF_APP0_LENGTH; } } if(!s->eof_rx[SIDE_BACK]){ int avail = s->buff_tot[SIDE_BACK] - s->buff_rx[SIDE_BACK]; if(bytes > avail){ bytes = avail; /* leave space for JFIF header at start of image */ if(s->bytes_rx[SIDE_BACK] < 2) bytes -= JFIF_APP0_LENGTH; } } DBG(15, "read_from_JPEGduplex: fto:%d frx:%d bto:%d brx:%d pa:%d\n", s->bytes_tot[SIDE_FRONT], s->bytes_rx[SIDE_FRONT], s->bytes_tot[SIDE_BACK], s->bytes_rx[SIDE_BACK], bytes); /* this will happen if buffer is not drained yet */ if(bytes < 1){ DBG(5, "read_from_JPEGduplex: Warning: no bytes this pass\n"); return ret; } /* fi-6770A gets mad if you 'read' too soon on usb, see if it is ready */ if(!s->bytes_rx[SIDE_FRONT] && s->connection == CONNECTION_USB){ DBG (15, "read: start of usb page, checking RIC\n"); ret = scanner_control_ric(s,bytes,SIDE_FRONT); if(ret){ DBG(5,"read: ric returning %d\n",ret); return ret; } } inLen = bytes; in = malloc(inLen); if(!in){ DBG(5, "read_from_JPEGduplex: not enough mem for buffer: %d\n",(int)inLen); return SANE_STATUS_NO_MEM; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, READ_code); set_R_datatype_code (cmd, R_datatype_imagedata); /* interlaced jpeg duplex always reads from front */ set_R_window_id (cmd, WD_wid_front); set_R_xfer_length (cmd, inLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if (ret == SANE_STATUS_GOOD || ret == SANE_STATUS_EOF) { DBG(15, "read_from_JPEGduplex: got GOOD/EOF, returning GOOD\n"); } else if (ret == SANE_STATUS_DEVICE_BUSY) { DBG(5, "read_from_JPEGduplex: got BUSY, returning GOOD\n"); inLen = 0; ret = SANE_STATUS_GOOD; } else { DBG(5, "read_from_JPEGduplex: error reading data status = %d\n", ret); inLen = 0; } for(i=0;i<(int)inLen;i++){ /* about to change stage */ if(in[i] == 0xff && s->jpeg_ff_offset != 0){ s->jpeg_ff_offset=0; continue; } /* last byte was an ff, this byte will change stage */ if(s->jpeg_ff_offset == 0){ /* first marker after SOI is not APP0, add one */ if(s->jpeg_stage == JPEG_STAGE_SOI && in[i] != 0xe0){ inject_jfif_header(s,SIDE_FRONT); inject_jfif_header(s,SIDE_BACK); s->jpeg_stage = JPEG_STAGE_HEAD; } /* SOI header, in both sides */ if(in[i] == 0xd8){ s->jpeg_stage = JPEG_STAGE_SOI; DBG(15, "read_from_JPEGduplex: stage SOI\n"); } /* headers (HuffTab/QTab/DRI), in both sides */ else if(in[i] == 0xc4 || in[i] == 0xdb || in[i] == 0xdd){ s->jpeg_stage = JPEG_STAGE_HEAD; DBG(15, "read_from_JPEGduplex: stage head\n"); } /* start of frame, in both sides, update x first */ else if(in[i]==0xc0){ s->jpeg_stage = JPEG_STAGE_SOF; DBG(15, "read_from_JPEGduplex: stage sof\n"); } /* start of scan, first few bytes of marker in both sides * but rest in front */ else if(in[i]==0xda){ s->jpeg_stage = JPEG_STAGE_SOS; DBG(15, "read_from_JPEGduplex: stage sos\n"); } /* found image block. images are not interlaced */ /* copy to front, don't change RST */ else if(in[i] >= 0xd0 && in[i] <= 0xd7 && s->jpeg_interlace == JPEG_INTERLACE_NONE){ s->jpeg_stage = JPEG_STAGE_FRONT; DBG(35, "read_from_JPEGduplex: stage front (all)\n"); } /* found even numbered image block. */ /* images are interlaced, so switch to back. */ /* also change from even RST to proper one */ else if(in[i] == 0xd0 || in[i] == 0xd2 || in[i] == 0xd4 || in[i] == 0xd6){ s->jpeg_stage = JPEG_STAGE_BACK; DBG(35, "read_from_JPEGduplex: stage back\n"); /* skip first RST for back side*/ if(!s->jpeg_back_rst){ DBG(15, "read_from_JPEGduplex: stage back jump\n"); s->jpeg_ff_offset++; s->jpeg_back_rst++; continue; } in[i] = 0xd0 + (s->jpeg_back_rst-1) % 8; s->jpeg_back_rst++; } /* finished back image block, switch to front */ /* also change from odd RST to proper one */ else if(in[i] == 0xd1 || in[i] == 0xd3 || in[i] == 0xd5 || in[i] == 0xd7){ s->jpeg_stage = JPEG_STAGE_FRONT; DBG(35, "read_from_JPEGduplex: stage front\n"); in[i] = 0xd0 + (s->jpeg_front_rst % 8); s->jpeg_front_rst++; } /* finished image, update totals */ else if(in[i]==0xd9){ s->jpeg_stage = JPEG_STAGE_EOI; DBG(15, "read_from_JPEGduplex: stage eoi %d %d\n",(int)inLen,i); } /* unknown, warn */ else if(in[i] != 0xff){ DBG(15, "read_from_JPEGduplex: unknown %02x\n", in[i]); } } s->jpeg_ff_offset++; /* first x byte in start of frame, buffer it */ if(s->jpeg_stage == JPEG_STAGE_SOF && s->jpeg_ff_offset == 7){ s->jpeg_x_byte = in[i]; continue; } /* second x byte in start of frame */ if(s->jpeg_stage == JPEG_STAGE_SOF && s->jpeg_ff_offset == 8){ int width = (s->jpeg_x_byte << 8) | in[i]; /* if image width equals what we asked for, then * the image is not interlaced, clean up the mess */ if(width == s->s_params.pixels_per_line){ DBG(15, "read_from_JPEGduplex: right width, req:%d got:%d\n", s->s_params.pixels_per_line,width); /* stop copying to the back */ s->jpeg_interlace = JPEG_INTERLACE_NONE; /* clear what is already in the back */ s->bytes_rx[SIDE_BACK]=0; s->lines_rx[SIDE_BACK]=0; s->buff_rx[SIDE_BACK]=0; /* and put the high-order width byte into front unchanged */ s->buffers[SIDE_FRONT][s->buff_rx[SIDE_FRONT]++] = s->jpeg_x_byte; s->bytes_rx[SIDE_FRONT]++; } /* image is interlaced afterall, continue */ else{ DBG(15, "read_from_JPEGduplex: wrong width, req:%d got:%d\n", s->s_params.pixels_per_line,width); /* put the high-order width byte into front side, shifted down */ s->buffers[SIDE_FRONT][s->buff_rx[SIDE_FRONT]++] = width >> 9; s->bytes_rx[SIDE_FRONT]++; /* put the high-order width byte into back side, shifted down */ s->buffers[SIDE_BACK][s->buff_rx[SIDE_BACK]++] = width >> 9; s->bytes_rx[SIDE_BACK]++; /* shift down low order byte */ in[i] = (width >> 1) & 0xff; } } /* copy these stages to front */ if(s->jpeg_stage == JPEG_STAGE_SOI || s->jpeg_stage == JPEG_STAGE_HEAD || s->jpeg_stage == JPEG_STAGE_SOF || s->jpeg_stage == JPEG_STAGE_SOS || s->jpeg_stage == JPEG_STAGE_EOI || s->jpeg_stage == JPEG_STAGE_FRONT ){ /* first byte after ff, send the ff first */ if(s->jpeg_ff_offset == 1){ s->buffers[SIDE_FRONT][s->buff_rx[SIDE_FRONT]++] = 0xff; s->bytes_rx[SIDE_FRONT]++; } s->buffers[SIDE_FRONT][s->buff_rx[SIDE_FRONT]++] = in[i]; s->bytes_rx[SIDE_FRONT]++; } /* copy these stages to back */ if( s->jpeg_interlace == JPEG_INTERLACE_ALT && ( s->jpeg_stage == JPEG_STAGE_SOI || s->jpeg_stage == JPEG_STAGE_HEAD || s->jpeg_stage == JPEG_STAGE_SOF || s->jpeg_stage == JPEG_STAGE_SOS || s->jpeg_stage == JPEG_STAGE_EOI || s->jpeg_stage == JPEG_STAGE_BACK ) ){ /* first byte after ff, send the ff first */ if(s->jpeg_ff_offset == 1){ s->buffers[SIDE_BACK][s->buff_rx[SIDE_BACK]++] = 0xff; s->bytes_rx[SIDE_BACK]++; } s->buffers[SIDE_BACK][s->buff_rx[SIDE_BACK]++] = in[i]; s->bytes_rx[SIDE_BACK]++; } /* reached last byte of SOS section, next byte front */ if(s->jpeg_stage == JPEG_STAGE_SOS && s->jpeg_ff_offset == 0x0d){ s->jpeg_stage = JPEG_STAGE_FRONT; } /* last byte of file, update totals, bail out */ if(s->jpeg_stage == JPEG_STAGE_EOI){ s->eof_rx[SIDE_FRONT] = 1; if(s->jpeg_interlace == JPEG_INTERLACE_ALT) s->eof_rx[SIDE_BACK] = 1; } } free(in); /* jpeg uses in-band EOI marker, so this is ususally redundant */ if(ret == SANE_STATUS_EOF){ DBG(15, "read_from_JPEGduplex: got EOF, finishing\n"); s->eof_rx[SIDE_FRONT] = 1; if(s->jpeg_interlace == JPEG_INTERLACE_ALT) s->eof_rx[SIDE_BACK] = 1; ret = SANE_STATUS_GOOD; } DBG (10, "read_from_JPEGduplex: finish\n"); return ret; } static SANE_Status read_from_3091duplex(struct fujitsu *s) { SANE_Status ret=SANE_STATUS_GOOD; unsigned char cmd[READ_len]; size_t cmdLen = READ_len; unsigned char * in; size_t inLen = 0; int side = SIDE_FRONT; int bytes = s->buffer_size; int off = (s->duplex_raster_offset+s->duplex_offset) * s->resolution_y/300; unsigned int i; DBG (10, "read_from_3091duplex: start\n"); if(s->eof_rx[SIDE_FRONT] && s->eof_rx[SIDE_BACK]){ DBG (10, "read_from_3091duplex: already have eofs, done\n"); return ret; } /* we don't know if the following read will give us front,back or both data * so we only get enough to fill whichever is smaller (and not yet done) */ if(!s->eof_rx[SIDE_FRONT]){ int avail = s->buff_tot[SIDE_FRONT] - s->buff_rx[SIDE_FRONT]; if(bytes > avail) bytes = avail; } if(!s->eof_rx[SIDE_BACK]){ int avail = s->buff_tot[SIDE_BACK] - s->buff_rx[SIDE_BACK]; if(bytes > avail) bytes = avail; } /* all requests must end on a line boundary */ bytes -= (bytes % s->s_params.bytes_per_line); DBG(15, "read_from_3091duplex: front img: to:%d rx:%d tx:%d li:%d\n", s->bytes_tot[SIDE_FRONT], s->bytes_rx[SIDE_FRONT], s->bytes_tx[SIDE_FRONT], s->lines_rx[SIDE_FRONT]); DBG(15, "read_from_3091duplex: front buf: to:%d rx:%d tx:%d\n", s->buff_tot[SIDE_FRONT], s->buff_rx[SIDE_FRONT], s->buff_tx[SIDE_FRONT]); DBG(15, "read_from_3091duplex: back img: to:%d rx:%d tx:%d li:%d\n", s->bytes_tot[SIDE_BACK], s->bytes_rx[SIDE_BACK], s->bytes_tx[SIDE_BACK], s->lines_rx[SIDE_BACK]); DBG(15, "read_from_3091duplex: back buf: to:%d rx:%d tx:%d\n", s->buff_tot[SIDE_BACK], s->buff_rx[SIDE_BACK], s->buff_tx[SIDE_BACK]); DBG(15, "read_from_3091duplex: bu:%d pa:%d of:%d\n", s->buffer_size, bytes, off); /* this could happen if the front buffer is not drained fast enough */ if(bytes < 1){ DBG(10, "read_from_3091duplex: Warning: no bytes this pass\n"); return ret; } inLen = bytes; in = malloc(inLen); if(!in){ DBG(5, "read_from_3091duplex: not enough mem for buffer: %d\n",(int)inLen); return SANE_STATUS_NO_MEM; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, READ_code); set_R_datatype_code (cmd, R_datatype_imagedata); /* 3091 duplex always reads from front */ set_R_window_id (cmd, WD_wid_front); set_R_xfer_length (cmd, inLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if (ret == SANE_STATUS_GOOD || ret == SANE_STATUS_EOF) { DBG(15, "read_from_3091duplex: got GOOD/EOF, returning GOOD\n"); } else if (ret == SANE_STATUS_DEVICE_BUSY) { DBG(5, "read_from_3091duplex: got BUSY, returning GOOD\n"); inLen = 0; ret = SANE_STATUS_GOOD; } else { DBG(5, "read_from_3091duplex: error reading data block status = %d\n", ret); inLen = 0; } /* loop thru all lines in read buffer */ for(i=0;is_params.bytes_per_line;i++){ /* start is front */ if(s->lines_rx[SIDE_FRONT] < off){ side=SIDE_FRONT; } /* end is back */ else if(s->eof_rx[SIDE_FRONT]){ side=SIDE_BACK; } /* odd are back */ else if( ((s->lines_rx[SIDE_FRONT] + s->lines_rx[SIDE_BACK] - off) % 2) ){ side=SIDE_BACK; } /* even are front */ else{ side=SIDE_FRONT; } if(s->s_mode == MODE_COLOR && s->color_interlace == COLOR_INTERLACE_3091){ copy_3091 (s, in + i*s->s_params.bytes_per_line, s->s_params.bytes_per_line, side); } else{ copy_buffer (s, in + i*s->s_params.bytes_per_line, s->s_params.bytes_per_line, side); } } if(ret == SANE_STATUS_EOF){ DBG(15, "read_from_3091duplex: got EOF, finishing both sides\n"); s->eof_rx[SIDE_FRONT] = 1; s->eof_rx[SIDE_BACK] = 1; ret = SANE_STATUS_GOOD; } free(in); DBG (10, "read_from_3091duplex: finish\n"); return ret; } static SANE_Status read_from_scanner(struct fujitsu *s, int side) { SANE_Status ret=SANE_STATUS_GOOD; unsigned char cmd[READ_len]; size_t cmdLen = READ_len; unsigned char * in; size_t inLen = 0; int bytes = s->buffer_size; int avail = s->buff_tot[side] - s->buff_rx[side]; int remain = s->bytes_tot[side] - s->bytes_rx[side]; DBG (10, "read_from_scanner: start %d\n", side); if(s->eof_rx[side]){ DBG (10, "read_from_scanner: already have eof, done\n"); return ret; } /* figure out the max amount to transfer */ if(bytes > avail) bytes = avail; /* all requests must end on line boundary */ bytes -= (bytes % s->s_params.bytes_per_line); /* some larger scanners require even bytes per block */ /* so we get even lines, but not on the last block */ /* cause odd number of lines would never finish */ if(bytes % 2 && bytes < remain){ bytes -= s->s_params.bytes_per_line; } /* jpeg scans leave space for JFIF header at start of image */ if(s->s_params.format == SANE_FRAME_JPEG && s->bytes_rx[side] < 2) bytes -= JFIF_APP0_LENGTH; DBG(15, "read_from_scanner: si:%d re:%d bs:%d by:%d av:%d\n", side, remain, s->buffer_size, bytes, avail); DBG(15, "read_from_scanner: img to:%d rx:%d tx:%d li:%d\n", s->bytes_tot[side], s->bytes_rx[side], s->bytes_tx[side], s->lines_rx[side]); DBG(15, "read_from_scanner: buf to:%d rx:%d tx:%d\n", s->buff_tot[side], s->buff_rx[side], s->buff_tx[side]); /* this will happen if buffer is not drained yet */ if(bytes < 1){ DBG(5, "read_from_scanner: no bytes this pass\n"); return ret; } /* fi-6770A gets mad if you 'read' too soon on usb, see if it is ready */ if(!s->bytes_rx[side] && s->connection == CONNECTION_USB){ DBG (15, "read_from_scanner: start of usb page, checking RIC\n"); ret = scanner_control_ric(s,bytes,side); if(ret){ DBG(5,"read_from_scanner: ric returning %d\n",ret); return ret; } } inLen = bytes; in = malloc(inLen); if(!in){ DBG(5, "read_from_scanner: not enough mem for buffer: %d\n",(int)inLen); return SANE_STATUS_NO_MEM; } memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, READ_code); set_R_datatype_code (cmd, R_datatype_imagedata); if (side == SIDE_BACK) { set_R_window_id (cmd, WD_wid_back); } else{ set_R_window_id (cmd, WD_wid_front); } set_R_xfer_length (cmd, inLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if (ret == SANE_STATUS_GOOD || ret == SANE_STATUS_EOF) { DBG(15, "read_from_scanner: got GOOD/EOF, returning GOOD\n"); ret = SANE_STATUS_GOOD; } else if (ret == SANE_STATUS_DEVICE_BUSY) { DBG(5, "read_from_scanner: got BUSY, returning GOOD\n"); inLen = 0; ret = SANE_STATUS_GOOD; } else { DBG(5, "read_from_scanner: error reading data block status = %d\n",ret); inLen = 0; } DBG(15, "read_from_scanner: read %lu bytes\n",(unsigned long)inLen); if(inLen){ if(s->s_mode==MODE_COLOR && s->color_interlace == COLOR_INTERLACE_3091){ copy_3091 (s, in, inLen, side); } else if(s->s_params.format == SANE_FRAME_JPEG){ copy_JPEG (s, in, inLen, side); } else{ copy_buffer (s, in, inLen, side); } } free(in); /* if this was a short read or not, log it */ s->ili_rx[side] = s->rs_ili; if(s->ili_rx[side]){ DBG(15, "read_from_scanner: got ILI\n"); } /* if this was an end of medium, log it */ if(s->rs_eom){ DBG(15, "read_from_scanner: got EOM\n"); s->eom_rx = 1; } /* paper ran out. lets try to set the eof flag on both sides, * but only if that side had a short read last time */ if(s->eom_rx){ int i; for(i=0;i<2;i++){ if(s->ili_rx[i]){ DBG(15, "read_from_scanner: finishing side %d\n",i); s->eof_rx[i] = 1; } } } DBG (10, "read_from_scanner: finish\n"); return ret; } static SANE_Status copy_3091(struct fujitsu *s, unsigned char * buf, int len, int side) { SANE_Status ret=SANE_STATUS_GOOD; int i, j, dest, boff, goff; DBG (10, "copy_3091: start\n"); /* Data is RR...GG...BB... on each line, * green is back 8 lines from red at 300 dpi * blue is back 4 lines from red at 300 dpi. * * Here, we get things on correct line, and * interlace to make RGBRGB. * * We add the user-supplied offsets before we scale * so that they are independent of scanning resolution. */ goff = (s->color_raster_offset+s->green_offset) * s->resolution_y/150; boff = (s->color_raster_offset+s->blue_offset) * s->resolution_y/300; /* loop thru all lines in read buffer */ for(i=0;is_params.bytes_per_line){ /* red at start of line */ dest = s->lines_rx[side] * s->s_params.bytes_per_line; if(dest >= 0 && dest < s->bytes_tot[side]){ for (j=0; js_params.pixels_per_line; j++){ s->buffers[side][dest+j*3] = buf[i+j]; } } /* green is in middle of line */ dest = (s->lines_rx[side] - goff) * s->s_params.bytes_per_line; if(dest >= 0 && dest < s->bytes_tot[side]){ for (j=0; js_params.pixels_per_line; j++){ s->buffers[side][dest+j*3+1] = buf[i+s->s_params.pixels_per_line+j]; } } /* blue is at end of line */ dest = (s->lines_rx[side] - boff) * s->s_params.bytes_per_line; if(dest >= 0 && dest < s->bytes_tot[side]){ for (j=0; js_params.pixels_per_line; j++){ s->buffers[side][dest+j*3+2] = buf[i+2*s->s_params.pixels_per_line+j]; } } s->lines_rx[side]++; } /* even if we have read data, we may not have any * full lines loaded yet, so we may have to lie */ i = (s->lines_rx[side]-goff) * s->s_params.bytes_per_line; if(i < 0){ i = 0; } s->bytes_rx[side] = i; s->buff_rx[side] = i; if(s->bytes_rx[side] == s->bytes_tot[side]){ s->eof_rx[side] = 1; } DBG(15, "copy_3091: si:%d imgrx:%d bufrx:%d li:%d eof:%d\n", side, s->bytes_rx[side], s->buff_rx[side], s->lines_rx[side], s->eof_rx[side]); DBG (10, "copy_3091: finish\n"); return ret; } static SANE_Status copy_JPEG(struct fujitsu *s, unsigned char * buf, int len, int side) { SANE_Status ret=SANE_STATUS_GOOD; int i, seen = 0; DBG (10, "copy_JPEG: start\n"); /* A jpeg image starts with the SOI marker, FF D8. * This is optionally followed by the JFIF APP0 * marker, FF E0. If that marker is not present, * we add it, so we can insert the resolution */ if(!s->bytes_rx[side] && len >= 4 && buf[0] == 0xFF && buf[1] == 0xD8 && buf[2] == 0xFF && buf[3] != 0xE0 ){ /* SOI marker */ for (i=0; i<2; i++){ s->buffers[side][s->buff_rx[side]++] = buf[i]; s->bytes_rx[side]++; seen++; } /* JFIF header after SOI */ inject_jfif_header(s,side); } memcpy(s->buffers[side]+s->buff_rx[side],buf+seen,len-seen); s->buff_rx[side] += len-seen; s->bytes_rx[side] += len-seen; /* should never happen with jpeg */ if(s->bytes_rx[side] == s->bytes_tot[side]){ s->eof_rx[side] = 1; } DBG (10, "copy_JPEG: finish\n"); return ret; } static SANE_Status copy_buffer(struct fujitsu *s, unsigned char * buf, int len, int side) { SANE_Status ret=SANE_STATUS_GOOD; int i, j; int bwidth = s->s_params.bytes_per_line; int pwidth = s->s_params.pixels_per_line; DBG (10, "copy_buffer: start\n"); /* invert image if scanner needs it for this mode */ /* jpeg data does not use inverting */ if(s->s_params.format != SANE_FRAME_JPEG && s->reverse_by_mode[s->s_mode]){ for(i=0; is_params.format == SANE_FRAME_RGB){ switch (s->color_interlace) { /* scanner returns pixel data as bgrbgr... */ case COLOR_INTERLACE_BGR: for(i=0; ibuffers[side][s->buff_rx[side]++] = buf[i+j*3+2]; s->buffers[side][s->buff_rx[side]++] = buf[i+j*3+1]; s->buffers[side][s->buff_rx[side]++] = buf[i+j*3]; } } break; /* one line has the following format: rrr...rrrggg...gggbbb...bbb */ case COLOR_INTERLACE_RRGGBB: for(i=0; ibuffers[side][s->buff_rx[side]++] = buf[i+j]; s->buffers[side][s->buff_rx[side]++] = buf[i+pwidth+j]; s->buffers[side][s->buff_rx[side]++] = buf[i+2*pwidth+j]; } } break; default: memcpy(s->buffers[side]+s->buff_rx[side],buf,len); s->buff_rx[side] += len; break; } } /* jpeg/gray/ht/binary */ else{ memcpy(s->buffers[side]+s->buff_rx[side],buf,len); s->buff_rx[side] += len; } s->bytes_rx[side] += len; s->lines_rx[side] += len/s->s_params.bytes_per_line; if(s->bytes_rx[side] == s->bytes_tot[side]){ s->eof_rx[side] = 1; } DBG (10, "copy_buffer: finish\n"); return ret; } static SANE_Status read_from_buffer(struct fujitsu *s, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len, int side) { SANE_Status ret=SANE_STATUS_GOOD; int bytes = max_len; int remain = s->buff_rx[side] - s->buff_tx[side]; DBG (10, "read_from_buffer: start\n"); /* figure out the max amount to transfer */ if(bytes > remain){ bytes = remain; } *len = bytes; DBG(15, "read_from_buffer: si:%d re:%d ml:%d by:%d\n", side, remain, max_len, bytes); DBG(15, "read_from_buffer: img to:%d rx:%d tx:%d\n", s->bytes_tot[side], s->bytes_rx[side], s->bytes_tx[side]); DBG(15, "read_from_buffer: buf to:%d rx:%d tx:%d\n", s->buff_tot[side], s->buff_rx[side], s->buff_tx[side]); /*FIXME this needs to timeout eventually */ if(!bytes){ DBG(5,"read_from_buffer: nothing to do\n"); return SANE_STATUS_GOOD; } memcpy(buf,s->buffers[side]+s->buff_tx[side],bytes); s->buff_tx[side] += bytes; s->bytes_tx[side] += bytes; DBG (10, "read_from_buffer: finish\n"); return ret; } /* we have bytes of higher mode image data in s->buffers */ /* user asked for lower mode image. downsample and copy to buf */ static SANE_Status downsample_from_buffer(struct fujitsu *s, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len, int side) { SANE_Status ret=SANE_STATUS_GOOD; DBG (10, "downsample_from_buffer: start %d %d %d %d\n", s->bytes_rx[side], s->bytes_tx[side], s->buff_rx[side], s->buff_tx[side]); if(s->s_mode == MODE_COLOR && s->u_mode == MODE_GRAYSCALE){ while(*len < max_len && s->buff_rx[side] - s->buff_tx[side] >= 3){ int gray = 0; switch (s->dropout_color) { case COLOR_RED: gray = *(s->buffers[side]+s->buff_tx[side]) * 3; break; case COLOR_GREEN: gray = *(s->buffers[side]+s->buff_tx[side]+1) * 3; break; case COLOR_BLUE: gray = *(s->buffers[side]+s->buff_tx[side]+2) * 3; break; default: gray = *(s->buffers[side]+s->buff_tx[side]) + *(s->buffers[side]+s->buff_tx[side]+1) + *(s->buffers[side]+s->buff_tx[side]+2); break; } /* bookkeeping for input */ s->buff_tx[side] += 3; s->bytes_tx[side] += 3; /* add byte to output */ *(buf + *len) = gray/3; (*len)++; } } else if(s->s_mode == MODE_COLOR && s->u_mode == MODE_LINEART){ /* threshold of 0 is actually middle of range */ /*FIXME: add dynamic threshold? */ unsigned char thresh = (s->threshold ? s->threshold : 127); while(*len < max_len && s->buff_rx[side] - s->buff_tx[side] >= 24){ int i; unsigned char out = 0; for(i=0; i<8; i++){ int gray = 0; switch (s->dropout_color) { case COLOR_RED: gray = *(s->buffers[side]+s->buff_tx[side]) * 3; break; case COLOR_GREEN: gray = *(s->buffers[side]+s->buff_tx[side]+1) * 3; break; case COLOR_BLUE: gray = *(s->buffers[side]+s->buff_tx[side]+2) * 3; break; default: gray = *(s->buffers[side]+s->buff_tx[side]) + *(s->buffers[side]+s->buff_tx[side]+1) + *(s->buffers[side]+s->buff_tx[side]+2); break; } /* black if input gray is lower than threshold */ if(gray/3 < thresh){ out |= (0x80 >> i); } /* bookkeeping for input */ s->buff_tx[side] += 3; s->bytes_tx[side] += 3; } /* add byte to output */ *(buf + *len) = out; (*len)++; } } else{ DBG (5, "downsample_from_buffer: invalid mode combination\n"); ret = SANE_STATUS_INVAL; } DBG (10, "downsample_from_buffer: finish %d %d %d %d\n", s->bytes_rx[side], s->bytes_tx[side], s->buff_rx[side], s->buff_tx[side]); return ret; } /* * @@ Section 5 - SANE cleanup functions */ /* * Cancels a scan. * * It has been said on the mailing list that sane_cancel is a bit of a * misnomer because it is routinely called to signal the end of a * batch - quoting David Mosberger-Tang: * * > In other words, the idea is to have sane_start() be called, and * > collect as many images as the frontend wants (which could in turn * > consist of multiple frames each as indicated by frame-type) and * > when the frontend is done, it should call sane_cancel(). * > Sometimes it's better to think of sane_cancel() as "sane_stop()" * > but that name would have had some misleading connotations as * > well, that's why we stuck with "cancel". * * The current consensus regarding duplex and ADF scans seems to be * the following call sequence: sane_start; sane_read (repeat until * EOF); sane_start; sane_read... and then call sane_cancel if the * batch is at an end. I.e. do not call sane_cancel during the run but * as soon as you get a SANE_STATUS_NO_DOCS. * * From the SANE spec: * This function is used to immediately or as quickly as possible * cancel the currently pending operation of the device represented by * handle h. This function can be called at any time (as long as * handle h is a valid handle) but usually affects long-running * operations only (such as image is acquisition). It is safe to call * this function asynchronously (e.g., from within a signal handler). * It is important to note that completion of this operaton does not * imply that the currently pending operation has been cancelled. It * only guarantees that cancellation has been initiated. Cancellation * completes only when the cancelled call returns (typically with a * status value of SANE_STATUS_CANCELLED). Since the SANE API does * not require any other operations to be re-entrant, this implies * that a frontend must not call any other operation until the * cancelled operation has returned. */ void sane_cancel (SANE_Handle handle) { struct fujitsu * s = (struct fujitsu *) handle; DBG (10, "sane_cancel: start\n"); s->cancelled = 1; /* if there is no other running function to check, we do it */ if(!s->reading) check_for_cancel(s); DBG (10, "sane_cancel: finish\n"); } /* * Ends use of the scanner. * * From the SANE spec: * This function terminates the association between the device handle * passed in argument h and the device it represents. If the device is * presently active, a call to sane_cancel() is performed first. After * this function returns, handle h must not be used anymore. */ void sane_close (SANE_Handle handle) { struct fujitsu * s = (struct fujitsu *) handle; DBG (10, "sane_close: start\n"); /*clears any held scans*/ mode_select_buff(s); disconnect_fd(s); DBG (10, "sane_close: finish\n"); } static SANE_Status disconnect_fd (struct fujitsu *s) { DBG (10, "disconnect_fd: start\n"); if(s->fd > -1){ if (s->connection == CONNECTION_USB) { DBG (15, "disconnecting usb device\n"); sanei_usb_close (s->fd); } else if (s->connection == CONNECTION_SCSI) { DBG (15, "disconnecting scsi device\n"); sanei_scsi_close (s->fd); } s->fd = -1; } DBG (10, "disconnect_fd: finish\n"); return SANE_STATUS_GOOD; } /* * Terminates the backend. * * From the SANE spec: * This function must be called to terminate use of a backend. The * function will first close all device handles that still might be * open (it is recommended to close device handles explicitly through * a call to sane_close(), but backends are required to release all * resources upon a call to this function). After this function * returns, no function other than sane_init() may be called * (regardless of the status value returned by sane_exit(). Neglecting * to call this function may result in some resources not being * released properly. */ void sane_exit (void) { struct fujitsu *dev, *next; DBG (10, "sane_exit: start\n"); for (dev = fujitsu_devList; dev; dev = next) { disconnect_fd(dev); next = dev->next; free (dev); } if (sane_devArray) free (sane_devArray); fujitsu_devList = NULL; sane_devArray = NULL; DBG (10, "sane_exit: finish\n"); } /* * @@ Section 6 - misc helper functions */ /* * Called by the SANE SCSI core and our usb code on device errors * parses the request sense return data buffer, * decides the best SANE_Status for the problem, produces debug msgs, * and copies the sense buffer into the scanner struct */ static SANE_Status sense_handler (int fd, unsigned char * sensed_data, void *arg) { struct fujitsu *s = arg; unsigned int sense = get_RS_sense_key (sensed_data); unsigned int asc = get_RS_ASC (sensed_data); unsigned int ascq = get_RS_ASCQ (sensed_data); DBG (5, "sense_handler: start\n"); /* kill compiler warning */ fd = fd; /* copy the rs return data into the scanner struct so that the caller can use it if he wants */ s->rs_info = get_RS_information (sensed_data); s->rs_eom = get_RS_EOM (sensed_data); s->rs_ili = get_RS_ILI (sensed_data); DBG (5, "Sense=%#02x, ASC=%#02x, ASCQ=%#02x, EOM=%d, ILI=%d, info=%#08lx\n", sense, asc, ascq, s->rs_eom, s->rs_ili, (unsigned long)s->rs_info); switch (sense) { case 0x0: if (0x80 == asc) { DBG (5, "No sense: hardware status bits?\n"); return SANE_STATUS_GOOD; } if (0x00 != asc) { DBG (5, "No sense: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if (0x00 != ascq) { DBG (5, "No sense: unknown ascq\n"); return SANE_STATUS_IO_ERROR; } /* ready, but short read */ if (s->rs_ili) { DBG (5, "No sense: ILI remainder:%lu\n",(unsigned long)s->rs_info); } /* ready, but end of paper */ if (s->rs_eom) { DBG (5, "No sense: EOM\n"); return SANE_STATUS_EOF; } DBG (5, "No sense: ready\n"); return SANE_STATUS_GOOD; case 0x2: if (0x00 != asc) { DBG (5, "Not ready: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if (0x00 != ascq) { DBG (5, "Not ready: unknown ascq\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "Not ready: busy\n"); return SANE_STATUS_DEVICE_BUSY; break; case 0x3: if (0x80 != asc) { DBG (5, "Medium error: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if (0x01 == ascq) { DBG (5, "Medium error: paper jam\n"); return SANE_STATUS_JAMMED; } if (0x02 == ascq) { DBG (5, "Medium error: cover open\n"); return SANE_STATUS_COVER_OPEN; } if (0x03 == ascq) { DBG (5, "Medium error: hopper empty\n"); return SANE_STATUS_NO_DOCS; } if (0x04 == ascq) { DBG (5, "Medium error: unusual paper\n"); return SANE_STATUS_JAMMED; } if (0x07 == ascq) { DBG (5, "Medium error: double feed\n"); return SANE_STATUS_JAMMED; } if (0x08 == ascq) { DBG (5, "Medium error: ADF setup error\n"); return SANE_STATUS_JAMMED; } if (0x09 == ascq) { DBG (5, "Medium error: Carrier sheet\n"); return SANE_STATUS_JAMMED; } if (0x10 == ascq) { DBG (5, "Medium error: no ink cartridge\n"); return SANE_STATUS_IO_ERROR; } if (0x13 == ascq) { DBG (5, "Medium error: temporary no data\n"); return SANE_STATUS_DEVICE_BUSY; } if (0x14 == ascq) { DBG (5, "Medium error: endorser error\n"); return SANE_STATUS_IO_ERROR; } if (0x20 == ascq) { DBG (5, "Medium error: Stop button\n"); return SANE_STATUS_NO_DOCS; } if (0x22 == ascq) { DBG (5, "Medium error: scanning halted\n"); return SANE_STATUS_CANCELLED; } if (0x30 == ascq) { DBG (5, "Medium error: Not enough paper\n"); return SANE_STATUS_NO_DOCS; } if (0x31 == ascq) { DBG (5, "Medium error: scanning disabled\n"); return SANE_STATUS_IO_ERROR; } if (0x32 == ascq) { DBG (5, "Medium error: scanning paused\n"); return SANE_STATUS_DEVICE_BUSY; } if (0x33 == ascq) { DBG (5, "Medium error: WiFi control error\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "Medium error: unknown ascq\n"); return SANE_STATUS_IO_ERROR; break; case 0x4: if (0x80 != asc && 0x44 != asc) { DBG (5, "Hardware error: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if ((0x44 == asc) && (0x00 == ascq)) { DBG (5, "Hardware error: EEPROM error\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x01 == ascq)) { DBG (5, "Hardware error: FB motor fuse\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x02 == ascq)) { DBG (5, "Hardware error: heater fuse\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x03 == ascq)) { DBG (5, "Hardware error: lamp fuse\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x04 == ascq)) { DBG (5, "Hardware error: ADF motor fuse\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x05 == ascq)) { DBG (5, "Hardware error: mechanical error\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x06 == ascq)) { DBG (5, "Hardware error: optical error\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x07 == ascq)) { DBG (5, "Hardware error: Fan error\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x08 == ascq)) { DBG (5, "Hardware error: IPC option error\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x10 == ascq)) { DBG (5, "Hardware error: endorser error\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x11 == ascq)) { DBG (5, "Hardware error: endorser fuse\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x80 == ascq)) { DBG (5, "Hardware error: interface board timeout\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x81 == ascq)) { DBG (5, "Hardware error: interface board error 1\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x82 == ascq)) { DBG (5, "Hardware error: interface board error 2\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "Hardware error: unknown asc/ascq\n"); return SANE_STATUS_IO_ERROR; break; case 0x5: if ((0x00 == asc) && (0x00 == ascq)) { DBG (5, "Illegal request: paper edge detected too soon\n"); return SANE_STATUS_INVAL; } if ((0x1a == asc) && (0x00 == ascq)) { DBG (5, "Illegal request: Parameter list error\n"); return SANE_STATUS_INVAL; } if ((0x20 == asc) && (0x00 == ascq)) { DBG (5, "Illegal request: invalid command\n"); return SANE_STATUS_INVAL; } if ((0x24 == asc) && (0x00 == ascq)) { DBG (5, "Illegal request: invalid CDB field\n"); return SANE_STATUS_INVAL; } if ((0x25 == asc) && (0x00 == ascq)) { DBG (5, "Illegal request: unsupported logical unit\n"); return SANE_STATUS_UNSUPPORTED; } if ((0x26 == asc) && (0x00 == ascq)) { DBG (5, "Illegal request: invalid field in parm list\n"); if (get_RS_additional_length(sensed_data) >= 0x0a) { DBG (5, "Offending byte is %#02x\n", get_RS_offending_byte(sensed_data)); /* move this to set_window() ? */ if (get_RS_offending_byte(sensed_data) >= 8) { DBG (5, "Window desc block? byte %#02x\n",get_RS_offending_byte(sensed_data)-8); } } return SANE_STATUS_INVAL; } if ((0x2C == asc) && (0x00 == ascq)) { DBG (5, "Illegal request: command sequence error\n"); return SANE_STATUS_INVAL; } if ((0x2C == asc) && (0x02 == ascq)) { DBG (5, "Illegal request: wrong window combination \n"); return SANE_STATUS_INVAL; } DBG (5, "Illegal request: unknown asc/ascq\n"); return SANE_STATUS_IO_ERROR; break; case 0x6: if ((0x00 == asc) && (0x00 == ascq)) { DBG (5, "Unit attention: device reset\n"); return SANE_STATUS_GOOD; } if ((0x80 == asc) && (0x01 == ascq)) { DBG (5, "Unit attention: power saving\n"); return SANE_STATUS_GOOD; } DBG (5, "Unit attention: unknown asc/ascq\n"); return SANE_STATUS_IO_ERROR; break; case 0xb: if ((0x43 == asc) && (0x00 == ascq)) { DBG (5, "Aborted command: message error\n"); return SANE_STATUS_IO_ERROR; } if ((0x45 == asc) && (0x00 == ascq)) { DBG (5, "Aborted command: select failure\n"); return SANE_STATUS_IO_ERROR; } if ((0x47 == asc) && (0x00 == ascq)) { DBG (5, "Aborted command: SCSI parity error\n"); return SANE_STATUS_IO_ERROR; } if ((0x48 == asc) && (0x00 == ascq)) { DBG (5, "Aborted command: initiator error message\n"); return SANE_STATUS_IO_ERROR; } if ((0x4e == asc) && (0x00 == ascq)) { DBG (5, "Aborted command: overlapped commands\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x01 == ascq)) { DBG (5, "Aborted command: image transfer error\n"); return SANE_STATUS_IO_ERROR; } if ((0x80 == asc) && (0x03 == ascq)) { DBG (5, "Aborted command: JPEG overflow error\n"); return SANE_STATUS_NO_MEM; } DBG (5, "Aborted command: unknown asc/ascq\n"); return SANE_STATUS_IO_ERROR; break; default: DBG (5, "Unknown Sense Code\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "sense_handler: should never happen!\n"); return SANE_STATUS_IO_ERROR; } /* * take a bunch of pointers, send commands to scanner */ static SANE_Status do_cmd(struct fujitsu *s, int runRS, int shortTime, unsigned char * cmdBuff, size_t cmdLen, unsigned char * outBuff, size_t outLen, unsigned char * inBuff, size_t * inLen ) { /* unset the request sense vars first */ s->rs_info = 0; s->rs_ili = 0; s->rs_eom = 0; if (s->connection == CONNECTION_SCSI) { return do_scsi_cmd(s, runRS, shortTime, cmdBuff, cmdLen, outBuff, outLen, inBuff, inLen ); } if (s->connection == CONNECTION_USB) { return do_usb_cmd(s, runRS, shortTime, cmdBuff, cmdLen, outBuff, outLen, inBuff, inLen ); } return SANE_STATUS_INVAL; } SANE_Status do_scsi_cmd(struct fujitsu *s, int runRS, int shortTime, unsigned char * cmdBuff, size_t cmdLen, unsigned char * outBuff, size_t outLen, unsigned char * inBuff, size_t * inLen ) { int ret; /*shut up compiler*/ runRS=runRS; shortTime=shortTime; DBG(10, "do_scsi_cmd: start\n"); DBG(25, "cmd: writing %d bytes\n", (int)cmdLen); hexdump(30, "cmd: >>", cmdBuff, cmdLen); if(outBuff && outLen){ DBG(25, "out: writing %d bytes\n", (int)outLen); hexdump(30, "out: >>", outBuff, outLen); } if (inBuff && inLen){ DBG(25, "in: reading %d bytes\n", (int)*inLen); memset(inBuff,0,*inLen); } ret = sanei_scsi_cmd2(s->fd, cmdBuff, cmdLen, outBuff, outLen, inBuff, inLen); if(ret != SANE_STATUS_GOOD && ret != SANE_STATUS_EOF){ DBG(5,"do_scsi_cmd: return '%s'\n",sane_strstatus(ret)); return ret; } /* FIXME: should we look at s->rs_info here? */ if (inBuff && inLen){ hexdump(30, "in: <<", inBuff, *inLen); DBG(25, "in: read %d bytes\n", (int)*inLen); } DBG(10, "do_scsi_cmd: finish\n"); return ret; } SANE_Status do_usb_cmd(struct fujitsu *s, int runRS, int shortTime, unsigned char * cmdBuff, size_t cmdLen, unsigned char * outBuff, size_t outLen, unsigned char * inBuff, size_t * inLen ) { /*sanei_usb overwrites the transfer size, * so make some local copies */ size_t usb_cmdLen = USB_COMMAND_LEN; size_t usb_outLen = outLen; size_t usb_statLen = USB_STATUS_LEN; size_t askLen = 0; /*copy the callers buffs into larger, padded ones*/ unsigned char usb_cmdBuff[USB_COMMAND_LEN]; unsigned char usb_statBuff[USB_STATUS_LEN]; int cmdTime = USB_COMMAND_TIME; int outTime = USB_DATA_TIME; int inTime = USB_DATA_TIME; int statTime = USB_STATUS_TIME; int ret = 0; int ret2 = 0; DBG (10, "do_usb_cmd: start\n"); if(shortTime){ cmdTime = USB_COMMAND_TIME/60; outTime = USB_DATA_TIME/60; inTime = USB_DATA_TIME/60; statTime = USB_STATUS_TIME/60; } /* build a USB packet around the SCSI command */ memset(&usb_cmdBuff,0,USB_COMMAND_LEN); usb_cmdBuff[0] = USB_COMMAND_CODE; memcpy(&usb_cmdBuff[USB_COMMAND_OFFSET],cmdBuff,cmdLen); /* change timeout */ sanei_usb_set_timeout(cmdTime); /* write the command out */ DBG(25, "cmd: writing %d bytes, timeout %d\n", USB_COMMAND_LEN, cmdTime); hexdump(30, "cmd: >>", usb_cmdBuff, USB_COMMAND_LEN); ret = sanei_usb_write_bulk(s->fd, usb_cmdBuff, &usb_cmdLen); DBG(25, "cmd: wrote %d bytes, retVal %d\n", (int)usb_cmdLen, ret); if(ret == SANE_STATUS_EOF){ DBG(5,"cmd: got EOF, returning IO_ERROR\n"); return SANE_STATUS_IO_ERROR; } if(ret != SANE_STATUS_GOOD){ DBG(5,"cmd: return error '%s'\n",sane_strstatus(ret)); return ret; } if(usb_cmdLen != USB_COMMAND_LEN){ DBG(5,"cmd: wrong size %d/%d\n", USB_COMMAND_LEN, (int)usb_cmdLen); return SANE_STATUS_IO_ERROR; } /* this command has a write component, and a place to get it */ if(outBuff && outLen && outTime){ /* change timeout */ sanei_usb_set_timeout(outTime); DBG(25, "out: writing %d bytes, timeout %d\n", (int)outLen, outTime); hexdump(30, "out: >>", outBuff, outLen); ret = sanei_usb_write_bulk(s->fd, outBuff, &usb_outLen); DBG(25, "out: wrote %d bytes, retVal %d\n", (int)usb_outLen, ret); if(ret == SANE_STATUS_EOF){ DBG(5,"out: got EOF, returning IO_ERROR\n"); return SANE_STATUS_IO_ERROR; } if(ret != SANE_STATUS_GOOD){ DBG(5,"out: return error '%s'\n",sane_strstatus(ret)); return ret; } if(usb_outLen != outLen){ DBG(5,"out: wrong size %d/%d\n", (int)outLen, (int)usb_outLen); return SANE_STATUS_IO_ERROR; } } /* this command has a read component, and a place to put it */ if(inBuff && inLen && inTime){ askLen = *inLen; memset(inBuff,0,askLen); /* change timeout */ sanei_usb_set_timeout(inTime); DBG(25, "in: reading %lu bytes, timeout %d\n", (unsigned long)askLen, inTime); ret = sanei_usb_read_bulk(s->fd, inBuff, inLen); DBG(25, "in: retVal %d\n", ret); if(ret == SANE_STATUS_EOF){ DBG(5,"in: got EOF, continuing\n"); ret = SANE_STATUS_GOOD; } if(ret != SANE_STATUS_GOOD){ DBG(5,"in: return error '%s'\n",sane_strstatus(ret)); return ret; } DBG(25, "in: read %lu bytes\n", (unsigned long)*inLen); if(*inLen){ hexdump(31, "in: <<", inBuff, *inLen); } if(*inLen && *inLen != askLen){ ret = SANE_STATUS_EOF; DBG(5,"in: short read, %lu/%lu\n", (unsigned long)*inLen,(unsigned long)askLen); } } /*gather the scsi status byte. use ret2 instead of ret for status*/ memset(&usb_statBuff,0,USB_STATUS_LEN); /* change timeout */ sanei_usb_set_timeout(statTime); DBG(25, "stat: reading %d bytes, timeout %d\n", USB_STATUS_LEN, statTime); ret2 = sanei_usb_read_bulk(s->fd, usb_statBuff, &usb_statLen); hexdump(30, "stat: <<", usb_statBuff, usb_statLen); DBG(25, "stat: read %d bytes, retVal %d\n", (int)usb_statLen, ret2); if(ret2 == SANE_STATUS_EOF){ DBG(5,"stat: got EOF, returning IO_ERROR\n"); return SANE_STATUS_IO_ERROR; } if(ret2 != SANE_STATUS_GOOD){ DBG(5,"stat: return error '%s'\n",sane_strstatus(ret2)); return ret2; } if(usb_statLen != USB_STATUS_LEN){ DBG(5,"stat: wrong size %d/%d\n", USB_STATUS_LEN, (int)usb_statLen); return SANE_STATUS_IO_ERROR; } /* busy status */ if(usb_statBuff[USB_STATUS_OFFSET] == 8){ DBG(25,"stat: busy\n"); return SANE_STATUS_DEVICE_BUSY; } /* if there is a non-busy status >0, try to figure out why */ if(usb_statBuff[USB_STATUS_OFFSET] > 0){ DBG(25,"stat: value %d\n", usb_statBuff[USB_STATUS_OFFSET]); /* caller is interested in having RS run on errors */ if(runRS){ unsigned char rs_cmd[REQUEST_SENSE_len]; size_t rs_cmdLen = REQUEST_SENSE_len; unsigned char rs_in[RS_return_size]; size_t rs_inLen = RS_return_size; memset(rs_cmd,0,rs_cmdLen); set_SCSI_opcode(rs_cmd, REQUEST_SENSE_code); set_RS_return_size(rs_cmd, rs_inLen); DBG(25,"rs sub call >>\n"); ret2 = do_cmd( s,0,0, rs_cmd, rs_cmdLen, NULL,0, rs_in, &rs_inLen ); DBG(25,"rs sub call <<\n"); if(ret2 == SANE_STATUS_EOF){ DBG(5,"rs: got EOF, returning IO_ERROR\n"); return SANE_STATUS_IO_ERROR; } if(ret2 != SANE_STATUS_GOOD){ DBG(5,"rs: return error '%s'\n",sane_strstatus(ret2)); return ret2; } /* parse the rs data */ ret2 = sense_handler( 0, rs_in, (void *)s ); /* this was a short read, but the usb layer did not know */ if(s->rs_ili && inBuff && inLen && inTime){ *inLen = askLen - s->rs_info; DBG(5,"do_usb_cmd: short read via rs, %lu/%lu\n", (unsigned long)*inLen,(unsigned long)askLen); } return ret2; } else{ DBG(5,"do_usb_cmd: Not calling rs!\n"); return SANE_STATUS_IO_ERROR; } } DBG (10, "do_usb_cmd: finish\n"); return ret; } static SANE_Status wait_scanner(struct fujitsu *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[TEST_UNIT_READY_len]; size_t cmdLen = TEST_UNIT_READY_len; DBG (10, "wait_scanner: start\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,TEST_UNIT_READY_code); ret = do_cmd ( s, 0, 1, cmd, cmdLen, NULL, 0, NULL, NULL ); if (ret != SANE_STATUS_GOOD) { DBG(5,"WARNING: Brain-dead scanner. Hitting with stick\n"); ret = do_cmd ( s, 0, 1, cmd, cmdLen, NULL, 0, NULL, NULL ); } if (ret != SANE_STATUS_GOOD) { DBG(5,"WARNING: Brain-dead scanner. Hitting with stick again\n"); ret = do_cmd ( s, 0, 1, cmd, cmdLen, NULL, 0, NULL, NULL ); } if (ret != SANE_STATUS_GOOD) { DBG (5, "wait_scanner: error '%s'\n", sane_strstatus (ret)); } DBG (10, "wait_scanner: finish\n"); return ret; } /* 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 fujitsu *s) { if(s->hwdeskewcrop){ return 1; } if( (s->swdeskew || s->swdespeck || s->swcrop || s->swskip) && s->s_params.format != SANE_FRAME_JPEG ){ return 1; } return 0; } /* certain scanners require the mode of the * image to be changed in software. */ static int must_downsample(struct fujitsu *s) { if(s->s_mode != s->u_mode && s->compress != COMP_JPEG ){ return 1; } return 0; } /* s->page_width stores the user setting * for the paper width in adf. sometimes, * we need a value that differs from this * due to using FB or overscan. */ static int get_page_width(struct fujitsu *s) { int width = s->page_width + 2 * (s->os_x_basic*1200/s->basic_x_res); /* scanner max for fb */ if(s->source == SOURCE_FLATBED){ return s->max_x_fb; } /* current paper size for adf not overscan */ if(s->overscan != MSEL_ON){ return s->page_width; } /* cant overscan larger than scanner max */ if(width > s->max_x){ return s->max_x; } /* overscan adds a margin to both sides */ return width; } /* s->page_height stores the user setting * for the paper height in adf. sometimes, * we need a value that differs from this * due to using FB or overscan. */ static int get_page_height(struct fujitsu *s) { int height = s->page_height + 2 * (s->os_y_basic*1200/s->basic_y_res); /* scanner max for fb */ if(s->source == SOURCE_FLATBED){ return s->max_y_fb; } /* current paper size for adf not overscan */ if(s->overscan != MSEL_ON){ return s->page_height; } /* cant overscan larger than scanner max */ if(height > s->max_y){ return s->max_y; } /* overscan adds a margin to both sides */ 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 set_max_y(struct fujitsu *s) { int i; for(i=0;i<4;i++){ if(!s->max_y_by_res[i].res) break; if(s->resolution_x <= s->max_y_by_res[i].res){ s->max_y = s->max_y_by_res[i].len; } } return s->max_y; } /** * Convenience method to determine longest string size in a list. */ static size_t maxStringSize (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } /* * Prints a hex dump of the given buffer onto the debug output stream. */ static void hexdump (int level, char *comment, unsigned char *p, int l) { int i; char line[70]; /* 'xxx: xx xx ... xx xx abc */ char *hex = line+4; char *bin = line+53; if(DBG_LEVEL < level) return; DBG (level, "%s\n", comment); for (i = 0; i < l; i++, p++) { /* at start of line */ if ((i % 16) == 0) { /* not at start of first line, print current, reset */ if (i) { DBG (level, "%s\n", line); } memset(line,0x20,69); line[69] = 0; hex = line + 4; bin = line + 53; sprintf (line, "%3.3x:", i); } /* the hex section */ sprintf (hex, " %2.2x", *p); hex += 3; *hex = ' '; /* the char section */ if(*p >= 0x20 && *p <= 0x7e){ *bin=*p; } else{ *bin='.'; } bin++; } /* print last (partial) line */ if (i) DBG (level, "%s\n", line); } /** * An advanced method we don't support but have to define. */ SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking) { DBG (10, "sane_set_io_mode\n"); DBG (15, "%d %p\n", non_blocking, h); return SANE_STATUS_UNSUPPORTED; } /** * An advanced method we don't support but have to define. */ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int *fdp) { DBG (10, "sane_get_select_fd\n"); DBG (15, "%p %d\n", h, *fdp); return SANE_STATUS_UNSUPPORTED; } /* * @@ Section 7 - Image processing functions */ /* Look in image for likely upper and left paper edges, then rotate * image so that upper left corner of paper is upper left of image. * FIXME: should we do this before we binarize instead of after? */ static SANE_Status buffer_deskew(struct fujitsu *s, int side) { SANE_Status ret = SANE_STATUS_GOOD; int bg_color = 0xd6; DBG (10, "buffer_deskew: start\n"); /*only find skew on first image from a page, or if first image had error */ if(s->side == SIDE_FRONT || s->source == SOURCE_ADF_BACK || s->deskew_stat){ s->deskew_stat = sanei_magic_findSkew( &s->s_params,s->buffers[side],s->resolution_x,s->resolution_y, &s->deskew_vals[0],&s->deskew_vals[1],&s->deskew_slope); if(s->deskew_stat){ DBG (5, "buffer_deskew: bad findSkew, bailing\n"); 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]; } /* tweak the bg color based on scanner settings */ if(s->s_mode == MODE_HALFTONE || s->s_mode == MODE_LINEART){ if(s->bg_color == COLOR_BLACK || s->hwdeskewcrop || s->overscan) bg_color = 0xff; else bg_color = 0; } else if(s->bg_color == COLOR_BLACK || s->hwdeskewcrop || s->overscan) bg_color = 0; ret = sanei_magic_rotate(&s->s_params,s->buffers[side], s->deskew_vals[0],s->deskew_vals[1],s->deskew_slope,bg_color); if(ret){ DBG(5,"buffer_deskew: rotate error: %d",ret); ret = SANE_STATUS_GOOD; goto cleanup; } cleanup: DBG (10, "buffer_deskew: finish\n"); return ret; } /* Look in image for likely left/right/bottom paper edges, then crop image. * Does not attempt to rotate the image, that should be done first. * FIXME: should we do this before we binarize instead of after? */ static SANE_Status buffer_crop(struct fujitsu *s, int side) { SANE_Status ret = SANE_STATUS_GOOD; DBG (10, "buffer_crop: start\n"); ret = sanei_magic_findEdges( &s->s_params,s->buffers[side],s->resolution_x,s->resolution_y, &s->crop_vals[0],&s->crop_vals[1],&s->crop_vals[2],&s->crop_vals[3]); if(ret){ DBG (5, "buffer_crop: bad edges, bailing\n"); ret = SANE_STATUS_GOOD; goto cleanup; } 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]); /* 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; } /* now crop the image */ 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]); if(ret){ DBG (5, "buffer_crop: bad crop, bailing\n"); ret = SANE_STATUS_GOOD; goto cleanup; } /* need to update user with new size */ update_u_params(s); /* update image size counter to new, smaller size */ s->bytes_rx[side] = s->s_params.lines * s->s_params.bytes_per_line; s->buff_rx[side] = s->bytes_rx[side]; cleanup: DBG (10, "buffer_crop: finish\n"); return ret; } /* Look in image for disconnected 'spots' of the requested size. * Replace the spots with the average color of the surrounding pixels. * FIXME: should we do this before we binarize instead of after? */ static SANE_Status buffer_despeck(struct fujitsu *s, int side) { SANE_Status ret = SANE_STATUS_GOOD; DBG (10, "buffer_despeck: start\n"); 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; } cleanup: DBG (10, "buffer_despeck: finish\n"); return ret; } /* Look if image has too few dark pixels.*/ static int buffer_isblank(struct fujitsu *s, int side) { SANE_Status ret = SANE_STATUS_GOOD; int status = 0; DBG (10, "buffer_isblank: start\n"); ret = sanei_magic_isBlank2(&s->s_params, s->buffers[side], s->resolution_x, s->resolution_y, s->swskip); if(ret == SANE_STATUS_NO_DOCS){ DBG (5, "buffer_isblank: blank!\n"); status = 1; } else if(ret){ DBG (5, "buffer_isblank: error %d\n",ret); } DBG (10, "buffer_isblank: finished\n"); return status; } sane-backends-1.0.29/backend/umax_pp_mid.h0000666000000000000000000001245713615534521015254 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001-2012 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Umax PP flatbed scanners. */ #ifdef HAVE_LINUX_PPDEV_H #include #include #include #endif #include "umax_pp_low.h" #ifndef _UMAX1220P_ #define _UMAX1220P_ #define UMAX1220P_OK 0 #define UMAX1220P_NOSCANNER 1 #define UMAX1220P_TRANSPORT_FAILED 2 #define UMAX1220P_PROBE_FAILED 3 #define UMAX1220P_SCANNER_FAILED 4 #define UMAX1220P_PARK_FAILED 5 #define UMAX1220P_START_FAILED 6 #define UMAX1220P_READ_FAILED 7 #define UMAX1220P_BUSY 8 /* probes the port for an umax1220p scanner initialize transport layer probe scanner if name is null, direct I/O is attempted to address given in port else ppdev is tried using the given name as device on success returns UMAX1220P_OK, else one of the error above. */ extern int sanei_umax_pp_attach (int port, const char *name); /* recognizes 1220P from 2000P on success returns UMAX1220P_OK, else one of the error above. */ extern int sanei_umax_pp_model (int port, int *model); /* if on=1 -> lights scanner lamp if on=0 -> lights off scanner lamp on success returns UMAX1220P_OK, else one of the error above. */ extern int sanei_umax_pp_lamp (int on); /* probes the port for an umax1220p scanner initialize transport layer initialize scanner on succes returns UMAX1220P_OK, else one of the error above. port: addr when doing direc I/O name: ppdev character device name */ extern int sanei_umax_pp_open (int port, char *name); /* release any ressource acquired during open since there may be only one scanner, no port parameter */ extern int sanei_umax_pp_close (void); /* stops any pending action, then parks the head */ extern int sanei_umax_pp_cancel (void); /* starts scanning: - find scanner origin - does channel gain calibration if needed - does calibration - initialize scan operation x, y, width and height are expressed in 600 dpi unit dpi must be 75, 150, 300, 600 or 1200 color is true for color scan, false for gray-levels gain value is 256*red_gain+16*green_gain+blue_gain if gain is given (ie <> 0), auto gain will not be performed returns UMAX1220P_OK on success, or one of the error above if successful, rbpp holds bytes/pixel, rth the height and rtw the width of scanned area expressed in pixels */ extern int sanei_umax_pp_start (int x, int y, int width, int height, int dpi, int color, int autoset, int gain, int offset, int *rbpp, int *rtw, int *rth); /* reads one block of data from scanner returns UMAX1220P_OK on success, or UMAX1220P_READ_FAILED on error it also sets internal cancel flag on error len if the length of the block needed window if the width in pixels of the scanned area dpi is the resolution, it is used to choose the best read method last is true if it is the last block of the scan buffer will hold the data read */ extern int sanei_umax_pp_read (long len, int window, int dpi, int last, unsigned char *buffer); /* get ASIC status from scanner returns UMAX1220P_OK if scanner idle, or UMAX1220P_BUSY if scanner's motor is on */ extern int sanei_umax_pp_status (void); /* set auto calibration 0: no, else yes */ extern void sanei_umax_pp_setauto (int mode); /* set umax astra model number */ extern void sanei_umax_pp_setastra (int val); /* set gamma tables */ extern void sanei_umax_pp_gamma (int *red, int *green, int *blue); /* sets coordinate of first usable left pixel */ extern int sanei_umax_pp_getLeft (void); #endif sane-backends-1.0.29/backend/rts8891.h0000666000000000000000000001077713615534521014117 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2007-2012 stef.dev@free.fr 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef RTS8891_H #define RTS8891_H #define ENABLE(OPTION) s->opt[OPTION].cap &= ~SANE_CAP_INACTIVE #define DISABLE(OPTION) s->opt[OPTION].cap |= SANE_CAP_INACTIVE #define IS_ACTIVE(OPTION) (((s->opt[OPTION].cap) & SANE_CAP_INACTIVE) == 0) #define RTS8891_CONFIG_FILE "rts8891.conf" #ifndef SANE_I18N #define SANE_I18N(text) text #endif /* */ #define COLOR_MODE SANE_VALUE_SCAN_MODE_COLOR #define GRAY_MODE SANE_VALUE_SCAN_MODE_GRAY #define LINEART_MODE SANE_VALUE_SCAN_MODE_LINEART /* preferred number of bytes to keep in buffer */ #define PREFERED_BUFFER_SIZE 2097152 /* all scanner memory */ /** List of SANE options */ enum Rts8891_Option { OPT_NUM_OPTS = 0, OPT_STANDARD_GROUP, OPT_MODE, OPT_PREVIEW, OPT_RESOLUTION, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ /* advanced image enhancement options */ OPT_ENHANCEMENT_GROUP, OPT_THRESHOLD, OPT_CUSTOM_GAMMA, /* toggle to enable custom gamma tables */ OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, /* advanced options */ OPT_ADVANCED_GROUP, OPT_LAMP_ON, OPT_LAMP_OFF, /* button group */ OPT_SENSOR_GROUP, OPT_BUTTON_1, OPT_BUTTON_2, OPT_BUTTON_3, OPT_BUTTON_4, OPT_BUTTON_5, OPT_BUTTON_6, OPT_BUTTON_7, OPT_BUTTON_8, OPT_BUTTON_9, OPT_BUTTON_10, OPT_BUTTON_11, /* must come last: */ NUM_OPTIONS }; /** * enumeration of configuration options */ enum Rts8891_Configure_Option { CFG_MODEL_NUMBER = 0, /* first option number must be zero */ CFG_SENSOR_NUMBER, CFG_ALLOW_SHARING, NUM_CFG_OPTIONS /* MUST be last */ }; /** Scanner object. This struct holds informations usefull for * the functions defined in SANE's standard. Informations closer * to the hardware are in the Rts8891_Device structure. There is * as many session structure than frontends using the scanner. */ typedef struct Rts8891_Session { /**< Next handle in linked list */ struct Rts8891_Session *next; /**< Low-level device object */ struct Rts8891_Device *dev; /* SANE data */ /**< We are currently scanning */ SANE_Bool scanning; /**< Data read is in non blocking mode */ SANE_Bool non_blocking; /**< Gray scans are emulated */ SANE_Bool emulated_gray; SANE_Option_Descriptor opt[NUM_OPTIONS]; /**< Option descriptors */ Option_Value val[NUM_OPTIONS]; /**< Option values */ SANE_Parameters params; /**< SANE Parameters */ /**< bytes to send to frontend for the scan */ SANE_Int to_send; /**< bytes currently sent to frontend during the scan */ SANE_Int sent; } Rts8891_Session; #endif /* not RTS8891_H */ sane-backends-1.0.29/backend/plustek-pp_tpa.c0000666000000000000000000011402213615534521015704 00000000000000/* @file plustek-pp_tpa.c * @brief Here we find some adjustments according to the scan source. * This file is ASIC P9800x specific * * based on sources acquired from Plustek Inc. * Copyright (C) 1998 Plustek Inc. * Copyright (C) 2000-2013 Gerhard Jaeger * also based on the work done by Rick Bronson * * History: * - 0.30 - initial version * - 0.31 - Added some comments * - 0.32 - no changes * - 0.33 - new header * - 0.34 - no changes * - 0.35 - no changes * - 0.36 - no changes * - 0.37 - cosmetic changes * - 0.38 - Replaced AllPointer by DataPointer * - renamed this file from transform.c tpa.c * - 0.39 - no changes * - 0.40 - no changes * - 0.41 - no changes * - 0.42 - changed include names * - 0.43 - no changes * - 0.44 - fix format string issues, as Long types default to int32_t * now * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #include "plustek-pp_scan.h" /***************************** local vars ************************************/ static UShort a_wGainString [] = { 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475, 500, 525, 550, 575, 600, 625, 650, 675, 700, 725, 750, 775, 800, 825 }; /*************************** local functions *********************************/ /*............................................................................. * */ static void tpaP98SubNoise( pScanData ps, pULong pdwSum, pUShort pwShading, ULong dwHilightOff, ULong dwShadowOff ) { ULong dwPixels, dwLines, dwSum; pUShort pw; for (dwPixels = 4; dwPixels--; pdwSum++, pwShading++) *pwShading = (UShort)(*pdwSum >> 5); for (dwPixels = 0; dwPixels < (ps->dwShadingPixels - 4); dwPixels++, pdwSum++, pwShading++) { pw = (pUShort)ps->Shade.pHilight + dwHilightOff + dwPixels; dwSum = 0; for (dwLines = _DEF_BRIGHTEST_SKIP; dwLines--; pw += 5400UL) dwSum += (ULong) *pw; pw = ps->pwShadow + dwShadowOff + dwPixels; for (dwLines = _DEF_DARKEST_SKIP; dwLines--; pw += 5400UL) dwSum += (ULong) *pw; *pwShading = (UShort)((*pdwSum - dwSum) / ps->Shade.dwDiv); } if (ps->dwShadingPixels != 5400UL) { for (dwPixels = 2700UL; dwPixels--; pdwSum++, pwShading++) *pwShading = (UShort)(*pdwSum >> 5); } } /*............................................................................. * */ static void tpaP98ShadingWaveformSum( pScanData ps ) { DataPointer pd, pt; ULong dw; pd.pdw = (pULong)ps->pScanBuffer1; pt.pw = (pUShort)ps->pScanBuffer1; if ((ps->DataInf.dwScanFlag & SCANDEF_TPA ) || (0 == ps->bShadingTimeFlag)) { if( ps->Shade.pHilight ) { tpaP98SubNoise( ps, (pULong)ps->pScanBuffer1, (pUShort)ps->pScanBuffer1, 0, 0); tpaP98SubNoise( ps ,(pULong)ps->pScanBuffer1 + 5400UL, (pUShort)ps->pScanBuffer1 + 5400UL, ps->dwHilightCh, ps->dwShadowCh); tpaP98SubNoise( ps, (pULong)ps->pScanBuffer1 + 5400UL * 2UL, (pUShort)ps->pScanBuffer1 + 5400UL * 2UL, ps->dwHilightCh * 2, ps->dwShadowCh * 2); } else { for (dw = 5400 * 3; dw; dw--, pt.pw++, pd.pdw++) *pt.pw = (UShort)(*pd.pdw / 32); /* shift 5 bits */ } } else { if (02 == ps->bShadingTimeFlag ) { for (dw = 5400 * 3; dw; dw--, pt.pw++, pd.pdw++) *pt.pw = (UShort)(*pd.pdw / 16); /* shift 4 bits */ } else { for (dw = 5400 * 3; dw; dw--, pt.pw++, pd.pdw++) *pt.pw = (UShort)(*pd.pdw / 4); /* shift 2 bits */ } } } /*............................................................................. * get wReduceRedFactor, wReduceGreenFactor, wReduceBlueFactor */ static void tpaP98GetNegativeTempRamData( pScanData ps ) { UShort wRedTemp, wGreenTemp, wBlueTemp; UShort wRedShadingTemp, wGreenShadingTemp, wBlueShadingTemp; ULong dw, dw1; DataPointer p; pULong pdwNegativeSumTemp; pUShort pNegativeTempRam, pNegativeTempRam2; ps->bFastMoveFlag = _FastMove_Low_C75_G150; MotorP98GoFullStep( ps ,80 ); pNegativeTempRam = (pUShort)(ps->pScanBuffer1 + 5400 * 6); pdwNegativeSumTemp = (pULong)(pNegativeTempRam + 960 * 3 * 2); pNegativeTempRam2 = (pUShort)(pdwNegativeSumTemp + 960 * 3 * 4); /* ClearNegativeSumBuffer() */ memset( pdwNegativeSumTemp, 0, (960 * 3 * 4)); /* SetReadNegativeTempRegister() */ ps->AsicReg.RD_Motor0Control = 0; IOCmdRegisterToScanner( ps, ps->RegMotor0Control, ps->AsicReg.RD_Motor0Control ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_Motor0Control = _MotorOn + _MotorHEightStep + _MotorDirForward; ps->AsicReg.RD_ModelControl = _ModelDpi600 + _LED_CONTROL + _LED_ACTIVITY; ps->AsicReg.RD_Dpi = ps->PhysicalDpi; if (!ps->wNegAdjustX) { ps->AsicReg.RD_Origin = (UShort)(ps->dwOffset70 + ps->Device.DataOriginX + _Negative96OriginOffsetX * 2); } else { ps->AsicReg.RD_Origin = (UShort)(ps->dwOffset70 + ps->Device.DataOriginX + ps->wNegAdjustX); } ps->AsicReg.RD_Pixels = 960; ps->AsicReg.RD_XStepTime = 32; IOPutOnAllRegisters( ps ); /* NegativeMotorRunLoop() */ p.pb = ps->a_nbNewAdrPointer; for (dw = _NUMBER_OF_SCANSTEPS / 8; dw; dw--, p.pdw++) *p.pdw = 0x87808780; IOSetToMotorRegister( ps ); for (dw1 = 16; dw1; dw1--) { TimerDef timer; MiscStartTimer( &timer, _SECOND ); while((IOReadFifoLength( ps ) < 960) && !MiscCheckTimer( &timer )) { _DO_UDELAY(1); } /* ReadColorDataIn() - Read 1 RGB line */ ps->AsicReg.RD_ModeControl = _ModeFifoRSel; IOReadScannerImageData( ps, (pUChar)pNegativeTempRam, 960 ); ps->AsicReg.RD_ModeControl = _ModeFifoGSel; IOReadScannerImageData( ps, (pUChar)(pNegativeTempRam + 960), 960 ); ps->AsicReg.RD_ModeControl = _ModeFifoBSel; IOReadScannerImageData( ps, (pUChar)(pNegativeTempRam + 960 * 2), 960 ); /* fillNegativeSum() */ for (dw = 0; dw < 960 * 3; dw++) pdwNegativeSumTemp[dw] += ((pUShort) pNegativeTempRam)[dw]; /* one line */ if (IOReadFifoLength( ps ) <= (960 * 2)) IORegisterDirectToScanner( ps, ps->RegRefreshScanState ); } /* AverageAndShift() */ for( dw = 0, dw1 = 0; dw < 240 * 3; dw++, dw1+=4 ) { pNegativeTempRam[dw] = (UShort)((pdwNegativeSumTemp[dw1] + pdwNegativeSumTemp[dw1+1] + pdwNegativeSumTemp[dw1+2] + pdwNegativeSumTemp[dw1+3]) / 128); /* shift 6 bits */ } /* NegativeAdd1() */ if (!ps->wNegAdjustX) { dw1 = (ps->dwOffsetNegative + _Negative96OriginOffsetX * 2 * 2) / 2; } else { dw1 = (ps->dwOffsetNegative + ps->wNegAdjustX * 2) / 2; } /* do R shading average */ for (dw = 0; dw < 240; dw++, dw1 += 4) { pNegativeTempRam2[dw] = (UShort)( (((pUShort)ps->pScanBuffer1)[dw1] + ((pUShort)ps->pScanBuffer1)[dw1+1] + ((pUShort)ps->pScanBuffer1)[dw1+2] + ((pUShort)ps->pScanBuffer1)[dw1+3]) / 4); } /* NegativeAdd1() */ if (!ps->wNegAdjustX) dw1 = (ps->dwOffsetNegative + 5400 * 2 + _Negative96OriginOffsetX * 2 * 2) / 2; else dw1 = (ps->dwOffsetNegative + 5400 * 2 + ps->wNegAdjustX * 2) / 2; /* do G shading average */ for (; dw < 240 * 2; dw++, dw1 += 4) { pNegativeTempRam2[dw] = (UShort)( (((pUShort)ps->pScanBuffer1)[dw1] + ((pUShort)ps->pScanBuffer1)[dw1+1] + ((pUShort)ps->pScanBuffer1)[dw1+2] + ((pUShort)ps->pScanBuffer1)[dw1+3]) / 4); } /* NegativeAdd1() */ if (!ps->wNegAdjustX) dw1 = (ps->dwOffsetNegative + 5400 * 4 + _Negative96OriginOffsetX * 2 * 2) / 2; else dw1 = (ps->dwOffsetNegative + 5400 * 4 + ps->wNegAdjustX * 2) / 2; /* do B shading average */ for (; dw < 240 * 3; dw++, dw1 += 4) { pNegativeTempRam2 [dw] = (UShort)( (((pUShort)ps->pScanBuffer1)[dw1] + ((pUShort)ps->pScanBuffer1)[dw1+1] + ((pUShort)ps->pScanBuffer1)[dw1+2] + ((pUShort)ps->pScanBuffer1)[dw1+3]) / 4); } wRedTemp = wGreenTemp = wBlueTemp = 0; wRedShadingTemp = wGreenShadingTemp = wBlueShadingTemp = 0; /* FindMaxNegValue -- find R */ for (dw = 0; dw < 240; dw++) { if (pNegativeTempRam[dw] >= wRedTemp && pNegativeTempRam[dw + 240] >= wGreenTemp && pNegativeTempRam[dw + 480] > wBlueTemp) { wRedTemp = pNegativeTempRam[dw]; wGreenTemp = pNegativeTempRam[dw + 240]; wBlueTemp = pNegativeTempRam[dw + 480]; wRedShadingTemp = pNegativeTempRam2[dw]; wGreenShadingTemp = pNegativeTempRam2[dw + 240]; wBlueShadingTemp = pNegativeTempRam2[dw + 480]; } } /* GainAddX = (1/4)*DoubleX + 1/ 2 */ if ((ps->bRedGainIndex += (Byte)((wRedShadingTemp / wRedTemp) * 100 - 50) / 25) > 32) ps->bRedGainIndex = 31; if ((ps->bGreenGainIndex += (Byte)((wGreenShadingTemp / wGreenTemp) * 100 - 50) / 25) > 32) ps->bGreenGainIndex = 31; if ((ps->bBlueGainIndex += (Byte)((wBlueShadingTemp / wBlueTemp) * 100 - 50) / 25) > 32) ps->bBlueGainIndex = 31; } /*............................................................................. * */ static void tpaP98RecalculateNegativeShadingGain( pScanData ps ) { Byte b[3]; UShort wSum, counter; UShort w, w1, w2; ULong dw, dw1; pUChar pDest, pSrce, pNegativeTempRam; pUChar pbReg[3]; TimerDef timer; DataPointer p; pNegativeTempRam = (pUChar)(ps->pScanBuffer1 + 5400 * 6); /* AdjustDarkCondition () */ ps->Shade.pCcdDac->DarkDAC.Colors.Red = ps->bsPreRedDAC; ps->Shade.pCcdDac->DarkDAC.Colors.Green = ps->bsPreGreenDAC; ps->Shade.pCcdDac->DarkDAC.Colors.Blue = ps->bsPreBlueDAC; ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = ps->wsDACCompareHighRed; ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = ps->wsDACCompareLowRed; ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = ps->wsDACCompareHighGreen; ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = ps->wsDACCompareLowGreen; ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = ps->wsDACCompareHighBlue; ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = ps->wsDACCompareLowBlue; DacP98FillGainOutDirectPort( ps ); /* ClearNegativeTempBuffer () */ memset( pNegativeTempRam, 0, (960 * 3 * 4)); /* GetNegGainValue () */ ps->PauseColorMotorRunStates( ps ); /* SetScanMode () set scan mode to Byte mode */ ps->AsicReg.RD_ScanControl |= _SCAN_BYTEMODE; ps->AsicReg.RD_ScanControl &= 0xfd; IOCmdRegisterToScanner(ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl); DacP98FillGainOutDirectPort( ps ); /* SetReadNegativeTempRegister() */ ps->AsicReg.RD_Motor0Control = 0; IOCmdRegisterToScanner( ps, ps->RegMotor0Control, ps->AsicReg.RD_Motor0Control ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_Motor0Control = _MotorOn + _MotorHEightStep + _MotorDirForward; ps->AsicReg.RD_ModelControl = _ModelDpi600 + _LED_CONTROL + _LED_ACTIVITY; ps->AsicReg.RD_Dpi = ps->PhysicalDpi; if (!ps->wNegAdjustX) { ps->AsicReg.RD_Origin = (UShort)(ps->dwOffset70 + ps->Device.DataOriginX + _Negative96OriginOffsetX * 2); } else { ps->AsicReg.RD_Origin = (UShort)(ps->dwOffset70 + ps->Device.DataOriginX + ps->wNegAdjustX); } ps->AsicReg.RD_Pixels = 960; ps->AsicReg.RD_XStepTime = 32; IOPutOnAllRegisters( ps ); /* ReReadNegativeTemp */ MiscStartTimer( &timer, _SECOND ); while((IOReadFifoLength( ps) < 960) && !MiscCheckTimer( &timer )) { _DO_UDELAY(1); /* 1 us delay */ } /* ReadColorDataIn() - Read 1 RGB line */ ps->AsicReg.RD_ModeControl = _ModeFifoRSel; IOReadScannerImageData( ps, pNegativeTempRam, 960); ps->AsicReg.RD_ModeControl = _ModeFifoGSel; IOReadScannerImageData( ps, pNegativeTempRam + 960, 960); ps->AsicReg.RD_ModeControl = _ModeFifoBSel; IOReadScannerImageData( ps, pNegativeTempRam + 960 * 2, 960); /* FindRGBGainValue(); */ pDest = pSrce = pNegativeTempRam; /* ReAdjustGainAverage() */ for (dw1 = 0; dw1 < (960 * 3) / 16; dw1++, pDest++) { for (dw = 0, wSum = 0; dw < 16; dw++, pSrce++) wSum += *pSrce; *pDest = wSum / 16; } /* FindTheMaxGainValue */ for (w = 0, p.pb = pNegativeTempRam; w < 3; w++) { for (dw = 960 / 16, b[w] = 0; dw; dw--, p.pb++) { if (b[w] < *p.pb) b[w] = *p.pb; } } ps->bRedHigh = b[0]; ps->bGreenHigh = b[1]; ps->bBlueHigh = b[2]; /* ModifyExposureTime () */ if ((ps->bRedHigh < _GAIN_LOW) || (ps->bGreenHigh < _GAIN_LOW) || (ps->bBlueHigh < _GAIN_LOW)) { ps->AsicReg.RD_LineControl = 192; } IOCmdRegisterToScanner( ps, ps->RegLineControl, ps->AsicReg.RD_LineControl ); counter = 0; /* ReAdjustRGBGain () */ for (w1 = 0; w1 < 16; w1++) { ps->PauseColorMotorRunStates( ps ); DacP98FillGainOutDirectPort( ps ); /* SetReadNegativeTempRegister () */ ps->AsicReg.RD_Motor0Control = 0; IOCmdRegisterToScanner( ps, ps->RegMotor0Control, ps->AsicReg.RD_Motor0Control ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_Motor0Control = _MotorOn + _MotorHEightStep + _MotorDirForward; ps->AsicReg.RD_ModelControl = _ModelDpi600 + _LED_CONTROL + _LED_ACTIVITY; ps->AsicReg.RD_Dpi = ps->PhysicalDpi; if (!ps->wNegAdjustX) { ps->AsicReg.RD_Origin = (UShort)(ps->dwOffset70 + ps->Device.DataOriginX + _Negative96OriginOffsetX * 2); } else { ps->AsicReg.RD_Origin = (UShort)(ps->dwOffset70 + ps->Device.DataOriginX + ps->wNegAdjustX); } ps->AsicReg.RD_Pixels = 960; ps->AsicReg.RD_XStepTime = 32; IOPutOnAllRegisters( ps ); /* ReReadNegativeTemp () */ MiscStartTimer( &timer, _SECOND ); while((IOReadFifoLength( ps ) < 960) && !MiscCheckTimer( &timer)) { _DO_UDELAY(1); } /* ReadColorDataIn() - Read 1 RGB line */ ps->AsicReg.RD_ModeControl = _ModeFifoRSel; IOReadScannerImageData( ps, pNegativeTempRam, 960 ); ps->AsicReg.RD_ModeControl = _ModeFifoGSel; IOReadScannerImageData( ps, pNegativeTempRam + 960, 960); ps->AsicReg.RD_ModeControl = _ModeFifoBSel; IOReadScannerImageData( ps ,pNegativeTempRam + 960 * 2, 960); /* ReAdjustGainAverage() */ pDest = pSrce = pNegativeTempRam; for( dw1 = 0; dw1 < (960 * 3) / 16; dw1++, pDest++ ) { for( dw = 0, wSum = 0; dw < 16; dw++, pSrce++ ) wSum += *pSrce; *pDest = wSum / 16; } /* FindTheMaxGainValue */ pbReg[0] = &ps->bRedGainIndex; pbReg[1] = &ps->bGreenGainIndex; pbReg[2] = &ps->bBlueGainIndex; for (w = 0, p.pb = pNegativeTempRam; w < 3; w++) { for (dw = 960 / 16, b [w] = 0; dw; dw--, p.pb++) { if (b[w] < *p.pb) b[w] = *p.pb; } if (b [w] < _GAIN_LOW) { if (( _GAIN_P98_HIGH - b [w]) < b [w]) *(pbReg [w]) += 1; else *(pbReg [w]) += 4; } else { if (b [w] > _GAIN_P98_HIGH) *(pbReg [w]) -= 1; } } for (w2 = 0; w2 < 3; w2++) { if (*(pbReg[w2]) > 31) (*(pbReg[w2])) = 31; } if ((b[0] == 0) || (b[1] == 0) || (b[2] == 0)) { counter++; if (counter < 16) { w1--; ps->bRedGainIndex -= 4; ps->bGreenGainIndex -= 4; ps->bBlueGainIndex -= 4; } } } DacP98FillGainOutDirectPort( ps ); ps->Shade.DarkOffset.Colors.Red = 0; ps->Shade.DarkOffset.Colors.Green = 0; ps->Shade.DarkOffset.Colors.Blue = 0; ps->OpenScanPath( ps ); DacP98FillShadingDarkToShadingRegister( ps ); ps->CloseScanPath( ps ); DacP98AdjustDark( ps ); } /*............................................................................. * */ static void tpaP98RecalculateShadingGainandData( pScanData ps ) { DataPointer p; ULong dw; UShort filmAdjustX; UShort wOldRedGain, wOldGreenGain, wOldBlueGain; UShort wNewRedGain, wNewGreenGain, wNewBlueGain; /* AdjustDarkCondition () */ ps->Shade.pCcdDac->DarkDAC.Colors.Red = ps->bsPreRedDAC; ps->Shade.pCcdDac->DarkDAC.Colors.Green = ps->bsPreGreenDAC; ps->Shade.pCcdDac->DarkDAC.Colors.Blue = ps->bsPreBlueDAC; ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = ps->wsDACCompareHighRed; ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = ps->wsDACCompareLowRed; ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = ps->wsDACCompareHighGreen; ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = ps->wsDACCompareLowGreen; ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = ps->wsDACCompareHighBlue; ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = ps->wsDACCompareLowBlue; wOldRedGain = a_wGainString[ps->bRedGainIndex] * 100/ps->wReduceRedFactor; /* SearchNewGain() */ for (ps->bRedGainIndex = 0; ps->bRedGainIndex < 32; ps->bRedGainIndex++) { if (wOldRedGain < a_wGainString[ps->bRedGainIndex]) break; } if (0 == ps->bRedGainIndex) ps->bRedGainIndex ++; wNewRedGain = a_wGainString[--ps->bRedGainIndex]; wOldGreenGain = a_wGainString[ps->bGreenGainIndex]*100/ ps->wReduceGreenFactor; /* SearchNewGain() */ for (ps->bGreenGainIndex = 0; ps->bGreenGainIndex < 32; ps->bGreenGainIndex++) { if (wOldGreenGain < a_wGainString[ps->bGreenGainIndex]) break; } if (0 == ps->bGreenGainIndex) ps->bGreenGainIndex ++; wNewGreenGain = a_wGainString[--ps->bGreenGainIndex]; wOldBlueGain = a_wGainString[ps->bBlueGainIndex]*100/ps->wReduceBlueFactor; /* SearchNewGain() */ for (ps->bBlueGainIndex = 0;ps->bBlueGainIndex < 32;ps->bBlueGainIndex++) { if (wOldBlueGain < a_wGainString[ps->bBlueGainIndex]) break; } if (0 == ps->bBlueGainIndex) ps->bBlueGainIndex ++; wNewBlueGain = a_wGainString[--ps->bBlueGainIndex]; DacP98FillGainOutDirectPort( ps ); ps->Shade.DarkOffset.Colors.Red = 0; ps->Shade.DarkOffset.Colors.Green = 0; ps->Shade.DarkOffset.Colors.Blue = 0; ps->OpenScanPath( ps ); DacP98FillShadingDarkToShadingRegister( ps ); ps->CloseScanPath( ps ); DacP98AdjustDark( ps ); /* RecalculateTransparencyImage() */ if (ps->DataInf.dwScanFlag & SCANDEF_Transparency) { filmAdjustX = ps->wPosAdjustX; } else { filmAdjustX = ps->wNegAdjustX; } if (!filmAdjustX) { p.pw = (pUShort)(ps->pScanBuffer1 + ps->dwOffsetNegative + _Negative96OriginOffsetX * 2); } else { p.pw = (pUShort)(ps->pScanBuffer1 + ps->dwOffsetNegative + filmAdjustX); } /* RecalculateData() */ for (dw= 0; dw < _NegativePageWidth * 2 + 132; dw++, p.pw++) *p.pw = *p.pw * wNewRedGain / wOldRedGain; if (!ps->wNegAdjustX) { p.pw = (pUShort)(ps->pScanBuffer1 + 5400 * 2 + ps->dwOffsetNegative + _Negative96OriginOffsetX * 2); } else { p.pw = (pUShort)(ps->pScanBuffer1 + 5400 * 2 + ps->dwOffsetNegative + ps->wNegAdjustX); } /* RecalculateData() */ for (dw= 0; dw < _NegativePageWidth * 2 + 132; dw++, p.pw++) *p.pw = *p.pw * wNewGreenGain / wOldGreenGain; if (!ps->wNegAdjustX) { p.pw = (pUShort)(ps->pScanBuffer1 + 5400 * 4 + ps->dwOffsetNegative + _Negative96OriginOffsetX * 2); } else { p.pw = (pUShort)(ps->pScanBuffer1 + 5400 * 4 + ps->dwOffsetNegative + ps->wNegAdjustX); } /* RecalculateData() - 64 + dwoffset70 */ for (dw= 0; dw < _NegativePageWidth * 2 + 132; dw++, p.pw++) *p.pw = *p.pw * wNewBlueGain / wOldBlueGain; } /************************ exported functions *********************************/ /*............................................................................. * perform some adjustments according to the source (normal, transparency etc) */ _LOC void TPAP98001AverageShadingData( pScanData ps ) { DBG( DBG_LOW, "TPAP98001AverageShadingData()\n" ); ps->wNegAdjustX = 0; ps->wPosAdjustX = 0; ps->dwOffsetNegative = 0; tpaP98ShadingWaveformSum( ps ); /* * CHANGE: to support Grayscale images in transparency and negative mode * original code: if ((ps->DataInf.wPhyDataType >= COLOR_TRUE24) && */ if((ps->DataInf.wPhyDataType >= COLOR_256GRAY) && (ps->DataInf.dwScanFlag & SCANDEF_TPA)) { if (((ps->DataInf.dwScanFlag & SCANDEF_Negative) && !ps->wNegAdjustX) || ((ps->DataInf.dwScanFlag & SCANDEF_Transparency) && !ps->wPosAdjustX)) { Long dwLeft, dwRight; pUShort pw = (pUShort)ps->pScanBuffer1; for (dwLeft = 0; dwLeft < 5400; dwLeft++) if (pw[dwLeft] >= 600) break; for (dwRight = 4600; dwRight; dwRight--) if (pw[dwRight] >= 600) break; DBG( DBG_LOW, "_TPAPageWidth = %u, _NegativePageWidth = %u\n" "right = %d, left = %d --> right = %d\n", _TPAPageWidth, _NegativePageWidth, dwRight, dwLeft, (((Long)dwRight-(Long)dwLeft)/2)); dwRight = (dwRight - dwLeft) / 2; if (ps->DataInf.dwScanFlag & SCANDEF_Negative) { if (dwRight >= (Long)_NegativePageWidth) { ps->wNegAdjustX = (UShort)(dwRight - _NegativePageWidth + dwLeft - ps->dwOffset70 - ps->Device.DataOriginX + 4U); if( ps->wNegAdjustX > (_Negative96OriginOffsetX * 2U)) ps->wNegAdjustX = (_Negative96OriginOffsetX * 2U); ps->DataInf.crImage.x += ps->wNegAdjustX; } else { ps->DataInf.crImage.x += (_Negative96OriginOffsetX * 2U); } } else { if (dwRight >= (Long)_TPAPageWidth) { ps->wPosAdjustX = (UShort)(dwRight - _TPAPageWidth + dwLeft - ps->dwOffset70 - ps->Device.DataOriginX + 4U); if( ps->wPosAdjustX > (_Transparency96OriginOffsetX * 2U)) ps->wPosAdjustX = (_Transparency96OriginOffsetX * 2U); ps->DataInf.crImage.x += ps->wPosAdjustX; } else { ps->DataInf.crImage.x += (_Transparency96OriginOffsetX * 2U); } } } #if 0 else { /* CHANGE: as we always reset the values, we can ignore this code..*/ if( ps->DataInf.dwScanFlag & SCANDEF_Negative ) ps->DataInf.crImage.x += ps->wNegAdjustX; else ps->DataInf.crImage.x += ps->wPosAdjustX; } #endif if( ps->DataInf.dwScanFlag & SCANDEF_Negative ) { ps->dwOffsetNegative = (ps->dwOffset70 + 64+4) * 2; tpaP98GetNegativeTempRamData( ps ); tpaP98RecalculateNegativeShadingGain( ps ); } else { ps->wReduceRedFactor = 0x3e; ps->wReduceGreenFactor = 0x39; ps->wReduceBlueFactor = 0x42; if( ps->Device.bCCDID == _CCD_518 ) { ps->wReduceRedFactor = 55; ps->wReduceGreenFactor = 55; ps->wReduceBlueFactor = 55; } if( ps->Device.bCCDID == _CCD_3797 ) { ps->wReduceRedFactor = 42; ps->wReduceGreenFactor = 50; ps->wReduceBlueFactor = 50; } tpaP98RecalculateShadingGainandData( ps ); } } } /*............................................................................. * perform some adjustments according to the source (normal, transparency etc) */ _LOC void TPAP98003FindCenterPointer( pScanData ps ) { ULong i; ULong width; ULong left; ULong right; pRGBUShortDef pwSum = ps->Bufs.b2.pSumRGB; if( ps->DataInf.dwScanFlag & SCANDEF_Negative ) width = _NEG_PAGEWIDTH600; else width = _NEG_PAGEWIDTH600 - 94; /* 2.54 cm tolerance */ left = ps->Device.DataOriginX + _NEG_ORG_OFFSETX * 2 - 600; right = ps->Device.DataOriginX + _NEG_ORG_OFFSETX * 2 + _NEG_PAGEWIDTH600 + 600; for( i = 5400UL - left, pwSum = ps->Bufs.b2.pSumRGB; i--; left++) if( pwSum[left].Red > _NEG_EDGE_VALUE && pwSum[left].Green > _NEG_EDGE_VALUE && pwSum[left].Blue > _NEG_EDGE_VALUE) break; for( i = 5400UL - left, pwSum = ps->Bufs.b2.pSumRGB; i--; right--) if( pwSum[right].Red > _NEG_EDGE_VALUE && pwSum[right].Green > _NEG_EDGE_VALUE && pwSum[right].Blue > _NEG_EDGE_VALUE) break; if((right <= left) || ((right - left) < width)) { if( ps->DataInf.dwScanFlag & SCANDEF_Negative ) ps->Scan.negBegin = ps->Device.DataOriginX + _NEG_ORG_OFFSETX * 2; else ps->Scan.posBegin = ps->Device.DataOriginX + _POS_ORG_OFFSETX * 2; } else { if( ps->DataInf.dwScanFlag & SCANDEF_Negative ) ps->Scan.negBegin = (right + left) / 2UL - _NEG_PAGEWIDTH; else ps->Scan.posBegin = (right + left) / 2UL - _POS_PAGEWIDTH; } } /*............................................................................. * this function does some reshading, when scanning negatives on an ASIC 98003 * based scanner */ _LOC void TPAP98003Reshading( pScanData ps ) { Byte bHi[3], bHiLeft[3], bHiRight[3]; ULong i, dwR, dwG, dwB, dwSum; ULong dwIndex, dwIndexRight, dwIndexLeft; DataPointer RedPtr, GreenPtr, BluePtr; TimerDef timer; bHi[0] = bHi[1] = bHi[2] = 0; /* CHECK: Why this ??? */ #if 1 ps->Scan.negScan[1].exposureTime = 144; ps->Scan.negScan[1].xStepTime = 18; ps->Scan.negScan[2].exposureTime = 144; ps->Scan.negScan[2].xStepTime = 36; ps->Scan.negScan[3].exposureTime = 144; ps->Scan.negScan[3].xStepTime = 72; ps->Scan.negScan[4].exposureTime = 144; ps->Scan.negScan[4].xStepTime = 144; #endif ps->Shade.wExposure = ps->Scan.negScan[ps->Scan.dpiIdx].exposureTime; ps->Shade.wXStep = ps->Scan.negScan[ps->Scan.dpiIdx].xStepTime; MiscStartTimer( &timer, _SECOND ); while(!(IOGetScanState(ps, _TRUE) & _SCANSTATE_STOP) && (_OK == MiscCheckTimer(&timer))); IODataToRegister( ps, ps->RegXStepTime, (Byte)(ps->AsicReg.RD_LineControl >> 4)); _DODELAY( 12 ); MotorP98003PositionYProc( ps, _NEG_SHADING_OFFS ); IODataToRegister( ps, ps->RegXStepTime, ps->AsicReg.RD_XStepTime ); ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE; IOSelectLampSource( ps ); IODataToRegister( ps, ps->RegLineControl, _LOBYTE(ps->Shade.wExposure)); IODataToRegister( ps, ps->RegXStepTime, _LOBYTE(ps->Shade.wXStep)); ps->AsicReg.RD_LineControl = _LOBYTE(ps->Shade.wExposure); ps->AsicReg.RD_ExtLineControl = _HIBYTE(ps->Shade.wExposure); ps->AsicReg.RD_XStepTime = (Byte)(ps->Shade.wExposure); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_Motor0Control = _FORWARD_MOTOR; ps->AsicReg.RD_Origin = (UShort)ps->Scan.negBegin; ps->AsicReg.RD_Pixels = _NEG_PAGEWIDTH600; memset( ps->a_nbNewAdrPointer, 0, _SCANSTATE_BYTES ); /* put 9 scan states to make sure there are 8 lines available at least */ for( i = 0; i <= 12; i++) ps->a_nbNewAdrPointer[i] = 0x8f; IOPutOnAllRegisters( ps ); _DODELAY( 70 ); /* prepare the buffers... */ memset( ps->Bufs.TpaBuf.pb, 0, _SizeTpaDataBuf ); RedPtr.pb = ps->Bufs.b1.pShadingMap; GreenPtr.pb = RedPtr.pb + _NEG_PAGEWIDTH600; BluePtr.pb = GreenPtr.pb + _NEG_PAGEWIDTH600; for( dwSum = 8; dwSum--; ) { IOReadOneShadingLine( ps, ps->Bufs.b1.pShadingMap, _NEG_PAGEWIDTH600 ); for( i = 0; i < _NEG_PAGEWIDTH600; i++) { ps->Bufs.TpaBuf.pusrgb[i].Red += RedPtr.pb[i]; ps->Bufs.TpaBuf.pusrgb[i].Green += GreenPtr.pb[i]; ps->Bufs.TpaBuf.pusrgb[i].Blue += BluePtr.pb[i]; } } for( i = 0; i < (_NEG_PAGEWIDTH600 * 3UL); i++ ) ps->Bufs.TpaBuf.pb[i] = ps->Bufs.TpaBuf.pw[i] >> 3; RedPtr.pb = ps->Bufs.TpaBuf.pb; /* Convert RGB to gray scale (Brightness), and average 16 pixels */ for( bHiRight[1] = 0, i = dwIndexRight = 0; i < _NEG_PAGEWIDTH600 / 2; i += 16 ) { bHiRight [0] = (Byte)(((((ULong) RedPtr.pbrgb [i].Red + (ULong) RedPtr.pbrgb[i + 1].Red + (ULong) RedPtr.pbrgb[i + 2].Red + (ULong) RedPtr.pbrgb[i + 3].Red + (ULong) RedPtr.pbrgb[i + 4].Red + (ULong) RedPtr.pbrgb[i + 5].Red + (ULong) RedPtr.pbrgb[i + 6].Red + (ULong) RedPtr.pbrgb[i + 7].Red + (ULong) RedPtr.pbrgb[i + 8].Red + (ULong) RedPtr.pbrgb[i + 9].Red + (ULong) RedPtr.pbrgb[i + 10].Red + (ULong) RedPtr.pbrgb[i + 11].Red + (ULong) RedPtr.pbrgb[i + 12].Red + (ULong) RedPtr.pbrgb[i + 13].Red + (ULong) RedPtr.pbrgb[i + 14].Red + (ULong) RedPtr.pbrgb[i + 15].Red) >> 4) * 30UL + (((ULong) RedPtr.pbrgb[i].Green + (ULong) RedPtr.pbrgb[i + 1].Green + (ULong) RedPtr.pbrgb[i + 2].Green + (ULong) RedPtr.pbrgb[i + 3].Green + (ULong) RedPtr.pbrgb[i + 4].Green + (ULong) RedPtr.pbrgb[i + 5].Green + (ULong) RedPtr.pbrgb[i + 6].Green + (ULong) RedPtr.pbrgb[i + 7].Green + (ULong) RedPtr.pbrgb[i + 8].Green + (ULong) RedPtr.pbrgb[i + 9].Green + (ULong) RedPtr.pbrgb[i + 10].Green + (ULong) RedPtr.pbrgb[i + 11].Green + (ULong) RedPtr.pbrgb[i + 12].Green + (ULong) RedPtr.pbrgb[i + 13].Green + (ULong) RedPtr.pbrgb[i + 14].Green + (ULong) RedPtr.pbrgb[i + 15].Green) >> 4) * 59UL + (((ULong) RedPtr.pbrgb[i].Blue + (ULong) RedPtr.pbrgb[i + 1].Blue + (ULong) RedPtr.pbrgb[i + 2].Blue + (ULong) RedPtr.pbrgb[i + 3].Blue + (ULong) RedPtr.pbrgb[i + 4].Blue + (ULong) RedPtr.pbrgb[i + 5].Blue + (ULong) RedPtr.pbrgb[i + 6].Blue + (ULong) RedPtr.pbrgb[i + 7].Blue + (ULong) RedPtr.pbrgb[i + 8].Blue + (ULong) RedPtr.pbrgb[i + 9].Blue + (ULong) RedPtr.pbrgb[i + 10].Blue + (ULong) RedPtr.pbrgb[i + 11].Blue + (ULong) RedPtr.pbrgb[i + 12].Blue + (ULong) RedPtr.pbrgb[i + 13].Blue + (ULong) RedPtr.pbrgb[i + 14].Blue + (ULong) RedPtr.pbrgb[i + 15].Blue) >> 4) * 11UL) / 100UL); if( bHiRight[1] < bHiRight[0] ) { bHiRight[1] = bHiRight[0]; dwIndexRight = i; } } /* Convert RGB to gray scale (Brightness), and average 16 pixels */ for( bHiLeft[1] = 0, i = dwIndexLeft = _NEG_PAGEWIDTH / 2; i < _NEG_PAGEWIDTH600; i += 16 ) { bHiLeft [0] = (Byte)(((((ULong) RedPtr.pbrgb[i].Red + (ULong) RedPtr.pbrgb[i + 1].Red + (ULong) RedPtr.pbrgb[i + 2].Red + (ULong) RedPtr.pbrgb[i + 3].Red + (ULong) RedPtr.pbrgb[i + 4].Red + (ULong) RedPtr.pbrgb[i + 5].Red + (ULong) RedPtr.pbrgb[i + 6].Red + (ULong) RedPtr.pbrgb[i + 7].Red + (ULong) RedPtr.pbrgb[i + 8].Red + (ULong) RedPtr.pbrgb[i + 9].Red + (ULong) RedPtr.pbrgb[i + 10].Red + (ULong) RedPtr.pbrgb[i + 11].Red + (ULong) RedPtr.pbrgb[i + 12].Red + (ULong) RedPtr.pbrgb[i + 13].Red + (ULong) RedPtr.pbrgb[i + 14].Red + (ULong) RedPtr.pbrgb[i + 15].Red) >> 4) * 30UL + (((ULong) RedPtr.pbrgb[i].Green + (ULong) RedPtr.pbrgb[i + 1].Green + (ULong) RedPtr.pbrgb[i + 2].Green + (ULong) RedPtr.pbrgb[i + 3].Green + (ULong) RedPtr.pbrgb[i + 4].Green + (ULong) RedPtr.pbrgb[i + 5].Green + (ULong) RedPtr.pbrgb[i + 6].Green + (ULong) RedPtr.pbrgb[i + 7].Green + (ULong) RedPtr.pbrgb[i + 8].Green + (ULong) RedPtr.pbrgb[i + 9].Green + (ULong) RedPtr.pbrgb[i + 10].Green + (ULong) RedPtr.pbrgb[i + 11].Green + (ULong) RedPtr.pbrgb[i + 12].Green + (ULong) RedPtr.pbrgb[i + 13].Green + (ULong) RedPtr.pbrgb[i + 14].Green + (ULong) RedPtr.pbrgb[i + 15].Green) >> 4) * 59UL + (((ULong) RedPtr.pbrgb[i].Blue + (ULong) RedPtr.pbrgb[i + 1].Blue + (ULong) RedPtr.pbrgb[i + 2].Blue + (ULong) RedPtr.pbrgb[i + 3].Blue + (ULong) RedPtr.pbrgb[i + 4].Blue + (ULong) RedPtr.pbrgb[i + 5].Blue + (ULong) RedPtr.pbrgb[i + 6].Blue + (ULong) RedPtr.pbrgb[i + 7].Blue + (ULong) RedPtr.pbrgb[i + 8].Blue + (ULong) RedPtr.pbrgb[i + 9].Blue + (ULong) RedPtr.pbrgb[i + 10].Blue + (ULong) RedPtr.pbrgb[i + 11].Blue + (ULong) RedPtr.pbrgb[i + 12].Blue + (ULong) RedPtr.pbrgb[i + 13].Blue + (ULong) RedPtr.pbrgb[i + 14].Blue + (ULong) RedPtr.pbrgb[i + 15].Blue) >> 4) * 11UL) / 100UL); if( bHiLeft[1] < bHiLeft[0] ) { bHiLeft[1] = bHiLeft[0]; dwIndexLeft = i; } } if((bHiLeft[1] < 200) && (bHiRight[1] < 200)) { if( bHiLeft[1] < bHiRight[1] ) dwIndex = dwIndexRight; else dwIndex = dwIndexLeft; } else { if( bHiLeft[1] > 200 ) dwIndex = dwIndexRight; else dwIndex = dwIndexLeft; } /* Get the hilight */ RedPtr.pusrgb = ps->Bufs.b2.pSumRGB + dwIndex + ps->AsicReg.RD_Origin + _SHADING_BEGINX; for( dwR = dwG = dwB = 0, i = 16; i--; RedPtr.pusrgb++ ) { dwR += RedPtr.pusrgb->Red; dwG += RedPtr.pusrgb->Green; dwB += RedPtr.pusrgb->Blue; } dwR >>= 8; dwG >>= 8; dwB >>= 8; if( dwR > dwG && dwR > dwB ) ps->Shade.bGainHigh = (Byte)dwR; /* >> 4 for average, >> 4 to 8-bit */ else { if( dwG > dwR && dwG > dwB ) ps->Shade.bGainHigh = (Byte)dwG; else ps->Shade.bGainHigh = (Byte)dwB; } ps->Shade.bGainHigh = (Byte)(ps->Shade.bGainHigh - 0x18); ps->Shade.bGainLow = (Byte)(ps->Shade.bGainHigh - 0x10); /* Reshading to get the new gain */ ps->Shade.Hilight.Colors.Red = 0; ps->Shade.Hilight.Colors.Green = 0; ps->Shade.Hilight.Colors.Blue = 0; ps->Shade.Gain.Colors.Red++; ps->Shade.Gain.Colors.Green++; ps->Shade.Gain.Colors.Blue++; ps->Shade.fStop = _FALSE; RedPtr.pb = ps->Bufs.b1.pShadingMap + dwIndex; GreenPtr.pb = RedPtr.pb + _NEG_PAGEWIDTH600; BluePtr.pb = GreenPtr.pb + _NEG_PAGEWIDTH600; for( i = 16; i-- && !ps->Shade.fStop;) { ps->Shade.fStop = _TRUE; DacP98003FillToDAC( ps, &ps->Device.RegDACGain, &ps->Shade.Gain ); IODataToRegister( ps, ps->RegModeControl, _ModeIdle ); ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE; IOSelectLampSource( ps ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_StepControl = _MOTOR0_SCANSTATE; ps->AsicReg.RD_Motor0Control = _FORWARD_MOTOR; memset( ps->a_nbNewAdrPointer, 0, _SCANSTATE_BYTES ); ps->a_nbNewAdrPointer[1] = 0x77; IOPutOnAllRegisters( ps ); _DODELAY( 50 ); if(IOReadOneShadingLine(ps,ps->Bufs.b1.pShadingMap,_NEG_PAGEWIDTH600)) { bHi[0] = DacP98003SumGains( RedPtr.pb, 32 ); bHi[1] = DacP98003SumGains( GreenPtr.pb, 32 ); bHi[2] = DacP98003SumGains( BluePtr.pb, 32 ); if( !bHi[0] || !bHi[1] || !bHi[2]) { ps->Shade.fStop = _FALSE; } else { DacP98003AdjustGain( ps, _CHANNEL_RED, bHi[0] ); DacP98003AdjustGain( ps, _CHANNEL_GREEN, bHi[1] ); DacP98003AdjustGain( ps, _CHANNEL_BLUE, bHi[2] ); } } else ps->Shade.fStop = _FALSE; } DacP98003FillToDAC( ps, &ps->Device.RegDACGain, &ps->Shade.Gain ); /* Set RGB Gain */ if( dwR && dwG && dwB ) { if(ps->Device.bCCDID == _CCD_3797 || ps->Device.bDACType == _DA_ESIC) { ps->Shade.pCcdDac->GainResize.Colors.Red = (UShort)((ULong)bHi[0] * 100UL / dwR); ps->Shade.pCcdDac->GainResize.Colors.Green = (UShort)((ULong)bHi[1] * 100UL / dwG); ps->Shade.pCcdDac->GainResize.Colors.Blue = (UShort)((ULong)bHi[2] * 100UL / dwB); } else { ps->Shade.pCcdDac->GainResize.Colors.Red = (UShort)((ULong)bHi[0] * 90UL / dwR); ps->Shade.pCcdDac->GainResize.Colors.Green = (UShort)((ULong)bHi[1] * 77UL / dwG); ps->Shade.pCcdDac->GainResize.Colors.Blue = (UShort)((ULong)bHi[2] * 73UL / dwB); } ps->Shade.DarkOffset.Colors.Red += (UShort)((dwR > bHi[0]) ? dwR - bHi[0] : 0); ps->Shade.DarkOffset.Colors.Green += (UShort)((dwG > bHi[1]) ? dwG - bHi[1] : 0); ps->Shade.DarkOffset.Colors.Blue += (UShort)((dwB > bHi[2]) ? dwB - bHi[2] : 0); if( ps->Device.bDACType != _DA_ESIC && ps->Device.bCCDID != _CCD_3799 ) { ps->Shade.DarkOffset.Colors.Red = (UShort)(ps->Shade.DarkOffset.Colors.Red * ps->Shade.pCcdDac->GainResize.Colors.Red / 100UL); ps->Shade.DarkOffset.Colors.Green = (UShort)(ps->Shade.DarkOffset.Colors.Green * ps->Shade.pCcdDac->GainResize.Colors.Green / 100UL); ps->Shade.DarkOffset.Colors.Blue = (UShort)(ps->Shade.DarkOffset.Colors.Blue * ps->Shade.pCcdDac->GainResize.Colors.Blue / 100UL); } } /* AdjustDark () */ ps->AsicReg.RD_Origin = _SHADING_BEGINX; ps->AsicReg.RD_Pixels = 5400; } /* END PLUSTEK-PP_TPA.C .....................................................*/ sane-backends-1.0.29/backend/plustek-usbio.c0000666000000000000000000002142713615534521015550 00000000000000/*............................................................................. * Project : SANE library for Plustek flatbed scanners. *............................................................................. */ /** @file plustek-usbio.c * @brief Some I/O stuff. * * Based on sources acquired from Plustek Inc.
* Copyright (C) 2001-2007 Gerhard Jaeger * * History: * History: * - 0.40 - starting version of the USB support * - 0.41 - moved some functions to a sane library (sanei_lm983x.c) * - 0.42 - no changes * - 0.43 - no changes * - 0.44 - added dump registers and dumpPic functions * - beautyfied output of ASIC detection * - 0.45 - fixed dumpRegs * - added dimension stuff to dumpPic * - 0.46 - disabled reset prior to the detection of Merlin * - 0.47 - no changes * - 0.48 - cleanup * - 0.49 - no changes * - 0.50 - usbio_DetectLM983x() now returns error if register * could not be red * - usbio_ResetLM983x() checks for reg7 value before writing * - 0.51 - allow dumpRegs to be called without valid fd * - 0.52 - no changes * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_lm983x.h" #define _UIO(func) \ { \ SANE_Status status; \ status = func; \ if (status != SANE_STATUS_GOOD) { \ DBG( _DBG_ERROR, "UIO error\n" ); \ return SANE_FALSE; \ } \ } #define usbio_ReadReg(fd, reg, value) \ sanei_lm983x_read (fd, reg, value, 1, 0) typedef struct { u_char depth; u_long x; u_long y; } PicDef, *pPicDef; static PicDef dPix; /** */ static void dumpPic( char* name, SANE_Byte *buffer, u_long len, int is_gray ) { u_short type; FILE *fp; if( DBG_LEVEL < _DBG_DPIC ) return; if( NULL == buffer ) { DBG( _DBG_DPIC, "Creating file '%s'\n", name ); fp = fopen( name, "w+b" ); if( NULL != fp ) { if( 0 != dPix.x ) { if (is_gray) type = 5; else type = 6; DBG( _DBG_DPIC, "> X=%lu, Y=%lu, depth=%u\n", dPix.x, dPix.y, dPix.depth ); if( dPix.depth > 8 ) fprintf( fp, "P%u\n%lu %lu\n65535\n", type, dPix.x, dPix.y); else fprintf( fp, "P%u\n%lu %lu\n255\n", type, dPix.x, dPix.y); } } } else { fp = fopen( name, "a+b" ); } if( NULL == fp ) { DBG( _DBG_DPIC, "Can not open file '%s'\n", name ); return; } fwrite( buffer, 1, len, fp ); fclose( fp ); } /** */ static void dumpPicInit( ScanParam *sd, char* name ) { dPix.x = sd->Size.dwPhyBytes; if( sd->bDataType == SCANDATATYPE_Color ) dPix.x /= 3; if( sd->bBitDepth > 8 ) dPix.x /= 2; dPix.y = sd->Size.dwLines; dPix.depth = sd->bBitDepth; if( sd->bDataType == SCANDATATYPE_Color ) dumpPic(name, NULL, 0, 0); else dumpPic(name, NULL, 0, 1); } /** * dump the LM983x registers */ static void dumpregs( int fd, SANE_Byte *cmp ) { char buf[256], b2[10]; SANE_Byte regs[0x80]; int i; if( DBG_LEVEL < _DBG_DREGS ) return; buf[0] = '\0'; if( fd >= 0 ) { usbio_ReadReg(fd, 0x01, ®s[0x01]); usbio_ReadReg(fd, 0x02, ®s[0x02]); usbio_ReadReg(fd, 0x03, ®s[0x03]); usbio_ReadReg(fd, 0x04, ®s[0x04]); usbio_ReadReg(fd, 0x07, ®s[0x07]); sanei_lm983x_read( fd, 0x08, ®s[0x8], 0x80-0x8, SANE_TRUE ); for( i = 0x0; i < 0x80; i++ ) { if((i%16) ==0 ) { if( buf[0] ) DBG( _DBG_DREGS, "%s\n", buf ); sprintf( buf, "0x%02x:", i ); } if((i%8)==0) strcat( buf, " "); /* the dataport read returns with "0 Bytes read", of course. */ if((i == 0) || (i == 5) || (i == 6)) strcat( buf, "XX "); else { sprintf( b2, "%02x ", regs[i]); strcat( buf, b2 ); } } DBG( _DBG_DREGS, "%s\n", buf ); } if( cmp ) { buf[0] = '\0'; DBG( _DBG_DREGS, "Internal setting:\n" ); for( i = 0x0; i < 0x80; i++ ) { if((i%16) ==0 ) { if( buf[0] ) DBG( _DBG_DREGS, "%s\n", buf ); sprintf( buf, "0x%02x:", i ); } if((i%8)==0) strcat( buf, " "); if((i == 0) || (i == 5) || (i == 6)) strcat( buf, "XX "); else { sprintf( b2, "%02x ", cmp[i]); strcat( buf, b2 ); } } DBG( _DBG_DREGS, "%s\n", buf ); } } /** * function to read the contents of a LM983x register and regarding some * extra stuff, like flushing register 2 when writing register 0x58, etc * * @param handle - * @param reg - * @param value - * @return */ static SANE_Bool usbio_WriteReg( SANE_Int handle, SANE_Byte reg, SANE_Byte value ) { int i; SANE_Byte data; /* retry loop... */ for( i = 0; i < 100; i++ ) { sanei_lm983x_write_byte( handle, reg, value ); /* Flush register 0x02 when register 0x58 is written */ if( 0x58 == reg ) { _UIO( usbio_ReadReg( handle, 2, &data )); _UIO( usbio_ReadReg( handle, 2, &data )); } if( reg != 7 ) return SANE_TRUE; /* verify register 7 */ _UIO( usbio_ReadReg( handle, 7, &data )); if( data == value ) { return SANE_TRUE; } } return SANE_FALSE; } /** try and read register 0x69 from a LM983x to find out which version we have. */ static SANE_Status usbio_DetectLM983x( SANE_Int fd, SANE_Byte *version ) { char buf[256]; SANE_Byte value; SANE_Status res; DBG( _DBG_INFO, "usbio_DetectLM983x\n"); res = usbio_ReadReg(fd, 0x69, &value); if( res != SANE_STATUS_GOOD ) { DBG( _DBG_ERROR, " * could not read version register!\n"); return res; } value &= 7; if (version) *version = value; res = SANE_STATUS_GOOD; sprintf( buf, "usbio_DetectLM983x: found " ); switch((SANE_Int)value ) { case 4: strcat( buf, "LM9832/3" ); break; case 3: strcat( buf, "LM9831" ); break; case 2: strcat( buf, "LM9830 --> unsupported!!!" ); res = SANE_STATUS_INVAL; break; default: DBG( _DBG_INFO, "Unknown chip v%d", value ); res = SANE_STATUS_INVAL; break; } DBG( _DBG_INFO, "%s\n", buf ); return res; } /** well, this is more or less a reset function, for LM9831 based devices * we issue a real reset command, while for LM9832/3 based devices, checking * and resetting register 7 will be enough... */ static SANE_Status usbio_ResetLM983x( Plustek_Device *dev ) { SANE_Byte value; HWDef *hw = &dev->usbDev.HwSetting; if( _LM9831 == hw->chip ) { DBG( _DBG_INFO," * resetting LM9831 device!\n"); _UIO( sanei_lm983x_write_byte( dev->fd, 0x07, 0)); _UIO( sanei_lm983x_write_byte( dev->fd, 0x07,0x20)); _UIO( sanei_lm983x_write_byte( dev->fd, 0x07, 0)); _UIO( usbio_ReadReg( dev->fd, 0x07, &value)); if (value != 0) { DBG( _DBG_ERROR, "usbio_ResetLM983x: reset was not " "successful, status=%d\n", value ); return SANE_STATUS_INVAL; } } else { _UIO( usbio_ReadReg( dev->fd, 0x07, &value)); if (value != 0 ) { DBG( _DBG_INFO," * setting device to idle state!\n"); _UIO( sanei_lm983x_write_byte( dev->fd, 0x07, 0)); } } return SANE_STATUS_GOOD; } /* END PLUSTEK-USBIO.C ......................................................*/ sane-backends-1.0.29/backend/lexmark.c0000666000000000000000000011163213615534521014403 00000000000000/* lexmark.c: SANE backend for Lexmark scanners. (C) 2003-2004 Lexmark International, Inc. (Original Source code) (C) 2005 Fred Odendaal (C) 2006-2013 Stéphane Voltz (C) 2010 "Torsten Houwaart" X74 support 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. **************************************************************************/ #include "lexmark.h" #define LEXMARK_CONFIG_FILE "lexmark.conf" #define BUILD 32 #define MAX_OPTION_STRING_SIZE 255 static Lexmark_Device *first_lexmark_device = 0; static SANE_Int num_lexmark_device = 0; static const SANE_Device **sane_device_list = NULL; /* Program globals F.O - Should this be per device?*/ static SANE_Bool initialized = SANE_FALSE; static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_COLOR, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_LINEART, NULL }; /* possible resolutions are: 75x75, 150x150, 300x300, 600x600, 600x1200 */ static SANE_Int x1100_dpi_list[] = { 5, 75, 150, 300, 600, 1200 }; static SANE_Int a920_dpi_list[] = { 4, 75, 150, 300, 600 }; static SANE_Int x1200_dpi_list[] = { 4, 75, 150, 300, 600 }; static SANE_Int x74_dpi_list[] = { 75, 150, 300, 600 }; static SANE_Range threshold_range = { SANE_FIX (0.0), /* minimum */ SANE_FIX (100.0), /* maximum */ SANE_FIX (1.0) /* quantization */ }; static const SANE_Range gain_range = { 0, /* minimum */ 31, /* maximum */ 0 /* quantization */ }; /* for now known models (2 ...) have the same scan window geometry. coordinates are expressed in pixels, with a quantization factor of 8 to have 'even' coordinates at 75 dpi */ static SANE_Range x_range = { 0, /* minimum */ 5104, /* maximum */ 16 /* quantization : 16 is required so we never have an odd width */ }; static SANE_Range y_range = { 0, /* minimum */ 6848, /* maximum */ /* 7032, for X74 */ 8 /* quantization */ }; /* static functions */ static SANE_Status init_options (Lexmark_Device * lexmark_device); static SANE_Status attachLexmark (SANE_String_Const devname); SANE_Status init_options (Lexmark_Device * dev) { SANE_Option_Descriptor *od; DBG (2, "init_options: dev = %p\n", (void *) dev); /* number of options */ od = &(dev->opt[OPT_NUM_OPTS]); od->name = SANE_NAME_NUM_OPTIONS; od->title = SANE_TITLE_NUM_OPTIONS; od->desc = SANE_DESC_NUM_OPTIONS; od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; dev->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* mode - sets the scan mode: Color, Gray, or Line Art */ od = &(dev->opt[OPT_MODE]); od->name = SANE_NAME_SCAN_MODE; od->title = SANE_TITLE_SCAN_MODE; od->desc = SANE_DESC_SCAN_MODE;; od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = MAX_OPTION_STRING_SIZE; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = mode_list; dev->val[OPT_MODE].s = malloc (od->size); if (!dev->val[OPT_MODE].s) return SANE_STATUS_NO_MEM; strcpy (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR); /* resolution */ od = &(dev->opt[OPT_RESOLUTION]); od->name = SANE_NAME_SCAN_RESOLUTION; od->title = SANE_TITLE_SCAN_RESOLUTION; od->desc = SANE_DESC_SCAN_RESOLUTION; od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_DPI; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_WORD_LIST; switch (dev->model.sensor_type) { case X1100_2C_SENSOR: case A920_SENSOR: od->constraint.word_list = a920_dpi_list; break; case X1100_B2_SENSOR: od->constraint.word_list = x1100_dpi_list; break; case X1200_SENSOR: case X1200_USB2_SENSOR: od->constraint.word_list = x1200_dpi_list; break; case X74_SENSOR: od->constraint.word_list = x74_dpi_list; break; } dev->val[OPT_RESOLUTION].w = 75; /* preview mode */ od = &(dev->opt[OPT_PREVIEW]); od->name = SANE_NAME_PREVIEW; od->title = SANE_TITLE_PREVIEW; od->desc = SANE_DESC_PREVIEW; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->type = SANE_TYPE_BOOL; od->constraint_type = SANE_CONSTRAINT_NONE; dev->val[OPT_PREVIEW].w = SANE_FALSE; /* "Geometry" group: */ od = &(dev->opt[OPT_GEOMETRY_GROUP]); od->name = ""; od->title = SANE_I18N ("Geometry"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->size = 0; od->constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ od = &(dev->opt[OPT_TL_X]); od->name = SANE_NAME_SCAN_TL_X; od->title = SANE_TITLE_SCAN_TL_X; od->desc = SANE_DESC_SCAN_TL_X; od->type = SANE_TYPE_INT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->size = sizeof (SANE_Word); od->unit = SANE_UNIT_PIXEL; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &x_range; dev->val[OPT_TL_X].w = 0; /* top-left y */ od = &(dev->opt[OPT_TL_Y]); od->name = SANE_NAME_SCAN_TL_Y; od->title = SANE_TITLE_SCAN_TL_Y; od->desc = SANE_DESC_SCAN_TL_Y; od->type = SANE_TYPE_INT; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->size = sizeof (SANE_Word); od->unit = SANE_UNIT_PIXEL; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &y_range; dev->val[OPT_TL_Y].w = 0; /* bottom-right x */ od = &(dev->opt[OPT_BR_X]); od->name = SANE_NAME_SCAN_BR_X; od->title = SANE_TITLE_SCAN_BR_X; od->desc = SANE_DESC_SCAN_BR_X; od->type = SANE_TYPE_INT; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->unit = SANE_UNIT_PIXEL; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &x_range; dev->val[OPT_BR_X].w = x_range.max; /* bottom-right y */ od = &(dev->opt[OPT_BR_Y]); od->name = SANE_NAME_SCAN_BR_Y; od->title = SANE_TITLE_SCAN_BR_Y; od->desc = SANE_DESC_SCAN_BR_Y; od->type = SANE_TYPE_INT; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->unit = SANE_UNIT_PIXEL; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &y_range; dev->val[OPT_BR_Y].w = y_range.max; /* threshold */ od = &(dev->opt[OPT_THRESHOLD]); od->name = SANE_NAME_THRESHOLD; od->title = SANE_TITLE_THRESHOLD; od->desc = SANE_DESC_THRESHOLD; od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_PERCENT; od->size = sizeof (SANE_Fixed); od->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &threshold_range; dev->val[OPT_THRESHOLD].w = SANE_FIX (50.0); /* gain group */ dev->opt[OPT_MANUAL_GAIN].name = "manual-channel-gain"; dev->opt[OPT_MANUAL_GAIN].title = SANE_I18N ("Gain"); dev->opt[OPT_MANUAL_GAIN].desc = SANE_I18N ("Color channels gain settings"); dev->opt[OPT_MANUAL_GAIN].type = SANE_TYPE_BOOL; dev->opt[OPT_MANUAL_GAIN].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; dev->opt[OPT_MANUAL_GAIN].size = sizeof (SANE_Bool); dev->val[OPT_MANUAL_GAIN].w = SANE_FALSE; /* gray gain */ dev->opt[OPT_GRAY_GAIN].name = "gray-gain"; dev->opt[OPT_GRAY_GAIN].title = SANE_I18N ("Gray gain"); dev->opt[OPT_GRAY_GAIN].desc = SANE_I18N ("Sets gray channel gain"); dev->opt[OPT_GRAY_GAIN].type = SANE_TYPE_INT; dev->opt[OPT_GRAY_GAIN].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_GRAY_GAIN].unit = SANE_UNIT_NONE; dev->opt[OPT_GRAY_GAIN].size = sizeof (SANE_Int); dev->opt[OPT_GRAY_GAIN].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GRAY_GAIN].constraint.range = &gain_range; dev->val[OPT_GRAY_GAIN].w = 10; /* red gain */ dev->opt[OPT_RED_GAIN].name = "red-gain"; dev->opt[OPT_RED_GAIN].title = SANE_I18N ("Red gain"); dev->opt[OPT_RED_GAIN].desc = SANE_I18N ("Sets red channel gain"); dev->opt[OPT_RED_GAIN].type = SANE_TYPE_INT; dev->opt[OPT_RED_GAIN].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_RED_GAIN].unit = SANE_UNIT_NONE; dev->opt[OPT_RED_GAIN].size = sizeof (SANE_Int); dev->opt[OPT_RED_GAIN].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_RED_GAIN].constraint.range = &gain_range; dev->val[OPT_RED_GAIN].w = 10; /* green gain */ dev->opt[OPT_GREEN_GAIN].name = "green-gain"; dev->opt[OPT_GREEN_GAIN].title = SANE_I18N ("Green gain"); dev->opt[OPT_GREEN_GAIN].desc = SANE_I18N ("Sets green channel gain"); dev->opt[OPT_GREEN_GAIN].type = SANE_TYPE_INT; dev->opt[OPT_GREEN_GAIN].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_GREEN_GAIN].unit = SANE_UNIT_NONE; dev->opt[OPT_GREEN_GAIN].size = sizeof (SANE_Int); dev->opt[OPT_GREEN_GAIN].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GREEN_GAIN].constraint.range = &gain_range; dev->val[OPT_GREEN_GAIN].w = 10; /* blue gain */ dev->opt[OPT_BLUE_GAIN].name = "blue-gain"; dev->opt[OPT_BLUE_GAIN].title = SANE_I18N ("Blue gain"); dev->opt[OPT_BLUE_GAIN].desc = SANE_I18N ("Sets blue channel gain"); dev->opt[OPT_BLUE_GAIN].type = SANE_TYPE_INT; dev->opt[OPT_BLUE_GAIN].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_BLUE_GAIN].unit = SANE_UNIT_NONE; dev->opt[OPT_BLUE_GAIN].size = sizeof (SANE_Int); dev->opt[OPT_BLUE_GAIN].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BLUE_GAIN].constraint.range = &gain_range; dev->val[OPT_BLUE_GAIN].w = 10; return SANE_STATUS_GOOD; } /***************************** SANE API ****************************/ SANE_Status attachLexmark (SANE_String_Const devname) { Lexmark_Device *lexmark_device; SANE_Int dn, vendor, product, variant; SANE_Status status; DBG (2, "attachLexmark: devname=%s\n", devname); for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { /* already attached devices */ if (strcmp (lexmark_device->sane.name, devname) == 0) { lexmark_device->missing = SANE_FALSE; return SANE_STATUS_GOOD; } } lexmark_device = (Lexmark_Device *) malloc (sizeof (Lexmark_Device)); if (lexmark_device == NULL) return SANE_STATUS_NO_MEM; #ifdef FAKE_USB status = SANE_STATUS_GOOD; #else status = sanei_usb_open (devname, &dn); #endif if (status != SANE_STATUS_GOOD) { DBG (1, "attachLexmark: couldn't open device `%s': %s\n", devname, sane_strstatus (status)); return status; } else DBG (2, "attachLexmark: device `%s' successfully opened\n", devname); #ifdef FAKE_USB status = SANE_STATUS_GOOD; /* put the id of the model you want to fake here */ vendor = 0x043d; product = 0x007c; /* X11xx */ variant = 0xb2; #else variant = 0; status = sanei_usb_get_vendor_product (dn, &vendor, &product); #endif if (status != SANE_STATUS_GOOD) { DBG (1, "attachLexmark: couldn't get vendor and product ids of device `%s': %s\n", devname, sane_strstatus (status)); #ifndef FAKE_USB sanei_usb_close (dn); #endif return status; } #ifndef FAKE_USB sanei_usb_close (dn); #endif DBG (2, "attachLexmark: testing device `%s': 0x%04x:0x%04x, variant=%d\n", devname, vendor, product, variant); if (sanei_lexmark_low_assign_model (lexmark_device, devname, vendor, product, variant) != SANE_STATUS_GOOD) { DBG (2, "attachLexmark: unsupported device `%s': 0x%04x:0x%04x\n", devname, vendor, product); return SANE_STATUS_UNSUPPORTED; } /* add new device to device list */ /* there are two variant of the scanner with the same USB id, * so we need to read registers from scanner to detect which one * is really connected */ status = sanei_lexmark_low_open_device (lexmark_device); sanei_usb_close (lexmark_device->devnum); /* set up scanner start status */ sanei_lexmark_low_init (lexmark_device); /* Set the default resolution here */ lexmark_device->x_dpi = 75; lexmark_device->y_dpi = 75; /* Make the pointer to the read buffer null here */ lexmark_device->read_buffer = NULL; /* Set the default threshold for lineart mode here */ lexmark_device->threshold = 0x80; lexmark_device->shading_coeff = NULL; /* mark device as present */ lexmark_device->missing = SANE_FALSE; /* insert it a the start of the chained list */ lexmark_device->next = first_lexmark_device; first_lexmark_device = lexmark_device; num_lexmark_device++; return status; } /** probe for supported lexmark devices * This function scan usb and try to attached to scanner * configured in lexmark.conf . */ static SANE_Status probe_lexmark_devices (void) { FILE *fp; SANE_Char line[PATH_MAX]; const char *lp; SANE_Int vendor, product; size_t len; Lexmark_Device *dev; /* mark already detected devices as missing, during device probe * detected devices will clear this flag */ dev = first_lexmark_device; while (dev != NULL) { dev->missing = SANE_TRUE; dev = dev->next; } /* open config file, parse option and try to open * any device configure in it */ fp = sanei_config_open (LEXMARK_CONFIG_FILE); if (!fp) { return SANE_STATUS_ACCESS_DENIED; } while (sanei_config_read (line, PATH_MAX, fp)) { /* ignore comments */ if (line[0] == '#') continue; len = strlen (line); /* delete newline characters at end */ if (line[len - 1] == '\n') line[--len] = '\0'; lp = sanei_config_skip_whitespace (line); /* skip empty lines */ if (*lp == 0) continue; if (sscanf (lp, "usb %i %i", &vendor, &product) == 2) ; else if (strncmp ("libusb", lp, 6) == 0) ; else if ((strncmp ("usb", lp, 3) == 0) && isspace (lp[3])) { lp += 3; lp = sanei_config_skip_whitespace (lp); } else continue; #ifdef FAKE_USB attachLexmark ("FAKE_USB"); #else sanei_usb_attach_matching_devices (lp, attachLexmark); #endif } fclose (fp); return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { SANE_Status status; DBG_INIT (); DBG (1, "SANE Lexmark backend version %d.%d.%d-devel\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (2, "sane_init: version_code=%p\n", (void *) version_code); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); #ifndef FAKE_USB sanei_usb_init (); #endif status = probe_lexmark_devices (); if (status == SANE_STATUS_GOOD) { initialized = SANE_TRUE; } else { initialized = SANE_FALSE; } return status; } void sane_exit (void) { Lexmark_Device *lexmark_device, *next_lexmark_device; DBG (2, "sane_exit\n"); if (!initialized) return; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = next_lexmark_device) { next_lexmark_device = lexmark_device->next; sanei_lexmark_low_destroy (lexmark_device); free (lexmark_device); } if (sane_device_list) free (sane_device_list); sanei_usb_exit(); initialized = SANE_FALSE; return; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Lexmark_Device *lexmark_device; SANE_Int index; DBG (2, "sane_get_devices: device_list=%p, local_only=%d\n", (void *) device_list, local_only); /* hot-plug case : detection of newly connected scanners */ sanei_usb_scan_devices (); probe_lexmark_devices (); if (sane_device_list) free (sane_device_list); sane_device_list = malloc ((num_lexmark_device + 1) * sizeof (sane_device_list[0])); if (!sane_device_list) return SANE_STATUS_NO_MEM; index = 0; lexmark_device = first_lexmark_device; while (lexmark_device != NULL) { if (lexmark_device->missing == SANE_FALSE) { sane_device_list[index] = &(lexmark_device->sane); index++; } lexmark_device = lexmark_device->next; } sane_device_list[index] = 0; *device_list = sane_device_list; return SANE_STATUS_GOOD; } /** * Open the backend, ie return the struct handle of a detected scanner * The struct returned is choosne if it matches the name given, which is * usefull when several scanners handled by the backend have been detected. * However, special case empty string "" and "lexmark" pick the first * available handle. */ SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Lexmark_Device *lexmark_device; SANE_Status status; DBG (2, "sane_open: devicename=\"%s\", handle=%p\n", devicename, (void *) handle); if (!initialized) { DBG (2, "sane_open: not initialized\n"); return SANE_STATUS_INVAL; } if (!handle) { DBG (2, "sane_open: no handle\n"); return SANE_STATUS_INVAL; } /* walk the linked list of scanner device until ther is a match * with the device name */ for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { DBG (2, "sane_open: devname from list: %s\n", lexmark_device->sane.name); if (strcmp (devicename, "") == 0 || strcmp (devicename, "lexmark") == 0 || strcmp (devicename, lexmark_device->sane.name) == 0) break; } *handle = lexmark_device; if (!lexmark_device) { DBG (2, "sane_open: Not a lexmark device\n"); return SANE_STATUS_INVAL; } status = init_options (lexmark_device); if (status != SANE_STATUS_GOOD) return status; status = sanei_lexmark_low_open_device (lexmark_device); DBG (2, "sane_open: end.\n"); return status; } void sane_close (SANE_Handle handle) { Lexmark_Device *lexmark_device; DBG (2, "sane_close: handle=%p\n", (void *) handle); if (!initialized) return; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } if (!lexmark_device) return; sanei_lexmark_low_close_device (lexmark_device); return; } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Lexmark_Device *lexmark_device; DBG (2, "sane_get_option_descriptor: handle=%p, option = %d\n", (void *) handle, option); if (!initialized) return NULL; /* Check for valid option number */ if ((option < 0) || (option >= NUM_OPTIONS)) return NULL; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } if (!lexmark_device) return NULL; if (lexmark_device->opt[option].name) { DBG (2, "sane_get_option_descriptor: name=%s\n", lexmark_device->opt[option].name); } return &(lexmark_device->opt[option]); } /* rebuilds parameters if needed, called each time SANE_INFO_RELOAD_OPTIONS is set */ static void calc_parameters (Lexmark_Device * lexmark_device) { if (strcmp (lexmark_device->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) { lexmark_device->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; } else { lexmark_device->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; } /* changing color mode implies changing gain setting */ if (lexmark_device->val[OPT_MANUAL_GAIN].w == SANE_TRUE) { if (strcmp (lexmark_device->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) != 0) { lexmark_device->opt[OPT_GRAY_GAIN].cap &= ~SANE_CAP_INACTIVE; lexmark_device->opt[OPT_RED_GAIN].cap |= SANE_CAP_INACTIVE; lexmark_device->opt[OPT_GREEN_GAIN].cap |= SANE_CAP_INACTIVE; lexmark_device->opt[OPT_BLUE_GAIN].cap |= SANE_CAP_INACTIVE; } else { lexmark_device->opt[OPT_GRAY_GAIN].cap |= SANE_CAP_INACTIVE; lexmark_device->opt[OPT_RED_GAIN].cap &= ~SANE_CAP_INACTIVE; lexmark_device->opt[OPT_GREEN_GAIN].cap &= ~SANE_CAP_INACTIVE; lexmark_device->opt[OPT_BLUE_GAIN].cap &= ~SANE_CAP_INACTIVE; } } else { lexmark_device->opt[OPT_GRAY_GAIN].cap |= SANE_CAP_INACTIVE; lexmark_device->opt[OPT_RED_GAIN].cap |= SANE_CAP_INACTIVE; lexmark_device->opt[OPT_GREEN_GAIN].cap |= SANE_CAP_INACTIVE; lexmark_device->opt[OPT_BLUE_GAIN].cap |= SANE_CAP_INACTIVE; } } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { Lexmark_Device *lexmark_device; SANE_Status status; SANE_Word w; DBG (2, "sane_control_option: handle=%p, opt=%d, act=%d, val=%p, info=%p\n", (void *) handle, option, action, (void *) value, (void *) info); if (!initialized) return SANE_STATUS_INVAL; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } if (!lexmark_device) return SANE_STATUS_INVAL; if (value == NULL) return SANE_STATUS_INVAL; if (info != NULL) *info = 0; if (option < 0 || option >= NUM_OPTIONS) return SANE_STATUS_INVAL; if (lexmark_device->opt[option].type == SANE_TYPE_GROUP) return SANE_STATUS_INVAL; switch (action) { case SANE_ACTION_SET_AUTO: if (!SANE_OPTION_IS_SETTABLE (lexmark_device->opt[option].cap)) return SANE_STATUS_INVAL; if (!(lexmark_device->opt[option].cap & SANE_CAP_AUTOMATIC)) return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: if (!SANE_OPTION_IS_SETTABLE (lexmark_device->opt[option].cap)) return SANE_STATUS_INVAL; /* Make sure boolean values are only TRUE or FALSE */ if (lexmark_device->opt[option].type == SANE_TYPE_BOOL) { if (! ((*(SANE_Bool *) value == SANE_FALSE) || (*(SANE_Bool *) value == SANE_TRUE))) return SANE_STATUS_INVAL; } /* Check range constraints */ if (lexmark_device->opt[option].constraint_type == SANE_CONSTRAINT_RANGE) { status = sanei_constrain_value (&(lexmark_device->opt[option]), value, info); if (status != SANE_STATUS_GOOD) { DBG (2, "SANE_CONTROL_OPTION: Bad value for range\n"); return SANE_STATUS_INVAL; } } switch (option) { case OPT_NUM_OPTS: case OPT_RESOLUTION: lexmark_device->val[option].w = *(SANE_Int *) value; sane_get_parameters (handle, 0); break; case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: DBG (2, "Option value set to %d (%s)\n", *(SANE_Word *) value, lexmark_device->opt[option].name); lexmark_device->val[option].w = *(SANE_Word *) value; if (lexmark_device->val[OPT_TL_X].w > lexmark_device->val[OPT_BR_X].w) { w = lexmark_device->val[OPT_TL_X].w; lexmark_device->val[OPT_TL_X].w = lexmark_device->val[OPT_BR_X].w; lexmark_device->val[OPT_BR_X].w = w; if (info) *info |= SANE_INFO_RELOAD_PARAMS; } if (lexmark_device->val[OPT_TL_Y].w > lexmark_device->val[OPT_BR_Y].w) { w = lexmark_device->val[OPT_TL_Y].w; lexmark_device->val[OPT_TL_Y].w = lexmark_device->val[OPT_BR_Y].w; lexmark_device->val[OPT_BR_Y].w = w; if (info) *info |= SANE_INFO_RELOAD_PARAMS; } break; case OPT_THRESHOLD: lexmark_device->val[option].w = *(SANE_Fixed *) value; lexmark_device->threshold = (0xFF * lexmark_device->val[option].w) / 100; break; case OPT_PREVIEW: lexmark_device->val[option].w = *(SANE_Int *) value; if (*(SANE_Word *) value) { lexmark_device->y_dpi = lexmark_device->val[OPT_RESOLUTION].w; lexmark_device->val[OPT_RESOLUTION].w = 75; } else { lexmark_device->val[OPT_RESOLUTION].w = lexmark_device->y_dpi; } if (info) *info |= SANE_INFO_RELOAD_OPTIONS; sane_get_parameters (handle, 0); if (info) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_GRAY_GAIN: case OPT_GREEN_GAIN: case OPT_RED_GAIN: case OPT_BLUE_GAIN: lexmark_device->val[option].w = *(SANE_Word *) value; return SANE_STATUS_GOOD; break; case OPT_MODE: strcpy (lexmark_device->val[option].s, value); calc_parameters (lexmark_device); if (info) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_MANUAL_GAIN: w = *(SANE_Word *) value; if (w == lexmark_device->val[OPT_MANUAL_GAIN].w) return SANE_STATUS_GOOD; /* no change */ lexmark_device->val[OPT_MANUAL_GAIN].w = w; calc_parameters (lexmark_device); if (info) *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; } if (info != NULL) *info |= SANE_INFO_RELOAD_PARAMS; break; case SANE_ACTION_GET_VALUE: switch (option) { case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_PREVIEW: case OPT_MANUAL_GAIN: case OPT_GRAY_GAIN: case OPT_GREEN_GAIN: case OPT_RED_GAIN: case OPT_BLUE_GAIN: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: *(SANE_Word *) value = lexmark_device->val[option].w; DBG (2, "Option value = %d (%s)\n", *(SANE_Word *) value, lexmark_device->opt[option].name); break; case OPT_THRESHOLD: *(SANE_Fixed *) value = lexmark_device->val[option].w; DBG (2, "Option value = %f\n", SANE_UNFIX (*(SANE_Fixed *) value)); break; case OPT_MODE: strcpy (value, lexmark_device->val[option].s); break; default: return SANE_STATUS_INVAL; } break; default: return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Lexmark_Device *lexmark_device; SANE_Parameters *device_params; SANE_Int xres, yres, width_px, height_px; SANE_Int channels, bitsperchannel; DBG (2, "sane_get_parameters: handle=%p, params=%p\n", (void *) handle, (void *) params); if (!initialized) return SANE_STATUS_INVAL; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } if (!lexmark_device) return SANE_STATUS_INVAL; yres = lexmark_device->val[OPT_RESOLUTION].w; if (yres == 1200) xres = 600; else xres = yres; /* 24 bit colour = 8 bits/channel for each of the RGB channels */ channels = 3; bitsperchannel = 8; /* If not color there is only 1 channel */ if (strcmp (lexmark_device->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) != 0) { channels = 1; bitsperchannel = 8; } /* geometry in pixels */ width_px = lexmark_device->val[OPT_BR_X].w - lexmark_device->val[OPT_TL_X].w; height_px = lexmark_device->val[OPT_BR_Y].w - lexmark_device->val[OPT_TL_Y].w; DBG (7, "sane_get_parameters: tl=(%d,%d) br=(%d,%d)\n", lexmark_device->val[OPT_TL_X].w, lexmark_device->val[OPT_TL_Y].w, lexmark_device->val[OPT_BR_X].w, lexmark_device->val[OPT_BR_Y].w); /* we must tell the front end the bitsperchannel for lineart is really */ /* only 1, so it can calculate the correct image size */ /* If not color there is only 1 channel */ if (strcmp (lexmark_device->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) { bitsperchannel = 1; } device_params = &(lexmark_device->params); device_params->format = SANE_FRAME_RGB; if (channels == 1) device_params->format = SANE_FRAME_GRAY; device_params->last_frame = SANE_TRUE; device_params->lines = (height_px * yres) / 600; device_params->depth = bitsperchannel; device_params->pixels_per_line = (width_px * xres) / 600; /* we always read an even number of sensor pixels */ if (device_params->pixels_per_line & 1) device_params->pixels_per_line++; /* data_size is the size transferred from the scanner to the backend */ /* therefore bitsperchannel is the same for gray and lineart */ /* note: bytes_per_line has been divided by 8 in lineart mode */ lexmark_device->data_size = channels * device_params->pixels_per_line * device_params->lines; if (bitsperchannel == 1) { device_params->bytes_per_line = (SANE_Int) ((7 + device_params->pixels_per_line) / 8); } else { device_params->bytes_per_line = (SANE_Int) (channels * device_params->pixels_per_line); } DBG (2, "sane_get_parameters: Data size determined as %ld\n", lexmark_device->data_size); DBG (2, "sane_get_parameters: \n"); if (device_params->format == SANE_FRAME_GRAY) DBG (2, " format: SANE_FRAME_GRAY\n"); else if (device_params->format == SANE_FRAME_RGB) DBG (2, " format: SANE_FRAME_RGB\n"); else DBG (2, " format: UNKNOWN\n"); if (device_params->last_frame == SANE_TRUE) DBG (2, " last_frame: TRUE\n"); else DBG (2, " last_frame: FALSE\n"); DBG (2, " lines %d\n", device_params->lines); DBG (2, " depth %d\n", device_params->depth); DBG (2, " pixels_per_line %d\n", device_params->pixels_per_line); DBG (2, " bytes_per_line %d\n", device_params->bytes_per_line); if (params != 0) { params->format = device_params->format; params->last_frame = device_params->last_frame; params->lines = device_params->lines; params->depth = device_params->depth; params->pixels_per_line = device_params->pixels_per_line; params->bytes_per_line = device_params->bytes_per_line; } return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Lexmark_Device *lexmark_device; SANE_Int offset; SANE_Status status; int resolution; DBG (2, "sane_start: handle=%p\n", (void *) handle); if (!initialized) return SANE_STATUS_INVAL; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } sane_get_parameters (handle, 0); if ((lexmark_device->params.lines == 0) || (lexmark_device->params.pixels_per_line == 0) || (lexmark_device->params.bytes_per_line == 0)) { DBG (2, "sane_start: \n"); DBG (2, " ERROR: Zero size encountered in:\n"); DBG (2, " number of lines, bytes per line, or pixels per line\n"); return SANE_STATUS_INVAL; } lexmark_device->device_cancelled = SANE_FALSE; lexmark_device->data_ctr = 0; lexmark_device->eof = SANE_FALSE; /* Need this cancel_ctr to determine how many times sane_cancel is called since it is called more than once. */ lexmark_device->cancel_ctr = 0; /* Find Home */ if (sanei_lexmark_low_search_home_fwd (lexmark_device)) { DBG (2, "sane_start: Scan head initially at home position\n"); } else { /* We may have been rewound too far, so move forward the distance from the edge to the home position */ sanei_lexmark_low_move_fwd (0x01a8, lexmark_device, lexmark_device->shadow_regs); /* Scan backwards until we find home */ sanei_lexmark_low_search_home_bwd (lexmark_device); } /* do calibration before offset detection , use sensor max dpi, not motor's one */ resolution = lexmark_device->val[OPT_RESOLUTION].w; if (resolution > 600) { resolution = 600; } sanei_lexmark_low_set_scan_regs (lexmark_device, resolution, 0, SANE_FALSE); status = sanei_lexmark_low_calibration (lexmark_device); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: calibration failed : %s ! \n", sane_strstatus (status)); return status; } /* At this point we're somewhere in the dot. We need to read a number of lines greater than the diameter of the dot and determine how many lines past the dot we've gone. We then use this information to see how far the scan head must move before starting the scan. */ /* offset is in 600 dpi unit */ offset = sanei_lexmark_low_find_start_line (lexmark_device); DBG (7, "start line offset=%d\n", offset); /* Set the shadow registers for scan with the options (resolution, mode, size) set in the front end. Pass the offset so we can get the vert. start. */ sanei_lexmark_low_set_scan_regs (lexmark_device, lexmark_device->val[OPT_RESOLUTION].w, offset, SANE_TRUE); if (sanei_lexmark_low_start_scan (lexmark_device) == SANE_STATUS_GOOD) { DBG (2, "sane_start: scan started\n"); return SANE_STATUS_GOOD; } else { lexmark_device->device_cancelled = SANE_TRUE; return SANE_STATUS_INVAL; } } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { Lexmark_Device *lexmark_device; long bytes_read; DBG (2, "sane_read: handle=%p, data=%p, max_length = %d, length=%p\n", (void *) handle, (void *) data, max_length, (void *) length); if (!initialized) { DBG (2, "sane_read: Not initialized\n"); return SANE_STATUS_INVAL; } for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } if (lexmark_device->device_cancelled) { DBG (2, "sane_read: Device was cancelled\n"); /* We don't know how far we've gone, so search for home. */ sanei_lexmark_low_search_home_bwd (lexmark_device); return SANE_STATUS_EOF; } if (!length) { DBG (2, "sane_read: NULL length pointer\n"); return SANE_STATUS_INVAL; } *length = 0; if (lexmark_device->eof) { DBG (2, "sane_read: Trying to read past EOF\n"); return SANE_STATUS_EOF; } if (!data) return SANE_STATUS_INVAL; bytes_read = sanei_lexmark_low_read_scan_data (data, max_length, lexmark_device); if (bytes_read < 0) return SANE_STATUS_IO_ERROR; else if (bytes_read == 0) return SANE_STATUS_EOF; else { *length = bytes_read; lexmark_device->data_ctr += bytes_read; } return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Lexmark_Device *lexmark_device; /* ssize_t bytes_read; */ DBG (2, "sane_cancel: handle = %p\n", (void *) handle); if (!initialized) return; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } /*If sane_cancel called more than once, return */ if (++lexmark_device->cancel_ctr > 1) return; /* Set the device flag so the next call to sane_read() can stop the scan. */ lexmark_device->device_cancelled = SANE_TRUE; return; } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Lexmark_Device *lexmark_device; DBG (2, "sane_set_io_mode: handle = %p, non_blocking = %d\n", (void *) handle, non_blocking); if (!initialized) return SANE_STATUS_INVAL; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } if (non_blocking) return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Lexmark_Device *lexmark_device; DBG (2, "sane_get_select_fd: handle = %p, fd %s 0\n", (void *) handle, fd ? "!=" : "="); if (!initialized) return SANE_STATUS_INVAL; for (lexmark_device = first_lexmark_device; lexmark_device; lexmark_device = lexmark_device->next) { if (lexmark_device == handle) break; } return SANE_STATUS_UNSUPPORTED; } /***************************** END OF SANE API ****************************/ /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ sane-backends-1.0.29/backend/mustek_pp.h0000666000000000000000000001564613615534521014764 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000-2003 Jochen Eisinger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef mustek_pp_h #define mustek_pp_h #if defined(HAVE_SYS_TYPES_H) # include #endif #if defined(HAVE_SYS_TIME_H) # include #endif #define DEBUG_NOT_STATIC #include "../include/sane/sanei_debug.h" /* Please note: ASSERT won't go away if you define NDEBUG, it just won't * output a message when ASSERT failes. So if "cond" does anything, it will * be executed, even if NDEBUG is defined... */ #define ASSERT(cond, retval) do { \ if (!(cond)) { \ DBG(2, "assertion %s failed\n", \ STRINGIFY(cond)); \ if (retval >= 0) \ return retval; \ else \ return; \ } \ } /* This macro uses a otherwise unused argument */ #if defined(__GNUC__) # define __UNUSED__ __attribute__ ((unused)) #else # define __UNUSED__ #endif /* the function init uses this callback to register a device to the backend */ typedef SANE_Status (*SANE_Attach_Callback) (SANE_String_Const port, SANE_String_Const name, SANE_Int driver, SANE_Int info); typedef struct { const char *driver; const char *author; const char *version; /* this function detects the presence of a scanner at the * given location */ SANE_Status (*init)(SANE_Int options, SANE_String_Const port, SANE_String_Const name, SANE_Attach_Callback attach); /* this function returns the informationen needed to set up * the device entry. the info parameter is passed from * init to the attach_callback to this function, to * help to identify the device, before it is registered */ void (*capabilities)(SANE_Int info, SANE_String *model, SANE_String *vendor, SANE_String *type, SANE_Int *maxres, SANE_Int *minres, SANE_Int *maxhsize, SANE_Int *maxvsize, SANE_Int *caps); /* tries to open the given device. returns a fd on success */ SANE_Status (*open)(SANE_String port, SANE_Int caps, SANE_Int *fd); /* start scanning session */ void (*setup)(SANE_Handle hndl); /* processes a configuration option */ SANE_Status (*config)(SANE_Handle hndl, SANE_String_Const optname, SANE_String_Const optval); /* stop scanning session */ void (*close)(SANE_Handle hndl); /* start actuall scan */ SANE_Status (*start)(SANE_Handle hndl); /* read data (one line) */ void (*read)(SANE_Handle hndl, SANE_Byte *buffer); /* stop scanner and return scanhead home */ void (*stop)(SANE_Handle hndl); } Mustek_pp_Functions; /* Drivers */ #define MUSTEK_PP_NUM_DRIVERS ((int)(sizeof(Mustek_pp_Drivers) / \ sizeof(Mustek_pp_Functions))) #define CAP_NOTHING 0 #define CAP_GAMMA_CORRECT 1 #define CAP_INVERT 2 #define CAP_SPEED_SELECT 4 #define CAP_LAMP_OFF 8 #define CAP_TA 16 #define CAP_DEPTH 32 /* Structure for holding name/value options from the configuration file */ typedef struct Mustek_pp_config_option { SANE_String name; SANE_String value; } Mustek_pp_config_option; typedef struct Mustek_pp_Device { struct Mustek_pp_Device *next; SANE_Device sane; /* non-const copy of SANE_Device */ SANE_String name, vendor, model, type; /* port */ SANE_String port; /* part describing hardware capabilities */ int minres; int maxres; int maxhsize; int maxvsize; int caps; /* functions */ Mustek_pp_Functions *func; /* Modified by EDG: device identification is needed to initialize private device descriptor */ SANE_Int info; /* Array of configuration file options */ int numcfgoptions; Mustek_pp_config_option *cfgoptions; } Mustek_pp_Device; #define STATE_IDLE 0 #define STATE_CANCELLED 1 #define STATE_SCANNING 2 #define MODE_BW 0 #define MODE_GRAYSCALE 1 #define MODE_COLOR 2 #define SPEED_SLOWEST 0 #define SPEED_SLOWER 1 #define SPEED_NORMAL 2 #define SPEED_FASTER 3 #define SPEED_FASTEST 4 enum Mustek_pp_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_DEPTH, OPT_RESOLUTION, OPT_PREVIEW, OPT_GRAY_PREVIEW, OPT_SPEED, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_INVERT, OPT_CUSTOM_GAMMA, /* use custom gamma tables? */ /* The gamma vectors MUST appear in the order gray, red, green, blue. */ OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, /* must come last: */ NUM_OPTIONS }; typedef struct Mustek_pp_Handle { struct Mustek_pp_Handle *next; Mustek_pp_Device *dev; int fd; int reader; int pipe; int state; int topX, topY; int bottomX, bottomY; int mode; int res; /* gamma table, etc... */ SANE_Int gamma_table[4][256]; int do_gamma; int invert; int use_ta; int depth; int speed; /* current parameters */ SANE_Parameters params; SANE_Range dpi_range; SANE_Range x_range; SANE_Range y_range; SANE_Range gamma_range; /* options */ SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; time_t lamp_on; void *priv; } Mustek_pp_Handle; #endif /* mustek_pp_h */ sane-backends-1.0.29/backend/niash_xfer.c0000666000000000000000000002131713615534521015066 00000000000000/* Copyright (C) 2001 Bertrik Sikken (bertrik@zonnet.nl) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $Id$ */ /* Provides a simple interface to read and write data from the scanner, without any knowledge whether it's a parallel or USB scanner */ #include /* printf */ #include /* better error reports */ #include /* better error reports */ #include "niash_xfer.h" #include "../include/sane/sanei_usb.h" /* list of supported models */ STATIC TScannerModel ScannerModels[] = { {"Hewlett-Packard", "ScanJet 3300C", 0x3F0, 0x205, eHp3300c} , {"Hewlett-Packard", "ScanJet 3400C", 0x3F0, 0x405, eHp3400c} , {"Hewlett-Packard", "ScanJet 4300C", 0x3F0, 0x305, eHp4300c} , {"Silitek Corp.", "HP ScanJet 4300c", 0x47b, 0x1002, eHp3400c} , {"Agfa", "Snapscan Touch", 0x6BD, 0x100, eAgfaTouch} , {"Trust", "Office Scanner USB 19200", 0x47b, 0x1000, eAgfaTouch} , /* last entry all zeros */ {0, 0, 0, 0, 0} }; static TFnReportDevice *_pfnReportDevice; static TScannerModel *_pModel; /* MatchUsbDevice ============== Matches a given USB vendor and product id against a list of supported scanners. IN iVendor USB vendor ID iProduct USB product ID OUT *ppModel Pointer to TScannerModel structure Returns TRUE if a matching USB scanner was found */ STATIC SANE_Bool MatchUsbDevice (int iVendor, int iProduct, TScannerModel ** ppModel) { TScannerModel *pModels = ScannerModels; DBG (DBG_MSG, "Matching USB device 0x%04X-0x%04X ... ", iVendor, iProduct); while (pModels->pszName != NULL) { if ((pModels->iVendor == iVendor) && (pModels->iProduct == iProduct)) { DBG (DBG_MSG, "found %s %s\n", pModels->pszVendor, pModels->pszName); *ppModel = pModels; return SANE_TRUE; } /* next model to match */ pModels++; } DBG (DBG_MSG, "nothing found\n"); return SANE_FALSE; } /************************************************************************ Public functions for the SANE compilation ************************************************************************/ /* callback for sanei_usb_attach_matching_devices */ static SANE_Status _AttachUsb (SANE_String_Const devname) { DBG (DBG_MSG, "_AttachUsb: found %s\n", devname); _pfnReportDevice (_pModel, (const char *) devname); return SANE_STATUS_GOOD; } /* NiashXferInit =============== Initialises all registered data transfer modules, which causes them to report any devices found through the pfnReport callback. IN pfnReport Function to call to report a transfer device */ static void NiashXferInit (TFnReportDevice * pfnReport) { TScannerModel *pModels = ScannerModels; sanei_usb_init (); _pfnReportDevice = pfnReport; /* loop over all scanner models */ while (pModels->pszName != NULL) { DBG (DBG_MSG, "Looking for %s...\n", pModels->pszName); _pModel = pModels; if (sanei_usb_find_devices ((SANE_Int) pModels->iVendor, (SANE_Int) pModels->iProduct, _AttachUsb) != SANE_STATUS_GOOD) { DBG (DBG_ERR, "Error invoking sanei_usb_find_devices"); break; } pModels++; } } static int NiashXferOpen (const char *pszName, EScannerModel * peModel) { SANE_Status status; SANE_Word vendor, product; int fd; TScannerModel *pModel = 0; DBG (DBG_MSG, "Trying to open %s...\n", pszName); status = sanei_usb_open (pszName, &fd); if (status != SANE_STATUS_GOOD) { return -1; } status = sanei_usb_get_vendor_product (fd, &vendor, &product); if (status == SANE_STATUS_GOOD) { MatchUsbDevice (vendor, product, &pModel); *peModel = pModel->eModel; } DBG (DBG_MSG, "handle = %d\n", (int) fd); return fd; } static void NiashXferClose (int iHandle) { /* close usb device */ if (iHandle != -1) { sanei_usb_close (iHandle); } } static void parusb_write_reg (int fd, unsigned char bReg, unsigned char bValue) { sanei_usb_control_msg (fd, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 0x0C, bReg, 0, 1, &bValue); } static void parusb_read_reg (int fd, unsigned char bReg, unsigned char *pbValue) { sanei_usb_control_msg (fd, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 0x0C, bReg, 0, 1, pbValue); } static void NiashWriteReg (int iHandle, unsigned char bReg, unsigned char bData) { if (iHandle < 0) { DBG (DBG_MSG, "Invalid handle %d\n", iHandle); return; } parusb_write_reg (iHandle, SPP_CONTROL, 0x14); parusb_write_reg (iHandle, EPP_ADDR, bReg); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); parusb_write_reg (iHandle, EPP_DATA_WRITE, bData); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); } static void NiashReadReg (int iHandle, unsigned char bReg, unsigned char *pbData) { if (iHandle < 0) { return; } parusb_write_reg (iHandle, SPP_CONTROL, 0x14); parusb_write_reg (iHandle, EPP_ADDR, bReg); parusb_write_reg (iHandle, SPP_CONTROL, 0x34); parusb_read_reg (iHandle, EPP_DATA_READ, pbData); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); } static void NiashWriteBulk (int iHandle, unsigned char *pabBuf, int iSize) { /* byte abSetup[8] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; HP3400 probably needs 0x01, 0x01 */ SANE_Byte abSetup[8] = { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; size_t size; if (iHandle < 0) { return; } /* select scanner register 0x24 */ parusb_write_reg (iHandle, SPP_CONTROL, 0x14); parusb_write_reg (iHandle, EPP_ADDR, 0x24); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); /* tell scanner that a bulk transfer follows */ abSetup[4] = (iSize) & 0xFF; abSetup[5] = (iSize >> 8) & 0xFF; sanei_usb_control_msg (iHandle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 0x04, USB_SETUP, 0, 8, abSetup); /* do the bulk write */ size = iSize; if (sanei_usb_write_bulk (iHandle, pabBuf, &size) != SANE_STATUS_GOOD) { DBG (DBG_ERR, "ERROR: Bulk write failed\n"); } } static void NiashReadBulk (int iHandle, unsigned char *pabBuf, int iSize) { SANE_Byte abSetup[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; size_t size; if (iHandle < 0) { return; } /* select scanner register 0x24 */ parusb_write_reg (iHandle, SPP_CONTROL, 0x14); parusb_write_reg (iHandle, EPP_ADDR, 0x24); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); /* tell scanner that a bulk transfer follows */ abSetup[4] = (iSize) & 0xFF; abSetup[5] = (iSize >> 8) & 0xFF; sanei_usb_control_msg (iHandle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 0x04, USB_SETUP, 0, 8, abSetup); /* do the bulk read */ size = iSize; if (sanei_usb_read_bulk (iHandle, pabBuf, &size) != SANE_STATUS_GOOD) { DBG (DBG_ERR, "ERROR: Bulk read failed\n"); } } static void NiashWakeup (int iHandle) { unsigned char abMagic[] = { 0xA0, 0xA8, 0x50, 0x58, 0x90, 0x98, 0xC0, 0xC8, 0x90, 0x98, 0xE0, 0xE8 }; int i; if (iHandle < 0) { return; } /* write magic startup sequence */ parusb_write_reg (iHandle, SPP_CONTROL, 0x14); for (i = 0; i < (int) sizeof (abMagic); i++) { parusb_write_reg (iHandle, SPP_DATA, abMagic[i]); } /* write 0x04 to scanner register 0x00 the hard way */ parusb_write_reg (iHandle, SPP_DATA, 0x00); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); parusb_write_reg (iHandle, SPP_CONTROL, 0x15); parusb_write_reg (iHandle, SPP_CONTROL, 0x1D); parusb_write_reg (iHandle, SPP_CONTROL, 0x15); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); parusb_write_reg (iHandle, SPP_DATA, 0x04); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); parusb_write_reg (iHandle, SPP_CONTROL, 0x15); parusb_write_reg (iHandle, SPP_CONTROL, 0x17); parusb_write_reg (iHandle, SPP_CONTROL, 0x15); parusb_write_reg (iHandle, SPP_CONTROL, 0x14); } sane-backends-1.0.29/backend/st400.h0000666000000000000000000000310413615534521013611 00000000000000#ifndef st400_h #define st400_h #define ST400_CONFIG_FILE "st400.conf" #define ST400_DEFAULT_DEVICE "/dev/scanner" /* maximum scanning area in inch (guessed) */ #define ST400_MAX_X 8.5 #define ST400_MAX_Y 12.0 enum ST400_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_RESOLUTION, OPT_DEPTH, OPT_THRESHOLD, OPT_GEOMETRY_GROUP, OPT_TL_X, OPT_TL_Y, OPT_BR_X, OPT_BR_Y, NUM_OPTIONS /* must be last */ }; typedef struct { size_t inq_voffset; /* offset in INQUIRY result */ char *inq_vendor; size_t inq_moffset; /* offset in INQUIRY result */ char *inq_model; size_t bits; /* 6 or 8 */ unsigned long bufsize; /* internal buffer of scanner */ unsigned long maxread; /* max bytes to read in a cmd (0 = no limit) */ SANE_Int *dpi_list; /* NULL for default list */ char *sane_vendor; char *sane_model; char *sane_type; } ST400_Model; typedef struct ST400_Device { struct ST400_Device *next; SANE_Device sane; SANE_Parameters params; SANE_Option_Descriptor opt[NUM_OPTIONS]; SANE_Word val[NUM_OPTIONS]; struct { unsigned open :1; unsigned scanning :1; unsigned eof :1; } status; /* pixel values of entire scan window - for convenience */ unsigned short x, y, w, h; int fd; /* SCSI filedescriptor */ /* backend buffer */ SANE_Byte *buffer; size_t bufsize; SANE_Byte *bufp; /* next byte to transfer */ size_t bytes_in_buffer; ST400_Model *model; /* scanner buffer */ unsigned short wy, wh; /* current subwindow */ unsigned long bytes_in_scanner; unsigned short lines_to_read; } ST400_Device; #endif /* st400_h */ /* The End */ sane-backends-1.0.29/backend/u12.c0000666000000000000000000014461213615534521013353 00000000000000/** @file u12.c * @brief SANE backend for USB scanner, based on Plusteks' ASIC P98003 and * the GeneSys Logic GL640 parallel-port to USB bridge. * * Based on source aquired from Plustek
* Copyright (c) 2003-2004 Gerhard Jaeger
* * History: * - 0.01 - initial version * - 0.02 - enabled other scan-modes * - increased default gamma to 1.5 *. *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #ifdef _AIX # include "../include/lalloca.h" /* MUST come first for AIX! */ #endif #include "../include/sane/config.h" #include "../include/lalloca.h" #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_SYS_TIME_H #include #endif #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #define BACKEND_VERSION "0.02-11" #define BACKEND_NAME u12 #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_thread.h" #include "../include/sane/sanei_usb.h" #define ALL_MODES #include "u12-scanner.h" #include "u12-hwdef.h" #include "u12.h" /*********************** the debug levels ************************************/ #define _DBG_FATAL 0 #define _DBG_ERROR 1 #define _DBG_WARNING 3 #define _DBG_INFO 5 #define _DBG_PROC 7 #define _DBG_SANE_INIT 10 #define _DBG_IO 128 #define _DBG_READ 255 /* uncomment this for testing... */ /*#define _FAKE_DEVICE */ /*****************************************************************************/ #define _SECTION "[usb]" #define _DEFAULT_DEVICE "auto" /* including the "worker" code... */ #include "u12-io.c" #include "u12-ccd.c" #include "u12-hw.c" #include "u12-motor.c" #include "u12-image.c" #include "u12-map.c" #include "u12-shading.c" #include "u12-tpa.c" #include "u12-if.c" /************************** global vars **************************************/ static int num_devices; static U12_Device *first_dev; static U12_Scanner *first_handle; static const SANE_Device **devlist = 0; static unsigned long tsecs = 0; static SANE_Bool cancelRead; #ifdef ALL_MODES static ModeParam mode_params[] = { {0, 1, COLOR_BW}, {0, 8, COLOR_256GRAY}, {1, 8, COLOR_TRUE24}, {1, 16, COLOR_TRUE42} }; static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, SANE_I18N("Color 36"), NULL }; static const SANE_String_Const src_list[] = { SANE_I18N("Normal"), SANE_I18N("Transparency"), SANE_I18N("Negative"), NULL }; #endif static const SANE_Range percentage_range = { SANE_FIX(-100), /* minimum */ SANE_FIX( 100), /* maximum */ SANE_FIX( 1) /* quantization */ }; /* authorization stuff */ static SANE_Auth_Callback auth = NULL; /****************************** the backend... *******************************/ #define _YN(x) (x?"yes":"no") /** * function to display the configuration options for the current device * @param cnf - pointer to the configuration structure whose content should be * displayed */ static void show_cnf( pCnfDef cnf ) { DBG( _DBG_SANE_INIT,"Device configuration:\n" ); DBG( _DBG_SANE_INIT,"device name : >%s<\n",cnf->devName ); DBG( _DBG_SANE_INIT,"USB-ID : >%s<\n",cnf->usbId ); DBG( _DBG_SANE_INIT,"warmup : %ds\n", cnf->adj.warmup ); DBG( _DBG_SANE_INIT,"lampOff : %d\n", cnf->adj.lampOff ); DBG( _DBG_SANE_INIT,"lampOffOnEnd : %s\n", _YN(cnf->adj.lampOffOnEnd )); DBG( _DBG_SANE_INIT,"red Gamma : %.2f\n",cnf->adj.rgamma ); DBG( _DBG_SANE_INIT,"green Gamma : %.2f\n",cnf->adj.ggamma ); DBG( _DBG_SANE_INIT,"blue Gamma : %.2f\n",cnf->adj.bgamma ); DBG( _DBG_SANE_INIT,"gray Gamma : %.2f\n",cnf->adj.graygamma ); DBG( _DBG_SANE_INIT,"---------------------\n" ); } /** Calls the device specific stop and close functions. * @param dev - pointer to the device specific structure * @return The function always returns SANE_STATUS_GOOD */ static SANE_Status drvClose( U12_Device *dev ) { if( dev->fd >= 0 ) { DBG( _DBG_INFO, "drvClose()\n" ); if( 0 != tsecs ) { DBG( _DBG_INFO, "TIME END 1: %lus\n", time(NULL)-tsecs); } /* don't check the return values, simply do it */ u12if_stopScan( dev ); u12if_close ( dev ); } dev->fd = -1; return SANE_STATUS_GOOD; } /** as the name says, close our pipes * @param scanner - * @return */ static SANE_Status drvClosePipes( U12_Scanner *scanner ) { if( scanner->r_pipe >= 0 ) { DBG( _DBG_PROC, "drvClosePipes(r_pipe)\n" ); close( scanner->r_pipe ); scanner->r_pipe = -1; } if( scanner->w_pipe >= 0 ) { DBG( _DBG_PROC, "drvClosePipes(w_pipe)\n" ); close( scanner->w_pipe ); scanner->w_pipe = -1; } return SANE_STATUS_EOF; } #ifdef ALL_MODES /** according to the mode and source we return the corresponding mode list */ static pModeParam getModeList( U12_Scanner *scanner ) { pModeParam mp = mode_params; /* the transparency/negative mode supports only gray and color */ if( 0 != scanner->val[OPT_EXT_MODE].w ) { mp = &mp[_TPAModeSupportMin]; } return mp; } #endif /** goes through a string list and returns the start-address of the string * that has been found, or NULL on error */ static const SANE_String_Const *search_string_list( const SANE_String_Const *list, SANE_String value ) { while( *list != NULL && strcmp(value, *list) != 0 ) ++list; if( *list == NULL ) return NULL; return list; } /** */ static void sig_chldhandler( int signo ) { DBG( _DBG_PROC, "(SIG) Child is down (signal=%d)\n", signo ); } /** signal handler to kill the child process */ 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 void usb_reader_process_sigterm_handler( int signo ) { DBG( _DBG_PROC, "(SIG) reader_process: terminated by signal %d\n", signo ); cancelRead = SANE_TRUE; } static void sigalarm_handler( int signo ) { _VAR_NOT_USED( signo ); DBG( _DBG_PROC, "ALARM!!!\n" ); } /** executed as a child process * read the data from the driver and send them to the parent process */ static int reader_process( void *args ) { int line; unsigned char *buf; unsigned long data_length; struct SIGACTION act; sigset_t ignore_set; SANE_Status status; U12_Scanner *scanner = (U12_Scanner *)args; if( sanei_thread_is_forked()) { DBG( _DBG_PROC, "reader_process started (forked)\n" ); close( scanner->r_pipe ); scanner->r_pipe = -1; } else { DBG( _DBG_PROC, "reader_process started (as thread)\n" ); } sigfillset ( &ignore_set ); sigdelset ( &ignore_set, SIGTERM ); #if defined (__APPLE__) && defined (__MACH__) sigdelset ( &ignore_set, SIGUSR2 ); #endif sigprocmask( SIG_SETMASK, &ignore_set, 0 ); cancelRead = SANE_FALSE; /* install the signal handler */ memset( &act, 0, sizeof (act)); sigemptyset(&(act.sa_mask)); act.sa_flags = 0; act.sa_handler = reader_process_sigterm_handler; sigaction( SIGTERM, &act, 0 ); act.sa_handler = usb_reader_process_sigterm_handler; sigaction( SIGUSR1, &act, 0 ); data_length = scanner->params.lines * scanner->params.bytes_per_line; DBG( _DBG_PROC, "reader_process:" "starting to READ data (%lu bytes)\n", data_length ); DBG( _DBG_PROC, "buf = 0x%08lx\n", (unsigned long)scanner->buf ); if( NULL == scanner->buf ) { DBG( _DBG_FATAL, "NULL Pointer !!!!\n" ); return SANE_STATUS_IO_ERROR; } /* here we read all data from the scanner... */ buf = scanner->buf; status = u12if_prepare( scanner->hw ); if( SANE_STATUS_GOOD == status ) { for( line = 0; line < scanner->params.lines; line++ ) { status = u12if_readLine( scanner->hw, buf ); if( SANE_STATUS_GOOD != status ) { break; } write( scanner->w_pipe, buf, scanner->params.bytes_per_line ); buf += scanner->params.bytes_per_line; } } close( scanner->w_pipe ); scanner->w_pipe = -1; /* on error, there's no need to clean up, as this is done by the parent */ if( SANE_STATUS_GOOD != status ) { DBG( _DBG_ERROR, "read failed, status = %i\n", (int)status ); return status; } DBG( _DBG_PROC, "reader_process: finished reading data\n" ); return SANE_STATUS_GOOD; } /** stop the current scan process */ static SANE_Status do_cancel( U12_Scanner *scanner, SANE_Bool closepipe ) { struct SIGACTION act; SANE_Pid res; DBG( _DBG_PROC,"do_cancel\n" ); scanner->scanning = SANE_FALSE; if( sanei_thread_is_valid (scanner->reader_pid) ) { DBG( _DBG_PROC, "---- killing reader_process ----\n" ); cancelRead = SANE_TRUE; sigemptyset(&(act.sa_mask)); act.sa_flags = 0; act.sa_handler = sigalarm_handler; sigaction( SIGALRM, &act, 0 ); /* kill our child process and wait until done */ sanei_thread_sendsig( scanner->reader_pid, SIGUSR1 ); /* give'em 10 seconds 'til done...*/ alarm(10); res = sanei_thread_waitpid( scanner->reader_pid, 0 ); alarm(0); if( res != scanner->reader_pid ) { DBG( _DBG_PROC,"sanei_thread_waitpid() failed !\n"); /* do it the hard way...*/ #ifdef USE_PTHREAD sanei_thread_kill( scanner->reader_pid ); #else sanei_thread_sendsig( scanner->reader_pid, SIGKILL ); #endif } sanei_thread_invalidate( scanner->reader_pid ); DBG( _DBG_PROC, "reader_process killed\n"); if( scanner->hw->fd >= 0 ) { u12hw_CancelSequence( scanner->hw ); } #ifndef HAVE_SETITIMER u12hw_StartLampTimer( scanner->hw ); #endif } if( SANE_TRUE == closepipe ) { drvClosePipes( scanner ); } drvClose( scanner->hw ); if( tsecs != 0 ) { DBG( _DBG_INFO, "TIME END 2: %lus\n", time(NULL)-tsecs); tsecs = 0; } return SANE_STATUS_CANCELLED; } /** initialize the options for the backend according to the device we have */ static SANE_Status init_options( U12_Scanner *s ) { int i; memset( s->opt, 0, sizeof(s->opt)); for( i = 0; i < NUM_OPTIONS; ++i ) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].unit = SANE_UNIT_NONE; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->opt[OPT_NUM_OPTS].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Scan Mode" group: */ s->opt[OPT_MODE_GROUP].name = "scanmode-group"; s->opt[OPT_MODE_GROUP].title = SANE_I18N("Scan Mode"); s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; #ifdef ALL_MODES /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = 32; s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].w = COLOR_TRUE24; /* scan source */ s->opt[OPT_EXT_MODE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_EXT_MODE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_EXT_MODE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_EXT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_EXT_MODE].size = 32; s->opt[OPT_EXT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_EXT_MODE].constraint.string_list = src_list; s->val[OPT_EXT_MODE].w = 0; /* Normal */ #endif /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_FIXED; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_PERCENT; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &percentage_range; s->val[OPT_BRIGHTNESS].w = 0; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_FIXED; s->opt[OPT_CONTRAST].unit = SANE_UNIT_PERCENT; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &percentage_range; s->val[OPT_CONTRAST].w = 0; /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_RESOLUTION].constraint.range = &s->hw->dpi_range; s->val[OPT_RESOLUTION].w = s->hw->dpi_range.min; /* custom-gamma table */ s->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; s->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->val[OPT_PREVIEW].w = 0; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].name = "geometry-group"; s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N("Geometry"); s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->val[OPT_TL_X].w = SANE_FIX(_DEFAULT_TLX); /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->val[OPT_TL_Y].w = SANE_FIX(_DEFAULT_TLY); /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->val[OPT_BR_X].w = SANE_FIX(_DEFAULT_BRX); /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; s->val[OPT_BR_Y].w = SANE_FIX(_DEFAULT_BRY); /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N("Enhancement"); s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; u12map_InitGammaSettings( s->hw ); /* grayscale gamma vector */ s->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR].wa = &(s->hw->gamma_table[0][0]); s->opt[OPT_GAMMA_VECTOR].constraint.range = &(s->hw->gamma_range); s->opt[OPT_GAMMA_VECTOR].size = s->hw->gamma_length * sizeof(SANE_Word); /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_R].wa = &(s->hw->gamma_table[1][0]); s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &(s->hw->gamma_range); s->opt[OPT_GAMMA_VECTOR_R].size = s->hw->gamma_length * sizeof(SANE_Word); /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_G].wa = &(s->hw->gamma_table[2][0]); s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &(s->hw->gamma_range); s->opt[OPT_GAMMA_VECTOR_G].size = s->hw->gamma_length * sizeof(SANE_Word); /* blue gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_B].wa = &(s->hw->gamma_table[3][0]); s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &(s->hw->gamma_range); s->opt[OPT_GAMMA_VECTOR_B].size = s->hw->gamma_length * sizeof(SANE_Word); /* GAMMA stuff is disabled per default */ s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; #ifdef ALL_MODES /* disable extended mode list for devices without TPA */ if( SANE_FALSE == s->hw->Tpa ) { s->opt[OPT_EXT_MODE].cap |= SANE_CAP_INACTIVE; } #endif return SANE_STATUS_GOOD; } /** Function to retrieve the vendor and product id from a given string * @param src - string, that should be investigated * @param dest - pointer to a string to receive the USB ID */ static void decodeUsbIDs( char *src, char **dest ) { const char *name; char *tmp = *dest; int len = strlen(_SECTION); if( isspace(src[len])) { strncpy( tmp, &src[len+1], (strlen(src)-(len+1))); tmp[(strlen(src)-(len+1))] = '\0'; } name = tmp; name = sanei_config_skip_whitespace( name ); if( '\0' == name[0] ) { DBG( _DBG_SANE_INIT, "next device uses autodetection\n" ); } else { u_short pi = 0, vi = 0; if( *name ) { name = sanei_config_get_string( name, &tmp ); if( tmp ) { vi = strtol( tmp, 0, 0 ); free( tmp ); } } name = sanei_config_skip_whitespace( name ); if( *name ) { name = sanei_config_get_string( name, &tmp ); if( tmp ) { pi = strtol( tmp, 0, 0 ); free( tmp ); } } /* create what we need to go through our device list...*/ sprintf( *dest, "0x%04X-0x%04X", vi, pi ); DBG( _DBG_SANE_INIT, "next device is a USB device (%s)\n", *dest ); } } #define _INT 0 #define _FLOAT 1 /** function to decode an value and give it back to the caller. * @param src - pointer to the source string to check * @param opt - string that keeps the option name to check src for * @param what - _FLOAT or _INT * @param result - pointer to the var that should receive our result * @param def - default value that result should be in case of any error * @return The function returns SANE_TRUE if the option has been found, * if not, it returns SANE_FALSE */ static SANE_Bool decodeVal( char *src, char *opt, int what, void *result, void *def ) { char *tmp, *tmp2; const char *name; /* skip the option string */ name = (const char*)&src[strlen("option")]; /* get the name of the option */ name = sanei_config_get_string( name, &tmp ); if( tmp ) { /* on success, compare wiht the given one */ if( 0 == strcmp( tmp, opt )) { DBG( _DBG_SANE_INIT, "Decoding option >%s<\n", opt ); if( _INT == what ) { /* assign the default value for this option... */ *((int*)result) = *((int*)def); if( *name ) { /* get the configuration value and decode it */ name = sanei_config_get_string( name, &tmp2 ); if( tmp2 ) { *((int*)result) = strtol( tmp2, 0, 0 ); free( tmp2 ); } } free( tmp ); return SANE_TRUE; } else if( _FLOAT == what ) { /* assign the default value for this option... */ *((double*)result) = *((double*)def); if( *name ) { /* get the configuration value and decode it */ name = sanei_config_get_string( name, &tmp2 ); if( tmp2 ) { *((double*)result) = strtod( tmp2, 0 ); free( tmp2 ); } } free( tmp ); return SANE_TRUE; } } free( tmp ); } return SANE_FALSE; } /** function to retrive the device name of a given string * @param src - string that keeps the option name to check src for * @param dest - pointer to the string, that should receive the detected * devicename * @return The function returns SANE_TRUE if the devicename has been found, * if not, it returns SANE_FALSE */ static SANE_Bool decodeDevName( char *src, char *dest ) { char *tmp; const char *name; if( 0 == strncmp( "device", src, 6 )) { name = (const char*)&src[strlen("device")]; name = sanei_config_skip_whitespace( name ); DBG( _DBG_SANE_INIT, "Decoding device name >%s<\n", name ); if( *name ) { name = sanei_config_get_string( name, &tmp ); if( tmp ) { strcpy( dest, tmp ); free( tmp ); return SANE_TRUE; } } } return SANE_FALSE; } /** attach a device to the backend */ static SANE_Status attach( const char *dev_name, pCnfDef cnf, U12_Device **devp ) { int result; int handle; U12_Device *dev; DBG( _DBG_SANE_INIT, "attach (%s, %p, %p)\n", dev_name, (void *)cnf, (void *)devp); /* already attached ?*/ for( dev = first_dev; dev; dev = dev->next ) { if( 0 == strcmp( dev->sane.name, dev_name )) { if( devp ) *devp = dev; return SANE_STATUS_GOOD; } } /* allocate some memory for the device */ dev = malloc( sizeof (*dev)); if( NULL == dev ) return SANE_STATUS_NO_MEM; /* assign all the stuff we need fo this device... */ memset(dev, 0, sizeof (*dev)); dev->fd = -1; dev->name = strdup(dev_name); /* hold it double to avoid */ dev->sane.name = dev->name; /* compiler warnings */ dev->sane.vendor = "Plustek"; dev->sane.model = "U12/1212U"; dev->sane.type = SANE_I18N ("flatbed scanner"); dev->initialized = SANE_FALSE; memcpy( &dev->adj, &cnf->adj, sizeof(AdjDef)); show_cnf( cnf ); strncpy( dev->usbId, cnf->usbId, _MAX_ID_LEN ); /* go ahead and open the scanner device */ handle = u12if_open( dev ); if( handle < 0 ) { DBG( _DBG_ERROR,"open failed: %d\n", handle ); return SANE_STATUS_IO_ERROR; } /* okay, so assign the handle... */ dev->fd = handle; /* now check what we have */ result = u12if_getCaps( dev ); if( result < 0 ) { DBG( _DBG_ERROR, "u12if_getCaps() failed(%d)\n", result); u12if_close( dev ); return SANE_STATUS_IO_ERROR; } /* save the info we got from the driver */ DBG( _DBG_INFO, "Scanner information:\n" ); DBG( _DBG_INFO, "Vendor : %s\n", dev->sane.vendor ); DBG( _DBG_INFO, "Model : %s\n", dev->sane.model ); DBG( _DBG_INFO, "Flags : 0x%08lx\n", dev->caps.flag ); if( SANE_STATUS_GOOD != u12if_SetupBuffer( dev )) { DBG( _DBG_ERROR, "u12if_SetupBuffer() failed\n" ); u12if_close( dev ); return SANE_STATUS_NO_MEM; } drvClose( dev ); DBG( _DBG_SANE_INIT, "attach: model = >%s<\n", dev->sane.model ); ++num_devices; dev->next = first_dev; first_dev = dev; if( devp ) *devp = dev; return SANE_STATUS_GOOD; } /** function to preset a configuration structure * @param cnf - pointer to the structure that should be initialized */ static void init_config_struct( pCnfDef cnf ) { memset( cnf, 0, sizeof(CnfDef)); cnf->adj.warmup = -1; cnf->adj.lampOff = -1; cnf->adj.lampOffOnEnd = -1; cnf->adj.graygamma = 1.0; cnf->adj.rgamma = 1.0; cnf->adj.ggamma = 1.0; cnf->adj.bgamma = 1.0; } /** intialize the backend */ SANE_Status sane_init( SANE_Int *version_code, SANE_Auth_Callback authorize ) { char str[PATH_MAX] = _DEFAULT_DEVICE; CnfDef config; size_t len; FILE *fp; DBG_INIT(); sanei_usb_init(); sanei_thread_init(); DBG( _DBG_INFO, "U12 backend V" BACKEND_VERSION", part of "PACKAGE " " VERSION "\n"); /* do some presettings... */ auth = authorize; first_dev = NULL; first_handle = NULL; num_devices = 0; /* initialize the configuration structure */ init_config_struct( &config ); if( version_code != NULL ) *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open( U12_CONFIG_FILE ); /* default to _DEFAULT_DEVICE instead of insisting on config file */ if( NULL == fp ) { return attach( _DEFAULT_DEVICE, &config, 0 ); } while( sanei_config_read( str, sizeof(str), fp)) { DBG( _DBG_SANE_INIT, ">%s<\n", str ); if( str[0] == '#') /* ignore line comments */ continue; len = strlen(str); if( 0 == len ) continue; /* ignore empty lines */ /* check for options */ if( 0 == strncmp(str, "option", 6)) { int ival; double dval; ival = -1; decodeVal( str, "warmup", _INT, &config.adj.warmup, &ival); decodeVal( str, "lampOff", _INT, &config.adj.lampOff, &ival); decodeVal( str, "lOffOnEnd", _INT, &config.adj.lampOffOnEnd,&ival); ival = 0; dval = 1.5; decodeVal( str, "grayGamma", _FLOAT, &config.adj.graygamma,&dval); decodeVal( str, "redGamma", _FLOAT, &config.adj.rgamma, &dval ); decodeVal( str, "greenGamma", _FLOAT, &config.adj.ggamma, &dval ); decodeVal( str, "blueGamma", _FLOAT, &config.adj.bgamma, &dval ); continue; /* check for sections: */ } else if( 0 == strncmp( str, _SECTION, strlen(_SECTION))) { char *tmp; /* new section, try and attach previous device */ if( config.devName[0] != '\0' ) { attach( config.devName, &config, 0 ); } else { if( first_dev != NULL ) { DBG( _DBG_WARNING, "section contains no device name," " ignored!\n" ); } } /* re-initialize the configuration structure */ init_config_struct( &config ); tmp = config.usbId; decodeUsbIDs( str, &tmp ); DBG( _DBG_SANE_INIT, "... next device\n" ); continue; } else if( SANE_TRUE == decodeDevName( str, config.devName )) { continue; } /* ignore other stuff... */ DBG( _DBG_SANE_INIT, "ignoring >%s<\n", str ); } fclose( fp ); /* try to attach the last device in the config file... */ if( config.devName[0] != '\0' ) attach( config.devName, &config, 0 ); return SANE_STATUS_GOOD; } /** cleanup the backend... */ void sane_exit( void ) { U12_Device *dev, *next; DBG( _DBG_SANE_INIT, "sane_exit\n" ); for( dev = first_dev; dev; ) { next = dev->next; u12if_shutdown( dev ); /* * we're doin' this to avoid compiler warnings as dev->sane.name * is defined as const char* */ if( dev->sane.name ) free( dev->name ); if( dev->res_list ) free( dev->res_list ); free( dev ); dev = next; } if( devlist ) free( devlist ); devlist = NULL; auth = NULL; first_dev = NULL; first_handle = NULL; } /** return a list of all devices */ SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only ) { int i; U12_Device *dev; DBG(_DBG_SANE_INIT, "sane_get_devices (%p, %ld)\n", (void *)device_list, (long) local_only); /* already called, so cleanup */ if( devlist ) free( devlist ); devlist = malloc((num_devices + 1) * sizeof (devlist[0])); if ( NULL == devlist ) return SANE_STATUS_NO_MEM; i = 0; for( dev = first_dev; i < num_devices; dev = dev->next ) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } /** open the sane device */ SANE_Status sane_open( SANE_String_Const devicename, SANE_Handle* handle ) { SANE_Status status; U12_Device *dev; U12_Scanner *s; CnfDef config; DBG( _DBG_SANE_INIT, "sane_open - %s\n", devicename ); if( devicename[0] ) { for( dev = first_dev; dev; dev = dev->next ) { if( strcmp( dev->sane.name, devicename ) == 0 ) break; } if( !dev ) { memset( &config, 0, sizeof(CnfDef)); status = attach( devicename, &config, &dev ); if( SANE_STATUS_GOOD != status ) return status; } } else { /* empty devicename -> use first device */ dev = first_dev; } if( !dev ) return SANE_STATUS_INVAL; s = malloc (sizeof (*s)); if( NULL == s ) return SANE_STATUS_NO_MEM; memset(s, 0, sizeof (*s)); s->r_pipe = -1; s->w_pipe = -1; s->hw = dev; s->scanning = SANE_FALSE; init_options( s ); /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; return SANE_STATUS_GOOD; } /** */ void sane_close( SANE_Handle handle ) { U12_Scanner *prev, *s; DBG( _DBG_SANE_INIT, "sane_close\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 ) { DBG( _DBG_ERROR, "close: invalid handle %p\n", handle); return; } drvClosePipes( s ); if( NULL != s->buf ) free(s->buf); if( NULL != s->hw->bufs.b1.pReadBuf ) free( s->hw->bufs.b1.pReadBuf ); if( NULL != s->hw->shade.pHilight ) free( s->hw->shade.pHilight ); if( NULL != s->hw->scaleBuf ) free( s->hw->scaleBuf ); drvClose( s->hw ); if (prev) prev->next = s->next; else first_handle = s->next; free(s); } /** return or set the parameter values, also do some checks */ SANE_Status sane_control_option( SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { U12_Scanner *s = (U12_Scanner *)handle; SANE_Status status; const SANE_String_Const *optval; #ifdef ALL_MODES pModeParam mp; int idx; #endif int scanmode; if ( s->scanning ) return SANE_STATUS_DEVICE_BUSY; if((option < 0) || (option >= NUM_OPTIONS)) return SANE_STATUS_INVAL; if( NULL != info ) *info = 0; switch( action ) { case SANE_ACTION_GET_VALUE: switch (option) { case OPT_PREVIEW: case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_CUSTOM_GAMMA: *(SANE_Word *)value = s->val[option].w; break; case OPT_CONTRAST: case OPT_BRIGHTNESS: *(SANE_Word *)value = (s->val[option].w << SANE_FIXED_SCALE_SHIFT); break; #ifdef ALL_MODES case OPT_MODE: case OPT_EXT_MODE: strcpy ((char *) value, s->opt[option].constraint.string_list[s->val[option].w]); break; #endif /* word array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy( value, s->val[option].wa, s->opt[option].size ); break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_VALUE: status = sanei_constrain_value( s->opt + option, value, info ); if( SANE_STATUS_GOOD != status ) return status; optval = NULL; if( SANE_CONSTRAINT_STRING_LIST == s->opt[option].constraint_type ) { optval = search_string_list( s->opt[option].constraint.string_list, (char *) value); if( NULL == optval ) return SANE_STATUS_INVAL; } switch (option) { case OPT_RESOLUTION: { int n; int min_d = s->hw->res_list[s->hw->res_list_size - 1]; int v = *(SANE_Word *)value; int best = v; for( n = 0; n < s->hw->res_list_size; n++ ) { int d = abs(v - s->hw->res_list[n]); if( d < min_d ) { min_d = d; best = s->hw->res_list[n]; } } s->val[option].w = (SANE_Word)best; if( v != best ) *(SANE_Word *)value = best; if( NULL != info ) { if( v != best ) *info |= SANE_INFO_INEXACT; *info |= SANE_INFO_RELOAD_PARAMS; } break; } case OPT_PREVIEW: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: s->val[option].w = *(SANE_Word *)value; if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_CUSTOM_GAMMA: s->val[option].w = *(SANE_Word *)value; if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; #ifdef ALL_MODES mp = getModeList( s ); scanmode = mp[s->val[OPT_MODE].w].scanmode; #else scanmode = COLOR_TRUE24; #endif s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; if( SANE_TRUE == s->val[option].w ) { if( scanmode == COLOR_256GRAY ) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; } else { s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } else { u12map_InitGammaSettings( s->hw ); if( scanmode == COLOR_256GRAY ) { s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; } else { s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } } break; case OPT_CONTRAST: case OPT_BRIGHTNESS: s->val[option].w = ((*(SANE_Word *)value) >> SANE_FIXED_SCALE_SHIFT); break; #ifdef ALL_MODES case OPT_MODE: idx = (optval - mode_list); mp = getModeList( s ); s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if( mp[idx].scanmode == COLOR_BW ) { s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; } s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; if( s->val[OPT_CUSTOM_GAMMA].w && !(s->opt[OPT_CUSTOM_GAMMA].cap & SANE_CAP_INACTIVE)) { if( mp[idx].scanmode == COLOR_256GRAY ) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; } else { s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } if( NULL != info ) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; s->val[option].w = optval - s->opt[option].constraint.string_list; break; case OPT_EXT_MODE: { s->val[option].w = optval - s->opt[option].constraint.string_list; /* * change the area and mode_list when changing the source */ if( s->val[option].w == 0 ) { s->hw->dpi_range.min = _DEF_DPI; s->hw->x_range.max = SANE_FIX(s->hw->max_x); s->hw->y_range.max = SANE_FIX(s->hw->max_y); s->val[OPT_TL_X].w = SANE_FIX(_DEFAULT_TLX); s->val[OPT_TL_Y].w = SANE_FIX(_DEFAULT_TLY); s->val[OPT_BR_X].w = SANE_FIX(_DEFAULT_BRX); s->val[OPT_BR_Y].w = SANE_FIX(_DEFAULT_BRY); s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].w = COLOR_TRUE24; } else { s->hw->dpi_range.min = _TPAMinDpi; if( s->val[option].w == 1 ) { s->hw->x_range.max = SANE_FIX(_TP_X); s->hw->y_range.max = SANE_FIX(_TP_Y); s->val[OPT_TL_X].w = SANE_FIX(_DEFAULT_TP_TLX); s->val[OPT_TL_Y].w = SANE_FIX(_DEFAULT_TP_TLY); s->val[OPT_BR_X].w = SANE_FIX(_DEFAULT_TP_BRX); s->val[OPT_BR_Y].w = SANE_FIX(_DEFAULT_TP_BRY); } else { s->hw->x_range.max = SANE_FIX(_NEG_X); s->hw->y_range.max = SANE_FIX(_NEG_Y); s->val[OPT_TL_X].w = SANE_FIX(_DEFAULT_NEG_TLX); s->val[OPT_TL_Y].w = SANE_FIX(_DEFAULT_NEG_TLY); s->val[OPT_BR_X].w = SANE_FIX(_DEFAULT_NEG_BRX); s->val[OPT_BR_Y].w = SANE_FIX(_DEFAULT_NEG_BRY); } s->opt[OPT_MODE].constraint.string_list = &mode_list[_TPAModeSupportMin]; s->val[OPT_MODE].w = 0; /* COLOR_24 is the default */ } s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; if( NULL != info ) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; break; } #endif case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy( s->val[option].wa, value, s->opt[option].size ); u12map_CheckGammaSettings(s->hw); if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS; break; default: return SANE_STATUS_INVAL; } break; default: return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /** according to the option number, return a pointer to a descriptor */ const SANE_Option_Descriptor * sane_get_option_descriptor( SANE_Handle handle, SANE_Int option ) { U12_Scanner *s = (U12_Scanner *)handle; if((option < 0) || (option >= NUM_OPTIONS)) return NULL; return &(s->opt[option]); } /** return the current parameter settings */ SANE_Status sane_get_parameters( SANE_Handle handle, SANE_Parameters *params ) { int ndpi; #ifdef ALL_MODES pModeParam mp; #endif U12_Scanner *s = (U12_Scanner *)handle; /* if we're called from within, calc best guess * do the same, if sane_get_parameters() is called * by a frontend before sane_start() is called */ if((NULL == params) || (s->scanning != SANE_TRUE)) { #ifdef ALL_MODES mp = getModeList( s ); #endif memset( &s->params, 0, sizeof (SANE_Parameters)); ndpi = s->val[OPT_RESOLUTION].w; s->params.pixels_per_line = SANE_UNFIX(s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) / _MM_PER_INCH * ndpi; s->params.lines = SANE_UNFIX( s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) / _MM_PER_INCH * ndpi; /* pixels_per_line seems to be 8 * n. */ /* s->params.pixels_per_line = s->params.pixels_per_line & ~7; debug only */ s->params.last_frame = SANE_TRUE; #ifdef ALL_MODES s->params.depth = mp[s->val[OPT_MODE].w].depth; #else s->params.depth = 8; s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line = 3 * s->params.pixels_per_line; #endif #ifdef ALL_MODES if( mp[s->val[OPT_MODE].w].color ) { s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line = 3 * s->params.pixels_per_line; } else { s->params.format = SANE_FRAME_GRAY; if (s->params.depth == 1) s->params.bytes_per_line = (s->params.pixels_per_line + 7) / 8; else s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8; } #endif /* if sane_get_parameters() was called before sane_start() */ /* pass new values to the caller */ if ((NULL != params) && (s->scanning != SANE_TRUE)) *params = s->params; } else *params = s->params; return SANE_STATUS_GOOD; } /** initiate the scan process */ SANE_Status sane_start( SANE_Handle handle ) { U12_Scanner *s = (U12_Scanner *)handle; U12_Device *dev; #ifdef ALL_MODES ModeParam *mp; #endif int result; int ndpi; int left, top; int width, height; int scanmode; int fds[2]; double dpi_x, dpi_y; ImgDef image; SANE_Status status; SANE_Word tmp; DBG( _DBG_SANE_INIT, "sane_start\n" ); if( s->scanning ) { return SANE_STATUS_DEVICE_BUSY; } status = sane_get_parameters (handle, NULL); if (status != SANE_STATUS_GOOD) { DBG( _DBG_ERROR, "sane_get_parameters failed\n" ); return status; } dev = s->hw; /* open the driver and get some information about the scanner */ dev->fd = u12if_open( dev ); if( dev->fd < 0 ) { DBG( _DBG_ERROR,"sane_start: open failed: %d\n", errno ); if( errno == EBUSY ) return SANE_STATUS_DEVICE_BUSY; return SANE_STATUS_IO_ERROR; } tsecs = 0; result = u12if_getCaps( dev ); if( result < 0 ) { DBG( _DBG_ERROR, "u12if_getCaps() failed(%d)\n", result); u12if_close( dev ); return SANE_STATUS_IO_ERROR; } /* All ready to go. Set image def and see what the scanner * says for crop info. */ ndpi = s->val[OPT_RESOLUTION].w; /* exchange the values as we can't deal with negative heights and so on...*/ tmp = s->val[OPT_TL_X].w; if( tmp > s->val[OPT_BR_X].w ) { DBG( _DBG_INFO, "exchanging BR-X - TL-X\n" ); s->val[OPT_TL_X].w = s->val[OPT_BR_X].w; s->val[OPT_BR_X].w = tmp; } tmp = s->val[OPT_TL_Y].w; if( tmp > s->val[OPT_BR_Y].w ) { DBG( _DBG_INFO, "exchanging BR-Y - TL-Y\n" ); s->val[OPT_TL_Y].w = s->val[OPT_BR_Y].w; s->val[OPT_BR_Y].w = tmp; } /* position and extent are always relative to 300 dpi */ dpi_x = (double)dev->dpi_max_x; dpi_y = (double)dev->dpi_max_y; left = (int)(SANE_UNFIX(s->val[OPT_TL_X].w)* dpi_x/ (_MM_PER_INCH*(dpi_x/_MEASURE_BASE))); top = (int)(SANE_UNFIX(s->val[OPT_TL_Y].w)*dpi_y/ (_MM_PER_INCH*(dpi_y/_MEASURE_BASE))); width = (int)(SANE_UNFIX(s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) * dpi_x / (_MM_PER_INCH *(dpi_x/_MEASURE_BASE))); height = (int)(SANE_UNFIX(s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) * dpi_y / (_MM_PER_INCH *(dpi_y/_MEASURE_BASE))); if((width == 0) || (height == 0)) { DBG( _DBG_ERROR, "invalid width or height!\n" ); return SANE_STATUS_INVAL; } /* adjust mode list according to the model we use and the source we have */ #ifdef ALL_MODES mp = getModeList( s ); scanmode = mp[s->val[OPT_MODE].w].scanmode; #else scanmode = COLOR_TRUE24; #endif DBG( _DBG_INFO, "scanmode = %u\n", scanmode ); /* clear it out just in case */ memset (&image, 0, sizeof(ImgDef)); /* this is what we want */ image.xyDpi.x = ndpi; image.xyDpi.y = ndpi; image.crArea.x = left; /* offset from left edge to area you want to scan */ image.crArea.y = top; /* offset from top edge to area you want to scan */ image.crArea.cx = width; /* always relative to 300 dpi */ image.crArea.cy = height; image.wDataType = scanmode; #ifdef ALL_MODES switch( s->val[OPT_EXT_MODE].w ) { case 1: image.dwFlag |= _SCANDEF_Transparency; break; case 2: image.dwFlag |= _SCANDEF_Negative; break; default: break; } #endif #if 0 if( s->val[OPT_PREVIEW].w ) image.dwFlag |= _SCANDEF_PREVIEW; #endif /* set adjustments for brightness and contrast */ dev->DataInf.siBrightness = s->val[OPT_BRIGHTNESS].w; dev->DataInf.siContrast = s->val[OPT_CONTRAST].w; DBG( _DBG_SANE_INIT, "brightness %i, contrast %i\n", dev->DataInf.siBrightness, dev->DataInf.siContrast ); result = u12image_SetupScanSettings( dev, &image ); if( SANE_STATUS_GOOD != result ) { DBG( _DBG_ERROR, "u12image_SetupScanSettings() failed(%d)\n", result ); u12if_close( dev ); return SANE_STATUS_IO_ERROR; } s->params.pixels_per_line = dev->DataInf.dwAppPixelsPerLine; s->params.bytes_per_line = dev->DataInf.dwAppBytesPerLine; s->params.lines = dev->DataInf.dwAppLinesPerArea; DBG( _DBG_INFO, "* PixelPerLine = %u\n", s->params.pixels_per_line ); DBG( _DBG_INFO, "* BytesPerLine = %u\n", s->params.bytes_per_line ); DBG( _DBG_INFO, "* Lines = %u\n", s->params.lines ); /* reset our timer...*/ tsecs = 0; s->buf = realloc( s->buf, (s->params.lines) * s->params.bytes_per_line ); if( NULL == s->buf ) { DBG( _DBG_ERROR, "realloc failed\n" ); u12if_close( dev ); return SANE_STATUS_NO_MEM; } result = u12if_startScan( dev ); if( SANE_STATUS_GOOD != result ) { DBG( _DBG_ERROR, "u12if_startScan() failed(%d)\n", result ); u12if_close( dev ); return SANE_STATUS_IO_ERROR; } s->scanning = SANE_TRUE; tsecs = (unsigned long)time(NULL); DBG( _DBG_INFO, "TIME START\n" ); /* * everything prepared, so start the child process and a pipe to communicate * pipe --> fds[0]=read-fd, fds[1]=write-fd */ if( pipe(fds) < 0 ) { DBG( _DBG_ERROR, "ERROR: could not create pipe\n" ); s->scanning = SANE_FALSE; u12if_close( dev ); return SANE_STATUS_IO_ERROR; } /* create reader routine as new process */ s->bytes_read = 0; s->r_pipe = fds[0]; s->w_pipe = fds[1]; s->reader_pid = sanei_thread_begin( reader_process, s ); cancelRead = SANE_FALSE; 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 ); return SANE_STATUS_IO_ERROR; } signal( SIGCHLD, sig_chldhandler ); if( sanei_thread_is_forked()) { close( s->w_pipe ); s->w_pipe = -1; } DBG( _DBG_SANE_INIT, "sane_start done\n" ); return SANE_STATUS_GOOD; } /** function to read the data from our child process */ SANE_Status sane_read( SANE_Handle handle, SANE_Byte *data, SANE_Int max_length, SANE_Int *length ) { U12_Scanner *s = (U12_Scanner*)handle; ssize_t nread; *length = 0; /* here we read all data from the driver... */ nread = read( s->r_pipe, data, max_length ); DBG( _DBG_READ, "sane_read - read %ld bytes\n", (long)nread ); if (!(s->scanning)) { return do_cancel( s, SANE_TRUE ); } if( nread < 0 ) { if( EAGAIN == errno ) { /* if we already had red the picture, so it's okay and stop */ if( s->bytes_read == (unsigned long)(s->params.lines * s->params.bytes_per_line)) { sanei_thread_waitpid( s->reader_pid, 0 ); sanei_thread_invalidate( s->reader_pid ); drvClose( s->hw ); return drvClosePipes(s); } /* else force the frontend to try again*/ return SANE_STATUS_GOOD; } else { DBG( _DBG_ERROR, "ERROR: errno=%d\n", errno ); do_cancel( s, SANE_TRUE ); return SANE_STATUS_IO_ERROR; } } *length = nread; s->bytes_read += nread; /* nothing red means that we're finished OR we had a problem...*/ if( 0 == nread ) { drvClose( s->hw ); s->exit_code = sanei_thread_get_status( s->reader_pid ); if( SANE_STATUS_GOOD != s->exit_code ) { drvClosePipes(s); return s->exit_code; } sanei_thread_invalidate( s->reader_pid ); return drvClosePipes(s); } return SANE_STATUS_GOOD; } /** cancel the scanning process */ void sane_cancel( SANE_Handle handle ) { U12_Scanner *s = (U12_Scanner *)handle; DBG( _DBG_SANE_INIT, "sane_cancel\n" ); if( s->scanning ) do_cancel( s, SANE_FALSE ); } /** set the pipe to blocking/non blocking mode */ SANE_Status sane_set_io_mode( SANE_Handle handle, SANE_Bool non_blocking ) { U12_Scanner *s = (U12_Scanner *)handle; DBG( _DBG_SANE_INIT, "sane_set_io_mode: non_blocking=%d\n", non_blocking ); if ( !s->scanning ) { DBG( _DBG_ERROR, "ERROR: not scanning !\n" ); return SANE_STATUS_INVAL; } if( -1 == s->r_pipe ) { DBG( _DBG_ERROR, "ERROR: not supported !\n" ); return SANE_STATUS_UNSUPPORTED; } if( fcntl (s->r_pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) { DBG( _DBG_ERROR, "ERROR: can´t set to non-blocking mode !\n" ); return SANE_STATUS_IO_ERROR; } DBG( _DBG_SANE_INIT, "sane_set_io_mode done\n" ); return SANE_STATUS_GOOD; } /** return the descriptor if available */ SANE_Status sane_get_select_fd( SANE_Handle handle, SANE_Int * fd ) { U12_Scanner *s = (U12_Scanner *)handle; DBG( _DBG_SANE_INIT, "sane_get_select_fd\n" ); if( !s->scanning ) { DBG( _DBG_ERROR, "ERROR: not scanning !\n" ); return SANE_STATUS_INVAL; } *fd = s->r_pipe; DBG( _DBG_SANE_INIT, "sane_get_select_fd done\n" ); return SANE_STATUS_GOOD; } /* END U12.C ................................................................*/ sane-backends-1.0.29/backend/magicolor.conf.in0000666000000000000000000000234513615534521016024 00000000000000### magicolor.conf ### ### here are some examples for how to configure the Magicolor backend ### Timeout settings: SNMP autodetection, Scan data read requests and other ### read requests. All values are given in milliseconds, ### i.e. 1000 is 1 second. # SNMP auto-detection waits 1.5 seconds snmp-timeout 1500 # wait 15 seconds for scan data (color scans take ~6 seconds to initialize, # so we need to wait longer than that) scan-data-timeout 15000 # Wait 5 seconds for all other data requests request-timeout 5000 ### Network: Format is "net IP_ADDRESS [USB_ID]" or "net autodiscovery" ### if USB_ID is left out, SNMP is used to detect the device type net autodiscovery #net 10.0.0.5 ### The following is a magicolor 1690mf with explicit IP-Address #net 10.0.0.5 0x2098 # net 192.168.0.1 ### USB: format is "usb" for automatic (libusb) discovery, based on USB IDs, ### or "usb to force the use of a particular ### device (the backend has some additional checks and will not use ### non-KONICA MINOLTA devices, though) usb ### For libusb support for unknown scanners use the following command ### usb ### e.g.: # usb 0x132b 0x2098 sane-backends-1.0.29/backend/gt68xx_generic.h0000666000000000000000000000544413615534521015614 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002 Sergey Vlasov 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef GT68XX_GENERIC_H #define GT68XX_GENERIC_H #include "gt68xx_low.h" static SANE_Status gt68xx_generic_move_relative (GT68xx_Device * dev, SANE_Int distance); static SANE_Status gt68xx_generic_start_scan (GT68xx_Device * dev); static SANE_Status gt68xx_generic_read_scanned_data (GT68xx_Device * dev, SANE_Bool * ready); static SANE_Status gt68xx_generic_set_afe (GT68xx_Device * dev, GT68xx_AFE_Parameters * params); static SANE_Status gt68xx_generic_set_exposure_time (GT68xx_Device * dev, GT68xx_Exposure_Parameters * params); static SANE_Status gt68xx_generic_get_id (GT68xx_Device * dev); static SANE_Status gt68xx_generic_paperfeed (GT68xx_Device * dev); static SANE_Status gt68xx_generic_setup_scan (GT68xx_Device * dev, GT68xx_Scan_Request * request, GT68xx_Scan_Action action, GT68xx_Scan_Parameters * params); static SANE_Status gt68xx_generic_move_paper (GT68xx_Device * dev, GT68xx_Scan_Request * request); #endif /* not GT68XX_GENERIC_H */ sane-backends-1.0.29/backend/snapscan-data.c0000666000000000000000000124406113615534521015461 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2006 Oliver Schwartz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file contains static calibration data for the Benq 5150C scanner. Once it is known how calibration for this scanner works this file becomes obsolete. */ /* $Id$ SANE SnapScan backend */ static const SANE_Byte calibration_data_5150[] = { 0x78,0x01,0xcc,0x47,0xca,0x53,0xcd,0x4a,0xd0,0x57,0xd5,0x46,0xda,0x56,0xdd,0x49, 0xe2,0x50,0xe1,0x47,0xe0,0x51,0xdf,0x4b,0xdc,0x4f,0xd4,0x52,0xd0,0x52,0xcd,0x4a, 0xcd,0x4e,0xcf,0x46,0xd1,0x50,0xd8,0x4d,0xdc,0x53,0xdf,0x4c,0xe5,0x4f,0xe2,0x45, 0xe2,0x53,0xe3,0x4b,0xde,0x50,0xd8,0x4b,0xd4,0x55,0xcf,0x4a,0xd0,0x50,0xd0,0x49, 0xd4,0x4f,0xd8,0x49,0xe0,0x4d,0xe3,0x4a,0xe4,0x55,0xe7,0x47,0xe7,0x4f,0xe5,0x46, 0xe1,0x51,0xdd,0x4a,0xd6,0x4d,0xd2,0x46,0xcd,0x51,0xcd,0x44,0xd3,0x54,0xd6,0x48, 0xdb,0x51,0xe2,0x4a,0xe5,0x4f,0xe7,0x4b,0xe8,0x54,0xe5,0x4e,0xe0,0x4e,0xdc,0x47, 0xd9,0x50,0xd4,0x48,0xd2,0x4c,0xd3,0x46,0xd6,0x4f,0xd9,0x4a,0xdf,0x4e,0xe1,0x47, 0xe6,0x4e,0xe6,0x4d,0xe7,0x4e,0xe5,0x4a,0xe2,0x55,0xdc,0x47,0xd7,0x54,0xd2,0x4a, 0xd1,0x50,0xce,0x45,0xd2,0x4e,0xd6,0x4a,0xd9,0x50,0xde,0x4a,0xe2,0x4d,0xe2,0x45, 0xe5,0x4f,0xe3,0x4c,0xe0,0x4c,0xdc,0x4d,0xd4,0x51,0xd0,0x47,0xce,0x4d,0xcc,0x45, 0xcd,0x50,0xd1,0x48,0xd4,0x4c,0xd8,0x48,0xda,0x55,0xde,0x4c,0xdd,0x4d,0xdb,0x46, 0xda,0x52,0xd6,0x4b,0xd1,0x4f,0xcc,0x45,0xc9,0x4e,0xc7,0x48,0xc8,0x4e,0xcb,0x47, 0xd0,0x51,0xd4,0x4b,0xd8,0x50,0xda,0x4a,0xdc,0x55,0xdb,0x45,0xd8,0x50,0xd4,0x4c, 0xcf,0x53,0xca,0x45,0xc7,0x4b,0xc6,0x4a,0xc5,0x56,0xc7,0x47,0xcb,0x50,0xd2,0x4a, 0xd5,0x55,0xd7,0x4a,0xda,0x4f,0xda,0x4a,0xd7,0x52,0xd4,0x4b,0xcf,0x54,0xca,0x46, 0xc6,0x51,0xc5,0x4a,0xc5,0x51,0xc7,0x46,0xca,0x54,0xd0,0x4b,0xd3,0x51,0xd6,0x4a, 0xd9,0x53,0xd9,0x47,0xd8,0x4d,0xd5,0x48,0xd0,0x53,0xca,0x47,0xc8,0x4c,0xc5,0x48, 0xc5,0x52,0xc6,0x49,0xcb,0x4f,0xcd,0x47,0xd1,0x51,0xd6,0x49,0xd8,0x52,0xd7,0x43, 0xd7,0x4d,0xd5,0x4a,0xcf,0x53,0xca,0x49,0xc7,0x50,0xc3,0x47,0xc1,0x51,0xc5,0x46, 0xca,0x4d,0xcc,0x49,0xd2,0x52,0xd6,0x4c,0xd8,0x52,0xd8,0x47,0xd7,0x50,0xd4,0x49, 0xd2,0x4c,0xcc,0x48,0xc9,0x4d,0xc6,0x47,0xc4,0x54,0xc6,0x45,0xc8,0x50,0xcd,0x46, 0xd1,0x51,0xd4,0x44,0xd7,0x51,0xd7,0x46,0xd7,0x53,0xd5,0x4a,0xd2,0x4d,0xcd,0x45, 0xcb,0x4f,0xc8,0x4c,0xc7,0x4d,0xc8,0x48,0xca,0x51,0xcd,0x45,0xd2,0x50,0xd6,0x48, 0xda,0x50,0xdb,0x48,0xdb,0x4f,0xd8,0x47,0xd5,0x53,0xd1,0x4b,0xcc,0x51,0xc9,0x49, 0xc9,0x4f,0xc7,0x4f,0xc9,0x53,0xcf,0x4a,0xd2,0x55,0xd7,0x49,0xda,0x4e,0xdc,0x48, 0xdc,0x52,0xda,0x48,0xd7,0x4e,0xd3,0x4d,0xce,0x51,0xcc,0x4a,0xc8,0x4e,0xc9,0x47, 0xcb,0x51,0xd1,0x49,0xd6,0x4a,0xd9,0x47,0xdd,0x53,0xdd,0x46,0xdf,0x4e,0xdc,0x4b, 0xd8,0x51,0xd3,0x4c,0xd0,0x4c,0xcd,0x4a,0xc9,0x52,0xc8,0x4a,0xca,0x50,0xd0,0x4a, 0xd5,0x51,0xd9,0x49,0xde,0x4d,0xe0,0x48,0xe0,0x54,0xe0,0x4b,0xda,0x50,0xd7,0x48, 0xd2,0x50,0xce,0x49,0xcc,0x50,0xcb,0x45,0xcd,0x55,0xd0,0x49,0xd5,0x4f,0xda,0x49, 0xde,0x4f,0xdf,0x49,0xdf,0x4e,0xdf,0x48,0xdd,0x52,0xd8,0x4c,0xd3,0x51,0xcd,0x49, 0xcc,0x52,0xc9,0x44,0xca,0x4f,0xce,0x4c,0xd4,0x54,0xd7,0x48,0xdc,0x50,0xe0,0x49, 0xe0,0x52,0xdf,0x49,0xdc,0x4c,0xd7,0x4b,0xd3,0x50,0xd0,0x48,0xca,0x50,0xca,0x4a, 0xcc,0x50,0xcf,0x47,0xd2,0x51,0xd8,0x47,0xdd,0x53,0xe0,0x49,0xdf,0x51,0xde,0x46, 0xdc,0x52,0xd9,0x46,0xd4,0x4e,0xce,0x45,0xcc,0x52,0xc9,0x49,0xc9,0x55,0xcc,0x46, 0xd0,0x4d,0xd6,0x48,0xd9,0x4d,0xda,0x48,0xdf,0x52,0xdb,0x4a,0xde,0x50,0xd7,0x48, 0xd6,0x50,0xcd,0x47,0xca,0x50,0xc8,0x48,0xc8,0x52,0xcb,0x48,0xcf,0x50,0xd2,0x46, 0xd8,0x51,0xdb,0x49,0xde,0x4e,0xdd,0x48,0xda,0x52,0xd8,0x49,0xd3,0x4e,0xce,0x49, 0xc9,0x50,0xc8,0x4b,0xc9,0x4f,0xcb,0x46,0xcc,0x52,0xd2,0x4b,0xda,0x4f,0xdc,0x45, 0xdb,0x4f,0xdc,0x48,0xde,0x4e,0xda,0x44,0xd4,0x4f,0xcb,0x46,0xca,0x4e,0xc9,0x4b, 0xc3,0x52,0xc6,0x46,0xcb,0x4e,0xd2,0x4c,0xd5,0x52,0xd8,0x49,0xda,0x51,0xdc,0x49, 0xdc,0x51,0xd6,0x45,0xd3,0x4f,0xcd,0x49,0xc9,0x51,0xc5,0x4a,0xc5,0x54,0xc6,0x46, 0xc8,0x54,0xd0,0x48,0xd5,0x4c,0xd6,0x46,0xdb,0x51,0xdd,0x48,0xda,0x50,0xd7,0x44, 0xd3,0x4d,0xce,0x47,0xc9,0x52,0xc6,0x46,0xc5,0x56,0xc7,0x48,0xcb,0x53,0xce,0x48, 0xd5,0x4e,0xd9,0x4b,0xdc,0x4f,0xdc,0x48,0xdd,0x54,0xdb,0x49,0xd3,0x52,0xce,0x49, 0xcc,0x50,0xc6,0x4a,0xc5,0x4e,0xc7,0x46,0xcb,0x50,0xce,0x46,0xd4,0x4e,0xd7,0x46, 0xdb,0x4b,0xdc,0x47,0xdc,0x51,0xda,0x49,0xd5,0x56,0xd2,0x4a,0xcd,0x4b,0xc9,0x49, 0xc8,0x4f,0xc8,0x48,0xca,0x4c,0xce,0x47,0xd3,0x52,0xd8,0x4a,0xdc,0x51,0xdc,0x46, 0xdc,0x4c,0xdc,0x48,0xd9,0x4d,0xd1,0x47,0xcc,0x58,0xc8,0x46,0xc7,0x54,0xc6,0x48, 0xc8,0x4a,0xca,0x47,0xd2,0x4c,0xd4,0x45,0xd7,0x50,0xd9,0x4a,0xda,0x4e,0xd8,0x46, 0xd5,0x51,0xd0,0x43,0xcb,0x4f,0xc6,0x45,0xc4,0x52,0xc7,0x43,0xc8,0x52,0xcb,0x45, 0xcf,0x51,0xd5,0x46,0xd9,0x4f,0xda,0x4b,0xda,0x53,0xd9,0x46,0xd6,0x4e,0xd1,0x48, 0xcb,0x51,0xc6,0x46,0xc6,0x4b,0xc4,0x40,0xc5,0x51,0xcb,0x47,0xd0,0x4d,0xd4,0x48, 0xd7,0x52,0xd1,0x4d,0xdc,0x34,0xdb,0x2f,0xd9,0x37,0xd4,0x30,0xce,0x40,0xcb,0x33, 0xca,0x3e,0xca,0x34,0xcc,0x32,0xd0,0x2f,0xd5,0x37,0xd7,0x30,0xda,0x37,0xdd,0x2d, 0xdc,0x34,0xd9,0x30,0xd7,0x34,0xd3,0x2d,0xcc,0x35,0xca,0x2c,0xc7,0x33,0xc8,0x2e, 0xca,0x37,0xcd,0x30,0xd1,0x35,0xd6,0x2d,0xd8,0x38,0xda,0x2c,0xda,0x37,0xd8,0x2d, 0xd6,0x36,0xd3,0x2e,0xc8,0x32,0xc7,0x2f,0xc5,0x32,0xc6,0x2a,0xc8,0x38,0xca,0x2a, 0xd0,0x36,0xd5,0x2e,0xd6,0x37,0xd9,0x2c,0xd9,0x31,0xd7,0x2e,0xd4,0x35,0xcf,0x30, 0xcb,0x34,0xc9,0x2c,0xc4,0x32,0xc3,0x2e,0xc6,0x35,0xc9,0x2d,0xcc,0x34,0xd1,0x2d, 0xd3,0x32,0xd5,0x2d,0xd6,0x36,0xd4,0x2d,0xd0,0x32,0xcd,0x30,0xc8,0x35,0xc5,0x2f, 0xc2,0x36,0xc2,0x2d,0xc2,0x35,0xc4,0x2b,0xc9,0x39,0xcf,0x2f,0xd1,0x32,0xd3,0x2c, 0xd7,0x38,0xd4,0x2f,0xd0,0x30,0xcd,0x2d,0xc9,0x39,0xc5,0x30,0xc3,0x35,0xc2,0x31, 0xc3,0x35,0xc5,0x28,0xc8,0x33,0xcc,0x30,0xd0,0x37,0xd3,0x2e,0xd3,0x39,0xd0,0x2a, 0xd0,0x34,0xcc,0x2e,0xc8,0x35,0xc3,0x2d,0xc0,0x35,0xbe,0x2d,0xbe,0x33,0xc2,0x2d, 0xc5,0x33,0xca,0x2b,0xcd,0x36,0xcf,0x2a,0xd3,0x36,0xd2,0x29,0xd0,0x36,0xce,0x2e, 0xca,0x38,0xc5,0x2a,0xc1,0x34,0xbf,0x2c,0xbf,0x35,0xc3,0x2d,0xc5,0x36,0xcb,0x2a, 0xd0,0x37,0xd2,0x31,0xd5,0x3a,0xd5,0x2c,0xd2,0x37,0xd1,0x2d,0xcd,0x35,0xc9,0x2c, 0xc7,0x35,0xc4,0x2d,0xc3,0x34,0xc4,0x2c,0xc8,0x3a,0xcd,0x2e,0xd0,0x37,0xd4,0x2e, 0xd5,0x32,0xd6,0x2d,0xd3,0x35,0xd0,0x2e,0xcd,0x34,0xc9,0x2d,0xc6,0x38,0xc3,0x2c, 0xc3,0x33,0xc5,0x2d,0xc8,0x33,0xcc,0x2a,0xcf,0x33,0xd4,0x2d,0xd6,0x34,0xd5,0x2e, 0xd4,0x35,0xd0,0x28,0xcc,0x35,0xc8,0x2c,0xc6,0x36,0xc3,0x2d,0xc1,0x38,0xc2,0x2d, 0xc4,0x35,0xc9,0x2f,0xcd,0x31,0xcf,0x2d,0xd4,0x35,0xd5,0x2f,0xd4,0x36,0xd2,0x2e, 0xce,0x36,0xc8,0x2a,0xc5,0x36,0xc1,0x2a,0xc1,0x36,0xc2,0x2f,0xc6,0x3a,0xca,0x2f, 0xce,0x3a,0xd2,0x2f,0xd2,0x33,0xd4,0x2f,0xd5,0x39,0xd3,0x2d,0xce,0x33,0xca,0x2b, 0xc8,0x3c,0xc4,0x2f,0xc0,0x33,0xc2,0x2c,0xc6,0x35,0xc9,0x2f,0xcb,0x32,0xd0,0x2a, 0xd3,0x37,0xd5,0x2f,0xd3,0x31,0xd1,0x33,0xd0,0x35,0xcd,0x2c,0xc8,0x34,0xc6,0x2c, 0xc4,0x32,0xc4,0x31,0xc5,0x35,0xc7,0x30,0xcc,0x33,0xd2,0x2e,0xd6,0x35,0xd6,0x2e, 0xd6,0x36,0xd5,0x2f,0xd2,0x38,0xcc,0x2f,0xc9,0x36,0xc4,0x30,0xc4,0x33,0xc2,0x27, 0xc5,0x34,0xc9,0x2d,0xcc,0x32,0xcf,0x2c,0xd4,0x33,0xd6,0x30,0xd6,0x34,0xd4,0x2d, 0xd3,0x39,0xce,0x30,0xca,0x36,0xc6,0x2e,0xc3,0x36,0xc2,0x30,0xc4,0x32,0xc8,0x2d, 0xcd,0x35,0xd1,0x2f,0xd2,0x33,0xd3,0x2c,0xd6,0x36,0xd3,0x2f,0xcf,0x36,0xcd,0x2e, 0xc9,0x36,0xc5,0x2c,0xc2,0x32,0xc2,0x2e,0xc3,0x34,0xc7,0x2e,0xca,0x33,0xd0,0x2e, 0xd3,0x39,0xd3,0x30,0xd4,0x34,0xd4,0x2d,0xd2,0x35,0xcd,0x32,0xc9,0x33,0xc6,0x2f, 0xc4,0x37,0xc2,0x2c,0xc2,0x35,0xc5,0x2d,0xc9,0x35,0xcd,0x2f,0xce,0x36,0xd2,0x2d, 0xd2,0x36,0xd3,0x2f,0xcf,0x38,0xcc,0x2f,0xc8,0x37,0xc3,0x30,0xc1,0x36,0xbf,0x2f, 0xc1,0x39,0xc3,0x30,0xc7,0x32,0xcc,0x2a,0xd0,0x38,0xd0,0x30,0xd1,0x36,0xd1,0x2c, 0xcf,0x37,0xca,0x30,0xc5,0x37,0xc2,0x2c,0xc1,0x37,0xc0,0x2f,0xbf,0x38,0xc1,0x2e, 0xc6,0x38,0xca,0x2e,0xce,0x35,0xd1,0x2b,0xd3,0x35,0xd3,0x2c,0xd0,0x39,0xcd,0x2a, 0xca,0x36,0xc6,0x2e,0xc1,0x34,0xbe,0x31,0xc0,0x36,0xc1,0x2f,0xc4,0x39,0xc8,0x2a, 0xce,0x35,0xcf,0x2d,0xcf,0x31,0xd0,0x2d,0xce,0x35,0xcb,0x2c,0xc7,0x36,0xc4,0x29, 0xc2,0x35,0xbf,0x2f,0xbe,0x32,0xc0,0x2e,0xc3,0x38,0xc8,0x2e,0xca,0x36,0xcd,0x30, 0xcf,0x33,0xd0,0x2d,0xcd,0x34,0xca,0x2f,0xc7,0x35,0xc0,0x30,0xc1,0x35,0xbd,0x2e, 0xbc,0x32,0xbe,0x2d,0xc0,0x38,0xc5,0x31,0xca,0x37,0xcd,0x2d,0xce,0x37,0xce,0x2d, 0xce,0x37,0xcb,0x30,0xc8,0x36,0xc3,0x2f,0xc0,0x35,0xbc,0x32,0xbb,0x35,0xbc,0x2c, 0xc0,0x38,0xc5,0x2d,0xc7,0x33,0xc8,0x2f,0xcc,0x37,0xcd,0x2d,0xca,0x37,0xc8,0x31, 0xc5,0x36,0xc2,0x2e,0xbe,0x35,0xba,0x30,0xbb,0x39,0xba,0x30,0xbd,0x34,0xc2,0x2f, 0xc6,0x38,0xc8,0x2e,0xca,0x32,0xcb,0x30,0xc9,0x33,0xc7,0x2e,0xc4,0x35,0xbf,0x2c, 0xbd,0x37,0xb9,0x2c,0xb7,0x37,0xb8,0x2f,0xbb,0x36,0xbf,0x2c,0xc3,0x33,0xc4,0x31, 0xc7,0x31,0xc9,0x31,0xc8,0x34,0xc4,0x30,0xc2,0x34,0xc1,0x2b,0xbb,0x38,0xb8,0x30, 0xb8,0x34,0xb8,0x2e,0xb9,0x33,0xbd,0x2e,0xc2,0x37,0xc7,0x2b,0xc9,0x34,0xc8,0x2e, 0xc9,0x31,0xc9,0x2c,0xc4,0x33,0xbf,0x30,0xbb,0x35,0xba,0x2d,0xb9,0x39,0xb9,0x2c, 0xba,0x32,0xbc,0x30,0xc2,0x35,0xc5,0x2a,0xc8,0x36,0xc7,0x2e,0xc7,0x33,0xc7,0x2c, 0xc4,0x38,0xc0,0x2e,0xbb,0x32,0xb8,0x2d,0xb7,0x37,0xb6,0x2e,0xb8,0x36,0xbb,0x2f, 0xc1,0x37,0xc4,0x2f,0xc6,0x32,0xc8,0x29,0xc8,0x37,0xc8,0x2f,0xc4,0x37,0xc0,0x2c, 0xbc,0x32,0xbb,0x2d,0xb8,0x36,0xb6,0x2a,0xb7,0x32,0xbb,0x2f,0xbf,0x33,0xc2,0x30, 0xc6,0x38,0xc8,0x2c,0xc8,0x32,0xc6,0x2e,0xc5,0x37,0xc1,0x2c,0xbd,0x39,0xba,0x2d, 0xb8,0x32,0xb7,0x2b,0xb8,0x39,0xba,0x2f,0xbf,0x33,0xc3,0x2f,0xc6,0x34,0xc8,0x2c, 0xc9,0x36,0xc7,0x32,0xc2,0x30,0xbe,0x2f,0xbd,0x34,0xb9,0x2b,0xb4,0x34,0xb5,0x2e, 0xb7,0x37,0xb9,0x2b,0xbb,0x35,0xc1,0x2b,0xc5,0x39,0xc7,0x2f,0xc6,0x32,0xc6,0x2a, 0xc6,0x37,0xbe,0x30,0xbc,0x36,0xb8,0x31,0xb7,0x38,0xb4,0x29,0xb4,0x30,0xb8,0x25, 0xbb,0x30,0xbf,0x2c,0xc3,0x36,0xc5,0x2e,0xc5,0x38,0xbc,0x32,0xc2,0x51,0xc0,0x4c, 0xbd,0x52,0xb9,0x57,0xb6,0x61,0xb4,0x57,0xb6,0x5b,0xb9,0x51,0xbd,0x56,0xc0,0x50, 0xc3,0x56,0xc4,0x51,0xc6,0x56,0xc4,0x54,0xc2,0x55,0xbf,0x51,0xba,0x5a,0xb8,0x4f, 0xb6,0x57,0xb4,0x4f,0xb5,0x54,0xb8,0x4f,0xbd,0x57,0xbd,0x50,0xc2,0x56,0xc2,0x51, 0xc2,0x56,0xc0,0x50,0xc1,0x59,0xbb,0x4f,0xb7,0x58,0xb4,0x52,0xb2,0x59,0xb1,0x51, 0xb2,0x5a,0xb5,0x52,0xbc,0x58,0xbf,0x4e,0xbe,0x55,0xc0,0x4e,0xc6,0x56,0xc2,0x4f, 0xbc,0x58,0xbe,0x4f,0xb9,0x56,0xb6,0x4f,0xb2,0x56,0xb2,0x4e,0xb3,0x5a,0xb5,0x4f, 0xb6,0x54,0xbc,0x4c,0xbf,0x55,0xbf,0x52,0xc1,0x55,0xc2,0x4f,0xc0,0x57,0xbd,0x52, 0xb8,0x58,0xb5,0x50,0xb4,0x54,0xb0,0x50,0xb2,0x5a,0xb4,0x52,0xb6,0x59,0xb9,0x4e, 0xbd,0x57,0xbf,0x4f,0xbd,0x53,0xbe,0x4f,0xbe,0x59,0xbb,0x4e,0xb7,0x57,0xb4,0x4f, 0xb0,0x55,0xad,0x4b,0xae,0x58,0xad,0x4d,0xb3,0x58,0xb6,0x50,0xbb,0x5b,0xbd,0x50, 0xbf,0x56,0xc0,0x4b,0xbc,0x57,0xba,0x4f,0xb7,0x55,0xb2,0x4e,0xae,0x5f,0xae,0x4d, 0xb0,0x55,0xb0,0x51,0xb3,0x55,0xb7,0x4f,0xbb,0x59,0xbb,0x53,0xbe,0x58,0xbd,0x50, 0xbb,0x59,0xb8,0x50,0xb6,0x54,0xb1,0x50,0xae,0x55,0xaa,0x4c,0xac,0x55,0xb0,0x4e, 0xb2,0x5b,0xb4,0x4e,0xba,0x59,0xbd,0x4f,0xbf,0x56,0xbe,0x50,0xbe,0x58,0xb9,0x51, 0xb8,0x59,0xb4,0x4f,0xb0,0x56,0xae,0x4f,0xad,0x56,0xb1,0x4d,0xb3,0x55,0xb5,0x4f, 0xb9,0x5b,0xbc,0x51,0xbe,0x58,0xbc,0x51,0xbd,0x5e,0xbb,0x51,0xb6,0x57,0xb2,0x50, 0xae,0x59,0xab,0x51,0xab,0x53,0xaa,0x50,0xaf,0x5a,0xb2,0x50,0xb6,0x56,0xba,0x50, 0xbd,0x59,0xbb,0x55,0xba,0x57,0xb9,0x4d,0xb8,0x58,0xb1,0x52,0xaf,0x58,0xad,0x4e, 0xac,0x57,0xad,0x4c,0xaf,0x55,0xb1,0x4c,0xb4,0x59,0xb6,0x51,0xbb,0x59,0xba,0x4d, 0xba,0x59,0xba,0x4f,0xb6,0x59,0xb1,0x52,0xaf,0x56,0xac,0x4f,0xaa,0x56,0xab,0x51, 0xae,0x59,0xaf,0x51,0xb0,0x57,0xb8,0x53,0xba,0x5a,0xb8,0x4d,0xba,0x57,0xb9,0x51, 0xb7,0x58,0xb1,0x52,0xae,0x59,0xac,0x51,0xac,0x56,0xaa,0x4c,0xad,0x59,0xb1,0x4f, 0xb4,0x56,0xb7,0x52,0xb9,0x57,0xbb,0x4d,0xb9,0x57,0xb9,0x52,0xb8,0x5a,0xb1,0x50, 0xae,0x57,0xae,0x4e,0xac,0x58,0xaa,0x4f,0xad,0x57,0xb2,0x4f,0xb4,0x57,0xb7,0x4b, 0xb9,0x55,0xb9,0x50,0xba,0x55,0xb5,0x4e,0xb3,0x58,0xb3,0x4f,0xae,0x55,0xa9,0x4e, 0xa9,0x53,0xab,0x4f,0xad,0x56,0xb0,0x52,0xb2,0x54,0xb6,0x52,0xba,0x5b,0xba,0x51, 0xba,0x55,0xba,0x50,0xb6,0x56,0xb3,0x4d,0xb1,0x57,0xad,0x50,0xab,0x5a,0xac,0x4f, 0xac,0x54,0xae,0x4f,0xb1,0x57,0xb4,0x51,0xb7,0x56,0xb8,0x50,0xb9,0x59,0xbb,0x4e, 0xb8,0x57,0xad,0x4e,0xa6,0x55,0xac,0x4f,0xa8,0x58,0xa0,0x4d,0xa3,0x57,0xac,0x50, 0xb0,0x55,0xb3,0x52,0xb6,0x5a,0xb7,0x4d,0xb9,0x58,0xb8,0x4d,0xb5,0x59,0xb4,0x4f, 0xaf,0x56,0xac,0x4f,0xa9,0x57,0xa8,0x4d,0xa9,0x57,0xac,0x4f,0xaf,0x59,0xb1,0x50, 0xb7,0x56,0xb6,0x4e,0xb4,0x5a,0xb6,0x4f,0xb5,0x59,0xaf,0x50,0xac,0x58,0xa9,0x4e, 0xa7,0x5a,0xa6,0x54,0xa7,0x57,0xa9,0x4b,0xad,0x59,0xaf,0x50,0xb4,0x58,0xb3,0x4f, 0xb5,0x54,0xb8,0x4f,0xb4,0x53,0xb0,0x4d,0xae,0x5a,0xac,0x50,0xa9,0x5a,0xa7,0x51, 0xa7,0x57,0xa8,0x51,0xad,0x56,0xb1,0x54,0xb5,0x5a,0xb6,0x51,0xbb,0x59,0xb8,0x52, 0xb6,0x56,0xb3,0x4d,0xb1,0x54,0xae,0x54,0xa9,0x55,0xa6,0x4f,0xa8,0x55,0xab,0x4f, 0xae,0x5c,0xaf,0x53,0xb4,0x58,0xb6,0x51,0xb7,0x5f,0xb7,0x4f,0xb6,0x56,0xb3,0x50, 0xaf,0x56,0xad,0x4f,0xa9,0x57,0xa7,0x4f,0xa9,0x59,0xaa,0x55,0xad,0x57,0xaf,0x50, 0xb3,0x54,0xb7,0x52,0xb9,0x57,0xb6,0x54,0xb5,0x58,0xb7,0x4e,0xb1,0x57,0xab,0x50, 0xaa,0x57,0xa6,0x53,0xa6,0x56,0xa8,0x51,0xa9,0x5a,0xac,0x50,0xb1,0x56,0xb3,0x4d, 0xb8,0x5a,0xb7,0x50,0xb4,0x55,0xb4,0x4e,0xb4,0x59,0xaf,0x54,0xab,0x57,0xab,0x4d, 0xaa,0x5a,0xab,0x4f,0xab,0x59,0xae,0x51,0xb3,0x5b,0xb5,0x52,0xb7,0x58,0xb7,0x50, 0xba,0x5a,0xb6,0x4e,0xb3,0x54,0xae,0x53,0xac,0x59,0xac,0x4f,0xa7,0x57,0xa6,0x51, 0xab,0x56,0xad,0x51,0xb1,0x57,0xb3,0x4f,0xb9,0x5a,0xb7,0x4d,0xb6,0x5a,0xb7,0x4f, 0xb5,0x59,0xb1,0x54,0xac,0x57,0xa8,0x51,0xa6,0x55,0xa5,0x50,0xa8,0x57,0xac,0x4f, 0xae,0x56,0xb3,0x4f,0xb6,0x58,0xb8,0x4f,0xb8,0x59,0xb4,0x4e,0xb1,0x58,0xad,0x50, 0xac,0x54,0xa6,0x4b,0xa5,0x57,0xa5,0x4e,0xa8,0x58,0xaa,0x52,0xae,0x59,0xaf,0x52, 0xb4,0x59,0xb4,0x52,0xb4,0x55,0xb2,0x54,0xb2,0x57,0xad,0x4d,0xa8,0x55,0xa8,0x4e, 0xa6,0x55,0xa4,0x53,0xa5,0x56,0xa9,0x4d,0xae,0x58,0xb1,0x4d,0xb2,0x58,0xb4,0x51, 0xb6,0x5a,0xb5,0x51,0xb1,0x53,0xae,0x51,0xab,0x58,0xa8,0x51,0xa4,0x58,0xa4,0x4c, 0xa7,0x58,0xaa,0x4e,0xac,0x51,0xb0,0x4f,0xb4,0x59,0xb6,0x54,0xb5,0x56,0xb5,0x50, 0xb5,0x57,0xb0,0x52,0xac,0x50,0xaa,0x4b,0xa5,0x58,0xa2,0x50,0xa7,0x58,0xa8,0x4d, 0xaa,0x5b,0xad,0x50,0xb3,0x56,0xb7,0x4f,0xb6,0x57,0xb4,0x54,0xb2,0x55,0xb0,0x50, 0xad,0x5a,0xa9,0x51,0xa5,0x54,0xa6,0x4f,0xa8,0x54,0xa8,0x54,0xab,0x58,0xae,0x50, 0xb4,0x5a,0xb6,0x51,0xb6,0x56,0xad,0x4c,0xb2,0x58,0xb2,0x4f,0xa8,0x5d,0xa2,0x4b, 0xa7,0x54,0xa7,0x50,0xa5,0x57,0xa9,0x4e,0xac,0x57,0xae,0x53,0xb3,0x5a,0xb4,0x50, 0xb7,0x59,0xb6,0x50,0xb4,0x54,0xb1,0x4e,0xad,0x5c,0xa8,0x50,0xa5,0x57,0xa4,0x4f, 0xa2,0x5b,0xa5,0x4a,0xa8,0x4e,0xad,0x48,0xb1,0x54,0xb4,0x53,0xb4,0x57,0xb2,0x51, 0xb4,0x5a,0xa7,0x53,0xac,0x44,0xac,0x42,0xa9,0x46,0xa7,0x43,0xaa,0x4e,0xab,0x48, 0xaf,0x4f,0xb1,0x41,0xb5,0x48,0xb8,0x3e,0xb8,0x49,0xb7,0x43,0xb5,0x4c,0xb2,0x3e, 0xb0,0x45,0xa9,0x41,0xa9,0x47,0xa7,0x3d,0xa8,0x46,0xaa,0x41,0xae,0x49,0xb1,0x42, 0xb4,0x48,0xb8,0x3f,0xb7,0x43,0xb6,0x3d,0xb5,0x44,0xb2,0x40,0xaf,0x49,0xaa,0x40, 0xa8,0x4a,0xa6,0x40,0xa7,0x42,0xa8,0x43,0xaa,0x45,0xb0,0x42,0xb3,0x49,0xb4,0x40, 0xb6,0x4a,0xb5,0x41,0xb3,0x45,0xaf,0x42,0xaf,0x43,0xa9,0x41,0xa6,0x49,0xa5,0x43, 0xa4,0x49,0xa5,0x3e,0xa8,0x46,0xad,0x42,0xb1,0x44,0xb2,0x45,0xb4,0x48,0xb3,0x42, 0xb3,0x4b,0xb2,0x3e,0xac,0x47,0xa8,0x40,0xa7,0x49,0xa3,0x41,0xa3,0x46,0xa4,0x42, 0xa5,0x47,0xaa,0x3f,0xaf,0x45,0xb0,0x3c,0xb1,0x4b,0xb3,0x40,0xb2,0x46,0xad,0x42, 0xac,0x46,0xa9,0x45,0xa4,0x49,0xa2,0x42,0xa4,0x49,0xa4,0x3d,0xa8,0x4a,0xa8,0x41, 0xae,0x48,0xb0,0x40,0xb1,0x43,0xb0,0x42,0xb1,0x49,0xae,0x43,0xaa,0x4c,0xa7,0x41, 0xa6,0x4b,0xa3,0x40,0xa2,0x4c,0xa1,0x3b,0xa4,0x49,0xa6,0x41,0xab,0x48,0xad,0x44, 0xb1,0x4a,0xb0,0x42,0xb1,0x44,0xaf,0x44,0xad,0x46,0xa6,0x42,0xa4,0x46,0xa1,0x40, 0xa2,0x4b,0x9f,0x41,0xa2,0x46,0xa4,0x42,0xa9,0x49,0xad,0x42,0xae,0x4b,0xae,0x40, 0xaf,0x49,0xab,0x40,0xa9,0x42,0xa6,0x3d,0xa3,0x45,0xa0,0x43,0xa0,0x4c,0x9e,0x40, 0xa1,0x44,0xa6,0x3f,0xa8,0x42,0xab,0x41,0xaf,0x4a,0xaf,0x3c,0xb0,0x48,0xae,0x3f, 0xac,0x47,0xa8,0x3f,0xa3,0x43,0xa0,0x41,0xa0,0x49,0x9f,0x3e,0xa1,0x49,0xa3,0x3d, 0xa7,0x48,0xa9,0x40,0xad,0x4a,0xae,0x40,0xaf,0x4e,0xad,0x42,0xac,0x4a,0xa7,0x41, 0xa5,0x49,0xa2,0x43,0x9f,0x46,0x9f,0x3e,0xa0,0x49,0xa2,0x45,0xa5,0x47,0xa8,0x3c, 0xab,0x45,0xac,0x45,0xac,0x47,0xab,0x40,0xa9,0x4c,0xa5,0x40,0xa2,0x4a,0xa0,0x3c, 0x9d,0x4b,0x9b,0x3d,0x9d,0x46,0xa0,0x3e,0xa5,0x4d,0xa6,0x3f,0xaa,0x4d,0xac,0x3c, 0xad,0x49,0xab,0x3f,0xaa,0x4a,0xa6,0x43,0xa3,0x4e,0x9d,0x41,0x9b,0x48,0x9a,0x3f, 0x9d,0x49,0x9c,0x40,0xa1,0x48,0xa4,0x40,0xa8,0x4d,0xa8,0x42,0xaa,0x4d,0xaa,0x42, 0xa8,0x48,0xa5,0x41,0xa2,0x46,0x9f,0x3e,0x9c,0x4c,0x9b,0x42,0x9b,0x44,0x9c,0x43, 0x9f,0x47,0xa4,0x3f,0xa5,0x49,0xa8,0x3e,0xaa,0x4a,0xa8,0x42,0xa8,0x4c,0xa3,0x3c, 0x9f,0x48,0x9d,0x3f,0x9c,0x44,0x97,0x41,0x98,0x49,0x9c,0x42,0x9f,0x46,0xa2,0x42, 0xa5,0x46,0xa7,0x3f,0xaa,0x44,0xa7,0x41,0xa7,0x4d,0xa5,0x40,0xa1,0x49,0x9b,0x42, 0x9c,0x4c,0x9a,0x3f,0x9a,0x47,0x9b,0x3f,0x9e,0x46,0xa2,0x44,0xa4,0x46,0xa6,0x3f, 0xa8,0x48,0xa9,0x3e,0xa6,0x46,0xa4,0x40,0xa1,0x4b,0x9e,0x3f,0x9c,0x48,0x99,0x3d, 0x99,0x47,0x99,0x41,0x9d,0x4b,0xa2,0x3d,0xa4,0x4c,0xa7,0x40,0xaa,0x4b,0xa8,0x3f, 0xa9,0x4a,0xa8,0x3d,0xa2,0x4a,0x9e,0x41,0x9f,0x4e,0x9a,0x42,0x98,0x4d,0x98,0x44, 0x9e,0x49,0x9f,0x41,0xa2,0x48,0xa7,0x44,0xaa,0x4d,0xa7,0x40,0xa9,0x4a,0xa8,0x3e, 0xa3,0x47,0xa0,0x3e,0x9d,0x4b,0x99,0x40,0x9a,0x49,0x9a,0x3d,0x9d,0x4a,0x9f,0x3d, 0xa2,0x4d,0xa5,0x41,0xa8,0x4d,0xa4,0x41,0xa5,0x4c,0xa4,0x43,0xa2,0x4a,0x9c,0x3b, 0x9a,0x4a,0x98,0x42,0x97,0x48,0x96,0x44,0x99,0x4d,0x9d,0x41,0xa2,0x49,0xa3,0x3f, 0xa5,0x47,0xa6,0x3f,0xa5,0x45,0xa3,0x3e,0xa1,0x49,0x9d,0x42,0x9a,0x48,0x98,0x3e, 0x97,0x49,0x98,0x3f,0x98,0x47,0x9d,0x3f,0xa0,0x4b,0xa5,0x3e,0xa7,0x44,0xa5,0x40, 0xa7,0x49,0xa5,0x41,0xa3,0x47,0xa0,0x44,0x9b,0x4a,0x97,0x40,0x98,0x4a,0x97,0x40, 0x9b,0x49,0x9d,0x41,0xa1,0x49,0xa5,0x3f,0xa8,0x47,0xa6,0x40,0xa7,0x48,0xa7,0x3e, 0xa5,0x4b,0x9f,0x40,0x9b,0x48,0x97,0x40,0x96,0x4c,0x98,0x3f,0x97,0x4e,0x97,0x41, 0x9f,0x49,0xa0,0x3d,0xa0,0x49,0xa2,0x42,0xa7,0x49,0xa3,0x44,0x9f,0x4a,0x9e,0x41, 0x9b,0x4c,0x96,0x3e,0x98,0x48,0x96,0x3d,0x98,0x4d,0x9a,0x3e,0x9f,0x46,0xa2,0x41, 0xa3,0x4c,0xa7,0x3f,0xa5,0x45,0xa4,0x41,0xa4,0x4b,0xa2,0x40,0x9c,0x47,0x99,0x43, 0x98,0x45,0x97,0x3f,0x98,0x47,0x99,0x41,0x9d,0x4f,0xa1,0x41,0xa5,0x48,0xa6,0x3f, 0xa6,0x4b,0xa5,0x3e,0xa5,0x44,0xa2,0x3d,0x9d,0x4f,0x9a,0x3e,0x98,0x47,0x96,0x41, 0x99,0x48,0x9c,0x3d,0x9e,0x49,0xa2,0x3f,0xa5,0x48,0xa6,0x41,0xa7,0x4c,0xa5,0x3f, 0xa4,0x48,0xa3,0x3d,0x9e,0x49,0x9a,0x3d,0x99,0x49,0x97,0x43,0x99,0x4b,0x9a,0x3f, 0x9e,0x46,0xa1,0x43,0xa4,0x45,0xa6,0x42,0xa7,0x4b,0xa6,0x3e,0xa6,0x46,0xa2,0x46, 0x9f,0x47,0x99,0x42,0x96,0x46,0x98,0x3d,0x96,0x4b,0x97,0x41,0x9b,0x4a,0x9f,0x3f, 0xa2,0x47,0xa4,0x42,0xa5,0x49,0xa3,0x40,0xa4,0x4b,0xa2,0x3f,0x9e,0x49,0x9a,0x3f, 0x97,0x4b,0x96,0x42,0x96,0x4b,0x97,0x3b,0x99,0x49,0x9e,0x40,0xa2,0x48,0xa4,0x43, 0xa6,0x49,0xa5,0x40,0xa5,0x47,0xa2,0x3f,0xa0,0x4c,0x9b,0x40,0x97,0x49,0x95,0x40, 0x93,0x4a,0x96,0x43,0x99,0x45,0x9c,0x3f,0xa0,0x46,0xa3,0x40,0xa5,0x4a,0xa4,0x41, 0xa6,0x4c,0xa2,0x42,0x9f,0x46,0x9b,0x3f,0x9a,0x4e,0x97,0x41,0x97,0x48,0x97,0x41, 0x9b,0x47,0x9e,0x3e,0xa1,0x49,0xa2,0x41,0xa5,0x4a,0xa6,0x3f,0xa5,0x4a,0xa3,0x3f, 0xa1,0x46,0x9c,0x3b,0x96,0x45,0x96,0x3f,0x97,0x4b,0x94,0x3f,0x96,0x49,0x9c,0x3f, 0xa1,0x4c,0xa4,0x43,0xa4,0x48,0xa6,0x3e,0xa5,0x4a,0xa2,0x3d,0x9f,0x47,0x9d,0x3e, 0x9a,0x48,0x96,0x40,0x94,0x47,0x94,0x47,0x98,0x4f,0x9a,0x40,0xa0,0x41,0xa2,0x37, 0xa5,0x48,0xa6,0x3f,0xa4,0x44,0xa1,0x41,0xa1,0x4c,0x95,0x41,0x99,0x53,0x98,0x54, 0x99,0x58,0x9b,0x55,0x9e,0x60,0xa3,0x57,0xa5,0x63,0xa7,0x55,0xa9,0x5c,0xa8,0x54, 0xa8,0x56,0xa6,0x4e,0xa1,0x55,0x9e,0x50,0x9d,0x5c,0x9a,0x54,0x9b,0x57,0x9a,0x52, 0x9e,0x56,0xa2,0x4e,0xa4,0x5d,0xa6,0x50,0xaa,0x5e,0xa8,0x4d,0xa6,0x59,0xa7,0x4c, 0xa4,0x59,0x9e,0x4e,0x9d,0x55,0x97,0x51,0x99,0x5c,0x99,0x50,0x9a,0x53,0x9e,0x4f, 0xa3,0x57,0xa6,0x54,0xa6,0x57,0xa6,0x4d,0xa6,0x58,0xa6,0x4f,0xa2,0x56,0x9c,0x54, 0x9b,0x5d,0x99,0x54,0x96,0x55,0x97,0x4f,0x99,0x59,0x9c,0x51,0xa1,0x5d,0xa5,0x4d, 0xa6,0x5b,0xa6,0x50,0xa7,0x54,0xa5,0x4d,0xa2,0x5e,0x9e,0x52,0x9b,0x56,0x98,0x50, 0x98,0x56,0x98,0x4f,0x9a,0x58,0x9d,0x4e,0xa2,0x57,0xa4,0x51,0xa7,0x60,0xa7,0x51, 0xa8,0x59,0xa6,0x50,0xa3,0x55,0x9d,0x53,0x9b,0x5b,0x98,0x4f,0x96,0x58,0x96,0x53, 0x99,0x5a,0x9a,0x54,0x9f,0x5a,0xa2,0x52,0xa5,0x5c,0xa7,0x4d,0xa8,0x5a,0xa4,0x51, 0xa3,0x58,0x9f,0x51,0x99,0x54,0x96,0x50,0x96,0x5e,0x94,0x51,0x96,0x5a,0x99,0x52, 0x9d,0x55,0xa0,0x50,0xa4,0x58,0xa4,0x54,0xa6,0x5f,0xa6,0x4e,0xa2,0x57,0x9f,0x4f, 0x9e,0x5b,0x98,0x51,0x97,0x57,0x97,0x53,0x98,0x5a,0x9a,0x52,0x9c,0x55,0xa1,0x52, 0xa3,0x5a,0xa4,0x4d,0xa4,0x57,0xa4,0x54,0xa2,0x5a,0x9c,0x53,0x9c,0x5a,0x98,0x4e, 0x97,0x58,0x95,0x51,0x98,0x58,0x99,0x54,0x9d,0x5a,0x9f,0x51,0xa2,0x57,0xa5,0x4d, 0xa5,0x58,0xa3,0x51,0xa2,0x58,0x9f,0x4f,0x9b,0x58,0x97,0x4d,0x95,0x59,0x93,0x52, 0x95,0x5c,0x97,0x52,0x9a,0x5a,0x9d,0x54,0xa0,0x5d,0xa1,0x50,0xa4,0x5b,0xa2,0x53, 0x9f,0x56,0x9d,0x52,0x9b,0x58,0x96,0x51,0x94,0x5d,0x93,0x50,0x94,0x59,0x96,0x4f, 0x99,0x57,0x9d,0x51,0xa0,0x58,0xa0,0x52,0xa3,0x60,0xa3,0x52,0xa1,0x57,0x9d,0x52, 0x9d,0x5a,0x99,0x4f,0x94,0x54,0x94,0x52,0x94,0x5a,0x95,0x4e,0x99,0x55,0x9b,0x51, 0xa0,0x5d,0xa1,0x4d,0xa2,0x56,0xa1,0x52,0xa0,0x5a,0x9d,0x52,0x99,0x5b,0x97,0x50, 0x94,0x5f,0x90,0x52,0x92,0x58,0x94,0x50,0x98,0x5a,0x9a,0x4f,0x9d,0x57,0xa0,0x55, 0xa0,0x59,0xa0,0x4f,0x9f,0x5b,0x9d,0x4f,0x9a,0x5b,0x95,0x51,0x93,0x56,0x90,0x51, 0x91,0x5d,0x93,0x52,0x95,0x55,0x9a,0x4f,0x9d,0x60,0x9f,0x55,0xa0,0x57,0xa0,0x4d, 0xa1,0x5a,0x9d,0x52,0x99,0x56,0x97,0x56,0x95,0x5e,0x92,0x4e,0x92,0x58,0x92,0x51, 0x95,0x59,0x98,0x50,0x9c,0x59,0x9e,0x50,0xa0,0x5d,0xa0,0x4e,0xa0,0x5a,0x9c,0x50, 0x99,0x55,0x95,0x50,0x94,0x59,0x8e,0x50,0x8f,0x5a,0x91,0x50,0x94,0x59,0x96,0x51, 0x9a,0x59,0x9e,0x56,0x9f,0x5a,0xa0,0x53,0x9f,0x5a,0x9d,0x53,0x9a,0x59,0x96,0x51, 0x93,0x5a,0x90,0x51,0x8f,0x54,0x91,0x4f,0x92,0x56,0x93,0x50,0x98,0x57,0x9c,0x4c, 0x9c,0x59,0x9d,0x51,0x9e,0x5d,0x9c,0x4f,0x9a,0x61,0x97,0x4a,0x94,0x5b,0x8f,0x55, 0x8f,0x57,0x8e,0x50,0x91,0x5b,0x95,0x4e,0x98,0x5c,0x9c,0x4f,0x9d,0x55,0x9f,0x4d, 0x9e,0x5d,0x9b,0x53,0x99,0x57,0x96,0x50,0x92,0x5d,0x8f,0x52,0x8d,0x57,0x8d,0x50, 0x90,0x5e,0x92,0x53,0x97,0x5a,0x99,0x52,0x9c,0x5a,0x9d,0x53,0x9d,0x58,0x9b,0x53, 0x99,0x5a,0x95,0x51,0x93,0x59,0x90,0x53,0x8f,0x5e,0x8d,0x53,0x8e,0x5a,0x91,0x52, 0x96,0x5b,0x98,0x52,0x9b,0x5a,0x9d,0x4f,0x9c,0x5c,0x98,0x51,0x97,0x58,0x96,0x54, 0x91,0x58,0x8c,0x51,0x8c,0x59,0x8c,0x56,0x8e,0x5c,0x8e,0x52,0x94,0x58,0x97,0x56, 0x99,0x57,0x9a,0x53,0x9c,0x54,0x98,0x51,0x97,0x5b,0x95,0x4e,0x93,0x5a,0x8d,0x54, 0x8c,0x5b,0x8c,0x4f,0x8e,0x53,0x8e,0x52,0x93,0x5b,0x95,0x4e,0x99,0x59,0x98,0x51, 0x99,0x5a,0x99,0x52,0x98,0x55,0x94,0x4d,0x92,0x5d,0x8d,0x53,0x8b,0x5b,0x88,0x53, 0x8c,0x5c,0x8d,0x52,0x8f,0x5a,0x94,0x50,0x98,0x5f,0x98,0x53,0x9a,0x5c,0x99,0x51, 0x99,0x60,0x95,0x55,0x92,0x5a,0x8d,0x53,0x8b,0x5b,0x8a,0x50,0x8b,0x57,0x8d,0x4f, 0x90,0x5c,0x94,0x53,0x98,0x59,0x97,0x50,0x98,0x5e,0x99,0x51,0x99,0x5a,0x94,0x50, 0x91,0x5b,0x8f,0x51,0x8d,0x56,0x8a,0x51,0x8b,0x5b,0x8d,0x51,0x91,0x57,0x94,0x52, 0x99,0x5d,0x99,0x52,0x9c,0x58,0x9d,0x4e,0x9c,0x5b,0x99,0x4f,0x97,0x5a,0x92,0x51, 0x8f,0x5b,0x8d,0x55,0x8e,0x52,0x90,0x4f,0x92,0x5e,0x95,0x53,0x99,0x56,0x9b,0x51, 0x9e,0x58,0x9c,0x52,0x9c,0x58,0x9a,0x4d,0x97,0x5c,0x92,0x53,0x90,0x5c,0x8c,0x50, 0x8c,0x59,0x8e,0x52,0x92,0x59,0x94,0x53,0x97,0x5a,0x9a,0x54,0x9c,0x58,0x9c,0x4f, 0x9b,0x5c,0x9a,0x54,0x96,0x57,0x92,0x58,0x8f,0x5e,0x8c,0x50,0x8c,0x59,0x8d,0x50, 0x90,0x54,0x95,0x52,0x98,0x55,0x9a,0x52,0x9c,0x5c,0x9c,0x51,0x9c,0x58,0x98,0x51, 0x97,0x57,0x95,0x54,0x8f,0x57,0x8b,0x55,0x8b,0x5c,0x8b,0x4e,0x8e,0x5c,0x93,0x4f, 0x97,0x5b,0x99,0x50,0x9c,0x5a,0x9c,0x50,0x9c,0x59,0x99,0x52,0x97,0x55,0x93,0x54, 0x91,0x5a,0x8d,0x52,0x8c,0x5d,0x8d,0x4d,0x91,0x5c,0x93,0x54,0x98,0x5b,0x9a,0x52, 0x9c,0x59,0x9d,0x51,0x9e,0x59,0x9b,0x4f,0x99,0x5d,0x95,0x51,0x92,0x59,0x8d,0x52, 0x8e,0x58,0x90,0x4f,0x90,0x57,0x94,0x55,0x98,0x59,0x9b,0x56,0x9f,0x57,0x9e,0x52, 0x9e,0x58,0x9e,0x4f,0x9c,0x5a,0x95,0x50,0x91,0x5d,0x8d,0x50,0x8c,0x55,0x8d,0x4b, 0x90,0x5d,0x92,0x52,0x98,0x5f,0x9b,0x55,0x9f,0x5f,0x9e,0x50,0x9f,0x53,0x9e,0x50, 0x9e,0x59,0x9a,0x4e,0x96,0x59,0x92,0x54,0x92,0x5f,0x90,0x50,0x92,0x5c,0x95,0x54, 0x98,0x59,0x9b,0x4f,0x9f,0x4f,0x9e,0x48,0xa1,0x59,0xa0,0x4e,0x9d,0x58,0x9a,0x50, 0x96,0x5a,0x8c,0x55,0x94,0x4d,0x95,0x45,0x97,0x52,0x9c,0x4e,0xa0,0x5b,0xa2,0x50, 0xa5,0x52,0xa6,0x4c,0xa3,0x50,0xa2,0x47,0xa0,0x56,0x9b,0x49,0x98,0x4f,0x96,0x4b, 0x94,0x54,0x96,0x46,0x98,0x53,0x99,0x48,0x9e,0x56,0xa1,0x48,0xa1,0x52,0xa3,0x4a, 0xa5,0x4e,0xa1,0x47,0x9d,0x52,0x9b,0x48,0x97,0x52,0x94,0x48,0x94,0x4f,0x95,0x43, 0x96,0x50,0x9b,0x47,0x9e,0x51,0xa1,0x4a,0xa3,0x54,0xa5,0x45,0xa4,0x51,0xa2,0x47, 0x9f,0x53,0x9d,0x48,0x99,0x4d,0x94,0x48,0x94,0x54,0x94,0x48,0x97,0x4f,0x9a,0x49, 0x9e,0x4d,0xa0,0x49,0xa2,0x50,0xa3,0x4c,0xa3,0x51,0xa3,0x49,0xa0,0x50,0x9e,0x4b, 0x99,0x4f,0x95,0x4b,0x93,0x4f,0x93,0x48,0x94,0x53,0x97,0x48,0x9c,0x4b,0xa0,0x48, 0xa0,0x53,0xa3,0x49,0xa3,0x4d,0xa0,0x50,0xa0,0x55,0x9c,0x4d,0x97,0x50,0x95,0x4c, 0x93,0x4c,0x92,0x4b,0x94,0x52,0x96,0x4c,0x9a,0x56,0xa0,0x48,0xa1,0x4f,0xa2,0x47, 0xa3,0x51,0xa2,0x49,0xa1,0x4e,0x9c,0x4b,0x99,0x55,0x95,0x47,0x93,0x52,0x93,0x4a, 0x93,0x52,0x96,0x4c,0x99,0x53,0x9e,0x46,0x9f,0x53,0xa2,0x4a,0xa3,0x51,0xa1,0x47, 0x9f,0x50,0x9c,0x49,0x9a,0x4d,0x94,0x4b,0x91,0x52,0x91,0x48,0x92,0x52,0x94,0x48, 0x97,0x50,0x9c,0x48,0x9f,0x50,0x9f,0x4b,0xa0,0x54,0xa2,0x47,0x9f,0x4d,0x9a,0x49, 0x99,0x50,0x94,0x4a,0x93,0x4e,0x91,0x47,0x92,0x55,0x94,0x4a,0x97,0x50,0x9a,0x49, 0x9e,0x4f,0xa0,0x4a,0xa1,0x4e,0xa0,0x47,0xa0,0x58,0x9d,0x4a,0x99,0x53,0x95,0x45, 0x92,0x51,0x91,0x48,0x91,0x53,0x93,0x4a,0x95,0x53,0x9a,0x49,0x9e,0x52,0x9f,0x49, 0xa0,0x50,0xa1,0x48,0x9f,0x50,0x9d,0x4b,0x99,0x52,0x95,0x47,0x93,0x51,0x92,0x4c, 0x91,0x51,0x92,0x49,0x96,0x4f,0x99,0x49,0x9c,0x51,0x9e,0x46,0xa1,0x52,0xa0,0x4c, 0x9e,0x53,0x9c,0x4b,0x9a,0x4d,0x95,0x48,0x93,0x55,0x92,0x4e,0x91,0x55,0x93,0x48, 0x95,0x53,0x99,0x4c,0x9c,0x51,0x9e,0x4a,0xa0,0x56,0xa1,0x4c,0x9f,0x4f,0x9d,0x45, 0x9a,0x52,0x94,0x49,0x90,0x50,0x8f,0x4a,0x8f,0x53,0x90,0x48,0x91,0x50,0x96,0x4e, 0x9a,0x54,0x9e,0x48,0x9e,0x50,0x9e,0x4a,0x9e,0x4e,0x9d,0x48,0x9a,0x56,0x95,0x49, 0x91,0x50,0x90,0x47,0x8d,0x52,0x90,0x49,0x93,0x56,0x98,0x4b,0x9a,0x51,0x9d,0x4b, 0x9e,0x51,0x9f,0x4b,0x9f,0x4e,0x9c,0x48,0x99,0x54,0x95,0x4b,0x91,0x52,0x90,0x47, 0x8e,0x50,0x8f,0x48,0x92,0x51,0x95,0x4a,0x99,0x56,0x9c,0x49,0x9f,0x55,0x9f,0x4c, 0x9f,0x50,0x9d,0x49,0x9a,0x53,0x96,0x49,0x92,0x52,0x8f,0x48,0x8e,0x4f,0x8f,0x47, 0x92,0x4f,0x94,0x46,0x97,0x50,0x9a,0x47,0x9c,0x51,0x9f,0x45,0x9e,0x54,0x9c,0x4a, 0x99,0x50,0x97,0x48,0x93,0x4f,0x8f,0x4b,0x8d,0x52,0x8e,0x48,0x90,0x4c,0x93,0x49, 0x97,0x51,0x9a,0x49,0x9b,0x52,0x9c,0x46,0x9e,0x4e,0x9b,0x49,0x98,0x53,0x95,0x4b, 0x90,0x55,0x8d,0x4d,0x8c,0x54,0x8c,0x47,0x8e,0x57,0x91,0x4d,0x95,0x53,0x9a,0x48, 0x9c,0x53,0x9c,0x4c,0x9c,0x52,0x9c,0x46,0x99,0x54,0x96,0x4d,0x92,0x4e,0x8f,0x49, 0x8e,0x4f,0x8e,0x4e,0x8f,0x53,0x91,0x49,0x95,0x50,0x96,0x50,0x9b,0x4f,0x9a,0x4b, 0x9c,0x53,0x9b,0x48,0x9a,0x4f,0x95,0x49,0x92,0x56,0x8d,0x4d,0x8d,0x52,0x8c,0x4a, 0x8d,0x4f,0x90,0x49,0x94,0x4f,0x97,0x4a,0x9b,0x56,0x9c,0x4c,0x9a,0x53,0x9b,0x4b, 0x9b,0x52,0x97,0x4d,0x93,0x51,0x8f,0x49,0x8d,0x54,0x8b,0x4a,0x8b,0x53,0x90,0x4a, 0x94,0x51,0x96,0x49,0x99,0x51,0x9b,0x49,0x9d,0x58,0x9c,0x48,0x99,0x51,0x98,0x49, 0x93,0x50,0x90,0x4b,0x8d,0x52,0x8d,0x4c,0x8c,0x56,0x8f,0x4b,0x93,0x55,0x97,0x47, 0x99,0x52,0x9d,0x4a,0x9c,0x50,0x9b,0x4e,0x99,0x54,0x99,0x4a,0x95,0x4d,0x8f,0x47, 0x8d,0x57,0x8d,0x47,0x8c,0x52,0x8f,0x48,0x94,0x5a,0x96,0x4b,0x99,0x50,0x9b,0x4b, 0x9d,0x55,0x9e,0x4a,0x9b,0x50,0x99,0x49,0x95,0x51,0x92,0x4b,0x8f,0x50,0x8d,0x4b, 0x8e,0x51,0x8f,0x49,0x92,0x52,0x96,0x4c,0x9a,0x4d,0x9c,0x4c,0x9d,0x54,0x9c,0x4b, 0x9d,0x4e,0x9a,0x4a,0x97,0x53,0x91,0x4a,0x8c,0x51,0x8b,0x47,0x8e,0x52,0x8e,0x4c, 0x91,0x53,0x97,0x49,0x9a,0x50,0x9f,0x48,0x9e,0x50,0x9d,0x4a,0x9d,0x53,0x9b,0x47, 0x99,0x51,0x94,0x4b,0x92,0x55,0x8f,0x48,0x8f,0x54,0x91,0x4d,0x92,0x56,0x97,0x4c, 0x9a,0x53,0x9d,0x4a,0x9e,0x50,0x9d,0x48,0x9e,0x53,0x9d,0x4b,0x9a,0x54,0x96,0x4b, 0x93,0x57,0x91,0x4d,0x91,0x4e,0x92,0x49,0x95,0x53,0x98,0x4b,0x9c,0x53,0x9f,0x49, 0xa0,0x55,0xa1,0x4c,0x9f,0x51,0x9f,0x46,0x9c,0x4f,0x97,0x46,0x94,0x54,0x91,0x4a, 0x90,0x55,0x91,0x4a,0x93,0x4d,0x97,0x47,0x9b,0x55,0x9d,0x4a,0xa0,0x4f,0xa0,0x4a, 0x9f,0x56,0x9f,0x4e,0x9b,0x4e,0x97,0x49,0x94,0x51,0x92,0x4d,0x8e,0x55,0x90,0x49, 0x93,0x53,0x98,0x4e,0x9b,0x55,0xa0,0x49,0xa0,0x55,0xa2,0x4a,0xa1,0x50,0x9f,0x49, 0x9c,0x53,0x99,0x4b,0x94,0x53,0x92,0x4d,0x92,0x4f,0x91,0x49,0x93,0x4f,0x97,0x49, 0x9b,0x55,0x9e,0x4d,0xa0,0x4e,0xa0,0x49,0xa1,0x56,0x9e,0x48,0x9d,0x57,0x99,0x48, 0x96,0x56,0x91,0x47,0x93,0x4f,0x93,0x4d,0x93,0x56,0x95,0x4c,0x97,0x53,0x9a,0x4a, 0xa0,0x51,0x9f,0x4d,0x9e,0x4f,0x9d,0x4d,0x9f,0x4e,0x97,0x4a,0x93,0x51,0x92,0x45, 0x92,0x52,0x93,0x4a,0x93,0x52,0x95,0x4b,0x99,0x55,0x9e,0x49,0xa0,0x52,0xa1,0x4d, 0xa1,0x55,0xa0,0x4c,0x9e,0x51,0x9c,0x4b,0x97,0x52,0x94,0x4c,0x93,0x54,0x92,0x4a, 0x93,0x54,0x97,0x4e,0x99,0x4f,0x9c,0x4d,0xa0,0x53,0xa1,0x49,0xa0,0x4b,0xa1,0x40, 0xa0,0x4c,0x9d,0x4a,0x9a,0x4e,0x93,0x49,0x91,0x53,0x8c,0x4e,0x98,0x35,0x9c,0x33, 0xa2,0x38,0xa5,0x3a,0xa6,0x47,0xa7,0x38,0xa8,0x43,0xa7,0x3b,0xa2,0x3b,0x9e,0x35, 0x9c,0x3e,0x98,0x34,0x95,0x3b,0x95,0x33,0x9a,0x3e,0x9d,0x35,0xa1,0x3c,0xa3,0x32, 0xa7,0x40,0xa8,0x35,0xa8,0x3c,0xa6,0x34,0xa5,0x3d,0xa1,0x35,0x9c,0x3a,0x99,0x3a, 0x97,0x39,0x98,0x37,0x9c,0x3a,0x9e,0x34,0xa3,0x3d,0xa7,0x35,0xa9,0x38,0xaa,0x31, 0xac,0x3c,0xab,0x34,0xa7,0x37,0xa3,0x33,0xa0,0x3c,0x9d,0x3b,0x9b,0x3c,0x9c,0x36, 0x9c,0x3f,0x9d,0x37,0xa2,0x38,0xa6,0x31,0xa9,0x3e,0xaa,0x35,0xaa,0x3c,0xa9,0x36, 0xa8,0x3c,0xa4,0x36,0x9e,0x3c,0x9b,0x31,0x9c,0x3c,0x9c,0x35,0x9c,0x3d,0x9d,0x33, 0xa2,0x39,0xa5,0x33,0xa9,0x3a,0xa9,0x35,0xab,0x3a,0xab,0x32,0xa6,0x38,0xa3,0x32, 0xa1,0x3d,0x9e,0x33,0x9a,0x3a,0x9a,0x34,0x9c,0x41,0x9f,0x32,0xa3,0x3d,0xa7,0x32, 0xaa,0x3d,0xab,0x35,0xac,0x3d,0xab,0x35,0xab,0x3f,0xa6,0x33,0xa2,0x3d,0x9e,0x35, 0x9e,0x3d,0x9b,0x37,0x9b,0x3b,0x9e,0x3a,0xa2,0x3e,0xa7,0x36,0xaa,0x3b,0xaa,0x37, 0xac,0x3d,0xaa,0x36,0xa9,0x3b,0xa6,0x36,0xa3,0x3d,0x9c,0x34,0x9a,0x3c,0x99,0x38, 0x9b,0x3f,0x9b,0x33,0xa0,0x3c,0xa4,0x37,0xa7,0x3a,0xaa,0x39,0xab,0x34,0xa9,0x39, 0xa6,0x41,0xa5,0x33,0xa1,0x3b,0x9b,0x33,0x9a,0x3c,0x97,0x34,0x9a,0x3b,0x9a,0x34, 0x9e,0x3c,0xa3,0x34,0xa5,0x3d,0xa8,0x33,0xa9,0x3d,0xaa,0x2f,0xa8,0x3b,0xa6,0x36, 0xa2,0x41,0x9e,0x34,0x9b,0x3a,0x99,0x34,0x98,0x41,0x97,0x35,0x9c,0x3e,0xa3,0x34, 0xa4,0x3b,0xa6,0x33,0xa8,0x3b,0xaa,0x35,0xa7,0x3e,0xa4,0x32,0xa3,0x39,0x9e,0x36, 0x9c,0x3f,0x9a,0x35,0x99,0x39,0x99,0x32,0x9e,0x40,0xa1,0x35,0xa6,0x3c,0xa8,0x36, 0xab,0x3f,0xaa,0x36,0xaa,0x3e,0xa6,0x32,0xa4,0x3c,0xa1,0x33,0x9d,0x39,0x9a,0x37, 0x9a,0x3b,0x9b,0x38,0x9e,0x3b,0xa3,0x36,0xa6,0x3d,0xa8,0x37,0xab,0x3d,0xab,0x33, 0xaa,0x3e,0xa9,0x33,0xa6,0x3d,0xa0,0x32,0x9d,0x42,0x9b,0x30,0x9b,0x3b,0x9b,0x3a, 0x9e,0x3b,0xa0,0x35,0xa5,0x3b,0xa8,0x36,0xab,0x43,0xab,0x33,0xab,0x3c,0xa8,0x31, 0xa4,0x3f,0xa0,0x37,0x9e,0x3a,0x9a,0x31,0x98,0x40,0x99,0x34,0x9d,0x3e,0xa0,0x35, 0xa5,0x3d,0xa8,0x37,0xab,0x3c,0xaa,0x36,0xab,0x3c,0xab,0x34,0xa8,0x3c,0xa2,0x33, 0xa0,0x3d,0x9a,0x34,0x9a,0x3e,0x9b,0x34,0x9e,0x3d,0x9f,0x33,0xa6,0x3c,0xa7,0x33, 0xab,0x3b,0xab,0x33,0xac,0x3d,0xa8,0x3a,0xa5,0x3a,0xa2,0x35,0x9d,0x39,0x9a,0x34, 0x98,0x39,0x99,0x30,0x9b,0x3a,0x9e,0x32,0xa2,0x40,0xa6,0x36,0xa7,0x3d,0xaa,0x38, 0xac,0x3c,0xa9,0x35,0xa6,0x3b,0xa2,0x37,0x9f,0x3f,0x9a,0x32,0x9a,0x3a,0x98,0x34, 0x9b,0x39,0x9e,0x34,0xa2,0x3a,0xa5,0x34,0xa9,0x3f,0xa9,0x33,0xaa,0x3d,0xa8,0x30, 0xa8,0x3b,0xa4,0x36,0xa0,0x3b,0x9c,0x36,0x9a,0x3e,0x99,0x34,0x9b,0x40,0x9d,0x35, 0xa1,0x42,0xa5,0x35,0xa8,0x37,0xa8,0x35,0xac,0x3e,0xa9,0x35,0xa7,0x3d,0xa4,0x3a, 0xa2,0x3b,0x9a,0x39,0x9a,0x3b,0x98,0x34,0x9a,0x3e,0x9c,0x38,0x9f,0x40,0xa4,0x35, 0xa8,0x3e,0xa8,0x37,0xa9,0x3a,0xa9,0x34,0xa8,0x44,0xa4,0x39,0xa0,0x3b,0x9c,0x37, 0x9a,0x3f,0x98,0x34,0x9a,0x3e,0x9a,0x37,0x9e,0x3f,0xa3,0x38,0xa6,0x3f,0xa8,0x38, 0xa9,0x3c,0xa9,0x35,0xa7,0x3b,0xa3,0x35,0x9f,0x41,0x9c,0x3a,0x99,0x3f,0x98,0x37, 0x99,0x42,0x9a,0x32,0x9f,0x3d,0xa2,0x36,0xa8,0x3f,0xa5,0x37,0xa7,0x3c,0xa8,0x36, 0xa7,0x3e,0xa0,0x37,0x9e,0x3d,0x9c,0x33,0x97,0x40,0x95,0x38,0x96,0x40,0x9b,0x36, 0x9d,0x3f,0x9f,0x36,0xa4,0x3e,0xa5,0x33,0xa9,0x3f,0xa8,0x3a,0xa5,0x3e,0xa2,0x35, 0xa0,0x3f,0x99,0x35,0x99,0x3a,0x96,0x37,0x96,0x3c,0x97,0x34,0x9b,0x3c,0x9f,0x32, 0xa4,0x3d,0xa6,0x39,0xa7,0x3d,0xa7,0x38,0xa7,0x3f,0xa4,0x3a,0xa0,0x38,0x9d,0x36, 0x9b,0x3f,0x98,0x38,0x97,0x3d,0x98,0x34,0x9b,0x3e,0x9e,0x36,0xa2,0x3c,0xa4,0x37, 0xa7,0x3d,0xa7,0x3a,0xa6,0x3a,0xa3,0x37,0xa2,0x40,0x9d,0x37,0x99,0x3d,0x97,0x37, 0x99,0x3e,0x98,0x36,0x9c,0x39,0x9e,0x36,0xa4,0x3f,0xa6,0x38,0xa8,0x3f,0xa8,0x33, 0xa9,0x3f,0xa5,0x34,0xa3,0x3e,0xa0,0x36,0x9c,0x3c,0x99,0x35,0x97,0x3d,0x98,0x32, 0x9b,0x40,0x9e,0x31,0xa1,0x3b,0xa3,0x33,0xa7,0x41,0xa8,0x37,0xa5,0x41,0xa5,0x35, 0xa4,0x3c,0x9e,0x38,0x9c,0x3c,0x99,0x35,0x97,0x40,0x98,0x37,0x99,0x42,0x9e,0x35, 0xa2,0x3f,0xa6,0x35,0xa9,0x3f,0xa9,0x37,0xa9,0x41,0xa6,0x37,0xa5,0x3e,0xa1,0x37, 0x9f,0x3e,0x9b,0x37,0x98,0x3b,0x98,0x32,0x9c,0x3f,0x9d,0x34,0xa3,0x3b,0xa5,0x36, 0xa8,0x3c,0xa8,0x31,0xa8,0x40,0xa7,0x2e,0xa5,0x40,0xa1,0x34,0x9e,0x3f,0x9b,0x35, 0x9a,0x3f,0x99,0x33,0x99,0x41,0x9d,0x38,0xa1,0x40,0xa5,0x39,0xa9,0x3d,0xaa,0x35, 0xaa,0x3d,0xa7,0x34,0xa6,0x3f,0xa2,0x39,0x9e,0x3f,0x9a,0x36,0x99,0x3c,0x98,0x35, 0x9b,0x3f,0x9e,0x31,0xa2,0x3c,0xa6,0x34,0xa8,0x3b,0xa8,0x38,0xa9,0x3d,0xa9,0x36, 0xa6,0x40,0xa2,0x3b,0x9f,0x3e,0x9b,0x34,0x98,0x3b,0x98,0x36,0x98,0x41,0x9b,0x32, 0xa1,0x3d,0xa4,0x34,0xa5,0x3c,0xa6,0x33,0xa8,0x41,0xa7,0x37,0xa4,0x39,0xa2,0x35, 0xa1,0x3d,0x9b,0x35,0x9a,0x41,0x99,0x32,0x97,0x3e,0x99,0x35,0xa1,0x40,0xa3,0x35, 0xa3,0x3a,0xa7,0x39,0xaa,0x3a,0xa7,0x37,0xa7,0x3e,0xa3,0x36,0xa1,0x3f,0x9e,0x36, 0x9c,0x3e,0x9a,0x36,0x9c,0x3e,0x9d,0x35,0xa1,0x3f,0xa4,0x32,0xa8,0x3f,0xa7,0x3c, 0xa9,0x45,0xa9,0x35,0xa7,0x31,0xa5,0x2c,0xa3,0x38,0x9e,0x33,0x9b,0x3c,0x99,0x36, 0x98,0x42,0x93,0x3b,0xa3,0x4d,0xa8,0x3f,0xad,0x4d,0xad,0x4c,0xad,0x57,0xac,0x51, 0xaa,0x51,0xa6,0x4b,0xa3,0x4d,0xa0,0x48,0x9d,0x4f,0x9c,0x45,0xa0,0x4a,0xa3,0x48, 0xa7,0x4b,0xaa,0x43,0xac,0x52,0xae,0x40,0xb0,0x48,0xae,0x46,0xad,0x4b,0xa9,0x48, 0xa5,0x52,0xa1,0x46,0x9f,0x4f,0x9e,0x46,0x9f,0x50,0xa2,0x4a,0xa7,0x4b,0xab,0x46, 0xae,0x4b,0xb0,0x44,0xb1,0x4e,0xae,0x4a,0xae,0x4e,0xaa,0x47,0xa7,0x4c,0xa3,0x45, 0xa1,0x50,0x9f,0x42,0xa1,0x52,0xa2,0x42,0xa4,0x50,0xaa,0x45,0xab,0x4c,0xae,0x46, 0xac,0x52,0xae,0x47,0xab,0x4b,0xa9,0x41,0xa7,0x4d,0xa2,0x46,0x9f,0x50,0x9d,0x46, 0xa1,0x4e,0x9f,0x44,0xa3,0x4d,0xa8,0x47,0xab,0x50,0xae,0x44,0xb2,0x4d,0xb0,0x46, 0xac,0x4d,0xa8,0x45,0xa8,0x4d,0xa0,0x45,0x9c,0x4f,0x9c,0x47,0xa0,0x47,0xa0,0x44, 0xa5,0x4c,0xaa,0x48,0xad,0x51,0xaf,0x4a,0xb0,0x4f,0xb0,0x45,0xaf,0x4c,0xac,0x45, 0xa8,0x51,0xa4,0x45,0xa3,0x49,0x9e,0x45,0xa0,0x4e,0xa1,0x42,0xa5,0x4e,0xa8,0x45, 0xaa,0x50,0xae,0x46,0xb0,0x4c,0xad,0x44,0xae,0x51,0xae,0x48,0xa9,0x4c,0xa5,0x46, 0xa4,0x4b,0xa1,0x41,0xa2,0x4e,0xa1,0x45,0xa6,0x51,0xab,0x47,0xae,0x4d,0xaf,0x43, 0xb4,0x4c,0xb4,0x46,0xb3,0x4a,0xb1,0x46,0xab,0x4b,0xa7,0x47,0xa5,0x4e,0xa2,0x48, 0x9e,0x4e,0xa0,0x48,0xa5,0x4c,0xa7,0x48,0xa9,0x50,0xb1,0x49,0xb3,0x4f,0xb2,0x45, 0xb4,0x4b,0xb0,0x48,0xae,0x47,0xa9,0x42,0xa6,0x4f,0xa5,0x44,0xa5,0x50,0xa4,0x48, 0xa6,0x50,0xab,0x44,0xae,0x4d,0xb2,0x46,0xb3,0x4e,0xb2,0x44,0xb4,0x4b,0xb2,0x44, 0xb0,0x4e,0xaa,0x45,0xa8,0x4e,0xa6,0x42,0xa4,0x51,0xa3,0x48,0xa8,0x4d,0xaa,0x4b, 0xae,0x4d,0xaf,0x48,0xb2,0x4f,0xb2,0x46,0xb1,0x50,0xaf,0x48,0xaf,0x4d,0xaa,0x47, 0xa7,0x4b,0xa6,0x45,0xa3,0x51,0xa3,0x42,0xa6,0x54,0xa8,0x49,0xad,0x51,0xb1,0x43, 0xb3,0x50,0xb4,0x4a,0xb5,0x4f,0xb4,0x47,0xb0,0x50,0xac,0x48,0xa9,0x4f,0xa4,0x49, 0xa4,0x51,0xa1,0x47,0xa4,0x4a,0xa8,0x47,0xaf,0x4f,0xaf,0x47,0xb3,0x4d,0xb3,0x49, 0xb5,0x4b,0xb2,0x47,0xae,0x4a,0xaa,0x47,0xa7,0x4f,0xa2,0x45,0xa0,0x4b,0xa0,0x48, 0xa4,0x4e,0xa7,0x44,0xac,0x4b,0xaf,0x49,0xb4,0x4d,0xb5,0x47,0xb6,0x4d,0xb3,0x44, 0xaf,0x4e,0xad,0x48,0xa9,0x4b,0xa4,0x45,0xa3,0x51,0xa3,0x45,0xa5,0x4d,0xa8,0x46, 0xab,0x4f,0xaf,0x44,0xb4,0x4c,0xb3,0x47,0xb4,0x50,0xb4,0x45,0xb4,0x4d,0xae,0x43, 0xa9,0x52,0xa8,0x43,0xa7,0x4a,0xa1,0x44,0xa5,0x4d,0xa9,0x46,0xac,0x4c,0xae,0x45, 0xb4,0x4e,0xb5,0x49,0xb5,0x4b,0xb4,0x42,0xb3,0x50,0xaf,0x48,0xac,0x4d,0xa8,0x46, 0xa4,0x50,0xa4,0x46,0xa4,0x4e,0xa5,0x47,0xa9,0x4b,0xac,0x48,0xb1,0x4c,0xb3,0x48, 0xb4,0x52,0xb4,0x44,0xb3,0x4b,0xaf,0x42,0xac,0x4c,0xa8,0x48,0xa3,0x4b,0xa1,0x47, 0xa3,0x4b,0xa4,0x43,0xa8,0x4c,0xac,0x48,0xb1,0x51,0xb2,0x49,0xb3,0x4a,0xb4,0x4b, 0xb3,0x4f,0xac,0x46,0xab,0x4e,0xa8,0x46,0xa3,0x51,0xa0,0x47,0xa2,0x4d,0xa6,0x49, 0xa9,0x4e,0xad,0x4d,0xb2,0x4c,0xb2,0x4a,0xb3,0x50,0xb4,0x4a,0xb3,0x48,0xaf,0x47, 0xad,0x4d,0xa8,0x47,0xa6,0x4d,0xa2,0x46,0xa2,0x51,0xa5,0x46,0xa7,0x4d,0xab,0x42, 0xaf,0x50,0xb1,0x47,0xb3,0x51,0xb2,0x42,0xb3,0x53,0xb0,0x4b,0xad,0x52,0xa9,0x46, 0xa6,0x4f,0xa6,0x4a,0xa6,0x4f,0xa6,0x45,0xa8,0x4b,0xac,0x45,0xb0,0x4d,0xaf,0x47, 0xb3,0x4f,0xb2,0x49,0xaf,0x4e,0xac,0x45,0xac,0x4e,0xa8,0x4a,0xa4,0x4c,0xa3,0x48, 0xa1,0x4e,0xa1,0x44,0xa5,0x51,0xa9,0x44,0xab,0x4f,0xac,0x43,0xb2,0x52,0xb1,0x46, 0xb0,0x4c,0xaf,0x46,0xac,0x4e,0xa7,0x45,0xa4,0x54,0xa2,0x47,0xa0,0x4c,0x9f,0x45, 0xa4,0x53,0xa8,0x49,0xac,0x4f,0xad,0x46,0xb0,0x50,0xb0,0x47,0xaf,0x4b,0xab,0x43, 0xab,0x4e,0xa6,0x47,0xa5,0x4d,0xa2,0x46,0xa1,0x52,0xa2,0x4c,0xa4,0x4d,0xa8,0x43, 0xac,0x51,0xae,0x46,0xb1,0x4b,0xb3,0x46,0xb2,0x52,0xb1,0x47,0xaf,0x4b,0xa9,0x45, 0xa7,0x4d,0xa2,0x49,0xa0,0x4a,0xa2,0x48,0xa2,0x50,0xa3,0x43,0xaa,0x4d,0xac,0x47, 0xaf,0x4b,0xaf,0x4d,0xb0,0x4c,0xaf,0x43,0xad,0x53,0xaa,0x49,0xa6,0x4f,0xa2,0x47, 0xa2,0x53,0xa3,0x46,0xa4,0x4c,0xa5,0x46,0xaa,0x55,0xae,0x48,0xb1,0x4e,0xb0,0x42, 0xb1,0x4d,0xb0,0x49,0xae,0x4f,0xa9,0x46,0xa5,0x54,0xa2,0x47,0xa1,0x4b,0xa0,0x49, 0xa1,0x4e,0xa5,0x48,0xaa,0x4e,0xad,0x45,0xb0,0x52,0xb3,0x49,0xb3,0x4d,0xb1,0x4a, 0xb0,0x4c,0xae,0x47,0xa7,0x4e,0xa3,0x47,0xa3,0x50,0xa3,0x45,0xa4,0x4f,0xa5,0x45, 0xaa,0x4b,0xad,0x48,0xb0,0x4b,0xb1,0x48,0xb1,0x55,0xb0,0x48,0xaf,0x4f,0xac,0x43, 0xa9,0x53,0xa5,0x48,0xa3,0x4b,0xa1,0x45,0x9b,0x54,0x9d,0x46,0xa8,0x4d,0xaa,0x45, 0xaa,0x50,0xae,0x45,0xb4,0x4d,0xb2,0x43,0xb0,0x4e,0xaf,0x44,0xaa,0x4b,0xa7,0x46, 0xa7,0x4d,0xa3,0x48,0x9a,0x4d,0x9d,0x43,0xab,0x52,0xa4,0x43,0xa2,0x52,0xb1,0x47, 0xb5,0x4f,0xae,0x48,0xb0,0x4d,0xae,0x43,0xaa,0x55,0xa6,0x42,0xa3,0x50,0xa4,0x48, 0xa4,0x4e,0xa6,0x48,0xa8,0x4b,0xab,0x46,0xae,0x52,0xb2,0x49,0xb4,0x4d,0xb1,0x46, 0xb1,0x4b,0xaf,0x49,0xaa,0x48,0xa5,0x45,0xa3,0x4d,0xa3,0x46,0xa1,0x50,0xa2,0x49, 0xa6,0x4b,0xa9,0x44,0xac,0x4b,0xaf,0x49,0xb1,0x50,0xb0,0x45,0xaf,0x4f,0xac,0x46, 0xaa,0x4f,0xa7,0x49,0xa2,0x4d,0xa0,0x46,0xa2,0x53,0xa3,0x46,0xa7,0x49,0xa9,0x42, 0xad,0x4d,0xb0,0x45,0xb0,0x51,0xaf,0x49,0xaf,0x53,0xad,0x3f,0xa8,0x45,0xa5,0x3f, 0xa3,0x4f,0x9f,0x43,0xa0,0x4e,0xa1,0x47,0xa3,0x50,0x9f,0x4b,0xb1,0x1e,0xb3,0x10, 0xb6,0x1a,0xb5,0x15,0xb4,0x28,0xaf,0x1a,0xad,0x1e,0xa7,0x12,0xa4,0x1d,0xa2,0x17, 0xa4,0x1e,0xa4,0x14,0xa5,0x1b,0xaa,0x15,0xb0,0x1c,0xaf,0x14,0xb1,0x1f,0xb3,0x17, 0xb2,0x1d,0xad,0x14,0xaa,0x1b,0xa6,0x12,0xa3,0x20,0xa0,0x12,0xa1,0x20,0xa3,0x17, 0xa8,0x17,0xab,0x12,0xaf,0x1d,0xb0,0x16,0xb3,0x21,0xb3,0x16,0xb2,0x18,0xaf,0x16, 0xab,0x1f,0xa5,0x11,0xa0,0x1a,0x9e,0x12,0x9f,0x1d,0xa0,0x17,0xa2,0x1a,0xa7,0x16, 0xad,0x19,0xaf,0x13,0xb0,0x1b,0xb0,0x16,0xb0,0x1e,0xad,0x13,0xa9,0x1b,0xa4,0x15, 0xa1,0x19,0x9f,0x13,0x9f,0x1b,0xa1,0x12,0xa4,0x1e,0xa4,0x13,0xaa,0x19,0xac,0x14, 0xad,0x1a,0xad,0x13,0xad,0x1e,0xa7,0x17,0xa5,0x1d,0xa1,0x1a,0x9c,0x1c,0x99,0x19, 0x97,0x1a,0x9a,0x11,0xa0,0x17,0x9f,0x10,0xa4,0x1e,0xa9,0x13,0xad,0x1a,0xae,0x17, 0xac,0x1b,0xab,0x16,0xa8,0x1f,0xa3,0x13,0xa1,0x1b,0x9d,0x18,0x9e,0x1d,0x9e,0x12, 0xa0,0x1d,0xa1,0x14,0xa9,0x1d,0xa9,0x12,0xab,0x20,0xad,0x12,0xae,0x1c,0xa8,0x13, 0xa8,0x1a,0xa5,0x13,0xa0,0x1d,0x9b,0x13,0x9d,0x1f,0x9b,0x16,0x9e,0x1d,0xa1,0x14, 0xa5,0x1c,0xa8,0x11,0xab,0x1c,0xac,0x15,0xab,0x20,0xa9,0x16,0xa7,0x19,0xa3,0x16, 0x9f,0x16,0x9b,0x12,0x99,0x19,0x9a,0x16,0x9d,0x1d,0x9e,0x12,0xa3,0x1b,0xa6,0x15, 0xaa,0x1d,0xab,0x14,0xab,0x1c,0xaa,0x12,0xa8,0x1b,0xa5,0x13,0xa2,0x1a,0x9e,0x11, 0x9b,0x1a,0x9b,0x14,0x9b,0x1b,0x9d,0x11,0xa3,0x1a,0xa7,0x18,0xa9,0x1d,0xaa,0x17, 0xac,0x1c,0xa9,0x11,0xa8,0x1e,0xa3,0x15,0x9f,0x21,0x9c,0x13,0x9a,0x21,0x99,0x13, 0x9d,0x1d,0x9d,0x16,0xa1,0x1f,0xa4,0x11,0xa9,0x1e,0xaa,0x15,0xab,0x1b,0xab,0x17, 0xa7,0x16,0xa6,0x14,0xa3,0x1e,0x9e,0x16,0x9c,0x1e,0x9b,0x13,0x9c,0x1a,0x9c,0x14, 0xa0,0x1f,0xa3,0x11,0xa6,0x1c,0xa5,0x10,0xa7,0x20,0xa9,0x18,0xa6,0x17,0xa4,0x15, 0xa2,0x1a,0x9f,0x19,0x9d,0x1d,0x9b,0x16,0x9d,0x1f,0x9b,0x14,0xa0,0x1b,0xa1,0x10, 0xa5,0x15,0xa4,0x18,0xaa,0x1e,0xa5,0x16,0xa6,0x1e,0xa4,0x0e,0xa2,0x1c,0x9c,0x11, 0x9a,0x20,0x9a,0x19,0x9a,0x1d,0x9d,0x13,0xa0,0x20,0xa3,0x13,0xa8,0x1c,0xa9,0x18, 0xab,0x1a,0xa8,0x12,0xa9,0x1a,0xa6,0x11,0xa2,0x20,0x9d,0x12,0x9a,0x1d,0x97,0x11, 0x9a,0x1e,0x9b,0x14,0x9e,0x1d,0xa1,0x15,0xa5,0x1d,0xa7,0x15,0xaa,0x1c,0xa9,0x14, 0xa8,0x19,0xa5,0x17,0xa2,0x1b,0x9e,0x14,0x9d,0x1d,0x9a,0x13,0x99,0x1d,0x9b,0x18, 0x9f,0x1e,0xa1,0x18,0xa5,0x1d,0xa7,0x14,0xaa,0x1f,0xa7,0x16,0xa9,0x1c,0xa5,0x13, 0xa2,0x1b,0x9f,0x13,0x9c,0x1b,0x9a,0x17,0x9a,0x1e,0x99,0x10,0x9d,0x1c,0x9d,0x13, 0xa2,0x1e,0xa4,0x12,0xa8,0x17,0xa6,0x13,0xa5,0x24,0xa6,0x13,0xa2,0x1e,0x9d,0x13, 0x9b,0x17,0x99,0x18,0x99,0x17,0x9b,0x18,0x9b,0x21,0x9f,0x14,0xa4,0x1e,0xa6,0x15, 0xa9,0x1c,0xa9,0x16,0xa8,0x1d,0xa5,0x11,0xa2,0x22,0xa0,0x16,0x9c,0x1e,0x99,0x14, 0x9b,0x1f,0x99,0x12,0x9a,0x1f,0x9f,0x1a,0xa1,0x1a,0xa2,0x12,0xa6,0x1c,0xa6,0x15, 0xa6,0x20,0xa3,0x14,0xa1,0x1d,0x9d,0x10,0x9a,0x22,0x97,0x15,0x96,0x1d,0x95,0x14, 0x99,0x1f,0x9c,0x15,0xa2,0x1e,0xa3,0x18,0xa5,0x20,0xa7,0x19,0xa6,0x1b,0xa3,0x15, 0xa4,0x1e,0x9e,0x16,0x9b,0x19,0x97,0x13,0x97,0x24,0x96,0x15,0x98,0x1e,0x9a,0x17, 0x9f,0x1b,0xa3,0x17,0xa5,0x1b,0xa4,0x14,0xa6,0x1d,0xa5,0x19,0xa2,0x18,0x9d,0x13, 0x9a,0x1f,0x97,0x16,0x96,0x1d,0x94,0x16,0x95,0x23,0x9a,0x14,0x9d,0x1b,0x9f,0x17, 0xa2,0x22,0xa4,0x17,0xa4,0x1f,0xa4,0x1b,0xa3,0x20,0x9e,0x13,0x99,0x20,0x98,0x16, 0x97,0x1f,0x95,0x15,0x94,0x20,0x98,0x18,0x9d,0x21,0xa0,0x15,0xa2,0x21,0xa5,0x1a, 0xa6,0x1e,0xa3,0x17,0xa1,0x1c,0x9e,0x16,0x9b,0x1c,0x98,0x18,0x96,0x1e,0x95,0x13, 0x96,0x1c,0x97,0x15,0x9c,0x1b,0x9e,0x16,0x9f,0x21,0xa0,0x17,0xa3,0x1d,0xa3,0x15, 0xa0,0x1e,0x9e,0x18,0x9c,0x1e,0x97,0x18,0x96,0x21,0x94,0x16,0x97,0x1e,0x9a,0x15, 0x9c,0x1b,0x9f,0x16,0xa1,0x1e,0xa2,0x14,0xa4,0x1f,0xa4,0x17,0xa2,0x1e,0xa0,0x17, 0x9c,0x20,0x99,0x19,0x96,0x1e,0x94,0x14,0x94,0x21,0x94,0x15,0x99,0x1f,0x9c,0x16, 0x9f,0x1e,0xa0,0x19,0xa2,0x1d,0xa2,0x15,0xa0,0x22,0x9e,0x15,0x9b,0x1c,0x96,0x16, 0x94,0x22,0x92,0x18,0x93,0x1c,0x94,0x12,0x97,0x20,0x9c,0x1a,0xa1,0x1e,0xa1,0x18, 0xa4,0x19,0xa3,0x1a,0xa2,0x20,0x9e,0x19,0x9b,0x25,0x97,0x14,0x96,0x1c,0x94,0x17, 0x95,0x1c,0x95,0x14,0x98,0x1f,0x9b,0x19,0x9f,0x1e,0xa0,0x16,0xa2,0x1d,0xa2,0x19, 0xa0,0x1d,0x9c,0x19,0x9a,0x20,0x96,0x19,0x93,0x20,0x91,0x12,0x93,0x1f,0x92,0x12, 0x95,0x20,0x99,0x1c,0x9c,0x1d,0x9f,0x14,0xa0,0x23,0xa1,0x17,0x9f,0x20,0x9d,0x1c, 0x9a,0x22,0x97,0x18,0x94,0x1c,0x92,0x16,0x91,0x23,0x93,0x15,0x97,0x1d,0x97,0x13, 0x9b,0x20,0x9f,0x14,0xa0,0x1d,0x9f,0x17,0x9f,0x21,0x9e,0x18,0x9b,0x1a,0x98,0x1a, 0x95,0x21,0x93,0x17,0x92,0x1c,0x92,0x18,0x93,0x23,0x96,0x1b,0x9a,0x1f,0x9a,0x16, 0x9e,0x23,0x9f,0x18,0x9d,0x1e,0x9b,0x18,0x9b,0x1f,0x97,0x17,0x94,0x1f,0x90,0x19, 0x91,0x1d,0x91,0x17,0x93,0x1b,0x96,0x17,0x9b,0x1f,0x9d,0x15,0x9f,0x1d,0xa0,0x17, 0x9f,0x21,0x9c,0x15,0x9d,0x1f,0x97,0x16,0x95,0x1f,0x93,0x16,0x92,0x1b,0x92,0x15, 0x94,0x1b,0x96,0x15,0x9a,0x1a,0x9d,0x12,0xa0,0x21,0x9f,0x12,0x9f,0x24,0x9e,0x19, 0x9b,0x24,0x97,0x17,0x95,0x15,0x93,0x0f,0x92,0x1e,0x91,0x16,0x93,0x1d,0x95,0x18, 0x99,0x20,0x96,0x1c,0xa2,0x60,0xa3,0x60,0xa4,0x6c,0xa1,0x6a,0x9e,0x77,0x9a,0x6e, 0x98,0x74,0x94,0x66,0x95,0x6a,0x95,0x62,0x98,0x6e,0x9c,0x5f,0x9f,0x6e,0xa0,0x61, 0xa3,0x6e,0xa3,0x62,0xa2,0x6b,0x9f,0x5c,0x9d,0x6e,0x9a,0x65,0x96,0x66,0x93,0x63, 0x96,0x6b,0x95,0x64,0x98,0x6a,0x9a,0x63,0x9f,0x6e,0xa1,0x60,0xa2,0x67,0xa3,0x61, 0xa5,0x68,0xa2,0x64,0x9e,0x6a,0x9b,0x62,0x97,0x6a,0x95,0x62,0x94,0x6c,0x93,0x60, 0x96,0x67,0x99,0x61,0x9c,0x68,0x9e,0x64,0xa4,0x6b,0xa4,0x61,0xa2,0x66,0xa2,0x64, 0xa0,0x69,0x9b,0x64,0x98,0x6c,0x95,0x68,0x95,0x71,0x94,0x65,0x96,0x6c,0x98,0x61, 0x9d,0x6c,0x9e,0x64,0xa1,0x66,0xa1,0x62,0xa2,0x6d,0xa1,0x61,0x9e,0x6c,0x9a,0x60, 0x97,0x6d,0x92,0x64,0x91,0x67,0x92,0x65,0x94,0x6d,0x96,0x61,0x9a,0x69,0x9d,0x62, 0xa2,0x68,0xa0,0x61,0xa0,0x6a,0x9f,0x63,0x9f,0x6f,0x9a,0x5d,0x98,0x66,0x94,0x60, 0x93,0x70,0x94,0x63,0x95,0x67,0x97,0x62,0x9c,0x6b,0x9f,0x5e,0xa0,0x6c,0xa1,0x63, 0xa1,0x71,0x9f,0x61,0x9d,0x6b,0x99,0x61,0x97,0x6c,0x95,0x63,0x94,0x6b,0x92,0x62, 0x96,0x6b,0x97,0x61,0x9b,0x6a,0x9d,0x5f,0xa1,0x6c,0xa0,0x63,0xa0,0x69,0x9f,0x5d, 0x9e,0x6d,0x9b,0x63,0x98,0x69,0x94,0x64,0x92,0x6a,0x91,0x5d,0x93,0x6d,0x93,0x61, 0x96,0x6a,0x9b,0x63,0x9b,0x65,0x93,0x62,0x97,0x6b,0x9c,0x62,0x91,0x67,0x8b,0x5e, 0x93,0x6d,0x92,0x63,0x8e,0x6d,0x91,0x64,0x94,0x6f,0x94,0x63,0x97,0x68,0x9a,0x60, 0x9e,0x69,0x9f,0x63,0x9f,0x68,0x9e,0x62,0x9e,0x6e,0x99,0x61,0x96,0x67,0x93,0x5f, 0x90,0x66,0x8f,0x5e,0x90,0x6c,0x90,0x61,0x95,0x6c,0x97,0x64,0x9a,0x6a,0x9b,0x66, 0x9d,0x6a,0x9c,0x62,0x9b,0x6c,0x98,0x62,0x96,0x6d,0x91,0x64,0x8e,0x69,0x8b,0x62, 0x8e,0x6a,0x8f,0x62,0x91,0x65,0x95,0x62,0x9a,0x70,0x9b,0x61,0x9d,0x6a,0x9c,0x64, 0x9c,0x69,0x98,0x62,0x96,0x6b,0x93,0x66,0x8f,0x6a,0x8d,0x64,0x8e,0x6a,0x8f,0x63, 0x93,0x6b,0x96,0x62,0x99,0x6c,0x9b,0x65,0x9e,0x6e,0x9b,0x62,0x9c,0x6a,0x99,0x62, 0x97,0x68,0x93,0x65,0x91,0x6a,0x8f,0x61,0x8f,0x6f,0x8f,0x61,0x93,0x6f,0x95,0x63, 0x99,0x70,0x9b,0x60,0x9d,0x68,0x9d,0x60,0x9e,0x6c,0x99,0x61,0x97,0x6c,0x94,0x62, 0x91,0x6c,0x8e,0x68,0x8e,0x67,0x8f,0x61,0x93,0x6e,0x95,0x63,0x98,0x6b,0x99,0x65, 0x9e,0x6a,0x9c,0x62,0x9c,0x6b,0x9b,0x66,0x98,0x73,0x95,0x5f,0x92,0x6e,0x8e,0x62, 0x8f,0x6b,0x90,0x63,0x91,0x6c,0x94,0x68,0x97,0x6a,0x9a,0x68,0x9d,0x6b,0x9b,0x61, 0x9b,0x6e,0x98,0x62,0x96,0x65,0x91,0x66,0x91,0x6e,0x8e,0x63,0x8f,0x6b,0x8e,0x5f, 0x91,0x6d,0x92,0x60,0x96,0x6c,0x99,0x60,0x9b,0x6d,0x9c,0x62,0x9c,0x69,0x99,0x63, 0x99,0x6c,0x94,0x61,0x92,0x67,0x8f,0x63,0x8b,0x68,0x85,0x61,0x8b,0x67,0x94,0x66, 0x8f,0x6f,0x92,0x68,0x9b,0x68,0x9c,0x61,0x9c,0x6e,0x9a,0x67,0x98,0x6b,0x94,0x65, 0x90,0x68,0x8e,0x65,0x8d,0x68,0x8c,0x62,0x8f,0x6d,0x91,0x60,0x94,0x67,0x97,0x67, 0x9b,0x6d,0x9a,0x66,0x9a,0x68,0x99,0x62,0x96,0x70,0x94,0x68,0x91,0x6c,0x8d,0x62, 0x8c,0x6b,0x8b,0x65,0x8d,0x6a,0x8d,0x62,0x92,0x70,0x95,0x66,0x96,0x68,0x98,0x5e, 0x99,0x6e,0x97,0x66,0x96,0x6c,0x92,0x64,0x8f,0x6d,0x8a,0x64,0x89,0x6a,0x89,0x62, 0x8c,0x6a,0x8c,0x66,0x90,0x69,0x95,0x66,0x96,0x68,0x98,0x63,0x98,0x6d,0x97,0x63, 0x95,0x70,0x92,0x64,0x90,0x6c,0x8e,0x66,0x8d,0x6f,0x8b,0x64,0x8f,0x6c,0x8e,0x62, 0x93,0x69,0x96,0x61,0x9a,0x6f,0x9a,0x66,0x9b,0x70,0x9a,0x65,0x99,0x68,0x95,0x63, 0x94,0x68,0x8f,0x63,0x8d,0x6c,0x8d,0x63,0x8f,0x70,0x90,0x68,0x92,0x68,0x97,0x64, 0x98,0x70,0x9a,0x66,0x9c,0x6b,0x9a,0x63,0x9a,0x71,0x97,0x5f,0x93,0x71,0x8f,0x63, 0x8e,0x6b,0x8d,0x63,0x8c,0x6d,0x8f,0x68,0x90,0x70,0x95,0x64,0x98,0x70,0x9b,0x5f, 0x9b,0x6c,0x9b,0x65,0x99,0x6a,0x96,0x63,0x94,0x6f,0x90,0x64,0x8d,0x6b,0x8c,0x63, 0x8d,0x6c,0x8d,0x62,0x90,0x66,0x93,0x66,0x98,0x70,0x9a,0x64,0x9b,0x6c,0x9a,0x65, 0x9a,0x6c,0x97,0x65,0x94,0x6b,0x91,0x66,0x90,0x6f,0x8d,0x60,0x8d,0x6d,0x8e,0x67, 0x93,0x6e,0x94,0x66,0x97,0x72,0x99,0x63,0x9c,0x71,0x9b,0x66,0x99,0x6c,0x97,0x61, 0x97,0x6d,0x91,0x63,0x8e,0x6c,0x8c,0x66,0x8c,0x75,0x8e,0x63,0x91,0x6d,0x92,0x63, 0x97,0x6f,0x9a,0x63,0x9b,0x6b,0x9a,0x62,0x9a,0x70,0x99,0x65,0x96,0x6a,0x91,0x63, 0x8f,0x6e,0x8c,0x63,0x8c,0x6b,0x8d,0x60,0x8f,0x70,0x92,0x66,0x96,0x6e,0x99,0x66, 0x9a,0x70,0x9b,0x62,0x99,0x72,0x99,0x68,0x97,0x6e,0x91,0x60,0x8e,0x6c,0x8e,0x67, 0x8c,0x6c,0x8b,0x65,0x8e,0x6c,0x90,0x67,0x95,0x6f,0x97,0x69,0x99,0x6d,0x9a,0x68, 0x9a,0x6f,0x98,0x64,0x96,0x6c,0x92,0x63,0x90,0x71,0x8d,0x64,0x8b,0x71,0x8c,0x65, 0x8e,0x6f,0x92,0x69,0x94,0x6a,0x97,0x64,0x9a,0x71,0x9a,0x67,0x9a,0x6c,0x98,0x67, 0x96,0x6d,0x92,0x65,0x8f,0x6c,0x8d,0x64,0x8b,0x72,0x8c,0x61,0x8e,0x6f,0x90,0x66, 0x94,0x6f,0x96,0x69,0x98,0x6d,0x99,0x68,0x99,0x73,0x98,0x69,0x97,0x6f,0x93,0x64, 0x8f,0x70,0x8d,0x66,0x8d,0x6b,0x8a,0x65,0x8c,0x6d,0x8f,0x66,0x92,0x70,0x95,0x69, 0x99,0x6f,0x9a,0x67,0x9a,0x6d,0x97,0x63,0x95,0x70,0x93,0x63,0x8f,0x6b,0x8c,0x66, 0x8b,0x6a,0x8a,0x61,0x8c,0x6c,0x8d,0x65,0x93,0x6f,0x96,0x63,0x99,0x6b,0x99,0x64, 0x9b,0x6d,0x99,0x64,0x96,0x69,0x93,0x64,0x90,0x72,0x8c,0x61,0x8b,0x63,0x8b,0x60, 0x8d,0x69,0x8e,0x65,0x93,0x6c,0x96,0x61,0x98,0x70,0x93,0x6b,0x9b,0x5b,0x9a,0x50, 0x99,0x55,0x95,0x5b,0x92,0x66,0x8f,0x5e,0x8e,0x60,0x8f,0x56,0x91,0x5e,0x92,0x55, 0x99,0x5d,0x9b,0x54,0x9d,0x5e,0x9d,0x54,0x9e,0x65,0x9c,0x55,0x9a,0x62,0x97,0x58, 0x94,0x5a,0x90,0x53,0x90,0x59,0x8e,0x53,0x91,0x60,0x92,0x53,0x95,0x5c,0x98,0x57, 0x9d,0x5c,0x9c,0x57,0x9d,0x5a,0x9c,0x54,0x9c,0x5e,0x97,0x54,0x95,0x5c,0x91,0x53, 0x8f,0x60,0x8e,0x53,0x90,0x59,0x91,0x58,0x94,0x60,0x98,0x52,0x9b,0x5d,0x9d,0x54, 0x9f,0x5c,0x9b,0x52,0x9b,0x5f,0x96,0x57,0x93,0x5b,0x90,0x57,0x8e,0x5d,0x8d,0x59, 0x8f,0x60,0x91,0x52,0x95,0x5c,0x97,0x52,0x9b,0x5e,0x9c,0x53,0x9d,0x5e,0x9b,0x57, 0x99,0x5b,0x96,0x53,0x93,0x5e,0x90,0x55,0x8d,0x5e,0x8d,0x58,0x8d,0x5d,0x8e,0x54, 0x93,0x5d,0x97,0x55,0x99,0x5b,0x9a,0x51,0x9b,0x62,0x9b,0x52,0x9a,0x5f,0x96,0x50, 0x94,0x5c,0x90,0x54,0x8e,0x5a,0x8c,0x51,0x8e,0x5d,0x8f,0x58,0x92,0x5d,0x94,0x51, 0x99,0x5f,0x9b,0x53,0x9a,0x5d,0x99,0x53,0x97,0x60,0x95,0x56,0x92,0x5e,0x8f,0x5b, 0x8e,0x5d,0x8a,0x50,0x8b,0x5b,0x8d,0x54,0x90,0x5f,0x93,0x54,0x98,0x5f,0x98,0x54, 0x99,0x5b,0x99,0x54,0x99,0x5d,0x95,0x53,0x93,0x5d,0x8f,0x52,0x8d,0x5f,0x8a,0x57, 0x8c,0x5d,0x8c,0x53,0x8f,0x5c,0x92,0x57,0x96,0x5e,0x98,0x55,0x99,0x5e,0x99,0x55, 0x98,0x5b,0x97,0x53,0x93,0x5b,0x8e,0x54,0x8b,0x5c,0x89,0x52,0x8a,0x5b,0x8a,0x55, 0x8e,0x5b,0x91,0x55,0x94,0x5b,0x96,0x50,0x99,0x5e,0x97,0x51,0x97,0x5b,0x96,0x58, 0x93,0x5d,0x8e,0x55,0x8a,0x59,0x88,0x53,0x89,0x62,0x89,0x55,0x8b,0x5c,0x8f,0x57, 0x94,0x5d,0x96,0x55,0x97,0x5f,0x96,0x54,0x97,0x5f,0x95,0x59,0x93,0x5b,0x8f,0x53, 0x8d,0x5b,0x8a,0x54,0x8a,0x5d,0x8a,0x55,0x8d,0x5e,0x8f,0x55,0x93,0x5c,0x96,0x58, 0x98,0x5e,0x96,0x54,0x98,0x5f,0x95,0x53,0x93,0x62,0x8f,0x53,0x8e,0x5e,0x8a,0x53, 0x8a,0x5c,0x8b,0x5b,0x8c,0x5f,0x8e,0x54,0x92,0x5f,0x94,0x58,0x97,0x5b,0x97,0x55, 0x97,0x5f,0x96,0x57,0x93,0x5c,0x8f,0x58,0x8b,0x61,0x8a,0x55,0x88,0x60,0x89,0x56, 0x8b,0x5e,0x8e,0x57,0x91,0x59,0x94,0x54,0x96,0x5c,0x96,0x56,0x97,0x60,0x94,0x54, 0x93,0x60,0x90,0x58,0x8e,0x5f,0x89,0x57,0x88,0x60,0x87,0x54,0x89,0x60,0x8c,0x55, 0x90,0x62,0x93,0x5b,0x95,0x5c,0x96,0x55,0x96,0x5f,0x94,0x5a,0x94,0x62,0x90,0x5a, 0x8d,0x5d,0x8a,0x59,0x88,0x5d,0x86,0x53,0x87,0x62,0x8a,0x5c,0x8d,0x5f,0x91,0x5a, 0x93,0x63,0x94,0x57,0x96,0x5f,0x95,0x58,0x93,0x5f,0x90,0x59,0x8d,0x62,0x89,0x53, 0x89,0x5e,0x88,0x5b,0x89,0x59,0x8a,0x57,0x8d,0x60,0x90,0x5c,0x93,0x5f,0x95,0x59, 0x95,0x66,0x95,0x5a,0x93,0x5f,0x91,0x59,0x8c,0x62,0x8b,0x57,0x88,0x61,0x87,0x57, 0x88,0x5e,0x8a,0x5b,0x8e,0x5f,0x91,0x5b,0x93,0x64,0x95,0x58,0x95,0x64,0x94,0x59, 0x94,0x66,0x92,0x58,0x8d,0x65,0x8b,0x59,0x88,0x63,0x87,0x5d,0x87,0x62,0x8a,0x5e, 0x8c,0x66,0x91,0x5a,0x91,0x61,0x94,0x5d,0x94,0x65,0x94,0x59,0x92,0x61,0x92,0x5f, 0x8e,0x65,0x8a,0x5d,0x88,0x61,0x88,0x5b,0x87,0x67,0x89,0x59,0x8b,0x63,0x8f,0x5f, 0x93,0x65,0x94,0x5d,0x95,0x62,0x94,0x5b,0x94,0x68,0x91,0x5c,0x8e,0x67,0x8b,0x63, 0x88,0x6c,0x87,0x5d,0x86,0x5e,0x87,0x60,0x8a,0x68,0x8b,0x62,0x90,0x64,0x91,0x64, 0x93,0x68,0x92,0x63,0x92,0x67,0x8f,0x62,0x8e,0x6a,0x8a,0x63,0x87,0x67,0x85,0x64, 0x86,0x6e,0x86,0x63,0x89,0x6a,0x8b,0x5f,0x8f,0x6d,0x90,0x64,0x92,0x6a,0x91,0x6b, 0x91,0x71,0x8f,0x67,0x8c,0x68,0x88,0x60,0x86,0x6a,0x85,0x67,0x84,0x6e,0x85,0x66, 0x87,0x75,0x88,0x68,0x8d,0x6c,0x8e,0x64,0x8f,0x72,0x90,0x67,0x91,0x6f,0x8d,0x65, 0x8c,0x73,0x89,0x63,0x86,0x6c,0x83,0x67,0x82,0x73,0x82,0x67,0x84,0x70,0x88,0x66, 0x8b,0x70,0x8d,0x69,0x8e,0x70,0x8f,0x65,0x8e,0x71,0x8d,0x66,0x8a,0x70,0x89,0x66, 0x82,0x71,0x82,0x66,0x82,0x6a,0x81,0x66,0x84,0x6e,0x86,0x63,0x8b,0x6d,0x8c,0x63, 0x8f,0x6f,0x8f,0x64,0x8f,0x6c,0x8e,0x69,0x8c,0x70,0x87,0x67,0x85,0x6c,0x82,0x64, 0x80,0x70,0x82,0x68,0x83,0x68,0x84,0x66,0x89,0x6c,0x8b,0x62,0x8f,0x6b,0x8f,0x6a, 0x90,0x6b,0x8e,0x66,0x8c,0x69,0x88,0x65,0x86,0x6e,0x82,0x63,0x80,0x68,0x80,0x63, 0x84,0x6f,0x84,0x63,0x87,0x6a,0x8a,0x67,0x8c,0x70,0x8d,0x62,0x8d,0x6f,0x8c,0x62, 0x89,0x70,0x88,0x63,0x86,0x6a,0x82,0x5f,0x81,0x6d,0x80,0x64,0x82,0x6d,0x82,0x63, 0x85,0x6f,0x88,0x65,0x8b,0x69,0x8a,0x66,0x8b,0x70,0x8c,0x63,0x8c,0x6c,0x87,0x66, 0x85,0x72,0x82,0x66,0x80,0x69,0x7f,0x66,0x7f,0x75,0x80,0x67,0x85,0x6f,0x86,0x66, 0x88,0x70,0x8a,0x67,0x8b,0x70,0x8a,0x68,0x88,0x76,0x87,0x6f,0x84,0x75,0x81,0x6c, 0x7e,0x74,0x7e,0x6b,0x7d,0x74,0x7e,0x6b,0x80,0x74,0x83,0x68,0x86,0x77,0x88,0x6f, 0x88,0x7a,0x89,0x6e,0x87,0x71,0x85,0x6d,0x82,0x79,0x80,0x6e,0x7d,0x7b,0x7a,0x72, 0x7a,0x78,0x7c,0x70,0x7d,0x73,0x82,0x6f,0x84,0x77,0x86,0x6e,0x87,0x78,0x87,0x70, 0x87,0x76,0x85,0x71,0x83,0x77,0x7f,0x70,0x7f,0x76,0x7a,0x72,0x7a,0x78,0x7b,0x6f, 0x7e,0x79,0x81,0x6e,0x83,0x78,0x86,0x6f,0x88,0x76,0x88,0x6f,0x88,0x76,0x86,0x72, 0x84,0x7c,0x81,0x74,0x7e,0x76,0x7c,0x72,0x7c,0x7b,0x7c,0x72,0x7e,0x76,0x81,0x6c, 0x84,0x79,0x86,0x71,0x89,0x7c,0x88,0x71,0x89,0x7d,0x88,0x71,0x85,0x7b,0x82,0x72, 0x81,0x7a,0x7e,0x73,0x7d,0x7b,0x7c,0x75,0x80,0x7e,0x83,0x7a,0x86,0x7f,0x88,0x7b, 0x89,0x80,0x83,0x80,0x69,0x59,0x9c,0x9a,0x9a,0x9b,0x9d,0x9e,0xa0,0xa1,0xa0,0xa2, 0xa4,0xa4,0xa7,0xa7,0xa7,0xa8,0xa9,0xa9,0xa8,0xa7,0xa6,0xa4,0xa3,0xa2,0xa1,0x9f, 0x9f,0x9c,0x9b,0x9a,0x9a,0x9a,0x9b,0x9b,0x9c,0x9e,0xa0,0xa2,0xa3,0xa3,0xa4,0xa4, 0xa7,0xa6,0xa7,0xa7,0xa7,0xa6,0xa4,0xa3,0xa2,0xa0,0xa0,0x9d,0x9c,0x9a,0x9a,0x99, 0x97,0x99,0x9a,0x9a,0x9b,0x9c,0x9d,0x9f,0xa3,0xa3,0xa5,0xa6,0xa6,0xa6,0xa6,0xa6, 0xa5,0xa6,0xa5,0xa4,0xa2,0xa2,0xa0,0x9e,0x9c,0x9c,0x9b,0x9a,0x9a,0x9b,0x9a,0x9c, 0x9d,0x9e,0x9e,0xa0,0xa2,0xa2,0xa1,0xa4,0xa4,0xa4,0xa5,0xa6,0xa5,0xa6,0xa4,0xa4, 0xa3,0xa1,0xa1,0x9f,0x9d,0x9b,0x99,0x9a,0x99,0x99,0x99,0x98,0x9a,0x9b,0x9e,0x9d, 0x9f,0x9f,0xa3,0xa4,0xa5,0xa6,0xa4,0xa3,0xa2,0xa5,0xa6,0xa6,0xa5,0xa3,0xa1,0x9f, 0x9d,0x9c,0x9b,0x9b,0x99,0x98,0x97,0x97,0x9a,0x9b,0x9e,0x9e,0x9f,0x9f,0xa1,0xa2, 0xa5,0xa4,0xa5,0xa6,0xa6,0xa7,0xa5,0xa4,0xa3,0xa3,0xa2,0xa1,0x9e,0x9d,0x9d,0x99, 0x9a,0x99,0x99,0x98,0x9a,0x9c,0x9c,0x9f,0x9f,0xa1,0xa3,0xa2,0xa5,0xa7,0xa8,0xa8, 0xa7,0xa6,0xa4,0xa4,0xa4,0xa4,0xa4,0xa2,0x9e,0x9c,0x9b,0x9a,0x99,0x9b,0x99,0x9a, 0x9b,0x9b,0x9e,0xa0,0xa0,0xa1,0xa2,0xa3,0xa4,0xa6,0xa6,0xa7,0xa7,0xa8,0xa8,0xa7, 0xa4,0xa5,0xa3,0xa1,0xa0,0x9e,0x9e,0x9c,0x9d,0x9b,0x9a,0x9a,0x9b,0x9b,0x9f,0xa0, 0xa0,0xa1,0xa2,0xa3,0xa5,0xa6,0xa8,0xa8,0xa8,0xa7,0xa8,0xa6,0xa6,0xa5,0xa4,0xa3, 0xa1,0x9f,0x9b,0x9b,0x99,0x98,0x99,0x9b,0x9c,0x9b,0x9d,0x9d,0x9f,0xa1,0xa3,0xa5, 0xa6,0xaa,0xaa,0xa9,0xa9,0xa7,0xa7,0xa7,0xa6,0xa7,0xa6,0xa6,0xa4,0xa2,0xa0,0x9f, 0x9f,0x9c,0x9c,0x9b,0x9c,0x9d,0x9f,0x9f,0x9f,0xa3,0xa4,0xa6,0xa7,0xa8,0xa9,0xa9, 0xaa,0xa9,0xa9,0xaa,0xa9,0xa7,0xa8,0xa8,0xa5,0xa4,0xa3,0xa1,0xa0,0x9f,0x9e,0x9d, 0x9f,0x9f,0xa0,0xa0,0xa3,0xa3,0xa5,0xa7,0xa9,0xa9,0xab,0xab,0xac,0xad,0xad,0xab, 0xaa,0xab,0xaa,0xa7,0xa7,0xa4,0xa3,0xa3,0xa1,0x9f,0x9e,0x9e,0x9e,0x9e,0x9f,0x9f, 0xa2,0xa3,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xab,0xab,0xaa,0xaa,0xab,0xa9,0xa7, 0xa5,0xa4,0xa3,0xa1,0xa2,0xa1,0x9f,0x9d,0x9c,0x9f,0x9f,0xa0,0xa2,0xa4,0xa6,0xa6, 0xa8,0xaa,0xac,0xac,0xac,0xac,0xad,0xad,0xab,0xab,0xab,0xa8,0xa9,0xa6,0xa5,0xa3, 0xa3,0xa1,0x9f,0x9f,0x9f,0x9e,0x9f,0xa1,0xa1,0xa3,0xa5,0xa6,0xa9,0xa9,0xaa,0xab, 0xaa,0xaa,0xac,0xad,0xac,0xa9,0xaa,0xa9,0xa8,0xa8,0xa4,0xa4,0xa2,0x9f,0x9f,0xa0, 0x9f,0xa0,0xa2,0xa1,0xa2,0xa3,0xa4,0xa5,0xa4,0xa5,0xa8,0xaa,0xae,0xaa,0xaa,0xa8, 0xa8,0xa8,0xa9,0xaa,0xa9,0xa5,0xa2,0xa2,0xa2,0xa1,0xa0,0xa0,0xa0,0xa1,0xa1,0xa1, 0xa1,0xa2,0xa3,0xa5,0xa7,0xa9,0xaa,0xac,0xac,0xad,0xad,0xac,0xac,0xab,0xac,0xab, 0xa9,0xa8,0xa8,0xa5,0xa3,0xa2,0xa0,0xa1,0xa0,0xa0,0x9f,0xa0,0xa2,0xa4,0xa4,0xa5, 0xa4,0xa6,0xa9,0xab,0xae,0xae,0xad,0xab,0xad,0xac,0xad,0xab,0xab,0xa9,0xa7,0xa7, 0xa5,0xa1,0xa0,0x9e,0x9e,0x9d,0x98,0xa6,0xa9,0xab,0xac,0xae,0xaf,0xb1,0xb2,0xb3, 0xb2,0xb4,0xb3,0xb4,0xb4,0xb5,0xb2,0xaf,0xae,0xad,0xab,0xab,0xa9,0xa9,0xa6,0xa3, 0xa5,0xa5,0xa6,0xa8,0xa8,0xab,0xab,0xae,0xaf,0xb0,0xb2,0xb3,0xb5,0xb4,0xb4,0xb4, 0xb3,0xb2,0xb2,0xb1,0xb0,0xaf,0xae,0xab,0xaa,0xa8,0xa8,0xa6,0xa6,0xa5,0xa8,0xaa, 0xaa,0xaa,0xad,0xae,0xb0,0xb4,0xb5,0xb4,0xb6,0xb7,0xb6,0xb8,0xb7,0xb7,0xb7,0xb5, 0xb3,0xb0,0xb1,0xaf,0xad,0xab,0xac,0xaa,0xaa,0xab,0xac,0xab,0xac,0xab,0xad,0xaf, 0xb1,0xb4,0xb4,0xb6,0xb5,0xb6,0xb6,0xb6,0xb6,0xb7,0xb5,0xb6,0xb5,0xb3,0xb1,0xaf, 0xab,0xab,0xaa,0xaa,0xaa,0xab,0xaa,0xaa,0xab,0xac,0xac,0xaf,0xb0,0xb1,0xb2,0xb4, 0xb7,0xb7,0xb5,0xb5,0xb7,0xb9,0xb5,0xb4,0xb2,0xb1,0xaf,0xaf,0xad,0xad,0xab,0xa9, 0xa8,0xa9,0xaa,0xac,0xac,0xad,0xae,0xaf,0xb0,0xb4,0xb6,0xb7,0xb5,0xb5,0xb7,0xb7, 0xb9,0xb9,0xb7,0xb9,0xb6,0xb5,0xb2,0xb1,0xae,0xae,0xae,0xac,0xac,0xaa,0xa8,0xa9, 0xab,0xad,0xae,0xae,0xb0,0xb2,0xb4,0xb6,0xb5,0xb6,0xb7,0xb9,0xb8,0xb7,0xb5,0xb4, 0xb5,0xb3,0xb4,0xb2,0xad,0xac,0xaa,0xa9,0xa9,0xa8,0xa8,0xa8,0xa8,0xa9,0xaa,0xab, 0xae,0xaf,0xb2,0xb3,0xb3,0xb2,0xb7,0xb8,0xb5,0xb5,0xb6,0xb3,0xb2,0xb3,0xb2,0xaf, 0xae,0xab,0xa9,0xaa,0xa7,0xa5,0xa7,0xa7,0xa9,0xa9,0xa9,0xaa,0xab,0xae,0xb1,0xb1, 0xb2,0xb4,0xb5,0xb6,0xb3,0xb5,0xb5,0xb4,0xb4,0xb5,0xb1,0xaf,0xac,0xab,0xab,0xaa, 0xaa,0xa9,0xa7,0xa8,0xa6,0xa6,0xa6,0xa8,0xaa,0xaf,0xb1,0xb1,0xaf,0xb0,0xb3,0xb3, 0xb4,0xb5,0xb5,0xb3,0xb1,0xb0,0xb2,0xaf,0xaf,0xae,0xab,0xaa,0xa8,0xa8,0xa8,0xa7, 0xa7,0xa7,0xa9,0xac,0xad,0xad,0xae,0xaf,0xb3,0xb3,0xb5,0xb5,0xb6,0xb5,0xb6,0xb6, 0xb4,0xb3,0xb2,0xb1,0xb0,0xae,0xae,0xac,0xaa,0xaa,0xa8,0xa9,0xa7,0xa8,0xaa,0xab, 0xae,0xb0,0xb0,0xb1,0xb2,0xb2,0xb4,0xb5,0xb6,0xb9,0xb6,0xb5,0xb5,0xb4,0xb4,0xb1, 0xb1,0xb0,0xad,0xac,0xab,0xab,0xaa,0xa8,0xa9,0xa9,0xaa,0xab,0xac,0xac,0xac,0xb0, 0xb2,0xb3,0xb5,0xb6,0xb6,0xb6,0xb5,0xb7,0xb5,0xb6,0xb4,0xb1,0xb0,0xae,0xac,0xac, 0xac,0xab,0xa8,0xa8,0xa7,0xa8,0xa7,0xaa,0xac,0xad,0xaf,0xb1,0xb1,0xb2,0xb5,0xb6, 0xb7,0xb6,0xb5,0xb6,0xb5,0xb6,0xb7,0xb5,0xb4,0xb2,0xae,0xaf,0xac,0xaa,0xa8,0xa8, 0xa7,0xa8,0xab,0xab,0xac,0xad,0xad,0xb1,0xb3,0xb3,0xb6,0xb6,0xb6,0xb5,0xb8,0xb6, 0xb7,0xb5,0xb4,0xb2,0xb1,0xb0,0xad,0xab,0xaa,0xa9,0xa7,0xa7,0xa5,0xa7,0xa8,0xa8, 0xa9,0xac,0xad,0xaf,0xb1,0xb3,0xb3,0xb3,0xb3,0xb5,0xb7,0xb7,0xb7,0xb5,0xb5,0xb1, 0xb3,0xb0,0xb0,0xad,0xac,0xaa,0xa8,0xa9,0xa7,0xa8,0xa8,0xa9,0xa9,0xab,0xae,0xae, 0xb0,0xb2,0xb4,0xb4,0xb6,0xb6,0xb5,0xb6,0xb6,0xb7,0xb4,0xb5,0xb4,0xb2,0xb0,0xaf, 0xae,0xac,0xab,0xab,0xa8,0xa9,0xa8,0xa9,0xab,0xac,0xae,0xaf,0xad,0xb1,0xb3,0xb5, 0xb5,0xb5,0xb6,0xb7,0xb7,0xb7,0xb4,0xb5,0xb3,0xb2,0xb0,0xb0,0xae,0xaa,0xa8,0xa8, 0xa9,0xa8,0xa7,0xa9,0xaa,0xaa,0xac,0xac,0xaf,0xb0,0xb3,0xb5,0xb5,0xb5,0xb6,0xb6, 0xb7,0xb7,0xb7,0xb6,0xb5,0xb2,0xb0,0xad,0xad,0xac,0xaa,0xa9,0xa9,0xa9,0xa8,0xa9, 0xa9,0xaa,0xaa,0xac,0xad,0xaf,0xb1,0xb1,0xb3,0xb3,0xb5,0xb5,0xb5,0xb5,0xb6,0xb3, 0xb3,0xb1,0xb0,0xac,0xad,0xab,0xab,0xa9,0xa8,0xa9,0xa8,0xa8,0xa8,0xa9,0xaa,0xab, 0xaf,0xb0,0xb1,0xb3,0xb4,0xb2,0xb3,0xb2,0xb4,0xb5,0xb3,0xb3,0xb3,0xb0,0xad,0xaa, 0xaa,0xaa,0xab,0xa8,0xa4,0xa4,0xa4,0xa4,0xa7,0xab,0xaa,0xaa,0xac,0xac,0xad,0xb0, 0xb0,0xb2,0xb3,0xb4,0xb5,0xb4,0xb3,0xb1,0xb1,0xb0,0xaf,0xae,0xad,0xa9,0xa7,0xa9, 0xa8,0xa6,0xa6,0xa5,0xa5,0xa5,0xa8,0xa8,0xab,0xac,0xae,0xaf,0xb2,0xb1,0xb3,0xb2, 0xb3,0xb4,0xb4,0xb3,0xb4,0xb1,0xaf,0xae,0xad,0xac,0xad,0xab,0xa9,0xa7,0xa7,0xa5, 0xa7,0xa7,0xa9,0xa8,0xa9,0xaa,0xac,0xae,0xaf,0xb0,0xb1,0xb0,0xb4,0xb3,0xb3,0xb3, 0xb0,0xaf,0xb0,0xaf,0xae,0xad,0xa9,0xa8,0xa6,0xa6,0xa7,0xa7,0xa8,0xa7,0xa9,0xaa, 0xab,0xac,0xad,0xaf,0xb1,0xb2,0xb4,0xb4,0xb4,0xb4,0xb5,0xb5,0xb5,0xb3,0xb0,0xb0, 0xb1,0xaf,0xac,0xaa,0xaa,0xa9,0xa8,0xa6,0xa6,0xa9,0xa8,0xa9,0xab,0xac,0xad,0xae, 0xae,0xaf,0xb1,0xb3,0xb2,0xb4,0xb4,0xb1,0xb1,0xb0,0xb2,0xb1,0xb0,0xac,0xac,0xaa, 0xab,0xaa,0xa8,0xa8,0xa7,0xa8,0xa8,0xa8,0xaa,0xac,0xad,0xae,0xae,0xb2,0xb3,0xb5, 0xb5,0xb7,0xb5,0xb6,0xb6,0xb4,0xb3,0xb3,0xb1,0xae,0xaf,0xad,0xae,0xaa,0xaa,0xa8, 0xa6,0xa8,0xa8,0xa8,0xaa,0xaa,0xac,0xae,0xb0,0xb0,0xb2,0xb2,0xb4,0xb5,0xb4,0xb3, 0xb5,0xb2,0xb2,0xb1,0xb1,0xae,0xad,0xab,0xaa,0xaa,0xa9,0xa7,0xa8,0xa7,0xa9,0xa8, 0xa9,0xac,0xab,0xad,0xb1,0xb0,0xb2,0xb4,0xb5,0xb6,0xb5,0xb5,0xb5,0xb4,0xb3,0xb2, 0xb2,0xb0,0xaf,0xad,0xab,0xab,0xa8,0xa8,0xa8,0xa7,0xa9,0xa8,0xaa,0xab,0xad,0xac, 0xb0,0xb2,0xb3,0xb4,0xb4,0xb5,0xb4,0xb5,0xb6,0xb5,0xb6,0xb4,0xb2,0xaf,0xae,0xad, 0xac,0xaa,0xa9,0xa6,0xa6,0xa7,0xa6,0xa6,0xa6,0xa7,0xa9,0xaa,0xae,0xaf,0xb1,0xb1, 0xb1,0xb3,0xb3,0xb3,0xb4,0xb4,0xb2,0xb1,0xb1,0xb1,0xaf,0xae,0xae,0xaa,0xaa,0xa9, 0xa9,0xaa,0xa8,0xa6,0xa5,0xa7,0xa9,0xad,0xb0,0xb1,0xaf,0xae,0xb0,0xb3,0xb4,0xb7, 0xb6,0xb5,0xb4,0xb4,0xb3,0xb2,0xb1,0xae,0xae,0xad,0xad,0xaa,0xa8,0xa9,0xa9,0xa9, 0xac,0xab,0xad,0xae,0xb0,0xb1,0xb1,0xb2,0xb5,0xb3,0xb5,0xb5,0xb6,0xb5,0xb6,0xb4, 0xb3,0xb2,0xb1,0xb0,0xae,0xae,0xad,0xab,0xa9,0xa9,0xa6,0xa5,0xa7,0xa4,0xa1,0xb0, 0xb4,0xb4,0xb7,0xba,0xb9,0xba,0xb8,0xba,0xba,0xba,0xb9,0xb8,0xb8,0xb6,0xb3,0xb2, 0xb1,0xb2,0xb0,0xad,0xac,0xac,0xad,0xae,0xb0,0xb0,0xb3,0xb2,0xb6,0xb7,0xb8,0xb8, 0xbb,0xbb,0xbb,0xbb,0xba,0xbe,0xb9,0xb9,0xba,0xb7,0xb6,0xb5,0xb3,0xb2,0xb0,0xaf, 0xaf,0xae,0xaf,0xaf,0xaf,0xb0,0xb3,0xb2,0xb8,0xb8,0xb9,0xba,0xbb,0xbb,0xbd,0xbd, 0xbd,0xbb,0xbb,0xba,0xba,0xb9,0xb7,0xb5,0xb5,0xb3,0xb2,0xb2,0xb1,0xaf,0xb0,0xb0, 0xb2,0xb2,0xb1,0xb2,0xb4,0xb7,0xb8,0xb7,0xb8,0xbb,0xba,0xb8,0xb9,0xbb,0xba,0xb8, 0xb8,0xb8,0xb7,0xb7,0xb3,0xb1,0xb3,0xb0,0xb0,0xac,0xaf,0xae,0xb1,0xae,0xaf,0xaf, 0xb2,0xb4,0xb6,0xb7,0xb8,0xb9,0xba,0xbc,0xbe,0xbd,0xbb,0xb9,0xb7,0xb6,0xb5,0xb5, 0xb7,0xb2,0xae,0xac,0xad,0xac,0xae,0xb0,0xb0,0xb1,0xb0,0xb1,0xb5,0xb6,0xb9,0xbb, 0xbc,0xbd,0xbe,0xbc,0xbe,0xbe,0xbe,0xbc,0xbc,0xbc,0xb8,0xb8,0xb6,0xb4,0xb4,0xb5, 0xb4,0xb0,0xb0,0xae,0xb0,0xb0,0xb1,0xb2,0xb4,0xb6,0xb6,0xb6,0xb8,0xba,0xbc,0xbc, 0xbe,0xbb,0xb9,0xba,0xbb,0xbb,0xbc,0xb8,0xb5,0xb4,0xb4,0xb3,0xb3,0xb1,0xb1,0xb1, 0xb2,0xb2,0xb4,0xb7,0xb7,0xb8,0xba,0xbb,0xbc,0xbd,0xbf,0xbf,0xc2,0xc1,0xc1,0xc1, 0xbe,0xc0,0xbd,0xba,0xb8,0xb7,0xb6,0xb6,0xb6,0xb2,0xb3,0xaf,0xae,0xaf,0xb1,0xb5, 0xb6,0xb5,0xb8,0xb8,0xb9,0xbd,0xbe,0xbe,0xc0,0xc0,0xbf,0xc1,0xc0,0xbe,0xbe,0xbd, 0xbd,0xbb,0xb9,0xb7,0xb6,0xb5,0xb5,0xb7,0xb6,0xb4,0xb5,0xb6,0xb8,0xba,0xbb,0xbb, 0xbe,0xbf,0xc2,0xc1,0xc1,0xc0,0xc1,0xc2,0xc1,0xc1,0xc1,0xc0,0xbc,0xbc,0xb9,0xb8, 0xb9,0xb9,0xb6,0xb6,0xb4,0xb4,0xb4,0xb7,0xb9,0xb8,0xbb,0xbc,0xbc,0xbd,0xbd,0xbe, 0xc1,0xc2,0xc0,0xbf,0xbf,0xbf,0xbd,0xbc,0xbe,0xbb,0xb9,0xb8,0xb7,0xb7,0xb6,0xb4, 0xb4,0xb5,0xb4,0xb6,0xb7,0xb8,0xb8,0xbc,0xbd,0xbe,0xc1,0xc1,0xc2,0xc3,0xc2,0xc4, 0xc5,0xc5,0xc3,0xc2,0xbe,0xbe,0xbd,0xbb,0xb9,0xb8,0xb4,0xb6,0xb6,0xb3,0xb4,0xb6, 0xb5,0xb7,0xb9,0xbc,0xbe,0xbf,0xbe,0xc2,0xbf,0xc0,0xc0,0xc3,0xc2,0xc1,0xbe,0xbd, 0xbb,0xb9,0xb7,0xb6,0xb6,0xb5,0xb3,0xb2,0xb1,0xb1,0xb3,0xb5,0xb6,0xb7,0xb9,0xba, 0xbe,0xbe,0xbf,0xc2,0xc2,0xc3,0xc3,0xc4,0xc4,0xc1,0xc2,0xbf,0xbc,0xbe,0xbb,0xba, 0xb9,0xb7,0xb4,0xb5,0xb5,0xb4,0xb4,0xb5,0xb7,0xb7,0xb9,0xb9,0xbb,0xbd,0xbe,0xc1, 0xc3,0xc2,0xc0,0xc0,0xc2,0xc2,0xc1,0xc2,0xc1,0xc0,0xbc,0xba,0xb9,0xb9,0xb9,0xb9, 0xb6,0xb2,0xb3,0xb3,0xb6,0xb8,0xbb,0xba,0xbd,0xbd,0xbd,0xc1,0xc2,0xc2,0xc3,0xc2, 0xc3,0xc2,0xc2,0xc2,0xc0,0xbe,0xbd,0xbc,0xbb,0xb9,0xb9,0xb4,0xb4,0xb5,0xb4,0xb3, 0xb5,0xb5,0xb6,0xb6,0xb8,0xba,0xbb,0xbe,0xc0,0xc2,0xc1,0xc2,0xc2,0xc3,0xc3,0xc1, 0xc1,0xbf,0xbe,0xbb,0xb9,0xb8,0xb7,0xb3,0xb3,0xb2,0xb2,0xb2,0xb3,0xb4,0xb5,0xb5, 0xb8,0xb9,0xbd,0xbf,0xc0,0xbf,0xc0,0xbf,0xc0,0xc2,0xc4,0xc1,0xbf,0xbd,0xb9,0xb9, 0xba,0xba,0xb7,0xb6,0xb2,0xb2,0xb2,0xb2,0xb4,0xb7,0xb8,0xb7,0xb8,0xbb,0xbc,0xbe, 0xc1,0xc1,0xc1,0xc2,0xc0,0xc2,0xc2,0xc2,0xc0,0xbf,0xbe,0xbc,0xbc,0xba,0xb8,0xb7, 0xb5,0xb1,0xb4,0xb3,0xb3,0xb4,0xb4,0xb5,0xb7,0xb8,0xbb,0xbb,0xbc,0xbe,0xbe,0xc0, 0xbf,0xc0,0xc1,0xc1,0xbf,0xbf,0xbe,0xbd,0xbd,0xba,0xb8,0xb6,0xb6,0xb6,0xb6,0xb6, 0xb5,0xb5,0xb7,0xb6,0xb8,0xba,0xbb,0xbb,0xc0,0xbd,0xbd,0xc0,0xc1,0xbf,0xc0,0xbd, 0xbd,0xbb,0xbb,0xbb,0xb9,0xb8,0xb7,0xb5,0xb4,0xb6,0xb4,0xb3,0xb1,0xb2,0xb3,0xb4, 0xb8,0xb9,0xb8,0xb9,0xb9,0xb9,0xbb,0xc0,0xbf,0xc0,0xbe,0xbe,0xbc,0xbd,0xbc,0xbc, 0xb7,0xb8,0xb6,0xb4,0xb6,0xb5,0xb3,0xb1,0xb1,0xb1,0xb1,0xb4,0xb6,0xb7,0xb7,0xb9, 0xba,0xba,0xbd,0xbd,0xbd,0xbd,0xbd,0xbc,0xbc,0xba,0xb9,0xb8,0xb8,0xb6,0xb5,0xb5, 0xb3,0xb2,0xb2,0xb2,0xb2,0xb3,0xb4,0xb3,0xb4,0xb7,0xb7,0xb9,0xbc,0xbc,0xbd,0xbe, 0xbf,0xc0,0xc2,0xc0,0xbf,0xbe,0xbf,0xbe,0xbc,0xba,0xb8,0xb7,0xb6,0xb3,0xb2,0xb0, 0xb0,0xb2,0xb4,0xb2,0xb3,0xb2,0xb4,0xb5,0xba,0xba,0xbc,0xbb,0xba,0xbb,0xbc,0xbc, 0xbd,0xbc,0xbc,0xbb,0xba,0xba,0xb8,0xb6,0xb6,0xb4,0xb2,0xb2,0xb2,0xb2,0xb4,0xb5, 0xb6,0xb5,0xb6,0xb7,0xba,0xbb,0xbd,0xbe,0xbe,0xbd,0xbe,0xbe,0xbe,0xbf,0xbc,0xbc, 0xbb,0xba,0xb7,0xb6,0xb4,0xb4,0xb2,0xb2,0xb1,0xb0,0xb0,0xb1,0xb2,0xb3,0xb6,0xb8, 0xb8,0xbb,0xbd,0xbd,0xbe,0xbf,0xc1,0xbf,0xc0,0xbf,0xbe,0xbd,0xbd,0xbe,0xbb,0xb8, 0xb7,0xb5,0xb3,0xb5,0xb4,0xb4,0xb4,0xb3,0xb4,0xb5,0xb5,0xb7,0xb8,0xbb,0xba,0xbc, 0xbe,0xbe,0xbf,0xbe,0xbf,0xbe,0xbd,0xbb,0xbd,0xbb,0xba,0xb9,0xb7,0xb6,0xb5,0xb4, 0xb3,0xb1,0xb1,0xad,0xaa,0xac,0xaf,0xb3,0xb9,0xb8,0xb9,0xb8,0xb7,0xb8,0xbd,0xc1, 0xc0,0xbf,0xbe,0xbd,0xbd,0xbe,0xbd,0xba,0xb9,0xb8,0xb6,0xb7,0xb8,0xb6,0xb0,0xaa, 0xa9,0xa9,0xb0,0xb8,0xbb,0xb4,0xae,0xad,0xb1,0xba,0xc0,0xc1,0xbf,0xbc,0xba,0xbc, 0xbe,0xbb,0xbc,0xb9,0xb8,0xb7,0xb5,0xb3,0xb4,0xb4,0xb4,0xb2,0xb4,0xb3,0xb6,0xb6, 0xb7,0xb9,0xb8,0xbb,0xbb,0xbe,0xc0,0xc1,0xbf,0xbe,0xbc,0xbd,0xbb,0xbc,0xbc,0xb9, 0xb6,0xb5,0xb4,0xb3,0xb3,0xb4,0xb2,0xb2,0xb1,0xb1,0xb3,0xb3,0xb6,0xb5,0xb8,0xb8, 0xba,0xbc,0xbb,0xbd,0xbe,0xbd,0xbc,0xbc,0xbb,0xba,0xb9,0xb9,0xb7,0xb6,0xb6,0xb3, 0xb1,0xb1,0xb1,0xb2,0xb2,0xb2,0xb3,0xb5,0xb6,0xb7,0xb7,0xb9,0xbb,0xbe,0xbd,0xbe, 0xbd,0xbb,0xbc,0xbc,0xbb,0xbb,0xb9,0xb7,0xb4,0xb4,0xb2,0xb3,0xb0,0xb0,0xad,0xaf, 0xad,0xb1,0xb1,0xb1,0xb1,0xaf,0xad,0xbc,0xc2,0xc3,0xc1,0xc3,0xc1,0xc4,0xc2,0xc3, 0xc1,0xc0,0xbc,0xbb,0xbb,0xb9,0xb7,0xb5,0xb5,0xb3,0xb3,0xb3,0xb4,0xb5,0xb5,0xb3, 0xb6,0xb8,0xb9,0xbe,0xbd,0xbc,0xbc,0xbd,0xbd,0xbf,0xbf,0xbe,0xbe,0xbc,0xbb,0xba, 0xb8,0xb8,0xb5,0xb6,0xb2,0xb1,0xb0,0xb1,0xb2,0xb2,0xb4,0xb6,0xb7,0xb8,0xb9,0xbc, 0xbd,0xbd,0xbf,0xc1,0xc0,0xc0,0xc1,0xbe,0xbf,0xbe,0xbb,0xba,0xb8,0xb7,0xb4,0xb3, 0xb0,0xb0,0xaf,0xb0,0xae,0xaf,0xaf,0xb1,0xb2,0xb6,0xb6,0xb9,0xbb,0xbd,0xbd,0xbb, 0xbe,0xbf,0xbc,0xbe,0xbc,0xbb,0xbb,0xb9,0xb5,0xb4,0xb4,0xb2,0xb2,0xb1,0xaf,0xaf, 0xaf,0xb1,0xb3,0xb5,0xb3,0xb4,0xb4,0xb7,0xb9,0xbb,0xba,0xba,0xb9,0xba,0xbb,0xba, 0xba,0xb4,0xb4,0xb3,0xb2,0xaf,0xae,0xac,0xaa,0xa9,0xa8,0xa7,0xa6,0xa9,0xab,0xb0, 0xaf,0xb0,0xae,0xb0,0xb4,0xb6,0xb8,0xb9,0xba,0xbc,0xba,0xba,0xb9,0xb8,0xba,0xb7, 0xb5,0xb5,0xb1,0xb1,0xaf,0xae,0xae,0xae,0xae,0xae,0xae,0xaf,0xaf,0xaf,0xb1,0xb5, 0xb8,0xb8,0xb7,0xb9,0xb8,0xba,0xbb,0xbb,0xba,0xb8,0xb5,0xb5,0xb5,0xb4,0xb2,0xb0, 0xae,0xad,0xab,0xac,0xab,0xaa,0xac,0xac,0xae,0xb0,0xb0,0xb3,0xb3,0xb6,0xb6,0xb6, 0xb8,0xb8,0xb8,0xb8,0xb7,0xb8,0xb5,0xb5,0xb2,0xb1,0xb0,0xaf,0xad,0xac,0xaa,0xa8, 0xa9,0xaa,0xaa,0xac,0xad,0xae,0xae,0xb1,0xb2,0xb4,0xb4,0xb6,0xb6,0xb7,0xb7,0xb7, 0xb8,0xb8,0xb7,0xb7,0xb5,0xb4,0xb2,0xb2,0xae,0xae,0xad,0xaa,0xaa,0xab,0xab,0xaa, 0xaa,0xac,0xae,0xb0,0xb3,0xb4,0xb4,0xb5,0xb6,0xb8,0xb8,0xb9,0xba,0xb8,0xb8,0xb6, 0xb6,0xb3,0xb0,0xb0,0xae,0xac,0xab,0xab,0xaa,0xa8,0xa9,0xaa,0xab,0xab,0xac,0xad, 0xaf,0xb0,0xb3,0xb4,0xb5,0xb5,0xb7,0xb8,0xb8,0xb7,0xb8,0xb5,0xb4,0xb5,0xb4,0xb3, 0xb1,0xb0,0xae,0xac,0xab,0xac,0xab,0xac,0xac,0xac,0xab,0xac,0xae,0xb1,0xb2,0xb3, 0xb2,0xb2,0xb4,0xb4,0xb6,0xb6,0xb5,0xb3,0xb2,0xb2,0xb2,0xb2,0xaf,0xaf,0xae,0xad, 0xac,0xab,0xab,0xac,0xab,0xaa,0xac,0xaf,0xaf,0xaf,0xae,0xb0,0xb2,0xb1,0xb2,0xb5, 0xb6,0xb4,0xb1,0xb2,0xb2,0xb2,0xb0,0xb0,0xaf,0xae,0xab,0xaa,0xab,0xab,0xaa,0xa9, 0xaa,0xab,0xaf,0xb0,0xb1,0xb2,0xb1,0xb4,0xb5,0xb7,0xb7,0xb9,0xb7,0xb6,0xb5,0xb6, 0xb5,0xb5,0xb4,0xb2,0xaf,0xad,0xab,0xaa,0xa9,0xaa,0xa7,0xa9,0xa9,0xa9,0xac,0xac, 0xae,0xb0,0xb0,0xb1,0xb4,0xb3,0xb5,0xb5,0xb7,0xb5,0xb6,0xb5,0xb4,0xb3,0xb2,0xb1, 0xaf,0xaf,0xad,0xae,0xab,0xaa,0xa9,0xa8,0xa9,0xaa,0xab,0xac,0xae,0xad,0xaf,0xaf, 0xb3,0xb4,0xb4,0xb6,0xb4,0xb3,0xb3,0xb5,0xb5,0xb3,0xb2,0xb0,0xad,0xac,0xad,0xab, 0xab,0xaa,0xa9,0xa8,0xaa,0xaa,0xa9,0xac,0xac,0xac,0xac,0xae,0xb0,0xb2,0xb1,0xb4, 0xb3,0xb3,0xb2,0xb2,0xb2,0xb4,0xb2,0xb1,0xae,0xad,0xab,0xaa,0xa9,0xa8,0xa6,0xa8, 0xa9,0xaa,0xa9,0xa9,0xaa,0xad,0xae,0xb0,0xb1,0xb4,0xb3,0xb5,0xb4,0xb5,0xb5,0xb5, 0xb3,0xb3,0xb2,0xb1,0xb0,0xaf,0xae,0xab,0xab,0xa8,0xa9,0xa7,0xaa,0xa8,0xa8,0xa8, 0xaa,0xac,0xae,0xaf,0xaf,0xaf,0xb0,0xb1,0xb3,0xb4,0xb3,0xb4,0xb1,0xaf,0xaf,0xae, 0xac,0xab,0xaa,0xa9,0xa7,0xa6,0xa6,0xa3,0xa5,0xa4,0xa5,0xa7,0xa7,0xaa,0xac,0xad, 0xaf,0xb0,0xaf,0xb1,0xb2,0xb4,0xb3,0xb1,0xb2,0xb0,0xaf,0xb0,0xaf,0xab,0xab,0xa9, 0xa8,0xa7,0xa6,0xa6,0xa6,0xa5,0xa6,0xa6,0xa6,0xa7,0xaa,0xab,0xac,0xaf,0xb1,0xb2, 0xb1,0xb1,0xb0,0xb1,0xb1,0xb2,0xb1,0xb0,0xad,0xac,0xa8,0xa8,0xa7,0xa7,0xa6,0xa6, 0xa4,0xa3,0xa3,0xa4,0xa4,0xa8,0xa7,0xa9,0xab,0xac,0xad,0xae,0xb0,0xb0,0xb0,0xae, 0xaf,0xaf,0xb0,0xaf,0xaf,0xad,0xa8,0xa8,0xa8,0xa7,0xa7,0xa7,0xa4,0xa2,0xa5,0xa3, 0xa5,0xa6,0xa7,0xa9,0xac,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb2,0xb0,0xaf,0xaf, 0xac,0xab,0xaa,0xa9,0xa7,0xa7,0xa5,0xa3,0xa5,0xa5,0xa3,0xa3,0xa4,0xa5,0xa6,0xa6, 0xaa,0xaa,0xab,0xab,0xa9,0xaa,0xab,0xad,0xae,0xae,0xad,0xac,0xaa,0xaa,0xab,0xa9, 0xa8,0xa6,0xa5,0xa6,0xa4,0xa3,0xa3,0xa4,0xa5,0xa8,0xaa,0xa8,0xaa,0xab,0xac,0xac, 0xaf,0xaf,0xae,0xae,0xb0,0xaf,0xb0,0xaf,0xad,0xae,0xaa,0xa9,0xa8,0xa8,0xa6,0xa4, 0xa3,0xa2,0xa3,0xa2,0xa3,0xa3,0xa4,0xa5,0xa5,0xa8,0xa9,0xaa,0xac,0xac,0xac,0xad, 0xad,0xad,0xad,0xac,0xab,0xab,0xaa,0xa8,0xa8,0xa5,0xa3,0xa3,0xa2,0xa1,0xa0,0x9f, 0xa2,0xa3,0xa2,0xa4,0xa5,0xa7,0xa9,0xaa,0xad,0xad,0xad,0xae,0xaf,0xaf,0xaf,0xaf, 0xad,0xac,0xaa,0xa9,0xa7,0xa5,0xa5,0xa4,0xa3,0xa3,0xa3,0xa2,0xa2,0xa3,0xa4,0xa4, 0xa6,0xa7,0xa8,0xaa,0xab,0xab,0xab,0xab,0xac,0xad,0xac,0xab,0xab,0xa9,0xa8,0xa6, 0xa6,0xa4,0xa3,0xa2,0xa1,0xa0,0x9f,0x9f,0xa1,0xa1,0xa1,0xa2,0xa4,0xa5,0xa6,0xa7, 0xaa,0xaa,0xac,0xab,0xac,0xad,0xad,0xac,0xac,0xa9,0xab,0xa8,0xa7,0xa6,0xa3,0xa2, 0xa2,0xa2,0xa0,0x9f,0xa0,0xa1,0xa2,0xa3,0xa5,0xa5,0xa4,0xa5,0xa8,0xab,0xab,0xab, 0xaa,0xaa,0xaa,0xaa,0xab,0xab,0xaa,0xa7,0xa7,0xa5,0xa6,0xa4,0xa3,0xa2,0xa2,0xa2, 0x9f,0xa0,0xa1,0x9f,0xa1,0xa2,0xa4,0xa6,0xa6,0xa5,0xa6,0xa8,0xab,0xab,0xab,0xa9, 0xa7,0xa7,0xa7,0xa9,0xa6,0xa5,0xa3,0xa1,0xa1,0x9f,0x9e,0x9e,0x9f,0x9f,0x9f,0x9f, 0xa0,0xa2,0xa4,0xa6,0xa7,0xa8,0xaa,0xaa,0xab,0xab,0xac,0xac,0xab,0xa9,0xa8,0xa8, 0xa8,0xa5,0xa5,0xa3,0xa1,0xa2,0xa1,0x9f,0xa0,0xa1,0xa0,0xa0,0xa1,0xa2,0xa4,0xa4, 0xa7,0xa9,0xa9,0xaa,0xab,0xab,0xab,0xaa,0xaa,0xa9,0xa9,0xa8,0xa7,0xa4,0xa4,0xa4, 0xa3,0xa1,0xa1,0xa0,0x9f,0x9e,0x9f,0xa1,0xa2,0xa2,0xa3,0xa5,0xa3,0xa6,0xa0,0xae, 0xb0,0xb1,0xb0,0xb0,0xaf,0xad,0xad,0xac,0xaa,0xa7,0xa7,0xa7,0xa6,0xa4,0xa2,0xa2, 0xa4,0xa4,0xa5,0xa5,0xa6,0xa8,0xa9,0xab,0xac,0xac,0xae,0xae,0xae,0xae,0xae,0xae, 0xaf,0xab,0xab,0xaa,0xa9,0xa8,0xa7,0xa6,0xa3,0xa3,0xa3,0xa3,0xa4,0xa4,0xa4,0xa6, 0xa6,0xa8,0xa8,0xab,0xac,0xb0,0xae,0xae,0xae,0xb0,0xb0,0xb2,0xb0,0xaf,0xad,0xab, 0xab,0xaa,0xa8,0xa6,0xa5,0xa5,0xa3,0xa3,0xa2,0xa3,0xa2,0xa4,0xa4,0xa8,0xa7,0xa7, 0xaa,0xac,0xac,0xaf,0xb0,0xb1,0xaf,0xaf,0xae,0xaf,0xaf,0xad,0xab,0xaa,0xa8,0xa6, 0xa5,0xa5,0xa3,0xa3,0xa4,0xa3,0xa2,0xa3,0xa4,0xa5,0xa6,0xa8,0xa9,0xaa,0xac,0xad, 0xac,0xad,0xae,0xad,0xac,0xae,0xad,0xab,0xa9,0xa9,0xa7,0xa7,0xa4,0xa2,0xa0,0x9f, 0x9e,0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa5,0xa7,0xa8,0xab,0xad,0xad,0xad,0xac,0xac, 0xac,0xab,0xab,0xab,0xab,0xa9,0xa6,0xa6,0xa5,0xa4,0xa3,0xa1,0xa2,0xa3,0xa4,0xa4, 0xa4,0xa6,0xa5,0xa7,0xaa,0xab,0xaa,0xab,0xac,0xad,0xad,0xad,0xab,0xac,0xaa,0xaa, 0xa7,0xa8,0xa4,0xa6,0xa3,0xa4,0xa2,0xa2,0xa1,0xa1,0xa1,0xa3,0xa3,0xa5,0xa4,0xa8, 0xa7,0xa7,0xa8,0xac,0xac,0xac,0xac,0xaa,0xac,0xab,0xab,0xaa,0xa8,0xa9,0xa6,0xa4, 0xa4,0xa5,0xa1,0xa2,0x9f,0xa0,0xa0,0xa1,0xa1,0xa2,0xa1,0xa2,0xa3,0xa6,0xa9,0xaa, 0xa2,0xa1,0x9c,0x9e,0xa5,0xa9,0xa7,0xa0,0x98,0x96,0x98,0x9f,0xa1,0xa1,0x9c,0x99, 0x9a,0x9e,0x9f,0x9f,0xa2,0xa2,0xa2,0xa4,0xa4,0xa5,0xa8,0xa8,0xa9,0xaa,0xaa,0xaa, 0xaa,0xaa,0xab,0xa9,0xa9,0xa7,0xa5,0xa5,0xa2,0xa2,0x9f,0x9e,0x9d,0x9d,0x9c,0x9e, 0x9e,0x9e,0xa0,0xa1,0xa1,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa7,0xa8,0xa8,0xa7,0xa7, 0xa6,0xa6,0xa3,0xa4,0xa1,0xa0,0x9e,0x9c,0x9c,0x9b,0x9a,0x9b,0x9d,0x9e,0x9e,0x9e, 0x9f,0xa1,0xa4,0xa5,0xa8,0xa8,0xa7,0xa8,0xa8,0xa9,0xa8,0xa7,0xa8,0xa5,0xa4,0xa2, 0xa3,0xa2,0xa0,0x9d,0x9c,0x9b,0x9c,0x9b,0x9d,0x9e,0x9e,0xa0,0xa1,0xa2,0xa3,0xa4, 0xa5,0xa6,0xa8,0xa9,0xa8,0xa8,0xa7,0xa7,0xa8,0xa5,0xa5,0xa4,0xa2,0xa0,0x9f,0x9f, 0x9e,0x9e,0x9d,0x9c,0x9c,0x9e,0x9e,0x9f,0xa2,0xa3,0xa3,0xa4,0xa6,0xa8,0xa8,0xaa, 0xa7,0xa9,0xa9,0xa7,0xa9,0xa7,0xa4,0xa4,0xa2,0xa4,0xa0,0xa0,0x9d,0x9c,0x9c,0x9d, 0x9d,0x9e,0x9d,0x9f,0xa0,0xa2,0xa3,0xa3,0xa4,0xa5,0xa6,0xa9,0xaa,0xa8,0xa7,0xa6, 0xa7,0xa6,0xa6,0xa4,0xa3,0xa0,0xa1,0x9f,0xa0,0x9d,0x9d,0x9d,0x9d,0x9e,0x9f,0x9f, 0xa0,0xa1,0xa3,0xa3,0xa3,0xa5,0xa7,0xa9,0xa7,0xa7,0xa5,0xa7,0xa6,0xa4,0xa5,0xa3, 0xa2,0xa0,0x9e,0x9e,0x9e,0x9d,0x9b,0x9c,0x9c,0x9b,0x9c,0x9e,0xa0,0xa1,0x9f,0xa1, 0xa3,0xa6,0xa5,0xa6,0xa7,0xa7,0xa7,0xa9,0xa7,0xa8,0xa5,0xa6,0xa3,0xa2,0xa1,0x9f, 0x9f,0x9e,0x9e,0x9e,0x96,0x94,0x94,0x96,0x9b,0xa3,0xa1,0x9c,0x9a,0x9b,0x9f,0xa6, 0xa7,0xa8,0xa8,0xa7,0xa8,0xa6,0xa5,0xa5,0xa5,0xa2,0xa1,0x9f,0x9d,0x9e,0x9c,0x9b, 0x9b,0x9a,0x9b,0x9c,0x9e,0xa0,0x9d,0x9f,0xa1,0xa3,0xa3,0xa5,0xa6,0xa6,0xa5,0xa4, 0xa6,0xa7,0xa3,0xa2,0xa1,0xa1,0x9e,0x9e,0x9d,0x9d,0x9b,0x9a,0x99,0x9a,0x99,0x9a, 0x9c,0x9c,0x9a,0x9e,0x9f,0x9f,0xa2,0xa1,0xa0,0xa2,0xa3,0xa3,0xa3,0xa2,0xa0,0xa0, 0xa0,0x9e,0x9e,0x9c,0x9a,0x99,0x96,0x96,0x95,0x96,0x97,0x98,0x99,0x99,0x99,0x9b, 0x9c,0xa0,0xa2,0xa1,0xa1,0xa2,0xa3,0xa3,0xa3,0xa2,0xa3,0xa1,0xa1,0x9f,0x9e,0x9d, 0x9d,0x9b,0x9d,0x9b,0x9a,0x99,0x9a,0x9b,0x9c,0x9b,0x9e,0x9e,0x9f,0xa1,0xa3,0xa4, 0xa4,0xa4,0xa6,0xa6,0xa7,0xa6,0xa5,0xa5,0xa4,0xa2,0xa2,0xa1,0xa0,0x9e,0x9d,0x9b, 0x9b,0x9b,0x9c,0x9d,0x9e,0x9d,0x9f,0x9f,0xa1,0xa4,0xa4,0xa4,0xa6,0xa7,0xa6,0xa7, 0xa8,0xa7,0xa6,0xa6,0xa6,0xa3,0xa2,0xa1,0xa0,0x9f,0x9d,0x9d,0x9b,0x9b,0x9c,0x9a, 0x9a,0x9d,0x9d,0x9e,0xa0,0xa0,0xa3,0xa3,0xa5,0xa5,0xa6,0xa6,0xa5,0xa7,0xa6,0xa6, 0xa3,0xa2,0xa3,0xa1,0x9e,0x9d,0x9d,0x9a,0x9a,0x9a,0x9a,0x9a,0x9b,0x9b,0x9c,0x9d, 0x9f,0x9f,0xa1,0xa4,0xa7,0xa6,0xa6,0xa7,0xa5,0xa7,0xa6,0xa7,0xa4,0xa5,0xa2,0xa1, 0xa0,0xa0,0x9e,0x9c,0x9e,0x9c,0x9b,0x99,0x9b,0x9b,0x9d,0x9f,0x9f,0x9f,0xa1,0xa3, 0xa5,0xa5,0xa6,0xa7,0xa8,0xa7,0xa6,0xa4,0xa4,0xa3,0xa3,0xa3,0xa3,0x9f,0x9e,0x9c, 0x9c,0x9b,0x9b,0x9a,0x9b,0x9c,0x9e,0x9f,0x9f,0x9e,0xa0,0xa2,0xa3,0xa5,0xa6,0xa6, 0xa6,0xa5,0xa6,0xa6,0xa5,0xa5,0xa5,0xa3,0xa1,0x9d,0x9e,0x9d,0x9d,0x9b,0x9b,0x99, 0x9a,0x9b,0x9c,0x9c,0x9d,0x9d,0xa0,0xa2,0xa1,0xa4,0xa5,0xa5,0xa6,0xa5,0xa6,0xa6, 0xa4,0xa5,0xa5,0xa4,0xa1,0xa0,0x9d,0x9c,0x9b,0x9c,0x9c,0x9a,0x9a,0x99,0x9a,0x9b, 0x9c,0x9d,0xa0,0xa1,0xa1,0xa3,0xa3,0xa4,0xa5,0xa6,0xa6,0xa5,0xa5,0xa5,0xa3,0xa3, 0xa2,0x9f,0x9f,0x9f,0x9e,0x9d,0x9c,0x9a,0x99,0x9b,0x9b,0x9b,0x9d,0xa0,0x9e,0x9f, 0xa2,0xa3,0xa5,0xa6,0xa6,0xa4,0xa6,0xa6,0xa5,0xa6,0xa4,0xa2,0xa1,0x9f,0xa0,0x9e, 0x9d,0x9c,0x9b,0x9a,0x98,0x9a,0x9b,0x9b,0x9c,0x9c,0x9e,0x9e,0xa1,0xa1,0xa2,0xa2, 0xa4,0xa4,0xa4,0xa5,0xa4,0xa4,0xa4,0xa2,0xa3,0xa1,0x9e,0x9d,0x9b,0x9b,0x9b,0x9b, 0x99,0x99,0x97,0x98,0x99,0x9c,0x9d,0x9e,0x9f,0xa1,0xa1,0xa2,0xa5,0xa6,0xa5,0xa6, 0xa4,0xa3,0xa3,0xa2,0xa1,0xa0,0x9f,0x9d,0x9c,0x9a,0x9a,0x99,0x98,0x98,0x99,0x9a, 0x9a,0x9b,0x9c,0x9d,0xa0,0xa1,0xa1,0xa2,0xa3,0xa4,0xa4,0xa5,0xa6,0xa5,0xa3,0xa2, 0xa1,0xa1,0x9f,0x9e,0x9d,0x9b,0x99,0x98,0x9a,0x99,0x99,0x99,0x9b,0x9b,0x9c,0x9f, 0x9f,0xa2,0xa3,0xa2,0xa2,0xa1,0x9e,0xa7,0xa9,0xa8,0xa7,0xa6,0xa5,0xa3,0xa1,0xa0, 0xa0,0xa0,0x9d,0x9e,0x9d,0x9d,0x9f,0xa0,0x9f,0x9f,0xa1,0xa4,0xa5,0xa8,0xa7,0xa7, 0xa9,0xa9,0xaa,0xac,0xaa,0xaa,0xa7,0xa8,0xa7,0xa6,0xa5,0xa3,0xa1,0xa1,0x9f,0x9f, 0x9f,0x9e,0x9d,0xa0,0xa1,0xa2,0xa0,0xa1,0xa2,0xa4,0xa6,0xa9,0xa8,0xa8,0xa7,0xa8, 0xa9,0xa9,0xa7,0xa8,0xa7,0xa5,0xa4,0xa4,0xa3,0xa1,0x9f,0x9f,0x9d,0x9d,0x9c,0x9f, 0x9f,0xa1,0xa0,0xa2,0xa2,0xa5,0xa5,0xa7,0xa7,0xa9,0xa9,0xaa,0xaa,0xa9,0xa6,0xa8, 0xa6,0xa5,0xa3,0xa1,0xa0,0x9f,0x9e,0x9e,0x9c,0x9b,0x9b,0x9e,0x9e,0x9f,0xa0,0xa1, 0xa3,0xa4,0xa4,0xa7,0xa6,0xa9,0xa6,0xa9,0xa7,0xa8,0xa6,0xa6,0xa4,0xa4,0xa2,0xa1, 0x9f,0xa0,0x9d,0x9c,0x9b,0x9c,0x9b,0x9b,0x9d,0x9e,0x9e,0xa0,0x9f,0xa4,0xa4,0xa4, 0xa6,0xa7,0xa6,0xa7,0xa6,0xa8,0xa6,0xa6,0xa5,0xa4,0xa2,0xa1,0x9f,0x9f,0x9e,0x9e, 0x9b,0x9b,0x9b,0x9b,0x9b,0x9c,0x9e,0x9e,0x9f,0xa1,0xa1,0xa3,0xa5,0xa7,0xa6,0xa5, 0xa5,0xa5,0xa4,0xa4,0xa3,0xa4,0xa1,0x9f,0x9d,0x9d,0x9c,0x9c,0x9b,0x9a,0x98,0x99, 0x99,0x9b,0x9d,0x9d,0x9c,0x9f,0x9f,0xa1,0xa4,0xa4,0xa3,0xa4,0xa4,0xa5,0xa4,0xa4, 0xa3,0xa4,0x9f,0xa1,0x9e,0x9e,0x9c,0x9c,0x9a,0x99,0x99,0x9a,0x9a,0x9b,0x99,0x9c, 0x9c,0x9e,0xa1,0xa0,0xa1,0xa4,0xa4,0xa3,0xa4,0xa5,0xa4,0xa3,0xa2,0xa3,0xa3,0x9f, 0x9e,0x9c,0x9b,0x9a,0x98,0x99,0x97,0x97,0x97,0x98,0x98,0x9b,0x9b,0x9d,0x9e,0x9f, 0xa0,0xa2,0xa3,0xa4,0xa3,0xa3,0xa3,0xa3,0xa2,0xa4,0xa1,0xa0,0x9e,0x9c,0x9a,0x9a, 0x97,0x97,0x95,0x97,0x97,0x97,0x98,0x98,0x98,0x9a,0x9d,0x9e,0x9f,0xa2,0xa2,0xa2, 0xa2,0xa2,0xa1,0xa3,0xa2,0xa1,0xa0,0xa0,0x9e,0x9d,0x9b,0x9b,0x9a,0x98,0x98,0x97, 0x98,0x9a,0x98,0x9a,0x9c,0x9e,0x9c,0x9f,0x9f,0xa1,0xa2,0xa4,0xa3,0xa3,0xa1,0xa3, 0xa3,0xa3,0xa2,0xa1,0x9e,0x9d,0x9d,0x9c,0x9b,0x99,0x97,0x97,0x97,0x99,0x99,0x9a, 0x99,0x9c,0x9c,0x9e,0x9e,0xa0,0xa1,0xa3,0xa2,0xa2,0xa3,0xa3,0xa2,0xa4,0xa1,0x9f, 0x9e,0x9e,0x9b,0x9c,0x98,0x98,0x97,0x96,0x96,0x98,0x97,0x97,0x98,0x9b,0x9a,0x9c, 0x9e,0xa0,0xa0,0xa0,0xa2,0xa1,0xa1,0xa1,0xa2,0xa2,0x9f,0x9f,0x9f,0x9c,0x9b,0x9b, 0x9a,0x98,0x97,0x97,0x96,0x95,0x96,0x96,0x98,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,0xa0, 0xa1,0xa1,0xa1,0xa2,0xa0,0xa0,0xa0,0xa2,0x9f,0x9c,0x9b,0x9a,0x9a,0x97,0x98,0x95, 0x95,0x95,0x96,0x97,0x95,0x96,0x97,0x97,0x9a,0x9c,0x9d,0x9e,0x9e,0x9e,0x9f,0xa1, 0xa0,0xa0,0xa0,0x9f,0x9d,0x9c,0x9a,0x9a,0x99,0x97,0x97,0x94,0x96,0x95,0x95,0x96, 0x97,0x97,0x99,0x98,0x9b,0x9c,0x9c,0x9e,0x9f,0xa0,0xa1,0xa0,0xa0,0xa0,0xa0,0x9f, 0x9e,0x9d,0x9d,0x99,0x99,0x99,0x98,0x95,0x97,0x96,0x94,0x96,0x95,0x97,0x98,0x9a, 0x9a,0x9c,0x9d,0x9d,0x9e,0xa0,0xa0,0x9f,0xa1,0xa0,0x9e,0x9f,0x9f,0x9e,0x9b,0x9a, 0x98,0x98,0x98,0x97,0x93,0x93,0x94,0x94,0x95,0x96,0x98,0x98,0x9a,0x9c,0x9d,0x9c, 0x9d,0x9e,0x9e,0xa0,0x9f,0x9f,0x9e,0x9d,0x9d,0x9e,0x9b,0x9b,0x99,0x97,0x96,0x96, 0x95,0x96,0x96,0x95,0x95,0x95,0x97,0x98,0x99,0x9b,0x9c,0x9e,0x9f,0x9e,0xa0,0xa1, 0xa0,0xa0,0x9f,0x9f,0x9d,0x9d,0x9c,0x9c,0x99,0x99,0x96,0x95,0x94,0x95,0x93,0x93, 0x92,0x94,0x96,0x96,0x97,0x96,0x97,0x9b,0x9c,0x9d,0x9d,0x9d,0x9d,0x9e,0x9d,0x9e, 0x9c,0x9b,0x9a,0x9a,0x98,0x98,0x96,0x96,0x93,0x93,0x92,0x94,0x93,0x94,0x94,0x95, 0x96,0x97,0x96,0x99,0x9b,0x9b,0x9b,0x9c,0x9c,0x9b,0x9b,0x9d,0x9c,0x9b,0x9a,0x99, 0x96,0x95,0x94,0x94,0x93,0x93,0x91,0x91,0x93,0x92,0x92,0x93,0x93,0x93,0x95,0x97, 0x99,0x99,0x99,0x99,0x99,0x9b,0x9c,0x9c,0x9b,0x98,0x98,0x96,0x97,0x97,0x94,0x93, 0x92,0x90,0x8f,0x8e,0x8f,0x8f,0x90,0x91,0x92,0x92,0x95,0x96,0x98,0x97,0x98,0x9a, 0x99,0x99,0x99,0x9a,0x99,0x97,0x97,0x97,0x95,0x95,0x92,0x8f,0x8e,0x8f,0x8e,0x8c, 0x8f,0x8e,0x8d,0x90,0x91,0x92,0x94,0x96,0x97,0x98,0x97,0x99,0x99,0x98,0x99,0x99, 0x99,0x99,0x98,0x96,0x97,0x93,0x92,0x92,0x91,0x8f,0x8e,0x8c,0x8d,0x8d,0x8e,0x90, 0x90,0x90,0x91,0x93,0x94,0x96,0x96,0x98,0x98,0x99,0x99,0x9a,0x99,0x9a,0x98,0x98, 0x96,0x95,0x93,0x93,0x91,0x90,0x8f,0x8d,0x8c,0x8d,0x8e,0x90,0x90,0x8f,0x90,0x91, 0x93,0x96,0x96,0x97,0x97,0x98,0x97,0x97,0x97,0x98,0x97,0x95,0x93,0x93,0x93,0x92, 0x91,0x90,0x8e,0x8e,0x8e,0x8c,0x8d,0x8e,0x8e,0x90,0x8e,0x8f,0x91,0x93,0x93,0x94, 0x94,0x95,0x95,0x96,0x95,0x95,0x95,0x95,0x94,0x93,0x90,0x90,0x90,0x8f,0x8d,0x8d, 0x8b,0x8c,0x8b,0x8b,0x8d,0x8c,0x8d,0x8e,0x8f,0x90,0x92,0x91,0x93,0x93,0x95,0x95, 0x95,0x94,0x95,0x93,0x92,0x91,0x91,0x8e,0x8e,0x8d,0x8b,0x8b,0x8a,0x8a,0x89,0x89, 0x89,0x89,0x8a,0x8b,0x8c,0x8c,0x8f,0x91,0x90,0x92,0x92,0x92,0x92,0x93,0x92,0x92, 0x91,0x90,0x8f,0x8f,0x8b,0x8c,0x8a,0x89,0x88,0x87,0x85,0x86,0x85,0x88,0x88,0x88, 0x89,0x8c,0x8d,0x8e,0x8f,0x90,0x90,0x91,0x91,0x91,0x92,0x91,0x91,0x91,0x8f,0x8f, 0x8c,0x8d,0x8a,0x8b,0x8a,0x86,0x86,0x86,0x85,0x86,0x87,0x89,0x8a,0x8b,0x8a,0x8c, 0x8e,0x90,0x90,0x92,0x90,0x90,0x92,0x93,0x90,0x91,0x90,0x90,0x8d,0x8d,0x8c,0x8a, 0x8a,0x89,0x87,0x88,0x87,0x89,0x87,0x8a,0x8a,0x8b,0x8c,0x8e,0x8d,0x90,0x8f,0x91, 0x92,0x92,0x92,0x92,0x91,0x92,0x90,0x90,0x8e,0x8f,0x8c,0x8c,0x8b,0x8b,0x89,0x88, 0x89,0x88,0x89,0x8a,0x8c,0x8b,0x8e,0x8d,0x90,0x90,0x92,0x91,0x91,0x8f,0x8b,0x6f, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf6,0x01,0x17,0x0f,0xd0,0x10,0x08,0x01, 0xb8,0xa1,0x34,0x01,0x78,0x01,0x34,0x01,0x42,0x46,0x41,0x45,0x43,0x48,0x43,0x48, 0x3d,0x44,0x40,0x44,0x41,0x49,0x3e,0x4d,0x43,0x44,0x3f,0x44,0x3e,0x47,0x41,0x49, 0x3f,0x44,0x3d,0x46,0x42,0x45,0x40,0x47,0x40,0x47,0x3f,0x44,0x3e,0x47,0x40,0x4a, 0x3d,0x49,0x3d,0x45,0x3f,0x4a,0x3f,0x49,0x3c,0x44,0x3f,0x42,0x3f,0x46,0x3f,0x49, 0x3f,0x47,0x3e,0x43,0x40,0x46,0x3e,0x49,0x3e,0x45,0x3e,0x4a,0x40,0x47,0x3d,0x48, 0x41,0x47,0x3e,0x45,0x3e,0x46,0x3e,0x45,0x42,0x46,0x3e,0x44,0x41,0x47,0x41,0x47, 0x3f,0x44,0x3d,0x44,0x3f,0x47,0x3a,0x48,0x40,0x46,0x3e,0x45,0x3f,0x48,0x3e,0x49, 0x41,0x45,0x3d,0x48,0x3d,0x47,0x41,0x4c,0x3f,0x43,0x41,0x45,0x41,0x47,0x3f,0x46, 0x42,0x44,0x3f,0x44,0x3f,0x47,0x3e,0x44,0x41,0x47,0x41,0x47,0x42,0x46,0x3c,0x47, 0x41,0x45,0x3e,0x44,0x40,0x45,0x3f,0x47,0x3d,0x45,0x3b,0x44,0x3f,0x42,0x3c,0x48, 0x41,0x46,0x3c,0x45,0x3d,0x49,0x3d,0x48,0x40,0x48,0x40,0x44,0x41,0x47,0x3d,0x47, 0x3d,0x41,0x3f,0x49,0x3f,0x48,0x3c,0x45,0x3d,0x44,0x3e,0x46,0x3e,0x47,0x3f,0x48, 0x3f,0x43,0x41,0x44,0x40,0x49,0x3d,0x47,0x3e,0x47,0x3e,0x46,0x40,0x44,0x40,0x48, 0x41,0x49,0x3e,0x43,0x40,0x44,0x3d,0x46,0x3e,0x47,0x41,0x42,0x40,0x48,0x3f,0x4a, 0x40,0x44,0x3e,0x45,0x3d,0x48,0x3f,0x46,0x3f,0x45,0x41,0x43,0x40,0x46,0x3d,0x47, 0x3e,0x46,0x3d,0x47,0x42,0x47,0x3e,0x44,0x3e,0x43,0x3e,0x44,0x41,0x47,0x3f,0x46, 0x40,0x41,0x3f,0x44,0x3f,0x48,0x3d,0x49,0x3d,0x43,0x3d,0x44,0x40,0x45,0x3e,0x47, 0x40,0x46,0x3c,0x46,0x40,0x46,0x3f,0x48,0x41,0x45,0x3f,0x46,0x43,0x45,0x3a,0x46, 0x3f,0x49,0x3c,0x43,0x40,0x44,0x3d,0x46,0x3e,0x48,0x3d,0x45,0x41,0x45,0x3b,0x49, 0x3f,0x44,0x40,0x4a,0x40,0x47,0x3e,0x4b,0x3d,0x44,0x40,0x43,0x3e,0x4b,0x3b,0x47, 0x40,0x47,0x3c,0x46,0x3f,0x49,0x3c,0x48,0x3e,0x44,0x3a,0x44,0x3f,0x47,0x3f,0x49, 0x3d,0x44,0x3e,0x47,0x3c,0x47,0x3a,0x46,0x3f,0x42,0x40,0x44,0x3e,0x46,0x3b,0x43, 0x3f,0x44,0x3d,0x44,0x40,0x48,0x3d,0x49,0x3c,0x43,0x3c,0x43,0x41,0x44,0x3e,0x49, 0x3f,0x41,0x3e,0x41,0x3d,0x44,0x3f,0x48,0x42,0x44,0x3d,0x44,0x40,0x45,0x3e,0x44, 0x3f,0x43,0x3d,0x44,0x3b,0x43,0x3e,0x47,0x41,0x48,0x3c,0x44,0x3e,0x47,0x3e,0x45, 0x3d,0x45,0x3d,0x41,0x3d,0x44,0x3d,0x44,0x3d,0x43,0x3d,0x45,0x3f,0x44,0x3b,0x47, 0x3e,0x42,0x3c,0x45,0x3f,0x44,0x39,0x4a,0x3d,0x42,0x3c,0x46,0x3f,0x45,0x3a,0x44, 0x3e,0x45,0x39,0x44,0x3d,0x45,0x3e,0x48,0x3d,0x42,0x3e,0x44,0x3f,0x43,0x3b,0x48, 0x3f,0x43,0x3b,0x44,0x3f,0x46,0x3b,0x44,0x3f,0x41,0x3e,0x43,0x40,0x46,0x3c,0x45, 0x3d,0x47,0x3e,0x44,0x3f,0x49,0x3e,0x48,0x3e,0x45,0x3d,0x46,0x3f,0x46,0x3d,0x47, 0x3e,0x46,0x3b,0x47,0x41,0x46,0x3b,0x48,0x3f,0x47,0x40,0x45,0x3e,0x47,0x40,0x48, 0x3f,0x43,0x3d,0x48,0x3e,0x44,0x3d,0x46,0x3b,0x43,0x3e,0x47,0x3c,0x45,0x3c,0x47, 0x3c,0x47,0x3e,0x45,0x3e,0x45,0x3f,0x45,0x39,0x45,0x3c,0x47,0x3e,0x45,0x3e,0x47, 0x3d,0x46,0x3e,0x47,0x3f,0x45,0x3a,0x49,0x3b,0x43,0x3e,0x45,0x3f,0x46,0x3d,0x43, 0x3d,0x44,0x3d,0x42,0x41,0x46,0x3d,0x44,0x41,0x44,0x3d,0x44,0x40,0x45,0x3c,0x45, 0x3d,0x45,0x3d,0x45,0x3c,0x45,0x3e,0x48,0x3e,0x43,0x3d,0x45,0x3f,0x46,0x3e,0x46, 0x3c,0x45,0x3e,0x49,0x3c,0x43,0x3a,0x44,0x3e,0x46,0x40,0x48,0x3f,0x45,0x3c,0x47, 0x3d,0x47,0x3e,0x47,0x40,0x41,0x3e,0x47,0x3c,0x44,0x3e,0x41,0x3c,0x45,0x3d,0x45, 0x3c,0x43,0x3f,0x46,0x40,0x42,0x3d,0x45,0x3f,0x45,0x3b,0x46,0x3c,0x46,0x3d,0x47, 0x3d,0x43,0x3c,0x46,0x3d,0x43,0x3d,0x44,0x3f,0x43,0x3d,0x45,0x3e,0x45,0x3b,0x49, 0x3e,0x46,0x3e,0x46,0x3e,0x44,0x3e,0x47,0x3e,0x45,0x3d,0x44,0x3e,0x43,0x3d,0x44, 0x3e,0x44,0x3c,0x46,0x3c,0x44,0x3c,0x49,0x3d,0x41,0x3e,0x47,0x3d,0x43,0x3b,0x46, 0x3a,0x44,0x3b,0x46,0x3f,0x43,0x3e,0x48,0x3b,0x43,0x3b,0x46,0x40,0x42,0x3b,0x46, 0x3d,0x42,0x3f,0x45,0x3e,0x45,0x41,0x44,0x41,0x43,0x3a,0x46,0x3d,0x46,0x40,0x46, 0x3c,0x42,0x3e,0x47,0x3f,0x45,0x3d,0x44,0x3d,0x44,0x38,0x42,0x3d,0x42,0x3d,0x45, 0x3d,0x46,0x3f,0x44,0x3e,0x44,0x3b,0x43,0x3c,0x47,0x3d,0x46,0x3e,0x40,0x3c,0x45, 0x3c,0x43,0x3d,0x43,0x42,0x43,0x39,0x45,0x3d,0x47,0x3d,0x44,0x3e,0x44,0x3e,0x48, 0x3d,0x43,0x3d,0x46,0x3c,0x46,0x3d,0x45,0x39,0x43,0x3d,0x42,0x3e,0x45,0x3a,0x45, 0x3a,0x44,0x3b,0x43,0x3e,0x44,0x3c,0x45,0x40,0x44,0x3e,0x45,0x3f,0x3f,0x3d,0x46, 0x3e,0x44,0x3c,0x45,0x3b,0x44,0x3d,0x43,0x3e,0x42,0x3f,0x44,0x40,0x47,0x3c,0x44, 0x3e,0x44,0x3b,0x45,0x3c,0x47,0x3b,0x41,0x3b,0x43,0x3b,0x44,0x3e,0x43,0x3d,0x42, 0x3c,0x44,0x3d,0x43,0x39,0x43,0x3c,0x47,0x3e,0x44,0x3d,0x46,0x3f,0x45,0x3c,0x41, 0x38,0x48,0x3c,0x44,0x3c,0x46,0x3d,0x44,0x3b,0x44,0x3b,0x44,0x3c,0x47,0x3b,0x44, 0x3e,0x43,0x3c,0x43,0x3c,0x45,0x3b,0x46,0x3f,0x45,0x3a,0x43,0x43,0x44,0x3a,0x46, 0x3e,0x44,0x3d,0x44,0x3c,0x41,0x3e,0x42,0x3d,0x44,0x3b,0x43,0x3e,0x43,0x3e,0x40, 0x3e,0x44,0x3b,0x46,0x3d,0x42,0x3b,0x41,0x3f,0x42,0x3b,0x45,0x3d,0x42,0x39,0x47, 0x3c,0x44,0x3e,0x46,0x3e,0x43,0x3b,0x46,0x3b,0x43,0x3d,0x43,0x3c,0x42,0x3a,0x45, 0x3d,0x45,0x39,0x45,0x3d,0x43,0x3d,0x44,0x40,0x43,0x3d,0x46,0x40,0x46,0x3a,0x3b, 0x35,0x3e,0x3c,0x46,0x3d,0x43,0x43,0x48,0x42,0x47,0x46,0x50,0x4a,0x4c,0x40,0x4a, 0x43,0x46,0x3f,0x4a,0x43,0x48,0x41,0x48,0x41,0x46,0x44,0x47,0x42,0x4a,0x43,0x4a, 0x43,0x48,0x41,0x46,0x41,0x47,0x41,0x47,0x44,0x44,0x42,0x47,0x42,0x46,0x3f,0x46, 0x41,0x47,0x43,0x48,0x42,0x48,0x43,0x49,0x41,0x48,0x41,0x48,0x45,0x43,0x40,0x47, 0x43,0x47,0x41,0x48,0x43,0x49,0x41,0x4a,0x41,0x49,0x41,0x47,0x3f,0x44,0x41,0x4a, 0x43,0x42,0x3f,0x48,0x41,0x47,0x42,0x4b,0x41,0x46,0x41,0x45,0x40,0x49,0x3f,0x48, 0x42,0x49,0x3e,0x4a,0x41,0x45,0x40,0x49,0x40,0x48,0x3e,0x48,0x40,0x45,0x41,0x46, 0x43,0x49,0x3f,0x48,0x3d,0x48,0x41,0x4a,0x43,0x47,0x3f,0x48,0x3f,0x46,0x40,0x4a, 0x40,0x48,0x3e,0x49,0x42,0x46,0x41,0x49,0x40,0x46,0x3f,0x47,0x42,0x4a,0x40,0x45, 0x41,0x45,0x41,0x47,0x41,0x48,0x41,0x4a,0x3e,0x49,0x3e,0x49,0x42,0x48,0x3f,0x48, 0x42,0x49,0x42,0x48,0x42,0x46,0x3f,0x48,0x42,0x48,0x43,0x49,0x42,0x49,0x40,0x4a, 0x44,0x45,0x3e,0x48,0x41,0x49,0x41,0x48,0x42,0x45,0x41,0x47,0x41,0x45,0x41,0x45, 0x40,0x48,0x3e,0x48,0x41,0x47,0x3d,0x4c,0x42,0x47,0x40,0x49,0x41,0x48,0x3f,0x4a, 0x42,0x48,0x3c,0x4c,0x43,0x45,0x3c,0x47,0x44,0x48,0x3d,0x48,0x3d,0x48,0x3e,0x49, 0x41,0x45,0x40,0x48,0x42,0x4a,0x42,0x4d,0x44,0x44,0x40,0x48,0x43,0x46,0x3f,0x4a, 0x42,0x46,0x42,0x46,0x43,0x49,0x3e,0x48,0x41,0x49,0x40,0x4c,0x43,0x45,0x41,0x47, 0x46,0x46,0x43,0x46,0x42,0x47,0x3e,0x48,0x43,0x48,0x41,0x46,0x42,0x48,0x3e,0x4b, 0x43,0x49,0x3f,0x46,0x42,0x47,0x40,0x49,0x43,0x44,0x41,0x47,0x3d,0x47,0x3e,0x4a, 0x3e,0x48,0x41,0x4b,0x42,0x44,0x40,0x4c,0x3f,0x46,0x42,0x48,0x42,0x49,0x40,0x47, 0x44,0x47,0x40,0x48,0x40,0x49,0x41,0x49,0x3f,0x49,0x40,0x46,0x41,0x4b,0x3f,0x46, 0x41,0x48,0x41,0x48,0x41,0x47,0x3c,0x48,0x45,0x45,0x3d,0x46,0x44,0x47,0x42,0x4b, 0x44,0x4a,0x40,0x48,0x42,0x47,0x42,0x4a,0x3f,0x48,0x3f,0x47,0x42,0x48,0x3c,0x4a, 0x3e,0x45,0x3f,0x48,0x46,0x49,0x3f,0x49,0x42,0x44,0x40,0x48,0x42,0x46,0x42,0x45, 0x3e,0x45,0x3f,0x4c,0x40,0x46,0x41,0x48,0x42,0x4a,0x44,0x49,0x3d,0x48,0x3f,0x48, 0x40,0x47,0x3f,0x47,0x3f,0x47,0x43,0x4a,0x42,0x49,0x41,0x44,0x42,0x49,0x3f,0x49, 0x42,0x46,0x42,0x46,0x41,0x47,0x43,0x4c,0x44,0x47,0x43,0x49,0x41,0x49,0x41,0x49, 0x41,0x45,0x41,0x46,0x44,0x45,0x41,0x47,0x40,0x47,0x3f,0x48,0x45,0x49,0x3e,0x47, 0x42,0x46,0x42,0x47,0x44,0x48,0x40,0x4b,0x43,0x47,0x40,0x49,0x42,0x49,0x42,0x45, 0x43,0x44,0x41,0x48,0x40,0x46,0x42,0x49,0x42,0x46,0x41,0x4c,0x43,0x47,0x41,0x4a, 0x43,0x46,0x40,0x47,0x42,0x47,0x3d,0x49,0x40,0x48,0x40,0x47,0x45,0x49,0x3e,0x47, 0x44,0x48,0x42,0x4b,0x44,0x4b,0x40,0x4b,0x41,0x4b,0x40,0x49,0x40,0x47,0x43,0x49, 0x42,0x47,0x42,0x4a,0x43,0x48,0x3f,0x4a,0x43,0x48,0x3f,0x4b,0x44,0x4a,0x40,0x48, 0x43,0x47,0x42,0x47,0x45,0x4a,0x42,0x4c,0x43,0x47,0x41,0x46,0x45,0x4d,0x41,0x49, 0x41,0x49,0x43,0x49,0x44,0x4a,0x42,0x4a,0x40,0x49,0x3e,0x49,0x44,0x4c,0x42,0x4a, 0x44,0x47,0x40,0x4a,0x42,0x49,0x43,0x4f,0x41,0x49,0x42,0x49,0x44,0x49,0x42,0x48, 0x46,0x48,0x40,0x4a,0x41,0x48,0x41,0x4b,0x43,0x45,0x3f,0x4a,0x3e,0x4b,0x3e,0x4b, 0x44,0x48,0x42,0x48,0x44,0x47,0x43,0x48,0x43,0x4b,0x40,0x49,0x45,0x47,0x42,0x4a, 0x45,0x45,0x40,0x45,0x42,0x4a,0x3f,0x48,0x42,0x48,0x43,0x48,0x41,0x4a,0x3d,0x4a, 0x40,0x48,0x3f,0x44,0x43,0x4c,0x42,0x47,0x43,0x47,0x42,0x49,0x41,0x4a,0x3e,0x4a, 0x40,0x48,0x43,0x46,0x40,0x49,0x42,0x49,0x43,0x47,0x42,0x48,0x42,0x4c,0x3f,0x4a, 0x41,0x49,0x3f,0x46,0x3f,0x48,0x42,0x4b,0x44,0x48,0x44,0x48,0x43,0x48,0x41,0x4a, 0x42,0x45,0x40,0x48,0x43,0x4a,0x42,0x4b,0x40,0x49,0x41,0x47,0x42,0x4b,0x41,0x48, 0x42,0x48,0x3d,0x4a,0x41,0x48,0x42,0x48,0x41,0x45,0x43,0x48,0x43,0x4a,0x40,0x4a, 0x44,0x49,0x43,0x48,0x40,0x4c,0x40,0x4c,0x43,0x46,0x42,0x4a,0x46,0x48,0x41,0x47, 0x42,0x48,0x41,0x49,0x44,0x47,0x41,0x49,0x42,0x4b,0x42,0x45,0x41,0x49,0x3f,0x49, 0x43,0x47,0x3e,0x4a,0x43,0x46,0x42,0x4b,0x44,0x46,0x42,0x48,0x42,0x47,0x3e,0x4a, 0x40,0x4a,0x40,0x47,0x42,0x4c,0x43,0x47,0x43,0x47,0x40,0x47,0x43,0x48,0x40,0x48, 0x45,0x49,0x42,0x47,0x41,0x47,0x41,0x49,0x43,0x49,0x3f,0x48,0x41,0x4a,0x3c,0x4a, 0x40,0x49,0x3e,0x46,0x40,0x47,0x42,0x4c,0x40,0x46,0x41,0x47,0x42,0x4a,0x40,0x4e, 0x44,0x47,0x41,0x47,0x42,0x48,0x42,0x4b,0x42,0x44,0x40,0x46,0x43,0x47,0x41,0x4a, 0x41,0x49,0x3f,0x4a,0x41,0x49,0x43,0x4b,0x40,0x4a,0x41,0x46,0x42,0x47,0x41,0x47, 0x42,0x49,0x44,0x4a,0x3e,0x4a,0x40,0x49,0x41,0x44,0x41,0x49,0x42,0x4a,0x42,0x4b, 0x41,0x46,0x40,0x44,0x42,0x49,0x40,0x48,0x41,0x47,0x3e,0x48,0x41,0x49,0x44,0x48, 0x3f,0x49,0x45,0x49,0x44,0x49,0x42,0x4d,0x41,0x48,0x40,0x48,0x40,0x48,0x40,0x4b, 0x43,0x48,0x41,0x46,0x41,0x47,0x3f,0x4b,0x44,0x48,0x42,0x45,0x42,0x4b,0x42,0x4a, 0x43,0x47,0x3e,0x45,0x44,0x49,0x45,0x49,0x40,0x49,0x3f,0x48,0x3f,0x47,0x40,0x48, 0x42,0x4c,0x40,0x47,0x42,0x46,0x42,0x49,0x43,0x44,0x41,0x47,0x45,0x48,0x42,0x48, 0x40,0x46,0x3f,0x48,0x45,0x4a,0x40,0x4c,0x42,0x4a,0x42,0x49,0x42,0x4a,0x40,0x4b, 0x42,0x49,0x3e,0x47,0x45,0x4c,0x3b,0x42,0x3b,0x42,0x41,0x46,0x47,0x47,0x47,0x44, 0x40,0x45,0x42,0x4d,0x42,0x4d,0x42,0x49,0x43,0x46,0x3f,0x43,0x3f,0x45,0x40,0x47, 0x3e,0x43,0x3f,0x45,0x40,0x49,0x3e,0x48,0x3f,0x48,0x42,0x45,0x42,0x48,0x3d,0x4c, 0x41,0x46,0x3d,0x47,0x3f,0x46,0x3f,0x46,0x42,0x42,0x3e,0x45,0x3f,0x49,0x3e,0x47, 0x3f,0x4a,0x3d,0x46,0x3e,0x45,0x3e,0x48,0x41,0x45,0x3f,0x45,0x41,0x48,0x3e,0x4a, 0x41,0x47,0x3e,0x48,0x42,0x4a,0x3e,0x47,0x41,0x44,0x42,0x44,0x43,0x47,0x3f,0x47, 0x40,0x49,0x3f,0x45,0x42,0x48,0x3e,0x48,0x41,0x45,0x3f,0x48,0x41,0x48,0x3b,0x4a, 0x41,0x45,0x42,0x42,0x40,0x44,0x40,0x4a,0x3e,0x47,0x40,0x43,0x3f,0x48,0x3c,0x45, 0x41,0x48,0x40,0x46,0x3f,0x47,0x40,0x47,0x40,0x44,0x3e,0x44,0x42,0x49,0x3f,0x48, 0x42,0x47,0x3d,0x47,0x40,0x45,0x40,0x47,0x40,0x47,0x3d,0x45,0x42,0x49,0x3f,0x48, 0x42,0x45,0x3e,0x44,0x3f,0x46,0x3c,0x49,0x40,0x43,0x3e,0x47,0x3f,0x47,0x3d,0x4c, 0x3e,0x48,0x40,0x45,0x3c,0x47,0x3d,0x48,0x40,0x43,0x3d,0x43,0x41,0x48,0x40,0x4a, 0x41,0x45,0x3e,0x45,0x3f,0x48,0x40,0x49,0x3f,0x48,0x3e,0x48,0x3e,0x49,0x40,0x49, 0x40,0x45,0x40,0x48,0x41,0x46,0x44,0x49,0x41,0x48,0x40,0x48,0x3d,0x45,0x3d,0x47, 0x40,0x46,0x3f,0x49,0x45,0x4a,0x3e,0x4b,0x40,0x47,0x40,0x47,0x41,0x46,0x42,0x49, 0x40,0x46,0x40,0x45,0x42,0x46,0x3e,0x4a,0x40,0x43,0x41,0x44,0x41,0x45,0x3f,0x44, 0x40,0x44,0x40,0x4b,0x43,0x48,0x40,0x4b,0x42,0x47,0x41,0x47,0x42,0x48,0x41,0x47, 0x40,0x46,0x40,0x48,0x3f,0x49,0x3c,0x48,0x3e,0x47,0x3e,0x45,0x3f,0x48,0x3f,0x48, 0x3f,0x44,0x40,0x47,0x40,0x4a,0x41,0x48,0x43,0x44,0x3f,0x43,0x41,0x48,0x41,0x4b, 0x3f,0x45,0x3e,0x44,0x3d,0x46,0x3d,0x47,0x40,0x46,0x3d,0x47,0x3e,0x4a,0x3f,0x4b, 0x40,0x44,0x41,0x44,0x43,0x47,0x3f,0x4c,0x40,0x49,0x40,0x44,0x40,0x46,0x3f,0x47, 0x3f,0x46,0x43,0x46,0x44,0x49,0x3b,0x46,0x45,0x47,0x40,0x46,0x43,0x47,0x40,0x48, 0x3f,0x46,0x3e,0x48,0x41,0x49,0x41,0x4b,0x41,0x45,0x3f,0x44,0x40,0x46,0x3f,0x49, 0x40,0x46,0x40,0x43,0x3f,0x4a,0x3f,0x47,0x42,0x44,0x3e,0x46,0x40,0x49,0x3f,0x48, 0x42,0x47,0x3d,0x44,0x40,0x48,0x3d,0x49,0x42,0x46,0x3d,0x47,0x3d,0x47,0x3e,0x49, 0x42,0x43,0x3e,0x45,0x41,0x47,0x3f,0x45,0x44,0x46,0x40,0x46,0x40,0x45,0x3f,0x46, 0x41,0x45,0x3f,0x42,0x41,0x46,0x3f,0x4b,0x41,0x48,0x3f,0x44,0x3f,0x46,0x3f,0x47, 0x41,0x45,0x3e,0x46,0x3f,0x4a,0x3f,0x49,0x3e,0x43,0x40,0x45,0x3e,0x47,0x3f,0x4a, 0x40,0x44,0x40,0x46,0x3d,0x4a,0x3d,0x48,0x3f,0x47,0x41,0x44,0x41,0x47,0x3d,0x49, 0x3e,0x47,0x3f,0x45,0x3f,0x4a,0x3d,0x48,0x3e,0x46,0x3d,0x45,0x40,0x45,0x3f,0x49, 0x40,0x46,0x3c,0x43,0x40,0x47,0x43,0x49,0x44,0x46,0x40,0x48,0x3e,0x48,0x3c,0x4b, 0x3d,0x47,0x40,0x47,0x40,0x47,0x40,0x49,0x42,0x48,0x3d,0x47,0x40,0x47,0x3f,0x48, 0x43,0x47,0x3f,0x46,0x41,0x47,0x3f,0x4a,0x44,0x43,0x41,0x45,0x43,0x47,0x42,0x47, 0x40,0x48,0x40,0x47,0x41,0x49,0x41,0x4b,0x40,0x43,0x3c,0x46,0x43,0x48,0x40,0x48, 0x40,0x48,0x3c,0x45,0x40,0x46,0x42,0x49,0x41,0x47,0x3f,0x49,0x41,0x48,0x40,0x4a, 0x41,0x45,0x40,0x47,0x41,0x49,0x41,0x4b,0x3f,0x47,0x41,0x46,0x41,0x48,0x41,0x4a, 0x42,0x46,0x40,0x47,0x40,0x49,0x3e,0x48,0x3f,0x47,0x3f,0x44,0x42,0x46,0x3e,0x48, 0x40,0x46,0x3f,0x4c,0x41,0x49,0x3f,0x4d,0x41,0x48,0x40,0x4a,0x43,0x46,0x3f,0x4a, 0x40,0x49,0x3f,0x48,0x40,0x48,0x3e,0x4b,0x42,0x45,0x3f,0x45,0x45,0x47,0x42,0x46, 0x44,0x45,0x3f,0x45,0x3e,0x4a,0x40,0x4c,0x3f,0x46,0x43,0x48,0x41,0x48,0x3f,0x4a, 0x41,0x48,0x3f,0x46,0x42,0x4a,0x43,0x4a,0x42,0x49,0x42,0x47,0x41,0x49,0x41,0x4b, 0x41,0x44,0x40,0x48,0x40,0x48,0x40,0x48,0x3f,0x48,0x3b,0x46,0x42,0x4b,0x40,0x4b, 0x3f,0x46,0x40,0x47,0x44,0x46,0x3f,0x49,0x43,0x48,0x41,0x48,0x42,0x4c,0x3f,0x49, 0x43,0x47,0x42,0x46,0x45,0x46,0x3f,0x47,0x3f,0x48,0x43,0x48,0x41,0x46,0x3d,0x47, 0x3f,0x48,0x3e,0x46,0x42,0x45,0x40,0x48,0x3f,0x47,0x3f,0x4b,0x41,0x46,0x3e,0x49, 0x41,0x47,0x41,0x4c,0x3e,0x47,0x41,0x4a,0x42,0x46,0x41,0x48,0x3f,0x48,0x3f,0x48, 0x43,0x47,0x41,0x47,0x42,0x4a,0x3e,0x49,0x42,0x46,0x3f,0x47,0x40,0x47,0x3f,0x48, 0x42,0x44,0x42,0x46,0x40,0x46,0x3c,0x4b,0x3f,0x46,0x43,0x47,0x40,0x4b,0x3f,0x4b, 0x42,0x47,0x3e,0x44,0x46,0x46,0x42,0x49,0x40,0x47,0x42,0x48,0x3f,0x46,0x3f,0x48, 0x41,0x46,0x3e,0x48,0x3e,0x4b,0x40,0x46,0x41,0x43,0x41,0x47,0x42,0x45,0x3e,0x48, 0x42,0x48,0x42,0x44,0x43,0x47,0x3f,0x47,0x40,0x46,0x42,0x46,0x42,0x46,0x3f,0x4a, 0x41,0x44,0x3e,0x47,0x41,0x44,0x41,0x46,0x41,0x46,0x3e,0x47,0x41,0x49,0x40,0x48, 0x42,0x48,0x3e,0x47,0x41,0x48,0x40,0x44,0x40,0x43,0x3f,0x48,0x3f,0x46,0x41,0x48, 0x41,0x45,0x3b,0x49,0x44,0x47,0x3d,0x48,0x41,0x46,0x3e,0x47,0x3f,0x48,0x3f,0x49, 0x40,0x46,0x3f,0x49,0x40,0x47,0x41,0x45,0x43,0x46,0x3e,0x45,0x42,0x4a,0x40,0x49, 0x43,0x46,0x42,0x47,0x42,0x47,0x40,0x4a,0x41,0x47,0x40,0x49,0x42,0x48,0x40,0x4b, 0x42,0x44,0x3e,0x47,0x41,0x46,0x41,0x47,0x44,0x48,0x3f,0x48,0x40,0x46,0x42,0x4a, 0x42,0x45,0x43,0x47,0x44,0x48,0x3e,0x4a,0x43,0x46,0x40,0x4a,0x40,0x45,0x41,0x46, 0x41,0x46,0x3e,0x46,0x42,0x45,0x42,0x48,0x42,0x46,0x41,0x4b,0x42,0x4d,0x3d,0x40, 0x39,0x43,0x3c,0x47,0x41,0x45,0x44,0x41,0x3c,0x40,0x43,0x4e,0x43,0x45,0x3d,0x46, 0x3c,0x44,0x3a,0x43,0x3e,0x40,0x39,0x45,0x3e,0x41,0x39,0x44,0x3d,0x43,0x41,0x45, 0x3d,0x42,0x3a,0x41,0x3a,0x42,0x3c,0x42,0x3d,0x43,0x3a,0x44,0x3b,0x46,0x3a,0x46, 0x3b,0x43,0x3c,0x45,0x3c,0x41,0x3c,0x41,0x3b,0x3e,0x39,0x41,0x3a,0x40,0x3a,0x46, 0x3b,0x42,0x3a,0x42,0x3c,0x42,0x39,0x43,0x3b,0x43,0x3e,0x41,0x3c,0x3f,0x3e,0x43, 0x3b,0x42,0x3a,0x43,0x3e,0x43,0x3c,0x43,0x3e,0x43,0x3b,0x43,0x3c,0x40,0x3e,0x45, 0x3b,0x43,0x3b,0x43,0x3e,0x41,0x3b,0x47,0x3a,0x46,0x3a,0x43,0x3b,0x44,0x3d,0x48, 0x3c,0x42,0x3c,0x40,0x40,0x42,0x37,0x42,0x3d,0x41,0x3b,0x47,0x3f,0x44,0x3c,0x42, 0x3b,0x43,0x39,0x44,0x39,0x43,0x3b,0x44,0x3b,0x42,0x38,0x46,0x3b,0x40,0x3c,0x42, 0x3b,0x45,0x3b,0x41,0x3b,0x43,0x3c,0x43,0x3d,0x42,0x3d,0x42,0x3d,0x3f,0x39,0x45, 0x3b,0x43,0x3b,0x44,0x39,0x44,0x3a,0x44,0x3a,0x44,0x3c,0x42,0x3a,0x42,0x3b,0x47, 0x3e,0x42,0x3a,0x44,0x3c,0x41,0x3a,0x48,0x3d,0x3d,0x3d,0x44,0x3d,0x42,0x3d,0x44, 0x3b,0x44,0x3c,0x43,0x39,0x41,0x3c,0x42,0x3d,0x43,0x3d,0x40,0x3a,0x40,0x3d,0x42, 0x3e,0x44,0x38,0x45,0x3e,0x3f,0x3c,0x45,0x3c,0x41,0x3d,0x44,0x3c,0x42,0x3b,0x43, 0x3d,0x43,0x3b,0x45,0x3c,0x41,0x38,0x44,0x3a,0x42,0x38,0x42,0x3a,0x43,0x3c,0x49, 0x3c,0x42,0x39,0x44,0x3b,0x44,0x37,0x44,0x3b,0x44,0x3a,0x44,0x3d,0x43,0x38,0x45, 0x3b,0x44,0x37,0x42,0x39,0x40,0x3a,0x43,0x3b,0x41,0x3c,0x41,0x3d,0x40,0x39,0x43, 0x40,0x44,0x38,0x43,0x3b,0x42,0x3b,0x44,0x3e,0x41,0x3d,0x44,0x3c,0x44,0x3b,0x45, 0x3b,0x44,0x3b,0x43,0x3e,0x43,0x3d,0x41,0x3d,0x40,0x3c,0x43,0x3a,0x45,0x3e,0x43, 0x3c,0x42,0x3b,0x42,0x3d,0x44,0x3e,0x47,0x3c,0x41,0x3c,0x43,0x3a,0x44,0x39,0x43, 0x3f,0x3f,0x3a,0x43,0x3e,0x40,0x3a,0x46,0x3b,0x41,0x39,0x44,0x3a,0x42,0x3a,0x45, 0x3e,0x40,0x3c,0x41,0x3b,0x41,0x3d,0x45,0x3e,0x44,0x39,0x43,0x3c,0x42,0x3c,0x45, 0x3b,0x43,0x3d,0x44,0x3b,0x43,0x3a,0x43,0x3e,0x3f,0x3d,0x42,0x3d,0x44,0x39,0x47, 0x3f,0x44,0x3c,0x42,0x3d,0x45,0x3b,0x43,0x3c,0x3e,0x3d,0x43,0x3f,0x44,0x3b,0x44, 0x3a,0x44,0x3e,0x42,0x3c,0x41,0x3a,0x43,0x3e,0x3e,0x3c,0x44,0x3d,0x44,0x3d,0x47, 0x3e,0x41,0x3a,0x45,0x3d,0x41,0x3d,0x43,0x3b,0x45,0x39,0x42,0x3b,0x45,0x39,0x45, 0x39,0x44,0x3f,0x44,0x3b,0x43,0x3b,0x44,0x3d,0x47,0x38,0x43,0x3e,0x42,0x3b,0x45, 0x3e,0x43,0x38,0x43,0x40,0x41,0x39,0x41,0x3e,0x43,0x36,0x42,0x3b,0x44,0x3c,0x41, 0x3b,0x43,0x3c,0x43,0x3b,0x40,0x3d,0x44,0x3c,0x43,0x3a,0x45,0x3d,0x42,0x38,0x44, 0x39,0x41,0x3a,0x42,0x3c,0x45,0x3a,0x47,0x3d,0x43,0x39,0x41,0x3f,0x41,0x3d,0x46, 0x3e,0x45,0x39,0x45,0x3b,0x41,0x3c,0x45,0x3f,0x44,0x3a,0x44,0x41,0x44,0x3b,0x46, 0x3f,0x43,0x3d,0x43,0x3d,0x43,0x3e,0x45,0x3d,0x46,0x3b,0x44,0x3f,0x43,0x3c,0x46, 0x3e,0x42,0x3a,0x42,0x3b,0x44,0x3a,0x47,0x3d,0x42,0x3d,0x45,0x39,0x42,0x38,0x46, 0x3c,0x44,0x3a,0x48,0x3e,0x42,0x3a,0x48,0x40,0x44,0x3c,0x43,0x3c,0x44,0x3b,0x42, 0x40,0x41,0x3a,0x44,0x3f,0x42,0x3e,0x45,0x3d,0x44,0x3b,0x42,0x3e,0x46,0x3b,0x44, 0x40,0x42,0x3a,0x45,0x3f,0x45,0x3b,0x44,0x3b,0x41,0x3c,0x44,0x3c,0x45,0x3a,0x45, 0x3c,0x44,0x39,0x43,0x3c,0x44,0x3a,0x44,0x3d,0x43,0x37,0x45,0x3c,0x43,0x3c,0x41, 0x3b,0x42,0x39,0x44,0x3d,0x45,0x3a,0x44,0x3d,0x43,0x40,0x42,0x3c,0x43,0x3d,0x44, 0x3b,0x42,0x3a,0x42,0x3e,0x44,0x3b,0x47,0x3b,0x41,0x3b,0x43,0x3b,0x42,0x3d,0x45, 0x3b,0x40,0x3c,0x43,0x40,0x43,0x3c,0x43,0x3f,0x42,0x3d,0x42,0x40,0x44,0x3a,0x44, 0x40,0x41,0x3e,0x47,0x3c,0x40,0x3e,0x44,0x40,0x44,0x3f,0x46,0x3b,0x44,0x3d,0x43, 0x3f,0x44,0x3d,0x47,0x42,0x43,0x39,0x46,0x3d,0x41,0x3b,0x44,0x3e,0x43,0x38,0x44, 0x3f,0x45,0x3d,0x46,0x3e,0x42,0x3d,0x43,0x3c,0x43,0x3a,0x45,0x3b,0x46,0x3c,0x48, 0x39,0x45,0x3c,0x45,0x39,0x41,0x3b,0x45,0x3d,0x43,0x3d,0x45,0x3e,0x42,0x3c,0x45, 0x3d,0x43,0x3b,0x45,0x3e,0x42,0x3e,0x41,0x3c,0x42,0x39,0x48,0x3e,0x46,0x3a,0x43, 0x3e,0x45,0x3a,0x46,0x3a,0x41,0x3c,0x46,0x3f,0x42,0x3b,0x44,0x3c,0x46,0x3a,0x47, 0x3a,0x44,0x3a,0x43,0x3e,0x45,0x39,0x44,0x3c,0x42,0x3a,0x44,0x3d,0x45,0x3b,0x47, 0x3c,0x43,0x3b,0x44,0x3a,0x44,0x3c,0x41,0x3e,0x43,0x3c,0x43,0x3c,0x41,0x3d,0x47, 0x3b,0x44,0x3e,0x41,0x3e,0x46,0x3c,0x43,0x3f,0x45,0x3a,0x43,0x3a,0x46,0x3b,0x46, 0x3f,0x42,0x3a,0x44,0x3b,0x47,0x3a,0x47,0x3b,0x41,0x3c,0x42,0x3e,0x44,0x3b,0x45, 0x3e,0x40,0x3b,0x42,0x3d,0x45,0x3d,0x48,0x3b,0x42,0x3a,0x43,0x3d,0x46,0x38,0x42, 0x3f,0x43,0x3d,0x40,0x3c,0x47,0x3b,0x47,0x3c,0x40,0x3d,0x42,0x3d,0x42,0x3d,0x46, 0x3c,0x41,0x3d,0x42,0x3c,0x43,0x3e,0x44,0x3d,0x3f,0x3c,0x42,0x37,0x47,0x3b,0x47, 0x3c,0x44,0x3d,0x44,0x3f,0x43,0x3d,0x44,0x3c,0x42,0x3a,0x44,0x3e,0x44,0x3c,0x45, 0x3b,0x44,0x3c,0x42,0x3b,0x44,0x3a,0x47,0x3c,0x45,0x38,0x42,0x3d,0x43,0x3c,0x46, 0x3e,0x41,0x3e,0x43,0x3a,0x44,0x37,0x46,0x3c,0x45,0x39,0x43,0x3c,0x47,0x3a,0x48, 0x3b,0x43,0x3c,0x44,0x3d,0x44,0x3e,0x48,0x3b,0x43,0x3a,0x44,0x3c,0x43,0x3a,0x48, 0x3b,0x41,0x3c,0x43,0x3d,0x45,0x38,0x48,0x3a,0x42,0x3f,0x43,0x3c,0x48,0x3b,0x48, 0x3c,0x40,0x3b,0x44,0x41,0x47,0x3a,0x3d,0x32,0x3e,0x3d,0x41,0x3e,0x43,0x41,0x48, 0x3f,0x46,0x48,0x52,0x4b,0x4e,0x45,0x4d,0x43,0x47,0x41,0x4a,0x45,0x4b,0x43,0x4a, 0x47,0x4b,0x43,0x47,0x41,0x4a,0x43,0x49,0x41,0x47,0x41,0x48,0x45,0x4b,0x46,0x4c, 0x43,0x47,0x45,0x49,0x41,0x4b,0x40,0x4d,0x47,0x47,0x43,0x49,0x44,0x49,0x42,0x4c, 0x42,0x46,0x40,0x48,0x43,0x4c,0x42,0x4c,0x41,0x4a,0x45,0x48,0x43,0x4b,0x42,0x4b, 0x43,0x4a,0x42,0x48,0x41,0x4a,0x44,0x4b,0x44,0x47,0x41,0x45,0x42,0x4b,0x40,0x4b, 0x43,0x4a,0x43,0x4a,0x44,0x4e,0x42,0x49,0x41,0x49,0x43,0x47,0x43,0x49,0x44,0x4d, 0x47,0x48,0x42,0x49,0x45,0x4a,0x41,0x49,0x45,0x48,0x3e,0x49,0x42,0x4b,0x44,0x4b, 0x42,0x4a,0x42,0x49,0x42,0x49,0x42,0x4c,0x46,0x48,0x42,0x45,0x44,0x4b,0x41,0x4f, 0x46,0x4a,0x43,0x4a,0x45,0x49,0x43,0x4a,0x43,0x48,0x42,0x45,0x44,0x4a,0x40,0x4c, 0x43,0x47,0x42,0x49,0x43,0x4a,0x45,0x4d,0x44,0x48,0x42,0x4b,0x41,0x4a,0x44,0x4d, 0x40,0x49,0x43,0x4c,0x45,0x47,0x42,0x4b,0x43,0x48,0x41,0x49,0x43,0x4a,0x43,0x49, 0x45,0x4a,0x43,0x49,0x40,0x4b,0x40,0x4c,0x43,0x4a,0x41,0x4b,0x42,0x48,0x3f,0x4d, 0x43,0x4b,0x41,0x4c,0x45,0x4a,0x42,0x4d,0x43,0x49,0x43,0x46,0x43,0x4b,0x44,0x4b, 0x44,0x49,0x45,0x49,0x41,0x47,0x41,0x4c,0x43,0x4b,0x42,0x4a,0x43,0x48,0x44,0x4d, 0x42,0x49,0x43,0x4a,0x43,0x4c,0x42,0x50,0x43,0x4b,0x44,0x49,0x45,0x4c,0x42,0x4a, 0x43,0x47,0x41,0x4a,0x43,0x4b,0x41,0x4b,0x42,0x46,0x43,0x48,0x40,0x4c,0x3e,0x4d, 0x44,0x47,0x41,0x4d,0x43,0x4c,0x41,0x4d,0x00,0x22,0x80,0x09,0x00,0x10,0x00,0x01, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xb6,0x48,0xb4,0x52,0xb6,0x4a,0xb7,0x56,0xba,0x48,0xbe,0x56,0xc1,0x49, 0xc4,0x50,0xc3,0x48,0xc3,0x4f,0xc1,0x4b,0xc0,0x4e,0xba,0x50,0xb8,0x52,0xb8,0x49, 0xb8,0x4f,0xb9,0x46,0xba,0x4f,0xbe,0x4c,0xc1,0x52,0xc4,0x4a,0xc8,0x51,0xc6,0x44, 0xc6,0x52,0xc7,0x4c,0xc5,0x4f,0xbe,0x49,0xbd,0x53,0xba,0x4b,0xbd,0x4f,0xbb,0x4a, 0xbc,0x51,0xbf,0x48,0xc6,0x4d,0xc7,0x4c,0xc9,0x53,0xcb,0x47,0xcb,0x50,0xcb,0x48, 0xc7,0x51,0xc4,0x4a,0xc1,0x4e,0xbd,0x47,0xbb,0x4d,0xbb,0x43,0xbf,0x56,0xc0,0x49, 0xc4,0x50,0xca,0x4b,0xcc,0x4f,0xcd,0x4b,0xce,0x54,0xcd,0x4c,0xc9,0x4d,0xc7,0x47, 0xc4,0x51,0xc2,0x47,0xc1,0x4c,0xc2,0x48,0xc2,0x50,0xc5,0x49,0xca,0x4f,0xcb,0x4a, 0xcf,0x4e,0xcf,0x4d,0xd1,0x4e,0xcf,0x4a,0xcc,0x53,0xc8,0x49,0xc4,0x55,0xc2,0x4b, 0xc2,0x51,0xc0,0x46,0xc3,0x4f,0xc4,0x4b,0xc7,0x4f,0xcb,0x4a,0xcd,0x50,0xcd,0x46, 0xd0,0x51,0xcf,0x4c,0xcd,0x4e,0xc9,0x4c,0xc3,0x50,0xc1,0x49,0xc1,0x4d,0xbf,0x47, 0xbf,0x53,0xc1,0x49,0xc3,0x4a,0xc6,0x49,0xc8,0x54,0xcb,0x48,0xca,0x4e,0xc9,0x45, 0xc8,0x51,0xc5,0x4a,0xc0,0x50,0xbe,0x44,0xbd,0x4f,0xbc,0x4b,0xbb,0x51,0xbd,0x49, 0xc0,0x50,0xc3,0x4b,0xc6,0x52,0xc7,0x48,0xc9,0x54,0xc8,0x46,0xc6,0x51,0xc3,0x49, 0xbf,0x51,0xbd,0x48,0xbb,0x4d,0xbb,0x4a,0xba,0x53,0xba,0x4a,0xbd,0x53,0xc2,0x4b, 0xc4,0x55,0xc7,0x49,0xc9,0x4e,0xc8,0x49,0xc6,0x4f,0xc4,0x4e,0xc0,0x51,0xbc,0x46, 0xba,0x52,0xba,0x4b,0xbb,0x4e,0xbb,0x45,0xbd,0x52,0xc1,0x4b,0xc3,0x54,0xc6,0x48, 0xc8,0x55,0xc8,0x47,0xc7,0x4f,0xc5,0x45,0xc0,0x51,0xbc,0x47,0xbc,0x4d,0xba,0x48, 0xba,0x50,0xb9,0x48,0xbd,0x4f,0xbf,0x45,0xc1,0x51,0xc5,0x47,0xc7,0x52,0xc6,0x46, 0xc7,0x4e,0xc4,0x4b,0xc0,0x53,0xbb,0x49,0xba,0x51,0xb9,0x4a,0xb7,0x4f,0xb9,0x48, 0xbc,0x4f,0xbe,0x4b,0xc1,0x53,0xc4,0x4d,0xc7,0x53,0xc6,0x49,0xc6,0x50,0xc4,0x47, 0xc2,0x4d,0xbd,0x4a,0xbc,0x4c,0xba,0x48,0xba,0x53,0xba,0x45,0xbb,0x50,0xbe,0x46, 0xc0,0x53,0xc3,0x46,0xc6,0x51,0xc5,0x48,0xc5,0x53,0xc3,0x48,0xc1,0x4e,0xbd,0x44, 0xbd,0x4f,0xbb,0x4c,0xbb,0x4e,0xba,0x49,0xbb,0x51,0xbc,0x46,0xc0,0x51,0xc4,0x49, 0xc7,0x50,0xc8,0x48,0xc8,0x4d,0xc5,0x46,0xc3,0x54,0xbf,0x49,0xbc,0x50,0xbb,0x4c, 0xbb,0x52,0xba,0x4f,0xbb,0x53,0xbd,0x4a,0xc0,0x53,0xc4,0x49,0xc6,0x4f,0xc8,0x49, 0xc8,0x53,0xc6,0x4b,0xc3,0x50,0xc0,0x4d,0xbd,0x54,0xbc,0x4d,0xb9,0x52,0xba,0x4a, 0xbb,0x54,0xbe,0x49,0xc2,0x4b,0xc4,0x47,0xc6,0x55,0xc6,0x47,0xc8,0x51,0xc6,0x4a, 0xc2,0x52,0xbe,0x4b,0xbd,0x4a,0xbb,0x49,0xb9,0x53,0xb9,0x49,0xb9,0x52,0xbd,0x4c, 0xc1,0x52,0xc4,0x49,0xc8,0x4e,0xc9,0x48,0xc8,0x50,0xc9,0x4a,0xc5,0x4f,0xc1,0x47, 0xbe,0x53,0xbc,0x4c,0xbb,0x51,0xba,0x45,0xbb,0x54,0xbc,0x4a,0xbe,0x51,0xc2,0x4b, 0xc5,0x50,0xc7,0x4a,0xc7,0x53,0xc7,0x46,0xc5,0x53,0xc1,0x4d,0xbe,0x52,0xba,0x48, 0xba,0x54,0xb8,0x45,0xb8,0x4f,0xba,0x4a,0xbe,0x56,0xc0,0x48,0xc4,0x52,0xc7,0x4a, 0xc6,0x54,0xc6,0x4b,0xc3,0x50,0xbf,0x49,0xbd,0x51,0xbb,0x4e,0xb9,0x4d,0xb8,0x49, 0xb9,0x51,0xba,0x47,0xbc,0x50,0xc1,0x48,0xc4,0x51,0xc7,0x48,0xc6,0x51,0xc5,0x4a, 0xc4,0x52,0xc1,0x49,0xbc,0x51,0xb8,0x47,0xb8,0x52,0xb7,0x4b,0xb7,0x55,0xb8,0x47, 0xba,0x50,0xbe,0x48,0xc0,0x50,0xc2,0x4a,0xc6,0x52,0xc2,0x4a,0xc4,0x51,0xbe,0x48, 0xc0,0x4f,0xb7,0x47,0xb7,0x4e,0xb6,0x46,0xb6,0x54,0xb7,0x47,0xba,0x4e,0xba,0x46, 0xbf,0x53,0xc2,0x4a,0xc4,0x4f,0xc3,0x44,0xc1,0x55,0xc0,0x4a,0xbb,0x50,0xb8,0x4a, 0xb6,0x52,0xb6,0x4e,0xb6,0x51,0xb6,0x45,0xb6,0x51,0xb9,0x4c,0xc1,0x4f,0xc3,0x48, 0xc1,0x51,0xc3,0x48,0xc5,0x4d,0xc1,0x45,0xbd,0x4e,0xb6,0x47,0xb7,0x4c,0xb7,0x4c, 0xb3,0x51,0xb3,0x47,0xb7,0x4e,0xbb,0x4c,0xbe,0x51,0xc0,0x46,0xc1,0x51,0xc3,0x49, 0xc2,0x52,0xbe,0x45,0xbb,0x51,0xb8,0x4c,0xb6,0x52,0xb4,0x47,0xb4,0x53,0xb5,0x48, 0xb4,0x52,0xba,0x49,0xbd,0x4d,0xbe,0x47,0xc1,0x54,0xc4,0x49,0xc2,0x4f,0xbf,0x45, 0xbb,0x4f,0xb7,0x47,0xb5,0x53,0xb4,0x48,0xb4,0x58,0xb5,0x46,0xb7,0x53,0xb8,0x49, 0xbf,0x4f,0xc2,0x49,0xc3,0x50,0xc2,0x49,0xc4,0x53,0xc2,0x49,0xbc,0x51,0xb9,0x48, 0xb7,0x52,0xb5,0x4a,0xb4,0x4f,0xb5,0x47,0xb7,0x51,0xb8,0x44,0xbe,0x4f,0xbf,0x4b, 0xc2,0x4c,0xc3,0x48,0xc3,0x51,0xc1,0x49,0xbe,0x56,0xbb,0x49,0xb8,0x4d,0xb6,0x4a, 0xb7,0x4e,0xb7,0x4b,0xb7,0x4c,0xb9,0x4a,0xbc,0x54,0xc0,0x49,0xc3,0x53,0xc3,0x45, 0xc3,0x4e,0xc2,0x4a,0xbf,0x50,0xbb,0x47,0xb7,0x54,0xb5,0x48,0xb6,0x53,0xb5,0x49, 0xb5,0x4c,0xb5,0x47,0xbb,0x4c,0xbd,0x47,0xbf,0x51,0xc1,0x49,0xc1,0x4e,0xc0,0x48, 0xbd,0x54,0xba,0x45,0xb7,0x4f,0xb4,0x46,0xb3,0x52,0xb6,0x42,0xb6,0x52,0xb7,0x47, 0xb9,0x55,0xbe,0x47,0xc0,0x4f,0xc2,0x4b,0xc1,0x51,0xc1,0x4a,0xbe,0x50,0xbb,0x49, 0xb7,0x4e,0xb4,0x45,0xb4,0x4a,0xb3,0x3f,0xb3,0x4e,0xb5,0x48,0xb8,0x50,0xbc,0x49, 0xc0,0x54,0xbe,0x4e,0xc6,0x35,0xc3,0x32,0xc2,0x37,0xbe,0x30,0xbc,0x3f,0xb9,0x34, 0xb9,0x3b,0xb9,0x33,0xba,0x33,0xbc,0x2e,0xbf,0x36,0xc0,0x30,0xc3,0x38,0xc5,0x2f, 0xc4,0x34,0xc3,0x2f,0xc0,0x35,0xbd,0x2d,0xb9,0x35,0xb8,0x2d,0xb7,0x36,0xb8,0x2e, 0xb8,0x34,0xb9,0x32,0xbb,0x38,0xc0,0x2e,0xc1,0x38,0xc3,0x2c,0xc3,0x38,0xc2,0x2d, 0xc0,0x36,0xbf,0x2d,0xb7,0x33,0xb6,0x31,0xb6,0x35,0xb7,0x2a,0xb7,0x39,0xb7,0x2a, 0xbb,0x36,0xbf,0x2d,0xc0,0x36,0xc2,0x2c,0xc2,0x36,0xc1,0x2e,0xbe,0x37,0xbb,0x2d, 0xb7,0x35,0xb7,0x2c,0xb5,0x31,0xb5,0x2f,0xb6,0x35,0xb7,0x2b,0xb8,0x35,0xbc,0x2d, 0xbd,0x30,0xbf,0x2d,0xc0,0x38,0xbf,0x2d,0xbb,0x36,0xb9,0x30,0xb5,0x35,0xb5,0x2d, 0xb3,0x37,0xb3,0x2a,0xb3,0x32,0xb4,0x2e,0xb6,0x39,0xbb,0x2e,0xbc,0x32,0xbe,0x2f, 0xc2,0x37,0xbf,0x31,0xbc,0x31,0xbb,0x2f,0xb8,0x39,0xb6,0x2f,0xb4,0x37,0xb6,0x2e, 0xb5,0x34,0xb5,0x2a,0xb7,0x34,0xba,0x2f,0xbc,0x3a,0xbf,0x2d,0xbe,0x38,0xbc,0x2b, 0xbc,0x37,0xb9,0x2e,0xb6,0x33,0xb3,0x2e,0xb2,0x34,0xb0,0x2b,0xb1,0x34,0xb2,0x2b, 0xb3,0x34,0xb7,0x2d,0xb9,0x35,0xbc,0x2c,0xbe,0x37,0xbe,0x2a,0xbd,0x36,0xba,0x2e, 0xb8,0x38,0xb3,0x2b,0xb3,0x32,0xb2,0x2a,0xb2,0x37,0xb3,0x2e,0xb4,0x37,0xb9,0x2b, 0xbe,0x38,0xbf,0x32,0xc1,0x3c,0xc1,0x2c,0xbf,0x3a,0xbe,0x2d,0xbb,0x35,0xb9,0x2c, 0xb8,0x34,0xb7,0x2e,0xb7,0x34,0xb6,0x2e,0xb8,0x3c,0xbb,0x2b,0xbe,0x39,0xc1,0x2f, 0xc1,0x31,0xc2,0x2b,0xc0,0x37,0xbe,0x2e,0xbb,0x35,0xb9,0x2f,0xb7,0x37,0xb7,0x2e, 0xb6,0x35,0xb7,0x2d,0xb8,0x36,0xba,0x2a,0xbc,0x35,0xc0,0x2e,0xc1,0x34,0xc1,0x2e, 0xbf,0x37,0xbd,0x29,0xb9,0x34,0xb7,0x2c,0xb7,0x39,0xb5,0x30,0xb4,0x3b,0xb4,0x2e, 0xb5,0x35,0xb7,0x30,0xbb,0x32,0xbd,0x2f,0xc1,0x37,0xc2,0x2f,0xc0,0x37,0xbf,0x2e, 0xbb,0x35,0xb7,0x2b,0xb5,0x36,0xb4,0x2c,0xb5,0x3a,0xb5,0x2f,0xb6,0x38,0xb8,0x2e, 0xbb,0x38,0xc0,0x2f,0xbf,0x32,0xc0,0x2f,0xc1,0x38,0xbf,0x2e,0xbb,0x33,0xb9,0x2d, 0xb7,0x3a,0xb5,0x2f,0xb3,0x32,0xb4,0x2b,0xb5,0x37,0xb7,0x30,0xb9,0x32,0xbd,0x2a, 0xbf,0x39,0xc1,0x2e,0xc0,0x2e,0xbe,0x36,0xbd,0x35,0xbb,0x2d,0xb7,0x34,0xb7,0x2d, 0xb7,0x35,0xb6,0x30,0xb6,0x33,0xb7,0x30,0xba,0x35,0xbf,0x2f,0xc2,0x36,0xc3,0x2e, 0xc2,0x35,0xc1,0x2f,0xbf,0x37,0xb9,0x30,0xb8,0x36,0xb6,0x32,0xb6,0x35,0xb4,0x2a, 0xb6,0x33,0xb8,0x2d,0xb9,0x31,0xbc,0x2d,0xc0,0x3b,0xc2,0x2c,0xc1,0x34,0xc0,0x2d, 0xbe,0x38,0xba,0x30,0xb8,0x35,0xb8,0x2d,0xb6,0x3c,0xb5,0x32,0xb5,0x34,0xb7,0x2d, 0xba,0x37,0xbd,0x2d,0xbf,0x33,0xbf,0x2c,0xc1,0x39,0xbf,0x2f,0xbc,0x33,0xbb,0x2f, 0xb8,0x35,0xb6,0x2d,0xb4,0x34,0xb4,0x30,0xb4,0x35,0xb4,0x31,0xb8,0x34,0xbd,0x2e, 0xbf,0x3a,0xbe,0x31,0xbf,0x36,0xc0,0x2f,0xbd,0x38,0xb9,0x30,0xb6,0x37,0xb4,0x30, 0xb4,0x37,0xb4,0x2d,0xb3,0x36,0xb4,0x2c,0xb6,0x38,0xba,0x2e,0xba,0x35,0xbd,0x2c, 0xbd,0x35,0xbc,0x32,0xbb,0x3b,0xb9,0x2e,0xb6,0x39,0xb3,0x31,0xb3,0x35,0xb1,0x2e, 0xb2,0x39,0xb3,0x30,0xb5,0x33,0xba,0x2b,0xbc,0x38,0xbc,0x31,0xbc,0x37,0xbc,0x2d, 0xbb,0x36,0xb6,0x30,0xb3,0x39,0xb2,0x2c,0xb1,0x37,0xb2,0x2f,0xb1,0x38,0xb1,0x2c, 0xb4,0x39,0xb7,0x2c,0xba,0x37,0xbd,0x2a,0xbf,0x34,0xbf,0x2e,0xbc,0x3a,0xba,0x2a, 0xb7,0x34,0xb4,0x2c,0xb2,0x33,0xb0,0x30,0xb2,0x3a,0xb1,0x2f,0xb2,0x3b,0xb6,0x2a, 0xbb,0x34,0xbb,0x2d,0xbc,0x2f,0xbc,0x2f,0xba,0x38,0xb7,0x2c,0xb5,0x36,0xb4,0x2d, 0xb3,0x34,0xb2,0x2f,0xb1,0x30,0xb2,0x2d,0xb3,0x38,0xb7,0x2f,0xb8,0x36,0xb9,0x30, 0xbb,0x35,0xbc,0x30,0xbb,0x35,0xb7,0x30,0xb5,0x37,0xb1,0x2f,0xb2,0x33,0xb0,0x2d, 0xae,0x34,0xb1,0x2e,0xb1,0x36,0xb5,0x30,0xb8,0x3b,0xbb,0x2f,0xbb,0x35,0xbb,0x2d, 0xbb,0x37,0xb9,0x30,0xb7,0x35,0xb4,0x2d,0xb2,0x37,0xb1,0x2f,0xb0,0x38,0xae,0x2b, 0xb0,0x39,0xb3,0x2c,0xb5,0x33,0xb7,0x2e,0xba,0x3b,0xbb,0x2c,0xb8,0x39,0xb6,0x30, 0xb3,0x35,0xb2,0x2d,0xaf,0x35,0xb0,0x2d,0xaf,0x3c,0xae,0x2d,0xaf,0x36,0xb1,0x2e, 0xb5,0x37,0xb7,0x2f,0xb7,0x36,0xb8,0x32,0xb8,0x35,0xb5,0x2c,0xb3,0x36,0xb1,0x2c, 0xb0,0x38,0xae,0x2d,0xad,0x36,0xad,0x2b,0xae,0x37,0xb0,0x29,0xb3,0x35,0xb4,0x31, 0xb6,0x35,0xb7,0x31,0xb7,0x33,0xb5,0x2f,0xb3,0x39,0xb1,0x2c,0xad,0x37,0xac,0x30, 0xae,0x35,0xae,0x2e,0xae,0x31,0xb0,0x2e,0xb3,0x39,0xb7,0x2a,0xb8,0x35,0xb7,0x2e, 0xb8,0x34,0xb8,0x2e,0xb5,0x36,0xb2,0x2f,0xae,0x36,0xae,0x2e,0xae,0x3a,0xae,0x2c, 0xae,0x34,0xaf,0x2f,0xb3,0x36,0xb6,0x2a,0xb8,0x39,0xb7,0x2e,0xb7,0x33,0xb7,0x2d, 0xb5,0x35,0xb1,0x30,0xaf,0x33,0xac,0x30,0xad,0x3a,0xad,0x2b,0xad,0x34,0xad,0x32, 0xb2,0x36,0xb5,0x2f,0xb6,0x31,0xb7,0x29,0xb8,0x38,0xb6,0x31,0xb4,0x36,0xb1,0x2d, 0xaf,0x34,0xaf,0x2f,0xae,0x33,0xac,0x2c,0xac,0x35,0xae,0x30,0xb1,0x32,0xb3,0x30, 0xb7,0x38,0xb8,0x2f,0xb9,0x34,0xb7,0x2d,0xb6,0x38,0xb4,0x2d,0xb1,0x38,0xaf,0x2f, 0xae,0x34,0xae,0x2b,0xae,0x36,0xae,0x30,0xb1,0x36,0xb5,0x2f,0xb8,0x37,0xb8,0x2b, 0xba,0x37,0xb8,0x32,0xb4,0x32,0xb1,0x30,0xb1,0x36,0xae,0x2c,0xab,0x32,0xac,0x32, 0xae,0x37,0xaf,0x2c,0xaf,0x37,0xb3,0x2b,0xb7,0x39,0xb7,0x31,0xb7,0x33,0xb7,0x2b, 0xb7,0x38,0xb2,0x2f,0xb1,0x36,0xaf,0x2f,0xb0,0x3a,0xac,0x29,0xac,0x30,0xad,0x25, 0xae,0x31,0xb1,0x2b,0xb4,0x35,0xb6,0x2e,0xb7,0x3a,0xb2,0x33,0xb8,0x52,0xb3,0x50, 0xb2,0x51,0xb0,0x58,0xae,0x61,0xad,0x58,0xaf,0x5c,0xb0,0x50,0xb2,0x58,0xb5,0x4d, 0xb7,0x57,0xb7,0x52,0xba,0x54,0xb9,0x54,0xb6,0x58,0xb5,0x4f,0xb0,0x59,0xae,0x50, 0xaf,0x56,0xad,0x4f,0xad,0x55,0xaf,0x4d,0xb1,0x5b,0xb1,0x51,0xb5,0x55,0xb6,0x50, 0xb6,0x56,0xb6,0x4f,0xb5,0x57,0xb1,0x4e,0xae,0x5a,0xac,0x50,0xac,0x5c,0xab,0x50, 0xab,0x58,0xac,0x51,0xb2,0x56,0xb3,0x4f,0xb2,0x57,0xb5,0x4d,0xba,0x56,0xb5,0x52, 0xb1,0x58,0xb3,0x4f,0xb0,0x59,0xae,0x4f,0xac,0x5a,0xad,0x4c,0xac,0x5a,0xac,0x50, 0xae,0x55,0xb3,0x4d,0xb4,0x56,0xb5,0x55,0xb7,0x58,0xb7,0x4e,0xb5,0x56,0xb4,0x50, 0xaf,0x58,0xad,0x50,0xae,0x56,0xac,0x50,0xad,0x5e,0xac,0x51,0xae,0x58,0xaf,0x4f, 0xb3,0x56,0xb4,0x50,0xb3,0x57,0xb4,0x4f,0xb4,0x59,0xb1,0x4f,0xae,0x59,0xac,0x4c, 0xaa,0x56,0xa9,0x4e,0xa9,0x5b,0xa7,0x4d,0xab,0x58,0xad,0x53,0xb1,0x59,0xb3,0x52, 0xb5,0x57,0xb6,0x4e,0xb3,0x57,0xb1,0x4d,0xae,0x57,0xaa,0x52,0xa9,0x5c,0xaa,0x4d, 0xab,0x55,0xaa,0x54,0xab,0x57,0xae,0x51,0xb2,0x59,0xb1,0x51,0xb4,0x56,0xb4,0x4f, 0xb2,0x58,0xaf,0x51,0xad,0x58,0xaa,0x50,0xa8,0x5c,0xa6,0x4e,0xa8,0x54,0xa9,0x50, 0xab,0x5c,0xaa,0x50,0xb1,0x58,0xb2,0x54,0xb5,0x5a,0xb4,0x52,0xb4,0x56,0xb1,0x50, 0xaf,0x58,0xad,0x4f,0xaa,0x57,0xa9,0x4f,0xa9,0x58,0xab,0x4f,0xac,0x57,0xac,0x4f, 0xb0,0x5b,0xb2,0x52,0xb4,0x59,0xb2,0x52,0xb4,0x5f,0xb1,0x52,0xad,0x57,0xab,0x4e, 0xa8,0x58,0xa8,0x51,0xa7,0x55,0xa7,0x4f,0xa9,0x57,0xaa,0x51,0xad,0x56,0xb0,0x50, 0xb3,0x5a,0xb0,0x52,0xb0,0x57,0xb0,0x4d,0xaf,0x5a,0xa8,0x53,0xa8,0x57,0xa7,0x50, 0xa8,0x56,0xa8,0x4c,0xa8,0x55,0xa9,0x4f,0xab,0x5b,0xad,0x52,0xb1,0x5a,0xb0,0x4f, 0xaf,0x57,0xb0,0x4f,0xac,0x57,0xa9,0x53,0xa8,0x5a,0xa6,0x51,0xa5,0x58,0xa6,0x53, 0xa7,0x5b,0xa6,0x50,0xa7,0x57,0xaf,0x53,0xb1,0x5d,0xae,0x4e,0xb1,0x58,0xaf,0x52, 0xae,0x5a,0xa9,0x52,0xa7,0x59,0xa6,0x52,0xa7,0x59,0xa5,0x4d,0xa6,0x5b,0xa8,0x50, 0xab,0x54,0xad,0x51,0xaf,0x55,0xb1,0x4f,0xaf,0x57,0xaf,0x51,0xae,0x5c,0xa9,0x4f, 0xa7,0x56,0xa7,0x4f,0xa6,0x59,0xa5,0x4f,0xa6,0x59,0xa7,0x50,0xaa,0x59,0xac,0x4b, 0xae,0x55,0xb0,0x4f,0xaf,0x55,0xab,0x4e,0xa9,0x5a,0xa9,0x4c,0xa6,0x58,0xa3,0x4e, 0xa4,0x53,0xa4,0x50,0xa6,0x57,0xa8,0x54,0xa9,0x58,0xac,0x51,0xb0,0x5a,0xb0,0x4f, 0xae,0x56,0xaf,0x51,0xac,0x57,0xa9,0x4e,0xa8,0x59,0xa6,0x4e,0xa5,0x58,0xa6,0x4f, 0xa6,0x52,0xa5,0x50,0xa8,0x53,0xaa,0x50,0xac,0x58,0xad,0x51,0xae,0x5a,0xaf,0x4e, 0xad,0x5a,0xa4,0x4f,0x9e,0x55,0xa4,0x4e,0xa3,0x5c,0x9b,0x4c,0x9e,0x58,0xa4,0x50, 0xa7,0x54,0xa9,0x52,0xab,0x59,0xac,0x50,0xae,0x5b,0xad,0x4d,0xab,0x57,0xa9,0x52, 0xa6,0x57,0xa2,0x50,0xa3,0x56,0xa2,0x4d,0xa2,0x59,0xa4,0x4f,0xa5,0x5b,0xa7,0x50, 0xac,0x56,0xab,0x4e,0xa9,0x5a,0xab,0x50,0xab,0x5a,0xa5,0x50,0xa2,0x58,0xa1,0x4e, 0xa0,0x59,0xa0,0x54,0xa1,0x56,0xa1,0x4b,0xa4,0x5c,0xa5,0x50,0xa8,0x57,0xa8,0x4e, 0xaa,0x54,0xac,0x4f,0xa9,0x55,0xa6,0x4f,0xa4,0x5b,0xa4,0x4f,0xa1,0x5b,0xa2,0x4e, 0xa0,0x5a,0xa1,0x4f,0xa4,0x55,0xa7,0x54,0xaa,0x5c,0xab,0x52,0xaf,0x59,0xad,0x51, 0xab,0x58,0xa9,0x4c,0xa7,0x57,0xa5,0x53,0xa2,0x59,0xa1,0x4f,0xa2,0x55,0xa4,0x4d, 0xa5,0x5c,0xa5,0x53,0xa9,0x5a,0xab,0x52,0xab,0x61,0xac,0x4f,0xab,0x56,0xa9,0x4f, 0xa6,0x58,0xa4,0x4e,0xa2,0x58,0xa2,0x4f,0xa3,0x5b,0xa4,0x55,0xa4,0x57,0xa5,0x50, 0xa9,0x53,0xac,0x51,0xae,0x59,0xab,0x56,0xaa,0x56,0xab,0x51,0xa7,0x59,0xa2,0x50, 0xa2,0x5a,0xa0,0x54,0xa0,0x56,0xa1,0x53,0xa2,0x5a,0xa4,0x4f,0xa7,0x59,0xa9,0x4d, 0xad,0x58,0xac,0x50,0xa9,0x57,0xaa,0x4f,0xaa,0x5a,0xa6,0x53,0xa3,0x58,0xa4,0x50, 0xa5,0x5b,0xa5,0x4f,0xa3,0x5a,0xa5,0x52,0xa9,0x5c,0xab,0x51,0xac,0x57,0xac,0x50, 0xaf,0x5b,0xac,0x54,0xa9,0x54,0xa5,0x52,0xa5,0x5c,0xa4,0x50,0xa2,0x58,0xa0,0x51, 0xa4,0x56,0xa4,0x50,0xa7,0x5a,0xa9,0x4d,0xae,0x5b,0xac,0x4c,0xac,0x5b,0xac,0x4f, 0xab,0x58,0xa8,0x53,0xa4,0x58,0xa2,0x51,0xa1,0x56,0xa0,0x54,0xa3,0x59,0xa4,0x4f, 0xa5,0x57,0xa8,0x50,0xac,0x57,0xae,0x4f,0xad,0x58,0xa9,0x50,0xa7,0x58,0xa4,0x50, 0xa4,0x56,0x9f,0x4b,0xa0,0x58,0xa1,0x4d,0xa2,0x57,0xa3,0x4f,0xa5,0x5b,0xa7,0x4f, 0xab,0x59,0xaa,0x50,0xaa,0x58,0xa8,0x54,0xa8,0x58,0xa4,0x4e,0xa1,0x58,0xa2,0x4c, 0xa1,0x55,0x9f,0x56,0x9f,0x52,0xa2,0x4e,0xa5,0x56,0xa8,0x4e,0xa9,0x58,0xaa,0x50, 0xac,0x59,0xab,0x51,0xa9,0x55,0xa5,0x50,0xa4,0x58,0xa2,0x51,0xa0,0x58,0xa0,0x4c, 0xa2,0x5b,0xa3,0x4f,0xa4,0x54,0xa8,0x4f,0xab,0x59,0xac,0x52,0xac,0x56,0xab,0x50, 0xac,0x58,0xa8,0x53,0xa5,0x4f,0xa4,0x4b,0xa1,0x57,0x9e,0x51,0xa2,0x58,0xa1,0x4d, 0xa2,0x5c,0xa6,0x4e,0xaa,0x53,0xac,0x51,0xac,0x56,0xaa,0x50,0xa9,0x55,0xa8,0x4e, 0xa5,0x5b,0xa2,0x53,0xa0,0x52,0xa0,0x50,0xa3,0x57,0xa2,0x53,0xa3,0x59,0xa7,0x52, 0xac,0x5c,0xac,0x52,0xac,0x58,0xa5,0x4f,0xa8,0x5b,0xa8,0x51,0xa0,0x5b,0x9c,0x4b, 0xa2,0x56,0xa3,0x4f,0xa1,0x57,0xa2,0x50,0xa5,0x55,0xa6,0x54,0xaa,0x5b,0xac,0x4e, 0xad,0x59,0xab,0x50,0xaa,0x56,0xa8,0x4f,0xa5,0x59,0xa1,0x51,0xa0,0x56,0xa0,0x53, 0x9e,0x5a,0xa0,0x4c,0xa1,0x4f,0xa5,0x49,0xa8,0x51,0xaa,0x53,0xaa,0x56,0xa9,0x4f, 0xab,0x59,0xa3,0x55,0xa6,0x45,0xa8,0x3f,0xa6,0x48,0xa4,0x44,0xa6,0x4d,0xa6,0x48, 0xa8,0x4d,0xaa,0x41,0xad,0x47,0xae,0x40,0xaf,0x4a,0xae,0x44,0xad,0x49,0xab,0x3c, 0xa9,0x46,0xa5,0x3f,0xa5,0x48,0xa4,0x3d,0xa5,0x47,0xa5,0x40,0xa8,0x48,0xaa,0x41, 0xad,0x48,0xb0,0x3f,0xaf,0x43,0xae,0x3c,0xae,0x45,0xac,0x3f,0xa8,0x4b,0xa6,0x3f, 0xa4,0x48,0xa4,0x3f,0xa3,0x43,0xa3,0x43,0xa5,0x45,0xa9,0x41,0xaa,0x47,0xac,0x3f, 0xad,0x4c,0xac,0x42,0xab,0x45,0xa8,0x42,0xa7,0x43,0xa3,0x43,0xa1,0x48,0xa2,0x40, 0xa2,0x4b,0xa0,0x41,0xa2,0x46,0xa6,0x43,0xaa,0x49,0xaa,0x42,0xad,0x4a,0xab,0x40, 0xab,0x4a,0xaa,0x40,0xa6,0x47,0xa2,0x44,0xa2,0x4b,0xa0,0x42,0xa0,0x43,0xa0,0x43, 0xa0,0x46,0xa3,0x40,0xa7,0x47,0xa8,0x3d,0xa9,0x4b,0xab,0x40,0xab,0x42,0xa7,0x41, 0xa6,0x47,0xa3,0x42,0xa0,0x4a,0xa0,0x43,0xa1,0x49,0xa1,0x3e,0xa3,0x4a,0xa2,0x40, 0xa7,0x47,0xa9,0x42,0xa9,0x43,0xa8,0x42,0xa9,0x47,0xa7,0x44,0xa4,0x49,0xa2,0x3f, 0xa1,0x4a,0xa0,0x40,0xa0,0x4b,0x9f,0x3d,0xa0,0x4a,0xa1,0x41,0xa5,0x47,0xa7,0x44, 0xaa,0x49,0xa9,0x43,0xa9,0x46,0xa8,0x42,0xa7,0x46,0xa1,0x41,0xa0,0x46,0x9e,0x40, 0xa0,0x4c,0x9d,0x41,0x9e,0x48,0x9e,0x42,0xa4,0x4a,0xa7,0x42,0xa7,0x48,0xa7,0x41, 0xa8,0x49,0xa5,0x40,0xa4,0x44,0xa0,0x3c,0x9f,0x44,0x9d,0x43,0x9e,0x4d,0x9c,0x40, 0x9d,0x46,0x9f,0x42,0xa2,0x45,0xa4,0x41,0xa8,0x49,0xa8,0x3e,0xa9,0x48,0xa7,0x3e, 0xa5,0x46,0xa2,0x3e,0x9e,0x45,0x9d,0x42,0x9d,0x4a,0x9c,0x40,0x9e,0x4b,0x9f,0x3d, 0xa1,0x49,0xa2,0x42,0xa6,0x4a,0xa6,0x40,0xa8,0x4a,0xa6,0x41,0xa5,0x4a,0xa1,0x41, 0xa0,0x49,0x9e,0x42,0x9d,0x47,0x9d,0x3f,0x9c,0x45,0x9e,0x46,0x9f,0x48,0xa3,0x3f, 0xa4,0x46,0xa6,0x43,0xa6,0x47,0xa5,0x3f,0xa3,0x49,0x9f,0x41,0x9d,0x49,0x9d,0x3e, 0x9b,0x4b,0x99,0x3e,0x9a,0x46,0x9b,0x3d,0x9f,0x4c,0xa1,0x3f,0xa4,0x4b,0xa5,0x3d, 0xa7,0x47,0xa5,0x42,0xa4,0x4a,0xa1,0x41,0x9e,0x4c,0x9b,0x3e,0x99,0x45,0x97,0x40, 0x9a,0x47,0x98,0x42,0x9c,0x48,0x9f,0x40,0xa3,0x49,0xa2,0x40,0xa4,0x4b,0xa4,0x42, 0xa2,0x4a,0x9f,0x41,0x9e,0x46,0x9c,0x3f,0x9a,0x4a,0x9a,0x43,0x9a,0x46,0x99,0x45, 0x9b,0x4a,0x9d,0x41,0xa0,0x48,0xa3,0x3d,0xa4,0x49,0xa1,0x44,0xa3,0x4d,0x9e,0x3c, 0x9a,0x49,0x98,0x42,0x99,0x47,0x97,0x3e,0x96,0x48,0x99,0x43,0x9b,0x45,0x9e,0x42, 0xa0,0x46,0xa2,0x3f,0xa3,0x47,0xa1,0x43,0xa1,0x4b,0xa0,0x3f,0x9c,0x48,0x98,0x41, 0x9a,0x4a,0x99,0x3d,0x98,0x46,0x99,0x3d,0x9a,0x45,0x9d,0x42,0x9e,0x47,0xa0,0x41, 0xa2,0x47,0xa2,0x40,0xa0,0x46,0x9f,0x3f,0x9c,0x4a,0x9a,0x3f,0x99,0x48,0x97,0x3f, 0x98,0x46,0x96,0x45,0x9a,0x4b,0x9c,0x3f,0x9f,0x45,0xa2,0x41,0xa4,0x4a,0xa1,0x42, 0xa3,0x4b,0xa2,0x3f,0x9d,0x48,0x9a,0x40,0x9c,0x4c,0x99,0x40,0x96,0x4c,0x96,0x41, 0x9b,0x49,0x9b,0x41,0x9e,0x49,0xa1,0x44,0xa4,0x4a,0xa3,0x3f,0xa4,0x4a,0xa2,0x3e, 0x9e,0x46,0x9c,0x3e,0x9a,0x4a,0x98,0x43,0x99,0x48,0x99,0x3d,0x9a,0x48,0x9a,0x40, 0x9d,0x4d,0xa1,0x3f,0xa2,0x4b,0x9f,0x40,0xa0,0x4b,0x9f,0x44,0x9d,0x46,0x98,0x3b, 0x97,0x48,0x96,0x41,0x96,0x46,0x95,0x45,0x96,0x4b,0x99,0x42,0x9d,0x49,0x9d,0x40, 0x9f,0x47,0x9f,0x42,0xa0,0x47,0x9c,0x40,0x9c,0x48,0x99,0x43,0x97,0x4a,0x97,0x3f, 0x97,0x4a,0x96,0x3d,0x96,0x48,0x99,0x3e,0x9c,0x49,0x9f,0x41,0xa1,0x44,0xa1,0x3f, 0xa2,0x48,0xa0,0x41,0x9f,0x48,0x9c,0x43,0x98,0x47,0x96,0x40,0x97,0x48,0x97,0x40, 0x99,0x4a,0x9a,0x41,0x9d,0x48,0xa0,0x3f,0xa3,0x44,0xa2,0x42,0xa2,0x4a,0xa2,0x3f, 0xa0,0x49,0x9d,0x3f,0x98,0x49,0x97,0x3f,0x96,0x4b,0x97,0x43,0x96,0x4b,0x95,0x41, 0x9b,0x49,0x9c,0x3e,0x9b,0x48,0x9e,0x43,0xa1,0x47,0x9e,0x43,0x9b,0x4a,0x9b,0x44, 0x97,0x4d,0x95,0x3d,0x97,0x4b,0x95,0x3c,0x96,0x4c,0x97,0x3f,0x9a,0x49,0x9d,0x43, 0x9e,0x4b,0xa2,0x3e,0xa0,0x47,0x9f,0x42,0xa0,0x4a,0x9e,0x40,0x99,0x47,0x97,0x43, 0x98,0x47,0x95,0x40,0x97,0x48,0x96,0x40,0x99,0x4b,0x9d,0x3e,0xa0,0x48,0xa0,0x41, 0xa1,0x4b,0x9f,0x40,0xa0,0x44,0x9e,0x3d,0x99,0x4d,0x97,0x40,0x98,0x47,0x97,0x43, 0x98,0x48,0x9a,0x3e,0x9b,0x49,0x9d,0x3c,0xa1,0x47,0xa1,0x42,0xa2,0x48,0xa0,0x3e, 0x9f,0x48,0x9d,0x40,0x9b,0x49,0x98,0x3f,0x98,0x47,0x98,0x41,0x99,0x49,0x98,0x42, 0x9a,0x46,0x9d,0x42,0xa0,0x46,0xa0,0x41,0xa2,0x4a,0xa1,0x3e,0xa1,0x48,0x9e,0x46, 0x9b,0x47,0x97,0x43,0x96,0x47,0x97,0x3d,0x96,0x4a,0x95,0x40,0x97,0x4a,0x9a,0x41, 0x9e,0x48,0x9f,0x41,0xa1,0x4b,0x9e,0x40,0x9f,0x48,0x9e,0x3f,0x9a,0x4a,0x98,0x3d, 0x96,0x4b,0x96,0x43,0x96,0x4a,0x95,0x3d,0x97,0x48,0x9c,0x3f,0x9f,0x47,0xa0,0x42, 0xa2,0x49,0xa0,0x42,0xa0,0x47,0x9c,0x40,0x9c,0x48,0x99,0x41,0x96,0x49,0x95,0x40, 0x94,0x49,0x95,0x43,0x97,0x47,0x9a,0x3d,0x9d,0x45,0xa0,0x42,0xa2,0x49,0xa1,0x42, 0xa2,0x4b,0x9f,0x41,0x9c,0x47,0x98,0x3d,0x99,0x4c,0x97,0x40,0x97,0x45,0x97,0x42, 0x99,0x46,0x9c,0x3e,0x9e,0x49,0x9f,0x3f,0xa1,0x48,0xa1,0x42,0xa0,0x4a,0x9f,0x40, 0x9e,0x48,0x99,0x3c,0x95,0x46,0x96,0x3f,0x97,0x47,0x94,0x40,0x95,0x49,0x99,0x41, 0x9e,0x4a,0xa0,0x44,0xa0,0x47,0xa2,0x3d,0xa2,0x4b,0x9e,0x3e,0x9c,0x44,0x99,0x40, 0x98,0x49,0x95,0x40,0x95,0x45,0x94,0x46,0x98,0x4b,0x99,0x3f,0x9d,0x41,0x9e,0x38, 0xa1,0x46,0xa1,0x40,0xa0,0x46,0x9d,0x40,0x9e,0x4b,0x96,0x44,0x9b,0x55,0x9a,0x52, 0x9b,0x58,0x9c,0x56,0x9d,0x60,0xa1,0x57,0xa4,0x60,0xa5,0x56,0xa6,0x5c,0xa6,0x53, 0xa6,0x57,0xa4,0x4e,0xa0,0x54,0x9e,0x4f,0x9c,0x5a,0x9b,0x52,0x9d,0x56,0x9b,0x50, 0x9d,0x58,0xa0,0x4d,0xa2,0x5b,0xa4,0x52,0xa7,0x5d,0xa6,0x4f,0xa4,0x57,0xa6,0x4d, 0xa2,0x59,0x9e,0x4e,0x9d,0x57,0x99,0x51,0x9a,0x5a,0x9b,0x4c,0x9a,0x55,0x9c,0x4f, 0xa0,0x59,0xa4,0x53,0xa4,0x58,0xa4,0x4f,0xa3,0x54,0xa4,0x4d,0x9f,0x57,0x9b,0x55, 0x9b,0x5a,0x9a,0x54,0x98,0x54,0x99,0x4e,0x99,0x58,0x9b,0x51,0xa0,0x5a,0xa2,0x50, 0xa4,0x5a,0xa5,0x4f,0xa5,0x56,0xa3,0x4d,0xa0,0x5b,0x9c,0x53,0x9b,0x57,0x99,0x50, 0x9b,0x58,0x99,0x4f,0x9a,0x5a,0x9b,0x50,0xa1,0x55,0xa2,0x51,0xa5,0x5d,0xa5,0x52, 0xa6,0x5a,0xa4,0x50,0xa1,0x57,0x9c,0x50,0x9b,0x58,0x98,0x50,0x98,0x59,0x98,0x53, 0x99,0x5a,0x9a,0x54,0x9d,0x5a,0xa0,0x50,0xa2,0x59,0xa4,0x4e,0xa5,0x5b,0xa1,0x52, 0xa0,0x5a,0x9d,0x50,0x99,0x56,0x97,0x4f,0x97,0x5b,0x96,0x52,0x96,0x58,0x98,0x53, 0x9b,0x57,0x9f,0x4f,0xa1,0x58,0xa2,0x53,0xa3,0x5a,0xa4,0x4c,0xa0,0x59,0x9d,0x51, 0x9d,0x5b,0x99,0x50,0x98,0x57,0x99,0x53,0x99,0x58,0x99,0x55,0x9a,0x56,0x9f,0x52, 0xa1,0x5a,0xa2,0x4c,0xa2,0x58,0xa2,0x55,0xa1,0x59,0x9b,0x52,0x9b,0x58,0x98,0x51, 0x99,0x57,0x99,0x4e,0x99,0x5a,0x99,0x53,0x9c,0x5e,0x9d,0x53,0xa0,0x58,0xa3,0x4d, 0xa3,0x5a,0xa1,0x51,0xa0,0x56,0x9d,0x50,0x9a,0x5a,0x97,0x4c,0x96,0x57,0x95,0x53, 0x96,0x5c,0x97,0x53,0x99,0x59,0x9c,0x50,0x9e,0x5b,0xa0,0x52,0xa2,0x5c,0xa1,0x55, 0x9e,0x56,0x9b,0x51,0x9a,0x57,0x97,0x51,0x97,0x5b,0x95,0x51,0x96,0x5c,0x95,0x50, 0x99,0x57,0x9c,0x53,0x9e,0x5a,0x9e,0x53,0xa1,0x5d,0xa1,0x51,0xa0,0x56,0x9c,0x54, 0x9b,0x5a,0x97,0x51,0x95,0x55,0x95,0x50,0x95,0x5a,0x95,0x4e,0x98,0x55,0x9a,0x51, 0x9e,0x5e,0x9f,0x4f,0xa0,0x55,0x9f,0x54,0x9f,0x58,0x9c,0x52,0x99,0x5b,0x97,0x54, 0x95,0x5e,0x92,0x51,0x94,0x58,0x95,0x52,0x98,0x58,0x9a,0x4c,0x9c,0x56,0x9e,0x57, 0x9e,0x5a,0x9e,0x53,0x9e,0x5c,0x9b,0x4f,0x98,0x58,0x95,0x52,0x94,0x56,0x92,0x52, 0x93,0x61,0x93,0x53,0x95,0x54,0x99,0x4e,0x9c,0x5d,0x9d,0x54,0x9d,0x59,0x9d,0x50, 0x9f,0x5f,0x9b,0x53,0x99,0x56,0x96,0x54,0x96,0x5e,0x94,0x4e,0x94,0x58,0x93,0x53, 0x96,0x5b,0x97,0x53,0x9a,0x58,0x9c,0x50,0x9e,0x5c,0x9e,0x4f,0x9e,0x59,0x99,0x52, 0x97,0x53,0x94,0x51,0x95,0x5c,0x90,0x50,0x91,0x59,0x92,0x54,0x94,0x58,0x95,0x51, 0x99,0x58,0x9c,0x57,0x9d,0x58,0x9e,0x52,0x9d,0x5a,0x9b,0x53,0x98,0x58,0x95,0x51, 0x93,0x5b,0x92,0x52,0x92,0x54,0x93,0x4f,0x93,0x56,0x92,0x51,0x97,0x57,0x9b,0x4f, 0x9a,0x57,0x9a,0x54,0x9c,0x59,0x99,0x51,0x99,0x5e,0x95,0x4e,0x94,0x5b,0x91,0x56, 0x90,0x5b,0x90,0x54,0x91,0x58,0x94,0x4f,0x96,0x57,0x99,0x51,0x9a,0x55,0x9c,0x4e, 0x9c,0x5d,0x99,0x55,0x97,0x58,0x94,0x51,0x91,0x5b,0x91,0x55,0x8f,0x5a,0x8f,0x52, 0x90,0x5e,0x92,0x54,0x95,0x58,0x97,0x52,0x9a,0x5b,0x9a,0x52,0x9b,0x59,0x99,0x53, 0x97,0x5a,0x94,0x52,0x92,0x55,0x91,0x54,0x90,0x5b,0x8f,0x56,0x8f,0x5d,0x90,0x51, 0x95,0x5a,0x96,0x57,0x98,0x5c,0x9b,0x4d,0x9a,0x5a,0x96,0x53,0x95,0x5b,0x95,0x56, 0x90,0x58,0x8d,0x53,0x8d,0x58,0x8d,0x56,0x8e,0x5b,0x8e,0x53,0x92,0x59,0x95,0x56, 0x98,0x55,0x98,0x52,0x99,0x57,0x96,0x52,0x95,0x5a,0x92,0x50,0x91,0x5b,0x8e,0x54, 0x8d,0x5a,0x8c,0x51,0x8e,0x57,0x8e,0x55,0x91,0x5c,0x93,0x4d,0x97,0x5b,0x96,0x51, 0x97,0x5a,0x97,0x53,0x96,0x55,0x93,0x4b,0x91,0x5a,0x8d,0x53,0x8c,0x5c,0x8a,0x51, 0x8d,0x5c,0x8d,0x55,0x8f,0x59,0x92,0x53,0x96,0x5d,0x96,0x52,0x98,0x5c,0x97,0x51, 0x97,0x60,0x94,0x56,0x92,0x5b,0x8d,0x52,0x8d,0x58,0x8d,0x4e,0x8d,0x5b,0x8d,0x51, 0x8f,0x5c,0x93,0x55,0x96,0x58,0x95,0x50,0x96,0x5a,0x97,0x54,0x97,0x59,0x92,0x51, 0x90,0x5e,0x90,0x53,0x8e,0x58,0x8c,0x52,0x8d,0x59,0x8e,0x54,0x90,0x58,0x93,0x52, 0x97,0x5a,0x98,0x50,0x9a,0x5a,0x9b,0x4e,0x9a,0x5a,0x97,0x51,0x95,0x5b,0x92,0x53, 0x90,0x58,0x90,0x53,0x90,0x53,0x90,0x4f,0x92,0x5c,0x94,0x53,0x97,0x59,0x99,0x50, 0x9b,0x5a,0x9a,0x52,0x9a,0x59,0x97,0x4e,0x95,0x59,0x91,0x51,0x90,0x5d,0x8f,0x4e, 0x8f,0x5a,0x8f,0x53,0x92,0x5b,0x93,0x52,0x96,0x5b,0x97,0x52,0x9a,0x59,0x9a,0x4f, 0x9a,0x5c,0x98,0x57,0x95,0x57,0x91,0x56,0x8f,0x5b,0x8d,0x51,0x8e,0x5b,0x8f,0x4f, 0x90,0x56,0x93,0x53,0x96,0x57,0x97,0x52,0x99,0x5a,0x9a,0x50,0x9a,0x5a,0x96,0x51, 0x96,0x58,0x94,0x52,0x8f,0x58,0x8d,0x52,0x8d,0x5a,0x8c,0x4f,0x8f,0x5b,0x92,0x50, 0x97,0x5b,0x98,0x4f,0x99,0x5c,0x9a,0x50,0x99,0x56,0x98,0x54,0x96,0x58,0x92,0x53, 0x92,0x59,0x8f,0x51,0x8e,0x5a,0x8f,0x4f,0x92,0x5a,0x93,0x54,0x98,0x5a,0x99,0x54, 0x9b,0x59,0x9c,0x51,0x9d,0x5c,0x9a,0x4f,0x97,0x5e,0x94,0x50,0x91,0x5b,0x8f,0x50, 0x90,0x56,0x91,0x4e,0x91,0x59,0x93,0x55,0x96,0x5a,0x9a,0x56,0x9d,0x59,0x9d,0x53, 0x9d,0x57,0x9b,0x50,0x99,0x5d,0x95,0x52,0x90,0x5d,0x8f,0x4f,0x8e,0x5a,0x8f,0x4a, 0x92,0x5b,0x92,0x52,0x97,0x5e,0x9b,0x53,0x9d,0x5f,0x9c,0x53,0x9e,0x56,0x9c,0x50, 0x9c,0x5b,0x99,0x4e,0x95,0x5a,0x93,0x50,0x94,0x5d,0x92,0x52,0x93,0x5a,0x95,0x55, 0x98,0x5a,0x9a,0x4f,0x9d,0x51,0x9c,0x48,0x9e,0x5a,0x9c,0x50,0x9b,0x57,0x99,0x4f, 0x97,0x59,0x90,0x57,0x99,0x4c,0x98,0x46,0x98,0x51,0x9c,0x4e,0xa0,0x5c,0xa2,0x4e, 0xa4,0x53,0xa4,0x4d,0xa2,0x52,0xa0,0x46,0x9f,0x56,0x9c,0x47,0x98,0x51,0x99,0x4b, 0x97,0x51,0x99,0x48,0x99,0x52,0x99,0x48,0x9e,0x53,0xa0,0x47,0xa0,0x50,0xa2,0x47, 0xa3,0x50,0x9f,0x46,0x9d,0x51,0x9b,0x4a,0x98,0x52,0x96,0x4b,0x97,0x4f,0x97,0x46, 0x97,0x50,0x9b,0x48,0x9d,0x52,0x9f,0x48,0xa2,0x52,0xa4,0x46,0xa3,0x54,0xa1,0x48, 0x9e,0x52,0x9c,0x46,0x99,0x4c,0x96,0x47,0x97,0x53,0x96,0x4c,0x98,0x4d,0x9a,0x4a, 0x9c,0x4f,0x9e,0x49,0xa0,0x54,0xa2,0x4c,0xa2,0x50,0xa2,0x4a,0xa0,0x50,0x9d,0x4b, 0x99,0x51,0x96,0x4a,0x94,0x51,0x96,0x49,0x95,0x50,0x97,0x48,0x9b,0x4f,0x9e,0x49, 0xa0,0x4f,0xa1,0x48,0xa2,0x4f,0xa1,0x4f,0x9f,0x55,0x9b,0x4c,0x98,0x50,0x96,0x4c, 0x96,0x4a,0x95,0x4b,0x96,0x52,0x96,0x4d,0x9a,0x53,0x9f,0x46,0xa0,0x51,0xa1,0x47, 0xa4,0x4f,0xa2,0x49,0xa1,0x4f,0x9c,0x4c,0x99,0x56,0x96,0x48,0x96,0x51,0x95,0x49, 0x97,0x4f,0x97,0x4c,0x99,0x54,0x9d,0x45,0x9e,0x53,0xa1,0x4a,0xa3,0x4e,0xa0,0x48, 0x9e,0x52,0x9c,0x4b,0x9a,0x4d,0x95,0x4d,0x94,0x52,0x94,0x4a,0x95,0x4d,0x95,0x49, 0x97,0x50,0x9c,0x49,0x9e,0x51,0x9d,0x4a,0x9f,0x54,0xa1,0x4a,0x9e,0x51,0x9a,0x46, 0x99,0x50,0x95,0x48,0x95,0x51,0x95,0x47,0x94,0x54,0x95,0x4a,0x97,0x51,0x9a,0x49, 0x9c,0x50,0xa0,0x4a,0xa0,0x4f,0x9e,0x48,0x9f,0x57,0x9c,0x4a,0x99,0x53,0x96,0x46, 0x95,0x51,0x95,0x47,0x93,0x52,0x95,0x4b,0x96,0x50,0x9a,0x48,0x9d,0x54,0x9e,0x4a, 0xa0,0x51,0xa0,0x49,0x9e,0x52,0x9c,0x4a,0x99,0x56,0x97,0x49,0x95,0x50,0x95,0x4b, 0x94,0x51,0x94,0x4a,0x97,0x4c,0x99,0x4a,0x9d,0x4f,0x9e,0x46,0xa0,0x53,0x9f,0x4e, 0x9f,0x55,0x9c,0x4d,0x9a,0x4e,0x97,0x45,0x94,0x53,0x95,0x4d,0x94,0x53,0x95,0x47, 0x96,0x54,0x99,0x4b,0x9c,0x51,0x9d,0x48,0xa0,0x58,0xa0,0x4d,0x9e,0x4f,0x9c,0x46, 0x9a,0x53,0x95,0x4a,0x92,0x4f,0x91,0x49,0x91,0x54,0x92,0x48,0x92,0x52,0x95,0x4e, 0x99,0x54,0x9c,0x49,0x9d,0x51,0x9d,0x48,0x9d,0x50,0x9d,0x4a,0x9a,0x53,0x95,0x4a, 0x93,0x50,0x92,0x46,0x90,0x51,0x92,0x4a,0x94,0x58,0x97,0x4c,0x99,0x51,0x9d,0x4c, 0x9d,0x50,0x9e,0x4a,0x9e,0x4d,0x9b,0x47,0x98,0x54,0x95,0x4d,0x93,0x52,0x92,0x48, 0x91,0x51,0x91,0x47,0x93,0x51,0x96,0x48,0x99,0x56,0x9b,0x4c,0x9d,0x55,0x9e,0x4a, 0x9d,0x50,0x9c,0x46,0x9a,0x4f,0x96,0x49,0x94,0x57,0x92,0x47,0x91,0x4e,0x91,0x47, 0x94,0x4e,0x95,0x47,0x97,0x50,0x9a,0x47,0x9c,0x52,0x9e,0x47,0x9d,0x55,0x9c,0x4b, 0x99,0x51,0x97,0x49,0x93,0x50,0x91,0x4b,0x90,0x55,0x91,0x4a,0x91,0x4e,0x93,0x4b, 0x98,0x4f,0x99,0x48,0x9a,0x54,0x9b,0x45,0x9d,0x4e,0x9a,0x46,0x97,0x54,0x94,0x4a, 0x91,0x55,0x8f,0x4c,0x8e,0x54,0x8f,0x46,0x90,0x59,0x91,0x4c,0x96,0x53,0x99,0x47, 0x9b,0x53,0x9c,0x4c,0x9b,0x53,0x9a,0x48,0x98,0x55,0x96,0x4b,0x92,0x4f,0x90,0x49, 0x90,0x52,0x91,0x4f,0x91,0x52,0x92,0x4c,0x95,0x52,0x96,0x52,0x99,0x51,0x99,0x49, 0x9b,0x54,0x9a,0x4a,0x98,0x52,0x95,0x45,0x92,0x57,0x8f,0x4c,0x8f,0x54,0x8f,0x4a, 0x8e,0x51,0x91,0x4b,0x92,0x50,0x97,0x4b,0x9a,0x56,0x9b,0x4c,0x99,0x56,0x9b,0x4c, 0x9a,0x53,0x96,0x4c,0x93,0x52,0x90,0x48,0x8f,0x57,0x8e,0x49,0x8e,0x51,0x91,0x4c, 0x93,0x50,0x95,0x4a,0x99,0x4f,0x9a,0x49,0x9c,0x58,0x9b,0x47,0x99,0x4d,0x98,0x4a, 0x94,0x50,0x91,0x49,0x8f,0x53,0x8f,0x4c,0x8e,0x55,0x91,0x4a,0x94,0x56,0x96,0x49, 0x98,0x52,0x9c,0x4b,0x9c,0x53,0x9b,0x4c,0x99,0x56,0x99,0x48,0x95,0x4e,0x90,0x48, 0x8f,0x56,0x90,0x49,0x90,0x4f,0x92,0x49,0x95,0x5c,0x96,0x4c,0x99,0x4f,0x9a,0x4b, 0x9c,0x52,0x9d,0x4c,0x9b,0x4f,0x99,0x4a,0x95,0x53,0x93,0x4b,0x92,0x4f,0x90,0x4c, 0x90,0x53,0x92,0x47,0x94,0x54,0x96,0x4b,0x9a,0x4e,0x9c,0x4e,0x9d,0x54,0x9b,0x49, 0x9b,0x4f,0x99,0x4c,0x96,0x53,0x92,0x4c,0x8e,0x54,0x8f,0x48,0x91,0x54,0x91,0x4a, 0x92,0x53,0x97,0x4a,0x9b,0x50,0x9e,0x4a,0x9f,0x4f,0x9c,0x4a,0x9b,0x54,0x9b,0x47, 0x99,0x52,0x95,0x4b,0x93,0x55,0x92,0x4a,0x92,0x55,0x93,0x4d,0x93,0x54,0x98,0x4c, 0x9a,0x52,0x9d,0x4b,0x9e,0x51,0x9d,0x48,0x9e,0x57,0x9c,0x4c,0x9a,0x53,0x97,0x4b, 0x95,0x54,0x95,0x4e,0x94,0x4d,0x95,0x48,0x96,0x56,0x98,0x4a,0x9c,0x53,0x9f,0x47, 0xa0,0x54,0xa0,0x4c,0x9e,0x51,0x9f,0x49,0x9b,0x51,0x98,0x4a,0x96,0x52,0x94,0x4a, 0x93,0x55,0x94,0x4b,0x95,0x4b,0x98,0x46,0x9b,0x57,0x9d,0x4a,0xa0,0x4f,0x9f,0x49, 0x9e,0x54,0x9d,0x50,0x9a,0x50,0x97,0x4c,0x96,0x55,0x95,0x4b,0x93,0x53,0x94,0x49, 0x95,0x53,0x99,0x4c,0x9c,0x54,0xa0,0x45,0xa1,0x56,0xa1,0x4c,0xa1,0x4f,0x9f,0x4b, 0x9c,0x56,0x9a,0x4b,0x96,0x50,0x95,0x4e,0x95,0x55,0x94,0x4b,0x96,0x4e,0x98,0x49, 0x9b,0x53,0x9e,0x4d,0x9f,0x51,0xa0,0x48,0xa1,0x5b,0x9e,0x46,0x9e,0x59,0x9a,0x47, 0x97,0x56,0x94,0x46,0x96,0x4d,0x96,0x4a,0x96,0x59,0x97,0x4c,0x98,0x52,0x9b,0x4c, 0xa0,0x53,0x9f,0x4d,0x9e,0x4f,0x9d,0x4c,0x9e,0x52,0x99,0x4a,0x95,0x53,0x95,0x42, 0x96,0x55,0x96,0x4d,0x96,0x52,0x96,0x48,0x9b,0x58,0x9e,0x4a,0xa1,0x53,0xa2,0x4b, 0xa1,0x55,0xa0,0x49,0x9f,0x4f,0x9d,0x4d,0x98,0x54,0x96,0x4d,0x96,0x54,0x95,0x4a, 0x96,0x55,0x98,0x4e,0x9a,0x4f,0x9d,0x4d,0xa1,0x55,0xa2,0x45,0xa1,0x4a,0xa0,0x41, 0x9f,0x4f,0x9c,0x47,0x9a,0x4f,0x95,0x48,0x95,0x57,0x93,0x4f,0x9c,0x33,0x9e,0x33, 0xa3,0x38,0xa6,0x3b,0xa7,0x48,0xa8,0x3a,0xa8,0x48,0xa8,0x3a,0xa3,0x3b,0x9f,0x33, 0x9d,0x40,0x9c,0x35,0x99,0x3c,0x9a,0x34,0x9d,0x3f,0x9f,0x35,0xa3,0x3d,0xa4,0x34, 0xa8,0x41,0xa8,0x34,0xa8,0x3e,0xa7,0x36,0xa5,0x41,0xa2,0x36,0x9e,0x3c,0x9c,0x39, 0x9c,0x3a,0x9c,0x36,0x9f,0x39,0xa0,0x34,0xa4,0x3f,0xa8,0x35,0xaa,0x39,0xaa,0x33, 0xac,0x3e,0xab,0x33,0xa9,0x37,0xa4,0x32,0xa3,0x3e,0xa1,0x3b,0xa0,0x3d,0xa1,0x35, 0xa0,0x3e,0xa0,0x37,0xa4,0x3a,0xa8,0x31,0xa9,0x43,0xab,0x35,0xab,0x3d,0xaa,0x35, 0xaa,0x3b,0xa5,0x35,0xa1,0x3c,0x9f,0x32,0xa0,0x3f,0xa1,0x37,0xa0,0x3e,0x9f,0x32, 0xa3,0x38,0xa5,0x32,0xaa,0x3a,0xa9,0x35,0xab,0x3b,0xab,0x34,0xa7,0x38,0xa4,0x32, 0xa3,0x3d,0xa1,0x35,0x9f,0x3a,0x9f,0x34,0xa1,0x42,0xa1,0x35,0xa4,0x3e,0xa8,0x32, 0xab,0x3b,0xaa,0x36,0xad,0x3a,0xac,0x35,0xab,0x41,0xa8,0x31,0xa4,0x3f,0xa1,0x36, 0xa2,0x3b,0x9f,0x36,0xa0,0x3b,0xa1,0x38,0xa3,0x40,0xa7,0x36,0xaa,0x3b,0xaa,0x39, 0xad,0x3e,0xaa,0x35,0xaa,0x3c,0xa7,0x37,0xa4,0x3f,0x9f,0x33,0x9e,0x3b,0x9d,0x37, 0x9f,0x3d,0x9e,0x33,0xa2,0x3f,0xa5,0x37,0xa7,0x3b,0xaa,0x37,0xab,0x35,0xaa,0x38, 0xa7,0x41,0xa6,0x34,0xa3,0x3e,0x9f,0x35,0x9e,0x3b,0x9c,0x32,0x9d,0x40,0x9d,0x34, 0xa0,0x3c,0xa4,0x35,0xa6,0x3a,0xa9,0x38,0xa9,0x40,0xa9,0x30,0xa9,0x3e,0xa7,0x36, 0xa4,0x3f,0xa0,0x37,0x9f,0x3a,0x9d,0x33,0x9d,0x3d,0x9b,0x36,0x9f,0x3e,0xa4,0x33, 0xa5,0x3c,0xa6,0x37,0xa9,0x3b,0xaa,0x35,0xa7,0x40,0xa6,0x32,0xa4,0x37,0xa1,0x39, 0x9f,0x3d,0x9e,0x35,0x9e,0x37,0x9d,0x32,0xa0,0x43,0xa2,0x34,0xa6,0x3d,0xa9,0x38, 0xaa,0x41,0xaa,0x38,0xaa,0x3e,0xa7,0x35,0xa5,0x3d,0xa2,0x31,0xa0,0x3a,0x9e,0x36, 0x9e,0x3b,0x9f,0x38,0xa1,0x3a,0xa4,0x36,0xa6,0x3f,0xa8,0x35,0xab,0x3b,0xab,0x32, 0xab,0x3e,0xa9,0x33,0xa6,0x3e,0xa2,0x33,0xa0,0x43,0x9f,0x32,0x9f,0x3b,0x9f,0x39, 0xa0,0x3c,0xa0,0x36,0xa6,0x39,0xa8,0x37,0xab,0x42,0xaa,0x35,0xaa,0x3c,0xa8,0x31, 0xa5,0x3d,0xa1,0x37,0xa0,0x3c,0x9e,0x32,0x9d,0x40,0x9d,0x34,0x9f,0x3f,0xa2,0x33, 0xa5,0x3a,0xa8,0x39,0xab,0x39,0xab,0x35,0xaa,0x40,0xaa,0x34,0xa9,0x3d,0xa3,0x35, 0xa3,0x3f,0x9e,0x35,0x9e,0x3e,0x9f,0x34,0x9f,0x43,0xa0,0x32,0xa7,0x3f,0xa8,0x31, 0xab,0x3d,0xab,0x32,0xab,0x41,0xa9,0x38,0xa5,0x3d,0xa2,0x38,0x9f,0x3b,0x9c,0x35, 0x9c,0x3b,0x9d,0x32,0x9d,0x3d,0x9f,0x34,0xa3,0x43,0xa7,0x37,0xa8,0x3c,0xaa,0x38, 0xab,0x3d,0xa9,0x34,0xa6,0x3b,0xa4,0x37,0x9f,0x40,0x9c,0x33,0x9d,0x39,0x9c,0x34, 0x9d,0x3d,0xa0,0x32,0xa3,0x3a,0xa6,0x37,0xa9,0x42,0xaa,0x35,0xaa,0x3e,0xa8,0x31, 0xa8,0x3d,0xa5,0x36,0xa2,0x3c,0xa0,0x37,0x9e,0x3d,0x9e,0x36,0x9e,0x43,0xa0,0x35, 0xa2,0x43,0xa6,0x37,0xa9,0x39,0xa9,0x34,0xaa,0x40,0xa9,0x36,0xa8,0x3d,0xa5,0x3a, 0xa3,0x3d,0x9d,0x38,0x9d,0x3d,0x9d,0x34,0x9e,0x40,0x9e,0x38,0xa1,0x42,0xa4,0x34, 0xa9,0x3e,0xa8,0x37,0xaa,0x3b,0xaa,0x35,0xa9,0x45,0xa4,0x38,0xa1,0x3c,0x9f,0x36, 0x9e,0x3f,0x9d,0x35,0x9e,0x3e,0x9e,0x38,0x9f,0x41,0xa4,0x36,0xa6,0x3e,0xa8,0x38, 0xaa,0x3b,0xaa,0x37,0xa7,0x3e,0xa4,0x38,0xa0,0x41,0x9e,0x39,0x9d,0x3c,0x9d,0x38, 0x9c,0x44,0x9d,0x34,0xa1,0x3c,0xa4,0x35,0xa8,0x42,0xa6,0x38,0xa8,0x3f,0xa8,0x37, 0xa8,0x3e,0xa2,0x36,0x9f,0x3f,0x9e,0x38,0x9b,0x42,0x99,0x36,0x9a,0x41,0x9e,0x37, 0x9e,0x40,0xa1,0x39,0xa4,0x3d,0xa6,0x37,0xa8,0x42,0xa8,0x3a,0xa5,0x3e,0xa3,0x37, 0xa1,0x3f,0x9b,0x34,0x9c,0x38,0x9a,0x39,0x9a,0x40,0x9a,0x35,0x9e,0x3c,0xa0,0x33, 0xa5,0x3d,0xa6,0x3a,0xa7,0x3c,0xa8,0x38,0xa7,0x40,0xa4,0x3a,0xa1,0x38,0x9f,0x35, 0x9d,0x41,0x9d,0x39,0x9c,0x3c,0x9b,0x34,0x9c,0x40,0x9f,0x36,0xa3,0x3c,0xa5,0x37, 0xa7,0x3d,0xa7,0x37,0xa6,0x39,0xa3,0x38,0xa3,0x41,0x9f,0x38,0x9c,0x3f,0x9c,0x37, 0x9e,0x3f,0x9d,0x38,0x9e,0x3b,0xa0,0x38,0xa4,0x43,0xa7,0x37,0xa8,0x3f,0xa8,0x35, 0xa9,0x40,0xa6,0x37,0xa5,0x3e,0xa1,0x35,0x9e,0x3e,0x9c,0x35,0x9b,0x40,0x9c,0x33, 0x9d,0x40,0x9f,0x32,0xa2,0x3c,0xa3,0x34,0xa7,0x45,0xa8,0x37,0xa5,0x41,0xa5,0x34, 0xa5,0x3c,0x9f,0x38,0x9e,0x3b,0x9c,0x36,0x9c,0x42,0x9b,0x3a,0x9b,0x40,0x9f,0x37, 0xa2,0x41,0xa6,0x37,0xa9,0x3d,0xaa,0x36,0xa9,0x42,0xa7,0x38,0xa5,0x40,0xa1,0x37, 0xa0,0x41,0x9e,0x36,0x9c,0x3b,0x9d,0x30,0x9e,0x3f,0x9e,0x34,0xa3,0x3d,0xa5,0x36, 0xa7,0x40,0xa7,0x32,0xa8,0x3d,0xa6,0x30,0xa4,0x42,0xa1,0x33,0x9e,0x41,0x9e,0x36, 0x9e,0x3d,0x9d,0x35,0x9d,0x41,0xa0,0x37,0xa3,0x40,0xa6,0x3b,0xaa,0x3e,0xaa,0x37, 0xaa,0x3e,0xa8,0x32,0xa5,0x43,0xa3,0x37,0x9f,0x3f,0x9d,0x37,0x9d,0x3c,0x9c,0x35, 0x9d,0x3f,0x9f,0x32,0xa2,0x3e,0xa6,0x35,0xa8,0x3f,0xa8,0x36,0xaa,0x3d,0xa9,0x36, 0xa6,0x40,0xa2,0x3b,0xa1,0x3c,0x9d,0x36,0x9c,0x3e,0x9c,0x36,0x9a,0x43,0x9c,0x35, 0xa0,0x41,0xa4,0x35,0xa5,0x3c,0xa6,0x34,0xa8,0x46,0xa7,0x38,0xa5,0x3a,0xa3,0x36, 0xa1,0x42,0x9e,0x37,0x9e,0x3f,0x9e,0x34,0x9a,0x40,0x9c,0x36,0xa2,0x42,0xa4,0x35, 0xa4,0x3c,0xa8,0x37,0xab,0x3c,0xa8,0x39,0xa6,0x42,0xa4,0x37,0xa1,0x40,0xa1,0x3a, 0x9f,0x3e,0x9e,0x36,0xa0,0x3e,0xa0,0x35,0xa2,0x42,0xa4,0x34,0xa8,0x3e,0xa8,0x3d, 0xaa,0x44,0xaa,0x37,0xa7,0x31,0xa5,0x2c,0xa3,0x38,0xa0,0x32,0x9f,0x3b,0x9d,0x37, 0x9c,0x40,0x9a,0x3d,0xa7,0x4d,0xaa,0x3f,0xaf,0x4f,0xae,0x4b,0xaf,0x58,0xad,0x52, 0xab,0x51,0xa9,0x48,0xa6,0x4f,0xa4,0x49,0xa1,0x51,0xa2,0x45,0xa4,0x4a,0xa6,0x49, 0xa9,0x4a,0xac,0x45,0xae,0x4f,0xb0,0x41,0xb1,0x4d,0xaf,0x44,0xad,0x4a,0xaa,0x47, 0xa7,0x52,0xa4,0x46,0xa4,0x4e,0xa4,0x44,0xa4,0x54,0xa6,0x48,0xa9,0x4c,0xac,0x47, 0xaf,0x4a,0xb1,0x47,0xb2,0x4f,0xaf,0x4d,0xae,0x52,0xac,0x47,0xa9,0x4c,0xa6,0x46, 0xa6,0x50,0xa4,0x44,0xa7,0x4e,0xa5,0x42,0xa7,0x50,0xac,0x44,0xad,0x4c,0xaf,0x45, 0xad,0x50,0xaf,0x46,0xac,0x50,0xab,0x41,0xaa,0x4f,0xa5,0x45,0xa4,0x50,0xa3,0x46, 0xa6,0x4e,0xa3,0x43,0xa6,0x4e,0xaa,0x46,0xac,0x50,0xaf,0x47,0xb2,0x4e,0xb0,0x44, 0xae,0x4d,0xaa,0x43,0xab,0x4c,0xa4,0x45,0xa2,0x4e,0xa2,0x46,0xa5,0x48,0xa4,0x47, 0xa8,0x4c,0xac,0x4a,0xb0,0x4e,0xb1,0x48,0xb2,0x4e,0xb2,0x48,0xb1,0x4d,0xae,0x47, 0xaa,0x52,0xa8,0x46,0xa8,0x49,0xa4,0x42,0xa4,0x50,0xa5,0x43,0xa8,0x4d,0xaa,0x46, 0xac,0x4f,0xaf,0x49,0xb1,0x4a,0xae,0x47,0xaf,0x50,0xb0,0x48,0xab,0x4c,0xa8,0x46, 0xa8,0x4e,0xa7,0x3f,0xa7,0x4d,0xa6,0x44,0xab,0x4e,0xad,0x47,0xb0,0x4e,0xb1,0x43, 0xb5,0x4d,0xb5,0x47,0xb5,0x4a,0xb3,0x44,0xae,0x4a,0xaa,0x47,0xaa,0x4d,0xa7,0x49, 0xa4,0x4f,0xa4,0x46,0xa9,0x4c,0xaa,0x47,0xac,0x50,0xb2,0x49,0xb4,0x4f,0xb3,0x46, 0xb5,0x4d,0xb2,0x45,0xb0,0x4a,0xac,0x42,0xaa,0x4c,0xaa,0x41,0xac,0x4e,0xa9,0x47, 0xab,0x4e,0xad,0x46,0xb0,0x4f,0xb4,0x47,0xb5,0x4d,0xb4,0x45,0xb5,0x4c,0xb4,0x46, 0xb2,0x4e,0xad,0x47,0xac,0x4c,0xab,0x45,0xaa,0x50,0xa8,0x45,0xac,0x4f,0xad,0x4b, 0xb0,0x4d,0xb0,0x4a,0xb3,0x4c,0xb4,0x48,0xb3,0x4e,0xb1,0x43,0xb1,0x4e,0xac,0x46, 0xab,0x4c,0xaa,0x44,0xa9,0x50,0xa8,0x43,0xaa,0x54,0xab,0x49,0xb0,0x4f,0xb2,0x47, 0xb6,0x4e,0xb6,0x4b,0xb7,0x4f,0xb6,0x4a,0xb3,0x4f,0xaf,0x47,0xac,0x4c,0xa9,0x47, 0xaa,0x50,0xa7,0x47,0xa9,0x49,0xaa,0x46,0xaf,0x50,0xb2,0x45,0xb4,0x4b,0xb4,0x48, 0xb6,0x4c,0xb2,0x47,0xaf,0x4b,0xab,0x47,0xaa,0x4f,0xa7,0x45,0xa6,0x4b,0xa7,0x49, 0xa9,0x4f,0xaa,0x46,0xaf,0x49,0xb1,0x4a,0xb5,0x4e,0xb6,0x47,0xb7,0x4f,0xb4,0x44, 0xb1,0x4e,0xaf,0x4b,0xac,0x4a,0xa8,0x43,0xaa,0x4f,0xa9,0x46,0xab,0x4f,0xaa,0x46, 0xad,0x50,0xb0,0x44,0xb5,0x4b,0xb4,0x46,0xb5,0x52,0xb5,0x46,0xb6,0x4c,0xb0,0x45, 0xac,0x50,0xac,0x44,0xac,0x4a,0xa7,0x43,0xa9,0x4e,0xac,0x47,0xae,0x4c,0xb0,0x45, 0xb5,0x4f,0xb6,0x49,0xb6,0x4e,0xb5,0x41,0xb5,0x4e,0xb0,0x46,0xae,0x4b,0xab,0x46, 0xa8,0x53,0xa9,0x43,0xa8,0x4e,0xa8,0x45,0xab,0x49,0xad,0x48,0xb2,0x4d,0xb5,0x4a, 0xb5,0x50,0xb5,0x44,0xb4,0x4f,0xb0,0x42,0xad,0x4a,0xaa,0x46,0xa7,0x4b,0xa6,0x49, 0xa7,0x4d,0xa7,0x43,0xa9,0x4d,0xad,0x45,0xb2,0x50,0xb2,0x48,0xb4,0x4b,0xb5,0x49, 0xb4,0x4e,0xad,0x46,0xab,0x50,0xaa,0x45,0xa7,0x4f,0xa6,0x44,0xa7,0x4d,0xa9,0x4a, 0xaa,0x50,0xae,0x4a,0xb3,0x4d,0xb3,0x4a,0xb4,0x4e,0xb4,0x49,0xb3,0x4a,0xb0,0x49, 0xae,0x4c,0xab,0x46,0xa9,0x4c,0xa6,0x45,0xa7,0x51,0xa8,0x47,0xa9,0x4c,0xac,0x43, 0xb0,0x4f,0xb2,0x47,0xb3,0x50,0xb3,0x40,0xb3,0x53,0xb2,0x4a,0xaf,0x51,0xab,0x46, 0xaa,0x4c,0xab,0x49,0xab,0x4f,0xa9,0x47,0xaa,0x4d,0xae,0x46,0xb1,0x4d,0xb0,0x44, 0xb3,0x52,0xb2,0x4b,0xb0,0x4f,0xad,0x45,0xad,0x4f,0xaa,0x46,0xa6,0x4c,0xa7,0x49, 0xa6,0x4e,0xa4,0x45,0xa7,0x55,0xab,0x46,0xac,0x4e,0xad,0x41,0xb2,0x54,0xb2,0x47, 0xb1,0x4e,0xaf,0x46,0xad,0x4f,0xa8,0x45,0xa7,0x50,0xa6,0x48,0xa5,0x4a,0xa4,0x45, 0xa7,0x52,0xa9,0x47,0xad,0x4d,0xae,0x47,0xb1,0x4d,0xb0,0x47,0xaf,0x4c,0xab,0x44, 0xaa,0x50,0xa8,0x47,0xa7,0x4b,0xa5,0x47,0xa8,0x4e,0xa7,0x49,0xa7,0x4b,0xaa,0x44, 0xae,0x4f,0xaf,0x46,0xb2,0x4d,0xb3,0x45,0xb2,0x50,0xb1,0x47,0xb0,0x4c,0xab,0x47, 0xa9,0x4c,0xa6,0x48,0xa5,0x4c,0xa6,0x49,0xa6,0x4e,0xa6,0x44,0xac,0x4c,0xae,0x49, 0xaf,0x4b,0xb0,0x49,0xb1,0x4c,0xaf,0x41,0xad,0x52,0xab,0x47,0xa9,0x4f,0xa6,0x48, 0xa6,0x50,0xa8,0x46,0xa8,0x4b,0xa7,0x46,0xab,0x53,0xaf,0x47,0xb2,0x4d,0xb1,0x43, 0xb2,0x4e,0xb1,0x47,0xae,0x50,0xaa,0x45,0xa7,0x53,0xa5,0x47,0xa6,0x4d,0xa4,0x4a, 0xa5,0x4d,0xa7,0x47,0xab,0x50,0xae,0x44,0xb0,0x50,0xb4,0x47,0xb3,0x4f,0xb1,0x49, 0xb1,0x4d,0xaf,0x46,0xaa,0x4c,0xa6,0x47,0xa8,0x4b,0xa7,0x45,0xa7,0x4f,0xa7,0x48, 0xab,0x4c,0xad,0x49,0xb0,0x4b,0xb1,0x48,0xb0,0x53,0xb0,0x47,0xaf,0x4f,0xad,0x44, 0xaa,0x50,0xa7,0x46,0xa7,0x4a,0xa6,0x47,0xa0,0x50,0xa1,0x46,0xaa,0x4b,0xac,0x45, 0xac,0x4e,0xae,0x46,0xb5,0x4a,0xb2,0x41,0xb1,0x4e,0xaf,0x46,0xac,0x4b,0xa9,0x45, 0xab,0x4f,0xa7,0x48,0x9e,0x4a,0x9f,0x43,0xad,0x4e,0xa5,0x45,0xa2,0x52,0xb1,0x47, 0xb5,0x4d,0xaf,0x48,0xb1,0x4d,0xae,0x42,0xab,0x51,0xa8,0x43,0xa8,0x4f,0xa9,0x47, 0xa9,0x4d,0xa8,0x48,0xaa,0x4c,0xab,0x47,0xaf,0x4f,0xb2,0x49,0xb4,0x4c,0xb0,0x46, 0xb1,0x4c,0xb0,0x49,0xab,0x4a,0xa7,0x44,0xa7,0x4e,0xa7,0x46,0xa6,0x4c,0xa5,0x47, 0xa8,0x4a,0xaa,0x44,0xac,0x4b,0xaf,0x49,0xb1,0x51,0xb0,0x46,0xb0,0x4e,0xac,0x46, 0xab,0x4f,0xa9,0x49,0xa5,0x4d,0xa5,0x43,0xa7,0x52,0xa6,0x46,0xa8,0x4a,0xa9,0x42, 0xae,0x4c,0xb0,0x46,0xb1,0x50,0xaf,0x48,0xb1,0x4f,0xad,0x42,0xa9,0x45,0xa6,0x3f, 0xa4,0x50,0xa2,0x47,0xa3,0x4e,0xa4,0x46,0xa6,0x4d,0xa4,0x4a,0xb5,0x1c,0xb6,0x0f, 0xb7,0x1d,0xb6,0x17,0xb6,0x28,0xb1,0x19,0xae,0x20,0xab,0x13,0xaa,0x1d,0xa7,0x14, 0xa9,0x1e,0xa8,0x16,0xa8,0x1c,0xab,0x12,0xb1,0x1c,0xb0,0x14,0xb2,0x1e,0xb3,0x17, 0xb2,0x20,0xaf,0x17,0xac,0x1a,0xa9,0x13,0xa8,0x1f,0xa5,0x12,0xa7,0x1f,0xa7,0x17, 0xaa,0x1b,0xad,0x11,0xb1,0x1b,0xb1,0x15,0xb4,0x20,0xb4,0x14,0xb2,0x1c,0xb0,0x14, 0xac,0x20,0xa8,0x15,0xa4,0x1a,0xa3,0x15,0xa4,0x1b,0xa3,0x19,0xa5,0x19,0xa9,0x14, 0xae,0x1d,0xb0,0x13,0xb1,0x1d,0xb1,0x15,0xb1,0x1e,0xae,0x13,0xaa,0x16,0xa6,0x15, 0xa6,0x1d,0xa4,0x10,0xa4,0x1a,0xa5,0x16,0xa7,0x1d,0xa6,0x14,0xab,0x19,0xae,0x14, 0xad,0x1c,0xad,0x11,0xae,0x1d,0xa7,0x14,0xa7,0x19,0xa3,0x18,0x9f,0x1b,0x9e,0x18, 0x9c,0x1a,0x9f,0x0f,0xa3,0x18,0xa2,0x0f,0xa6,0x19,0xaa,0x15,0xae,0x19,0xaf,0x17, 0xae,0x19,0xac,0x15,0xaa,0x1f,0xa6,0x13,0xa4,0x19,0xa2,0x16,0xa4,0x1d,0xa3,0x13, 0xa3,0x1d,0xa3,0x11,0xaa,0x1b,0xaa,0x12,0xad,0x1e,0xae,0x14,0xaf,0x1c,0xaa,0x14, 0xaa,0x1c,0xa6,0x13,0xa3,0x1d,0x9f,0x13,0xa1,0x1d,0xa0,0x15,0xa1,0x1d,0xa3,0x13, 0xa7,0x1d,0xa9,0x12,0xac,0x1c,0xac,0x15,0xac,0x1e,0xab,0x14,0xa8,0x18,0xa5,0x14, 0xa2,0x17,0x9f,0x10,0x9e,0x1b,0x9f,0x17,0xa1,0x1e,0xa1,0x15,0xa4,0x1a,0xa7,0x18, 0xab,0x1e,0xab,0x14,0xac,0x1c,0xaa,0x12,0xaa,0x19,0xa6,0x16,0xa4,0x1d,0xa1,0x13, 0x9f,0x1b,0xa0,0x14,0x9f,0x1f,0x9f,0x12,0xa5,0x1a,0xa8,0x19,0xaa,0x1d,0xab,0x17, 0xad,0x1c,0xab,0x12,0xaa,0x1b,0xa4,0x14,0xa3,0x1f,0x9f,0x13,0x9e,0x22,0x9e,0x15, 0x9f,0x20,0x9f,0x18,0xa3,0x1d,0xa5,0x12,0xa9,0x1b,0xaa,0x15,0xab,0x1b,0xab,0x18, 0xa8,0x1a,0xa7,0x15,0xa4,0x20,0xa1,0x14,0xa1,0x1d,0xa0,0x10,0xa1,0x19,0x9e,0x15, 0xa1,0x1f,0xa5,0x14,0xa7,0x1a,0xa6,0x14,0xa9,0x1f,0xa9,0x17,0xa7,0x19,0xa5,0x16, 0xa4,0x1b,0xa2,0x19,0xa1,0x1e,0x9f,0x12,0xa1,0x1e,0x9f,0x15,0xa2,0x1c,0xa3,0x12, 0xa6,0x16,0xa5,0x17,0xaa,0x1d,0xa6,0x15,0xa6,0x1e,0xa4,0x10,0xa4,0x1e,0x9f,0x11, 0x9e,0x22,0x9f,0x18,0x9e,0x1e,0xa0,0x13,0xa2,0x20,0xa4,0x15,0xa8,0x1c,0xaa,0x17, 0xab,0x1d,0xa9,0x13,0xa9,0x18,0xa6,0x12,0xa5,0x1f,0x9e,0x11,0x9d,0x1b,0x9c,0x11, 0x9e,0x1e,0x9e,0x14,0xa0,0x1e,0xa1,0x12,0xa5,0x1c,0xa8,0x15,0xaa,0x1c,0xa9,0x14, 0xa9,0x1c,0xa6,0x17,0xa4,0x1c,0xa0,0x13,0xa0,0x1c,0x9e,0x13,0x9e,0x1d,0x9f,0x17, 0xa2,0x1f,0xa2,0x17,0xa6,0x1e,0xa6,0x16,0xaa,0x1e,0xa8,0x18,0xa9,0x18,0xa6,0x14, 0xa3,0x19,0xa0,0x13,0xa0,0x1d,0x9e,0x16,0x9e,0x1f,0x9d,0x10,0xa0,0x1c,0x9f,0x16, 0xa2,0x20,0xa5,0x12,0xa8,0x1b,0xa6,0x15,0xa6,0x21,0xa6,0x16,0xa3,0x1f,0x9f,0x13, 0x9e,0x18,0x9c,0x19,0x9e,0x17,0x9e,0x15,0x9d,0x20,0xa1,0x16,0xa5,0x20,0xa7,0x14, 0xa9,0x1e,0xa9,0x16,0xa8,0x1d,0xa6,0x13,0xa3,0x22,0xa2,0x18,0x9f,0x1e,0x9d,0x14, 0x9f,0x1f,0x9d,0x16,0x9d,0x1d,0xa0,0x1a,0xa3,0x19,0xa3,0x12,0xa6,0x1d,0xa6,0x16, 0xa7,0x1e,0xa3,0x14,0xa2,0x1e,0x9d,0x12,0x9c,0x20,0x9b,0x16,0x9a,0x20,0x9a,0x16, 0x9c,0x1f,0x9f,0x19,0xa3,0x1d,0xa3,0x19,0xa5,0x21,0xa7,0x18,0xa7,0x1d,0xa3,0x15, 0xa4,0x1f,0x9f,0x15,0x9c,0x19,0x9a,0x12,0x9b,0x21,0x9a,0x16,0x9b,0x1c,0x9b,0x17, 0xa0,0x1b,0xa3,0x17,0xa5,0x1f,0xa5,0x14,0xa5,0x1c,0xa5,0x1a,0xa2,0x1b,0x9e,0x12, 0x9b,0x20,0x9a,0x18,0x9b,0x1f,0x98,0x17,0x97,0x20,0x9b,0x15,0x9e,0x1c,0xa0,0x18, 0xa2,0x22,0xa4,0x14,0xa2,0x20,0xa4,0x1a,0xa3,0x20,0x9e,0x14,0x9c,0x1d,0x9a,0x17, 0x9b,0x1d,0x99,0x15,0x99,0x1e,0x9a,0x17,0xa0,0x1f,0xa1,0x16,0xa2,0x21,0xa5,0x1a, 0xa6,0x1e,0xa3,0x17,0xa2,0x1b,0x9e,0x13,0x9c,0x1d,0x9a,0x19,0x9a,0x1d,0x99,0x15, 0x99,0x1d,0x99,0x14,0x9d,0x1d,0x9d,0x16,0x9f,0x1d,0xa0,0x18,0xa3,0x1f,0xa2,0x15, 0x9f,0x1d,0x9e,0x18,0x9d,0x1e,0x99,0x19,0x99,0x20,0x99,0x15,0x9a,0x1f,0x9c,0x17, 0x9d,0x1d,0x9f,0x18,0xa2,0x1f,0xa2,0x15,0xa4,0x1f,0xa4,0x13,0xa2,0x1d,0xa0,0x18, 0x9d,0x20,0x9b,0x1a,0x98,0x20,0x97,0x15,0x96,0x20,0x97,0x14,0x99,0x1f,0x9d,0x16, 0x9e,0x20,0xa0,0x19,0xa2,0x1d,0xa2,0x14,0xa0,0x22,0x9e,0x16,0x9c,0x1d,0x98,0x16, 0x97,0x21,0x96,0x17,0x96,0x1e,0x96,0x12,0x98,0x20,0x9c,0x1b,0xa0,0x1f,0xa0,0x14, 0xa3,0x1a,0xa3,0x19,0xa1,0x21,0x9e,0x17,0x9c,0x23,0x99,0x17,0x99,0x1e,0x98,0x17, 0x99,0x1d,0x98,0x12,0x99,0x1d,0x9b,0x16,0xa0,0x1c,0xa0,0x18,0xa1,0x1e,0xa1,0x19, 0xa0,0x1c,0x9d,0x19,0x9b,0x1e,0x97,0x19,0x97,0x1d,0x95,0x12,0x97,0x1f,0x95,0x10, 0x97,0x20,0x9a,0x18,0x9c,0x20,0x9f,0x11,0xa2,0x1e,0xa1,0x18,0xa1,0x1d,0x9d,0x1a, 0x9b,0x22,0x98,0x17,0x96,0x1c,0x95,0x17,0x95,0x22,0x96,0x15,0x98,0x1c,0x98,0x14, 0x9c,0x1f,0x9f,0x17,0x9f,0x1b,0x9e,0x19,0xa0,0x1e,0x9f,0x18,0x9b,0x1b,0x99,0x19, 0x97,0x21,0x97,0x15,0x96,0x1b,0x95,0x19,0x95,0x1e,0x96,0x1d,0x9a,0x20,0x9a,0x17, 0x9e,0x24,0x9f,0x15,0x9d,0x1c,0x9b,0x17,0x9c,0x1d,0x98,0x16,0x96,0x1d,0x94,0x19, 0x95,0x1e,0x94,0x16,0x94,0x1b,0x97,0x17,0x9b,0x1c,0x9d,0x16,0x9f,0x1f,0xa0,0x18, 0x9f,0x20,0x9c,0x15,0x9c,0x21,0x98,0x16,0x97,0x1c,0x96,0x19,0x95,0x1a,0x96,0x14, 0x95,0x1b,0x97,0x16,0x9a,0x1a,0x9c,0x13,0xa0,0x1e,0x9f,0x11,0x9f,0x25,0x9e,0x18, 0x9c,0x24,0x98,0x16,0x97,0x12,0x96,0x0d,0x96,0x1c,0x94,0x17,0x95,0x1d,0x96,0x16, 0x9a,0x1f,0x9a,0x1e,0xa4,0x5d,0xa4,0x60,0xa4,0x6b,0xa1,0x6b,0x9f,0x75,0x9b,0x6e, 0x9a,0x73,0x98,0x66,0x99,0x6c,0x98,0x63,0x9a,0x6b,0x9c,0x63,0xa0,0x6e,0xa1,0x61, 0xa3,0x6f,0xa3,0x63,0xa3,0x6a,0x9f,0x5f,0x9e,0x6d,0x9b,0x65,0x99,0x69,0x97,0x62, 0x9a,0x6c,0x98,0x63,0x9a,0x6c,0x9a,0x61,0xa0,0x6b,0xa1,0x61,0xa2,0x65,0xa3,0x63, 0xa5,0x6a,0xa2,0x64,0x9f,0x67,0x9c,0x61,0x99,0x6a,0x98,0x60,0x98,0x6b,0x96,0x60, 0x98,0x6a,0x9b,0x62,0x9c,0x69,0x9f,0x62,0xa4,0x6b,0xa4,0x62,0xa2,0x68,0xa2,0x63, 0xa0,0x6a,0x9c,0x61,0x9a,0x6d,0x99,0x67,0x9a,0x6d,0x98,0x63,0x99,0x6c,0x99,0x61, 0x9e,0x6e,0x9f,0x64,0xa1,0x66,0xa1,0x64,0xa2,0x6a,0xa1,0x62,0x9f,0x6b,0x9b,0x64, 0x99,0x6c,0x96,0x67,0x95,0x66,0x96,0x65,0x97,0x69,0x98,0x63,0x9a,0x6a,0x9d,0x62, 0xa1,0x68,0xa0,0x64,0xa0,0x6b,0x9f,0x61,0x9f,0x70,0x9c,0x5d,0x99,0x66,0x98,0x60, 0x98,0x6f,0x99,0x63,0x98,0x67,0x99,0x61,0x9d,0x69,0x9f,0x60,0xa0,0x6c,0xa1,0x64, 0xa1,0x71,0x9f,0x61,0x9e,0x6c,0x9a,0x61,0x99,0x6a,0x97,0x62,0x98,0x69,0x96,0x61, 0x99,0x6c,0x99,0x62,0x9c,0x6a,0x9c,0x60,0xa1,0x6b,0xa0,0x60,0xa0,0x6a,0xa0,0x5e, 0x9f,0x6f,0x9c,0x62,0x99,0x69,0x96,0x65,0x96,0x69,0x96,0x5d,0x97,0x6c,0x97,0x5f, 0x98,0x6d,0x9c,0x62,0x9c,0x65,0x94,0x61,0x98,0x69,0x9c,0x62,0x92,0x68,0x8d,0x5f, 0x95,0x6d,0x95,0x5f,0x91,0x69,0x95,0x65,0x97,0x6d,0x96,0x64,0x98,0x68,0x9b,0x61, 0x9e,0x6e,0x9f,0x63,0x9f,0x67,0x9f,0x62,0x9d,0x72,0x9a,0x62,0x98,0x67,0x94,0x60, 0x93,0x69,0x93,0x5f,0x93,0x69,0x93,0x63,0x95,0x6b,0x98,0x64,0x9a,0x6a,0x9b,0x62, 0x9d,0x6b,0x9d,0x5f,0x9c,0x6a,0x99,0x64,0x97,0x6d,0x93,0x64,0x91,0x6b,0x8f,0x64, 0x92,0x6c,0x92,0x65,0x92,0x64,0x95,0x62,0x9c,0x6e,0x9c,0x5f,0x9d,0x6b,0x9c,0x65, 0x9c,0x68,0x99,0x62,0x97,0x6a,0x94,0x66,0x92,0x69,0x91,0x64,0x92,0x6c,0x91,0x63, 0x94,0x6e,0x97,0x62,0x99,0x6d,0x9c,0x62,0x9e,0x6d,0x9d,0x5f,0x9d,0x6a,0x9a,0x61, 0x98,0x68,0x94,0x64,0x94,0x68,0x93,0x63,0x93,0x6f,0x92,0x63,0x95,0x6a,0x96,0x60, 0x9a,0x70,0x9b,0x62,0x9d,0x68,0x9d,0x60,0x9e,0x6d,0x99,0x60,0x98,0x6d,0x95,0x63, 0x93,0x6b,0x92,0x67,0x92,0x67,0x92,0x63,0x94,0x6d,0x97,0x63,0x98,0x6c,0x9a,0x64, 0x9e,0x6a,0x9d,0x61,0x9c,0x6b,0x9b,0x66,0x99,0x6f,0x96,0x5f,0x95,0x6b,0x92,0x64, 0x93,0x6e,0x93,0x63,0x94,0x6a,0x96,0x67,0x97,0x6b,0x9b,0x66,0x9c,0x6a,0x9a,0x62, 0x9b,0x6b,0x98,0x64,0x97,0x68,0x93,0x62,0x93,0x6d,0x92,0x64,0x93,0x6d,0x91,0x60, 0x93,0x6c,0x95,0x5f,0x98,0x6c,0x99,0x61,0x9b,0x6e,0x9c,0x63,0x9c,0x67,0x9a,0x64, 0x99,0x6c,0x95,0x62,0x93,0x6a,0x93,0x64,0x8f,0x68,0x89,0x63,0x8e,0x67,0x96,0x67, 0x91,0x6f,0x92,0x65,0x9b,0x69,0x9c,0x61,0x9c,0x6e,0x9a,0x68,0x99,0x6c,0x95,0x67, 0x92,0x67,0x91,0x64,0x90,0x69,0x90,0x63,0x92,0x6f,0x92,0x62,0x95,0x6a,0x97,0x67, 0x9a,0x6e,0x9a,0x63,0x9a,0x6c,0x99,0x63,0x97,0x6d,0x94,0x68,0x92,0x6c,0x90,0x63, 0x8f,0x6b,0x8e,0x63,0x8f,0x6a,0x8e,0x60,0x93,0x6f,0x95,0x66,0x96,0x69,0x97,0x5e, 0x98,0x6d,0x96,0x65,0x95,0x6a,0x92,0x65,0x90,0x6f,0x8b,0x62,0x8b,0x6a,0x8c,0x63, 0x8d,0x6e,0x8d,0x64,0x90,0x67,0x95,0x68,0x96,0x6c,0x97,0x61,0x98,0x6c,0x97,0x62, 0x96,0x70,0x93,0x62,0x91,0x6b,0x90,0x63,0x90,0x6f,0x8e,0x65,0x91,0x6b,0x90,0x62, 0x93,0x69,0x97,0x5f,0x99,0x6d,0x9a,0x64,0x9c,0x6d,0x9a,0x66,0x99,0x6a,0x96,0x64, 0x95,0x69,0x91,0x62,0x90,0x6c,0x91,0x64,0x93,0x6f,0x92,0x66,0x94,0x6c,0x98,0x62, 0x9a,0x6f,0x9b,0x66,0x9c,0x6a,0x9b,0x64,0x9a,0x71,0x98,0x5f,0x94,0x70,0x91,0x62, 0x91,0x68,0x91,0x63,0x90,0x6a,0x91,0x67,0x92,0x71,0x96,0x63,0x98,0x73,0x9b,0x5f, 0x9b,0x6a,0x9b,0x67,0x99,0x6b,0x96,0x63,0x95,0x6f,0x91,0x66,0x8f,0x6c,0x90,0x63, 0x90,0x6e,0x90,0x63,0x92,0x67,0x94,0x66,0x9a,0x6f,0x9a,0x64,0x9b,0x6e,0x9b,0x64, 0x9a,0x6d,0x98,0x65,0x95,0x6c,0x93,0x64,0x92,0x6f,0x91,0x63,0x90,0x6c,0x91,0x65, 0x94,0x6f,0x94,0x66,0x97,0x70,0x9a,0x62,0x9c,0x73,0x9b,0x67,0x99,0x6d,0x97,0x62, 0x98,0x6f,0x93,0x67,0x91,0x6c,0x90,0x63,0x90,0x73,0x91,0x66,0x93,0x6e,0x92,0x63, 0x97,0x70,0x9a,0x62,0x9b,0x6e,0x9a,0x61,0x9a,0x6f,0x99,0x64,0x96,0x6d,0x92,0x63, 0x91,0x6d,0x90,0x64,0x90,0x6b,0x90,0x63,0x91,0x70,0x93,0x66,0x95,0x70,0x98,0x66, 0x9a,0x70,0x9a,0x65,0x98,0x72,0x99,0x67,0x96,0x70,0x92,0x5e,0x90,0x6d,0x91,0x67, 0x90,0x6c,0x8e,0x63,0x90,0x6c,0x92,0x67,0x95,0x73,0x97,0x69,0x99,0x6c,0x9a,0x67, 0x99,0x70,0x98,0x63,0x97,0x6c,0x93,0x63,0x92,0x75,0x90,0x64,0x8e,0x71,0x8f,0x67, 0x90,0x71,0x93,0x68,0x95,0x6b,0x98,0x66,0x9a,0x71,0x99,0x69,0x9b,0x6f,0x99,0x67, 0x97,0x6f,0x93,0x66,0x92,0x69,0x90,0x64,0x8f,0x71,0x91,0x5d,0x8f,0x70,0x91,0x64, 0x94,0x6e,0x96,0x6a,0x98,0x6f,0x99,0x69,0x98,0x75,0x98,0x67,0x96,0x73,0x93,0x66, 0x91,0x6f,0x8f,0x66,0x90,0x6a,0x8d,0x68,0x8e,0x6e,0x90,0x67,0x93,0x6f,0x95,0x69, 0x99,0x6e,0x9a,0x65,0x9a,0x6f,0x97,0x64,0x97,0x6d,0x94,0x63,0x91,0x6b,0x8e,0x66, 0x8e,0x6c,0x8e,0x62,0x8f,0x6e,0x8f,0x65,0x93,0x70,0x95,0x66,0x97,0x6b,0x98,0x64, 0x9a,0x6e,0x98,0x63,0x97,0x69,0x95,0x66,0x92,0x74,0x8e,0x61,0x8e,0x65,0x8f,0x5f, 0x8e,0x6a,0x8f,0x64,0x93,0x6e,0x96,0x61,0x97,0x72,0x97,0x6a,0x9c,0x5a,0x9a,0x50, 0x9a,0x58,0x96,0x5a,0x94,0x67,0x93,0x5e,0x93,0x64,0x93,0x56,0x94,0x5d,0x93,0x57, 0x99,0x5d,0x9b,0x52,0x9d,0x5d,0x9e,0x54,0x9f,0x66,0x9c,0x54,0x9b,0x61,0x99,0x56, 0x96,0x5c,0x94,0x54,0x94,0x5c,0x93,0x53,0x95,0x60,0x95,0x54,0x96,0x5f,0x99,0x56, 0x9e,0x5a,0x9c,0x55,0x9d,0x5b,0x9c,0x55,0x9c,0x62,0x98,0x53,0x97,0x5d,0x94,0x51, 0x93,0x61,0x93,0x54,0x94,0x5b,0x94,0x58,0x96,0x62,0x9a,0x4f,0x9c,0x5c,0x9d,0x55, 0x9f,0x5c,0x9c,0x53,0x9b,0x62,0x98,0x54,0x95,0x5d,0x93,0x58,0x93,0x5f,0x91,0x59, 0x93,0x5f,0x93,0x54,0x97,0x5f,0x98,0x51,0x9c,0x5e,0x9c,0x52,0x9d,0x5f,0x9b,0x53, 0x9a,0x5a,0x97,0x56,0x95,0x5f,0x93,0x55,0x91,0x5c,0x91,0x56,0x91,0x5e,0x91,0x55, 0x94,0x5c,0x98,0x56,0x99,0x59,0x9b,0x53,0x9b,0x62,0x9b,0x50,0x9a,0x60,0x97,0x50, 0x95,0x5e,0x92,0x55,0x92,0x5c,0x91,0x53,0x91,0x62,0x91,0x56,0x94,0x5c,0x95,0x53, 0x99,0x5c,0x9a,0x54,0x9a,0x5f,0x99,0x54,0x97,0x63,0x96,0x55,0x92,0x60,0x91,0x57, 0x91,0x5d,0x8e,0x52,0x8f,0x5a,0x90,0x55,0x91,0x60,0x93,0x57,0x98,0x5e,0x98,0x52, 0x9a,0x5c,0x9a,0x54,0x99,0x5c,0x96,0x55,0x94,0x5f,0x91,0x53,0x8f,0x62,0x8e,0x55, 0x90,0x5e,0x8e,0x52,0x90,0x5c,0x94,0x58,0x95,0x60,0x99,0x54,0x99,0x5d,0x98,0x55, 0x98,0x59,0x97,0x55,0x94,0x5c,0x90,0x56,0x8e,0x5e,0x8d,0x53,0x8e,0x5a,0x8d,0x53, 0x8f,0x5c,0x92,0x57,0x94,0x5d,0x97,0x51,0x99,0x5e,0x97,0x53,0x97,0x59,0x97,0x55, 0x93,0x5e,0x8f,0x55,0x8d,0x5b,0x8c,0x56,0x8d,0x62,0x8c,0x52,0x8c,0x5d,0x90,0x55, 0x93,0x60,0x96,0x53,0x97,0x5c,0x96,0x55,0x97,0x60,0x95,0x58,0x94,0x5a,0x90,0x51, 0x8f,0x5c,0x8e,0x56,0x8e,0x5b,0x8e,0x55,0x8f,0x60,0x90,0x57,0x93,0x5c,0x96,0x58, 0x99,0x5f,0x96,0x55,0x98,0x5e,0x96,0x52,0x94,0x61,0x90,0x54,0x90,0x5f,0x8d,0x53, 0x8e,0x5a,0x8e,0x5b,0x8e,0x60,0x90,0x55,0x93,0x5f,0x94,0x58,0x97,0x5c,0x97,0x58, 0x97,0x60,0x96,0x58,0x93,0x5c,0x90,0x56,0x8e,0x61,0x8d,0x58,0x8c,0x63,0x8c,0x57, 0x8e,0x5d,0x8e,0x56,0x92,0x5b,0x94,0x54,0x96,0x5d,0x96,0x58,0x97,0x5e,0x94,0x56, 0x93,0x63,0x91,0x57,0x90,0x5f,0x8d,0x56,0x8c,0x60,0x8b,0x56,0x8c,0x60,0x8e,0x54, 0x90,0x60,0x93,0x5e,0x95,0x5d,0x96,0x57,0x95,0x61,0x95,0x5a,0x94,0x62,0x90,0x5a, 0x8e,0x61,0x8c,0x59,0x8b,0x5c,0x8a,0x58,0x8a,0x63,0x8a,0x5c,0x8d,0x5f,0x90,0x58, 0x92,0x63,0x93,0x59,0x96,0x5e,0x95,0x59,0x94,0x5f,0x90,0x5a,0x8d,0x61,0x8b,0x56, 0x8a,0x60,0x8b,0x5c,0x8c,0x5b,0x8c,0x58,0x8e,0x61,0x90,0x5b,0x92,0x63,0x95,0x5b, 0x94,0x64,0x95,0x59,0x93,0x5d,0x91,0x5a,0x8d,0x63,0x8d,0x57,0x8c,0x5f,0x8b,0x58, 0x8a,0x5d,0x8c,0x5b,0x8e,0x5f,0x91,0x5a,0x92,0x64,0x95,0x5a,0x94,0x64,0x94,0x58, 0x94,0x65,0x92,0x5b,0x8e,0x66,0x8c,0x59,0x8a,0x68,0x8a,0x5d,0x8a,0x60,0x8c,0x5f, 0x8d,0x66,0x91,0x59,0x91,0x60,0x94,0x5d,0x94,0x65,0x93,0x59,0x92,0x61,0x92,0x5c, 0x8e,0x63,0x8b,0x5c,0x8a,0x61,0x8b,0x5b,0x8b,0x67,0x8b,0x5b,0x8c,0x63,0x8e,0x61, 0x93,0x69,0x94,0x5a,0x95,0x62,0x94,0x5b,0x93,0x6a,0x91,0x5c,0x8f,0x66,0x8c,0x60, 0x8a,0x6a,0x8a,0x5e,0x88,0x60,0x89,0x60,0x8b,0x6a,0x8b,0x61,0x90,0x68,0x91,0x62, 0x93,0x68,0x92,0x61,0x93,0x68,0x8f,0x61,0x8e,0x6d,0x8b,0x62,0x8a,0x69,0x88,0x62, 0x8a,0x6b,0x89,0x63,0x8a,0x6c,0x8b,0x5f,0x8e,0x70,0x90,0x66,0x91,0x6a,0x91,0x6b, 0x91,0x72,0x8f,0x66,0x8d,0x68,0x88,0x61,0x88,0x6e,0x87,0x66,0x88,0x6d,0x87,0x68, 0x88,0x75,0x89,0x69,0x8d,0x6c,0x8e,0x62,0x8e,0x74,0x90,0x66,0x90,0x6d,0x8d,0x65, 0x8b,0x74,0x89,0x65,0x86,0x6c,0x85,0x66,0x85,0x72,0x84,0x69,0x86,0x72,0x88,0x6a, 0x8b,0x72,0x8d,0x68,0x8f,0x6e,0x8e,0x68,0x8e,0x72,0x8c,0x65,0x8a,0x71,0x88,0x67, 0x84,0x72,0x84,0x66,0x84,0x6c,0x84,0x68,0x85,0x70,0x87,0x63,0x8b,0x70,0x8c,0x65, 0x8e,0x70,0x8e,0x62,0x8f,0x6b,0x8e,0x6a,0x8c,0x71,0x88,0x67,0x87,0x6c,0x84,0x63, 0x83,0x71,0x84,0x67,0x85,0x68,0x85,0x66,0x89,0x6d,0x8b,0x62,0x8e,0x6c,0x8e,0x68, 0x8f,0x6d,0x8d,0x65,0x8c,0x69,0x88,0x64,0x86,0x71,0x85,0x64,0x83,0x68,0x83,0x64, 0x86,0x6f,0x84,0x64,0x87,0x6b,0x8b,0x65,0x8c,0x72,0x8c,0x62,0x8c,0x70,0x8c,0x62, 0x8a,0x6f,0x88,0x65,0x86,0x6c,0x84,0x60,0x84,0x71,0x83,0x64,0x84,0x6e,0x84,0x65, 0x85,0x6e,0x88,0x64,0x8a,0x68,0x8a,0x66,0x8b,0x74,0x8b,0x65,0x8a,0x70,0x87,0x65, 0x85,0x71,0x83,0x64,0x83,0x6b,0x82,0x64,0x83,0x77,0x83,0x68,0x84,0x70,0x87,0x66, 0x88,0x71,0x8a,0x66,0x8a,0x71,0x8a,0x68,0x88,0x7a,0x87,0x6e,0x83,0x74,0x82,0x6c, 0x81,0x77,0x80,0x6e,0x80,0x73,0x80,0x6c,0x81,0x77,0x83,0x6c,0x87,0x73,0x88,0x6d, 0x88,0x79,0x89,0x6e,0x87,0x74,0x86,0x6c,0x83,0x7d,0x80,0x72,0x7f,0x7a,0x7d,0x71, 0x7d,0x78,0x7d,0x72,0x7e,0x73,0x82,0x70,0x84,0x77,0x86,0x6d,0x86,0x77,0x86,0x71, 0x87,0x76,0x86,0x6f,0x83,0x77,0x80,0x71,0x80,0x7a,0x7d,0x71,0x7d,0x78,0x7c,0x71, 0x7f,0x79,0x80,0x72,0x83,0x76,0x85,0x72,0x87,0x7a,0x86,0x70,0x87,0x76,0x85,0x72, 0x84,0x7d,0x81,0x75,0x7f,0x75,0x7e,0x74,0x7f,0x7b,0x7e,0x73,0x7f,0x76,0x81,0x6f, 0x84,0x79,0x85,0x74,0x87,0x7b,0x88,0x75,0x88,0x7f,0x87,0x75,0x85,0x79,0x83,0x75, 0x81,0x78,0x80,0x73,0x80,0x7b,0x7f,0x74,0x80,0x82,0x82,0x77,0x83,0x82,0x87,0x7c, 0x88,0x81,0x85,0x7f,0x6a,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xb4,0x47,0xb1,0x52,0xb4,0x4b,0xb6,0x55,0xb8,0x46,0xbc,0x55,0xbe,0x47, 0xc1,0x50,0xc1,0x4a,0xc1,0x4e,0xbf,0x4b,0xbd,0x50,0xba,0x4e,0xb7,0x52,0xb5,0x4b, 0xb4,0x51,0xb7,0x48,0xb9,0x4f,0xbc,0x4b,0xc0,0x4f,0xc2,0x4b,0xc5,0x50,0xc4,0x45, 0xc5,0x52,0xc5,0x4d,0xc2,0x50,0xbe,0x48,0xbc,0x53,0xb9,0x49,0xb9,0x50,0xb9,0x4a, 0xbb,0x52,0xbe,0x4a,0xc4,0x4c,0xc6,0x4b,0xc7,0x51,0xca,0x46,0xc9,0x51,0xc9,0x46, 0xc5,0x51,0xc4,0x48,0xc0,0x4c,0xbc,0x46,0xba,0x4d,0xb9,0x42,0xbe,0x51,0xc0,0x4b, 0xc2,0x50,0xc8,0x4a,0xca,0x4c,0xcb,0x4a,0xcc,0x51,0xcb,0x4a,0xc8,0x4e,0xc5,0x46, 0xc4,0x51,0xc1,0x48,0xbf,0x4b,0xbf,0x47,0xc2,0x4f,0xc5,0x4a,0xc8,0x50,0xca,0x48, 0xce,0x4f,0xcd,0x4b,0xcf,0x4c,0xcd,0x49,0xcb,0x50,0xc7,0x47,0xc5,0x53,0xc1,0x4b, 0xc0,0x52,0xbe,0x45,0xc3,0x4d,0xc4,0x4b,0xc8,0x4c,0xcb,0x49,0xcd,0x4f,0xcc,0x45, 0xce,0x53,0xce,0x4b,0xcc,0x4a,0xc9,0x4b,0xc5,0x4e,0xc1,0x48,0xc0,0x4f,0xbe,0x45, 0xbf,0x53,0xc2,0x49,0xc4,0x4b,0xc6,0x49,0xc8,0x54,0xcb,0x4c,0xc9,0x4f,0xc9,0x45, 0xc7,0x51,0xc5,0x4a,0xc2,0x4f,0xbf,0x43,0xbd,0x4d,0xbb,0x4a,0xbb,0x51,0xbe,0x48, 0xc1,0x50,0xc4,0x4d,0xc8,0x4f,0xc7,0x47,0xc9,0x52,0xc8,0x47,0xc8,0x4f,0xc3,0x4b, 0xc1,0x52,0xbe,0x46,0xbb,0x4d,0xba,0x48,0xba,0x53,0xbb,0x49,0xbf,0x4f,0xc3,0x48, 0xc4,0x58,0xc6,0x49,0xc8,0x4d,0xc8,0x4a,0xc7,0x4e,0xc4,0x4d,0xc2,0x4e,0xbd,0x47, 0xba,0x52,0xba,0x4b,0xba,0x50,0xbc,0x42,0xbd,0x51,0xc1,0x4c,0xc3,0x52,0xc5,0x49, 0xc7,0x52,0xc7,0x47,0xc6,0x4d,0xc4,0x4a,0xc1,0x50,0xbd,0x49,0xbb,0x4c,0xb9,0x46, 0xb9,0x50,0xb9,0x47,0xbe,0x4f,0xbf,0x48,0xc1,0x4f,0xc5,0x48,0xc6,0x53,0xc5,0x46, 0xc6,0x4d,0xc3,0x4c,0xbf,0x52,0xbb,0x4a,0xba,0x50,0xb8,0x48,0xb5,0x51,0xb9,0x45, 0xbc,0x4c,0xbd,0x4a,0xc0,0x50,0xc3,0x4b,0xc5,0x51,0xc4,0x47,0xc5,0x4f,0xc2,0x47, 0xc0,0x4e,0xbc,0x47,0xbb,0x4d,0xb8,0x49,0xb7,0x52,0xb7,0x44,0xba,0x50,0xbc,0x47, 0xbe,0x51,0xc0,0x43,0xc4,0x4f,0xc2,0x43,0xc2,0x51,0xc1,0x47,0xbd,0x50,0xbb,0x46, 0xbb,0x4f,0xb8,0x4c,0xb7,0x4d,0xb7,0x49,0xb9,0x50,0xba,0x44,0xbd,0x52,0xc1,0x47, 0xc3,0x50,0xc4,0x49,0xc4,0x4c,0xc1,0x49,0xbf,0x52,0xbc,0x4a,0xb9,0x50,0xb6,0x48, 0xb5,0x52,0xb5,0x4b,0xb6,0x52,0xba,0x48,0xbb,0x50,0xbf,0x49,0xc0,0x4f,0xc2,0x4b, 0xc2,0x51,0xc0,0x49,0xbe,0x50,0xbc,0x4a,0xb9,0x51,0xb7,0x4c,0xb3,0x50,0xb5,0x4a, 0xb6,0x51,0xba,0x48,0xbd,0x4a,0xbe,0x45,0xc1,0x51,0xc1,0x48,0xc2,0x51,0xc0,0x4c, 0xbd,0x51,0xb9,0x4b,0xb8,0x49,0xb5,0x46,0xb2,0x51,0xb3,0x47,0xb4,0x52,0xb8,0x4c, 0xbb,0x51,0xbd,0x47,0xc2,0x4e,0xc2,0x49,0xc1,0x50,0xc1,0x4b,0xbe,0x4e,0xba,0x48, 0xb8,0x51,0xb6,0x48,0xb4,0x50,0xb3,0x45,0xb5,0x52,0xb6,0x49,0xba,0x4f,0xbd,0x4b, 0xbe,0x50,0xc0,0x4a,0xbf,0x50,0xbf,0x49,0xbe,0x54,0xbb,0x4b,0xb8,0x51,0xb4,0x48, 0xb3,0x51,0xb1,0x46,0xb2,0x4d,0xb4,0x49,0xb7,0x53,0xba,0x47,0xbd,0x51,0xc0,0x4a, 0xbf,0x53,0xbe,0x49,0xbd,0x4e,0xb9,0x4a,0xb7,0x51,0xb5,0x4c,0xb1,0x50,0xb0,0x47, 0xb2,0x50,0xb4,0x48,0xb5,0x50,0xb9,0x46,0xbd,0x4e,0xbf,0x49,0xbf,0x4f,0xbd,0x48, 0xbd,0x51,0xba,0x47,0xb7,0x4e,0xb3,0x44,0xb2,0x54,0xb0,0x4a,0xb1,0x55,0xb2,0x47, 0xb4,0x4e,0xb8,0x4a,0xba,0x4f,0xb9,0x48,0xbe,0x51,0xba,0x4b,0xbd,0x51,0xb8,0x46, 0xb8,0x50,0xb2,0x47,0xb1,0x4d,0xae,0x4a,0xae,0x51,0xb1,0x4a,0xb4,0x4d,0xb4,0x44, 0xb8,0x50,0xba,0x48,0xbd,0x4f,0xbb,0x44,0xba,0x54,0xb9,0x48,0xb5,0x50,0xb3,0x4b, 0xaf,0x53,0xaf,0x4e,0xae,0x50,0xb0,0x46,0xb1,0x52,0xb4,0x4c,0xb9,0x50,0xbc,0x46, 0xba,0x51,0xbc,0x48,0xbe,0x4f,0xbb,0x42,0xb7,0x4e,0xb1,0x48,0xb2,0x4c,0xb0,0x4c, 0xac,0x50,0xae,0x48,0xb2,0x4d,0xb6,0x4b,0xb7,0x51,0xba,0x47,0xba,0x50,0xbd,0x48, 0xbc,0x50,0xb8,0x43,0xb6,0x4f,0xb3,0x48,0xb1,0x50,0xaf,0x47,0xae,0x56,0xaf,0x49, 0xb0,0x51,0xb5,0x4b,0xb8,0x4a,0xb9,0x46,0xbd,0x51,0xbe,0x4b,0xbd,0x4f,0xbb,0x42, 0xb7,0x4d,0xb4,0x47,0xb1,0x51,0xaf,0x48,0xae,0x54,0xb0,0x46,0xb3,0x52,0xb5,0x4a, 0xba,0x4e,0xbd,0x4a,0xbe,0x4f,0xbd,0x49,0xbf,0x52,0xbd,0x4c,0xb8,0x54,0xb5,0x47, 0xb5,0x4e,0xb0,0x48,0xb0,0x4e,0xb1,0x47,0xb4,0x51,0xb5,0x45,0xba,0x4f,0xbc,0x47, 0xbe,0x4c,0xbf,0x47,0xbf,0x51,0xbd,0x49,0xba,0x54,0xb8,0x49,0xb7,0x4b,0xb3,0x4a, 0xb1,0x50,0xb3,0x49,0xb4,0x4d,0xb7,0x47,0xb9,0x51,0xbd,0x4a,0xc0,0x50,0xc0,0x47, 0xc0,0x4d,0xc0,0x48,0xbe,0x4f,0xb8,0x47,0xb6,0x53,0xb3,0x46,0xb2,0x53,0xb1,0x49, 0xb4,0x4c,0xb5,0x48,0xba,0x4c,0xbb,0x46,0xbd,0x50,0xbf,0x49,0xbf,0x4e,0xbe,0x45, 0xbc,0x52,0xb9,0x44,0xb6,0x4e,0xb3,0x45,0xb1,0x52,0xb4,0x44,0xb5,0x51,0xb7,0x46, 0xb9,0x52,0xbd,0x46,0xbe,0x50,0xc1,0x4a,0xc1,0x51,0xc0,0x45,0xbd,0x51,0xbb,0x4b, 0xb8,0x4f,0xb5,0x44,0xb4,0x48,0xb2,0x40,0xb3,0x4f,0xb7,0x48,0xb9,0x4f,0xbc,0x46, 0xbe,0x53,0xbb,0x4d,0xc5,0x35,0xc3,0x30,0xc3,0x36,0xbf,0x31,0xbc,0x41,0xb9,0x32, 0xb9,0x3e,0xb9,0x34,0xbb,0x33,0xbe,0x2f,0xc0,0x36,0xc1,0x30,0xc4,0x38,0xc5,0x2d, 0xc4,0x36,0xc3,0x30,0xc2,0x36,0xbf,0x2d,0xbb,0x33,0xba,0x2d,0xb7,0x35,0xb8,0x2d, 0xb9,0x36,0xbb,0x30,0xbe,0x37,0xc1,0x2f,0xc3,0x38,0xc4,0x2b,0xc4,0x37,0xc3,0x2f, 0xc2,0x35,0xc1,0x2e,0xb9,0x32,0xb9,0x2e,0xb6,0x35,0xb8,0x2c,0xb9,0x38,0xbb,0x2a, 0xbe,0x37,0xc1,0x2f,0xc2,0x36,0xc4,0x2a,0xc4,0x32,0xc4,0x2f,0xc1,0x35,0xbe,0x2c, 0xbb,0x37,0xba,0x2d,0xb7,0x31,0xb6,0x2c,0xb9,0x36,0xba,0x2a,0xbc,0x32,0xc0,0x2e, 0xc1,0x32,0xc2,0x2e,0xc3,0x37,0xc2,0x2b,0xbe,0x33,0xbd,0x2e,0xba,0x35,0xb8,0x2d, 0xb5,0x37,0xb5,0x2e,0xb6,0x34,0xb8,0x2b,0xba,0x37,0xbe,0x30,0xbf,0x32,0xc2,0x2c, 0xc5,0x36,0xc3,0x2d,0xc0,0x31,0xbe,0x2e,0xbc,0x3b,0xba,0x2d,0xb8,0x34,0xb8,0x2f, 0xb8,0x37,0xb9,0x2c,0xbb,0x34,0xbe,0x2f,0xc0,0x39,0xc3,0x2c,0xc2,0x39,0xc0,0x2b, 0xbf,0x36,0xbd,0x2f,0xba,0x34,0xb7,0x2c,0xb5,0x36,0xb4,0x2b,0xb4,0x31,0xb6,0x2b, 0xb8,0x35,0xbb,0x2d,0xbd,0x36,0xc0,0x2c,0xc2,0x36,0xc2,0x2d,0xc1,0x39,0xbf,0x2f, 0xbd,0x37,0xb8,0x2c,0xb6,0x33,0xb5,0x2c,0xb5,0x34,0xb8,0x2e,0xba,0x35,0xbe,0x2d, 0xc2,0x3a,0xc3,0x32,0xc5,0x3b,0xc6,0x2c,0xc4,0x38,0xc3,0x2d,0xc1,0x35,0xbf,0x2c, 0xbc,0x34,0xba,0x2e,0xba,0x34,0xbb,0x2e,0xbd,0x3a,0xc0,0x2a,0xc3,0x38,0xc4,0x31, 0xc7,0x2f,0xc6,0x2c,0xc4,0x36,0xc2,0x2f,0xc0,0x34,0xbf,0x2f,0xbc,0x39,0xba,0x2f, 0xba,0x33,0xbc,0x2d,0xbe,0x35,0xc0,0x2a,0xc1,0x32,0xc5,0x2b,0xc6,0x33,0xc4,0x30, 0xc4,0x36,0xc2,0x2c,0xbf,0x33,0xbd,0x2c,0xbc,0x36,0xba,0x31,0xb8,0x39,0xb9,0x2d, 0xbb,0x34,0xbc,0x30,0xc0,0x31,0xc2,0x2d,0xc6,0x34,0xc7,0x2f,0xc5,0x37,0xc4,0x2f, 0xc1,0x37,0xbd,0x2a,0xbc,0x36,0xba,0x2b,0xba,0x38,0xbb,0x2f,0xbd,0x38,0xbe,0x2f, 0xc2,0x38,0xc6,0x2f,0xc5,0x33,0xc4,0x30,0xc7,0x37,0xc6,0x2e,0xc1,0x32,0xbf,0x2e, 0xbe,0x3b,0xbb,0x2d,0xb8,0x31,0xba,0x2d,0xbc,0x38,0xbe,0x30,0xbf,0x30,0xc3,0x29, 0xc5,0x38,0xc7,0x2d,0xc6,0x31,0xc4,0x33,0xc4,0x34,0xc3,0x2e,0xbf,0x34,0xbe,0x2d, 0xbc,0x32,0xbc,0x31,0xbd,0x34,0xbf,0x2e,0xc1,0x33,0xc6,0x2e,0xc8,0x36,0xc9,0x2f, 0xc8,0x36,0xc6,0x31,0xc6,0x37,0xc0,0x2f,0xc0,0x36,0xbd,0x2f,0xbb,0x34,0xba,0x2a, 0xbc,0x33,0xbe,0x30,0xc0,0x30,0xc2,0x2c,0xc6,0x35,0xc9,0x2f,0xc7,0x34,0xc6,0x2d, 0xc5,0x38,0xc2,0x32,0xbf,0x34,0xbe,0x2b,0xbc,0x36,0xba,0x31,0xbc,0x33,0xbf,0x2d, 0xc2,0x38,0xc5,0x2d,0xc5,0x35,0xc5,0x2c,0xc8,0x37,0xc6,0x2f,0xc3,0x35,0xc2,0x2e, 0xc0,0x37,0xbd,0x2c,0xba,0x33,0xb9,0x30,0xba,0x33,0xbc,0x30,0xbf,0x34,0xc3,0x2e, 0xc5,0x3a,0xc4,0x30,0xc6,0x36,0xc6,0x2e,0xc4,0x37,0xc0,0x30,0xbf,0x35,0xbd,0x2f, 0xbb,0x3a,0xba,0x2c,0xb9,0x35,0xbb,0x2b,0xbe,0x38,0xc0,0x30,0xc2,0x36,0xc4,0x2f, 0xc4,0x36,0xc4,0x32,0xc2,0x36,0xbf,0x30,0xbe,0x38,0xbb,0x31,0xba,0x36,0xb6,0x30, 0xb9,0x3a,0xbb,0x30,0xbd,0x33,0xc1,0x2c,0xc4,0x3a,0xc4,0x31,0xc4,0x38,0xc4,0x2d, 0xc2,0x37,0xbe,0x30,0xbb,0x37,0xba,0x2f,0xb9,0x36,0xb8,0x30,0xb8,0x36,0xba,0x2f, 0xbd,0x36,0xc0,0x2e,0xc2,0x36,0xc4,0x2a,0xc6,0x33,0xc6,0x2b,0xc5,0x3a,0xc2,0x2c, 0xbf,0x35,0xbd,0x2c,0xba,0x33,0xb7,0x31,0xb9,0x38,0xba,0x2f,0xbc,0x3a,0xbe,0x28, 0xc3,0x37,0xc3,0x2d,0xc3,0x31,0xc3,0x30,0xc2,0x36,0xc0,0x2d,0xbd,0x36,0xbd,0x2e, 0xba,0x36,0xb8,0x30,0xb8,0x33,0xba,0x2d,0xbc,0x36,0xbe,0x30,0xc0,0x38,0xc1,0x31, 0xc4,0x35,0xc5,0x2d,0xc3,0x35,0xbf,0x30,0xbd,0x34,0xbb,0x2f,0xba,0x35,0xb7,0x2e, 0xb6,0x33,0xb9,0x2d,0xba,0x36,0xbd,0x32,0xc0,0x39,0xc3,0x2d,0xc3,0x36,0xc3,0x2d, 0xc3,0x37,0xc2,0x2f,0xc0,0x36,0xbc,0x2f,0xba,0x37,0xb9,0x2e,0xb7,0x36,0xb6,0x2d, 0xb9,0x38,0xbd,0x2e,0xbe,0x31,0xbf,0x2e,0xc2,0x37,0xc3,0x2b,0xc0,0x37,0xbf,0x32, 0xbd,0x35,0xbb,0x2e,0xb8,0x38,0xb7,0x2f,0xb7,0x38,0xb7,0x2f,0xb8,0x37,0xb9,0x30, 0xbe,0x37,0xbf,0x2b,0xc0,0x32,0xc1,0x33,0xc0,0x34,0xbe,0x2f,0xbc,0x34,0xb9,0x2b, 0xb9,0x36,0xb6,0x2c,0xb4,0x36,0xb5,0x2d,0xb7,0x37,0xb9,0x2c,0xbc,0x36,0xbe,0x2f, 0xbe,0x32,0xbf,0x32,0xbf,0x34,0xbd,0x2e,0xbb,0x36,0xba,0x2b,0xb7,0x36,0xb4,0x30, 0xb6,0x35,0xb5,0x2b,0xb6,0x33,0xb9,0x2d,0xbb,0x36,0xc1,0x2a,0xc1,0x35,0xc0,0x2e, 0xc1,0x32,0xc1,0x2c,0xbe,0x35,0xbb,0x2e,0xb7,0x37,0xb7,0x2d,0xb6,0x3b,0xb6,0x2d, 0xb7,0x33,0xb9,0x2f,0xbc,0x37,0xbf,0x2b,0xc0,0x36,0xbf,0x2c,0xbf,0x35,0xc0,0x2e, 0xbe,0x39,0xb9,0x30,0xb8,0x30,0xb5,0x2f,0xb4,0x38,0xb4,0x2c,0xb6,0x36,0xb7,0x30, 0xbc,0x34,0xbe,0x2d,0xc0,0x32,0xc0,0x2a,0xc1,0x37,0xbf,0x30,0xbd,0x36,0xba,0x2b, 0xb9,0x34,0xb8,0x2c,0xb6,0x33,0xb4,0x2b,0xb5,0x33,0xb7,0x30,0xb9,0x33,0xbd,0x2f, 0xbf,0x36,0xc1,0x2d,0xc2,0x35,0xc0,0x2d,0xbf,0x39,0xbc,0x2c,0xba,0x39,0xb8,0x2e, 0xb6,0x32,0xb5,0x28,0xb7,0x3a,0xb8,0x2f,0xba,0x34,0xbd,0x31,0xc1,0x37,0xc1,0x2b, 0xc2,0x37,0xc1,0x30,0xbd,0x32,0xba,0x2e,0xba,0x37,0xb7,0x2c,0xb3,0x31,0xb3,0x31, 0xb6,0x36,0xb8,0x2d,0xb9,0x36,0xbd,0x29,0xbf,0x39,0xc1,0x2f,0xc0,0x32,0xc0,0x2c, 0xc1,0x39,0xba,0x31,0xb9,0x37,0xb7,0x31,0xb7,0x38,0xb4,0x29,0xb5,0x2f,0xb7,0x26, 0xb8,0x31,0xbb,0x2d,0xbd,0x36,0xbe,0x2f,0xbe,0x36,0xb8,0x34,0xbf,0x53,0xbd,0x4f, 0xbc,0x52,0xb9,0x57,0xb6,0x61,0xb4,0x57,0xb7,0x5b,0xb9,0x50,0xba,0x57,0xbd,0x4d, 0xbe,0x58,0xc0,0x50,0xc1,0x56,0xc0,0x55,0xbf,0x56,0xbc,0x50,0xb9,0x59,0xb7,0x50, 0xb8,0x57,0xb6,0x4f,0xb6,0x54,0xb8,0x4c,0xbb,0x59,0xbb,0x50,0xbe,0x56,0xbf,0x51, 0xbf,0x55,0xbe,0x51,0xbe,0x5a,0xb9,0x4c,0xb8,0x59,0xb5,0x52,0xb4,0x5b,0xb3,0x50, 0xb3,0x5a,0xb6,0x53,0xbb,0x56,0xbc,0x4f,0xba,0x57,0xbd,0x4e,0xc2,0x56,0xbe,0x4f, 0xb9,0x5a,0xbc,0x4e,0xb8,0x56,0xb6,0x50,0xb5,0x58,0xb5,0x4e,0xb5,0x5b,0xb5,0x52, 0xb7,0x54,0xbb,0x4e,0xbd,0x56,0xbe,0x53,0xbf,0x55,0xc0,0x4e,0xbe,0x56,0xbd,0x52, 0xb9,0x55,0xb7,0x51,0xb6,0x56,0xb5,0x4e,0xb6,0x5a,0xb6,0x51,0xb8,0x59,0xb7,0x51, 0xbc,0x59,0xbd,0x52,0xbc,0x54,0xbc,0x4c,0xbc,0x58,0xba,0x4e,0xb7,0x57,0xb6,0x4f, 0xb4,0x57,0xb1,0x4c,0xb1,0x58,0xb0,0x4f,0xb4,0x5a,0xb6,0x51,0xba,0x5a,0xbb,0x52, 0xbe,0x56,0xbf,0x4a,0xbc,0x55,0xba,0x4c,0xb7,0x57,0xb3,0x51,0xb1,0x5c,0xb2,0x4d, 0xb3,0x53,0xb4,0x54,0xb5,0x57,0xb8,0x51,0xbb,0x5a,0xba,0x52,0xbd,0x55,0xbd,0x4f, 0xbb,0x58,0xb9,0x4f,0xb6,0x56,0xb4,0x50,0xb0,0x5a,0xae,0x4b,0xb0,0x55,0xb3,0x4f, 0xb4,0x5d,0xb4,0x51,0xba,0x5a,0xbb,0x50,0xbd,0x5a,0xbd,0x51,0xbd,0x57,0xb9,0x50, 0xb8,0x56,0xb7,0x4f,0xb3,0x55,0xb2,0x4f,0xb1,0x58,0xb4,0x4e,0xb6,0x54,0xb6,0x4e, 0xb9,0x5b,0xbc,0x50,0xbd,0x59,0xbb,0x51,0xbd,0x5d,0xbb,0x51,0xb6,0x57,0xb5,0x4f, 0xb2,0x57,0xb0,0x50,0xaf,0x53,0xaf,0x50,0xb3,0x5a,0xb5,0x4f,0xb6,0x55,0xb9,0x50, 0xbc,0x5b,0xb9,0x56,0xb8,0x57,0xb9,0x4c,0xb8,0x59,0xb2,0x51,0xb1,0x57,0xb0,0x51, 0xb0,0x55,0xb0,0x4c,0xb3,0x56,0xb3,0x4e,0xb4,0x5b,0xb6,0x52,0xba,0x5a,0xb9,0x4c, 0xb8,0x59,0xb9,0x4d,0xb5,0x57,0xb3,0x54,0xb2,0x58,0xb0,0x4c,0xae,0x59,0xaf,0x51, 0xb1,0x5b,0xb0,0x50,0xb0,0x56,0xb9,0x52,0xb9,0x5c,0xb7,0x4b,0xb9,0x56,0xb9,0x4e, 0xb7,0x5a,0xb2,0x52,0xb0,0x58,0xaf,0x51,0xae,0x58,0xad,0x4d,0xaf,0x58,0xb1,0x50, 0xb4,0x54,0xb6,0x52,0xb8,0x55,0xba,0x4e,0xb7,0x58,0xb8,0x53,0xb7,0x5c,0xb1,0x50, 0xb0,0x56,0xb0,0x4d,0xae,0x5a,0xad,0x4f,0xaf,0x58,0xb1,0x50,0xb3,0x57,0xb6,0x4b, 0xb6,0x56,0xb7,0x4f,0xb7,0x55,0xb3,0x4d,0xb2,0x57,0xb2,0x4f,0xaf,0x56,0xab,0x4d, 0xab,0x55,0xac,0x50,0xaf,0x57,0xb1,0x51,0xb1,0x56,0xb5,0x51,0xb8,0x5a,0xb8,0x50, 0xb7,0x55,0xb7,0x51,0xb4,0x57,0xb1,0x4d,0xb1,0x58,0xaf,0x4d,0xad,0x5a,0xae,0x4e, 0xae,0x52,0xaf,0x4f,0xb1,0x54,0xb2,0x51,0xb5,0x58,0xb6,0x50,0xb6,0x58,0xb8,0x4e, 0xb5,0x58,0xad,0x4f,0xa7,0x55,0xac,0x4f,0xaa,0x58,0xa2,0x4f,0xa6,0x56,0xac,0x50, 0xb0,0x55,0xb2,0x52,0xb4,0x5a,0xb4,0x4d,0xb6,0x5a,0xb5,0x4c,0xb3,0x59,0xb2,0x50, 0xaf,0x57,0xac,0x4f,0xac,0x57,0xaa,0x4f,0xab,0x58,0xac,0x50,0xae,0x5a,0xb1,0x4e, 0xb5,0x57,0xb3,0x4d,0xb2,0x59,0xb4,0x4f,0xb3,0x5c,0xae,0x4e,0xab,0x58,0xaa,0x4d, 0xa9,0x58,0xa8,0x52,0xa8,0x56,0xaa,0x4c,0xad,0x5b,0xae,0x4e,0xb1,0x57,0xb0,0x4c, 0xb2,0x54,0xb4,0x4f,0xb1,0x56,0xad,0x50,0xad,0x5b,0xad,0x4f,0xa9,0x56,0xa9,0x4d, 0xa8,0x58,0xa9,0x53,0xad,0x55,0xb0,0x53,0xb2,0x5c,0xb3,0x54,0xb6,0x56,0xb4,0x50, 0xb2,0x5a,0xb1,0x4d,0xaf,0x57,0xae,0x53,0xaa,0x59,0xa8,0x4e,0xa9,0x55,0xac,0x4c, 0xad,0x5c,0xae,0x50,0xb1,0x58,0xb4,0x51,0xb4,0x5d,0xb3,0x50,0xb3,0x56,0xb1,0x4f, 0xaf,0x59,0xad,0x4e,0xac,0x57,0xaa,0x4e,0xab,0x5c,0xac,0x54,0xae,0x56,0xae,0x50, 0xb2,0x53,0xb4,0x53,0xb7,0x56,0xb3,0x57,0xb3,0x57,0xb5,0x4f,0xb0,0x58,0xab,0x53, 0xab,0x58,0xa8,0x52,0xa8,0x55,0xa9,0x52,0xab,0x5b,0xad,0x4f,0xb0,0x59,0xb1,0x4e, 0xb5,0x59,0xb3,0x51,0xb1,0x57,0xb1,0x52,0xb3,0x5b,0xaf,0x55,0xab,0x59,0xab,0x52, 0xac,0x5e,0xac,0x4e,0xac,0x5b,0xae,0x52,0xb1,0x5d,0xb3,0x53,0xb5,0x59,0xb4,0x52, 0xb6,0x5c,0xb4,0x4e,0xb1,0x55,0xaf,0x52,0xae,0x5d,0xad,0x4e,0xa9,0x55,0xa8,0x4f, 0xac,0x58,0xae,0x4f,0xaf,0x58,0xb1,0x4f,0xb6,0x5d,0xb4,0x4d,0xb4,0x59,0xb4,0x4e, 0xb3,0x59,0xb0,0x54,0xae,0x58,0xab,0x51,0xa8,0x58,0xa8,0x52,0xab,0x58,0xad,0x4e, 0xae,0x58,0xb1,0x51,0xb4,0x58,0xb6,0x4f,0xb6,0x5a,0xb2,0x4f,0xb0,0x58,0xae,0x4f, 0xae,0x58,0xa8,0x4b,0xa8,0x58,0xa9,0x4e,0xab,0x5b,0xac,0x52,0xae,0x5a,0xaf,0x4e, 0xb3,0x58,0xb2,0x53,0xb2,0x54,0xb1,0x51,0xb1,0x59,0xae,0x4c,0xab,0x57,0xab,0x4f, 0xa9,0x53,0xa7,0x52,0xa7,0x56,0xaa,0x4e,0xae,0x58,0xb1,0x4f,0xb1,0x59,0xb1,0x53, 0xb4,0x5a,0xb3,0x52,0xb0,0x55,0xaf,0x4d,0xad,0x5b,0xaa,0x50,0xa7,0x59,0xa7,0x4c, 0xa9,0x5b,0xac,0x4d,0xad,0x52,0xb0,0x4f,0xb4,0x5c,0xb5,0x54,0xb5,0x53,0xb4,0x52, 0xb4,0x58,0xb0,0x52,0xad,0x50,0xad,0x4b,0xa9,0x59,0xa6,0x52,0xab,0x56,0xaa,0x4e, 0xab,0x5c,0xad,0x50,0xb2,0x53,0xb5,0x4e,0xb4,0x5d,0xb2,0x50,0xb1,0x55,0xb0,0x4e, 0xae,0x5a,0xab,0x51,0xa8,0x52,0xa8,0x50,0xaa,0x59,0xaa,0x54,0xac,0x58,0xae,0x52, 0xb4,0x59,0xb4,0x50,0xb4,0x56,0xad,0x4d,0xb0,0x5b,0xb1,0x4e,0xa9,0x5d,0xa5,0x4b, 0xa9,0x57,0xa9,0x50,0xa7,0x59,0xaa,0x50,0xad,0x5b,0xae,0x53,0xb2,0x5a,0xb4,0x4e, 0xb5,0x5c,0xb3,0x50,0xb2,0x54,0xaf,0x50,0xad,0x5d,0xab,0x4f,0xa9,0x55,0xa7,0x52, 0xa6,0x59,0xa7,0x4d,0xaa,0x4f,0xae,0x48,0xb0,0x57,0xb2,0x54,0xb2,0x56,0xaf,0x50, 0xb2,0x58,0xa9,0x55,0xaf,0x44,0xaf,0x41,0xad,0x4b,0xab,0x43,0xad,0x4d,0xad,0x49, 0xb0,0x4d,0xb2,0x41,0xb4,0x48,0xb7,0x3f,0xb8,0x4d,0xb6,0x44,0xb5,0x4a,0xb2,0x3d, 0xb1,0x44,0xac,0x40,0xac,0x47,0xaa,0x3d,0xac,0x4a,0xac,0x41,0xaf,0x49,0xb1,0x42, 0xb4,0x4a,0xb7,0x3f,0xb6,0x45,0xb6,0x3a,0xb5,0x46,0xb2,0x41,0xb0,0x49,0xad,0x41, 0xac,0x49,0xaa,0x3e,0xaa,0x43,0xab,0x45,0xad,0x49,0xb0,0x42,0xb2,0x47,0xb2,0x40, 0xb5,0x4a,0xb4,0x40,0xb2,0x45,0xb0,0x40,0xaf,0x48,0xab,0x42,0xa9,0x49,0xa8,0x41, 0xa8,0x4a,0xa7,0x42,0xaa,0x47,0xae,0x42,0xb2,0x4a,0xb2,0x44,0xb3,0x4a,0xb3,0x3f, 0xb2,0x4b,0xb1,0x41,0xae,0x44,0xab,0x41,0xaa,0x4f,0xa6,0x42,0xa6,0x45,0xa7,0x43, 0xa8,0x46,0xaa,0x42,0xaf,0x44,0xaf,0x3e,0xb0,0x4b,0xb3,0x3f,0xb2,0x45,0xae,0x40, 0xae,0x48,0xac,0x42,0xa8,0x48,0xa7,0x42,0xa8,0x4b,0xa8,0x3d,0xab,0x4a,0xab,0x3e, 0xaf,0x45,0xb1,0x41,0xb1,0x44,0xb0,0x44,0xb1,0x4b,0xaf,0x43,0xac,0x4a,0xaa,0x3f, 0xa9,0x49,0xa7,0x3f,0xa6,0x4b,0xa6,0x3d,0xa8,0x4c,0xa9,0x41,0xac,0x47,0xae,0x44, 0xb1,0x49,0xb0,0x43,0xb1,0x46,0xb0,0x43,0xaf,0x48,0xa9,0x40,0xa8,0x44,0xa7,0x3f, 0xa6,0x4b,0xa4,0x40,0xa6,0x47,0xa7,0x43,0xab,0x4b,0xaf,0x44,0xaf,0x4c,0xb0,0x3f, 0xaf,0x4a,0xad,0x3f,0xab,0x43,0xa9,0x3e,0xa7,0x46,0xa5,0x40,0xa5,0x4e,0xa3,0x40, 0xa4,0x46,0xa7,0x42,0xa9,0x45,0xac,0x41,0xaf,0x4a,0xaf,0x3d,0xaf,0x49,0xaf,0x3b, 0xac,0x47,0xaa,0x3e,0xa7,0x44,0xa5,0x44,0xa4,0x4b,0xa3,0x41,0xa6,0x49,0xa7,0x3d, 0xa8,0x48,0xaa,0x42,0xae,0x4a,0xaf,0x3f,0xb0,0x4b,0xad,0x40,0xac,0x4b,0xa8,0x43, 0xa9,0x49,0xa6,0x42,0xa4,0x48,0xa3,0x42,0xa4,0x4b,0xa6,0x45,0xa7,0x46,0xaa,0x3d, 0xac,0x46,0xad,0x46,0xad,0x46,0xad,0x3f,0xab,0x4b,0xa7,0x41,0xa5,0x4b,0xa4,0x3e, 0xa2,0x48,0xa0,0x3c,0xa2,0x46,0xa3,0x3e,0xa7,0x4c,0xa7,0x42,0xab,0x4c,0xac,0x3d, 0xae,0x48,0xac,0x41,0xab,0x49,0xa8,0x43,0xa6,0x4b,0xa1,0x42,0xa0,0x47,0x9e,0x3e, 0xa1,0x49,0xa0,0x41,0xa3,0x48,0xa7,0x3f,0xaa,0x4b,0xa9,0x41,0xab,0x4c,0xab,0x43, 0xaa,0x4a,0xa7,0x42,0xa6,0x43,0xa4,0x3e,0xa2,0x4d,0xa0,0x41,0xa1,0x45,0xa1,0x44, 0xa2,0x47,0xa6,0x3e,0xa7,0x49,0xaa,0x3f,0xab,0x4d,0xa8,0x44,0xaa,0x4b,0xa5,0x3c, 0xa2,0x48,0xa0,0x41,0xa0,0x46,0x9b,0x40,0x9d,0x4c,0xa0,0x41,0xa3,0x48,0xa5,0x43, 0xa7,0x45,0xa9,0x3f,0xaa,0x45,0xa7,0x43,0xa8,0x4d,0xa6,0x40,0xa3,0x4a,0xa0,0x41, 0xa0,0x4b,0x9f,0x3e,0x9e,0x47,0xa0,0x3e,0xa2,0x47,0xa5,0x42,0xa5,0x46,0xa6,0x40, 0xa9,0x48,0xaa,0x3f,0xa7,0x47,0xa5,0x41,0xa4,0x4c,0xa2,0x3e,0xa1,0x48,0x9e,0x3f, 0x9e,0x49,0x9e,0x44,0xa1,0x4c,0xa3,0x41,0xa6,0x48,0xa9,0x40,0xab,0x4b,0xa8,0x40, 0xaa,0x4b,0xaa,0x3f,0xa5,0x48,0xa3,0x41,0xa4,0x4e,0x9f,0x40,0x9d,0x4a,0x9d,0x41, 0xa2,0x49,0xa2,0x43,0xa5,0x46,0xa9,0x40,0xab,0x4f,0xa9,0x42,0xab,0x49,0xa9,0x3d, 0xa6,0x4a,0xa4,0x3e,0xa1,0x48,0x9f,0x42,0x9f,0x4b,0xa0,0x3d,0xa2,0x4a,0xa3,0x3f, 0xa5,0x4c,0xa7,0x40,0xa9,0x4b,0xa7,0x41,0xa7,0x4b,0xa7,0x41,0xa5,0x4a,0xa0,0x3c, 0x9f,0x4a,0x9d,0x42,0x9c,0x49,0x9d,0x45,0x9e,0x4b,0xa1,0x41,0xa4,0x49,0xa4,0x40, 0xa7,0x46,0xa7,0x3f,0xa7,0x46,0xa5,0x3e,0xa4,0x4a,0xa1,0x44,0x9f,0x49,0x9d,0x40, 0x9e,0x48,0x9d,0x40,0x9e,0x48,0xa2,0x3e,0xa4,0x4b,0xa6,0x41,0xa9,0x45,0xa8,0x40, 0xa9,0x48,0xa8,0x41,0xa6,0x48,0xa3,0x43,0xa0,0x4b,0x9e,0x40,0x9e,0x48,0x9d,0x41, 0xa1,0x49,0xa1,0x40,0xa4,0x49,0xa7,0x3f,0xa9,0x49,0xa8,0x42,0xaa,0x4a,0xaa,0x3f, 0xa8,0x4b,0xa4,0x40,0xa0,0x47,0x9d,0x41,0x9c,0x4c,0x9c,0x42,0x9d,0x4c,0x9c,0x40, 0xa3,0x49,0xa2,0x40,0xa2,0x48,0xa4,0x46,0xa8,0x4c,0xa6,0x43,0xa2,0x49,0xa2,0x42, 0xa0,0x4c,0x9c,0x3d,0x9d,0x47,0x9c,0x3e,0x9d,0x4b,0x9f,0x3f,0xa2,0x48,0xa5,0x44, 0xa5,0x4b,0xa8,0x3e,0xa7,0x45,0xa8,0x3f,0xa7,0x4b,0xa5,0x43,0xa1,0x47,0x9e,0x45, 0x9e,0x46,0x9c,0x3f,0x9d,0x48,0x9f,0x3e,0xa0,0x51,0xa3,0x42,0xa7,0x4a,0xa7,0x41, 0xa8,0x4c,0xa7,0x3f,0xa8,0x46,0xa5,0x3e,0xa1,0x4f,0x9f,0x41,0x9e,0x46,0x9c,0x41, 0x9f,0x4a,0xa1,0x3d,0xa2,0x4b,0xa5,0x3f,0xa7,0x4a,0xa8,0x41,0xa8,0x4b,0xa7,0x3b, 0xa7,0x48,0xa5,0x40,0xa3,0x47,0x9f,0x3e,0x9e,0x4a,0x9d,0x40,0x9f,0x4b,0x9f,0x42, 0xa2,0x45,0xa4,0x42,0xa7,0x44,0xa7,0x41,0xa9,0x4b,0xa7,0x40,0xa8,0x49,0xa6,0x45, 0xa3,0x47,0x9e,0x42,0x9d,0x48,0x9c,0x41,0x9c,0x4b,0x9d,0x41,0x9f,0x4b,0xa1,0x40, 0xa6,0x48,0xa7,0x41,0xa8,0x4c,0xa6,0x3e,0xa7,0x4b,0xa6,0x3d,0xa2,0x48,0xa0,0x3f, 0x9e,0x4b,0x9d,0x43,0x9c,0x49,0x9d,0x3d,0x9f,0x4b,0xa3,0x3f,0xa6,0x49,0xa7,0x43, 0xa8,0x4b,0xa8,0x41,0xa8,0x48,0xa5,0x40,0xa4,0x4d,0xa1,0x41,0x9d,0x47,0x9b,0x42, 0x9a,0x48,0x9c,0x43,0x9f,0x46,0x9f,0x40,0xa4,0x47,0xa6,0x42,0xa8,0x49,0xa8,0x42, 0xa9,0x4b,0xa7,0x3f,0xa3,0x47,0xa0,0x3e,0xa0,0x4e,0x9d,0x40,0x9c,0x45,0x9d,0x43, 0xa1,0x48,0xa3,0x3f,0xa4,0x46,0xa7,0x3f,0xa8,0x4d,0xa8,0x40,0xa8,0x4b,0xa6,0x3f, 0xa5,0x47,0xa1,0x3c,0x9d,0x45,0x9c,0x3d,0x9d,0x4c,0x9b,0x3f,0x9d,0x4c,0xa1,0x3f, 0xa5,0x4c,0xa7,0x43,0xa7,0x47,0xa9,0x3f,0xa9,0x4b,0xa5,0x3e,0xa3,0x48,0xa2,0x3e, 0xa0,0x47,0x9c,0x40,0x9a,0x49,0x9b,0x46,0x9e,0x50,0xa0,0x3f,0xa4,0x41,0xa5,0x38, 0xa8,0x47,0xa8,0x40,0xa6,0x43,0xa4,0x40,0xa3,0x4d,0x9a,0x44,0xa1,0x54,0x9f,0x52, 0xa0,0x56,0xa2,0x56,0xa4,0x62,0xa8,0x57,0xaa,0x62,0xab,0x55,0xac,0x59,0xac,0x55, 0xac,0x56,0xab,0x4e,0xa7,0x55,0xa5,0x4e,0xa3,0x5d,0xa0,0x54,0xa2,0x56,0xa1,0x51, 0xa4,0x57,0xa7,0x4f,0xa9,0x5a,0xaa,0x53,0xad,0x5e,0xac,0x4c,0xaa,0x58,0xac,0x4d, 0xa8,0x55,0xa5,0x4f,0xa4,0x54,0x9f,0x53,0xa0,0x5d,0xa0,0x50,0xa1,0x56,0xa3,0x4f, 0xa7,0x58,0xaa,0x54,0xaa,0x58,0xaa,0x4e,0xaa,0x58,0xab,0x4e,0xa6,0x56,0xa2,0x54, 0xa3,0x5c,0xa0,0x54,0x9d,0x54,0x9d,0x50,0xa1,0x58,0xa2,0x54,0xa6,0x5c,0xa9,0x4d, 0xaa,0x5b,0xaa,0x51,0xab,0x55,0xaa,0x4b,0xa7,0x5b,0xa4,0x52,0xa2,0x5a,0x9f,0x51, 0xa0,0x56,0x9f,0x4f,0xa1,0x59,0xa2,0x51,0xa7,0x59,0xa8,0x53,0xab,0x5e,0xab,0x51, 0xab,0x59,0xaa,0x53,0xa8,0x56,0xa4,0x4f,0xa2,0x5a,0x9f,0x4e,0x9d,0x59,0x9e,0x52, 0xa0,0x5b,0xa1,0x52,0xa4,0x5a,0xa7,0x4f,0xa9,0x5d,0xaa,0x4f,0xac,0x5c,0xa7,0x50, 0xa7,0x59,0xa4,0x51,0xa0,0x55,0x9d,0x50,0x9d,0x5d,0x9b,0x50,0x9d,0x58,0x9e,0x54, 0xa2,0x57,0xa6,0x4f,0xa8,0x56,0xa8,0x54,0xa9,0x5d,0xaa,0x4d,0xa6,0x59,0xa3,0x51, 0xa4,0x5c,0xa0,0x50,0x9d,0x58,0x9e,0x55,0x9f,0x5b,0xa1,0x54,0xa1,0x58,0xa5,0x52, 0xa8,0x59,0xa7,0x4f,0xa8,0x58,0xa8,0x54,0xa7,0x5c,0xa2,0x53,0xa2,0x59,0x9f,0x4e, 0x9e,0x58,0x9e,0x4f,0x9f,0x59,0xa0,0x54,0xa3,0x5f,0xa4,0x50,0xa7,0x57,0xa8,0x50, 0xa9,0x58,0xa7,0x50,0xa7,0x57,0xa4,0x4f,0xa0,0x5b,0x9e,0x4f,0x9d,0x59,0x9a,0x50, 0x9c,0x5b,0x9e,0x54,0xa0,0x59,0xa2,0x53,0xa5,0x5f,0xa6,0x52,0xa8,0x5d,0xa6,0x52, 0xa4,0x56,0xa1,0x51,0xa0,0x58,0x9e,0x54,0x9d,0x5c,0x9a,0x51,0x9c,0x5e,0x9d,0x51, 0x9f,0x57,0xa2,0x52,0xa5,0x5a,0xa4,0x54,0xa8,0x5e,0xa7,0x52,0xa6,0x58,0xa2,0x54, 0xa2,0x5d,0x9e,0x51,0x9c,0x57,0x9c,0x51,0x9c,0x5c,0x9b,0x4d,0x9f,0x58,0xa2,0x4f, 0xa5,0x5d,0xa5,0x4d,0xa7,0x57,0xa6,0x53,0xa5,0x57,0xa2,0x55,0x9f,0x5a,0x9e,0x52, 0x9c,0x5e,0x98,0x50,0x99,0x5b,0x9b,0x53,0x9f,0x58,0xa0,0x4e,0xa2,0x55,0xa4,0x54, 0xa4,0x59,0xa4,0x51,0xa4,0x5c,0xa1,0x52,0x9f,0x59,0x9c,0x51,0x9b,0x55,0x99,0x4f, 0x99,0x5c,0x99,0x54,0x9b,0x54,0x9e,0x51,0xa3,0x5e,0xa3,0x55,0xa3,0x58,0xa4,0x4e, 0xa6,0x5f,0xa1,0x52,0x9f,0x59,0x9d,0x53,0x9d,0x5e,0x99,0x50,0x99,0x59,0x99,0x51, 0x9c,0x59,0x9d,0x51,0xa0,0x58,0xa2,0x52,0xa4,0x5b,0xa5,0x4d,0xa5,0x5a,0xa0,0x52, 0x9f,0x55,0x9c,0x51,0x9b,0x59,0x96,0x4f,0x96,0x59,0x98,0x52,0x9a,0x58,0x9c,0x51, 0x9f,0x5a,0xa2,0x56,0xa4,0x59,0xa3,0x51,0xa3,0x57,0xa1,0x52,0x9e,0x55,0x9b,0x54, 0x9a,0x5a,0x97,0x54,0x97,0x55,0x97,0x50,0x99,0x55,0x99,0x51,0x9d,0x55,0xa1,0x4d, 0xa0,0x5a,0xa1,0x55,0xa2,0x5c,0x9f,0x51,0x9f,0x5c,0x9c,0x4a,0x9b,0x5b,0x96,0x54, 0x95,0x5c,0x95,0x52,0x98,0x5a,0x9a,0x51,0x9d,0x58,0xa0,0x4f,0xa0,0x53,0xa1,0x51, 0xa2,0x5c,0x9f,0x55,0x9d,0x59,0x9b,0x50,0x98,0x5c,0x96,0x55,0x94,0x58,0x94,0x52, 0x96,0x60,0x98,0x55,0x9c,0x58,0x9e,0x53,0xa1,0x5a,0xa0,0x53,0xa0,0x5a,0x9f,0x54, 0x9e,0x5b,0x9a,0x50,0x99,0x57,0x96,0x54,0x95,0x5c,0x94,0x55,0x95,0x5c,0x98,0x52, 0x9b,0x5c,0x9c,0x56,0x9e,0x59,0xa1,0x4e,0x9f,0x5c,0x9c,0x51,0x9c,0x5a,0x9b,0x55, 0x97,0x58,0x93,0x53,0x93,0x5a,0x92,0x55,0x94,0x5a,0x94,0x52,0x98,0x5d,0x9c,0x57, 0x9d,0x56,0x9e,0x51,0x9f,0x58,0x9c,0x53,0x9b,0x5b,0x98,0x50,0x98,0x5b,0x94,0x55, 0x92,0x5a,0x93,0x4f,0x95,0x55,0x94,0x54,0x98,0x5a,0x9a,0x4f,0x9d,0x58,0x9c,0x4f, 0x9d,0x58,0x9c,0x52,0x9c,0x54,0x99,0x4f,0x97,0x5b,0x93,0x52,0x91,0x5b,0x90,0x50, 0x92,0x5b,0x94,0x52,0x95,0x5a,0x98,0x50,0x9c,0x5e,0x9c,0x56,0x9e,0x5c,0x9c,0x51, 0x9e,0x5f,0x9a,0x55,0x98,0x5a,0x93,0x51,0x92,0x5a,0x92,0x4f,0x92,0x58,0x93,0x50, 0x96,0x5c,0x99,0x54,0x9c,0x58,0x9b,0x51,0x9c,0x5a,0x9c,0x53,0x9d,0x59,0x98,0x51, 0x96,0x5c,0x96,0x51,0x94,0x59,0x91,0x51,0x92,0x5a,0x95,0x52,0x97,0x59,0x99,0x53, 0x9d,0x5c,0x9d,0x51,0xa0,0x5b,0xa0,0x50,0xa0,0x5b,0x9d,0x50,0x9c,0x5b,0x98,0x52, 0x96,0x5a,0x95,0x55,0x95,0x51,0x95,0x50,0x99,0x5b,0x9a,0x55,0x9d,0x5a,0x9f,0x52, 0xa1,0x5b,0xa0,0x53,0xa0,0x57,0x9e,0x4e,0x9b,0x5a,0x98,0x52,0x97,0x5d,0x94,0x4f, 0x94,0x59,0x95,0x53,0x98,0x59,0x99,0x50,0x9c,0x59,0x9d,0x53,0xa0,0x59,0x9f,0x50, 0xa0,0x5a,0x9e,0x54,0x9c,0x57,0x97,0x58,0x96,0x5b,0x94,0x4f,0x93,0x58,0x93,0x51, 0x97,0x56,0x9a,0x52,0x9c,0x57,0x9d,0x50,0x9f,0x5a,0xa0,0x50,0xa0,0x59,0x9c,0x51, 0x9c,0x57,0x9a,0x53,0x96,0x55,0x92,0x54,0x92,0x59,0x91,0x52,0x95,0x5a,0x99,0x4e, 0x9c,0x5a,0x9d,0x51,0xa0,0x59,0x9f,0x50,0x9f,0x58,0x9e,0x54,0x9b,0x57,0x98,0x52, 0x98,0x59,0x94,0x51,0x93,0x5b,0x94,0x4f,0x98,0x5a,0x99,0x52,0x9d,0x5c,0x9f,0x53, 0xa0,0x5a,0xa1,0x50,0xa2,0x5b,0x9e,0x50,0x9d,0x5d,0x9b,0x54,0x98,0x59,0x95,0x4f, 0x94,0x55,0x95,0x50,0x97,0x55,0x99,0x53,0x9c,0x56,0xa0,0x54,0xa3,0x58,0xa2,0x52, 0xa2,0x58,0xa2,0x4e,0xa0,0x5c,0x9a,0x4f,0x96,0x5b,0x93,0x51,0x92,0x58,0x93,0x4a, 0x97,0x5c,0x98,0x53,0x9c,0x60,0xa0,0x54,0xa3,0x5a,0xa2,0x51,0xa3,0x57,0xa3,0x4e, 0xa2,0x5b,0x9e,0x4d,0x9c,0x5a,0x99,0x51,0x99,0x5d,0x98,0x4e,0x9a,0x5a,0x9b,0x54, 0x9d,0x5a,0xa0,0x4f,0xa3,0x53,0xa1,0x46,0xa3,0x58,0xa2,0x4d,0xa1,0x5a,0x9d,0x51, 0x9b,0x5b,0x94,0x55,0x9c,0x4b,0x9c,0x46,0x9e,0x4f,0xa2,0x4d,0xa5,0x5c,0xa7,0x4f, 0xa9,0x54,0xaa,0x4c,0xa8,0x51,0xa5,0x48,0xa4,0x52,0xa1,0x47,0x9f,0x4f,0x9d,0x4d, 0x9c,0x52,0x9d,0x46,0x9f,0x53,0x9f,0x45,0xa4,0x51,0xa5,0x47,0xa5,0x51,0xa8,0x48, 0xa9,0x4f,0xa5,0x47,0xa4,0x4f,0xa1,0x49,0x9e,0x55,0x9b,0x4c,0x9a,0x50,0x9c,0x47, 0x9d,0x4f,0xa1,0x47,0xa3,0x51,0xa5,0x49,0xa7,0x50,0xa9,0x47,0xa8,0x52,0xa6,0x47, 0xa4,0x53,0xa2,0x47,0x9f,0x4f,0x9b,0x48,0x9b,0x51,0x9b,0x4d,0x9e,0x4e,0x9f,0x49, 0xa2,0x4e,0xa4,0x48,0xa6,0x52,0xa7,0x4b,0xa7,0x50,0xa8,0x48,0xa5,0x50,0xa3,0x4c, 0x9f,0x52,0x9c,0x4b,0x99,0x51,0x9a,0x4a,0x9a,0x52,0x9d,0x48,0xa0,0x50,0xa4,0x49, 0xa6,0x4f,0xa7,0x48,0xa8,0x4b,0xa5,0x4d,0xa5,0x52,0xa1,0x4b,0x9e,0x51,0x9c,0x4d, 0x9b,0x4f,0x99,0x4a,0x9c,0x50,0x9c,0x4c,0xa0,0x52,0xa5,0x48,0xa5,0x51,0xa6,0x49, 0xa9,0x4f,0xa7,0x49,0xa6,0x4f,0xa1,0x49,0x9f,0x56,0x9d,0x45,0x9b,0x4f,0x9a,0x4c, 0x9b,0x51,0x9d,0x4b,0x9f,0x53,0xa3,0x46,0xa4,0x54,0xa6,0x4b,0xa8,0x4e,0xa5,0x49, 0xa3,0x50,0xa1,0x49,0xa0,0x4d,0x9b,0x4b,0x98,0x52,0x98,0x4b,0x9a,0x4d,0x9b,0x4a, 0x9d,0x50,0xa1,0x48,0xa4,0x50,0xa2,0x49,0xa4,0x53,0xa6,0x4a,0xa3,0x50,0x9f,0x4a, 0x9f,0x50,0x9b,0x48,0x9a,0x51,0x99,0x48,0x99,0x54,0x9c,0x4a,0x9e,0x4e,0xa0,0x48, 0xa3,0x4f,0xa5,0x49,0xa5,0x4f,0xa4,0x47,0xa4,0x54,0xa2,0x4a,0x9f,0x52,0x9c,0x44, 0x99,0x52,0x99,0x4a,0x98,0x50,0x9a,0x49,0x9b,0x51,0x9f,0x49,0xa3,0x52,0xa3,0x4a, 0xa5,0x50,0xa5,0x4a,0xa3,0x52,0xa2,0x4b,0x9e,0x52,0x9c,0x48,0x9a,0x52,0x99,0x4c, 0x98,0x53,0x99,0x48,0x9d,0x4e,0x9e,0x48,0xa1,0x52,0xa3,0x46,0xa5,0x52,0xa5,0x4e, 0xa3,0x52,0xa2,0x4c,0xa0,0x4d,0x9d,0x46,0x9a,0x52,0x99,0x4c,0x99,0x54,0x9b,0x49, 0x9c,0x54,0x9e,0x49,0xa2,0x52,0xa2,0x4b,0xa4,0x53,0xa5,0x4d,0xa3,0x52,0xa2,0x47, 0xa0,0x54,0x9a,0x4b,0x97,0x52,0x97,0x47,0x95,0x51,0x97,0x48,0x98,0x50,0x9a,0x51, 0x9f,0x55,0xa2,0x4a,0xa2,0x51,0xa2,0x47,0xa2,0x4e,0xa2,0x4c,0xa0,0x54,0x9b,0x49, 0x9a,0x4f,0x98,0x49,0x95,0x51,0x97,0x49,0x99,0x54,0x9d,0x4c,0x9f,0x51,0xa2,0x4b, 0xa2,0x53,0xa3,0x49,0xa3,0x4d,0xa1,0x47,0x9e,0x50,0x9c,0x4e,0x99,0x54,0x97,0x4a, 0x96,0x50,0x96,0x48,0x99,0x50,0x9b,0x48,0x9e,0x55,0xa1,0x4c,0xa3,0x55,0xa3,0x4c, 0xa3,0x52,0xa1,0x4b,0xa0,0x4f,0x9b,0x48,0x9a,0x54,0x97,0x49,0x94,0x50,0x96,0x44, 0x99,0x50,0x9a,0x48,0x9c,0x51,0x9f,0x46,0xa1,0x50,0xa3,0x46,0xa2,0x55,0xa1,0x4b, 0x9e,0x50,0x9c,0x49,0x99,0x50,0x95,0x49,0x94,0x53,0x95,0x48,0x97,0x4d,0x9a,0x4b, 0x9d,0x51,0x9f,0x47,0x9f,0x51,0xa0,0x46,0xa2,0x4e,0xa0,0x46,0x9c,0x53,0x9b,0x4a, 0x96,0x56,0x95,0x4d,0x93,0x54,0x94,0x48,0x95,0x56,0x97,0x4d,0x9b,0x54,0x9e,0x47, 0xa0,0x53,0xa0,0x4b,0xa0,0x52,0xa0,0x45,0x9d,0x54,0x9b,0x4c,0x97,0x50,0x96,0x4a, 0x94,0x52,0x95,0x4e,0x96,0x52,0x98,0x4a,0x9b,0x4f,0x9b,0x52,0x9e,0x50,0x9f,0x49, 0xa0,0x55,0x9f,0x49,0x9e,0x4e,0x9a,0x49,0x98,0x56,0x94,0x4c,0x95,0x53,0x93,0x4a, 0x93,0x51,0x97,0x4c,0x98,0x50,0x9c,0x4a,0xa0,0x56,0xa0,0x4c,0x9d,0x56,0x9f,0x4e, 0xa0,0x52,0x9c,0x4b,0x98,0x53,0x96,0x48,0x94,0x54,0x92,0x49,0x93,0x53,0x98,0x4a, 0x99,0x51,0x9b,0x48,0x9e,0x51,0x9f,0x49,0xa1,0x57,0xa0,0x47,0x9e,0x51,0x9d,0x4b, 0x99,0x50,0x98,0x4a,0x94,0x53,0x93,0x4b,0x93,0x52,0x96,0x4b,0x99,0x55,0x9c,0x48, 0x9d,0x53,0xa2,0x4c,0xa1,0x53,0x9f,0x4d,0x9e,0x56,0x9f,0x4c,0x9b,0x4f,0x96,0x46, 0x95,0x57,0x94,0x47,0x94,0x52,0x97,0x4b,0x9b,0x5b,0x9c,0x4b,0x9e,0x51,0xa0,0x4d, 0xa1,0x52,0xa2,0x4d,0xa0,0x50,0x9e,0x49,0x9b,0x52,0x99,0x4b,0x97,0x50,0x95,0x4c, 0x95,0x53,0x98,0x4a,0x9a,0x52,0x9c,0x49,0x9f,0x4c,0xa0,0x50,0xa2,0x53,0xa1,0x4b, 0xa0,0x50,0x9f,0x4b,0x9c,0x52,0x97,0x4b,0x94,0x51,0x93,0x49,0x96,0x54,0x96,0x4b, 0x99,0x51,0x9c,0x4a,0xa0,0x52,0xa3,0x49,0xa3,0x4e,0xa1,0x49,0xa0,0x52,0xa0,0x48, 0x9e,0x54,0x9b,0x4c,0x99,0x54,0x96,0x4a,0x96,0x53,0x98,0x4b,0x99,0x55,0x9d,0x4c, 0xa0,0x51,0xa2,0x49,0xa3,0x51,0xa2,0x4b,0xa3,0x54,0xa2,0x4d,0x9f,0x53,0x9d,0x4a, 0x9a,0x55,0x9a,0x4c,0x99,0x4d,0x9a,0x4a,0x9c,0x56,0x9e,0x46,0xa1,0x53,0xa4,0x48, 0xa5,0x55,0xa6,0x4c,0xa4,0x50,0xa4,0x48,0xa0,0x50,0x9e,0x48,0x9c,0x54,0x99,0x48, 0x98,0x56,0x99,0x4b,0x9b,0x4d,0x9e,0x46,0xa0,0x53,0xa2,0x4b,0xa5,0x4e,0xa5,0x49, 0xa4,0x55,0xa3,0x50,0xa0,0x50,0x9d,0x4a,0x9c,0x51,0x9a,0x4b,0x97,0x55,0x99,0x4b, 0x9b,0x54,0x9f,0x4c,0xa1,0x54,0xa4,0x45,0xa5,0x56,0xa6,0x4a,0xa6,0x50,0xa5,0x4d, 0xa2,0x54,0xa0,0x4a,0x9d,0x4f,0x9a,0x4c,0x9a,0x51,0x99,0x4a,0x9b,0x50,0x9e,0x48, 0xa1,0x55,0xa4,0x4e,0xa5,0x50,0xa5,0x49,0xa7,0x59,0xa3,0x48,0xa3,0x58,0xa0,0x48, 0x9d,0x57,0x99,0x49,0x9a,0x4f,0x9b,0x4b,0x9c,0x55,0x9d,0x4d,0x9e,0x54,0xa1,0x4b, 0xa6,0x54,0xa4,0x4c,0xa2,0x51,0xa2,0x4e,0xa4,0x4e,0x9e,0x4b,0x9b,0x51,0x9a,0x48, 0x9a,0x54,0x9b,0x4c,0x9b,0x50,0x9c,0x4a,0xa0,0x55,0xa3,0x4b,0xa6,0x53,0xa6,0x4b, 0xa6,0x56,0xa5,0x4b,0xa4,0x54,0xa2,0x4c,0x9e,0x52,0x9c,0x4d,0x9b,0x52,0x99,0x49, 0x9b,0x56,0x9e,0x4e,0x9f,0x4f,0xa2,0x4b,0xa6,0x54,0xa7,0x47,0xa6,0x48,0xa6,0x43, 0xa5,0x4e,0xa2,0x49,0xa1,0x4e,0x9b,0x48,0x98,0x52,0x95,0x4f,0xa1,0x35,0xa4,0x30, 0xa9,0x3b,0xab,0x3b,0xad,0x46,0xac,0x3b,0xad,0x44,0xad,0x3b,0xa9,0x3a,0xa6,0x35, 0xa5,0x3e,0xa1,0x35,0x9e,0x39,0x9f,0x33,0xa3,0x3c,0xa5,0x33,0xa9,0x3d,0xaa,0x35, 0xad,0x42,0xae,0x33,0xae,0x3b,0xac,0x33,0xab,0x3d,0xa8,0x37,0xa5,0x3a,0xa2,0x38, 0xa0,0x3b,0xa1,0x36,0xa4,0x38,0xa5,0x35,0xa9,0x3d,0xad,0x33,0xae,0x3a,0xaf,0x32, 0xb1,0x3c,0xb0,0x35,0xae,0x36,0xaa,0x33,0xa8,0x3b,0xa5,0x3a,0xa4,0x3b,0xa4,0x36, 0xa5,0x3d,0xa6,0x36,0xaa,0x39,0xad,0x32,0xae,0x40,0xb0,0x34,0xb0,0x3b,0xaf,0x35, 0xaf,0x3d,0xab,0x35,0xa8,0x3d,0xa4,0x32,0xa4,0x3c,0xa5,0x36,0xa4,0x3c,0xa5,0x32, 0xa9,0x37,0xab,0x32,0xaf,0x3b,0xae,0x33,0xb0,0x3c,0xb0,0x32,0xad,0x3a,0xaa,0x33, 0xa9,0x3d,0xa7,0x35,0xa4,0x3b,0xa2,0x34,0xa6,0x42,0xa7,0x32,0xaa,0x3f,0xae,0x32, 0xb0,0x3c,0xb0,0x36,0xb3,0x3d,0xb1,0x32,0xb1,0x3d,0xad,0x31,0xa9,0x40,0xa7,0x36, 0xa6,0x3d,0xa3,0x33,0xa4,0x3b,0xa7,0x38,0xa9,0x3e,0xad,0x37,0xb0,0x39,0xaf,0x38, 0xb2,0x3d,0xb0,0x38,0xaf,0x3b,0xad,0x35,0xa9,0x3e,0xa5,0x33,0xa3,0x3c,0xa2,0x39, 0xa3,0x3e,0xa4,0x31,0xa7,0x3d,0xaa,0x33,0xac,0x3a,0xaf,0x38,0xb0,0x34,0xaf,0x39, 0xac,0x40,0xac,0x33,0xa9,0x3b,0xa4,0x35,0xa2,0x3a,0xa0,0x36,0xa2,0x3d,0xa3,0x33, 0xa6,0x3e,0xaa,0x34,0xac,0x3c,0xae,0x36,0xae,0x3f,0xaf,0x2f,0xaf,0x3d,0xac,0x34, 0xa9,0x3f,0xa6,0x35,0xa4,0x39,0xa1,0x35,0xa1,0x40,0xa0,0x35,0xa4,0x3d,0xa9,0x33, 0xaa,0x3a,0xab,0x35,0xae,0x3b,0xaf,0x33,0xac,0x3e,0xaa,0x34,0xaa,0x3a,0xa7,0x39, 0xa3,0x40,0xa2,0x35,0xa2,0x39,0xa1,0x33,0xa7,0x3f,0xa7,0x33,0xab,0x3e,0xae,0x38, 0xaf,0x42,0xaf,0x35,0xb0,0x3d,0xac,0x33,0xaa,0x3e,0xa8,0x35,0xa6,0x39,0xa3,0x38, 0xa2,0x39,0xa4,0x37,0xa7,0x3c,0xa9,0x34,0xac,0x3c,0xae,0x37,0xb0,0x3d,0xb0,0x34, 0xb0,0x3e,0xae,0x33,0xab,0x3e,0xa7,0x32,0xa5,0x41,0xa3,0x32,0xa3,0x3d,0xa4,0x38, 0xa6,0x3b,0xa6,0x34,0xac,0x39,0xae,0x38,0xb0,0x41,0xaf,0x33,0xb0,0x3b,0xad,0x31, 0xaa,0x3e,0xa7,0x34,0xa6,0x3a,0xa2,0x33,0xa2,0x3f,0xa2,0x34,0xa5,0x3e,0xa8,0x35, 0xab,0x3e,0xae,0x37,0xb0,0x3a,0xaf,0x36,0xb0,0x3d,0xb0,0x32,0xae,0x3a,0xa9,0x34, 0xa9,0x3d,0xa4,0x35,0xa3,0x3e,0xa4,0x37,0xa6,0x3f,0xa7,0x33,0xad,0x3b,0xad,0x32, 0xb0,0x3c,0xb0,0x34,0xb1,0x3f,0xae,0x38,0xab,0x3b,0xa8,0x35,0xa5,0x39,0xa1,0x34, 0xa0,0x3b,0xa1,0x31,0xa3,0x3b,0xa5,0x34,0xa8,0x40,0xad,0x37,0xad,0x3e,0xaf,0x37, 0xb1,0x3c,0xae,0x33,0xab,0x3b,0xa9,0x38,0xa6,0x3d,0xa3,0x32,0xa2,0x3d,0xa1,0x32, 0xa4,0x3b,0xa6,0x33,0xa9,0x3c,0xac,0x36,0xae,0x40,0xaf,0x34,0xb0,0x3e,0xae,0x32, 0xae,0x3c,0xab,0x35,0xa9,0x3b,0xa5,0x36,0xa3,0x3b,0xa2,0x35,0xa3,0x42,0xa7,0x37, 0xa7,0x42,0xac,0x37,0xae,0x37,0xae,0x35,0xb1,0x3c,0xae,0x37,0xae,0x3d,0xab,0x39, 0xa9,0x3d,0xa4,0x3c,0xa3,0x3a,0xa2,0x35,0xa3,0x41,0xa5,0x38,0xa7,0x41,0xaa,0x34, 0xaf,0x3e,0xae,0x38,0xb0,0x3d,0xaf,0x34,0xae,0x46,0xaa,0x38,0xa8,0x39,0xa5,0x36, 0xa4,0x3e,0xa2,0x34,0xa3,0x3e,0xa4,0x36,0xa6,0x40,0xaa,0x38,0xad,0x3e,0xad,0x3a, 0xaf,0x3b,0xaf,0x37,0xad,0x3d,0xaa,0x36,0xa6,0x42,0xa4,0x38,0xa2,0x40,0xa1,0x36, 0xa2,0x43,0xa3,0x30,0xa7,0x3e,0xaa,0x36,0xad,0x44,0xac,0x3a,0xad,0x3e,0xad,0x38, 0xac,0x40,0xa8,0x36,0xa5,0x3d,0xa5,0x36,0xa0,0x45,0x9e,0x37,0xa0,0x3f,0xa4,0x33, 0xa5,0x3f,0xa7,0x35,0xaa,0x3d,0xac,0x35,0xae,0x40,0xae,0x3a,0xab,0x3f,0xa9,0x35, 0xa8,0x3f,0xa2,0x34,0xa2,0x37,0xa0,0x38,0x9f,0x40,0xa0,0x33,0xa4,0x3f,0xa6,0x36, 0xab,0x3e,0xac,0x38,0xad,0x3d,0xae,0x39,0xaf,0x3f,0xaa,0x3a,0xa7,0x3a,0xa6,0x35, 0xa4,0x41,0xa1,0x3b,0xa1,0x3c,0xa1,0x33,0xa2,0x40,0xa4,0x37,0xa8,0x3b,0xaa,0x36, 0xad,0x3e,0xac,0x38,0xab,0x3b,0xa9,0x37,0xa9,0x43,0xa5,0x38,0xa2,0x3e,0xa0,0x38, 0xa2,0x3f,0xa2,0x35,0xa4,0x3c,0xa6,0x37,0xaa,0x44,0xac,0x37,0xad,0x41,0xad,0x33, 0xb0,0x3e,0xac,0x35,0xaa,0x3c,0xa7,0x38,0xa4,0x3e,0xa2,0x35,0xa1,0x3c,0xa1,0x34, 0xa5,0x3f,0xa5,0x33,0xa8,0x3d,0xa9,0x35,0xac,0x46,0xad,0x38,0xab,0x3f,0xab,0x32, 0xab,0x3c,0xa6,0x39,0xa5,0x3b,0xa3,0x37,0xa1,0x41,0xa1,0x38,0xa2,0x41,0xa6,0x36, 0xa8,0x3e,0xac,0x37,0xae,0x40,0xb0,0x37,0xae,0x45,0xad,0x39,0xac,0x3e,0xa8,0x38, 0xa7,0x3e,0xa3,0x36,0xa1,0x3c,0xa1,0x32,0xa3,0x42,0xa4,0x37,0xa9,0x3a,0xaa,0x37, 0xac,0x42,0xad,0x32,0xad,0x42,0xab,0x31,0xab,0x41,0xa7,0x35,0xa5,0x40,0xa4,0x35, 0xa1,0x3e,0xa2,0x33,0xa3,0x3f,0xa5,0x39,0xa9,0x3e,0xab,0x38,0xae,0x3f,0xaf,0x36, 0xaf,0x3c,0xad,0x34,0xac,0x40,0xa9,0x38,0xa6,0x3e,0xa3,0x37,0xa2,0x3e,0xa1,0x34, 0xa3,0x40,0xa6,0x34,0xa8,0x3c,0xac,0x35,0xae,0x3f,0xad,0x37,0xaf,0x3e,0xae,0x38, 0xae,0x3f,0xa8,0x3d,0xa7,0x3d,0xa4,0x35,0xa1,0x3c,0xa1,0x36,0xa0,0x42,0xa2,0x35, 0xa7,0x3e,0xaa,0x36,0xab,0x3a,0xab,0x34,0xac,0x44,0xad,0x37,0xab,0x38,0xa9,0x36, 0xa8,0x40,0xa2,0x36,0xa2,0x40,0xa2,0x33,0x9f,0x40,0xa1,0x35,0xa8,0x41,0xaa,0x35, 0xa9,0x3c,0xad,0x3a,0xaf,0x3d,0xad,0x3a,0xac,0x3f,0xaa,0x37,0xa8,0x3f,0xa6,0x36, 0xa2,0x40,0xa2,0x37,0xa4,0x3e,0xa5,0x34,0xa8,0x42,0xaa,0x33,0xae,0x3d,0xad,0x3b, 0xaf,0x45,0xaf,0x36,0xad,0x32,0xab,0x2a,0xa9,0x39,0xa6,0x34,0xa4,0x3d,0xa0,0x37, 0x9f,0x41,0x9d,0x3b,0xad,0x4e,0xaf,0x3d,0xb3,0x4f,0xb3,0x4e,0xb3,0x57,0xb3,0x4e, 0xb1,0x51,0xae,0x4a,0xac,0x4e,0xaa,0x4a,0xa7,0x4f,0xa6,0x44,0xa9,0x4b,0xab,0x4a, 0xae,0x4d,0xb1,0x44,0xb3,0x53,0xb4,0x43,0xb5,0x4f,0xb4,0x46,0xb3,0x4a,0xb0,0x49, 0xad,0x51,0xaa,0x46,0xa8,0x4b,0xa8,0x45,0xa9,0x52,0xab,0x48,0xaf,0x4b,0xb1,0x49, 0xb4,0x4a,0xb6,0x45,0xb7,0x4e,0xb5,0x49,0xb3,0x51,0xb2,0x47,0xaf,0x4c,0xac,0x44, 0xab,0x52,0xa9,0x43,0xab,0x51,0xab,0x41,0xac,0x54,0xb2,0x45,0xb2,0x4c,0xb4,0x48, 0xb3,0x4f,0xb4,0x46,0xb2,0x4c,0xb0,0x41,0xaf,0x4e,0xab,0x45,0xa9,0x50,0xa7,0x48, 0xaa,0x4d,0xa8,0x44,0xab,0x4c,0xaf,0x46,0xb2,0x54,0xb4,0x43,0xb7,0x4c,0xb6,0x46, 0xb3,0x4c,0xb0,0x48,0xb1,0x4c,0xaa,0x47,0xa6,0x53,0xa6,0x46,0xaa,0x47,0xaa,0x44, 0xad,0x4a,0xb2,0x48,0xb5,0x4f,0xb7,0x4a,0xb7,0x4f,0xb7,0x45,0xb6,0x4a,0xb3,0x45, 0xb0,0x51,0xae,0x46,0xae,0x4b,0xa9,0x44,0xa9,0x50,0xab,0x45,0xad,0x4e,0xaf,0x44, 0xb0,0x50,0xb4,0x47,0xb7,0x48,0xb4,0x45,0xb4,0x51,0xb5,0x46,0xb1,0x4b,0xae,0x45, 0xae,0x4d,0xab,0x40,0xac,0x4c,0xac,0x44,0xb0,0x51,0xb3,0x47,0xb6,0x4f,0xb7,0x42, 0xbb,0x4c,0xbb,0x46,0xba,0x4b,0xb8,0x47,0xb3,0x4d,0xb0,0x48,0xb1,0x4e,0xac,0x49, 0xa9,0x4e,0xaa,0x46,0xaf,0x4e,0xb0,0x47,0xb2,0x50,0xb7,0x48,0xb9,0x4c,0xb9,0x46, 0xbb,0x4d,0xb8,0x44,0xb6,0x48,0xb3,0x41,0xb0,0x4d,0xaf,0x43,0xb1,0x4d,0xaf,0x48, 0xb2,0x4f,0xb4,0x43,0xb6,0x4d,0xba,0x46,0xba,0x4f,0xb9,0x44,0xbb,0x4b,0xba,0x46, 0xb8,0x4d,0xb4,0x46,0xb3,0x4c,0xb1,0x43,0xae,0x52,0xad,0x48,0xb1,0x50,0xb3,0x4a, 0xb6,0x4c,0xb6,0x46,0xb9,0x4c,0xb9,0x47,0xb9,0x4f,0xb7,0x46,0xb7,0x4e,0xb3,0x46, 0xb2,0x4b,0xb0,0x45,0xad,0x50,0xad,0x42,0xb0,0x55,0xb2,0x48,0xb7,0x4e,0xb8,0x44, 0xba,0x52,0xbb,0x4b,0xbd,0x4e,0xbd,0x49,0xb8,0x52,0xb6,0x48,0xb3,0x4f,0xaf,0x47, 0xb0,0x4e,0xad,0x47,0xaf,0x4a,0xb1,0x44,0xb6,0x50,0xb8,0x45,0xba,0x4c,0xb9,0x47, 0xbc,0x4c,0xb8,0x45,0xb5,0x4d,0xb1,0x48,0xaf,0x50,0xac,0x45,0xab,0x4b,0xab,0x4a, 0xaf,0x4f,0xb2,0x44,0xb5,0x49,0xb7,0x47,0xbc,0x4e,0xbc,0x46,0xbe,0x4c,0xbb,0x45, 0xb6,0x51,0xb6,0x4a,0xb3,0x4c,0xae,0x46,0xae,0x52,0xae,0x45,0xb0,0x4e,0xb1,0x46, 0xb4,0x4f,0xb6,0x43,0xbc,0x4b,0xba,0x45,0xbb,0x50,0xbb,0x45,0xbc,0x4d,0xb6,0x44, 0xb3,0x52,0xb2,0x45,0xb1,0x4a,0xac,0x46,0xae,0x52,0xb3,0x46,0xb5,0x4d,0xb6,0x43, 0xbb,0x4f,0xbc,0x4a,0xbc,0x4d,0xbc,0x41,0xba,0x51,0xb7,0x46,0xb5,0x4c,0xb2,0x45, 0xad,0x51,0xae,0x44,0xae,0x4f,0xaf,0x46,0xb1,0x4d,0xb3,0x45,0xb9,0x4d,0xba,0x49, 0xbb,0x50,0xbc,0x42,0xbb,0x4c,0xb8,0x44,0xb4,0x4e,0xb1,0x47,0xae,0x4d,0xab,0x47, 0xad,0x4d,0xad,0x41,0xb0,0x4c,0xb3,0x48,0xb8,0x52,0xb8,0x49,0xb9,0x4d,0xbb,0x4c, 0xba,0x4f,0xb4,0x45,0xb4,0x4f,0xb2,0x46,0xad,0x50,0xab,0x45,0xac,0x4d,0xb0,0x4a, 0xb2,0x4e,0xb5,0x4a,0xb8,0x50,0xba,0x4a,0xbb,0x4e,0xbb,0x4a,0xba,0x4a,0xb7,0x4a, 0xb6,0x4b,0xb2,0x46,0xaf,0x4e,0xac,0x46,0xad,0x54,0xad,0x46,0xb0,0x4e,0xb2,0x41, 0xb6,0x4e,0xb7,0x48,0xb9,0x53,0xb9,0x43,0xb9,0x56,0xb8,0x4a,0xb5,0x52,0xb2,0x45, 0xb1,0x4f,0xb0,0x4a,0xb0,0x4e,0xb0,0x46,0xb1,0x4e,0xb5,0x43,0xb7,0x4f,0xb6,0x45, 0xba,0x4f,0xb8,0x47,0xb7,0x4e,0xb4,0x45,0xb3,0x50,0xb1,0x4a,0xae,0x4c,0xad,0x46, 0xaa,0x50,0xab,0x45,0xaf,0x52,0xb2,0x48,0xb2,0x51,0xb3,0x43,0xb8,0x51,0xb8,0x47, 0xb7,0x4e,0xb6,0x46,0xb3,0x4e,0xb0,0x46,0xae,0x54,0xad,0x46,0xab,0x4c,0xaa,0x45, 0xaf,0x50,0xb0,0x48,0xb3,0x4d,0xb4,0x46,0xb6,0x4e,0xb6,0x47,0xb5,0x4b,0xb2,0x45, 0xb1,0x4d,0xae,0x48,0xaf,0x4b,0xac,0x48,0xac,0x53,0xad,0x48,0xae,0x4d,0xb1,0x44, 0xb4,0x50,0xb5,0x46,0xb8,0x4b,0xb9,0x45,0xb8,0x55,0xb8,0x44,0xb6,0x4c,0xb2,0x46, 0xb1,0x4c,0xac,0x4a,0xaa,0x4b,0xac,0x47,0xac,0x50,0xad,0x43,0xb2,0x4c,0xb4,0x47, 0xb5,0x4b,0xb6,0x49,0xb6,0x4d,0xb5,0x42,0xb4,0x55,0xb3,0x47,0xb0,0x4f,0xad,0x46, 0xab,0x51,0xac,0x46,0xaf,0x4b,0xaf,0x47,0xb2,0x55,0xb5,0x45,0xb8,0x4c,0xb7,0x43, 0xb7,0x50,0xb7,0x44,0xb5,0x50,0xb1,0x47,0xae,0x55,0xac,0x45,0xab,0x4c,0xa9,0x4b, 0xac,0x4c,0xae,0x47,0xb1,0x50,0xb5,0x45,0xb7,0x52,0xb9,0x46,0xb9,0x4f,0xb7,0x49, 0xb8,0x4b,0xb6,0x47,0xb1,0x4c,0xad,0x46,0xae,0x4d,0xad,0x44,0xac,0x50,0xae,0x46, 0xb1,0x4b,0xb4,0x4a,0xb6,0x4b,0xb7,0x47,0xb7,0x54,0xb7,0x45,0xb6,0x4e,0xb4,0x45, 0xb2,0x53,0xae,0x47,0xad,0x49,0xab,0x47,0xa6,0x54,0xa8,0x46,0xb0,0x4d,0xb1,0x46, 0xb1,0x51,0xb4,0x48,0xba,0x4c,0xb8,0x44,0xb8,0x4d,0xb6,0x46,0xb3,0x4d,0xb0,0x46, 0xb2,0x4d,0xac,0x48,0xa4,0x4b,0xa7,0x44,0xb3,0x51,0xab,0x44,0xa8,0x52,0xb7,0x45, 0xbb,0x4e,0xb5,0x46,0xb7,0x4c,0xb5,0x44,0xb3,0x55,0xb0,0x42,0xae,0x4f,0xae,0x45, 0xae,0x4d,0xaf,0x49,0xb1,0x4e,0xb2,0x47,0xb4,0x50,0xb8,0x48,0xba,0x4e,0xb6,0x45, 0xb7,0x4b,0xb6,0x47,0xb1,0x4a,0xae,0x45,0xad,0x4e,0xad,0x47,0xac,0x4e,0xac,0x48, 0xaf,0x4a,0xb0,0x44,0xb2,0x4b,0xb5,0x4a,0xb7,0x50,0xb6,0x44,0xb6,0x4e,0xb3,0x46, 0xb1,0x50,0xb0,0x47,0xac,0x4c,0xaa,0x43,0xac,0x53,0xac,0x44,0xaf,0x4a,0xb0,0x43, 0xb4,0x4b,0xb6,0x47,0xb6,0x50,0xb5,0x49,0xb5,0x51,0xb3,0x40,0xaf,0x45,0xad,0x3e, 0xac,0x4f,0xa8,0x46,0xa8,0x4e,0xa9,0x48,0xab,0x4f,0xa7,0x4b,0xba,0x1e,0xbb,0x10, 0xbc,0x1d,0xbc,0x16,0xbb,0x2b,0xb7,0x18,0xb4,0x21,0xb1,0x15,0xaf,0x1c,0xac,0x16, 0xae,0x1d,0xae,0x13,0xae,0x1a,0xb2,0x15,0xb6,0x20,0xb6,0x12,0xb6,0x20,0xb8,0x15, 0xb8,0x1d,0xb5,0x17,0xb2,0x19,0xb0,0x13,0xad,0x20,0xaa,0x14,0xab,0x20,0xac,0x17, 0xb1,0x1c,0xb3,0x11,0xb6,0x1c,0xb6,0x16,0xb9,0x20,0xba,0x15,0xb8,0x1a,0xb6,0x16, 0xb3,0x1f,0xad,0x11,0xab,0x1b,0xa8,0x12,0xa9,0x1e,0xa9,0x18,0xac,0x19,0xaf,0x15, 0xb4,0x1b,0xb6,0x13,0xb6,0x1f,0xb6,0x16,0xb6,0x20,0xb3,0x12,0xb0,0x19,0xac,0x14, 0xac,0x1c,0xa8,0x13,0xa9,0x19,0xab,0x14,0xad,0x1f,0xac,0x13,0xb2,0x1c,0xb3,0x13, 0xb3,0x19,0xb3,0x13,0xb3,0x1f,0xad,0x16,0xad,0x1f,0xa9,0x18,0xa5,0x1c,0xa2,0x1b, 0xa1,0x1c,0xa3,0x12,0xa9,0x1a,0xa9,0x0f,0xab,0x1e,0xb0,0x16,0xb3,0x1a,0xb5,0x18, 0xb4,0x18,0xb3,0x16,0xb0,0x20,0xac,0x14,0xab,0x1c,0xa7,0x18,0xa8,0x1e,0xa7,0x15, 0xaa,0x1c,0xaa,0x12,0xb0,0x1c,0xb0,0x14,0xb1,0x21,0xb4,0x13,0xb4,0x1c,0xaf,0x16, 0xaf,0x1b,0xac,0x14,0xa9,0x1c,0xa5,0x15,0xa6,0x1c,0xa5,0x14,0xa7,0x1c,0xaa,0x15, 0xad,0x1d,0xaf,0x12,0xb1,0x1d,0xb2,0x15,0xb2,0x1f,0xb0,0x14,0xae,0x18,0xaa,0x16, 0xa8,0x19,0xa5,0x13,0xa3,0x1d,0xa4,0x16,0xa7,0x1e,0xa7,0x14,0xab,0x1c,0xad,0x17, 0xb1,0x1d,0xb2,0x13,0xb1,0x1d,0xb0,0x13,0xb0,0x1c,0xad,0x17,0xab,0x1e,0xa7,0x16, 0xa4,0x1b,0xa5,0x15,0xa5,0x1e,0xa6,0x11,0xab,0x1c,0xae,0x17,0xb0,0x1d,0xb1,0x19, 0xb3,0x1a,0xb1,0x11,0xb0,0x1a,0xaa,0x15,0xa8,0x21,0xa5,0x16,0xa4,0x22,0xa2,0x15, 0xa5,0x1f,0xa6,0x17,0xa9,0x1e,0xab,0x12,0xae,0x21,0xb0,0x15,0xb2,0x1c,0xb1,0x18, 0xaf,0x19,0xae,0x15,0xac,0x1e,0xa8,0x18,0xa5,0x20,0xa5,0x13,0xa6,0x1c,0xa5,0x16, 0xa8,0x1c,0xac,0x14,0xad,0x1e,0xac,0x14,0xad,0x22,0xaf,0x17,0xac,0x1c,0xab,0x17, 0xaa,0x19,0xa9,0x18,0xa7,0x1e,0xa5,0x12,0xa6,0x21,0xa5,0x15,0xa9,0x1c,0xa8,0x10, 0xab,0x18,0xab,0x18,0xb0,0x1d,0xab,0x12,0xab,0x20,0xaa,0x10,0xaa,0x1e,0xa6,0x13, 0xa4,0x20,0xa4,0x1a,0xa4,0x1d,0xa7,0x14,0xaa,0x1f,0xab,0x15,0xaf,0x1c,0xb1,0x18, 0xb1,0x1d,0xaf,0x13,0xaf,0x17,0xad,0x14,0xaa,0x22,0xa6,0x12,0xa4,0x1c,0xa2,0x11, 0xa3,0x1f,0xa5,0x16,0xa7,0x1d,0xa8,0x15,0xab,0x20,0xae,0x15,0xb0,0x1e,0xaf,0x15, 0xaf,0x1c,0xac,0x16,0xaa,0x1d,0xa7,0x15,0xa5,0x21,0xa4,0x12,0xa3,0x1c,0xa4,0x17, 0xa9,0x1f,0xa8,0x16,0xac,0x1e,0xad,0x16,0xae,0x20,0xae,0x16,0xaf,0x1a,0xac,0x14, 0xaa,0x1c,0xa7,0x15,0xa5,0x1c,0xa3,0x17,0xa3,0x1e,0xa2,0x11,0xa6,0x1e,0xa6,0x18, 0xa8,0x20,0xab,0x14,0xae,0x18,0xac,0x15,0xac,0x23,0xad,0x14,0xaa,0x1e,0xa6,0x12, 0xa4,0x19,0xa2,0x19,0xa3,0x19,0xa4,0x16,0xa4,0x23,0xa8,0x15,0xab,0x20,0xad,0x14, 0xaf,0x1f,0xaf,0x18,0xae,0x1f,0xac,0x12,0xaa,0x21,0xa9,0x19,0xa5,0x21,0xa3,0x15, 0xa4,0x1f,0xa3,0x14,0xa4,0x1e,0xa7,0x1a,0xaa,0x1b,0xa9,0x10,0xab,0x1e,0xac,0x15, 0xad,0x1e,0xa9,0x14,0xa8,0x1e,0xa4,0x13,0xa2,0x22,0xa1,0x17,0x9f,0x1f,0x9f,0x14, 0xa3,0x1e,0xa5,0x17,0xa9,0x1d,0xaa,0x1a,0xac,0x23,0xad,0x18,0xad,0x1b,0xa9,0x16, 0xaa,0x1f,0xa5,0x16,0xa3,0x1a,0xa0,0x14,0xa0,0x25,0x9f,0x14,0xa1,0x1d,0xa2,0x18, 0xa6,0x1e,0xa9,0x16,0xac,0x1c,0xaa,0x14,0xaa,0x21,0xab,0x19,0xa8,0x1c,0xa4,0x11, 0xa3,0x1e,0xa1,0x16,0xa0,0x1d,0x9e,0x19,0x9e,0x20,0xa1,0x14,0xa5,0x1f,0xa6,0x18, 0xa8,0x20,0xab,0x17,0xa9,0x1d,0xaa,0x1b,0xab,0x1f,0xa5,0x13,0xa3,0x1d,0xa1,0x15, 0xa1,0x1c,0x9e,0x15,0x9f,0x1f,0xa1,0x17,0xa5,0x21,0xa7,0x17,0xa9,0x24,0xaa,0x19, 0xac,0x1f,0xa9,0x19,0xa8,0x1e,0xa4,0x14,0xa2,0x1e,0xa0,0x19,0x9f,0x1e,0x9d,0x16, 0x9f,0x1e,0x9f,0x15,0xa2,0x1a,0xa3,0x17,0xa5,0x1f,0xa5,0x19,0xa8,0x1e,0xa7,0x15, 0xa4,0x20,0xa5,0x1a,0xa4,0x1e,0xa0,0x1a,0xa0,0x1f,0x9e,0x15,0xa0,0x1e,0xa3,0x17, 0xa4,0x1e,0xa6,0x19,0xa8,0x1e,0xa7,0x15,0xa9,0x1d,0xa9,0x17,0xa8,0x1f,0xa6,0x19, 0xa3,0x20,0xa2,0x19,0x9e,0x1e,0x9c,0x14,0x9c,0x22,0x9d,0x15,0xa0,0x1e,0xa3,0x15, 0xa6,0x1e,0xa6,0x1b,0xa7,0x1e,0xa7,0x12,0xa6,0x21,0xa4,0x18,0xa2,0x1f,0x9e,0x15, 0x9d,0x20,0x9b,0x1a,0x9c,0x1f,0x9c,0x12,0x9f,0x20,0xa2,0x18,0xa5,0x21,0xa7,0x17, 0xa8,0x1a,0xa8,0x1a,0xa7,0x22,0xa5,0x18,0xa2,0x23,0x9f,0x16,0x9f,0x1d,0x9d,0x18, 0x9d,0x1d,0x9e,0x15,0xa0,0x1d,0xa1,0x18,0xa5,0x1e,0xa5,0x17,0xa7,0x1d,0xa7,0x19, 0xa6,0x1c,0xa3,0x19,0xa0,0x21,0x9e,0x18,0x9d,0x1d,0x9a,0x0f,0x9c,0x1f,0x9b,0x14, 0x9e,0x21,0xa0,0x1b,0xa3,0x1d,0xa4,0x15,0xa6,0x22,0xa7,0x17,0xa6,0x1d,0xa3,0x1b, 0xa1,0x23,0x9e,0x16,0x9c,0x1d,0x9b,0x1a,0x9a,0x21,0x9b,0x18,0x9f,0x1d,0x9e,0x14, 0xa0,0x20,0xa5,0x14,0xa5,0x1c,0xa4,0x17,0xa5,0x1f,0xa5,0x18,0xa2,0x19,0x9f,0x18, 0x9e,0x23,0x9c,0x16,0x9b,0x1a,0x9b,0x19,0x9b,0x20,0x9c,0x1d,0xa1,0x1f,0xa0,0x17, 0xa4,0x25,0xa5,0x17,0xa3,0x1b,0xa1,0x17,0xa2,0x1e,0x9e,0x17,0x9c,0x1d,0x99,0x1a, 0x99,0x21,0x9a,0x18,0x9a,0x1b,0x9d,0x17,0xa1,0x1e,0xa3,0x15,0xa5,0x1d,0xa6,0x18, 0xa5,0x22,0xa2,0x15,0xa2,0x21,0x9f,0x18,0x9d,0x1b,0x9c,0x17,0x9b,0x1d,0x9b,0x14, 0x9c,0x1c,0x9e,0x15,0xa0,0x1b,0xa2,0x14,0xa5,0x1f,0xa4,0x13,0xa4,0x25,0xa3,0x19, 0xa1,0x25,0x9e,0x15,0x9e,0x14,0x9a,0x12,0x9b,0x1e,0x99,0x18,0x9c,0x1d,0x9c,0x18, 0x9f,0x1d,0x9d,0x1d,0xa9,0x5e,0xaa,0x5f,0xaa,0x6b,0xa7,0x6a,0xa4,0x78,0xa1,0x6d, 0xa1,0x73,0x9d,0x66,0x9e,0x6b,0x9e,0x61,0xa0,0x6c,0xa2,0x61,0xa6,0x6e,0xa7,0x63, 0xa8,0x70,0xa8,0x65,0xa9,0x69,0xa6,0x5e,0xa4,0x6b,0xa1,0x67,0x9f,0x68,0x9c,0x65, 0x9f,0x6e,0x9e,0x63,0xa0,0x69,0xa0,0x60,0xa6,0x6c,0xa7,0x60,0xa8,0x68,0xa9,0x62, 0xaa,0x68,0xa8,0x63,0xa5,0x67,0xa2,0x61,0xa0,0x6c,0x9e,0x63,0x9d,0x69,0x9b,0x62, 0x9f,0x69,0xa1,0x61,0xa2,0x66,0xa4,0x63,0xaa,0x6a,0xa9,0x63,0xa8,0x68,0xa7,0x64, 0xa6,0x69,0xa3,0x63,0xa0,0x6d,0x9e,0x67,0x9e,0x70,0x9d,0x63,0x9e,0x6c,0xa0,0x60, 0xa4,0x6c,0xa5,0x63,0xa7,0x68,0xa6,0x64,0xa7,0x6c,0xa7,0x5f,0xa5,0x6e,0xa2,0x63, 0x9f,0x6c,0x9b,0x64,0x9a,0x67,0x9b,0x63,0x9c,0x6c,0x9e,0x63,0xa1,0x6a,0xa3,0x63, 0xa7,0x6a,0xa5,0x64,0xa6,0x6b,0xa5,0x62,0xa5,0x71,0xa2,0x5d,0x9f,0x68,0x9e,0x62, 0x9c,0x70,0x9d,0x64,0x9e,0x66,0x9f,0x61,0xa3,0x6a,0xa4,0x60,0xa6,0x6d,0xa7,0x63, 0xa7,0x70,0xa6,0x5f,0xa4,0x6b,0xa0,0x61,0xa0,0x6d,0x9d,0x62,0x9c,0x6c,0x9b,0x61, 0x9e,0x6d,0xa0,0x5f,0xa2,0x6b,0xa2,0x5f,0xa7,0x6b,0xa5,0x62,0xa6,0x6a,0xa5,0x5d, 0xa4,0x6e,0xa2,0x64,0xa0,0x68,0x9c,0x63,0x9b,0x68,0x9b,0x5f,0x9c,0x6c,0x9c,0x63, 0x9e,0x6d,0xa2,0x63,0xa1,0x66,0x99,0x60,0x9d,0x69,0xa2,0x62,0x97,0x66,0x92,0x60, 0x9b,0x6d,0x9a,0x60,0x95,0x6a,0x98,0x62,0x9c,0x6b,0x9c,0x65,0x9f,0x69,0xa1,0x61, 0xa4,0x6a,0xa4,0x64,0xa5,0x69,0xa5,0x5e,0xa4,0x6b,0xa0,0x63,0x9e,0x66,0x9c,0x5f, 0x98,0x66,0x97,0x61,0x99,0x67,0x99,0x61,0x9b,0x6a,0x9d,0x65,0xa0,0x6a,0xa1,0x65, 0xa3,0x6b,0xa2,0x61,0xa1,0x6c,0x9f,0x64,0x9d,0x6d,0x99,0x65,0x97,0x69,0x94,0x63, 0x97,0x6a,0x98,0x64,0x99,0x63,0x9c,0x62,0xa1,0x6d,0xa1,0x61,0xa3,0x68,0xa2,0x63, 0xa2,0x6b,0x9f,0x62,0x9d,0x69,0x9b,0x64,0x98,0x69,0x96,0x64,0x97,0x6b,0x97,0x63, 0x9b,0x6b,0x9d,0x62,0x9f,0x6c,0xa1,0x65,0xa4,0x6b,0xa2,0x61,0xa2,0x6d,0xa0,0x61, 0x9e,0x68,0x9b,0x65,0x9a,0x68,0x98,0x61,0x98,0x6d,0x98,0x60,0x9b,0x6c,0x9e,0x5f, 0xa0,0x70,0xa1,0x60,0xa3,0x68,0xa4,0x5f,0xa3,0x69,0xa0,0x5f,0x9f,0x6d,0x9c,0x62, 0x9a,0x6b,0x98,0x68,0x98,0x68,0x97,0x64,0x9b,0x6d,0x9d,0x62,0x9e,0x6c,0xa0,0x63, 0xa4,0x6a,0xa2,0x63,0xa1,0x6b,0xa0,0x66,0x9f,0x6f,0x9b,0x60,0x9b,0x6c,0x98,0x64, 0x98,0x6d,0x99,0x62,0x9a,0x69,0x9c,0x67,0x9d,0x67,0xa0,0x69,0xa2,0x6a,0xa0,0x61, 0xa1,0x6c,0x9e,0x63,0x9d,0x66,0x99,0x61,0x99,0x6a,0x97,0x63,0x97,0x6a,0x96,0x60, 0x9a,0x6d,0x9a,0x60,0x9e,0x6a,0x9f,0x62,0xa1,0x6b,0xa1,0x61,0xa2,0x6a,0xa0,0x64, 0x9f,0x6b,0x9b,0x62,0x9a,0x6b,0x98,0x63,0x94,0x66,0x8e,0x63,0x94,0x67,0x9c,0x65, 0x97,0x6d,0x98,0x65,0xa1,0x6a,0xa1,0x62,0xa2,0x6c,0xa0,0x64,0x9f,0x6c,0x9c,0x67, 0x99,0x6b,0x97,0x64,0x95,0x66,0x94,0x63,0x98,0x69,0x99,0x61,0x9b,0x6a,0x9e,0x68, 0xa0,0x6e,0xa0,0x65,0xa0,0x69,0x9e,0x61,0x9d,0x6d,0x9a,0x68,0x98,0x6a,0x96,0x62, 0x95,0x6c,0x94,0x65,0x96,0x6c,0x94,0x61,0x9a,0x6d,0x9b,0x69,0x9b,0x69,0x9b,0x61, 0x9e,0x6f,0x9c,0x63,0x9b,0x6b,0x98,0x63,0x96,0x6d,0x91,0x62,0x91,0x6c,0x91,0x62, 0x94,0x6c,0x93,0x64,0x96,0x69,0x9b,0x68,0x9c,0x69,0x9c,0x62,0x9e,0x6d,0x9c,0x64, 0x9d,0x6f,0x99,0x62,0x98,0x6b,0x96,0x65,0x96,0x6e,0x94,0x64,0x97,0x6c,0x97,0x63, 0x9a,0x6b,0x9c,0x60,0x9f,0x6f,0x9f,0x67,0xa1,0x6c,0xa0,0x66,0x9f,0x6b,0x9c,0x63, 0x9c,0x6b,0x98,0x64,0x96,0x69,0x95,0x63,0x98,0x6d,0x98,0x65,0x9b,0x69,0x9e,0x64, 0x9f,0x71,0xa0,0x66,0xa2,0x6a,0xa0,0x65,0xa0,0x71,0x9e,0x5f,0x9b,0x6e,0x98,0x64, 0x98,0x69,0x96,0x65,0x95,0x6d,0x97,0x67,0x9a,0x6e,0x9b,0x63,0x9e,0x72,0xa0,0x5f, 0xa1,0x6a,0xa1,0x64,0x9f,0x6b,0x9c,0x63,0x9b,0x6f,0x98,0x64,0x95,0x6c,0x94,0x63, 0x95,0x6d,0x96,0x63,0x98,0x66,0x9a,0x64,0xa0,0x6f,0xa0,0x64,0xa1,0x6d,0xa0,0x64, 0xa0,0x6c,0x9e,0x66,0x9c,0x6d,0x99,0x65,0x99,0x6d,0x96,0x61,0x96,0x6d,0x96,0x65, 0x9a,0x6e,0x9b,0x65,0x9e,0x71,0x9f,0x62,0xa2,0x71,0xa1,0x66,0x9f,0x6b,0x9d,0x64, 0x9e,0x6e,0x9a,0x66,0x97,0x6c,0x95,0x63,0x95,0x72,0x97,0x65,0x9a,0x6c,0x99,0x63, 0x9d,0x70,0xa0,0x63,0xa1,0x6b,0x9f,0x61,0xa0,0x6d,0xa0,0x68,0x9d,0x6c,0x98,0x64, 0x98,0x6e,0x96,0x65,0x95,0x6a,0x96,0x63,0x99,0x6c,0x99,0x68,0x9c,0x70,0x9e,0x65, 0xa1,0x6f,0xa0,0x64,0x9f,0x71,0xa0,0x67,0x9d,0x71,0x99,0x5f,0x97,0x6b,0x97,0x6b, 0x96,0x6d,0x95,0x65,0x97,0x6e,0x99,0x67,0x9b,0x70,0x9d,0x6d,0x9f,0x6d,0xa0,0x68, 0x9f,0x71,0x9e,0x64,0x9d,0x6c,0x99,0x63,0x99,0x74,0x96,0x65,0x93,0x72,0x95,0x65, 0x96,0x70,0x9a,0x68,0x9b,0x6e,0x9e,0x66,0xa1,0x6f,0x9f,0x67,0xa0,0x6c,0x9f,0x66, 0x9c,0x6f,0x9a,0x65,0x98,0x69,0x96,0x65,0x95,0x6f,0x94,0x63,0x95,0x71,0x98,0x66, 0x9b,0x6b,0x9c,0x69,0x9d,0x6e,0x9e,0x67,0x9e,0x77,0x9e,0x67,0x9c,0x72,0x9a,0x66, 0x97,0x71,0x96,0x68,0x96,0x6c,0x92,0x67,0x95,0x6e,0x98,0x68,0x99,0x6e,0x9b,0x6b, 0x9e,0x70,0xa0,0x65,0xa0,0x6c,0x9d,0x65,0x9d,0x6f,0x9a,0x63,0x97,0x69,0x94,0x68, 0x93,0x6d,0x93,0x62,0x95,0x6f,0x95,0x63,0x9a,0x6e,0x9c,0x65,0x9d,0x6a,0x9e,0x64, 0xa1,0x6e,0x9e,0x64,0x9c,0x68,0x9a,0x64,0x99,0x74,0x94,0x62,0x93,0x64,0x94,0x60, 0x95,0x69,0x96,0x65,0x99,0x6e,0x9c,0x61,0x9c,0x73,0x9a,0x6b,0xa3,0x59,0xa2,0x4f, 0xa1,0x58,0x9d,0x59,0x9c,0x66,0x99,0x5e,0x97,0x60,0x99,0x58,0x9a,0x5c,0x9a,0x57, 0xa0,0x5e,0xa2,0x55,0xa3,0x5d,0xa3,0x56,0xa5,0x64,0xa2,0x53,0xa1,0x62,0x9f,0x59, 0x9c,0x5b,0x9a,0x52,0x99,0x5c,0x98,0x55,0x9b,0x62,0x9c,0x56,0x9c,0x60,0x9f,0x54, 0xa3,0x5b,0xa2,0x58,0xa3,0x5b,0xa2,0x51,0xa2,0x60,0x9f,0x53,0x9e,0x5b,0x9a,0x56, 0x99,0x5f,0x97,0x55,0x99,0x5b,0x9b,0x56,0x9d,0x5f,0x9f,0x51,0xa2,0x5d,0xa3,0x55, 0xa5,0x5d,0xa2,0x54,0xa1,0x61,0x9e,0x59,0x9c,0x5e,0x99,0x57,0x98,0x5e,0x96,0x59, 0x99,0x5d,0x99,0x51,0x9d,0x5d,0x9e,0x53,0xa2,0x5e,0xa1,0x50,0xa3,0x5e,0xa1,0x54, 0xa0,0x5b,0x9d,0x56,0x9a,0x60,0x98,0x56,0x96,0x5b,0x95,0x59,0x96,0x5e,0x97,0x53, 0x9a,0x5c,0x9e,0x54,0x9f,0x5c,0xa0,0x54,0xa2,0x5f,0xa1,0x51,0xa0,0x60,0x9d,0x50, 0x9c,0x5d,0x99,0x54,0x97,0x5a,0x95,0x50,0x96,0x60,0x98,0x56,0x9a,0x5a,0x9b,0x52, 0x9f,0x5d,0xa1,0x54,0x9f,0x5e,0x9f,0x53,0x9d,0x60,0x9c,0x54,0x9a,0x5c,0x97,0x59, 0x97,0x5b,0x94,0x52,0x94,0x5a,0x95,0x57,0x98,0x5f,0x9a,0x56,0x9e,0x5a,0x9e,0x53, 0x9f,0x5b,0x9f,0x53,0x9f,0x5d,0x9b,0x52,0x9b,0x5c,0x97,0x52,0x95,0x61,0x94,0x56, 0x95,0x5b,0x95,0x56,0x97,0x5e,0x9a,0x56,0x9c,0x5e,0x9f,0x57,0x9f,0x5b,0x9e,0x55, 0x9e,0x5a,0x9d,0x55,0x9a,0x5d,0x96,0x57,0x94,0x5e,0x93,0x51,0x92,0x5a,0x93,0x54, 0x97,0x5b,0x99,0x55,0x9b,0x5b,0x9c,0x51,0x9f,0x5d,0x9d,0x53,0x9d,0x5c,0x9d,0x57, 0x9a,0x5e,0x96,0x55,0x94,0x5b,0x91,0x52,0x92,0x61,0x92,0x57,0x93,0x5c,0x96,0x58, 0x9a,0x5d,0x9c,0x56,0x9d,0x5c,0x9c,0x55,0x9e,0x5e,0x9b,0x59,0x9a,0x5b,0x97,0x52, 0x96,0x5d,0x93,0x57,0x93,0x59,0x93,0x57,0x95,0x60,0x97,0x56,0x9a,0x5a,0x9d,0x58, 0x9f,0x5d,0x9d,0x56,0x9e,0x5d,0x9c,0x53,0x9a,0x62,0x97,0x52,0x97,0x5f,0x93,0x52, 0x92,0x5c,0x93,0x5c,0x95,0x5e,0x96,0x56,0x99,0x5e,0x9a,0x56,0x9d,0x5b,0x9d,0x57, 0x9d,0x5f,0x9c,0x58,0x99,0x5c,0x96,0x58,0x95,0x5f,0x92,0x56,0x90,0x60,0x91,0x55, 0x93,0x5c,0x95,0x56,0x98,0x58,0x9a,0x56,0x9c,0x5b,0x9c,0x56,0x9c,0x60,0x9b,0x57, 0x99,0x61,0x96,0x58,0x96,0x5e,0x92,0x56,0x91,0x61,0x90,0x57,0x93,0x5e,0x94,0x56, 0x97,0x62,0x9a,0x5c,0x9b,0x5e,0x9b,0x57,0x9c,0x5d,0x9a,0x5b,0x9b,0x5f,0x96,0x5a, 0x94,0x61,0x93,0x59,0x90,0x5c,0x8f,0x56,0x91,0x63,0x92,0x5a,0x93,0x61,0x97,0x59, 0x99,0x62,0x99,0x5a,0x9c,0x5d,0x9b,0x57,0x9a,0x5d,0x97,0x5a,0x95,0x5f,0x92,0x52, 0x91,0x61,0x91,0x5c,0x92,0x5a,0x92,0x58,0x94,0x61,0x97,0x5c,0x98,0x60,0x9b,0x5b, 0x9a,0x64,0x9a,0x5a,0x9a,0x5d,0x97,0x59,0x94,0x61,0x94,0x58,0x91,0x62,0x90,0x57, 0x90,0x5c,0x93,0x5b,0x94,0x60,0x97,0x5d,0x99,0x62,0x9b,0x5a,0x9a,0x64,0x9a,0x59, 0x99,0x68,0x98,0x5b,0x94,0x64,0x93,0x56,0x90,0x64,0x8f,0x5d,0x90,0x61,0x93,0x5f, 0x94,0x64,0x97,0x5b,0x98,0x5f,0x9a,0x5e,0x9a,0x65,0x99,0x59,0x98,0x60,0x98,0x5d, 0x95,0x63,0x91,0x5c,0x90,0x61,0x90,0x5d,0x8f,0x65,0x91,0x5c,0x93,0x62,0x96,0x5f, 0x99,0x68,0x99,0x5a,0x9b,0x61,0x99,0x5d,0x99,0x68,0x97,0x5c,0x95,0x67,0x92,0x62, 0x90,0x6c,0x90,0x5f,0x8d,0x61,0x8f,0x62,0x91,0x67,0x91,0x61,0x96,0x66,0x97,0x64, 0x98,0x68,0x98,0x64,0x98,0x69,0x95,0x61,0x94,0x6c,0x92,0x64,0x90,0x69,0x8d,0x63, 0x8f,0x6d,0x8e,0x61,0x90,0x6b,0x92,0x5f,0x95,0x6d,0x96,0x65,0x97,0x6c,0x96,0x6b, 0x96,0x72,0x94,0x65,0x93,0x67,0x8f,0x61,0x8e,0x6a,0x8d,0x69,0x8d,0x6d,0x8d,0x67, 0x8e,0x75,0x8f,0x6a,0x93,0x6c,0x94,0x62,0x94,0x73,0x96,0x65,0x96,0x6e,0x93,0x65, 0x92,0x72,0x90,0x64,0x8d,0x6d,0x8b,0x65,0x8a,0x70,0x8b,0x67,0x8c,0x71,0x8e,0x6a, 0x92,0x6d,0x93,0x66,0x94,0x6d,0x94,0x68,0x94,0x70,0x92,0x67,0x91,0x71,0x8e,0x67, 0x8a,0x71,0x8a,0x65,0x89,0x6c,0x89,0x66,0x8b,0x6f,0x8d,0x65,0x91,0x6f,0x91,0x62, 0x94,0x6f,0x94,0x65,0x94,0x69,0x93,0x6a,0x92,0x71,0x8e,0x63,0x8d,0x6c,0x8a,0x62, 0x88,0x6f,0x89,0x67,0x8b,0x68,0x8b,0x63,0x8e,0x70,0x91,0x61,0x94,0x6b,0x93,0x68, 0x94,0x6d,0x93,0x65,0x92,0x67,0x8e,0x64,0x8d,0x6d,0x8a,0x63,0x88,0x68,0x89,0x65, 0x8b,0x71,0x8b,0x65,0x8d,0x6a,0x90,0x65,0x92,0x6f,0x92,0x62,0x91,0x70,0x91,0x61, 0x8f,0x72,0x8e,0x64,0x8d,0x6a,0x89,0x61,0x89,0x6c,0x88,0x62,0x8a,0x6e,0x8a,0x65, 0x8b,0x6e,0x8d,0x62,0x90,0x67,0x8f,0x64,0x91,0x6f,0x90,0x64,0x90,0x6f,0x8c,0x66, 0x8b,0x73,0x89,0x68,0x88,0x6b,0x86,0x64,0x87,0x76,0x88,0x69,0x8b,0x6f,0x8b,0x66, 0x8d,0x70,0x8f,0x65,0x90,0x6e,0x8e,0x68,0x8d,0x78,0x8d,0x6d,0x89,0x77,0x87,0x6c, 0x86,0x76,0x84,0x6c,0x84,0x73,0x85,0x6e,0x87,0x74,0x88,0x6b,0x8b,0x75,0x8d,0x6f, 0x8d,0x79,0x8e,0x6c,0x8c,0x74,0x8a,0x6b,0x88,0x77,0x85,0x70,0x84,0x79,0x81,0x71, 0x81,0x7a,0x83,0x72,0x83,0x74,0x87,0x6e,0x89,0x77,0x8b,0x6e,0x8b,0x78,0x8b,0x71, 0x8c,0x76,0x8a,0x70,0x88,0x78,0x86,0x6f,0x85,0x7a,0x81,0x72,0x80,0x75,0x81,0x71, 0x84,0x78,0x85,0x71,0x87,0x76,0x8a,0x70,0x8b,0x78,0x8c,0x6e,0x8b,0x77,0x8b,0x6f, 0x89,0x7d,0x86,0x76,0x85,0x77,0x83,0x73,0x82,0x7e,0x82,0x73,0x84,0x77,0x85,0x71, 0x89,0x7a,0x8a,0x72,0x8c,0x7c,0x8c,0x70,0x8d,0x7e,0x8b,0x70,0x8a,0x7b,0x88,0x72, 0x87,0x7a,0x84,0x73,0x83,0x7c,0x83,0x74,0x85,0x80,0x87,0x76,0x89,0x80,0x8b,0x7b, 0x8b,0x83,0x88,0x7d,0x6c,0x56,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,00 }; sane-backends-1.0.29/backend/dc210.conf.in0000666000000000000000000000172713615534521014664 00000000000000# Serial port where the camera is connected ## Linux port=/dev/ttyS0 ## IRIX #port=/dev/ttyd1 ## Solaris #port=/dev/term/a ## HP-UX #port=/dev/tty0p0 ## Digital UNIX #port=/dev/tty01 # Max baud rate for download. Camera always starts at 9600 baud, then # switches to the higher rate ## This works for Linux. Also works for IRIX (6.3 or higher), providing that ## the host is an O2, OCTANE, Origin2000/200, Onyx2, Origin3000/300, Onyx3 or ## a newer SGI hardware [see serial(7)]. #baud=115200 ## This works for most UNIX's baud=38400 # Prints some extra information during the init phase. This can be # handy, but note that printing anything to stderr breaks the saned # network scanning. #dumpinquiry # How many usec (1,000,000ths of a) between writing the command and reading the # result. 125000 seems to be the lowest I could go reliably. cmdrespause=125000 # How many usec (1,000,000ths of a) between sending the "back to default" break # sending commands. breakpause=1000000; sane-backends-1.0.29/backend/ricoh2_buffer.c0000666000000000000000000001424713615534521015463 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2018 Stanislav Yuzvinsky Based on the work done by viruxx 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "../include/sane/config.h" #include #include #if defined(__APPLE__) && defined(__MACH__) #include #else #include #endif #include "../include/sane/sanei_debug.h" typedef struct ricoh2_buffer { /* lifetime constants */ SANE_Byte *data; SANE_Int size; SANE_Int pixels_per_line; SANE_Int info_size; SANE_Bool is_rgb; /* state */ SANE_Int current_position; SANE_Int remain_in_line; } ricoh2_buffer; static ricoh2_buffer * ricoh2_buffer_create (SANE_Int size, SANE_Int pixels_per_line, SANE_Int info_size, SANE_Bool is_rgb) { ricoh2_buffer *self; assert (size > 0); assert (pixels_per_line > 0); assert (info_size >= 0); self = malloc (sizeof (ricoh2_buffer)); if (!self) return NULL; self->data = malloc (size); if (!self->data) { free (self); return NULL; } self->size = size; self->pixels_per_line = pixels_per_line; self->info_size = info_size; self->is_rgb = is_rgb; self->current_position = 0; self->remain_in_line = pixels_per_line; DBG (192, "size = %d pixels_per_line = %d info_size = %d rgb? = %d pos = %d\n", self->size, self->pixels_per_line, self->info_size, self->is_rgb, self->current_position); return self; } /* destructor */ static void ricoh2_buffer_dispose (ricoh2_buffer *self) { assert (self); free (self->data); free (self); } static SANE_Byte * ricoh2_buffer_get_internal_buffer (ricoh2_buffer *self) { assert (self); DBG (192, "engaging a buffer of size %d\n", self->size); self->current_position = 0; self->remain_in_line = self->pixels_per_line; DBG (192, "remain in line = %d\n", self->remain_in_line); return self->data; } static SANE_Int ricoh2_buffer_get_bytes_remain (ricoh2_buffer *self) { assert (self); DBG (192, "bytes remain in the buffer %d\n", self->size - self->current_position); return self->size - self->current_position; } inline static SANE_Int min (SANE_Int v1, SANE_Int v2) { return v1 < v2 ? v1 : v2; } static SANE_Int ricoh2_buffer_get_data (ricoh2_buffer *self, SANE_Byte *dest, SANE_Int dest_size) { SANE_Int actually_copied = 0; SANE_Int pixels_to_copy; SANE_Int bytes_per_pixel; SANE_Int bytes_per_color; SANE_Byte *src; SANE_Byte *end; assert (self); assert (dest); assert (self->size > self->current_position); bytes_per_pixel = self->is_rgb ? 3 : 1; bytes_per_color = self->pixels_per_line + self->info_size; DBG (192, "trying to get %d bytes from the buffer, " "while %d bytes in the line\n", dest_size, self->remain_in_line); for (pixels_to_copy = min (dest_size / bytes_per_pixel, self->remain_in_line); pixels_to_copy && self->size > self->current_position; pixels_to_copy = min (dest_size / bytes_per_pixel, self->remain_in_line)) { DBG (192, "providing %d bytes to the user (until the end of the line), " "position in buffer is %d\n", pixels_to_copy * bytes_per_pixel, self->current_position); for (src = self->data + self->current_position, end = src + pixels_to_copy; src < end; ++src) { *(dest++) = *(src); if (bytes_per_pixel == 3) { *(dest++) = *(src + bytes_per_color); *(dest++) = *(src + 2 * bytes_per_color); } } dest_size -= pixels_to_copy * bytes_per_pixel; actually_copied += pixels_to_copy * bytes_per_pixel; self->current_position += pixels_to_copy; self->remain_in_line -= pixels_to_copy; // move to the next line if (!self->remain_in_line) { self->current_position += self->info_size; if (self->is_rgb) self->current_position += 2 * bytes_per_color; self->remain_in_line = self->pixels_per_line; DBG (192, "Line feed, new position is %d\n", self->current_position); } DBG (192, "left in the buffer: %d\n", self->size - self->current_position); } /* invariant */ assert (self->size >= self->current_position); return actually_copied; } sane-backends-1.0.29/backend/umax_pp_low.h0000666000000000000000000001105613615534521015276 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001-2012 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Umax PP flatbed scanners. */ #include #include "../include/sane/config.h" /*****************************************************************************/ /* set port to 'idle state' and get iopl */ /*****************************************************************************/ extern int sanei_umax_pp_initPort (int port, const char *name); extern int sanei_umax_pp_initScanner (int recover); extern int sanei_umax_pp_initTransport (int recover); extern int sanei_umax_pp_endSession (void); extern int sanei_umax_pp_initCancel (void); extern int sanei_umax_pp_cancel (void); extern int sanei_umax_pp_checkModel (void); extern int sanei_umax_pp_getauto (void); extern int sanei_umax_pp_UTA (void); extern void sanei_umax_pp_setauto (int mode); #ifndef __GLOBALES__ #define RGB_MODE 0x10 #define RGB12_MODE 0x11 #define BW_MODE 0x08 #define BW12_MODE 0x09 #define BW2_MODE 0x04 #define __GLOBALES__ #endif /* __GLOBALES__ */ #ifndef PRECISION_ON #define PRECISION_ON 1 #define PRECISION_OFF 0 #define LAMP_STATE 0x20 #define MOTOR_BIT 0x40 #define ASIC_BIT 0x100 #define UMAX_PP_PARPORT_PS2 0x01 #define UMAX_PP_PARPORT_BYTE 0x02 #define UMAX_PP_PARPORT_EPP 0x04 #define UMAX_PP_PARPORT_ECP 0x08 #endif extern int sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color, int gain, int offset); extern int sanei_umax_pp_move (int distance, int precision, unsigned char *buffer); extern int sanei_umax_pp_setLamp (int on); extern int sanei_umax_pp_completionWait (void); extern int sanei_umax_pp_commitScan (void); extern int sanei_umax_pp_park (void); extern int sanei_umax_pp_parkWait (void); extern int sanei_umax_pp_readBlock (long len, int window, int dpi, int last, unsigned char *buffer); extern int sanei_umax_pp_startScan (int x, int y, int width, int height, int dpi, int color, int gain, int offset, int *rbpp, int *rtw, int *rth); extern void sanei_umax_pp_setport (int port); extern int sanei_umax_pp_getport (void); extern void sanei_umax_pp_setparport (int fd); extern int sanei_umax_pp_getparport (void); extern void sanei_umax_pp_setastra (int mod); extern int sanei_umax_pp_getastra (void); extern void sanei_umax_pp_setLeft (int mod); extern int sanei_umax_pp_getLeft (void); extern void sanei_umax_pp_setfull (int mod); extern int sanei_umax_pp_getfull (void); extern int sanei_umax_pp_scannerStatus (void); extern int sanei_umax_pp_probeScanner (int recover); extern char **sanei_parport_find_port (void); extern char **sanei_parport_find_device (void); extern int sanei_umax_pp_cmdSync (int cmd); extern void sanei_umax_pp_gamma (int *red, int *green, int *blue); sane-backends-1.0.29/backend/u12-map.c0000666000000000000000000001323013615534521014115 00000000000000/* @file u12_map.c * @brief functions to create and manipulate gamma lookup tables. * * Copyright (C) 2003-2004 Gerhard Jaeger * * History: * - 0.01 - initial version * - 0.02 - inverting map when scanning binary images * - changed u12map_Adjust() * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ /** * @param s - pointer to the scanner specific structure * @return The function always returns SANE_STATUS_GOOD */ static SANE_Status u12map_InitGammaSettings( U12_Device *dev ) { int i, j, val; double gamma; dev->gamma_length = 4096; dev->gamma_range.min = 0; dev->gamma_range.max = 255; dev->gamma_range.quant = 0; DBG( _DBG_INFO, "Presetting Gamma tables (len=%u)\n", dev->gamma_length ); DBG( _DBG_INFO, "----------------------------------\n" ); /* preset the gamma maps */ for( i = 0; i < 4; i++ ) { switch( i ) { case 1: gamma = dev->adj.rgamma; break; case 2: gamma = dev->adj.ggamma; break; case 3: gamma = dev->adj.bgamma; break; default: gamma = dev->adj.graygamma; break; } for( j = 0; j < dev->gamma_length; j++ ) { val = (dev->gamma_range.max * pow((double) j / ((double)dev->gamma_length - 1.0), 1.0 / gamma )); if( val > dev->gamma_range.max ) val = dev->gamma_range.max; dev->gamma_table[i][j] = val; } } return SANE_STATUS_GOOD; } /** Check the gamma vectors we got back and limit if necessary * @param s - pointer to the scanner specific structure * @return nothing */ static void u12map_CheckGammaSettings( U12_Device *dev ) { int i, j; for( i = 0; i < 4 ; i++ ) { for( j = 0; j < dev->gamma_length; j++ ) { if( dev->gamma_table[i][j] > dev->gamma_range.max ) { dev->gamma_table[i][j] = dev->gamma_range.max; } } } } /** adjust acording to brightness and contrast */ static void u12map_Adjust( U12_Device *dev, int which, SANE_Byte *buf ) { int i; u_long *pdw; double b, c, tmp; DBG( _DBG_INFO, "u12map_Adjust(%u)\n", which ); /* adjust brightness (b) and contrast (c) using the function: * * s'(x,y) = (s(x,y) + b) * c * b = [-127, 127] * c = [0,2] */ /* scale brightness and contrast... */ b = ((double)dev->DataInf.siBrightness * 192.0)/100.0; c = ((double)dev->DataInf.siContrast + 100.0)/100.0; DBG( _DBG_INFO, "* brightness = %i -> %i\n", dev->DataInf.siBrightness, (SANE_Byte)b); DBG( _DBG_INFO, "* contrast*100 = %i -> %i\n", dev->DataInf.siContrast, (int)(c*100)); for( i = 0; i < dev->gamma_length; i++ ) { if((_MAP_MASTER == which) || (_MAP_RED == which)) { tmp = ((double)(dev->gamma_table[0][i] + b)) * c; if( tmp < 0 ) tmp = 0; if( tmp > 255 ) tmp = 255; buf[i] = (SANE_Byte)tmp; } if((_MAP_MASTER == which) || (_MAP_GREEN == which)) { tmp = ((double)(dev->gamma_table[1][i] + b)) * c; if( tmp < 0 ) tmp = 0; if( tmp > 255 ) tmp = 255; buf[4096+i] = (SANE_Byte)tmp; } if((_MAP_MASTER == which) || (_MAP_BLUE == which)) { tmp = ((double)(dev->gamma_table[2][i] + b)) * c; if( tmp < 0 ) tmp = 0; if( tmp > 255 ) tmp = 255; buf[8192+i] = (SANE_Byte)tmp; } } if((dev->DataInf.dwScanFlag & _SCANDEF_Negative) || (dev->DataInf.wPhyDataType == COLOR_BW)) { DBG( _DBG_INFO, "inverting...\n" ); if((_MAP_MASTER == which) || (_MAP_RED == which)) { DBG( _DBG_INFO, "inverting RED map\n" ); pdw = (u_long*)&buf[0]; for( i = dev->gamma_length / 4; i; i--, pdw++ ) *pdw = ~(*pdw); } if((_MAP_MASTER == which) || (_MAP_GREEN == which)) { DBG( _DBG_INFO, "inverting GREEN map\n" ); pdw = (u_long*)&buf[4096]; for( i = dev->gamma_length / 4; i; i--, pdw++ ) *pdw = ~(*pdw); } if((_MAP_MASTER == which) || (_MAP_BLUE == which)) { DBG( _DBG_INFO, "inverting BLUE map\n" ); pdw = (u_long*)&buf[8192]; for( i = dev->gamma_length / 4; i; i--, pdw++ ) *pdw = ~(*pdw); } } } /* END U12-MAP.C ............................................................*/ sane-backends-1.0.29/backend/microtek2.c0000666000000000000000000105177113615534521014647 00000000000000/*************************************************************************** * SANE - Scanner Access Now Easy. microtek2.c This file (C) 1998, 1999 Bernd Schroeder modifications 2000, 2001 Karsten Festag 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. *************************************************************************** This file implements a SANE backend for Microtek scanners with SCSI-2 command set. (feedback to: bernd@aquila.muc.de) ( karsten.festag@t-online.de) ***************************************************************************/ #ifdef _AIX # include /* MUST come first for AIX! */ #endif #include "../include/sane/config.h" #include "../include/lalloca.h" #include #include #include #include #include #include #include #include #include #include #include "../include/_stdint.h" #ifdef HAVE_AUTHORIZATION #include #endif #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_thread.h" #ifndef TESTBACKEND #define BACKEND_NAME microtek2 #else #define BACKEND_NAME microtek2_test #endif /* for testing*/ /*#define NO_PHANTOMTYPE_SHADING*/ #include "../include/sane/sanei_backend.h" #include "microtek2.h" #ifdef HAVE_AUTHORIZATION static SANE_Auth_Callback auth_callback; #endif static int md_num_devices = 0; /* number of devices from config file */ static Microtek2_Device *md_first_dev = NULL; /* list of known devices */ static Microtek2_Scanner *ms_first_handle = NULL; /* list of open scanners */ /* options that can be configured in the config file */ static Config_Options md_options = { 1.0, "off", "off", "off", "off", "off", "off"}; static Config_Temp *md_config_temp = NULL; static int md_dump = 0; /* from config file: */ /* 1: inquiry + scanner attributes */ /* 2: + all scsi commands and data */ /* 3: + all scan data */ static int md_dump_clear = 1; /*---------- sane_cancel() ---------------------------------------------------*/ void sane_cancel (SANE_Handle handle) { Microtek2_Scanner *ms = handle; DBG(30, "sane_cancel: handle=%p\n", handle); if ( ms->scanning == SANE_TRUE ) cleanup_scanner(ms); ms->cancelled = SANE_TRUE; ms->fd[0] = ms->fd[1] = -1; } /*---------- sane_close() ----------------------------------------------------*/ void sane_close (SANE_Handle handle) { Microtek2_Scanner *ms = handle; DBG(30, "sane_close: ms=%p\n", (void *) ms); if ( ! ms ) return; /* free malloc'ed stuff */ cleanup_scanner(ms); /* remove Scanner from linked list */ if ( ms_first_handle == ms ) ms_first_handle = ms->next; else { Microtek2_Scanner *ts = ms_first_handle; while ( (ts != NULL) && (ts->next != ms) ) ts = ts->next; ts->next = ts->next->next; /* == ms->next */ } DBG(100, "free ms at %p\n", (void *) ms); free((void *) ms); ms = NULL; } /*---------- sane_exit() -----------------------------------------------------*/ void sane_exit (void) { Microtek2_Device *next; int i; DBG(30, "sane_exit:\n"); /* close all leftover Scanners */ while (ms_first_handle != NULL) sane_close(ms_first_handle); /* free up device list */ while (md_first_dev != NULL) { next = md_first_dev->next; for ( i = 0; i < 4; i++ ) { if ( md_first_dev->custom_gamma_table[i] ) { DBG(100, "free md_first_dev->custom_gamma_table[%d] at %p\n", i, (void *) md_first_dev->custom_gamma_table[i]); free((void *) md_first_dev->custom_gamma_table[i]); md_first_dev->custom_gamma_table[i] = NULL; } } if ( md_first_dev->shading_table_w ) { DBG(100, "free md_first_dev->shading_table_w at %p\n", md_first_dev->shading_table_w); free((void *) md_first_dev->shading_table_w); md_first_dev->shading_table_w = NULL; } if ( md_first_dev->shading_table_d ) { DBG(100, "free md_first_dev->shading_table_d at %p\n", md_first_dev->shading_table_d); free((void *) md_first_dev->shading_table_d); md_first_dev->shading_table_d = NULL; } DBG(100, "free md_first_dev at %p\n", (void *) md_first_dev); free((void *) md_first_dev); md_first_dev = next; } sane_get_devices(NULL, SANE_FALSE); /* free list of SANE_Devices */ DBG(30, "sane_exit: MICROTEK2 says goodbye.\n"); } /*---------- sane_get_devices()-----------------------------------------------*/ SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only) { /* return a list of available devices; available here means that we get */ /* a positive response to an 'INQUIRY' and possibly to a */ /* 'READ SCANNER ATTRIBUTE' call */ static const SANE_Device **sd_list = NULL; Microtek2_Device *md; SANE_Status status; int index; DBG(30, "sane_get_devices: local_only=%d\n", local_only); /* this is hack to get the list freed with a call from sane_exit() */ if ( device_list == NULL ) { if ( sd_list ) { DBG(100, "free sd_list at %p\n", (void *) sd_list); free(sd_list); sd_list=NULL; } DBG(30, "sane_get_devices: sd_list_freed\n"); return SANE_STATUS_GOOD; } /* first free old list, if there is one; frontend wants a new list */ if ( sd_list ) { DBG(100, "free sd_list at %p\n", (void *) sd_list); free(sd_list); /* free array of pointers */ } sd_list = (const SANE_Device **) malloc( (md_num_devices + 1) * sizeof(SANE_Device **)); DBG(100, "sane_get_devices: sd_list=%p, malloc'd %lu bytes\n", (void *) sd_list, (u_long) ((md_num_devices + 1) * sizeof(SANE_Device **))); if ( ! sd_list ) { DBG(1, "sane_get_devices: malloc() for sd_list failed\n"); return SANE_STATUS_NO_MEM; } *device_list = sd_list; index = 0; md = md_first_dev; while ( md ) { status = attach(md); if ( status != SANE_STATUS_GOOD ) { DBG(10, "sane_get_devices: attach status '%s'\n", sane_strstatus(status)); md = md->next; continue; } /* check whether unit is ready, if so add it to the list */ status = scsi_test_unit_ready(md); if ( status != SANE_STATUS_GOOD ) { DBG(10, "sane_get_devices: test_unit_ready status '%s'\n", sane_strstatus(status)); md = md->next; continue; } sd_list[index] = &md->sane; ++index; md = md->next; } sd_list[index] = NULL; return SANE_STATUS_GOOD; } /*---------- sane_get_parameters() -------------------------------------------*/ SANE_Status sane_get_parameters(SANE_Handle handle, SANE_Parameters *params) { Microtek2_Scanner *ms = handle; Microtek2_Device *md; Option_Value *val; Microtek2_Info *mi; int mode; int depth; int bits_pp_in; /* bits per pixel from scanner */ int bits_pp_out; /* bits_per_pixel transferred to frontend */ int bytes_per_line; double x_pixel_per_mm; double y_pixel_per_mm; double x1_pixel; double y1_pixel; double width_pixel; double height_pixel; DBG(40, "sane_get_parameters: handle=%p, params=%p\n", handle, (void *) params); md = ms->dev; mi = &md->info[md->scan_source]; val= ms->val; if ( ! ms->scanning ) /* get an estimate for the params */ { get_scan_mode_and_depth(ms, &mode, &depth, &bits_pp_in, &bits_pp_out); switch ( mode ) { case MS_MODE_COLOR: if ( mi->onepass ) { ms->params.format = SANE_FRAME_RGB; ms->params.last_frame = SANE_TRUE; } else { ms->params.format = SANE_FRAME_RED; ms->params.last_frame = SANE_FALSE; } break; case MS_MODE_GRAY: case MS_MODE_HALFTONE: case MS_MODE_LINEART: case MS_MODE_LINEARTFAKE: ms->params.format = SANE_FRAME_GRAY; ms->params.last_frame = SANE_TRUE; break; default: DBG(1, "sane_get_parameters: Unknown scan mode %d\n", mode); break; } ms->params.depth = (SANE_Int) bits_pp_out; /* calculate lines, pixels per line and bytes per line */ if ( val[OPT_RESOLUTION_BIND].w == SANE_TRUE ) { x_pixel_per_mm = y_pixel_per_mm = SANE_UNFIX(val[OPT_RESOLUTION].w) / MM_PER_INCH; DBG(30, "sane_get_parameters: x_res=y_res=%f\n", SANE_UNFIX(val[OPT_RESOLUTION].w)); } else { x_pixel_per_mm = SANE_UNFIX(val[OPT_RESOLUTION].w) / MM_PER_INCH; y_pixel_per_mm = SANE_UNFIX(val[OPT_Y_RESOLUTION].w) / MM_PER_INCH; DBG(30, "sane_get_parameters: x_res=%f, y_res=%f\n", SANE_UNFIX(val[OPT_RESOLUTION].w), SANE_UNFIX(val[OPT_Y_RESOLUTION].w)); } DBG(30, "sane_get_parameters: x_ppm=%f, y_ppm=%f\n", x_pixel_per_mm, y_pixel_per_mm); y1_pixel = SANE_UNFIX(ms->val[OPT_TL_Y].w) * y_pixel_per_mm; height_pixel = fabs(SANE_UNFIX(ms->val[OPT_BR_Y].w) * y_pixel_per_mm - y1_pixel) + 0.5; ms->params.lines = (SANE_Int) height_pixel; x1_pixel = SANE_UNFIX(ms->val[OPT_TL_X].w) * x_pixel_per_mm; width_pixel = fabs(SANE_UNFIX(ms->val[OPT_BR_X].w) * x_pixel_per_mm - x1_pixel) + 0.5; ms->params.pixels_per_line = (SANE_Int) width_pixel; if ( bits_pp_out == 1 ) bytes_per_line = (width_pixel + 7 ) / 8; else { bytes_per_line = ( width_pixel * bits_pp_out ) / 8 ; if ( mode == MS_MODE_COLOR && mi->onepass ) bytes_per_line *= 3; } ms->params.bytes_per_line = (SANE_Int) bytes_per_line; } /* if ms->scanning */ if ( params ) *params = ms->params; DBG(30,"sane_get_parameters: format=%d, last_frame=%d, lines=%d\n", ms->params.format,ms->params.last_frame, ms->params.lines); DBG(30,"sane_get_parameters: depth=%d, ppl=%d, bpl=%d\n", ms->params.depth,ms->params.pixels_per_line, ms->params.bytes_per_line); return SANE_STATUS_GOOD; } /*---------- sane_get_select_fd() --------------------------------------------*/ SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int *fd) { Microtek2_Scanner *ms = handle; DBG(30, "sane_get_select_fd: ms=%p\n", (void *) ms); if ( ! ms->scanning ) { DBG(1, "sane_get_select_fd: Scanner not scanning\n"); return SANE_STATUS_INVAL; } *fd = (SANE_Int) ms->fd[0]; return SANE_STATUS_GOOD; } /*---------- 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; DBG_INIT(); DBG(1, "sane_init: Microtek2 (v%d.%d build %s) says hello...\n", MICROTEK2_MAJOR, MICROTEK2_MINOR, MICROTEK2_BUILD); if ( version_code ) *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, 0); #ifdef HAVE_AUTHORIZATION auth_callback = authorize; #endif sanei_thread_init(); fp = sanei_config_open(MICROTEK2_CONFIG_FILE); if ( fp == NULL ) DBG(10, "sane_init: file not opened: '%s'\n", MICROTEK2_CONFIG_FILE); else { /* check config file for devices and associated options */ parse_config_file(fp, &md_config_temp); while ( md_config_temp ) { sanei_config_attach_matching_devices(md_config_temp->device, attach_one); if ( md_config_temp->next ) /* go to next device, if existent */ md_config_temp = md_config_temp->next; else break; } fclose(fp); } if ( md_first_dev == NULL ) { /* config file not found or no valid entry; default to /dev/scanner */ /* instead of insisting on config file */ add_device_list("/dev/scanner", &md); if ( md ) attach(md); } return SANE_STATUS_GOOD; } /*---------- sane_open() -----------------------------------------------------*/ SANE_Status sane_open(SANE_String_Const name, SANE_Handle *handle) { SANE_Status status; Microtek2_Scanner *ms; Microtek2_Device *md; #ifdef HAVE_AUTHORIZATION struct stat st; int rc; #endif DBG(30, "sane_open: device='%s'\n", name); *handle = NULL; md = md_first_dev; if ( name ) { /* add_device_list() returns a pointer to the device struct if */ /* the device is known or newly added, else it returns NULL */ status = add_device_list(name, &md); if ( status != SANE_STATUS_GOOD ) return status; } if ( ! md ) { DBG(10, "sane_open: invalid device name '%s'\n", name); return SANE_STATUS_INVAL; } /* attach calls INQUIRY and READ SCANNER ATTRIBUTES */ status = attach(md); if ( status != SANE_STATUS_GOOD ) return status; ms = malloc(sizeof(Microtek2_Scanner)); DBG(100, "sane_open: ms=%p, malloc'd %lu bytes\n", (void *) ms, (u_long) sizeof(Microtek2_Scanner)); if ( ms == NULL ) { DBG(1, "sane_open: malloc() for ms failed\n"); return SANE_STATUS_NO_MEM; } memset(ms, 0, sizeof(Microtek2_Scanner)); ms->dev = md; ms->scanning = SANE_FALSE; ms->cancelled = SANE_FALSE; ms->current_pass = 0; ms->sfd = -1; sanei_thread_initialize(ms->pid); ms->fp = NULL; ms->gamma_table = NULL; ms->buf.src_buf = ms->buf.src_buffer[0] = ms->buf.src_buffer[1] = NULL; ms->control_bytes = NULL; ms->shading_image = NULL; ms->condensed_shading_w = NULL; ms->condensed_shading_d = NULL; ms->current_color = MS_COLOR_ALL; ms->current_read_color = MS_COLOR_RED; init_options(ms, MD_SOURCE_FLATBED); /* insert scanner into linked list */ ms->next = ms_first_handle; ms_first_handle = ms; *handle = ms; #ifdef HAVE_AUTHORIZATION /* check whether the file with the passwords exists. If it doesnt */ /* exist, we dont use any authorization */ rc = stat(PASSWD_FILE, &st); if ( rc == -1 && errno == ENOENT ) return SANE_STATUS_GOOD; else { status = do_authorization(md->name); return status; } #else return SANE_STATUS_GOOD; #endif } /*---------- sane_read() -----------------------------------------------------*/ SANE_Status sane_read(SANE_Handle handle, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *len ) { Microtek2_Scanner *ms = handle; SANE_Status status; ssize_t nread; DBG(30, "sane_read: handle=%p, buf=%p, maxlen=%d\n", handle, buf, maxlen); *len = 0; if ( ! ms->scanning || ms->cancelled ) { if ( ms->cancelled ) { status = SANE_STATUS_CANCELLED; } else { DBG(15, "sane_read: Scanner %p not scanning\n", (void *) ms); status = SANE_STATUS_IO_ERROR; } DBG(15, "sane_read: scan cancelled or scanner not scanning->cleanup\n"); cleanup_scanner(ms); return status; } nread = read(ms->fd[0], (void *) buf, (int) maxlen); if ( nread == -1 ) { if ( errno == EAGAIN ) { DBG(30, "sane_read: currently no data available\n"); return SANE_STATUS_GOOD; } else { DBG(1, "sane_read: read() failed, errno=%d\n", errno); cleanup_scanner(ms); return SANE_STATUS_IO_ERROR; } } if ( nread == 0 ) { DBG(15, "sane_read: read 0 bytes -> EOF\n"); ms->scanning = SANE_FALSE; cleanup_scanner(ms); return SANE_STATUS_EOF; } *len = (SANE_Int) nread; DBG(30, "sane_read: *len=%d\n", *len); return SANE_STATUS_GOOD; } /*---------- sane_set_io_mode() ---------------------------------------------*/ SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Microtek2_Scanner *ms = handle; int rc; DBG(30, "sane_set_io_mode: handle=%p, nonblocking=%d\n", handle, non_blocking); if ( ! ms->scanning ) { DBG(1, "sane_set_io_mode: Scanner not scanning\n"); return SANE_STATUS_INVAL; } rc = fcntl(ms->fd[0], F_SETFL, non_blocking ? O_NONBLOCK : 0); if ( rc == -1 ) { DBG(1, "sane_set_io_mode: fcntl() failed\n"); return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /*---------- add_device_list() -----------------------------------------------*/ static SANE_Status add_device_list(SANE_String_Const dev_name, Microtek2_Device **mdev) { Microtek2_Device *md; SANE_String hdev; size_t len; if ( (hdev = strdup(dev_name)) == NULL) { DBG(5, "add_device_list: malloc() for hdev failed\n"); return SANE_STATUS_NO_MEM; } len = strlen(hdev); if ( hdev[len - 1] == '\n' ) hdev[--len] = '\0'; DBG(30, "add_device_list: device='%s'\n", hdev); /* check, if device is already known */ md = md_first_dev; while ( md ) { if ( strcmp(hdev, md->name) == 0 ) { DBG(30, "add_device_list: device '%s' already in list\n", hdev); *mdev = md; return SANE_STATUS_GOOD; } md = md->next; } md = (Microtek2_Device *) malloc(sizeof(Microtek2_Device)); DBG(100, "add_device_list: md=%p, malloc'd %lu bytes\n", (void *) md, (u_long) sizeof(Microtek2_Device)); if ( md == NULL ) { DBG(1, "add_device_list: malloc() for md failed\n"); return SANE_STATUS_NO_MEM; } /* initialize Device and add it at the beginning of the list */ memset(md, 0, sizeof(Microtek2_Device)); md->next = md_first_dev; md_first_dev = md; md->sane.name = NULL; md->sane.vendor = NULL; md->sane.model = NULL; md->sane.type = NULL; md->scan_source = MD_SOURCE_FLATBED; md->shading_table_w = NULL; md->shading_table_d = NULL; strncpy(md->name, hdev, PATH_MAX - 1); if ( md_config_temp ) md->opts = md_config_temp->opts; else md->opts = md_options; ++md_num_devices; *mdev = md; DBG(100, "free hdev at %p\n", hdev); free(hdev); return SANE_STATUS_GOOD; } /*---------- attach() --------------------------------------------------------*/ static SANE_Status attach(Microtek2_Device *md) { /* This function is called from sane_init() to do the inquiry and to read */ /* the scanner attributes. If one of these calls fails, or if a new */ /* device is passed in sane_open() this function may also be called */ /* from sane_open() or sane_get_devices(). */ SANE_String model_string; SANE_Status status; SANE_Byte source_info; DBG(30, "attach: device='%s'\n", md->name); status = scsi_inquiry( &md->info[MD_SOURCE_FLATBED], md->name ); if ( status != SANE_STATUS_GOOD ) { DBG(1, "attach: '%s'\n", sane_strstatus(status)); return status; } /* We copy the inquiry info into the info structures for each scansource */ /* like ADF, TMA, STRIPE and SLIDE */ for ( source_info = 1; source_info < 5; ++source_info ) memcpy( &md->info[source_info], &md->info[MD_SOURCE_FLATBED], sizeof( Microtek2_Info ) ); /* Here we should insert a function, that stores all the relevant */ /* information in the info structure in a more conveniant format */ /* in the device structure, e.g. the model name with a trailing '\0'. */ status = check_inquiry(md, &model_string); if ( status != SANE_STATUS_GOOD ) return status; md->sane.name = md->name; md->sane.vendor = "Microtek"; md->sane.model = strdup(model_string); if ( md->sane.model == NULL ) DBG(1, "attach: strdup for model string failed\n"); md->sane.type = "flatbed scanner"; md->revision = strtod(md->info[MD_SOURCE_FLATBED].revision, NULL); status = scsi_read_attributes(&md->info[0], md->name, MD_SOURCE_FLATBED); if ( status != SANE_STATUS_GOOD ) { DBG(1, "attach: '%s'\n", sane_strstatus(status)); return status; } if ( MI_LUTCAP_NONE( md->info[MD_SOURCE_FLATBED].lut_cap) ) /* no gamma tables */ md->model_flags |= MD_NO_GAMMA; /* check whether the device supports transparency media adapters */ if ( md->info[MD_SOURCE_FLATBED].option_device & MI_OPTDEV_TMA ) { status = scsi_read_attributes(&md->info[0], md->name, MD_SOURCE_TMA); if ( status != SANE_STATUS_GOOD ) return status; } /* check whether the device supports an ADF */ if ( md->info[MD_SOURCE_FLATBED].option_device & MI_OPTDEV_ADF ) { status = scsi_read_attributes(&md->info[0], md->name, MD_SOURCE_ADF); if ( status != SANE_STATUS_GOOD ) return status; } /* check whether the device supports STRIPES */ if ( md->info[MD_SOURCE_FLATBED].option_device & MI_OPTDEV_STRIPE ) { status = scsi_read_attributes(&md->info[0], md->name, MD_SOURCE_STRIPE); if ( status != SANE_STATUS_GOOD ) return status; } /* check whether the device supports SLIDES */ if ( md->info[MD_SOURCE_FLATBED].option_device & MI_OPTDEV_SLIDE ) { /* The Phantom 636cx indicates in its attributes that it supports */ /* slides, but it doesn't. Thus this command would fail. */ if ( ! (md->model_flags & MD_NO_SLIDE_MODE) ) { status = scsi_read_attributes(&md->info[0], md->name, MD_SOURCE_SLIDE); if ( status != SANE_STATUS_GOOD ) return status; } } status = scsi_read_system_status(md, -1); if ( status != SANE_STATUS_GOOD ) return status; return SANE_STATUS_GOOD; } /*---------- attach_one() ----------------------------------------------------*/ static SANE_Status attach_one (const char *name) { Microtek2_Device *md; Microtek2_Device *md_tmp; DBG(30, "attach_one: name='%s'\n", name); md_tmp = md_first_dev; /* if add_device_list() adds an entry it does this at the beginning */ /* of the list and thus changes md_first_dev */ add_device_list(name, &md); if ( md_tmp != md_first_dev ) attach(md); return SANE_STATUS_GOOD; } /*---------- cancel_scan() ---------------------------------------------------*/ static SANE_Status cancel_scan(Microtek2_Scanner *ms) { SANE_Status status; DBG(30, "cancel_scan: ms=%p\n", (void *) ms); /* READ IMAGE with a transferlength of 0 aborts a scan */ ms->transfer_length = 0; status = scsi_read_image(ms, (uint8_t *) NULL, 1); if ( status != SANE_STATUS_GOOD ) { DBG(1, "cancel_scan: cancel failed: '%s'\n", sane_strstatus(status)); status = SANE_STATUS_IO_ERROR; } else status = SANE_STATUS_CANCELLED; close(ms->fd[1]); /* if we are aborting a scan because, for example, we run out 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 (sanei_thread_is_valid (ms->pid)) { sanei_thread_kill(ms->pid); sanei_thread_waitpid(ms->pid, NULL); } return status; } /*---------- check_option() --------------------------------------------------*/ static void check_option(const char *cp, Config_Options *co) { /* This function analyses options in the config file */ char *endptr; /* When this function is called, it is already made sure that this */ /* is an option line, i.e. a line that starts with option */ cp = sanei_config_skip_whitespace(cp); /* skip blanks */ cp = sanei_config_skip_whitespace(cp + 6); /* skip "option" */ if ( strncmp(cp, "dump", 4) == 0 && isspace(cp[4]) ) { cp = sanei_config_skip_whitespace(cp + 4); if ( *cp ) { md_dump = (int) strtol(cp, &endptr, 10); if ( md_dump > 4 || md_dump < 0 ) { md_dump = 1; DBG(30, "check_option: setting dump to %d\n", md_dump); } cp = sanei_config_skip_whitespace(endptr); if ( *cp ) { /* something behind the option value or value wrong */ md_dump = 1; DBG(30, "check_option: option value wrong\n"); } } else { DBG(30, "check_option: missing option value\n"); /* reasonable fallback */ md_dump = 1; } } else if ( strncmp(cp, "strip-height", 12) == 0 && isspace(cp[12]) ) { cp = sanei_config_skip_whitespace(cp + 12); if ( *cp ) { co->strip_height = strtod(cp, &endptr); DBG(30, "check_option: setting strip_height to %f\n", co->strip_height); if ( co->strip_height <= 0.0 ) co->strip_height = 14.0; cp = sanei_config_skip_whitespace(endptr); if ( *cp ) { /* something behind the option value or value wrong */ co->strip_height = 14.0; DBG(30, "check_option: option value wrong: %f\n", co->strip_height); } } } else if ( strncmp(cp, "no-backtrack-option", 19) == 0 && isspace(cp[19]) ) { cp = sanei_config_skip_whitespace(cp + 19); if ( strncmp(cp, "on", 2) == 0 ) { cp = sanei_config_skip_whitespace(cp + 2); co->no_backtracking = "on"; } else if ( strncmp(cp, "off", 3) == 0 ) { cp = sanei_config_skip_whitespace(cp + 3); co->no_backtracking = "off"; } else co->no_backtracking = "off"; if ( *cp ) { /* something behind the option value or value wrong */ co->no_backtracking = "off"; DBG(30, "check_option: option value wrong: %s\n", cp); } } else if ( strncmp(cp, "lightlid-35", 11) == 0 && isspace(cp[11]) ) { cp = sanei_config_skip_whitespace(cp + 11); if ( strncmp(cp, "on", 2) == 0 ) { cp = sanei_config_skip_whitespace(cp + 2); co->lightlid35 = "on"; } else if ( strncmp(cp, "off", 3) == 0 ) { cp = sanei_config_skip_whitespace(cp + 3); co->lightlid35 = "off"; } else co->lightlid35 = "off"; if ( *cp ) { /* something behind the option value or value wrong */ co->lightlid35 = "off"; DBG(30, "check_option: option value wrong: %s\n", cp); } } else if ( strncmp(cp, "toggle-lamp", 11) == 0 && isspace(cp[11]) ) { cp = sanei_config_skip_whitespace(cp + 11); if ( strncmp(cp, "on", 2) == 0 ) { cp = sanei_config_skip_whitespace(cp + 2); co->toggle_lamp = "on"; } else if ( strncmp(cp, "off", 3) == 0 ) { cp = sanei_config_skip_whitespace(cp + 3); co->toggle_lamp = "off"; } else co->toggle_lamp = "off"; if ( *cp ) { /* something behind the option value or value wrong */ co->toggle_lamp = "off"; DBG(30, "check_option: option value wrong: %s\n", cp); } } else if ( strncmp(cp, "lineart-autoadjust", 18) == 0 && isspace(cp[18]) ) { cp = sanei_config_skip_whitespace(cp + 18); if ( strncmp(cp, "on", 2) == 0 ) { cp = sanei_config_skip_whitespace(cp + 2); co->auto_adjust = "on"; } else if ( strncmp(cp, "off", 3) == 0 ) { cp = sanei_config_skip_whitespace(cp + 3); co->auto_adjust = "off"; } else co->auto_adjust = "off"; if ( *cp ) { /* something behind the option value or value wrong */ co->auto_adjust = "off"; DBG(30, "check_option: option value wrong: %s\n", cp); } } else if ( strncmp(cp, "backend-calibration", 19) == 0 && isspace(cp[19]) ) { cp = sanei_config_skip_whitespace(cp + 19); if ( strncmp(cp, "on", 2) == 0 ) { cp = sanei_config_skip_whitespace(cp + 2); co->backend_calibration = "on"; } else if ( strncmp(cp, "off", 3) == 0 ) { cp = sanei_config_skip_whitespace(cp + 3); co->backend_calibration = "off"; } else co->backend_calibration = "off"; if ( *cp ) { /* something behind the option value or value wrong */ co->backend_calibration = "off"; DBG(30, "check_option: option value wrong: %s\n", cp); } } else if ( strncmp(cp, "colorbalance-adjust", 19) == 0 && isspace(cp[19]) ) { cp = sanei_config_skip_whitespace(cp + 19); if ( strncmp(cp, "on", 2) == 0 ) { cp = sanei_config_skip_whitespace(cp + 2); co->colorbalance_adjust = "on"; } else if ( strncmp(cp, "off", 3) == 0 ) { cp = sanei_config_skip_whitespace(cp + 3); co->colorbalance_adjust = "off"; } else co->colorbalance_adjust = "off"; if ( *cp ) { /* something behind the option value or value wrong */ co->colorbalance_adjust = "off"; DBG(30, "check_option: option value wrong: %s\n", cp); } } else DBG(30, "check_option: invalid option in '%s'\n", cp); } /*---------- check_inquiry() -------------------------------------------------*/ static SANE_Status check_inquiry(Microtek2_Device *md, SANE_String *model_string) { Microtek2_Info *mi; DBG(30, "check_inquiry: md=%p\n", (void *) md); md->n_control_bytes = 0; md->shading_length = 0; md->shading_table_contents = 0; mi = &md->info[MD_SOURCE_FLATBED]; if ( mi->scsi_version != MI_SCSI_II_VERSION ) { DBG(1, "check_inquiry: Device is not a SCSI-II device, but 0x%02x\n", mi->scsi_version); return SANE_STATUS_IO_ERROR; } if ( mi->device_type != MI_DEVTYPE_SCANNER ) { DBG(1, "check_inquiry: Device is not a scanner, but 0x%02x\n", mi->device_type); return SANE_STATUS_IO_ERROR; } if ( strncasecmp("MICROTEK", mi->vendor, INQ_VENDOR_L) != 0 && strncmp(" ", mi->vendor, INQ_VENDOR_L) != 0 && strncmp("AGFA ", mi->vendor, INQ_VENDOR_L) != 0 ) { DBG(1, "check_inquiry: Device is not a Microtek, but '%.*s'\n", INQ_VENDOR_L, mi->vendor); return SANE_STATUS_IO_ERROR; } if ( mi->depth & MI_HASDEPTH_16 ) md->shading_depth = 16; else if ( mi->depth & MI_HASDEPTH_14 ) md->shading_depth = 14; else if ( mi->depth & MI_HASDEPTH_12 ) md->shading_depth = 12; else if ( mi->depth & MI_HASDEPTH_10 ) md->shading_depth = 10; else md->shading_depth = 8; switch (mi->model_code) { case 0x81: case 0xab: *model_string = "ScanMaker 4"; break; case 0x85: *model_string = "ScanMaker V300 / ColorPage-EP"; /* The ScanMaker V300 (FW < 2.70) returns some values for the */ /* "read image info" command in only two bytes */ /* and doesn't understand read_image_status */ md->model_flags |= MD_NO_RIS_COMMAND; if ( md->revision < 2.70 ) md->model_flags |= MD_RII_TWO_BYTES; break; case 0x87: *model_string = "ScanMaker 5"; md->model_flags |= MD_NO_GAMMA; break; case 0x89: *model_string = "ScanMaker 6400XL"; break; case 0x8a: *model_string = "ScanMaker 9600XL"; break; case 0x8c: *model_string = "ScanMaker 630 / ScanMaker V600"; break; case 0x8d: *model_string = "ScanMaker 336 / ScanMaker V310"; break; case 0x90: case 0x92: *model_string = "E3+ / Vobis HighScan"; break; case 0x91: *model_string = "ScanMaker X6 / Phantom 636"; /* The X6 indicates a data format of segregated data in TMA mode */ /* but actually transfers as chunky data */ md->model_flags |= MD_DATA_FORMAT_WRONG; if ( md->revision == 1.00 ) md->model_flags |= MD_OFFSET_2; break; case 0x93: *model_string = "ScanMaker 336 / ScanMaker V310"; break; case 0x70: case 0x71: case 0x94: case 0xa0: *model_string = "Phantom 330cx / Phantom 336cx / SlimScan C3"; /* These models do not accept gamma tables. Apparently they */ /* read the control bits and do not accept shading tables */ /* They also don't support enhancements (contrast, brightness...)*/ md->model_flags |= MD_NO_SLIDE_MODE | MD_NO_GAMMA #ifndef NO_PHANTOMTYPE_SHADING | MD_PHANTOM336CX_TYPE_SHADING #endif | MD_READ_CONTROL_BIT | MD_NO_ENHANCEMENTS; md->opt_backend_calib_default = SANE_TRUE; md->opt_no_backtrack_default = SANE_TRUE; md->n_control_bytes = 320; md->shading_length = 18; md->shading_depth = 10; md->controlbit_offset = 7; break; case 0x95: *model_string = "ArtixScan 1010"; break; case 0x97: *model_string = "ScanMaker 636"; break; case 0x98: *model_string = "ScanMaker X6EL"; if ( md->revision == 1.00 ) md->model_flags |= MD_OFFSET_2; break; case 0x99: *model_string = "ScanMaker X6USB"; if ( md->revision == 1.00 ) md->model_flags |= MD_OFFSET_2; md->model_flags |= MD_X6_SHORT_TRANSFER; break; case 0x9a: *model_string = "Phantom 636cx / C6"; /* The Phantom 636cx says it supports the SLIDE mode, but it */ /* doesn't. Thus inquring the attributes for slide mode would */ /* fail. Also it does not accept gamma tables. Apparently */ /* it reads the control bits and does not accept shading tables */ md->model_flags |= MD_NO_SLIDE_MODE | MD_READ_CONTROL_BIT | MD_NO_GAMMA | MD_PHANTOM_C6; md->opt_backend_calib_default = SANE_TRUE; md->opt_no_backtrack_default = SANE_TRUE; md->n_control_bytes = 647; /* md->shading_length = 18; firmware values seem to work better */ md->shading_depth = 12; md->controlbit_offset = 18; break; case 0x9d: *model_string = "AGFA Duoscan T1200"; break; case 0xa3: *model_string = "ScanMaker V6USL"; /* The V6USL does not accept gamma tables */ md->model_flags |= MD_NO_GAMMA; break; case 0xa5: *model_string = "ArtixScan 4000t"; break; case 0xac: *model_string = "ScanMaker V6UL"; /* The V6USL does not accept gamma tables, perhaps the V6UL also */ md->model_flags |= MD_NO_GAMMA; break; case 0xaf: *model_string = "SlimScan C3"; md->model_flags |= MD_NO_SLIDE_MODE | MD_NO_GAMMA | MD_READ_CONTROL_BIT | MD_NO_ENHANCEMENTS; md->opt_backend_calib_default = SANE_TRUE; md->opt_no_backtrack_default = SANE_TRUE; md->n_control_bytes = 320; md->controlbit_offset = 7; break; case 0xb0: *model_string = "ScanMaker X12USL"; md->opt_backend_calib_default = SANE_TRUE; md->model_flags |= MD_16BIT_TRANSFER | MD_CALIB_DIVISOR_600; break; case 0xb3: *model_string = "ScanMaker 3600"; break; case 0xb4: *model_string = "ScanMaker 4700"; break; case 0xb6: *model_string = "ScanMaker V6UPL"; /* is like V6USL but with USB and Parport interface ?? */ md->model_flags |= MD_NO_GAMMA; break; case 0xb8: *model_string = "ScanMaker 3700"; break; case 0xde: *model_string = "ScanMaker 9800XL"; md->model_flags |= MD_NO_GAMMA | MD_16BIT_TRANSFER; md->opt_backend_calib_default = SANE_TRUE; md->opt_no_backtrack_default = SANE_TRUE; break; default: DBG(1, "check_inquiry: Model 0x%02x not supported\n", mi->model_code); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /*---------- cleanup_scanner() -----------------------------------------------*/ static void cleanup_scanner(Microtek2_Scanner *ms) { DBG(30, "cleanup_scanner: ms=%p, ms->sfd=%d\n", (void *) ms, ms->sfd); if ( ms->scanning == SANE_TRUE ) cancel_scan(ms); if ( ms->sfd != -1 ) sanei_scsi_close(ms->sfd); ms->sfd = -1; sanei_thread_invalidate(ms->pid); ms->fp = NULL; ms->current_pass = 0; ms->scanning = SANE_FALSE; ms->cancelled = SANE_FALSE; /* free buffers */ if ( ms->buf.src_buffer[0] ) { DBG(100, "free ms->buf.src_buffer[0] at %p\n", ms->buf.src_buffer[0]); free((void *) ms->buf.src_buffer[0]); ms->buf.src_buffer[0] = NULL; ms->buf.src_buf = NULL; } if ( ms->buf.src_buffer[1] ) { DBG(100, "free ms->buf.src_buffer[1] at %p\n", ms->buf.src_buffer[1]); free((void *) ms->buf.src_buffer[1]); ms->buf.src_buffer[1] = NULL; ms->buf.src_buf = NULL; } if ( ms->buf.src_buf ) { DBG(100, "free ms->buf.src_buf at %p\n", ms->buf.src_buf); free((void *) ms->buf.src_buf); ms->buf.src_buf = NULL; } if ( ms->temporary_buffer ) { DBG(100, "free ms->temporary_buffer at %p\n", ms->temporary_buffer); free((void *) ms->temporary_buffer); ms->temporary_buffer = NULL; } if ( ms->gamma_table ) { DBG(100, "free ms->gamma_table at %p\n", ms->gamma_table); free((void *) ms->gamma_table); ms->gamma_table = NULL; } if ( ms->control_bytes ) { DBG(100, "free ms->control_bytes at %p\n", ms->control_bytes); free((void *) ms->control_bytes); ms->control_bytes = NULL; } if ( ms->condensed_shading_w ) { DBG(100, "free ms->condensed_shading_w at %p\n", ms->condensed_shading_w); free((void *) ms->condensed_shading_w); ms->condensed_shading_w = NULL; } if ( ms->condensed_shading_d ) { DBG(100, "free ms->condensed_shading_d at %p\n", ms->condensed_shading_d); free((void *) ms->condensed_shading_d); ms->condensed_shading_d = NULL; } return; } #ifdef HAVE_AUTHORIZATION /*---------- do_authorization() ----------------------------------------------*/ static SANE_Status do_authorization(char *ressource) { /* This function implements a simple authorization function. It looks */ /* up an entry in the file SANE_PATH_CONFIG_DIR/auth. Such an entry */ /* must be of the form device:user:password where password is a crypt() */ /* encrypted password. If several users are allowed to access a device */ /* an entry must be created for each user. If no entry exists for device */ /* or the file does not exist no authentication is neccessary. If the */ /* file exists, but cant be opened the authentication fails */ SANE_Status status; FILE *fp; int device_found; char username[SANE_MAX_USERNAME_LEN]; char password[SANE_MAX_PASSWORD_LEN]; char line[MAX_LINE_LEN]; char *linep; char *device; char *user; char *passwd; char *p; DBG(30, "do_authorization: ressource=%s\n", ressource); if ( auth_callback == NULL ) /* frontend does not require authorization */ return SANE_STATUS_GOOD; /* first check if an entry exists in for this device. If not, we dont */ /* use authorization */ fp = fopen(PASSWD_FILE, "r"); if ( fp == NULL ) { if ( errno == ENOENT ) { DBG(1, "do_authorization: file not found: %s\n", PASSWD_FILE); return SANE_STATUS_GOOD; } else { DBG(1, "do_authorization: fopen() failed, errno=%d\n", errno); return SANE_STATUS_ACCESS_DENIED; } } linep = &line[0]; device_found = 0; while ( fgets(line, MAX_LINE_LEN, fp) ) { p = index(linep, SEPARATOR); if ( p ) { *p = '\0'; device = linep; if ( strcmp(device, ressource) == 0 ) { DBG(2, "equal\n"); device_found = 1; break; } } } if ( ! device_found ) { fclose(fp); return SANE_STATUS_GOOD; } fseek(fp, 0L, SEEK_SET); (*auth_callback) (ressource, username, password); status = SANE_STATUS_ACCESS_DENIED; do { fgets(line, MAX_LINE_LEN, fp); if ( ! ferror(fp) && ! feof(fp) ) { /* neither strsep(3) nor strtok(3) seem to work on my system */ p = index(linep, SEPARATOR); if ( p == NULL ) continue; *p = '\0'; device = linep; if ( strcmp( device, ressource) != 0 ) /* not a matching entry */ continue; linep = ++p; p = index(linep, SEPARATOR); if ( p == NULL ) continue; *p = '\0'; user = linep; if ( strncmp(user, username, SANE_MAX_USERNAME_LEN) != 0 ) continue; /* username doesnt match */ linep = ++p; /* rest of the line is considered to be the password */ passwd = linep; /* remove newline */ *(passwd + strlen(passwd) - 1) = '\0'; p = crypt(password, SALT); if ( strcmp(p, passwd) == 0 ) { /* authentication ok */ status = SANE_STATUS_GOOD; break; } else continue; } } while ( ! ferror(fp) && ! feof(fp) ); fclose(fp); return status; } #endif /*---------- dump_area() -----------------------------------------------------*/ static SANE_Status dump_area(uint8_t *area, int len, char *info) { /* this function dumps control or information blocks */ #define BPL 16 /* bytes per line to print */ int i; int o; int o_limit; char outputline[100]; char *outbuf; if ( ! info[0] ) info = "No additional info available"; DBG(30, "dump_area: %s\n", info); outbuf = outputline; o_limit = (len + BPL - 1) / BPL; for ( o = 0; o < o_limit; o++) { sprintf(outbuf, " %4d: ", o * BPL); outbuf += 8; for ( i=0; i < BPL && (o * BPL + i ) < len; i++) { if ( i == BPL / 2 ) { sprintf(outbuf, " "); outbuf +=1; } sprintf(outbuf, "%02x", area[o * BPL + i]); outbuf += 2; } sprintf(outbuf, "%*s", 2 * ( 2 + BPL - i), " " ); outbuf += (2 * ( 2 + BPL - i)); sprintf(outbuf, "%s", (i == BPL / 2) ? " " : ""); outbuf += ((i == BPL / 2) ? 1 : 0); for ( i = 0; i < BPL && (o * BPL + i ) < len; i++) { if ( i == BPL / 2 ) { sprintf(outbuf, " "); outbuf += 1; } sprintf(outbuf, "%c", isprint(area[o * BPL + i]) ? area[o * BPL + i] : '.'); outbuf += 1; } outbuf = outputline; DBG(1, "%s\n", outbuf); } return SANE_STATUS_GOOD; } /*---------- dump_area2() ----------------------------------------------------*/ static SANE_Status dump_area2(uint8_t *area, int len, char *info) { #define BPL 16 /* bytes per line to print */ int i; char outputline[100]; char *outbuf; if ( ! info[0] ) info = "No additional info available"; DBG(1, "[%s]\n", info); outbuf = outputline; for ( i = 0; i < len; i++) { sprintf(outbuf, "%02x,", *(area + i)); outbuf += 3; if ( ((i+1)%BPL == 0) || (i == len-1) ) { outbuf = outputline; DBG(1, "%s\n", outbuf); } } return SANE_STATUS_GOOD; } /*---------- dump_to_file() --------------------------------------------------*/ /*--- only for debugging, currently not used -----*/ #if 0 static SANE_Status dump_to_file(uint8_t *area, int len, char *filename, char *mode) { FILE *out; int i; out = fopen(filename, mode); for ( i = 0; i < len; i++) fputc( *(area + i ), out); fclose(out); return SANE_STATUS_GOOD; } #endif /*---------- dump_attributes() -----------------------------------------------*/ static SANE_Status dump_attributes(Microtek2_Info *mi) { /* dump all we know about the scanner */ int i; DBG(30, "dump_attributes: mi=%p\n", (void *) mi); DBG(1, "\n"); DBG(1, "Scanner attributes from device structure\n"); DBG(1, "========================================\n"); DBG(1, "Scanner ID...\n"); DBG(1, "~~~~~~~~~~~~~\n"); DBG(1, " Vendor Name%15s: '%s'\n", " ", mi->vendor); DBG(1, " Model Name%16s: '%s'\n", " ", mi->model); DBG(1, " Revision%18s: '%s'\n", " ", mi->revision); DBG(1, " Model Code%16s: 0x%02x\n"," ", mi->model_code); switch(mi->model_code) { case 0x80: DBG(1, "Redondo 2000XL / ArtixScan 2020\n"); break; case 0x81: DBG(1, "ScanMaker 4 / Aruba\n"); break; case 0x82: DBG(1, "Bali\n"); break; case 0x83: DBG(1, "Washington\n"); break; case 0x84: DBG(1, "Manhattan\n"); break; case 0x85: DBG(1, "ScanMaker V300 / Phantom parallel / TR3\n"); break; case 0x86: DBG(1, "CCP\n"); break; case 0x87: DBG(1, "Scanmaker V\n"); break; case 0x88: DBG(1, "Scanmaker VI\n"); break; case 0x89: DBG(1, "ScanMaker 6400XL / A3-400\n"); break; case 0x8a: DBG(1, "ScanMaker 9600XL / A3-600\n"); break; case 0x8b: DBG(1, "Watt\n"); break; case 0x8c: DBG(1, "ScanMaker V600 / TR6\n"); break; case 0x8d: DBG(1, "ScanMaker V310 / Tr3 10-bit\n"); break; case 0x8e: DBG(1, "CCB\n"); break; case 0x8f: DBG(1, "Sun Rise\n"); break; case 0x90: DBG(1, "ScanMaker E3+ 10-bit\n"); break; case 0x91: DBG(1, "ScanMaker X6 / Phantom 636\n"); break; case 0x92: DBG(1, "ScanMaker E3+ / Vobis Highscan\n"); break; case 0x93: DBG(1, "ScanMaker V310\n"); break; case 0x94: DBG(1, "SlimScan C3 / Phantom 330cx / 336cx\n"); break; case 0x95: DBG(1, "ArtixScan 1010\n"); break; case 0x97: DBG(1, "ScanMaker V636\n"); break; case 0x98: DBG(1, "ScanMaker X6EL\n"); break; case 0x99: DBG(1, "ScanMaker X6 / X6USB\n"); break; case 0x9a: DBG(1, "SlimScan C6 / Phantom 636cx\n"); break; case 0x9d: DBG(1, "AGFA DuoScan T1200\n"); break; case 0xa0: DBG(1, "SlimScan C3 / Phantom 336cx\n"); break; case 0xac: DBG(1, "ScanMaker V6UL\n"); break; case 0xa3: DBG(1, "ScanMaker V6USL\n"); break; case 0xaf: DBG(1, "SlimScan C3 / Phantom 336cx\n"); break; case 0xb0: DBG(1, "ScanMaker X12USL\n"); break; case 0xb3: DBG(1, "ScanMaker 3600\n"); break; case 0xb4: DBG(1, "ScanMaker 4700\n"); break; case 0xb6: DBG(1, "ScanMaker V6UPL\n"); break; case 0xb8: DBG(1, "ScanMaker 3700\n"); break; case 0xde: DBG(1, "ScanMaker 9800XL\n"); break; default: DBG(1, "Unknown\n"); break; } DBG(1, " Device Type Code%10s: 0x%02x (%s),\n", " ", mi->device_type, mi->device_type & MI_DEVTYPE_SCANNER ? "Scanner" : "Unknown type"); switch (mi->scanner_type) { case MI_TYPE_FLATBED: DBG(1, " Scanner type%14s:%s", " ", " Flatbed scanner\n"); break; case MI_TYPE_TRANSPARENCY: DBG(1, " Scanner type%14s:%s", " ", " Transparency scanner\n"); break; case MI_TYPE_SHEEDFEED: DBG(1, " Scanner type%14s:%s", " ", " Sheet feed scanner\n"); break; default: DBG(1, " Scanner type%14s:%s", " ", " Unknown\n"); break; } DBG(1, " Supported options%9s: Automatic document feeder: %s\n", " ", mi->option_device & MI_OPTDEV_ADF ? "Yes" : "No"); DBG(1, "%30sTransparency media adapter: %s\n", " ", mi->option_device & MI_OPTDEV_TMA ? "Yes" : "No"); DBG(1, "%30sAuto paper detecting: %s\n", " ", mi->option_device & MI_OPTDEV_ADP ? "Yes" : "No"); DBG(1, "%30sAdvanced picture system: %s\n", " ", mi->option_device & MI_OPTDEV_APS ? "Yes" : "No"); DBG(1, "%30sStripes: %s\n", " ", mi->option_device & MI_OPTDEV_STRIPE ? "Yes" : "No"); DBG(1, "%30sSlides: %s\n", " ", mi->option_device & MI_OPTDEV_SLIDE ? "Yes" : "No"); DBG(1, " Scan button%15s: %s\n", " ", mi->scnbuttn ? "Yes" : "No"); DBG(1, "\n"); DBG(1, " Imaging Capabilities...\n"); DBG(1, " ~~~~~~~~~~~~~~~~~~~~~~~\n"); DBG(1, " Color scanner%6s: %s\n", " ", (mi->color) ? "Yes" : "No"); DBG(1, " Number passes%6s: %d pass%s\n", " ", (mi->onepass) ? 1 : 3, (mi->onepass) ? "" : "es"); DBG(1, " Resolution%9s: X-max: %5d dpi\n%35sY-max: %5d dpi\n", " ", mi->max_xresolution, " ",mi->max_yresolution); DBG(1, " Geometry%11s: Geometric width: %5d pts (%2.2f'')\n", " ", mi->geo_width, (float) mi->geo_width / (float) mi->opt_resolution); DBG(1, "%23sGeometric height:%5d pts (%2.2f'')\n", " ", mi->geo_height, (float) mi->geo_height / (float) mi->opt_resolution); DBG(1, " Optical resolution%1s: %d\n", " ", mi->opt_resolution); DBG(1, " Modes%14s: Lineart: %s\n%35sHalftone: %s\n", " ", (mi->scanmode & MI_HASMODE_LINEART) ? " Yes" : " No", " ", (mi->scanmode & MI_HASMODE_HALFTONE) ? "Yes" : "No"); DBG(1, "%23sGray: %s\n%35sColor: %s\n", " ", (mi->scanmode & MI_HASMODE_GRAY) ? " Yes" : " No", " ", (mi->scanmode & MI_HASMODE_COLOR) ? " Yes" : " No"); DBG(1, " Depths%14s: Nibble Gray: %s\n", " ", (mi->depth & MI_HASDEPTH_NIBBLE) ? "Yes" : "No"); DBG(1, "%23s10-bit-color: %s\n", " ", (mi->depth & MI_HASDEPTH_10) ? "Yes" : "No"); DBG(1, "%23s12-bit-color: %s\n", " ", (mi->depth & MI_HASDEPTH_12) ? "Yes" : "No"); DBG(1, "%23s14-bit-color: %s\n", " ", (mi->depth & MI_HASDEPTH_14) ? "Yes" : "No"); DBG(1, "%23s16-bit-color: %s\n", " ", (mi->depth & MI_HASDEPTH_16) ? "Yes" : "No"); DBG(1, " d/l of HT pattern%2s: %s\n", " ", (mi->has_dnldptrn) ? "Yes" : "No"); DBG(1, " Builtin HT pattern%1s: %d\n", " ", mi->grain_slct); if ( MI_LUTCAP_NONE(mi->lut_cap) ) DBG(1, " LUT capabilities : None\n"); if ( mi->lut_cap & MI_LUTCAP_256B ) DBG(1, " LUT capabilities : 256 bytes\n"); if ( mi->lut_cap & MI_LUTCAP_1024B ) DBG(1, " LUT capabilities : 1024 bytes\n"); if ( mi->lut_cap & MI_LUTCAP_1024W ) DBG(1, " LUT capabilities : 1024 words\n"); if ( mi->lut_cap & MI_LUTCAP_4096B ) DBG(1, " LUT capabilities : 4096 bytes\n"); if ( mi->lut_cap & MI_LUTCAP_4096W ) DBG(1, " LUT capabilities : 4096 words\n"); if ( mi->lut_cap & MI_LUTCAP_64k_W ) DBG(1, " LUT capabilities : 64k words\n"); if ( mi->lut_cap & MI_LUTCAP_16k_W ) DBG(1, " LUT capabilities : 16k words\n"); DBG(1, "\n"); DBG(1, " Miscellaneous capabilities...\n"); DBG(1, " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); if ( mi->onepass) { switch(mi->data_format) { case MI_DATAFMT_CHUNKY: DBG(1, " Data format :%s", " Chunky data, R, G & B in one pixel\n"); break; case MI_DATAFMT_LPLCONCAT: DBG(1, " Data format :%s", " Line by line in concatenated sequence,\n"); DBG(1, "%23swithout color indicator\n", " "); break; case MI_DATAFMT_LPLSEGREG: DBG(1, " Data format :%s", " Line by line in segregated sequence,\n"); DBG(1, "%23swith color indicator\n", " "); break; case MI_DATAFMT_WORDCHUNKY: DBG(1, " Data format : Word chunky data\n"); break; default: DBG(1, " Data format : Unknown\n"); break; } } else DBG(1, "No information with 3-pass scanners\n"); DBG(1, " Color Sequence%17s: \n", " "); for ( i = 0; i < RSA_COLORSEQUENCE_L; i++) { switch(mi->color_sequence[i]) { case MI_COLSEQ_RED: DBG(1,"%34s%s\n", " ","R"); break; case MI_COLSEQ_GREEN: DBG(1,"%34s%s\n", " ","G"); break; case MI_COLSEQ_BLUE: DBG(1,"%34s%s\n", " ","B"); break; } } if ( mi->new_image_status == SANE_TRUE ) DBG(1, " Using new ReadImageStatus format\n"); else DBG(1, " Using old ReadImageStatus format\n"); if ( mi->direction & MI_DATSEQ_RTOL ) DBG(1, " Scanning direction : right to left\n"); else DBG(1, " Scanning direction : left to right\n"); DBG(1, " CCD gap%24s: %d lines\n", " ", mi->ccd_gap); DBG(1, " CCD pixels%21s: %d\n", " ", mi->ccd_pixels); DBG(1, " Calib white stripe location%4s: %d\n", " ", mi->calib_white); DBG(1, " Max calib space%16s: %d\n", " ", mi->calib_space); DBG(1, " Number of lens%17s: %d\n", " ", mi->nlens); DBG(1, " Max number of windows%10s: %d\n", " ", mi->nwindows); DBG(1, " Shading transfer function%6s: 0x%02x\n", " ",mi->shtrnsferequ); DBG(1, " Red balance%20s: %d\n", " ", mi->balance[0]); DBG(1, " Green balance%18s: %d\n", " ", mi->balance[1]); DBG(1, " Blue balance%19s: %d\n", " " , mi->balance[2]); DBG(1, " Buffer type%20s: %s\n", " ", mi->buftype ? "Ping-Pong" : "Ring"); DBG(1, " FEPROM%25s: %s\n", " ", mi->feprom ? "Yes" : "No"); md_dump_clear = 0; return SANE_STATUS_GOOD; } /*---------- max_string_size() -----------------------------------------------*/ static size_t max_string_size (const SANE_String_Const strings[]) { size_t size; size_t max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen(strings[i]) + 1; /* +1 because NUL counts as part of string */ if (size > max_size) max_size = size; } return max_size; } /*---------- parse_config_file() ---------------------------------------------*/ static void parse_config_file(FILE *fp, Config_Temp **ct) { /* builds a list of device names with associated options from the */ /* config file for later use, when building the list of devices. */ /* ct->device = NULL indicates global options (valid for all devices */ char s[PATH_MAX]; Config_Options global_opts; Config_Temp *hct1; Config_Temp *hct2; DBG(30, "parse_config_file: fp=%p\n", (void *) fp); *ct = hct1 = NULL; /* first read global options and store them in global_opts */ /* initialize global_opts with default values */ global_opts = md_options; while ( sanei_config_read(s, sizeof(s), fp) ) { DBG(100, "parse_config_file: read line: %s\n", s); if ( *s == '#' || *s == '\0' ) /* ignore empty lines and comments */ continue; if ( strncmp( sanei_config_skip_whitespace(s), "option ", 7) == 0 || strncmp( sanei_config_skip_whitespace(s), "option\t", 7) == 0 ) { DBG(100, "parse_config_file: found global option %s\n", s); check_option(s, &global_opts); } else /* it is considered a new device */ break; } if ( ferror(fp) || feof(fp) ) { if ( ferror(fp) ) DBG(1, "parse_config_file: fread failed: errno=%d\n", errno); return; } while ( ! feof(fp) && ! ferror(fp) ) { if ( *s == '#' || *s == '\0' ) /* ignore empty lines and comments */ { sanei_config_read(s, sizeof(s), fp); continue; } if ( strncmp( sanei_config_skip_whitespace(s), "option ", 7) == 0 || strncmp( sanei_config_skip_whitespace(s), "option\t", 7) == 0 ) { /* when we enter this loop for the first time we allocate */ /* memory, because the line surely contains a device name, */ /* so hct1 is always != NULL at this point */ DBG(100, "parse_config_file: found device option %s\n", s); check_option(s, &hct1->opts); } else /* it is considered a new device */ { DBG(100, "parse_config_file: found device %s\n", s); hct2 = (Config_Temp *) malloc(sizeof(Config_Temp)); if ( hct2 == NULL ) { DBG(1, "parse_config_file: malloc() failed\n"); return; } if ( *ct == NULL ) /* first element */ *ct = hct1 = hct2; hct1->next = hct2; hct1 = hct2; hct1->device = strdup(s); hct1->opts = global_opts; hct1->next = NULL; } sanei_config_read(s, sizeof(s), fp); } /* set filepointer to the beginning of the file */ fseek(fp, 0L, SEEK_SET); return; } /*---------- signal_handler() ------------------------------------------------*/ static void signal_handler (int signal) { if ( signal == SIGTERM ) { sanei_scsi_req_flush_all (); _exit (SANE_STATUS_GOOD); } } /*---------- init_options() --------------------------------------------------*/ static SANE_Status init_options(Microtek2_Scanner *ms, uint8_t current_scan_source) { /* This function is called every time, when the scan source changes. */ /* The option values, that possibly change, are then reinitialized, */ /* whereas the option descriptors and option values that never */ /* change are not */ SANE_Option_Descriptor *sod; SANE_Status status; Option_Value *val; Microtek2_Device *md; Microtek2_Info *mi; int tablesize; int option_size; int max_gamma_value; int color; int i; static int first_call = 1; /* indicates, whether option */ /* descriptors must be initialized */ /* cannot be used as after a sane_close the sod's must be initialized */ DBG(30, "init_options: handle=%p, source=%d\n", (void *) ms, current_scan_source); sod = ms->sod; val = ms->val; md = ms->dev; mi = &md->info[current_scan_source]; /* needed for gamma calculation */ get_lut_size(mi, &md->max_lut_size, &md->lut_entry_size); /* calculate new values, where possibly needed */ /* Scan source */ if ( val[OPT_SOURCE].s ) free((void *) val[OPT_SOURCE].s); i = 0; md->scansource_list[i] = (SANE_String) MD_SOURCESTRING_FLATBED; if ( current_scan_source == MD_SOURCE_FLATBED ) val[OPT_SOURCE].s = (SANE_String) strdup(md->scansource_list[i]); if ( md->status.adfcnt ) { md->scansource_list[++i] = (SANE_String) MD_SOURCESTRING_ADF; if ( current_scan_source == MD_SOURCE_ADF ) val[OPT_SOURCE].s = (SANE_String) strdup(md->scansource_list[i]); } if ( md->status.tmacnt ) { md->scansource_list[++i] = (SANE_String) MD_SOURCESTRING_TMA; if ( current_scan_source == MD_SOURCE_TMA ) val[OPT_SOURCE].s = (SANE_String) strdup(md->scansource_list[i]); } if ( mi->option_device & MI_OPTDEV_STRIPE ) { md->scansource_list[++i] = (SANE_String) MD_SOURCESTRING_STRIPE; if ( current_scan_source == MD_SOURCE_STRIPE ) val[OPT_SOURCE].s = (SANE_String) strdup(md->scansource_list[i]); } /* Comment this out as long as I do not know in which bit */ /* it is indicated, whether a slide adapter is connected */ #if 0 if ( mi->option_device & MI_OPTDEV_SLIDE ) { md->scansource_list[++i] = (SANE_String) MD_SOURCESTRING_SLIDE; if ( current_scan_source == MD_SOURCE_SLIDE ) val[OPT_SOURCE].s = (SANE_String) strdup(md->scansource_list[i]); } #endif md->scansource_list[++i] = NULL; /* Scan mode */ if ( val[OPT_MODE].s ) free((void *) val[OPT_MODE].s); i = 0; if ( (mi->scanmode & MI_HASMODE_COLOR) ) { md->scanmode_list[i] = (SANE_String) MD_MODESTRING_COLOR; val[OPT_MODE].s = strdup(md->scanmode_list[i]); ++i; } if ( mi->scanmode & MI_HASMODE_GRAY ) { md->scanmode_list[i] = (SANE_String) MD_MODESTRING_GRAY; if ( ! (mi->scanmode & MI_HASMODE_COLOR ) ) val[OPT_MODE].s = strdup(md->scanmode_list[i]); ++i; } if ( mi->scanmode & MI_HASMODE_HALFTONE ) { md->scanmode_list[i] = (SANE_String) MD_MODESTRING_HALFTONE; if ( ! (mi->scanmode & MI_HASMODE_COLOR ) && ! (mi->scanmode & MI_HASMODE_GRAY ) ) val[OPT_MODE].s = strdup(md->scanmode_list[i]); ++i; } /* Always enable a lineart mode. Some models (X6, FW 1.40) say */ /* that they have no lineart mode. In this case we will do a grayscale */ /* scan and convert it to onebit data */ md->scanmode_list[i] = (SANE_String) MD_MODESTRING_LINEART; if ( ! (mi->scanmode & MI_HASMODE_COLOR ) && ! (mi->scanmode & MI_HASMODE_GRAY ) && ! (mi->scanmode & MI_HASMODE_HALFTONE ) ) val[OPT_MODE].s = strdup(md->scanmode_list[i]); ++i; md->scanmode_list[i] = NULL; /* bitdepth */ i = 0; #if 0 if ( mi->depth & MI_HASDEPTH_NIBBLE ) md->bitdepth_list[++i] = (SANE_Int) MD_DEPTHVAL_4; #endif md->bitdepth_list[++i] = (SANE_Int) MD_DEPTHVAL_8; if ( mi->depth & MI_HASDEPTH_10 ) md->bitdepth_list[++i] = (SANE_Int) MD_DEPTHVAL_10; if ( mi->depth & MI_HASDEPTH_12 ) md->bitdepth_list[++i] = (SANE_Int) MD_DEPTHVAL_12; if ( mi->depth & MI_HASDEPTH_14 ) md->bitdepth_list[++i] = (SANE_Int) MD_DEPTHVAL_14; if ( mi->depth & MI_HASDEPTH_16 ) md->bitdepth_list[++i] = (SANE_Int) MD_DEPTHVAL_16; md->bitdepth_list[0] = i; if ( md->bitdepth_list[1] == (SANE_Int) MD_DEPTHVAL_8 ) val[OPT_BITDEPTH].w = md->bitdepth_list[1]; else val[OPT_BITDEPTH].w = md->bitdepth_list[2]; /* Halftone */ md->halftone_mode_list[0] = (SANE_String) MD_HALFTONE0; md->halftone_mode_list[1] = (SANE_String) MD_HALFTONE1; md->halftone_mode_list[2] = (SANE_String) MD_HALFTONE2; md->halftone_mode_list[3] = (SANE_String) MD_HALFTONE3; md->halftone_mode_list[4] = (SANE_String) MD_HALFTONE4; md->halftone_mode_list[5] = (SANE_String) MD_HALFTONE5; md->halftone_mode_list[6] = (SANE_String) MD_HALFTONE6; md->halftone_mode_list[7] = (SANE_String) MD_HALFTONE7; md->halftone_mode_list[8] = (SANE_String) MD_HALFTONE8; md->halftone_mode_list[9] = (SANE_String) MD_HALFTONE9; md->halftone_mode_list[10] = (SANE_String) MD_HALFTONE10; md->halftone_mode_list[11] = (SANE_String) MD_HALFTONE11; md->halftone_mode_list[12] = NULL; if ( val[OPT_HALFTONE].s ) free((void *) val[OPT_HALFTONE].s); val[OPT_HALFTONE].s = strdup(md->halftone_mode_list[0]); /* Resolution */ md->x_res_range_dpi.min = SANE_FIX(10.0); md->x_res_range_dpi.max = SANE_FIX(mi->max_xresolution); md->x_res_range_dpi.quant = SANE_FIX(1.0); val[OPT_RESOLUTION].w = MIN(MD_RESOLUTION_DEFAULT, md->x_res_range_dpi.max); md->y_res_range_dpi.min = SANE_FIX(10.0); md->y_res_range_dpi.max = SANE_FIX(mi->max_yresolution); md->y_res_range_dpi.quant = SANE_FIX(1.0); val[OPT_Y_RESOLUTION].w = val[OPT_RESOLUTION].w; /* bind is default */ /* Preview mode */ val[OPT_PREVIEW].w = SANE_FALSE; /* Geometry */ md->x_range_mm.min = SANE_FIX(0.0); md->x_range_mm.max = SANE_FIX((double) mi->geo_width / (double) mi->opt_resolution * MM_PER_INCH); md->x_range_mm.quant = SANE_FIX(0.0); md->y_range_mm.min = SANE_FIX(0.0); md->y_range_mm.max = SANE_FIX((double) mi->geo_height / (double) mi->opt_resolution * MM_PER_INCH); md->y_range_mm.quant = SANE_FIX(0.0); val[OPT_TL_X].w = SANE_FIX(0.0); val[OPT_TL_Y].w = SANE_FIX(0.0); val[OPT_BR_X].w = md->x_range_mm.max; val[OPT_BR_Y].w = md->y_range_mm.max; /* Enhancement group */ val[OPT_BRIGHTNESS].w = MD_BRIGHTNESS_DEFAULT; val[OPT_CONTRAST].w = MD_CONTRAST_DEFAULT; val[OPT_THRESHOLD].w = MD_THRESHOLD_DEFAULT; /* Gamma */ /* linear gamma must come first */ i = 0; md->gammamode_list[i++] = (SANE_String) MD_GAMMAMODE_LINEAR; md->gammamode_list[i++] = (SANE_String) MD_GAMMAMODE_SCALAR; md->gammamode_list[i++] = (SANE_String) MD_GAMMAMODE_CUSTOM; if ( val[OPT_GAMMA_MODE].s ) free((void *) val[OPT_GAMMA_MODE].s); val[OPT_GAMMA_MODE].s = strdup(md->gammamode_list[0]); md->gammamode_list[i] = NULL; /* bind gamma */ val[OPT_GAMMA_BIND].w = SANE_TRUE; val[OPT_GAMMA_SCALAR].w = MD_GAMMA_DEFAULT; val[OPT_GAMMA_SCALAR_R].w = MD_GAMMA_DEFAULT; val[OPT_GAMMA_SCALAR_G].w = MD_GAMMA_DEFAULT; val[OPT_GAMMA_SCALAR_B].w = MD_GAMMA_DEFAULT; /* If the device supports gamma tables, we allocate memory according */ /* to lookup table capabilities, otherwise we allocate 4096 elements */ /* which is sufficient for a color depth of 12. If the device */ /* does not support gamma tables, we fill the table according to */ /* the actual bit depth, i.e. 256 entries with a range of 0..255 */ /* if the actual bit depth is 8, for example. This will hopefully*/ /* make no trouble if the bit depth is 1. */ if ( md->model_flags & MD_NO_GAMMA ) { tablesize = 4096; option_size = (int) pow(2.0, (double) val[OPT_BITDEPTH].w ); max_gamma_value = option_size - 1; } else { tablesize = md->max_lut_size; option_size = tablesize; max_gamma_value = md->max_lut_size - 1; } for ( color = 0; color < 4; color++ ) { /* index 0 is used if bind gamma == true, index 1 to 3 */ /* if bind gamma == false */ if ( md->custom_gamma_table[color] ) free((void *) md->custom_gamma_table[color]); md->custom_gamma_table[color] = (SANE_Int *) malloc(tablesize * sizeof(SANE_Int)); DBG(100, "init_options: md->custom_gamma_table[%d]=%p, malloc'd %lu bytes\n", color, (void *) md->custom_gamma_table[color], (u_long) (tablesize * sizeof(SANE_Int))); if ( md->custom_gamma_table[color] == NULL ) { DBG(1, "init_options: malloc for custom gamma table failed\n"); return SANE_STATUS_NO_MEM; } for ( i = 0; i < max_gamma_value; i++ ) md->custom_gamma_table[color][i] = i; } md->custom_gamma_range.min = 0; md->custom_gamma_range.max = max_gamma_value; md->custom_gamma_range.quant = 1; sod[OPT_GAMMA_CUSTOM].size = option_size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_R].size = option_size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_G].size = option_size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_B].size = option_size * sizeof (SANE_Int); val[OPT_GAMMA_CUSTOM].wa = &md->custom_gamma_table[0][0]; val[OPT_GAMMA_CUSTOM_R].wa = &md->custom_gamma_table[1][0]; val[OPT_GAMMA_CUSTOM_G].wa = &md->custom_gamma_table[2][0]; val[OPT_GAMMA_CUSTOM_B].wa = &md->custom_gamma_table[3][0]; /* Shadow, midtone, highlight, exposure time */ md->channel_list[0] = (SANE_String) MD_CHANNEL_MASTER; md->channel_list[1] = (SANE_String) MD_CHANNEL_RED; md->channel_list[2] = (SANE_String) MD_CHANNEL_GREEN; md->channel_list[3] = (SANE_String) MD_CHANNEL_BLUE; md->channel_list[4] = NULL; if ( val[OPT_CHANNEL].s ) free((void *) val[OPT_CHANNEL].s); val[OPT_CHANNEL].s = strdup(md->channel_list[0]); val[OPT_SHADOW].w = MD_SHADOW_DEFAULT; val[OPT_SHADOW_R].w = MD_SHADOW_DEFAULT; val[OPT_SHADOW_G].w = MD_SHADOW_DEFAULT; val[OPT_SHADOW_B].w = MD_SHADOW_DEFAULT; val[OPT_MIDTONE].w = MD_MIDTONE_DEFAULT; val[OPT_MIDTONE_R].w = MD_MIDTONE_DEFAULT; val[OPT_MIDTONE_G].w = MD_MIDTONE_DEFAULT; val[OPT_MIDTONE_B].w = MD_MIDTONE_DEFAULT; val[OPT_HIGHLIGHT].w = MD_HIGHLIGHT_DEFAULT; val[OPT_HIGHLIGHT_R].w = MD_HIGHLIGHT_DEFAULT; val[OPT_HIGHLIGHT_G].w = MD_HIGHLIGHT_DEFAULT; val[OPT_HIGHLIGHT_B].w = MD_HIGHLIGHT_DEFAULT; val[OPT_EXPOSURE].w = MD_EXPOSURE_DEFAULT; val[OPT_EXPOSURE_R].w = MD_EXPOSURE_DEFAULT; val[OPT_EXPOSURE_G].w = MD_EXPOSURE_DEFAULT; val[OPT_EXPOSURE_B].w = MD_EXPOSURE_DEFAULT; /* special options */ val[OPT_RESOLUTION_BIND].w = SANE_TRUE; /* enable/disable option for backtracking */ val[OPT_DISABLE_BACKTRACK].w = md->opt_no_backtrack_default; /* enable/disable calibration by backend */ val[OPT_CALIB_BACKEND].w = md->opt_backend_calib_default; /* turn off the lamp during a scan */ val[OPT_LIGHTLID35].w = SANE_FALSE; /* auto adjustment of threshold during a lineart scan */ val[OPT_AUTOADJUST].w = SANE_FALSE; /* color balance (100% means no correction) */ val[OPT_BALANCE_R].w = SANE_FIX(100); val[OPT_BALANCE_G].w = SANE_FIX(100); val[OPT_BALANCE_B].w = SANE_FIX(100); if ( first_call ) { /* initialize option descriptors and ranges */ /* Percentage range for brightness, contrast */ md->percentage_range.min = 0 << SANE_FIXED_SCALE_SHIFT; md->percentage_range.max = 200 << SANE_FIXED_SCALE_SHIFT; md->percentage_range.quant = 1 << SANE_FIXED_SCALE_SHIFT; md->threshold_range.min = 1; md->threshold_range.max = 255; md->threshold_range.quant = 1; md->scalar_gamma_range.min = SANE_FIX(0.1); md->scalar_gamma_range.max = SANE_FIX(4.0); md->scalar_gamma_range.quant = SANE_FIX(0.1); md->shadow_range.min = 0; md->shadow_range.max = 253; md->shadow_range.quant = 1; md->midtone_range.min = 1; md->midtone_range.max = 254; md->midtone_range.quant = 1; md->highlight_range.min = 2; md->highlight_range.max = 255; md->highlight_range.quant = 1; md->exposure_range.min = 0; md->exposure_range.max = 510; md->exposure_range.quant = 2; md->balance_range.min = 0; md->balance_range.max = 200 << SANE_FIXED_SCALE_SHIFT; md->balance_range.quant = 1 << SANE_FIXED_SCALE_SHIFT; /* default for most options */ for ( i = 0; i < NUM_OPTIONS; i++ ) { sod[i].type = SANE_TYPE_FIXED; sod[i].unit = SANE_UNIT_NONE; sod[i].size = sizeof(SANE_Fixed); sod[i].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; sod[i].constraint_type = SANE_CONSTRAINT_RANGE; } sod[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; sod[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; sod[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; sod[OPT_NUM_OPTS].type = SANE_TYPE_INT; sod[OPT_NUM_OPTS].size = sizeof (SANE_Int); sod[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; sod[OPT_NUM_OPTS].constraint_type = SANE_CONSTRAINT_NONE; val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* NUM_OPTIONS is no option */ DBG(255, "sod=%p\n", (void *) sod); DBG(255, "OPT_NUM_OPTS=%d\n", OPT_NUM_OPTS); DBG(255, "SANE_CAP_SOFT_DETECT=%d\n", SANE_CAP_SOFT_DETECT); DBG(255, "OPT_NUM_OPTS.cap=%d\n", sod[0].cap); /* The Scan Mode Group */ sod[OPT_MODE_GROUP].title = M_TITLE_SCANMODEGRP; sod[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; sod[OPT_MODE_GROUP].size = 0; sod[OPT_MODE_GROUP].desc = ""; sod[OPT_MODE_GROUP].cap = 0; sod[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Scan source */ sod[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; sod[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; sod[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; sod[OPT_SOURCE].type = SANE_TYPE_STRING; sod[OPT_SOURCE].size = max_string_size(md->scansource_list); /* if there is only one scan source, deactivate option */ if ( md->scansource_list[1] == NULL ) sod[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; sod[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; sod[OPT_SOURCE].constraint.string_list = md->scansource_list; /* Scan mode */ sod[OPT_MODE].name = SANE_NAME_SCAN_MODE; sod[OPT_MODE].title = SANE_TITLE_SCAN_MODE; sod[OPT_MODE].desc = SANE_DESC_SCAN_MODE; sod[OPT_MODE].type = SANE_TYPE_STRING; sod[OPT_MODE].size = max_string_size(md->scanmode_list); sod[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; sod[OPT_MODE].constraint.string_list = md->scanmode_list; /* Bit depth */ sod[OPT_BITDEPTH].name = SANE_NAME_BIT_DEPTH; sod[OPT_BITDEPTH].title = SANE_TITLE_BIT_DEPTH; sod[OPT_BITDEPTH].desc = SANE_DESC_BIT_DEPTH; sod[OPT_BITDEPTH].type = SANE_TYPE_INT; sod[OPT_BITDEPTH].unit = SANE_UNIT_BIT; sod[OPT_BITDEPTH].size = sizeof(SANE_Int); /* if we have only 8 bit color deactivate this option */ if ( md->bitdepth_list[0] == 1 ) sod[OPT_BITDEPTH].cap |= SANE_CAP_INACTIVE; sod[OPT_BITDEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; sod[OPT_BITDEPTH].constraint.word_list = md->bitdepth_list; /* Halftone */ sod[OPT_HALFTONE].name = SANE_NAME_HALFTONE; sod[OPT_HALFTONE].title = SANE_TITLE_HALFTONE; sod[OPT_HALFTONE].desc = SANE_DESC_HALFTONE; sod[OPT_HALFTONE].type = SANE_TYPE_STRING; sod[OPT_HALFTONE].size = max_string_size(md->halftone_mode_list); sod[OPT_HALFTONE].cap |= SANE_CAP_INACTIVE; sod[OPT_HALFTONE].constraint_type = SANE_CONSTRAINT_STRING_LIST; sod[OPT_HALFTONE].constraint.string_list = md->halftone_mode_list; /* Resolution */ sod[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; sod[OPT_RESOLUTION].title = SANE_TITLE_SCAN_X_RESOLUTION; sod[OPT_RESOLUTION].desc = SANE_DESC_SCAN_X_RESOLUTION; sod[OPT_RESOLUTION].unit = SANE_UNIT_DPI; sod[OPT_RESOLUTION].constraint.range = &md->x_res_range_dpi; sod[OPT_Y_RESOLUTION].name = SANE_NAME_SCAN_Y_RESOLUTION; sod[OPT_Y_RESOLUTION].title = SANE_TITLE_SCAN_Y_RESOLUTION; sod[OPT_Y_RESOLUTION].desc = SANE_DESC_SCAN_Y_RESOLUTION; sod[OPT_Y_RESOLUTION].unit = SANE_UNIT_DPI; sod[OPT_Y_RESOLUTION].cap |= SANE_CAP_INACTIVE; sod[OPT_Y_RESOLUTION].constraint.range = &md->y_res_range_dpi; /* Preview */ sod[OPT_PREVIEW].name = SANE_NAME_PREVIEW; sod[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; sod[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; sod[OPT_PREVIEW].type = SANE_TYPE_BOOL; sod[OPT_PREVIEW].size = sizeof(SANE_Bool); sod[OPT_PREVIEW].constraint_type = SANE_CONSTRAINT_NONE; /* Geometry group, for scan area selection */ sod[OPT_GEOMETRY_GROUP].title = M_TITLE_GEOMGRP; sod[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; sod[OPT_GEOMETRY_GROUP].size = 0; sod[OPT_GEOMETRY_GROUP].desc = ""; sod[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; sod[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; sod[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; sod[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; sod[OPT_TL_X].unit = SANE_UNIT_MM; sod[OPT_TL_X].constraint.range = &md->x_range_mm; sod[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; sod[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; sod[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; sod[OPT_TL_Y].unit = SANE_UNIT_MM; sod[OPT_TL_Y].constraint.range = &md->y_range_mm; sod[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; sod[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; sod[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; sod[OPT_BR_X].unit = SANE_UNIT_MM; sod[OPT_BR_X].constraint.range = &md->x_range_mm; sod[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; sod[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; sod[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; sod[OPT_BR_Y].unit = SANE_UNIT_MM; sod[OPT_BR_Y].constraint.range = &md->y_range_mm; /* Enhancement group */ sod[OPT_ENHANCEMENT_GROUP].title = M_TITLE_ENHANCEGRP; sod[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; sod[OPT_ENHANCEMENT_GROUP].desc = ""; sod[OPT_ENHANCEMENT_GROUP].size = 0; sod[OPT_ENHANCEMENT_GROUP].cap = 0; sod[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; sod[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; sod[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; sod[OPT_BRIGHTNESS].unit = SANE_UNIT_PERCENT; sod[OPT_BRIGHTNESS].constraint.range = &md->percentage_range; sod[OPT_CONTRAST].name = SANE_NAME_CONTRAST; sod[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; sod[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; sod[OPT_CONTRAST].unit = SANE_UNIT_PERCENT; sod[OPT_CONTRAST].constraint.range = &md->percentage_range; sod[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; sod[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; sod[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; sod[OPT_THRESHOLD].type = SANE_TYPE_INT; sod[OPT_THRESHOLD].size = sizeof(SANE_Int); sod[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; sod[OPT_THRESHOLD].constraint.range = &md->threshold_range; /* automatically adjust threshold for a lineart scan */ sod[OPT_AUTOADJUST].name = M_NAME_AUTOADJUST; sod[OPT_AUTOADJUST].title = M_TITLE_AUTOADJUST; sod[OPT_AUTOADJUST].desc = M_DESC_AUTOADJUST; sod[OPT_AUTOADJUST].type = SANE_TYPE_BOOL; sod[OPT_AUTOADJUST].size = sizeof(SANE_Bool); sod[OPT_AUTOADJUST].constraint_type = SANE_CONSTRAINT_NONE; if ( strncmp(md->opts.auto_adjust, "off", 3) == 0 ) sod[OPT_AUTOADJUST].cap |= SANE_CAP_INACTIVE; /* Gamma */ sod[OPT_GAMMA_GROUP].title = "Gamma"; sod[OPT_GAMMA_GROUP].desc = ""; sod[OPT_GAMMA_GROUP].type = SANE_TYPE_GROUP; sod[OPT_GAMMA_GROUP].size = 0; sod[OPT_GAMMA_GROUP].cap = 0; sod[OPT_GAMMA_GROUP].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_GAMMA_MODE].name = M_NAME_GAMMA_MODE; sod[OPT_GAMMA_MODE].title = M_TITLE_GAMMA_MODE; sod[OPT_GAMMA_MODE].desc = M_DESC_GAMMA_MODE; sod[OPT_GAMMA_MODE].type = SANE_TYPE_STRING; sod[OPT_GAMMA_MODE].size = max_string_size(md->gammamode_list); sod[OPT_GAMMA_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; sod[OPT_GAMMA_MODE].constraint.string_list = md->gammamode_list; sod[OPT_GAMMA_BIND].name = M_NAME_GAMMA_BIND; sod[OPT_GAMMA_BIND].title = M_TITLE_GAMMA_BIND; sod[OPT_GAMMA_BIND].desc = M_DESC_GAMMA_BIND; sod[OPT_GAMMA_BIND].type = SANE_TYPE_BOOL; sod[OPT_GAMMA_BIND].size = sizeof(SANE_Bool); sod[OPT_GAMMA_BIND].constraint_type = SANE_CONSTRAINT_NONE; /* this is active if gamma_bind == true and gammamode == scalar */ sod[OPT_GAMMA_SCALAR].name = M_NAME_GAMMA_SCALAR; sod[OPT_GAMMA_SCALAR].title = M_TITLE_GAMMA_SCALAR; sod[OPT_GAMMA_SCALAR].desc = M_DESC_GAMMA_SCALAR; sod[OPT_GAMMA_SCALAR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR].constraint.range = &md->scalar_gamma_range; sod[OPT_GAMMA_SCALAR_R].name = M_NAME_GAMMA_SCALAR_R; sod[OPT_GAMMA_SCALAR_R].title = M_TITLE_GAMMA_SCALAR_R; sod[OPT_GAMMA_SCALAR_R].desc = M_DESC_GAMMA_SCALAR_R; sod[OPT_GAMMA_SCALAR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_R].constraint.range = &md->scalar_gamma_range; sod[OPT_GAMMA_SCALAR_G].name = M_NAME_GAMMA_SCALAR_G; sod[OPT_GAMMA_SCALAR_G].title = M_TITLE_GAMMA_SCALAR_G; sod[OPT_GAMMA_SCALAR_G].desc = M_DESC_GAMMA_SCALAR_G; sod[OPT_GAMMA_SCALAR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_G].constraint.range = &md->scalar_gamma_range; sod[OPT_GAMMA_SCALAR_B].name = M_NAME_GAMMA_SCALAR_B; sod[OPT_GAMMA_SCALAR_B].title = M_TITLE_GAMMA_SCALAR_B; sod[OPT_GAMMA_SCALAR_B].desc = M_DESC_GAMMA_SCALAR_B; sod[OPT_GAMMA_SCALAR_B].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_B].constraint.range = &md->scalar_gamma_range; sod[OPT_GAMMA_CUSTOM].name = SANE_NAME_GAMMA_VECTOR; sod[OPT_GAMMA_CUSTOM].title = SANE_TITLE_GAMMA_VECTOR; sod[OPT_GAMMA_CUSTOM].desc = SANE_DESC_GAMMA_VECTOR; sod[OPT_GAMMA_CUSTOM].type = SANE_TYPE_INT; sod[OPT_GAMMA_CUSTOM].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM].size = option_size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM].constraint.range = &md->custom_gamma_range; sod[OPT_GAMMA_CUSTOM_R].name = SANE_NAME_GAMMA_VECTOR_R; sod[OPT_GAMMA_CUSTOM_R].title = SANE_TITLE_GAMMA_VECTOR_R; sod[OPT_GAMMA_CUSTOM_R].desc = SANE_DESC_GAMMA_VECTOR_R; sod[OPT_GAMMA_CUSTOM_R].type = SANE_TYPE_INT; sod[OPT_GAMMA_CUSTOM_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_R].size = option_size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_R].constraint.range = &md->custom_gamma_range; sod[OPT_GAMMA_CUSTOM_G].name = SANE_NAME_GAMMA_VECTOR_G; sod[OPT_GAMMA_CUSTOM_G].title = SANE_TITLE_GAMMA_VECTOR_G; sod[OPT_GAMMA_CUSTOM_G].desc = SANE_DESC_GAMMA_VECTOR_G; sod[OPT_GAMMA_CUSTOM_G].type = SANE_TYPE_INT; sod[OPT_GAMMA_CUSTOM_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_G].size = option_size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_G].constraint.range = &md->custom_gamma_range; sod[OPT_GAMMA_CUSTOM_B].name = SANE_NAME_GAMMA_VECTOR_B; sod[OPT_GAMMA_CUSTOM_B].title = SANE_TITLE_GAMMA_VECTOR_B; sod[OPT_GAMMA_CUSTOM_B].desc = SANE_DESC_GAMMA_VECTOR_B; sod[OPT_GAMMA_CUSTOM_B].type = SANE_TYPE_INT; sod[OPT_GAMMA_CUSTOM_B].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_B].size = option_size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_B].constraint.range = &md->custom_gamma_range; /* Shadow, midtone, highlight */ sod[OPT_SMH_GROUP].title = M_TITLE_SMHGRP; sod[OPT_SMH_GROUP].desc = ""; sod[OPT_SMH_GROUP].type = SANE_TYPE_GROUP; sod[OPT_SMH_GROUP].size = 0; sod[OPT_SMH_GROUP].cap = 0; sod[OPT_SMH_GROUP].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_CHANNEL].name = M_NAME_CHANNEL; sod[OPT_CHANNEL].title = M_TITLE_CHANNEL; sod[OPT_CHANNEL].desc = M_DESC_CHANNEL; sod[OPT_CHANNEL].type = SANE_TYPE_STRING; sod[OPT_CHANNEL].size = max_string_size(md->channel_list); sod[OPT_CHANNEL].constraint_type = SANE_CONSTRAINT_STRING_LIST; sod[OPT_CHANNEL].constraint.string_list = md->channel_list; sod[OPT_SHADOW].name = SANE_NAME_SHADOW; sod[OPT_SHADOW].title = SANE_TITLE_SHADOW; sod[OPT_SHADOW].desc = SANE_DESC_SHADOW; sod[OPT_SHADOW].type = SANE_TYPE_INT; sod[OPT_SHADOW].size = sizeof(SANE_Int); sod[OPT_SHADOW].constraint.range = &md->shadow_range; sod[OPT_SHADOW_R].name = SANE_NAME_SHADOW_R; sod[OPT_SHADOW_R].title = SANE_TITLE_SHADOW_R; sod[OPT_SHADOW_R].desc = SANE_DESC_SHADOW_R; sod[OPT_SHADOW_R].type = SANE_TYPE_INT; sod[OPT_SHADOW_R].size = sizeof(SANE_Int); sod[OPT_SHADOW_R].constraint.range = &md->shadow_range; sod[OPT_SHADOW_G].name = SANE_NAME_SHADOW_G; sod[OPT_SHADOW_G].title = SANE_TITLE_SHADOW_G; sod[OPT_SHADOW_G].desc = SANE_DESC_SHADOW_G; sod[OPT_SHADOW_G].type = SANE_TYPE_INT; sod[OPT_SHADOW_G].size = sizeof(SANE_Int); sod[OPT_SHADOW_G].constraint.range = &md->shadow_range; sod[OPT_SHADOW_B].name = SANE_NAME_SHADOW_B; sod[OPT_SHADOW_B].title = SANE_TITLE_SHADOW_B; sod[OPT_SHADOW_B].desc = SANE_DESC_SHADOW_B; sod[OPT_SHADOW_B].type = SANE_TYPE_INT; sod[OPT_SHADOW_B].size = sizeof(SANE_Int); sod[OPT_SHADOW_B].constraint.range = &md->shadow_range; sod[OPT_MIDTONE].name = M_NAME_MIDTONE; sod[OPT_MIDTONE].title = M_TITLE_MIDTONE; sod[OPT_MIDTONE].desc = M_DESC_MIDTONE; sod[OPT_MIDTONE].type = SANE_TYPE_INT; sod[OPT_MIDTONE].size = sizeof(SANE_Int); sod[OPT_MIDTONE].constraint.range = &md->midtone_range; sod[OPT_MIDTONE_R].name = M_NAME_MIDTONE_R; sod[OPT_MIDTONE_R].title = M_TITLE_MIDTONE_R; sod[OPT_MIDTONE_R].desc = M_DESC_MIDTONE_R; sod[OPT_MIDTONE_R].type = SANE_TYPE_INT; sod[OPT_MIDTONE_R].size = sizeof(SANE_Int); sod[OPT_MIDTONE_R].constraint.range = &md->midtone_range; sod[OPT_MIDTONE_G].name = M_NAME_MIDTONE_G; sod[OPT_MIDTONE_G].title = M_TITLE_MIDTONE_G; sod[OPT_MIDTONE_G].desc = M_DESC_MIDTONE_G; sod[OPT_MIDTONE_G].type = SANE_TYPE_INT; sod[OPT_MIDTONE_G].size = sizeof(SANE_Int); sod[OPT_MIDTONE_G].constraint.range = &md->midtone_range; sod[OPT_MIDTONE_B].name = M_NAME_MIDTONE_B; sod[OPT_MIDTONE_B].title = M_TITLE_MIDTONE_B; sod[OPT_MIDTONE_B].desc = M_DESC_MIDTONE_B; sod[OPT_MIDTONE_B].type = SANE_TYPE_INT; sod[OPT_MIDTONE_B].size = sizeof(SANE_Int); sod[OPT_MIDTONE_B].constraint.range = &md->midtone_range; sod[OPT_HIGHLIGHT].name = SANE_NAME_HIGHLIGHT; sod[OPT_HIGHLIGHT].title = SANE_TITLE_HIGHLIGHT; sod[OPT_HIGHLIGHT].desc = SANE_DESC_HIGHLIGHT; sod[OPT_HIGHLIGHT].type = SANE_TYPE_INT; sod[OPT_HIGHLIGHT].size = sizeof(SANE_Int); sod[OPT_HIGHLIGHT].constraint.range = &md->highlight_range; sod[OPT_HIGHLIGHT_R].name = SANE_NAME_HIGHLIGHT_R; sod[OPT_HIGHLIGHT_R].title = SANE_TITLE_HIGHLIGHT_R; sod[OPT_HIGHLIGHT_R].desc = SANE_DESC_HIGHLIGHT_R; sod[OPT_HIGHLIGHT_R].type = SANE_TYPE_INT; sod[OPT_HIGHLIGHT_R].size = sizeof(SANE_Int); sod[OPT_HIGHLIGHT_R].constraint.range = &md->highlight_range; sod[OPT_HIGHLIGHT_G].name = SANE_NAME_HIGHLIGHT_G; sod[OPT_HIGHLIGHT_G].title = SANE_TITLE_HIGHLIGHT_G; sod[OPT_HIGHLIGHT_G].desc = SANE_DESC_HIGHLIGHT_G; sod[OPT_HIGHLIGHT_G].type = SANE_TYPE_INT; sod[OPT_HIGHLIGHT_G].size = sizeof(SANE_Int); sod[OPT_HIGHLIGHT_G].constraint.range = &md->highlight_range; sod[OPT_HIGHLIGHT_B].name = SANE_NAME_HIGHLIGHT_B; sod[OPT_HIGHLIGHT_B].title = SANE_TITLE_HIGHLIGHT_B; sod[OPT_HIGHLIGHT_B].desc = SANE_DESC_HIGHLIGHT_B; sod[OPT_HIGHLIGHT_B].type = SANE_TYPE_INT; sod[OPT_HIGHLIGHT_B].size = sizeof(SANE_Int); sod[OPT_HIGHLIGHT_B].constraint.range = &md->highlight_range; sod[OPT_EXPOSURE].name = SANE_NAME_SCAN_EXPOS_TIME; sod[OPT_EXPOSURE].title = SANE_TITLE_SCAN_EXPOS_TIME; sod[OPT_EXPOSURE].desc = SANE_DESC_SCAN_EXPOS_TIME; sod[OPT_EXPOSURE].type = SANE_TYPE_INT; sod[OPT_EXPOSURE].unit = SANE_UNIT_PERCENT; sod[OPT_EXPOSURE].size = sizeof(SANE_Int); sod[OPT_EXPOSURE].constraint.range = &md->exposure_range; sod[OPT_EXPOSURE_R].name = SANE_NAME_SCAN_EXPOS_TIME_R; sod[OPT_EXPOSURE_R].title = SANE_TITLE_SCAN_EXPOS_TIME_R; sod[OPT_EXPOSURE_R].desc = SANE_DESC_SCAN_EXPOS_TIME_R; sod[OPT_EXPOSURE_R].type = SANE_TYPE_INT; sod[OPT_EXPOSURE_R].unit = SANE_UNIT_PERCENT; sod[OPT_EXPOSURE_R].size = sizeof(SANE_Int); sod[OPT_EXPOSURE_R].constraint.range = &md->exposure_range; sod[OPT_EXPOSURE_G].name = SANE_NAME_SCAN_EXPOS_TIME_G; sod[OPT_EXPOSURE_G].title = SANE_TITLE_SCAN_EXPOS_TIME_G; sod[OPT_EXPOSURE_G].desc = SANE_DESC_SCAN_EXPOS_TIME_G; sod[OPT_EXPOSURE_G].type = SANE_TYPE_INT; sod[OPT_EXPOSURE_G].unit = SANE_UNIT_PERCENT; sod[OPT_EXPOSURE_G].size = sizeof(SANE_Int); sod[OPT_EXPOSURE_G].constraint.range = &md->exposure_range; sod[OPT_EXPOSURE_B].name = SANE_NAME_SCAN_EXPOS_TIME_B; sod[OPT_EXPOSURE_B].title = SANE_TITLE_SCAN_EXPOS_TIME_B; sod[OPT_EXPOSURE_B].desc = SANE_DESC_SCAN_EXPOS_TIME_B; sod[OPT_EXPOSURE_B].type = SANE_TYPE_INT; sod[OPT_EXPOSURE_B].unit = SANE_UNIT_PERCENT; sod[OPT_EXPOSURE_B].size = sizeof(SANE_Int); sod[OPT_EXPOSURE_B].constraint.range = &md->exposure_range; /* The Special Options Group */ sod[OPT_SPECIAL].title = M_TITLE_SPECIALGRP; sod[OPT_SPECIAL].type = SANE_TYPE_GROUP; sod[OPT_SPECIAL].size = 0; sod[OPT_SPECIAL].desc = ""; sod[OPT_SPECIAL].cap = SANE_CAP_ADVANCED; sod[OPT_SPECIAL].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_RESOLUTION_BIND].name = SANE_NAME_RESOLUTION_BIND; sod[OPT_RESOLUTION_BIND].title = SANE_TITLE_RESOLUTION_BIND; sod[OPT_RESOLUTION_BIND].desc = SANE_DESC_RESOLUTION_BIND; sod[OPT_RESOLUTION_BIND].type = SANE_TYPE_BOOL; sod[OPT_RESOLUTION_BIND].size = sizeof(SANE_Bool); sod[OPT_RESOLUTION_BIND].cap |= SANE_CAP_ADVANCED; sod[OPT_RESOLUTION_BIND].constraint_type = SANE_CONSTRAINT_NONE; /* enable/disable option for backtracking */ sod[OPT_DISABLE_BACKTRACK].name = M_NAME_NOBACKTRACK; sod[OPT_DISABLE_BACKTRACK].title = M_TITLE_NOBACKTRACK; sod[OPT_DISABLE_BACKTRACK].desc = M_DESC_NOBACKTRACK; sod[OPT_DISABLE_BACKTRACK].type = SANE_TYPE_BOOL; sod[OPT_DISABLE_BACKTRACK].size = sizeof(SANE_Bool); sod[OPT_DISABLE_BACKTRACK].cap |= SANE_CAP_ADVANCED; sod[OPT_DISABLE_BACKTRACK].constraint_type = SANE_CONSTRAINT_NONE; if ( strncmp(md->opts.no_backtracking, "off", 3) == 0 ) sod[OPT_DISABLE_BACKTRACK].cap |= SANE_CAP_INACTIVE; /* calibration by driver */ sod[OPT_CALIB_BACKEND].name = M_NAME_CALIBBACKEND; sod[OPT_CALIB_BACKEND].title = M_TITLE_CALIBBACKEND; sod[OPT_CALIB_BACKEND].desc = M_DESC_CALIBBACKEND; sod[OPT_CALIB_BACKEND].type = SANE_TYPE_BOOL; sod[OPT_CALIB_BACKEND].size = sizeof(SANE_Bool); sod[OPT_CALIB_BACKEND].cap |= SANE_CAP_ADVANCED; sod[OPT_CALIB_BACKEND].constraint_type = SANE_CONSTRAINT_NONE; if ( strncmp(md->opts.backend_calibration, "off", 3) == 0 ) sod[OPT_CALIB_BACKEND].cap |= SANE_CAP_INACTIVE; /* turn off the lamp of the flatbed during a scan */ sod[OPT_LIGHTLID35].name = M_NAME_LIGHTLID35; sod[OPT_LIGHTLID35].title = M_TITLE_LIGHTLID35; sod[OPT_LIGHTLID35].desc = M_DESC_LIGHTLID35; sod[OPT_LIGHTLID35].type = SANE_TYPE_BOOL; sod[OPT_LIGHTLID35].size = sizeof(SANE_Bool); sod[OPT_LIGHTLID35].cap |= SANE_CAP_ADVANCED; sod[OPT_LIGHTLID35].constraint_type = SANE_CONSTRAINT_NONE; if ( strncmp(md->opts.lightlid35, "off", 3) == 0 ) sod[OPT_LIGHTLID35].cap |= SANE_CAP_INACTIVE; /* toggle the lamp of the flatbed */ sod[OPT_TOGGLELAMP].name = M_NAME_TOGGLELAMP; sod[OPT_TOGGLELAMP].title = M_TITLE_TOGGLELAMP; sod[OPT_TOGGLELAMP].desc = M_DESC_TOGGLELAMP; sod[OPT_TOGGLELAMP].type = SANE_TYPE_BUTTON; sod[OPT_TOGGLELAMP].size = 0; sod[OPT_TOGGLELAMP].cap |= SANE_CAP_ADVANCED; sod[OPT_TOGGLELAMP].constraint_type = SANE_CONSTRAINT_NONE; if ( strncmp(md->opts.toggle_lamp, "off", 3) == 0 ) sod[OPT_TOGGLELAMP].cap |= SANE_CAP_INACTIVE; /* color balance */ sod[OPT_COLORBALANCE].title = M_TITLE_COLBALANCEGRP; sod[OPT_COLORBALANCE].type = SANE_TYPE_GROUP; sod[OPT_COLORBALANCE].size = 0; sod[OPT_COLORBALANCE].desc = ""; sod[OPT_COLORBALANCE].cap = SANE_CAP_ADVANCED; sod[OPT_COLORBALANCE].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_BALANCE_R].name = M_NAME_BALANCE_R; sod[OPT_BALANCE_R].title = M_TITLE_BALANCE_R; sod[OPT_BALANCE_R].desc = M_DESC_BALANCE_R; sod[OPT_BALANCE_R].unit = SANE_UNIT_PERCENT; sod[OPT_BALANCE_R].cap |= SANE_CAP_ADVANCED; sod[OPT_BALANCE_R].constraint.range = &md->balance_range; if ( strncmp(md->opts.colorbalance_adjust, "off", 3) == 0 ) sod[OPT_BALANCE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_G].name = M_NAME_BALANCE_G; sod[OPT_BALANCE_G].title = M_TITLE_BALANCE_G; sod[OPT_BALANCE_G].desc = M_DESC_BALANCE_G; sod[OPT_BALANCE_G].unit = SANE_UNIT_PERCENT; sod[OPT_BALANCE_G].cap |= SANE_CAP_ADVANCED; sod[OPT_BALANCE_G].constraint.range = &md->balance_range; if ( strncmp(md->opts.colorbalance_adjust, "off", 3) == 0 ) sod[OPT_BALANCE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_B].name = M_NAME_BALANCE_B; sod[OPT_BALANCE_B].title = M_TITLE_BALANCE_B; sod[OPT_BALANCE_B].desc = M_DESC_BALANCE_B; sod[OPT_BALANCE_B].unit = SANE_UNIT_PERCENT; sod[OPT_BALANCE_B].cap |= SANE_CAP_ADVANCED; sod[OPT_BALANCE_B].constraint.range = &md->balance_range; if ( strncmp(md->opts.colorbalance_adjust, "off", 3) == 0 ) sod[OPT_BALANCE_B].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_FW].name = M_NAME_BALANCE_FW; sod[OPT_BALANCE_FW].title = M_TITLE_BALANCE_FW; sod[OPT_BALANCE_FW].desc = M_DESC_BALANCE_FW; sod[OPT_BALANCE_FW].type = SANE_TYPE_BUTTON; sod[OPT_BALANCE_FW].size = 0; sod[OPT_BALANCE_FW].cap |= SANE_CAP_ADVANCED; sod[OPT_BALANCE_FW].constraint_type = SANE_CONSTRAINT_NONE; if ( strncmp(md->opts.colorbalance_adjust, "off", 3) == 0 ) sod[OPT_BALANCE_FW].cap |= SANE_CAP_INACTIVE; } status = set_option_dependencies(ms, sod, val); if ( status != SANE_STATUS_GOOD ) return status; return SANE_STATUS_GOOD; } /*---------- set_option_dependencies() ---------------------------------------*/ static SANE_Status set_option_dependencies(Microtek2_Scanner *ms, SANE_Option_Descriptor *sod, Option_Value *val) { Microtek2_Device *md; md = ms->dev; DBG(40, "set_option_dependencies: val=%p, sod=%p, mode=%s\n", (void *) val, (void *) sod, val[OPT_MODE].s); if ( strcmp(val[OPT_MODE].s, MD_MODESTRING_COLOR) == 0 ) { /* activate brightness,..., deactivate halftone pattern */ /* and threshold */ sod[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; sod[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; sod[OPT_CHANNEL].cap &= ~SANE_CAP_INACTIVE; sod[OPT_SHADOW].cap &= ~SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap &= ~SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT].cap &= ~SANE_CAP_INACTIVE; sod[OPT_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; sod[OPT_HALFTONE].cap |= SANE_CAP_INACTIVE; sod[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; if ( md->bitdepth_list[0] != 1 ) sod[OPT_BITDEPTH].cap &= ~SANE_CAP_INACTIVE; else sod[OPT_BITDEPTH].cap |= SANE_CAP_INACTIVE; sod[OPT_AUTOADJUST].cap |= SANE_CAP_INACTIVE; if ( ! ( strncmp(md->opts.colorbalance_adjust, "off", 3) == 0 ) ) { sod[OPT_BALANCE_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_BALANCE_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_BALANCE_B].cap &= ~SANE_CAP_INACTIVE; sod[OPT_BALANCE_FW].cap &= ~SANE_CAP_INACTIVE; } /* reset options values that are inactive to their default */ val[OPT_THRESHOLD].w = MD_THRESHOLD_DEFAULT; } else if ( strcmp(val[OPT_MODE].s, MD_MODESTRING_GRAY) == 0 ) { sod[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; sod[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; sod[OPT_CHANNEL].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW].cap &= ~SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap &= ~SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT].cap &= ~SANE_CAP_INACTIVE; sod[OPT_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; sod[OPT_HALFTONE].cap |= SANE_CAP_INACTIVE; sod[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; if ( md->bitdepth_list[0] != 1 ) sod[OPT_BITDEPTH].cap &= ~SANE_CAP_INACTIVE; else sod[OPT_BITDEPTH].cap |= SANE_CAP_INACTIVE; sod[OPT_AUTOADJUST].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_B].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_FW].cap |= SANE_CAP_INACTIVE; /* reset options values that are inactive to their default */ if ( val[OPT_CHANNEL].s ) free((void *) val[OPT_CHANNEL].s); val[OPT_CHANNEL].s = strdup((SANE_String) MD_CHANNEL_MASTER); } else if ( strcmp(val[OPT_MODE].s, MD_MODESTRING_HALFTONE) == 0 ) { sod[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; sod[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; sod[OPT_CHANNEL].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; sod[OPT_HALFTONE].cap &= ~SANE_CAP_INACTIVE; sod[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; sod[OPT_BITDEPTH].cap |= SANE_CAP_INACTIVE; sod[OPT_AUTOADJUST].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_B].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_FW].cap |= SANE_CAP_INACTIVE; /* reset options values that are inactive to their default */ val[OPT_BRIGHTNESS].w = MD_BRIGHTNESS_DEFAULT; val[OPT_CONTRAST].w = MD_CONTRAST_DEFAULT; if ( val[OPT_CHANNEL].s ) free((void *) val[OPT_CHANNEL].s); val[OPT_CHANNEL].s = strdup((SANE_String) MD_CHANNEL_MASTER); val[OPT_SHADOW].w = MD_SHADOW_DEFAULT; val[OPT_MIDTONE].w = MD_MIDTONE_DEFAULT; val[OPT_HIGHLIGHT].w = MD_HIGHLIGHT_DEFAULT; val[OPT_EXPOSURE].w = MD_EXPOSURE_DEFAULT; val[OPT_THRESHOLD].w = MD_THRESHOLD_DEFAULT; } else if ( strcmp(val[OPT_MODE].s, MD_MODESTRING_LINEART) == 0 ) { sod[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; sod[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; sod[OPT_CHANNEL].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; sod[OPT_HALFTONE].cap |= SANE_CAP_INACTIVE; if ( val[OPT_AUTOADJUST].w == SANE_FALSE ) sod[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; else sod[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; sod[OPT_BITDEPTH].cap |= SANE_CAP_INACTIVE; sod[OPT_AUTOADJUST].cap &= ~SANE_CAP_INACTIVE; sod[OPT_BALANCE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_B].cap |= SANE_CAP_INACTIVE; sod[OPT_BALANCE_FW].cap |= SANE_CAP_INACTIVE; /* reset options values that are inactive to their default */ val[OPT_BRIGHTNESS].w = MD_BRIGHTNESS_DEFAULT; val[OPT_CONTRAST].w = MD_CONTRAST_DEFAULT; if ( val[OPT_CHANNEL].s ) free((void *) val[OPT_CHANNEL].s); val[OPT_CHANNEL].s = strdup((SANE_String) MD_CHANNEL_MASTER); val[OPT_SHADOW].w = MD_SHADOW_DEFAULT; val[OPT_MIDTONE].w = MD_MIDTONE_DEFAULT; val[OPT_HIGHLIGHT].w = MD_HIGHLIGHT_DEFAULT; val[OPT_EXPOSURE].w = MD_EXPOSURE_DEFAULT; } else { DBG(1, "set_option_dependencies: unknown mode '%s'\n", val[OPT_MODE].s ); return SANE_STATUS_INVAL; } /* these ones are always inactive if the mode changes */ sod[OPT_SHADOW_R].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_G].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_B].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_B].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_R].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_G].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_B].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_B].cap |= SANE_CAP_INACTIVE; /* reset options values that are inactive to their default */ val[OPT_SHADOW_R].w = val[OPT_SHADOW_G].w = val[OPT_SHADOW_B].w = MD_SHADOW_DEFAULT; val[OPT_MIDTONE_R].w = val[OPT_MIDTONE_G].w = val[OPT_MIDTONE_B].w = MD_MIDTONE_DEFAULT; val[OPT_HIGHLIGHT_R].w = val[OPT_HIGHLIGHT_G].w = val[OPT_HIGHLIGHT_B].w = MD_HIGHLIGHT_DEFAULT; val[OPT_EXPOSURE_R].w = val[OPT_EXPOSURE_G].w = val[OPT_EXPOSURE_B].w = MD_EXPOSURE_DEFAULT; if ( SANE_OPTION_IS_SETTABLE(sod[OPT_GAMMA_MODE].cap) ) { restore_gamma_options(sod, val); } return SANE_STATUS_GOOD; } /*---------- sane_control_option() -------------------------------------------*/ SANE_Status sane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int *info) { Microtek2_Scanner *ms = handle; Microtek2_Device *md; Microtek2_Info *mi; Option_Value *val; SANE_Option_Descriptor *sod; SANE_Status status; md = ms->dev; val = &ms->val[0]; sod = &ms->sod[0]; mi = &md->info[md->scan_source]; if ( ms->scanning ) return SANE_STATUS_DEVICE_BUSY; if ( option < 0 || option >= NUM_OPTIONS ) { DBG(100, "sane_control_option: option %d; action %d \n", option, action); DBG(10, "sane_control_option: option %d invalid\n", option); return SANE_STATUS_INVAL; } if ( ! SANE_OPTION_IS_ACTIVE(ms->sod[option].cap) ) { DBG(100, "sane_control_option: option %d; action %d \n", option, action); DBG(10, "sane_control_option: option %d not active\n", option); return SANE_STATUS_INVAL; } if ( info ) *info = 0; switch ( action ) { case SANE_ACTION_GET_VALUE: /* read out option values */ switch ( option ) { /* word options */ case OPT_BITDEPTH: case OPT_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_THRESHOLD: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_PREVIEW: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_SHADOW: case OPT_SHADOW_R: case OPT_SHADOW_G: case OPT_SHADOW_B: case OPT_MIDTONE: case OPT_MIDTONE_R: case OPT_MIDTONE_G: case OPT_MIDTONE_B: case OPT_HIGHLIGHT: case OPT_HIGHLIGHT_R: case OPT_HIGHLIGHT_G: case OPT_HIGHLIGHT_B: case OPT_EXPOSURE: case OPT_EXPOSURE_R: case OPT_EXPOSURE_G: case OPT_EXPOSURE_B: case OPT_GAMMA_SCALAR: case OPT_GAMMA_SCALAR_R: case OPT_GAMMA_SCALAR_G: case OPT_GAMMA_SCALAR_B: case OPT_BALANCE_R: case OPT_BALANCE_G: case OPT_BALANCE_B: *(SANE_Word *) value = val[option].w; if (sod[option].type == SANE_TYPE_FIXED ) DBG(50, "sane_control_option: opt=%d, act=%d, val=%f\n", option, action, SANE_UNFIX(val[option].w)); else DBG(50, "sane_control_option: opt=%d, act=%d, val=%d\n", option, action, val[option].w); return SANE_STATUS_GOOD; /* boolean options */ case OPT_RESOLUTION_BIND: case OPT_DISABLE_BACKTRACK: case OPT_CALIB_BACKEND: case OPT_LIGHTLID35: case OPT_GAMMA_BIND: case OPT_AUTOADJUST: *(SANE_Bool *) value = val[option].w; DBG(50, "sane_control_option: opt=%d, act=%d, val=%d\n", option, action, val[option].w); return SANE_STATUS_GOOD; /* string options */ case OPT_SOURCE: case OPT_MODE: case OPT_HALFTONE: case OPT_CHANNEL: case OPT_GAMMA_MODE: strcpy(value, val[option].s); DBG(50, "sane_control_option: opt=%d, act=%d, val=%s\n", option, action, val[option].s); return SANE_STATUS_GOOD; /* word array options */ case OPT_GAMMA_CUSTOM: case OPT_GAMMA_CUSTOM_R: case OPT_GAMMA_CUSTOM_G: case OPT_GAMMA_CUSTOM_B: memcpy(value, val[option].wa, sod[option].size); return SANE_STATUS_GOOD; /* button options */ case OPT_TOGGLELAMP: case OPT_BALANCE_FW: return SANE_STATUS_GOOD; /* others */ case OPT_NUM_OPTS: *(SANE_Word *) value = NUM_OPTIONS; return SANE_STATUS_GOOD; default: return SANE_STATUS_UNSUPPORTED; } /* NOTREACHED */ /* break; */ case SANE_ACTION_SET_VALUE: /* set option values */ if ( ! SANE_OPTION_IS_SETTABLE(sod[option].cap) ) { DBG(100, "sane_control_option: option %d; action %d \n", option, action); DBG(10, "sane_control_option: trying to set unsettable option\n"); return SANE_STATUS_INVAL; } /* do not check OPT_BR_Y, xscanimage sometimes tries to set */ /* it to a too large value; bug in xscanimage ? */ /* if ( option != OPT_BR_Y ) { */ status = sanei_constrain_value(ms->sod + option, value, info); if (status != SANE_STATUS_GOOD) { DBG(10, "sane_control_option: invalid option value\n"); return status; } /* } */ switch ( sod[option].type ) { case SANE_TYPE_BOOL: DBG(50, "sane_control_option: option=%d, action=%d, value=%d\n", option, action, *(SANE_Int *) value); if ( ! ( ( *(SANE_Bool *) value == SANE_TRUE ) || ( *(SANE_Bool *) value == SANE_FALSE ) ) ) { DBG(10, "sane_control_option: invalid BOOL option value\n"); return SANE_STATUS_INVAL; } if ( val[option].w == *(SANE_Bool *) value ) /* no change */ return SANE_STATUS_GOOD; val[option].w = *(SANE_Bool *) value; break; case SANE_TYPE_INT: if ( sod[option].size == sizeof(SANE_Int) ) { /* word option */ DBG(50, "sane_control_option: option=%d, action=%d, " "value=%d\n", option, action, *(SANE_Int *) value); if ( val[option].w == *(SANE_Int *) value ) /* no change */ return SANE_STATUS_GOOD; val[option].w = *(SANE_Int *) value; } else { /* word array option */ memcpy(val[option].wa, value, sod[option].size); } break; case SANE_TYPE_FIXED: DBG(50, "sane_control_option: option=%d, action=%d, value=%f\n", option, action, SANE_UNFIX( *(SANE_Fixed *) value)); if ( val[option].w == *(SANE_Fixed *) value ) /* no change */ return SANE_STATUS_GOOD; val[option].w = *(SANE_Fixed *) value; break; case SANE_TYPE_STRING: DBG(50, "sane_control_option: option=%d, action=%d, value=%s\n", option, action, (SANE_String) value); if ( strcmp(val[option].s, (SANE_String) value) == 0 ) return SANE_STATUS_GOOD; /* no change */ if ( val[option].s ) free((void *) val[option].s); val[option].s = strdup(value); if ( val[option].s == NULL ) { DBG(1, "sane_control_option: strdup failed\n"); return SANE_STATUS_NO_MEM; } break; case SANE_TYPE_BUTTON: break; default: DBG(1, "sane_control_option: unknown type %d\n", sod[option].type); break; } switch ( option ) { case OPT_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: if ( info ) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_DISABLE_BACKTRACK: case OPT_CALIB_BACKEND: case OPT_LIGHTLID35: case OPT_PREVIEW: case OPT_BRIGHTNESS: case OPT_THRESHOLD: case OPT_CONTRAST: case OPT_EXPOSURE: case OPT_EXPOSURE_R: case OPT_EXPOSURE_G: case OPT_EXPOSURE_B: case OPT_GAMMA_SCALAR: case OPT_GAMMA_SCALAR_R: case OPT_GAMMA_SCALAR_G: case OPT_GAMMA_SCALAR_B: case OPT_GAMMA_CUSTOM: case OPT_GAMMA_CUSTOM_R: case OPT_GAMMA_CUSTOM_G: case OPT_GAMMA_CUSTOM_B: case OPT_HALFTONE: case OPT_BALANCE_R: case OPT_BALANCE_G: case OPT_BALANCE_B: return SANE_STATUS_GOOD; case OPT_BITDEPTH: /* If the bitdepth has changed we must change the size of */ /* the gamma table if the device does not support gamma */ /* tables. This will hopefully cause no trouble if the */ /* mode is one bit */ if ( md->model_flags & MD_NO_GAMMA ) { int max_gamma_value; int size; int color; int i; size = (int) pow(2.0, (double) val[OPT_BITDEPTH].w) - 1; max_gamma_value = size - 1; for ( color = 0; color < 4; color++ ) { for ( i = 0; i < max_gamma_value; i++ ) md->custom_gamma_table[color][i] = (SANE_Int) i; } md->custom_gamma_range.max = (SANE_Int) max_gamma_value; sod[OPT_GAMMA_CUSTOM].size = size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_R].size = size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_G].size = size * sizeof (SANE_Int); sod[OPT_GAMMA_CUSTOM_B].size = size * sizeof (SANE_Int); if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; } if ( info ) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_SOURCE: if ( info ) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; if ( strcmp(val[option].s, MD_SOURCESTRING_FLATBED) == 0 ) md->scan_source = MD_SOURCE_FLATBED; else if ( strcmp(val[option].s, MD_SOURCESTRING_TMA) == 0 ) md->scan_source = MD_SOURCE_TMA; else if ( strcmp(val[option].s, MD_SOURCESTRING_ADF) == 0 ) md->scan_source = MD_SOURCE_ADF; else if ( strcmp(val[option].s, MD_SOURCESTRING_STRIPE) == 0 ) md->scan_source = MD_SOURCE_STRIPE; else if ( strcmp(val[option].s, MD_SOURCESTRING_SLIDE) == 0 ) md->scan_source = MD_SOURCE_SLIDE; else { DBG(1, "sane_control_option: unsupported option %s\n", val[option].s); return SANE_STATUS_UNSUPPORTED; } init_options(ms, md->scan_source); return SANE_STATUS_GOOD; case OPT_MODE: if ( info ) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; status = set_option_dependencies(ms, sod, val); /* Options with side effects need special treatment. They are */ /* reset, even if they were set by set_option_dependencies(): */ /* if we have more than one color depth activate this option */ if ( md->bitdepth_list[0] == 1 ) sod[OPT_BITDEPTH].cap |= SANE_CAP_INACTIVE; if ( strncmp(md->opts.auto_adjust, "off", 3) == 0 ) sod[OPT_AUTOADJUST].cap |= SANE_CAP_INACTIVE; if ( status != SANE_STATUS_GOOD ) return status; return SANE_STATUS_GOOD; case OPT_CHANNEL: if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; if ( strcmp(val[option].s, MD_CHANNEL_MASTER) == 0 ) { sod[OPT_SHADOW].cap &= ~SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap &= ~SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT].cap &= ~SANE_CAP_INACTIVE; sod[OPT_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; sod[OPT_SHADOW_R].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_R].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_G].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_G].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_B].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_B].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_B].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_B].cap |= SANE_CAP_INACTIVE; } else if ( strcmp(val[option].s, MD_CHANNEL_RED) == 0 ) { sod[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_MIDTONE_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_SHADOW_G].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_G].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_B].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_B].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_B].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_B].cap |= SANE_CAP_INACTIVE; } else if ( strcmp(val[option].s, MD_CHANNEL_GREEN) == 0 ) { sod[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_R].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_R].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_MIDTONE_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_SHADOW_B].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_B].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_B].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_B].cap |= SANE_CAP_INACTIVE; } else if ( strcmp(val[option].s, MD_CHANNEL_BLUE) == 0 ) { sod[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_R].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_R].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_R].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_G].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_G].cap |= SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_G].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW_B].cap &= ~SANE_CAP_INACTIVE; sod[OPT_MIDTONE_B].cap &= ~SANE_CAP_INACTIVE; sod[OPT_HIGHLIGHT_B].cap &= ~SANE_CAP_INACTIVE; sod[OPT_EXPOSURE_B].cap &= ~SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; case OPT_GAMMA_MODE: restore_gamma_options(sod, val); if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_GAMMA_BIND: restore_gamma_options(sod, val); if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_SHADOW: case OPT_SHADOW_R: case OPT_SHADOW_G: case OPT_SHADOW_B: if ( val[option].w >= val[option + 1].w ) { val[option + 1].w = val[option].w + 1; if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; } if ( val[option + 1].w >= val[option + 2].w ) val[option + 2].w = val[option + 1].w + 1; return SANE_STATUS_GOOD; case OPT_MIDTONE: case OPT_MIDTONE_R: case OPT_MIDTONE_G: case OPT_MIDTONE_B: if ( val[option].w <= val[option - 1].w ) { val[option - 1].w = val[option].w - 1; if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; } if ( val[option].w >= val[option + 1].w ) { val[option + 1].w = val[option].w + 1; if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_HIGHLIGHT: case OPT_HIGHLIGHT_R: case OPT_HIGHLIGHT_G: case OPT_HIGHLIGHT_B: if ( val[option].w <= val[option - 1].w ) { val[option - 1].w = val[option].w - 1; if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; } if ( val[option - 1].w <= val[option - 2].w ) val[option - 2].w = val[option - 1].w - 1; return SANE_STATUS_GOOD; case OPT_RESOLUTION_BIND: if ( ms->val[option].w == SANE_FALSE ) { ms->sod[OPT_Y_RESOLUTION].cap &= ~SANE_CAP_INACTIVE; } else { ms->sod[OPT_Y_RESOLUTION].cap |= SANE_CAP_INACTIVE; } if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_TOGGLELAMP: status = scsi_read_system_status(md, -1); if ( status != SANE_STATUS_GOOD ) return SANE_STATUS_IO_ERROR; md->status.flamp ^= 1; status = scsi_send_system_status(md, -1); if ( status != SANE_STATUS_GOOD ) return SANE_STATUS_IO_ERROR; return SANE_STATUS_GOOD; case OPT_AUTOADJUST: if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; if ( ms->val[option].w == SANE_FALSE ) ms->sod[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; else ms->sod[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; return SANE_STATUS_GOOD; case OPT_BALANCE_FW: val[OPT_BALANCE_R].w = SANE_FIX((uint8_t)( (float)mi->balance[0] / 2.55 ) ); val[OPT_BALANCE_G].w = SANE_FIX((uint8_t)( (float)mi->balance[1] / 2.55 ) ); val[OPT_BALANCE_B].w = SANE_FIX((uint8_t)( (float)mi->balance[2] / 2.55 ) ); if ( info ) *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; default: return SANE_STATUS_UNSUPPORTED; } #if 0 break; #endif default: DBG(1, "sane_control_option: Unsupported action %d\n", action); return SANE_STATUS_UNSUPPORTED; } } /*---------- sane_get_option_descriptor() ------------------------------------*/ const SANE_Option_Descriptor * sane_get_option_descriptor(SANE_Handle handle, SANE_Int n) { Microtek2_Scanner *ms = handle; DBG(255, "sane_get_option_descriptor: handle=%p, sod=%p, opt=%d\n", (void *) handle, (void *) ms->sod, n); if ( n < 0 || n >= NUM_OPTIONS ) { DBG(30, "sane_get_option_descriptor: invalid option %d\n", n); return NULL; } return &ms->sod[n]; } /*---------- restore_gamma_options() -----------------------------------------*/ static SANE_Status restore_gamma_options(SANE_Option_Descriptor *sod, Option_Value *val) { DBG(40, "restore_gamma_options: val=%p, sod=%p\n", (void *) val, (void *) sod); /* if we dont have a gamma table return immediately */ if ( ! val[OPT_GAMMA_MODE].s ) return SANE_STATUS_GOOD; if ( strcmp(val[OPT_MODE].s, MD_MODESTRING_COLOR) == 0 ) { sod[OPT_GAMMA_MODE].cap &= ~SANE_CAP_INACTIVE; if ( strcmp(val[OPT_GAMMA_MODE].s, MD_GAMMAMODE_LINEAR) == 0 ) { sod[OPT_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_B].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_B].cap |= SANE_CAP_INACTIVE; } else if ( strcmp(val[OPT_GAMMA_MODE].s, MD_GAMMAMODE_SCALAR) == 0 ) { sod[OPT_GAMMA_BIND].cap &= ~SANE_CAP_INACTIVE; if ( val[OPT_GAMMA_BIND].w == SANE_TRUE ) { sod[OPT_GAMMA_SCALAR].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_B].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_B].cap |= SANE_CAP_INACTIVE; } else { sod[OPT_GAMMA_SCALAR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_B].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_B].cap |= SANE_CAP_INACTIVE; } } else if ( strcmp(val[OPT_GAMMA_MODE].s, MD_GAMMAMODE_CUSTOM) == 0 ) { sod[OPT_GAMMA_BIND].cap &= ~SANE_CAP_INACTIVE; if ( val[OPT_GAMMA_BIND].w == SANE_TRUE ) { sod[OPT_GAMMA_CUSTOM].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_B].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_B].cap |= SANE_CAP_INACTIVE; } else { sod[OPT_GAMMA_CUSTOM].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_B].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_B].cap |= SANE_CAP_INACTIVE; } } } else if ( strcmp(val[OPT_MODE].s, MD_MODESTRING_GRAY) == 0 ) { sod[OPT_GAMMA_MODE].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_B].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_B].cap |= SANE_CAP_INACTIVE; if ( strcmp(val[OPT_GAMMA_MODE].s, MD_GAMMAMODE_LINEAR) == 0 ) { sod[OPT_GAMMA_SCALAR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM].cap |= SANE_CAP_INACTIVE; } else if ( strcmp(val[OPT_GAMMA_MODE].s, MD_GAMMAMODE_SCALAR) == 0 ) { sod[OPT_GAMMA_SCALAR].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM].cap |= SANE_CAP_INACTIVE; } else if ( strcmp(val[OPT_GAMMA_MODE].s, MD_GAMMAMODE_CUSTOM) == 0 ) { sod[OPT_GAMMA_CUSTOM].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR].cap |= SANE_CAP_INACTIVE; } } else if ( strcmp(val[OPT_MODE].s, MD_MODESTRING_HALFTONE) == 0 || strcmp(val[OPT_MODE].s, MD_MODESTRING_LINEART) == 0 ) { /* reset gamma to default */ if ( val[OPT_GAMMA_MODE].s ) free((void *) val[OPT_GAMMA_MODE].s); val[OPT_GAMMA_MODE].s = strdup(MD_GAMMAMODE_LINEAR); sod[OPT_GAMMA_MODE].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_SCALAR_B].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_CUSTOM_B].cap |= SANE_CAP_INACTIVE; } else DBG(1, "restore_gamma_options: unknown mode %s\n", val[OPT_MODE].s); return SANE_STATUS_GOOD; } /*---------- calculate_sane_params() -----------------------------------------*/ static SANE_Status calculate_sane_params(Microtek2_Scanner *ms) { Microtek2_Device *md; Microtek2_Info *mi; DBG(30, "calculate_sane_params: ms=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; if ( ! mi->onepass && ms->mode == MS_MODE_COLOR ) { if ( ms->current_pass == 1 ) ms->params.format = SANE_FRAME_RED; else if ( ms->current_pass == 2 ) ms->params.format = SANE_FRAME_GREEN; else if ( ms->current_pass == 3 ) ms->params.format = SANE_FRAME_BLUE; else { DBG(1, "calculate_sane_params: invalid pass number %d\n", ms->current_pass); return SANE_STATUS_IO_ERROR; } } else if ( mi->onepass && ms->mode == MS_MODE_COLOR ) ms->params.format = SANE_FRAME_RGB; else ms->params.format = SANE_FRAME_GRAY; if ( ! mi->onepass && ms->mode == MS_MODE_COLOR && ms->current_pass < 3 ) ms->params.last_frame = SANE_FALSE; else ms->params.last_frame = SANE_TRUE; ms->params.lines = ms->src_remaining_lines; ms->params.pixels_per_line = ms->ppl; ms->params.bytes_per_line = ms->real_bpl; ms->params.depth = ms->bits_per_pixel_out; return SANE_STATUS_GOOD; } /*---------- get_calib_params() ----------------------------------------------*/ static void get_calib_params(Microtek2_Scanner *ms) { Microtek2_Device *md; Microtek2_Info *mi; DBG(30, "get_calib_params: handle=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; if ( md->model_flags & MD_CALIB_DIVISOR_600 ) { if ( ms->x_resolution_dpi <= 600 ) mi->calib_divisor = 2; else mi->calib_divisor = 1; } DBG(30, "Calib Divisor: %d\n", mi->calib_divisor); ms->x_resolution_dpi = mi->opt_resolution / mi->calib_divisor; ms->y_resolution_dpi = mi->opt_resolution / 5; /* ignore dust particles */ ms->x1_dots = 0; ms->y1_dots = mi->calib_white; ms->width_dots = mi->geo_width; if ( md->shading_length != 0 ) ms->height_dots = md->shading_length; else ms->height_dots = mi->calib_space; ms->mode = MS_MODE_COLOR; if ( mi->depth & MI_HASDEPTH_16 ) ms->depth = 16; else if ( mi->depth & MI_HASDEPTH_14 ) ms->depth = 14; else if ( mi->depth & MI_HASDEPTH_12 ) ms->depth = 12; else if ( mi->depth & MI_HASDEPTH_10 ) ms->depth = 10; else ms->depth = 8; ms->stay = 0; if ( mi->calib_space < 10 ) ms->stay = 1; ms->rawdat = 1; ms->quality = 1; ms->fastscan = 0; /* ms->scan_source = md->scan_source; */ ms->scan_source = 0; ms->brightness_m = ms->brightness_r = ms->brightness_g = ms->brightness_b = 128; ms->exposure_m = ms->exposure_r = ms->exposure_g = ms->exposure_b = 0; ms->contrast_m = ms->contrast_r = ms->contrast_g = ms->contrast_b = 128; ms->shadow_m = ms->shadow_r = ms->shadow_g = ms->shadow_b = 0; ms->midtone_m = ms->midtone_r = ms->midtone_g = ms->midtone_b = 128; ms->highlight_m = ms->highlight_r = ms->highlight_g = ms->highlight_b = 255; return; } /*---------- get_scan_parameters () ------------------------------------------*/ static SANE_Status get_scan_parameters(Microtek2_Scanner *ms) { Microtek2_Device *md; Microtek2_Info *mi; double dpm; /* dots per millimeter */ int x2_dots; int y2_dots; int i; DBG(30, "get_scan_parameters: handle=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; get_scan_mode_and_depth(ms, &ms->mode, &ms->depth, &ms->bits_per_pixel_in, &ms->bits_per_pixel_out); /* get the scan_source */ if ( strcmp(ms->val[OPT_SOURCE].s, MD_SOURCESTRING_FLATBED) == 0 ) ms->scan_source = MS_SOURCE_FLATBED; else if ( strcmp(ms->val[OPT_SOURCE].s, MD_SOURCESTRING_ADF) == 0 ) ms->scan_source = MS_SOURCE_ADF; else if ( strcmp(ms->val[OPT_SOURCE].s, MD_SOURCESTRING_TMA) == 0 ) ms->scan_source = MS_SOURCE_TMA; else if ( strcmp(ms->val[OPT_SOURCE].s, MD_SOURCESTRING_STRIPE) == 0 ) ms->scan_source = MS_SOURCE_STRIPE; else if ( strcmp(ms->val[OPT_SOURCE].s, MD_SOURCESTRING_SLIDE) == 0 ) ms->scan_source = MS_SOURCE_SLIDE; /* enable/disable backtracking */ if ( ms->val[OPT_DISABLE_BACKTRACK].w == SANE_TRUE ) ms->no_backtracking = 1; else ms->no_backtracking = 0; /* turn off the lamp during a scan */ if ( ms->val[OPT_LIGHTLID35].w == SANE_TRUE ) ms->lightlid35 = 1; else ms->lightlid35 = 0; /* automatic adjustment of threshold */ if ( ms->val[OPT_AUTOADJUST].w == SANE_TRUE) ms->auto_adjust = 1; else ms->auto_adjust = 0; /* color calibration by backend */ if ( ms->val[OPT_CALIB_BACKEND].w == SANE_TRUE ) ms->calib_backend = 1; else ms->calib_backend = 0; /* if halftone mode select halftone pattern */ if ( ms->mode == MS_MODE_HALFTONE ) { i = 0; while ( strcmp(md->halftone_mode_list[i], ms->val[OPT_HALFTONE].s) ) ++i; ms->internal_ht_index = i; } /* if lineart get the value for threshold */ if ( ms->mode == MS_MODE_LINEART || ms->mode == MS_MODE_LINEARTFAKE) ms->threshold = (uint8_t) ms->val[OPT_THRESHOLD].w; else ms->threshold = (uint8_t) M_THRESHOLD_DEFAULT; DBG(30, "get_scan_parameters: mode=%d, depth=%d, bpp_in=%d, bpp_out=%d\n", ms->mode, ms->depth, ms->bits_per_pixel_in, ms->bits_per_pixel_out); /* calculate positions, width and height in dots */ /* check for impossible values */ /* ensure a minimum scan area of 10 x 10 pixels */ dpm = (double) mi->opt_resolution / MM_PER_INCH; ms->x1_dots = (SANE_Int) ( SANE_UNFIX(ms->val[OPT_TL_X].w) * dpm + 0.5 ); if ( ms->x1_dots > ( mi->geo_width - 10 ) ) ms->x1_dots = ( mi->geo_width - 10 ); ms->y1_dots = (SANE_Int) ( SANE_UNFIX(ms->val[OPT_TL_Y].w) * dpm + 0.5 ); if ( ms->y1_dots > ( mi->geo_height - 10 ) ) ms->y1_dots = ( mi->geo_height - 10 ); x2_dots = (int) ( SANE_UNFIX(ms->val[OPT_BR_X].w) * dpm + 0.5 ); if ( x2_dots >= mi->geo_width ) x2_dots = mi->geo_width - 1; y2_dots = (int) ( SANE_UNFIX(ms->val[OPT_BR_Y].w) * dpm + 0.5 ); if ( y2_dots >= mi->geo_height ) y2_dots = mi->geo_height - 1; ms->width_dots = x2_dots - ms->x1_dots; if ( md->model_flags && MD_OFFSET_2 ) /* this firmware has problems with */ if ( ( ms->width_dots % 2 ) == 1 ) /* odd pixel numbers */ ms->width_dots -= 1; if ( ms->width_dots < 10 ) ms->width_dots = 10; ms->height_dots = y2_dots - ms->y1_dots; if ( ms->height_dots < 10 ) ms->height_dots = 10; /*test!!!*/ /* ms->y1_dots -= 50;*/ /* take scanning direction into account */ if ((mi->direction & MI_DATSEQ_RTOL) == 1) ms->x1_dots = mi->geo_width - ms->x1_dots - ms->width_dots; if ( ms->val[OPT_RESOLUTION_BIND].w == SANE_TRUE ) { ms->x_resolution_dpi = (SANE_Int) (SANE_UNFIX(ms->val[OPT_RESOLUTION].w) + 0.5); ms->y_resolution_dpi = (SANE_Int) (SANE_UNFIX(ms->val[OPT_RESOLUTION].w) + 0.5); } else { ms->x_resolution_dpi = (SANE_Int) (SANE_UNFIX(ms->val[OPT_RESOLUTION].w) + 0.5); ms->y_resolution_dpi = (SANE_Int) (SANE_UNFIX(ms->val[OPT_Y_RESOLUTION].w) + 0.5); } if ( ms->x_resolution_dpi < 10 ) ms->x_resolution_dpi = 10; if ( ms->y_resolution_dpi < 10 ) ms->y_resolution_dpi = 10; DBG(30, "get_scan_parameters: yres=%d, x1=%d, width=%d, y1=%d, height=%d\n", ms->y_resolution_dpi, ms->x1_dots, ms->width_dots, ms->y1_dots, ms->height_dots); /* Preview mode */ if ( ms->val[OPT_PREVIEW].w == SANE_TRUE ) { ms->fastscan = SANE_TRUE; ms->quality = SANE_FALSE; } else { ms->fastscan = SANE_FALSE; ms->quality = SANE_TRUE; } ms->rawdat = 0; /* brightness, contrast, values 1,..,255 */ ms->brightness_m = (uint8_t) (SANE_UNFIX(ms->val[OPT_BRIGHTNESS].w) / SANE_UNFIX(md->percentage_range.max) * 254.0) + 1; ms->brightness_r = ms->brightness_g = ms->brightness_b = ms->brightness_m; ms->contrast_m = (uint8_t) (SANE_UNFIX(ms->val[OPT_CONTRAST].w) / SANE_UNFIX(md->percentage_range.max) * 254.0) + 1; ms->contrast_r = ms->contrast_g = ms->contrast_b = ms->contrast_m; /* shadow, midtone, highlight, exposure */ ms->shadow_m = (uint8_t) ms->val[OPT_SHADOW].w; ms->shadow_r = (uint8_t) ms->val[OPT_SHADOW_R].w; ms->shadow_g = (uint8_t) ms->val[OPT_SHADOW_G].w; ms->shadow_b = (uint8_t) ms->val[OPT_SHADOW_B].w; ms->midtone_m = (uint8_t) ms->val[OPT_MIDTONE].w; ms->midtone_r = (uint8_t) ms->val[OPT_MIDTONE_R].w; ms->midtone_g = (uint8_t) ms->val[OPT_MIDTONE_G].w; ms->midtone_b = (uint8_t) ms->val[OPT_MIDTONE_B].w; ms->highlight_m = (uint8_t) ms->val[OPT_HIGHLIGHT].w; ms->highlight_r = (uint8_t) ms->val[OPT_HIGHLIGHT_R].w; ms->highlight_g = (uint8_t) ms->val[OPT_HIGHLIGHT_G].w; ms->highlight_b = (uint8_t) ms->val[OPT_HIGHLIGHT_B].w; ms->exposure_m = (uint8_t) (ms->val[OPT_EXPOSURE].w / 2); ms->exposure_r = (uint8_t) (ms->val[OPT_EXPOSURE_R].w / 2); ms->exposure_g = (uint8_t) (ms->val[OPT_EXPOSURE_G].w / 2); ms->exposure_b = (uint8_t) (ms->val[OPT_EXPOSURE_B].w / 2); ms->gamma_mode = strdup( (char *) ms->val[OPT_GAMMA_MODE].s); ms->balance[0] = (uint8_t) (SANE_UNFIX(ms->val[OPT_BALANCE_R].w)); ms->balance[1] = (uint8_t) (SANE_UNFIX(ms->val[OPT_BALANCE_G].w)); ms->balance[2] = (uint8_t) (SANE_UNFIX(ms->val[OPT_BALANCE_B].w)); DBG(255, "get_scan_parameters:ms->balance[0]=%d,[1]=%d,[2]=%d\n", ms->balance[0], ms->balance[1], ms->balance[2]); return SANE_STATUS_GOOD; } /*---------- get_scan_mode_and_depth() ---------------------------------------*/ static SANE_Status get_scan_mode_and_depth(Microtek2_Scanner *ms, int *mode, int *depth, int *bits_per_pixel_in, int *bits_per_pixel_out) { /* This function translates the strings for the possible modes and */ /* bitdepth into a more conveniant format as needed for SET WINDOW. */ /* bits_per_pixel is the number of bits per color one pixel needs */ /* when transferred from the scanner, bits_perpixel_out is the */ /* number of bits per color one pixel uses when transferred to the */ /* frontend. These may be different. For example, with a depth of 4 */ /* two pixels per byte are transferred from the scanner, but only one */ /* pixel per byte is transferred to the frontend. */ /* If lineart_fake is set to !=0, we need the parameters for a */ /* grayscale scan, because the scanner has no lineart mode */ Microtek2_Device *md; Microtek2_Info *mi; DBG(30, "get_scan_mode_and_depth: handle=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; if ( strcmp(ms->val[OPT_MODE].s, MD_MODESTRING_COLOR) == 0 ) *mode = MS_MODE_COLOR; else if ( strcmp(ms->val[OPT_MODE].s, MD_MODESTRING_GRAY) == 0 ) *mode = MS_MODE_GRAY; else if ( strcmp(ms->val[OPT_MODE].s, MD_MODESTRING_HALFTONE) == 0) *mode = MS_MODE_HALFTONE; else if ( strcmp(ms->val[OPT_MODE].s, MD_MODESTRING_LINEART) == 0 ) { if ( MI_LINEART_NONE(mi->scanmode) || ms->val[OPT_AUTOADJUST].w == SANE_TRUE || md->model_flags & MD_READ_CONTROL_BIT) *mode = MS_MODE_LINEARTFAKE; else *mode = MS_MODE_LINEART; } else { DBG(1, "get_scan_mode_and_depth: Unknown mode %s\n", ms->val[OPT_MODE].s); return SANE_STATUS_INVAL; } if ( strcmp(ms->val[OPT_MODE].s, MD_MODESTRING_COLOR) == 0 || strcmp(ms->val[OPT_MODE].s, MD_MODESTRING_GRAY) == 0 ) { if ( ms->val[OPT_BITDEPTH].w == MD_DEPTHVAL_16 ) { *depth = 16; *bits_per_pixel_in = *bits_per_pixel_out = 16; } else if ( ms->val[OPT_BITDEPTH].w == MD_DEPTHVAL_14 ) { *depth = 14; *bits_per_pixel_in = *bits_per_pixel_out = 16; } else if ( ms->val[OPT_BITDEPTH].w == MD_DEPTHVAL_12 ) { *depth = 12; *bits_per_pixel_in = *bits_per_pixel_out = 16; } else if ( ms->val[OPT_BITDEPTH].w == MD_DEPTHVAL_10 ) { *depth = 10; *bits_per_pixel_in = *bits_per_pixel_out = 16; } else if ( ms->val[OPT_BITDEPTH].w == MD_DEPTHVAL_8 ) { *depth = 8; *bits_per_pixel_in = *bits_per_pixel_out = 8; } else if ( ms->val[OPT_MODE].w == MD_DEPTHVAL_4 ) { *depth = 4; *bits_per_pixel_in = 4; *bits_per_pixel_out = 8; } } else if ( strcmp(ms->val[OPT_MODE].s, MD_MODESTRING_HALFTONE) == 0 ) { *depth = 1; *bits_per_pixel_in = *bits_per_pixel_out = 1; } else /* lineart */ { *bits_per_pixel_out = 1; if ( *mode == MS_MODE_LINEARTFAKE ) { *depth = 8; *bits_per_pixel_in = 8; } else { *depth = 1; *bits_per_pixel_in = 1; } } #if 0 if ( ms->val[OPT_PREVIEW].w == SANE_TRUE ) { if ( *depth > 8 ) { *depth = 8; *bits_per_pixel_in = *bits_per_pixel_out = 8; } } #endif DBG(30, "get_scan_mode_and_depth: mode=%d, depth=%d," " bits_pp_in=%d, bits_pp_out=%d, preview=%d\n", *mode, *depth, *bits_per_pixel_in, *bits_per_pixel_out, ms->val[OPT_PREVIEW].w); return SANE_STATUS_GOOD; } /*---------- scsi_wait_for_image() -------------------------------------------*/ static SANE_Status scsi_wait_for_image(Microtek2_Scanner *ms) { int retry = 60; SANE_Status status; DBG(30, "scsi_wait_for_image: ms=%p\n", (void *) ms); while ( retry-- > 0 ) { status = scsi_read_image_status(ms); if (status == SANE_STATUS_DEVICE_BUSY ) { sleep(1); continue; } if ( status == SANE_STATUS_GOOD ) return status; /* status != GOOD && != BUSY */ DBG(1, "scsi_wait_for_image: '%s'\n", sane_strstatus(status)); return status; } /* BUSY after n retries */ DBG(1, "scsi_wait_for_image: '%s'\n", sane_strstatus(status)); return status; } /*---------- scsi_read_gamma() -----------------------------------------------*/ /* currently not used */ /* static SANE_Status scsi_read_gamma(Microtek2_Scanner *ms, int color) { uint8_t readgamma[RG_CMD_L]; uint8_t result[3072]; size_t size; SANE_Bool endiantype; SANE_Status status; RG_CMD(readgamma); ENDIAN_TYPE(endiantype); RG_PCORMAC(readgamma, endiantype); RG_COLOR(readgamma, color); RG_WORD(readgamma, ( ms->dev->lut_entry_size == 1 ) ? 0 : 1); RG_TRANSFERLENGTH(readgamma, (color == 3 ) ? 3072 : 1024); dump_area(readgamma, 10, "ReadGamma"); size = sizeof(result); status = sanei_scsi_cmd(ms->sfd, readgamma, sizeof(readgamma), result, &size); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_read_gamma: (L,R) read_gamma failed: status '%s'\n", sane_strstatus(status)); return status; } dump_area(result, 3072, "Result"); return SANE_STATUS_GOOD; } */ /*---------- scsi_send_gamma() -----------------------------------------------*/ static SANE_Status scsi_send_gamma(Microtek2_Scanner *ms) { SANE_Bool endiantype; SANE_Status status; size_t size; uint8_t *cmd, color; DBG(30, "scsi_send_gamma: pos=%p, size=%d, word=%d, color=%d\n", ms->gamma_table, ms->lut_size_bytes, ms->word, ms->current_color); if ( ( 3 * ms->lut_size_bytes ) <= 0xffff ) /*send Gamma with one command*/ { cmd = (uint8_t *) alloca(SG_CMD_L + 3 * ms->lut_size_bytes); if ( cmd == NULL ) { DBG(1, "scsi_send_gamma: Couldn't get buffer for gamma table\n"); return SANE_STATUS_IO_ERROR; } SG_SET_CMD(cmd); ENDIAN_TYPE(endiantype) SG_SET_PCORMAC(cmd, endiantype); SG_SET_COLOR(cmd, ms->current_color); SG_SET_WORD(cmd, ms->word); SG_SET_TRANSFERLENGTH(cmd, 3 * ms->lut_size_bytes); memcpy(cmd + SG_CMD_L, ms->gamma_table, 3 * ms->lut_size_bytes); size = 3 * ms->lut_size_bytes; if ( md_dump >= 2 ) dump_area2(cmd, SG_CMD_L, "sendgammacmd"); if ( md_dump >= 3 ) dump_area2(cmd + SG_CMD_L, size, "sendgammadata"); status = sanei_scsi_cmd(ms->sfd, cmd, size + SG_CMD_L, NULL, 0); if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_send_gamma: '%s'\n", sane_strstatus(status)); } else /* send gamma with 3 commands, one for each color */ { for ( color = 0; color < 3; color++ ) { cmd = (uint8_t *) alloca(SG_CMD_L + ms->lut_size_bytes); if ( cmd == NULL ) { DBG(1, "scsi_send_gamma: Couldn't get buffer for gamma table\n"); return SANE_STATUS_IO_ERROR; } SG_SET_CMD(cmd); ENDIAN_TYPE(endiantype) SG_SET_PCORMAC(cmd, endiantype); SG_SET_COLOR(cmd, color); SG_SET_WORD(cmd, ms->word); SG_SET_TRANSFERLENGTH(cmd, ms->lut_size_bytes); memcpy(cmd + SG_CMD_L, ms->gamma_table + color * ms->lut_size_bytes, ms->lut_size_bytes); size = ms->lut_size_bytes; if ( md_dump >= 2 ) dump_area2(cmd, SG_CMD_L, "sendgammacmd"); if ( md_dump >= 3 ) dump_area2(cmd + SG_CMD_L, size, "sendgammadata"); status = sanei_scsi_cmd(ms->sfd, cmd, size + SG_CMD_L, NULL, 0); if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_send_gamma: '%s'\n", sane_strstatus(status)); } } return status; } /*---------- scsi_inquiry() --------------------------------------------------*/ static SANE_Status scsi_inquiry(Microtek2_Info *mi, char *device) { SANE_Status status; uint8_t cmd[INQ_CMD_L]; uint8_t *result; uint8_t inqlen; size_t size; int sfd; DBG(30, "scsi_inquiry: mi=%p, device='%s'\n", (void *) mi, device); status = sanei_scsi_open(device, &sfd, scsi_sense_handler, 0); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_inquiry: '%s'\n", sane_strstatus(status)); return status; } INQ_CMD(cmd); INQ_SET_ALLOC(cmd, INQ_ALLOC_L); result = (uint8_t *) alloca(INQ_ALLOC_L); if ( result == NULL ) { DBG(1, "scsi_inquiry: malloc failed\n"); sanei_scsi_close(sfd); return SANE_STATUS_NO_MEM; } size = INQ_ALLOC_L; status = sanei_scsi_cmd(sfd, cmd, sizeof(cmd), result, &size); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_inquiry: '%s'\n", sane_strstatus(status)); sanei_scsi_close(sfd); return status; } INQ_GET_INQLEN(inqlen, result); INQ_SET_ALLOC(cmd, inqlen + INQ_ALLOC_L); result = alloca(inqlen + INQ_ALLOC_L); if ( result == NULL ) { DBG(1, "scsi_inquiry: malloc failed\n"); sanei_scsi_close(sfd); return SANE_STATUS_NO_MEM; } size = inqlen + INQ_ALLOC_L; if (md_dump >= 2 ) dump_area2(cmd, sizeof(cmd), "inquiry"); status = sanei_scsi_cmd(sfd, cmd, sizeof(cmd), result, &size); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_inquiry: cmd '%s'\n", sane_strstatus(status)); sanei_scsi_close(sfd); return status; } sanei_scsi_close(sfd); if (md_dump >= 2 ) { dump_area2((uint8_t *) result, size, "inquiryresult"); dump_area((uint8_t *) result, size, "inquiryresult"); } /* copy results */ INQ_GET_QUAL(mi->device_qualifier, result); INQ_GET_DEVT(mi->device_type, result); INQ_GET_VERSION(mi->scsi_version, result); INQ_GET_VENDOR(mi->vendor, (char *)result); INQ_GET_MODEL(mi->model, (char *)result); INQ_GET_REV(mi->revision, (char *)result); INQ_GET_MODELCODE(mi->model_code, result); return SANE_STATUS_GOOD; } /*---------- scsi_read_attributes() ------------------------------------------*/ static SANE_Status scsi_read_attributes(Microtek2_Info *pmi, char *device, uint8_t scan_source) { SANE_Status status; Microtek2_Info *mi; uint8_t readattributes[RSA_CMD_L]; uint8_t result[RSA_TRANSFERLENGTH]; size_t size; int sfd; mi = &pmi[scan_source]; DBG(30, "scsi_read_attributes: mi=%p, device='%s', source=%d\n", (void *) mi, device, scan_source); RSA_CMD(readattributes); RSA_SETMEDIA(readattributes, scan_source); status = sanei_scsi_open(device, &sfd, scsi_sense_handler, 0); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_read_attributes: open '%s'\n", sane_strstatus(status)); return status; } if (md_dump >= 2 ) dump_area2(readattributes, sizeof(readattributes), "scannerattributes"); size = sizeof(result); status = sanei_scsi_cmd(sfd, readattributes, sizeof(readattributes), result, &size); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_read_attributes: cmd '%s'\n", sane_strstatus(status)); sanei_scsi_close(sfd); return status; } sanei_scsi_close(sfd); /* The X6 appears to lie about the data format for a TMA */ if ( (&pmi[0])->model_code == 0x91 ) result[0] &= 0xfd; /* default value for calib_divisor ... bit49?? */ mi->calib_divisor = 1; /* 9600XL */ if ( (&pmi[0])->model_code == 0xde ) mi->calib_divisor = 2; /* 6400XL has problems in lineart mode*/ if ( (&pmi[0])->model_code == 0x89 ) result[13] &= 0xfe; /* simulate no lineart */ #if 0 result[13] &= 0xfe; /* simulate no lineart */ #endif /* copy all the stuff into the info structure */ RSA_COLOR(mi->color, result); RSA_ONEPASS(mi->onepass, result); RSA_SCANNERTYPE(mi->scanner_type, result); RSA_FEPROM(mi->feprom, result); RSA_DATAFORMAT(mi->data_format, result); RSA_COLORSEQUENCE(mi->color_sequence, result); RSA_NIS(mi->new_image_status, result); RSA_DATSEQ(mi->direction, result); RSA_CCDGAP(mi->ccd_gap, result); RSA_MAX_XRESOLUTION(mi->max_xresolution, result); RSA_MAX_YRESOLUTION(mi->max_yresolution, result); RSA_GEOWIDTH(mi->geo_width, result); RSA_GEOHEIGHT(mi->geo_height, result); RSA_OPTRESOLUTION(mi->opt_resolution, result); RSA_DEPTH(mi->depth, result); /* The X12USL doesn't say that it has 14bit */ if ( (&pmi[0])->model_code == 0xb0 ) mi->depth |= MI_HASDEPTH_14; RSA_SCANMODE(mi->scanmode, result); RSA_CCDPIXELS(mi->ccd_pixels, result); RSA_LUTCAP(mi->lut_cap, result); RSA_DNLDPTRN(mi->has_dnldptrn, result); RSA_GRAINSLCT(mi->grain_slct, result); RSA_SUPPOPT(mi->option_device, result); RSA_CALIBWHITE(mi->calib_white, result); RSA_CALIBSPACE(mi->calib_space, result); RSA_NLENS(mi->nlens, result); RSA_NWINDOWS(mi->nwindows, result); RSA_SHTRNSFEREQU(mi->shtrnsferequ, result); RSA_SCNBTTN(mi->scnbuttn, result); RSA_BUFTYPE(mi->buftype, result); RSA_REDBALANCE(mi->balance[0], result); RSA_GREENBALANCE(mi->balance[1], result); RSA_BLUEBALANCE(mi->balance[2], result); RSA_APSMAXFRAMES(mi->aps_maxframes, result); if (md_dump >= 2 ) dump_area2((uint8_t *) result, sizeof(result), "scannerattributesresults"); if ( md_dump >= 1 && md_dump_clear ) dump_attributes(mi); return SANE_STATUS_GOOD; } /*---------- scsi_read_control_bits() ----------------------------------------*/ static SANE_Status scsi_read_control_bits(Microtek2_Scanner *ms) { SANE_Status status; uint8_t cmd[RCB_CMD_L]; uint32_t byte; int bit; int count_1s; 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); RCB_SET_CMD(cmd); RCB_SET_LENGTH(cmd, ms->n_control_bytes); if ( md_dump >= 2) dump_area2(cmd, RCB_CMD_L, "readcontrolbits"); status = sanei_scsi_cmd(ms->sfd, cmd, sizeof(cmd), ms->control_bytes, &ms->n_control_bytes); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_read_control_bits: cmd '%s'\n", sane_strstatus(status)); return status; } if ( md_dump >= 2) dump_area2(ms->control_bytes, ms->n_control_bytes, "readcontrolbitsresult"); count_1s = 0; for ( byte = 0; byte < ms->n_control_bytes; byte++ ) { for ( bit = 0; bit < 8; bit++ ) { if ( (ms->control_bytes[byte] >> bit) & 0x01 ) ++count_1s; } } DBG(20, "read_control_bits: number of 1's in controlbytes: %d\n", count_1s); return SANE_STATUS_GOOD; } /*---------- scsi_set_window() -----------------------------------------------*/ static SANE_Status scsi_set_window(Microtek2_Scanner *ms, int n) { /* n windows, not yet */ /* implemented */ SANE_Status status; uint8_t *setwindow; int size; DBG(30, "scsi_set_window: ms=%p, wnd=%d\n", (void *) ms, n); size = SW_CMD_L + SW_HEADER_L + n * SW_BODY_L; setwindow = (uint8_t *) malloc(size); DBG(100, "scsi_set_window: setwindow= %p, malloc'd %d Bytes\n", setwindow, size); if ( setwindow == NULL ) { DBG(1, "scsi_set_window: malloc for setwindow failed\n"); return SANE_STATUS_NO_MEM; } memset(setwindow, 0, size); SW_CMD(setwindow); SW_PARAM_LENGTH(setwindow, SW_HEADER_L + n * SW_BODY_L); SW_WNDDESCLEN(setwindow + SW_HEADER_P, SW_WNDDESCVAL); #define POS (setwindow + SW_BODY_P(n-1)) SW_WNDID(POS, n-1); SW_XRESDPI(POS, ms->x_resolution_dpi); SW_YRESDPI(POS, ms->y_resolution_dpi); SW_XPOSTL(POS, ms->x1_dots); SW_YPOSTL(POS, ms->y1_dots); SW_WNDWIDTH(POS, ms->width_dots); SW_WNDHEIGHT(POS, ms->height_dots); SW_THRESHOLD(POS, ms->threshold); SW_IMGCOMP(POS, ms->mode); SW_BITSPERPIXEL(POS, ms->depth); SW_EXTHT(POS, ms->use_external_ht); SW_INTHTINDEX(POS, ms->internal_ht_index); SW_RIF(POS, 1); SW_LENS(POS, 0); /* ???? */ SW_INFINITE(POS, 0); SW_STAY(POS, ms->stay); SW_RAWDAT(POS, ms->rawdat); SW_QUALITY(POS, ms->quality); SW_FASTSCAN(POS, ms->fastscan); SW_MEDIA(POS, ms->scan_source); SW_BRIGHTNESS_M(POS, ms->brightness_m); SW_CONTRAST_M(POS, ms->contrast_m); SW_EXPOSURE_M(POS, ms->exposure_m); SW_SHADOW_M(POS, ms->shadow_m); SW_MIDTONE_M(POS, ms->midtone_m); SW_HIGHLIGHT_M(POS, ms->highlight_m); /* the following properties are only referenced if it's a color scan */ /* but I guess they don't matter at a gray scan */ SW_BRIGHTNESS_R(POS, ms->brightness_r); SW_CONTRAST_R(POS, ms->contrast_r); SW_EXPOSURE_R(POS, ms->exposure_r); SW_SHADOW_R(POS, ms->shadow_r); SW_MIDTONE_R(POS, ms->midtone_r); SW_HIGHLIGHT_R(POS, ms->highlight_r); SW_BRIGHTNESS_G(POS, ms->brightness_g); SW_CONTRAST_G(POS, ms->contrast_g); SW_EXPOSURE_G(POS, ms->exposure_g); SW_SHADOW_G(POS, ms->shadow_g); SW_MIDTONE_G(POS, ms->midtone_g); SW_HIGHLIGHT_G(POS, ms->highlight_g); SW_BRIGHTNESS_B(POS, ms->brightness_b); SW_CONTRAST_B(POS, ms->contrast_b); SW_EXPOSURE_B(POS, ms->exposure_b); SW_SHADOW_B(POS, ms->shadow_b); SW_MIDTONE_B(POS, ms->midtone_b); SW_HIGHLIGHT_B(POS, ms->highlight_b); if ( md_dump >= 2 ) { dump_area2(setwindow, 10, "setwindowcmd"); dump_area2(setwindow + 10 ,8 , "setwindowheader"); dump_area2(setwindow + 18 ,61 , "setwindowbody"); } status = sanei_scsi_cmd(ms->sfd, setwindow, size, NULL, 0); if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_set_window: '%s'\n", sane_strstatus(status)); DBG(100, "scsi_set_window: free setwindow at %p\n", setwindow); free((void *) setwindow); return status; } /*---------- scsi_read_image_info() ------------------------------------------*/ static SANE_Status scsi_read_image_info(Microtek2_Scanner *ms) { uint8_t cmd[RII_CMD_L]; uint8_t result[RII_RESULT_L]; size_t size; SANE_Status status; Microtek2_Device *md; md = ms->dev; DBG(30, "scsi_read_image_info: ms=%p\n", (void *) ms); RII_SET_CMD(cmd); if ( md_dump >= 2) dump_area2(cmd, RII_CMD_L, "readimageinfo"); size = sizeof(result); status = sanei_scsi_cmd(ms->sfd, cmd, sizeof(cmd), result, &size); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_read_image_info: '%s'\n", sane_strstatus(status)); return status; } if ( md_dump >= 2) dump_area2(result, size, "readimageinforesult"); /* The V300 returns some values in only two bytes */ if ( !(md->revision==2.70) && (md->model_flags & MD_RII_TWO_BYTES) ) { RII_GET_V300_WIDTHPIXEL(ms->ppl, result); RII_GET_V300_WIDTHBYTES(ms->bpl, result); RII_GET_V300_HEIGHTLINES(ms->src_remaining_lines, result); RII_GET_V300_REMAINBYTES(ms->remaining_bytes, result); } else { RII_GET_WIDTHPIXEL(ms->ppl, result); RII_GET_WIDTHBYTES(ms->bpl, result); RII_GET_HEIGHTLINES(ms->src_remaining_lines, result); RII_GET_REMAINBYTES(ms->remaining_bytes, result); } DBG(30, "scsi_read_image_info: ppl=%d, bpl=%d, lines=%d, remain=%d\n", ms->ppl, ms->bpl, ms->src_remaining_lines, ms->remaining_bytes); return SANE_STATUS_GOOD; } /*---------- scsi_read_image() -----------------------------------------------*/ static SANE_Status scsi_read_image(Microtek2_Scanner *ms, uint8_t *buffer, int bytes_per_pixel) { uint8_t cmd[RI_CMD_L]; SANE_Bool endiantype; SANE_Status status; size_t size; size_t i; uint8_t tmp; DBG(30, "scsi_read_image: ms=%p, buffer=%p\n", (void *) ms, buffer); ENDIAN_TYPE(endiantype) RI_SET_CMD(cmd); RI_SET_PCORMAC(cmd, endiantype); RI_SET_COLOR(cmd, ms->current_read_color); RI_SET_TRANSFERLENGTH(cmd, ms->transfer_length); DBG(30, "scsi_read_image: transferlength=%d\n", ms->transfer_length); if ( md_dump >= 2 ) dump_area2(cmd, RI_CMD_L, "readimagecmd"); size = ms->transfer_length; status = sanei_scsi_cmd(ms->sfd, cmd, sizeof(cmd), buffer, &size); if ( buffer && ( ms->dev->model_flags & MD_PHANTOM_C6 ) && endiantype ) { switch(bytes_per_pixel) { case 1: break; case 2: for ( i = 1; i < size; i += 2 ) { tmp = buffer[i-1]; buffer[i-1] = buffer[i]; buffer[i] = tmp; } break; default: DBG(1, "scsi_read_image: Unexpected bytes_per_pixel=%d\n", bytes_per_pixel); } } if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_read_image: '%s'\n", sane_strstatus(status)); if ( md_dump > 3 ) dump_area2(buffer, ms->transfer_length, "readimageresult"); return status; } /*---------- scsi_read_image_status() ----------------------------------------*/ static SANE_Status scsi_read_image_status(Microtek2_Scanner *ms) { Microtek2_Device *md; Microtek2_Info *mi; uint8_t cmd[RIS_CMD_L]; uint8_t dummy; size_t dummy_length; SANE_Status status; SANE_Bool endian_type; md = ms->dev; mi = &md->info[md->scan_source]; DBG(30, "scsi_read_image_status: ms=%p\n", (void *) ms); ENDIAN_TYPE(endian_type) RIS_SET_CMD(cmd); RIS_SET_PCORMAC(cmd, endian_type); RIS_SET_COLOR(cmd, ms->current_read_color); /* mi->new_image_status = SANE_TRUE; */ /* for testing*/ if ( mi->new_image_status == SANE_TRUE ) { DBG(30, "scsi_read_image_status: use new image status \n"); dummy_length = 1; cmd[8] = 1; } else { DBG(30, "scsi_read_image_status: use old image status \n"); dummy_length = 0; cmd[8] = 0; } if ( md_dump >= 2 ) dump_area2(cmd, sizeof(cmd), "readimagestatus"); status = sanei_scsi_cmd(ms->sfd, cmd, sizeof(cmd), &dummy, &dummy_length); if ( mi->new_image_status == SANE_TRUE ) { if ( dummy == 0 ) status = SANE_STATUS_GOOD; else status = SANE_STATUS_DEVICE_BUSY; } /* For some (X6USB) scanner We say we are going to try to read 1 byte of data (as recommended in the Microtek SCSI command documentation under "New Image Status") so that dubious SCSI host adapters (like the one in at least some Microtek X6 USB scanners) don't get wedged trying to do a zero length read. However, we do not actually try to read this byte of data, as that wedges the USB scanner as well. IOW the SCSI command says we are going to read 1 byte, but in fact we don't: */ /*cmd[8] = 1; status = sanei_scsi_cmd(ms->sfd, cmd, sizeof(cmd), &dummy, 0); */ if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_read_image_status: '%s'\n", sane_strstatus(status)); return status; } /*---------- scsi_read_shading () --------------------------------------------*/ static SANE_Status scsi_read_shading(Microtek2_Scanner *ms, uint8_t *buffer, uint32_t length) { uint8_t cmd[RSI_CMD_L]; SANE_Bool endiantype; SANE_Status status = SANE_STATUS_GOOD; size_t size; 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); size = length; RSI_SET_CMD(cmd); ENDIAN_TYPE(endiantype) RSI_SET_PCORMAC(cmd, endiantype); RSI_SET_COLOR(cmd, ms->current_color); RSI_SET_DARK(cmd, ms->dark); RSI_SET_WORD(cmd, ms->word); RSI_SET_TRANSFERLENGTH(cmd, size); if ( md_dump >= 2 ) dump_area2(cmd, RSI_CMD_L, "readshading"); DBG(100, "scsi_read_shading: sfd=%d, cmd=%p, sizeofcmd=%lu," "dest=%p, destsize=%lu\n", ms->sfd, cmd, (u_long) sizeof(cmd), buffer, (u_long) size); status = sanei_scsi_cmd(ms->sfd, cmd, sizeof(cmd), buffer, &size); if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_read_shading: '%s'\n", sane_strstatus(status)); if ( md_dump > 3) dump_area2(buffer, size, "readshadingresult"); return status; } /*---------- scsi_send_shading () --------------------------------------------*/ static SANE_Status scsi_send_shading(Microtek2_Scanner *ms, uint8_t *shading_data, uint32_t length, uint8_t dark) { SANE_Bool endiantype; SANE_Status status; size_t size; uint8_t *cmd; DBG(30, "scsi_send_shading: pos=%p, size=%d, word=%d, color=%d, dark=%d\n", shading_data, length, ms->word, ms->current_color, dark); cmd = (uint8_t *) malloc(SSI_CMD_L + length); DBG(100, "scsi_send_shading: cmd=%p, malloc'd %d bytes\n", cmd, SSI_CMD_L + length); if ( cmd == NULL ) { DBG(1, "scsi_send_shading: Couldn't get buffer for shading table\n"); return SANE_STATUS_NO_MEM; } SSI_SET_CMD(cmd); ENDIAN_TYPE(endiantype) SSI_SET_PCORMAC(cmd, endiantype); SSI_SET_COLOR(cmd, ms->current_color); SSI_SET_DARK(cmd, dark); SSI_SET_WORD(cmd, ms->word); SSI_SET_TRANSFERLENGTH(cmd, length); memcpy(cmd + SSI_CMD_L, shading_data, length); size = length; if ( md_dump >= 2 ) dump_area2(cmd, SSI_CMD_L, "sendshading"); if ( md_dump >= 3 ) dump_area2(cmd + SSI_CMD_L, size, "sendshadingdata"); status = sanei_scsi_cmd(ms->sfd, cmd, size + SSI_CMD_L, NULL, 0); if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_send_shading: '%s'\n", sane_strstatus(status)); DBG(100, "free cmd at %p\n", cmd); free((void *) cmd); return status; } /*---------- scsi_read_system_status() ---------------------------------------*/ static SANE_Status scsi_read_system_status(Microtek2_Device *md, int fd) { uint8_t cmd[RSS_CMD_L]; uint8_t result[RSS_RESULT_L]; int sfd; size_t size; SANE_Status status; DBG(30, "scsi_read_system_status: md=%p, fd=%d\n", (void *) md, fd); if ( fd == -1 ) { status = sanei_scsi_open(md->name, &sfd, scsi_sense_handler, 0); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_read_system_status: open '%s'\n", sane_strstatus(status)); return status; } } else sfd = fd; RSS_CMD(cmd); if ( md_dump >= 2) dump_area2(cmd, RSS_CMD_L, "readsystemstatus"); size = sizeof(result); status = sanei_scsi_cmd(sfd, cmd, sizeof(cmd), result, &size); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_read_system_status: cmd '%s'\n", sane_strstatus(status)); sanei_scsi_close(sfd); return status; } if ( fd == -1 ) sanei_scsi_close(sfd); if ( md_dump >= 2) dump_area2(result, size, "readsystemstatusresult"); md->status.sskip = RSS_SSKIP(result); md->status.ntrack = RSS_NTRACK(result); md->status.ncalib = RSS_NCALIB(result); md->status.tlamp = RSS_TLAMP(result); md->status.flamp = RSS_FLAMP(result); md->status.rdyman= RSS_RDYMAN(result); md->status.trdy = RSS_TRDY(result); md->status.frdy = RSS_FRDY(result); md->status.adp = RSS_RDYMAN(result); md->status.detect = RSS_DETECT(result); md->status.adptime = RSS_ADPTIME(result); md->status.lensstatus = RSS_LENSSTATUS(result); md->status.aloff = RSS_ALOFF(result); md->status.timeremain = RSS_TIMEREMAIN(result); md->status.tmacnt = RSS_TMACNT(result); md->status.paper = RSS_PAPER(result); md->status.adfcnt = RSS_ADFCNT(result); md->status.currentmode = RSS_CURRENTMODE(result); md->status.buttoncount = RSS_BUTTONCOUNT(result); return SANE_STATUS_GOOD; } /*---------- scsi_request_sense() --------------------------------------------*/ /* currently not used */ #if 0 static SANE_Status scsi_request_sense(Microtek2_Scanner *ms) { uint8_t requestsense[RQS_CMD_L]; uint8_t buffer[100]; SANE_Status status; int size; int asl; int as_info_length; DBG(30, "scsi_request_sense: ms=%p\n", (void *) ms); RQS_CMD(requestsense); RQS_ALLOCLENGTH(requestsense, 100); size = sizeof(buffer); status = sanei_scsi_cmd(ms->sfd, requestsense, sizeof(requestsense), buffer, &size); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_request_sense: '%s'\n", sane_strstatus(status)); return status; } if ( md_dump >= 2 ) dump_area2(buffer, size, "requestsenseresult"); dump_area(buffer, RQS_LENGTH(buffer), "RequestSense"); asl = RQS_ASL(buffer); if ( (as_info_length = RQS_ASINFOLENGTH(buffer)) > 0 ) DBG(25, "scsi_request_sense: info '%.*s'\n", as_info_length, RQS_ASINFO(buffer)); return SANE_STATUS_GOOD; } #endif /*---------- scsi_send_system_status() ---------------------------------------*/ static SANE_Status scsi_send_system_status(Microtek2_Device *md, int fd) { uint8_t cmd[SSS_CMD_L + SSS_DATA_L]; uint8_t *pos; int sfd; SANE_Status status; DBG(30, "scsi_send_system_status: md=%p, fd=%d\n", (void *) md, fd); memset(cmd, 0, SSS_CMD_L + SSS_DATA_L); if ( fd == -1 ) { status = sanei_scsi_open(md->name, &sfd, scsi_sense_handler, 0); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_send_system_status: open '%s'\n", sane_strstatus(status)); return status; } } else sfd = fd; SSS_CMD(cmd); pos = cmd + SSS_CMD_L; SSS_STICK(pos, md->status.stick); SSS_NTRACK(pos, md->status.ntrack); SSS_NCALIB(pos, md->status.ncalib); SSS_TLAMP(pos, md->status.tlamp); SSS_FLAMP(pos, md->status.flamp); SSS_RESERVED17(pos, md->status.reserved17); SSS_RDYMAN(pos, md->status.rdyman); SSS_TRDY(pos, md->status.trdy); SSS_FRDY(pos, md->status.frdy); SSS_ADP(pos, md->status.adp); SSS_DETECT(pos, md->status.detect); SSS_ADPTIME(pos, md->status.adptime); SSS_LENSSTATUS(pos, md->status.lensstatus); SSS_ALOFF(pos, md->status.aloff); SSS_TIMEREMAIN(pos, md->status.timeremain); SSS_TMACNT(pos, md->status.tmacnt); SSS_PAPER(pos, md->status.paper); SSS_ADFCNT(pos, md->status.adfcnt); SSS_CURRENTMODE(pos, md->status.currentmode); SSS_BUTTONCOUNT(pos, md->status.buttoncount); if ( md_dump >= 2) { dump_area2(cmd, SSS_CMD_L, "sendsystemstatus"); dump_area2(cmd + SSS_CMD_L, SSS_DATA_L, "sendsystemstatusdata"); } status = sanei_scsi_cmd(sfd, cmd, sizeof(cmd), NULL, 0); if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_send_system_status: '%s'\n", sane_strstatus(status)); if ( fd == -1 ) sanei_scsi_close(sfd); return status; } /*---------- scsi_sense_handler() --------------------------------------------*/ /* rewritten 19.12.2001 for better SANE_STATUS return codes */ static SANE_Status scsi_sense_handler (int fd, u_char *sense, void *arg) { int as_info_length; uint8_t sense_key; uint8_t asc; uint8_t ascq; DBG(30, "scsi_sense_handler: fd=%d, sense=%p arg=%p\n",fd, sense, arg); dump_area(sense, RQS_LENGTH(sense), "SenseBuffer"); sense_key = RQS_SENSEKEY(sense); asc = RQS_ASC(sense); ascq = RQS_ASCQ(sense); DBG(5, "scsi_sense_handler: SENSE KEY (0x%02x), " "ASC (0x%02x), ASCQ (0x%02x)\n", sense_key, asc, ascq); if ( (as_info_length = RQS_ASINFOLENGTH(sense)) > 0 ) DBG(5,"scsi_sense_handler: info: '%*s'\n", as_info_length, RQS_ASINFO(sense)); switch ( sense_key ) { case RQS_SENSEKEY_NOSENSE: return SANE_STATUS_GOOD; case RQS_SENSEKEY_HWERR: case RQS_SENSEKEY_ILLEGAL: case RQS_SENSEKEY_VENDOR: if ( asc == 0x4a && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Command phase error\n"); else if ( asc == 0x2c && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Command sequence error\n"); else if ( asc == 0x4b && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Data phase error\n"); else if ( asc == 0x40 ) { DBG(5, "scsi_sense_handler: Hardware diagnostic failure:\n"); switch ( ascq ) { case RQS_ASCQ_CPUERR: DBG(5, "scsi_sense_handler: CPU error\n"); break; case RQS_ASCQ_SRAMERR: DBG(5, "scsi_sense_handler: SRAM error\n"); break; case RQS_ASCQ_DRAMERR: DBG(5, "scsi_sense_handler: DRAM error\n"); break; case RQS_ASCQ_DCOFF: DBG(5, "scsi_sense_handler: DC Offset error\n"); break; case RQS_ASCQ_GAIN: DBG(5, "scsi_sense_handler: Gain error\n"); break; case RQS_ASCQ_POS: DBG(5, "scsi_sense_handler: Positoning error\n"); break; default: DBG(5, "scsi_sense_handler: Unknown combination of ASC" " (0x%02x) and ASCQ (0x%02x)\n", asc, ascq); break; } } else if ( asc == 0x00 && ascq == 0x05) { DBG(5, "scsi_sense_handler: End of data detected\n"); return SANE_STATUS_EOF; } 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 specified\n"); else if ( asc == 0x20 && ascq == 0x00 ) /* Ok */ DBG(5, "scsi_sense_handler: Invalid command opcode\n"); else if ( asc == 0x24 && ascq == 0x00 ) /* Ok */ DBG(5, "scsi_sense_handler: Invalid field in CDB\n"); else if ( asc == 0x26 && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Invalid field in the param list\n"); else if ( asc == 0x49 && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Invalid message error\n"); else if ( asc == 0x60 && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Lamp failure\n"); else if ( asc == 0x25 && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Unsupported logic. unit\n"); else if ( asc == 0x53 && ascq == 0x00 ) { DBG(5, "scsi_sense_handler: ADF paper jam or no paper\n"); return SANE_STATUS_NO_DOCS; } else if ( asc == 0x54 && ascq == 0x00 ) { DBG(5, "scsi_sense_handler: Media bumping\n"); return SANE_STATUS_JAMMED; /* Don't know if this is right! */ } else if ( asc == 0x55 && ascq == 0x00 ) { DBG(5, "scsi_sense_handler: Scan Job stopped or cancelled\n"); return SANE_STATUS_CANCELLED; } else if ( asc == 0x3a && ascq == 0x00 ) { DBG(5, "scsi_sense_handler: Media (ADF or TMA) not available\n"); return SANE_STATUS_NO_DOCS; } else if ( asc == 0x3a && ascq == 0x01 ) { DBG(5, "scsi_sense_handler: Door is not closed\n"); return SANE_STATUS_COVER_OPEN; } else if ( asc == 0x3a && ascq == 0x02 ) DBG(5, "scsi_sense_handler: Door is not opened\n"); else if ( asc == 0x00 && ascq == 0x00 ) DBG(5, "scsi_sense_handler: No additional sense information\n"); /* Ok */ else if ( asc == 0x1a && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Parameter list length error\n"); else if ( asc == 0x26 && ascq == 0x02 ) DBG(5, "scsi_sense_handler: Parameter value invalid\n"); else if ( asc == 0x03 && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Peripheral device write fault - " "Firmware Download Error\n"); else if ( asc == 0x2c && ascq == 0x01 ) DBG(5, "scsi_sense_handler: Too many windows specified\n"); else if ( asc == 0x80 && ascq == 0x00 ) DBG(5, "scsi_sense_handler: Target abort scan\n"); else if ( asc == 0x96 && ascq == 0x08 ) { DBG(5, "scsi_sense_handler: Firewire Device busy\n"); return SANE_STATUS_DEVICE_BUSY; } else DBG(5, "scsi_sense_handler: Unknown combination of SENSE KEY " "(0x%02x), ASC (0x%02x) and ASCQ (0x%02x)\n", sense_key, asc, ascq); return SANE_STATUS_IO_ERROR; default: DBG(5, "scsi_sense_handler: Unknown sense key (0x%02x)\n", sense_key); return SANE_STATUS_IO_ERROR; } } /*---------- scsi_test_unit_ready() ------------------------------------------*/ static SANE_Status scsi_test_unit_ready(Microtek2_Device *md) { SANE_Status status; uint8_t tur[TUR_CMD_L]; int sfd; DBG(30, "scsi_test_unit_ready: md=%s\n", md->name); TUR_CMD(tur); status = sanei_scsi_open(md->name, &sfd, scsi_sense_handler, 0); if ( status != SANE_STATUS_GOOD ) { DBG(1, "scsi_test_unit_ready: open '%s'\n", sane_strstatus(status)); return status; } if ( md_dump >= 2 ) dump_area2(tur, sizeof(tur), "testunitready"); status = sanei_scsi_cmd(sfd, tur, sizeof(tur), NULL, 0); if ( status != SANE_STATUS_GOOD ) DBG(1, "scsi_test_unit_ready: cmd '%s'\n", sane_strstatus(status)); sanei_scsi_close(sfd); return status; } /*---------- sane_start() ----------------------------------------------------*/ SANE_Status sane_start(SANE_Handle handle) { SANE_Status status = SANE_STATUS_GOOD; Microtek2_Scanner *ms = handle; Microtek2_Device *md; Microtek2_Info *mi; uint8_t *pos; int color, rc, retry; DBG(30, "sane_start: handle=0x%p\n", handle); md = ms->dev; mi = &md->info[md->scan_source]; ms->n_control_bytes = md->n_control_bytes; if ( md->model_flags & MD_READ_CONTROL_BIT ) { if (ms->control_bytes) free((void *)ms->control_bytes); ms->control_bytes = (uint8_t *) malloc(ms->n_control_bytes); DBG(100, "sane_start: ms->control_bytes=%p, malloc'd %lu bytes\n", ms->control_bytes, (u_long) ms->n_control_bytes); if ( ms->control_bytes == NULL ) { DBG(1, "sane_start: malloc() for control bits failed\n"); status = SANE_STATUS_NO_MEM; goto cleanup; } } if (ms->sfd < 0) /* first or only pass of this scan */ { /* open device */ for ( retry = 0; retry < 10; retry++ ) { status = sanei_scsi_open (md->sane.name, &ms->sfd, scsi_sense_handler, 0); if ( status != SANE_STATUS_DEVICE_BUSY ) break; DBG(30, "sane_start: Scanner busy, trying again\n"); sleep(1); } if ( status != SANE_STATUS_GOOD ) { DBG(1, "sane_start: scsi_open: '%s'\n", sane_strstatus(status)); goto cleanup; } status = scsi_read_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) goto cleanup; if ( ms->val[OPT_CALIB_BACKEND].w == SANE_TRUE ) DBG(30, "sane_start: backend calibration on\n"); else DBG(30, "sane_start: backend calibration off\n"); if ( ( ms->val[OPT_CALIB_BACKEND].w == SANE_TRUE ) && !( md->model_flags & MD_PHANTOM336CX_TYPE_SHADING ) ) { /* Read shading only once - possible with CIS scanners */ /* assuming only CIS scanners use Controlbits */ if ( ( md->shading_table_w == NULL ) || !( md->model_flags & MD_READ_CONTROL_BIT ) ) { status = get_scan_parameters(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; status = read_shading_image(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; } } status = get_scan_parameters(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; status = scsi_read_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) goto cleanup; md->status.aloff |= 128; md->status.timeremain = 10; if ( ms->scan_source == MS_SOURCE_FLATBED || ms->scan_source == MS_SOURCE_ADF ) { md->status.flamp |= MD_FLAMP_ON; md->status.tlamp &= ~MD_TLAMP_ON; } else { md->status.flamp &= ~MD_FLAMP_ON; md->status.tlamp |= MD_TLAMP_ON; } if ( ms->lightlid35 ) { md->status.flamp &= ~MD_FLAMP_ON; /* md->status.tlamp |= MD_TLAMP_ON;*/ /* with this line on some scanners (X6, 0x91) the Flamp goes on */ } if ( ms->no_backtracking ) md->status.ntrack |= MD_NTRACK_ON; else md->status.ntrack &= ~MD_NTRACK_ON; status = scsi_send_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) goto cleanup; /* calculate gamma: we assume, that the gamma values are transferred */ /* with one send gamma command, even if it is a 3 pass scanner */ if ( md->model_flags & MD_NO_GAMMA ) { ms->lut_size = (int) pow(2.0, (double) ms->depth); ms->lut_entry_size = ms->depth > 8 ? 2 : 1; } else { get_lut_size(mi, &ms->lut_size, &ms->lut_entry_size); } ms->lut_size_bytes = ms->lut_size * ms->lut_entry_size; ms->word = (ms->lut_entry_size == 2); ms->gamma_table = (uint8_t *) malloc(3 * ms->lut_size_bytes ); DBG(100, "sane_start: ms->gamma_table=%p, malloc'd %d bytes\n", ms->gamma_table, 3 * ms->lut_size_bytes); if ( ms->gamma_table == NULL ) { DBG(1, "sane_start: malloc for gammatable failed\n"); status = SANE_STATUS_NO_MEM; goto cleanup; } for ( color = 0; color < 3; color++ ) { pos = ms->gamma_table + color * ms->lut_size_bytes; calculate_gamma(ms, pos, color, ms->gamma_mode); } /* Some models ignore the settings for the exposure time, */ /* so we must do it ourselves. Apparently this seems to be */ /* the case for all models that have the chunky data format */ if ( mi->data_format == MI_DATAFMT_CHUNKY ) set_exposure(ms); if ( ! (md->model_flags & MD_NO_GAMMA) ) { status = scsi_send_gamma(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; } status = scsi_set_window(ms, 1); if ( status != SANE_STATUS_GOOD ) goto cleanup; ms->scanning = SANE_TRUE; ms->cancelled = SANE_FALSE; } ++ms->current_pass; status = scsi_read_image_info(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; status = prepare_buffers(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; status = calculate_sane_params(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; if ( !( md->model_flags & MD_NO_RIS_COMMAND ) ) { /* !!FIXME!! - hack for C6USB because RIS over USB doesn't wait until */ /* scanner ready */ if (mi->model_code == 0x9a) sleep(2); status = scsi_wait_for_image(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; } if ( ms->calib_backend && ( md->model_flags & MD_PHANTOM336CX_TYPE_SHADING ) && ( ( md->shading_table_w == NULL ) || ( ms->mode != md->shading_table_contents ) ) ) { status = read_cx_shading(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; } if ( ms->lightlid35 ) /* hopefully this leads to a switched off flatbed lamp with lightlid */ { status = scsi_read_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) goto cleanup; md->status.flamp &= ~MD_FLAMP_ON; md->status.tlamp &= ~MD_TLAMP_ON; status = scsi_send_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) goto cleanup; } if ( md->model_flags & MD_READ_CONTROL_BIT ) { status = scsi_read_control_bits(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; if ( ms->calib_backend ) { status = condense_shading(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; } } /* open a pipe and fork a child process, that actually reads the data */ rc = pipe(ms->fd); if ( rc == -1 ) { DBG(1, "sane_start: pipe failed\n"); status = SANE_STATUS_IO_ERROR; goto cleanup; } /* create reader routine as new thread or process */ ms->pid = sanei_thread_begin( reader_process,(void*) ms); if ( !sanei_thread_is_valid (ms->pid) ) { DBG(1, "sane_start: fork failed\n"); status = SANE_STATUS_IO_ERROR; goto cleanup; } if (sanei_thread_is_forked()) close(ms->fd[1]); return SANE_STATUS_GOOD; cleanup: cleanup_scanner(ms); return status; } /*---------- prepare_buffers -------------------------------------------------*/ static SANE_Status prepare_buffers(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; Microtek2_Info *mi; uint32_t strip_lines; int i; status = SANE_STATUS_GOOD; DBG(30, "prepare_buffers: ms=0x%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; /* calculate maximum number of lines to read */ strip_lines = (int) ((double) ms->y_resolution_dpi * md->opts.strip_height); if ( strip_lines == 0 ) strip_lines = 1; /* calculate number of lines that fit into the source buffer */ #ifdef TESTBACKEND ms->src_max_lines = MIN( 5000000 / ms->bpl, strip_lines); #else ms->src_max_lines = MIN( sanei_scsi_max_request_size / ms->bpl, strip_lines); #endif if ( ms->src_max_lines == 0 ) { DBG(1, "sane_start: Scan buffer too small\n"); status = SANE_STATUS_IO_ERROR; goto cleanup; } /* allocate buffers */ ms->src_buffer_size = ms->src_max_lines * ms->bpl; if ( ms->mode == MS_MODE_COLOR && mi->data_format == MI_DATAFMT_LPLSEGREG ) { /* In this case the data is not neccessarily in the order RGB */ /* and there may be different numbers of read red, green and blue */ /* segments. We allocate a second buffer to read new lines in */ /* and hold undelivered pixels in the other buffer */ int extra_buf_size; extra_buf_size = 2 * ms->bpl * mi->ccd_gap * (int) ceil( (double) mi->max_yresolution / (double) mi->opt_resolution); for ( i = 0; i < 2; i++ ) { if ( ms->buf.src_buffer[i] ) free((void *) ms->buf.src_buffer[i]); ms->buf.src_buffer[i] = (uint8_t *) malloc(ms->src_buffer_size + extra_buf_size); DBG(100, "prepare_buffers: ms->buf.src_buffer[%d]=%p," "malloc'd %d bytes\n", i, ms->buf.src_buffer[i], ms->src_buffer_size + extra_buf_size); if ( ms->buf.src_buffer[i] == NULL ) { DBG(1, "sane_start: malloc for scan buffer failed\n"); status = SANE_STATUS_NO_MEM; goto cleanup; } } ms->buf.free_lines = ms->src_max_lines + extra_buf_size / ms->bpl; ms->buf.free_max_lines = ms->buf.free_lines; ms->buf.src_buf = ms->buf.src_buffer[0]; ms->buf.current_src = 0; /* index to current buffer */ } else { if ( ms->buf.src_buf ) free((void *) ms->buf.src_buf); ms->buf.src_buf = malloc(ms->src_buffer_size); DBG(100, "sane_start: ms->buf.src_buf=%p, malloc'd %d bytes\n", ms->buf.src_buf, ms->src_buffer_size); if ( ms->buf.src_buf == NULL ) { DBG(1, "sane_start: malloc for scan buffer failed\n"); status = SANE_STATUS_NO_MEM; goto cleanup; } } for ( i = 0; i < 3; i++ ) { ms->buf.current_pos[i] = ms->buf.src_buffer[0]; ms->buf.planes[0][i] = 0; ms->buf.planes[1][i] = 0; } /* allocate a temporary buffer for the data, if auto_adjust threshold */ /* is selected. */ if ( ms->auto_adjust == 1 ) { ms->temporary_buffer = (uint8_t *) malloc(ms->remaining_bytes); DBG(100, "sane_start: ms->temporary_buffer=%p, malloc'd %d bytes\n", ms->temporary_buffer, ms->remaining_bytes); if ( ms->temporary_buffer == NULL ) { DBG(1, "sane_start: malloc() for temporary buffer failed\n"); status = SANE_STATUS_NO_MEM; goto cleanup; } } else ms->temporary_buffer = NULL; /* some data formats have additional information in a scan line, which */ /* is not transferred to the frontend; real_bpl is the number of bytes */ /* per line, that is copied into the frontend's buffer */ ms->real_bpl = (uint32_t) ceil( ((double) ms->ppl * (double) ms->bits_per_pixel_out) / 8.0 ); if ( mi->onepass && ms->mode == MS_MODE_COLOR ) ms->real_bpl *= 3; ms->real_remaining_bytes = ms->real_bpl * ms->src_remaining_lines; return SANE_STATUS_GOOD; cleanup: cleanup_scanner(ms); return status; } static void write_shading_buf_pnm(Microtek2_Scanner *ms, uint32_t lines) { FILE *outfile; uint16_t pixel, color, linenr, factor; unsigned char img_val_out; float img_val = 0; Microtek2_Device *md; Microtek2_Info *mi; md = ms->dev; mi = &md->info[md->scan_source]; if ( mi->depth & MI_HASDEPTH_16 ) factor = 256; else if ( mi->depth & MI_HASDEPTH_14 ) factor = 64; else if ( mi->depth & MI_HASDEPTH_12 ) factor = 16; else if ( mi->depth & MI_HASDEPTH_10 ) factor = 4; else factor = 1; if ( md->model_flags & MD_16BIT_TRANSFER ) factor = 256; outfile = fopen("shading_buf_w.pnm", "w"); fprintf(outfile, "P6\n#imagedata\n%d %d\n255\n", mi->geo_width / mi->calib_divisor, lines); for ( linenr=0; linenr < lines; linenr++ ) { if (mi->data_format == MI_DATAFMT_LPLSEGREG) { DBG(1, "Output of shading buffer unsupported for" "Segreg Data format\n"); break; } for ( pixel=0; pixel < (uint16_t) (mi->geo_width / mi->calib_divisor); pixel++) { for ( color=0; color < 3; color++ ) { switch( mi->data_format ) { case MI_DATAFMT_LPLCONCAT: if ( md->shading_depth > 8) img_val = *((uint16_t *) ms->shading_image + linenr * ( ms->bpl / ms->lut_entry_size ) + mi->color_sequence[color] * ( ms->bpl / ms->lut_entry_size / 3 ) + pixel); else img_val = *((uint8_t *) ms->shading_image + linenr * ( ms->bpl / ms->lut_entry_size ) + mi->color_sequence[color] * ( ms->bpl / ms->lut_entry_size / 3 ) + pixel); break; case MI_DATAFMT_CHUNKY: case MI_DATAFMT_9800: img_val = *((uint16_t *)ms->shading_image + linenr * 3 * ( mi->geo_width / mi->calib_divisor ) + 3 * pixel + mi->color_sequence[color]); break; } img_val /= factor; img_val_out = (unsigned char)img_val; fputc(img_val_out, outfile); } } } fclose(outfile); return; } static void write_shading_pnm(Microtek2_Scanner *ms) { FILE *outfile_w = NULL, *outfile_d = NULL; int pixel, color, line, offset, num_shading_pixels, output_height; uint16_t img_val, factor; Microtek2_Device *md; Microtek2_Info *mi; output_height = 180; md = ms->dev; mi = &md->info[md->scan_source]; DBG(30, "write_shading_pnm: ms=%p\n", (void *) ms); if ( mi->depth & MI_HASDEPTH_16 ) factor = 256; else if ( mi->depth & MI_HASDEPTH_14 ) factor = 64; else if ( mi->depth & MI_HASDEPTH_12 ) factor = 16; else if ( mi->depth & MI_HASDEPTH_10 ) factor = 4; else factor = 1; if ( md->model_flags & MD_16BIT_TRANSFER ) factor = 256; if ( md->model_flags & MD_PHANTOM336CX_TYPE_SHADING ) num_shading_pixels = ms->n_control_bytes * 8; else num_shading_pixels = mi->geo_width / mi->calib_divisor; if ( md->shading_table_w != NULL ) { outfile_w = fopen("microtek2_shading_w.pnm", "w"); fprintf(outfile_w, "P6\n#imagedata\n%d %d\n255\n", num_shading_pixels, output_height); } if ( md->shading_table_d != NULL ) { outfile_d = fopen("microtek2_shading_d.pnm", "w"); fprintf(outfile_d, "P6\n#imagedata\n%d %d\n255\n", num_shading_pixels, output_height); } for ( line=0; line < output_height; ++line ) { for ( pixel=0; pixel < num_shading_pixels ; ++pixel) { for ( color=0; color < 3; ++color ) { offset = mi->color_sequence[color] * num_shading_pixels + pixel; if ( md->shading_table_w != NULL ) { if ( ms->lut_entry_size == 2 ) { img_val = *((uint16_t *) md->shading_table_w + offset ); img_val /= factor; } else img_val = *((uint8_t *) md->shading_table_w + offset ); fputc((unsigned char)img_val, outfile_w); } if ( md->shading_table_d != NULL ) { if ( ms->lut_entry_size == 2 ) { img_val = *((uint16_t *) md->shading_table_d + offset ); img_val /= factor; } else img_val = *((uint8_t *) md->shading_table_d + offset ); fputc((unsigned char)img_val, outfile_d); } } } } if ( md->shading_table_w != NULL ) fclose(outfile_w); if ( md->shading_table_d != NULL ) fclose(outfile_d); return; } static void write_cshading_pnm(Microtek2_Scanner *ms) { FILE *outfile; Microtek2_Device *md; Microtek2_Info *mi; int pixel, color, line, offset, img_val, img_height=30, factor; md = ms->dev; mi = &md->info[md->scan_source]; if ( mi->depth & MI_HASDEPTH_16 ) factor = 256; else if ( mi->depth & MI_HASDEPTH_14 ) factor = 64; else if ( mi->depth & MI_HASDEPTH_12 ) factor = 16; else if ( mi->depth & MI_HASDEPTH_10 ) factor = 4; else factor = 1; if ( md->model_flags & MD_16BIT_TRANSFER ) factor = 256; outfile = fopen("microtek2_cshading_w.pnm", "w"); if ( ms->mode == MS_MODE_COLOR ) fprintf(outfile, "P6\n#imagedata\n%d %d\n255\n", ms->ppl, img_height); else fprintf(outfile, "P5\n#imagedata\n%d %d\n255\n", ms->ppl, img_height); for ( line=0; line < img_height; ++line ) { for ( pixel=0; pixel < (int)ms->ppl; ++pixel) { for ( color=0; color < 3; ++color ) { offset = color * (int)ms->ppl + pixel; if ( ms->lut_entry_size == 1 ) img_val = (int) *((uint8_t *)ms->condensed_shading_w + offset); else { img_val = (int) *((uint16_t *)ms->condensed_shading_w + offset); img_val /= factor; } fputc((unsigned char)img_val, outfile); if ( ms->mode == MS_MODE_GRAY ) break; } } } fclose(outfile); return; } /*---------- condense_shading() ----------------------------------------------*/ static SANE_Status condense_shading(Microtek2_Scanner *ms) { /* This function extracts the relevant shading pixels from */ /* the shading image according to the 1's in the result of */ /* 'read control bits', and stores them in a memory block. */ /* We will then have as many shading pixels as there are */ /* pixels per line. The order of the pixels in the condensed */ /* shading data block will always be left to right. The color */ /* sequence remains unchanged. */ Microtek2_Device *md; Microtek2_Info *mi; uint32_t byte; uint32_t cond_length; /* bytes per condensed shading line */ int color, count, lfd_bit; int shad_bplc, shad_pixels; /* bytes per line & color in shading image */ int bit, flag; uint32_t sh_offset, csh_offset; int gray_filter_color = 1; /* which color of the shading is taken for gray*/ md = ms->dev; mi = &md->info[md->scan_source]; DBG(30, "condense_shading: ms=%p, ppl=%d\n", (void *) ms, ms->ppl); if ( md->shading_table_w == NULL ) { DBG(1, "condense shading: no shading table found, skip shading\n"); return SANE_STATUS_GOOD; } get_lut_size( mi, &ms->lut_size, &ms->lut_entry_size ); if ( md->model_flags & MD_PHANTOM336CX_TYPE_SHADING ) { shad_pixels = ms->n_control_bytes * 8; gray_filter_color = 0; /* 336CX reads only one shading in gray mode*/ } else shad_pixels = mi->geo_width; shad_bplc = shad_pixels * ms->lut_entry_size; if ( md_dump >= 3 ) { dump_area2(md->shading_table_w, shad_bplc * 3, "shading_table_w"); if ( md->model_flags & MD_PHANTOM336CX_TYPE_SHADING ) write_shading_pnm(ms); } cond_length = ms->bpl * ms->lut_entry_size; if ( ms->condensed_shading_w ) { free((void*) ms->condensed_shading_w ); ms->condensed_shading_w = NULL; } ms->condensed_shading_w = (uint8_t *)malloc(cond_length); DBG(100, "condense_shading: ms->condensed_shading_w=%p," "malloc'd %d bytes\n", ms->condensed_shading_w, cond_length); if ( ms->condensed_shading_w == NULL ) { DBG(1, "condense_shading: malloc for white table failed\n"); return SANE_STATUS_NO_MEM; } if ( md->shading_table_d != NULL ) { if ( md_dump >= 3 ) dump_area2(md->shading_table_d, shad_bplc * 3, "shading_table_d"); if ( ms->condensed_shading_d ) { free((void*) ms->condensed_shading_d ); ms->condensed_shading_d = NULL; } ms->condensed_shading_d = (uint8_t *)malloc(cond_length); DBG(100, "condense_shading: ms->condensed_shading_d=%p," " malloc'd %d bytes\n", ms->condensed_shading_d, cond_length); if ( ms->condensed_shading_d == NULL ) { DBG(1, "condense_shading: malloc for dark table failed\n"); return SANE_STATUS_NO_MEM; } } DBG(128, "controlbit offset=%d\n", md->controlbit_offset); count = 0; for (lfd_bit = 0; ( lfd_bit < mi->geo_width ) && ( count < (int)ms->ppl ); ++lfd_bit) { byte = ( lfd_bit + md->controlbit_offset ) / 8; bit = ( lfd_bit + md->controlbit_offset ) % 8; if ( mi->direction & MI_DATSEQ_RTOL ) flag = ((ms->control_bytes[byte] >> bit) & 0x01); else flag = ((ms->control_bytes[byte] >> (7 - bit)) & 0x01); if ( flag == 1 ) /* flag==1 if byte's bit is set */ { for ( color = 0; color < 3; ++color ) { if ( ( ms->mode == MS_MODE_COLOR ) || ( ( ms->mode == MS_MODE_GRAY ) && ( color == gray_filter_color ) ) || ( ( ms->mode == MS_MODE_LINEARTFAKE ) && ( color == gray_filter_color ) ) ) { sh_offset = color * shad_pixels + lfd_bit; if ( md->model_flags & MD_PHANTOM336CX_TYPE_SHADING ) sh_offset += md->controlbit_offset; if ( ms->mode == MS_MODE_COLOR ) csh_offset = color * ms->ppl + count; else csh_offset = count; if ( csh_offset > cond_length ) { DBG(1, "condense_shading: wrong control bits data, " ); DBG(1, "csh_offset (%d) > cond_length(%d)\n", csh_offset, cond_length ); csh_offset = cond_length; } if ( ms->lut_entry_size == 2 ) { *((uint16_t *)ms->condensed_shading_w + csh_offset) = *((uint16_t *)md->shading_table_w + sh_offset); if ( ms->condensed_shading_d != NULL ) *((uint16_t *)ms->condensed_shading_d + csh_offset) = *((uint16_t *)md->shading_table_d + sh_offset); } else { *((uint8_t *)ms->condensed_shading_w + csh_offset) = *((uint8_t *)md->shading_table_w + sh_offset); if ( ms->condensed_shading_d != NULL ) *((uint8_t *)ms->condensed_shading_d + csh_offset) = *((uint8_t *)md->shading_table_d + sh_offset); } } } ++count; } } if ( md_dump >= 3 ) { dump_area2(ms->condensed_shading_w, cond_length, "condensed_shading_w"); if ( ms->condensed_shading_d != NULL ) dump_area2(ms->condensed_shading_d, cond_length, "condensed_shading_d"); write_cshading_pnm(ms); } return SANE_STATUS_GOOD; } /*---------- read_shading_image() --------------------------------------------*/ static SANE_Status read_shading_image(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; Microtek2_Info *mi; uint32_t lines; uint8_t *buf; int max_lines; int lines_to_read; DBG(30, "read_shading_image: ms=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; if ( ! MI_WHITE_SHADING_ONLY(mi->shtrnsferequ) || ( md->model_flags & MD_PHANTOM_C6 ) ) /* Dark shading correction */ /* ~~~~~~~~~~~~~~~~~~~~~~~ */ { DBG(30, "read_shading_image: reading black data\n"); md->status.ntrack |= MD_NTRACK_ON; md->status.ncalib &= ~MD_NCALIB_ON; md->status.flamp |= MD_FLAMP_ON; if ( md->model_flags & MD_PHANTOM_C6 ) { md->status.stick |= MD_STICK_ON; md->status.reserved17 |= MD_RESERVED17_ON; } get_calib_params(ms); if ( md->model_flags & MD_PHANTOM_C6 ) ms->stay = 1; status = scsi_send_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) return status; status = scsi_set_window(ms, 1); if ( status != SANE_STATUS_GOOD ) return status; #ifdef TESTBACKEND status = scsi_read_sh_image_info(ms); #else status = scsi_read_image_info(ms); #endif if ( status != SANE_STATUS_GOOD ) return status; status = scsi_wait_for_image(ms); if ( status != SANE_STATUS_GOOD ) return status; status = scsi_read_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) return status; md->status.flamp &= ~MD_FLAMP_ON; status = scsi_send_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) return status; ms->shading_image = malloc(ms->bpl * ms->src_remaining_lines); DBG(100, "read shading image: ms->shading_image=%p," " malloc'd %d bytes\n", ms->shading_image, ms->bpl * ms->src_remaining_lines); if ( ms->shading_image == NULL ) { DBG(1, "read_shading_image: malloc for buffer failed\n"); return SANE_STATUS_NO_MEM; } buf = ms->shading_image; #ifdef TESTBACKEND max_lines = 5000000 / ms->bpl; #else max_lines = sanei_scsi_max_request_size / ms->bpl; #endif if ( max_lines == 0 ) { DBG(1, "read_shading_image: buffer too small\n"); return SANE_STATUS_IO_ERROR; } lines = ms->src_remaining_lines; while ( ms->src_remaining_lines > 0 ) { lines_to_read = MIN(max_lines, ms->src_remaining_lines); ms->src_buffer_size = lines_to_read * ms->bpl; ms->transfer_length = ms->src_buffer_size; #ifdef TESTBACKEND status = scsi_read_sh_d_image(ms, buf); #else status = scsi_read_image(ms, buf, md->shading_depth>8 ? 2 : 1); #endif if ( status != SANE_STATUS_GOOD ) { DBG(1, "read_shading_image: read image failed: '%s'\n", sane_strstatus(status)); return status; } ms->src_remaining_lines -= lines_to_read; buf += ms->src_buffer_size; } status = prepare_shading_data(ms, lines, &md->shading_table_d); if ( status != SANE_STATUS_GOOD ) return status; /* send shading data to the device */ /* Some models use "read_control bit", and the shading must be */ /* applied by the backend later */ if ( ! (md->model_flags & MD_READ_CONTROL_BIT) ) { status = shading_function(ms, md->shading_table_d); if ( status != SANE_STATUS_GOOD ) return status; ms->word = ms->lut_entry_size == 2 ? 1 : 0; ms->current_color = MS_COLOR_ALL; status = scsi_send_shading(ms, md->shading_table_d, 3 * ms->lut_entry_size * mi->geo_width / mi->calib_divisor, 1); if ( status != SANE_STATUS_GOOD ) return status; } DBG(100, "free memory for ms->shading_image at %p\n", ms->shading_image); free((void *) ms->shading_image); ms->shading_image = NULL; } /* white shading correction */ /* ~~~~~~~~~~~~~~~~~~~~~~~~ */ DBG(30, "read_shading_image: reading white data\n"); /* According to the doc NCalib must be set for white shading data */ /* if we have a black and a white shading correction and must be */ /* cleared if we have only a white shading collection */ if ( ! MI_WHITE_SHADING_ONLY(mi->shtrnsferequ) || ( md->model_flags & MD_PHANTOM_C6 ) ) md->status.ncalib |= MD_NCALIB_ON; else md->status.ncalib &= ~MD_NCALIB_ON; md->status.flamp |= MD_FLAMP_ON; /* md->status.tlamp &= ~MD_TLAMP_ON; */ md->status.ntrack |= MD_NTRACK_ON; if ( md->model_flags & MD_PHANTOM_C6 ) { md->status.stick &= ~MD_STICK_ON; md->status.reserved17 |= MD_RESERVED17_ON; } get_calib_params(ms); #ifdef NO_PHANTOMTYPE_SHADING /* md->status.stick &= ~MD_STICK_ON; */ /* md->status.ncalib &= ~MD_NCALIB_ON; */ /* md->status.reserved17 &= ~MD_RESERVED17_ON; */ ms->rawdat = 0; #endif status = scsi_send_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) return status; status = scsi_set_window(ms, 1); if ( status != SANE_STATUS_GOOD ) return status; #ifdef TESTBACKEND status = scsi_read_sh_image_info(ms); #else status = scsi_read_image_info(ms); #endif if ( status != SANE_STATUS_GOOD ) return status; status = scsi_wait_for_image(ms); if ( status != SANE_STATUS_GOOD ) return status; #ifdef NO_PHANTOMTYPE_SHADING if ( !( md->model_flags & MD_READ_CONTROL_BIT ) ) { #endif status = scsi_read_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) return status; #ifdef NO_PHANTOMTYPE_SHADING } #endif #ifdef NO_PHANTOMTYPE_SHADING if ( mi->model_code == 0x94 ) status = scsi_read_control_bits(ms); #endif ms->shading_image = malloc(ms->bpl * ms->src_remaining_lines); DBG(100, "read shading image: ms->shading_image=%p, malloc'd %d bytes\n", ms->shading_image, ms->bpl * ms->src_remaining_lines); if ( ms->shading_image == NULL ) { DBG(1, "read_shading_image: malloc for buffer failed\n"); return SANE_STATUS_NO_MEM; } buf = ms->shading_image; #ifdef TESTBACKEND max_lines = 5000000 / ms->bpl; #else max_lines = sanei_scsi_max_request_size / ms->bpl; #endif if ( max_lines == 0 ) { DBG(1, "read_shading_image: buffer too small\n"); return SANE_STATUS_IO_ERROR; } lines = ms->src_remaining_lines; while ( ms->src_remaining_lines > 0 ) { lines_to_read = MIN(max_lines, ms->src_remaining_lines); ms->src_buffer_size = lines_to_read * ms->bpl; ms->transfer_length = ms->src_buffer_size; #ifdef TESTBACKEND status = scsi_read_sh_w_image(ms, buf); #else status = scsi_read_image(ms, buf, md->shading_depth>8 ? 2 : 1); #endif if ( status != SANE_STATUS_GOOD ) return status; ms->src_remaining_lines -= lines_to_read; buf += ms->src_buffer_size; } status = prepare_shading_data(ms, lines, &md->shading_table_w); if ( status != SANE_STATUS_GOOD ) return status; if ( md_dump >= 3 ) { write_shading_buf_pnm(ms, lines); write_shading_pnm(ms); } /* send shading data to the device */ /* Some models use "read_control bit", and the shading must be */ /* applied by the backend later */ if ( ! (md->model_flags & MD_READ_CONTROL_BIT) ) { status = shading_function(ms, md->shading_table_w); if ( status != SANE_STATUS_GOOD ) return status; ms->word = ms->lut_entry_size == 2 ? 1 : 0; ms->current_color = MS_COLOR_ALL; status = scsi_send_shading(ms, md->shading_table_w, 3 * ms->lut_entry_size * mi->geo_width / mi->calib_divisor, 0); if ( status != SANE_STATUS_GOOD ) return status; } ms->rawdat = 0; ms->stay = 0; md->status.ncalib |= MD_NCALIB_ON; if ( md->model_flags & MD_PHANTOM_C6 ) { md->status.stick &= ~MD_STICK_ON; md->status.reserved17 &= ~MD_RESERVED17_ON; } #ifdef NO_PHANTOMTYPE_SHADING if (mi->model_code == 0x94) md->status.ncalib &= ~MD_NCALIB_ON; #endif status = scsi_send_system_status(md, ms->sfd); if ( status != SANE_STATUS_GOOD ) return status; DBG(100, "free memory for ms->shading_image at %p\n", ms->shading_image); free((void *) ms->shading_image); ms->shading_image = NULL; return SANE_STATUS_GOOD; } /*---------- prepare_shading_data() ------------------------------------------*/ static SANE_Status prepare_shading_data(Microtek2_Scanner *ms, uint32_t lines, uint8_t **data) { /* This function calculates one line of black or white shading data */ /* from the shading image. At the end we have one line. The */ /* color sequence is unchanged. */ #define MICROTEK2_CALIB_USE_MEDIAN Microtek2_Device *md; Microtek2_Info *mi; uint32_t length,line; int color, i; SANE_Status status; #ifdef MICROTEK2_CALIB_USE_MEDIAN uint16_t *sortbuf, value; #else uint32_t value; #endif DBG(30, "prepare_shading_data: ms=%p, lines=%d, *data=%p\n", (void *) ms, lines, *data); md = ms->dev; mi = &md->info[md->scan_source]; status = SANE_STATUS_GOOD; get_lut_size(mi, &ms->lut_size, &ms->lut_entry_size); length = 3 * ms->lut_entry_size * mi->geo_width / mi->calib_divisor; if ( *data == NULL ) { *data = (uint8_t *) malloc(length); DBG(100, "prepare_shading_data: malloc'd %d bytes at %p\n", length, *data); if ( *data == NULL ) { DBG(1, "prepare_shading_data: malloc for shading table failed\n"); return SANE_STATUS_NO_MEM; } } #ifdef MICROTEK2_CALIB_USE_MEDIAN sortbuf = malloc( lines * ms->lut_entry_size ); DBG(100, "prepare_shading_data: sortbuf= %p, malloc'd %d Bytes\n", (void *) sortbuf, lines * ms->lut_entry_size); if ( sortbuf == NULL ) { DBG(1, "prepare_shading_data: malloc for sort buffer failed\n"); return SANE_STATUS_NO_MEM; } #endif switch( mi->data_format ) { case MI_DATAFMT_LPLCONCAT: if ( ms->lut_entry_size == 1 ) { DBG(1, "prepare_shading_data: wordsize == 1 unsupported\n"); return SANE_STATUS_UNSUPPORTED; } for ( color = 0; color < 3; color++ ) { for ( i = 0; i < ( mi->geo_width / mi->calib_divisor ); i++ ) { value = 0; for ( line = 0; line < lines; line++ ) #ifndef MICROTEK2_CALIB_USE_MEDIAN /* average the shading lines to get the shading data */ value += *((uint16_t *) ms->shading_image + line * ( ms->bpl / ms->lut_entry_size ) + color * ( ms->bpl / ms->lut_entry_size / 3 ) + i); value /= lines; *((uint16_t *) *data + color * ( mi->geo_width / mi->calib_divisor ) + i) = (uint16_t) MIN(0xffff, value); #else /* use a median filter to get the shading data -- should be better */ *(sortbuf + line ) = *((uint16_t *) ms->shading_image + line * ( ms->bpl / ms->lut_entry_size ) + color * ( ms->bpl / ms->lut_entry_size / 3 ) + i); qsort(sortbuf, lines, sizeof(uint16_t), (qsortfunc)compare_func_16); value = *(sortbuf + ( lines - 1 ) / 2 ); *((uint16_t *) *data + color * ( mi->geo_width / mi->calib_divisor ) + i) = value; #endif } } break; case MI_DATAFMT_CHUNKY: case MI_DATAFMT_9800: if ( ms->lut_entry_size == 1 ) { DBG(1, "prepare_shading_data: wordsize == 1 unsupported\n"); return SANE_STATUS_UNSUPPORTED; } for ( color = 0; color < 3; color++ ) { for ( i = 0; i < ( mi->geo_width / mi->calib_divisor ); i++ ) { value = 0; for ( line = 0; line < lines; line++ ) #ifndef MICROTEK2_CALIB_USE_MEDIAN /* average the shading lines to get the shading data */ value += *((uint16_t *) ms->shading_image + line * 3 * mi->geo_width / mi->calib_divisor + 3 * i + color); value /= lines; *((uint16_t *) *data + color * ( mi->geo_width / mi->calib_divisor ) + i) = (uint16_t) MIN(0xffff, value); #else /* use a median filter to get the shading data -- should be better */ *(sortbuf + line ) = *((uint16_t *) ms->shading_image + line * 3 * mi->geo_width / mi->calib_divisor + 3 * i + color); qsort(sortbuf, lines, sizeof(uint16_t), (qsortfunc)compare_func_16); value = *(sortbuf + ( lines - 1 ) / 2 ); *((uint16_t *) *data + color * ( mi->geo_width / mi->calib_divisor ) + i) = value; #endif } } break; case MI_DATAFMT_LPLSEGREG: for ( color = 0; color < 3; color++ ) { for ( i = 0; i < ( mi->geo_width / mi->calib_divisor ); i++ ) { value = 0; if ( ms->lut_entry_size == 1 ) { for ( line = 0; line < lines; line++ ) value += *((uint8_t *) ms->shading_image + line * 3 * mi->geo_width / mi->calib_divisor + 3 * i + color); value /= lines; *((uint8_t *) *data + color * ( mi->geo_width / mi->calib_divisor ) + i) = (uint8_t) MIN(0xff, value); } else { for ( line = 0; line < lines; line++ ) value += *((uint16_t *) ms->shading_image + line * 3 * mi->geo_width / mi->calib_divisor + 3 * i + color); value /= lines; #ifndef MICROTEK2_CALIB_USE_MEDIAN *((uint16_t *) *data + color * ( mi->geo_width / mi->calib_divisor ) + i) = (uint16_t) MIN(0xffff, value); #else *((uint16_t *) *data + color * ( mi->geo_width / mi->calib_divisor ) + i) = value; #endif } } } break; default: DBG(1, "prepare_shading_data: Unsupported data format 0x%02x\n", mi->data_format); status = SANE_STATUS_UNSUPPORTED; } #ifdef MICROTEK2_CALIB_USE_MEDIAN DBG(100, "prepare_shading_data: free sortbuf at %p\n", (void *) sortbuf); free(sortbuf); sortbuf = NULL; #endif return status; } /*---------- read_cx_shading() -----------------------------------------------*/ static SANE_Status read_cx_shading(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; md = ms->dev; DBG(30, "read_cx_shading: ms=%p\n",(void *) ms); md->shading_table_contents = ms->mode; if ( ms->mode == MS_MODE_COLOR ) ms->current_color = MS_COLOR_ALL; else ms->current_color = MS_COLOR_GREEN; /* for grayscale */ ms->word = 1; ms->dark = 0; status = read_cx_shading_image(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; ms->word = 0; /* the Windows driver reads dark shading with word=0 */ ms->dark = 1; status = read_cx_shading_image(ms); if ( status != SANE_STATUS_GOOD ) goto cleanup; return SANE_STATUS_GOOD; cleanup: cleanup_scanner(ms); return status; } /*---------- read_cx_shading_image() -----------------------------------------*/ static SANE_Status read_cx_shading_image(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; uint32_t shading_bytes, linesize, buffer_size; uint8_t *buf; int max_lines, lines_to_read, remaining_lines; md = ms->dev; shading_bytes = ms->n_control_bytes * 8 * md->shading_length; if ( ms->current_color == MS_COLOR_ALL ) shading_bytes *= 3; if ( ms->word == 1 ) shading_bytes *= 2; if ( ms->shading_image ) { free((void *) ms->shading_image); ms->shading_image = NULL; } ms->shading_image = malloc(shading_bytes); DBG(100, "read_cx_shading: ms->shading_image=%p, malloc'd %d bytes\n", ms->shading_image, shading_bytes); if ( ms->shading_image == NULL ) { DBG(1, "read_cx_shading: malloc for cx_shading buffer failed\n"); return SANE_STATUS_NO_MEM; } buf = ms->shading_image; DBG(30, "read_cx_shading_image: ms=%p, shading_bytes=%d\n", (void *) ms, shading_bytes); linesize = shading_bytes / md->shading_length; #ifdef TESTBACKEND max_lines = 5000000 / linesize; #else max_lines = sanei_scsi_max_request_size / linesize; #endif /* the following part is like in "read_shading_image" */ remaining_lines = md->shading_length; while ( remaining_lines > 0 ) { lines_to_read = MIN(max_lines, remaining_lines); buffer_size = lines_to_read * linesize; status = scsi_read_shading(ms, buf, buffer_size); if ( status != SANE_STATUS_GOOD ) { DBG(1, "read_cx_shading: '%s'\n", sane_strstatus(status)); return status; } remaining_lines -= lines_to_read; buf += buffer_size; } status = calc_cx_shading_line(ms); if ( status != SANE_STATUS_GOOD ) { DBG(1, "read_cx_shading: '%s'\n", sane_strstatus(status)); return status; } if ( ms->shading_image ) { DBG(100, "free memory for ms->shading_image at %p\n", ms->shading_image); free((void *) ms->shading_image); ms->shading_image = NULL; } return status; } /*---------- calc_cx_shading_line() ------------------------------------------*/ /* calculates the mean value of the shading lines and stores one line of */ /* 8-bit shading data. Scanning direction + color sequence remain as they are */ /* ToDo: more than 8-bit data */ static SANE_Status calc_cx_shading_line(Microtek2_Scanner *ms) { Microtek2_Device *md; SANE_Status status; uint8_t *current_byte, *buf, *shading_table_pointer; uint8_t color, factor; uint32_t shading_line_pixels, shading_line_bytes, shading_data_bytes, line, i, accu, color_offset; uint16_t *sortbuf, value; md = ms->dev; status = SANE_STATUS_GOOD; sortbuf = malloc( md->shading_length * sizeof(float) ); DBG(100, "calc_cx_shading: sortbuf= %p, malloc'd %lu Bytes\n", (void *) sortbuf, (u_long) (md->shading_length * sizeof(float))); if ( sortbuf == NULL ) { DBG(1, "calc_cx_shading: malloc for sort buffer failed\n"); return SANE_STATUS_NO_MEM; } buf = ms->shading_image; shading_line_pixels = ms->n_control_bytes * 8; /* = 2560 for 330CX */ shading_line_bytes = shading_line_pixels; /* grayscale */ if ( ms->mode == MS_MODE_COLOR ) /* color */ shading_line_bytes *= 3; shading_data_bytes = shading_line_bytes; /* 8-bit color depth */ if (ms->word == 1) /* > 8-bit color depth */ shading_data_bytes *= 2; factor = 4; /* shading bit depth = 10bit; shading line bit depth = 8bit */ if (ms->dark == 0) /* white shading data */ { if ( md->shading_table_w ) free( (void *)md->shading_table_w ); md->shading_table_w = (uint8_t *) malloc(shading_line_bytes); DBG(100, "calc_cx_shading: md->shading_table_w=%p, malloc'd %d bytes\n", md->shading_table_w, shading_line_bytes); if ( md->shading_table_w == NULL ) { DBG(100, "calc_cx_shading: malloc for white shadingtable failed\n"); status = SANE_STATUS_NO_MEM; cleanup_scanner(ms); } shading_table_pointer = md->shading_table_w; } else /* dark shading data */ { if ( md->shading_table_d ) free( (void *)md->shading_table_d); md->shading_table_d = (uint8_t *) malloc(shading_line_bytes); DBG(100, "calc_cx_shading: md->shading_table_d=%p, malloc'd %d bytes\n", md->shading_table_d, shading_line_bytes); if ( md->shading_table_d == NULL ) { DBG(1, "calc_cx_shading: malloc for dark shading table failed\n"); status = SANE_STATUS_NO_MEM; cleanup_scanner(ms); } shading_table_pointer = md->shading_table_d; } DBG(30, "calc_cx_shading_line: ms=%p\n" "md->shading_table_w=%p\n" "md->shading_table_d=%p\n" "shading_line_bytes=%d\n" "shading_line_pixels=%d\n" "shading_table_pointer=%p\n", (void *) ms, md->shading_table_w, md->shading_table_d, shading_line_bytes, shading_line_pixels, shading_table_pointer); /* calculating the median pixel values over the shading lines */ /* and write them to the shading table */ for (color = 0; color < 3; color++) { color_offset = color * shading_line_pixels; if ( ms->word == 1 ) color_offset *=2; for (i = 0; i < shading_line_pixels; i++) { value = 0; for (line = 0; line < md->shading_length; line++) { current_byte = buf + ( line * shading_data_bytes ) + color_offset + i; accu = *current_byte; /* word shading data: the lower bytes per line and color are */ /* transfered first in one block and then the high bytes */ /* in one block */ /* the dark shading data is also 10 bit, but only the */ /* low byte is transferred (ms->word = 0) */ if ( ms->word == 1 ) { current_byte = buf + ( line * shading_data_bytes ) + color_offset + shading_line_pixels + i; accu += ( *current_byte * 256 ); } *( sortbuf + line ) = accu; } /* this is the Median filter: sort the values ascending and take the middlest */ qsort(sortbuf, md->shading_length, sizeof(float), (qsortfunc)compare_func_16); value = *( sortbuf + ( md->shading_length - 1 ) / 2 ); *shading_table_pointer = (uint8_t) (value / factor); shading_table_pointer++; } if ( ms->mode != MS_MODE_COLOR ) break; } return status; } /*---------- get_lut_size() --------------------------------------------------*/ static SANE_Status get_lut_size(Microtek2_Info *mi, int *max_lut_size, int *lut_entry_size) { /* returns the maximum lookup table size. A device might indicate */ /* several lookup table sizes. */ DBG(30, "get_lut_size: mi=%p\n", (void *) mi); *max_lut_size = 0; *lut_entry_size = 0; /* Normally this function is used for both gamma and shading tables */ /* If, however, the device indicates, that it does not support */ /* lookup tables, we set these values as if the device has a maximum */ /* bitdepth of 12, and these values are only used to determine the */ /* size of the shading table */ if ( MI_LUTCAP_NONE(mi->lut_cap) ) { *max_lut_size = 4096; *lut_entry_size = 2; } if ( mi->lut_cap & MI_LUTCAP_256B ) { *max_lut_size = 256; *lut_entry_size = 1; } if ( mi->lut_cap & MI_LUTCAP_1024B ) { *max_lut_size = 1024; *lut_entry_size = 1; } if ( mi->lut_cap & MI_LUTCAP_1024W ) { *max_lut_size = 1024; *lut_entry_size = 2; } if ( mi->lut_cap & MI_LUTCAP_4096B ) { *max_lut_size = 4096; *lut_entry_size = 1; } if ( mi->lut_cap & MI_LUTCAP_4096W ) { *max_lut_size = 4096; *lut_entry_size = 2; } if ( mi->lut_cap & MI_LUTCAP_64k_W ) { *max_lut_size = 65536; *lut_entry_size = 2; } if ( mi->lut_cap & MI_LUTCAP_16k_W ) { *max_lut_size = 16384; *lut_entry_size = 2; } DBG(30, "get_lut_size: mi=%p, lut_size=%d, lut_entry_size=%d\n", (void *) mi, *max_lut_size, *lut_entry_size); return SANE_STATUS_GOOD; } /*---------- calculate_gamma() -----------------------------------------------*/ static SANE_Status calculate_gamma(Microtek2_Scanner *ms, uint8_t *pos, int color, char *mode) { Microtek2_Device *md; Microtek2_Info *mi; double exp; double mult; double steps; unsigned int val; int i; int factor; /* take into account the differences between the */ /* possible values for the color and the number */ /* of bits the scanner works with internally. */ /* If depth == 1 handle this as if the maximum */ /* depth was chosen */ DBG(30, "calculate_gamma: ms=%p, pos=%p, color=%d, mode=%s\n", (void *) ms, pos, color, mode); md = ms->dev; mi = &md->info[md->scan_source]; /* does this work everywhere ? */ if ( md->model_flags & MD_NO_GAMMA ) { factor = 1; mult = (double) (ms->lut_size - 1); } else { if ( mi->depth & MI_HASDEPTH_16 ) { factor = ms->lut_size / 65536; mult = 65535.0; } else if ( mi->depth & MI_HASDEPTH_14 ) { factor = ms->lut_size / 16384; mult = 16383.0; } else if ( mi->depth & MI_HASDEPTH_12 ) { factor = ms->lut_size / 4096; mult = 4095.0; } else if ( mi->depth & MI_HASDEPTH_10 ) { factor = ms->lut_size / 1024; mult = 1023.0; } else { factor = ms->lut_size / 256; mult = 255.0; } } #if 0 factor = ms->lut_size / (int) pow(2.0, (double) ms->depth); mult = pow(2.0, (double) ms->depth) - 1.0; /* depending on output size */ #endif steps = (double) (ms->lut_size - 1); /* depending on input size */ DBG(30, "calculate_gamma: factor=%d, mult =%f, steps=%f, mode=%s\n", factor, mult, steps, ms->val[OPT_GAMMA_MODE].s); if ( strcmp(mode, MD_GAMMAMODE_SCALAR) == 0 ) { int option; option = OPT_GAMMA_SCALAR; /* OPT_GAMMA_SCALAR_R follows OPT_GAMMA_SCALAR directly */ if ( ms->val[OPT_GAMMA_BIND].w == SANE_TRUE ) exp = 1.0 / SANE_UNFIX(ms->val[option].w); else exp = 1.0 / SANE_UNFIX(ms->val[option + color + 1].w); for ( i = 0; i < ms->lut_size; i++ ) { val = (unsigned int) (mult * pow((double) i / steps, exp) + .5); if ( ms->lut_entry_size == 2 ) *((uint16_t *) pos + i) = (uint16_t) val; else *((uint8_t *) pos + i) = (uint8_t) val; } } else if ( strcmp(mode, MD_GAMMAMODE_CUSTOM) == 0 ) { int option; SANE_Int *src; option = OPT_GAMMA_CUSTOM; if ( ms->val[OPT_GAMMA_BIND].w == SANE_TRUE ) src = ms->val[option].wa; else src = ms->val[option + color + 1].wa; for ( i = 0; i < ms->lut_size; i++ ) { if ( ms->lut_entry_size == 2 ) *((uint16_t *) pos + i) = (uint16_t) (src[i] / factor); else *((uint8_t *) pos + i) = (uint8_t) (src[i] / factor); } } else if ( strcmp(mode, MD_GAMMAMODE_LINEAR) == 0 ) { for ( i = 0; i < ms->lut_size; i++ ) { if ( ms->lut_entry_size == 2 ) *((uint16_t *) pos + i) = (uint16_t) (i / factor); else *((uint8_t *) pos + i) = (uint8_t) (i / factor); } } return SANE_STATUS_GOOD; } /*---------- shading_function() ----------------------------------------------*/ static SANE_Status shading_function(Microtek2_Scanner *ms, uint8_t *data) { Microtek2_Device *md; Microtek2_Info *mi; uint32_t value; int color; int i; DBG(40, "shading_function: ms=%p, data=%p\n", (void *) ms, data); md = ms->dev; mi = &md->info[md->scan_source]; /* mi = &md->info[MD_SOURCE_FLATBED]; */ if ( ms->lut_entry_size == 1 ) { DBG(1, "shading_function: wordsize = 1 unsupported\n"); return SANE_STATUS_IO_ERROR; } for ( color = 0; color < 3; color++ ) { for ( i = 0; i < ( mi->geo_width / mi->calib_divisor ); i++) { value = *((uint16_t *) data + color * ( mi->geo_width / mi->calib_divisor ) + i); switch ( mi->shtrnsferequ ) { case 0x00: /* output == input */ break; case 0x01: value = (ms->lut_size * ms->lut_size) / value; *((uint16_t *) data + color * ( mi->geo_width / mi->calib_divisor ) + i) = (uint16_t) MIN(0xffff, value); break; case 0x11: value = (ms->lut_size * ms->lut_size) / (uint32_t) ( (double) value * ((double) mi->balance[color] / 255.0)); *((uint16_t *) data + color * ( mi->geo_width / mi->calib_divisor ) + i) = (uint16_t) MIN(0xffff, value); break; case 0x15: value = (uint32_t) ( ( 1073741824 / (double) value ) * ( (double) mi->balance[color] / 256.0) ); value = MIN(value, (uint32_t)65535); *((uint16_t *) data + color * ( mi->geo_width / mi->calib_divisor ) + i) = (uint16_t) MIN(0xffff, value); break; default: DBG(1, "Unsupported shading transfer function 0x%02x\n", mi->shtrnsferequ ); break; } } } return SANE_STATUS_GOOD; } /*---------- set_exposure() --------------------------------------------------*/ static void set_exposure(Microtek2_Scanner *ms) { /* This function manipulates the colors according to the exposure time */ /* settings on models where they are ignored. Currently this seems to */ /* be the case for all models with the data format chunky data. They */ /* all have tables with two byte gamma output, so for now we ignore */ /* gamma tables with one byte output */ Microtek2_Device *md; Microtek2_Info *mi; int color; int size; int depth; int maxval; int byte; uint32_t val32; uint8_t *from; uint8_t exposure; uint8_t exposure_rgb[3]; DBG(30, "set_exposure: ms=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; if ( ms->lut_entry_size == 1 ) { DBG(1, "set_exposure: 1 byte gamma output tables currently ignored\n"); return; } if ( mi->depth & MI_HASDEPTH_16 ) depth = 16; else if ( mi->depth & MI_HASDEPTH_14 ) depth = 14; else if ( mi->depth & MI_HASDEPTH_12 ) depth = 12; else if ( mi->depth & MI_HASDEPTH_10 ) depth = 10; else depth = 8; maxval = ( 1 << depth ) - 1; from = ms->gamma_table; size = ms->lut_size; /* first master channel, apply transformation to all colors */ exposure = ms->exposure_m; for ( byte = 0; byte < ms->lut_size; byte++ ) { for ( color = 0; color < 3; color++) { val32 = (uint32_t) *((uint16_t *) from + color * size + byte); val32 = MIN(val32 + val32 * (2 * (uint32_t) exposure / 100), (uint32_t) maxval); *((uint16_t *) from + color * size + byte) = (uint16_t) val32; } } /* and now apply transformation to each channel */ exposure_rgb[0] = ms->exposure_r; exposure_rgb[1] = ms->exposure_g; exposure_rgb[2] = ms->exposure_b; for ( color = 0; color < 3; color++ ) { for ( byte = 0; byte < size; byte++ ) { val32 = (uint32_t) *((uint16_t *) from + color * size + byte); val32 = MIN(val32 + val32 * (2 * (uint32_t) exposure_rgb[color] / 100), (uint32_t) maxval); *((uint16_t *) from + color * size + byte) = (uint16_t) val32; } } return; } /*---------- reader_process() ------------------------------------------------*/ static int reader_process(void *data) { Microtek2_Scanner *ms = (Microtek2_Scanner *) data; SANE_Status status; Microtek2_Info *mi; Microtek2_Device *md; struct SIGACTION act; sigset_t sigterm_set; static uint8_t *temp_current = NULL; DBG(30, "reader_process: ms=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; if (sanei_thread_is_forked()) close(ms->fd[0]); sigemptyset (&sigterm_set); sigaddset (&sigterm_set, SIGTERM); memset (&act, 0, sizeof (act)); act.sa_handler = signal_handler; sigaction (SIGTERM, &act, 0); ms->fp = fdopen(ms->fd[1], "w"); if ( ms->fp == NULL ) { DBG(1, "reader_process: fdopen() failed, errno=%d\n", errno); return SANE_STATUS_IO_ERROR; } if ( ms->auto_adjust == 1 ) { if ( temp_current == NULL ) temp_current = ms->temporary_buffer; } while ( ms->src_remaining_lines > 0 ) { ms->src_lines_to_read = MIN(ms->src_remaining_lines, ms->src_max_lines); ms->transfer_length = ms->src_lines_to_read * ms->bpl; DBG(30, "reader_process: transferlength=%d, lines=%d, linelength=%d, " "real_bpl=%d, srcbuf=%p\n", ms->transfer_length, ms->src_lines_to_read, ms->bpl, ms->real_bpl, ms->buf.src_buf); sigprocmask (SIG_BLOCK, &sigterm_set, 0); status = scsi_read_image(ms, ms->buf.src_buf, (ms->depth > 8) ? 2 : 1); sigprocmask (SIG_UNBLOCK, &sigterm_set, 0); if ( status != SANE_STATUS_GOOD ) return SANE_STATUS_IO_ERROR; ms->src_remaining_lines -= ms->src_lines_to_read; /* prepare data for frontend */ switch (ms->mode) { case MS_MODE_COLOR: if ( ! mi->onepass ) /* TODO */ { DBG(1, "reader_process: 3 pass not yet supported\n"); return SANE_STATUS_IO_ERROR; } else { switch ( mi->data_format ) { case MI_DATAFMT_CHUNKY: case MI_DATAFMT_9800: status = chunky_proc_data(ms); if ( status != SANE_STATUS_GOOD ) return status; break; case MI_DATAFMT_LPLCONCAT: status = lplconcat_proc_data(ms); if ( status != SANE_STATUS_GOOD ) return status; break; case MI_DATAFMT_LPLSEGREG: status = segreg_proc_data(ms); if ( status != SANE_STATUS_GOOD ) return status; break; case MI_DATAFMT_WORDCHUNKY: status = wordchunky_proc_data(ms); if ( status != SANE_STATUS_GOOD ) return status; break; default: DBG(1, "reader_process: format %d\n", mi->data_format); return SANE_STATUS_IO_ERROR; } } break; case MS_MODE_GRAY: status = gray_proc_data(ms); if ( status != SANE_STATUS_GOOD ) return status; break; case MS_MODE_HALFTONE: case MS_MODE_LINEART: status = proc_onebit_data(ms); if ( status != SANE_STATUS_GOOD ) return status; break; case MS_MODE_LINEARTFAKE: if ( ms->auto_adjust == 1 ) status = auto_adjust_proc_data(ms, &temp_current); else status = lineartfake_proc_data(ms); if ( status != SANE_STATUS_GOOD ) return status; break; default: DBG(1, "reader_process: Unknown scan mode %d\n", ms->mode); return SANE_STATUS_IO_ERROR; } } fclose(ms->fp); return SANE_STATUS_GOOD; } /*---------- chunky_proc_data() ----------------------------------------------*/ static SANE_Status chunky_proc_data(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; uint32_t line; uint8_t *from; int pad; int bpp; /* bytes per pixel */ int bits_pp_in; /* bits per pixel input */ int bits_pp_out; /* bits per pixel output */ int bpl_ppl_diff; DBG(30, "chunky_proc_data: ms=%p\n", (void *) ms); md = ms->dev; 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; bpp = bits_pp_out / 8; /* Some models have 3 * ppl + 6 bytes per line if the number of pixels */ /* per line is even and 3 * ppl + 3 bytes per line if the number of */ /* pixels per line is odd. According to the documentation it should be */ /* bpl = 3*ppl (even number of pixels) or bpl=3*ppl+1 (odd number of */ /* pixels. Even worse: On different models it is different at which */ /* position in a scanline the image data starts. bpl_ppl_diff tries */ /* to fix this. */ if ( (md->model_flags & MD_OFFSET_2) && pad == 1 ) bpl_ppl_diff = 2; else bpl_ppl_diff = 0; #if 0 if ( md->revision == 1.00 && mi->model_code != 0x81 ) bpl_ppl_diff = ms->bpl - ( 3 * ms->ppl * bpp ) - pad; else bpl_ppl_diff = ms->bpl - ( 3 * ms->ppl * bpp ); if ( md->revision > 1.00 ) bpl_ppl_diff = ms->bpl - ( 3 * ms->ppl * bpp ); else bpl_ppl_diff = ms->bpl - ( 3 * ms->ppl * bpp ) - pad; #endif from = ms->buf.src_buf; from += bpl_ppl_diff; DBG(30, "chunky_proc_data: lines=%d, bpl=%d, ppl=%d, bpp=%d, depth=%d" " junk=%d\n", ms->src_lines_to_read, ms->bpl, ms->ppl, bpp, ms->depth, bpl_ppl_diff); for ( line = 0; line < (uint32_t) ms->src_lines_to_read; line++ ) { status = chunky_copy_pixels(ms, from); if ( status != SANE_STATUS_GOOD ) return status; from += ms->bpl; } return SANE_STATUS_GOOD; } /*---------- chunky_copy_pixels() --------------------------------------------*/ static SANE_Status chunky_copy_pixels(Microtek2_Scanner *ms, uint8_t *from) { Microtek2_Device *md; uint32_t pixel; int color; DBG(30, "chunky_copy_pixels: from=%p, pixels=%d, fp=%p, depth=%d\n", from, ms->ppl, (void *) ms->fp, ms->depth); md = ms->dev; if ( ms->depth > 8 ) { if ( !( md->model_flags & MD_16BIT_TRANSFER ) ) { int scale1; int scale2; uint16_t val16; scale1 = 16 - ms->depth; scale2 = 2 * ms->depth - 16; for ( pixel = 0; pixel < ms->ppl; pixel++ ) { for ( color = 0; color < 3; color++ ) { val16 = *( (uint16_t *) from + 3 * pixel + color ); val16 = ( val16 << scale1 ) | ( val16 >> scale2 ); fwrite((void *) &val16, 2, 1, ms->fp); } } } else { fwrite((void *) from, 2, 3 * ms->ppl, ms->fp); } } else if ( ms->depth == 8 ) { fwrite((void *) from, 1, 3 * ms->ppl, ms->fp); } else { DBG(1, "chunky_copy_pixels: Unknown depth %d\n", ms->depth); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /*---------- segreg_proc_data() ----------------------------------------------*/ static SANE_Status segreg_proc_data(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; Microtek2_Info *mi; char colormap[] = "RGB"; uint8_t *from; uint32_t lines_to_deliver; int bpp; /* bytes per pixel */ int bpf; /* bytes per frame including color indicator */ int pad; int colseq2; int color; int save_current_src; int frame; DBG(30, "segreg_proc_data: ms=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; /* take a trailing junk byte into account */ 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; 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", ms->src_lines_to_read, ms->bpl, ms->ppl, bpf, bpp, ms->depth, pad, ms->buf.free_lines, ms->calib_backend); /* determine how many planes of each color are in the source buffer */ from = ms->buf.src_buf; for ( frame = 0; frame < 3 * ms->src_lines_to_read; frame++, from += bpf ) { switch ( *from ) { case 'R': ++ms->buf.planes[0][MS_COLOR_RED]; break; case 'G': ++ms->buf.planes[0][MS_COLOR_GREEN]; break; case 'B': ++ms->buf.planes[0][MS_COLOR_BLUE]; break; default: DBG(1, "segreg_proc_data: unknown color indicator (1) " "0x%02x\n", *from); return SANE_STATUS_IO_ERROR; } } ms->buf.free_lines -= ms->src_lines_to_read; save_current_src = ms->buf.current_src; if ( ms->buf.free_lines < ms->src_max_lines ) { ms->buf.current_src = !ms->buf.current_src; ms->buf.src_buf = ms->buf.src_buffer[ms->buf.current_src]; ms->buf.free_lines = ms->buf.free_max_lines; } else ms->buf.src_buf += ms->src_lines_to_read * ms->bpl; colseq2 = mi->color_sequence[2]; lines_to_deliver = ms->buf.planes[0][colseq2] + ms->buf.planes[1][colseq2]; if ( lines_to_deliver == 0 ) return SANE_STATUS_GOOD; DBG(30, "segreg_proc_data: planes[0][0]=%d, planes[0][1]=%d, " "planes[0][2]=%d\n", ms->buf.planes[0][0], ms->buf.planes[0][1], ms->buf.planes[0][2] ); DBG(30, "segreg_proc_data: planes[1][0]=%d, planes[1][1]=%d, " "planes[1][2]=%d\n", ms->buf.planes[1][0], ms->buf.planes[1][1], ms->buf.planes[1][2] ); while ( lines_to_deliver > 0 ) { for ( color = 0; color < 3; color++ ) { /* get the position of the next plane for each color */ do { if ( *ms->buf.current_pos[color] == colormap[color] ) break; ms->buf.current_pos[color] += bpf; } while ( 1 ); ms->buf.current_pos[color] += 2; /* skip color indicator */ } status = segreg_copy_pixels(ms); if ( status != SANE_STATUS_GOOD ) { DBG(1, "segreg_copy_pixels:status %d\n", status); return status; } for ( color = 0; color < 3; color++ ) { /* skip a padding byte at the end, if present */ ms->buf.current_pos[color] += pad; if ( ms->buf.planes[1][color] > 0 ) { --ms->buf.planes[1][color]; if ( ms->buf.planes[1][color] == 0 ) /* we have copied from the prehold buffer and are */ /* done now, we continue with the source buffer */ ms->buf.current_pos[color] = ms->buf.src_buffer[save_current_src]; } else { --ms->buf.planes[0][color]; if ( ms->buf.planes[0][color] == 0 && ms->buf.current_src != save_current_src ) ms->buf.current_pos[color] = ms->buf.src_buffer[ms->buf.current_src]; } } DBG(100, "planes_to_deliver=%d\n", lines_to_deliver); --lines_to_deliver; } if ( ms->buf.current_src != save_current_src ) { for ( color = 0; color < 3; color++ ) { ms->buf.planes[1][color] += ms->buf.planes[0][color]; ms->buf.planes[0][color] = 0; } } DBG(30, "segreg_proc_data: src_buf=%p, free_lines=%d\n", ms->buf.src_buf, ms->buf.free_lines); return SANE_STATUS_GOOD; } /*---------- segreg_copy_pixels() --------------------------------------------*/ static SANE_Status segreg_copy_pixels(Microtek2_Scanner *ms) { Microtek2_Device *md; Microtek2_Info *mi; uint32_t pixel; int color, i, gamma_by_backend, right_to_left, scale1, scale2, bpp_in; float s_w, s_d; /* shading byte from condensed_shading */ float val, maxval = 0, shading_factor = 0; uint16_t val16 = 0; uint8_t val8 = 0; uint8_t *from_effective; uint8_t *gamma[3]; float f[3]; /* color balance factor */ md = ms->dev; mi = &md->info[md->scan_source]; gamma_by_backend = md->model_flags & MD_NO_GAMMA ? 1 : 0; right_to_left = mi->direction & MI_DATSEQ_RTOL; scale1 = 16 - ms->depth; scale2 = 2 * ms->depth - 16; bpp_in = ( ms->bits_per_pixel_in + 7 ) / 8; /*Bytes per pixel from scanner*/ if ((md->model_flags & MD_READ_CONTROL_BIT) && ms->calib_backend) { maxval = (float) pow(2.0, (float) ms->depth) - 1.0; s_w = maxval; s_d = 0.0; shading_factor = (float) pow(2.0, (double) (md->shading_depth - ms->depth) ); } if ( gamma_by_backend ) { i = (ms->depth > 8) ? 2 : 1; for ( color = 0; color < 3; color++) gamma[color] = ms->gamma_table + i * (int) pow(2.0, (double)ms->depth); } DBG(30, "segreg_copy_pixels: pixels=%d\n", ms->ppl); DBG(100, "segreg_copy_pixels: buffer 0x%p, right_to_left=%d, depth=%d\n", (void *) ms->buf.current_pos, right_to_left, ms->depth); for (color = 0; color < 3; color++ ) f[color] = (float) ms->balance[color] / 100.0; DBG(100, "segreg_copy_pixels: color balance:\n" " ms->balance[R]=%d, ms->balance[G]=%d, ms->balance[B]=%d\n", ms->balance[0], ms->balance[1], ms->balance[2]); for ( pixel = 0; pixel < ms->ppl; pixel++ ) { for ( color = 0; color < 3; color++ ) { if ( right_to_left ) from_effective = ms->buf.current_pos[color] + ( ms->ppl - 1 - pixel ) * bpp_in; else from_effective = ms->buf.current_pos[color] + pixel * bpp_in; if ( ms->depth > 8 ) val = (float) *(uint16_t *)from_effective; else if ( ms->depth == 8 ) val = (float) *from_effective; else { DBG(1, "segreg_copy_pixels: Unknown depth %d\n", ms->depth); return SANE_STATUS_IO_ERROR; } if ((md->model_flags & MD_READ_CONTROL_BIT) && ms->calib_backend && ( ms->condensed_shading_w != NULL )) /* apply shading by backend */ { get_cshading_values(ms, color, pixel, shading_factor, right_to_left, &s_d, &s_w); if ( s_w == s_d ) s_w = s_d + 1; if ( val < s_d ) val = s_d; val = maxval *( val - s_d ) / ( s_w - s_d ); val *= f[color]; /* if scanner doesn't support brightness, contrast */ if ( md->model_flags & MD_NO_ENHANCEMENTS ) { val += ( ( ms->brightness_m - 128 ) * 2 ); val = ( val - 128 ) * ( ms->contrast_m / 128 ) + 128; } val = MAX( 0.0, val); val = MIN( maxval, val ); } val16 = (uint16_t) val; val8 = (uint8_t) val; /* apply gamma correction if needed */ if ( gamma_by_backend ) { if ( ms->depth > 8 ) val16 = *((uint16_t *) gamma[color] + val16); else val8 = gamma[color][val8]; } if ( ms->depth > 8 ) { val16 = ( val16 << scale1 ) | ( val16 >> scale2 ); fwrite((void *) &val16, 2, 1, ms->fp); } else { fputc((unsigned char) val8, ms->fp); } } } for ( color = 0; color < 3; color++ ) { ms->buf.current_pos[color] += ms->ppl; if ( ms->depth > 8 ) ms->buf.current_pos[color] += ms->ppl; } return SANE_STATUS_GOOD; } /*---------- lplconcat_proc_data() -------------------------------------------*/ static SANE_Status lplconcat_proc_data(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; Microtek2_Info *mi; uint32_t line; uint8_t *from[3]; uint8_t *save_from[3]; int color; int bpp; int gamma_by_backend; int right_to_left; /* 0=left to right, 1=right to left */ DBG(30, "lplconcat_proc_data: ms=%p\n", (void *) ms); /* This data format seems to honour the color sequence indicator */ md = ms->dev; mi = &md->info[md->scan_source]; bpp = ms->bits_per_pixel_out / 8; /* ms->bits_per_pixel_out is 8 or 16 */ right_to_left = mi->direction & MI_DATSEQ_RTOL; gamma_by_backend = md->model_flags & MD_NO_GAMMA ? 1 : 0; if ( right_to_left == 1 ) { for ( color = 0; color < 3; color++ ) { from[color] = ms->buf.src_buf + ( mi->color_sequence[color] + 1 ) * ( ms->bpl / 3 ) - bpp - (ms->bpl - 3 * ms->ppl * bpp) / 3; } } else for ( color = 0; color < 3; color++ ) from[color] = ms->buf.src_buf + mi->color_sequence[color] * ( ms->bpl / 3 ); for ( line = 0; line < (uint32_t) ms->src_lines_to_read; line++ ) { for ( color = 0 ; color < 3; color++ ) save_from[color] = from[color]; status = lplconcat_copy_pixels(ms, from, right_to_left, gamma_by_backend); if ( status != SANE_STATUS_GOOD ) return status; for ( color = 0; color < 3; color++ ) from[color] = save_from[color] + ms->bpl; } return SANE_STATUS_GOOD; } /*---------- lplconcat_copy_pixels() -----------------------------------------*/ static SANE_Status lplconcat_copy_pixels(Microtek2_Scanner *ms, uint8_t **from, int right_to_left, int gamma_by_backend) { Microtek2_Device *md; Microtek2_Info *mi; uint32_t pixel; uint16_t val16 = 0; uint8_t val8 = 0; uint8_t *gamma[3]; float s_d; /* dark shading pixel */ float s_w; /* white shading pixel */ float shading_factor = 0; float f[3]; /* color balance factor */ float val, maxval = 0; int color; int step, scale1, scale2; int i; DBG(30, "lplconcat_copy_pixels: ms=%p, righttoleft=%d, gamma=%d,\n", (void *) ms, right_to_left, gamma_by_backend); md = ms->dev; mi = &md->info[md->scan_source]; if ((md->model_flags & MD_READ_CONTROL_BIT) && ms->calib_backend) { shading_factor = (float) pow(2.0,(double)(md->shading_depth - ms->depth)); maxval = (float) pow(2.0, (double) ms->depth) - 1.0; s_w = maxval; s_d = 0.0; } step = ( right_to_left == 1 ) ? -1 : 1; if ( ms->depth > 8 ) step *= 2; scale1 = 16 - ms->depth; scale2 = 2 * ms->depth - 16; if ( gamma_by_backend ) { i = ( ms->depth > 8 ) ? 2 : 1; for ( color = 0; color < 3; color++ ) gamma[color] = ms->gamma_table + i * (int) pow(2.0,(double)ms->depth); } for (color = 0; color < 3; color++ ) f[color] = (float)ms->balance[color] / 100.0; DBG(100, "lplconcat_copy_pixels: color balance:\n" " ms->balance[R]=%d, ms->balance[G]=%d, ms->balance[B]=%d\n", ms->balance[0], ms->balance[1], ms->balance[2]); for ( pixel = 0; pixel < ms->ppl; pixel++ ) { for ( color = 0; color < 3; color++ ) { if ( ms->depth > 8 ) val = (float) *(uint16_t *) from[color]; else if ( ms->depth == 8 ) val = (float) *from[color]; else { DBG(1, "lplconcat_copy_pixels: Unknown depth %d\n", ms->depth); return SANE_STATUS_IO_ERROR; } if ((md->model_flags & MD_READ_CONTROL_BIT) && ms->calib_backend && ( ms->condensed_shading_w != NULL )) /* apply shading by backend */ { get_cshading_values(ms, mi->color_sequence[color], pixel, shading_factor, right_to_left, &s_d, &s_w); if ( val < s_d ) val = s_d; if ( s_w == s_d ) s_w = s_d + 1; val = ( maxval * ( val - s_d ) ) / (s_w - s_d); val *= f[color]; /* apply color balance */ /* if scanner doesn't support brightness, contrast ... */ if ( md->model_flags & MD_NO_ENHANCEMENTS ) { val += ( ( ms->brightness_m - 128 ) * 2 ); val = ( val - 128 ) * ( ms->contrast_m / 128 ) + 128; } if ( val > maxval ) val = maxval; if ( val < 0.0 ) val = 0.0; } val16 = (uint16_t) val; val8 = (uint8_t) val; /* apply gamma correction if needed */ if ( gamma_by_backend ) { if ( ms->depth > 8 ) val16 = *((uint16_t *) gamma[color] + val16); else val8 = gamma[color][val8]; } if ( ms->depth > 8 ) { val16 = ( val16 << scale1 ) | ( val16 >> scale2 ); fwrite((void *) &val16, 2, 1, ms->fp); } else { fputc((unsigned char) val8, ms->fp); } from[color] += step; } } return SANE_STATUS_GOOD; } /*---------- wordchunky_proc_data() ------------------------------------------*/ static SANE_Status wordchunky_proc_data(Microtek2_Scanner *ms) { SANE_Status status; uint8_t *from; uint32_t line; DBG(30, "wordchunky_proc_data: ms=%p\n", (void *) ms); from = ms->buf.src_buf; for ( line = 0; line < (uint32_t) ms->src_lines_to_read; line++ ) { status = wordchunky_copy_pixels(from, ms->ppl, ms->depth, ms->fp); if ( status != SANE_STATUS_GOOD ) return status; from += ms->bpl; } return SANE_STATUS_GOOD; } /*---------- wordchunky_copy_pixels() ----------------------------------------*/ static SANE_Status wordchunky_copy_pixels(uint8_t *from, uint32_t pixels, int depth, FILE *fp) { uint32_t pixel; int color; DBG(30, "wordchunky_copy_pixels: from=%p, pixels=%d, depth=%d\n", from, pixels, depth); if ( depth > 8 ) { int scale1; int scale2; uint16_t val16; scale1 = 16 - depth; scale2 = 2 * depth - 16; for ( pixel = 0; pixel < pixels; pixel++ ) { for ( color = 0; color < 3; color++ ) { val16 = *(uint16_t *) from; val16 = ( val16 << scale1 ) | ( val16 >> scale2 ); fwrite((void *) &val16, 2, 1, fp); from += 2; } } } else if ( depth == 8 ) { pixel = 0; do { fputc((char ) *from, fp); fputc((char) *(from + 2), fp); fputc((char) *(from + 4), fp); ++pixel; if ( pixel < pixels ) { fputc((char) *(from + 1), fp); fputc((char) *(from + 3), fp); fputc((char) *(from + 5), fp); ++pixel; } from += 6; } while ( pixel < pixels ); } else { DBG(1, "wordchunky_copy_pixels: Unknown depth %d\n", depth); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /*---------- gray_proc_data() ------------------------------------------------*/ static SANE_Status gray_proc_data(Microtek2_Scanner *ms) { SANE_Status status; Microtek2_Device *md; Microtek2_Info *mi; uint8_t *from; int gamma_by_backend, bpp; int right_to_left; /* for scanning direction */ DBG(30, "gray_proc_data: lines=%d, bpl=%d, ppl=%d, depth=%d\n", ms->src_lines_to_read, ms->bpl, ms->ppl, ms->depth); md = ms->dev; mi = &md->info[md->scan_source]; gamma_by_backend = md->model_flags & MD_NO_GAMMA ? 1 : 0; right_to_left = mi->direction & MI_DATSEQ_RTOL; bpp = ( ms->bits_per_pixel_in + 7 ) / 8; if ( right_to_left == 1 ) from = ms->buf.src_buf + ms->ppl * bpp - bpp; else from = ms->buf.src_buf; do { status = gray_copy_pixels(ms, from, right_to_left, gamma_by_backend); if ( status != SANE_STATUS_GOOD ) return status; from += ms->bpl; --ms->src_lines_to_read; } while ( ms->src_lines_to_read > 0 ); return SANE_STATUS_GOOD; } /*---------- gray_copy_pixels() ----------------------------------------------*/ static SANE_Status gray_copy_pixels(Microtek2_Scanner *ms, uint8_t *from, int right_to_left, int gamma_by_backend) { Microtek2_Device *md; uint32_t pixel; uint16_t val16; uint8_t val8; int step, scale1, scale2; float val, maxval = 0; float s_w, s_d, shading_factor = 0; DBG(30, "gray_copy_pixels: pixels=%d, from=%p, fp=%p, depth=%d\n", ms->ppl, from, (void *) ms->fp, ms->depth); md = ms->dev; step = right_to_left == 1 ? -1 : 1; if ( ms->depth > 8 ) step *= 2; val = 0; scale1 = 16 - ms->depth; scale2 = 2 * ms->depth - 16; if ((md->model_flags & MD_READ_CONTROL_BIT) && ms->calib_backend) { maxval = (float) pow(2.0, (float) ms->depth) - 1.0; s_w = maxval; s_d = 0.0; shading_factor = (float) pow(2.0, (double) (md->shading_depth - ms->depth) ); } if ( ms->depth >= 8 ) { for ( pixel = 0; pixel < ms->ppl; pixel++ ) { if ( ms->depth > 8 ) val = (float) *(uint16_t *) from; if ( ms->depth == 8 ) val = (float) *from; if ((md->model_flags & MD_READ_CONTROL_BIT) && ms->calib_backend && ( ms->condensed_shading_w != NULL )) /* apply shading by backend */ { get_cshading_values(ms, 0, pixel, shading_factor, right_to_left, &s_d, &s_w); if ( val < s_d ) val = s_d; val = ( val - s_d ) * maxval / (s_w - s_d ); val = MAX( 0.0, val ); val = MIN( maxval, val ); } if ( ms->depth > 8 ) { val16 = (uint16_t) val; if ( gamma_by_backend ) val16 = *((uint16_t *) ms->gamma_table + val16); if ( !( md->model_flags & MD_16BIT_TRANSFER ) ) val16 = ( val16 << scale1 ) | ( val16 >> scale2 ); fwrite((void *) &val16, 2, 1, ms->fp); } if ( ms->depth == 8 ) { val8 = (uint8_t) val; if ( gamma_by_backend ) val8 = ms->gamma_table[(int)val8]; fputc((char)val8, ms->fp); } from += step; } } else if ( ms->depth == 4 ) { pixel = 0; while ( pixel < ms->ppl ) { fputc((char) ( ((*from >> 4) & 0x0f) | (*from & 0xf0) ), ms->fp); ++pixel; if ( pixel < ms->ppl ) fputc((char) ((*from & 0x0f) | ((*from << 4) & 0xf0)), ms->fp); from += step; ++pixel; } } else { DBG(1, "gray_copy_pixels: Unknown depth %d\n", ms->depth); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /*---------- proc_onebit_data() ----------------------------------------------*/ static SANE_Status proc_onebit_data(Microtek2_Scanner *ms) { Microtek2_Device *md; Microtek2_Info *mi; uint32_t bytes_to_copy; /* bytes per line to copy */ uint32_t line; uint32_t byte; uint32_t ppl; uint8_t *from; uint8_t to; int right_to_left; int bit; int toindex; DBG(30, "proc_onebit_data: ms=%p\n", (void *) ms); md = ms->dev; mi = &md->info[md->scan_source]; from = ms->buf.src_buf; bytes_to_copy = ( ms->ppl + 7 ) / 8 ; right_to_left = mi->direction & MI_DATSEQ_RTOL; DBG(30, "proc_onebit_data: bytes_to_copy=%d, lines=%d\n", bytes_to_copy, ms->src_lines_to_read); line = 0; to = 0; do { /* in onebit mode black and white colors are inverted */ if ( right_to_left ) { /* If the direction is right_to_left, we must skip some */ /* trailing bits at the end of the scan line and invert the */ /* bit sequence. We copy 8 bits into a byte, but these bits */ /* are normally not byte aligned. */ /* Determine the position of the first bit to copy */ ppl = ms->ppl; byte = ( ppl + 7 ) / 8 - 1; bit = ppl % 8 - 1; to = 0; toindex = 8; while ( ppl > 0 ) { to |= ( ( from[byte] >> (7 - bit) ) & 0x01); --toindex; if ( toindex == 0 ) { fputc( (char) ~to, ms->fp); toindex = 8; to = 0; } else to <<= 1; --bit; if ( bit < 0 ) { bit = 7; --byte; } --ppl; } /* print the last byte of the line, if it was not */ /* completely filled */ bit = ms->ppl % 8; if ( bit != 0 ) fputc( (char) ~(to << (7 - bit)), ms->fp); } else for ( byte = 0; byte < bytes_to_copy; byte++ ) fputc( (char) ~from[byte], ms->fp); from += ms->bpl; } while ( ++line < (uint32_t) ms->src_lines_to_read ); return SANE_STATUS_GOOD; } /*---------- lineartfake_proc_data() -----------------------------------------*/ static SANE_Status lineartfake_proc_data(Microtek2_Scanner *ms) { Microtek2_Device *md; Microtek2_Info *mi; SANE_Status status; uint8_t *from; int right_to_left; DBG(30, "lineartfake_proc_data: lines=%d, bpl=%d, ppl=%d, depth=%d\n", ms->src_lines_to_read, ms->bpl, ms->ppl, ms->depth); md = ms->dev; mi = &md->info[md->scan_source]; right_to_left = mi->direction & MI_DATSEQ_RTOL; if ( right_to_left == 1 ) from = ms->buf.src_buf + ms->ppl - 1; else from = ms->buf.src_buf; do { status = lineartfake_copy_pixels(ms, from, ms->ppl, ms->threshold, right_to_left, ms->fp); if ( status != SANE_STATUS_GOOD ) return status; from += ms->bpl; --ms->src_lines_to_read; } while ( ms->src_lines_to_read > 0 ); return SANE_STATUS_GOOD; } /*---------- lineartfake_copy_pixels() ---------------------------------------*/ static SANE_Status lineartfake_copy_pixels(Microtek2_Scanner *ms, uint8_t *from, uint32_t pixels, uint8_t threshold, int right_to_left, FILE *fp) { Microtek2_Device *md; uint32_t pixel; uint32_t bit; uint8_t dest; uint8_t val; float s_d, s_w, maxval, shading_factor, grayval; int step; DBG(30, "lineartfake_copy_pixels: from=%p,pixels=%d,threshold=%d,file=%p\n", from, pixels, threshold, (void *) fp); md = ms->dev; bit = 0; dest = 0; step = right_to_left == 1 ? -1 : 1; maxval = 255.0; s_w = maxval; s_d = 0.0; shading_factor = (float) pow(2.0, (double) (md->shading_depth - 8) ); for ( pixel = 0; pixel < pixels; pixel++ ) { if ((md->model_flags & MD_READ_CONTROL_BIT) && ms->calib_backend && ( ms->condensed_shading_w != NULL )) /* apply shading by backend */ { get_cshading_values(ms, 0, pixel, shading_factor, right_to_left, &s_d, &s_w); } else /* no shading */ { s_w = maxval; s_d = 0.0; } grayval = (float) *from; if ( grayval < s_d ) grayval = s_d; grayval = ( grayval - s_d ) * maxval / (s_w - s_d ); grayval = MAX( 0.0, grayval ); grayval = MIN( maxval, grayval ); if ( (uint8_t)grayval < threshold ) val = 1; else val = 0; dest = ( dest << 1 ) | val; bit = ( bit + 1 ) % 8; if ( bit == 0 ) /* 8 input bytes processed */ { fputc((char) dest, fp); dest = 0; } from += step; } if ( bit != 0 ) { dest <<= 7 - bit; fputc((char) dest, fp); } return SANE_STATUS_GOOD; } /*---------- auto_adjust_proc_data() -----------------------------------------*/ static SANE_Status auto_adjust_proc_data(Microtek2_Scanner *ms, uint8_t **temp_current) { Microtek2_Device *md; Microtek2_Info *mi; SANE_Status status; uint8_t *from; uint32_t line; uint32_t lines; uint32_t pixel; uint32_t threshold; int right_to_left; DBG(30, "auto_adjust_proc_data: ms=%p, temp_current=%p\n", (void *) ms, *temp_current); md = ms->dev; mi = &md->info[md->scan_source]; right_to_left = mi->direction & MI_DATSEQ_RTOL; memcpy(*temp_current, ms->buf.src_buf, ms->transfer_length); *temp_current += ms->transfer_length; threshold = 0; status = SANE_STATUS_GOOD; if ( ms->src_remaining_lines == 0 ) /* we have read all the image data, */ { /* calculate threshold value */ for ( pixel = 0; pixel < ms->remaining_bytes; pixel++ ) threshold += *(ms->temporary_buffer + pixel); threshold /= ms->remaining_bytes; lines = ms->remaining_bytes / ms->bpl; for ( line = 0; line < lines; line++ ) { from = ms->temporary_buffer + line * ms->bpl; if ( right_to_left == 1 ) from += ms->ppl - 1; status = lineartfake_copy_pixels(ms, from, ms->ppl, (uint8_t) threshold, right_to_left, ms->fp); } *temp_current = NULL; } return status; } /*-------------- get_cshading_values -----------------------------------------*/ static SANE_Status get_cshading_values(Microtek2_Scanner *ms, uint8_t color, uint32_t pixel, float shading_factor, int right_to_left, float *s_d, float *s_w) { Microtek2_Device *md; uint32_t csh_offset; md = ms->dev; if ( right_to_left == 1 ) csh_offset = (color + 1) * ms->ppl - 1 - pixel; else csh_offset = color * ms->ppl + pixel; if ( ( md->shading_depth > 8 ) && ( ms->lut_entry_size == 2) ) /* condensed shading is 2 byte color data */ { if ( ms->condensed_shading_d != NULL ) *s_d = (float) *( (uint16_t *)ms->condensed_shading_d + csh_offset ); else *s_d = 0.0; *s_w = (float) *( (uint16_t *)ms->condensed_shading_w + csh_offset ); *s_w /= shading_factor; *s_d /= shading_factor; } else /* condensed shading is 8 bit data */ { *s_w = (float) *( ms->condensed_shading_w + csh_offset ); if ( ms->condensed_shading_d != NULL ) *s_d = (float) *( ms->condensed_shading_d + csh_offset ); else *s_d = 0.0; } return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/epson_scsi.h0000666000000000000000000000130013615534521015100 00000000000000#ifndef _EPSON_SCSI_H_ #define _EPSON_SCSI_H_ #include #include "../include/sane/sane.h" #define TEST_UNIT_READY_COMMAND (0x00) #define READ_6_COMMAND (0x08) #define WRITE_6_COMMAND (0x0a) #define INQUIRY_COMMAND (0x12) #define TYPE_PROCESSOR (0x03) #define INQUIRY_BUF_SIZE (36) SANE_Status sanei_epson_scsi_sense_handler (int scsi_fd, u_char * result, void *arg); SANE_Status sanei_epson_scsi_inquiry (int fd, int page_code, void *buf, size_t * buf_size); int sanei_epson_scsi_read (int fd, void *buf, size_t buf_size, SANE_Status * status); int sanei_epson_scsi_write (int fd, const void *buf, size_t buf_size, SANE_Status * status); #endif sane-backends-1.0.29/backend/as6e.h0000666000000000000000000000630713615534521013605 00000000000000/* sane - Scanner Access Now Easy. Artec AS6E backend. Copyright (C) 2000 Eugene S. Weiss 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a backend for the Artec AS6E by making a bridge to the as6edriver program. The as6edriver program can be found at http://as6edriver.sourceforge.net . */ #ifndef as6e_h #define as6e_h #include #include #include "../include/sane/sane.h" typedef enum { OPT_NUM_OPTS = 0, OPT_MODE, OPT_RESOLUTION, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_BRIGHTNESS, OPT_CONTRAST, /* must come last */ NUM_OPTIONS } AS6E_Option; typedef struct { int color; int resolution; int startpos; int stoppos; int startline; int stopline; int ctloutpipe; int ctlinpipe; int datapipe; } AS6E_Params; typedef struct AS6E_Device { struct AS6E_Device *next; SANE_Device sane; } AS6E_Device; typedef struct AS6E_Scan { struct AS6E_Scan *next; SANE_Option_Descriptor options_list[NUM_OPTIONS]; Option_Value value[NUM_OPTIONS]; SANE_Bool scanning; SANE_Bool cancelled; SANE_Parameters sane_params; AS6E_Params as6e_params; pid_t child_pid; size_t bytes_to_read; SANE_Byte *scan_buffer; SANE_Byte *line_buffer; SANE_Word scan_buffer_count; SANE_Word image_counter; } AS6E_Scan; #ifndef PATH_MAX #define PATH_MAX 1024 #endif #define AS6E_CONFIG_FILE "as6e.conf" #define READPIPE 0 #define WRITEPIPE 1 #define SCAN_BUF_SIZE 32768 #endif /* as6e_h */ sane-backends-1.0.29/backend/pieusb_usb.c0000666000000000000000000005323513615534521015104 00000000000000/* sane - Scanner Access Now Easy. pieusb_usb.c Copyright (C) 2012-2015 Jan Vleeshouwers, Michael Rickmann, Klaus Kaempf 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "pieusb.h" #include "pieusb_scancmd.h" #include "pieusb_usb.h" #include "../include/sane/sanei_usb.h" #include /* usleep */ #include /* time */ /* USB functions */ static SANE_Status _ctrl_out_byte(SANE_Int device_number, SANE_Int port, SANE_Byte b); static SANE_Status _bulk_size(SANE_Int device_number, unsigned int size); static SANE_Status _ctrl_in_byte(SANE_Int device_number, SANE_Byte* b); static SANE_Status _bulk_in(SANE_Int device_number, SANE_Byte* data, size_t *size); static SANE_Status _ieee_command(SANE_Int device_number, SANE_Byte command); /* Defines for use in USB functions */ #define REQUEST_TYPE_IN (USB_TYPE_VENDOR | USB_DIR_IN) #define REQUEST_TYPE_OUT (USB_TYPE_VENDOR | USB_DIR_OUT) #define REQUEST_REGISTER 0x0c #define REQUEST_BUFFER 0x04 #define ANYINDEX 0x00 /* wIndex value for USB control transfer - value is irrelevant */ /* from libieee1284 */ #define C1284_NSTROBE 0x01 #define C1284_NINIT 0x04 /* usb via ieee1284 */ #define IEEE1284_ADDR 0x00 #define IEEE1284_RESET 0x30 #define IEEE1284_SCSI 0xe0 #define PORT_SCSI_SIZE 0x0082 #define PORT_SCSI_STATUS 0x0084 #define PORT_SCSI_CMD 0x0085 #define PORT_PAR_CTRL 0x0087 /* IEEE1284 parallel control */ #define PORT_PAR_DATA 0x0088 /* IEEE1284 parallel data */ /* see also: SCSI Status Codes http://www.t10.org/lists/2status.htm */ typedef enum { USB_STATUS_OK = 0x00, /* ok */ USB_STATUS_READ = 0x01, /* read: send expected length, then read data */ USB_STATUS_CHECK = 0x02, /* check condition */ USB_STATUS_BUSY = 0x03, /* wait on usb */ USB_STATUS_AGAIN = 0x08, /* re-send scsi cmd */ USB_STATUS_FAIL = 0x88, /* ??? */ USB_STATUS_ERROR = 0xff /* usb i/o error */ } PIEUSB_USB_Status; static PIEUSB_USB_Status _pieusb_scsi_command(SANE_Int device_number, SANE_Byte command[], SANE_Byte data[], SANE_Int size); #define SENSE_CODE_WARMING_UP 4 /* Standard SCSI Sense codes*/ #define SCSI_NO_ADDITIONAL_SENSE_INFORMATION 0x00 struct code_text_t { int code; char *text; }; static struct code_text_t usb_code_text[] = { { 0x00, "Ok" }, { 0x01, "Read" }, { 0x02, "Check" }, { 0x03, "Busy" }, { 0x08, "Again" }, { 0xff, "Error" }, { -1, NULL } }; static struct code_text_t scsi_code_text[] = { { 0x00, "Test Unit Ready" } ,{ 0x01, "Calibrate" } ,{ 0x03, "Request Sense" } ,{ 0x04, "Format" } ,{ 0x08, "Read" } ,{ 0x0a, "Write" } ,{ 0x0f, "Get Param" } ,{ 0x10, "Mark" } ,{ 0x11, "Space" } ,{ 0x12, "Inquiry" } ,{ 0x15, "Mode Select" } ,{ 0x16, "Reserve Unit" } ,{ 0x18, "Copy" } ,{ 0x1a, "Mode Sense" } ,{ 0x1b, "Scan" } ,{ 0x1d, "Diagnose" } ,{ 0xa8, "Read Extended" } ,{ 0xd1, "Slide" } ,{ 0xd2, "Set Scan Head" } ,{ 0xd7, "Read Gain Offset" } ,{ 0xdc, "Write Gain Offset" } ,{ 0xdd, "Read State" } ,{ -1, NULL } }; static char * code_to_text(struct code_text_t *list, int code) { while (list && list->text) { if (list->code == code) return list->text; list++; } return "**unknown**"; } /** * Convert PIEUSB_Status to SANE_Status */ SANE_Status sanei_pieusb_convert_status(PIEUSB_Status status) { return (SANE_Status)status; } /** * hex dump 'size' bytes starting at 'ptr' */ static void _hexdump(char *msg, unsigned char *ptr, int size) { unsigned char *lptr = ptr; int count = 0; long start = 0; long clipped = 0; if (DBG_info_proc > DBG_LEVEL) return; if (size > 127) { clipped = size; size = 128; } while (size-- > 0) { if ((count % 16) == 0) { fprintf (stderr, "%s\t%08lx:", msg?msg:"", start); msg = NULL; } fprintf (stderr, " %02x", *ptr++); count++; start++; if (size == 0) { while ((count % 16) != 0) { fprintf (stderr, " "); count++; } } if ((count % 16) == 0) { fprintf (stderr, " "); while (lptr < ptr) { unsigned char c = *lptr & 0x7f; fprintf (stderr, "%c", ((c < 0x20)||(c == 0x7f)) ? '.' : c); lptr++; } fprintf (stderr, "\n"); } } if ((count % 16) != 0) fprintf (stderr, "\n"); if (clipped > 0) fprintf (stderr, "\t%08lx bytes clipped\n", clipped); fflush(stderr); return; } /* ========================================================================= * * USB functions * * ========================================================================= */ /** * Send a command to the device, retry 10 times if device is busy * and return SENSE data in the sense fields of status if there is a CHECK * CONDITION response from the command. * If the REQUEST SENSE command fails, the SANE status code is unequal to * PIEUSB_STATUS_GOOD and the sense fields are empty. * * @param device_number Device number * @param command Command array * @param data Input or output data buffer * @param size Size of the data buffer * @param status Pieusb_Command_Status */ PIEUSB_Status sanei_pieusb_command(SANE_Int device_number, SANE_Byte command[], SANE_Byte data[], SANE_Int size) { #define MAXTIME 60 /* max 60 seconds */ time_t start; SANE_Status sane_status; PIEUSB_Status ret = PIEUSB_STATUS_DEVICE_BUSY; SANE_Byte usbstat; PIEUSB_USB_Status usb_status = USB_STATUS_AGAIN; DBG (DBG_info_usb, "*** sanei_pieusb_command(%02x:%s): size 0x%02x\n", command[0], code_to_text (scsi_code_text, command[0]), size); start = time(NULL); while ((time(NULL)-start) < MAXTIME) { DBG (DBG_info_usb, "\tsanei_pieusb_command loop, status %d:%s\n", usb_status, code_to_text (usb_code_text, usb_status)); if (usb_status == USB_STATUS_AGAIN) { usb_status = _pieusb_scsi_command (device_number, command, data, size); DBG (DBG_info_usb, "\t_pieusb_scsi_command returned %d:%s\n", usb_status, code_to_text (usb_code_text, usb_status)); continue; } if (usb_status == USB_STATUS_OK) { ret = PIEUSB_STATUS_GOOD; break; } if (usb_status == USB_STATUS_READ) { DBG (DBG_error, "\tsanei_pieusb_command() 2nd STATUS_READ ?!\n"); ret = PIEUSB_STATUS_IO_ERROR; break; } if (usb_status == USB_STATUS_CHECK) { /* check condition */ struct Pieusb_Sense sense; struct Pieusb_Command_Status senseStatus; #define SCSI_REQUEST_SENSE 0x03 if (command[0] == SCSI_REQUEST_SENSE) { DBG (DBG_error, "\tsanei_pieusb_command() recursive SCSI_REQUEST_SENSE\n"); ret = PIEUSB_STATUS_INVAL; break; } /* A check sense may be a busy state in disguise * It is also practical to execute a request sense command by * default. The calling function should interpret * PIEUSB_STATUS_CHECK_SENSE as 'sense data available'. */ sanei_pieusb_cmd_get_sense (device_number, &sense, &senseStatus, &ret); if (senseStatus.pieusb_status != PIEUSB_STATUS_GOOD) { DBG (DBG_error, "\tsanei_pieusb_command(): CHECK CONDITION, but REQUEST SENSE fails\n"); ret = senseStatus.pieusb_status; } break; } if (usb_status == USB_STATUS_BUSY) { /* wait on usb */ sane_status = _ctrl_in_byte (device_number, &usbstat); if (sane_status != SANE_STATUS_GOOD) { DBG (DBG_error, "\tpieusb_scsi_command() fails status in: %d\n", sane_status); ret = PIEUSB_STATUS_IO_ERROR; break; } usb_status = usbstat; if (usb_status == USB_STATUS_AGAIN) { sleep(1); } continue; } if (usb_status == USB_STATUS_AGAIN) { /* re-send scsi cmd */ continue; } if (usb_status == USB_STATUS_FAIL) { DBG (DBG_error, "\tsanei_pieusb_command() usb status again2\n"); usb_status = USB_STATUS_ERROR; sanei_pieusb_usb_reset(device_number); ret = PIEUSB_STATUS_IO_ERROR; break; } if (usb_status == USB_STATUS_ERROR) { sanei_pieusb_usb_reset(device_number); ret = PIEUSB_STATUS_IO_ERROR; break; } DBG (DBG_error, "\tsanei_pieusb_command() unhandled usb status 0x%02x\n", usb_status); ret = PIEUSB_STATUS_IO_ERROR; break; } if ((time(NULL)-start) > MAXTIME) { DBG (DBG_info_usb, "\tsanei_pieusb_command() timeout !\n"); } DBG (DBG_info_usb, "\tsanei_pieusb_command() finished with state %d\n", ret); return ret; } /** * Reset IEEE1284 interface * * @param device_number Device number * @returns SANE_Status */ SANE_Status sanei_pieusb_usb_reset(SANE_Int device_number) { DBG (DBG_info_sane, "\tsanei_pieusb_usb_reset()\n"); return _ieee_command (device_number, IEEE1284_RESET); } /* http://www.t10.org/lists/2sensekey.htm */ static struct code_text_t sense_code_text[] = { { SCSI_SENSE_NO_SENSE, "No Sense" }, { SCSI_SENSE_RECOVERED_ERROR, "Recovered Error" }, { SCSI_SENSE_NOT_READY, "Not Ready" }, { SCSI_SENSE_MEDIUM_ERROR, "Medium Error" }, { SCSI_SENSE_HARDWARE_ERROR, "Hardware Error" }, { SCSI_SENSE_ILLEGAL_REQUEST, "Illegal Request" }, { SCSI_SENSE_UNIT_ATTENTION, "Unit Attention" }, { SCSI_SENSE_DATA_PROTECT, "Data Protect" }, { SCSI_SENSE_BLANK_CHECK, "Blank Check" }, { SCSI_SENSE_VENDOR_SPECIFIC, "Vendor Specific" }, { SCSI_SENSE_COPY_ABORTED, "Copy Aborted" }, { SCSI_SENSE_ABORTED_COMMAND, "Aborted Command" }, { SCSI_SENSE_EQUAL, "Equal" }, { SCSI_SENSE_VOLUME_OVERFLOW, "Volume Overflow" }, { SCSI_SENSE_MISCOMPARE, "Miscompare" }, { SCSI_SENSE_COMPLETED, "Completed" }, { -1, NULL } }; /** * Return a textual description of the given sense code. * * See http://www.t10.org/lists/asc-num.txt * * @param sense * @return description */ SANE_String sanei_pieusb_decode_sense(struct Pieusb_Sense* sense, PIEUSB_Status *status) { SANE_Char* desc = malloc(200); SANE_Char* ptr; strcpy (desc, code_to_text (sense_code_text, sense->senseKey)); ptr = desc + strlen(desc); switch (sense->senseKey) { case SCSI_SENSE_NOT_READY: if (sense->senseCode == SENSE_CODE_WARMING_UP && sense->senseQualifier == 1) { strcpy (ptr, ": Logical unit is in the process of becoming ready"); *status = PIEUSB_STATUS_WARMING_UP; } else { sprintf (ptr, ": senseCode 0x%02x, senseQualifier 0x%02x", sense->senseCode, sense->senseQualifier); *status = PIEUSB_STATUS_INVAL; } break; case SCSI_SENSE_UNIT_ATTENTION: if (sense->senseCode == 0x1a && sense->senseQualifier == 0) { strcpy (ptr, ": Invalid field in parameter list"); *status = PIEUSB_STATUS_INVAL; break; } else if (sense->senseCode == 0x20 && sense->senseQualifier == 0) { strcpy (ptr, ": Invalid command operation code"); *status = PIEUSB_STATUS_INVAL; break; } else if (sense->senseCode == 0x82 && sense->senseQualifier == 0) { strcpy (ptr, ": Calibration disable not granted"); *status = PIEUSB_STATUS_MUST_CALIBRATE; break; } else if (sense->senseCode == 0x00 && sense->senseQualifier == 6) { strcpy (ptr, ": I/O process terminated"); *status = PIEUSB_STATUS_IO_ERROR; break; } else if (sense->senseCode == 0x26 && sense->senseQualifier == 0x82) { strcpy (ptr, ": MODE SELECT value invalid: resolution too high (vs)"); *status = PIEUSB_STATUS_INVAL; break; } else if (sense->senseCode == 0x26 && sense->senseQualifier == 0x83) { strcpy (ptr, ": MODE SELECT value invalid: select only one color (vs)"); *status = PIEUSB_STATUS_INVAL; break; } else if (sense->senseCode == 0x26 && sense->senseQualifier == 0x83) { strcpy (ptr, ": MODE SELECT value invalid: unsupported bit depth (vs)"); *status = PIEUSB_STATUS_INVAL; break; } /*fallthru*/ case SCSI_SENSE_NO_SENSE: case SCSI_SENSE_RECOVERED_ERROR: case SCSI_SENSE_MEDIUM_ERROR: case SCSI_SENSE_HARDWARE_ERROR: case SCSI_SENSE_ILLEGAL_REQUEST: case SCSI_SENSE_DATA_PROTECT: case SCSI_SENSE_BLANK_CHECK: case SCSI_SENSE_VENDOR_SPECIFIC: case SCSI_SENSE_COPY_ABORTED: case SCSI_SENSE_ABORTED_COMMAND: case SCSI_SENSE_EQUAL: case SCSI_SENSE_VOLUME_OVERFLOW: case SCSI_SENSE_MISCOMPARE: case SCSI_SENSE_COMPLETED: default: sprintf (ptr, ": senseCode 0x%02x, senseQualifier 0x%02x", sense->senseCode, sense->senseQualifier); *status = PIEUSB_STATUS_INVAL; } return desc; } /** * Prepare IEEE1284 interface * Issue one of IEEE1284_ADDR, IEEE1284_RESET, or IEEE1284_SCSI * * @param device_number Device number * @param command - IEEE1284 command * @returns SANE_Status */ static SANE_Status _ieee_command(SANE_Int device_number, SANE_Byte command) { SANE_Status st; static int sequence[] = { 0xff, 0xaa, 0x55, 0x00, 0xff, 0x87, 0x78 }; #define SEQUENCE_LEN 7 unsigned int i; /* 2 x 4 + 3 bytes preceding command, then SCSI_COMMAND_LEN bytes command */ /* IEEE1284 command, see hpsj5s.c:cpp_daisy() */ for (i = 0; i < SEQUENCE_LEN; ++i) { st = _ctrl_out_byte (device_number, PORT_PAR_DATA, sequence[i]); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_ieee_command fails after %d bytes\n", i); return st; } } st = _ctrl_out_byte (device_number, PORT_PAR_DATA, command); if (st == SANE_STATUS_GOOD) { usleep(3000); /* 3.000 usec -> 3 msec */ st = _ctrl_out_byte (device_number, PORT_PAR_CTRL, C1284_NINIT|C1284_NSTROBE); /* CTRL_VAL_FINAL */ if (st == SANE_STATUS_GOOD) { st = _ctrl_out_byte (device_number, PORT_PAR_CTRL, C1284_NINIT); if (st == SANE_STATUS_GOOD) { st = _ctrl_out_byte (device_number, PORT_PAR_DATA, 0xff); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_ieee_command fails to write final data\n"); } } else { DBG (DBG_error, "\t\t_ieee_command fails to reset strobe\n"); } } else { DBG (DBG_error, "\t\t_ieee_command fails to set strobe\n"); } } return st; #undef SEQUENCE_LEN } /** * Send a command to the device. * The command is a SCSI_COMMAND_LEN-byte array. The data-array is used for input and output. * The sense-fields of Pieusb_Command_Status are cleared. * * @param device_number Device number * @param command Command array * @param data Input or output data buffer * @param size Size of the data buffer * @returns PIEUSB_SCSI_Status */ static PIEUSB_USB_Status _pieusb_scsi_command(SANE_Int device_number, SANE_Byte command[], SANE_Byte data[], SANE_Int size) { SANE_Status st; SANE_Byte usbstat; int i; DBG (DBG_info_usb, "\t\t_pieusb_scsi_command(): %02x:%s\n", command[0], code_to_text (scsi_code_text, command[0])); st = _ieee_command (device_number, IEEE1284_SCSI); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_pieusb_scsi_command can't prep scsi cmd: %d\n", st); return USB_STATUS_ERROR; } /* output command */ for (i = 0; i < SCSI_COMMAND_LEN; ++i) { SANE_Status st; st = _ctrl_out_byte (device_number, PORT_SCSI_CMD, command[i]); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_pieusb_scsi_command fails command out, after %d bytes: %d\n", i, st); return USB_STATUS_ERROR; } } _hexdump ("Cmd", command, SCSI_COMMAND_LEN); /* Verify this sequence */ st = _ctrl_in_byte (device_number, &usbstat); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_pieusb_scsi_command fails status after command out: %d\n", st); return USB_STATUS_ERROR; } /* Process rest of the data, if present; either input or output, possibly bulk */ DBG (DBG_info_usb, "\t\t_pieusb_scsi_command usbstat 0x%02x\n", usbstat); if (usbstat == USB_STATUS_OK && size > 0) { /* * send additional data to usb */ _hexdump ("Out", data, size); for (i = 0; i < size; ++i) { st = _ctrl_out_byte (device_number, PORT_SCSI_CMD, data[i]); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_pieusb_scsi_command fails data out after %d bytes: %d\n", i, st); return USB_STATUS_ERROR; } } /* Verify data out */ st = _ctrl_in_byte (device_number, &usbstat); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_pieusb_scsi_command fails status after data out: %d\n", st); return USB_STATUS_ERROR; } } else if (usbstat == USB_STATUS_READ) { /* Intermediate status OK, device has made data available for reading */ /* Read data */ size_t remsize; size_t partsize; remsize = (size_t)size; DBG (DBG_info_usb, "\t\t_pieusb_scsi_command data in\n"); while (remsize > 0) { partsize = remsize > 0x1000000 ? 0x1000000 : remsize; /* 0xc000 must be multiples of 0x4000, see _bulk_in() */ /* send expected length */ st = _bulk_size (device_number, partsize); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_pieusb_scsi_command prepare read data failed for size %u: %d\n", (unsigned int)partsize, st); return USB_STATUS_ERROR; } /* read expected length bytes */ st = _bulk_in (device_number, data + size - remsize, &partsize); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_pieusb_scsi_command read data failed for size %u: %d\n", (unsigned int)partsize, st); return USB_STATUS_ERROR; } remsize -= partsize; /* DBG (DBG_info, "\t\t_pieusb_scsi_command partsize %08x, remsize %08x\n", (unsigned int)partsize, (unsigned int)remsize); */ } /* Verify data in */ st = _ctrl_in_byte (device_number, &usbstat); if (st != SANE_STATUS_GOOD) { DBG (DBG_error, "\t\t_pieusb_scsi_command fails status after data in: %d\n", st); return USB_STATUS_ERROR; } _hexdump ("In", data, size); } return usbstat; } /** * Simplified control transfer: one byte to given port * * @param device_number device number * @param b byte to send to device * @return SANE status */ static SANE_Status _ctrl_out_byte(SANE_Int device_number, SANE_Int port, SANE_Byte b) { /* int r = libusb_control_transfer(scannerHandle, CTRL_OUT, 0x0C, 0x0088, ANYINDEX, &b, 1, TIMEOUT); */ return sanei_usb_control_msg(device_number, REQUEST_TYPE_OUT, REQUEST_REGISTER, port, ANYINDEX, 1, &b); } /** * Simplified control transfer for port/wValue = 0x82 - prepare bulk * * @param device_number device number * @param size Size of bulk transfer which follows (number of bytes) * @return SANE status */ static SANE_Status _bulk_size(SANE_Int device_number, unsigned int size) { SANE_Byte bulksize[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; bulksize[4] = size & 0xff; bulksize[5] = (size >> 8) & 0xff; bulksize[6] = (size >> 16) & 0xff; bulksize[7] = (size >> 24) & 0xff; return sanei_usb_control_msg(device_number, REQUEST_TYPE_OUT, REQUEST_BUFFER, PORT_SCSI_SIZE, ANYINDEX, 8, bulksize); } /* * Ctrl inbound, single byte */ /** * Inbound control transfer * * @param device_number device number * @param b byte received from device * @return SANE status */ static SANE_Status _ctrl_in_byte(SANE_Int device_number, SANE_Byte* b) { /* int r = libusb_control_transfer(scannerHandle, CTRL_IN, 0x0C, 0x0084, ANYINDEX, &b, 1, TIMEOUT); */ /* int r = libusb_control_transfer(scannerHandle, CTRL_IN, 0x0C, 0x0084, ANYINDEX, &b, 1, TIMEOUT); */ return sanei_usb_control_msg(device_number, REQUEST_TYPE_IN, REQUEST_REGISTER, PORT_SCSI_STATUS, ANYINDEX, 1, b); } /** * Bulk in transfer for data, in parts of 0x4000 bytes max * * @param device_number device number * @param data array holding or receiving data (must be preallocated) * @param size ptr to size of the data array / actual size on output * @return SANE status */ static SANE_Status _bulk_in(SANE_Int device_number, SANE_Byte *data, size_t *size) { size_t remaining = 0; SANE_Status r = SANE_STATUS_GOOD; size_t part; remaining = *size; while (remaining > 0) { /* Determine bulk size */ part = (remaining >= 0x4000) ? 0x4000 : remaining; /* max 16k per chunk */ /* DBG (DBG_info, "\t\t_bulk_in: %08x @ %p, %08x rem\n", (unsigned int)part, data, (unsigned int)remaining); */ r = sanei_usb_read_bulk(device_number, data, &part); if (r != SANE_STATUS_GOOD) { break; } /* DBG (DBG_info, "\t\t_bulk_in: -> %d : %08x\n", r, (unsigned int)part);*/ remaining -= part; data += part; } *size -= remaining; return r; } sane-backends-1.0.29/backend/hp3500.c0000666000000000000000000031157313615534521013665 00000000000000/* sane - Scanner Access Now Easy. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. -------------------------------------------------------------------------- This file implements a SANE backend for HP ScanJet 3500 series scanners. Currently supported: - HP ScanJet 3500C - HP ScanJet 3530C - HP ScanJet 3570C SANE FLOW DIAGRAM - sane_init() : initialize backend, attach scanners . - sane_get_devices() : query list of scanner devices . - sane_open() : open a particular scanner device . . - sane_set_io_mode : set blocking mode . . - sane_get_select_fd : get scanner fd . . - sane_get_option_descriptor() : get option information . . - sane_control_option() : change option values . . . . - sane_start() : start image acquisition . . - sane_get_parameters() : returns actual scan parameters . . - sane_read() : read image data (from pipe) . . . . - sane_cancel() : cancel operation . - sane_close() : close opened scanner device - sane_exit() : terminate use of backend There are some device specific routines in this file that are in "#if 0" sections - these are left in place for documentation purposes in case somebody wants to implement features that use those routines. */ /* ------------------------------------------------------------------------- */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_LIBC_H # include /* NeXTStep/OpenStep */ #endif #include "../include/sane/sane.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_thread.h" #include "../include/sane/sanei_backend.h" #define RTCMD_GETREG 0x80 #define RTCMD_READSRAM 0x81 #define RTCMD_SETREG 0x88 #define RTCMD_WRITESRAM 0x89 #define RTCMD_NVRAMCONTROL 0x8a #define RTCMD_BYTESAVAIL 0x90 #define RTCMD_READBYTES 0x91 #define RT_CHANNEL_ALL 0 #define RT_CHANNEL_RED 1 #define RT_CHANNEL_GREEN 2 #define RT_CHANNEL_BLUE 3 typedef int (*rts8801_callback) (void *param, unsigned bytes, void *data); #define DEBUG 1 #define SCANNER_UNIT_TO_FIXED_MM(number) SANE_FIX(number * MM_PER_INCH / 1200) #define FIXED_MM_TO_SCANNER_UNIT(number) SANE_UNFIX(number) * 1200 / MM_PER_INCH #define MSG_ERR 1 #define MSG_USER 5 #define MSG_INFO 6 #define FLOW_CONTROL 10 #define MSG_IO 15 #define MSG_IO_READ 17 #define IO_CMD 20 #define IO_CMD_RES 20 #define MSG_GET 25 /* ------------------------------------------------------------------------- */ enum hp3500_option { OPT_NUM_OPTS = 0, OPT_RESOLUTION, OPT_GEOMETRY_GROUP, OPT_TL_X, OPT_TL_Y, OPT_BR_X, OPT_BR_Y, OPT_MODE_GROUP, OPT_MODE, OPT_BRIGHTNESS, OPT_CONTRAST, OPT_GAMMA, NUM_OPTIONS }; typedef struct { int left; int top; int right; int bottom; } hp3500_rect; struct hp3500_data { struct hp3500_data *next; char *devicename; int sfd; int pipe_r; int pipe_w; SANE_Pid reader_pid; int resolution; int mode; time_t last_scan; hp3500_rect request_mm; hp3500_rect actual_mm; hp3500_rect fullres_pixels; hp3500_rect actres_pixels; int rounded_left; int rounded_top; int rounded_right; int rounded_bottom; int bytes_per_scan_line; int scan_width_pixels; int scan_height_pixels; int brightness; int contrast; double gamma; SANE_Option_Descriptor opt[NUM_OPTIONS]; SANE_Device sane; }; struct hp3500_write_info { struct hp3500_data *scanner; int bytesleft; }; typedef struct detailed_calibration_data { unsigned char const *channeldata[3]; unsigned resolution_divisor; } detailed_calibration_data; static struct hp3500_data *first_dev = 0; static struct hp3500_data **new_dev = &first_dev; static int num_devices = 0; static SANE_Int res_list[] = { 9, 50, 75, 100, 150, 200, 300, 400, 600, 1200 }; static const SANE_Range range_x = { 0, SANE_FIX (215.9), SANE_FIX (MM_PER_INCH / 1200) }; static const SANE_Range range_y = { 0, SANE_FIX (298.7), SANE_FIX (MM_PER_INCH / 1200) }; 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 #define HP3500_GRAY_SCAN 1 #define HP3500_LINEART_SCAN 2 #define HP3500_TOTAL_SCANS 3 static char const *scan_mode_list[HP3500_TOTAL_SCANS + 1] = { 0 }; static SANE_Status attachScanner (const char *name); static SANE_Status init_options (struct hp3500_data *scanner); 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 */ static const SANE_Device **devlist = 0; /* * SANE Interface */ /** * Called by SANE initially. * * From the SANE spec: * This function must be called before any other SANE function can be * called. The behavior of a SANE backend is undefined if this * function is not called first. The version code of the backend is * returned in the value pointed to by version_code. If that pointer * is NULL, no version code is returned. Argument authorize is either * a pointer to a function that is invoked when the backend requires * authentication for a specific resource or NULL if the frontend does * not support authentication. */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { authorize = authorize; /* get rid of compiler warning */ DBG_INIT (); DBG (10, "sane_init\n"); sanei_usb_init (); sanei_thread_init (); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); sanei_usb_find_devices (0x03f0, 0x2205, attachScanner); sanei_usb_find_devices (0x03f0, 0x2005, attachScanner); return SANE_STATUS_GOOD; } /** * Called by SANE to find out about supported devices. * * From the SANE spec: * This function can be used to query the list of devices that are * available. If the function executes successfully, it stores a * pointer to a NULL terminated array of pointers to SANE_Device * structures in *device_list. The returned list is guaranteed to * remain unchanged and valid until (a) another call to this function * is performed or (b) a call to sane_exit() is performed. This * function can be called repeatedly to detect when new devices become * available. If argument local_only is true, only local devices are * returned (devices directly attached to the machine that SANE is * running on). If it is false, the device list includes all remote * devices that are accessible to the SANE library. * * SANE does not require that this function is called before a * sane_open() call is performed. A device name may be specified * explicitly by a user which would make it unnecessary and * undesirable to call this function first. */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { int i; struct hp3500_data *dev; DBG (10, "sane_get_devices %d\n", local_only); if (devlist) free (devlist); devlist = calloc (num_devices + 1, sizeof (SANE_Device *)); if (!devlist) return SANE_STATUS_NO_MEM; for (dev = first_dev, i = 0; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } /** * Called to establish connection with the scanner. This function will * also establish meaningful defauls and initialize the options. * * From the SANE spec: * This function is used to establish a connection to a particular * device. The name of the device to be opened is passed in argument * name. If the call completes successfully, a handle for the device * is returned in *h. As a special case, specifying a zero-length * string as the device requests opening the first available device * (if there is such a device). */ SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle) { struct hp3500_data *dev = NULL; struct hp3500_data *scanner = NULL; if (name[0] == 0) { DBG (10, "sane_open: no device requested, using default\n"); if (first_dev) { scanner = (struct hp3500_data *) first_dev; DBG (10, "sane_open: device %s found\n", first_dev->sane.name); } } else { DBG (10, "sane_open: device %s requested\n", name); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, name) == 0) { DBG (10, "sane_open: device %s found\n", name); scanner = (struct hp3500_data *) dev; } } } if (!scanner) { DBG (10, "sane_open: no device found\n"); return SANE_STATUS_INVAL; } *handle = scanner; init_options (scanner); scanner->resolution = 200; scanner->request_mm.left = 0; scanner->request_mm.top = 0; scanner->request_mm.right = SCANNER_UNIT_TO_FIXED_MM (10200); scanner->request_mm.bottom = SCANNER_UNIT_TO_FIXED_MM (14100); scanner->mode = 0; scanner->brightness = 128; scanner->contrast = 64; scanner->gamma = 2.2; calculateDerivedValues (scanner); return SANE_STATUS_GOOD; } /** * An advanced method we don't support but have to define. */ SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking) { DBG (10, "sane_set_io_mode\n"); DBG (99, "%d %p\n", non_blocking, h); return SANE_STATUS_UNSUPPORTED; } /** * An advanced method we don't support but have to define. */ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fdp) { struct hp3500_data *scanner = (struct hp3500_data *) h; DBG (10, "sane_get_select_fd\n"); *fdp = scanner->pipe_r; DBG (99, "%p %d\n", h, *fdp); return SANE_STATUS_GOOD; } /** * Returns the options we know. * * From the SANE spec: * This function is used to access option descriptors. The function * returns the option descriptor for option number n of the device * represented by handle h. Option number 0 is guaranteed to be a * valid option. Its value is an integer that specifies the number of * options that are available for device handle h (the count includes * option 0). If n is not a valid option index, the function returns * NULL. The returned option descriptor is guaranteed to remain valid * (and at the returned address) until the device is closed. */ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct hp3500_data *scanner = handle; DBG (MSG_GET, "sane_get_option_descriptor: \"%s\"\n", scanner->opt[option].name); if ((unsigned) option >= NUM_OPTIONS) return NULL; return &scanner->opt[option]; } /** * Gets or sets an option value. * * From the SANE spec: * This function is used to set or inquire the current value of option * number n of the device represented by handle h. The manner in which * the option is controlled is specified by parameter action. The * possible values of this parameter are described in more detail * below. The value of the option is passed through argument val. It * is a pointer to the memory that holds the option value. The memory * area pointed to by v must be big enough to hold the entire option * value (determined by member size in the corresponding option * descriptor). * * The only exception to this rule is that when setting the value of a * string option, the string pointed to by argument v may be shorter * since the backend will stop reading the option value upon * encountering the first NUL terminator in the string. If argument i * is not NULL, the value of *i will be set to provide details on how * well the request has been met. */ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { struct hp3500_data *scanner = (struct hp3500_data *) handle; SANE_Status status; SANE_Word cap; SANE_Int dummy; int i; /* Make sure that all those statements involving *info cannot break (better * than having to do "if (info) ..." everywhere!) */ if (info == 0) info = &dummy; *info = 0; if (option >= NUM_OPTIONS) return SANE_STATUS_INVAL; cap = scanner->opt[option].cap; /* * SANE_ACTION_GET_VALUE: We have to find out the current setting and * return it in a human-readable form (often, text). */ if (action == SANE_ACTION_GET_VALUE) { DBG (MSG_GET, "sane_control_option: get value \"%s\"\n", scanner->opt[option].name); DBG (11, "\tcap = %d\n", cap); if (!SANE_OPTION_IS_ACTIVE (cap)) { DBG (10, "\tinactive\n"); return SANE_STATUS_INVAL; } switch (option) { case OPT_NUM_OPTS: *(SANE_Word *) val = NUM_OPTIONS; return SANE_STATUS_GOOD; case OPT_RESOLUTION: *(SANE_Word *) val = scanner->resolution; return SANE_STATUS_GOOD; case OPT_TL_X: *(SANE_Word *) val = scanner->request_mm.left; return SANE_STATUS_GOOD; case OPT_TL_Y: *(SANE_Word *) val = scanner->request_mm.top; return SANE_STATUS_GOOD; case OPT_BR_X: *(SANE_Word *) val = scanner->request_mm.right; return SANE_STATUS_GOOD; case OPT_BR_Y: *(SANE_Word *) val = scanner->request_mm.bottom; return SANE_STATUS_GOOD; case OPT_MODE: strcpy ((SANE_Char *) val, scan_mode_list[scanner->mode]); return SANE_STATUS_GOOD; case OPT_CONTRAST: *(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; } } else if (action == SANE_ACTION_SET_VALUE) { DBG (10, "sane_control_option: set value \"%s\"\n", scanner->opt[option].name); if (!SANE_OPTION_IS_ACTIVE (cap)) { DBG (10, "\tinactive\n"); return SANE_STATUS_INVAL; } if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (10, "\tnot settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (scanner->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (10, "\tbad value\n"); return status; } /* * Note - for those options which can assume one of a list of * valid values, we can safely assume that they will have * exactly one of those values because that's what * sanei_constrain_value does. Hence no "else: invalid" branches * below. */ switch (option) { case OPT_RESOLUTION: if (scanner->resolution == *(SANE_Word *) val) { return SANE_STATUS_GOOD; } scanner->resolution = (*(SANE_Word *) val); calculateDerivedValues (scanner); *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_TL_X: if (scanner->request_mm.left == *(SANE_Word *) val) return SANE_STATUS_GOOD; scanner->request_mm.left = *(SANE_Word *) val; calculateDerivedValues (scanner); if (scanner->actual_mm.left != scanner->request_mm.left) *info |= SANE_INFO_INEXACT; *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_TL_Y: if (scanner->request_mm.top == *(SANE_Word *) val) return SANE_STATUS_GOOD; scanner->request_mm.top = *(SANE_Word *) val; calculateDerivedValues (scanner); if (scanner->actual_mm.top != scanner->request_mm.top) *info |= SANE_INFO_INEXACT; *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_BR_X: if (scanner->request_mm.right == *(SANE_Word *) val) { return SANE_STATUS_GOOD; } scanner->request_mm.right = *(SANE_Word *) val; calculateDerivedValues (scanner); if (scanner->actual_mm.right != scanner->request_mm.right) *info |= SANE_INFO_INEXACT; *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_BR_Y: if (scanner->request_mm.bottom == *(SANE_Word *) val) { return SANE_STATUS_GOOD; } scanner->request_mm.bottom = *(SANE_Word *) val; calculateDerivedValues (scanner); if (scanner->actual_mm.bottom != scanner->request_mm.bottom) *info |= SANE_INFO_INEXACT; *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_MODE: for (i = 0; scan_mode_list[i]; ++i) { if (!strcmp ((SANE_Char const *) val, scan_mode_list[i])) { DBG (10, "Setting scan mode to %s (request: %s)\n", scan_mode_list[i], (SANE_Char const *) val); scanner->mode = i; return SANE_STATUS_GOOD; } } /* Impossible */ return SANE_STATUS_INVAL; case OPT_BRIGHTNESS: scanner->brightness = *(SANE_Word *) val; return SANE_STATUS_GOOD; 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; } /** * Called by SANE when a page acquisition operation is to be started. * */ SANE_Status sane_start (SANE_Handle handle) { struct hp3500_data *scanner = handle; int defaultFds[2]; int ret; DBG (10, "sane_start\n"); if (scanner->sfd < 0) { /* first call */ DBG (10, "sane_start opening USB device\n"); if (sanei_usb_open (scanner->sane.name, &(scanner->sfd)) != SANE_STATUS_GOOD) { DBG (MSG_ERR, "sane_start: open of %s failed:\n", scanner->sane.name); return SANE_STATUS_INVAL; } } calculateDerivedValues (scanner); DBG (10, "\tbytes per line = %d\n", scanner->bytes_per_scan_line); DBG (10, "\tpixels_per_line = %d\n", scanner->scan_width_pixels); DBG (10, "\tlines = %d\n", scanner->scan_height_pixels); /* create a pipe, fds[0]=read-fd, fds[1]=write-fd */ if (pipe (defaultFds) < 0) { DBG (MSG_ERR, "ERROR: could not create pipe\n"); do_cancel (scanner); return SANE_STATUS_IO_ERROR; } scanner->pipe_r = defaultFds[0]; scanner->pipe_w = defaultFds[1]; ret = SANE_STATUS_GOOD; scanner->reader_pid = sanei_thread_begin (reader_process, scanner); time (&scanner->last_scan); if (!sanei_thread_is_valid (scanner->reader_pid)) { DBG (MSG_ERR, "cannot fork reader process.\n"); DBG (MSG_ERR, "%s", strerror (errno)); ret = SANE_STATUS_IO_ERROR; } if (sanei_thread_is_forked ()) { close (scanner->pipe_w); } if (ret == SANE_STATUS_GOOD) { DBG (10, "sane_start: ok\n"); } return ret; } /** * Called by SANE to retrieve information about the type of data * that the current scan will return. * * From the SANE spec: * This function is used to obtain the current scan parameters. The * returned parameters are guaranteed to be accurate between the time * a scan has been started (sane_start() has been called) and the * completion of that request. Outside of that window, the returned * values are best-effort estimates of what the parameters will be * when sane_start() gets invoked. * * Calling this function before a scan has actually started allows, * for example, to get an estimate of how big the scanned image will * be. The parameters passed to this function are the handle h of the * device for which the parameters should be obtained and a pointer p * to a parameter structure. */ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { struct hp3500_data *scanner = (struct hp3500_data *) handle; DBG (10, "sane_get_parameters\n"); calculateDerivedValues (scanner); params->format = (scanner->mode == HP3500_COLOR_SCAN) ? SANE_FRAME_RGB : SANE_FRAME_GRAY; params->depth = (scanner->mode == HP3500_LINEART_SCAN) ? 1 : 8; params->pixels_per_line = scanner->scan_width_pixels; params->lines = scanner->scan_height_pixels; params->bytes_per_line = scanner->bytes_per_scan_line; params->last_frame = 1; DBG (10, "\tdepth %d\n", params->depth); DBG (10, "\tlines %d\n", params->lines); DBG (10, "\tpixels_per_line %d\n", params->pixels_per_line); DBG (10, "\tbytes_per_line %d\n", params->bytes_per_line); return SANE_STATUS_GOOD; } /** * Called by SANE to read data. * * In this implementation, sane_read does nothing much besides reading * data from a pipe and handing it back. On the other end of the pipe * there's the reader process which gets data from the scanner and * stuffs it into the pipe. * * From the SANE spec: * This function is used to read image data from the device * represented by handle h. Argument buf is a pointer to a memory * area that is at least maxlen bytes long. The number of bytes * returned is stored in *len. A backend must set this to zero when * the call fails (i.e., when a status other than SANE_STATUS_GOOD is * returned). * * When the call succeeds, the number of bytes returned can be * anywhere in the range from 0 to maxlen bytes. */ SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { struct hp3500_data *scanner = (struct hp3500_data *) handle; ssize_t nread; int source = scanner->pipe_r; *len = 0; nread = read (source, buf, max_len); DBG (30, "sane_read: read %ld bytes of %ld\n", (long) nread, (long) max_len); if (nread < 0) { if (errno == EAGAIN) { return SANE_STATUS_GOOD; } else { do_cancel (scanner); return SANE_STATUS_IO_ERROR; } } *len = nread; if (nread == 0) { close (source); DBG (10, "sane_read: pipe closed\n"); return SANE_STATUS_EOF; } return SANE_STATUS_GOOD; } /* sane_read */ /** * Cancels a scan. * * It has been said on the mailing list that sane_cancel is a bit of a * misnomer because it is routinely called to signal the end of a * batch - quoting David Mosberger-Tang: * * > In other words, the idea is to have sane_start() be called, and * > collect as many images as the frontend wants (which could in turn * > consist of multiple frames each as indicated by frame-type) and * > when the frontend is done, it should call sane_cancel(). * > Sometimes it's better to think of sane_cancel() as "sane_stop()" * > but that name would have had some misleading connotations as * > well, that's why we stuck with "cancel". * * The current consensus regarding duplex and ADF scans seems to be * the following call sequence: sane_start; sane_read (repeat until * EOF); sane_start; sane_read... and then call sane_cancel if the * batch is at an end. I.e. do not call sane_cancel during the run but * as soon as you get a SANE_STATUS_NO_DOCS. * * From the SANE spec: * This function is used to immediately or as quickly as possible * cancel the currently pending operation of the device represented by * handle h. This function can be called at any time (as long as * handle h is a valid handle) but usually affects long-running * operations only (such as image is acquisition). It is safe to call * this function asynchronously (e.g., from within a signal handler). * It is important to note that completion of this operaton does not * imply that the currently pending operation has been cancelled. It * only guarantees that cancellation has been initiated. Cancellation * completes only when the cancelled call returns (typically with a * status value of SANE_STATUS_CANCELLED). Since the SANE API does * not require any other operations to be re-entrant, this implies * that a frontend must not call any other operation until the * cancelled operation has returned. */ void sane_cancel (SANE_Handle h) { DBG (10, "sane_cancel\n"); do_cancel ((struct hp3500_data *) h); } /** * Ends use of the scanner. * * From the SANE spec: * This function terminates the association between the device handle * passed in argument h and the device it represents. If the device is * presently active, a call to sane_cancel() is performed first. After * this function returns, handle h must not be used anymore. */ void sane_close (SANE_Handle handle) { DBG (10, "sane_close\n"); do_reset (handle); do_cancel (handle); } /** * Terminates the backend. * * From the SANE spec: * This function must be called to terminate use of a backend. The * function will first close all device handles that still might be * open (it is recommended to close device handles explicitly through * a call to sane_clo-se(), but backends are required to release all * resources upon a call to this function). After this function * returns, no function other than sane_init() may be called * (regardless of the status value returned by sane_exit(). Neglecting * to call this function may result in some resources not being * released properly. */ void sane_exit (void) { struct hp3500_data *dev, *next; DBG (10, "sane_exit\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free (dev->devicename); free (dev); } if (devlist) free (devlist); } /* * The scanning code */ static SANE_Status attachScanner (const char *devicename) { struct hp3500_data *dev; DBG (15, "attach_scanner: %s\n", devicename); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { DBG (5, "attach_scanner: scanner already attached (is ok)!\n"); return SANE_STATUS_GOOD; } } if (NULL == (dev = malloc (sizeof (*dev)))) return SANE_STATUS_NO_MEM; memset (dev, 0, sizeof (*dev)); dev->devicename = strdup (devicename); dev->sfd = -1; dev->last_scan = 0; dev->reader_pid = (SANE_Pid) -1; dev->pipe_r = dev->pipe_w = -1; dev->sane.name = dev->devicename; dev->sane.vendor = "Hewlett-Packard"; dev->sane.model = "ScanJet 3500"; dev->sane.type = "scanner"; ++num_devices; *new_dev = dev; DBG (15, "attach_scanner: done\n"); return SANE_STATUS_GOOD; } static SANE_Status init_options (struct hp3500_data *scanner) { int i; SANE_Option_Descriptor *opt; memset (scanner->opt, 0, sizeof (scanner->opt)); for (i = 0; i < NUM_OPTIONS; ++i) { scanner->opt[i].name = "filler"; scanner->opt[i].size = sizeof (SANE_Word); scanner->opt[i].cap = SANE_CAP_INACTIVE; } opt = scanner->opt + OPT_NUM_OPTS; opt->title = SANE_TITLE_NUM_OPTIONS; opt->desc = SANE_DESC_NUM_OPTIONS; opt->type = SANE_TYPE_INT; opt->cap = SANE_CAP_SOFT_DETECT; opt = scanner->opt + OPT_RESOLUTION; opt->name = SANE_NAME_SCAN_RESOLUTION; opt->title = SANE_TITLE_SCAN_RESOLUTION; opt->desc = SANE_DESC_SCAN_RESOLUTION; opt->type = SANE_TYPE_INT; opt->constraint_type = SANE_CONSTRAINT_WORD_LIST; opt->constraint.word_list = res_list; opt->unit = SANE_UNIT_DPI; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt = scanner->opt + OPT_GEOMETRY_GROUP; opt->title = SANE_I18N ("Geometry"); opt->desc = SANE_I18N ("Geometry Group"); opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; opt = scanner->opt + OPT_TL_X; opt->name = SANE_NAME_SCAN_TL_X; opt->title = SANE_TITLE_SCAN_TL_X; opt->desc = SANE_DESC_SCAN_TL_X; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &range_x; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt = scanner->opt + OPT_TL_Y; opt->name = SANE_NAME_SCAN_TL_Y; opt->title = SANE_TITLE_SCAN_TL_Y; opt->desc = SANE_DESC_SCAN_TL_Y; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &range_y; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt = scanner->opt + OPT_BR_X; opt->name = SANE_NAME_SCAN_BR_X; opt->title = SANE_TITLE_SCAN_BR_X; opt->desc = SANE_DESC_SCAN_BR_X; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &range_x; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt = scanner->opt + OPT_BR_Y; opt->name = SANE_NAME_SCAN_BR_Y; opt->title = SANE_TITLE_SCAN_BR_Y; opt->desc = SANE_DESC_SCAN_BR_Y; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &range_y; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if (!scan_mode_list[0]) { scan_mode_list[HP3500_COLOR_SCAN] = SANE_VALUE_SCAN_MODE_COLOR; scan_mode_list[HP3500_GRAY_SCAN] = SANE_VALUE_SCAN_MODE_GRAY; scan_mode_list[HP3500_LINEART_SCAN] = SANE_VALUE_SCAN_MODE_LINEART; scan_mode_list[HP3500_TOTAL_SCANS] = 0; } opt = scanner->opt + OPT_MODE_GROUP; opt->title = SANE_I18N ("Scan Mode Group"); opt->desc = SANE_I18N ("Scan Mode Group"); opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; opt = scanner->opt + OPT_MODE; opt->name = SANE_NAME_SCAN_MODE; 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 = (SANE_String_Const *) scan_mode_list; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt = scanner->opt + OPT_BRIGHTNESS; opt->name = SANE_NAME_BRIGHTNESS; opt->title = SANE_TITLE_BRIGHTNESS; opt->desc = SANE_DESC_BRIGHTNESS; opt->type = SANE_TYPE_INT; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &range_brightness; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt = scanner->opt + OPT_CONTRAST; opt->name = SANE_NAME_CONTRAST; opt->title = SANE_TITLE_CONTRAST; opt->desc = SANE_DESC_CONTRAST; opt->type = SANE_TYPE_INT; opt->constraint_type = SANE_CONSTRAINT_RANGE; 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; } static void do_reset (struct hp3500_data *scanner) { scanner = scanner; /* kill warning */ } static void do_cancel (struct hp3500_data *scanner) { if (sanei_thread_is_valid (scanner->reader_pid)) { if (sanei_thread_kill (scanner->reader_pid) == 0) { int exit_status; sanei_thread_waitpid (scanner->reader_pid, &exit_status); } sanei_thread_invalidate (scanner->reader_pid); } if (scanner->pipe_r >= 0) { close (scanner->pipe_r); scanner->pipe_r = -1; } } static void calculateDerivedValues (struct hp3500_data *scanner) { DBG (12, "calculateDerivedValues\n"); /* Convert the SANE_FIXED values for the scan area into 1/1200 inch * scanner units */ scanner->fullres_pixels.left = FIXED_MM_TO_SCANNER_UNIT (scanner->request_mm.left); scanner->fullres_pixels.top = FIXED_MM_TO_SCANNER_UNIT (scanner->request_mm.top); scanner->fullres_pixels.right = FIXED_MM_TO_SCANNER_UNIT (scanner->request_mm.right); scanner->fullres_pixels.bottom = FIXED_MM_TO_SCANNER_UNIT (scanner->request_mm.bottom); DBG (12, "\tleft margin: %u\n", scanner->fullres_pixels.left); DBG (12, "\ttop margin: %u\n", scanner->fullres_pixels.top); DBG (12, "\tright margin: %u\n", scanner->fullres_pixels.right); DBG (12, "\tbottom margin: %u\n", scanner->fullres_pixels.bottom); scanner->scan_width_pixels = scanner->resolution * (scanner->fullres_pixels.right - scanner->fullres_pixels.left) / 1200; scanner->scan_height_pixels = scanner->resolution * (scanner->fullres_pixels.bottom - scanner->fullres_pixels.top) / 1200; if (scanner->mode == HP3500_LINEART_SCAN) scanner->bytes_per_scan_line = (scanner->scan_width_pixels + 7) / 8; else if (scanner->mode == HP3500_GRAY_SCAN) scanner->bytes_per_scan_line = scanner->scan_width_pixels; else scanner->bytes_per_scan_line = scanner->scan_width_pixels * 3; if (scanner->scan_width_pixels < 1) scanner->scan_width_pixels = 1; if (scanner->scan_height_pixels < 1) scanner->scan_height_pixels = 1; scanner->actres_pixels.left = scanner->fullres_pixels.left * scanner->resolution / 1200; scanner->actres_pixels.top = scanner->fullres_pixels.top * scanner->resolution / 1200; scanner->actres_pixels.right = scanner->actres_pixels.left + scanner->scan_width_pixels; scanner->actres_pixels.bottom = scanner->actres_pixels.top + scanner->scan_height_pixels; scanner->actual_mm.left = SCANNER_UNIT_TO_FIXED_MM (scanner->fullres_pixels.left); scanner->actual_mm.top = SCANNER_UNIT_TO_FIXED_MM (scanner->fullres_pixels.top); scanner->actual_mm.bottom = SCANNER_UNIT_TO_FIXED_MM (scanner->scan_width_pixels * 1200 / scanner->resolution); scanner->actual_mm.right = SCANNER_UNIT_TO_FIXED_MM (scanner->scan_height_pixels * 1200 / scanner->resolution); DBG (12, "calculateDerivedValues: ok\n"); } /* From here on in we have the original code written for the scanner demo */ #define MAX_COMMANDS_BYTES 131072 #define MAX_READ_COMMANDS 1 /* Issuing more than one register * read command in a single request * seems to put the device in an * unpredictable state. */ #define MAX_READ_BYTES 0xffc0 #define REG_DESTINATION_POSITION 0x60 #define REG_MOVE_CONTROL_TEST 0xb3 static int command_reads_outstanding = 0; static int command_bytes_outstanding = 0; static unsigned char command_buffer[MAX_COMMANDS_BYTES]; static int receive_bytes_outstanding = 0; static char *command_readmem_outstanding[MAX_READ_COMMANDS]; static int command_readbytes_outstanding[MAX_READ_COMMANDS]; static unsigned char sram_access_method = 0; static unsigned sram_size = 0; static int udh; static int rt_execute_commands (void) { SANE_Status result; size_t bytes; if (!command_bytes_outstanding) return 0; bytes = command_bytes_outstanding; result = sanei_usb_write_bulk (udh, /* 0x02, */ command_buffer, &bytes); if (result == SANE_STATUS_GOOD && receive_bytes_outstanding) { unsigned char readbuf[MAX_READ_BYTES]; int total_read = 0; do { bytes = receive_bytes_outstanding - total_read; result = sanei_usb_read_bulk (udh, /* 0x81, */ readbuf + total_read, &bytes); if (result == SANE_STATUS_GOOD) total_read += bytes; else break; } while (total_read < receive_bytes_outstanding); if (result == SANE_STATUS_GOOD) { unsigned char *readptr; int i; for (i = 0, readptr = readbuf; i < command_reads_outstanding; readptr += command_readbytes_outstanding[i++]) { memcpy (command_readmem_outstanding[i], readptr, command_readbytes_outstanding[i]); } } } receive_bytes_outstanding = command_reads_outstanding = command_bytes_outstanding = 0; return (result == SANE_STATUS_GOOD) ? 0 : -1; } static int rt_queue_command (int command, int reg, int count, int bytes, void const *data_, int readbytes, void *readdata) { int len = 4 + bytes; unsigned char *buffer; unsigned char const *data = data_; /* We add "bytes" here to account for the possiblity that all of the * data bytes are 0xaa and hence require a following 0x00 byte. */ if (command_bytes_outstanding + len + bytes > MAX_COMMANDS_BYTES || (readbytes && ((command_reads_outstanding >= MAX_READ_COMMANDS) || (receive_bytes_outstanding >= MAX_READ_BYTES)))) { if (rt_execute_commands () < 0) return -1; } buffer = command_buffer + command_bytes_outstanding; *buffer++ = command; *buffer++ = reg; *buffer++ = count >> 8; *buffer++ = count; while (bytes--) { *buffer++ = *data; if (*data++ == 0xaa) { *buffer++ = 0; ++len; } } command_bytes_outstanding += len; if (readbytes) { command_readbytes_outstanding[command_reads_outstanding] = readbytes; command_readmem_outstanding[command_reads_outstanding] = readdata; receive_bytes_outstanding += readbytes; ++command_reads_outstanding; } return 0; } static int rt_send_command_immediate (int command, int reg, int count, int bytes, void *data, int readbytes, void *readdata) { rt_queue_command (command, reg, count, bytes, data, readbytes, readdata); return rt_execute_commands (); } static int rt_queue_read_register (int reg, int bytes, void *data) { return rt_queue_command (RTCMD_GETREG, reg, bytes, 0, 0, bytes, data); } static int rt_read_register_immediate (int reg, int bytes, void *data) { if (rt_queue_read_register (reg, bytes, data) < 0) return -1; return rt_execute_commands (); } static int rt_queue_set_register (int reg, int bytes, void *data) { return rt_queue_command (RTCMD_SETREG, reg, bytes, bytes, data, 0, 0); } static int rt_set_register_immediate (int reg, int bytes, void *data) { if (reg < 0xb3 && reg + bytes > 0xb3) { int bytes_in_first_block = 0xb3 - reg; if (rt_set_register_immediate (reg, bytes_in_first_block, data) < 0 || rt_set_register_immediate (0xb4, bytes - bytes_in_first_block - 1, (char *) data + bytes_in_first_block + 1) < 0) return -1; return 0; } if (rt_queue_set_register (reg, bytes, data) < 0) return -1; return rt_execute_commands (); } static int rt_set_one_register (int reg, int val) { char r = val; return rt_set_register_immediate (reg, 1, &r); } static int rt_write_sram (int bytes, void *data_) { unsigned char *data = (unsigned char *) data_; /* The number of bytes passed in could be much larger than we can transmit * (0xffc0) bytes. With 0xaa escapes it could be even larger. Accordingly * we need to count the 0xaa escapes and write in chunks if the number of * bytes would otherwise exceed a limit (I have used 0xf000 as the limit). */ while (bytes > 0) { int now = 0; int bufsize = 0; while (now < bytes && bufsize < 0xf000) { int i; /* Try to avoid writing part pages */ for (i = 0; i < 32 && now < bytes; ++i) { ++bufsize; if (data[now++] == 0xaa) ++bufsize; } } if (rt_send_command_immediate (RTCMD_WRITESRAM, 0, now, now, data, 0, 0) < 0) return -1; bytes -= now; data += now; } return 0; } static int rt_read_sram (int bytes, void *data_) { unsigned char *data = (unsigned char *) data_; while (bytes > 0) { int now = (bytes > 0xf000) ? 0xf000 : bytes; if (rt_send_command_immediate (RTCMD_READSRAM, 0, bytes, 0, 0, bytes, data) < 0) return -1; bytes -= now; data += now; } return 0; } static int rt_set_sram_page (int page) { unsigned char regs[2]; regs[0] = page; regs[1] = page >> 8; return rt_set_register_immediate (0x91, 2, regs); } static int rt_detect_sram (unsigned *totalbytes, unsigned char *r93setting) { char data[0x818]; char testbuf[0x818]; unsigned i; int test_values[] = { 6, 2, 1, -1 }; for (i = 0; i < sizeof (data); ++i) data[i] = i % 0x61; for (i = 0; test_values[i] != -1; ++i) { if (rt_set_one_register (0x93, test_values[i]) || rt_set_sram_page (0x81) || rt_write_sram (0x818, data) || rt_set_sram_page (0x81) || rt_read_sram (0x818, testbuf)) return -1; if (!memcmp (testbuf, data, 0x818)) { sram_access_method = test_values[i]; if (r93setting) *r93setting = sram_access_method; break; } } if (!sram_access_method) return -1; for (i = 0; i < 16; ++i) { int j; char write_data[32]; char read_data[32]; int pagesetting; for (j = 0; j < 16; j++) { write_data[j * 2] = j * 2; write_data[j * 2 + 1] = i; } pagesetting = i * 4096; if (rt_set_sram_page (pagesetting) < 0 || rt_write_sram (32, write_data) < 0) return -1; if (i) { if (rt_set_sram_page (0) < 0 || rt_read_sram (32, read_data) < 0) return -1; if (!memcmp (read_data, write_data, 32)) { sram_size = i * 0x20000; if (totalbytes) *totalbytes = sram_size; return 0; } } } return -1; } static int rt_get_available_bytes (void) { unsigned char data[3]; if (rt_queue_command (RTCMD_BYTESAVAIL, 0, 3, 0, 0, 3, data) < 0 || rt_execute_commands () < 0) return -1; return ((unsigned) data[0]) | ((unsigned) data[1] << 8) | ((unsigned) data[2] << 16); } static int rt_get_data (int bytes, void *data) { int total = 0; while (bytes) { int bytesnow = bytes; if (bytesnow > 0xffc0) bytesnow = 0xffc0; if (rt_queue_command (RTCMD_READBYTES, 0, bytesnow, 0, 0, bytesnow, data) < 0 || rt_execute_commands () < 0) return -1; total += bytesnow; bytes -= bytesnow; data = (char *) data + bytesnow; } return 0; } static int rt_is_moving (void) { char r; if (rt_read_register_immediate (REG_MOVE_CONTROL_TEST, 1, &r) < 0) return -1; if (r == 0x08) return 1; return 0; } static int rt_is_rewound (void) { char r; if (rt_read_register_immediate (0x1d, 1, &r) < 0) return -1; if (r & 0x02) return 1; return 0; } static int rt_set_direction_forwards (unsigned char *regs) { regs[0xc6] |= 0x08; return 0; } static int rt_set_direction_rewind (unsigned char *regs) { regs[0xc6] &= 0xf7; return 0; } static int rt_set_stop_when_rewound (unsigned char *regs, int stop) { if (stop) regs[0xb2] |= 0x10; else regs[0xb2] &= 0xef; return 0; } static int rt_start_moving (void) { if (rt_set_one_register (REG_MOVE_CONTROL_TEST, 2) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, 2) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, 0) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, 0) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, 8) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, 8) < 0) return -1; return 0; } static int rt_stop_moving (void) { if (rt_set_one_register (REG_MOVE_CONTROL_TEST, 2) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, 2) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, 0) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, 0) < 0) return -1; return 0; } static int rt_set_powersave_mode (int enable) { unsigned char r; if (rt_read_register_immediate (REG_MOVE_CONTROL_TEST, 1, &r) < 0) return -1; if (r & 0x04) { if (enable == 1) return 0; r &= ~0x04; } else { if (enable == 0) return 0; r |= 0x04; } if (rt_set_one_register (REG_MOVE_CONTROL_TEST, r) < 0 || rt_set_one_register (REG_MOVE_CONTROL_TEST, r) < 0) return -1; return 0; } static int rt_turn_off_lamp (void) { return rt_set_one_register (0x3a, 0); } static int rt_turn_on_lamp (void) { char r3ab[2]; char r10; char r58; if (rt_read_register_immediate (0x3a, 1, r3ab) < 0 || rt_read_register_immediate (0x10, 1, &r10) < 0 || rt_read_register_immediate (0x58, 1, &r58) < 0) return -1; r3ab[0] |= 0x80; r3ab[1] = 0x40; r10 |= 0x01; r58 &= 0x0f; if (rt_set_register_immediate (0x3a, 2, r3ab) < 0 || rt_set_one_register (0x10, r10) < 0 || rt_set_one_register (0x58, r58) < 0) return -1; return 0; } static int rt_set_value_lsbfirst (unsigned char *regs, int firstreg, int totalregs, unsigned value) { while (totalregs--) { regs[firstreg++] = value & 0xff; value >>= 8; } return 0; } #if 0 static int rt_set_value_msbfirst (unsigned char *regs, int firstreg, int totalregs, unsigned value) { while (totalregs--) { regs[firstreg + totalregs] = value & 0xff; value >>= 8; } return 0; } #endif static int rt_set_ccd_shift_clock_multiplier (unsigned char *regs, unsigned value) { return rt_set_value_lsbfirst (regs, 0xf0, 3, value); } static int rt_set_ccd_clock_reset_interval (unsigned char *regs, unsigned value) { return rt_set_value_lsbfirst (regs, 0xf9, 3, value); } static int rt_set_ccd_clamp_clock_multiplier (unsigned char *regs, unsigned value) { return rt_set_value_lsbfirst (regs, 0xfc, 3, value); } static int rt_set_movement_pattern (unsigned char *regs, unsigned value) { return rt_set_value_lsbfirst (regs, 0xc0, 3, value); } static int rt_set_motor_movement_clock_multiplier (unsigned char *regs, unsigned value) { regs[0x40] = (regs[0x40] & ~0xc0) | (value << 6); return 0; } static int rt_set_motor_type (unsigned char *regs, unsigned value) { regs[0xc9] = (regs[0xc9] & 0xf8) | (value & 0x7); return 0; } static int rt_set_noscan_distance (unsigned char *regs, unsigned value) { DBG (10, "Setting distance without scanning to %d\n", value); return rt_set_value_lsbfirst (regs, 0x60, 2, value); } static int rt_set_total_distance (unsigned char *regs, unsigned value) { DBG (10, "Setting total distance to %d\n", value); return rt_set_value_lsbfirst (regs, 0x62, 2, value); } static int rt_set_scanline_start (unsigned char *regs, unsigned value) { return rt_set_value_lsbfirst (regs, 0x66, 2, value); } static int rt_set_scanline_end (unsigned char *regs, unsigned value) { return rt_set_value_lsbfirst (regs, 0x6c, 2, value); } static int rt_set_basic_calibration (unsigned char *regs, int redoffset1, int redoffset2, int redgain, int greenoffset1, int greenoffset2, int greengain, int blueoffset1, int blueoffset2, int bluegain) { regs[0x02] = redoffset1; regs[0x05] = redoffset2; regs[0x08] = redgain; regs[0x03] = greenoffset1; regs[0x06] = greenoffset2; regs[0x09] = greengain; regs[0x04] = blueoffset1; regs[0x07] = blueoffset2; regs[0x0a] = bluegain; return 0; } static int rt_set_calibration_addresses (unsigned char *regs, unsigned redaddr, unsigned greenaddr, 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); /* 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; } static int rt_set_lamp_duty_cycle (unsigned char *regs, int enable, int frequency, int offduty) { if (enable) regs[0x3b] |= 0x80; else regs[0x3b] &= 0x7f; regs[0x3b] = (regs[0x3b] & 0x80) | ((frequency & 0x7) << 4) | (offduty & 0x0f); regs[0x3d] = (regs[0x3d] & 0x7f) | ((frequency & 0x8) << 4); return 0; } static int rt_set_data_feed_on (unsigned char *regs) { regs[0xb2] &= ~0x04; 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) { if (enable) regs[0x00] &= ~0x10; else regs[0x00] |= 0x10; return 0; } static int rt_set_cdss (unsigned char *regs, int val1, int val2) { regs[0x28] = (regs[0x28] & 0xe0) | (val1 & 0x1f); regs[0x2a] = (regs[0x2a] & 0xe0) | (val2 & 0x1f); return 0; } static int rt_set_cdsc (unsigned char *regs, int val1, int val2) { regs[0x29] = (regs[0x29] & 0xe0) | (val1 & 0x1f); regs[0x2b] = (regs[0x2b] & 0xe0) | (val2 & 0x1f); return 0; } static int rt_update_after_setting_cdss2 (unsigned char *regs) { int fullcolour = (!(regs[0x2f] & 0xc0) && (regs[0x2f] & 0x04)); int value = regs[0x2a] & 0x1f; regs[0x2a] = (regs[0x2a] & 0xe0) | (value & 0x1f); if (fullcolour) value *= 3; if ((regs[0x40] & 0xc0) == 0x40) value += 17; else value += 16; regs[0x2c] = (regs[0x2c] & 0xe0) | (value % 24); regs[0x2d] = (regs[0x2d] & 0xe0) | ((value + 2) % 24); return 0; } static int rt_set_cph0s (unsigned char *regs, int on) { if (on) regs[0x2d] |= 0x20; /* 1200dpi horizontal coordinate space */ else regs[0x2d] &= ~0x20; /* 600dpi horizontal coordinate space */ return 0; } static int rt_set_cvtr_lm (unsigned char *regs, int val1, int val2, int val3) { regs[0x28] = (regs[0x28] & ~0xe0) | (val1 << 5); regs[0x29] = (regs[0x29] & ~0xe0) | (val2 << 5); regs[0x2a] = (regs[0x2a] & ~0xe0) | (val3 << 5); return 0; } static int rt_set_cvtr_mpt (unsigned char *regs, int val1, int val2, int val3) { regs[0x3c] = (val1 & 0x0f) | (val2 << 4); regs[0x3d] = (regs[0x3d] & 0xf0) | (val3 & 0x0f); return 0; } static int rt_set_cvtr_wparams (unsigned char *regs, unsigned fpw, unsigned bpw, unsigned w) { regs[0x31] = (w & 0x0f) | ((bpw << 4) & 0x30) | (fpw << 6); return 0; } static int rt_enable_movement (unsigned char *regs, int enable) { if (enable) regs[0xc3] |= 0x80; else regs[0xc3] &= ~0x80; return 0; } static int rt_set_scan_frequency (unsigned char *regs, int frequency) { regs[0x64] = (regs[0x64] & 0xf0) | (frequency & 0x0f); return 0; } static int rt_set_merge_channels (unsigned char *regs, int on) { /* RGBRGB instead of RRRRR...GGGGG...BBBB */ regs[0x2f] &= ~0x14; regs[0x2f] |= on ? 0x04 : 0x10; return 0; } static int rt_set_channel (unsigned char *regs, int channel) { regs[0x2f] = (regs[0x2f] & ~0xc0) | (channel << 6); return 0; } static int rt_set_single_channel_scanning (unsigned char *regs, int on) { if (on) regs[0x2f] |= 0x20; else regs[0x2f] &= ~0x20; return 0; } static int rt_set_colour_mode (unsigned char *regs, int on) { if (on) regs[0x2f] |= 0x02; else regs[0x2f] &= ~0x02; return 0; } static int rt_set_horizontal_resolution (unsigned char *regs, int resolution) { int base_resolution = 300; if (regs[0x2d] & 0x20) base_resolution *= 2; if (regs[0xd3] & 0x08) base_resolution *= 2; regs[0x7a] = base_resolution / resolution; return 0; } static int rt_set_last_sram_page (unsigned char *regs, int pagenum) { rt_set_value_lsbfirst (regs, 0x8b, 2, pagenum); return 0; } static int rt_set_step_size (unsigned char *regs, int stepsize) { rt_set_value_lsbfirst (regs, 0xe2, 2, stepsize); rt_set_value_lsbfirst (regs, 0xe0, 2, 0); return 0; } static int rt_set_all_registers (void const *regs_) { char regs[255]; memcpy (regs, regs_, 255); regs[0x32] &= ~0x40; if (rt_set_one_register (0x32, regs[0x32]) < 0 || rt_set_register_immediate (0, 255, regs) < 0 || rt_set_one_register (0x32, regs[0x32] | 0x40) < 0) return -1; return 0; } static int rt_adjust_misc_registers (unsigned char *regs) { /* Mostly unknown purposes - probably no need to adjust */ regs[0xc6] = (regs[0xc6] & 0x0f) | 0x20; /* Purpose unknown - appears to do nothing */ regs[0x2e] = 0x86; /* ???? - Always has this value */ regs[0x30] = 2; /* CCPL = 1 */ regs[0xc9] |= 0x38; /* Doesn't have any obvious effect, but the Windows driver does this */ return 0; } #define NVR_MAX_ADDRESS_SIZE 11 #define NVR_MAX_OPCODE_SIZE 3 #define NVR_DATA_SIZE 8 #define NVR_MAX_COMMAND_SIZE ((NVR_MAX_ADDRESS_SIZE + \ NVR_MAX_OPCODE_SIZE + \ NVR_DATA_SIZE) * 2 + 1) static int rt_nvram_enable_controller (int enable) { unsigned char r; if (rt_read_register_immediate (0x1d, 1, &r) < 0) return -1; if (enable) r |= 1; else r &= ~1; return rt_set_one_register (0x1d, r); } static int rt_nvram_init_command (void) { unsigned char regs[13]; if (rt_read_register_immediate (0x10, 13, regs) < 0) return -1; regs[2] |= 0xf0; regs[4] = (regs[4] & 0x1f) | 0x60; return rt_set_register_immediate (0x10, 13, regs); } static int rt_nvram_init_stdvars (int block, int *addrbits, unsigned char *basereg) { int bitsneeded; int capacity; switch (block) { case 0: bitsneeded = 7; break; case 1: bitsneeded = 9; break; case 2: bitsneeded = 11; break; default: bitsneeded = 0; capacity = 1; while (capacity < block) capacity <<= 1, ++bitsneeded; break; } *addrbits = bitsneeded; if (rt_read_register_immediate (0x10, 1, basereg) < 0) return -1; *basereg &= ~0x60; return 0; } static void rt_nvram_set_half_bit (unsigned char *buffer, int value, unsigned char stdbits, int whichhalf) { *buffer = stdbits | (value ? 0x40 : 0) | (whichhalf ? 0x20 : 0); } static void rt_nvram_set_command_bit (unsigned char *buffer, int value, unsigned char stdbits) { rt_nvram_set_half_bit (buffer, value, stdbits, 0); rt_nvram_set_half_bit (buffer + 1, value, stdbits, 1); } static void rt_nvram_set_addressing_bits (unsigned char *buffer, int location, int addressingbits, unsigned char stdbits) { int currentbit = 1 << (addressingbits - 1); while (addressingbits--) { rt_nvram_set_command_bit (buffer, (location & currentbit) ? 1 : 0, stdbits); buffer += 2; currentbit >>= 1; } } #if 0 static int rt_nvram_enable_write (int addressingbits, int enable, unsigned char stdbits) { unsigned char cmdbuffer[NVR_MAX_COMMAND_SIZE]; int cmdsize = 6 + addressingbits * 2; rt_nvram_set_command_bit (cmdbuffer, 1, stdbits); rt_nvram_set_command_bit (cmdbuffer + 2, 0, stdbits); rt_nvram_set_command_bit (cmdbuffer + 4, 0, stdbits); rt_nvram_set_command_bit (cmdbuffer + 6, enable, stdbits); if (addressingbits > 1) rt_nvram_set_addressing_bits (cmdbuffer + 8, 0, addressingbits - 1, stdbits); if (rt_nvram_enable_controller (1) < 0 || rt_send_command_immediate (RTCMD_NVRAMCONTROL, 0, cmdsize, cmdsize, cmdbuffer, 0, 0) < 0 || rt_nvram_enable_controller (0) < 0) { return -1; } return 0; } static int rt_nvram_write (int block, int location, char const *data, int bytes) { int addressingbits; unsigned char stdbits; unsigned char cmdbuffer[NVR_MAX_COMMAND_SIZE]; unsigned char *address_bits; unsigned char *data_bits; int cmdsize; /* This routine doesn't appear to work, but I can't see anything wrong with it */ if (rt_nvram_init_stdvars (block, &addressingbits, &stdbits) < 0) return -1; cmdsize = (addressingbits + 8) * 2 + 6; address_bits = cmdbuffer + 6; data_bits = address_bits + (addressingbits * 2); rt_nvram_set_command_bit (cmdbuffer, 1, stdbits); rt_nvram_set_command_bit (cmdbuffer + 2, 0, stdbits); rt_nvram_set_command_bit (cmdbuffer + 4, 1, stdbits); if (rt_nvram_init_command () < 0 || rt_nvram_enable_write (addressingbits, 1, stdbits) < 0) return -1; while (bytes--) { int i; rt_nvram_set_addressing_bits (address_bits, location, addressingbits, stdbits); rt_nvram_set_addressing_bits (data_bits, *data++, 8, stdbits); if (rt_nvram_enable_controller (1) < 0 || rt_send_command_immediate (RTCMD_NVRAMCONTROL, 0, cmdsize, cmdsize, cmdbuffer, 0, 0) < 0 || rt_nvram_enable_controller (0) < 0) return -1; if (rt_nvram_enable_controller (1) < 0) return -1; for (i = 0; i < cmdsize; ++i) { unsigned char r; unsigned char cmd; rt_nvram_set_half_bit (&cmd, 0, stdbits, i & 1); if (rt_send_command_immediate (RTCMD_NVRAMCONTROL, 0, 1, 1, &cmd, 0, 0) < 0 || rt_read_register_immediate (0x10, 1, &r) < 0) { return -1; } else if (r & 0x80) { break; } } if (rt_nvram_enable_controller (0) < 0) return -1; ++location; } if (rt_nvram_enable_write (addressingbits, 0, stdbits) < 0) return -1; return 0; } #endif static int rt_nvram_read (int block, int location, unsigned char *data, int bytes) { int addressingbits; unsigned char stdbits; unsigned char cmdbuffer[NVR_MAX_COMMAND_SIZE]; unsigned char *address_bits; unsigned char readbit_command[2]; int cmdsize; if (rt_nvram_init_stdvars (block, &addressingbits, &stdbits) < 0) return -1; cmdsize = addressingbits * 2 + 7; address_bits = cmdbuffer + 6; rt_nvram_set_command_bit (cmdbuffer, 1, stdbits); rt_nvram_set_command_bit (cmdbuffer + 2, 1, stdbits); rt_nvram_set_command_bit (cmdbuffer + 4, 0, stdbits); rt_nvram_set_half_bit (cmdbuffer + cmdsize - 1, 0, stdbits, 0); rt_nvram_set_half_bit (readbit_command, 0, stdbits, 1); rt_nvram_set_half_bit (readbit_command + 1, 0, stdbits, 0); if (rt_nvram_init_command () < 0) return -1; while (bytes--) { char c = 0; unsigned char r; int i; rt_nvram_set_addressing_bits (address_bits, location, addressingbits, stdbits); if (rt_nvram_enable_controller (1) < 0 || rt_send_command_immediate (RTCMD_NVRAMCONTROL, 0x1d, cmdsize, cmdsize, cmdbuffer, 0, 0) < 0) return -1; for (i = 0; i < 8; ++i) { c <<= 1; if (rt_send_command_immediate (RTCMD_NVRAMCONTROL, 0x1d, 2, 2, readbit_command, 0, 0) < 0 || rt_read_register_immediate (0x10, 1, &r) < 0) return -1; if (r & 0x80) c |= 1; } if (rt_nvram_enable_controller (0) < 0) return -1; *data++ = c; ++location; } 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 */ 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, /* 0x30 */ 0xd0, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38 */ 0x00, 0x00, 0xa0, 0x37, 0xff, 0x0f, 0x00, 0x00, /* 0x40 */ 0x80, 0x00, 0x00, 0x00, 0x8c, 0x76, 0x00, 0x00, /* 0x48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50 */ 0x20, 0xbc, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58 */ 0x1d, 0x1f, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, /* 0x60 */ 0x5e, 0xea, 0x5f, 0xea, 0x00, 0x80, 0x64, 0x00, /* 0x68 */ 0x00, 0x00, 0x00, 0x00, 0x84, 0x04, 0x00, 0x00, /* 0x70 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 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, 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, /* 0xb0 */ 0x12, 0x08, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, /* 0xb8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0 */ 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, /* 0xc8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0 */ 0xff, 0xbf, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, /* 0xd8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0 */ 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #define RT_NORMAL_TG 0 #define RT_DOUBLE_TG 1 #define RT_TRIPLE_TG 2 #define RT_DDOUBLE_TG 3 #define RT_300_TG 4 #define RT_150_TG 5 #define RT_TEST_TG 6 static struct tg_info__ { int tg_cph0p; int tg_crsp; int tg_cclpp; int tg_cph0s; int tg_cdss1; int tg_cdsc1; int tg_cdss2; int tg_cdsc2; } tg_info[] = { /* CPH CCD Shifting Clock * 0P ??? Perhaps CCD rising edge position * 0S ??? * CRS Reset CCD Clock * P ??? Perhaps CCD falling edge position * CCLP CCD Clamp Clock * P ??? * CDS ??? * S1 ??? * S2 ??? * C1 ??? * C2 ??? */ /*CPH0P CRSP CCLPP CPH0S CDSS1 CDSC1 CDSS2 CDSC2 */ { 0x01FFE0, 0x3c0000, 0x003000, 1, 0xb, 0xd, 0x00, 0x01}, /* NORMAL */ { 0x7ff800, 0xf00000, 0x01c000, 0, 0xb, 0xc, 0x14, 0x15}, /* DOUBLE */ { 0x033fcc, 0x300000, 0x060000, 1, 0x8, 0xa, 0x00, 0x01}, /* TRIPLE */ { 0x028028, 0x300000, 0x060000, 1, 0x8, 0xa, 0x00, 0x01}, /* DDOUBLE */ { 0x7ff800, 0x030000, 0x060000, 0, 0xa, 0xc, 0x17, 0x01}, /* 300 */ { 0x7fc700, 0x030000, 0x060000, 0, 0x7, 0x9, 0x17, 0x01}, /* 150 */ { 0x7ff800, 0x300000, 0x060000, 0, 0xa, 0xc, 0x17, 0x01}, /* TEST */ }; struct resolution_parameters { unsigned resolution; int reg_39_value; int reg_c3_value; int reg_c6_value; int scan_frequency; int cph0s; int red_green_offset; int green_blue_offset; int intra_channel_offset; int motor_movement_clock_multiplier; int d3_bit_3_value; int tg; int step_size; }; /* The TG value sets seem to affect the exposure time: * At 200dpi: * NORMAL gets higher values than DOUBLE * DDOUBLE gives a crazy spike in the data * TRIPLE gives a black result * TEST gives a black result * 300 gives a black result * 150 gives a black result */ static struct resolution_parameters resparms[] = { /* Acceptable values for stepsz are: * 0x157b 0xabd, 0x55e, 0x2af, 0x157, 0xab, 0x55 */ /* 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, 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, 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} }; struct dcalibdata { unsigned char *buffers[3]; int pixelsperrow; int pixelnow; int channelnow; int firstrowdone; }; static void dump_registers (unsigned char const *); static int rts8801_rewind (void) { unsigned char regs[255]; int n; int tg_setting = RT_DOUBLE_TG; rt_read_register_immediate (0, 255, regs); rt_set_noscan_distance (regs, 59998); rt_set_total_distance (regs, 59999); rt_set_stop_when_rewound (regs, 0); rt_set_one_register (0xc6, 0); rt_set_one_register (0xc6, 0); rt_set_direction_rewind (regs); rt_set_step_size (regs, 0x55); regs[0x39] = 3; regs[0xc3] = (regs[0xc3] & 0xf8) | 0x86; regs[0xc6] = (regs[0xc6] & 0xf8) | 4; rt_set_horizontal_resolution (regs, 25); 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_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_cvtr_wparams (regs, 3, 0, 6); rt_set_cvtr_mpt (regs, 15, 15, 15); rt_set_cvtr_lm (regs, 7, 7, 7); rt_set_motor_type (regs, 2); if (DBG_LEVEL >= 5) dump_registers (regs); rt_set_all_registers (regs); rt_set_one_register (0x2c, regs[0x2c]); rt_start_moving (); while (!rt_is_rewound () && ((n = rt_get_available_bytes ()) > 0 || rt_is_moving () > 0)) { if (n) { char buffer[0xffc0]; if (n > (int) sizeof (buffer)) n = sizeof (buffer); rt_get_data (n, buffer); } else { usleep (10000); } } rt_stop_moving (); return 0; } static int cancelled_scan = 0; static unsigned get_lsbfirst_int (unsigned char const *p, int n) { unsigned value = *p++; int shift = 8; while (--n) { unsigned now = *p++; value |= now << shift; shift += 8; } return value; } static int convert_c6 (int i) { switch (i) { case 3: return 1; case 1: return 2; case 4: return 4; } return -1; } static void dump_registers (unsigned char const *regs) { int i = 0; long pixels; DBG (5, "Scan commencing with registers:\n"); while (i < 255) { int j = 0; char buffer[80]; buffer[0] = 0; sprintf (buffer + strlen (buffer), "%02x:", i); while (j < 8) { sprintf (buffer + strlen (buffer), " %02x", regs[i++]); j++; } sprintf (buffer + strlen (buffer), " -"); while (j++ < 16 && i < 255) sprintf (buffer + strlen (buffer), " %02x", regs[i++]); DBG (5, " %s\n", buffer); } DBG (5, " Position:\n"); DBG (5, " Distance without scanning: %u\n", get_lsbfirst_int (regs + 0x60, 2)); DBG (5, " Total distance: %u\n", get_lsbfirst_int (regs + 0x62, 2)); DBG (5, " Scanning distance: %u\n", get_lsbfirst_int (regs + 0x62, 2) - get_lsbfirst_int (regs + 0x60, 2)); DBG (5, " Direction: %s\n", (regs[0xc6] & 0x08) ? "forward" : "rewind"); DBG (5, " Motor: %s\n", (regs[0xc3] & 0x80) ? "enabled" : "disabled"); if (regs[0x7a]) DBG (5, " X range: %u-%u\n", get_lsbfirst_int (regs + 0x66, 2) / regs[0x7a], get_lsbfirst_int (regs + 0x6c, 2) / regs[0x7a]); DBG (5, " TG Info:\n"); DBG (5, " CPH0P: %06x\n", get_lsbfirst_int (regs + 0xf0, 3)); DBG (5, " CRSP: %06x\n", get_lsbfirst_int (regs + 0xf9, 3)); DBG (5, " CCLPP: %06x\n", get_lsbfirst_int (regs + 0xfc, 3)); DBG (5, " CPH0S: %d\n", (regs[0x2d] & 0x20) ? 1 : 0); DBG (5, " CDSS1: %02x\n", regs[0x28] & 0x1f); DBG (5, " CDSC1: %02x\n", regs[0x29] & 0x1f); DBG (5, " CDSS2: %02x\n", regs[0x2a] & 0x1f); DBG (5, " CDSC2: %02x\n", regs[0x2b] & 0x1f); DBG (5, " Resolution specific:\n"); if (!regs[0x7a]) DBG (5, " Horizontal resolution: Denominator is zero!\n"); else DBG (5, " Horizontal resolution: %u\n", 300 * ((regs[0x2d] & 0x20) ? 2 : 1) * ((regs[0xd3] & 0x08) ? 2 : 1) / regs[0x7a]); DBG (5, " Derived vertical resolution: %u\n", 400 * (regs[0xc3] & 0x1f) * convert_c6 (regs[0xc6] & 0x7) / (regs[0x39] + 1)); DBG (5, " Register D3:3 %u\n", (regs[0xd3] & 0x08) ? 1 : 0); DBG (5, " Register 39: %u\n", regs[0x39]); DBG (5, " Register C3:0-5: %u\n", regs[0xc3] & 0x1f); DBG (5, " Register C6:0-2: %u\n", regs[0xc6] & 0x7); DBG (5, " Motor movement clock multiplier: %u\n", regs[0x40] >> 6); DBG (5, " Step Size: %04x\n", get_lsbfirst_int (regs + 0xe2, 2)); DBG (5, " Frequency: %u\n", regs[0x64] & 0xf); DBG (5, " Colour registers\n"); DBG (5, " Register 2F: %02x\n", regs[0x2f]); DBG (5, " Register 2C: %02x\n", regs[0x2c]); if (regs[0x7a]) { DBG (5, " Scan data estimates:\n"); pixels = (long) (get_lsbfirst_int (regs + 0x62, 2) - get_lsbfirst_int (regs + 0x60, 2)) * (long) (get_lsbfirst_int (regs + 0x6c, 2) - get_lsbfirst_int (regs + 0x66, 2)) / regs[0x7a]; DBG (5, " Pixels: %ld\n", pixels); DBG (5, " Bytes at 24BPP: %ld\n", pixels * 3); DBG (5, " Bytes at 1BPP: %ld\n", pixels / 8); } DBG (5, "\n"); } static int constrain (int val, int min, int max) { if (val < min) { DBG (10, "Clipped %d to %d\n", val, min); val = min; } else if (val > max) { DBG (10, "Clipped %d to %d\n", val, max); val = 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, unsigned height, unsigned colour, unsigned red_green_offset, unsigned green_blue_offset, unsigned intra_channel_offset, rts8801_callback cbfunc, void *params, int oddfirst, unsigned char const *calib_info, int merged_channels, double *postprocess_offsets, double *postprocess_gains) { unsigned rowbytes = 0; unsigned output_rowbytes = 0; unsigned channels = 0; unsigned total_rows = 0; unsigned char *row_buffer; unsigned char *output_buffer; unsigned buffered_rows; int rows_to_begin; int rowbuffer_bytes; int n; unsigned rownow = 0; unsigned bytenow = 0; unsigned char *channel_data[3][2]; unsigned i; unsigned j; int result = 0; unsigned rows_supplied = 0; calib_info = calib_info; /* Kill warning */ if (cancelled_scan) return -1; rt_start_moving (); channels = 3; rowbytes = width * 3; switch (colour) { case HP3500_GRAY_SCAN: output_rowbytes = width; break; case HP3500_COLOR_SCAN: output_rowbytes = rowbytes; break; case HP3500_LINEART_SCAN: output_rowbytes = (width + 7) / 8; break; } buffered_rows = red_green_offset + green_blue_offset + intra_channel_offset + 1; rows_to_begin = buffered_rows; rowbuffer_bytes = buffered_rows * rowbytes; row_buffer = (unsigned char *) malloc (rowbuffer_bytes); output_buffer = (unsigned char *) malloc (rowbytes); for (i = j = 0; i < channels; ++i) { if (i == 1) j += red_green_offset; else if (i == 2) j += green_blue_offset; if (merged_channels) channel_data[i][1 - oddfirst] = row_buffer + rowbytes * j + i; else channel_data[i][1 - oddfirst] = row_buffer + rowbytes * j + width * i; channel_data[i][oddfirst] = channel_data[i][1 - oddfirst] + rowbytes * intra_channel_offset; } while (((n = rt_get_available_bytes ()) > 0 || rt_is_moving () > 0) && !cancelled_scan) { if (n == 1 && (rt_is_moving () || rt_get_available_bytes () != 1)) n = 0; if (n > 0) { unsigned char buffer[0xffc0]; if (n > 0xffc0) n = 0xffc0; else if ((n > 1) && (n & 1)) --n; if (rt_get_data (n, buffer) >= 0) { unsigned char *bufnow = buffer; while (n) { int numcopy = rowbytes - bytenow; if (numcopy > n) numcopy = n; memcpy (row_buffer + rownow * rowbytes + bytenow, bufnow, numcopy); bytenow += numcopy; bufnow += numcopy; n -= numcopy; if (bytenow == rowbytes) { if (!rows_to_begin || !--rows_to_begin) { unsigned char *outnow = output_buffer; unsigned x; 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 (postprocess_gains && postprocess_offsets) { int ppidx = j * width + x; pix = constrain ( pix * postprocess_gains[ppidx] - postprocess_offsets[ppidx], 0, 255); } *outnow++ = pix; } } if (colour == HP3500_GRAY_SCAN || colour == HP3500_LINEART_SCAN) { unsigned char const *in_now = output_buffer; int bit = 7; outnow = output_buffer; for (i = 0; i < width; ++i) { if (colour == HP3500_GRAY_SCAN) { *outnow++ = ((unsigned) in_now[0] * 2989 + (unsigned) in_now[1] * 5870 + (unsigned) in_now[2] * 1140) / 10000; } else { if (bit == 7) *outnow = ((in_now[1] < 0x80) ? 0x80 : 0); else if (in_now[1] < 0x80) *outnow |= (1 << bit); if (bit == 0) { ++outnow; bit = 7; } else { --bit; } } in_now += 3; } } if (rows_supplied++ < height && !((*cbfunc) (params, output_rowbytes, output_buffer))) break; for (i = 0; i < channels; ++i) { for (j = 0; j < 2; ++j) { channel_data[i][j] += rowbytes; if (channel_data[i][j] - row_buffer >= rowbuffer_bytes) channel_data[i][j] -= rowbuffer_bytes; } } } ++total_rows; if (++rownow == buffered_rows) rownow = 0; bytenow = 0; } } } DBG (30, "total_rows = %d\r", total_rows); } else { usleep (10000); } } DBG (10, "\n"); if (n < 0) result = -1; free (output_buffer); free (row_buffer); rt_stop_moving (); return result; } 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) { int res = 0; for (res = 0; resparms[res].resolution != resolution; ++res) { if (!resparms[res].resolution) return -1; } return res; } static int rts8801_fullscan (unsigned x, unsigned y, unsigned w, unsigned h, unsigned xresolution, unsigned yresolution, unsigned colour, rts8801_callback cbfunc, void *param, unsigned char *calib_info, int flags, int red_calib_offset, int green_calib_offset, int blue_calib_offset, int end_calib_offset, double *postprocess_offsets, double *postprocess_gains) { int ires, jres; int tg_setting; unsigned char regs[256]; 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); if (ires < 0 || jres < 0) return -1; /* Set scan parameters */ rt_read_register_immediate (0, 255, regs); regs[255] = 0; rt_enable_ccd (regs, 1); rt_enable_movement (regs, 1); rt_set_scan_frequency (regs, 1); rt_adjust_misc_registers (regs); rt_set_cvtr_wparams (regs, 3, 0, 6); rt_set_cvtr_mpt (regs, 15, 15, 15); rt_set_cvtr_lm (regs, 7, 7, 7); rt_set_motor_type (regs, 2); if (rt_nvram_read (0, 0x7b, &offdutytime, 1) < 0 || offdutytime >= 15) { offdutytime = 6; } rt_set_lamp_duty_cycle (regs, 1, /* On */ 10, /* Frequency */ offdutytime); /* Off duty time */ rt_set_movement_pattern (regs, 0x800000); rt_set_direction_forwards (regs); rt_set_stop_when_rewound (regs, 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) { rt_set_calibration_addresses (regs, red_calib_offset, green_calib_offset, blue_calib_offset, end_calib_offset, w); regs[0x40] |= 0x2f; } else if (end_calib_offset >= 0) { rt_set_calibration_addresses (regs, 0x600, 0x600, 0x600, end_calib_offset, w); } rt_set_channel (regs, RT_CHANNEL_ALL); rt_set_single_channel_scanning (regs, 0); rt_set_merge_channels (regs, 1); rt_set_colour_mode (regs, 1); rt_set_last_sram_page (regs, (local_sram_size - 1) >> 5); scan_frequency = resparms[jres].scan_frequency; rt_set_cph0s (regs, resparms[ires].cph0s); if (resparms[ires].d3_bit_3_value) regs[0xd3] |= 0x08; else regs[0xd3] &= 0xf7; if (flags & RTS8801_F_SUPPRESS_MOVEMENT) regs[0xc3] &= 0x7f; regs[0xb2] &= 0xf7; rt_set_horizontal_resolution (regs, xresolution); rt_set_scanline_start (regs, x * (1200 / xresolution) / (resparms[ires].cph0s ? 1 : 2) / (resparms[ires].d3_bit_3_value ? 1 : 2)); rt_set_scanline_end (regs, (x + w) * (1200 / xresolution) / (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]); if (DBG_LEVEL >= 5) dump_registers (regs); result = rts8801_doscan (w, h, colour, red_green_offset, green_blue_offset, intra_channel_offset, cbfunc, param, (x & 1), calib_info, (regs[0x2f] & 0x04) != 0, postprocess_offsets, postprocess_gains); return result; } static int accumfunc (struct dcalibdata *dcd, int bytes, char *data) { unsigned char *c = (unsigned char *) data; while (bytes > 0) { if (dcd->firstrowdone) dcd->buffers[dcd->channelnow][dcd->pixelnow - dcd->pixelsperrow] = *c; if (++dcd->channelnow >= 3) { dcd->channelnow = 0; if (++dcd->pixelnow == dcd->pixelsperrow) ++dcd->firstrowdone; } c++; bytes--; } return 1; } static int calcmedian (unsigned char const *data, int pixel, int pixels_per_row, int elements) { int tallies[256]; int i; int elemstogo = elements / 2; memset (tallies, 0, sizeof (tallies)); data += pixel; for (i = 0; i < elements; ++i) { ++tallies[*data]; data += pixels_per_row; } i = 0; while (elemstogo - tallies[i] > 0) elemstogo -= tallies[i++]; return i; } struct calibdata { unsigned char *buffer; int space; }; static int storefunc (struct calibdata *cd, int bytes, char *data) { if (cd->space > 0) { if (bytes > cd->space) bytes = cd->space; memcpy (cd->buffer, data, bytes); cd->buffer += bytes; cd->space -= bytes; } return 1; } static unsigned sum_channel (unsigned char *p, int n, int bytwo) { unsigned v = 0; while (n-- > 0) { v += *p; p += 3; if (bytwo) p += 3; } return v; } 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, unsigned w, unsigned h, unsigned resolution, unsigned colour, unsigned brightness, unsigned contrast, rts8801_callback cbfunc, 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 iCalibY; int iCalibTarget; int iMoveFlags = 0; unsigned aiBestOffset[6]; int aiPassed[6]; int i; unsigned j; int k; int calibration_size; unsigned char *pDetailedCalib; int red_calibration_offset; int green_calibration_offset; int blue_calibration_offset; int end_calibration_offset; int base_resolution; int resolution_divisor; int resolution_index; int detailed_calibration_rows = 50; unsigned char *tdetail_buffer; 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 */ rt_set_all_registers (initial_regs); rt_set_powersave_mode (0); /* Initial rewind in case scanner is stuck away from home position */ rts8801_rewind (); /* Detect SRAM */ rt_detect_sram (&local_sram_size, &r93setting); /* Warm up the lamp */ DBG (10, "Warming up the lamp\n"); rt_turn_on_lamp (); if (do_warmup) sleep (25); /* Basic calibration */ DBG (10, "Calibrating (stage 1)\n"); calib_info[2] = calib_info[5] = calib_info[8] = 1; iCalibY = (resolution == 25) ? 1 : 2; iCalibTarget = 550; rt_turn_off_lamp(); for (i = 0; i < 6; ++i) { aiBestOffset[i] = 0xbf; aiPassed[i] = 0; } do { DBG (30, "Initial calibration pass commences\n"); onechanged = 0; for (i = 0; i < 3; ++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 (1401, iCalibY, 100, 2, 400, resolution, HP3500_COLOR_SCAN, (rts8801_callback) storefunc, &cd, calib_info, iMoveFlags, -1, -1, -1, -1, 0, 0); DBG (30, "Completed scan for initial calibration pass\n"); iMoveFlags = RTS8801_F_SUPPRESS_MOVEMENT | RTS8801_F_NO_DISPLACEMENTS; iCalibY = 2; for (i = 0; i < 6; ++i) { int sum; if (aiBestOffset[i] >= 255 || aiPassed[i] > 2) continue; sum = sum_channel (calibbuf + i, 50, 1); DBG (20, "channel[%d] sum = %d (target %d)\n", i, sum, iCalibTarget); if (sum < iCalibTarget) { onechanged = 1; ++aiBestOffset[i]; } else { ++aiPassed[i]; } } DBG (30, "Initial calibration pass completed\n"); } while (onechanged); DBG (20, "Offsets calculated\n"); rt_turn_on_lamp(); usleep(500000); tdetail_buffer = (unsigned char *) malloc (w * 3 * detailed_calibration_rows); for (i = 0; i < 3; ++i) { calib_info[i * 3 + 2] = 1; aiPassed[i] = 0; } do { struct dcalibdata dcdt; 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 | 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; 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); if (val > largest) largest = val; } if (largest < 0xe0) { ++calib_info[i * 3 + 2]; onechanged = 1; } else { ++aiPassed[i]; } } } while (onechanged); for (i = 0; i < 3; ++i) { DBG (10, "Channel [%d] gain=%02x offset=%02x\n", i, calib_info[i * 3] + 2, calib_info[i * 3]); } DBG (20, "Gain factors calculated\n"); /* Stage 2 calibration */ DBG (10, "Calibrating (stage 2)\n"); detail_buffer = (unsigned char *) malloc (w * 3 * detailed_calibration_rows); dcd.buffers[0] = detail_buffer; dcd.buffers[1] = (detail_buffer + w * detailed_calibration_rows); dcd.buffers[2] = (dcd.buffers[1] + w * detailed_calibration_rows); dcd.pixelsperrow = w; /* And now for the detailed calibration */ resolution_index = find_resolution_index (resolution); base_resolution = 300; if (resparms[resolution_index].cph0s) base_resolution *= 2; if (resparms[resolution_index].d3_bit_3_value) base_resolution *= 2; resolution_divisor = base_resolution / resolution; calibration_size = w * resolution_divisor * 6 + 1568 + 96; red_calibration_offset = 0x600; green_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; for (j = 0; j < 256; j++) { /* 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) { for (k = 0; k < resolution_divisor; ++k) { pDetailedCalib[idx++] = 0; pDetailedCalib[idx++] = 0x80; } } } rt_set_sram_page (0); rt_set_one_register (0x93, r93setting); rt_write_sram (calibration_size, pDetailedCalib); 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 (); 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, needs_postprocessed_calibration ? postprocess_offsets : 0, needs_postprocessed_calibration ? postprocess_gains : 0); rt_turn_off_lamp (); rts8801_rewind (); rt_set_powersave_mode (1); if (pDetailedCalib) 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; } static int writefunc (struct hp3500_write_info *winfo, int bytes, char *data) { static int warned = 0; if (bytes > winfo->bytesleft) { if (!warned) { warned = 1; DBG (1, "Overflow protection triggered\n"); rt_stop_moving (); } bytes = winfo->bytesleft; if (!bytes) return 0; } winfo->bytesleft -= bytes; return write (winfo->scanner->pipe_w, data, bytes) == bytes; } #ifdef _POSIX_SOURCE static void sigtermHandler (int signal) { signal = signal; /* get rid of compiler warning */ cancelled_scan = 1; } #endif static int reader_process (void *pv) { struct hp3500_data *scanner = pv; time_t t; sigset_t ignore_set; sigset_t sigterm_set; struct SIGACTION act; struct hp3500_write_info winfo; int status; if (sanei_thread_is_forked ()) { close (scanner->pipe_r); sigfillset (&ignore_set); sigdelset (&ignore_set, SIGTERM); #if defined (__APPLE__) && defined (__MACH__) sigdelset (&ignore_set, SIGUSR2); #endif sigprocmask (SIG_SETMASK, &ignore_set, 0); sigemptyset (&sigterm_set); sigaddset (&sigterm_set, SIGTERM); memset (&act, 0, sizeof (act)); #ifdef _POSIX_SOURCE act.sa_handler = sigtermHandler; #endif 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; if (getenv ("HP3500_NOWARMUP") && atoi (getenv ("HP3500_NOWARMUP")) > 0) do_warmup = 0; udh = scanner->sfd; cancelled_scan = 0; winfo.scanner = scanner; winfo.bytesleft = scanner->bytes_per_scan_line * scanner->scan_height_pixels; if (getenv ("HP3500_SLEEP")) { int seconds = atoi (getenv ("HP3500_SLEEP")); DBG (1, "Backend process %d sleeping for %d seconds\n", getpid (), seconds); sleep (seconds); } DBG (10, "Scanning at %ddpi, mode=%s\n", scanner->resolution, scan_mode_list[scanner->mode]); if (rts8801_scan (scanner->actres_pixels.left + 250 * scanner->resolution / 1200, scanner->actres_pixels.top + 599 * scanner->resolution / 1200, 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, 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; } sane-backends-1.0.29/backend/plustek-pp_models.c0000666000000000000000000004442013615534521016407 00000000000000/* @file plustek-pp_models.c * @brief model specific stuff * * based on sources acquired from Plustek Inc. * Copyright (C) 1998 Plustek Inc. * Copyright (C) 2000-2004 Gerhard Jaeger * also based on the work done by Rick Bronson * * History: * - 0.30 - initial version * - 0.31 - no changes * - 0.32 - no changes * - 0.33 - no changes * - 0.34 - no changes * - 0.35 - added some comments * - did some fine tuning on the 9630P and 12000P/9600P models * - moved function initPageSettings() to this module * - 0.36 - as the ps->MaxWideLineBlks and ps->MaxWideLineLen are only used * for the OP 4800, it has been removed from pScanData * - changed settings of OP600 according to the Primax Direct 4800 tests * - removed dwPreferSize from struct ScannerCaps * - fixed the 5seconds bed-hit problem for ASIC 96001/3 based models * - changes, due to define renaming * - 0.37 - added ButtonCount init * - added A3I model * - added functions modelInitCaps(), modelInitMotor() and * modelSetBufferSizes() * - 0.38 - added P12 stuff * - code cleanup * - 0.39 - no changes * - 0.40 - changed back to build 0.39-3 (disabled A3I stuff) * - 0.41 - added _OVR_PLUSTEK_4800P switch * - 0.42 - added SFLAG_CUSTOM_GAMMA to capabilities * - added _OVR_PRIMAX_4800D30 switch * - changed include names * - 0.43 - no changes * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #include "plustek-pp_scan.h" /*************************** local functions *********************************/ /*............................................................................. * initialize the extension according to the page size... */ static void modelInitPageSettings( pScanData ps ) { DBG(DBG_LOW, "modelInitPageSettings()\n" ); if( MODEL_OP_9630PL == ps->sCaps.Model ) ps->dwScannerSize = _SCANSIZE_LEGAL; else if( MODEL_OP_A3I == ps->sCaps.Model ) ps->dwScannerSize = _SCANSIZE_A3; else ps->dwScannerSize = _SCANSIZE_A4; /* default width for all but A3 - 8.5"* 300dpi (_MEASURE_BASE) */ ps->sCaps.wMaxExtentX = 2550; /* this applies to all scanners but the A3 model */ ps->LensInf.rExtentX.wMin = 150; ps->LensInf.rExtentX.wDef = 2550; ps->LensInf.rExtentX.wMax = 2550; ps->LensInf.rExtentX.wPhyMax = 2500; ps->LensInf.rExtentY.wMin = 150; ps->LensInf.wBeginX = 0; ps->LensInf.wBeginY = 0; switch( ps->dwScannerSize ) { case _SCANSIZE_A4: /* 11.69 inches */ DBG( DBG_LOW, "A4 set\n" ); ps->sCaps.wMaxExtentY = ps->LensInf.rExtentY.wDef = ps->LensInf.rExtentY.wMax = ps->LensInf.rExtentY.wPhyMax = _MEASURE_BASE * 11.6934; break; case _SCANSIZE_A3: /* 17 inches */ DBG( DBG_LOW, "A3 set\n" ); ps->sCaps.wMaxExtentY = ps->LensInf.rExtentY.wMax = ps->LensInf.rExtentY.wDef = ps->LensInf.rExtentY.wPhyMax = _MEASURE_BASE * 17; /* _MEASURE_BASE * 11.69 */ ps->sCaps.wMaxExtentX = ps->LensInf.rExtentX.wDef = ps->LensInf.rExtentX.wMax = 3507; ps->LensInf.rExtentX.wPhyMax = 3500; break; case _SCANSIZE_LETTER: /* 11 inches */ DBG( DBG_LOW, "Letter set\n" ); ps->sCaps.wMaxExtentY = ps->LensInf.rExtentY.wDef = ps->LensInf.rExtentY.wMax = ps->LensInf.rExtentY.wPhyMax = _MEASURE_BASE * 11; break; case _SCANSIZE_LEGAL: /* 14 inches */ DBG( DBG_LOW, "Legal set\n" ); ps->sCaps.wMaxExtentY = ps->LensInf.rExtentY.wDef = ps->LensInf.rExtentY.wMax = ps->LensInf.rExtentY.wPhyMax = _MEASURE_BASE * 14; } /* * add this value to avoid the problems in binary mode */ ps->LensInf.rExtentY.wMax += 64; /* set the DPI stuff */ ps->LensInf.rDpiX.wMin = 16; ps->LensInf.rDpiX.wDef = 50; ps->LensInf.rDpiX.wMax = (ps->PhysicalDpi * 16); ps->LensInf.rDpiX.wPhyMax = ps->PhysicalDpi; ps->LensInf.rDpiY.wMin = 16; ps->LensInf.rDpiY.wDef = 50; ps->LensInf.rDpiY.wMax = (ps->PhysicalDpi * 16); ps->LensInf.rDpiY.wPhyMax = (ps->PhysicalDpi * 2); } /*............................................................................. * set the scanner capabilities */ static void modelInitCaps( pScanData ps ) { ps->sCaps.wIOBase = _NO_BASE; ps->sCaps.dwFlag = SFLAG_CUSTOM_GAMMA; } /*............................................................................. * set the motor stuff */ static void modelInitMotor( pScanData ps ) { if( _ASIC_IS_96001 == ps->sCaps.AsicID ) { ps->FullStep = _MotorFullStep96001; ps->MotorOn = _MotorOn96001; ps->IgnorePF = _MotorIgnorePF96001; ps->StepMask = ~ps->FullStep; } else { ps->FullStep = _Motor1FullStep; ps->MotorOn = _MotorOn; ps->IgnorePF = _MotorIgnorePF; ps->StepMask = _MotorStepMask; } ps->BackwardSteps = 4000; } /*............................................................................. * according to the models' capabilities, set the buffer stuff */ static void modelSetBufferSizes( pScanData ps ) { /* should depend on the scan-area !!!! */ if( 400 == ps->PhysicalDpi ) { /* assuming a A3I */ ps->BufferSizeBase = 3517; ps->BufferForColorRunTable = (5500 * 4); /* might be 17" * 800dpi !!! */ } else if( 600 == ps->PhysicalDpi ) { ps->BufferSizeBase = 2560; ps->BufferForColorRunTable = (5500 * 4); } else { ps->BufferSizeBase = 1280; ps->BufferForColorRunTable = 9000; } ps->BufferSizePerModel = ps->BufferSizeBase * 2; ps->BufferForDataRead1 = ps->BufferSizePerModel * 3; /* patch that for the 600 DPI models OP9630 etc.*/ if(( 300 != ps->PhysicalDpi) && (_ASIC_IS_96003 == ps->sCaps.AsicID)) ps->BufferForDataRead1 += 300; ps->BufferFor1stColor = (ps->BufferSizePerModel * 17); ps->BufferFor2ndColor = (ps->BufferSizePerModel * 9); ps->TotalBufferRequire = (ps->BufferFor1stColor + ps->BufferFor2ndColor + ps->BufferForDataRead1 + ps->BufferForColorRunTable ); } /************************ exported functions *********************************/ /*............................................................................. * set the model to 4800 */ _LOC void ModelSet4800( pScanData ps ) { DBG( DBG_LOW, "ModelSet4800()\n" ); /* has 96001 ASIC */ ps->sCaps.AsicID = _ASIC_IS_96001; ps->sCaps.Model = MODEL_OP_4800P; ps->Device.buttons = 0; ps->Device.ModelCtrl = (_ModelDpi300 | _ModelMemSize32k96001 | _ModelWhiteIs0); ps->Device.DataOriginX = 72; ps->PhysicalDpi = 300; ps->TimePerLine = 0x30; ps->Offset70 = 70; modelSetBufferSizes( ps ); ps->a_wGrayInitTime[0] = 220; /* _EppTimeForOthers */ ps->a_wGrayInitTime[1] = 720; /* _SppTimeForOthers */ ps->a_wGrayInitTime[2] = 360; /* _BidirTimeForOthers */ ps->a_wColorInitTime[0] = 500; /* _EppTimeForColor */ ps->a_wColorInitTime[1] = 1680; /* _SppTimeForColor */ ps->a_wColorInitTime[2] = 1100; /* _BidirTimeForColor */ ps->AsicRedColor = _ASIC_REDCOLOR; ps->AsicGreenColor = _ASIC_GREENCOLOR; ps->RedDataReady = _RED_DATA_READY; ps->GreenDataReady = _GREEN_DATA_READY; /* * used for shading stuff (see dac.c) */ ps->FBKScanLineBlks = 5; ps->FBKScanLineLenBase = 1024; ps->FBKScanLineLen = (ps->FBKScanLineLenBase * 3); ps->ShadingBufferSize = ps->FBKScanLineLen; ps->ShadingBankSize = (ps->FBKScanLineLenBase * 4); ps->ShadingBankRed = (_MemBankSize4k96001 | 0x3a); ps->ShadingBankGreen = (_MemBankSize4k96001 | 0x3e); ps->ShadingBankBlue = (_MemBankSize4k96001 | 0x3c); ps->ShadingScanLineBlks = 6; ps->ShadingScanLineLen = (ps->BufferSizeBase * 3); ps->OneScanLineLen = (ps->BufferSizePerModel * 3); modelInitMotor( ps ); modelInitCaps ( ps ); modelInitPageSettings( ps ); DBG( DBG_LOW, "ModelSet4800() done.\n" ); } /*............................................................................. * set the model to 4830 */ _LOC void ModelSet4830( pScanData ps ) { DBG( DBG_LOW, "ModelSet4830()\n" ); /* has 96003 ASIC */ ps->sCaps.Model = MODEL_OP_4830P; if( _OVR_PRIMAX_4800D30 == ps->ModelOverride ) { DBG( DBG_LOW, "Model Override --> Primax 4800D 30\n" ); ps->sCaps.Model = MODEL_PMX_4800D3; } ps->sCaps.AsicID = _ASIC_IS_96003; ps->Device.buttons = 1; ps->Device.ModelCtrl = (_ModelDpi300 | _ModelMemSize32k3 | _ModelWhiteIs0); ps->Device.DataOriginX = 72; ps->PhysicalDpi = 300; ps->TimePerLine = 0x30; ps->Offset70 = 70; modelSetBufferSizes( ps ); ps->a_wGrayInitTime[0] = 220; /* _EppTimeForOthers */ ps->a_wGrayInitTime[1] = 720; /* _SppTimeForOthers */ ps->a_wGrayInitTime[2] = 360; /* _BidirTimeForOthers */ ps->a_wColorInitTime[0] = 500; /* _EppTimeForColor */ ps->a_wColorInitTime[1] = 1680; /* _SppTimeForColor */ ps->a_wColorInitTime[2] = 1100; /* _BidirTimeForColor */ ps->AsicRedColor = _ASIC_REDCOLOR; ps->AsicGreenColor = _ASIC_GREENCOLOR; ps->RedDataReady = _RED_DATA_READY; ps->GreenDataReady = _GREEN_DATA_READY; /* * used for shading stuff (see dac.c) */ ps->FBKScanLineBlks = 5; ps->FBKScanLineLenBase = 1024; ps->FBKScanLineLen = (ps->FBKScanLineLenBase * 3); ps->ShadingBufferSize = ps->FBKScanLineLen; ps->ShadingBankSize = (ps->FBKScanLineLenBase * 4); ps->ShadingBankRed = (_MemBankSize4k | 0x3a); ps->ShadingBankGreen = (_MemBankSize4k | 0x3e); ps->ShadingBankBlue = (_MemBankSize4k | 0x3c); ps->ShadingScanLineBlks = 6; ps->ShadingScanLineLen = (ps->BufferSizeBase * 3); ps->OneScanLineLen = (ps->BufferSizePerModel * 3); modelInitMotor( ps ); modelInitCaps ( ps ); modelInitPageSettings( ps ); DBG( DBG_LOW, "ModelSet4830() done.\n" ); } /*............................................................................. * set the model to 600, tested on a Primax Direct 4800 and OP600 */ _LOC void ModelSet600( pScanData ps ) { DBG( DBG_LOW, "ModelSet600()\n" ); /* * set to 4830 first, then do the differences */ ModelSet4830( ps ); ps->Device.buttons = 0; if( _OVR_PLUSTEK_4800P == ps->ModelOverride ) { DBG( DBG_LOW, "Model Override --> OpticPro4800\n" ); ps->sCaps.Model = MODEL_OP_4800P; } else if( _OVR_PRIMAX_4800D == ps->ModelOverride ) { DBG( DBG_LOW, "Model Override --> Primax 4800D\n" ); ps->sCaps.Model = MODEL_PMX_4800D; } else { ps->sCaps.Model = MODEL_OP_600P; /* for Plustek OpticPro 600P it's necessary to swap Red and Green * changed by mh moloch@nikocity.de */ ps->AsicRedColor = _ASIC_GREENCOLOR; ps->AsicGreenColor = _ASIC_REDCOLOR; } DBG( DBG_LOW, "ModelSet600() done.\n" ); } /*............................................................................. * set the model to 12000P, 96000P (tested on a OP96000P) */ _LOC void ModelSet12000( pScanData ps ) { DBG( DBG_LOW, "ModelSet12000()\n" ); /* * set to 9630 first, then do the differences */ ModelSet9630( ps ); ps->Device.buttons = 0; ps->sCaps.Model = MODEL_OP_12000P; /* * swapped Red and Green for 12000P/96000P */ ps->AsicRedColor = _ASIC_GREENCOLOR; ps->AsicGreenColor = _ASIC_REDCOLOR; ps->RedDataReady = _GREEN_DATA_READY; ps->GreenDataReady = _RED_DATA_READY; DBG( DBG_LOW, "ModelSet12000() done.\n" ); } /*............................................................................. * set the model to A3I */ _LOC void ModelSetA3I( pScanData ps ) { DBG( DBG_LOW, "ModelSetA3I()\n" ); /* * has 96003 ASIC */ ps->Device.buttons = 1; ps->sCaps.Model = MODEL_OP_A3I; ps->sCaps.AsicID = _ASIC_IS_96003; ps->Device.ModelCtrl = (_ModelDpi400 | _ModelMemSize128k4 | _ModelWhiteIs0); ps->Device.DataOriginX = 164; ps->PhysicalDpi = 400; ps->TimePerLine = 0x50; ps->Offset70 = 145; modelSetBufferSizes( ps ); ps->a_wGrayInitTime[0] = 133; /* _EppTimeForOthers */ ps->a_wGrayInitTime[1] = 720; /* _SppTimeForOthers */ ps->a_wGrayInitTime[2] = 300; /* _BidirTimeForOthers */ ps->a_wColorInitTime[0] = 400; /* _EppTimeForColor */ ps->a_wColorInitTime[1] = 1800; /* _SppTimeForColor */ ps->a_wColorInitTime[2] = 800; /* _BidirTimeForColor */ ps->AsicRedColor = _ASIC_GREENCOLOR; ps->AsicGreenColor = _ASIC_REDCOLOR; ps->RedDataReady = _GREEN_DATA_READY; ps->GreenDataReady = _RED_DATA_READY; ps->FBKScanLineBlks = 10; ps->FBKScanLineLenBase = 2048; ps->FBKScanLineLen = (ps->FBKScanLineLenBase * 3); ps->ShadingBufferSize = (1024 * 7); ps->ShadingBankSize = 8192; ps->ShadingBankRed = (_MemBankSize8k | 0x34); ps->ShadingBankGreen = (_MemBankSize8k | 0x3c); ps->ShadingBankBlue = (_MemBankSize8k | 0x38); ps->ShadingScanLineBlks = 10; ps->ShadingScanLineLen = (ps->BufferSizeBase * 3); ps->OneScanLineLen = (ps->ShadingScanLineLen * 2); modelInitMotor( ps ); ps->BackwardSteps = 9000; modelInitCaps( ps ); modelInitPageSettings( ps ); /* * need to double the vals */ ps->LensInf.rExtentX.wMax *= 2; ps->LensInf.rExtentX.wPhyMax *= 2; ps->LensInf.rExtentY.wMax *= 2; ps->LensInf.rExtentY.wPhyMax *= 2; DBG( DBG_LOW, "ModelSetA3I() done.\n" ); } /*............................................................................. * set the model to 9630 */ _LOC void ModelSet9630( pScanData ps ) { DBG( DBG_LOW, "ModelSet9360()\n" ); /* * has 96003 ASIC */ if( _OVR_PLUSTEK_9630PL == ps->ModelOverride ) { DBG( DBG_LOW, "Model Override --> 9630PL\n" ); ps->sCaps.Model = MODEL_OP_9630PL; } else { ps->sCaps.Model = MODEL_OP_9630P; } ps->Device.buttons = 1; ps->sCaps.AsicID = _ASIC_IS_96003; ps->Device.ModelCtrl = (_ModelDpi600 | _ModelMemSize128k4 | _ModelWhiteIs0); ps->Device.DataOriginX = 64; ps->PhysicalDpi = 600; ps->TimePerLine = 0x5a; ps->Offset70 = 95; modelSetBufferSizes( ps ); ps->a_wGrayInitTime[0] = 133; /* _EppTimeForOthers */ ps->a_wGrayInitTime[1] = 720; /* _SppTimeForOthers */ ps->a_wGrayInitTime[2] = 300; /* _BidirTimeForOthers */ ps->a_wColorInitTime[0] = 400; /* _EppTimeForColor */ ps->a_wColorInitTime[1] = 1800; /* _SppTimeForColor */ ps->a_wColorInitTime[2] = 800; /* _BidirTimeForColor */ ps->AsicRedColor = _ASIC_REDCOLOR; ps->AsicGreenColor = _ASIC_GREENCOLOR; ps->RedDataReady = _RED_DATA_READY; ps->GreenDataReady = _GREEN_DATA_READY; ps->ShadingBufferSize = (1024 * 7); ps->ShadingBankSize = 8192; ps->ShadingBankRed = (_MemBankSize8k | 0x34); ps->ShadingBankGreen = (_MemBankSize8k | 0x3c); ps->ShadingBankBlue = (_MemBankSize8k | 0x38); ps->ShadingScanLineBlks = 10; ps->ShadingScanLineLen = (2560 * 3); ps->FBKScanLineBlks = 10; ps->FBKScanLineLenBase = 2048; ps->FBKScanLineLen = (ps->FBKScanLineLenBase * 6); ps->OneScanLineLen = (5120 * 3); modelInitMotor( ps ); ps->BackwardSteps = 9000; modelInitCaps( ps ); modelInitPageSettings( ps ); /* * need to double the vals */ ps->LensInf.rExtentX.wMax *= 2; ps->LensInf.rExtentX.wPhyMax *= 2; ps->LensInf.rExtentY.wMax *= 2; ps->LensInf.rExtentY.wPhyMax *= 2; DBG( DBG_LOW, "ModelSet9630() done.\n" ); } /*............................................................................. * set the model to 9636 (ASIC 98001 models) * works for 9636P Turbo and 9636T /12000T */ _LOC void ModelSet9636( pScanData ps ) { DBG( DBG_LOW, "ModelSet9636()\n" ); /* *set to 9630 first, then do the differences */ ModelSet9630( ps ); ps->Device.buttons = 0; /* * has 98001 ASIC */ if( _OVR_PLUSTEK_9636 == ps->ModelOverride ) { DBG( DBG_LOW, "Model Override --> 9636P+/Turbo\n" ); ps->sCaps.Model = MODEL_OP_9636PP; } else if( _OVR_PLUSTEK_9636P == ps->ModelOverride ) { DBG( DBG_LOW, "Model Override --> 9636P\n" ); ps->sCaps.Model = MODEL_OP_9636P; } else { ps->sCaps.Model = MODEL_OP_9636T; ps->sCaps.dwFlag |= SFLAG_TPA; } ps->Device.DataOriginX = 72; ps->sCaps.AsicID = _ASIC_IS_98001; ps->TotalBufferRequire = _LINE_BUFSIZE * 2 + _LINE_BUFSIZE1 + ps->BufferForColorRunTable + _PROCESS_BUFSIZE; /* do it again, as ModelSet9630() changes the result of this function !*/ modelInitPageSettings( ps ); DBG( DBG_LOW, "ModelSet9636() done.\n" ); } /*............................................................................. * set the model to P12 (ASIC 98003 models) */ _LOC void ModelSetP12( pScanData ps ) { DBG( DBG_LOW, "ModelSetP12()\n" ); /* * set to 9630 first, then do the differences */ ModelSet9630( ps ); ps->Device.DataOriginX = 72; ps->sCaps.Model = MODEL_OP_PT12; ps->sCaps.AsicID = _ASIC_IS_98003; ps->TotalBufferRequire = _SizeTotalBufTpa; /* do it again, as ModelSet9630() changes the result of this function !*/ modelInitPageSettings( ps ); DBG( DBG_LOW, "ModelSetP12() done.\n" ); } /* END PLUSTEK-PP_MODEL.C ...................................................*/ sane-backends-1.0.29/backend/mustek_usb2.h0000666000000000000000000001154313615534521015210 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000-2005 Mustek. Originally maintained by Mustek Copyright (C) 2001-2005 by Henning Meier-Geinitz. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for the Mustek BearPaw 2448 TA Pro and similar USB2 scanners. */ #ifndef MUSTEK_USB2_H #define MUSTEK_USB2_H #ifndef SANE_I18N #define SANE_I18N(text) text #endif #define ENABLE(OPTION) s->opt[OPTION].cap &= ~SANE_CAP_INACTIVE #define DISABLE(OPTION) s->opt[OPTION].cap |= SANE_CAP_INACTIVE #define IS_ACTIVE(OPTION) (((s->opt[OPTION].cap) & SANE_CAP_INACTIVE) == 0) /* RIE: return if error */ #define RIE(function) do {status = function; if (status != SANE_STATUS_GOOD) \ return status;} while (SANE_FALSE) #define SCAN_BUFFER_SIZE (64 * 1024) #define MAX_RESOLUTIONS 12 #define DEF_LINEARTTHRESHOLD 128 #define PER_ADD_START_LINES 0 #define PRE_ADD_START_X 0 enum Mustek_Usb_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_SOURCE, OPT_RESOLUTION, OPT_PREVIEW, OPT_DEBUG_GROUP, OPT_AUTO_WARMUP, OPT_ENHANCEMENT_GROUP, OPT_THRESHOLD, OPT_GAMMA_VALUE, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ /* must come last: */ NUM_OPTIONS }; typedef struct Scanner_Model { /** @name Identification */ /*@{ */ /** A single lowercase word to be used in the configuration file. */ SANE_String_Const name; /** Device vendor string. */ SANE_String_Const vendor; /** Device model name. */ SANE_String_Const model; /** Name of the firmware file. */ SANE_String_Const firmware_name; /** @name Scanner model parameters */ /*@{ */ SANE_Int dpi_values[MAX_RESOLUTIONS]; /* possible resolutions */ SANE_Fixed x_offset; /* Start of scan area in mm */ SANE_Fixed y_offset; /* Start of scan area in mm */ SANE_Fixed x_size; /* Size of scan area in mm */ SANE_Fixed y_size; /* Size of scan area in mm */ SANE_Fixed x_offset_ta; /* Start of scan area in TA mode in mm */ SANE_Fixed y_offset_ta; /* Start of scan area in TA mode in mm */ SANE_Fixed x_size_ta; /* Size of scan area in TA mode in mm */ SANE_Fixed y_size_ta; /* Size of scan area in TA mode in mm */ RGBORDER line_mode_color_order; /* Order of the CCD/CIS colors */ SANE_Fixed default_gamma_value; /* Default gamma value */ SANE_Bool is_cis; /* Is this a CIS or CCD scanner? */ SANE_Word flags; /* Which hacks are needed for this scanner? */ /*@} */ } Scanner_Model; typedef struct Mustek_Scanner { /* all the state needed to define a scan request: */ struct Mustek_Scanner *next; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; unsigned short *gamma_table; SANE_Parameters params; /**< SANE Parameters */ Scanner_Model model; SETPARAMETERS setpara; GETPARAMETERS getpara; SANE_Bool bIsScanning; SANE_Bool bIsReading; SANE_Word read_rows; /* transfer image's lines */ SANE_Byte *Scan_data_buf; /*store Scanned data for transfer */ SANE_Byte *Scan_data_buf_start; /*point to data need to transfer */ size_t scan_buffer_len; /* length of data buf */ } Mustek_Scanner; #endif sane-backends-1.0.29/backend/sm3840_scan.c0000666000000000000000000010462513615534521014706 00000000000000/* sane - Scanner Access Now Easy. ScanMaker 3840 Backend Copyright (C) 2005 Earle F. Philhower, III earle@ziplabel.com - http://www.ziplabel.com 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include #include #include "sm3840_lib.h" #ifndef BACKENDNAME static void setup_scan (p_usb_dev_handle udev, SM3840_Params * p, char *stname, int raw, int nohead); #else static void setup_scan (p_usb_dev_handle udev, SM3840_Params * p); #endif #ifndef BACKENDNAME #include "sm3840_lib.c" int main (int argc, char *argv[]) { int i; int gray = 0; int dpi = 1200; int bpp16 = 0; int raw = 0; int nohead = 0; double gain = 3.5; int offset = 1800; usb_dev_handle *udev; char *stname; double topin, botin, leftin, rightin; int topline, scanlines, leftpix, scanpix; stname = NULL; topin = 0.0; botin = 11.7; leftin = 0.0; rightin = 8.5; for (i = 1; i < argc; i++) { if (!strcmp (argv[i], "-300")) dpi = 300; else if (!strcmp (argv[i], "-600")) dpi = 600; else if (!strcmp (argv[i], "-1200")) dpi = 1200; else if (!strcmp (argv[i], "-150")) dpi = 150; else if (!strcmp (argv[i], "-top")) topin = atof (argv[++i]); else if (!strcmp (argv[i], "-bot")) botin = atof (argv[++i]); else if (!strcmp (argv[i], "-left")) leftin = atof (argv[++i]); else if (!strcmp (argv[i], "-right")) rightin = atof (argv[++i]); else if (!strcmp (argv[i], "-gain")) gain = atof (argv[++i]); else if (!strcmp (argv[i], "-offset")) offset = atoi (argv[++i]); else if (!strcmp (argv[i], "-gray")) gray = 1; else if (!strcmp (argv[i], "-16bpp")) bpp16 = 1; else if (!strcmp (argv[i], "-raw")) raw = 1; else if (!strcmp (argv[i], "-nohead")) nohead = 1; else stname = argv[i]; } SM3840_Params params; params.gray = gray; params.dpi = dpi; params.bpp = bpp16 ? 16 : 8; params.gain = gain; params.offset = offset; params.lamp = 15; params.top = topin; params.left = leftin; params.height = botin - topin; params.width = rightin - leftin; prepare_params (¶ms); udev = find_device (0x05da, 0x30d4); /* 3840 */ if (!udev) udev = find_device (0x05da, 0x30cf); /* 4800 */ if (!udev) fprintf (stderr, "Unable to open scanner.\n"); else setup_scan (udev, ¶ms, stname, raw, nohead); return 0; } #endif #ifndef BACKENDNAME static void setup_scan (p_usb_dev_handle udev, SM3840_Params * p, char *stname, int raw, int nohead) #else static void setup_scan (p_usb_dev_handle udev, SM3840_Params * p) #endif { int gray = p->gray ? 1 : 0; int dpi = p->dpi; int bpp16 = (p->bpp == 16) ? 1 : 0; double gain = p->gain; int offset = p->offset; int topline = p->topline; int scanlines = p->scanlines; int leftpix = p->leftpix; int scanpix = p->scanpix; unsigned char hello[2] = { 0x55, 0xaa }; unsigned char howdy[3]; unsigned short *whitebalance; int whitebalancesize = (dpi == 1200) ? 12672 : 6528; unsigned short *whitemap; int whitemapsize = (dpi == 1200) ? 29282 : 14642; unsigned short *whitescan; unsigned short *lightmap; unsigned int topreg, botreg; int redreg, greenreg, bluereg, donered, donegreen, doneblue; int rgreg = 0x00; int ggreg = 0x00; int bgreg = 0x00; int i, j; int red, green, blue; unsigned char rd_byte; unsigned short GRAYMASK = 0xc000; #ifndef BACKENDNAME char fname[64]; char head[128]; 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); DBG (2, "params.bpp = %d\n", p->bpp); DBG (2, "params.gain = %f\n", p->gain); DBG (2, "params.offset = %d\n", p->offset); DBG (2, "params.lamp = %d\n", p->lamp); DBG (2, "params.top = %f\n", p->top); DBG (2, "params.left = %f\n", p->left); DBG (2, "params.height = %f\n", p->height); DBG (2, "params.width = %f\n", p->width); DBG (2, "params.topline = %d\n", p->topline); DBG (2, "params.scanlines = %d\n", p->scanlines); DBG (2, "params.leftpix = %d\n", p->leftpix); DBG (2, "params.scanpix = %d\n", p->scanpix); DBG (2, "params.linelen = %d\n", p->linelen); reset_scanner (udev); idle_ab (udev); 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); write_regs (udev, 1, 0x97, 0x0b); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x0f); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x05); write_vctl (udev, 0x0b, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 7, 0xa8, 0x80, 0x83, 0xa2, 0x85, 0x01, 0x83, 0x82, 0x85, 0x00, 0x83, 0x00, 0x93, 0x00); write_regs (udev, 1, 0xa8, 0x80); 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); write_regs (udev, 1, 0x97, 0x0b); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x0f); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x05); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 4, 0x83, 0x20, 0x8d, 0xfe, 0x83, 0x00, 0x8d, 0xff); write_regs (udev, 1, 0x97, 0x00); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 8, 0x80, 0x00, 0x84, 0x00, 0xbe, 0x00, 0xc0, 0x00, 0x86, 0x00, 0x89, 0x00, 0x94, 0x00, 0x01, 0x02); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); write_regs (udev, 1, 0x94, 0x51); write_regs (udev, 1, 0xb0, 0x00); write_regs (udev, 1, 0xb1, 0x00); write_regs (udev, 1, 0xb2, 0x00); write_regs (udev, 1, 0xb3, 0x00); write_regs (udev, 1, 0xb4, 0x10); write_regs (udev, 1, 0xb5, 0x1f); write_regs (udev, 1, 0xb0, 0x00); write_regs (udev, 1, 0xb1, 0x00); write_regs (udev, 1, 0xb2, 0x00); write_vctl (udev, 0x0c, 0x0002, 0x0002, 0x00); 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); 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); write_regs (udev, 1, 0x97, 0x0b); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x0f); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x05); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 4, 0x83, 0x20, 0x8d, 0xfe, 0x83, 0x00, 0x8d, 0xff); write_regs (udev, 1, 0x97, 0x00); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 8, 0x80, 0x00, 0x84, 0x00, 0xbe, 0x00, 0xc0, 0x00, 0x86, 0x00, 0x89, 0x00, 0x94, 0x00, 0x01, 0x02); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); write_regs (udev, 16, 0xbe, 0x18, 0x80, 0x00, 0x84, 0x00, 0x89, 0x00, 0x88, 0x00, 0x86, 0x00, 0x90, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc0, 0x00); write_regs (udev, 4, 0x83, 0x20, 0x8d, 0xff, 0x83, 0x00, 0x8d, 0xff); write_regs (udev, 5, 0x83, 0x00, 0xa3, 0xff, 0xa4, 0xff, 0xa1, 0xff, 0xa2, 0xf7); write_regs (udev, 4, 0x83, 0x22, 0x87, 0x01, 0x83, 0x02, 0x87, 0x16); write_regs (udev, 11, 0xa0, 0x00, 0x9c, 0x00, 0x9f, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0xa0, 0x00, 0xce, 0x0c, 0x83, 0x20, 0xa5, 0x00, 0xa6, 0x00, 0xa7, 0x00); set_gain_black (udev, 0x01, 0x01, 0x01, 0xaa, 0xaa, 0xaa); write_regs (udev, 16, 0x9b, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x01, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x02, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x03, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00); write_regs (udev, 4, 0x83, 0xa2, 0x85, 0x98, 0x83, 0x82, 0x85, 0x3a); write_regs (udev, 1, 0x9d, 0x80); write_regs (udev, 1, 0x9d, 0x00); if (dpi == 1200) write_regs (udev, 1, 0x94, 0x51); else write_regs (udev, 1, 0x94, 0x61); whitemap = (unsigned short *) malloc (whitemapsize); set_lightmap_white (whitemap, dpi, 0); if (dpi == 1200) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x80, 0xb2, 0x06, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x06); else write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x40, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x7f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, wr_timeout); set_lightmap_white (whitemap, dpi, 1); if (dpi == 1200) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x7f, 0xb5, 0x07); else write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x80, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xbf, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, wr_timeout); set_lightmap_white (whitemap, dpi, 2); if (dpi == 1200) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x80, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x07); else write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0xc0, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); usb_bulk_write (udev, 2, (unsigned char *) whitemap, whitemapsize, wr_timeout); free (whitemap); /* Move to head... */ idle_ab (udev); write_regs (udev, 1, 0x97, 0x00); idle_ab (udev); write_regs (udev, 16, 0xbe, 0x18, 0x80, 0x00, 0x84, 0x00, 0x89, 0x00, 0x88, 0x00, 0x86, 0x00, 0x90, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc0, 0x00); idle_ab (udev); write_regs (udev, 16, 0x84, 0x94, 0x80, 0xd1, 0x80, 0xc1, 0x82, 0x7f, 0xcf, 0x04, 0xc1, 0x02, 0xc2, 0x00, 0xc3, 0x06, 0xc4, 0xff, 0xc5, 0x40, 0xc6, 0x8c, 0xc7, 0xdc, 0xc8, 0x20, 0xc0, 0x72, 0x89, 0xff, 0x86, 0xff); poll1 (udev); write_regs (udev, 4, 0x83, 0xa2, 0x85, 0x01, 0x83, 0x82, 0x85, 0x00); write_regs (udev, 1, 0x9d, 0x80); write_regs (udev, 1, 0x9d, 0x00); if (dpi == 1200) write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x77, 0xb9, 0x1e); else write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x3b, 0xb9, 0x1f); write_regs (udev, 5, 0xc0, 0x00, 0x84, 0x00, 0x80, 0xa1, 0xcf, 0x04, 0x82, 0x00); if (dpi == 1200) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x02, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x01, 0xbd, 0x01, 0x88, 0xa4, 0xc1, 0x02, 0xc2, 0x00, 0xc3, 0x02, 0xc4, 0x01, 0xc5, 0x01, 0xc6, 0xa3, 0xc7, 0xa4, 0xc8, 0x04, 0xc0, 0xd2, 0x89, 0x05, 0x86, 0x00); else write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x04, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x01, 0xbd, 0x01, 0x88, 0xd0, 0xc1, 0x01, 0xc2, 0x00, 0xc3, 0x04, 0xc4, 0x01, 0xc5, 0x01, 0xc6, 0xcf, 0xc7, 0xd0, 0xc8, 0x14, 0xc0, 0xd1, 0x89, 0x0a, 0x86, 0x00); write_regs (udev, 8, 0xbb, 0x01, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x40, 0x91, 0x00, 0x83, 0x82); write_regs (udev, 1, 0xbe, 0x0d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); whitebalance = (unsigned short *) malloc (whitebalancesize); usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); 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); redreg = greenreg = bluereg = 0x80; red = green = blue = 0; donered = donegreen = doneblue = 0; DBG (2, "setting blackpoint\n"); for (j = 0; (j < 16) && !(donered && donegreen && doneblue); j++) { set_gain_black (udev, 0x01, 0x01, 0x01, redreg, greenreg, bluereg); if (dpi == 1200) write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x77, 0xb9, 0x1e); else write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x3b, 0xb9, 0x1f); write_regs (udev, 8, 0xbb, 0x01, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x40, 0x91, 0x00, 0x83, 0x82); write_regs (udev, 1, 0xbe, 0x0d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); usb_bulk_read (udev, 1, (unsigned char *) whitebalance, whitebalancesize, rd_timeout); fix_endian_short (whitebalance, whitebalancesize/2); if (!donered) { red = (whitebalance[0] + whitebalance[3] + whitebalance[6]) / 3; if (red > 0x1000) redreg += 0x10; else if (red > 0x500) redreg += 0x08; else if (red > 0x0010) redreg++; else donered = 1; } if (!donegreen) { green = (whitebalance[1] + whitebalance[4] + whitebalance[7]) / 3; if (green > 0x1000) greenreg += 0x10; else if (green > 0x0500) greenreg += 0x08; else if (green > 0x0010) greenreg++; else donegreen = 1; } if (!doneblue) { blue = (whitebalance[2] + whitebalance[5] + whitebalance[8]) / 3; if (blue > 0x1000) bluereg += 0x10; else if (blue > 0x0500) bluereg += 0x08; else if (blue > 0x0010) bluereg++; else doneblue = 1; } DBG (2, "red=%d(%d)%02x, green=%d(%d)%02x, blue=%d(%d)%02x\n", red, donered, redreg, green, donegreen, greenreg, blue, doneblue, bluereg); write_regs (udev, 2, 0xbe, 0x00, 0x84, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); } DBG (2, "setting whitepoint\n"); donegreen = donered = doneblue = 0; for (j = 0; (j < 16) && !(donered && donegreen && doneblue); j++) { set_gain_black (udev, rgreg, ggreg, bgreg, redreg, greenreg, bluereg); if (dpi == 1200) idle_ab (udev); write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x3b, 0xb9, 0x1f); if (dpi == 1200) idle_ab (udev); write_regs (udev, 8, 0xbb, 0x01, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x40, 0x91, 0x00, 0x83, 0x82); write_regs (udev, 1, 0xbe, 0x0d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); usb_bulk_read (udev, 1, (unsigned char *) whitebalance, whitebalancesize, rd_timeout); fix_endian_short (whitebalance, whitebalancesize/2); if (!donered) { red = (whitebalance[180 * 3 + 0] + whitebalance[180 * 3 + 3] + whitebalance[180 * 3 + 6]) / 3; if (red < 0x5000) rgreg += 0x02; else if (red < 0x8000) rgreg += 0x01; else donered = 1; } if (!donegreen) { green = (whitebalance[180 * 3 + 1] + whitebalance[180 * 3 + 4] + whitebalance[180 * 3 + 7]) / 3; if (green < 0x5000) ggreg += 0x02; else if (green < 0x8000) ggreg += 0x01; else donegreen = 1; } if (!doneblue) { blue = (whitebalance[180 * 3 + 2] + whitebalance[180 * 3 + 5] + whitebalance[180 * 3 + 8]) / 3; if (blue < 0x5000) bgreg += 0x02; else if (blue < 0x8000) bgreg += 0x01; else doneblue = 1; } DBG (2, "red=%d(%d)%02x, green=%d(%d)%02x, blue=%d(%d)%02x\n", red, donered, rgreg, green, donegreen, ggreg, blue, doneblue, bgreg); write_regs (udev, 2, 0xbe, 0x00, 0x84, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); } free (whitebalance); /* One step down for optimal contrast... */ if (rgreg) rgreg--; if (bgreg) bgreg--; if (ggreg) ggreg--; write_regs (udev, 8, 0x80, 0x00, 0x84, 0x00, 0xbe, 0x00, 0xc0, 0x00, 0x86, 0x00, 0x89, 0x00, 0x94, 0x00, 0x01, 0x02); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); write_regs (udev, 16, 0xbe, 0x18, 0x80, 0x00, 0x84, 0x00, 0x89, 0x00, 0x88, 0x00, 0x86, 0x00, 0x90, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc0, 0x00); write_regs (udev, 4, 0x83, 0x20, 0x8d, 0xff, 0x83, 0x00, 0x8d, 0xff); write_regs (udev, 5, 0x83, 0x00, 0xa3, 0xff, 0xa4, 0xff, 0xa1, 0xff, 0xa2, 0xf7); write_regs (udev, 4, 0x83, 0x22, 0x87, 0x01, 0x83, 0x02, 0x87, 0x16); write_regs (udev, 11, 0xa0, 0x00, 0x9c, 0x00, 0x9f, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0xa0, 0x00, 0xce, 0x0c, 0x83, 0x20, 0xa5, 0x00, 0xa6, 0x00, 0xa7, 0x00); set_gain_black (udev, rgreg, ggreg, bgreg, redreg, greenreg, bluereg); write_regs (udev, 16, 0x9b, 0x00, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x01, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x02, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x03, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00); write_regs (udev, 4, 0x83, 0xa2, 0x85, 0x98, 0x83, 0x82, 0x85, 0x3a); write_regs (udev, 1, 0x9d, 0x80); write_regs (udev, 1, 0x9d, 0x00); if (dpi == 1200) write_regs (udev, 1, 0x94, 0x71); else write_regs (udev, 1, 0x94, 0x61); write_regs (udev, 4, 0x83, 0xa2, 0x85, 0x01, 0x83, 0x82, 0x85, 0x00); write_regs (udev, 1, 0x9d, 0x80); write_regs (udev, 1, 0x9d, 0x00); if (dpi == 1200) write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0xbf, 0xb9, 0x17); else write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0xdf, 0xb9, 0x1b); write_regs (udev, 6, 0xc0, 0x00, 0x84, 0x00, 0x84, 0xb4, 0x80, 0xe1, 0xcf, 0x04, 0x82, 0x00); if (dpi == 1200) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x02, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x20, 0xbd, 0x08, 0x88, 0xa4, 0xc1, 0x02, 0xc2, 0x00, 0xc3, 0x02, 0xc4, 0x20, 0xc5, 0x08, 0xc6, 0x96, 0xc7, 0xa4, 0xc8, 0x06, 0xc0, 0xd2, 0x89, 0x24, 0x86, 0x01); else write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x04, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x20, 0xbd, 0x10, 0x88, 0xd0, 0xc1, 0x01, 0xc2, 0x00, 0xc3, 0x04, 0xc4, 0x20, 0xc5, 0x10, 0xc6, 0xc3, 0xc7, 0xd0, 0xc8, 0x1c, 0xc0, 0xd1, 0x89, 0x24, 0x86, 0x01); write_regs (udev, 8, 0xbb, 0x05, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x40, 0x91, 0x00, 0x83, 0x82); write_regs (udev, 1, 0xbe, 0x1d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); 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); fix_endian_short (whitescan, (5632 * 2 * 3 * (dpi == 1200 ? 2 : 1)) * 2); write_regs (udev, 5, 0x83, 0x00, 0xa3, 0xff, 0xa4, 0xff, 0xa1, 0xff, 0xa2, 0xff); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); write_regs (udev, 2, 0xbe, 0x00, 0x84, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); 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); write_regs (udev, 1, 0x97, 0x0b); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x0f); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x05); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 4, 0x83, 0x20, 0x8d, 0xff, 0x83, 0x00, 0x8d, 0xff); write_regs (udev, 1, 0x97, 0x00); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x00); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 16, 0xbe, 0x18, 0x80, 0x00, 0x84, 0x00, 0x89, 0x00, 0x88, 0x00, 0x86, 0x00, 0x90, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc0, 0x00); write_regs (udev, 16, 0x84, 0x94, 0x80, 0xd1, 0x80, 0xc1, 0x82, 0x7f, 0xcf, 0x04, 0xc1, 0x02, 0xc2, 0x00, 0xc3, 0x06, 0xc4, 0xff, 0xc5, 0x40, 0xc6, 0x8c, 0xc7, 0xdc, 0xc8, 0x20, 0xc0, 0x72, 0x89, 0xff, 0x86, 0xff); poll1 (udev); /* ready scan position */ /* 1/3" of unscannable area at top... */ if (dpi == 300) topreg = 120 * 4; else if (dpi == 600) topreg = 139 * 4; else if (dpi == 1200) topreg = 152 * 4; else /*if (dpi == 150) */ topreg = 120 * 4; topreg += topline * (1200 / dpi); write_regs (udev, 16, 0xbe, 0x18, 0x80, 0x00, 0x84, 0x00, 0x89, 0x00, 0x88, 0x00, 0x86, 0x00, 0x90, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc0, 0x00); write_regs (udev, 14, 0x84, 0xb4, 0x80, 0xe1, 0xcf, 0x04, 0xc1, 0x02, 0xc2, 0x00, 0xc3, 0x07, 0xc4, 0xff, 0xc5, 0x40, 0xc6, 0x8c, 0xc7, 0xdc, 0xc8, 0x20, 0xc0, 0x72, 0x89, topreg & 255, 0x86, 255 & (topreg >> 8)); write_regs (udev, 1, 0x97, 0x00); poll2 (udev); write_regs (udev, 8, 0x80, 0x00, 0x84, 0x00, 0xbe, 0x00, 0xc0, 0x00, 0x86, 0x00, 0x89, 0x00, 0x94, 0x00, 0x01, 0x02); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); write_regs (udev, 16, 0xbe, 0x18, 0x80, 0x00, 0x84, 0x00, 0x89, 0x00, 0x88, 0x00, 0x86, 0x00, 0x90, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc0, 0x00); if (dpi == 1200) write_regs (udev, 4, 0x83, 0x20, 0x8d, 0x24, 0x83, 0x00, 0x8d, 0xff); else write_regs (udev, 4, 0x83, 0x20, 0x8d, 0xff, 0x83, 0x00, 0x8d, 0xff); if (dpi != 1200) write_regs (udev, 5, 0x83, 0x00, 0xa3, 0xff, 0xa4, 0xff, 0xa1, 0xff, 0xa2, 0xf7); if (dpi == 1200) write_regs (udev, 4, 0x83, 0x22, 0x87, 0x01, 0x83, 0x02, 0x87, 0x2c); else write_regs (udev, 4, 0x83, 0x22, 0x87, 0x01, 0x83, 0x02, 0x87, 0x16); if (dpi == 1200) write_regs (udev, 11, 0xa0, 0x00, 0x9c, 0x00, 0x9f, 0x40, 0x9d, 0x00, 0x9e, 0x00, 0xa0, 0x00, 0xce, 0x0c, 0x83, 0x20, 0xa5, 0x00, 0xa6, 0x00, 0xa7, 0x00); else write_regs (udev, 11, 0xa0, 0x00, 0x9c, 0x00, 0x9f, 0x00, 0x9d, 0x00, 0x9e, 0x00, 0xa0, 0x00, 0xce, 0x0c, 0x83, 0x20, 0xa5, 0x00, 0xa6, 0x00, 0xa7, 0x00); set_gain_black (udev, rgreg, ggreg, bgreg, redreg, greenreg, bluereg); if (!bpp16) { if (dpi == 1200) write_regs (udev, 16, 0x9b, 0x00, 0x98, 0xc7, 0x99, 0x99, 0x9a, 0xd5, 0x9b, 0x01, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x02, 0x98, 0xc8, 0x99, 0x99, 0x9a, 0xd3, 0x9b, 0x03, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00); else if (dpi == 150) write_regs (udev, 16, 0x9b, 0x00, 0x98, 0x94, 0x99, 0x67, 0x9a, 0x83, 0x9b, 0x01, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x02, 0x98, 0x7e, 0x99, 0x5d, 0x9a, 0x7d, 0x9b, 0x03, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00); else write_regs (udev, 16, 0x9b, 0x00, 0x98, 0xb3, 0x99, 0x72, 0x9a, 0x9d, 0x9b, 0x01, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x02, 0x98, 0xa3, 0x99, 0x6f, 0x9a, 0x94, 0x9b, 0x03, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00); } else { if (dpi == 1200) write_regs (udev, 16, 0x9b, 0x00, 0x98, 0xb9, 0x99, 0x7a, 0x9a, 0xd6, 0x9b, 0x01, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x02, 0x98, 0xbc, 0x99, 0x7c, 0x9a, 0xd3, 0x9b, 0x03, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00); else if (dpi == 150) write_regs (udev, 16, 0x9b, 0x00, 0x98, 0x9c, 0x99, 0x5f, 0x9a, 0x87, 0x9b, 0x01, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x02, 0x98, 0x97, 0x99, 0x58, 0x9a, 0x81, 0x9b, 0x03, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00); else write_regs (udev, 16, 0x9b, 0x00, 0x98, 0x9d, 0x99, 0x79, 0x9a, 0x8e, 0x9b, 0x01, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00, 0x9b, 0x02, 0x98, 0x89, 0x99, 0x71, 0x9a, 0x80, 0x9b, 0x03, 0x98, 0x00, 0x99, 0x00, 0x9a, 0x00); } write_regs (udev, 4, 0x83, 0xa2, 0x85, 0x98, 0x83, 0x82, 0x85, 0x3a); write_regs (udev, 1, 0x9d, 0x80); write_regs (udev, 1, 0x9d, 0x00); if (!bpp16) { if (dpi == 1200) write_regs (udev, 1, 0x94, 0x51); else write_regs (udev, 1, 0x94, 0x41); } else { if (dpi == 1200) write_regs (udev, 1, 0x94, 0x71); else write_regs (udev, 1, 0x94, 0x61); } lightmap = (unsigned short *) malloc (whitemapsize); calc_lightmap (whitescan, lightmap, 0, dpi, gain, offset); select_pixels (lightmap, dpi, leftpix, scanpix); if (dpi == 1200) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x80, 0xb2, 0x06, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x06); else write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x40, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x7f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, wr_timeout); calc_lightmap (whitescan, lightmap, 1, dpi, gain, offset); if (dpi == 1200) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x7f, 0xb5, 0x07); else write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x80, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xbf, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); fix_endian_short (&GRAYMASK, 1); if (gray) for (i = 0; i < whitemapsize / 2; i++) lightmap[i] |= GRAYMASK; usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, wr_timeout); calc_lightmap (whitescan, lightmap, 2, dpi, gain, offset); if (dpi == 1200) write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x80, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x07); else write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0xc0, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, whitemapsize, 0x00); usb_bulk_write (udev, 2, (unsigned char *) lightmap, whitemapsize, wr_timeout); free (whitescan); free (lightmap); if (!bpp16) download_lut8 (udev, dpi, gray ? 0 : 1); write_regs (udev, 4, 0x83, 0xa2, 0x85, 0x01, 0x83, 0x82, 0x85, 0x00); write_regs (udev, 1, 0x9d, 0x80); write_regs (udev, 1, 0x9d, 0x00); if (!bpp16) { if (dpi == 1200) write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0x1f, 0xb5, 0x06, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x43, 0xb9, 0x2d); else if (dpi == 150) write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0x0f, 0xb5, 0x07, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0xe0, 0xb9, 0x37); else write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0x0f, 0xb5, 0x07, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x90, 0xb9, 0x37); } else { if (dpi == 1200) write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x87, 0xb9, 0x18); else if (dpi == 150) write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0xc1, 0xb9, 0x1e); else write_regs (udev, 10, 0xb0, 0x00, 0xb1, 0x00, 0xb2, 0x00, 0xb3, 0xff, 0xb4, 0xff, 0xb5, 0x03, 0xb6, 0x01, 0xb7, 0x00, 0xb8, 0x21, 0xb9, 0x1e); } /* [86,89] controls number of 300dpi steps to scan */ botreg = scanlines * (1200 / dpi) + 400; write_regs (udev, 6, 0xc0, 0x00, 0x84, 0x00, 0x84, 0xb4, 0x80, 0xe1, 0xcf, 0x04, 0x82, 0x00); if (!bpp16) { if (dpi == 300) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x04, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x20, 0xbd, 0x10, 0x88, 0xd0, 0xc1, 0x01, 0xc2, 0x00, 0xc3, 0x04, 0xc4, 0x20, 0xc5, 0x10, 0xc6, 0xc3, 0xc7, 0xd0, 0xc8, 0x12, 0xc0, 0xd1, 0x89, botreg & 255, 0x86, 255 & (botreg >> 8)); else if (dpi == 600) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x04, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x20, 0xbd, 0x10, 0x88, 0xd0, 0xc1, 0x01, 0xc2, 0x00, 0xc3, 0x04, 0xc4, 0x20, 0xc5, 0x10, 0xc6, 0xc3, 0xc7, 0xd0, 0xc8, 0x16, 0xc0, 0xd1, 0x89, botreg & 255, 0x86, 255 & (botreg >> 8)); else if (dpi == 1200) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x02, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x20, 0xbd, 0x08, 0x88, 0xa4, 0xc1, 0x02, 0xc2, 0x00, 0xc3, 0x02, 0xc4, 0x20, 0xc5, 0x08, 0xc6, 0x96, 0xc7, 0xa4, 0xc8, 0x06, 0xc0, 0xd2, 0x89, botreg & 255, 0x86, 255 & (botreg >> 8)); else if (dpi == 150) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x06, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x1c, 0xbd, 0x08, 0x88, 0xe0, 0xc1, 0x01, 0xc2, 0x00, 0xc3, 0x03, 0xc4, 0x1c, 0xc5, 0x08, 0xc6, 0xd7, 0xc7, 0xe0, 0xc8, 0x11, 0xc0, 0xd1, 0x89, botreg & 255, 0x86, 255 & (botreg >> 8)); if (dpi == 300) write_regs (udev, 8, 0xbb, 0x01, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x20, 0x91, 0x00, 0x83, 0x82); else if (dpi == 600) write_regs (udev, 8, 0xbb, 0x02, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x20, 0x91, 0x00, 0x83, 0x82); else if (dpi == 1200) write_regs (udev, 8, 0xbb, 0x02, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x20, 0x91, 0x00, 0x83, 0x82); else if (dpi == 150) write_regs (udev, 8, 0xbb, 0x00, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x20, 0x91, 0x00, 0x83, 0x82); } else { if (dpi == 300) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x04, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x20, 0xbd, 0x10, 0x88, 0xd0, 0xc1, 0x01, 0xc2, 0x00, 0xc3, 0x04, 0xc4, 0x20, 0xc5, 0x10, 0xc6, 0xc3, 0xc7, 0xd0, 0xc8, 0x13, 0xc0, 0xd1, 0x89, botreg & 255, 0x86, 255 & (botreg >> 8)); else if (dpi == 150) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x06, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x1c, 0xbd, 0x08, 0x88, 0xe0, 0xc1, 0x01, 0xc2, 0x00, 0xc3, 0x03, 0xc4, 0x1c, 0xc5, 0x08, 0xc6, 0xd7, 0xc7, 0xe0, 0xc8, 0x12, 0xc0, 0xd1, 0x89, botreg & 255, 0x86, 255 & (botreg >> 8)); else if (dpi == 1200) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x02, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x20, 0xbd, 0x08, 0x88, 0xa4, 0xc1, 0x02, 0xc2, 0x00, 0xc3, 0x02, 0xc4, 0x20, 0xc5, 0x08, 0xc6, 0x96, 0xc7, 0xa4, 0xc8, 0x0c, 0xc0, 0xd2, 0x89, botreg & 255, 0x86, 255 & (botreg >> 8)); else if (dpi == 600) write_regs (udev, 18, 0x83, 0xa2, 0x85, 0x04, 0x83, 0x82, 0x85, 0x00, 0xbc, 0x20, 0xbd, 0x10, 0x88, 0xd0, 0xc1, 0x01, 0xc2, 0x00, 0xc3, 0x04, 0xc4, 0x20, 0xc5, 0x10, 0xc6, 0xc3, 0xc7, 0xd0, 0xc8, 0x1a, 0xc0, 0xd1, 0x89, botreg & 255, 0x86, 255 & (botreg >> 8)); if (dpi == 300) write_regs (udev, 8, 0xbb, 0x02, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x70, 0x91, 0x00, 0x83, 0x82); else if (dpi == 150) write_regs (udev, 8, 0xbb, 0x01, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x70, 0x91, 0x00, 0x83, 0x82); else if (dpi == 1200) write_regs (udev, 8, 0xbb, 0x05, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x70, 0x91, 0x00, 0x83, 0x82); else if (dpi == 600) write_regs (udev, 8, 0xbb, 0x04, 0x9b, 0x24, 0x8b, 0x00, 0x8e, 0x80, 0xbf, 0x00, 0x90, 0x70, 0x91, 0x00, 0x83, 0x82); } if (gray) write_regs (udev, 1, 0xbe, 0x05); else write_regs (udev, 1, 0xbe, 0x0d); write_vctl (udev, 0x0c, 0x0003, 0x0001, 0x00); usb_bulk_read (udev, 1, &rd_byte, 1, rd_timeout); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); #ifndef BACKENDNAME sprintf (fname, "%d.%s", dpi, gray ? "pgm" : "ppm"); if (stname) strcpy (fname, stname); sprintf (head, "P%d\n%d %d\n%d\n", gray ? 5 : 6, scanpix, scanlines, bpp16 ? 65535 : 255); if (nohead) head[0] = 0; if (!raw) record_image (udev, fname, dpi, scanpix, scanlines, gray, head, bpp16); else record_head (udev, fname, scanpix * (gray ? 1 : 3) * (bpp16 ? 2 : 1) * scanlines, ""); reset_scanner (udev); idle_ab (udev); set_lamp_timer (udev, 5); #endif } sane-backends-1.0.29/backend/cardscan.c0000666000000000000000000013306713615534521014524 00000000000000/* sane - Scanner Access Now Easy. This file is part of the SANE package, and implements a SANE backend for various Corex Cardscan scanners. 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 published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. -------------------------------------------------------------------------- The source code is divided in sections which you can easily find by searching for the tag "@@". Section 1 - Init & static stuff Section 2 - sane_init, _get_devices, _open & friends Section 3 - sane_*_option functions Section 4 - sane_start, _get_param, _read & friends Section 5 - sane_close functions Section 6 - misc functions Changes: v0, 2007-05-09, MAN (SANE v1.0.19) - initial release v1, 2008-02-14, MAN - sanei_config_read has already cleaned string (#310597) v2, 2010-02-10, MAN - add lines_per_block config option - 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: cmd packet format: cmdcode cmdlenlow cmdlenhigh cmdpayloadbytes resp packet format: respcode paperfound resplenlow resplenhigh respayloadbytes ############ status read loop? ################## >> 01 01 00 00 << 81 00 07 00 00 09 0c 61 c2 7a 0a >> 34 00 00 << b4 00 00 00 >> 01 01 00 00 << 81 00 07 00 00 09 0c 61 c2 7a 0a >> 34 00 00 << b4 00 00 00 >> 01 01 00 00 << 81 00 07 00 00 09 0c 61 c2 7a 0a ############# scanner settings read? (0x04b8 is scan width) ############# >> 48 00 00 << c8 00 0c 00 b8 04 60 00 00 80 00 00 00 58 ca 7d ############## color and gray calibration data read ############ >> 45 00 00 << 0x2600 bytes, bbbBBBgggGGGrrrRRRxxxXXX ############ 34/b4 and 01/81 status loop til paper inserted ############## >> 35 01 00 00 << b5 01 01 00 00 always together? { >> 14 05 00 80 1b 28 00 0f << 94 01 05 00 80 1b 28 00 0f >> 22 01 00 00 << a2 01 01 00 00 } >> 1a 01 00 66 << 9a 01 01 00 66 >> 19 03 00 51 62 49 << 99 01 03 00 51 62 49 ############# heat up lamp? ################# ===========color=================== three times { >> 18 07 00 00 01 60 00 61 00 07 << 0x40 read and 0x03 read the 3 byte drops from f4 f4 f4 to 17 10 08 etc. } ===========gray=================== three times { >> 12 06 00 00 01 60 00 61 00 << 0x40 read and 0x01 read } the 1 byte drops from f4 to 02 ================================== >> 35 01 00 00 << b5 01 01 00 00 >> 13 01 00 28 << 93 01 01 00 28 ===========color=================== three times { >> 18 07 00 01 10 60 00 18 05 07 << 0xe2c0 read } 14/94 and 22/a2 many times { >> 18 07 00 01 10 60 00 18 05 07 << 0xe2c0 read } ===========gray=================== two times { >> 12 06 00 01 10 60 00 18 05 << 0x4bc0 read } 14/94 and 22/a2 many times { >> 12 06 00 01 10 60 00 18 05 << 0x4bc0 read } ================================== >> 35 01 00 ff << b5 00 01 00 ff 14/94 and 22/a2 ########### discarge capacitor? ########### four times { >> 21 02 00 0a 00 << a1 00 02 00 0a 00 } >> 01 01 00 00 << 81 00 07 00 00 09 0c 61 c2 7a 0a >> 35 01 00 ff << b5 00 01 00 ff >> 34 00 00 << b4 00 00 00 ############################################# SANE FLOW DIAGRAM - sane_init() : initialize backend . - sane_get_devices() : query list of scanner devices . - sane_open() : open a particular scanner device . . - sane_set_io_mode : set blocking mode . . - sane_get_select_fd : get scanner fd . . . . - sane_get_option_descriptor() : get option information . . - sane_control_option() : change option values . . - sane_get_parameters() : returns estimated scan parameters . . - (repeat previous 3 functions) . . . . - sane_start() : start image acquisition . . - sane_get_parameters() : returns actual scan parameters . . - sane_read() : read image data (from pipe) . . (sane_read called multiple times; after sane_read returns EOF, . . loop may continue with sane_start which may return a 2nd page . . when doing duplex scans, or load the next page from the ADF) . . . . - sane_cancel() : cancel operation . - sane_close() : close opened scanner device - sane_exit() : terminate use of backend */ /* * @@ Section 1 - Init */ #include "../include/sane/config.h" #include /*memcpy...*/ #include /*isspace*/ #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include "cardscan.h" #define DEBUG 1 #define BUILD 3 /* values for SANE_DEBUG_CARDSCAN env var: - errors 5 - function trace 10 - function detail 15 - get/setopt cmds 20 - usb cmd trace 25 - usb cmd detail 30 - useless noise 35 */ int global_has_cal_buffer = 1; int global_lines_per_block = 16; /* ------------------------------------------------------------------------- */ #define STRING_GRAYSCALE SANE_VALUE_SCAN_MODE_GRAY #define STRING_COLOR SANE_VALUE_SCAN_MODE_COLOR /* * used by attach* and sane_get_devices * a ptr to a null term array of ptrs to SANE_Device structs * a ptr to a single-linked list of scanner structs */ static const SANE_Device **sane_devArray = NULL; static struct scanner *scanner_devList = NULL; /* * @@ Section 2 - SANE & scanner init code */ /* * Called by SANE initially. * * From the SANE spec: * This function must be called before any other SANE function can be * called. The behavior of a SANE backend is undefined if this * function is not called first. The version code of the backend is * returned in the value pointed to by version_code. If that pointer * is NULL, no version code is returned. Argument authorize is either * a pointer to a function that is invoked when the backend requires * authentication for a specific resource or NULL if the frontend does * not support authentication. */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { authorize = authorize; /* get rid of compiler warning */ DBG_INIT (); DBG (10, "sane_init: start\n"); sanei_usb_init(); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (5, "sane_init: cardscan backend %d.%d.%d, from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); DBG (10, "sane_init: finish\n"); return SANE_STATUS_GOOD; } /* * Called by SANE to find out about supported devices. * * From the SANE spec: * This function can be used to query the list of devices that are * available. If the function executes successfully, it stores a * pointer to a NULL terminated array of pointers to SANE_Device * structures in *device_list. The returned list is guaranteed to * remain unchanged and valid until (a) another call to this function * is performed or (b) a call to sane_exit() is performed. This * function can be called repeatedly to detect when new devices become * available. If argument local_only is true, only local devices are * returned (devices directly attached to the machine that SANE is * running on). If it is false, the device list includes all remote * devices that are accessible to the SANE library. * * SANE does not require that this function is called before a * sane_open() call is performed. A device name may be specified * explicitly by a user which would make it unnecessary and * undesirable to call this function first. * * Read the config file, find scanners with help from sanei_* * store in global device structs */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { struct scanner *dev; char line[PATH_MAX]; const char *lp; FILE *fp; int num_devices=0; int i=0; local_only = local_only; /* get rid of compiler warning */ DBG (10, "sane_get_devices: start\n"); global_has_cal_buffer = 1; global_lines_per_block = 16; fp = sanei_config_open (CONFIG_FILE); if (fp) { DBG (15, "sane_get_devices: reading config file %s\n", CONFIG_FILE); while (sanei_config_read (line, PATH_MAX, fp)) { lp = line; /* ignore comments */ if (*lp == '#') continue; /* skip empty lines */ if (*lp == 0) continue; if ((strncmp ("usb", lp, 3) == 0) && isspace (lp[3])) { DBG (15, "sane_get_devices: looking for '%s'\n", lp); sanei_usb_attach_matching_devices(lp, attach_one); } else if (!strncmp(lp, "has_cal_buffer", 14) && isspace (lp[14])) { int buf; lp += 14; lp = sanei_config_skip_whitespace (lp); buf = atoi (lp); if(buf){ global_has_cal_buffer = 1; } else{ global_has_cal_buffer = 0; } DBG (15, "sane_get_devices: setting \"has_cal_buffer\" to %d\n", global_has_cal_buffer); } else if (!strncmp(lp, "lines_per_block", 15) && isspace (lp[15])) { int buf; lp += 15; lp = sanei_config_skip_whitespace (lp); buf = atoi (lp); if(buf < 1 || buf > 32){ DBG (15, "sane_get_devices: \"lines_per_block\"=%d\n out of range", buf ); continue; } DBG (15, "sane_get_devices: \"lines_per_block\" is %d\n", buf); global_lines_per_block = buf; } else{ DBG (5, "sane_get_devices: config line \"%s\" ignored.\n", lp); } } fclose (fp); } else { DBG (5, "sane_get_devices: no config file '%s', using defaults\n", CONFIG_FILE); DBG (15, "sane_get_devices: looking for 'usb 0x08F0 0x0005'\n"); sanei_usb_attach_matching_devices("usb 0x08F0 0x0005", attach_one); } for (dev = scanner_devList; dev; dev=dev->next) { DBG (15, "sane_get_devices: found scanner %s\n",dev->device_name); num_devices++; } DBG (15, "sane_get_devices: found %d scanner(s)\n",num_devices); sane_devArray = calloc (num_devices + 1, sizeof (SANE_Device*)); if (!sane_devArray) return SANE_STATUS_NO_MEM; for (dev = scanner_devList; dev; dev=dev->next) { sane_devArray[i++] = (SANE_Device *)&dev->sane; } sane_devArray[i] = 0; *device_list = sane_devArray; DBG (10, "sane_get_devices: finish\n"); return SANE_STATUS_GOOD; } /* callback used by sane_get_devices * build the scanner struct and link to global list * unless struct is already loaded, then pretend */ static SANE_Status attach_one (const char *device_name) { struct scanner *s; int ret, i; SANE_Word vid, pid; DBG (10, "attach_one: start '%s'\n", device_name); for (s = scanner_devList; s; s = s->next) { if (strcmp (s->sane.name, device_name) == 0) { DBG (10, "attach_one: already attached!\n"); return SANE_STATUS_GOOD; } } /* build a scanner struct to hold it */ DBG (15, "attach_one: init struct\n"); if ((s = calloc (sizeof (*s), 1)) == NULL) return SANE_STATUS_NO_MEM; /* copy the device name */ s->device_name = strdup (device_name); if (!s->device_name){ free (s); return SANE_STATUS_NO_MEM; } /* connect the fd */ DBG (15, "attach_one: connect fd\n"); s->fd = -1; ret = connect_fd(s); if(ret != SANE_STATUS_GOOD){ free (s->device_name); free (s); return ret; } /* clean up the scanner struct based on model */ /* this is the only piece of model specific code */ sanei_usb_get_vendor_product(s->fd,&vid,&pid); if(vid == 0x08f0){ s->vendor_name = "CardScan"; if(pid == 0x0005){ s->product_name = "800c"; } else if(pid == 0x0002){ s->product_name = "600c"; } else{ DBG (5, "Unknown product, using default settings\n"); 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"; s->product_name = "Unknown"; } DBG (15, "attach_one: Found %s scanner %s at %s\n", s->vendor_name, s->product_name, s->device_name); /*copy config file settings*/ s->has_cal_buffer = global_has_cal_buffer; s->lines_per_block = global_lines_per_block; s->color_block_size = s->lines_per_block * PIXELS_PER_LINE * 3; s->gray_block_size = s->lines_per_block * PIXELS_PER_LINE; /* try to get calibration */ if(s->has_cal_buffer){ DBG (15, "attach_one: scanner calibration\n"); ret = load_calibration(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot calibrate, incompatible?\n"); free (s->device_name); free (s); return ret; } } else{ DBG (15, "attach_one: skipping calibration\n"); } /* set SANE option 'values' to good defaults */ DBG (15, "attach_one: init options\n"); /* go ahead and setup the first opt, because * frontend may call control_option on it * before calling get_option_descriptor */ memset (s->opt, 0, sizeof (s->opt)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].name = "filler"; s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_INACTIVE; } s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; DBG (15, "attach_one: init settings\n"); /* we close the connection, so that another backend can talk to scanner */ disconnect_fd(s); /* load info into sane_device struct */ s->sane.name = s->device_name; s->sane.vendor = s->vendor_name; s->sane.model = s->product_name; s->sane.type = "scanner"; s->next = scanner_devList; scanner_devList = s; DBG (10, "attach_one: finish\n"); return SANE_STATUS_GOOD; } /* * connect the fd in the scanner struct */ static SANE_Status connect_fd (struct scanner *s) { SANE_Status ret; DBG (10, "connect_fd: start\n"); if(s->fd > -1){ DBG (5, "connect_fd: already open\n"); ret = SANE_STATUS_GOOD; } else { DBG (15, "connect_fd: opening USB device\n"); ret = sanei_usb_open (s->device_name, &(s->fd)); } if(ret != SANE_STATUS_GOOD){ DBG (5, "connect_fd: could not open device: %d\n", ret); } DBG (10, "connect_fd: finish\n"); return ret; } static SANE_Status load_calibration(struct scanner *s) { SANE_Status ret=SANE_STATUS_GOOD; unsigned char cmd[] = {0x45, 0x00, 0x00}; unsigned char * buf; size_t bytes = HEADER_SIZE + CAL_COLOR_SIZE*2 + CAL_GRAY_SIZE*2; int j; DBG (10, "load_calibration: start\n"); buf = malloc(bytes); if(!buf){ DBG(5, "load_calibration: not enough mem for buffer: %ld\n",(long)bytes); return SANE_STATUS_NO_MEM; } ret = do_cmd( s, 0, cmd, sizeof(cmd), NULL, 0, buf, &bytes ); if (ret == SANE_STATUS_GOOD) { DBG(15, "load_calibration: got GOOD\n"); /* * color cal data comes from scaner like: * bbbbbbbBBBBBBBgggggggGGGGGGGrrrrrrrRRRRRRR * where b=darkblue, B=lightblue, etc * reorder the data into two buffers * bbbbbbbgggggggrrrrrrr and BBBBBBBGGGGGGGRRRRRRR */ /*dark/light blue*/ memcpy(s->cal_color_b, buf+HEADER_SIZE, PIXELS_PER_LINE); memcpy(s->cal_color_w, buf+HEADER_SIZE+PIXELS_PER_LINE, PIXELS_PER_LINE); /*dark/light green*/ memcpy(s->cal_color_b+PIXELS_PER_LINE, buf+HEADER_SIZE+(PIXELS_PER_LINE*2), PIXELS_PER_LINE); memcpy(s->cal_color_w+PIXELS_PER_LINE, buf+HEADER_SIZE+(PIXELS_PER_LINE*3), PIXELS_PER_LINE); /*dark/light red*/ memcpy(s->cal_color_b+(PIXELS_PER_LINE*2), buf+HEADER_SIZE+(PIXELS_PER_LINE*4), PIXELS_PER_LINE); memcpy(s->cal_color_w+(PIXELS_PER_LINE*2), buf+HEADER_SIZE+(PIXELS_PER_LINE*5), PIXELS_PER_LINE); /* then slide the light data down using the dark offset */ for(j=0;jcal_color_w[j] -= s->cal_color_b[j]; } /*dark/light gray*/ memcpy(s->cal_gray_b, buf+HEADER_SIZE+(CAL_COLOR_SIZE*2), PIXELS_PER_LINE); memcpy(s->cal_gray_w, buf+HEADER_SIZE+(CAL_COLOR_SIZE*2)+PIXELS_PER_LINE, PIXELS_PER_LINE); /* then slide the light data down using the dark offset */ for(j=0;jcal_gray_w[j] -= s->cal_gray_b[j]; } hexdump(35, "cal_color_b:", s->cal_color_b, CAL_COLOR_SIZE); hexdump(35, "cal_color_w:", s->cal_color_w, CAL_COLOR_SIZE); hexdump(35, "cal_gray_b:", s->cal_gray_b, CAL_GRAY_SIZE); hexdump(35, "cal_gray_w:", s->cal_gray_w, CAL_GRAY_SIZE); } else { DBG(5, "load_calibration: error reading data block status = %d\n", ret); } DBG (10, "load_calibration: finish\n"); return ret; } /* * From the SANE spec: * This function is used to establish a connection to a particular * device. The name of the device to be opened is passed in argument * name. If the call completes successfully, a handle for the device * is returned in *h. As a special case, specifying a zero-length * string as the device requests opening the first available device * (if there is such a device). */ SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle) { struct scanner *dev = NULL; struct scanner *s = NULL; SANE_Status ret; DBG (10, "sane_open: start\n"); if(name[0] == 0){ if(scanner_devList){ DBG (15, "sane_open: no device requested, using first\n"); s = scanner_devList; } else{ DBG (15, "sane_open: no device requested, none found\n"); } } else{ DBG (15, "sane_open: device %s requested, attaching\n", name); ret = attach_one(name); if(ret){ DBG (5, "sane_open: attach error %d\n",ret); return ret; } for (dev = scanner_devList; dev; dev = dev->next) { if (strcmp (dev->sane.name, name) == 0) { s = dev; break; } } } if (!s) { DBG (5, "sane_open: no device found\n"); return SANE_STATUS_INVAL; } DBG (15, "sane_open: device %s found\n", s->sane.name); *handle = s; /* connect the fd so we can talk to scanner */ ret = connect_fd(s); if(ret != SANE_STATUS_GOOD){ return ret; } DBG (10, "sane_open: finish\n"); return SANE_STATUS_GOOD; } /* * @@ Section 3 - SANE Options functions */ /* * Returns the options we know. * * From the SANE spec: * This function is used to access option descriptors. The function * returns the option descriptor for option number n of the device * represented by handle h. Option number 0 is guaranteed to be a * valid option. Its value is an integer that specifies the number of * options that are available for device handle h (the count includes * option 0). If n is not a valid option index, the function returns * NULL. The returned option descriptor is guaranteed to remain valid * (and at the returned address) until the device is closed. */ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct scanner *s = handle; int i; SANE_Option_Descriptor *opt = &s->opt[option]; DBG (20, "sane_get_option_descriptor: %d\n", option); if ((unsigned) option >= NUM_OPTIONS) return NULL; /* "Mode" group -------------------------------------------------------- */ if(option==OPT_MODE_GROUP){ opt->title = "Scan Mode"; opt->desc = ""; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* scan mode */ else if(option==OPT_MODE){ i=0; s->mode_list[i++]=STRING_GRAYSCALE; s->mode_list[i++]=STRING_COLOR; s->mode_list[i]=NULL; opt->name = SANE_NAME_SCAN_MODE; opt->title = SANE_TITLE_SCAN_MODE; opt->desc = SANE_DESC_SCAN_MODE; opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->mode_list; opt->size = maxStringSize (opt->constraint.string_list); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } return opt; } /** * Gets or sets an option value. * * From the SANE spec: * This function is used to set or inquire the current value of option * number n of the device represented by handle h. The manner in which * the option is controlled is specified by parameter action. The * possible values of this parameter are described in more detail * below. The value of the option is passed through argument val. It * is a pointer to the memory that holds the option value. The memory * area pointed to by v must be big enough to hold the entire option * value (determined by member size in the corresponding option * descriptor). * * The only exception to this rule is that when setting the value of a * string option, the string pointed to by argument v may be shorter * since the backend will stop reading the option value upon * encountering the first NUL terminator in the string. If argument i * is not NULL, the value of *i will be set to provide details on how * well the request has been met. */ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { struct scanner *s = (struct scanner *) handle; SANE_Int dummy = 0; /* Make sure that all those statements involving *info cannot break (better * than having to do "if (info) ..." everywhere!) */ if (info == 0) info = &dummy; if (option >= NUM_OPTIONS) { DBG (5, "sane_control_option: %d too big\n", option); return SANE_STATUS_INVAL; } if (!SANE_OPTION_IS_ACTIVE (s->opt[option].cap)) { DBG (5, "sane_control_option: %d inactive\n", option); return SANE_STATUS_INVAL; } /* * SANE_ACTION_GET_VALUE: We have to find out the current setting and * return it in a human-readable form (often, text). */ if (action == SANE_ACTION_GET_VALUE) { SANE_Word * val_p = (SANE_Word *) val; DBG (20, "sane_control_option: get value for '%s' (%d)\n", s->opt[option].name,option); switch (option) { case OPT_NUM_OPTS: *val_p = NUM_OPTIONS; return SANE_STATUS_GOOD; case OPT_MODE: if(s->mode == MODE_GRAYSCALE){ strcpy (val, STRING_GRAYSCALE); } else if(s->mode == MODE_COLOR){ strcpy (val, STRING_COLOR); } return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { int tmp; SANE_Status status; DBG (20, "sane_control_option: set value for '%s' (%d)\n", s->opt[option].name,option); if ( s->started ) { DBG (5, "sane_control_option: cant set, device busy\n"); return SANE_STATUS_DEVICE_BUSY; } if (!SANE_OPTION_IS_SETTABLE (s->opt[option].cap)) { DBG (5, "sane_control_option: not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (5, "sane_control_option: bad value\n"); return status; } /* * Note - for those options which can assume one of a list of * valid values, we can safely assume that they will have * exactly one of those values because that's what * sanei_constrain_value does. Hence no "else: invalid" branches * below. */ switch (option) { /* Mode Group */ case OPT_MODE: if (!strcmp (val, STRING_GRAYSCALE)) { tmp = MODE_GRAYSCALE; } else{ tmp = MODE_COLOR; } if (tmp == s->mode) return SANE_STATUS_GOOD; s->mode = tmp; *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; } /* switch */ } /* else */ return SANE_STATUS_INVAL; } /* * @@ Section 4 - SANE scanning functions */ /* * Called by SANE to retrieve information about the type of data * that the current scan will return. * * From the SANE spec: * This function is used to obtain the current scan parameters. The * returned parameters are guaranteed to be accurate between the time * a scan has been started (sane_start() has been called) and the * completion of that request. Outside of that window, the returned * values are best-effort estimates of what the parameters will be * when sane_start() gets invoked. * * Calling this function before a scan has actually started allows, * for example, to get an estimate of how big the scanned image will * be. The parameters passed to this function are the handle h of the * device for which the parameters should be obtained and a pointer p * to a parameter structure. */ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { struct scanner *s = (struct scanner *) handle; DBG (10, "sane_get_parameters: start\n"); params->pixels_per_line = PIXELS_PER_LINE; params->lines = -1; params->last_frame = 1; if (s->mode == MODE_COLOR) { params->format = SANE_FRAME_RGB; params->depth = 8; params->bytes_per_line = params->pixels_per_line * 3; } else if (s->mode == MODE_GRAYSCALE) { params->format = SANE_FRAME_GRAY; params->depth = 8; params->bytes_per_line = params->pixels_per_line; } DBG (15, "\tdepth %d\n", params->depth); DBG (15, "\tlines %d\n", params->lines); DBG (15, "\tpixels_per_line %d\n", params->pixels_per_line); DBG (15, "\tbytes_per_line %d\n", params->bytes_per_line); DBG (10, "sane_get_parameters: finish\n"); return SANE_STATUS_GOOD; } /* * Called by SANE when a page acquisition operation is to be started. */ SANE_Status sane_start (SANE_Handle handle) { struct scanner *s = handle; SANE_Status ret; DBG (10, "sane_start: start\n"); /* first page of batch */ if(s->started){ DBG(5,"sane_start: previous transfer not finished?"); sane_cancel((SANE_Handle)s); return SANE_STATUS_CANCELLED; } /* set clean defaults */ s->started=1; s->bytes_rx=0; s->bytes_tx=0; s->paperless_lines=0; /* heat up the lamp */ if(s->mode == MODE_COLOR){ ret = heat_lamp_color(s); } else{ ret = heat_lamp_gray(s); } if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to heat lamp\n"); sane_cancel((SANE_Handle)s); return ret; } DBG (10, "sane_start: finish\n"); return SANE_STATUS_GOOD; } static SANE_Status heat_lamp_gray(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; SANE_Status ret2 = SANE_STATUS_GOOD; unsigned char cmd[] = {0x12, 0x06, 0x00, 0x00, 0x01, 0x60, 0x00, 0x61, 0x00}; size_t bytes = HEADER_SIZE + 1; unsigned char * buf; int i; DBG (10, "heat_lamp_gray: start\n"); buf = malloc(bytes); if(!buf){ DBG(5, "heat_lamp_gray: not enough mem for buffer: %lu\n", (long unsigned)bytes); return SANE_STATUS_NO_MEM; } for(i=0;i<10;i++){ ret2 = do_cmd( s, 0, cmd, sizeof(cmd), NULL, 0, buf, &bytes ); if (ret2 != SANE_STATUS_GOOD) { DBG(5, "heat_lamp_gray: %d error\n",i); ret = ret2; break; } if(!buf[1]){ DBG(5, "heat_lamp_gray: %d got no docs\n",i); ret = SANE_STATUS_NO_DOCS; break; } DBG(15, "heat_lamp_gray: %d got: %d %d\n",i, buf[HEADER_SIZE],s->cal_gray_b[0]); if(buf[HEADER_SIZE] < 0x20){ DBG(15, "heat_lamp_gray: hot\n"); ret = SANE_STATUS_GOOD; break; } else{ DBG(15, "heat_lamp_gray: cold\n"); ret = SANE_STATUS_DEVICE_BUSY; } } free(buf); DBG (10, "heat_lamp_gray: finish %d\n",ret); return ret; } static SANE_Status heat_lamp_color(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; SANE_Status ret2 = SANE_STATUS_GOOD; unsigned char cmd[] = {0x18, 0x07, 0x00, 0x00, 0x01, 0x60, 0x00, 0x61, 0x00, 0x07}; size_t bytes = HEADER_SIZE + 3; unsigned char * buf; int i; DBG (10, "heat_lamp_color: start\n"); buf = malloc(bytes); if(!buf){ DBG(5, "heat_lamp_color: not enough mem for buffer: %lu\n", (long unsigned)bytes); return SANE_STATUS_NO_MEM; } for(i=0;i<10;i++){ ret2 = do_cmd( s, 0, cmd, sizeof(cmd), NULL, 0, buf, &bytes ); if (ret2 != SANE_STATUS_GOOD) { DBG(5, "heat_lamp_color: %d error\n",i); ret = ret2; break; } if(!buf[1]){ DBG(5, "heat_lamp_color: %d got no docs\n",i); ret = SANE_STATUS_NO_DOCS; break; } DBG(15, "heat_lamp_color: %d got: %d,%d,%d %d,%d,%d\n",i, buf[HEADER_SIZE],buf[HEADER_SIZE+1],buf[HEADER_SIZE+2], s->cal_color_b[0],s->cal_color_b[1],s->cal_color_b[2]); if(buf[HEADER_SIZE] < 0x20 && buf[HEADER_SIZE+1] < 0x20 && buf[HEADER_SIZE+2] < 0x20){ DBG(15, "heat_lamp_color: hot\n"); ret = SANE_STATUS_GOOD; break; } else{ DBG(15, "heat_lamp_color: cold\n"); ret = SANE_STATUS_DEVICE_BUSY; } } free(buf); DBG (10, "heat_lamp_color: finish %d\n",ret); return ret; } /* * Called by SANE to read data. * * From the SANE spec: * This function is used to read image data from the device * represented by handle h. Argument buf is a pointer to a memory * area that is at least maxlen bytes long. The number of bytes * returned is stored in *len. A backend must set this to zero when * the call fails (i.e., when a status other than SANE_STATUS_GOOD is * returned). * * When the call succeeds, the number of bytes returned can be * anywhere in the range from 0 to maxlen bytes. */ SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { struct scanner *s = (struct scanner *) handle; SANE_Status ret=SANE_STATUS_GOOD; DBG (10, "sane_read: start\n"); *len = 0; /* cancelled? */ if(!s->started){ DBG (5, "sane_read: call sane_start first\n"); return SANE_STATUS_CANCELLED; } /* have sent all of current buffer */ if(s->bytes_tx == s->bytes_rx){ /* at end of data, stop */ if(s->paperless_lines >= MAX_PAPERLESS_LINES){ DBG (15, "sane_read: returning eof\n"); power_down(s); return SANE_STATUS_EOF; } /* more to get, reset and go */ s->bytes_tx = 0; s->bytes_rx = 0; if(s->mode == MODE_COLOR){ ret = read_from_scanner_color(s); } else{ ret = read_from_scanner_gray(s); } if(ret){ DBG(5,"sane_read: returning %d\n",ret); return ret; } } /* data in current buffer, send some of it */ *len = s->bytes_rx - s->bytes_tx; if(*len > max_len){ *len = max_len; } memcpy(buf,s->buffer+s->bytes_tx,*len); s->bytes_tx += *len; DBG (10, "sane_read: %d,%d,%d finish\n", *len,s->bytes_rx,s->bytes_tx); return ret; } static SANE_Status read_from_scanner_gray(struct scanner *s) { SANE_Status ret=SANE_STATUS_GOOD; /*cmd len-le16 move lines ??? ??? ??? ???*/ unsigned char cmd[] = {0x12, 0x06, 0x00, 0x01, 0x01, 0x60, 0x00, 0x18, 0x05}; size_t bytes = HEADER_SIZE + s->gray_block_size; unsigned char * buf; int i,j; DBG (10, "read_from_scanner_gray: start\n"); cmd[4] = s->lines_per_block; buf = malloc(bytes); if(!buf){ DBG(5, "read_from_scanner_gray: not enough mem for buffer: %lu\n", (long unsigned)bytes); return SANE_STATUS_NO_MEM; } ret = do_cmd( s, 0, cmd, sizeof(cmd), NULL, 0, buf, &bytes ); if (ret == SANE_STATUS_GOOD) { DBG(15, "read_from_scanner_gray: got GOOD\n"); if(!buf[1]){ s->paperless_lines += s->lines_per_block; } s->bytes_rx = s->gray_block_size; /*memcpy(s->buffer,buf+HEADER_SIZE,s->gray_block_size);*/ /* reorder the gray data into the struct's buffer */ for(i=0;igray_block_size;i+=PIXELS_PER_LINE){ for(j=0;jcal_gray_b[j]; unsigned char wcal = s->cal_gray_w[j]; byte = (byte <= bcal)?0:(byte-bcal); byte = (byte >= wcal)?255:(byte*255/wcal); s->buffer[i+j] = byte; } } } else { DBG(5, "read_from_scanner_gray: error reading status = %d\n", ret); } free(buf); DBG (10, "read_from_scanner_gray: finish\n"); return ret; } static SANE_Status read_from_scanner_color(struct scanner *s) { SANE_Status ret=SANE_STATUS_GOOD; unsigned char cmd[] = {0x18, 0x07, 0x00, 0x01, 0x01, 0x60, 0x00, 0x18, 0x05, 0x07}; size_t bytes = HEADER_SIZE + s->color_block_size; unsigned char * buf; int i,j,k; DBG (10, "read_from_scanner_color: start\n"); cmd[4] = s->lines_per_block; buf = malloc(bytes); if(!buf){ DBG(5, "read_from_scanner_color: not enough mem for buffer: %lu\n", (long unsigned)bytes); return SANE_STATUS_NO_MEM; } ret = do_cmd( s, 0, cmd, sizeof(cmd), NULL, 0, buf, &bytes ); if (ret == SANE_STATUS_GOOD) { DBG(15, "read_from_scanner_color: got GOOD\n"); if(!buf[1]){ s->paperless_lines += s->lines_per_block; } s->bytes_rx = s->color_block_size; /*memcpy(s->buffer,buf+HEADER_SIZE,s->color_block_size);*/ /* reorder the color data into the struct's buffer */ for(i=0;icolor_block_size;i+=PIXELS_PER_LINE*3){ for(j=0;jcal_color_b[offset]; unsigned char wcal = s->cal_color_w[offset]; byte = (byte <= bcal)?0:(byte-bcal); byte = (byte >= wcal)?255:(byte*255/wcal); s->buffer[i+j*3+k] = byte; } } } } else { DBG(5, "read_from_scanner_color: error reading status = %d\n", ret); } free(buf); DBG (10, "read_from_scanner_color: finish\n"); return ret; } /* * @@ Section 4 - SANE cleanup functions */ /* * Cancels a scan. * * From the SANE spec: * This function is used to immediately or as quickly as possible * cancel the currently pending operation of the device represented by * handle h. This function can be called at any time (as long as * handle h is a valid handle) but usually affects long-running * operations only (such as image is acquisition). It is safe to call * this function asynchronously (e.g., from within a signal handler). * It is important to note that completion of this operaton does not * imply that the currently pending operation has been cancelled. It * only guarantees that cancellation has been initiated. Cancellation * completes only when the cancelled call returns (typically with a * status value of SANE_STATUS_CANCELLED). Since the SANE API does * not require any other operations to be re-entrant, this implies * that a frontend must not call any other operation until the * cancelled operation has returned. */ void sane_cancel (SANE_Handle handle) { struct scanner * s = (struct scanner *) handle; DBG (10, "sane_cancel: start\n"); s->started = 0; DBG (10, "sane_cancel: finish\n"); } static SANE_Status power_down(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[] = {0x21, 0x02, 0x00, 0x0a, 0x00}; unsigned char buf[6]; size_t bytes = sizeof(buf); int i; DBG (10, "power_down: start\n"); for(i=0;i<5;i++){ ret = do_cmd( s, 0, cmd, sizeof(cmd), NULL, 0, buf, &bytes ); if(ret != SANE_STATUS_GOOD){ break; } } #if 0 unsigned char cmd[] = {0x35, 0x01, 0x00, 0xff}; unsigned char buf[5]; size_t bytes = sizeof(buf); DBG (10, "power_down: start\n"); ret = do_cmd( s, 0, cmd, sizeof(cmd), NULL, 0, buf, &bytes ); #endif DBG (10, "power_down: finish %d\n",ret); return ret; } /* * Ends use of the scanner. * * From the SANE spec: * This function terminates the association between the device handle * passed in argument h and the device it represents. If the device is * presently active, a call to sane_cancel() is performed first. After * this function returns, handle h must not be used anymore. */ void sane_close (SANE_Handle handle) { DBG (10, "sane_close: start\n"); sane_cancel(handle); disconnect_fd((struct scanner *) handle); DBG (10, "sane_close: finish\n"); } static SANE_Status disconnect_fd (struct scanner *s) { DBG (10, "disconnect_fd: start\n"); if(s->fd > -1){ DBG (15, "disconnecting usb device\n"); sanei_usb_close (s->fd); s->fd = -1; } DBG (10, "disconnect_fd: finish\n"); return SANE_STATUS_GOOD; } /* * Terminates the backend. * * From the SANE spec: * This function must be called to terminate use of a backend. The * function will first close all device handles that still might be * open (it is recommended to close device handles explicitly through * a call to sane_close(), but backends are required to release all * resources upon a call to this function). After this function * returns, no function other than sane_init() may be called * (regardless of the status value returned by sane_exit(). Neglecting * to call this function may result in some resources not being * released properly. */ void sane_exit (void) { struct scanner *dev, *next; DBG (10, "sane_exit: start\n"); for (dev = scanner_devList; dev; dev = next) { disconnect_fd(dev); next = dev->next; free (dev->device_name); free (dev); } if (sane_devArray) free (sane_devArray); scanner_devList = NULL; sane_devArray = NULL; DBG (10, "sane_exit: finish\n"); } /* * @@ Section 5 - misc helper functions */ /* * take a bunch of pointers, send commands to scanner */ static SANE_Status do_cmd(struct scanner *s, int shortTime, unsigned char * cmdBuff, size_t cmdLen, unsigned char * outBuff, size_t outLen, unsigned char * inBuff, size_t * inLen ) { /* sanei_usb overwrites the transfer size, so make some local copies */ size_t loc_cmdLen = cmdLen; size_t loc_outLen = outLen; size_t loc_inLen = *inLen; int cmdTime = USB_COMMAND_TIME; int outTime = USB_DATA_TIME; int inTime = USB_DATA_TIME; int ret = 0; DBG (10, "do_cmd: start\n"); if(shortTime){ cmdTime /= 20; outTime /= 20; inTime /= 20; } /* change timeout */ sanei_usb_set_timeout(cmdTime); /* write the command out */ DBG(25, "cmd: writing %ld bytes, timeout %d\n", (long)cmdLen, cmdTime); hexdump(30, "cmd: >>", cmdBuff, cmdLen); ret = sanei_usb_write_bulk(s->fd, cmdBuff, &cmdLen); DBG(25, "cmd: wrote %ld bytes, retVal %d\n", (long)cmdLen, ret); if(ret == SANE_STATUS_EOF){ DBG(5,"cmd: got EOF, returning IO_ERROR\n"); return SANE_STATUS_IO_ERROR; } if(ret != SANE_STATUS_GOOD){ DBG(5,"cmd: return error '%s'\n",sane_strstatus(ret)); return ret; } if(loc_cmdLen != cmdLen){ DBG(5,"cmd: wrong size %ld/%ld\n", (long)loc_cmdLen, (long)cmdLen); return SANE_STATUS_IO_ERROR; } /* this command has a write component, and a place to get it */ if(outBuff && outLen && outTime){ /* change timeout */ sanei_usb_set_timeout(outTime); DBG(25, "out: writing %ld bytes, timeout %d\n", (long)outLen, outTime); hexdump(30, "out: >>", outBuff, outLen); ret = sanei_usb_write_bulk(s->fd, outBuff, &outLen); DBG(25, "out: wrote %ld bytes, retVal %d\n", (long)outLen, ret); if(ret == SANE_STATUS_EOF){ DBG(5,"out: got EOF, returning IO_ERROR\n"); return SANE_STATUS_IO_ERROR; } if(ret != SANE_STATUS_GOOD){ DBG(5,"out: return error '%s'\n",sane_strstatus(ret)); return ret; } if(loc_outLen != outLen){ DBG(5,"out: wrong size %ld/%ld\n", (long)loc_outLen, (long)outLen); return SANE_STATUS_IO_ERROR; } } /* this command has a read component, and a place to put it */ if(inBuff && inLen && inTime){ memset(inBuff,0,*inLen); /* change timeout */ sanei_usb_set_timeout(inTime); DBG(25, "in: reading %ld bytes, timeout %d\n", (long)*inLen, inTime); ret = sanei_usb_read_bulk(s->fd, inBuff, inLen); DBG(25, "in: retVal %d\n", ret); if(ret == SANE_STATUS_EOF){ DBG(5,"in: got EOF, continuing\n"); } else if(ret != SANE_STATUS_GOOD){ DBG(5,"in: return error '%s'\n",sane_strstatus(ret)); return ret; } DBG(25, "in: read %ld bytes\n", (long)*inLen); if(*inLen){ hexdump(30, "in: <<", inBuff, *inLen); } if(loc_inLen != *inLen){ ret = SANE_STATUS_EOF; DBG(5,"in: short read %ld/%ld\n", (long)loc_inLen, (long)*inLen); } } DBG (10, "do_cmd: finish\n"); return ret; } /** * Convenience method to determine longest string size in a list. */ static size_t maxStringSize (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } /** * Prints a hex dump of the given buffer onto the debug output stream. */ static void hexdump (int level, char *comment, unsigned char *p, int l) { int i; char line[128]; char *ptr; if(DBG_LEVEL < level) return; DBG (level, "%s\n", comment); ptr = line; for (i = 0; i < l; i++, p++) { if ((i % 16) == 0) { if (ptr != line) { *ptr = '\0'; DBG (level, "%s\n", line); ptr = line; } sprintf (ptr, "%3.3x:", i); ptr += 4; } sprintf (ptr, " %2.2x", *p); ptr += 3; } *ptr = '\0'; DBG (level, "%s\n", line); } /** * An advanced method we don't support but have to define. */ SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking) { DBG (10, "sane_set_io_mode\n"); DBG (15, "%d %p\n", non_blocking, h); return SANE_STATUS_UNSUPPORTED; } /** * An advanced method we don't support but have to define. */ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int *fdp) { DBG (10, "sane_get_select_fd\n"); DBG (15, "%p %d\n", h, *fdp); return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/sp15c-scsi.h0000666000000000000000000004752513615534521014650 00000000000000#ifndef SP15C_SCSI_H #define SP15C_SCSI_H /* sane - Scanner Access Now Easy. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Fujitsu ScanParner 15c flatbed/ADF scanners. It was derived from the COOLSCAN driver. Written by Randolph Bentson */ /* ------------------------------------------------------------------------- */ /* * $Log$ * Revision 1.6 2005/09/19 19:57:48 fzago-guest * Replaced __unused__ with __sane_unused__ to avoid a namespace conflict. * * Revision 1.5 2004/11/13 19:53:04 fzago-guest * Fixes some warnings. * * Revision 1.4 2003/12/27 17:48:38 hmg-guest * Silenced some compilation warnings. * * Revision 1.3 2000/08/12 15:09:37 pere * Merge devel (v1.0.3) into head branch. * * Revision 1.1.2.4 2000/03/14 17:47:12 abel * new version of the Sharp backend added. * * Revision 1.1.2.3 2000/02/14 14:20:19 pere * Make lint_catcher static to avoid link problems with duplicate symbols. * * Revision 1.1.2.2 2000/01/26 03:51:48 pere * Updated backends sp15c (v1.12) and m3096g (v1.11). * * Revision 1.7 2000/01/05 05:27:34 bentson * indent to barfin' GNU style * * Revision 1.6 1999/12/03 20:56:44 bentson * add MEDIA CHECK command * * Revision 1.5 1999/11/24 15:57:50 bentson * add license * * Revision 1.4 1999/11/23 19:04:08 bentson * clean up and enhance inquiry command * * Revision 1.3 1999/11/23 06:42:19 bentson * add 4-bit grayscale support; fix color count field placement * * Revision 1.2 1999/11/22 18:15:43 bentson * more work on color support * * Revision 1.1 1999/11/19 15:09:08 bentson * cribbed from m3096g * */ /****************************************************/ static inline void setbitfield (unsigned char *pageaddr, int mask, int shift, int val) \ { *pageaddr = (*pageaddr & ~(mask << shift)) | ((val & mask) << shift); } /* ------------------------------------------------------------------------- */ static inline void resetbitfield (unsigned char *pageaddr, int mask, int shift, int val) \ { *pageaddr = (*pageaddr & ~(mask << shift)) | (((!val) & mask) << shift); } /* ------------------------------------------------------------------------- */ static inline int getbitfield (unsigned char *pageaddr, int mask, int shift) \ { return ((*pageaddr >> shift) & mask); } /* ------------------------------------------------------------------------- */ static inline int getnbyte (unsigned char *pnt, int nbytes) \ { unsigned int result = 0; int i; #ifdef DEBUG assert (nbytes < 5); #endif for (i = 0; i < nbytes; i++) result = (result << 8) | (pnt[i] & 0xff); return result; } /* ------------------------------------------------------------------------- */ static inline void putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) \ { int i; #ifdef DEBUG assert (nbytes < 5); #endif for (i = nbytes - 1; i >= 0; i--) \ { pnt[i] = value & 0xff; value = value >> 8; } } /* ==================================================================== */ /* SCSI commands */ typedef struct { unsigned char *cmd; unsigned int size; } scsiblk; /* ==================================================================== */ #define RESERVE_UNIT 0x16 #define RELEASE_UNIT 0x17 #define INQUIRY 0x12 #define REQUEST_SENSE 0x03 #define SEND_DIAGNOSTIC 0x1d #define TEST_UNIT_READY 0x00 #define SET_WINDOW 0x24 #define SET_SUBWINDOW 0xc0 #define OBJECT_POSITION 0x31 #define MEDIA_CHECK 0x08 #define SEND 0x2a #define READ 0x28 #define MODE_SELECT 0x15 #define MODE_SENSE 0x1a #define SCAN 0x1b /* ==================================================================== */ static unsigned char reserve_unitC[] = {RESERVE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00}; static scsiblk reserve_unitB = {reserve_unitC, sizeof (reserve_unitC)}; /* ==================================================================== */ static unsigned char release_unitC[] = {RELEASE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00}; static scsiblk release_unitB = {release_unitC, sizeof (release_unitC)}; /* ==================================================================== */ static unsigned char inquiryC[] = {INQUIRY, 0x00, 0x00, 0x00, 0x1f, 0x00}; static scsiblk inquiryB = {inquiryC, sizeof (inquiryC)}; #define set_IN_return_size(icb,val) icb[0x04]=val #define set_IN_length(out,n) out[0x04]=n-5 #define get_IN_periph_qual(in) getbitfield(in, 0x07, 5) #define IN_periph_qual_lun 0x00 #define IN_periph_qual_nolun 0x03 #define get_IN_periph_devtype(in) getbitfield(in, 0x1f, 0) #define IN_periph_devtype_scanner 0x06 #define IN_periph_devtype_unknown 0x1f #define get_IN_response_format(in) getbitfield(in + 0x03, 0x0f, 0) #define IN_recognized 0x02 #define get_IN_additional_length(in) in[0x04] #define get_IN_vendor(in, buf) strncpy(buf, in + 0x08, 0x08) #define get_IN_product(in, buf) strncpy(buf, in + 0x10, 0x010) #define get_IN_version(in, buf) strncpy(buf, in + 0x20, 0x04) #define get_IN_color_mode(in) getbitfield(in + 0x24, 0xf, 0) #define get_IN_color_seq(in) getbitfield(in + 0x24, 0x7, 4) #define get_IN_adf(in) getbitfield(in + 0x24, 0x1, 7) /* ==================================================================== */ static unsigned char request_senseC[] = {REQUEST_SENSE, 0x00, 0x00, 0x00, 0x00, 0x00}; static scsiblk request_senseB = {request_senseC, sizeof (request_senseC)}; #define set_RS_allocation_length(sb,val) sb[0x04] = (unsigned char)val /* defines for request sense return block */ #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7) #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0) #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7) #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6) #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5) #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0) #define get_RS_information(b) getnbyte(b+0x03, 4) /* normally 0 */ #define get_RS_additional_length(b) b[0x07] /* always 10 */ #define get_RS_ASC(b) b[0x0c] #define get_RS_ASCQ(b) b[0x0d] #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /* valid, always 0 */ #define rs_return_block_size 18 /* Says Nikon */ /* ==================================================================== */ static unsigned char send_diagnosticC[] = {SEND_DIAGNOSTIC, 0x04, 0x00, 0x00, 0x00, 0x00}; static scsiblk send_diagnosticB = {send_diagnosticC, sizeof (send_diagnosticC)}; /* ==================================================================== */ static unsigned char test_unit_readyC[] = {TEST_UNIT_READY, 0x00, 0x00, 0x00, 0x00, 0x00}; static scsiblk test_unit_readyB = {test_unit_readyC, sizeof (test_unit_readyC)}; /* ==================================================================== */ static unsigned char set_windowC[] = {SET_WINDOW, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}; /* opcode, lun, _____4 X reserved____, _transfer length, ctl */ static scsiblk set_windowB = {set_windowC, sizeof (set_windowC)}; #define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) #define get_SW_xferlen(sb) getnbyte(sb + 0x06, 3) /* ==================================================================== */ static unsigned char set_subwindowC[] = {SET_SUBWINDOW}; static scsiblk set_subwindowB = {set_subwindowC, sizeof (set_subwindowC)}; /* ==================================================================== */ static unsigned char object_positionC[] = {OBJECT_POSITION, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* ADF, _____Count_____, ________Reserved______, Ctl */ static scsiblk object_positionB = {object_positionC, sizeof (object_positionC)}; #define set_OP_autofeed(b,val) setbitfield(b+0x01, 0x07, 0, val) #define OP_Discharge 0x00 #define OP_Feed 0x01 /* ==================================================================== */ static unsigned char media_checkC[] = {MEDIA_CHECK, 0x00, 0x00, 0x00, 0x00, 0x00}; /* ADF, _Reserved_, Len, Ctl */ static scsiblk media_checkB = {media_checkC, sizeof (media_checkC)}; #define set_MC_return_size(sb,val) sb[0x04]=val #define get_MC_adf_status(sb) sb[0x00] #define MC_ADF_OK 0x01 /* ==================================================================== */ static unsigned char media_parameter_data_blockC[] = { 0x00 }; static scsiblk media_parameter_data_blockB = {media_parameter_data_blockC, sizeof (media_parameter_data_blockC)}; /* ==================================================================== */ static unsigned char sendC[] = {SEND, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static scsiblk sendB = {sendC, sizeof (sendC)}; #define set_S_datatype_code(sb, val) sb[0x02] = (unsigned char)val #define S_datatype_imagedatai 0x00 #define S_EX_datatype_LUT 0x01 /* Experiment code */ #define S_EX_datatype_shading_data 0xa0 /* Experiment code */ #define S_user_reg_gamma 0xc0 #define S_device_internal_info 0x03 #define set_S_datatype_qual_upper(sb, val) sb[0x04] = (unsigned char)val #define S_DQ_none 0x00 #define S_DQ_Rcomp 0x06 #define S_DQ_Gcomp 0x07 #define S_DQ_Bcomp 0x08 #define S_DQ_Reg1 0x01 #define S_DQ_Reg2 0x02 #define S_DQ_Reg3 0x03 #define set_S_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3) /* static unsigned char gamma_user_LUT_LS1K[512] = { 0x00 }; static scsiblk gamma_user_LUT_LS1K_LS1K = { gamma_user_LUT_LS1K, sizeof(gamma_user_LUT_LS1K) }; */ /* ==================================================================== */ static unsigned char readC[] = {READ, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* Type, rsvd, type qual, __xfer length__, Ctl */ static scsiblk readB = {readC, sizeof (readC)}; #define set_R_datatype_code(sb, val) sb[0x02] = val #define R_datatype_imagedata 0x00 #define R_pixel_size 0x80 #define set_R_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3) /* ==================================================================== */ static unsigned char mode_selectC[] = {MODE_SELECT, 0x10, 0x00, 0x00, 0x00, 0x00}; static scsiblk mode_selectB = {mode_selectC, sizeof (mode_selectC)}; /* ==================================================================== */ static unsigned char mode_senseC[] = {MODE_SENSE, 0x18, 0x03, 0x00, 0x00, 0x00, /* PF set, page type 03 */ }; static scsiblk mode_senseB = {mode_senseC, sizeof (mode_senseC)}; #define set_MS_DBD(b, val) setbitfield(b, 0x01, 3, (val?1:0)) #define set_MS_len(b, val) putnbyte(b+0x04, val, 1) #define get_MS_MUD(b) getnbyte(b+(0x04+((int)*(b+0x3)))+0x4,2) /* ==================================================================== */ static unsigned char scanC[] = {SCAN, 0x00, 0x00, 0x00, 0x00, 0x00}; static scsiblk scanB = {scanC, sizeof (scanC)}; #define set_SC_xfer_length(sb, val) sb[0x04] = (unsigned char)val /* ==================================================================== */ /* We use the same structure for both SET WINDOW and GET WINDOW. */ static unsigned char window_parameter_data_blockC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* reserved */ 0x00, 0x00, /* Window Descriptor Length */ }; static scsiblk window_parameter_data_blockB = {window_parameter_data_blockC, sizeof (window_parameter_data_blockC)}; #define set_WDPB_wdblen(sb, len) putnbyte(sb + 0x06, len, 2) #define get_WDPB_wdblen(sb) getnbyte(sb + 0x06, 2) #define WDB_size_empty 0x28 /* wdb_len if nothing is set by inquiry */ #define WDB_size_BW 0x40 #define WDB_size_Color 0x33 #define WDB_size_max 0xff /* ==================================================================== */ static unsigned char window_descriptor_blockC[] = { 0x00, /* 0x00 *//* Window Identifier */ #define set_WD_wid(sb, val) sb[0] = val #define WD_wid_all 0x00 /* Only one supported */ 0x00, /* 0x01 *//* reserved, AUTO */ #define set_WD_auto(sb, val) setbitfield(sb + 0x01, 1, 0, val) #define get_WD_auto(sb) getbitfield(sb + 0x01, 1, 0) 0x00, 0x00, /* 0x02 *//* X resolution in dpi, 0 => 400 */ #define set_WD_Xres(sb, val) putnbyte(sb + 0x02, val, 2) #define get_WD_Xres(sb) getnbyte(sb + 0x02, 2) 0x00, 0x00, /* 0x04 *//* Y resolution in dpi, 0 => 400 */ #define set_WD_Yres(sb, val) putnbyte(sb + 0x04, val, 2) #define get_WD_Yres(sb) getnbyte(sb + 0x04, 2) 0x00, 0x00, 0x00, 0x00, /* 0x06 *//* Upper Left X in inch/1200 */ #define set_WD_ULX(sb, val) putnbyte(sb + 0x06, val, 4) #define get_WD_ULX(sb) getnbyte(sb + 0x06, 4) 0x00, 0x00, 0x00, 0x00, /* 0x0a *//* Upper Left Y in inch/1200 */ #define set_WD_ULY(sb, val) putnbyte(sb + 0x0a, val, 4) #define get_WD_ULY(sb) getnbyte(sb + 0x0a, 4) 0x00, 0x00, 0x00, 0x00, /* 0x0e *//* Width */ #define set_WD_width(sb, val) putnbyte(sb + 0x0e, val, 4) #define get_WD_width(sb) getnbyte(sb + 0x0e, 4) #define WD_width 10200 0x00, 0x00, 0x00, 0x00, /* 0x12 *//* Length */ #define set_WD_length(sb, val) putnbyte(sb + 0x12, val, 4) #define get_WD_length(sb) getnbyte(sb + 0x12, 4) #define WD_length 13200 0x00, /* 0x16 *//* Brightness */ #define set_WD_brightness(sb, val) sb[0x16] = val #define get_WD_brightness(sb) sb[0x16] #define WD_brightness 0x80 0x00, /* 0x17 *//* Threshold */ #define set_WD_threshold(sb, val) sb[0x17] = val #define get_WD_threshold(sb) sb[0x17] #define WD_threshold 0x80 0x00, /* 0x18 *//* Contrast */ #define set_WD_contrast(sb, val) sb[0x18] = val #define get_WD_contrast(sb) sb[0x18] 0x05, /* 0x19 *//* Image composition */ #define set_WD_composition(sb, val) sb[0x19] = val #define get_WD_composition(sb) sb[0x19] /* lineart, halftone, greyscale, binary color, dither color, multi-color */ #define WD_comp_LA 0 #define WD_comp_HT 1 #define WD_comp_GS 2 #define WD_comp_BC 3 #define WD_comp_DC 4 #define WD_comp_MC 5 #define WD_comp_G4 10 #define WD_comp_G8 11 0x08, /* 0x1a *//* Bits/Pixel */ #define set_WD_bitsperpixel(sb, val) sb[0x1a] = val #define get_WD_bitsperpixel(sb) sb[0x1a] 0x00, 0x00, /* 0x1b *//* Halftone pattern */ #define set_WD_halftone(sb, val) putnbyte(sb + 0x1b, val, 2) #define get_WD_halftone(sb) getnbyte(sb + 0x1b, 2) 0x00, /* 0x1d *//*************** STUFF ***************/ #define set_WD_rif(sb, val) setbitfield(sb + 0x1d, 1, 7, val) #define get_WD_rif(sb) getbitfield(sb + 0x1d, 1, 7) #define set_WD_pad(sb, val) setbitfield(sb + 0x1d, 7, 0, val) #define get_WD_pad(sb) getbitfield(sb + 0x1d, 7, 0) 0x00, 0x00, /* 0x1e *//* bit ordering */ #define set_WD_bitorder(sb, val) putnbyte(sb + 0x1e, val, 2) #define get_WD_bitorder(sb) getnbyte(sb + 0x1e, 2) 0x00, /* 0x20 *//* compression type */ #define set_WD_compress_type(sb, val) sb[0x20] = val #define get_WD_compress_type(sb) sb[0x20] 0x00, /* 0x21 *//* compression argument */ #define set_WD_compress_arg(sb, val) sb[0x21] = val #define get_WD_compress_arg(sb) sb[0x21] 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x22 *//* reserved */ 0x00, /* 0x28 *//* vendor id code */ #define set_WD_vendor_id_code(sb, val) sb[0x28] = val #define get_WD_vendor_id_code(sb) sb[0x28] #define WD_bw 0x00 #define WD_color 0xFF 0x00, /* 0x29 C *//* parm length */ #define set_WD_parm_length(sb, val) sb[0x29] = val #define get_WD_parm_length(sb) sb[0x29] 0x00, /* 0x2a C *//* ADF, source, Color */ #define set_WD_adf(sb, val) setbitfield(sb + 0x2a, 1, 7, val) #define get_WD_adf(sb) getbitfield(sb + 0x2a, 1, 7) #define set_WD_source(sb, val) setbitfield(sb + 0x2a, 1, 6, val) #define get_WD_source(sb) getbitfield(sb + 0x2a, 1, 6) #define set_WD_color(sb, val) setbitfield(sb + 0x2a, 7, 3, val) #define get_WD_color(sb) getbitfield(sb + 0x2a, 7, 3) #define WD_color_green 0 #define WD_color_red 1 #define WD_color_greenx 2 #define WD_color_blue 3 #define WD_color_rgb 4 0x00, /* 0x2b C *//* highlight color */ #define set_WD_highlight_color(sb, val) sb[0x2b] = val #define get_WD_highlight_color(sb) sb[0x2b] 0x00, /* 0x2c C *//* shadow value */ #define set_WD_shadow_value(sb, val) sb[0x2c] = val #define get_WD_shadow_value(sb) sb[0x2c] 0x00, 0x00, /* 0x2d C *//* line width */ #define set_WD_line_width(sb, val) putnbyte(sb + 0x2d, val, 2) #define get_WD_line_width(sb) getnbyte(sb + 0x2d, 2) 0x00, 0x00, /* 0x2f C *//* line count */ #define set_WD_line_count(sb, val) putnbyte(sb + 0x2f, val, 2) #define get_WD_line_count(sb) getnbyte(sb + 0x2f, 2) 0x00, /* 0x31 *//* reserved */ 0x00, /* 0x32 *//* reserved */ 0x00, /* 0x33 *//* reserved */ 0x00, /* 0x34 *//* reserved */ 0x00, /* 0x35 *//* paper size */ #define set_WD_paper_size(sb, val) sb[0x35] = val #define get_WD_paper_size(sb) sb[0x35] 0x00, 0x00, 0x00, 0x00, /* 0x36 BW *//* paper width X */ #define set_WD_paper_width_X(sb, val) putnbyte(sb + 0x36, val, 4) #define get_WD_paper_width_X(sb) getnbyte(sb + 0x36, 4) 0x00, 0x00, 0x00, 0x00, /* 0x3a BW *//* paper length Y */ #define set_WD_paper_length_Y(sb, val) putnbyte(sb+0x3a, val, 4) #define get_WD_paper_length_Y(sb) getnbyte(sb + 0x3a, 4) 0x00, /* 0x3e *//* reserved */ 0x00, /* 0x3f *//* reserved */ /* 0x40 (last) */ }; static scsiblk window_descriptor_blockB = {window_descriptor_blockC, sizeof (window_descriptor_blockC)}; /* ==================================================================== */ #if 0 #define set_WDB_length(wdb,len) (wdb.size = (len)) #define WDB_OFF(b) (b + set_window.size) #define WDB_OFF(b, n) (b + set_window.size + \ window_parameter_data_block.size + \ ( window_descriptor_block.size * (n - 1) ) ) #define set_WDPB_wdbnum(sb,n) set_WPDB_wdblen(sb,window_descriptor_block.size*n) #endif /* ==================================================================== */ static scsiblk __sane_unused__ *lint_catcher[] = {&reserve_unitB, &release_unitB, &inquiryB, &request_senseB, &send_diagnosticB, &test_unit_readyB, &set_windowB, &set_subwindowB, &object_positionB, &media_checkB, &media_parameter_data_blockB, &sendB, &readB, &mode_selectB, &mode_senseB, &scanB, &window_parameter_data_blockB, &window_descriptor_blockB}; #endif /* SP15C_SCSI_H */ sane-backends-1.0.29/backend/hp5400_sanei.h0000666000000000000000000001012513615534521015037 00000000000000#ifndef _HP5400_SANEI_H_ #define _HP5400_SANEI_H_ /* sane - Scanner Access Now Easy. Copyright (C) 2003 Martijn van Oosterhout Copyright (C) 2003 Thomas Soumarmon Copyright (c) 2003 Henning Meier-Geinitz, Originally copied from HP3300 testtools. Original notice follows: Copyright (C) 2001 Bertrik Sikken (bertrik@zonnet.nl) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Transport layer for communication with HP5400/5470 scanner. Implementation using sanei_usb Additions to support bulk data transport. Added debugging info - 19/02/2003 Martijn Changed to use sanei_usb instead of direct /dev/usb/scanner access - 15/04/2003 Henning */ #define CMD_INITBULK1 0x0087 /* send 0x14 */ #define CMD_INITBULK2 0x0083 /* send 0x24 */ #define CMD_INITBULK3 0x0082 /* transfer length 0xf000 */ HP5400_SANE_STATIC void _UsbWriteControl (int fd, int iValue, int iIndex, void *pabData, int iSize); HP5400_SANE_STATIC void hp5400_command_write_noverify (int fd, int iValue, void *pabData, int iSize); HP5400_SANE_STATIC void _UsbReadControl (int fd, int iValue, int iIndex, void *pabData, int iSize); HP5400_SANE_STATIC int hp5400_open (const char *filename); HP5400_SANE_STATIC void hp5400_close (int iHandle); /* returns value > 0 if verify ok */ HP5400_SANE_STATIC int hp5400_command_verify (int iHandle, int iCmd); /* returns > 0 if command OK */ HP5400_SANE_STATIC int hp5400_command_read_noverify (int iHandle, int iCmd, int iLen, void *pbData); /* returns > 0 if command OK */ HP5400_SANE_STATIC int hp5400_command_read (int iHandle, int iCmd, int iLen, void *pbData); /* returns >0 if command OK */ HP5400_SANE_STATIC int hp5400_command_write (int iHandle, int iCmd, int iLen, void *pbData); #ifdef STANDALONE /* returns >0 if command OK */ HP5400_SANE_STATIC int hp5400_bulk_read (int iHandle, size_t len, int block, FILE * file); #endif /* returns >0 if command OK */ HP5400_SANE_STATIC int hp5400_bulk_read_block (int iHandle, int iCmd, void *cmd, int cmdlen, void *buffer, int len); /* returns >0 if command OK */ HP5400_SANE_STATIC int hp5400_bulk_command_write (int iHandle, int iCmd, void *cmd, int cmdlen, int datalen, int block, char *data); /** ScannerIsOn retrieve on/off status from scanner @return 1 if is on 0 if is off -1 if is not reachable */ HP5400_SANE_STATIC int hp5400_isOn (int iHandle); #endif sane-backends-1.0.29/backend/umax.c0000666000000000000000000107571213615534521013723 00000000000000/* --------------------------------------------------------------------------------------------------------- */ /* sane - Scanner Access Now Easy. umax.c (C) 1997-2007 Oliver Rauch 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for UMAX flatbed scanners. */ /* --------------------------------------------------------------------------------------------------------- */ #define BUILD 45 /* --------------------------------------------------------------------------------------------------------- */ /* SANE-FLOW-DIAGRAMM - sane_init() : initialize backend, attach scanners(devicename,0) . - sane_get_devices() : query list of scanner-devices . - sane_open() : open a particular scanner-device and attach_scanner(devicename,&dev) . . - sane_set_io_mode : set blocking-mode . . - sane_get_select_fd : get scanner-fd . . - sane_get_option_descriptor() : get option information . . - sane_control_option() : change option values . . . . - sane_start() : start image aquisition . . - sane_get_parameters() : returns actual scan-parameters . . - sane_read() : read image-data (from pipe) in ADF mode this is done often: . . - sane_start() : start image aquisition . . - sane_get_parameters() : returns actual scan-parameters . . - sane_read() : read image-data (from pipe) . . - sane_cancel() : cancel operation, kill reader_process . - sane_close() : close opened scanner-device, do_cancel, free buffer and handle - sane_exit() : terminate use of backend, free devicename and device-struture */ /* ------------------------------------------------------------ DBG OUTPUT LEVELS -------------------------- */ #define DBG_error0 0 #define DBG_error 1 #define DBG_sense 2 #define DBG_warning 3 #define DBG_inquiry 4 #define DBG_info 5 #define DBG_info2 6 #define DBG_proc 7 #define DBG_read 8 #define DBG_sane_init 10 #define DBG_sane_proc 11 #define DBG_sane_info 12 #define DBG_sane_option 13 /* ------------------------------------------------------------ SANE DEFINES ------------------------------- */ #define BACKEND_NAME umax #define UMAX_CONFIG_FILE "umax.conf" /* ------------------------------------------------------------ SANE INTERNATIONALISATION ------------------ */ #ifndef SANE_I18N #define SANE_I18N(text) text #endif /* ------------------------------------------------------------ INCLUDES ----------------------------------- */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_thread.h" #ifdef UMAX_ENABLE_USB # include "sane/sanei_usb.h" #endif #include #include #include "umax-scsidef.h" #include "umax-scanner.c" #ifdef UMAX_ENABLE_USB # include "umax-usb.c" #endif #include "umax.h" /* ------------------------------------------------------------ SANE DEFINES ------------------------------- */ #ifndef PATH_MAX #define PATH_MAX 1024 #endif /* ------------------------------------------------------------ OPTION DEFINITIONS ------------------------- */ #define SANE_NAME_BATCH_SCAN_START "batch-scan-start" #define SANE_TITLE_BATCH_SCAN_START "Batch scan start" #define SANE_DESC_BATCH_SCAN_START "set for first scan of batch" #define SANE_NAME_BATCH_SCAN_LOOP "batch-scan-loop" #define SANE_TITLE_BATCH_SCAN_LOOP "Batch scan loop" #define SANE_DESC_BATCH_SCAN_LOOP "set for middle scans of batch" #define SANE_NAME_BATCH_SCAN_END "batch-scan-end" #define SANE_TITLE_BATCH_SCAN_END "Batch scan end" #define SANE_DESC_BATCH_SCAN_END "set for last scan of batch" #define SANE_NAME_BATCH_NEXT_TL_Y "batch-scan-next-tl-y" #define SANE_TITLE_BATCH_NEXT_TL_Y "Batch scan next top left Y" #define SANE_DESC_BATCH_NEXT_TL_Y "Set top left Y position for next scan" #define SANE_UMAX_NAME_SELECT_CALIBRATON_EXPOSURE_TIME "select-calibration-exposure-time" #define SANE_UMAX_TITLE_SELECT_CALIBRATION_EXPOSURE_TIME "Set calibration exposure time" #define SANE_UMAX_DESC_SELECT_CALIBRATION_EXPOSURE_TIME "Allow different settings for calibration and scan exposure times" /* ------------------------------------------------------------ STRING DEFINITIONS ------------------------- */ #define FLB_STR SANE_I18N("Flatbed") #define UTA_STR SANE_I18N("Transparency Adapter") #define ADF_STR SANE_I18N("Automatic Document Feeder") #define LINEART_STR SANE_VALUE_SCAN_MODE_LINEART #define HALFTONE_STR SANE_VALUE_SCAN_MODE_HALFTONE #define GRAY_STR SANE_VALUE_SCAN_MODE_GRAY #define COLOR_LINEART_STR SANE_VALUE_SCAN_MODE_COLOR_LINEART #define COLOR_HALFTONE_STR SANE_VALUE_SCAN_MODE_COLOR_HALFTONE #define COLOR_STR SANE_VALUE_SCAN_MODE_COLOR /* ------------------------------------------------------------ DEFINITIONS -------------------------------- */ #define P_200_TO_255(per) ( (SANE_UNFIX(per) + 100) * 255/200 ) #define P_100_TO_255(per) SANE_UNFIX(per * 255/100 ) #define P_100_TO_254(per) 1+SANE_UNFIX(per * 254/100 ) /* ------------------------------------------------------------ GLOBAL VARIABLES --------------------------- */ static SANE_String scan_mode_list[7]; static SANE_String_Const source_list[4]; static SANE_Int bit_depth_list[9]; static SANE_Auth_Callback frontend_authorize_callback; static int umax_scsi_buffer_size_min = 32768; /* default: minimum scsi buffer size: 32 KB */ static int umax_scsi_buffer_size_max = 131072; /* default: maximum scsi buffer size: 128 KB */ /* number of lines that shall be scanned in one buffer for preview if possible */ /* this value should not be too large because it defines the step size in which */ /* the scanned parts are displayed while preview scan is in progress */ static int umax_preview_lines = 10; /* default: 10 preview lines */ /* number of lines that shall be scanned in one buffer for scan if possible */ static int umax_scan_lines = 40; /* default: 40 scan lines */ static int umax_scsi_maxqueue = 2; /* use command queueing depth 2 as default */ static int umax_handle_bad_sense_error = 0; /* default: handle bad sense error code as device busy */ static int umax_execute_request_sense = 0; /* default: do not use request sense in do_calibration */ static int umax_force_preview_bit_rgb = 0; /* default: do not force preview bit in real color scan */ static int umax_slow = -1; /* don`t use slow scanning speed */ static int umax_smear = -1; /* don`t care about image smearing problem */ static int umax_calibration_area = -1; /* -1=auto, 0=calibration on image, 1=calibration for full ccd */ static int umax_calibration_width_offset = -99999; /* -99999=auto */ static int umax_calibration_width_offset_batch = -99999; /* -99999=auto */ static int umax_calibration_bytespp = -1; /* -1=auto */ static int umax_exposure_time_rgb_bind = -1; /* -1=auto */ static int umax_invert_shading_data = -1; /* -1=auto */ static int umax_lamp_control_available = 0; /* 0=disabled */ static int umax_gamma_lsb_padded = -1; /* -1=auto */ static int umax_connection_type = 1; /* 1=scsi, 2=usb */ /* ------------------------------------------------------------ CALIBRATION MODE --------------------------- */ #ifdef UMAX_CALIBRATION_MODE_SELECTABLE #define CALIB_MODE_0000 SANE_I18N("Use Image Composition") #define CALIB_MODE_1111 SANE_I18N("Bi-level black and white (lineart mode)") #define CALIB_MODE_1110 SANE_I18N("Dithered/halftone black & white (halftone mode)") #define CALIB_MODE_1101 SANE_I18N("Multi-level black & white (grayscale mode)") #define CALIB_MODE_1010 SANE_I18N("Multi-level RGB color (one pass color)") #define CALIB_MODE_1001 SANE_I18N("Ignore calibration") static SANE_String_Const calibration_list[] = { CALIB_MODE_0000, CALIB_MODE_1111, CALIB_MODE_1110, CALIB_MODE_1101, CALIB_MODE_1010, CALIB_MODE_1001, 0 }; #endif /* --------------------------------------------------------------------------------------------------------- */ enum { UMAX_CALIBRATION_AREA_IMAGE = 0, UMAX_CALIBRATION_AREA_CCD }; static const SANE_Int pattern_dim_list[] = { 5, /* # of elements */ 2, 4, 6, 8, 12 }; static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; static const SANE_Range percentage_range = { SANE_FIX(-100), /* minimum */ SANE_FIX( 100), /* maximum */ SANE_FIX( 1) /* quantization */ }; static const SANE_Range percentage_range_100 = { SANE_FIX( 0), /* minimum */ SANE_FIX(100), /* maximum */ SANE_FIX( 0) /* quantization */ }; static int num_devices = 0; static const SANE_Device **devlist = NULL; static Umax_Device *first_dev = NULL; static Umax_Scanner *first_handle = NULL; /* ------------------------------------------------------------ MATH-HELPERS ------------------------------- */ #define min(a, b) (((a)<(b))?(a):(b)) #define max(a, b) (((a)>(b))?(a):(b)) #define inrange(minimum, val, maximum) (min(maximum, max(val, minimum))) /* ------------------------------------------------------------ umax_test_little_endian -------------------- */ static SANE_Bool umax_test_little_endian(void) { SANE_Int testvalue = 255; unsigned char *firstbyte = (unsigned char *) &testvalue; if (*firstbyte == 255) { return SANE_TRUE; } return SANE_FALSE; } /* ------------------------------------------------------------ DBG_inq_nz --------------------------------- */ static void DBG_inq_nz(char *text, int flag) { if (flag != 0) { DBG(DBG_inquiry,"%s", text); } } /*------------------------------------------------------------- DBG_sense_nz ------------------------------- */ static void DBG_sense_nz(char *text, int flag) { if (flag != 0) { DBG(DBG_sense,"%s", text); } } /* ------------------------------------------------------------ UMAX PRINT INQUIRY ------------------------- */ static void umax_print_inquiry(Umax_Device *dev) { unsigned char *inquiry_block; int i; inquiry_block=dev->buffer[0]; DBG(DBG_inquiry,"INQUIRY:\n"); DBG(DBG_inquiry,"========\n"); DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"vendor........................: '%s'\n", dev->vendor); DBG(DBG_inquiry,"product.......................: '%s'\n", dev->product); DBG(DBG_inquiry,"version.......................: '%s'\n", dev->version); DBG(DBG_inquiry,"peripheral qualifier..........: %d\n", get_inquiry_periph_qual(inquiry_block)); DBG(DBG_inquiry,"peripheral device type........: %d\n", get_inquiry_periph_devtype(inquiry_block)); DBG_inq_nz("RMB bit set (reserved)\n", get_inquiry_rmb(inquiry_block)); DBG_inq_nz("0x01 bit 6\n", get_inquiry_0x01_bit6(inquiry_block)); DBG_inq_nz("0x01 bit 5\n", get_inquiry_0x01_bit5(inquiry_block)); DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"CBHS value range..............: %s\n", cbhs_str[dev->inquiry_cbhs]); DBG(DBG_inquiry,"scanmode......................: %s\n", scanmode_str[get_inquiry_scanmode(inquiry_block)]); if (dev->inquiry_transavail) { DBG(DBG_inquiry,"UTA (transparency)............: available\n"); if (get_inquiry_translamp(inquiry_block) == 0) { DBG(DBG_inquiry,"UTA lamp status ..............: off\n"); } else { DBG(DBG_inquiry,"UTA lamp status ..............: on\n"); } DBG(DBG_inquiry,"\n"); } DBG(DBG_inquiry,"inquiry block length..........: %d bytes\n", dev->inquiry_len); if (dev->inquiry_len<=0x8e) { DBG(DBG_inquiry, "Inquiry block is unexpected short, should be at least 147 bytes\n"); } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"ISO Version (reserved).......: %d\n", get_inquiry_iso_version(inquiry_block)); DBG(DBG_inquiry,"ECMA Version (reserved).......: %d\n", get_inquiry_ecma_version(inquiry_block)); DBG(DBG_inquiry,"ANSI Version .................: %d\n", get_inquiry_ansi_version(inquiry_block)); DBG(DBG_inquiry,"\n"); DBG_inq_nz("AENC bit set (reserved)\n", get_inquiry_aenc(inquiry_block)); DBG_inq_nz("TmIOP bit set (reserved)\n", get_inquiry_tmiop(inquiry_block)); DBG_inq_nz("0x03 bit 5\n", get_inquiry_0x03_bit5(inquiry_block)); DBG_inq_nz("0x03 bit 4\n", get_inquiry_0x03_bit4(inquiry_block)); DBG(DBG_inquiry,"reserved byte 0x05 = %d\n", get_inquiry_0x05(inquiry_block)); DBG(DBG_inquiry,"reserved byte 0x06 = %d\n", get_inquiry_0x06(inquiry_block)); DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"scsi features (%02x):\n", get_inquiry_scsi_byte(inquiry_block)); DBG(DBG_inquiry,"-------------------\n"); 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(" - 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)); DBG_inq_nz(" - sftre\n", get_inquiry_scsi_sftre(inquiry_block)); /* 0x24 */ if (dev->inquiry_len<=0x24) { return; } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"f/w support function:\n"); DBG(DBG_inquiry,"---------------------\n"); DBG_inq_nz(" - quality calibration\n", dev->inquiry_quality_ctrl); DBG_inq_nz(" - fast preview function\n", dev->inquiry_preview); DBG_inq_nz(" - shadow compensation by f/w\n", get_inquiry_fw_shadow_comp(inquiry_block)); DBG_inq_nz(" - reselection phase\n", get_inquiry_fw_reselection(inquiry_block)); DBG_inq_nz(" - lamp intensity control\n", dev->inquiry_lamp_ctrl); DBG_inq_nz(" - batch scan function\n", get_inquiry_fw_batch_scan(inquiry_block)); DBG_inq_nz(" - calibration mode control by driver\n", get_inquiry_fw_calibration(inquiry_block)); /* 0x36, 0x37 */ DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"reserved byte 0x36 = %d\n", get_inquiry_0x36(inquiry_block)); DBG(DBG_inquiry,"reserved byte 0x37 = %d\n", get_inquiry_0x37(inquiry_block)); if (get_inquiry_fw_adjust_exposure_tf(inquiry_block)) { int unit; DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"adjust exposure time function\n"); unit=get_inquiry_exposure_time_step_unit(inquiry_block); DBG(DBG_inquiry,"exposure time step units......: %d micro-sec\n", unit); DBG(DBG_inquiry,"exposure time maximum.........: %d micro-sec\n", unit*get_inquiry_exposure_time_max(inquiry_block)); DBG(DBG_inquiry,"exposure time minimum (LHG)...: %d micro-sec\n", unit*get_inquiry_exposure_time_lhg_min(inquiry_block)); DBG(DBG_inquiry,"exposure time minimum color...: %d micro-sec\n", unit*get_inquiry_exposure_time_color_min(inquiry_block)); DBG(DBG_inquiry,"exposure time default FB (LH).: %d micro-sec\n", unit*get_inquiry_exposure_time_lh_def_fb(inquiry_block)); DBG(DBG_inquiry,"exposure time default UTA (LH): %d micro-sec\n", unit*get_inquiry_exposure_time_lh_def_uta(inquiry_block)); DBG(DBG_inquiry,"exposure time default FB gray.: %d micro-sec\n", unit*get_inquiry_exposure_time_gray_def_fb(inquiry_block)); DBG(DBG_inquiry,"exposure time default UTA gray: %d micro-sec\n", unit*get_inquiry_exposure_time_gray_def_uta(inquiry_block)); DBG(DBG_inquiry,"exposure time default FB red..: %d micro-sec\n", unit*get_inquiry_exposure_time_def_r_fb(inquiry_block)); DBG(DBG_inquiry,"exposure time default FB grn..: %d micro-sec\n", unit*get_inquiry_exposure_time_def_g_fb(inquiry_block)); DBG(DBG_inquiry,"exposure time default FB blue.: %d micro-sec\n", unit*get_inquiry_exposure_time_def_b_fb(inquiry_block)); DBG(DBG_inquiry,"exposure time default UTA red.: %d micro-sec\n", unit*get_inquiry_exposure_time_def_r_uta(inquiry_block)); DBG(DBG_inquiry,"exposure time default UTA grn.: %d micro-sec\n", unit*get_inquiry_exposure_time_def_g_uta(inquiry_block)); DBG(DBG_inquiry,"exposure time default UTA blue: %d micro-sec\n", unit*get_inquiry_exposure_time_def_b_uta(inquiry_block)); } /* 0x60 */ if (dev->inquiry_len<=0x60) { return; } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"scan modes (%02x):\n", get_inquiry_sc_feature_byte0(inquiry_block)); DBG(DBG_inquiry,"----------------\n"); DBG_inq_nz(" - three passes color mode\n", get_inquiry_sc_three_pass_color(inquiry_block)); DBG_inq_nz(" - single pass color mode\n", get_inquiry_sc_one_pass_color(inquiry_block)); DBG_inq_nz(" - lineart mode\n", dev->inquiry_lineart); DBG_inq_nz(" - halftone mode\n", dev->inquiry_halftone); DBG_inq_nz(" - gray mode\n", dev->inquiry_gray); DBG_inq_nz(" - color mode\n", dev->inquiry_color); DBG_inq_nz(" - transparency (UTA)\n", dev->inquiry_uta); DBG_inq_nz(" - automatic document feeder (ADF)\n", dev->inquiry_adf); /* 0x61 */ if (dev->inquiry_len<=0x61) { return; } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"scanner capability (%02x, %02x, %02x):\n", get_inquiry_sc_feature_byte1(inquiry_block), get_inquiry_sc_feature_byte2(inquiry_block), get_inquiry_sc_feature_byte3(inquiry_block)); DBG(DBG_inquiry,"--------------------------------\n"); DBG_inq_nz(" - double resolution\n", dev->inquiry_dor); DBG_inq_nz(" - send high byte first\n", get_inquiry_sc_high_byte_first(inquiry_block)); DBG_inq_nz(" - bi-level image reverse\n", dev->inquiry_reverse); DBG_inq_nz(" - multi-level image reverse\n", dev->inquiry_reverse_multi); DBG_inq_nz(" - support shadow function\n", dev->inquiry_shadow); DBG_inq_nz(" - support highlight function\n", dev->inquiry_highlight); DBG_inq_nz(" - f/w downloadable\n", get_inquiry_sc_downloadable_fw(inquiry_block)); DBG_inq_nz(" - paper length can reach to 14 inch\n", get_inquiry_sc_paper_length_14(inquiry_block)); /* 0x62 */ if (dev->inquiry_len<=0x62) { return; } DBG_inq_nz(" - shading data/gain uploadable\n", get_inquiry_sc_uploadable_shade(inquiry_block)); DBG_inq_nz(" - analog gamma correction\n", dev->inquiry_analog_gamma); DBG_inq_nz(" - x, y coordinate base\n", get_inquiry_xy_coordinate_base(inquiry_block)); DBG_inq_nz(" - lineart starts with LSB\n", get_inquiry_lineart_order(inquiry_block)); DBG_inq_nz(" - start density \n", get_inquiry_start_density(inquiry_block)); DBG_inq_nz(" - hardware x scaling\n", get_inquiry_hw_x_scaling(inquiry_block)); DBG_inq_nz(" - hardware y scaling\n", get_inquiry_hw_y_scaling(inquiry_block)); /* 0x63 */ if (dev->inquiry_len<=0x63) { return; } 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(" - 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)); DBG_inq_nz(" - UTA lens calib pos selectable\n", get_inquiry_sel_uta_lens_cal_pos(inquiry_block)); /* 0x64 - 0x68*/ if (dev->inquiry_len<=0x68) { return; } if (dev->inquiry_gamma_dwload) { DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"gamma download available\n"); DBG_inq_nz("gamma download type 2\n", get_inquiry_gamma_type_2(inquiry_block)); DBG(DBG_inquiry,"lines of gamma curve: %s\n", gamma_lines_str[get_inquiry_gamma_lines(inquiry_block)]); /* 0x66 */ DBG_inq_nz("gamma input 8 bits/pixel support\n", get_inquiry_gib_8bpp(inquiry_block)); DBG_inq_nz("gamma input 9 bits/pixel support\n", get_inquiry_gib_9bpp(inquiry_block)); DBG_inq_nz("gamma input 10 bits/pixel support\n", get_inquiry_gib_10bpp(inquiry_block)); DBG_inq_nz("gamma input 12 bits/pixel support\n", get_inquiry_gib_12bpp(inquiry_block)); DBG_inq_nz("gamma input 14 bits/pixel support\n", get_inquiry_gib_14bpp(inquiry_block)); DBG_inq_nz("gamma input 16 bits/pixel support\n", get_inquiry_gib_16bpp(inquiry_block)); DBG_inq_nz("0x66 bit 6\n", get_inquiry_0x66_bit6(inquiry_block)); DBG_inq_nz("0x66 bit 7\n", get_inquiry_0x66_bit7(inquiry_block)); /* 0x68 */ DBG_inq_nz("gamma output 8 bits/pixel support\n", get_inquiry_gob_8bpp(inquiry_block)); DBG_inq_nz("gamma output 9 bits/pixel support\n", get_inquiry_gob_9bpp(inquiry_block)); DBG_inq_nz("gamma output 10 bits/pixel support\n", get_inquiry_gob_10bpp(inquiry_block)); DBG_inq_nz("gamma output 12 bits/pixel support\n", get_inquiry_gob_12bpp(inquiry_block)); DBG_inq_nz("gamma output 14 bits/pixel support\n", get_inquiry_gob_14bpp(inquiry_block)); DBG_inq_nz("gamma output 16 bits/pixel support\n", get_inquiry_gob_16bpp(inquiry_block)); DBG_inq_nz("0x68 bit 6\n", get_inquiry_0x68_bit6(inquiry_block)); DBG_inq_nz("0x68 bit 7\n", get_inquiry_0x68_bit7(inquiry_block)); } /* 0x64 - 0x68 reserved bits */ DBG_inq_nz("0x64 bit 2\n", get_inquiry_0x64_bit2(inquiry_block)); DBG_inq_nz("0x64 bit 3\n", get_inquiry_0x64_bit3(inquiry_block)); DBG_inq_nz("0x64 bit 4\n", get_inquiry_0x64_bit4(inquiry_block)); DBG_inq_nz("0x64 bit 6\n", get_inquiry_0x64_bit6(inquiry_block)); DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"reserved byte 0x65 = %d\n", get_inquiry_0x65(inquiry_block)); DBG(DBG_inquiry,"reserved byte 0x67 = %d\n", get_inquiry_0x67(inquiry_block)); /* 0x69 */ if (dev->inquiry_len<=0x69) { return; } DBG(DBG_inquiry,"\n"); if (get_inquiry_hda(inquiry_block)) { DBG(DBG_inquiry,"halftone download available\n"); DBG(DBG_inquiry,"halftone pattern download max matrix %dx%d\n", get_inquiry_max_halftone_matrix(inquiry_block), get_inquiry_max_halftone_matrix(inquiry_block)); } /* 0x6a */ if (dev->inquiry_len<=0x6a) { return; } DBG_inq_nz("built-in halftone patterns:\n", get_inquiry_halftones_supported(inquiry_block)); DBG_inq_nz("built-in halftone pattern size ............: 2x2\n", get_inquiry_halftones_2x2(inquiry_block)); DBG_inq_nz("built-in halftone pattern size ............: 4x4\n", get_inquiry_halftones_4x4(inquiry_block)); DBG_inq_nz("built-in halftone pattern size ............: 6x6\n", get_inquiry_halftones_6x6(inquiry_block)); DBG_inq_nz("built-in halftone pattern size ............: 8x8\n", get_inquiry_halftones_8x8(inquiry_block)); DBG_inq_nz("built-in halftone pattern size ............: 12x12\n", get_inquiry_halftones_12x12(inquiry_block)); /* 0x6b, 0x6c */ DBG(DBG_inquiry,"reserved byte 0x6b = %d\n", get_inquiry_0x6b(inquiry_block)); DBG(DBG_inquiry,"reserved byte 0x6c = %d\n", get_inquiry_0x6c(inquiry_block)); /* 0x6d */ if (dev->inquiry_len<=0x6d) { return; } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"color sequence............................: %s\n", color_sequence_str[get_inquiry_colorseq(inquiry_block)]); DBG_inq_nz("color ordering support....................: pixel\n", get_inquiry_color_order_pixel(inquiry_block)); DBG_inq_nz("color ordering support....................: line without CCD distance\n", get_inquiry_color_order_line_no_ccd(inquiry_block)); DBG_inq_nz("color ordering support....................: plane\n", get_inquiry_color_order_plane(inquiry_block)); DBG_inq_nz("color ordering support....................: line with CCD distance\n", get_inquiry_color_order_line_w_ccd(inquiry_block)); DBG_inq_nz("color ordering support....................: (reserved)\n", get_inquiry_color_order_reserved(inquiry_block)); /* 0x6e */ if (dev->inquiry_len<=0x71) { return; } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"maximum video memory......................: %d KB\n", dev->inquiry_vidmem/1024); /* 0x72 */ DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"reserved byte 0x72 = %d\n", get_inquiry_0x72(inquiry_block)); DBG(DBG_inquiry,"\n"); /* 0x73/0x94 - 0x75/0x96 */ if (dev->inquiry_len<=0x75) { return; } DBG(DBG_inquiry,"optical resolution........................: %d dpi\n", dev->inquiry_optical_res); DBG(DBG_inquiry,"maximum x-resolution......................: %d dpi\n", dev->inquiry_x_res); DBG(DBG_inquiry,"maximum y-resolution......................: %d dpi\n", dev->inquiry_y_res); /* ---------- */ /* 0x76 0x77 */ if (dev->inquiry_len<=0x77) { return; } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"FB (flatbed-mode):\n"); DBG(DBG_inquiry,"FB maximum scan width.....................: %2.2f inch\n", dev->inquiry_fb_width); DBG(DBG_inquiry,"FB maximum scan length....................: %2.2f inch\n", dev->inquiry_fb_length); /* ---------- */ /* 0x7a - 0x81 */ if (dev->inquiry_len<=0x81) { return; } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"UTA (transparency-mode):\n"); DBG(DBG_inquiry,"UTA x-original point......................: %2.2f inch\n", dev->inquiry_uta_x_off); DBG(DBG_inquiry,"UTA y-original point......................: %2.2f inch\n", dev->inquiry_uta_y_off); DBG(DBG_inquiry,"UTA maximum scan width....................: %2.2f inch\n", dev->inquiry_uta_width); DBG(DBG_inquiry,"UTA maximum scan length...................: %2.2f inch\n", dev->inquiry_uta_length); /* ---------- */ /* 0x82-0x85 */ DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"reserved byte 0x82 = %d\n", get_inquiry_0x82(inquiry_block)); /* ---------- */ /* 0x83/0xa0 - 0x85/0xa2 */ if (dev->inquiry_len<=0x85) { return; } DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"DOR (double optical resolution-mode):\n"); DBG(DBG_inquiry,"DOR optical resolution....................: %d dpi\n", dev->inquiry_dor_optical_res); DBG(DBG_inquiry,"DOR maximum x-resolution..................: %d dpi\n", dev->inquiry_dor_x_res); DBG(DBG_inquiry,"DOR maximum y-resolution..................: %d dpi\n", dev->inquiry_dor_y_res); /* 0x86 - 0x8d */ if (dev->inquiry_len<=0x8d) { return; } DBG(DBG_inquiry,"DOR x-original point......................: %2.2f inch\n", dev->inquiry_dor_x_off); DBG(DBG_inquiry,"DOR y-original point......................: %2.2f inch\n", dev->inquiry_dor_y_off); DBG(DBG_inquiry,"DOR maximum scan width....................: %2.2f inch\n", dev->inquiry_dor_width); DBG(DBG_inquiry,"DOR maximum scan length...................: %2.2f inch\n", dev->inquiry_dor_length); DBG(DBG_inquiry,"\n"); /* ---------- */ /* 0x8e */ DBG(DBG_inquiry,"reserved byte 0x8e = %d\n", get_inquiry_0x8e(inquiry_block)); DBG(DBG_inquiry,"\n"); /* ---------- */ /* 0x8f */ if (dev->inquiry_len<=0x8f) { return; } DBG(DBG_inquiry,"last calibration lamp density.............: %d\n", get_inquiry_last_calibration_lamp_density(inquiry_block)); /* 0x90 */ DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"reserved byte 0x90 = %d\n", get_inquiry_0x90(inquiry_block)); DBG(DBG_inquiry,"\n"); /* 0x91 */ if (dev->inquiry_len<=0x91) { return; } DBG(DBG_inquiry,"lamp warmup maximum time..................: %d sec\n", dev->inquiry_max_warmup_time); /* 0x92 0x93 */ if (dev->inquiry_len<=0x93) { return; } DBG(DBG_inquiry,"window descriptor block length............: %d bytes\n", get_inquiry_wdb_length(inquiry_block)); /* ----------------- */ /* 0x97 */ if (dev->inquiry_len<=0x97) { return; } if (get_inquiry_analog_gamma_table(inquiry_block) == 0) { DBG(DBG_inquiry,"no analog gamma function\n"); } else { DBG(DBG_inquiry,"mp 8832 analog gamma table\n"); } /* 0x98, 0x99 */ DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"reserved byte 0x98 = %d\n", get_inquiry_0x98(inquiry_block)); DBG(DBG_inquiry,"reserved byte 0x99 = %d\n", get_inquiry_0x99(inquiry_block)); DBG(DBG_inquiry,"\n"); /* 0x9a */ if (dev->inquiry_len<=0x9a) { return; } DBG(DBG_inquiry,"maximum calibration data lines for shading: %d\n", get_inquiry_max_calibration_data_lines(inquiry_block)); /* 0x9b */ if (dev->inquiry_len<=0x9b) { return; } DBG(DBG_inquiry,"fb/uta: color line arrangement mode.......: %d\n", get_inquiry_fb_uta_line_arrangement_mode(inquiry_block)); /* 0x9c */ if (dev->inquiry_len<=0x9c) { return; } DBG(DBG_inquiry,"adf: color line arrangement mode.......: %d\n", get_inquiry_adf_line_arrangement_mode(inquiry_block)); /* 0x9d */ if (dev->inquiry_len<=0x9d) { return; } DBG(DBG_inquiry,"CCD line distance.........................: %d\n", get_inquiry_CCD_line_distance(inquiry_block)); DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"reserved byte 0x9e = %d\n", get_inquiry_0x9e(inquiry_block)); /* 0xa2 following */ if (dev->inquiry_len<=0xa2) { return; } DBG(DBG_inquiry,"\n"); for(i=0xa3; iinquiry_len; i++) { DBG(DBG_inquiry,"unknown reserved byte 0x%x = %d\n", i, inquiry_block[i]); } } /* ------------------------------------------------------------ CBHS_CORRECT ------------------------------- */ static int umax_cbhs_correct(int minimum, int cbhs, int maximum) { int range = maximum - minimum + 1; if (range == 256) { return cbhs; } return (int)( (cbhs/256.0)*range + minimum ); } /* ------------------------------------------------------------ SENSE_HANDLER ------------------------------ */ static SANE_Status sense_handler(int scsi_fd, unsigned char *result, void *arg) /* is called by sanei_scsi */ { unsigned char asc, ascq, sensekey; int asc_ascq, len; Umax_Device *dev = arg; DBG(DBG_proc, "check condition sense handler (scsi_fd = %d)\n", scsi_fd); sensekey = get_RS_sense_key(result); asc = get_RS_ASC(result); ascq = get_RS_ASCQ(result); asc_ascq = (int)(256 * asc + ascq); len = 7 + get_RS_additional_length(result); if ( get_RS_error_code(result) != 0x70 ) { DBG(DBG_error, "invalid sense key error code (%d)\n", get_RS_error_code(result)); switch (dev->handle_bad_sense_error) { default: case 0: DBG(DBG_error, "=> handled as DEVICE BUSY!\n"); return SANE_STATUS_DEVICE_BUSY; case 1: DBG(DBG_error, "=> handled as ok!\n"); return SANE_STATUS_GOOD; case 2: DBG(DBG_error, "=> handled as i/o error!\n"); return SANE_STATUS_IO_ERROR; case 3: DBG(DBG_error, "=> ignored, sense handler does continue\n"); } } DBG(DBG_sense, "check condition sense: %s\n", sense_str[sensekey]); /* when we reach here then we have no valid data in buffer[0] */ /* but it may be helpful to have the result data in buffer[0] */ memset(dev->buffer[0], 0, rs_return_block_size); /* clear sense data buffer */ memcpy(dev->buffer[0], result, len+1); /* copy sense data to buffer */ if (len > 0x15) { int scanner_error = get_RS_scanner_error_code(result); if (scanner_error < 100) { DBG(DBG_sense, "-> %s (#%d)\n", scanner_error_str[scanner_error], scanner_error); } else { DBG(DBG_sense, "-> error %d\n", scanner_error); } } if (get_RS_ILI(result) != 0) { DBG(DBG_sense, "-> ILI-ERROR: requested data length is larger than actual length\n"); } switch(sensekey) { case 0x00: /* no sense */ return SANE_STATUS_GOOD; break; case 0x03: /* medium error */ if (asc_ascq == 0x1400) { DBG(DBG_sense, "-> misfeed, paper jam\n"); return SANE_STATUS_JAMMED; } else if (asc_ascq == 0x1401) { DBG(DBG_sense, "-> adf not ready\n"); return SANE_STATUS_NO_DOCS; } else { DBG(DBG_sense, "-> unknown medium error: asc=%d, ascq=%d\n", asc, ascq); } break; case 0x04: /* hardware error */ if (asc_ascq == 0x4000) { DBG(DBG_sense, "-> diagnostic error:\n"); if (len >= 0x13) { DBG_sense_nz(" dim light\n", get_RS_asb_dim_light(result)); DBG_sense_nz(" no light\n", get_RS_asb_no_light(result)); DBG_sense_nz(" sensor or motor error\n", get_RS_asb_sensor_motor(result)); DBG_sense_nz(" too light\n", get_RS_asb_too_light(result)); DBG_sense_nz(" calibration error\n", get_RS_asb_calibration(result)); DBG_sense_nz(" rom error\n", get_RS_asb_rom(result)); DBG_sense_nz(" ram error\n", get_RS_asb_ram(result)); DBG_sense_nz(" cpu error\n", get_RS_asb_cpu(result)); DBG_sense_nz(" scsi error\n", get_RS_asb_scsi(result)); DBG_sense_nz(" timer error\n", get_RS_asb_timer(result)); DBG_sense_nz(" filter motor error\n", get_RS_asb_filter_motor(result)); DBG_sense_nz(" dc adjust error\n", get_RS_asb_dc_adjust(result)); DBG_sense_nz(" uta home sensor or motor error\n", get_RS_asb_uta_sensor(result)); } } else { DBG(DBG_sense, "-> unknown hardware error: asc=%d, ascq=%d\n", asc, ascq); } return SANE_STATUS_IO_ERROR; break; case 0x05: /* illegal request */ if (asc_ascq == 0x2000) { DBG(DBG_sense, "-> invalid command operation code\n"); } else if (asc_ascq == 0x2400) { DBG(DBG_sense, "-> illegal field in CDB\n"); } else if (asc_ascq == 0x2500) { DBG(DBG_sense, "-> logical unit not supported\n"); } else if (asc_ascq == 0x2600) { DBG(DBG_sense, "-> invalid field in parameter list\n"); } else if (asc_ascq == 0x2c01) { DBG(DBG_sense, "-> too many windows specified\n"); } else if (asc_ascq == 0x2c02) { DBG(DBG_sense, "-> invalid combination of windows specified\n"); } else { DBG(DBG_sense, "-> illegal request: asc=%d, ascq=%d\n", asc, ascq); } if (len >= 0x11) { if (get_RS_SKSV(result) != 0) { if (get_RS_CD(result) == 0) { DBG(DBG_sense, "-> illegal parameter in CDB\n"); } else { DBG(DBG_sense, "-> illegal parameter is in the data parameters sent during data out phase\n"); } DBG(DBG_sense, "-> error detected in byte %d\n", get_RS_field_pointer(result)); } } return SANE_STATUS_IO_ERROR; break; case 0x06: /* unit attention */ if (asc_ascq == 0x2900) { DBG(DBG_sense, "-> power on, reset or bus device reset\n"); } else if (asc_ascq == 0x3f01) { DBG(DBG_sense, "-> microcode has been changed\n"); } else { DBG(DBG_sense, "-> unit attention: asc=%d, ascq=%d\n", asc, ascq); } break; case 0x09: /* vendor specific */ if (asc == 0x00) { DBG(DBG_sense, "-> button protocol\n"); if (ascq & 1) { dev->button0_pressed = 1; DBG(DBG_sense, "-> button 0 pressed\n"); } if (ascq & 2) { dev->button1_pressed = 1; DBG(DBG_sense, "-> button 1 pressed\n"); } if (ascq & 4) { dev->button2_pressed = 1; DBG(DBG_sense, "-> button 2 pressed\n"); } return SANE_STATUS_GOOD; } else if (asc_ascq == 0x8001) { DBG(DBG_sense, "-> lamp warmup\n"); return SANE_STATUS_DEVICE_BUSY; } else if (asc_ascq == 0x8002) { DBG(DBG_sense, "-> calibration by driver\n"); if (dev) { dev->do_calibration = 1; /* set flag for calibration by driver */ } return SANE_STATUS_GOOD; } else { DBG(DBG_sense, "-> vendor specific sense-code: asc=%d, ascq=%d\n", asc, ascq); } break; } return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ UMAX SET RGB BIND -------------------------- */ static void umax_set_rgb_bind(Umax_Scanner *scanner) { if ( (scanner->val[OPT_RGB_BIND].w == SANE_FALSE) && (strcmp(scanner->val[OPT_MODE].s, COLOR_STR) == 0) ) /* enable rgb options */ { if (scanner->device->inquiry_analog_gamma) { scanner->opt[OPT_ANALOG_GAMMA].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_B].cap &= ~SANE_CAP_INACTIVE; } if (scanner->device->inquiry_highlight) { scanner->opt[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_B].cap &= ~SANE_CAP_INACTIVE; } if (scanner->device->inquiry_shadow) { scanner->opt[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_B].cap &= ~SANE_CAP_INACTIVE; } } else /* only show gray options */ { if (scanner->device->inquiry_analog_gamma) { scanner->opt[OPT_ANALOG_GAMMA].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_B].cap |= SANE_CAP_INACTIVE; } if (scanner->device->inquiry_highlight) { scanner->opt[OPT_HIGHLIGHT].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_B].cap |= SANE_CAP_INACTIVE; } if (scanner->device->inquiry_shadow) { scanner->opt[OPT_SHADOW].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_B].cap |= SANE_CAP_INACTIVE; } } if ( (scanner->device->inquiry_exposure_adj) && (scanner->val[OPT_SELECT_EXPOSURE_TIME].w) ) { if ( (scanner->val[OPT_RGB_BIND].w == SANE_FALSE) && (!scanner->device->exposure_time_rgb_bind) && (strcmp(scanner->val[OPT_MODE].s, COLOR_STR) == 0) ) /* enable rgb exposure time options */ { if (scanner->val[OPT_SELECT_CAL_EXPOSURE_TIME].w) /* exposure time setting for calibration enabled */ { scanner->opt[OPT_CAL_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_B].cap &= ~SANE_CAP_INACTIVE; } else /* no separate settings for calibration exposure times */ { scanner->opt[OPT_CAL_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_SCAN_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_B].cap &= ~SANE_CAP_INACTIVE; } else /* enable gray exposure time options */ { if (scanner->val[OPT_SELECT_CAL_EXPOSURE_TIME].w) /* exposure time setting for calibration enabled */ { scanner->opt[OPT_CAL_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; } else /* no separate settings for calibration exposure times */ { scanner->opt[OPT_CAL_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_CAL_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; } } } /* ------------------------------------------------------------ UMAX CALCULATE PIXELS ---------------------- */ static int umax_calculate_pixels(int scansize_pixel, int resolution, int resolution_base, int coordinate_base) /* scansize_pixel = size in pixels at 1200 dpi */ /* resolution = scan resolution */ /* resolution_base = this is the optical resolution * 1 or * 2 */ /* coordinate_base = this is 1200 dpi */ { unsigned int intsize_inch, intsize_pixel, diffsize_pixel, missing_pixels, del_pixel_1, pix; int toomuch; intsize_inch = scansize_pixel / coordinate_base; /* full inches */ intsize_pixel = intsize_inch * resolution; /* pixels in full inches */ diffsize_pixel = scansize_pixel % coordinate_base; /* missing pixels in last inch at 1200 dpi */ missing_pixels = diffsize_pixel * resolution_base / coordinate_base; /* missing pixels at resolution_base dpi */ del_pixel_1 = resolution_base - resolution; /* pixels to erase in one inch */ toomuch = 0; /* number of pixels that must be deleted in last inch */ if (del_pixel_1 != 0) /* search the number of pixels that must deleted */ { pix = 0; while (pix <= missing_pixels) { toomuch++; pix = toomuch * resolution_base/del_pixel_1; } if (pix > missing_pixels) { toomuch--; } } return (intsize_pixel + missing_pixels - toomuch); } /* ------------------------------------------------------------ UMAX FORGET LINE --------------------------- */ static int umax_forget_line(Umax_Device *dev, int color) /* tests if line related to optical resolution has to be skipped for selected resolution */ /* returns 0 if line is ok, -1 if line has to be skipped */ { unsigned int opt_res = dev->relevant_optical_res * dev->scale_y; unsigned int forget; dev->pixelline_opt_res++; /* increment number of lines in optical res */ if (opt_res != dev->y_resolution) /* are there any lines to skip ? */ { forget = (dev->pixelline_del[color] * opt_res)/(opt_res - dev->y_resolution); if (dev->pixelline_optic[color]++ == forget) { dev->pixelline_del[color]++; /* inc pointer to next line to skip */ return(-1); /* skip line */ } } return(0); /* ok, order this line */ } /* ------------------------------------------------------------ UMAX ORDER LINE TO PIXEL ------------------- */ static void umax_order_line_to_pixel(Umax_Device *dev, unsigned char *source, int color) /* reads a one-color line and writes it into a pixel-ordered-buffer if line */ /* is not skipped */ /* color = 0:red, 1:green, 2:blue */ { unsigned int i; unsigned int line = dev->pixelline_next[color]; /* bufferlinenumber */ unsigned char *dest = dev->pixelbuffer; if (dest != NULL) { if (dev->bits_per_pixel_code == 1) /* 24 bpp */ { dest += line * dev->width_in_pixels * 3 + color; for (i=0; iwidth_in_pixels; i++) /* cp each pixel into pixelbuffer */ { *dest++ = *source++; dest++; dest++; } } else /* > 24 bpp */ { dest += line * dev->width_in_pixels * 6 + color * 2; for(i=0; iwidth_in_pixels; i++) /* cp each pixel into pixelbuffer */ { *dest++ = *source++; /* byte order correct ? , don't know ! */ *dest++ = *source++; dest++; dest++; dest++; dest++; } } line++; if (line >= dev->pixelline_max) { line = 0; } dev->pixelline_next[color] = line; /* next line of this color */ dev->pixelline_ready[color]++; /* number of ready lines for color */ DBG(DBG_read, "merged line as color %d to line %d\n", color, dev->pixelline_ready[color]); } } /* ------------------------------------------------------------ UMAX ORDER LINE ---------------------------- */ static void umax_order_line(Umax_Device *dev, unsigned char *source) { unsigned int CCD_distance = dev->CCD_distance * dev->scale_y; unsigned int length = (dev->scanlength * dev->scale_y * dev->relevant_optical_res) / dev->y_coordinate_base; unsigned int color; do /* search next valid line */ { if (dev->pixelline_opt_res < CCD_distance) { color = dev->CCD_color[0]; /* color 0 */ } else if (dev->pixelline_opt_res < CCD_distance * 3) { color = dev->CCD_color[1 + ((dev->pixelline_opt_res - CCD_distance) % 2)]; /* color 1,2 */ } else if (dev->pixelline_opt_res < length * 3 - CCD_distance * 3) { color = dev->CCD_color[3 + (dev->pixelline_opt_res % 3)]; /* color 3,4,5 */ } else if (dev->pixelline_opt_res < length * 3 - CCD_distance) { color = dev->CCD_color[6 + ((dev->pixelline_opt_res - length*3 + CCD_distance*3) % 2)]; /* color 6,7 */ } else { color = dev->CCD_color[8]; /* color 8 */ } } while(umax_forget_line(dev, color) != 0); /* until found correct line */ umax_order_line_to_pixel(dev, source, color); } /* ------------------------------------------------------------ UMAX GET PIXEL LINE ------------------------ */ static unsigned char * umax_get_pixel_line(Umax_Device *dev) { unsigned char *source = NULL; if (dev->pixelbuffer != NULL) { if ( (dev->pixelline_ready[0] > dev->pixelline_written) && (dev->pixelline_ready[1] > dev->pixelline_written) && (dev->pixelline_ready[2] > dev->pixelline_written) ) { source = dev->pixelbuffer + dev->pixelline_read * dev->width_in_pixels * 3; dev->pixelline_written++; dev->pixelline_read++; if (dev->pixelline_read >= dev->pixelline_max) { dev->pixelline_read = 0; } } } return source; } /* ============================================================ Switches between the SCSI and USB commands = */ /* ------------------------------------------------------------ UMAX SCSI CMD ------------------------------ */ static SANE_Status umax_scsi_cmd(Umax_Device *dev, const void *src, size_t src_size, void *dst, size_t * dst_size) { switch (dev->connection_type) { case SANE_UMAX_SCSI: return sanei_scsi_cmd(dev->sfd, src, src_size, dst, dst_size); break; #ifdef UMAX_ENABLE_USB case SANE_UMAX_USB: return sanei_umaxusb_cmd(dev->sfd, src, src_size, dst, dst_size); break; #endif default: return(SANE_STATUS_INVAL); } } /* ------------------------------------------------------------ UMAX SCSI OPEN EXTENDED -------------------- */ static SANE_Status umax_scsi_open_extended(const char *devicename, Umax_Device *dev, SANEI_SCSI_Sense_Handler handler, void *handler_arg, int *buffersize) { switch (dev->connection_type) { case SANE_UMAX_SCSI: return sanei_scsi_open_extended(devicename, &dev->sfd, handler, handler_arg, buffersize); break; #ifdef UMAX_ENABLE_USB case SANE_UMAX_USB: return sanei_umaxusb_open_extended(devicename, &dev->sfd, handler, handler_arg, buffersize); break; #endif default: return(SANE_STATUS_INVAL); } } /* ------------------------------------------------------------ UMAX SCSI OPEN ----------------------------- */ static SANE_Status umax_scsi_open(const char *devicename, Umax_Device *dev, SANEI_SCSI_Sense_Handler handler, void *handler_arg) { switch (dev->connection_type) { case SANE_UMAX_SCSI: return sanei_scsi_open(devicename, &dev->sfd, handler, handler_arg); break; #ifdef UMAX_ENABLE_USB case SANE_UMAX_USB: return sanei_umaxusb_open(devicename, &dev->sfd, handler, handler_arg); break; #endif default: return(SANE_STATUS_INVAL); } } /* ------------------------------------------------------------ UMAX SCSI CLOSE ---------------------------- */ static void umax_scsi_close(Umax_Device *dev) { switch (dev->connection_type) { case SANE_UMAX_SCSI: sanei_scsi_close(dev->sfd); dev->sfd=-1; break; #ifdef UMAX_ENABLE_USB case SANE_UMAX_USB: sanei_umaxusb_close(dev->sfd); dev->sfd=-1; break; #endif } } /* ------------------------------------------------------------ UMAX SCSI REQ ENTER ------------------------ */ static SANE_Status umax_scsi_req_enter(Umax_Device *dev, const void *src, size_t src_size, void *dst, size_t * dst_size, void **idp) { switch (dev->connection_type) { case SANE_UMAX_SCSI: return sanei_scsi_req_enter (dev->sfd, src, src_size, dst, dst_size, idp); break; #ifdef UMAX_ENABLE_USB case SANE_UMAX_USB: return sanei_umaxusb_req_enter (dev->sfd, src, src_size, dst, dst_size, idp); break; #endif default: return(SANE_STATUS_INVAL); } } /* ------------------------------------------------------------ UMAX SCSI REQ WAIT ------------------------- */ static SANE_Status umax_scsi_req_wait(Umax_Device *dev, void *id) { switch (dev->connection_type) { case SANE_UMAX_SCSI: return sanei_scsi_req_wait(id); break; #ifdef UMAX_ENABLE_USB case SANE_UMAX_USB: return sanei_umaxusb_req_wait(id); break; #endif default: return(SANE_STATUS_INVAL); } } /* ------------------------------------------------------------ UMAX SCSI GET LAMP STATUS ------------------ */ static SANE_Status umax_scsi_get_lamp_status(Umax_Device *dev, int *lamp_on) { SANE_Status status; size_t size = 1; DBG(DBG_proc, "umax_scsi_get_lamp_status\n"); status = umax_scsi_cmd(dev, get_lamp_status.cmd, get_lamp_status.size, dev->buffer[0], &size); if (status) { DBG(DBG_error, "umax_scsi_get_lamp_status: command returned status %s\n", sane_strstatus(status)); return status; } *lamp_on = get_lamp_status_lamp_on(dev->buffer[0]); DBG(DBG_info, "lamp_status = %d\n", *lamp_on); return status; } /* ------------------------------------------------------------ UMAX SCSI SET LAMP STATUS ------------------ */ static SANE_Status umax_scsi_set_lamp_status(Umax_Device *dev, int lamp_on) { SANE_Status status; DBG(DBG_proc, "umax_scsi_set_lamp_status\n"); DBG(DBG_info, "lamp_status=%d\n", lamp_on); set_lamp_status_lamp_on(set_lamp_status.cmd, lamp_on); status = umax_scsi_cmd(dev, set_lamp_status.cmd, set_lamp_status.size, NULL, NULL); if (status) { DBG(DBG_error, "umax_scsi_set_lamp_status: command returned status %s\n", sane_strstatus(status)); } return status; } /* ------------------------------------------------------------ UMAX SET LAMP STATUS ----------------------- */ static SANE_Status umax_set_lamp_status(SANE_Handle handle, int lamp_on) { Umax_Scanner *scanner = handle; int lamp_status; SANE_Status status; DBG(DBG_proc, "umax_set_lamp_status\n"); if (umax_scsi_open(scanner->device->sane.name, scanner->device, sense_handler, scanner->device) != SANE_STATUS_GOOD ) { DBG(DBG_error, "ERROR: umax_set_lamp_status: open of %s failed:\n", scanner->device->sane.name); return SANE_STATUS_INVAL; } status = umax_scsi_get_lamp_status(scanner->device, &lamp_status); if (!status) { status = umax_scsi_set_lamp_status(scanner->device, lamp_on); } umax_scsi_close(scanner->device); return status; } /* ------------------------------------------------------------ UMAX GET DATA BUFFER STATUS ---------------- */ #ifndef UMAX_HIDE_UNUSED /* NOT USED */ static SANE_Status umax_get_data_buffer_status(Umax_Device *dev) { SANE_Status status; DBG(DBG_proc, "get_data_buffer_status\n"); set_GDBS_wait(get_data_buffer_status.cmd,1); /* wait for scanned data */ status = umax_scsi_cmd(dev, get_data_buffer_status.cmd, get_data_buffer_status.size, NULL, NULL); if (status) { DBG(DBG_error, "umax_get_data_buffer_status: command returned status %s\n", sane_strstatus(status)); } return status; } #endif /* ------------------------------------------------------------ UMAX DO REQUEST SENSE ---------------------- */ static void umax_do_request_sense(Umax_Device *dev) { size_t size = rs_return_block_size; SANE_Status status; DBG(DBG_proc, "do_request_sense\n"); set_RS_allocation_length(request_sense.cmd, rs_return_block_size); status = umax_scsi_cmd(dev, request_sense.cmd, request_sense.size, dev->buffer[0], &size); if (status) { DBG(DBG_error, "umax_do_request_sense: command returned status %s\n", sane_strstatus(status)); } } /* ------------------------------------------------------------ UMAX WAIT SCANNER -------------------------- */ static SANE_Status umax_wait_scanner(Umax_Device *dev) { SANE_Status status; int cnt = 0; DBG(DBG_proc, "wait_scanner\n"); do { if (cnt > 100) /* maximal 100 * 0.5 sec = 50 sec */ { DBG(DBG_warning, "scanner does not get ready\n"); return -1; } /* test unit ready */ status = umax_scsi_cmd(dev, test_unit_ready.cmd, test_unit_ready.size, NULL, NULL); cnt++; if (status) { if (cnt == 1) { DBG(DBG_info2, "scanner reports %s, waiting ...\n", sane_strstatus(status)); } usleep(500000); /* wait 0.5 seconds */ } } while (status != SANE_STATUS_GOOD ); DBG(DBG_info, "scanner ready\n"); return status; } #define WAIT_SCANNER { int status = umax_wait_scanner(dev); if (status) return status; } /* ------------------------------------------------------------ UMAX GRAB SCANNER -------------------------- */ static int umax_grab_scanner(Umax_Device *dev) { int status; DBG(DBG_proc, "grab_scanner\n"); WAIT_SCANNER; /* wait for scanner ready */ status = umax_scsi_cmd(dev, reserve_unit.cmd, reserve_unit.size, NULL, NULL); if (status) { DBG(DBG_error, "umax_grab_scanner: command returned status %s\n", sane_strstatus(status)); } else { DBG(DBG_info, "scanner reserved\n"); } return status; } /* ------------------------------------------------------------ UMAX REPOSITION SCANNER -------------------- */ static int umax_reposition_scanner(Umax_Device *dev) { int status; int pause; pause = dev->pause_after_reposition + dev->pause_for_moving * (dev->upper_left_y + dev->scanlength) / ( (dev->inquiry_fb_length * dev->y_coordinate_base) ); DBG(DBG_info2, "trying to reposition scanner ...\n"); status = umax_scsi_cmd(dev, object_position.cmd, object_position.size, NULL, NULL); if (status) { DBG(DBG_error, "umax_reposition_scanner: command returned status %s\n", sane_strstatus(status)); return status; } if (pause > 0) /* predefined time to wait (Astra 2400S) */ { DBG(DBG_info2, "pause for repositioning %d msec ...\n", pause); usleep(((long) pause) * 1000); DBG(DBG_info, "repositioning pause done\n"); } else if (pause == 0) /* use TEST UNIT READY */ { WAIT_SCANNER; DBG(DBG_info, "scanner repositioned\n"); } else /* pause < 0 : return without any pause */ { DBG(DBG_info, "not waiting for finishing reposition scanner\n"); } return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ UMAX GIVE SCANNER -------------------------- */ static int umax_give_scanner(Umax_Device *dev) { int status; DBG(DBG_info2, "trying to release scanner ...\n"); status = umax_scsi_cmd(dev, release_unit.cmd, release_unit.size, NULL, NULL); if (status) { DBG(DBG_error, "umax_give_scanner: command returned status %s\n", sane_strstatus(status)); } else { DBG(DBG_info, "scanner released\n"); } if (!dev->batch_scan || dev->batch_end) { umax_reposition_scanner(dev); } else { usleep(200000); /* 200 ms pause to make sure program does not exit before scanner is ready */ } return status; } /* ------------------------------------------------------------ UMAX SEND GAMMA DATA ----------------------- */ static void umax_send_gamma_data(Umax_Device *dev, void *gamma_data, int color) { unsigned char *data = gamma_data; unsigned char *dest; int length; SANE_Status status; DBG(DBG_proc, "send_gamma_data\n"); if (dev->inquiry_gamma_dwload == 0) { DBG(DBG_error, "ERROR: gamma download not available\n"); return; } memcpy(dev->buffer[0], send.cmd, send.size); /* send */ set_S_datatype_code(dev->buffer[0], S_datatype_gamma); /* gamma curve */ dest = dev->buffer[0] + send.size; if (dev->inquiry_gamma_DCF == 0) /* gamma format type 0 */ { DBG(DBG_info, "using gamma download curve format type 0\n"); memcpy(dest, gamma_DCF0.cmd, gamma_DCF0.size); if (color == 1) /* one color */ { set_DCF0_gamma_lines(dest, DCF0_gamma_one_line); set_DCF0_gamma_color(dest, 0, DCF0_gamma_color_gray); /* grayscale */ if ( (dev->colormode == RGB) && (dev->three_pass != 0) ) /* 3 pass color */ { set_DCF0_gamma_color(dest, 0, dev->three_pass_color); /* set color */ } dest = dest + 2; memcpy(dest, data, 1024); /* copy data */ set_S_xfer_length(dev->buffer[0], 1026); /* set length */ status = umax_scsi_cmd(dev, dev->buffer[0], send.size + 1026, NULL, NULL); if (status) { DBG(DBG_error, "umax_send_gamma_data(DCF=0, one color): command returned status %s\n", sane_strstatus(status)); } } else /* three colors */ { set_DCF0_gamma_lines(dest, DCF0_gamma_three_lines); set_DCF0_gamma_color(dest, 0, DCF0_gamma_color_red); /* red */ set_DCF0_gamma_color(dest, 1, DCF0_gamma_color_green); /* green */ set_DCF0_gamma_color(dest, 2, DCF0_gamma_color_blue); /* blue */ dest = dest + 2; memcpy(dest, data, 1024); /* copy red data */ dest = dest + 1025; data = data + 1024; memcpy(dest, data, 1024); /* copy green data */ dest = dest + 1025; data = data + 1024; memcpy(dest, data, 1024); /* copy blue data */ set_S_xfer_length(dev->buffer[0], 3076); /* set length */ status = umax_scsi_cmd(dev, dev->buffer[0], send.size + 3076, NULL, NULL); if (status) { DBG(DBG_error, "umax_send_gamma_data(DCF=0, RGB): command returned status %s\n", sane_strstatus(status)); } } } else if (dev->inquiry_gamma_DCF == 1) /* gamma format type 1 */ { DBG(DBG_info, "using gamma download curve format type 1\n"); memcpy(dest, gamma_DCF1.cmd, gamma_DCF1.size); set_DCF1_gamma_color(dest, DCF1_gamma_color_gray); /* grayscale */ if ( (dev->colormode == RGB) && (dev->three_pass != 0) ) /* 3 pass color */ { set_DCF1_gamma_color(dest, dev->three_pass_color); /* set color */ } dest = dest + 2; memcpy(dest, data, 256); /* copy data */ set_S_xfer_length(dev->buffer[0], 258); /* set length */ status = umax_scsi_cmd(dev, dev->buffer[0], send.size + 258, NULL, NULL); if (status) { DBG(DBG_error, "umax_send_gamma_data(DCF=1): command returned status %s\n", sane_strstatus(status)); } } else if (dev->inquiry_gamma_DCF == 2) /* gamma format type 2 */ { DBG(DBG_info, "using gamma download curve format type 2\n"); memcpy(dest, gamma_DCF2.cmd, gamma_DCF2.size); set_DCF2_gamma_color(dest, DCF2_gamma_color_gray); /* grayscale */ if ( (dev->colormode == RGB) && (dev->three_pass != 0) ) /* 3 pass color */ { set_DCF2_gamma_color(dest, dev->three_pass_color); } /* set color */ if (color == 1) { set_DCF2_gamma_lines(dest, DCF2_gamma_one_line); } else { set_DCF2_gamma_lines(dest, DCF2_gamma_three_lines); } set_DCF2_gamma_input_bits(dest, dev->gamma_input_bits_code); set_DCF2_gamma_output_bits(dest, dev->bits_per_pixel_code); dest = dev->buffer[0] + send.size + gamma_DCF2.size; /* write to dest */ if (dev->gamma_input_bits_code & 32) { length = 65536; /* 16 input bits */ } else if (dev->gamma_input_bits_code & 16) { length = 16384; /* 14 input bits */ } else if (dev->gamma_input_bits_code & 8) { length = 4096; /* 12 input bits */ } else if (dev->gamma_input_bits_code & 4) { length = 1024; /* 10 input bits */ } else if (dev->gamma_input_bits_code & 2) { length = 512; /* 9 input bits */ } else { length = 256; /* 8 input bits */ } if (dev->bits_per_pixel_code != 1) /* more than 8 output bits per pixel */ { length = length * 2; /* = 2 output bytes */ } if (dev->bufsize >= color*length+gamma_DCF2.size) { set_S_xfer_length(dev->buffer[0], color*length+gamma_DCF2.size); /* set length */ memcpy(dest, data, color*length); /* copy data */ status = umax_scsi_cmd(dev, dev->buffer[0], send.size+gamma_DCF2.size + length * color, NULL, NULL); if (status) { DBG(DBG_error, "umax_send_gamma_data(DCF=2): command returned status %s\n", sane_strstatus(status)); } } else { DBG(DBG_error, "ERROR: too small scsi buffer (%d bytes) to send gamma data\n", dev->bufsize); } } else { DBG(DBG_error, "ERROR: unknown gamma download curve type for this scanner\n"); } } /* ------------------------------------------------------------ UMAX SEND DATA ---------------------------- */ static void umax_send_data(Umax_Device *dev, void *data, int size, int datatype) { unsigned char *dest; SANE_Status status; memcpy(dev->buffer[0], send.cmd, send.size); /* send */ set_S_datatype_code(dev->buffer[0], datatype); /* set datatype */ set_S_xfer_length(dev->buffer[0], size); /* bytes */ dest=dev->buffer[0] + send.size; memcpy(dest, data, size); /* copy data */ status = umax_scsi_cmd(dev, dev->buffer[0], send.size + size, NULL, NULL); if (status) { DBG(DBG_error, "umax_send_data: command returned status %s\n", sane_strstatus(status)); } } /* ------------------------------------------------------------ UMAX SEND HALFTONE PATTERN ----------------- */ #ifndef UMAX_HIDE_UNUSED static void umax_send_halftone_pattern(Umax_Device *dev, void *data, int size) { DBG(DBG_proc,"send_halftone_pattern\n"); umax_send_data(dev, data, size*size, S_datatype_halftone); } #endif /* ------------------------------------------------------------ UMAX SEND SHADING DATA -------------------- */ static void umax_send_shading_data(Umax_Device *dev, void *data, int size) { DBG(DBG_proc,"send_shading_data\n"); umax_send_data(dev, data, size, S_datatype_shading); } /* ------------------------------------------------------------ UMAX SEND GAIN DATA ----------------------- */ #ifndef UMAX_HIDE_UNUSED static void umax_send_gain_data(Umax_Device *dev, void *data, int size) { DBG(DBG_proc,"send_gain_data\n"); umax_send_data(dev, data, size, S_datatype_gain); } #endif /* ------------------------------------------------------------ UMAX QUEUE READ IMAGE DATA REQ ------------- */ static SANE_Status umax_queue_read_image_data_req(Umax_Device *dev, unsigned int length, int bufnr) { SANE_Status status; DBG(DBG_proc, "umax_queue_read_image_data_req for buffer[%d], length = %d\n", bufnr, length); set_R_xfer_length(sread.cmd, length); /* set length */ set_R_datatype_code(sread.cmd, R_datatype_imagedata); /* set datatype */ dev->length_queued[bufnr] = length; /* set length request */ dev->length_read[bufnr] = length; /* set length request, can be changed asyncronous by umax_scsi_req_enter */ status = umax_scsi_req_enter(dev, sread.cmd, sread.size, dev->buffer[bufnr], &(dev->length_read[bufnr]), &(dev->queue_id[bufnr])); if (status) { DBG(DBG_error, "umax_queue_read_image_data_req: command returned status %s\n", sane_strstatus(status)); return -1; } else { DBG(DBG_info2, "umax_queue_read_image_data_req: id for buffer[%d] is %p\n", bufnr, dev->queue_id[bufnr]); } return length; } /* ------------------------------------------------------------ UMAX WAIT QUEUED IMAGE DATA ---------------- */ static int umax_wait_queued_image_data(Umax_Device *dev, int bufnr) { SANE_Status status; DBG(DBG_proc, "umax_wait_queued_image_data for buffer[%d] (id=%p)\n", bufnr, dev->queue_id[bufnr]); status = umax_scsi_req_wait(dev, dev->queue_id[bufnr]); if (status) { DBG(DBG_error, "umax_wait_queued_image_data: wait returned status %s\n", sane_strstatus(status)); return -1; } return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ UMAX READ DATA ----------------------------- */ static int umax_read_data(Umax_Device *dev, size_t length, int datatype) { SANE_Status status; set_R_xfer_length(sread.cmd, length); /* set length */ set_R_datatype_code(sread.cmd, datatype); /* set datatype */ status = umax_scsi_cmd(dev, sread.cmd, sread.size, dev->buffer[0], &length); if (status) { DBG(DBG_error, "umax_read_data: command returned status %s\n", sane_strstatus(status)); return -1; } return length; } /* ------------------------------------------------------------ UMAX READ SHADING DATA -------------------- */ static int umax_read_shading_data(Umax_Device *dev, unsigned int length) { DBG(DBG_proc,"read_shading_data\n"); return umax_read_data(dev, length, R_datatype_shading); } /* ------------------------------------------------------------ UMAX READ GAIN DATA ----------------------- */ #ifndef UMAX_HIDE_UNUSED static int umax_read_gain_data(Umax_Device *dev, unsigned int length) { DBG(DBG_proc,"read_gain_data\n"); return umax_read_data(dev, length, R_datatype_gain); } #endif /* ------------------------------------------------------------ UMAX READ IMAGE DATA ---------------------- */ #ifndef UMAX_HIDE_UNUSED static int umax_read_image_data(Umax_Device *dev, unsigned int length) { DBG(DBG_proc,"read_image_data\n"); WAIT_SCANNER; return umax_read_data(dev, length, R_datatype_imagedata); } #endif /* ------------------------------------------------------------ UMAX CORRECT LIGHT ------------------------- */ static int umax_correct_light(int light, int analog_gamma_byte) /* correct highlight/shadow if analog gamma is set */ { double analog_gamma; analog_gamma=analog_gamma_table[analog_gamma_byte]; return( (int) 255 * pow( ((double) light)/255.0 , (1.0/analog_gamma) )+.5 ); } /* ------------------------------------------------------------ UMAX SET WINDOW PARAM ---------------------- */ /* set_window_param sets all the window parameters. This means building a */ /* fairly complicated SCSI command before sending it... */ static SANE_Status umax_set_window_param(Umax_Device *dev) { SANE_Status status; int num_dblocks = 1; /* number of window descriptor blocks, usually 1 or 3 */ unsigned char buffer_r[max_WDB_size], buffer_g[max_WDB_size], buffer_b[max_WDB_size]; DBG(DBG_proc, "set_window_param\n"); memset(buffer_r, '\0', max_WDB_size); /* clear buffer */ set_WDB_length(dev->wdb_len); /* length of win descriptor block */ memcpy(buffer_r, window_descriptor_block.cmd, window_descriptor_block.size); /* copy preset data */ set_WD_wid(buffer_r, 0); /* window identifier */ set_WD_auto(buffer_r, dev->set_auto); /* 0 or 1: don't know what it is */ /* geometry */ set_WD_Xres(buffer_r, dev->x_resolution); /* x resolution in dpi */ set_WD_Yres(buffer_r, dev->y_resolution); /* y resolution in dpi */ set_WD_ULX(buffer_r, dev->upper_left_x); /* left_edge x */ set_WD_ULY(buffer_r, dev->upper_left_y); /* upper_edge y */ set_WD_width(buffer_r, dev->scanwidth); /* width */ set_WD_length(buffer_r, dev->scanlength); /* length */ /* BTC */ set_WD_brightness(buffer_r, dev->brightness); /* brightness, only halftone */ set_WD_threshold(buffer_r, dev->threshold); /* threshold, only lineart */ set_WD_contrast(buffer_r, dev->contrast); /* contrast, only halftone */ /* scanmode, preset to LINEART */ set_WD_composition(buffer_r, WD_comp_lineart); /* image composition */ /* = (scan-mode) */ set_WD_bitsperpixel(buffer_r, WD_bits_1); /* bits/pixel (1,8,9,10,12,14,16) */ set_WD_halftone(buffer_r, dev->halftone); /* select halftone-pattern */ set_WD_RIF(buffer_r, dev->reverse); /* reverse, invert black and white */ set_WD_speed(buffer_r, dev->WD_speed); /* set speed */ set_WD_select_color(buffer_r, WD_color_gray); /* color for window-block */ /* set highlight and shadow in dependence of analog gamma */ set_WD_highlight(buffer_r, umax_correct_light(dev->highlight_r, dev->analog_gamma_r)); set_WD_shadow(buffer_r, umax_correct_light(dev->shadow_r, dev->analog_gamma_r)); /* scan options */ set_WD_gamma(buffer_r, dev->digital_gamma_r); /* set digital gamma */ set_WD_module(buffer_r, dev->module); /* flatbed or transparency */ set_WD_CBHS(buffer_r, dev->cbhs_range); /* 50 or 255 */ set_WD_FF(buffer_r, dev->fix_focus_position); /* fix focus position */ set_WD_RMIF(buffer_r, dev->reverse_multi); /* reverse color-values */ set_WD_FDC(buffer_r, dev->lens_cal_in_doc_pos); /* lens calibration in document position */ set_WD_PF(buffer_r, dev->disable_pre_focus); /* disable pre focus */ set_WD_LCL(buffer_r, dev->holder_focus_pos_0mm); /* 0.6mm <-> 0.0mm holder focus position */ set_WD_HBT(buffer_r, dev->low_byte_first); /* set byte order for 16 bit scanners */ set_WD_DOR(buffer_r, dev->dor); /* double-resolution-mode */ set_WD_scan_exposure_level(buffer_r, dev->exposure_time_scan_r); /* scan exposure time */ set_WD_calibration_exposure_level(buffer_r, dev->exposure_time_calibration_r);/* calibration exposure time */ set_WD_batch(buffer_r, dev->batch_scan); /* batch or normal scan */ set_WD_MF(buffer_r, dev->manual_focus); /* automatic <-> manual focus */ set_WD_line_arrangement(buffer_r, WD_line_arrengement_by_fw); /* line arrangement by scanner */ set_WD_warmup(buffer_r, dev->warmup); /* warmup */ set_WD_calibration(buffer_r, dev->calibration); /* image calibration */ set_WD_color_sequence(buffer_r, WD_color_sequence_RGB); /* sequence RGB */ set_WD_color_ordering(buffer_r, WD_color_ordering_pixel); /* set to pixel for pbm, pgm, pnm-file */ set_WD_analog_gamma(buffer_r, dev->analog_gamma_r ); /* analog gamma */ set_WD_lamp_c_density(buffer_r, dev->c_density); /* calibrat. lamp density */ set_WD_lamp_s_density(buffer_r, dev->s_density); /* scan lamp density */ set_WD_next_upper_left(buffer_r, dev->batch_next_tl_y); /* batch scan next top left y position */ set_WD_pixel_count(buffer_r, dev->width_in_pixels); /* pixel count */ set_WD_line_count(buffer_r, dev->length_in_pixels); /* line count */ set_WD_x_coordinate_base(buffer_r, dev->x_coordinate_base); /* dpi (1200) */ set_WD_y_coordinate_base(buffer_r, dev->y_coordinate_base); /* dpi (1200) */ set_WD_calibration_data_lines(buffer_r, dev->calib_lines); /* required lines for calibration by driver */ switch(dev->colormode) { case LINEART: /* LINEART */ set_WD_composition(buffer_r, WD_comp_lineart); set_WD_bitsperpixel(buffer_r, WD_bits_1); set_WD_select_color(buffer_r, WD_color_gray); break; case HALFTONE: /* HALFTONE */ set_WD_composition(buffer_r, WD_comp_dithered); set_WD_bitsperpixel(buffer_r, WD_bits_1); set_WD_select_color(buffer_r, WD_color_gray); break; case GRAYSCALE: /* GRAYSCALE */ set_WD_composition(buffer_r, WD_comp_gray); set_WD_bitsperpixel(buffer_r, dev->bits_per_pixel); set_WD_select_color(buffer_r, WD_color_gray); break; case RGB_LINEART: /* COLOR MODES */ case RGB_HALFTONE: case RGB: if (dev->colormode == RGB_LINEART ) { set_WD_composition(buffer_r, WD_comp_rgb_bilevel); set_WD_bitsperpixel(buffer_r, WD_bits_1); } else if (dev->colormode == RGB_HALFTONE ) { set_WD_composition(buffer_r, WD_comp_rgb_dithered); set_WD_bitsperpixel(buffer_r, WD_bits_1); } else /* RGB */ { set_WD_composition(buffer_r, WD_comp_rgb_full); set_WD_bitsperpixel(buffer_r, dev->bits_per_pixel); } if (dev->three_pass == 0) { /* singlepass */ num_dblocks = 3; if (dev->do_color_ordering != 0) { set_WD_line_arrangement(buffer_r, WD_line_arrengement_by_driver); if (dev->CCD_distance == 0) { set_WD_color_ordering(buffer_r, WD_color_ordering_line_no_ccd); } else { set_WD_color_ordering(buffer_r, WD_color_ordering_line_w_ccd); } } memcpy(buffer_g, buffer_r, max_WDB_size); /* copy WDB for green */ memcpy(buffer_b, buffer_r, max_WDB_size); /* copy WDB for blue */ set_WD_wid(buffer_r, WD_wid_red); /* window identifier red */ set_WD_wid(buffer_g, WD_wid_green); /* window identifier green */ set_WD_wid(buffer_b, WD_wid_blue); /* window identifier blue */ set_WD_select_color(buffer_r, WD_color_red); /* select red for this window */ set_WD_select_color(buffer_g, WD_color_green); /* select green for this window */ set_WD_select_color(buffer_b, WD_color_blue); /* select blue for this window */ set_WD_gamma(buffer_r, dev->digital_gamma_r); /* digital gamma */ set_WD_gamma(buffer_g, dev->digital_gamma_g); set_WD_gamma(buffer_b, dev->digital_gamma_b); set_WD_analog_gamma(buffer_r, dev->analog_gamma_r); /* analog gamma */ set_WD_analog_gamma(buffer_g, dev->analog_gamma_g); set_WD_analog_gamma(buffer_b, dev->analog_gamma_b); /* set highlight in dependence of analog gamma */ set_WD_highlight(buffer_r, umax_correct_light(dev->highlight_r, dev->analog_gamma_r)); set_WD_highlight(buffer_g, umax_correct_light(dev->highlight_g, dev->analog_gamma_g)); set_WD_highlight(buffer_b, umax_correct_light(dev->highlight_b, dev->analog_gamma_b)); /* set shadow in dependence of analog gamma */ set_WD_shadow(buffer_r, umax_correct_light(dev->shadow_r, dev->analog_gamma_r)); set_WD_shadow(buffer_g, umax_correct_light(dev->shadow_g, dev->analog_gamma_g)); set_WD_shadow(buffer_b, umax_correct_light(dev->shadow_b, dev->analog_gamma_b)); set_WD_scan_exposure_level(buffer_r, dev->exposure_time_scan_r); /* set scan exposure times */ set_WD_scan_exposure_level(buffer_g, dev->exposure_time_scan_g); set_WD_scan_exposure_level(buffer_b, dev->exposure_time_scan_b); set_WD_calibration_exposure_level(buffer_r, dev->exposure_time_calibration_r);/* set calib exp times */ set_WD_calibration_exposure_level(buffer_g, dev->exposure_time_calibration_g); set_WD_calibration_exposure_level(buffer_b, dev->exposure_time_calibration_b); } else { /* threepass */ set_WD_wid(buffer_r, 0); /* window identifier */ set_WD_color_ordering(buffer_r, WD_color_ordering_plane); /* ???? */ if (dev->colormode == RGB_LINEART ) { set_WD_composition(buffer_r, WD_comp_lineart); /* color-lineart-mode */ } else if (dev->colormode == RGB_HALFTONE ) { set_WD_composition(buffer_r, WD_comp_dithered); /* color-halftone-mode */ } else /* RGB */ { set_WD_composition(buffer_r, WD_comp_gray); /* color-mode */ } switch (dev->three_pass_color) { case WD_wid_red: set_WD_select_color(buffer_r, WD_color_red); /* color red */ set_WD_gamma(buffer_r, dev->digital_gamma_r); set_WD_analog_gamma(buffer_r, dev->analog_gamma_r); set_WD_highlight(buffer_r, umax_correct_light(dev->highlight_r, dev->analog_gamma_r)); set_WD_shadow(buffer_r, umax_correct_light(dev->shadow_r, dev->analog_gamma_r)); set_WD_scan_exposure_level(buffer_r, dev->exposure_time_scan_r); set_WD_calibration_exposure_level(buffer_r, dev->exposure_time_calibration_r); break; case WD_wid_green: set_WD_select_color(buffer_r, WD_color_green); /* color green */ set_WD_gamma(buffer_r, dev->digital_gamma_g); set_WD_analog_gamma(buffer_r, dev->analog_gamma_g); set_WD_highlight(buffer_r, umax_correct_light(dev->highlight_g, dev->analog_gamma_g)); set_WD_shadow(buffer_r, umax_correct_light(dev->shadow_g, dev->analog_gamma_g)); set_WD_scan_exposure_level(buffer_r, dev->exposure_time_scan_g); set_WD_calibration_exposure_level(buffer_r, dev->exposure_time_calibration_g); break; case WD_wid_blue: set_WD_select_color(buffer_r, WD_color_blue); /* color blue */ set_WD_gamma(buffer_r, dev->digital_gamma_b); set_WD_analog_gamma(buffer_r, dev->analog_gamma_b); set_WD_highlight(buffer_r, umax_correct_light(dev->highlight_b, dev->analog_gamma_b)); set_WD_shadow(buffer_r, umax_correct_light(dev->shadow_b, dev->analog_gamma_b)); set_WD_scan_exposure_level(buffer_r, dev->exposure_time_scan_b); set_WD_calibration_exposure_level(buffer_r, dev->exposure_time_calibration_b); break; } /* switch dev->three_pass_color */ } /* if (single_pass) else (three_pass) */ break; } /* switch dev->colormode, case RGB */ /* prepare SCSI-BUFFER */ memcpy(dev->buffer[0], set_window.cmd, set_window.size); /* SET-WINDOW cmd */ memcpy(WPDB_OFF(dev->buffer[0]), window_parameter_data_block.cmd, window_parameter_data_block.size); /* WPDB */ set_WPDB_wdbnum(WPDB_OFF(dev->buffer[0]), num_dblocks); /* set WD_len */ memcpy(WDB_OFF(dev->buffer[0],1), buffer_r, window_descriptor_block.size); /* add WD_block */ if ( num_dblocks == 3) /* if singelpass RGB */ { memcpy(WDB_OFF(dev->buffer[0],2), buffer_g, window_descriptor_block.size); /* add green */ memcpy(WDB_OFF(dev->buffer[0],3), buffer_b, window_descriptor_block.size); /* add blue */ } DBG(DBG_info2, "window descriptor block created with %d bytes\n", dev->wdb_len); set_SW_xferlen(dev->buffer[0], (window_parameter_data_block.size + (window_descriptor_block.size * num_dblocks))); status = umax_scsi_cmd(dev, dev->buffer[0], set_window.size + window_parameter_data_block.size + (window_descriptor_block.size * num_dblocks), NULL, NULL); if (status) { DBG(DBG_error, "umax_set_window_param: command returned status %s\n", sane_strstatus(status)); } else { DBG(DBG_info, "window(s) set\n"); } return status; } /* ------------------------------------------------------------ UMAX DO INQUIRY ---------------------------- */ static void umax_do_inquiry(Umax_Device *dev) { size_t size; SANE_Status status; DBG(DBG_proc,"do_inquiry\n"); memset(dev->buffer[0], '\0', 256); /* clear buffer */ size = 5; set_inquiry_return_size(inquiry.cmd, size); /* first get only 5 bytes to get size of inquiry_return_block */ status = umax_scsi_cmd(dev, inquiry.cmd, inquiry.size, dev->buffer[0], &size); if (status) { DBG(DBG_error, "umax_do_inquiry: command returned status %s\n", sane_strstatus(status)); } size = get_inquiry_additional_length(dev->buffer[0]) + 5; set_inquiry_return_size(inquiry.cmd, size); /* then get inquiry with actual size */ status = umax_scsi_cmd(dev, inquiry.cmd, inquiry.size, dev->buffer[0], &size); if (status) { DBG(DBG_error, "umax_do_inquiry: command returned status %s\n", sane_strstatus(status)); } } /* ------------------------------------------------------------ UMAX START SCAN ---------------------------- */ static SANE_Status umax_start_scan(Umax_Device *dev) { int size = 1; SANE_Status status; DBG(DBG_proc,"start_scan\n"); if (dev->adf) /* ADF selected: test for ADF errors */ { umax_do_inquiry(dev); /* get inquiry */ if (get_inquiry_ADF_paper_jam(dev->buffer[0])) /* test for ADF paper jam */ { DBG(DBG_error,"ERROR: umax_start_scan: ADF paper jam\n"); return SANE_STATUS_JAMMED; } else if (get_inquiry_ADF_cover_open(dev->buffer[0])) /* test for ADF cover open */ { DBG(DBG_error,"ERROR: umax_start_scan: ADF cover open\n"); return SANE_STATUS_COVER_OPEN; } else if (get_inquiry_ADF_no_paper(dev->buffer[0])) /* test for ADF no paper */ { DBG(DBG_error,"ERROR: umax_start_scan: ADF no paper\n"); return SANE_STATUS_NO_DOCS; } } set_SC_quality(scan.cmd, dev->quality); /* 1=qual, 0=fast */ set_SC_adf( scan.cmd, dev->adf); /* ADF, 0=off, 1=use */ set_SC_preview(scan.cmd, dev->preview); /* 1=preview */ set_SC_wid(scan.cmd, 1, 0); /* Window-Identifier */ set_SC_xfer_length(scan.cmd, size); /* following Bytes */ DBG(DBG_info,"starting scan\n"); status = umax_scsi_cmd(dev, scan.cmd, scan.size + size, NULL, NULL); if (status) { DBG(DBG_error, "umax_start_scan: command returned status %s\n", sane_strstatus(status)); } return status; } /* ------------------------------------------------------------ UMAX DO CALIBRATION ------------------------ */ static SANE_Status umax_do_calibration(Umax_Device *dev) { SANE_Status status; unsigned int width = 0; unsigned int lines = 0; unsigned int bytespp = 0; DBG(DBG_proc,"do_calibration\n"); status = umax_wait_scanner(dev); if ((status == SANE_STATUS_GOOD) && (dev->do_calibration != 0)) /* calibration by driver */ { unsigned char *shading_data = 0; unsigned int i, j; long *average; DBG(DBG_info,"driver is doing calibration\n"); if (umax_execute_request_sense) { DBG(DBG_info,"request sense call is enabled\n"); memset(dev->buffer[0], 0, rs_return_block_size); /* clear sense data buffer */ umax_do_request_sense(dev); /* new request-sense call to get all data */ } else { DBG(DBG_info,"request sense call is disabled\n"); } if (get_RS_SCC_condition_code(dev->buffer[0]) != 1) { DBG(DBG_warning,"WARNING: missing information about shading-data\n"); DBG(DBG_warning," driver tries to guess missing values!\n"); if ((dev->calibration_area != UMAX_CALIBRATION_AREA_CCD) && (!dev->batch_scan)) /* calibration is done with image geometry and depth */ { DBG(DBG_warning," Calibration is done with selected image geometry and depth!\n"); width = dev->scanwidth * dev->relevant_optical_res / dev->x_coordinate_base; if (dev->calibration_width_offset > -99999) /* driver or user (umax.conf) define an offset */ { width = width + dev->calibration_width_offset; DBG(DBG_warning," Using calibration width offset of %d\n", dev->calibration_width_offset); } if (dev->colormode == RGB) { width = width * 3; } lines = dev->calib_lines; if (dev->gamma_input_bits_code <= 1) { bytespp = 1; /* 8 bit mode */ } else { bytespp = 2; /* 16 bit mode */ } } else /* calibration is done with full scanarea and full depth */ { DBG(DBG_warning," Calibration is done for each CCD pixel with full depth!\n"); width = (int)(dev->inquiry_fb_width * dev->inquiry_optical_res); if (dev->batch_scan) { if (dev->calibration_width_offset_batch > -99999) /* driver or user (umax.conf) define an offset for batch scanning */ { width = width + dev->calibration_width_offset_batch; DBG(DBG_warning," Using calibration width offset for batch scanning of %d\n", dev->calibration_width_offset_batch); } } else /* normal scan */ { if (dev->calibration_width_offset > -99999) /* driver or user (umax.conf) define an offset */ { width = width + dev->calibration_width_offset; DBG(DBG_warning," Using calibration width offset of %d\n", dev->calibration_width_offset); } } if (dev->colormode == RGB) { width = width * 3; } lines = dev->calib_lines; if (dev->gamma_input_bits_code <= 1) { bytespp = 1; /* 8 bit mode */ } else { bytespp = 2; /* 16 bit mode */ } } } else { lines = get_RS_SCC_calibration_lines(dev->buffer[0]); bytespp = get_RS_SCC_calibration_bytespp(dev->buffer[0]); width = get_RS_SCC_calibration_bytesperline(dev->buffer[0]) / bytespp; } if (dev->calibration_bytespp > 0) /* correct bytespp if necessary and driver knows about it or user did select it */ { bytespp = dev->calibration_bytespp; } DBG(DBG_info,"scanner sends %d lines with %d pixels and %d bytes/pixel\n", lines, width, bytespp); if (width * bytespp > dev->bufsize) { DBG(DBG_error,"ERROR: scsi buffer is to small for one shading line, calibration aborted\n"); DBG(DBG_error,"=> change umax.conf options scsi-buffer-size-min and scsi-buffer-size-max\n"); return SANE_STATUS_NO_MEM; } /* UMAX S12 sends a kind of uncalibrated image data, bright -> 255, dark -> 0 */ /* (although 0 is not black) my scanner sends values around 220 */ /* for some scanners the data is simply sent back, other scanners want 255-value as awnswer */ average = calloc(width, sizeof(long)); if (average == 0) { DBG(DBG_error,"ERROR: could not allocate memory for averaging shading data: calibration aborted\n"); return SANE_STATUS_NO_MEM; } shading_data = calloc(width, bytespp); if (shading_data == 0) { DBG(DBG_error,"ERROR: could not allocate memory for shading data: calibration aborted\n"); return SANE_STATUS_NO_MEM; } if (bytespp == 1) /* 1 byte per pixel */ { DBG(DBG_info,"calculating average value for 8 bit shading data!\n"); for (i=0; ibuffer[0][j]; } DBG(DBG_read,"8 bit shading-line %d read\n", i+1); } for (j=0; jlow_byte_first) /* 2 bytes per pixel with low byte first */ { DBG(DBG_info,"calculating average value for 16 bit shading data (low byte first)!\n"); for (i=0; ibuffer[0][2*j+1] + dev->buffer[0][2*j] ; } DBG(DBG_read,"16 bit shading-line %d read\n", i+1); } for (j=0; jbuffer[0][2*j] + dev->buffer[0][2*j + 1] ; } DBG(DBG_read,"16 bit shading-line %d read\n", i+1); } for (j=0; jinvert_shading_data) ) /* invert data */ { if (bytespp == 1) { DBG(DBG_info,"inverting 8 bit shading data\n"); for (j=0; jdo_calibration = 0; } return status; } /* ------------------------------------------------------------ UMAX DO NEW INQUIRY ------------------------ */ static void umax_do_new_inquiry(Umax_Device *dev, size_t size) /* call inquiry again if wrong length */ { SANE_Status status; DBG(DBG_proc,"do_new_inquiry\n"); memset(dev->buffer[0], '\0', 256); /* clear buffer */ set_inquiry_return_size(inquiry.cmd, size); status = umax_scsi_cmd(dev, inquiry.cmd, inquiry.size, dev->buffer[0], &size); if (status) { DBG(DBG_error, "umax_do_new_inquiry: command returned status %s\n", sane_strstatus(status)); } } /* ------------------------------------------------------------ UMAX CORRECT INQUIRY ----------------------- */ static void umax_correct_inquiry(Umax_Device *dev, char *vendor, char *product, char *version) { DBG(DBG_info, "umax_correct_inquiry(\"%s %s %s\")\n", vendor, product, version); if (!strncmp(vendor, "UMAX ", 5)) { if (!strncmp(product, "Astra 600S ", 11)) { int add_len = get_inquiry_additional_length(dev->buffer[0]); DBG(DBG_warning,"setting up special options for %s\n", product); if (add_len == 0x8f) { DBG(DBG_warning," - correcting wrong inquiry data\n"); umax_do_new_inquiry(dev, 0x9b); /* get inquiry with correct length */ set_inquiry_length(dev->buffer[0], 0x9e); /* correct inquiry len */ /* correct color-ordering from pixel to line_with_ccd_distance */ set_inquiry_color_order(dev->buffer[0], IN_color_ordering_line_w_ccd); set_inquiry_fb_uta_line_arrangement_mode(dev->buffer[0], 32); set_inquiry_CCD_line_distance(dev->buffer[0], 8); /* we should reset ADF-bit here too */ if (dev->invert_shading_data == -1) /* nothing defined in umax.conf */ { DBG(DBG_warning," - activating inversion of shading data\n"); dev->invert_shading_data = 1; } } } else if (!strncmp(product, "Astra 610S ", 11)) { int add_len = get_inquiry_additional_length(dev->buffer[0]); DBG(DBG_warning,"setting up special options for %s\n", product); if (add_len == 0x8f) { DBG(DBG_warning," - correcting wrong inquiry data\n"); umax_do_new_inquiry(dev, 0x9b); /* get inquiry with correct length */ set_inquiry_length(dev->buffer[0], 0x9e); /* correct inquiry len */ /* correct color-ordering from pixel to line_with_ccd_distance */ set_inquiry_color_order(dev->buffer[0], IN_color_ordering_line_w_ccd); set_inquiry_fb_uta_line_arrangement_mode(dev->buffer[0], 33); set_inquiry_CCD_line_distance(dev->buffer[0], 8); if (dev->invert_shading_data == -1) /* nothing defined in umax.conf */ { DBG(DBG_warning," - activating inversion of shading data\n"); dev->invert_shading_data = 1; } } } else if ( (!strncmp(product, "Astra 1200S ", 12)) || (!strncmp(product, "Perfection600 ", 14)) ) { DBG(DBG_warning,"using standard options for %s\n", product); } else if (!strncmp(product, "Astra 1220S ", 12)) { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->gamma_lsb_padded == -1) /* nothing defined in umax.conf and not by backend */ { DBG(DBG_warning," - 16 bit gamma table is created lsb padded\n"); dev->gamma_lsb_padded = 1; } if (!strncmp(version, "V1.5 ", 4)) { DBG(DBG_warning," - lamp control enabled for version %s\n", version); dev->lamp_control_available = 1; } } else if (!strncmp(product, "Astra 2100S ", 12)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - lamp control enabled\n"); dev->lamp_control_available = 1; if (dev->calibration_bytespp == -1) /* no calibration-bytespp defined in umax.conf */ { DBG(DBG_warning," - setting calibration_bytespp = 1\n"); dev->calibration_bytespp = 1; /* scanner says 2 bytespp for calibration but 1 bytepp is correct */ } } else if (!strncmp(product, "Astra 2200 ", 11)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - lamp control enabled\n"); dev->lamp_control_available = 1; if (dev->calibration_area == -1) /* no calibration area defined in umax.conf */ { DBG(DBG_warning," - calibration by driver is done for each CCD pixel\n"); dev->calibration_area = UMAX_CALIBRATION_AREA_CCD; } if (dev->calibration_bytespp == -1) /* no calibration-bytespp defined in umax.conf */ { DBG(DBG_warning," - setting calibration_bytespp = 2\n"); dev->calibration_bytespp = 2; } DBG(DBG_warning," - common x and y resolution\n"); dev->common_xy_resolutions = 1; if (dev->connection_type == SANE_UMAX_USB) { DBG(DBG_warning," - disabling quality calibration for USB connection\n"); set_inquiry_fw_quality(dev->buffer[0], 0); } } else if (!strncmp(product, "Astra 2400S ", 12)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - defining pauses\n"); dev->pause_for_color_calibration = 7000; /* pause between start_scan and do_calibration in ms */ dev->pause_for_gray_calibration = 4000; /* pause between start_scan and do_calibration in ms */ dev->pause_after_calibration = 0000; /* pause between do_calibration and read data in ms */ dev->pause_after_reposition = 3000; /* pause after repostion scanner in ms */ dev->pause_for_moving = 3000; /* pause for moving scanhead over full area */ DBG(DBG_warning," - correcting ADF bit in inquiry\n"); set_inquiry_sc_adf(dev->buffer[0], 1); /* set second bit that indicates ADF is supported */ } else if (!strncmp(product, "Vista-T630 ", 11)) { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->slow == -1) /* option is not predefined in umax.conf */ { DBG(DBG_warning," - activating slow option\n"); dev->slow = 1; } } else if (!strncmp(product, "UC630 ", 6)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - reposition_scanner waits until move of scan head has finished\n"); dev->pause_after_reposition = 0; /* call wait_scanner */ } else if (!strncmp(product, "UC840 ", 6)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - reposition_scanner waits until move of scan head has finished\n"); dev->pause_after_reposition = 0; /* call wait_scanner */ } else if (!strncmp(product, "UC1260 ", 7)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - setting gamma download curve format to type 1\n"); dev->inquiry_gamma_DCF = 1; /* define gamma download curve format */ DBG(DBG_warning," - reposition_scanner waits until move of scan head has finished\n"); dev->pause_after_reposition = 0; /* call wait_scanner */ } else if (!strncmp(product, "UC1200S ", 8)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - setting gamma download curve format to type 1\n"); dev->inquiry_gamma_DCF = 1; /* define gamma download curve format */ } else if (!strncmp(product, "UC1200SE ", 9)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - setting gamma download curve format to type 0\n"); dev->inquiry_gamma_DCF = 0; /* define gamma download curve format */ } else if (!strncmp(product, "ARCUS PLUS ", 11)) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - setting gamma download curve format to type 0\n"); dev->inquiry_gamma_DCF = 0; /* define gamma download curve format */ } else if ( (!strncmp(product, "UMAX S-12G ", 11)) || (!strncmp(product, "UMAX S-12 ", 10)) || (!strncmp(product, "SuperVista S-12 ", 16)) ) { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - setting maximum calibration data lines to 66\n"); set_inquiry_max_calibration_data_lines(dev->buffer[0], 66); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = -1; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } if (dev->calibration_area == -1) /* no calibration area defined in umax.conf */ { DBG(DBG_warning," - calibration by driver is done for each CCD pixel\n"); dev->calibration_area = UMAX_CALIBRATION_AREA_CCD; } } else if (!strncmp(product, "Mirage D-16L ", 13)) { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->calibration_area == -1) /* no calibration area defined in umax.conf */ { DBG(DBG_warning," - calibration by driver is done for each CCD pixel\n"); dev->calibration_area = UMAX_CALIBRATION_AREA_CCD; } if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = 308; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } } else if (!strncmp(product, "PowerLook III ", 14)) { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = 28; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } /* calibration_area = image */ if (dev->calibration_width_offset_batch == -99999) /* no calibration-width-offset for batch scanning defined in umax.conf */ { dev->calibration_width_offset_batch = 828; DBG(DBG_warning," - adding calibration width offset for batch scanning of %d pixels\n", dev->calibration_width_offset_batch); } } else if (!strncmp(product, "Power Look 2000", 15)) { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = 22; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } /* calibration_area = image */ if (dev->calibration_width_offset_batch == -99999) /* no calibration-width-offset for batch scanning defined in umax.conf */ { dev->calibration_width_offset_batch = 24; DBG(DBG_warning," - adding calibration width offset for batch scanning of %d pixels\n", dev->calibration_width_offset_batch); } } else if (!strncmp(product, "PowerLook 2100XL", 16)) { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = 52; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } /* calibration_area = image */ if (dev->calibration_width_offset_batch == -99999) /* no calibration-width-offset for batch scanning defined in umax.conf */ { dev->calibration_width_offset_batch = 1052; DBG(DBG_warning," - adding calibration width offset for batch scanning of %d pixels\n", dev->calibration_width_offset_batch); } dev->force_quality_calibration = 1; DBG(DBG_warning," - always set quality calibration\n"); /* the scanner uses the same exposure times for red, green and blue exposure_time_rgb_bind = 1 */ } else if (!strncmp(product, "PowerLook 3000 ", 15)) { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = 52; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } /* calibration_area = image */ if (dev->calibration_width_offset_batch == -99999) /* no calibration-width-offset for batch scanning defined in umax.conf */ { /* not tested */ dev->calibration_width_offset_batch = 1052; DBG(DBG_warning," - adding calibration width offset for batch scanning of %d pixels\n", dev->calibration_width_offset_batch); } } else { DBG(DBG_warning,"using standard options for %s\n", product); } } else if (!strncmp(vendor, "LinoHell ", 9)) { if ( (!strncmp(product, "Office ", 7)) || (!strncmp(product, "JADE ", 5)) ) /* is a Supervista S-12 */ { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - setting maximum calibration data lines to 66\n"); set_inquiry_max_calibration_data_lines(dev->buffer[0], 66); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = -1; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } if (dev->calibration_area == -1) /* no calibration area defined in umax.conf */ { DBG(DBG_warning," - calibration by driver is done for each CCD pixel\n"); dev->calibration_area = UMAX_CALIBRATION_AREA_CCD; } } else if (!strncmp(product, "OPAL2 ", 6)) /* looks like a Mirage II */ { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->gamma_lsb_padded == -1) /* nothing defined in umax.conf and not by backend */ { DBG(DBG_warning," - 16 bit gamma table is created lsb padded\n"); dev->gamma_lsb_padded = 1; } } } else if (!strncmp(vendor, "Linotype ", 9)) { if (!strncmp(product, "SAPHIR4 ", 8)) /* is a Powerlook III */ { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = 28; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } /* calibration_area = image */ if (dev->calibration_width_offset_batch == -99999) /* no calibration-width-offset for batch scanning defined in umax.conf */ { dev->calibration_width_offset_batch = 828; DBG(DBG_warning," - adding calibration width offset for batch scanning of %d pixels\n", dev->calibration_width_offset_batch); } } } else if (!strncmp(vendor, "HDM ", 4)) { if (!strncmp(product, "LS4H1S ", 7)) /* is a Powerlook III */ { DBG(DBG_warning,"setting up special options for %s\n", product); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = 28; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } /* calibration_area = image */ if (dev->calibration_width_offset_batch == -99999) /* no calibration-width-offset for batch scanning defined in umax.conf */ { dev->calibration_width_offset_batch = 828; DBG(DBG_warning," - adding calibration width offset for batch scanning of %d pixels\n", dev->calibration_width_offset_batch); } } } else if (!strncmp(vendor, "ESCORT ", 7)) { if (!strncmp(product, "Galleria 600S ", 14)) /* this is an Astra 600S */ { int add_len = get_inquiry_additional_length(dev->buffer[0]); DBG(DBG_warning,"setting up special options for %s\n", product); if (add_len == 0x8f) { DBG(DBG_warning," - correcting wrong inquiry data\n"); umax_do_new_inquiry(dev, 0x9b); /* get inquiry with correct length */ set_inquiry_length(dev->buffer[0], 0x9e); /* correct inquiry len */ /* correct color-ordering from pixel to line_with_ccd_distance */ set_inquiry_color_order(dev->buffer[0], IN_color_ordering_line_w_ccd); set_inquiry_fb_uta_line_arrangement_mode(dev->buffer[0], 32); set_inquiry_CCD_line_distance(dev->buffer[0], 8); /* we should reset ADF-bit here too */ if (dev->invert_shading_data == -1) /* nothing defined in umax.conf */ { DBG(DBG_warning," - activating inversion of shading data\n"); dev->invert_shading_data = 1; } } } } else if (!strncmp(vendor, "TriGem ", 7)) { if (!strncmp(product, "PowerScanII ", 12)) /* is a Supervista S-12 */ { DBG(DBG_warning,"setting up special options for %s\n", product); DBG(DBG_warning," - setting maximum calibration data lines to 66\n"); set_inquiry_max_calibration_data_lines(dev->buffer[0], 66); if (dev->calibration_width_offset == -99999) /* no calibration-width-offset defined in umax.conf */ { dev->calibration_width_offset = -1; DBG(DBG_warning," - adding calibration width offset of %d pixels\n", dev->calibration_width_offset); } if (dev->calibration_area == -1) /* no calibration area defined in umax.conf */ { DBG(DBG_warning," - calibration by driver is done for each CCD pixel\n"); dev->calibration_area = UMAX_CALIBRATION_AREA_CCD; } } } } /* ------------------------------------------------------------ UMAX IDENTIFY SCANNER ---------------------- */ static int umax_identify_scanner(Umax_Device *dev) { char vendor[10]; char product[0x12]; char version[6]; char *pp; DBG(DBG_proc,"identify_scanner\n"); umax_do_inquiry(dev); /* get inquiry */ if (get_inquiry_periph_devtype(dev->buffer[0]) != IN_periph_devtype_scanner) { return 1; } /* no scanner */ get_inquiry_vendor( (char *)dev->buffer[0], vendor); vendor[8] = ' '; vendor[9] = '\0'; get_inquiry_product((char *)dev->buffer[0], product); product[16] = ' '; product[17] = '\0'; get_inquiry_version((char *)dev->buffer[0], version); version[4] = ' '; version[5] = '\0'; pp = &vendor[8]; while (*(pp-1) == ' ') { *pp-- = '\0'; } pp = &product[0x10]; while (*(pp-1) == ' ') { *pp-- = '\0'; } pp = &version[4]; while (*pp == ' ') { *pp-- = '\0'; } DBG(DBG_info, "Found %s scanner %sversion %s on device %s\n", vendor, product, version, dev->devicename); /* look for scanners that do not give all inquiry-information */ /* and if possible use driver-known inquiry-data */ if (get_inquiry_additional_length(dev->buffer[0])>=0x8f) { int i = 0; while (strncmp("END_OF_LIST", scanner_str[2*i], 11) != 0) /* Now identify full supported scanners */ { if (!strncmp(vendor, scanner_str[2*i], strlen(scanner_str[2*i])) ) { if (!strncmp(product, scanner_str[2*i+1], strlen(scanner_str[2*i+1])) ) { umax_correct_inquiry(dev, vendor, product, version); return 0; } } i++; } if (strncmp(vendor, "UMAX ", 5)) { return 1; } /* not UMAX then abort */ DBG(DBG_error0, "WARNING: %s scanner %s version %s on device %s\n" "is currently an unrecognized device for this backend version.\n" "Please make sure you use the most recent version of the umax backend.\n" "You can download new umax-backend versions from:\n" "http://www.rauch-domain.de/sane-umax\n", vendor, product, version, dev->devicename); DBG(DBG_error0, "Inquiry seems to be ok.\n" "******************************************************************\n" "*** !!!! CONTINUE AT YOUR OWN RISK !!!! ***\n" "******************************************************************\n" "If you already use the most recent umax-backend version\n" "then please contact me: Oliver.Rauch@rauch-domain.de\n"); return 0; } else /* inquiry-data not complete */ if (!strncmp(vendor, "UMAX ", 5)) /* test UMAX-scanners with short inquiry */ { inquiry_blk inq_data; int i; for(i=0; i < known_inquiry; i++) { inq_data = *inquiry_table[i]; if (!strncmp(product, inq_data.scanner, strlen(inq_data.scanner))) { DBG(DBG_warning, "inquiry-block-length: %d\n", get_inquiry_additional_length(dev->buffer[0])+5); DBG(DBG_warning, "using driver-internal inquiry-data for this scanner!\n"); /* copy driver-defined inquiry-data into inquiry-block */ memcpy(dev->buffer[0]+0x24, inq_data.inquiry, inq_data.inquiry_len-0x24); /* correct variables */ set_inquiry_sc_uta(dev->buffer[0], get_inquiry_transavail(dev->buffer[0])); /* transparancy available ? */ set_inquiry_sc_adf(dev->buffer[0], get_inquiry_scanmode(dev->buffer[0])); /* automatic document feeder available ? */ set_inquiry_length(dev->buffer[0], inq_data.inquiry_len); umax_correct_inquiry(dev, vendor, product, version); return 0; /* ok */ } } DBG(DBG_error0, "ERROR: %s scanner %s version %s on device %s\n" "is currently an unrecognized device, and inquiry is too short,\n" "so we are not able to continue!\n" "Please make sure you use the most recent version of the umax backend.\n" "You can download new umax-backend versions from:\n" "http://www.rauch-domain.de/sane-umax\n" "You already use the most recent umax-backend version:\n" "Please contact me: Oliver.Rauch@rauch-domain.de\n", vendor, product, version, dev->devicename); } return 1; /* NO SUPPORTED SCANNER: short inquiry-block and unknown scanner */ } /* ------------------------------------------------------------ UMAX TRIM BUFSIZE -------------------------- */ static void umax_trim_rowbufsize(Umax_Device *dev) { unsigned int lines=0; if (dev->row_bufsize > dev->row_len) { lines = dev->row_bufsize / dev->row_len; if (lines > dev->lines_max) /* reduce number of lines to scan if set up in config file */ { lines = dev->lines_max; } dev->row_bufsize = lines * dev->row_len; } DBG(DBG_proc,"trim_rowbufsize: row_bufsize = %d bytes = %d lines\n", dev->row_bufsize, lines); } /* ------------------------------------------------------------ UMAX CALCULATE EXPOSURE TIME --------------- */ static void umax_calculate_exposure_time(Umax_Device *dev, int def, int *value) { int level; DBG(DBG_proc,"calculate_exposure_time\n"); if ( (*value)) { if ( (*value) == -1 ) { (*value) = def; } else { level = (*value) / dev->inquiry_exposure_time_step_unit; (*value) = inrange(dev->use_exposure_time_min, level, dev->inquiry_exposure_time_max); } } } /* ------------------------------------------------------------ UMAX CHECK VALUES -------------------------- */ static int umax_check_values(Umax_Device *dev) { double inquiry_x_orig; double inquiry_y_orig; double inquiry_width; double inquiry_length; unsigned int maxwidth; unsigned int maxlength; DBG(DBG_proc,"check_values\n"); /* ------------------------------- flatbed ------------------------------- */ dev->module = WD_module_flatbed; /* reset scanmode to flatbed first */ /* --------------------------------- uta --------------------------------- */ if (dev->uta != 0) { dev->module = WD_module_transparency; if ( (dev->inquiry_uta == 0) || (dev->inquiry_transavail == 0) ) { DBG(DBG_error, "ERROR: transparency mode not supported by scanner\n"); return(1); } } /* --------------------------------- adf --------------------------------- */ if (dev->adf != 0) { if (dev->inquiry_adf == 0) { DBG(DBG_error,"ERROR: adf mode not supported by scanner\n"); return(1); } } /* --------------------------------- dor --------------------------------- */ if (dev->dor != 0) { if (dev->inquiry_dor == 0) { DBG(DBG_error, "ERROR: double optical resolution not supported by scanner\n"); return(1); } } /* ------------------------------- resolution ------------------------ */ if (dev->dor == 0) /* standard (FB) */ { dev->relevant_optical_res = dev->inquiry_optical_res; dev->relevant_max_x_res = dev->inquiry_x_res; dev->relevant_max_y_res = dev->inquiry_y_res; } else /* DOR mode */ { dev->relevant_optical_res = dev->inquiry_dor_optical_res; dev->relevant_max_x_res = dev->inquiry_dor_x_res; dev->relevant_max_y_res = dev->inquiry_dor_y_res; } if (dev->x_resolution <= 0) { DBG(DBG_error,"ERROR: no x-resolution given\n"); return(1); } if (dev->x_resolution > dev->relevant_max_x_res) { dev->x_resolution = dev->relevant_max_x_res; } if (dev->x_resolution > dev->relevant_optical_res) { dev->scale_x = 2; } else { dev->scale_x = 1; } if (dev->y_resolution <= 0) { DBG(DBG_error,"ERROR: no y-resolution given\n"); return(1); } if (dev->y_resolution > dev->relevant_max_y_res) { dev->y_resolution = dev->relevant_max_y_res; } if (dev->y_resolution > dev->relevant_optical_res) { dev->scale_y = 2; } else if (dev->y_resolution > dev->relevant_optical_res/2) { dev->scale_y = 1; } else { /* astra 600S and 610S need this in umax_forget_line */ dev->scale_y = 0.5; } /* ------------------------------- scanarea ------------------------ */ if (dev->module == WD_module_flatbed) /* flatbed mode */ { inquiry_x_orig = 0; /* flatbed origin */ inquiry_y_orig = 0; inquiry_width = dev->inquiry_fb_width; /* flatbed width */ inquiry_length = dev->inquiry_fb_length; } else /* transparency mode */ { inquiry_x_orig = dev->inquiry_uta_x_off; /* uta origin */ inquiry_y_orig = dev->inquiry_uta_y_off; inquiry_width = dev->inquiry_uta_x_off + dev->inquiry_uta_width; /* uta width */ inquiry_length = dev->inquiry_uta_y_off + dev->inquiry_uta_length; } if (dev->dor != 0) { inquiry_x_orig = dev->inquiry_dor_x_off; /* dor origin */ inquiry_y_orig = dev->inquiry_dor_y_off; inquiry_width = dev->inquiry_dor_x_off + dev->inquiry_dor_width; /* dor width */ inquiry_length = dev->inquiry_dor_y_off + dev->inquiry_dor_length; } /* limit the size to what the scanner can scan. */ /* this is particularly important because the scanners don't have */ /* built-in checks and will happily grind their gears if this is exceeded. */ maxwidth = inquiry_width * dev->x_coordinate_base - dev->upper_left_x - 1; if ( (dev->scanwidth <= 0) || (dev->scanwidth > maxwidth) ) { dev->scanwidth = maxwidth; } if (dev->upper_left_x < inquiry_x_orig) { dev->upper_left_x = inquiry_x_orig; } maxlength = inquiry_length * dev->y_coordinate_base - dev->upper_left_y - 1; if ( (dev->scanlength <= 0) || (dev->scanlength > maxlength) ) { dev->scanlength = maxlength; } if (dev->upper_left_y < inquiry_y_orig) { dev->upper_left_y = inquiry_y_orig; } /* Now calculate width and length in pixels */ dev->width_in_pixels = umax_calculate_pixels(dev->scanwidth, dev->x_resolution, dev->relevant_optical_res * dev->scale_x, dev->x_coordinate_base); dev->length_in_pixels = umax_calculate_pixels(dev->scanlength, dev->y_resolution, dev->relevant_optical_res * dev->scale_y, dev->y_coordinate_base); if ((dev->scanwidth <= 0) || (dev->scanlength <= 0)) { DBG(DBG_error,"ERROR: scanwidth or scanlength not given\n"); return(1); } if (dev->bits_per_pixel_code == 1) { dev->bytes_per_color = 1; } else { dev->bytes_per_color = 2; } switch(dev->colormode) { case LINEART: dev->width_in_pixels -= dev->width_in_pixels % 8; dev->row_len = (dev->width_in_pixels / 8); break; case HALFTONE: dev->width_in_pixels -= dev->width_in_pixels % 8; dev->row_len = (dev->width_in_pixels / 8); break; case GRAYSCALE: dev->row_len = dev->width_in_pixels * dev->bytes_per_color; break; case RGB_LINEART: case RGB_HALFTONE: if (dev->three_pass) { dev->row_len = dev->width_in_pixels / 8 ; } else { dev->row_len = (dev->width_in_pixels / 8 ) * 3; } break; case RGB: if (dev->three_pass) /* three (24bpp) or six (30bpp) bytes per pixel */ { dev->row_len = dev->width_in_pixels * dev->bytes_per_color; } else { dev->row_len = dev->width_in_pixels * 3 * dev->bytes_per_color; } break; } /* ------------------------------- wdb length ------------------------ */ if (dev->wdb_len <= 0) { dev->wdb_len = dev->inquiry_wdb_len; if (dev->wdb_len <= 0) { DBG(DBG_error,"ERROR: wdb-length not given\n"); return(1); } } if (dev->wdb_len > used_WDB_size) { DBG(DBG_warning,"WARNING:window descriptor block too long, will be shortned!\n"); dev->wdb_len = used_WDB_size; } /* ----------------------------- cbhs-range ----------------------------- */ dev->threshold = umax_cbhs_correct(dev->inquiry_threshold_min, dev->threshold , dev->inquiry_threshold_max); dev->contrast = umax_cbhs_correct(dev->inquiry_contrast_min, dev->contrast , dev->inquiry_contrast_max); dev->brightness = umax_cbhs_correct(dev->inquiry_brightness_min, dev->brightness, dev->inquiry_brightness_max); dev->highlight_r = umax_cbhs_correct(dev->inquiry_highlight_min, dev->highlight_r, dev->inquiry_highlight_max); dev->highlight_g = umax_cbhs_correct(dev->inquiry_highlight_min, dev->highlight_g, dev->inquiry_highlight_max); dev->highlight_b = umax_cbhs_correct(dev->inquiry_highlight_min, dev->highlight_b, dev->inquiry_highlight_max); dev->shadow_r = umax_cbhs_correct(dev->inquiry_shadow_min, dev->shadow_r, dev->inquiry_shadow_max-1); dev->shadow_g = umax_cbhs_correct(dev->inquiry_shadow_min, dev->shadow_g, dev->inquiry_shadow_max-1); dev->shadow_b = umax_cbhs_correct(dev->inquiry_shadow_min, dev->shadow_b, dev->inquiry_shadow_max-1); if (dev->shadow_r >= dev->highlight_r) { dev->shadow_r = dev->highlight_r-1; } if (dev->shadow_g >= dev->highlight_g) { dev->shadow_g = dev->highlight_g-1; } if (dev->shadow_b >= dev->highlight_b) { dev->shadow_b = dev->highlight_b-1; } /* ----------------------- quality calibration and preview -------------- */ if (dev->inquiry_preview == 0) { if (dev->preview) { DBG(DBG_warning, "WARNING: fast preview function not supported by scanner\n"); dev->preview = 0; } } /* always set calibration lines because we also need this value if the scanner requeires calibration by driver */ dev->calib_lines = dev->inquiry_max_calib_lines; if (dev->force_quality_calibration) { dev->quality = 1; /* always use quality calibration */ } else if (dev->inquiry_quality_ctrl == 0) { if (dev->quality) { DBG(DBG_warning, "WARNING: quality calibration not supported by scanner\n"); dev->quality = 0; } } else { if (dev->preview != 0) { DBG(DBG_info, "quality calibration disabled in preview mode\n"); dev->quality = 0; /* do not use quality calibration in preview mode */ } } /* --------------------------- lamp intensity control ------------------- */ if (dev->inquiry_lamp_ctrl == 0) { if (dev->c_density || dev->s_density) { DBG(DBG_warning, "WARNING: scanner doesn't support lamp intensity control\n"); } dev->c_density = dev->s_density = 0; } /* --------------------------- reverse (negative) ----------------------- */ if (dev->reverse != 0) { if ( (dev->colormode == LINEART) || (dev->colormode == HALFTONE) || (dev->colormode == RGB_LINEART) || (dev->colormode == RGB_HALFTONE) ) { if (dev->inquiry_reverse == 0) { DBG(DBG_error, "ERROR: reverse for bi-level-image not supported\n"); return(1); } } else { dev->reverse = 0; } } if (dev->reverse_multi != 0) { if ((dev->colormode == RGB) || (dev->colormode == GRAYSCALE) ) { if (dev->inquiry_reverse_multi == 0) { DBG(DBG_error, "ERROR: reverse for multi-level-image not supported\n"); return(1); } } else { dev->reverse_multi = 0; } } /* ----------------------------- analog gamma ---------------------------- */ if (dev->inquiry_analog_gamma == 0) { if (dev->analog_gamma_r + dev->analog_gamma_g + dev->analog_gamma_b != 0) { DBG(DBG_warning,"WARNING: analog gamma correction not supported by scanner!\n"); } dev->analog_gamma_r = dev->analog_gamma_g = dev->analog_gamma_b = 0; } /* ---------------------------- digital gamma ---------------------------- */ if ( (dev->digital_gamma_r == 0) || (dev->digital_gamma_g == 0) || (dev->digital_gamma_b == 0) ) { if (dev->inquiry_gamma_dwload == 0) { DBG(DBG_warning, "WARNING: gamma download not available\n"); dev->digital_gamma_r = dev->digital_gamma_g = dev->digital_gamma_b = 15; } } /* ---------------------------- speed and smear ------------------------- */ if (dev->slow == 1) { dev->WD_speed = WD_speed_slow; } else { dev->WD_speed = WD_speed_fast; } if (dev->smear == 1) { dev->WD_speed += WD_speed_smear; } /* ---------------------- test bits per pixel --------------------------- */ if ( ( (dev->inquiry_GIB | 1) & dev->gamma_input_bits_code) == 0 ) { DBG(DBG_warning,"WARNING: selected gamma input bits not supported, gamma ignored\n"); dev->gamma_input_bits_code = 1; dev->digital_gamma_r = dev->digital_gamma_g = dev->digital_gamma_b = 15; } if ( ( (dev->inquiry_GOB | 1) & dev->bits_per_pixel_code) == 0 ) { DBG(DBG_error,"ERROR: selected bits per pixel not supported\n"); return(1); } /* ----------------------- scan mode dependencies ------------------------ */ switch(dev->colormode) { case LINEART: /* ------------ LINEART ------------- */ case RGB_LINEART: /* ---------- RGB_LINEART ----------- */ dev->use_exposure_time_min = dev->inquiry_exposure_time_l_min; if (dev->module == WD_module_flatbed) { dev->use_exposure_time_def_r = dev->inquiry_exposure_time_l_fb_def; } else { dev->use_exposure_time_def_r = dev->inquiry_exposure_time_l_uta_def; } if (dev->inquiry_lineart == 0) { DBG(DBG_error,"ERROR: lineart mode not supported by scanner\n"); return(1); } break; case HALFTONE: /* ----------- HALFTONE------------ */ case RGB_HALFTONE: /* --------- RGB_HALFTONE---------- */ dev->use_exposure_time_min = dev->inquiry_exposure_time_h_min; if (dev->module == WD_module_flatbed) { dev->use_exposure_time_def_r = dev->inquiry_exposure_time_h_fb_def; } else { dev->use_exposure_time_def_r = dev->inquiry_exposure_time_h_uta_def; } if (dev->inquiry_halftone == 0) { DBG(DBG_error,"ERROR: halftone mode not supported by scanner\n"); return(1); } break; case GRAYSCALE: /* ---------- GRAYSCALE ------------- */ dev->use_exposure_time_min = dev->inquiry_exposure_time_g_min; if (dev->module == WD_module_flatbed) { dev->use_exposure_time_def_r = dev->inquiry_exposure_time_g_fb_def; } else { dev->use_exposure_time_def_r = dev->inquiry_exposure_time_g_uta_def; } if (dev->inquiry_gray == 0) { DBG(DBG_error, "ERROR: grayscale mode not supported by scanner\n"); return(1); } break; case RGB: /* ----------------- COLOR ---------- */ dev->use_exposure_time_min = dev->inquiry_exposure_time_c_min; if (dev->module == WD_module_flatbed) { dev->use_exposure_time_def_r = dev->inquiry_exposure_time_c_fb_def_r; dev->use_exposure_time_def_g = dev->inquiry_exposure_time_c_fb_def_g; dev->use_exposure_time_def_b = dev->inquiry_exposure_time_c_fb_def_b; } else { dev->use_exposure_time_def_r = dev->inquiry_exposure_time_c_uta_def_r; dev->use_exposure_time_def_g = dev->inquiry_exposure_time_c_uta_def_g; dev->use_exposure_time_def_b = dev->inquiry_exposure_time_c_uta_def_b; } if (dev->inquiry_color == 0) { DBG(DBG_error,"ERROR: color mode not supported by scanner\n"); return(1); } if (dev->inquiry_one_pass_color) { DBG(DBG_info,"using one pass scanning mode\n"); if (dev->inquiry_color_order & IN_color_ordering_pixel) { DBG(DBG_info,"scanner uses color-pixel-ordering\n"); } else if (dev->inquiry_color_order & IN_color_ordering_line_no_ccd) { dev->CCD_distance = 0; dev->do_color_ordering = 1; DBG(DBG_info,"scanner uses color-line-ordering without CCD-distance\n"); } else if (dev->inquiry_color_order & IN_color_ordering_line_w_ccd) { dev->CCD_distance = dev->inquiry_CCD_line_distance; dev->do_color_ordering = 1; switch (dev->inquiry_fb_uta_color_arrangement) /* define color order for line ordering */ { case 1: dev->CCD_color[0] = CCD_color_green; dev->CCD_color[1] = CCD_color_blue; dev->CCD_color[2] = CCD_color_green; dev->CCD_color[3] = CCD_color_blue; dev->CCD_color[4] = CCD_color_red; dev->CCD_color[5] = CCD_color_green; dev->CCD_color[6] = CCD_color_blue; dev->CCD_color[7] = CCD_color_red; dev->CCD_color[8] = CCD_color_red; break; case 2: dev->CCD_color[0] = CCD_color_blue; dev->CCD_color[1] = CCD_color_green; dev->CCD_color[2] = CCD_color_blue; dev->CCD_color[3] = CCD_color_green; dev->CCD_color[4] = CCD_color_red; dev->CCD_color[5] = CCD_color_blue; dev->CCD_color[6] = CCD_color_green; dev->CCD_color[7] = CCD_color_red; dev->CCD_color[8] = CCD_color_red; break; case 3: dev->CCD_color[0] = CCD_color_red; dev->CCD_color[1] = CCD_color_blue; dev->CCD_color[2] = CCD_color_red; dev->CCD_color[3] = CCD_color_blue; dev->CCD_color[4] = CCD_color_green; dev->CCD_color[5] = CCD_color_red; dev->CCD_color[6] = CCD_color_blue; dev->CCD_color[7] = CCD_color_green; dev->CCD_color[8] = CCD_color_green; break; case 4: /* may be wrong !!! */ dev->CCD_color[0] = CCD_color_red; dev->CCD_color[1] = CCD_color_green; dev->CCD_color[2] = CCD_color_red; dev->CCD_color[3] = CCD_color_green; dev->CCD_color[4] = CCD_color_red; dev->CCD_color[5] = CCD_color_blue; dev->CCD_color[6] = CCD_color_green; dev->CCD_color[7] = CCD_color_blue; dev->CCD_color[8] = CCD_color_blue; break; case 32: /* not defined from UMAX, for Astra 600S */ dev->CCD_color[0] = CCD_color_green; dev->CCD_color[1] = CCD_color_green; dev->CCD_color[2] = CCD_color_blue; dev->CCD_color[3] = CCD_color_green; dev->CCD_color[4] = CCD_color_red; dev->CCD_color[5] = CCD_color_blue; dev->CCD_color[6] = CCD_color_red; dev->CCD_color[7] = CCD_color_blue; dev->CCD_color[8] = CCD_color_red; break; case 33: /* not defined from UMAX, for Astra 610S */ dev->CCD_color[0] = CCD_color_red; dev->CCD_color[1] = CCD_color_red; dev->CCD_color[2] = CCD_color_blue; dev->CCD_color[3] = CCD_color_red; dev->CCD_color[4] = CCD_color_green; dev->CCD_color[5] = CCD_color_blue; dev->CCD_color[6] = CCD_color_green; dev->CCD_color[7] = CCD_color_blue; dev->CCD_color[8] = CCD_color_green; break; default: dev->CCD_color[0] = CCD_color_green; dev->CCD_color[1] = CCD_color_blue; dev->CCD_color[2] = CCD_color_green; dev->CCD_color[3] = CCD_color_blue; dev->CCD_color[4] = CCD_color_red; dev->CCD_color[5] = CCD_color_green; dev->CCD_color[6] = CCD_color_blue; dev->CCD_color[7] = CCD_color_red; dev->CCD_color[8] = CCD_color_red; } DBG(DBG_info,"scanner uses color-line-ordering with CCD-distance of %d lines\n", dev->CCD_distance); } else { DBG(DBG_error,"ERROR: color-ordering-type not supported \n"); return(1); } } else { DBG(DBG_info,"using three pass scanning mode\n"); dev->three_pass=1; } break; } /* switch */ /* ----------------------------- color ordering ------------------------ */ if (dev->do_color_ordering != 0) { if ( (dev->colormode != RGB) || (dev->three_pass != 0) ) { dev->do_color_ordering = 0; /* color ordering not necessery */ } } return(0); } /* ------------------------------------------------------------ UMAX GET INQUIRY VALUES -------------------- */ static void umax_get_inquiry_values(Umax_Device *dev) { unsigned char * inquiry_block; DBG(DBG_proc,"get_inquiry_values\n"); inquiry_block = dev->buffer[0]; dev->inquiry_len = get_inquiry_additional_length(dev->buffer[0])+5; dev->cbhs_range = dev->inquiry_cbhs = get_inquiry_CBHS(inquiry_block); if (dev->cbhs_range > IN_CBHS_255) { dev->cbhs_range = IN_CBHS_255; } if (dev->cbhs_range == IN_CBHS_50) { dev->inquiry_contrast_min = 103; /* minimum value for c */ dev->inquiry_contrast_max = 153; /* maximum value for c */ dev->inquiry_brightness_min = 78; /* minimum value for b */ dev->inquiry_brightness_max = 178; /* maximum value for b */ dev->inquiry_threshold_min = 78; /* minimum value for t */ dev->inquiry_threshold_max = 178; /* maximum value for t */ dev->inquiry_highlight_min = 1; /* minimum value for h */ dev->inquiry_highlight_max = 50; /* maximum value for h */ dev->inquiry_shadow_min = 0; /* minimum value for s */ dev->inquiry_shadow_max = 49; /* maximum value for s */ } get_inquiry_vendor( (char *)inquiry_block, dev->vendor); dev->vendor[8] ='\0'; get_inquiry_product((char *)inquiry_block, dev->product); dev->product[16]='\0'; get_inquiry_version((char *)inquiry_block, dev->version); dev->version[4] ='\0'; dev->inquiry_batch_scan = get_inquiry_fw_batch_scan(inquiry_block); dev->inquiry_quality_ctrl = get_inquiry_fw_quality(inquiry_block); dev->inquiry_preview = get_inquiry_fw_fast_preview(inquiry_block); dev->inquiry_lamp_ctrl = get_inquiry_fw_lamp_int_cont(inquiry_block); dev->inquiry_calibration = get_inquiry_fw_calibration(inquiry_block); dev->inquiry_transavail = get_inquiry_transavail(inquiry_block); dev->inquiry_adfmode = get_inquiry_scanmode(inquiry_block); if (dev->inquiry_len<=0x8f) { DBG(DBG_warning, "WARNING: inquiry return block is unexpected short.\n"); } dev->inquiry_uta = get_inquiry_sc_uta(inquiry_block); dev->inquiry_adf = get_inquiry_sc_adf(inquiry_block); dev->inquiry_one_pass_color = get_inquiry_sc_one_pass_color(inquiry_block); dev->inquiry_three_pass_color = get_inquiry_sc_three_pass_color(inquiry_block); dev->inquiry_color = get_inquiry_sc_color(inquiry_block); dev->inquiry_gray = get_inquiry_sc_gray(inquiry_block); dev->inquiry_halftone = get_inquiry_sc_halftone(inquiry_block); dev->inquiry_lineart = get_inquiry_sc_lineart(inquiry_block); dev->inquiry_exposure_adj = get_inquiry_fw_adjust_exposure_tf(inquiry_block); dev->inquiry_exposure_time_step_unit = get_inquiry_exposure_time_step_unit(inquiry_block); dev->inquiry_exposure_time_max = get_inquiry_exposure_time_max(inquiry_block); /* --- lineart --- */ dev->inquiry_exposure_time_l_min = get_inquiry_exposure_time_lhg_min(inquiry_block); dev->inquiry_exposure_time_l_fb_def = get_inquiry_exposure_time_lh_def_fb(inquiry_block); dev->inquiry_exposure_time_l_uta_def = get_inquiry_exposure_time_lh_def_uta(inquiry_block); /* --- halftone --- */ dev->inquiry_exposure_time_h_min = get_inquiry_exposure_time_lhg_min(inquiry_block); dev->inquiry_exposure_time_h_fb_def = get_inquiry_exposure_time_lh_def_fb(inquiry_block); dev->inquiry_exposure_time_h_uta_def = get_inquiry_exposure_time_lh_def_uta(inquiry_block); /* --- grayscale --- */ dev->inquiry_exposure_time_g_min = get_inquiry_exposure_time_lhg_min(inquiry_block); dev->inquiry_exposure_time_g_fb_def = get_inquiry_exposure_time_gray_def_fb(inquiry_block); dev->inquiry_exposure_time_g_uta_def = get_inquiry_exposure_time_gray_def_uta(inquiry_block); /* --- color --- */ dev->inquiry_exposure_time_c_min = get_inquiry_exposure_time_color_min(inquiry_block); dev->inquiry_exposure_time_c_fb_def_r = get_inquiry_exposure_time_def_r_fb(inquiry_block); dev->inquiry_exposure_time_c_fb_def_g = get_inquiry_exposure_time_def_g_fb(inquiry_block); dev->inquiry_exposure_time_c_fb_def_b = get_inquiry_exposure_time_def_g_fb(inquiry_block); dev->inquiry_exposure_time_c_uta_def_r = get_inquiry_exposure_time_def_r_uta(inquiry_block); dev->inquiry_exposure_time_c_uta_def_g = get_inquiry_exposure_time_def_g_uta(inquiry_block); dev->inquiry_exposure_time_c_uta_def_b = get_inquiry_exposure_time_def_b_uta(inquiry_block); dev->inquiry_dor = get_inquiry_sc_double_res(inquiry_block); dev->inquiry_reverse = get_inquiry_sc_bi_image_reverse(inquiry_block); dev->inquiry_reverse_multi = get_inquiry_sc_multi_image_reverse(inquiry_block); dev->inquiry_shadow = 1 - get_inquiry_sc_no_shadow(inquiry_block); dev->inquiry_highlight = 1 - get_inquiry_sc_no_highlight(inquiry_block); dev->inquiry_analog_gamma = get_inquiry_analog_gamma(inquiry_block); dev->inquiry_lineart_order = get_inquiry_lineart_order(inquiry_block); dev->inquiry_lens_cal_in_doc_pos = get_inquiry_manual_focus(inquiry_block); dev->inquiry_manual_focus = get_inquiry_manual_focus(inquiry_block); dev->inquiry_sel_uta_lens_cal_pos = get_inquiry_manual_focus(inquiry_block); dev->inquiry_gamma_dwload = get_inquiry_gamma_download_available(inquiry_block); if (get_inquiry_gamma_type_2(inquiry_block) != 0) { dev->inquiry_gamma_DCF = 2; } dev->inquiry_GIB = get_inquiry_gib(inquiry_block); dev->inquiry_GOB = get_inquiry_gob(inquiry_block); dev->inquiry_color_order = get_inquiry_color_order(inquiry_block); dev->inquiry_vidmem = get_inquiry_max_vidmem(inquiry_block); /* optical resolution = [0x73] * 100 + [0x94] , 0x94 is not always defined */ dev->inquiry_optical_res = 100 * get_inquiry_max_opt_res(inquiry_block); if (dev->inquiry_len > 0x94) { dev->inquiry_optical_res += get_inquiry_optical_resolution_residue(inquiry_block); } /* x resolution = [0x74] * 100 + [0x95] , 0x95 is not always defined */ dev->inquiry_x_res = 100 * get_inquiry_max_x_res(inquiry_block); if (dev->inquiry_len > 0x95) { dev->inquiry_x_res+= get_inquiry_x_resolution_residue(inquiry_block); }; /* y resolution = [0x75] * 100 + [0x96] , 0x96 is not always defined */ dev->inquiry_y_res = 100 * get_inquiry_max_y_res(inquiry_block); if (dev->inquiry_len > 0x96) { dev->inquiry_y_res+= get_inquiry_y_resolution_residue(inquiry_block); } /* optical resolution = [0x83] * 100 + [0xa0] , 0xa0 is not always defined */ dev->inquiry_dor_optical_res = 100 * get_inquiry_dor_max_opt_res(inquiry_block); if (dev->inquiry_len > 0xa0) { dev->inquiry_dor_optical_res += get_inquiry_dor_optical_resolution_residue(inquiry_block); } /* x resolution = [0x84] * 100 + [0xa1] , 0xa1 is not always defined */ dev->inquiry_dor_x_res = 100 * get_inquiry_dor_max_x_res(inquiry_block); if (dev->inquiry_len > 0xa1) { dev->inquiry_dor_x_res+= get_inquiry_dor_x_resolution_residue(inquiry_block); } /* y resolution = [0x85] * 100 + [0xa2] , 0xa2 is not always defined */ dev->inquiry_dor_y_res = 100 * get_inquiry_dor_max_y_res(inquiry_block); if (dev->inquiry_len > 0xa2) { dev->inquiry_dor_y_res+= get_inquiry_dor_y_resolution_residue(inquiry_block); } if (dev->inquiry_dor) /* DOR mode available ? */ { /* if DOR resolutions are not defined, use double of standard resolution */ if (dev->inquiry_dor_optical_res == 0) { dev->inquiry_dor_optical_res = dev->inquiry_optical_res * 2; } if (dev->inquiry_dor_x_res == 0) { dev->inquiry_dor_x_res = dev->inquiry_x_res * 2; } if (dev->inquiry_dor_y_res == 0) { dev->inquiry_dor_y_res = dev->inquiry_y_res * 2; } } dev->inquiry_fb_width = (double)get_inquiry_fb_max_scan_width(inquiry_block) * 0.01; dev->inquiry_fb_length = (double)get_inquiry_fb_max_scan_length(inquiry_block) * 0.01; dev->inquiry_uta_width = (double)get_inquiry_uta_max_scan_width(inquiry_block) * 0.01; dev->inquiry_uta_length = (double)get_inquiry_uta_max_scan_length(inquiry_block) * 0.01; dev->inquiry_uta_x_off = (double)get_inquiry_uta_x_original_point(inquiry_block) * 0.01; dev->inquiry_uta_y_off = (double)get_inquiry_uta_y_original_point(inquiry_block) * 0.01; dev->inquiry_dor_width = (double)get_inquiry_dor_max_scan_width(inquiry_block) * 0.01; dev->inquiry_dor_length = (double)get_inquiry_dor_max_scan_length(inquiry_block) * 0.01; dev->inquiry_dor_x_off = (double)get_inquiry_dor_x_original_point(inquiry_block) * 0.01; dev->inquiry_dor_y_off = (double)get_inquiry_dor_y_original_point(inquiry_block) * 0.01; dev->inquiry_max_warmup_time = get_inquiry_lamp_warmup_maximum_time(inquiry_block) * 2; dev->inquiry_wdb_len = get_inquiry_wdb_length(inquiry_block); /* it is not guaranteed that the following values are in the inquiry return block */ /* 0x9a */ if (dev->inquiry_len<=0x9a) { return; } dev->inquiry_max_calib_lines = get_inquiry_max_calibration_data_lines(inquiry_block); /* 0x9b */ if (dev->inquiry_len<=0x9b) { return; } dev->inquiry_fb_uta_color_arrangement = get_inquiry_fb_uta_line_arrangement_mode(inquiry_block); /* 0x9c */ if (dev->inquiry_len<=0x9c) { return; } dev->inquiry_adf_color_arrangement = get_inquiry_adf_line_arrangement_mode(inquiry_block); /* 0x9d */ if (dev->inquiry_len<=0x9d) { return; } dev->inquiry_CCD_line_distance = get_inquiry_CCD_line_distance(inquiry_block); return; } /* ------------------------------------------------------------ UMAX CALCULATE ANALOG GAMMA ---------------- */ static int umax_calculate_analog_gamma(double value) { int gamma; if (value < 1.0) { value=1.0; } if (value > 2.0) { value=2.0; } gamma=0; /* select gamma_value from analog_gamma_table */ while (value>analog_gamma_table[gamma]) { gamma++; } if (gamma) { if ((analog_gamma_table[gamma-1] + analog_gamma_table[gamma]) /2 > value) { gamma--; } } return(gamma); } /* ------------------------------------------------------------ UMAX OUTPUT IMAGE DATA -------------------- */ static void umax_output_image_data(Umax_Device *dev, FILE *fp, unsigned int data_to_read, int bufnr) { if (dev->do_color_ordering == 0) /* pixel ordering */ { if ((dev->inquiry_lineart_order) && (dev->colormode == LINEART)) /* lineart with LSB first */ { unsigned int i, j; int new, old; for (i=0; ibuffer[bufnr][i]; new = 0; for (j=0; j<8; j++) /* reverse bit order of 1 byte */ { new = (new << 1) + (old & 1); old = old >> 1; } dev->buffer[bufnr][i]=new; } } fwrite(dev->buffer[bufnr], 1, data_to_read, fp); } else /* line ordering */ { unsigned char *linesource = dev->buffer[bufnr]; unsigned char *pixelsource; int bytes = 1; int lines; int i; if (dev->bits_per_pixel_code != 1) /* >24 bpp */ { bytes = 2; } lines = data_to_read / (dev->width_in_pixels * bytes); for(i=0; iwidth_in_pixels * bytes; pixelsource = umax_get_pixel_line(dev); if (pixelsource != NULL) { fwrite(pixelsource, bytes, dev->width_in_pixels * 3, fp); } } } } /* ------------------------------------------------------------ UMAX READER PROCESS ------------------------ */ static int umax_reader_process(Umax_Device *dev, FILE *fp, unsigned int image_size) { int status; int bytes = 1; int queue_filled = 0; unsigned int bufnr_queue = 0; unsigned int bufnr_read = 0; unsigned int data_left_to_read = image_size; unsigned int data_left_to_queue = image_size; unsigned int data_to_read; unsigned int data_to_queue; dev->row_bufsize = dev->bufsize; umax_trim_rowbufsize(dev); /* trim bufsize */ if (dev->bits_per_pixel_code != 1) /* >24 bpp */ { bytes = 2; } DBG(DBG_read,"reading %u bytes in blocks of %u bytes\n", image_size, dev->row_bufsize); if (dev->pixelbuffer != NULL) /* buffer exists? */ { free(dev->pixelbuffer); dev->pixelbuffer = NULL; } if (dev->do_color_ordering != 0) { DBG(DBG_info,"ordering from line-order to pixel-order\n"); dev->pixelline_max = 3 * dev->CCD_distance * dev->scale_y + 2; dev->pixelbuffer = malloc(dev->width_in_pixels * dev->pixelline_max * bytes * 3); if (dev->pixelbuffer == NULL) /* NO MEMORY */ { return -1; } } WAIT_SCANNER; do { if (data_left_to_queue) { data_to_queue = (data_left_to_queue < dev->row_bufsize) ? data_left_to_queue : dev->row_bufsize; /* umax_get_data_buffer_status(dev); */ status = umax_queue_read_image_data_req(dev, data_to_queue, bufnr_queue); if (status == 0) /* no error but nothing queued */ { continue; } if (status == -1) /* error */ { DBG(DBG_error,"ERROR: umax_reader_process: unable to queue read image data request!\n"); free(dev->pixelbuffer); dev->pixelbuffer = NULL; return(-1); } data_left_to_queue -= data_to_queue; DBG(DBG_read, "umax_reader_process: read image data queued for buffer[%d] \n", bufnr_queue); bufnr_queue++; if (bufnr_queue >= dev->scsi_maxqueue) { bufnr_queue = 0; queue_filled = 1; /* ok, we can start to read the queued buffers - if not already started */ } if (!data_left_to_queue) { queue_filled = 1; /* ok, we can start to read the queued buffer(s) - all read requests are send */ } } if (queue_filled) /* queue filled, ok we can read data */ { status = umax_wait_queued_image_data(dev, bufnr_read); if (status == -1) { DBG(DBG_error,"ERROR: umax_reader_process: unable to get image data from scanner!\n"); free(dev->pixelbuffer); dev->pixelbuffer = NULL; return(-1); } data_to_read = dev->length_read[bufnr_read]; /* number of bytes in buffer */ umax_output_image_data(dev, fp, data_to_read, bufnr_read); data_left_to_read -= data_to_read; DBG(DBG_read, "umax_reader_process: buffer of %d bytes read; %d bytes to go\n", data_to_read, data_left_to_read); /* if we did not get all requested data increase data_left_to_queue so that we get all needed data */ if (dev->length_read[bufnr_read] != dev->length_queued[bufnr_read]) { data_left_to_queue += dev->length_queued[bufnr_read] - dev->length_read[bufnr_read]; } bufnr_read++; if (bufnr_read >= dev->scsi_maxqueue) { bufnr_read = 0; } } } while (data_left_to_read); free(dev->pixelbuffer); dev->pixelbuffer = NULL; return 0; } /* ------------------------------------------------------------ UMAX INITIALIZE VALUES --------------------- */ static void umax_initialize_values(Umax_Device *dev) /* called each time before setting scan-values */ { /* Initialize dev structure */ DBG(DBG_proc,"initialize_values\n"); dev->three_pass = 0; /* 1 if threepas_mode only */ dev->row_len = -1; dev->max_value = 255; /* maximum value */ dev->wdb_len = 0; dev->width_in_pixels = 0; /* scan width in pixels */ dev->length_in_pixels = 0; /* scan length in pixels */ dev->scanwidth = 0; /* width in inch at x_coordinate_base dpi */ dev->scanlength = 0; /* length in inch at y_coordinate_base dpi */ dev->x_resolution = 0; dev->y_resolution = 0; dev->upper_left_x = 0; /* at 1200pt/inch */ dev->upper_left_y = 0; /* at 1200pt/inch */ dev->bytes_per_color = 0; /* bytes for each color */ dev->bits_per_pixel = 8; /* number of bits per pixel */ dev->bits_per_pixel_code = 1; /* 1 = 8/24 bpp, 2 = 9/27 bpp, 4 = 10/30 bpp */ dev->gamma_input_bits_code = 1; /* 8 = 12/36 bpp, 16 = 14/42 bpp, 32 = 16/48 bpp */ dev->set_auto = 0; /* 0 or 1 */ dev->preview = 0; /* 1 for preview */ dev->quality = 0; /* quality calibration */ dev->warmup = 0; /* warmup-bit */ dev->fix_focus_position = 0; /* fix focus position */ dev->lens_cal_in_doc_pos = 0; /* lens calibration in document position */ dev->disable_pre_focus = 0; /* disable pre focus */ dev->holder_focus_pos_0mm = 0; /* 0.6mm <-> 0.0mm holder focus position */ dev->manual_focus = 0; /* automatic <-> manual focus */ dev->colormode = 0; /* LINEART, HALFTONE, GRAYSCALE or RGB */ dev->adf = 0; /* 1 if adf shall be used */ dev->uta = 0; /* 1 if uta shall be used */ dev->module = WD_module_flatbed; dev->cbhs_range = WD_CBHS_255; dev->dor = 0; dev->halftone = WD_halftone_8x8_1; dev->reverse = 0; dev->reverse_multi = 0; dev->calibration = 0; dev->exposure_time_calibration_r = 0; /* use this for calibration */ dev->exposure_time_calibration_g = 0; /* use this for calibration */ dev->exposure_time_calibration_b = 0; /* use this for calibration */ dev->exposure_time_scan_r = 0; /* use this for scan */ dev->exposure_time_scan_g = 0; /* use this for scan */ dev->exposure_time_scan_b = 0; /* use this for scan */ dev->c_density = WD_lamp_c_density_auto; /* calibration lamp density */ dev->s_density = WD_lamp_s_density_auto; /* next scan lamp density */ dev->threshold = 128; /* threshold for lineart mode */ dev->brightness = 128; /* brightness for halftone mode */ dev->contrast = 128; /* contrast for halftone mode */ dev->highlight_r = 255; /* highlight gray/red */ dev->highlight_g = 255; /* highlight green */ dev->highlight_b = 255; /* highlight blue */ dev->shadow_r = 0; /* shadow gray/red */ dev->shadow_g = 0; /* shadow green */ dev->shadow_b = 0; /* shadow blue */ dev->digital_gamma_r = WD_gamma_normal; dev->digital_gamma_g = WD_gamma_normal; dev->digital_gamma_b = WD_gamma_normal; dev->analog_gamma_r = 0; /* analog gamma for red and gray to 1.0 */ dev->analog_gamma_g = 0; /* analog gamma for green to 1.0 */ dev->analog_gamma_b = 0; /* analog gamma for blue to 1.0 */ dev->pixelline_ready[0] = 0; /* reset all values for color ordering */ dev->pixelline_ready[1] = 0; dev->pixelline_ready[2] = 0; dev->pixelline_next[0] = 0; dev->pixelline_next[1] = 0; dev->pixelline_next[2] = 0; dev->pixelline_del[0] = 1; dev->pixelline_del[1] = 1; dev->pixelline_del[2] = 1; dev->pixelline_optic[0] = 1; dev->pixelline_optic[1] = 1; dev->pixelline_optic[2] = 1; dev->pixelline_max = 0; dev->pixelline_opt_res = 0; dev->pixelline_read = 0; dev->pixelline_written = 0; dev->CCD_distance = 0; dev->calib_lines = 0; /* request calibration lines */ dev->do_calibration = 0; /* no calibration by driver */ dev->do_color_ordering = 0; /* no line- to pixel-mode ordering */ dev->button0_pressed = 0; /* reset button 0 pressed flag */ dev->button1_pressed = 0; /* reset button 1 pressed flag */ dev->button2_pressed = 0; /* reset button 2 pressed flag */ } /* ------------------------------------------------------------ UMAX INIT ---------------------------------- */ static void umax_init(Umax_Device *dev) /* umax_init is called once while driver-initialization */ { DBG(DBG_proc,"init\n"); dev->devicename = NULL; dev->pixelbuffer = NULL; /* config file or predefined settings */ if (dev->connection_type == SANE_UMAX_SCSI) { dev->request_scsi_maxqueue = umax_scsi_maxqueue; } else /* SANE_UMAX_USB, USB does not support command queueing */ { DBG(DBG_info2, "setting request_scsi_maxqueue = 1 for USB connection\n"); dev->request_scsi_maxqueue = 1; } dev->request_preview_lines = umax_preview_lines; dev->request_scan_lines = umax_scan_lines; dev->handle_bad_sense_error = umax_handle_bad_sense_error; dev->execute_request_sense = umax_execute_request_sense; dev->scsi_buffer_size_min = umax_scsi_buffer_size_min; dev->scsi_buffer_size_max = umax_scsi_buffer_size_max; dev->force_preview_bit_rgb = umax_force_preview_bit_rgb; dev->slow = umax_slow; dev->smear = umax_smear; dev->calibration_area = umax_calibration_area; dev->calibration_width_offset = umax_calibration_width_offset; dev->calibration_width_offset_batch = umax_calibration_width_offset_batch; dev->calibration_bytespp = umax_calibration_bytespp; dev->exposure_time_rgb_bind = umax_exposure_time_rgb_bind; dev->invert_shading_data = umax_invert_shading_data; dev->lamp_control_available = umax_lamp_control_available; dev->gamma_lsb_padded = umax_gamma_lsb_padded; DBG(DBG_info, "request_scsi_maxqueue = %d\n", dev->request_scsi_maxqueue); DBG(DBG_info, "request_preview_lines = %d\n", dev->request_preview_lines); DBG(DBG_info, "request_scan_lines = %d\n", dev->request_scan_lines); DBG(DBG_info, "handle_bad_sense_error = %d\n", dev->handle_bad_sense_error); DBG(DBG_info, "execute_request_sense = %d\n", dev->execute_request_sense); DBG(DBG_info, "scsi_buffer_size_min = %d\n", dev->scsi_buffer_size_min); DBG(DBG_info, "scsi_buffer_size_max = %d\n", dev->scsi_buffer_size_max); DBG(DBG_info, "force_preview_bit_rgb = %d\n", dev->force_preview_bit_rgb); DBG(DBG_info, "slow = %d\n", dev->slow); DBG(DBG_info, "smear = %d\n", dev->smear); DBG(DBG_info, "calibration_area = %d\n", dev->calibration_area); DBG(DBG_info, "calibration_width_offset = %d\n", dev->calibration_width_offset); DBG(DBG_info, "calibration_width_offset_batch = %d\n", dev->calibration_width_offset_batch); DBG(DBG_info, "calibration_bytespp = %d\n", dev->calibration_bytespp); DBG(DBG_info, "exposure_time_rgb_bind = %d\n", dev->exposure_time_rgb_bind); DBG(DBG_info, "invert_shading_data = %d\n", dev->invert_shading_data); DBG(DBG_info, "lamp_control_available = %d\n", dev->lamp_control_available); dev->inquiry_len = 0; dev->inquiry_wdb_len = -1; dev->inquiry_optical_res = -1; dev->inquiry_x_res = -1; dev->inquiry_y_res = -1; dev->inquiry_fb_width = -1; dev->inquiry_fb_length = -1; dev->inquiry_uta_width = -1; dev->inquiry_uta_length = -1; dev->inquiry_dor_width = -1; dev->inquiry_dor_length = -1; dev->inquiry_exposure_adj = 0; dev->inquiry_exposure_time_step_unit = -1; /* exposure time unit in micro sec */ dev->inquiry_exposure_time_max = -1; /* exposure time maximum */ dev->inquiry_exposure_time_l_min = -1; /* exposure time minimum for lineart */ dev->inquiry_exposure_time_l_fb_def = -1; /* exposure time default for lineart flatbed */ dev->inquiry_exposure_time_l_uta_def = -1; /* exposure time default for lineart uta */ dev->inquiry_exposure_time_h_min = -1; /* exposure time minimum for halftone */ dev->inquiry_exposure_time_h_fb_def = -1; /* exposure time default for halftone flatbed */ dev->inquiry_exposure_time_h_uta_def = -1; /* exposure time default for halftone uta */ dev->inquiry_exposure_time_g_min = -1; /* exposure time minimum for grayscale */ dev->inquiry_exposure_time_g_fb_def = -1; /* exposure time default for grayscale flatbed */ dev->inquiry_exposure_time_g_uta_def = -1; /* exposure time default for grayscale uta */ dev->inquiry_exposure_time_c_min = -1; /* exposure time minimum for color */ dev->inquiry_exposure_time_c_fb_def_r = -1; /* exposure time default for color flatbed red */ dev->inquiry_exposure_time_c_fb_def_g = -1; /* exposure time default for color flatbed green */ dev->inquiry_exposure_time_c_fb_def_b = -1; /* exposure time default for color flatbed blue */ dev->inquiry_exposure_time_c_uta_def_r = -1; /* exposure time default for color uta red */ dev->inquiry_exposure_time_c_uta_def_g = -1; /* exposure time default for color uta green */ dev->inquiry_exposure_time_c_uta_def_b = -1; /* exposure time default for color uta blue */ dev->inquiry_max_warmup_time = 0; /* maximum warmup time */ dev->inquiry_cbhs = WD_CBHS_255; dev->inquiry_contrast_min = 1; /* minimum value for c */ dev->inquiry_contrast_max = 255; /* maximum value for c */ dev->inquiry_brightness_min = 1; /* minimum value for b */ dev->inquiry_brightness_max = 255; /* maximum value for b */ dev->inquiry_threshold_min = 1; /* minimum value for t */ dev->inquiry_threshold_max = 255; /* maximum value for t */ dev->inquiry_highlight_min = 1; /* minimum value for h */ dev->inquiry_highlight_max = 255; /* maximum value for h */ dev->inquiry_shadow_min = 0; /* minimum value for s */ dev->inquiry_shadow_max = 254; /* maximum value for s */ dev->inquiry_quality_ctrl = 0; dev->inquiry_preview = 0; dev->inquiry_lamp_ctrl = 0; dev->inquiry_transavail = 0; dev->inquiry_uta = 0; dev->inquiry_adfmode = 0; dev->inquiry_adf = 0; dev->inquiry_dor = 0; dev->inquiry_reverse = 0; dev->inquiry_reverse_multi = 0; dev->inquiry_analog_gamma = 0; dev->inquiry_gamma_dwload = 0; dev->inquiry_one_pass_color = 0; dev->inquiry_three_pass_color = 0; dev->inquiry_color = 0; dev->inquiry_gray = 0; dev->inquiry_halftone = 0; dev->inquiry_lineart = 0; dev->inquiry_calibration = 1; dev->inquiry_shadow = 0; dev->inquiry_highlight = 0; dev->inquiry_gamma_DCF = -1; dev->inquiry_max_calib_lines = 66; /* most scanners use 66 lines, so lets define it as default */ dev->common_xy_resolutions = 0; dev->x_coordinate_base = 1200; /* these are the 1200pt/inch */ dev->y_coordinate_base = 1200; /* these are the 1200pt/inch */ dev->button0_pressed = 0; /* reset button 0 pressed flag */ dev->button1_pressed = 0; /* reset button 1 pressed flag */ dev->button2_pressed = 0; /* reset button 2 pressed flag */ dev->pause_for_color_calibration = 0; /* pause between start_scan and do_calibration in ms */ dev->pause_for_gray_calibration = 0; /* pause between start_scan and do_calibration in ms */ dev->pause_after_calibration = 0; /* pause between do_calibration and read data in ms */ dev->pause_after_reposition = -1; /* pause after repostion scanner in ms, -1 = do not wait */ dev->pause_for_moving = 0; /* pause for moving scanhead over full area */ if (umax_test_little_endian() == SANE_TRUE) { dev->low_byte_first = 1; /* in 2 byte mode send lowbyte first */ DBG(DBG_info, "backend runs on little endian machine\n"); } else { dev->low_byte_first = 0; /* in 2 byte mode send highbyte first */ DBG(DBG_info, "backend runs on big endian machine\n"); } #ifdef HAVE_SANEI_SCSI_OPEN_EXTENDED DBG(DBG_info,"variable scsi buffer size (usage of sanei_scsi_open_extended)\n"); #else DBG(DBG_info,"fixed scsi buffer size = %d bytes\n", sanei_scsi_max_request_size); #endif } /* ------------------------------------------------------------ MAX STRING SIZE ---------------------------- */ static size_t max_string_size(SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) { max_size = size; } } return max_size; } /* ------------------------------------------------------------ DO CANCEL ---------------------------------- */ static SANE_Status do_cancel(Umax_Scanner *scanner) { SANE_Pid pid; int status; DBG(DBG_sane_proc,"do_cancel\n"); scanner->scanning = SANE_FALSE; 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 (!sanei_thread_is_valid (pid)) { DBG(DBG_sane_info, "do_cancel: sanei_thread_waitpid failed, already terminated ? (%s)\n", strerror(errno)); } else { DBG(DBG_sane_info, "do_cancel: reader_process terminated with status: %s\n", sane_strstatus(status)); } sanei_thread_invalidate (scanner->reader_pid); if (scanner->device->pixelbuffer != NULL) /* pixelbuffer exists? */ { free(scanner->device->pixelbuffer); /* free pixelbuffer */ scanner->device->pixelbuffer = NULL; } } sanei_scsi_req_flush_all(); /* flush SCSI queue, when we do not do this then sanei_scsi crashes next time */ if (scanner->device->sfd != -1) /* make sure we have a working filedescriptor */ { umax_give_scanner(scanner->device); /* reposition and release scanner */ DBG(DBG_sane_info,"closing scannerdevice filedescriptor\n"); umax_scsi_close(scanner->device); } scanner->device->three_pass_color = 1; /* reset color in color scanning */ return SANE_STATUS_CANCELLED; } /* ------------------------------------------------------------ ATTACH SCANNER ----------------------------- */ static SANE_Status attach_scanner(const char *devicename, Umax_Device **devp, int connection_type) { Umax_Device *dev; int i; DBG(DBG_sane_proc,"attach_scanner: %s, connection_type %d\n", devicename, connection_type); for (dev = first_dev; dev; dev = dev->next) /* search is scanner already is listed in devicelist */ { if (strcmp(dev->sane.name, devicename) == 0) /* scanner is already listed */ { if (devp) { *devp = dev; /* return pointer to device */ } return SANE_STATUS_GOOD; } } /* scanner has not been attached yet */ dev = malloc( sizeof(*dev) ); if (!dev) { return SANE_STATUS_NO_MEM; } memset(dev, '\0', sizeof(Umax_Device)); /* clear structure */ /* If connection type is not known (==0) then try to open the device as an USB device. */ /* If it fails, try the SCSI method. */ #ifdef UMAX_ENABLE_USB dev->connection_type = connection_type; /* 0 = unknown, 1=scsi, 2=usb */ if (dev->connection_type != SANE_UMAX_SCSI) { dev->bufsize = 16384; /* 16KB */ DBG(DBG_info, "attach_scanner: opening usb device %s\n", devicename); if (sanei_umaxusb_open(devicename, &dev->sfd, sense_handler, dev) == SANE_STATUS_GOOD) { dev->connection_type = SANE_UMAX_USB; } else /* opening usb device failed */ { if (dev->connection_type == SANE_UMAX_USB) /* we know it is not a scsi device: error */ { DBG(DBG_error, "ERROR: attach_scanner: opening usb device %s failed\n", devicename); free(dev); return SANE_STATUS_INVAL; } DBG(DBG_info, "attach_scanner: failed to open %s as usb device\n", devicename); } } #else dev->connection_type = SANE_UMAX_SCSI; #endif if (dev->connection_type != SANE_UMAX_USB) /* not an USB device, then try as SCSI */ { #ifdef HAVE_SANEI_SCSI_OPEN_EXTENDED dev->bufsize = 16384; /* 16KB */ DBG(DBG_info, "attach_scanner: opening scsi device %s\n", devicename); if (sanei_scsi_open_extended(devicename, &dev->sfd, sense_handler, dev, (int *) &dev->bufsize) != 0) { DBG(DBG_error, "ERROR: attach_scanner: opening scsi device %s failed\n", devicename); free(dev); return SANE_STATUS_INVAL; } if (dev->bufsize < 4096) /* < 4KB */ { DBG(DBG_error, "ERROR: attach_scanner: sanei_scsi_open_extended returned too small scsi buffer\n"); umax_scsi_close(dev); free(dev); return SANE_STATUS_NO_MEM; } DBG(DBG_info, "attach_scanner: sanei_scsi_open_extended returned scsi buffer size = %d\n", dev->bufsize); #else dev->bufsize = sanei_scsi_max_request_size; if (sanei_scsi_open(devicename, dev, sense_handler, dev) != 0) { DBG(DBG_error, "ERROR: attach_scanner: opening scsi device %s failed\n", devicename); free(dev); return SANE_STATUS_INVAL; } #endif dev->connection_type = SANE_UMAX_SCSI; /* set connection type (may have been unknown == 0) */ } DBG(DBG_info, "attach_scanner: allocating SCSI buffer[0]\n"); dev->buffer[0] = malloc(dev->bufsize); /* allocate buffer */ for (i=1; ibuffer[i] = NULL; } if (!dev->buffer[0]) /* malloc failed */ { DBG(DBG_error, "ERROR: attach scanner: could not allocate buffer[0]\n"); umax_scsi_close(dev); free(dev); return SANE_STATUS_NO_MEM; } dev->scsi_maxqueue = 1; /* only one buffer outside the reader process */ umax_init(dev); /* preset values in structure dev */ umax_initialize_values(dev); /* reset values */ dev->devicename = strdup(devicename); if (umax_identify_scanner(dev) != 0) { DBG(DBG_error, "ERROR: attach_scanner: scanner-identification failed\n"); umax_scsi_close(dev); free(dev->buffer[0]); free(dev); return SANE_STATUS_INVAL; } if (dev->slow == -1) /* option is not predefined in umax.conf and not by backend */ { dev->slow = 0; } if (dev->smear == -1) /* option is not predefined in umax.conf and not by backend */ { dev->smear = 0; } if (dev->invert_shading_data == -1) /* nothing defined in umax.conf and not by backend */ { dev->invert_shading_data = 0; } if (dev->gamma_lsb_padded == -1) /* nothing defined in umax.conf and not by backend */ { dev->gamma_lsb_padded = 0; } umax_get_inquiry_values(dev); umax_print_inquiry(dev); DBG(DBG_inquiry,"\n"); DBG(DBG_inquiry,"==================== end of inquiry ====================\n"); DBG(DBG_inquiry,"\n"); umax_scsi_close(dev); dev->sane.name = dev->devicename; dev->sane.vendor = dev->vendor; dev->sane.model = dev->product; dev->sane.type = "flatbed scanner"; if (strcmp(dev->sane.model,"PSD ") == 0) { dev->sane.type = "page scanner"; } dev->x_range.min = SANE_FIX(0); dev->x_range.quant = SANE_FIX(0); dev->x_range.max = SANE_FIX(dev->inquiry_fb_width * MM_PER_INCH); dev->y_range.min = SANE_FIX(0); dev->y_range.quant = SANE_FIX(0); dev->y_range.max = SANE_FIX(dev->inquiry_fb_length * MM_PER_INCH); #if UMAX_RESOLUTION_PERCENT_STEP dev->x_dpi_range.min = SANE_FIX(dev->inquiry_optical_res/100); dev->x_dpi_range.quant = SANE_FIX(dev->inquiry_optical_res/100); #else dev->x_dpi_range.min = SANE_FIX(5); dev->x_dpi_range.quant = SANE_FIX(5); #endif dev->x_dpi_range.max = SANE_FIX(dev->inquiry_x_res); #if UMAX_RESOLUTION_PERCENT_STEP dev->y_dpi_range.min = SANE_FIX(dev->inquiry_optical_res/100); dev->y_dpi_range.quant = SANE_FIX(dev->inquiry_optical_res/100); #else dev->y_dpi_range.min = SANE_FIX(5); dev->y_dpi_range.quant = SANE_FIX(5); #endif dev->y_dpi_range.max = SANE_FIX(dev->inquiry_y_res); dev->analog_gamma_range.min = SANE_FIX(1.0); dev->analog_gamma_range.quant = SANE_FIX(0.01); dev->analog_gamma_range.max = SANE_FIX(2.0); DBG(DBG_info,"x_range.max = %f\n", SANE_UNFIX(dev->x_range.max)); DBG(DBG_info,"y_range.max = %f\n", SANE_UNFIX(dev->y_range.max)); DBG(DBG_info,"x_dpi_range.max = %f\n", SANE_UNFIX(dev->x_dpi_range.max)); DBG(DBG_info,"y_dpi_range.max = %f\n", SANE_UNFIX(dev->y_dpi_range.max)); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) { *devp = dev; } return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ READER PROCESS SIGTERM HANDLER ------------ */ static void reader_process_sigterm_handler(int signal) { DBG(DBG_sane_info,"reader_process: terminated by signal %d\n", signal); sanei_scsi_req_flush_all(); /* flush SCSI queue */ _exit (SANE_STATUS_GOOD); } /* ------------------------------------------------------------ READER PROCESS ----------------------------- */ static int reader_process(void *data) /* executed as a child process or as thread */ { Umax_Scanner *scanner = (Umax_Scanner *)data; FILE *fp; int status; unsigned int data_length; struct SIGACTION act; unsigned int i; if (sanei_thread_is_forked()) { DBG(DBG_sane_proc,"reader_process started (forked)\n"); close(scanner->pipe_read_fd); scanner->pipe_read_fd = -1; /* sanei_scsi crashes when the scsi commands are not flushed, done in reader_process_sigterm_handler */ memset(&act, 0, sizeof (act)); /* define SIGTERM-handler */ act.sa_handler = reader_process_sigterm_handler; sigaction(SIGTERM, &act, 0); } else { DBG(DBG_sane_proc,"reader_process started (as thread)\n"); } scanner->device->scsi_maxqueue = scanner->device->request_scsi_maxqueue; if (scanner->device->request_scsi_maxqueue > 1) { for (i = 1; idevice->buffer[i]) { DBG(DBG_info, "reader_process: freeing SCSI buffer[%d]\n", i); free(scanner->device->buffer[i]); /* free buffer */ scanner->device->buffer[i] = NULL; } } for (i = 1; idevice->request_scsi_maxqueue; i++) { DBG(DBG_info, "reader_process: allocating SCSI buffer[%d]\n", i); scanner->device->buffer[i] = malloc(scanner->device->bufsize); /* allocate buffer */ if (!scanner->device->buffer[i]) /* malloc failed */ { DBG(DBG_warning, "WARNING: reader_process: only allocated %d/%d scsi buffers\n", i, scanner->device->request_scsi_maxqueue); scanner->device->scsi_maxqueue = i; break; /* leave for loop */ } } } data_length = scanner->params.lines * scanner->params.bytes_per_line; fp = fdopen(scanner->pipe_write_fd, "w"); if (!fp) { return SANE_STATUS_IO_ERROR; } DBG(DBG_sane_info,"reader_process: starting to READ data\n"); status = umax_reader_process(scanner->device, fp, data_length); fclose(fp); /* close write end of pipe */ for (i = 1; idevice->request_scsi_maxqueue; i++) { if (scanner->device->buffer[i]) { DBG(DBG_info, "reader_process: freeing SCSI buffer[%d]\n", i); free(scanner->device->buffer[i]); /* free buffer */ scanner->device->buffer[i] = NULL; } } DBG(DBG_sane_info,"reader_process: finished reading data\n"); return status; } /* ------------------------------------------------------------ INIT OPTIONS ------------------------------- */ static SANE_Status init_options(Umax_Scanner *scanner) { int i; int scan_modes; int bit_depths; DBG(DBG_sane_proc,"init_options\n"); memset(scanner->opt, 0, sizeof (scanner->opt)); memset(scanner->val, 0, sizeof (scanner->val)); for (i = 0; i < NUM_OPTIONS; ++i) { scanner->opt[i].size = sizeof (SANE_Word); scanner->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } scanner->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; /* empty string */ scanner->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; scanner->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; scanner->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; scanner->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; scanner->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ scanner->opt[OPT_MODE_GROUP].title = SANE_I18N("Scan Mode"); scanner->opt[OPT_MODE_GROUP].desc = ""; scanner->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_MODE_GROUP].cap = 0; scanner->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; scan_modes = -1; if (scanner->device->inquiry_lineart) { scan_mode_list[++scan_modes] = LINEART_STR; } if (scanner->device->inquiry_halftone) { scan_mode_list[++scan_modes]= HALFTONE_STR; } if (scanner->device->inquiry_gray) { scan_mode_list[++scan_modes]= GRAY_STR; } if (scanner->device->inquiry_color) { /* if (scanner->device->inquiry_lineart) { scan_mode_list[++scan_modes]= COLOR_LINEART_STR; } if (scanner->device->inquiry_halftone) { scan_mode_list[++scan_modes]= COLOR_HALFTONE_STR; } */ scan_mode_list[++scan_modes]= COLOR_STR; } scan_mode_list[scan_modes + 1] = 0; { int i=0; source_list[i++]= FLB_STR; if (scanner->device->inquiry_adfmode) { source_list[i++] = ADF_STR; } if (scanner->device->inquiry_transavail) { source_list[i++] = UTA_STR; } source_list[i] = 0; } /* scan mode */ scanner->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; scanner->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; scanner->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; scanner->opt[OPT_MODE].type = SANE_TYPE_STRING; scanner->opt[OPT_MODE].size = max_string_size((SANE_String_Const *) scan_mode_list); scanner->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_MODE].constraint.string_list = (SANE_String_Const *) scan_mode_list; scanner->val[OPT_MODE].s = (SANE_Char*)strdup(scan_mode_list[0]); /* source */ scanner->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; scanner->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; scanner->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; scanner->opt[OPT_SOURCE].type = SANE_TYPE_STRING; scanner->opt[OPT_SOURCE].size = max_string_size(source_list); scanner->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_SOURCE].constraint.string_list = source_list; scanner->val[OPT_SOURCE].s = (SANE_Char*)strdup(source_list[0]); /* x-resolution */ scanner->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; scanner->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; scanner->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; scanner->opt[OPT_X_RESOLUTION].type = SANE_TYPE_FIXED; scanner->opt[OPT_X_RESOLUTION].unit = SANE_UNIT_DPI; scanner->opt[OPT_X_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_X_RESOLUTION].constraint.range = &scanner->device->x_dpi_range; scanner->val[OPT_X_RESOLUTION].w = 100 << SANE_FIXED_SCALE_SHIFT; /* y-resolution */ scanner->opt[OPT_Y_RESOLUTION].name = SANE_NAME_SCAN_Y_RESOLUTION; scanner->opt[OPT_Y_RESOLUTION].title = SANE_TITLE_SCAN_Y_RESOLUTION; scanner->opt[OPT_Y_RESOLUTION].desc = SANE_DESC_SCAN_Y_RESOLUTION; scanner->opt[OPT_Y_RESOLUTION].type = SANE_TYPE_FIXED; scanner->opt[OPT_Y_RESOLUTION].unit = SANE_UNIT_DPI; scanner->opt[OPT_Y_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_Y_RESOLUTION].constraint.range = &scanner->device->y_dpi_range; scanner->val[OPT_Y_RESOLUTION].w = 100 << SANE_FIXED_SCALE_SHIFT; scanner->opt[OPT_Y_RESOLUTION].cap |= SANE_CAP_INACTIVE; /* bind resolution */ scanner->opt[OPT_RESOLUTION_BIND].name = SANE_NAME_RESOLUTION_BIND; scanner->opt[OPT_RESOLUTION_BIND].title = SANE_TITLE_RESOLUTION_BIND; scanner->opt[OPT_RESOLUTION_BIND].desc = SANE_DESC_RESOLUTION_BIND; scanner->opt[OPT_RESOLUTION_BIND].type = SANE_TYPE_BOOL; scanner->val[OPT_RESOLUTION_BIND].w = SANE_TRUE; if (scanner->device->common_xy_resolutions) /* disable bind if x and y res have to be the same */ { scanner->opt[OPT_RESOLUTION_BIND].cap |= SANE_CAP_INACTIVE; } /* negative */ scanner->opt[OPT_NEGATIVE].name = SANE_NAME_NEGATIVE; scanner->opt[OPT_NEGATIVE].title = SANE_TITLE_NEGATIVE; scanner->opt[OPT_NEGATIVE].desc = SANE_DESC_NEGATIVE; scanner->opt[OPT_NEGATIVE].type = SANE_TYPE_BOOL; scanner->val[OPT_NEGATIVE].w = SANE_FALSE; if (scanner->device->inquiry_reverse_multi == 0) { scanner->opt[OPT_NEGATIVE].cap |= SANE_CAP_INACTIVE; } /* ------------------------------ */ /* "Geometry" group: */ scanner->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N("Geometry"); scanner->opt[OPT_GEOMETRY_GROUP].desc = ""; scanner->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; scanner->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ scanner->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; scanner->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; scanner->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; scanner->opt[OPT_TL_X].type = SANE_TYPE_FIXED; scanner->opt[OPT_TL_X].unit = SANE_UNIT_MM; scanner->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_TL_X].constraint.range = &(scanner->device->x_range); scanner->val[OPT_TL_X].w = 0; /* top-left y */ scanner->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; scanner->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; scanner->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; scanner->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; scanner->opt[OPT_TL_Y].unit = SANE_UNIT_MM; scanner->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_TL_Y].constraint.range = &(scanner->device->y_range); scanner->val[OPT_TL_Y].w = 0; /* bottom-right x */ scanner->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; scanner->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; scanner->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; scanner->opt[OPT_BR_X].type = SANE_TYPE_FIXED; scanner->opt[OPT_BR_X].unit = SANE_UNIT_MM; scanner->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BR_X].constraint.range = &(scanner->device->x_range); scanner->val[OPT_BR_X].w = scanner->device->x_range.max; /* bottom-right y */ scanner->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; scanner->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; scanner->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; scanner->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; scanner->opt[OPT_BR_Y].unit = SANE_UNIT_MM; scanner->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BR_Y].constraint.range = &(scanner->device->y_range); scanner->val[OPT_BR_Y].w = scanner->device->y_range.max; /* ------------------------------ */ /* "Enhancement" group: */ scanner->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N("Enhancement"); scanner->opt[OPT_ENHANCEMENT_GROUP].desc = ""; scanner->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_ENHANCEMENT_GROUP].cap = 0; scanner->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* bit depth */ bit_depths = 0; if (scanner->device->inquiry_GOB & 1) { bit_depth_list[++bit_depths] = 8; } if (scanner->device->inquiry_GOB & 2) { bit_depth_list[++bit_depths] = 9; } if (scanner->device->inquiry_GOB & 4) { bit_depth_list[++bit_depths] = 10; } if (scanner->device->inquiry_GOB & 8) { bit_depth_list[++bit_depths] = 12; } if (scanner->device->inquiry_GOB & 16) { bit_depth_list[++bit_depths] = 14; } if (scanner->device->inquiry_GOB & 32) { bit_depth_list[++bit_depths] = 16; } bit_depth_list[0] = bit_depths; scanner->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; scanner->opt[OPT_BIT_DEPTH].unit = SANE_UNIT_BIT; scanner->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; scanner->opt[OPT_BIT_DEPTH].constraint.word_list = bit_depth_list; scanner->val[OPT_BIT_DEPTH].w = bit_depth_list[1]; /* quality-calibration */ scanner->opt[OPT_QUALITY].name = SANE_NAME_QUALITY_CAL; scanner->opt[OPT_QUALITY].title = SANE_TITLE_QUALITY_CAL; scanner->opt[OPT_QUALITY].desc = SANE_DESC_QUALITY_CAL; scanner->opt[OPT_QUALITY].type = SANE_TYPE_BOOL; scanner->val[OPT_QUALITY].w = SANE_FALSE; if ((scanner->device->inquiry_quality_ctrl == 0) || (scanner->device->force_quality_calibration) ) { scanner->opt[OPT_QUALITY].cap |= SANE_CAP_INACTIVE; } else /* enable quality calibration when available */ { scanner->val[OPT_QUALITY].w = SANE_TRUE; } /* double optical resolution */ scanner->opt[OPT_DOR].name = SANE_NAME_DOR; scanner->opt[OPT_DOR].title = SANE_TITLE_DOR; scanner->opt[OPT_DOR].desc = SANE_DESC_DOR; scanner->opt[OPT_DOR].type = SANE_TYPE_BOOL; scanner->val[OPT_DOR].w = SANE_FALSE; if (scanner->device->inquiry_dor == 0) { scanner->opt[OPT_DOR].cap |= SANE_CAP_INACTIVE; } /* warmup */ scanner->opt[OPT_WARMUP].name = SANE_NAME_WARMUP; scanner->opt[OPT_WARMUP].title = SANE_TITLE_WARMUP; scanner->opt[OPT_WARMUP].desc = SANE_DESC_WARMUP; scanner->opt[OPT_WARMUP].type = SANE_TYPE_BOOL; scanner->val[OPT_WARMUP].w = SANE_FALSE; if (scanner->device->inquiry_max_warmup_time == 0) { scanner->opt[OPT_WARMUP].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_RGB_BIND].name = SANE_NAME_RGB_BIND; scanner->opt[OPT_RGB_BIND].title = SANE_TITLE_RGB_BIND; scanner->opt[OPT_RGB_BIND].desc = SANE_DESC_RGB_BIND; scanner->opt[OPT_RGB_BIND].type = SANE_TYPE_BOOL; scanner->val[OPT_RGB_BIND].w = SANE_FALSE; /* brightness */ scanner->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; scanner->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; scanner->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; scanner->opt[OPT_BRIGHTNESS].type = SANE_TYPE_FIXED; scanner->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BRIGHTNESS].constraint.range = &percentage_range; scanner->val[OPT_BRIGHTNESS].w = 0; /* contrast */ scanner->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; scanner->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; scanner->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; scanner->opt[OPT_CONTRAST].type = SANE_TYPE_FIXED; scanner->opt[OPT_CONTRAST].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_CONTRAST].constraint.range = &percentage_range; scanner->val[OPT_CONTRAST].w = 0; /* threshold */ scanner->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; scanner->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; scanner->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; scanner->opt[OPT_THRESHOLD].type = SANE_TYPE_FIXED; scanner->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_THRESHOLD].constraint.range = &percentage_range_100; scanner->val[OPT_THRESHOLD].w = SANE_FIX(50); /* ------------------------------ */ /* highlight, white level */ scanner->opt[OPT_HIGHLIGHT].name = SANE_NAME_HIGHLIGHT; scanner->opt[OPT_HIGHLIGHT].title = SANE_TITLE_HIGHLIGHT; scanner->opt[OPT_HIGHLIGHT].desc = SANE_DESC_HIGHLIGHT; scanner->opt[OPT_HIGHLIGHT].type = SANE_TYPE_FIXED; scanner->opt[OPT_HIGHLIGHT].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_HIGHLIGHT].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_HIGHLIGHT].constraint.range = &percentage_range_100; scanner->val[OPT_HIGHLIGHT].w = SANE_FIX(100); scanner->opt[OPT_HIGHLIGHT_R].name = SANE_NAME_HIGHLIGHT_R; scanner->opt[OPT_HIGHLIGHT_R].title = SANE_TITLE_HIGHLIGHT_R; scanner->opt[OPT_HIGHLIGHT_R].desc = SANE_DESC_HIGHLIGHT_R; scanner->opt[OPT_HIGHLIGHT_R].type = SANE_TYPE_FIXED; scanner->opt[OPT_HIGHLIGHT_R].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_HIGHLIGHT_R].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_HIGHLIGHT_R].constraint.range = &percentage_range_100; scanner->val[OPT_HIGHLIGHT_R].w = SANE_FIX(100); scanner->opt[OPT_HIGHLIGHT_G].name = SANE_NAME_HIGHLIGHT_G; scanner->opt[OPT_HIGHLIGHT_G].title = SANE_TITLE_HIGHLIGHT_G; scanner->opt[OPT_HIGHLIGHT_G].desc = SANE_DESC_HIGHLIGHT_G; scanner->opt[OPT_HIGHLIGHT_G].type = SANE_TYPE_FIXED; scanner->opt[OPT_HIGHLIGHT_G].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_HIGHLIGHT_G].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_HIGHLIGHT_G].constraint.range = &percentage_range_100; scanner->val[OPT_HIGHLIGHT_G].w = SANE_FIX(100); scanner->opt[OPT_HIGHLIGHT_B].name = SANE_NAME_HIGHLIGHT_B; scanner->opt[OPT_HIGHLIGHT_B].title = SANE_TITLE_HIGHLIGHT_B; scanner->opt[OPT_HIGHLIGHT_B].desc = SANE_DESC_HIGHLIGHT_B; scanner->opt[OPT_HIGHLIGHT_B].type = SANE_TYPE_FIXED; scanner->opt[OPT_HIGHLIGHT_B].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_HIGHLIGHT_B].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_HIGHLIGHT_B].constraint.range = &percentage_range_100; scanner->val[OPT_HIGHLIGHT_B].w = SANE_FIX(100); /* shadow, black level */ scanner->opt[OPT_SHADOW].name = SANE_NAME_SHADOW; scanner->opt[OPT_SHADOW].title = SANE_TITLE_SHADOW; scanner->opt[OPT_SHADOW].desc = SANE_DESC_SHADOW; scanner->opt[OPT_SHADOW].type = SANE_TYPE_FIXED; scanner->opt[OPT_SHADOW].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_SHADOW].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SHADOW].constraint.range = &percentage_range_100; scanner->val[OPT_SHADOW].w = 0; scanner->opt[OPT_SHADOW_R].name = SANE_NAME_SHADOW_R; scanner->opt[OPT_SHADOW_R].title = SANE_TITLE_SHADOW_R; scanner->opt[OPT_SHADOW_R].desc = SANE_DESC_SHADOW_R; scanner->opt[OPT_SHADOW_R].type = SANE_TYPE_FIXED; scanner->opt[OPT_SHADOW_R].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_SHADOW_R].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SHADOW_R].constraint.range = &percentage_range_100; scanner->val[OPT_SHADOW_R].w = 0; scanner->opt[OPT_SHADOW_G].name = SANE_NAME_SHADOW_G; scanner->opt[OPT_SHADOW_G].title = SANE_TITLE_SHADOW_G; scanner->opt[OPT_SHADOW_G].desc = SANE_DESC_SHADOW_G; scanner->opt[OPT_SHADOW_G].type = SANE_TYPE_FIXED; scanner->opt[OPT_SHADOW_G].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_SHADOW_G].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SHADOW_G].constraint.range = &percentage_range_100; scanner->val[OPT_SHADOW_G].w = 0; scanner->opt[OPT_SHADOW_B].name = SANE_NAME_SHADOW_B; scanner->opt[OPT_SHADOW_B].title = SANE_TITLE_SHADOW_B; scanner->opt[OPT_SHADOW_B].desc = SANE_DESC_SHADOW_B; scanner->opt[OPT_SHADOW_B].type = SANE_TYPE_FIXED; scanner->opt[OPT_SHADOW_B].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_SHADOW_B].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SHADOW_B].constraint.range = &percentage_range_100; scanner->val[OPT_SHADOW_B].w = 0; /* analog-gamma */ scanner->opt[OPT_ANALOG_GAMMA].name = SANE_NAME_ANALOG_GAMMA; scanner->opt[OPT_ANALOG_GAMMA].title = SANE_TITLE_ANALOG_GAMMA; scanner->opt[OPT_ANALOG_GAMMA].desc = SANE_DESC_ANALOG_GAMMA; scanner->opt[OPT_ANALOG_GAMMA].type = SANE_TYPE_FIXED; scanner->opt[OPT_ANALOG_GAMMA].unit = SANE_UNIT_NONE; scanner->opt[OPT_ANALOG_GAMMA].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_ANALOG_GAMMA].constraint.range = &(scanner->device->analog_gamma_range); scanner->val[OPT_ANALOG_GAMMA].w = 1 << SANE_FIXED_SCALE_SHIFT; scanner->opt[OPT_ANALOG_GAMMA_R].name = SANE_NAME_ANALOG_GAMMA_R; scanner->opt[OPT_ANALOG_GAMMA_R].title = SANE_TITLE_ANALOG_GAMMA_R; scanner->opt[OPT_ANALOG_GAMMA_R].desc = SANE_DESC_ANALOG_GAMMA_R; scanner->opt[OPT_ANALOG_GAMMA_R].type = SANE_TYPE_FIXED; scanner->opt[OPT_ANALOG_GAMMA_R].unit = SANE_UNIT_NONE; scanner->opt[OPT_ANALOG_GAMMA_R].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_ANALOG_GAMMA_R].constraint.range = &(scanner->device->analog_gamma_range); scanner->val[OPT_ANALOG_GAMMA_R].w = 1 << SANE_FIXED_SCALE_SHIFT; scanner->opt[OPT_ANALOG_GAMMA_G].name = SANE_NAME_ANALOG_GAMMA_G; scanner->opt[OPT_ANALOG_GAMMA_G].title = SANE_TITLE_ANALOG_GAMMA_G; scanner->opt[OPT_ANALOG_GAMMA_G].desc = SANE_DESC_ANALOG_GAMMA_G; scanner->opt[OPT_ANALOG_GAMMA_G].type = SANE_TYPE_FIXED; scanner->opt[OPT_ANALOG_GAMMA_G].unit = SANE_UNIT_NONE; scanner->opt[OPT_ANALOG_GAMMA_G].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_ANALOG_GAMMA_G].constraint.range = &(scanner->device->analog_gamma_range); scanner->val[OPT_ANALOG_GAMMA_G].w = 1 << SANE_FIXED_SCALE_SHIFT; scanner->opt[OPT_ANALOG_GAMMA_B].name = SANE_NAME_ANALOG_GAMMA_B; scanner->opt[OPT_ANALOG_GAMMA_B].title = SANE_TITLE_ANALOG_GAMMA_B; scanner->opt[OPT_ANALOG_GAMMA_B].desc = SANE_DESC_ANALOG_GAMMA_B; scanner->opt[OPT_ANALOG_GAMMA_B].type = SANE_TYPE_FIXED; scanner->opt[OPT_ANALOG_GAMMA_B].unit = SANE_UNIT_NONE; scanner->opt[OPT_ANALOG_GAMMA_B].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_ANALOG_GAMMA_B].constraint.range = &(scanner->device->analog_gamma_range); scanner->val[OPT_ANALOG_GAMMA_B].w = 1 << SANE_FIXED_SCALE_SHIFT; /* custom-gamma table */ scanner->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; scanner->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; scanner->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; scanner->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; scanner->val[OPT_CUSTOM_GAMMA].w = SANE_TRUE; /* grayscale gamma vector */ scanner->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; scanner->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; scanner->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; scanner->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; scanner->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; scanner->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; scanner->val[OPT_GAMMA_VECTOR].wa = scanner->gamma_table[0]; scanner->opt[OPT_GAMMA_VECTOR].constraint.range = &scanner->output_range; scanner->opt[OPT_GAMMA_VECTOR].size = scanner->gamma_length * sizeof(SANE_Word); scanner->output_range.min = 0; if (bit_depth_list[1] == 8) { scanner->output_range.max = 255; /* 8 bits/pixel */ } else { scanner->output_range.max = 65535; /* 9-16 bits/pixel */ } scanner->output_range.quant = 0; /* red gamma vector */ scanner->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; scanner->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; scanner->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; scanner->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; scanner->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; scanner->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; scanner->val[OPT_GAMMA_VECTOR_R].wa = scanner->gamma_table[1]; scanner->opt[OPT_GAMMA_VECTOR_R].constraint.range = &(scanner->gamma_range); scanner->opt[OPT_GAMMA_VECTOR_R].size = scanner->gamma_length * sizeof(SANE_Word); /* green gamma vector */ scanner->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; scanner->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; scanner->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; scanner->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; scanner->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; scanner->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; scanner->val[OPT_GAMMA_VECTOR_G].wa = scanner->gamma_table[2]; scanner->opt[OPT_GAMMA_VECTOR_G].constraint.range = &(scanner->gamma_range); scanner->opt[OPT_GAMMA_VECTOR_G].size = scanner->gamma_length * sizeof(SANE_Word); /* blue gamma vector */ scanner->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; scanner->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; scanner->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; scanner->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; scanner->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; scanner->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; scanner->val[OPT_GAMMA_VECTOR_B].wa = scanner->gamma_table[3]; scanner->opt[OPT_GAMMA_VECTOR_B].constraint.range = &(scanner->gamma_range); scanner->opt[OPT_GAMMA_VECTOR_B].size = scanner->gamma_length * sizeof(SANE_Word); /* halftone dimension */ scanner->opt[OPT_HALFTONE_DIMENSION].name = SANE_NAME_HALFTONE_DIMENSION; scanner->opt[OPT_HALFTONE_DIMENSION].title = SANE_TITLE_HALFTONE_DIMENSION; scanner->opt[OPT_HALFTONE_DIMENSION].desc = SANE_DESC_HALFTONE_DIMENSION; scanner->opt[OPT_HALFTONE_DIMENSION].type = SANE_TYPE_INT; scanner->opt[OPT_HALFTONE_DIMENSION].unit = SANE_UNIT_PIXEL; scanner->opt[OPT_HALFTONE_DIMENSION].constraint_type = SANE_CONSTRAINT_WORD_LIST; scanner->opt[OPT_HALFTONE_DIMENSION].constraint.word_list = pattern_dim_list; scanner->val[OPT_HALFTONE_DIMENSION].w = pattern_dim_list[1]; /* halftone pattern */ scanner->opt[OPT_HALFTONE_PATTERN].name = SANE_NAME_HALFTONE_PATTERN; scanner->opt[OPT_HALFTONE_PATTERN].title = SANE_TITLE_HALFTONE_PATTERN; scanner->opt[OPT_HALFTONE_PATTERN].desc = SANE_DESC_HALFTONE_PATTERN; scanner->opt[OPT_HALFTONE_PATTERN].type = SANE_TYPE_INT; scanner->opt[OPT_HALFTONE_PATTERN].size = 0; scanner->opt[OPT_HALFTONE_PATTERN].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_HALFTONE_PATTERN].constraint.range = &u8_range; scanner->val[OPT_HALFTONE_PATTERN].wa = scanner->halftone_pattern; /* ------------------------------ */ /* "Advanced" group: */ scanner->opt[OPT_ADVANCED_GROUP].title = SANE_I18N("Advanced"); scanner->opt[OPT_ADVANCED_GROUP].desc = ""; scanner->opt[OPT_ADVANCED_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_ADVANCED_GROUP].cap = SANE_CAP_ADVANCED; scanner->opt[OPT_ADVANCED_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* ------------------------------ */ /* select exposure time */ scanner->opt[OPT_SELECT_EXPOSURE_TIME].name = SANE_NAME_SELECT_EXPOSURE_TIME; scanner->opt[OPT_SELECT_EXPOSURE_TIME].title = SANE_TITLE_SELECT_EXPOSURE_TIME; scanner->opt[OPT_SELECT_EXPOSURE_TIME].desc = SANE_DESC_SELECT_EXPOSURE_TIME; scanner->opt[OPT_SELECT_EXPOSURE_TIME].type = SANE_TYPE_BOOL; scanner->val[OPT_SELECT_EXPOSURE_TIME].w = SANE_FALSE; /* select calibration exposure time */ scanner->opt[OPT_SELECT_CAL_EXPOSURE_TIME].name = SANE_UMAX_NAME_SELECT_CALIBRATON_EXPOSURE_TIME; scanner->opt[OPT_SELECT_CAL_EXPOSURE_TIME].title = SANE_UMAX_TITLE_SELECT_CALIBRATION_EXPOSURE_TIME; scanner->opt[OPT_SELECT_CAL_EXPOSURE_TIME].desc = SANE_UMAX_DESC_SELECT_CALIBRATION_EXPOSURE_TIME; scanner->opt[OPT_SELECT_CAL_EXPOSURE_TIME].type = SANE_TYPE_BOOL; scanner->val[OPT_SELECT_CAL_EXPOSURE_TIME].w = SANE_FALSE; scanner->opt[OPT_SELECT_CAL_EXPOSURE_TIME].cap |= SANE_CAP_INACTIVE; /* calibration exposure time */ scanner->opt[OPT_CAL_EXPOS_TIME].name = SANE_NAME_CAL_EXPOS_TIME; scanner->opt[OPT_CAL_EXPOS_TIME].title = SANE_TITLE_CAL_EXPOS_TIME; scanner->opt[OPT_CAL_EXPOS_TIME].desc = SANE_DESC_CAL_EXPOS_TIME; scanner->opt[OPT_CAL_EXPOS_TIME].type = SANE_TYPE_INT; scanner->opt[OPT_CAL_EXPOS_TIME].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_CAL_EXPOS_TIME].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_CAL_EXPOS_TIME].constraint.range = &(scanner->exposure_time_range); scanner->val[OPT_CAL_EXPOS_TIME].w = scanner->device->inquiry_exposure_time_g_fb_def * scanner->device->inquiry_exposure_time_step_unit; scanner->opt[OPT_CAL_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; /* calibration exposure time red */ scanner->opt[OPT_CAL_EXPOS_TIME_R].name = SANE_NAME_CAL_EXPOS_TIME_R; scanner->opt[OPT_CAL_EXPOS_TIME_R].title = SANE_TITLE_CAL_EXPOS_TIME_R; scanner->opt[OPT_CAL_EXPOS_TIME_R].desc = SANE_DESC_CAL_EXPOS_TIME_R; scanner->opt[OPT_CAL_EXPOS_TIME_R].type = SANE_TYPE_INT; scanner->opt[OPT_CAL_EXPOS_TIME_R].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_CAL_EXPOS_TIME_R].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_CAL_EXPOS_TIME_R].constraint.range = &(scanner->exposure_time_range); scanner->val[OPT_CAL_EXPOS_TIME_R].w = scanner->device->inquiry_exposure_time_c_fb_def_r * scanner->device->inquiry_exposure_time_step_unit; scanner->opt[OPT_CAL_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; /* calibration exposure time green */ scanner->opt[OPT_CAL_EXPOS_TIME_G].name = SANE_NAME_CAL_EXPOS_TIME_G; scanner->opt[OPT_CAL_EXPOS_TIME_G].title = SANE_TITLE_CAL_EXPOS_TIME_G; scanner->opt[OPT_CAL_EXPOS_TIME_G].desc = SANE_DESC_CAL_EXPOS_TIME_G; scanner->opt[OPT_CAL_EXPOS_TIME_G].type = SANE_TYPE_INT; scanner->opt[OPT_CAL_EXPOS_TIME_G].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_CAL_EXPOS_TIME_G].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_CAL_EXPOS_TIME_G].constraint.range = &(scanner->exposure_time_range); scanner->val[OPT_CAL_EXPOS_TIME_G].w = scanner->device->inquiry_exposure_time_c_fb_def_g * scanner->device->inquiry_exposure_time_step_unit; scanner->opt[OPT_CAL_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; /* calibration exposure time blue */ scanner->opt[OPT_CAL_EXPOS_TIME_B].name = SANE_NAME_CAL_EXPOS_TIME_B; scanner->opt[OPT_CAL_EXPOS_TIME_B].title = SANE_TITLE_CAL_EXPOS_TIME_B; scanner->opt[OPT_CAL_EXPOS_TIME_B].desc = SANE_DESC_CAL_EXPOS_TIME_B; scanner->opt[OPT_CAL_EXPOS_TIME_B].type = SANE_TYPE_INT; scanner->opt[OPT_CAL_EXPOS_TIME_B].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_CAL_EXPOS_TIME_B].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_CAL_EXPOS_TIME_B].constraint.range = &(scanner->exposure_time_range); scanner->val[OPT_CAL_EXPOS_TIME_B].w = scanner->device->inquiry_exposure_time_c_fb_def_b * scanner->device->inquiry_exposure_time_step_unit; scanner->opt[OPT_CAL_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; /* scan exposure time */ scanner->opt[OPT_SCAN_EXPOS_TIME].name = SANE_NAME_SCAN_EXPOS_TIME; scanner->opt[OPT_SCAN_EXPOS_TIME].title = SANE_TITLE_SCAN_EXPOS_TIME; scanner->opt[OPT_SCAN_EXPOS_TIME].desc = SANE_DESC_SCAN_EXPOS_TIME; scanner->opt[OPT_SCAN_EXPOS_TIME].type = SANE_TYPE_INT; scanner->opt[OPT_SCAN_EXPOS_TIME].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_SCAN_EXPOS_TIME].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SCAN_EXPOS_TIME].constraint.range = &(scanner->exposure_time_range); scanner->val[OPT_SCAN_EXPOS_TIME].w = scanner->device->inquiry_exposure_time_g_fb_def * scanner->device->inquiry_exposure_time_step_unit; scanner->opt[OPT_SCAN_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; /* scan exposure time red */ scanner->opt[OPT_SCAN_EXPOS_TIME_R].name = SANE_NAME_SCAN_EXPOS_TIME_R; scanner->opt[OPT_SCAN_EXPOS_TIME_R].title = SANE_TITLE_SCAN_EXPOS_TIME_R; scanner->opt[OPT_SCAN_EXPOS_TIME_R].desc = SANE_DESC_SCAN_EXPOS_TIME_R; scanner->opt[OPT_SCAN_EXPOS_TIME_R].type = SANE_TYPE_INT; scanner->opt[OPT_SCAN_EXPOS_TIME_R].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_SCAN_EXPOS_TIME_R].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SCAN_EXPOS_TIME_R].constraint.range = &(scanner->exposure_time_range); scanner->val[OPT_SCAN_EXPOS_TIME_R].w = scanner->device->inquiry_exposure_time_c_fb_def_r * scanner->device->inquiry_exposure_time_step_unit; scanner->opt[OPT_SCAN_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; /* scan exposure time green */ scanner->opt[OPT_SCAN_EXPOS_TIME_G].name = SANE_NAME_SCAN_EXPOS_TIME_G; scanner->opt[OPT_SCAN_EXPOS_TIME_G].title = SANE_TITLE_SCAN_EXPOS_TIME_G; scanner->opt[OPT_SCAN_EXPOS_TIME_G].desc = SANE_DESC_SCAN_EXPOS_TIME_G; scanner->opt[OPT_SCAN_EXPOS_TIME_G].type = SANE_TYPE_INT; scanner->opt[OPT_SCAN_EXPOS_TIME_G].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_SCAN_EXPOS_TIME_G].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SCAN_EXPOS_TIME_G].constraint.range = &(scanner->exposure_time_range); scanner->val[OPT_SCAN_EXPOS_TIME_G].w = scanner->device->inquiry_exposure_time_c_fb_def_g * scanner->device->inquiry_exposure_time_step_unit; scanner->opt[OPT_SCAN_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; /* scan exposure time blue */ scanner->opt[OPT_SCAN_EXPOS_TIME_B].name = SANE_NAME_SCAN_EXPOS_TIME_B; scanner->opt[OPT_SCAN_EXPOS_TIME_B].title = SANE_TITLE_SCAN_EXPOS_TIME_B; scanner->opt[OPT_SCAN_EXPOS_TIME_B].desc = SANE_DESC_SCAN_EXPOS_TIME_B; scanner->opt[OPT_SCAN_EXPOS_TIME_B].type = SANE_TYPE_INT; scanner->opt[OPT_SCAN_EXPOS_TIME_B].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_SCAN_EXPOS_TIME_B].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SCAN_EXPOS_TIME_B].constraint.range = &(scanner->exposure_time_range); scanner->val[OPT_SCAN_EXPOS_TIME_B].w = scanner->device->inquiry_exposure_time_c_fb_def_b * scanner->device->inquiry_exposure_time_step_unit; scanner->opt[OPT_SCAN_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; if (scanner->device->inquiry_exposure_adj == 0) { scanner->opt[OPT_SELECT_EXPOSURE_TIME].cap |= SANE_CAP_INACTIVE; } /* ------------------------------ */ /* select calibration lamp density */ scanner->opt[OPT_SELECT_LAMP_DENSITY].name = SANE_NAME_SELECT_LAMP_DENSITY; scanner->opt[OPT_SELECT_LAMP_DENSITY].title = SANE_TITLE_SELECT_LAMP_DENSITY; scanner->opt[OPT_SELECT_LAMP_DENSITY].desc = SANE_DESC_SELECT_LAMP_DENSITY; scanner->opt[OPT_SELECT_LAMP_DENSITY].type = SANE_TYPE_BOOL; scanner->val[OPT_SELECT_LAMP_DENSITY].w = SANE_FALSE; /* calibration lamp density */ scanner->opt[OPT_CAL_LAMP_DEN].name = SANE_NAME_CAL_LAMP_DEN; scanner->opt[OPT_CAL_LAMP_DEN].title = SANE_TITLE_CAL_LAMP_DEN; scanner->opt[OPT_CAL_LAMP_DEN].desc = SANE_DESC_CAL_LAMP_DEN; scanner->opt[OPT_CAL_LAMP_DEN].type = SANE_TYPE_FIXED; scanner->opt[OPT_CAL_LAMP_DEN].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_CAL_LAMP_DEN].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_CAL_LAMP_DEN].constraint.range = &percentage_range_100; scanner->val[OPT_CAL_LAMP_DEN].w = SANE_FIX(50); scanner->opt[OPT_CAL_LAMP_DEN].cap |= SANE_CAP_INACTIVE; /* scan lamp density */ scanner->opt[OPT_SCAN_LAMP_DEN].name = SANE_NAME_SCAN_LAMP_DEN; scanner->opt[OPT_SCAN_LAMP_DEN].title = SANE_TITLE_SCAN_LAMP_DEN; scanner->opt[OPT_SCAN_LAMP_DEN].desc = SANE_DESC_SCAN_LAMP_DEN; scanner->opt[OPT_SCAN_LAMP_DEN].type = SANE_TYPE_FIXED; scanner->opt[OPT_SCAN_LAMP_DEN].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_SCAN_LAMP_DEN].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_SCAN_LAMP_DEN].constraint.range = &percentage_range_100; scanner->val[OPT_SCAN_LAMP_DEN].w = SANE_FIX(50); scanner->opt[OPT_SCAN_LAMP_DEN].cap |= SANE_CAP_INACTIVE; if (scanner->device->inquiry_lamp_ctrl == 0) { scanner->opt[OPT_SELECT_LAMP_DENSITY].cap |= SANE_CAP_INACTIVE; } /* ------------------------------ */ /* disable pre focus */ scanner->opt[OPT_DISABLE_PRE_FOCUS].name = "disable-pre-focus"; scanner->opt[OPT_DISABLE_PRE_FOCUS].title = SANE_I18N("Disable pre focus"); scanner->opt[OPT_DISABLE_PRE_FOCUS].desc = SANE_I18N("Do not calibrate focus"); scanner->opt[OPT_DISABLE_PRE_FOCUS].type = SANE_TYPE_BOOL; scanner->val[OPT_DISABLE_PRE_FOCUS].w = SANE_FALSE; if (scanner->device->inquiry_manual_focus == 0) { scanner->opt[OPT_DISABLE_PRE_FOCUS].cap |= SANE_CAP_INACTIVE; } /* manual pre focus */ scanner->opt[OPT_MANUAL_PRE_FOCUS].name = "manual-pre-focus"; scanner->opt[OPT_MANUAL_PRE_FOCUS].title = SANE_I18N("Manual pre focus"); scanner->opt[OPT_MANUAL_PRE_FOCUS].desc = ""; scanner->opt[OPT_MANUAL_PRE_FOCUS].type = SANE_TYPE_BOOL; scanner->val[OPT_MANUAL_PRE_FOCUS].w = SANE_FALSE; if (scanner->device->inquiry_manual_focus == 0) { scanner->opt[OPT_MANUAL_PRE_FOCUS].cap |= SANE_CAP_INACTIVE; } /* fix focus position */ scanner->opt[OPT_FIX_FOCUS_POSITION].name = "fix-focus-position"; scanner->opt[OPT_FIX_FOCUS_POSITION].title = SANE_I18N("Fix focus position"); scanner->opt[OPT_FIX_FOCUS_POSITION].desc = ""; scanner->opt[OPT_FIX_FOCUS_POSITION].type = SANE_TYPE_BOOL; scanner->val[OPT_FIX_FOCUS_POSITION].w = SANE_FALSE; if (scanner->device->inquiry_manual_focus == 0) { scanner->opt[OPT_FIX_FOCUS_POSITION].cap |= SANE_CAP_INACTIVE; } /* lens calibration in doc position */ scanner->opt[OPT_LENS_CALIBRATION_DOC_POS].name = "lens-calibration-in-doc-position"; scanner->opt[OPT_LENS_CALIBRATION_DOC_POS].title = SANE_I18N("Lens calibration in doc position"); scanner->opt[OPT_LENS_CALIBRATION_DOC_POS].desc = SANE_I18N("Calibrate lens focus in document position"); scanner->opt[OPT_LENS_CALIBRATION_DOC_POS].type = SANE_TYPE_BOOL; scanner->val[OPT_LENS_CALIBRATION_DOC_POS].w = SANE_FALSE; if (scanner->device->inquiry_lens_cal_in_doc_pos == 0) { scanner->opt[OPT_LENS_CALIBRATION_DOC_POS].cap |= SANE_CAP_INACTIVE; } /* 0mm holder focus position */ scanner->opt[OPT_HOLDER_FOCUS_POS_0MM].name = "holder-focus-position-0mm"; scanner->opt[OPT_HOLDER_FOCUS_POS_0MM].title = SANE_I18N("Holder focus position 0mm"); scanner->opt[OPT_HOLDER_FOCUS_POS_0MM].desc = SANE_I18N("Use 0mm holder focus position instead of 0.6mm"); scanner->opt[OPT_HOLDER_FOCUS_POS_0MM].type = SANE_TYPE_BOOL; scanner->val[OPT_HOLDER_FOCUS_POS_0MM].w = SANE_FALSE; if (scanner->device->inquiry_sel_uta_lens_cal_pos == 0) { scanner->opt[OPT_HOLDER_FOCUS_POS_0MM].cap |= SANE_CAP_INACTIVE; } /* ------------------------------ */ /* lamp on */ scanner->opt[OPT_LAMP_ON].name = "lamp-on"; scanner->opt[OPT_LAMP_ON].title = SANE_I18N("Lamp on"); scanner->opt[OPT_LAMP_ON].desc = SANE_I18N("Turn on scanner lamp"); scanner->opt[OPT_LAMP_ON].type = SANE_TYPE_BUTTON; scanner->opt[OPT_LAMP_ON].unit = SANE_UNIT_NONE; scanner->opt[OPT_LAMP_ON].size = 0; scanner->opt[OPT_LAMP_ON].constraint_type = SANE_CONSTRAINT_NONE; scanner->val[OPT_LAMP_ON].w = 0; if (!scanner->device->lamp_control_available) /* lamp state can not be controlled by driver */ { scanner->opt[OPT_LAMP_ON].cap |= SANE_CAP_INACTIVE; } /* ------------------------------ */ /* lamp off */ scanner->opt[OPT_LAMP_OFF].name = "lamp-off"; scanner->opt[OPT_LAMP_OFF].title = SANE_I18N("Lamp off"); scanner->opt[OPT_LAMP_OFF].desc = SANE_I18N("Turn off scanner lamp"); scanner->opt[OPT_LAMP_OFF].type = SANE_TYPE_BUTTON; scanner->opt[OPT_LAMP_OFF].unit = SANE_UNIT_NONE; scanner->opt[OPT_LAMP_OFF].size = 0; scanner->opt[OPT_LAMP_OFF].constraint_type = SANE_CONSTRAINT_NONE; scanner->val[OPT_LAMP_OFF].w = 0; if (!scanner->device->lamp_control_available) /* lamp state can not be controlled by driver */ { scanner->opt[OPT_LAMP_OFF].cap |= SANE_CAP_INACTIVE; } /* ------------------------------ */ /* lamp off at exit */ scanner->opt[OPT_LAMP_OFF_AT_EXIT].name = "lamp-off-at-exit"; scanner->opt[OPT_LAMP_OFF_AT_EXIT].title = SANE_I18N("Lamp off at exit"); scanner->opt[OPT_LAMP_OFF_AT_EXIT].desc = SANE_I18N("Turn off lamp when program exits"); scanner->opt[OPT_LAMP_OFF_AT_EXIT].type = SANE_TYPE_BOOL; scanner->val[OPT_LAMP_OFF_AT_EXIT].w = SANE_FALSE; if (!scanner->device->lamp_control_available) /* lamp state can not be controlled by driver */ { scanner->opt[OPT_LAMP_OFF_AT_EXIT].cap |= SANE_CAP_INACTIVE; } /* ------------------------------ */ /* batch-scan-start */ scanner->opt[OPT_BATCH_SCAN_START].name = SANE_NAME_BATCH_SCAN_START; scanner->opt[OPT_BATCH_SCAN_START].title = SANE_TITLE_BATCH_SCAN_START; scanner->opt[OPT_BATCH_SCAN_START].desc = SANE_DESC_BATCH_SCAN_START; scanner->opt[OPT_BATCH_SCAN_START].type = SANE_TYPE_BOOL; scanner->val[OPT_BATCH_SCAN_START].w = SANE_FALSE; /* batch-scan-loop */ scanner->opt[OPT_BATCH_SCAN_LOOP].name = SANE_NAME_BATCH_SCAN_LOOP; scanner->opt[OPT_BATCH_SCAN_LOOP].title = SANE_TITLE_BATCH_SCAN_LOOP; scanner->opt[OPT_BATCH_SCAN_LOOP].desc = SANE_DESC_BATCH_SCAN_LOOP; scanner->opt[OPT_BATCH_SCAN_LOOP].type = SANE_TYPE_BOOL; scanner->val[OPT_BATCH_SCAN_LOOP].w = SANE_FALSE; /* batch-scan-end */ scanner->opt[OPT_BATCH_SCAN_END].name = SANE_NAME_BATCH_SCAN_END; scanner->opt[OPT_BATCH_SCAN_END].title = SANE_TITLE_BATCH_SCAN_END; scanner->opt[OPT_BATCH_SCAN_END].desc = SANE_DESC_BATCH_SCAN_END; scanner->opt[OPT_BATCH_SCAN_END].type = SANE_TYPE_BOOL; scanner->val[OPT_BATCH_SCAN_END].w = SANE_FALSE; /* batch-scan-next-y */ scanner->opt[OPT_BATCH_NEXT_TL_Y].name = SANE_NAME_BATCH_NEXT_TL_Y; scanner->opt[OPT_BATCH_NEXT_TL_Y].title = SANE_TITLE_BATCH_NEXT_TL_Y; scanner->opt[OPT_BATCH_NEXT_TL_Y].desc = SANE_DESC_BATCH_NEXT_TL_Y; scanner->opt[OPT_BATCH_NEXT_TL_Y].type = SANE_TYPE_FIXED; scanner->opt[OPT_BATCH_NEXT_TL_Y].unit = SANE_UNIT_MM; scanner->opt[OPT_BATCH_NEXT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BATCH_NEXT_TL_Y].constraint.range = &(scanner->device->y_range); scanner->val[OPT_BATCH_NEXT_TL_Y].w = 0xFFFF; /* mark value as not touched */ if (scanner->device->inquiry_batch_scan == 0) { scanner->opt[OPT_BATCH_SCAN_START].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_BATCH_SCAN_LOOP].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_BATCH_SCAN_END].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_BATCH_NEXT_TL_Y].cap |= SANE_CAP_INACTIVE; } /* ------------------------------ */ #ifdef UMAX_CALIBRATION_MODE_SELECTABLE /* calibration mode */ scanner->opt[OPT_CALIB_MODE].name = "calibrationmode"; scanner->opt[OPT_CALIB_MODE].title = SANE_I18N("Calibration mode"); scanner->opt[OPT_CALIB_MODE].desc = SANE_I18N("Define calibration mode"); scanner->opt[OPT_CALIB_MODE].type = SANE_TYPE_STRING; scanner->opt[OPT_CALIB_MODE].size = max_string_size(calibration_list); scanner->opt[OPT_CALIB_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_CALIB_MODE].constraint.string_list = calibration_list; scanner->val[OPT_CALIB_MODE].s = (SANE_Char*)strdup(calibration_list[0]); if (scanner->device->inquiry_calibration == 0) { scanner->opt[OPT_CALIB_MODE].cap |= SANE_CAP_INACTIVE; } #endif /* preview */ scanner->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; scanner->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; scanner->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; scanner->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; scanner->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; scanner->val[OPT_PREVIEW].w = SANE_FALSE; sane_control_option(scanner, OPT_MODE, SANE_ACTION_SET_VALUE, (SANE_String *) scan_mode_list[scan_modes], NULL ); return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ ATTACH ONE SCSI ----------------------------- */ /* callback function for sanei_config_attach_matching_devices(dev_name, attach_one_scsi) */ static SANE_Status attach_one_scsi(const char *name) { attach_scanner(name, 0, SANE_UMAX_SCSI); return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ ATTACH ONE USB ------------------------------ */ /* callback function for sanei_usb_attach_matching_devices(dev_name, attach_one_usb) */ static SANE_Status attach_one_usb(const char *name) { attach_scanner(name, 0, SANE_UMAX_USB); return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ UMAX TEST CONFIGURE OPTION ------------------ */ static SANE_Status umax_test_configure_option(const char *option_str, char *test_name, int *test_value, int test_min, int test_max) /* returns with 1 if option was found, 0 if option was not found */ { const char *value_str; char *end_ptr; int value; if (strncmp(option_str, test_name, strlen(test_name)) == 0) { value_str = sanei_config_skip_whitespace(option_str+strlen(test_name)); errno = 0; value = strtol(value_str, &end_ptr, 10); if (end_ptr == value_str || errno) { DBG(DBG_error, "ERROR: invalid value \"%s\" for option %s in %s\n", value_str, test_name, UMAX_CONFIG_FILE); } else { if (value < test_min) { DBG(DBG_error, "ERROR: value \"%d\" is too small for option %s in %s\n", value, test_name, UMAX_CONFIG_FILE); value = test_min; } else if (value > test_max) { DBG(DBG_error, "ERROR: value \"%d\" is too large for option %s in %s\n", value, test_name, UMAX_CONFIG_FILE); value = test_max; } *test_value = value; DBG(DBG_info, "option %s = %d\n", test_name, *test_value); } return 1; } return 0; } /* ------------------------------------------------------------ SANE INIT ---------------------------------- */ SANE_Status sane_init(SANE_Int *version_code, SANE_Auth_Callback authorize) { char config_line[PATH_MAX]; const char *option_str; size_t len; FILE *fp; /* we have to initialize these global variables here because sane_init can be called several times */ num_devices = 0; devlist = NULL; first_dev = NULL; first_handle = NULL; DBG_INIT(); DBG(DBG_sane_init,"sane_init\n"); DBG(DBG_error,"This is sane-umax version %d.%d build %d\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD); #ifdef UMAX_ENABLE_USB DBG(DBG_error,"compiled with USB support for Astra 2200\n"); #else DBG(DBG_error,"no USB support for Astra 2200\n"); #endif DBG(DBG_error,"(C) 1997-2002 by Oliver Rauch\n"); DBG(DBG_error,"EMAIL: Oliver.Rauch@rauch-domain.de\n"); if (version_code) { *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, BUILD); } frontend_authorize_callback = authorize; /* store frontend authorize callback */ sanei_thread_init(); /* must be called before any other sanei_thread call */ #ifdef UMAX_ENABLE_USB sanei_usb_init(); sanei_pv8630_init(); #endif fp = sanei_config_open(UMAX_CONFIG_FILE); if (!fp) { /* no config-file: try /dev/scanner and /dev/usbscanner. */ attach_scanner("/dev/scanner", 0, SANE_UMAX_SCSI); #ifdef UMAX_ENABLE_USB attach_scanner("/dev/usbscanner", 0, SANE_UMAX_USB); #endif return SANE_STATUS_GOOD; } DBG(DBG_info, "reading configure file %s\n", UMAX_CONFIG_FILE); while(sanei_config_read(config_line, sizeof(config_line), fp)) { if (config_line[0] == '#') { continue; /* ignore line comments */ } if (strncmp(config_line, "option", 6) == 0) { option_str = sanei_config_skip_whitespace(config_line+6); if (umax_test_configure_option(option_str, "scsi-maxqueue", &umax_scsi_maxqueue, 1, SANE_UMAX_SCSI_MAXQUEUE)); else if (umax_test_configure_option(option_str, "scsi-buffer-size-min", &umax_scsi_buffer_size_min, 4096, 1048576)); else if (umax_test_configure_option(option_str, "scsi-buffer-size-max", &umax_scsi_buffer_size_max, 4096, 1048576)); else if (umax_test_configure_option(option_str, "preview-lines", &umax_preview_lines, 1, 65535)); else if (umax_test_configure_option(option_str, "scan-lines", &umax_scan_lines, 1, 65535)); else if (umax_test_configure_option(option_str, "handle-bad-sense-error", &umax_handle_bad_sense_error, 0, 3)); else if (umax_test_configure_option(option_str, "execute-request-sense", &umax_execute_request_sense, 0, 1)); else if (umax_test_configure_option(option_str, "force-preview-bit-rgb", &umax_force_preview_bit_rgb, 0, 1)); else if (umax_test_configure_option(option_str, "slow-speed", &umax_slow, -1, 1)); else if (umax_test_configure_option(option_str, "care-about-smearing", &umax_smear, -1, 1)); else if (umax_test_configure_option(option_str, "calibration-full-ccd", &umax_calibration_area, -1, 1)); else if (umax_test_configure_option(option_str, "calibration-width-offset-batch", &umax_calibration_width_offset_batch, -99999, 65535)); else if (umax_test_configure_option(option_str, "calibration-width-offset", &umax_calibration_width_offset, -99999, 65535)); else if (umax_test_configure_option(option_str, "calibration-bytes-pixel", &umax_calibration_bytespp, -1, 2)); else if (umax_test_configure_option(option_str, "exposure-time-rgb-bind", &umax_exposure_time_rgb_bind, -1, 1)); else if (umax_test_configure_option(option_str, "invert-shading-data", &umax_invert_shading_data, -1, 1)); else if (umax_test_configure_option(option_str, "lamp-control-available", &umax_lamp_control_available, 0, 1)); else if (umax_test_configure_option(option_str, "gamma-lsb-padded", &umax_gamma_lsb_padded, -1, 1)); else if (umax_test_configure_option(option_str, "connection-type", &umax_connection_type, 1, 2)); else { DBG(DBG_error,"ERROR: unknown option \"%s\" in %s\n", option_str, UMAX_CONFIG_FILE); } continue; } else if (strncmp(config_line, "scsi", 4) == 0) { DBG(DBG_info,"sanei_config_attach_matching_devices(%s)\n", config_line); sanei_config_attach_matching_devices(config_line, attach_one_scsi); continue; } else if (strncmp(config_line, "usb", 3) == 0) { #ifdef UMAX_ENABLE_USB DBG(DBG_info,"sanei_usb_attach_matching_devices(%s)\n", config_line); sanei_usb_attach_matching_devices(config_line, attach_one_usb); #else DBG(DBG_info,"USB not supported, ignoring config line: %s\n", config_line); #endif continue; } len = strlen(config_line); if (!len) /* ignore empty lines */ { continue; } /* umax_connection_type is set by umax.conf: 1=scsi, 2=usb */ attach_scanner(config_line, 0, umax_connection_type); /* try to open as devicename */ } DBG(DBG_info, "finished reading configure file\n"); fclose(fp); return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ SANE EXIT ---------------------------------- */ void sane_exit(void) { Umax_Device *dev, *next; DBG(DBG_sane_init,"sane_exit\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free(dev->devicename); free(dev); } if (devlist) { free(devlist); } } /* ------------------------------------------------------------ SANE GET DEVICES --------------------------- */ SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only) { Umax_Device *dev; int i; DBG(DBG_sane_init,"sane_get_devices(local_only = %d)\n", local_only); if (devlist) { free(devlist); } devlist = malloc((num_devices + 1) * sizeof (devlist[0])); if (!devlist) { return SANE_STATUS_NO_MEM; } i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) { devlist[i++] = &dev->sane; } devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ SANE OPEN ---------------------------------- */ SANE_Status sane_open(SANE_String_Const devicename, SANE_Handle *handle) { Umax_Device *dev; SANE_Status status; Umax_Scanner *scanner; unsigned int i, j; DBG(DBG_sane_init,"sane_open\n"); if (devicename[0]) /* search for devicename */ { DBG(DBG_sane_info,"sane_open: devicename=%s\n", devicename); for (dev = first_dev; dev; dev = dev->next) { if (strcmp(dev->sane.name, devicename) == 0) { break; /* device found, exit for loop */ } } if (!dev) /* no device found */ { status = attach_scanner(devicename, &dev, 0 /* connection-type not known */); /* try to open devicename and set dev */ if (status != SANE_STATUS_GOOD) { return status; } } } else { DBG(DBG_sane_info,"sane_open: no devicename, opening first device\n"); dev = first_dev; /* empty devicename -> use first device */ } if (!dev) /* no device found */ { return SANE_STATUS_INVAL; } scanner = malloc(sizeof (*scanner)); if (!scanner) { return SANE_STATUS_NO_MEM; } memset(scanner, 0, sizeof (*scanner)); scanner->device = dev; if (scanner->device->inquiry_GIB & 32) { scanner->gamma_length = 65536; /* 16 bits input */ DBG(DBG_sane_info, "Using 16 bits for gamma input\n"); } else if (scanner->device->inquiry_GIB & 16) { scanner->gamma_length = 16384; /* 14 bits input */ DBG(DBG_sane_info, "Using 14 bits for gamma input\n"); } else if (scanner->device->inquiry_GIB & 8) { scanner->gamma_length = 4096; /* 12 bits input */ DBG(DBG_sane_info, "Using 12 bits for gamma input\n"); } else if (scanner->device->inquiry_GIB & 4) { scanner->gamma_length = 1024; /* 10 bits input */ DBG(DBG_sane_info, "Using 10 bits for gamma input\n"); } else if (scanner->device->inquiry_GIB & 2) { scanner->gamma_length = 512; /* 9 bits input */ DBG(DBG_sane_info, "Using 9 bits for gamma input\n"); } else { scanner->gamma_length = 256; /* 8 bits input */ DBG(DBG_sane_info, "Using 8 bits for gamma input\n"); } scanner->output_bytes = 1; /* 8 bits output */ scanner->gamma_range.min = 0; scanner->gamma_range.max = scanner->gamma_length-1; scanner->gamma_range.quant = 0; scanner->gamma_table[0] = (SANE_Int *) malloc(scanner->gamma_length * sizeof(SANE_Int)); scanner->gamma_table[1] = (SANE_Int *) malloc(scanner->gamma_length * sizeof(SANE_Int)); scanner->gamma_table[2] = (SANE_Int *) malloc(scanner->gamma_length * sizeof(SANE_Int)); scanner->gamma_table[3] = (SANE_Int *) malloc(scanner->gamma_length * sizeof(SANE_Int)); for (j = 0; j < scanner->gamma_length; ++j) /* gamma_table[0] : converts GIB to GOB */ { scanner->gamma_table[0][j] = j * scanner->device->max_value / scanner->gamma_length; } for (i = 1; i < 4; ++i) /* gamma_table[1,2,3] : doesn't convert anything (GIB->GIB) */ { for (j = 0; j < scanner->gamma_length; ++j) { scanner->gamma_table[i][j] = j; } } scanner->exposure_time_range.min = scanner->device->inquiry_exposure_time_c_min * scanner->device->inquiry_exposure_time_step_unit; scanner->exposure_time_range.quant = scanner->device->inquiry_exposure_time_step_unit; scanner->exposure_time_range.max = scanner->device->inquiry_exposure_time_max * scanner->device->inquiry_exposure_time_step_unit; init_options(scanner); scanner->next = first_handle; /* insert newly opened handle into list of open handles: */ first_handle = scanner; *handle = scanner; return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ SANE CLOSE --------------------------------- */ void sane_close(SANE_Handle handle) { Umax_Scanner *prev, *scanner; DBG(DBG_sane_init,"sane_close\n"); if (!first_handle) { DBG(DBG_error, "ERROR: sane_close: no handles opened\n"); return; } /* remove handle from list of open handles: */ prev = 0; for (scanner = first_handle; scanner; scanner = scanner->next) { if (scanner == handle) { break; } prev = scanner; } if (!scanner) { DBG(DBG_error, "ERROR: sane_close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (scanner->scanning) /* stop scan if still scanning */ { do_cancel(handle); } if (scanner->device->lamp_control_available) /* lamp state can be controlled by driver */ { if (scanner->val[OPT_LAMP_OFF_AT_EXIT].w) /* turn off scanner lamp on sane_close */ { umax_set_lamp_status(handle, 0 /* lamp off */); } } if (prev) { prev->next = scanner->next; } else { first_handle = scanner->next; } free(scanner->gamma_table[0]); /* free custom gamma tables */ free(scanner->gamma_table[1]); free(scanner->gamma_table[2]); free(scanner->gamma_table[3]); free(scanner->device->buffer[0]); /* free buffer allocated by umax_initialize_values */ scanner->device->buffer[0] = NULL; scanner->device->bufsize = 0; free(scanner); /* free scanner */ } /* ------------------------------------------------------------ SANE GET OPTION DESCRIPTOR ----------------- */ const SANE_Option_Descriptor *sane_get_option_descriptor(SANE_Handle handle, SANE_Int option) { Umax_Scanner *scanner = handle; DBG(DBG_sane_option,"sane_get_option_descriptor %d\n", option); if ((unsigned) option >= NUM_OPTIONS) { return 0; } return scanner->opt + option; } /* ------------------------------------------------------------ UMAX SET MAX GEOMETRY ---------------------- */ static void umax_set_max_geometry(Umax_Scanner *scanner) { if (scanner->val[OPT_DOR].w) { scanner->device->x_range.min = SANE_FIX(scanner->device->inquiry_dor_x_off * MM_PER_INCH); scanner->device->x_range.max = SANE_FIX( (scanner->device->inquiry_dor_x_off + scanner->device->inquiry_dor_width) * MM_PER_INCH); scanner->device->y_range.min = SANE_FIX(scanner->device->inquiry_dor_y_off * MM_PER_INCH); scanner->device->y_range.max = SANE_FIX( (scanner->device->inquiry_dor_y_off + scanner->device->inquiry_dor_length) * MM_PER_INCH); scanner->device->x_dpi_range.max = SANE_FIX(scanner->device->inquiry_dor_x_res); scanner->device->y_dpi_range.max = SANE_FIX(scanner->device->inquiry_dor_y_res); } else if ( (strcmp(scanner->val[OPT_SOURCE].s, FLB_STR) == 0) || (strcmp(scanner->val[OPT_SOURCE].s, ADF_STR) == 0) ) { scanner->device->x_range.min = 0; scanner->device->x_range.max = SANE_FIX(scanner->device->inquiry_fb_width * MM_PER_INCH); scanner->device->y_range.min = 0; scanner->device->y_range.max = SANE_FIX(scanner->device->inquiry_fb_length * MM_PER_INCH); scanner->device->x_dpi_range.max = SANE_FIX(scanner->device->inquiry_x_res); scanner->device->y_dpi_range.max = SANE_FIX(scanner->device->inquiry_y_res); } else if (strcmp(scanner->val[OPT_SOURCE].s, UTA_STR) == 0) { scanner->device->x_range.min = SANE_FIX(scanner->device->inquiry_uta_x_off * MM_PER_INCH); scanner->device->x_range.max = SANE_FIX( (scanner->device->inquiry_uta_x_off + scanner->device->inquiry_uta_width) * MM_PER_INCH); scanner->device->y_range.min = SANE_FIX(scanner->device->inquiry_uta_y_off * MM_PER_INCH); scanner->device->y_range.max = SANE_FIX( ( scanner->device->inquiry_uta_y_off + scanner->device->inquiry_uta_length) * MM_PER_INCH); scanner->device->x_dpi_range.max = SANE_FIX(scanner->device->inquiry_x_res); scanner->device->y_dpi_range.max = SANE_FIX(scanner->device->inquiry_y_res); } DBG(DBG_info,"x_range = [%f .. %f]\n", SANE_UNFIX(scanner->device->x_range.min), SANE_UNFIX(scanner->device->x_range.max)); DBG(DBG_info,"y_range = [%f .. %f]\n", SANE_UNFIX(scanner->device->y_range.min), SANE_UNFIX(scanner->device->y_range.max)); DBG(DBG_info,"x_dpi_range = [1 .. %f]\n", SANE_UNFIX(scanner->device->x_dpi_range.max)); DBG(DBG_info,"y_dpi_range = [1 .. %f]\n", SANE_UNFIX(scanner->device->y_dpi_range.max)); /* make sure geometry selection is in bounds */ if ( scanner->val[OPT_TL_X].w < scanner->device->x_range.min) { scanner->val[OPT_TL_X].w = scanner->device->x_range.min; } if (scanner->val[OPT_TL_Y].w < scanner->device->y_range.min) { scanner->val[OPT_TL_Y].w = scanner->device->y_range.min; } if ( scanner->val[OPT_BR_X].w > scanner->device->x_range.max) { scanner->val[OPT_BR_X].w = scanner->device->x_range.max; } if (scanner->val[OPT_BR_Y].w > scanner->device->y_range.max) { scanner->val[OPT_BR_Y].w = scanner->device->y_range.max; } } /* ------------------------------------------------------------ SANE CONTROL OPTION ------------------------ */ SANE_Status sane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int *info) { Umax_Scanner *scanner = handle; SANE_Status status; SANE_Word w, cap; SANE_String_Const name; if (info) { *info = 0; } if (scanner->scanning) { return SANE_STATUS_DEVICE_BUSY; } if ((unsigned) option >= NUM_OPTIONS) { return SANE_STATUS_INVAL; } cap = scanner->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { return SANE_STATUS_INVAL; } name = scanner->opt[option].name; if (!name) { name = "(no name)"; } if (action == SANE_ACTION_GET_VALUE) { DBG(DBG_sane_option,"get %s [#%d]\n", name, option); switch (option) { /* word options: */ case OPT_NUM_OPTS: case OPT_RESOLUTION_BIND: case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_PREVIEW: case OPT_BIT_DEPTH: case OPT_NEGATIVE: case OPT_BATCH_SCAN_START: case OPT_BATCH_SCAN_LOOP: case OPT_BATCH_SCAN_END: case OPT_BATCH_NEXT_TL_Y: case OPT_QUALITY: case OPT_DOR: case OPT_WARMUP: case OPT_RGB_BIND: case OPT_ANALOG_GAMMA: case OPT_ANALOG_GAMMA_R: case OPT_ANALOG_GAMMA_G: case OPT_ANALOG_GAMMA_B: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_THRESHOLD: case OPT_HIGHLIGHT: case OPT_HIGHLIGHT_R: case OPT_HIGHLIGHT_G: case OPT_HIGHLIGHT_B: case OPT_SHADOW: case OPT_SHADOW_R: case OPT_SHADOW_G: case OPT_SHADOW_B: case OPT_CUSTOM_GAMMA: case OPT_HALFTONE_DIMENSION: case OPT_SELECT_EXPOSURE_TIME: case OPT_SELECT_CAL_EXPOSURE_TIME: case OPT_CAL_EXPOS_TIME: case OPT_CAL_EXPOS_TIME_R: case OPT_CAL_EXPOS_TIME_G: case OPT_CAL_EXPOS_TIME_B: case OPT_SCAN_EXPOS_TIME: case OPT_SCAN_EXPOS_TIME_R: case OPT_SCAN_EXPOS_TIME_G: case OPT_SCAN_EXPOS_TIME_B: case OPT_CAL_LAMP_DEN: case OPT_SCAN_LAMP_DEN: case OPT_DISABLE_PRE_FOCUS: case OPT_MANUAL_PRE_FOCUS: case OPT_FIX_FOCUS_POSITION: case OPT_LENS_CALIBRATION_DOC_POS: case OPT_HOLDER_FOCUS_POS_0MM: case OPT_LAMP_OFF_AT_EXIT: case OPT_SELECT_LAMP_DENSITY: *(SANE_Word *) val = scanner->val[option].w; return SANE_STATUS_GOOD; /* word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: case OPT_HALFTONE_PATTERN: memcpy (val, scanner->val[option].wa, scanner->opt[option].size); return SANE_STATUS_GOOD; /* string options: */ case OPT_SOURCE: /* fall through */ case OPT_MODE: /* fall through */ #ifdef UMAX_CALIBRATION_MODE_SELECTABLE case OPT_CALIB_MODE: /* fall through */ #endif strcpy (val, scanner->val[option].s); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { switch (scanner->opt[option].type) { case SANE_TYPE_INT: DBG(DBG_sane_option, "set %s [#%d] to %d\n", name, option, *(SANE_Word *) val); break; case SANE_TYPE_FIXED: DBG(DBG_sane_option, "set %s [#%d] to %f\n", name, option, SANE_UNFIX(*(SANE_Word *) val)); break; case SANE_TYPE_STRING: DBG(DBG_sane_option, "set %s [#%d] to %s\n", name, option, (char *) val); break; case SANE_TYPE_BOOL: DBG(DBG_sane_option, "set %s [#%d] to %d\n", name, option, *(SANE_Word *) val); break; default: DBG(DBG_sane_option, "set %s [#%d]\n", name, option); } if (!SANE_OPTION_IS_SETTABLE(cap)) { DBG(DBG_error, "could not set option, not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value(scanner->opt+option, val, info); if (status != SANE_STATUS_GOOD) { DBG(DBG_error, "could not set option, invalid value\n"); return status; } switch (option) { /* (mostly) side-effect-free word options: */ case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } /* fall through */ case OPT_NUM_OPTS: case OPT_NEGATIVE: case OPT_BATCH_SCAN_START: case OPT_BATCH_SCAN_LOOP: case OPT_BATCH_SCAN_END: case OPT_BATCH_NEXT_TL_Y: case OPT_QUALITY: case OPT_WARMUP: case OPT_PREVIEW: case OPT_ANALOG_GAMMA: case OPT_ANALOG_GAMMA_R: case OPT_ANALOG_GAMMA_G: case OPT_ANALOG_GAMMA_B: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_THRESHOLD: case OPT_HIGHLIGHT: case OPT_HIGHLIGHT_R: case OPT_HIGHLIGHT_G: case OPT_HIGHLIGHT_B: case OPT_SHADOW: case OPT_SHADOW_R: case OPT_SHADOW_G: case OPT_SHADOW_B: case OPT_CAL_EXPOS_TIME: case OPT_CAL_EXPOS_TIME_R: case OPT_CAL_EXPOS_TIME_G: case OPT_CAL_EXPOS_TIME_B: case OPT_SCAN_EXPOS_TIME: case OPT_SCAN_EXPOS_TIME_R: case OPT_SCAN_EXPOS_TIME_G: case OPT_SCAN_EXPOS_TIME_B: case OPT_CAL_LAMP_DEN: case OPT_SCAN_LAMP_DEN: case OPT_DISABLE_PRE_FOCUS: case OPT_MANUAL_PRE_FOCUS: case OPT_FIX_FOCUS_POSITION: case OPT_LENS_CALIBRATION_DOC_POS: case OPT_HOLDER_FOCUS_POS_0MM: case OPT_LAMP_OFF_AT_EXIT: scanner->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; case OPT_DOR: { if (scanner->val[option].w != *(SANE_Word *) val) { scanner->val[option].w = *(SANE_Word *) val; /* update valure for umax_set_max_geometry */ if (info) { *info |= SANE_INFO_RELOAD_PARAMS; *info |= SANE_INFO_RELOAD_OPTIONS; } DBG(DBG_info,"sane_control_option: set DOR = %d\n", scanner->val[option].w); umax_set_max_geometry(scanner); } return SANE_STATUS_GOOD; } case OPT_BIT_DEPTH: { if (scanner->val[option].w != *(SANE_Word *) val) { scanner->val[option].w = *(SANE_Word *) val; if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } scanner->output_range.min = 0; scanner->output_range.quant = 0; if (scanner->val[option].w == 8) /* 8 bit mode */ { scanner->output_bytes = 1; /* 1 bytes output */ scanner->output_range.max = 255; } else /* > 8 bit mode */ { scanner->output_bytes = 2; /* 2 bytes output */ if (scanner->device->gamma_lsb_padded) /* e.g. astra 1220s need lsb padded data */ { scanner->output_range.max = (int) pow(2, scanner->val[option].w) - 1; } else { scanner->output_range.max = 65535; /* define maxval for msb padded data */ } } if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } } return SANE_STATUS_GOOD; } case OPT_RGB_BIND: { if (scanner->val[option].w != *(SANE_Word *) val) { scanner->val[option].w = *(SANE_Word *) val; if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } umax_set_rgb_bind(scanner); } return SANE_STATUS_GOOD; } case OPT_RESOLUTION_BIND: { if (scanner->val[option].w != *(SANE_Word *) val) { scanner->val[option].w = *(SANE_Word *) val; if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } if (scanner->val[option].w == SANE_FALSE) { /* don't bind */ scanner->opt[OPT_Y_RESOLUTION].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_X_RESOLUTION; scanner->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; scanner->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_X_RESOLUTION; } else { /* bind */ scanner->opt[OPT_Y_RESOLUTION].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; scanner->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; scanner->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; } } return SANE_STATUS_GOOD; } case OPT_SELECT_EXPOSURE_TIME: case OPT_SELECT_CAL_EXPOSURE_TIME: { if (scanner->val[option].w != *(SANE_Word *) val) { scanner->val[option].w = *(SANE_Word *) val; if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } if (scanner->val[OPT_SELECT_EXPOSURE_TIME].w == SANE_FALSE) { scanner->opt[OPT_SELECT_CAL_EXPOSURE_TIME].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; } else /* exposure time selection active */ { scanner->opt[OPT_SELECT_CAL_EXPOSURE_TIME].cap &= ~SANE_CAP_INACTIVE; if ( (strcmp(scanner->val[OPT_MODE].s, COLOR_STR) != 0) || (scanner->val[OPT_RGB_BIND].w == SANE_TRUE) || (scanner->device->exposure_time_rgb_bind) ) /* RGB bind */ { if (scanner->val[OPT_SELECT_CAL_EXPOSURE_TIME].w) { scanner->opt[OPT_CAL_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; } else { scanner->opt[OPT_CAL_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_SCAN_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; } else /* no RGB bind */ { if (scanner->val[OPT_SELECT_CAL_EXPOSURE_TIME].w) { scanner->opt[OPT_CAL_EXPOS_TIME_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_B].cap &= ~SANE_CAP_INACTIVE; } else { scanner->opt[OPT_CAL_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_SCAN_EXPOS_TIME_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_B].cap &= ~SANE_CAP_INACTIVE; } } } return SANE_STATUS_GOOD; } case OPT_SELECT_LAMP_DENSITY: { if (scanner->val[option].w != *(SANE_Word *) val) { scanner->val[option].w = *(SANE_Word *) val; if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } if (scanner->val[option].w == SANE_FALSE) { scanner->opt[OPT_CAL_LAMP_DEN].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_LAMP_DEN].cap |= SANE_CAP_INACTIVE; } else { scanner->opt[OPT_CAL_LAMP_DEN].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_LAMP_DEN].cap &= ~SANE_CAP_INACTIVE; } } return SANE_STATUS_GOOD; } /* side-effect-free word-array options: */ case OPT_HALFTONE_PATTERN: case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (scanner->val[option].wa, val, scanner->opt[option].size); return SANE_STATUS_GOOD; /* single string-option with side-effect: */ case OPT_SOURCE: { if (scanner->val[option].s) { free(scanner->val[option].s); } scanner->val[option].s = (SANE_Char *) strdup(val); /* update string for umax_set_max_geometry */ DBG(DBG_info,"sane_control_option: set SOURCE = %s\n", (SANE_Char *) val); umax_set_max_geometry(scanner); if (info) { *info |= SANE_INFO_RELOAD_PARAMS; *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; } break; /* side-effect-free single-string options: */ #ifdef UMAX_CALIBRATION_MODE_SELECTABLE case OPT_CALIB_MODE: /* fall through */ #endif { if (scanner->val[option].s) { free (scanner->val[option].s); } scanner->val[option].s = (SANE_Char*)strdup(val); return SANE_STATUS_GOOD; } /* options with side-effects: */ case OPT_CUSTOM_GAMMA: { w = *(SANE_Word *) val; if (w == scanner->val[OPT_CUSTOM_GAMMA].w) { return SANE_STATUS_GOOD; } scanner->val[OPT_CUSTOM_GAMMA].w = w; if (w) /* use custom_gamma_table */ { const char *mode = scanner->val[OPT_MODE].s; if ( (strcmp(mode, LINEART_STR) == 0) || (strcmp(mode, HALFTONE_STR) == 0) || (strcmp(mode, GRAY_STR) == 0) ) { scanner->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; } else if (strcmp(mode, COLOR_STR) == 0) { scanner->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } else /* don't use custom_gamma_table */ { scanner->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; } case OPT_MODE: { int halftoning; if (scanner->val[option].s) { free (scanner->val[option].s); } scanner->val[option].s = (SANE_Char*)strdup(val); if (info) { *info |=SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; } scanner->opt[OPT_NEGATIVE].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_RGB_BIND].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_ANALOG_GAMMA_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HIGHLIGHT_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SHADOW_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CAL_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HALFTONE_DIMENSION].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; halftoning = (strcmp(val, HALFTONE_STR) == 0 || strcmp(val, COLOR_HALFTONE_STR) == 0); if (halftoning || strcmp(val, LINEART_STR) == 0 || strcmp(val, COLOR_LINEART_STR) == 0) { /* one bit modes */ if (scanner->device->inquiry_reverse) { scanner->opt[OPT_NEGATIVE].cap &= ~SANE_CAP_INACTIVE; } if (halftoning) { /* halftoning modes */ scanner->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; if (scanner->device->inquiry_highlight) { scanner->opt[OPT_HIGHLIGHT].cap &= ~SANE_CAP_INACTIVE; } if (scanner->device->inquiry_shadow) { scanner->opt[OPT_SHADOW].cap &= ~SANE_CAP_INACTIVE; } /* disable halftone pattern download options */ #if 0 scanner->opt[OPT_HALFTONE_DIMENSION].cap &= ~SANE_CAP_INACTIVE; if (scanner->val[OPT_HALFTONE_DIMENSION].w) { scanner->opt[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; } #endif if (scanner->val[OPT_SELECT_EXPOSURE_TIME].w == SANE_TRUE) { scanner->opt[OPT_CAL_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; } scanner->exposure_time_range.min = scanner->device->inquiry_exposure_time_h_min * scanner->device->inquiry_exposure_time_step_unit; } else { /* lineart modes */ scanner->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; if (scanner->val[OPT_SELECT_EXPOSURE_TIME].w == SANE_TRUE) { scanner->opt[OPT_CAL_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; } scanner->exposure_time_range.min = scanner->device->inquiry_exposure_time_l_min * scanner->device->inquiry_exposure_time_step_unit; } } else { /* multi-bit modes(gray or color) */ scanner->opt[OPT_BIT_DEPTH].cap &= ~SANE_CAP_INACTIVE; if (scanner->device->inquiry_highlight) { scanner->opt[OPT_HIGHLIGHT].cap &= ~SANE_CAP_INACTIVE; } if (scanner->device->inquiry_shadow) { scanner->opt[OPT_SHADOW].cap &= ~SANE_CAP_INACTIVE; } if (scanner->device->inquiry_reverse_multi) { scanner->opt[OPT_NEGATIVE].cap &= ~SANE_CAP_INACTIVE; } if (scanner->device->inquiry_gamma_dwload) { scanner->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; } else { scanner->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; } if (scanner->device->inquiry_analog_gamma) { scanner->opt[OPT_ANALOG_GAMMA].cap &= ~SANE_CAP_INACTIVE; } if (scanner->val[OPT_SELECT_EXPOSURE_TIME].w == SANE_TRUE) { scanner->opt[OPT_CAL_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_SCAN_EXPOS_TIME].cap &= ~SANE_CAP_INACTIVE; } if (strcmp(val, COLOR_STR) == 0) { if ( (scanner->device->inquiry_analog_gamma) || (scanner->device->inquiry_highlight) || (scanner->device->inquiry_shadow) || (scanner->device->inquiry_exposure_adj) ) { scanner->opt[OPT_RGB_BIND].cap &= ~SANE_CAP_INACTIVE; } scanner->exposure_time_range.min = scanner->device->inquiry_exposure_time_c_min * scanner->device->inquiry_exposure_time_step_unit; } else /* grayscale */ { scanner->exposure_time_range.min = scanner->device->inquiry_exposure_time_g_min * scanner->device->inquiry_exposure_time_step_unit; } } umax_set_rgb_bind(scanner); if (scanner->val[OPT_CUSTOM_GAMMA].w) { if (strcmp(val, GRAY_STR) == 0) { scanner->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; } else if (strcmp(val, COLOR_STR) == 0) { scanner->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } return SANE_STATUS_GOOD; } case OPT_HALFTONE_DIMENSION: /* halftone pattern dimension affects halftone pattern option: */ { unsigned dim = *(SANE_Word *) val; scanner->val[option].w = dim; if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } scanner->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; if (dim > 0) { scanner->opt[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_HALFTONE_PATTERN].size = dim * sizeof (SANE_Word); } return SANE_STATUS_GOOD; } case OPT_LAMP_ON: { if (!umax_set_lamp_status(handle, 1 /* lamp on */)) { return SANE_STATUS_GOOD; } else { return SANE_STATUS_UNSUPPORTED; } } case OPT_LAMP_OFF: { if (!umax_set_lamp_status(handle, 0 /* lamp off */)) { return SANE_STATUS_GOOD; } else { return SANE_STATUS_UNSUPPORTED; } } } } /* else */ return SANE_STATUS_INVAL; } /* ------------------------------------------------------------ SANE GET PARAMETERS ------------------------ */ SANE_Status sane_get_parameters(SANE_Handle handle, SANE_Parameters *params) { Umax_Scanner *scanner = handle; const char *mode; DBG(DBG_sane_info,"sane_get_parameters\n"); if (!scanner->scanning) { /* not scanning, so lets use recent values */ double width, length, x_dpi, y_dpi; memset(&scanner->params, 0, sizeof (scanner->params)); width = SANE_UNFIX(scanner->val[OPT_BR_X].w - scanner->val[OPT_TL_X].w); length = SANE_UNFIX(scanner->val[OPT_BR_Y].w - scanner->val[OPT_TL_Y].w); x_dpi = SANE_UNFIX(scanner->val[OPT_X_RESOLUTION].w); y_dpi = SANE_UNFIX(scanner->val[OPT_Y_RESOLUTION].w); if ( (scanner->val[OPT_RESOLUTION_BIND].w == SANE_TRUE) || (scanner->val[OPT_PREVIEW].w == SANE_TRUE) ) { y_dpi = x_dpi; } if (x_dpi > 0.0 && y_dpi > 0.0 && width > 0.0 && length > 0.0) { double x_dots_per_mm = x_dpi / MM_PER_INCH; double y_dots_per_mm = y_dpi / MM_PER_INCH; scanner->params.pixels_per_line = width * x_dots_per_mm; scanner->params.lines = length * y_dots_per_mm; } } mode = scanner->val[OPT_MODE].s; if (strcmp(mode, LINEART_STR) == 0 || strcmp(mode, HALFTONE_STR) == 0) { scanner->params.format = SANE_FRAME_GRAY; scanner->params.bytes_per_line = (scanner->params.pixels_per_line + 7) / 8; scanner->params.depth = 1; } else if (strcmp(mode, GRAY_STR) == 0) { scanner->params.format = SANE_FRAME_GRAY; scanner->params.bytes_per_line = scanner->params.pixels_per_line * scanner->output_bytes; scanner->params.depth = 8 * scanner->output_bytes; } else if (strcmp(mode, COLOR_LINEART_STR) == 0 || strcmp(mode, COLOR_HALFTONE_STR) == 0 ) { if (scanner->device->inquiry_one_pass_color) { scanner->device->three_pass = 0; scanner->params.format = SANE_FRAME_RGB; scanner->params.bytes_per_line = 3 * scanner->params.pixels_per_line; scanner->params.depth = 8; } else /* three pass color */ { scanner->device->three_pass = 1; scanner->params.format = SANE_FRAME_RED + scanner->device->three_pass_color - 1; scanner->params.bytes_per_line = scanner->params.pixels_per_line; scanner->params.depth = 8; } } else /* RGB */ { if (scanner->device->inquiry_one_pass_color) { scanner->device->three_pass = 0; scanner->params.format = SANE_FRAME_RGB; scanner->params.bytes_per_line = 3 * scanner->params.pixels_per_line * scanner->output_bytes; scanner->params.depth = 8 * scanner->output_bytes; } else /* three pass color */ { scanner->device->three_pass = 1; scanner->params.format = SANE_FRAME_RED + scanner->device->three_pass_color - 1; scanner->params.bytes_per_line = scanner->params.pixels_per_line * scanner->output_bytes; scanner->params.depth = 8 * scanner->output_bytes; } } scanner->params.last_frame = (scanner->params.format != SANE_FRAME_RED && scanner->params.format != SANE_FRAME_GREEN); if (params) { *params = scanner->params; } return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ SANE START --------------------------------- */ SANE_Status sane_start(SANE_Handle handle) { Umax_Scanner *scanner = handle; const char *mode; double xbasedots, ybasedots; const char *scan_source; int pause; int status; int fds[2]; DBG(DBG_sane_init,"sane_start\n"); /* Invalidate reader_pid so a subsequent error and following call to * do_cancel() won't trip over it. */ sanei_thread_invalidate(scanner->reader_pid); mode = scanner->val[OPT_MODE].s; if (scanner->device->sfd == -1) /* first call, don`t run this routine again on multi frame or multi image scan */ { umax_initialize_values(scanner->device); /* reset values */ scanner->device->three_pass_color = 1; /* test for adf and uta */ scan_source = scanner->val[OPT_SOURCE].s; if (strcmp(scan_source, UTA_STR) == 0) { if ( (scanner->device->inquiry_uta != 0) && (scanner->device->inquiry_transavail != 0) ) { scanner->device->uta = 1; } else { DBG(DBG_error,"ERROR: Transparency Adapter not available\n"); umax_scsi_close(scanner->device); return SANE_STATUS_INVAL; } } else /* Test if ADF is selected */ { scanner->device->uta = 0; if (strcmp(scan_source, ADF_STR) == 0) { if ( (scanner->device->inquiry_adf) && (scanner->device->inquiry_adfmode) ) { scanner->device->adf = 1; } else { DBG(DBG_error,"ERROR: Automatic Document Feeder not available\n"); umax_scsi_close(scanner->device); return SANE_STATUS_INVAL; } } else { scanner->device->adf = 0; } } if (scanner->device->inquiry_GIB & 32) /* 16 bit input mode */ { scanner->device->gamma_input_bits_code = 32; DBG(DBG_sane_info, "Using 16 bits for gamma input\n"); } else if (scanner->device->inquiry_GIB & 16) /* 14 bit input mode */ { scanner->device->gamma_input_bits_code = 16; DBG(DBG_sane_info, "Using 14 bits for gamma input\n"); } else if (scanner->device->inquiry_GIB & 8) /* 12 bit input mode */ { scanner->device->gamma_input_bits_code = 8; DBG(DBG_sane_info, "Using 12 bits for gamma input\n"); } else if (scanner->device->inquiry_GIB & 4) /* 10 bit input mode */ { scanner->device->gamma_input_bits_code = 4; DBG(DBG_sane_info, "Using 10 bits for gamma input\n"); } else if (scanner->device->inquiry_GIB & 2) /* 9 bit input mode */ { scanner->device->gamma_input_bits_code = 2; DBG(DBG_sane_info, "Using 9 bits for gamma input\n"); } else /* 8 bit input mode */ { scanner->device->gamma_input_bits_code = 1; DBG(DBG_sane_info, "Using 8 bits for gamma input\n"); } if (scanner->val[OPT_BIT_DEPTH].w == 16) /* 16 bit output mode */ { scanner->device->bits_per_pixel = 16; scanner->device->bits_per_pixel_code = 32; scanner->device->max_value = 65535; DBG(DBG_sane_info,"Using 16 bits for output\n"); } else if (scanner->val[OPT_BIT_DEPTH].w == 14) /* 14 bit output mode */ { scanner->device->bits_per_pixel = 14; scanner->device->bits_per_pixel_code = 16; scanner->device->max_value = 16383; DBG(DBG_sane_info,"Using 14 bits for output\n"); } else if (scanner->val[OPT_BIT_DEPTH].w == 12) /* 12 bit output mode */ { scanner->device->bits_per_pixel = 12; scanner->device->bits_per_pixel_code = 8; scanner->device->max_value = 4095; DBG(DBG_sane_info,"Using 12 bits for output\n"); } else if (scanner->val[OPT_BIT_DEPTH].w == 10) /* 10 bit output mode */ { scanner->device->bits_per_pixel = 10; scanner->device->bits_per_pixel_code = 4; scanner->device->max_value = 1023; DBG(DBG_sane_info,"Using 10 bits for output\n"); } else if (scanner->val[OPT_BIT_DEPTH].w == 9) /* 9 bit output mode */ { scanner->device->bits_per_pixel = 9; scanner->device->bits_per_pixel_code = 2; scanner->device->max_value = 511; DBG(DBG_sane_info,"Using 9 bits for output\n"); } else /* 8 bit output mode */ { scanner->device->bits_per_pixel = 8; scanner->device->bits_per_pixel_code = 1; scanner->device->max_value = 255; DBG(DBG_sane_info,"Using 8 bits for output\n"); } scanner->device->reverse = scanner->device->reverse_multi = scanner->val[OPT_NEGATIVE].w; scanner->device->threshold = P_100_TO_255(scanner->val[OPT_THRESHOLD].w); scanner->device->brightness = P_200_TO_255(scanner->val[OPT_BRIGHTNESS].w); scanner->device->contrast = P_200_TO_255(scanner->val[OPT_CONTRAST].w); scanner->device->batch_scan = ( scanner->val[OPT_BATCH_SCAN_START].w || scanner->val[OPT_BATCH_SCAN_LOOP].w || scanner->val[OPT_BATCH_SCAN_END].w ); scanner->device->batch_end = scanner->val[OPT_BATCH_SCAN_END].w; scanner->device->batch_next_tl_y = SANE_UNFIX(scanner->val[OPT_BATCH_NEXT_TL_Y].w) * scanner->device->y_coordinate_base / MM_PER_INCH; if (scanner->val[OPT_BATCH_NEXT_TL_Y].w == 0xFFFF) /* option not set: use br_y => scanhead stops at end of batch area */ { scanner->device->batch_next_tl_y = SANE_UNFIX(scanner->val[OPT_BR_Y].w) * scanner->device->y_coordinate_base / MM_PER_INCH; } if ((scanner->device->batch_scan) && !scanner->val[OPT_BATCH_SCAN_START].w) { scanner->device->calibration = 9; /* no calibration - otherwise the scanhead will go into calibration position */ } else { scanner->device->calibration = 0; /* calibration defined by image type */ } scanner->device->quality = scanner->val[OPT_QUALITY].w; scanner->device->dor = scanner->val[OPT_DOR].w; scanner->device->preview = scanner->val[OPT_PREVIEW].w; scanner->device->warmup = scanner->val[OPT_WARMUP].w; scanner->device->fix_focus_position = scanner->val[OPT_FIX_FOCUS_POSITION].w; scanner->device->lens_cal_in_doc_pos = scanner->val[OPT_LENS_CALIBRATION_DOC_POS].w; scanner->device->disable_pre_focus = scanner->val[OPT_DISABLE_PRE_FOCUS].w; scanner->device->holder_focus_pos_0mm = scanner->val[OPT_HOLDER_FOCUS_POS_0MM].w; scanner->device->manual_focus = scanner->val[OPT_MANUAL_PRE_FOCUS].w; scanner->device->analog_gamma_r = scanner->device->analog_gamma_g = scanner->device->analog_gamma_b = umax_calculate_analog_gamma(SANE_UNFIX(scanner->val[OPT_ANALOG_GAMMA].w)); scanner->device->highlight_r = scanner->device->highlight_g = scanner->device->highlight_b = P_100_TO_255(scanner->val[OPT_HIGHLIGHT].w); scanner->device->shadow_r = scanner->device->shadow_g = scanner->device->shadow_b = P_100_TO_255(scanner->val[OPT_SHADOW].w); if (scanner->val[OPT_SELECT_EXPOSURE_TIME].w == SANE_TRUE) { if (scanner->val[OPT_SELECT_CAL_EXPOSURE_TIME].w) /* separate calibration exposure time */ { scanner->device->exposure_time_calibration_r = scanner->device->exposure_time_calibration_g = scanner->device->exposure_time_calibration_b = scanner->val[OPT_CAL_EXPOS_TIME].w; } else /* same exposure times for calibration as for scanning */ { scanner->device->exposure_time_calibration_r = scanner->device->exposure_time_calibration_g = scanner->device->exposure_time_calibration_b = scanner->val[OPT_SCAN_EXPOS_TIME].w; } scanner->device->exposure_time_scan_r = scanner->device->exposure_time_scan_g = scanner->device->exposure_time_scan_b = scanner->val[OPT_SCAN_EXPOS_TIME].w; } if (scanner->val[OPT_SELECT_LAMP_DENSITY].w == SANE_TRUE) { scanner->device->c_density = P_100_TO_254(scanner->val[OPT_CAL_LAMP_DEN].w); scanner->device->s_density = P_100_TO_254(scanner->val[OPT_SCAN_LAMP_DEN].w); } if (strcmp(mode, LINEART_STR) == 0) { scanner->device->colormode = LINEART; } else if (strcmp(mode, HALFTONE_STR) == 0) { scanner->device->colormode = HALFTONE; } else if (strcmp(mode, GRAY_STR) == 0) { scanner->device->colormode = GRAYSCALE; } else if (strcmp(mode, COLOR_LINEART_STR) == 0) { scanner->device->colormode = RGB_LINEART; } else if (strcmp(mode, COLOR_HALFTONE_STR) == 0) { scanner->device->colormode = RGB_HALFTONE; } else if (strcmp(mode, COLOR_STR) == 0) { scanner->device->colormode = RGB; if (scanner->val[OPT_RGB_BIND].w == SANE_FALSE) { scanner->device->analog_gamma_r = umax_calculate_analog_gamma( SANE_UNFIX(scanner->val[OPT_ANALOG_GAMMA_R].w) ); scanner->device->analog_gamma_g = umax_calculate_analog_gamma( SANE_UNFIX(scanner->val[OPT_ANALOG_GAMMA_G].w) ); scanner->device->analog_gamma_b = umax_calculate_analog_gamma( SANE_UNFIX(scanner->val[OPT_ANALOG_GAMMA_B].w) ); scanner->device->highlight_r = P_100_TO_255(scanner->val[OPT_HIGHLIGHT_R].w); scanner->device->highlight_g = P_100_TO_255(scanner->val[OPT_HIGHLIGHT_G].w); scanner->device->highlight_b = P_100_TO_255(scanner->val[OPT_HIGHLIGHT_B].w); scanner->device->shadow_r = P_100_TO_255(scanner->val[OPT_SHADOW_R].w); scanner->device->shadow_g = P_100_TO_255(scanner->val[OPT_SHADOW_G].w); scanner->device->shadow_b = P_100_TO_255(scanner->val[OPT_SHADOW_B].w); if ((scanner->val[OPT_SELECT_EXPOSURE_TIME].w == SANE_TRUE) && (!scanner->device->exposure_time_rgb_bind)) { if (scanner->val[OPT_SELECT_CAL_EXPOSURE_TIME].w) /* separate calibration exposure time */ { scanner->device->exposure_time_calibration_r = scanner->val[OPT_CAL_EXPOS_TIME_R].w; scanner->device->exposure_time_calibration_g = scanner->val[OPT_CAL_EXPOS_TIME_G].w; scanner->device->exposure_time_calibration_b = scanner->val[OPT_CAL_EXPOS_TIME_B].w; } else /* same exposure times for calibration as for scanning */ { scanner->device->exposure_time_calibration_r = scanner->val[OPT_SCAN_EXPOS_TIME_R].w; scanner->device->exposure_time_calibration_g = scanner->val[OPT_SCAN_EXPOS_TIME_G].w; scanner->device->exposure_time_calibration_b = scanner->val[OPT_SCAN_EXPOS_TIME_B].w; } scanner->device->exposure_time_scan_r = scanner->val[OPT_SCAN_EXPOS_TIME_R].w; scanner->device->exposure_time_scan_g = scanner->val[OPT_SCAN_EXPOS_TIME_G].w; scanner->device->exposure_time_scan_b = scanner->val[OPT_SCAN_EXPOS_TIME_B].w; } } } if (scanner->device->force_preview_bit_rgb != 0) /* in RGB-mode set preview bit, eg. for UMAX S6E */ { if (scanner->device->colormode == RGB) { DBG(DBG_sane_info,"setting preview bit = 1 (option force-preview-bit-rgb)\n"); scanner->device->preview = SANE_TRUE; } } #ifdef UMAX_CALIBRATION_MODE_SELECTABLE if (strcmp(scanner->val[OPT_CALIB_MODE].s, CALIB_MODE_0000) == 0) { scanner->device->calibration = 0; } else if (strcmp(scanner->val[OPT_CALIB_MODE].s, CALIB_MODE_1111) == 0) { scanner->device->calibration = 15; } else if (strcmp(scanner->val[OPT_CALIB_MODE].s, CALIB_MODE_1110) == 0) { scanner->device->calibration = 14; } else if (strcmp(scanner->val[OPT_CALIB_MODE].s, CALIB_MODE_1101) == 0) { scanner->device->calibration = 13; } else if (strcmp(scanner->val[OPT_CALIB_MODE].s, CALIB_MODE_1010) == 0) { scanner->device->calibration = 10; } else if (strcmp(scanner->val[OPT_CALIB_MODE].s, CALIB_MODE_1001) == 0) { scanner->device->calibration = 9; } #endif /* get and set geometric values for scanning */ scanner->device->x_resolution = SANE_UNFIX(scanner->val[OPT_X_RESOLUTION].w); scanner->device->y_resolution = SANE_UNFIX(scanner->val[OPT_Y_RESOLUTION].w); if ( (scanner->val[OPT_RESOLUTION_BIND].w == SANE_TRUE) || (scanner->val[OPT_PREVIEW].w == SANE_TRUE) ) { scanner->device->y_resolution = scanner->device->x_resolution; } xbasedots = scanner->device->x_coordinate_base / MM_PER_INCH; ybasedots = scanner->device->y_coordinate_base / MM_PER_INCH; #if 0 scanner->device->upper_left_x = ((int) (SANE_UNFIX(scanner->val[OPT_TL_X].w) * xbasedots)) & 65534; scanner->device->upper_left_y = ((int) (SANE_UNFIX(scanner->val[OPT_TL_Y].w) * ybasedots)) & 65534; scanner->device->scanwidth = ((int)((SANE_UNFIX(scanner->val[OPT_BR_X].w - scanner->val[OPT_TL_X].w)) * xbasedots)) & 65534; scanner->device->scanlength = ((int)((SANE_UNFIX(scanner->val[OPT_BR_Y].w - scanner->val[OPT_TL_Y].w)) * ybasedots)) & 65534; #endif scanner->device->upper_left_x = (int) (SANE_UNFIX(scanner->val[OPT_TL_X].w) * xbasedots); scanner->device->upper_left_y = (int) (SANE_UNFIX(scanner->val[OPT_TL_Y].w) * ybasedots); scanner->device->scanwidth = (int)((SANE_UNFIX(scanner->val[OPT_BR_X].w - scanner->val[OPT_TL_X].w)) * xbasedots); scanner->device->scanlength = (int)((SANE_UNFIX(scanner->val[OPT_BR_Y].w - scanner->val[OPT_TL_Y].w)) * ybasedots); if (umax_check_values(scanner->device) != 0) { DBG(DBG_error,"ERROR: invalid scan-values\n"); scanner->scanning = SANE_FALSE; return SANE_STATUS_INVAL; } /* The scanner defines a x-origin-offset for DOR mode, this offset is used for the */ /* x range in this backend, so the frontend/user knows the correct positions related to */ /* scanner's surface. But the scanner wants x values from origin 0 instead */ /* of the x-origin defined by the scanner`s inquiry */ if (scanner->device->dor != 0) /* dor mode active */ { 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 */ { scanner->device->upper_left_x = 0; /* but negative values are not allowed */ } } scanner->params.bytes_per_line = scanner->device->row_len; scanner->params.pixels_per_line = scanner->device->width_in_pixels; scanner->params.lines = scanner->device->length_in_pixels; /* set exposure times */ if ( scanner->device->inquiry_exposure_adj ) { umax_calculate_exposure_time(scanner->device, scanner->device->use_exposure_time_def_r, &scanner->device->exposure_time_calibration_r); umax_calculate_exposure_time(scanner->device, scanner->device->use_exposure_time_def_g, &scanner->device->exposure_time_calibration_g); umax_calculate_exposure_time(scanner->device, scanner->device->use_exposure_time_def_b, &scanner->device->exposure_time_calibration_b); umax_calculate_exposure_time(scanner->device, scanner->device->use_exposure_time_def_r, &scanner->device->exposure_time_scan_r); umax_calculate_exposure_time(scanner->device, scanner->device->use_exposure_time_def_g, &scanner->device->exposure_time_scan_g); umax_calculate_exposure_time(scanner->device, scanner->device->use_exposure_time_def_b, &scanner->device->exposure_time_scan_b); } else { scanner->device->exposure_time_calibration_r = scanner->device->exposure_time_calibration_g = scanner->device->exposure_time_calibration_b = scanner->device->exposure_time_scan_r = scanner->device->exposure_time_scan_g = scanner->device->exposure_time_scan_b = 0; } scanner->scanning = SANE_TRUE; sane_get_parameters(scanner, 0); DBG(DBG_sane_info,"x_resolution (dpi) = %u\n", scanner->device->x_resolution); DBG(DBG_sane_info,"y_resolution (dpi) = %u\n", scanner->device->y_resolution); DBG(DBG_sane_info,"x_coordinate_base (dpi) = %u\n", scanner->device->x_coordinate_base); DBG(DBG_sane_info,"y_coordinate_base (dpi) = %u\n", scanner->device->y_coordinate_base); DBG(DBG_sane_info,"upper_left_x (xbase) = %d\n", scanner->device->upper_left_x); DBG(DBG_sane_info,"upper_left_y (ybase) = %d\n", scanner->device->upper_left_y); DBG(DBG_sane_info,"scanwidth (xbase) = %u\n", scanner->device->scanwidth); DBG(DBG_sane_info,"scanlength (ybase) = %u\n", scanner->device->scanlength); DBG(DBG_sane_info,"width in pixels = %u\n", scanner->device->width_in_pixels); DBG(DBG_sane_info,"length in pixels = %u\n", scanner->device->length_in_pixels); DBG(DBG_sane_info,"bits per pixel/color = %u\n", scanner->device->bits_per_pixel); DBG(DBG_sane_info,"bytes per line = %d\n", scanner->params.bytes_per_line); DBG(DBG_sane_info,"pixels_per_line = %d\n", scanner->params.pixels_per_line); DBG(DBG_sane_info,"lines = %d\n", scanner->params.lines); DBG(DBG_sane_info,"negative = %d\n", scanner->device->reverse); DBG(DBG_sane_info,"threshold (lineart) = %d\n", scanner->device->threshold); DBG(DBG_sane_info,"brightness (halftone) = %d\n", scanner->device->brightness); DBG(DBG_sane_info,"contrast (halftone) = %d\n", scanner->device->contrast); DBG(DBG_sane_info,"analog_gamma = %d %d %d\n", scanner->device->analog_gamma_r, scanner->device->analog_gamma_g, scanner->device->analog_gamma_b); DBG(DBG_sane_info,"highlight = %d %d %d\n", scanner->device->highlight_r, scanner->device->highlight_g, scanner->device->highlight_b); DBG(DBG_sane_info,"shadow = %d %d %d\n", scanner->device->shadow_r, scanner->device->shadow_g, scanner->device->shadow_b); DBG(DBG_sane_info,"calibrat. exposure time = %d %d %d\n", scanner->device->exposure_time_calibration_r, scanner->device->exposure_time_calibration_g, scanner->device->exposure_time_calibration_b); DBG(DBG_sane_info,"scan exposure time = %d %d %d\n", scanner->device->exposure_time_scan_r, scanner->device->exposure_time_scan_g, scanner->device->exposure_time_scan_b); #ifdef UMAX_CALIBRATION_MODE_SELECTABLE DBG(DBG_sane_info,"calibration = %s\n", scanner->val[OPT_CALIB_MODE].s); #endif DBG(DBG_sane_info,"calibration mode number = %d\n", scanner->device->calibration); DBG(DBG_sane_info,"batch scan = %d\n", scanner->device->batch_scan); DBG(DBG_sane_info,"batch end = %d\n", scanner->device->batch_end); DBG(DBG_sane_info,"batch next top left y = %d\n", scanner->device->batch_next_tl_y); DBG(DBG_sane_info,"quality calibration = %d\n", scanner->device->quality); DBG(DBG_sane_info,"warm up = %d\n", scanner->device->warmup); DBG(DBG_sane_info,"fast preview function = %d\n", scanner->device->preview); DBG(DBG_sane_info,"DOR = %d\n", scanner->device->dor); DBG(DBG_sane_info,"ADF = %d\n", scanner->device->adf); DBG(DBG_sane_info,"manual focus = %d\n", scanner->device->manual_focus); DBG(DBG_sane_info,"fix focus position = %d\n", scanner->device->fix_focus_position); DBG(DBG_sane_info,"disable pre focus = %d\n", scanner->device->disable_pre_focus); DBG(DBG_sane_info,"lens cal in doc pos = %d\n", scanner->device->lens_cal_in_doc_pos); DBG(DBG_sane_info,"holder focus pos 0mm = %d\n", scanner->device->holder_focus_pos_0mm); if (scanner->val[OPT_PREVIEW].w) /* preview mode */ { scanner->device->lines_max = scanner->device->request_preview_lines; } else /* scan mode */ { scanner->device->lines_max = scanner->device->request_scan_lines; } #ifdef HAVE_SANEI_SCSI_OPEN_EXTENDED { unsigned int scsi_bufsize = 0; scsi_bufsize = scanner->device->width_in_pixels * scanner->device->lines_max; if (scsi_bufsize == 0) /* no scsi buffer size, take scanner buffer size */ { scsi_bufsize = scanner->device->inquiry_vidmem; } if (scsi_bufsize < scanner->device->scsi_buffer_size_min) /* make sure buffer has at least minimum size */ { scsi_bufsize = scanner->device->scsi_buffer_size_min; } else if (scsi_bufsize > scanner->device->scsi_buffer_size_max) /* make sure buffer does not exceed maximum size */ { scsi_bufsize = scanner->device->scsi_buffer_size_max; } if (umax_scsi_open_extended(scanner->device->sane.name, scanner->device, sense_handler, scanner->device, (int *) &scsi_bufsize) != 0) { DBG(DBG_error, "ERROR: sane_start: open failed\n"); scanner->scanning = SANE_FALSE; return SANE_STATUS_INVAL; } if (scsi_bufsize < scanner->device->scsi_buffer_size_min) /* minimum size must be available */ { DBG(DBG_error, "ERROR: sane_start: umax_scsi_open_extended returned too small scsi buffer\n"); umax_scsi_close((scanner->device)); scanner->scanning = SANE_FALSE; return SANE_STATUS_NO_MEM; } DBG(DBG_info, "sane_start: umax_scsi_open_extended returned scsi buffer size = %d\n", scsi_bufsize); if (scsi_bufsize < scanner->device->width_in_pixels) /* print warning when buffer is smaller than one scanline */ { DBG(DBG_warning, "WARNING: sane_start: scsi buffer is smaller than one scanline\n"); } if (scsi_bufsize != scanner->device->bufsize) { DBG(DBG_info, "sane_start: buffer size has changed, reallocating buffer\n"); if (scanner->device->buffer[0]) { DBG(DBG_info, "sane_start: freeing SCSI buffer[0]\n"); free(scanner->device->buffer[0]); /* free buffer */ } scanner->device->bufsize = scsi_bufsize; DBG(DBG_info, "sane_start: allocating SCSI buffer[0]\n"); scanner->device->buffer[0] = malloc(scanner->device->bufsize); /* allocate buffer */ if (!scanner->device->buffer[0]) /* malloc failed */ { DBG(DBG_error, "ERROR: sane_start: could not allocate buffer[0]\n"); umax_scsi_close(scanner->device); scanner->device->bufsize = 0; scanner->scanning = SANE_FALSE; return SANE_STATUS_NO_MEM; } } } #else if ( umax_scsi_open(scanner->device->sane.name, scanner->device, sense_handler, scanner->device) != SANE_STATUS_GOOD ) { scanner->scanning = SANE_FALSE; DBG(DBG_error, "ERROR: sane_start: open of %s failed:\n", scanner->device->sane.name); return SANE_STATUS_INVAL; } /* there is no need to reallocate the buffer because the size is fixed */ #endif /* grab scanner */ if (umax_grab_scanner(scanner->device)) { umax_scsi_close(scanner->device); scanner->scanning = SANE_FALSE; DBG(DBG_warning,"WARNING: unable to reserve scanner: device busy\n"); return SANE_STATUS_DEVICE_BUSY; } /* halftone pattern download is not ready in this version */ #if 0 /* send halftonepattern */ if ( (strcmp(mode, HALFTONE_STR) == 0) || (strcmp(mode, COLOR_HALFTONE_STR) == 0) ) { umax_send_halftone_pattern(scanner->device, (char *) &(scanner->halftone_pattern[0]), scanner->val[OPT_HALFTONE_DIMENSION].w ); scanner->device->halftone = WD_halftone_download; } /* end of send halftonepattern */ #endif } /* ------------ end of first call -------------- */ /* send gammacurves */ if (scanner->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE) { if (strcmp(mode, COLOR_STR) == 0) { if (scanner->device->three_pass == 0) /* one pass color scan */ { unsigned int i, dest, color, value; char *gamma; gamma = malloc( (size_t) (3 * scanner->gamma_length * scanner->output_bytes) ); if (gamma == NULL) { DBG(DBG_warning,"WARNING: not able to allocate memory for gamma table, gamma ignored !!!\n"); } else { dest=0; for(color=1; color <= 3; color++) { for(i=0; i < scanner->gamma_length; i++) { value = scanner->gamma_table[color][i]; if (scanner->output_bytes == 2) { gamma[dest++] = scanner->gamma_table[0][value] / 256; } gamma[dest++] = (scanner->gamma_table[0][value] & 255); } } DBG(DBG_sane_info,"sending 3 * %d bytes of gamma data for RGB\n", scanner->gamma_length * scanner->output_bytes); umax_send_gamma_data(scanner->device, &gamma[0], 3); scanner->device->digital_gamma_r = scanner->device->digital_gamma_g = scanner->device->digital_gamma_b = WD_gamma_download; free(gamma); } } else /* three pass color scan */ { unsigned int i, dest, color, value; char *gamma; gamma = malloc( (size_t) (scanner->gamma_length * scanner->output_bytes) ); if (gamma == NULL) { DBG(DBG_warning,"not able to allocate memory for gamma table, gamma ignored !!!\n"); } else { dest = 0; color = scanner->device->three_pass_color; for(i = 0; i < scanner->gamma_length; i++) { value = scanner->gamma_table[color][i]; if (scanner->output_bytes == 2) { gamma[dest++] = scanner->gamma_table[0][value] / 256; } gamma[dest++] = (scanner->gamma_table[0][value] & 255); } DBG(DBG_sane_info,"sending %d bytes of gamma data for color %d\n", scanner->gamma_length * scanner->output_bytes, color); umax_send_gamma_data(scanner->device, &gamma[0], 1); scanner->device->digital_gamma_r = scanner->device->digital_gamma_g = scanner->device->digital_gamma_b = WD_gamma_download; free(gamma); } } } else if (strcmp(mode, GRAY_STR) == 0) /* grayscale scan */ { unsigned int i, dest; char *gamma; gamma = malloc( (size_t) (scanner->gamma_length * scanner->output_bytes) ); if (gamma == NULL) { DBG(DBG_warning,"WARNING: not able to allocate memory for gamma table, gamma ignored !!!\n"); } else { dest=0; for(i=0; i < scanner->gamma_length; i++) { if (scanner->output_bytes == 2) { gamma[dest++] = scanner->gamma_table[0][i] / 256; } gamma[dest++] = (scanner->gamma_table[0][i] & 255); } DBG(DBG_sane_info,"sending %d bytes of gamma data for gray\n", scanner->gamma_length * scanner->output_bytes); umax_send_gamma_data(scanner->device, &gamma[0], 1); scanner->device->digital_gamma_r = WD_gamma_download; free(gamma); } } } /* end of send gammacurves */ if ( scanner->device->three_pass_color > WD_wid_red) /* three pass scan, not first pass */ { umax_reposition_scanner(scanner->device); } umax_set_window_param(scanner->device); status = umax_start_scan(scanner->device); if (status) /* errror */ { umax_give_scanner(scanner->device); /* reposition and release scanner */ return status; } pause = scanner->device->pause_for_color_calibration; if (scanner->device->colormode != RGB) { pause = scanner->device->pause_for_gray_calibration; } if (pause) /* Astra 2400S needs this pause (7sec in color, 4sec in gray mode) */ { DBG(DBG_info2,"pause for calibration %d msec ...\n", pause); usleep(((long) pause) * 1000); /* time in ms */ DBG(DBG_info2,"pause done\n"); } status = umax_do_calibration(scanner->device); if (status) /* errror */ { umax_give_scanner(scanner->device); /* reposition and release scanner */ return status; } if (scanner->device->pause_after_calibration) /* may be usefull */ { DBG(DBG_info2,"pause after calibration %d msec ...\n", scanner->device->pause_after_calibration); usleep(((long) scanner->device->pause_after_calibration) * 1000); /* time in ms */ DBG(DBG_info2,"pause done\n"); } if (pipe(fds) < 0) { DBG(DBG_error,"ERROR: could not create pipe\n"); scanner->scanning = SANE_FALSE; umax_give_scanner(scanner->device); /* reposition and release scanner */ umax_scsi_close(scanner->device); return SANE_STATUS_IO_ERROR; } scanner->pipe_read_fd = fds[0]; scanner->pipe_write_fd = fds[1]; /* start reader_process, deponds on OS if fork() or threads are used */ scanner->reader_pid = sanei_thread_begin(reader_process, (void *) scanner); if (!sanei_thread_is_valid (scanner->reader_pid)) { DBG(DBG_error, "ERROR: sanei_thread_begin failed (%s)\n", strerror(errno)); scanner->scanning = SANE_FALSE; umax_give_scanner(scanner->device); /* reposition and release scanner */ umax_scsi_close(scanner->device); return SANE_STATUS_NO_MEM; /* any other reason than no memory possible ? */ } if (sanei_thread_is_forked()) { close(scanner->pipe_write_fd); scanner->pipe_write_fd = -1; } return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ SANE READ ---------------------------------- */ SANE_Status sane_read(SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { Umax_Scanner *scanner = handle; ssize_t nread; *len = 0; nread = read(scanner->pipe_read_fd, buf, max_len); DBG(DBG_sane_info, "sane_read: read %ld bytes\n", (long) nread); if (!(scanner->scanning)) /* OOPS, not scanning */ { return do_cancel(scanner); } if (nread < 0) { if (errno == EAGAIN) { DBG(DBG_sane_info, "sane_read: EAGAIN\n"); return SANE_STATUS_GOOD; } else { do_cancel(scanner); /* we had an error, stop scanner */ return SANE_STATUS_IO_ERROR; } } *len = nread; if (nread == 0) /* EOF */ { if ( (scanner->device->three_pass == 0) || (scanner->device->colormode <= RGB_LINEART) || (++(scanner->device->three_pass_color) > 3) ) { do_cancel(scanner); } DBG(DBG_sane_proc,"closing read end of pipe\n"); if (scanner->pipe_read_fd >= 0) { close(scanner->pipe_read_fd); scanner->pipe_read_fd = -1; } return SANE_STATUS_EOF; } return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ SANE CANCEL -------------------------------- */ void sane_cancel(SANE_Handle handle) { Umax_Scanner *scanner = handle; DBG(DBG_sane_init,"sane_cancel\n"); if (scanner->scanning) { do_cancel(scanner); } } /* ------------------------------------------------------------ SANE SET IO MODE --------------------------- */ SANE_Status sane_set_io_mode(SANE_Handle handle, SANE_Bool non_blocking) { Umax_Scanner *scanner = handle; DBG(DBG_sane_init,"sane_set_io_mode: non_blocking=%d\n", non_blocking); if (!scanner->scanning) { return SANE_STATUS_INVAL; } if (fcntl(scanner->pipe_read_fd, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) { return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ SANE GET SELECT FD ------------------------- */ SANE_Status sane_get_select_fd(SANE_Handle handle, SANE_Int *fd) { Umax_Scanner *scanner = handle; DBG(DBG_sane_init,"sane_get_select_fd\n"); if (!scanner->scanning) { return SANE_STATUS_INVAL; } *fd = scanner->pipe_read_fd; return SANE_STATUS_GOOD; } /* ------------------------------------------------------------ EOF ---------------------------------------- */ sane-backends-1.0.29/backend/ibm.h0000666000000000000000000002262013615534521013512 00000000000000/* sane - Scanner Access Now Easy. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef ibm_h #define ibm_h 1 #include #include "../include/sane/config.h" /* defines for scan_image_mode field */ #define IBM_BINARY_MONOCHROME 0 #define IBM_DITHERED_MONOCHROME 1 #define IBM_GRAYSCALE 2 /* defines for paper field */ #define IBM_PAPER_USER_DEFINED 0 #define IBM_PAPER_A3 1 #define IBM_PAPER_A4 2 #define IBM_PAPER_A4L 3 #define IBM_PAPER_A5 4 #define IBM_PAPER_A5L 5 #define IBM_PAPER_A6 6 #define IBM_PAPER_B4 7 #define IBM_PAPER_B5 8 #define IBM_PAPER_LEGAL 9 #define IBM_PAPER_LETTER 10 /* sizes for mode parameter's base_measurement_unit */ #define INCHES 0 #define MILLIMETERS 1 #define POINTS 2 #define DEFAULT_MUD 1200 #define MEASUREMENTS_PAGE (SANE_Byte)(0x03) /* Mode Page Control */ #define PC_CURRENT 0x00 #define PC_CHANGE 0x40 #define PC_DEFAULT 0x80 #define PC_SAVED 0xc0 static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_HALFTONE, SANE_VALUE_SCAN_MODE_GRAY, 0 }; static const SANE_String_Const paper_list[] = { "User", "A3", "A4", "A4R", "A5", "A5R", "A6", "B4", "B5", "Legal", "Letter", 0 }; #define PAPER_A3_W 14032 #define PAPER_A3_H 19842 #define PAPER_A4_W 9921 #define PAPER_A4_H 14032 #define PAPER_A4R_W 14032 #define PAPER_A4R_H 9921 #define PAPER_A5_W 7016 #define PAPER_A5_H 9921 #define PAPER_A5R_W 9921 #define PAPER_A5R_H 7016 #define PAPER_A6_W 4960 #define PAPER_A6_H 7016 #define PAPER_B4_W 11811 #define PAPER_B4_H 16677 #define PAPER_B5_W 8598 #define PAPER_B5_H 12142 #define PAPER_LEGAL_W 10200 #define PAPER_LEGAL_H 16800 #define PAPER_LETTER_W 10200 #define PAPER_LETTER_H 13200 static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; static const SANE_Range ibm2456_res_range = { 100, /* minimum */ 600, /* maximum */ 0 /* quantization */ }; static const SANE_Range default_x_range = { 0, /* minimum */ /* (SANE_Word) ( * DEFAULT_MUD), maximum */ 14032, /* maximum (found empirically for Gray mode) */ /* in Lineart mode it works till 14062 */ 2 /* quantization */ }; static const SANE_Range default_y_range = { 0, /* minimum */ /* (SANE_Word) (14 * DEFAULT_MUD), maximum */ 20410, /* maximum (found empirically) */ 2 /* quantization */ }; static inline void _lto2b(SANE_Int val, SANE_Byte *bytes) { bytes[0] = (val >> 8) & 0xff; bytes[1] = val & 0xff; } static inline void _lto3b(SANE_Int val, SANE_Byte *bytes) { bytes[0] = (val >> 16) & 0xff; bytes[1] = (val >> 8) & 0xff; bytes[2] = val & 0xff; } static inline void _lto4b(SANE_Int val, SANE_Byte *bytes) { bytes[0] = (val >> 24) & 0xff; bytes[1] = (val >> 16) & 0xff; bytes[2] = (val >> 8) & 0xff; bytes[3] = val & 0xff; } static inline SANE_Int _2btol(SANE_Byte *bytes) { SANE_Int rv; rv = (bytes[0] << 8) | bytes[1]; return (rv); } static inline SANE_Int _3btol(SANE_Byte *bytes) { SANE_Int rv; rv = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2]; return (rv); } static inline SANE_Int _4btol(SANE_Byte *bytes) { SANE_Int rv; rv = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; return (rv); } typedef enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_X_RESOLUTION, OPT_Y_RESOLUTION, OPT_ADF, OPT_GEOMETRY_GROUP, OPT_PAPER, /* predefined formats */ OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_BRIGHTNESS, OPT_CONTRAST, /* must come last: */ NUM_OPTIONS } Ibm_Option; typedef struct Ibm_Info { SANE_Range xres_range; SANE_Range yres_range; SANE_Range x_range; SANE_Range y_range; SANE_Range brightness_range; SANE_Range contrast_range; SANE_Int xres_default; SANE_Int yres_default; SANE_Int image_mode_default; SANE_Int paper_default; SANE_Int brightness_default; SANE_Int contrast_default; SANE_Int adf_default; SANE_Int bmu; SANE_Int mud; } Ibm_Info; typedef struct Ibm_Device { struct Ibm_Device *next; SANE_Device sane; Ibm_Info info; } Ibm_Device; typedef struct Ibm_Scanner { /* all the state needed to define a scan request: */ struct Ibm_Scanner *next; int fd; /* SCSI filedescriptor */ SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Parameters params; /* scanner dependent/low-level state: */ Ibm_Device *hw; SANE_Int xres; SANE_Int yres; SANE_Int ulx; SANE_Int uly; SANE_Int width; SANE_Int length; SANE_Int brightness; SANE_Int contrast; SANE_Int image_composition; SANE_Int bpp; SANE_Bool reverse; /* next lines by mf */ SANE_Int adf_state; #define ADF_UNUSED 0 /* scan from flatbed, not ADF */ #define ADF_ARMED 1 /* scan from ADF, everything's set up */ #define ADF_CLEANUP 2 /* eject paper from ADF on close */ /* end lines by mf */ size_t bytes_to_read; int scanning; } Ibm_Scanner; struct inquiry_data { SANE_Byte devtype; SANE_Byte byte2; SANE_Byte byte3; SANE_Byte byte4; SANE_Byte byte5; SANE_Byte res1[2]; SANE_Byte flags; SANE_Byte vendor[8]; SANE_Byte product[8]; SANE_Byte revision[4]; SANE_Byte byte[60]; }; #define IBM_WINDOW_DATA_SIZE 320 struct ibm_window_data { /* header */ SANE_Byte reserved[6]; SANE_Byte len[2]; /* data */ SANE_Byte window_id; /* must be zero */ SANE_Byte reserved0; SANE_Byte x_res[2]; SANE_Byte y_res[2]; SANE_Byte x_org[4]; SANE_Byte y_org[4]; SANE_Byte width[4]; SANE_Byte length[4]; SANE_Byte brightness; SANE_Byte threshold; SANE_Byte contrast; SANE_Byte image_comp; /* image composition (data type) */ SANE_Byte bits_per_pixel; SANE_Byte halftone_code; /* halftone_pattern[0] in ricoh.h */ SANE_Byte halftone_id; /* halftone_pattern[1] in ricoh.h */ SANE_Byte pad_type; SANE_Byte bit_ordering[2]; SANE_Byte compression_type; SANE_Byte compression_arg; SANE_Byte res3[6]; /* Vendor Specific parameter byte(s) */ /* Ricoh specific, follow the scsi2 standard ones */ SANE_Byte byte1; SANE_Byte byte2; SANE_Byte mrif_filtering_gamma_id; SANE_Byte byte3; SANE_Byte byte4; SANE_Byte binary_filter; SANE_Byte reserved2[18]; SANE_Byte reserved3[256]; }; struct measurements_units_page { SANE_Byte page_code; /* 0x03 */ SANE_Byte parameter_length; /* 0x06 */ SANE_Byte bmu; SANE_Byte res1; SANE_Byte mud[2]; SANE_Byte res2[2]; /* anybody know what `COH' may mean ??? */ /* next 4 lines by mf */ SANE_Byte adf_page_code; SANE_Byte adf_parameter_length; SANE_Byte adf_control; SANE_Byte res3[5]; }; struct mode_pages { SANE_Byte page_code; SANE_Byte parameter_length; SANE_Byte rest[14]; /* modified by mf; it was 6; see above */ #if 0 SANE_Byte more_pages[243]; /* maximum size 255 bytes (incl header) */ #endif }; #endif /* ibm_h */ sane-backends-1.0.29/backend/plustek-usbimg.c0000666000000000000000000013613213615534521015715 00000000000000/*............................................................................. * Project : SANE library for Plustek flatbed scanners. *............................................................................. */ /** @file plustek-usbimg.c * @brief Image processing functions for copying and scaling image lines. * * Based on sources acquired from Plustek Inc.
* Copyright (C) 2001-2007 Gerhard Jaeger * * History: * - 0.40 - starting version of the USB support * - 0.41 - fixed the 14bit problem for LM9831 devices * - 0.42 - no changes * - 0.43 - no changes * - 0.44 - added CIS parts and dumpPic function * - 0.45 - added gray scaling functions for CIS devices * - fixed usb_GrayScale16 function * - fixed a bug in usb_ColorScale16_2 function * - fixed endless loop bug * - fixed a bug in usb_GrayScalePseudo16 function * - fixed a bug in usb_GrayDuplicatePseudo16 function * - removed the scaler stuff for CIS devices * - 0.46 - minor fixes * - 0.47 - added big-endian/little endian stuff * - 0.48 - fixed usb_ColorDuplicateGray16() and * usb_ColorScaleGray16() * - added usb_BWScaleFromColor() and usb_BWDuplicateFromColor() * - cleanup * - 0.49 - a_bRegs is now part of the device structure * - 0.50 - cleanup * - 0.51 - added usb_ColorDuplicateGray16_2(), usb_ColorScaleGray16_2() * usb_BWScaleFromColor_2() and usb_BWDuplicateFromColor_2() * - 0.52 - cleanup * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #define _SCALER 1000 static u_char bShift, Shift; static u_short wSum, Mask; /* */ static u_char BitTable[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; static u_char BitsReverseTable[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff }; /************************ some helper functions ******************************/ static void ReverseBits( int b, u_char **pTar, int *iByte, int *iWeightSum, int iSrcWeight, int iTarWeight, int cMax ) { int bit; cMax = (1 << cMax); if(iSrcWeight == iTarWeight) { for( bit = 1; bit < cMax; bit <<= 1) { *iByte <<= 1; if(b & bit) *iByte |= 1; if(*iByte >= 0x100) { **pTar++ = (u_char)*iByte; *iByte = 1; } } } else { for( bit = 1; bit < cMax; bit <<= 1 ) { *iWeightSum += iTarWeight; while(*iWeightSum >= iSrcWeight) { *iWeightSum -= iSrcWeight; *iByte <<= 1; if(b & bit) *iByte |= 1; if(*iByte >= 0x100) { **pTar++ = (u_char)*iByte; *iByte = 1; } } } } } static void usb_ReverseBitStream( u_char *pSrc, u_char *pTar, int iPixels, int iBufSize, int iSrcWeight/* = 0*/, int iTarWeight/* = 0*/, int iPadBit/* = 1*/) { int i; int iByte = 1; int cBytes = iPixels / 8; int cBits = iPixels % 8; u_char bPad = iPadBit? 0xff: 0; u_char *pTarget = pTar; int iWeightSum = 0; if(iSrcWeight == iTarWeight) { if(cBits) { int cShift = 8 - cBits; for(i = cBytes, pSrc = pSrc + cBytes - 1; i > 0; i--, pSrc--, pTar++) *pTar = BitsReverseTable[(u_char)((*pSrc << cBits) | (*(pSrc+1) >> cShift))]; ReverseBits(*(pSrc+1) >> cShift, &pTar, &iByte, &iWeightSum, iSrcWeight, iTarWeight, cBits); } else /* byte boundary */ { for(i = cBytes, pSrc = pSrc + cBytes - 1; i > 0; i--, pSrc--, pTar++) *pTar = BitsReverseTable[*pSrc]; } } else /* To shrink or enlarge */ { if(cBits) { int cShift = 8 - cBits; for(i = cBytes, pSrc = pSrc + cBytes - 1; i > 0; i--, pSrc--) ReverseBits((*pSrc << cBits) | (*(pSrc+1) >> cShift), &pTar, &iByte, &iWeightSum, iSrcWeight, iTarWeight, 8); ReverseBits(*(pSrc+1) >> cShift, &pTar, &iByte, &iWeightSum, iSrcWeight, iTarWeight, cBits); } else /* byte boundary */ { for(i = cBytes, pSrc = pSrc + cBytes - 1; i > 0; i--, pSrc--) ReverseBits(*pSrc, &pTar, &iByte, &iWeightSum, iSrcWeight, iTarWeight, 8); } } if(iByte != 1) { while(iByte < 0x100) { iByte <<= 1; iByte |= iPadBit; } *pTar++ = (u_char)iByte; } cBytes = (int)(pTar - pTarget); for(i = iBufSize - cBytes; i > 0; i--, pTar++) *pTar = bPad; } /** */ static void usb_AverageColorByte( Plustek_Device *dev ) { u_long dw; ScanDef *scan = &dev->scanning; if((scan->sParam.bSource == SOURCE_Negative || scan->sParam.bSource == SOURCE_Transparency) && scan->sParam.PhyDpi.x > 800) { for (dw = 0; dw < (scan->sParam.Size.dwPhyPixels - 1); dw++) { scan->Red.pcb[dw].a_bColor[0] = (u_char)(((u_short)scan->Red.pcb[dw].a_bColor[0] + (u_short)scan->Red.pcb[dw + 1].a_bColor[0]) / 2); scan->Green.pcb[dw].a_bColor[0] = (u_char)(((u_short)scan->Green.pcb[dw].a_bColor[0] + (u_short)scan->Green.pcb[dw + 1].a_bColor[0]) / 2); scan->Blue.pcb[dw].a_bColor[0] = (u_char)(((u_short)scan->Blue.pcb[dw].a_bColor[0] + (u_short)scan->Blue.pcb[dw + 1].a_bColor[0]) / 2); } } } /** */ static void usb_AverageColorWord( Plustek_Device *dev ) { u_char ls = 2; u_long dw; ScanDef *scan = &dev->scanning; if((scan->sParam.bSource == SOURCE_Negative || scan->sParam.bSource == SOURCE_Transparency) && scan->sParam.PhyDpi.x > 800) { scan->Red.pcw[0].Colors[0] = _HILO2WORD(scan->Red.pcw[0].HiLo[0]) >> ls; scan->Green.pcw[0].Colors[0] = _HILO2WORD(scan->Green.pcw[0].HiLo[0]) >> ls; scan->Blue.pcw[0].Colors[0] = _HILO2WORD(scan->Blue.pcw[0].HiLo[0]) >> ls; for (dw = 0; dw < (scan->sParam.Size.dwPhyPixels - 1); dw++) { scan->Red.pcw[dw + 1].Colors[0] = _HILO2WORD(scan->Red.pcw[dw + 1].HiLo[0]) >> ls; scan->Green.pcw[dw + 1].Colors[0] = _HILO2WORD(scan->Green.pcw[dw + 1].HiLo[0]) >> ls; scan->Blue.pcw[dw + 1].Colors[0] = _HILO2WORD(scan->Blue.pcw[dw + 1].HiLo[0]) >> ls; scan->Red.pcw[dw].Colors[0] = (u_short)(((u_long)scan->Red.pcw[dw].Colors[0] + (u_long)scan->Red.pcw[dw + 1].Colors[0]) / 2); scan->Green.pcw[dw].Colors[0] = (u_short)(((u_long)scan->Green.pcw[dw].Colors[0] + (u_long)scan->Green.pcw[dw + 1].Colors[0]) / 2); scan->Blue.pcw[dw].Colors[0] = (u_short)(((u_long)scan->Blue.pcw[dw].Colors[0] + (u_long)scan->Blue.pcw[dw + 1].Colors[0]) / 2); scan->Red.pcw[dw].Colors[0] = _HILO2WORD(scan->Red.pcw[dw].HiLo[0]) << ls; scan->Green.pcw[dw].Colors[0] = _HILO2WORD(scan->Green.pcw[dw].HiLo[0]) << ls; scan->Blue.pcw[dw].Colors[0] = _HILO2WORD(scan->Blue.pcw[dw].HiLo[0]) << ls; } scan->Red.pcw[dw].Colors[0] = _HILO2WORD(scan->Red.pcw[dw].HiLo[0]) << ls; scan->Green.pcw[dw].Colors[0] = _HILO2WORD(scan->Green.pcw[dw].HiLo[0]) << ls; scan->Blue.pcw[dw].Colors[0] = _HILO2WORD(scan->Blue.pcw[dw].HiLo[0]) << ls; } } /** */ static void usb_AverageGrayByte( Plustek_Device *dev ) { u_long dw; ScanDef *scan = &dev->scanning; if((scan->sParam.bSource == SOURCE_Negative || scan->sParam.bSource == SOURCE_Transparency) && scan->sParam.PhyDpi.x > 800) { for (dw = 0; dw < (scan->sParam.Size.dwPhyPixels - 1); dw++) scan->Green.pb[dw] = (u_char)(((u_short)scan->Green.pb[dw]+ (u_short)scan->Green.pb[dw+1]) / 2); } } /** */ static void usb_AverageGrayWord( Plustek_Device *dev ) { u_long dw; ScanDef *scan = &dev->scanning; if((scan->sParam.bSource == SOURCE_Negative || scan->sParam.bSource == SOURCE_Transparency) && scan->sParam.PhyDpi.x > 800) { scan->Green.pw[0] = _HILO2WORD(scan->Green.philo[0]) >> 2; for (dw = 0; dw < (scan->sParam.Size.dwPhyPixels - 1); dw++) { scan->Green.pw[dw + 1] = _HILO2WORD(scan->Green.philo[dw+1]) >> 2; scan->Green.pw[dw] = (u_short)(((u_long)scan->Green.pw[dw]+ (u_long)scan->Green.pw[dw+1]) / 2); scan->Green.pw[dw] = _HILO2WORD(scan->Green.philo[dw]) << 2; } scan->Green.pw[dw] = _HILO2WORD(scan->Green.philo[dw]) << 2; } } /** * returns the zoom value, used for our scaling algorithm (DDA algo * digital differential analyzer). */ static int usb_GetScaler( ScanDef *scan ) { double ratio; ratio = (double)scan->sParam.UserDpi.x/ (double)scan->sParam.PhyDpi.x; return (int)(1.0/ratio * _SCALER); } /******************************* the copy functions **************************/ /** do a simple memcopy from scan-buffer to user buffer */ static void usb_ColorDuplicate8( Plustek_Device *dev ) { int next; u_long dw, pixels; ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } for( dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next ) { scan->UserBuf.pb_rgb[pixels].Red = scan->Red.pcb[dw].a_bColor[0]; scan->UserBuf.pb_rgb[pixels].Green = scan->Green.pcb[dw].a_bColor[0]; scan->UserBuf.pb_rgb[pixels].Blue = scan->Blue.pcb[dw].a_bColor[0]; } } /** reorder from rgb line to rgb pixel (CIS scanner) */ static void usb_ColorDuplicate8_2( Plustek_Device *dev ) { int next; u_long dw, pixels; ScanDef *scan = &dev->scanning; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } for( dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next ) { scan->UserBuf.pb_rgb[pixels].Red = (u_char)scan->Red.pb[dw]; scan->UserBuf.pb_rgb[pixels].Green = (u_char)scan->Green.pb[dw]; scan->UserBuf.pb_rgb[pixels].Blue = (u_char)scan->Blue.pb[dw]; } } /** */ static void usb_ColorDuplicate16( Plustek_Device *dev ) { int next; u_char ls; u_long dw, pixels; ScanDef *scan = &dev->scanning; SANE_Bool swap = usb_HostSwap(); usb_AverageColorWord( dev ); if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { if( swap ) { scan->UserBuf.pw_rgb[pixels].Red = _HILO2WORD(scan->Red.pcw[dw].HiLo[0]) >> ls; scan->UserBuf.pw_rgb[pixels].Green = _HILO2WORD(scan->Green.pcw[dw].HiLo[0]) >> ls; scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(scan->Blue.pcw[dw].HiLo[0]) >> ls; } else { scan->UserBuf.pw_rgb[pixels].Red = scan->Red.pw[dw] >> ls; scan->UserBuf.pw_rgb[pixels].Green= scan->Green.pw[dw] >> ls; scan->UserBuf.pw_rgb[pixels].Blue = scan->Blue.pw[dw] >> ls; } } } /** */ static void usb_ColorDuplicate16_2( Plustek_Device *dev ) { int next; u_char ls; HiLoDef tmp; u_long dw, pixels; ScanDef *scan = &dev->scanning; SANE_Bool swap = usb_HostSwap(); usb_AverageColorWord( dev ); if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; for( dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { if( swap ) { tmp = *((HiLoDef*)&scan->Red.pw[dw]); scan->UserBuf.pw_rgb[pixels].Red = _HILO2WORD(tmp) >> ls; tmp = *((HiLoDef*)&scan->Green.pw[dw]); scan->UserBuf.pw_rgb[pixels].Green = _HILO2WORD(tmp) >> ls; tmp = *((HiLoDef*)&scan->Blue.pw[dw]); scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(tmp) >> ls; } else { scan->UserBuf.pw_rgb[pixels].Red = scan->Red.pw[dw] >> ls; scan->UserBuf.pw_rgb[pixels].Green = scan->Green.pw[dw] >> ls; scan->UserBuf.pw_rgb[pixels].Blue = scan->Blue.pw[dw] >> ls; } } } /** */ static void usb_ColorDuplicatePseudo16( Plustek_Device *dev ) { int next; u_short wR, wG, wB; u_long dw, pixels; ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); if (scan->sParam.bSource == SOURCE_ADF) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } wR = (u_short)scan->Red.pcb[0].a_bColor[0]; wG = (u_short)scan->Green.pcb[0].a_bColor[0]; wB = (u_short)scan->Blue.pcb[0].a_bColor[0]; for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { scan->UserBuf.pw_rgb[pixels].Red = (wR + scan->Red.pcb[dw].a_bColor[0]) << bShift; scan->UserBuf.pw_rgb[pixels].Green = (wG + scan->Green.pcb[dw].a_bColor[0]) << bShift; scan->UserBuf.pw_rgb[pixels].Blue = (wB + scan->Blue.pcb[dw].a_bColor[0]) << bShift; wR = (u_short)scan->Red.pcb[dw].a_bColor[0]; wG = (u_short)scan->Green.pcb[dw].a_bColor[0]; wB = (u_short)scan->Blue.pcb[dw].a_bColor[0]; } } /** */ static void usb_ColorDuplicateGray( Plustek_Device *dev ) { int next; u_long dw, pixels; ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); if (scan->sParam.bSource == SOURCE_ADF) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } switch(scan->fGrayFromColor) { case 1: for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pb[pixels] = scan->Red.pcb[dw].a_bColor[0]; break; case 2: for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pb[pixels] = scan->Green.pcb[dw].a_bColor[0]; break; case 3: for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pb[pixels] = scan->Blue.pcb[dw].a_bColor[0]; break; } } /** */ static void usb_ColorDuplicateGray_2( Plustek_Device *dev ) { int next; u_long dw, pixels; ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); if (scan->sParam.bSource == SOURCE_ADF) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } switch(scan->fGrayFromColor) { case 1: for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pb[pixels] = scan->Red.pb[dw]; break; case 3: for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pb[pixels] = scan->Blue.pb[dw]; break; default: for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pb[pixels] = scan->Green.pb[dw]; break; } } /** */ static void usb_ColorDuplicateGray16( Plustek_Device *dev ) { int next; u_char ls; u_long dw, pixels; ScanDef *scan = &dev->scanning; SANE_Bool swap = usb_HostSwap(); usb_AverageColorWord( dev ); if (scan->sParam.bSource == SOURCE_ADF) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; switch(scan->fGrayFromColor) { case 1: if( swap ) { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pw[pixels] = _HILO2WORD(scan->Red.pcw[dw].HiLo[0]) >> ls; } else { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pw[pixels] = scan->Red.pw[dw] >> ls; } break; case 2: if( swap ) { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pw[pixels] = _HILO2WORD(scan->Green.pcw[dw].HiLo[0]) >> ls; } else { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pw[pixels] = scan->Green.pw[dw] >> ls; } break; case 3: if( swap ) { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pw[pixels] = _HILO2WORD(scan->Blue.pcw[dw].HiLo[0]) >> ls; } else { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) scan->UserBuf.pw[pixels] = scan->Blue.pw[dw] >> ls; } break; } } /** */ static void usb_ColorDuplicateGray16_2( Plustek_Device *dev ) { int next; u_char ls; u_long dw, pixels; HiLoDef tmp; ScanDef *scan = &dev->scanning; SANE_Bool swap = usb_HostSwap(); usb_AverageColorWord( dev ); if (scan->sParam.bSource == SOURCE_ADF) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; switch(scan->fGrayFromColor) { case 1: if( swap ) { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { tmp = *((HiLoDef*)&scan->Red.pw[dw]); scan->UserBuf.pw[pixels] = _HILO2WORD(tmp) >> ls; } } else { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { scan->UserBuf.pw[pixels] = scan->Red.pw[dw] >> ls; } } break; case 2: if( swap ) { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { tmp = *((HiLoDef*)&scan->Green.pw[dw]); scan->UserBuf.pw[pixels] = _HILO2WORD(tmp) >> ls; } } else { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { scan->UserBuf.pw[pixels] = scan->Green.pw[dw] >> ls; } } break; case 3: if( swap ) { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { tmp = *((HiLoDef*)&scan->Blue.pw[dw]); scan->UserBuf.pw[pixels] = _HILO2WORD(tmp) >> ls; } } else { for (dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { scan->UserBuf.pw[pixels] = scan->Blue.pw[dw] >> ls; } } break; } } /** */ static void usb_GrayDuplicate8( Plustek_Device *dev ) { u_char *dest, *src; u_long pixels; ScanDef *scan = &dev->scanning; usb_AverageGrayByte( dev ); if( scan->sParam.bSource == SOURCE_ADF ) { pixels = scan->sParam.Size.dwPixels; src = scan->Green.pb; dest = scan->UserBuf.pb + pixels - 1; for(; pixels; pixels--, src++, dest--) *dest = *src; } else { memcpy( scan->UserBuf.pb, scan->Green.pb, scan->sParam.Size.dwBytes ); } } /** */ static void usb_GrayDuplicate16( Plustek_Device *dev ) { int next; u_char ls; u_short *dest; u_long pixels; HiLoDef *pwm; ScanDef *scan = &dev->scanning; SANE_Bool swap = usb_HostSwap(); usb_AverageGrayWord( dev ); if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; dest = scan->UserBuf.pw + scan->sParam.Size.dwPixels - 1; } else { next = 1; dest = scan->UserBuf.pw; } if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; pwm = scan->Green.philo; for( pixels=scan->sParam.Size.dwPixels; pixels--; pwm++, dest += next ) { if( swap ) *dest = (_PHILO2WORD(pwm)) >> ls; else *dest = (_PLOHI2WORD(pwm)) >> ls; } } /** */ static void usb_GrayDuplicatePseudo16( Plustek_Device *dev ) { u_char *src; int next; u_short g; u_short *dest; u_long pixels; ScanDef *scan = &dev->scanning; usb_AverageGrayByte( dev ); if (scan->sParam.bSource == SOURCE_ADF) { next = -1; dest = scan->UserBuf.pw + scan->sParam.Size.dwPixels - 1; } else { next = 1; dest = scan->UserBuf.pw; } src = scan->Green.pb; g = (u_short)*src; for( pixels=scan->sParam.Size.dwPixels; pixels--; src++, dest += next ) { *dest = (g + *src) << bShift; g = (u_short)*src; } } /** copy binary data to the user buffer */ static void usb_BWDuplicate( Plustek_Device *dev ) { ScanDef *scan = &dev->scanning; if(scan->sParam.bSource == SOURCE_ADF) { usb_ReverseBitStream( scan->Green.pb, scan->UserBuf.pb, scan->sParam.Size.dwValidPixels, scan->dwBytesLine, 0, 0, 1 ); } else { memcpy( scan->UserBuf.pb, scan->Green.pb, scan->sParam.Size.dwBytes ); } } /** generate binary data from one of the three color inputs according to the * value in fGrayFromColor (CCD version) */ static void usb_BWDuplicateFromColor( Plustek_Device *dev ) { int next; u_char d, s, *dest; u_short j; u_long pixels; ColorByteDef *src; ScanDef *scan = &dev->scanning; if( scan->sParam.bSource == SOURCE_ADF ) { dest = scan->UserBuf.pb + scan->sParam.Size.dwPixels - 1; next = -1; } else { dest = scan->UserBuf.pb; next = 1; } switch(scan->fGrayFromColor) { case 1: src = scan->Red.pcb; break; case 3: src = scan->Blue.pcb; break; default: src = scan->Green.pcb; break; } d = j = 0; for( pixels = scan->sParam.Size.dwPixels; pixels; pixels--, src++ ) { s = src->a_bColor[0]; if( s != 0 ) d |= BitTable[j]; j++; if( j == 8 ) { *dest = d; dest += next; d = j = 0; } } } /** generate binary data from one of the three color inputs according to the * value in fGrayFromColor (CIS version) */ static void usb_BWDuplicateFromColor_2( Plustek_Device *dev ) { int next; u_char d, *dest, *src; u_short j; u_long pixels; ScanDef *scan = &dev->scanning; if( scan->sParam.bSource == SOURCE_ADF ) { dest = scan->UserBuf.pb + scan->sParam.Size.dwPixels - 1; next = -1; } else { dest = scan->UserBuf.pb; next = 1; } switch(scan->fGrayFromColor) { case 1: src = scan->Red.pb; break; case 3: src = scan->Blue.pb; break; default: src = scan->Green.pb; break; } d = j = 0; for( pixels = scan->sParam.Size.dwPixels; pixels; pixels--, src++ ) { if( *src != 0 ) d |= BitTable[j]; j++; if( j == 8 ) { *dest = d; dest += next; d = j = 0; } } } /************************** the scaling functions ****************************/ /** */ static void usb_ColorScaleGray( Plustek_Device *dev ) { int izoom, ddax, next; u_long dw, pixels; ColorByteDef *src; ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } switch(scan->fGrayFromColor) { case 1: src = scan->Red.pcb; break; case 3: src = scan->Blue.pcb; break; default: src = scan->Green.pcb; break; } izoom = usb_GetScaler( scan ); for( ddax = 0; dw; src++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { scan->UserBuf.pb[pixels] = src->a_bColor[0]; pixels += next; ddax += izoom; dw--; } } } /** */ static void usb_ColorScaleGray_2( Plustek_Device *dev ) { u_char *src; int izoom, ddax, next; u_long dw, pixels; ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } switch(scan->fGrayFromColor) { case 1: src = scan->Red.pb; break; case 3: src = scan->Blue.pb; break; default: src = scan->Green.pb; break; } izoom = usb_GetScaler( scan ); for( ddax = 0; dw; src++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { scan->UserBuf.pb[pixels] = *src; pixels += next; ddax += izoom; dw--; } } } /** */ static void usb_ColorScaleGray16( Plustek_Device *dev ) { u_char ls; int izoom, ddax, next; u_long dw, pixels, bitsput; SANE_Bool swap = usb_HostSwap(); ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } izoom = usb_GetScaler( scan ); if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; switch( scan->fGrayFromColor ) { case 1: for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { if( swap ) { scan->UserBuf.pw[pixels] = _HILO2WORD(scan->Red.pcw[bitsput].HiLo[0]) >> ls; } else { scan->UserBuf.pw[pixels] = scan->Red.pw[bitsput] >> ls; } pixels += next; ddax += izoom; dw--; } } break; case 2: for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { if( swap ) { scan->UserBuf.pw[pixels] = _HILO2WORD(scan->Green.pcw[bitsput].HiLo[0]) >> ls; } else { scan->UserBuf.pw[pixels] = scan->Green.pw[bitsput] >> ls; } pixels += next; ddax += izoom; dw--; } } break; case 3: for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { if( swap ) { scan->UserBuf.pw[pixels] = _HILO2WORD(scan->Blue.pcw[bitsput].HiLo[0]) >> ls; } else { scan->UserBuf.pw[pixels] = scan->Blue.pw[bitsput] >> ls; } pixels += next; ddax += izoom; dw--; } } break; } } /** */ static void usb_ColorScaleGray16_2( Plustek_Device *dev ) { u_char ls; int izoom, ddax, next; u_long dw, pixels, bitsput; HiLoDef tmp; SANE_Bool swap = usb_HostSwap(); ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } izoom = usb_GetScaler( scan ); if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; switch( scan->fGrayFromColor ) { case 1: for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { if( swap ) { tmp = *((HiLoDef*)&scan->Red.pw[bitsput]); scan->UserBuf.pw[pixels] = _HILO2WORD(tmp) >> ls; } else { scan->UserBuf.pw[pixels] = scan->Red.pw[dw] >> ls; } pixels += next; ddax += izoom; dw--; } } break; case 2: for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { if( swap ) { tmp = *((HiLoDef*)&scan->Green.pw[bitsput]); scan->UserBuf.pw[pixels] = _HILO2WORD(tmp) >> ls; } else { scan->UserBuf.pw[pixels] = scan->Green.pw[bitsput] >> ls; } pixels += next; ddax += izoom; dw--; } } break; case 3: for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { if( swap ) { tmp = *((HiLoDef*)&scan->Blue.pw[bitsput]); scan->UserBuf.pw[pixels] = _HILO2WORD(tmp) >> ls; } else { scan->UserBuf.pw[pixels] = scan->Blue.pw[bitsput] >> ls; } pixels += next; ddax += izoom; dw--; } } break; } } /** here we copy and scale from scanner world to user world... */ static void usb_ColorScale8( Plustek_Device *dev ) { int izoom, ddax, next; u_long dw, pixels, bitsput; ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } izoom = usb_GetScaler( scan ); for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { scan->UserBuf.pb_rgb[pixels].Red = scan->Red.pcb[bitsput].a_bColor[0]; scan->UserBuf.pb_rgb[pixels].Green = scan->Green.pcb[bitsput].a_bColor[0]; scan->UserBuf.pb_rgb[pixels].Blue = scan->Blue.pcb[bitsput].a_bColor[0]; pixels += next; ddax += izoom; dw--; } } } static void usb_ColorScale8_2( Plustek_Device *dev ) { int izoom, ddax, next; u_long dw, pixels, bitsput; ScanDef *scan = &dev->scanning; dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } izoom = usb_GetScaler( scan ); for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { scan->UserBuf.pb_rgb[pixels].Red = scan->Red.pb[bitsput]; scan->UserBuf.pb_rgb[pixels].Green = scan->Green.pb[bitsput]; scan->UserBuf.pb_rgb[pixels].Blue = scan->Blue.pb[bitsput]; pixels += next; ddax += izoom; dw--; } } } /** */ static void usb_ColorScale16( Plustek_Device *dev ) { u_char ls; int izoom, ddax, next; u_long dw, pixels, bitsput; SANE_Bool swap = usb_HostSwap(); ScanDef *scan = &dev->scanning; usb_AverageColorWord( dev ); dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } izoom = usb_GetScaler( scan ); if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { if( swap ) { scan->UserBuf.pw_rgb[pixels].Red = _HILO2WORD(scan->Red.pcw[bitsput].HiLo[0]) >> ls; scan->UserBuf.pw_rgb[pixels].Green = _HILO2WORD(scan->Green.pcw[bitsput].HiLo[0]) >> ls; scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(scan->Blue.pcw[bitsput].HiLo[0]) >> ls; } else { scan->UserBuf.pw_rgb[pixels].Red = scan->Red.pw[bitsput]>>ls; scan->UserBuf.pw_rgb[pixels].Green = scan->Green.pw[bitsput] >> ls; scan->UserBuf.pw_rgb[pixels].Blue = scan->Blue.pw[bitsput] >> ls; } pixels += next; ddax += izoom; dw--; } } } /** */ static void usb_ColorScale16_2( Plustek_Device *dev ) { u_char ls; HiLoDef tmp; int izoom, ddax, next; u_long dw, pixels, bitsput; SANE_Bool swap = usb_HostSwap(); ScanDef *scan = &dev->scanning; usb_AverageColorWord( dev ); dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } izoom = usb_GetScaler( scan ); if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { if( swap ) { tmp = *((HiLoDef*)&scan->Red.pw[bitsput]); scan->UserBuf.pw_rgb[pixels].Red = _HILO2WORD(tmp) >> ls; tmp = *((HiLoDef*)&scan->Green.pw[bitsput]); scan->UserBuf.pw_rgb[pixels].Green = _HILO2WORD(tmp) >> ls; tmp = *((HiLoDef*)&scan->Blue.pw[bitsput]); scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(tmp) >> ls; } else { scan->UserBuf.pw_rgb[pixels].Red = scan->Red.pw[bitsput] >> ls; scan->UserBuf.pw_rgb[pixels].Green = scan->Green.pw[bitsput] >> ls; scan->UserBuf.pw_rgb[pixels].Blue = scan->Blue.pw[bitsput] >> ls; } pixels += next; ddax += izoom; dw--; } } } /** */ static void usb_ColorScalePseudo16( Plustek_Device *dev ) { int izoom, ddax, next; u_short wR, wG, wB; u_long dw, pixels, bitsput; ScanDef *scan = &dev->scanning; usb_AverageColorByte( dev ); dw = scan->sParam.Size.dwPixels; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; pixels = scan->sParam.Size.dwPixels - 1; } else { next = 1; pixels = 0; } izoom = usb_GetScaler( scan ); wR = (u_short)scan->Red.pcb[0].a_bColor[0]; wG = (u_short)scan->Green.pcb[0].a_bColor[1]; wB = (u_short)scan->Blue.pcb[0].a_bColor[2]; for( bitsput = 0, ddax = 0; dw; bitsput++ ) { ddax -= _SCALER; while((ddax < 0) && (dw > 0)) { scan->UserBuf.pw_rgb[pixels].Red = (wR + scan->Red.pcb[bitsput].a_bColor[0]) << bShift; scan->UserBuf.pw_rgb[pixels].Green = (wG + scan->Green.pcb[bitsput].a_bColor[0]) << bShift; scan->UserBuf.pw_rgb[pixels].Blue = (wB + scan->Blue.pcb[bitsput].a_bColor[0]) << bShift; pixels += next; ddax += izoom; dw--; } wR = (u_short)scan->Red.pcb[bitsput].a_bColor[0]; wG = (u_short)scan->Green.pcb[bitsput].a_bColor[0]; wB = (u_short)scan->Blue.pcb[bitsput].a_bColor[0]; } } /** */ static void usb_BWScale( Plustek_Device *dev ) { u_char tmp, *dest, *src; int izoom, ddax; u_long i, dw; ScanDef *scan = &dev->scanning; src = scan->Green.pb; if( scan->sParam.bSource == SOURCE_ADF ) { int iSum = wSum; usb_ReverseBitStream(scan->Green.pb, scan->UserBuf.pb, scan->sParam.Size.dwValidPixels, scan->dwBytesLine, scan->sParam.PhyDpi.x, scan->sParam.UserDpi.x, 1 ); wSum = iSum; return; } else { dest = scan->UserBuf.pb; } izoom = usb_GetScaler( scan ); memset( dest, 0, scan->dwBytesLine ); ddax = 0; dw = 0; for( i = 0; i < scan->sParam.Size.dwValidPixels; i++ ) { ddax -= _SCALER; while( ddax < 0 ) { tmp = src[(i>>3)]; if((dw>>3) < scan->sParam.Size.dwValidPixels ) { if( 0 != (tmp &= (1 << ((~(i & 0x7))&0x7)))) dest[dw>>3] |= (1 << ((~(dw & 0x7))&0x7)); } dw++; ddax += izoom; } } } /** */ static void usb_BWScaleFromColor( Plustek_Device *dev ) { u_char d, s, *dest; u_short j; u_long pixels; int izoom, ddax, next; ColorByteDef *src; ScanDef *scan = &dev->scanning; if (scan->sParam.bSource == SOURCE_ADF) { dest = scan->UserBuf.pb + scan->sParam.Size.dwPixels - 1; next = -1; } else { dest = scan->UserBuf.pb; next = 1; } /* setup the source buffer */ switch(scan->fGrayFromColor) { case 1: src = scan->Red.pcb; break; case 3: src = scan->Blue.pcb; break; default: src = scan->Green.pcb; break; } izoom = usb_GetScaler( scan ); ddax = 0; d = j = 0; for( pixels = scan->sParam.Size.dwPixels; pixels; src++ ) { ddax -= _SCALER; while((ddax < 0) && (pixels > 0)) { s = src->a_bColor[0]; if( s != 0 ) d |= BitTable[j]; j++; if( j == 8 ) { *dest = d; dest += next; d = j = 0; } ddax += izoom; pixels--; } } } /** */ static void usb_BWScaleFromColor_2( Plustek_Device *dev ) { u_char d, *dest, *src; u_short j; u_long pixels; int izoom, ddax, next; ScanDef *scan = &dev->scanning; if (scan->sParam.bSource == SOURCE_ADF) { dest = scan->UserBuf.pb + scan->sParam.Size.dwPixels - 1; next = -1; } else { dest = scan->UserBuf.pb; next = 1; } /* setup the source buffer */ switch(scan->fGrayFromColor) { case 1: src = scan->Red.pb; break; case 3: src = scan->Blue.pb; break; default: src = scan->Green.pb; break; } izoom = usb_GetScaler( scan ); ddax = 0; d = j = 0; for( pixels = scan->sParam.Size.dwPixels; pixels; src++ ) { ddax -= _SCALER; while((ddax < 0) && (pixels > 0)) { if( *src != 0 ) d |= BitTable[j]; j++; if( j == 8 ) { *dest = d; dest += next; d = j = 0; } ddax += izoom; pixels--; } } } /** */ static void usb_GrayScale8( Plustek_Device *dev ) { u_char *dest, *src; int izoom, ddax, next; u_long pixels; ScanDef *scan = &dev->scanning; usb_AverageGrayByte( dev ); src = scan->Green.pb; if( scan->sParam.bSource == SOURCE_ADF ) { dest = scan->UserBuf.pb + scan->sParam.Size.dwPixels - 1; next = -1; } else { dest = scan->UserBuf.pb; next = 1; } izoom = usb_GetScaler( scan ); ddax = 0; for( pixels = scan->sParam.Size.dwPixels; pixels; src++ ) { ddax -= _SCALER; while((ddax < 0) && (pixels > 0)) { *dest = *src; dest += next; ddax += izoom; pixels--; } } } /** */ static void usb_GrayScale16( Plustek_Device *dev ) { u_char ls; int izoom, ddax, next; u_short *dest; u_long pixels; HiLoDef *pwm; ScanDef *scan = &dev->scanning; SANE_Bool swap = usb_HostSwap(); usb_AverageGrayWord( dev); pwm = scan->Green.philo; wSum = scan->sParam.PhyDpi.x; if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; dest = scan->UserBuf.pw + scan->sParam.Size.dwPixels - 1; } else { next = 1; dest = scan->UserBuf.pw; } izoom = usb_GetScaler( scan ); ddax = 0; if( scan->dwFlag & SCANFLAG_RightAlign ) ls = Shift; else ls = 0; for( pixels = scan->sParam.Size.dwPixels; pixels; pwm++ ) { ddax -= _SCALER; while((ddax < 0) && (pixels > 0)) { if( swap ) *dest = _PHILO2WORD(pwm) >> ls; else *dest = _PLOHI2WORD(pwm) >> ls; dest += next; ddax += izoom; pixels--; } } } /** */ static void usb_GrayScalePseudo16( Plustek_Device *dev ) { u_char *src; int izoom, ddax, next; u_short *dest, g; u_long pixels; ScanDef *scan = &dev->scanning; usb_AverageGrayByte( dev ); if( scan->sParam.bSource == SOURCE_ADF ) { next = -1; dest = scan->UserBuf.pw + scan->sParam.Size.dwPixels - 1; } else { next = 1; dest = scan->UserBuf.pw; } src = scan->Green.pb; g = (u_short)*src; izoom = usb_GetScaler( scan ); ddax = 0; for( pixels = scan->sParam.Size.dwPixels; pixels; src++ ) { ddax -= _SCALER; while((ddax < 0) && (pixels > 0)) { *dest = (g + *src) << bShift; dest += next; ddax += izoom; pixels--; } g = (u_short)*src; } } /** function to select the apropriate pixel copy function */ static void usb_GetImageProc( Plustek_Device *dev ) { ScanDef *scan = &dev->scanning; DCapsDef *sc = &dev->usbDev.Caps; HWDef *hw = &dev->usbDev.HwSetting; bShift = 0; if( scan->sParam.UserDpi.x != scan->sParam.PhyDpi.x ) { /* Pixel scaling... */ switch( scan->sParam.bDataType ) { case SCANDATATYPE_Color: if (scan->sParam.bBitDepth > 8) { if( usb_IsCISDevice(dev)){ scan->pfnProcess = usb_ColorScale16_2; DBG( _DBG_INFO, "ImageProc is: ColorScale16_2\n" ); } else { scan->pfnProcess = usb_ColorScale16; DBG( _DBG_INFO, "ImageProc is: ColorScale16\n" ); } if (scan->fGrayFromColor) { if( usb_IsCISDevice(dev)){ scan->pfnProcess = usb_ColorScaleGray16_2; DBG( _DBG_INFO, "ImageProc is: ColorScaleGray16_2\n" ); } else { scan->pfnProcess = usb_ColorScaleGray16; DBG( _DBG_INFO, "ImageProc is: ColorScaleGray16\n" ); } } } else if (scan->dwFlag & SCANFLAG_Pseudo48) { scan->pfnProcess = usb_ColorScalePseudo16; DBG( _DBG_INFO, "ImageProc is: ColorScalePseudo16\n" ); } else if (scan->fGrayFromColor) { if( usb_IsCISDevice(dev)){ if (scan->fGrayFromColor > 7 ) { scan->pfnProcess = usb_BWScaleFromColor_2; DBG( _DBG_INFO, "ImageProc is: BWScaleFromColor_2\n" ); } else { scan->pfnProcess = usb_ColorScaleGray_2; DBG( _DBG_INFO, "ImageProc is: ColorScaleGray_2\n" ); } } else { if (scan->fGrayFromColor > 7 ) { scan->pfnProcess = usb_BWScaleFromColor; DBG( _DBG_INFO, "ImageProc is: BWScaleFromColor\n" ); } else { scan->pfnProcess = usb_ColorScaleGray; DBG( _DBG_INFO, "ImageProc is: ColorScaleGray\n" ); } } } else { if( usb_IsCISDevice(dev)){ scan->pfnProcess = usb_ColorScale8_2; DBG( _DBG_INFO, "ImageProc is: ColorScale8_2\n" ); } else { scan->pfnProcess = usb_ColorScale8; DBG( _DBG_INFO, "ImageProc is: ColorScale8\n" ); } } break; case SCANDATATYPE_Gray: if (scan->sParam.bBitDepth > 8) { scan->pfnProcess = usb_GrayScale16; DBG( _DBG_INFO, "ImageProc is: GrayScale16\n" ); } else { if (scan->dwFlag & SCANFLAG_Pseudo48) { scan->pfnProcess = usb_GrayScalePseudo16; DBG( _DBG_INFO, "ImageProc is: GrayScalePseudo16\n" ); } else { scan->pfnProcess = usb_GrayScale8; DBG( _DBG_INFO, "ImageProc is: GrayScale8\n" ); } } break; default: scan->pfnProcess = usb_BWScale; DBG( _DBG_INFO, "ImageProc is: BWScale\n" ); break; } } else { /* Pixel copy */ switch( scan->sParam.bDataType ) { case SCANDATATYPE_Color: if (scan->sParam.bBitDepth > 8) { if( usb_IsCISDevice(dev)){ scan->pfnProcess = usb_ColorDuplicate16_2; DBG( _DBG_INFO, "ImageProc is: ColorDuplicate16_2\n" ); } else { scan->pfnProcess = usb_ColorDuplicate16; DBG( _DBG_INFO, "ImageProc is: ColorDuplicate16\n" ); } if (scan->fGrayFromColor) { if( usb_IsCISDevice(dev)){ scan->pfnProcess = usb_ColorDuplicateGray16_2; DBG( _DBG_INFO, "ImageProc is: ColorDuplicateGray16_2\n" ); } else { scan->pfnProcess = usb_ColorDuplicateGray16; DBG( _DBG_INFO, "ImageProc is: ColorDuplicateGray16\n" ); } } } else if (scan->dwFlag & SCANFLAG_Pseudo48) { scan->pfnProcess = usb_ColorDuplicatePseudo16; DBG( _DBG_INFO, "ImageProc is: ColorDuplicatePseudo16\n" ); } else if (scan->fGrayFromColor) { if( usb_IsCISDevice(dev)){ if (scan->fGrayFromColor > 7 ) { scan->pfnProcess = usb_BWDuplicateFromColor_2; DBG( _DBG_INFO, "ImageProc is: BWDuplicateFromColor_2\n" ); } else { scan->pfnProcess = usb_ColorDuplicateGray_2; DBG( _DBG_INFO, "ImageProc is: ColorDuplicateGray_2\n" ); } } else { if (scan->fGrayFromColor > 7 ) { scan->pfnProcess = usb_BWDuplicateFromColor; DBG( _DBG_INFO, "ImageProc is: BWDuplicateFromColor\n" ); } else { scan->pfnProcess = usb_ColorDuplicateGray; DBG( _DBG_INFO, "ImageProc is: ColorDuplicateGray\n" ); } } } else { if( usb_IsCISDevice(dev)){ scan->pfnProcess = usb_ColorDuplicate8_2; DBG( _DBG_INFO, "ImageProc is: ColorDuplicate8_2\n" ); } else { scan->pfnProcess = usb_ColorDuplicate8; DBG( _DBG_INFO, "ImageProc is: ColorDuplicate8\n" ); } } break; case SCANDATATYPE_Gray: if (scan->sParam.bBitDepth > 8) { scan->pfnProcess = usb_GrayDuplicate16; DBG( _DBG_INFO, "ImageProc is: GrayDuplicate16\n" ); } else { if (scan->dwFlag & SCANFLAG_Pseudo48) { scan->pfnProcess = usb_GrayDuplicatePseudo16; DBG( _DBG_INFO, "ImageProc is: GrayDuplicatePseudo16\n" ); } else { scan->pfnProcess = usb_GrayDuplicate8; DBG( _DBG_INFO, "ImageProc is: GrayDuplicate8\n" ); } } break; default: scan->pfnProcess = usb_BWDuplicate; DBG( _DBG_INFO, "ImageProc is: BWDuplicate\n" ); break; } } if( scan->sParam.bBitDepth == 8 ) { if( scan->dwFlag & SCANFLAG_Pseudo48 ) { if( scan->dwFlag & SCANFLAG_RightAlign ) { bShift = 5; } else { /* this should fix the Bearpaw/U12 discrepancy * in general the fix is needed, but not for the U12 * why? - no idea! */ if(_WAF_BSHIFT7_BUG == (_WAF_BSHIFT7_BUG & sc->workaroundFlag)) bShift = 0; /* Holger Bischof 16.12.2001 */ else bShift = 7; } DBG( _DBG_INFO, "bShift adjusted: %u\n", bShift ); } } if( _LM9833 == hw->chip ) { Shift = 0; Mask = 0xFFFF; } else { Shift = 2; Mask = 0xFFFC; } } /** * here we read the image data into our intermediate buffer (in the NT version * the function was implemented as thread) */ static SANE_Int usb_ReadData( Plustek_Device *dev ) { u_long dw, dwRet, dwBytes, pl; ScanDef *scan = &dev->scanning; HWDef *hw = &dev->usbDev.HwSetting; DBG( _DBG_READ, "usb_ReadData()\n" ); pl = dev->usbDev.a_bRegs[0x4e] * hw->wDRAMSize/128; while( scan->sParam.Size.dwTotalBytes ) { if( usb_IsEscPressed()) { DBG( _DBG_INFO, "usb_ReadData() - Cancel detected...\n" ); return 0; } if( scan->sParam.Size.dwTotalBytes > scan->dwBytesScanBuf ) dw = scan->dwBytesScanBuf; else dw = scan->sParam.Size.dwTotalBytes; scan->sParam.Size.dwTotalBytes -= dw; if(!scan->sParam.Size.dwTotalBytes && dw < (pl * 1024)) { if(!(dev->usbDev.a_bRegs[0x4e] = (u_char)ceil((double)dw / (4.0 * hw->wDRAMSize)))) { dev->usbDev.a_bRegs[0x4e] = 1; } dev->usbDev.a_bRegs[0x4f] = 0; sanei_lm983x_write( dev->fd, 0x4e, &dev->usbDev.a_bRegs[0x4e], 2, SANE_TRUE ); } while( scan->bLinesToSkip ) { DBG( _DBG_READ, "Skipping %u lines\n", scan->bLinesToSkip ); dwBytes = scan->bLinesToSkip * scan->sParam.Size.dwPhyBytes; if (dwBytes > scan->dwBytesScanBuf) { dwBytes = scan->dwBytesScanBuf; scan->bLinesToSkip -= scan->dwLinesScanBuf; } else { scan->bLinesToSkip = 0; } if( !usb_ScanReadImage( dev, scan->pbGetDataBuf, dwBytes )) return 0; } if( usb_ScanReadImage( dev, scan->pbGetDataBuf, dw )) { dumpPic("plustek-pic.raw", scan->pbGetDataBuf, dw, 0); if( scan->dwLinesDiscard ) { DBG(_DBG_READ, "Discarding %lu lines\n", scan->dwLinesDiscard); dwRet = dw / scan->sParam.Size.dwPhyBytes; if (scan->dwLinesDiscard > dwRet) { scan->dwLinesDiscard -= dwRet; dwRet = 0; } else { dwRet -= scan->dwLinesDiscard; scan->dwLinesDiscard = 0; } } else { dwRet = dw / scan->sParam.Size.dwPhyBytes; } scan->pbGetDataBuf += scan->dwBytesScanBuf; if( scan->pbGetDataBuf >= scan->pbScanBufEnd ) { scan->pbGetDataBuf = scan->pbScanBufBegin; } if( dwRet ) return dwRet; } } return 0; } /* END PLUSTEK-USBIMG.C .....................................................*/ sane-backends-1.0.29/backend/p5_device.c0000666000000000000000000011273013615534521014603 00000000000000/** * Description of the Primax PagePartner model */ static P5_Model pagepartner_model = { "Primax PagePartner", "Primax", "PagePartner", SANE_I18N ("sheetfed scanner"), {300, 200, 150, 100, 0}, /* 500 seems also possible */ {600, 400, 300, 200, 150, 100, 0}, 300, 600, 100, 100, 16, SANE_FIX (0.0), SANE_FIX (0.0), SANE_FIX (215.9), SANE_FIX (300.0), }; #ifdef HAVE_LINUX_PPDEV_H static char * addr_name (uint16_t addr) { switch (addr) { case DATA: return "DATA"; break; case STATUS: return "STATUS"; break; case CONTROL: return "CONTROL"; break; case EPPADR: return "EPPADR"; break; case EPPDATA: return "EPPDATA"; break; default: return "*ERROR*"; } } #endif /** @brief low level hardware access functions * @{ */ static uint8_t inb (int fd, uint16_t addr) { #ifdef HAVE_LINUX_PPDEV_H uint8_t val = 0xff; int rc, mode = 0xff; switch (addr) { case DATA: rc = ioctl (fd, PPRDATA, &val); break; case STATUS: rc = ioctl (fd, PPRSTATUS, &val); break; case CONTROL: rc = ioctl (fd, PPRCONTROL, &val); break; case EPPDATA: mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); #ifdef PPSETFLAGS mode = PP_FASTREAD; rc = ioctl (fd, PPSETFLAGS, &mode); #endif rc = read (fd, &val, 1); break; default: DBG (DBG_error, "inb(%s) escaped ppdev\n", addr_name (addr)); return 0xFF; } if (rc < 0) { DBG (DBG_error, "ppdev ioctl returned <%s>\n", strerror (errno)); } return val; #else if(fd && addr) return 0; return 0; #endif } static void outb (int fd, uint16_t addr, uint8_t value) { #ifdef HAVE_LINUX_PPDEV_H int rc = 0, mode = 0xff; switch (addr) { case DATA: rc = ioctl (fd, PPWDATA, &value); break; case CONTROL: mode = value & 0x20; rc = ioctl (fd, PPDATADIR, &mode); if (!rc) { value = value & 0xDF; rc = ioctl (fd, PPWCONTROL, &value); } break; case EPPDATA: mode = 0; /* data forward */ rc = ioctl (fd, PPDATADIR, &mode); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); rc = write (fd, &value, 1); break; case EPPADR: mode = 0; /* data forward */ rc = ioctl (fd, PPDATADIR, &mode); mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); rc = write (fd, &value, 1); break; default: DBG (DBG_error, "outb(%s,0x%02x) escaped ppdev\n", addr_name (addr), value); break; } if (rc < 0) { DBG (DBG_error, "ppdev ioctl returned <%s>\n", strerror (errno)); } #else if(fd && addr && value) return; #endif /* HAVE_LINUX_PPDEV_H */ } static void write_reg (int fd, uint8_t index, uint8_t value) { uint8_t idx; /* both nibbles hold the same value */ idx = index & 0x0F; DBG (DBG_io2, "write_reg(REG%X,0x%x)\n", idx, value); idx = idx << 4 | idx; outb (fd, EPPADR, idx); outb (fd, EPPDATA, value); } static uint8_t read_reg (int fd, uint8_t index) { uint8_t idx; /* both nibbles hold the same value */ idx = index & 0x0F; idx = idx << 4 | idx; outb (fd, EPPADR, idx); return inb (fd, EPPDATA); } #ifdef HAVE_LINUX_PPDEV_H static int read_data (int fd, uint8_t * data, int length) { int mode, rc, nb; unsigned char bval; bval = REG8; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); rc = write (fd, &bval, 1); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); #ifdef PPSETFLAGS mode = PP_FASTREAD; rc = ioctl (fd, PPSETFLAGS, &mode); #endif mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); nb = 0; while (nb < length) { rc = read (fd, data + nb, length - nb); if (rc < 0) { DBG (DBG_error, "memtest: error reading data back!\n"); return 0; } else { nb += rc; } } return 1; } static void index_write_data (int fd, uint8_t index, uint8_t * data, int length) { int mode; unsigned char bval; bval = index; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; ioctl (fd, PPSETMODE, &mode); write (fd, &bval, 1); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; ioctl (fd, PPSETMODE, &mode); mode = 0; /* data forward */ ioctl (fd, PPDATADIR, &mode); write (fd, data, length); return; } static void write_data (int fd, uint8_t * data, int length) { index_write_data (fd, REG8, data, length); } static void write_reg2 (int fd, uint8_t index, uint16_t value) { uint8_t data2[2]; data2[0] = value & 0xff; data2[1] = value >> 8; index_write_data (fd, index, data2, 2); } #else static int read_data (int fd, uint8_t * data, int length) { if(fd && data && length) return -1; return -1; } static void write_data (int fd, uint8_t * data, int length) { if(fd && data && length) return; } static void write_reg2 (int fd, uint8_t index, uint16_t value) { if(fd && index && value) return; } #endif /** * @} */ /** @brief This function checks a memory buffer. * This function writes at the given memory address then read it back * to check the scanner is correctly working. * @param fd file descriptor used to access hardware * @param addr address where to write and read * @return SANE_TRUE on succes, SANE_FALSE otherwise */ static int memtest (int fd, uint16_t addr) { uint8_t sent[256]; uint8_t back[256]; int i; write_reg2 (fd, REG1, addr); for (i = 0; i < 256; i++) { sent[i] = (uint8_t) i; back[i] = 0; } write_data (fd, sent, 256); read_data (fd, back, 256); /* check if data read back is the same that the one sent */ for (i = 0; i < 256; i++) { if (back[i] != sent[i]) { return SANE_FALSE; } } return SANE_TRUE; } #define INB(k,y,z) val=inb(k,y); if(val!=z) { DBG(DBG_error,"expected 0x%02x, got 0x%02x\n",z, val); return SANE_FALSE; } /** @brief connect to scanner * This function sends the connect sequence for the scanner. * @param fd filedescriptor of the parallel port communication channel * @return SANE_TRUE in case of success, SANE_FALSE otherwise */ static int connect (int fd) { uint8_t val; inb (fd, CONTROL); outb (fd, CONTROL, 0x04); outb (fd, DATA, 0x02); INB (fd, DATA, 0x02); outb (fd, DATA, 0x03); INB (fd, DATA, 0x03); outb (fd, DATA, 0x03); outb (fd, DATA, 0x83); outb (fd, DATA, 0x03); outb (fd, DATA, 0x83); INB (fd, DATA, 0x83); outb (fd, DATA, 0x82); INB (fd, DATA, 0x82); outb (fd, DATA, 0x02); outb (fd, DATA, 0x82); outb (fd, DATA, 0x02); outb (fd, DATA, 0x82); INB (fd, DATA, 0x82); outb (fd, DATA, 0x82); INB (fd, DATA, 0x82); outb (fd, DATA, 0x02); outb (fd, DATA, 0x82); outb (fd, DATA, 0x02); outb (fd, DATA, 0x82); INB (fd, DATA, 0x82); outb (fd, DATA, 0x83); INB (fd, DATA, 0x83); outb (fd, DATA, 0x03); outb (fd, DATA, 0x83); outb (fd, DATA, 0x03); outb (fd, DATA, 0x83); INB (fd, DATA, 0x83); outb (fd, DATA, 0x82); INB (fd, DATA, 0x82); outb (fd, DATA, 0x02); outb (fd, DATA, 0x82); outb (fd, DATA, 0x02); outb (fd, DATA, 0x82); INB (fd, DATA, 0x82); outb (fd, DATA, 0x83); INB (fd, DATA, 0x83); outb (fd, DATA, 0x03); outb (fd, DATA, 0x83); outb (fd, DATA, 0x03); outb (fd, DATA, 0x83); INB (fd, DATA, 0x83); outb (fd, DATA, 0x83); INB (fd, DATA, 0x83); outb (fd, DATA, 0x03); outb (fd, DATA, 0x83); outb (fd, DATA, 0x03); outb (fd, DATA, 0x83); INB (fd, DATA, 0x83); outb (fd, DATA, 0x82); INB (fd, DATA, 0x82); outb (fd, DATA, 0x02); outb (fd, DATA, 0x82); outb (fd, DATA, 0x02); outb (fd, DATA, 0x82); outb (fd, DATA, 0xFF); DBG (DBG_info, "connect() OK...\n"); return SANE_TRUE; } static int disconnect (int fd) { uint8_t val; outb (fd, CONTROL, 0x04); outb (fd, DATA, 0x00); INB (fd, DATA, 0x00); outb (fd, DATA, 0x01); INB (fd, DATA, 0x01); outb (fd, DATA, 0x01); outb (fd, DATA, 0x81); outb (fd, DATA, 0x01); outb (fd, DATA, 0x81); INB (fd, DATA, 0x81); outb (fd, DATA, 0x80); INB (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); INB (fd, DATA, 0x80); outb (fd, DATA, 0x80); INB (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); INB (fd, DATA, 0x80); outb (fd, DATA, 0x81); INB (fd, DATA, 0x81); outb (fd, DATA, 0x01); outb (fd, DATA, 0x81); outb (fd, DATA, 0x01); outb (fd, DATA, 0x81); INB (fd, DATA, 0x81); outb (fd, DATA, 0x80); INB (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); INB (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); INB (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); INB (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); outb (fd, DATA, 0x00); outb (fd, DATA, 0x80); inb (fd, CONTROL); outb (fd, CONTROL, 0x0C); return SANE_STATUS_GOOD; } static void setadresses (int fd, uint16_t start, uint16_t end) { write_reg (fd, REG3, start & 0xff); write_reg (fd, REG4, start >> 8); write_reg (fd, REG5, end & 0xff); write_reg (fd, REG6, end >> 8); DBG (DBG_io, "setadresses(0x%x,0x%x); OK...\n", start, end); } #ifdef HAVE_LINUX_PPDEV_H /** @brief open parallel port device * opens parallel port's low level device in EPP mode * @param devicename nam of the real device or the special value 'auto' * @return file descriptor in cas of successn -1 otherwise */ static int open_pp (const char *devicename) { int fd, mode = 0; char *name; DBG (DBG_proc, "open_pp: start, devicename=%s\n", devicename); /* TODO improve auto device finding */ if (strncmp (devicename, "auto", 4) == 0) { name = strdup("/dev/parport0"); } else { name = strdup(devicename); } /* open device */ fd = open (name, O_RDWR); if (fd < 0) { switch (errno) { case ENOENT: #ifdef ENIO case ENXIO: #endif #ifdef ENODEV case ENODEV: #endif DBG (DBG_error, "open_pp: no %s device ...\n", name); break; case EACCES: DBG (DBG_error, "open_pp: current user cannot use existing %s device ...\n", name); break; default: DBG (DBG_error, "open_pp: %s while opening %s\n", strerror (errno), name); } return -1; } free(name); /* claim device and set it to EPP */ ioctl (fd, PPCLAIM); ioctl (fd, PPGETMODES, &mode); if (mode & PARPORT_MODE_PCSPP) DBG (DBG_io, "PARPORT_MODE_PCSPP\n"); if (mode & PARPORT_MODE_TRISTATE) DBG (DBG_io, "PARPORT_MODE_TRISTATE\n"); if (mode & PARPORT_MODE_EPP) DBG (DBG_io, "PARPORT_MODE_EPP\n"); if (mode & PARPORT_MODE_ECP) DBG (DBG_io, "PARPORT_MODE_ECP\n"); if (mode & PARPORT_MODE_COMPAT) DBG (DBG_io, "PARPORT_MODE_COMPAT\n"); if (mode & PARPORT_MODE_DMA) DBG (DBG_io, "PARPORT_MODE_DMA\n"); if (mode & PARPORT_MODE_EPP) { mode = IEEE1284_MODE_EPP; } else { /* if (mode & PARPORT_MODE_ECP) { mode = IEEE1284_MODE_ECP; } else */ { mode = -1; } } if (mode == -1) { DBG (DBG_error, "open_pp: no EPP mode, giving up ...\n"); ioctl (fd, PPRELEASE); close (fd); return -1; } ioctl (fd, PPNEGOT, &mode); ioctl (fd, PPSETMODE, &mode); DBG (DBG_proc, "open_pp: exit\n"); return fd; } /** close low level device * release and close low level hardware device */ static void close_pp (int fd) { int mode = IEEE1284_MODE_COMPAT; if (fd > 2) { ioctl (fd, PPNEGOT, &mode); ioctl (fd, PPRELEASE); close (fd); } } #else /* HAVE_LINUX_PPDEV_H */ static int open_pp (const char *devicename) { if(devicename) return -1; return -1; } static void close_pp (int fd) { if(fd) return; } #endif /* HAVE_LINUX_PPDEV_H */ /** @brief test if a document is inserted * Test if a document is inserted by reading register E * @param fd file descriptor to access scanner * @return SANE_STATUS_NO_DOCS if no document or SANE_STATUS_GOOD * if something is present. */ static SANE_Status test_document (int fd) { int detector; /* check for document presence 0xC6: present, 0xC3 no document */ detector = read_reg (fd, REGE); DBG (DBG_io, "test_document: detector=0x%02X\n", detector); /* document inserted */ if (detector & 0x04) return SANE_STATUS_GOOD; return SANE_STATUS_NO_DOCS; } /** * return the amount of scanned data available * @param fd file descriptor to access scanner * @return avaible byte number */ static int available_bytes (int fd) { int counter; /* read the number of 256 bytes block of scanned data */ counter = read_reg (fd, REG9); DBG (DBG_io, "available_bytes: available_bytes=0x%02X\n", counter); return 256 * counter; } static SANE_Status build_correction (P5_Device * dev, unsigned int dpi, unsigned int mode, unsigned int start, unsigned int width) { unsigned int i, j, shift, step; DBG (DBG_proc, "build_correction: start=%d, width=%d\n", start, width); DBG (DBG_trace, "build_correction: dpi=%d, mode=%d\n", dpi, mode); /* loop on calibration data to find the matching one */ j = 0; while (dev->calibration_data[j]->dpi != dpi) { j++; if (j > MAX_RESOLUTIONS) { DBG (DBG_error, "build_correction: couldn't find calibration!\n"); return SANE_STATUS_INVAL; } } if (dev->gain != NULL) { free (dev->gain); dev->gain = NULL; } if (dev->offset != NULL) { free (dev->offset); dev->offset = NULL; } dev->gain = (float *) malloc (width * sizeof (float)); if (dev->gain == NULL) { DBG (DBG_error, "build_correction: failed to allocate memory for gain!\n"); return SANE_STATUS_NO_MEM; } dev->offset = (uint8_t *) malloc (width); if (dev->offset == NULL) { DBG (DBG_error, "build_correction: failed to allocate memory for offset!\n"); return SANE_STATUS_NO_MEM; } /* compute starting point of calibration data to use */ shift = start; step = 1; if (mode == MODE_GRAY) { /* we use green data */ shift += 1; step = 3; } for (i = 0; i < width; i += step) { if (dev->calibration_data[j]->white_data[shift + i] - dev->calibration_data[0]->black_data[shift + i] > BLACK_LEVEL) { dev->gain[i] = WHITE_TARGET / ((float) (dev->calibration_data[j]->white_data[shift + i] - dev->calibration_data[j]->black_data[shift + i])); dev->offset[i] = dev->calibration_data[j]->black_data[shift + i]; } else { dev->gain[i] = 1.0; dev->offset[i] = 0; } } return SANE_STATUS_GOOD; DBG (DBG_proc, "build_correction: end\n"); } /** @brief start up a real scan * This function starts the scan with the given parameters. * @param dev device describing hardware * @param mode color, gray level or lineart. * @param dpi desired scan resolution. * @param startx coordinate of the first pixel to scan in * scan's resolution coordinate * @param width width of the scanned area * scanner's physical scan aread. * @return SANE_STATUS_GOOD if scan is successfully started */ static SANE_Status start_scan (P5_Device * dev, int mode, unsigned int dpi, unsigned int startx, unsigned int width) { uint8_t reg0=0; uint8_t reg2=0; uint8_t regF=0; uint16_t addr=0; uint16_t start, end; unsigned int xdpi; DBG (DBG_proc, "start_scan: start \n"); DBG (DBG_io, "start_scan: startx=%d, width=%d, dpi=%d\n", startx, width, dpi); /** @brief register values * - reg2 : reg2 seems related to x dpi and provides only 100, * 150, 200 and 300 resolutions. * - regF : lower nibble gives y dpi resolution ranging from 150 * to 1200 dpi. */ xdpi = dpi; switch (dpi) { case 100: reg2 = 0x90; regF = 0xA2; break; case 150: reg2 = 0x10; regF = 0xA4; break; case 200: reg2 = 0x80; regF = 0xA6; break; case 300: reg2 = 0x00; regF = 0xA8; break; case 400: reg2 = 0x80; /* xdpi=200 */ regF = 0xAA; xdpi = 200; break; case 500: reg2 = 0x00; regF = 0xAC; xdpi = 300; break; case 600: reg2 = 0x00; regF = 0xAE; xdpi = 300; break; } switch (mode) { case MODE_COLOR: reg0 = 0x00; addr = 0x0100; break; case MODE_GRAY: /* green channel only */ reg0 = 0x20; addr = 0x0100; break; case MODE_LINEART: reg0 = 0x40; addr = 0x0908; break; } write_reg (dev->fd, REG1, 0x01); write_reg (dev->fd, REG7, 0x00); write_reg (dev->fd, REG0, reg0); write_reg (dev->fd, REG1, 0x00); write_reg (dev->fd, REGF, regF); /* the memory addr used to test need not to be related * to resolution, 0x0100 could be always used */ /* TODO get rid of it */ memtest (dev->fd, addr); /* handle case where dpi>xdpi */ start = startx; if (dpi > xdpi) { width = (width * xdpi) / dpi; start = (startx * xdpi) / dpi; } /* compute and set start addr */ if (mode == MODE_COLOR) { start = start * 3; width = width * 3; } end = start + width + 1; /* build calibration data for the scan */ if (dev->calibrated) { build_correction (dev, xdpi, mode, start, width); } setadresses (dev->fd, start, end); write_reg (dev->fd, REG1, addr >> 8); write_reg (dev->fd, REG2, reg2); regF = (regF & 0x0F) | 0x80; write_reg (dev->fd, REGF, regF); write_reg (dev->fd, REG0, reg0); if (mode == MODE_LINEART) { write_reg (dev->fd, 0x07, 0x04); } else { write_reg (dev->fd, 0x07, 0x00); } write_reg (dev->fd, REG1, addr >> 8); write_reg2 (dev->fd, REG1, addr); write_reg (dev->fd, REGF, regF | 0x01); write_reg (dev->fd, REG0, reg0 | 0x0C); if (mode == MODE_LINEART) { write_reg (dev->fd, REG1, 0x19); } else { write_reg (dev->fd, REG1, 0x11); } DBG (DBG_proc, "start_scan: exit\n"); return SANE_STATUS_GOOD; } /** read a line of scan data * @param dev device to read * @param data pointer where to store data * @param length total bytes to read on one line * @param ltr total number of lines to read * @param retry signals that the function must read as much lines it can * @param x2 tells that lines must be enlarged by a 2 factor * @param mode COLOR_MODE if color mode * @returns number of data lines read, -1 in case of error */ static int read_line (P5_Device * dev, uint8_t * data, size_t length, int ltr, SANE_Bool retry, SANE_Bool x2, int mode, SANE_Bool correction) { uint8_t counter, read, cnt; uint8_t inbuffer[MAX_SENSOR_PIXELS * 2 * 3 + 2]; unsigned int i, factor; float val; DBG (DBG_proc, "read_line: trying to read %d lines of %lu bytes\n", ltr, (unsigned long)length); counter = read_reg (dev->fd, REG9); DBG (DBG_io, "read_line: %d bytes available\n", counter * 256); read = 0; if (x2 == SANE_FALSE) { factor = 1; } else { factor = 2; } /* in retry mode we read until not enough data, but in no retry * read only one line , counter give us 256 bytes block available * and we want an number multiple of color channels */ cnt = (255 + length / factor) / 256; while ((counter > cnt && retry == 1) || (counter > cnt && read == 0)) { /* read data from scanner, first and last byte aren't picture data */ read_data (dev->fd, inbuffer, length / factor + 2); /* image correction */ if (correction == SANE_TRUE) { for (i = 0; i < length / factor; i++) { val = inbuffer[i + 1] - dev->offset[i]; if (val > 0) { val = val * dev->gain[i]; if (val < 255) inbuffer[i + 1] = val; else inbuffer[i + 1] = 255; } else { inbuffer[i + 1] = 0; } } } /* handle horizontal data doubling */ if (x2 == SANE_FALSE) { memcpy (data + read * length, inbuffer + 1, length); } else { if (mode == MODE_COLOR) { for (i = 0; i < length / factor; i += 3) { data[read * length + i * factor] = inbuffer[i + 1]; data[read * length + i * factor + 1] = inbuffer[i + 2]; data[read * length + i * factor + 2] = inbuffer[i + 3]; data[read * length + i * factor + 3] = inbuffer[i + 1]; data[read * length + i * factor + 4] = inbuffer[i + 2]; data[read * length + i * factor + 5] = inbuffer[i + 3]; } } else { for (i = 0; i < length / factor; i++) { data[read * length + i * factor] = inbuffer[i + 1]; data[read * length + i * factor + 1] = inbuffer[i + 1]; } } } read++; if (retry == SANE_TRUE) { read_reg (dev->fd, REGF); read_reg (dev->fd, REGA); read_reg (dev->fd, REG9); counter = read_reg (dev->fd, REG9); read_reg (dev->fd, REGA); if (read >= ltr) { DBG (DBG_io, "read_line returning %d lines\n", read); return read; } counter = read_reg (dev->fd, REG9); } } read_reg (dev->fd, REGF); read_reg (dev->fd, REGA); read_reg (dev->fd, REG9); counter = read_reg (dev->fd, REG9); read_reg (dev->fd, REGA); DBG (DBG_io, "read_line returning %d lines\n", read); return read; } static SANE_Status eject (int fd) { int detector; DBG (DBG_proc, "eject: start ...\n"); do { write_reg2 (fd, REG1, 0x1110); detector = read_reg (fd, REGE); detector = read_reg (fd, REGE); } while ((detector & 0x04) != 0); write_reg (fd, REG0, 0x00); write_reg (fd, REG1, 0x00); write_reg (fd, REGF, 0x82); write_reg (fd, REG7, 0x00); DBG (DBG_proc, "eject: end.\n"); return SANE_STATUS_GOOD; } /** @brief wait for document to be present in feeder * Polls document sensor until something is present. Give up after 20 seconds * @param fd file descriptor of the physical device */ /* static int wait_document (int fd, uint8_t detector) { int count = 0; uint8_t val; write_reg (fd, REG1, 0x00); write_reg (fd, REG7, 0x00); detector = read_reg (fd, REGE); while (detector == 0xc3 && count < 20) { sleep (1); count++; detector = read_reg (fd, REGE); } setadresses (fd, 0x002d, 0x09c7); write_reg (fd, REG1, 0x00); write_reg (fd, REG2, 0x90); write_reg (fd, REGF, 0x82); write_reg (fd, REG0, 0x00); val = inb (fd, STATUS) & 0xf8; if (val != 0xf8) { DBG (DBG_error, "wait_document: unexpected STATUS value 0x%02x instead of 0xf8", val); } if (count >= 20) { DBG (DBG_error, "wait_document: failed to detect document!\n"); return 0; } return 1; } */ /** @brief move at 150 dpi * move the paper at 150 dpi motor speed by the amount specified * @params dev pointer to the device structure */ static SANE_Status move (P5_Device * dev) { int skip, done, read, count; SANE_Status status = SANE_STATUS_GOOD; unsigned char buffer[256]; DBG (DBG_proc, "move: start\n"); /* compute number of lines to skip */ skip = dev->ystart; /* works, but remains to be explained ... */ if (dev->ydpi > 300) skip = skip / 2; DBG (DBG_io, "move: skipping %d lines at %d dpi\n", skip, dev->ydpi); /* we do a real scan of small width, discarding data */ done = 0; status = start_scan (dev, MODE_GRAY, dev->ydpi, 0, 256); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "move: failed to start scan\n"); return SANE_STATUS_INVAL; } do { /* test if document left the feeder */ status = test_document (dev->fd); if (status == SANE_STATUS_NO_DOCS) { DBG (DBG_info, "move: document was shorter than the required move\n"); return SANE_STATUS_INVAL; } /* test if data is available */ count = available_bytes (dev->fd); if (count) { read = read_line (dev, buffer, 256, 1, SANE_FALSE, SANE_FALSE, MODE_GRAY, SANE_FALSE); if (read == -1) { DBG (DBG_error, "move: failed to read data\n"); return SANE_STATUS_INVAL; } done += read; } } while (done < skip); /* reset scanner */ write_reg2 (dev->fd, REG1, 0x1110); count = read_reg (dev->fd, REGE); count = read_reg (dev->fd, REGE); write_reg (dev->fd, REG0, 0x00); write_reg (dev->fd, REG1, 0x00); write_reg (dev->fd, REGF, 0x82); write_reg (dev->fd, REG7, 0x00); DBG (DBG_proc, "move: exit\n"); return status; } /** clean up calibration data * @param dev device to clean up */ static void cleanup_calibration (P5_Device * dev) { int i; for (i = 0; i < MAX_RESOLUTIONS * 2; i++) { if (dev->calibration_data[i] != NULL) { free (dev->calibration_data[i]); dev->calibration_data[i] = NULL; } } dev->calibrated = SANE_FALSE; } /** detect a black scan line * parses the given buffer and retrun SANE_TRUE if the line is an * acceptable black line for calibration * @param buffer data line to parse * @param pixels number of pixels * @param mode MODE_COLOR or MODE_GRAY * @returns SANE_TRUE if it is considered as a white line */ static SANE_Bool is_black_line (uint8_t * buffer, unsigned int pixels, int mode) { unsigned int i, start, end, count, width; /* compute width in bytes */ if (mode == MODE_COLOR) { width = pixels * 3; } else { width = pixels; } /* we allow the calibration target to be narrower than full width, ie * black margin at both ends of the line */ start = (5 * width) / 100; end = (95 * width) / 100; count = 0; /* count number of black bytes */ for (i = start; i < end; i++) { if (buffer[i] > BLACK_LEVEL) { count++; } } /* we allow 3% black pixels maximum */ if (count > (3 * width) / 100) { DBG (DBG_io, "is_black_line=SANE_FALSE\n"); return SANE_FALSE; } DBG (DBG_io, "is_black_line=SANE_TRUE\n"); return SANE_TRUE; } /** detect a white scan line * parses the given buffer and retrun SANE_TRUE if the line is an * acceptable white line for calibration * @param buffer data line to parse * @param pixels number of pixels * @param mode MODE_COLOR or MODE_GRAY * @returns SANE_TRUE if it is considered as a white line */ static SANE_Bool is_white_line (uint8_t * buffer, unsigned int pixels, int mode) { unsigned int i, start, end, count, width; /* compute width in bytes */ if (mode == MODE_COLOR) { width = pixels * 3; } else { width = pixels; } /* we allow the calibration target to be narrower than full width, ie * black margin at both ends of the line */ start = (5 * width) / 100; end = (95 * width) / 100; count = 0; /* count number of black bytes */ for (i = start; i < end; i++) { if (buffer[i] < BLACK_LEVEL) { count++; } } /* we allow 3% black pixels maximum */ if (count > (3 * width) / 100) { DBG (DBG_io, "is_white_line=SANE_FALSE\n"); return SANE_FALSE; } DBG (DBG_io, "is_white_line=SANE_TRUE\n"); return SANE_TRUE; } /* ------------------------------------------------------------------------- */ /* writes gray data to a pnm file */ /* static void write_gray_data (unsigned char *image, char *name, SANE_Int width, SANE_Int height) { FILE *fdbg = NULL; fdbg = fopen (name, "wb"); if (fdbg == NULL) return; fprintf (fdbg, "P5\n%d %d\n255\n", width, height); fwrite (image, width, height, fdbg); fclose (fdbg); } */ /* ------------------------------------------------------------------------- */ /* writes rgb data to a pnm file */ static void write_rgb_data (char *name, unsigned char *image, SANE_Int width, SANE_Int height) { FILE *fdbg = NULL; fdbg = fopen (name, "wb"); if (fdbg == NULL) return; fprintf (fdbg, "P6\n%d %d\n255\n", width, height); fwrite (image, width * 3, height, fdbg); fclose (fdbg); } /** give calibration file name * computes the calibration file name to use based on the * backend name and device */ static char * calibration_file (const char *devicename) { char *ptr = NULL; char tmp_str[PATH_MAX]; ptr = getenv ("HOME"); if (ptr != NULL) { sprintf (tmp_str, "%s/.sane/p5-%s.cal", ptr, devicename); } else { ptr = getenv ("TMPDIR"); if (ptr != NULL) { sprintf (tmp_str, "%s/p5-%s.cal", ptr, devicename); } else { sprintf (tmp_str, "/tmp/p5-%s.cal", devicename); } } DBG (DBG_trace, "calibration_file: using >%s< for calibration file name\n", tmp_str); return strdup (tmp_str); } /** restore calibration data * restore calibration data by loading previously saved calibration data * @param dev device to restore * @return SANE_STATUS_GOOD on success, otherwise error code */ static SANE_Status restore_calibration (P5_Device * dev) { SANE_Status status = SANE_STATUS_GOOD; char *fname = NULL; FILE *fcalib = NULL; size_t size; int i; DBG (DBG_proc, "restore_calibration: start\n"); cleanup_calibration (dev); fname = calibration_file (dev->model->name); fcalib = fopen (fname, "rb"); if (fcalib == NULL) { DBG (DBG_error, "restore_calibration: failed to open %s!\n", fname); free (fname); return SANE_STATUS_IO_ERROR; } /* loop filling calibration data until EOF reached */ i = 0; while (!feof (fcalib) && (i < 2 * MAX_RESOLUTIONS)) { dev->calibration_data[i] = malloc (sizeof (P5_Calibration_Data)); if (dev->calibration_data[i] == NULL) { cleanup_calibration (dev); free (fname); fclose (fcalib); DBG (DBG_error, "restore_calibration: failed to allocate memory for calibration\n"); return SANE_STATUS_NO_MEM; } size = fread (dev->calibration_data[i], 1, sizeof (P5_Calibration_Data), fcalib); if (feof (fcalib)) { free (dev->calibration_data[i]); dev->calibration_data[i] = NULL; } else if (size != sizeof (P5_Calibration_Data)) { cleanup_calibration (dev); free (fname); fclose (fcalib); DBG (DBG_error, "restore_calibration: failed to read from file\n"); return SANE_STATUS_IO_ERROR; } DBG (DBG_trace, "restore_calibration: read 1 calibration structure from file\n"); i++; } dev->calibrated = SANE_TRUE; fclose (fcalib); free (fname); DBG (DBG_proc, "restore_calibration: end\n"); return status; } /** save calibration data * save calibration data from memory to file * @param dev device calibration to save * @return SANE_STATUS_GOOD on success, otherwise error code */ static SANE_Status save_calibration (P5_Device * dev) { SANE_Status status = SANE_STATUS_GOOD; char *fname = NULL; FILE *fcalib = NULL; int i; size_t size; DBG (DBG_proc, "save_calibration: start\n"); fname = calibration_file (dev->model->name); fcalib = fopen (fname, "wb"); if (fcalib == NULL) { DBG (DBG_error, "save_calibration: failed to open %s!\n", fname); free (fname); return SANE_STATUS_IO_ERROR; } /* loop filling calibration data until EOF reached */ i = 0; while (dev->calibration_data[i] != NULL && (i < 2 * MAX_RESOLUTIONS)) { size = fwrite (dev->calibration_data[i], sizeof (P5_Calibration_Data), 1, fcalib); if (size != sizeof (P5_Calibration_Data)) { free (fname); fclose (fcalib); DBG (DBG_error, "save_calibration: failed to write to file\n"); return SANE_STATUS_IO_ERROR; } DBG (DBG_trace, "save_calibration: wrote 1 calibration structure to file\n"); i++; } fclose (fcalib); free (fname); DBG (DBG_proc, "save_calibration: end\n"); return status; } /** calibrate scanner * calibrates scanner by scanning a white sheet to get * reference data. The black reference data is extracted from the lines * that precede the physical document. * Calibration is done at 300 color, then data is built for other modes * and resolutions. * @param dev device to calibrate */ static SANE_Status sheetfed_calibration (P5_Device * dev) { uint8_t buffer[MAX_SENSOR_PIXELS * 3]; uint16_t white_data[MAX_SENSOR_PIXELS * 3]; uint16_t black_data[MAX_SENSOR_PIXELS * 3]; unsigned int i, j, k, dpi, pixels, read, black, white; float coeff; unsigned int red, green, blue; int line; SANE_Status status; char title[40]; FILE *dbg = fopen ("debug.pnm", "wb"); fprintf (dbg, "P6\n%d %d\n255\n", MAX_SENSOR_PIXELS, CALIBRATION_SKIP_LINES * 4); DBG (DBG_proc, "sheetfed_calibration: start\n"); /* check calibration target has been loaded in ADF */ status = test_document (dev->fd); if (status == SANE_STATUS_NO_DOCS) { DBG (DBG_error, "sheetfed_calibration: no calibration target present!\n"); return SANE_STATUS_NO_DOCS; } /* clean up calibration data */ cleanup_calibration (dev); /* a RGB scan to get reference data */ /* initialize calibration slot for the resolution */ i = 0; dpi = dev->model->max_xdpi; pixels = MAX_SENSOR_PIXELS; dev->calibration_data[i] = (P5_Calibration_Data *) malloc (sizeof (P5_Calibration_Data)); if (dev->calibration_data[i] == NULL) { cleanup_calibration (dev); DBG (DBG_error, "sheetfed_calibration: failed to allocate memory for calibration\n"); return SANE_STATUS_NO_MEM; } dev->calibration_data[i]->dpi = dpi; /* start scan */ status = start_scan (dev, MODE_COLOR, dpi, 0, pixels); if (status != SANE_STATUS_GOOD) { cleanup_calibration (dev); DBG (DBG_error, "sheetfed_calibration: failed to start scan at %d dpi\n", dpi); return SANE_STATUS_INVAL; } white = 0; black = 0; read = 0; for (j = 0; j < pixels * 3; j++) { black_data[j] = 0; white_data[j] = 0; } /* read lines and gather black and white ones until enough for sensor's * native resolution */ do { status = test_document (dev->fd); if (status == SANE_STATUS_NO_DOCS && (white < 10 || black < 10)) { cleanup_calibration (dev); DBG (DBG_error, "sheetfed_calibration: calibration sheet too short!\n"); return SANE_STATUS_INVAL; } memset (buffer, 0x00, MAX_SENSOR_PIXELS * 3); line = read_line (dev, buffer, pixels * 3, 1, SANE_FALSE, SANE_FALSE, MODE_COLOR, SANE_FALSE); if (line == -1) { DBG (DBG_error, "sheetfed_calibration: failed to read data\n"); return SANE_STATUS_INVAL; } /* if a data line has been read, add it to reference data */ if (line) { read++; fwrite (buffer, pixels * 3, 1, dbg); if (is_white_line (buffer, pixels, MODE_COLOR) && white < 256) { white++; /* first calibration lines are skipped */ for (j = 0; j < pixels * 3 && read > CALIBRATION_SKIP_LINES; j++) { white_data[j] += buffer[j]; } } if (is_black_line (buffer, pixels, MODE_COLOR) && black < 256) { black++; for (j = 0; j < pixels * 3; j++) { black_data[j] += buffer[j]; } } } } while (test_document (dev->fd) != SANE_STATUS_NO_DOCS); DBG (DBG_trace, "sheetfed_calibration: white lines=%d, black lines=%d\n", white, black); /* average pixels and store in per dpi calibration data */ for (j = 0; j < pixels * 3; j++) { dev->calibration_data[i]->white_data[j] = white_data[j] / white; dev->calibration_data[i]->black_data[j] = black_data[j] / black; } /* we average red, green and blue offset on the full sensor */ red = 0; green = 0; blue = 0; for (j = 0; j < pixels * 3; j += 3) { red += dev->calibration_data[i]->black_data[j]; green += dev->calibration_data[i]->black_data[j + 1]; blue += dev->calibration_data[i]->black_data[j + 2]; } for (j = 0; j < pixels * 3; j += 3) { dev->calibration_data[i]->black_data[j] = red / pixels; dev->calibration_data[i]->black_data[j + 1] = green / pixels; dev->calibration_data[i]->black_data[j + 2] = blue / pixels; } /* trace calibration data for debug */ if (DBG_LEVEL > DBG_data) { sprintf (title, "calibration-white-%d.pnm", dev->calibration_data[i]->dpi); write_rgb_data (title, dev->calibration_data[i]->white_data, pixels, 1); sprintf (title, "calibration-black-%d.pnm", dev->calibration_data[i]->dpi); write_rgb_data (title, dev->calibration_data[i]->black_data, pixels, 1); } /* loop on all remaining resolution and compute calibration data from it */ for (i = 1; i < MAX_RESOLUTIONS && dev->model->xdpi_values[i] > 0; i++) { dev->calibration_data[i] = (P5_Calibration_Data *) malloc (sizeof (P5_Calibration_Data)); if (dev->calibration_data[i] == NULL) { cleanup_calibration (dev); DBG (DBG_error, "sheetfed_calibration: failed to allocate memory for calibration\n"); return SANE_STATUS_INVAL; } dev->calibration_data[i]->dpi = dev->model->xdpi_values[i]; coeff = ((float) dev->model->xdpi_values[i]) / (float) dpi; /* generate data by decimation */ for (j = 0; j < pixels / coeff; j++) { k = j * coeff; dev->calibration_data[i]->white_data[j] = dev->calibration_data[0]->white_data[k]; dev->calibration_data[i]->white_data[j + 1] = dev->calibration_data[0]->white_data[k + 1]; dev->calibration_data[i]->white_data[j + 2] = dev->calibration_data[0]->white_data[k + 2]; dev->calibration_data[i]->black_data[j] = dev->calibration_data[0]->black_data[k]; dev->calibration_data[i]->black_data[j + 1] = dev->calibration_data[0]->black_data[k + 1]; dev->calibration_data[i]->black_data[j + 2] = dev->calibration_data[0]->black_data[k + 2]; } } fclose (dbg); dev->calibrated = SANE_TRUE; /* eject calibration target */ eject (dev->fd); DBG (DBG_proc, "sheetfed_calibration: end\n"); return SANE_STATUS_GOOD; } /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ sane-backends-1.0.29/backend/pieusb_specific.c0000666000000000000000000032520313615534521016075 00000000000000/* sane - Scanner Access Now Easy. pieusb_specific.c Copyright (C) 2012-2015 Jan Vleeshouwers, Michael Rickmann, Klaus Kaempf 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* ========================================================================= * * Various Pieusb backend specific functions * * Option handling, configuration file handling, post-processing * * ========================================================================= */ #define DEBUG_DECLARE_ONLY #include "pieusb.h" #include #include #include #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include #include #include #include "pieusb_usb.h" #include "pieusb_scancmd.h" #include "pieusb_buffer.h" #include "pieusb_specific.h" /* Pieusb specific */ /* sub to sanei_pieusb_find_device_callback() */ static SANE_Status pieusb_initialize_device_definition (Pieusb_Device_Definition* dev, Pieusb_Scanner_Properties* inq, const char* devicename, SANE_Word vendor_id, SANE_Word product_id); static void pieusb_print_inquiry (Pieusb_Device_Definition * dev); /* sub to sane_start() */ static void pieusb_calculate_shading(struct Pieusb_Scanner *scanner, SANE_Byte* buffer); /* MR */ /* sub to sanei_pieusb_post() */ static SANE_Status pieusb_write_pnm_file (char *filename, uint16_t *data, int depth, int channels, int pixels_per_line, int lines); /* Auxilary */ static size_t max_string_size (SANE_String_Const const strings[]); static double getGain(int gain); static int getGainSetting(double gain); /* static void updateGain(Pieusb_Scanner *scanner, int color_index); */ static void updateGain2(Pieusb_Scanner *scanner, int color_index, double gain_increase); /* -------------------------------------------------------------------------- * * SPECIFIC PIEUSB * * --------------------------------------------------------------------------*/ /* Settings for byte order */ #define SCAN_IMG_FMT_OKLINE 0x08 #define SCAN_IMG_FMT_BLK_ONE 0x04 #define SCAN_IMG_FMT_MOTOROLA 0x02 #define SCAN_IMG_FMT_INTEL 0x01 /* Settings for scanner capabilities */ #define SCAN_CAP_PWRSAV 0x80 #define SCAN_CAP_EXT_CAL 0x40 #define SCAN_CAP_FAST_PREVIEW 0x10 #define SCAN_CAP_DISABLE_CAL 0x08 #define SCAN_CAP_SPEEDS 0x07 /* Available scanner options */ #define SCAN_OPT_DEV_MPCL 0x80 #define SCAN_OPT_DEV_TP1 0x04 #define SCAN_OPT_DEV_TP 0x02 #define SCAN_OPT_DEV_ADF 0x01 /* Options */ #define SANE_NAME_EXPOSURE_R "exposure-time-r" #define SANE_TITLE_EXPOSURE_R "Exposure time red" #define SANE_DESC_EXPOSURE_R "The time the red color filter of the CCD is exposed" #define SANE_NAME_EXPOSURE_G "exposure-time-g" #define SANE_TITLE_EXPOSURE_G "Exposure time green" #define SANE_DESC_EXPOSURE_G "The time the green color filter of the CCD is exposed" #define SANE_NAME_EXPOSURE_B "exposure-time-b" #define SANE_TITLE_EXPOSURE_B "Exposure time blue" #define SANE_DESC_EXPOSURE_B "The time the blue color filter of the CCD is exposed" #define SANE_NAME_EXPOSURE_I "exposure-time-i" #define SANE_TITLE_EXPOSURE_I "Exposure time infrared" #define SANE_DESC_EXPOSURE_I "The time the infrared color filter of the CCD is exposed" #define SANE_EXPOSURE_DEFAULT DEFAULT_EXPOSURE #if 1 #define SANE_NAME_GAIN_R "gain-r" #define SANE_TITLE_GAIN_R "Gain red" #define SANE_DESC_GAIN_R "The gain of the signal processor for red" #define SANE_NAME_GAIN_G "gain-g" #define SANE_TITLE_GAIN_G "Gain green" #define SANE_DESC_GAIN_G "The gain of the signal processor for green" #define SANE_NAME_GAIN_B "gain-b" #define SANE_TITLE_GAIN_B "Gain blue" #define SANE_DESC_GAIN_B "The gain of the signal processor for blue" #define SANE_NAME_GAIN_I "gain-i" #define SANE_TITLE_GAIN_I "Gain infrared" #define SANE_DESC_GAIN_I "The gain of the signal processor for infrared" #define SANE_GAIN_DEFAULT DEFAULT_GAIN #define SANE_NAME_OFFSET_R "offset-r" #define SANE_TITLE_OFFSET_R "Offset red" #define SANE_DESC_OFFSET_R "The offset of the signal processor for red" #define SANE_NAME_OFFSET_G "offset-g" #define SANE_TITLE_OFFSET_G "Offset greed" #define SANE_DESC_OFFSET_G "The offset of the signal processor for green" #define SANE_NAME_OFFSET_B "offset-b" #define SANE_TITLE_OFFSET_B "Offset blue" #define SANE_DESC_OFFSET_B "The offset of the signal processor for blue" #define SANE_NAME_OFFSET_I "offset-i" #define SANE_TITLE_OFFSET_I "Offset infrared" #define SANE_DESC_OFFSET_I "The offset of the signal processor for infrared" #define SANE_OFFSET_DEFAULT DEFAULT_OFFSET #else #define SANE_NAME_GAIN "gain" #define SANE_TITLE_GAIN "Gain" #define SANE_DESC_GAIN "The gain of the signal processor for the 4 CCD color filters (R,G,B,I)" #define SANE_GAIN_DEFAULT 0x13 #define SANE_NAME_OFFSET "offset" #define SANE_TITLE_OFFSET "Offset" #define SANE_DESC_OFFSET "The offset of the signal processor for the 4 CCD color filters (R,G,B,I)" #define SANE_OFFSET_DEFAULT 0 #endif #define min(a,b) (((a)<(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b)) static const SANE_Range percentage_range_100 = { 0 << SANE_FIXED_SCALE_SHIFT, /* minimum */ 100 << SANE_FIXED_SCALE_SHIFT, /* maximum */ 0 << SANE_FIXED_SCALE_SHIFT /* quantization */ }; /* From the firmware disassembly */ static const SANE_Range gain_range = { 0, /* minimum */ 63, /* maximum */ 0 /* quantization */ }; /* From the firmware disassembly */ static const SANE_Range offset_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; static const double gains[] = { 1.000, 1.075, 1.154, 1.251, 1.362, 1.491, 1.653, /* 0, 5, 10, 15, 20, 25, 30 */ 1.858, 2.115, 2.458, 2.935, 3.638, 4.627 /* 35, 40, 45, 50, 55, 60 */ }; /** * Callback called whenever a connected USB device reports a supported vendor * and product id combination. * Used by sane_init() and by sane_open(). * * @param name Device name which has required vendor and product id * @return SANE_STATUS_GOOD */ SANE_Status sanei_pieusb_find_device_callback (const char *devicename) { struct Pieusb_Command_Status status; SANE_Status r; Pieusb_Device_Definition *dev; int device_number; /* index in usb devices list maintained by sani_usb */ Pieusb_Scanner_Properties inq; int retry; DBG (DBG_info_proc, "sanei_pieusb_find_device_callback: %s\n", devicename); /* Check if device is present in the Pieusb device list */ for (dev = pieusb_definition_list_head; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { return SANE_STATUS_GOOD; } } /* If not, create a new device struct */ dev = malloc (sizeof (*dev)); if (!dev) { return SANE_STATUS_NO_MEM; } /* Get device number: index of the device in the sanei_usb devices list */ r = sanei_usb_open (devicename, &device_number); if (r != SANE_STATUS_GOOD) { free (dev); DBG (DBG_error, "sanei_pieusb_find_device_callback: sanei_usb_open failed for device %s: %s\n",devicename,sane_strstatus(r)); return r; } /* Get device properties */ retry = 2; while (retry > 0) { retry--; /* get inquiry data length */ sanei_pieusb_cmd_inquiry (device_number, &inq, 5, &status); if (status.pieusb_status == PIEUSB_STATUS_GOOD) { break; } else if (status.pieusb_status == PIEUSB_STATUS_IO_ERROR) { if (retry > 0) { DBG (DBG_info_proc, "inquiry failed, resetting usb\n"); if (sanei_pieusb_usb_reset(device_number) == SANE_STATUS_GOOD) { continue; /* retry after IEEE1284 reset */ } if (sanei_usb_reset(device_number) == SANE_STATUS_GOOD) { continue; /* retry after USB reset */ } } } free (dev); DBG (DBG_error, "sanei_pieusb_find_device_callback: get scanner properties (5 bytes) failed with %d\n", status.pieusb_status); sanei_usb_close (device_number); return status.pieusb_status; } /* get full inquiry data */ sanei_pieusb_cmd_inquiry(device_number, &inq, inq.additionalLength+4, &status); if (status.pieusb_status != PIEUSB_STATUS_GOOD) { free (dev); DBG (DBG_error, "sanei_pieusb_find_device_callback: get scanner properties failed\n"); sanei_usb_close (device_number); return status.pieusb_status; } /* Close the device again */ sanei_usb_close(device_number); /* Initialize device definition */ r = pieusb_initialize_device_definition(dev, &inq, devicename, pieusb_supported_usb_device.vendor, pieusb_supported_usb_device.product); if (r != SANE_STATUS_GOOD) { return r; } /* Output */ pieusb_print_inquiry (dev); /* Check model number */ if (inq.model != pieusb_supported_usb_device.model) { free (dev); DBG (DBG_error, "sanei_pieusb_find_device_callback: wrong model number %d\n", inq.model); 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; pieusb_definition_list_head = dev; return SANE_STATUS_GOOD; } /** * Full initialization of a Pieusb_Device structure from INQUIRY data. * The function is used in find_device_callback(), so when sane_init() or * sane_open() is called. * * @param dev */ static SANE_Status pieusb_initialize_device_definition (Pieusb_Device_Definition* dev, Pieusb_Scanner_Properties* inq, const char* devicename, SANE_Word vendor_id, SANE_Word product_id) { char *pp, *buf; /* Initialize device definition */ dev->next = NULL; dev->sane.name = strdup(devicename); /* Create 0-terminated string without trailing spaces for vendor */ buf = malloc(9); if (buf == NULL) return SANE_STATUS_NO_MEM; memcpy(buf, inq->vendor, 8); pp = buf + 8; *pp-- = '\0'; while (*pp == ' ') *pp-- = '\0'; dev->sane.vendor = buf; /* Create 0-terminated string without trailing spaces for model */ buf = malloc(17); if (buf == NULL) return SANE_STATUS_NO_MEM; memcpy(buf, inq->product, 16); pp = buf + 16; *pp-- = '\0'; while (*pp == ' ') *pp-- = '\0'; dev->sane.model = buf; dev->sane.type = "film scanner"; dev->vendorId = vendor_id; dev->productId = product_id; /* Create 0-terminated strings without trailing spaces for revision */ buf = malloc(5); if (buf == NULL) return SANE_STATUS_NO_MEM; memcpy(buf, inq->productRevision, 4); pp = buf + 4; *pp-- = '\0'; while (*pp == ' ') *pp-- = '\0'; dev->version = buf; dev->model = inq->model; /* Maximum resolution values */ dev->maximum_resolution_x = inq->maxResolutionX; dev->maximum_resolution_y = inq->maxResolutionY; if (dev->maximum_resolution_y < 256) { /* y res is a multiplier */ dev->maximum_resolution = dev->maximum_resolution_x; dev->maximum_resolution_x *= dev->maximum_resolution_y; dev->maximum_resolution_y = dev->maximum_resolution_x; } else { /* y res really is resolution */ dev->maximum_resolution = min (dev->maximum_resolution_x, dev->maximum_resolution_y); } /* Geometry */ dev->scan_bed_width = (double) inq->maxScanWidth / dev->maximum_resolution; dev->scan_bed_height = (double) inq->maxScanHeight / dev->maximum_resolution; dev->slide_top_left_x = inq->x0; dev->slide_top_left_y = inq->y0; dev->slide_width = (double) (inq->x1 - inq->x0) / dev->maximum_resolution; dev->slide_height = (double) (inq->y1 - inq->y0) / dev->maximum_resolution; /* Integer and bit-encoded properties */ dev->halftone_patterns = inq->halftones & 0x0f; dev->color_filters = inq->filters; dev->color_depths = inq->colorDepths; dev->color_formats = inq->colorFormat; dev->image_formats = inq->imageFormat; dev->scan_capabilities = inq->scanCapability; dev->optional_devices = inq->optionalDevices; dev->enhancements = inq->enhancements; dev->gamma_bits = inq->gammaBits; dev->fast_preview_resolution = inq->previewScanResolution; dev->minimum_highlight = inq->minumumHighlight; dev->maximum_shadow = inq->maximumShadow; dev->calibration_equation = inq->calibrationEquation; dev->minimum_exposure = inq->minimumExposure; dev->maximum_exposure = inq->maximumExposure*4; /* *4 to solve the strange situation that the default value is out of range */ dev->x0 = inq->x0; dev->y0 = inq->y0; dev->x1 = inq->x1; dev->y1 = inq->y1; dev->production = strndup(inq->production, 4); dev->timestamp = strndup(inq->timestamp, 20); dev->signature = (char *)strndup((char *)inq->signature, 40); /* Ranges for various quantities */ dev->x_range.min = SANE_FIX (0); dev->x_range.quant = SANE_FIX (0); dev->x_range.max = SANE_FIX (dev->scan_bed_width * MM_PER_INCH); dev->y_range.min = SANE_FIX (0); dev->y_range.quant = SANE_FIX (0); dev->y_range.max = SANE_FIX (dev->scan_bed_height * MM_PER_INCH); dev->dpi_range.min = SANE_FIX (25); dev->dpi_range.quant = SANE_FIX (1); dev->dpi_range.max = SANE_FIX (max (dev->maximum_resolution_x, dev->maximum_resolution_y)); dev->shadow_range.min = SANE_FIX (0); dev->shadow_range.quant = SANE_FIX (1); dev->shadow_range.max = SANE_FIX (dev->maximum_shadow); dev->highlight_range.min = SANE_FIX (dev->minimum_highlight); dev->highlight_range.quant = SANE_FIX (1); dev->highlight_range.max = SANE_FIX (100); dev->exposure_range.min = dev->minimum_exposure; dev->exposure_range.quant = 1; dev->exposure_range.max = dev->maximum_exposure; dev->dust_range.min = 0; dev->dust_range.quant = 1; dev->dust_range.max = 100; /* Enumerated ranges vor various quantities */ /*TODO: create from inq->filters */ dev->scan_mode_list[0] = SANE_VALUE_SCAN_MODE_LINEART; dev->scan_mode_list[1] = SANE_VALUE_SCAN_MODE_HALFTONE; dev->scan_mode_list[2] = SANE_VALUE_SCAN_MODE_GRAY; dev->scan_mode_list[3] = SANE_VALUE_SCAN_MODE_COLOR; dev->scan_mode_list[4] = SANE_VALUE_SCAN_MODE_RGBI; dev->scan_mode_list[5] = 0; dev->calibration_mode_list[0] = SCAN_CALIBRATION_DEFAULT; dev->calibration_mode_list[1] = SCAN_CALIBRATION_AUTO; dev->calibration_mode_list[2] = SCAN_CALIBRATION_PREVIEW; dev->calibration_mode_list[3] = SCAN_CALIBRATION_OPTIONS; dev->calibration_mode_list[4] = 0; dev->gain_adjust_list[0] = SCAN_GAIN_ADJUST_03; dev->gain_adjust_list[1] = SCAN_GAIN_ADJUST_05; dev->gain_adjust_list[2] = SCAN_GAIN_ADJUST_08; dev->gain_adjust_list[3] = SCAN_GAIN_ADJUST_10; dev->gain_adjust_list[4] = SCAN_GAIN_ADJUST_12; dev->gain_adjust_list[5] = SCAN_GAIN_ADJUST_16; dev->gain_adjust_list[6] = SCAN_GAIN_ADJUST_19; dev->gain_adjust_list[7] = SCAN_GAIN_ADJUST_24; dev->gain_adjust_list[8] = SCAN_GAIN_ADJUST_30; dev->gain_adjust_list[9] = 0; /*TODO: create from inq->colorDepths? Maybe not: didn't experiment with * 4 and 12 bit depths. Don;t know how they behave. */ dev->bpp_list[0] = 3; /* count */ dev->bpp_list[1] = 1; dev->bpp_list[2] = 8; dev->bpp_list[3] = 16; /* Infrared */ dev->ir_sw_list[0] = "None"; dev->ir_sw_list[1] = "Reduce red overlap"; dev->ir_sw_list[2] = "Remove dirt"; dev->ir_sw_list[3] = 0; dev->grain_sw_list[0] = 4; dev->grain_sw_list[1] = 0; dev->grain_sw_list[2] = 1; dev->grain_sw_list[3] = 2; dev->grain_sw_list[4] = 3; dev->grain_sw_list[5] = 0; dev->crop_sw_list[0] = "None"; dev->crop_sw_list[1] = "Outside"; dev->crop_sw_list[2] = "Inside"; dev->crop_sw_list[3] = 0; /* halftone_list */ dev->halftone_list[0] = "53lpi 45d ROUND"; /* 8x8 pattern */ dev->halftone_list[1] = "70lpi 45d ROUND"; /* 6x6 pattern */ dev->halftone_list[2] = "75lpi Hori. Line"; /* 4x4 pattern */ dev->halftone_list[3] = "4X4 BAYER"; /* 4x4 pattern */ dev->halftone_list[4] = "4X4 SCROLL"; /* 4x4 pattern */ dev->halftone_list[5] = "5x5 26 Levels"; /* 5x5 pattern */ dev->halftone_list[6] = "4x4 SQUARE"; /* 4x4 pattern */ dev->halftone_list[7] = "5x5 TILE"; /* 5x5 pattern */ dev->halftone_list[8] = 0; return SANE_STATUS_GOOD; } /** * Output device definition. * The function is used in find_device_callback(), so when sane_init() or * sane_open() is called. * * @param dev Device to output */ static void pieusb_print_inquiry (Pieusb_Device_Definition * dev) { DBG (DBG_inquiry, "INQUIRY:\n"); DBG (DBG_inquiry, "========\n"); DBG (DBG_inquiry, "\n"); DBG (DBG_inquiry, "vendor........................: '%s'\n", dev->sane.vendor); DBG (DBG_inquiry, "product.......................: '%s'\n", dev->sane.model); DBG (DBG_inquiry, "model .......................: 0x%04x\n", dev->model); DBG (DBG_inquiry, "version.......................: '%s'\n", dev->version); DBG (DBG_inquiry, "X resolution..................: %d dpi\n", dev->maximum_resolution_x); DBG (DBG_inquiry, "Y resolution..................: %d dpi\n", dev->maximum_resolution_y); DBG (DBG_inquiry, "pixel resolution..............: %d dpi\n", dev->maximum_resolution); DBG (DBG_inquiry, "fb width......................: %f in\n", dev->scan_bed_width); DBG (DBG_inquiry, "fb length.....................: %f in\n", dev->scan_bed_height); DBG (DBG_inquiry, "transparency width............: %f in\n", dev->slide_width); DBG (DBG_inquiry, "transparency length...........: %f in\n", dev->slide_height); DBG (DBG_inquiry, "transparency offset...........: %d,%d\n", dev->slide_top_left_x, dev->slide_top_left_y); DBG (DBG_inquiry, "# of halftones................: %d\n", dev->halftone_patterns); DBG (DBG_inquiry, "One pass color................: %s\n", dev->color_filters & SCAN_ONE_PASS_COLOR ? "yes" : "no"); DBG (DBG_inquiry, "Filters.......................: %s%s%s%s%s (%02x)\n", dev->color_filters & SCAN_FILTER_INFRARED ? "Infrared " : "", dev->color_filters & SCAN_FILTER_RED ? "Red " : "", dev->color_filters & SCAN_FILTER_GREEN ? "Green " : "", dev->color_filters & SCAN_FILTER_BLUE ? "Blue " : "", dev->color_filters & SCAN_FILTER_NEUTRAL ? "Neutral " : "", dev->color_filters); DBG (DBG_inquiry, "Color depths..................: %s%s%s%s%s%s (%02x)\n", dev->color_depths & SCAN_COLOR_DEPTH_16 ? "16 bit " : "", dev->color_depths & SCAN_COLOR_DEPTH_12 ? "12 bit " : "", dev->color_depths & SCAN_COLOR_DEPTH_10 ? "10 bit " : "", dev->color_depths & SCAN_COLOR_DEPTH_8 ? "8 bit " : "", dev->color_depths & SCAN_COLOR_DEPTH_4 ? "4 bit " : "", dev->color_depths & SCAN_COLOR_DEPTH_1 ? "1 bit " : "", dev->color_depths); DBG (DBG_inquiry, "Color Format..................: %s%s%s (%02x)\n", dev->color_formats & SCAN_COLOR_FORMAT_INDEX ? "Indexed " : "", dev->color_formats & SCAN_COLOR_FORMAT_LINE ? "Line " : "", dev->color_formats & SCAN_COLOR_FORMAT_PIXEL ? "Pixel " : "", dev->color_formats); DBG (DBG_inquiry, "Image Format..................: %s%s%s%s (%02x)\n", dev->image_formats & SCAN_IMG_FMT_OKLINE ? "OKLine " : "", dev->image_formats & SCAN_IMG_FMT_BLK_ONE ? "BlackOne " : "", dev->image_formats & SCAN_IMG_FMT_MOTOROLA ? "Motorola " : "", dev->image_formats & SCAN_IMG_FMT_INTEL ? "Intel" : "", dev->image_formats); DBG (DBG_inquiry, "Scan Capability...............: %s%s%s%s%d speeds (%02x)\n", dev->scan_capabilities & SCAN_CAP_PWRSAV ? "PowerSave " : "", dev->scan_capabilities & SCAN_CAP_EXT_CAL ? "ExtCal " : "", dev->scan_capabilities & SCAN_CAP_FAST_PREVIEW ? "FastPreview" : "", dev->scan_capabilities & SCAN_CAP_DISABLE_CAL ? "DisCal " : "", dev->scan_capabilities & SCAN_CAP_SPEEDS, dev->scan_capabilities); DBG (DBG_inquiry, "Optional Devices..............: %s%s%s%s (%02x)\n", dev->optional_devices & SCAN_OPT_DEV_MPCL ? "MultiPageLoad " : "", dev->optional_devices & SCAN_OPT_DEV_TP1 ? "TransModule1 " : "", dev->optional_devices & SCAN_OPT_DEV_TP ? "TransModule " : "", dev->optional_devices & SCAN_OPT_DEV_ADF ? "ADF " : "", dev->optional_devices); DBG (DBG_inquiry, "Enhancement...................: %02x\n", dev->enhancements); DBG (DBG_inquiry, "Gamma bits....................: %d\n", dev->gamma_bits); DBG (DBG_inquiry, "Fast Preview Resolution.......: %d\n", dev->fast_preview_resolution); DBG (DBG_inquiry, "Min Highlight.................: %d\n", dev->minimum_highlight); DBG (DBG_inquiry, "Max Shadow....................: %d\n", dev->maximum_shadow); DBG (DBG_inquiry, "Cal Eqn.......................: %d\n", dev->calibration_equation); DBG (DBG_inquiry, "Min Exposure..................: %d\n", dev->minimum_exposure); DBG (DBG_inquiry, "Max Exposure..................: %d\n", dev->maximum_exposure); DBG (DBG_inquiry, "x0,y0 x1,y1...................: %d,%d %d,%d\n", dev->x0, dev->y0, dev->x1, dev->y1); DBG (DBG_inquiry, "production....................: '%s'\n", dev->production); DBG (DBG_inquiry, "timestamp.....................: '%s'\n", dev->timestamp); DBG (DBG_inquiry, "signature.....................: '%s'\n", dev->signature); } /** * Initiaize scanner options from the device definition and from exposure, * gain and offset defaults. The function is called by sane_open(), when no * optimized settings are available yet. The scanner object is fully * initialized in sane_start(). * * @param scanner Scanner to initialize * @return SANE_STATUS_GOOD */ SANE_Status sanei_pieusb_init_options (Pieusb_Scanner* scanner) { int i; DBG (DBG_info_proc, "sanei_pieusb_init_options\n"); memset (scanner->opt, 0, sizeof (scanner->opt)); memset (scanner->val, 0, sizeof (scanner->val)); for (i = 0; i < NUM_OPTIONS; ++i) { scanner->opt[i].size = sizeof (SANE_Word); scanner->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* Number of options (a pseudo-option) */ scanner->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; scanner->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; scanner->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; scanner->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; scanner->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; scanner->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ scanner->opt[OPT_MODE_GROUP].title = "Scan Mode"; scanner->opt[OPT_MODE_GROUP].desc = ""; scanner->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_MODE_GROUP].cap = 0; scanner->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ scanner->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; scanner->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; scanner->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; scanner->opt[OPT_MODE].type = SANE_TYPE_STRING; scanner->opt[OPT_MODE].size = max_string_size ((SANE_String_Const const *) scanner->device->scan_mode_list); scanner->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_MODE].constraint.string_list = (SANE_String_Const const *) scanner->device->scan_mode_list; scanner->val[OPT_MODE].s = (SANE_Char *) strdup (scanner->device->scan_mode_list[3]); /* default RGB */ /* bit depth */ scanner->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; scanner->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; scanner->opt[OPT_BIT_DEPTH].size = sizeof (SANE_Word); scanner->opt[OPT_BIT_DEPTH].constraint.word_list = scanner->device->bpp_list; scanner->val[OPT_BIT_DEPTH].w = scanner->device->bpp_list[2]; /* resolution */ scanner->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; scanner->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; scanner->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; scanner->opt[OPT_RESOLUTION].type = SANE_TYPE_FIXED; scanner->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; scanner->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_RESOLUTION].constraint.range = &scanner->device->dpi_range; scanner->val[OPT_RESOLUTION].w = scanner->device->fast_preview_resolution << SANE_FIXED_SCALE_SHIFT; /* halftone pattern */ scanner->opt[OPT_HALFTONE_PATTERN].name = SANE_NAME_HALFTONE_PATTERN; scanner->opt[OPT_HALFTONE_PATTERN].title = SANE_TITLE_HALFTONE_PATTERN; scanner->opt[OPT_HALFTONE_PATTERN].desc = SANE_DESC_HALFTONE_PATTERN; scanner->opt[OPT_HALFTONE_PATTERN].type = SANE_TYPE_STRING; scanner->opt[OPT_HALFTONE_PATTERN].size = max_string_size ((SANE_String_Const const *) scanner->device->halftone_list); scanner->opt[OPT_HALFTONE_PATTERN].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_HALFTONE_PATTERN].constraint.string_list = (SANE_String_Const const *) scanner->device->halftone_list; scanner->val[OPT_HALFTONE_PATTERN].s = (SANE_Char *) strdup (scanner->device->halftone_list[6]); scanner->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; /* Not implemented, and only meaningful at depth 1 */ /* lineart threshold */ scanner->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; scanner->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; scanner->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; scanner->opt[OPT_THRESHOLD].type = SANE_TYPE_FIXED; scanner->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_THRESHOLD].constraint.range = &percentage_range_100; scanner->val[OPT_THRESHOLD].w = SANE_FIX (50); /* scanner->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; Not implemented, and only meaningful at depth 1 */ /* create a sharper scan at the cost of scan time */ scanner->opt[OPT_SHARPEN].name = "sharpen"; scanner->opt[OPT_SHARPEN].title = "Sharpen scan"; scanner->opt[OPT_SHARPEN].desc = "Sharpen scan by taking more time to discharge the CCD."; scanner->opt[OPT_SHARPEN].type = SANE_TYPE_BOOL; scanner->opt[OPT_SHARPEN].unit = SANE_UNIT_NONE; scanner->opt[OPT_SHARPEN].constraint_type = SANE_CONSTRAINT_NONE; scanner->val[OPT_SHARPEN].b = SANE_FALSE; scanner->opt[OPT_SHARPEN].cap |= SANE_CAP_SOFT_SELECT; /* skip the auto-calibration phase before the scan */ scanner->opt[OPT_SHADING_ANALYSIS].name = "shading-analysis"; scanner->opt[OPT_SHADING_ANALYSIS].title = "Perform shading analysis"; scanner->opt[OPT_SHADING_ANALYSIS].desc = "Collect shading reference data before scanning the image. If set to 'no', this option may be overridden by the scanner."; scanner->opt[OPT_SHADING_ANALYSIS].type = SANE_TYPE_BOOL; scanner->opt[OPT_SHADING_ANALYSIS].unit = SANE_UNIT_NONE; scanner->opt[OPT_SHADING_ANALYSIS].constraint_type = SANE_CONSTRAINT_NONE; scanner->val[OPT_SHADING_ANALYSIS].b = SANE_FALSE; scanner->opt[OPT_SHADING_ANALYSIS].cap |= SANE_CAP_SOFT_SELECT; /* use auto-calibration settings for scan */ scanner->opt[OPT_CALIBRATION_MODE].name = "calibration"; scanner->opt[OPT_CALIBRATION_MODE].title = "Calibration mode"; scanner->opt[OPT_CALIBRATION_MODE].desc = "How to calibrate the scanner."; scanner->opt[OPT_CALIBRATION_MODE].type = SANE_TYPE_STRING; scanner->opt[OPT_CALIBRATION_MODE].size = max_string_size ((SANE_String_Const const *) scanner->device->calibration_mode_list); scanner->opt[OPT_CALIBRATION_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_CALIBRATION_MODE].constraint.string_list = (SANE_String_Const const *) scanner->device->calibration_mode_list; scanner->val[OPT_CALIBRATION_MODE].s = (SANE_Char *) strdup (scanner->device->calibration_mode_list[1]); /* default auto */ /* OPT_GAIN_ADJUST */ scanner->opt[OPT_GAIN_ADJUST].name = "gain-adjust"; scanner->opt[OPT_GAIN_ADJUST].title = "Adjust gain"; scanner->opt[OPT_GAIN_ADJUST].desc = "Adjust gain determined by calibration procedure."; scanner->opt[OPT_GAIN_ADJUST].type = SANE_TYPE_STRING; scanner->opt[OPT_GAIN_ADJUST].size = max_string_size ((SANE_String_Const const *) scanner->device->gain_adjust_list); scanner->opt[OPT_GAIN_ADJUST].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_GAIN_ADJUST].constraint.string_list = (SANE_String_Const const *) scanner->device->gain_adjust_list; scanner->val[OPT_GAIN_ADJUST].s = (SANE_Char *) strdup (scanner->device->gain_adjust_list[2]); /* x 1.0 (no change) */ /* scan infrared channel faster but less accurate */ scanner->opt[OPT_FAST_INFRARED].name = "fast-infrared"; scanner->opt[OPT_FAST_INFRARED].title = "Fast infrared scan"; scanner->opt[OPT_FAST_INFRARED].desc = "Do not reposition scan head before scanning infrared line. Results in an infrared offset which may deteriorate IR dust and scratch removal."; scanner->opt[OPT_FAST_INFRARED].type = SANE_TYPE_BOOL; scanner->opt[OPT_FAST_INFRARED].unit = SANE_UNIT_NONE; scanner->opt[OPT_FAST_INFRARED].constraint_type = SANE_CONSTRAINT_NONE; scanner->val[OPT_FAST_INFRARED].b = SANE_FALSE; scanner->opt[OPT_FAST_INFRARED].cap |= SANE_CAP_SOFT_SELECT; /* automatically advance to next slide after scan */ scanner->opt[OPT_ADVANCE_SLIDE].name = "advcane"; scanner->opt[OPT_ADVANCE_SLIDE].title = "Advance slide"; scanner->opt[OPT_ADVANCE_SLIDE].desc = "Automatically advance to next slide after scan"; scanner->opt[OPT_ADVANCE_SLIDE].type = SANE_TYPE_BOOL; scanner->opt[OPT_ADVANCE_SLIDE].unit = SANE_UNIT_NONE; scanner->opt[OPT_ADVANCE_SLIDE].constraint_type = SANE_CONSTRAINT_NONE; scanner->val[OPT_ADVANCE_SLIDE].w = SANE_TRUE; scanner->opt[OPT_ADVANCE_SLIDE].cap |= SANE_CAP_SOFT_SELECT; /* "Geometry" group: */ scanner->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; scanner->opt[OPT_GEOMETRY_GROUP].desc = ""; scanner->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; scanner->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ scanner->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; scanner->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; scanner->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; scanner->opt[OPT_TL_X].type = SANE_TYPE_FIXED; scanner->opt[OPT_TL_X].unit = SANE_UNIT_MM; scanner->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_TL_X].constraint.range = &(scanner->device->x_range); scanner->val[OPT_TL_X].w = 0; /* top-left y */ scanner->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; scanner->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; scanner->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; scanner->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; scanner->opt[OPT_TL_Y].unit = SANE_UNIT_MM; scanner->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_TL_Y].constraint.range = &(scanner->device->y_range); scanner->val[OPT_TL_Y].w = 0; /* bottom-right x */ scanner->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; scanner->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; scanner->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; scanner->opt[OPT_BR_X].type = SANE_TYPE_FIXED; scanner->opt[OPT_BR_X].unit = SANE_UNIT_MM; scanner->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BR_X].constraint.range = &(scanner->device->x_range); scanner->val[OPT_BR_X].w = scanner->device->x_range.max; /* bottom-right y */ scanner->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; scanner->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; scanner->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; scanner->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; scanner->opt[OPT_BR_Y].unit = SANE_UNIT_MM; scanner->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BR_Y].constraint.range = &(scanner->device->y_range); scanner->val[OPT_BR_Y].w = scanner->device->y_range.max; /* "Enhancement" group: */ scanner->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; scanner->opt[OPT_ENHANCEMENT_GROUP].desc = ""; scanner->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_ENHANCEMENT_GROUP].cap = 0; scanner->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* correct data for lamp variations (shading) */ scanner->opt[OPT_CORRECT_SHADING].name = "correct-shading"; scanner->opt[OPT_CORRECT_SHADING].title = "Correct shading"; scanner->opt[OPT_CORRECT_SHADING].desc = "Correct data for lamp variations (shading)"; scanner->opt[OPT_CORRECT_SHADING].type = SANE_TYPE_BOOL; scanner->opt[OPT_CORRECT_SHADING].unit = SANE_UNIT_NONE; scanner->val[OPT_CORRECT_SHADING].w = SANE_TRUE; /* correct infrared for red crosstalk */ scanner->opt[OPT_CORRECT_INFRARED].name = "correct-infrared"; scanner->opt[OPT_CORRECT_INFRARED].title = "Correct infrared"; scanner->opt[OPT_CORRECT_INFRARED].desc = "Correct infrared for red crosstalk"; scanner->opt[OPT_CORRECT_INFRARED].type = SANE_TYPE_BOOL; scanner->opt[OPT_CORRECT_INFRARED].unit = SANE_UNIT_NONE; scanner->val[OPT_CORRECT_INFRARED].w = SANE_FALSE; /* detect and remove dust and scratch artifacts */ scanner->opt[OPT_CLEAN_IMAGE].name = "clean-image"; scanner->opt[OPT_CLEAN_IMAGE].title = "Clean image"; scanner->opt[OPT_CLEAN_IMAGE].desc = "Detect and remove dust and scratch artifacts"; scanner->opt[OPT_CLEAN_IMAGE].type = SANE_TYPE_BOOL; scanner->opt[OPT_CLEAN_IMAGE].unit = SANE_UNIT_NONE; scanner->val[OPT_CLEAN_IMAGE].w = SANE_FALSE; /* strength of grain filtering */ scanner->opt[OPT_SMOOTH_IMAGE].name = "smooth"; scanner->opt[OPT_SMOOTH_IMAGE].title = "Attenuate film grain"; scanner->opt[OPT_SMOOTH_IMAGE].desc = "Amount of smoothening"; scanner->opt[OPT_SMOOTH_IMAGE].type = SANE_TYPE_INT; scanner->opt[OPT_SMOOTH_IMAGE].constraint_type = SANE_CONSTRAINT_WORD_LIST; scanner->opt[OPT_SMOOTH_IMAGE].size = sizeof (SANE_Word); scanner->opt[OPT_SMOOTH_IMAGE].constraint.word_list = scanner->device->grain_sw_list; scanner->val[OPT_SMOOTH_IMAGE].w = scanner->device->grain_sw_list[1]; if (scanner->opt[OPT_SMOOTH_IMAGE].constraint.word_list[0] < 2) { scanner->opt[OPT_SMOOTH_IMAGE].cap |= SANE_CAP_INACTIVE; } /* gamma correction, to make image sRGB like */ scanner->opt[OPT_TRANSFORM_TO_SRGB].name = "srgb"; scanner->opt[OPT_TRANSFORM_TO_SRGB].title = "sRGB colors"; scanner->opt[OPT_TRANSFORM_TO_SRGB].desc = "Transform image to approximate sRGB color space"; scanner->opt[OPT_TRANSFORM_TO_SRGB].type = SANE_TYPE_BOOL; scanner->opt[OPT_TRANSFORM_TO_SRGB].unit = SANE_UNIT_NONE; scanner->val[OPT_TRANSFORM_TO_SRGB].w = SANE_FALSE; scanner->opt[OPT_TRANSFORM_TO_SRGB].cap |= SANE_CAP_INACTIVE; /* color correction for generic negative film */ scanner->opt[OPT_INVERT_IMAGE].name = "invert"; scanner->opt[OPT_INVERT_IMAGE].title = "Invert colors"; scanner->opt[OPT_INVERT_IMAGE].desc = "Correct for generic negative film"; scanner->opt[OPT_INVERT_IMAGE].type = SANE_TYPE_BOOL; scanner->opt[OPT_INVERT_IMAGE].unit = SANE_UNIT_NONE; scanner->val[OPT_INVERT_IMAGE].w = SANE_FALSE; scanner->opt[OPT_INVERT_IMAGE].cap |= SANE_CAP_INACTIVE; /* crop image */ scanner->opt[OPT_CROP_IMAGE].name = "crop"; scanner->opt[OPT_CROP_IMAGE].title = "Cropping"; scanner->opt[OPT_CROP_IMAGE].desc = "How to crop the image"; scanner->opt[OPT_CROP_IMAGE].type = SANE_TYPE_STRING; scanner->opt[OPT_CROP_IMAGE].size = max_string_size ((SANE_String_Const const *)(void*) scanner->device->crop_sw_list); scanner->opt[OPT_CROP_IMAGE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_CROP_IMAGE].constraint.string_list = (SANE_String_Const const *)(void*) scanner->device->crop_sw_list; scanner->val[OPT_CROP_IMAGE].s = (SANE_Char *) strdup (scanner->device->crop_sw_list[2]); /* "Advanced" group: */ scanner->opt[OPT_ADVANCED_GROUP].title = "Advanced"; scanner->opt[OPT_ADVANCED_GROUP].desc = ""; scanner->opt[OPT_ADVANCED_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_ADVANCED_GROUP].cap = SANE_CAP_ADVANCED; scanner->opt[OPT_ADVANCED_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* preview */ scanner->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; scanner->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; scanner->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; scanner->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; scanner->val[OPT_PREVIEW].w = SANE_FALSE; /* save shading data */ scanner->opt[OPT_SAVE_SHADINGDATA].name = "save-shading-data"; scanner->opt[OPT_SAVE_SHADINGDATA].title = "Save shading data"; scanner->opt[OPT_SAVE_SHADINGDATA].desc = "Save shading data in 'pieusb.shading'"; scanner->opt[OPT_SAVE_SHADINGDATA].type = SANE_TYPE_BOOL; scanner->val[OPT_SAVE_SHADINGDATA].w = SANE_FALSE; /* save CCD mask */ scanner->opt[OPT_SAVE_CCDMASK].name = "save-ccdmask"; scanner->opt[OPT_SAVE_CCDMASK].title = "Save CCD mask"; scanner->opt[OPT_SAVE_CCDMASK].desc = "Save CCD mask 'pieusb.ccd'"; scanner->opt[OPT_SAVE_CCDMASK].type = SANE_TYPE_BOOL; scanner->val[OPT_SAVE_CCDMASK].w = SANE_FALSE; scanner->opt[OPT_LIGHT].name = "light"; scanner->opt[OPT_LIGHT].title = "Light"; scanner->opt[OPT_LIGHT].desc = "Light"; scanner->opt[OPT_LIGHT].type = SANE_TYPE_INT; scanner->opt[OPT_LIGHT].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_LIGHT].cap |= SANE_CAP_SOFT_SELECT; scanner->opt[OPT_LIGHT].size = sizeof(SANE_Word); scanner->val[OPT_LIGHT].w = DEFAULT_LIGHT; scanner->opt[OPT_DOUBLE_TIMES].name = "double-times"; scanner->opt[OPT_DOUBLE_TIMES].title = "Double times"; scanner->opt[OPT_DOUBLE_TIMES].desc = "Double times"; scanner->opt[OPT_DOUBLE_TIMES].type = SANE_TYPE_INT; scanner->opt[OPT_DOUBLE_TIMES].unit = SANE_UNIT_MICROSECOND; scanner->opt[OPT_DOUBLE_TIMES].cap |= SANE_CAP_SOFT_SELECT; scanner->opt[OPT_DOUBLE_TIMES].size = sizeof(SANE_Word); scanner->val[OPT_DOUBLE_TIMES].w = DEFAULT_DOUBLE_TIMES; /* exposure times for R, G, B and I */ scanner->opt[OPT_SET_EXPOSURE_R].name = SANE_NAME_EXPOSURE_R; scanner->opt[OPT_SET_EXPOSURE_R].title = SANE_TITLE_EXPOSURE_R; scanner->opt[OPT_SET_EXPOSURE_R].desc = SANE_DESC_EXPOSURE_R; scanner->opt[OPT_SET_EXPOSURE_G].name = SANE_NAME_EXPOSURE_G; scanner->opt[OPT_SET_EXPOSURE_G].title = SANE_TITLE_EXPOSURE_G; scanner->opt[OPT_SET_EXPOSURE_G].desc = SANE_DESC_EXPOSURE_G; scanner->opt[OPT_SET_EXPOSURE_B].name = SANE_NAME_EXPOSURE_B; scanner->opt[OPT_SET_EXPOSURE_B].title = SANE_TITLE_EXPOSURE_B; scanner->opt[OPT_SET_EXPOSURE_B].desc = SANE_DESC_EXPOSURE_B; scanner->opt[OPT_SET_EXPOSURE_I].name = SANE_NAME_EXPOSURE_I; scanner->opt[OPT_SET_EXPOSURE_I].title = SANE_TITLE_EXPOSURE_I; scanner->opt[OPT_SET_EXPOSURE_I].desc = SANE_DESC_EXPOSURE_I; for (i = OPT_SET_EXPOSURE_R; i <= OPT_SET_EXPOSURE_I; ++i) { scanner->opt[i].type = SANE_TYPE_INT; scanner->opt[i].unit = SANE_UNIT_MICROSECOND; scanner->opt[i].cap |= SANE_CAP_SOFT_SELECT; scanner->opt[i].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[i].constraint.range = &(scanner->device->exposure_range); scanner->opt[i].size = sizeof(SANE_Word); scanner->val[i].w = SANE_EXPOSURE_DEFAULT; } /* gain for R, G, B and I */ scanner->opt[OPT_SET_GAIN_R].name = SANE_NAME_GAIN_R; scanner->opt[OPT_SET_GAIN_R].title = SANE_TITLE_GAIN_R; scanner->opt[OPT_SET_GAIN_R].desc = SANE_DESC_GAIN_R; scanner->opt[OPT_SET_GAIN_G].name = SANE_NAME_GAIN_G; scanner->opt[OPT_SET_GAIN_G].title = SANE_TITLE_GAIN_G; scanner->opt[OPT_SET_GAIN_G].desc = SANE_DESC_GAIN_G; scanner->opt[OPT_SET_GAIN_B].name = SANE_NAME_GAIN_B; scanner->opt[OPT_SET_GAIN_B].title = SANE_TITLE_GAIN_B; scanner->opt[OPT_SET_GAIN_B].desc = SANE_DESC_GAIN_B; scanner->opt[OPT_SET_GAIN_I].name = SANE_NAME_GAIN_I; scanner->opt[OPT_SET_GAIN_I].title = SANE_TITLE_GAIN_I; scanner->opt[OPT_SET_GAIN_I].desc = SANE_DESC_GAIN_I; for (i = OPT_SET_GAIN_R; i <= OPT_SET_GAIN_I; ++i) { scanner->opt[i].type = SANE_TYPE_INT; scanner->opt[i].unit = SANE_UNIT_NONE; scanner->opt[i].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[i].constraint.range = &gain_range; scanner->opt[i].size = sizeof(SANE_Word); scanner->val[i].w = SANE_GAIN_DEFAULT; } /* offsets for R, G, B and I */ scanner->opt[OPT_SET_OFFSET_R].name = SANE_NAME_OFFSET_R; scanner->opt[OPT_SET_OFFSET_R].title = SANE_TITLE_OFFSET_R; scanner->opt[OPT_SET_OFFSET_R].desc = SANE_DESC_OFFSET_R; scanner->opt[OPT_SET_OFFSET_G].name = SANE_NAME_OFFSET_G; scanner->opt[OPT_SET_OFFSET_G].title = SANE_TITLE_OFFSET_G; scanner->opt[OPT_SET_OFFSET_G].desc = SANE_DESC_OFFSET_G; scanner->opt[OPT_SET_OFFSET_B].name = SANE_NAME_OFFSET_B; scanner->opt[OPT_SET_OFFSET_B].title = SANE_TITLE_OFFSET_B; scanner->opt[OPT_SET_OFFSET_B].desc = SANE_DESC_OFFSET_B; scanner->opt[OPT_SET_OFFSET_I].name = SANE_NAME_OFFSET_I; scanner->opt[OPT_SET_OFFSET_I].title = SANE_TITLE_OFFSET_I; scanner->opt[OPT_SET_OFFSET_I].desc = SANE_DESC_OFFSET_I; for (i = OPT_SET_OFFSET_R; i <= OPT_SET_OFFSET_I; ++i) { scanner->opt[i].type = SANE_TYPE_INT; scanner->opt[i].unit = SANE_UNIT_NONE; scanner->opt[i].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[i].constraint.range = &offset_range; scanner->opt[i].size = sizeof(SANE_Word); scanner->val[i].w = SANE_OFFSET_DEFAULT; } return SANE_STATUS_GOOD; } /** * 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_Int* model_number, SANE_Int* flags) { char *vendor_id_string, *product_id_string, *model_number_string, *flags_string; if (strncmp (config_line, "usb ", 4) != 0) { return SANE_STATUS_INVAL; } /* Detect vendor-id */ config_line += 4; config_line = sanei_config_skip_whitespace (config_line); if (*config_line) { config_line = sanei_config_get_string (config_line, &vendor_id_string); if (vendor_id_string) { *vendor_id = strtol (vendor_id_string, 0, 0); free (vendor_id_string); } else { return SANE_STATUS_INVAL; } config_line = sanei_config_skip_whitespace (config_line); } else { return SANE_STATUS_INVAL; } /* Detect product-id */ config_line = sanei_config_skip_whitespace (config_line); if (*config_line) { config_line = sanei_config_get_string (config_line, &product_id_string); if (product_id_string) { *product_id = strtol (product_id_string, 0, 0); free (product_id_string); } else { return SANE_STATUS_INVAL; } config_line = sanei_config_skip_whitespace (config_line); } else { return SANE_STATUS_INVAL; } /* 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 = (SANE_Int) strtol (model_number_string, 0, 0); free (model_number_string); } else { return SANE_STATUS_INVAL; } config_line = sanei_config_skip_whitespace (config_line); } 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; } /** * Check if current list of supported devices contains the given specifications. * * @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_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].flags == flags) { return SANE_TRUE; } i++; } return SANE_FALSE; } /** * Add the given specifications to the current list of supported devices * @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_Int model_number, SANE_Int flags) { int i = 0, k; struct Pieusb_USB_Device_Entry* dl; while (pieusb_supported_usb_device_list[i].vendor != 0) { i++; } /* 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 %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].flags); } dl = realloc(pieusb_supported_usb_device_list,(i+2)*sizeof(struct Pieusb_USB_Device_Entry)); /* Add one entry to list */ if (dl == NULL) { return SANE_STATUS_INVAL; } /* Copy values */ pieusb_supported_usb_device_list = dl; 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 %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].flags); } return SANE_STATUS_GOOD; } /** * Actions to perform when a cancel request has been received. * * @param scanner scanner to stop scanning * @return SANE_STATUS_CANCELLED */ SANE_Status sanei_pieusb_on_cancel (Pieusb_Scanner * scanner) { struct Pieusb_Command_Status status; DBG (DBG_info_proc, "sanei_pieusb_on_cancel()\n"); sanei_pieusb_cmd_stop_scan (scanner->device_number, &status); sanei_pieusb_cmd_set_scan_head (scanner->device_number, 1, 0, &status); sanei_pieusb_buffer_delete (&scanner->buffer); scanner->scanning = SANE_FALSE; return SANE_STATUS_CANCELLED; } /** * Determine maximum lengt of a set of strings. * * @param strings Set of strings * @return maximum length */ static size_t max_string_size (SANE_String_Const const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) { max_size = size; } } return max_size; } /* From MR's pie.c */ /* ------------------------- PIEUSB_CORRECT_SHADING -------------------------- */ /** * Correct the given buffer for shading using shading data in scanner. * If the loop order is width->color->height, a 7200 dpi scan correction takes * 45 minutes. If the loop order is color->height->width, this is less than 3 * minutes. So it is worthwhile to find the used pixels first (array width_to_loc). * * @param scanner Scanner * @param buffer Buffer to correct */ void sanei_pieusb_correct_shading(struct Pieusb_Scanner *scanner, struct Pieusb_Read_Buffer *buffer) { int i, j, c, k; SANE_Uint val, val_org, *p; int *width_to_loc; DBG (DBG_info_proc, "sanei_pieusb_correct_shading()\n"); /* Loop through CCD-mask to find used pixels */ width_to_loc = calloc(buffer->width,sizeof(int)); j = 0; for (i = 0; i < scanner->ccd_mask_size; i++) { if (scanner->ccd_mask[i] == 0) { width_to_loc[j++] = i; } } /* Correct complete image */ for (c = 0; c < buffer->colors; c++) { DBG(DBG_info,"sanei_pieusb_correct_shading() correct color %d\n",c); for (k = 0; k < buffer->height; k++) { /* DBG(DBG_info,"Correct line %d\n",k); */ p = buffer->data + c * buffer->width * buffer->height + k * buffer->width; for (j = 0; j < buffer->width; j++) { val_org = *p; val = lround((double)scanner->shading_mean[c] / scanner->shading_ref[c][width_to_loc[j]] * val_org); /* DBG(DBG_info,"Correct [%d,%d,%d] %d -> %d\n",k,j,c,val_org,val); */ *p++ = val; } } } /* Free memory */ free(width_to_loc); } /* === functions copied from MR's code === */ /** * * @param scanner * @param in_img * @param planes * @param out_planes * @return */ SANE_Status sanei_pieusb_post (Pieusb_Scanner *scanner, uint16_t **in_img, int planes) { uint16_t *cplane[PLANES]; /* R, G, B, I gray scale planes */ SANE_Parameters parameters; /* describes the image */ int winsize_smooth; /* for adapting replaced pixels */ char filename[64]; SANE_Status status; int smooth, i; memcpy (¶meters, &scanner->scan_parameters, sizeof (SANE_Parameters)); parameters.format = SANE_FRAME_GRAY; parameters.bytes_per_line = parameters.pixels_per_line; if (parameters.depth > 8) parameters.bytes_per_line *= 2; parameters.last_frame = 0; DBG (DBG_info, "pie_usb_post: %d ppl, %d lines, %d bits, %d planes, %d dpi\n", parameters.pixels_per_line, parameters.lines, parameters.depth, planes, scanner->mode.resolution); if (planes > PLANES) { DBG (DBG_error, "pie_usb_post: too many planes: %d (max %d)\n", planes, PLANES); return SANE_STATUS_INVAL; } for (i = 0; i < planes; i++) cplane[i] = in_img[i]; /* dirt is rather resolution invariant, so * setup resolution dependent parameters */ /* film grain reduction */ smooth = scanner->val[OPT_SMOOTH_IMAGE].w; winsize_smooth = (scanner->mode.resolution / 540) | 1; /* smoothen whole image or only replaced pixels */ if (smooth) { winsize_smooth += 2 * (smooth - 3); /* even */ if (winsize_smooth < 3) smooth = 0; } if (winsize_smooth < 3) winsize_smooth = 3; DBG (DBG_info, "pie_usb_sw_post: winsize_smooth %d\n", winsize_smooth); /* RGBI post-processing if selected: * 1) remove spectral overlay from ired plane, * 2) remove dirt, smoothen if, crop if */ if (scanner->val[OPT_CORRECT_INFRARED].b) /* (scanner->processing & POST_SW_IRED_MASK) */ { /* remove spectral overlay from ired plane */ status = sanei_ir_spectral_clean (¶meters, scanner->ln_lut, cplane[0], cplane[3]); if (status != SANE_STATUS_GOOD) return status; if (DBG_LEVEL >= 15) { snprintf (filename, 63, "/tmp/ir-spectral.pnm"); pieusb_write_pnm_file (filename, cplane[3], parameters.depth, 1, parameters.pixels_per_line, parameters.lines); } if (scanner->cancel_request) /* asynchronous cancel ? */ return SANE_STATUS_CANCELLED; } /* scanner-> processing & POST_SW_IRED_MASK */ /* remove dirt, smoothen if, crop if */ if (scanner->val[OPT_CLEAN_IMAGE].b) /* (scanner->processing & POST_SW_DIRT) */ { double *norm_histo; uint16_t *thresh_data; int static_thresh, too_thresh; /* static thresholds */ int winsize_filter; /* primary size of filtering window */ int size_dilate; /* the dirt mask */ /* size of filter detecting dirt */ winsize_filter = (int) (5.0 * (double) scanner->mode.resolution / 300.0) | 1; if (winsize_filter < 3) winsize_filter = 3; /* dirt usually has smooth edges which also need correction */ size_dilate = scanner->mode.resolution / 1000 + 1; /* first detect large dirt by a static threshold */ status = sanei_ir_create_norm_histogram (¶meters, cplane[3], &norm_histo); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "pie_usb_sw_post: no buffer\n"); return SANE_STATUS_NO_MEM; } /* generate a "bimodal" static threshold */ status = sanei_ir_threshold_yen (¶meters, norm_histo, &static_thresh); if (status != SANE_STATUS_GOOD) return status; /* generate traditional static threshold */ status = sanei_ir_threshold_otsu (¶meters, norm_histo, &too_thresh); if (status != SANE_STATUS_GOOD) return status; /* choose lower one */ if (too_thresh < static_thresh) static_thresh = too_thresh; free (norm_histo); /* then generate dirt mask with adaptive thresholding filter * and add the dirt from the static threshold */ /* last two parameters: 10, 50 detects more, 20, 75 less */ status = sanei_ir_filter_madmean (¶meters, cplane[3], &thresh_data, winsize_filter, 20, 100); if (status != SANE_STATUS_GOOD) { free (thresh_data); return status; } sanei_ir_add_threshold (¶meters, cplane[3], thresh_data, static_thresh); if (DBG_LEVEL >= 15) { snprintf (filename, 63, "/tmp/ir-threshold.pnm"); pieusb_write_pnm_file (filename, thresh_data, 8, 1, parameters.pixels_per_line, parameters.lines); } if (scanner->cancel_request) { /* asynchronous cancel ? */ free (thresh_data); return SANE_STATUS_CANCELLED; } /* replace the dirt and smoothen film grain and crop if possible */ status = sanei_ir_dilate_mean (¶meters, cplane, thresh_data, 500, size_dilate, winsize_smooth, smooth, 0, NULL); if (status != SANE_STATUS_GOOD) { free (thresh_data); return status; } smooth = 0; free (thresh_data); } if (DBG_LEVEL >= 15) { pieusb_write_pnm_file ("/tmp/RGBi-img.pnm", scanner->buffer.data, scanner->scan_parameters.depth, 3, scanner->scan_parameters.pixels_per_line, scanner->scan_parameters.lines); } return status; } /* ------------------------------ PIE_USB_WRITE_PNM_FILE ------------------------------- */ static SANE_Status pieusb_write_pnm_file (char *filename, SANE_Uint *data, int depth, int channels, int pixels_per_line, int lines) { FILE *out; int r, c, ch; SANE_Uint val; uint8_t b = 0; DBG (DBG_info_proc, "pie_usb_write_pnm_file: depth=%d, channels=%d, ppl=%d, lines=%d\n", depth, channels, pixels_per_line, lines); out = fopen (filename, "w"); if (!out) { DBG (DBG_error, "pie_usb_write_pnm_file: could not open %s for writing: %s\n", filename, strerror (errno)); return SANE_STATUS_INVAL; } switch (depth) { case 1: fprintf (out, "P4\n%d\n%d\n", pixels_per_line, lines); for (r = 0; r < lines; r++) { int i; i = 0; b = 0; for (c = 0; c < pixels_per_line; c++) { val = *(data + r * pixels_per_line + c); if (val > 0) b |= (0x80 >> i); i++; if (i == 7) { fputc(b, out); i = 0; b = 0; } } if (i != 0) { fputc(b, out); } } break; case 8: fprintf (out, "P%c\n%d\n%d\n%d\n", channels == 1 ? '5' : '6', pixels_per_line, lines, 255); for (r = 0; r < lines; r++) { for (c = 0; c < pixels_per_line; c++) { for (ch = 0; ch < channels; ch++) { val = *(data + ch * lines * pixels_per_line + r * pixels_per_line + c); b = val & 0xFF; fputc(b, out); } } } break; case 16: fprintf (out, "P%c\n%d\n%d\n%d\n", channels == 1 ? '5' : '6', pixels_per_line, lines, 65535); for (r = 0; r < lines; r++) { for (c = 0; c < pixels_per_line; c++) { for (ch = 0; ch < channels; ch++) { val = *(data + ch * lines * pixels_per_line + r * pixels_per_line + c); b = (val >> 8) & 0xFF; fputc(b, out); b = val & 0xFF; fputc(b, out); } } } break; default: DBG (DBG_error, "pie_usb_write_pnm_file: depth %d not implemented\n", depth); } fclose (out); DBG (DBG_info, "pie_usb_write_pnm_file: finished\n"); return SANE_STATUS_GOOD; } /** * Check option inconsistencies. * In most cases an inconsistency can be solved by ignoring an option setting. * Message these situations and return 1 to indicate we can work with the * current set op options. If the settings are really inconsistent, return 0. */ int sanei_pieusb_analyse_options(struct Pieusb_Scanner *scanner) { /* Checks*/ if (scanner->val[OPT_TL_X].w > scanner->val[OPT_BR_X].w) { DBG (DBG_error, "sane_start: %s (%.1f mm) is bigger than %s (%.1f mm) -- aborting\n", scanner->opt[OPT_TL_X].title, SANE_UNFIX (scanner->val[OPT_TL_X].w), scanner->opt[OPT_BR_X].title, SANE_UNFIX (scanner->val[OPT_BR_X].w)); return 0; } if (scanner->val[OPT_TL_Y].w > scanner->val[OPT_BR_Y].w) { DBG (DBG_error, "sane_start: %s (%.1f mm) is bigger than %s (%.1f mm) -- aborting\n", scanner->opt[OPT_TL_Y].title, SANE_UNFIX (scanner->val[OPT_TL_Y].w), scanner->opt[OPT_BR_Y].title, SANE_UNFIX (scanner->val[OPT_BR_Y].w)); return 0; } /* Modes sometimes limit other choices */ if (scanner->val[OPT_PREVIEW].b) { /* Preview uses its own specific settings */ if (scanner->val[OPT_RESOLUTION].w != (scanner->device->fast_preview_resolution << SANE_FIXED_SCALE_SHIFT)) { DBG (DBG_info_sane, "Option %s = %f ignored during preview\n", scanner->opt[OPT_RESOLUTION].name, SANE_UNFIX(scanner->val[OPT_RESOLUTION].w)); } if (scanner->val[OPT_SHARPEN].b) { DBG (DBG_info_sane, "Option %s = %d ignored during preview\n", scanner->opt[OPT_SHARPEN].name, scanner->val[OPT_SHARPEN].b); } if (!scanner->val[OPT_FAST_INFRARED].b) { DBG (DBG_info_sane, "Option %s = %d ignored during preview\n", scanner->opt[OPT_FAST_INFRARED].name, scanner->val[OPT_FAST_INFRARED].b); } if (scanner->val[OPT_CORRECT_INFRARED].b) { DBG (DBG_info_sane, "Option %s = %d ignored during preview\n", scanner->opt[OPT_CORRECT_INFRARED].name, scanner->val[OPT_CORRECT_INFRARED].b); } if (scanner->val[OPT_CLEAN_IMAGE].b) { DBG (DBG_info_sane, "Option %s = %d ignored during preview\n", scanner->opt[OPT_CLEAN_IMAGE].name, scanner->val[OPT_CLEAN_IMAGE].b); } if (scanner->val[OPT_SMOOTH_IMAGE].w != 0) { DBG (DBG_info_sane, "Option %s = %d ignored during preview\n", scanner->opt[OPT_SMOOTH_IMAGE].name, scanner->val[OPT_SMOOTH_IMAGE].w); } if (strcmp(scanner->val[OPT_CROP_IMAGE].s, scanner->device->crop_sw_list[0]) != 0) { DBG (DBG_info_sane, "Option %s = %s ignored during preview\n", scanner->opt[OPT_CROP_IMAGE].name, scanner->val[OPT_CROP_IMAGE].s); } if (scanner->val[OPT_TRANSFORM_TO_SRGB].b) { DBG (DBG_info_sane, "Option %s = %d ignored during preview\n", scanner->opt[OPT_TRANSFORM_TO_SRGB].name, scanner->val[OPT_TRANSFORM_TO_SRGB].w); } if (scanner->val[OPT_INVERT_IMAGE].w) { DBG (DBG_info_sane, "Option %s = %d ignored during preview\n", scanner->opt[OPT_INVERT_IMAGE].name, scanner->val[OPT_INVERT_IMAGE].w); } } else if (strcmp(scanner->val[OPT_MODE].s,SANE_VALUE_SCAN_MODE_LINEART)==0) { /* Can we do any post processing in lineart? Needs testing to see what's possible */ if (scanner->val[OPT_BIT_DEPTH].w != 1) { DBG (DBG_info_sane, "Option %s = %d ignored in lineart mode (will use 1)\n", scanner->opt[OPT_BIT_DEPTH].name, scanner->val[OPT_BIT_DEPTH].w); } if (!scanner->val[OPT_FAST_INFRARED].b) { DBG (DBG_info_sane, "Option %s = %d ignored in lineart mode (irrelevant)\n", scanner->opt[OPT_FAST_INFRARED].name, scanner->val[OPT_FAST_INFRARED].b); } if (!scanner->val[OPT_CORRECT_SHADING].b) { DBG (DBG_info_sane, "Option %s = %d ignored in lineart mode (irrelevant)\n", scanner->opt[OPT_CORRECT_SHADING].name, scanner->val[OPT_CORRECT_SHADING].b); } if (!scanner->val[OPT_CORRECT_INFRARED].b) { DBG (DBG_info_sane, "Option %s = %d ignored in lineart mode (irrelevant)\n", scanner->opt[OPT_CORRECT_INFRARED].name, scanner->val[OPT_CORRECT_INFRARED].b); } if (scanner->val[OPT_CLEAN_IMAGE].b) { DBG (DBG_info_sane, "Option %s = %d ignored in lineart mode (irrelevant)\n", scanner->opt[OPT_CLEAN_IMAGE].name, scanner->val[OPT_CLEAN_IMAGE].b); } if (scanner->val[OPT_SMOOTH_IMAGE].w != 0) { DBG (DBG_info_sane, "Option %s = %d ignored in lineart mode (irrelevant)\n", scanner->opt[OPT_SMOOTH_IMAGE].name, scanner->val[OPT_SMOOTH_IMAGE].w); } if (strcmp(scanner->val[OPT_CROP_IMAGE].s, scanner->device->crop_sw_list[0]) != 0) { DBG (DBG_info_sane, "Option %s = %s ignored in lineart mode (irrelevant)\n", scanner->opt[OPT_CROP_IMAGE].name, scanner->val[OPT_CROP_IMAGE].s); } if (scanner->val[OPT_TRANSFORM_TO_SRGB].b) { DBG (DBG_info_sane, "Option %s = %d ignored in lineart mode (irrelevant)\n", scanner->opt[OPT_TRANSFORM_TO_SRGB].name, scanner->val[OPT_TRANSFORM_TO_SRGB].w); } } else if (strcmp(scanner->val[OPT_MODE].s,SANE_VALUE_SCAN_MODE_HALFTONE)==0) { /* Can we do any post processing in halftone? Needs testing to see what's possible */ if (scanner->val[OPT_BIT_DEPTH].w != 1) { DBG (DBG_info_sane, "Option %s = %d ignored in halftone mode (will use 1)\n", scanner->opt[OPT_BIT_DEPTH].name, scanner->val[OPT_BIT_DEPTH].w); } if (!scanner->val[OPT_FAST_INFRARED].b) { DBG (DBG_info_sane, "Option %s = %d ignored in halftone mode (irrelevant)\n", scanner->opt[OPT_FAST_INFRARED].name, scanner->val[OPT_FAST_INFRARED].b); } if (!scanner->val[OPT_CORRECT_SHADING].b) { DBG (DBG_info_sane, "Option %s = %d ignored in halftone mode (irrelevant)\n", scanner->opt[OPT_CORRECT_SHADING].name, scanner->val[OPT_CORRECT_SHADING].b); } if (!scanner->val[OPT_CORRECT_INFRARED].b) { DBG (DBG_info_sane, "Option %s = %d ignored in halftone mode (irrelevant)\n", scanner->opt[OPT_CORRECT_INFRARED].name, scanner->val[OPT_CORRECT_INFRARED].b); } if (scanner->val[OPT_CLEAN_IMAGE].b) { DBG (DBG_info_sane, "Option %s = %d ignored in halftone mode (irrelevant)\n", scanner->opt[OPT_CLEAN_IMAGE].name, scanner->val[OPT_CLEAN_IMAGE].b); } if (scanner->val[OPT_SMOOTH_IMAGE].w != 0) { DBG (DBG_info_sane, "Option %s = %d ignored in halftone mode (irrelevant)\n", scanner->opt[OPT_SMOOTH_IMAGE].name, scanner->val[OPT_SMOOTH_IMAGE].w); } if (strcmp(scanner->val[OPT_CROP_IMAGE].s, scanner->device->crop_sw_list[0]) != 0) { DBG (DBG_info_sane, "Option %s = %s ignored in halftone mode (irrelevant)\n", scanner->opt[OPT_CROP_IMAGE].name, scanner->val[OPT_CROP_IMAGE].s); } if (scanner->val[OPT_TRANSFORM_TO_SRGB].b) { DBG (DBG_info_sane, "Option %s = %d ignored in halftone mode (irrelevant)\n", scanner->opt[OPT_TRANSFORM_TO_SRGB].name, scanner->val[OPT_TRANSFORM_TO_SRGB].w); } } else if (strcmp(scanner->val[OPT_MODE].s,SANE_VALUE_SCAN_MODE_GRAY)==0) { /* Can we do any post processing in gray mode? */ /* Can we obtain a single color channel in this mode? How? */ /* Is this just RGB with luminance trasformation? */ /* Needs testing to see what's possible */ /* Only do 8 or 16 bit scans */ if (scanner->val[OPT_BIT_DEPTH].w == 1) { DBG (DBG_info_sane, "Option %s = %d ignored in gray mode (will use 8)\n", scanner->opt[OPT_BIT_DEPTH].name, scanner->val[OPT_BIT_DEPTH].w); } if (!scanner->val[OPT_FAST_INFRARED].b) { DBG (DBG_info_sane, "Option %s = %d ignored in gray mode (irrelevant)\n", scanner->opt[OPT_FAST_INFRARED].name, scanner->val[OPT_FAST_INFRARED].b); } if (!scanner->val[OPT_CORRECT_INFRARED].b) { DBG (DBG_info_sane, "Option %s = %d ignored in gray mode (irrelevant)\n", scanner->opt[OPT_CORRECT_INFRARED].name, scanner->val[OPT_CORRECT_INFRARED].b); } if (scanner->val[OPT_CLEAN_IMAGE].b) { DBG (DBG_info_sane, "Option %s = %d ignored in gray mode (irrelevant)\n", scanner->opt[OPT_CLEAN_IMAGE].name, scanner->val[OPT_CLEAN_IMAGE].b); } if (scanner->val[OPT_TRANSFORM_TO_SRGB].b) { DBG (DBG_info_sane, "Option %s = %d ignored in gray mode (irrelevant)\n", scanner->opt[OPT_TRANSFORM_TO_SRGB].name, scanner->val[OPT_TRANSFORM_TO_SRGB].w); } } else if (strcmp(scanner->val[OPT_MODE].s,SANE_VALUE_SCAN_MODE_COLOR)==0) { /* Some options require infrared data to be obtained, so all infrared options are relevant */ /* Only do 8 or 16 bit scans */ if (scanner->val[OPT_BIT_DEPTH].w == 1) { DBG (DBG_info_sane, "Option %s = %d ignored in color mode (will use 8)\n", scanner->opt[OPT_BIT_DEPTH].name, scanner->val[OPT_BIT_DEPTH].w); } } else if (strcmp(scanner->val[OPT_MODE].s,SANE_VALUE_SCAN_MODE_RGBI)==0) { /* Only do 8 or 16 bit scans */ if (scanner->val[OPT_BIT_DEPTH].w == 1) { DBG (DBG_info_sane, "Option %s = %d ignored in color mode (will use 8)\n", scanner->opt[OPT_BIT_DEPTH].name, scanner->val[OPT_BIT_DEPTH].w); } } return 1; } /** * Print options * * @param scanner */ void sanei_pieusb_print_options(struct Pieusb_Scanner *scanner) { int k; /* List current options and values */ DBG (DBG_info, "Num options = %d\n", scanner->val[OPT_NUM_OPTS].w); for (k = 1; k < scanner->val[OPT_NUM_OPTS].w; k++) { switch (scanner->opt[k].type) { case SANE_TYPE_BOOL: DBG(DBG_info," Option %d: %s = %d\n", k, scanner->opt[k].name, scanner->val[k].b); break; case SANE_TYPE_INT: DBG(DBG_info," Option %d: %s = %d\n", k, scanner->opt[k].name, scanner->val[k].w); break; case SANE_TYPE_FIXED: DBG(DBG_info," Option %d: %s = %f\n", k, scanner->opt[k].name, SANE_UNFIX (scanner->val[k].w)); break; case SANE_TYPE_STRING: DBG(DBG_info," Option %d: %s = %s\n", k, scanner->opt[k].name, scanner->val[k].s); break; case SANE_TYPE_GROUP: DBG(DBG_info," Option %d: %s = %s\n", k, scanner->opt[k].title, scanner->val[k].s); break; default: DBG(DBG_info," Option %d: %s unknown type %d\n", k, scanner->opt[k].name, scanner->opt[k].type); break; } } } /** * Calculate reference values for each pixel, line means and line maxima. * We have got 45 lines for all four colors and for each CCD pixel. * The reference value for each pixel is the 45-line average for that * pixel, for each color separately. * * @param scanner * @param buffer */ static void pieusb_calculate_shading(struct Pieusb_Scanner *scanner, SANE_Byte* buffer) { int k, m; SANE_Byte* p; SANE_Int ci, val; SANE_Int shading_width = scanner->device->shading_parameters[0].pixelsPerLine; SANE_Int shading_height = scanner->device->shading_parameters[0].nLines; /* Initialze all to 0 */ for (k = 0; k < SHADING_PARAMETERS_INFO_COUNT; k++) { scanner->shading_max[k] = 0; scanner->shading_mean[k] = 0; memset(scanner->shading_ref[k], 0, shading_width * sizeof (SANE_Int)); } /* Process data from buffer */ p = buffer; switch (scanner->mode.colorFormat) { case 0x01: /* Pixel */ /* Process pixel by pixel */ for (k = 0; k < shading_height; k++) { for (m = 0; m < shading_width; m++) { for (ci = 0; ci < SHADING_PARAMETERS_INFO_COUNT; ci++) { val = *(p) + *(p+1) * 256; scanner->shading_ref[ci][m] += val; scanner->shading_max[ci] = scanner->shading_max[ci] < val ? val : scanner->shading_max[ci]; p += 2; } } } break; case 0x04: /* Indexed */ /* Process each line in the sequence found in the buffer */ for (k = 0; k < shading_height*4; k++) { /* Save at right color */ switch (*p) { case 'R': ci = 0; break; case 'G': ci = 1; break; case 'B': ci = 2; break; case 'I': ci = 3; break; default: ci = -1; break; /* ignore line */ } /* Add scanned data to reference line and keep track of maximum */ if (ci != -1) { for (m = 0; m < shading_width; m++) { val = *(p+2+2*m) + *(p+2+2*m+1) * 256; scanner->shading_ref[ci][m] += val; scanner->shading_max[ci] = scanner->shading_max[ci] < val ? val : scanner->shading_max[ci]; /* DBG(DBG_error,"%02d Shading_ref[%d][%d] = %d\n",k,ci,m,scanner->shading_ref[ci][m]); */ } } /* Next line */ p += 2*shading_width+2; } break; default: DBG (DBG_error,"sane_start(): color format %d not implemented\n",scanner->mode.colorFormat); return; } /* Mean reference value needs division */ for (k = 0; k < SHADING_PARAMETERS_INFO_COUNT; k++) { for (m = 0; m < shading_width; m++) { scanner->shading_ref[k][m] = lround((double)scanner->shading_ref[k][m]/shading_height); /* DBG(DBG_error,"Shading_ref[%d][%d] = %d\n",k,m,scanner->shading_ref[k][m]); */ } } /* Overall means */ for (k = 0; k < SHADING_PARAMETERS_INFO_COUNT; k++) { for (m=0; mshading_mean[k] += scanner->shading_ref[k][m]; } scanner->shading_mean[k] = lround((double)scanner->shading_mean[k]/shading_width); DBG (DBG_error,"Shading_mean[%d] = %d\n",k,scanner->shading_mean[k]); } /* Set shading data present */ scanner->shading_data_present = SANE_TRUE; /* Export shading data as TIFF */ #ifdef CAN_DO_4_CHANNEL_TIFF if (scanner->val[OPT_SAVE_SHADINGDATA].b) { struct Pieusb_Read_Buffer shading; SANE_Byte* lboff = buffer; SANE_Int bpl = shading_width*2; SANE_Int n; buffer_create(&shading, shading_width, shading_height, 0x0F, 16); for (n=0; n<4*shading_height; n++) { if (buffer_put_single_color_line(&shading, *lboff, lboff+2, bpl) == 0) { break; } lboff += (bpl + 2); } FILE* fs = fopen("pieusb.shading", "w"); /* write_tiff_rgbi_header (fs, shading_width, shading_height, 16, 3600, NULL); */ fwrite(shading.data, 1, shading.image_size_bytes, fs); fclose(fs); buffer_delete(&shading); } #endif } /* * Set frame (from scanner options) */ SANE_Status sanei_pieusb_set_frame_from_options(Pieusb_Scanner * scanner) { double dpmm; struct Pieusb_Command_Status status; dpmm = (double) scanner->device->maximum_resolution / MM_PER_INCH; scanner->frame.x0 = SANE_UNFIX(scanner->val[OPT_TL_X].w) * dpmm; scanner->frame.y0 = SANE_UNFIX(scanner->val[OPT_TL_Y].w) * dpmm; scanner->frame.x1 = SANE_UNFIX(scanner->val[OPT_BR_X].w) * dpmm; scanner->frame.y1 = SANE_UNFIX(scanner->val[OPT_BR_Y].w) * dpmm; scanner->frame.index = 0x80; /* 0x80: value from cyberview */ sanei_pieusb_cmd_set_scan_frame (scanner->device_number, scanner->frame.index, &(scanner->frame), &status); DBG (DBG_info_sane, "sanei_pieusb_set_frame_from_options(): sanei_pieusb_cmd_set_scan_frame status %s\n", sane_strstatus (sanei_pieusb_convert_status (status.pieusb_status))); return status.pieusb_status; } /* * Set mode (from scanner options) */ SANE_Status sanei_pieusb_set_mode_from_options(Pieusb_Scanner * scanner) { struct Pieusb_Command_Status status; const char *mode; SANE_Status res; mode = scanner->val[OPT_MODE].s; if (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) { scanner->mode.passes = SCAN_FILTER_GREEN; /* G */ scanner->mode.colorFormat = SCAN_COLOR_FORMAT_PIXEL; } else if(strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) { scanner->mode.passes = SCAN_FILTER_GREEN; /* G */ scanner->mode.colorFormat = SCAN_COLOR_FORMAT_PIXEL; } else if(strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) { scanner->mode.passes = SCAN_FILTER_GREEN; /* G=gray; unable to get R & B & I to work */ scanner->mode.colorFormat = SCAN_COLOR_FORMAT_PIXEL; } else if(scanner->val[OPT_PREVIEW].b) { /* Catch preview here, otherwise next ifs get complicated */ scanner->mode.passes = SCAN_ONE_PASS_COLOR; scanner->mode.colorFormat = SCAN_COLOR_FORMAT_INDEX; /* pixel format might be an alternative */ } else if(strcmp (mode, SANE_VALUE_SCAN_MODE_RGBI) == 0) { scanner->mode.passes = SCAN_ONE_PASS_RGBI; scanner->mode.colorFormat = SCAN_COLOR_FORMAT_INDEX; } else if(strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0 && scanner->val[OPT_CLEAN_IMAGE].b) { scanner->mode.passes = SCAN_ONE_PASS_RGBI; /* Need infrared for cleaning */ scanner->mode.colorFormat = SCAN_COLOR_FORMAT_INDEX; } else { /* SANE_VALUE_SCAN_MODE_COLOR */ scanner->mode.passes = SCAN_ONE_PASS_COLOR; scanner->mode.colorFormat = SCAN_COLOR_FORMAT_INDEX; /* pixel format might be an alternative */ } /* Resolution */ if (scanner->val[OPT_PREVIEW].b) { scanner->mode.resolution = scanner->device->fast_preview_resolution; DBG (DBG_info_sane, "sanei_pieusb_set_mode_from_options(): resolution fast preview (%d)\n", scanner->mode.resolution); } else { scanner->mode.resolution = SANE_UNFIX (scanner->val[OPT_RESOLUTION].w); DBG (DBG_info_sane, "sanei_pieusb_set_mode_from_options(): resolution from option setting (%d)\n", scanner->mode.resolution); } /* Bit depth: exit on untested values */ switch (scanner->val[OPT_BIT_DEPTH].w) { case 1: scanner->mode.colorDepth = SCAN_COLOR_DEPTH_1; break; case 8: scanner->mode.colorDepth = SCAN_COLOR_DEPTH_8; break; case 16: scanner->mode.colorDepth = SCAN_COLOR_DEPTH_16; break; default: /* 4, 10 & 12 */ DBG (DBG_error, "sanei_pieusb_set_mode_from_options(): sanei_pieusb_cmd_set_scan_frame untested bit depth %d\n", scanner->val[OPT_BIT_DEPTH].w); return SANE_STATUS_INVAL; } scanner->mode.byteOrder = 0x01; /* 0x01 = Intel; only bit 0 used */ scanner->mode.sharpen = scanner->val[OPT_SHARPEN].b && !scanner->val[OPT_PREVIEW].b; scanner->mode.skipShadingAnalysis = !scanner->val[OPT_SHADING_ANALYSIS].b; scanner->mode.fastInfrared = scanner->val[OPT_FAST_INFRARED].b && !scanner->val[OPT_PREVIEW].b; if (strcmp (scanner->val[OPT_HALFTONE_PATTERN].s, "53lpi 45d ROUND") == 0) { scanner->mode.halftonePattern = 0; } else { /*TODO: the others */ scanner->mode.halftonePattern = 0; } scanner->mode.lineThreshold = SANE_UNFIX (scanner->val[OPT_THRESHOLD].w) / 100 * 0xFF; /* 0xFF = 100% */ sanei_pieusb_cmd_set_mode (scanner->device_number, &(scanner->mode), &status); res = sanei_pieusb_convert_status(status.pieusb_status); if (res == SANE_STATUS_GOOD) { res = sanei_pieusb_wait_ready (scanner, 0); } DBG (DBG_info_sane, "sanei_pieusb_set_mode_from_options(): sanei_pieusb_cmd_set_mode status %s\n", sane_strstatus(res)); return res; } /** * Set gains, exposure and offset, to: * - values default (pieusb_set_default_gain_offset) * - values set by options * - values set by auto-calibration procedure * - values determined from preceeding preview * * @param scanner * @return */ SANE_Status sanei_pieusb_set_gain_offset(Pieusb_Scanner * scanner, const char *calibration_mode) { struct Pieusb_Command_Status status; SANE_Status ret; double gain; DBG (DBG_info,"sanei_pieusb_set_gain_offset(): mode = %s\n", calibration_mode); if (strcmp (calibration_mode, SCAN_CALIBRATION_DEFAULT) == 0) { /* Default values */ DBG(DBG_info_sane,"sanei_pieusb_set_gain_offset(): get calibration data from defaults\n"); scanner->settings.exposureTime[0] = DEFAULT_EXPOSURE; scanner->settings.exposureTime[1] = DEFAULT_EXPOSURE; scanner->settings.exposureTime[2] = DEFAULT_EXPOSURE; scanner->settings.exposureTime[3] = DEFAULT_EXPOSURE; scanner->settings.offset[0] = DEFAULT_OFFSET; scanner->settings.offset[1] = DEFAULT_OFFSET; scanner->settings.offset[2] = DEFAULT_OFFSET; scanner->settings.offset[3] = DEFAULT_OFFSET; scanner->settings.gain[0] = DEFAULT_GAIN; scanner->settings.gain[1] = DEFAULT_GAIN; scanner->settings.gain[2] = DEFAULT_GAIN; scanner->settings.gain[3] = DEFAULT_GAIN; scanner->settings.light = DEFAULT_LIGHT; scanner->settings.extraEntries = DEFAULT_ADDITIONAL_ENTRIES; scanner->settings.doubleTimes = DEFAULT_DOUBLE_TIMES; status.pieusb_status = PIEUSB_STATUS_GOOD; } else if ((strcmp(calibration_mode, SCAN_CALIBRATION_PREVIEW) == 0) && scanner->preview_done) { /* If no preview data availble, do the auto-calibration. */ double dg, dgi; DBG (DBG_info, "sanei_pieusb_set_gain_offset(): get calibration data from preview. scanner->mode.passes %d\n", scanner->mode.passes); switch (scanner->mode.passes) { case SCAN_ONE_PASS_RGBI: dg = 3.00; dgi = ((double)scanner->settings.saturationLevel[0] / 65536) / ((double)scanner->preview_upper_bound[0] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; dgi = ((double)scanner->settings.saturationLevel[1] / 65536) / ((double)scanner->preview_upper_bound[1] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; dgi = ((double)scanner->settings.saturationLevel[2] / 65536) / ((double)scanner->preview_upper_bound[2] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; updateGain2(scanner, 0, dg); updateGain2(scanner, 1, dg); updateGain2(scanner, 2, dg); break; case SCAN_ONE_PASS_COLOR: dg = 3.00; dgi = ((double)scanner->settings.saturationLevel[0] / 65536) / ((double)scanner->preview_upper_bound[0] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; dgi = ((double)scanner->settings.saturationLevel[1] / 65536) / ((double)scanner->preview_upper_bound[1] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; dgi = ((double)scanner->settings.saturationLevel[2] / 65536) / ((double)scanner->preview_upper_bound[2] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; updateGain2(scanner, 0, dg); updateGain2(scanner, 1, dg); updateGain2(scanner, 2, dg); break; case SCAN_FILTER_BLUE: dg = 3.00; dgi = ((double)scanner->settings.saturationLevel[2] / 65536) / ((double)scanner->preview_upper_bound[2] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; updateGain2(scanner, 2, dg); break; case SCAN_FILTER_GREEN: dg = 3.00; dgi = ((double)scanner->settings.saturationLevel[1] / 65536) / ((double)scanner->preview_upper_bound[1] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; updateGain2(scanner, 1, dg); break; case SCAN_FILTER_RED: dg = 3.00; dgi = ((double)scanner->settings.saturationLevel[0] / 65536) / ((double)scanner->preview_upper_bound[0] / HISTOGRAM_SIZE); if (dgi < dg) dg = dgi; updateGain2(scanner, 0, dg); break; case SCAN_FILTER_NEUTRAL: break; } status.pieusb_status = PIEUSB_STATUS_GOOD; } else if (strcmp (calibration_mode, SCAN_CALIBRATION_OPTIONS) == 0) { DBG (DBG_info_sane, "sanei_pieusb_set_gain_offset(): get calibration data from options\n"); /* Exposure times */ scanner->settings.exposureTime[0] = scanner->val[OPT_SET_EXPOSURE_R].w; scanner->settings.exposureTime[1] = scanner->val[OPT_SET_EXPOSURE_G].w; scanner->settings.exposureTime[2] = scanner->val[OPT_SET_EXPOSURE_B].w; scanner->settings.exposureTime[3] = scanner->val[OPT_SET_EXPOSURE_I].w; /* Infrared */ /* Offsets */ scanner->settings.offset[0] = scanner->val[OPT_SET_OFFSET_R].w; scanner->settings.offset[1] = scanner->val[OPT_SET_OFFSET_G].w; scanner->settings.offset[2] = scanner->val[OPT_SET_OFFSET_B].w; scanner->settings.offset[3] = scanner->val[OPT_SET_OFFSET_I].w; /* Infrared */ /* Gains */ scanner->settings.gain[0] = scanner->val[OPT_SET_GAIN_R].w; scanner->settings.gain[1] = scanner->val[OPT_SET_GAIN_G].w; scanner->settings.gain[2] = scanner->val[OPT_SET_GAIN_B].w; scanner->settings.gain[3] = scanner->val[OPT_SET_GAIN_I].w; /* Infrared */ /* Light, extra entries and doubling */ scanner->settings.light = scanner->val[OPT_LIGHT].w; scanner->settings.extraEntries = DEFAULT_ADDITIONAL_ENTRIES; scanner->settings.doubleTimes = scanner->val[OPT_DOUBLE_TIMES].w; status.pieusb_status = PIEUSB_STATUS_GOOD; } else { /* SCAN_CALIBRATION_AUTO */ DBG (DBG_info_sane, "sanei_pieusb_set_gain_offset(): get calibration data from scanner\n"); sanei_pieusb_cmd_get_gain_offset (scanner->device_number, &scanner->settings, &status); } /* Check status */ if (status.pieusb_status == PIEUSB_STATUS_DEVICE_BUSY) { ret = sanei_pieusb_wait_ready (scanner, 0); if (ret != SANE_STATUS_GOOD) { DBG (DBG_error,"sanei_pieusb_set_gain_offset(): not ready after sanei_pieusb_cmd_get_gain_offset(): %d\n", ret); return ret; } } else if (status.pieusb_status != PIEUSB_STATUS_GOOD) { return SANE_STATUS_INVAL; } /* Adjust gain */ gain = 1.0; if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_03) == 0) { gain = 0.3; } else if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_05) == 0) { gain = 0.5; } else if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_08) == 0) { gain = 0.8; } else if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_10) == 0) { gain = 1.0; } else if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_12) == 0) { gain = 1.2; } else if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_16) == 0) { gain = 1.6; } else if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_19) == 0) { gain = 1.9; } else if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_24) == 0) { gain = 2.4; } else if (strcmp (scanner->val[OPT_GAIN_ADJUST].s, SCAN_GAIN_ADJUST_30) == 0) { gain = 3.0; } switch (scanner->mode.passes) { case SCAN_ONE_PASS_RGBI: case SCAN_ONE_PASS_COLOR: updateGain2 (scanner, 0, gain); updateGain2 (scanner, 1, gain); updateGain2 (scanner, 2, gain); /* Don't correct IR, hampers cleaning process... */ break; case SCAN_FILTER_INFRARED: updateGain2 (scanner, 3, gain); break; case SCAN_FILTER_BLUE: updateGain2 (scanner, 2, gain); break; case SCAN_FILTER_GREEN: updateGain2 (scanner, 1, gain); break; case SCAN_FILTER_RED: updateGain2 (scanner, 0, gain); break; case SCAN_FILTER_NEUTRAL: break; } /* Now set values for gain, offset and exposure */ sanei_pieusb_cmd_set_gain_offset (scanner->device_number, &(scanner->settings), &status); ret = sanei_pieusb_convert_status (status.pieusb_status); DBG (DBG_info_sane, "sanei_pieusb_set_gain_offset(): status %s\n", sane_strstatus (ret)); return ret; } /* * get shading data * must be called immediately after sanei_pieusb_set_gain_offset */ SANE_Status sanei_pieusb_get_shading_data(Pieusb_Scanner * scanner) { struct Pieusb_Command_Status status; SANE_Int shading_width; SANE_Int shading_height; SANE_Byte* buffer; SANE_Int lines; SANE_Int cols; SANE_Int size; SANE_Status res = SANE_STATUS_GOOD; DBG (DBG_info_sane, "sanei_pieusb_get_shading_data()\n"); shading_width = scanner->device->shading_parameters[0].pixelsPerLine; shading_height = scanner->device->shading_parameters[0].nLines; if (shading_height < 1) { DBG (DBG_error, "shading_height < 1\n"); return SANE_STATUS_INVAL; } switch (scanner->mode.colorFormat) { case SCAN_COLOR_FORMAT_PIXEL: /* Pixel */ lines = shading_height * 4; cols = 2 * shading_width; break; case SCAN_COLOR_FORMAT_INDEX: /* Indexed */ lines = shading_height * 4; cols = (2 * shading_width + 2); break; default: DBG (DBG_error, "sanei_pieusb_get_shading_data(): color format %d not implemented\n", scanner->mode.colorFormat); return SANE_STATUS_INVAL; } size = cols * lines; buffer = malloc (size); if (buffer == NULL) { return SANE_STATUS_NO_MEM; } sanei_pieusb_cmd_get_scanned_lines (scanner->device_number, buffer, 4, cols * 4, &status); if (status.pieusb_status == PIEUSB_STATUS_GOOD) { res = sanei_pieusb_wait_ready (scanner, 0); if (res == SANE_STATUS_GOOD) { sanei_pieusb_cmd_get_scanned_lines (scanner->device_number, buffer + cols*4, lines - 4, (lines - 4) * cols, &status); if (status.pieusb_status == PIEUSB_STATUS_GOOD) { pieusb_calculate_shading (scanner, buffer); } res = sanei_pieusb_convert_status (status.pieusb_status); } } else { res = sanei_pieusb_convert_status (status.pieusb_status); } free (buffer); return res; } /* * */ SANE_Status sanei_pieusb_get_ccd_mask(Pieusb_Scanner * scanner) { struct Pieusb_Command_Status status; DBG(DBG_info_proc, "sanei_pieusb_get_ccd_mask()\n"); sanei_pieusb_cmd_get_ccd_mask(scanner->device_number, scanner->ccd_mask, scanner->ccd_mask_size, &status); if (status.pieusb_status == PIEUSB_STATUS_GOOD) { /* Save CCD mask */ if (scanner->val[OPT_SAVE_CCDMASK].b) { FILE* fs = fopen ("pieusb.ccd", "w"); fwrite (scanner->ccd_mask, 1, scanner->ccd_mask_size, fs); fclose (fs); } } return sanei_pieusb_convert_status(status.pieusb_status); } /** * Read parameters from scanner * and initialize SANE parameters * * @param scanner * @return parameter_bytes for use in get_scan_data() */ SANE_Status sanei_pieusb_get_parameters(Pieusb_Scanner * scanner, SANE_Int *parameter_bytes) { struct Pieusb_Command_Status status; struct Pieusb_Scan_Parameters parameters; const char *mode; DBG (DBG_info_proc, "sanei_pieusb_get_parameters()\n"); sanei_pieusb_cmd_get_parameters (scanner->device_number, ¶meters, &status); if (status.pieusb_status != PIEUSB_STATUS_GOOD) { return sanei_pieusb_convert_status (status.pieusb_status); } *parameter_bytes = parameters.bytes; /* Use response from sanei_pieusb_cmd_get_parameters() for initialization of SANE parameters. * Note the weird values of the bytes-field: this is because of the colorFormat * setting in sanei_pieusb_cmd_set_mode(). The single-color modes all use the pixel format, * which makes sanei_pieusb_cmd_get_parameters() return a full color line although just * one color actually contains data. For the index format, the bytes field * gives the size of a single color line. */ mode = scanner->val[OPT_MODE].s; if (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) { scanner->scan_parameters.format = SANE_FRAME_GRAY; scanner->scan_parameters.depth = 1; scanner->scan_parameters.bytes_per_line = parameters.bytes/3; } else if (strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) { scanner->scan_parameters.format = SANE_FRAME_GRAY; scanner->scan_parameters.depth = 1; scanner->scan_parameters.bytes_per_line = parameters.bytes/3; } else if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) { scanner->scan_parameters.format = SANE_FRAME_GRAY; scanner->scan_parameters.depth = scanner->val[OPT_BIT_DEPTH].w; scanner->scan_parameters.bytes_per_line = parameters.bytes/3; } else if (strcmp (mode, SANE_VALUE_SCAN_MODE_RGBI) == 0) { scanner->scan_parameters.format = SANE_FRAME_RGB; /* was: SANE_FRAME_RGBI */ scanner->scan_parameters.depth = scanner->val[OPT_BIT_DEPTH].w; scanner->scan_parameters.bytes_per_line = 4*parameters.bytes; } else { /* SANE_VALUE_SCAN_MODE_COLOR, with and without option clean image set */ scanner->scan_parameters.format = SANE_FRAME_RGB; scanner->scan_parameters.depth = scanner->val[OPT_BIT_DEPTH].w; scanner->scan_parameters.bytes_per_line = 3*parameters.bytes; } scanner->scan_parameters.lines = parameters.lines; scanner->scan_parameters.pixels_per_line = parameters.width; scanner->scan_parameters.last_frame = SANE_TRUE; DBG (DBG_info_sane,"sanei_pieusb_get_parameters(): mode '%s'\n", mode); DBG (DBG_info_sane," format = %d\n", scanner->scan_parameters.format); DBG (DBG_info_sane," depth = %d\n", scanner->scan_parameters.depth); DBG (DBG_info_sane," bytes_per_line = %d\n", scanner->scan_parameters.bytes_per_line); DBG (DBG_info_sane," lines = %d\n", scanner->scan_parameters.lines); DBG (DBG_info_sane," pixels_per_line = %d\n", scanner->scan_parameters.pixels_per_line); DBG (DBG_info_sane," last_frame = %d\n", scanner->scan_parameters.last_frame); return SANE_STATUS_GOOD; } SANE_Status sanei_pieusb_get_scan_data(Pieusb_Scanner * scanner, SANE_Int parameter_bytes) { struct Pieusb_Command_Status status; SANE_Parameters *parameters = &scanner->scan_parameters; SANE_Int lines_to_read, lines_remaining; SANE_Int ppl, bpl; SANE_Byte *linebuf, *lboff; SANE_Bool compress; int n, k, i; switch (scanner->mode.colorFormat) { case SCAN_COLOR_FORMAT_PIXEL: /* Pixel */ lines_to_read = scanner->buffer.height; break; case SCAN_COLOR_FORMAT_INDEX: /* Indexed */ lines_to_read = scanner->buffer.colors * scanner->buffer.height; break; default: DBG(DBG_error, "sanei_pieusb_get_scan_data(): color format %d not implemented\n",scanner->mode.colorFormat); return SANE_STATUS_INVAL; } lines_remaining = lines_to_read; DBG (DBG_info_proc, "sanei_pieusb_get_scan_data(colorFormat %d), lines_to_read %d, bytes %d\n", scanner->mode.colorFormat, lines_to_read, parameter_bytes); /* fdraw = open("/tmp/pieusb.raw", O_WRONLY | O_CREAT | O_TRUNC, (mode_t)0600); if (fdraw == -1) { perror("error opening raw image buffer file"); } */ while (lines_remaining > 0) { SANE_Int lines; /* Read lines */ /* The amount of bytes_per_line varies with color format setting; only 'pixel' and 'index' implemented */ ppl = parameters->pixels_per_line; switch (scanner->mode.colorFormat) { case SCAN_COLOR_FORMAT_PIXEL: /* Pixel */ bpl = parameter_bytes; break; case SCAN_COLOR_FORMAT_INDEX: /* Indexed */ bpl = parameter_bytes + 2; /* Index bytes! */ break; default: DBG(DBG_error, "sanei_pieusb_get_scan_data(): color format %d not implemented\n", scanner->mode.colorFormat); return SANE_STATUS_INVAL; } lines = (lines_remaining < 256) ? lines_remaining : 255; DBG(DBG_info_sane, "sanei_pieusb_get_scan_data(): reading lines: now %d, bytes per line = %d\n", lines, bpl); linebuf = malloc(lines * bpl); sanei_pieusb_cmd_get_scanned_lines(scanner->device_number, linebuf, lines, lines * bpl, &status); if (status.pieusb_status != PIEUSB_STATUS_GOOD ) { /* Error, return */ free(linebuf); return SANE_STATUS_INVAL; } /* Save raw data */ /* if (fdraw != -1) { wcnt = write(fdraw,linebuf,parameters.lines*bpl); DBG(DBG_info_sane,"Raw written %d\n",wcnt); } */ /* Copy into official buffer * Sometimes the scanner returns too many lines. Take care not to * overflow the buffer. */ lboff = linebuf; switch (scanner->mode.colorFormat) { case SCAN_COLOR_FORMAT_PIXEL: /* The scanner may return lines with 3 colors even though only * one color is actually scanned. Detect this situation and * eliminate the excess samples from the line buffer before * handing it to buffer_put_full_color_line(). */ compress = SANE_FALSE; if (scanner->buffer.colors == 1 && (bpl * scanner->buffer.packing_density / ppl) == (3 * scanner->buffer.packet_size_bytes)) { compress = SANE_TRUE; } for (n = 0; n < lines; n++) { if (compress) { /* Move samples to fill up all unused locations */ int ps = scanner->buffer.packet_size_bytes; for (k = 0; k < scanner->buffer.line_size_packets; k++) { for (i = 0; i < ps; i++) { lboff[ps*k+i] = lboff[3*ps*k+i]; } } } if (sanei_pieusb_buffer_put_full_color_line(&scanner->buffer, lboff, bpl/3) == 0) { /* Error, return */ return SANE_STATUS_INVAL; } lboff += bpl; } break; case SCAN_COLOR_FORMAT_INDEX: /* Indexed data */ for (n = 0; n < lines; n++) { if (sanei_pieusb_buffer_put_single_color_line(&scanner->buffer, *lboff, lboff+2, bpl-2) == 0) { /* Error, return */ return SANE_STATUS_INVAL; } lboff += bpl; } break; default: DBG(DBG_error, "sanei_pieusb_get_scan_data(): store color format %d not implemented\n", scanner->mode.colorFormat); free(linebuf); return SANE_STATUS_INVAL; } free(linebuf); lines_remaining -= lines; /* Note: excess discarded */ DBG(DBG_info_sane, "sanei_pieusb_get_scan_data(): reading lines: remaining %d\n", lines_remaining); } /* if (fdraw != -1) close(fdraw); */ return SANE_STATUS_GOOD; } /** * Wait for scanner to get ready * * loop of test_ready/read_state * * @param scanner * @param device_number, used if scanner == NULL * @return SANE_Status */ SANE_Status sanei_pieusb_wait_ready(Pieusb_Scanner * scanner, SANE_Int device_number) { struct Pieusb_Command_Status status; struct Pieusb_Scanner_State state; time_t start, elapsed; DBG (DBG_info_proc, "sanei_pieusb_wait_ready()\n"); start = time(NULL); if (scanner) device_number = scanner->device_number; for(;;) { sanei_pieusb_cmd_test_unit_ready(device_number, &status); DBG (DBG_info_proc, "-> sanei_pieusb_cmd_test_unit_ready: %d\n", status.pieusb_status); if (status.pieusb_status == PIEUSB_STATUS_GOOD) break; if (status.pieusb_status == PIEUSB_STATUS_IO_ERROR) break; sanei_pieusb_cmd_read_state(device_number, &state, &status); DBG (DBG_info_proc, "-> sanei_pieusb_cmd_read_state: %d\n", status.pieusb_status); if (status.pieusb_status != PIEUSB_STATUS_DEVICE_BUSY) break; sleep(2); elapsed = time(NULL) - start; if (elapsed > 120) { /* 2 minute overall timeout */ DBG (DBG_error, "scanner not ready after 2 minutes\n"); break; } if (elapsed % 2) { DBG (DBG_info, "still waiting for scanner to get ready\n"); } } return sanei_pieusb_convert_status(status.pieusb_status); } SANE_Status sanei_pieusb_analyze_preview(Pieusb_Scanner * scanner) { int k, n; SANE_Parameters params; SANE_Int N; double *norm_histo; double level; DBG(DBG_info, "sanei_pieusb_analyze_preview(): saving preview data\n"); /* Settings */ scanner->preview_done = SANE_TRUE; for (k = 0; k < 4; k++) { scanner->preview_exposure[k] = scanner->settings.exposureTime[k]; scanner->preview_gain[k] = scanner->settings.gain[k]; scanner->preview_offset[k] = scanner->settings.offset[k]; } /* Analyze color planes */ N = scanner->buffer.width * scanner->buffer.height; params.format = SANE_FRAME_GRAY; params.depth = scanner->buffer.depth; params.pixels_per_line = scanner->buffer.width; params.lines = scanner->buffer.height; for (k = 0; k < scanner->buffer.colors; k++) { /* Create histogram for color k */ sanei_ir_create_norm_histogram (¶ms, scanner->buffer.data + k * N, &norm_histo); /* Find 1% and 99% limits */ level = 0; for (n =0; n < HISTOGRAM_SIZE; n++) { level += norm_histo[n]; if (level < 0.01) { scanner->preview_lower_bound[k] = n; } if (level < 0.99) { scanner->preview_upper_bound[k] = n; } } DBG(DBG_info,"sanei_pieusb_analyze_preview(): 1%%-99%% levels for color %d: %d - %d\n", k, scanner->preview_lower_bound[k], scanner->preview_upper_bound[k]); } /* Disable remaining color planes */ for (k = scanner->buffer.colors; k < 4; k++) { scanner->preview_lower_bound[k] = 0; scanner->preview_upper_bound[k] = 0; } return SANE_STATUS_GOOD; } /** * Return actual gain at given gain setting * * @param gain Gain setting (0 - 63) * @return */ static double getGain(int gain) { int k; /* Actually an error, but don't be picky */ if (gain <= 0) { return gains[0]; } /* A gain > 63 is also an error, but don't be picky */ if (gain >= 60) { return (gain-55)*(gains[12]-gains[11])/5 + gains[11]; } /* Interpolate other values */ k = gain/5; /* index of array value just below given gain */ return (gain-5*k)*(gains[k+1]-gains[k])/5 + gains[k]; } static int getGainSetting(double gain) { int k, m; /* Out of bounds */ if (gain < 1.0) { return 0; } if (gain >= gains[12]) { m = 60 + lround((gain-gains[11])/(gains[12]-gains[11])*5); if (m > 63) m = 63; return m; } /* Interpolate the rest */ m = 0; for (k = 0; k <= 11; k++) { if (gains[k] <= gain && gain < gains[k+1]) { m = 5*k + lround((gain-gains[k])/(gains[k+1]-gains[k])*5); } } return m; } /** * Modify gain and exposure times in order to make maximal use of the scan depth. * Each color treated separately, infrared excluded. * * This may be too aggressive => leads to a noisy whitish border instead of the orange. * In a couuple of tries, gain was set to values of 60 and above, which introduces * the noise? * The whitish border is logical since the brightest parts of the negative, the * unexposed borders, are amplified to values near CCD saturation, which is white. * Maybe a uniform gain increase for each color is more appropriate? Somewhere * between 2.5 and 3 seems worthwhile trying, see updateGain2(). * switch (scanner->mode.passes) { case SCAN_ONE_PASS_RGBI: updateGain(scanner,0); updateGain(scanner,1); updateGain(scanner,2); updateGain(scanner,3); break; case SCAN_ONE_PASS_COLOR: updateGain(scanner,0); updateGain(scanner,1); updateGain(scanner,2); break; case SCAN_FILTER_INFRARED: updateGain(scanner,3); break; case SCAN_FILTER_BLUE: updateGain(scanner,2); break; case SCAN_FILTER_GREEN: updateGain(scanner,1); break; case SCAN_FILTER_RED: updateGain(scanner,0); break; case SCAN_FILTER_NEUTRAL: break; } * @param scanner */ /* static void updateGain(Pieusb_Scanner *scanner, int color_index) { double g, dg; DBG(DBG_info_sane,"updateGain(): color %d preview used G=%d Exp=%d\n", color_index, scanner->preview_gain[color_index], scanner->preview_exposure[color_index]); // Additional gain to obtain dg = ((double)scanner->settings.saturationLevel[color_index] / 65536) / ((double)scanner->preview_upper_bound[color_index] / HISTOGRAM_SIZE); DBG(DBG_info_sane,"updateGain(): additional gain %f\n", dg); // Achieve this by modifying gain and exposure // Gain used for preview g = getGain(scanner->preview_gain[color_index]); DBG(DBG_info_sane,"updateGain(): preview had gain %d => %f\n",scanner->preview_gain[color_index],g); // Look up new gain setting g*sqrt(dg) DBG(DBG_info_sane,"updateGain(): optimized gain * %f = %f\n",sqrt(dg),sqrt(dg)*g); scanner->settings.gain[color_index] = getGainSetting(g*sqrt(dg)); DBG(DBG_info_sane,"updateGain(): optimized gain setting %d => %f\n",scanner->settings.gain[color_index],getGain(scanner->settings.gain[color_index])); // Exposure change is straightforward DBG(DBG_info_sane,"updateGain(): remains for exposure %f\n",dg/(getGain(scanner->settings.gain[color_index])/g)); scanner->settings.exposureTime[color_index] = lround( g / getGain(scanner->settings.gain[color_index]) * dg * scanner->preview_exposure[color_index] ); DBG(DBG_info_sane,"updateGain(): new setting G=%d Exp=%d\n", scanner->settings.gain[color_index], scanner->settings.exposureTime[color_index]); } */ static void updateGain2(Pieusb_Scanner *scanner, int color_index, double gain_increase) { double g; DBG(DBG_info,"updateGain2(): color %d preview used G=%d Exp=%d\n", color_index, scanner->settings.gain[color_index], scanner->settings.exposureTime[color_index]); /* Additional gain to obtain */ DBG(DBG_info,"updateGain2(): additional gain %f\n", gain_increase); /* Achieve this by modifying gain and exposure */ /* Gain used for preview */ g = getGain(scanner->settings.gain[color_index]); DBG(DBG_info,"updateGain2(): preview had gain %d => %f\n", scanner->settings.gain[color_index], g); /* Look up new gain setting g*sqrt(dg) */ DBG(DBG_info,"updateGain2(): optimized gain * %f = %f\n", sqrt(gain_increase), sqrt(gain_increase) * g); scanner->settings.gain[color_index] = getGainSetting(g * sqrt(gain_increase)); DBG(DBG_info,"updateGain2(): optimized gain setting %d => %f\n", scanner->settings.gain[color_index], getGain(scanner->settings.gain[color_index])); /* Exposure change is straightforward */ DBG(DBG_info,"updateGain2(): remains for exposure %f\n", gain_increase / (getGain(scanner->settings.gain[color_index]) / g)); scanner->settings.exposureTime[color_index] = lround( g / getGain(scanner->settings.gain[color_index]) * gain_increase * scanner->settings.exposureTime[color_index] ); DBG(DBG_info,"updateGain2(): new setting G=%d Exp=%d\n", scanner->settings.gain[color_index], scanner->settings.exposureTime[color_index]); } sane-backends-1.0.29/backend/coolscan-scsidef.h0000666000000000000000000007027313615534521016171 00000000000000 /* ------------------------------------------------------------------------- */ /* coolscan-scsidef.h: scsi-definiton header file for COOLSCAN scanner driver. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* ------------------------------------------------------------------------- */ #ifndef COOLSCAN_SCSIDEF_H #define COOLSCAN_SCSIDEF_H /* ========================================================================= */ /* I'm using functions derived from Eric Youngdale's scsiinfo * program here for dealing with parts of SCSI commands. */ static inline void setbitfield (unsigned char *pageaddr, int mask, int shift, int val) \ { *pageaddr = (*pageaddr & ~(mask << shift)) | ((val & mask) << shift); } /* ------------------------------------------------------------------------- */ static inline void resetbitfield (unsigned char *pageaddr, int mask, int shift, int val) \ { *pageaddr = (*pageaddr & ~(mask << shift)) | (((!val) & mask) << shift); } /* ------------------------------------------------------------------------- */ static inline int getbitfield (unsigned char *pageaddr, int mask, int shift) \ { return ((*pageaddr >> shift) & mask); } /* ------------------------------------------------------------------------- */ static inline int getnbyte (unsigned char *pnt, int nbytes) \ { unsigned int result = 0; int i; #ifdef DEBUG assert (nbytes < 5); #endif for (i = 0; i < nbytes; i++) result = (result << 8) | (pnt[i] & 0xff); return result; } /* ------------------------------------------------------------------------- */ static inline void putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) \ { int i; #ifdef DEBUG assert (nbytes < 5); #endif for (i = nbytes - 1; i >= 0; i--) \ { pnt[i] = value & 0xff; value = value >> 8; } } /* ==================================================================== */ /* Not all of these are defined in scsi.h, so we'll make sure * we agree about them here... */ #undef WRITE_BUFFER /* correct size write_buffer for scanner */ #define TEST_UNIT_READY 0x00 #define REQUEST_SENSE 0x03 #define INQUIRY 0x12 #define MODE_SELECT 0x15 #define RESERVE_UNIT 0x16 #define RELEASE_UNIT 0x17 #define MODE_SENSE 0x1a #define SCAN 0x1b #define SEND_DIAGNOSTIC 0x1d #define SET_WINDOW 0x24 #define GET_WINDOW 0x25 #define READ 0x28 #define SEND 0x2a #define OBJECT_POSITION 0x31 #define WRITE_BUFFER 0x3b #define READ_BUFFER 0x3c #define SABORT 0xc0 #define COMMAND_C1 0xc1 #define AUTO_FOCUS 0xc2 #define UNIT_MOVE 0xe0 /* ==================================================================== */ /* wdb_len if nothing is set by inquiry */ #define STD_WDB_LEN 0x28 /* ==================================================================== */ /* SCSI commands */ typedef struct { unsigned char *cmd; int size; } scsiblk; /* ==================================================================== */ #define set_inquiry_return_size(icb,val) icb[0x04]=val static unsigned char inquiryC[] = {INQUIRY, 0x00, 0x00, 0x00, 0x1f, 0x00}; static scsiblk inquiry = {inquiryC, sizeof (inquiryC)}; #define get_inquiry_periph_qual(in) getbitfield(in, 0x07, 5) #define IN_periph_qual_lun 0x00 #define IN_periph_qual_nolun 0x03 #define get_inquiry_periph_devtype(in) getbitfield(in, 0x1f, 0) #define IN_periph_devtype_scanner 0x06 #define IN_periph_devtype_unknown 0x1f #define get_inquiry_response_format(in) getbitfield(in + 0x03, 0x07, 0) #define IN_recognized 0x02 #define get_inquiry_additional_length(in) in[0x04] #define get_inquiry_length(in) in[0x03] #define set_inquiry_length(out,n) out[0x04]=n-5 #define get_inquiry_vendor(in, buf) strncpy(buf, in + 0x08, 0x08) #define get_inquiry_product(in, buf) strncpy(buf, in + 0x10, 0x010) #define get_inquiry_version(in, buf) strncpy(buf, in + 0x20, 0x04) /* ==================================================================== */ /* static unsigned char mode_selectC[] = { MODE_SELECT, 0x10, 0x00, 0x00, 0x00, 0x00 static scsiblk mode_select = { mode_selectC,sizeof(mode_selectC) }; */ /* ==================================================================== */ static unsigned char test_unit_readyC[] = { TEST_UNIT_READY, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk test_unit_ready = {test_unit_readyC, sizeof (test_unit_readyC)}; /* ==================================================================== */ static unsigned char reserve_unitC[] = { RESERVE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk reserve_unit = {reserve_unitC, sizeof (reserve_unitC)}; /* ==================================================================== */ static unsigned char release_unitC[] = { RELEASE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk release_unit = {release_unitC, sizeof (release_unitC)}; /* ==================================================================== */ static unsigned char mode_senseC[] = { MODE_SENSE, 0x18, 0x03, 0x00, 0x00, 0x00, /* PF set, page type 03 */ }; #define set_MS_DBD(b, val) setbitfield(b, 0x01, 3, (val?1:0)) #define set_MS_len(b, val) putnbyte(b+0x04, val, 1) #define get_MS_MUD(b) getnbyte(b+(0x04+((int)*(b+0x3)))+0x4,2) static scsiblk mode_sense = {mode_senseC, sizeof (mode_senseC)}; /* ==================================================================== */ static unsigned char set_windowC[] = { SET_WINDOW, 0x00, /* opcode, lun */ 0x00, 0x00, 0x00, 0x00, /* reserved */ 0x00, 0x00, 0x00, /* transfer length; needs to be set */ 0x00, /* control byte */ }; #define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) static scsiblk set_window = {set_windowC, sizeof (set_windowC)}; /* ==================================================================== */ static unsigned char get_windowC[] = { GET_WINDOW, 0x01, /* opcode, lun, misc (should be 0x01? */ 0x00, 0x00, 0x00, /* reserved */ 0x00, /* Window identifier */ 0x00, 0x00, 0x00, /* transfer length; needs to be get */ 0x00, /* control byte */ }; #define set_GW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) #define set_WindowID_wid(sb, val) sb[5] = val static scsiblk get_window = {get_windowC, sizeof (get_windowC)}; /* ==================================================================== */ /* We use the same structure for both SET WINDOW and GET WINDOW. */ static unsigned char window_parameter_data_blockC[] = { 0x00, 0x00, /* window data length, in case of get, or 0 in case of set */ 0x00, 0x00, 0x00, 0x00, /* reserved */ 0x00, 0x00, /* Window Descriptor Length, value must be set by SHORT_WDB define */ }; #define set_WPDB_wdblen(sb, len) putnbyte(sb + 0x06, len, 2) static scsiblk window_parameter_data_block = { window_parameter_data_blockC, sizeof (window_parameter_data_blockC) }; /* ==================================================================== */ static unsigned char window_descriptor_blockC[] = { /* Any field maked with 'R' (e.g. R0x55) indicate a filed provided for * development. In normal operation, 0 is set here. If any other value is set, * operationis not guaranteed! */ #define max_WDB_size 0xff #define used_WDB_size 0x75 0x00, /* 0x00 */ /* Window Identifier */ #define set_WD_wid(sb, val) sb[0] = val #define WD_wid_all 0x00 /* Only one supported */ 0x00, /* 0x01 */ /* reserved, AUTO */ #define set_WD_auto(sb, val) setbitfield(sb + 0x01, 1, 0, val) #define get_WD_auto(sb) getbitfield(sb + 0x01, 1, 0) 0x00, 0x00, /* 0x02 */ /* X Resolution in dpi */ #define set_WD_Xres(sb, val) putnbyte(sb + 0x02, val, 2) #define get_WD_Xres(sb) getnbyte(sb + 0x02, 2) 0x00, 0x00, /* 0x04 */ /* Y Resolution in dpi */ #define set_WD_Yres(sb, val) putnbyte(sb + 0x04, val, 2) #define get_WD_Yres(sb) getnbyte(sb + 0x04, 2) 0x00, 0x00, 0x00, 0x00, /* 0x06 */ /* Upper Left X in 1200|2700pt/inch */ #define set_WD_ULX(sb, val) putnbyte(sb + 0x06, val, 4) #define get_WD_ULX(sb) getnbyte(sb + 0x06, 4) 0x00, 0x00, 0x00, 0x00, /* 0x0a */ /* Upper Left Y in 1200|2700pt/inch */ #define set_WD_ULY(sb, val) putnbyte(sb + 0x0a, val, 4) #define get_WD_ULY(sb) getnbyte(sb + 0x0a, 4) 0x00, 0x00, 0x00, 0x00, /* 0x0e */ /* Width 1200pt/inch */ #define set_WD_width(sb, val) putnbyte(sb + 0x0e, val, 4) #define get_WD_width(sb) getnbyte(sb + 0x0e, 4) 0x00, 0x00, 0x00, 0x00, /* 0x12 */ /* Length 1200pt/inch */ #define set_WD_length(sb, val) putnbyte(sb + 0x12, val, 4) #define get_WD_length(sb) getnbyte(sb + 0x12, 4) 0x00, /* 0x16 */ /* Brightness */ #define set_WD_brightness(sb, val) sb[0x16] = val #define get_WD_brightness(sb) sb[0x16] 0x00, /* 0x17 */ /* Reserved */ 0x00, /* 0x18 */ /* Contrast */ #define set_WD_contrast(sb, val) sb[0x18] = val #define get_WD_contrast(sb) sb[0x18] 0x05, /* 0x19 */ /* Image Mode */ #define set_WD_composition(sb, val) sb[0x19] = val #define get_WD_composition(sb) sb[0x19] #define WD_comp_grey 0x02 #define WD_comp_gray 0x02 #define WD_comp_rgb_full 0x05 0x08, /* 0x1a */ /* Bits/Pixel */ #define set_WD_bitsperpixel(sb, val) sb[0x1a] = val #define get_WD_bitsperpixel(sb) sb[0x1a] #define WD_bits_8 0x08 0, 0, 0, 0, 0, /* 0x1b */ /* Reserved */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28 */ /* X-axis pixel count (1-2592 */ #define get_WD_xpixels(sb) getnbyte(sb + 0x28, 4) 0, 0, 0, 0, /* 0x2c */ /* Y-axis pixel count (1-3888) */ #define get_WD_ypixels(sb) getnbyte(sb + 0x2c, 4) 0x01, /* 0x30 */ /* Reserved, negative/positive * reserved, drop-out color * (Green) */ #define set_WD_negative(sb, val) setbitfield(sb + 0x30, 0x1, 4, (val?1:0)) #define get_WD_negative(sb) getbitfield(sb + 0x30, 0x1, 4) #define WD_Negative 0x01 #define WD_Positive 0x00 #define set_WD_dropoutcolor(sb, val) setbitfield(sb + 0x30, 0x3, 0, val) #define get_WD_dropoutcolor(sb) getbitfield(sb + 0x30, 0x3, 0) #define WD_Dropout_Red 0x00 #define WD_Dropout_Green 0x01 #define WD_Dropout_Blue 0x02 0x00, /* 0x31 */ /* scan mode */ #define set_WD_scanmode(sb, val) setbitfield(sb + 0x31, 0x3, 4, val) #define get_WD_scanmode(sb) getbitfield(sb + 0x31, 0x3, 4) #define WD_Scan 0x00 #define WD_Prescan 0x01 0x40, /* 0x32 */ /* Data transfer mode */ #define set_WD_transfermode(sb, val) setbitfield(sb + 0x32, 0x3, 6, val) #define get_WD_transfermode(sb) getbitfield(sb + 0x32, 0x3, 6) #define WD_LineSequence 0x2 #define WD_DotSequence 0x1 0x02, /* 0x33 */ /* Gamma selection */ #define set_WD_gammaselection(sb, val) putnbyte(sb + 0x33, val, 1) #define get_WD_gammaselection(sb) getnbyte(sb + 0x33, 1) #define WD_Linear 0x2 #define WD_Monitor 0x3 0, /* 0x34 */ /* Reserved */ 0x40, /* 0x35 */ /* Reserved, shading, analog gamma, averaging */ #define set_WD_shading(sb, val) setbitfield(sb + 0x35, 0x1, 6, val) #define get_WD_shading(sb) getbitfield(sb + 0x35, 0x1, 6) #define WD_Shading_ON 0x0 #define WD_Shading_OFF 0x1 #define set_WD_analog_gamma_R(sb, val) setbitfield(sb + 0x35, 0x1, 5, val) #define set_WD_analog_gamma_G(sb, val) setbitfield(sb + 0x35, 0x1, 4, val) #define set_WD_analog_gamma_B(sb, val) setbitfield(sb + 0x35, 0x1, 3, val) #define get_WD_analog_gamma_R(sb) getbitfield(sb + 0x35, 0x1, 5) #define get_WD_analog_gamma_G(sb) getbitfield(sb + 0x35, 0x1, 4) #define get_WD_analog_gamma_B(sb) getbitfield(sb + 0x35, 0x1, 3) #define WD_Analog_Gamma_ON 0x0 #define WD_Analog_Gamma_OFF 0x1 #define set_WD_averaging(sb, val) setbitfield(sb + 0x35, 0x7, 0, (val?7:0)) #define get_WD_averaging(sb) getbitfield(sb + 0x35, 0x7, 0) #define WD_Averaging_ON 0x0 #define WD_Averaging_OFF 0x1 0, /* 0x36 */ /* reserved */ 0, /* 0x37 */ /* R brightness */ #define set_WD_brightness_R(b, val) putnbyte(b + 0x37, val, 1) #define get_WD_brightness_R(b) getnbyte(b + 0x37, 1) 0, /* 0x38 */ /* G brightness */ #define set_WD_brightness_G(b, val) putnbyte(b + 0x38, val, 1) #define get_WD_brightness_G(b) getnbyte(b + 0x38, 1) 0, /* 0x39 */ /* B brightness */ #define set_WD_brightness_B(b, val) putnbyte(b + 0x39, val, 1) #define get_WD_brightness_B(b) getnbyte(b + 0x39, 1) 0, /* 0x3a */ /* R contrast */ #define set_WD_contrast_R(b, val) putnbyte(b + 0x3a, val, 1) #define get_WD_contrast_R(b) getnbyte(b + 0x3a, 1) 0, /* 0x3b */ /* G contrast */ #define set_WD_contrast_G(b, val) putnbyte(b + 0x3b, val, 1) #define get_WD_contrast_G(b) getnbyte(b + 0x3b, 1) 0, /* 0x3c */ /* B contrast */ #define set_WD_contrast_B(b, val) putnbyte(b + 0x3c, val, 1) #define get_WD_contrast_B(b) getnbyte(b + 0x3c, 1) 0, 0, 0, 0, /* 0x3d */ /* Reserved */ 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x49 */ /* R exposure time adjustment [0, 12-200] */ #define set_WD_exposure_R(b, val) putnbyte(b + 0x49, val, 1) #define get_WD_exposure_R(b) getnbyte(b + 0x49, 1) 0, /* 0x4a */ /* G exposure time adjustment [0, 12-200] */ #define set_WD_exposure_G(b, val) putnbyte(b + 0x4a, val, 1) #define get_WD_exposure_G(b) getnbyte(b + 0x4a, 1) 0, /* 0x4b */ /* B exposure time adjustment [0, 12-200] */ #define set_WD_exposure_B(b, val) putnbyte(b + 0x4b, val, 1) #define get_WD_exposure_B(b) getnbyte(b + 0x4b, 1) 0, 0, 0, 0, /* 0x4c */ /* Reserved */ 0, 0, 0, /* 0x52 */ /* Amount of R shift [0, 128+-15] */ #define set_WD_shift_R(b, val) putnbyte(b + 0x52, val, 1) #define get_WD_shift_R(b) getnbyte(b + 0x52, 1) 0, /* 0x53 */ /* Amount of G shift [0, 128+-15] */ #define set_WD_shift_G(b, val) putnbyte(b + 0x53, val, 1) #define get_WD_shift_G(b) getnbyte(b + 0x53, 1) 0, /* 0x54 */ /* Amount of B shift [0, 128+-15] */ #define set_WD_shift_B(b, val) putnbyte(b + 0x54, val, 1) #define get_WD_shift_B(b) getnbyte(b + 0x54, 1) 0, /* R0x55 */ /* Amount of R offset [0-255] */ 0, /* R0x56 */ /* Amount of G offset [0-255] */ 0, /* R0x57 */ /* Amount of B offset [0-255] */ 0, 0, /* 0x58 */ /* Maximum resolution (for GET WINDOW: [2700]) */ #define get_WD_maxres(b) getnbyte(b + 0x58, 2) 0, 0, /* 0x5a */ /* Reserved */ 0, /* 0x5c */ /* LUT-R, LUT-G */ #define set_WD_LUT_R(b, val) setbitfield(b + 0x5c, 0x0f, 4, val) #define set_WD_LUT_G(b, val) setbitfield(b + 0x5c, 0x0f, 0, val) #define get_WD_LUT_R(b) getbitfield(b + 0x5c, 0x0f, 4) #define get_WD_LUT_G(b) getbitfield(b + 0x5c, 0x0f, 0) 0, /* 0x5d */ /* LUT-B, reserved */ #define set_WD_LUT_B(b, val) setbitfield(b + 0x5d, 0x0f, 4, val) #define get_WD_LUT_B(b) getbitfield(b + 0x5d, 0x0f, 4) 0, /* R0x5e */ /* LS-1000: reserved. LS-20: R B/W reference point */ 0, /* R0x5f */ /* LS-1000: reserved. LS-20: G B/W reference point */ 0, /* R0x60 */ /* LS-1000: reserved. LS-20: B B/W reference point */ 0, /* R0x61 */ /* R exposure time unit [0-7] (LS-1000); [0, 2-1] (LS-20) */ 0, /* R0x62 */ /* G exposure time unit [0-7] (LS-1000); [0, 2-1] (LS-20) */ 0, /* R0x63 */ /* B exposure time unit [0-7] (LS-1000); [0, 2-1] (LS-20) */ 0, /* 0x64 */ /* Reserved */ 0, /* 0x65 */ /* Reserved, stop */ #define set_WD_stop(b, val) setbitfield(b+0x65, 0x01, 0, val) #define get_WD_stop(b) getbitfield(b+0x65, 0x01, 0) 0, /* R0x66 */ /* R gain [0-4] (LS-1000), [0-255] (LS-20) */ 0, /* R0x67 */ /* G gain [0-4] (LS-1000), [0-255] (LS-20) */ 0, /* R0x68 */ /* B gain [0-4] (LS-1000), [0-255] (LS-20) */ 0, 0, 0, 0, /* R0x69 */ /* R exposure time variable [0, 64-65535] */ 0, 0, 0, 0, /* R0x6d */ /* G exposure time variable [0, 64-65535] */ 0, 0, 0, 0, /* R0x71 */ /* B exposure time variable [0, 64-65535] */ /* 0x75 (last) */ }; static scsiblk window_descriptor_block = { window_descriptor_blockC, sizeof (window_descriptor_blockC) }; /* LS-30 has different window-descriptor ! */ static unsigned char window_descriptor_blockC_LS30[] = { #define used_WDB_size_LS30 0x32 0x00, /* 0x00 */ /* Window Identifier */ #define WD_wid_0 0x00 /* Only one supported */ #define WD_wid_1 0x01 #define WD_wid_2 0x02 #define WD_wid_3 0x03 #define WD_wid_4 0x04 #define WD_wid_9 0x09 0x00, /* reserved, AUTO */ 0x00, 0x00, /* 0x02 */ /* X Resolution in dpi */ 0x00, 0x00, /* 0x04 */ /* Y Resolution in dpi */ 0x00, 0x00, 0x00, 0x00, /* 0x06 */ /* Upper Left X in 2700pt/inch */ 0x00, 0x00, 0x00, 0x00, /* 0x0a */ /* Upper Left Y in 2700pt/inch */ 0x00, 0x00, 0x00, 0x00, /* 0x0e */ /* Width 1200pt/inch */ 0x00, 0x00, 0x00, 0x00, /* 0x12 */ /* Length 1200pt/inch */ 0x00, /* 0x16 */ /* Brightness */ 0x00, /* 0x17 */ /* Reserved */ 0x00, /* 0x18 */ /* Contrast */ 0x05, /* 0x19 */ /* Image Mode */ 0x08, /* 0x1a */ /* Bits/Pixel */ #define WD_bits_10 0x0a 0, 0, 0, 0, 0, /* 0x1b */ /* Reserved */ 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */ 0, /* 0x29 */ /* Negative/positive prevue/scan */ #define set_WD_negative_LS30(sb, val) setbitfield(sb + 0x29, 0x1, 0, (val?0:1)) #define get_WD_negative_LS30(sb) getbitfield(sb + 0x29, 0x1, 0) /* scan mode */ #define set_WD_scanmode_LS30(sb, val) setbitfield(sb + 0x29, 0x3, 0, val) #define get_WD_scanmode_LS30(sb) getbitfield(sb + 0x29, 0x3, 0) 0x04, /* 0x2a */ 0x02, /* 0x2b */ 0x01, /* 0x2c */ 0xff, /* 0x2d */ 0,0, /* 0x2e */ 0,0, /* 0x30 */ #define set_gain_LS30(sb, val) putnbyte(sb + 0x2e, val, 4) #define get_gain_LS30(sb) getnbyte(sb + 0x2e, 4) }; static scsiblk window_descriptor_block_LS30 = { window_descriptor_blockC, sizeof (window_descriptor_blockC_LS30) }; /* ==================================================================== */ /*#define set_WDB_length(length) (window_descriptor_block.size = (length)) */ #define WPDB_OFF(b) (b + set_window.size) #define WDB_OFF(b, n) (b + set_window.size + \ window_parameter_data_block.size + \ ( window_descriptor_block.size * (n - 1) ) ) #define set_WPDB_wdbnum(sb,n) set_WPDB_wdblen(sb,window_descriptor_block.size*n) /* ==================================================================== */ static unsigned char scanC[] = { SCAN, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk scan = {scanC, sizeof (scanC)}; #define set_SC_xfer_length(sb, val) sb[0x04] = (unsigned char)val /* ==================================================================== */ /* static unsigned char send_diagnosticC[] = { SEND_DIAGNOSTIC, 0x04, 0x00, 0x00, 0x00, 0x00 }; static scsiblk send_diagnostic = { send_diagnosticC, sizeof(send_diagnosticC) }; */ /* ==================================================================== */ /* sread instead of read because read is a libc primitive */ static unsigned char sreadC[] = { READ, 0x00, 0x00, /* Data Type Code */ 0x00, /* reserved */ 0x00, 0x00, /* data type qualifier */ 0x00, 0x00, 0x00, /* transfer length */ 0x00 /* control */ }; static scsiblk sread = {sreadC, sizeof (sreadC)}; #define set_R_data1_code(sb, val) sb[0x01] = val #define set_R_datatype_code(sb, val) sb[0x02] = val #define R_datatype_imagedata 0x00 #define R_EX_datatype_LUT 0x01 /* Experiment code */ #define R_image_positions 0x88 #define R_EX_datatype_shading_data 0xa0 /* Experiment code */ #define R_user_reg_gamma 0xc0 #define R_device_internal_info 0xe0 #define set_R_datatype_qual_upper(sb, val) sb[0x04] = val #define set_R_datatype_qual_lower(sb, val) sb[0x05] = val #define R_DQ_none 0x00 #define R_DQ_Rcomp 0x06 #define R_DQ_Gcomp 0x07 #define R_DQ_Bcomp 0x08 #define R_DQ_Reg1 0x01 #define R_DQ_Reg2 0x02 #define R_DQ_Reg3 0x03 #define set_R_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3) /* ==================================================================== */ /* Length of internal info structure */ #define DI_length 256 /* Functions for picking out data from the internal info structure */ #define get_DI_ADbits(b) getnbyte(b + 0x00, 1) #define get_DI_Outputbits(b) getnbyte(b + 0x01, 1) #define get_DI_MaxResolution(b) getnbyte(b + 0x02, 2) #define get_DI_Xmax(b) getnbyte(b + 0x04, 2) #define get_DI_Ymax(b) getnbyte(b + 0x06, 2) #define get_DI_Xmaxpixel(b) getnbyte(b + 0x08, 2) #define get_DI_Ymaxpixel(b) getnbyte(b + 0x0a, 2) #define get_DI_currentY(b) getnbyte(b + 0x10, 2) #define get_DI_currentFocus(b) getnbyte(b + 0x12, 2) #define get_DI_currentscanpitch(b) getnbyte(b + 0x14, 1) #define get_DI_autofeeder(b) getnbyte(b + 0x1e, 1) #define get_DI_analoggamma(b) getnbyte(b + 0x1f, 1) #define get_DI_deviceerror0(b) getnbyte(b + 0x40, 1) #define get_DI_deviceerror1(b) getnbyte(b + 0x41, 1) #define get_DI_deviceerror2(b) getnbyte(b + 0x42, 1) #define get_DI_deviceerror3(b) getnbyte(b + 0x43, 1) #define get_DI_deviceerror4(b) getnbyte(b + 0x44, 1) #define get_DI_deviceerror5(b) getnbyte(b + 0x45, 1) #define get_DI_deviceerror6(b) getnbyte(b + 0x46, 1) #define get_DI_deviceerror7(b) getnbyte(b + 0x47, 1) #define get_DI_WBETR_R(b) getnbyte(b + 0x80, 2) /* White balance exposure time variable R */ #define get_DI_WBETR_G(b) getnbyte(b + 0x82, 2) #define get_DI_WBETR_B(b) getnbyte(b + 0x84, 2) #define get_DI_PRETV_R(b) getnbyte(b + 0x88, 2) /* Prescan result exposure tim4e variable R */ #define get_DI_PRETV_G(b) getnbyte(b + 0x8a, 2) #define get_DI_PRETV_B(b) getnbyte(b + 0x8c, 2) #define get_DI_CETV_R(b) getnbyte(b + 0x90, 2) /* Current exposure time variable R */ #define get_DI_CETV_G(b) getnbyte(b + 0x92, 2) #define get_DI_CETV_B(b) getnbyte(b + 0x94, 2) #define get_DI_IETU_R(b) getnbyte(b + 0x98, 1) /* Internal exposure time unit R */ #define get_DI_IETU_G(b) getnbyte(b + 0x99, 1) #define get_DI_IETU_B(b) getnbyte(b + 0x9a, 1) #define get_DI_limitcondition(b) getnbyte(b + 0xa0, 1) #define get_DI_offsetdata_R(b) getnbyte(b + 0xa1, 1) #define get_DI_offsetdata_G(b) getnbyte(b + 0xa2, 1) #define get_DI_offsetdata_B(b) getnbyte(b + 0xa3, 1) #define get_DI_poweron_errors(b,to) memcpy(to, (b + 0xa8), 8) /* ==================================================================== */ static unsigned char sendC[] = { SEND, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk send = {sendC, sizeof (sendC)}; #define set_S_datatype_code(sb, val) sb[0x02] = (unsigned char)val #define S_datatype_imagedatai 0x00 #define S_EX_datatype_LUT 0x01 /* Experiment code */ #define S_EX_datatype_shading_data 0xa0 /* Experiment code */ #define S_user_reg_gamma 0xc0 #define S_device_internal_info 0x03 #define set_S_datatype_qual_upper(sb, val) sb[0x04] = (unsigned char)val #define S_DQ_none 0x00 #define S_DQ_Rcomp 0x06 #define S_DQ_Gcomp 0x07 #define S_DQ_Bcomp 0x08 #define S_DQ_Reg1 0x01 #define S_DQ_Reg2 0x02 #define S_DQ_Reg3 0x03 #define S_DQ_Reg9 0x09 #define set_S_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3) /* static unsigned char gamma_user_LUT_LS1K[512] = { 0x00 }; static scsiblk gamma_user_LUT_LS1K_LS1K = { gamma_user_LUT_LS1K, sizeof(gamma_user_LUT_LS1K) }; */ /* ==================================================================== */ static unsigned char object_positionC[] = { OBJECT_POSITION, 0x00, /* Auto feeder function */ 0x00, 0x00, 0x00, /* Count */ 0x00, 0x00, 0x00, 0x00, /* Reserved */ 0x00 /* Control byte */ }; #define set_OP_autofeed(b,val) setbitfield(b+0x01, 0x07, 0, val) #define OP_Discharge 0x00 #define OP_Feed 0x01 #define OP_Absolute 0x02 /* For development only */ static scsiblk object_position = { object_positionC, sizeof (object_positionC) }; /* ==================================================================== */ static unsigned char autofocusC[] = { AUTO_FOCUS, 0x00, 0x00, 0x00, 0x00, /* transfer length (0|8) */ 0x00 /* Control byte */ }; #define set_AF_transferlength(b, val) b[0x04] = (unsigned char)val #define get_AF_transferlength(b) ((int)b[0x04] & 0xff) #define set_AF_XPoint(b, val) putnbyte(b+0x06, val, 4) #define set_AF_YPoint(b, val) putnbyte(b+0x0a, val, 4) #define AF_Point_length 8 static scsiblk autofocus = {autofocusC, sizeof (autofocusC)}; /* ==================================================================== */ static unsigned char command_c1_C[] = { 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* */ 0x00, 0x00 /* transfer length*/ }; static scsiblk command_c1 = {command_c1_C, sizeof (command_c1_C)}; /* ==================================================================== */ static unsigned char autofocusLS30C[] = { 0xe0, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, /* */ 0x09, 0x00 /* transfer length*/ }; static unsigned char autofocuspos[] = { 0x00, 0x00, 0x00, 0x05, 0x10, /* x-position */ 0x00, 0x00, 0x07, 0x9b, /* y-position */ }; #define set_AF_transferlength(b, val) b[0x04] = (unsigned char)val #define get_AF_transferlength(b) ((int)b[0x04] & 0xff) #define set_AF_XPoint(b, val) putnbyte(b+0x06, val, 4) #define set_AF_YPoint(b, val) putnbyte(b+0x0a, val, 4) #define AF_Point_length 8 static scsiblk autofocusLS30 = {autofocusLS30C, sizeof (autofocusLS30C)}; /* ==================================================================== */ static unsigned char commande1C[] = { 0xe1, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, /* */ 0x0d, 0x00 /* transfer length*/ }; static scsiblk commande1 = {commande1C, sizeof (commande1C)}; /* ==================================================================== */ /* static unsigned char request_senseC[] = { REQUEST_SENSE, 0x00, 0x00, 0x00, 0x00, 0x00 #define set_RS_allocation_length(sb,val) sb[0x04] = (unsigned char)val }; static scsiblk request_sense = { request_senseC, sizeof (request_senseC) }; */ /* defines for request sense return block */ #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7) #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0) #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7) #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6) #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5) #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0) #define get_RS_information(b) getnbyte(b+0x03, 4) /* normally 0 */ #define get_RS_additional_length(b) b[0x07] /* always 10 */ #define get_RS_ASC(b) b[0x0c] #define get_RS_ASCQ(b) b[0x0d] #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /* valid, always 0 */ #define rs_return_block_size 18 /* Says Nikon */ #endif sane-backends-1.0.29/backend/u12-hwdef.h0000666000000000000000000003607613615534521014457 00000000000000/** @file u12-hwdef.h * @brief Definitions for the ASIC. * * Copyright (c) 2003-2004 Gerhard Jaeger * * History: * - 0.01 - initial version * - 0.02 - change _DEF_BW_THRESHOLD * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #ifndef __U12_HWDEF_H__ #define __U12_HWDEF_H__ #define _LOWORD(x) ((u_short)(x & 0xffff)) #define _HIWORD(x) ((u_short)(x >> 16)) #define _LOBYTE(x) ((SANE_Byte)((x) & 0xFF)) #define _HIBYTE(x) ((SANE_Byte)((x) >> 8)) #define _SET_REG(b,c,r,v) {b[c*2]=r; b[(c*2)+1]=v;c++;} /** some magics for the ASIC */ #define _ID_TO_PRINTER 0x00 #define _ID1ST 0x69 #define _ID2ND 0x96 #define _ID3RD 0xa5 #define _ID4TH 0x5a /** some more for reset... */ #define _RESET1ST 0x69 #define _RESET2ND 0x96 #define _RESET3RD 0xaa #define _RESET4TH 0x55 /** Printer Control Port: Definitions */ #define _CTRL_STROBE 0x01 #define _CTRL_AUTOLF 0x02 #define _CTRL_NOT_INIT 0x04 #define _CTRL_SELECT_IN 0x08 #define _CTRL_ENABLE_IRQ 0x10 #define _CTRL_DIRECTION 0x20 #define _CTRL_RESERVED 0xc0 /** for Asic I/O signal control */ #define _CTRL_GENSIGNAL (_CTRL_RESERVED + _CTRL_NOT_INIT) /* 0xc4 */ #define _CTRL_SIGNAL_REGWRITE (_CTRL_GENSIGNAL + _CTRL_SELECT_IN) /* 0xcc */ #define _CTRL_END_REGWRITE (_CTRL_GENSIGNAL) /* 0xc4 */ #define _CTRL_SIGNAL_DATAWRITE (_CTRL_GENSIGNAL + _CTRL_AUTOLF) /* 0xc6 */ #define _CTRL_END_DATAWRITE (_CTRL_GENSIGNAL) /* 0xc4 */ #define ASIC_ID 0x83 /** the Register set */ #define REG_SWITCHBUS 0x00 #define REG_EPPENABLE 0x01 #define REG_READDATAMODE 0x03 #define REG_WRITEDATAMODE 0x04 #define REG_INITDATAFIFO 0x05 #define REG_FORCESTEP 0x06 #define REG_REFRESHSCANSTATE 0x08 #define REG_WAITSTATEINSERT 0x0a #define REG_RFIFOOFFSET 0x0a #define REG_GFIFOOFFSET 0x0b #define REG_BFIFOOFFSET 0x0c #define REG_STEPCONTROL 0x14 #define REG_MOTOR0CONTROL 0x15 #define REG_XSTEPTIME 0x16 #define REG_GETSCANSTATE 0x17 #define REG_ASICID 0x18 #define REG_MEMORYLO 0x19 #define REG_MEMORYHI 0x1a #define REG_MODECONTROL 0x1b #define REG_LINECONTROL 0x1c #define REG_SCANCONTROL 0x1d #define REG_CONFIG 0x1e #define REG_MODELCONTROL 0x1f #define REG_MODEL1CONTROL 0x20 #define REG_DPILO 0x21 #define REG_DPIHI 0x22 #define REG_SCANPOSLO 0x23 #define REG_SCANPOSHI 0x24 #define REG_WIDTHPIXELLO 0x25 #define REG_WIDTHPIXELHI 0x26 #define REG_THRESHOLDLO 0x27 #define REG_THRESHOLDHI 0x28 #define REG_ADCADDR 0x2a #define REG_ADCDATA 0x2b #define REG_ADCSERIALOUT 0x2d #define REG_RESETCONFIG 0x2e #define REG_STATUS 0x30 #define REG_SCANSTATECONTROL 0x31 #define REG_REDCHDARKOFFSETLO 0x33 #define REG_REDCHDARKOFFSETHI 0x34 #define REG_GREENCHDARKOFFSETLO 0x35 #define REG_GREENCHDARKOFFSETHI 0x36 #define REG_BLUECHDARKOFFSETLO 0x37 #define REG_BLUECHDARKOFFSETHI 0x38 #define REG_FIFOFULLEN0 0x54 #define REG_FIFOFULLEN1 0x55 #define REG_FIFOFULLEN2 0x56 #define REG_MOTORTOTALSTEP0 0x57 #define REG_MOTORTOTALSTEP1 0x58 #define REG_MOTORFREERUNCOUNT0 0x59 #define REG_MOTORFREERUNCOUNT1 0x5a #define REG_SCANCONTROL1 0x5b #define REG_MOTORFREERUNTRIGGER 0x5c #define REG_RESETMTSC 0x5d #define REG_MOTORDRVTYPE 0x64 #define REG_STATUS2 0x66 #define REG_EXTENDEDLINECONTROL 0x6d #define REG_EXTENDEDXSTEP 0x6e #define REG_PLLPREDIV 0x71 #define REG_PLLMAINDIV 0x72 #define REG_PLLPOSTDIV 0x73 #define REG_CLOCKSELECTOR 0x74 #define REG_TESTMODE 0xf0 /* Register RegStepControl (Addr: 0x14) */ #define _MOTOR0_ONESTEP 0x01 #define _MOTOR0_SCANSTATE 0x02 #define _MOTOR_FREERUN 0x40 #define _MOTOR_NOFREERUN 0x00 /* Register RegGetScanState (Addr: 0x17)*/ #define _SCANSTATE_MASK 0x3f /* bit 0-5 */ #define _SCANSTATE_STOP 0x80 /* Register RegMemoryLow/High (Addr: 0x19/0x1a)*/ #define _MAP_ADDR_RED 0x00 #define _MAP_ADDR_GREEN 0x40 #define _MAP_ADDR_BLUE 0x80 #define _MAP_ADDR_SIZE 0x40 /* Register RegModeControl (Addr: 0x1b)*/ #define _ModeScan 0x00 #define _ModeIdle 0x01 #define _ModeShadingMem 0x02 #define _ModeMappingMem 0x03 #define _ModeReadMappingMem 0x07 #define _ModeFifoRSel 0x00 #define _ModeFifoGSel 0x08 #define _ModeFifoBSel 0x10 #define _ModeFifoClose 0x18 /* Register RegLineControl (Addr: 0x1c) */ #define _LINE_SCANTIME_MASK 0x3f /* bit 0-6 */ #define _LINE_CDSINVERSE 0x80 /* Color Drive Signal */ /* Register RegScanControl (Addr: 0x1d) */ #define _SCAN_BITMODE 0x00 #define _SCAN_BYTEMODE 0x01 /* Gray/Color mode */ #define _SCAN_12BITMODE 0x02 #define _SCAN_1ST_AVERAGE 0x04 /* first pixel is averaged pixel */ #define _SCAN_BITDIRR2L 0x08 /* bit shift from right to left */ #define _SCAN_NORMALLAMP_ON 0x10 /* normal Lamp */ #define _SCAN_TPALAMP_ON 0x20 #define _SCAN_DATA_INVERT 0x40 #define _BITALIGN_LEFT 0x80 #define _SCAN_LAMPS_ON (_SCAN_NORMALLAMP_ON | _SCAN_TPALAMP_ON) #define _SCAN_LAMP_MASK _SCAN_LAMPS_ON /* Register RegMotor0Control (Addr: 0x15) */ #define _MotorDirForward 0x01 #define _MotorDirBackward 0x00 #define _MotorOn 0x02 #define _MotorHFullStepH 0x00 #define _MotorHHalfStep 0x04 #define _MotorHQuarterStep 0x08 #define _MotorPowerEnable 0x40 #define _MotorHHomeStop 0x80 #define _DIR_FW 1 #define _DIR_BW 2 #define _DIR_NONE 0 #define _FORWARD_MOTOR (_MotorDirForward + _MotorOn + \ _MotorHQuarterStep + _MotorPowerEnable) #define _BACKWARD_MOTOR (_MotorDirBackward + _MotorOn + _MotorHHomeStop + \ _MotorHQuarterStep + _MotorPowerEnable) /* Register RegConfiguration (Addr: 0x1e) */ #define _P98_CCD_TYPE_ID 0x07 #define _P98_NEC_MACHINE 0x08 #define _P98_PCBID 0xF0 #define _DEF_BW_THRESHOLD 128 /* default B/W mode threshold value */ #define _NUMBER_OF_SCANSTEPS 64 /* Asic spec.: up to 64 scan steps */ #define _SCANSTATE_BYTES (_NUMBER_OF_SCANSTEPS/2) #define _CCD_3797 0 #define _CCD_3799 1 #define _CCD_535 2 #define _CCD_2556 3 #define _CCD_518 4 #define _CCD_539 5 #define _CCD_3777 6 #define _CCD_548 7 /* PCB-IDs (from parport driver)... */ #define _OPTICWORKS2000 0x00 #define _PLUSTEK_SCANNER 0x10 #define _SCANNER_WITH_TPA 0x20 #define _SCANNER4Button 0x30 #define _SCANNER4ButtonTPA 0x40 #define _SCANNER5Button 0x50 #define _SCANNER5ButtonTPA 0x60 #define _SCANNER1Button 0x70 #define _SCANNER1ButtonTPA 0x80 #define _SCANNER2Button 0x90 #define _AGFA_SCANNER 0xf0 #define _AGFA_PCB 0x1f /* Register RegModelControl (Addr: 0x1f) */ #define _HOME_SENSOR_POLARITY 0x01 #define _LED_CONTROL 0x02 #define _LED_ACTIVITY 0x04 #define _MODEL_DPI200 0x00 #define _MODEL_DPI300 0x08 #define _MODEL_DPI400 0x10 #define _MODEL_DPI600 0x18 #define _MODEL_DPI800 0x20 #define _MODEL_DPI1200 0x28 #define _DUMMY_12BIT 0x40 /* Register RegModel1Control (Addr: 0x20) */ #define _SCAN_GRAYTYPE 0x01 #define _CCD_SHIFT_GATE 0x02 #define _CCD_SHIFT_PULSE 0x04 #define _BUTTON_MODE 0x08 #define _MOTOR_2003 0x00 #define _MOTOR_2916 0x10 #define _MOTOR_7042 0x20 /* Register RegThresholdGapControl (Addr: 0x29) */ #define _THRESHOLDGAP_MASK 0x0f /* Register RegResetConfig (Addr: 0x2e) */ #define _ADC_MASK 0x07 #define _DA_WOLFSON8143 0x00 #define _DA_ESIC 0x04 #define _DA_SAMSUNG8531 0x05 #define _DA_WOLFSON8141 0x06 #define _DA_SAMSUNG1224 0x07 #define _MOTOR0_MASK 0x18 #define _MOTOR0_2003 0x00 #define _MOTOR0_2916 0x08 #define _MOTOR0_7042 0x10 #define _MOTOR1_MASK 0x60 #define _MOTOR1_2003 0x00 #define _MOTOR1_2916 0x20 #define _MOTOR1_7042 0x40 /* Status Register (Addr: 0x30) */ #define _FLAG_PAPER 0x01 #define _FLAG_KEY 0x80 /* Register RegFifoFullLength (Addr: 0x54) */ #define _RED_FULLSIZE 0x00 #define _GREEN_FULLSIZE 0x08 #define _BLUE_FULLSIZE 0x10 /* Register RegScanControl1 (Addr: 0x5b) */ #define _MTSC_ENABLE 0x01 #define _SCANSTOPONBUFFULL 0x02 #define _MFRC_RUNSCANSTATE 0x04 #define _MFRC_BY_XSTEP 0x08 /* Register RegMotorDriverType (Addr: 0x64) */ #define _MOTORS_MASK 0x33 #define _MOTORR_MASK 0xf3 #define _MOTORR_WEAK 0x04 #define _MOTORR_MEDIUM 0x08 #define _MOTORR_STRONG 0x0c #define _MOTORT_WEAK 0x40 #define _MOTORT_MEDIUM 0x80 #define _MOTORT_STRONG 0xc0 #define _BUTTON_SELECT1 0x40 #define _BUTTON_SELECT2 0x80 #define _BUTTON_DISABLE 0xc0 /** Register RegStatus2 (Addr: 0x66) */ #define _REFLECTIONLAMP_ON 0x01 #define _TPALAMP_ON 0x02 #define _STILL_FREE_RUNNING 0x04 #define _BUFFER_IS_FULL 0x08 /** Register RegTestMode (Addr: 0xf0) */ #define _SW_TESTMODE 0x20 /** buffer sizes */ #define _BYTES_PER_CHANNEL 5500UL #define _SIZE_DATA_BUF (u_long)(_BYTES_PER_CHANNEL * 3 * 2) #define _SIZE_TPA_DATA_BUF (u_long)(_BYTES_PER_CHANNEL * 3 * 2) #define _SIZE_SHADING_SUM_BUF (u_long)(_BYTES_PER_CHANNEL * 3 * 4) #define _SIZE_TOTAL_BUF (u_long)(_SIZE_DATA_BUF + _SIZE_SHADING_SUM_BUF) #define _SIZE_TOTAL_BUF_TPA (u_long)(_SIZE_TOTAL_BUF + _SIZE_TPA_DATA_BUF) /** internal FIFO buffers */ #define _SIZE_REDFIFO 196608UL /* 192k */ #define _SIZE_GREENFIFO 147456UL /* 144k */ #define _SIZE_BLUEFIFO 114688UL /* 112k */ #define _SIZE_GRAYFIFO (_SIZE_REDFIFO + _SIZE_GREENFIFO + _SIZE_BLUEFIFO) /* Scan State Definitions */ #define _SS_STEP 0x08 #define _SS_RED 0x04 #define _SS_GREEN 0x02 #define _SS_BLUE 0x01 #define _SS_MONO _SS_GREEN #define _SS_COLOR (_SS_RED | _SS_GREEN | _SS_BLUE) /** some positioning stuff */ #define _RFT_SCANNING_ORG 380U #define _POS_SCANNING_ORG 2840U #define _NEG_SCANNING_ORG 3000U #define _TPA_SHADINGORG 2172U #define _DATA_ORIGIN_X 72 #define _YOFFSET 300 #define _POS_PAGEWIDTH 450U #define _POS_ORG_OFFSETX 0x41C #define _NEG_PAGEWIDTH 464U #define _NEG_PAGEWIDTH600 992U #define _NEG_ORG_OFFSETX 0x430 #define _NEG_EDGE_VALUE 0x800 #define _NEG_SHADING_OFFS 1500U #define _SHADING_BEGINX 4U #define _DEFAULT_LINESCANTIME 96 #define _LINE_TIMEOUT (_SECOND * 5 ) /** for mirroring parts of the 98003 ASIC register set */ typedef struct { SANE_Byte RD_Motor1Control; /* 0x0b */ SANE_Byte RD_StepControl; /* 0x14 */ SANE_Byte RD_Motor0Control; /* 0x15 */ SANE_Byte RD_XStepTime; /* 0x16 */ SANE_Byte RD_ModeControl; /* 0x1b */ SANE_Byte RD_LineControl; /* 0x1c */ SANE_Byte RD_ScanControl; /* 0x1d, init = 5 */ SANE_Byte RD_ModelControl; /* 0x1f */ SANE_Byte RD_Model1Control; /* 0x20 */ u_short RD_Dpi; /* 0x21 */ u_short RD_Origin; /* 0x23 */ u_short RD_Pixels; /* 0x25 */ u_short RD_ThresholdControl; /* 0x27 */ SANE_Byte RD_ThresholdGapCtrl; /* 0x29 */ u_short RD_RedDarkOff; /* 0x33 */ u_short RD_GreenDarkOff; /* 0x35 */ u_short RD_BlueDarkOff; /* 0x37 */ u_long RD_BufFullSize; /* 0x54 */ u_short RD_MotorTotalSteps; /* 0x57 */ SANE_Byte RD_ScanControl1; /* 0x5b */ SANE_Byte RD_MotorDriverType; /* 0x64 */ SANE_Byte RD_ExtLineControl; /* 0x6d */ SANE_Byte RD_ExtXStepTime; /* 0x6e */ } ShadowRegs; /** to hold all the shading stuff for calibrating a scanner */ typedef struct svd { ColorWord GainResize; ColorWord DarkCmpHi; ColorWord DarkCmpLo; ColorWord DarkOffSub; ColorByte DarkDAC; SANE_Byte Reserved; } ShadingVarDef; typedef struct { ShadingVarDef *pCcdDac; ColorByte DarkDAC; ColorWord DarkOffset; u_short wDarkLevels; SANE_Byte intermediate; u_long dwDiv; SANE_Byte skipShadow; SANE_Byte skipHilight; ColorByte Hilight; RGBUShortDef *pHilight; ColorByte Gain; SANE_Byte bGainDouble; SANE_Byte bUniGain; SANE_Byte bMinGain; SANE_Byte bMaxGain; SANE_Byte bGainHigh; SANE_Byte bGainLow; SANE_Bool fStop; u_short wExposure; u_short wXStep; } ShadingDef; #endif /* guard __U12_HWDEF_H__ */ /* END U12-HWDEF.H ..........................................................*/ sane-backends-1.0.29/backend/kvs1025.conf.in0000666000000000000000000000004713615534521015160 00000000000000usb "Panasonic KV-S1025C" /dev/scanner sane-backends-1.0.29/backend/umax1220u-common.c0000666000000000000000000016553713615534521015707 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1999 Paul Mackerras Copyright (C) 2000 Adrian Perez Jorge Copyright (C) 2001 Frank Zago Copyright (C) 2001 Marcio Teixeira Parts copyright (C) 2006 Patrick Lessard 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Defines a driver and API for accessing the UMAX Astra 1220U USB scanner. Based on the original command line tool by Paul Mackerras. The UMAX Astra 1220U scanner uses the PowerVision PV8630 Parallel Port to USB bridge. This chip is also used by the HP4200C flatbed scanner. Adrian Perez Jorge wrote a nice interface file for that chip and Frank Zago adapted it to use the sanei_usb interface. Thanks, guys, for making my life easier! :) */ #include #include #include #include #include #include #include /* * The backend performs test scans in order to calibrate * the CCD and to find the zero location. If you would like * to look at those scans, define DEBUG_CALIBRATION to have * the backend save "find_zero.pgm" and "calibration.pgm" to * disk. */ /* #define DEBUG_CALIBRATION */ /* * Define DEBUG_BOUNDS to insert paranoid array bounds * overrun detection into the code. */ /* #define DEBUG_BOUNDS */ /* These values are empirically determined and are given * in 1/600 inch units. If UMAX_MAX_HEIGHT is too large, * the scanner may grind its gears. I assume there is a * physical limit to UMAX_MAX_WIDTH as well (based on the * sensor size) but I do not know what it is. The current * value can be increased beyond what it is now, but you * gain nothing in usuable scan area (you only scan more * of the underside of the scanner's plastic lid). */ #define UMAX_MAX_WIDTH 5400 #define UMAX_MAX_HEIGHT 7040 /* Buffer size. Specifies the size of the buffer that is * used to copy data from the scanner. The old command * line driver had this set at 0x80000 which is likely * the largest possible chunck of data that can be. * at once. This is probably most efficient, but using * a lower value for the SANE driver makes the driver * more responsive to interaction. */ #define BUFFER_SIZE 0x80000 /* Constants that can be used with set_lamp_state to * control the state of the scanner's lamp */ typedef enum { UMAX_LAMP_OFF = 0, UMAX_LAMP_ON = 1 } UMAX_Lamp_State; /* Constants that can be used with move to control * the rate of scanner head movement */ typedef enum { UMAX_NOT_FINE = 0, UMAX_FINE = 1 } UMAX_Speed; /* If anyone knows some descriptive names for these, * please update */ typedef enum { CMD_0 = 0x00, CMD_1 = 0x01, CMD_2 = 0x02, CMD_4 = 0x04, CMD_8 = 0x08, CMD_40 = 0x40, CMD_WRITE = 0x80, CMD_READ = 0xc0 } UMAX_Cmd; /* Product IDs for Astra scanners */ typedef enum { ASTRA_1220U = 0x0010, ASTRA_2000U = 0x0030, ASTRA_2100U = 0x0130 } UMAX_Model; /* The bytes UMAX_SYNC1 and UMAX_SYNC2 serve as a * synchronization signal. Unintentional sync bytes * in the data stream are escaped with UMAX_ESCAPE * character */ #define UMAX_SYNC1 0x55 #define UMAX_SYNC2 0xaa #define UMAX_ESCAPE 0x1b /* Status bits. These bits are active low. * In umax_pp, UMAX_REVERSE_BIT is called * MOTOR_BIT. */ #define UMAX_FORWARD_BIT 0x40 #define UMAX_ERROR_BIT 0x20 #define UMAX_MOTOR_OFF_BIT 0x08 #define UMAX_OK 0x48 /* Used to be 0xC8 */ #define UMAX_OK_WITH_MOTOR 0x40 /* Used to be 0xD0 */ #define UMAX_STATUS_MASK 0x68 /* This byte is used as a placeholder for bytes that are parameterized * in the opcode strings */ #define XXXX 0x00 /* This macro is used to check the return code of * functions */ #define CHK(A) {if( (res = A) != SANE_STATUS_GOOD ) { \ DBG( 1, "Failure on line of %s: %d\n", __FILE__, \ __LINE__ ); return A; }} /* Macros that are used for array overrun detection * (when DEBUG_BOUNDS is defined) */ #ifdef DEBUG_BOUNDS #define PAD 10 #define PAD_ARRAY( A, len ) {int i; \ for( i = 0; i < PAD; i++ ) {A[len+i]=0x55;}} #define CHK_ARRAY( A, len ) {int i;for( i = 0; i < PAD; i++ ) {\ if(A[len+i]!=0x55) { \ DBG( 1, "Array overrun detected on line %d\n", __LINE__ ); \ }}} #else #define PAD 0 #define PAD_ARRAY( A, len ) #define CHK_ARRAY( A, len ) #endif /* This data structure contains data related * to the scanning process. */ typedef struct { /* Constant data */ int color; int w; int h; int xo; int yo; int xdpi; /* Physical x dpi */ int ydpi; /* Physical y dpi */ int xsamp; int ysamp; int xskip; int yskip; int fd; /* Device file handle */ UMAX_Model model; /* Raw scan data buffer */ unsigned char *p; int bh; /* Size of buffer in lines */ int hexp; /* Scan lines yet to be read */ /* Decoding logic */ int x, y, maxh; int done; /* Boolean, all lines decoded */ /* Calibration data */ unsigned char caldata[16070 + PAD]; /* Scan head position */ int scanner_ypos; int scanner_yorg; } UMAX_Handle; typedef unsigned char UMAX_Status_Byte; #if 0 static void unused_operations () { /* These operations are unused anywhere in the driver */ unsigned char opb8[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, 0x18, 0x10, 0x03, 0x06, 0x00, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0x13, 0x1a }; unsigned char opb9[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, 0x41, 0x20, 0x24, 0x06, 0x00, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0x13, 0x1a }; unsigned char opb10[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, 0x41, 0x60, 0x4f, 0x06, 0x00, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0x93, 0x1a }; unsigned char opc5[16] = { 0x05, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2f, 0x2f, 0x00, 0x00, 0x30, 0x0c, 0xc3, 0xa4, 0x00 }; unsigned char opc6[16] = { 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2f, 0x2f, 0x00, 0x88, 0x48, 0x0c, 0x83, 0xa4, 0x00 }; unsigned char opc7[16] = { 0x05, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2f, 0x2f, 0x00, 0xec, 0x4e, 0x0c, 0xc3, 0xa4, 0x00 }; unsigned char opd2[8] = { 0x06, 0xf4, 0xff, 0x81, 0x3d, 0x00, 0x00, 0x30 }; } #endif #if 0 static SANE_Status calib (UMAX_Handle * scan) { unsigned char buf[65536]; opc5[11] = 0x30; opd2[7] = 0x30; CHK (get_pixels (scan, opc5, opb8, opd2, ope, 24, 0, buff)); opc5[11] = 0x40; opd2[7] = 0x40; CHK (get_pixels (scan, opc5, opb8, opd2, ope, 24, 0, buff)); opd2[6] = 8; opd2[7] = 0x30; CHK (get_pixels (scan, opc6, opb9, opd2, ope, 0x200, 1, buff)); opc7[10] = 0xec; opd2[6] = 0xc; opd2[7] = 0x40; CHK (get_pixels (scan, opc7, opb10, opd2, ope, 5300, 1, buff)); opc7[10] = 0xed; opd2[6] = 0xd; CHK (get_pixels (scan, opc7, opb10, opd2, ope, 5300, 0, buff)); return SANE_STATUS_GOOD; } #endif /* This seems to configure the pv8630 chip somehow. I wish * all the magic numbers were defined as self-descriptive * constants somewhere. I made some guesses based on what * I found in "pv8630.c", but alas there wasn't enough in * there. If you know what this does, please let me know! */ static SANE_Status xxxops (UMAX_Handle * scan) { SANE_Status res; DBG (9, "doing xxxops\n"); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_RMODE, 0x02)); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_UNKNOWN, 0x0E)); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_RDATA, 0x40)); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_UNKNOWN, 0x06)); CHK (sanei_pv8630_xpect_byte (scan->fd, PV8630_RSTATUS, 0x38, 0xFF)); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_UNKNOWN, 0x07)); CHK (sanei_pv8630_xpect_byte (scan->fd, PV8630_RSTATUS, 0x38, 0xFF)); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_UNKNOWN, 0x04)); CHK (sanei_pv8630_xpect_byte (scan->fd, PV8630_RSTATUS, 0xF8, 0xFF)); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_UNKNOWN, 0x05)); CHK (sanei_pv8630_xpect_byte (scan->fd, PV8630_UNKNOWN, 0x05, 0xFF)); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_UNKNOWN, 0x04)); CHK (sanei_pv8630_write_byte (scan->fd, PV8630_RMODE, 0x1E)); return res; } /* Apparently sends the two syncronization characters followed by the command length, followed by the command number */ static SANE_Status usync (UMAX_Handle * scan, UMAX_Cmd cmd, int len) { UMAX_Status_Byte s0, s4; SANE_Status res; unsigned char buf[4]; size_t nb; DBG (80, "usync: len = %d, cmd = %d\n", len, cmd); buf[0] = UMAX_SYNC1; buf[1] = UMAX_SYNC2; nb = 2; CHK (sanei_pv8630_flush_buffer (scan->fd)); CHK (sanei_pv8630_prep_bulkwrite (scan->fd, nb)); CHK (sanei_pv8630_bulkwrite (scan->fd, buf, &nb)); CHK (sanei_pv8630_wait_byte (scan->fd, PV8630_RSTATUS, UMAX_OK, UMAX_STATUS_MASK, 20)); buf[0] = len >> 16; buf[1] = len >> 8; buf[2] = len; buf[3] = cmd; nb = 4; CHK (sanei_pv8630_flush_buffer (scan->fd)); CHK (sanei_pv8630_prep_bulkwrite (scan->fd, nb)); CHK (sanei_pv8630_bulkwrite (scan->fd, buf, &nb)); CHK (sanei_pv8630_read_byte (scan->fd, PV8630_RDATA, &s0)); CHK (sanei_pv8630_read_byte (scan->fd, PV8630_RSTATUS, &s4)); DBG (90, "usync: s0 = %#x s4 = %#x\n", s0, s4); return SANE_STATUS_GOOD; } /* This function escapes any syncronization sequence that may be in data, storing the result in buf. In the worst case where every character gets escaped buf must be at least twice as large as dlen. */ static int bescape (const unsigned char *data, int dlen, unsigned char *buf, int blen) { const unsigned char *p; unsigned char *q; int i, c; i = blen; /* Eliminate compiler warning about unused param */ p = data; q = buf; for (i = 0; i < dlen; ++i) { c = *p++; if (c == UMAX_ESCAPE || (c == UMAX_SYNC2 && i > 0 && p[-2] == UMAX_SYNC1)) *q++ = UMAX_ESCAPE; *q++ = c; } return q - buf; } /* Write */ static SANE_Status cwrite (UMAX_Handle * scan, UMAX_Cmd cmd, size_t len, const unsigned char *data, UMAX_Status_Byte * s) { SANE_Status res; UMAX_Status_Byte s0, s4; static unsigned char *escaped = NULL; static size_t escaped_size = 0; DBG (80, "cwrite: cmd = %d, len = %lu\n", cmd, (u_long) len); CHK (usync (scan, cmd | CMD_WRITE, len)); if (len <= 0) return SANE_STATUS_GOOD; if (escaped_size < len * 2) { escaped_size = len * 2; if (escaped) free (escaped); escaped = malloc (escaped_size); if (escaped == NULL) return SANE_STATUS_NO_MEM; } len = bescape (data, len, escaped, len * 2); CHK (sanei_pv8630_wait_byte (scan->fd, PV8630_RSTATUS, UMAX_OK, UMAX_STATUS_MASK, 20)); CHK (sanei_pv8630_flush_buffer (scan->fd)); CHK (sanei_pv8630_prep_bulkwrite (scan->fd, len)); CHK (sanei_pv8630_bulkwrite (scan->fd, escaped, &len)); CHK (sanei_pv8630_read_byte (scan->fd, PV8630_RSTATUS, &s4)); CHK (sanei_pv8630_read_byte (scan->fd, PV8630_RDATA, &s0)); DBG (90, "cwrite: s0 = %#x s4 = %#x\n", s0, s4); if (s) *s = s0; return SANE_STATUS_GOOD; } /* Read */ static SANE_Status cread (UMAX_Handle * scan, UMAX_Cmd cmd, size_t len, unsigned char *data, UMAX_Status_Byte * s) { SANE_Status res; UMAX_Status_Byte s0, s4; DBG (80, "cread: cmd = %d, len = %lu\n", cmd, (u_long) len); CHK (usync (scan, cmd | CMD_READ, len)); if (len > 0) { CHK (sanei_pv8630_wait_byte (scan->fd, PV8630_RSTATUS, UMAX_OK_WITH_MOTOR, UMAX_STATUS_MASK, 2000)); while (len > 0) { size_t req, n; req = n = (len > 0xf000) ? 0xf000 : len; CHK (sanei_pv8630_prep_bulkread (scan->fd, n)); CHK (sanei_pv8630_bulkread (scan->fd, data, &n)); if (n < req) { DBG (1, "qread: Expecting to read %lu, only got %lu\n", (u_long) req, (u_long) n); return SANE_STATUS_IO_ERROR; } data += n; len -= n; } } CHK (sanei_pv8630_read_byte (scan->fd, PV8630_RSTATUS, &s4)); CHK (sanei_pv8630_read_byte (scan->fd, PV8630_RDATA, &s0)); DBG (90, "cwrite: s0 = %#x s4 = %#x\n", s0, s4); if (s) *s = s0; return SANE_STATUS_GOOD; } /* Seems to be like cwrite, with a verification option */ static SANE_Status cwritev (UMAX_Handle * scan, UMAX_Cmd cmd, size_t len, const unsigned char *data, UMAX_Status_Byte * s) { SANE_Status res; unsigned char buf[16384]; /* Write out the opcode */ CHK (cwrite (scan, cmd, len, data, s)); if (len <= 0) return SANE_STATUS_GOOD; /* Read the opcode back */ CHK (cread (scan, cmd, len, buf, NULL)); if (bcmp (buf, data, len)) { DBG (1, "cwritev: verification failed\n"); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /* Send command */ static SANE_Status csend (UMAX_Handle * scan, UMAX_Cmd cmd) { DBG (80, "csend: cmd = %d\n", cmd); return usync (scan, cmd, 0); } /* Lamp control */ static SANE_Status cwritev_opc1_lamp_ctrl (UMAX_Handle * scan, UMAX_Lamp_State state) { unsigned char opc1[16] = { 0x01, 0x00, 0x01, 0x70, 0x00, 0x00, 0x60, 0x2f, 0x13, 0x05, 0x00, 0x00, 0x00, 0x80, 0xf0, 0x00 }; DBG (9, "cwritev_opc1: set lamp state = %s\n", (state == UMAX_LAMP_OFF) ? "off" : "on"); opc1[14] = (state == UMAX_LAMP_OFF) ? 0x90 : 0xf0; return cwritev (scan, CMD_2, 16, opc1, NULL); } /* Restore Head 1220U */ static SANE_Status cwritev_opb3_restore (UMAX_Handle * scan) { unsigned char opb3[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x03, 0xc1, 0x80, 0x00, 0x00, 0x04, 0x00, 0x16, 0x80, 0x15, 0x78, 0x03, 0x03, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0x1b, 0x1a, }; SANE_Status res; DBG (9, "cwritev_opb3_restore:\n"); CHK (cwritev (scan, CMD_8, 35, opb3, NULL)); CHK (csend (scan, CMD_40)); return SANE_STATUS_GOOD; } /* Restore Head 2100U */ static SANE_Status cwritev_opb3_restore_2100U (UMAX_Handle * scan) { unsigned char opb3[36] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x03, 0xc1, 0x80, 0x00, 0x00, 0x04, 0x00, 0x16, 0x80, 0x15, 0x78, 0x03, 0x03, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x2a, 0xe9, 0x68, 0xdf, 0x0b, 0x1a, 0x00 }; SANE_Status res; DBG (9, "cwritev_opb3_restore:\n"); CHK (cwritev (scan, CMD_8, 36, opb3, NULL)); CHK (csend (scan, CMD_40)); return SANE_STATUS_GOOD; } /* Initialize and turn lamp on 1220U */ /* This function seems to perform various things. First, it loads a default gamma information (which is used for the calibration scan), returns the head to the park position, and turns the lamp on. This function used to be split up into two parts, umaxinit and umaxinit2. */ static SANE_Status umaxinit (UMAX_Handle * scan) { unsigned char opb[34] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x03, 0xc1, 0x80, 0x60, 0x20, 0x00, 0x00, 0x16, 0x41, 0xe0, 0xac, 0x03, 0x03, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0 }; unsigned char opb1[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x03, 0xc1, 0x80, 0x00, 0x20, 0x02, 0x00, 0x16, 0x41, 0xe0, 0xac, 0x03, 0x03, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1a }; unsigned char opb2[35] = { 0x00, 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x03, 0xc1, 0x80, 0x00, 0x20, 0x02, 0x00, 0x16, 0x41, 0xe0, 0xac, 0x03, 0x03, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x1a }; unsigned char opb4[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x03, 0xc1, 0x80, 0x60, 0x20, 0x00, 0x00, 0x16, 0x41, 0xe0, 0xac, 0x03, 0x03, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0xf3, 0x1b }; unsigned char opbx[35]; unsigned char opc[16] = { 0x02, 0x80, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2f, 0x2f, 0x07, 0x00, 0x00, 0x00, 0x80, 0xf0, 0x00 }; unsigned char opcx[16]; unsigned char opd[8] = { 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa }; SANE_Status res; UMAX_Status_Byte s; unsigned char ramp[800]; int i; unsigned char *p; DBG (3, "umaxinit called\n"); CHK (csend (scan, CMD_0)); CHK (xxxops (scan)); CHK (cwritev (scan, CMD_8, 34, opb, &s)); CHK (cread (scan, CMD_8, 35, opbx, &s)); CHK (cwritev (scan, CMD_8, 35, opb1, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "umaxinit: checkpoint 2:\n"); /* The following code appears to send three 256 entry, 8-bit gamma tables * to the scanner */ p = ramp; *p++ = 0; *p++ = 0; *p++ = 0; for (i = 0; i < 256; ++i) *p++ = i; for (i = 0; i < 256; ++i) *p++ = i; for (i = 0; i < 256; ++i) *p++ = i; *p++ = 0xaa; *p++ = 0xaa; res = cwritev (scan, CMD_4, p - ramp, ramp, &s); if (res != SANE_STATUS_GOOD) { DBG (4, "umaxinit: Writing ramp 1 failed (is this a 2000U?)\n"); } CHK (cwritev (scan, CMD_8, 35, opb1, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "umaxinit: checkpoint 3:\n"); /* The following code appears to send a 256 entry, 16-bit gamma table * to the scanner */ p = ramp; for (i = 0; i < 256; ++i) { *p++ = i; *p++ = 0; } res = cwrite (scan, CMD_4, p - ramp, ramp, &s); if (res != SANE_STATUS_GOOD) { DBG (4, "umaxinit: Writing ramp 2 failed (is this a 2000U?)\n"); } CHK (cwritev (scan, CMD_8, 35, opb2, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "umaxinit: checkpoint 4:\n"); /* The following code appears to send a 256 entry, 16-bit gamma table * to the scanner. */ p = ramp; for (i = 0; i < 256; ++i) { *p++ = i; *p++ = 4; } res = cwritev (scan, CMD_4, p - ramp, ramp, &s); if (res != SANE_STATUS_GOOD) { DBG (4, "umaxinit: Writing ramp 3 failed (is this a 2000U?)\n"); } CHK (cwritev (scan, CMD_8, 35, opb1, &s)); CHK (cwritev (scan, CMD_2, 16, opc, NULL)); CHK (cwritev (scan, CMD_1, 8, opd, NULL)); CHK (csend (scan, CMD_0)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "umaxinit: checkpoint 5: s = %#x\n", s); if ((s & 0x40) == 0) { DBG (4, "umaxinit: turning on lamp and restoring\n"); CHK (cwritev_opc1_lamp_ctrl (scan, UMAX_LAMP_ON)); CHK (cwritev_opb3_restore (scan)); for (i = 0; i < 60; ++i) { CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "umaxinit: s = %#x\n", s); if ((s & 0x40) != 0) break; DBG (4, "umaxinit: sleeping\n"); usleep (500000); } } DBG (4, "umaxinit: checkpoint 6\n"); CHK (csend (scan, CMD_0)); /* The following stuff used to be in umaxinit2() */ DBG (4, "umaxinit: checkpoint 7\n"); CHK (xxxops (scan)); CHK (csend (scan, CMD_0)); CHK (xxxops (scan)); CHK (cwritev (scan, CMD_8, 34, opb4, &s)); CHK (cread (scan, CMD_8, 35, opbx, &s)); CHK (cread (scan, CMD_2, 16, opcx, &s)); CHK (cwritev (scan, CMD_2, 16, opc, NULL)); CHK (cwritev (scan, CMD_1, 8, opd, NULL)); CHK (csend (scan, CMD_0)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "umaxinit: checkpoint 8: s = %d\n", s); return SANE_STATUS_GOOD; } /* Initialize and turn lamp on 2100U */ static SANE_Status umaxinit_2100U (UMAX_Handle * scan) { unsigned char opx[36]; unsigned char opy[16]; SANE_Status res; UMAX_Status_Byte s; DBG (3, "umaxinit called\n"); CHK (xxxops (scan)); CHK (csend (scan, CMD_0)); /* Turn lamp on */ cwritev_opc1_lamp_ctrl (scan, UMAX_LAMP_ON); CHK (cread (scan, CMD_8, 36, opx, &s)); CHK (cread (scan, CMD_2, 16, opy, &s)); CHK (csend (scan, CMD_0)); CHK (cread (scan, CMD_2, 0, NULL, &s)); CHK (csend (scan, CMD_0)); return SANE_STATUS_GOOD; } /* Move head 1220U */ static SANE_Status move (UMAX_Handle * scan, int distance, UMAX_Speed fine) { unsigned char opc4[16] = { 0x01, XXXX, XXXX, XXXX, 0x00, 0x00, 0x60, 0x2f, XXXX, XXXX, 0x00, 0x00, 0x00, 0x80, XXXX, 0x00 }; unsigned char opb5[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, 0xf6, 0x79, 0xbf, 0x06, 0x00, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0x13, 0x1a }; unsigned char opb7[35] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x6e, 0xf6, 0x79, 0xbf, 0x01, 0x00, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0x13, 0x1a }; unsigned char ope[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }; unsigned char ope2[3] = { 0x00, 0xff, 0x8f }; unsigned char buf[512 + PAD]; SANE_Status res; UMAX_Status_Byte s; SANE_Bool rev = distance < 0; int skip = (rev ? -distance : distance) - 1; DBG (9, "move: distance = %d, scanner_ypos = %d\n", distance, scan->scanner_ypos); PAD_ARRAY (buf, 512); if (distance == 0) return SANE_STATUS_GOOD; opc4[1] = skip << 6; opc4[2] = skip >> 2; opc4[3] = (rev ? 0x20 : 0x70) + ((skip >> 10) & 0xf); opc4[9] = rev ? 0x01 : 0x05; if (fine == UMAX_FINE) { opc4[8] = 0x2f; opc4[14] = 0xa4; } else { opc4[8] = 0x17; opc4[14] = 0xac; } scan->scanner_ypos += (fine == UMAX_FINE ? distance : 2 * distance + (rev ? -1 : 1)); scan->scanner_ypos = (scan->scanner_ypos + (rev ? 0 : 3)) & ~3; CHK (cwrite (scan, CMD_2, 16, opc4, &s)); CHK (cwrite (scan, CMD_8, 35, rev ? opb7 : opb5, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (10, "move: checkpoint 1: s = %d\n", s); CHK (csend (scan, CMD_0)); if (rev) CHK (cwrite (scan, CMD_4, 3, ope2, &s)) else CHK (cwrite (scan, CMD_4, 8, ope, &s)); CHK (csend (scan, CMD_40)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (10, "move: checkpoint 2: s = %d\n", s); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (10, "move: checkpoint 3: s = %d\n", s); CHK (cread (scan, CMD_4, 512, buf, &s)); CHK_ARRAY (buf, 512); return res; } /* Move head 2100U */ static SANE_Status move_2100U (UMAX_Handle * scan, int distance, UMAX_Speed fine) { unsigned char opc4[16] = { 0x01, XXXX, XXXX, XXXX, 0x00, 0x00, 0x60, 0x2f, XXXX, XXXX, 0x00, 0x00, 0x00, 0x80, XXXX, 0x00 }; unsigned char opb5[36] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, 0xf6, 0x79, 0xbf, 0x06, 0x00, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x2a, 0xe9, 0x68, 0xdf, 0x03, 0x1a, 0x00 }; unsigned char opb7[36] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x6e, 0xf6, 0x79, 0xbf, 0x01, 0x00, 0x00, 0x00, 0x46, 0xa0, 0x00, 0x8b, 0x49, 0x2a, 0xe9, 0x68, 0xdf, 0x03, 0x1a, 0x00 }; unsigned char ope[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }; unsigned char ope2[3] = { 0x00, 0xff, 0xff }; unsigned char buf[512]; SANE_Status res; UMAX_Status_Byte s; SANE_Bool rev = distance < 0; int skip = (rev ? -distance : distance) - 1; DBG (9, "move: distance = %d, scanner_ypos = %d\n", distance, scan->scanner_ypos); PAD_ARRAY (buf, 512); if (distance == 0) return SANE_STATUS_GOOD; opc4[1] = skip << 6; opc4[2] = skip >> 2; opc4[3] = (rev ? 0x20 : 0x70) + ((skip >> 10) & 0x0f); opc4[9] = rev ? 0x01 : 0x05; if (fine == UMAX_FINE) { opc4[8] = 0x2b; opc4[14] = 0xa4; } else { opc4[8] = 0x15; opc4[14] = 0xac; } scan->scanner_ypos += (fine == UMAX_FINE ? distance : 2 * distance + (rev ? -1 : 1)); scan->scanner_ypos = (scan->scanner_ypos + (rev ? 0 : 3)) & ~3; CHK (cwrite (scan, CMD_2, 16, opc4, &s)); CHK (cwrite (scan, CMD_8, 36, rev ? opb7 : opb5, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (10, "move: checkpoint 1: s = %d\n", s); CHK (csend (scan, CMD_0)); if (rev) CHK (cwrite (scan, CMD_4, 3, ope2, &s)) else CHK (cwrite (scan, CMD_4, 8, ope, &s)); CHK (csend (scan, CMD_40)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (10, "move: checkpoint 2: s = %d\n", s); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (10, "move: checkpoint 3: s = %d\n", s); CHK (cread (scan, CMD_4, 512, buf, &s)); CHK_ARRAY (buf, 512); return res; } /* Get pixel image 1220U */ static SANE_Status get_pixels (UMAX_Handle * scan, unsigned char *op2, unsigned char *op8, unsigned char *op1, unsigned char *op4, int len, int zpos, unsigned char *buf) { SANE_Status res; UMAX_Status_Byte s; DBG (9, "get_pixels: len = %d, zpos = %d\n", len, zpos); if (zpos == 0) CHK (csend (scan, CMD_0)); CHK (cwrite (scan, CMD_2, 16, op2, &s)); CHK (cwrite (scan, CMD_8, 35, op8, &s)); CHK (cwrite (scan, CMD_1, 8, op1, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); if (zpos == 1) CHK (csend (scan, CMD_0)); CHK (cwrite (scan, CMD_4, 8, op4, &s)); CHK (csend (scan, CMD_40)); CHK (cread (scan, CMD_2, 0, NULL, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); CHK (cread (scan, CMD_4, len, buf, &s)); return SANE_STATUS_GOOD; } /* Get pixel image 2100U */ static SANE_Status get_pixels_2100U (UMAX_Handle * scan, unsigned char *op2, unsigned char *op8, unsigned char *op1, unsigned char *op4, int len, int zpos, unsigned char *buf) { SANE_Status res; UMAX_Status_Byte s; DBG (9, "get_pixels: len = %d, zpos = %d\n", len, zpos); CHK (cwrite (scan, CMD_2, 16, op2, &s)); CHK (cwrite (scan, CMD_8, 36, op8, &s)); if (zpos == 1) CHK (cwritev (scan, CMD_1, 8, op1, &s)) else CHK (cwrite (scan, CMD_1, 8, op1, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); if (zpos == 1) CHK (csend (scan, CMD_0)); CHK (cwrite (scan, CMD_4, 8, op4, &s)); CHK (csend (scan, CMD_40)); CHK (cread (scan, CMD_2, 0, NULL, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); CHK (cread (scan, CMD_4, len, buf, &s)); return SANE_STATUS_GOOD; } /* This function locates the black stripe under scanner lid */ static int locate_black_stripe (unsigned char *img, int w, int h) { int epos, ecnt, x, y; unsigned char *p; epos = 0; ecnt = 0; p = img; for (x = 0; x < w; ++x, ++p) { int d, dmax = 0, dpos = 0; unsigned char *q = img + x; for (y = 1; y < h; ++y, q += w) { d = q[0] - q[w]; if (d > dmax) { dmax = d; dpos = y; } } if (dmax > 0) { epos += dpos; ++ecnt; } } if (ecnt == 0) epos = 70; else epos = (epos + ecnt / 2) / ecnt; return epos; } /* To find the lowest head position 1220U */ static SANE_Status find_zero (UMAX_Handle * scan) { unsigned char opc3[16] = { 0xb4, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2f, 0x2f, 0x05, 0x00, 0x00, 0x00, 0x80, 0xa4, 0x00 }; unsigned char ope1[8] = { 0x00, 0x00, 0x00, 0xaa, 0xcc, 0xee, 0x80, 0xff }; unsigned char opb6[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, 0xfb, 0xc4, 0xe5, 0x06, 0x00, 0x00, 0x60, 0x4d, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0x13, 0x1a }; unsigned char opd1[8] = { 0x06, 0xf4, 0xff, 0x81, 0x3d, 0x00, 0x08, 0x00 }; SANE_Status res; int s; unsigned char *img; DBG (9, "find_zero:\n"); img = malloc (54000); if (img == 0) { DBG (1, "out of memory (need 54000)\n"); return SANE_STATUS_NO_MEM; } CHK (csend (scan, CMD_0)); CHK (get_pixels (scan, opc3, opb6, opd1, ope1, 54000, 1, img)); #ifdef DEBUG_CALIBRATION { int w = 300, h = 180; FILE *f2 = fopen ("find_zero.pgm", "wb"); fprintf (f2, "P5\n%d %d\n255\n", w, h); fwrite (img, 1, w * h, f2); fclose (f2); } #endif s = locate_black_stripe (img, 300, 180); scan->scanner_yorg = scan->scanner_ypos + s + 64; scan->scanner_ypos += 180 + 3; scan->scanner_ypos &= ~3; free (img); return SANE_STATUS_GOOD; } /* To find the lowest head position 2100U */ static SANE_Status find_zero_2100U (UMAX_Handle * scan) { unsigned char opc3[16] = { 0xb4, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2f, 0x2b, 0x05, 0x00, 0x00, 0x00, 0x80, 0xa4, 0x00 }; unsigned char ope1[8] = { 0x00, 0x00, 0x00, 0xaa, 0xcc, 0xee, 0x80, 0xff }; unsigned char opb6[36] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, 0xfb, 0xc4, 0xe5, 0x06, 0x00, 0x00, 0x60, 0x4d, 0xa0, 0x00, 0x8b, 0x49, 0x2a, 0xe9, 0x68, 0xdf, 0x03, 0x1a, 0x00 }; unsigned char opd1[8] = { 0x06, 0xf4, 0xff, 0x81, 0x1b, 0x00, 0x08, 0x00 }; SANE_Status res; int s; unsigned char *img; DBG (9, "find_zero:\n"); img = malloc (54000); if (img == 0) { DBG (1, "out of memory (need 54000)\n"); return SANE_STATUS_NO_MEM; } CHK (csend (scan, CMD_0)); CHK (get_pixels_2100U (scan, opc3, opb6, opd1, ope1, 54000, 1, img)); #ifdef DEBUG_CALIBRATION { int w = 300, h = 180; FILE *f2 = fopen ("find_zero.pgm", "wb"); fprintf (f2, "P5\n%d %d\n255\n", w, h); fwrite (img, 1, w * h, f2); fclose (f2); } #endif s = locate_black_stripe (img, 300, 180); scan->scanner_yorg = scan->scanner_ypos + s + 64; scan->scanner_ypos += 180 + 3; scan->scanner_ypos &= ~3; free (img); return SANE_STATUS_GOOD; } /* Calibration 1220U */ /* Format of caldata: 5100 bytes of CCD calibration values 5100 bytes of CCD calibration values 5100 bytes of CCD calibration values 256 bytes of gamma data for blue 256 bytes of gamma data for green 256 bytes of gamma data for red 2 bytes of extra information */ static SANE_Status get_caldata (UMAX_Handle * scan, int color) { unsigned char opc9[16] = { XXXX, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x00, 0x17, 0x05, 0xec, 0x4e, 0x0c, XXXX, 0xac }; unsigned char opb11[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, 0xad, 0xa0, 0x49, 0x06, 0x00, 0x00, XXXX, XXXX, 0xa0, 0x00, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, 0x93, 0x1b }; unsigned char ope[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }; unsigned char opd4[8] = { 0x06, 0xf4, 0xff, 0x81, 0x3d, 0x00, XXXX, XXXX }; SANE_Status res; unsigned char *p; int h = 66; int w = color ? 3 * 5100 : 5100; int x0 = color ? 0 : 5100; int l = w * h; int i, x, y; PAD_ARRAY (scan->caldata, 16070); DBG (9, "get_caldata: color = %d\n", color); p = malloc (l); if (p == 0) { DBG (1, "out of memory (need %d)\n", l); return SANE_STATUS_NO_MEM; } memset (scan->caldata, 0, 3 * 5100); CHK (csend (scan, CMD_0)); opc9[0] = h + 4; if (color) { opc9[13] = 0x03; opb11[23] = 0xc4; opb11[24] = 0x5c; opd4[6] = 0x08; opd4[7] = 0x00; } else { opc9[13] = 0xc3; opb11[23] = 0xec; opb11[24] = 0x54; opd4[6] = 0x0c; opd4[7] = 0x40; } /* Do a test scan of the calibration strip (which is located * under the scanner's lid */ CHK (get_pixels (scan, opc9, opb11, opd4, ope, l, 0, p)); #ifdef DEBUG_CALIBRATION { FILE *f2 = fopen ("calibration.pgm", "wb"); fprintf (f2, "P5\n%d %d\n255\n", w, h); fwrite (p, 1, w * h, f2); fclose (f2); } #endif scan->scanner_ypos += (h + 4) * 2 + 3; scan->scanner_ypos &= ~3; /* The following loop computes the gain for each of the CCD pixel * elements. */ for (x = 0; x < w; ++x) { int t = 0, gn; double av, gain; for (y = 0; y < h; ++y) t += p[x + y * w]; av = (double) t / h; gain = 250 / av; gn = (int) ((gain - 0.984) * 102.547 + 0.5); if (gn < 0) gn = 0; else if (gn > 255) gn = 255; scan->caldata[x + x0] = gn; } /* Gamma table for blue */ for (i = 0; i < 256; ++i) scan->caldata[i + 3 * 5100 + 0] = i; /* Gamma table for green */ for (i = 0; i < 256; ++i) scan->caldata[i + 3 * 5100 + 256] = i; /* Gamma table for red */ for (i = 0; i < 256; ++i) scan->caldata[i + 3 * 5100 + 512] = i; free (p); CHK_ARRAY (scan->caldata, 16070); return SANE_STATUS_GOOD; } /* Calibration 2100U */ /* Format of caldata: 5100 bytes of CCD calibration values 5100 bytes of CCD calibration values 5100 bytes of CCD calibration values 256 bytes of gamma data for blue 256 bytes of gamma data for green 256 bytes of gamma data for red 2 bytes of extra information */ static SANE_Status get_caldata_2100U (UMAX_Handle * scan, int color) { unsigned char opc9[16] = { XXXX, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x00, 0x15, 0x05, XXXX, XXXX, XXXX, XXXX, 0xac, 0x00 }; unsigned char opb11[36] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6e, XXXX, XXXX, 0x46, 0x06, 0x00, 0x00, XXXX, XXXX, 0xa0, 0x00, 0x8b, 0x49, 0x2a, 0xe9, 0x68, 0xdf, 0x83, XXXX, 0x00 }; unsigned char opd4[8] = { 0x06, 0xf4, 0xff, 0x81, 0x1b, 0x00, XXXX, XXXX }; unsigned char ope[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }; /* default gamma translation table */ unsigned char ggamma[256] = { 0x00, 0x06, 0x0A, 0x0D, 0x10, 0x12, 0x14, 0x17, 0x19, 0x1B, 0x1D, 0x1F, 0x21, 0x23, 0x24, 0x26, 0x28, 0x2A, 0x2B, 0x2D, 0x2E, 0x30, 0x31, 0x33, 0x34, 0x36, 0x37, 0x39, 0x3A, 0x3B, 0x3D, 0x3E, 0x40, 0x41, 0x42, 0x43, 0x45, 0x46, 0x47, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB8, 0xB9, 0xBA, 0xBB, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xBF, 0xC0, 0xC1, 0xC2, 0xC2, 0xC3, 0xC4, 0xC5, 0xC5, 0xC6, 0xC7, 0xC8, 0xC8, 0xC9, 0xCA, 0xCB, 0xCB, 0xCC, 0xCD, 0xCE, 0xCE, 0xCF, 0xD0, 0xD1, 0xD1, 0xD2, 0xD3, 0xD4, 0xD4, 0xD5, 0xD6, 0xD6, 0xD7, 0xD8, 0xD9, 0xD9, 0xDA, 0xDB, 0xDC, 0xDC, 0xDD, 0xDE, 0xDE, 0xDF, 0xE0, 0xE1, 0xE1, 0xE2, 0xE3, 0xE3, 0xE4, 0xE5, 0xE6, 0xE6, 0xE7, 0xE8, 0xE8, 0xE9, 0xEA, 0xEA, 0xEB, 0xEC, 0xEC, 0xED, 0xEE, 0xEF, 0xEF, 0xF0, 0xF1, 0xF1, 0xF2, 0xF3, 0xF3, 0xF4, 0xF5, 0xF5, 0xF6, 0xF7, 0xF7, 0xF8, 0xF9, 0xF9, 0xFA, 0xFB, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFF }; SANE_Status res; unsigned char *p; int h = 66; int w = color ? 3 * 5100 : 5100; int x0 = color ? 0 : 5100; int l = w * h; int i, x, y; int t, gn; double av, pct; PAD_ARRAY (scan->caldata, 16070); DBG (9, "get_caldata: color = %d\n", color); p = malloc (l); if (p == 0) { DBG (1, "out of memory (need %d)\n", l); return SANE_STATUS_NO_MEM; } memset (scan->caldata, 0, 3 * 5100); CHK (csend (scan, CMD_0)); CHK (csend (scan, CMD_0)); opc9[0] = h + 4; if (color) { opc9[10] = 0xb6; opc9[11] = 0x3b; opc9[12] = 0x0c; opc9[13] = 0x03; opb11[17] = 0x7e; opb11[18] = 0xb0; opb11[23] = 0xc4; opb11[24] = 0x5c; opb11[34] = 0x1b; opd4[6] = 0x0f; opd4[7] = 0x40; } else { opc9[10] = 0xa6; opc9[11] = 0x2a; opc9[12] = 0x08; opc9[13] = 0xc2; opb11[17] = 0x7f; opb11[18] = 0xc0; opb11[23] = 0xec; opb11[24] = 0x54; opb11[34] = 0x1a; opd4[6] = 0x06; opd4[7] = 0x20; } /* Do a test scan of the calibration strip (which is located * under the scanner's lid */ CHK (get_pixels_2100U (scan, opc9, opb11, opd4, ope, l, 0, p)); #ifdef DEBUG_CALIBRATION { FILE *f2 = fopen ("calibration.pgm", "wb"); fprintf (f2, "P5\n%d %d\n255\n", w, h); fwrite (p, 1, w * h, f2); fclose (f2); } #endif scan->scanner_ypos += (h + 4) * 2 + 3; scan->scanner_ypos &= ~3; /* The following loop computes the gain for each of the CCD pixel * elements. */ for (x = 0; x < w; x++) { t = 0; for (y = 0; y < h; y++) t += p[x + y * w]; av = (double) t / h; pct = 100.0 - (av * 100.0) / 250; gn = (int) (pct / 0.57); pct = gn; av = exp((-pct)/50)*2.5+0.9; gn = gn * av; if (gn < 0) gn = 0; else if (gn > 127) gn = 127; scan->caldata[x + x0] = gn; } /* Gamma table for blue */ for (i = 0; i < 256; i++) scan->caldata[i + 3 * 5100 + 0] = ggamma[i]; /* Gamma table for green */ for (i = 0; i < 256; i++) scan->caldata[i + 3 * 5100 + 256] = ggamma[i]; /* Gamma table for red */ for (i = 0; i < 256; i++) scan->caldata[i + 3 * 5100 + 512] = ggamma[i]; free (p); CHK_ARRAY (scan->caldata, 16070); return SANE_STATUS_GOOD; } /* Sends scan user parameters from frontend 1220U */ static SANE_Status send_scan_parameters (UMAX_Handle * scan) { SANE_Status res; UMAX_Status_Byte s; /* Appears to correspond to opscan in umax_pp_low.c */ unsigned char opbgo[35] = { 0x00, 0x00, 0xb0, 0x4f, 0xd8, 0xe7, 0xfa, 0x10, 0xef, 0xc4, 0x3c, 0x71, 0x0f, 0x00, 0x04, 0x00, 0x6e, XXXX, XXXX, XXXX, 0xc4, 0x7e, 0x00, XXXX, XXXX, 0xa0, 0x0a, 0x8b, 0x49, 0x4a, 0xd0, 0x68, 0xdf, XXXX, 0x1a }; /* Appears to correspond to opsc53 in umax_pp_low.c */ unsigned char opcgo[16] = { XXXX, XXXX, XXXX, XXXX, 0xec, 0x03, XXXX, XXXX, XXXX, XXXX, 0xec, 0x4e, XXXX, XXXX, XXXX }; /* Appears to correspond to opsc04 in umax_pp_low.c */ unsigned char opdgo[8] = { 0x06, 0xf4, 0xff, 0x81, 0x3d, 0x00, XXXX, XXXX }; unsigned char subsamp[9] = { 0xff, 0xff, 0xaa, 0xaa, 0x88, 0x88, 0x88, 0x88, 0x80 }; const int xend = scan->xskip + scan->w * scan->xsamp + (scan->xsamp + 1) / 2; const int ytot = scan->hexp * scan->ysamp + 12; opbgo[17] = scan->xskip % 256; opbgo[18] = ((scan->xskip >> 8) & 0xf) + (xend << 4); opbgo[19] = xend >> 4; opbgo[33] = 0x33 + ((xend & 0x1000) >> 5) + ((scan->xskip & 0x1000) >> 6); /* bytes per line */ opbgo[23] = scan->color ? 0xc6 : 0x77; opbgo[24] = scan->color ? 0x5b : 0x4a; /* Scan height */ opcgo[0] = ytot; opcgo[1] = ((ytot >> 8) & 0x3f) + (scan->yskip << 6); opcgo[2] = scan->yskip >> 2; opcgo[3] = 0x50 + ((scan->yskip >> 10) & 0xf); /* This is what used to be here: opcgo[6] = bh == h? 0: 0x60; // a guess I replaced it with what umax_pp_low.c uses, since it made more sense */ opcgo[6] = (scan->ydpi <= 300) ? 0x00 : 0x60; opcgo[8] = (scan->ydpi <= 300) ? 0x17 : 0x2F; opcgo[9] = (scan->ydpi >= 300) ? 0x05 : 0x07; opcgo[14] = (scan->ydpi == 600) ? 0xa4 : 0xac; opcgo[7] = scan->color ? 0x2F : 0x40; opcgo[12] = scan->color ? 0x10 : 0x0C; opcgo[13] = scan->color ? 0x04 : 0xc3; opdgo[6] = scan->color ? 0x88 : 0x8c; opdgo[7] = scan->color ? 0x00 : 0x40; DBG (3, "send_scan_parameters: xskip = %d, yskip = %d\n", scan->xskip, scan->yskip); CHK (csend (scan, CMD_0)); CHK (csend (scan, CMD_0)); CHK (cwritev (scan, CMD_2, 16, opcgo, &s)); CHK (cwritev (scan, CMD_8, 35, opbgo, &s)); CHK (cwritev (scan, CMD_1, 8, opdgo, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "send_scan_parameters: checkpoint 1: s = %d\n", s); /* Loads the new calibration data (that was computed by get_caldata) into the scanner */ scan->caldata[16068] = subsamp[scan->xsamp]; scan->caldata[16069] = subsamp[scan->ysamp]; CHK (cwrite (scan, CMD_4, 16070, scan->caldata, &s)); CHK (csend (scan, CMD_40)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "send_scan_parameters: checkpoint 2: s = %d\n", s); return SANE_STATUS_GOOD; } /* Sends scan user parameters from frontend 2100U */ static SANE_Status send_scan_parameters_2100U (UMAX_Handle * scan) { SANE_Status res; UMAX_Status_Byte s; int bpl; /* Appears to correspond to opscan in umax_pp_low.c */ unsigned char opbgo[36] = { 0x00, 0x00, 0xb0, 0x4f, 0xd8, 0xe7, 0xfa, 0x10, 0xef, 0xc4, 0x3c, 0x71, 0x0f, 0x00, 0x04, 0x00, 0x6e, XXXX, XXXX, XXXX, 0xc4, 0x7e, 0x00, XXXX, XXXX, 0xa0, 0x0a, 0x8b, 0x49, 0x2a, 0xe9, 0x68, 0xdf, XXXX, 0x1a, 0x00 }; /* Appears to correspond to opsc53 in umax_pp_low.c */ unsigned char opcgo[16] = { XXXX, XXXX, XXXX, XXXX, 0xec, 0x03, 0x60, XXXX, XXXX, XXXX, XXXX, XXXX, XXXX, XXXX, XXXX, 0x00 }; /* Appears to correspond to opsc04 in umax_pp_low.c */ unsigned char opdgo[8] = { 0x06, 0xf4, 0xff, 0x81, 0x1b, 0x00, XXXX, XXXX }; unsigned char subsamp[9] = { 0xff, 0xff, 0xaa, 0xaa, 0x88, 0x88, 0x88, 0x88, 0x80 }; const int xend = scan->xskip + scan->w * scan->xsamp + (scan->xsamp + 1) / 2; const int ytot = scan->hexp * scan->ysamp + 12; opbgo[17] = scan->xskip % 256; opbgo[18] = ((scan->xskip >> 8) & 0x0f) + (xend << 4); opbgo[19] = xend >> 4; opbgo[33] = 0x23 + ((xend & 0x1000) >> 5) + ((scan->xskip & 0x1000) >> 6); /* bytes per line */ bpl = (scan->color ? 3 : 1) * scan->w * scan->xdpi; opbgo[23] = bpl % 256; opbgo[24] = 0x41 + ((bpl / 256) & 0x1f); /* Scan height */ opcgo[0] = ytot; opcgo[1] = ((ytot >> 8) & 0x3f) + (scan->yskip << 6); opcgo[2] = (scan->yskip >> 2); opcgo[3] = 0x50 + ((scan->yskip >> 10) & 0x0f); opcgo[6] = (scan->ydpi <= 300) ? 0x00 : 0x60; opcgo[8] = (scan->ydpi <= 300) ? 0x17 : 0x2F; opcgo[9] = (scan->ydpi >= 300) ? 0x05 : 0x07; opcgo[14] = (scan->ydpi == 600) ? 0xa4 : 0xac; opcgo[7] = scan->color ? 0x2f : 0x40; opcgo[10] = scan->color ? 0xb6 : 0xa6; opcgo[11] = scan->color ? 0x3b : 0x2a; opcgo[12] = scan->color ? 0x0c : 0x08; opcgo[13] = scan->color ? 0x03 : 0xc2; opdgo[6] = scan->color ? 0x8f : 0x86; opdgo[7] = scan->color ? 0x40 : 0x20; DBG (3, "send_scan_parameters: xskip = %d, yskip = %d\n", scan->xskip, scan->yskip); CHK (csend (scan, CMD_0)); CHK (csend (scan, CMD_0)); CHK (cwritev (scan, CMD_2, 16, opcgo, &s)); CHK (cwritev (scan, CMD_8, 36, opbgo, &s)); CHK (cwritev (scan, CMD_1, 8, opdgo, &s)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "send_scan_parameters: checkpoint 1: s = %d\n", s); /* Loads the new calibration data (that was computed by get_caldata) into the scanner */ scan->caldata[16068] = subsamp[scan->xsamp]; scan->caldata[16069] = subsamp[scan->ysamp]; CHK (cwrite (scan, CMD_4, 16070, scan->caldata, &s)); CHK (csend (scan, CMD_40)); CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "send_scan_parameters: checkpoint 2: s = %d\n", s); return SANE_STATUS_GOOD; } /* Read raw data */ static SANE_Status read_raw_data (UMAX_Handle * scan, unsigned char *data, int len) { SANE_Status res; UMAX_Status_Byte s; CHK (cread (scan, CMD_2, 0, NULL, &s)); CHK (cread (scan, CMD_4, len, data, &s)); return SANE_STATUS_GOOD; } /* Read raw strip color */ static SANE_Status read_raw_strip_color (UMAX_Handle * scan) { /** yres = 75 => ydpi = 150 => ysamp = 2 => yoff_scale = 8 yres = 150 => ydpi = 150 => ysamp = 1 => yoff_scale = 4 yres = 300 => ydpi = 300 => ysamp = 1 => yoff_scale = 2 yres = 600 => ydpi = 600 => ysamp = 1 => yoff_scale = 1 */ const int yoff_scale = 600 * scan->ysamp / scan->ydpi; const int linelen = 3 * scan->w; /* yoff_scale = 8 => roff = 5 * w, goff = 1 * w, boff = 0 * w, hextra = 1 yoff_scale = 4 => roff = 8 * w, goff = 4 * w, boff = 0 * w, hextra = 2 yoff_scale = 2 => roff = 14 * w, goff = 7 * w, boff = 0 * w, hextra = 4 yoff_scale = 1 => roff = 26 * w, goff = 13 * w, boff = 0 * w, hextra = 8 */ const int hextra = 8 / yoff_scale; SANE_Status res; int lines_to_read = scan->hexp; DBG (9, "read_raw_strip_color: hexp = %d, bh = %d\n", scan->hexp, scan->bh); if (scan->maxh == -1) { DBG (10, "read_raw_strip_color: filling buffer for the first time\n"); if (lines_to_read > scan->bh) lines_to_read = scan->bh; CHK (read_raw_data (scan, scan->p, lines_to_read * linelen)); scan->maxh = lines_to_read - hextra; } else { DBG (10, "read_raw_strip_color: reading new rows into buffer\n"); memmove (scan->p, scan->p + (scan->bh - hextra) * linelen, hextra * linelen); if (lines_to_read > (scan->bh - hextra)) lines_to_read = scan->bh - hextra; CHK (read_raw_data (scan, scan->p + hextra * linelen, lines_to_read * linelen)); scan->maxh = lines_to_read; } scan->hexp -= lines_to_read; scan->x = 0; scan->y = 0; return SANE_STATUS_GOOD; } /* Read raw strip grey */ static SANE_Status read_raw_strip_gray (UMAX_Handle * scan) { const int linelen = scan->w; SANE_Status res; int lines_to_read = scan->bh; DBG (9, "read_raw_strip_gray: hexp = %d\n", scan->hexp); if (lines_to_read > scan->hexp) lines_to_read = scan->hexp; scan->hexp -= lines_to_read; CHK (read_raw_data (scan, scan->p, lines_to_read * linelen)); scan->maxh = lines_to_read; scan->x = 0; scan->y = 0; return SANE_STATUS_GOOD; } /* Read raw strip */ static SANE_Status read_raw_strip (UMAX_Handle * scan) { if (scan->color) return read_raw_strip_color (scan); else return read_raw_strip_gray (scan); } /* Set scan user pamaters Frontend */ static SANE_Status UMAX_set_scan_parameters (UMAX_Handle * scan, const int color, const int xo, const int yo, const int w, const int h, const int xres, const int yres) { /* Validate the input parameters */ int left = xo; int top = yo; int right = xo + w * 600 / xres; int bottom = yo + h * 600 / yres; DBG (2, "UMAX_set_scan_parameters:\n"); DBG (2, "color = %d \n", color); DBG (2, "xo = %d, yo = %d\n", xo, yo); DBG (2, "w = %d, h = %d\n", w, h); DBG (2, "xres = %d, yres = %d\n", xres, yres); DBG (2, "left = %d, top = %d\n", left, top); DBG (2, "right = %d, bottom = %d\n", right, bottom); if ((left < 0) || (right > UMAX_MAX_WIDTH)) return SANE_STATUS_INVAL; if ((top < 0) || (bottom > UMAX_MAX_HEIGHT)) return SANE_STATUS_INVAL; if (((right - left) < 10) || ((bottom - top) < 10)) return SANE_STATUS_INVAL; if ((xres != 75) && (xres != 150) && (xres != 300) && (xres != 600)) return SANE_STATUS_INVAL; if ((yres != 75) && (yres != 150) && (yres != 300) && (yres != 600)) return SANE_STATUS_INVAL; /* If we get this far, begin initializing the data structure */ scan->color = color; scan->w = w; scan->h = h; scan->xo = xo; scan->yo = yo; /* The scanner has a fixed X resolution of 600 dpi, but supports three choices for the Y resolution. We must choose an appropriate physical resolution and the corresponding sampling value. It is not clear to me why the choice depends on whether we are scanning in color or not, but the original code did this and I didn't want to mess with it. Physical X resolution choice: xres = 75 => xdpi = 600 (xsamp = 8) xres = 150 => xdpi = 600 (xsamp = 4) xres = 300 => xdpi = 600 (xsamp = 2) xres = 600 => xdpi = 600 (xsamp = 1) Physical Y resolution choice (if color): yres = 75 => ydpi = 150 (ysamp = 2) yres = 150 => ydpi = 150 (ysamp = 1) yres = 300 => ydpi = 300 (ysamp = 1) yres = 600 => ydpi = 600 (ysamp = 1) Physical Y resolution choice (if not color): yres = 75 => ydpi = 300 (ysamp = 4) yres = 150 => ydpi = 300 (ysamp = 2) yres = 300 => ydpi = 300 (ysamp = 1) yres = 600 => ydpi = 600 (ysamp = 1) */ scan->xdpi = 600; if (yres <= 150 && color) scan->ydpi = 150; else if (yres > 300) scan->ydpi = 600; else scan->ydpi = 300; scan->xsamp = scan->xdpi / xres; scan->ysamp = scan->ydpi / yres; return SANE_STATUS_GOOD; } /* Start actual scan 1220U */ static SANE_Status UMAX_start_scan (UMAX_Handle * scan) { SANE_Status res; int linelen; int yd; DBG (3, "UMAX_start_scan called\n"); if (scan->color) { const int yoff_scale = 600 * scan->ysamp / scan->ydpi; const int hextra = 8 / yoff_scale; linelen = 3 * scan->w; scan->hexp = scan->h + hextra; } else { linelen = scan->w; scan->hexp = scan->h; } scan->bh = BUFFER_SIZE / linelen; scan->p = malloc (scan->bh * linelen); if (scan->p == 0) return SANE_STATUS_NO_MEM; DBG (4, "UMAX_start_scan: bh = %d, linelen = %d\n", scan->bh, linelen); scan->maxh = -1; scan->done = 0; /* Initialize the scanner and position the scan head */ CHK (umaxinit (scan)); /* This scans in the black and white calibration strip that * is located under the scanner's lid. The scan of that strip * is used to pick correct values for the CCD calibration * values */ scan->scanner_ypos = 0; CHK (move (scan, 196, UMAX_NOT_FINE)); CHK (find_zero (scan)); CHK (move (scan, scan->scanner_yorg - 232 - scan->scanner_ypos, UMAX_FINE)); CHK (get_caldata (scan, scan->color)); /* This moves the head back to the starting position */ yd = scan->scanner_yorg + scan->yo - scan->scanner_ypos; if (yd < 0) CHK (move (scan, yd, UMAX_FINE)); if (yd > 300) CHK (move (scan, (yd - 20) / 2, UMAX_NOT_FINE)); yd = scan->scanner_yorg + scan->yo - scan->scanner_ypos; scan->yskip = yd / (600 / scan->ydpi); scan->xskip = scan->xo / (600 / scan->xdpi); /* Read in the first chunk of raw data */ CHK (send_scan_parameters (scan)); CHK (read_raw_strip (scan)); DBG (4, "UMAX_start_scan successful\n"); return SANE_STATUS_GOOD; } /* Start actual scan 2100U */ static SANE_Status UMAX_start_scan_2100U (UMAX_Handle * scan) { SANE_Status res; int linelen; int yd; DBG (3, "UMAX_start_scan called\n"); if (scan->color) { const int yoff_scale = 600 * scan->ysamp / scan->ydpi; const int hextra = 8 / yoff_scale; linelen = 3 * scan->w; scan->hexp = scan->h + hextra; } else { linelen = scan->w; scan->hexp = scan->h; } scan->bh = BUFFER_SIZE / linelen; scan->p = malloc (scan->bh * linelen); if (scan->p == 0) return SANE_STATUS_NO_MEM; DBG (4, "UMAX_start_scan: bh = %d, linelen = %d\n", scan->bh, linelen); scan->maxh = -1; scan->done = 0; /* Initialize the scanner and position the scan head */ CHK (umaxinit_2100U (scan)); /* This scans in the black and white calibration strip that * is located under the scanner's lid. The scan of that strip * is used to pick correct values for the CCD calibration * values */ scan->scanner_ypos = 0; CHK (move_2100U (scan, 196, UMAX_NOT_FINE)); CHK (find_zero_2100U (scan)); CHK (move_2100U (scan, scan->scanner_yorg - 232 - scan->scanner_ypos, UMAX_FINE)); CHK (get_caldata_2100U (scan, scan->color)); /* This moves the head back to the starting position */ yd = scan->scanner_yorg + scan->yo - scan->scanner_ypos; if (yd < 0) CHK (move_2100U (scan, yd, UMAX_FINE)); if (yd > 300) CHK (move_2100U (scan, (yd - 20) / 2, UMAX_NOT_FINE)); yd = scan->scanner_yorg + scan->yo - scan->scanner_ypos; scan->yskip = yd / (600 / scan->ydpi); scan->xskip = scan->xo / (600 / scan->xdpi); /* Read in the first chunk of raw data */ CHK (send_scan_parameters_2100U (scan)); CHK (read_raw_strip (scan)); DBG (4, "UMAX_start_scan successful\n"); return SANE_STATUS_GOOD; } /* Set lamp state */ static SANE_Status UMAX_set_lamp_state (UMAX_Handle * scan, UMAX_Lamp_State state) { SANE_Status res; DBG (3, "UMAX_set_lamp_state: state = %d\n", (int) state); CHK (csend (scan, CMD_0)); CHK (cwritev_opc1_lamp_ctrl (scan, state)); return SANE_STATUS_GOOD; } /* Park head 1220U */ static SANE_Status UMAX_park_head (UMAX_Handle * scan) { SANE_Status res; UMAX_Status_Byte s; int i; DBG (3, "UMAX_park_head called\n"); CHK (csend (scan, CMD_0)); /* WARNING: Must call cwritev_opc1_lamp_ctrl before cwritev_opb3_restore, * otherwise the head moves the wrong way and makes ugly grinding noises. */ CHK (cwritev_opc1_lamp_ctrl (scan, UMAX_LAMP_ON)); CHK (cwritev_opb3_restore (scan)); for (i = 0; i < 60; ++i) { CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "UMAX_park_head: s = %#x\n", s); if ((s & 0x40) != 0) break; DBG (4, "UMAX_park_head: sleeping\n"); usleep (500000); } scan->scanner_ypos = 0; return SANE_STATUS_GOOD; } /* Park head 2100U */ static SANE_Status UMAX_park_head_2100U (UMAX_Handle * scan) { SANE_Status res; UMAX_Status_Byte s; int i; DBG (3, "UMAX_park_head called\n"); CHK (csend (scan, CMD_0)); /* WARNING: Must call cwritev_opc1_lamp_ctrl before cwritev_opb3_restore, * otherwise the head moves the wrong way and makes ugly grinding noises. */ CHK (cwritev_opc1_lamp_ctrl (scan, UMAX_LAMP_ON)); CHK (cwritev_opb3_restore_2100U (scan)); for (i = 0; i < 60; ++i) { CHK (cread (scan, CMD_2, 0, NULL, &s)); DBG (4, "UMAX_park_head: s = %#x\n", s); if ((s & 0x40) != 0) break; DBG (4, "UMAX_park_head: sleeping\n"); usleep (500000); } /* CHK (csend (scan, CMD_0)); CHK (csend (scan, CMD_0)); */ scan->scanner_ypos = 0; return SANE_STATUS_GOOD; } /* Finish scan */ static SANE_Status UMAX_finish_scan (UMAX_Handle * scan) { DBG (3, "UMAX_finish_scan:\n"); if (scan->p) free (scan->p); scan->p = NULL; return SANE_STATUS_GOOD; } /* RGB decoding for a color scan */ static SANE_Status UMAX_get_rgb (UMAX_Handle * scan, unsigned char *rgb) { if (scan->color) { const int linelen = 3 * scan->w; const int yoff_scale = 600 * scan->ysamp / scan->ydpi; const int roff = (8 / yoff_scale * 3 + 2) * scan->w; const int goff = (4 / yoff_scale * 3 + 1) * scan->w; const int boff = 0; unsigned char *base = scan->p + (scan->y * linelen) + scan->x; rgb[0] = base[roff]; rgb[1] = base[goff]; rgb[2] = base[boff]; } else { const int linelen = scan->w; unsigned char *base = scan->p + (scan->y * linelen) + (scan->x); rgb[0] = base[0]; rgb[1] = base[0]; rgb[2] = base[0]; } if (!(((scan->x + 1) == scan->w) && ((scan->y + 1) == scan->maxh))) { ++scan->x; if (scan->x == scan->w) { ++scan->y; scan->x = 0; } return SANE_STATUS_GOOD; } if (scan->hexp <= 0) { DBG (4, "UMAX_get_rgb: setting done flag\n"); scan->done = 1; return SANE_STATUS_GOOD; } return read_raw_strip (scan); } /* Close device */ static SANE_Status UMAX_close_device (UMAX_Handle * scan) { DBG (3, "UMAX_close_device:\n"); sanei_usb_close (scan->fd); return SANE_STATUS_GOOD; } /* Open device */ static SANE_Status UMAX_open_device (UMAX_Handle * scan, const char *dev) { SANE_Word vendor; SANE_Word product; SANE_Status res; DBG (3, "UMAX_open_device: `%s'\n", dev); res = sanei_usb_open (dev, &scan->fd); if (res != SANE_STATUS_GOOD) { DBG (1, "UMAX_open_device: couldn't open device `%s': %s\n", dev, sane_strstatus (res)); return res; } #ifndef NO_AUTODETECT /* We have opened the device. Check that it is a USB scanner. */ if (sanei_usb_get_vendor_product (scan->fd, &vendor, &product) != SANE_STATUS_GOOD) { DBG (1, "UMAX_open_device: sanei_usb_get_vendor_product failed\n"); /* This is not a USB scanner, or SANE or the OS doesn't support it. */ sanei_usb_close (scan->fd); scan->fd = -1; return SANE_STATUS_UNSUPPORTED; } /* Make sure we have a UMAX scanner */ if (vendor != 0x1606) { DBG (1, "UMAX_open_device: incorrect vendor\n"); sanei_usb_close (scan->fd); scan->fd = -1; return SANE_STATUS_UNSUPPORTED; } /* Now check whether it is a scanner we know about */ switch (product) { case ASTRA_2000U: /* The UMAX Astra 2000U is only partially supported by this driver. Expect severe color problems! :) */ DBG (1, "UMAX_open_device: Scanner is a 2000U. Expect color problems :)\n"); scan->model = ASTRA_2000U; break; case ASTRA_2100U: scan->model = ASTRA_2100U; break; case ASTRA_1220U: scan->model = ASTRA_1220U; break; default: DBG (1, "UMAX_open_device: unknown product number\n"); sanei_usb_close (scan->fd); scan->fd = -1; return SANE_STATUS_UNSUPPORTED; } #endif res = csend (scan, CMD_0); if (res != SANE_STATUS_GOOD) UMAX_close_device (scan); CHK (res); res = xxxops (scan); if (res != SANE_STATUS_GOOD) UMAX_close_device (scan); CHK (res); return SANE_STATUS_GOOD; } /* Get scanner model name */ static const char * UMAX_get_device_name (UMAX_Handle * scan) { switch (scan->model) { case ASTRA_1220U: return "Astra 1220U"; case ASTRA_2000U: return "Astra 2000U"; case ASTRA_2100U: return "Astra 2100U"; } return "Unknown"; } /* End */ sane-backends-1.0.29/backend/hp-accessor.h0000666000000000000000000001010713615534521015147 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Geoffrey T. Dairiki 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP Scanners supporting HP Scanner Control Language (SCL). */ #ifndef HP_ACCESSOR_H_INCLUDED #define HP_ACCESSOR_H_INCLUDED #include "hp.h" HpData sanei_hp_data_new (void); HpData sanei_hp_data_dup (HpData orig); void sanei_hp_data_destroy (HpData this); HpAccessor sanei_hp_accessor_new (HpData data, size_t size); HpAccessor sanei_hp_accessor_int_new (HpData data); HpAccessor sanei_hp_accessor_bool_new (HpData data); HpAccessor sanei_hp_accessor_fixed_new (HpData data); HpAccessor sanei_hp_accessor_choice_new(HpData data, HpChoice choices, hp_bool_t may_change); HpAccessor sanei_hp_accessor_vector_new(HpData data, unsigned length, unsigned depth); HpAccessor sanei_hp_accessor_gamma_vector_new(HpData data, unsigned length, unsigned depth); HpAccessor sanei_hp_accessor_matrix_vector_new(HpData data, unsigned length, unsigned depth); HpAccessor sanei_hp_accessor_subvector_new(HpAccessorVector super, unsigned nchan, unsigned chan); HpAccessor sanei_hp_accessor_geometry_new (HpAccessor val, HpAccessor lim, hp_bool_t is_br, HpAccessor res); SANE_Status sanei_hp_accessor_get (HpAccessor this, HpData data, void * valp); SANE_Status sanei_hp_accessor_set (HpAccessor this, HpData data, void * valp); int sanei_hp_accessor_getint(HpAccessor this, HpData data); void sanei_hp_accessor_setint(HpAccessor this, HpData data, int v); const void *sanei_hp_accessor_data (HpAccessor this, HpData data); void * sanei__hp_accessor_data (HpAccessor this, HpData data); size_t sanei_hp_accessor_size (HpAccessor this); unsigned sanei_hp_accessor_vector_length (HpAccessorVector this); SANE_Fixed sanei_hp_accessor_vector_minval (HpAccessorVector this); SANE_Fixed sanei_hp_accessor_vector_maxval (HpAccessorVector this); SANE_Int sanei_hp_accessor_choice_maxsize (HpAccessorChoice this); SANE_String_Const * sanei_hp_accessor_choice_strlist (HpAccessorChoice this, HpOptSet optset, HpData data, const HpDeviceInfo *info); #endif /* HP_ACCESSOR_H_INCLUDED */ sane-backends-1.0.29/backend/epsonds-net.c0000666000000000000000000001336013615534521015176 00000000000000/* * 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; } sane-backends-1.0.29/backend/teco2.conf.in0000666000000000000000000000117213615534521015061 00000000000000# VM3564 RELISYS AVEC II S3 scanner scsi "RELISYS" "AVEC II S3" # VM356A Primax Jewel 4800 scanner scsi "Primax" "Jewel" # VM356A Relisys APOLLO Express 3 scsi "RELISYS" "APOLLO Express 3" # VM3575 Relisys AVEC Super 3 scsi "RELISYS" "AVEC Super 3" # VM3575 Relisys SCORPIO Super 3 # VM3575 Mustek ScanMagic 4830S # VM6586 Relisys SCORPIO Pro-S scsi "" "Flatbed Scanner" # VM656A Relisys APOLLO Express 6 scsi "RELISYS" "APOLLO Express 6" # VM6575 Relisys SCORPIO Pro scsi "RELISYS" "SCORPIO Pro" # VM6575 Primax Profi 9600 scsi "Primax" "Profi 9600" # VM6586 Primax Profi 19200 scsi "Primax" "Profi 19200" /dev/scanner sane-backends-1.0.29/backend/hp5400_sane.c0000666000000000000000000006357013615534521014675 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2003 Martijn van Oosterhout Copyright (C) 2003 Thomas Soumarmon Originally copied from HP3300 testtools. Original notice follows: Copyright (C) 2001 Bertrik Sikken (bertrik@zonnet.nl) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* SANE interface for hp54xx scanners. Prototype. Parts of this source were inspired by other backends. */ #include "../include/sane/config.h" /* definitions for debug */ #include "hp5400_debug.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_usb.h" #include /* malloc, free */ #include /* memcpy */ #include #include #define HP5400_CONFIG_FILE "hp5400.conf" #include "hp5400.h" /* includes for data transfer methods */ #include "hp5400.h" #ifdef STANDALONE #include "hp5400_scanner.h" #endif #if defined(LINUX_USB_SUPPORT) #include "hp5400_linux.c" #endif #if defined(USCANNER_SUPPORT) #include "hp5400_uscanner.c" #endif #if defined(LIBUSB_SUPPORT) #include "hp5400_libusb.c" #endif #if defined(LIBIEEE1284_SUPPORT) #include "hp5400_ieee1284.c" #endif /* other definitions */ #ifndef min #define min(A,B) (((A)<(B)) ? (A) : (B)) #endif #ifndef max #define max(A,B) (((A)>(B)) ? (A) : (B)) #endif #define TRUE 1 #define FALSE 0 #define MM_TO_PIXEL(_mm_, _dpi_) ((_mm_) * (_dpi_) / 25.4) #define PIXEL_TO_MM(_pixel_, _dpi_) ((_pixel_) * 25.4 / (_dpi_)) #define NUM_GAMMA_ENTRIES 65536 /* options enumerator */ typedef enum { optCount = 0, optGroupGeometry, optTLX, optTLY, optBRX, optBRY, optDPI, optGroupImage, optGammaTableRed, /* Gamma Tables */ optGammaTableGreen, optGammaTableBlue, optLast, /* Disable the offset code */ optGroupMisc, optOffsetX, optOffsetY /* put temporarily disabled options here after optLast */ /* optLamp, */ } EOptionIndex; typedef union { SANE_Word w; SANE_Word *wa; /* word array */ SANE_String s; } TOptionValue; typedef struct { SANE_Option_Descriptor aOptions[optLast]; TOptionValue aValues[optLast]; TScanParams ScanParams; THWParams HWParams; TDataPipe DataPipe; int iLinesLeft; SANE_Int *aGammaTableR; /* a 16-to-16 bit color lookup table */ SANE_Int *aGammaTableG; /* a 16-to-16 bit color lookup table */ SANE_Int *aGammaTableB; /* a 16-to-16 bit color lookup table */ int fScanning; /* TRUE if actively scanning */ int fCanceled; } TScanner; /* linked list of SANE_Device structures */ typedef struct TDevListEntry { struct TDevListEntry *pNext; SANE_Device dev; char* devname; } TDevListEntry; /* Device filename for USB access */ char usb_devfile[128]; static TDevListEntry *_pFirstSaneDev = 0; static int iNumSaneDev = 0; static const SANE_Device **_pSaneDevList = 0; /* option constraints */ static const SANE_Range rangeGammaTable = {0, 65535, 1}; #ifdef SUPPORT_2400_DPI static const SANE_Int setResolutions[] = {6, 75, 150, 300, 600, 1200, 2400}; #else static const SANE_Int setResolutions[] = {5, 75, 150, 300, 600, 1200}; #endif static const SANE_Range rangeXmm = {0, 220, 1}; static const SANE_Range rangeYmm = {0, 300, 1}; static const SANE_Range rangeXoffset = {0, 20, 1}; static const SANE_Range rangeYoffset = {0, 70, 1}; static const SANE_Int offsetX = 5; static const SANE_Int offsetY = 52; static void _InitOptions(TScanner *s) { int i, j; SANE_Option_Descriptor *pDesc; TOptionValue *pVal; /* set a neutral gamma */ if( s->aGammaTableR == NULL ) /* Not yet allocated */ { s->aGammaTableR = malloc( NUM_GAMMA_ENTRIES * sizeof( SANE_Int ) ); s->aGammaTableG = malloc( NUM_GAMMA_ENTRIES * sizeof( SANE_Int ) ); s->aGammaTableB = malloc( NUM_GAMMA_ENTRIES * sizeof( SANE_Int ) ); for (j = 0; j < NUM_GAMMA_ENTRIES; j++) { s->aGammaTableR[j] = j; s->aGammaTableG[j] = j; s->aGammaTableB[j] = j; } } for (i = optCount; i < optLast; i++) { pDesc = &s->aOptions[i]; pVal = &s->aValues[i]; /* defaults */ pDesc->name = ""; pDesc->title = ""; pDesc->desc = ""; pDesc->type = SANE_TYPE_INT; pDesc->unit = SANE_UNIT_NONE; pDesc->size = sizeof(SANE_Word); pDesc->constraint_type = SANE_CONSTRAINT_NONE; pDesc->cap = 0; switch (i) { case optCount: pDesc->title = SANE_TITLE_NUM_OPTIONS; pDesc->desc = SANE_DESC_NUM_OPTIONS; pDesc->cap = SANE_CAP_SOFT_DETECT; pVal->w = (SANE_Word)optLast; break; case optGroupGeometry: pDesc->title = "Geometry"; pDesc->type = SANE_TYPE_GROUP; pDesc->size = 0; break; case optTLX: pDesc->name = SANE_NAME_SCAN_TL_X; pDesc->title = SANE_TITLE_SCAN_TL_X; pDesc->desc = SANE_DESC_SCAN_TL_X; pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeXmm; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = rangeXmm.min + offsetX; break; case optTLY: pDesc->name = SANE_NAME_SCAN_TL_Y; pDesc->title = SANE_TITLE_SCAN_TL_Y; pDesc->desc = SANE_DESC_SCAN_TL_Y; pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeYmm; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = rangeYmm.min + offsetY; break; case optBRX: pDesc->name = SANE_NAME_SCAN_BR_X; pDesc->title = SANE_TITLE_SCAN_BR_X; pDesc->desc = SANE_DESC_SCAN_BR_X; pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeXmm; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = rangeXmm.max + offsetX; break; case optBRY: pDesc->name = SANE_NAME_SCAN_BR_Y; pDesc->title = SANE_TITLE_SCAN_BR_Y; pDesc->desc = SANE_DESC_SCAN_BR_Y; pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeYmm; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = rangeYmm.max + offsetY; break; case optDPI: pDesc->name = SANE_NAME_SCAN_RESOLUTION; pDesc->title = SANE_TITLE_SCAN_RESOLUTION; pDesc->desc = SANE_DESC_SCAN_RESOLUTION; pDesc->unit = SANE_UNIT_DPI; pDesc->constraint_type = SANE_CONSTRAINT_WORD_LIST; pDesc->constraint.word_list = setResolutions; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = setResolutions[1]; break; case optGroupImage: pDesc->title = SANE_I18N("Image"); pDesc->type = SANE_TYPE_GROUP; pDesc->size = 0; break; case optGammaTableRed: pDesc->name = SANE_NAME_GAMMA_VECTOR_R; pDesc->title = SANE_TITLE_GAMMA_VECTOR_R; pDesc->desc = SANE_DESC_GAMMA_VECTOR_R; pDesc->size = NUM_GAMMA_ENTRIES * sizeof( SANE_Int ); pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeGammaTable; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->wa = s->aGammaTableR; break; case optGammaTableGreen: pDesc->name = SANE_NAME_GAMMA_VECTOR_G; pDesc->title = SANE_TITLE_GAMMA_VECTOR_G; pDesc->desc = SANE_DESC_GAMMA_VECTOR_G; pDesc->size = NUM_GAMMA_ENTRIES * sizeof( SANE_Int ); pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeGammaTable; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->wa = s->aGammaTableG; break; case optGammaTableBlue: pDesc->name = SANE_NAME_GAMMA_VECTOR_B; pDesc->title = SANE_TITLE_GAMMA_VECTOR_B; pDesc->desc = SANE_DESC_GAMMA_VECTOR_B; pDesc->size = NUM_GAMMA_ENTRIES * sizeof( SANE_Int ); pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeGammaTable; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->wa = s->aGammaTableB; break; case optGroupMisc: pDesc->title = SANE_I18N("Miscellaneous"); pDesc->type = SANE_TYPE_GROUP; pDesc->size = 0; break; case optOffsetX: pDesc->title = SANE_I18N("offset X"); pDesc->desc = SANE_I18N("Hardware internal X position of the scanning area."); pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeXoffset; pDesc->cap = SANE_CAP_SOFT_SELECT; pVal->w = offsetX; break; case optOffsetY: pDesc->title = SANE_I18N("offset Y"); pDesc->desc = SANE_I18N("Hardware internal Y position of the scanning area."); pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeYoffset; pDesc->cap = SANE_CAP_SOFT_SELECT; pVal->w = offsetY; break; #if 0 case optLamp: pDesc->name = "lamp"; pDesc->title = SANE_I18N("Lamp status"); pDesc->desc = SANE_I18N("Switches the lamp on or off."); pDesc->type = SANE_TYPE_BOOL; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; /* switch the lamp on when starting for first the time */ pVal->w = SANE_TRUE; break; #endif #if 0 case optCalibrate: pDesc->name = "calibrate"; pDesc->title = SANE_I18N("Calibrate"); pDesc->desc = SANE_I18N("Calibrates for black and white level."); pDesc->type = SANE_TYPE_BUTTON; pDesc->cap = SANE_CAP_SOFT_SELECT; pDesc->size = 0; break; #endif default: HP5400_DBG(DBG_ERR, "Uninitialised option %d\n", i); break; } } } static int _ReportDevice(TScannerModel *pModel, const char *pszDeviceName) { TDevListEntry *pNew, *pDev; HP5400_DBG(DBG_MSG, "hp5400: _ReportDevice '%s'\n", pszDeviceName); pNew = malloc(sizeof(TDevListEntry)); if (!pNew) { HP5400_DBG(DBG_ERR, "no mem\n"); return -1; } /* add new element to the end of the list */ if (_pFirstSaneDev == NULL) { _pFirstSaneDev = pNew; } else { for (pDev = _pFirstSaneDev; pDev->pNext; pDev = pDev->pNext) { ; } pDev->pNext = pNew; } /* fill in new element */ pNew->pNext = 0; /* we use devname to avoid having to free a const * pointer */ pNew->devname = (char*)strdup(pszDeviceName); pNew->dev.name = pNew->devname; pNew->dev.vendor = pModel->pszVendor; pNew->dev.model = pModel->pszName; pNew->dev.type = "flatbed scanner"; iNumSaneDev++; return 0; } static SANE_Status attach_one_device (SANE_String_Const devname) { const char * filename = (const char*) devname; if (HP5400Detect (filename, _ReportDevice) < 0) { HP5400_DBG (DBG_MSG, "attach_one_device: couldn't attach %s\n", devname); return SANE_STATUS_INVAL; } HP5400_DBG (DBG_MSG, "attach_one_device: attached %s successfully\n", devname); return SANE_STATUS_GOOD; } /*****************************************************************************/ SANE_Status sane_init (SANE_Int * piVersion, SANE_Auth_Callback pfnAuth) { FILE *conf_fp; /* Config file stream */ SANE_Char line[PATH_MAX]; SANE_Char *str = NULL; SANE_String_Const proper_str; int nline = 0; /* prevent compiler from complaing about unused parameters */ pfnAuth = pfnAuth; strcpy(usb_devfile, "/dev/usb/scanner0"); _pFirstSaneDev = 0; iNumSaneDev = 0; InitHp5400_internal(); DBG_INIT (); HP5400_DBG (DBG_MSG, "sane_init: SANE hp5400 backend version %d.%d-%d (from %s)\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); sanei_usb_init (); conf_fp = sanei_config_open (HP5400_CONFIG_FILE); iNumSaneDev = 0; if (conf_fp) { HP5400_DBG (DBG_MSG, "Reading config file\n"); while (sanei_config_read (line, sizeof (line), conf_fp)) { ++nline; if (str) { free (str); } proper_str = sanei_config_get_string (line, &str); /* Discards white lines and comments */ if (!str || proper_str == line || str[0] == '#') { HP5400_DBG (DBG_MSG, "Discarding line %d\n", nline); } else { /* If line's not blank or a comment, then it's the device * filename or a usb directive. */ HP5400_DBG (DBG_MSG, "Trying to attach %s\n", line); sanei_usb_attach_matching_devices (line, attach_one_device); } } /* while */ fclose (conf_fp); } else { HP5400_DBG (DBG_ERR, "Unable to read config file \"%s\": %s\n", HP5400_CONFIG_FILE, strerror (errno)); HP5400_DBG (DBG_MSG, "Using default built-in values\n"); attach_one_device (usb_devfile); } if (piVersion != NULL) { *piVersion = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); } return SANE_STATUS_GOOD; } void sane_exit (void) { TDevListEntry *pDev, *pNext; HP5400_DBG (DBG_MSG, "sane_exit\n"); /* free device list memory */ if (_pSaneDevList) { for (pDev = _pFirstSaneDev; pDev; pDev = pNext) { pNext = pDev->pNext; free (pDev->devname); /* pDev->dev.name is the same pointer that pDev->devname */ free (pDev); } _pFirstSaneDev = 0; free (_pSaneDevList); _pSaneDevList = 0; } FreeHp5400_internal(); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { TDevListEntry *pDev; int i; HP5400_DBG (DBG_MSG, "sane_get_devices\n"); local_only = local_only; if (_pSaneDevList) { free (_pSaneDevList); } _pSaneDevList = malloc (sizeof (*_pSaneDevList) * (iNumSaneDev + 1)); if (!_pSaneDevList) { HP5400_DBG (DBG_MSG, "no mem\n"); return SANE_STATUS_NO_MEM; } i = 0; for (pDev = _pFirstSaneDev; pDev; pDev = pDev->pNext) { _pSaneDevList[i++] = &pDev->dev; } _pSaneDevList[i++] = 0; /* last entry is 0 */ *device_list = _pSaneDevList; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h) { TScanner *s; HP5400_DBG (DBG_MSG, "sane_open: %s\n", name); /* check the name */ if (strlen (name) == 0) { /* default to first available device */ name = _pFirstSaneDev->dev.name; } s = malloc (sizeof (TScanner)); if (!s) { HP5400_DBG (DBG_MSG, "malloc failed\n"); return SANE_STATUS_NO_MEM; } memset (s, 0, sizeof (TScanner)); /* Clear everything to zero */ if (HP5400Open (&s->HWParams, name) < 0) { /* is this OK ? */ HP5400_DBG (DBG_ERR, "HP5400Open failed\n"); free ((void *) s); return SANE_STATUS_INVAL; /* is this OK? */ } HP5400_DBG (DBG_MSG, "Handle=%d\n", s->HWParams.iXferHandle); _InitOptions (s); *h = s; /* Turn on lamp by default at startup */ /* SetLamp(&s->HWParams, TRUE); */ return SANE_STATUS_GOOD; } void sane_close (SANE_Handle h) { TScanner *s; HP5400_DBG (DBG_MSG, "sane_close\n"); s = (TScanner *) h; /* turn of scanner lamp */ SetLamp (&s->HWParams, FALSE); /* close scanner */ HP5400Close (&s->HWParams); /* free scanner object memory */ free ((void *) s); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle h, SANE_Int n) { TScanner *s; HP5400_DBG (DBG_MSG, "sane_get_option_descriptor %d\n", n); if ((n < optCount) || (n >= optLast)) { return NULL; } s = (TScanner *) h; return &s->aOptions[n]; } SANE_Status sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action Action, void *pVal, SANE_Int * pInfo) { TScanner *s; SANE_Int info; HP5400_DBG (DBG_MSG, "sane_control_option: option %d, action %d\n", n, Action); s = (TScanner *) h; info = 0; switch (Action) { case SANE_ACTION_GET_VALUE: switch (n) { /* Get options of type SANE_Word */ case optBRX: case optTLX: *(SANE_Word *) pVal = s->aValues[n].w; /* Not needed anymore - s->aValues[optOffsetX].w; */ HP5400_DBG (DBG_MSG, "sane_control_option: SANE_ACTION_GET_VALUE %d = %d\n", n, *(SANE_Word *) pVal); break; case optBRY: case optTLY: *(SANE_Word *) pVal = s->aValues[n].w; /* Not needed anymore - - s->aValues[optOffsetY].w; */ HP5400_DBG (DBG_MSG, "sane_control_option: SANE_ACTION_GET_VALUE %d = %d\n", n, *(SANE_Word *) pVal); break; case optOffsetX: case optOffsetY: case optCount: case optDPI: HP5400_DBG (DBG_MSG, "sane_control_option: SANE_ACTION_GET_VALUE %d = %d\n", n, (int) s->aValues[n].w); *(SANE_Word *) pVal = s->aValues[n].w; break; /* Get options of type SANE_Word array */ case optGammaTableRed: case optGammaTableGreen: case optGammaTableBlue: HP5400_DBG (DBG_MSG, "Reading gamma table\n"); memcpy (pVal, s->aValues[n].wa, s->aOptions[n].size); break; #if 0 /* Get options of type SANE_Bool */ case optLamp: GetLamp (&s->HWParams, &fLampIsOn); *(SANE_Bool *) pVal = fLampIsOn; break; #endif #if 0 case optCalibrate: /* although this option has nothing to read, it's added here to avoid a warning when running scanimage --help */ break; #endif default: HP5400_DBG (DBG_MSG, "SANE_ACTION_GET_VALUE: Invalid option (%d)\n", n); } break; case SANE_ACTION_SET_VALUE: if (s->fScanning) { HP5400_DBG (DBG_ERR, "sane_control_option: SANE_ACTION_SET_VALUE not allowed during scan\n"); return SANE_STATUS_INVAL; } switch (n) { case optCount: return SANE_STATUS_INVAL; break; case optBRX: case optTLX: info |= SANE_INFO_RELOAD_PARAMS; s->ScanParams.iLines = 0; /* Forget actual image settings */ s->aValues[n].w = *(SANE_Word *) pVal; /* Not needed anymore - + s->aValues[optOffsetX].w; */ break; case optBRY: case optTLY: info |= SANE_INFO_RELOAD_PARAMS; s->ScanParams.iLines = 0; /* Forget actual image settings */ s->aValues[n].w = *(SANE_Word *) pVal; /* Not needed anymore - + s->aValues[optOffsetY].w; */ break; case optDPI: info |= SANE_INFO_RELOAD_PARAMS; s->ScanParams.iLines = 0; /* Forget actual image settings */ #ifdef SUPPORT_2400_DPI (s->aValues[n].w) = *(SANE_Word *) pVal; #else (s->aValues[n].w) = min (1200, *(SANE_Word *) pVal); #endif break; case optGammaTableRed: case optGammaTableGreen: case optGammaTableBlue: HP5400_DBG (DBG_MSG, "Writing gamma table\n"); memcpy (s->aValues[n].wa, pVal, s->aOptions[n].size); break; /* case optLamp: fVal = *(SANE_Bool *)pVal; HP5400_DBG(DBG_MSG, "lamp %s\n", fVal ? "on" : "off"); SetLamp(&s->HWParams, fVal); break; */ #if 0 case optCalibrate: /* SimpleCalib(&s->HWParams); */ break; #endif default: HP5400_DBG (DBG_ERR, "SANE_ACTION_SET_VALUE: Invalid option (%d)\n", n); } if (pInfo != NULL) { *pInfo = info; } break; case SANE_ACTION_SET_AUTO: return SANE_STATUS_UNSUPPORTED; default: HP5400_DBG (DBG_ERR, "Invalid action (%d)\n", Action); return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle h, SANE_Parameters * p) { TScanner *s; HP5400_DBG (DBG_MSG, "sane_get_parameters\n"); s = (TScanner *) h; /* first do some checks */ if (s->aValues[optTLX].w >= s->aValues[optBRX].w) { HP5400_DBG (DBG_ERR, "TLX should be smaller than BRX\n"); return SANE_STATUS_INVAL; /* proper error code? */ } if (s->aValues[optTLY].w >= s->aValues[optBRY].w) { HP5400_DBG (DBG_ERR, "TLY should be smaller than BRY\n"); return SANE_STATUS_INVAL; /* proper error code? */ } /* return the data */ p->format = SANE_FRAME_RGB; p->last_frame = SANE_TRUE; p->depth = 8; if (s->ScanParams.iLines) /* Initialised by doing a scan */ { p->pixels_per_line = s->ScanParams.iBytesPerLine / 3; p->lines = s->ScanParams.iLines; p->bytes_per_line = s->ScanParams.iBytesPerLine; } else { p->lines = MM_TO_PIXEL (s->aValues[optBRY].w - s->aValues[optTLY].w, s->aValues[optDPI].w); p->pixels_per_line = MM_TO_PIXEL (s->aValues[optBRX].w - s->aValues[optTLX].w, s->aValues[optDPI].w); p->bytes_per_line = p->pixels_per_line * 3; } return SANE_STATUS_GOOD; } #define BUFFER_READ_HEADER_SIZE 32 SANE_Status sane_start (SANE_Handle h) { TScanner *s; SANE_Parameters par; HP5400_DBG (DBG_MSG, "sane_start\n"); s = (TScanner *) h; if (sane_get_parameters (h, &par) != SANE_STATUS_GOOD) { HP5400_DBG (DBG_MSG, "Invalid scan parameters (sane_get_parameters)\n"); return SANE_STATUS_INVAL; } s->iLinesLeft = par.lines; /* fill in the scanparams using the option values */ s->ScanParams.iDpi = s->aValues[optDPI].w; s->ScanParams.iLpi = s->aValues[optDPI].w; /* Guessing here. 75dpi => 1, 2400dpi => 32 */ /* s->ScanParams.iColourOffset = s->aValues[optDPI].w / 75; */ /* now we don't need correction => corrected by scan request type ? */ s->ScanParams.iColourOffset = 0; s->ScanParams.iTop = MM_TO_PIXEL (s->aValues[optTLY].w + s->HWParams.iTopLeftY, HW_LPI); s->ScanParams.iLeft = MM_TO_PIXEL (s->aValues[optTLX].w + s->HWParams.iTopLeftX, HW_DPI); /* Note: All measurements passed to the scanning routines must be in HW_LPI */ s->ScanParams.iWidth = MM_TO_PIXEL (s->aValues[optBRX].w - s->aValues[optTLX].w, HW_LPI); s->ScanParams.iHeight = MM_TO_PIXEL (s->aValues[optBRY].w - s->aValues[optTLY].w, HW_LPI); /* After the scanning, the iLines and iBytesPerLine will be filled in */ /* copy gamma table */ WriteGammaCalibTable (s->HWParams.iXferHandle, s->aGammaTableR, s->aGammaTableG, s->aGammaTableB); /* prepare the actual scan */ /* We say normal here. In future we should have a preview flag to set preview mode */ if (InitScan (SCAN_TYPE_NORMAL, &s->ScanParams, &s->HWParams) != 0) { HP5400_DBG (DBG_MSG, "Invalid scan parameters (InitScan)\n"); return SANE_STATUS_INVAL; } /* for the moment no lines has been read */ s->ScanParams.iLinesRead = 0; s->fScanning = TRUE; return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle h, SANE_Byte * buf, SANE_Int maxlen, SANE_Int * len) { /* Read actual scan from the circular buffer */ /* Note: this is already color corrected, though some work still needs to be done to deal with the colour offsetting */ TScanner *s; char *buffer = (char*)buf; HP5400_DBG (DBG_MSG, "sane_read: request %d bytes \n", maxlen); s = (TScanner *) h; /* nothing has been read for the moment */ *len = 0; /* if we read all the lines return EOF */ if (s->ScanParams.iLinesRead == s->ScanParams.iLines) { /* FinishScan( &s->HWParams ); *** FinishScan called in sane_cancel */ HP5400_DBG (DBG_MSG, "sane_read: EOF\n"); return SANE_STATUS_EOF; } /* read as many lines the buffer may contain and while there are lines to be read */ while ((*len + s->ScanParams.iBytesPerLine <= maxlen) && (s->ScanParams.iLinesRead < s->ScanParams.iLines)) { /* get one more line from the circular buffer */ CircBufferGetLine (s->HWParams.iXferHandle, &s->HWParams.pipe, buffer); /* increment pointer, size and line number */ buffer += s->ScanParams.iBytesPerLine; *len += s->ScanParams.iBytesPerLine; s->ScanParams.iLinesRead++; } HP5400_DBG (DBG_MSG, "sane_read: %d bytes read\n", *len); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle h) { TScanner *s; HP5400_DBG (DBG_MSG, "sane_cancel\n"); s = (TScanner *) h; /* to be implemented more thoroughly */ /* Make sure the scanner head returns home */ FinishScan (&s->HWParams); s->fCanceled = TRUE; s->fScanning = FALSE; } SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool m) { HP5400_DBG (DBG_MSG, "sane_set_io_mode %s\n", m ? "non-blocking" : "blocking"); /* prevent compiler from complaining about unused parameters */ h = h; if (m) { return SANE_STATUS_UNSUPPORTED; } return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fd) { HP5400_DBG (DBG_MSG, "sane_select_fd\n"); /* prevent compiler from complaining about unused parameters */ h = h; fd = fd; return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/epsonds-io.h0000666000000000000000000000174413615534521015027 00000000000000/* * epsonds-io.h - Epson ESC/I-2 driver, low level I/O. * * Copyright (C) 2015 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. */ #ifndef epsonds_io_h #define epsonds_io_h #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 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, char *rxbuf, size_t rxlen); SANE_Status eds_control(epsonds_scanner *s, void *buf, size_t buf_size); SANE_Status eds_fsy(epsonds_scanner *s); SANE_Status eds_fsx(epsonds_scanner *s); SANE_Status eds_lock(epsonds_scanner *s); #endif sane-backends-1.0.29/backend/kvs1025_usb.c0000666000000000000000000002171113615534521014722 00000000000000/* Copyright (C) 2008, Panasonic Russia Ltd. */ /* sane - Scanner Access Now Easy. Panasonic KV-S1020C / KV-S1025C USB scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/lassert.h" #include "kvs1025.h" #include "kvs1025_low.h" #include "kvs1025_usb.h" #include "kvs1025_cmds.h" #include "../include/sane/sanei_debug.h" extern PKV_DEV g_devices; /* Chain of devices */ extern const SANE_Device **g_devlist; /* static functions */ /* Attach USB scanner */ static SANE_Status attach_scanner_usb (const char *device_name) { PKV_DEV dev; SANE_Word vendor, product; DBG (DBG_error, "attaching USB scanner %s\n", device_name); sanei_usb_get_vendor_product_byname(device_name,&vendor,&product); dev = (PKV_DEV) malloc (sizeof (KV_DEV)); if (dev == NULL) return SANE_STATUS_NO_MEM; memset (dev, 0, sizeof (KV_DEV)); dev->bus_mode = KV_USB_BUS; dev->usb_fd = -1; dev->scsi_fd = -1; strcpy (dev->device_name, device_name); dev->buffer0 = (unsigned char *) malloc (SCSI_BUFFER_SIZE + 12); dev->buffer = dev->buffer0 + 12; if (dev->buffer0 == NULL) { free (dev); return SANE_STATUS_NO_MEM; } dev->scsi_type = 6; strcpy (dev->scsi_type_str, "ADF Scanner"); strcpy (dev->scsi_vendor, "Panasonic"); strcpy (dev->scsi_product, product == (int) KV_S1020C ? "KV-S1020C" : product == (int) KV_S1025C ? "KV-S1025C" : product == (int) KV_S1045C ? "KV-S1045C" : "KV-S10xxC"); strcpy (dev->scsi_version, "1.00"); /* Set SANE_Device */ dev->sane.name = dev->device_name; dev->sane.vendor = dev->scsi_vendor; dev->sane.model = dev->scsi_product; dev->sane.type = dev->scsi_type_str; /* Add into g_devices chain */ dev->next = g_devices; g_devices = dev; return SANE_STATUS_GOOD; } /* Get all supported scanners, and store into g_devlist */ SANE_Status kv_usb_enum_devices (void) { int cnt = 0; int i; PKV_DEV pd; char usb_str[18]; DBG (DBG_proc, "kv_usb_enum_devices: enter\n"); sanei_usb_init(); sprintf(usb_str,"usb %#04x %#04x",VENDOR_ID,KV_S1020C); sanei_usb_attach_matching_devices(usb_str, attach_scanner_usb); sprintf(usb_str,"usb %#04x %#04x",VENDOR_ID,KV_S1025C); sanei_usb_attach_matching_devices(usb_str, attach_scanner_usb); sprintf(usb_str,"usb %#04x %#04x",VENDOR_ID,KV_S1045C); sanei_usb_attach_matching_devices(usb_str, attach_scanner_usb); for (pd = g_devices; pd; pd=pd->next) { cnt++; } g_devlist = (const SANE_Device **) malloc (sizeof (SANE_Device *) * (cnt + 1)); if (g_devlist == NULL) { DBG (DBG_proc, "kv_usb_enum_devices: leave on error " " --out of memory\n"); return SANE_STATUS_NO_MEM; } pd = g_devices; for (i = 0; i < cnt; i++) { g_devlist[i] = (const SANE_Device *) &pd->sane; pd = pd->next; } g_devlist[cnt] = 0; DBG (DBG_proc, "kv_usb_enum_devices: leave with %d devices.\n", cnt); return SANE_STATUS_GOOD; } /* Check if device is already open */ SANE_Bool kv_usb_already_open (PKV_DEV dev) { return (dev->usb_fd > -1); } /* Open an USB device */ SANE_Status kv_usb_open (PKV_DEV dev) { SANE_Status ret; DBG (DBG_proc, "kv_usb_open: enter\n"); if (kv_usb_already_open(dev)) { DBG (DBG_proc, "kv_usb_open: leave -- already open\n"); return SANE_STATUS_GOOD; } ret = sanei_usb_open (dev->device_name, &(dev->usb_fd)); if (ret) { DBG (DBG_error, "kv_usb_open: leave -- cannot open device\n"); return SANE_STATUS_IO_ERROR; } sanei_usb_clear_halt (dev->usb_fd); DBG (DBG_proc, "kv_usb_open: leave\n"); return SANE_STATUS_GOOD; } /* Close an USB device */ void kv_usb_close (PKV_DEV dev) { DBG (DBG_proc, "kv_usb_close: enter\n"); if (kv_usb_already_open(dev)) { sanei_usb_close(dev->usb_fd); dev->usb_fd = -1; } DBG (DBG_proc, "kv_usb_close: leave\n"); } /* Clean up the USB bus and release all resources allocated to devices */ void kv_usb_cleanup (void) { } /* Send command via USB, and get response data */ SANE_Status kv_usb_escape (PKV_DEV dev, PKV_CMD_HEADER header, unsigned char *status_byte) { int got_response = 0; size_t len; unsigned char cmd_buff[24]; memset (cmd_buff, 0, 24); cmd_buff[3] = 0x18; /* container length */ cmd_buff[5] = 1; /* container type: command block */ cmd_buff[6] = 0x90; /* code */ if (!kv_usb_already_open(dev)) { DBG (DBG_error, "kv_usb_escape: error, device not open.\n"); return SANE_STATUS_IO_ERROR; } memcpy (cmd_buff + 12, header->cdb, header->cdb_size); /* change timeout */ sanei_usb_set_timeout(KV_CMD_TIMEOUT); /* Send command */ len = 24; if (sanei_usb_write_bulk (dev->usb_fd, (SANE_Byte *) cmd_buff, &len)) { DBG (DBG_error, "usb_bulk_write: Error writing command.\n"); hexdump (DBG_error, "cmd block", cmd_buff, 24); return SANE_STATUS_IO_ERROR; } /* Send / Read data */ if (header->direction == KV_CMD_IN) { size_t size = header->data_size + 12; size_t size_read = size; unsigned char *data = ((unsigned char *) header->data) - 12; SANE_Status ret; ret = sanei_usb_read_bulk (dev->usb_fd, (SANE_Byte *) data, &size_read); /*empty read is ok?*/ if (ret == SANE_STATUS_EOF){ sanei_usb_clear_halt (dev->usb_fd); ret = SANE_STATUS_GOOD; } if (ret) { sanei_usb_clear_halt (dev->usb_fd); DBG (DBG_error, "usb_bulk_read: Error reading data.\n"); return SANE_STATUS_IO_ERROR; } if (size_read != size) { DBG (DBG_shortread, "usb_bulk_read: Warning - short read\n"); DBG (DBG_shortread, "usb_bulk_read: bytes to read = %lu\n", (unsigned long)size); DBG (DBG_shortread, "usb_bulk_read: bytes actual read = %lu\n", (unsigned long)size_read); /*hexdump (DBG_shortread, "data", data, size_read); */ } } if (header->direction == KV_CMD_OUT) { size_t size = header->data_size + 12; size_t size_written = size; unsigned char *data = ((unsigned char *) header->data) - 12; SANE_Status ret; memset (data, 0, 12); Ito32 (size, data); data[5] = 0x02; /* container type: data block */ data[6] = 0xb0; /* code */ ret = sanei_usb_write_bulk (dev->usb_fd, (SANE_Byte *) data, &size_written); /*empty write is ok?*/ if (ret == SANE_STATUS_EOF){ sanei_usb_clear_halt (dev->usb_fd); ret = SANE_STATUS_GOOD; } if (ret) { sanei_usb_clear_halt (dev->usb_fd); DBG (DBG_error, "usb_bulk_write: Error writing data.\n"); return SANE_STATUS_IO_ERROR; } if (size_written != size) { DBG (DBG_shortread, "usb_bulk_write: Warning - short written\n"); DBG (DBG_shortread, "usb_bulk_write: bytes to write = %lu\n", (unsigned long)size); DBG (DBG_shortread, "usb_bulk_write: bytes actual written = %lu\n", (unsigned long)size_written); hexdump (DBG_shortread, "data", data, size_written); } } /* Get response */ if (!got_response) { SANE_Status ret; size_t len = 16; ret = sanei_usb_read_bulk (dev->usb_fd, (SANE_Byte *) cmd_buff, &len); if (ret || len != 16) { DBG (DBG_error, "usb_bulk_read: Error reading response." " read %lu bytes\n", (unsigned long)len); sanei_usb_clear_halt (dev->usb_fd); return SANE_STATUS_IO_ERROR; } } if (cmd_buff[5] != 3) { DBG (DBG_error, "usb_bulk_read: Invalid response block.\n"); hexdump (DBG_error, "response", cmd_buff, 16); return SANE_STATUS_IO_ERROR; } *status_byte = cmd_buff[15] & 0x3E; return SANE_STATUS_GOOD; } /* Send command via USB, and request sense on CHECK CONDITION status */ SANE_Status kv_usb_send_command (PKV_DEV dev, PKV_CMD_HEADER header, PKV_CMD_RESPONSE response) { unsigned char status = 0; SANE_Status s; memset (response, 0, sizeof (KV_CMD_RESPONSE)); response->status = KV_FAILED; s = kv_usb_escape (dev, header, &status); if (s) { status = 0x02; } if (status == 0x02) { /* check condition */ /* request sense */ KV_CMD_HEADER hdr; memset (&hdr, 0, sizeof (hdr)); hdr.direction = KV_CMD_IN; hdr.cdb[0] = SCSI_REQUEST_SENSE; hdr.cdb[4] = 0x12; hdr.cdb_size = 6; hdr.data_size = 0x12; hdr.data = &response->sense; if (kv_usb_escape (dev, &hdr, &status) != 0) return SANE_STATUS_IO_ERROR; hexdump (DBG_error, "sense data", (unsigned char *) &response->sense, 0x12); response->status = KV_CHK_CONDITION; } else { response->status = KV_SUCCESS; } return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/plustek-pp_p12.c0000666000000000000000000006161513615534521015533 00000000000000/* @file plustek-pp_p12.c * @brief p12 and pt12 specific stuff * * based on sources acquired from Plustek Inc. * Copyright (C) 2000 Plustek Inc. * Copyright (C) 2001-2013 Gerhard Jaeger * * History: * - 0.38 - initial version * - 0.39 - added Genius Colorpage Vivid III V2 stuff * - 0.40 - no changes * - 0.41 - no changes * - 0.42 - removed setting of ps->sCaps.dwFlag in p12InitiateComponentModel() * - 0.43 - no changes * - 0.44 - fix format string issues, as Long types default to int32_t * now * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #include "plustek-pp_scan.h" /*************************** some local vars *********************************/ static RegDef p12CcdStop[] = { {0x41, 0xff}, {0x42, 0xff}, {0x60, 0xff}, {0x61, 0xff}, {0x4b, 0xff}, {0x4c, 0xff}, {0x4d, 0xff}, {0x4e, 0xff}, {0x2a, 0x01}, {0x2b, 0x00}, {0x2d, 0x00}, {0x1b, 0x19}, {0x15, 0x00} }; /*************************** local functions *********************************/ /** init the stuff according to the buttons */ static void p12ButtonSetup( pScanData ps, Byte nrOfButtons ) { ps->Device.buttons = nrOfButtons; ps->Device.Model1Mono &= ~_BUTTON_MODE; ps->Device.Model1Color &= ~_BUTTON_MODE; ps->AsicReg.RD_MotorDriverType |= _BUTTON_DISABLE; ps->Scan.motorPower |= _BUTTON_DISABLE; } /** According to what we have detected, set the other stuff */ static void p12InitiateComponentModel( pScanData ps ) { /* preset some stuff and do the differences later */ ps->Device.buttons = 0; ps->Device.Model1Mono = _BUTTON_MODE + _CCD_SHIFT_GATE + _SCAN_GRAYTYPE; ps->Device.Model1Color = _BUTTON_MODE + _CCD_SHIFT_GATE; ps->Device.dwModelOriginY = 64; ps->Device.fTpa = _FALSE; ps->Device.ModelCtrl = (_LED_ACTIVITY | _LED_CONTROL); /* ps->sCaps.dwFlag should have been set correctly in models.c */ switch( ps->Device.bPCBID ) { case _PLUSTEK_SCANNER: DBG( DBG_LOW, "We have a Plustek Scanner\n" ); ps->sCaps.Model = MODEL_OP_P12; break; case _SCANNER_WITH_TPA: DBG( DBG_LOW, "Scanner has TPA\n" ); ps->Device.fTpa = _TRUE; ps->sCaps.dwFlag |= SFLAG_TPA; break; case _SCANNER4Button: DBG( DBG_LOW, "Scanner has 4 Buttons\n" ); p12ButtonSetup( ps, 4 ); break; case _SCANNER4ButtonTPA: DBG( DBG_LOW, "Scanner has 4 Buttons & TPA\n" ); ps->Device.fTpa = _TRUE; ps->sCaps.dwFlag |= SFLAG_TPA; p12ButtonSetup( ps, 4 ); break; case _SCANNER5Button: DBG( DBG_LOW, "Scanner has 5 Buttons\n" ); ps->Device.dwModelOriginY = 64 + 20; p12ButtonSetup( ps, 5 ); break; case _SCANNER5ButtonTPA: DBG( DBG_LOW, "Scanner has 5 Buttons & TPA\n" ); ps->Device.dwModelOriginY = 64 + 20; ps->Device.fTpa = _TRUE; ps->sCaps.dwFlag |= SFLAG_TPA; p12ButtonSetup( ps, 5 ); break; case _SCANNER1Button: DBG( DBG_LOW, "Scanner has 1 Button\n" ); p12ButtonSetup( ps, 1 ); break; case _SCANNER1ButtonTPA: DBG( DBG_LOW, "Scanner has 1 Button & TPA\n" ); ps-> Device.fTpa = _TRUE; ps->sCaps.dwFlag |= SFLAG_TPA; p12ButtonSetup( ps, 1 ); break; case _AGFA_SCANNER: DBG( DBG_LOW, "Agfa Scanner\n" ); ps->Device.dwModelOriginY = 24; /* 1200 dpi */ break; case _SCANNER2Button: DBG( DBG_LOW, "Scanner has 2 Buttons\n" ); DBG( DBG_LOW, "Seems we have a Genius Colorpage Vivid III V2\n" ); ps->Device.dwModelOriginY = 64 - 33; p12ButtonSetup( ps, 2 ); ps->sCaps.Model = MODEL_GEN_CPV2; break; default: DBG( DBG_LOW, "Default Model: P12\n" ); ps->sCaps.Model = MODEL_OP_P12; break; } if( _MOTOR0_2003 == ps->Device.bMotorID ) { ps->Device.f2003 = _TRUE; ps->Device.XStepMono = 10; ps->Device.XStepColor = 6; ps->Device.XStepBack = 5; ps->AsicReg.RD_MotorDriverType |= _MOTORR_STRONG; } else { ps->Device.f2003 = _FALSE; ps->Device.XStepMono = 8; ps->Device.XStepColor = 4; ps->Device.XStepBack = 5; ps->AsicReg.RD_MotorDriverType |= _MOTORR_WEAK; } } /*............................................................................. * prepare all the necessary variables - */ static void p12SetupScannerVariables( pScanData ps ) { DBG( DBG_LOW, "p12SetupScannerVariables()\n" ); /* * these values were originally altered by registry entries (NT-driver) * and used to adjust the picture position... */ ps->Device.lUpNormal = 0; ps->Device.lUpNegative = 20; ps->Device.lUpPositive = -30; ps->Device.lLeftNormal = 51; ps->OpenScanPath( ps ); ps->ReInitAsic( ps, _FALSE ); ps->CloseScanPath( ps ); } /*............................................................................. * */ static void p12SetupScanningCondition( pScanData ps ) { TimerDef timer; ULong channel; Byte bState; pUChar pState = ps->Bufs.b1.pReadBuf; DBG( DBG_LOW, "p12SetupScanningCondition()\n" ); P12SetGeneralRegister( ps ); IORegisterToScanner( ps, ps->RegResetMTSC ); /* ------- Setup MinRead/MaxRead Fifo size ------- */ if( ps->DataInf.wPhyDataType <= COLOR_TRUE24 ) { ps->Scan.dwMaxReadFifo = ps->Scan.dwMinReadFifo = ps->DataInf.dwAsicBytesPerPlane * 2; } else { ps->Scan.dwMaxReadFifo = ps->Scan.dwMinReadFifo = ps->DataInf.dwAppPixelsPerLine << 1; } if( ps->Scan.dwMinReadFifo < 1024) ps->Scan.dwMinReadFifo = ps->Scan.dwMaxReadFifo = 1024; ps->Scan.dwMaxReadFifo += (ps->DataInf.dwAsicBytesPerPlane / 2); DBG( DBG_LOW, "MinReadFifo=%u, MaxReadFifo=%u\n", ps->Scan.dwMinReadFifo, ps->Scan.dwMaxReadFifo ); /* ------- Set the max. read fifo to asic ------- */ if( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { ps->Scan.bFifoSelect = ps->RegBFifoOffset; if( !ps->Scan.p48BitBuf.pb ) { Long lRed, lGreen; lRed = (_SIZE_REDFIFO - _SIZE_BLUEFIFO) / ps->DataInf.dwAsicBytesPerPlane - ps->Scan.bd_rk.wRedKeep; lGreen = (_SIZE_GREENFIFO - _SIZE_BLUEFIFO) / ps->DataInf.dwAsicBytesPerPlane - ps->Scan.gd_gk.wGreenKeep; if((lRed < 0) || (lGreen < 0)) { if( lRed < lGreen ) { channel = _RED_FULLSIZE << 16; ps->AsicReg.RD_BufFullSize = _SIZE_REDFIFO; lGreen = lRed; } else { channel = _GREEN_FULLSIZE << 16; ps->AsicReg.RD_BufFullSize = _SIZE_GREENFIFO; } lGreen = (ULong)(-lGreen * ps->DataInf.dwAsicBytesPerPlane); if( ps->DataInf.wPhyDataType > COLOR_TRUE24 ) lGreen >>= 1; ps->Scan.dwMinReadFifo += (ULong)lGreen; ps->Scan.dwMaxReadFifo += (ULong)lGreen; } else { channel = _BLUE_FULLSIZE << 16; ps->AsicReg.RD_BufFullSize = _SIZE_BLUEFIFO; } } else { channel = _BLUE_FULLSIZE << 16; ps->AsicReg.RD_BufFullSize = _SIZE_BLUEFIFO; } } else { ps->Scan.bFifoSelect = ps->RegGFifoOffset; channel = _GREEN_FULLSIZE << 16; ps->AsicReg.RD_BufFullSize = _SIZE_GRAYFIFO; } ps->AsicReg.RD_BufFullSize -= (ps->DataInf.dwAsicBytesPerPlane << 1); if( ps->DataInf.wPhyDataType > COLOR_TRUE24 ) ps->AsicReg.RD_BufFullSize >>= 1; ps->AsicReg.RD_BufFullSize |= channel; ps->Scan.bRefresh = (Byte)(ps->Scan.dwInterval << 1); ps->AsicReg.RD_LineControl = (_LOBYTE (ps->Shade.wExposure)); ps->AsicReg.RD_ExtLineControl = (_HIBYTE (ps->Shade.wExposure)); ps->AsicReg.RD_XStepTime = (_LOBYTE (ps->Shade.wXStep)); ps->AsicReg.RD_ExtXStepTime = (_HIBYTE (ps->Shade.wXStep)); ps->AsicReg.RD_Motor0Control = _FORWARD_MOTOR; ps->AsicReg.RD_StepControl = _MOTOR0_SCANSTATE; ps->AsicReg.RD_ModeControl = (_ModeScan | _ModeFifoGSel); DBG( DBG_LOW, "bRefresh = %i\n", ps->Scan.bRefresh ); if( ps->DataInf.wPhyDataType == COLOR_BW ) { ps->AsicReg.RD_ScanControl = _SCAN_BITMODE; if( !(ps->DataInf.dwScanFlag & SCANDEF_Inverse)) ps->AsicReg.RD_ScanControl |= _P98_SCANDATA_INVERT; } else if( ps->DataInf.wPhyDataType <= COLOR_TRUE24 ) ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE; else { ps->AsicReg.RD_ScanControl = _SCAN_12BITMODE; if(!(ps->DataInf.dwScanFlag & SCANDEF_RightAlign)) ps->AsicReg.RD_ScanControl |= _BITALIGN_LEFT; if( ps->DataInf.dwScanFlag & SCANDEF_Inverse) ps->AsicReg.RD_ScanControl |= _P98_SCANDATA_INVERT; } ps->AsicReg.RD_ScanControl |= _SCAN_1ST_AVERAGE; IOSelectLampSource( ps ); DBG( DBG_LOW, "RD_ScanControl = 0x%02x\n", ps->AsicReg.RD_ScanControl ); ps->AsicReg.RD_MotorTotalSteps = (ULong)ps->DataInf.crImage.cy * 4 + ((ps->Device.f0_8_16) ? 32 : 16) + ((ps->Scan.bDiscardAll) ? 32 : 0); ps->AsicReg.RD_ScanControl1 = (_MTSC_ENABLE | _SCANSTOPONBUFFULL | _MFRC_RUNSCANSTATE | _MFRC_BY_XSTEP); ps->AsicReg.RD_Dpi = ps->DataInf.xyPhyDpi.x; if(!(ps->DataInf.dwScanFlag & SCANDEF_TPA )) { ps->AsicReg.RD_Origin = (UShort)(ps->Device.lLeftNormal * 2 + ps->Device.DataOriginX + ps->DataInf.crImage.x ); } else if( ps->DataInf.dwScanFlag & SCANDEF_Transparency ) { ps->AsicReg.RD_Origin = (UShort)(ps->Scan.posBegin + ps->DataInf.crImage.x); } else { ps->AsicReg.RD_Origin = (UShort)(ps->Scan.negBegin + ps->DataInf.crImage.x); } if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) ps->AsicReg.RD_Origin >>= 1; if( ps->DataInf.wPhyDataType == COLOR_BW ) ps->AsicReg.RD_Pixels = (UShort)ps->DataInf.dwAsicBytesPerPlane; else ps->AsicReg.RD_Pixels = (UShort)ps->DataInf.dwAppPixelsPerLine; DBG( DBG_LOW, "RD_Origin = %u, RD_Pixels = %u\n", ps->AsicReg.RD_Origin, ps->AsicReg.RD_Pixels ); /* ------- Prepare scan states ------- */ memset( ps->a_nbNewAdrPointer, 0, _SCANSTATE_BYTES ); memset( ps->Bufs.b1.pReadBuf, 0, _NUMBER_OF_SCANSTEPS ); if( ps->DataInf.wPhyDataType <= COLOR_256GRAY ) bState = (_SS_MONO | _SS_STEP); else bState = (_SS_COLOR | _SS_STEP); for( channel = _NUMBER_OF_SCANSTEPS; channel; channel -= ps->Scan.dwInterval ) { *pState = bState; if( ps->Scan.dwInterlace ) pState[ ps->Scan.dwInterlace] = _SS_STEP; pState += ps->Scan.dwInterval; } for( channel = 0, pState = ps->Bufs.b1.pReadBuf; channel < _SCANSTATE_BYTES; channel++) { ps->a_nbNewAdrPointer[channel] = pState [0] | (pState [1] << 4); pState += 2; } /* ------- Wait for scan state stop ------- */ MiscStartTimer( &timer, _SECOND * 2 ); while(!(IOGetScanState( ps, _FALSE ) & _SCANSTATE_STOP) && !MiscCheckTimer(&timer)); /* CHECK: Replace by IOPutAll.... */ IODownloadScanStates( ps ); IODataToRegister( ps, ps->RegLineControl, ps->AsicReg.RD_LineControl); IODataToRegister( ps, ps->RegExtendedLineControl, ps->AsicReg.RD_ExtLineControl); IODataToRegister( ps, ps->RegXStepTime, ps->AsicReg.RD_XStepTime); IODataToRegister( ps, ps->RegExtendedXStep, ps->AsicReg.RD_ExtXStepTime); IODataToRegister( ps, ps->RegMotorDriverType, ps->AsicReg.RD_MotorDriverType); IODataToRegister( ps, ps->RegStepControl, ps->AsicReg.RD_StepControl); IODataToRegister( ps, ps->RegMotor0Control, ps->AsicReg.RD_Motor0Control); IODataToRegister( ps, ps->RegModelControl,ps->AsicReg.RD_ModelControl); IODataToRegister( ps, ps->RegDpiLow, (_LOBYTE(ps->AsicReg.RD_Dpi))); IODataToRegister( ps, ps->RegDpiHigh, (_HIBYTE(ps->AsicReg.RD_Dpi))); IODataToRegister( ps, ps->RegScanPosLow, (_LOBYTE(ps->AsicReg.RD_Origin))); IODataToRegister( ps, ps->RegScanPosHigh,(_HIBYTE(ps->AsicReg.RD_Origin))); IODataToRegister( ps, ps->RegWidthPixelsLow, (_LOBYTE(ps->AsicReg.RD_Pixels))); IODataToRegister( ps, ps->RegWidthPixelsHigh, (_HIBYTE(ps->AsicReg.RD_Pixels))); IODataToRegister( ps, ps->RegThresholdLow, (_LOBYTE(ps->AsicReg.RD_ThresholdControl))); IODataToRegister( ps, ps->RegThresholdHigh, (_HIBYTE(ps->AsicReg.RD_ThresholdControl))); IODataToRegister( ps, ps->RegMotorTotalStep0, (_LOBYTE(ps->AsicReg.RD_MotorTotalSteps))); IODataToRegister( ps, ps->RegMotorTotalStep1, (_HIBYTE(ps->AsicReg.RD_MotorTotalSteps))); IODataToRegister( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl); IORegisterToScanner( ps, ps->RegInitDataFifo); } /*............................................................................. * program the CCD relevant stuff */ static void p12ProgramCCD( pScanData ps) { UShort w; pRegDef rp; DBG( DBG_IO, "p12ProgramCCD: 0x%08lx[%lu]\n", (unsigned long)ps->Device.pCCDRegisters, ((unsigned long)ps->Device.wNumCCDRegs * ps->Shade.bIntermediate)); DBG( DBG_IO, " %u regs * %u (intermediate)\n", ps->Device.wNumCCDRegs, ps->Shade.bIntermediate ); rp = ps->Device.pCCDRegisters + (ULong)ps->Device.wNumCCDRegs * ps->Shade.bIntermediate; for( w = ps->Device.wNumCCDRegs; w--; rp++ ) { DBG( DBG_IO, "[0x%02x] = 0x%02x\n", rp->bReg, rp->bParam ); IODataToRegister( ps, rp->bReg, rp->bParam ); } } /*............................................................................. * this initializes the ASIC and prepares the different functions for shading * and scanning */ static void p12Init98003( pScanData ps, Bool shading ) { DBG( DBG_LOW, "p12InitP98003(%d)\n", shading ); /* get DAC and motor stuff */ ps->Device.bDACType = IODataFromRegister( ps, ps->RegResetConfig ); ps->Device.bMotorID = (Byte)(ps->Device.bDACType & _MOTOR0_MASK); ps->AsicReg.RD_MotorDriverType = (Byte)((ps->Device.bDACType & _MOTOR0_MASK) >> 3); ps->AsicReg.RD_MotorDriverType |= (Byte)((ps->Device.bDACType & _MOTOR1_MASK) >> 1); ps->Scan.motorPower = ps->AsicReg.RD_MotorDriverType | _MOTORR_STRONG; ps->Device.bDACType &= _ADC_MASK; /*get CCD and PCB ID */ ps->Device.bPCBID = IODataFromRegister( ps, ps->RegConfiguration ); ps->Device.bCCDID = ps->Device.bPCBID & 0x07; ps->Device.bPCBID &= 0xf0; if( _AGFA_SCANNER == ps->Device.bPCBID ) ps->Device.bDACType = _DA_WOLFSON8141; DBG( DBG_LOW, "PCB-ID=0x%02x, CCD-ID=0x%02x, DAC-TYPE=0x%02x\n", ps->Device.bPCBID, ps->Device.bCCDID, ps->Device.bDACType ); p12InitiateComponentModel( ps ); /* encode the CCD-id into the flag parameter */ ps->sCaps.dwFlag |= ((ULong)(ps->Device.bCCDID | ps->Device.bPCBID) << 16); P12InitCCDandDAC( ps, shading ); if( ps->Shade.bIntermediate & _ScanMode_Mono ) ps->AsicReg.RD_Model1Control = ps->Device.Model1Mono; else ps->AsicReg.RD_Model1Control = ps->Device.Model1Color; IODataToRegister( ps, ps->RegPllPredivider, 1 ); IODataToRegister( ps, ps->RegPllMaindivider, 0x20 ); IODataToRegister( ps, ps->RegPllPostdivider, 2 ); IODataToRegister( ps, ps->RegClockSelector, 3 ); /* 2 */ IODataToRegister( ps, ps->RegMotorDriverType, ps->AsicReg.RD_MotorDriverType ); /* this might be changed, def value is 11 */ IODataToRegister( ps, ps->RegWaitStateInsert, 11 ); IODataToRegister( ps, ps->RegModel1Control, ps->AsicReg.RD_Model1Control ); p12ProgramCCD( ps ); } /*............................................................................. * initialize the register values for the 98003 asic and preset other stuff */ static void p12InitializeAsicRegister( pScanData ps ) { memset( &ps->AsicReg, 0, sizeof(RegData)); } /*............................................................................. * as the function name says */ static void p12PutToIdleMode( pScanData ps ) { ULong i; ps->OpenScanPath( ps ); DBG( DBG_IO, "CCD-Stop\n" ); for( i = 0; i < 13; i++ ) { DBG( DBG_IO, "[0x%02x] = 0x%02x\n", p12CcdStop[i].bReg, p12CcdStop[i].bParam ); IODataToRegister( ps, p12CcdStop[i].bReg, p12CcdStop[i].bParam ); } ps->CloseScanPath( ps ); } /*............................................................................. * here we simply call the WaitForShading function which performs this topic */ static int p12Calibration( pScanData ps ) { Bool result; DBG( DBG_LOW, "p12Calibration()\n" ); /* * wait for shading to be done */ ps->OpenScanPath( ps ); _ASSERT(ps->WaitForShading); result = ps->WaitForShading( ps ); ps->CloseScanPath( ps ); if( !result ) return _E_TIMEOUT; return _OK; } /************************ exported functions *********************************/ /*............................................................................. * initialize the register values and function calls for the 98003 asic */ _LOC int P12InitAsic( pScanData ps ) { int result; DBG( DBG_LOW, "P12InitAsic()\n" ); /* * preset the asic shadow registers */ p12InitializeAsicRegister( ps ); ps->IO.bOpenCount = 0; /* * setup the register values */ ps->RegSwitchBus = 0; ps->RegEPPEnable = 1; ps->RegECPEnable = 2; ps->RegReadDataMode = 3; ps->RegWriteDataMode = 4; ps->RegInitDataFifo = 5; ps->RegForceStep = 6; ps->RegInitScanState = 7; ps->RegRefreshScanState = 8; ps->RegWaitStateInsert = 0x0a; ps->RegRFifoOffset = 0x0a; ps->RegGFifoOffset = 0x0b; ps->RegBFifoOffset = 0x0c; ps->RegBitDepth = 0x13; ps->RegStepControl = 0x14; ps->RegMotor0Control = 0x15; ps->RegXStepTime = 0x16; ps->RegGetScanState = 0x17; ps->RegAsicID = 0x18; ps->RegMemoryLow = 0x19; ps->RegMemoryHigh = 0x1a; ps->RegModeControl = 0x1b; ps->RegLineControl = 0x1c; ps->RegScanControl = 0x1d; ps->RegConfiguration = 0x1e; ps->RegModelControl = 0x1f; ps->RegModel1Control = 0x20; ps->RegDpiLow = 0x21; ps->RegDpiHigh = 0x22; ps->RegScanPosLow = 0x23; ps->RegScanPosHigh = 0x24; ps->RegWidthPixelsLow = 0x25; ps->RegWidthPixelsHigh = 0x26; ps->RegThresholdLow = 0x27; ps->RegThresholdHigh = 0x28; ps->RegThresholdGapControl = 0x29; ps->RegADCAddress = 0x2a; ps->RegADCData = 0x2b; ps->RegADCPixelOffset = 0x2c; ps->RegADCSerialOutStr = 0x2d; ps->RegResetConfig = 0x2e; ps->RegLensPosition = 0x2f; ps->RegStatus = 0x30; ps->RegScanStateControl = 0x31; ps->RegRedChDarkOffsetLow = 0x33; ps->RegRedChDarkOffsetHigh = 0x34; ps->RegGreenChDarkOffsetLow = 0x35; ps->RegGreenChDarkOffsetHigh= 0x36; ps->RegBlueChDarkOffsetLow = 0x37; ps->RegBlueChDarkOffsetHigh = 0x38; ps->RegResetPulse0 = 0x39; ps->RegResetPulse1 = 0x3a; ps->RegCCDClampTiming0 = 0x3b; ps->RegCCDClampTiming1 = 0x3c; ps->RegVSMPTiming0 = 0x41; ps->RegVSMPTiming1 = 0x42; ps->RegCCDQ1Timing0 = 0x43; ps->RegCCDQ1Timing1 = 0x44; ps->RegCCDQ1Timing2 = 0x45; ps->RegCCDQ1Timing3 = 0x46; ps->RegCCDQ2Timing0 = 0x47; ps->RegCCDQ2Timing1 = 0x48; ps->RegCCDQ2Timing2 = 0x49; ps->RegCCDQ2Timing3 = 0x4a; ps->RegADCclockTiming0 = 0x4b; ps->RegADCclockTiming1 = 0x4c; ps->RegADCclockTiming2 = 0x4d; ps->RegADCclockTiming3 = 0x4e; ps->RegADCDVTiming0 = 0x50; ps->RegADCDVTiming1 = 0x51; ps->RegADCDVTiming2 = 0x52; ps->RegADCDVTiming3 = 0x53; ps->RegFifoFullLength0 = 0x54; ps->RegFifoFullLength1 = 0x55; ps->RegFifoFullLength2 = 0x56; ps->RegMotorTotalStep0 = 0x57; ps->RegMotorTotalStep1 = 0x58; ps->RegMotorFreeRunCount0 = 0x59; ps->RegMotorFreeRunCount1 = 0x5a; ps->RegScanControl1 = 0x5b; ps->RegMotorFreeRunTrigger = 0x5c; ps->RegResetMTSC = 0x5d; ps->RegMotor1Control = 0x62; ps->RegMotor2Control = 0x63; ps->RegMotorDriverType = 0x64; ps->RegStatus2 = 0x66; ps->RegExtendedLineControl = 0x6d; ps->RegExtendedXStep = 0x6e; ps->RegPllPredivider = 0x71; ps->RegPllMaindivider = 0x72; ps->RegPllPostdivider = 0x73; ps->RegClockSelector = 0x74; ps->RegTestMode = 0xf0; /* * setup function calls */ ps->SetupScannerVariables = p12SetupScannerVariables; ps->SetupScanningCondition = p12SetupScanningCondition; ps->Calibration = p12Calibration; ps->PutToIdleMode = p12PutToIdleMode; ps->ReInitAsic = p12Init98003; ps->CtrlReadHighNibble = _CTRL_GENSIGNAL + _CTRL_AUTOLF + _CTRL_STROBE; ps->CtrlReadLowNibble = _CTRL_GENSIGNAL + _CTRL_AUTOLF; ps->IO.useEPPCmdMode = _FALSE; /* * initialize the other modules and set some * function pointer */ result = DacInitialize( ps ); if( _OK != result ) return result; result = ImageInitialize( ps ); if( _OK != result ) return result; result = IOFuncInitialize( ps ); if( _OK != result ) return result; result = IOInitialize( ps ); if( _OK != result ) return result; result = MotorInitialize( ps ); if( _OK != result ) return result; if( _FALSE == ps->OpenScanPath( ps )) { DBG( DBG_LOW, "P12InitAsic() failed.\n" ); return _E_NO_DEV; } /*get CCD and PCB ID */ ps->Device.bPCBID = IODataFromRegister( ps, ps->RegConfiguration ); ps->Device.bCCDID = ps->Device.bPCBID & 0x07; ps->Device.bPCBID &= 0xf0; DBG( DBG_LOW, "PCB-ID=0x%02x, CCD-ID=0x%02x\n", ps->Device.bPCBID, ps->Device.bCCDID ); /* get a more closer model description...*/ p12InitiateComponentModel( ps ); ps->CloseScanPath( ps ); /* here we check for the OpticWorks 2000, which is not supported */ if( _OPTICWORKS2000 == ps->Device.bPCBID ) { DBG( DBG_LOW, "OpticWorks 2000 not supported!\n" ); return _E_NOSUPP; } DBG( DBG_LOW, "P12InitAsic() done.\n" ); return _OK; } /*............................................................................. * set all necessary register contents */ _LOC void P12SetGeneralRegister( pScanData ps ) { DBG( DBG_LOW, "P12SetGeneralRegister()\n" ); ps->Scan.fMotorBackward = _FALSE; ps->Scan.fRefreshState = _FALSE; if( COLOR_BW == ps->DataInf.wPhyDataType ) ps->AsicReg.RD_ScanControl = _SCAN_BITMODE; else { if( ps->DataInf.wPhyDataType <= COLOR_TRUE24 ) ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE; else ps->AsicReg.RD_ScanControl = _SCAN_12BITMODE; } IOSelectLampSource( ps ); if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) ps->AsicReg.RD_ModelControl = ps->Device.ModelCtrl | _ModelDpi300; else ps->AsicReg.RD_ModelControl = ps->Device.ModelCtrl | _ModelDpi600; ps->AsicReg.RD_Motor0Control = _MotorOn | _MotorHQuarterStep | _MotorPowerEnable; ps->AsicReg.RD_ScanControl1 = _SCANSTOPONBUFFULL | _MFRC_BY_XSTEP; ps->AsicReg.RD_StepControl = _MOTOR0_SCANSTATE; } /* END PLUSTEK-PP_P12.C .....................................................*/ sane-backends-1.0.29/backend/plustek-pp_image.c0000666000000000000000000014515213615534521016212 00000000000000/* @file plustek-pp_image.c * @brief functions to convert scanner data into image data * * based on sources acquired from Plustek Inc. * Copyright (C) 1998 Plustek Inc. * Copyright (C) 2000-2013 Gerhard Jaeger * also based on the work done by Rick Bronson * * History: * - 0.30 - initial version * - 0.31 - no changes * - 0.32 - no changes * - 0.33 - no changes * - 0.34 - reactivated code in imageP96WaitLineData() to recover from * loosing data * - 0.35 - no changes * - 0.36 - removed comment * - added wDither exchange to imageP9xSetupScanSettings * - added fnHalftoneDirect1 which provides dithering by using random * thresholds * - removed the swapping behaviour for model OP_600 in * fnP96ColorDirect() according to the Primax 4800 Direct tests * - changes, due to define renaming * - removed _ASIC_96001 specific stuff to invert colors * - 0.37 - removed // comments * - corrected output of 12bit/pixel * - 0.38 - added P12 stuff * - renamed WaitLineData functions to ReadOneImageLine * - 0.39 - fixed a problem in imageP98003ReadOneImageLine, that causes * these I/O timeouts... * - 0.40 - no changes * - 0.41 - no changes * - 0.42 - fixed a problem for the 12bit modes fo ASIC9800x based devices * - changed include names * - 0.43 - removed floating point stuff * - cleanup * - 0.44 - fix format string issues, as Long types default to int32_t * now * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #include "plustek-pp_scan.h" /************************ local definitions **********************************/ #define _LINE_TIMEOUT (_SECOND * 5 ) /* max 5 second per line ! */ /*************************** local vars **************************************/ static UShort wPreviewScanned = 0; static ExpXStepDef posScan[5] = {{128, 8}, {96, 12}, {96, 24}, {96, 48}, {96, 96}}; static ExpXStepDef negScan[5] = {{128, 8}, {96, 12}, {96, 24}, {96, 48}, {96, 96}}; static ExpXStepDef nmlScan[4][5] = { {{160, 10}, {96, 12}, {96, 24}, {96, 48}, {96, 96}}, /* EPP */ {{160, 10}, {128, 16}, {128, 32}, {192, 96}, {192, 96}}, /* SPP */ {{160, 10}, {96, 12}, {96, 24}, {160, 80}, {160, 160}}, /* BPP */ {{160, 10}, {96, 12}, {96, 24}, {96, 48}, {96, 96}} /* ECP */ }; static ThreshDef xferSpeed[4] = { {0, 3200, 2500}, {0, 1200, 800}, {0, 800, 1250}, {0, 3200, 2500} }; /*************************** local functions *********************************/ /** return the correct DPI-value * The ASIC 96001/3 models are limited to an optical resolution of 300 Dpi * so it´s necessary to scale in X and Y direction (see scale.c)! */ static UShort imageGetPhysDPI( pScanData ps, pImgDef pImgInf, Bool fDpiX ) { if( _IS_ASIC98(ps->sCaps.AsicID)) { if (fDpiX) { if (pImgInf->xyDpi.x > ps->LensInf.rDpiX.wPhyMax) return ps->LensInf.rDpiX.wPhyMax; else return pImgInf->xyDpi.x; } else { if (pImgInf->xyDpi.y > ps->LensInf.rDpiY.wPhyMax) return ps->LensInf.rDpiY.wPhyMax; else return pImgInf->xyDpi.y; } } else { if (fDpiX) { if (pImgInf->wDataType >= COLOR_TRUE24) { if (pImgInf->xyDpi.x > ps->LensInf.rDpiX.wPhyMax) return ps->LensInf.rDpiX.wPhyMax; else return pImgInf->xyDpi.x; } else { if (pImgInf->xyDpi.x > (ps->LensInf.rDpiX.wPhyMax * 2)) return (ps->LensInf.rDpiX.wPhyMax * 2); else return pImgInf->xyDpi.x; } } else { if (pImgInf->wDataType >= COLOR_TRUE24 ) { if (pImgInf->xyDpi.y > (ps->LensInf.rDpiY.wPhyMax / 2)) return (ps->LensInf.rDpiY.wPhyMax / 2); else return pImgInf->xyDpi.y; } else { if (pImgInf->xyDpi.y > ps->LensInf.rDpiY.wPhyMax) return ps->LensInf.rDpiY.wPhyMax; else return pImgInf->xyDpi.y; } } } } /***************************************************************************** * Sampling stuff for ASIC 98003 * *****************************************************************************/ static Bool fnEveryLines( pScanData ps ) { _VAR_NOT_USED( ps ); return _TRUE; } static Bool fnSampleLines( pScanData ps ) { ps->DataInf.wYSum += ps->DataInf.xyAppDpi.y; if( ps->DataInf.wYSum >= ps->DataInf.xyPhyDpi.y ) { ps->DataInf.wYSum -= ps->DataInf.xyPhyDpi.y; return _TRUE; } return _FALSE; } static Bool fnSamplePreview( pScanData ps ) { ps->DataInf.wYSum += wPreviewScanned; if( ps->DataInf.wYSum >= 150 ) { ps->DataInf.wYSum -= 150; return _TRUE; } return _FALSE; } /***************************************************************************** * Data Processing Routines * *****************************************************************************/ static Bool fnReadToDriver( pScanData ps ) { ps->AsicReg.RD_ModeControl = _ModeFifoBSel; IOReadScannerImageData( ps, ps->Scan.BufPut.blue.bp, ps->DataInf.dwAsicBytesPerPlane ); ps->AsicReg.RD_ModeControl = _ModeFifoGSel; IOReadScannerImageData( ps, ps->Scan.BufPut.green.bp, ps->DataInf.dwAsicBytesPerPlane ); if( ps->Scan.gd_gk.wGreenKeep ) ps->Scan.gd_gk.wGreenKeep--; else { ps->Scan.BufPut.green.bp += ps->DataInf.dwAsicBytesPerPlane; if( ps->Scan.BufPut.green.bp >= ps->Scan.BufEnd.green.bp ) ps->Scan.BufPut.green.bp = ps->Scan.BufBegin.green.bp; } ps->AsicReg.RD_ModeControl = _ModeFifoRSel; IOReadScannerImageData( ps, ps->Scan.BufPut.red.bp, ps->DataInf.dwAsicBytesPerPlane ); ps->Scan.BufPut.red.bp += ps->DataInf.dwAsicBytesPerPlane; if( ps->Scan.BufPut.red.bp >= ps->Scan.BufEnd.red.bp ) ps->Scan.BufPut.red.bp = ps->Scan.BufBegin.red.bp; if( ps->Scan.bd_rk.wRedKeep ) { ps->Scan.bd_rk.wRedKeep--; return _FALSE; } else { ps->Scan.BufData.green.bp = ps->Scan.BufGet.green.bp; if( ps->DataInf.dwScanFlag & SCANDEF_ColorBGROrder ) { ps->Scan.BufData.red.bp = ps->Scan.BufGet.blue.bp; ps->Scan.BufData.blue.bp = ps->Scan.BufGet.red.bp; } else { ps->Scan.BufData.red.bp = ps->Scan.BufGet.red.bp; ps->Scan.BufData.blue.bp = ps->Scan.BufGet.blue.bp; } ps->Scan.BufGet.red.bp += ps->DataInf.dwAsicBytesPerPlane; ps->Scan.BufGet.green.bp += ps->DataInf.dwAsicBytesPerPlane; if( ps->Scan.BufGet.red.bp >= ps->Scan.BufEnd.red.bp ) ps->Scan.BufGet.red.bp = ps->Scan.BufBegin.red.bp; if( ps->Scan.BufGet.green.bp >= ps->Scan.BufEnd.green.bp ) ps->Scan.BufGet.green.bp = ps->Scan.BufBegin.green.bp; return _TRUE; } } static Bool fnReadOutScanner( pScanData ps ) { if( ps->Scan.bd_rk.wBlueDiscard ) { ps->Scan.bd_rk.wBlueDiscard--; ps->AsicReg.RD_ModeControl = _ModeFifoBSel; IOReadScannerImageData( ps, ps->Bufs.b1.pReadBuf, ps->DataInf.dwAsicBytesPerPlane ); if( ps->Scan.gd_gk.wGreenDiscard ) { ps->Scan.gd_gk.wGreenDiscard--; ps->AsicReg.RD_ModeControl = _ModeFifoGSel; IOReadScannerImageData( ps, ps->Bufs.b1.pReadBuf, ps->DataInf.dwAsicBytesPerPlane); } return _FALSE; } else { IOReadColorData( ps, ps->Bufs.b1.pReadBuf, ps->DataInf.dwAsicBytesPerPlane ); return _TRUE; } } /** Interpolates the gray data by using averaged the continuous pixels */ static void fnP96GrayDirect( pScanData ps, pVoid pBuf, pVoid pImg, ULong bl ) { pUChar src, dest; src = (pUChar)pImg; dest = (pUChar)pBuf; for (; bl; bl--, src++, dest++ ) *dest = ps->pbMapRed [*src]; } /** This routine used in the condition: * 1) The data type is B/W or GrayScale. * 2) The required horizontal resolution doesn't exceed the optic spec. * 3) The required vertical resolution exceeds the optic spec. * So, the vertcal lines have to average with previous line to smooth the * image. */ static void fnDataDirect( pScanData ps, pVoid pBuf, pVoid pImg, ULong bl ) { _VAR_NOT_USED( ps ); memcpy( pBuf, pImg, bl ); } /** According to dither matrix to convert the input gray scale data into * one-bit data. */ static void fnHalftoneDirect0( pScanData ps, pVoid pb, pVoid pImg, ULong bL ) { pUChar pDither, src, dest; ULong dw; src = (pUChar)pImg; dest = (pUChar)pb; pDither = &ps->a_bDitherPattern[ps->dwDitherIndex]; for( ; bL; bL--, dest++, pDither -= 8 ) { for( dw = 8; dw; dw--, src++, pDither++ ) { if( *src < *pDither ) { *dest = (*dest << 1) | 0x01; } else { *dest <<= 1; } } } ps->dwDitherIndex = (ps->dwDitherIndex + 8) & 0x3f; } /** use random generator to make halftoning */ static void fnHalftoneDirect1( pScanData ps, pVoid pb, pVoid pImg, ULong bL ) { pUChar src, dest; UChar threshold; ULong dw; _VAR_NOT_USED( ps ); src = (pUChar)pImg; dest = (pUChar)pb; for (; bL; bL--, dest++ ) { for (dw = 8; dw; dw--, src++ ) { threshold = (UChar)MiscLongRand(); if (*src < threshold ) { *dest = (*dest << 1) | 0x01; } else { *dest <<= 1; } } } } /** Merges the color planes to pixels style without enlarge operation. */ static void fnP98ColorDirect( pScanData ps, pVoid pb, pVoid pImg, ULong bL ) { pUChar src; pRGBByteDef dest; src = (pUChar)pImg; dest = (pRGBByteDef)pb; for ( bL = ps->DataInf.dwAsicPixelsPerPlane; bL; bL--, src++, dest++) { dest->Red = *src; dest->Green = src[ps->DataInf.dwAsicPixelsPerPlane]; dest->Blue = src[ps->DataInf.dwAsicPixelsPerPlane*2]; } } static void fnP96ColorDirect( pScanData ps, pVoid pb, pVoid pImg, ULong bL ) { pUChar src; pRGBByteDef dest; src = (pUChar)pImg; dest = (pRGBByteDef)pb; for ( bL = ps->DataInf.dwAsicPixelsPerPlane; bL; bL--, dest++, src++) { dest->Red =ps->pbMapRed[*src]; dest->Green=ps->pbMapGreen[src[ps->DataInf.dwAsicPixelsPerPlane]]; dest->Blue =ps->pbMapBlue[src[ps->DataInf.dwAsicPixelsPerPlane*2]]; } } /** Merges the color planes to pixels style without enlarge operation. * The scanner returns the pixel data in Motorola-Format, so we have to swap */ static void fnP98Color48( pScanData ps, pVoid pb, pVoid pImg, ULong bL ) { pUShort src; pRGBUShortDef dest; register ULong i; _VAR_NOT_USED( bL ); src = (pUShort)pImg; dest = (pRGBUShortDef)pb; for ( i = ps->DataInf.dwAsicPixelsPerPlane; i; i--, src++, dest++) { dest->Red = *src; dest->Green = src[ps->DataInf.dwAsicPixelsPerPlane]; dest->Blue = src[ps->DataInf.dwAsicPixelsPerPlane * 2]; } } /** prepare for scanning */ static int imageP98SetupScanSettings( pScanData ps, pScanInfo pInf ) { UShort brightness; DBG( DBG_LOW, "imageP98SetupScanSettings()\n" ); ps->DataInf.dwScanFlag = pInf->ImgDef.dwFlag; ps->DataInf.dwVxdFlag = 0; ps->DataInf.crImage = pInf->ImgDef.crArea; /* AdjustOriginXByLens * [NOTE] * Here we just simply adjust it to double (600 DPI is two times of * 300 DPI), but if this model is a multi-lens scanner, we should adjust * it according to different lens. */ ps->DataInf.crImage.x <<= 1; ps->DataInf.xyAppDpi = pInf->ImgDef.xyDpi; ps->DataInf.siBrightness = pInf->siBrightness; ps->DataInf.wDither = pInf->wDither; ps->DataInf.wAppDataType = pInf->ImgDef.wDataType; ps->GetImageInfo( ps, &pInf->ImgDef ); if (ps->DataInf.dwVxdFlag & _VF_DATATOUSERBUFFER) { ps->Scan.DataProcess = fnDataDirect; } if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) { ps->Scan.lBufferAdjust = -(Long)ps->DataInf.dwAppBytesPerLine; } else { ps->Scan.lBufferAdjust = (Long)ps->DataInf.dwAppBytesPerLine; } DBG( DBG_LOW, "Scan settings:\n" ); DBG( DBG_LOW, "ImageInfo: (x=%u,y=%u,dx=%u,dy=%u)\n", ps->DataInf.crImage.x, ps->DataInf.crImage.y, ps->DataInf.crImage.cx, ps->DataInf.crImage.cy ); /* * SetBwBrightness * [NOTE] * * 0 _DEF_BW_THRESHOLD 255 * +-------------------------+--------------------------------+ * |<------- Black --------->|<----------- White ------------>| * So, if user wish to make image darker, the threshold value should be * higher than _defBwThreshold, otherwise it should lower than the * _DefBwThreshold. * Darker = _DefBwThreshold + White * Input / 127; * Input < 0, and White = 255 - _DefBwThreshold, so * = _DefBwThreshold - (255 - _DefBwThreshold) * Input / 127; * The brighter is the same idea. * * CHECK: it seems that the brightness only works for the binary mode ! */ if( ps->DataInf.wPhyDataType != COLOR_BW ) {/* if not line art */ ps->wBrightness = pInf->siBrightness; /* use internal tables for */ ps->wContrast = pInf->siContrast; /* brightness and contrast */ pInf->siBrightness = 0; /* don't use asic for threshold */ } /* CHECK: We have now two methods for setting the brightness... */ DBG( DBG_LOW, "brightness = %i\n", pInf->siBrightness ); if (ps->DataInf.siBrightness < 0) { brightness = (UShort)(_DEF_BW_THRESHOLD - (255 - _DEF_BW_THRESHOLD) * ps->DataInf.siBrightness /127); } else { brightness = (UShort)(_DEF_BW_THRESHOLD - _DEF_BW_THRESHOLD * ps->DataInf.siBrightness /127); } ps->AsicReg.RD_ThresholdControl = brightness; DBG( DBG_LOW, "1. brightness = %i\n", brightness ); if( ps->DataInf.siBrightness >= 0 ) { brightness = (short)((long)(-(255 - _DEF_BW_THRESHOLD) * ps->DataInf.siBrightness) / 127 + _DEF_BW_THRESHOLD); } else { brightness = (short)((long)(_DEF_BW_THRESHOLD * ps->DataInf.siBrightness) / 127 + _DEF_BW_THRESHOLD); } brightness = (brightness ^ 0xff) & 0xff; if( _ASIC_IS_98003 == ps->sCaps.AsicID ) { ps->AsicReg.RD_ThresholdControl = brightness; DBG( DBG_LOW, "2. brightness = %i\n", brightness ); } ps->DataInf.pCurrentBuffer = ps->pScanBuffer1; return _OK; } /** */ static void imageP98DoCopyBuffer( pScanData ps, pUChar pImage ) { memcpy( ps->pFilterBuf, pImage, ps->DataInf.dwAsicBytesPerPlane ); ps->pFilterBuf += 5120; if (ps->pFilterBuf >= ps->pEndBuf) ps->pFilterBuf = ps->pProcessingBuf; } /** */ static Bool imageP98CopyToFilterBuffer( pScanData ps, pUChar pImage ) { if (ps->fDoFilter) { if (ps->fFilterFirstLine) { imageP98DoCopyBuffer( ps, pImage ); imageP98DoCopyBuffer( ps, pImage ); ps->dwLinesFilter--; return _FALSE; } else { imageP98DoCopyBuffer( ps, pImage ); if ((ps->dwLinesFilter--) == 0) imageP98DoCopyBuffer( ps, pImage); } } return _TRUE; } /** */ static void imageP98UnSharpCompare( pScanData ps, Byte Center, Byte Neighbour, pLong pdwNewValue ) { Byte b; b = (Center >= Neighbour) ? Center - Neighbour : Neighbour - Center ; if (b > ps->bOffsetFilter) { *pdwNewValue -= (Long)Neighbour; ps->dwDivFilter--; } } /** */ static void imageP98DoFilter( pScanData ps, pUChar pPut ) { ULong dw; Long dwNewValue; if (ps->fDoFilter && (ps->DataInf.xyAppDpi.x) >= 600UL) { /* DoUnsharpMask(); */ for (dw = 0; dw < ps->DataInf.dwAsicBytesPerPlane - 2; dw++, pPut++) { ps->dwDivFilter = ps->dwMul; dwNewValue = ((ULong)ps->pGet2[dw+1]) * ps->dwMul; imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet1[dw], &dwNewValue); imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet1[dw+1], &dwNewValue); imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet1[dw+2], &dwNewValue); imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet2[dw], &dwNewValue); imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet2[dw+2], &dwNewValue); imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet3[dw], &dwNewValue); imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet3[dw+1], &dwNewValue); imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet3[dw+2], &dwNewValue); if( dwNewValue > 0 ) { if((dwNewValue /= ps->dwDivFilter) < 255) { *pPut = (Byte) dwNewValue; } else { *pPut = 255; } } else { *pPut = 0; } } pPut = ps->pGet1; ps->pGet1 = ps->pGet2; ps->pGet2 = ps->pGet3; ps->pGet3 = pPut; } } /** */ static Bool imageP98DataIsReady( pScanData ps ) { Byte b; ps->Scan.fMotorBackward = _FALSE; ps->bMoveDataOutFlag = _DataAfterRefreshState; b = (ps->DataInf.wPhyDataType >= COLOR_TRUE24) ? _BLUE_DATA_READY : _GREEN_DATA_READY; while( _TRUE ) { ps->dwColorRunIndex ++; if(ps->pColorRunTable[ps->dwColorRunIndex] & b) break; } if (b == _GREEN_DATA_READY) { ps->AsicReg.RD_ModeControl = _ModeFifoGSel; IOReadScannerImageData( ps, ps->DataInf.pCurrentBuffer, ps->DataInf.dwAsicBytesPerPlane ); imageP98CopyToFilterBuffer( ps, ps->DataInf.pCurrentBuffer ); } else { /* ReadColorImageData() */ if( ps->DataInf.dwScanFlag & SCANDEF_ColorBGROrder ) { ps->AsicReg.RD_ModeControl = _ModeFifoRSel; IOReadScannerImageData( ps, ps->pScanBuffer1 + ps->DataInf.dwAsicBytesPerPlane * 2, ps->DataInf.dwAsicBytesPerPlane ); ps->AsicReg.RD_ModeControl = _ModeFifoGSel; IOReadScannerImageData( ps, ps->pScanBuffer1 + ps->DataInf.dwAsicBytesPerPlane, ps->DataInf.dwAsicBytesPerPlane ); ps->AsicReg.RD_ModeControl = _ModeFifoBSel; IOReadScannerImageData( ps, ps->pScanBuffer1, ps->DataInf.dwAsicBytesPerPlane ); } else { IOReadColorData( ps, ps->pScanBuffer1, ps->DataInf.dwAsicBytesPerPlane ); } } if (ps->fFilterFirstLine) { ps->fFilterFirstLine = _FALSE; return _TRUE; } imageP98DoFilter( ps, ps->DataInf.pCurrentBuffer ); (*ps->Scan.DataProcess)( ps, ps->Scan.bp.pMonoBuf, ps->DataInf.pCurrentBuffer, ps->DataInf.dwAppPhyBytesPerLine ); return _TRUE; } /** here we wait for one data-line */ static Bool imageP98001ReadOneImageLine( pScanData ps ) { ULong dwFifoCounter; TimerDef timer; MiscStartTimer( &timer, _LINE_TIMEOUT ); do { ps->Scan.bNowScanState = IOGetScanState( ps, _FALSE ); dwFifoCounter = IOReadFifoLength( ps ); if (!(ps->Scan.bNowScanState & _SCANSTATE_STOP) && (dwFifoCounter < ps->dwMaxReadFifoData)) { if( ps->Scan.bOldScanState != ps->Scan.bNowScanState ) ps->UpdateDataCurrentReadLine( ps ); if( dwFifoCounter >= ps->Scan.dwMinReadFifo ) return imageP98DataIsReady( ps ); } else { /* ScanStateIsStop */ if (dwFifoCounter >= ps->dwSizeMustProcess) return imageP98DataIsReady( ps ); ps->UpdateDataCurrentReadLine( ps ); if( dwFifoCounter >= ps->Scan.dwMinReadFifo ) return imageP98DataIsReady( ps ); } _DODELAY(10); /* delay 10 ms */ } while (!MiscCheckTimer( &timer )); DBG( DBG_HIGH, "Timeout - Scanner malfunction !!\n" ); MotorToHomePosition(ps); /* timed out, scanner malfunction */ return _FALSE; } /** calculate the image properties according to the scanmode */ static void imageP98GetInfo( pScanData ps, pImgDef pImgInf ) { DBG( DBG_LOW, "imageP98GetInfo()\n" ); ps->DataInf.xyPhyDpi.x = imageGetPhysDPI( ps, pImgInf, _TRUE ); ps->DataInf.xyPhyDpi.y = imageGetPhysDPI( ps, pImgInf, _FALSE ); DBG( DBG_LOW, "xyPhyDpi.x = %u, xyPhyDpi.y = %u\n", ps->DataInf.xyPhyDpi.x, ps->DataInf.xyPhyDpi.y ); DBG( DBG_LOW, "crArea.x = %u, crArea.y = %u\n", pImgInf->crArea.x, pImgInf->crArea.y ); DBG( DBG_LOW, "crArea.cx = %u, crArea.cy = %u\n", pImgInf->crArea.cx, pImgInf->crArea.cy ); ps->DataInf.XYRatio = 1000 * ps->DataInf.xyPhyDpi.y/ps->DataInf.xyPhyDpi.x; DBG( DBG_LOW, "xyDpi.x = %u, xyDpi.y = %u, XYRatio = %u\n", pImgInf->xyDpi.x, pImgInf->xyDpi.y, ps->DataInf.XYRatio ); ps->DataInf.dwAppLinesPerArea = (ULong)pImgInf->crArea.cy * pImgInf->xyDpi.y / _MEASURE_BASE; ps->DataInf.dwAppPixelsPerLine = (ULong)pImgInf->crArea.cx * pImgInf->xyDpi.x / _MEASURE_BASE; ps->DataInf.dwPhysBytesPerLine = (ULong)pImgInf->crArea.cx * ps->DataInf.xyPhyDpi.x / _MEASURE_BASE; if( pImgInf->wDataType <= COLOR_HALFTONE ) { ps->DataInf.dwAsicPixelsPerPlane = (ps->DataInf.dwAppPixelsPerLine+7UL)& 0xfffffff8UL; ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppBytesPerLine = ps->DataInf.dwAsicBytesPerLine = ps->DataInf.dwAsicBytesPerPlane = ps->DataInf.dwAsicPixelsPerPlane>>3; } else { ps->DataInf.dwAsicBytesPerPlane = ps->DataInf.dwAsicPixelsPerPlane = ps->DataInf.dwAppPixelsPerLine; } if( COLOR_TRUE48 == pImgInf->wDataType ) { ps->DataInf.dwAsicBytesPerPlane *= 2; } switch( pImgInf->wDataType ) { case COLOR_BW: ps->DataInf.dwVxdFlag |= _VF_DATATOUSERBUFFER; ps->DataInf.wPhyDataType = COLOR_BW; ps->Shade.bIntermediate = _ScanMode_Mono; break; case COLOR_HALFTONE: if( ps->DataInf.wDither == 2 ) { ps->Scan.DataProcess = fnHalftoneDirect1; } else { ps->Scan.DataProcess = fnHalftoneDirect0; } /* * CHANGE: it seems, that we have to use the same settings as for 256GRAY */ ps->DataInf.dwAsicBytesPerPlane = ps->DataInf.dwAsicPixelsPerPlane = ps->DataInf.dwAppPixelsPerLine; ps->DataInf.wPhyDataType = COLOR_256GRAY; ps->Shade.bIntermediate = _ScanMode_Mono; break; case COLOR_256GRAY: ps->DataInf.dwVxdFlag |= _VF_DATATOUSERBUFFER; ps->DataInf.dwAsicBytesPerLine = ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine; ps->DataInf.wPhyDataType = COLOR_256GRAY; ps->Shade.bIntermediate = _ScanMode_Mono; break; case COLOR_TRUE24: ps->Scan.DataProcess = fnP98ColorDirect; ps->DataInf.dwAsicBytesPerLine = ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine * 3; ps->DataInf.wPhyDataType = COLOR_TRUE24; ps->Shade.bIntermediate = _ScanMode_Color; break; case COLOR_TRUE48: ps->Scan.DataProcess = fnP98Color48; ps->DataInf.dwAsicBytesPerLine = ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine * 6; ps->DataInf.wPhyDataType = COLOR_TRUE48; ps->Shade.bIntermediate = _ScanMode_Color; break; } if (pImgInf->dwFlag & SCANDEF_BoundaryDWORD) { ps->DataInf.dwAppBytesPerLine = (ps->DataInf.dwAppPhyBytesPerLine + 3) & 0xfffffffc; } else { if (pImgInf->dwFlag & SCANDEF_BoundaryWORD) { ps->DataInf.dwAppBytesPerLine = (ps->DataInf.dwAppPhyBytesPerLine + 1) & 0xfffffffe; } else { ps->DataInf.dwAppBytesPerLine = ps->DataInf.dwAppPhyBytesPerLine; } } DBG( DBG_LOW, "AppLinesPerArea = %u\n", ps->DataInf.dwAppLinesPerArea ); DBG( DBG_LOW, "AppPixelsPerLine = %u\n", ps->DataInf.dwAppPixelsPerLine ); DBG( DBG_LOW, "AppPhyBytesPerLine = %u\n", ps->DataInf.dwAppPhyBytesPerLine ); DBG( DBG_LOW, "AppBytesPerLine = %u\n", ps->DataInf.dwAppBytesPerLine ); DBG( DBG_LOW, "AsicPixelsPerPlane = %u\n", ps->DataInf.dwAsicPixelsPerPlane ); DBG( DBG_LOW, "AsicBytesPerPlane = %u\n", ps->DataInf.dwAsicBytesPerPlane ); DBG( DBG_LOW, "AsicBytesPerLine = %u\n", ps->DataInf.dwAsicBytesPerLine ); DBG( DBG_LOW, "Physical Bytes = %u\n", ps->DataInf.dwPhysBytesPerLine ); } /** */ static void imageP96GetInfo( pScanData ps, pImgDef pImgInf ) { DBG( DBG_LOW, "imageP96GetInfo()\n" ); ps->DataInf.xyPhyDpi.x = imageGetPhysDPI( ps, pImgInf, _TRUE ); ps->DataInf.xyPhyDpi.y = imageGetPhysDPI( ps, pImgInf, _FALSE ); DBG( DBG_LOW, "xyPhyDpi.x = %u, xyPhyDpi.y = %u\n", ps->DataInf.xyPhyDpi.x, ps->DataInf.xyPhyDpi.y ); DBG( DBG_LOW, "crArea.x = %u, crArea.y = %u\n", pImgInf->crArea.x, pImgInf->crArea.y ); DBG( DBG_LOW, "crArea.cx = %u, crArea.cy = %u\n", pImgInf->crArea.cx, pImgInf->crArea.cy ); ps->DataInf.XYRatio = 1000 * ps->DataInf.xyPhyDpi.y/ps->DataInf.xyPhyDpi.x; DBG( DBG_LOW, "xyDpi.x = %u, xyDpi.y = %u, XYRatio = %u\n", pImgInf->xyDpi.x, pImgInf->xyDpi.y, ps->DataInf.XYRatio ); ps->DataInf.dwAppLinesPerArea = (ULong)pImgInf->crArea.cy * pImgInf->xyDpi.y / _MEASURE_BASE; ps->DataInf.dwAsicBytesPerPlane = ps->DataInf.dwAsicPixelsPerPlane = (ULong)ps->DataInf.xyPhyDpi.x * pImgInf->crArea.cx / _MEASURE_BASE; ps->DataInf.dwAppPixelsPerLine = (ULong)pImgInf->crArea.cx * pImgInf->xyDpi.x / _MEASURE_BASE; ps->DataInf.dwPhysBytesPerLine = (ULong)pImgInf->crArea.cx * ps->DataInf.xyPhyDpi.x / _MEASURE_BASE; ps->DataInf.wPhyDataType = ps->DataInf.wAppDataType; switch( pImgInf->wDataType ) { case COLOR_BW: ps->DataInf.dwAsicBytesPerPlane = (ps->DataInf.dwAsicPixelsPerPlane + 7) >> 3; ps->DataInf.dwAppPhyBytesPerLine = (ps->DataInf.dwAppPixelsPerLine + 7) >> 3; ps->DataInf.dwVxdFlag |= _VF_DATATOUSERBUFFER; ps->Scan.DataProcess = fnDataDirect; break; case COLOR_HALFTONE: ps->DataInf.dwAppPhyBytesPerLine = (ps->DataInf.dwAsicPixelsPerPlane + 7) >> 3; if( ps->DataInf.wDither == 2 ) { ps->Scan.DataProcess = fnHalftoneDirect1; } else { ps->Scan.DataProcess = fnHalftoneDirect0; } ps->DataInf.wPhyDataType = COLOR_256GRAY; break; case COLOR_256GRAY: ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine; ps->Scan.DataProcess = fnP96GrayDirect; break; case COLOR_TRUE24: #ifdef _A3I_EN ps->Scan.DataProcess = fnP98ColorDirect; #else ps->Scan.DataProcess = fnP96ColorDirect; #endif ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine * 3; } if( pImgInf->dwFlag & SCANDEF_BoundaryDWORD ) { ps->DataInf.dwAppBytesPerLine = (ps->DataInf.dwAppPhyBytesPerLine + 3) & 0xfffffffc; } else { if ( pImgInf->dwFlag & SCANDEF_BoundaryWORD ) { ps->DataInf.dwAppBytesPerLine = (ps->DataInf.dwAppPhyBytesPerLine + 1) & 0xfffffffe; } else { ps->DataInf.dwAppBytesPerLine = ps->DataInf.dwAppPhyBytesPerLine; } } if (ps->DataInf.wPhyDataType == COLOR_TRUE24) ps->DataInf.dwAsicBytesPerLine = ps->DataInf.dwAsicBytesPerPlane * 3; else ps->DataInf.dwAsicBytesPerLine = ps->DataInf.dwAsicBytesPerPlane; /* WORK: AsicBytesPerLine only used for ASIC_98001 based scanners - try to remove ** that, also try to remove redundant info */ DBG( DBG_LOW, "AppLinesPerArea = %u\n", ps->DataInf.dwAppLinesPerArea ); DBG( DBG_LOW, "AppPixelsPerLine = %u\n", ps->DataInf.dwAppPixelsPerLine ); DBG( DBG_LOW, "AppPhyBytesPerLine = %u\n", ps->DataInf.dwAppPhyBytesPerLine ); DBG( DBG_LOW, "AppBytesPerLine = %u\n", ps->DataInf.dwAppBytesPerLine ); DBG( DBG_LOW, "AsicPixelsPerPlane = %u\n", ps->DataInf.dwAsicPixelsPerPlane ); DBG( DBG_LOW, "AsicBytesPerPlane = %u\n", ps->DataInf.dwAsicBytesPerPlane ); DBG( DBG_LOW, "AsicBytesPerLine = %u\n", ps->DataInf.dwAsicBytesPerLine ); DBG( DBG_LOW, "Physical Bytes = %u\n", ps->DataInf.dwPhysBytesPerLine ); } /** here we wait for one data-line */ static Bool imageP96ReadOneImageLine( pScanData ps ) { Bool result = _FALSE; Byte bData, bFifoCount; TimerDef timer; MiscStartTimer( &timer, _LINE_TIMEOUT); do { bFifoCount = IODataRegisterFromScanner( ps, ps->RegFifoOffset ); /* CHECK ps->bMoveDataOutFlag will never be set to _DataFromStopState !!!*/ #if 1 if ((bFifoCount < ps->bMinReadFifo) && (ps->bMoveDataOutFlag == _DataFromStopState)) { bData = IOGetScanState( ps, _FALSE); if (!(bData & _SCANSTATE_STOP)) { if (bData < ps->bCurrentLineCount) bData += _NUMBER_OF_SCANSTEPS; if ((bData - ps->bCurrentLineCount) < _SCANSTATE_BYTES) continue; } ps->bMoveDataOutFlag = _DataAfterRefreshState; } #endif /* // HEINER:A3I // if( ps->bMoveDataOutFlag != _DataFromStopState ) // ps->UpdateDataCurrentReadLine( ps ); */ if( bFifoCount >= ps->bMinReadFifo ) { /* data is ready */ for (; !(*ps->pCurrentColorRunTable & (ps->RedDataReady | ps->GreenDataReady | _BLUE_DATA_READY)); ps->pCurrentColorRunTable++); #ifdef DEBUG if( ps->pCurrentColorRunTable > (ps->pColorRunTable+ps->BufferForColorRunTable)) DBG( DBG_LOW, "WARNING: pCurrentColorRunTab>pColorRunTable\n"); #endif if (ps->DataInf.wPhyDataType == COLOR_TRUE24) { /* read color planes (either R/G/B or R/B/G sequence that * depends on COLOR CCD, see below */ if (*ps->pCurrentColorRunTable & ps->b1stColor) { *ps->pCurrentColorRunTable &= ps->b1stMask; IOReadScannerImageData (ps, ps->pPutBufR, ps->DataInf.dwAsicBytesPerPlane); ps->pPutBufR += ps->BufferSizePerModel; if (ps->pPutBufR == ps->pEndBufR) ps->pPutBufR = ps->pPrescan16; } else if (*ps->pCurrentColorRunTable & ps->b2ndColor) { *ps->pCurrentColorRunTable &= ps->b2ndMask; IOReadScannerImageData( ps, ps->pPutBufG, ps->DataInf.dwAsicBytesPerPlane); ps->pPutBufG += ps->BufferSizePerModel; if (ps->pPutBufG == ps->pEndBufG) ps->pPutBufG = ps->pPrescan8; } else { *ps->pCurrentColorRunTable &= ps->b3rdMask; ps->pCurrentColorRunTable++; /* processed this step */ /* according to CCD type & image placement method to * read third color into corresponding location. * SONY CCD: Red, Green and Blue. * TOSHIBA CCD: Red, Blue and Green. * SCANDEF_BmpStyle: Blue, Green and Red, Otherwise * Red, Green and Blue. */ if (ps->b3rdColor & ps->GreenDataReady) { /* Green always in middle */ IOReadScannerImageData (ps, ps->DataInf.pCurrentBuffer + ps->DataInf.dwAsicBytesPerPlane, ps->DataInf.dwAsicBytesPerPlane); } else { /* Blue depends the request style from caller */ if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) { /* BMP style, blue is the first one */ IOReadScannerImageData (ps, ps->DataInf.pCurrentBuffer, ps->DataInf.dwAsicBytesPerPlane); } else { /* Blue is the last one */ IOReadScannerImageData (ps, ps->DataInf.pCurrentBuffer + ps->DataInf.dwAsicBytesPerPlane * 2, ps->DataInf.dwAsicBytesPerPlane); } } /* reassemble 3 color lines for separated RGB value */ if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) { /* BMP style, red is last one */ memcpy( ps->DataInf.pCurrentBuffer + ps->DataInf.dwAsicBytesPerPlane * 2, ps->pGetBufR, ps->DataInf.dwAsicBytesPerPlane); } else { /* Red is first one */ memcpy( ps->DataInf.pCurrentBuffer, ps->pGetBufR, ps->DataInf.dwAsicBytesPerPlane ); } if (ps->b2ndColor & ps->GreenDataReady) { /* Green always in middle */ memcpy( ps->DataInf.pCurrentBuffer + ps->DataInf.dwAsicBytesPerPlane, ps->pGetBufG, ps->DataInf.dwAsicBytesPerPlane); } else { /* Blue depends the request style from caller */ if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) { /* BMP style, blue is the first one */ memcpy( ps->DataInf.pCurrentBuffer, ps->pGetBufG, ps->DataInf.dwAsicBytesPerPlane); } else { /* BMP style, blue is the last one */ memcpy( ps->DataInf.pCurrentBuffer + ps->DataInf.dwAsicBytesPerPlane * 2, ps->pGetBufG, ps->DataInf.dwAsicBytesPerPlane ); } } /* Adjust the get pointers */ ps->pGetBufR += ps->BufferSizePerModel; ps->pGetBufG += ps->BufferSizePerModel; if (ps->pGetBufR == ps->pEndBufR) ps->pGetBufR = ps->pPrescan16; if (ps->pGetBufG == ps->pEndBufG) ps->pGetBufG = ps->pPrescan8; result = _TRUE; /* Line data in buffer */ break; } /* reset timer for new 10-second interval */ MiscStartTimer( &timer, (10 * _SECOND)); } else { /* Gray Image */ *ps->pCurrentColorRunTable &= 0xf0; /* leave high nibble for debug */ ps->pCurrentColorRunTable++; /* this step has been processed */ IOReadScannerImageData( ps, ps->DataInf.pCurrentBuffer, ps->DataInf.dwAsicBytesPerPlane ); result = _TRUE; break; } } /* HEINER:A3I */ if( ps->bMoveDataOutFlag != _DataFromStopState ) ps->UpdateDataCurrentReadLine( ps ); } while (!MiscCheckTimer( &timer)); if( _TRUE == result ) { (*ps->Scan.DataProcess)( ps, ps->Scan.bp.pMonoBuf, ps->DataInf.pCurrentBuffer, ps->DataInf.dwAppPhyBytesPerLine ); return _TRUE; } DBG( DBG_HIGH, "Timeout - Scanner malfunction !!\n" ); MotorToHomePosition(ps); return _FALSE; } /** prepare for scanning */ static int imageP96SetupScanSettings( pScanData ps, pScanInfo pInf ) { DBG( DBG_LOW, "imageSetupP96ScanSettings()\n" ); ps->DataInf.dwVxdFlag = 0; if (pInf->ImgDef.dwFlag & SCANDEF_BuildBwMap) ps->DataInf.dwVxdFlag |= _VF_BUILDMAP; ps->DataInf.dwScanFlag = pInf->ImgDef.dwFlag; ps->DataInf.crImage = pInf->ImgDef.crArea; /* scale according to DPI */ ps->DataInf.crImage.x *= ps->PhysicalDpi / _MEASURE_BASE; ps->DataInf.crImage.cx *= ps->PhysicalDpi / _MEASURE_BASE; if( ps->DataInf.dwScanFlag & SCANDEF_TPA ) { ps->DataInf.crImage.x += _Transparency48OriginOffsetX; ps->DataInf.crImage.y += _Transparency48OriginOffsetY; } ps->DataInf.xyAppDpi = pInf->ImgDef.xyDpi; ps->DataInf.wAppDataType = pInf->ImgDef.wDataType; ps->DataInf.wDither = pInf->wDither; ps->GetImageInfo( ps, &pInf->ImgDef ); /* try to get brightness to work */ if (ps->DataInf.wPhyDataType != COLOR_BW) { /* if not line art */ ps->wBrightness = pInf->siBrightness; /* use internal tables for */ ps->wContrast = pInf->siContrast; /* brightness and contrast */ pInf->siBrightness = 0; /* don't use asic for threshold */ } ps->DataInf.siBrightness = pInf->siBrightness; if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) ps->Scan.lBufferAdjust = -(Long)ps->DataInf.dwAppBytesPerLine; else ps->Scan.lBufferAdjust = (Long)ps->DataInf.dwAppBytesPerLine; if (ps->DataInf.siBrightness < 0) ps->DataInf.siBrightness = 255 - (_DEF_BW_THRESHOLD * ps->DataInf.siBrightness / 127 + _DEF_BW_THRESHOLD); else ps->DataInf.siBrightness = 255 - ((255 - _DEF_BW_THRESHOLD) * ps->DataInf.siBrightness / 127 + _DEF_BW_THRESHOLD); ps->AsicReg.RD_ThresholdControl = (Byte)ps->DataInf.siBrightness; ps->DataInf.pCurrentBuffer = ps->pScanBuffer1; return _OK; } /** */ static Bool imageP98003DataIsReady( pScanData ps ) { pUChar pb; if( ps->Scan.bDiscardAll ) { ps->Scan.bDiscardAll--; if( ps->DataInf.wPhyDataType <= COLOR_256GRAY ) { ps->AsicReg.RD_ModeControl = _ModeFifoGSel; IOReadScannerImageData( ps, ps->Bufs.b1.pReadBuf, ps->DataInf.dwAsicBytesPerPlane ); } else { IOReadColorData( ps, ps->Bufs.b1.pReadBuf, ps->DataInf.dwAsicBytesPerPlane ); } return _FALSE; } if( ps->DataInf.wPhyDataType <= COLOR_256GRAY ) { ps->AsicReg.RD_ModeControl = _ModeFifoGSel; pb = ps->Scan.bp.pMonoBuf; /* use a larger buffer during halftone reads...*/ if( ps->DataInf.wAppDataType == COLOR_HALFTONE ) pb = ps->Scan.BufPut.red.bp; IOReadScannerImageData( ps, pb, ps->DataInf.dwAsicBytesPerPlane ); } else { if( !ps->Scan.DataRead( ps )) { return _FALSE; } } if( ps->Scan.DoSample( ps )) { if( ps->Scan.dwLinesToRead == 1 && !(IOGetScanState( ps, _TRUE ) & _SCANSTATE_STOP)) IORegisterToScanner( ps, ps->RegRefreshScanState ); /* direct is done here without copying...*/ if( fnDataDirect != ps->Scan.DataProcess ) { (*ps->Scan.DataProcess)(ps, (pVoid)(ps->Scan.bp.pMonoBuf ), (pVoid)(ps->Scan.BufPut.red.bp), ps->DataInf.dwAppPhyBytesPerLine); } return _TRUE; } return _FALSE; } /** */ static Bool imageP98003ReadOneImageLine( pScanData ps ) { Byte b, state; TimerDef timer, t2; MiscStartTimer( &timer, _LINE_TIMEOUT ); MiscStartTimer( &t2, _SECOND*2 ); do { state = IOGetScanState( ps, _TRUE ); ps->Scan.bNowScanState = (state & _SCANSTATE_MASK); if( state & _SCANSTATE_STOP ) { MotorP98003ModuleForwardBackward( ps ); if( IOReadFifoLength( ps ) >= ps->Scan.dwMinReadFifo ) if( imageP98003DataIsReady( ps )) return _TRUE; } else { ps->Scan.bModuleState = _MotorInNormalState; b = ps->Scan.bNowScanState - ps->Scan.bOldScanState; if((char) b < 0) b += _NUMBER_OF_SCANSTEPS; if( b >= ps->Scan.bRefresh ) { IORegisterToScanner( ps, ps->RegRefreshScanState ); ps->Scan.bOldScanState = IOGetScanState( ps, _TRUE ); ps->Scan.bOldScanState &= _SCANSTATE_MASK; } if( IOReadFifoLength( ps ) >= ps->Scan.dwMaxReadFifo ) { if( imageP98003DataIsReady( ps )) return _TRUE; } else { b = ps->Scan.bNowScanState - ps->Scan.bOldScanState; if((char) b < 0) b += _NUMBER_OF_SCANSTEPS; if( b >= ps->Scan.bRefresh ) { IORegisterToScanner( ps, ps->RegRefreshScanState ); ps->Scan.bOldScanState = IOGetScanState( ps, _TRUE ); ps->Scan.bOldScanState &= _SCANSTATE_MASK; } if( IOReadFifoLength( ps ) >= ps->Scan.dwMinReadFifo ) { if( imageP98003DataIsReady( ps )) return _TRUE; } } } _DODELAY(5); /* delay 5 ms */ } while( !MiscCheckTimer( &timer )); #ifdef __KERNEL__ _PRINT( #else DBG( DBG_HIGH, #endif "Timeout - Scanner malfunction !!\n" ); MotorToHomePosition(ps); /* timed out, scanner malfunction */ return _FALSE; } /** */ static void imageP98003SetupScanStateVariables( pScanData ps, ULong index ) { DataType var; ps->Scan.dpiIdx = index; if(!(ps->DataInf.dwScanFlag & SCANDEF_TPA)) { if(((ps->IO.portMode == _PORT_BIDI) || (ps->IO.portMode == _PORT_SPP)) && (ps->DataInf.wPhyDataType > COLOR_TRUE24) && (ps->DataInf.xyAppDpi.y >= 600)) { ps->Shade.wExposure = nmlScan[ps->IO.portMode][index].exposureTime; ps->Shade.wXStep = nmlScan[ps->IO.portMode][index].xStepTime; } else { ps->Shade.wExposure = nmlScan[_PORT_EPP][index].exposureTime; ps->Shade.wXStep = nmlScan[_PORT_EPP][index].xStepTime; } if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) { ps->Shade.wExposure >>= 1; ps->Shade.wXStep >>= 1; } } else { if( ps->DataInf.dwScanFlag & SCANDEF_Transparency ) { ps->Shade.wExposure = posScan[index].exposureTime; ps->Shade.wXStep = posScan[index].xStepTime; } else { ps->Shade.wExposure = ps->Scan.negScan[index].exposureTime; ps->Shade.wXStep = ps->Scan.negScan[index].xStepTime; } } ps->Scan.dwInterlace = 0; ps->Scan.dwInterval = 1; if( ps->DataInf.wPhyDataType == COLOR_BW ) var.dwValue = xferSpeed[ps->IO.portMode].thresholdBW; else { if( ps->DataInf.wPhyDataType == COLOR_256GRAY ) var.dwValue = xferSpeed[ps->IO.portMode].thresholdGray; else var.dwValue = xferSpeed[ps->IO.portMode].thresholdColor; } /* for small size/descreen */ if((ps->DataInf.xyAppDpi.y >= 300) && var.dwValue && (ps->DataInf.dwAsicBytesPerPlane <= var.dwValue)) { ps->Scan.dwInterval <<= 1; } if( var.dwValue && ps->DataInf.dwAsicBytesPerPlane > var.dwValue ) { if((var.dwValue << 1) > ps->DataInf.dwAsicBytesPerPlane) ps->Scan.dwInterval <<= 1; else if((var.dwValue << 2) > ps->DataInf.dwAsicBytesPerPlane) ps->Scan.dwInterval <<= 2; else ps->Scan.dwInterval <<= 3; } /* 48 bit/600 dpi/Bpp mode will scan failed */ if(((ps->IO.portMode == _PORT_BIDI) || (ps->IO.portMode == _PORT_SPP)) && (ps->DataInf.wPhyDataType > COLOR_TRUE24) && (ps->DataInf.xyAppDpi.y >= 600)) { ps->Scan.dwInterval <<= 1; } if( ps->DataInf.wPhyDataType >= COLOR_TRUE24 ) { if( ps->DataInf.xyPhyDpi.y > 75U ) { if( ps->Device.f0_8_16 ) { ps->Scan.gd_gk.wGreenDiscard = ps->DataInf.xyPhyDpi.y / 75U; } else { ps->Scan.gd_gk.wGreenDiscard = ps->DataInf.xyPhyDpi.y / 150U; } } else { ps->Scan.gd_gk.wGreenDiscard = 1; } ps->Scan.bd_rk.wBlueDiscard = ps->Scan.gd_gk.wGreenDiscard << 1; } else { ps->Scan.bd_rk.wBlueDiscard = ps->Scan.gd_gk.wGreenDiscard = 0; } } /** PrepareScanningVariables() !!! */ static int imageP98003SetupScanSettings( pScanData ps, pScanInfo pInf ) { DBG( DBG_LOW, "imageP98003SetupScanSettings()\n" ); /* call the one for ASIC 98001 first */ imageP98SetupScanSettings( ps, pInf ); if( !(ps->DataInf.dwScanFlag & SCANDEF_TPA )) { ps->Scan.dwScanOrigin = ps->Device.lUpNormal * 4 + _RFT_SCANNING_ORG; } else if( ps->DataInf.dwScanFlag & SCANDEF_Transparency) { ps->Scan.dwScanOrigin = ps->Device.lUpPositive * 4 + _POS_SCANNING_ORG; } else { ps->Scan.dwScanOrigin = ps->Device.lUpNegative * 4 + _NEG_SCANNING_ORG; } ps->Scan.dwScanOrigin += ps->Device.dwModelOriginY; /* ------- Setup CCD Offset variables ------- */ if( ps->DataInf.xyAppDpi.y <= 75 ) { if( ps->DataInf.dwVxdFlag & _VF_PREVIEW ) { ps->Scan.bDiscardAll = 0; ps->DataInf.xyPhyDpi.y = 150; ps->Shade.bIntermediate |= _ScanMode_AverageOut; imageP98003SetupScanStateVariables( ps, 1 ); ps->Scan.gd_gk.wGreenDiscard = 0; if( ps->DataInf.xyAppDpi.y >= 38 ) ps->Scan.bd_rk.wBlueDiscard = 1; else ps->Scan.bd_rk.wBlueDiscard = 0; if( ps->DataInf.wPhyDataType >= COLOR_256GRAY ) { ps->Shade.wXStep = 6; ps->Shade.wExposure = 8 * ps->Shade.wXStep; } } else { if(!(ps->DataInf.dwScanFlag & SCANDEF_TPA) && (ps->DataInf.xyAppDpi.y <= 50) && (ps->DataInf.wPhyDataType >= COLOR_TRUE24)) { ps->Shade.bIntermediate |= _ScanMode_AverageOut; } if((ps->DataInf.wPhyDataTypeDevice.f0_8_16 || (ps->Shade.bIntermediate & _ScanMode_AverageOut)) { ps->Scan.bDiscardAll = 1; ps->DataInf.xyPhyDpi.y = 75; imageP98003SetupScanStateVariables( ps, 0 ); } else { ps->Scan.bDiscardAll = 2; ps->DataInf.xyPhyDpi.y = 150; imageP98003SetupScanStateVariables( ps, 1 ); } } } else { if( ps->DataInf.xyAppDpi.y <= 150 ) { ps->Scan.bDiscardAll = 2; ps->DataInf.xyPhyDpi.y = 150; imageP98003SetupScanStateVariables( ps, 1 ); } else if( ps->DataInf.xyAppDpi.y <= 300 ) { ps->Scan.bDiscardAll = 4; ps->DataInf.xyPhyDpi.y = 300; imageP98003SetupScanStateVariables( ps, 2 ); } else if( ps->DataInf.xyAppDpi.y <= 600 ) { ps->Scan.bDiscardAll = 8; ps->DataInf.xyPhyDpi.y = 600; imageP98003SetupScanStateVariables( ps, 3 ); } else { ps->Scan.bDiscardAll = 16; ps->DataInf.xyPhyDpi.y = 1200; imageP98003SetupScanStateVariables( ps, 4 ); } } /* ------- Lines have to sample or not? ------- */ if( ps->DataInf.xyAppDpi.y == ps->DataInf.xyPhyDpi.y ) { DBG( DBG_LOW, "Sample every line\n" ); ps->Scan.DoSample = fnEveryLines; } else { if( ps->DataInf.dwVxdFlag & _VF_PREVIEW ) { DBG( DBG_LOW, "Sample preview\n" ); ps->Scan.DoSample = fnSamplePreview; ps->DataInf.wYSum = 150; if( ps->DataInf.xyAppDpi.y >= 38 ) wPreviewScanned = ps->DataInf.xyAppDpi.y * 2; else if( ps->DataInf.xyAppDpi.y >= 19 ) wPreviewScanned = ps->DataInf.xyAppDpi.y * 4; else wPreviewScanned = ps->DataInf.xyAppDpi.y * 8; } else { DBG( DBG_LOW, "Sample lines (%u - %u)...\n", ps->DataInf.xyPhyDpi.y, ps->DataInf.xyAppDpi.y ); ps->Scan.DoSample = fnSampleLines; ps->DataInf.wYSum = ps->DataInf.xyPhyDpi.y - ps->DataInf.xyAppDpi.y; } } /* * now assign the buffer pointers for image aquisition */ ps->Scan.p48BitBuf.pb = NULL; if( ps->DataInf.wPhyDataType >= COLOR_TRUE24 ) { ULong r,g,b; r = (ULong)_SIZE_REDFIFO / ps->DataInf.dwAsicBytesPerPlane - ps->Scan.bd_rk.wRedKeep; g = (ULong)_SIZE_GREENFIFO / ps->DataInf.dwAsicBytesPerPlane - ps->Scan.gd_gk.wGreenKeep; if((int)r < 16 || (int)g < 16) { b = (ULong)(ps->Scan.bd_rk.wRedKeep + ps->Scan.gd_gk.wGreenKeep + 2U) * ps->DataInf.dwAsicBytesPerPlane; DBG( DBG_LOW, "48Bit buffer request: len=%u bytes, available=%u\n", b, ps->TotalBufferRequire ); if( b > ps->TotalBufferRequire ) return _E_NORESOURCE; ps->Scan.p48BitBuf.pb = ps->Bufs.b1.pReadBuf; } } if( ps->Scan.p48BitBuf.pb ){ ps->Scan.DataRead = fnReadToDriver; ps->Scan.BufGet.red.bp = ps->Scan.BufPut.red.bp = ps->Scan.BufBegin.red.bp = ps->Scan.p48BitBuf.pb; ps->Scan.BufEnd.red.bp = ps->Scan.BufBegin.green.bp = ps->Scan.BufGet.green.bp = ps->Scan.BufPut.green.bp = ps->Scan.p48BitBuf.pb + ps->DataInf.dwAsicBytesPerLine * (ps->Scan.bd_rk.wRedKeep + 1U); ps->Scan.BufEnd.green.bp = ps->Scan.BufBegin.green.bp + ps->DataInf.dwAsicBytesPerLine * (ps->Scan.gd_gk.wGreenKeep + 1U); ps->Scan.BufPut.blue.bp = ps->Scan.BufGet.blue.bp = ps->Bufs.b1.pReadBuf + ps->DataInf.dwAsicBytesPerLine * 2; } else { ps->Scan.DataRead = fnReadOutScanner; ps->Scan.BufPut.red.bp = ps->Bufs.b1.pReadBuf; ps->Scan.BufData.green.bp = ps->Scan.BufPut.green.bp = ps->Scan.BufPut.red.bp + ps->DataInf.dwAsicBytesPerLine; ps->Scan.BufPut.blue.bp = ps->Scan.BufPut.green.bp + ps->DataInf.dwAsicBytesPerLine; if( ps->DataInf.dwScanFlag & SCANDEF_ColorBGROrder ) { ps->Scan.BufData.red.bp = ps->Scan.BufPut.blue.bp; ps->Scan.BufData.blue.bp = ps->Scan.BufPut.red.bp; } else { ps->Scan.BufData.red.bp = ps->Scan.BufPut.red.bp; ps->Scan.BufData.blue.bp = ps->Scan.BufPut.blue.bp; } } /* CHECK: maybe remove this stuff */ if( ps->DataInf.dwScanFlag & SCANDEF_Transparency) { posScan[1].exposureTime = 96; posScan[1].xStepTime = 12; posScan[2].exposureTime = 96; posScan[2].xStepTime = 24; posScan[3].exposureTime = 96; posScan[3].xStepTime = 48; posScan[4].exposureTime = 96; posScan[4].xStepTime = 96; /* Reset shading Exposure Time & xStep Time */ ps->Shade.wExposure = posScan[ps->Scan.dpiIdx].exposureTime; ps->Shade.wXStep = posScan[ps->Scan.dpiIdx].xStepTime; } else if( ps->DataInf.dwScanFlag & SCANDEF_Negative) { ps->Scan.negScan[1].exposureTime = 96; ps->Scan.negScan[1].xStepTime = 12; ps->Scan.negScan[2].exposureTime = 96; ps->Scan.negScan[2].xStepTime = 24; ps->Scan.negScan[3].exposureTime = 96; ps->Scan.negScan[3].xStepTime = 48; ps->Scan.negScan[4].exposureTime = 96; ps->Scan.negScan[4].xStepTime = 96; /* Reset shading Exposure Time & xStep Time */ ps->Shade.wExposure = ps->Scan.negScan[ps->Scan.dpiIdx].exposureTime; ps->Shade.wXStep = ps->Scan.negScan[ps->Scan.dpiIdx].xStepTime; } return _OK; } /************************ exported functions *********************************/ /** */ _LOC int ImageInitialize( pScanData ps ) { DBG( DBG_HIGH, "ImageInitialize()\n" ); if( NULL == ps ) return _E_NULLPTR; ps->Scan.dpiIdx = 0; ps->Scan.negScan = negScan; /* * depending on the asic, we set some functions */ if( _ASIC_IS_98001 == ps->sCaps.AsicID ) { ps->GetImageInfo = imageP98GetInfo; ps->SetupScanSettings = imageP98SetupScanSettings; ps->ReadOneImageLine = imageP98001ReadOneImageLine; } else if( _ASIC_IS_98003 == ps->sCaps.AsicID ) { ps->GetImageInfo = imageP98GetInfo; ps->SetupScanSettings = imageP98003SetupScanSettings; ps->ReadOneImageLine = imageP98003ReadOneImageLine; } else if( _IS_ASIC96(ps->sCaps.AsicID)) { ps->GetImageInfo = imageP96GetInfo; ps->SetupScanSettings = imageP96SetupScanSettings; ps->ReadOneImageLine = imageP96ReadOneImageLine; } else { DBG( DBG_HIGH , "NOT SUPPORTED ASIC !!!\n" ); return _E_NOSUPP; } return _OK; } /* END PLUSTEK-PP_IMAGE.C ...................................................*/ sane-backends-1.0.29/backend/st400.c0000666000000000000000000011250013615534521013605 00000000000000/* vim: ts=4 sw=4 noexpandtab */ /* st400.c - SANE module for Siemens ST400 flatbed scanner Copyright (C) 1999-2000 Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. ************************************************************************* This file implements a SANE backend for the Siemens ST400 flatbed scanner. Unfortunately, I have no documentation for this scanner. All I have is an old PC Pascal source and an Amiga C source (derived from the Pascal source). Both are quite primitive, and so is this backend... Version numbers of this backend follow SANE version scheme: The first number is SANE's major version (i.e. the version of the SANE API that this backend conforms to), the second is the version of this backend. Thus, version 1.2 is the second release of this backend for SANE v1. 1.0 (08 Mar 1999): First public release, for SANE v1.0.0 1.1 (12 Mar 1999): Fixed some stupid bugs (caused crash if accessed via net). 1.2 (23 Apr 1999): Oops, got threshold backwards. Tested with SANE 1.0.1. 1.3 (27 Apr 1999): Seems the separate MODE SELECT to switch the light on is not necessary. Removed debugging output via syslog, it was only used to track down a bug in saned. Some minor cleanups. Removed illegal version check (only frontends should do this). Made "maxread" and "delay" config options instead of compile-time #define's. Added model check via INQUIRY, and related changes. 1.4 (29 Jun 1999): New config options to configure scanner models. See st400.conf for details. These options are only for testing, and will be removed someday. 1.5 (26 Mar 2000): Check for optnum >= 0. Fixed some hardcoded paths in manpage. ST400 locks up with reads >64KB - added maxread entry to model struct. Tested with SANE 1.0.2. 1.6 (08 Apr 2000): Minor cleanups. 1.7 (18 Dec 2001): Security fix from Tim Waugh. Dump inquiry data to "$HOME/st400.dump" instead of "/tmp/st400.dump". */ #include "../include/sane/config.h" #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_config.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_debug.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #define BACKEND_NAME st400 #include "../include/sane/sanei_backend.h" #include "st400.h" /* supported scanners */ static ST400_Model st400_models[] = { { 8, "SIEMENS", 16, "ST 400", 6, 0x200000UL, 65536UL, NULL, "Siemens", "ST400", "flatbed scanner" }, { 8, "SIEMENS", 16, "ST 800", 6, 0x200000UL, 65536UL, NULL, "Siemens", "ST800", "flatbed scanner" }, /* to be tested */ { 0, "", 0, "", 6, 0x200000UL, 65536UL, NULL, "Unknown", "untested", "flatbed scanner" }, /* matches anything */ /* must be last */ { 0, NULL, 0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL } }; static ST400_Device *st400_devices = NULL; static unsigned int st400_num_devices = 0; static const SANE_Device **st400_device_array = NULL; /* The array pointer must stay valid between calls to sane_get_devices(). * So we cannot modify or deallocate the array when a new device is attached * - until the next call to sane_get_devices(). The array_valid bit indicates * whether the array is still in sync with the device list or not (if new * devices have been attached in the meantime). */ static struct { unsigned array_valid: 1; } st400_status = { 0 }; static size_t st400_maxread = 0; static size_t st400_light_delay = 0; static int st400_dump_data = 0; /* SCSI commands */ #define CMD_TEST_UNIT_READY 0x00 #define CMD_INQUIRY 0x12 #define CMD_MODE_SELECT 0x15 #define CMD_RESERVE 0x16 #define CMD_RELEASE 0x17 #define CMD_START_STOP 0x1b #define CMD_SET_WINDOW 0x24 #define CMD_READ_CAPACITY 0x25 /* get window settings - unused */ #define CMD_READ10 0x28 /* prototypes */ static SANE_Status st400_inquiry( int fd, ST400_Model **modelP ); static SANE_Status st400_sense_handler( int fd, SANE_Byte *result, void *arg ); static SANE_Status st400_attach( const char *devname, ST400_Device **devP ); static SANE_Status st400_attach_one( const char *device ); static void st400_init_options( ST400_Device *dev ); static SANE_Status st400_set_window( ST400_Device *dev ); static SANE_Status st400_wait_ready( int fd ); static SANE_Status st400_cmd6( int fd, SANE_Byte cmd, SANE_Byte ctrl ); static SANE_Status st400_read10( int fd, SANE_Byte *buf, size_t *lenP ); static void st400_reset_options( ST400_Device *dev ); #undef min #define min(a, b) ((a) < (b) ? (a) : (b)) #define maxval(bpp) ((1<<(bpp))-1) /* Debugging levels */ #define DERR 0 /* errors */ #define DINFO 1 /* misc information */ #define DSENSE 2 /* SCSI sense */ #define DSCSI 3 /* SCSI commands */ #define DOPT 4 /* option control */ #define DVAR 5 /* important variables */ #define DCODE 6 /* code flow */ /********************************************************************* * low-level SCSI functions *********************************************************************/ #define set24(m, x) do { \ *((SANE_Byte *)(m)+0) = (SANE_Byte)(((x) >> 16) & 0xff); \ *((SANE_Byte *)(m)+1) = (SANE_Byte)(((x) >> 8) & 0xff); \ *((SANE_Byte *)(m)+2) = (SANE_Byte)(((x) >> 0) & 0xff); \ } while(0) #define set16(m, x) do { \ *((SANE_Byte *)(m)+0) = (SANE_Byte)(((x) >> 8) & 0xff); \ *((SANE_Byte *)(m)+1) = (SANE_Byte)(((x) >> 0) & 0xff); \ } while(0) static int str_at_offset(char *str, size_t offset, unsigned char *data) { size_t len; len = strlen(str); return !strncmp((char *)&data[offset], str, len); } static SANE_Status st400_inquiry( int fd, ST400_Model **modelP ) { struct { SANE_Byte cmd, lun, reserved[2], tr_len, ctrl; } scsi_cmd; /* struct { SANE_Byte devtype, devqual, version; SANE_Byte reserved1, additionallength; SANE_Byte reserved2[2], flags; SANE_Byte vendor[8], product[16], release[4]; SANE_Byte reserved3[60]; } inqdata; */ struct { SANE_Byte bytes[96]; } inqdata; size_t inqlen; SANE_Status status; ST400_Model *model; inqlen = sizeof(inqdata); memset(&scsi_cmd, 0, sizeof(scsi_cmd)); scsi_cmd.cmd = CMD_INQUIRY; scsi_cmd.tr_len = inqlen; DBG(DSCSI, "SCSI: sending INQUIRY (%lu bytes)\n", (u_long)inqlen); status = sanei_scsi_cmd(fd, &scsi_cmd, sizeof(scsi_cmd), &inqdata, &inqlen); DBG(DSCSI, "SCSI: result=%s (%lu bytes)\n", sane_strstatus(status), (u_long)inqlen); if( status != SANE_STATUS_GOOD ) return status; if( st400_dump_data ) { const char *home = getenv ("HOME"); char basename[] = "st400.dump"; char *name; FILE *fp; if (home) { name = malloc (strlen (home) + sizeof (basename) + 1); sprintf (name, "%s/%s", home, basename); } else name = basename; fp = fopen(name, "ab"); if( fp != NULL ) { fwrite(inqdata.bytes, 1, inqlen, fp); fclose(fp); } if (name != basename) free (name); } if( inqlen != sizeof(inqdata) ) return SANE_STATUS_IO_ERROR; for( model = st400_models; model->inq_vendor; model++ ) { if( str_at_offset(model->inq_vendor, model->inq_voffset, inqdata.bytes) && str_at_offset(model->inq_model, model->inq_moffset, inqdata.bytes) ) { *modelP = model; DBG(DINFO, "found matching scanner model \"%s %s\" in list\n", model->sane_vendor, model->sane_model); return SANE_STATUS_GOOD; } } return SANE_STATUS_UNSUPPORTED; } static SANE_Status st400_cmd6( int fd, SANE_Byte cmd, SANE_Byte ctrl ) { struct { SANE_Byte cmd, lun, reserved[2], tr_len, ctrl; } scsi_cmd; SANE_Status status; memset(&scsi_cmd, 0, sizeof(scsi_cmd)); scsi_cmd.cmd = cmd; scsi_cmd.ctrl = ctrl; DBG(DSCSI, "SCSI: sending cmd6 0x%02x (ctrl=%d)\n", (int)cmd, (int)ctrl); status = sanei_scsi_cmd(fd, &scsi_cmd, sizeof(scsi_cmd), 0, 0); DBG(DSCSI, "SCSI: result=%s\n", sane_strstatus(status)); return status; } #define st400_test_ready(fd) st400_cmd6(fd, CMD_TEST_UNIT_READY, 0) #define st400_reserve(fd) st400_cmd6(fd, CMD_RESERVE, 0) #define st400_release(fd) st400_cmd6(fd, CMD_RELEASE, 0) #define st400_start_scan(fd) st400_cmd6(fd, CMD_START_STOP, 0) #define st400_light_on(fd) st400_cmd6(fd, CMD_MODE_SELECT, 0x80) #define st400_light_off(fd) st400_cmd6(fd, CMD_MODE_SELECT, 0) static SANE_Status st400_wait_ready( int fd ) { #define SLEEPTIME 100000L /* 100ms */ long max_sleep = 60000000L; /* 60 seconds */ SANE_Status status; DBG(DCODE, "st400_wait_ready(%d)\n", fd); while(1) { status = st400_test_ready(fd); switch( status ) { case SANE_STATUS_DEVICE_BUSY: if( max_sleep > 0 ) { usleep(SLEEPTIME); /* retry after 100ms */ max_sleep -= SLEEPTIME; break; } /* else fall through */ default: DBG(DERR, "st400_wait_ready: failed, error=%s\n", sane_strstatus(status)); /* fall through */ case SANE_STATUS_GOOD: return status; } } /*NOTREACHED*/ } static SANE_Status st400_set_window( ST400_Device *dev ) { unsigned short xoff, yoff; SANE_Byte th; struct { /* 10byte command */ SANE_Byte cmd, lun, reserved1[4], tr_len[3], ctrl; /* 40byte window struct */ SANE_Byte reserved2[6], wd_len[2], winnr, reserved3; SANE_Byte x_res[2], y_res[2]; /* resolution: 200, 300, 400 */ SANE_Byte x_ul[2], y_ul[2]; /* upper left corner */ SANE_Byte width[2], height[2]; SANE_Byte reserved4, threshold; SANE_Byte reserved5, halftone; /* ht: 0 or 2 */ SANE_Byte bitsperpixel, reserved6[13]; /* bpp: 1 or 8 */ } scsi_cmd; /* The PC/Amiga source uses reserved5 to indicate A4/A5 paper size * (values 4 and 5), but a comment implies that this is only for the * scanning program and the value is ignored by the scanner. */ SANE_Status status; memset(&scsi_cmd, 0, sizeof(scsi_cmd)); scsi_cmd.cmd = CMD_SET_WINDOW; set24(scsi_cmd.tr_len, 40); set16(scsi_cmd.wd_len, 32); /* These offsets seem to be required to avoid damaging the scanner: * If a scan with 0/0 as the top left corner is started, the scanner * seems to try to move the carriage over the bottom end (not a * pretty sound). */ xoff = (11L * dev->val[OPT_RESOLUTION]) / 100; yoff = 6; th = (double)maxval(dev->model->bits) * SANE_UNFIX(dev->val[OPT_THRESHOLD]) / 100.0; scsi_cmd.winnr = 1; set16(scsi_cmd.x_res, (unsigned short)dev->val[OPT_RESOLUTION]); set16(scsi_cmd.y_res, (unsigned short)dev->val[OPT_RESOLUTION]); set16(scsi_cmd.x_ul, dev->x + xoff); set16(scsi_cmd.y_ul, dev->wy + yoff); set16(scsi_cmd.width, dev->w); set16(scsi_cmd.height, dev->wh); scsi_cmd.threshold = th; scsi_cmd.halftone = (dev->val[OPT_DEPTH] == 1) ? 0 : 2; scsi_cmd.bitsperpixel = dev->val[OPT_DEPTH]; DBG(DSCSI, "SCSI: sending SET_WINDOW (x=%hu y=%hu w=%hu h=%hu wy=%hu wh=%hu th=%d\n", dev->x, dev->y, dev->w, dev->h, dev->wy, dev->wh, (int)th); status = sanei_scsi_cmd(dev->fd, &scsi_cmd, sizeof(scsi_cmd), 0, 0); DBG(DSCSI, "SCSI: result=%s\n", sane_strstatus(status)); return status; } static SANE_Status st400_read10( int fd, SANE_Byte *buf, size_t *lenP ) { struct { SANE_Byte cmd, lun, res[4], tr_len[3], ctrl; } scsi_cmd; SANE_Status status; memset(&scsi_cmd, 0, sizeof(scsi_cmd)); scsi_cmd.cmd = CMD_READ10; set24(scsi_cmd.tr_len, *lenP); DBG(DSCSI, "SCSI: sending READ10 (%lu bytes)\n", (u_long)(*lenP)); status = sanei_scsi_cmd(fd, &scsi_cmd, sizeof(scsi_cmd), buf, lenP); DBG(DSCSI, "SCSI: result=%s (%lu bytes)\n", sane_strstatus(status), (u_long)(*lenP)); return status; } static SANE_Status st400_fill_scanner_buffer( ST400_Device *dev ) { SANE_Status status; DBG(DCODE, "st400_fill_scanner_buffer(%p)\n", (void *) dev); if( dev->lines_to_read == 0 ) dev->status.eof = 1; if( dev->status.eof ) return SANE_STATUS_EOF; dev->wh = dev->model->bufsize / dev->params.bytes_per_line; if( dev->wh > dev->lines_to_read ) dev->wh = dev->lines_to_read; DBG(DVAR, "dev->wh = %hu\n", dev->wh); status = st400_set_window(dev); if( status != SANE_STATUS_GOOD ) return status; status = st400_start_scan(dev->fd); if( status != SANE_STATUS_GOOD ) return status; dev->wy += dev->wh; dev->lines_to_read -= dev->wh; dev->bytes_in_scanner = dev->wh * dev->params.bytes_per_line; return SANE_STATUS_GOOD; } static SANE_Status st400_fill_backend_buffer( ST400_Device *dev ) { size_t r; SANE_Status status; DBG(DCODE, "st400_fill_backend_buffer(%p)\n", (void *) dev); if( dev->bytes_in_scanner == 0 ) { status = st400_fill_scanner_buffer(dev); if( status != SANE_STATUS_GOOD ) return status; } r = min(dev->bufsize, dev->bytes_in_scanner); status = st400_read10(dev->fd, dev->buffer, &r); if( status == SANE_STATUS_GOOD ) { dev->bufp = dev->buffer; dev->bytes_in_buffer = r; dev->bytes_in_scanner -= r; if( r == 0 ) dev->status.eof = 1; } return status; } static SANE_Status st400_sense_handler( int fd, SANE_Byte *result, void *arg ) { /* ST400_Device *dev = arg; */ SANE_Status status; fd = fd; arg = arg; /* silence compilation warnings */ switch( result[0] & 0x0f ) { case 0x0: status = SANE_STATUS_GOOD; break; case 0x1: DBG(DSENSE, "SCSI: sense RECOVERED_ERROR\n"); status = SANE_STATUS_GOOD; /* ?? */ break; case 0x2: DBG(DSENSE, "SCSI: sense NOT_READY\n"); status = SANE_STATUS_DEVICE_BUSY; break; case 0x4: DBG(DSENSE, "SCSI: sense HARDWARE_ERROR\n"); status = SANE_STATUS_IO_ERROR; break; case 0x5: DBG(DSENSE, "SCSI: sense ILLEGAL_REQUEST\n"); status = SANE_STATUS_IO_ERROR; break; case 0x6: DBG(DSENSE, "SCSI: sense UNIT_ATTENTION\n"); status = SANE_STATUS_DEVICE_BUSY; break; case 0xb: DBG(DSENSE, "SCSI: sense ABORTED_COMMAND\n"); status = SANE_STATUS_CANCELLED; /* ?? */ break; default: DBG(DSENSE, "SCSI: sense unknown (%d)\n", result[0] & 0x0f); status = SANE_STATUS_IO_ERROR; break; } return status; } /********************************************************************* * Sane initializing stuff *********************************************************************/ static SANE_Status st400_attach( const char *devname, ST400_Device **devP ) { ST400_Device *dev; ST400_Model *model; SANE_Status status; int fd; DBG(DCODE, "st400_attach(%s, %p)\n", devname, (void *) devP); if( devP ) *devP = NULL; for( dev = st400_devices; dev != NULL; dev = dev->next ) { if( strcmp(dev->sane.name, devname) == 0 ) { if( devP ) *devP = dev; DBG(DCODE, "st400_attach: found device in list\n"); return SANE_STATUS_GOOD; } } dev = calloc(1, sizeof(*dev)); if( !dev ) return SANE_STATUS_NO_MEM; DBG(DCODE, "st400_attach: new device struct at %p\n", (void *) dev); status = sanei_scsi_open(devname, &fd, st400_sense_handler, dev); if( status == SANE_STATUS_GOOD ) { status = st400_inquiry(fd, &model); if( status == SANE_STATUS_GOOD ) status = st400_test_ready(fd); sanei_scsi_close(fd); } if( status != SANE_STATUS_GOOD ) { free(dev); return status; } /* initialize device structure */ dev->sane.name = strdup(devname); if( !dev->sane.name ) { free(dev); return SANE_STATUS_NO_MEM; } dev->sane.vendor = model->sane_vendor; dev->sane.model = model->sane_model; dev->sane.type = model->sane_type; dev->status.open = 0; dev->status.scanning = 0; dev->status.eof = 0; dev->fd = -1; dev->buffer = NULL; dev->model = model; st400_init_options(dev); DBG(DCODE, "st400_attach: everything ok, adding device to list\n"); dev->next = st400_devices; st400_devices = dev; ++st400_num_devices; st400_status.array_valid = 0; if( devP ) *devP = dev; return SANE_STATUS_GOOD; } static SANE_Status st400_attach_one( const char *device ) { DBG(DCODE, "st400_attach_one(%s)\n", device); return st400_attach(device, NULL); } static SANE_Status st400_config_get_arg(char **optP, unsigned long *argP, size_t linenum) { int n; linenum = linenum; /* silence compilation warnings */ if( sscanf(*optP, "%lu%n", argP, &n) == 1 ) { *optP += n; *optP = (char *)sanei_config_skip_whitespace(*optP); return SANE_STATUS_GOOD; } return SANE_STATUS_INVAL; } static SANE_Status st400_config_get_single_arg(char *opt, unsigned long *argP, size_t linenum) { int n; if( sscanf(opt, "%lu%n", argP, &n) == 1 ) { opt += n; opt = (char *)sanei_config_skip_whitespace(opt); if( *opt == '\0' ) return SANE_STATUS_GOOD; else { DBG(DERR, "extraneous arguments at line %lu: %s\n", (u_long)linenum, opt); return SANE_STATUS_INVAL; } } DBG(DERR, "invalid option argument at line %lu: %s\n", (u_long)linenum, opt); return SANE_STATUS_INVAL; } static SANE_Status st400_config_do_option(char *opt, size_t linenum) { unsigned long arg; SANE_Status status; int i; status = SANE_STATUS_GOOD; opt = (char *)sanei_config_skip_whitespace(opt); if( strncmp(opt, "maxread", 7) == 0 && isspace(opt[7]) ) { opt += 8; status = st400_config_get_single_arg(opt, &arg, linenum); if( status == SANE_STATUS_GOOD ) { if( arg == 0 ) st400_maxread = sanei_scsi_max_request_size; else st400_maxread = (size_t)arg; } } else if( strncmp(opt, "delay", 5) == 0 && isspace(opt[5]) ) { opt += 6; status = st400_config_get_single_arg(opt, &arg, linenum); if( status == SANE_STATUS_GOOD ) st400_light_delay = (size_t)arg; } else if( strncmp(opt, "scanner_bufsize", 15) == 0 && isspace(opt[15]) ) { opt += 16; status = st400_config_get_single_arg(opt, &arg, linenum); if( status == SANE_STATUS_GOOD ) if( st400_devices ) st400_devices->model->bufsize = arg; /* FIXME: changes bufsize for all scanners of this model! */ } else if( strncmp(opt, "scanner_bits", 12) == 0 && isspace(opt[12]) ) { opt += 13; status = st400_config_get_single_arg(opt, &arg, linenum); if( status == SANE_STATUS_GOOD ) if( st400_devices ) st400_devices->model->bits = arg; /* FIXME */ } else if( strncmp(opt, "scanner_maxread", 15) == 0 && isspace(opt[15]) ) { opt += 16; status = st400_config_get_single_arg(opt, &arg, linenum); if( status == SANE_STATUS_GOOD ) if( st400_devices ) st400_devices->model->maxread = arg; /* FIXME */ } else if( strncmp(opt, "scanner_resolutions", 19) == 0 && isspace(opt[19]) ) { opt += 20; st400_devices->model->dpi_list = malloc(16 * sizeof(SANE_Int)); i = 0; do { status = st400_config_get_arg(&opt, &arg, linenum); if( status == SANE_STATUS_GOOD ) { ++i; st400_devices->model->dpi_list[i] = (SANE_Int)arg; } } while( status == SANE_STATUS_GOOD && i < 15 ); st400_devices->model->dpi_list[0] = i; DBG(DINFO, "%d entries for resolution\n", i); status = SANE_STATUS_GOOD; } else if( strncmp(opt, "dump_inquiry", 12) == 0 ) { st400_dump_data = 1; } if( st400_devices ) st400_reset_options(st400_devices); return status; } SANE_Status sane_init( SANE_Int *versionP, SANE_Auth_Callback authorize ) { FILE *fp; SANE_Status status; DBG_INIT(); DBG(DCODE, "sane_init: version %s null, authorize %s null\n", (versionP) ? "!=" : "==", (authorize) ? "!=" : "=="); if( versionP != NULL ) *versionP = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, 0); status = SANE_STATUS_GOOD; if( (fp = sanei_config_open(ST400_CONFIG_FILE)) != NULL ) { char line[PATH_MAX], *str; size_t len, linenum; linenum = 0; DBG(DCODE, "sane_init: reading config file\n"); while( sanei_config_read(line, sizeof(line), fp) ) { ++linenum; str = line; if( str[0] == '#' ) continue; /* ignore comments */ str = (char *)sanei_config_skip_whitespace(str); len = strlen(str); if( !len ) continue; /* ignore empty lines */ if( strncmp(str, "option", 6) == 0 && isspace(str[6]) ) { DBG(DCODE, "sane_init: config line <%s>\n", line); status = st400_config_do_option(str+7, linenum); } else { DBG(DCODE, "sane_init: attaching device <%s>\n", line); sanei_config_attach_matching_devices(line, st400_attach_one); } if( status != SANE_STATUS_GOOD ) break; } DBG(DCODE, "sane_init: closing config file\n"); fclose(fp); } if( status == SANE_STATUS_GOOD && st400_devices == NULL ) { DBG(DCODE, "sane_init: attaching default device <%s>\n", ST400_DEFAULT_DEVICE); sanei_config_attach_matching_devices(ST400_DEFAULT_DEVICE, st400_attach_one); } return status; } void sane_exit( void ) { ST400_Device *dev; DBG(DCODE, "sane_exit()\n"); while( (dev = st400_devices) != NULL ) { st400_devices = dev->next; sane_close(dev); free((char *)(dev->sane.name)); free(dev); } st400_num_devices = 0; if( st400_device_array ) { DBG(DCODE, "sane_exit: freeing device array\n"); free(st400_device_array); st400_device_array = NULL; st400_status.array_valid = 0; } } SANE_Status sane_get_devices( const SANE_Device ***devarrayP, SANE_Bool local_only ) { ST400_Device *dev; unsigned int i; DBG(DCODE, "sane_get_devices(%p, %d)\n", (void *) devarrayP, (int)local_only); if( !st400_status.array_valid ) { if( st400_device_array ) { DBG(DCODE, "sane_get_devices: freeing old device array\n"); free(st400_device_array); } st400_device_array = malloc((st400_num_devices + 1) * sizeof(*st400_device_array)); if( !st400_device_array ) return SANE_STATUS_NO_MEM; DBG(DCODE, "sane_get_devices: new device array at %p\n", (void *) st400_device_array); dev = st400_devices; for( i = 0; i < st400_num_devices; i++ ) { st400_device_array[i] = &dev->sane; dev = dev->next; } st400_device_array[st400_num_devices] = NULL; st400_status.array_valid = 1; } DBG(DCODE, "sane_get_devices: %u entries in device array\n", st400_num_devices); if( devarrayP ) *devarrayP = st400_device_array; return SANE_STATUS_GOOD; } SANE_Status sane_open( SANE_String_Const devicename, SANE_Handle *handleP ) { ST400_Device *dev; SANE_Status status; DBG(DCODE, "sane_open(%s, %p)\n", devicename, (void *) handleP); *handleP = NULL; if( devicename && devicename[0] ) { status = st400_attach(devicename, &dev); if( status != SANE_STATUS_GOOD ) return status; } else dev = st400_devices; if( !dev ) return SANE_STATUS_INVAL; if( dev->status.open ) return SANE_STATUS_DEVICE_BUSY; dev->status.open = 1; st400_reset_options(dev); *handleP = (SANE_Handle)dev; return SANE_STATUS_GOOD; } void sane_close( SANE_Handle handle ) { ST400_Device *dev = handle; DBG(DCODE, "sane_close(%p)\n", handle); if( dev->status.open ) { sane_cancel(dev); dev->status.open = 0; } } /* * options */ static void st400_reset_options( ST400_Device *dev ) { DBG(DCODE, "st400_reset_options(%p)\n", (void *) dev); dev->val[OPT_NUM_OPTS] = NUM_OPTIONS; dev->val[OPT_RESOLUTION] = dev->opt[OPT_RESOLUTION].constraint.word_list[1]; dev->val[OPT_DEPTH] = dev->opt[OPT_DEPTH].constraint.word_list[1]; dev->val[OPT_THRESHOLD] = SANE_FIX(50.0); dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; dev->val[OPT_TL_X] = SANE_FIX(0.0); dev->val[OPT_TL_Y] = SANE_FIX(0.0); dev->val[OPT_BR_X] = SANE_FIX(0.0); dev->val[OPT_BR_Y] = SANE_FIX(0.0); if( dev->model->dpi_list ) dev->opt[OPT_RESOLUTION].constraint.word_list = dev->model->dpi_list; } static void st400_init_options( ST400_Device *dev ) { static const SANE_Int depth_list[] = { 2, 1, 8 }; static const SANE_Int dpi_list[] = { 3, 200, 300, 400 }; static const SANE_Range thres_range = { SANE_FIX(0.0), SANE_FIX(100.0), SANE_FIX(0.0) }; static const SANE_Range x_range = { SANE_FIX(0.0), SANE_FIX(ST400_MAX_X * MM_PER_INCH), SANE_FIX(0.0) }; static const SANE_Range y_range = { SANE_FIX(0.0), SANE_FIX(ST400_MAX_Y * MM_PER_INCH), SANE_FIX(0.0) }; DBG(DCODE, "st400_init_options(%p)\n", (void *)dev); dev->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; dev->opt[OPT_NUM_OPTS].unit = SANE_UNIT_NONE; dev->opt[OPT_NUM_OPTS].size = sizeof(SANE_Word); dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; dev->opt[OPT_NUM_OPTS].constraint_type = SANE_CONSTRAINT_NONE; dev->opt[OPT_MODE_GROUP].title= "Scan Mode"; dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; 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].unit = SANE_UNIT_DPI; dev->opt[OPT_RESOLUTION].size = sizeof(SANE_Word); dev->opt[OPT_RESOLUTION].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; dev->opt[OPT_RESOLUTION].constraint.word_list = dpi_list; dev->opt[OPT_DEPTH].name = SANE_NAME_BIT_DEPTH; dev->opt[OPT_DEPTH].title = SANE_TITLE_BIT_DEPTH; dev->opt[OPT_DEPTH].desc = SANE_DESC_BIT_DEPTH; dev->opt[OPT_DEPTH].type = SANE_TYPE_INT; dev->opt[OPT_DEPTH].unit = SANE_UNIT_BIT; dev->opt[OPT_DEPTH].size = sizeof(SANE_Word); dev->opt[OPT_DEPTH].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; dev->opt[OPT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; dev->opt[OPT_DEPTH].constraint.word_list = depth_list; dev->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; dev->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; dev->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; dev->opt[OPT_THRESHOLD].type = SANE_TYPE_FIXED; dev->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; dev->opt[OPT_THRESHOLD].size = sizeof(SANE_Word); 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 = &thres_range; dev->opt[OPT_GEOMETRY_GROUP].title= "Geometry"; dev->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; dev->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; dev->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; dev->opt[OPT_TL_X].type = SANE_TYPE_FIXED; dev->opt[OPT_TL_X].unit = SANE_UNIT_MM; dev->opt[OPT_TL_X].size = sizeof(SANE_Word); dev->opt[OPT_TL_X].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; dev->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_X].constraint.range = &x_range; dev->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; dev->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; dev->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; dev->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; dev->opt[OPT_TL_Y].unit = SANE_UNIT_MM; dev->opt[OPT_TL_Y].size = sizeof(SANE_Word); dev->opt[OPT_TL_Y].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; dev->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_Y].constraint.range = &y_range; dev->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; dev->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; dev->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; dev->opt[OPT_BR_X].type = SANE_TYPE_FIXED; dev->opt[OPT_BR_X].unit = SANE_UNIT_MM; dev->opt[OPT_BR_X].size = sizeof(SANE_Word); dev->opt[OPT_BR_X].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; dev->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_X].constraint.range = &x_range; dev->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; dev->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; dev->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; dev->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; dev->opt[OPT_BR_Y].unit = SANE_UNIT_MM; dev->opt[OPT_BR_Y].size = sizeof(SANE_Word); dev->opt[OPT_BR_Y].cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; dev->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_Y].constraint.range = &y_range; st400_reset_options(dev); } const SANE_Option_Descriptor * sane_get_option_descriptor( SANE_Handle handle, SANE_Int optnum ) { ST400_Device *dev = handle; DBG(DOPT, "sane_get_option_descriptor(%p, %d)\n", handle, (int)optnum); if( dev->status.open && optnum >= 0 && optnum < NUM_OPTIONS ) return &dev->opt[optnum]; return NULL; } SANE_Status sane_control_option( SANE_Handle handle, SANE_Int optnum, SANE_Action action, void *valP, SANE_Int *infoP) { ST400_Device *dev = handle; SANE_Status status; DBG(DCODE, "sane_control_option(%p, %d, %d, %p, %p)\n", (void *) handle, (int)optnum, (int)action, valP, (void *) infoP); if( infoP ) *infoP = 0; if( !dev->status.open ) return SANE_STATUS_INVAL; if( dev->status.scanning ) return SANE_STATUS_DEVICE_BUSY; if( optnum < 0 || optnum >= NUM_OPTIONS ) return SANE_STATUS_INVAL; switch( action ) { case SANE_ACTION_GET_VALUE: DBG(DOPT, "getting option %d (value=%d)\n", (int)optnum, (int)dev->val[optnum]); switch( optnum ) { case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_DEPTH: case OPT_THRESHOLD: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: *(SANE_Word *)valP = dev->val[optnum]; break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_VALUE: if( !SANE_OPTION_IS_SETTABLE(dev->opt[optnum].cap) ) return SANE_STATUS_INVAL; status = sanei_constrain_value(&dev->opt[optnum], valP, infoP); if( status != SANE_STATUS_GOOD ) return status; DBG(DOPT, "setting option %d to %d\n", (int)optnum, (int)*(SANE_Word *)valP); switch( optnum ) { case OPT_DEPTH: if( *(SANE_Word *)valP != 1 ) dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; else dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; if( infoP ) *infoP |= SANE_INFO_RELOAD_OPTIONS; /* fall through */ case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: if( infoP ) *infoP |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_THRESHOLD: dev->val[optnum] = *(SANE_Word *)valP; break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_AUTO: DBG(DOPT, "automatic option setting\n"); return SANE_STATUS_UNSUPPORTED; default: return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters( SANE_Handle handle, SANE_Parameters *paramsP ) { ST400_Device *dev = handle; DBG(DCODE, "sane_get_parameters(%p, %p)\n", handle, (void *) paramsP); if( !dev->status.open ) return SANE_STATUS_INVAL; if( !dev->status.scanning ) { double width, height, dpi; dev->params.format = SANE_FRAME_GRAY; dev->params.last_frame = SANE_TRUE; dev->params.lines = 0; dev->params.depth = dev->val[OPT_DEPTH]; width = SANE_UNFIX(dev->val[OPT_BR_X] - dev->val[OPT_TL_X]); height = SANE_UNFIX(dev->val[OPT_BR_Y] - dev->val[OPT_TL_Y]); dpi = dev->val[OPT_RESOLUTION]; /* make best-effort guess at what parameters will look like once scanning starts. */ if( dpi > 0.0 && width > 0.0 && height > 0.0 ) { double dots_per_mm = dpi / MM_PER_INCH; dev->params.pixels_per_line = width * dots_per_mm + 0.5; dev->params.lines = height * dots_per_mm + 0.5; if( dev->params.depth == 1 ) { /* Pad to an even multiple of 8. This way we can simply * copy the bytes from the scanner to the SANE buffer * (only need to invert them). */ dev->params.pixels_per_line += 7; dev->params.pixels_per_line &= ~7; /*dev->params.bytes_per_line = (dev->params.pixels_per_line + 7)/8;*/ dev->params.bytes_per_line = dev->params.pixels_per_line/8; } else dev->params.bytes_per_line = dev->params.pixels_per_line; dev->x = SANE_UNFIX(dev->val[OPT_TL_X]) * dots_per_mm + 0.5; dev->y = SANE_UNFIX(dev->val[OPT_TL_Y]) * dots_per_mm + 0.5; dev->w = dev->params.pixels_per_line; dev->h = dev->params.lines; DBG(DVAR, "parameters: bpl=%d, x=%hu, y=%hu, w=%hu, h=%hu\n", (int)dev->params.bytes_per_line, dev->x, dev->y, dev->w, dev->h); } } if( paramsP ) *paramsP = dev->params; return SANE_STATUS_GOOD; } SANE_Status sane_start( SANE_Handle handle ) { ST400_Device *dev = handle; SANE_Status status; DBG(DCODE, "sane_start(%p)\n", handle); if( !dev->status.open ) return SANE_STATUS_INVAL; if( dev->status.scanning ) return SANE_STATUS_DEVICE_BUSY; status = sane_get_parameters(dev, NULL); if( status != SANE_STATUS_GOOD ) return status; if( !dev->buffer ) { if( st400_maxread > 0 ) dev->bufsize = min(st400_maxread, (unsigned int) sanei_scsi_max_request_size); else if( dev->model->maxread > 0 ) dev->bufsize = min(dev->model->maxread, (unsigned int) sanei_scsi_max_request_size); else dev->bufsize = sanei_scsi_max_request_size; DBG(DVAR, "allocating %lu bytes buffer\n", (u_long)dev->bufsize); dev->buffer = malloc(dev->bufsize); if( !dev->buffer ) return SANE_STATUS_NO_MEM; } dev->bufp = dev->buffer; dev->bytes_in_buffer = 0; if( dev->fd < 0 ) { status = sanei_scsi_open(dev->sane.name, &dev->fd, st400_sense_handler, dev); if( status != SANE_STATUS_GOOD ) goto return_error; } dev->status.eof = 0; status = st400_wait_ready(dev->fd); if( status != SANE_STATUS_GOOD ) goto close_and_return; status = st400_reserve(dev->fd); if( status != SANE_STATUS_GOOD ) goto close_and_return; if( st400_light_delay > 0 ) { status = st400_light_on(dev->fd); if( status != SANE_STATUS_GOOD ) goto release_and_return; usleep(st400_light_delay * 100000); /* 1/10 seconds */ } dev->wy = dev->y; dev->lines_to_read = dev->h; dev->bytes_in_scanner = 0; status = st400_fill_scanner_buffer(dev); if( status != SANE_STATUS_GOOD ) goto lightoff_and_return; /* everything ok */ dev->status.scanning = 1; return SANE_STATUS_GOOD; lightoff_and_return: if( st400_light_delay ) st400_light_off(dev->fd); release_and_return: st400_release(dev->fd); close_and_return: sanei_scsi_close(dev->fd); return_error: dev->fd = -1; return status; } void sane_cancel( SANE_Handle handle ) { ST400_Device *dev = handle; DBG(DCODE, "sane_cancel(%p)\n", handle); if( dev->status.scanning ) { #if 0 st400_stop_scan(dev->fd); #endif if( st400_light_delay ) st400_light_off(dev->fd); st400_release(dev->fd); sanei_scsi_close(dev->fd); dev->status.scanning = 0; dev->fd = -1; } if( dev->buffer ) { free(dev->buffer); dev->buffer = NULL; } } SANE_Status sane_read( SANE_Handle handle, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *lenP ) { ST400_Device *dev = handle; SANE_Status status; size_t r, i; SANE_Byte val; DBG(DCODE, "sane_read(%p, %p, %d, %p)\n", handle, buf, (int)maxlen, (void *) lenP); *lenP = 0; if( !dev->status.scanning ) return SANE_STATUS_INVAL; if( dev->status.eof ) return SANE_STATUS_EOF; status = SANE_STATUS_GOOD; while( maxlen > 0 ) { if( dev->bytes_in_buffer == 0 ) { status = st400_fill_backend_buffer(dev); if( status == SANE_STATUS_EOF ) return SANE_STATUS_GOOD; if( status != SANE_STATUS_GOOD ) { *lenP = 0; return status; } } r = min((SANE_Int) dev->bytes_in_buffer, maxlen); if( dev->val[OPT_DEPTH] == 1 || dev->model->bits == 8 ) { /* This is simple. We made sure the scanning are is aligned to * 8 pixels (see sane_get_parameters()), so we can simply copy * the stuff - only need to invert it. */ for( i = 0; i < r; i++ ) *buf++ = ~(*dev->bufp++); } else { SANE_Byte mv; /* The scanner sends bytes with 6bit-values (0..63), where 0 means * white. To convert to 8bit, we invert the values (so 0 means * black) and then shift them two bits to the left and replicate * the most- significant bits in the lowest two bits of the * 8bit-value: * bit-pattern x x 5 4 3 2 1 0 becomes 5 4 3 2 1 0 5 4 * This is more accurate than simply shifting the values two bits * to the left (e.g. 6bit-white 00111111 gets converted to 8bit- * white 11111111 instead of almost-white 11111100) and is still * reasonably fast. */ mv = (SANE_Byte)maxval(dev->model->bits); /* Note: this works with any bit depth <= 8 */ for( i = 0; i < r; i++ ) { val = mv - *dev->bufp++; val <<= (8 - dev->model->bits); val += (val >> dev->model->bits); *buf++ = val; } } maxlen -= r; dev->bytes_in_buffer -= r; *lenP += r; } return status; } /********************************************************************* * Advanced functions (not supported) *********************************************************************/ SANE_Status sane_set_io_mode( SANE_Handle handle, SANE_Bool nonblock ) { DBG(DCODE, "sane_set_io_mode(%p, %d)\n", handle, (int)nonblock); if( nonblock == SANE_TRUE ) return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd( SANE_Handle handle, SANE_Int *fdP ) { DBG(DCODE, "sane_get_select_fd(%p, %p)\n", handle, (void *) fdP); return SANE_STATUS_UNSUPPORTED; } /* The End */ sane-backends-1.0.29/backend/mustek_usb2_high.c0000666000000000000000000026034713615534521016212 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2005 Mustek. Originally maintained by Mustek Author:Jack Roy 2005.5.24 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for the Mustek BearPaw 2448 TA Pro and similar USB2 scanners. */ #include /* HOLD */ #include /* local header files */ #include "mustek_usb2_asic.c" #include "mustek_usb2_high.h" /* ******************++ spuicall_g.h ****************************/ /*global variable HOLD: these should go to scanner structure */ /*base type*/ static SANE_Bool g_bOpened; static SANE_Bool g_bPrepared; static SANE_Bool g_isCanceled; static SANE_Bool g_bSharpen; static SANE_Bool g_bFirstReadImage; static SANE_Bool g_isScanning; static SANE_Bool g_isSelfGamma; static SANE_Byte g_bScanBits; static SANE_Byte *g_lpReadImageHead; static unsigned short s_wOpticalYDpi[] = { 1200, 600, 300, 150, 75, 0 }; static unsigned short s_wOpticalXDpi[] = { 1200, 600, 300, 150, 75, 0 }; static unsigned short g_X; static unsigned short g_Y; static unsigned short g_Width; static unsigned short g_Height; static unsigned short g_XDpi; static unsigned short g_YDpi; static unsigned short g_SWWidth; static unsigned short g_SWHeight; static unsigned short g_wPixelDistance; /*even & odd sensor problem */ static unsigned short g_wLineDistance; static unsigned short g_wScanLinesPerBlock; static unsigned short g_wReadedLines; static unsigned short g_wReadImageLines; static unsigned short g_wReadyShadingLine; static unsigned short g_wStartShadingLinePos; static unsigned short g_wLineartThreshold; static unsigned int g_wtheReadyLines; static unsigned int g_wMaxScanLines; static unsigned int g_dwScannedTotalLines; static unsigned int g_dwImageBufferSize; static unsigned int g_BytesPerRow; static unsigned int g_SWBytesPerRow; static unsigned int g_dwCalibrationSize; static unsigned int g_dwBufferSize; static unsigned int g_dwTotalTotalXferLines; static unsigned short *g_pGammaTable; static unsigned char *g_pDeviceFile; static pthread_t g_threadid_readimage; /*user define type*/ static COLORMODE g_ScanMode; static TARGETIMAGE g_tiTarget; static SCANTYPE g_ScanType = ST_Reflective; static SCANSOURCE g_ssScanSource; static PIXELFLAVOR g_PixelFlavor; static SUGGESTSETTING g_ssSuggest; static Asic g_chip; static int g_nSecLength, g_nDarkSecLength; static int g_nSecNum, g_nDarkSecNum; static unsigned short g_wCalWidth; static unsigned short g_wDarkCalWidth; static int g_nPowerNum; static unsigned short g_wStartPosition; static pthread_mutex_t g_scannedLinesMutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t g_readyLinesMutex = PTHREAD_MUTEX_INITIALIZER; /*for modify the last point*/ static SANE_Byte * g_lpBefLineImageData = NULL; static SANE_Bool g_bIsFirstReadBefData = TRUE; static unsigned int g_dwAlreadyGetLines = 0; /* forward declarations */ static SANE_Bool MustScanner_Init (void); static SANE_Bool MustScanner_GetScannerState (void); static SANE_Bool MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn); static SANE_Bool MustScanner_BackHome (void); static SANE_Bool MustScanner_Prepare (SANE_Byte bScanSource); #ifdef SANE_UNUSED static SANE_Bool MustScanner_AdjustOffset (int nTimes, SANE_Bool * bDirection, SANE_Byte * bOffset, SANE_Byte * bLastMin, SANE_Byte * bLastOffset, unsigned short * wMinValue, SANE_Byte * bOffsetUpperBound, SANE_Byte * bOffsetLowerBound, unsigned short wStdMinLevel, unsigned short wStdMaxLevel); static SANE_Bool MustScanner_SecondAdjustOffset (int nTimes, SANE_Bool * bDirection, SANE_Byte * bOffset, SANE_Byte * bLastMin, SANE_Byte * bLastOffset, unsigned short * wMinValue, SANE_Byte * bOffsetUpperBound, SANE_Byte * bOffsetLowerBound, unsigned short wStdMinLevel, unsigned short wStdMaxLevel); #endif static unsigned short MustScanner_FiltLower (unsigned short * pSort, unsigned short TotalCount, unsigned short LowCount, unsigned short HighCount); static SANE_Bool MustScanner_GetRgb48BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetRgb48BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetMono16BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetMono8BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetMono1BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static SANE_Bool MustScanner_GetMono1BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount); static void *MustScanner_ReadDataFromScanner (void * dummy); static void MustScanner_PrepareCalculateMaxMin (unsigned short wResolution); static void MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue, unsigned short * lpMinValue, unsigned short wResolution); static SANE_Byte QBET4 (SANE_Byte A, SANE_Byte B); static unsigned int GetScannedLines (void); static unsigned int GetReadyLines (void); static void AddScannedLines (unsigned short wAddLines); static void AddReadyLines (void); static void ModifyLinePoint (SANE_Byte * lpImageData, SANE_Byte * lpImageDataBefore, unsigned int dwBytesPerLine, unsigned int dwLinesCount, unsigned short wPixDistance, unsigned short wModPtCount); #include "mustek_usb2_reflective.c" #include "mustek_usb2_transparent.c" /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: Parameters: none Return value: if initialize the scanner success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_Init () { DBG (DBG_FUNC, "MustScanner_Init: Call in\n"); g_chip.firmwarestate = FS_NULL; if (STATUS_GOOD != Asic_Open (&g_chip, g_pDeviceFile)) { DBG (DBG_FUNC, "MustScanner_Init: Asic_Open return error\n"); return FALSE; } if (STATUS_GOOD != Asic_Initialize (&g_chip)) { DBG (DBG_FUNC, "MustScanner_Init: Asic_Initialize return error\n"); return FALSE; } g_dwImageBufferSize = 24L * 1024L * 1024L; g_dwBufferSize = 64L * 1024L; g_dwCalibrationSize = 64L * 1024L; g_lpReadImageHead = NULL; g_isCanceled = FALSE; g_bFirstReadImage = TRUE; g_bOpened = FALSE; g_bPrepared = FALSE; g_bSharpen = FALSE; g_isScanning = FALSE; g_isSelfGamma = FALSE; g_pGammaTable = NULL; if (NULL != g_pDeviceFile) { free (g_pDeviceFile); g_pDeviceFile = NULL; } g_ssScanSource = SS_Reflective; g_PixelFlavor = PF_BlackIs0; Asic_Close (&g_chip); DBG (DBG_FUNC, "MustScanner_Init: leave MustScanner_Init\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: check the scanner connect status Parameters: none Return value: if scanner's status is OK return TRUE else return FASLE ***********************************************************************/ static SANE_Bool MustScanner_GetScannerState () { if (STATUS_GOOD != Asic_Open (&g_chip, g_pDeviceFile)) { DBG (DBG_FUNC, "MustScanner_GetScannerState: Asic_Open return error\n"); return FALSE; } else { Asic_Close (&g_chip); return TRUE; } } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: Turn the lamp on or off Parameters: isLampOn: turn the lamp on or off isTALampOn: turn the TA lamp on or off Return value: if operation success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn) { SANE_Bool hasTA; DBG (DBG_FUNC, "MustScanner_PowerControl: Call in\n"); if (STATUS_GOOD != Asic_Open (&g_chip, g_pDeviceFile)) { DBG (DBG_FUNC, "MustScanner_PowerControl: Asic_Open return error\n"); return FALSE; } if (STATUS_GOOD != Asic_TurnLamp (&g_chip, isLampOn)) { DBG (DBG_FUNC, "MustScanner_PowerControl: Asic_TurnLamp return error\n"); return FALSE; } if (STATUS_GOOD != Asic_IsTAConnected (&g_chip, &hasTA)) { DBG (DBG_FUNC, "MustScanner_PowerControl: Asic_IsTAConnected return error\n"); return FALSE; } if (hasTA) { if (STATUS_GOOD != Asic_TurnTA (&g_chip, isTALampOn)) { DBG (DBG_FUNC, "MustScanner_PowerControl: Asic_TurnTA return error\n"); return FALSE; } } Asic_Close (&g_chip); DBG (DBG_FUNC, "MustScanner_PowerControl: leave MustScanner_PowerControl\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: Turn the carriage home Parameters: none Return value: if the operation success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_BackHome () { DBG (DBG_FUNC, "MustScanner_BackHome: call in \n"); if (STATUS_GOOD != Asic_Open (&g_chip, g_pDeviceFile)) { DBG (DBG_FUNC, "MustScanner_BackHome: Asic_Open return error\n"); return FALSE; } if (STATUS_GOOD != Asic_CarriageHome (&g_chip, FALSE)) { DBG (DBG_FUNC, "MustScanner_BackHome: Asic_CarriageHome return error\n"); return FALSE; } if (STATUS_GOOD != Asic_WaitUnitReady (&g_chip)) { DBG (DBG_FUNC, "MustScanner_BackHome: Asic_WaitUnitReady return error\n"); return FALSE; } Asic_Close (&g_chip); DBG (DBG_FUNC, "MustScanner_BackHome: leave MustScanner_BackHome\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: prepare the scan image Parameters: bScanSource: the scan source Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_Prepare (SANE_Byte bScanSource) { DBG (DBG_FUNC, "MustScanner_Prepare: call in\n"); if (STATUS_GOOD != Asic_Open (&g_chip, g_pDeviceFile)) { DBG (DBG_FUNC, "MustScanner_Prepare: Asic_Open return error\n"); return FALSE; } if (STATUS_GOOD != Asic_WaitUnitReady (&g_chip)) { DBG (DBG_FUNC, "MustScanner_Prepare: Asic_WaitUnitReady return error\n"); return FALSE; } if (SS_Reflective == bScanSource) { DBG (DBG_FUNC, "MustScanner_Prepare:ScanSource is SS_Reflective\n"); if (STATUS_GOOD != Asic_TurnLamp (&g_chip, TRUE)) { DBG (DBG_FUNC, "MustScanner_Prepare: Asic_TurnLamp return error\n"); return FALSE; } if (STATUS_GOOD != Asic_SetSource (&g_chip, LS_REFLECTIVE)) { DBG (DBG_FUNC, "MustScanner_Prepare: Asic_SetSource return error\n"); return FALSE; } } else if (SS_Positive == bScanSource) { DBG (DBG_FUNC, "MustScanner_Prepare:ScanSource is SS_Positive\n"); if (STATUS_GOOD != Asic_TurnTA (&g_chip, TRUE)) { DBG (DBG_FUNC, "MustScanner_Prepare: Asic_TurnTA return error\n"); return FALSE; } if (STATUS_GOOD != Asic_SetSource (&g_chip, LS_POSITIVE)) { DBG (DBG_FUNC, "MustScanner_Prepare: Asic_SetSource return error\n"); return FALSE; } } else if (SS_Negative == bScanSource) { DBG (DBG_FUNC, "MustScanner_Prepare:ScanSource is SS_Negative\n"); if (STATUS_GOOD != Asic_TurnTA (&g_chip, TRUE)) { DBG (DBG_FUNC, "MustScanner_Prepare: Asic_TurnTA return error\n"); return FALSE; } if (STATUS_GOOD != Asic_SetSource (&g_chip, LS_NEGATIVE)) { DBG (DBG_FUNC, "MustScanner_Prepare: Asic_SetSource return error\n"); return FALSE; } DBG (DBG_FUNC, "MustScanner_Prepare: Asic_SetSource return good\n"); } Asic_Close (&g_chip); g_bPrepared = TRUE; DBG (DBG_FUNC, "MustScanner_Prepare: leave MustScanner_Prepare\n"); return TRUE; } #ifdef SANE_UNUSED /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Adjuest the offset Parameters: nTimes: Adjuest offset the times bDirection: whether direction bOffset: the data of offset bLastMin: the last min data bLastOffset: the last offset data wMinValue: the min value of offset bOffsetUpperBound: the upper bound of offset bOffsetLowerBound: the lower bound of offset wStdMinLevel: the min level of offset wStdMaxLevel: the max level of offset Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_AdjustOffset (int nTimes, SANE_Bool * bDirection, SANE_Byte * bOffset, SANE_Byte * bLastMin, SANE_Byte * bLastOffset, unsigned short * wMinValue, SANE_Byte * bOffsetUpperBound, SANE_Byte * bOffsetLowerBound, unsigned short wStdMinLevel, unsigned short wStdMaxLevel) { if ((*wMinValue <= wStdMaxLevel) && (*wMinValue >= wStdMinLevel)) { return TRUE; } if (nTimes == 0) { *bLastMin = LOSANE_Byte (*wMinValue); *bLastOffset = *bOffset; if (*wMinValue == 255) { *bOffset = 0; } else { *bOffset = 255; } } if (nTimes == 1) { if (*wMinValue > *bLastMin) { if (*wMinValue > wStdMaxLevel && *bLastMin > wStdMaxLevel) { *bDirection = !(*bDirection); return TRUE; } if (*wMinValue < wStdMinLevel && *bLastMin < wStdMinLevel) return TRUE; } if (*wMinValue < *bLastMin) { if (*wMinValue < wStdMinLevel && *bLastMin < wStdMinLevel) *bDirection = !(*bDirection); if (*wMinValue > wStdMaxLevel && *bLastMin > wStdMaxLevel) return TRUE; } } if (nTimes > 1) { if (*wMinValue > *bLastMin) { SANE_Byte bTemp; bTemp = *bOffset; *bOffset = (*bOffsetUpperBound + *bOffsetLowerBound) / 2; if (nTimes > 2) { if (*wMinValue > wStdMaxLevel) if (bDirection) *bOffsetLowerBound = bTemp; else *bOffsetUpperBound = bTemp; else if (bDirection) *bOffsetUpperBound = bTemp; else *bOffsetLowerBound = bTemp; } *bLastOffset = bTemp; *bLastMin = (SANE_Byte) * wMinValue; } else { SANE_Byte bTemp; bTemp = *bOffset; *bOffset = (*bOffsetUpperBound + *bOffsetLowerBound) / 2; if (nTimes > 2) { if (*wMinValue == *bLastMin) { if (*wMinValue > wStdMaxLevel) { if (!bDirection) *bOffsetUpperBound = bTemp; else *bOffsetLowerBound = bTemp; } else { if (!bDirection) *bOffsetLowerBound = bTemp; else *bOffsetUpperBound = bTemp; } } else { if (*wMinValue > wStdMaxLevel) { if (bDirection) *bOffsetUpperBound = bTemp; else *bOffsetLowerBound = bTemp; } else { if (bDirection) *bOffsetLowerBound = bTemp; else *bOffsetUpperBound = bTemp; } } } *bLastOffset = bTemp; *bLastMin = (SANE_Byte) * wMinValue; } } /* end of if(nTimes > 1) */ return TRUE; } #endif #ifdef SANE_UNUSED /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Adjuest the offset second times Parameters: nTimes: Adjuest offset the times bDirection: whether direction bOffset: the data of offset bLastMin: the last min data bLastOffset: the last offset data wMinValue: the min value of offset bOffsetUpperBound: the upper bound of offset bOffsetLowerBound: the lower bound of offset wStdMinLevel: the min level of offset wStdMaxLevel: the max level of offset Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_SecondAdjustOffset (int nTimes, SANE_Bool * bDirection, SANE_Byte * bOffset, SANE_Byte * bLastMin, SANE_Byte * bLastOffset, unsigned short * wMinValue, SANE_Byte * bOffsetUpperBound, SANE_Byte * bOffsetLowerBound, unsigned short wStdMinLevel, unsigned short wStdMaxLevel) { if ((*wMinValue <= wStdMaxLevel) && (*wMinValue >= wStdMinLevel)) { return TRUE; } if (nTimes == 0) { *bLastMin = LOSANE_Byte (*wMinValue); *bLastOffset = *bOffset; if (*bDirection == 0) { *bOffsetUpperBound = *bLastOffset; *bOffsetLowerBound = 0; *bOffset = 0; } else { *bOffsetUpperBound = 255; *bOffsetLowerBound = *bLastOffset; *bOffset = 255; } } if (nTimes >= 1) { if (*wMinValue > wStdMaxLevel) { if (*wMinValue > *bLastMin) { if (*bDirection == 0) { *bOffsetUpperBound = *bOffset; } else { *bOffsetLowerBound = *bOffset; } *bOffset = (*bOffsetUpperBound + *bOffsetLowerBound) / 2; } else { if (*bDirection == 1) { *bOffsetUpperBound = *bOffset; *bOffset = (*bOffsetUpperBound + *bOffsetLowerBound) / 2; } else { *bOffsetLowerBound = *bOffset; *bOffset = (*bOffsetUpperBound + *bOffsetLowerBound) / 2; } } } /*end of if(*wMinValue > MAX_OFFSET) */ if (*wMinValue < wStdMinLevel) { if (*wMinValue > *bLastMin) { if (*bDirection == 0) { *bOffsetLowerBound = *bOffset; } else { *bOffsetUpperBound = *bOffset; } *bOffset = (*bOffsetUpperBound + *bOffsetLowerBound) / 2; } else { if (*bDirection == 1) { *bOffsetUpperBound = *bOffset; *bOffset = (*bOffsetUpperBound + *bOffsetLowerBound) / 2; } else { *bOffsetLowerBound = *bOffset; *bOffset = (*bOffsetUpperBound + *bOffsetLowerBound) / 2; } } } /*end of if(*wMinValue > MIN_OFFSET) */ *bLastMin = (SANE_Byte) * wMinValue; } /*end of if(nTimes >= 1) */ /* HOLD: missing return value! Correct? */ return FALSE; } #endif /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Filter the data Parameters: pSort: the sort data TotalCount: the total count LowCount: the low count HighCount: the upper count Return value: the data of Filter ***********************************************************************/ static unsigned short MustScanner_FiltLower (unsigned short * pSort, unsigned short TotalCount, unsigned short LowCount, unsigned short HighCount) { unsigned short Bound = TotalCount - 1; unsigned short LeftCount = HighCount - LowCount; int Temp = 0; unsigned int Sum = 0; unsigned short i, j; for (i = 0; i < Bound; i++) { for (j = 0; j < Bound - i; j++) { if (pSort[j + 1] > pSort[j]) { Temp = pSort[j]; pSort[j] = pSort[j + 1]; pSort[j + 1] = Temp; } } } for (i = 0; i < LeftCount; i++) Sum += pSort[i + LowCount]; return (unsigned short) (Sum / LeftCount); } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when single CCD and color is 48bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetRgb48BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short wRLinePos = 0; unsigned short wGLinePos = 0; unsigned short wBLinePos = 0; unsigned short wRTempData; unsigned short wGTempData; unsigned short wBTempData; unsigned short i; DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: call in \n"); g_isCanceled = FALSE; g_isScanning = TRUE; wWantedTotalLines = *wLinesCount; TotalXferLines = 0; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: thread create\n"); g_bFirstReadImage = FALSE; } if (!isOrderInvert) { for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { wRLinePos = g_wtheReadyLines % g_wMaxScanLines; wGLinePos = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePos = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; for (i = 0; i < g_SWWidth; i++) { wRTempData = *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + i * 6 + 0); wRTempData += *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + i * 6 + 1) << 8; wGTempData = *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + i * 6 + 2); wGTempData += *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + i * 6 + 3) << 8; wBTempData = *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + i * 6 + 4); wBTempData += *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + i * 6 + 5) << 8; *(lpLine + i * 6 + 0) = LOBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 1) = HIBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 2) = LOBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 3) = HIBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 4) = LOBYTE (g_pGammaTable[wBTempData + 131072]); *(lpLine + i * 6 + 5) = HIBYTE (g_pGammaTable[wBTempData + 131072]); } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: thread exit\n"); break; } } } else { for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { wRLinePos = g_wtheReadyLines % g_wMaxScanLines; wGLinePos = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePos = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; for (i = 0; i < g_SWWidth; i++) { wRTempData = *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + i * 6 + 0); wRTempData += *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + i * 6 + 1) << 8; wGTempData = *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + i * 6 + 2); wGTempData += *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + i * 6 + 3) << 8; wBTempData = *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + i * 6 + 4); wBTempData += *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + i * 6 + 5) << 8; *(lpLine + i * 6 + 4) = LOBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 5) = HIBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 2) = LOBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 3) = HIBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 0) = LOBYTE (g_pGammaTable[wBTempData + 131072]); *(lpLine + i * 6 + 1) = HIBYTE (g_pGammaTable[wBTempData + 131072]); } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: thread exit\n"); break; } } /*end for */ } *wLinesCount = TotalXferLines; g_isScanning = FALSE; DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: leave MustScanner_GetRgb48BitLine\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when double CCD and color is 48bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetRgb48BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short wRLinePosOdd = 0; unsigned short wGLinePosOdd = 0; unsigned short wBLinePosOdd = 0; unsigned short wRLinePosEven = 0; unsigned short wGLinePosEven = 0; unsigned short wBLinePosEven = 0; unsigned int wRTempData; unsigned int wGTempData; unsigned int wBTempData; unsigned int wNextTempData; unsigned short i; DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine1200DPI: call in \n"); TotalXferLines = 0; wWantedTotalLines = *wLinesCount; g_isCanceled = FALSE; g_isScanning = TRUE; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine1200DPI: thread create\n"); g_bFirstReadImage = FALSE; } if (!isOrderInvert) { for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine1200DPI: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { if (ST_Reflective == g_ScanType) { wRLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wGLinePosOdd = (g_wtheReadyLines - g_wLineDistance - g_wPixelDistance) % g_wMaxScanLines; wBLinePosOdd = (g_wtheReadyLines - g_wLineDistance * 2 - g_wPixelDistance) % g_wMaxScanLines; wRLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines; wGLinePosEven = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePosEven = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; } else { wRLinePosEven = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wGLinePosEven = (g_wtheReadyLines - g_wLineDistance - g_wPixelDistance) % g_wMaxScanLines; wBLinePosEven = (g_wtheReadyLines - g_wLineDistance * 2 - g_wPixelDistance) % g_wMaxScanLines; wRLinePosOdd = (g_wtheReadyLines) % g_wMaxScanLines; wGLinePosOdd = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePosOdd = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; } for (i = 0; i < g_SWWidth;) { if (i + 1 != g_SWWidth) { wRTempData = *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + i * 6 + 0); wRTempData += *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + i * 6 + 1) << 8; wNextTempData = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + (i + 1) * 6 + 0); wNextTempData += *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + (i + 1) * 6 + 1) << 8; wRTempData = (wRTempData + wNextTempData) >> 1; wGTempData = *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + i * 6 + 2); wGTempData += *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + i * 6 + 3) << 8; wNextTempData = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + (i + 1) * 6 + 2); wNextTempData += *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + (i + 1) * 6 + 3) << 8; wGTempData = (wGTempData + wNextTempData) >> 1; wBTempData = *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + i * 6 + 4); wBTempData += *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + i * 6 + 5) << 8; wNextTempData = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + (i + 1) * 6 + 4); wNextTempData += *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + (i + 1) * 6 + 5) << 8; wBTempData = (wBTempData + wNextTempData) >> 1; *(lpLine + i * 6 + 0) = LOBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 1) = HIBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 2) = LOBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 3) = HIBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 4) = LOBYTE (g_pGammaTable[wBTempData + 131072]); *(lpLine + i * 6 + 5) = HIBYTE (g_pGammaTable[wBTempData + 131072]); i++; if (i >= g_SWWidth) { break; } wRTempData = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + i * 6 + 0); wRTempData += *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + i * 6 + 1) << 8; wNextTempData = *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 0); wNextTempData += *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 1) << 8; wRTempData = (wRTempData + wNextTempData) >> 1; wGTempData = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + i * 6 + 2); wGTempData += *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + i * 6 + 3) << 8; wNextTempData = *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 2); wNextTempData += *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 3) << 8; wGTempData = (wGTempData + wNextTempData) >> 1; wBTempData = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + i * 6 + 4); wBTempData += *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + i * 6 + 5) << 8; wNextTempData = *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 4); wNextTempData += *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 5) << 8; wBTempData = (wBTempData + wNextTempData) >> 1; *(lpLine + i * 6 + 0) = LOBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 1) = HIBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 2) = LOBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 3) = HIBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 4) = LOBYTE (g_pGammaTable[wBTempData + 131072]); *(lpLine + i * 6 + 5) = HIBYTE (g_pGammaTable[wBTempData + 131072]); i++; } } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine1200DPI: thread exit\n"); break; } } } else { for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine1200DPI: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { if (ST_Reflective == g_ScanType) { wRLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wGLinePosOdd = (g_wtheReadyLines - g_wLineDistance - g_wPixelDistance) % g_wMaxScanLines; wBLinePosOdd = (g_wtheReadyLines - g_wLineDistance * 2 - g_wPixelDistance) % g_wMaxScanLines; wRLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines; wGLinePosEven = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePosEven = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; } else { wRLinePosEven = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wGLinePosEven = (g_wtheReadyLines - g_wLineDistance - g_wPixelDistance) % g_wMaxScanLines; wBLinePosEven = (g_wtheReadyLines - g_wLineDistance * 2 - g_wPixelDistance) % g_wMaxScanLines; wRLinePosOdd = (g_wtheReadyLines) % g_wMaxScanLines; wGLinePosOdd = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePosOdd = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; } for (i = 0; i < g_SWWidth;) { if ((i + 1) != g_SWWidth) { wRTempData = *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + i * 6 + 0); wRTempData += *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + i * 6 + 1) << 8; wNextTempData = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + (i + 1) * 6 + 0); wNextTempData += *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + (i + 1) * 6 + 1) << 8; wRTempData = (wRTempData + wNextTempData) >> 1; wGTempData = *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + i * 6 + 2); wGTempData += *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + i * 6 + 3) << 8; wNextTempData = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + (i + 1) * 6 + 2); wNextTempData += *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + (i + 1) * 6 + 3) << 8; wGTempData = (wGTempData + wNextTempData) >> 1; wBTempData = *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + i * 6 + 4); wBTempData += *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + i * 6 + 5) << 8; wNextTempData = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + (i + 1) * 6 + 4); wNextTempData += *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + (i + 1) * 6 + 5) << 8; wBTempData = (wBTempData + wNextTempData) >> 1; *(lpLine + i * 6 + 4) = LOBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 5) = HIBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 2) = LOBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 3) = HIBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 0) = LOBYTE (g_pGammaTable[wBTempData + 131072]); *(lpLine + i * 6 + 1) = HIBYTE (g_pGammaTable[wBTempData + 131072]); i++; if (i >= g_SWWidth) { break; } wRTempData = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + i * 6 + 0); wRTempData += *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + i * 6 + 1) << 8; wNextTempData = *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 0); wNextTempData += *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 1) << 8; wRTempData = (wRTempData + wNextTempData) >> 1; wGTempData = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + i * 6 + 2); wGTempData += *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + i * 6 + 3) << 8; wNextTempData = *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 2); wNextTempData += *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 3) << 8; wGTempData = (wGTempData + wNextTempData) >> 1; wBTempData = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + i * 6 + 4); wBTempData += *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + i * 6 + 5) << 8; wNextTempData = *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 4); wNextTempData += *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + (i + 1) * 6 + 5) << 8; wBTempData = (wBTempData + wNextTempData) >> 1; *(lpLine + i * 6 + 4) = LOBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 5) = HIBYTE (g_pGammaTable[wRTempData]); *(lpLine + i * 6 + 2) = LOBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 3) = HIBYTE (g_pGammaTable[wGTempData + 65536]); *(lpLine + i * 6 + 0) = LOBYTE (g_pGammaTable[wBTempData + 131072]); *(lpLine + i * 6 + 1) = HIBYTE (g_pGammaTable[wBTempData + 131072]); i++; } } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine1200DPI: thread exit\n"); break; } } } *wLinesCount = TotalXferLines; g_isScanning = FALSE; DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine1200DPI: leave MustScanner_GetRgb48BitLine1200DPI\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when single CCD and color is 24bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short wRLinePos = 0; unsigned short wGLinePos = 0; unsigned short wBLinePos = 0; SANE_Byte byRed; SANE_Byte byGreen; SANE_Byte byBlue; SANE_Byte bNextPixel = 0; unsigned short i; unsigned short tempR, tempG, tempB; DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: call in\n"); g_isCanceled = FALSE; g_isScanning = TRUE; wWantedTotalLines = *wLinesCount; DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: get wWantedTotalLines= %d\n", wWantedTotalLines); TotalXferLines = 0; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: thread create\n"); g_bFirstReadImage = FALSE; } if (!isOrderInvert) { DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: !isOrderInvert\n"); for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { wRLinePos = g_wtheReadyLines % g_wMaxScanLines; wGLinePos = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePos = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; for (i = 0; i < g_SWWidth; i++) { byRed = *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + i * 3 + 0); bNextPixel = *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + (i + 1) * 3 + 0); byRed = (byRed + bNextPixel) >> 1; byGreen = *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + i * 3 + 1); bNextPixel = *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + (i + 1) * 3 + 1); byGreen = (byGreen + bNextPixel) >> 1; byBlue = *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + i * 3 + 2); bNextPixel = *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + (i + 1) * 3 + 2); byBlue = (byBlue + bNextPixel) >> 1; #ifdef ENABLE_GAMMA tempR = (unsigned short) ((byRed << 4) | QBET4 (byBlue, byGreen)); tempG = (unsigned short) ((byGreen << 4) | QBET4 (byRed, byBlue)); tempB = (unsigned short) ((byBlue << 4) | QBET4 (byGreen, byRed)); *(lpLine + i * 3 + 0) = (unsigned char) (*(g_pGammaTable + tempR)); *(lpLine + i * 3 + 1) = (unsigned char) (*(g_pGammaTable + 4096 + tempG)); *(lpLine + i * 3 + 2) = (unsigned char) (*(g_pGammaTable + 8192 + tempB)); #else *(lpLine + i * 3 + 0) = (unsigned char) byRed; *(lpLine + i * 3 + 1) = (unsigned char) byGreen; *(lpLine + i * 3 + 2) = (unsigned char) byBlue; #endif } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: g_dwTotalTotalXferLines=%d,g_SWHeight=%d\n", g_dwTotalTotalXferLines, g_SWHeight); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: g_SWBytesPerRow=%d\n", g_SWBytesPerRow); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: thread exit\n"); break; } } } else { DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: isOrderInvert is TRUE\n"); for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { wRLinePos = g_wtheReadyLines % g_wMaxScanLines; wGLinePos = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePos = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; for (i = 0; i < g_SWWidth; i++) { DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: before byRed\n"); byRed = *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + i * 3 + 0); bNextPixel = *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + (i + 1) * 3 + 0); /*R-channel */ byRed = (byRed + bNextPixel) >> 1; DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: before byGreen\n"); byGreen = *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + i * 3 + 1); bNextPixel = *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + (i + 1) * 3 + 1); /*G-channel */ byGreen = (byGreen + bNextPixel) >> 1; DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: before byBlue\n"); byBlue = *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + i * 3 + 2); bNextPixel = *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + (i + 1) * 3 + 2); /*B-channel */ byBlue = (byBlue + bNextPixel) >> 1; DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: before set lpLine\n"); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: i=%d\n", i); #ifdef ENABLE_GAMMA *(lpLine + i * 3 + 2) = (unsigned char) (*(g_pGammaTable + (unsigned short) ((byRed << 4) | QBET4 (byBlue, byGreen)))); *(lpLine + i * 3 + 1) = (unsigned char) (*(g_pGammaTable + 4096 + (unsigned short) ((byGreen << 4) | QBET4 (byRed, byBlue)))); *(lpLine + i * 3 + 0) = (unsigned char) (*(g_pGammaTable + 8192 + (unsigned short) ((byBlue << 4) | QBET4 (byGreen, byRed)))); #else *(lpLine + i * 3 + 2) = (unsigned char) byRed; *(lpLine + i * 3 + 1) = (unsigned char) byGreen; *(lpLine + i * 3 + 0) = (unsigned char) byBlue; #endif } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: g_dwTotalTotalXferLines=%d,g_SWHeight=%d\n", g_dwTotalTotalXferLines, g_SWHeight); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: g_SWBytesPerRow=%d\n", g_SWBytesPerRow); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: thread exit\n"); break; } } /*end for */ } *wLinesCount = TotalXferLines; g_isScanning = FALSE; DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: leave MustScanner_GetRgb24BitLine\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when double CCD and color is 24bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short wRLinePosOdd = 0; unsigned short wGLinePosOdd = 0; unsigned short wBLinePosOdd = 0; unsigned short wRLinePosEven = 0; unsigned short wGLinePosEven = 0; unsigned short wBLinePosEven = 0; SANE_Byte byRed; SANE_Byte byGreen; SANE_Byte byBlue; SANE_Byte bNextPixel = 0; unsigned short i; DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: call in\n"); g_isCanceled = FALSE; g_isScanning = TRUE; TotalXferLines = 0; wWantedTotalLines = *wLinesCount; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: thread create\n"); g_bFirstReadImage = FALSE; } if (!isOrderInvert) { for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: g_dwTotalTotalXferLines=%d\n", g_dwTotalTotalXferLines); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: g_Height=%d\n", g_Height); pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { if (ST_Reflective == g_ScanType) { wRLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wGLinePosOdd = (g_wtheReadyLines - g_wLineDistance - g_wPixelDistance) % g_wMaxScanLines; wBLinePosOdd = (g_wtheReadyLines - g_wLineDistance * 2 - g_wPixelDistance) % g_wMaxScanLines; wRLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines; wGLinePosEven = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePosEven = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; } else { wRLinePosEven = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wGLinePosEven = (g_wtheReadyLines - g_wLineDistance - g_wPixelDistance) % g_wMaxScanLines; wBLinePosEven = (g_wtheReadyLines - g_wLineDistance * 2 - g_wPixelDistance) % g_wMaxScanLines; wRLinePosOdd = (g_wtheReadyLines) % g_wMaxScanLines; wGLinePosOdd = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePosOdd = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; } for (i = 0; i < g_SWWidth;) { if ((i + 1) != g_SWWidth) { byRed = *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + i * 3 + 0); bNextPixel = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + (i + 1) * 3 + 0); /*R-channel */ byRed = (byRed + bNextPixel) >> 1; byGreen = *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + i * 3 + 1); bNextPixel = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + (i + 1) * 3 + 1); /*G-channel */ byGreen = (byGreen + bNextPixel) >> 1; byBlue = *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + i * 3 + 2); bNextPixel = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + (i + 1) * 3 + 2); /*B-channel */ byBlue = (byBlue + bNextPixel) >> 1; #ifdef ENABLE_GAMMA *(lpLine + i * 3 + 0) = (unsigned char) (*(g_pGammaTable + (unsigned short) ((byRed << 4) | QBET4 (byBlue, byGreen)))); *(lpLine + i * 3 + 1) = (unsigned char) (*(g_pGammaTable + 4096 + (unsigned short) ((byGreen << 4) | QBET4 (byRed, byBlue)))); *(lpLine + i * 3 + 2) = (unsigned char) (*(g_pGammaTable + 8192 + (unsigned short) ((byBlue << 4) | QBET4 (byGreen, byRed)))); #else *(lpLine + i * 3 + 0) = (unsigned char) byRed; *(lpLine + i * 3 + 1) = (unsigned char) byGreen; *(lpLine + i * 3 + 2) = (unsigned char) byBlue; #endif i++; if (i >= g_SWWidth) { break; } byRed = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + i * 3 + 0); bNextPixel = *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + (i + 1) * 3 + 0); byRed = (byRed + bNextPixel) >> 1; byGreen = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + i * 3 + 1); bNextPixel = *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + (i + 1) * 3 + 1); byGreen = (byGreen + bNextPixel) >> 1; byBlue = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + i * 3 + 2); bNextPixel = *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + (i + 1) * 3 + 2); byBlue = (byBlue + bNextPixel) >> 1; #ifdef ENABLE_GAMMA *(lpLine + i * 3 + 0) = (unsigned char) (*(g_pGammaTable + (unsigned short) ((byRed << 4) | QBET4 (byBlue, byGreen)))); *(lpLine + i * 3 + 1) = (unsigned char) (*(g_pGammaTable + 4096 + (unsigned short) ((byGreen << 4) | QBET4 (byRed, byBlue)))); *(lpLine + i * 3 + 2) = (unsigned char) (*(g_pGammaTable + 8192 + (unsigned short) ((byBlue << 4) | QBET4 (byGreen, byRed)))); #else *(lpLine + i * 3 + 0) = (unsigned char) byRed; *(lpLine + i * 3 + 1) = (unsigned char) byGreen; *(lpLine + i * 3 + 2) = (unsigned char) byBlue; #endif i++; } } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: g_dwTotalTotalXferLines=%d\n", g_dwTotalTotalXferLines); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: g_Height=%d\n", g_Height); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: thread exit\n"); break; } } } else { for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: g_dwTotalTotalXferLines=%d\n", g_dwTotalTotalXferLines); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: g_Height=%d\n", g_Height); pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { if (ST_Reflective == g_ScanType) { wRLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wGLinePosOdd = (g_wtheReadyLines - g_wLineDistance - g_wPixelDistance) % g_wMaxScanLines; wBLinePosOdd = (g_wtheReadyLines - g_wLineDistance * 2 - g_wPixelDistance) % g_wMaxScanLines; wRLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines; wGLinePosEven = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePosEven = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; } else { wRLinePosEven = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wGLinePosEven = (g_wtheReadyLines - g_wLineDistance - g_wPixelDistance) % g_wMaxScanLines; wBLinePosEven = (g_wtheReadyLines - g_wLineDistance * 2 - g_wPixelDistance) % g_wMaxScanLines; wRLinePosOdd = (g_wtheReadyLines) % g_wMaxScanLines; wGLinePosOdd = (g_wtheReadyLines - g_wLineDistance) % g_wMaxScanLines; wBLinePosOdd = (g_wtheReadyLines - g_wLineDistance * 2) % g_wMaxScanLines; } for (i = 0; i < g_SWWidth;) { if ((i + 1) != g_SWWidth) { byRed = *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + i * 3 + 0); bNextPixel = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + (i + 1) * 3 + 0); byRed = (byRed + bNextPixel) >> 1; byGreen = *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + i * 3 + 1); bNextPixel = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + (i + 1) * 3 + 1); byGreen = (byGreen + bNextPixel) >> 1; byBlue = *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + i * 3 + 2); bNextPixel = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + (i + 1) * 3 + 2); byBlue = (byBlue + bNextPixel) >> 1; #ifdef ENABLE_GAMMA *(lpLine + i * 3 + 2) = (unsigned char) (*(g_pGammaTable + (unsigned short) ((byRed << 4) | QBET4 (byBlue, byGreen)))); *(lpLine + i * 3 + 1) = (unsigned char) (*(g_pGammaTable + 4096 + (unsigned short) ((byGreen << 4) | QBET4 (byRed, byBlue)))); *(lpLine + i * 3 + 0) = (unsigned char) (*(g_pGammaTable + 8192 + (unsigned short) ((byBlue << 4) | QBET4 (byGreen, byRed)))); #else *(lpLine + i * 3 + 2) = (unsigned char) byRed; *(lpLine + i * 3 + 1) = (unsigned char) byGreen; *(lpLine + i * 3 + 0) = (unsigned char) byBlue; #endif i++; if (i >= g_SWWidth) { break; } byRed = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + i * 3 + 0); bNextPixel = *(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow + (i + 1) * 3 + 0); byRed = (byRed + bNextPixel) >> 1; byGreen = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + i * 3 + 1); bNextPixel = *(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow + (i + 1) * 3 + 1); byGreen = (byGreen + bNextPixel) >> 1; byBlue = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + i * 3 + 2); bNextPixel = *(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow + (i + 1) * 3 + 2); byBlue = (byBlue + bNextPixel) >> 1; #ifdef ENABLE_GAMMA *(lpLine + i * 3 + 2) = (unsigned char) (*(g_pGammaTable + (unsigned short) ((byRed << 4) | QBET4 (byBlue, byGreen)))); *(lpLine + i * 3 + 1) = (unsigned char) (*(g_pGammaTable + 4096 + (unsigned short) ((byGreen << 4) | QBET4 (byRed, byBlue)))); *(lpLine + i * 3 + 0) = (unsigned char) (*(g_pGammaTable + 8192 + (unsigned short) ((byBlue << 4) | QBET4 (byGreen, byRed)))); #else *(lpLine + i * 3 + 2) = (unsigned char) byRed; *(lpLine + i * 3 + 1) = (unsigned char) byGreen; *(lpLine + i * 3 + 0) = (unsigned char) byBlue; #endif i++; } } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: g_dwTotalTotalXferLines=%d\n", g_dwTotalTotalXferLines); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: g_Height=%d\n", g_Height); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: thread exit\n"); break; } } } *wLinesCount = TotalXferLines; g_isScanning = FALSE; DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: leave MustScanner_GetRgb24BitLine1200DPI\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when single CCD and color is 16bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetMono16BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned int wTempData; unsigned short wLinePos = 0; unsigned short i; isOrderInvert = isOrderInvert; DBG (DBG_FUNC, "MustScanner_GetMono16BitLine: call in\n"); TotalXferLines = 0; g_isCanceled = FALSE; g_isScanning = TRUE; wWantedTotalLines = *wLinesCount; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetMono16BitLine: thread create\n"); g_bFirstReadImage = FALSE; } for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono16BitLine: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { wLinePos = g_wtheReadyLines % g_wMaxScanLines; for (i = 0; i < g_SWWidth; i++) { wTempData = *(g_lpReadImageHead + wLinePos * g_BytesPerRow + i * 2 + 0); wTempData += *(g_lpReadImageHead + wLinePos * g_BytesPerRow + i * 2 + 1) << 8; *(lpLine + i * 2 + 0) = LOBYTE (g_pGammaTable[wTempData]); *(lpLine + i * 2 + 1) = HIBYTE (g_pGammaTable[wTempData]); } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono16BitLine: thread exit\n"); break; } } *wLinesCount = TotalXferLines; g_isScanning = FALSE; DBG (DBG_FUNC, "MustScanner_GetMono16BitLine: leave MustScanner_GetMono16BitLine\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when double CCD and color is 16bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned int dwTempData; unsigned short wLinePosOdd = 0; unsigned short wLinePosEven = 0; unsigned short i; SANE_Byte * lpTemp = lpLine; isOrderInvert = isOrderInvert; DBG (DBG_FUNC, "MustScanner_GetMono16BitLine1200DPI: call in\n"); TotalXferLines = 0; g_isCanceled = FALSE; g_isScanning = TRUE; wWantedTotalLines = *wLinesCount; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetMono16BitLine1200DPI: thread create\n"); g_bFirstReadImage = FALSE; } for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono16BitLine1200DPI: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { if (ST_Reflective == g_ScanType) { wLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines; } else { wLinePosEven = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wLinePosOdd = (g_wtheReadyLines) % g_wMaxScanLines; } for (i = 0; i < g_SWWidth;) { if ((i + 1) != g_SWWidth) { dwTempData = (unsigned int) (* (g_lpReadImageHead + wLinePosOdd * g_BytesPerRow + i * 2 + 0)); dwTempData += (unsigned int) (* (g_lpReadImageHead + wLinePosOdd * g_BytesPerRow + i * 2 + 1) << 8); dwTempData += (unsigned int) (* (g_lpReadImageHead + wLinePosEven * g_BytesPerRow + (i + 1) * 2 + 0)); dwTempData += (unsigned int) (* (g_lpReadImageHead + wLinePosEven * g_BytesPerRow + (i + 1) * 2 + 1) << 8); dwTempData = g_pGammaTable[dwTempData >> 1]; *(lpLine + i * 2 + 0) = LOBYTE ((unsigned short) dwTempData); *(lpLine + i * 2 + 1) = HIBYTE ((unsigned short) dwTempData); i++; if (i >= g_SWWidth) { break; } dwTempData = (unsigned int) (* (g_lpReadImageHead + wLinePosEven * g_BytesPerRow + i * 2 + 0)); dwTempData += (unsigned int) (* (g_lpReadImageHead + wLinePosEven * g_BytesPerRow + i * 2 + 1) << 8); dwTempData += (unsigned int) (* (g_lpReadImageHead + wLinePosOdd * g_BytesPerRow + (i + 1) * 2 + 0)); dwTempData += (unsigned int) (* (g_lpReadImageHead + wLinePosOdd * g_BytesPerRow + (i + 1) * 2 + 1) << 8); dwTempData = g_pGammaTable[dwTempData >> 1]; *(lpLine + i * 2 + 0) = LOBYTE ((unsigned short) dwTempData); *(lpLine + i * 2 + 1) = HIBYTE ((unsigned short) dwTempData); i++; } } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono16BitLine1200DPI: thread exit\n"); break; } } *wLinesCount = TotalXferLines; g_isScanning = FALSE; /*for modify the last point */ if (g_bIsFirstReadBefData) { g_lpBefLineImageData = (SANE_Byte *) malloc (g_SWBytesPerRow); if (NULL == g_lpBefLineImageData) { return FALSE; } memset (g_lpBefLineImageData, 0, g_SWBytesPerRow); memcpy (g_lpBefLineImageData, lpTemp, g_SWBytesPerRow); g_bIsFirstReadBefData = FALSE; } ModifyLinePoint (lpTemp, g_lpBefLineImageData, g_SWBytesPerRow, wWantedTotalLines, 2, 4); memcpy (g_lpBefLineImageData, lpTemp + (wWantedTotalLines - 1) * g_SWBytesPerRow, g_SWBytesPerRow); g_dwAlreadyGetLines += wWantedTotalLines; if (g_dwAlreadyGetLines >= g_SWHeight) { DBG (DBG_FUNC, "MustScanner_GetMono16BitLine1200DPI: free before line data!\n"); free (g_lpBefLineImageData); g_lpBefLineImageData = NULL; g_dwAlreadyGetLines = 0; g_bIsFirstReadBefData = TRUE; } DBG (DBG_FUNC, "MustScanner_GetMono16BitLine1200DPI: leave MustScanner_GetMono16BitLine1200DPI\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when single CCD and color is 8bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetMono8BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short i; unsigned short wLinePos = 0; isOrderInvert = isOrderInvert; DBG (DBG_FUNC, "MustScanner_GetMono8BitLine: call in\n"); TotalXferLines = 0; g_isCanceled = FALSE; g_isScanning = TRUE; wWantedTotalLines = *wLinesCount; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetMono8BitLine: thread create\n"); g_bFirstReadImage = FALSE; } for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono8BitLine: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { wLinePos = g_wtheReadyLines % g_wMaxScanLines; for (i = 0; i < g_SWWidth; i++) { *(lpLine + i) = (SANE_Byte) * (g_pGammaTable + (unsigned short) ((* (g_lpReadImageHead + wLinePos * g_BytesPerRow + i) << 4) | (rand () & 0x0f))); } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono8BitLine: thread exit\n"); break; } } *wLinesCount = TotalXferLines; g_isScanning = FALSE; DBG (DBG_FUNC, "MustScanner_GetMono8BitLine: leave MustScanner_GetMono8BitLine\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when double CCD and color is 8bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { SANE_Byte *lpTemp; unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short wLinePosOdd = 0; unsigned short wLinePosEven = 0; SANE_Byte byGray; unsigned short i; SANE_Byte bNextPixel = 0; isOrderInvert = isOrderInvert; DBG (DBG_FUNC, "MustScanner_GetMono8BitLine1200DPI: call in\n"); TotalXferLines = 0; g_isCanceled = FALSE; g_isScanning = TRUE; wWantedTotalLines = *wLinesCount; lpTemp = lpLine; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetMono8BitLine1200DPI: thread create\n"); g_bFirstReadImage = FALSE; } for (; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono8BitLine1200DPI: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { if (ST_Reflective == g_ScanType) { wLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines; } else { wLinePosEven = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; wLinePosOdd = (g_wtheReadyLines) % g_wMaxScanLines; } for (i = 0; i < g_SWWidth;) { if ((i + 1) != g_SWWidth) { byGray = *(g_lpReadImageHead + wLinePosOdd * g_BytesPerRow + i); bNextPixel = *(g_lpReadImageHead + wLinePosEven * g_BytesPerRow + (i + 1)); byGray = (byGray + bNextPixel) >> 1; *(lpLine + i) = (SANE_Byte) * (g_pGammaTable + (byGray << 4 | (rand () & 0x0f))); i++; if (i >= g_SWWidth) { break; } byGray = *(g_lpReadImageHead + wLinePosEven * g_BytesPerRow + i); bNextPixel = *(g_lpReadImageHead + wLinePosOdd * g_BytesPerRow + (i + 1)); byGray = (byGray + bNextPixel) >> 1; *(lpLine + i) = (SANE_Byte) * (g_pGammaTable + (byGray << 4 | (rand () & 0x0f))); i++; } } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono8BitLine1200DPI: thread exit\n"); break; } } *wLinesCount = TotalXferLines; g_isScanning = FALSE; /*for modify the last point */ if (g_bIsFirstReadBefData) { g_lpBefLineImageData = (SANE_Byte *) malloc (g_SWBytesPerRow); if (NULL == g_lpBefLineImageData) { return FALSE; } memset (g_lpBefLineImageData, 0, g_SWBytesPerRow); memcpy (g_lpBefLineImageData, lpTemp, g_SWBytesPerRow); g_bIsFirstReadBefData = FALSE; } ModifyLinePoint (lpTemp, g_lpBefLineImageData, g_SWBytesPerRow, wWantedTotalLines, 1, 4); memcpy (g_lpBefLineImageData, lpTemp + (wWantedTotalLines - 1) * g_SWBytesPerRow, g_SWBytesPerRow); g_dwAlreadyGetLines += wWantedTotalLines; if (g_dwAlreadyGetLines >= g_SWHeight) { DBG (DBG_FUNC, "MustScanner_GetMono8BitLine1200DPI: free the before line data!\n"); free (g_lpBefLineImageData); g_lpBefLineImageData = NULL; g_dwAlreadyGetLines = 0; g_bIsFirstReadBefData = TRUE; } DBG (DBG_FUNC, "MustScanner_GetMono8BitLine1200DPI: leave MustScanner_GetMono8BitLine1200DPI\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when single CCD and color is 1bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetMono1BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short wLinePos; unsigned short i; isOrderInvert = isOrderInvert; DBG (DBG_FUNC, "MustScanner_GetMono1BitLine: call in\n"); g_isCanceled = FALSE; g_isScanning = TRUE; wWantedTotalLines = *wLinesCount; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetMono1BitLine: thread create\n"); g_bFirstReadImage = FALSE; } memset (lpLine, 0, wWantedTotalLines * g_SWWidth / 8); for (TotalXferLines = 0; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono1BitLine: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { wLinePos = g_wtheReadyLines % g_wMaxScanLines; for (i = 0; i < g_SWWidth; i++) { if (*(g_lpReadImageHead + wLinePos * g_BytesPerRow + i) > g_wLineartThreshold) { *(lpLine + i / 8) += (0x80 >> (i % 8)); } } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += (g_SWBytesPerRow / 8); AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono1BitLine: thread exit\n"); break; } } *wLinesCount = TotalXferLines; g_isScanning = FALSE; DBG (DBG_FUNC, "MustScanner_GetMono1BitLine: leave MustScanner_GetMono1BitLine\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Repair line when double CCD and color is 1bit Parameters: lpLine: point to image be repaired isOrderInvert: RGB or BGR wLinesCount: how many line be repaired Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool MustScanner_GetMono1BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert, unsigned short * wLinesCount) { unsigned short wWantedTotalLines; unsigned short TotalXferLines; unsigned short i; unsigned short wLinePosOdd; unsigned short wLinePosEven; isOrderInvert = isOrderInvert; DBG (DBG_FUNC, "MustScanner_GetMono1BitLine1200DPI: call in\n"); g_isCanceled = FALSE; g_isScanning = TRUE; wWantedTotalLines = *wLinesCount; if (g_bFirstReadImage) { pthread_create (&g_threadid_readimage, NULL, MustScanner_ReadDataFromScanner, NULL); DBG (DBG_FUNC, "MustScanner_GetMono1BitLine1200DPI: thread create\n"); g_bFirstReadImage = FALSE; } memset (lpLine, 0, wWantedTotalLines * g_SWWidth / 8); for (TotalXferLines = 0; TotalXferLines < wWantedTotalLines;) { if (g_dwTotalTotalXferLines >= g_SWHeight) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono1BitLine1200DPI: thread exit\n"); *wLinesCount = TotalXferLines; g_isScanning = FALSE; return TRUE; } if (GetScannedLines () > g_wtheReadyLines) { if (ST_Reflective == g_ScanType) { wLinePosEven = (g_wtheReadyLines) % g_wMaxScanLines; wLinePosOdd = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; } else { wLinePosOdd = (g_wtheReadyLines) % g_wMaxScanLines; wLinePosEven = (g_wtheReadyLines - g_wPixelDistance) % g_wMaxScanLines; } for (i = 0; i < g_SWWidth;) { if ((i + 1) != g_SWWidth) { if (*(g_lpReadImageHead + wLinePosOdd * g_BytesPerRow + i) > g_wLineartThreshold) *(lpLine + i / 8) += (0x80 >> (i % 8)); i++; if (i >= g_SWWidth) { break; } if (*(g_lpReadImageHead + wLinePosEven * g_BytesPerRow + i) > g_wLineartThreshold) *(lpLine + i / 8) += (0x80 >> (i % 8)); i++; } } TotalXferLines++; g_dwTotalTotalXferLines++; lpLine += g_SWBytesPerRow / 8; AddReadyLines (); } if (g_isCanceled) { pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "MustScanner_GetMono1BitLine1200DPI: thread exit\n"); break; } } /*end for */ *wLinesCount = TotalXferLines; g_isScanning = FALSE; DBG (DBG_FUNC, "MustScanner_GetMono1BitLine1200DPI: leave MustScanner_GetMono1BitLine1200DPI\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/21 Routine Description: prepare calculate Max and Min value Parameters: wResolution: the scan resolution Return value: none ***********************************************************************/ static void MustScanner_PrepareCalculateMaxMin (unsigned short wResolution) { g_wDarkCalWidth = 52; if (wResolution <= 600) { g_wCalWidth = ((5120 * wResolution / 600 + 511) >> 9) << 9; g_wDarkCalWidth = g_wDarkCalWidth / (1200 / wResolution); if (wResolution < 200) { g_nPowerNum = 3; g_nSecLength = 8; /* 2^nPowerNum */ g_nDarkSecLength = g_wDarkCalWidth / 2; /* Dark has at least 2 sections */ } else { g_nPowerNum = 6; g_nSecLength = 64; /* 2^nPowerNum */ g_nDarkSecLength = g_wDarkCalWidth / 3; } } else { g_nPowerNum = 6; g_nSecLength = 64; /*2^nPowerNum */ g_wCalWidth = 10240; g_nDarkSecLength = g_wDarkCalWidth / 5; } if (g_nDarkSecLength <= 0) { g_nDarkSecLength = 1; } g_wStartPosition = 13 * wResolution / 1200; g_wCalWidth -= g_wStartPosition; /* start of find Max value */ g_nSecNum = (int) (g_wCalWidth / g_nSecLength); /* start of fin min value */ g_nDarkSecNum = (int) (g_wDarkCalWidth / g_nDarkSecLength); } /********************************************************************** Author: Jack Date: 2005/05/21 Routine Description: calculate the Max and Min value Parameters: pBuffer: the image data lpMaxValue: the max value lpMinValue: the min value wResolution: the scan resolution Return value: none ***********************************************************************/ static void MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue, unsigned short * lpMinValue, unsigned short wResolution) { unsigned short *wSecData = NULL, *wDarkSecData = NULL; int i, j; wResolution = wResolution; wSecData = (unsigned short *) malloc (sizeof (unsigned short) * g_nSecNum); if (wSecData == NULL) { return; } else { memset (wSecData, 0, g_nSecNum * sizeof (unsigned short)); } for (i = 0; i < g_nSecNum; i++) { for (j = 0; j < g_nSecLength; j++) wSecData[i] += *(pBuffer + g_wStartPosition + i * g_nSecLength + j); wSecData[i] >>= g_nPowerNum; } *lpMaxValue = wSecData[0]; for (i = 0; i < g_nSecNum; i++) { if (*lpMaxValue < wSecData[i]) *lpMaxValue = wSecData[i]; } free (wSecData); wDarkSecData = (unsigned short *) malloc (sizeof (unsigned short) * g_nDarkSecNum); if (wDarkSecData == NULL) { return; } else { memset (wDarkSecData, 0, g_nDarkSecNum * sizeof (unsigned short)); } for (i = 0; i < g_nDarkSecNum; i++) { for (j = 0; j < g_nDarkSecLength; j++) wDarkSecData[i] += *(pBuffer + g_wStartPosition + i * g_nDarkSecLength + j); wDarkSecData[i] /= g_nDarkSecLength; } *lpMinValue = wDarkSecData[0]; for (i = 0; i < g_nDarkSecNum; i++) { if (*lpMinValue > wDarkSecData[i]) *lpMinValue = wDarkSecData[i]; } free (wDarkSecData); } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Read the data from scanner Parameters: none Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static void * MustScanner_ReadDataFromScanner (void * dummy) { unsigned short wTotalReadImageLines = 0; unsigned short wWantedLines = g_Height; SANE_Byte * lpReadImage = g_lpReadImageHead; SANE_Bool isWaitImageLineDiff = FALSE; unsigned int wMaxScanLines = g_wMaxScanLines; unsigned short wReadImageLines = 0; unsigned short wScanLinesThisBlock; unsigned short wBufferLines = g_wLineDistance * 2 + g_wPixelDistance; dummy = dummy; DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: call in, and in new thread\n"); while (wTotalReadImageLines < wWantedLines && g_lpReadImageHead) { if (!isWaitImageLineDiff) { wScanLinesThisBlock = (wWantedLines - wTotalReadImageLines) < g_wScanLinesPerBlock ? (wWantedLines - wTotalReadImageLines) : g_wScanLinesPerBlock; DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: wWantedLines=%d\n", wWantedLines); DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: wScanLinesThisBlock=%d\n", wScanLinesThisBlock); if (STATUS_GOOD != Asic_ReadImage (&g_chip, lpReadImage, wScanLinesThisBlock)) { DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner:Asic_ReadImage return error\n"); DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner:thread exit\n"); return NULL; } /*has read in memroy Buffer */ wReadImageLines += wScanLinesThisBlock; AddScannedLines (wScanLinesThisBlock); wTotalReadImageLines += wScanLinesThisBlock; lpReadImage += wScanLinesThisBlock * g_BytesPerRow; /*Buffer is full */ if (wReadImageLines >= wMaxScanLines) { lpReadImage = g_lpReadImageHead; wReadImageLines = 0; } if ((g_dwScannedTotalLines - GetReadyLines ()) >= (wMaxScanLines - (wBufferLines + g_wScanLinesPerBlock)) && g_dwScannedTotalLines > GetReadyLines ()) { isWaitImageLineDiff = TRUE; } } else if (g_dwScannedTotalLines <= GetReadyLines () + wBufferLines + g_wScanLinesPerBlock) { isWaitImageLineDiff = FALSE; } pthread_testcancel (); } DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: Read image ok\n"); DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: thread exit\n"); DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: leave MustScanner_ReadDataFromScanner\n"); return NULL; } /********************************************************************** Author: Jack Date: 2005/05/26 Routine Description: get the lines of scanned Parameters: none Return value: the lines of scanned ***********************************************************************/ static unsigned int GetScannedLines () { unsigned int dwScannedLines = 0; pthread_mutex_lock (&g_scannedLinesMutex); dwScannedLines = g_dwScannedTotalLines; pthread_mutex_unlock (&g_scannedLinesMutex); return dwScannedLines; } /********************************************************************** Author: Jack Date: 2005/05/26 Routine Description: get lines which pass to superstratum Parameters: none Return value: the lines which pass to superstratum ***********************************************************************/ static unsigned int GetReadyLines () { unsigned int dwReadyLines = 0; pthread_mutex_lock (&g_readyLinesMutex); dwReadyLines = g_wtheReadyLines; pthread_mutex_unlock (&g_readyLinesMutex); return dwReadyLines; } /********************************************************************** Author: Jack Date: 2005/05/26 Routine Description: add the scanned total lines Parameters: wAddLines: add the lines Return value: none ***********************************************************************/ static void AddScannedLines (unsigned short wAddLines) { pthread_mutex_lock (&g_scannedLinesMutex); g_dwScannedTotalLines += wAddLines; pthread_mutex_unlock (&g_scannedLinesMutex); } /********************************************************************** Author: Jack Date: 2005/05/26 Routine Description: add the ready lines Parameters: none Return value: none ***********************************************************************/ static void AddReadyLines () { pthread_mutex_lock (&g_readyLinesMutex); g_wtheReadyLines++; pthread_mutex_unlock (&g_readyLinesMutex); } /********************************************************************** Author: Jack Date: 2005/05/26 Routine Description: modify the point Parameters: lpImageData: the data of image lpImageDataBefore: the data of before line image dwBytesPerLine: the bytes of per line dwLinesCount: the line count wPixDistance: the pixel distance wModPtCount: the modify point count Return value: none ***********************************************************************/ static void ModifyLinePoint (SANE_Byte * lpImageData, SANE_Byte * lpImageDataBefore, unsigned int dwBytesPerLine, unsigned int dwLinesCount, unsigned short wPixDistance, unsigned short wModPtCount) { unsigned short i = 0; unsigned short j = 0; unsigned short wLines = 0; unsigned int dwWidth = dwBytesPerLine / wPixDistance; for (i = wModPtCount; i > 0; i--) { for (j = 0; j < wPixDistance; j++) { /*modify the first line */ *(lpImageData + (dwWidth - i) * wPixDistance + j) = (*(lpImageData + (dwWidth - i - 1) * wPixDistance + j) + *(lpImageDataBefore + (dwWidth - i) * wPixDistance + j)) / 2; /*modify other lines */ for (wLines = 1; wLines < dwLinesCount; wLines++) { unsigned int dwBytesBefor = (wLines - 1) * dwBytesPerLine; unsigned int dwBytes = wLines * dwBytesPerLine; *(lpImageData + dwBytes + (dwWidth - i) * wPixDistance + j) = (* (lpImageData + dwBytes + (dwWidth - i - 1) * wPixDistance + j) + *(lpImageData + dwBytesBefor + (dwWidth - i) * wPixDistance + j)) / 2; } } } } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Modifiy the image data Parameters: A: the input the image data B: the input the iamge data Return value: the modified data ***********************************************************************/ static SANE_Byte QBET4 (SANE_Byte A, SANE_Byte B) { SANE_Byte bQBET[16][16] = { {0, 0, 0, 0, 1, 1, 2, 2, 4, 4, 5, 5, 8, 8, 9, 9}, {0, 0, 0, 0, 1, 1, 2, 2, 4, 4, 5, 5, 8, 8, 9, 9}, {0, 0, 0, 0, 1, 1, 2, 2, 4, 4, 5, 5, 8, 8, 9, 9}, {0, 0, 0, 0, 1, 1, 2, 2, 4, 4, 5, 5, 8, 8, 9, 9}, {1, 1, 1, 1, 3, 3, 3, 3, 6, 6, 6, 6, 10, 10, 11, 11}, {1, 1, 1, 1, 3, 3, 3, 3, 6, 6, 6, 6, 10, 10, 11, 11}, {2, 2, 2, 2, 3, 3, 3, 3, 7, 7, 7, 7, 10, 10, 11, 11}, {2, 2, 2, 2, 3, 3, 3, 3, 7, 7, 7, 7, 10, 10, 11, 11}, {4, 4, 4, 4, 6, 6, 7, 7, 12, 12, 12, 12, 13, 13, 14, 14}, {4, 4, 4, 4, 6, 6, 7, 7, 12, 12, 12, 12, 13, 13, 14, 14}, {5, 5, 5, 5, 6, 6, 7, 7, 12, 12, 12, 12, 13, 13, 14, 14}, {5, 5, 5, 5, 6, 6, 7, 7, 12, 12, 12, 12, 13, 13, 14, 14}, {8, 8, 8, 8, 10, 10, 10, 10, 13, 13, 13, 13, 15, 15, 15, 15}, {8, 8, 8, 8, 10, 10, 10, 10, 13, 13, 13, 13, 15, 15, 15, 15}, {9, 9, 9, 9, 11, 11, 11, 11, 14, 14, 14, 14, 15, 15, 15, 15}, {9, 9, 9, 9, 11, 11, 11, 11, 14, 14, 14, 14, 15, 15, 15, 15} }; A = A & 0x0f; B = B & 0x0f; return bQBET[A][B]; } /* end of the file MustScanner.c */ sane-backends-1.0.29/backend/umax-uc1260.c0000666000000000000000000001047713615534521014635 00000000000000/* ------------------------------------------------------------------------- */ /* umax-uc1260.c: inquiry for UMAX scanner uc1260 (C) 1997-2002 Oliver Rauch 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* ------------------------------------------------------------------------- */ #include "umax-scanner.h" /* ------------------------------------------------------------------------- */ static unsigned char UC1260_INQUIRY[] = { #define UC1260_INQUIRY_LEN 0x9d /* 24 F/W support function */ 0x03, /* 25 -27 exposure-times */ 0x00, 0x00, 0x00, /* 28 - 29 reserved */ 0x00, 0x00, /* 2a - 35 exposure times */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 36 - 37 reserved */ 0x00, 0x00, /* 38 - 5f scsi reserved */ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, /* 60 -62 scanner capability*/ 0x31, 0x0c, 0x07, /* 63 reserved */ 0x00, /* 64 gamma */ 0xa3, /* 65 reserved */ 0x00, /* 66 GIB */ 0x01, /* 67 reserved */ 0x00, /* 68 GOB */ 0x01, /* 69 - 6a halftone */ 0x0c, 0x2f, /* 6b - 6c reserved */ 0x00, 0x00, /* 6d color sequence */ 0x08, /* 6e - 71 video memory */ 0x00, 0x20, 0x00, 0x00, /* 72 reserved */ 0x00, /* 73 max optical res in 100 dpi */ 0x06, /* 74 max x_res in 100 dpi */ 0x06, /* 75 max y_res in 100 dpi */ 0x0c, /* 76-77 fb max scan width in 0.01 inch */ 0x03, 0x52, /* 78-79 fb max scan length in 0.01 inch */ 0x05, 0x78, /* UTA parameters empirically determined on Peter Missel's unit */ /* 7a-7b uta x original point */ 0x00, 0x77, /* 7c-7d uta y original point */ 0x00, 0x8f, /* 7e-7f uta max scan width in 0.01 inch */ 0x02, 0x63, /* 80-81 uta max scan length in 0.01 inch */ 0x03, 0x61, /* 82-85 reserved */ 00, 00, 00, 00, /* 86-87 dor x original point */ 0x00, 0x00, /* 88-89 dor x original point */ 0x00, 0x00, /* 8a-8b dor max scan width in 0.01 inch */ 0x00, 0x00, /* 8c-8d dor max scan length in 0.01 inch */ 0x00, 0x00, /* 8e reserved */ 0x00, /* 8f last calibration lamp density */ 0x00, /* 90 reserved */ 0x00, /* 91 lamp warmup max time */ 0x00, /* 92-93 window descriptor block length */ 0x00, 0x30, /* 94 optical resolution residue (1dpi) */ 0x00, /* 95 x_resolution residue (1dpi) */ 0x00, /* 96 y_resolution residue (1dpi) */ 0x00, /* 97 analog gamma table */ 0x00, /* 98-99 reserved */ 0x00, 0x00, /* 9a max calibration data lines */ 0x00, /* 9b fb/uta colour-sequnce-mode */ 0x01, /* 9c adf colour-sequnce-mode */ 0x01, /* 9d line-distance of ccd */ 0x08 }; static inquiry_blk inquiry_uc1260 = { "UC1260 ",UC1260_INQUIRY, UC1260_INQUIRY_LEN }; sane-backends-1.0.29/backend/plustek-usbhw.c0000666000000000000000000013443413615534521015562 00000000000000/*............................................................................. * Project : SANE library for Plustek flatbed scanners. *............................................................................. */ /** @file plustek-usbhw.c * @brief Functions to control the scanner hardware. * * Based on sources acquired from Plustek Inc.
* Copyright (C) 2001-2013 Gerhard Jaeger * * History: * - 0.40 - starting version of the USB support * - 0.41 - added EPSON1250 specific stuff * - added alternative usb_IsScannerReady function * - 0.42 - added warmup stuff * - added UMAX 3400 stuff * - fixed problem with minimum wait time... * - 0.43 - added usb_switchLamp for non-Plustek devices * - 0.44 - added bStepsToReverse and active Pixelstart values * - to resetRegister function * - modified getLampStatus function for CIS devices * - added usb_Wait4Warmup() * - moved usb_IsEscPressed to this file * - added usb_switchLampX * - do now not reinitialized MISC I/O pins upon reset registers * - 0.45 - added function usb_AdjustLamps() to tweak CIS lamp settings * - fixed NULL pointer problem in lamp-off ISR * - added usb_AdjustCISLampSettings() * - skipping warmup for CIS devices * - 0.46 - fixed problem in usb_GetLampStatus for CIS devices, as we * read back reg[0x29] to wrong position * made it compile without itimer definitions * - 0.47 - moved usb_HostSwap() and usb_Swap() to this file. * - fixed lampOff timer for systems w/o setitimer * - added lamp off adjustment for CIS devices * - 0.48 - added usb_IsCISDevice() * - added usb_HasTPA() * - changed usb_Wait4Warmup() * - added usb_WaitPos() * - added usb_FillLampRegs() - sets also PWMDutyCylce now * - added UMAX3450 TPA autodetection * - 0.49 - a_bRegs is now part of the device structure * - fixed problem in backtracking, when speedup is enabled * - added usb_UpdateButtonStatus() * - 0.50 - added button support for Plustek/Genius devices * - changed behaviour of usb_IsScannerReady * - added special misc I/O setup for CIS devices (usb_ResetRegisters) * - 0.51 - change usb_AdjustLamps() and use it now in usb_switchLamp() * - added usb_Wait4ScanSample() and usb_InCalibrationMode() * - tweaked EjectPaper to work correctly with the supported sheet-fed * devices * - fixed button handling for Plustek/Genius devices and added * some more debug output to that code path * - 0.52 - changed DCapsDef, lamp -> misc_io * - hammer in output bit, when using misc io pins for lamp switching * - increased wait time for sheet-fed scanner (needed for Q-SCAN A6, * patch by Hiroshi Miura) * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #ifdef HAVE_SYS_TIME_H #include #endif #define DEV_LampReflection 1 #define DEV_LampTPA 2 #define DEV_LampAll 3 #define DEV_LampPositive 4 #define DEV_LampNegative 5 #define WAIT_TIME_FOR_SCAN_SAMPLE 20 /* 20 seconds maximum wait time */ /** the NatSemi 983x is a big endian chip, and the line protocol data all * arrives big-endian. This determines if we need to swap to host-order */ static SANE_Bool usb_HostSwap( void ) { u_short pattern = 0xfeed; /* deadbeef */ unsigned char *bytewise = (unsigned char *)&pattern; if ( bytewise[0] == 0xfe ) { DBG( _DBG_READ, "We're big-endian! No need to swap!\n" ); return 0; } DBG( _DBG_READ, "We're little-endian! NatSemi LM983x is big!\n" ); DBG( _DBG_READ, "--> Must swap data!\n" ); return 1; } /** as the name says.. */ static void usb_Swap( u_short *pw, u_long dwBytes ) { for( dwBytes /= 2; dwBytes--; pw++ ) _SWAP(((u_char*) pw)[0], ((u_char*)pw)[1]); } /** * This function is used to detect a cancel condition, * our ESC key is the SIGUSR1 signal. It is sent by the backend when the * cancel button has been pressed * * @param - none * @return the function returns SANE_TRUE if a cancel condition has been * detected, if not, it returns SANE_FALSE */ static SANE_Bool usb_IsEscPressed( void ) { sigset_t sigs; sigpending( &sigs ); if( sigismember( &sigs, SIGUSR1 )) { DBG( _DBG_INFO, "SIGUSR1 is pending --> Cancel detected\n" ); return SANE_TRUE; } return SANE_FALSE; } /** usb_GetMotorSet * according to the model, the function returns the address of * the corresponding entry of the Motor table */ static ClkMotorDef* usb_GetMotorSet( eModelDef model ) { int i; for( i = 0; i < MODEL_LAST; i++ ) { if( model == Motors[i].motorModel ) { return &(Motors[i]); } } return NULL; } /** switch motor on or off * @param handle - handle to open USB device * @param fOn - SANE_TRUE means motor on, SANE_FALSE means motor off * @return always SANE_TRUE */ static SANE_Bool usb_MotorOn( Plustek_Device *dev, SANE_Bool fOn ) { if( fOn ) dev->usbDev.a_bRegs[0x45] |= 0x10; else dev->usbDev.a_bRegs[0x45] &= ~0x10; usbio_WriteReg( dev->fd, 0x45, dev->usbDev.a_bRegs[0x45] ); return SANE_TRUE; } /** */ static SANE_Bool usb_IsCISDevice( Plustek_Device *dev ) { return ( dev->usbDev.HwSetting.bReg_0x26 & _ONE_CH_COLOR ); } /** */ static SANE_Bool usb_IsSheetFedDevice( Plustek_Device *dev ) { return ( dev->usbDev.Caps.wFlags & DEVCAPSFLAG_SheetFed ); } /** */ static SANE_Bool usb_InCalibrationMode( Plustek_Device *dev ) { if((dev->scanning.dwFlag & SCANFLAG_Calibration) == 0) return SANE_FALSE; return SANE_TRUE; } /** check if scanner is ready */ static SANE_Bool usb_IsScannerReady( Plustek_Device *dev ) { u_char value; double len; long timeout; struct timeval t; SANE_Status res; /* time in s = 1000*scanner length in inches/max step speed/in */ len = (dev->usbDev.Caps.Normal.Size.y/(double)_MEASURE_BASE) + 5; len = (1000.0 * len)/dev->usbDev.HwSetting.dMaxMoveSpeed; len /= 1000.0; /* wait at least 10 seconds... */ if( len < 10 ) len = 10; gettimeofday( &t, NULL); timeout = t.tv_sec + len; do { res = usbio_ReadReg( dev->fd, 7, &value); if( res != SANE_STATUS_GOOD ) { sleep(1); } else { if( value == 0 ) { _UIO( usbio_ResetLM983x( dev )); return SANE_TRUE; } if((value == 0) || (value >= 0x20) || (value == 0x03)) { if( !usbio_WriteReg( dev->fd, 0x07, 0 )) { DBG( _DBG_ERROR, "Scanner not ready!!!\n" ); return SANE_FALSE; } else { return SANE_TRUE; } } } gettimeofday( &t, NULL); } while( t.tv_sec < timeout ); DBG( _DBG_ERROR, "Scanner not ready!!!\n" ); return SANE_FALSE; } /** */ static SANE_Bool usb_SensorAdf( Plustek_Device *dev ) { u_char value; if( usb_IsSheetFedDevice(dev)) return SANE_FALSE; usbio_ReadReg( dev->fd, 0x02, &value ); return (value & 0x20); } /** */ static SANE_Bool usb_SensorPaper( Plustek_Device *dev ) { DCapsDef *sc = &dev->usbDev.Caps; u_char val, mask = 0x02; usbio_ReadReg( dev->fd, 0x02, &val ); if( usb_IsSheetFedDevice(dev)) mask = _GET_PAPERSENSE_PORT(sc->misc_io); return (val & mask); } /** function for sheet-fed devices, to make sure, that there's * something to scan */ static SANE_Bool usb_Wait4ScanSample( Plustek_Device *dev ) { struct timeval start_time, t2; if( !usb_IsSheetFedDevice(dev)) return SANE_TRUE; DBG( _DBG_INFO2, "Waiting for something to scan...\n" ); gettimeofday( &start_time, NULL ); do { gettimeofday( &t2, NULL ); if( t2.tv_sec > start_time.tv_sec + WAIT_TIME_FOR_SCAN_SAMPLE ) { DBG( _DBG_ERROR, "Nothing to scan!!!\n" ); return SANE_FALSE; } if( usb_IsEscPressed()) return SANE_FALSE; } while( !usb_SensorPaper( dev )); /* just a little delay, to make sure the paper is taken by the scanner */ usleep(100* 1000); DBG( _DBG_INFO2, "... okay, scanning now!\n" ); return SANE_TRUE; } /** function to move the sensor and to speed it up to a certain speed until * the position is reached */ static SANE_Bool usb_WaitPos( Plustek_Device *dev, u_long to, SANE_Bool stay ) { SANE_Bool retval; u_char value, mclk_div, mch; u_char r[2]; u_short ffs, step, min_ffs; long dwTicks; double maxf, fac, speed; struct timeval start_time, t2; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; /* get current master clock divider */ usbio_ReadReg( dev->fd, 0x08, &value ); mclk_div = (value >> 1) + 1; /* get current channel mode */ usbio_ReadReg( dev->fd, 0x26, &value ); mch = ((value & 0x07) > 1) ? 1:3; /* calculate the current speed */ ffs = regs[0x48] * 256 + regs[0x49]; speed = ((double)CRYSTAL_FREQ) /(double)((u_long)mclk_div * 32UL * (u_long)mch * (u_long)ffs * hw->wMotorDpi); /* disabled ? */ if((hw->dHighSpeed == 0.0) || (dev->adj.disableSpeedup != 0)) { min_ffs = 0xffff; maxf = 0.0; if( !stay ) return SANE_TRUE; } else { min_ffs = (u_short)(CRYSTAL_FREQ /((u_long)mclk_div * 32UL * (u_long)mch * hw->dHighSpeed * hw->wMotorDpi)); maxf = (ffs - min_ffs)/4; if( maxf > 100.0 ) maxf = 100.0; if( maxf < 5.0 ) maxf = 5.0; DBG( _DBG_INFO2, ">>>> CURRENT MCLK_DIV = %u\n", mclk_div ); DBG( _DBG_INFO2, ">>>> MCH = %u\n", mch ); DBG( _DBG_INFO2, ">>>> FFS = %u\n", ffs ); DBG( _DBG_INFO2, ">>>> HIGH-SPEED = %.3f (%.3f)\n", speed, hw->dHighSpeed); DBG( _DBG_INFO2, ">>>> MIN_FFS = %u (%.3f)\n", min_ffs, maxf); } gettimeofday( &start_time, NULL ); dwTicks = start_time.tv_sec + to; step = 1; retval = SANE_FALSE; for(;;) { usleep( 1000 ); _UIO( usbio_ReadReg( dev->fd, 0x07, &value )); if (!value) return SANE_TRUE; gettimeofday(&t2, NULL); if( t2.tv_sec > dwTicks ) break; if( min_ffs != 0xffff ) { fac = maxf/step; if( ffs ) { if((u_short)fac < ffs ) { ffs -= fac; if( ffs < min_ffs ) ffs = min_ffs; } else { if(ffs != min_ffs ) ffs = min_ffs; else ffs = 0; } } if( ffs >= min_ffs ) { if((int)fac > 25 ) usleep( 150 * 1000 ); r[0] = (u_char)(ffs >> 8); r[1] = (u_char)(ffs & 0xFF); sanei_lm983x_write(dev->fd, 0x48, r, 2, SANE_TRUE); if(ffs == min_ffs ) ffs = 0; } else { if( !stay ) { retval = SANE_TRUE; break; } } step++; } } return retval; } /** function to move the sensor or if sheet-fed device, to move the paper. * In moving backward-mode, the home sensor is always turned on. * @param action - what to do * @param steps - steps to move, based on 300dpi, 0 means move forever */ static SANE_Bool usb_ModuleMove( Plustek_Device *dev, u_char action, u_long dwStep ) { SANE_Bool retval, ejected; u_char bReg2, reg7, mclk_div; u_short wFastFeedStepSize; double dMaxMoveSpeed; ClkMotorDef *clk; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; if( action != MOVE_ToPaperSensor && action != MOVE_EjectAllPapers && action != MOVE_SkipPaperSensor && action != MOVE_ToShading && !dwStep ) { return SANE_TRUE; } if( !usb_IsScannerReady( dev )) { DBG( _DBG_ERROR, "Sensor-position NOT reached\n" ); return SANE_FALSE; } if( action == MOVE_EjectAllPapers ) { double d = hw->dMaxMoveSpeed; /* FIXME */ if (hw->motorModel == MODEL_QSCAN_A6){ DBG( _DBG_INFO2, "Q-SCAN-A6 may not be able to detect ejected papers\n"); return SANE_TRUE; } hw->dMaxMoveSpeed += 0.8; /* was 0.6 */ DBG( _DBG_INFO2, "Ejecting paper...\n" ); retval = SANE_TRUE; ejected = SANE_FALSE; do { if( usb_SensorPaper(dev)) { if (!usb_ModuleMove(dev,MOVE_SkipPaperSensor, 0 )) { hw->dMaxMoveSpeed = d; return SANE_FALSE; } ejected = SANE_TRUE; } if( usb_SensorAdf(dev) && !usb_ModuleMove(dev,MOVE_ToPaperSensor, 0 )) { hw->dMaxMoveSpeed = d; return SANE_FALSE; } if( usb_IsEscPressed()) { retval = SANE_FALSE; break; } } while( usb_SensorPaper(dev)); /* when the paper is beyond the sensor, we move another 300 steps * to make sure, that the scanned sheet is out of the scanner * BUT: not at startup */ if (dev->initialized >= 0 || ejected) { DBG(_DBG_INFO2, "... MORE EJECT...\n"); if(!usb_ModuleMove( dev, MOVE_Forward, 300 /* *3 */)) { hw->dMaxMoveSpeed = d; return SANE_FALSE; } } usbio_WriteReg( dev->fd, 0x07, 0); usbio_WriteReg( dev->fd, 0x58, regs[0x58]); usbio_ReadReg( dev->fd, 0x02, &bReg2 ); hw->dMaxMoveSpeed = d; DBG( _DBG_INFO2, "...done\n" ); return retval; } usbio_WriteReg( dev->fd, 0x0a, 0 ); /* Compute fast feed step size, use equation 3 and equation 8 */ dMaxMoveSpeed = hw->dMaxMoveSpeed; if( action == MOVE_ToShading ) { if( hw->dMaxMoveSpeed > 0.5 ) dMaxMoveSpeed = hw->dMaxMoveSpeed - 0.5; } clk = usb_GetMotorSet( hw->motorModel ); mclk_div = clk->mclk_fast; wFastFeedStepSize = (u_short)(CRYSTAL_FREQ / ((u_long)mclk_div * 8UL * 1 * dMaxMoveSpeed * 4 * hw->wMotorDpi)); regs[0x48] = (u_char)(wFastFeedStepSize >> 8); regs[0x49] = (u_char)(wFastFeedStepSize & 0xFF); dwStep = dwStep * hw->wMotorDpi / 300UL; regs[0x4a] = _HIBYTE(_LOWORD(dwStep)); regs[0x4b] = _LOBYTE(_LOWORD(dwStep)); regs[0x45] |= 0x10; DBG( _DBG_INFO2,"MotorDPI=%u, MaxMoveSpeed=%.3f, " "FFStepSize=%u, Steps=%lu\n", hw->wMotorDpi, hw->dMaxMoveSpeed, wFastFeedStepSize, dwStep ); DBG( _DBG_INFO2, "MOTOR: " "PWM=0x%02x, PWM_DUTY=0x%02x 0x45=0x%02x " "0x48=0x%02x, 0x49=0x%02x \n", regs[0x56], regs[0x57], regs[0x45], regs[0x48], regs[0x49] ); DBG( _DBG_INFO2,"MCLK_FFW = %u --> 0x%02x\n", mclk_div, (mclk_div-1)*2 ); /* The setting for chassis moving is: * MCLK divider = 6, 8 bits/pixel, HDPI divider = 12, * no integration time adjustment and 1 channel grayscale */ /* MCLK divider = 6 */ if( !usbio_WriteReg(dev->fd, 0x08, (mclk_div-1)*2 /*0x0A*/)) return SANE_FALSE; /* 8 bits/pixel, HDPI divider = 12 */ if( !usbio_WriteReg(dev->fd, 0x09, 0x1F)) return SANE_FALSE; /* Turn off integration time adjustment */ if( !usbio_WriteReg(dev->fd, 0x19, 0)) return SANE_FALSE; /* 1 channel grayscale, green channel */ if( !usbio_WriteReg(dev->fd, 0x26, 0x0C)) return SANE_FALSE; _UIO(sanei_lm983x_write(dev->fd, 0x48, ®s[0x48], 2, SANE_TRUE)); _UIO(sanei_lm983x_write(dev->fd, 0x4A, ®s[0x4A], 2, SANE_TRUE)); /* disable home */ if( !usbio_WriteReg(dev->fd, 0x58, regs[0x58] & ~7)) return SANE_FALSE; if( !usbio_WriteReg(dev->fd, 0x45, regs[0x45] )) return SANE_FALSE; if( action == MOVE_Forward || action == MOVE_ToShading ) reg7 = 5; else if( action == MOVE_Backward ) reg7 = 6; else if( action == MOVE_ToPaperSensor || action == MOVE_EjectAllPapers || action == MOVE_SkipPaperSensor ) { reg7 = 1; } else { return SANE_TRUE; } retval = SANE_FALSE; /* start the sensor... */ if( usbio_WriteReg( dev->fd, 0x07, reg7 )) { long secs; struct timeval start_time, t2; /* at least we move 20 seconds before timeout... */ gettimeofday( &start_time, NULL ); secs = start_time.tv_sec + 20; if( action == MOVE_ToPaperSensor ) { for(;;) { if( usb_SensorPaper( dev )) { usbio_WriteReg( dev->fd, 0x07, 0 ); usbio_WriteReg( dev->fd, 0x58, regs[0x58] ); usbio_ReadReg ( dev->fd, 0x02, &bReg2 ); return SANE_TRUE; } gettimeofday(&t2, NULL); if( t2.tv_sec > secs ) break; } } else if( action == MOVE_SkipPaperSensor ) { for(;;) { if( !usb_SensorPaper( dev )) { usbio_WriteReg( dev->fd, 0x07, 0 ); usbio_WriteReg( dev->fd, 0x58, regs[0x58] ); usbio_ReadReg ( dev->fd, 0x02, &bReg2 ); return SANE_TRUE; } gettimeofday(&t2, NULL); if( t2.tv_sec > secs ) break; } } else { retval = usb_WaitPos( dev, 200, SANE_TRUE ); } usbio_WriteReg( dev->fd, 0x58, regs[0x58] ); usbio_ReadReg ( dev->fd, 0x02, &bReg2 ); } if( !retval ) DBG( _DBG_ERROR, "Position NOT reached\n" ); return retval; } /** */ static SANE_Bool usb_ModuleToHome( Plustek_Device *dev, SANE_Bool fWait ) { u_char mclk_div; u_char value; DCapsDef *scaps = &dev->usbDev.Caps; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; if( usb_IsSheetFedDevice(dev)) { return usb_ModuleMove( dev, MOVE_EjectAllPapers, 0 ); } /* Check if merlin is ready for setting command */ usbio_WriteReg( dev->fd, 0x58, hw->bReg_0x58 ); usbio_ReadReg ( dev->fd, 2, &value ); if( value & 1 ) { dev->usbDev.fModFirstHome = SANE_FALSE; return SANE_TRUE; } _UIO( usbio_ReadReg( dev->fd, 0x07, &value )); if( dev->usbDev.fModFirstHome ) { dev->usbDev.fModFirstHome = SANE_FALSE; if( hw->motorModel != MODEL_Tokyo600 ) usb_ModuleMove( dev, MOVE_Forward, hw->wMotorDpi / 2); } /* if not homing, do it... */ if( value != 2 ) { u_short wFastFeedStepSize; if( hw->motorModel == MODEL_Tokyo600 ) { usbio_WriteReg( dev->fd, 0x07, 0 ); } else { _UIO( usbio_ResetLM983x( dev )); usleep(200*1000); } if(!_IS_PLUSTEKMOTOR(hw->motorModel)) { ClkMotorDef *clk; clk = usb_GetMotorSet( hw->motorModel ); regs[0x56] = clk->pwm_fast; regs[0x57] = clk->pwm_duty_fast; mclk_div = clk->mclk_fast; } else { mclk_div = 6; if( scaps->OpticDpi.x == 1200 || scaps->bPCB == 2) { switch( hw->motorModel ) { case MODEL_KaoHsiung: case MODEL_HuaLien: default: regs[0x56] = 1; regs[0x57] = 63; break; } } else { /* if(Device.Caps.OpticDpi.x == 600) */ switch( hw->motorModel ) { case MODEL_Tokyo600: regs[0x56] = 4; regs[0x57] = 4; /* 2; */ break; case MODEL_HuaLien: if( dev->caps.dwFlag & SFLAG_ADF ) { regs[0x56] = 64; /* 32; */ regs[0x57] = 4; /* 16; */ } else { regs[0x56] = 32; regs[0x57] = 16; } break; case MODEL_KaoHsiung: default: regs[0x56] = 64; regs[0x57] = 20; break; } } } /* Compute fast feed step size, use equation 3 and equation 8 * assumptions: MCLK = 6, Lineratemode (CM=1) */ wFastFeedStepSize = (u_short)(CRYSTAL_FREQ / (mclk_div * 8 * 1 * hw->dMaxMotorSpeed * 4 * hw->wMotorDpi)); regs[0x48] = (u_char)(wFastFeedStepSize >> 8); regs[0x49] = (u_char)(wFastFeedStepSize & 0xFF); regs[0x4a] = 0; regs[0x4b] = 0; regs[0x45] |= 0x10; DBG( _DBG_INFO2,"MotorDPI=%u, MaxMotorSpeed=%.3f, FFStepSize=%u\n", hw->wMotorDpi, hw->dMaxMotorSpeed, wFastFeedStepSize ); DBG( _DBG_INFO, "MOTOR: " "PWM=0x%02x, PWM_DUTY=0x%02x 0x45=0x%02x " "0x48=0x%02x, 0x49=0x%02x\n", regs[0x56], regs[0x57], regs[0x45], regs[0x48], regs[0x49] ); /* The setting for chassis moving is: * MCLK divider = 6, 8 bits/pixel, HDPI divider = 12, * no integration time adjustment and 1 channel grayscale */ /* MCLK divider = 6 */ value = (u_char)((mclk_div-1) * 2); DBG( _DBG_INFO, "MCLK_FFW = %u --> 0x%02x\n", mclk_div, value ); if( !usbio_WriteReg(dev->fd, 0x08, value)) return SANE_FALSE; /* 8 bits/pixel, HDPI divider = 12 */ if( !usbio_WriteReg(dev->fd, 0x09, 0x1F)) return SANE_FALSE; /* Turn off integration time adjustment */ if( !usbio_WriteReg(dev->fd, 0x19, 0)) return SANE_FALSE; /* 1 channel grayscale, green channel */ if( !usbio_WriteReg(dev->fd, 0x26, 0x8C)) return SANE_FALSE; _UIO(sanei_lm983x_write(dev->fd, 0x48, ®s[0x48], 4, SANE_TRUE)); _UIO(sanei_lm983x_write(dev->fd, 0x56, ®s[0x56], 3, SANE_TRUE)); if( !usbio_WriteReg(dev->fd, 0x45, regs[0x45])) return SANE_FALSE; usbio_WriteReg(dev->fd, 0x0a, 0); if( hw->motorModel == MODEL_HuaLien && scaps->OpticDpi.x == 600 ) usleep(100 * 1000); if( !usbio_WriteReg(dev->fd, 0x07, 2)) return SANE_FALSE; #if 0 if( hw->motorModel == MODEL_Tokyo600) { u_long dwSpeedUp = GetTickCount () + 250; /* while(GetTickCount () < dwSpeedUp) */ while((int)(dwSpeedUp - GetTickCount ()) > 0) { Sleep (10); if (!ReadRegister (0x07, &value)) return FALSE; if (!value) return TRUE; } wFastFeedStepSize = (WORD)(CRYSTAL_FREQ / (6UL * 8UL * 1 * Device.HwSetting.dMaxMotorSpeed * 4 * Device.HwSetting.wMotorDpi) * 60 / 78); regs[0x48] = (u_char)(wFastFeedStepSize >> 8); regs[0x49] = (u_char)(wFastFeedStepSize & 0xFF); WriteRegisters(0x48, ®s[0x48], 2); } #endif } return usb_WaitPos( dev, 150, fWait ); } /** */ static SANE_Bool usb_MotorSelect( Plustek_Device *dev, SANE_Bool fADF ) { DCapsDef *sCaps = &dev->usbDev.Caps; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; if(!_IS_PLUSTEKMOTOR(hw->motorModel)) { return SANE_TRUE; } if( fADF ) { if( sCaps->bCCD == kNEC3778 ) { hw->wMotorDpi = 300; hw->dMaxMotorSpeed = 1.5; hw->dMaxMoveSpeed = 1.5; sCaps->OpticDpi.y = 600; } regs[0x5b] |= 0x80; } else { if( sCaps->bCCD == kNEC3778 ) { hw->wMotorDpi = 600; hw->dMaxMotorSpeed = 1.1; hw->dMaxMoveSpeed = 0.9; sCaps->OpticDpi.y = 1200; } regs[0x5b] &= ~0x80; } /* To stop the motor moving */ usbio_WriteReg( dev->fd, 0x07, 0 ); usleep(10 * 1000); usbio_WriteReg( dev->fd, 0x5b, regs[0x5b] ); return SANE_TRUE; } /** function to adjust the lamp settings of a CIS device without tweaking * the driver-device settings * @param dev - our almitghty device structure * @param on - switch the lamp on or off */ static SANE_Bool usb_AdjustLamps( Plustek_Device *dev, SANE_Bool on ) { HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; if( !usb_IsCISDevice(dev)) return SANE_TRUE; DBG(_DBG_INFO2, "usb_AdjustLamps(%u)\n", on ); if( on ) { regs[0x2c] = _HIBYTE(hw->red_lamp_on); regs[0x2d] = _LOBYTE(hw->red_lamp_on); regs[0x2e] = _HIBYTE(hw->red_lamp_off); regs[0x2f] = _LOBYTE(hw->red_lamp_off); regs[0x30] = _HIBYTE(hw->green_lamp_on); regs[0x31] = _LOBYTE(hw->green_lamp_on); regs[0x32] = _HIBYTE(hw->green_lamp_off); regs[0x33] = _LOBYTE(hw->green_lamp_off); regs[0x34] = _HIBYTE(hw->blue_lamp_on); regs[0x35] = _LOBYTE(hw->blue_lamp_on); regs[0x36] = _HIBYTE(hw->blue_lamp_off); regs[0x37] = _LOBYTE(hw->blue_lamp_off); } else { memset( ®s[0x2c], 0, 12 ); regs[0x2c] = 0x3f; regs[0x2d] = 0xff; regs[0x30] = 0x3f; regs[0x31] = 0xff; regs[0x34] = 0x3f; regs[0x35] = 0xff; } return sanei_lm983x_write( dev->fd, 0x2c, ®s[0x2c], 0x37-0x2c+1, SANE_TRUE ); } /** */ static void usb_AdjustCISLampSettings( Plustek_Device *dev, SANE_Bool on ) { HWDef *hw = &dev->usbDev.HwSetting; if( !usb_IsCISDevice(dev)) return; DBG( _DBG_INFO2, "AdjustCISLamps(%u)\n", on ); if((dev->scanning.sParam.bDataType == SCANDATATYPE_Gray) || (dev->scanning.sParam.bDataType == SCANDATATYPE_BW)) { DBG( _DBG_INFO2, " * setting mono mode\n" ); hw->bReg_0x29 = hw->illu_mono.mode; memcpy( &hw->red_lamp_on, &hw->illu_mono.red_lamp_on, sizeof(u_short) * 6 ); } else { DBG( _DBG_INFO2, " * setting color mode\n" ); hw->bReg_0x29 = hw->illu_color.mode; memcpy( &hw->red_lamp_on, &hw->illu_color.red_lamp_on, sizeof(u_short) * 6 ); } if( !on ) { hw->red_lamp_on = 0x3fff; hw->red_lamp_off = 0; hw->green_lamp_on = 0x3fff; hw->green_lamp_off = 0; hw->blue_lamp_on = 0x3fff; hw->blue_lamp_off = 0; } else { if( dev->adj.rlampoff > 0 ) { hw->red_lamp_off = dev->adj.rlampoff; if( hw->red_lamp_off > 0x3fff ) hw->red_lamp_off = 0x3fff; DBG( _DBG_INFO2, " * red_lamp_off adjusted: %u\n", hw->red_lamp_off ); } if( dev->adj.glampoff > 0 ) { hw->green_lamp_off = dev->adj.glampoff; if( hw->green_lamp_off > 0x3fff ) hw->green_lamp_off = 0x3fff; DBG( _DBG_INFO2, " * green_lamp_off adjusted: %u\n", hw->green_lamp_off ); } if( dev->adj.blampoff > 0 ) { hw->blue_lamp_off = dev->adj.blampoff; if( hw->blue_lamp_off > 0x3fff ) hw->blue_lamp_off = 0x3fff; DBG( _DBG_INFO2, " * blue_lamp_off adjusted: %u\n", hw->blue_lamp_off ); } } dev->usbDev.a_bRegs[0x29] = hw->bReg_0x29; usb_AdjustLamps( dev, on ); } /** according to the flag field, we return the register and * it's mask to turn on/off the lamp. * @param flag - field to check * @param reg - pointer to a var to receive the register value * @param msk - pointer to a var to receive the mask value * @return Nothing */ static void usb_GetLampRegAndMask( u_long flag, SANE_Byte *reg, SANE_Byte *msk ) { if( _MIO6 == ( _MIO6 & flag )) { *reg = 0x5b; *msk = 0x80; } else if( _MIO5 == ( _MIO5 & flag )) { *reg = 0x5b; *msk = 0x08; } else if( _MIO4 == ( _MIO4 & flag )) { *reg = 0x5a; *msk = 0x80; } else if( _MIO3 == ( _MIO3 & flag )) { *reg = 0x5a; *msk = 0x08; } else if( _MIO2 == ( _MIO2 & flag )) { *reg = 0x59; *msk = 0x80; } else if( _MIO1 == ( _MIO1 & flag )) { *reg = 0x59; *msk = 0x08; } else { *reg = 0; *msk = 0; } } /** usb_GetLampStatus * This function returns the current lamp in use. * For non Plustek devices, it always returns DEV_LampReflection. * @param dev - pointer to our device structure, * it should contain all we need * @return - 0 if the scanner hasn't been used before, DEV_LampReflection * for the normal lamp, or DEV_LampTPA for negative/transparency * lamp */ static int usb_GetLampStatus( Plustek_Device *dev ) { int iLampStatus = 0; u_char *regs = dev->usbDev.a_bRegs; HWDef *hw = &dev->usbDev.HwSetting; DCapsDef *sc = &dev->usbDev.Caps; SANE_Byte reg, msk, val; if( NULL == hw ) { DBG( _DBG_ERROR, "NULL-Pointer detected: usb_GetLampStatus()\n" ); return -1; } /* do we use the misc I/O pins for switching the lamp ? */ if( _WAF_MISC_IO_LAMPS & sc->workaroundFlag ) { usb_GetLampRegAndMask( sc->misc_io, ®, &msk ); if( 0 == reg ) { usbio_ReadReg( dev->fd, 0x29, ® ); if( reg & 3 ) iLampStatus |= DEV_LampReflection; } else { /* check if the lamp is on */ usbio_ReadReg( dev->fd, reg, &val ); DBG( _DBG_INFO2, "LAMP-REG[0x%02x] = 0x%02x (msk=0x%02x)\n", reg,val,msk); if( val & msk ) iLampStatus |= DEV_LampReflection; /* if the device supports a TPA, we check this here */ if( sc->wFlags & DEVCAPSFLAG_TPA ) { usb_GetLampRegAndMask( _GET_TPALAMP(sc->misc_io), ®, &msk ); if (reg) { usbio_ReadReg( dev->fd, reg, &val ); DBG( _DBG_INFO2, "TPA-REG[0x%02x] = 0x%02x (msk=0x%02x)\n", reg,val,msk); if( val & msk ) iLampStatus |= DEV_LampTPA; } } /* CanoScan D660U extra vaganza... */ if((dev->usbDev.vendor == 0x04A9) && (dev->usbDev.product==0x2208)) { sanei_lm983x_read( dev->fd, 0x29, ®s[0x29], 3, SANE_TRUE ); DBG( _DBG_INFO, "[29]=0x%02x, [2A]=0x%02x, [2B]=0x%02x\n", regs[0x29], regs[0x2a], regs[0x2b] ); } } } else { sanei_lm983x_read(dev->fd, 0x29,®s[0x29],0x37-0x29+1,SANE_TRUE); if((regs[0x29] & 3) == 1) { /* HEINER: BETTER define register to check ! */ if(!_IS_PLUSTEKMOTOR(hw->motorModel)) { iLampStatus |= DEV_LampReflection; } else { if((regs[0x2e] * 256 + regs[0x2f]) > hw->wLineEnd ) iLampStatus |= DEV_LampReflection; if((regs[0x36] * 256 + regs[0x37]) > hw->wLineEnd ) iLampStatus |= DEV_LampTPA; } } } DBG( _DBG_INFO, "LAMP-STATUS: 0x%08x (%s)\n", iLampStatus, iLampStatus?"on":"off" ); return iLampStatus; } /** usb_switchLampX * used for all devices that use some misc I/O pins to switch the lamp */ static SANE_Bool usb_switchLampX( Plustek_Device *dev, SANE_Bool on, SANE_Bool tpa ) { SANE_Byte reg, msk; DCapsDef *sc = &dev->usbDev.Caps; u_char *regs = dev->usbDev.a_bRegs; if( tpa ) usb_GetLampRegAndMask( _GET_TPALAMP(sc->misc_io), ®, &msk ); else usb_GetLampRegAndMask( sc->misc_io, ®, &msk ); if( 0 == reg ) return SANE_FALSE; /* no need to switch something */ DBG( _DBG_INFO, "usb_switchLampX(ON=%u,TPA=%u)\n", on, tpa ); if( on ) { /* in fact the output bit should be set by the default settings * but we make sure, that it is set anyway... */ if (msk & 0x08) msk |= 0x01; else msk |= 0x10; regs[reg] |= msk; } else { regs[reg] &= ~msk; } DBG( _DBG_INFO, "Switch Lamp: %u, regs[0x%02x] = 0x%02x\n", on, reg, regs[reg] ); usbio_WriteReg( dev->fd, reg, regs[reg] ); return SANE_TRUE; } /** usb_switchLamp * used for all devices that use some misc I/O pins to switch the lamp */ static SANE_Bool usb_switchLamp( Plustek_Device *dev, SANE_Bool on ) { SANE_Bool result; if((dev->scanning.sParam.bSource == SOURCE_Negative) || (dev->scanning.sParam.bSource == SOURCE_Transparency)) { result = usb_switchLampX( dev, on, SANE_TRUE ); } else { result = usb_switchLampX( dev, on, SANE_FALSE ); } /* to switch off CIS, we need to tweak the lampoff/on regs */ usb_AdjustLamps( dev, on ); return result; } /** usb_LedOn */ static void usb_LedOn( Plustek_Device *dev, SANE_Bool fOn ) { u_char value; if( dev->usbDev.HwSetting.motorModel != MODEL_HuaLien ) return; value = dev->usbDev.a_bRegs[0x0d]; if( fOn ) value |= 0x10; else value &= ~0x10; dev->usbDev.a_bRegs[0x0d] = value; usbio_WriteReg( dev->fd, 0x0d, value ); } /** usb_FillLampRegs * set all the registers controlling the lamps */ static void usb_FillLampRegs( Plustek_Device *dev ) { HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; regs[0x2a] = _HIBYTE( hw->wGreenPWMDutyCycleLow ); regs[0x2b] = _LOBYTE( hw->wGreenPWMDutyCycleLow ); regs[0x2c] = _HIBYTE( hw->red_lamp_on ); regs[0x2d] = _LOBYTE( hw->red_lamp_on ); regs[0x2e] = _HIBYTE( hw->red_lamp_off); regs[0x2f] = _LOBYTE( hw->red_lamp_off); regs[0x30] = _HIBYTE( hw->green_lamp_on ); regs[0x31] = _LOBYTE( hw->green_lamp_on ); regs[0x32] = _HIBYTE( hw->green_lamp_off); regs[0x33] = _LOBYTE( hw->green_lamp_off); regs[0x34] = _HIBYTE( hw->blue_lamp_on ); regs[0x35] = _LOBYTE( hw->blue_lamp_on ); regs[0x36] = _HIBYTE( hw->blue_lamp_off); regs[0x37] = _LOBYTE( hw->blue_lamp_off); } /** usb_LampOn */ static SANE_Bool usb_LampOn( Plustek_Device *dev, SANE_Bool fOn, SANE_Bool fResetTimer ) { DCapsDef *sc = &dev->usbDev.Caps; ScanDef *scanning = &dev->scanning; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; int iLampStatus = usb_GetLampStatus( dev ); int lampId = -1; struct timeval t; if( NULL == scanning ) { DBG( _DBG_ERROR, "NULL-Pointer detected: usb_LampOn()\n" ); return SANE_FALSE; } switch( scanning->sParam.bSource ) { case SOURCE_Reflection: case SOURCE_ADF: lampId = DEV_LampReflection; break; case SOURCE_Transparency: case SOURCE_Negative: lampId = DEV_LampTPA; break; } if( fOn ) { if( iLampStatus != lampId ) { DBG( _DBG_INFO, "Switching Lamp on\n" ); /* here we might have to switch off the TPA/Main lamp before * using the other one */ if( lampId != dev->usbDev.currentLamp ) { if( dev->usbDev.currentLamp == DEV_LampReflection ) usb_switchLampX( dev, SANE_FALSE, SANE_FALSE ); else usb_switchLampX( dev, SANE_FALSE, SANE_TRUE ); } memset( ®s[0x29], 0, (0x37-0x29+1)); regs[0x29] = hw->bReg_0x29; if( !usb_switchLamp(dev, SANE_TRUE )) { if( lampId == DEV_LampReflection ) { regs[0x2e] = 16383 / 256; regs[0x2f] = 16383 % 256; } if( lampId == DEV_LampTPA ) { regs[0x36] = 16383 / 256; regs[0x37] = 16383 % 256; } } if( _WAF_MISC_IO_LAMPS & sc->workaroundFlag ) usb_FillLampRegs( dev ); sanei_lm983x_write( dev->fd, 0x29, ®s[0x29], 0x37-0x29+1, SANE_TRUE ); if( lampId != dev->usbDev.currentLamp ) { dev->usbDev.currentLamp = lampId; if( fResetTimer ) { gettimeofday( &t, NULL ); dev->usbDev.dwTicksLampOn = t.tv_sec; DBG( _DBG_INFO, "Warmup-Timer started\n" ); } } } } else { int iStatusChange = iLampStatus & ~lampId; if( iStatusChange != iLampStatus ) { DBG( _DBG_INFO, "Switching Lamp off\n" ); memset( ®s[0x29], 0, 0x37-0x29+1 ); if( !usb_switchLamp(dev, SANE_FALSE )) { if( iStatusChange & DEV_LampReflection ) { regs[0x2e] = 16383 / 256; regs[0x2f] = 16383 % 256; } if( iStatusChange & DEV_LampTPA ) { regs[0x36] = 16383 / 256; regs[0x37] = 16383 % 256; } } if( _WAF_MISC_IO_LAMPS & sc->workaroundFlag ) usb_FillLampRegs( dev ); sanei_lm983x_write( dev->fd, 0x29, ®s[0x29], 0x37-0x29+1, SANE_TRUE ); } } if( usb_GetLampStatus(dev)) usb_LedOn( dev, SANE_TRUE ); else usb_LedOn( dev, SANE_FALSE ); return SANE_TRUE; } /** Function to preset the registers for the specific device, which * should never change during the whole operation * Affected registers:
* 0x0b - 0x0e - Sensor settings - directly from the HWDef
* 0x0f - 0x18 - Sensor Configuration - directly from the HwDef
* 0x1a - 0x1b - Stepper Phase Correction
* 0x20 - 0x21 - Line End
* 0x21 - 0x22 - Data Pixel start
* 0x23 - 0x24 - Data Pixel end
* 0x45 - Stepper Motor Mode
* 0x4c - 0x4d - Full Steps to Scan after PAPER SENSE 2 trips
* 0x50 - Steps to reverse when buffer is full
* 0x51 - Acceleration Profile
* 0x54 - 0x5e - Motor Settings, Paper-Sense Settings and Misc I/O
* * @param dev - pointer to our device structure, * it should contain all we need * @return - Nothing */ static void usb_ResetRegisters( Plustek_Device *dev ) { int linend; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; DBG( _DBG_INFO, "RESETTING REGISTERS(%i) - 0x%02x\n", dev->initialized, (int) sizeof(dev->usbDev.a_bRegs)); memset( regs, 0, sizeof(dev->usbDev.a_bRegs)); memcpy( regs+0x0b, &hw->bSensorConfiguration, 4 ); memcpy( regs+0x0f, &hw->bReg_0x0f_Color, 10 ); regs[0x1a] = _HIBYTE( hw->StepperPhaseCorrection ); regs[0x1b] = _LOBYTE( hw->StepperPhaseCorrection ); /* HEINER: CHECK WHY THIS has been disabled*/ #if 0 regs[0x1c] = hw->bOpticBlackStart; regs[0x1d] = hw->bOpticBlackEnd; regs[0x1e] = _HIBYTE( hw->wActivePixelsStart ); regs[0x1f] = _LOBYTE( hw->wActivePixelsStart ); #endif regs[0x20] = _HIBYTE( hw->wLineEnd ); regs[0x21] = _LOBYTE( hw->wLineEnd ); regs[0x22] = _HIBYTE( hw->bOpticBlackStart ); regs[0x23] = _LOBYTE( hw->bOpticBlackStart ); linend = hw->bOpticBlackStart + hw->wLineEnd; if( linend < (hw->wLineEnd-20)) linend = hw->wLineEnd-20; regs[0x24] = _HIBYTE( linend ); regs[0x25] = _LOBYTE( linend ); regs[0x2a] = _HIBYTE( hw->wGreenPWMDutyCycleHigh ); regs[0x2b] = _LOBYTE( hw->wGreenPWMDutyCycleHigh ); regs[0x45] = hw->bReg_0x45; regs[0x4c] = _HIBYTE( hw->wStepsAfterPaperSensor2 ); regs[0x4d] = _LOBYTE( hw->wStepsAfterPaperSensor2 ); regs[0x50] = hw->bStepsToReverse; regs[0x51] = hw->bReg_0x51; /* if already initialized, we ignore the MISC I/O settings as * they are used to determine the current lamp settings... */ if( dev->initialized >= 0 ) { DBG( _DBG_INFO2, "USING MISC I/O settings\n" ); memcpy( regs+0x54, &hw->bReg_0x54, 0x58 - 0x54 + 1 ); regs[0x5c] = hw->bReg_0x5c; regs[0x5d] = hw->bReg_0x5d; regs[0x5e] = hw->bReg_0x5e; sanei_lm983x_read( dev->fd, 0x59, ®s[0x59], 3, SANE_TRUE ); } else { DBG( _DBG_INFO2, "SETTING THE MISC I/Os\n" ); memcpy( regs+0x54, &hw->bReg_0x54, 0x5e - 0x54 + 1 ); if( usb_IsCISDevice( dev )) { /* this sequence seems to be needed at least for the * CanoScan devices to work properly after power-up */ sanei_lm983x_write_byte( dev->fd, 0x5b, regs[0x5b] ); sanei_lm983x_write_byte( dev->fd, 0x59, regs[0x59] ); sanei_lm983x_write_byte( dev->fd, 0x5a, regs[0x5a] ); } else { sanei_lm983x_write( dev->fd, 0x59, ®s[0x59], 3, SANE_TRUE ); } } DBG( _DBG_INFO, "MISC I/O after RESET: 0x%02x, 0x%02x, 0x%02x\n", regs[0x59], regs[0x5a], regs[0x5b] ); } /** function which checks if we are already in home position or not. * */ static SANE_Bool usb_SensorStatus( Plustek_Device *dev ) { u_char value; HWDef *hw = &dev->usbDev.HwSetting; /* HEINER: Maybe needed to avoid recalibration!!! */ #if 0 if( dev->scanning.fCalibrated ) return SANE_TRUE; #endif /* read the status register */ _UIO( usbio_ReadReg( dev->fd, 2, &value )); if( value & 1 ) { _UIO( usbio_ReadReg( dev->fd, 0x7, &value)); if( value ) { usbio_WriteReg( dev->fd, 0x07, 0 ); usbio_WriteReg( dev->fd, 0x07, 0x20 ); usbio_WriteReg( dev->fd, 0x07, 0 ); sanei_lm983x_write( dev->fd, 0x58, &hw->bReg_0x58, 0x5b-0x58+1, SANE_TRUE ); usbio_ReadReg( dev->fd, 2, &value ); usbio_ReadReg( dev->fd, 2, &value ); } usb_MotorOn( dev, SANE_FALSE ); return SANE_TRUE; } _UIO( usbio_ReadReg( dev->fd, 0x7, &value )); if( !(value & 2)) { usb_ModuleToHome( dev, SANE_FALSE ); } return SANE_FALSE; } /** */ static void usb_LampSwitch( Plustek_Device *dev, SANE_Bool sw ) { int handle = -1; if( -1 == dev->fd ) { if( SANE_STATUS_GOOD == sanei_usb_open(dev->sane.name, &handle)) { dev->fd = handle; } } /* needs to be recalibrated */ dev->scanning.fCalibrated = SANE_FALSE; if( -1 != dev->fd ) usb_LampOn( dev, sw, SANE_FALSE ); if( -1 != handle ) { dev->fd = -1; sanei_usb_close( handle ); } } /* HEINER: replace!!! */ static Plustek_Device *dev_xxx = NULL; /** ISR to switch lamp off after time has elapsed */ static void usb_LampTimerIrq( int sig ) { if( NULL == dev_xxx ) return; _VAR_NOT_USED( sig ); DBG( _DBG_INFO, "LAMP OFF!!!\n" ); usb_LampSwitch( dev_xxx, SANE_FALSE ); } /** usb_StartLampTimer */ static void usb_StartLampTimer( Plustek_Device *dev ) { sigset_t block, pause_mask; struct sigaction s; #ifdef HAVE_SETITIMER struct itimerval interval; #endif /* block SIGALRM */ sigemptyset( &block ); sigaddset ( &block, SIGALRM ); sigprocmask( SIG_BLOCK, &block, &pause_mask ); /* setup handler */ sigemptyset( &s.sa_mask ); sigaddset ( &s.sa_mask, SIGALRM ); s.sa_flags = 0; s.sa_handler = usb_LampTimerIrq; if( sigaction( SIGALRM, &s, NULL ) < 0 ) DBG( _DBG_ERROR, "Can't setup timer-irq handler\n" ); sigprocmask( SIG_UNBLOCK, &block, &pause_mask ); #ifdef HAVE_SETITIMER /* define a one-shot timer */ interval.it_value.tv_usec = 0; interval.it_value.tv_sec = dev->usbDev.dwLampOnPeriod; interval.it_interval.tv_usec = 0; interval.it_interval.tv_sec = 0; if( 0 != dev->usbDev.dwLampOnPeriod ) { dev_xxx = dev; setitimer( ITIMER_REAL, &interval, &dev->saveSettings ); DBG( _DBG_INFO, "Lamp-Timer started (using ITIMER)\n" ); } #else if( 0 != dev->usbDev.dwLampOnPeriod ) { dev_xxx = dev; alarm( dev->usbDev.dwLampOnPeriod ); DBG( _DBG_INFO, "Lamp-Timer started (using ALARM)\n" ); } #endif } /** usb_StopLampTimer */ static void usb_StopLampTimer( Plustek_Device *dev ) { sigset_t block, pause_mask; /* block SIGALRM */ sigemptyset( &block ); sigaddset ( &block, SIGALRM ); sigprocmask( SIG_BLOCK, &block, &pause_mask ); dev_xxx = NULL; #ifdef HAVE_SETITIMER if( 0 != dev->usbDev.dwLampOnPeriod ) setitimer( ITIMER_REAL, &dev->saveSettings, NULL ); #else _VAR_NOT_USED( dev ); alarm( 0 ); #endif DBG( _DBG_INFO, "Lamp-Timer stopped\n" ); } /** wait until warmup has been done */ static SANE_Bool usb_Wait4Warmup( Plustek_Device *dev ) { u_long dw; struct timeval t; if( usb_IsCISDevice(dev)) { DBG(_DBG_INFO,"Warmup: skipped for CIS devices\n" ); return SANE_TRUE; } if( dev->adj.warmup < 0 ) return SANE_TRUE; /* * wait until warmup period has been elapsed */ gettimeofday( &t, NULL); dw = t.tv_sec - dev->usbDev.dwTicksLampOn; if( dw < (u_long)dev->adj.warmup ) DBG(_DBG_INFO,"Warmup: Waiting %d seconds\n", dev->adj.warmup ); do { gettimeofday( &t, NULL); dw = t.tv_sec - dev->usbDev.dwTicksLampOn; if( usb_IsEscPressed()) { return SANE_FALSE; } } while( dw < (u_long)dev->adj.warmup ); return SANE_TRUE; } /** function for TPA autodection (EPSON & UMAX devices) */ static SANE_Bool usb_HasTPA( Plustek_Device *dev ) { static char model[] = { "3450" }; u_char val; if( dev->usbDev.vendor == 0x04B8 ) { /* the EPSON section */ usb_switchLampX( dev, SANE_FALSE, SANE_TRUE ); usbio_WriteReg ( dev->fd, 0x58, 0x1d ); usbio_WriteReg ( dev->fd, 0x59, 0x49 ); usbio_ReadReg ( dev->fd, 0x02, &val ); usbio_WriteReg ( dev->fd, 0x58, dev->usbDev.HwSetting.bReg_0x58 ); usbio_WriteReg ( dev->fd, 0x59, dev->usbDev.HwSetting.bReg_0x59 ); DBG( _DBG_INFO, "REG[0x02] = 0x%02x\n", val ); if( val & 0x02 ) { DBG( _DBG_INFO, "EPSON-TPA detected\n" ); return SANE_TRUE; } else DBG( _DBG_INFO, "EPSON-TPA NOT detected\n" ); if( dev->adj.enableTpa ) { DBG( _DBG_INFO, "EPSON-TPA usage forced\n" ); return SANE_TRUE; } } else if( dev->usbDev.vendor == 0x1606 ) { /* the UMAX section */ if((dev->usbDev.product == 0x0050) || (dev->usbDev.product == 0x0060)) { usbio_ReadReg ( dev->fd, 0x02, &val ); DBG( _DBG_INFO, "REG[0x02] = 0x%02x\n", val ); usbio_WriteReg ( dev->fd, 0x58, dev->usbDev.HwSetting.bReg_0x58 ); usbio_WriteReg ( dev->fd, 0x5a, dev->usbDev.HwSetting.bReg_0x5a ); usbio_WriteReg ( dev->fd, 0x5b, dev->usbDev.HwSetting.bReg_0x5b ); usbio_ReadReg ( dev->fd, 0x02, &val ); DBG( _DBG_INFO, "REG[0x02] = 0x%02x\n", val ); if( val & 0x02 ) { DBG( _DBG_INFO, "UMAX-TPA detected\n" ); dev->usbDev.ModelStr = model; return SANE_TRUE; } else DBG( _DBG_INFO, "UMAX-TPA NOT detected\n" ); if( dev->adj.enableTpa ) { DBG( _DBG_INFO, "UMAX-TPA usage forced\n" ); dev->usbDev.ModelStr = model; return SANE_TRUE; } } } return SANE_FALSE; } /** function for reading the button states */ static SANE_Bool usb_UpdateButtonStatus( Plustek_Scanner *s ) { u_char mio[3]; SANE_Byte val, mask; int i, j, bc; int handle = -1; SANE_Status status; Plustek_Device *dev = s->hw; DCapsDef *caps = &dev->usbDev.Caps; if (caps->bButtons == 0) return SANE_FALSE; status = sanei_access_lock( dev->sane.name, 3 ); if( SANE_STATUS_GOOD != status ) return SANE_FALSE; if( -1 == dev->fd ) { status = sanei_usb_open(dev->sane.name, &handle); if( SANE_STATUS_GOOD != status ) { sanei_access_unlock( dev->sane.name ); return SANE_FALSE; } dev->fd = handle; } /* we have to check all 6 misc I/O ports for input configuration*/ mio[0] = dev->usbDev.HwSetting.bReg_0x59; mio[1] = dev->usbDev.HwSetting.bReg_0x5a; mio[2] = dev->usbDev.HwSetting.bReg_0x5b; usbio_ReadReg( dev->fd, 0x07, &val ); if( val == 0 ) { /* first read clears the status... */ usbio_ReadReg( dev->fd, 0x02, &val ); /* Plustek and KYE/Genius use altnernative button handling */ if((dev->usbDev.vendor == 0x07B3) || (dev->usbDev.vendor == 0x0458)) { DBG( _DBG_INFO2, "Button Value=0x%02x\n", val ); /* no button pressed so far */ for( i = 0; i < caps->bButtons; i++ ) s->val[OPT_BUTTON_0 + i].w = 0; if (caps->bButtons == 2 || caps->bButtons == 5) { val >>= 2; val &= 0x07; DBG( _DBG_INFO2, "Button Value=0x%02x (2/5)\n", val ); switch( val ) { case 1: s->val[OPT_BUTTON_1].w = 1; break; case 2: s->val[OPT_BUTTON_0].w = 1; break; case 3: s->val[OPT_BUTTON_2].w = 1; break; case 4: s->val[OPT_BUTTON_3].w = 1; break; case 6: s->val[OPT_BUTTON_4].w = 1; break; } } else if (caps->bButtons == 4 ) { val >>= 5; val &= 0x07; DBG( _DBG_INFO2, "Button Value=0x%02x (4)\n", val ); switch( val ) { case 1: s->val[OPT_BUTTON_0].w = 1; break; case 2: s->val[OPT_BUTTON_1].w = 1; break; case 4: s->val[OPT_BUTTON_2].w = 1; break; case 6: s->val[OPT_BUTTON_3].w = 1; break; } } else { DBG( _DBG_INFO2, "Hmm, could not handle this!\n" ); } } else { /* the generic section... */ val >>= 2; bc = 0; /* only use the "valid" ports, that reflect a button */ if( _WAF_MISC_IO_BUTTONS & caps->workaroundFlag ) { if((caps->misc_io & _PORT0) == 0) mio[0] = 0xff; if((caps->misc_io & _PORT1) == 0) mio[1] = 0xff; if((caps->misc_io & _PORT2) == 0) mio[2] = 0xff; } for( i = 0; i < 3; i++ ) { DBG( _DBG_INFO2, "Checking MISC IO[%u]=0x%02x\n", i, mio[i] ); mask = 0x01; for( j = 0; j < 2; j++ ) { if((mio[i] & mask) == 0) { DBG( _DBG_INFO2, "* port %u configured as input," " status: %s (%u)\n", (i*2)+j+1, ((val & 1)?"PRESSED":"RELEASED"), (OPT_BUTTON_0 + bc)); s->val[OPT_BUTTON_0 + bc].w = val & 1; bc++; } val >>= 1; mask <<= 4; } } } } else { DBG( _DBG_INFO2, "Scanner NOT idle: 0x%02x\n", val ); } if( -1 != handle ) { dev->fd = -1; sanei_usb_close( handle ); } sanei_access_unlock( dev->sane.name ); return SANE_TRUE; } /* END PLUSTEK-USBHW.C ......................................................*/ sane-backends-1.0.29/backend/genesys/0000755000000000000000000000000013615535551014325 500000000000000sane-backends-1.0.29/backend/genesys/gl843.cpp0000666000000000000000000031712613615534521015624 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2010-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "gl843_registers.h" #include "gl843.h" #include "test_settings.h" #include #include namespace genesys { namespace gl843 { // Set address for writing data static void gl843_set_buffer_address(Genesys_Device* dev, uint32_t addr) { DBG_HELPER_ARGS(dbg, "setting address to 0x%05x", addr & 0xffff); dev->interface->write_register(0x5b, ((addr >> 8) & 0xff)); dev->interface->write_register(0x5c, (addr & 0xff)); } /** * compute the step multiplier used */ static int gl843_get_step_multiplier(Genesys_Register_Set* regs) { GenesysRegister *r = sanei_genesys_get_address(regs, REG_0x9D); int value = 1; if (r != nullptr) { switch (r->value & 0x0c) { case 0x04: value = 2; break; case 0x08: value = 4; break; default: value = 1; } } DBG(DBG_io, "%s: step multiplier is %d\n", __func__, value); return value; } /** copy sensor specific settings */ static void gl843_setup_sensor(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs) { DBG_HELPER(dbg); for (const auto& custom_reg : sensor.custom_regs) { regs->set8(custom_reg.address, custom_reg.value); } if (!(dev->model->flags & GENESYS_FLAG_FULL_HWDPI_MODE) && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7200I && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7300 && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7500I) { regs->set8(0x7d, 0x90); } dev->segment_order = sensor.segment_order; } /** @brief set all registers to default values . * This function is called only once at the beginning and * fills register startup values for registers reused across scans. * Those that are rarely modified or not modified are written * individually. * @param dev device structure holding register set to initialize */ static void gl843_init_registers (Genesys_Device * dev) { // Within this function SENSOR_DEF marker documents that a register is part // of the sensors definition and the actual value is set in // gl843_setup_sensor(). // 0x6c, 0x6d, 0x6e, 0x6f, 0xa6, 0xa7, 0xa8, 0xa9 are defined in the Gpo sensor struct DBG_HELPER(dbg); dev->reg.clear(); dev->reg.init_reg(0x01, 0x00); dev->reg.init_reg(0x02, 0x78); dev->reg.init_reg(0x03, 0x1f); if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x03, 0x1d); } if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x03, 0x1c); } dev->reg.init_reg(0x04, 0x10); if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x04, 0x22); } // fine tune upon device description dev->reg.init_reg(0x05, 0x80); if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x05, 0x08); } const auto& sensor = sanei_genesys_find_sensor_any(dev); sanei_genesys_set_dpihw(dev->reg, sensor, sensor.optical_res); // TODO: on 8600F the windows driver turns off GAIN4 which is recommended dev->reg.init_reg(0x06, 0xd8); /* SCANMOD=110, PWRBIT and GAIN4 */ if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x06, 0xd8); /* SCANMOD=110, PWRBIT and GAIN4 */ } if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I) { dev->reg.init_reg(0x06, 0xd0); } if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x06, 0xf0); /* SCANMOD=111, PWRBIT and no GAIN4 */ } dev->reg.init_reg(0x08, 0x00); dev->reg.init_reg(0x09, 0x00); dev->reg.init_reg(0x0a, 0x00); if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x0a, 0x18); } if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x0a, 0x10); } // This register controls clock and RAM settings and is further modified in // gl843_boot dev->reg.init_reg(0x0b, 0x6a); if (dev->model->model_id == ModelId::CANON_4400F) { dev->reg.init_reg(0x0b, 0x69); // 16M only } if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x0b, 0x89); } if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I) { dev->reg.init_reg(0x0b, 0x2a); } if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x0b, 0x4a); } if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x0b, 0x69); } if (dev->model->model_id != ModelId::CANON_8400F && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7200I && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7300) { dev->reg.init_reg(0x0c, 0x00); } // EXPR[0:15], EXPG[0:15], EXPB[0:15]: Exposure time settings. dev->reg.init_reg(0x10, 0x00); // SENSOR_DEF dev->reg.init_reg(0x11, 0x00); // SENSOR_DEF dev->reg.init_reg(0x12, 0x00); // SENSOR_DEF dev->reg.init_reg(0x13, 0x00); // SENSOR_DEF dev->reg.init_reg(0x14, 0x00); // SENSOR_DEF dev->reg.init_reg(0x15, 0x00); // SENSOR_DEF if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8600F) { dev->reg.set16(REG_EXPR, 0x9c40); dev->reg.set16(REG_EXPG, 0x9c40); dev->reg.set16(REG_EXPB, 0x9c40); } if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.set16(REG_EXPR, 0x2c09); dev->reg.set16(REG_EXPG, 0x22b8); dev->reg.set16(REG_EXPB, 0x10f0); } // CCD signal settings. dev->reg.init_reg(0x16, 0x33); // SENSOR_DEF dev->reg.init_reg(0x17, 0x1c); // SENSOR_DEF dev->reg.init_reg(0x18, 0x10); // SENSOR_DEF // EXPDMY[0:7]: Exposure time of dummy lines. dev->reg.init_reg(0x19, 0x2a); // SENSOR_DEF // Various CCD clock settings. dev->reg.init_reg(0x1a, 0x04); // SENSOR_DEF dev->reg.init_reg(0x1b, 0x00); // SENSOR_DEF dev->reg.init_reg(0x1c, 0x20); // SENSOR_DEF dev->reg.init_reg(0x1d, 0x04); // SENSOR_DEF dev->reg.init_reg(0x1e, 0x10); if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x1e, 0x20); } if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x1e, 0xa0); } dev->reg.init_reg(0x1f, 0x01); if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x1f, 0xff); } dev->reg.init_reg(0x20, 0x10); dev->reg.init_reg(0x21, 0x04); dev->reg.init_reg(0x22, 0x10); dev->reg.init_reg(0x23, 0x10); if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x22, 0xc8); dev->reg.init_reg(0x23, 0xc8); } if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x22, 0x50); dev->reg.init_reg(0x23, 0x50); } dev->reg.init_reg(0x24, 0x04); dev->reg.init_reg(0x25, 0x00); dev->reg.init_reg(0x26, 0x00); dev->reg.init_reg(0x27, 0x00); dev->reg.init_reg(0x2c, 0x02); dev->reg.init_reg(0x2d, 0x58); // BWHI[0:7]: high level of black and white threshold dev->reg.init_reg(0x2e, 0x80); // BWLOW[0:7]: low level of black and white threshold dev->reg.init_reg(0x2f, 0x80); dev->reg.init_reg(0x30, 0x00); dev->reg.init_reg(0x31, 0x14); dev->reg.init_reg(0x32, 0x27); dev->reg.init_reg(0x33, 0xec); // DUMMY: CCD dummy and optically black pixel count dev->reg.init_reg(0x34, 0x24); if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x34, 0x14); } if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x34, 0x3c); } // MAXWD: If available buffer size is less than 2*MAXWD words, then // "buffer full" state will be set. dev->reg.init_reg(0x35, 0x00); dev->reg.init_reg(0x36, 0xff); dev->reg.init_reg(0x37, 0xff); // LPERIOD: Line period or exposure time for CCD or CIS. dev->reg.init_reg(0x38, 0x55); // SENSOR_DEF dev->reg.init_reg(0x39, 0xf0); // SENSOR_DEF // FEEDL[0:24]: The number of steps of motor movement. dev->reg.init_reg(0x3d, 0x00); dev->reg.init_reg(0x3e, 0x00); dev->reg.init_reg(0x3f, 0x01); // Latch points for high and low bytes of R, G and B channels of AFE. If // multiple clocks per pixel are consumed, then the setting defines during // which clock the corresponding value will be read. // RHI[0:4]: The latch point for high byte of R channel. // RLOW[0:4]: The latch point for low byte of R channel. // GHI[0:4]: The latch point for high byte of G channel. // GLOW[0:4]: The latch point for low byte of G channel. // BHI[0:4]: The latch point for high byte of B channel. // BLOW[0:4]: The latch point for low byte of B channel. dev->reg.init_reg(0x52, 0x01); // SENSOR_DEF dev->reg.init_reg(0x53, 0x04); // SENSOR_DEF dev->reg.init_reg(0x54, 0x07); // SENSOR_DEF dev->reg.init_reg(0x55, 0x0a); // SENSOR_DEF dev->reg.init_reg(0x56, 0x0d); // SENSOR_DEF dev->reg.init_reg(0x57, 0x10); // SENSOR_DEF // VSMP[0:4]: The position of the image sampling pulse for AFE in cycles. // VSMPW[0:2]: The length of the image sampling pulse for AFE in cycles. dev->reg.init_reg(0x58, 0x1b); // SENSOR_DEF dev->reg.init_reg(0x59, 0x00); // SENSOR_DEF dev->reg.init_reg(0x5a, 0x40); // SENSOR_DEF // 0x5b-0x5c: GMMADDR[0:15] address for gamma or motor tables download // SENSOR_DEF // DECSEL[0:2]: The number of deceleration steps after touching home sensor // STOPTIM[0:4]: The stop duration between change of directions in // backtracking dev->reg.init_reg(0x5e, 0x23); if (dev->model->model_id == ModelId::CANON_4400F) { dev->reg.init_reg(0x5e, 0x3f); } if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x5e, 0x85); } if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x5e, 0x1f); } if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x5e, 0x01); } //FMOVDEC: The number of deceleration steps in table 5 for auto-go-home dev->reg.init_reg(0x5f, 0x01); if (dev->model->model_id == ModelId::CANON_4400F) { dev->reg.init_reg(0x5f, 0xf0); } if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x5f, 0xf0); } if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x5f, 0x01); } // Z1MOD[0:20] dev->reg.init_reg(0x60, 0x00); dev->reg.init_reg(0x61, 0x00); dev->reg.init_reg(0x62, 0x00); // Z2MOD[0:20] dev->reg.init_reg(0x63, 0x00); dev->reg.init_reg(0x64, 0x00); dev->reg.init_reg(0x65, 0x00); // STEPSEL[0:1]. Motor movement step mode selection for tables 1-3 in // scanning mode. // MTRPWM[0:5]. Motor phase PWM duty cycle setting for tables 1-3 dev->reg.init_reg(0x67, 0x7f); // FSTPSEL[0:1]: Motor movement step mode selection for tables 4-5 in // command mode. // FASTPWM[5:0]: Motor phase PWM duty cycle setting for tables 4-5 dev->reg.init_reg(0x68, 0x7f); if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300) { dev->reg.init_reg(0x67, 0x80); dev->reg.init_reg(0x68, 0x80); } // FSHDEC[0:7]: The number of deceleration steps after scanning is finished // (table 3) dev->reg.init_reg(0x69, 0x01); if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x69, 64); } // FMOVNO[0:7] The number of acceleration or deceleration steps for fast // moving (table 4) dev->reg.init_reg(0x6a, 0x04); if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x69, 64); } // GPIO-related register bits dev->reg.init_reg(0x6b, 0x30); if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x6b, 0x72); } if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x6b, 0xb1); } if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x6b, 0xf4); } if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x6b, 0x31); } // 0x6c, 0x6d, 0x6e, 0x6f are set according to gpio tables. See // gl843_init_gpio. // RSH[0:4]: The position of rising edge of CCD RS signal in cycles // RSL[0:4]: The position of falling edge of CCD RS signal in cycles // CPH[0:4]: The position of rising edge of CCD CP signal in cycles. // CPL[0:4]: The position of falling edge of CCD CP signal in cycles dev->reg.init_reg(0x70, 0x01); // SENSOR_DEF dev->reg.init_reg(0x71, 0x03); // SENSOR_DEF dev->reg.init_reg(0x72, 0x04); // SENSOR_DEF dev->reg.init_reg(0x73, 0x05); // SENSOR_DEF if (dev->model->model_id == ModelId::CANON_4400F) { dev->reg.init_reg(0x70, 0x01); dev->reg.init_reg(0x71, 0x03); dev->reg.init_reg(0x72, 0x01); dev->reg.init_reg(0x73, 0x03); } if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x70, 0x01); dev->reg.init_reg(0x71, 0x03); dev->reg.init_reg(0x72, 0x03); dev->reg.init_reg(0x73, 0x04); } if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x70, 0x00); dev->reg.init_reg(0x71, 0x02); dev->reg.init_reg(0x72, 0x02); dev->reg.init_reg(0x73, 0x04); } if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x70, 0x00); dev->reg.init_reg(0x71, 0x02); dev->reg.init_reg(0x72, 0x00); dev->reg.init_reg(0x73, 0x00); } // CK1MAP[0:17], CK3MAP[0:17], CK4MAP[0:17]: CCD clock bit mapping setting. dev->reg.init_reg(0x74, 0x00); // SENSOR_DEF dev->reg.init_reg(0x75, 0x00); // SENSOR_DEF dev->reg.init_reg(0x76, 0x3c); // SENSOR_DEF dev->reg.init_reg(0x77, 0x00); // SENSOR_DEF dev->reg.init_reg(0x78, 0x00); // SENSOR_DEF dev->reg.init_reg(0x79, 0x9f); // SENSOR_DEF dev->reg.init_reg(0x7a, 0x00); // SENSOR_DEF dev->reg.init_reg(0x7b, 0x00); // SENSOR_DEF dev->reg.init_reg(0x7c, 0x55); // SENSOR_DEF // various AFE settings dev->reg.init_reg(0x7d, 0x00); if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x7d, 0x20); } // GPOLED[x]: LED vs GPIO settings dev->reg.init_reg(0x7e, 0x00); // BSMPDLY, VSMPDLY // LEDCNT[0:1]: Controls led blinking and its period dev->reg.init_reg(0x7f, 0x00); // VRHOME, VRMOVE, VRBACK, VRSCAN: Vref settings of the motor driver IC for // moving in various situations. dev->reg.init_reg(0x80, 0x00); if (dev->model->model_id == ModelId::CANON_4400F) { dev->reg.init_reg(0x80, 0x0c); } if (dev->model->model_id == ModelId::CANON_8400F) { dev->reg.init_reg(0x80, 0x28); } if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x80, 0x50); } if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x80, 0x0f); } if (dev->model->model_id != ModelId::CANON_4400F) { dev->reg.init_reg(0x81, 0x00); dev->reg.init_reg(0x82, 0x00); dev->reg.init_reg(0x83, 0x00); dev->reg.init_reg(0x84, 0x00); dev->reg.init_reg(0x85, 0x00); dev->reg.init_reg(0x86, 0x00); } dev->reg.init_reg(0x87, 0x00); if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8400F || dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x87, 0x02); } // MTRPLS[0:7]: The width of the ADF motor trigger signal pulse. if (dev->model->model_id != ModelId::CANON_8400F && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7200I && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7300) { dev->reg.init_reg(0x94, 0xff); } // 0x95-0x97: SCANLEN[0:19]: Controls when paper jam bit is set in sheetfed // scanners. // ONDUR[0:15]: The duration of PWM ON phase for LAMP control // OFFDUR[0:15]: The duration of PWM OFF phase for LAMP control // both of the above are in system clocks if (dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0x98, 0x00); dev->reg.init_reg(0x99, 0x00); dev->reg.init_reg(0x9a, 0x00); dev->reg.init_reg(0x9b, 0x00); } if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { // TODO: move to set for scan dev->reg.init_reg(0x98, 0x03); dev->reg.init_reg(0x99, 0x30); dev->reg.init_reg(0x9a, 0x01); dev->reg.init_reg(0x9b, 0x80); } // RMADLY[0:1], MOTLAG, CMODE, STEPTIM, MULDMYLN, IFRS dev->reg.init_reg(0x9d, 0x04); if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->reg.init_reg(0x9d, 0x00); } if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8400F || dev->model->model_id == ModelId::CANON_8600F || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I || dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0x9d, 0x08); // sets the multiplier for slope tables } // SEL3INV, TGSTIME[0:2], TGWTIME[0:2] if (dev->model->model_id != ModelId::CANON_8400F && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7200I && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7300) { dev->reg.init_reg(0x9e, 0x00); // SENSOR_DEF } if (dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7300) { dev->reg.init_reg(0xa2, 0x0f); } // RFHSET[0:4]: Refresh time of SDRAM in units of 2us if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8600F) { dev->reg.init_reg(0xa2, 0x1f); } // 0xa6-0xa9: controls gpio, see gl843_gpio_init // not documented if (dev->model->model_id != ModelId::CANON_4400F && dev->model->model_id != ModelId::CANON_8400F && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7200I && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7300) { dev->reg.init_reg(0xaa, 0x00); } // GPOM9, MULSTOP[0-2], NODECEL, TB3TB1, TB5TB2, FIX16CLK. Not documented if (dev->model->model_id != ModelId::CANON_8400F && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7200I && dev->model->model_id != ModelId::PLUSTEK_OPTICFILM_7300) { dev->reg.init_reg(0xab, 0x50); } if (dev->model->model_id == ModelId::CANON_4400F) { dev->reg.init_reg(0xab, 0x00); } if (dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { // BUG: this should apply to ModelId::CANON_CANOSCAN_8600F too, but due to previous bug // the 8400F case overwrote it dev->reg.init_reg(0xab, 0x40); } // VRHOME[3:2], VRMOVE[3:2], VRBACK[3:2]: Vref setting of the motor driver IC // for various situations. if (dev->model->model_id == ModelId::CANON_8600F || dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050 || dev->model->model_id == ModelId::HP_SCANJET_4850C) { dev->reg.init_reg(0xac, 0x00); } dev->calib_reg = dev->reg; if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I) { uint8_t data[32] = { 0x8c, 0x8f, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x73, 0x63, 0x68, 0x69, 0x65, 0x6e, 0x00, }; dev->interface->write_buffer(0x3c, 0x3ff000, data, 32, ScannerInterface::FLAG_SWAP_REGISTERS); } } // Send slope table for motor movement slope_table in machine byte order static void gl843_send_slope_table(Genesys_Device* dev, int table_nr, const std::vector& slope_table, int steps) { DBG_HELPER_ARGS(dbg, "table_nr = %d, steps = %d", table_nr, steps); int i; char msg[10000]; std::vector table(steps * 2); for (i = 0; i < steps; i++) { table[i * 2] = slope_table[i] & 0xff; table[i * 2 + 1] = slope_table[i] >> 8; } if (DBG_LEVEL >= DBG_io) { std::sprintf(msg, "write slope %d (%d)=", table_nr, steps); for (i = 0; i < steps; i++) { std::sprintf (msg+strlen(msg), "%d", slope_table[i]); } DBG(DBG_io, "%s: %s\n", __func__, msg); } if (dev->interface->is_mock()) { dev->interface->record_slope_table(table_nr, slope_table); } // slope table addresses are fixed : 0x40000, 0x48000, 0x50000, 0x58000, 0x60000 // XXX STEF XXX USB 1.1 ? sanei_genesys_write_0x8c (dev, 0x0f, 0x14); dev->interface->write_gamma(0x28, 0x40000 + 0x8000 * table_nr, table.data(), steps * 2, ScannerInterface::FLAG_SWAP_REGISTERS); // FIXME: remove this when updating tests gl843_set_buffer_address(dev, 0); } static void gl843_set_ad_fe(Genesys_Device* dev) { for (const auto& reg : dev->frontend.regs) { dev->interface->write_fe_register(reg.address, reg.value); } } // Set values of analog frontend void CommandSetGl843::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const { DBG_HELPER_ARGS(dbg, "%s", set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == AFE_POWER_SAVE ? "powersave" : "huh?"); (void) sensor; int i; if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; dev->frontend_is_init = true; } // check analog frontend type // FIXME: looks like we write to that register with initial data uint8_t fe_type = dev->interface->read_register(REG_0x04) & REG_0x04_FESET; if (fe_type == 2) { gl843_set_ad_fe(dev); return; } if (fe_type != 0) { throw SaneException(SANE_STATUS_UNSUPPORTED, "unsupported frontend type %d", fe_type); } DBG(DBG_proc, "%s(): frontend reset complete\n", __func__); for (i = 1; i <= 3; i++) { // FIXME: the check below is just historical artifact, we can remove it when convenient if (!dev->frontend_is_init) { dev->interface->write_fe_register(i, 0x00); } else { dev->interface->write_fe_register(i, dev->frontend.regs.get_value(0x00 + i)); } } for (const auto& reg : sensor.custom_fe_regs) { dev->interface->write_fe_register(reg.address, reg.value); } for (i = 0; i < 3; i++) { // FIXME: the check below is just historical artifact, we can remove it when convenient if (!dev->frontend_is_init) { dev->interface->write_fe_register(0x20 + i, 0x00); } else { dev->interface->write_fe_register(0x20 + i, dev->frontend.get_offset(i)); } } if (dev->model->sensor_id == SensorId::CCD_KVSS080) { for (i = 0; i < 3; i++) { // FIXME: the check below is just historical artifact, we can remove it when convenient if (!dev->frontend_is_init) { dev->interface->write_fe_register(0x24 + i, 0x00); } else { dev->interface->write_fe_register(0x24 + i, dev->frontend.regs.get_value(0x24 + i)); } } } for (i = 0; i < 3; i++) { // FIXME: the check below is just historical artifact, we can remove it when convenient if (!dev->frontend_is_init) { dev->interface->write_fe_register(0x28 + i, 0x00); } else { dev->interface->write_fe_register(0x28 + i, dev->frontend.get_gain(i)); } } } static void gl843_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const Motor_Profile& motor_profile, unsigned int exposure, unsigned scan_yres, unsigned int scan_lines, unsigned int scan_dummy, unsigned int feed_steps, MotorFlag flags) { DBG_HELPER_ARGS(dbg, "exposure=%d, scan_yres=%d, step_type=%d, scan_lines=%d, scan_dummy=%d, " "feed_steps=%d, flags=%x", exposure, scan_yres, static_cast(motor_profile.step_type), scan_lines, scan_dummy, feed_steps, static_cast(flags)); int use_fast_fed, coeff; unsigned int lincnt; unsigned feedl, dist; GenesysRegister *r; uint32_t z1, z2; /* get step multiplier */ unsigned step_multiplier = gl843_get_step_multiplier (reg); use_fast_fed = 0; if ((scan_yres >= 300 && feed_steps > 900) || (has_flag(flags, MotorFlag::FEED))) { use_fast_fed = 1; } lincnt=scan_lines; reg->set24(REG_LINCNT, lincnt); DBG(DBG_io, "%s: lincnt=%d\n", __func__, lincnt); /* compute register 02 value */ r = sanei_genesys_get_address(reg, REG_0x02); r->value = 0x00; sanei_genesys_set_motor_power(*reg, true); if (use_fast_fed) { r->value |= REG_0x02_FASTFED; } else { r->value &= ~REG_0x02_FASTFED; } /* in case of automatic go home, move until home sensor */ if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { r->value |= REG_0x02_AGOHOME | REG_0x02_NOTHOME; } /* disable backtracking */ if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE) ||(scan_yres>=2400 && dev->model->model_id != ModelId::CANON_4400F) ||(scan_yres>=sensor.optical_res)) { r->value |= REG_0x02_ACDCDIS; } if (has_flag(flags, MotorFlag::REVERSE)) { r->value |= REG_0x02_MTRREV; } else { r->value &= ~REG_0x02_MTRREV; } /* scan and backtracking slope table */ auto scan_table = sanei_genesys_slope_table(dev->model->asic_type, scan_yres, exposure, dev->motor.base_ydpi, step_multiplier, motor_profile); gl843_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); gl843_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); reg->set8(REG_STEPNO, scan_table.steps_count / step_multiplier); reg->set8(REG_FASTNO, scan_table.steps_count / step_multiplier); // fast table unsigned fast_yres = sanei_genesys_get_lowest_ydpi(dev); auto fast_table = sanei_genesys_slope_table(dev->model->asic_type, fast_yres, exposure, dev->motor.base_ydpi, step_multiplier, motor_profile); gl843_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count); gl843_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); gl843_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.steps_count); reg->set8(REG_FSHDEC, fast_table.steps_count / step_multiplier); reg->set8(REG_FMOVNO, fast_table.steps_count / step_multiplier); /* substract acceleration distance from feedl */ feedl=feed_steps; feedl <<= static_cast(motor_profile.step_type); dist = scan_table.steps_count / step_multiplier; if (use_fast_fed) { dist += (fast_table.steps_count / step_multiplier) * 2; } 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 */ if (dist < feedl) { feedl -= dist; } else { feedl = 1; } reg->set24(REG_FEEDL, feedl); DBG(DBG_io, "%s: feedl=%d\n", __func__, feedl); /* doesn't seem to matter that much */ sanei_genesys_calculate_zmod(use_fast_fed, exposure, scan_table.table, scan_table.steps_count / step_multiplier, feedl, scan_table.steps_count / step_multiplier, &z1, &z2); if(scan_yres>600) { z1=0; z2=0; } reg->set24(REG_Z1MOD, z1); DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); reg->set24(REG_Z2MOD, z2); DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); r = sanei_genesys_get_address(reg, REG_0x1E); r->value &= 0xf0; /* 0 dummy lines */ r->value |= scan_dummy; /* dummy lines */ reg->set8_mask(REG_0x67, static_cast(motor_profile.step_type) << REG_0x67S_STEPSEL, 0xc0); reg->set8_mask(REG_0x68, static_cast(motor_profile.step_type) << REG_0x68S_FSTPSEL, 0xc0); // steps for STOP table reg->set8(REG_FMOVDEC, fast_table.steps_count / step_multiplier); /* Vref XXX STEF XXX : optical divider or step type ? */ r = sanei_genesys_get_address (reg, 0x80); if (!(dev->model->flags & GENESYS_FLAG_FULL_HWDPI_MODE)) { r->value = 0x50; coeff = sensor.get_hwdpi_divisor_for_dpi(scan_yres); if (dev->model->motor_id == MotorId::KVSS080) { if(coeff>=1) { r->value |= 0x05; } } else { switch(coeff) { case 4: r->value |= 0x0a; break; case 2: r->value |= 0x0f; break; case 1: r->value |= 0x0f; break; } } } } /** @brief setup optical related registers * start and pixels are expressed in optical sensor resolution coordinate * space. * @param dev device to use * @param reg registers to set up * @param exposure exposure time to use * @param used_res scanning resolution used, may differ from * scan's one * @param start logical start pixel coordinate * @param pixels logical number of pixels to use * @param channels number of color channles used (1 or 3) * @param depth bit depth of the scan (1, 8 or 16 bits) * @param ccd_size_divisor true specifies how much x coordinates must be shrunk * @param color_filter to choose the color channel used in gray scans * @param flags to drive specific settings such no calibration, XPA use ... */ static void gl843_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, unsigned int exposure, const ScanSession& session) { DBG_HELPER_ARGS(dbg, "exposure=%d", exposure); unsigned int dpihw; unsigned int tgtime; /**> exposure time multiplier */ GenesysRegister *r; /* tgtime */ tgtime = exposure / 65536 + 1; 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 = sensor.get_register_hwdpi(session.output_resolution); DBG(DBG_io2, "%s: dpihw=%d\n", __func__, dpihw); /* sensor parameters */ gl843_setup_sensor(dev, sensor, reg); // resolution is divided according to CKSEL unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel(); DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel); dev->cmd_set->set_fe(dev, sensor, AFE_SET); /* enable shading */ regs_set_optical_off(dev->model->asic_type, *reg); r = sanei_genesys_get_address (reg, REG_0x01); if (has_flag(session.params.flags, ScanFlag::DISABLE_SHADING) || (dev->model->flags & GENESYS_FLAG_NO_CALIBRATION || (dev->model->flags & GENESYS_FLAG_CALIBRATION_HOST_SIDE))) { r->value &= ~REG_0x01_DVDSET; } else { r->value |= REG_0x01_DVDSET; } bool use_shdarea = dpihw > 600; if (dev->model->model_id == ModelId::CANON_4400F) { use_shdarea = session.params.xres <= 600; } else if (dev->model->model_id == ModelId::CANON_8400F) { use_shdarea = session.params.xres <= 400; } if (use_shdarea) { r->value |= REG_0x01_SHDAREA; } else { r->value &= ~REG_0x01_SHDAREA; } r = sanei_genesys_get_address (reg, REG_0x03); if (dev->model->model_id == ModelId::CANON_8600F) { r->value |= REG_0x03_AVEENB; } else { r->value &= ~REG_0x03_AVEENB; } // FIXME: we probably don't need to set exposure to registers at this point. It was this way // before a refactor. sanei_genesys_set_lamp_power(dev, sensor, *reg, !has_flag(session.params.flags, ScanFlag::DISABLE_LAMP)); /* select XPA */ r->value &= ~REG_0x03_XPASEL; if (has_flag(session.params.flags, ScanFlag::USE_XPA)) { r->value |= REG_0x03_XPASEL; } reg->state.is_xpa_on = has_flag(session.params.flags, ScanFlag::USE_XPA); /* BW threshold */ r = sanei_genesys_get_address(reg, REG_0x2E); r->value = dev->settings.threshold; r = sanei_genesys_get_address(reg, REG_0x2F); r->value = dev->settings.threshold; /* monochrome / color scan */ r = sanei_genesys_get_address(reg, REG_0x04); switch (session.params.depth) { case 8: r->value &= ~(REG_0x04_LINEART | REG_0x04_BITSET); break; case 16: r->value &= ~REG_0x04_LINEART; r->value |= REG_0x04_BITSET; break; } r->value &= ~(REG_0x04_FILTER | REG_0x04_AFEMOD); if (session.params.channels == 1) { switch (session.params.color_filter) { case ColorFilter::RED: r->value |= 0x14; break; case ColorFilter::BLUE: r->value |= 0x1c; break; case ColorFilter::GREEN: r->value |= 0x18; break; default: break; // should not happen } } else { switch (dev->frontend.layout.type) { case FrontendType::WOLFSON: r->value |= 0x10; // pixel by pixel break; case FrontendType::ANALOG_DEVICES: r->value |= 0x20; // slow color pixel by pixel break; default: throw SaneException("Invalid frontend type %d", static_cast(dev->frontend.layout.type)); } } sanei_genesys_set_dpihw(*reg, sensor, dpihw); if (should_enable_gamma(session, sensor)) { reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB; } else { reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB; } unsigned dpiset = session.output_resolution * session.ccd_size_divisor * ccd_pixels_per_system_pixel; if (sensor.dpiset_override != 0) { dpiset = sensor.dpiset_override; } reg->set16(REG_DPISET, dpiset); DBG(DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); reg->set16(REG_STRPIXEL, session.pixel_startx); reg->set16(REG_ENDPIXEL, session.pixel_endx); /* MAXWD is expressed in 2 words unit */ /* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */ // BUG: the division by ccd_size_divisor likely does not make sense reg->set24(REG_MAXWD, (session.output_line_bytes / session.ccd_size_divisor) >> 1); reg->set16(REG_LPERIOD, exposure / tgtime); DBG(DBG_io2, "%s: exposure used=%d\n", __func__, exposure/tgtime); r = sanei_genesys_get_address (reg, REG_DUMMY); r->value = sensor.dummy_pixel; } void CommandSetGl843::init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const { DBG_HELPER(dbg); session.assert_computed(); int exposure; int slope_dpi = 0; int dummy = 0; /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode */ dummy = 0; if (dev->model->model_id == ModelId::CANON_4400F && session.params.yres == 1200) { dummy = 1; } /* slope_dpi */ /* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */ if (dev->model->is_cis) slope_dpi = session.params.yres * session.params.channels; else slope_dpi = session.params.yres; slope_dpi = slope_dpi * (1 + dummy); /* scan_step_type */ exposure = sensor.exposure_lperiod; if (exposure < 0) { throw std::runtime_error("Exposure not defined in sensor definition"); } const auto& motor_profile = sanei_genesys_get_motor_profile(*gl843_motor_profiles, dev->model->motor_id, exposure); DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure); DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, static_cast(motor_profile.step_type)); // now _LOGICAL_ optical values used are known, setup registers gl843_init_optical_regs_scan(dev, sensor, reg, exposure, session); /*** motor parameters ***/ MotorFlag mflags = MotorFlag::NONE; if (has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { mflags |= MotorFlag::DISABLE_BUFFER_FULL_MOVE; } if (has_flag(session.params.flags, ScanFlag::FEEDING)) { mflags |= MotorFlag::FEED; } if (has_flag(session.params.flags, ScanFlag::USE_XPA)) { mflags |= MotorFlag::USE_XPA; } if (has_flag(session.params.flags, ScanFlag::REVERSE)) { mflags |= MotorFlag::REVERSE; } unsigned scan_lines = dev->model->is_cis ? session.output_line_count * session.params.channels : session.output_line_count; gl843_init_motor_regs_scan(dev, sensor, reg, motor_profile, exposure, slope_dpi, scan_lines, dummy, session.params.starty, mflags); dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); build_image_pipeline(dev, session); dev->read_active = true; dev->session = session; dev->total_bytes_read = 0; dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines; DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read); } ScanSession CommandSetGl843::calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const { DBG_HELPER(dbg); debug_dump(DBG_info, settings); int start; /* we have 2 domains for ccd: xres below or above half ccd max dpi */ unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(settings.xres); if (settings.scan_method == ScanMethod::TRANSPARENCY || settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { start = static_cast(dev->model->x_offset_ta); } else { start = static_cast(dev->model->x_offset); } if (dev->model->model_id == ModelId::CANON_8600F) { // FIXME: this is probably just an artifact of a bug elsewhere start /= ccd_size_divisor; } start += static_cast(settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = settings.xres; session.params.yres = settings.yres; session.params.startx = start; // not used session.params.starty = 0; // not used session.params.pixels = settings.pixels; session.params.requested_pixels = settings.requested_pixels; session.params.lines = settings.lines; session.params.depth = settings.depth; session.params.channels = settings.get_channels(); session.params.scan_method = settings.scan_method; session.params.scan_mode = settings.scan_mode; session.params.color_filter = settings.color_filter; session.params.flags = ScanFlag::NONE; compute_session(dev, session, sensor); return session; } /** * for fast power saving methods only, like disabling certain amplifiers * @param dev device to use * @param enable true to set inot powersaving * */ void CommandSetGl843::save_power(Genesys_Device* dev, bool enable) const { DBG_HELPER_ARGS(dbg, "enable = %d", enable); // switch KV-SS080 lamp off if (dev->model->gpio_id == GpioId::KVSS080) { uint8_t val = dev->interface->read_register(REG_0x6C); if (enable) { val &= 0xef; } else { val |= 0x10; } dev->interface->write_register(REG_0x6C, val); } } void CommandSetGl843::set_powersaving(Genesys_Device* dev, int delay /* in minutes */) const { (void) dev; DBG_HELPER_ARGS(dbg, "delay = %d", delay); } static bool gl843_get_paper_sensor(Genesys_Device* dev) { DBG_HELPER(dbg); uint8_t val = dev->interface->read_register(REG_0x6D); return (val & 0x1) == 0; } void CommandSetGl843::eject_document(Genesys_Device* dev) const { (void) dev; DBG_HELPER(dbg); } void CommandSetGl843::load_document(Genesys_Device* dev) const { DBG_HELPER(dbg); (void) dev; } /** * detects end of document and adjust current scan * to take it into account * used by sheetfed scanners */ void CommandSetGl843::detect_document_end(Genesys_Device* dev) const { DBG_HELPER(dbg); bool paper_loaded = gl843_get_paper_sensor(dev); /* sheetfed scanner uses home sensor as paper present */ if (dev->document && !paper_loaded) { DBG(DBG_info, "%s: no more document\n", __func__); dev->document = false; unsigned scanned_lines = 0; catch_all_exceptions(__func__, [&](){ sanei_genesys_read_scancnt(dev, &scanned_lines); }); std::size_t output_lines = dev->session.output_line_count; std::size_t offset_lines = static_cast( (dev->model->post_scan * dev->session.params.yres) / MM_PER_INCH); std::size_t scan_end_lines = scanned_lines + offset_lines; std::size_t remaining_lines = dev->get_pipeline_source().remaining_bytes() / dev->session.output_line_bytes_raw; DBG(DBG_io, "%s: scanned_lines=%u\n", __func__, scanned_lines); DBG(DBG_io, "%s: scan_end_lines=%zu\n", __func__, scan_end_lines); DBG(DBG_io, "%s: output_lines=%zu\n", __func__, output_lines); DBG(DBG_io, "%s: remaining_lines=%zu\n", __func__, remaining_lines); if (scan_end_lines > output_lines) { auto skip_lines = scan_end_lines - output_lines; if (remaining_lines > skip_lines) { DBG(DBG_io, "%s: skip_lines=%zu\n", __func__, skip_lines); remaining_lines -= skip_lines; dev->get_pipeline_source().set_remaining_bytes(remaining_lines * dev->session.output_line_bytes_raw); dev->total_bytes_to_read -= skip_lines * dev->session.output_line_bytes_requested; } } } } // enables or disables XPA slider motor void gl843_set_xpa_motor_power(Genesys_Device* dev, Genesys_Register_Set& regs, bool set) { DBG_HELPER(dbg); uint8_t val; if (dev->model->model_id == ModelId::CANON_8400F) { if (set) { val = dev->interface->read_register(0x6c); val &= ~(REG_0x6C_GPIO16 | REG_0x6C_GPIO13); if (dev->session.output_resolution >= 2400) { val &= ~REG_0x6C_GPIO10; } dev->interface->write_register(0x6c, val); val = dev->interface->read_register(0xa9); val |= REG_0xA9_GPO30; val &= ~REG_0xA9_GPO29; dev->interface->write_register(0xa9, val); } else { val = dev->interface->read_register(0x6c); val |= REG_0x6C_GPIO16 | REG_0x6C_GPIO13; dev->interface->write_register(0x6c, val); val = dev->interface->read_register(0xa9); val &= ~REG_0xA9_GPO30; val |= REG_0xA9_GPO29; dev->interface->write_register(0xa9, val); } } else if (dev->model->model_id == ModelId::CANON_8600F) { if (set) { val = dev->interface->read_register(REG_0x6C); val &= ~REG_0x6C_GPIO14; if (dev->session.output_resolution >= 2400) { val |= REG_0x6C_GPIO10; } dev->interface->write_register(REG_0x6C, val); val = dev->interface->read_register(REG_0xA6); val |= REG_0xA6_GPIO17; val &= ~REG_0xA6_GPIO23; dev->interface->write_register(REG_0xA6, val); } else { val = dev->interface->read_register(REG_0x6C); val |= REG_0x6C_GPIO14; val &= ~REG_0x6C_GPIO10; dev->interface->write_register(REG_0x6C, val); val = dev->interface->read_register(REG_0xA6); val &= ~REG_0xA6_GPIO17; val &= ~REG_0xA6_GPIO23; dev->interface->write_register(REG_0xA6, val); } } else if (dev->model->model_id == ModelId::HP_SCANJET_G4050) { if (set) { // set MULTFILM et GPOADF val = dev->interface->read_register(REG_0x6B); val |=REG_0x6B_MULTFILM|REG_0x6B_GPOADF; dev->interface->write_register(REG_0x6B, val); val = dev->interface->read_register(REG_0x6C); val &= ~REG_0x6C_GPIO15; dev->interface->write_register(REG_0x6C, val); /* Motor power ? No move at all without this one */ val = dev->interface->read_register(REG_0xA6); val |= REG_0xA6_GPIO20; dev->interface->write_register(REG_0xA6, val); val = dev->interface->read_register(REG_0xA8); val &= ~REG_0xA8_GPO27; dev->interface->write_register(REG_0xA8, val); val = dev->interface->read_register(REG_0xA9); val |= REG_0xA9_GPO32|REG_0xA9_GPO31; dev->interface->write_register(REG_0xA9, val); } else { // unset GPOADF val = dev->interface->read_register(REG_0x6B); val &= ~REG_0x6B_GPOADF; dev->interface->write_register(REG_0x6B, val); val = dev->interface->read_register(REG_0xA8); val |= REG_0xA8_GPO27; dev->interface->write_register(REG_0xA8, val); val = dev->interface->read_register(REG_0xA9); val &= ~REG_0xA9_GPO31; dev->interface->write_register(REG_0xA9, val); } } regs.state.is_xpa_motor_on = set; } /** @brief light XPA lamp * toggle gpios to switch off regular lamp and light on the * XPA light * @param dev device to set up */ static void gl843_set_xpa_lamp_power(Genesys_Device* dev, bool set) { DBG_HELPER(dbg); struct LampSettings { ModelId model_id; ScanMethod scan_method; GenesysRegisterSettingSet regs_on; GenesysRegisterSettingSet regs_off; }; // FIXME: BUG: we're not clearing the registers to the previous state when returning back when // turning off the lamp LampSettings settings[] = { { ModelId::CANON_8400F, ScanMethod::TRANSPARENCY, { { 0xa6, 0x34, 0xf4 }, }, { { 0xa6, 0x40, 0x70 }, } }, { ModelId::CANON_8400F, ScanMethod::TRANSPARENCY_INFRARED, { { 0x6c, 0x40, 0x40 }, { 0xa6, 0x01, 0xff }, }, { { 0x6c, 0x00, 0x40 }, { 0xa6, 0x00, 0xff }, } }, { ModelId::CANON_8600F, ScanMethod::TRANSPARENCY, { { 0xa6, 0x34, 0xf4 }, { 0xa7, 0xe0, 0xe0 }, }, { { 0xa6, 0x40, 0x70 }, } }, { ModelId::CANON_8600F, ScanMethod::TRANSPARENCY_INFRARED, { { 0xa6, 0x00, 0xc0 }, { 0xa7, 0xe0, 0xe0 }, { 0x6c, 0x80, 0x80 }, }, { { 0xa6, 0x00, 0xc0 }, { 0x6c, 0x00, 0x80 }, } }, { ModelId::PLUSTEK_OPTICFILM_7200I, ScanMethod::TRANSPARENCY, { }, { { 0xa6, 0x40, 0x70 }, // BUG: remove this cleanup write, it was enabled by accident } }, { ModelId::PLUSTEK_OPTICFILM_7200I, ScanMethod::TRANSPARENCY_INFRARED, { { 0xa8, 0x07, 0x07 }, }, { { 0xa8, 0x00, 0x07 }, } }, { ModelId::PLUSTEK_OPTICFILM_7300, ScanMethod::TRANSPARENCY, {}, {} }, { ModelId::PLUSTEK_OPTICFILM_7500I, ScanMethod::TRANSPARENCY, {}, {} }, { ModelId::PLUSTEK_OPTICFILM_7500I, ScanMethod::TRANSPARENCY_INFRARED, { { 0xa8, 0x07, 0x07 }, }, { { 0xa8, 0x00, 0x07 }, } }, }; for (const auto& setting : settings) { if (setting.model_id == dev->model->model_id && setting.scan_method == dev->settings.scan_method) { apply_reg_settings_to_device(*dev, set ? setting.regs_on : setting.regs_off); return; } } // BUG: we're currently calling the function in shut down path of regular lamp if (set) { throw SaneException("Unexpected code path entered"); } GenesysRegisterSettingSet regs = { { 0xa6, 0x40, 0x70 }, }; apply_reg_settings_to_device(*dev, regs); // TODO: throw exception when we're only calling this function in error return path // throw SaneException("Could not find XPA lamp settings"); } // Send the low-level scan command void CommandSetGl843::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, bool start_motor) const { DBG_HELPER(dbg); (void) sensor; /* set up GPIO for scan */ switch(dev->model->gpio_id) { /* KV case */ case GpioId::KVSS080: dev->interface->write_register(REG_0xA9, 0x00); dev->interface->write_register(REG_0xA6, 0xf6); // blinking led dev->interface->write_register(0x7e, 0x04); break; case GpioId::G4050: dev->interface->write_register(REG_0xA7, 0xfe); dev->interface->write_register(REG_0xA8, 0x3e); dev->interface->write_register(REG_0xA9, 0x06); if ((reg->get8(0x05) & REG_0x05_DPIHW) == REG_0x05_DPIHW_600) { dev->interface->write_register(REG_0x6C, 0x20); dev->interface->write_register(REG_0xA6, 0x44); } else { dev->interface->write_register(REG_0x6C, 0x60); dev->interface->write_register(REG_0xA6, 0x46); } if (reg->state.is_xpa_on && reg->state.is_lamp_on) { gl843_set_xpa_lamp_power(dev, true); } if (reg->state.is_xpa_on) { gl843_set_xpa_motor_power(dev, *reg, true); } // blinking led dev->interface->write_register(REG_0x7E, 0x01); break; case GpioId::CANON_8400F: case GpioId::CANON_8600F: if (reg->state.is_xpa_on && reg->state.is_lamp_on) { gl843_set_xpa_lamp_power(dev, true); } if (reg->state.is_xpa_on) { gl843_set_xpa_motor_power(dev, *reg, true); } break; case GpioId::PLUSTEK_OPTICFILM_7200I: case GpioId::PLUSTEK_OPTICFILM_7300: case GpioId::PLUSTEK_OPTICFILM_7500I: { if (reg->state.is_xpa_on && reg->state.is_lamp_on) { gl843_set_xpa_lamp_power(dev, true); } break; } case GpioId::CANON_4400F: default: break; } // clear scan and feed count dev->interface->write_register(REG_0x0D, REG_0x0D_CLRLNCNT | REG_0x0D_CLRMCNT); // enable scan and motor uint8_t val = dev->interface->read_register(REG_0x01); val |= REG_0x01_SCAN; dev->interface->write_register(REG_0x01, val); scanner_start_action(*dev, start_motor); if (reg->state.is_motor_on) { dev->advance_head_pos_by_session(ScanHeadId::PRIMARY); } if (reg->state.is_xpa_motor_on) { dev->advance_head_pos_by_session(ScanHeadId::SECONDARY); } } // Send the stop scan command void CommandSetGl843::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg, bool check_stop) const { DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop); // post scan gpio dev->interface->write_register(0x7e, 0x00); // turn off XPA lamp if needed // BUG: the if condition below probably shouldn't be enabled when XPA is off if (reg->state.is_xpa_on || reg->state.is_lamp_on) { gl843_set_xpa_lamp_power(dev, false); } if (!dev->model->is_sheetfed) { scanner_stop_action(*dev); } } /** @brief Moves the slider to the home (top) position slowly * */ void CommandSetGl843::move_back_home(Genesys_Device* dev, bool wait_until_home) const { scanner_move_back_home(*dev, wait_until_home); } // Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi // from very top of scanner void CommandSetGl843::search_start_position(Genesys_Device* dev) const { DBG_HELPER(dbg); Genesys_Register_Set local_reg; int pixels = 600; int dpi = 300; local_reg = dev->reg; /* sets for a 200 lines * 600 pixels */ /* normal scan with no shading */ // FIXME: the current approach of doing search only for one resolution does not work on scanners // whith employ different sensors with potentially different settings. const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method); ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; // we should give a small offset here - ~60 steps session.params.pixels = 600; session.params.lines = dev->model->search_lines; session.params.depth = 8; session.params.channels = 1; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::GREEN; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::IGNORE_LINE_DISTANCE | ScanFlag::DISABLE_BUFFER_FULL_MOVE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &local_reg, session); // send to scanner dev->interface->write_registers(local_reg); dev->cmd_set->begin_scan(dev, sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_start_position"); end_scan(dev, &local_reg, true); dev->reg = local_reg; return; } wait_until_buffer_non_empty(dev); // now we're on target, we can read data Image image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); scanner_stop_action_no_move(*dev, local_reg); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl843_search_position.pnm", image); } dev->cmd_set->end_scan(dev, &local_reg, true); /* update regs to copy ASIC internal state */ dev->reg = local_reg; for (auto& sensor_update : sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) { sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi, pixels, dev->model->search_lines); } } // sets up register for coarse gain calibration // todo: check it for scanners using it void CommandSetGl843::init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); ScanFlag flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { flags |= ScanFlag::USE_XPA; } ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel(); session.params.lines = 20; session.params.depth = 16; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = flags; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, ®s, session); sanei_genesys_set_motor_power(regs, false); DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres); dev->interface->write_registers(regs); } // init registers for shading calibration shading calibration is done at dpihw void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); int move, resolution, dpihw, factor; /* initial calibration reg values */ regs = dev->reg; dev->calib_channels = 3; if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { dev->calib_lines = dev->model->shading_ta_lines; } else { dev->calib_lines = dev->model->shading_lines; } dpihw = sensor.get_logical_hwdpi(dev->settings.xres); factor=sensor.optical_res/dpihw; resolution=dpihw; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, dev->calib_channels, dev->settings.scan_method); if ((dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) && dev->model->model_id == ModelId::CANON_8600F && dev->settings.xres == 4800) { float offset = static_cast(dev->model->x_offset_ta); offset /= calib_sensor.get_ccd_size_divisor_for_dpi(resolution); offset = static_cast((offset * calib_sensor.optical_res) / MM_PER_INCH); float size = static_cast(dev->model->x_size_ta); size /= calib_sensor.get_ccd_size_divisor_for_dpi(resolution); size = static_cast((size * calib_sensor.optical_res) / MM_PER_INCH); dev->calib_pixels_offset = static_cast(offset); dev->calib_pixels = static_cast(size); } else { dev->calib_pixels_offset = 0; dev->calib_pixels = calib_sensor.sensor_pixels / factor; } dev->calib_resolution = resolution; ScanFlag flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::DISABLE_BUFFER_FULL_MOVE | ScanFlag::IGNORE_LINE_DISTANCE; if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { // note: move_to_ta() function has already been called and the sensor is at the // transparency adapter move = static_cast(dev->model->y_offset_calib_white_ta - dev->model->y_offset_sensor_to_ta); flags |= ScanFlag::USE_XPA; } else { move = static_cast(dev->model->y_offset_calib_white); } move = static_cast((move * resolution) / MM_PER_INCH); ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = dev->calib_pixels_offset; session.params.starty = move; session.params.pixels = dev->calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; session.params.channels = dev->calib_channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = flags; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); // the pixel number may be updated to conform to scanner constraints dev->calib_pixels = session.output_pixels; dev->calib_session = session; dev->calib_total_bytes_to_read = session.output_total_bytes_raw; dev->interface->write_registers(regs); } /** @brief set up registers for the actual scan */ void CommandSetGl843::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); float move; int move_dpi; float start; debug_dump(DBG_info, dev->settings); move_dpi = dev->motor.base_ydpi; ScanFlag flags = ScanFlag::NONE; if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { // note: move_to_ta() function has already been called and the sensor is at the // transparency adapter if (dev->ignore_offsets) { move = 0; } else { move = static_cast(dev->model->y_offset_ta - dev->model->y_offset_sensor_to_ta); } flags |= ScanFlag::USE_XPA; } else { if (dev->ignore_offsets) { move = 0; } else { move = static_cast(dev->model->y_offset); } } move += static_cast(dev->settings.tl_y); move = static_cast((move * move_dpi) / MM_PER_INCH); DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ if (dev->settings.scan_method==ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { start = static_cast(dev->model->x_offset_ta); } else { start = static_cast(dev->model->x_offset); } if (dev->model->model_id == ModelId::CANON_8400F || dev->model->model_id == ModelId::CANON_8600F) { // FIXME: this is probably just an artifact of a bug elsewhere start /= sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres); } start = static_cast(start + dev->settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = static_cast(start); session.params.starty = static_cast(move); session.params.pixels = dev->settings.pixels; session.params.requested_pixels = dev->settings.requested_pixels; session.params.lines = dev->settings.lines; session.params.depth = dev->settings.depth; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = flags; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &dev->reg, session); } /** * This function sends gamma tables to ASIC */ void CommandSetGl843::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); int size; int i; size = 256; /* allocate temporary gamma tables: 16 bits words, 3 channels */ std::vector gamma(size * 2 * 3); std::vector rgamma = get_gamma_table(dev, sensor, GENESYS_RED); std::vector ggamma = get_gamma_table(dev, sensor, GENESYS_GREEN); std::vector bgamma = get_gamma_table(dev, sensor, GENESYS_BLUE); // copy sensor specific's gamma tables for (i = 0; i < size; i++) { gamma[i * 2 + size * 0 + 0] = rgamma[i] & 0xff; gamma[i * 2 + size * 0 + 1] = (rgamma[i] >> 8) & 0xff; gamma[i * 2 + size * 2 + 0] = ggamma[i] & 0xff; gamma[i * 2 + size * 2 + 1] = (ggamma[i] >> 8) & 0xff; gamma[i * 2 + size * 4 + 0] = bgamma[i] & 0xff; gamma[i * 2 + size * 4 + 1] = (bgamma[i] >> 8) & 0xff; } dev->interface->write_gamma(0x28, 0x0000, gamma.data(), size * 2 * 3, ScannerInterface::FLAG_SWAP_REGISTERS); } /* this function does the led calibration by scanning one line of the calibration area below scanner's top on white strip. -needs working coarse/gain */ SensorExposure CommandSetGl843::led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); int num_pixels; int avg[3], avga, avge; int turn; uint16_t expr, expg, expb; // offset calibration is always done in color mode unsigned channels = 3; // take a copy, as we're going to modify exposure auto calib_sensor = sanei_genesys_find_sensor(dev, sensor.optical_res, channels, dev->settings.scan_method); num_pixels = (calib_sensor.sensor_pixels * calib_sensor.optical_res) / calib_sensor.optical_res; /* initial calibration reg values */ regs = dev->reg; ScanSession session; session.params.xres = calib_sensor.sensor_pixels; session.params.yres = dev->motor.base_ydpi; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); dev->interface->write_registers(regs); /* we try to get equal bright leds here: loop: average per color adjust exposure times */ expr = calib_sensor.exposure.red; expg = calib_sensor.exposure.green; expb = calib_sensor.exposure.blue; turn = 0; bool acceptable = false; do { calib_sensor.exposure.red = expr; calib_sensor.exposure.green = expg; calib_sensor.exposure.blue = expb; regs_set_exposure(dev->model->asic_type, regs, calib_sensor.exposure); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting first line reading\n", __func__); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("led_calibration"); move_back_home(dev, true); return calib_sensor.exposure; } auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); scanner_stop_action_no_move(*dev, regs); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl843_led_%02d.pnm", turn); sanei_genesys_write_pnm_file(fn, image); } acceptable = true; for (unsigned ch = 0; ch < channels; ch++) { avg[ch] = 0; for (std::size_t x = 0; x < image.get_width(); x++) { avg[ch] += image.get_raw_channel(x, 0, ch); } avg[ch] /= image.get_width(); } DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); acceptable = true; if (avg[0] < avg[1] * 0.95 || avg[1] < avg[0] * 0.95 || avg[0] < avg[2] * 0.95 || avg[2] < avg[0] * 0.95 || avg[1] < avg[2] * 0.95 || avg[2] < avg[1] * 0.95) acceptable = false; if (!acceptable) { avga = (avg[0] + avg[1] + avg[2]) / 3; expr = (expr * avga) / avg[0]; expg = (expg * avga) / avg[1]; expb = (expb * avga) / avg[2]; /* keep the resulting exposures below this value. too long exposure drives the ccd into saturation. we may fix this by relying on the fact that we get a striped scan without shading, by means of statistical calculation */ avge = (expr + expg + expb) / 3; /* don't overflow max exposure */ if (avge > 3000) { expr = (expr * 2000) / avge; expg = (expg * 2000) / avge; expb = (expb * 2000) / avge; } if (avge < 50) { expr = (expr * 50) / avge; expg = (expg * 50) / avge; expb = (expb * 50) / avge; } } scanner_stop_action(*dev); turn++; } while (!acceptable && turn < 100); DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, expr, expg, expb); move_back_home(dev, true); return calib_sensor.exposure; } /** * average dark pixels of a 8 bits scan of a given channel */ static int dark_average_channel(const Image& image, unsigned black, unsigned channel) { auto channels = get_pixel_channels(image.get_format()); unsigned avg[3]; // computes average values on black margin for (unsigned ch = 0; ch < channels; ch++) { avg[ch] = 0; unsigned count = 0; // FIXME: start with the second line because the black pixels often have noise on the first // line; the cause is probably incorrectly cleaned up previous scan for (std::size_t y = 1; y < image.get_height(); y++) { for (unsigned j = 0; j < black; j++) { avg[ch] += image.get_raw_channel(j, y, ch); count++; } } if (count > 0) { avg[ch] /= count; } DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, ch, avg[ch]); } DBG(DBG_info, "%s: average = %d\n", __func__, avg[channel]); return avg[channel]; } /** @brief calibrate AFE offset * Iterate doing scans at target dpi until AFE offset if correct. One * color line is scanned at a time. Scanning head doesn't move. * @param dev device to calibrate */ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); if (dev->frontend.layout.type != FrontendType::WOLFSON) return; unsigned channels; int pass, resolution, lines; int topavg[3], bottomavg[3], avg[3]; int top[3], bottom[3], black_pixels, pixels, factor, dpihw; /* offset calibration is always done in color mode */ channels = 3; lines = 8; // compute divider factor to compute final pixels number dpihw = sensor.get_logical_hwdpi(dev->settings.xres); factor = sensor.optical_res / dpihw; resolution = dpihw; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); int target_pixels = calib_sensor.sensor_pixels / factor; int start_pixel = 0; black_pixels = calib_sensor.black_pixels / factor; if ((dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) && dev->model->model_id == ModelId::CANON_8600F && dev->settings.xres == 4800) { start_pixel = static_cast(dev->model->x_offset_ta); start_pixel /= calib_sensor.get_ccd_size_divisor_for_dpi(resolution); start_pixel = static_cast((start_pixel * calib_sensor.optical_res) / MM_PER_INCH); target_pixels = static_cast(dev->model->x_size_ta); target_pixels /= calib_sensor.get_ccd_size_divisor_for_dpi(resolution); target_pixels = static_cast((target_pixels * calib_sensor.optical_res) / MM_PER_INCH); } ScanFlag flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { flags |= ScanFlag::USE_XPA; } ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = start_pixel; session.params.starty = 0; session.params.pixels = target_pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = ColorFilter::RED; session.params.flags = flags; compute_session(dev, session, calib_sensor); pixels = session.output_pixels; DBG(DBG_io, "%s: dpihw =%d\n", __func__, dpihw); DBG(DBG_io, "%s: factor =%d\n", __func__, factor); DBG(DBG_io, "%s: resolution =%d\n", __func__, resolution); DBG(DBG_io, "%s: pixels =%d\n", __func__, pixels); DBG(DBG_io, "%s: black_pixels=%d\n", __func__, black_pixels); init_regs_for_scan_session(dev, calib_sensor, ®s, session); sanei_genesys_set_motor_power(regs, false); // init gain and offset for (unsigned ch = 0; ch < 3; ch++) { bottom[ch] = 10; dev->frontend.set_offset(ch, bottom[ch]); dev->frontend.set_gain(ch, 0); } dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET); // scan with bottom AFE settings dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting first line reading\n", __func__); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("offset_calibration"); scanner_stop_action_no_move(*dev, regs); return; } auto first_line = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); scanner_stop_action_no_move(*dev, regs); if (DBG_LEVEL >= DBG_data) { char fn[40]; std::snprintf(fn, 40, "gl843_bottom_offset_%03d_%03d_%03d.pnm", bottom[0], bottom[1], bottom[2]); sanei_genesys_write_pnm_file(fn, first_line); } for (unsigned ch = 0; ch < 3; ch++) { bottomavg[ch] = dark_average_channel(first_line, black_pixels, ch); DBG(DBG_io2, "%s: bottom avg %d=%d\n", __func__, ch, bottomavg[ch]); } // now top value for (unsigned ch = 0; ch < 3; ch++) { top[ch] = 255; dev->frontend.set_offset(ch, top[ch]); } dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET); // scan with top AFE values dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting second line reading\n", __func__); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); auto second_line = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); scanner_stop_action_no_move(*dev, regs); for (unsigned ch = 0; ch < 3; ch++){ topavg[ch] = dark_average_channel(second_line, black_pixels, ch); DBG(DBG_io2, "%s: top avg %d=%d\n", __func__, ch, topavg[ch]); } pass = 0; std::vector debug_image; size_t debug_image_lines = 0; std::string debug_image_info; /* loop until acceptable level */ while ((pass < 32) && ((top[0] - bottom[0] > 1) || (top[1] - bottom[1] > 1) || (top[2] - bottom[2] > 1))) { pass++; // settings for new scan for (unsigned ch = 0; ch < 3; ch++) { if (top[ch] - bottom[ch] > 1) { dev->frontend.set_offset(ch, (top[ch] + bottom[ch]) / 2); } } dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET); // scan with no move dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting second line reading\n", __func__); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); second_line = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); scanner_stop_action_no_move(*dev, regs); if (DBG_LEVEL >= DBG_data) { char title[100]; std::snprintf(title, 100, "lines: %d pixels_per_line: %d offsets[0..2]: %d %d %d\n", lines, pixels, dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); debug_image_info += title; std::copy(second_line.get_row_ptr(0), second_line.get_row_ptr(0) + second_line.get_row_bytes() * second_line.get_height(), std::back_inserter(debug_image)); debug_image_lines += lines; } for (unsigned ch = 0; ch < 3; ch++) { avg[ch] = dark_average_channel(second_line, black_pixels, ch); DBG(DBG_info, "%s: avg[%d]=%d offset=%d\n", __func__, ch, avg[ch], dev->frontend.get_offset(ch)); } // compute new boundaries for (unsigned ch = 0; ch < 3; ch++) { if (topavg[ch] >= avg[ch]) { topavg[ch] = avg[ch]; top[ch] = dev->frontend.get_offset(ch); } else { bottomavg[ch] = avg[ch]; bottom[ch] = dev->frontend.get_offset(ch); } } } if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_file("gl843_offset_all_desc.txt", reinterpret_cast(debug_image_info.data()), debug_image_info.size()); sanei_genesys_write_pnm_file("gl843_offset_all.pnm", debug_image.data(), session.params.depth, channels, pixels, debug_image_lines); } DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); } /* alternative coarse gain calibration this on uses the settings from offset_calibration and uses only one scanline */ /* with offset and coarse calibration we only want to get our input range into a reasonable shape. the fine calibration of the upper and lower bounds will be done with shading. */ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const { DBG_HELPER_ARGS(dbg, "dpi = %d", dpi); int factor, dpihw; float coeff; int lines; int resolution; if (dev->frontend.layout.type != FrontendType::WOLFSON) return; dpihw = sensor.get_logical_hwdpi(dpi); factor=sensor.optical_res/dpihw; // coarse gain calibration is always done in color mode unsigned channels = 3; /* follow CKSEL */ if (dev->model->sensor_id == SensorId::CCD_KVSS080) { if(dev->settings.xressettings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { flags |= ScanFlag::USE_XPA; } const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = 0; session.params.starty = 0; session.params.pixels = target_pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = flags; compute_session(dev, session, calib_sensor); std::size_t pixels = session.output_pixels; try { init_regs_for_scan_session(dev, calib_sensor, ®s, session); } catch (...) { catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); }); throw; } sanei_genesys_set_motor_power(regs, false); dev->interface->write_registers(regs); dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("coarse_gain_calibration"); scanner_stop_action(*dev); move_back_home(dev, true); return; } auto line = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); scanner_stop_action_no_move(*dev, regs); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl843_gain.pnm", line); } // average value on each channel for (unsigned ch = 0; ch < channels; ch++) { std::vector values; // FIXME: start from the second line because the first line often has artifacts. Probably // caused by unclean cleanup of previous scan for (std::size_t x = pixels / 4; x < (pixels * 3 / 4); x++) { values.push_back(line.get_raw_channel(x, 1, ch)); } // pick target value at 95th percentile of all values. There may be a lot of black values // in transparency scans for example std::sort(values.begin(), values.end()); uint16_t curr_output = values[unsigned((values.size() - 1) * 0.95)]; float target_value = calib_sensor.gain_white_ref * coeff; int code = compute_frontend_gain(curr_output, target_value, dev->frontend.layout.type); dev->frontend.set_gain(ch, code); DBG(DBG_proc, "%s: channel %d, max=%d, target=%d, setting:%d\n", __func__, ch, curr_output, static_cast(target_value), code); } if (dev->model->is_cis) { uint8_t gain0 = dev->frontend.get_gain(0); if (gain0 > dev->frontend.get_gain(1)) { gain0 = dev->frontend.get_gain(1); } if (gain0 > dev->frontend.get_gain(2)) { gain0 = dev->frontend.get_gain(2); } dev->frontend.set_gain(0, gain0); dev->frontend.set_gain(1, gain0); dev->frontend.set_gain(2, gain0); } if (channels == 1) { dev->frontend.set_gain(0, dev->frontend.get_gain(1)); dev->frontend.set_gain(2, dev->frontend.get_gain(1)); } scanner_stop_action(*dev); move_back_home(dev, true); } // wait for lamp warmup by scanning the same line until difference // between 2 scans is below a threshold void CommandSetGl843::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, int* channels, int* total_size) const { DBG_HELPER(dbg); int num_pixels; int dpihw; int resolution; int factor; /* setup scan */ *channels=3; resolution=600; dpihw = sensor.get_logical_hwdpi(resolution); resolution=dpihw; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, *channels, dev->settings.scan_method); factor = calib_sensor.optical_res/dpihw; num_pixels = calib_sensor.sensor_pixels/(factor*2); *total_size = num_pixels * 3 * 1; *reg = dev->reg; ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = num_pixels/2; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 8; session.params.channels = *channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, reg, session); sanei_genesys_set_motor_power(*reg, false); dev->interface->write_registers(*reg); } /** * 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 */ static void gl843_init_gpio(Genesys_Device* dev) { DBG_HELPER(dbg); apply_registers_ordered(dev->gpo.regs, { 0x6e, 0x6f }, [&](const GenesysRegisterSetting& reg) { dev->interface->write_register(reg.address, reg.value); }); } /* * * initialize ASIC from power on condition */ void CommandSetGl843::asic_boot(Genesys_Device* dev, bool cold) const { DBG_HELPER(dbg); uint8_t val; if (cold) { dev->interface->write_register(0x0e, 0x01); dev->interface->write_register(0x0e, 0x00); } if(dev->usb_mode == 1) { val = 0x14; } else { val = 0x11; } dev->interface->write_0x8c(0x0f, val); // test CHKVER val = dev->interface->read_register(REG_0x40); if (val & REG_0x40_CHKVER) { val = dev->interface->read_register(0x00); DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ gl843_init_registers (dev); if (dev->model->model_id == ModelId::CANON_8600F) { // turns on vref control for maximum current of the motor driver dev->interface->write_register(REG_0x6B, 0x72); } else { dev->interface->write_register(REG_0x6B, 0x02); } // Write initial registers dev->interface->write_registers(dev->reg); // Enable DRAM by setting a rising edge on bit 3 of reg 0x0b val = dev->reg.find_reg(0x0b).value & REG_0x0B_DRAMSEL; val = (val | REG_0x0B_ENBDRAM); dev->interface->write_register(REG_0x0B, val); dev->reg.find_reg(0x0b).value = val; if (dev->model->model_id == ModelId::CANON_8400F) { dev->interface->write_0x8c(0x1e, 0x01); dev->interface->write_0x8c(0x10, 0xb4); dev->interface->write_0x8c(0x0f, 0x02); } else if (dev->model->model_id == ModelId::CANON_8600F) { dev->interface->write_0x8c(0x10, 0xc8); } else if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { dev->interface->write_0x8c(0x10, 0xd4); } else { dev->interface->write_0x8c(0x10, 0xb4); } /* CLKSET */ int clock_freq = REG_0x0B_48MHZ; switch (dev->model->model_id) { case ModelId::CANON_8600F: clock_freq = REG_0x0B_60MHZ; break; case ModelId::PLUSTEK_OPTICFILM_7200I: clock_freq = REG_0x0B_30MHZ; break; case ModelId::PLUSTEK_OPTICFILM_7300: case ModelId::PLUSTEK_OPTICFILM_7500I: clock_freq = REG_0x0B_40MHZ; break; default: break; } val = (dev->reg.find_reg(0x0b).value & ~REG_0x0B_CLKSET) | clock_freq; dev->interface->write_register(REG_0x0B, val); dev->reg.find_reg(0x0b).value = val; /* prevent further writings by bulk write register */ dev->reg.remove_reg(0x0b); if (dev->model->model_id != ModelId::CANON_8600F) { // set up end access // FIXME: this is overwritten in gl843_init_gpio dev->interface->write_register(REG_0xA7, 0x04); dev->interface->write_register(REG_0xA9, 0x00); } // set RAM read address dev->interface->write_register(REG_0x29, 0x00); dev->interface->write_register(REG_0x2A, 0x00); dev->interface->write_register(REG_0x2B, 0x00); // setup gpio gl843_init_gpio(dev); scanner_move(*dev, dev->model->default_method, 300, Direction::FORWARD); dev->interface->sleep_ms(100); } /* * * initialize backend and ASIC : registers, motor tables, and gamma tables * then ensure scanner's head is at home */ void CommandSetGl843::init(Genesys_Device* dev) const { DBG_INIT (); DBG_HELPER(dbg); sanei_genesys_asic_init(dev, 0); } void CommandSetGl843::update_hardware_sensors(Genesys_Scanner* s) const { DBG_HELPER(dbg); /* do what is needed to get a new set of events, but try to not lose any of them. */ uint8_t val = s->dev->interface->read_register(REG_0x6D); switch (s->dev->model->gpio_id) { case GpioId::KVSS080: s->buttons[BUTTON_SCAN_SW].write((val & 0x04) == 0); break; case GpioId::G4050: s->buttons[BUTTON_SCAN_SW].write((val & 0x01) == 0); s->buttons[BUTTON_FILE_SW].write((val & 0x02) == 0); s->buttons[BUTTON_EMAIL_SW].write((val & 0x04) == 0); s->buttons[BUTTON_COPY_SW].write((val & 0x08) == 0); break; case GpioId::CANON_4400F: case GpioId::CANON_8400F: default: break; } } /** @brief move sensor to transparency adaptor * Move sensor to the calibration of the transparency adapator (XPA). * @param dev device to use */ void CommandSetGl843::move_to_ta(Genesys_Device* dev) const { DBG_HELPER(dbg); const auto& resolution_settings = dev->model->get_resolution_settings(dev->model->default_method); float resolution = resolution_settings.get_min_resolution_y(); unsigned multiplier = 16; if (dev->model->model_id == ModelId::CANON_8400F) { multiplier = 4; } unsigned feed = static_cast(multiplier * (dev->model->y_offset_sensor_to_ta * resolution) / MM_PER_INCH); scanner_move(*dev, dev->model->default_method, feed, Direction::FORWARD); } /** @brief search for a full width black or white strip. * This function searches for a black or white stripe across the scanning area. * When searching backward, the searched area must completely be of the desired * color since this area will be used for calibration which scans forward. * @param dev scanner device * @param forward true if searching forward, false if searching backward * @param black true if searching for a black strip, false for a white strip */ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const { DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse"); unsigned int pixels, lines, channels; Genesys_Register_Set local_reg; int dpi; unsigned int pass, count, found, x, y; dev->cmd_set->set_fe(dev, sensor, AFE_SET); scanner_stop_action(*dev); /* set up for a gray scan at lowest dpi */ dpi = sanei_genesys_get_lowest_dpi(dev); channels = 1; const auto& calib_sensor = sanei_genesys_find_sensor(dev, dpi, channels, dev->settings.scan_method); /* 10 MM */ /* lines = (10 * dpi) / MM_PER_INCH; */ /* shading calibation is done with dev->motor.base_ydpi */ lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi; pixels = (calib_sensor.sensor_pixels * dpi) / calib_sensor.optical_res; dev->set_head_pos_zero(ScanHeadId::PRIMARY); local_reg = dev->reg; ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::RED; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_SHADING; if (!forward) { session.params.flags = ScanFlag::REVERSE; } compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, &local_reg, session); dev->interface->write_registers(local_reg); dev->cmd_set->begin_scan(dev, calib_sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_strip"); scanner_stop_action(*dev); return; } wait_until_buffer_non_empty(dev); // now we're on target, we can read data auto data = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); scanner_stop_action(*dev); pass = 0; if (DBG_LEVEL >= DBG_data) { char fn[40]; std::snprintf(fn, 40, "gl843_search_strip_%s_%s%02d.pnm", black ? "black" : "white", forward ? "fwd" : "bwd", pass); sanei_genesys_write_pnm_file(fn, data); } /* loop until strip is found or maximum pass number done */ found = 0; while (pass < 20 && !found) { dev->interface->write_registers(local_reg); // now start scan dev->cmd_set->begin_scan(dev, calib_sensor, &local_reg, true); wait_until_buffer_non_empty(dev); // now we're on target, we can read data data = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); scanner_stop_action(*dev); if (DBG_LEVEL >= DBG_data) { char fn[40]; std::snprintf(fn, 40, "gl843_search_strip_%s_%s%02d.pnm", black ? "black" : "white", forward ? "fwd" : "bwd", pass); sanei_genesys_write_pnm_file(fn, data); } /* search data to find black strip */ /* when searching forward, we only need one line of the searched color since we * will scan forward. But when doing backward search, we need all the area of the * same color */ if (forward) { for (y = 0; y < lines && !found; y++) { count = 0; /* count of white/black pixels depending on the color searched */ for (x = 0; x < pixels; x++) { /* when searching for black, detect white pixels */ if (black && data.get_raw_channel(x, y, 0) > 90) { count++; } /* when searching for white, detect black pixels */ if (!black && data.get_raw_channel(x, y, 0) < 60) { count++; } } /* at end of line, if count >= 3%, line is not fully of the desired color * so we must go to next line of the buffer */ /* count*100/pixels < 3 */ if ((count * 100) / pixels < 3) { found = 1; DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, pass, y); } else { DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, (100 * count) / pixels); } } } else /* since calibration scans are done forward, we need the whole area to be of the required color when searching backward */ { count = 0; for (y = 0; y < lines; y++) { /* count of white/black pixels depending on the color searched */ for (x = 0; x < pixels; x++) { // when searching for black, detect white pixels if (black && data.get_raw_channel(x, y, 0) > 90) { count++; } // when searching for white, detect black pixels if (!black && data.get_raw_channel(x, y, 0) < 60) { count++; } } } /* at end of area, if count >= 3%, area is not fully of the desired color * so we must go to next buffer */ if ((count * 100) / (pixels * lines) < 3) { found = 1; DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, (100 * count) / pixels); } } pass++; } if (found) { DBG(DBG_info, "%s: %s strip found\n", __func__, black ? "black" : "white"); } else { throw SaneException(SANE_STATUS_UNSUPPORTED, "%s strip not found", black ? "black" : "white"); } } /** * Send shading calibration data. The buffer is considered to always hold values * for all the channels. */ void CommandSetGl843::send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const { DBG_HELPER(dbg); uint32_t final_size, length, i; uint8_t *buffer; int count,offset; GenesysRegister *r; uint16_t strpixel, endpixel, startx; offset=0; length=size; r = sanei_genesys_get_address(&dev->reg, REG_0x01); if (r->value & REG_0x01_SHDAREA) { /* recompute STRPIXEL used shading calibration so we can * compute offset within data for SHDAREA case */ // FIXME: the following is likely incorrect // start coordinate in optical dpi coordinates startx = (sensor.dummy_pixel / sensor.ccd_pixels_per_system_pixel()) / dev->session.hwdpi_divisor; startx *= dev->session.pixel_count_multiplier; /* current scan coordinates */ strpixel = dev->session.pixel_startx; endpixel = dev->session.pixel_endx; if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8600F) { int half_ccd_factor = dev->session.optical_resolution / sensor.get_logical_hwdpi(dev->session.output_resolution); strpixel /= half_ccd_factor * sensor.ccd_pixels_per_system_pixel(); endpixel /= half_ccd_factor * sensor.ccd_pixels_per_system_pixel(); } /* 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", __func__, strpixel, endpixel, startx); } dev->interface->record_key_value("shading_offset", std::to_string(offset)); dev->interface->record_key_value("shading_length", std::to_string(length)); /* compute and allocate size for final data */ final_size = ((length+251) / 252) * 256; DBG(DBG_io, "%s: final shading size=%04x (length=%d)\n", __func__, final_size, length); std::vector final_data(final_size, 0); /* copy regular shading data to the expected layout */ buffer = final_data.data(); count = 0; /* loop over calibration data */ for (i = 0; i < length; i++) { buffer[count] = data[offset+i]; count++; if ((count % (256*2)) == (252*2)) { count += 4*2; } } dev->interface->write_buffer(0x3c, 0, final_data.data(), count, ScannerInterface::FLAG_SMALL_ADDRESS); } bool CommandSetGl843::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const { (void) dev; return true; } void CommandSetGl843::wait_for_motor_stop(Genesys_Device* dev) const { (void) dev; } std::unique_ptr create_gl843_cmd_set() { return std::unique_ptr(new CommandSetGl843{}); } } // namespace gl843 } // namespace genesys sane-backends-1.0.29/backend/genesys/scanner_interface.cpp0000666000000000000000000000374013615534521020426 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "scanner_interface.h" namespace genesys { ScannerInterface::~ScannerInterface() = default; } // namespace genesys sane-backends-1.0.29/backend/genesys/usb_device.h0000666000000000000000000000724713615534521016540 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_USB_DEVICE_H #define BACKEND_GENESYS_USB_DEVICE_H #include "error.h" #include "../include/sane/sanei_usb.h" #include #include namespace genesys { class IUsbDevice { public: IUsbDevice() = default; IUsbDevice(const IUsbDevice& other) = delete; IUsbDevice& operator=(const IUsbDevice&) = delete; virtual ~IUsbDevice(); virtual bool is_open() const = 0; virtual const std::string& name() const = 0; virtual void open(const char* dev_name) = 0; virtual void clear_halt() = 0; virtual void reset() = 0; virtual void close() = 0; virtual void get_vendor_product(int& vendor, int& product) = 0; virtual void control_msg(int rtype, int reg, int value, int index, int length, std::uint8_t* data) = 0; virtual void bulk_read(std::uint8_t* buffer, std::size_t* size) = 0; virtual void bulk_write(const std::uint8_t* buffer, std::size_t* size) = 0; }; class UsbDevice : public IUsbDevice { public: UsbDevice() = default; ~UsbDevice() override; bool is_open() const override { return is_open_; } const std::string& name() const override { return name_; } void open(const char* dev_name) override; void clear_halt() override; void reset() override; void close() override; void get_vendor_product(int& vendor, int& product) override; void control_msg(int rtype, int reg, int value, int index, int length, std::uint8_t* data) override; void bulk_read(std::uint8_t* buffer, std::size_t* size) override; void bulk_write(const std::uint8_t* buffer, std::size_t* size) override; private: void assert_is_open() const; void set_not_open(); std::string name_; bool is_open_ = false; int device_num_ = 0; }; } // namespace genesys #endif // BACKEND_GENESYS_USB_DEVICE_H sane-backends-1.0.29/backend/genesys/motor.cpp0000666000000000000000000001440413615534521016114 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "motor.h" #include "utilities.h" #include namespace genesys { unsigned MotorSlope::get_table_step_shifted(unsigned step, StepType step_type) const { // first two steps are always equal to the initial speed if (step < 2) { return initial_speed_w >> static_cast(step_type); } step--; float initial_speed_v = 1.0f / initial_speed_w; float speed_v = std::sqrt(initial_speed_v * initial_speed_v + 2 * acceleration * step); return static_cast(1.0f / speed_v) >> static_cast(step_type); } float compute_acceleration_for_steps(unsigned initial_w, unsigned max_w, unsigned steps) { float initial_speed_v = 1.0f / static_cast(initial_w); float max_speed_v = 1.0f / static_cast(max_w); return (max_speed_v * max_speed_v - initial_speed_v * initial_speed_v) / (2 * steps); } MotorSlope MotorSlope::create_from_steps(unsigned initial_w, unsigned max_w, unsigned steps) { MotorSlope slope; slope.initial_speed_w = initial_w; slope.max_speed_w = max_w; slope.acceleration = compute_acceleration_for_steps(initial_w, max_w, steps); return slope; } void MotorSlopeTable::slice_steps(unsigned count) { if (count >= table.size() || count > steps_count) { throw SaneException("Excepssive steps count"); } steps_count = count; } unsigned get_slope_table_max_size(AsicType asic_type) { switch (asic_type) { case AsicType::GL646: case AsicType::GL841: return 255; case AsicType::GL843: case AsicType::GL845: case AsicType::GL846: case AsicType::GL847: case AsicType::GL124: return 1024; default: throw SaneException("Unknown asic type"); } } MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_speed_w, StepType step_type, unsigned steps_alignment, unsigned min_size, unsigned max_size) { DBG_HELPER_ARGS(dbg, "target_speed_w: %d, step_type: %d, steps_alignment: %d, min_size: %d", target_speed_w, static_cast(step_type), steps_alignment, min_size); MotorSlopeTable table; unsigned step_shift = static_cast(step_type); unsigned target_speed_shifted_w = target_speed_w >> step_shift; unsigned max_speed_shifted_w = slope.max_speed_w >> step_shift; if (target_speed_shifted_w < max_speed_shifted_w) { dbg.log(DBG_warn, "failed to reach target speed"); } unsigned final_speed = std::max(target_speed_shifted_w, max_speed_shifted_w); table.table.reserve(max_size); while (table.table.size() < max_size - 1) { unsigned current = slope.get_table_step_shifted(table.table.size(), step_type); if (current <= final_speed) { break; } table.table.push_back(current); table.pixeltime_sum += current; } // make sure the target speed (or the max speed if target speed is too high) is present in // the table table.table.push_back(final_speed); table.pixeltime_sum += table.table.back(); // fill the table up to the specified size while (table.table.size() < max_size - 1 && (table.table.size() % steps_alignment != 0 || table.table.size() < min_size)) { table.table.push_back(table.table.back()); table.pixeltime_sum += table.table.back(); } table.steps_count = table.table.size(); // fill the rest of the table with the final speed table.table.resize(max_size, final_speed); return table; } std::ostream& operator<<(std::ostream& out, const MotorSlope& slope) { out << "MotorSlope{\n" << " initial_speed_w: " << slope.initial_speed_w << '\n' << " max_speed_w: " << slope.max_speed_w << '\n' << " a: " << slope.acceleration << '\n' << '}'; return out; } std::ostream& operator<<(std::ostream& out, const Genesys_Motor& motor) { out << "Genesys_Motor{\n" << " id: " << static_cast(motor.id) << '\n' << " base_ydpi: " << motor.base_ydpi << '\n' << " optical_ydpi: " << motor.optical_ydpi << '\n' << " slopes: " << format_indent_braced_list(4, format_vector_indent_braced(4, "MotorSlope", motor.slopes)) << '}'; return out; } } // namespace genesys sane-backends-1.0.29/backend/genesys/gl646.cpp0000666000000000000000000033117713615534521015627 00000000000000/* sane - Scanner Access Now Easy. 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) 2005-2009 Pierre Willenbrock Copyright (C) 2007 Luke Copyright (C) 2011 Alexey Osipov for HP2400 description and tuning 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "gl646.h" #include "gl646_registers.h" #include "test_settings.h" #include namespace genesys { namespace gl646 { namespace { constexpr unsigned CALIBRATION_LINES = 10; } // namespace static void gl646_send_slope_table(Genesys_Device* dev, int table_nr, const std::vector& slope_table, int steps); /** * reads value from gpio endpoint */ static void gl646_gpio_read(IUsbDevice& usb_dev, uint8_t* value) { DBG_HELPER(dbg); usb_dev.control_msg(REQUEST_TYPE_IN, REQUEST_REGISTER, GPIO_READ, INDEX, 1, value); } /** * writes the given value to gpio endpoint */ static void gl646_gpio_write(IUsbDevice& usb_dev, uint8_t value) { DBG_HELPER_ARGS(dbg, "(0x%02x)", value); usb_dev.control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, GPIO_WRITE, INDEX, 1, &value); } /** * writes the given value to gpio output enable endpoint */ static void gl646_gpio_output_enable(IUsbDevice& usb_dev, uint8_t value) { DBG_HELPER_ARGS(dbg, "(0x%02x)", value); usb_dev.control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, GPIO_OUTPUT_ENABLE, INDEX, 1, &value); } /** * stop scanner's motor * @param dev scanner's device */ static void gl646_stop_motor(Genesys_Device* dev) { DBG_HELPER(dbg); dev->interface->write_register(0x0f, 0x00); } /** * find the closest match in mode tables for the given resolution and scan mode. * @param sensor id of the sensor * @param required required resolution * @param color true is color mode * @return the closest resolution for the sensor and mode */ static unsigned get_closest_resolution(SensorId sensor_id, int required, unsigned channels) { unsigned best_res = 0; unsigned best_diff = 9600; for (const auto& sensor : *s_sensors) { if (sensor_id != sensor.sensor_id) continue; // exit on perfect match if (sensor.resolutions.matches(required) && sensor.matches_channel_count(channels)) { DBG(DBG_info, "%s: match found for %d\n", __func__, required); return required; } // computes distance and keep mode if it is closer than previous if (sensor.matches_channel_count(channels)) { for (auto res : sensor.resolutions.resolutions()) { unsigned curr_diff = std::abs(static_cast(res) - static_cast(required)); if (curr_diff < best_diff) { best_res = res; best_diff = curr_diff; } } } } DBG(DBG_info, "%s: closest match for %d is %d\n", __func__, required, best_res); return best_res; } /** * Returns the cksel values used by the required scan mode. * @param sensor id of the sensor * @param required required resolution * @param color true is color mode * @return cksel value for mode */ static int get_cksel(SensorId sensor_id, int required, unsigned channels) { for (const auto& sensor : *s_sensors) { // exit on perfect match if (sensor.sensor_id == sensor_id && sensor.resolutions.matches(required) && sensor.matches_channel_count(channels)) { unsigned cksel = sensor.ccd_pixels_per_system_pixel(); DBG(DBG_io, "%s: match found for %d (cksel=%d)\n", __func__, required, cksel); return cksel; } } DBG(DBG_error, "%s: failed to find match for %d dpi\n", __func__, required); /* fail safe fallback */ return 1; } void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, const ScanSession& session) const { DBG_HELPER(dbg); session.assert_computed(); debug_dump(DBG_info, sensor); uint32_t move = session.params.starty; int i, nb; Motor_Master *motor = nullptr; uint32_t z1, z2; int feedl; /* for the given resolution, search for master * motor mode setting */ i = 0; nb = sizeof (motor_master) / sizeof (Motor_Master); while (i < nb) { if (dev->model->motor_id == motor_master[i].motor_id && motor_master[i].dpi == session.params.yres && motor_master[i].channels == session.params.channels) { motor = &motor_master[i]; } i++; } if (motor == nullptr) { throw SaneException("unable to find settings for motor %d at %d dpi, color=%d", static_cast(dev->model->motor_id), session.params.yres, session.params.channels); } /* now we can search for the specific sensor settings */ i = 0; // now apply values from settings to registers regs->set16(REG_EXPR, sensor.exposure.red); regs->set16(REG_EXPG, sensor.exposure.green); regs->set16(REG_EXPB, sensor.exposure.blue); for (const auto& reg : sensor.custom_regs) { regs->set8(reg.address, reg.value); } /* now generate slope tables : we are not using generate_slope_table3 yet */ auto slope_table1 = create_slope_table(motor->slope1, motor->slope1.max_speed_w, StepType::FULL, 1, 4, get_slope_table_max_size(AsicType::GL646)); auto slope_table2 = create_slope_table(motor->slope2, motor->slope2.max_speed_w, StepType::FULL, 1, 4, get_slope_table_max_size(AsicType::GL646)); /* R01 */ /* now setup other registers for final scan (ie with shading enabled) */ /* watch dog + shading + scan enable */ regs->find_reg(0x01).value |= REG_0x01_DOGENB | REG_0x01_DVDSET | REG_0x01_SCAN; if (dev->model->is_cis) { regs->find_reg(0x01).value |= REG_0x01_CISSET; } else { regs->find_reg(0x01).value &= ~REG_0x01_CISSET; } /* if device has no calibration, don't enable shading correction */ if (dev->model->flags & GENESYS_FLAG_NO_CALIBRATION) { regs->find_reg(0x01).value &= ~REG_0x01_DVDSET; } regs->find_reg(0x01).value &= ~REG_0x01_FASTMOD; if (motor->fastmod) { regs->find_reg(0x01).value |= REG_0x01_FASTMOD; } /* R02 */ /* allow moving when buffer full by default */ if (!dev->model->is_sheetfed) { dev->reg.find_reg(0x02).value &= ~REG_0x02_ACDCDIS; } else { dev->reg.find_reg(0x02).value |= REG_0x02_ACDCDIS; } /* setup motor power and direction */ sanei_genesys_set_motor_power(*regs, true); if (has_flag(session.params.flags, ScanFlag::REVERSE)) { regs->find_reg(0x02).value |= REG_0x02_MTRREV; } else { regs->find_reg(0x02).value &= ~REG_0x02_MTRREV; } /* fastfed enabled (2 motor slope tables) */ if (motor->fastfed) { regs->find_reg(0x02).value |= REG_0x02_FASTFED; } else { regs->find_reg(0x02).value &= ~REG_0x02_FASTFED; } /* step type */ regs->find_reg(0x02).value &= ~REG_0x02_STEPSEL; switch (motor->steptype) { case StepType::FULL: break; case StepType::HALF: regs->find_reg(0x02).value |= 1; break; case StepType::QUARTER: regs->find_reg(0x02).value |= 2; break; default: regs->find_reg(0x02).value |= 3; break; } if (dev->model->is_sheetfed) { regs->find_reg(0x02).value &= ~REG_0x02_AGOHOME; } else { regs->find_reg(0x02).value |= REG_0x02_AGOHOME; } /* R03 */ regs->find_reg(0x03).value &= ~REG_0x03_AVEENB; // regs->find_reg(0x03).value |= REG_0x03_AVEENB; regs->find_reg(0x03).value &= ~REG_0x03_LAMPDOG; /* select XPA */ regs->find_reg(0x03).value &= ~REG_0x03_XPASEL; if ((session.params.flags & ScanFlag::USE_XPA) != ScanFlag::NONE) { regs->find_reg(0x03).value |= REG_0x03_XPASEL; } regs->state.is_xpa_on = (session.params.flags & ScanFlag::USE_XPA) != ScanFlag::NONE; /* R04 */ /* monochrome / color scan */ switch (session.params.depth) { case 8: regs->find_reg(0x04).value &= ~(REG_0x04_LINEART | REG_0x04_BITSET); break; case 16: regs->find_reg(0x04).value &= ~REG_0x04_LINEART; regs->find_reg(0x04).value |= REG_0x04_BITSET; break; } sanei_genesys_set_dpihw(*regs, sensor, sensor.optical_res); /* gamma enable for scans */ if (dev->model->flags & GENESYS_FLAG_14BIT_GAMMA) { regs->find_reg(0x05).value |= REG_0x05_GMM14BIT; } regs->find_reg(0x05).value &= ~REG_0x05_GMMENB; /* true CIS gray if needed */ if (dev->model->is_cis && session.params.channels == 1 && dev->settings.true_gray) { regs->find_reg(0x05).value |= REG_0x05_LEDADD; } else { regs->find_reg(0x05).value &= ~REG_0x05_LEDADD; } /* HP2400 1200dpi mode tuning */ if (dev->model->sensor_id == SensorId::CCD_HP2400) { /* reset count of dummy lines to zero */ regs->find_reg(0x1e).value &= ~REG_0x1E_LINESEL; if (session.params.xres >= 1200) { /* there must be one dummy line */ regs->find_reg(0x1e).value |= 1 & REG_0x1E_LINESEL; /* GPO12 need to be set to zero */ regs->find_reg(0x66).value &= ~0x20; } else { /* set GPO12 back to one */ regs->find_reg(0x66).value |= 0x20; } } /* motor steps used */ unsigned forward_steps = motor->fwdbwd; unsigned backward_steps = motor->fwdbwd; // the steps count must be different by at most 128, otherwise it's impossible to construct // a proper backtracking curve. We're using slightly lower limit to allow at least a minimum // distance between accelerations (forward_steps, backward_steps) if (slope_table1.steps_count > slope_table2.steps_count + 100) { slope_table2.steps_count += slope_table1.steps_count - 100; } if (slope_table2.steps_count > slope_table1.steps_count + 100) { slope_table1.steps_count += slope_table2.steps_count - 100; } if (slope_table1.steps_count >= slope_table2.steps_count) { backward_steps += (slope_table1.steps_count - slope_table2.steps_count) * 2; } else { forward_steps += (slope_table2.steps_count - slope_table1.steps_count) * 2; } if (forward_steps > 255) { if (backward_steps < (forward_steps - 255)) { throw SaneException("Can't set backtracking parameters without skipping image"); } backward_steps -= forward_steps - 255; } if (backward_steps > 255) { if (forward_steps < (backward_steps - 255)) { throw SaneException("Can't set backtracking parameters without skipping image"); } forward_steps -= backward_steps - 255; } regs->find_reg(0x21).value = slope_table1.steps_count; regs->find_reg(0x24).value = slope_table2.steps_count; regs->find_reg(0x22).value = forward_steps; regs->find_reg(0x23).value = backward_steps; /* CIS scanners read one line per color channel * since gray mode use 'add' we also read 3 channels even not in * color mode */ if (dev->model->is_cis) { regs->set24(REG_LINCNT, session.output_line_count * 3); } else { regs->set24(REG_LINCNT, session.output_line_count); } regs->set16(REG_STRPIXEL, session.pixel_startx); regs->set16(REG_ENDPIXEL, session.pixel_endx); regs->set24(REG_MAXWD, session.output_line_bytes); regs->set16(REG_DPISET, session.output_resolution * session.ccd_size_divisor * sensor.ccd_pixels_per_system_pixel()); regs->set16(REG_LPERIOD, sensor.exposure_lperiod); /* move distance must be adjusted to take into account the extra lines * read to reorder data */ feedl = move; if (session.num_staggered_lines + session.max_color_shift_lines > 0 && feedl != 0) { int feed_offset = ((session.max_color_shift_lines + session.num_staggered_lines) * dev->motor.optical_ydpi) / motor->dpi; if (feedl > feed_offset) { feedl = feedl - feed_offset; } } /* we assume all scans are done with 2 tables */ /* feedl = feed_steps - fast_slope_steps*2 - (slow_slope_steps >> scan_step_type); */ /* but head has moved due to shading calibration => dev->scanhead_position_primary */ if (feedl > 0) { DBG(DBG_info, "%s: initial move=%d\n", __func__, feedl); /* TODO clean up this when I'll fully understand. * for now, special casing each motor */ switch (dev->model->motor_id) { case MotorId::MD_5345: switch (motor->dpi) { case 200: feedl -= 70; break; case 300: feedl -= 70; break; case 400: feedl += 130; break; case 600: feedl += 160; break; case 1200: feedl += 160; break; case 2400: feedl += 180; break; default: break; } break; case MotorId::HP2300: switch (motor->dpi) { case 75: feedl -= 180; break; case 150: feedl += 0; break; case 300: feedl += 30; break; case 600: feedl += 35; break; case 1200: feedl += 45; break; default: break; } break; case MotorId::HP2400: switch (motor->dpi) { case 150: feedl += 150; break; case 300: feedl += 220; break; case 600: feedl += 260; break; case 1200: feedl += 280; /* 300 */ break; case 50: feedl += 0; break; case 100: feedl += 100; break; default: break; } break; /* theorical value */ default: { unsigned step_shift = static_cast(motor->steptype); if (motor->fastfed) { feedl = feedl - 2 * slope_table2.steps_count - (slope_table1.steps_count >> step_shift); } else { feedl = feedl - (slope_table1.steps_count >> step_shift); } break; } } /* security */ if (feedl < 0) feedl = 0; } DBG(DBG_info, "%s: final move=%d\n", __func__, feedl); regs->set24(REG_FEEDL, feedl); regs->find_reg(0x65).value = motor->mtrpwm; sanei_genesys_calculate_zmod(regs->find_reg(0x02).value & REG_0x02_FASTFED, sensor.exposure_lperiod, slope_table1.table, slope_table1.steps_count, move, motor->fwdbwd, &z1, &z2); /* no z1/z2 for sheetfed scanners */ if (dev->model->is_sheetfed) { z1 = 0; z2 = 0; } regs->set16(REG_Z1MOD, z1); regs->set16(REG_Z2MOD, z2); regs->find_reg(0x6b).value = slope_table2.steps_count; regs->find_reg(0x6c).value = (regs->find_reg(0x6c).value & REG_0x6C_TGTIME) | ((z1 >> 13) & 0x38) | ((z2 >> 16) & 0x07); write_control(dev, sensor, session.output_resolution); // setup analog frontend gl646_set_fe(dev, sensor, AFE_SET, session.output_resolution); dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); build_image_pipeline(dev, session); dev->read_active = true; dev->session = session; dev->total_bytes_read = 0; dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines; /* select color filter based on settings */ regs->find_reg(0x04).value &= ~REG_0x04_FILTER; if (session.params.channels == 1) { switch (session.params.color_filter) { case ColorFilter::RED: regs->find_reg(0x04).value |= 0x04; break; case ColorFilter::GREEN: regs->find_reg(0x04).value |= 0x08; break; case ColorFilter::BLUE: regs->find_reg(0x04).value |= 0x0c; break; default: break; } } gl646_send_slope_table(dev, 0, slope_table1.table, regs->get8(0x21)); gl646_send_slope_table(dev, 1, slope_table2.table, regs->get8(0x6b)); } /** copy sensor specific settings */ /* *dev : device infos *regs : regiters to be set extended : do extended set up ccd_size_divisor: set up for half ccd resolution all registers 08-0B, 10-1D, 52-5E are set up. They shouldn't appear anywhere else but in register init */ static void gl646_setup_sensor (Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys_Register_Set * regs) { (void) dev; DBG(DBG_proc, "%s: start\n", __func__); for (const auto& reg_setting : sensor.custom_base_regs) { regs->set8(reg_setting.address, reg_setting.value); } // FIXME: all other drivers don't set exposure here regs_set_exposure(AsicType::GL646, *regs, sensor.exposure); DBG(DBG_proc, "%s: end\n", __func__); } /** * Set all registers to default values after init * @param dev scannerr's device to set */ static void gl646_init_regs (Genesys_Device * dev) { int addr; DBG(DBG_proc, "%s\n", __func__); dev->reg.clear(); for (addr = 1; addr <= 0x0b; addr++) dev->reg.init_reg(addr, 0); for (addr = 0x10; addr <= 0x29; addr++) dev->reg.init_reg(addr, 0); for (addr = 0x2c; addr <= 0x39; addr++) dev->reg.init_reg(addr, 0); for (addr = 0x3d; addr <= 0x3f; addr++) dev->reg.init_reg(addr, 0); for (addr = 0x52; addr <= 0x5e; addr++) dev->reg.init_reg(addr, 0); for (addr = 0x60; addr <= 0x6d; addr++) dev->reg.init_reg(addr, 0); dev->reg.find_reg(0x01).value = 0x20 /*0x22 */ ; /* enable shading, CCD, color, 1M */ dev->reg.find_reg(0x02).value = 0x30 /*0x38 */ ; /* auto home, one-table-move, full step */ if (dev->model->motor_id == MotorId::MD_5345) { dev->reg.find_reg(0x02).value |= 0x01; // half-step } switch (dev->model->motor_id) { case MotorId::MD_5345: dev->reg.find_reg(0x02).value |= 0x01; /* half-step */ break; case MotorId::XP200: /* for this sheetfed scanner, no AGOHOME, nor backtracking */ dev->reg.find_reg(0x02).value = 0x50; break; default: break; } dev->reg.find_reg(0x03).value = 0x1f /*0x17 */ ; /* lamp on */ dev->reg.find_reg(0x04).value = 0x13 /*0x03 */ ; /* 8 bits data, 16 bits A/D, color, Wolfson fe *//* todo: according to spec, 0x0 is reserved? */ switch (dev->model->adc_id) { case AdcId::AD_XP200: dev->reg.find_reg(0x04).value = 0x12; break; default: /* Wolfson frontend */ dev->reg.find_reg(0x04).value = 0x13; break; } const auto& sensor = sanei_genesys_find_sensor_any(dev); dev->reg.find_reg(0x05).value = 0x00; /* 12 bits gamma, disable gamma, 24 clocks/pixel */ sanei_genesys_set_dpihw(dev->reg, sensor, sensor.optical_res); if (dev->model->flags & GENESYS_FLAG_14BIT_GAMMA) { dev->reg.find_reg(0x05).value |= REG_0x05_GMM14BIT; } if (dev->model->adc_id == AdcId::AD_XP200) { dev->reg.find_reg(0x05).value |= 0x01; /* 12 clocks/pixel */ } if (dev->model->sensor_id == SensorId::CCD_HP2300) { dev->reg.find_reg(0x06).value = 0x00; // PWRBIT off, shading gain=4, normal AFE image capture } else { dev->reg.find_reg(0x06).value = 0x18; // PWRBIT on, shading gain=8, normal AFE image capture } gl646_setup_sensor(dev, sensor, &dev->reg); dev->reg.find_reg(0x1e).value = 0xf0; /* watch-dog time */ switch (dev->model->sensor_id) { case SensorId::CCD_HP2300: dev->reg.find_reg(0x1e).value = 0xf0; dev->reg.find_reg(0x1f).value = 0x10; dev->reg.find_reg(0x20).value = 0x20; break; case SensorId::CCD_HP2400: dev->reg.find_reg(0x1e).value = 0x80; dev->reg.find_reg(0x1f).value = 0x10; dev->reg.find_reg(0x20).value = 0x20; break; case SensorId::CCD_HP3670: dev->reg.find_reg(0x19).value = 0x2a; dev->reg.find_reg(0x1e).value = 0x80; dev->reg.find_reg(0x1f).value = 0x10; dev->reg.find_reg(0x20).value = 0x20; break; case SensorId::CIS_XP200: dev->reg.find_reg(0x1e).value = 0x10; dev->reg.find_reg(0x1f).value = 0x01; dev->reg.find_reg(0x20).value = 0x50; break; default: dev->reg.find_reg(0x1f).value = 0x01; dev->reg.find_reg(0x20).value = 0x50; break; } dev->reg.find_reg(0x21).value = 0x08 /*0x20 */ ; /* table one steps number for forward slope curve of the acc/dec */ dev->reg.find_reg(0x22).value = 0x10 /*0x08 */ ; /* steps number of the forward steps for start/stop */ dev->reg.find_reg(0x23).value = 0x10 /*0x08 */ ; /* steps number of the backward steps for start/stop */ dev->reg.find_reg(0x24).value = 0x08 /*0x20 */ ; /* table one steps number backward slope curve of the acc/dec */ dev->reg.find_reg(0x25).value = 0x00; /* scan line numbers (7000) */ dev->reg.find_reg(0x26).value = 0x00 /*0x1b */ ; dev->reg.find_reg(0x27).value = 0xd4 /*0x58 */ ; dev->reg.find_reg(0x28).value = 0x01; /* PWM duty for lamp control */ dev->reg.find_reg(0x29).value = 0xff; dev->reg.find_reg(0x2c).value = 0x02; /* set resolution (600 DPI) */ dev->reg.find_reg(0x2d).value = 0x58; dev->reg.find_reg(0x2e).value = 0x78; /* set black&white threshold high level */ dev->reg.find_reg(0x2f).value = 0x7f; /* set black&white threshold low level */ dev->reg.find_reg(0x30).value = 0x00; /* begin pixel position (16) */ dev->reg.find_reg(0x31).value = sensor.dummy_pixel /*0x10 */ ; /* TGW + 2*TG_SHLD + x */ dev->reg.find_reg(0x32).value = 0x2a /*0x15 */ ; /* end pixel position (5390) */ dev->reg.find_reg(0x33).value = 0xf8 /*0x0e */ ; /* TGW + 2*TG_SHLD + y */ dev->reg.find_reg(0x34).value = sensor.dummy_pixel; dev->reg.find_reg(0x35).value = 0x01 /*0x00 */ ; /* set maximum word size per line, for buffer full control (10800) */ dev->reg.find_reg(0x36).value = 0x00 /*0x2a */ ; dev->reg.find_reg(0x37).value = 0x00 /*0x30 */ ; dev->reg.find_reg(0x38).value = 0x2a; // line period (exposure time = 11000 pixels) */ dev->reg.find_reg(0x39).value = 0xf8; dev->reg.find_reg(0x3d).value = 0x00; /* set feed steps number of motor move */ dev->reg.find_reg(0x3e).value = 0x00; dev->reg.find_reg(0x3f).value = 0x01 /*0x00 */ ; dev->reg.find_reg(0x60).value = 0x00; /* Z1MOD, 60h:61h:(6D b5:b3), remainder for start/stop */ dev->reg.find_reg(0x61).value = 0x00; /* (21h+22h)/LPeriod */ dev->reg.find_reg(0x62).value = 0x00; /* Z2MODE, 62h:63h:(6D b2:b0), remainder for start scan */ dev->reg.find_reg(0x63).value = 0x00; /* (3Dh+3Eh+3Fh)/LPeriod for one-table mode,(21h+1Fh)/LPeriod */ dev->reg.find_reg(0x64).value = 0x00; /* motor PWM frequency */ dev->reg.find_reg(0x65).value = 0x00; /* PWM duty cycle for table one motor phase (63 = max) */ if (dev->model->motor_id == MotorId::MD_5345) { // PWM duty cycle for table one motor phase (63 = max) dev->reg.find_reg(0x65).value = 0x02; } for (const auto& reg : dev->gpo.regs) { dev->reg.set8(reg.address, reg.value); } switch (dev->model->motor_id) { case MotorId::HP2300: case MotorId::HP2400: dev->reg.find_reg(0x6a).value = 0x7f; /* table two steps number for acc/dec */ dev->reg.find_reg(0x6b).value = 0x78; /* table two steps number for acc/dec */ dev->reg.find_reg(0x6d).value = 0x7f; break; case MotorId::MD_5345: dev->reg.find_reg(0x6a).value = 0x42; /* table two fast moving step type, PWM duty for table two */ dev->reg.find_reg(0x6b).value = 0xff; /* table two steps number for acc/dec */ dev->reg.find_reg(0x6d).value = 0x41; /* select deceleration steps whenever go home (0), accel/decel stop time (31 * LPeriod) */ break; case MotorId::XP200: dev->reg.find_reg(0x6a).value = 0x7f; /* table two fast moving step type, PWM duty for table two */ dev->reg.find_reg(0x6b).value = 0x08; /* table two steps number for acc/dec */ dev->reg.find_reg(0x6d).value = 0x01; /* select deceleration steps whenever go home (0), accel/decel stop time (31 * LPeriod) */ break; case MotorId::HP3670: dev->reg.find_reg(0x6a).value = 0x41; /* table two steps number for acc/dec */ dev->reg.find_reg(0x6b).value = 0xc8; /* table two steps number for acc/dec */ dev->reg.find_reg(0x6d).value = 0x7f; break; default: dev->reg.find_reg(0x6a).value = 0x40; /* table two fast moving step type, PWM duty for table two */ dev->reg.find_reg(0x6b).value = 0xff; /* table two steps number for acc/dec */ dev->reg.find_reg(0x6d).value = 0x01; /* select deceleration steps whenever go home (0), accel/decel stop time (31 * LPeriod) */ break; } dev->reg.find_reg(0x6c).value = 0x00; /* peroid times for LPeriod, expR,expG,expB, Z1MODE, Z2MODE (one period time) */ } // Send slope table for motor movement slope_table in machine byte order static void gl646_send_slope_table(Genesys_Device* dev, int table_nr, const std::vector& slope_table, int steps) { DBG_HELPER_ARGS(dbg, "table_nr = %d, steps = %d)=%d .. %d", table_nr, steps, slope_table[0], slope_table[steps - 1]); int dpihw; int start_address; dpihw = dev->reg.find_reg(0x05).value >> 6; if (dpihw == 0) /* 600 dpi */ start_address = 0x08000; else if (dpihw == 1) /* 1200 dpi */ start_address = 0x10000; else if (dpihw == 2) /* 2400 dpi */ start_address = 0x1f800; else { throw SaneException("Unexpected dpihw"); } std::vector table(steps * 2); for (int i = 0; i < steps; i++) { table[i * 2] = slope_table[i] & 0xff; table[i * 2 + 1] = slope_table[i] >> 8; } if (dev->interface->is_mock()) { dev->interface->record_slope_table(table_nr, slope_table); } dev->interface->write_buffer(0x3c, start_address + table_nr * 0x100, table.data(), steps * 2); } // Set values of Analog Device type frontend static void gl646_set_ad_fe(Genesys_Device* dev, uint8_t set) { DBG_HELPER(dbg); int i; if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; // write them to analog frontend dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x01, dev->frontend.regs.get_value(0x01)); } if (set == AFE_SET) { for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x02 + i, dev->frontend.get_gain(i)); } for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x05 + i, dev->frontend.get_offset(i)); } } /* if (set == AFE_POWER_SAVE) { dev->interface->write_fe_register(0x00, dev->frontend.reg[0] | 0x04); } */ } /** set up analog frontend * set up analog frontend * @param dev device to set up * @param set action from AFE_SET, AFE_INIT and AFE_POWERSAVE * @param dpi resolution of the scan since it affects settings */ static void gl646_wm_hp3670(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set, unsigned dpi) { DBG_HELPER(dbg); int i; switch (set) { case AFE_INIT: dev->interface->write_fe_register(0x04, 0x80); dev->interface->sleep_ms(200); dev->interface->write_register(0x50, 0x00); dev->frontend = dev->frontend_initial; dev->interface->write_fe_register(0x01, dev->frontend.regs.get_value(0x01)); dev->interface->write_fe_register(0x02, dev->frontend.regs.get_value(0x02)); gl646_gpio_output_enable(dev->interface->get_usb_device(), 0x07); break; case AFE_POWER_SAVE: dev->interface->write_fe_register(0x01, 0x06); dev->interface->write_fe_register(0x06, 0x0f); return; break; default: /* AFE_SET */ /* mode setup */ i = dev->frontend.regs.get_value(0x03); if (dpi > sensor.optical_res / 2) { /* fe_reg_0x03 must be 0x12 for 1200 dpi in WOLFSON_HP3670. * WOLFSON_HP2400 in 1200 dpi mode works well with * fe_reg_0x03 set to 0x32 or 0x12 but not to 0x02 */ i = 0x12; } dev->interface->write_fe_register(0x03, i); /* offset and sign (or msb/lsb ?) */ for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x20 + i, dev->frontend.get_offset(i)); dev->interface->write_fe_register(0x24 + i, dev->frontend.regs.get_value(0x24 + i)); } // gain for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x28 + i, dev->frontend.get_gain(i)); } } } /** Set values of analog frontend * @param dev device to set * @param set action to execute * @param dpi dpi to setup the AFE */ static void gl646_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set, int dpi) { DBG_HELPER_ARGS(dbg, "%s,%d", set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == AFE_POWER_SAVE ? "powersave" : "huh?", dpi); int i; uint8_t val; /* Analog Device type frontend */ uint8_t frontend_type = dev->reg.find_reg(0x04).value & REG_0x04_FESET; if (frontend_type == 0x02) { gl646_set_ad_fe(dev, set); return; } /* Wolfson type frontend */ if (frontend_type != 0x03) { throw SaneException("unsupported frontend type %d", frontend_type); } /* per frontend function to keep code clean */ switch (dev->model->adc_id) { case AdcId::WOLFSON_HP3670: case AdcId::WOLFSON_HP2400: gl646_wm_hp3670(dev, sensor, set, dpi); return; default: DBG(DBG_proc, "%s(): using old method\n", __func__); break; } /* initialize analog frontend */ if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; // reset only done on init dev->interface->write_fe_register(0x04, 0x80); /* enable GPIO for some models */ if (dev->model->sensor_id == SensorId::CCD_HP2300) { val = 0x07; gl646_gpio_output_enable(dev->interface->get_usb_device(), val); } return; } // set fontend to power saving mode if (set == AFE_POWER_SAVE) { dev->interface->write_fe_register(0x01, 0x02); return; } /* here starts AFE_SET */ /* TODO : base this test on cfg reg3 or a CCD family flag to be created */ /* if (dev->model->ccd_type != SensorId::CCD_HP2300 && dev->model->ccd_type != SensorId::CCD_HP3670 && dev->model->ccd_type != SensorId::CCD_HP2400) */ { dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x02, dev->frontend.regs.get_value(0x02)); } // start with reg3 dev->interface->write_fe_register(0x03, dev->frontend.regs.get_value(0x03)); switch (dev->model->sensor_id) { default: for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x24 + i, dev->frontend.regs.get_value(0x24 + i)); dev->interface->write_fe_register(0x28 + i, dev->frontend.get_gain(i)); dev->interface->write_fe_register(0x20 + i, dev->frontend.get_offset(i)); } break; /* just can't have it to work .... case SensorId::CCD_HP2300: case SensorId::CCD_HP2400: case SensorId::CCD_HP3670: dev->interface->write_fe_register(0x23, dev->frontend.get_offset(1)); dev->interface->write_fe_register(0x28, dev->frontend.get_gain(1)); break; */ } // end with reg1 dev->interface->write_fe_register(0x01, dev->frontend.regs.get_value(0x01)); } /** Set values of analog frontend * this this the public interface, the gl646 as to use one more * parameter to work effectively, hence the redirection * @param dev device to set * @param set action to execute */ void CommandSetGl646::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const { gl646_set_fe(dev, sensor, set, dev->settings.yres); } /** * enters or leaves power saving mode * limited to AFE for now. * @param dev scanner's device * @param enable true to enable power saving, false to leave it */ void CommandSetGl646::save_power(Genesys_Device* dev, bool enable) const { DBG_HELPER_ARGS(dbg, "enable = %d", enable); const auto& sensor = sanei_genesys_find_sensor_any(dev); if (enable) { // gl646_set_fe(dev, sensor, AFE_POWER_SAVE); } else { gl646_set_fe(dev, sensor, AFE_INIT, 0); } } void CommandSetGl646::set_powersaving(Genesys_Device* dev, int delay /* in minutes */) const { DBG_HELPER_ARGS(dbg, "delay = %d", delay); Genesys_Register_Set local_reg(Genesys_Register_Set::SEQUENTIAL); int rate, exposure_time, tgtime, time; local_reg.init_reg(0x01, dev->reg.get8(0x01)); // disable fastmode local_reg.init_reg(0x03, dev->reg.get8(0x03)); // Lamp power control local_reg.init_reg(0x05, dev->reg.get8(0x05) & ~REG_0x05_BASESEL); // 24 clocks/pixel local_reg.init_reg(0x38, 0x00); // line period low local_reg.init_reg(0x39, 0x00); //line period high local_reg.init_reg(0x6c, 0x00); // period times for LPeriod, expR,expG,expB, Z1MODE, Z2MODE if (!delay) local_reg.find_reg(0x03).value &= 0xf0; /* disable lampdog and set lamptime = 0 */ else if (delay < 20) local_reg.find_reg(0x03).value = (local_reg.get8(0x03) & 0xf0) | 0x09; /* enable lampdog and set lamptime = 1 */ else local_reg.find_reg(0x03).value = (local_reg.get8(0x03) & 0xf0) | 0x0f; /* enable lampdog and set lamptime = 7 */ time = delay * 1000 * 60; /* -> msec */ exposure_time = static_cast((time * 32000.0 / (24.0 * 64.0 * (local_reg.get8(0x03) & REG_0x03_LAMPTIM) * 1024.0) + 0.5)); /* 32000 = system clock, 24 = clocks per pixel */ rate = (exposure_time + 65536) / 65536; if (rate > 4) { rate = 8; tgtime = 3; } else if (rate > 2) { rate = 4; tgtime = 2; } else if (rate > 1) { rate = 2; tgtime = 1; } else { rate = 1; tgtime = 0; } local_reg.find_reg(0x6c).value |= tgtime << 6; exposure_time /= rate; if (exposure_time > 65535) exposure_time = 65535; local_reg.find_reg(0x38).value = exposure_time / 256; local_reg.find_reg(0x39).value = exposure_time & 255; dev->interface->write_registers(local_reg); } /** * loads document into scanner * currently only used by XP200 * bit2 (0x04) of gpio is paper event (document in/out) on XP200 * HOMESNR is set if no document in front of sensor, the sequence of events is * paper event -> document is in the sheet feeder * HOMESNR becomes 0 -> document reach sensor * HOMESNR becomes 1 ->document left sensor * paper event -> document is out */ void CommandSetGl646::load_document(Genesys_Device* dev) const { DBG_HELPER(dbg); // FIXME: sequential not really needed in this case Genesys_Register_Set regs(Genesys_Register_Set::SEQUENTIAL); unsigned count; /* no need to load document is flatbed scanner */ if (!dev->model->is_sheetfed) { DBG(DBG_proc, "%s: nothing to load\n", __func__); DBG(DBG_proc, "%s: end\n", __func__); return; } auto status = scanner_read_status(*dev); // home sensor is set if a document is inserted if (status.is_at_home) { /* if no document, waits for a paper event to start loading */ /* with a 60 seconde minutes timeout */ count = 0; std::uint8_t val = 0; do { gl646_gpio_read(dev->interface->get_usb_device(), &val); DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, val); if ((val & 0x04) != 0x04) { DBG(DBG_warn, "%s: no paper detected\n", __func__); } dev->interface->sleep_ms(200); count++; } while (((val & 0x04) != 0x04) && (count < 300)); /* 1 min time out */ if (count == 300) { throw SaneException(SANE_STATUS_NO_DOCS, "timeout waiting for document"); } } /* set up to fast move before scan then move until document is detected */ regs.init_reg(0x01, 0x90); /* AGOME, 2 slopes motor moving */ regs.init_reg(0x02, 0x79); /* motor feeding steps to 0 */ regs.init_reg(0x3d, 0); regs.init_reg(0x3e, 0); regs.init_reg(0x3f, 0); /* 50 fast moving steps */ regs.init_reg(0x6b, 50); /* set GPO */ regs.init_reg(0x66, 0x30); /* stesp NO */ regs.init_reg(0x21, 4); regs.init_reg(0x22, 1); regs.init_reg(0x23, 1); regs.init_reg(0x24, 4); /* generate slope table 2 */ auto slope_table = create_slope_table(MotorSlope::create_from_steps(6000, 2400, 50), 2400, StepType::FULL, 1, 4, get_slope_table_max_size(AsicType::GL646)); // document loading: // send regs // start motor // wait e1 status to become e0 gl646_send_slope_table(dev, 1, slope_table.table, slope_table.steps_count); dev->interface->write_registers(regs); scanner_start_action(*dev, true); count = 0; do { status = scanner_read_status(*dev); dev->interface->sleep_ms(200); count++; } while (status.is_motor_enabled && (count < 300)); if (count == 300) { throw SaneException(SANE_STATUS_JAMMED, "can't load document"); } /* when loading OK, document is here */ dev->document = true; /* set up to idle */ regs.set8(0x02, 0x71); regs.set8(0x3f, 1); regs.set8(0x6b, 8); dev->interface->write_registers(regs); } /** * detects end of document and adjust current scan * to take it into account * used by sheetfed scanners */ void CommandSetGl646::detect_document_end(Genesys_Device* dev) const { DBG_HELPER(dbg); std::uint8_t gpio; unsigned int bytes_left; // test for document presence scanner_read_print_status(*dev); gl646_gpio_read(dev->interface->get_usb_device(), &gpio); DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio); /* detect document event. There one event when the document go in, * then another when it leaves */ if (dev->document && (gpio & 0x04) && (dev->total_bytes_read > 0)) { DBG(DBG_info, "%s: no more document\n", __func__); dev->document = false; /* adjust number of bytes to read: * total_bytes_to_read is the number of byte to send to frontend * total_bytes_read is the number of bytes sent to frontend * read_bytes_left is the number of bytes to read from the scanner */ DBG(DBG_io, "%s: total_bytes_to_read=%zu\n", __func__, dev->total_bytes_to_read); DBG(DBG_io, "%s: total_bytes_read =%zu\n", __func__, dev->total_bytes_read); // amount of data available from scanner is what to scan sanei_genesys_read_valid_words(dev, &bytes_left); unsigned lines_in_buffer = bytes_left / dev->session.output_line_bytes_raw; // we add the number of lines needed to read the last part of the document in unsigned lines_offset = static_cast( (dev->model->y_offset * dev->session.params.yres) / MM_PER_INCH); unsigned remaining_lines = lines_in_buffer + lines_offset; bytes_left = remaining_lines * dev->session.output_line_bytes_raw; if (bytes_left < dev->get_pipeline_source().remaining_bytes()) { dev->get_pipeline_source().set_remaining_bytes(bytes_left); dev->total_bytes_to_read = dev->total_bytes_read + bytes_left; } DBG(DBG_io, "%s: total_bytes_to_read=%zu\n", __func__, dev->total_bytes_to_read); DBG(DBG_io, "%s: total_bytes_read =%zu\n", __func__, dev->total_bytes_read); } } /** * eject document from the feeder * currently only used by XP200 * TODO we currently rely on AGOHOME not being set for sheetfed scanners, * maybe check this flag in eject to let the document being eject automaticaly */ void CommandSetGl646::eject_document(Genesys_Device* dev) const { DBG_HELPER(dbg); // FIXME: SEQUENTIAL not really needed in this case Genesys_Register_Set regs((Genesys_Register_Set::SEQUENTIAL)); unsigned count; std::uint8_t gpio; /* at the end there will be noe more document */ dev->document = false; // first check for document event gl646_gpio_read(dev->interface->get_usb_device(), &gpio); DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio); // test status : paper event + HOMESNR -> no more doc ? auto status = scanner_read_status(*dev); // home sensor is set when document is inserted if (status.is_at_home) { dev->document = false; DBG(DBG_info, "%s: no more document to eject\n", __func__); DBG(DBG_proc, "%s: end\n", __func__); return; } // there is a document inserted, eject it dev->interface->write_register(0x01, 0xb0); /* wait for motor to stop */ do { dev->interface->sleep_ms(200); status = scanner_read_status(*dev); } while (status.is_motor_enabled); /* set up to fast move before scan then move until document is detected */ regs.init_reg(0x01, 0xb0); /* AGOME, 2 slopes motor moving , eject 'backward' */ regs.init_reg(0x02, 0x5d); /* motor feeding steps to 119880 */ regs.init_reg(0x3d, 1); regs.init_reg(0x3e, 0xd4); regs.init_reg(0x3f, 0x48); /* 60 fast moving steps */ regs.init_reg(0x6b, 60); /* set GPO */ regs.init_reg(0x66, 0x30); /* stesp NO */ regs.init_reg(0x21, 4); regs.init_reg(0x22, 1); regs.init_reg(0x23, 1); regs.init_reg(0x24, 4); /* generate slope table 2 */ auto slope_table = create_slope_table(MotorSlope::create_from_steps(10000, 1600, 60), 1600, StepType::FULL, 1, 4, get_slope_table_max_size(AsicType::GL646)); // document eject: // send regs // start motor // wait c1 status to become c8 : HOMESNR and ~MOTFLAG gl646_send_slope_table(dev, 1, slope_table.table, slope_table.steps_count); dev->interface->write_registers(regs); scanner_start_action(*dev, true); /* loop until paper sensor tells paper is out, and till motor is running */ /* use a 30 timeout */ count = 0; do { status = scanner_read_status(*dev); dev->interface->sleep_ms(200); count++; } while (!status.is_at_home && (count < 150)); // read GPIO on exit gl646_gpio_read(dev->interface->get_usb_device(), &gpio); DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio); } // Send the low-level scan command void CommandSetGl646::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, bool start_motor) const { DBG_HELPER(dbg); (void) sensor; // FIXME: SEQUENTIAL not really needed in this case Genesys_Register_Set local_reg(Genesys_Register_Set::SEQUENTIAL); local_reg.init_reg(0x03, reg->get8(0x03)); local_reg.init_reg(0x01, reg->get8(0x01) | REG_0x01_SCAN); if (start_motor) { local_reg.init_reg(0x0f, 0x01); } else { local_reg.init_reg(0x0f, 0x00); // do not start motor yet } dev->interface->write_registers(local_reg); dev->advance_head_pos_by_session(ScanHeadId::PRIMARY); } // Send the stop scan command static void end_scan_impl(Genesys_Device* dev, Genesys_Register_Set* reg, bool check_stop, bool eject) { DBG_HELPER_ARGS(dbg, "check_stop = %d, eject = %d", check_stop, eject); scanner_stop_action_no_move(*dev, *reg); unsigned wait_limit_seconds = 30; /* for sheetfed scanners, we may have to eject document */ if (dev->model->is_sheetfed) { if (eject && dev->document) { dev->cmd_set->eject_document(dev); } wait_limit_seconds = 3; } if (is_testing_mode()) { return; } dev->interface->sleep_ms(100); if (check_stop) { for (unsigned i = 0; i < wait_limit_seconds * 10; i++) { if (scanner_is_motor_stopped(*dev)) { return; } dev->interface->sleep_ms(100); } throw SaneException(SANE_STATUS_IO_ERROR, "could not stop motor"); } } // Send the stop scan command void CommandSetGl646::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg, bool check_stop) const { end_scan_impl(dev, reg, check_stop, false); } /** * parks head * @param dev scanner's device * @param wait_until_home true if the function waits until head parked */ void CommandSetGl646::move_back_home(Genesys_Device* dev, bool wait_until_home) const { DBG_HELPER_ARGS(dbg, "wait_until_home = %d\n", wait_until_home); int i; int loop = 0; auto status = scanner_read_status(*dev); if (status.is_at_home) { DBG(DBG_info, "%s: end since already at home\n", __func__); dev->set_head_pos_zero(ScanHeadId::PRIMARY); return; } /* stop motor if needed */ if (status.is_motor_enabled) { gl646_stop_motor(dev); dev->interface->sleep_ms(200); } /* when scanhead is moving then wait until scanhead stops or timeout */ DBG(DBG_info, "%s: ensuring that motor is off\n", __func__); for (i = 400; i > 0; i--) { // do not wait longer than 40 seconds, count down to get i = 0 when busy status = scanner_read_status(*dev); if (!status.is_motor_enabled && status.is_at_home) { DBG(DBG_info, "%s: already at home and not moving\n", __func__); dev->set_head_pos_zero(ScanHeadId::PRIMARY); return; } if (!status.is_motor_enabled) { break; } dev->interface->sleep_ms(100); } if (!i) /* the loop counted down to 0, scanner still is busy */ { dev->set_head_pos_unknown(); throw SaneException(SANE_STATUS_DEVICE_BUSY, "motor is still on: device busy"); } // setup for a backward scan of 65535 steps, with no actual data reading auto resolution = sanei_genesys_get_lowest_dpi(dev); const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 3, dev->model->default_method); ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = 0; session.params.starty = 65535; session.params.pixels = 600; session.params.requested_pixels = 600; session.params.lines = 1; session.params.depth = 8; session.params.channels = 3; session.params.scan_method = dev->model->default_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = ColorFilter::RED; session.params.flags = ScanFlag::USE_XCORRECTION | ScanFlag::REVERSE; if (dev->model->default_method == ScanMethod::TRANSPARENCY) { session.params.flags |= ScanFlag::USE_XPA; } compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &dev->reg, session); /* backward , no actual data scanned TODO more setup flags to avoid this register manipulations ? */ regs_set_optical_off(dev->model->asic_type, dev->reg); // sets frontend gl646_set_fe(dev, sensor, AFE_SET, resolution); /* write scan registers */ try { dev->interface->write_registers(dev->reg); } catch (...) { DBG(DBG_error, "%s: failed to bulk write registers\n", __func__); } /* registers are restored to an iddl state, give up if no head to park */ if (dev->model->is_sheetfed) { DBG(DBG_proc, "%s: end \n", __func__); return; } // starts scan { // this is effectively the same as dev->cmd_set->begin_scan(dev, sensor, &dev->reg, true); // except that we don't modify the head position calculations // FIXME: SEQUENTIAL not really needed in this case Genesys_Register_Set scan_local_reg(Genesys_Register_Set::SEQUENTIAL); scan_local_reg.init_reg(0x03, dev->reg.get8(0x03)); scan_local_reg.init_reg(0x01, dev->reg.get8(0x01) | REG_0x01_SCAN); scan_local_reg.init_reg(0x0f, 0x01); dev->interface->write_registers(scan_local_reg); } if (is_testing_mode()) { dev->interface->test_checkpoint("move_back_home"); dev->set_head_pos_zero(ScanHeadId::PRIMARY); return; } /* loop until head parked */ if (wait_until_home) { while (loop < 300) /* do not wait longer then 30 seconds */ { auto status = scanner_read_status(*dev); if (status.is_at_home) { DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_proc, "%s: end\n", __func__); dev->interface->sleep_ms(500); dev->set_head_pos_zero(ScanHeadId::PRIMARY); return; } dev->interface->sleep_ms(100); ++loop; } // when we come here then the scanner needed too much time for this, so we better // stop the motor catch_all_exceptions(__func__, [&](){ gl646_stop_motor (dev); }); catch_all_exceptions(__func__, [&](){ end_scan_impl(dev, &dev->reg, true, false); }); dev->set_head_pos_unknown(); throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home"); } DBG(DBG_info, "%s: scanhead is still moving\n", __func__); } /** * Automatically set top-left edge of the scan area by scanning an * area at 300 dpi from very top of scanner * @param dev device stucture describing the scanner */ void CommandSetGl646::search_start_position(Genesys_Device* dev) const { DBG_HELPER(dbg); Genesys_Settings settings; unsigned int resolution, x, y; /* we scan at 300 dpi */ resolution = get_closest_resolution(dev->model->sensor_id, 300, 1); // FIXME: the current approach of doing search only for one resolution does not work on scanners // whith employ different sensors with potentially different settings. const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 1, dev->model->default_method); /* fill settings for a gray level scan */ settings.scan_method = dev->model->default_method; settings.scan_mode = ScanColorMode::GRAY; settings.xres = resolution; settings.yres = resolution; settings.tl_x = 0; settings.tl_y = 0; settings.pixels = 600; settings.requested_pixels = settings.pixels; settings.lines = dev->model->search_lines; settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; // scan the desired area std::vector data; simple_scan(dev, sensor, settings, true, true, false, data, "search_start_position"); // handle stagger case : reorder gray data and thus loose some lines auto staggered_lines = dev->session.num_staggered_lines; if (staggered_lines > 0) { DBG(DBG_proc, "%s: 'un-staggering'\n", __func__); for (y = 0; y < settings.lines - staggered_lines; y++) { /* one point out of 2 is 'unaligned' */ for (x = 0; x < settings.pixels; x += 2) { data[y * settings.pixels + x] = data[(y + staggered_lines) * settings.pixels + x]; } } /* correct line number */ settings.lines -= staggered_lines; } if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl646_search_position.pnm", data.data(), settings.depth, 1, settings.pixels, settings.lines); } // now search reference points on the data for (auto& sensor_update : sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) { sanei_genesys_search_reference_point(dev, sensor_update, data.data(), 0, resolution, settings.pixels, settings.lines); } } /** * internally overriden during effective calibration * sets up register for coarse gain calibration */ void CommandSetGl646::init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); (void) dev; (void) sensor; (void) regs; } /** * init registers for shading calibration * we assume that scanner's head is on an area suiting shading calibration. * We scan a full scan width area by the shading line number for the device * at either at full sensor's resolution or half depending upon ccd_size_divisor * @param dev scanner's device */ void CommandSetGl646::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); (void) regs; Genesys_Settings settings; int cksel = 1; /* fill settings for scan : always a color scan */ int channels = 3; const auto& calib_sensor = sanei_genesys_find_sensor(dev, dev->settings.xres, channels, dev->settings.scan_method); unsigned ccd_size_divisor = calib_sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres); settings.scan_method = dev->settings.scan_method; settings.scan_mode = dev->settings.scan_mode; if (!dev->model->is_cis) { // FIXME: always a color scan, but why don't we set scan_mode to COLOR_SINGLE_PASS always? settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; } settings.xres = sensor.optical_res / ccd_size_divisor; cksel = get_cksel(dev->model->sensor_id, dev->settings.xres, channels); settings.xres = settings.xres / cksel; settings.yres = settings.xres; settings.tl_x = 0; settings.tl_y = 0; settings.pixels = (calib_sensor.sensor_pixels * settings.xres) / calib_sensor.optical_res; settings.requested_pixels = settings.pixels; dev->calib_lines = dev->model->shading_lines; settings.lines = dev->calib_lines * (3 - ccd_size_divisor); settings.depth = 16; settings.color_filter = dev->settings.color_filter; settings.disable_interpolation = dev->settings.disable_interpolation; settings.threshold = dev->settings.threshold; // we don't want top offset, but we need right margin to be the same than the one for the final // scan setup_for_scan(dev, calib_sensor, &dev->reg, settings, true, false, false, false); /* used when sending shading calibration data */ dev->calib_pixels = settings.pixels; dev->calib_channels = dev->session.params.channels; if (!dev->model->is_cis) { dev->calib_channels = 3; } /* no shading */ dev->reg.find_reg(0x01).value &= ~REG_0x01_DVDSET; dev->reg.find_reg(0x02).value |= REG_0x02_ACDCDIS; /* ease backtracking */ dev->reg.find_reg(0x02).value &= ~(REG_0x02_FASTFED | REG_0x02_AGOHOME); dev->reg.find_reg(0x05).value &= ~REG_0x05_GMMENB; sanei_genesys_set_motor_power(dev->reg, false); /* TODO another flag to setup regs ? */ /* enforce needed LINCNT, getting rid of extra lines for color reordering */ if (!dev->model->is_cis) { dev->reg.set24(REG_LINCNT, dev->calib_lines); } else { dev->reg.set24(REG_LINCNT, dev->calib_lines * 3); } /* copy reg to calib_reg */ dev->calib_reg = dev->reg; DBG(DBG_info, "%s:\n\tdev->settings.xres=%d\n\tdev->settings.yres=%d\n", __func__, dev->settings.xres, dev->settings.yres); } bool CommandSetGl646::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const { return dev->is_head_pos_known(ScanHeadId::PRIMARY) && dev->head_pos(ScanHeadId::PRIMARY) && dev->settings.scan_method == ScanMethod::FLATBED; } /** * set up registers for the actual scan. The scan's parameters are given * through the device settings. It allocates the scan buffers. */ void CommandSetGl646::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); debug_dump(DBG_info, dev->settings); ScanSession session = calculate_scan_session(dev, sensor, dev->settings); init_regs_for_scan_session(dev, sensor, &dev->reg, session); /* gamma is only enabled at final scan time */ if (dev->settings.depth < 16) { dev->reg.find_reg(0x05).value |= REG_0x05_GMMENB; } } /** * set up registers for the actual scan. The scan's parameters are given * through the device settings. It allocates the scan buffers. * @param dev scanner's device * @param regs registers to set up * @param settings settings of scan * @param split true if move to scan area is split from scan, false is * scan first moves to area * @param xcorrection take x geometry correction into account (fixed and detected offsets) * @param ycorrection take y geometry correction into account */ static void setup_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set*regs, Genesys_Settings settings, bool split, bool xcorrection, bool ycorrection, bool reverse) { DBG_HELPER(dbg); debug_dump(DBG_info, dev->settings); // compute distance to move float move = 0; // XXX STEF XXX MD5345 -> optical_ydpi, other base_ydpi => half/full step ? */ if (!split) { if (!dev->model->is_sheetfed) { if (ycorrection) { move = static_cast(dev->model->y_offset); } // add tl_y to base movement } move += static_cast(settings.tl_y); if (move < 0) { DBG(DBG_error, "%s: overriding negative move value %f\n", __func__, move); move = 0; } } move = static_cast((move * dev->motor.optical_ydpi) / MM_PER_INCH); DBG(DBG_info, "%s: move=%f steps\n", __func__, move); float start = static_cast(settings.tl_x); if (xcorrection) { if (settings.scan_method == ScanMethod::FLATBED) { start += static_cast(dev->model->x_offset); } else { start += static_cast(dev->model->x_offset_ta); } } start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = settings.xres; session.params.yres = settings.yres; session.params.startx = static_cast(start); session.params.starty = static_cast(move); session.params.pixels = settings.pixels; session.params.requested_pixels = settings.requested_pixels; session.params.lines = settings.lines; session.params.depth = settings.depth; session.params.channels = settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = settings.scan_mode; session.params.color_filter = settings.color_filter; session.params.flags = ScanFlag::NONE; if (settings.scan_method == ScanMethod::TRANSPARENCY) { session.params.flags |= ScanFlag::USE_XPA; } if (xcorrection) { session.params.flags |= ScanFlag::USE_XCORRECTION; } if (reverse) { session.params.flags |= ScanFlag::REVERSE; } compute_session(dev, session, sensor); dev->cmd_set->init_regs_for_scan_session(dev, sensor, regs, session); } /** * this function send gamma table to ASIC */ void CommandSetGl646::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); int size; int address; int bits; /* gamma table size */ if (dev->model->flags & GENESYS_FLAG_14BIT_GAMMA) { size = 16384; bits = 14; } else { size = 4096; bits = 12; } /* allocate temporary gamma tables: 16 bits words, 3 channels */ std::vector gamma(size * 2 * 3); sanei_genesys_generate_gamma_buffer(dev, sensor, bits, size-1, size, gamma.data()); /* table address */ switch (dev->reg.find_reg(0x05).value >> 6) { case 0: /* 600 dpi */ address = 0x09000; break; case 1: /* 1200 dpi */ address = 0x11000; break; case 2: /* 2400 dpi */ address = 0x20000; break; default: throw SaneException("invalid dpi"); } dev->interface->write_buffer(0x3c, address, gamma.data(), size * 2 * 3); } /** @brief this function does the led calibration. * this function does the led calibration by scanning one line of the calibration * area below scanner's top on white strip. The scope of this function is * currently limited to the XP200 */ SensorExposure CommandSetGl646::led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); (void) regs; int total_size; unsigned int i, j; int val; int avg[3], avga, avge; int turn; uint16_t expr, expg, expb; Genesys_Settings settings; SANE_Int resolution; unsigned channels = dev->settings.get_channels(); /* get led calibration resolution */ if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS) { settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; } else { settings.scan_mode = ScanColorMode::GRAY; } resolution = get_closest_resolution(dev->model->sensor_id, sensor.optical_res, channels); /* offset calibration is always done in color mode */ settings.scan_method = dev->model->default_method; settings.xres = resolution; settings.yres = resolution; settings.tl_x = 0; settings.tl_y = 0; settings.pixels = (sensor.sensor_pixels * resolution) / sensor.optical_res; settings.requested_pixels = settings.pixels; settings.lines = 1; settings.depth = 16; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; /* colors * bytes_per_color * scan lines */ total_size = settings.pixels * channels * 2 * 1; std::vector line(total_size); /* we try to get equal bright leds here: loop: average per color adjust exposure times */ expr = sensor.exposure.red; expg = sensor.exposure.green; expb = sensor.exposure.blue; turn = 0; auto calib_sensor = sensor; bool acceptable = false; do { calib_sensor.exposure.red = expr; calib_sensor.exposure.green = expg; calib_sensor.exposure.blue = expb; DBG(DBG_info, "%s: starting first line reading\n", __func__); simple_scan(dev, calib_sensor, settings, false, true, false, line, "led_calibration"); if (is_testing_mode()) { return calib_sensor.exposure; } if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl646_led_%02d.pnm", turn); sanei_genesys_write_pnm_file(fn, line.data(), 16, channels, settings.pixels, 1); } acceptable = true; for (j = 0; j < channels; j++) { avg[j] = 0; for (i = 0; i < settings.pixels; i++) { if (dev->model->is_cis) val = line[i * 2 + j * 2 * settings.pixels + 1] * 256 + line[i * 2 + j * 2 * settings.pixels]; else val = line[i * 2 * channels + 2 * j + 1] * 256 + line[i * 2 * channels + 2 * j]; avg[j] += val; } avg[j] /= settings.pixels; } DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); acceptable = true; if (!acceptable) { avga = (avg[0] + avg[1] + avg[2]) / 3; expr = (expr * avga) / avg[0]; expg = (expg * avga) / avg[1]; expb = (expb * avga) / avg[2]; /* keep exposure time in a working window */ avge = (expr + expg + expb) / 3; if (avge > 0x2000) { expr = (expr * 0x2000) / avge; expg = (expg * 0x2000) / avge; expb = (expb * 0x2000) / avge; } if (avge < 0x400) { expr = (expr * 0x400) / avge; expg = (expg * 0x400) / avge; expb = (expb * 0x400) / avge; } } turn++; } while (!acceptable && turn < 100); DBG(DBG_info,"%s: acceptable exposure: 0x%04x,0x%04x,0x%04x\n", __func__, expr, expg, expb); // BUG: we don't store the result of the last iteration to the sensor return calib_sensor.exposure; } /** * average dark pixels of a scan */ static int dark_average (uint8_t * data, unsigned int pixels, unsigned int lines, unsigned int channels, unsigned int black) { unsigned int i, j, k, average, count; unsigned int avg[3]; uint8_t val; /* computes average value on black margin */ for (k = 0; k < channels; k++) { avg[k] = 0; count = 0; for (i = 0; i < lines; i++) { for (j = 0; j < black; j++) { val = data[i * channels * pixels + j + k]; avg[k] += val; count++; } } if (count) avg[k] /= count; DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } average = 0; for (i = 0; i < channels; i++) average += avg[i]; average /= channels; DBG(DBG_info, "%s: average = %d\n", __func__, average); return average; } /** @brief calibration for AD frontend devices * we do simple scan until all black_pixels are higher than 0, * raising offset at each turn. */ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); (void) sensor; unsigned int channels; int pass = 0; SANE_Int resolution; Genesys_Settings settings; unsigned int x, y, adr, min; unsigned int bottom, black_pixels; channels = 3; resolution = get_closest_resolution(dev->model->sensor_id, sensor.optical_res, channels); const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED); black_pixels = (calib_sensor.black_pixels * resolution) / calib_sensor.optical_res; DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); settings.scan_method = dev->model->default_method; settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; settings.xres = resolution; settings.yres = resolution; settings.tl_x = 0; settings.tl_y = 0; settings.pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res; settings.requested_pixels = settings.pixels; settings.lines = CALIBRATION_LINES; settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; /* scan first line of data with no gain */ dev->frontend.set_gain(0, 0); dev->frontend.set_gain(1, 0); dev->frontend.set_gain(2, 0); std::vector line; /* scan with no move */ bottom = 1; do { pass++; dev->frontend.set_offset(0, bottom); dev->frontend.set_offset(1, bottom); dev->frontend.set_offset(2, bottom); simple_scan(dev, calib_sensor, settings, false, true, false, line, "ad_fe_offset_calibration"); if (is_testing_mode()) { return; } if (DBG_LEVEL >= DBG_data) { char title[30]; std::snprintf(title, 30, "gl646_offset%03d.pnm", static_cast(bottom)); sanei_genesys_write_pnm_file (title, line.data(), 8, channels, settings.pixels, settings.lines); } min = 0; for (y = 0; y < settings.lines; y++) { for (x = 0; x < black_pixels; x++) { adr = (x + y * settings.pixels) * channels; if (line[adr] > min) min = line[adr]; if (line[adr + 1] > min) min = line[adr + 1]; if (line[adr + 2] > min) min = line[adr + 2]; } } DBG(DBG_io2, "%s: pass=%d, min=%d\n", __func__, pass, min); bottom++; } while (pass < 128 && min == 0); if (pass == 128) { throw SaneException(SANE_STATUS_INVAL, "failed to find correct offset"); } DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); } /** * This function does the offset calibration by scanning one line of the calibration * area below scanner's top. There is a black margin and the remaining is white. * genesys_search_start() must have been called so that the offsets and margins * are already known. * @param dev scanner's device */ void CommandSetGl646::offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); (void) regs; unsigned int channels; int pass = 0, avg; Genesys_Settings settings; int topavg, bottomavg; int top, bottom, black_pixels; if (dev->model->adc_id == AdcId::AD_XP200) { ad_fe_offset_calibration(dev, sensor); return; } DBG(DBG_proc, "%s: start\n", __func__); // TODO /* setup for a RGB scan, one full sensor's width line */ /* resolution is the one from the final scan */ channels = 3; int resolution = get_closest_resolution(dev->model->sensor_id, dev->settings.xres, channels); const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED); black_pixels = (calib_sensor.black_pixels * resolution) / calib_sensor.optical_res; DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); settings.scan_method = dev->model->default_method; settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; settings.xres = resolution; settings.yres = resolution; settings.tl_x = 0; settings.tl_y = 0; settings.pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res; settings.requested_pixels = settings.pixels; settings.lines = CALIBRATION_LINES; settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; /* scan first line of data with no gain, but with offset from * last calibration */ dev->frontend.set_gain(0, 0); dev->frontend.set_gain(1, 0); dev->frontend.set_gain(2, 0); /* scan with no move */ bottom = 90; dev->frontend.set_offset(0, bottom); dev->frontend.set_offset(1, bottom); dev->frontend.set_offset(2, bottom); std::vector first_line, second_line; simple_scan(dev, calib_sensor, settings, false, true, false, first_line, "offset_first_line"); if (DBG_LEVEL >= DBG_data) { char title[30]; std::snprintf(title, 30, "gl646_offset%03d.pnm", bottom); sanei_genesys_write_pnm_file(title, first_line.data(), 8, channels, settings.pixels, settings.lines); } bottomavg = dark_average(first_line.data(), settings.pixels, settings.lines, channels, black_pixels); DBG(DBG_io2, "%s: bottom avg=%d\n", __func__, bottomavg); /* now top value */ top = 231; dev->frontend.set_offset(0, top); dev->frontend.set_offset(1, top); dev->frontend.set_offset(2, top); simple_scan(dev, calib_sensor, settings, false, true, false, second_line, "offset_second_line"); if (DBG_LEVEL >= DBG_data) { char title[30]; std::snprintf(title, 30, "gl646_offset%03d.pnm", top); sanei_genesys_write_pnm_file (title, second_line.data(), 8, channels, settings.pixels, settings.lines); } topavg = dark_average(second_line.data(), settings.pixels, settings.lines, channels, black_pixels); DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg); if (is_testing_mode()) { return; } /* loop until acceptable level */ while ((pass < 32) && (top - bottom > 1)) { pass++; /* settings for new scan */ dev->frontend.set_offset(0, (top + bottom) / 2); dev->frontend.set_offset(1, (top + bottom) / 2); dev->frontend.set_offset(2, (top + bottom) / 2); // scan with no move simple_scan(dev, calib_sensor, settings, false, true, false, second_line, "offset_calibration_i"); if (DBG_LEVEL >= DBG_data) { char title[30]; std::snprintf(title, 30, "gl646_offset%03d.pnm", dev->frontend.get_offset(1)); sanei_genesys_write_pnm_file (title, second_line.data(), 8, channels, settings.pixels, settings.lines); } avg = dark_average (second_line.data(), settings.pixels, settings.lines, channels, black_pixels); DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.get_offset(1)); /* compute new boundaries */ if (topavg == avg) { topavg = avg; top = dev->frontend.get_offset(1); } else { bottomavg = avg; bottom = dev->frontend.get_offset(1); } } DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); } /** @brief gain calibration for Analog Device frontends * Alternative coarse gain calibration */ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) { DBG_HELPER(dbg); (void) sensor; (void) regs; unsigned int i, channels, val; unsigned int size, count, resolution, pass; float average; Genesys_Settings settings; char title[32]; /* setup for a RGB scan, one full sensor's width line */ /* resolution is the one from the final scan */ channels = 3; resolution = get_closest_resolution(dev->model->sensor_id, dpi, channels); const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, ScanMethod::FLATBED); settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; settings.scan_method = dev->model->default_method; settings.xres = resolution; settings.yres = resolution; settings.tl_x = 0; settings.tl_y = 0; settings.pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res; settings.requested_pixels = settings.pixels; settings.lines = CALIBRATION_LINES; settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; size = channels * settings.pixels * settings.lines; /* start gain value */ dev->frontend.set_gain(0, 1); dev->frontend.set_gain(1, 1); dev->frontend.set_gain(2, 1); average = 0; pass = 0; std::vector line; // loop until each channel raises to acceptable level while ((average < calib_sensor.gain_white_ref) && (pass < 30)) { // scan with no move simple_scan(dev, calib_sensor, settings, false, true, false, line, "ad_fe_coarse_gain_calibration"); /* log scanning data */ if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl646_alternative_gain%02d.pnm", pass); sanei_genesys_write_pnm_file(title, line.data(), 8, channels, settings.pixels, settings.lines); } pass++; /* computes white average */ average = 0; count = 0; for (i = 0; i < size; i++) { val = line[i]; average += val; count++; } average = average / count; uint8_t gain0 = dev->frontend.get_gain(0); // adjusts gain for the channel if (average < calib_sensor.gain_white_ref) { gain0 += 1; } dev->frontend.set_gain(0, gain0); dev->frontend.set_gain(1, gain0); dev->frontend.set_gain(2, gain0); DBG(DBG_proc, "%s: average = %.2f, gain = %d\n", __func__, average, gain0); } DBG(DBG_info, "%s: gains=(%d,%d,%d)\n", __func__, dev->frontend.get_gain(0), dev->frontend.get_gain(1), dev->frontend.get_gain(2)); } /** * Alternative coarse gain calibration * this on uses the settings from offset_calibration. First scan moves so * we can go to calibration area for XPA. * @param dev device for scan * @param dpi resolutnio to calibrate at */ void CommandSetGl646::coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const { DBG_HELPER(dbg); (void) dpi; unsigned int i, j, k, channels, val, maximum, idx; unsigned int count, resolution, pass; float average[3]; Genesys_Settings settings; char title[32]; if (dev->model->sensor_id == SensorId::CIS_XP200) { return ad_fe_coarse_gain_calibration(dev, sensor, regs, sensor.optical_res); } /* setup for a RGB scan, one full sensor's width line */ /* resolution is the one from the final scan */ channels = 3; /* we are searching a sensor resolution */ resolution = get_closest_resolution(dev->model->sensor_id, dev->settings.xres, channels); const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, ScanMethod::FLATBED); settings.scan_method = dev->settings.scan_method; settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; settings.xres = resolution; settings.yres = resolution; settings.tl_y = 0; if (settings.scan_method == ScanMethod::FLATBED) { settings.tl_x = 0; settings.pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res; } else { settings.tl_x = dev->model->x_offset_ta; settings.pixels = static_cast((dev->model->x_size_ta * resolution) / MM_PER_INCH); } settings.requested_pixels = settings.pixels; settings.lines = CALIBRATION_LINES; settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; /* start gain value */ dev->frontend.set_gain(0, 1); dev->frontend.set_gain(1, 1); dev->frontend.set_gain(2, 1); if (channels > 1) { average[0] = 0; average[1] = 0; average[2] = 0; idx = 0; } else { average[0] = 255; average[1] = 255; average[2] = 255; switch (dev->settings.color_filter) { case ColorFilter::RED: idx = 0; break; case ColorFilter::GREEN: idx = 1; break; case ColorFilter::BLUE: idx = 2; break; default: idx = 0; break; // should not happen } average[idx] = 0; } pass = 0; std::vector line; /* loop until each channel raises to acceptable level */ while (((average[0] < calib_sensor.gain_white_ref) || (average[1] < calib_sensor.gain_white_ref) || (average[2] < calib_sensor.gain_white_ref)) && (pass < 30)) { // scan with no move simple_scan(dev, calib_sensor, settings, false, true, false, line, "coarse_gain_calibration"); /* log scanning data */ if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl646_gain%02d.pnm", pass); sanei_genesys_write_pnm_file(title, line.data(), 8, channels, settings.pixels, settings.lines); } pass++; /* average high level for each channel and compute gain to reach the target code we only use the central half of the CCD data */ for (k = idx; k < idx + channels; k++) { /* we find the maximum white value, so we can deduce a threshold to average white values */ maximum = 0; for (i = 0; i < settings.lines; i++) { for (j = 0; j < settings.pixels; j++) { val = line[i * channels * settings.pixels + j + k]; if (val > maximum) maximum = val; } } /* threshold */ maximum = static_cast(maximum * 0.9); /* computes white average */ average[k] = 0; count = 0; for (i = 0; i < settings.lines; i++) { for (j = 0; j < settings.pixels; j++) { /* averaging only white points allow us not to care about dark margins */ val = line[i * channels * settings.pixels + j + k]; if (val > maximum) { average[k] += val; count++; } } } average[k] = average[k] / count; /* adjusts gain for the channel */ if (average[k] < calib_sensor.gain_white_ref) dev->frontend.set_gain(k, dev->frontend.get_gain(k) + 1); DBG(DBG_proc, "%s: channel %d, average = %.2f, gain = %d\n", __func__, k, average[k], dev->frontend.get_gain(k)); } } if (channels < 3) { dev->frontend.set_gain(1, dev->frontend.get_gain(0)); dev->frontend.set_gain(2, dev->frontend.get_gain(0)); } DBG(DBG_info, "%s: gains=(%d,%d,%d)\n", __func__, dev->frontend.get_gain(0), dev->frontend.get_gain(1), dev->frontend.get_gain(2)); } /** * sets up the scanner's register for warming up. We scan 2 lines without moving. * */ void CommandSetGl646::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* local_reg, int* channels, int* total_size) const { DBG_HELPER(dbg); (void) sensor; Genesys_Settings settings; int resolution, lines; dev->frontend = dev->frontend_initial; resolution = get_closest_resolution(dev->model->sensor_id, 300, 1); const auto& local_sensor = sanei_genesys_find_sensor(dev, resolution, 1, dev->settings.scan_method); /* set up for a half width 2 lines gray scan without moving */ settings.scan_method = dev->model->default_method; settings.scan_mode = ScanColorMode::GRAY; settings.xres = resolution; settings.yres = resolution; settings.tl_x = 0; settings.tl_y = 0; settings.pixels = (local_sensor.sensor_pixels * resolution) / local_sensor.optical_res; settings.requested_pixels = settings.pixels; settings.lines = 2; settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; // setup for scan setup_for_scan(dev, local_sensor, &dev->reg, settings, true, false, false, false); /* we are not going to move, so clear these bits */ dev->reg.find_reg(0x02).value &= ~(REG_0x02_FASTFED | REG_0x02_AGOHOME); /* don't enable any correction for this scan */ dev->reg.find_reg(0x01).value &= ~REG_0x01_DVDSET; /* copy to local_reg */ *local_reg = dev->reg; /* turn off motor during this scan */ sanei_genesys_set_motor_power(*local_reg, false); /* returned value to higher level warmup function */ *channels = 1; lines = local_reg->get24(REG_LINCNT) + 1; *total_size = lines * settings.pixels; // now registers are ok, write them to scanner gl646_set_fe(dev, local_sensor, AFE_SET, settings.xres); dev->interface->write_registers(*local_reg); } /* * this function moves head without scanning, forward, then backward * so that the head goes to park position. * as a by-product, also check for lock */ static void gl646_repark_head(Genesys_Device* dev) { DBG_HELPER(dbg); Genesys_Settings settings; unsigned int expected, steps; settings.scan_method = dev->model->default_method; settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; settings.xres = get_closest_resolution(dev->model->sensor_id, 75, 1); settings.yres = settings.xres; settings.tl_x = 0; settings.tl_y = 5; settings.pixels = 600; settings.requested_pixels = settings.pixels; settings.lines = 4; settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; const auto& sensor = sanei_genesys_find_sensor(dev, settings.xres, 3, dev->model->default_method); setup_for_scan(dev, sensor, &dev->reg, settings, false, false, false, false); /* TODO seems wrong ... no effective scan */ regs_set_optical_off(dev->model->asic_type, dev->reg); dev->interface->write_registers(dev->reg); // start scan dev->cmd_set->begin_scan(dev, sensor, &dev->reg, true); expected = dev->reg.get24(REG_FEEDL); do { dev->interface->sleep_ms(100); sanei_genesys_read_feed_steps (dev, &steps); } while (steps < expected); // toggle motor flag, put an huge step number and redo move backward dev->cmd_set->move_back_home(dev, 1); } /* * * initialize ASIC : registers, motor tables, and gamma tables * then ensure scanner's head is at home * @param dev device description of the scanner to initailize */ void CommandSetGl646::init(Genesys_Device* dev) const { DBG_INIT(); DBG_HELPER(dbg); uint8_t val = 0; uint32_t addr = 0xdead; size_t len; // to detect real power up condition, we write to REG_0x41 with pwrbit set, then read it back. // When scanner is cold (just replugged) PWRBIT will be set in the returned value auto status = scanner_read_status(*dev); if (status.is_replugged) { DBG(DBG_info, "%s: device is cold\n", __func__); } else { DBG(DBG_info, "%s: device is hot\n", __func__); } const auto& sensor = sanei_genesys_find_sensor_any(dev); /* if scanning session hasn't been initialized, set it up */ if (!dev->already_initialized) { dev->dark_average_data.clear(); dev->white_average_data.clear(); dev->settings.color_filter = ColorFilter::GREEN; /* Set default values for registers */ gl646_init_regs (dev); // Init shading data sanei_genesys_init_shading_data(dev, sensor, sensor.sensor_pixels); /* initial calibration reg values */ dev->calib_reg = dev->reg; } // execute physical unit init only if cold if (status.is_replugged) { DBG(DBG_info, "%s: device is cold\n", __func__); val = 0x04; dev->interface->get_usb_device().control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_INIT, INDEX, 1, &val); // ASIC reset dev->interface->write_register(0x0e, 0x00); dev->interface->sleep_ms(100); // Write initial registers dev->interface->write_registers(dev->reg); // send gamma tables if needed dev->cmd_set->send_gamma_table(dev, sensor); // Set powersaving(default = 15 minutes) dev->cmd_set->set_powersaving(dev, 15); } // Set analog frontend gl646_set_fe(dev, sensor, AFE_INIT, 0); /* GPO enabling for XP200 */ if (dev->model->sensor_id == SensorId::CIS_XP200) { dev->interface->write_register(0x68, dev->gpo.regs.get_value(0x68)); dev->interface->write_register(0x69, dev->gpo.regs.get_value(0x69)); // enable GPIO gl646_gpio_output_enable(dev->interface->get_usb_device(), 6); // writes 0 to GPIO gl646_gpio_write(dev->interface->get_usb_device(), 0); // clear GPIO enable gl646_gpio_output_enable(dev->interface->get_usb_device(), 0); dev->interface->write_register(0x66, 0x10); dev->interface->write_register(0x66, 0x00); dev->interface->write_register(0x66, 0x10); } /* MD6471/G2410 and XP200 read/write data from an undocumented memory area which * is after the second slope table */ if (dev->model->gpio_id != GpioId::HP3670 && dev->model->gpio_id != GpioId::HP2400) { switch (sensor.optical_res) { case 600: addr = 0x08200; break; case 1200: addr = 0x10200; break; case 2400: addr = 0x1fa00; break; } sanei_genesys_set_buffer_address(dev, addr); sanei_usb_set_timeout (2 * 1000); len = 6; // for some reason, read fails here for MD6471, HP2300 and XP200 one time out of // 2 scanimage launches try { dev->interface->bulk_read_data(0x45, dev->control, len); } catch (...) { dev->interface->bulk_read_data(0x45, dev->control, len); } DBG(DBG_info, "%s: control read=0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", __func__, dev->control[0], dev->control[1], dev->control[2], dev->control[3], dev->control[4], dev->control[5]); sanei_usb_set_timeout (30 * 1000); } else /* HP2400 and HP3670 case */ { dev->control[0] = 0x00; dev->control[1] = 0x00; dev->control[2] = 0x01; dev->control[3] = 0x00; dev->control[4] = 0x00; dev->control[5] = 0x00; } /* ensure head is correctly parked, and check lock */ if (!dev->model->is_sheetfed) { if (dev->model->flags & GENESYS_FLAG_REPARK) { // FIXME: if repark fails, we should print an error message that the scanner is locked and // the user should unlock the lock. We should also rethrow with SANE_STATUS_JAMMED gl646_repark_head(dev); } else { move_back_home(dev, true); } } /* here session and device are initialized */ dev->already_initialized = true; } void CommandSetGl646::move_to_ta(Genesys_Device* dev) const { DBG_HELPER(dbg); simple_move(dev, static_cast(dev->model->y_offset_sensor_to_ta)); } /** * Does a simple scan: ie no line reordering and avanced data buffering and * shading correction. Memory for data is allocated in this function * and must be freed by caller. * @param dev device of the scanner * @param settings parameters of the scan * @param move true if moving during scan * @param forward true if moving forward during scan * @param shading true to enable shading correction * @param data pointer for the data */ static void simple_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Settings settings, bool move, bool forward, bool shading, std::vector& data, const char* scan_identifier) { DBG_HELPER_ARGS(dbg, "move=%d, forward=%d, shading=%d", move, forward, shading); unsigned int size, lines, x, y, bpp; bool split; /* round up to multiple of 3 in case of CIS scanner */ if (dev->model->is_cis) { settings.lines = ((settings.lines + 2) / 3) * 3; } /* setup for move then scan */ split = !(move && settings.tl_y > 0); setup_for_scan(dev, sensor, &dev->reg, settings, split, false, false, !forward); /* allocate memory fo scan : LINCNT may have been adjusted for CCD reordering */ if (dev->model->is_cis) { lines = dev->reg.get24(REG_LINCNT) / 3; } else { lines = dev->reg.get24(REG_LINCNT) + 1; } size = lines * settings.pixels; if (settings.depth == 16) { bpp = 2; } else { bpp = 1; } size *= bpp * settings.get_channels(); data.clear(); data.resize(size); DBG(DBG_io, "%s: allocated %d bytes of memory for %d lines\n", __func__, size, lines); /* put back real line number in settings */ settings.lines = lines; // initialize frontend gl646_set_fe(dev, sensor, AFE_SET, settings.xres); /* no shading correction and not watch dog for simple scan */ dev->reg.find_reg(0x01).value &= ~(REG_0x01_DVDSET | REG_0x01_DOGENB); if (shading) { dev->reg.find_reg(0x01).value |= REG_0x01_DVDSET; } /* enable gamma table for the scan */ dev->reg.find_reg(0x05).value |= REG_0x05_GMMENB; /* one table movement for simple scan */ dev->reg.find_reg(0x02).value &= ~REG_0x02_FASTFED; if (!move) { sanei_genesys_set_motor_power(dev->reg, false); /* no automatic go home if no movement */ dev->reg.find_reg(0x02).value &= ~REG_0x02_AGOHOME; } /* no automatic go home when using XPA */ if (settings.scan_method == ScanMethod::TRANSPARENCY) { dev->reg.find_reg(0x02).value &= ~REG_0x02_AGOHOME; } // write scan registers dev->interface->write_registers(dev->reg); // starts scan dev->cmd_set->begin_scan(dev, sensor, &dev->reg, move); if (is_testing_mode()) { dev->interface->test_checkpoint(scan_identifier); return; } wait_until_buffer_non_empty(dev, true); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); /* in case of CIS scanner, we must reorder data */ if (dev->model->is_cis && settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS) { /* alloc one line sized working buffer */ std::vector buffer(settings.pixels * 3 * bpp); /* reorder one line of data and put it back to buffer */ if (bpp == 1) { for (y = 0; y < lines; y++) { /* reorder line */ for (x = 0; x < settings.pixels; x++) { buffer[x * 3] = data[y * settings.pixels * 3 + x]; buffer[x * 3 + 1] = data[y * settings.pixels * 3 + settings.pixels + x]; buffer[x * 3 + 2] = data[y * settings.pixels * 3 + 2 * settings.pixels + x]; } /* copy line back */ memcpy (data.data() + settings.pixels * 3 * y, buffer.data(), settings.pixels * 3); } } else { for (y = 0; y < lines; y++) { /* reorder line */ for (x = 0; x < settings.pixels; x++) { buffer[x * 6] = data[y * settings.pixels * 6 + x * 2]; buffer[x * 6 + 1] = data[y * settings.pixels * 6 + x * 2 + 1]; buffer[x * 6 + 2] = data[y * settings.pixels * 6 + 2 * settings.pixels + x * 2]; buffer[x * 6 + 3] = data[y * settings.pixels * 6 + 2 * settings.pixels + x * 2 + 1]; buffer[x * 6 + 4] = data[y * settings.pixels * 6 + 4 * settings.pixels + x * 2]; buffer[x * 6 + 5] = data[y * settings.pixels * 6 + 4 * settings.pixels + x * 2 + 1]; } /* copy line back */ memcpy (data.data() + settings.pixels * 6 * y, buffer.data(), settings.pixels * 6); } } } // end scan , waiting the motor to stop if needed (if moving), but without ejecting doc end_scan_impl(dev, &dev->reg, true, false); } /** * Does a simple move of the given distance by doing a scan at lowest resolution * shading correction. Memory for data is allocated in this function * and must be freed by caller. * @param dev device of the scanner * @param distance distance to move in MM */ static void simple_move(Genesys_Device* dev, SANE_Int distance) { DBG_HELPER_ARGS(dbg, "%d mm", distance); Genesys_Settings settings; unsigned resolution = sanei_genesys_get_lowest_dpi(dev); const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 3, dev->model->default_method); /* TODO give a no AGOHOME flag */ settings.scan_method = dev->model->default_method; settings.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; settings.xres = resolution; settings.yres = resolution; settings.tl_y = 0; settings.tl_x = 0; settings.pixels = (sensor.sensor_pixels * settings.xres) / sensor.optical_res; settings.requested_pixels = settings.pixels; settings.lines = static_cast((distance * settings.xres) / MM_PER_INCH); settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; std::vector data; simple_scan(dev, sensor, settings, true, true, false, data, "simple_move"); } /** * update the status of the required sensor in the scanner session * the button fileds are used to make events 'sticky' */ void CommandSetGl646::update_hardware_sensors(Genesys_Scanner* session) const { DBG_HELPER(dbg); Genesys_Device *dev = session->dev; uint8_t value; // do what is needed to get a new set of events, but try to not loose any of them. gl646_gpio_read(dev->interface->get_usb_device(), &value); DBG(DBG_io, "%s: GPIO=0x%02x\n", __func__, value); // scan button if (dev->model->buttons & GENESYS_HAS_SCAN_SW) { switch (dev->model->gpio_id) { case GpioId::XP200: session->buttons[BUTTON_SCAN_SW].write((value & 0x02) != 0); break; case GpioId::MD_5345: session->buttons[BUTTON_SCAN_SW].write(value == 0x16); break; case GpioId::HP2300: session->buttons[BUTTON_SCAN_SW].write(value == 0x6c); break; case GpioId::HP3670: case GpioId::HP2400: session->buttons[BUTTON_SCAN_SW].write((value & 0x20) == 0); break; default: throw SaneException(SANE_STATUS_UNSUPPORTED, "unknown gpo type"); } } // email button if (dev->model->buttons & GENESYS_HAS_EMAIL_SW) { switch (dev->model->gpio_id) { case GpioId::MD_5345: session->buttons[BUTTON_EMAIL_SW].write(value == 0x12); break; case GpioId::HP3670: case GpioId::HP2400: session->buttons[BUTTON_EMAIL_SW].write((value & 0x08) == 0); break; default: throw SaneException(SANE_STATUS_UNSUPPORTED, "unknown gpo type"); } } // copy button if (dev->model->buttons & GENESYS_HAS_COPY_SW) { switch (dev->model->gpio_id) { case GpioId::MD_5345: session->buttons[BUTTON_COPY_SW].write(value == 0x11); break; case GpioId::HP2300: session->buttons[BUTTON_COPY_SW].write(value == 0x5c); break; case GpioId::HP3670: case GpioId::HP2400: session->buttons[BUTTON_COPY_SW].write((value & 0x10) == 0); break; default: throw SaneException(SANE_STATUS_UNSUPPORTED, "unknown gpo type"); } } // power button if (dev->model->buttons & GENESYS_HAS_POWER_SW) { switch (dev->model->gpio_id) { case GpioId::MD_5345: session->buttons[BUTTON_POWER_SW].write(value == 0x14); break; default: throw SaneException(SANE_STATUS_UNSUPPORTED, "unknown gpo type"); } } // ocr button if (dev->model->buttons & GENESYS_HAS_OCR_SW) { switch (dev->model->gpio_id) { case GpioId::MD_5345: session->buttons[BUTTON_OCR_SW].write(value == 0x13); break; default: throw SaneException(SANE_STATUS_UNSUPPORTED, "unknown gpo type"); } } // document detection if (dev->model->buttons & GENESYS_HAS_PAGE_LOADED_SW) { switch (dev->model->gpio_id) { case GpioId::XP200: session->buttons[BUTTON_PAGE_LOADED_SW].write((value & 0x04) != 0); break; default: throw SaneException(SANE_STATUS_UNSUPPORTED, "unknown gpo type"); } } /* XPA detection */ if (dev->model->flags & GENESYS_FLAG_XPA) { switch (dev->model->gpio_id) { case GpioId::HP3670: case GpioId::HP2400: /* test if XPA is plugged-in */ if ((value & 0x40) == 0) { DBG(DBG_io, "%s: enabling XPA\n", __func__); session->opt[OPT_SOURCE].cap &= ~SANE_CAP_INACTIVE; } else { DBG(DBG_io, "%s: disabling XPA\n", __func__); session->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; } break; default: throw SaneException(SANE_STATUS_UNSUPPORTED, "unknown gpo type"); } } } static void write_control(Genesys_Device* dev, const Genesys_Sensor& sensor, int resolution) { DBG_HELPER(dbg); uint8_t control[4]; uint32_t addr = 0xdead; /* 2300 does not write to 'control' */ if (dev->model->motor_id == MotorId::HP2300) { return; } /* MD6471/G2410/HP2300 and XP200 read/write data from an undocumented memory area which * is after the second slope table */ switch (sensor.optical_res) { case 600: addr = 0x08200; break; case 1200: addr = 0x10200; break; case 2400: addr = 0x1fa00; break; default: throw SaneException("failed to compute control address"); } /* XP200 sets dpi, what other scanner put is unknown yet */ switch (dev->model->motor_id) { case MotorId::XP200: /* we put scan's dpi, not motor one */ control[0] = resolution & 0xff; control[1] = (resolution >> 8) & 0xff; control[2] = dev->control[4]; control[3] = dev->control[5]; break; case MotorId::HP3670: case MotorId::HP2400: case MotorId::MD_5345: default: control[0] = dev->control[2]; control[1] = dev->control[3]; control[2] = dev->control[4]; control[3] = dev->control[5]; break; } DBG(DBG_info, "%s: control write=0x%02x 0x%02x 0x%02x 0x%02x\n", __func__, control[0], control[1], control[2], control[3]); dev->interface->write_buffer(0x3c, addr, control, 4); } /** * search for a full width black or white strip. * @param dev scanner device * @param forward true if searching forward, false if searching backward * @param black true if searching for a black strip, false for a white strip */ void CommandSetGl646::search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const { DBG_HELPER(dbg); (void) sensor; Genesys_Settings settings; int res = get_closest_resolution(dev->model->sensor_id, 75, 1); unsigned int pass, count, found, x, y; char title[80]; const auto& calib_sensor = sanei_genesys_find_sensor(dev, res, 1, ScanMethod::FLATBED); /* we set up for a lowest available resolution color grey scan, full width */ settings.scan_method = dev->model->default_method; settings.scan_mode = ScanColorMode::GRAY; settings.xres = res; settings.yres = res; settings.tl_x = 0; settings.tl_y = 0; settings.pixels = static_cast((dev->model->x_size * res) / MM_PER_INCH); settings.pixels /= calib_sensor.get_ccd_size_divisor_for_dpi(res); settings.requested_pixels = settings.pixels; /* 15 mm at at time */ settings.lines = static_cast((15 * settings.yres) / MM_PER_INCH); settings.depth = 8; settings.color_filter = ColorFilter::RED; settings.disable_interpolation = 0; settings.threshold = 0; /* signals if a strip of the given color has been found */ found = 0; /* detection pass done */ pass = 0; std::vector data; /* loop until strip is found or maximum pass number done */ while (pass < 20 && !found) { // scan a full width strip simple_scan(dev, calib_sensor, settings, true, forward, false, data, "search_strip"); if (is_testing_mode()) { return; } if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl646_search_strip_%s%02d.pnm", forward ? "fwd" : "bwd", pass); sanei_genesys_write_pnm_file (title, data.data(), settings.depth, 1, settings.pixels, settings.lines); } /* search data to find black strip */ /* when searching forward, we only need one line of the searched color since we * will scan forward. But when doing backward search, we need all the area of the * same color */ if (forward) { for (y = 0; y < settings.lines && !found; y++) { count = 0; /* count of white/black pixels depending on the color searched */ for (x = 0; x < settings.pixels; x++) { /* when searching for black, detect white pixels */ if (black && data[y * settings.pixels + x] > 90) { count++; } /* when searching for white, detect black pixels */ if (!black && data[y * settings.pixels + x] < 60) { count++; } } /* at end of line, if count >= 3%, line is not fully of the desired color * so we must go to next line of the buffer */ /* count*100/pixels < 3 */ if ((count * 100) / settings.pixels < 3) { found = 1; DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, pass, y); } else { DBG(DBG_data, "%s: pixels=%d, count=%d\n", __func__, settings.pixels, count); } } } else /* since calibration scans are done forward, we need the whole area to be of the required color when searching backward */ { count = 0; for (y = 0; y < settings.lines; y++) { /* count of white/black pixels depending on the color searched */ for (x = 0; x < settings.pixels; x++) { /* when searching for black, detect white pixels */ if (black && data[y * settings.pixels + x] > 60) { count++; } /* when searching for white, detect black pixels */ if (!black && data[y * settings.pixels + x] < 60) { count++; } } } /* at end of area, if count >= 3%, area is not fully of the desired color * so we must go to next buffer */ if ((count * 100) / (settings.pixels * settings.lines) < 3) { found = 1; DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { DBG(DBG_data, "%s: pixels=%d, count=%d\n", __func__, settings.pixels, count); } } pass++; } if (found) { DBG(DBG_info, "%s: strip found\n", __func__); } else { throw SaneException(SANE_STATUS_UNSUPPORTED, "%s strip not found", black ? "black" : "white"); } } void CommandSetGl646::wait_for_motor_stop(Genesys_Device* dev) const { (void) dev; } void CommandSetGl646::send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, std::uint8_t* data, int size) const { (void) dev; (void) sensor; (void) data; (void) size; throw SaneException("not implemented"); } ScanSession CommandSetGl646::calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const { // compute distance to move float move = 0; // XXX STEF XXX MD5345 -> optical_ydpi, other base_ydpi => half/full step ? */ if (!dev->model->is_sheetfed) { move = static_cast(dev->model->y_offset); // add tl_y to base movement } move += static_cast(settings.tl_y); if (move < 0) { DBG(DBG_error, "%s: overriding negative move value %f\n", __func__, move); move = 0; } move = static_cast((move * dev->motor.optical_ydpi) / MM_PER_INCH); float start = static_cast(settings.tl_x); if (settings.scan_method == ScanMethod::FLATBED) { start += static_cast(dev->model->x_offset); } else { start += static_cast(dev->model->x_offset_ta); } start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = settings.xres; session.params.yres = settings.yres; session.params.startx = static_cast(start); session.params.starty = static_cast(move); session.params.pixels = settings.pixels; session.params.requested_pixels = settings.requested_pixels; session.params.lines = settings.lines; session.params.depth = settings.depth; session.params.channels = settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = settings.scan_mode; session.params.color_filter = settings.color_filter; session.params.flags = ScanFlag::USE_XCORRECTION; if (settings.scan_method == ScanMethod::TRANSPARENCY) { session.params.flags |= ScanFlag::USE_XPA; } compute_session(dev, session, sensor); return session; } void CommandSetGl646::asic_boot(Genesys_Device *dev, bool cold) const { (void) dev; (void) cold; throw SaneException("not implemented"); } std::unique_ptr create_gl646_cmd_set() { return std::unique_ptr(new CommandSetGl646{}); } } // namespace gl646 } // namespace genesys sane-backends-1.0.29/backend/genesys/gl124.h0000666000000000000000000001551413615534521015255 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2010-2016 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL124_H #define BACKEND_GENESYS_GL124_H #include "genesys.h" #include "command_set.h" namespace genesys { namespace gl124 { typedef struct { uint8_t r31; uint8_t r32; uint8_t r33; uint8_t r34; uint8_t r35; uint8_t r36; uint8_t r38; } Gpio_layout; /** @brief gpio layout * describes initial gpio settings for a given model * registers 0x31 to 0x38 */ static Gpio_layout gpios[]={ /* LiDE 110 */ { /* 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38 */ 0x9f, 0x59, 0x01, 0x80, 0x5f, 0x01, 0x00 }, /* LiDE 210 */ { 0x9f, 0x59, 0x01, 0x80, 0x5f, 0x01, 0x00 }, /* LiDE 120 */ { 0x9f, 0x53, 0x01, 0x80, 0x5f, 0x01, 0x00 }, }; typedef struct { uint8_t rd0; uint8_t rd1; uint8_t rd2; uint8_t re0; uint8_t re1; uint8_t re2; uint8_t re3; uint8_t re4; uint8_t re5; uint8_t re6; uint8_t re7; } Memory_layout; static Memory_layout layouts[]={ /* 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, 220 */ { 0x0a, 0x1f, 0x34, 0x01, 0x24, 0x08, 0x91, 0x08, 0x92, 0x0f, 0xff } }; static void gl124_send_slope_table(Genesys_Device* dev, int table_nr, const std::vector& slope_table, int steps); class CommandSetGl124 : public CommandSet { public: ~CommandSetGl124() override = default; bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const override; void init(Genesys_Device* dev) const override; void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const override; void init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const override; void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const override; void set_powersaving(Genesys_Device* dev, int delay) const override; void save_power(Genesys_Device* dev, bool enable) const override; void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, bool start_motor) const override; void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void search_start_position(Genesys_Device* dev) const override; void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const override; SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void wait_for_motor_stop(Genesys_Device* dev) const override; void move_back_home(Genesys_Device* dev, bool wait_until_home) const override; void update_hardware_sensors(struct Genesys_Scanner* s) const override; bool needs_update_home_sensor_gpio() const override { return true; } void update_home_sensor_gpio(Genesys_Device& dev) const override; void load_document(Genesys_Device* dev) const override; void detect_document_end(Genesys_Device* dev) const override; void eject_document(Genesys_Device* dev) const override; void search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const override; void move_to_ta(Genesys_Device* dev) const override; void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const override; ScanSession calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const override; void asic_boot(Genesys_Device* dev, bool cold) const override; }; enum SlopeTable { SCAN_TABLE = 0, // table 1 at 0x4000 BACKTRACK_TABLE = 1, // table 2 at 0x4800 STOP_TABLE = 2, // table 3 at 0x5000 FAST_TABLE = 3, // table 4 at 0x5800 HOME_TABLE = 4, // table 5 at 0x6000 }; } // namespace gl124 } // namespace genesys #endif // BACKEND_GENESYS_GL124_H sane-backends-1.0.29/backend/genesys/usb_device.cpp0000666000000000000000000000763013615534521017067 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "usb_device.h" namespace genesys { IUsbDevice::~IUsbDevice() = default; UsbDevice::~UsbDevice() { if (is_open()) { DBG(DBG_error, "UsbDevice not closed; closing automatically"); close(); } } void UsbDevice::open(const char* dev_name) { DBG_HELPER(dbg); if (is_open()) { throw SaneException("device already open"); } int device_num = 0; dbg.status("open device"); TIE(sanei_usb_open(dev_name, &device_num)); name_ = dev_name; device_num_ = device_num; is_open_ = true; } void UsbDevice::clear_halt() { DBG_HELPER(dbg); assert_is_open(); TIE(sanei_usb_clear_halt(device_num_)); } void UsbDevice::reset() { DBG_HELPER(dbg); assert_is_open(); TIE(sanei_usb_reset(device_num_)); } void UsbDevice::close() { DBG_HELPER(dbg); assert_is_open(); // we can't do much if closing fails, so we close the device on our side regardless of the // function succeeds int device_num = device_num_; set_not_open(); sanei_usb_close(device_num); } void UsbDevice::get_vendor_product(int& vendor, int& product) { DBG_HELPER(dbg); assert_is_open(); TIE(sanei_usb_get_vendor_product(device_num_, &vendor, &product)); } void UsbDevice::control_msg(int rtype, int reg, int value, int index, int length, std::uint8_t* data) { DBG_HELPER(dbg); assert_is_open(); TIE(sanei_usb_control_msg(device_num_, rtype, reg, value, index, length, data)); } void UsbDevice::bulk_read(std::uint8_t* buffer, std::size_t* size) { DBG_HELPER(dbg); assert_is_open(); TIE(sanei_usb_read_bulk(device_num_, buffer, size)); } void UsbDevice::bulk_write(const std::uint8_t* buffer, std::size_t* size) { DBG_HELPER(dbg); assert_is_open(); TIE(sanei_usb_write_bulk(device_num_, buffer, size)); } void UsbDevice::assert_is_open() const { if (!is_open()) { throw SaneException("device not open"); } } void UsbDevice::set_not_open() { device_num_ = 0; is_open_ = false; name_ = ""; } } // namespace genesys sane-backends-1.0.29/backend/genesys/motor.h0000666000000000000000000001340013615534521015554 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_MOTOR_H #define BACKEND_GENESYS_MOTOR_H #include #include #include "enums.h" namespace genesys { /* Describes a motor acceleration curve. Definitions: v - speed in steps per pixeltime w - speed in pixel times per step. w = 1 / v a - acceleration in steps per pixeltime squared s - distance travelled in steps t - time in pixeltime The physical mode defines the curve in physical quantities. We asssume that the scanner head accelerates from standstill to the target speed uniformly. Then: v(t) = v(0) + a * t (2) Where `a` is acceleration, `t` is time. Also we can calculate the travelled distance `s`: s(t) = v(0) * t + a * t^2 / 2 (3) The actual motor slope is defined as the duration of each motor step. That means we need to define speed in terms of travelled distance. Solving (3) for `t` gives: sqrt( v(0)^2 + 2 * a * s ) - v(0) t(s) = --------------------------------- (4) a Combining (4) and (2) will yield: v(s) = sqrt( v(0)^2 + 2 * a * s ) (5) The data in the slope struct MotorSlope corresponds to the above in the following way: maximum_start_speed is `w(0) = 1/v(0)` maximum_speed is defines maximum speed which should not be exceeded minimum_steps is not used g is `a` Given the start and target speeds on a known motor curve, `a` can be computed as follows: v(t1)^2 - v(t0)^2 a = ----------------- (6) 2 * s Here `v(t0)` and `v(t1)` are the start and target speeds and `s` is the number of step required to reach the target speeds. */ struct MotorSlope { // initial speed in pixeltime per step unsigned initial_speed_w = 0; // max speed in pixeltime per step unsigned max_speed_w = 0; // maximum number of steps in the table unsigned max_step_count; // acceleration in steps per pixeltime squared. float acceleration = 0; unsigned get_table_step_shifted(unsigned step, StepType step_type) const; static MotorSlope create_from_steps(unsigned initial_w, unsigned max_w, unsigned steps); }; struct MotorSlopeTable { std::vector table; unsigned steps_count = 0; unsigned pixeltime_sum = 0; void slice_steps(unsigned count); }; unsigned get_slope_table_max_size(AsicType asic_type); MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_speed_w, StepType step_type, unsigned steps_alignment, unsigned min_size, unsigned max_size); std::ostream& operator<<(std::ostream& out, const MotorSlope& slope); struct Genesys_Motor { Genesys_Motor() = default; // id of the motor description MotorId id = MotorId::UNKNOWN; // motor base steps. Unit: 1/inch int base_ydpi = 0; // maximum resolution in y-direction. Unit: 1/inch int optical_ydpi = 0; // slopes to derive individual slopes from std::vector slopes; MotorSlope& get_slope(StepType step_type) { return slopes[static_cast(step_type)]; } const MotorSlope& get_slope(StepType step_type) const { return slopes[static_cast(step_type)]; } StepType max_step_type() const { if (slopes.empty()) { throw std::runtime_error("Slopes table is empty"); } return static_cast(slopes.size() - 1); } }; std::ostream& operator<<(std::ostream& out, const Genesys_Motor& motor); } // namespace genesys #endif // BACKEND_GENESYS_MOTOR_H sane-backends-1.0.29/backend/genesys/serialize.h0000666000000000000000000001332713615534521016413 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_SERIALIZE_H #define BACKEND_GENESYS_SERIALIZE_H #include "error.h" #include #include #include #include #include namespace genesys { // it would be best to use something like boost.serialization inline void serialize_newline(std::ostream& str) { str << '\n'; } inline void serialize_newline(std::istream& str) { (void) str; } inline void serialize(std::ostream& str, bool x) { str << static_cast(x) << " "; } inline void serialize(std::istream& str, bool& x) { unsigned v; str >> v; x = v; } inline void serialize(std::ostream& str, char x) { str << static_cast(x) << " "; } inline void serialize(std::istream& str, char& x) { int v; str >> v; x = v; } inline void serialize(std::ostream& str, unsigned char x) { str << static_cast(x) << " "; } inline void serialize(std::istream& str, unsigned char& x) { unsigned v; str >> v; x = v; } inline void serialize(std::ostream& str, signed char x) { str << static_cast(x) << " "; } inline void serialize(std::istream& str, signed char& x) { int v; str >> v; x = v; } inline void serialize(std::ostream& str, short x) { str << x << " "; } inline void serialize(std::istream& str, short& x) { str >> x; } inline void serialize(std::ostream& str, unsigned short x) { str << x << " "; } inline void serialize(std::istream& str, unsigned short& x) { str >> x; } inline void serialize(std::ostream& str, int x) { str << x << " "; } inline void serialize(std::istream& str, int& x) { str >> x; } inline void serialize(std::ostream& str, unsigned int x) { str << x << " "; } inline void serialize(std::istream& str, unsigned int& x) { str >> x; } inline void serialize(std::ostream& str, long x) { str << x << " "; } inline void serialize(std::istream& str, long& x) { str >> x; } inline void serialize(std::ostream& str, unsigned long x) { str << x << " "; } inline void serialize(std::istream& str, unsigned long& x) { str >> x; } inline void serialize(std::ostream& str, long long x) { str << x << " "; } inline void serialize(std::istream& str, long long& x) { str >> x; } inline void serialize(std::ostream& str, unsigned long long x) { str << x << " "; } inline void serialize(std::istream& str, unsigned long long& x) { str >> x; } inline void serialize(std::ostream& str, float x) { str << x << " "; } inline void serialize(std::istream& str, float& x) { str >> x; } inline void serialize(std::ostream& str, double x) { str << x << " "; } inline void serialize(std::istream& str, double& x) { str >> x; } inline void serialize(std::ostream& str, const std::string& x) { str << x << " "; } inline void serialize(std::istream& str, std::string& x) { str >> x; } template void serialize(std::ostream& str, std::vector& x) { serialize(str, x.size()); serialize_newline(str); for (auto& item : x) { serialize(str, item); serialize_newline(str); } } template void serialize(std::istream& str, std::vector& x, size_t max_size = std::numeric_limits::max()) { size_t new_size; serialize(str, new_size); if (new_size > max_size) { throw SaneException("Too large std::vector to deserialize"); } x.reserve(new_size); for (size_t i = 0; i < new_size; ++i) { T item; serialize(str, item); x.push_back(item); } } template void serialize(std::ostream& str, std::array& x) { serialize(str, x.size()); serialize_newline(str); for (auto& item : x) { serialize(str, item); serialize_newline(str); } } template void serialize(std::istream& str, std::array& x) { size_t new_size; serialize(str, new_size); if (new_size > Size) { throw SaneException("Incorrect std::array size to deserialize"); } for (auto& item : x) { serialize(str, item); } } } // namespace genesys #endif sane-backends-1.0.29/backend/genesys/static_init.h0000666000000000000000000000562513615534521016740 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_STATIC_INIT_H #define BACKEND_GENESYS_STATIC_INIT_H #include #include namespace genesys { void add_function_to_run_at_backend_exit(const std::function& function); // calls functions added via add_function_to_run_at_backend_exit() in reverse order of being // added. void run_functions_at_backend_exit(); template class StaticInit { public: StaticInit() = default; StaticInit(const StaticInit&) = delete; StaticInit& operator=(const StaticInit&) = delete; template void init(Args&& ... args) { ptr_ = std::unique_ptr(new T(std::forward(args)...)); add_function_to_run_at_backend_exit([this](){ deinit(); }); } void deinit() { ptr_.reset(); } const T* operator->() const { return ptr_.get(); } T* operator->() { return ptr_.get(); } const T& operator*() const { return *ptr_.get(); } T& operator*() { return *ptr_.get(); } private: std::unique_ptr ptr_; }; } // namespace genesys #endif // BACKEND_GENESYS_STATIC_INIT_H sane-backends-1.0.29/backend/genesys/sensor.cpp0000666000000000000000000001475313615534521016274 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "sensor.h" #include "utilities.h" #include namespace genesys { std::ostream& operator<<(std::ostream& out, const StaggerConfig& config) { out << "StaggerConfig{\n" << " min_resolution: " << config.min_resolution() << '\n' << " lines_at_min: " << config.lines_at_min() << '\n' << "}"; return out; } std::ostream& operator<<(std::ostream& out, const FrontendType& type) { switch (type) { case FrontendType::UNKNOWN: out << "UNKNOWN"; break; case FrontendType::WOLFSON: out << "WOLFSON"; break; case FrontendType::ANALOG_DEVICES: out << "ANALOG_DEVICES"; break; default: out << "(unknown value)"; } return out; } std::ostream& operator<<(std::ostream& out, const GenesysFrontendLayout& layout) { StreamStateSaver state_saver{out}; out << "GenesysFrontendLayout{\n" << " type: " << layout.type << '\n' << std::hex << " offset_addr[0]: " << layout.offset_addr[0] << '\n' << " offset_addr[1]: " << layout.offset_addr[1] << '\n' << " offset_addr[2]: " << layout.offset_addr[2] << '\n' << " gain_addr[0]: " << layout.gain_addr[0] << '\n' << " gain_addr[1]: " << layout.gain_addr[1] << '\n' << " gain_addr[2]: " << layout.gain_addr[2] << '\n' << '}'; return out; } std::ostream& operator<<(std::ostream& out, const Genesys_Frontend& frontend) { StreamStateSaver state_saver{out}; out << "Genesys_Frontend{\n" << " id: " << static_cast(frontend.id) << '\n' << " regs: " << format_indent_braced_list(4, frontend.regs) << '\n' << std::hex << " reg2[0]: " << frontend.reg2[0] << '\n' << " reg2[1]: " << frontend.reg2[1] << '\n' << " reg2[2]: " << frontend.reg2[2] << '\n' << " layout: " << format_indent_braced_list(4, frontend.layout) << '\n' << '}'; return out; } std::ostream& operator<<(std::ostream& out, const SensorExposure& exposure) { out << "SensorExposure{\n" << " red: " << exposure.red << '\n' << " green: " << exposure.green << '\n' << " blue: " << exposure.blue << '\n' << '}'; return out; } std::ostream& operator<<(std::ostream& out, const ResolutionFilter& resolutions) { if (resolutions.matches_any()) { out << "ANY"; return out; } out << format_vector_unsigned(4, resolutions.resolutions()); return out; } std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor) { out << "Genesys_Sensor{\n" << " sensor_id: " << static_cast(sensor.sensor_id) << '\n' << " optical_res: " << sensor.optical_res << '\n' << " resolutions: " << format_indent_braced_list(4, sensor.resolutions) << '\n' << " channels: " << format_vector_unsigned(4, sensor.channels) << '\n' << " method: " << sensor.method << '\n' << " register_dpihw_override: " << sensor.register_dpihw_override << '\n' << " logical_dpihw_override: " << sensor.logical_dpihw_override << '\n' << " dpiset_override: " << sensor.dpiset_override << '\n' << " ccd_size_divisor: " << sensor.ccd_size_divisor << '\n' << " pixel_count_multiplier: " << sensor.pixel_count_multiplier << '\n' << " black_pixels: " << sensor.black_pixels << '\n' << " dummy_pixel: " << sensor.dummy_pixel << '\n' << " ccd_start_xoffset: " << sensor.ccd_start_xoffset << '\n' << " sensor_pixels: " << sensor.sensor_pixels << '\n' << " fau_gain_white_ref: " << sensor.fau_gain_white_ref << '\n' << " gain_white_ref: " << sensor.gain_white_ref << '\n' << " exposure: " << format_indent_braced_list(4, sensor.exposure) << '\n' << " exposure_lperiod: " << sensor.exposure_lperiod << '\n' << " segment_size: " << sensor.segment_size << '\n' << " segment_order: " << format_indent_braced_list(4, format_vector_unsigned(4, sensor.segment_order)) << '\n' << " stagger_config: " << format_indent_braced_list(4, sensor.stagger_config) << '\n' << " custom_base_regs: " << format_indent_braced_list(4, sensor.custom_base_regs) << '\n' << " custom_regs: " << format_indent_braced_list(4, sensor.custom_regs) << '\n' << " custom_fe_regs: " << format_indent_braced_list(4, sensor.custom_fe_regs) << '\n' << " gamma.red: " << sensor.gamma[0] << '\n' << " gamma.green: " << sensor.gamma[1] << '\n' << " gamma.blue: " << sensor.gamma[2] << '\n' << "}"; return out; } } // namespace genesys sane-backends-1.0.29/backend/genesys/buffer.h0000666000000000000000000000571313615534521015675 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_BUFFER_H #define BACKEND_GENESYS_BUFFER_H #include #include #include namespace genesys { /* A FIFO buffer. Note, that this is _not_ a ringbuffer. if we need a block which does not fit at the end of our available data, we move the available data to the beginning. */ struct Genesys_Buffer { Genesys_Buffer() = default; std::size_t size() const { return buffer_.size(); } std::size_t avail() const { return avail_; } std::size_t pos() const { return pos_; } // TODO: refactor code that uses this function to no longer use it void set_pos(std::size_t pos) { pos_ = pos; } void alloc(std::size_t size); void clear(); void reset(); std::uint8_t* get_write_pos(std::size_t size); std::uint8_t* get_read_pos(); // TODO: mark as const void produce(std::size_t size); void consume(std::size_t size); private: std::vector buffer_; // current position in read buffer std::size_t pos_ = 0; // data bytes currently in buffer std::size_t avail_ = 0; }; } // namespace genesys #endif // BACKEND_GENESYS_BUFFER_H sane-backends-1.0.29/backend/genesys/row_buffer.h0000666000000000000000000001342413615534521016562 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_LINE_BUFFER_H #define BACKEND_GENESYS_LINE_BUFFER_H #include "error.h" #include #include #include #include namespace genesys { class RowBuffer { public: RowBuffer(std::size_t line_bytes) : row_bytes_{line_bytes} {} RowBuffer(const RowBuffer&) = default; RowBuffer& operator=(const RowBuffer&) = default; ~RowBuffer() = default; const std::uint8_t* get_row_ptr(std::size_t y) const { if (y >= height()) { throw SaneException("y %zu is out of range", y); } return data_.data() + row_bytes_ * get_row_index(y); } std::uint8_t* get_row_ptr(std::size_t y) { if (y >= height()) { throw SaneException("y %zu is out of range", y); } return data_.data() + row_bytes_ * get_row_index(y); } const std::uint8_t* get_front_row_ptr() const { return get_row_ptr(0); } std::uint8_t* get_front_row_ptr() { return get_row_ptr(0); } const std::uint8_t* get_back_row_ptr() const { return get_row_ptr(height() - 1); } std::uint8_t* get_back_row_ptr() { return get_row_ptr(height() - 1); } bool empty() const { return is_linear_ && first_ == last_; } bool full() { if (is_linear_) { return last_ == buffer_end_; } return first_ == last_; } bool is_linear() const { return is_linear_; } void linearize() { if (!is_linear_) { std::rotate(data_.begin(), data_.begin() + row_bytes_ * first_, data_.end()); last_ = height(); first_ = 0; is_linear_ = true; } } void pop_front() { if (empty()) { throw SaneException("Trying to pop out of empty() line buffer"); } first_++; if (first_ == last_) { first_ = 0; last_ = 0; is_linear_ = true; } else if (first_ == buffer_end_) { first_ = 0; is_linear_ = true; } } void push_front() { if (height() + 1 >= height_capacity()) { ensure_capacity(std::max(1, height() * 2)); } if (first_ == 0) { is_linear_ = false; first_ = buffer_end_; } first_--; } void pop_back() { if (empty()) { throw SaneException("Trying to pop out of empty() line buffer"); } if (last_ == 0) { last_ = buffer_end_; is_linear_ = true; } last_--; if (first_ == last_) { first_ = 0; last_ = 0; is_linear_ = true; } } void push_back() { if (height() + 1 >= height_capacity()) { ensure_capacity(std::max(1, height() * 2)); } if (last_ == buffer_end_) { is_linear_ = false; last_ = 0; } last_++; } std::size_t row_bytes() const { return row_bytes_; } std::size_t height() const { if (!is_linear_) { return last_ + buffer_end_ - first_; } return last_ - first_; } std::size_t height_capacity() const { return buffer_end_; } void clear() { first_ = 0; last_ = 0; } private: std::size_t get_row_index(std::size_t index) const { if (index >= buffer_end_ - first_) { return index - (buffer_end_ - first_); } return index + first_; } void ensure_capacity(std::size_t capacity) { if (capacity < height_capacity()) return; linearize(); data_.resize(capacity * row_bytes_); buffer_end_ = capacity; } private: std::size_t row_bytes_ = 0; std::size_t first_ = 0; std::size_t last_ = 0; std::size_t buffer_end_ = 0; bool is_linear_ = true; std::vector data_; }; } // namespace genesys #endif // BACKEND_GENESYS_LINE_BUFFER_H sane-backends-1.0.29/backend/genesys/tables_sensor.cpp0000666000000000000000000043470313615534521017627 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "low.h" namespace genesys { inline unsigned default_get_logical_hwdpi(const Genesys_Sensor& sensor, unsigned xres) { if (sensor.logical_dpihw_override) return sensor.logical_dpihw_override; // can't be below 600 dpi if (xres <= 600) { return 600; } if (xres <= static_cast(sensor.optical_res) / 4) { return sensor.optical_res / 4; } if (xres <= static_cast(sensor.optical_res) / 2) { return sensor.optical_res / 2; } return sensor.optical_res; } inline unsigned get_sensor_optical_with_ccd_divisor(const Genesys_Sensor& sensor, unsigned xres) { unsigned hwres = sensor.optical_res / sensor.get_ccd_size_divisor_for_dpi(xres); if (xres <= hwres / 4) { return hwres / 4; } if (xres <= hwres / 2) { return hwres / 2; } return hwres; } inline unsigned default_get_ccd_size_divisor_for_dpi(const Genesys_Sensor& sensor, unsigned xres) { if (sensor.ccd_size_divisor >= 4 && xres * 4 <= static_cast(sensor.optical_res)) { return 4; } if (sensor.ccd_size_divisor >= 2 && xres * 2 <= static_cast(sensor.optical_res)) { return 2; } return 1; } inline unsigned get_ccd_size_divisor_exact(const Genesys_Sensor& sensor, unsigned xres) { (void) xres; return sensor.ccd_size_divisor; } inline unsigned get_ccd_size_divisor_gl124(const Genesys_Sensor& sensor, unsigned xres) { // we have 2 domains for ccd: xres below or above half ccd max dpi if (xres <= 300 && sensor.ccd_size_divisor > 1) { return 2; } return 1; } inline unsigned default_get_hwdpi_divisor_for_dpi(const Genesys_Sensor& sensor, unsigned xres) { return sensor.optical_res / default_get_logical_hwdpi(sensor, xres); } StaticInit> s_sensors; void genesys_init_sensor_tables() { s_sensors.init(); Genesys_Sensor sensor; sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_UMAX; sensor.optical_res = 1200; sensor.black_pixels = 48; sensor.dummy_pixel = 64; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10800; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.custom_regs = { { 0x08, 0x01 }, { 0x09, 0x03 }, { 0x0a, 0x05 }, { 0x0b, 0x07 }, { 0x16, 0x33 }, { 0x17, 0x05 }, { 0x18, 0x31 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x13 }, { 0x53, 0x17 }, { 0x54, 0x03 }, { 0x55, 0x07 }, { 0x56, 0x0b }, { 0x57, 0x0f }, { 0x58, 0x23 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_ST12; sensor.optical_res = 600; sensor.black_pixels = 48; sensor.dummy_pixel = 85; sensor.ccd_start_xoffset = 152; sensor.sensor_pixels = 5416; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.custom_regs = { { 0x08, 0x02 }, { 0x09, 0x00 }, { 0x0a, 0x06 }, { 0x0b, 0x04 }, { 0x16, 0x2b }, { 0x17, 0x08 }, { 0x18, 0x20 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x0c }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_ST24; sensor.optical_res = 1200; sensor.black_pixels = 48; sensor.dummy_pixel = 64; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10800; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.custom_regs = { { 0x08, 0x0e }, { 0x09, 0x0c }, { 0x0a, 0x00 }, { 0x0b, 0x0c }, { 0x16, 0x33 }, { 0x17, 0x08 }, { 0x18, 0x31 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x17 }, { 0x53, 0x03 }, { 0x54, 0x07 }, { 0x55, 0x0b }, { 0x56, 0x0f }, { 0x57, 0x13 }, { 0x58, 0x03 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_5345; sensor.optical_res = 1200; sensor.ccd_size_divisor = 2; sensor.black_pixels = 48; sensor.dummy_pixel = 16; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10872; sensor.fau_gain_white_ref = 190; sensor.gain_white_ref = 190; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.stagger_config = StaggerConfig{ 1200, 4 }; // FIXME: may be incorrect sensor.custom_base_regs = { { 0x08, 0x0d }, { 0x09, 0x0f }, { 0x0a, 0x11 }, { 0x0b, 0x13 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x30 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x23 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 }, }; sensor.gamma = { 2.38f, 2.35f, 2.34f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings { ResolutionFilter resolutions; unsigned exposure_lperiod; unsigned ccd_size_divisor; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 50 }, 12000, 2, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x28 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 75 }, 11000, 2, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x28 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 100 }, 11000, 2, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x28 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 150 }, 11000, 2, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x28 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 200 }, 11000, 2, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x28 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 300 }, 11000, 2, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x28 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 400 }, 11000, 2, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x28 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 600 }, 11000, 2, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x28 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 1200 }, 11000, 1, { { 0x08, 0x0d }, { 0x09, 0x0f }, { 0x0a, 0x11 }, { 0x0b, 0x13 }, { 0x16, 0x0b }, { 0x17, 0x0a }, { 0x18, 0x30 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x03 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x0b }, { 0x55, 0x0f }, { 0x56, 0x13 }, { 0x57, 0x17 }, { 0x58, 0x23 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.ccd_size_divisor = setting.ccd_size_divisor; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_HP2400; sensor.optical_res = 1200; sensor.black_pixels = 48; sensor.dummy_pixel = 15; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10872; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.stagger_config = StaggerConfig{1200, 4}; // FIXME: may be incorrect sensor.custom_base_regs = { { 0x08, 0x14 }, { 0x09, 0x15 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0xbf }, { 0x17, 0x08 }, { 0x18, 0x3f }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x0b }, { 0x53, 0x0f }, { 0x54, 0x13 }, { 0x55, 0x17 }, { 0x56, 0x03 }, { 0x57, 0x07 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x0e }, { 0x5d, 0x00 }, { 0x5e, 0x00 }, }; sensor.gamma = { 2.1f, 2.1f, 2.1f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings { ResolutionFilter resolutions; unsigned exposure_lperiod; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 50 }, 7211, { { 0x08, 0x14 }, { 0x09, 0x15 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0xbf }, { 0x17, 0x08 }, { 0x18, 0x3f }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x0b }, { 0x53, 0x0f }, { 0x54, 0x13 }, { 0x55, 0x17 }, { 0x56, 0x03 }, { 0x57, 0x07 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 100 }, 7211, { { 0x08, 0x14 }, { 0x09, 0x15 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0xbf }, { 0x17, 0x08 }, { 0x18, 0x3f }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x0b }, { 0x53, 0x0f }, { 0x54, 0x13 }, { 0x55, 0x17 }, { 0x56, 0x03 }, { 0x57, 0x07 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 150 }, 7211, { { 0x08, 0x14 }, { 0x09, 0x15 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0xbf }, { 0x17, 0x08 }, { 0x18, 0x3f }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x0b }, { 0x53, 0x0f }, { 0x54, 0x13 }, { 0x55, 0x17 }, { 0x56, 0x03 }, { 0x57, 0x07 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 300 }, 8751, { { 0x08, 0x14 }, { 0x09, 0x15 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0xbf }, { 0x17, 0x08 }, { 0x18, 0x3f }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x0b }, { 0x53, 0x0f }, { 0x54, 0x13 }, { 0x55, 0x17 }, { 0x56, 0x03 }, { 0x57, 0x07 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 600 }, 18760, { { 0x08, 0x0e }, { 0x09, 0x0f }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0xbf }, { 0x17, 0x08 }, { 0x18, 0x31 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x0b }, { 0x55, 0x0f }, { 0x56, 0x13 }, { 0x57, 0x17 }, { 0x58, 0x23 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 1200 }, 21749, { { 0x08, 0x02 }, { 0x09, 0x04 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0xbf }, { 0x17, 0x08 }, { 0x18, 0x30 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0xc0 }, { 0x1d, 0x42 }, { 0x52, 0x0b }, { 0x53, 0x0f }, { 0x54, 0x13 }, { 0x55, 0x17 }, { 0x56, 0x03 }, { 0x57, 0x07 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x0e }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_HP2300; sensor.optical_res = 600; sensor.ccd_size_divisor = 2; sensor.black_pixels = 48; sensor.dummy_pixel = 20; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 5368; sensor.fau_gain_white_ref = 180; sensor.gain_white_ref = 180; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.custom_base_regs = { { 0x08, 0x16 }, { 0x09, 0x00 }, { 0x0a, 0x01 }, { 0x0b, 0x03 }, { 0x16, 0xb7 }, { 0x17, 0x0a }, { 0x18, 0x20 }, { 0x19, 0x2a }, { 0x1a, 0x6a }, { 0x1b, 0x8a }, { 0x1c, 0x00 }, { 0x1d, 0x05 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x06 }, { 0x5c, 0x0b }, { 0x5d, 0x10 }, { 0x5e, 0x16 }, }; sensor.gamma = { 2.1f, 2.1f, 2.1f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings { ResolutionFilter resolutions; unsigned exposure_lperiod; unsigned ccd_size_divisor; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 75 }, 4480, 2, { { 0x08, 0x16 }, { 0x09, 0x00 }, { 0x0a, 0x01 }, { 0x0b, 0x03 }, { 0x16, 0xb7 }, { 0x17, 0x0a }, { 0x18, 0x20 }, { 0x19, 0x2a }, { 0x1a, 0x6a }, { 0x1b, 0x8a }, { 0x1c, 0x00 }, { 0x1d, 0x85 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x06 }, { 0x5c, 0x0b }, { 0x5d, 0x10 }, { 0x5e, 0x16 } } }, { { 150 }, 4350, 2, { { 0x08, 0x16 }, { 0x09, 0x00 }, { 0x0a, 0x01 }, { 0x0b, 0x03 }, { 0x16, 0xb7 }, { 0x17, 0x0a }, { 0x18, 0x20 }, { 0x19, 0x2a }, { 0x1a, 0x6a }, { 0x1b, 0x8a }, { 0x1c, 0x00 }, { 0x1d, 0x85 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x06 }, { 0x5c, 0x0b }, { 0x5d, 0x10 }, { 0x5e, 0x16 } } }, { { 300 }, 4350, 2, { { 0x08, 0x16 }, { 0x09, 0x00 }, { 0x0a, 0x01 }, { 0x0b, 0x03 }, { 0x16, 0xb7 }, { 0x17, 0x0a }, { 0x18, 0x20 }, { 0x19, 0x2a }, { 0x1a, 0x6a }, { 0x1b, 0x8a }, { 0x1c, 0x00 }, { 0x1d, 0x85 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x06 }, { 0x5c, 0x0b }, { 0x5d, 0x10 }, { 0x5e, 0x16 } } }, { { 600 }, 8700, 1, { { 0x08, 0x01 }, { 0x09, 0x03 }, { 0x0a, 0x04 }, { 0x0b, 0x06 }, { 0x16, 0xb7 }, { 0x17, 0x0a }, { 0x18, 0x20 }, { 0x19, 0x2a }, { 0x1a, 0x6a }, { 0x1b, 0x8a }, { 0x1c, 0x00 }, { 0x1d, 0x05 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x06 }, { 0x5c, 0x0b }, { 0x5d, 0x10 }, { 0x5e, 0x16 } } }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.ccd_size_divisor = setting.ccd_size_divisor; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_35; sensor.optical_res = 1200; sensor.ccd_size_divisor = 2; sensor.black_pixels = 87; sensor.dummy_pixel = 87; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10400; sensor.fau_gain_white_ref = 0; sensor.gain_white_ref = 0; sensor.exposure = { 0x0400, 0x0400, 0x0400 }; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0x00 }, { 0x17, 0x02 }, { 0x18, 0x00 }, { 0x19, 0x50 }, { 0x1a, 0x00 }, // TODO: 1a-1d: these do no harm, but may be neccessery for CCD { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x02 }, { 0x52, 0x05 }, // [GB](HI|LOW) not needed for cis { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x3a }, { 0x59, 0x03 }, { 0x5a, 0x40 }, { 0x5b, 0x00 }, // TODO: 5b-5e { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_XP200; sensor.optical_res = 600; sensor.black_pixels = 5; sensor.dummy_pixel = 38; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 5200; sensor.fau_gain_white_ref = 200; sensor.gain_white_ref = 200; sensor.exposure = { 0x1450, 0x0c80, 0x0a28 }; sensor.custom_base_regs = { { 0x08, 0x16 }, { 0x09, 0x00 }, { 0x0a, 0x01 }, { 0x0b, 0x03 }, { 0x16, 0xb7 }, { 0x17, 0x0a }, { 0x18, 0x20 }, { 0x19, 0x2a }, { 0x1a, 0x6a }, { 0x1b, 0x8a }, { 0x1c, 0x00 }, { 0x1d, 0x05 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x06 }, { 0x5c, 0x0b }, { 0x5d, 0x10 }, { 0x5e, 0x16 }, }; sensor.custom_regs = { { 0x08, 0x06 }, { 0x09, 0x07 }, { 0x0a, 0x0a }, { 0x0b, 0x04 }, { 0x16, 0x24 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x2a }, { 0x1a, 0x0a }, { 0x1b, 0x0a }, { 0x1c, 0x00 }, { 0x1d, 0x11 }, { 0x52, 0x08 }, { 0x53, 0x02 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x1a }, { 0x59, 0x51 }, { 0x5a, 0x00 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } }; sensor.gamma = { 2.1f, 2.1f, 2.1f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings { ResolutionFilter resolutions; std::vector channels; unsigned exposure_lperiod; SensorExposure exposure; }; CustomSensorSettings custom_settings[] = { { { 75 }, { 3 }, 5700, { 0x1644, 0x0c80, 0x092e } }, { { 100 }, { 3 }, 5700, { 0x1644, 0x0c80, 0x092e } }, { { 200 }, { 3 }, 5700, { 0x1644, 0x0c80, 0x092e } }, { { 300 }, { 3 }, 9000, { 0x1644, 0x0c80, 0x092e } }, { { 600 }, { 3 }, 16000, { 0x1644, 0x0c80, 0x092e } }, { { 75 }, { 1 }, 16000, { 0x050a, 0x0fa0, 0x1010 } }, { { 100 }, { 1 }, 7800, { 0x050a, 0x0fa0, 0x1010 } }, { { 200 }, { 1 }, 11000, { 0x050a, 0x0fa0, 0x1010 } }, { { 300 }, { 1 }, 13000, { 0x050a, 0x0fa0, 0x1010 } }, { { 600 }, { 1 }, 24000, { 0x050a, 0x0fa0, 0x1010 } }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.channels = setting.channels; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_HP3670; sensor.optical_res = 1200; sensor.black_pixels = 48; sensor.dummy_pixel = 16; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10872; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0, 0, 0 }; sensor.stagger_config = StaggerConfig{1200, 4}; // FIXME: may be incorrect sensor.custom_base_regs = { { 0x08, 0x00 }, { 0x09, 0x0a }, { 0x0a, 0x0b }, { 0x0b, 0x0d }, { 0x16, 0x33 }, { 0x17, 0x07 }, { 0x18, 0x20 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0xc0 }, { 0x1d, 0x43 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x00 }, { 0x5a, 0x15 }, { 0x5b, 0x05 }, { 0x5c, 0x0a }, { 0x5d, 0x0f }, { 0x5e, 0x00 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings { ResolutionFilter resolutions; unsigned exposure_lperiod; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 50 }, 5758, { { 0x08, 0x00 }, { 0x09, 0x0a }, { 0x0a, 0x0b }, { 0x0b, 0x0d }, { 0x16, 0x33 }, { 0x17, 0x07 }, { 0x18, 0x33 }, { 0x19, 0x2a }, { 0x1a, 0x02 }, { 0x1b, 0x13 }, { 0x1c, 0xc0 }, { 0x1d, 0x43 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x15 }, { 0x5a, 0xc1 }, { 0x5b, 0x05 }, { 0x5c, 0x0a }, { 0x5d, 0x0f }, { 0x5e, 0x00 } } }, { { 75 }, 4879, { { 0x08, 0x00 }, { 0x09, 0x0a }, { 0x0a, 0x0b }, { 0x0b, 0x0d }, { 0x16, 0x33 }, { 0x17, 0x07 }, { 0x18, 0x33 }, { 0x19, 0x2a }, { 0x1a, 0x02 }, { 0x1b, 0x13 }, { 0x1c, 0xc0 }, { 0x1d, 0x43 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x15 }, { 0x5a, 0xc1 }, { 0x5b, 0x05 }, { 0x5c, 0x0a }, { 0x5d, 0x0f }, { 0x5e, 0x00 } } }, { { 100 }, 4487, { { 0x08, 0x00 }, { 0x09, 0x0a }, { 0x0a, 0x0b }, { 0x0b, 0x0d }, { 0x16, 0x33 }, { 0x17, 0x07 }, { 0x18, 0x33 }, { 0x19, 0x2a }, { 0x1a, 0x02 }, { 0x1b, 0x13 }, { 0x1c, 0xc0 }, { 0x1d, 0x43 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x15 }, { 0x5a, 0xc1 }, { 0x5b, 0x05 }, { 0x5c, 0x0a }, { 0x5d, 0x0f }, { 0x5e, 0x00 } } }, { { 150 }, 4879, { { 0x08, 0x00 }, { 0x09, 0x0a }, { 0x0a, 0x0b }, { 0x0b, 0x0d }, { 0x16, 0x33 }, { 0x17, 0x07 }, { 0x18, 0x33 }, { 0x19, 0x2a }, { 0x1a, 0x02 }, { 0x1b, 0x13 }, { 0x1c, 0xc0 }, { 0x1d, 0x43 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x15 }, { 0x5a, 0xc1 }, { 0x5b, 0x05 }, { 0x5c, 0x0a }, { 0x5d, 0x0f }, { 0x5e, 0x00 } } }, { { 300 }, 4503, { { 0x08, 0x00 }, { 0x09, 0x0a }, { 0x0a, 0x0b }, { 0x0b, 0x0d }, { 0x16, 0x33 }, { 0x17, 0x07 }, { 0x18, 0x33 }, { 0x19, 0x2a }, { 0x1a, 0x02 }, { 0x1b, 0x13 }, { 0x1c, 0xc0 }, { 0x1d, 0x43 }, { 0x52, 0x0f }, { 0x53, 0x13 }, { 0x54, 0x17 }, { 0x55, 0x03 }, { 0x56, 0x07 }, { 0x57, 0x0b }, { 0x58, 0x83 }, { 0x59, 0x15 }, { 0x5a, 0xc1 }, { 0x5b, 0x05 }, { 0x5c, 0x0a }, { 0x5d, 0x0f }, { 0x5e, 0x00 } } }, { { 600 }, 10251, { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x06 }, { 0x0b, 0x08 }, { 0x16, 0x33 }, { 0x17, 0x07 }, { 0x18, 0x31 }, { 0x19, 0x2a }, { 0x1a, 0x02 }, { 0x1b, 0x0e }, { 0x1c, 0xc0 }, { 0x1d, 0x43 }, { 0x52, 0x0b }, { 0x53, 0x0f }, { 0x54, 0x13 }, { 0x55, 0x17 }, { 0x56, 0x03 }, { 0x57, 0x07 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x02 }, { 0x5c, 0x0e }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, { { 1200 }, 12750, { { 0x08, 0x0d }, { 0x09, 0x0f }, { 0x0a, 0x11 }, { 0x0b, 0x13 }, { 0x16, 0x2b }, { 0x17, 0x07 }, { 0x18, 0x30 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0xc0 }, { 0x1d, 0x43 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x0b }, { 0x55, 0x0f }, { 0x56, 0x13 }, { 0x57, 0x17 }, { 0x58, 0x23 }, { 0x59, 0x00 }, { 0x5a, 0xc1 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x00 } } }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_DP665; sensor.optical_res = 600; sensor.black_pixels = 27; sensor.dummy_pixel = 27; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 2496; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x1100, 0x1100, 0x1100 }; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0x00 }, { 0x17, 0x02 }, { 0x18, 0x04 }, { 0x19, 0x50 }, { 0x1a, 0x10 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x02 }, { 0x52, 0x04 }, // [GB](HI|LOW) not needed for cis { 0x53, 0x05 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x54 }, { 0x59, 0x03 }, { 0x5a, 0x00 }, { 0x5b, 0x00 }, // TODO: 5b-5e { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x01 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_ROADWARRIOR; sensor.optical_res = 600; sensor.black_pixels = 27; sensor.dummy_pixel = 27; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 5200; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x1100, 0x1100, 0x1100 }; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0x00 }, { 0x17, 0x02 }, { 0x18, 0x04 }, { 0x19, 0x50 }, { 0x1a, 0x10 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x02 }, { 0x52, 0x04 }, // [GB](HI|LOW) not needed for cis { 0x53, 0x05 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x54 }, { 0x59, 0x03 }, { 0x5a, 0x00 }, { 0x5b, 0x00 }, // TODO: 5b-5e { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x01 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_DSMOBILE600; sensor.optical_res = 600; sensor.black_pixels = 28; sensor.dummy_pixel = 28; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 5200; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x1544, 0x1544, 0x1544 }; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0x00 }, { 0x17, 0x02 }, { 0x18, 0x04 }, { 0x19, 0x50 }, { 0x1a, 0x10 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x02 }, { 0x52, 0x04 }, // [GB](HI|LOW) not needed for cis { 0x53, 0x05 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x54 }, { 0x59, 0x03 }, { 0x5a, 0x00 }, { 0x5b, 0x00 }, // TODO: 5b-5e { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x01 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_XP300; sensor.optical_res = 600; sensor.black_pixels = 27; sensor.dummy_pixel = 27; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10240; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x1100, 0x1100, 0x1100 }; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0x00 }, { 0x17, 0x02 }, { 0x18, 0x04 }, { 0x19, 0x50 }, { 0x1a, 0x10 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x02 }, { 0x52, 0x04 }, // [GB](HI|LOW) not needed for cis { 0x53, 0x05 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x54 }, { 0x59, 0x03 }, { 0x5a, 0x00 }, { 0x5b, 0x00 }, // TODO: 5b-5e { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x01 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_DP685; sensor.optical_res = 600; sensor.black_pixels = 27; sensor.dummy_pixel = 27; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 5020; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x1100, 0x1100, 0x1100 }; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0x00 }, { 0x17, 0x02 }, { 0x18, 0x04 }, { 0x19, 0x50 }, { 0x1a, 0x10 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x02 }, { 0x52, 0x04 }, // [GB](HI|LOW) not needed for cis { 0x53, 0x05 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x54 }, { 0x59, 0x03 }, { 0x5a, 0x00 }, { 0x5b, 0x00 }, // TODO: 5b-5e { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x01 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_200; sensor.optical_res = 4800; sensor.black_pixels = 87*4; sensor.dummy_pixel = 16*4; sensor.ccd_start_xoffset = 320*8; sensor.sensor_pixels = 5136*8; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; SensorExposure exposure; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { // Note: Windows driver uses 1424 lperiod and enables dummy line (0x17) { { 75, 100, 150, 200 }, 2848, { 304, 203, 180 }, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, // Note: Windows driver uses 788 lperiod and enables dummy line (0x17) { { 300, 400 }, 1424, { 304, 203, 180 }, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 600 }, 1432, { 492, 326, 296 }, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 1200 }, 2712, { 935, 592, 538 }, 5136, { 0, 1 }, { { 0x16, 0x10 }, { 0x17, 0x08 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 2400 }, 5280, { 1777, 1125, 979 }, 5136, { 0, 2, 1, 3 }, { { 0x16, 0x10 }, { 0x17, 0x06 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 4800 }, 10416, { 3377, 2138, 1780 }, 5136, { 0, 2, 4, 6, 1, 3, 5, 7 }, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } } }; for (const auto& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; sensor.segment_size = setting.segment_size; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_700F; sensor.optical_res = 4800; sensor.black_pixels = 73*8; // black pixels 73 at 600 dpi sensor.dummy_pixel = 16*8; // 384 at 600 dpi sensor.ccd_start_xoffset = 384*8; // 8x5570 segments, 5187+1 for rounding sensor.sensor_pixels = 5188*8; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; SensorExposure exposure; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 75, 100, 150, 200 }, 2848, { 465, 310, 239 }, 5187, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x87 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0xf9 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 300 }, 1424, { 465, 310, 239 }, 5187, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x87 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0xf9 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 600 }, 1504, { 465, 310, 239 }, 5187, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x87 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0xf9 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 1200 }, 2696, { 1464, 844, 555 }, 5187, { 0, 1 }, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x87 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0xf9 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 2400 }, 10576, { 2798, 1558, 972 }, 5187, { 0, 1, 2, 3 }, { { 0x16, 0x10 }, { 0x17, 0x08 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x87 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0xf9 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 4800 }, 10576, { 2798, 1558, 972 }, 5187, { 0, 1, 4, 5, 2, 3, 6, 7 }, { { 0x16, 0x10 }, { 0x17, 0x06 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x07 }, { 0x53, 0x03 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x87 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0xf9 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } } }; for (const auto& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; sensor.segment_size = setting.segment_size; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_100; sensor.optical_res = 2400; sensor.black_pixels = 87*4; sensor.dummy_pixel = 16*4; sensor.ccd_start_xoffset = 320*4; sensor.sensor_pixels = 5136*4; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x01c1, 0x0126, 0x00e5 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; SensorExposure exposure; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 75, 100, 150, 200 }, 2304, { 423, 294, 242 }, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 300 }, 1728, { 423, 294, 242 }, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 600 }, 1432, { 423, 294, 242 }, 5136, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x0a }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, }, }, { { 1200 }, 2712, { 791, 542, 403 }, 5136, {0, 1}, { { 0x16, 0x10 }, { 0x17, 0x08 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } }, { { 2400 }, 5280, { 1504, 1030, 766 }, 5136, {0, 2, 1, 3}, { { 0x16, 0x10 }, { 0x17, 0x06 }, { 0x18, 0x00 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x2a }, { 0x59, 0xe1 }, { 0x5a, 0x55 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, } } }; for (const auto& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; sensor.segment_size = setting.segment_size; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_KVSS080; sensor.optical_res = 600; sensor.black_pixels = 38; sensor.dummy_pixel = 38; sensor.ccd_start_xoffset = 152; sensor.sensor_pixels = 5376; sensor.fau_gain_white_ref = 160; sensor.gain_white_ref = 160; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.exposure_lperiod = 8000; sensor.custom_regs = { { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x00 }, { 0x77, 0x00 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff }, { 0x0c, 0x00 }, { 0x70, 0x01 }, { 0x71, 0x03 }, { 0x9e, 0x00 }, { 0xaa, 0x00 }, { 0x16, 0x33 }, { 0x17, 0x1c }, { 0x18, 0x00 }, { 0x19, 0x2a }, { 0x1a, 0x2c }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x04 }, { 0x52, 0x0c }, { 0x53, 0x0f }, { 0x54, 0x00 }, { 0x55, 0x03 }, { 0x56, 0x06 }, { 0x57, 0x09 }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0xc0 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_G4050; sensor.optical_res = 4800; sensor.black_pixels = 50*8; // 31 at 600 dpi dummy_pixels 58 at 1200 sensor.dummy_pixel = 58; sensor.ccd_start_xoffset = 152; sensor.sensor_pixels = 5360*8; sensor.fau_gain_white_ref = 160; sensor.gain_white_ref = 160; sensor.exposure = { 0x2c09, 0x22b8, 0x10f0 }; sensor.stagger_config = StaggerConfig{ 2400, 4 }; // FIXME: may be incorrect sensor.custom_regs = {}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; ScanMethod method; GenesysRegisterSettingSet extra_custom_regs; }; CustomSensorSettings custom_settings[] = { { { 100, 150, 200, 300, 400, 600 }, 8016, ScanMethod::FLATBED, { { 0x74, 0x00 }, { 0x75, 0x01 }, { 0x76, 0xff }, { 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff }, { 0x0c, 0x00 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x9e, 0x00 }, { 0xaa, 0x00 }, { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, { 0x56, 0x05 }, { 0x57, 0x08 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0x40 }, } }, { { 1200 }, 56064, ScanMethod::FLATBED, { { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x01 }, { 0x79, 0xff }, { 0x7a, 0x00 }, { 0x7b, 0x01 }, { 0x7c, 0xff }, { 0x0c, 0x20 }, { 0x70, 0x08 }, { 0x71, 0x0c }, { 0x9e, 0xc0 }, { 0xaa, 0x05 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0e }, { 0x57, 0x11 }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, } }, { { 2400 }, 56064, ScanMethod::FLATBED, { { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, { 0x0c, 0x20 }, { 0x70, 0x08 }, { 0x71, 0x0a }, { 0x9e, 0xc0 }, { 0xaa, 0x05 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0xc0 }, { 0x1d, 0x08 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0e }, { 0x57, 0x11 }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, } }, { { 4800 }, 42752, ScanMethod::FLATBED, { { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, { 0x0c, 0x21 }, { 0x70, 0x08 }, { 0x71, 0x0a }, { 0x9e, 0xc0 }, { 0xaa, 0x07 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0xc1 }, { 0x1d, 0x08 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0e }, { 0x57, 0x11 }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, } }, { ResolutionFilter::ANY, 15624, ScanMethod::TRANSPARENCY, { { 0x74, 0x00 }, { 0x75, 0x1c }, { 0x76, 0x7f }, { 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff }, { 0x0c, 0x00 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x9e, 0x00 }, { 0xaa, 0x00 }, { 0x16, 0x33 }, { 0x17, 0x4c }, { 0x18, 0x01 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, { 0x52, 0x0e }, { 0x53, 0x11 }, { 0x54, 0x02 }, { 0x55, 0x05 }, { 0x56, 0x08 }, { 0x57, 0x0b }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0xc0 }, } } }; auto base_custom_regs = sensor.custom_regs; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.method = setting.method; sensor.custom_regs = base_custom_regs; sensor.custom_regs.merge(setting.extra_custom_regs); s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_HP_4850C; sensor.optical_res = 4800; sensor.black_pixels = 100; sensor.dummy_pixel = 58; sensor.ccd_start_xoffset = 152; sensor.sensor_pixels = 5360*8; sensor.fau_gain_white_ref = 160; sensor.gain_white_ref = 160; sensor.exposure = { 0x2c09, 0x22b8, 0x10f0 }; sensor.stagger_config = StaggerConfig{ 2400, 4 }; // FIXME: may be incorrect sensor.custom_regs = {}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; ScanMethod method; GenesysRegisterSettingSet extra_custom_regs; }; CustomSensorSettings custom_settings[] = { { { 100, 150, 200, 300, 400, 600 }, 8016, ScanMethod::FLATBED, { { 0x0c, 0x00 }, { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x00 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, { 0x56, 0x05 }, { 0x57, 0x08 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x74, 0x00 }, { 0x75, 0x01 }, { 0x76, 0xff }, { 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff }, { 0x9e, 0x00 }, { 0xaa, 0x00 }, } }, { { 1200 }, 56064, ScanMethod::FLATBED, { { 0x0c, 0x20 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0e }, { 0x57, 0x11 }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x08 }, { 0x71, 0x0c }, { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x01 }, { 0x79, 0xff }, { 0x7a, 0x00 }, { 0x7b, 0x01 }, { 0x7c, 0xff }, { 0x9e, 0xc0 }, { 0xaa, 0x05 }, } }, { { 2400 }, 56064, ScanMethod::FLATBED, { { 0x0c, 0x20 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0xc0 }, { 0x1d, 0x08 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0e }, { 0x57, 0x11 }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x08 }, { 0x71, 0x0a }, { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, { 0x9e, 0xc0 }, { 0xaa, 0x05 }, } }, { { 4800 }, 42752, ScanMethod::FLATBED, { { 0x0c, 0x21 }, { 0x16, 0x3b }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x38 }, { 0x1b, 0x10 }, { 0x1c, 0xc1 }, { 0x1d, 0x08 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0e }, { 0x57, 0x11 }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x08 }, { 0x71, 0x0a }, { 0x74, 0x0f }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, { 0x9e, 0xc0 }, { 0xaa, 0x07 }, } }, { ResolutionFilter::ANY, 15624, ScanMethod::TRANSPARENCY, { { 0x0c, 0x00 }, { 0x16, 0x33 }, { 0x17, 0x4c }, { 0x18, 0x01 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, { 0x52, 0x0e }, { 0x53, 0x11 }, { 0x54, 0x02 }, { 0x55, 0x05 }, { 0x56, 0x08 }, { 0x57, 0x0b }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0xc0 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x74, 0x00 }, { 0x75, 0x1c }, { 0x76, 0x7f }, { 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x03 }, { 0x7b, 0xff }, { 0x7c, 0xff }, { 0x9e, 0x00 }, { 0xaa, 0x00 }, } } }; auto base_custom_regs = sensor.custom_regs; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.method = setting.method; sensor.custom_regs = base_custom_regs; sensor.custom_regs.merge(setting.extra_custom_regs); s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_CANON_4400F; sensor.optical_res = 4800; sensor.ccd_size_divisor = 4; sensor.black_pixels = 50*8; // 31 at 600 dpi, 58 at 1200 dpi sensor.dummy_pixel = 20; sensor.ccd_start_xoffset = 152; // 5360 max at 600 dpi sensor.sensor_pixels = 5700 * 8; sensor.fau_gain_white_ref = 160; sensor.gain_white_ref = 160; sensor.exposure = { 0x9c40, 0x9c40, 0x9c40 }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = get_sensor_optical_with_ccd_divisor; sensor.get_register_hwdpi_fun = [](const Genesys_Sensor&, unsigned) { return 4800; }; sensor.get_hwdpi_divisor_fun = [](const Genesys_Sensor&, unsigned) { return 1; }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; std::vector methods; GenesysRegisterSettingSet extra_custom_regs; }; CustomSensorSettings custom_settings[] = { { { 300, 600, 1200 }, 11640, { ScanMethod::FLATBED }, { { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x6b }, { 0x52, 0x0a }, { 0x53, 0x0d }, { 0x54, 0x00 }, { 0x55, 0x03 }, { 0x56, 0x06 }, { 0x57, 0x08 }, { 0x58, 0x5b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x72, 0x01 }, { 0x73, 0x03 }, { 0x74, 0x00 }, { 0x75, 0xf8 }, { 0x76, 0x38 }, { 0x77, 0x00 }, { 0x78, 0xfc }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0xa4 }, { 0x9e, 0x2d }, } }, { { 300, 600, 1200 }, 33300, { ScanMethod::TRANSPARENCY }, { { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x6b }, { 0x52, 0x0a }, { 0x53, 0x0d }, { 0x54, 0x00 }, { 0x55, 0x03 }, { 0x56, 0x06 }, { 0x57, 0x08 }, { 0x58, 0x5b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x72, 0x00 }, { 0x73, 0x02 }, { 0x74, 0x00 }, { 0x75, 0xf8 }, { 0x76, 0x38 }, { 0x77, 0x00 }, { 0x78, 0xfc }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0xa4 }, { 0x9e, 0x2d }, } }, { { 2400 }, 33300, { ScanMethod::TRANSPARENCY }, { { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x01 }, { 0x1d, 0x75 }, { 0x52, 0x0b }, { 0x53, 0x0d }, { 0x54, 0x00 }, { 0x55, 0x03 }, { 0x56, 0x06 }, { 0x57, 0x09 }, { 0x58, 0x53 }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x72, 0x02 }, { 0x73, 0x04 }, { 0x74, 0x00 }, { 0x75, 0xff }, { 0x76, 0x00 }, { 0x77, 0x00 }, { 0x78, 0xff }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x54 }, { 0x7c, 0x92 }, { 0x9e, 0x2d }, } }, { { 4800 }, 33300, { ScanMethod::TRANSPARENCY }, { { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x61 }, { 0x1d, 0x75 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0d }, { 0x57, 0x0f }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x08 }, { 0x71, 0x0a }, { 0x72, 0x0a }, { 0x73, 0x0c }, { 0x74, 0x00 }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x00 }, { 0x7b, 0x54 }, { 0x7c, 0x92 }, { 0x9e, 0x2d }, } } }; for (const CustomSensorSettings& setting : custom_settings) { for (auto method : setting.methods) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.method = method; sensor.custom_regs = setting.extra_custom_regs; s_sensors->push_back(sensor); } } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_CANON_8400F; sensor.optical_res = 3200; sensor.register_dpihw_override = 4800; sensor.ccd_size_divisor = 1; sensor.black_pixels = 50*8; // 31 at 600 dpi, 58 at 1200 dpi sensor.dummy_pixel = 20; sensor.ccd_start_xoffset = 152; sensor.sensor_pixels = 27200; sensor.fau_gain_white_ref = 160; sensor.gain_white_ref = 160; sensor.exposure = { 0x9c40, 0x9c40, 0x9c40 }; sensor.stagger_config = StaggerConfig{ 3200, 6 }; sensor.custom_regs = {}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = get_sensor_optical_with_ccd_divisor; sensor.get_register_hwdpi_fun = [](const Genesys_Sensor&, unsigned) { return 4800; }; sensor.get_hwdpi_divisor_fun = [](const Genesys_Sensor&, unsigned) { return 1; }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ResolutionFilter resolutions; unsigned dpiset_override; unsigned pixel_count_multiplier; int exposure_lperiod; std::vector methods; GenesysRegisterSettingSet extra_custom_regs; GenesysRegisterSettingSet custom_fe_regs; }; CustomSensorSettings custom_settings[] = { { { 400 }, 2400, 1, 7200, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, { 0x56, 0x07 }, { 0x57, 0x0a }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x01 }, { 0x71, 0x02 }, { 0x72, 0x03 }, { 0x73, 0x04 }, { 0x74, 0x00 }, { 0x75, 0x0e }, { 0x76, 0x3f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x01 }, { 0x7b, 0xb6 }, { 0x7c, 0xdb }, { 0x80, 0x2a }, }, {} }, { { 800 }, 4800, 1, 7200, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, { 0x56, 0x07 }, { 0x57, 0x0a }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x01 }, { 0x71, 0x02 }, { 0x72, 0x03 }, { 0x73, 0x04 }, { 0x74, 0x00 }, { 0x75, 0x0e }, { 0x76, 0x3f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x01 }, { 0x7b, 0xb6 }, { 0x7c, 0xdb }, { 0x80, 0x20 }, }, {} }, { { 1600 }, 4800, 1, 14400, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x11 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa1 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, { 0x56, 0x05 }, { 0x57, 0x08 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x01 }, { 0x71, 0x02 }, { 0x72, 0x02 }, { 0x73, 0x03 }, { 0x74, 0x00 }, { 0x75, 0x01 }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x02 }, { 0x7b, 0x49 }, { 0x7c, 0x24 }, { 0x80, 0x28 }, }, { { 0x03, 0x1f }, } }, { { 3200 }, 4800, 1, 28800, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x84 }, { 0x1e, 0xa1 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0e }, { 0x57, 0x11 }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x09 }, { 0x71, 0x0a }, { 0x72, 0x0b }, { 0x73, 0x0c }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x00 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x02 }, { 0x7b, 0x49 }, { 0x7c, 0x24 }, { 0x80, 0x2b }, }, { { 0x03, 0x1f }, }, }, { { 400 }, 2400, 1, 14400, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, { 0x56, 0x07 }, { 0x57, 0x0a }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x01 }, { 0x71, 0x02 }, { 0x72, 0x03 }, { 0x73, 0x04 }, { 0x74, 0x00 }, { 0x75, 0x0e }, { 0x76, 0x3f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x01 }, { 0x7b, 0xb6 }, { 0x7c, 0xdb }, { 0x80, 0x20 }, }, {} }, { { 800 }, 4800, 1, 14400, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, { 0x56, 0x07 }, { 0x57, 0x0a }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x01 }, { 0x71, 0x02 }, { 0x72, 0x03 }, { 0x73, 0x04 }, { 0x74, 0x00 }, { 0x75, 0x0e }, { 0x76, 0x3f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x01 }, { 0x7b, 0xb6 }, { 0x7c, 0xdb }, { 0x80, 0x20 }, }, {} }, { { 1600 }, 4800, 1, 28800, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x11 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, { 0x56, 0x05 }, { 0x57, 0x08 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x00 }, { 0x71, 0x01 }, { 0x72, 0x02 }, { 0x73, 0x03 }, { 0x74, 0x00 }, { 0x75, 0x01 }, { 0x76, 0xff }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x02 }, { 0x7b, 0x49 }, { 0x7c, 0x24 }, { 0x80, 0x29 }, }, { { 0x03, 0x1f }, }, }, { { 3200 }, 4800, 1, 28800, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, { 0x56, 0x0e }, { 0x57, 0x11 }, { 0x58, 0x1b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x09 }, { 0x71, 0x0a }, { 0x72, 0x0b }, { 0x73, 0x0c }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x00 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x02 }, { 0x7b, 0x49 }, { 0x7c, 0x24 }, { 0x80, 0x2b }, }, { { 0x03, 0x1f }, }, }, }; for (const CustomSensorSettings& setting : custom_settings) { for (auto method : setting.methods) { sensor.resolutions = setting.resolutions; sensor.dpiset_override = setting.dpiset_override; sensor.pixel_count_multiplier = setting.pixel_count_multiplier; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.method = method; sensor.custom_regs = setting.extra_custom_regs; sensor.custom_fe_regs = setting.custom_fe_regs; s_sensors->push_back(sensor); } } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_CANON_8600F; sensor.optical_res = 4800; sensor.ccd_size_divisor = 4; sensor.black_pixels = 31; sensor.dummy_pixel = 20; sensor.ccd_start_xoffset = 0; // not used at the moment // 11372 pixels at 1200 dpi sensor.sensor_pixels = 11372*4; sensor.fau_gain_white_ref = 160; sensor.gain_white_ref = 160; sensor.exposure = { 0x9c40, 0x9c40, 0x9c40 }; sensor.stagger_config = StaggerConfig{4800, 8}; sensor.custom_regs = {}; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = get_sensor_optical_with_ccd_divisor; sensor.get_register_hwdpi_fun = [](const Genesys_Sensor&, unsigned) { return 4800; }; sensor.get_hwdpi_divisor_fun = [](const Genesys_Sensor&, unsigned) { return 1; }; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; std::vector methods; GenesysRegisterSettingSet extra_custom_regs; GenesysRegisterSettingSet custom_fe_regs; }; CustomSensorSettings custom_settings[] = { { { 300, 600, 1200 }, 24000, { ScanMethod::FLATBED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x6b }, { 0x52, 0x0c }, { 0x53, 0x0f }, { 0x54, 0x00 }, { 0x55, 0x03 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x72, 0x02 }, { 0x73, 0x04 }, { 0x56, 0x06 }, { 0x57, 0x09 }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x74, 0x03 }, { 0x75, 0xf0 }, { 0x76, 0xf0 }, { 0x77, 0x03 }, { 0x78, 0xfe }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0x49 }, { 0x9e, 0x2d }, { 0xaa, 0x00 }, }, {}, }, { { 300, 600, 1200 }, 45000, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x6b }, { 0x52, 0x0c }, { 0x53, 0x0f }, { 0x54, 0x00 }, { 0x55, 0x03 }, { 0x56, 0x06 }, { 0x57, 0x09 }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x72, 0x02 }, { 0x73, 0x04 }, { 0x74, 0x03 }, { 0x75, 0xf0 }, { 0x76, 0xf0 }, { 0x77, 0x03 }, { 0x78, 0xfe }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0x49 }, { 0x9e, 0x2d }, { 0xaa, 0x00 }, }, {}, }, { { 2400 }, 45000, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x15 }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x01 }, { 0x1d, 0x75 }, { 0x52, 0x0c }, { 0x53, 0x0f }, { 0x54, 0x00 }, { 0x55, 0x03 }, { 0x56, 0x06 }, { 0x57, 0x09 }, { 0x58, 0x6b }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x00 }, { 0x71, 0x02 }, { 0x72, 0x02 }, { 0x73, 0x04 }, { 0x74, 0x03 }, { 0x75, 0xfe }, { 0x76, 0x00 }, { 0x77, 0x03 }, { 0x78, 0xfe }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0x49 }, { 0x9e, 0x2d }, { 0xaa, 0x00 }, }, {}, }, { { 4800 }, 45000, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x15 }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x61 }, { 0x1d, 0x75 }, { 0x52, 0x03 }, { 0x53, 0x06 }, { 0x54, 0x09 }, { 0x55, 0x0c }, { 0x56, 0x0f }, { 0x57, 0x00 }, { 0x58, 0x23 }, { 0x59, 0x00 }, { 0x5a, 0x40 }, { 0x70, 0x0a }, { 0x71, 0x0c }, { 0x72, 0x0c }, { 0x73, 0x0e }, { 0x74, 0x03 }, { 0x75, 0xff }, { 0x76, 0xff }, { 0x77, 0x03 }, { 0x78, 0xff }, { 0x79, 0xff }, { 0x7a, 0x00 }, { 0x7b, 0x92 }, { 0x7c, 0x49 }, { 0x9e, 0x2d }, { 0xaa, 0x00 }, }, { { 0x03, 0x1f }, }, }, }; for (const CustomSensorSettings& setting : custom_settings) { for (auto method : setting.methods) { sensor.resolutions = setting.resolutions; sensor.method = method; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.custom_regs = setting.extra_custom_regs; sensor.custom_fe_regs = setting.custom_fe_regs; s_sensors->push_back(sensor); } } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_HP_N6310; sensor.optical_res = 2400; // sensor.ccd_size_divisor = 2; Possibly half CCD, needs checking sensor.black_pixels = 96; sensor.dummy_pixel = 26; sensor.ccd_start_xoffset = 128; sensor.sensor_pixels = 42720; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.custom_regs = { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x02 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x08 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, { 0x56, 0x05 }, { 0x57, 0x08 }, { 0x58, 0x63 }, { 0x59, 0x00 }, { 0x5a, 0x40 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_110; sensor.optical_res = 2400; sensor.ccd_size_divisor = 2; sensor.black_pixels = 87; sensor.dummy_pixel = 16; sensor.ccd_start_xoffset = 303; sensor.sensor_pixels = 5168*4; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_gl124; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; SensorExposure exposure; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 75, 100, 150 }, 4608, { 462, 609, 453 }, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0c }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, { 0x70, 0x06 }, { 0x71, 0x08 }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x0a }, { 0x95, 0x18 }, { 0x96, 0x00 }, { 0x97, 0x9a }, { 0x98, 0x21 }, } }, { { 300 }, 4608, { 462, 609, 453 }, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x0c }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, { 0x70, 0x06 }, { 0x71, 0x08 }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x0a }, { 0x95, 0x18 }, { 0x96, 0x00 }, { 0x97, 0x9a }, { 0x98, 0x21 }, } }, { { 600 }, 5360, { 823, 1117, 805 }, std::vector{}, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x0a }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, { 0x70, 0x06 }, { 0x71, 0x08 }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x21 }, }, }, { { 1200 }, 10528, { 6071, 6670, 6042 }, { 0, 1 }, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 },{ 0x20, 0x08 }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, { 0x70, 0x06 }, { 0x71, 0x08 }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x12 }, { 0x89, 0x47 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x22 }, } }, { { 2400 }, 20864, { 7451, 8661, 7405 }, { 0, 2, 1, 3 }, { { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x06 }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, { 0x70, 0x06 }, { 0x71, 0x08 }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x12 }, { 0x89, 0x47 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x24 }, } } }; for (const auto& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_120; sensor.optical_res = 2400; sensor.ccd_size_divisor = 2; sensor.black_pixels = 87; sensor.dummy_pixel = 16; sensor.ccd_start_xoffset = 303; // SEGCNT at 600 DPI by number of segments sensor.sensor_pixels = 5104*4; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_gl124; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; SensorExposure exposure; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 75, 100, 150, 300 }, 4608, { 1244, 1294, 1144 }, std::vector{}, { { 0x16, 0x15 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x02 }, { 0x52, 0x04 }, { 0x53, 0x06 }, { 0x54, 0x00 }, { 0x55, 0x02 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x3a }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x61, 0x20 }, { 0x70, 0x00 }, { 0x71, 0x1f }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x0f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x5e }, { 0x93, 0x00 }, { 0x94, 0x09 }, { 0x95, 0xf8 }, { 0x96, 0x00 }, { 0x97, 0x70 }, { 0x98, 0x21 }, }, }, { { 600 }, 5360, { 2394, 2444, 2144 }, std::vector{}, { { 0x16, 0x11 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x02 }, { 0x52, 0x04 }, { 0x53, 0x06 }, { 0x54, 0x00 }, { 0x55, 0x02 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x3a }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x61, 0x20 }, { 0x70, 0x1f }, { 0x71, 0x1f }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x0f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x5e }, { 0x93, 0x00 }, { 0x94, 0x13 }, { 0x95, 0xf0 }, { 0x96, 0x00 }, { 0x97, 0x8b }, { 0x98, 0x21 }, }, }, { { 1200 }, 10528, { 4694, 4644, 4094 }, std::vector{}, { { 0x16, 0x15 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x02 }, { 0x52, 0x04 }, { 0x53, 0x06 }, { 0x54, 0x00 }, { 0x55, 0x02 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x3a }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x61, 0x20 }, { 0x70, 0x1f }, { 0x71, 0x1f }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x0f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x5e }, { 0x93, 0x00 }, { 0x94, 0x27 }, { 0x95, 0xe0 }, { 0x96, 0x00 }, { 0x97, 0xc0 }, { 0x98, 0x21 }, }, }, { { 2400 }, 20864, { 8944, 8144, 7994 }, std::vector{}, { { 0x16, 0x11 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x00 }, { 0x20, 0x02 }, { 0x52, 0x04 }, { 0x53, 0x06 }, { 0x54, 0x00 }, { 0x55, 0x02 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x3a }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x61, 0x20 }, { 0x70, 0x00 }, { 0x71, 0x1f }, { 0x72, 0x08 }, { 0x73, 0x0a }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x0f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x5e }, { 0x93, 0x00 }, { 0x94, 0x4f }, { 0x95, 0xc0 }, { 0x96, 0x01 }, { 0x97, 0x2a }, { 0x98, 0x21 }, } }, }; for (const auto& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_210; sensor.optical_res = 2400; sensor.ccd_size_divisor = 2; sensor.black_pixels = 87; sensor.dummy_pixel = 16; sensor.ccd_start_xoffset = 303; sensor.sensor_pixels = 5168*4; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_gl124; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; SensorExposure exposure; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 75, 100, 150, 300 }, 2768, { 388, 574, 393 }, std::vector{}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0c }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, // { 0x70, 0x00 }, // FIXME: check if default value is different { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x0a }, { 0x95, 0x18 }, { 0x96, 0x00 }, { 0x97, 0x9a }, { 0x98, 0x21 }, } }, { { 600 }, 5360, { 388, 574, 393 }, std::vector{}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0a }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, // { 0x70, 0x00 }, // FIXME: check if default value is different { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x21 }, } }, { { 1200 }, 10528, { 388, 574, 393 }, {0, 1}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x08 }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, // { 0x70, 0x00 }, // FIXME: check if default value is different { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x22 }, }, }, { { 2400 }, 20864, { 6839, 8401, 6859 }, {0, 2, 1, 3}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x06 }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, // { 0x70, 0x00 }, // FIXME: check if default value is different { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x1e }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x12 }, { 0x89, 0x47 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x24 }, }, } }; for (const auto& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_220; sensor.optical_res = 2400; sensor.ccd_size_divisor = 2; sensor.black_pixels = 87; sensor.dummy_pixel = 16; sensor.ccd_start_xoffset = 303; sensor.sensor_pixels = 5168*4; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.gamma = { 2.2f, 2.2f, 2.2f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_gl124; { struct CustomSensorSettings { ResolutionFilter resolutions; int exposure_lperiod; SensorExposure exposure; std::vector segment_order; GenesysRegisterSettingSet custom_regs; }; CustomSensorSettings custom_settings[] = { { { 75, 100, 150, 300 }, 2768, { 388, 574, 393 }, std::vector{}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0c }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, // { 0x70, 0x00 }, // FIXME: check if default value is different { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x0f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x0a }, { 0x95, 0x18 }, { 0x96, 0x00 }, { 0x97, 0x9a }, { 0x98, 0x21 }, } }, { { 600 }, 5360, { 388, 574, 393 }, std::vector{}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x0a }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, // { 0x70, 0x00 }, // FIXME: check if default value is different { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x0f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x21 }, } }, { { 1200 }, 10528, { 388, 574, 393 }, {0, 1}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x08 }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, // { 0x70, 0x00 }, // FIXME: check if default value is different { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x0f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x00 }, { 0x89, 0x65 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x22 }, } }, { { 2400 }, 20864, { 6839, 8401, 6859 }, {0, 2, 1, 3}, { // { 0x16, 0x00 }, // FIXME: check if default value is different { 0x16, 0x10 }, { 0x17, 0x04 }, { 0x18, 0x00 }, { 0x19, 0x01 }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x02 }, { 0x1d, 0x01 }, { 0x20, 0x06 }, { 0x52, 0x00 }, { 0x53, 0x02 }, { 0x54, 0x04 }, { 0x55, 0x06 }, { 0x56, 0x04 }, { 0x57, 0x04 }, { 0x58, 0x04 }, { 0x59, 0x04 }, { 0x5a, 0x1a }, { 0x5b, 0x00 }, { 0x5c, 0xc0 }, { 0x61, 0x20 }, // { 0x70, 0x00 }, // FIXME: check if default value is different { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x0f }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, { 0x88, 0x12 }, { 0x89, 0x47 }, { 0x93, 0x00 }, { 0x94, 0x14 }, { 0x95, 0x30 }, { 0x96, 0x00 }, { 0x97, 0xa3 }, { 0x98, 0x24 }, }, } }; for (const auto& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.exposure = setting.exposure; sensor.segment_order = setting.segment_order; sensor.custom_regs = setting.custom_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_PLUSTEK_OPTICPRO_3600; sensor.optical_res = 1200; sensor.ccd_size_divisor = 2; sensor.black_pixels = 87; sensor.dummy_pixel = 87; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10100; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x0b, 0x00 }, { 0x16, 0x33 }, { 0x17, 0x0b }, { 0x18, 0x11 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0xc4 }, { 0x52, 0x07 }, // [GB](HI|LOW) not needed for cis { 0x53, 0x0a }, { 0x54, 0x0c }, { 0x55, 0x00 }, { 0x56, 0x02 }, { 0x57, 0x06 }, { 0x58, 0x22 }, { 0x59, 0x69 }, { 0x5a, 0x40 }, { 0x5b, 0x00 }, // TODO: 5b-5e { 0x5c, 0x00 }, { 0x5d, 0x00 }, { 0x5e, 0x02 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_PLUSTEK_OPTICFILM_7200I; sensor.optical_res = 7200; sensor.register_dpihw_override = 1200; sensor.black_pixels = 88; // TODO sensor.dummy_pixel = 20; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10200; // TODO sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.stagger_config = StaggerConfig{7200, 4}; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x16, 0x23 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x21 }, { 0x1d, 0x84 }, { 0x52, 0x0a }, { 0x53, 0x0d }, { 0x54, 0x10 }, { 0x55, 0x01 }, { 0x56, 0x04 }, { 0x57, 0x07 }, { 0x58, 0x3a }, { 0x59, 0x81 }, { 0x5a, 0xc0 }, { 0x70, 0x0a }, { 0x71, 0x0b }, { 0x72, 0x0c }, { 0x73, 0x0d }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x00 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings { ResolutionFilter resolutions; ScanMethod method; unsigned ccd_size_divisor; unsigned logical_dpihw_override; unsigned pixel_count_multiplier; unsigned exposure_lperiod; unsigned dpiset_override; GenesysRegisterSettingSet custom_fe_regs; }; CustomSensorSettings custom_settings[] = { { { 900 }, ScanMethod::TRANSPARENCY, 1, 900, 8, 0x2538, 150, {} }, { { 1800 }, ScanMethod::TRANSPARENCY, 1, 1800, 4, 0x2538, 300, {} }, { { 3600 }, ScanMethod::TRANSPARENCY, 1, 3600, 2, 0x2538, 600, {} }, { { 7200 }, ScanMethod::TRANSPARENCY, 1, 7200, 1, 0x19c8, 1200, { { 0x02, 0x1b }, { 0x03, 0x14 }, { 0x04, 0x20 }, } }, { { 900 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 900, 8, 0x1f54, 150, {} }, { { 1800 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 1800, 4, 0x1f54, 300, {} }, { { 3600 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 3600, 2, 0x1f54, 600, {} }, { { 7200 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 7200, 1, 0x1f54, 1200, {} }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.method = setting.method; sensor.ccd_size_divisor = setting.ccd_size_divisor; sensor.logical_dpihw_override = setting.logical_dpihw_override; sensor.pixel_count_multiplier = setting.pixel_count_multiplier; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.dpiset_override = setting.dpiset_override; sensor.custom_fe_regs = setting.custom_fe_regs; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_PLUSTEK_OPTICFILM_7300; sensor.optical_res = 7200; sensor.method = ScanMethod::TRANSPARENCY; sensor.register_dpihw_override = 1200; sensor.black_pixels = 88; // TODO sensor.dummy_pixel = 20; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10200; // TODO sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.exposure_lperiod = 0x2f44; sensor.stagger_config = StaggerConfig{7200, 4}; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x16, 0x27 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x84 }, { 0x52, 0x0a }, { 0x53, 0x0d }, { 0x54, 0x0f }, { 0x55, 0x01 }, { 0x56, 0x04 }, { 0x57, 0x07 }, { 0x58, 0x31 }, { 0x59, 0x79 }, { 0x5a, 0xc0 }, { 0x70, 0x0c }, { 0x71, 0x0d }, { 0x72, 0x0e }, { 0x73, 0x0f }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x00 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings { ResolutionFilter resolutions; unsigned ccd_size_divisor; unsigned logical_dpihw_override; unsigned pixel_count_multiplier; unsigned dpiset_override; }; CustomSensorSettings custom_settings[] = { { { 900 }, 1, 900, 8, 150 }, { { 1800 }, 1, 1800, 4, 300 }, { { 3600 }, 1, 3600, 2, 600 }, { { 7200 }, 1, 7200, 1, 1200 }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.ccd_size_divisor = setting.ccd_size_divisor; sensor.logical_dpihw_override = setting.logical_dpihw_override; sensor.pixel_count_multiplier = setting.pixel_count_multiplier; sensor.dpiset_override = setting.dpiset_override; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_PLUSTEK_OPTICFILM_7500I; sensor.optical_res = 7200; sensor.register_dpihw_override = 1200; sensor.black_pixels = 88; // TODO sensor.dummy_pixel = 20; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10200; // TODO sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 230; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.stagger_config = StaggerConfig{7200, 4}; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x00 }, { 0x0a, 0x00 }, { 0x16, 0x27 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x84 }, { 0x52, 0x0a }, { 0x53, 0x0d }, { 0x54, 0x0f }, { 0x55, 0x01 }, { 0x56, 0x04 }, { 0x57, 0x07 }, { 0x58, 0x31 }, { 0x59, 0x79 }, { 0x5a, 0xc0 }, { 0x70, 0x0c }, { 0x71, 0x0d }, { 0x72, 0x0e }, { 0x73, 0x0f }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x00 }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x00 }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x00 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = get_ccd_size_divisor_exact; { struct CustomSensorSettings { ResolutionFilter resolutions; ScanMethod method; unsigned ccd_size_divisor; unsigned logical_dpihw_override; unsigned pixel_count_multiplier; unsigned exposure_lperiod; unsigned dpiset_override; }; CustomSensorSettings custom_settings[] = { { { 900 }, ScanMethod::TRANSPARENCY, 1, 900, 8, 0x2f44, 150 }, { { 1800 }, ScanMethod::TRANSPARENCY, 1, 1800, 4, 0x2f44, 300 }, { { 3600 }, ScanMethod::TRANSPARENCY, 1, 3600, 2, 0x2f44, 600 }, { { 7200 }, ScanMethod::TRANSPARENCY, 1, 7200, 1, 0x2f44, 1200 }, { { 900 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 900, 8, 0x2af8, 150 }, { { 1800 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 1800, 4, 0x2af8, 300 }, { { 3600 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 3600, 2, 0x2af8, 600 }, { { 7200 }, ScanMethod::TRANSPARENCY_INFRARED, 1, 7200, 1, 0x2af8, 1200 }, }; for (const CustomSensorSettings& setting : custom_settings) { sensor.resolutions = setting.resolutions; sensor.method = setting.method; sensor.ccd_size_divisor = setting.ccd_size_divisor; sensor.logical_dpihw_override = setting.logical_dpihw_override; sensor.pixel_count_multiplier = setting.pixel_count_multiplier; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.dpiset_override = setting.dpiset_override; s_sensors->push_back(sensor); } } sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_IMG101; sensor.resolutions = { 75, 100, 150, 300, 600, 1200 }; sensor.exposure_lperiod = 11000; sensor.segment_size = 5136; sensor.segment_order = {0, 1}; sensor.optical_res = 1200; sensor.black_pixels = 31; sensor.dummy_pixel = 31; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10800; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0x0000, 0x0000, 0x0000 }; sensor.custom_regs = { { 0x16, 0xbb }, { 0x17, 0x13 }, { 0x18, 0x10 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x06 }, { 0x52, 0x02 }, { 0x53, 0x04 }, { 0x54, 0x06 }, { 0x55, 0x08 }, { 0x56, 0x0a }, { 0x57, 0x00 }, { 0x58, 0x59 }, { 0x59, 0x31 }, { 0x5a, 0x40 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, }; sensor.gamma = { 1.7f, 1.7f, 1.7f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CCD_PLUSTEK_OPTICBOOK_3800; sensor.resolutions = { 75, 100, 150, 300, 600, 1200 }; sensor.exposure_lperiod = 11000; sensor.optical_res = 1200; sensor.black_pixels = 31; sensor.dummy_pixel = 31; sensor.ccd_start_xoffset = 0; sensor.sensor_pixels = 10200; sensor.fau_gain_white_ref = 210; sensor.gain_white_ref = 200; sensor.exposure = { 0, 0, 0 }; sensor.custom_regs = { { 0x16, 0xbb }, { 0x17, 0x13 }, { 0x18, 0x10 }, { 0x19, 0xff }, { 0x1a, 0x34 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x06 }, { 0x52, 0x02 }, { 0x53, 0x04 }, { 0x54, 0x06 }, { 0x55, 0x08 }, { 0x56, 0x0a }, { 0x57, 0x00 }, { 0x58, 0x59 }, { 0x59, 0x31 }, { 0x5a, 0x40 }, { 0x74, 0x00 }, { 0x75, 0x00 }, { 0x76, 0x3c }, { 0x77, 0x00 }, { 0x78, 0x00 }, { 0x79, 0x9f }, { 0x7a, 0x00 }, { 0x7b, 0x00 }, { 0x7c, 0x55 }, }; sensor.gamma = { 1.7f, 1.7f, 1.7f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); sensor = Genesys_Sensor(); sensor.sensor_id = SensorId::CIS_CANON_LIDE_80; sensor.optical_res = 1200; // real hardware limit is 2400 sensor.ccd_size_divisor = 2; sensor.black_pixels = 20; sensor.dummy_pixel = 6; // tuned to give 3*8 multiple startx coordinate during shading calibration sensor.ccd_start_xoffset = 34; // 14=>3, 20=>2 // 10400, too wide=>10288 in shading data 10240~ // 10208 too short for shading, max shading data = 10240 pixels, endpix-startpix=10208 sensor.sensor_pixels = 10240; sensor.fau_gain_white_ref = 150; sensor.gain_white_ref = 150; // maps to 0x70-0x73 for GL841 sensor.exposure = { 0x1000, 0x1000, 0x0500 }; sensor.custom_regs = { { 0x08, 0x00 }, { 0x09, 0x05 }, { 0x0a, 0x07 }, { 0x0b, 0x09 }, { 0x16, 0x00 }, { 0x17, 0x01 }, { 0x18, 0x00 }, { 0x19, 0x06 }, { 0x1a, 0x00 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x04 }, { 0x52, 0x03 }, { 0x53, 0x07 }, { 0x54, 0x00 }, { 0x55, 0x00 }, { 0x56, 0x00 }, { 0x57, 0x00 }, { 0x58, 0x29 }, { 0x59, 0x69 }, { 0x5a, 0x55 }, { 0x5b, 0x00 }, { 0x5c, 0x00 }, { 0x5d, 0x20 }, { 0x5e, 0x41 }, }; sensor.gamma = { 1.0f, 1.0f, 1.0f }; sensor.get_logical_hwdpi_fun = default_get_logical_hwdpi; sensor.get_register_hwdpi_fun = default_get_logical_hwdpi; sensor.get_hwdpi_divisor_fun = default_get_hwdpi_divisor_for_dpi; sensor.get_ccd_size_divisor_fun = default_get_ccd_size_divisor_for_dpi; s_sensors->push_back(sensor); } } // namespace genesys sane-backends-1.0.29/backend/genesys/tables_frontend.cpp0000666000000000000000000003711213615534521020126 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "low.h" namespace genesys { StaticInit> s_frontends; void genesys_init_frontend_tables() { s_frontends.init(); GenesysFrontendLayout wolfson_layout; wolfson_layout.type = FrontendType::WOLFSON; wolfson_layout.offset_addr = { 0x20, 0x21, 0x22 }; wolfson_layout.gain_addr = { 0x28, 0x29, 0x2a }; GenesysFrontendLayout analog_devices; analog_devices.type = FrontendType::ANALOG_DEVICES; Genesys_Frontend fe; fe.id = AdcId::WOLFSON_UMAX; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x05 }, { 0x03, 0x11 }, { 0x20, 0x80 }, { 0x21, 0x80 }, { 0x22, 0x80 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x02 }, { 0x29, 0x02 }, { 0x2a, 0x02 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::WOLFSON_ST12; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x05 }, { 0x03, 0x03 }, { 0x20, 0xc8 }, { 0x21, 0xc8 }, { 0x22, 0xc8 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x04 }, { 0x29, 0x04 }, { 0x2a, 0x04 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::WOLFSON_ST24; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x05 }, { 0x03, 0x21 }, { 0x20, 0xc8 }, { 0x21, 0xc8 }, { 0x22, 0xc8 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x06 }, { 0x29, 0x06 }, { 0x2a, 0x06 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::WOLFSON_5345; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x05 }, { 0x03, 0x12 }, { 0x20, 0xb8 }, { 0x21, 0xb8 }, { 0x22, 0xb8 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x04 }, { 0x29, 0x04 }, { 0x2a, 0x04 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); // reg3=0x02 for 50-600 dpi, 0x32 (0x12 also works well) at 1200 fe = Genesys_Frontend(); fe.id = AdcId::WOLFSON_HP2400; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x05 }, { 0x03, 0x02 }, { 0x20, 0xb4 }, { 0x21, 0xb6 }, { 0x22, 0xbc }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x06 }, { 0x29, 0x09 }, { 0x2a, 0x08 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::WOLFSON_HP2300; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x04 }, { 0x03, 0x02 }, { 0x20, 0xbe }, { 0x21, 0xbe }, { 0x22, 0xbe }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x04 }, { 0x29, 0x04 }, { 0x2a, 0x04 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::CANON_LIDE_35; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x3d }, { 0x02, 0x08 }, { 0x03, 0x00 }, { 0x20, 0xe1 }, { 0x21, 0xe1 }, { 0x22, 0xe1 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x93 }, { 0x29, 0x93 }, { 0x2a, 0x93 }, }; fe.reg2 = {0x00, 0x19, 0x06}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::AD_XP200; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x58 }, { 0x01, 0x80 }, { 0x02, 0x00 }, { 0x03, 0x00 }, { 0x20, 0x09 }, { 0x21, 0x09 }, { 0x22, 0x09 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x09 }, { 0x29, 0x09 }, { 0x2a, 0x09 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::WOLFSON_XP300; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x35 }, { 0x02, 0x20 }, { 0x03, 0x14 }, { 0x20, 0xe1 }, { 0x21, 0xe1 }, { 0x22, 0xe1 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x93 }, { 0x29, 0x93 }, { 0x2a, 0x93 }, }; fe.reg2 = {0x07, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::WOLFSON_HP3670; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x05 }, { 0x03, 0x32 }, { 0x20, 0xba }, { 0x21, 0xb8 }, { 0x22, 0xb8 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x06 }, { 0x29, 0x05 }, { 0x2a, 0x04 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::WOLFSON_DSM600; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x35 }, { 0x02, 0x20 }, { 0x03, 0x14 }, { 0x20, 0x85 }, { 0x21, 0x85 }, { 0x22, 0x85 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0xa0 }, { 0x29, 0xa0 }, { 0x2a, 0xa0 }, }; fe.reg2 = {0x07, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::CANON_LIDE_200; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x9d }, { 0x01, 0x91 }, { 0x02, 0x00 }, { 0x03, 0x00 }, { 0x20, 0x00 }, { 0x21, 0x3f }, { 0x22, 0x00 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x32 }, { 0x29, 0x04 }, { 0x2a, 0x00 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::CANON_LIDE_700F; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x9d }, { 0x01, 0x9e }, { 0x02, 0x00 }, { 0x03, 0x00 }, { 0x20, 0x00 }, { 0x21, 0x3f }, { 0x22, 0x00 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x2f }, { 0x29, 0x04 }, { 0x2a, 0x00 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::KVSS080; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x23 }, { 0x02, 0x24 }, { 0x03, 0x0f }, { 0x20, 0x80 }, { 0x21, 0x80 }, { 0x22, 0x80 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x4b }, { 0x29, 0x4b }, { 0x2a, 0x4b }, }; fe.reg2 = {0x00,0x00,0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::G4050; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x23 }, { 0x02, 0x24 }, { 0x03, 0x1f }, { 0x20, 0x45 }, { 0x21, 0x45 }, { 0x22, 0x45 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x4b }, { 0x29, 0x4b }, { 0x2a, 0x4b }, }; fe.reg2 = {0x00,0x00,0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::CANON_LIDE_110; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x80 }, { 0x01, 0x8a }, { 0x02, 0x23 }, { 0x03, 0x4c }, { 0x20, 0x00 }, { 0x21, 0x00 }, { 0x22, 0x00 }, { 0x24, 0x00 }, { 0x25, 0xca }, { 0x26, 0x94 }, { 0x28, 0x00 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); /** @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 ?) */ fe = Genesys_Frontend(); fe.id = AdcId::CANON_LIDE_120; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x80 }, { 0x01, 0xa3 }, { 0x02, 0x2b }, { 0x03, 0x4c }, { 0x20, 0x00 }, { 0x21, 0x00 }, { 0x22, 0x00 }, { 0x24, 0x00 }, // actual address 0x05 { 0x25, 0xca }, // actual address 0x06 { 0x26, 0x95 }, // actual address 0x07 { 0x28, 0x00 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::PLUSTEK_OPTICPRO_3600; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x70 }, { 0x01, 0x80 }, { 0x02, 0x00 }, { 0x03, 0x00 }, { 0x20, 0x00 }, { 0x21, 0x00 }, { 0x22, 0x00 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x3f }, { 0x29, 0x3d }, { 0x2a, 0x3d }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::PLUSTEK_OPTICFILM_7200I; fe.layout = analog_devices; fe.regs = { { 0x00, 0xf8 }, { 0x01, 0x80 }, { 0x02, 0x0a }, { 0x03, 0x06 }, { 0x04, 0x0f }, { 0x05, 0x56 }, { 0x06, 0x64 }, { 0x07, 0x56 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::PLUSTEK_OPTICFILM_7300; fe.layout = analog_devices; fe.regs = { { 0x00, 0xf8 }, { 0x01, 0x80 }, { 0x02, 0x10 }, { 0x03, 0x06 }, { 0x04, 0x06 }, { 0x05, 0x09 }, { 0x06, 0x0a }, { 0x07, 0x0102 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::PLUSTEK_OPTICFILM_7500I; fe.layout = analog_devices; fe.regs = { { 0x00, 0xf8 }, { 0x01, 0x80 }, { 0x02, 0x1d }, { 0x03, 0x17 }, { 0x04, 0x13 }, { 0x05, 0x00 }, { 0x06, 0x00 }, { 0x07, 0x0111 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::CANON_4400F; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x23 }, { 0x02, 0x24 }, { 0x03, 0x2f }, { 0x20, 0x6d }, { 0x21, 0x67 }, { 0x22, 0x5b }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0xd8 }, { 0x29, 0xd1 }, { 0x2a, 0xb9 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::CANON_8400F; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x23 }, { 0x02, 0x24 }, { 0x03, 0x0f }, { 0x20, 0x60 }, { 0x21, 0x5c }, { 0x22, 0x6c }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x8a }, { 0x29, 0x9f }, { 0x2a, 0xc2 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::CANON_8600F; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x00 }, { 0x01, 0x23 }, { 0x02, 0x24 }, { 0x03, 0x2f }, { 0x20, 0x67 }, { 0x21, 0x69 }, { 0x22, 0x68 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0xdb }, { 0x29, 0xda }, { 0x2a, 0xd7 }, }; fe.reg2 = { 0x00, 0x00, 0x00 }; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::IMG101; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x78 }, { 0x01, 0xf0 }, { 0x02, 0x00 }, { 0x03, 0x00 }, { 0x20, 0x00 }, { 0x21, 0x00 }, { 0x22, 0x00 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x00 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); fe = Genesys_Frontend(); fe.id = AdcId::PLUSTEK_OPTICBOOK_3800; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x78 }, { 0x01, 0xf0 }, { 0x02, 0x00 }, { 0x03, 0x00 }, { 0x20, 0x00 }, { 0x21, 0x00 }, { 0x22, 0x00 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x00 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); /* reg0: control 74 data, 70 no data * reg3: offset * reg6: gain * reg0 , reg3, reg6 */ fe = Genesys_Frontend(); fe.id = AdcId::CANON_LIDE_80; fe.layout = wolfson_layout; fe.regs = { { 0x00, 0x70 }, { 0x01, 0x16 }, { 0x02, 0x60 }, { 0x03, 0x00 }, { 0x20, 0x00 }, { 0x21, 0x00 }, { 0x22, 0x00 }, { 0x24, 0x00 }, { 0x25, 0x00 }, { 0x26, 0x00 }, { 0x28, 0x00 }, { 0x29, 0x00 }, { 0x2a, 0x00 }, }; fe.reg2 = {0x00, 0x00, 0x00}; s_frontends->push_back(fe); } } // namespace genesys sane-backends-1.0.29/backend/genesys/device.h0000666000000000000000000002776513615534521015676 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_DEVICE_H #define BACKEND_GENESYS_DEVICE_H #include "calibration.h" #include "command_set.h" #include "buffer.h" #include "enums.h" #include "image_pipeline.h" #include "motor.h" #include "settings.h" #include "sensor.h" #include "register.h" #include "usb_device.h" #include "scanner_interface.h" #include namespace genesys { struct Genesys_Gpo { Genesys_Gpo() = default; // Genesys_Gpo GpioId id = GpioId::UNKNOWN; /* GL646 and possibly others: - have the value registers at 0x66 and 0x67 - have the enable registers at 0x68 and 0x69 GL841, GL842, GL843, GL846, GL848 and possibly others: - have the value registers at 0x6c and 0x6d. - have the enable registers at 0x6e and 0x6f. */ GenesysRegisterSettingSet regs; }; /// Stores a SANE_Fixed value which is automatically converted from and to floating-point values class FixedFloat { public: FixedFloat() = default; FixedFloat(const FixedFloat&) = default; FixedFloat(double number) : value_{SANE_FIX(number)} {} FixedFloat& operator=(const FixedFloat&) = default; FixedFloat& operator=(double number) { value_ = SANE_FIX(number); return *this; } operator double() const { return value(); } double value() const { return SANE_UNFIX(value_); } private: SANE_Fixed value_ = 0; }; struct MethodResolutions { std::vector methods; std::vector resolutions_x; std::vector resolutions_y; unsigned get_min_resolution_x() const { return *std::min_element(resolutions_x.begin(), resolutions_x.end()); } unsigned get_min_resolution_y() const { return *std::min_element(resolutions_y.begin(), resolutions_y.end()); } std::vector get_resolutions() const; }; /** @brief structure to describe a scanner model * This structure describes a model. It is composed of information on the * sensor, the motor, scanner geometry and flags to drive operation. */ struct Genesys_Model { Genesys_Model() = default; const char* name = nullptr; const char* vendor = nullptr; const char* model = nullptr; ModelId model_id = ModelId::UNKNOWN; AsicType asic_type = AsicType::UNKNOWN; // possible x and y resolutions for each method supported by the scanner std::vector resolutions; // possible depths in gray mode std::vector bpp_gray_values; // possible depths in color mode std::vector bpp_color_values; // the default scanning method. This is used when moving the head for example ScanMethod default_method = ScanMethod::FLATBED; // All offsets below are with respect to the sensor home position // Start of scan area in mm FixedFloat x_offset = 0; // Start of scan area in mm (Amount of feeding needed to get to the medium) FixedFloat y_offset = 0; // Size of scan area in mm FixedFloat x_size = 0; // Size of scan area in mm FixedFloat y_size = 0; // Start of white strip in mm FixedFloat y_offset_calib_white = 0; // Start of black mark in mm FixedFloat x_offset_calib_black = 0; // Start of scan area in transparency mode in mm FixedFloat x_offset_ta = 0; // Start of scan area in transparency mode in mm FixedFloat y_offset_ta = 0; // Size of scan area in transparency mode in mm FixedFloat x_size_ta = 0; // Size of scan area in transparency mode in mm FixedFloat y_size_ta = 0; // The position of the sensor when it's aligned with the lamp for transparency scanning FixedFloat y_offset_sensor_to_ta = 0; // Start of white strip in transparency mode in mm FixedFloat y_offset_calib_white_ta = 0; // Start of black strip in transparency mode in mm FixedFloat y_offset_calib_black_ta = 0; // Size of scan area after paper sensor stop sensing document in mm FixedFloat post_scan = 0; // Amount of feeding needed to eject document after finishing scanning in mm FixedFloat eject_feed = 0; // Line-distance correction (in pixel at optical_ydpi) for CCD scanners SANE_Int ld_shift_r = 0; SANE_Int ld_shift_g = 0; SANE_Int ld_shift_b = 0; // Order of the CCD/CIS colors ColorOrder line_mode_color_order = ColorOrder::RGB; // Is this a CIS or CCD scanner? bool is_cis = false; // Is this sheetfed scanner? bool is_sheetfed = false; // sensor type SensorId sensor_id = SensorId::UNKNOWN; // Analog-Digital converter type AdcId adc_id = AdcId::UNKNOWN; // General purpose output type GpioId gpio_id = GpioId::UNKNOWN; // stepper motor type MotorId motor_id = MotorId::UNKNOWN; // Which hacks are needed for this scanner? SANE_Word flags = 0; // Button flags, described existing buttons for the model SANE_Word buttons = 0; // how many lines are used for shading calibration SANE_Int shading_lines = 0; // how many lines are used for shading calibration in TA mode SANE_Int shading_ta_lines = 0; // how many lines are used to search start position SANE_Int search_lines = 0; const MethodResolutions& get_resolution_settings(ScanMethod method) const; std::vector get_resolutions(ScanMethod method) const; }; /** * Describes the current device status for the backend * session. This should be more accurately called * Genesys_Session . */ struct Genesys_Device { Genesys_Device() = default; ~Genesys_Device(); using Calibration = std::vector; // frees commonly used data void clear(); SANE_Word vendorId = 0; /**< USB vendor identifier */ SANE_Word productId = 0; /**< USB product identifier */ // USB mode: // 0: not set // 1: USB 1.1 // 2: USB 2.0 SANE_Int usb_mode = 0; std::string file_name; std::string calib_file; // if enabled, no calibration data will be loaded or saved to files SANE_Int force_calibration = 0; // if enabled, will ignore the scan offsets and start scanning at true origin. This allows // acquiring the positions of the black and white strips and the actual scan area bool ignore_offsets = false; Genesys_Model *model = nullptr; // pointers to low level functions std::unique_ptr cmd_set; Genesys_Register_Set reg; Genesys_Register_Set calib_reg; Genesys_Settings settings; Genesys_Frontend frontend, frontend_initial; // whether the frontend is initialized. This is currently used just to preserve historical // behavior bool frontend_is_init = false; Genesys_Gpo gpo; Genesys_Motor motor; std::uint8_t control[6] = {}; size_t average_size = 0; // number of pixels used during shading calibration size_t calib_pixels = 0; // number of lines used during shading calibration size_t calib_lines = 0; size_t calib_channels = 0; size_t calib_resolution = 0; // bytes to read from USB when calibrating. If 0, this is not set size_t calib_total_bytes_to_read = 0; // the session that was configured for calibration ScanSession calib_session; // certain scanners support much higher resolution when scanning transparency, but we can't // read whole width of the scanner as a single line at that resolution. Thus for stuff like // calibration we want to read only the possible calibration area. size_t calib_pixels_offset = 0; // gamma overrides. If a respective array is not empty then it means that the gamma for that // color is overridden. std::vector gamma_override_tables[3]; std::vector white_average_data; std::vector dark_average_data; bool already_initialized = false; bool read_active = false; // signal wether the park command has been issued bool parking = false; // for sheetfed scanner's, is TRUE when there is a document in the scanner bool document = false; Genesys_Buffer read_buffer; // buffer for digital lineart from gray data Genesys_Buffer binarize_buffer; // local buffer for gray data during dynamix lineart Genesys_Buffer local_buffer; // total bytes read sent to frontend size_t total_bytes_read = 0; // total bytes read to be sent to frontend size_t total_bytes_to_read = 0; // contains computed data for the current setup ScanSession session; // look up table used in dynamic rasterization unsigned char lineart_lut[256] = {}; Calibration calibration_cache; // number of scan lines used during scan int line_count = 0; // array describing the order of the sub-segments of the sensor std::vector segment_order; // buffer to handle even/odd data Genesys_Buffer oe_buffer = {}; // stores information about how the input image should be processed ImagePipelineStack pipeline; // an buffer that allows reading from `pipeline` in chunks of any size ImageBuffer pipeline_buffer; // when true the scanned picture is first buffered to allow software image enhancements bool buffer_image = false; // image buffer where the scanned picture is stored std::vector img_buffer; ImagePipelineNodeBytesSource& get_pipeline_source(); std::unique_ptr interface; bool is_head_pos_known(ScanHeadId scan_head) const; unsigned head_pos(ScanHeadId scan_head) const; void set_head_pos_unknown(); void set_head_pos_zero(ScanHeadId scan_head); void advance_head_pos_by_session(ScanHeadId scan_head); void advance_head_pos_by_steps(ScanHeadId scan_head, Direction direction, unsigned steps); private: // the position of the primary scan head in motor->base_dpi units unsigned head_pos_primary_ = 0; bool is_head_pos_primary_known_ = true; // the position of the secondary scan head in motor->base_dpi units. Only certain scanners // have a secondary scan head. unsigned head_pos_secondary_ = 0; bool is_head_pos_secondary_known_ = true; friend class ScannerInterfaceUsb; }; std::ostream& operator<<(std::ostream& out, const Genesys_Device& dev); void apply_reg_settings_to_device(Genesys_Device& dev, const GenesysRegisterSettingSet& regs); } // namespace genesys #endif sane-backends-1.0.29/backend/genesys/utilities.h0000666000000000000000000001254713615534521016442 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_UTILITIES_H #define BACKEND_GENESYS_UTILITIES_H #include "error.h" #include #include #include #include namespace genesys { template void compute_array_percentile_approx(T* result, const T* data, std::size_t line_count, std::size_t elements_per_line, float percentile) { if (line_count == 0) { throw SaneException("invalid line count"); } if (line_count == 1) { std::copy(data, data + elements_per_line, result); return; } std::vector column_elems; column_elems.resize(line_count, 0); std::size_t select_elem = std::min(static_cast(line_count * percentile), line_count - 1); auto select_it = column_elems.begin() + select_elem; for (std::size_t ix = 0; ix < elements_per_line; ++ix) { for (std::size_t iy = 0; iy < line_count; ++iy) { column_elems[iy] = data[iy * elements_per_line + ix]; } std::nth_element(column_elems.begin(), select_it, column_elems.end()); *result++ = *select_it; } } template class BasicStreamStateSaver { public: explicit BasicStreamStateSaver(std::basic_ios& stream) : stream_{stream} { flags_ = stream_.flags(); width_ = stream_.width(); precision_ = stream_.precision(); fill_ = stream_.fill(); } ~BasicStreamStateSaver() { stream_.flags(flags_); stream_.width(width_); stream_.precision(precision_); stream_.fill(fill_); } BasicStreamStateSaver(const BasicStreamStateSaver&) = delete; BasicStreamStateSaver& operator=(const BasicStreamStateSaver&) = delete; private: std::basic_ios& stream_; std::ios_base::fmtflags flags_; std::streamsize width_ = 0; std::streamsize precision_ = 0; Char fill_ = ' '; }; using StreamStateSaver = BasicStreamStateSaver>; template std::string format_indent_braced_list(unsigned indent, const T& x) { std::string indent_str(indent, ' '); std::ostringstream out; out << x; auto formatted_str = out.str(); if (formatted_str.empty()) { return formatted_str; } std::string out_str; for (std::size_t i = 0; i < formatted_str.size(); ++i) { out_str += formatted_str[i]; if (formatted_str[i] == '\n' && i < formatted_str.size() - 1 && formatted_str[i + 1] != '\n') { out_str += indent_str; } } return out_str; } template std::string format_vector_unsigned(unsigned indent, const std::vector& arg) { std::ostringstream out; std::string indent_str(indent, ' '); out << "std::vector{ "; for (const auto& el : arg) { out << indent_str << static_cast(el) << "\n"; } out << "}"; return out.str(); } template std::string format_vector_indent_braced(unsigned indent, const char* type, const std::vector& arg) { if (arg.empty()) { return "{}"; } std::string indent_str(indent, ' '); std::stringstream out; out << "std::vector<" << type << ">{\n"; for (const auto& item : arg) { out << indent_str << format_indent_braced_list(indent, item) << '\n'; } out << "}"; return out.str(); } } // namespace genesys #endif // BACKEND_GENESYS_UTILITIES_H sane-backends-1.0.29/backend/genesys/gl841_registers.h0000666000000000000000000002446113615534521017353 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL841_REGISTERS_H #define BACKEND_GENESYS_GL841_REGISTERS_H #include namespace genesys { namespace gl841 { using RegAddr = std::uint16_t; using RegMask = std::uint8_t; using RegShift = unsigned; static constexpr RegAddr REG_0x01 = 0x01; static constexpr RegMask REG_0x01_CISSET = 0x80; static constexpr RegMask REG_0x01_DOGENB = 0x40; static constexpr RegMask REG_0x01_DVDSET = 0x20; static constexpr RegMask REG_0x01_M16DRAM = 0x08; static constexpr RegMask REG_0x01_DRAMSEL = 0x04; static constexpr RegMask REG_0x01_SHDAREA = 0x02; static constexpr RegMask REG_0x01_SCAN = 0x01; static constexpr RegAddr REG_0x02 = 0x02; static constexpr RegMask REG_0x02_NOTHOME = 0x80; static constexpr RegMask REG_0x02_ACDCDIS = 0x40; static constexpr RegMask REG_0x02_AGOHOME = 0x20; static constexpr RegMask REG_0x02_MTRPWR = 0x10; static constexpr RegMask REG_0x02_FASTFED = 0x08; static constexpr RegMask REG_0x02_MTRREV = 0x04; static constexpr RegMask REG_0x02_HOMENEG = 0x02; static constexpr RegMask REG_0x02_LONGCURV = 0x01; static constexpr RegMask REG_0x03_LAMPDOG = 0x80; static constexpr RegMask REG_0x03_AVEENB = 0x40; static constexpr RegMask REG_0x03_XPASEL = 0x20; static constexpr RegMask REG_0x03_LAMPPWR = 0x10; static constexpr RegMask REG_0x03_LAMPTIM = 0x0f; static constexpr RegMask REG_0x04_LINEART = 0x80; static constexpr RegMask REG_0x04_BITSET = 0x40; static constexpr RegMask REG_0x04_AFEMOD = 0x30; static constexpr RegMask REG_0x04_FILTER = 0x0c; static constexpr RegMask REG_0x04_FESET = 0x03; static constexpr RegShift REG_0x04S_AFEMOD = 4; static constexpr RegAddr REG_0x05 = 0x05; static constexpr RegMask REG_0x05_DPIHW = 0xc0; static constexpr RegMask REG_0x05_DPIHW_600 = 0x00; static constexpr RegMask REG_0x05_DPIHW_1200 = 0x40; static constexpr RegMask REG_0x05_DPIHW_2400 = 0x80; static constexpr RegMask REG_0x05_MTLLAMP = 0x30; static constexpr RegMask REG_0x05_GMMENB = 0x08; static constexpr RegMask REG_0x05_MTLBASE = 0x03; static constexpr RegAddr REG_0x06 = 0x06; static constexpr RegMask REG_0x06_SCANMOD = 0xe0; static constexpr RegShift REG_0x06S_SCANMOD = 5; static constexpr RegMask REG_0x06_PWRBIT = 0x10; static constexpr RegMask REG_0x06_GAIN4 = 0x08; static constexpr RegMask REG_0x06_OPTEST = 0x07; static constexpr RegMask REG_0x07_SRAMSEL = 0x08; static constexpr RegMask REG_0x07_FASTDMA = 0x04; static constexpr RegMask REG_0x07_DMASEL = 0x02; static constexpr RegMask REG_0x07_DMARDWR = 0x01; static constexpr RegMask REG_0x08_DECFLAG = 0x40; static constexpr RegMask REG_0x08_GMMFFR = 0x20; static constexpr RegMask REG_0x08_GMMFFG = 0x10; static constexpr RegMask REG_0x08_GMMFFB = 0x08; static constexpr RegMask REG_0x08_GMMZR = 0x04; static constexpr RegMask REG_0x08_GMMZG = 0x02; static constexpr RegMask REG_0x08_GMMZB = 0x01; static constexpr RegMask REG_0x09_MCNTSET = 0xc0; static constexpr RegMask REG_0x09_CLKSET = 0x30; static constexpr RegMask REG_0x09_BACKSCAN = 0x08; static constexpr RegMask REG_0x09_ENHANCE = 0x04; static constexpr RegMask REG_0x09_SHORTTG = 0x02; static constexpr RegMask REG_0x09_NWAIT = 0x01; static constexpr RegShift REG_0x09S_MCNTSET = 6; static constexpr RegShift REG_0x09S_CLKSET = 4; static constexpr RegMask REG_0x0A_SRAMBUF = 0x01; static constexpr RegAddr REG_0x0D = 0x0d; static constexpr RegMask REG_0x0D_CLRLNCNT = 0x01; static constexpr RegMask REG_0x16_CTRLHI = 0x80; static constexpr RegMask REG_0x16_TOSHIBA = 0x40; static constexpr RegMask REG_0x16_TGINV = 0x20; static constexpr RegMask REG_0x16_CK1INV = 0x10; static constexpr RegMask REG_0x16_CK2INV = 0x08; static constexpr RegMask REG_0x16_CTRLINV = 0x04; static constexpr RegMask REG_0x16_CKDIS = 0x02; static constexpr RegMask REG_0x16_CTRLDIS = 0x01; static constexpr RegMask REG_0x17_TGMODE = 0xc0; static constexpr RegMask REG_0x17_TGMODE_NO_DUMMY = 0x00; static constexpr RegMask REG_0x17_TGMODE_REF = 0x40; static constexpr RegMask REG_0x17_TGMODE_XPA = 0x80; static constexpr RegMask REG_0x17_TGW = 0x3f; static constexpr RegShift REG_0x17S_TGW = 0; static constexpr RegMask REG_0x18_CNSET = 0x80; static constexpr RegMask REG_0x18_DCKSEL = 0x60; static constexpr RegMask REG_0x18_CKTOGGLE = 0x10; static constexpr RegMask REG_0x18_CKDELAY = 0x0c; static constexpr RegMask REG_0x18_CKSEL = 0x03; static constexpr RegMask REG_0x1A_MANUAL3 = 0x02; static constexpr RegMask REG_0x1A_MANUAL1 = 0x01; static constexpr RegMask REG_0x1A_CK4INV = 0x08; static constexpr RegMask REG_0x1A_CK3INV = 0x04; static constexpr RegMask REG_0x1A_LINECLP = 0x02; static constexpr RegMask REG_0x1C_TGTIME = 0x07; static constexpr RegMask REG_0x1D_CK4LOW = 0x80; static constexpr RegMask REG_0x1D_CK3LOW = 0x40; static constexpr RegMask REG_0x1D_CK1LOW = 0x20; static constexpr RegMask REG_0x1D_TGSHLD = 0x1f; static constexpr RegShift REG_0x1DS_TGSHLD = 0; static constexpr RegAddr REG_0x1E = 0x1e; static constexpr RegMask REG_0x1E_WDTIME = 0xf0; static constexpr RegShift REG_0x1ES_WDTIME = 4; static constexpr RegMask REG_0x1E_LINESEL = 0x0f; static constexpr RegShift REG_0x1ES_LINESEL = 0; static constexpr RegAddr REG_EXPR = 0x10; static constexpr RegAddr REG_EXPG = 0x12; static constexpr RegAddr REG_EXPB = 0x14; static constexpr RegAddr REG_STEPNO = 0x21; static constexpr RegAddr REG_FWDSTEP = 0x22; static constexpr RegAddr REG_BWDSTEP = 0x23; static constexpr RegAddr REG_FASTNO = 0x24; static constexpr RegAddr REG_LINCNT = 0x25; static constexpr RegAddr REG_DPISET = 0x2c; static constexpr RegAddr REG_STRPIXEL = 0x30; static constexpr RegAddr REG_ENDPIXEL = 0x32; static constexpr RegAddr REG_MAXWD = 0x35; static constexpr RegAddr REG_LPERIOD = 0x38; static constexpr RegAddr REG_0x40 = 0x40; static constexpr RegMask REG_0x40_HISPDFLG = 0x04; static constexpr RegMask REG_0x40_MOTMFLG = 0x02; static constexpr RegMask REG_0x40_DATAENB = 0x01; static constexpr RegMask REG_0x41_PWRBIT = 0x80; static constexpr RegMask REG_0x41_BUFEMPTY = 0x40; static constexpr RegMask REG_0x41_FEEDFSH = 0x20; static constexpr RegMask REG_0x41_SCANFSH = 0x10; static constexpr RegMask REG_0x41_HOMESNR = 0x08; static constexpr RegMask REG_0x41_LAMPSTS = 0x04; static constexpr RegMask REG_0x41_FEBUSY = 0x02; static constexpr RegMask REG_0x41_MOTORENB = 0x01; static constexpr RegMask REG_0x58_VSMP = 0xf8; static constexpr RegShift REG_0x58S_VSMP = 3; static constexpr RegMask REG_0x58_VSMPW = 0x07; static constexpr RegShift REG_0x58S_VSMPW = 0; static constexpr RegMask REG_0x59_BSMP = 0xf8; static constexpr RegShift REG_0x59S_BSMP = 3; static constexpr RegMask REG_0x59_BSMPW = 0x07; static constexpr RegShift REG_0x59S_BSMPW = 0; static constexpr RegMask REG_0x5A_ADCLKINV = 0x80; static constexpr RegMask REG_0x5A_RLCSEL = 0x40; static constexpr RegMask REG_0x5A_CDSREF = 0x30; static constexpr RegShift REG_0x5AS_CDSREF = 4; static constexpr RegMask REG_0x5A_RLC = 0x0f; static constexpr RegShift REG_0x5AS_RLC = 0; static constexpr RegMask REG_0x5E_DECSEL = 0xe0; static constexpr RegShift REG_0x5ES_DECSEL = 5; static constexpr RegMask REG_0x5E_STOPTIM = 0x1f; static constexpr RegShift REG_0x5ES_STOPTIM = 0; static constexpr RegMask REG_0x60_ZIMOD = 0x1f; static constexpr RegMask REG_0x61_Z1MOD = 0xff; static constexpr RegMask REG_0x62_Z1MOD = 0xff; static constexpr RegMask REG_0x63_Z2MOD = 0x1f; static constexpr RegMask REG_0x64_Z2MOD = 0xff; static constexpr RegMask REG_0x65_Z2MOD = 0xff; static constexpr RegMask REG_0x67_STEPSEL = 0xc0; static constexpr RegMask REG_0x67_FULLSTEP = 0x00; static constexpr RegMask REG_0x67_HALFSTEP = 0x40; static constexpr RegMask REG_0x67_QUATERSTEP = 0x80; static constexpr RegMask REG_0x67_MTRPWM = 0x3f; static constexpr RegMask REG_0x68_FSTPSEL = 0xc0; static constexpr RegMask REG_0x68_FULLSTEP = 0x00; static constexpr RegMask REG_0x68_HALFSTEP = 0x40; static constexpr RegMask REG_0x68_QUATERSTEP = 0x80; static constexpr RegMask REG_0x68_FASTPWM = 0x3f; static constexpr RegMask REG_0x6B_MULTFILM = 0x80; static constexpr RegMask REG_0x6B_GPOM13 = 0x40; static constexpr RegMask REG_0x6B_GPOM12 = 0x20; static constexpr RegMask REG_0x6B_GPOM11 = 0x10; static constexpr RegMask REG_0x6B_GPO18 = 0x02; static constexpr RegMask REG_0x6B_GPO17 = 0x01; static constexpr RegAddr REG_0x6B = 0x6b; static constexpr RegAddr REG_0x6C = 0x6c; static constexpr RegMask REG_0x6C_GPIOH = 0xff; static constexpr RegMask REG_0x6C_GPIOL = 0xff; static constexpr RegAddr REG_0x6D = 0x6d; static constexpr RegAddr REG_0x6E = 0x6e; static constexpr RegAddr REG_0x6F = 0x6f; static constexpr RegMask REG_0x87_LEDADD = 0x04; } // namespace gl841 } // namespace genesys #endif // BACKEND_GENESYS_GL841_REGISTERS_H sane-backends-1.0.29/backend/genesys/gl841.h0000666000000000000000000001244513615534521015263 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2011-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "genesys.h" #include "command_set.h" #ifndef BACKEND_GENESYS_GL841_H #define BACKEND_GENESYS_GL841_H namespace genesys { namespace gl841 { class CommandSetGl841 : public CommandSet { public: ~CommandSetGl841() override = default; bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const override; void init(Genesys_Device* dev) const override; void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const override; void init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const override; void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const override; void set_powersaving(Genesys_Device* dev, int delay) const override; void save_power(Genesys_Device* dev, bool enable) const override; void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, bool start_motor) const override; void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void search_start_position(Genesys_Device* dev) const override; void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const override; SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void wait_for_motor_stop(Genesys_Device* dev) const override; void move_back_home(Genesys_Device* dev, bool wait_until_home) const override; void update_hardware_sensors(struct Genesys_Scanner* s) const override; void load_document(Genesys_Device* dev) const override; void detect_document_end(Genesys_Device* dev) const override; void eject_document(Genesys_Device* dev) const override; void search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const override; void move_to_ta(Genesys_Device* dev) const override; void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const override; ScanSession calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const override; void asic_boot(Genesys_Device* dev, bool cold) const override; }; } // namespace gl841 } // namespace genesys #endif // BACKEND_GENESYS_GL841_H sane-backends-1.0.29/backend/genesys/register.h0000666000000000000000000003574613615534521016261 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_REGISTER_H #define BACKEND_GENESYS_REGISTER_H #include "utilities.h" #include #include #include #include #include #include #include namespace genesys { template struct Register { std::uint16_t address = 0; Value value = 0; }; using GenesysRegister = Register; template inline bool operator<(const Register& lhs, const Register& rhs) { return lhs.address < rhs.address; } struct GenesysRegisterSetState { bool is_lamp_on = false; bool is_xpa_on = false; bool is_motor_on = false; bool is_xpa_motor_on = false; }; template class RegisterContainer { public: enum Options { SEQUENTIAL = 1 }; using RegisterType = Register; using ContainerType = std::vector; using iterator = typename ContainerType::iterator; using const_iterator = typename ContainerType::const_iterator; RegisterContainer() = default; RegisterContainer(Options opts) : RegisterContainer() { if ((opts & SEQUENTIAL) == SEQUENTIAL) { sorted_ = false; } } void init_reg(std::uint16_t address, Value default_value) { if (find_reg_index(address) >= 0) { set(address, default_value); return; } RegisterType reg; reg.address = address; reg.value = default_value; registers_.push_back(reg); if (sorted_) std::sort(registers_.begin(), registers_.end()); } bool has_reg(std::uint16_t address) const { return find_reg_index(address) >= 0; } void remove_reg(std::uint16_t address) { int i = find_reg_index(address); if (i < 0) { throw std::runtime_error("the register does not exist"); } registers_.erase(registers_.begin() + i); } RegisterType& find_reg(std::uint16_t address) { int i = find_reg_index(address); if (i < 0) { throw std::runtime_error("the register does not exist"); } return registers_[i]; } const RegisterType& find_reg(std::uint16_t address) const { int i = find_reg_index(address); if (i < 0) { throw std::runtime_error("the register does not exist"); } return registers_[i]; } void set(std::uint16_t address, Value value) { find_reg(address).value = value; } Value get(std::uint16_t address) const { return find_reg(address).value; } void reserve(std::size_t size) { registers_.reserve(size); } void clear() { registers_.clear(); } std::size_t size() const { return registers_.size(); } iterator begin() { return registers_.begin(); } const_iterator begin() const { return registers_.begin(); } iterator end() { return registers_.end(); } const_iterator end() const { return registers_.end(); } private: int find_reg_index(std::uint16_t address) const { if (!sorted_) { for (std::size_t i = 0; i < registers_.size(); i++) { if (registers_[i].address == address) { return i; } } return -1; } RegisterType search; search.address = address; auto it = std::lower_bound(registers_.begin(), registers_.end(), search); if (it == registers_.end()) return -1; if (it->address != address) return -1; return std::distance(registers_.begin(), it); } // registers are stored in a sorted vector bool sorted_ = true; std::vector registers_; }; template std::ostream& operator<<(std::ostream& out, const RegisterContainer& container) { StreamStateSaver state_saver{out}; out << "RegisterContainer{\n"; out << std::hex; out.fill('0'); for (const auto& reg : container) { unsigned address_width = sizeof(reg.address) * 2; unsigned value_width = sizeof(reg.value) * 2; out << " 0x" << std::setw(address_width) << static_cast(reg.address) << " = 0x" << std::setw(value_width) << static_cast(reg.value) << '\n'; } out << "}"; return out; } class Genesys_Register_Set { public: static constexpr unsigned MAX_REGS = 256; using ContainerType = RegisterContainer; using iterator = typename ContainerType::iterator; using const_iterator = typename ContainerType::const_iterator; // FIXME: this shouldn't live here, but in a separate struct that contains Genesys_Register_Set GenesysRegisterSetState state; enum Options { SEQUENTIAL = 1 }; Genesys_Register_Set() { registers_.reserve(MAX_REGS); } // by default the register set is sorted by address. In certain cases it's importand to send // the registers in certain order: use the SEQUENTIAL option for that Genesys_Register_Set(Options opts) : registers_{static_cast(opts)} { registers_.reserve(MAX_REGS); } const ContainerType& registers() const { return registers_; } void init_reg(std::uint16_t address, std::uint8_t default_value) { registers_.init_reg(address, default_value); } bool has_reg(std::uint16_t address) const { return registers_.has_reg(address); } void remove_reg(std::uint16_t address) { registers_.remove_reg(address); } GenesysRegister& find_reg(std::uint16_t address) { return registers_.find_reg(address); } const GenesysRegister& find_reg(std::uint16_t address) const { return registers_.find_reg(address); } GenesysRegister* find_reg_address(std::uint16_t address) { return &find_reg(address); } const GenesysRegister* find_reg_address(std::uint16_t address) const { return &find_reg(address); } void set8(std::uint16_t address, std::uint8_t value) { find_reg(address).value = value; } void set8_mask(std::uint16_t address, std::uint8_t value, std::uint8_t mask) { auto& reg = find_reg(address); reg.value = (reg.value & ~mask) | value; } void set16(std::uint16_t address, std::uint16_t value) { find_reg(address).value = (value >> 8) & 0xff; find_reg(address + 1).value = value & 0xff; } void set24(std::uint16_t address, std::uint32_t value) { find_reg(address).value = (value >> 16) & 0xff; find_reg(address + 1).value = (value >> 8) & 0xff; find_reg(address + 2).value = value & 0xff; } std::uint8_t get8(std::uint16_t address) const { return find_reg(address).value; } std::uint16_t get16(std::uint16_t address) const { return (find_reg(address).value << 8) | find_reg(address + 1).value; } std::uint32_t get24(std::uint16_t address) const { return (find_reg(address).value << 16) | (find_reg(address + 1).value << 8) | find_reg(address + 2).value; } void clear() { registers_.clear(); } std::size_t size() const { return registers_.size(); } iterator begin() { return registers_.begin(); } const_iterator begin() const { return registers_.begin(); } iterator end() { return registers_.end(); } const_iterator end() const { return registers_.end(); } private: // registers are stored in a sorted vector ContainerType registers_; }; inline std::ostream& operator<<(std::ostream& out, const Genesys_Register_Set& regs) { out << regs.registers(); return out; } template struct RegisterSetting { using ValueType = Value; using AddressType = std::uint16_t; RegisterSetting() = default; RegisterSetting(AddressType p_address, ValueType p_value) : address(p_address), value(p_value) {} RegisterSetting(AddressType p_address, ValueType p_value, ValueType p_mask) : address(p_address), value(p_value), mask(p_mask) {} AddressType address = 0; ValueType value = 0; ValueType mask = 0xff; bool operator==(const RegisterSetting& other) const { return address == other.address && value == other.value && mask == other.mask; } }; using GenesysRegisterSetting = RegisterSetting; using GenesysRegisterSetting16 = RegisterSetting; template void serialize(Stream& str, RegisterSetting& reg) { serialize(str, reg.address); serialize(str, reg.value); serialize(str, reg.mask); } template class RegisterSettingSet { public: using ValueType = Value; using SettingType = RegisterSetting; using AddressType = typename SettingType::AddressType; using container = std::vector; using iterator = typename container::iterator; using const_iterator = typename container::const_iterator; RegisterSettingSet() = default; RegisterSettingSet(std::initializer_list ilist) : registers_(ilist) {} iterator begin() { return registers_.begin(); } const_iterator begin() const { return registers_.begin(); } iterator end() { return registers_.end(); } const_iterator end() const { return registers_.end(); } SettingType& operator[](std::size_t i) { return registers_[i]; } const SettingType& operator[](std::size_t i) const { return registers_[i]; } std::size_t size() const { return registers_.size(); } bool empty() const { return registers_.empty(); } void clear() { registers_.clear(); } void push_back(SettingType reg) { registers_.push_back(reg); } void merge(const RegisterSettingSet& other) { for (const auto& reg : other) { set_value(reg.address, reg.value); } } SettingType& find_reg(AddressType address) { int i = find_reg_index(address); if (i < 0) { throw std::runtime_error("the register does not exist"); } return registers_[i]; } const SettingType& find_reg(AddressType address) const { int i = find_reg_index(address); if (i < 0) { throw std::runtime_error("the register does not exist"); } return registers_[i]; } ValueType get_value(AddressType address) const { int index = find_reg_index(address); if (index >= 0) { return registers_[index].value; } throw std::out_of_range("Unknown register"); } void set_value(AddressType address, ValueType value) { int index = find_reg_index(address); if (index >= 0) { registers_[index].value = value; return; } push_back(SettingType(address, value)); } template friend void serialize(std::istream& str, RegisterSettingSet& reg); template friend void serialize(std::ostream& str, RegisterSettingSet& reg); bool operator==(const RegisterSettingSet& other) const { return registers_ == other.registers_; } private: int find_reg_index(AddressType address) const { for (std::size_t i = 0; i < registers_.size(); i++) { if (registers_[i].address == address) { return i; } } return -1; } std::vector registers_; }; using GenesysRegisterSettingSet = RegisterSettingSet; using GenesysRegisterSettingSet16 = RegisterSettingSet; template std::ostream& operator<<(std::ostream& out, const RegisterSettingSet& container) { StreamStateSaver state_saver{out}; out << "RegisterSettingSet{\n"; out << std::hex; out.fill('0'); for (const auto& reg : container) { unsigned address_width = sizeof(reg.address) * 2; unsigned value_width = sizeof(reg.value) * 2; unsigned mask_width = sizeof(reg.mask) * 2; out << " 0x" << std::setw(address_width) << static_cast(reg.address) << " = 0x" << std::setw(value_width) << static_cast(reg.value) << " & 0x" << std::setw(mask_width) << static_cast(reg.mask) << '\n'; } out << "}"; return out; } template inline void serialize(std::istream& str, RegisterSettingSet& reg) { using AddressType = typename RegisterSetting::AddressType; reg.clear(); const std::size_t max_register_address = 1 << (sizeof(AddressType) * CHAR_BIT); serialize(str, reg.registers_, max_register_address); } template inline void serialize(std::ostream& str, RegisterSettingSet& reg) { serialize(str, reg.registers_); } template void apply_registers_ordered(const RegisterSettingSet& set, std::initializer_list order, F f) { for (std::uint16_t addr : order) { f(set.find_reg(addr)); } for (const auto& reg : set) { if (std::find(order.begin(), order.end(), reg.address) != order.end()) { continue; } f(reg); } } } // namespace genesys #endif // BACKEND_GENESYS_REGISTER_H sane-backends-1.0.29/backend/genesys/scanner_interface.h0000666000000000000000000001030213615534521020063 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_SCANNER_INTERFACE_H #define BACKEND_GENESYS_SCANNER_INTERFACE_H #include "fwd.h" #include #include #include #include namespace genesys { // Represents an interface through which all low level operations are performed. class ScannerInterface { public: enum Flags { FLAG_NONE = 0, FLAG_SWAP_REGISTERS = 1 << 0, FLAG_SMALL_ADDRESS = 1 << 1 }; virtual ~ScannerInterface(); virtual bool is_mock() const = 0; virtual std::uint8_t read_register(std::uint16_t address) = 0; virtual void write_register(std::uint16_t address, std::uint8_t value) = 0; virtual void write_registers(const Genesys_Register_Set& regs) = 0; virtual void write_0x8c(std::uint8_t index, std::uint8_t value) = 0; virtual void bulk_read_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) = 0; virtual void bulk_write_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) = 0; // GL646, GL841, GL843 have different ways to write to RAM and to gamma tables // FIXME: remove flags when updating tests virtual void write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags = FLAG_NONE) = 0; virtual void write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags = FLAG_NONE) = 0; // GL845, GL846, GL847 and GL124 have a uniform way to write to RAM tables virtual void write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) = 0; virtual std::uint16_t read_fe_register(std::uint8_t address) = 0; virtual void write_fe_register(std::uint8_t address, std::uint16_t value) = 0; virtual IUsbDevice& get_usb_device() = 0; // sleeps the specified number of microseconds. Will not sleep if testing mode is enabled. virtual void sleep_us(unsigned microseconds) = 0; void sleep_ms(unsigned milliseconds) { sleep_us(milliseconds * 1000); } virtual void record_progress_message(const char* msg) = 0; virtual void record_slope_table(unsigned table_nr, const std::vector& steps) = 0; virtual void record_key_value(const std::string& key, const std::string& value) = 0; virtual void test_checkpoint(const std::string& name) = 0; }; } // namespace genesys #endif sane-backends-1.0.29/backend/genesys/image_buffer.cpp0000666000000000000000000001375113615534521017373 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "image_buffer.h" #include "image.h" namespace genesys { ImageBuffer::ImageBuffer(std::size_t size, ProducerCallback producer) : producer_{producer}, size_{size}, buffer_offset_{size} { buffer_.resize(size_); } bool ImageBuffer::get_data(std::size_t size, std::uint8_t* out_data) { const std::uint8_t* out_data_end = out_data + size; auto copy_buffer = [&]() { std::size_t bytes_copy = std::min(out_data_end - out_data, available()); std::memcpy(out_data, buffer_.data() + buffer_offset_, bytes_copy); out_data += bytes_copy; buffer_offset_ += bytes_copy; }; // first, read remaining data from buffer if (available() > 0) { copy_buffer(); } if (out_data == out_data_end) { return true; } // now the buffer is empty and there's more data to be read bool got_data = true; do { buffer_offset_ = 0; got_data &= producer_(size_, buffer_.data()); copy_buffer(); } while(out_data < out_data_end && got_data); return got_data; } void FakeBufferModel::push_step(std::size_t buffer_size, std::size_t row_bytes) { sizes_.push_back(buffer_size); available_sizes_.push_back(0); row_bytes_.push_back(row_bytes); } std::size_t FakeBufferModel::available_space() const { if (sizes_.empty()) throw SaneException("Model has not been setup"); return sizes_.front() - available_sizes_.front(); } void FakeBufferModel::simulate_read(std::size_t size) { if (sizes_.empty()) { throw SaneException("Model has not been setup"); } if (available_space() < size) { throw SaneException("Attempted to simulate read of too much memory"); } available_sizes_.front() += size; for (unsigned i = 1; i < sizes_.size(); ++i) { auto avail_src = available_sizes_[i - 1]; auto avail_dst = sizes_[i] - available_sizes_[i]; auto avail = (std::min(avail_src, avail_dst) / row_bytes_[i]) * row_bytes_[i]; available_sizes_[i - 1] -= avail; available_sizes_[i] += avail; } available_sizes_.back() = 0; } ImageBufferGenesysUsb::ImageBufferGenesysUsb(std::size_t total_size, const FakeBufferModel& buffer_model, ProducerCallback producer) : remaining_size_{total_size}, buffer_model_{buffer_model}, producer_{producer} {} bool ImageBufferGenesysUsb::get_data(std::size_t size, std::uint8_t* out_data) { const std::uint8_t* out_data_end = out_data + size; auto copy_buffer = [&]() { std::size_t bytes_copy = std::min(out_data_end - out_data, available()); std::memcpy(out_data, buffer_.data() + buffer_offset_, bytes_copy); out_data += bytes_copy; buffer_offset_ += bytes_copy; }; // first, read remaining data from buffer if (available() > 0) { copy_buffer(); } if (out_data == out_data_end) { return true; } // now the buffer is empty and there's more data to be read do { if (remaining_size_ == 0) return false; auto bytes_to_read = get_read_size(); buffer_offset_ = 0; buffer_end_ = bytes_to_read; buffer_.resize(bytes_to_read); producer_(bytes_to_read, buffer_.data()); if (remaining_size_ < bytes_to_read) { remaining_size_ = 0; } else { remaining_size_ -= bytes_to_read; } copy_buffer(); } while(out_data < out_data_end); return true; } std::size_t ImageBufferGenesysUsb::get_read_size() { std::size_t size = buffer_model_.available_space(); // never read an odd number. exception: last read // the chip internal counter does not count half words. size &= ~1; // Some setups need the reads to be multiples of 256 bytes size &= ~0xff; if (remaining_size_ < size) { size = remaining_size_; /*round up to a multiple of 256 bytes */ size += (size & 0xff) ? 0x100 : 0x00; size &= ~0xff; } buffer_model_.simulate_read(size); return size; } } // namespace genesys sane-backends-1.0.29/backend/genesys/calibration.h0000666000000000000000000000713713615534521016715 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_CALIBRATION_H #define BACKEND_GENESYS_CALIBRATION_H #include "sensor.h" #include "settings.h" #include namespace genesys { struct Genesys_Calibration_Cache { Genesys_Calibration_Cache() = default; ~Genesys_Calibration_Cache() = default; // used to check if entry is compatible SetupParams params; std::time_t last_calibration = 0; Genesys_Frontend frontend; Genesys_Sensor sensor; size_t calib_pixels = 0; size_t calib_channels = 0; size_t average_size = 0; std::vector white_average_data; std::vector dark_average_data; bool operator==(const Genesys_Calibration_Cache& other) const { return params == other.params && last_calibration == other.last_calibration && frontend == other.frontend && sensor == other.sensor && calib_pixels == other.calib_pixels && calib_channels == other.calib_channels && average_size == other.average_size && white_average_data == other.white_average_data && dark_average_data == other.dark_average_data; } }; template void serialize(Stream& str, Genesys_Calibration_Cache& x) { serialize(str, x.params); serialize_newline(str); serialize(str, x.last_calibration); serialize_newline(str); serialize(str, x.frontend); serialize_newline(str); serialize(str, x.sensor); serialize_newline(str); serialize(str, x.calib_pixels); serialize(str, x.calib_channels); serialize(str, x.average_size); serialize_newline(str); serialize(str, x.white_average_data); serialize_newline(str); serialize(str, x.dark_average_data); } } // namespace genesys #endif // BACKEND_GENESYS_CALIBRATION_H sane-backends-1.0.29/backend/genesys/register_cache.h0000666000000000000000000000546613615534521017400 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_REGISTER_CACHE_H #define BACKEND_GENESYS_REGISTER_CACHE_H #include "register.h" namespace genesys { template class RegisterCache { public: void update(std::uint16_t address, Value value) { if (regs_.has_reg(address)) { regs_.set(address, value); } else { regs_.init_reg(address, value); } } void update(const Genesys_Register_Set& regs) { for (const auto& reg : regs) { update(reg.address, reg.value); } } Value get(std::uint16_t address) const { return regs_.get(address); } private: RegisterContainer regs_; template friend std::ostream& operator<<(std::ostream& out, const RegisterCache& cache); }; template std::ostream& operator<<(std::ostream& out, const RegisterCache& cache) { out << cache.regs_; return out; } } // namespace genesys #endif // BACKEND_GENESYS_LINE_BUFFER_H sane-backends-1.0.29/backend/genesys/test_settings.cpp0000666000000000000000000000602013615534521017646 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "test_settings.h" namespace genesys { namespace { bool s_testing_mode = false; std::uint16_t s_vendor_id = 0; std::uint16_t s_product_id = 0; TestCheckpointCallback s_checkpoint_callback; } // namespace bool is_testing_mode() { return s_testing_mode; } void disable_testing_mode() { s_testing_mode = false; s_vendor_id = 0; s_product_id = 0; } void enable_testing_mode(std::uint16_t vendor_id, std::uint16_t product_id, TestCheckpointCallback checkpoint_callback) { s_testing_mode = true; s_vendor_id = vendor_id; s_product_id = product_id; s_checkpoint_callback = checkpoint_callback; } std::uint16_t get_testing_vendor_id() { return s_vendor_id; } std::uint16_t get_testing_product_id() { return s_product_id; } std::string get_testing_device_name() { std::string name; unsigned max_size = 50; name.resize(max_size); name.resize(std::snprintf(&name.front(), max_size, "test device:0x%04x:0x%04x", s_vendor_id, s_product_id)); return name; } TestCheckpointCallback get_testing_checkpoint_callback() { return s_checkpoint_callback; } } // namespace genesys sane-backends-1.0.29/backend/genesys/gl846.cpp0000666000000000000000000020651613615534521015627 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2012-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file * * This file handles GL846 and GL845 ASICs since they are really close to each other. */ #define DEBUG_DECLARE_ONLY #include "gl846.h" #include "gl846_registers.h" #include "test_settings.h" #include namespace genesys { namespace gl846 { /** * compute the step multiplier used */ static int gl846_get_step_multiplier (Genesys_Register_Set * regs) { GenesysRegister *r = sanei_genesys_get_address(regs, 0x9d); int value = 1; if (r != nullptr) { value = (r->value & 0x0f)>>1; value = 1 << value; } DBG (DBG_io, "%s: step multiplier is %d\n", __func__, value); return value; } /** @brief sensor specific settings */ static void gl846_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs) { DBG_HELPER(dbg); for (const auto& reg : sensor.custom_regs) { regs->set8(reg.address, reg.value); } regs->set16(REG_EXPR, sensor.exposure.red); regs->set16(REG_EXPG, sensor.exposure.green); regs->set16(REG_EXPB, sensor.exposure.blue); dev->segment_order = sensor.segment_order; } /** @brief set all registers to default values . * This function is called only once at the beginning and * fills register startup values for registers reused across scans. * Those that are rarely modified or not modified are written * individually. * @param dev device structure holding register set to initialize */ static void gl846_init_registers (Genesys_Device * dev) { DBG_HELPER(dbg); dev->reg.clear(); dev->reg.init_reg(0x01, 0x60); dev->reg.init_reg(0x02, 0x38); dev->reg.init_reg(0x03, 0x03); dev->reg.init_reg(0x04, 0x22); dev->reg.init_reg(0x05, 0x60); dev->reg.init_reg(0x06, 0x10); dev->reg.init_reg(0x08, 0x60); dev->reg.init_reg(0x09, 0x00); dev->reg.init_reg(0x0a, 0x00); dev->reg.init_reg(0x0b, 0x8b); dev->reg.init_reg(0x0c, 0x00); dev->reg.init_reg(0x0d, 0x00); dev->reg.init_reg(0x10, 0x00); dev->reg.init_reg(0x11, 0x00); dev->reg.init_reg(0x12, 0x00); dev->reg.init_reg(0x13, 0x00); dev->reg.init_reg(0x14, 0x00); dev->reg.init_reg(0x15, 0x00); dev->reg.init_reg(0x16, 0xbb); // SENSOR_DEF dev->reg.init_reg(0x17, 0x13); // SENSOR_DEF dev->reg.init_reg(0x18, 0x10); // SENSOR_DEF dev->reg.init_reg(0x19, 0x2a); // SENSOR_DEF dev->reg.init_reg(0x1a, 0x34); // SENSOR_DEF dev->reg.init_reg(0x1b, 0x00); // SENSOR_DEF dev->reg.init_reg(0x1c, 0x20); // SENSOR_DEF dev->reg.init_reg(0x1d, 0x06); // SENSOR_DEF dev->reg.init_reg(0x1e, 0xf0); dev->reg.init_reg(0x1f, 0x01); dev->reg.init_reg(0x20, 0x03); dev->reg.init_reg(0x21, 0x10); dev->reg.init_reg(0x22, 0x60); dev->reg.init_reg(0x23, 0x60); dev->reg.init_reg(0x24, 0x60); dev->reg.init_reg(0x25, 0x00); dev->reg.init_reg(0x26, 0x00); dev->reg.init_reg(0x27, 0x00); dev->reg.init_reg(0x2c, 0x00); dev->reg.init_reg(0x2d, 0x00); dev->reg.init_reg(0x2e, 0x80); dev->reg.init_reg(0x2f, 0x80); dev->reg.init_reg(0x30, 0x00); dev->reg.init_reg(0x31, 0x00); dev->reg.init_reg(0x32, 0x00); dev->reg.init_reg(0x33, 0x00); dev->reg.init_reg(0x34, 0x1f); dev->reg.init_reg(0x35, 0x00); dev->reg.init_reg(0x36, 0x40); dev->reg.init_reg(0x37, 0x00); dev->reg.init_reg(0x38, 0x2a); dev->reg.init_reg(0x39, 0xf8); dev->reg.init_reg(0x3d, 0x00); dev->reg.init_reg(0x3e, 0x00); dev->reg.init_reg(0x3f, 0x01); dev->reg.init_reg(0x52, 0x02); // SENSOR_DEF dev->reg.init_reg(0x53, 0x04); // SENSOR_DEF dev->reg.init_reg(0x54, 0x06); // SENSOR_DEF dev->reg.init_reg(0x55, 0x08); // SENSOR_DEF dev->reg.init_reg(0x56, 0x0a); // SENSOR_DEF dev->reg.init_reg(0x57, 0x00); // SENSOR_DEF dev->reg.init_reg(0x58, 0x59); // SENSOR_DEF dev->reg.init_reg(0x59, 0x31); // SENSOR_DEF dev->reg.init_reg(0x5a, 0x40); // SENSOR_DEF dev->reg.init_reg(0x5e, 0x1f); dev->reg.init_reg(0x5f, 0x01); dev->reg.init_reg(0x60, 0x00); dev->reg.init_reg(0x61, 0x00); dev->reg.init_reg(0x62, 0x00); dev->reg.init_reg(0x63, 0x00); dev->reg.init_reg(0x64, 0x00); dev->reg.init_reg(0x65, 0x00); dev->reg.init_reg(0x67, 0x7f); dev->reg.init_reg(0x68, 0x7f); dev->reg.init_reg(0x69, 0x01); dev->reg.init_reg(0x6a, 0x01); dev->reg.init_reg(0x70, 0x01); dev->reg.init_reg(0x71, 0x00); dev->reg.init_reg(0x72, 0x02); dev->reg.init_reg(0x73, 0x01); dev->reg.init_reg(0x74, 0x00); // SENSOR_DEF dev->reg.init_reg(0x75, 0x00); // SENSOR_DEF dev->reg.init_reg(0x76, 0x00); // SENSOR_DEF dev->reg.init_reg(0x77, 0x00); // SENSOR_DEF dev->reg.init_reg(0x78, 0x00); // SENSOR_DEF dev->reg.init_reg(0x79, 0x3f); // SENSOR_DEF dev->reg.init_reg(0x7a, 0x00); // SENSOR_DEF dev->reg.init_reg(0x7b, 0x09); // SENSOR_DEF dev->reg.init_reg(0x7c, 0x99); // SENSOR_DEF dev->reg.init_reg(0x7d, 0x20); dev->reg.init_reg(0x7f, 0x05); dev->reg.init_reg(0x80, 0x4f); dev->reg.init_reg(0x87, 0x02); dev->reg.init_reg(0x94, 0xff); dev->reg.init_reg(0x9d, 0x04); dev->reg.init_reg(0x9e, 0x00); dev->reg.init_reg(0xa1, 0xe0); dev->reg.init_reg(0xa2, 0x1f); dev->reg.init_reg(0xab, 0xc0); dev->reg.init_reg(0xbb, 0x00); dev->reg.init_reg(0xbc, 0x0f); dev->reg.init_reg(0xdb, 0xff); dev->reg.init_reg(0xfe, 0x08); dev->reg.init_reg(0xff, 0x02); dev->reg.init_reg(0x98, 0x20); dev->reg.init_reg(0x99, 0x00); dev->reg.init_reg(0x9a, 0x90); dev->reg.init_reg(0x9b, 0x00); dev->reg.init_reg(0xf8, 0x05); const auto& sensor = sanei_genesys_find_sensor_any(dev); sanei_genesys_set_dpihw(dev->reg, sensor, sensor.optical_res); /* initalize calibration reg */ dev->calib_reg = dev->reg; } /**@brief send slope table for motor movement * Send slope_table in machine byte order * @param dev device to send slope table * @param table_nr index of the slope table in ASIC memory * Must be in the [0-4] range. * @param slope_table pointer to 16 bit values array of the slope table * @param steps number of elements in the slope table */ static void gl846_send_slope_table(Genesys_Device* dev, int table_nr, const std::vector& slope_table, int steps) { DBG_HELPER_ARGS(dbg, "table_nr = %d, steps = %d", table_nr, steps); int i; char msg[10000]; /* sanity check */ if(table_nr<0 || table_nr>4) { throw SaneException("invalid table number %d", table_nr); } std::vector table(steps * 2); for (i = 0; i < steps; i++) { table[i * 2] = slope_table[i] & 0xff; table[i * 2 + 1] = slope_table[i] >> 8; } if (DBG_LEVEL >= DBG_io) { std::sprintf(msg, "write slope %d (%d)=", table_nr, steps); for (i = 0; i < steps; i++) { std::sprintf(msg+strlen(msg), "%d", slope_table[i]); } DBG (DBG_io, "%s: %s\n", __func__, msg); } if (dev->interface->is_mock()) { dev->interface->record_slope_table(table_nr, slope_table); } // slope table addresses are fixed dev->interface->write_ahb(0x10000000 + 0x4000 * table_nr, steps * 2, table.data()); } /** * Set register values of Analog Device type frontend * */ static void gl846_set_adi_fe(Genesys_Device* dev, uint8_t set) { DBG_HELPER(dbg); int i; // wait for FE to be ready auto status = scanner_read_status(*dev); while (status.is_front_end_busy) { dev->interface->sleep_ms(10); status = scanner_read_status(*dev); }; if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; } // write them to analog frontend dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x01, dev->frontend.regs.get_value(0x01)); for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x02 + i, dev->frontend.get_gain(i)); } for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x05 + i, dev->frontend.get_offset(i)); } } // Set values of analog frontend void CommandSetGl846::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const { DBG_HELPER_ARGS(dbg, "%s", set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == AFE_POWER_SAVE ? "powersave" : "huh?"); (void) sensor; /* route to specific analog frontend setup */ uint8_t frontend_type = dev->reg.find_reg(0x04).value & REG_0x04_FESET; switch (frontend_type) { case 0x02: /* ADI FE */ gl846_set_adi_fe(dev, set); break; default: throw SaneException("unsupported frontend type %d", frontend_type); } } // @brief set up motor related register for scan static void gl846_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const Motor_Profile& motor_profile, unsigned int scan_exposure_time, unsigned scan_yres, unsigned int scan_lines, unsigned int scan_dummy, unsigned int feed_steps, MotorFlag flags) { DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, scan_yres=%d, step_type=%d, scan_lines=%d, " "scan_dummy=%d, feed_steps=%d, flags=%x", scan_exposure_time, scan_yres, static_cast(motor_profile.step_type), scan_lines, scan_dummy, feed_steps, static_cast(flags)); int use_fast_fed; unsigned int fast_dpi; unsigned int feedl, dist; GenesysRegister *r; uint32_t z1, z2; unsigned int min_restep = 0x20; uint8_t val; unsigned int ccdlmt,tgtime; unsigned step_multiplier = gl846_get_step_multiplier(reg); use_fast_fed=0; /* no fast fed since feed works well */ if (dev->settings.yres == 4444 && feed_steps > 100 && !has_flag(flags, MotorFlag::FEED)) { use_fast_fed = 1; } DBG (DBG_io, "%s: use_fast_fed=%d\n", __func__, use_fast_fed); reg->set24(REG_LINCNT, scan_lines); DBG (DBG_io, "%s: lincnt=%d\n", __func__, scan_lines); /* compute register 02 value */ r = sanei_genesys_get_address(reg, REG_0x02); r->value = 0x00; sanei_genesys_set_motor_power(*reg, true); if (use_fast_fed) r->value |= REG_0x02_FASTFED; else r->value &= ~REG_0x02_FASTFED; if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { r->value |= REG_0x02_AGOHOME | REG_0x02_NOTHOME; } if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE) ||(scan_yres>=sensor.optical_res)) { r->value |= REG_0x02_ACDCDIS; } if (has_flag(flags, MotorFlag::REVERSE)) { r->value |= REG_0x02_MTRREV; } else { r->value &= ~REG_0x02_MTRREV; } /* scan and backtracking slope table */ auto scan_table = sanei_genesys_slope_table(dev->model->asic_type, scan_yres, scan_exposure_time, dev->motor.base_ydpi, step_multiplier, motor_profile); gl846_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); gl846_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); /* fast table */ fast_dpi=sanei_genesys_get_lowest_ydpi(dev); // BUG: looks like for fast moves we use inconsistent step type StepType fast_step_type = motor_profile.step_type; if (static_cast(motor_profile.step_type) >= static_cast(StepType::QUARTER)) { fast_step_type = StepType::QUARTER; } Motor_Profile fast_motor_profile = motor_profile; fast_motor_profile.step_type = fast_step_type; auto fast_table = sanei_genesys_slope_table(dev->model->asic_type, fast_dpi, scan_exposure_time, dev->motor.base_ydpi, step_multiplier, fast_motor_profile); gl846_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count); gl846_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); gl846_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.steps_count); /* correct move distance by acceleration and deceleration amounts */ feedl=feed_steps; if (use_fast_fed) { feedl <<= static_cast(fast_step_type); dist = (scan_table.steps_count + 2 * fast_table.steps_count); /* TODO read and decode REG_0xAB */ r = sanei_genesys_get_address (reg, 0x5e); dist += (r->value & 31); /* FEDCNT */ r = sanei_genesys_get_address(reg, REG_FEDCNT); dist += r->value; } else { feedl <<= static_cast(motor_profile.step_type); dist = scan_table.steps_count; if (has_flag(flags, MotorFlag::FEED)) { dist *= 2; } } DBG (DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* check for overflow */ if (dist < feedl) { feedl -= dist; } else { feedl = 0; } reg->set24(REG_FEEDL, feedl); DBG (DBG_io ,"%s: feedl=%d\n",__func__,feedl); r = sanei_genesys_get_address(reg, REG_0x0C); ccdlmt = (r->value & REG_0x0C_CCDLMT) + 1; r = sanei_genesys_get_address(reg, REG_0x1C); tgtime = 1 << (r->value & REG_0x1C_TGTIME); /* hi res motor speed GPIO */ /* uint8_t effective = dev->interface->read_register(REG_0x6C); */ /* if quarter step, bipolar Vref2 */ /* XXX STEF XXX GPIO if (motor_profile.step_type > 1) { if (motor_profile.step_type < 3) { val = effective & ~REG_0x6C_GPIO13; } else { val = effective | REG_0x6C_GPIO13; } } else { val = effective; } dev->interface->write_register(REG_0x6C, val); */ /* effective scan */ /* effective = dev->interface->read_register(REG_0x6C); val = effective | REG_0x6C_GPIO10; dev->interface->write_register(REG_0x6C, val); */ if(dev->model->gpio_id == GpioId::IMG101) { if (scan_yres == sensor.get_register_hwdpi(scan_yres)) { val=1; } else { val=0; } dev->interface->write_register(REG_0x7E, val); } min_restep = (scan_table.steps_count / step_multiplier) / 2 - 1; if (min_restep < 1) { min_restep = 1; } r = sanei_genesys_get_address(reg, REG_FWDSTEP); r->value = min_restep; r = sanei_genesys_get_address(reg, REG_BWDSTEP); r->value = min_restep; sanei_genesys_calculate_zmod(use_fast_fed, scan_exposure_time*ccdlmt*tgtime, scan_table.table, scan_table.steps_count, feedl, min_restep * step_multiplier, &z1, &z2); DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); reg->set24(REG_0x60, z1 | (static_cast(motor_profile.step_type) << (16 + REG_0x60S_STEPSEL))); DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); reg->set24(REG_0x63, z2 | (static_cast(motor_profile.step_type) << (16 + REG_0x63S_FSTPSEL))); r = sanei_genesys_get_address (reg, 0x1e); r->value &= 0xf0; /* 0 dummy lines */ r->value |= scan_dummy; /* dummy lines */ r = sanei_genesys_get_address(reg, REG_0x67); r->value = 0x7f; r = sanei_genesys_get_address(reg, REG_0x68); r->value = 0x7f; reg->set8(REG_STEPNO, scan_table.steps_count / step_multiplier); reg->set8(REG_FASTNO, scan_table.steps_count / step_multiplier); reg->set8(REG_FSHDEC, scan_table.steps_count / step_multiplier); reg->set8(REG_FMOVNO, fast_table.steps_count / step_multiplier); reg->set8(REG_FMOVDEC, fast_table.steps_count / step_multiplier); } /** @brief set up registers related to sensor * Set up the following registers 0x01 0x03 0x10-0x015 R/G/B exposures 0x19 EXPDMY 0x2e BWHI 0x2f BWLO 0x04 0x87 0x05 0x2c,0x2d DPISET 0x30,0x31 STRPIXEL 0x32,0x33 ENDPIXEL 0x35,0x36,0x37 MAXWD [25:2] (>>2) 0x38,0x39 LPERIOD 0x34 DUMMY */ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, unsigned int exposure_time, const ScanSession& session) { DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time); unsigned int dpihw; GenesysRegister *r; // resolution is divided according to ccd_pixels_per_system_pixel() unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel(); DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel); // to manage high resolution device while keeping good low resolution scanning speed, // we make hardware dpi vary dpihw = sensor.get_register_hwdpi(session.params.xres * ccd_pixels_per_system_pixel); DBG(DBG_io2, "%s: dpihw=%d\n", __func__, dpihw); gl846_setup_sensor(dev, sensor, reg); dev->cmd_set->set_fe(dev, sensor, AFE_SET); /* enable shading */ regs_set_optical_off(dev->model->asic_type, *reg); r = sanei_genesys_get_address(reg, REG_0x01); r->value |= REG_0x01_SHDAREA; if (has_flag(session.params.flags, ScanFlag::DISABLE_SHADING) || (dev->model->flags & GENESYS_FLAG_NO_CALIBRATION)) { r->value &= ~REG_0x01_DVDSET; } else { r->value |= REG_0x01_DVDSET; } r = sanei_genesys_get_address(reg, REG_0x03); r->value &= ~REG_0x03_AVEENB; sanei_genesys_set_lamp_power(dev, sensor, *reg, !has_flag(session.params.flags, ScanFlag::DISABLE_LAMP)); /* BW threshold */ r = sanei_genesys_get_address (reg, 0x2e); r->value = dev->settings.threshold; r = sanei_genesys_get_address (reg, 0x2f); r->value = dev->settings.threshold; /* monochrome / color scan */ r = sanei_genesys_get_address(reg, REG_0x04); switch (session.params.depth) { case 8: r->value &= ~(REG_0x04_LINEART | REG_0x04_BITSET); break; case 16: r->value &= ~REG_0x04_LINEART; r->value |= REG_0x04_BITSET; break; } r->value &= ~(REG_0x04_FILTER | REG_0x04_AFEMOD); if (session.params.channels == 1) { switch (session.params.color_filter) { case ColorFilter::RED: r->value |= 0x24; break; case ColorFilter::BLUE: r->value |= 0x2c; break; case ColorFilter::GREEN: r->value |= 0x28; break; default: break; // should not happen } } else { r->value |= 0x20; // mono } sanei_genesys_set_dpihw(*reg, sensor, dpihw); if (should_enable_gamma(session, sensor)) { reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB; } else { reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB; } /* CIS scanners can do true gray by setting LEDADD */ /* we set up LEDADD only when asked */ if (dev->model->is_cis) { r = sanei_genesys_get_address (reg, 0x87); r->value &= ~REG_0x87_LEDADD; if (session.enable_ledadd) { r->value |= REG_0x87_LEDADD; } /* RGB weighting r = sanei_genesys_get_address (reg, 0x01); r->value &= ~REG_0x01_TRUEGRAY; if (session.enable_ledadd)) { r->value |= REG_0x01_TRUEGRAY; }*/ } unsigned dpiset = session.params.xres * ccd_pixels_per_system_pixel; reg->set16(REG_DPISET, dpiset); DBG(DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); reg->set16(REG_STRPIXEL, session.pixel_startx); reg->set16(REG_ENDPIXEL, session.pixel_endx); build_image_pipeline(dev, session); /* MAXWD is expressed in 4 words unit */ // BUG: we shouldn't multiply by channels here reg->set24(REG_MAXWD, (session.output_line_bytes_raw * session.params.channels >> 2)); reg->set16(REG_LPERIOD, exposure_time); DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time); r = sanei_genesys_get_address (reg, 0x34); r->value = sensor.dummy_pixel; } void CommandSetGl846::init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const { DBG_HELPER(dbg); session.assert_computed(); int move; int exposure_time; int slope_dpi = 0; int dummy = 0; dummy = 3-session.params.channels; /* slope_dpi */ /* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */ if (dev->model->is_cis) { slope_dpi = session.params.yres * session.params.channels; } else { slope_dpi = session.params.yres; } slope_dpi = slope_dpi * (1 + dummy); exposure_time = sensor.exposure_lperiod; const auto& motor_profile = sanei_genesys_get_motor_profile(*gl846_motor_profiles, dev->model->motor_id, exposure_time); DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, static_cast(motor_profile.step_type)); /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode */ gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session); /*** motor parameters ***/ /* add tl_y to base movement */ move = session.params.starty; DBG(DBG_info, "%s: move=%d steps\n", __func__, move); MotorFlag mflags = MotorFlag::NONE; if (has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { mflags |= MotorFlag::DISABLE_BUFFER_FULL_MOVE; } if (has_flag(session.params.flags, ScanFlag::FEEDING)) { mflags |= MotorFlag::FEED; } if (has_flag(session.params.flags, ScanFlag::REVERSE)) { mflags |= MotorFlag::REVERSE; } gl846_init_motor_regs_scan(dev, sensor, reg, motor_profile, exposure_time, slope_dpi, dev->model->is_cis ? session.output_line_count * session.params.channels : session.output_line_count, dummy, move, mflags); /*** prepares data reordering ***/ dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); dev->read_active = true; dev->session = session; dev->total_bytes_read = 0; dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines; DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read); } ScanSession CommandSetGl846::calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const { int start; DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, settings); /* start */ start = static_cast(dev->model->x_offset); start += static_cast(settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = settings.xres; session.params.yres = settings.yres; session.params.startx = start; // not used session.params.starty = 0; // not used session.params.pixels = settings.pixels; session.params.requested_pixels = settings.requested_pixels; session.params.lines = settings.lines; session.params.depth = settings.depth; session.params.channels = settings.get_channels(); session.params.scan_method = settings.scan_method; session.params.scan_mode = settings.scan_mode; session.params.color_filter = settings.color_filter; session.params.flags = ScanFlag::NONE; compute_session(dev, session, sensor); return session; } // for fast power saving methods only, like disabling certain amplifiers void CommandSetGl846::save_power(Genesys_Device* dev, bool enable) const { (void) dev; DBG_HELPER_ARGS(dbg, "enable = %d", enable); } void CommandSetGl846::set_powersaving(Genesys_Device* dev, int delay /* in minutes */) const { (void) dev; DBG_HELPER_ARGS(dbg, "delay = %d", delay); } // Send the low-level scan command void CommandSetGl846::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, bool start_motor) const { DBG_HELPER(dbg); (void) sensor; uint8_t val; GenesysRegister *r; /* XXX STEF XXX SCAN GPIO */ /* val = dev->interface->read_register(REG_0x6C); dev->interface->write_register(REG_0x6C, val); */ val = REG_0x0D_CLRLNCNT; dev->interface->write_register(REG_0x0D, val); val = REG_0x0D_CLRMCNT; dev->interface->write_register(REG_0x0D, val); val = dev->interface->read_register(REG_0x01); val |= REG_0x01_SCAN; dev->interface->write_register(REG_0x01, val); r = sanei_genesys_get_address (reg, REG_0x01); r->value = val; scanner_start_action(*dev, start_motor); dev->advance_head_pos_by_session(ScanHeadId::PRIMARY); } // Send the stop scan command void CommandSetGl846::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg, bool check_stop) const { (void) reg; DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop); if (!dev->model->is_sheetfed) { scanner_stop_action(*dev); } } // Moves the slider to the home (top) postion slowly void CommandSetGl846::move_back_home(Genesys_Device* dev, bool wait_until_home) const { scanner_move_back_home(*dev, wait_until_home); } // Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi // from very top of scanner void CommandSetGl846::search_start_position(Genesys_Device* dev) const { DBG_HELPER(dbg); int size; Genesys_Register_Set local_reg; int pixels = 600; int dpi = 300; local_reg = dev->reg; /* sets for a 200 lines * 600 pixels */ /* normal scan with no shading */ // FIXME: the current approach of doing search only for one resolution does not work on scanners // whith employ different sensors with potentially different settings. const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method); ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; /*we should give a small offset here~60 steps */ session.params.pixels = 600; session.params.lines = dev->model->search_lines; session.params.depth = 8; session.params.channels = 1; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::GREEN; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &local_reg, session); // send to scanner dev->interface->write_registers(local_reg); size = pixels * dev->model->search_lines; std::vector data(size); begin_scan(dev, sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_start_position"); end_scan(dev, &local_reg, true); dev->reg = local_reg; return; } wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl846_search_position.pnm", data.data(), 8, 1, pixels, dev->model->search_lines); } end_scan(dev, &local_reg, true); /* update regs to copy ASIC internal state */ dev->reg = local_reg; // TODO: find out where sanei_genesys_search_reference_point stores information, // and use that correctly for (auto& sensor_update : sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) { sanei_genesys_search_reference_point(dev, sensor_update, data.data(), 0, dpi, pixels, dev->model->search_lines); } } // sets up register for coarse gain calibration // todo: check it for scanners using it void CommandSetGl846::init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel(); session.params.lines = 20; session.params.depth = 16; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, ®s, session); DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres); dev->interface->write_registers(regs); } // init registers for shading calibration void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); float move; dev->calib_channels = 3; /* initial calibration reg values */ regs = dev->reg; dev->calib_resolution = sensor.get_register_hwdpi(dev->settings.xres); const auto& calib_sensor = sanei_genesys_find_sensor(dev, dev->calib_resolution, dev->calib_channels, dev->settings.scan_method); dev->calib_total_bytes_to_read = 0; dev->calib_lines = dev->model->shading_lines; if (dev->calib_resolution==4800) { dev->calib_lines *= 2; } dev->calib_pixels = (calib_sensor.sensor_pixels * dev->calib_resolution) / calib_sensor.optical_res; DBG(DBG_io, "%s: calib_lines = %zu\n", __func__, dev->calib_lines); DBG(DBG_io, "%s: calib_pixels = %zu\n", __func__, dev->calib_pixels); /* this is aworkaround insufficent distance for slope * motor acceleration TODO special motor slope for shading */ move=1; if(dev->calib_resolution<1200) { move=40; } ScanSession session; session.params.xres = dev->calib_resolution; session.params.yres = dev->calib_resolution; session.params.startx = 0; session.params.starty = static_cast(move); session.params.pixels = dev->calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; session.params.channels = dev->calib_channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::DISABLE_BUFFER_FULL_MOVE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); dev->interface->write_registers(regs); /* we use GENESYS_FLAG_SHADING_REPARK */ dev->set_head_pos_zero(ScanHeadId::PRIMARY); } /** @brief set up registers for the actual scan */ void CommandSetGl846::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); float move; int move_dpi; float start; debug_dump(DBG_info, dev->settings); /* steps to move to reach scanning area: - first we move to physical start of scanning either by a fixed steps amount from the black strip or by a fixed amount from parking position, minus the steps done during shading calibration - then we move by the needed offset whitin physical scanning area assumption: steps are expressed at maximum motor resolution we need: float y_offset; float y_size; float y_offset_calib; mm_to_steps()=motor dpi / 2.54 / 10=motor dpi / MM_PER_INCH */ /* if scanner uses GENESYS_FLAG_SEARCH_START y_offset is relative from origin, else, it is from parking position */ move_dpi = dev->motor.base_ydpi; move = static_cast(dev->model->y_offset); move = static_cast(move + dev->settings.tl_y); move = static_cast((move * move_dpi) / MM_PER_INCH); move -= dev->head_pos(ScanHeadId::PRIMARY); 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 * computing acceleration/deceleration distance for scan * resolution. So leave a remainder for it so scan makes the final * move tuning */ if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700) { scanner_move(*dev, dev->model->default_method, static_cast(move - 500), Direction::FORWARD); move=500; } DBG(DBG_info, "%s: move=%f steps\n", __func__, move); DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = static_cast(dev->model->x_offset); start = static_cast(start + dev->settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = static_cast(start); session.params.starty = static_cast(move); session.params.pixels = dev->settings.pixels; session.params.requested_pixels = dev->settings.requested_pixels; session.params.lines = dev->settings.lines; session.params.depth = dev->settings.depth; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; // backtracking isn't handled well, so don't enable it session.params.flags = ScanFlag::DISABLE_BUFFER_FULL_MOVE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &dev->reg, session); } /** * Send shading calibration data. The buffer is considered to always hold values * for all the channels. */ void CommandSetGl846::send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const { DBG_HELPER_ARGS(dbg, "writing %d bytes of shading data", size); uint32_t addr, length, i, x, factor, pixels; uint32_t dpiset, dpihw; uint8_t val,*ptr,*src; /* shading data is plit in 3 (up to 5 with IR) areas write(0x10014000,0x00000dd8) URB 23429 bulk_out len 3544 wrote 0x33 0x10 0x.... write(0x1003e000,0x00000dd8) write(0x10068000,0x00000dd8) */ length = static_cast(size / 3); unsigned strpixel = dev->session.pixel_startx; unsigned endpixel = dev->session.pixel_endx; /* compute deletion factor */ dpiset = dev->reg.get16(REG_DPISET); dpihw = sensor.get_register_hwdpi(dpiset); factor=dpihw/dpiset; DBG(DBG_io2, "%s: factor=%d\n", __func__, factor); pixels=endpixel-strpixel; /* since we're using SHDAREA, substract startx coordinate from shading */ strpixel -= (sensor.ccd_start_xoffset * 600) / sensor.optical_res; /* turn pixel value into bytes 2x16 bits words */ strpixel*=2*2; pixels*=2*2; dev->interface->record_key_value("shading_offset", std::to_string(strpixel)); dev->interface->record_key_value("shading_pixels", std::to_string(pixels)); dev->interface->record_key_value("shading_length", std::to_string(length)); dev->interface->record_key_value("shading_factor", std::to_string(factor)); std::vector buffer(pixels, 0); 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 */ /* write actual color channel data */ for(i=0;i<3;i++) { /* build up actual shading data by copying the part from the full width one * to the one corresponding to SHDAREA */ ptr = buffer.data(); /* iterate on both sensor segment */ for(x=0;xinterface->read_register(0xd0+i); addr = val * 8192 + 0x10000000; dev->interface->write_ahb(addr, pixels, buffer.data()); } } /** @brief calibrates led exposure * Calibrate exposure by scanning a white area until the used exposure gives * data white enough. * @param dev device to calibrate */ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); int num_pixels; int total_size; int used_res; int i, j; int val; int channels; int avg[3], top[3], bottom[3]; int turn; uint16_t exp[3]; float move = static_cast(dev->model->y_offset_calib_white); move = static_cast((move * (dev->motor.base_ydpi / 4)) / MM_PER_INCH); if(move>20) { scanner_move(*dev, dev->model->default_method, static_cast(move), Direction::FORWARD); } DBG(DBG_io, "%s: move=%f steps\n", __func__, move); /* offset calibration is always done in color mode */ channels = 3; used_res = sensor.get_register_hwdpi(dev->settings.xres); const auto& calib_sensor = sanei_genesys_find_sensor(dev, used_res, channels, dev->settings.scan_method); num_pixels = (calib_sensor.sensor_pixels * used_res) / calib_sensor.optical_res; /* initial calibration reg values */ regs = dev->reg; ScanSession session; session.params.xres = used_res; session.params.yres = used_res; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); total_size = num_pixels * channels * (session.params.depth / 8) * 1; std::vector line(total_size); /* initial loop values and boundaries */ exp[0] = calib_sensor.exposure.red; exp[1] = calib_sensor.exposure.green; exp[2] = calib_sensor.exposure.blue; bottom[0]=29000; bottom[1]=29000; bottom[2]=29000; top[0]=41000; top[1]=51000; top[2]=51000; turn = 0; /* no move during led calibration */ sanei_genesys_set_motor_power(regs, false); bool acceptable = false; do { // set up exposure regs.set16(REG_EXPR, exp[0]); regs.set16(REG_EXPG, exp[1]); regs.set16(REG_EXPB, exp[2]); // write registers and scan data dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting line reading\n", __func__); begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("led_calibration"); scanner_stop_action(*dev); move_back_home(dev, true); return calib_sensor.exposure; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); // stop scanning scanner_stop_action(*dev); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl846_led_%02d.pnm", turn); sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth, channels, num_pixels, 1); } /* compute average */ for (j = 0; j < channels; j++) { avg[j] = 0; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = line[i * 2 + j * 2 * num_pixels + 1] * 256 + line[i * 2 + j * 2 * num_pixels]; else val = line[i * 2 * channels + 2 * j + 1] * 256 + line[i * 2 * channels + 2 * j]; avg[j] += val; } avg[j] /= num_pixels; } DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); /* check if exposure gives average within the boundaries */ acceptable = true; for(i=0;i<3;i++) { if(avg[i]top[i]) { exp[i]=(exp[i]*top[i])/avg[i]; acceptable = false; } } turn++; } while (!acceptable && turn < 100); DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]); // set these values as final ones for scan dev->reg.set16(REG_EXPR, exp[0]); dev->reg.set16(REG_EXPG, exp[1]); dev->reg.set16(REG_EXPB, exp[2]); /* go back home */ if(move>20) { move_back_home(dev, true); } return { exp[0], exp[1], exp[2] }; } /** * set up GPIO/GPOE for idle state */ static void gl846_init_gpio(Genesys_Device* dev) { DBG_HELPER(dbg); int idx=0; /* search GPIO profile */ while (gpios[idx].gpio_id != GpioId::UNKNOWN && dev->model->gpio_id != gpios[idx].gpio_id) { idx++; } if (gpios[idx].gpio_id == GpioId::UNKNOWN) { throw SaneException("failed to find GPIO profile for sensor_id=%d", static_cast(dev->model->sensor_id)); } dev->interface->write_register(REG_0xA7, gpios[idx].ra7); dev->interface->write_register(REG_0xA6, gpios[idx].ra6); dev->interface->write_register(REG_0x6B, gpios[idx].r6b); dev->interface->write_register(REG_0x6C, gpios[idx].r6c); dev->interface->write_register(REG_0x6D, gpios[idx].r6d); dev->interface->write_register(REG_0x6E, gpios[idx].r6e); dev->interface->write_register(REG_0x6F, gpios[idx].r6f); dev->interface->write_register(REG_0xA8, gpios[idx].ra8); dev->interface->write_register(REG_0xA9, gpios[idx].ra9); } /** * set memory layout by filling values in dedicated registers */ static void gl846_init_memory_layout(Genesys_Device* dev) { DBG_HELPER(dbg); int idx = 0, i; uint8_t val; /* point to per model memory layout */ idx = 0; while (layouts[idx].model != nullptr && strcmp(dev->model->name,layouts[idx].model)!=0) { if(strcmp(dev->model->name,layouts[idx].model)!=0) idx++; } if (layouts[idx].model == nullptr) { throw SaneException("failed to find memory layout for model %s", dev->model->name); } /* CLKSET and DRAMSEL */ val = layouts[idx].dramsel; dev->interface->write_register(REG_0x0B, val); dev->reg.find_reg(0x0b).value = val; /* prevent further writings by bulk write register */ dev->reg.remove_reg(0x0b); /* setup base address for shading and scanned data. */ for(i=0;i<10;i++) { dev->interface->write_register(0xe0+i, layouts[idx].rx[i]); } } /* * * initialize ASIC from power on condition */ void CommandSetGl846::asic_boot(Genesys_Device* dev, bool cold) const { DBG_HELPER(dbg); uint8_t val; // reset ASIC if cold boot if (cold) { dev->interface->write_register(0x0e, 0x01); dev->interface->write_register(0x0e, 0x00); } if(dev->usb_mode == 1) { val = 0x14; } else { val = 0x11; } dev->interface->write_0x8c(0x0f, val); // test CHKVER val = dev->interface->read_register(REG_0x40); if (val & REG_0x40_CHKVER) { val = dev->interface->read_register(0x00); DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ gl846_init_registers (dev); // Write initial registers dev->interface->write_registers(dev->reg); /* Enable DRAM by setting a rising edge on bit 3 of reg 0x0b */ val = dev->reg.find_reg(0x0b).value & REG_0x0B_DRAMSEL; val = (val | REG_0x0B_ENBDRAM); dev->interface->write_register(REG_0x0B, val); dev->reg.find_reg(0x0b).value = val; /* CIS_LINE */ if (dev->model->is_cis) { dev->reg.init_reg(0x08, REG_0x08_CIS_LINE); dev->interface->write_register(0x08, dev->reg.find_reg(0x08).value); } // set up clocks dev->interface->write_0x8c(0x10, 0x0e); dev->interface->write_0x8c(0x13, 0x0e); // setup gpio gl846_init_gpio(dev); // setup internal memory layout gl846_init_memory_layout(dev); dev->reg.init_reg(0xf8, 0x05); dev->interface->write_register(0xf8, dev->reg.find_reg(0xf8).value); } /** * initialize backend and ASIC : registers, motor tables, and gamma tables * then ensure scanner's head is at home */ void CommandSetGl846::init(Genesys_Device* dev) const { DBG_INIT (); DBG_HELPER(dbg); sanei_genesys_asic_init(dev, 0); } void CommandSetGl846::update_hardware_sensors(Genesys_Scanner* s) const { DBG_HELPER(dbg); /* do what is needed to get a new set of events, but try to not lose any of them. */ uint8_t val; uint8_t scan, file, email, copy; switch(s->dev->model->gpio_id) { default: scan=0x01; file=0x02; email=0x04; copy=0x08; } val = s->dev->interface->read_register(REG_0x6D); s->buttons[BUTTON_SCAN_SW].write((val & scan) == 0); s->buttons[BUTTON_FILE_SW].write((val & file) == 0); s->buttons[BUTTON_EMAIL_SW].write((val & email) == 0); s->buttons[BUTTON_COPY_SW].write((val & copy) == 0); } void CommandSetGl846::update_home_sensor_gpio(Genesys_Device& dev) const { DBG_HELPER(dbg); std::uint8_t val = dev.interface->read_register(REG_0x6C); val |= 0x41; dev.interface->write_register(REG_0x6C, val); } /** @brief search for a full width black or white strip. * This function searches for a black or white stripe across the scanning area. * When searching backward, the searched area must completely be of the desired * color since this area will be used for calibration which scans forward. * @param dev scanner device * @param forward true if searching forward, false if searching backward * @param black true if searching for a black strip, false for a white strip */ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const { DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse"); unsigned int pixels, lines, channels; Genesys_Register_Set local_reg; size_t size; unsigned int pass, count, found, x, y; char title[80]; set_fe(dev, sensor, AFE_SET); scanner_stop_action(*dev); // set up for a gray scan at lowest dpi const auto& resolution_settings = dev->model->get_resolution_settings(dev->settings.scan_method); unsigned dpi = resolution_settings.get_min_resolution_x(); channels = 1; /* 10 MM */ /* lines = (10 * dpi) / MM_PER_INCH; */ /* shading calibation is done with dev->motor.base_ydpi */ lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi; pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res; dev->set_head_pos_zero(ScanHeadId::PRIMARY); local_reg = dev->reg; ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::RED; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA; if (!forward) { session.params.flags |= ScanFlag::REVERSE; } compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &local_reg, session); size = pixels * channels * lines * (session.params.depth / 8); std::vector data(size); dev->interface->write_registers(local_reg); begin_scan(dev, sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_strip"); scanner_stop_action(*dev); return; } wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); scanner_stop_action(*dev); pass = 0; if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl846_search_strip_%s_%s%02d.pnm", black ? "black" : "white", forward ? "fwd" : "bwd", pass); sanei_genesys_write_pnm_file(title, data.data(), session.params.depth, channels, pixels, lines); } /* loop until strip is found or maximum pass number done */ found = 0; while (pass < 20 && !found) { dev->interface->write_registers(local_reg); // now start scan begin_scan(dev, sensor, &local_reg, true); wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); scanner_stop_action(*dev); if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl846_search_strip_%s_%s%02d.pnm", black ? "black" : "white", forward ? "fwd" : "bwd", pass); sanei_genesys_write_pnm_file(title, data.data(), session.params.depth, channels, pixels, lines); } /* search data to find black strip */ /* when searching forward, we only need one line of the searched color since we * will scan forward. But when doing backward search, we need all the area of the * same color */ if (forward) { for (y = 0; y < lines && !found; y++) { count = 0; /* count of white/black pixels depending on the color searched */ for (x = 0; x < pixels; x++) { /* when searching for black, detect white pixels */ if (black && data[y * pixels + x] > 90) { count++; } /* when searching for white, detect black pixels */ if (!black && data[y * pixels + x] < 60) { count++; } } /* at end of line, if count >= 3%, line is not fully of the desired color * so we must go to next line of the buffer */ /* count*100/pixels < 3 */ if ((count * 100) / pixels < 3) { found = 1; DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, pass, y); } else { DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, (100 * count) / pixels); } } } else /* since calibration scans are done forward, we need the whole area to be of the required color when searching backward */ { count = 0; for (y = 0; y < lines; y++) { /* count of white/black pixels depending on the color searched */ for (x = 0; x < pixels; x++) { /* when searching for black, detect white pixels */ if (black && data[y * pixels + x] > 90) { count++; } /* when searching for white, detect black pixels */ if (!black && data[y * pixels + x] < 60) { count++; } } } /* at end of area, if count >= 3%, area is not fully of the desired color * so we must go to next buffer */ if ((count * 100) / (pixels * lines) < 3) { found = 1; DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, (100 * count) / pixels); } } pass++; } if (found) { DBG(DBG_info, "%s: %s strip found\n", __func__, black ? "black" : "white"); } else { throw SaneException(SANE_STATUS_UNSUPPORTED, "%s strip not found", black ? "black" : "white"); } } /** * average dark pixels of a 8 bits scan */ static int dark_average (uint8_t * data, unsigned int pixels, unsigned int lines, unsigned int channels, unsigned int black) { unsigned int i, j, k, average, count; unsigned int avg[3]; uint8_t val; /* computes average value on black margin */ for (k = 0; k < channels; k++) { avg[k] = 0; count = 0; for (i = 0; i < lines; i++) { for (j = 0; j < black; j++) { val = data[i * channels * pixels + j + k]; avg[k] += val; count++; } } if (count) avg[k] /= count; DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } average = 0; for (i = 0; i < channels; i++) average += avg[i]; average /= channels; DBG(DBG_info, "%s: average = %d\n", __func__, average); return average; } void CommandSetGl846::offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); unsigned channels; int pass = 0, avg, total_size; int topavg, bottomavg, lines; int top, bottom, black_pixels, pixels; // no gain nor offset for AKM AFE uint8_t reg04 = dev->interface->read_register(REG_0x04); if ((reg04 & REG_0x04_FESET) == 0x02) { return; } /* offset calibration is always done in color mode */ channels = 3; dev->calib_pixels = sensor.sensor_pixels; lines=1; pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res; black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res; DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); ScanSession session; session.params.xres = sensor.optical_res; session.params.yres = sensor.optical_res; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, ®s, session); sanei_genesys_set_motor_power(regs, false); total_size = pixels * channels * lines * (session.params.depth / 8); std::vector first_line(total_size); std::vector second_line(total_size); /* init gain */ dev->frontend.set_gain(0, 0); dev->frontend.set_gain(1, 0); dev->frontend.set_gain(2, 0); /* scan with no move */ bottom = 10; dev->frontend.set_offset(0, bottom); dev->frontend.set_offset(1, bottom); dev->frontend.set_offset(2, bottom); set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting first line reading\n", __func__); begin_scan(dev, sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("offset_calibration"); return; } sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl846_offset%03d.pnm", bottom); sanei_genesys_write_pnm_file(fn, first_line.data(), session.params.depth, channels, pixels, lines); } bottomavg = dark_average(first_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_io2, "%s: bottom avg=%d\n", __func__, bottomavg); /* now top value */ top = 255; dev->frontend.set_offset(0, top); dev->frontend.set_offset(1, top); dev->frontend.set_offset(2, top); set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting second line reading\n", __func__); begin_scan(dev, sensor, ®s, true); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); topavg = dark_average(second_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg); /* loop until acceptable level */ while ((pass < 32) && (top - bottom > 1)) { pass++; /* settings for new scan */ dev->frontend.set_offset(0, (top + bottom) / 2); dev->frontend.set_offset(1, (top + bottom) / 2); dev->frontend.set_offset(2, (top + bottom) / 2); // scan with no move set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting second line reading\n", __func__); begin_scan(dev, sensor, ®s, true); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl846_offset%03d.pnm", dev->frontend.get_offset(1)); sanei_genesys_write_pnm_file(fn, second_line.data(), session.params.depth, channels, pixels, lines); } avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.get_offset(1)); /* compute new boundaries */ if (topavg == avg) { topavg = avg; top = dev->frontend.get_offset(1); } else { bottomavg = avg; bottom = dev->frontend.get_offset(1); } } DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); } void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const { DBG_HELPER(dbg); int pixels; int total_size; int i, j, channels; int max[3]; float gain[3],coeff; int val, code, lines; DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi); // no gain nor offset for AKM AFE uint8_t reg04 = dev->interface->read_register(REG_0x04); if ((reg04 & REG_0x04_FESET) == 0x02) { return; } /* coarse gain calibration is always done in color mode */ channels = 3; /* follow CKSEL */ if(dev->settings.xressettings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); try { init_regs_for_scan_session(dev, sensor, ®s, session); } catch (...) { catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); }); throw; } sanei_genesys_set_motor_power(regs, false); dev->interface->write_registers(regs); total_size = pixels * channels * (16 / session.params.depth) * lines; std::vector line(total_size); set_fe(dev, sensor, AFE_SET); begin_scan(dev, sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("coarse_gain_calibration"); scanner_stop_action(*dev); move_back_home(dev, true); return; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl846_gain.pnm", line.data(), session.params.depth, channels, pixels, lines); } /* average value on each channel */ for (j = 0; j < channels; j++) { max[j] = 0; for (i = pixels/4; i < (pixels*3/4); i++) { if (dev->model->is_cis) val = line[i + j * pixels]; else val = line[i * channels + j]; max[j] += val; } max[j] = max[j] / (pixels/2); gain[j] = (static_cast(sensor.gain_white_ref) * coeff) / max[j]; /* turn logical gain value into gain code, checking for overflow */ code = static_cast(283 - 208 / gain[j]); if (code > 255) code = 255; else if (code < 0) code = 0; dev->frontend.set_gain(j, code); DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j], dev->frontend.get_gain(j)); } if (dev->model->is_cis) { uint8_t gain0 = dev->frontend.get_gain(0); if (gain0 > dev->frontend.get_gain(1)) { gain0 = dev->frontend.get_gain(1); } if (gain0 > dev->frontend.get_gain(2)) { gain0 = dev->frontend.get_gain(2); } dev->frontend.set_gain(0, gain0); dev->frontend.set_gain(1, gain0); dev->frontend.set_gain(2, gain0); } scanner_stop_action(*dev); move_back_home(dev, true); } bool CommandSetGl846::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const { (void) dev; return false; } void CommandSetGl846::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const { (void) dev; (void) sensor; (void) regs; (void) channels; (void) total_size; throw SaneException("not implemented"); } void CommandSetGl846::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const { sanei_genesys_send_gamma_table(dev, sensor); } void CommandSetGl846::wait_for_motor_stop(Genesys_Device* dev) const { (void) dev; } void CommandSetGl846::load_document(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl846::detect_document_end(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl846::eject_document(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl846::move_to_ta(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } std::unique_ptr create_gl846_cmd_set() { return std::unique_ptr(new CommandSetGl846{}); } } // namespace gl846 } // namespace genesys sane-backends-1.0.29/backend/genesys/settings.h0000666000000000000000000002564113615534521016266 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_SETTINGS_H #define BACKEND_GENESYS_SETTINGS_H #include "enums.h" #include "serialize.h" namespace genesys { struct Genesys_Settings { ScanMethod scan_method = ScanMethod::FLATBED; ScanColorMode scan_mode = ScanColorMode::LINEART; // horizontal dpi unsigned xres = 0; // vertical dpi unsigned yres = 0; //x start on scan table in mm double tl_x = 0; // y start on scan table in mm double tl_y = 0; // number of lines at scan resolution unsigned int lines = 0; // number of pixels expected from the scanner unsigned int pixels = 0; // number of pixels expected by the frontend unsigned requested_pixels = 0; // bit depth of the scan unsigned int depth = 0; ColorFilter color_filter = ColorFilter::NONE; // true if scan is true gray, false if monochrome scan int true_gray = 0; // lineart threshold int threshold = 0; // lineart threshold curve for dynamic rasterization int threshold_curve = 0; // Disable interpolation for xres::max(); // resolution in x direction unsigned xres = NOT_SET; // resolution in y direction unsigned yres = NOT_SET; // start pixel in X direction, from dummy_pixel + 1 unsigned startx = NOT_SET; // start pixel in Y direction, counted according to base_ydpi unsigned starty = NOT_SET; // the number of pixels in X direction. Note that each logical pixel may correspond to more // than one CCD pixel, see CKSEL and GenesysSensor::ccd_pixels_per_system_pixel() unsigned pixels = NOT_SET; // the number of pixels in the X direction as requested by the frontend. This will be different // from `pixels` if the X resolution requested by the frontend is different than the actual // resolution. This is only needed to compute dev->total_bytes_to_read. If 0, then the value // is the same as pixels. // TODO: move the computation of total_bytes_to_read to a higher layer. unsigned requested_pixels = 0; // the number of pixels in Y direction unsigned lines = NOT_SET; // the depth of the scan in bits. Allowed are 1, 8, 16 unsigned depth = NOT_SET; // the number of channels unsigned channels = NOT_SET; ScanMethod scan_method = static_cast(NOT_SET); ScanColorMode scan_mode = static_cast(NOT_SET); ColorFilter color_filter = static_cast(NOT_SET); ScanFlag flags; unsigned get_requested_pixels() const { if (requested_pixels != 0) { return requested_pixels; } return pixels; } void assert_valid() const { if (xres == NOT_SET || yres == NOT_SET || startx == NOT_SET || starty == NOT_SET || pixels == NOT_SET || lines == NOT_SET ||depth == NOT_SET || channels == NOT_SET || scan_method == static_cast(NOT_SET) || scan_mode == static_cast(NOT_SET) || color_filter == static_cast(NOT_SET)) { throw std::runtime_error("SetupParams are not valid"); } } bool operator==(const SetupParams& other) const { return xres == other.xres && yres == other.yres && startx == other.startx && starty == other.starty && pixels == other.pixels && requested_pixels == other.requested_pixels && lines == other.lines && depth == other.depth && channels == other.channels && scan_method == other.scan_method && scan_mode == other.scan_mode && color_filter == other.color_filter && flags == other.flags; } }; std::ostream& operator<<(std::ostream& out, const SetupParams& params); template void serialize(Stream& str, SetupParams& x) { serialize(str, x.xres); serialize(str, x.yres); serialize(str, x.startx); serialize(str, x.starty); serialize(str, x.pixels); serialize(str, x.requested_pixels); serialize(str, x.lines); serialize(str, x.depth); serialize(str, x.channels); serialize(str, x.scan_method); serialize(str, x.scan_mode); serialize(str, x.color_filter); serialize(str, x.flags); } struct ScanSession { SetupParams params; // whether the session setup has been computed via compute_session() bool computed = false; // specifies the reduction (if any) of hardware dpi on the Genesys chip side. // except gl646 unsigned hwdpi_divisor = 1; // specifies the reduction (if any) of CCD effective dpi which is performed by latching the // data coming from CCD in such a way that 1/2 or 3/4 of pixel data is ignored. unsigned ccd_size_divisor = 1; // the optical resolution of the scanner. unsigned optical_resolution = 0; // the number of pixels at the optical resolution, not including segmentation overhead. unsigned optical_pixels = 0; // the number of pixels at the optical resolution, including segmentation overhead. // only on gl846, g847 unsigned optical_pixels_raw = 0; // the resolution of the output data. // gl843-only unsigned output_resolution = 0; // the number of pixels in output data (after desegmentation) unsigned output_pixels = 0; // the number of bytes in the output of a channel of a single line (after desegmentation) unsigned output_channel_bytes = 0; // the number of bytes in the output of a single line (after desegmentation) unsigned output_line_bytes = 0; // the number of bytes per line in the output data from the scanner (before desegmentation) // Equal to output_line_bytes if sensor does not have segments unsigned output_line_bytes_raw = 0; // the number of bytes per line as requested by the frontend unsigned output_line_bytes_requested = 0; // the number of lines in the output of the scanner. This must be larger than the user // requested number due to line staggering and color channel shifting. unsigned output_line_count = 0; // the total number of bytes to read from the scanner (before desegmentation) unsigned output_total_bytes_raw = 0; // the total number of bytes to read from the scanner (after desegmentation) unsigned output_total_bytes = 0; // the number of staggered lines (i.e. lines that overlap during scanning due to line being // thinner than the CCD element) unsigned num_staggered_lines = 0; // the number of lines that color channels shift due to different physical positions of // different color channels. unsigned max_color_shift_lines = 0; // actual line shift of the red color unsigned color_shift_lines_r = 0; // actual line shift of the green color unsigned color_shift_lines_g = 0; // actual line shift of the blue color unsigned color_shift_lines_b = 0; // the number of scanner segments used in the current scan unsigned segment_count = 1; // the physical pixel positions that are sent to the registers unsigned pixel_startx = 0; unsigned pixel_endx = 0; // certain scanners require the logical pixel count to be multiplied on certain resolutions unsigned pixel_count_multiplier = 1; // Distance in pixels between consecutive pixels, e.g. between odd and even pixels. Note that // the number of segments can be large. // only on gl124, gl846, gl847 unsigned conseq_pixel_dist = 0; // The number of "even" pixels to scan. This corresponds to the number of pixels that will be // scanned from a single segment // only on gl124, gl846, gl847 unsigned output_segment_pixel_group_count = 0; // The number of bytes to skip at start of line during desegmentation. // Currently it's always zero. unsigned output_segment_start_offset = 0; // the sizes of the corresponding buffers size_t buffer_size_read = 0; size_t buffer_size_lines = 0; size_t buffer_size_shrink = 0; size_t buffer_size_out = 0; // whether to enable ledadd functionality bool enable_ledadd = false; // what pipeline modifications are needed bool pipeline_needs_reorder = false; bool pipeline_needs_ccd = false; bool pipeline_needs_shrink = false; void assert_computed() const { if (!computed) { throw std::runtime_error("ScanSession is not computed"); } } }; std::ostream& operator<<(std::ostream& out, const ScanSession& session); std::ostream& operator<<(std::ostream& out, const SANE_Parameters& params); } // namespace genesys #endif // BACKEND_GENESYS_SETTINGS_H sane-backends-1.0.29/backend/genesys/settings.cpp0000666000000000000000000001441713615534521016620 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "settings.h" #include "utilities.h" #include namespace genesys { std::ostream& operator<<(std::ostream& out, const Genesys_Settings& settings) { StreamStateSaver state_saver{out}; out << "Genesys_Settings{\n" << " xres: " << settings.xres << " yres: " << settings.yres << '\n' << " lines: " << settings.lines << '\n' << " pixels per line (actual): " << settings.pixels << '\n' << " pixels per line (requested): " << settings.requested_pixels << '\n' << " depth: " << settings.depth << '\n'; auto prec = out.precision(); out.precision(3); out << " tl_x: " << settings.tl_x << " tl_y: " << settings.tl_y << '\n'; out.precision(prec); out << " scan_mode: " << settings.scan_mode << '\n' << '}'; return out; } std::ostream& operator<<(std::ostream& out, const SetupParams& params) { StreamStateSaver state_saver{out}; out << "SetupParams{\n" << " xres: " << params.xres << " yres: " << params.yres << '\n' << " lines: " << params.lines << '\n' << " pixels per line (actual): " << params.pixels << '\n' << " pixels per line (requested): " << params.requested_pixels << '\n' << " depth: " << params.depth << '\n' << " channels: " << params.channels << '\n' << " startx: " << params.startx << " starty: " << params.starty << '\n' << " scan_mode: " << params.scan_mode << '\n' << " color_filter: " << params.color_filter << '\n' << " flags: " << params.flags << '\n' << "}"; return out; } std::ostream& operator<<(std::ostream& out, const ScanSession& session) { out << "ScanSession{\n" << " computed: " << session.computed << '\n' << " hwdpi_divisor: " << session.hwdpi_divisor << '\n' << " ccd_size_divisor: " << session.ccd_size_divisor << '\n' << " optical_resolution: " << session.optical_resolution << '\n' << " optical_pixels: " << session.optical_pixels << '\n' << " optical_pixels_raw: " << session.optical_pixels_raw << '\n' << " output_resolution: " << session.output_resolution << '\n' << " output_pixels: " << session.output_pixels << '\n' << " output_line_bytes: " << session.output_line_bytes << '\n' << " output_line_bytes_raw: " << session.output_line_bytes_raw << '\n' << " output_line_count: " << session.output_line_count << '\n' << " num_staggered_lines: " << session.num_staggered_lines << '\n' << " color_shift_lines_r: " << session.color_shift_lines_r << '\n' << " color_shift_lines_g: " << session.color_shift_lines_g << '\n' << " color_shift_lines_b: " << session.color_shift_lines_b << '\n' << " max_color_shift_lines: " << session.max_color_shift_lines << '\n' << " enable_ledadd: " << session.enable_ledadd << '\n' << " segment_count: " << session.segment_count << '\n' << " pixel_startx: " << session.pixel_startx << '\n' << " pixel_endx: " << session.pixel_endx << '\n' << " conseq_pixel_dist: " << session.conseq_pixel_dist << '\n' << " output_segment_pixel_group_count: " << session.output_segment_pixel_group_count << '\n' << " buffer_size_read: " << session.buffer_size_read << '\n' << " buffer_size_read: " << session.buffer_size_lines << '\n' << " buffer_size_shrink: " << session.buffer_size_shrink << '\n' << " buffer_size_out: " << session.buffer_size_out << '\n' << " filters: " << (session.pipeline_needs_reorder ? " reorder": "") << (session.pipeline_needs_ccd ? " ccd": "") << (session.pipeline_needs_shrink ? " shrink": "") << '\n' << " params: " << format_indent_braced_list(4, session.params) << '\n' << "}"; return out; } std::ostream& operator<<(std::ostream& out, const SANE_Parameters& params) { out << "SANE_Parameters{\n" << " format: " << static_cast(params.format) << '\n' << " last_frame: " << params.last_frame << '\n' << " bytes_per_line: " << params.bytes_per_line << '\n' << " pixels_per_line: " << params.pixels_per_line << '\n' << " lines: " << params.lines << '\n' << " depth: " << params.depth << '\n' << '}'; return out; } } // namespace genesys sane-backends-1.0.29/backend/genesys/test_usb_device.cpp0000666000000000000000000000710013615534521020116 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "test_usb_device.h" #include "low.h" namespace genesys { TestUsbDevice::TestUsbDevice(std::uint16_t vendor, std::uint16_t product) : vendor_{vendor}, product_{product} { } TestUsbDevice::~TestUsbDevice() { if (is_open()) { DBG(DBG_error, "TestUsbDevice not closed; closing automatically"); close(); } } void TestUsbDevice::open(const char* dev_name) { DBG_HELPER(dbg); if (is_open()) { throw SaneException("device already open"); } name_ = dev_name; is_open_ = true; } void TestUsbDevice::clear_halt() { DBG_HELPER(dbg); assert_is_open(); } void TestUsbDevice::reset() { DBG_HELPER(dbg); assert_is_open(); } void TestUsbDevice::close() { DBG_HELPER(dbg); assert_is_open(); is_open_ = false; name_ = ""; } void TestUsbDevice::get_vendor_product(int& vendor, int& product) { DBG_HELPER(dbg); assert_is_open(); vendor = vendor_; product = product_; } void TestUsbDevice::control_msg(int rtype, int reg, int value, int index, int length, std::uint8_t* data) { (void) reg; (void) value; (void) index; DBG_HELPER(dbg); assert_is_open(); if (rtype == REQUEST_TYPE_IN) { std::memset(data, 0, length); } } void TestUsbDevice::bulk_read(std::uint8_t* buffer, std::size_t* size) { DBG_HELPER(dbg); assert_is_open(); std::memset(buffer, 0, *size); } void TestUsbDevice::bulk_write(const std::uint8_t* buffer, std::size_t* size) { (void) buffer; (void) size; DBG_HELPER(dbg); assert_is_open(); } void TestUsbDevice::assert_is_open() const { if (!is_open()) { throw SaneException("device not open"); } } } // namespace genesys sane-backends-1.0.29/backend/genesys/gl843_registers.h0000666000000000000000000003563613615534521017363 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL843_REGISTERS_H #define BACKEND_GENESYS_GL843_REGISTERS_H #include namespace genesys { namespace gl843 { using RegAddr = std::uint16_t; using RegMask = std::uint8_t; using RegShift = unsigned; static constexpr RegAddr REG_0x01 = 0x01; static constexpr RegMask REG_0x01_CISSET = 0x80; static constexpr RegMask REG_0x01_DOGENB = 0x40; static constexpr RegMask REG_0x01_DVDSET = 0x20; static constexpr RegMask REG_0x01_STAGGER = 0x10; static constexpr RegMask REG_0x01_COMPENB = 0x08; static constexpr RegMask REG_0x01_TRUEGRAY = 0x04; static constexpr RegMask REG_0x01_SHDAREA = 0x02; static constexpr RegMask REG_0x01_SCAN = 0x01; static constexpr RegAddr REG_0x02 = 0x02; static constexpr RegMask REG_0x02_NOTHOME = 0x80; static constexpr RegMask REG_0x02_ACDCDIS = 0x40; static constexpr RegMask REG_0x02_AGOHOME = 0x20; static constexpr RegMask REG_0x02_MTRPWR = 0x10; static constexpr RegMask REG_0x02_FASTFED = 0x08; static constexpr RegMask REG_0x02_MTRREV = 0x04; static constexpr RegMask REG_0x02_HOMENEG = 0x02; static constexpr RegMask REG_0x02_LONGCURV = 0x01; static constexpr RegAddr REG_0x03 = 0x03; static constexpr RegMask REG_0x03_LAMPDOG = 0x80; static constexpr RegMask REG_0x03_AVEENB = 0x40; static constexpr RegMask REG_0x03_XPASEL = 0x20; static constexpr RegMask REG_0x03_LAMPPWR = 0x10; static constexpr RegMask REG_0x03_LAMPTIM = 0x0f; static constexpr RegAddr REG_0x04 = 0x04; static constexpr RegMask REG_0x04_LINEART = 0x80; static constexpr RegMask REG_0x04_BITSET = 0x40; static constexpr RegMask REG_0x04_AFEMOD = 0x30; static constexpr RegMask REG_0x04_FILTER = 0x0c; static constexpr RegMask REG_0x04_FESET = 0x03; static constexpr RegShift REG_0x04S_AFEMOD = 4; static constexpr RegAddr REG_0x05 = 0x05; static constexpr RegMask REG_0x05_DPIHW = 0xc0; static constexpr RegMask REG_0x05_DPIHW_600 = 0x00; static constexpr RegMask REG_0x05_DPIHW_1200 = 0x40; static constexpr RegMask REG_0x05_DPIHW_2400 = 0x80; static constexpr RegMask REG_0x05_DPIHW_4800 = 0xc0; static constexpr RegMask REG_0x05_MTLLAMP = 0x30; static constexpr RegMask REG_0x05_GMMENB = 0x08; static constexpr RegMask REG_0x05_MTLBASE = 0x03; static constexpr RegAddr REG_0x06 = 0x06; static constexpr RegMask REG_0x06_SCANMOD = 0xe0; static constexpr RegShift REG_0x06S_SCANMOD = 5; static constexpr RegMask REG_0x06_PWRBIT = 0x10; static constexpr RegMask REG_0x06_GAIN4 = 0x08; static constexpr RegMask REG_0x06_OPTEST = 0x07; static constexpr RegMask REG_0x07_LAMPSIM = 0x80; static constexpr RegMask REG_0x08_DECFLAG = 0x40; static constexpr RegMask REG_0x08_GMMFFR = 0x20; static constexpr RegMask REG_0x08_GMMFFG = 0x10; static constexpr RegMask REG_0x08_GMMFFB = 0x08; static constexpr RegMask REG_0x08_GMMZR = 0x04; static constexpr RegMask REG_0x08_GMMZG = 0x02; static constexpr RegMask REG_0x08_GMMZB = 0x01; static constexpr RegMask REG_0x09_MCNTSET = 0xc0; static constexpr RegMask REG_0x09_EVEN1ST = 0x20; static constexpr RegMask REG_0x09_BLINE1ST = 0x10; static constexpr RegMask REG_0x09_BACKSCAN = 0x08; static constexpr RegMask REG_0x09_ENHANCE = 0x04; static constexpr RegMask REG_0x09_SHORTTG = 0x02; static constexpr RegMask REG_0x09_NWAIT = 0x01; static constexpr RegShift REG_0x09S_MCNTSET = 6; static constexpr RegShift REG_0x09S_CLKSET = 4; static constexpr RegAddr REG_0x0B = 0x0b; static constexpr RegMask REG_0x0B_DRAMSEL = 0x07; static constexpr RegMask REG_0x0B_ENBDRAM = 0x08; static constexpr RegMask REG_0x0B_RFHDIS = 0x10; static constexpr RegMask REG_0x0B_CLKSET = 0xe0; static constexpr RegMask REG_0x0B_24MHZ = 0x00; static constexpr RegMask REG_0x0B_30MHZ = 0x20; static constexpr RegMask REG_0x0B_40MHZ = 0x40; static constexpr RegMask REG_0x0B_48MHZ = 0x60; static constexpr RegMask REG_0x0B_60MHZ = 0x80; static constexpr RegAddr REG_0x0D = 0x0d; static constexpr RegMask REG_0x0D_JAMPCMD = 0x80; static constexpr RegMask REG_0x0D_DOCCMD = 0x40; static constexpr RegMask REG_0x0D_CCDCMD = 0x20; static constexpr RegMask REG_0x0D_FULLSTP = 0x10; static constexpr RegMask REG_0x0D_SEND = 0x08; static constexpr RegMask REG_0x0D_CLRMCNT = 0x04; static constexpr RegMask REG_0x0D_CLRDOCJM = 0x02; static constexpr RegMask REG_0x0D_CLRLNCNT = 0x01; static constexpr RegAddr REG_0x0F = 0x0f; static constexpr RegAddr REG_EXPR = 0x10; static constexpr RegAddr REG_EXPG = 0x12; static constexpr RegAddr REG_EXPB = 0x14; static constexpr RegMask REG_0x16_CTRLHI = 0x80; static constexpr RegMask REG_0x16_TOSHIBA = 0x40; static constexpr RegMask REG_0x16_TGINV = 0x20; static constexpr RegMask REG_0x16_CK1INV = 0x10; static constexpr RegMask REG_0x16_CK2INV = 0x08; static constexpr RegMask REG_0x16_CTRLINV = 0x04; static constexpr RegMask REG_0x16_CKDIS = 0x02; static constexpr RegMask REG_0x16_CTRLDIS = 0x01; static constexpr RegMask REG_0x17_TGMODE = 0xc0; static constexpr RegMask REG_0x17_TGMODE_NO_DUMMY = 0x00; static constexpr RegMask REG_0x17_TGMODE_REF = 0x40; static constexpr RegMask REG_0x17_TGMODE_XPA = 0x80; static constexpr RegMask REG_0x17_TGW = 0x3f; static constexpr RegShift REG_0x17S_TGW = 0; static constexpr RegAddr REG_0x18 = 0x18; static constexpr RegMask REG_0x18_CNSET = 0x80; static constexpr RegMask REG_0x18_DCKSEL = 0x60; static constexpr RegMask REG_0x18_CKTOGGLE = 0x10; static constexpr RegMask REG_0x18_CKDELAY = 0x0c; static constexpr RegMask REG_0x18_CKSEL = 0x03; static constexpr RegAddr REG_EXPDMY = 0x19; static constexpr RegMask REG_0x1A_TGLSW2 = 0x80; static constexpr RegMask REG_0x1A_TGLSW1 = 0x40; static constexpr RegMask REG_0x1A_MANUAL3 = 0x02; static constexpr RegMask REG_0x1A_MANUAL1 = 0x01; static constexpr RegMask REG_0x1A_CK4INV = 0x08; static constexpr RegMask REG_0x1A_CK3INV = 0x04; static constexpr RegMask REG_0x1A_LINECLP = 0x02; static constexpr RegAddr REG_0x1C = 0x1c; static constexpr RegMask REG_0x1C_TGTIME = 0x07; static constexpr RegMask REG_0x1D_CK4LOW = 0x80; static constexpr RegMask REG_0x1D_CK3LOW = 0x40; static constexpr RegMask REG_0x1D_CK1LOW = 0x20; static constexpr RegMask REG_0x1D_TGSHLD = 0x1f; static constexpr RegShift REG_0x1DS_TGSHLD = 0; static constexpr RegAddr REG_0x1E = 0x1e; static constexpr RegMask REG_0x1E_WDTIME = 0xf0; static constexpr RegShift REG_0x1ES_WDTIME = 4; static constexpr RegMask REG_0x1E_LINESEL = 0x0f; static constexpr RegShift REG_0x1ES_LINESEL = 0; static constexpr RegAddr REG_0x21 = 0x21; static constexpr RegAddr REG_STEPNO = 0x21; static constexpr RegAddr REG_FWDSTEP = 0x22; static constexpr RegAddr REG_BWDSTEP = 0x23; static constexpr RegAddr REG_FASTNO = 0x24; static constexpr RegAddr REG_LINCNT = 0x25; static constexpr RegAddr REG_0x29 = 0x29; static constexpr RegAddr REG_0x2A = 0x2a; static constexpr RegAddr REG_0x2B = 0x2b; static constexpr RegAddr REG_DPISET = 0x2c; static constexpr RegAddr REG_0x2E = 0x2e; static constexpr RegAddr REG_0x2F = 0x2f; static constexpr RegAddr REG_STRPIXEL = 0x30; static constexpr RegAddr REG_ENDPIXEL = 0x32; static constexpr RegAddr REG_DUMMY = 0x34; static constexpr RegAddr REG_MAXWD = 0x35; static constexpr RegAddr REG_LPERIOD = 0x38; static constexpr RegAddr REG_FEEDL = 0x3d; static constexpr RegAddr REG_0x40 = 0x40; static constexpr RegMask REG_0x40_DOCSNR = 0x80; static constexpr RegMask REG_0x40_ADFSNR = 0x40; static constexpr RegMask REG_0x40_COVERSNR = 0x20; static constexpr RegMask REG_0x40_CHKVER = 0x10; static constexpr RegMask REG_0x40_DOCJAM = 0x08; static constexpr RegMask REG_0x40_HISPDFLG = 0x04; static constexpr RegMask REG_0x40_MOTMFLG = 0x02; static constexpr RegMask REG_0x40_DATAENB = 0x01; static constexpr RegMask REG_0x41_PWRBIT = 0x80; static constexpr RegMask REG_0x41_BUFEMPTY = 0x40; static constexpr RegMask REG_0x41_FEEDFSH = 0x20; static constexpr RegMask REG_0x41_SCANFSH = 0x10; static constexpr RegMask REG_0x41_HOMESNR = 0x08; static constexpr RegMask REG_0x41_LAMPSTS = 0x04; static constexpr RegMask REG_0x41_FEBUSY = 0x02; static constexpr RegMask REG_0x41_MOTORENB = 0x01; static constexpr RegMask REG_0x58_VSMP = 0xf8; static constexpr RegShift REG_0x58S_VSMP = 3; static constexpr RegMask REG_0x58_VSMPW = 0x07; static constexpr RegShift REG_0x58S_VSMPW = 0; static constexpr RegMask REG_0x59_BSMP = 0xf8; static constexpr RegShift REG_0x59S_BSMP = 3; static constexpr RegMask REG_0x59_BSMPW = 0x07; static constexpr RegShift REG_0x59S_BSMPW = 0; static constexpr RegMask REG_0x5A_ADCLKINV = 0x80; static constexpr RegMask REG_0x5A_RLCSEL = 0x40; static constexpr RegMask REG_0x5A_CDSREF = 0x30; static constexpr RegShift REG_0x5AS_CDSREF = 4; static constexpr RegMask REG_0x5A_RLC = 0x0f; static constexpr RegShift REG_0x5AS_RLC = 0; static constexpr RegAddr REG_0x5E = 0x5e; static constexpr RegMask REG_0x5E_DECSEL = 0xe0; static constexpr RegShift REG_0x5ES_DECSEL = 5; static constexpr RegMask REG_0x5E_STOPTIM = 0x1f; static constexpr RegShift REG_0x5ES_STOPTIM = 0; static constexpr RegAddr REG_FMOVDEC = 0x5f; static constexpr RegAddr REG_0x60 = 0x60; static constexpr RegMask REG_0x60_Z1MOD = 0x1f; static constexpr RegAddr REG_0x61 = 0x61; static constexpr RegMask REG_0x61_Z1MOD = 0xff; static constexpr RegAddr REG_0x62 = 0x62; static constexpr RegMask REG_0x62_Z1MOD = 0xff; static constexpr RegAddr REG_0x63 = 0x63; static constexpr RegMask REG_0x63_Z2MOD = 0x1f; static constexpr RegAddr REG_0x64 = 0x64; static constexpr RegMask REG_0x64_Z2MOD = 0xff; static constexpr RegAddr REG_0x65 = 0x65; static constexpr RegMask REG_0x65_Z2MOD = 0xff; static constexpr RegAddr REG_0x67 = 0x67; static constexpr RegAddr REG_0x68 = 0x68; static constexpr RegShift REG_0x67S_STEPSEL = 6; static constexpr RegMask REG_0x67_STEPSEL = 0xc0; static constexpr RegMask REG_0x67_FULLSTEP = 0x00; static constexpr RegMask REG_0x67_HALFSTEP = 0x20; static constexpr RegMask REG_0x67_EIGHTHSTEP = 0x60; static constexpr RegMask REG_0x67_16THSTEP = 0x80; static constexpr RegShift REG_0x68S_FSTPSEL = 6; static constexpr RegMask REG_0x68_FSTPSEL = 0xc0; static constexpr RegMask REG_0x68_FULLSTEP = 0x00; static constexpr RegMask REG_0x68_HALFSTEP = 0x20; static constexpr RegMask REG_0x68_EIGHTHSTEP = 0x60; static constexpr RegMask REG_0x68_16THSTEP = 0x80; static constexpr RegAddr REG_FSHDEC = 0x69; static constexpr RegAddr REG_FMOVNO = 0x6a; static constexpr RegAddr REG_0x6B = 0x6b; static constexpr RegMask REG_0x6B_MULTFILM = 0x80; static constexpr RegMask REG_0x6B_GPOM13 = 0x40; static constexpr RegMask REG_0x6B_GPOM12 = 0x20; static constexpr RegMask REG_0x6B_GPOM11 = 0x10; static constexpr RegMask REG_0x6B_GPOCK4 = 0x08; static constexpr RegMask REG_0x6B_GPOCP = 0x04; static constexpr RegMask REG_0x6B_GPOLEDB = 0x02; static constexpr RegMask REG_0x6B_GPOADF = 0x01; static constexpr RegAddr REG_0x6C = 0x6c; static constexpr RegMask REG_0x6C_GPIO16 = 0x80; static constexpr RegMask REG_0x6C_GPIO15 = 0x40; static constexpr RegMask REG_0x6C_GPIO14 = 0x20; static constexpr RegMask REG_0x6C_GPIO13 = 0x10; static constexpr RegMask REG_0x6C_GPIO12 = 0x08; static constexpr RegMask REG_0x6C_GPIO11 = 0x04; static constexpr RegMask REG_0x6C_GPIO10 = 0x02; static constexpr RegMask REG_0x6C_GPIO9 = 0x01; static constexpr RegMask REG_0x6C_GPIOH = 0xff; static constexpr RegMask REG_0x6C_GPIOL = 0xff; static constexpr RegAddr REG_Z1MOD = 0x60; static constexpr RegAddr REG_Z2MOD = 0x63; static constexpr RegAddr REG_0x6D = 0x6d; static constexpr RegAddr REG_0x6E = 0x6e; static constexpr RegAddr REG_0x6F = 0x6f; static constexpr RegAddr REG_CK1MAP = 0x74; static constexpr RegAddr REG_CK3MAP = 0x77; static constexpr RegAddr REG_CK4MAP = 0x7a; static constexpr RegAddr REG_0x7E = 0x7e; static constexpr RegAddr REG_0x9D = 0x9d; static constexpr RegShift REG_0x9DS_STEPTIM = 2; static constexpr RegMask REG_0x87_LEDADD = 0x04; static constexpr RegAddr REG_0xA6 = 0xa6; static constexpr RegMask REG_0xA6_GPIO24 = 0x80; static constexpr RegMask REG_0xA6_GPIO23 = 0x40; static constexpr RegMask REG_0xA6_GPIO22 = 0x20; static constexpr RegMask REG_0xA6_GPIO21 = 0x10; static constexpr RegMask REG_0xA6_GPIO20 = 0x08; static constexpr RegMask REG_0xA6_GPIO19 = 0x04; static constexpr RegMask REG_0xA6_GPIO18 = 0x02; static constexpr RegMask REG_0xA6_GPIO17 = 0x01; static constexpr RegAddr REG_0xA7 = 0xa7; static constexpr RegMask REG_0xA7_GPOE24 = 0x80; static constexpr RegMask REG_0xA7_GPOE23 = 0x40; static constexpr RegMask REG_0xA7_GPOE22 = 0x20; static constexpr RegMask REG_0xA7_GPOE21 = 0x10; static constexpr RegMask REG_0xA7_GPOE20 = 0x08; static constexpr RegMask REG_0xA7_GPOE19 = 0x04; static constexpr RegMask REG_0xA7_GPOE18 = 0x02; static constexpr RegMask REG_0xA7_GPOE17 = 0x01; static constexpr RegAddr REG_0xA8 = 0xa8; static constexpr RegMask REG_0xA8_GPOE27 = 0x20; static constexpr RegMask REG_0xA8_GPOE26 = 0x10; static constexpr RegMask REG_0xA8_GPOE25 = 0x08; static constexpr RegMask REG_0xA8_GPO27 = 0x04; static constexpr RegMask REG_0xA8_GPO26 = 0x02; static constexpr RegMask REG_0xA8_GPO25 = 0x01; static constexpr RegAddr REG_0xA9 = 0xa9; static constexpr RegMask REG_0xA9_GPO33 = 0x20; static constexpr RegMask REG_0xA9_GPO32 = 0x10; static constexpr RegMask REG_0xA9_GPO31 = 0x08; static constexpr RegMask REG_0xA9_GPO30 = 0x04; static constexpr RegMask REG_0xA9_GPO29 = 0x02; static constexpr RegMask REG_0xA9_GPO28 = 0x01; } // namespace gl843 } // namespace genesys #endif // BACKEND_GENESYS_GL843_REGISTERS_H sane-backends-1.0.29/backend/genesys/error.h0000666000000000000000000001507413615534521015556 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_ERROR_H #define BACKEND_GENESYS_ERROR_H #include "../include/sane/config.h" #include "../include/sane/sane.h" #include "../include/sane/sanei_backend.h" #include #include #include #include #include #define DBG_error0 0 /* errors/warnings printed even with devuglevel 0 */ #define DBG_error 1 /* fatal errors */ #define DBG_init 2 /* initialization and scanning time messages */ #define DBG_warn 3 /* warnings and non-fatal errors */ #define DBG_info 4 /* informational messages */ #define DBG_proc 5 /* starting/finishing functions */ #define DBG_io 6 /* io functions */ #define DBG_io2 7 /* io functions that are called very often */ #define DBG_data 8 /* log image data */ namespace genesys { class SaneException : public std::exception { public: SaneException(SANE_Status status); SaneException(SANE_Status status, const char* format, ...) #ifdef __GNUC__ __attribute__((format(printf, 3, 4))) #endif ; SaneException(const char* format, ...) #ifdef __GNUC__ __attribute__((format(printf, 2, 3))) #endif ; SANE_Status status() const; const char* what() const noexcept override; private: void set_msg(); void set_msg(const char* format, std::va_list vlist); std::string msg_; SANE_Status status_; }; // call a function and throw an exception on error #define TIE(function) \ do { \ SANE_Status tmp_status = function; \ if (tmp_status != SANE_STATUS_GOOD) { \ throw ::genesys::SaneException(tmp_status); \ } \ } while (false) class DebugMessageHelper { public: static constexpr unsigned MAX_BUF_SIZE = 120; DebugMessageHelper(const char* func); DebugMessageHelper(const char* func, const char* format, ...) #ifdef __GNUC__ __attribute__((format(printf, 3, 4))) #endif ; ~DebugMessageHelper(); void status(const char* msg) { vstatus("%s", msg); } void vstatus(const char* format, ...) #ifdef __GNUC__ __attribute__((format(printf, 2, 3))) #endif ; void clear() { msg_[0] = '\n'; } void log(unsigned level, const char* msg); void vlog(unsigned level, const char* format, ...) #ifdef __GNUC__ __attribute__((format(printf, 3, 4))) #endif ; private: const char* func_ = nullptr; char msg_[MAX_BUF_SIZE]; unsigned num_exceptions_on_enter_ = 0; }; #if defined(__GNUC__) || defined(__clang__) #define GENESYS_CURRENT_FUNCTION __PRETTY_FUNCTION__ #elif defined(__FUNCSIG__) #define GENESYS_CURRENT_FUNCTION __FUNCSIG__ #else #define GENESYS_CURRENT_FUNCTION __func__ #endif #define DBG_HELPER(var) DebugMessageHelper var(GENESYS_CURRENT_FUNCTION) #define DBG_HELPER_ARGS(var, ...) DebugMessageHelper var(GENESYS_CURRENT_FUNCTION, __VA_ARGS__) template SANE_Status wrap_exceptions_to_status_code(const char* func, F&& function) { try { function(); return SANE_STATUS_GOOD; } catch (const SaneException& exc) { DBG(DBG_error, "%s: got error: %s\n", func, exc.what()); return exc.status(); } catch (const std::bad_alloc& exc) { (void) exc; DBG(DBG_error, "%s: failed to allocate memory\n", func); return SANE_STATUS_NO_MEM; } catch (const std::exception& exc) { DBG(DBG_error, "%s: got uncaught exception: %s\n", func, exc.what()); return SANE_STATUS_INVAL; } catch (...) { DBG(DBG_error, "%s: got unknown uncaught exception\n", func); return SANE_STATUS_INVAL; } } template void catch_all_exceptions(const char* func, F&& function) { try { function(); } catch (const SaneException& exc) { DBG(DBG_error, "%s: got exception: %s\n", func, exc.what()); } catch (const std::bad_alloc& exc) { DBG(DBG_error, "%s: got exception: could not allocate memory: %s\n", func, exc.what()); } catch (const std::exception& exc) { DBG(DBG_error, "%s: got uncaught exception: %s\n", func, exc.what()); } catch (...) { DBG(DBG_error, "%s: got unknown uncaught exception\n", func); } } inline void wrap_status_code_to_exception(SANE_Status status) { if (status == SANE_STATUS_GOOD) return; throw SaneException(status); } } // namespace genesys #endif // BACKEND_GENESYS_ERROR_H sane-backends-1.0.29/backend/genesys/low.cpp0000666000000000000000000021304613615534521015560 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2010-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "low.h" #include "assert.h" #include "test_settings.h" #include "gl124_registers.h" #include "gl646_registers.h" #include "gl841_registers.h" #include "gl843_registers.h" #include "gl846_registers.h" #include "gl847_registers.h" #include "gl646_registers.h" #include #include #include /* ------------------------------------------------------------------------ */ /* functions calling ASIC specific functions */ /* ------------------------------------------------------------------------ */ namespace genesys { /** * setup the hardware dependent functions */ namespace gl124 { std::unique_ptr create_gl124_cmd_set(); } namespace gl646 { std::unique_ptr create_gl646_cmd_set(); } namespace gl841 { std::unique_ptr create_gl841_cmd_set(); } namespace gl843 { std::unique_ptr create_gl843_cmd_set(); } namespace gl846 { std::unique_ptr create_gl846_cmd_set(); } namespace gl847 { std::unique_ptr create_gl847_cmd_set(); } void sanei_genesys_init_cmd_set(Genesys_Device* dev) { DBG_INIT (); DBG_HELPER(dbg); switch (dev->model->asic_type) { case AsicType::GL646: dev->cmd_set = gl646::create_gl646_cmd_set(); break; case AsicType::GL841: dev->cmd_set = gl841::create_gl841_cmd_set(); break; case AsicType::GL843: dev->cmd_set = gl843::create_gl843_cmd_set(); break; case AsicType::GL845: // since only a few reg bits differs we handle both together case AsicType::GL846: dev->cmd_set = gl846::create_gl846_cmd_set(); break; case AsicType::GL847: dev->cmd_set = gl847::create_gl847_cmd_set(); break; case AsicType::GL124: dev->cmd_set = gl124::create_gl124_cmd_set(); break; default: throw SaneException(SANE_STATUS_INVAL, "unknown ASIC type"); } } /* ------------------------------------------------------------------------ */ /* General IO and debugging functions */ /* ------------------------------------------------------------------------ */ void sanei_genesys_write_file(const char* filename, const std::uint8_t* data, std::size_t length) { DBG_HELPER(dbg); std::FILE* out = std::fopen(filename, "w"); if (!out) { throw SaneException("could not open %s for writing: %s", filename, strerror(errno)); } std::fwrite(data, 1, length, out); std::fclose(out); } // Write data to a pnm file (e.g. calibration). For debugging only // data is RGB or grey, with little endian byte order void sanei_genesys_write_pnm_file(const char* filename, const std::uint8_t* data, int depth, int channels, int pixels_per_line, int lines) { DBG_HELPER_ARGS(dbg, "depth=%d, channels=%d, ppl=%d, lines=%d", depth, channels, pixels_per_line, lines); int count; std::FILE* out = std::fopen(filename, "w"); if (!out) { throw SaneException("could not open %s for writing: %s\n", filename, strerror(errno)); } if(depth==1) { fprintf (out, "P4\n%d\n%d\n", pixels_per_line, lines); } else { std::fprintf(out, "P%c\n%d\n%d\n%d\n", channels == 1 ? '5' : '6', pixels_per_line, lines, static_cast(std::pow(static_cast(2), static_cast(depth - 1)))); } if (channels == 3) { for (count = 0; count < (pixels_per_line * lines * 3); count++) { if (depth == 16) fputc (*(data + 1), out); fputc (*(data++), out); if (depth == 16) data++; } } else { if (depth==1) { pixels_per_line/=8; } for (count = 0; count < (pixels_per_line * lines); count++) { switch (depth) { case 8: fputc (*(data + count), out); break; case 16: fputc (*(data + 1), out); fputc (*(data), out); data += 2; break; default: fputc(data[count], out); break; } } } std::fclose(out); } void sanei_genesys_write_pnm_file16(const char* filename, const uint16_t* data, unsigned channels, unsigned pixels_per_line, unsigned lines) { DBG_HELPER_ARGS(dbg, "channels=%d, ppl=%d, lines=%d", channels, pixels_per_line, lines); std::FILE* out = std::fopen(filename, "w"); if (!out) { throw SaneException("could not open %s for writing: %s\n", filename, strerror(errno)); } std::fprintf(out, "P%c\n%d\n%d\n%d\n", channels == 1 ? '5' : '6', pixels_per_line, lines, 256 * 256 - 1); for (unsigned count = 0; count < (pixels_per_line * lines * channels); count++) { fputc(*data >> 8, out); fputc(*data & 0xff, out); data++; } std::fclose(out); } bool is_supported_write_pnm_file_image_format(PixelFormat format) { switch (format) { case PixelFormat::I1: case PixelFormat::RGB111: case PixelFormat::I8: case PixelFormat::RGB888: case PixelFormat::I16: case PixelFormat::RGB161616: return true; default: return false; } } void sanei_genesys_write_pnm_file(const char* filename, const Image& image) { if (!is_supported_write_pnm_file_image_format(image.get_format())) { throw SaneException("Unsupported format %d", static_cast(image.get_format())); } sanei_genesys_write_pnm_file(filename, image.get_row_ptr(0), get_pixel_format_depth(image.get_format()), get_pixel_channels(image.get_format()), image.get_width(), image.get_height()); } /* ------------------------------------------------------------------------ */ /* Read and write RAM, registers and AFE */ /* ------------------------------------------------------------------------ */ unsigned sanei_genesys_get_bulk_max_size(AsicType asic_type) { /* Genesys supports 0xFE00 maximum size in general, wheraus GL646 supports 0xFFC0. We use 0xF000 because that's the packet limit in the Linux usbmon USB capture stack. By default it limits packet size to b_size / 5 where b_size is the size of the ring buffer. By default it's 300*1024, so the packet is limited 61440 without any visibility to acquiring software. */ if (asic_type == AsicType::GL124 || asic_type == AsicType::GL846 || asic_type == AsicType::GL847) { return 0xeff0; } return 0xf000; } // Set address for writing data void sanei_genesys_set_buffer_address(Genesys_Device* dev, uint32_t addr) { DBG_HELPER(dbg); if (dev->model->asic_type==AsicType::GL847 || dev->model->asic_type==AsicType::GL845 || dev->model->asic_type==AsicType::GL846 || dev->model->asic_type==AsicType::GL124) { DBG(DBG_warn, "%s: shouldn't be used for GL846+ ASICs\n", __func__); return; } DBG(DBG_io, "%s: setting address to 0x%05x\n", __func__, addr & 0xfffffff0); addr = addr >> 4; dev->interface->write_register(0x2b, (addr & 0xff)); addr = addr >> 8; dev->interface->write_register(0x2a, (addr & 0xff)); } /* ------------------------------------------------------------------------ */ /* Medium level functions */ /* ------------------------------------------------------------------------ */ Status scanner_read_status(Genesys_Device& dev) { DBG_HELPER(dbg); std::uint16_t address = 0; switch (dev.model->asic_type) { case AsicType::GL124: address = 0x101; break; case AsicType::GL646: case AsicType::GL841: case AsicType::GL843: case AsicType::GL845: case AsicType::GL846: case AsicType::GL847: address = 0x41; break; default: throw SaneException("Unsupported asic type"); } // same for all chips constexpr std::uint8_t PWRBIT = 0x80; constexpr std::uint8_t BUFEMPTY = 0x40; constexpr std::uint8_t FEEDFSH = 0x20; constexpr std::uint8_t SCANFSH = 0x10; constexpr std::uint8_t HOMESNR = 0x08; constexpr std::uint8_t LAMPSTS = 0x04; constexpr std::uint8_t FEBUSY = 0x02; constexpr std::uint8_t MOTORENB = 0x01; auto value = dev.interface->read_register(address); Status status; status.is_replugged = !(value & PWRBIT); status.is_buffer_empty = value & BUFEMPTY; status.is_feeding_finished = value & FEEDFSH; status.is_scanning_finished = value & SCANFSH; status.is_at_home = value & HOMESNR; status.is_lamp_on = value & LAMPSTS; status.is_front_end_busy = value & FEBUSY; status.is_motor_enabled = value & MOTORENB; if (DBG_LEVEL >= DBG_io) { debug_print_status(dbg, status); } return status; } Status scanner_read_reliable_status(Genesys_Device& dev) { DBG_HELPER(dbg); scanner_read_status(dev); dev.interface->sleep_ms(100); return scanner_read_status(dev); } void scanner_read_print_status(Genesys_Device& dev) { scanner_read_status(dev); } /** * decodes and prints content of status register * @param val value read from status register */ void debug_print_status(DebugMessageHelper& dbg, Status val) { std::stringstream str; str << val; dbg.vlog(DBG_info, "status=%s\n", str.str().c_str()); } #if 0 /* returns pixels per line from register set */ /*candidate for moving into chip specific files?*/ static int genesys_pixels_per_line (Genesys_Register_Set * reg) { int pixels_per_line; pixels_per_line = reg->get8(0x32) * 256 + reg->get8(0x33); pixels_per_line -= (reg->get8(0x30) * 256 + reg->get8(0x31)); return pixels_per_line; } /* returns dpiset from register set */ /*candidate for moving into chip specific files?*/ static int genesys_dpiset (Genesys_Register_Set * reg) { return reg->get8(0x2c) * 256 + reg->get8(0x2d); } #endif /** read the number of valid words in scanner's RAM * ie registers 42-43-44 */ // candidate for moving into chip specific files? void sanei_genesys_read_valid_words(Genesys_Device* dev, unsigned int* words) { DBG_HELPER(dbg); switch (dev->model->asic_type) { case AsicType::GL124: *words = dev->interface->read_register(0x102) & 0x03; *words = *words * 256 + dev->interface->read_register(0x103); *words = *words * 256 + dev->interface->read_register(0x104); *words = *words * 256 + dev->interface->read_register(0x105); break; case AsicType::GL845: case AsicType::GL846: *words = dev->interface->read_register(0x42) & 0x02; *words = *words * 256 + dev->interface->read_register(0x43); *words = *words * 256 + dev->interface->read_register(0x44); *words = *words * 256 + dev->interface->read_register(0x45); break; case AsicType::GL847: *words = dev->interface->read_register(0x42) & 0x03; *words = *words * 256 + dev->interface->read_register(0x43); *words = *words * 256 + dev->interface->read_register(0x44); *words = *words * 256 + dev->interface->read_register(0x45); break; default: *words = dev->interface->read_register(0x44); *words += dev->interface->read_register(0x43) * 256; if (dev->model->asic_type == AsicType::GL646) { *words += ((dev->interface->read_register(0x42) & 0x03) * 256 * 256); } else { *words += ((dev->interface->read_register(0x42) & 0x0f) * 256 * 256); } } DBG(DBG_proc, "%s: %d words\n", __func__, *words); } /** read the number of lines scanned * ie registers 4b-4c-4d */ void sanei_genesys_read_scancnt(Genesys_Device* dev, unsigned int* words) { DBG_HELPER(dbg); if (dev->model->asic_type == AsicType::GL124) { *words = (dev->interface->read_register(0x10b) & 0x0f) << 16; *words += (dev->interface->read_register(0x10c) << 8); *words += dev->interface->read_register(0x10d); } else { *words = dev->interface->read_register(0x4d); *words += dev->interface->read_register(0x4c) * 256; if (dev->model->asic_type == AsicType::GL646) { *words += ((dev->interface->read_register(0x4b) & 0x03) * 256 * 256); } else { *words += ((dev->interface->read_register(0x4b) & 0x0f) * 256 * 256); } } DBG(DBG_proc, "%s: %d lines\n", __func__, *words); } /** @brief Check if the scanner's internal data buffer is empty * @param *dev device to test for data * @param *empty return value * @return empty will be set to true if there is no scanned data. **/ bool sanei_genesys_is_buffer_empty(Genesys_Device* dev) { DBG_HELPER(dbg); dev->interface->sleep_ms(1); auto status = scanner_read_status(*dev); if (status.is_buffer_empty) { /* fix timing issue on USB3 (or just may be too fast) hardware * spotted by John S. Weber */ dev->interface->sleep_ms(1); DBG(DBG_io2, "%s: buffer is empty\n", __func__); return true; } DBG(DBG_io, "%s: buffer is filled\n", __func__); return false; } void wait_until_buffer_non_empty(Genesys_Device* dev, bool check_status_twice) { // FIXME: reduce MAX_RETRIES once tests are updated const unsigned MAX_RETRIES = 100000; for (unsigned i = 0; i < MAX_RETRIES; ++i) { if (check_status_twice) { // FIXME: this only to preserve previous behavior, can be removed scanner_read_status(*dev); } bool empty = sanei_genesys_is_buffer_empty(dev); dev->interface->sleep_ms(10); if (!empty) return; } throw SaneException(SANE_STATUS_IO_ERROR, "failed to read data"); } void wait_until_has_valid_words(Genesys_Device* dev) { unsigned words = 0; unsigned sleep_time_ms = 10; for (unsigned wait_ms = 0; wait_ms < 50000; wait_ms += sleep_time_ms) { sanei_genesys_read_valid_words(dev, &words); if (words != 0) break; dev->interface->sleep_ms(sleep_time_ms); } if (words == 0) { throw SaneException(SANE_STATUS_IO_ERROR, "timeout, buffer does not get filled"); } } // Read data (e.g scanned image) from scan buffer void sanei_genesys_read_data_from_scanner(Genesys_Device* dev, uint8_t* data, size_t size) { DBG_HELPER_ARGS(dbg, "size = %zu bytes", size); if (size & 1) DBG(DBG_info, "WARNING %s: odd number of bytes\n", __func__); wait_until_has_valid_words(dev); dev->interface->bulk_read_data(0x45, data, size); } Image read_unshuffled_image_from_scanner(Genesys_Device* dev, const ScanSession& session, std::size_t total_bytes) { DBG_HELPER(dbg); auto format = create_pixel_format(session.params.depth, dev->model->is_cis ? 1 : session.params.channels, dev->model->line_mode_color_order); auto width = get_pixels_from_row_bytes(format, session.output_line_bytes_raw); auto height = session.output_line_count * (dev->model->is_cis ? session.params.channels : 1); Image image(width, height, format); auto max_bytes = image.get_row_bytes() * height; if (total_bytes > max_bytes) { throw SaneException("Trying to read too much data %zu (max %zu)", total_bytes, max_bytes); } if (total_bytes != max_bytes) { DBG(DBG_info, "WARNING %s: trying to read not enough data (%zu, full fill %zu\n", __func__, total_bytes, max_bytes); } sanei_genesys_read_data_from_scanner(dev, image.get_row_ptr(0), total_bytes); ImagePipelineStack pipeline; pipeline.push_first_node(image); if ((dev->model->flags & GENESYS_FLAG_16BIT_DATA_INVERTED) && session.params.depth == 16) { dev->pipeline.push_node(); } #ifdef WORDS_BIGENDIAN if (depth == 16) { dev->pipeline.push_node(); } #endif if (dev->model->is_cis && session.params.channels == 3) { dev->pipeline.push_node(dev->model->line_mode_color_order); } if (dev->pipeline.get_output_format() == PixelFormat::BGR888) { dev->pipeline.push_node(PixelFormat::RGB888); } if (dev->pipeline.get_output_format() == PixelFormat::BGR161616) { dev->pipeline.push_node(PixelFormat::RGB161616); } return pipeline.get_image(); } void sanei_genesys_read_feed_steps(Genesys_Device* dev, unsigned int* steps) { DBG_HELPER(dbg); if (dev->model->asic_type == AsicType::GL124) { *steps = (dev->interface->read_register(0x108) & 0x1f) << 16; *steps += (dev->interface->read_register(0x109) << 8); *steps += dev->interface->read_register(0x10a); } else { *steps = dev->interface->read_register(0x4a); *steps += dev->interface->read_register(0x49) * 256; if (dev->model->asic_type == AsicType::GL646) { *steps += ((dev->interface->read_register(0x48) & 0x03) * 256 * 256); } else if (dev->model->asic_type == AsicType::GL841) { *steps += ((dev->interface->read_register(0x48) & 0x0f) * 256 * 256); } else { *steps += ((dev->interface->read_register(0x48) & 0x1f) * 256 * 256); } } DBG(DBG_proc, "%s: %d steps\n", __func__, *steps); } void sanei_genesys_set_lamp_power(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, bool set) { static const uint8_t REG_0x03_LAMPPWR = 0x10; if (set) { regs.find_reg(0x03).value |= REG_0x03_LAMPPWR; if (dev->model->asic_type == AsicType::GL841) { regs_set_exposure(dev->model->asic_type, regs, sanei_genesys_fixup_exposure(sensor.exposure)); regs.set8(0x19, 0x50); } if (dev->model->asic_type == AsicType::GL843) { regs_set_exposure(dev->model->asic_type, regs, sensor.exposure); // we don't actually turn on lamp on infrared scan if ((dev->model->model_id == ModelId::CANON_8400F || dev->model->model_id == ModelId::CANON_8600F || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) && dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { regs.find_reg(0x03).value &= ~REG_0x03_LAMPPWR; } } } else { regs.find_reg(0x03).value &= ~REG_0x03_LAMPPWR; if (dev->model->asic_type == AsicType::GL841) { regs_set_exposure(dev->model->asic_type, regs, {0x0101, 0x0101, 0x0101}); regs.set8(0x19, 0xff); } if (dev->model->asic_type == AsicType::GL843) { if (dev->model->model_id == ModelId::PANASONIC_KV_SS080 || dev->model->model_id == ModelId::HP_SCANJET_4850C || dev->model->model_id == ModelId::HP_SCANJET_G4010 || dev->model->model_id == ModelId::HP_SCANJET_G4050) { // BUG: datasheet says we shouldn't set exposure to zero regs_set_exposure(dev->model->asic_type, regs, {0, 0, 0}); } } } regs.state.is_lamp_on = set; } void sanei_genesys_set_motor_power(Genesys_Register_Set& regs, bool set) { static const uint8_t REG_0x02_MTRPWR = 0x10; if (set) { regs.find_reg(0x02).value |= REG_0x02_MTRPWR; } else { regs.find_reg(0x02).value &= ~REG_0x02_MTRPWR; } regs.state.is_motor_on = set; } bool should_enable_gamma(const ScanSession& session, const Genesys_Sensor& sensor) { if ((session.params.flags & ScanFlag::DISABLE_GAMMA) != ScanFlag::NONE) { return false; } if (sensor.gamma[0] == 1.0f || sensor.gamma[1] == 1.0f || sensor.gamma[2] == 1.0f) { return false; } if (session.params.depth == 16) return false; return true; } std::vector get_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor, int color) { if (!dev->gamma_override_tables[color].empty()) { return dev->gamma_override_tables[color]; } else { std::vector ret; sanei_genesys_create_default_gamma_table(dev, ret, sensor.gamma[color]); return ret; } } /** @brief generates gamma buffer to transfer * Generates gamma table buffer to send to ASIC. Applies * contrast and brightness if set. * @param dev device to set up * @param bits number of bits used by gamma * @param max value for gamma * @param size of the gamma table * @param gamma allocated gamma buffer to fill */ void sanei_genesys_generate_gamma_buffer(Genesys_Device* dev, const Genesys_Sensor& sensor, int bits, int max, int size, uint8_t* gamma) { DBG_HELPER(dbg); std::vector rgamma = get_gamma_table(dev, sensor, GENESYS_RED); std::vector ggamma = get_gamma_table(dev, sensor, GENESYS_GREEN); std::vector bgamma = get_gamma_table(dev, sensor, GENESYS_BLUE); if(dev->settings.contrast!=0 || dev->settings.brightness!=0) { std::vector lut(65536); sanei_genesys_load_lut(reinterpret_cast(lut.data()), bits, bits, 0, max, dev->settings.contrast, dev->settings.brightness); for (int i = 0; i < size; i++) { uint16_t value=rgamma[i]; value=lut[value]; gamma[i * 2 + size * 0 + 0] = value & 0xff; gamma[i * 2 + size * 0 + 1] = (value >> 8) & 0xff; value=ggamma[i]; value=lut[value]; gamma[i * 2 + size * 2 + 0] = value & 0xff; gamma[i * 2 + size * 2 + 1] = (value >> 8) & 0xff; value=bgamma[i]; value=lut[value]; gamma[i * 2 + size * 4 + 0] = value & 0xff; gamma[i * 2 + size * 4 + 1] = (value >> 8) & 0xff; } } else { for (int i = 0; i < size; i++) { uint16_t value=rgamma[i]; gamma[i * 2 + size * 0 + 0] = value & 0xff; gamma[i * 2 + size * 0 + 1] = (value >> 8) & 0xff; value=ggamma[i]; gamma[i * 2 + size * 2 + 0] = value & 0xff; gamma[i * 2 + size * 2 + 1] = (value >> 8) & 0xff; value=bgamma[i]; gamma[i * 2 + size * 4 + 0] = value & 0xff; gamma[i * 2 + size * 4 + 1] = (value >> 8) & 0xff; } } } /** @brief send gamma table to scanner * This function sends generic gamma table (ie ones built with * provided gamma) or the user defined one if provided by * fontend. Used by gl846+ ASICs * @param dev device to write to */ void sanei_genesys_send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); int size; int i; size = 256 + 1; /* allocate temporary gamma tables: 16 bits words, 3 channels */ std::vector gamma(size * 2 * 3, 255); sanei_genesys_generate_gamma_buffer(dev, sensor, 16, 65535, size, gamma.data()); // loop sending gamma tables NOTE: 0x01000000 not 0x10000000 for (i = 0; i < 3; i++) { // clear corresponding GMM_N bit uint8_t val = dev->interface->read_register(0xbd); val &= ~(0x01 << i); dev->interface->write_register(0xbd, val); // clear corresponding GMM_F bit val = dev->interface->read_register(0xbe); val &= ~(0x01 << i); dev->interface->write_register(0xbe, val); // FIXME: currently the last word of each gamma table is not initialied, so to work around // unstable data, just set it to 0 which is the most likely value of uninitialized memory // (proper value is probably 0xff) gamma[size * 2 * i + size * 2 - 2] = 0; gamma[size * 2 * i + size * 2 - 1] = 0; /* set GMM_Z */ dev->interface->write_register(0xc5+2*i, gamma[size*2*i+1]); dev->interface->write_register(0xc6+2*i, gamma[size*2*i]); dev->interface->write_ahb(0x01000000 + 0x200 * i, (size-1) * 2, gamma.data() + i * size * 2+2); } } static unsigned align_int_up(unsigned num, unsigned alignment) { unsigned mask = alignment - 1; if (num & mask) num = (num & ~mask) + alignment; return num; } void compute_session_buffer_sizes(AsicType asic, ScanSession& s) { size_t line_bytes = s.output_line_bytes; size_t line_bytes_stagger = s.output_line_bytes; if (asic != AsicType::GL646) { // BUG: this is historical artifact and should be removed. Note that buffer sizes affect // how often we request the scanner for data and thus change the USB traffic. line_bytes_stagger = multiply_by_depth_ceil(s.optical_pixels, s.params.depth) * s.params.channels; } struct BufferConfig { size_t* result_size = nullptr; size_t lines = 0; size_t lines_mult = 0; size_t max_size = 0; // does not apply if 0 size_t stagger_lines = 0; BufferConfig() = default; BufferConfig(std::size_t* rs, std::size_t l, std::size_t lm, std::size_t ms, std::size_t sl) : result_size{rs}, lines{l}, lines_mult{lm}, max_size{ms}, stagger_lines{sl} {} }; std::array configs; if (asic == AsicType::GL124 || asic == AsicType::GL843) { configs = { { { &s.buffer_size_read, 32, 1, 0, s.max_color_shift_lines + s.num_staggered_lines }, { &s.buffer_size_lines, 32, 1, 0, s.max_color_shift_lines + s.num_staggered_lines }, { &s.buffer_size_shrink, 16, 1, 0, 0 }, { &s.buffer_size_out, 8, 1, 0, 0 }, } }; } else if (asic == AsicType::GL841) { size_t max_buf = sanei_genesys_get_bulk_max_size(asic); configs = { { { &s.buffer_size_read, 8, 2, max_buf, s.max_color_shift_lines + s.num_staggered_lines }, { &s.buffer_size_lines, 8, 2, max_buf, s.max_color_shift_lines + s.num_staggered_lines }, { &s.buffer_size_shrink, 8, 1, max_buf, 0 }, { &s.buffer_size_out, 8, 1, 0, 0 }, } }; } else { configs = { { { &s.buffer_size_read, 16, 1, 0, s.max_color_shift_lines + s.num_staggered_lines }, { &s.buffer_size_lines, 16, 1, 0, s.max_color_shift_lines + s.num_staggered_lines }, { &s.buffer_size_shrink, 8, 1, 0, 0 }, { &s.buffer_size_out, 8, 1, 0, 0 }, } }; } for (BufferConfig& config : configs) { size_t buf_size = line_bytes * config.lines; if (config.max_size > 0 && buf_size > config.max_size) { buf_size = (config.max_size / line_bytes) * line_bytes; } buf_size *= config.lines_mult; buf_size += line_bytes_stagger * config.stagger_lines; *config.result_size = buf_size; } } void compute_session_pipeline(const Genesys_Device* dev, ScanSession& s) { auto channels = s.params.channels; auto depth = s.params.depth; s.pipeline_needs_reorder = true; if (channels != 3 && depth != 16) { s.pipeline_needs_reorder = false; } #ifndef WORDS_BIGENDIAN if (channels != 3 && depth == 16) { s.pipeline_needs_reorder = false; } if (channels == 3 && depth == 16 && !dev->model->is_cis && dev->model->line_mode_color_order == ColorOrder::RGB) { s.pipeline_needs_reorder = false; } #endif if (channels == 3 && depth == 8 && !dev->model->is_cis && dev->model->line_mode_color_order == ColorOrder::RGB) { s.pipeline_needs_reorder = false; } s.pipeline_needs_ccd = s.max_color_shift_lines + s.num_staggered_lines > 0; s.pipeline_needs_shrink = dev->settings.requested_pixels != s.output_pixels; } void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor) { unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel(); if (dev->model->asic_type == AsicType::GL646) { // startx cannot be below dummy pixel value s.pixel_startx = sensor.dummy_pixel; if (has_flag(s.params.flags, ScanFlag::USE_XCORRECTION) && sensor.ccd_start_xoffset > 0) { s.pixel_startx = sensor.ccd_start_xoffset; } s.pixel_startx += s.params.startx; if (sensor.stagger_config.stagger_at_resolution(s.params.xres, s.params.yres) > 0) { s.pixel_startx |= 1; } s.pixel_endx = s.pixel_startx + s.optical_pixels; s.pixel_startx /= sensor.ccd_pixels_per_system_pixel() * s.ccd_size_divisor; s.pixel_endx /= sensor.ccd_pixels_per_system_pixel() * s.ccd_size_divisor; } else if (dev->model->asic_type == AsicType::GL841) { s.pixel_startx = ((sensor.ccd_start_xoffset + s.params.startx) * s.optical_resolution) / sensor.optical_res; s.pixel_startx += sensor.dummy_pixel + 1; if (s.num_staggered_lines > 0 && (s.pixel_startx & 1) == 0) { s.pixel_startx++; } /* In case of SHDAREA, we need to align start on pixel average factor, startx is different than 0 only when calling for function to setup for scan, where shading data needs to be align. NOTE: we can check the value of the register here, because we don't set this bit anywhere except in initialization. */ const uint8_t REG_0x01_SHDAREA = 0x02; if ((dev->reg.find_reg(0x01).value & REG_0x01_SHDAREA) != 0) { unsigned average_factor = s.optical_resolution / s.params.xres; s.pixel_startx = align_multiple_floor(s.pixel_startx, average_factor); } s.pixel_endx = s.pixel_startx + s.optical_pixels; } else if (dev->model->asic_type == AsicType::GL843) { s.pixel_startx = (s.params.startx + sensor.dummy_pixel) / ccd_pixels_per_system_pixel; s.pixel_endx = s.pixel_startx + s.optical_pixels / ccd_pixels_per_system_pixel; s.pixel_startx /= s.hwdpi_divisor; s.pixel_endx /= s.hwdpi_divisor; // in case of stagger we have to start at an odd coordinate bool stagger_starts_even = dev->model->model_id == ModelId::CANON_8400F; if (s.num_staggered_lines > 0) { if (!stagger_starts_even && (s.pixel_startx & 1) == 0) { s.pixel_startx++; s.pixel_endx++; } else if (stagger_starts_even && (s.pixel_startx & 1) != 0) { s.pixel_startx++; s.pixel_endx++; } } } else if (dev->model->asic_type == AsicType::GL845 || dev->model->asic_type == AsicType::GL846 || dev->model->asic_type == AsicType::GL847) { s.pixel_startx = s.params.startx; if (s.num_staggered_lines > 0) { s.pixel_startx |= 1; } s.pixel_startx += sensor.ccd_start_xoffset * ccd_pixels_per_system_pixel; s.pixel_endx = s.pixel_startx + s.optical_pixels_raw; s.pixel_startx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel; s.pixel_endx /= s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel; } else if (dev->model->asic_type == AsicType::GL124) { s.pixel_startx = s.params.startx; if (s.num_staggered_lines > 0) { s.pixel_startx |= 1; } s.pixel_startx /= ccd_pixels_per_system_pixel; // FIXME: should we add sensor.dummy_pxel to pixel_startx at this point? s.pixel_endx = s.pixel_startx + s.optical_pixels / ccd_pixels_per_system_pixel; s.pixel_startx /= s.hwdpi_divisor * s.segment_count; s.pixel_endx /= s.hwdpi_divisor * s.segment_count; std::uint32_t segcnt = (sensor.custom_regs.get_value(gl124::REG_SEGCNT) << 16) + (sensor.custom_regs.get_value(gl124::REG_SEGCNT + 1) << 8) + sensor.custom_regs.get_value(gl124::REG_SEGCNT + 2); if (s.pixel_endx == segcnt) { s.pixel_endx = 0; } } s.pixel_count_multiplier = sensor.pixel_count_multiplier; s.pixel_startx *= sensor.pixel_count_multiplier; s.pixel_endx *= sensor.pixel_count_multiplier; } void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); (void) dev; s.params.assert_valid(); if (s.params.depth != 8 && s.params.depth != 16) { throw SaneException("Unsupported depth setting %d", s.params.depth); } unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel(); // compute optical and output resolutions if (dev->model->asic_type == AsicType::GL843) { // FIXME: this may be incorrect, but need more scanners to test s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres); } else { s.hwdpi_divisor = sensor.get_hwdpi_divisor_for_dpi(s.params.xres * ccd_pixels_per_system_pixel); } s.ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(s.params.xres); if (dev->model->asic_type == AsicType::GL646) { s.optical_resolution = sensor.optical_res; } else { s.optical_resolution = sensor.optical_res / s.ccd_size_divisor; } s.output_resolution = s.params.xres; if (s.output_resolution > s.optical_resolution) { throw std::runtime_error("output resolution higher than optical resolution"); } // compute the number of optical pixels that will be acquired by the chip s.optical_pixels = (s.params.pixels * s.optical_resolution) / s.output_resolution; if (s.optical_pixels * s.output_resolution < s.params.pixels * s.optical_resolution) { s.optical_pixels++; } if (dev->model->asic_type == AsicType::GL841) { if (s.optical_pixels & 1) s.optical_pixels++; } if (dev->model->asic_type == AsicType::GL646 && s.params.xres == 400) { s.optical_pixels = (s.optical_pixels / 6) * 6; } if (dev->model->asic_type == AsicType::GL843) { // ensure the number of optical pixels is divisible by 2. // In quarter-CCD mode optical_pixels is 4x larger than the actual physical number s.optical_pixels = align_int_up(s.optical_pixels, 2 * s.ccd_size_divisor); if (dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7200I || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7300 || dev->model->model_id == ModelId::PLUSTEK_OPTICFILM_7500I) { s.optical_pixels = align_int_up(s.optical_pixels, 16); } } // after all adjustments on the optical pixels have been made, compute the number of pixels // to retrieve from the chip s.output_pixels = (s.optical_pixels * s.output_resolution) / s.optical_resolution; // Note: staggering is not applied for calibration. Staggering starts at 2400 dpi s.num_staggered_lines = 0; if (!has_flag(s.params.flags, ScanFlag::IGNORE_LINE_DISTANCE)) { s.num_staggered_lines = sensor.stagger_config.stagger_at_resolution(s.params.xres, s.params.yres); } s.color_shift_lines_r = dev->model->ld_shift_r; s.color_shift_lines_g = dev->model->ld_shift_g; s.color_shift_lines_b = dev->model->ld_shift_b; if (dev->model->motor_id == MotorId::G4050 && s.params.yres > 600) { // it seems base_dpi of the G4050 motor is changed above 600 dpi s.color_shift_lines_r = (s.color_shift_lines_r * 3800) / dev->motor.base_ydpi; s.color_shift_lines_g = (s.color_shift_lines_g * 3800) / dev->motor.base_ydpi; s.color_shift_lines_b = (s.color_shift_lines_b * 3800) / dev->motor.base_ydpi; } s.color_shift_lines_r = (s.color_shift_lines_r * s.params.yres) / dev->motor.base_ydpi; s.color_shift_lines_g = (s.color_shift_lines_g * s.params.yres) / dev->motor.base_ydpi; s.color_shift_lines_b = (s.color_shift_lines_b * s.params.yres) / dev->motor.base_ydpi; s.max_color_shift_lines = 0; if (s.params.channels > 1 && !has_flag(s.params.flags, ScanFlag::IGNORE_LINE_DISTANCE)) { s.max_color_shift_lines = std::max(s.color_shift_lines_r, std::max(s.color_shift_lines_g, s.color_shift_lines_b)); } s.output_line_count = s.params.lines + s.max_color_shift_lines + s.num_staggered_lines; s.output_channel_bytes = multiply_by_depth_ceil(s.output_pixels, s.params.depth); s.output_line_bytes = s.output_channel_bytes * s.params.channels; s.segment_count = sensor.get_segment_count(); s.optical_pixels_raw = s.optical_pixels; s.output_line_bytes_raw = s.output_line_bytes; s.conseq_pixel_dist = 0; if (dev->model->asic_type == AsicType::GL845 || dev->model->asic_type == AsicType::GL846 || dev->model->asic_type == AsicType::GL847) { if (s.segment_count > 1) { s.conseq_pixel_dist = sensor.segment_size; // in case of multi-segments sensor, we have to add the width of the sensor crossed by // the scan area unsigned extra_segment_scan_area = align_multiple_ceil(s.conseq_pixel_dist, 2); extra_segment_scan_area *= s.segment_count - 1; extra_segment_scan_area *= s.hwdpi_divisor * s.segment_count; extra_segment_scan_area *= ccd_pixels_per_system_pixel; s.optical_pixels_raw += extra_segment_scan_area; } s.output_line_bytes_raw = multiply_by_depth_ceil( (s.optical_pixels_raw * s.output_resolution) / sensor.optical_res / s.segment_count, s.params.depth); } if (dev->model->asic_type == AsicType::GL841) { if (dev->model->is_cis) { s.output_line_bytes_raw = s.output_channel_bytes; } } if (dev->model->asic_type == AsicType::GL124) { if (dev->model->is_cis) { s.output_line_bytes_raw = s.output_channel_bytes; } s.conseq_pixel_dist = s.output_pixels / s.ccd_size_divisor / s.segment_count; } if (dev->model->asic_type == AsicType::GL843) { s.conseq_pixel_dist = s.output_pixels / s.segment_count; } s.output_segment_pixel_group_count = 0; if (dev->model->asic_type == AsicType::GL124 || dev->model->asic_type == AsicType::GL843) { s.output_segment_pixel_group_count = multiply_by_depth_ceil( s.output_pixels / s.ccd_size_divisor / s.segment_count, s.params.depth); } if (dev->model->asic_type == AsicType::GL845 || dev->model->asic_type == AsicType::GL846 || dev->model->asic_type == AsicType::GL847) { s.output_segment_pixel_group_count = multiply_by_depth_ceil( s.optical_pixels / (s.hwdpi_divisor * s.segment_count * ccd_pixels_per_system_pixel), s.params.depth); } s.output_line_bytes_requested = multiply_by_depth_ceil( s.params.get_requested_pixels() * s.params.channels, s.params.depth); s.output_total_bytes_raw = s.output_line_bytes_raw * s.output_line_count; s.output_total_bytes = s.output_line_bytes * s.output_line_count; compute_session_buffer_sizes(dev->model->asic_type, s); compute_session_pipeline(dev, s); compute_session_pixel_offsets(dev, s, sensor); if (dev->model->asic_type == AsicType::GL124 || dev->model->asic_type == AsicType::GL845 || dev->model->asic_type == AsicType::GL846) { s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray); } if (dev->model->asic_type == AsicType::GL841 || dev->model->asic_type == AsicType::GL843) { // no 16 bit gamma for this ASIC if (s.params.depth == 16) { s.params.flags |= ScanFlag::DISABLE_GAMMA; } } s.computed = true; DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, s); } static std::size_t get_usb_buffer_read_size(AsicType asic, const ScanSession& session) { switch (asic) { case AsicType::GL646: // buffer not used on this chip set return 1; case AsicType::GL124: // BUG: we shouldn't multiply by channels here nor divide by ccd_size_divisor return session.output_line_bytes_raw / session.ccd_size_divisor * session.params.channels; case AsicType::GL845: case AsicType::GL846: case AsicType::GL847: // BUG: we shouldn't multiply by channels here return session.output_line_bytes_raw * session.params.channels; case AsicType::GL843: return session.output_line_bytes_raw * 2; default: throw SaneException("Unknown asic type"); } } static FakeBufferModel get_fake_usb_buffer_model(const ScanSession& session) { FakeBufferModel model; model.push_step(session.buffer_size_read, 1); if (session.pipeline_needs_reorder) { model.push_step(session.buffer_size_lines, session.output_line_bytes); } if (session.pipeline_needs_ccd) { model.push_step(session.buffer_size_shrink, session.output_line_bytes); } if (session.pipeline_needs_shrink) { model.push_step(session.buffer_size_out, session.output_line_bytes); } return model; } void build_image_pipeline(Genesys_Device* dev, const ScanSession& session) { static unsigned s_pipeline_index = 0; s_pipeline_index++; auto format = create_pixel_format(session.params.depth, dev->model->is_cis ? 1 : session.params.channels, dev->model->line_mode_color_order); auto depth = get_pixel_format_depth(format); auto width = get_pixels_from_row_bytes(format, session.output_line_bytes_raw); auto read_data_from_usb = [dev](std::size_t size, std::uint8_t* data) { dev->interface->bulk_read_data(0x45, data, size); return true; }; auto lines = session.output_line_count * (dev->model->is_cis ? session.params.channels : 1); dev->pipeline.clear(); // FIXME: here we are complicating things for the time being to preserve the existing behaviour // This allows to be sure that the changes to the image pipeline have not introduced // regressions. if (session.segment_count > 1) { // BUG: we're reading one line too much dev->pipeline.push_first_node( width, lines + 1, format, get_usb_buffer_read_size(dev->model->asic_type, session), read_data_from_usb); auto output_width = session.output_segment_pixel_group_count * session.segment_count; dev->pipeline.push_node(output_width, dev->segment_order, session.conseq_pixel_dist, 1, 1); } else { auto read_bytes_left_after_deseg = session.output_line_bytes * session.output_line_count; if (dev->model->asic_type == AsicType::GL646) { read_bytes_left_after_deseg *= dev->model->is_cis ? session.params.channels : 1; } dev->pipeline.push_first_node( width, lines, format, read_bytes_left_after_deseg, get_fake_usb_buffer_model(session), read_data_from_usb); } if (DBG_LEVEL >= DBG_io2) { dev->pipeline.push_node("gl_pipeline_" + std::to_string(s_pipeline_index) + "_0_before_swap.pnm"); } if ((dev->model->flags & GENESYS_FLAG_16BIT_DATA_INVERTED) && depth == 16) { dev->pipeline.push_node(); } #ifdef WORDS_BIGENDIAN if (depth == 16) { dev->pipeline.push_node(); } #endif if (DBG_LEVEL >= DBG_io2) { dev->pipeline.push_node("gl_pipeline_" + std::to_string(s_pipeline_index) + "_1_after_swap.pnm"); } if (dev->model->is_cis && session.params.channels == 3) { dev->pipeline.push_node(dev->model->line_mode_color_order); } if (dev->pipeline.get_output_format() == PixelFormat::BGR888) { dev->pipeline.push_node(PixelFormat::RGB888); } if (dev->pipeline.get_output_format() == PixelFormat::BGR161616) { dev->pipeline.push_node(PixelFormat::RGB161616); } if (session.max_color_shift_lines > 0 && session.params.channels == 3) { dev->pipeline.push_node( session.color_shift_lines_r, session.color_shift_lines_g, session.color_shift_lines_b); } if (DBG_LEVEL >= DBG_io2) { dev->pipeline.push_node("gl_pipeline_" + std::to_string(s_pipeline_index) + "_2_after_shift.pnm"); } if (session.num_staggered_lines > 0) { std::vector shifts{0, session.num_staggered_lines}; dev->pipeline.push_node(shifts); } if (DBG_LEVEL >= DBG_io2) { dev->pipeline.push_node("gl_pipeline_" + std::to_string(s_pipeline_index) + "_3_after_stagger.pnm"); } if ((dev->model->flags & GENESYS_FLAG_CALIBRATION_HOST_SIDE) && !(dev->model->flags & GENESYS_FLAG_NO_CALIBRATION)) { dev->pipeline.push_node(dev->dark_average_data, dev->white_average_data); if (DBG_LEVEL >= DBG_io2) { dev->pipeline.push_node("gl_pipeline_" + std::to_string(s_pipeline_index) + "_4_after_calibrate.pnm"); } } if (session.output_pixels != session.params.get_requested_pixels()) { dev->pipeline.push_node(session.params.get_requested_pixels()); } auto read_from_pipeline = [dev](std::size_t size, std::uint8_t* out_data) { (void) size; // will be always equal to dev->pipeline.get_output_row_bytes() return dev->pipeline.get_next_row_data(out_data); }; dev->pipeline_buffer = ImageBuffer{dev->pipeline.get_output_row_bytes(), read_from_pipeline}; } std::uint8_t compute_frontend_gain_wolfson(float value, float target_value) { /* the flow of data through the frontend ADC is as follows (see e.g. WM8192 datasheet) input -> apply offset (o = i + 260mV * (DAC[7:0]-127.5)/127.5) -> -> apply gain (o = i * 208/(283-PGA[7:0]) -> ADC Here we have some input data that was acquired with zero gain (PGA==0). We want to compute gain such that the output would approach full ADC range (controlled by target_value). We want to solve the following for {PGA}: {value} = {input} * 208 / (283 - 0) {target_value} = {input} * 208 / (283 - {PGA}) The solution is the following equation: {PGA} = 283 * (1 - {value} / {target_value}) */ float gain = value / target_value; int code = static_cast(283 * (1 - gain)); return clamp(code, 0, 255); } std::uint8_t compute_frontend_gain_analog_devices(float value, float target_value) { /* The flow of data through the frontend ADC is as follows (see e.g. AD9826 datasheet) input -> apply offset (o = i + 300mV * (OFFSET[8] ? 1 : -1) * (OFFSET[7:0] / 127) -> apply gain (o = i * 6 / (1 + 5 * ( 63 - PGA[5:0] ) / 63 ) ) -> ADC We want to solve the following for {PGA}: {value} = {input} * 6 / (1 + 5 * ( 63 - 0) / 63 ) ) {target_value} = {input} * 6 / (1 + 5 * ( 63 - {PGA}) / 63 ) ) The solution is the following equation: {PGA} = (378 / 5) * ({target_value} - {value} / {target_value}) */ int code = static_cast((378.0f / 5.0f) * ((target_value - value) / target_value)); return clamp(code, 0, 63); } std::uint8_t compute_frontend_gain(float value, float target_value, FrontendType frontend_type) { if (frontend_type == FrontendType::WOLFSON) { return compute_frontend_gain_wolfson(value, target_value); } if (frontend_type == FrontendType::ANALOG_DEVICES) { return compute_frontend_gain_analog_devices(value, target_value); } throw SaneException("Unknown frontend to compute gain for"); } /** @brief initialize device * Initialize backend and ASIC : registers, motor tables, and gamma tables * then ensure scanner's head is at home. Designed for gl846+ ASICs. * Detects cold boot (ie first boot since device plugged) in this case * an extensice setup up is done at hardware level. * * @param dev device to initialize * @param max_regs umber of maximum used registers */ void sanei_genesys_asic_init(Genesys_Device* dev, bool /*max_regs*/) { DBG_HELPER(dbg); uint8_t val; bool cold = true; // URB 16 control 0xc0 0x0c 0x8e 0x0b len 1 read 0x00 */ dev->interface->get_usb_device().control_msg(REQUEST_TYPE_IN, REQUEST_REGISTER, VALUE_GET_REGISTER, 0x00, 1, &val); 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; } else { dev->usb_mode = 2; } /* Check if the device has already been initialized and powered up. We read register 0x06 and check PWRBIT, if reset scanner has been freshly powered up. This bit will be set to later so that following reads can detect power down/up cycle */ if (!is_testing_mode()) { if (dev->interface->read_register(0x06) & 0x10) { cold = false; } } 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", __func__); return; } // set up hardware and registers dev->cmd_set->asic_boot(dev, cold); /* now hardware part is OK, set up device struct */ dev->white_average_data.clear(); dev->dark_average_data.clear(); dev->settings.color_filter = ColorFilter::RED; /* duplicate initial values into calibration registers */ dev->calib_reg = dev->reg; const auto& sensor = sanei_genesys_find_sensor_any(dev); // Set analog frontend dev->cmd_set->set_fe(dev, sensor, AFE_INIT); dev->already_initialized = true; // Move to home if needed dev->cmd_set->move_back_home(dev, true); dev->set_head_pos_zero(ScanHeadId::PRIMARY); // Set powersaving (default = 15 minutes) dev->cmd_set->set_powersaving(dev, 15); } void scanner_start_action(Genesys_Device& dev, bool start_motor) { DBG_HELPER(dbg); switch (dev.model->asic_type) { case AsicType::GL646: case AsicType::GL841: case AsicType::GL843: case AsicType::GL845: case AsicType::GL846: case AsicType::GL847: case AsicType::GL124: break; default: throw SaneException("Unsupported chip"); } if (start_motor) { dev.interface->write_register(0x0f, 0x01); } else { dev.interface->write_register(0x0f, 0); } } void sanei_genesys_set_dpihw(Genesys_Register_Set& regs, const Genesys_Sensor& sensor, unsigned dpihw) { // same across GL646, GL841, GL843, GL846, GL847, GL124 const uint8_t REG_0x05_DPIHW_MASK = 0xc0; const uint8_t REG_0x05_DPIHW_600 = 0x00; const uint8_t REG_0x05_DPIHW_1200 = 0x40; const uint8_t REG_0x05_DPIHW_2400 = 0x80; const uint8_t REG_0x05_DPIHW_4800 = 0xc0; if (sensor.register_dpihw_override != 0) { dpihw = sensor.register_dpihw_override; } uint8_t dpihw_setting; switch (dpihw) { case 600: dpihw_setting = REG_0x05_DPIHW_600; break; case 1200: dpihw_setting = REG_0x05_DPIHW_1200; break; case 2400: dpihw_setting = REG_0x05_DPIHW_2400; break; case 4800: dpihw_setting = REG_0x05_DPIHW_4800; break; default: throw SaneException("Unknown dpihw value: %d", dpihw); } regs.set8_mask(0x05, dpihw_setting, REG_0x05_DPIHW_MASK); } void regs_set_exposure(AsicType asic_type, Genesys_Register_Set& regs, const SensorExposure& exposure) { switch (asic_type) { case AsicType::GL124: { regs.set24(gl124::REG_EXPR, exposure.red); regs.set24(gl124::REG_EXPG, exposure.green); regs.set24(gl124::REG_EXPB, exposure.blue); break; } case AsicType::GL646: { regs.set16(gl646::REG_EXPR, exposure.red); regs.set16(gl646::REG_EXPG, exposure.green); regs.set16(gl646::REG_EXPB, exposure.blue); break; } case AsicType::GL841: { regs.set16(gl841::REG_EXPR, exposure.red); regs.set16(gl841::REG_EXPG, exposure.green); regs.set16(gl841::REG_EXPB, exposure.blue); break; } case AsicType::GL843: { regs.set16(gl843::REG_EXPR, exposure.red); regs.set16(gl843::REG_EXPG, exposure.green); regs.set16(gl843::REG_EXPB, exposure.blue); break; } case AsicType::GL845: case AsicType::GL846: { regs.set16(gl846::REG_EXPR, exposure.red); regs.set16(gl846::REG_EXPG, exposure.green); regs.set16(gl846::REG_EXPB, exposure.blue); break; } case AsicType::GL847: { regs.set16(gl847::REG_EXPR, exposure.red); regs.set16(gl847::REG_EXPG, exposure.green); regs.set16(gl847::REG_EXPB, exposure.blue); break; } default: throw SaneException("Unsupported asic"); } } void regs_set_optical_off(AsicType asic_type, Genesys_Register_Set& regs) { DBG_HELPER(dbg); switch (asic_type) { case AsicType::GL646: { regs.find_reg(gl646::REG_0x01).value &= ~gl646::REG_0x01_SCAN; break; } case AsicType::GL841: { regs.find_reg(gl841::REG_0x01).value &= ~gl841::REG_0x01_SCAN; break; } case AsicType::GL843: { regs.find_reg(gl843::REG_0x01).value &= ~gl843::REG_0x01_SCAN; break; } case AsicType::GL845: case AsicType::GL846: { regs.find_reg(gl846::REG_0x01).value &= ~gl846::REG_0x01_SCAN; break; } case AsicType::GL847: { regs.find_reg(gl847::REG_0x01).value &= ~gl847::REG_0x01_SCAN; break; } case AsicType::GL124: { regs.find_reg(gl124::REG_0x01).value &= ~gl124::REG_0x01_SCAN; break; } default: throw SaneException("Unsupported asic"); } } bool get_registers_gain4_bit(AsicType asic_type, const Genesys_Register_Set& regs) { switch (asic_type) { case AsicType::GL646: return static_cast(regs.get8(gl646::REG_0x06) & gl646::REG_0x06_GAIN4); case AsicType::GL841: return static_cast(regs.get8(gl841::REG_0x06) & gl841::REG_0x06_GAIN4); case AsicType::GL843: return static_cast(regs.get8(gl843::REG_0x06) & gl843::REG_0x06_GAIN4); case AsicType::GL845: case AsicType::GL846: return static_cast(regs.get8(gl846::REG_0x06) & gl846::REG_0x06_GAIN4); case AsicType::GL847: return static_cast(regs.get8(gl847::REG_0x06) & gl847::REG_0x06_GAIN4); case AsicType::GL124: return static_cast(regs.get8(gl124::REG_0x06) & gl124::REG_0x06_GAIN4); default: throw SaneException("Unsupported chipset"); } } /** * Wait for the scanning head to park */ void sanei_genesys_wait_for_home(Genesys_Device* dev) { DBG_HELPER(dbg); /* clear the parking status whatever the outcome of the function */ dev->parking = false; if (is_testing_mode()) { return; } // read initial status, if head isn't at home and motor is on we are parking, so we wait. // gl847/gl124 need 2 reads for reliable results auto status = scanner_read_status(*dev); dev->interface->sleep_ms(10); status = scanner_read_status(*dev); if (status.is_at_home) { DBG (DBG_info, "%s: already at home\n", __func__); return; } unsigned timeout_ms = 200000; unsigned elapsed_ms = 0; do { dev->interface->sleep_ms(100); elapsed_ms += 100; status = scanner_read_status(*dev); } while (elapsed_ms < timeout_ms && !status.is_at_home); /* if after the timeout, head is still not parked, error out */ if (elapsed_ms >= timeout_ms && !status.is_at_home) { DBG (DBG_error, "%s: failed to reach park position in %dseconds\n", __func__, timeout_ms / 1000); throw SaneException(SANE_STATUS_IO_ERROR, "failed to reach park position"); } } /** @brief motor profile * search for the database of motor profiles and get the best one. Each * profile is at full step and at a reference exposure. Use first entry * by default. * @param motors motor profile database * @param motor_type motor id * @param exposure exposure time * @return a pointer to a Motor_Profile struct */ const Motor_Profile& sanei_genesys_get_motor_profile(const std::vector& motors, MotorId motor_id, int exposure) { int idx; idx=-1; for (std::size_t i = 0; i < motors.size(); ++i) { // exact match if (motors[i].motor_id == motor_id && motors[i].exposure==exposure) { return motors[i]; } // closest match if (motors[i].motor_id == motor_id) { /* if profile exposure is higher than the required one, * the entry is a candidate for the closest match */ if (motors[i].exposure == 0 || motors[i].exposure >= exposure) { if(idx<0) { /* no match found yet */ idx=i; } else { /* test for better match */ if(motors[i].exposuremodel->get_resolution_settings(dev->settings.scan_method); return resolution_settings.get_min_resolution_y(); } /** @brief returns the lowest possible dpi for the device * Parses device entry to find lowest motor or sensor dpi. * @param dev device description * @return lowest motor resolution */ int sanei_genesys_get_lowest_dpi(Genesys_Device *dev) { const auto& resolution_settings = dev->model->get_resolution_settings(dev->settings.scan_method); return std::min(resolution_settings.get_min_resolution_x(), resolution_settings.get_min_resolution_y()); } /** @brief check is a cache entry may be used * Compares current settings with the cache entry and return * true if they are compatible. * 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. * flatbed cache entries are considred too old and then expires if they * are older than the expiration time option, forcing calibration at least once * then given time. */ bool sanei_genesys_is_compatible_calibration(Genesys_Device* dev, const ScanSession& session, const Genesys_Calibration_Cache* cache, bool for_overwrite) { DBG_HELPER(dbg); #ifdef HAVE_SYS_TIME_H struct timeval time; #endif bool compatible = true; const auto& dev_params = session.params; if (dev_params.scan_method != cache->params.scan_method) { dbg.vlog(DBG_io, "incompatible: scan_method %d vs. %d\n", static_cast(dev_params.scan_method), static_cast(cache->params.scan_method)); compatible = false; } if (dev_params.xres != cache->params.xres) { dbg.vlog(DBG_io, "incompatible: params.xres %d vs. %d\n", dev_params.xres, cache->params.xres); compatible = false; } if (dev_params.yres != cache->params.yres) { // exposure depends on selected sensor and we select the sensor according to yres dbg.vlog(DBG_io, "incompatible: params.yres %d vs. %d\n", dev_params.yres, cache->params.yres); compatible = false; } if (dev_params.channels != cache->params.channels) { // exposure depends on total number of pixels at least on gl841 dbg.vlog(DBG_io, "incompatible: params.channels %d vs. %d\n", dev_params.channels, cache->params.channels); compatible = false; } if (dev_params.startx != cache->params.startx) { // exposure depends on total number of pixels at least on gl841 dbg.vlog(DBG_io, "incompatible: params.startx %d vs. %d\n", dev_params.startx, cache->params.startx); compatible = false; } if (dev_params.pixels != cache->params.pixels) { // exposure depends on total number of pixels at least on gl841 dbg.vlog(DBG_io, "incompatible: params.pixels %d vs. %d\n", dev_params.pixels, cache->params.pixels); compatible = false; } if (!compatible) { DBG (DBG_proc, "%s: completed, non compatible cache\n", __func__); return false; } /* a cache entry expires after afetr expiration time for non sheetfed scanners */ /* this is not taken into account when overwriting cache entries */ #ifdef HAVE_SYS_TIME_H if (!for_overwrite && dev->settings.expiration_time >=0) { gettimeofday(&time, nullptr); if ((time.tv_sec - cache->last_calibration > dev->settings.expiration_time*60) && !dev->model->is_sheetfed && (dev->settings.scan_method == ScanMethod::FLATBED)) { DBG (DBG_proc, "%s: expired entry, non compatible cache\n", __func__); return false; } } #endif return true; } /** @brief build lookup table for digital enhancements * Function to build a lookup table (LUT), often used by scanners to implement brightness/contrast/gamma or by backends to speed binarization/thresholding offset and slope inputs are -127 to +127 slope rotates line around central input/output val, 0 makes horizontal line pos zero neg . x . . x . x . . x out . x .xxxxxxxxxxx . x . x . . x ....x....... ............ .......x.... in in in offset moves line vertically, and clamps to output range 0 keeps the line crossing the center of the table high low . xxxxxxxx . . x . out x . x . . x ............ xxxxxxxx.... in in out_min/max provide bounds on output values, useful when building thresholding lut. 0 and 255 are good defaults otherwise. * @param lut pointer where to store the generated lut * @param in_bits number of bits for in values * @param out_bits number of bits of out values * @param out_min minimal out value * @param out_max maximal out value * @param slope slope of the generated data * @param offset offset of the generated data */ void sanei_genesys_load_lut(unsigned char* lut, int in_bits, int out_bits, int out_min, int out_max, int slope, int offset) { DBG_HELPER(dbg); int i, j; double shift, rise; int max_in_val = (1 << in_bits) - 1; int max_out_val = (1 << out_bits) - 1; uint8_t *lut_p8 = lut; uint16_t* lut_p16 = reinterpret_cast(lut); /* slope is converted to rise per unit run: * first [-127,127] to [-.999,.999] * then to [-PI/4,PI/4] then [0,PI/2] * then take the tangent (T.O.A) * then multiply by the normal linear slope * because the table may not be square, i.e. 1024x256*/ auto pi_4 = M_PI / 4.0; rise = std::tan(static_cast(slope) / 128 * pi_4 + pi_4) * max_out_val / max_in_val; /* line must stay vertically centered, so figure * out vertical offset at central input value */ shift = static_cast(max_out_val) / 2 - (rise * max_in_val / 2); /* convert the user offset setting to scale of output * first [-127,127] to [-1,1] * then to [-max_out_val/2,max_out_val/2]*/ shift += static_cast(offset) / 127 * max_out_val / 2; for (i = 0; i <= max_in_val; i++) { j = static_cast(rise * i + shift); /* cap data to required range */ if (j < out_min) { j = out_min; } else if (j > out_max) { j = out_max; } /* copy result according to bit depth */ if (out_bits <= 8) { *lut_p8 = j; lut_p8++; } else { *lut_p16 = j; lut_p16++; } } } } // namespace genesys sane-backends-1.0.29/backend/genesys/image_buffer.h0000666000000000000000000000775513615534521017047 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_IMAGE_BUFFER_H #define BACKEND_GENESYS_IMAGE_BUFFER_H #include "enums.h" #include "row_buffer.h" #include #include namespace genesys { // This class allows reading from row-based source in smaller or larger chunks of data class ImageBuffer { public: using ProducerCallback = std::function; ImageBuffer() {} ImageBuffer(std::size_t size, ProducerCallback producer); std::size_t size() const { return size_; } std::size_t available() const { return size_ - buffer_offset_; } bool get_data(std::size_t size, std::uint8_t* out_data); private: ProducerCallback producer_; std::size_t size_ = 0; std::size_t buffer_offset_ = 0; std::vector buffer_; }; class FakeBufferModel { public: FakeBufferModel() {} void push_step(std::size_t buffer_size, std::size_t row_bytes); std::size_t available_space() const; void simulate_read(std::size_t size); private: std::vector sizes_; std::vector available_sizes_; std::vector row_bytes_; }; // This class is similar to ImageBuffer, but preserves historical peculiarities of buffer handling // in the backend to preserve exact behavior class ImageBufferGenesysUsb { public: using ProducerCallback = std::function; ImageBufferGenesysUsb() {} ImageBufferGenesysUsb(std::size_t total_size, const FakeBufferModel& buffer_model, ProducerCallback producer); std::size_t remaining_size() const { return remaining_size_; } void set_remaining_size(std::size_t bytes) { remaining_size_ = bytes; } std::size_t available() const { return buffer_end_ - buffer_offset_; } bool get_data(std::size_t size, std::uint8_t* out_data); private: std::size_t get_read_size(); std::size_t remaining_size_ = 0; std::size_t buffer_offset_ = 0; std::size_t buffer_end_ = 0; std::vector buffer_; FakeBufferModel buffer_model_; ProducerCallback producer_; }; } // namespace genesys #endif // BACKEND_GENESYS_IMAGE_BUFFER_H sane-backends-1.0.29/backend/genesys/test_settings.h0000666000000000000000000000526113615534521017321 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_TEST_SETTINGS_H #define BACKEND_GENESYS_TEST_SETTINGS_H #include "scanner_interface.h" #include "register_cache.h" #include "test_usb_device.h" #include namespace genesys { using TestCheckpointCallback = std::function; bool is_testing_mode(); void disable_testing_mode(); void enable_testing_mode(std::uint16_t vendor_id, std::uint16_t product_id, TestCheckpointCallback checkpoint_callback); std::uint16_t get_testing_vendor_id(); std::uint16_t get_testing_product_id(); std::string get_testing_device_name(); TestCheckpointCallback get_testing_checkpoint_callback(); } // namespace genesys #endif // BACKEND_GENESYS_TEST_SETTINGS_H sane-backends-1.0.29/backend/genesys/device.cpp0000666000000000000000000002515713615534521016222 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "device.h" #include "command_set.h" #include "low.h" #include "utilities.h" namespace genesys { std::vector MethodResolutions::get_resolutions() const { std::vector ret; std::copy(resolutions_x.begin(), resolutions_x.end(), std::back_inserter(ret)); std::copy(resolutions_y.begin(), resolutions_y.end(), std::back_inserter(ret)); // sort in decreasing order std::sort(ret.begin(), ret.end(), std::greater()); ret.erase(std::unique(ret.begin(), ret.end()), ret.end()); return ret; } const MethodResolutions& Genesys_Model::get_resolution_settings(ScanMethod method) const { for (const auto& res_for_method : resolutions) { for (auto res_method : res_for_method.methods) { if (res_method == method) { return res_for_method; } } } throw SaneException("Could not find resolution settings for method %d", static_cast(method)); } std::vector Genesys_Model::get_resolutions(ScanMethod method) const { return get_resolution_settings(method).get_resolutions(); } Genesys_Device::~Genesys_Device() { clear(); } void Genesys_Device::clear() { read_buffer.clear(); binarize_buffer.clear(); local_buffer.clear(); calib_file.clear(); calibration_cache.clear(); white_average_data.clear(); dark_average_data.clear(); } ImagePipelineNodeBytesSource& Genesys_Device::get_pipeline_source() { return static_cast(pipeline.front()); } bool Genesys_Device::is_head_pos_known(ScanHeadId scan_head) const { switch (scan_head) { case ScanHeadId::PRIMARY: return is_head_pos_primary_known_; case ScanHeadId::SECONDARY: return is_head_pos_secondary_known_; case ScanHeadId::ALL: return is_head_pos_primary_known_ && is_head_pos_secondary_known_; default: throw SaneException("Unknown scan head ID"); } } unsigned Genesys_Device::head_pos(ScanHeadId scan_head) const { switch (scan_head) { case ScanHeadId::PRIMARY: return head_pos_primary_; case ScanHeadId::SECONDARY: return head_pos_secondary_; default: throw SaneException("Unknown scan head ID"); } } void Genesys_Device::set_head_pos_unknown() { is_head_pos_primary_known_ = false; is_head_pos_secondary_known_ = false; } void Genesys_Device::set_head_pos_zero(ScanHeadId scan_head) { if ((scan_head & ScanHeadId::PRIMARY) != ScanHeadId::NONE) { head_pos_primary_ = 0; is_head_pos_primary_known_ = true; } if ((scan_head & ScanHeadId::SECONDARY) != ScanHeadId::NONE) { head_pos_secondary_ = 0; is_head_pos_secondary_known_ = true; } } void Genesys_Device::advance_head_pos_by_session(ScanHeadId scan_head) { int motor_steps = session.params.starty + (session.params.lines * motor.base_ydpi) / session.params.yres; auto direction = has_flag(session.params.flags, ScanFlag::REVERSE) ? Direction::BACKWARD : Direction::FORWARD; advance_head_pos_by_steps(scan_head, direction, motor_steps); } static void advance_pos(unsigned& pos, Direction direction, unsigned offset) { if (direction == Direction::FORWARD) { pos += offset; } else { if (pos < offset) { throw SaneException("Trying to advance head behind the home sensor"); } pos -= offset; } } void Genesys_Device::advance_head_pos_by_steps(ScanHeadId scan_head, Direction direction, unsigned steps) { if ((scan_head & ScanHeadId::PRIMARY) != ScanHeadId::NONE) { if (!is_head_pos_primary_known_) { throw SaneException("Trying to advance head while scanhead position is not known"); } advance_pos(head_pos_primary_, direction, steps); } if ((scan_head & ScanHeadId::SECONDARY) != ScanHeadId::NONE) { if (!is_head_pos_secondary_known_) { throw SaneException("Trying to advance head while scanhead position is not known"); } advance_pos(head_pos_secondary_, direction, steps); } } void print_scan_position(std::ostream& out, const Genesys_Device& dev, ScanHeadId scan_head) { if (dev.is_head_pos_known(scan_head)) { out << dev.head_pos(scan_head); } else { out <<"(unknown)"; } } std::ostream& operator<<(std::ostream& out, const Genesys_Device& dev) { StreamStateSaver state_saver{out}; out << "Genesys_Device{\n" << std::hex << " vendorId: 0x" << dev.vendorId << '\n' << " productId: 0x" << dev.productId << '\n' << std::dec << " usb_mode: " << dev.usb_mode << '\n' << " file_name: " << dev.file_name << '\n' << " calib_file: " << dev.calib_file << '\n' << " force_calibration: " << dev.force_calibration << '\n' << " ignore_offsets: " << dev.ignore_offsets << '\n' << " model: (not printed)\n" << " reg: " << format_indent_braced_list(4, dev.reg) << '\n' << " calib_reg: " << format_indent_braced_list(4, dev.calib_reg) << '\n' << " settings: " << format_indent_braced_list(4, dev.settings) << '\n' << " frontend: " << format_indent_braced_list(4, dev.frontend) << '\n' << " frontend_initial: " << format_indent_braced_list(4, dev.frontend_initial) << '\n' << " frontend_is_init: " << dev.frontend_is_init << '\n' << " gpo.regs: " << format_indent_braced_list(4, dev.gpo.regs) << '\n' << " motor: " << format_indent_braced_list(4, dev.motor) << '\n' << " control[0..6]: " << std::hex << static_cast(dev.control[0]) << ' ' << static_cast(dev.control[1]) << ' ' << static_cast(dev.control[2]) << ' ' << static_cast(dev.control[3]) << ' ' << static_cast(dev.control[4]) << ' ' << static_cast(dev.control[5]) << '\n' << std::dec << " average_size: " << dev.average_size << '\n' << " calib_pixels: " << dev.calib_pixels << '\n' << " calib_lines: " << dev.calib_lines << '\n' << " calib_channels: " << dev.calib_channels << '\n' << " calib_resolution: " << dev.calib_resolution << '\n' << " calib_total_bytes_to_read: " << dev.calib_total_bytes_to_read << '\n' << " calib_session: " << format_indent_braced_list(4, dev.calib_session) << '\n' << " calib_pixels_offset: " << dev.calib_pixels_offset << '\n' << " gamma_override_tables[0].size(): " << dev.gamma_override_tables[0].size() << '\n' << " gamma_override_tables[1].size(): " << dev.gamma_override_tables[1].size() << '\n' << " gamma_override_tables[2].size(): " << dev.gamma_override_tables[2].size() << '\n' << " white_average_data.size(): " << dev.white_average_data.size() << '\n' << " dark_average_data.size(): " << dev.dark_average_data.size() << '\n' << " already_initialized: " << dev.already_initialized << '\n' << " scanhead_position[PRIMARY]: "; print_scan_position(out, dev, ScanHeadId::PRIMARY); out << '\n' << " scanhead_position[SECONDARY]: "; print_scan_position(out, dev, ScanHeadId::SECONDARY); out << '\n' << " read_active: " << dev.read_active << '\n' << " parking: " << dev.parking << '\n' << " document: " << dev.document << '\n' << " read_buffer.size(): " << dev.read_buffer.size() << '\n' << " binarize_buffer.size(): " << dev.binarize_buffer.size() << '\n' << " local_buffer.size(): " << dev.local_buffer.size() << '\n' << " oe_buffer.size(): " << dev.oe_buffer.size() << '\n' << " total_bytes_read: " << dev.total_bytes_read << '\n' << " total_bytes_to_read: " << dev.total_bytes_to_read << '\n' << " session: " << format_indent_braced_list(4, dev.session) << '\n' << " lineart_lut: (not printed)\n" << " calibration_cache: (not printed)\n" << " line_count: " << dev.line_count << '\n' << " segment_order: " << format_indent_braced_list(4, format_vector_unsigned(4, dev.segment_order)) << '\n' << " buffer_image: " << dev.buffer_image << '\n' << " img_buffer.size(): " << dev.img_buffer.size() << '\n' << '}'; return out; } void apply_reg_settings_to_device(Genesys_Device& dev, const GenesysRegisterSettingSet& regs) { for (const auto& reg : regs) { uint8_t val = dev.interface->read_register(reg.address); val = (val & ~reg.mask) | (reg.value & reg.mask); dev.interface->write_register(reg.address, val); } } } // namespace genesys sane-backends-1.0.29/backend/genesys/conv.h0000666000000000000000000000500213615534521015360 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_CONV_H #define BACKEND_GENESYS_CONV_H #include "device.h" #include "sensor.h" #include "genesys.h" namespace genesys { void binarize_line(Genesys_Device* dev, std::uint8_t* src, std::uint8_t* dst, int width); void genesys_gray_lineart(Genesys_Device* dev, std::uint8_t* src_data, std::uint8_t* dst_data, std::size_t pixels, size_t lines, std::uint8_t threshold); void genesys_crop(Genesys_Scanner* s); void genesys_deskew(Genesys_Scanner *s, const Genesys_Sensor& sensor); void genesys_despeck(Genesys_Scanner* s); void genesys_derotate(Genesys_Scanner* s); } // namespace genesys #endif // BACKEND_GENESYS_CONV_H sane-backends-1.0.29/backend/genesys/gl846.h0000666000000000000000000001772713615534521015300 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2012-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "genesys.h" #include "command_set.h" #ifndef BACKEND_GENESYS_GL846_H #define BACKEND_GENESYS_GL846_H namespace genesys { namespace gl846 { typedef struct { GpioId gpio_id; uint8_t r6b; uint8_t r6c; uint8_t r6d; uint8_t r6e; uint8_t r6f; uint8_t ra6; uint8_t ra7; uint8_t ra8; uint8_t ra9; } Gpio_Profile; static Gpio_Profile gpios[]={ { GpioId::IMG101, 0x72, 0x1f, 0xa4, 0x13, 0xa7, 0x11, 0xff, 0x19, 0x05}, { GpioId::PLUSTEK_OPTICBOOK_3800, 0x30, 0x01, 0x80, 0x2d, 0x80, 0x0c, 0x8f, 0x08, 0x04}, { GpioId::UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, }; typedef struct { const char *model; uint8_t dramsel; /* shading data address */ uint8_t rd0; uint8_t rd1; uint8_t rd2; /* scanned data address */ uint8_t rx[24]; } Memory_layout; static Memory_layout layouts[]={ /* Image formula 101 */ { "canon-image-formula-101", 0x8b, 0x0a, 0x1b, 0x00, { /* RED ODD START / RED ODD END */ 0x00, 0xb0, 0x05, 0xe7, /* [0x00b0, 0x05e7] 1336*4000w */ /* RED EVEN START / RED EVEN END */ 0x05, 0xe8, 0x0b, 0x1f, /* [0x05e8, 0x0b1f] */ /* GREEN ODD START / GREEN ODD END */ 0x0b, 0x20, 0x10, 0x57, /* [0x0b20, 0x1057] */ /* GREEN EVEN START / GREEN EVEN END */ 0x10, 0x58, 0x15, 0x8f, /* [0x1058, 0x158f] */ /* BLUE ODD START / BLUE ODD END */ 0x15, 0x90, 0x1a, 0xc7, /* [0x1590,0x1ac7] */ /* BLUE EVEN START / BLUE EVEN END */ 0x1a, 0xc8, 0x1f, 0xff /* [0x1ac8,0x1fff] */ } }, /* OpticBook 3800 */ { "plustek-opticbook-3800", 0x2a, 0x0a, 0x0a, 0x0a, { /* RED ODD START / RED ODD END */ 0x00, 0x68, 0x03, 0x00, /* RED EVEN START / RED EVEN END */ 0x03, 0x01, 0x05, 0x99, /* GREEN ODD START / GREEN ODD END */ 0x05, 0x9a, 0x08, 0x32, /* GREEN EVEN START / GREEN EVEN END */ 0x08, 0x33, 0x0a, 0xcb, /* BLUE ODD START / BLUE ODD END */ 0x0a, 0xcc, 0x0d, 0x64, /* BLUE EVEN START / BLUE EVEN END */ 0x0d, 0x65, 0x0f, 0xfd } }, /* list terminating entry */ { nullptr, 0, 0, 0, 0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} } }; class CommandSetGl846 : public CommandSet { public: ~CommandSetGl846() override = default; bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const override; void init(Genesys_Device* dev) const override; void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const override; void init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const override; void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const override; void set_powersaving(Genesys_Device* dev, int delay) const override; void save_power(Genesys_Device* dev, bool enable) const override; void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, bool start_motor) const override; void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void search_start_position(Genesys_Device* dev) const override; void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const override; SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void wait_for_motor_stop(Genesys_Device* dev) const override; void move_back_home(Genesys_Device* dev, bool wait_until_home) const override; void update_hardware_sensors(struct Genesys_Scanner* s) const override; bool needs_update_home_sensor_gpio() const override { return true; } void update_home_sensor_gpio(Genesys_Device& dev) const override; void load_document(Genesys_Device* dev) const override; void detect_document_end(Genesys_Device* dev) const override; void eject_document(Genesys_Device* dev) const override; void search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const override; void move_to_ta(Genesys_Device* dev) const override; void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const override; ScanSession calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const override; void asic_boot(Genesys_Device* dev, bool cold) const override; }; enum SlopeTable { SCAN_TABLE = 0, // table 1 at 0x4000 BACKTRACK_TABLE = 1, // table 2 at 0x4800 STOP_TABLE = 2, // table 3 at 0x5000 FAST_TABLE = 3, // table 4 at 0x5800 HOME_TABLE = 4, // table 5 at 0x6000 }; } // namespace gl846 } // namespace genesys #endif // BACKEND_GENESYS_GL846_H sane-backends-1.0.29/backend/genesys/tables_gpo.cpp0000666000000000000000000002173113615534521017074 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "low.h" namespace genesys { StaticInit> s_gpo; void genesys_init_gpo_tables() { s_gpo.init(); Genesys_Gpo gpo; gpo.id = GpioId::UMAX; gpo.regs = { { 0x66, 0x11 }, { 0x67, 0x00 }, { 0x68, 0x51 }, { 0x69, 0x20 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::ST12; gpo.regs = { { 0x66, 0x11 }, { 0x67, 0x00 }, { 0x68, 0x51 }, { 0x69, 0x20 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::ST24; gpo.regs = { { 0x66, 0x00 }, { 0x67, 0x00 }, { 0x68, 0x51 }, { 0x69, 0x20 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::MD_5345; // bits 11-12 are for bipolar V-ref input voltage gpo.regs = { { 0x66, 0x30 }, { 0x67, 0x18 }, { 0x68, 0xa0 }, { 0x69, 0x18 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::HP2400; gpo.regs = { { 0x66, 0x30 }, { 0x67, 0x00 }, { 0x68, 0x31 }, { 0x69, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::HP2300; gpo.regs = { { 0x66, 0x00 }, { 0x67, 0x00 }, { 0x68, 0x00 }, { 0x69, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_LIDE_35; gpo.regs = { { 0x6c, 0x02 }, { 0x6d, 0x80 }, { 0x6e, 0xef }, { 0x6f, 0x80 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::XP200; gpo.regs = { { 0x66, 0x30 }, { 0x67, 0x00 }, { 0x68, 0xb0 }, { 0x69, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::HP3670; gpo.regs = { { 0x66, 0x00 }, { 0x67, 0x00 }, { 0x68, 0x00 }, { 0x69, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::XP300; gpo.regs = { { 0x6c, 0x09 }, { 0x6d, 0xc6 }, { 0x6e, 0xbb }, { 0x6f, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::DP665; gpo.regs = { { 0x6c, 0x18 }, { 0x6d, 0x00 }, { 0x6e, 0xbb }, { 0x6f, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::DP685; gpo.regs = { { 0x6c, 0x3f }, { 0x6d, 0x46 }, { 0x6e, 0xfb }, { 0x6f, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_LIDE_200; gpo.regs = { { 0x6c, 0xfb }, // 0xfb when idle , 0xf9/0xe9 (1200) when scanning { 0x6d, 0x20 }, { 0x6e, 0xff }, { 0x6f, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_LIDE_700F; gpo.regs = { { 0x6c, 0xdb }, { 0x6d, 0xff }, { 0x6e, 0xff }, { 0x6f, 0x80 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::KVSS080; gpo.regs = { { 0x6c, 0xf5 }, { 0x6d, 0x20 }, { 0x6e, 0x7e }, { 0x6f, 0xa1 }, { 0xa6, 0x06 }, { 0xa7, 0x0f }, { 0xa8, 0x00 }, { 0xa9, 0x08 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::G4050; gpo.regs = { { 0x6c, 0x20 }, { 0x6d, 0x00 }, { 0x6e, 0xfc }, { 0x6f, 0x00 }, { 0xa6, 0x08 }, { 0xa7, 0x1e }, { 0xa8, 0x3e }, { 0xa9, 0x06 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::HP_N6310; gpo.regs = { { 0x6c, 0xa3 }, { 0x6d, 0x00 }, { 0x6e, 0x7f }, { 0x6f, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_LIDE_110; gpo.regs = { { 0x6c, 0xfb }, { 0x6d, 0x20 }, { 0x6e, 0xff }, { 0x6f, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_LIDE_120; gpo.regs = { { 0x6c, 0xfb }, { 0x6d, 0x20 }, { 0x6e, 0xff }, { 0x6f, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_LIDE_210; gpo.regs = { { 0x6c, 0xfb }, { 0x6d, 0x20 }, { 0x6e, 0xff }, { 0x6f, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::PLUSTEK_OPTICPRO_3600; gpo.regs = { { 0x6c, 0x02 }, { 0x6d, 0x00 }, { 0x6e, 0x1e }, { 0x6f, 0x80 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::PLUSTEK_OPTICFILM_7200I; gpo.regs = { { 0x6c, 0x4c }, { 0x6d, 0x80 }, { 0x6e, 0x4c }, { 0x6f, 0x80 }, { 0xa6, 0x00 }, { 0xa7, 0x07 }, { 0xa8, 0x20 }, { 0xa9, 0x01 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::PLUSTEK_OPTICFILM_7300; gpo.regs = { { 0x6c, 0x4c }, { 0x6d, 0x00 }, { 0x6e, 0x4c }, { 0x6f, 0x80 }, { 0xa6, 0x00 }, { 0xa7, 0x07 }, { 0xa8, 0x20 }, { 0xa9, 0x01 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::PLUSTEK_OPTICFILM_7500I; gpo.regs = { { 0x6c, 0x4c }, { 0x6d, 0x00 }, { 0x6e, 0x4c }, { 0x6f, 0x80 }, { 0xa6, 0x00 }, { 0xa7, 0x07 }, { 0xa8, 0x20 }, { 0xa9, 0x01 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_4400F; gpo.regs = { { 0x6c, 0x01 }, { 0x6d, 0x7f }, { 0x6e, 0xff }, { 0x6f, 0x00 }, { 0xa6, 0x00 }, { 0xa7, 0xff }, { 0xa8, 0x07 }, { 0xa9, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_8400F; gpo.regs = { { 0x6c, 0x9a }, { 0x6d, 0xdf }, { 0x6e, 0xfe }, { 0x6f, 0x60 }, { 0xa6, 0x00 }, { 0xa7, 0x03 }, { 0xa8, 0x00 }, { 0xa9, 0x02 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_8600F; gpo.regs = { { 0x6c, 0x20 }, { 0x6d, 0x7c }, { 0x6e, 0xff }, { 0x6f, 0x00 }, { 0xa6, 0x00 }, { 0xa7, 0xff }, { 0xa8, 0x00 }, { 0xa9, 0x00 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::IMG101; gpo.regs = { { 0x6c, 0x41 }, { 0x6d, 0xa4 }, { 0x6e, 0x13 }, { 0x6f, 0xa7 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::PLUSTEK_OPTICBOOK_3800; gpo.regs = { { 0x6c, 0x41 }, { 0x6d, 0xa4 }, { 0x6e, 0x13 }, { 0x6f, 0xa7 }, }; s_gpo->push_back(gpo); gpo = Genesys_Gpo(); gpo.id = GpioId::CANON_LIDE_80; gpo.regs = { { 0x6c, 0x28 }, { 0x6d, 0x90 }, { 0x6e, 0x75 }, { 0x6f, 0x80 }, }; s_gpo->push_back(gpo); } } // namespace genesys sane-backends-1.0.29/backend/genesys/gl124.cpp0000666000000000000000000022270413615534521015611 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2010-2016 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "gl124.h" #include "gl124_registers.h" #include "test_settings.h" #include namespace genesys { namespace gl124 { /** @brief set all registers to default values . * This function is called only once at the beginning and * fills register startup values for registers reused across scans. * Those that are rarely modified or not modified are written * individually. * @param dev device structure holding register set to initialize */ static void gl124_init_registers (Genesys_Device * dev) { DBG_HELPER(dbg); dev->reg.clear(); // default to LiDE 110 dev->reg.init_reg(0x01, 0xa2); // + REG_0x01_SHDAREA dev->reg.init_reg(0x02, 0x90); dev->reg.init_reg(0x03, 0x50); dev->reg.init_reg(0x04, 0x03); dev->reg.init_reg(0x05, 0x00); if(dev->model->sensor_id == SensorId::CIS_CANON_LIDE_120) { dev->reg.init_reg(0x06, 0x50); dev->reg.init_reg(0x07, 0x00); } else { dev->reg.init_reg(0x03, 0x50 & ~REG_0x03_AVEENB); dev->reg.init_reg(0x06, 0x50 | REG_0x06_GAIN4); } dev->reg.init_reg(0x09, 0x00); dev->reg.init_reg(0x0a, 0xc0); dev->reg.init_reg(0x0b, 0x2a); dev->reg.init_reg(0x0c, 0x12); dev->reg.init_reg(0x11, 0x00); dev->reg.init_reg(0x12, 0x00); dev->reg.init_reg(0x13, 0x0f); dev->reg.init_reg(0x14, 0x00); dev->reg.init_reg(0x15, 0x80); dev->reg.init_reg(0x16, 0x10); // SENSOR_DEF dev->reg.init_reg(0x17, 0x04); // SENSOR_DEF dev->reg.init_reg(0x18, 0x00); // SENSOR_DEF dev->reg.init_reg(0x19, 0x01); // SENSOR_DEF dev->reg.init_reg(0x1a, 0x30); // SENSOR_DEF dev->reg.init_reg(0x1b, 0x00); // SENSOR_DEF dev->reg.init_reg(0x1c, 0x00); // SENSOR_DEF dev->reg.init_reg(0x1d, 0x01); // SENSOR_DEF dev->reg.init_reg(0x1e, 0x10); dev->reg.init_reg(0x1f, 0x00); dev->reg.init_reg(0x20, 0x15); // SENSOR_DEF dev->reg.init_reg(0x21, 0x00); if(dev->model->sensor_id != SensorId::CIS_CANON_LIDE_120) { dev->reg.init_reg(0x22, 0x02); } else { dev->reg.init_reg(0x22, 0x14); } dev->reg.init_reg(0x23, 0x00); dev->reg.init_reg(0x24, 0x00); dev->reg.init_reg(0x25, 0x00); dev->reg.init_reg(0x26, 0x0d); dev->reg.init_reg(0x27, 0x48); dev->reg.init_reg(0x28, 0x00); dev->reg.init_reg(0x29, 0x56); dev->reg.init_reg(0x2a, 0x5e); dev->reg.init_reg(0x2b, 0x02); dev->reg.init_reg(0x2c, 0x02); dev->reg.init_reg(0x2d, 0x58); dev->reg.init_reg(0x3b, 0x00); dev->reg.init_reg(0x3c, 0x00); dev->reg.init_reg(0x3d, 0x00); dev->reg.init_reg(0x3e, 0x00); dev->reg.init_reg(0x3f, 0x02); dev->reg.init_reg(0x40, 0x00); dev->reg.init_reg(0x41, 0x00); dev->reg.init_reg(0x42, 0x00); dev->reg.init_reg(0x43, 0x00); dev->reg.init_reg(0x44, 0x00); dev->reg.init_reg(0x45, 0x00); dev->reg.init_reg(0x46, 0x00); dev->reg.init_reg(0x47, 0x00); dev->reg.init_reg(0x48, 0x00); dev->reg.init_reg(0x49, 0x00); dev->reg.init_reg(0x4f, 0x00); dev->reg.init_reg(0x52, 0x00); // SENSOR_DEF dev->reg.init_reg(0x53, 0x02); // SENSOR_DEF dev->reg.init_reg(0x54, 0x04); // SENSOR_DEF dev->reg.init_reg(0x55, 0x06); // SENSOR_DEF dev->reg.init_reg(0x56, 0x04); // SENSOR_DEF dev->reg.init_reg(0x57, 0x04); // SENSOR_DEF dev->reg.init_reg(0x58, 0x04); // SENSOR_DEF dev->reg.init_reg(0x59, 0x04); // SENSOR_DEF dev->reg.init_reg(0x5a, 0x1a); // SENSOR_DEF dev->reg.init_reg(0x5b, 0x00); // SENSOR_DEF dev->reg.init_reg(0x5c, 0xc0); // SENSOR_DEF dev->reg.init_reg(0x5f, 0x00); dev->reg.init_reg(0x60, 0x02); dev->reg.init_reg(0x61, 0x00); // SENSOR_DEF dev->reg.init_reg(0x62, 0x00); dev->reg.init_reg(0x63, 0x00); dev->reg.init_reg(0x64, 0x00); dev->reg.init_reg(0x65, 0x00); dev->reg.init_reg(0x66, 0x00); dev->reg.init_reg(0x67, 0x00); dev->reg.init_reg(0x68, 0x00); dev->reg.init_reg(0x69, 0x00); dev->reg.init_reg(0x6a, 0x00); dev->reg.init_reg(0x6b, 0x00); dev->reg.init_reg(0x6c, 0x00); dev->reg.init_reg(0x6e, 0x00); dev->reg.init_reg(0x6f, 0x00); if (dev->model->sensor_id != SensorId::CIS_CANON_LIDE_120) { dev->reg.init_reg(0x6d, 0xd0); dev->reg.init_reg(0x71, 0x08); } else { dev->reg.init_reg(0x6d, 0x00); dev->reg.init_reg(0x71, 0x1f); } dev->reg.init_reg(0x70, 0x00); // SENSOR_DEF dev->reg.init_reg(0x71, 0x08); // SENSOR_DEF dev->reg.init_reg(0x72, 0x08); // SENSOR_DEF dev->reg.init_reg(0x73, 0x0a); // SENSOR_DEF // CKxMAP dev->reg.init_reg(0x74, 0x00); // SENSOR_DEF dev->reg.init_reg(0x75, 0x00); // SENSOR_DEF dev->reg.init_reg(0x76, 0x3c); // SENSOR_DEF dev->reg.init_reg(0x77, 0x00); // SENSOR_DEF dev->reg.init_reg(0x78, 0x00); // SENSOR_DEF dev->reg.init_reg(0x79, 0x9f); // SENSOR_DEF dev->reg.init_reg(0x7a, 0x00); // SENSOR_DEF dev->reg.init_reg(0x7b, 0x00); // SENSOR_DEF dev->reg.init_reg(0x7c, 0x55); // SENSOR_DEF dev->reg.init_reg(0x7d, 0x00); dev->reg.init_reg(0x7e, 0x08); dev->reg.init_reg(0x7f, 0x58); if (dev->model->sensor_id != SensorId::CIS_CANON_LIDE_120) { dev->reg.init_reg(0x80, 0x00); dev->reg.init_reg(0x81, 0x14); } else { dev->reg.init_reg(0x80, 0x00); dev->reg.init_reg(0x81, 0x10); } // STRPIXEL dev->reg.init_reg(0x82, 0x00); dev->reg.init_reg(0x83, 0x00); dev->reg.init_reg(0x84, 0x00); // ENDPIXEL dev->reg.init_reg(0x85, 0x00); dev->reg.init_reg(0x86, 0x00); dev->reg.init_reg(0x87, 0x00); dev->reg.init_reg(0x88, 0x00); // SENSOR_DEF dev->reg.init_reg(0x89, 0x65); // SENSOR_DEF dev->reg.init_reg(0x8a, 0x00); dev->reg.init_reg(0x8b, 0x00); dev->reg.init_reg(0x8c, 0x00); dev->reg.init_reg(0x8d, 0x00); dev->reg.init_reg(0x8e, 0x00); dev->reg.init_reg(0x8f, 0x00); dev->reg.init_reg(0x90, 0x00); dev->reg.init_reg(0x91, 0x00); dev->reg.init_reg(0x92, 0x00); dev->reg.init_reg(0x93, 0x00); // SENSOR_DEF dev->reg.init_reg(0x94, 0x14); // SENSOR_DEF dev->reg.init_reg(0x95, 0x30); // SENSOR_DEF dev->reg.init_reg(0x96, 0x00); // SENSOR_DEF dev->reg.init_reg(0x97, 0x90); // SENSOR_DEF dev->reg.init_reg(0x98, 0x01); // SENSOR_DEF dev->reg.init_reg(0x99, 0x1f); dev->reg.init_reg(0x9a, 0x00); dev->reg.init_reg(0x9b, 0x80); dev->reg.init_reg(0x9c, 0x80); dev->reg.init_reg(0x9d, 0x3f); dev->reg.init_reg(0x9e, 0x00); dev->reg.init_reg(0x9f, 0x00); dev->reg.init_reg(0xa0, 0x20); dev->reg.init_reg(0xa1, 0x30); dev->reg.init_reg(0xa2, 0x00); dev->reg.init_reg(0xa3, 0x20); dev->reg.init_reg(0xa4, 0x01); dev->reg.init_reg(0xa5, 0x00); dev->reg.init_reg(0xa6, 0x00); dev->reg.init_reg(0xa7, 0x08); dev->reg.init_reg(0xa8, 0x00); dev->reg.init_reg(0xa9, 0x08); dev->reg.init_reg(0xaa, 0x01); dev->reg.init_reg(0xab, 0x00); dev->reg.init_reg(0xac, 0x00); dev->reg.init_reg(0xad, 0x40); dev->reg.init_reg(0xae, 0x01); dev->reg.init_reg(0xaf, 0x00); dev->reg.init_reg(0xb0, 0x00); dev->reg.init_reg(0xb1, 0x40); dev->reg.init_reg(0xb2, 0x00); dev->reg.init_reg(0xb3, 0x09); dev->reg.init_reg(0xb4, 0x5b); dev->reg.init_reg(0xb5, 0x00); dev->reg.init_reg(0xb6, 0x10); dev->reg.init_reg(0xb7, 0x3f); dev->reg.init_reg(0xb8, 0x00); dev->reg.init_reg(0xbb, 0x00); dev->reg.init_reg(0xbc, 0xff); dev->reg.init_reg(0xbd, 0x00); dev->reg.init_reg(0xbe, 0x07); dev->reg.init_reg(0xc3, 0x00); dev->reg.init_reg(0xc4, 0x00); /* gamma dev->reg.init_reg(0xc5, 0x00); dev->reg.init_reg(0xc6, 0x00); dev->reg.init_reg(0xc7, 0x00); dev->reg.init_reg(0xc8, 0x00); dev->reg.init_reg(0xc9, 0x00); dev->reg.init_reg(0xca, 0x00); dev->reg.init_reg(0xcb, 0x00); dev->reg.init_reg(0xcc, 0x00); dev->reg.init_reg(0xcd, 0x00); dev->reg.init_reg(0xce, 0x00); */ if (dev->model->sensor_id == SensorId::CIS_CANON_LIDE_120) { dev->reg.init_reg(0xc5, 0x20); dev->reg.init_reg(0xc6, 0xeb); dev->reg.init_reg(0xc7, 0x20); dev->reg.init_reg(0xc8, 0xeb); dev->reg.init_reg(0xc9, 0x20); dev->reg.init_reg(0xca, 0xeb); } // memory layout /* dev->reg.init_reg(0xd0, 0x0a); dev->reg.init_reg(0xd1, 0x1f); dev->reg.init_reg(0xd2, 0x34); */ dev->reg.init_reg(0xd3, 0x00); dev->reg.init_reg(0xd4, 0x00); dev->reg.init_reg(0xd5, 0x00); dev->reg.init_reg(0xd6, 0x00); dev->reg.init_reg(0xd7, 0x00); dev->reg.init_reg(0xd8, 0x00); dev->reg.init_reg(0xd9, 0x00); // memory layout /* dev->reg.init_reg(0xe0, 0x00); dev->reg.init_reg(0xe1, 0x48); dev->reg.init_reg(0xe2, 0x15); dev->reg.init_reg(0xe3, 0x90); dev->reg.init_reg(0xe4, 0x15); dev->reg.init_reg(0xe5, 0x91); dev->reg.init_reg(0xe6, 0x2a); dev->reg.init_reg(0xe7, 0xd9); dev->reg.init_reg(0xe8, 0x2a); dev->reg.init_reg(0xe9, 0xad); dev->reg.init_reg(0xea, 0x40); dev->reg.init_reg(0xeb, 0x22); dev->reg.init_reg(0xec, 0x40); dev->reg.init_reg(0xed, 0x23); dev->reg.init_reg(0xee, 0x55); dev->reg.init_reg(0xef, 0x6b); dev->reg.init_reg(0xf0, 0x55); dev->reg.init_reg(0xf1, 0x6c); dev->reg.init_reg(0xf2, 0x6a); dev->reg.init_reg(0xf3, 0xb4); dev->reg.init_reg(0xf4, 0x6a); dev->reg.init_reg(0xf5, 0xb5); dev->reg.init_reg(0xf6, 0x7f); dev->reg.init_reg(0xf7, 0xfd); */ dev->reg.init_reg(0xf8, 0x01); // other value is 0x05 dev->reg.init_reg(0xf9, 0x00); dev->reg.init_reg(0xfa, 0x00); dev->reg.init_reg(0xfb, 0x00); dev->reg.init_reg(0xfc, 0x00); dev->reg.init_reg(0xff, 0x00); // fine tune upon device description const auto& sensor = sanei_genesys_find_sensor_any(dev); sanei_genesys_set_dpihw(dev->reg, sensor, sensor.optical_res); dev->calib_reg = dev->reg; } /**@brief send slope table for motor movement * Send slope_table in machine byte order * @param dev device to send slope table * @param table_nr index of the slope table in ASIC memory * Must be in the [0-4] range. * @param slope_table pointer to 16 bit values array of the slope table * @param steps number of elemnts in the slope table */ static void gl124_send_slope_table(Genesys_Device* dev, int table_nr, const std::vector& slope_table, int steps) { DBG_HELPER_ARGS(dbg, "table_nr = %d, steps = %d", table_nr, steps); int i; char msg[10000]; /* sanity check */ if(table_nr<0 || table_nr>4) { throw SaneException("invalid table number"); } std::vector table(steps * 2); for (i = 0; i < steps; i++) { table[i * 2] = slope_table[i] & 0xff; table[i * 2 + 1] = slope_table[i] >> 8; } if (DBG_LEVEL >= DBG_io) { std::sprintf(msg, "write slope %d (%d)=", table_nr, steps); for (i = 0; i < steps; i++) { std::sprintf(msg + std::strlen(msg), ",%d", slope_table[i]); } DBG (DBG_io, "%s: %s\n", __func__, msg); } if (dev->interface->is_mock()) { dev->interface->record_slope_table(table_nr, slope_table); } // slope table addresses are fixed dev->interface->write_ahb(0x10000000 + 0x4000 * table_nr, steps * 2, table.data()); } /** @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 void gl124_set_ti_fe(Genesys_Device* dev, uint8_t set) { DBG_HELPER(dbg); int i; if (set == AFE_INIT) { DBG(DBG_proc, "%s: setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; } // start writing to DAC dev->interface->write_fe_register(0x00, 0x80); /* write values to analog frontend */ for (uint16_t addr = 0x01; addr < 0x04; addr++) { dev->interface->write_fe_register(addr, dev->frontend.regs.get_value(addr)); } dev->interface->write_fe_register(0x04, 0x00); /* these are not really sign for this AFE */ for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x05 + i, dev->frontend.regs.get_value(0x24 + i)); } if (dev->model->adc_id == AdcId::CANON_LIDE_120) { dev->interface->write_fe_register(0x00, 0x01); } else { dev->interface->write_fe_register(0x00, 0x11); } } // Set values of analog frontend void CommandSetGl124::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const { DBG_HELPER_ARGS(dbg, "%s", set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == AFE_POWER_SAVE ? "powersave" : "huh?"); (void) sensor; uint8_t val; if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; } val = dev->interface->read_register(REG_0x0A); /* route to correct analog FE */ switch ((val & REG_0x0A_SIFSEL) >> REG_0x0AS_SIFSEL) { case 3: gl124_set_ti_fe(dev, set); break; case 0: case 1: case 2: default: throw SaneException("unsupported analog FE 0x%02x", val); } } static void gl124_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const Motor_Profile& motor_profile, unsigned int scan_exposure_time, unsigned scan_yres, unsigned int scan_lines, unsigned int scan_dummy, unsigned int feed_steps, ScanColorMode scan_mode, MotorFlag flags) { DBG_HELPER(dbg); int use_fast_fed; unsigned int lincnt, fast_dpi; unsigned int feedl,dist; uint32_t z1, z2; unsigned yres; unsigned min_speed; unsigned int linesel; DBG(DBG_info, "%s : scan_exposure_time=%d, scan_yres=%d, step_type=%d, scan_lines=%d, " "scan_dummy=%d, feed_steps=%d, scan_mode=%d, flags=%x\n", __func__, scan_exposure_time, scan_yres, static_cast(motor_profile.step_type), scan_lines, scan_dummy, feed_steps, static_cast(scan_mode), static_cast(flags)); /* we never use fast fed since we do manual feed for the scans */ use_fast_fed=0; /* enforce motor minimal scan speed * @TODO extend motor struct for this value */ if (scan_mode == ScanColorMode::COLOR_SINGLE_PASS) { min_speed = 900; } else { switch(dev->model->motor_id) { case MotorId::CANON_LIDE_110: min_speed = 600; break; case MotorId::CANON_LIDE_120: min_speed = 900; break; default: min_speed = 900; break; } } /* compute min_speed and linesel */ if(scan_yres 0 */ if(linesel==0) { linesel=1; yres=scan_yres*2; } } else { yres=scan_yres; linesel=0; } DBG(DBG_io2, "%s: final yres=%d, linesel=%d\n", __func__, yres, linesel); lincnt=scan_lines*(linesel+1); reg->set24(REG_LINCNT, lincnt); DBG (DBG_io, "%s: lincnt=%d\n", __func__, lincnt); /* compute register 02 value */ uint8_t r02 = REG_0x02_NOTHOME; if (use_fast_fed) { r02 |= REG_0x02_FASTFED; } else { r02 &= ~REG_0x02_FASTFED; } if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { r02 |= REG_0x02_AGOHOME; } if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE) || (yres >= sensor.optical_res)) { r02 |= REG_0x02_ACDCDIS; } if (has_flag(flags, MotorFlag::REVERSE)) { r02 |= REG_0x02_MTRREV; } reg->set8(REG_0x02, r02); sanei_genesys_set_motor_power(*reg, true); reg->set16(REG_SCANFED, 4); /* scan and backtracking slope table */ auto scan_table = sanei_genesys_slope_table(dev->model->asic_type, yres, scan_exposure_time, dev->motor.base_ydpi, 1, motor_profile); gl124_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); gl124_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); reg->set16(REG_STEPNO, scan_table.steps_count); /* fast table */ fast_dpi=yres; /* if (scan_mode != ScanColorMode::COLOR_SINGLE_PASS) { fast_dpi*=3; } */ auto fast_table = sanei_genesys_slope_table(dev->model->asic_type, fast_dpi, scan_exposure_time, dev->motor.base_ydpi, 1, motor_profile); gl124_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count); gl124_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); reg->set16(REG_FASTNO, fast_table.steps_count); reg->set16(REG_FSHDEC, fast_table.steps_count); reg->set16(REG_FMOVNO, fast_table.steps_count); /* substract acceleration distance from feedl */ feedl=feed_steps; feedl <<= static_cast(motor_profile.step_type); dist = scan_table.steps_count; if (has_flag(flags, MotorFlag::FEED)) { dist *= 2; } if (use_fast_fed) { dist += fast_table.steps_count * 2; } DBG (DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* get sure we don't use insane value */ if (dist < feedl) { feedl -= dist; } else { feedl = 0; } reg->set24(REG_FEEDL, feedl); DBG (DBG_io, "%s: feedl=%d\n", __func__, feedl); /* doesn't seem to matter that much */ sanei_genesys_calculate_zmod(use_fast_fed, scan_exposure_time, scan_table.table, scan_table.steps_count, feedl, scan_table.steps_count, &z1, &z2); reg->set24(REG_Z1MOD, z1); DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); reg->set24(REG_Z2MOD, z2); DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); /* LINESEL */ reg->set8_mask(REG_0x1D, linesel, REG_0x1D_LINESEL); reg->set8(REG_0xA0, (static_cast(motor_profile.step_type) << REG_0xA0S_STEPSEL) | (static_cast(motor_profile.step_type) << REG_0xA0S_FSTPSEL)); reg->set16(REG_FMOVDEC, fast_table.steps_count); } /** @brief copy sensor specific settings * Set up register set for the given sensor resolution. Values are from the device table * in genesys_devices.c for registers: * [0x16 ... 0x1d] * [0x52 ... 0x5e] * Other come from the specific device sensor table in genesys_gl124.h: * 0x18, 0x20, 0x61, 0x98 and * @param dev device to set up * @param regs register set to modify * @param dpi resolution of the sensor during scan * @param ccd_size_divisor flag for half ccd mode * */ static void gl124_setup_sensor(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs) { DBG_HELPER(dbg); for (const auto& reg : sensor.custom_regs) { regs->set8(reg.address, reg.value); } regs->set24(REG_EXPR, sensor.exposure.red); regs->set24(REG_EXPG, sensor.exposure.green); regs->set24(REG_EXPB, sensor.exposure.blue); dev->segment_order = sensor.segment_order; } /** @brief setup optical related registers * start and pixels are expressed in optical sensor resolution coordinate * space. * @param dev scanner device to use * @param reg registers to set up * @param exposure_time exposure time to use * @param used_res scanning resolution used, may differ from * scan's one * @param start logical start pixel coordinate * @param pixels logical number of pixels to use * @param channels number of color channels (currently 1 or 3) * @param depth bit depth of the scan (1, 8 or 16) * @param ccd_size_divisor whether sensor's timings are such that x coordinates must be halved * @param color_filter color channel to use as gray data * @param flags optical flags (@see ) */ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, unsigned int exposure_time, const ScanSession& session) { DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time); unsigned int dpihw; GenesysRegister *r; uint32_t expmax; // resolution is divided according to ccd_pixels_per_system_pixel unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel(); DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel); // to manage high resolution device while keeping good low resolution scanning speed, we // make hardware dpi vary dpihw = sensor.get_register_hwdpi(session.output_resolution * ccd_pixels_per_system_pixel); DBG(DBG_io2, "%s: dpihw=%d\n", __func__, dpihw); gl124_setup_sensor(dev, sensor, reg); dev->cmd_set->set_fe(dev, sensor, AFE_SET); /* enable shading */ regs_set_optical_off(dev->model->asic_type, *reg); r = sanei_genesys_get_address (reg, REG_0x01); if (has_flag(session.params.flags, ScanFlag::DISABLE_SHADING) || (dev->model->flags & GENESYS_FLAG_NO_CALIBRATION)) { r->value &= ~REG_0x01_DVDSET; } else { r->value |= REG_0x01_DVDSET; } r = sanei_genesys_get_address(reg, REG_0x03); if ((dev->model->sensor_id != SensorId::CIS_CANON_LIDE_120) && (session.params.xres>=600)) { r->value &= ~REG_0x03_AVEENB; DBG (DBG_io, "%s: disabling AVEENB\n", __func__); } else { r->value |= ~REG_0x03_AVEENB; DBG (DBG_io, "%s: enabling AVEENB\n", __func__); } sanei_genesys_set_lamp_power(dev, sensor, *reg, !has_flag(session.params.flags, ScanFlag::DISABLE_LAMP)); // BW threshold dev->interface->write_register(REG_0x114, dev->settings.threshold); dev->interface->write_register(REG_0x115, dev->settings.threshold); /* monochrome / color scan */ r = sanei_genesys_get_address (reg, REG_0x04); switch (session.params.depth) { case 8: r->value &= ~(REG_0x04_LINEART | REG_0x04_BITSET); break; case 16: r->value &= ~REG_0x04_LINEART; r->value |= REG_0x04_BITSET; break; } r->value &= ~REG_0x04_FILTER; if (session.params.channels == 1) { switch (session.params.color_filter) { case ColorFilter::RED: r->value |= 0x10; break; case ColorFilter::BLUE: r->value |= 0x30; break; case ColorFilter::GREEN: r->value |= 0x20; break; default: break; // should not happen } } sanei_genesys_set_dpihw(*reg, sensor, dpihw); if (should_enable_gamma(session, sensor)) { reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB; } else { reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB; } unsigned dpiset_reg = session.output_resolution * ccd_pixels_per_system_pixel * session.ccd_size_divisor; if (sensor.dpiset_override != 0) { dpiset_reg = sensor.dpiset_override; } reg->set16(REG_DPISET, dpiset_reg); DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset_reg); r = sanei_genesys_get_address(reg, REG_0x06); r->value |= REG_0x06_GAIN4; /* CIS scanners can do true gray by setting LEDADD */ /* we set up LEDADD only when asked */ if (dev->model->is_cis) { r = sanei_genesys_get_address (reg, REG_0x60); r->value &= ~REG_0x60_LEDADD; if (session.enable_ledadd) { r->value |= REG_0x60_LEDADD; expmax = reg->get24(REG_EXPR); expmax = std::max(expmax, reg->get24(REG_EXPG)); expmax = std::max(expmax, reg->get24(REG_EXPB)); dev->reg.set24(REG_EXPR, expmax); dev->reg.set24(REG_EXPG, expmax); dev->reg.set24(REG_EXPB, expmax); } /* RGB weighting, REG_TRUER,G and B are to be set */ r = sanei_genesys_get_address (reg, 0x01); r->value &= ~REG_0x01_TRUEGRAY; if (session.enable_ledadd) { r->value |= REG_0x01_TRUEGRAY; dev->interface->write_register(REG_TRUER, 0x80); dev->interface->write_register(REG_TRUEG, 0x80); dev->interface->write_register(REG_TRUEB, 0x80); } } reg->set24(REG_STRPIXEL, session.pixel_startx); reg->set24(REG_ENDPIXEL, session.pixel_endx); dev->line_count = 0; build_image_pipeline(dev, session); // MAXWD is expressed in 2 words unit // BUG: we shouldn't multiply by channels here reg->set24(REG_MAXWD, session.output_line_bytes_raw / session.ccd_size_divisor * session.params.channels); reg->set24(REG_LPERIOD, exposure_time); DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time); reg->set16(REG_DUMMY, sensor.dummy_pixel); } void CommandSetGl124::init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const { DBG_HELPER(dbg); session.assert_computed(); int move; int exposure_time; int dummy = 0; int slope_dpi = 0; /* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */ if (dev->model->is_cis) { slope_dpi = session.params.yres * session.params.channels; } else { slope_dpi = session.params.yres; } if (has_flag(session.params.flags, ScanFlag::FEEDING)) { exposure_time = 2304; } else { exposure_time = sensor.exposure_lperiod; } const auto& motor_profile = sanei_genesys_get_motor_profile(*gl124_motor_profiles, dev->model->motor_id, exposure_time); DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, static_cast(motor_profile.step_type)); /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode */ // now _LOGICAL_ optical values used are known, setup registers gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session); /* add tl_y to base movement */ move = session.params.starty; DBG(DBG_info, "%s: move=%d steps\n", __func__, move); MotorFlag mflags = MotorFlag::NONE; if (has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { mflags |= MotorFlag::DISABLE_BUFFER_FULL_MOVE; } if (has_flag(session.params.flags, ScanFlag::FEEDING)) { mflags |= MotorFlag::FEED; } if (has_flag(session.params.flags, ScanFlag::REVERSE)) { mflags |= MotorFlag::REVERSE; } gl124_init_motor_regs_scan(dev, sensor, reg, motor_profile, exposure_time, slope_dpi, dev->model->is_cis ? session.output_line_count * session.params.channels : session.output_line_count, dummy, move, session.params.scan_mode, mflags); /*** prepares data reordering ***/ dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); dev->read_active = true; dev->session = session; dev->total_bytes_read = 0; dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines; DBG(DBG_info, "%s: total bytes to send to frontend = %zu\n", __func__, dev->total_bytes_to_read); } ScanSession CommandSetGl124::calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const { int start; DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, settings); /* start */ start = static_cast(dev->model->x_offset); start += static_cast(settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = settings.xres; session.params.yres = settings.yres; session.params.startx = start; session.params.starty = 0; // not used session.params.pixels = settings.pixels; session.params.requested_pixels = settings.requested_pixels; session.params.lines = settings.lines; session.params.depth = settings.depth; session.params.channels = settings.get_channels(); session.params.scan_method = settings.scan_method; session.params.scan_mode = settings.scan_mode; session.params.color_filter = settings.color_filter; session.params.flags = ScanFlag::NONE; compute_session(dev, session, sensor); return session; } /** * for fast power saving methods only, like disabling certain amplifiers * @param dev device to use * @param enable true to set inot powersaving * */ void CommandSetGl124::save_power(Genesys_Device* dev, bool enable) const { (void) dev; DBG_HELPER_ARGS(dbg, "enable = %d", enable); } void CommandSetGl124::set_powersaving(Genesys_Device* dev, int delay /* in minutes */) const { DBG_HELPER_ARGS(dbg, "delay = %d", delay); GenesysRegister *r; r = sanei_genesys_get_address(&dev->reg, REG_0x03); r->value &= ~0xf0; if(delay<15) { r->value |= delay; } else { r->value |= 0x0f; } } /** @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 */ void gl124_setup_scan_gpio(Genesys_Device* dev, int resolution) { DBG_HELPER(dbg); uint8_t val = dev->interface->read_register(REG_0x32); /* LiDE 110, 210 and 220 cases */ if(dev->model->gpio_id != GpioId::CANON_LIDE_120) { 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 { /* 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; dev->interface->write_register(REG_0x32, val); } // Send the low-level scan command // todo: is this that useful ? void CommandSetGl124::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, bool start_motor) const { DBG_HELPER(dbg); (void) sensor; (void) reg; // set up GPIO for scan gl124_setup_scan_gpio(dev,dev->settings.yres); // clear scan and feed count dev->interface->write_register(REG_0x0D, REG_0x0D_CLRLNCNT | REG_0x0D_CLRMCNT); // enable scan and motor uint8_t val = dev->interface->read_register(REG_0x01); val |= REG_0x01_SCAN; dev->interface->write_register(REG_0x01, val); scanner_start_action(*dev, start_motor); dev->advance_head_pos_by_session(ScanHeadId::PRIMARY); } // Send the stop scan command void CommandSetGl124::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg, bool check_stop) const { (void) reg; DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop); if (!dev->model->is_sheetfed) { scanner_stop_action(*dev); } } /** 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 */ void CommandSetGl124::move_back_home(Genesys_Device* dev, bool wait_until_home) const { scanner_move_back_home(*dev, wait_until_home); } // Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi // from very top of scanner void CommandSetGl124::search_start_position(Genesys_Device* dev) const { DBG_HELPER(dbg); int size; Genesys_Register_Set local_reg = dev->reg; int pixels = 600; int dpi = 300; /* sets for a 200 lines * 600 pixels */ /* normal scan with no shading */ // FIXME: the current approach of doing search only for one resolution does not work on scanners // whith employ different sensors with potentially different settings. const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, ScanMethod::FLATBED); ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; /*we should give a small offset here~60 steps */ session.params.pixels = 600; session.params.lines = dev->model->search_lines; session.params.depth = 8; session.params.channels = 1; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::GREEN; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::IGNORE_LINE_DISTANCE | ScanFlag::DISABLE_BUFFER_FULL_MOVE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &local_reg, session); // send to scanner dev->interface->write_registers(local_reg); size = pixels * dev->model->search_lines; std::vector data(size); begin_scan(dev, sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_start_position"); end_scan(dev, &local_reg, true); dev->reg = local_reg; return; } wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl124_search_position.pnm", data.data(), 8, 1, pixels, dev->model->search_lines); } end_scan(dev, &local_reg, true); /* update regs to copy ASIC internal state */ dev->reg = local_reg; for (auto& sensor_update : sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) { sanei_genesys_search_reference_point(dev, sensor_update, data.data(), 0, dpi, pixels, dev->model->search_lines); } } // sets up register for coarse gain calibration // todo: check it for scanners using it void CommandSetGl124::init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel(); session.params.lines = 20; session.params.depth = 16; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::FEEDING | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, ®s, session); sanei_genesys_set_motor_power(regs, false); DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres); dev->interface->write_registers(regs); } // init registers for shading calibration shading calibration is done at dpihw void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); int move, resolution, dpihw, factor; /* initial calibration reg values */ regs = dev->reg; dev->calib_channels = 3; dev->calib_lines = dev->model->shading_lines; dpihw = sensor.get_register_hwdpi(dev->settings.xres); if(dpihw>=2400) { dev->calib_lines *= 2; } resolution=dpihw; unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres); resolution /= ccd_size_divisor; dev->calib_lines /= ccd_size_divisor; // reducing just because we reduced the resolution const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, dev->calib_channels, dev->settings.scan_method); dev->calib_resolution = resolution; dev->calib_total_bytes_to_read = 0; factor = calib_sensor.optical_res / resolution; dev->calib_pixels = calib_sensor.sensor_pixels / factor; /* distance to move to reach white target at high resolution */ move=0; if (dev->settings.yres >= 1200) { move = static_cast(dev->model->y_offset_calib_white); move = static_cast((move * (dev->motor.base_ydpi/4)) / MM_PER_INCH); } DBG (DBG_io, "%s: move=%d steps\n", __func__, move); ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = 0; session.params.starty = move; session.params.pixels = dev->calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; session.params.channels = dev->calib_channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = ColorFilter::RED; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::DISABLE_BUFFER_FULL_MOVE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); try { init_regs_for_scan_session(dev, calib_sensor, ®s, session); } catch (...) { catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); }); throw; } sanei_genesys_set_motor_power(regs, false); dev->interface->write_registers(regs); } void CommandSetGl124::wait_for_motor_stop(Genesys_Device* dev) const { DBG_HELPER(dbg); auto status = scanner_read_status(*dev); uint8_t val40 = dev->interface->read_register(REG_0x100); if (!status.is_motor_enabled && (val40 & REG_0x100_MOTMFLG) == 0) { return; } do { dev->interface->sleep_ms(10); status = scanner_read_status(*dev); val40 = dev->interface->read_register(REG_0x100); } while (status.is_motor_enabled ||(val40 & REG_0x100_MOTMFLG)); dev->interface->sleep_ms(50); } /** @brief set up registers for the actual scan */ void CommandSetGl124::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); float move; int move_dpi; float start; debug_dump(DBG_info, dev->settings); /* y (motor) distance to move to reach scanned area */ move_dpi = dev->motor.base_ydpi/4; move = static_cast(dev->model->y_offset); move += static_cast(dev->settings.tl_y); move = static_cast((move * move_dpi) / MM_PER_INCH); DBG (DBG_info, "%s: move=%f steps\n", __func__, move); if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700) { scanner_move(*dev, dev->model->default_method, static_cast(move - 500), Direction::FORWARD); move=500; } DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = static_cast(dev->model->x_offset); start += static_cast(dev->settings.tl_x); start /= sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = static_cast(start); session.params.starty = static_cast(move); session.params.pixels = dev->settings.pixels; session.params.requested_pixels = dev->settings.requested_pixels; session.params.lines = dev->settings.lines; session.params.depth = dev->settings.depth; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::NONE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &dev->reg, session); } /** * Send shading calibration data. The buffer is considered to always hold values * for all the channels. */ void CommandSetGl124::send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, std::uint8_t* data, int size) const { DBG_HELPER_ARGS(dbg, "writing %d bytes of shading data", size); uint32_t addr, length, x, factor, segcnt, pixels, i; uint16_t dpiset,dpihw; uint8_t *ptr, *src; /* logical size of a color as seen by generic code of the frontend */ length = size / 3; std::uint32_t strpixel = dev->session.pixel_startx; std::uint32_t endpixel = dev->session.pixel_endx; segcnt = dev->reg.get24(REG_SEGCNT); if(endpixel==0) { endpixel=segcnt; } /* compute deletion factor */ dpiset = dev->reg.get16(REG_DPISET); dpihw = sensor.get_register_hwdpi(dpiset); factor=dpihw/dpiset; DBG( DBG_io2, "%s: factor=%d\n",__func__,factor); /* turn pixel value into bytes 2x16 bits words */ strpixel*=2*2; /* 2 words of 2 bytes */ endpixel*=2*2; segcnt*=2*2; pixels=endpixel-strpixel; dev->interface->record_key_value("shading_start_pixel", std::to_string(strpixel)); dev->interface->record_key_value("shading_pixels", std::to_string(pixels)); dev->interface->record_key_value("shading_length", std::to_string(length)); dev->interface->record_key_value("shading_factor", std::to_string(factor)); dev->interface->record_key_value("shading_segcnt", std::to_string(segcnt)); dev->interface->record_key_value("shading_segment_count", std::to_string(dev->session.segment_count)); DBG( DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n",__func__,length, length/4); std::vector buffer(pixels * dev->session.segment_count, 0); /* write actual red data */ for(i=0;i<3;i++) { /* copy data to work buffer and process it */ /* coefficent destination */ ptr = buffer.data(); /* iterate on both sensor segment */ for(x=0;xsession.segment_count) { case 1: ptr[0+pixels*0]=src[0+segcnt*0]; ptr[1+pixels*0]=src[1+segcnt*0]; ptr[2+pixels*0]=src[2+segcnt*0]; ptr[3+pixels*0]=src[3+segcnt*0]; break; case 2: ptr[0+pixels*0]=src[0+segcnt*0]; ptr[1+pixels*0]=src[1+segcnt*0]; ptr[2+pixels*0]=src[2+segcnt*0]; ptr[3+pixels*0]=src[3+segcnt*0]; ptr[0+pixels*1]=src[0+segcnt*1]; ptr[1+pixels*1]=src[1+segcnt*1]; ptr[2+pixels*1]=src[2+segcnt*1]; ptr[3+pixels*1]=src[3+segcnt*1]; break; case 4: ptr[0+pixels*0]=src[0+segcnt*0]; ptr[1+pixels*0]=src[1+segcnt*0]; ptr[2+pixels*0]=src[2+segcnt*0]; ptr[3+pixels*0]=src[3+segcnt*0]; ptr[0+pixels*1]=src[0+segcnt*2]; ptr[1+pixels*1]=src[1+segcnt*2]; ptr[2+pixels*1]=src[2+segcnt*2]; ptr[3+pixels*1]=src[3+segcnt*2]; ptr[0+pixels*2]=src[0+segcnt*1]; ptr[1+pixels*2]=src[1+segcnt*1]; ptr[2+pixels*2]=src[2+segcnt*1]; ptr[3+pixels*2]=src[3+segcnt*1]; ptr[0+pixels*3]=src[0+segcnt*3]; ptr[1+pixels*3]=src[1+segcnt*3]; ptr[2+pixels*3]=src[2+segcnt*3]; ptr[3+pixels*3]=src[3+segcnt*3]; break; } /* next shading coefficient */ ptr+=4; } uint8_t val = dev->interface->read_register(0xd0+i); addr = val * 8192 + 0x10000000; dev->interface->write_ahb(addr, pixels * dev->session.segment_count, buffer.data()); } } /** @brief move to calibration area * This functions moves scanning head to calibration area * by doing a 600 dpi scan * @param dev scanner device */ static void move_to_calibration_area(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) { (void) sensor; DBG_HELPER(dbg); int pixels; int size; unsigned resolution = 600; unsigned channels = 3; const auto& move_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); pixels = (move_sensor.sensor_pixels * 600) / move_sensor.optical_res; /* initial calibration reg values */ regs = dev->reg; ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; session.params.lines = 1; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, move_sensor); dev->cmd_set->init_regs_for_scan_session(dev, move_sensor, ®s, session); size = pixels * 3; std::vector line(size); // write registers and scan data dev->interface->write_registers(regs); DBG (DBG_info, "%s: starting line reading\n", __func__); dev->cmd_set->begin_scan(dev, move_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("move_to_calibration_area"); scanner_stop_action(*dev); return; } sanei_genesys_read_data_from_scanner(dev, line.data(), size); // stop scanning scanner_stop_action(*dev); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl124_movetocalarea.pnm", line.data(), 8, 3, pixels, 1); } } /* this function does the led calibration by scanning one line of the calibration area below scanner's top on white strip. -needs working coarse/gain */ SensorExposure CommandSetGl124::led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); int num_pixels; int total_size; int resolution; int dpihw; int i, j; int val; int channels; int avg[3]; int turn; uint16_t exp[3],target; /* move to calibration area */ move_to_calibration_area(dev, sensor, regs); /* offset calibration is always done in 16 bit depth color mode */ channels = 3; dpihw = sensor.get_register_hwdpi(dev->settings.xres); resolution = dpihw; unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres); resolution /= ccd_size_divisor; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); num_pixels = (calib_sensor.sensor_pixels * resolution) / calib_sensor.optical_res; /* initial calibration reg values */ regs = dev->reg; ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); total_size = num_pixels * channels * (session.params.depth / 8) * 1; std::vector line(total_size); // initial loop values and boundaries exp[0] = calib_sensor.exposure.red; exp[1] = calib_sensor.exposure.green; exp[2] = calib_sensor.exposure.blue; target=sensor.gain_white_ref*256; turn = 0; /* no move during led calibration */ sanei_genesys_set_motor_power(regs, false); bool acceptable = false; do { // set up exposure regs.set24(REG_EXPR, exp[0]); regs.set24(REG_EXPG, exp[1]); regs.set24(REG_EXPB, exp[2]); // write registers and scan data dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting line reading\n", __func__); begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("led_calibration"); scanner_stop_action(*dev); return calib_sensor.exposure; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); // stop scanning scanner_stop_action(*dev); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl124_led_%02d.pnm", turn); sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth, channels, num_pixels, 1); } /* compute average */ for (j = 0; j < channels; j++) { avg[j] = 0; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = line[i * 2 + j * 2 * num_pixels + 1] * 256 + line[i * 2 + j * 2 * num_pixels]; else val = line[i * 2 * channels + 2 * j + 1] * 256 + line[i * 2 * channels + 2 * j]; avg[j] += val; } avg[j] /= num_pixels; } DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); /* check if exposure gives average within the boundaries */ acceptable = true; for(i=0;i<3;i++) { /* we accept +- 2% delta from target */ if(abs(avg[i]-target)>target/50) { float prev_weight = 0.5; exp[i] = exp[i] * prev_weight + ((exp[i] * target) / avg[i]) * (1 - prev_weight); acceptable = false; } } turn++; } while (!acceptable && turn < 100); DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]); // set these values as final ones for scan dev->reg.set24(REG_EXPR, exp[0]); dev->reg.set24(REG_EXPG, exp[1]); dev->reg.set24(REG_EXPB, exp[2]); return { exp[0], exp[1], exp[2] }; } /** * average dark pixels of a 8 bits scan */ static int dark_average (uint8_t * data, unsigned int pixels, unsigned int lines, unsigned int channels, unsigned int black) { unsigned int i, j, k, average, count; unsigned int avg[3]; uint8_t val; /* computes average value on black margin */ for (k = 0; k < channels; k++) { avg[k] = 0; count = 0; for (i = 0; i < lines; i++) { for (j = 0; j < black; j++) { val = data[i * channels * pixels + j + k]; avg[k] += val; count++; } } if (count) avg[k] /= count; DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } average = 0; for (i = 0; i < channels; i++) average += avg[i]; average /= channels; DBG(DBG_info, "%s: average = %d\n", __func__, average); return average; } void CommandSetGl124::offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); unsigned channels; int pass = 0, avg, total_size; int topavg, bottomavg, lines; int top, bottom, black_pixels, pixels; // no gain nor offset for TI AFE uint8_t reg0a = dev->interface->read_register(REG_0x0A); if (((reg0a & REG_0x0A_SIFSEL) >> REG_0x0AS_SIFSEL) == 3) { return; } /* offset calibration is always done in color mode */ channels = 3; dev->calib_pixels = sensor.sensor_pixels; lines=1; pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res; black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res; DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); ScanSession session; session.params.xres = sensor.optical_res; session.params.yres = sensor.optical_res; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, ®s, session); sanei_genesys_set_motor_power(regs, false); /* allocate memory for scans */ total_size = pixels * channels * lines * (session.params.depth / 8); std::vector first_line(total_size); std::vector second_line(total_size); /* init gain */ dev->frontend.set_gain(0, 0); dev->frontend.set_gain(1, 0); dev->frontend.set_gain(2, 0); /* scan with no move */ bottom = 10; dev->frontend.set_offset(0, bottom); dev->frontend.set_offset(1, bottom); dev->frontend.set_offset(2, bottom); set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting first line reading\n", __func__); begin_scan(dev, sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("offset_calibration"); return; } sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char title[30]; std::snprintf(title, 30, "gl124_offset%03d.pnm", bottom); sanei_genesys_write_pnm_file(title, first_line.data(), session.params.depth, channels, pixels, lines); } bottomavg = dark_average(first_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_io2, "%s: bottom avg=%d\n", __func__, bottomavg); /* now top value */ top = 255; dev->frontend.set_offset(0, top); dev->frontend.set_offset(1, top); dev->frontend.set_offset(2, top); set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting second line reading\n", __func__); begin_scan(dev, sensor, ®s, true); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); topavg = dark_average(second_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg); /* loop until acceptable level */ while ((pass < 32) && (top - bottom > 1)) { pass++; /* settings for new scan */ dev->frontend.set_offset(0, (top + bottom) / 2); dev->frontend.set_offset(1, (top + bottom) / 2); dev->frontend.set_offset(2, (top + bottom) / 2); // scan with no move set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting second line reading\n", __func__); begin_scan(dev, sensor, ®s, true); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char title[30]; std::snprintf(title, 30, "gl124_offset%03d.pnm", dev->frontend.get_offset(1)); sanei_genesys_write_pnm_file(title, second_line.data(), session.params.depth, channels, pixels, lines); } avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.get_offset(1)); /* compute new boundaries */ if (topavg == avg) { topavg = avg; top = dev->frontend.get_offset(1); } else { bottomavg = avg; bottom = dev->frontend.get_offset(1); } } DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); } /* alternative coarse gain calibration this on uses the settings from offset_calibration and uses only one scanline */ /* with offset and coarse calibration we only want to get our input range into a reasonable shape. the fine calibration of the upper and lower bounds will be done with shading. */ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const { DBG_HELPER_ARGS(dbg, "dpi = %d", dpi); int pixels; int total_size; int i, j, channels; int max[3]; float gain[3],coeff; int val, code, lines; // no gain nor offset for TI AFE uint8_t reg0a = dev->interface->read_register(REG_0x0A); if (((reg0a & REG_0x0A_SIFSEL) >> REG_0x0AS_SIFSEL) == 3) { return; } /* coarse gain calibration is always done in color mode */ channels = 3; if(dev->settings.xressettings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); try { init_regs_for_scan_session(dev, sensor, ®s, session); } catch (...) { catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); }); throw; } sanei_genesys_set_motor_power(regs, false); dev->interface->write_registers(regs); total_size = pixels * channels * (16 / session.params.depth) * lines; std::vector line(total_size); set_fe(dev, sensor, AFE_SET); begin_scan(dev, sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("coarse_gain_calibration"); scanner_stop_action(*dev); move_back_home(dev, true); return; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl124_gain.pnm", line.data(), session.params.depth, channels, pixels, lines); } /* average value on each channel */ for (j = 0; j < channels; j++) { max[j] = 0; for (i = pixels/4; i < (pixels*3/4); i++) { if (dev->model->is_cis) { val = line[i + j * pixels]; } else { val = line[i * channels + j]; } max[j] += val; } max[j] = max[j] / (pixels/2); gain[j] = (static_cast(sensor.gain_white_ref) * coeff) / max[j]; /* turn logical gain value into gain code, checking for overflow */ code = static_cast(283 - 208 / gain[j]); if (code > 255) code = 255; else if (code < 0) code = 0; dev->frontend.set_gain(j, code); DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j], dev->frontend.get_gain(j)); } if (dev->model->is_cis) { uint8_t gain0 = dev->frontend.get_gain(0); if (gain0 > dev->frontend.get_gain(1)) { gain0 = dev->frontend.get_gain(1); } if (gain0 > dev->frontend.get_gain(2)) { gain0 = dev->frontend.get_gain(2); } dev->frontend.set_gain(0, gain0); dev->frontend.set_gain(1, gain0); dev->frontend.set_gain(2, gain0); } if (channels == 1) { dev->frontend.set_gain(0, dev->frontend.get_gain(1)); dev->frontend.set_gain(2, dev->frontend.get_gain(1)); } scanner_stop_action(*dev); move_back_home(dev, true); } // wait for lamp warmup by scanning the same line until difference // between 2 scans is below a threshold void CommandSetGl124::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, int* channels, int* total_size) const { DBG_HELPER(dbg); int num_pixels; *channels=3; *reg = dev->reg; ScanSession session; session.params.xres = sensor.optical_res; session.params.yres = dev->motor.base_ydpi; session.params.startx = sensor.sensor_pixels / 4; session.params.starty = 0; session.params.pixels = sensor.sensor_pixels / 2; session.params.lines = 1; session.params.depth = 8; session.params.channels = *channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, reg, session); num_pixels = session.output_pixels; *total_size = num_pixels * 3 * 1; /* colors * bytes_per_color * scan lines */ sanei_genesys_set_motor_power(*reg, false); dev->interface->write_registers(*reg); } /** @brief default GPIO values * set up GPIO/GPOE for idle state * @param dev device to set up */ static void gl124_init_gpio(Genesys_Device* dev) { DBG_HELPER(dbg); int idx; /* per model GPIO layout */ if (dev->model->model_id == ModelId::CANON_LIDE_110) { idx = 0; } else if (dev->model->model_id == ModelId::CANON_LIDE_120) { idx = 2; } else { /* canon LiDE 210 and 220 case */ idx = 1; } dev->interface->write_register(REG_0x31, gpios[idx].r31); dev->interface->write_register(REG_0x32, gpios[idx].r32); dev->interface->write_register(REG_0x33, gpios[idx].r33); dev->interface->write_register(REG_0x34, gpios[idx].r34); dev->interface->write_register(REG_0x35, gpios[idx].r35); dev->interface->write_register(REG_0x36, gpios[idx].r36); dev->interface->write_register(REG_0x38, gpios[idx].r38); } /** * set memory layout by filling values in dedicated registers */ static void gl124_init_memory_layout(Genesys_Device* dev) { DBG_HELPER(dbg); int idx = 0; /* point to per model memory layout */ if (dev->model->model_id == ModelId::CANON_LIDE_110 || dev->model->model_id == ModelId::CANON_LIDE_120) { idx = 0; } else { /* canon LiDE 210 and 220 case */ idx = 1; } /* setup base address for shading data. */ /* values must be multiplied by 8192=0x4000 to give address on AHB */ /* R-Channel shading bank0 address setting for CIS */ dev->interface->write_register(0xd0, layouts[idx].rd0); /* G-Channel shading bank0 address setting for CIS */ dev->interface->write_register(0xd1, layouts[idx].rd1); /* B-Channel shading bank0 address setting for CIS */ dev->interface->write_register(0xd2, layouts[idx].rd2); /* setup base address for scanned data. */ /* values must be multiplied by 1024*2=0x0800 to give address on AHB */ /* R-Channel ODD image buffer 0x0124->0x92000 */ /* size for each buffer is 0x16d*1k word */ dev->interface->write_register(0xe0, layouts[idx].re0); dev->interface->write_register(0xe1, layouts[idx].re1); /* R-Channel ODD image buffer end-address 0x0291->0x148800 => size=0xB6800*/ dev->interface->write_register(0xe2, layouts[idx].re2); dev->interface->write_register(0xe3, layouts[idx].re3); /* R-Channel EVEN image buffer 0x0292 */ dev->interface->write_register(0xe4, layouts[idx].re4); dev->interface->write_register(0xe5, layouts[idx].re5); /* R-Channel EVEN image buffer end-address 0x03ff*/ dev->interface->write_register(0xe6, layouts[idx].re6); dev->interface->write_register(0xe7, layouts[idx].re7); /* same for green, since CIS, same addresses */ dev->interface->write_register(0xe8, layouts[idx].re0); dev->interface->write_register(0xe9, layouts[idx].re1); dev->interface->write_register(0xea, layouts[idx].re2); dev->interface->write_register(0xeb, layouts[idx].re3); dev->interface->write_register(0xec, layouts[idx].re4); dev->interface->write_register(0xed, layouts[idx].re5); dev->interface->write_register(0xee, layouts[idx].re6); dev->interface->write_register(0xef, layouts[idx].re7); /* same for blue, since CIS, same addresses */ dev->interface->write_register(0xf0, layouts[idx].re0); dev->interface->write_register(0xf1, layouts[idx].re1); dev->interface->write_register(0xf2, layouts[idx].re2); dev->interface->write_register(0xf3, layouts[idx].re3); dev->interface->write_register(0xf4, layouts[idx].re4); dev->interface->write_register(0xf5, layouts[idx].re5); dev->interface->write_register(0xf6, layouts[idx].re6); dev->interface->write_register(0xf7, layouts[idx].re7); } /** * initialize backend and ASIC : registers, motor tables, and gamma tables * then ensure scanner's head is at home */ void CommandSetGl124::init(Genesys_Device* dev) const { DBG_INIT (); DBG_HELPER(dbg); sanei_genesys_asic_init(dev, 0); } /* * * initialize ASIC from power on condition */ void CommandSetGl124::asic_boot(Genesys_Device* dev, bool cold) const { DBG_HELPER(dbg); // reset ASIC in case of cold boot if (cold) { dev->interface->write_register(0x0e, 0x01); dev->interface->write_register(0x0e, 0x00); } // enable GPOE 17 dev->interface->write_register(0x36, 0x01); // set GPIO 17 uint8_t val = dev->interface->read_register(0x33); val |= 0x01; dev->interface->write_register(0x33, val); // test CHKVER val = dev->interface->read_register(REG_0x100); if (val & REG_0x100_CHKVER) { val = dev->interface->read_register(0x00); DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ gl124_init_registers (dev); // Write initial registers dev->interface->write_registers(dev->reg); // tune reg 0B dev->interface->write_register(REG_0x0B, REG_0x0B_30MHZ | REG_0x0B_ENBDRAM | REG_0x0B_64M); dev->reg.remove_reg(0x0b); //set up end access dev->interface->write_0x8c(0x10, 0x0b); dev->interface->write_0x8c(0x13, 0x0e); /* CIS_LINE */ dev->reg.init_reg(0x08, REG_0x08_CIS_LINE); dev->interface->write_register(0x08, dev->reg.find_reg(0x08).value); // setup gpio gl124_init_gpio(dev); // setup internal memory layout gl124_init_memory_layout(dev); } void CommandSetGl124::update_hardware_sensors(Genesys_Scanner* s) const { /* do what is needed to get a new set of events, but try to not loose any of them. */ DBG_HELPER(dbg); uint8_t val = s->dev->interface->read_register(REG_0x31); /* TODO : for the next scanner special case, * add another per scanner button profile struct to avoid growing * hard-coded button mapping here. */ if ((s->dev->model->gpio_id == GpioId::CANON_LIDE_110) || (s->dev->model->gpio_id == GpioId::CANON_LIDE_120)) { s->buttons[BUTTON_SCAN_SW].write((val & 0x01) == 0); s->buttons[BUTTON_FILE_SW].write((val & 0x08) == 0); s->buttons[BUTTON_EMAIL_SW].write((val & 0x04) == 0); s->buttons[BUTTON_COPY_SW].write((val & 0x02) == 0); } else { /* LiDE 210 case */ s->buttons[BUTTON_EXTRA_SW].write((val & 0x01) == 0); s->buttons[BUTTON_SCAN_SW].write((val & 0x02) == 0); s->buttons[BUTTON_COPY_SW].write((val & 0x04) == 0); s->buttons[BUTTON_EMAIL_SW].write((val & 0x08) == 0); s->buttons[BUTTON_FILE_SW].write((val & 0x10) == 0); } } void CommandSetGl124::update_home_sensor_gpio(Genesys_Device& dev) const { DBG_HELPER(dbg); std::uint8_t val = dev.interface->read_register(REG_0x32); val &= ~REG_0x32_GPIO10; dev.interface->write_register(REG_0x32, val); } bool CommandSetGl124::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const { (void) dev; return true; } void CommandSetGl124::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const { sanei_genesys_send_gamma_table(dev, sensor); } void CommandSetGl124::load_document(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl124::detect_document_end(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl124::eject_document(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl124::search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const { (void) dev; (void) sensor; (void) forward; (void) black; throw SaneException("not implemented"); } void CommandSetGl124::move_to_ta(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } std::unique_ptr create_gl124_cmd_set() { return std::unique_ptr(new CommandSetGl124{}); } } // namespace gl124 } // namespace genesys sane-backends-1.0.29/backend/genesys/command_set.h0000666000000000000000000001605113615534521016712 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_COMMAND_SET_H #define BACKEND_GENESYS_COMMAND_SET_H #include "device.h" #include "fwd.h" #include namespace genesys { /** Scanner command set description. This description contains parts which are common to all scanners with the same command set, but may have different optical resolution and other parameters. */ class CommandSet { public: virtual ~CommandSet() = default; virtual bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const = 0; virtual void init(Genesys_Device* dev) const = 0; virtual void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const = 0; virtual void init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const = 0; virtual void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const = 0; virtual void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const = 0; /** Set up registers for a scan. Similar to init_regs_for_scan except that the session is already computed from the session */ virtual void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const= 0; virtual void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, std::uint8_t set) const = 0; virtual void set_powersaving(Genesys_Device* dev, int delay) const = 0; virtual void save_power(Genesys_Device* dev, bool enable) const = 0; virtual void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, bool start_motor) const = 0; virtual void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const = 0; /** * Send gamma tables to ASIC */ virtual void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const = 0; virtual void search_start_position(Genesys_Device* dev) const = 0; virtual void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const = 0; virtual void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const = 0; virtual SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const = 0; virtual void wait_for_motor_stop(Genesys_Device* dev) const = 0; virtual void move_back_home(Genesys_Device* dev, bool wait_until_home) const = 0; // Updates hardware sensor information in Genesys_Scanner.val[]. virtual void update_hardware_sensors(struct Genesys_Scanner* s) const = 0; /** Whether the scanner needs to call update_home_sensor_gpio before reading the status of the home sensor. On some chipsets this is unreliable until update_home_sensor_gpio() is called. */ virtual bool needs_update_home_sensor_gpio() const { return false; } /** Needed on some chipsets before reading the status of the home sensor to make this operation reliable. */ virtual void update_home_sensor_gpio(Genesys_Device& dev) const { (void) dev; } // functions for sheetfed scanners // load document into scanner virtual void load_document(Genesys_Device* dev) const = 0; /** Detects is the scanned document has left scanner. In this case it updates the amount of data to read and set up flags in the dev struct */ virtual void detect_document_end(Genesys_Device* dev) const = 0; /// eject document from scanner virtual void eject_document(Genesys_Device* dev) const = 0; /** * search for an black or white area in forward or reverse * direction */ virtual void search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const = 0; /// move scanning head to transparency adapter virtual void move_to_ta(Genesys_Device* dev) const = 0; /// write shading data calibration to ASIC virtual void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, std::uint8_t* data, int size) const = 0; virtual bool has_send_shading_data() const { return true; } /// calculate an instance of ScanSession for scanning with the given settings virtual ScanSession calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const = 0; /// cold boot init function virtual void asic_boot(Genesys_Device* dev, bool cold) const = 0; }; } // namespace genesys #endif // BACKEND_GENESYS_COMMAND_SET_H sane-backends-1.0.29/backend/genesys/buffer.cpp0000666000000000000000000000563113615534521016227 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "buffer.h" #include #include namespace genesys { void Genesys_Buffer::alloc(std::size_t size) { buffer_.resize(size); avail_ = 0; pos_ = 0; } void Genesys_Buffer::clear() { buffer_.clear(); avail_ = 0; pos_ = 0; } void Genesys_Buffer::reset() { avail_ = 0; pos_ = 0; } std::uint8_t* Genesys_Buffer::get_write_pos(std::size_t size) { if (avail_ + size > buffer_.size()) return nullptr; if (pos_ + avail_ + size > buffer_.size()) { std::memmove(buffer_.data(), buffer_.data() + pos_, avail_); pos_ = 0; } return buffer_.data() + pos_ + avail_; } std::uint8_t* Genesys_Buffer::get_read_pos() { return buffer_.data() + pos_; } void Genesys_Buffer::produce(std::size_t size) { if (size > buffer_.size() - avail_) throw std::runtime_error("buffer size exceeded"); avail_ += size; } void Genesys_Buffer::consume(std::size_t size) { if (size > avail_) throw std::runtime_error("no more data in buffer"); avail_ -= size; pos_ += size; } } // namespace genesys sane-backends-1.0.29/backend/genesys/static_init.cpp0000666000000000000000000000504413615534521017266 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "static_init.h" #include namespace genesys { static std::unique_ptr>> s_functions_run_at_backend_exit; void add_function_to_run_at_backend_exit(const std::function& function) { if (!s_functions_run_at_backend_exit) s_functions_run_at_backend_exit.reset(new std::vector>()); s_functions_run_at_backend_exit->push_back(std::move(function)); } void run_functions_at_backend_exit() { for (auto it = s_functions_run_at_backend_exit->rbegin(); it != s_functions_run_at_backend_exit->rend(); ++it) { (*it)(); } s_functions_run_at_backend_exit.reset(); } } // namespace genesys sane-backends-1.0.29/backend/genesys/enums.cpp0000666000000000000000000001117013615534521016100 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "enums.h" #include "genesys.h" #include namespace genesys { const char* scan_method_to_option_string(ScanMethod method) { switch (method) { case ScanMethod::FLATBED: return STR_FLATBED; case ScanMethod::TRANSPARENCY: return STR_TRANSPARENCY_ADAPTER; case ScanMethod::TRANSPARENCY_INFRARED: return STR_TRANSPARENCY_ADAPTER_INFRARED; } throw SaneException("Unknown scan method %d", static_cast(method)); } ScanMethod option_string_to_scan_method(const std::string& str) { if (str == STR_FLATBED) { return ScanMethod::FLATBED; } else if (str == STR_TRANSPARENCY_ADAPTER) { return ScanMethod::TRANSPARENCY; } else if (str == STR_TRANSPARENCY_ADAPTER_INFRARED) { return ScanMethod::TRANSPARENCY_INFRARED; } throw SaneException("Unknown scan method option %s", str.c_str()); } const char* scan_color_mode_to_option_string(ScanColorMode mode) { switch (mode) { case ScanColorMode::COLOR_SINGLE_PASS: return SANE_VALUE_SCAN_MODE_COLOR; case ScanColorMode::GRAY: return SANE_VALUE_SCAN_MODE_GRAY; case ScanColorMode::HALFTONE: return SANE_VALUE_SCAN_MODE_HALFTONE; case ScanColorMode::LINEART: return SANE_VALUE_SCAN_MODE_LINEART; } throw SaneException("Unknown scan mode %d", static_cast(mode)); } ScanColorMode option_string_to_scan_color_mode(const std::string& str) { if (str == SANE_VALUE_SCAN_MODE_COLOR) { return ScanColorMode::COLOR_SINGLE_PASS; } else if (str == SANE_VALUE_SCAN_MODE_GRAY) { return ScanColorMode::GRAY; } else if (str == SANE_VALUE_SCAN_MODE_HALFTONE) { return ScanColorMode::HALFTONE; } else if (str == SANE_VALUE_SCAN_MODE_LINEART) { return ScanColorMode::LINEART; } throw SaneException("Unknown scan color mode %s", str.c_str()); } std::ostream& operator<<(std::ostream& out, ColorFilter mode) { switch (mode) { case ColorFilter::RED: out << "RED"; break; case ColorFilter::GREEN: out << "GREEN"; break; case ColorFilter::BLUE: out << "BLUE"; break; case ColorFilter::NONE: out << "NONE"; break; default: out << static_cast(mode); break; } return out; } std::ostream& operator<<(std::ostream& out, StepType type) { switch (type) { case StepType::FULL: out << "1/1"; break; case StepType::HALF: out << "1/2"; break; case StepType::QUARTER: out << "1/4"; break; case StepType::EIGHTH: out << "1/8"; break; default: out << static_cast(type); break; } return out; } std::ostream& operator<<(std::ostream& out, ScanFlag flags) { StreamStateSaver state_saver{out}; out << "0x" << std::hex << static_cast(flags); return out; } } // namespace genesys sane-backends-1.0.29/backend/genesys/error.cpp0000666000000000000000000001434113615534521016105 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "error.h" #include namespace genesys { extern "C" void sanei_debug_msg(int level, int max_level, const char *be, const char *fmt, std::va_list ap); #if (defined(__GNUC__) || defined(__CLANG__)) && (defined(__linux__) || defined(__APPLE__)) extern "C" char* __cxa_get_globals(); #endif static unsigned num_uncaught_exceptions() { #if __cplusplus >= 201703L int count = std::uncaught_exceptions(); return count >= 0 ? count : 0; #elif (defined(__GNUC__) || defined(__CLANG__)) && (defined(__linux__) || defined(__APPLE__)) // the format of the __cxa_eh_globals struct is enshrined into the Itanium C++ ABI and it's // very unlikely we'll get issues referencing it directly char* cxa_eh_globals_ptr = __cxa_get_globals(); return *reinterpret_cast(cxa_eh_globals_ptr + sizeof(void*)); #else return std::uncaught_exception() ? 1 : 0; #endif } SaneException::SaneException(SANE_Status status) : status_(status) { set_msg(); } SaneException::SaneException(SANE_Status status, const char* format, ...) : status_(status) { std::va_list args; va_start(args, format); set_msg(format, args); va_end(args); } SaneException::SaneException(const char* format, ...) : status_(SANE_STATUS_INVAL) { std::va_list args; va_start(args, format); set_msg(format, args); va_end(args); } SANE_Status SaneException::status() const { return status_; } const char* SaneException::what() const noexcept { return msg_.c_str(); } void SaneException::set_msg() { const char* status_msg = sane_strstatus(status_); std::size_t status_msg_len = std::strlen(status_msg); msg_.reserve(status_msg_len); msg_ = status_msg; } void SaneException::set_msg(const char* format, std::va_list vlist) { const char* status_msg = sane_strstatus(status_); std::size_t status_msg_len = std::strlen(status_msg); std::va_list vlist2; va_copy(vlist2, vlist); int msg_len = std::vsnprintf(nullptr, 0, format, vlist2); va_end(vlist2); if (msg_len < 0) { const char* formatting_error_msg = "(error formatting arguments)"; msg_.reserve(std::strlen(formatting_error_msg) + 3 + status_msg_len); msg_ = formatting_error_msg; msg_ += " : "; msg_ += status_msg; return; } msg_.reserve(msg_len + status_msg_len + 3); msg_.resize(msg_len + 1, ' '); std::vsnprintf(&msg_[0], msg_len + 1, format, vlist); msg_.resize(msg_len, ' '); msg_ += " : "; msg_ += status_msg; } DebugMessageHelper::DebugMessageHelper(const char* func) { func_ = func; num_exceptions_on_enter_ = num_uncaught_exceptions(); msg_[0] = '\0'; DBG(DBG_proc, "%s: start\n", func_); } DebugMessageHelper::DebugMessageHelper(const char* func, const char* format, ...) { func_ = func; num_exceptions_on_enter_ = num_uncaught_exceptions(); msg_[0] = '\0'; DBG(DBG_proc, "%s: start\n", func_); DBG(DBG_proc, "%s: ", func_); std::va_list args; va_start(args, format); sanei_debug_msg(DBG_proc, DBG_LEVEL, STRINGIFY(BACKEND_NAME), format, args); va_end(args); DBG(DBG_proc, "\n"); } DebugMessageHelper::~DebugMessageHelper() { if (num_exceptions_on_enter_ < num_uncaught_exceptions()) { if (msg_[0] != '\0') { DBG(DBG_error, "%s: failed during %s\n", func_, msg_); } else { DBG(DBG_error, "%s: failed\n", func_); } } else { DBG(DBG_proc, "%s: completed\n", func_); } } void DebugMessageHelper::vstatus(const char* format, ...) { std::va_list args; va_start(args, format); std::vsnprintf(msg_, MAX_BUF_SIZE, format, args); va_end(args); } void DebugMessageHelper::log(unsigned level, const char* msg) { DBG(level, "%s: %s\n", func_, msg); } void DebugMessageHelper::vlog(unsigned level, const char* format, ...) { std::string msg; std::va_list args; va_start(args, format); int msg_len = std::vsnprintf(nullptr, 0, format, args); va_end(args); if (msg_len < 0) { DBG(level, "%s: error formatting error message: %s\n", func_, format); return; } msg.resize(msg_len + 1, ' '); va_start(args, format); std::vsnprintf(&msg.front(), msg.size(), format, args); va_end(args); msg.resize(msg_len, ' '); // strip the null character DBG(level, "%s: %s\n", func_, msg.c_str()); } } // namespace genesys sane-backends-1.0.29/backend/genesys/gl841.cpp0000666000000000000000000040203713615534521015616 00000000000000/* sane - Scanner Access Now Easy. 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) 2005 Philipp Schmid Copyright (C) 2005-2009 Pierre Willenbrock Copyright (C) 2006 Laurent Charpentier Copyright (C) 2010 Chris Berry and Michael Rickmann for Plustek Opticbook 3600 support 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "gl841.h" #include "gl841_registers.h" #include "test_settings.h" #include namespace genesys { namespace gl841 { static int gl841_exposure_time(Genesys_Device *dev, const Genesys_Sensor& sensor, float slope_dpi, StepType scan_step_type, int start, int used_pixels); /** copy sensor specific settings */ /* *dev : device infos *regs : registers to be set extended : do extended set up ccd_size_divisor: set up for half ccd resolution all registers 08-0B, 10-1D, 52-59 are set up. They shouldn't appear anywhere else but in register_ini Responsible for signals to CCD/CIS: CCD_CK1X (CK1INV(0x16),CKDIS(0x16),CKTOGGLE(0x18),CKDELAY(0x18),MANUAL1(0x1A),CK1MTGL(0x1C),CK1LOW(0x1D),CK1MAP(0x74,0x75,0x76),CK1NEG(0x7D)) CCD_CK2X (CK2INV(0x16),CKDIS(0x16),CKTOGGLE(0x18),CKDELAY(0x18),MANUAL1(0x1A),CK1LOW(0x1D),CK1NEG(0x7D)) CCD_CK3X (MANUAL3(0x1A),CK3INV(0x1A),CK3MTGL(0x1C),CK3LOW(0x1D),CK3MAP(0x77,0x78,0x79),CK3NEG(0x7D)) CCD_CK4X (MANUAL3(0x1A),CK4INV(0x1A),CK4MTGL(0x1C),CK4LOW(0x1D),CK4MAP(0x7A,0x7B,0x7C),CK4NEG(0x7D)) CCD_CPX (CTRLHI(0x16),CTRLINV(0x16),CTRLDIS(0x16),CPH(0x72),CPL(0x73),CPNEG(0x7D)) CCD_RSX (CTRLHI(0x16),CTRLINV(0x16),CTRLDIS(0x16),RSH(0x70),RSL(0x71),RSNEG(0x7D)) CCD_TGX (TGINV(0x16),TGMODE(0x17),TGW(0x17),EXPR(0x10,0x11),TGSHLD(0x1D)) CCD_TGG (TGINV(0x16),TGMODE(0x17),TGW(0x17),EXPG(0x12,0x13),TGSHLD(0x1D)) CCD_TGB (TGINV(0x16),TGMODE(0x17),TGW(0x17),EXPB(0x14,0x15),TGSHLD(0x1D)) LAMP_SW (EXPR(0x10,0x11),XPA_SEL(0x03),LAMP_PWR(0x03),LAMPTIM(0x03),MTLLAMP(0x04),LAMPPWM(0x29)) XPA_SW (EXPG(0x12,0x13),XPA_SEL(0x03),LAMP_PWR(0x03),LAMPTIM(0x03),MTLLAMP(0x04),LAMPPWM(0x29)) LAMP_B (EXPB(0x14,0x15),LAMP_PWR(0x03)) other registers: CISSET(0x01),CNSET(0x18),DCKSEL(0x18),SCANMOD(0x18),EXPDMY(0x19),LINECLP(0x1A),CKAREA(0x1C),TGTIME(0x1C),LINESEL(0x1E),DUMMY(0x34) Responsible for signals to AFE: VSMP (VSMP(0x58),VSMPW(0x58)) BSMP (BSMP(0x59),BSMPW(0x59)) other register settings depending on this: RHI(0x52),RLOW(0x53),GHI(0x54),GLOW(0x55),BHI(0x56),BLOW(0x57), */ static void sanei_gl841_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys_Register_Set * regs, bool extended, unsigned ccd_size_divisor) { DBG(DBG_proc, "%s\n", __func__); // that one is tricky at least for (uint16_t addr = 0x08; addr <= 0x0b; ++addr) { regs->set8(0x70 + addr - 0x08, sensor.custom_regs.get_value(addr)); } // ignore registers in range [0x10..0x16) for (uint16_t addr = 0x16; addr < 0x1e; ++addr) { regs->set8(addr, sensor.custom_regs.get_value(addr)); } // ignore registers in range [0x5b..0x5e] for (uint16_t addr = 0x52; addr < 0x52 + 9; ++addr) { regs->set8(addr, sensor.custom_regs.get_value(addr)); } /* don't go any further if no extended setup */ if (!extended) return; /* todo : add more CCD types if needed */ /* we might want to expand the Sensor struct to have these 2 kind of settings */ if (dev->model->sensor_id == SensorId::CCD_5345) { if (ccd_size_divisor > 1) { GenesysRegister* r; /* settings for CCD used at half is max resolution */ r = sanei_genesys_get_address (regs, 0x70); r->value = 0x00; r = sanei_genesys_get_address (regs, 0x71); r->value = 0x05; r = sanei_genesys_get_address (regs, 0x72); r->value = 0x06; r = sanei_genesys_get_address (regs, 0x73); r->value = 0x08; r = sanei_genesys_get_address (regs, 0x18); r->value = 0x28; r = sanei_genesys_get_address (regs, 0x58); r->value = 0x80 | (r->value & 0x03); /* VSMP=16 */ } else { GenesysRegister* r; /* swap latch times */ r = sanei_genesys_get_address (regs, 0x18); r->value = 0x30; regs->set8(0x52, sensor.custom_regs.get_value(0x55)); regs->set8(0x53, sensor.custom_regs.get_value(0x56)); regs->set8(0x54, sensor.custom_regs.get_value(0x57)); regs->set8(0x55, sensor.custom_regs.get_value(0x52)); regs->set8(0x56, sensor.custom_regs.get_value(0x53)); regs->set8(0x57, sensor.custom_regs.get_value(0x54)); r = sanei_genesys_get_address (regs, 0x58); r->value = 0x20 | (r->value & 0x03); /* VSMP=4 */ } return; } if (dev->model->sensor_id == SensorId::CCD_HP2300) { /* settings for CCD used at half is max resolution */ GenesysRegister* r; if (ccd_size_divisor > 1) { r = sanei_genesys_get_address (regs, 0x70); r->value = 0x16; r = sanei_genesys_get_address (regs, 0x71); r->value = 0x00; r = sanei_genesys_get_address (regs, 0x72); r->value = 0x01; r = sanei_genesys_get_address (regs, 0x73); r->value = 0x03; /* manual clock programming */ r = sanei_genesys_get_address (regs, 0x1d); r->value |= 0x80; } else { r = sanei_genesys_get_address (regs, 0x70); r->value = 1; r = sanei_genesys_get_address (regs, 0x71); r->value = 3; r = sanei_genesys_get_address (regs, 0x72); r->value = 4; r = sanei_genesys_get_address (regs, 0x73); r->value = 6; } r = sanei_genesys_get_address (regs, 0x58); r->value = 0x80 | (r->value & 0x03); /* VSMP=16 */ return; } } /* * Set all registers LiDE 80 to default values * (function called only once at the beginning) * we are doing a special case to ease development */ static void gl841_init_lide80 (Genesys_Device * dev) { dev->reg.init_reg(0x01, 0x82); // 0x02 = SHDAREA and no CISSET ! dev->reg.init_reg(0x02, 0x10); dev->reg.init_reg(0x03, 0x50); dev->reg.init_reg(0x04, 0x02); dev->reg.init_reg(0x05, 0x4c); // 1200 DPI dev->reg.init_reg(0x06, 0x38); // 0x38 scanmod=1, pwrbit, GAIN4 dev->reg.init_reg(0x07, 0x00); dev->reg.init_reg(0x08, 0x00); dev->reg.init_reg(0x09, 0x11); dev->reg.init_reg(0x0a, 0x00); dev->reg.init_reg(0x10, 0x40); dev->reg.init_reg(0x11, 0x00); dev->reg.init_reg(0x12, 0x40); dev->reg.init_reg(0x13, 0x00); dev->reg.init_reg(0x14, 0x40); dev->reg.init_reg(0x15, 0x00); dev->reg.init_reg(0x16, 0x00); dev->reg.init_reg(0x17, 0x01); dev->reg.init_reg(0x18, 0x00); dev->reg.init_reg(0x19, 0x06); dev->reg.init_reg(0x1a, 0x00); dev->reg.init_reg(0x1b, 0x00); dev->reg.init_reg(0x1c, 0x00); dev->reg.init_reg(0x1d, 0x04); dev->reg.init_reg(0x1e, 0x10); dev->reg.init_reg(0x1f, 0x04); dev->reg.init_reg(0x20, 0x02); dev->reg.init_reg(0x21, 0x10); dev->reg.init_reg(0x22, 0x20); dev->reg.init_reg(0x23, 0x20); dev->reg.init_reg(0x24, 0x10); dev->reg.init_reg(0x25, 0x00); dev->reg.init_reg(0x26, 0x00); dev->reg.init_reg(0x27, 0x00); dev->reg.init_reg(0x29, 0xff); const auto& sensor = sanei_genesys_find_sensor_any(dev); dev->reg.init_reg(0x2c, sensor.optical_res>>8); dev->reg.init_reg(0x2d, sensor.optical_res & 0xff); dev->reg.init_reg(0x2e, 0x80); dev->reg.init_reg(0x2f, 0x80); dev->reg.init_reg(0x30, 0x00); dev->reg.init_reg(0x31, 0x10); dev->reg.init_reg(0x32, 0x15); dev->reg.init_reg(0x33, 0x0e); dev->reg.init_reg(0x34, 0x40); dev->reg.init_reg(0x35, 0x00); dev->reg.init_reg(0x36, 0x2a); dev->reg.init_reg(0x37, 0x30); dev->reg.init_reg(0x38, 0x2a); dev->reg.init_reg(0x39, 0xf8); dev->reg.init_reg(0x3d, 0x00); dev->reg.init_reg(0x3e, 0x00); dev->reg.init_reg(0x3f, 0x00); dev->reg.init_reg(0x52, 0x03); dev->reg.init_reg(0x53, 0x07); dev->reg.init_reg(0x54, 0x00); dev->reg.init_reg(0x55, 0x00); dev->reg.init_reg(0x56, 0x00); dev->reg.init_reg(0x57, 0x00); dev->reg.init_reg(0x58, 0x29); dev->reg.init_reg(0x59, 0x69); dev->reg.init_reg(0x5a, 0x55); dev->reg.init_reg(0x5d, 0x20); dev->reg.init_reg(0x5e, 0x41); dev->reg.init_reg(0x5f, 0x40); dev->reg.init_reg(0x60, 0x00); dev->reg.init_reg(0x61, 0x00); dev->reg.init_reg(0x62, 0x00); dev->reg.init_reg(0x63, 0x00); dev->reg.init_reg(0x64, 0x00); dev->reg.init_reg(0x65, 0x00); dev->reg.init_reg(0x66, 0x00); dev->reg.init_reg(0x67, 0x40); dev->reg.init_reg(0x68, 0x40); dev->reg.init_reg(0x69, 0x20); dev->reg.init_reg(0x6a, 0x20); dev->reg.init_reg(0x6c, 0x00); dev->reg.init_reg(0x6d, 0x00); dev->reg.init_reg(0x6e, 0x00); dev->reg.init_reg(0x6f, 0x00); dev->reg.init_reg(0x70, 0x00); dev->reg.init_reg(0x71, 0x05); dev->reg.init_reg(0x72, 0x07); dev->reg.init_reg(0x73, 0x09); dev->reg.init_reg(0x74, 0x00); dev->reg.init_reg(0x75, 0x01); dev->reg.init_reg(0x76, 0xff); dev->reg.init_reg(0x77, 0x00); dev->reg.init_reg(0x78, 0x0f); dev->reg.init_reg(0x79, 0xf0); dev->reg.init_reg(0x7a, 0xf0); dev->reg.init_reg(0x7b, 0x00); dev->reg.init_reg(0x7c, 0x1e); dev->reg.init_reg(0x7d, 0x11); dev->reg.init_reg(0x7e, 0x00); dev->reg.init_reg(0x7f, 0x50); dev->reg.init_reg(0x80, 0x00); dev->reg.init_reg(0x81, 0x00); dev->reg.init_reg(0x82, 0x0f); dev->reg.init_reg(0x83, 0x00); dev->reg.init_reg(0x84, 0x0e); dev->reg.init_reg(0x85, 0x00); dev->reg.init_reg(0x86, 0x0d); dev->reg.init_reg(0x87, 0x02); dev->reg.init_reg(0x88, 0x00); dev->reg.init_reg(0x89, 0x00); for (const auto& reg : dev->gpo.regs) { dev->reg.set8(reg.address, reg.value); } // specific scanner settings, clock and gpio first // FIXME: remove the dummy reads as we don't use the values if (!is_testing_mode()) { dev->interface->read_register(REG_0x6B); } dev->interface->write_register(REG_0x6B, 0x0c); dev->interface->write_register(0x06, 0x10); dev->interface->write_register(REG_0x6E, 0x6d); dev->interface->write_register(REG_0x6F, 0x80); dev->interface->write_register(REG_0x6B, 0x0e); if (!is_testing_mode()) { dev->interface->read_register(REG_0x6C); } dev->interface->write_register(REG_0x6C, 0x00); if (!is_testing_mode()) { dev->interface->read_register(REG_0x6D); } dev->interface->write_register(REG_0x6D, 0x8f); if (!is_testing_mode()) { dev->interface->read_register(REG_0x6B); } dev->interface->write_register(REG_0x6B, 0x0e); if (!is_testing_mode()) { dev->interface->read_register(REG_0x6B); } dev->interface->write_register(REG_0x6B, 0x0e); if (!is_testing_mode()) { dev->interface->read_register(REG_0x6B); } dev->interface->write_register(REG_0x6B, 0x0a); if (!is_testing_mode()) { dev->interface->read_register(REG_0x6B); } dev->interface->write_register(REG_0x6B, 0x02); if (!is_testing_mode()) { dev->interface->read_register(REG_0x6B); } dev->interface->write_register(REG_0x6B, 0x06); dev->interface->write_0x8c(0x10, 0x94); dev->interface->write_register(0x09, 0x10); // FIXME: the following code originally changed 0x6b, but due to bug the 0x6c register was // effectively changed. The current behavior matches the old code, but should probably be fixed. dev->reg.find_reg(0x6c).value |= REG_0x6B_GPO18; dev->reg.find_reg(0x6c).value &= ~REG_0x6B_GPO17; sanei_gl841_setup_sensor(dev, sensor, &dev->reg, 0, 1); } /* * Set all registers to default values * (function called only once at the beginning) */ static void gl841_init_registers (Genesys_Device * dev) { int addr; DBG(DBG_proc, "%s\n", __func__); dev->reg.clear(); if (dev->model->model_id == ModelId::CANON_LIDE_80) { gl841_init_lide80(dev); return ; } for (addr = 1; addr <= 0x0a; addr++) { dev->reg.init_reg(addr, 0); } for (addr = 0x10; addr <= 0x27; addr++) { dev->reg.init_reg(addr, 0); } dev->reg.init_reg(0x29, 0); for (addr = 0x2c; addr <= 0x39; addr++) dev->reg.init_reg(addr, 0); for (addr = 0x3d; addr <= 0x3f; addr++) dev->reg.init_reg(addr, 0); for (addr = 0x52; addr <= 0x5a; addr++) dev->reg.init_reg(addr, 0); for (addr = 0x5d; addr <= 0x87; addr++) dev->reg.init_reg(addr, 0); dev->reg.find_reg(0x01).value = 0x20; /* (enable shading), CCD, color, 1M */ if (dev->model->is_cis) { dev->reg.find_reg(0x01).value |= REG_0x01_CISSET; } else { dev->reg.find_reg(0x01).value &= ~REG_0x01_CISSET; } dev->reg.find_reg(0x02).value = 0x30 /*0x38 */ ; /* auto home, one-table-move, full step */ dev->reg.find_reg(0x02).value |= REG_0x02_AGOHOME; sanei_genesys_set_motor_power(dev->reg, true); dev->reg.find_reg(0x02).value |= REG_0x02_FASTFED; dev->reg.find_reg(0x03).value = 0x1f /*0x17 */ ; /* lamp on */ dev->reg.find_reg(0x03).value |= REG_0x03_AVEENB; if (dev->model->sensor_id == SensorId::CCD_PLUSTEK_OPTICPRO_3600) { // AD front end dev->reg.find_reg(0x04).value = (2 << REG_0x04S_AFEMOD) | 0x02; } else /* Wolfson front end */ { dev->reg.find_reg(0x04).value |= 1 << REG_0x04S_AFEMOD; } const auto& sensor = sanei_genesys_find_sensor_any(dev); dev->reg.find_reg(0x05).value = 0x00; /* disable gamma, 24 clocks/pixel */ unsigned dpihw = 0; if (sensor.sensor_pixels < 0x1500) { dpihw = 600; } else if (sensor.sensor_pixels < 0x2a80) { dpihw = 1200; } else if (sensor.sensor_pixels < 0x5400) { dpihw = 2400; } else { throw SaneException("Cannot handle sensor pixel count %d", sensor.sensor_pixels); } sanei_genesys_set_dpihw(dev->reg, sensor, dpihw); dev->reg.find_reg(0x06).value |= REG_0x06_PWRBIT; dev->reg.find_reg(0x06).value |= REG_0x06_GAIN4; /* XP300 CCD needs different clock and clock/pixels values */ if (dev->model->sensor_id != SensorId::CCD_XP300 && dev->model->sensor_id != SensorId::CCD_DP685 && dev->model->sensor_id != SensorId::CCD_PLUSTEK_OPTICPRO_3600) { dev->reg.find_reg(0x06).value |= 0 << REG_0x06S_SCANMOD; dev->reg.find_reg(0x09).value |= 1 << REG_0x09S_CLKSET; } else { dev->reg.find_reg(0x06).value |= 0x05 << REG_0x06S_SCANMOD; /* 15 clocks/pixel */ dev->reg.find_reg(0x09).value = 0; /* 24 MHz CLKSET */ } dev->reg.find_reg(0x1e).value = 0xf0; /* watch-dog time */ dev->reg.find_reg(0x17).value |= 1 << REG_0x17S_TGW; dev->reg.find_reg(0x19).value = 0x50; dev->reg.find_reg(0x1d).value |= 1 << REG_0x1DS_TGSHLD; dev->reg.find_reg(0x1e).value |= 1 << REG_0x1ES_WDTIME; /*SCANFED*/ dev->reg.find_reg(0x1f).value = 0x01; /*BUFSEL*/ dev->reg.find_reg(0x20).value = 0x20; /*LAMPPWM*/ dev->reg.find_reg(0x29).value = 0xff; /*BWHI*/ dev->reg.find_reg(0x2e).value = 0x80; /*BWLOW*/ dev->reg.find_reg(0x2f).value = 0x80; /*LPERIOD*/ dev->reg.find_reg(0x38).value = 0x4f; dev->reg.find_reg(0x39).value = 0xc1; /*VSMPW*/ dev->reg.find_reg(0x58).value |= 3 << REG_0x58S_VSMPW; /*BSMPW*/ dev->reg.find_reg(0x59).value |= 3 << REG_0x59S_BSMPW; /*RLCSEL*/ dev->reg.find_reg(0x5a).value |= REG_0x5A_RLCSEL; /*STOPTIM*/ dev->reg.find_reg(0x5e).value |= 0x2 << REG_0x5ES_STOPTIM; sanei_gl841_setup_sensor(dev, sensor, &dev->reg, 0, 1); // set up GPIO for (const auto& reg : dev->gpo.regs) { dev->reg.set8(reg.address, reg.value); } /* TODO there is a switch calling to be written here */ if (dev->model->gpio_id == GpioId::CANON_LIDE_35) { dev->reg.find_reg(0x6b).value |= REG_0x6B_GPO18; dev->reg.find_reg(0x6b).value &= ~REG_0x6B_GPO17; } if (dev->model->gpio_id == GpioId::XP300) { dev->reg.find_reg(0x6b).value |= REG_0x6B_GPO17; } if (dev->model->gpio_id == GpioId::DP685) { /* REG_0x6B_GPO18 lights on green led */ dev->reg.find_reg(0x6b).value |= REG_0x6B_GPO17|REG_0x6B_GPO18; } DBG(DBG_proc, "%s complete\n", __func__); } // Send slope table for motor movement slope_table in machine byte order static void gl841_send_slope_table(Genesys_Device* dev, int table_nr, const std::vector& slope_table, int steps) { DBG_HELPER_ARGS(dbg, "table_nr = %d, steps = %d", table_nr, steps); int dpihw; int start_address; char msg[4000]; /*#ifdef WORDS_BIGENDIAN*/ int i; /*#endif*/ dpihw = dev->reg.find_reg(0x05).value >> 6; if (dpihw == 0) /* 600 dpi */ start_address = 0x08000; else if (dpihw == 1) /* 1200 dpi */ start_address = 0x10000; else if (dpihw == 2) /* 2400 dpi */ start_address = 0x20000; else { throw SaneException("Unexpected dpihw"); } std::vector table(steps * 2); for(i = 0; i < steps; i++) { table[i * 2] = slope_table[i] & 0xff; table[i * 2 + 1] = slope_table[i] >> 8; } if (DBG_LEVEL >= DBG_io) { std::sprintf(msg, "write slope %d (%d)=", table_nr, steps); for (i = 0; i < steps; i++) { std::sprintf (msg+strlen(msg), ",%d", slope_table[i]); } DBG(DBG_io, "%s: %s\n", __func__, msg); } if (dev->interface->is_mock()) { dev->interface->record_slope_table(table_nr, slope_table); } dev->interface->write_buffer(0x3c, start_address + table_nr * 0x200, table.data(), steps * 2); } static void gl841_set_lide80_fe(Genesys_Device* dev, uint8_t set) { DBG_HELPER(dbg); if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; // write them to analog frontend dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x03, dev->frontend.regs.get_value(0x01)); dev->interface->write_fe_register(0x06, dev->frontend.regs.get_value(0x02)); } if (set == AFE_SET) { dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x06, dev->frontend.regs.get_value(0x20)); dev->interface->write_fe_register(0x03, dev->frontend.regs.get_value(0x28)); } } // Set values of Analog Device type frontend static void gl841_set_ad_fe(Genesys_Device* dev, uint8_t set) { DBG_HELPER(dbg); int i; if (dev->model->adc_id==AdcId::CANON_LIDE_80) { gl841_set_lide80_fe(dev, set); return; } if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; // write them to analog frontend dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x01, dev->frontend.regs.get_value(0x01)); for (i = 0; i < 6; i++) { dev->interface->write_fe_register(0x02 + i, 0x00); } } if (set == AFE_SET) { // write them to analog frontend dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x01, dev->frontend.regs.get_value(0x01)); // Write fe 0x02 (red gain) dev->interface->write_fe_register(0x02, dev->frontend.get_gain(0)); // Write fe 0x03 (green gain) dev->interface->write_fe_register(0x03, dev->frontend.get_gain(1)); // Write fe 0x04 (blue gain) dev->interface->write_fe_register(0x04, dev->frontend.get_gain(2)); // Write fe 0x05 (red offset) dev->interface->write_fe_register(0x05, dev->frontend.get_offset(0)); // Write fe 0x06 (green offset) dev->interface->write_fe_register(0x06, dev->frontend.get_offset(1)); // Write fe 0x07 (blue offset) dev->interface->write_fe_register(0x07, dev->frontend.get_offset(2)); } } // Set values of analog frontend void CommandSetGl841::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const { DBG_HELPER_ARGS(dbg, "%s", set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == AFE_POWER_SAVE ? "powersave" : "huh?"); (void) sensor; /* Analog Device type frontend */ uint8_t frontend_type = dev->reg.find_reg(0x04).value & REG_0x04_FESET; if (frontend_type == 0x02) { gl841_set_ad_fe(dev, set); return; } if (frontend_type != 0x00) { throw SaneException("unsupported frontend type %d", frontend_type); } if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; // reset only done on init dev->interface->write_fe_register(0x04, 0x80); DBG(DBG_proc, "%s(): frontend reset complete\n", __func__); } if (set == AFE_POWER_SAVE) { dev->interface->write_fe_register(0x01, 0x02); return; } /* todo : base this test on cfg reg3 or a CCD family flag to be created */ /*if (dev->model->ccd_type!=SensorId::CCD_HP2300 && dev->model->ccd_type!=SensorId::CCD_HP2400) */ { dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x02, dev->frontend.regs.get_value(0x02)); } dev->interface->write_fe_register(0x01, dev->frontend.regs.get_value(0x01)); dev->interface->write_fe_register(0x03, dev->frontend.regs.get_value(0x03)); dev->interface->write_fe_register(0x06, dev->frontend.reg2[0]); dev->interface->write_fe_register(0x08, dev->frontend.reg2[1]); dev->interface->write_fe_register(0x09, dev->frontend.reg2[2]); for (unsigned i = 0; i < 3; i++) { dev->interface->write_fe_register(0x24 + i, dev->frontend.regs.get_value(0x24 + i)); dev->interface->write_fe_register(0x28 + i, dev->frontend.get_gain(i)); dev->interface->write_fe_register(0x20 + i, dev->frontend.get_offset(i)); } } enum MotorAction { MOTOR_ACTION_FEED = 1, MOTOR_ACTION_GO_HOME = 2, MOTOR_ACTION_HOME_FREE = 3 }; // @brief turn off motor static void gl841_init_motor_regs_off(Genesys_Register_Set* reg, unsigned int scan_lines) { DBG_HELPER_ARGS(dbg, "scan_lines=%d", scan_lines); unsigned int feedl; GenesysRegister* r; feedl = 2; r = sanei_genesys_get_address (reg, 0x3d); r->value = (feedl >> 16) & 0xf; r = sanei_genesys_get_address (reg, 0x3e); r->value = (feedl >> 8) & 0xff; r = sanei_genesys_get_address (reg, 0x3f); r->value = feedl & 0xff; r = sanei_genesys_get_address (reg, 0x5e); r->value &= ~0xe0; r = sanei_genesys_get_address (reg, 0x25); r->value = (scan_lines >> 16) & 0xf; r = sanei_genesys_get_address (reg, 0x26); r->value = (scan_lines >> 8) & 0xff; r = sanei_genesys_get_address (reg, 0x27); r->value = scan_lines & 0xff; r = sanei_genesys_get_address (reg, 0x02); r->value &= ~0x01; /*LONGCURV OFF*/ r->value &= ~0x80; /*NOT_HOME OFF*/ r->value &= ~0x10; r->value &= ~0x06; r->value &= ~0x08; r->value &= ~0x20; r->value &= ~0x40; r = sanei_genesys_get_address (reg, 0x67); r->value = 0x3f; r = sanei_genesys_get_address (reg, 0x68); r->value = 0x3f; r = sanei_genesys_get_address(reg, REG_STEPNO); r->value = 0; r = sanei_genesys_get_address(reg, REG_FASTNO); r->value = 0; r = sanei_genesys_get_address (reg, 0x69); r->value = 0; r = sanei_genesys_get_address (reg, 0x6a); r->value = 0; r = sanei_genesys_get_address (reg, 0x5f); r->value = 0; } /** @brief write motor table frequency * Write motor frequency data table. * @param dev device to set up motor * @param ydpi motor target resolution */ static void gl841_write_freq(Genesys_Device* dev, unsigned int ydpi) { DBG_HELPER(dbg); /**< fast table */ uint8_t tdefault[] = {0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76}; uint8_t t1200[] = {0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20}; uint8_t t300[] = {0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60}; uint8_t t150[] = {0x0c,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0x40,0x14,0x80,0x15,0x80,0x15,0x80,0x15,0x80,0x15,0x80,0x15,0x80,0x15,0x80,0x15,0x0c,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0x11,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x0c,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0x40,0xd4,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x0c,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0x11,0x60,0x16,0x60,0x16,0x60,0x16,0x60,0x16,0x60,0x16,0x60,0x16,0x60,0x16,0x60}; uint8_t *table; if(dev->model->motor_id == MotorId::CANON_LIDE_80) { switch(ydpi) { case 3600: case 1200: table=t1200; break; case 900: case 300: table=t300; break; case 450: case 150: table=t150; break; default: table=tdefault; } dev->interface->write_register(0x66, 0x00); dev->interface->write_gamma(0x28, 0xc000, table, 128, ScannerInterface::FLAG_SWAP_REGISTERS); dev->interface->write_register(0x5b, 0x00); dev->interface->write_register(0x5c, 0x00); } } static void gl841_init_motor_regs(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, unsigned int feed_steps,/*1/base_ydpi*/ /*maybe float for half/quarter step resolution?*/ unsigned int action, MotorFlag flags) { DBG_HELPER_ARGS(dbg, "feed_steps=%d, action=%d, flags=%x", feed_steps, action, static_cast(flags)); unsigned int fast_exposure = 0; int use_fast_fed = 0; unsigned int feedl; GenesysRegister* r; /*number of scan lines to add in a scan_lines line*/ { std::vector table; table.resize(256, 0xffff); gl841_send_slope_table(dev, 0, table, 256); gl841_send_slope_table(dev, 1, table, 256); gl841_send_slope_table(dev, 2, table, 256); gl841_send_slope_table(dev, 3, table, 256); gl841_send_slope_table(dev, 4, table, 256); } gl841_write_freq(dev, dev->motor.base_ydpi / 4); if (action == MOTOR_ACTION_FEED || action == MOTOR_ACTION_GO_HOME) { /* FEED and GO_HOME can use fastest slopes available */ fast_exposure = gl841_exposure_time(dev, sensor, dev->motor.base_ydpi / 4, StepType::FULL, 0, 0); DBG(DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure); } if (action == MOTOR_ACTION_HOME_FREE) { /* HOME_FREE must be able to stop in one step, so do not try to get faster */ fast_exposure = dev->motor.get_slope(StepType::FULL).max_speed_w; } auto fast_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, StepType::FULL, fast_exposure, dev->motor.base_ydpi / 4); feedl = feed_steps - fast_table.steps_count * 2; use_fast_fed = 1; /* all needed slopes available. we did even decide which mode to use. what next? - transfer slopes SCAN: flags \ use_fast_fed ! 0 1 ------------------------\-------------------- 0 ! 0,1,2 0,1,2,3 MotorFlag::AUTO_GO_HOME ! 0,1,2,4 0,1,2,3,4 OFF: none FEED: 3 GO_HOME: 3 HOME_FREE: 3 - setup registers * slope specific registers (already done) * DECSEL for HOME_FREE/GO_HOME/SCAN * FEEDL * MTRREV * MTRPWR * FASTFED * STEPSEL * MTRPWM * FSTPSEL * FASTPWM * HOMENEG * BWDSTEP * FWDSTEP * Z1 * Z2 */ r = sanei_genesys_get_address(reg, 0x3d); r->value = (feedl >> 16) & 0xf; r = sanei_genesys_get_address(reg, 0x3e); r->value = (feedl >> 8) & 0xff; r = sanei_genesys_get_address(reg, 0x3f); r->value = feedl & 0xff; r = sanei_genesys_get_address(reg, 0x5e); r->value &= ~0xe0; r = sanei_genesys_get_address(reg, 0x25); r->value = 0; r = sanei_genesys_get_address(reg, 0x26); r->value = 0; r = sanei_genesys_get_address(reg, 0x27); r->value = 0; r = sanei_genesys_get_address(reg, 0x02); r->value &= ~0x01; /*LONGCURV OFF*/ r->value &= ~0x80; /*NOT_HOME OFF*/ r->value |= 0x10; if (action == MOTOR_ACTION_GO_HOME) r->value |= 0x06; else r->value &= ~0x06; if (use_fast_fed) r->value |= 0x08; else r->value &= ~0x08; if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { r->value |= 0x20; } else { r->value &= ~0x20; } r->value &= ~0x40; if (has_flag(flags, MotorFlag::REVERSE)) { r->value |= REG_0x02_MTRREV; } gl841_send_slope_table(dev, 3, fast_table.table, 256); r = sanei_genesys_get_address(reg, 0x67); r->value = 0x3f; r = sanei_genesys_get_address(reg, 0x68); r->value = 0x3f; r = sanei_genesys_get_address(reg, REG_STEPNO); r->value = 0; r = sanei_genesys_get_address(reg, REG_FASTNO); r->value = 0; r = sanei_genesys_get_address(reg, 0x69); r->value = 0; r = sanei_genesys_get_address(reg, 0x6a); r->value = (fast_table.steps_count >> 1) + (fast_table.steps_count & 1); r = sanei_genesys_get_address(reg, 0x5f); r->value = (fast_table.steps_count >> 1) + (fast_table.steps_count & 1); } static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, unsigned int scan_exposure_time,/*pixel*/ unsigned scan_yres, // dpi, motor resolution StepType scan_step_type, unsigned int scan_lines,/*lines, scan resolution*/ unsigned int scan_dummy, // number of scan lines to add in a scan_lines line unsigned int feed_steps,/*1/base_ydpi*/ // maybe float for half/quarter step resolution? MotorFlag flags) { DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, scan_yres=%d, scan_step_type=%d, scan_lines=%d," " scan_dummy=%d, feed_steps=%d, flags=%x", scan_exposure_time, scan_yres, static_cast(scan_step_type), scan_lines, scan_dummy, feed_steps, static_cast(flags)); unsigned int fast_exposure; int use_fast_fed = 0; unsigned int fast_time; unsigned int slow_time; unsigned int feedl; GenesysRegister* r; unsigned int min_restep = 0x20; uint32_t z1, z2; fast_exposure = gl841_exposure_time(dev, sensor, dev->motor.base_ydpi / 4, StepType::FULL, 0, 0); DBG(DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure); { std::vector table; table.resize(256, 0xffff); gl841_send_slope_table(dev, 0, table, 256); gl841_send_slope_table(dev, 1, table, 256); gl841_send_slope_table(dev, 2, table, 256); gl841_send_slope_table(dev, 3, table, 256); gl841_send_slope_table(dev, 4, table, 256); } /* motor frequency table */ gl841_write_freq(dev, scan_yres); /* we calculate both tables for SCAN. the fast slope step count depends on how many steps we need for slow acceleration and how much steps we are allowed to use. */ auto slow_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, scan_step_type, scan_exposure_time, scan_yres); auto back_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, scan_step_type, 0, scan_yres); if (feed_steps < (slow_table.steps_count >> static_cast(scan_step_type))) { /*TODO: what should we do here?? go back to exposure calculation?*/ feed_steps = slow_table.steps_count >> static_cast(scan_step_type); } auto fast_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, StepType::FULL, fast_exposure, dev->motor.base_ydpi / 4); unsigned max_fast_slope_steps_count = 1; if (feed_steps > (slow_table.steps_count >> static_cast(scan_step_type)) + 2) { max_fast_slope_steps_count = (feed_steps - (slow_table.steps_count >> static_cast(scan_step_type))) / 2; } if (fast_table.steps_count > max_fast_slope_steps_count) { fast_table.slice_steps(max_fast_slope_steps_count); } /* fast fed special cases handling */ if (dev->model->gpio_id == GpioId::XP300 || dev->model->gpio_id == GpioId::DP685) { /* quirk: looks like at least this scanner is unable to use 2-feed mode */ use_fast_fed = 0; } else if (feed_steps < fast_table.steps_count * 2 + (slow_table.steps_count >> static_cast(scan_step_type))) { use_fast_fed = 0; DBG(DBG_info, "%s: feed too short, slow move forced.\n", __func__); } else { /* for deciding whether we should use fast mode we need to check how long we need for (fast)accelerating, moving, decelerating, (TODO: stopping?) (slow)accelerating again versus (slow)accelerating and moving. we need fast and slow tables here. */ /*NOTE: scan_exposure_time is per scan_yres*/ /*NOTE: fast_exposure is per base_ydpi/4*/ /*we use full steps as base unit here*/ fast_time = fast_exposure / 4 * (feed_steps - fast_table.steps_count*2 - (slow_table.steps_count >> static_cast(scan_step_type))) + fast_table.pixeltime_sum*2 + slow_table.pixeltime_sum; slow_time = (scan_exposure_time * scan_yres) / dev->motor.base_ydpi * (feed_steps - (slow_table.steps_count >> static_cast(scan_step_type))) + slow_table.pixeltime_sum; DBG(DBG_info, "%s: Time for slow move: %d\n", __func__, slow_time); DBG(DBG_info, "%s: Time for fast move: %d\n", __func__, fast_time); use_fast_fed = fast_time < slow_time; } if (use_fast_fed) { feedl = feed_steps - fast_table.steps_count * 2 - (slow_table.steps_count >> static_cast(scan_step_type)); } else if ((feed_steps << static_cast(scan_step_type)) < slow_table.steps_count) { feedl = 0; } else { feedl = (feed_steps << static_cast(scan_step_type)) - slow_table.steps_count; } DBG(DBG_info, "%s: Decided to use %s mode\n", __func__, use_fast_fed?"fast feed":"slow feed"); /* all needed slopes available. we did even decide which mode to use. what next? - transfer slopes SCAN: flags \ use_fast_fed ! 0 1 ------------------------\-------------------- 0 ! 0,1,2 0,1,2,3 MotorFlag::AUTO_GO_HOME ! 0,1,2,4 0,1,2,3,4 OFF: none FEED: 3 GO_HOME: 3 HOME_FREE: 3 - setup registers * slope specific registers (already done) * DECSEL for HOME_FREE/GO_HOME/SCAN * FEEDL * MTRREV * MTRPWR * FASTFED * STEPSEL * MTRPWM * FSTPSEL * FASTPWM * HOMENEG * BWDSTEP * FWDSTEP * Z1 * Z2 */ r = sanei_genesys_get_address (reg, 0x3d); r->value = (feedl >> 16) & 0xf; r = sanei_genesys_get_address (reg, 0x3e); r->value = (feedl >> 8) & 0xff; r = sanei_genesys_get_address (reg, 0x3f); r->value = feedl & 0xff; r = sanei_genesys_get_address (reg, 0x5e); r->value &= ~0xe0; r = sanei_genesys_get_address (reg, 0x25); r->value = (scan_lines >> 16) & 0xf; r = sanei_genesys_get_address (reg, 0x26); r->value = (scan_lines >> 8) & 0xff; r = sanei_genesys_get_address (reg, 0x27); r->value = scan_lines & 0xff; r = sanei_genesys_get_address (reg, 0x02); r->value &= ~0x01; /*LONGCURV OFF*/ r->value &= ~0x80; /*NOT_HOME OFF*/ r->value |= 0x10; r->value &= ~0x06; if (use_fast_fed) r->value |= 0x08; else r->value &= ~0x08; if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) r->value |= 0x20; else r->value &= ~0x20; if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE)) { r->value |= 0x40; } else { r->value &= ~0x40; } gl841_send_slope_table(dev, 0, slow_table.table, 256); gl841_send_slope_table(dev, 1, back_table.table, 256); gl841_send_slope_table(dev, 2, slow_table.table, 256); if (use_fast_fed) { gl841_send_slope_table(dev, 3, fast_table.table, 256); } if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { gl841_send_slope_table(dev, 4, fast_table.table, 256); } /* now reg 0x21 and 0x24 are available, we can calculate reg 0x22 and 0x23, reg 0x60-0x62 and reg 0x63-0x65 rule: 2*STEPNO+FWDSTEP=2*FASTNO+BWDSTEP */ /* steps of table 0*/ if (min_restep < slow_table.steps_count * 2 + 2) { min_restep = slow_table.steps_count * 2 + 2; } /* steps of table 1*/ if (min_restep < back_table.steps_count * 2 + 2) { min_restep = back_table.steps_count * 2 + 2; } /* steps of table 0*/ r = sanei_genesys_get_address(reg, REG_FWDSTEP); r->value = min_restep - slow_table.steps_count*2; /* steps of table 1*/ r = sanei_genesys_get_address(reg, REG_BWDSTEP); r->value = min_restep - back_table.steps_count*2; /* for z1/z2: in dokumentation mentioned variables a-d: a = time needed for acceleration, table 1 b = time needed for reg 0x1f... wouldn't that be reg0x1f*exposure_time? c = time needed for acceleration, table 1 d = time needed for reg 0x22... wouldn't that be reg0x22*exposure_time? z1 = (c+d-1) % exposure_time z2 = (a+b-1) % exposure_time */ /* i don't see any effect of this. i can only guess that this will enhance sub-pixel accuracy z1 = (slope_0_time-1) % exposure_time; z2 = (slope_0_time-1) % exposure_time; */ z1 = z2 = 0; DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); r = sanei_genesys_get_address (reg, 0x60); r->value = ((z1 >> 16) & 0xff); r = sanei_genesys_get_address (reg, 0x61); r->value = ((z1 >> 8) & 0xff); r = sanei_genesys_get_address (reg, 0x62); r->value = (z1 & 0xff); r = sanei_genesys_get_address (reg, 0x63); r->value = ((z2 >> 16) & 0xff); r = sanei_genesys_get_address (reg, 0x64); r->value = ((z2 >> 8) & 0xff); r = sanei_genesys_get_address (reg, 0x65); r->value = (z2 & 0xff); r = sanei_genesys_get_address(reg, REG_0x1E); r->value &= REG_0x1E_WDTIME; r->value |= scan_dummy; r = sanei_genesys_get_address (reg, 0x67); r->value = 0x3f | (static_cast(scan_step_type) << 6); r = sanei_genesys_get_address (reg, 0x68); r->value = 0x3f; r = sanei_genesys_get_address(reg, REG_STEPNO); r->value = (slow_table.steps_count >> 1) + (slow_table.steps_count & 1); r = sanei_genesys_get_address(reg, REG_FASTNO); r->value = (back_table.steps_count >> 1) + (back_table.steps_count & 1); r = sanei_genesys_get_address (reg, 0x69); r->value = (slow_table.steps_count >> 1) + (slow_table.steps_count & 1); r = sanei_genesys_get_address (reg, 0x6a); r->value = (fast_table.steps_count >> 1) + (fast_table.steps_count & 1); r = sanei_genesys_get_address (reg, 0x5f); r->value = (fast_table.steps_count >> 1) + (fast_table.steps_count & 1); } static int gl841_get_dpihw(Genesys_Device * dev) { GenesysRegister* r; r = sanei_genesys_get_address(&dev->reg, 0x05); if ((r->value & REG_0x05_DPIHW) == REG_0x05_DPIHW_600) { return 600; } if ((r->value & REG_0x05_DPIHW) == REG_0x05_DPIHW_1200) { return 1200; } if ((r->value & REG_0x05_DPIHW) == REG_0x05_DPIHW_2400) { return 2400; } return 0; } static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, unsigned int exposure_time, const ScanSession& session) { DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time); GenesysRegister* r; uint16_t expavg, expr, expb, expg; dev->cmd_set->set_fe(dev, sensor, AFE_SET); /* gpio part.*/ if (dev->model->gpio_id == GpioId::CANON_LIDE_35) { r = sanei_genesys_get_address(reg, REG_0x6C); if (session.ccd_size_divisor > 1) { r->value &= ~0x80; } else { r->value |= 0x80; } } if (dev->model->gpio_id == GpioId::CANON_LIDE_80) { r = sanei_genesys_get_address(reg, REG_0x6C); if (session.ccd_size_divisor > 1) { r->value &= ~0x40; r->value |= 0x20; } else { r->value &= ~0x20; r->value |= 0x40; } } /* enable shading */ r = sanei_genesys_get_address (reg, 0x01); r->value |= REG_0x01_SCAN; if (has_flag(session.params.flags, ScanFlag::DISABLE_SHADING) || (dev->model->flags & GENESYS_FLAG_NO_CALIBRATION)) { r->value &= ~REG_0x01_DVDSET; } else { r->value |= REG_0x01_DVDSET; } /* average looks better than deletion, and we are already set up to use one of the average enabled resolutions */ r = sanei_genesys_get_address (reg, 0x03); r->value |= REG_0x03_AVEENB; sanei_genesys_set_lamp_power(dev, sensor, *reg, !has_flag(session.params.flags, ScanFlag::DISABLE_LAMP)); /* BW threshold */ r = sanei_genesys_get_address (reg, 0x2e); r->value = dev->settings.threshold; r = sanei_genesys_get_address (reg, 0x2f); r->value = dev->settings.threshold; /* monochrome / color scan */ r = sanei_genesys_get_address (reg, 0x04); switch (session.params.depth) { case 8: r->value &= ~(REG_0x04_LINEART | REG_0x04_BITSET); break; case 16: r->value &= ~REG_0x04_LINEART; r->value |= REG_0x04_BITSET; break; } /* AFEMOD should depend on FESET, and we should set these * bits separately */ r->value &= ~(REG_0x04_FILTER | REG_0x04_AFEMOD); if (has_flag(session.params.flags, ScanFlag::ENABLE_LEDADD)) { r->value |= 0x10; /* no filter */ } else if (session.params.channels == 1) { switch (session.params.color_filter) { case ColorFilter::RED: r->value |= 0x14; break; case ColorFilter::GREEN: r->value |= 0x18; break; case ColorFilter::BLUE: r->value |= 0x1c; break; default: r->value |= 0x10; break; } } else { if (dev->model->sensor_id == SensorId::CCD_PLUSTEK_OPTICPRO_3600) { r->value |= 0x22; /* slow color pixel by pixel */ } else { r->value |= 0x10; /* color pixel by pixel */ } } /* CIS scanners can do true gray by setting LEDADD */ r = sanei_genesys_get_address (reg, 0x87); r->value &= ~REG_0x87_LEDADD; if (has_flag(session.params.flags, ScanFlag::ENABLE_LEDADD)) { r->value |= REG_0x87_LEDADD; expr = reg->get16(REG_EXPR); expg = reg->get16(REG_EXPG); expb = reg->get16(REG_EXPB); /* use minimal exposure for best image quality */ expavg = expg; if (expr < expg) expavg = expr; if (expb < expavg) expavg = expb; dev->reg.set16(REG_EXPR, expavg); dev->reg.set16(REG_EXPG, expavg); dev->reg.set16(REG_EXPB, expavg); } // enable gamma tables if (should_enable_gamma(session, sensor)) { reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB; } else { reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB; } /* sensor parameters */ sanei_gl841_setup_sensor(dev, sensor, &dev->reg, 1, session.ccd_size_divisor); r = sanei_genesys_get_address (reg, 0x29); r->value = 255; /*<<<"magic" number, only suitable for cis*/ reg->set16(REG_DPISET, gl841_get_dpihw(dev) * session.output_resolution / session.optical_resolution); reg->set16(REG_STRPIXEL, session.pixel_startx); reg->set16(REG_ENDPIXEL, session.pixel_endx); reg->set24(REG_MAXWD, session.output_line_bytes); reg->set16(REG_LPERIOD, exposure_time); r = sanei_genesys_get_address (reg, 0x34); r->value = sensor.dummy_pixel; } static int gl841_get_led_exposure(Genesys_Device * dev, const Genesys_Sensor& sensor) { int d,r,g,b,m; if (!dev->model->is_cis) return 0; d = dev->reg.find_reg(0x19).value; r = sensor.exposure.red; g = sensor.exposure.green; b = sensor.exposure.blue; m = r; if (m < g) m = g; if (m < b) m = b; return m + d; } /** @brief compute exposure time * Compute exposure time for the device and the given scan resolution */ static int gl841_exposure_time(Genesys_Device *dev, const Genesys_Sensor& sensor, float slope_dpi, StepType scan_step_type, int start, int used_pixels) { int exposure_time = 0; int led_exposure; led_exposure=gl841_get_led_exposure(dev, sensor); exposure_time = sanei_genesys_exposure_time2( dev, slope_dpi, scan_step_type, start+used_pixels,/*+tgtime? currently done in sanei_genesys_exposure_time2 with tgtime = 32 pixel*/ led_exposure); return exposure_time; } /**@brief compute scan_step_type * Try to do at least 4 steps per line. if that is impossible we will have to * live with that. * @param dev device * @param yres motor resolution */ static StepType gl841_scan_step_type(Genesys_Device *dev, int yres) { StepType type = StepType::FULL; /* TODO : check if there is a bug around the use of max_step_type */ /* should be <=1, need to chek all devices entry in genesys_devices */ if (yres * 4 < dev->motor.base_ydpi || dev->motor.max_step_type() == StepType::FULL) { type = StepType::FULL; } else if (yres * 4 < dev->motor.base_ydpi * 2 || dev->motor.max_step_type() <= StepType::HALF) { type = StepType::HALF; } else { type = StepType::QUARTER; } /* this motor behaves differently */ if (dev->model->motor_id==MotorId::CANON_LIDE_80) { // driven by 'frequency' tables ? type = StepType::FULL; } return type; } void CommandSetGl841::init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const { DBG_HELPER(dbg); session.assert_computed(); int move; int exposure_time; int slope_dpi = 0; int dummy = 0; /* results: for scanner: start end dpiset exposure_time dummy z1 z2 for ordered_read: dev->words_per_line dev->read_factor dev->requested_buffer_size dev->read_buffer_size dev->read_pos dev->read_bytes_in_buffer dev->read_bytes_left dev->max_shift dev->stagger independent of our calculated values: dev->total_bytes_read dev->bytes_to_read */ /* dummy */ /* dummy lines: may not be usefull, for instance 250 dpi works with 0 or 1 dummy line. Maybe the dummy line adds correctness since the motor runs slower (higher dpi) */ /* for cis this creates better aligned color lines: dummy \ scanned lines 0: R G B R ... 1: R G B - R ... 2: R G B - - R ... 3: R G B - - - R ... 4: R G B - - - - R ... 5: R G B - - - - - R ... 6: R G B - - - - - - R ... 7: R G B - - - - - - - R ... 8: R G B - - - - - - - - R ... 9: R G B - - - - - - - - - R ... 10: R G B - - - - - - - - - - R ... 11: R G B - - - - - - - - - - - R ... 12: R G B - - - - - - - - - - - - R ... 13: R G B - - - - - - - - - - - - - R ... 14: R G B - - - - - - - - - - - - - - R ... 15: R G B - - - - - - - - - - - - - - - R ... -- pierre */ dummy = 0; /* slope_dpi */ /* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */ if (dev->model->is_cis) { slope_dpi = session.params.yres* session.params.channels; } else { slope_dpi = session.params.yres; } slope_dpi = slope_dpi * (1 + dummy); StepType scan_step_type = gl841_scan_step_type(dev, session.params.yres); exposure_time = gl841_exposure_time(dev, sensor, slope_dpi, scan_step_type, session.pixel_startx, session.optical_pixels); DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session); move = session.params.starty; DBG(DBG_info, "%s: move=%d steps\n", __func__, move); /* subtract current head position */ move -= (dev->head_pos(ScanHeadId::PRIMARY) * session.params.yres) / dev->motor.base_ydpi; DBG(DBG_info, "%s: move=%d steps\n", __func__, move); if (move < 0) move = 0; /* round it */ /* the move is not affected by dummy -- pierre */ /* move = ((move + dummy) / (dummy + 1)) * (dummy + 1); DBG(DBG_info, "%s: move=%d steps\n", __func__, move);*/ if (has_flag(session.params.flags, ScanFlag::SINGLE_LINE)) { gl841_init_motor_regs_off(reg, dev->model->is_cis ? session.output_line_count * session.params.channels : session.output_line_count); } else { auto motor_flag = has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE) ? MotorFlag::DISABLE_BUFFER_FULL_MOVE : MotorFlag::NONE; gl841_init_motor_regs_scan(dev, sensor, reg, exposure_time, slope_dpi, scan_step_type, dev->model->is_cis ? session.output_line_count * session.params.channels : session.output_line_count, dummy, move, motor_flag); } dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); build_image_pipeline(dev, session); dev->read_active = true; dev->session = session; dev->total_bytes_read = 0; dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines; DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read); } ScanSession CommandSetGl841::calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const { int start; DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, settings); /* start */ start = static_cast(dev->model->x_offset); start += static_cast(settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = settings.xres; session.params.yres = settings.yres; session.params.startx = start; session.params.starty = 0; // not used session.params.pixels = settings.pixels; session.params.requested_pixels = settings.requested_pixels; session.params.lines = settings.lines; session.params.depth = settings.depth; session.params.channels = settings.get_channels(); session.params.scan_method = settings.scan_method; session.params.scan_mode = settings.scan_mode; session.params.color_filter = settings.color_filter; session.params.flags = ScanFlag::NONE; compute_session(dev, session, sensor); return session; } // for fast power saving methods only, like disabling certain amplifiers void CommandSetGl841::save_power(Genesys_Device* dev, bool enable) const { DBG_HELPER_ARGS(dbg, "enable = %d", enable); const auto& sensor = sanei_genesys_find_sensor_any(dev); if (enable) { if (dev->model->gpio_id == GpioId::CANON_LIDE_35) { /* expect GPIO17 to be enabled, and GPIO9 to be disabled, while GPIO8 is disabled*/ /* final state: GPIO8 disabled, GPIO9 enabled, GPIO17 disabled, GPIO18 disabled*/ uint8_t val = dev->interface->read_register(REG_0x6D); dev->interface->write_register(REG_0x6D, val | 0x80); dev->interface->sleep_ms(1); /*enable GPIO9*/ val = dev->interface->read_register(REG_0x6C); dev->interface->write_register(REG_0x6C, val | 0x01); /*disable GPO17*/ val = dev->interface->read_register(REG_0x6B); dev->interface->write_register(REG_0x6B, val & ~REG_0x6B_GPO17); /*disable GPO18*/ val = dev->interface->read_register(REG_0x6B); dev->interface->write_register(REG_0x6B, val & ~REG_0x6B_GPO18); dev->interface->sleep_ms(1); val = dev->interface->read_register(REG_0x6D); dev->interface->write_register(REG_0x6D, val & ~0x80); } if (dev->model->gpio_id == GpioId::DP685) { uint8_t val = dev->interface->read_register(REG_0x6B); dev->interface->write_register(REG_0x6B, val & ~REG_0x6B_GPO17); dev->reg.find_reg(0x6b).value &= ~REG_0x6B_GPO17; dev->calib_reg.find_reg(0x6b).value &= ~REG_0x6B_GPO17; } set_fe(dev, sensor, AFE_POWER_SAVE); } else { if (dev->model->gpio_id == GpioId::CANON_LIDE_35) { /* expect GPIO17 to be enabled, and GPIO9 to be disabled, while GPIO8 is disabled*/ /* final state: GPIO8 enabled, GPIO9 disabled, GPIO17 enabled, GPIO18 enabled*/ uint8_t val = dev->interface->read_register(REG_0x6D); dev->interface->write_register(REG_0x6D, val | 0x80); dev->interface->sleep_ms(10); /*disable GPIO9*/ val = dev->interface->read_register(REG_0x6C); dev->interface->write_register(REG_0x6C, val & ~0x01); /*enable GPIO10*/ val = dev->interface->read_register(REG_0x6C); dev->interface->write_register(REG_0x6C, val | 0x02); /*enable GPO17*/ val = dev->interface->read_register(REG_0x6B); dev->interface->write_register(REG_0x6B, val | REG_0x6B_GPO17); dev->reg.find_reg(0x6b).value |= REG_0x6B_GPO17; dev->calib_reg.find_reg(0x6b).value |= REG_0x6B_GPO17; /*enable GPO18*/ val = dev->interface->read_register(REG_0x6B); dev->interface->write_register(REG_0x6B, val | REG_0x6B_GPO18); dev->reg.find_reg(0x6b).value |= REG_0x6B_GPO18; dev->calib_reg.find_reg(0x6b).value |= REG_0x6B_GPO18; } if (dev->model->gpio_id == GpioId::DP665 || dev->model->gpio_id == GpioId::DP685) { uint8_t val = dev->interface->read_register(REG_0x6B); dev->interface->write_register(REG_0x6B, val | REG_0x6B_GPO17); dev->reg.find_reg(0x6b).value |= REG_0x6B_GPO17; dev->calib_reg.find_reg(0x6b).value |= REG_0x6B_GPO17; } } } void CommandSetGl841::set_powersaving(Genesys_Device* dev, int delay /* in minutes */) const { DBG_HELPER_ARGS(dbg, "delay = %d", delay); // FIXME: SEQUENTIAL not really needed in this case Genesys_Register_Set local_reg(Genesys_Register_Set::SEQUENTIAL); int rate, exposure_time, tgtime, time; local_reg.init_reg(0x01, dev->reg.get8(0x01)); /* disable fastmode */ local_reg.init_reg(0x03, dev->reg.get8(0x03)); /* Lamp power control */ local_reg.init_reg(0x05, dev->reg.get8(0x05)); /*& ~REG_0x05_BASESEL*/; /* 24 clocks/pixel */ local_reg.init_reg(0x18, 0x00); // Set CCD type local_reg.init_reg(0x38, 0x00); local_reg.init_reg(0x39, 0x00); // period times for LPeriod, expR,expG,expB, Z1MODE, Z2MODE local_reg.init_reg(0x1c, dev->reg.get8(0x05) & ~REG_0x1C_TGTIME); if (!delay) { local_reg.find_reg(0x03).value = local_reg.find_reg(0x03).value & 0xf0; /* disable lampdog and set lamptime = 0 */ } else if (delay < 20) { local_reg.find_reg(0x03).value = (local_reg.find_reg(0x03).value & 0xf0) | 0x09; /* enable lampdog and set lamptime = 1 */ } else { local_reg.find_reg(0x03).value = (local_reg.find_reg(0x03).value & 0xf0) | 0x0f; /* enable lampdog and set lamptime = 7 */ } time = delay * 1000 * 60; /* -> msec */ exposure_time = static_cast(time * 32000.0 / (24.0 * 64.0 * (local_reg.find_reg(0x03).value & REG_0x03_LAMPTIM) * 1024.0) + 0.5); /* 32000 = system clock, 24 = clocks per pixel */ rate = (exposure_time + 65536) / 65536; if (rate > 4) { rate = 8; tgtime = 3; } else if (rate > 2) { rate = 4; tgtime = 2; } else if (rate > 1) { rate = 2; tgtime = 1; } else { rate = 1; tgtime = 0; } local_reg.find_reg(0x1c).value |= tgtime; exposure_time /= rate; if (exposure_time > 65535) exposure_time = 65535; local_reg.set8(0x38, exposure_time >> 8); local_reg.set8(0x39, exposure_time & 255); /* lowbyte */ dev->interface->write_registers(local_reg); } static void gl841_stop_action(Genesys_Device* dev) { DBG_HELPER(dbg); Genesys_Register_Set local_reg; unsigned int loop; scanner_read_print_status(*dev); if (scanner_is_motor_stopped(*dev)) { DBG(DBG_info, "%s: already stopped\n", __func__); return; } local_reg = dev->reg; regs_set_optical_off(dev->model->asic_type, local_reg); gl841_init_motor_regs_off(&local_reg,0); dev->interface->write_registers(local_reg); if (is_testing_mode()) { return; } /* looks like writing the right registers to zero is enough to get the chip out of scan mode into command mode, actually triggering(writing to register 0x0f) seems to be unnecessary */ loop = 10; while (loop > 0) { if (scanner_is_motor_stopped(*dev)) { return; } dev->interface->sleep_ms(100); loop--; } throw SaneException(SANE_STATUS_IO_ERROR, "could not stop motor"); } static bool gl841_get_paper_sensor(Genesys_Device* dev) { DBG_HELPER(dbg); uint8_t val = dev->interface->read_register(REG_0x6D); return (val & 0x1) == 0; } void CommandSetGl841::eject_document(Genesys_Device* dev) const { DBG_HELPER(dbg); Genesys_Register_Set local_reg; unsigned int init_steps; float feed_mm; int loop; if (!dev->model->is_sheetfed) { DBG(DBG_proc, "%s: there is no \"eject sheet\"-concept for non sheet fed\n", __func__); DBG(DBG_proc, "%s: finished\n", __func__); return; } local_reg.clear(); // FIXME: unused result scanner_read_status(*dev); gl841_stop_action(dev); local_reg = dev->reg; regs_set_optical_off(dev->model->asic_type, local_reg); const auto& sensor = sanei_genesys_find_sensor_any(dev); gl841_init_motor_regs(dev, sensor, &local_reg, 65536, MOTOR_ACTION_FEED, MotorFlag::NONE); dev->interface->write_registers(local_reg); try { scanner_start_action(*dev, true); } catch (...) { catch_all_exceptions(__func__, [&]() { gl841_stop_action(dev); }); // restore original registers catch_all_exceptions(__func__, [&]() { dev->interface->write_registers(dev->reg); }); throw; } if (is_testing_mode()) { dev->interface->test_checkpoint("eject_document"); gl841_stop_action(dev); return; } if (gl841_get_paper_sensor(dev)) { DBG(DBG_info, "%s: paper still loaded\n", __func__); /* force document TRUE, because it is definitely present */ dev->document = true; dev->set_head_pos_zero(ScanHeadId::PRIMARY); loop = 300; while (loop > 0) /* do not wait longer then 30 seconds */ { if (!gl841_get_paper_sensor(dev)) { DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_proc, "%s: finished\n", __func__); break; } dev->interface->sleep_ms(100); --loop; } if (loop == 0) { // when we come here then the scanner needed too much time for this, so we better stop // the motor catch_all_exceptions(__func__, [&](){ gl841_stop_action(dev); }); throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home"); } } feed_mm = static_cast(dev->model->eject_feed); if (dev->document) { feed_mm += static_cast(dev->model->post_scan); } sanei_genesys_read_feed_steps(dev, &init_steps); /* now feed for extra steps */ loop = 0; while (loop < 300) /* do not wait longer then 30 seconds */ { unsigned int steps; sanei_genesys_read_feed_steps(dev, &steps); DBG(DBG_info, "%s: init_steps: %d, steps: %d\n", __func__, init_steps, steps); if (steps > init_steps + (feed_mm * dev->motor.base_ydpi) / MM_PER_INCH) { break; } dev->interface->sleep_ms(100); ++loop; } gl841_stop_action(dev); dev->document = false; } void CommandSetGl841::load_document(Genesys_Device* dev) const { DBG_HELPER(dbg); int loop = 300; while (loop > 0) /* do not wait longer then 30 seconds */ { if (gl841_get_paper_sensor(dev)) { DBG(DBG_info, "%s: document inserted\n", __func__); /* when loading OK, document is here */ dev->document = true; // give user some time to place document correctly dev->interface->sleep_ms(1000); break; } dev->interface->sleep_ms(100); --loop; } if (loop == 0) { // when we come here then the user needed to much time for this throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for document"); } } /** * detects end of document and adjust current scan * to take it into account * used by sheetfed scanners */ void CommandSetGl841::detect_document_end(Genesys_Device* dev) const { DBG_HELPER(dbg); bool paper_loaded = gl841_get_paper_sensor(dev); /* sheetfed scanner uses home sensor as paper present */ if (dev->document && !paper_loaded) { DBG(DBG_info, "%s: no more document\n", __func__); dev->document = false; /* we can't rely on total_bytes_to_read since the frontend * might have been slow to read data, so we re-evaluate the * amount of data to scan form the hardware settings */ unsigned scanned_lines = 0; try { sanei_genesys_read_scancnt(dev, &scanned_lines); } catch (...) { dev->total_bytes_to_read = dev->total_bytes_read; throw; } if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS && dev->model->is_cis) { scanned_lines /= 3; } std::size_t output_lines = dev->session.output_line_count; std::size_t offset_lines = static_cast( (dev->model->post_scan / MM_PER_INCH) * dev->settings.yres); std::size_t scan_end_lines = scanned_lines + offset_lines; std::size_t remaining_lines = dev->get_pipeline_source().remaining_bytes() / dev->session.output_line_bytes_raw; DBG(DBG_io, "%s: scanned_lines=%u\n", __func__, scanned_lines); DBG(DBG_io, "%s: scan_end_lines=%zu\n", __func__, scan_end_lines); DBG(DBG_io, "%s: output_lines=%zu\n", __func__, output_lines); DBG(DBG_io, "%s: remaining_lines=%zu\n", __func__, remaining_lines); if (scan_end_lines > output_lines) { auto skip_lines = scan_end_lines - output_lines; if (remaining_lines > skip_lines) { DBG(DBG_io, "%s: skip_lines=%zu\n", __func__, skip_lines); remaining_lines -= skip_lines; dev->get_pipeline_source().set_remaining_bytes(remaining_lines * dev->session.output_line_bytes_raw); dev->total_bytes_to_read -= skip_lines * dev->session.output_line_bytes_requested; } } } } // Send the low-level scan command // todo : is this that useful ? void CommandSetGl841::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, bool start_motor) const { DBG_HELPER(dbg); (void) sensor; // FIXME: SEQUENTIAL not really needed in this case Genesys_Register_Set local_reg(Genesys_Register_Set::SEQUENTIAL); uint8_t val; if (dev->model->gpio_id == GpioId::CANON_LIDE_80) { val = dev->interface->read_register(REG_0x6B); val = REG_0x6B_GPO18; dev->interface->write_register(REG_0x6B, val); } if (dev->model->sensor_id != SensorId::CCD_PLUSTEK_OPTICPRO_3600) { local_reg.init_reg(0x03, reg->get8(0x03) | REG_0x03_LAMPPWR); } else { // TODO PLUSTEK_3600: why ?? local_reg.init_reg(0x03, reg->get8(0x03)); } local_reg.init_reg(0x01, reg->get8(0x01) | REG_0x01_SCAN); local_reg.init_reg(0x0d, 0x01); // scanner_start_action(dev, start_motor) if (start_motor) { local_reg.init_reg(0x0f, 0x01); } else { // do not start motor yet local_reg.init_reg(0x0f, 0x00); } dev->interface->write_registers(local_reg); dev->advance_head_pos_by_session(ScanHeadId::PRIMARY); } // Send the stop scan command void CommandSetGl841::end_scan(Genesys_Device* dev, Genesys_Register_Set __sane_unused__* reg, bool check_stop) const { DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop); if (!dev->model->is_sheetfed) { gl841_stop_action(dev); } } // Moves the slider to steps static void gl841_feed(Genesys_Device* dev, int steps) { DBG_HELPER_ARGS(dbg, "steps = %d", steps); Genesys_Register_Set local_reg; int loop; gl841_stop_action(dev); // FIXME: we should pick sensor according to the resolution scanner is currently operating on const auto& sensor = sanei_genesys_find_sensor_any(dev); local_reg = dev->reg; regs_set_optical_off(dev->model->asic_type, local_reg); gl841_init_motor_regs(dev, sensor, &local_reg, steps, MOTOR_ACTION_FEED, MotorFlag::NONE); dev->interface->write_registers(local_reg); try { scanner_start_action(*dev, true); } catch (...) { catch_all_exceptions(__func__, [&]() { gl841_stop_action (dev); }); // restore original registers catch_all_exceptions(__func__, [&]() { dev->interface->write_registers(dev->reg); }); throw; } if (is_testing_mode()) { dev->interface->test_checkpoint("feed"); dev->advance_head_pos_by_steps(ScanHeadId::PRIMARY, Direction::FORWARD, steps); gl841_stop_action(dev); return; } loop = 0; while (loop < 300) /* do not wait longer then 30 seconds */ { auto status = scanner_read_status(*dev); if (!status.is_motor_enabled) { DBG(DBG_proc, "%s: finished\n", __func__); dev->advance_head_pos_by_steps(ScanHeadId::PRIMARY, Direction::FORWARD, steps); return; } dev->interface->sleep_ms(100); ++loop; } /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl841_stop_action (dev); dev->set_head_pos_unknown(); throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home"); } // Moves the slider to the home (top) position slowly void CommandSetGl841::move_back_home(Genesys_Device* dev, bool wait_until_home) const { DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home); Genesys_Register_Set local_reg; int loop = 0; if (dev->model->is_sheetfed) { DBG(DBG_proc, "%s: there is no \"home\"-concept for sheet fed\n", __func__); DBG(DBG_proc, "%s: finished\n", __func__); return; } // reset gpio pin uint8_t val; if (dev->model->gpio_id == GpioId::CANON_LIDE_35) { val = dev->interface->read_register(REG_0x6C); val = dev->gpo.regs.get_value(0x6c); dev->interface->write_register(REG_0x6C, val); } if (dev->model->gpio_id == GpioId::CANON_LIDE_80) { val = dev->interface->read_register(REG_0x6B); val = REG_0x6B_GPO18 | REG_0x6B_GPO17; dev->interface->write_register(REG_0x6B, val); } dev->cmd_set->save_power(dev, false); // first read gives HOME_SENSOR true auto status = scanner_read_reliable_status(*dev); if (status.is_at_home) { DBG(DBG_info, "%s: already at home, completed\n", __func__); dev->set_head_pos_zero(ScanHeadId::PRIMARY); return; } scanner_stop_action_no_move(*dev, dev->reg); /* if motor is on, stop current action */ if (status.is_motor_enabled) { gl841_stop_action(dev); } local_reg = dev->reg; const auto& sensor = sanei_genesys_find_sensor_any(dev); gl841_init_motor_regs(dev, sensor, &local_reg, 65536, MOTOR_ACTION_GO_HOME, MotorFlag::REVERSE); // set up for no scan regs_set_optical_off(dev->model->asic_type, local_reg); dev->interface->write_registers(local_reg); try { scanner_start_action(*dev, true); } catch (...) { catch_all_exceptions(__func__, [&]() { gl841_stop_action(dev); }); // restore original registers catch_all_exceptions(__func__, [&]() { dev->interface->write_registers(dev->reg); }); throw; } if (is_testing_mode()) { dev->interface->test_checkpoint("move_back_home"); dev->set_head_pos_zero(ScanHeadId::PRIMARY); return; } if (wait_until_home) { while (loop < 300) /* do not wait longer then 30 seconds */ { auto status = scanner_read_status(*dev); if (status.is_at_home) { DBG(DBG_info, "%s: reached home position\n", __func__); DBG(DBG_proc, "%s: finished\n", __func__); dev->set_head_pos_zero(ScanHeadId::PRIMARY); return; } dev->interface->sleep_ms(100); ++loop; } // when we come here then the scanner needed too much time for this, so we better stop // the motor catch_all_exceptions(__func__, [&](){ gl841_stop_action(dev); }); dev->set_head_pos_unknown(); throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home"); } DBG(DBG_info, "%s: scanhead is still moving\n", __func__); } // Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi // from very top of scanner void CommandSetGl841::search_start_position(Genesys_Device* dev) const { DBG_HELPER(dbg); int size; Genesys_Register_Set local_reg; int pixels = 600; int dpi = 300; local_reg = dev->reg; /* sets for a 200 lines * 600 pixels */ /* normal scan with no shading */ // FIXME: the current approach of doing search only for one resolution does not work on scanners // whith employ different sensors with potentially different settings. const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method); ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; /*we should give a small offset here~60 steps*/ session.params.pixels = 600; session.params.lines = dev->model->search_lines; session.params.depth = 8; session.params.channels = 1; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::GREEN; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::IGNORE_LINE_DISTANCE | ScanFlag::DISABLE_BUFFER_FULL_MOVE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &local_reg, session); // send to scanner dev->interface->write_registers(local_reg); size = pixels * dev->model->search_lines; std::vector data(size); dev->cmd_set->begin_scan(dev, sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_start_position"); dev->cmd_set->end_scan(dev, &local_reg, true); dev->reg = local_reg; return; } wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl841_search_position.pnm", data.data(), 8, 1, pixels, dev->model->search_lines); } dev->cmd_set->end_scan(dev, &local_reg, true); /* update regs to copy ASIC internal state */ dev->reg = local_reg; for (auto& sensor_update : sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) { sanei_genesys_search_reference_point(dev, sensor_update, data.data(), 0, dpi, pixels, dev->model->search_lines); } } // sets up register for coarse gain calibration // todo: check it for scanners using it void CommandSetGl841::init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel(); session.params.lines = 20; session.params.depth = 16; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, ®s, session); DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres); dev->interface->write_registers(regs); /* if (DBG_LEVEL >= DBG_info) sanei_gl841_print_registers (regs);*/ } // init registers for shading calibration void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER_ARGS(dbg, "lines = %zu", dev->calib_lines); SANE_Int ydpi; unsigned starty = 0; /* initial calibration reg values */ regs = dev->reg; ydpi = dev->motor.base_ydpi; if (dev->model->motor_id == MotorId::PLUSTEK_OPTICPRO_3600) /* TODO PLUSTEK_3600: 1200dpi not yet working, produces dark bar */ { ydpi = 600; } if (dev->model->motor_id == MotorId::CANON_LIDE_80) { ydpi = gl841_get_dpihw(dev); /* get over extra dark area for this model. It looks like different devices have dark areas of different width due to manufacturing variability. The initial value of starty was 140, but it moves the sensor almost past the dark area completely in places on certain devices. On a particular device the black area starts at roughly position 160 to 230 depending on location (the dark area is not completely parallel to the frame). */ starty = 70; } dev->calib_channels = 3; dev->calib_lines = dev->model->shading_lines; unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres); unsigned factor = sensor.optical_res / resolution; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, dev->calib_channels, dev->settings.scan_method); dev->calib_pixels = calib_sensor.sensor_pixels / factor; ScanSession session; session.params.xres = resolution; session.params.yres = ydpi; session.params.startx = 0; session.params.starty = starty; session.params.pixels = dev->calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; session.params.channels = dev->calib_channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | /*ScanFlag::DISABLE_BUFFER_FULL_MOVE |*/ ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); dev->interface->write_registers(regs); } // set up registers for the actual scan void CommandSetGl841::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); float move; int move_dpi; float start; debug_dump(DBG_info, dev->settings); /* steps to move to reach scanning area: - first we move to physical start of scanning either by a fixed steps amount from the black strip or by a fixed amount from parking position, minus the steps done during shading calibration - then we move by the needed offset whitin physical scanning area assumption: steps are expressed at maximum motor resolution we need: float y_offset; float y_size; float y_offset_calib; mm_to_steps()=motor dpi / 2.54 / 10=motor dpi / MM_PER_INCH */ /* if scanner uses GENESYS_FLAG_SEARCH_START y_offset is relative from origin, else, it is from parking position */ move_dpi = dev->motor.base_ydpi; move = 0; if (dev->model->flags & GENESYS_FLAG_SEARCH_START) { move += static_cast(dev->model->y_offset_calib_white); } DBG(DBG_info, "%s move=%f steps\n", __func__, move); move += static_cast(dev->model->y_offset); DBG(DBG_info, "%s: move=%f steps\n", __func__, move); move += static_cast(dev->settings.tl_y); DBG(DBG_info, "%s: move=%f steps\n", __func__, move); move = static_cast((move * move_dpi) / MM_PER_INCH); /* start */ start = static_cast(dev->model->x_offset); start += static_cast(dev->settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode */ ScanFlag flags = ScanFlag::NONE; /* true gray (led add for cis scanners) */ if(dev->model->is_cis && dev->settings.true_gray && dev->settings.scan_mode != ScanColorMode::COLOR_SINGLE_PASS && dev->model->sensor_id != SensorId::CIS_CANON_LIDE_80) { // on Lide 80 the LEDADD bit results in only red LED array being lit DBG(DBG_io, "%s: activating LEDADD\n", __func__); flags |= ScanFlag::ENABLE_LEDADD; } ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = static_cast(start); session.params.starty = static_cast(move); session.params.pixels = dev->settings.pixels; session.params.requested_pixels = dev->settings.requested_pixels; session.params.lines = dev->settings.lines; session.params.depth = dev->settings.depth; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = flags; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &dev->reg, session); } // this function sends generic gamma table (ie linear ones) or the Sensor specific one if provided void CommandSetGl841::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); int size; size = 256; /* allocate temporary gamma tables: 16 bits words, 3 channels */ std::vector gamma(size * 2 * 3); sanei_genesys_generate_gamma_buffer(dev, sensor, 16, 65535, size, gamma.data()); dev->interface->write_gamma(0x28, 0x0000, gamma.data(), size * 2 * 3); } /* this function does the led calibration by scanning one line of the calibration area below scanner's top on white strip. -needs working coarse/gain */ SensorExposure CommandSetGl841::led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); int num_pixels; int total_size; int i, j; int val; int channels; int avg[3], avga, avge; int turn; uint16_t exp[3], target; int move; /* these 2 boundaries should be per sensor */ uint16_t min_exposure=500; uint16_t max_exposure; /* feed to white strip if needed */ if (dev->model->y_offset_calib_white > 0) { move = static_cast(dev->model->y_offset_calib_white); move = static_cast((move * (dev->motor.base_ydpi)) / MM_PER_INCH); DBG(DBG_io, "%s: move=%d lines\n", __func__, move); gl841_feed(dev, move); } /* offset calibration is always done in color mode */ channels = 3; unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres); unsigned factor = sensor.optical_res / resolution; const auto& calib_sensor_base = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); num_pixels = calib_sensor_base.sensor_pixels / factor; ScanSession session; session.params.xres = resolution; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor_base); init_regs_for_scan_session(dev, calib_sensor_base, ®s, session); dev->interface->write_registers(regs); total_size = num_pixels * channels * 2 * 1; /* colors * bytes_per_color * scan lines */ std::vector line(total_size); /* we try to get equal bright leds here: loop: average per color adjust exposure times */ exp[0] = sensor.exposure.red; exp[1] = sensor.exposure.green; exp[2] = sensor.exposure.blue; turn = 0; /* max exposure is set to ~2 time initial average * exposure, or 2 time last calibration exposure */ max_exposure=((exp[0]+exp[1]+exp[2])/3)*2; target=sensor.gain_white_ref*256; auto calib_sensor = calib_sensor_base; bool acceptable = false; do { calib_sensor.exposure.red = exp[0]; calib_sensor.exposure.green = exp[1]; calib_sensor.exposure.blue = exp[2]; regs_set_exposure(dev->model->asic_type, regs, calib_sensor.exposure); dev->interface->write_register(0x10, (calib_sensor.exposure.red >> 8) & 0xff); dev->interface->write_register(0x11, calib_sensor.exposure.red & 0xff); dev->interface->write_register(0x12, (calib_sensor.exposure.green >> 8) & 0xff); dev->interface->write_register(0x13, calib_sensor.exposure.green & 0xff); dev->interface->write_register(0x14, (calib_sensor.exposure.blue >> 8) & 0xff); dev->interface->write_register(0x15, calib_sensor.exposure.blue & 0xff); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting line reading\n", __func__); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("led_calibration"); move_back_home(dev, true); return calib_sensor.exposure; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl841_led_%d.pnm", turn); sanei_genesys_write_pnm_file(fn, line.data(), 16, channels, num_pixels, 1); } /* compute average */ for (j = 0; j < channels; j++) { avg[j] = 0; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = line[i * 2 + j * 2 * num_pixels + 1] * 256 + line[i * 2 + j * 2 * num_pixels]; else val = line[i * 2 * channels + 2 * j + 1] * 256 + line[i * 2 * channels + 2 * j]; avg[j] += val; } avg[j] /= num_pixels; } DBG(DBG_info,"%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); acceptable = true; /* exposure is acceptable if each color is in the %5 range * of other color channels */ if (avg[0] < avg[1] * 0.95 || avg[1] < avg[0] * 0.95 || avg[0] < avg[2] * 0.95 || avg[2] < avg[0] * 0.95 || avg[1] < avg[2] * 0.95 || avg[2] < avg[1] * 0.95) { acceptable = false; } /* led exposure is not acceptable if white level is too low * ~80 hardcoded value for white level */ if(avg[0]<20000 || avg[1]<20000 || avg[2]<20000) { acceptable = false; } /* for scanners using target value */ if(target>0) { acceptable = true; for(i=0;i<3;i++) { /* we accept +- 2% delta from target */ if(abs(avg[i]-target)>target/50) { exp[i]=(exp[i]*target)/avg[i]; acceptable = false; } } } else { if (!acceptable) { avga = (avg[0]+avg[1]+avg[2])/3; exp[0] = (exp[0] * avga) / avg[0]; exp[1] = (exp[1] * avga) / avg[1]; exp[2] = (exp[2] * avga) / avg[2]; /* keep the resulting exposures below this value. too long exposure drives the ccd into saturation. we may fix this by relying on the fact that we get a striped scan without shading, by means of statistical calculation */ avge = (exp[0] + exp[1] + exp[2]) / 3; if (avge > max_exposure) { exp[0] = (exp[0] * max_exposure) / avge; exp[1] = (exp[1] * max_exposure) / avge; exp[2] = (exp[2] * max_exposure) / avge; } if (avge < min_exposure) { exp[0] = (exp[0] * min_exposure) / avge; exp[1] = (exp[1] * min_exposure) / avge; exp[2] = (exp[2] * min_exposure) / avge; } } } gl841_stop_action(dev); turn++; } while (!acceptable && turn < 100); DBG(DBG_info,"%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]); dev->cmd_set->move_back_home(dev, true); return calib_sensor.exposure; } /** @brief calibration for AD frontend devices * offset calibration assumes that the scanning head is on a black area * For LiDE80 analog frontend * 0x0003 : is gain and belongs to [0..63] * 0x0006 : is offset * We scan a line with no gain until average offset reaches the target */ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) { DBG_HELPER(dbg); int num_pixels; int total_size; int i; int average; int turn; int top; int bottom; int target; /* don't impact 3600 behavior since we can't test it */ if (dev->model->sensor_id == SensorId::CCD_PLUSTEK_OPTICPRO_3600) { return; } unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres); unsigned factor = sensor.optical_res / resolution; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, dev->settings.scan_method); num_pixels = calib_sensor.sensor_pixels / factor; ScanSession session; session.params.xres = resolution; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 8; session.params.channels = 3; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); dev->cmd_set->init_regs_for_scan_session(dev, calib_sensor, ®s, session); total_size = num_pixels * 3 * 2 * 1; std::vector line(total_size); dev->frontend.set_gain(0, 0); dev->frontend.set_gain(1, 0); dev->frontend.set_gain(2, 0); /* loop on scan until target offset is reached */ turn=0; target=24; bottom=0; top=255; do { /* set up offset mid range */ dev->frontend.set_offset(0, (top + bottom) / 2); dev->frontend.set_offset(1, (top + bottom) / 2); dev->frontend.set_offset(2, (top + bottom) / 2); /* scan line */ DBG(DBG_info, "%s: starting line reading\n", __func__); dev->interface->write_registers(regs); dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("ad_fe_offset_calibration"); gl841_stop_action(dev); return; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); gl841_stop_action (dev); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl841_offset_%02d.pnm", turn); sanei_genesys_write_pnm_file(fn, line.data(), 8, 3, num_pixels, 1); } /* search for minimal value */ average=0; for(i=0;itarget) { top=(top+bottom)/2; } else { bottom=(top+bottom)/2; } turn++; } while ((top-bottom)>1 && turn < 100); // FIXME: don't overwrite the calibrated values dev->frontend.set_offset(0, 0); dev->frontend.set_offset(1, 0); dev->frontend.set_offset(2, 0); DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); } /* this function does the offset calibration by scanning one line of the calibration area below scanner's top. There is a black margin and the remaining is white. sanei_genesys_search_start() must have been called so that the offsets and margins are allready known. this function expects the slider to be where? */ void CommandSetGl841::offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); int num_pixels; int total_size; int i, j; int val; int channels; int off[3],offh[3],offl[3],off1[3],off2[3]; int min1[3],min2[3]; int cmin[3],cmax[3]; int turn; int mintgt = 0x400; /* Analog Device fronted have a different calibration */ if ((dev->reg.find_reg(0x04).value & REG_0x04_FESET) == 0x02) { return ad_fe_offset_calibration(dev, sensor, regs); } /* offset calibration is always done in color mode */ channels = 3; unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres); unsigned factor = sensor.optical_res / resolution; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); num_pixels = calib_sensor.sensor_pixels / factor; ScanSession session; session.params.xres = resolution; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE | ScanFlag::DISABLE_LAMP; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); total_size = num_pixels * channels * 2 * 1; /* colors * bytes_per_color * scan lines */ std::vector first_line(total_size); std::vector second_line(total_size); /* scan first line of data with no offset nor gain */ /*WM8199: gain=0.73; offset=-260mV*/ /*okay. the sensor black level is now at -260mV. we only get 0 from AFE...*/ /* we should probably do real calibration here: * -detect acceptable offset with binary search * -calculate offset from this last version * * acceptable offset means * - few completely black pixels(<10%?) * - few completely white pixels(<10%?) * * final offset should map the minimum not completely black * pixel to 0(16 bits) * * this does account for dummy pixels at the end of ccd * this assumes slider is at black strip(which is not quite as black as "no * signal"). * */ dev->frontend.set_gain(0, 0); dev->frontend.set_gain(1, 0); dev->frontend.set_gain(2, 0); offh[0] = 0xff; offh[1] = 0xff; offh[2] = 0xff; offl[0] = 0x00; offl[1] = 0x00; offl[2] = 0x00; turn = 0; bool acceptable = false; do { dev->interface->write_registers(regs); for (j=0; j < channels; j++) { off[j] = (offh[j]+offl[j])/2; dev->frontend.set_offset(j, off[j]); } dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET); DBG(DBG_info, "%s: starting first line reading\n", __func__); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("offset_calibration"); return; } sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl841_offset1_%02d.pnm", turn); sanei_genesys_write_pnm_file(fn, first_line.data(), 16, channels, num_pixels, 1); } acceptable = true; for (j = 0; j < channels; j++) { cmin[j] = 0; cmax[j] = 0; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = first_line[i * 2 + j * 2 * num_pixels + 1] * 256 + first_line[i * 2 + j * 2 * num_pixels]; else val = first_line[i * 2 * channels + 2 * j + 1] * 256 + first_line[i * 2 * channels + 2 * j]; if (val < 10) cmin[j]++; if (val > 65525) cmax[j]++; } /* TODO the DP685 has a black strip in the middle of the sensor * should be handled in a more elegant way , could be a bug */ if (dev->model->sensor_id == SensorId::CCD_DP685) cmin[j] -= 20; if (cmin[j] > num_pixels/100) { acceptable = false; if (dev->model->is_cis) offl[0] = off[0]; else offl[j] = off[j]; } if (cmax[j] > num_pixels/100) { acceptable = false; if (dev->model->is_cis) offh[0] = off[0]; else offh[j] = off[j]; } } DBG(DBG_info,"%s: black/white pixels: %d/%d,%d/%d,%d/%d\n", __func__, cmin[0], cmax[0], cmin[1], cmax[1], cmin[2], cmax[2]); if (dev->model->is_cis) { offh[2] = offh[1] = offh[0]; offl[2] = offl[1] = offl[0]; } gl841_stop_action(dev); turn++; } while (!acceptable && turn < 100); DBG(DBG_info,"%s: acceptable offsets: %d,%d,%d\n", __func__, off[0], off[1], off[2]); for (j = 0; j < channels; j++) { off1[j] = off[j]; min1[j] = 65536; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = first_line[i * 2 + j * 2 * num_pixels + 1] * 256 + first_line[i * 2 + j * 2 * num_pixels]; else val = first_line[i * 2 * channels + 2 * j + 1] * 256 + first_line[i * 2 * channels + 2 * j]; if (min1[j] > val && val >= 10) min1[j] = val; } } offl[0] = off[0]; offl[1] = off[0]; offl[2] = off[0]; turn = 0; do { for (j=0; j < channels; j++) { off[j] = (offh[j]+offl[j])/2; dev->frontend.set_offset(j, off[j]); } dev->cmd_set->set_fe(dev, calib_sensor, AFE_SET); DBG(DBG_info, "%s: starting second line reading\n", __func__); dev->interface->write_registers(regs); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl841_offset2_%02d.pnm", turn); sanei_genesys_write_pnm_file(fn, second_line.data(), 16, channels, num_pixels, 1); } acceptable = true; for (j = 0; j < channels; j++) { cmin[j] = 0; cmax[j] = 0; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = second_line[i * 2 + j * 2 * num_pixels + 1] * 256 + second_line[i * 2 + j * 2 * num_pixels]; else val = second_line[i * 2 * channels + 2 * j + 1] * 256 + second_line[i * 2 * channels + 2 * j]; if (val < 10) cmin[j]++; if (val > 65525) cmax[j]++; } if (cmin[j] > num_pixels/100) { acceptable = false; if (dev->model->is_cis) offl[0] = off[0]; else offl[j] = off[j]; } if (cmax[j] > num_pixels/100) { acceptable = false; if (dev->model->is_cis) offh[0] = off[0]; else offh[j] = off[j]; } } DBG(DBG_info, "%s: black/white pixels: %d/%d,%d/%d,%d/%d\n", __func__, cmin[0], cmax[0], cmin[1], cmax[1], cmin[2], cmax[2]); if (dev->model->is_cis) { offh[2] = offh[1] = offh[0]; offl[2] = offl[1] = offl[0]; } gl841_stop_action(dev); turn++; } while (!acceptable && turn < 100); DBG(DBG_info, "%s: acceptable offsets: %d,%d,%d\n", __func__, off[0], off[1], off[2]); for (j = 0; j < channels; j++) { off2[j] = off[j]; min2[j] = 65536; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = second_line[i * 2 + j * 2 * num_pixels + 1] * 256 + second_line[i * 2 + j * 2 * num_pixels]; else val = second_line[i * 2 * channels + 2 * j + 1] * 256 + second_line[i * 2 * channels + 2 * j]; if (min2[j] > val && val != 0) min2[j] = val; } } DBG(DBG_info, "%s: first set: %d/%d,%d/%d,%d/%d\n", __func__, off1[0], min1[0], off1[1], min1[1], off1[2], min1[2]); DBG(DBG_info, "%s: second set: %d/%d,%d/%d,%d/%d\n", __func__, off2[0], min2[0], off2[1], min2[1], off2[2], min2[2]); /* calculate offset for each channel based on minimal pixel value min1 at offset off1 and minimal pixel value min2 at offset off2 to get min at off, values are linearly interpolated: min=real+off*fact min1=real+off1*fact min2=real+off2*fact fact=(min1-min2)/(off1-off2) real=min1-off1*(min1-min2)/(off1-off2) off=(min-min1+off1*(min1-min2)/(off1-off2))/((min1-min2)/(off1-off2)) off=(min*(off1-off2)+min1*off2-off1*min2)/(min1-min2) */ for (j = 0; j < channels; j++) { if (min2[j]-min1[j] == 0) { /*TODO: try to avoid this*/ DBG(DBG_warn, "%s: difference too small\n", __func__); if (mintgt * (off1[j] - off2[j]) + min1[j] * off2[j] - min2[j] * off1[j] >= 0) off[j] = 0x0000; else off[j] = 0xffff; } else off[j] = (mintgt * (off1[j] - off2[j]) + min1[j] * off2[j] - min2[j] * off1[j])/(min1[j]-min2[j]); if (off[j] > 255) off[j] = 255; if (off[j] < 0) off[j] = 0; dev->frontend.set_offset(j, off[j]); } DBG(DBG_info, "%s: final offsets: %d,%d,%d\n", __func__, off[0], off[1], off[2]); if (dev->model->is_cis) { if (off[0] < off[1]) off[0] = off[1]; if (off[0] < off[2]) off[0] = off[2]; dev->frontend.set_offset(0, off[0]); dev->frontend.set_offset(1, off[0]); dev->frontend.set_offset(2, off[0]); } if (channels == 1) { dev->frontend.set_offset(1, dev->frontend.get_offset(0)); dev->frontend.set_offset(2, dev->frontend.get_offset(0)); } } /* alternative coarse gain calibration this on uses the settings from offset_calibration and uses only one scanline */ /* with offset and coarse calibration we only want to get our input range into a reasonable shape. the fine calibration of the upper and lower bounds will be done with shading. */ void CommandSetGl841::coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const { DBG_HELPER_ARGS(dbg, "dpi=%d", dpi); int num_pixels; int total_size; int i, j, channels; int max[3]; float gain[3]; int val; int lines=1; int move; // feed to white strip if needed if (dev->model->y_offset_calib_white > 0) { move = static_cast(dev->model->y_offset_calib_white); move = static_cast((move * (dev->motor.base_ydpi)) / MM_PER_INCH); DBG(DBG_io, "%s: move=%d lines\n", __func__, move); gl841_feed(dev, move); } /* coarse gain calibration is allways done in color mode */ channels = 3; unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres); unsigned factor = sensor.optical_res / resolution; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); num_pixels = calib_sensor.sensor_pixels / factor; ScanSession session; session.params.xres = resolution; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = lines; session.params.depth = 16; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); dev->interface->write_registers(regs); total_size = num_pixels * channels * 2 * lines; /* colors * bytes_per_color * scan lines */ std::vector line(total_size); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("coarse_gain_calibration"); gl841_stop_action(dev); move_back_home(dev, true); return; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); if (DBG_LEVEL >= DBG_data) sanei_genesys_write_pnm_file("gl841_gain.pnm", line.data(), 16, channels, num_pixels, lines); /* average high level for each channel and compute gain to reach the target code we only use the central half of the CCD data */ for (j = 0; j < channels; j++) { max[j] = 0; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = line[i * 2 + j * 2 * num_pixels + 1] * 256 + line[i * 2 + j * 2 * num_pixels]; else val = line[i * 2 * channels + 2 * j + 1] * 256 + line[i * 2 * channels + 2 * j]; if (val > max[j]) max[j] = val; } gain[j] = 65535.0f / max[j]; uint8_t out_gain = 0; if (dev->model->adc_id == AdcId::CANON_LIDE_35 || dev->model->adc_id == AdcId::WOLFSON_XP300 || dev->model->adc_id == AdcId::WOLFSON_DSM600) { gain[j] *= 0.69f; // seems we don't get the real maximum. empirically derived if (283 - 208/gain[j] > 255) out_gain = 255; else if (283 - 208/gain[j] < 0) out_gain = 0; else out_gain = static_cast(283 - 208 / gain[j]); } else if (dev->model->adc_id == AdcId::CANON_LIDE_80) { out_gain = static_cast(gain[j] * 12); } dev->frontend.set_gain(j, out_gain); DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j], out_gain); } for (j = 0; j < channels; j++) { if(gain[j] > 10) { DBG (DBG_error0, "**********************************************\n"); DBG (DBG_error0, "**********************************************\n"); DBG (DBG_error0, "**** ****\n"); DBG (DBG_error0, "**** Extremely low Brightness detected. ****\n"); DBG (DBG_error0, "**** Check the scanning head is ****\n"); DBG (DBG_error0, "**** unlocked and moving. ****\n"); DBG (DBG_error0, "**** ****\n"); DBG (DBG_error0, "**********************************************\n"); DBG (DBG_error0, "**********************************************\n"); throw SaneException(SANE_STATUS_JAMMED, "scanning head is locked"); } } if (dev->model->is_cis) { uint8_t gain0 = dev->frontend.get_gain(0); if (gain0 > dev->frontend.get_gain(1)) { gain0 = dev->frontend.get_gain(1); } if (gain0 > dev->frontend.get_gain(2)) { gain0 = dev->frontend.get_gain(2); } dev->frontend.set_gain(0, gain0); dev->frontend.set_gain(1, gain0); dev->frontend.set_gain(2, gain0); } if (channels == 1) { dev->frontend.set_gain(0, dev->frontend.get_gain(1)); dev->frontend.set_gain(2, dev->frontend.get_gain(1)); } DBG(DBG_info, "%s: gain=(%d,%d,%d)\n", __func__, dev->frontend.get_gain(0), dev->frontend.get_gain(1), dev->frontend.get_gain(2)); gl841_stop_action(dev); dev->cmd_set->move_back_home(dev, true); } // wait for lamp warmup by scanning the same line until difference // between 2 scans is below a threshold void CommandSetGl841::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* local_reg, int* channels, int* total_size) const { DBG_HELPER(dbg); int num_pixels = 4 * 300; *local_reg = dev->reg; /* okay.. these should be defaults stored somewhere */ dev->frontend.set_gain(0, 0); dev->frontend.set_gain(1, 0); dev->frontend.set_gain(2, 0); dev->frontend.set_offset(0, 0x80); dev->frontend.set_offset(1, 0x80); dev->frontend.set_offset(2, 0x80); ScanSession session; session.params.xres = sensor.optical_res; session.params.yres = dev->settings.yres; session.params.startx = sensor.dummy_pixel; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = *channels; session.params.scan_method = dev->settings.scan_method; if (*channels == 3) { session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; } else { session.params.scan_mode = ScanColorMode::GRAY; } session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, local_reg, session); num_pixels = session.output_pixels; *total_size = num_pixels * 3 * 2 * 1; /* colors * bytes_per_color * scan lines */ dev->interface->write_registers(*local_reg); } /* * this function moves head without scanning, forward, then backward * so that the head goes to park position. * as a by-product, also check for lock */ static void sanei_gl841_repark_head(Genesys_Device* dev) { DBG_HELPER(dbg); gl841_feed(dev,232); // toggle motor flag, put an huge step number and redo move backward dev->cmd_set->move_back_home(dev, true); } /* * initialize ASIC : registers, motor tables, and gamma tables * then ensure scanner's head is at home */ void CommandSetGl841::init(Genesys_Device* dev) const { size_t size; DBG_INIT (); DBG_HELPER(dbg); dev->set_head_pos_zero(ScanHeadId::PRIMARY); /* Check if the device has already been initialized and powered up */ if (dev->already_initialized) { auto status = scanner_read_status(*dev); if (!status.is_replugged) { DBG(DBG_info, "%s: already initialized\n", __func__); return; } } dev->dark_average_data.clear(); dev->white_average_data.clear(); dev->settings.color_filter = ColorFilter::RED; // ASIC reset dev->interface->write_register(0x0e, 0x01); dev->interface->write_register(0x0e, 0x00); /* Set default values for registers */ gl841_init_registers (dev); // Write initial registers dev->interface->write_registers(dev->reg); const auto& sensor = sanei_genesys_find_sensor_any(dev); // Set analog frontend dev->cmd_set->set_fe(dev, sensor, AFE_INIT); // FIXME: move_back_home modifies dev->calib_reg and requires it to be filled dev->calib_reg = dev->reg; // Move home dev->cmd_set->move_back_home(dev, true); // Init shading data sanei_genesys_init_shading_data(dev, sensor, sensor.sensor_pixels); /* ensure head is correctly parked, and check lock */ if (dev->model->flags & GENESYS_FLAG_REPARK) { // FIXME: if repark fails, we should print an error message that the scanner is locked and // the user should unlock the lock. We should also rethrow with SANE_STATUS_JAMMED sanei_gl841_repark_head(dev); } // send gamma tables dev->cmd_set->send_gamma_table(dev, sensor); /* initial calibration reg values */ Genesys_Register_Set& regs = dev->calib_reg; regs = dev->reg; unsigned resolution = sensor.get_logical_hwdpi(300); unsigned factor = sensor.optical_res / resolution; const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, dev->settings.scan_method); unsigned num_pixels = 16 / factor; ScanSession session; session.params.xres = resolution; session.params.yres = 300; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = 3; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = ColorFilter::RED; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); dev->interface->write_registers(regs); size = num_pixels * 3 * 2 * 1; // colors * bytes_per_color * scan lines std::vector line(size); DBG(DBG_info, "%s: starting dummy data reading\n", __func__); dev->cmd_set->begin_scan(dev, calib_sensor, ®s, true); sanei_usb_set_timeout(1000);/* 1 second*/ if (is_testing_mode()) { dev->interface->test_checkpoint("init"); } else { // ignore errors. next read will succeed catch_all_exceptions(__func__, [&](){ sanei_genesys_read_data_from_scanner(dev, line.data(), size); }); } sanei_usb_set_timeout(30 * 1000);/* 30 seconds*/ end_scan(dev, ®s, true); regs = dev->reg; // Set powersaving(default = 15 minutes) set_powersaving(dev, 15); dev->already_initialized = true; } void CommandSetGl841::update_hardware_sensors(Genesys_Scanner* s) const { DBG_HELPER(dbg); /* do what is needed to get a new set of events, but try to not lose any of them. */ uint8_t val; if (s->dev->model->gpio_id == GpioId::CANON_LIDE_35 || s->dev->model->gpio_id == GpioId::CANON_LIDE_80) { val = s->dev->interface->read_register(REG_0x6D); s->buttons[BUTTON_SCAN_SW].write((val & 0x01) == 0); s->buttons[BUTTON_FILE_SW].write((val & 0x02) == 0); s->buttons[BUTTON_EMAIL_SW].write((val & 0x04) == 0); s->buttons[BUTTON_COPY_SW].write((val & 0x08) == 0); } if (s->dev->model->gpio_id == GpioId::XP300 || s->dev->model->gpio_id == GpioId::DP665 || s->dev->model->gpio_id == GpioId::DP685) { val = s->dev->interface->read_register(REG_0x6D); s->buttons[BUTTON_PAGE_LOADED_SW].write((val & 0x01) == 0); s->buttons[BUTTON_SCAN_SW].write((val & 0x02) == 0); } } /** @brief search for a full width black or white strip. * This function searches for a black or white stripe across the scanning area. * When searching backward, the searched area must completely be of the desired * color since this area will be used for calibration which scans forward. * @param dev scanner device * @param forward true if searching forward, false if searching backward * @param black true if searching for a black strip, false for a white strip */ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const { DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse"); unsigned int pixels, lines, channels; Genesys_Register_Set local_reg; size_t size; unsigned int pass, count, found, x, y, length; char title[80]; GenesysRegister *r; uint8_t white_level=90; /**< default white level to detect white dots */ uint8_t black_level=60; /**< default black level to detect black dots */ /* use maximum gain when doing forward white strip detection * since we don't have calibrated the sensor yet */ if(!black && forward) { dev->frontend.set_gain(0, 0xff); dev->frontend.set_gain(1, 0xff); dev->frontend.set_gain(2, 0xff); } dev->cmd_set->set_fe(dev, sensor, AFE_SET); gl841_stop_action(dev); // set up for a gray scan at lowest dpi const auto& resolution_settings = dev->model->get_resolution_settings(dev->settings.scan_method); unsigned dpi = resolution_settings.get_min_resolution_x(); channels = 1; /* shading calibation is done with dev->motor.base_ydpi */ /* lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi; */ lines = static_cast((10 * dpi) / MM_PER_INCH); pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res; /* 20 cm max length for calibration sheet */ length = static_cast(((200 * dpi) / MM_PER_INCH) / lines); dev->set_head_pos_zero(ScanHeadId::PRIMARY); local_reg = dev->reg; ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::RED; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA; compute_session(dev, session, sensor); size = pixels * channels * lines * (session.params.depth / 8); std::vector data(size); init_regs_for_scan_session(dev, sensor, &local_reg, session); /* set up for reverse or forward */ r = sanei_genesys_get_address(&local_reg, 0x02); if (forward) { r->value &= ~4; } else { r->value |= 4; } dev->interface->write_registers(local_reg); dev->cmd_set->begin_scan(dev, sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_strip"); gl841_stop_action(dev); return; } // waits for valid data wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); gl841_stop_action(dev); pass = 0; if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl841_search_strip_%s_%s%02u.pnm", black ? "black" : "white", forward ? "fwd" : "bwd", pass); sanei_genesys_write_pnm_file(title, data.data(), session.params.depth, channels, pixels, lines); } /* loop until strip is found or maximum pass number done */ found = 0; while (pass < length && !found) { dev->interface->write_registers(local_reg); //now start scan dev->cmd_set->begin_scan(dev, sensor, &local_reg, true); // waits for valid data wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); gl841_stop_action (dev); if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl841_search_strip_%s_%s%02u.pnm", black ? "black" : "white", forward ? "fwd" : "bwd", pass); sanei_genesys_write_pnm_file(title, data.data(), session.params.depth, channels, pixels, lines); } /* search data to find black strip */ /* when searching forward, we only need one line of the searched color since we * will scan forward. But when doing backward search, we need all the area of the * same color */ if (forward) { for (y = 0; y < lines && !found; y++) { count = 0; /* count of white/black pixels depending on the color searched */ for (x = 0; x < pixels; x++) { /* when searching for black, detect white pixels */ if (black && data[y * pixels + x] > white_level) { count++; } /* when searching for white, detect black pixels */ if (!black && data[y * pixels + x] < black_level) { count++; } } /* at end of line, if count >= 3%, line is not fully of the desired color * so we must go to next line of the buffer */ /* count*100/pixels < 3 */ if ((count * 100) / pixels < 3) { found = 1; DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, pass, y); } else { DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, (100 * count) / pixels); } } } else /* since calibration scans are done forward, we need the whole area to be of the required color when searching backward */ { count = 0; for (y = 0; y < lines; y++) { /* count of white/black pixels depending on the color searched */ for (x = 0; x < pixels; x++) { /* when searching for black, detect white pixels */ if (black && data[y * pixels + x] > white_level) { count++; } /* when searching for white, detect black pixels */ if (!black && data[y * pixels + x] < black_level) { count++; } } } /* at end of area, if count >= 3%, area is not fully of the desired color * so we must go to next buffer */ if ((count * 100) / (pixels * lines) < 3) { found = 1; DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, (100 * count) / pixels); } } pass++; } if (found) { DBG(DBG_info, "%s: %s strip found\n", __func__, black ? "black" : "white"); } else { throw SaneException(SANE_STATUS_UNSUPPORTED, "%s strip not found", black ? "black" : "white"); } } /** * Send shading calibration data. The buffer is considered to always hold values * for all the channels. */ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const { DBG_HELPER_ARGS(dbg, "writing %d bytes of shading data", size); uint32_t length, x, factor, pixels, i; uint16_t dpiset, dpihw, beginpixel; uint8_t *ptr,*src; /* old method if no SHDAREA */ if ((dev->reg.find_reg(0x01).value & REG_0x01_SHDAREA) == 0) { dev->interface->write_buffer(0x3c, 0x0000, data, size); return; } /* data is whole line, we extract only the part for the scanned area */ length = static_cast(size / 3); unsigned strpixel = dev->session.pixel_startx; unsigned endpixel = dev->session.pixel_endx; /* compute deletion/average factor */ dpiset = dev->reg.get16(REG_DPISET); dpihw = gl841_get_dpihw(dev); unsigned ccd_size_divisor = dev->session.ccd_size_divisor; factor=dpihw/dpiset; DBG(DBG_io2, "%s: dpihw=%d, dpiset=%d, ccd_size_divisor=%d, factor=%d\n", __func__, dpihw, dpiset, ccd_size_divisor, factor); /* turn pixel value into bytes 2x16 bits words */ strpixel*=2*2; /* 2 words of 2 bytes */ endpixel*=2*2; pixels=endpixel-strpixel; /* shading pixel begin is start pixel minus start pixel during shading * calibration. Currently only cases handled are full and half ccd resolution. */ beginpixel = sensor.ccd_start_xoffset / ccd_size_divisor; beginpixel += sensor.dummy_pixel + 1; DBG(DBG_io2, "%s: ORIGIN PIXEL=%d\n", __func__, beginpixel); beginpixel = (strpixel-beginpixel*2*2)/factor; DBG(DBG_io2, "%s: BEGIN PIXEL=%d\n", __func__, beginpixel/4); dev->interface->record_key_value("shading_offset", std::to_string(beginpixel)); dev->interface->record_key_value("shading_pixels", std::to_string(pixels)); dev->interface->record_key_value("shading_length", std::to_string(length)); DBG(DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n", __func__, length, length/4); std::vector buffer(pixels, 0); /* write actual shading data contigously * channel by channel, starting at addr 0x0000 * */ for(i=0;i<3;i++) { /* copy data to work buffer and process it */ /* coefficent destination */ ptr=buffer.data(); /* iterate on both sensor segment, data has been averaged, * so is in the right order and we only have to copy it */ for(x=0;xinterface->write_buffer(0x3c, 0x5400 * i, buffer.data(), pixels); } } bool CommandSetGl841::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const { (void) dev; return true; } void CommandSetGl841::wait_for_motor_stop(Genesys_Device* dev) const { (void) dev; } void CommandSetGl841::move_to_ta(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl841::asic_boot(Genesys_Device *dev, bool cold) const { (void) dev; (void) cold; throw SaneException("not implemented"); } std::unique_ptr create_gl841_cmd_set() { return std::unique_ptr(new CommandSetGl841{}); } } // namespace gl841 } // namespace genesys sane-backends-1.0.29/backend/genesys/scanner_interface_usb.h0000666000000000000000000000717313615534521020750 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_SCANNER_INTERFACE_USB_H #define BACKEND_GENESYS_SCANNER_INTERFACE_USB_H #include "scanner_interface.h" #include "usb_device.h" namespace genesys { class ScannerInterfaceUsb : public ScannerInterface { public: ScannerInterfaceUsb(Genesys_Device* dev); ~ScannerInterfaceUsb() override; bool is_mock() const override; std::uint8_t read_register(std::uint16_t address) override; void write_register(std::uint16_t address, std::uint8_t value) override; void write_registers(const Genesys_Register_Set& regs) override; void write_0x8c(std::uint8_t index, std::uint8_t value) override; void bulk_read_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) override; void bulk_write_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) override; void write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags) override; void write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags) override; void write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) override; std::uint16_t read_fe_register(std::uint8_t address) override; void write_fe_register(std::uint8_t address, std::uint16_t value) override; IUsbDevice& get_usb_device() override; void sleep_us(unsigned microseconds) override; void record_progress_message(const char* msg) override; void record_slope_table(unsigned table_nr, const std::vector& steps) override; void record_key_value(const std::string& key, const std::string& value) override; void test_checkpoint(const std::string& name) override; private: Genesys_Device* dev_; UsbDevice usb_dev_; }; } // namespace genesys #endif sane-backends-1.0.29/backend/genesys/genesys.cpp0000666000000000000000000063221013615534521016432 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2003, 2004 Henning Meier-Geinitz Copyright (C) 2004, 2005 Gerhard Jaeger Copyright (C) 2004-2016 Stéphane Voltz Copyright (C) 2005-2009 Pierre Willenbrock Copyright (C) 2006 Laurent Charpentier Copyright (C) 2007 Luke Copyright (C) 2010 Chris Berry and Michael Rickmann for Plustek Opticbook 3600 support Dynamic rasterization code was taken from the epjistsu backend by m. allan noah Software processing for deskew, crop and dspeckle are inspired by allan's noah work in the fujitsu backend 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* * SANE backend for Genesys Logic GL646/GL841/GL842/GL843/GL846/GL847/GL124 based scanners */ #define DEBUG_NOT_STATIC #include "genesys.h" #include "conv.h" #include "gl124_registers.h" #include "gl841_registers.h" #include "gl843_registers.h" #include "gl846_registers.h" #include "gl847_registers.h" #include "usb_device.h" #include "utilities.h" #include "scanner_interface_usb.h" #include "test_scanner_interface.h" #include "test_settings.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_magic.h" #include #include #include #include #include #include #include #include #include #ifndef SANE_GENESYS_API_LINKAGE #define SANE_GENESYS_API_LINKAGE extern "C" #endif namespace genesys { // Data that we allocate to back SANE_Device objects in s_sane_devices struct SANE_Device_Data { std::string name; }; namespace { StaticInit> s_scanners; StaticInit> s_sane_devices; StaticInit> s_sane_devices_data; StaticInit> s_sane_devices_ptrs; StaticInit> s_devices; // Maximum time for lamp warm-up constexpr unsigned WARMUP_TIME = 65; } // namespace static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_COLOR, SANE_VALUE_SCAN_MODE_GRAY, /* SANE_TITLE_HALFTONE, currently unused */ SANE_VALUE_SCAN_MODE_LINEART, nullptr }; static SANE_String_Const color_filter_list[] = { SANE_I18N ("Red"), SANE_I18N ("Green"), SANE_I18N ("Blue"), nullptr }; static SANE_String_Const cis_color_filter_list[] = { SANE_I18N ("Red"), SANE_I18N ("Green"), SANE_I18N ("Blue"), SANE_I18N ("None"), nullptr }; static SANE_Range swdespeck_range = { 1, 9, 1 }; static SANE_Range time_range = { 0, /* minimum */ 60, /* maximum */ 0 /* quantization */ }; static const SANE_Range u12_range = { 0, /* minimum */ 4095, /* maximum */ 0 /* quantization */ }; static const SANE_Range u14_range = { 0, /* minimum */ 16383, /* maximum */ 0 /* quantization */ }; static const SANE_Range u16_range = { 0, /* minimum */ 65535, /* maximum */ 0 /* quantization */ }; static const SANE_Range percentage_range = { SANE_FIX (0), /* minimum */ SANE_FIX (100), /* maximum */ SANE_FIX (1) /* quantization */ }; static const SANE_Range threshold_curve_range = { 0, /* minimum */ 127, /* maximum */ 1 /* quantization */ }; /** * range for brightness and contrast */ static const SANE_Range enhance_range = { -100, /* minimum */ 100, /* maximum */ 1 /* quantization */ }; /** * range for expiration time */ static const SANE_Range expiration_range = { -1, /* minimum */ 30000, /* maximum */ 1 /* quantization */ }; const Genesys_Sensor& sanei_genesys_find_sensor_any(Genesys_Device* dev) { DBG_HELPER(dbg); for (const auto& sensor : *s_sensors) { if (dev->model->sensor_id == sensor.sensor_id) { return sensor; } } throw std::runtime_error("Given device does not have sensor defined"); } Genesys_Sensor* find_sensor_impl(Genesys_Device* dev, unsigned dpi, unsigned channels, ScanMethod scan_method) { DBG_HELPER_ARGS(dbg, "dpi: %d, channels: %d, scan_method: %d", dpi, channels, static_cast(scan_method)); for (auto& sensor : *s_sensors) { if (dev->model->sensor_id == sensor.sensor_id && sensor.resolutions.matches(dpi) && sensor.matches_channel_count(channels) && sensor.method == scan_method) { return &sensor; } } return nullptr; } bool sanei_genesys_has_sensor(Genesys_Device* dev, unsigned dpi, unsigned channels, ScanMethod scan_method) { DBG_HELPER_ARGS(dbg, "dpi: %d, channels: %d, scan_method: %d", dpi, channels, static_cast(scan_method)); return find_sensor_impl(dev, dpi, channels, scan_method) != nullptr; } const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, unsigned dpi, unsigned channels, ScanMethod scan_method) { DBG_HELPER_ARGS(dbg, "dpi: %d, channels: %d, scan_method: %d", dpi, channels, static_cast(scan_method)); const auto* sensor = find_sensor_impl(dev, dpi, channels, scan_method); if (sensor) return *sensor; throw std::runtime_error("Given device does not have sensor defined"); } Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, unsigned dpi, unsigned channels, ScanMethod scan_method) { DBG_HELPER_ARGS(dbg, "dpi: %d, channels: %d, scan_method: %d", dpi, channels, static_cast(scan_method)); auto* sensor = find_sensor_impl(dev, dpi, channels, scan_method); if (sensor) return *sensor; throw std::runtime_error("Given device does not have sensor defined"); } std::vector> sanei_genesys_find_sensors_all(Genesys_Device* dev, ScanMethod scan_method) { DBG_HELPER_ARGS(dbg, "scan_method: %d", static_cast(scan_method)); std::vector> ret; for (const Genesys_Sensor& sensor : sanei_genesys_find_sensors_all_for_write(dev, scan_method)) { ret.push_back(sensor); } return ret; } std::vector> sanei_genesys_find_sensors_all_for_write(Genesys_Device* dev, ScanMethod scan_method) { DBG_HELPER_ARGS(dbg, "scan_method: %d", static_cast(scan_method)); std::vector> ret; for (auto& sensor : *s_sensors) { if (dev->model->sensor_id == sensor.sensor_id && sensor.method == scan_method) { ret.push_back(sensor); } } return ret; } void sanei_genesys_init_structs (Genesys_Device * dev) { DBG_HELPER(dbg); bool gpo_ok = false; bool motor_ok = false; bool fe_ok = false; /* initialize the GPO data stuff */ for (const auto& gpo : *s_gpo) { if (dev->model->gpio_id == gpo.id) { dev->gpo = gpo; gpo_ok = true; break; } } // initialize the motor data stuff for (const auto& motor : *s_motors) { if (dev->model->motor_id == motor.id) { dev->motor = motor; motor_ok = true; break; } } for (const auto& frontend : *s_frontends) { if (dev->model->adc_id == frontend.id) { dev->frontend_initial = frontend; dev->frontend = frontend; fe_ok = true; break; } } if (!motor_ok || !gpo_ok || !fe_ok) { throw SaneException("bad description(s) for fe/gpo/motor=%d/%d/%d\n", static_cast(dev->model->sensor_id), static_cast(dev->model->gpio_id), static_cast(dev->model->motor_id)); } } /* Generate slope table for motor movement */ /** * This function generates a slope table using the slope from the motor struct * truncated at the given exposure time or step count, whichever comes first. * The summed time of the acceleration steps is returned, and the * number of accerelation steps is put into used_steps. * * @param dev Device struct * @param slope_table Table to write to * @param step_type Generate table for this step_type. 0=>full, 1=>half, * 2=>quarter * @param exposure_time Minimum exposure time of a scan line * @param yres Resolution of a scan line * @param used_steps Final number of steps is stored here * @return Motor slope table * @note all times in pixel time */ MotorSlopeTable sanei_genesys_create_slope_table3(AsicType asic_type, const Genesys_Motor& motor, StepType step_type, int exposure_time, unsigned yres) { unsigned target_speed_w = (exposure_time * yres) / motor.base_ydpi; return create_slope_table(motor.get_slope(step_type), target_speed_w, step_type, 1, 1, get_slope_table_max_size(asic_type)); } /** @brief computes gamma table * Generates a gamma table of the given length within 0 and the given * maximum value * @param gamma_table gamma table to fill * @param size size of the table * @param maximum value allowed for gamma * @param gamma_max maximum gamma value * @param gamma gamma to compute values * @return a gamma table filled with the computed values * */ void sanei_genesys_create_gamma_table (std::vector& gamma_table, int size, float maximum, float gamma_max, float gamma) { gamma_table.clear(); gamma_table.resize(size, 0); int i; float value; DBG(DBG_proc, "%s: size = %d, ""maximum = %g, gamma_max = %g, gamma = %g\n", __func__, size, maximum, gamma_max, gamma); for (i = 0; i < size; i++) { value = static_cast(gamma_max * std::pow(static_cast(i) / size, 1.0 / gamma)); if (value > maximum) { value = maximum; } gamma_table[i] = static_cast(value); } DBG(DBG_proc, "%s: completed\n", __func__); } void sanei_genesys_create_default_gamma_table(Genesys_Device* dev, std::vector& gamma_table, float gamma) { int size = 0; int max = 0; if (dev->model->asic_type == AsicType::GL646) { if (dev->model->flags & GENESYS_FLAG_14BIT_GAMMA) { size = 16384; } else { size = 4096; } max = size - 1; } else if (dev->model->asic_type == AsicType::GL124 || dev->model->asic_type == AsicType::GL846 || dev->model->asic_type == AsicType::GL847) { size = 257; max = 65535; } else { size = 256; max = 65535; } sanei_genesys_create_gamma_table(gamma_table, size, max, max, gamma); } /* computes the exposure_time on the basis of the given vertical dpi, the number of pixels the ccd needs to send, the step_type and the corresponding maximum speed from the motor struct */ /* Currently considers maximum motor speed at given step_type, minimum line exposure needed for conversion and led exposure time. TODO: Should also consider maximum transfer rate: ~6.5MB/s. Note: The enhance option of the scanners does _not_ help. It only halves the amount of pixels transfered. */ SANE_Int sanei_genesys_exposure_time2(Genesys_Device * dev, float ydpi, StepType step_type, int endpixel, int exposure_by_led) { int exposure_by_ccd = endpixel + 32; unsigned max_speed_motor_w = dev->motor.get_slope(step_type).max_speed_w; int exposure_by_motor = static_cast((max_speed_motor_w * dev->motor.base_ydpi) / ydpi); int exposure = exposure_by_ccd; if (exposure < exposure_by_motor) exposure = exposure_by_motor; if (exposure < exposure_by_led && dev->model->is_cis) exposure = exposure_by_led; DBG(DBG_info, "%s: ydpi=%d, step=%d, endpixel=%d led=%d => exposure=%d\n", __func__, static_cast(ydpi), static_cast(step_type), endpixel, exposure_by_led, exposure); return exposure; } /* Sends a block of shading information to the scanner. The data is placed at address 0x0000 for color mode, gray mode and unconditionally for the following CCD chips: HP2300, HP2400 and HP5345 In the other cases (lineart, halftone on ccd chips not mentioned) the addresses are 0x2a00 for dpihw==0, 0x5500 for dpihw==1 and 0xa800 for dpihw==2. //Note: why this? The data needs to be of size "size", and in little endian byte order. */ static void genesys_send_offset_and_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) { DBG_HELPER_ARGS(dbg, "(size = %d)", size); int dpihw; int start_address; /* ASIC higher than gl843 doesn't have register 2A/2B, so we route to * a per ASIC shading data loading function if available. * It is also used for scanners using SHDAREA */ if (dev->cmd_set->has_send_shading_data()) { dev->cmd_set->send_shading_data(dev, sensor, data, size); return; } /* gl646, gl84[123] case */ dpihw = dev->reg.get8(0x05) >> 6; /* TODO invert the test so only the 2 models behaving like that are * tested instead of adding all the others */ /* many scanners send coefficient for lineart/gray like in color mode */ if ((dev->settings.scan_mode == ScanColorMode::LINEART || dev->settings.scan_mode == ScanColorMode::HALFTONE) && dev->model->sensor_id != SensorId::CCD_PLUSTEK_OPTICBOOK_3800 && dev->model->sensor_id != SensorId::CCD_KVSS080 && dev->model->sensor_id != SensorId::CCD_G4050 && dev->model->sensor_id != SensorId::CCD_HP_4850C && dev->model->sensor_id != SensorId::CCD_CANON_4400F && dev->model->sensor_id != SensorId::CCD_CANON_8400F && dev->model->sensor_id != SensorId::CCD_CANON_8600F && dev->model->sensor_id != SensorId::CCD_DSMOBILE600 && dev->model->sensor_id != SensorId::CCD_XP300 && dev->model->sensor_id != SensorId::CCD_DP665 && dev->model->sensor_id != SensorId::CCD_DP685 && dev->model->sensor_id != SensorId::CIS_CANON_LIDE_80 && dev->model->sensor_id != SensorId::CCD_ROADWARRIOR && dev->model->sensor_id != SensorId::CCD_HP2300 && dev->model->sensor_id != SensorId::CCD_HP2400 && dev->model->sensor_id != SensorId::CCD_HP3670 && dev->model->sensor_id != SensorId::CCD_5345) /* lineart, halftone */ { if (dpihw == 0) { /* 600 dpi */ start_address = 0x02a00; } else if (dpihw == 1) { /* 1200 dpi */ start_address = 0x05500; } else if (dpihw == 2) { /* 2400 dpi */ start_address = 0x0a800; } else { /* reserved */ throw SaneException("unknown dpihw"); } } else { // color start_address = 0x00; } dev->interface->write_buffer(0x3c, start_address, data, size); } // ? void sanei_genesys_init_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, int pixels_per_line) { DBG_HELPER_ARGS(dbg, "pixels_per_line: %d", pixels_per_line); if (dev->model->flags & GENESYS_FLAG_CALIBRATION_HOST_SIDE) { return; } int channels; int i; if (dev->cmd_set->has_send_shading_data()) { return; } DBG(DBG_proc, "%s (pixels_per_line = %d)\n", __func__, pixels_per_line); // BUG: GRAY shouldn't probably be in the if condition below. Discovered when refactoring if (dev->settings.scan_mode == ScanColorMode::GRAY || dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS) { channels = 3; } else { channels = 1; } // 16 bit black, 16 bit white std::vector shading_data(pixels_per_line * 4 * channels, 0); uint8_t* shading_data_ptr = shading_data.data(); for (i = 0; i < pixels_per_line * channels; i++) { *shading_data_ptr++ = 0x00; /* dark lo */ *shading_data_ptr++ = 0x00; /* dark hi */ *shading_data_ptr++ = 0x00; /* white lo */ *shading_data_ptr++ = 0x40; /* white hi -> 0x4000 */ } genesys_send_offset_and_shading(dev, sensor, shading_data.data(), pixels_per_line * 4 * channels); } // Find the position of the reference point: takes gray level 8 bits data and find // first CCD usable pixel and top of scanning area void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& sensor, const uint8_t* src_data, int start_pixel, int dpi, int width, int height) { DBG_HELPER(dbg); int x, y; int current, left, top = 0; int size, count; int level = 80; /* edge threshold level */ // sanity check if ((width < 3) || (height < 3)) { throw SaneException("invalid width or height"); } /* transformed image data */ size = width * height; std::vector image2(size, 0); std::vector image(size, 0); /* laplace filter to denoise picture */ std::memcpy(image2.data(), src_data, size); std::memcpy(image.data(), src_data, size); // to initialize unprocessed part of the image buffer for (y = 1; y < height - 1; y++) { for (x = 1; x < width - 1; x++) { image[y * width + x] = (image2[(y - 1) * width + x + 1] + 2 * image2[(y - 1) * width + x] + image2[(y - 1) * width + x - 1] + 2 * image2[y * width + x + 1] + 4 * image2[y * width + x] + 2 * image2[y * width + x - 1] + image2[(y + 1) * width + x + 1] + 2 * image2[(y + 1) * width + x] + image2[(y + 1) * width + x - 1]) / 16; } } image2 = image; if (DBG_LEVEL >= DBG_data) sanei_genesys_write_pnm_file("gl_laplace.pnm", image.data(), 8, 1, width, height); /* apply X direction sobel filter -1 0 1 -2 0 2 -1 0 1 and finds threshold level */ level = 0; for (y = 2; y < height - 2; y++) { for (x = 2; x < width - 2; x++) { current = image2[(y - 1) * width + x + 1] - image2[(y - 1) * width + x - 1] + 2 * image2[y * width + x + 1] - 2 * image2[y * width + x - 1] + image2[(y + 1) * width + x + 1] - image2[(y + 1) * width + x - 1]; if (current < 0) current = -current; if (current > 255) current = 255; image[y * width + x] = current; if (current > level) level = current; } } if (DBG_LEVEL >= DBG_data) sanei_genesys_write_pnm_file("gl_xsobel.pnm", image.data(), 8, 1, width, height); /* set up detection level */ level = level / 3; /* find left black margin first todo: search top before left we average the result of N searches */ left = 0; count = 0; for (y = 2; y < 11; y++) { x = 8; while ((x < width / 2) && (image[y * width + x] < level)) { image[y * width + x] = 255; x++; } count++; left += x; } if (DBG_LEVEL >= DBG_data) sanei_genesys_write_pnm_file("gl_detected-xsobel.pnm", image.data(), 8, 1, width, height); left = left / count; // turn it in CCD pixel at full sensor optical resolution sensor.ccd_start_xoffset = start_pixel + (left * sensor.optical_res) / dpi; /* find top edge by detecting black strip */ /* apply Y direction sobel filter -1 -2 -1 0 0 0 1 2 1 */ level = 0; for (y = 2; y < height - 2; y++) { for (x = 2; x < width - 2; x++) { current = -image2[(y - 1) * width + x + 1] - 2 * image2[(y - 1) * width + x] - image2[(y - 1) * width + x - 1] + image2[(y + 1) * width + x + 1] + 2 * image2[(y + 1) * width + x] + image2[(y + 1) * width + x - 1]; if (current < 0) current = -current; if (current > 255) current = 255; image[y * width + x] = current; if (current > level) level = current; } } if (DBG_LEVEL >= DBG_data) sanei_genesys_write_pnm_file("gl_ysobel.pnm", image.data(), 8, 1, width, height); /* set up detection level */ level = level / 3; /* search top of horizontal black stripe : TODO yet another flag */ if (dev->model->sensor_id == SensorId::CCD_5345 && dev->model->motor_id == MotorId::MD_5345) { top = 0; count = 0; for (x = width / 2; x < width - 1; x++) { y = 2; while ((y < height) && (image[x + y * width] < level)) { image[y * width + x] = 255; y++; } count++; top += y; } if (DBG_LEVEL >= DBG_data) sanei_genesys_write_pnm_file("gl_detected-ysobel.pnm", image.data(), 8, 1, width, height); top = top / count; /* bottom of black stripe is of fixed witdh, this hardcoded value * will be moved into device struct if more such values are needed */ top += 10; dev->model->y_offset_calib_white = (top * MM_PER_INCH) / dpi; DBG(DBG_info, "%s: black stripe y_offset = %f mm \n", __func__, dev->model->y_offset_calib_white.value()); } /* find white corner in dark area : TODO yet another flag */ if ((dev->model->sensor_id == SensorId::CCD_HP2300 && dev->model->motor_id == MotorId::HP2300) || (dev->model->sensor_id == SensorId::CCD_HP2400 && dev->model->motor_id == MotorId::HP2400) || (dev->model->sensor_id == SensorId::CCD_HP3670 && dev->model->motor_id == MotorId::HP3670)) { top = 0; count = 0; for (x = 10; x < 60; x++) { y = 2; while ((y < height) && (image[x + y * width] < level)) y++; top += y; count++; } top = top / count; dev->model->y_offset_calib_white = (top * MM_PER_INCH) / dpi; DBG(DBG_info, "%s: white corner y_offset = %f mm\n", __func__, dev->model->y_offset_calib_white.value()); } DBG(DBG_proc, "%s: ccd_start_xoffset = %d, left = %d, top = %d\n", __func__, sensor.ccd_start_xoffset, left, top); } namespace gl843 { void gl843_park_xpa_lamp(Genesys_Device* dev); void gl843_set_xpa_motor_power(Genesys_Device* dev, Genesys_Register_Set& regs, bool set); } // namespace gl843 namespace gl124 { void gl124_setup_scan_gpio(Genesys_Device* dev, int resolution); } // namespace gl124 void scanner_clear_scan_and_feed_counts(Genesys_Device& dev) { switch (dev.model->asic_type) { case AsicType::GL843: { dev.interface->write_register(gl843::REG_0x0D, gl843::REG_0x0D_CLRLNCNT | gl843::REG_0x0D_CLRMCNT); break; } case AsicType::GL845: case AsicType::GL846: { dev.interface->write_register(gl846::REG_0x0D, gl846::REG_0x0D_CLRLNCNT | gl846::REG_0x0D_CLRMCNT); break; } case AsicType::GL847:{ dev.interface->write_register(gl847::REG_0x0D, gl847::REG_0x0D_CLRLNCNT | gl847::REG_0x0D_CLRMCNT); break; } case AsicType::GL124:{ dev.interface->write_register(gl124::REG_0x0D, gl124::REG_0x0D_CLRLNCNT | gl124::REG_0x0D_CLRMCNT); break; } default: throw SaneException("Unsupported asic type"); } } void scanner_clear_scan_and_feed_counts2(Genesys_Device& dev) { // FIXME: switch to scanner_clear_scan_and_feed_counts when updating tests switch (dev.model->asic_type) { case AsicType::GL843: { dev.interface->write_register(gl843::REG_0x0D, gl843::REG_0x0D_CLRLNCNT); dev.interface->write_register(gl843::REG_0x0D, gl843::REG_0x0D_CLRMCNT); break; } case AsicType::GL845: case AsicType::GL846: { dev.interface->write_register(gl846::REG_0x0D, gl846::REG_0x0D_CLRLNCNT); dev.interface->write_register(gl846::REG_0x0D, gl846::REG_0x0D_CLRMCNT); break; } case AsicType::GL847: { dev.interface->write_register(gl847::REG_0x0D, gl847::REG_0x0D_CLRLNCNT); dev.interface->write_register(gl847::REG_0x0D, gl847::REG_0x0D_CLRMCNT); break; } case AsicType::GL124: { dev.interface->write_register(gl124::REG_0x0D, gl124::REG_0x0D_CLRLNCNT); dev.interface->write_register(gl124::REG_0x0D, gl124::REG_0x0D_CLRMCNT); break; } default: throw SaneException("Unsupported asic type"); } } bool scanner_is_motor_stopped(Genesys_Device& dev) { switch (dev.model->asic_type) { case AsicType::GL646: { auto status = scanner_read_status(dev); return !status.is_motor_enabled && status.is_feeding_finished; } case AsicType::GL841: { auto reg = dev.interface->read_register(gl841::REG_0x40); return (!(reg & gl841::REG_0x40_DATAENB) && !(reg & gl841::REG_0x40_MOTMFLG)); } case AsicType::GL843: { auto status = scanner_read_status(dev); auto reg = dev.interface->read_register(gl843::REG_0x40); return (!(reg & gl843::REG_0x40_DATAENB) && !(reg & gl843::REG_0x40_MOTMFLG) && !status.is_motor_enabled); } case AsicType::GL845: case AsicType::GL846: { auto status = scanner_read_status(dev); auto reg = dev.interface->read_register(gl846::REG_0x40); return (!(reg & gl846::REG_0x40_DATAENB) && !(reg & gl846::REG_0x40_MOTMFLG) && !status.is_motor_enabled); } case AsicType::GL847: { auto status = scanner_read_status(dev); auto reg = dev.interface->read_register(gl847::REG_0x40); return (!(reg & gl847::REG_0x40_DATAENB) && !(reg & gl847::REG_0x40_MOTMFLG) && !status.is_motor_enabled); } case AsicType::GL124: { auto status = scanner_read_status(dev); auto reg = dev.interface->read_register(gl124::REG_0x100); return (!(reg & gl124::REG_0x100_DATAENB) && !(reg & gl124::REG_0x100_MOTMFLG) && !status.is_motor_enabled); } default: throw SaneException("Unsupported asic type"); } } void scanner_stop_action(Genesys_Device& dev) { DBG_HELPER(dbg); switch (dev.model->asic_type) { case AsicType::GL843: case AsicType::GL845: case AsicType::GL846: case AsicType::GL847: case AsicType::GL124: break; default: throw SaneException("Unsupported asic type"); } if (dev.cmd_set->needs_update_home_sensor_gpio()) { dev.cmd_set->update_home_sensor_gpio(dev); } if (scanner_is_motor_stopped(dev)) { DBG(DBG_info, "%s: already stopped\n", __func__); return; } scanner_stop_action_no_move(dev, dev.reg); if (is_testing_mode()) { return; } for (unsigned i = 0; i < 10; ++i) { if (scanner_is_motor_stopped(dev)) { return; } dev.interface->sleep_ms(100); } throw SaneException(SANE_STATUS_IO_ERROR, "could not stop motor"); } void scanner_stop_action_no_move(Genesys_Device& dev, genesys::Genesys_Register_Set& regs) { switch (dev.model->asic_type) { case AsicType::GL646: case AsicType::GL841: case AsicType::GL843: case AsicType::GL845: case AsicType::GL846: case AsicType::GL847: case AsicType::GL124: break; default: throw SaneException("Unsupported asic type"); } regs_set_optical_off(dev.model->asic_type, regs); // same across all supported ASICs dev.interface->write_register(0x01, regs.get8(0x01)); // looks like certain scanners lock up if we try to scan immediately after stopping previous // action. dev.interface->sleep_ms(100); } void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, Direction direction) { DBG_HELPER_ARGS(dbg, "steps=%d direction=%d", steps, static_cast(direction)); auto local_reg = dev.reg; unsigned resolution = dev.model->get_resolution_settings(scan_method).get_min_resolution_y(); const auto& sensor = sanei_genesys_find_sensor(&dev, resolution, 3, scan_method); bool uses_secondary_head = (scan_method == ScanMethod::TRANSPARENCY || scan_method == ScanMethod::TRANSPARENCY_INFRARED); bool uses_secondary_pos = uses_secondary_head && dev.model->default_method == ScanMethod::FLATBED; if (!dev.is_head_pos_known(ScanHeadId::PRIMARY)) { throw SaneException("Unknown head position"); } if (uses_secondary_pos && !dev.is_head_pos_known(ScanHeadId::SECONDARY)) { throw SaneException("Unknown head position"); } if (direction == Direction::BACKWARD && steps > dev.head_pos(ScanHeadId::PRIMARY)) { throw SaneException("Trying to feed behind the home position %d %d", steps, dev.head_pos(ScanHeadId::PRIMARY)); } if (uses_secondary_pos && direction == Direction::BACKWARD && steps > dev.head_pos(ScanHeadId::SECONDARY)) { throw SaneException("Trying to feed behind the home position %d %d", steps, dev.head_pos(ScanHeadId::SECONDARY)); } ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = 0; session.params.starty = steps; session.params.pixels = 100; session.params.lines = 3; session.params.depth = 8; session.params.channels = 3; session.params.scan_method = scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; if (dev.model->asic_type == AsicType::GL843) { session.params.color_filter = ColorFilter::RED; } else { session.params.color_filter = dev.settings.color_filter; } session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::FEEDING | ScanFlag::IGNORE_LINE_DISTANCE; if (dev.model->asic_type == AsicType::GL124) { session.params.flags |= ScanFlag::DISABLE_BUFFER_FULL_MOVE; } if (direction == Direction::BACKWARD) { session.params.flags |= ScanFlag::REVERSE; } compute_session(&dev, session, sensor); dev.cmd_set->init_regs_for_scan_session(&dev, sensor, &local_reg, session); if (dev.model->asic_type != AsicType::GL843) { regs_set_exposure(dev.model->asic_type, local_reg, {0, 0, 0}); } scanner_clear_scan_and_feed_counts2(dev); dev.interface->write_registers(local_reg); if (uses_secondary_head) { gl843::gl843_set_xpa_motor_power(&dev, local_reg, true); } try { scanner_start_action(dev, true); } catch (...) { catch_all_exceptions(__func__, [&]() { gl843::gl843_set_xpa_motor_power(&dev, local_reg, false); }); catch_all_exceptions(__func__, [&]() { scanner_stop_action(dev); }); // restore original registers catch_all_exceptions(__func__, [&]() { dev.interface->write_registers(dev.reg); }); throw; } if (is_testing_mode()) { dev.interface->test_checkpoint("feed"); dev.advance_head_pos_by_steps(ScanHeadId::PRIMARY, direction, steps); if (uses_secondary_pos) { dev.advance_head_pos_by_steps(ScanHeadId::SECONDARY, direction, steps); } // FIXME: why don't we stop the scanner like on other ASICs if (dev.model->asic_type != AsicType::GL843) { scanner_stop_action(dev); } if (uses_secondary_head) { gl843::gl843_set_xpa_motor_power(&dev, local_reg, false); } return; } // wait until feed count reaches the required value // FIXME: should porbably wait for some timeout Status status; for (unsigned i = 0;; ++i) { status = scanner_read_status(dev); if (status.is_feeding_finished || ( direction == Direction::BACKWARD && status.is_at_home)) { break; } dev.interface->sleep_ms(10); } // FIXME: why don't we stop the scanner like on other ASICs if (dev.model->asic_type != AsicType::GL843) { scanner_stop_action(dev); } if (uses_secondary_head) { gl843::gl843_set_xpa_motor_power(&dev, local_reg, false); } dev.advance_head_pos_by_steps(ScanHeadId::PRIMARY, direction, steps); if (uses_secondary_pos) { dev.advance_head_pos_by_steps(ScanHeadId::SECONDARY, direction, steps); } // looks like certain scanners lock up if we scan immediately after feeding dev.interface->sleep_ms(100); } void scanner_move_back_home(Genesys_Device& dev, bool wait_until_home) { DBG_HELPER_ARGS(dbg, "wait_until_home = %d", wait_until_home); switch (dev.model->asic_type) { case AsicType::GL843: case AsicType::GL845: case AsicType::GL846: case AsicType::GL847: case AsicType::GL124: break; default: throw SaneException("Unsupported asic type"); } // FIXME: also check whether the scanner actually has a secondary head if (!dev.is_head_pos_known(ScanHeadId::SECONDARY) || dev.head_pos(ScanHeadId::SECONDARY) > 0 || dev.settings.scan_method == ScanMethod::TRANSPARENCY || dev.settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { scanner_move_back_home_ta(dev); } if (dev.is_head_pos_known(ScanHeadId::PRIMARY) && dev.head_pos(ScanHeadId::PRIMARY) > 1000) { // leave 500 steps for regular slow back home scanner_move(dev, dev.model->default_method, dev.head_pos(ScanHeadId::PRIMARY) - 500, Direction::BACKWARD); } if (dev.cmd_set->needs_update_home_sensor_gpio()) { dev.cmd_set->update_home_sensor_gpio(dev); } auto status = scanner_read_reliable_status(dev); if (status.is_at_home) { dbg.log(DBG_info, "already at home"); dev.set_head_pos_zero(ScanHeadId::PRIMARY); return; } if (dev.model->model_id == ModelId::CANON_LIDE_210) { // move the head back a little first if (dev.is_head_pos_known(ScanHeadId::PRIMARY) && dev.head_pos(ScanHeadId::PRIMARY) > 30) { scanner_move(dev, dev.model->default_method, 20, Direction::BACKWARD); } } Genesys_Register_Set local_reg = dev.reg; unsigned resolution = sanei_genesys_get_lowest_ydpi(&dev); const auto& sensor = sanei_genesys_find_sensor(&dev, resolution, 1, dev.model->default_method); ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = 100; if (dev.model->asic_type == AsicType::GL843) { session.params.starty = 40000; } else { session.params.starty = 30000; } session.params.pixels = 100; session.params.lines = 100; session.params.depth = 8; session.params.channels = 1; session.params.scan_method = dev.settings.scan_method; if (dev.model->asic_type == AsicType::GL843) { session.params.scan_mode = ScanColorMode::LINEART; session.params.color_filter = dev.settings.color_filter; } else { session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::RED; } session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::IGNORE_LINE_DISTANCE | ScanFlag::REVERSE; if (dev.model->asic_type == AsicType::GL843) { session.params.flags |= ScanFlag::DISABLE_BUFFER_FULL_MOVE; } compute_session(&dev, session, sensor); dev.cmd_set->init_regs_for_scan_session(&dev, sensor, &local_reg, session); scanner_clear_scan_and_feed_counts(dev); dev.interface->write_registers(local_reg); if (dev.model->asic_type == AsicType::GL124) { gl124::gl124_setup_scan_gpio(&dev, resolution); } try { scanner_start_action(dev, true); } catch (...) { catch_all_exceptions(__func__, [&]() { scanner_stop_action(dev); }); // restore original registers catch_all_exceptions(__func__, [&]() { dev.interface->write_registers(dev.reg); }); throw; } if (dev.cmd_set->needs_update_home_sensor_gpio()) { dev.cmd_set->update_home_sensor_gpio(dev); } if (is_testing_mode()) { dev.interface->test_checkpoint("move_back_home"); dev.set_head_pos_zero(ScanHeadId::PRIMARY); return; } if (wait_until_home) { for (unsigned i = 0; i < 300; ++i) { auto status = scanner_read_status(dev); if (status.is_at_home) { dbg.log(DBG_info, "reached home position"); if (dev.model->asic_type == AsicType::GL846 || dev.model->asic_type == AsicType::GL847) { scanner_stop_action(dev); } dev.set_head_pos_zero(ScanHeadId::PRIMARY); return; } dev.interface->sleep_ms(100); } // when we come here then the scanner needed too much time for this, so we better stop // the motor catch_all_exceptions(__func__, [&](){ scanner_stop_action(dev); }); dev.set_head_pos_unknown(); throw SaneException(SANE_STATUS_IO_ERROR, "timeout while waiting for scanhead to go home"); } dbg.log(DBG_info, "scanhead is still moving"); } void scanner_move_back_home_ta(Genesys_Device& dev) { DBG_HELPER(dbg); switch (dev.model->asic_type) { case AsicType::GL843: break; default: throw SaneException("Unsupported asic type"); } Genesys_Register_Set local_reg = dev.reg; auto scan_method = ScanMethod::TRANSPARENCY; unsigned resolution = dev.model->get_resolution_settings(scan_method).get_min_resolution_y(); const auto& sensor = sanei_genesys_find_sensor(&dev, resolution, 1, scan_method); if (dev.is_head_pos_known(ScanHeadId::SECONDARY) && dev.head_pos(ScanHeadId::SECONDARY) > 1000) { // leave 500 steps for regular slow back home scanner_move(dev, scan_method, dev.head_pos(ScanHeadId::SECONDARY) - 500, Direction::BACKWARD); } ScanSession session; session.params.xres = resolution; session.params.yres = resolution; session.params.startx = 100; session.params.starty = 30000; session.params.pixels = 100; session.params.lines = 100; session.params.depth = 8; session.params.channels = 1; session.params.scan_method = scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::RED; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::IGNORE_LINE_DISTANCE | ScanFlag::REVERSE; compute_session(&dev, session, sensor); dev.cmd_set->init_regs_for_scan_session(&dev, sensor, &local_reg, session); scanner_clear_scan_and_feed_counts(dev); dev.interface->write_registers(local_reg); gl843::gl843_set_xpa_motor_power(&dev, local_reg, true); try { scanner_start_action(dev, true); } catch (...) { catch_all_exceptions(__func__, [&]() { scanner_stop_action(dev); }); // restore original registers catch_all_exceptions(__func__, [&]() { dev.interface->write_registers(dev.reg); }); throw; } if (is_testing_mode()) { dev.interface->test_checkpoint("move_back_home_ta"); if (dev.is_head_pos_known(ScanHeadId::PRIMARY)) { if (dev.head_pos(ScanHeadId::PRIMARY) > dev.head_pos(ScanHeadId::SECONDARY)) { dev.advance_head_pos_by_steps(ScanHeadId::PRIMARY, Direction::BACKWARD, dev.head_pos(ScanHeadId::SECONDARY)); } else { dev.set_head_pos_zero(ScanHeadId::PRIMARY); } dev.set_head_pos_zero(ScanHeadId::SECONDARY); } scanner_stop_action(dev); gl843::gl843_set_xpa_motor_power(&dev, local_reg, false); return; } for (unsigned i = 0; i < 1200; ++i) { auto status = scanner_read_status(dev); if (status.is_at_home) { dbg.log(DBG_info, "TA reached home position"); if (dev.is_head_pos_known(ScanHeadId::PRIMARY)) { if (dev.head_pos(ScanHeadId::PRIMARY) > dev.head_pos(ScanHeadId::SECONDARY)) { dev.advance_head_pos_by_steps(ScanHeadId::PRIMARY, Direction::BACKWARD, dev.head_pos(ScanHeadId::SECONDARY)); } else { dev.set_head_pos_zero(ScanHeadId::PRIMARY); } dev.set_head_pos_zero(ScanHeadId::SECONDARY); } scanner_stop_action(dev); gl843::gl843_set_xpa_motor_power(&dev, local_reg, false); return; } dev.interface->sleep_ms(100); } throw SaneException("Timeout waiting for XPA lamp to park"); } void sanei_genesys_calculate_zmod(bool two_table, uint32_t exposure_time, const std::vector& slope_table, unsigned acceleration_steps, unsigned move_steps, unsigned buffer_acceleration_steps, uint32_t* out_z1, uint32_t* out_z2) { DBG(DBG_info, "%s: two_table=%d\n", __func__, two_table); // acceleration total time unsigned sum = std::accumulate(slope_table.begin(), slope_table.begin() + acceleration_steps, 0, std::plus()); /* Z1MOD: c = sum(slope_table; reg_stepno) d = reg_fwdstep * Z1MOD = (c+d) % exposure_time */ *out_z1 = (sum + buffer_acceleration_steps * slope_table[acceleration_steps - 1]) % exposure_time; /* Z2MOD: a = sum(slope_table; reg_stepno) b = move_steps or 1 if 2 tables Z1MOD = (a+b) % exposure_time */ if (!two_table) { sum = sum + (move_steps * slope_table[acceleration_steps - 1]); } else { sum = sum + slope_table[acceleration_steps - 1]; } *out_z2 = sum % exposure_time; } static uint8_t genesys_adjust_gain(double* applied_multi, double multi, uint8_t gain) { double voltage, original_voltage; uint8_t new_gain = 0; DBG(DBG_proc, "%s: multi=%f, gain=%d\n", __func__, multi, gain); voltage = 0.5 + gain * 0.25; original_voltage = voltage; voltage *= multi; new_gain = static_cast((voltage - 0.5) * 4); if (new_gain > 0x0e) new_gain = 0x0e; voltage = 0.5 + (new_gain) * 0.25; *applied_multi = voltage / original_voltage; DBG(DBG_proc, "%s: orig voltage=%.2f, new voltage=%.2f, *applied_multi=%f, new_gain=%d\n", __func__, original_voltage, voltage, *applied_multi, new_gain); return new_gain; } // todo: is return status necessary (unchecked?) static void genesys_average_white(Genesys_Device* dev, Genesys_Sensor& sensor, int channels, int channel, uint8_t* data, int size, int *max_average) { DBG_HELPER_ARGS(dbg, "channels=%d, channel=%d, size=%d", channels, channel, size); int gain_white_ref, sum, range; int average; int i; range = size / 50; if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { gain_white_ref = sensor.fau_gain_white_ref * 256; } else { gain_white_ref = sensor.gain_white_ref * 256; } if (range < 1) range = 1; size = size / (2 * range * channels); data += (channel * 2); *max_average = 0; while (size--) { sum = 0; for (i = 0; i < range; i++) { sum += (*data); sum += *(data + 1) * 256; data += (2 * channels); /* byte based */ } average = (sum / range); if (average > *max_average) *max_average = average; } DBG(DBG_proc, "%s: max_average=%d, gain_white_ref = %d, finished\n", __func__, *max_average, gain_white_ref); if (*max_average >= gain_white_ref) throw SaneException(SANE_STATUS_INVAL); } /* todo: understand, values are too high */ static int genesys_average_black (Genesys_Device * dev, int channel, uint8_t * data, int pixels) { int i; int sum; int pixel_step; DBG(DBG_proc, "%s: channel=%d, pixels=%d\n", __func__, channel, pixels); sum = 0; if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS) { data += (channel * 2); pixel_step = 3 * 2; } else { pixel_step = 2; } for (i = 0; i < pixels; i++) { sum += *data; sum += *(data + 1) * 256; data += pixel_step; } DBG(DBG_proc, "%s = %d\n", __func__, sum / pixels); return sum / pixels; } // todo: check; it works but the lines 1, 2, and 3 are too dark even with the // same offset and gain settings? static void genesys_coarse_calibration(Genesys_Device* dev, Genesys_Sensor& sensor) { DBG_HELPER_ARGS(dbg, "scan_mode = %d", static_cast(dev->settings.scan_mode)); int black_pixels; int white_average; uint8_t offset[4] = { 0xa0, 0x00, 0xa0, 0x40 }; /* first value isn't used */ uint16_t white[12], dark[12]; int i, j; black_pixels = sensor.black_pixels * dev->settings.xres / sensor.optical_res; unsigned channels = dev->settings.get_channels(); DBG(DBG_info, "channels %d y_size %f xres %d\n", channels, dev->model->y_size.value(), dev->settings.xres); unsigned size = static_cast(channels * 2 * dev->model->y_size * dev->settings.xres / MM_PER_INCH); /* 1 1 mm 1/inch inch/mm */ std::vector calibration_data(size); std::vector all_data(size * 4, 1); dev->cmd_set->set_fe(dev, sensor, AFE_INIT); dev->frontend.set_gain(0, 2); dev->frontend.set_gain(1, 2); dev->frontend.set_gain(2, 2); // TODO: ? was 2 dev->frontend.set_offset(0, offset[0]); dev->frontend.set_offset(1, offset[0]); dev->frontend.set_offset(2, offset[0]); for (i = 0; i < 4; i++) /* read 4 lines */ { if (i < 3) /* first 3 lines */ { dev->frontend.set_offset(0, offset[i]); dev->frontend.set_offset(1, offset[i]); dev->frontend.set_offset(2, offset[i]); } if (i == 1) /* second line */ { double applied_multi; double gain_white_ref; if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { gain_white_ref = sensor.fau_gain_white_ref * 256; } else { gain_white_ref = sensor.gain_white_ref * 256; } // white and black are defined downwards uint8_t gain0 = genesys_adjust_gain(&applied_multi, gain_white_ref / (white[0] - dark[0]), dev->frontend.get_gain(0)); uint8_t gain1 = genesys_adjust_gain(&applied_multi, gain_white_ref / (white[1] - dark[1]), dev->frontend.get_gain(1)); uint8_t gain2 = genesys_adjust_gain(&applied_multi, gain_white_ref / (white[2] - dark[2]), dev->frontend.get_gain(2)); // FIXME: looks like overwritten data. Are the above calculations doing // anything at all? dev->frontend.set_gain(0, gain0); dev->frontend.set_gain(1, gain1); dev->frontend.set_gain(2, gain2); dev->frontend.set_gain(0, 2); dev->frontend.set_gain(1, 2); dev->frontend.set_gain(2, 2); dev->interface->write_fe_register(0x28, dev->frontend.get_gain(0)); dev->interface->write_fe_register(0x29, dev->frontend.get_gain(1)); dev->interface->write_fe_register(0x2a, dev->frontend.get_gain(2)); } if (i == 3) /* last line */ { double x, y, rate; for (j = 0; j < 3; j++) { x = static_cast(dark[(i - 2) * 3 + j] - dark[(i - 1) * 3 + j]) * 254 / (offset[i - 1] / 2 - offset[i - 2] / 2); y = x - x * (offset[i - 1] / 2) / 254 - dark[(i - 1) * 3 + j]; rate = (x - DARK_VALUE - y) * 254 / x + 0.5; uint8_t curr_offset = static_cast(rate); if (curr_offset > 0x7f) { curr_offset = 0x7f; } curr_offset <<= 1; dev->frontend.set_offset(j, curr_offset); } } dev->interface->write_fe_register(0x20, dev->frontend.get_offset(0)); dev->interface->write_fe_register(0x21, dev->frontend.get_offset(1)); dev->interface->write_fe_register(0x22, dev->frontend.get_offset(2)); DBG(DBG_info, "%s: doing scan: gain: %d/%d/%d, offset: %d/%d/%d\n", __func__, dev->frontend.get_gain(0), dev->frontend.get_gain(1), dev->frontend.get_gain(2), dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); dev->cmd_set->begin_scan(dev, sensor, &dev->calib_reg, false); if (is_testing_mode()) { dev->interface->test_checkpoint("coarse_calibration"); dev->cmd_set->end_scan(dev, &dev->calib_reg, true); return; } sanei_genesys_read_data_from_scanner(dev, calibration_data.data(), size); std::memcpy(all_data.data() + i * size, calibration_data.data(), size); if (i == 3) /* last line */ { std::vector all_data_8(size * 4 / 2); unsigned int count; for (count = 0; count < static_cast(size * 4 / 2); count++) { all_data_8[count] = all_data[count * 2 + 1]; } sanei_genesys_write_pnm_file("gl_coarse.pnm", all_data_8.data(), 8, channels, size / 6, 4); } dev->cmd_set->end_scan(dev, &dev->calib_reg, true); if (dev->settings.scan_mode == ScanColorMode::COLOR_SINGLE_PASS) { for (j = 0; j < 3; j++) { genesys_average_white(dev, sensor, 3, j, calibration_data.data(), size, &white_average); white[i * 3 + j] = white_average; dark[i * 3 + j] = genesys_average_black (dev, j, calibration_data.data(), black_pixels); DBG(DBG_info, "%s: white[%d]=%d, black[%d]=%d\n", __func__, i * 3 + j, white[i * 3 + j], i * 3 + j, dark[i * 3 + j]); } } else /* one color-component modes */ { genesys_average_white(dev, sensor, 1, 0, calibration_data.data(), size, &white_average); white[i * 3 + 0] = white[i * 3 + 1] = white[i * 3 + 2] = white_average; dark[i * 3 + 0] = dark[i * 3 + 1] = dark[i * 3 + 2] = genesys_average_black (dev, 0, calibration_data.data(), black_pixels); } } /* for (i = 0; i < 4; i++) */ DBG(DBG_info, "%s: final: gain: %d/%d/%d, offset: %d/%d/%d\n", __func__, dev->frontend.get_gain(0), dev->frontend.get_gain(1), dev->frontend.get_gain(2), dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); } /** * scans a white area with motor and lamp off to get the per CCD pixel offset * that will be used to compute shading coefficient * @param dev scanner's device */ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_Sensor& sensor, std::vector& out_average_data, bool is_dark, const std::string& log_filename_prefix) { DBG_HELPER(dbg); debug_dump(DBG_info, dev->calib_session); size_t size; uint32_t pixels_per_line; uint8_t channels; /* end pixel - start pixel */ pixels_per_line = dev->calib_pixels; channels = dev->calib_channels; uint32_t out_pixels_per_line = pixels_per_line + dev->calib_pixels_offset; // FIXME: we set this during both dark and white calibration. A cleaner approach should // probably be used dev->average_size = channels * out_pixels_per_line; out_average_data.clear(); out_average_data.resize(dev->average_size); if (is_dark && dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { // FIXME: dark shading currently not supported on infrared transparency scans return; } // FIXME: the current calculation is likely incorrect on non-GL843 implementations, // but this needs checking if (dev->calib_total_bytes_to_read > 0) { size = dev->calib_total_bytes_to_read; } else if (dev->model->asic_type == AsicType::GL843) { size = channels * 2 * pixels_per_line * dev->calib_lines; } else { size = channels * 2 * pixels_per_line * (dev->calib_lines + 1); } std::vector calibration_data(size / 2); bool motor = true; if (dev->model->flags & GENESYS_FLAG_SHADING_NO_MOVE) { motor = false; } // turn off motor and lamp power for flatbed scanners, but not for sheetfed scanners // because they have a calibration sheet with a sufficient black strip if (is_dark && !dev->model->is_sheetfed) { sanei_genesys_set_lamp_power(dev, sensor, dev->calib_reg, false); sanei_genesys_set_motor_power(dev->calib_reg, motor); } else { sanei_genesys_set_lamp_power(dev, sensor, dev->calib_reg, true); sanei_genesys_set_motor_power(dev->calib_reg, motor); } dev->interface->write_registers(dev->calib_reg); if (is_dark) { // wait some time to let lamp to get dark dev->interface->sleep_ms(200); } else if (dev->model->flags & GENESYS_FLAG_DARK_CALIBRATION) { // make sure lamp is bright again // FIXME: what about scanners that take a long time to warm the lamp? dev->interface->sleep_ms(500); } bool start_motor = !is_dark; dev->cmd_set->begin_scan(dev, sensor, &dev->calib_reg, start_motor); if (is_testing_mode()) { dev->interface->test_checkpoint(is_dark ? "dark_shading_calibration" : "white_shading_calibration"); dev->cmd_set->end_scan(dev, &dev->calib_reg, true); return; } sanei_genesys_read_data_from_scanner(dev, reinterpret_cast(calibration_data.data()), size); dev->cmd_set->end_scan(dev, &dev->calib_reg, true); if (dev->model->flags & GENESYS_FLAG_16BIT_DATA_INVERTED) { for (std::size_t i = 0; i < size / 2; ++i) { auto value = calibration_data[i]; value = ((value >> 8) & 0xff) | ((value << 8) & 0xff00); calibration_data[i] = value; } } std::fill(out_average_data.begin(), out_average_data.begin() + dev->calib_pixels_offset * channels, 0); compute_array_percentile_approx(out_average_data.data() + dev->calib_pixels_offset * channels, calibration_data.data(), dev->calib_lines, pixels_per_line * channels, 0.5f); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file16((log_filename_prefix + "_shading.pnm").c_str(), calibration_data.data(), channels, pixels_per_line, dev->calib_lines); sanei_genesys_write_pnm_file16((log_filename_prefix + "_average.pnm").c_str(), out_average_data.data(), channels, out_pixels_per_line, 1); } } static void genesys_dark_shading_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); genesys_shading_calibration_impl(dev, sensor, dev->dark_average_data, true, "gl_black_"); } /* * this function builds dummy dark calibration data so that we can * compute shading coefficient in a clean way * todo: current values are hardcoded, we have to find if they * can be computed from previous calibration data (when doing offset * calibration ?) */ static void genesys_dummy_dark_shading(Genesys_Device* dev, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); uint32_t pixels_per_line; uint8_t channels; uint32_t skip, xend; int dummy1, dummy2, dummy3; /* dummy black average per channel */ pixels_per_line = dev->calib_pixels; channels = dev->calib_channels; uint32_t out_pixels_per_line = pixels_per_line + dev->calib_pixels_offset; dev->average_size = channels * out_pixels_per_line; dev->dark_average_data.clear(); dev->dark_average_data.resize(dev->average_size, 0); /* we average values on 'the left' where CCD pixels are under casing and give darkest values. We then use these as dummy dark calibration */ if (dev->settings.xres <= sensor.optical_res / 2) { skip = 4; xend = 36; } else { skip = 4; xend = 68; } if (dev->model->sensor_id==SensorId::CCD_G4050 || dev->model->sensor_id==SensorId::CCD_HP_4850C || dev->model->sensor_id==SensorId::CCD_CANON_4400F || dev->model->sensor_id==SensorId::CCD_CANON_8400F || dev->model->sensor_id==SensorId::CCD_KVSS080) { skip = 2; xend = sensor.black_pixels; } /* average each channels on half left margin */ dummy1 = 0; dummy2 = 0; dummy3 = 0; for (unsigned x = skip + 1; x <= xend; x++) { dummy1 += dev->white_average_data[channels * x]; if (channels > 1) { dummy2 += dev->white_average_data[channels * x + 1]; dummy3 += dev->white_average_data[channels * x + 2]; } } dummy1 /= (xend - skip); if (channels > 1) { dummy2 /= (xend - skip); dummy3 /= (xend - skip); } DBG(DBG_proc, "%s: dummy1=%d, dummy2=%d, dummy3=%d \n", __func__, dummy1, dummy2, dummy3); /* fill dark_average */ for (unsigned x = 0; x < out_pixels_per_line; x++) { dev->dark_average_data[channels * x] = dummy1; if (channels > 1) { dev->dark_average_data[channels * x + 1] = dummy2; dev->dark_average_data[channels * x + 2] = dummy3; } } } static void genesys_repark_sensor_before_shading(Genesys_Device* dev) { DBG_HELPER(dbg); if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK) { dev->cmd_set->move_back_home(dev, true); if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { dev->cmd_set->move_to_ta(dev); } } } static void genesys_repark_sensor_after_white_shading(Genesys_Device* dev) { DBG_HELPER(dbg); if (dev->model->flags & GENESYS_FLAG_SHADING_REPARK) { dev->cmd_set->move_back_home(dev, true); } } static void genesys_white_shading_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); genesys_shading_calibration_impl(dev, sensor, dev->white_average_data, false, "gl_white_"); } // This calibration uses a scan over the calibration target, comprising a black and a white strip. // (So the motor must be on.) static void genesys_dark_white_shading_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor) { DBG_HELPER_ARGS(dbg, "lines = %zu", dev->calib_lines); size_t size; uint32_t pixels_per_line; uint8_t channels; unsigned int x; uint32_t dark, white, dark_sum, white_sum, dark_count, white_count, col, dif; pixels_per_line = dev->calib_pixels; channels = dev->calib_channels; uint32_t out_pixels_per_line = pixels_per_line + dev->calib_pixels_offset; dev->average_size = channels * out_pixels_per_line; dev->white_average_data.clear(); dev->white_average_data.resize(dev->average_size); dev->dark_average_data.clear(); dev->dark_average_data.resize(dev->average_size); if (dev->calib_total_bytes_to_read > 0) size = dev->calib_total_bytes_to_read; else size = channels * 2 * pixels_per_line * dev->calib_lines; std::vector calibration_data(size); bool motor = true; if (dev->model->flags & GENESYS_FLAG_SHADING_NO_MOVE) { motor = false; } // turn on motor and lamp power sanei_genesys_set_lamp_power(dev, sensor, dev->calib_reg, true); sanei_genesys_set_motor_power(dev->calib_reg, motor); dev->interface->write_registers(dev->calib_reg); dev->cmd_set->begin_scan(dev, sensor, &dev->calib_reg, false); if (is_testing_mode()) { dev->interface->test_checkpoint("dark_white_shading_calibration"); dev->cmd_set->end_scan(dev, &dev->calib_reg, true); return; } sanei_genesys_read_data_from_scanner(dev, calibration_data.data(), size); dev->cmd_set->end_scan(dev, &dev->calib_reg, true); if (DBG_LEVEL >= DBG_data) { if (dev->model->is_cis) { sanei_genesys_write_pnm_file("gl_black_white_shading.pnm", calibration_data.data(), 16, 1, pixels_per_line*channels, dev->calib_lines); } else { sanei_genesys_write_pnm_file("gl_black_white_shading.pnm", calibration_data.data(), 16, channels, pixels_per_line, dev->calib_lines); } } std::fill(dev->dark_average_data.begin(), dev->dark_average_data.begin() + dev->calib_pixels_offset * channels, 0); std::fill(dev->white_average_data.begin(), dev->white_average_data.begin() + dev->calib_pixels_offset * channels, 0); uint16_t* average_white = dev->white_average_data.data() + dev->calib_pixels_offset * channels; uint16_t* average_dark = dev->dark_average_data.data() + dev->calib_pixels_offset * channels; for (x = 0; x < pixels_per_line * channels; x++) { dark = 0xffff; white = 0; for (std::size_t y = 0; y < dev->calib_lines; y++) { col = calibration_data[(x + y * pixels_per_line * channels) * 2]; col |= calibration_data[(x + y * pixels_per_line * channels) * 2 + 1] << 8; if (col > white) white = col; if (col < dark) dark = col; } dif = white - dark; dark = dark + dif / 8; white = white - dif / 8; dark_count = 0; dark_sum = 0; white_count = 0; white_sum = 0; for (std::size_t y = 0; y < dev->calib_lines; y++) { col = calibration_data[(x + y * pixels_per_line * channels) * 2]; col |= calibration_data[(x + y * pixels_per_line * channels) * 2 + 1] << 8; if (col >= white) { white_sum += col; white_count++; } if (col <= dark) { dark_sum += col; dark_count++; } } dark_sum /= dark_count; white_sum /= white_count; *average_dark++ = dark_sum; *average_white++ = white_sum; } if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file16("gl_white_average.pnm", dev->white_average_data.data(), channels, out_pixels_per_line, 1); sanei_genesys_write_pnm_file16("gl_dark_average.pnm", dev->dark_average_data.data(), channels, out_pixels_per_line, 1); } } /* computes one coefficient given bright-dark value * @param coeff factor giving 1.00 gain * @param target desired target code * @param value brght-dark value * */ static unsigned int compute_coefficient (unsigned int coeff, unsigned int target, unsigned int value) { int result; if (value > 0) { result = (coeff * target) / value; if (result >= 65535) { result = 65535; } } else { result = coeff; } return result; } /** @brief compute shading coefficients for LiDE scanners * The dark/white shading is actually performed _after_ reducing * resolution via averaging. only dark/white shading data for what would be * first pixel at full resolution is used. * * scanner raw input to output value calculation: * o=(i-off)*(gain/coeff) * * from datasheet: * off=dark_average * gain=coeff*bright_target/(bright_average-dark_average) * works for dark_target==0 * * what we want is these: * bright_target=(bright_average-off)*(gain/coeff) * dark_target=(dark_average-off)*(gain/coeff) * leading to * off = (dark_average*bright_target - bright_average*dark_target)/(bright_target - dark_target) * gain = (bright_target - dark_target)/(bright_average - dark_average)*coeff * * @param dev scanner's device * @param shading_data memory area where to store the computed shading coefficients * @param pixels_per_line number of pixels per line * @param words_per_color memory words per color channel * @param channels number of color channels (actually 1 or 3) * @param o shading coefficients left offset * @param coeff 4000h or 2000h depending on fast scan mode or not (GAIN4 bit) * @param target_bright value of the white target code * @param target_dark value of the black target code */ static void compute_averaged_planar (Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t * shading_data, unsigned int pixels_per_line, unsigned int words_per_color, unsigned int channels, unsigned int o, unsigned int coeff, unsigned int target_bright, unsigned int target_dark) { unsigned int x, i, j, br, dk, res, avgpixels, basepixels, val; unsigned int fill,factor; 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); /* strangely i can write 0x20000 bytes beginning at 0x00000 without overwriting slope tables - which begin at address 0x10000(for 1200dpi hw mode): memory is organized in words(2 bytes) instead of single bytes. explains quite some things */ /* another one: the dark/white shading is actually performed _after_ reducing resolution via averaging. only dark/white shading data for what would be first pixel at full resolution is used. */ /* scanner raw input to output value calculation: o=(i-off)*(gain/coeff) from datasheet: off=dark_average gain=coeff*bright_target/(bright_average-dark_average) works for dark_target==0 what we want is these: bright_target=(bright_average-off)*(gain/coeff) dark_target=(dark_average-off)*(gain/coeff) leading to off = (dark_average*bright_target - bright_average*dark_target)/(bright_target - dark_target) gain = (bright_target - dark_target)/(bright_average - dark_average)*coeff */ res = dev->settings.xres; if (sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres) > 1) { res *= 2; } /* this should be evenly dividable */ basepixels = sensor.optical_res / res; /* gl841 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */ if (basepixels < 1) avgpixels = 1; else if (basepixels < 6) avgpixels = basepixels; else if (basepixels < 8) avgpixels = 6; else if (basepixels < 10) avgpixels = 8; else if (basepixels < 12) avgpixels = 10; else if (basepixels < 15) avgpixels = 12; else avgpixels = 15; /* LiDE80 packs shading data */ if (dev->model->sensor_id != SensorId::CIS_CANON_LIDE_80) { factor=1; fill=avgpixels; } else { factor=avgpixels; fill=1; } 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) { if ((x + o) * 2 * 2 + 3 > words_per_color * 2) break; for (j = 0; j < channels; j++) { dk = 0; br = 0; for (i = 0; i < avgpixels; i++) { // dark data dk += dev->dark_average_data[(x + i + pixels_per_line * j)]; // white data br += dev->white_average_data[(x + i + pixels_per_line * j)]; } br /= avgpixels; dk /= avgpixels; if (br * target_dark > dk * target_bright) val = 0; else if (dk * target_bright - br * target_dark > 65535 * (target_bright - target_dark)) val = 65535; else { val = (dk * target_bright - br * target_dark) / (target_bright - target_dark); } /*fill all pixels, even if only the last one is relevant*/ for (i = 0; i < fill; i++) { shading_data[(x/factor + o + i) * 2 * 2 + words_per_color * 2 * j] = val & 0xff; shading_data[(x/factor + o + i) * 2 * 2 + words_per_color * 2 * j + 1] = val >> 8; } val = br - dk; if (65535 * val > (target_bright - target_dark) * coeff) { val = (coeff * (target_bright - target_dark)) / val; } else { val = 65535; } /*fill all pixels, even if only the last one is relevant*/ for (i = 0; i < fill; i++) { shading_data[(x/factor + o + i) * 2 * 2 + words_per_color * 2 * j + 2] = val & 0xff; shading_data[(x/factor + o + i) * 2 * 2 + words_per_color * 2 * j + 3] = val >> 8; } } /* fill remaining channels */ for (j = channels; j < 3; j++) { for (i = 0; i < fill; i++) { shading_data[(x/factor + o + i) * 2 * 2 + words_per_color * 2 * j ] = shading_data[(x/factor + o + i) * 2 * 2 ]; shading_data[(x/factor + o + i) * 2 * 2 + words_per_color * 2 * j + 1] = shading_data[(x/factor + o + i) * 2 * 2 + 1]; shading_data[(x/factor + o + i) * 2 * 2 + words_per_color * 2 * j + 2] = shading_data[(x/factor + o + i) * 2 * 2 + 2]; shading_data[(x/factor + o + i) * 2 * 2 + words_per_color * 2 * j + 3] = shading_data[(x/factor + o + i) * 2 * 2 + 3]; } } } } static std::array color_order_to_cmat(ColorOrder color_order) { switch (color_order) { case ColorOrder::RGB: return {0, 1, 2}; case ColorOrder::GBR: return {2, 0, 1}; default: throw std::logic_error("Unknown color order"); } } /** * Computes shading coefficient using formula in data sheet. 16bit data values * manipulated here are little endian. For now we assume deletion scanning type * and that there is always 3 channels. * @param dev scanner's device * @param shading_data memory area where to store the computed shading coefficients * @param pixels_per_line number of pixels per line * @param channels number of color channels (actually 1 or 3) * @param cmat color transposition matrix * @param offset shading coefficients left offset * @param coeff 4000h or 2000h depending on fast scan mode or not * @param target value of the target code */ static void compute_coefficients(Genesys_Device * dev, uint8_t * shading_data, unsigned int pixels_per_line, unsigned int channels, ColorOrder color_order, int offset, unsigned int coeff, unsigned int target) { uint8_t *ptr; /* contain 16bit words in little endian */ unsigned int x, c; unsigned int val, br, dk; unsigned int start, end; DBG(DBG_io, "%s: pixels_per_line=%d, coeff=0x%04x\n", __func__, pixels_per_line, coeff); auto cmat = color_order_to_cmat(color_order); /* compute start & end values depending of the offset */ if (offset < 0) { start = -1 * offset; end = pixels_per_line; } else { start = 0; end = pixels_per_line - offset; } for (c = 0; c < channels; c++) { for (x = start; x < end; x++) { /* TODO if channels=1 , use filter to know the base addr */ ptr = shading_data + 4 * ((x + offset) * channels + cmat[c]); // dark data dk = dev->dark_average_data[x * channels + c]; // white data br = dev->white_average_data[x * channels + c]; /* compute coeff */ val=compute_coefficient(coeff,target,br-dk); /* assign it */ ptr[0] = dk & 255; ptr[1] = dk / 256; ptr[2] = val & 0xff; ptr[3] = val / 256; } } } /** * Computes shading coefficient using formula in data sheet. 16bit data values * manipulated here are little endian. Data is in planar form, ie grouped by * lines of the same color component. * @param dev scanner's device * @param shading_data memory area where to store the computed shading coefficients * @param factor averaging factor when the calibration scan is done at a higher resolution * than the final scan * @param pixels_per_line number of pixels per line * @param words_per_color total number of shading data words for one color element * @param channels number of color channels (actually 1 or 3) * @param cmat transcoding matrix for color channel order * @param offset shading coefficients left offset * @param coeff 4000h or 2000h depending on fast scan mode or not * @param target white target value */ static void compute_planar_coefficients(Genesys_Device * dev, uint8_t * shading_data, unsigned int factor, unsigned int pixels_per_line, unsigned int words_per_color, unsigned int channels, ColorOrder color_order, unsigned int offset, unsigned int coeff, unsigned int target) { uint8_t *ptr; /* contains 16bit words in little endian */ uint32_t x, c, i; uint32_t val, dk, br; auto cmat = color_order_to_cmat(color_order); DBG(DBG_io, "%s: factor=%d, pixels_per_line=%d, words=0x%X, coeff=0x%04x\n", __func__, factor, pixels_per_line, words_per_color, coeff); for (c = 0; c < channels; c++) { /* shading data is larger than pixels_per_line so offset can be neglected */ for (x = 0; x < pixels_per_line; x+=factor) { /* x2 because of 16 bit values, and x2 since one coeff for dark * and another for white */ ptr = shading_data + words_per_color * cmat[c] * 2 + (x + offset) * 4; dk = 0; br = 0; /* average case */ for(i=0;idark_average_data[((x+i) + pixels_per_line * c)]; br += dev->white_average_data[((x+i) + pixels_per_line * c)]; } dk /= factor; br /= factor; val = compute_coefficient (coeff, target, br - dk); /* we duplicate the information to have calibration data at optical resolution */ for (i = 0; i < factor; i++) { ptr[0 + 4 * i] = dk & 255; ptr[1 + 4 * i] = dk / 256; ptr[2 + 4 * i] = val & 0xff; ptr[3 + 4 * i] = val / 256; } } } /* in case of gray level scan, we duplicate shading information on all * three color channels */ if(channels==1) { memcpy(shading_data+cmat[1]*2*words_per_color, shading_data+cmat[0]*2*words_per_color, words_per_color*2); memcpy(shading_data+cmat[2]*2*words_per_color, shading_data+cmat[0]*2*words_per_color, words_per_color*2); } } static void compute_shifted_coefficients (Genesys_Device * dev, const Genesys_Sensor& sensor, uint8_t * shading_data, unsigned int pixels_per_line, unsigned int channels, ColorOrder color_order, int offset, unsigned int coeff, unsigned int target_dark, unsigned int target_bright, unsigned int patch_size) /* contigous extent */ { unsigned int x, avgpixels, basepixels, i, j, val1, val2; unsigned int br_tmp [3], dk_tmp [3]; uint8_t *ptr = shading_data + offset * 3 * 4; /* contain 16bit words in little endian */ unsigned int patch_cnt = offset * 3; /* at start, offset of first patch */ auto cmat = color_order_to_cmat(color_order); x = dev->settings.xres; if (sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres) > 1) x *= 2; /* scanner is using half-ccd mode */ basepixels = sensor.optical_res / x; /*this should be evenly dividable */ /* gl841 supports 1/1 1/2 1/3 1/4 1/5 1/6 1/8 1/10 1/12 1/15 averaging */ if (basepixels < 1) avgpixels = 1; else if (basepixels < 6) avgpixels = basepixels; else if (basepixels < 8) avgpixels = 6; else if (basepixels < 10) avgpixels = 8; else if (basepixels < 12) avgpixels = 10; else if (basepixels < 15) avgpixels = 12; else avgpixels = 15; DBG(DBG_info, "%s: pixels_per_line=%d, coeff=0x%04x, averaging over %d pixels\n", __func__, pixels_per_line, coeff, avgpixels); for (x = 0; x <= pixels_per_line - avgpixels; x += avgpixels) { memset (&br_tmp, 0, sizeof(br_tmp)); memset (&dk_tmp, 0, sizeof(dk_tmp)); for (i = 0; i < avgpixels; i++) { for (j = 0; j < channels; j++) { br_tmp[j] += dev->white_average_data[((x + i) * channels + j)]; dk_tmp[i] += dev->dark_average_data[((x + i) * channels + j)]; } } for (j = 0; j < channels; j++) { br_tmp[j] /= avgpixels; dk_tmp[j] /= avgpixels; if (br_tmp[j] * target_dark > dk_tmp[j] * target_bright) val1 = 0; else if (dk_tmp[j] * target_bright - br_tmp[j] * target_dark > 65535 * (target_bright - target_dark)) val1 = 65535; else val1 = (dk_tmp[j] * target_bright - br_tmp[j] * target_dark) / (target_bright - target_dark); val2 = br_tmp[j] - dk_tmp[j]; if (65535 * val2 > (target_bright - target_dark) * coeff) val2 = (coeff * (target_bright - target_dark)) / val2; else val2 = 65535; br_tmp[j] = val1; dk_tmp[j] = val2; } for (i = 0; i < avgpixels; i++) { for (j = 0; j < channels; j++) { * ptr++ = br_tmp[ cmat[j] ] & 0xff; * ptr++ = br_tmp[ cmat[j] ] >> 8; * ptr++ = dk_tmp[ cmat[j] ] & 0xff; * ptr++ = dk_tmp[ cmat[j] ] >> 8; patch_cnt++; if (patch_cnt == patch_size) { patch_cnt = 0; val1 = cmat[2]; cmat[2] = cmat[1]; cmat[1] = cmat[0]; cmat[0] = val1; } } } } } static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); if (dev->model->flags & GENESYS_FLAG_CALIBRATION_HOST_SIDE) { return; } uint32_t pixels_per_line; uint8_t channels; int o; unsigned int length; /**> number of shading calibration data words */ unsigned int factor; unsigned int coeff, target_code, words_per_color = 0; pixels_per_line = dev->calib_pixels + dev->calib_pixels_offset; channels = dev->calib_channels; /* we always build data for three channels, even for gray * we make the shading data such that each color channel data line is contiguous * to the next one, which allow to write the 3 channels in 1 write * during genesys_send_shading_coefficient, some values are words, other bytes * hence the x2 factor */ switch (dev->reg.get8(0x05) >> 6) { /* 600 dpi */ case 0: words_per_color = 0x2a00; break; /* 1200 dpi */ case 1: words_per_color = 0x5500; break; /* 2400 dpi */ case 2: words_per_color = 0xa800; break; /* 4800 dpi */ case 3: words_per_color = 0x15000; break; } /* special case, memory is aligned on 0x5400, this has yet to be explained */ /* could be 0xa800 because sensor is truly 2400 dpi, then halved because * we only set 1200 dpi */ if(dev->model->sensor_id==SensorId::CIS_CANON_LIDE_80) { words_per_color = 0x5400; } length = words_per_color * 3 * 2; /* allocate computed size */ // contains 16bit words in little endian std::vector shading_data(length, 0); /* TARGET/(Wn-Dn) = white gain -> ~1.xxx then it is multiplied by 0x2000 or 0x4000 to give an integer Wn = white average for column n Dn = dark average for column n */ if (get_registers_gain4_bit(dev->model->asic_type, dev->calib_reg)) { coeff = 0x4000; } else { coeff = 0x2000; } /* compute avg factor */ if(dev->settings.xres>sensor.optical_res) { factor=1; } else { factor=sensor.optical_res/dev->settings.xres; } /* for GL646, shading data is planar if REG_0x01_FASTMOD is set and * chunky if not. For now we rely on the fact that we know that * each sensor is used only in one mode. Currently only the CIS_XP200 * sets REG_0x01_FASTMOD. */ /* TODO setup a struct in genesys_devices that * will handle these settings instead of having this switch growing up */ switch (dev->model->sensor_id) { case SensorId::CCD_XP300: case SensorId::CCD_ROADWARRIOR: case SensorId::CCD_DP665: case SensorId::CCD_DP685: case SensorId::CCD_DSMOBILE600: target_code = 0xdc00; o = 4; compute_planar_coefficients (dev, shading_data.data(), factor, pixels_per_line, words_per_color, channels, ColorOrder::RGB, o, coeff, target_code); break; case SensorId::CIS_XP200: target_code = 0xdc00; o = 2; compute_planar_coefficients (dev, shading_data.data(), 1, pixels_per_line, words_per_color, channels, ColorOrder::GBR, o, coeff, target_code); break; case SensorId::CCD_HP2300: target_code = 0xdc00; o = 2; if(dev->settings.xres<=sensor.optical_res/2) { o = o - sensor.dummy_pixel / 2; } compute_coefficients (dev, shading_data.data(), pixels_per_line, 3, ColorOrder::RGB, o, coeff, target_code); break; case SensorId::CCD_5345: target_code = 0xe000; o = 4; if(dev->settings.xres<=sensor.optical_res/2) { o = o - sensor.dummy_pixel; } compute_coefficients (dev, shading_data.data(), pixels_per_line, 3, ColorOrder::RGB, o, coeff, target_code); break; case SensorId::CCD_HP3670: case SensorId::CCD_HP2400: target_code = 0xe000; // offset is dependent on ccd_pixels_per_system_pixel(), but we couldn't use this in // common code previously. // FIXME: use sensor.ccd_pixels_per_system_pixel() if(dev->settings.xres<=300) { o = -10; } else if(dev->settings.xres<=600) { o = -6; } else { o = +2; } compute_coefficients (dev, shading_data.data(), pixels_per_line, 3, ColorOrder::RGB, o, coeff, target_code); break; case SensorId::CCD_KVSS080: case SensorId::CCD_PLUSTEK_OPTICBOOK_3800: case SensorId::CCD_G4050: case SensorId::CCD_HP_4850C: case SensorId::CCD_CANON_4400F: case SensorId::CCD_CANON_8400F: case SensorId::CCD_CANON_8600F: case SensorId::CCD_PLUSTEK_OPTICFILM_7200I: case SensorId::CCD_PLUSTEK_OPTICFILM_7300: case SensorId::CCD_PLUSTEK_OPTICFILM_7500I: target_code = 0xe000; o = 0; compute_coefficients (dev, shading_data.data(), pixels_per_line, 3, ColorOrder::RGB, o, coeff, target_code); break; case SensorId::CIS_CANON_LIDE_700F: case SensorId::CIS_CANON_LIDE_100: case SensorId::CIS_CANON_LIDE_200: case SensorId::CIS_CANON_LIDE_110: case SensorId::CIS_CANON_LIDE_120: case SensorId::CIS_CANON_LIDE_210: case SensorId::CIS_CANON_LIDE_220: /* TODO store this in a data struct so we avoid * growing this switch */ switch(dev->model->sensor_id) { case SensorId::CIS_CANON_LIDE_110: case SensorId::CIS_CANON_LIDE_120: case SensorId::CIS_CANON_LIDE_210: case SensorId::CIS_CANON_LIDE_220: case SensorId::CIS_CANON_LIDE_700F: target_code = 0xc000; break; default: target_code = 0xdc00; } words_per_color=pixels_per_line*2; length = words_per_color * 3 * 2; shading_data.clear(); shading_data.resize(length, 0); compute_planar_coefficients (dev, shading_data.data(), 1, pixels_per_line, words_per_color, channels, ColorOrder::RGB, 0, coeff, target_code); break; case SensorId::CIS_CANON_LIDE_35: compute_averaged_planar (dev, sensor, shading_data.data(), pixels_per_line, words_per_color, channels, 4, coeff, 0xe000, 0x0a00); break; case SensorId::CIS_CANON_LIDE_80: compute_averaged_planar (dev, sensor, shading_data.data(), pixels_per_line, words_per_color, channels, 0, coeff, 0xe000, 0x0800); break; case SensorId::CCD_PLUSTEK_OPTICPRO_3600: compute_shifted_coefficients (dev, sensor, shading_data.data(), pixels_per_line, channels, ColorOrder::RGB, 12, /* offset */ coeff, 0x0001, /* target_dark */ 0xf900, /* target_bright */ 256); /* patch_size: contigous extent */ break; default: throw SaneException(SANE_STATUS_UNSUPPORTED, "sensor %d not supported", static_cast(dev->model->sensor_id)); break; } // do the actual write of shading calibration data to the scanner genesys_send_offset_and_shading(dev, sensor, shading_data.data(), length); } /** * search calibration cache list for an entry matching required scan. * If one is found, set device calibration with it * @param dev scanner's device * @return false if no matching cache entry has been * found, true if one has been found and used. */ static bool genesys_restore_calibration(Genesys_Device * dev, Genesys_Sensor& sensor) { DBG_HELPER(dbg); // if no cache or no function to evaluate cache entry ther can be no match/ if (dev->calibration_cache.empty()) { return false; } auto session = dev->cmd_set->calculate_scan_session(dev, sensor, dev->settings); /* we walk the link list of calibration cache in search for a * matching one */ for (auto& cache : dev->calibration_cache) { if (sanei_genesys_is_compatible_calibration(dev, session, &cache, false)) { dev->frontend = cache.frontend; /* we don't restore the gamma fields */ sensor.exposure = cache.sensor.exposure; dev->average_size = cache.average_size; dev->calib_pixels = cache.calib_pixels; dev->calib_channels = cache.calib_channels; dev->dark_average_data = cache.dark_average_data; dev->white_average_data = cache.white_average_data; if (!dev->cmd_set->has_send_shading_data()) { genesys_send_shading_coefficient(dev, sensor); } DBG(DBG_proc, "%s: restored\n", __func__); return true; } } DBG(DBG_proc, "%s: completed(nothing found)\n", __func__); return false; } static void genesys_save_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); #ifdef HAVE_SYS_TIME_H struct timeval time; #endif auto session = dev->cmd_set->calculate_scan_session(dev, sensor, dev->settings); auto found_cache_it = dev->calibration_cache.end(); for (auto cache_it = dev->calibration_cache.begin(); cache_it != dev->calibration_cache.end(); cache_it++) { if (sanei_genesys_is_compatible_calibration(dev, session, &*cache_it, true)) { found_cache_it = cache_it; break; } } /* if we found on overridable cache, we reuse it */ if (found_cache_it == dev->calibration_cache.end()) { /* create a new cache entry and insert it in the linked list */ dev->calibration_cache.push_back(Genesys_Calibration_Cache()); found_cache_it = std::prev(dev->calibration_cache.end()); } found_cache_it->average_size = dev->average_size; found_cache_it->dark_average_data = dev->dark_average_data; found_cache_it->white_average_data = dev->white_average_data; found_cache_it->params = session.params; found_cache_it->frontend = dev->frontend; found_cache_it->sensor = sensor; found_cache_it->calib_pixels = dev->calib_pixels; found_cache_it->calib_channels = dev->calib_channels; #ifdef HAVE_SYS_TIME_H gettimeofday(&time, nullptr); found_cache_it->last_calibration = time.tv_sec; #endif } /** * does the calibration process for a flatbed scanner * - offset calibration * - gain calibration * - shading calibration * @param dev device to calibrate */ static void genesys_flatbed_calibration(Genesys_Device* dev, Genesys_Sensor& sensor) { DBG_HELPER(dbg); uint32_t pixels_per_line; unsigned coarse_res = sensor.optical_res; if (dev->settings.yres <= sensor.optical_res / 2) { coarse_res /= 2; } if (dev->model->model_id == ModelId::CANON_8400F) { coarse_res = 1600; } if (dev->model->model_id == ModelId::CANON_4400F || dev->model->model_id == ModelId::CANON_8600F) { coarse_res = 1200; } /* do offset calibration if needed */ if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION) { dev->interface->record_progress_message("offset_calibration"); dev->cmd_set->offset_calibration(dev, sensor, dev->calib_reg); /* since all the registers are set up correctly, just use them */ dev->interface->record_progress_message("coarse_gain_calibration"); dev->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, coarse_res); } else { /* since we have 2 gain calibration proc, skip second if first one was used. */ dev->interface->record_progress_message("init_regs_for_coarse_calibration"); dev->cmd_set->init_regs_for_coarse_calibration(dev, sensor, dev->calib_reg); dev->interface->record_progress_message("genesys_coarse_calibration"); genesys_coarse_calibration(dev, sensor); } if (dev->model->is_cis) { /* the afe now sends valid data for doing led calibration */ dev->interface->record_progress_message("led_calibration"); switch (dev->model->asic_type) { case AsicType::GL124: case AsicType::GL845: case AsicType::GL846: case AsicType::GL847: { auto calib_exposure = dev->cmd_set->led_calibration(dev, sensor, dev->calib_reg); for (auto& sensor_update : sanei_genesys_find_sensors_all_for_write(dev, sensor.method)) { sensor_update.get().exposure = calib_exposure; } sensor.exposure = calib_exposure; break; } default: { sensor.exposure = dev->cmd_set->led_calibration(dev, sensor, dev->calib_reg); } } /* calibrate afe again to match new exposure */ if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION) { dev->interface->record_progress_message("offset_calibration"); dev->cmd_set->offset_calibration(dev, sensor, dev->calib_reg); // since all the registers are set up correctly, just use them dev->interface->record_progress_message("coarse_gain_calibration"); dev->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, coarse_res); } else { // since we have 2 gain calibration proc, skip second if first one was used dev->interface->record_progress_message("init_regs_for_coarse_calibration"); dev->cmd_set->init_regs_for_coarse_calibration(dev, sensor, dev->calib_reg); dev->interface->record_progress_message("genesys_coarse_calibration"); genesys_coarse_calibration(dev, sensor); } } /* we always use sensor pixel number when the ASIC can't handle multi-segments sensor */ if (!(dev->model->flags & GENESYS_FLAG_SIS_SENSOR)) { pixels_per_line = static_cast((dev->model->x_size * dev->settings.xres) / MM_PER_INCH); } else { pixels_per_line = sensor.sensor_pixels; } // send default shading data dev->interface->record_progress_message("sanei_genesys_init_shading_data"); sanei_genesys_init_shading_data(dev, sensor, pixels_per_line); if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { dev->cmd_set->move_to_ta(dev); } // shading calibration if (dev->model->flags & GENESYS_FLAG_DARK_WHITE_CALIBRATION) { dev->interface->record_progress_message("init_regs_for_shading"); dev->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg); dev->interface->record_progress_message("genesys_dark_white_shading_calibration"); genesys_dark_white_shading_calibration(dev, sensor); } else { DBG(DBG_proc, "%s : genesys_dark_shading_calibration dev->calib_reg ", __func__); debug_dump(DBG_proc, dev->calib_reg); if (dev->model->flags & GENESYS_FLAG_DARK_CALIBRATION) { dev->interface->record_progress_message("init_regs_for_shading"); dev->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg); dev->interface->record_progress_message("genesys_dark_shading_calibration"); genesys_dark_shading_calibration(dev, sensor); genesys_repark_sensor_before_shading(dev); } dev->interface->record_progress_message("init_regs_for_shading2"); dev->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg); dev->interface->record_progress_message("genesys_white_shading_calibration"); genesys_white_shading_calibration(dev, sensor); genesys_repark_sensor_after_white_shading(dev); if (!(dev->model->flags & GENESYS_FLAG_DARK_CALIBRATION)) { genesys_dummy_dark_shading(dev, sensor); } } if (!dev->cmd_set->has_send_shading_data()) { dev->interface->record_progress_message("genesys_send_shading_coefficient"); genesys_send_shading_coefficient(dev, sensor); } } /** * Does the calibration process for a sheetfed scanner * - offset calibration * - gain calibration * - shading calibration * During calibration a predefined calibration sheet with specific black and white * areas is used. * @param dev device to calibrate */ static void genesys_sheetfed_calibration(Genesys_Device* dev, Genesys_Sensor& sensor) { DBG_HELPER(dbg); bool forward = true; // first step, load document dev->cmd_set->load_document(dev); /* led, offset and gain calibration are influenced by scan * settings. So we set it to sensor resolution */ dev->settings.xres = sensor.optical_res; /* XP200 needs to calibrate a full and half sensor's resolution */ if (dev->model->sensor_id == SensorId::CIS_XP200 && dev->settings.xres <= sensor.optical_res / 2) { dev->settings.xres /= 2; } /* the afe needs to sends valid data even before calibration */ /* go to a white area */ try { dev->cmd_set->search_strip(dev, sensor, forward, false); } catch (...) { catch_all_exceptions(__func__, [&](){ dev->cmd_set->eject_document(dev); }); throw; } if (dev->model->is_cis) { dev->cmd_set->led_calibration(dev, sensor, dev->calib_reg); } /* calibrate afe */ if (dev->model->flags & GENESYS_FLAG_OFFSET_CALIBRATION) { dev->cmd_set->offset_calibration(dev, sensor, dev->calib_reg); /* since all the registers are set up correctly, just use them */ dev->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, sensor.optical_res); } else /* since we have 2 gain calibration proc, skip second if first one was used. */ { dev->cmd_set->init_regs_for_coarse_calibration(dev, sensor, dev->calib_reg); genesys_coarse_calibration(dev, sensor); } /* search for a full width black strip and then do a 16 bit scan to * gather black shading data */ if (dev->model->flags & GENESYS_FLAG_DARK_CALIBRATION) { /* seek black/white reverse/forward */ try { dev->cmd_set->search_strip(dev, sensor, forward, true); } catch (...) { catch_all_exceptions(__func__, [&](){ dev->cmd_set->eject_document(dev); }); throw; } dev->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg); try { genesys_dark_shading_calibration(dev, sensor); } catch (...) { catch_all_exceptions(__func__, [&](){ dev->cmd_set->eject_document(dev); }); throw; } forward = false; } /* go to a white area */ try { dev->cmd_set->search_strip(dev, sensor, forward, false); } catch (...) { catch_all_exceptions(__func__, [&](){ dev->cmd_set->eject_document(dev); }); throw; } genesys_repark_sensor_before_shading(dev); dev->cmd_set->init_regs_for_shading(dev, sensor, dev->calib_reg); try { genesys_white_shading_calibration(dev, sensor); genesys_repark_sensor_after_white_shading(dev); } catch (...) { catch_all_exceptions(__func__, [&](){ dev->cmd_set->eject_document(dev); }); throw; } // in case we haven't black shading data, build it from black pixels of white calibration // FIXME: shouldn't we use genesys_dummy_dark_shading() ? if (!(dev->model->flags & GENESYS_FLAG_DARK_CALIBRATION)) { dev->dark_average_data.clear(); dev->dark_average_data.resize(dev->average_size, 0x0f0f); /* XXX STEF XXX * with black point in white shading, build an average black * pixel and use it to fill the dark_average * dev->calib_pixels (sensor.sensor_pixels * dev->settings.xres) / sensor.optical_res, dev->calib_lines, */ } /* send the shading coefficient when doing whole line shading * but not when using SHDAREA like GL124 */ if (!dev->cmd_set->has_send_shading_data()) { genesys_send_shading_coefficient(dev, sensor); } // save the calibration data genesys_save_calibration(dev, sensor); // and finally eject calibration sheet dev->cmd_set->eject_document(dev); // restore settings dev->settings.xres = sensor.optical_res; } /** * does the calibration process for a device * @param dev device to calibrate */ static void genesys_scanner_calibration(Genesys_Device* dev, Genesys_Sensor& sensor) { DBG_HELPER(dbg); if (!dev->model->is_sheetfed) { genesys_flatbed_calibration(dev, sensor); return; } genesys_sheetfed_calibration(dev, sensor); } /* ------------------------------------------------------------------------ */ /* High level (exported) functions */ /* ------------------------------------------------------------------------ */ /* * wait lamp to be warm enough by scanning the same line until * differences between two scans are below a threshold */ static void genesys_warmup_lamp(Genesys_Device* dev) { DBG_HELPER(dbg); unsigned seconds = 0; int pixel; int channels, total_size; double first_average = 0; double second_average = 0; int difference = 255; int lines = 3; const auto& sensor = sanei_genesys_find_sensor_any(dev); dev->cmd_set->init_regs_for_warmup(dev, sensor, &dev->reg, &channels, &total_size); std::vector first_line(total_size); std::vector second_line(total_size); do { DBG(DBG_info, "%s: one more loop\n", __func__); dev->cmd_set->begin_scan(dev, sensor, &dev->reg, false); if (is_testing_mode()) { dev->interface->test_checkpoint("warmup_lamp"); dev->cmd_set->end_scan(dev, &dev->reg, true); return; } wait_until_buffer_non_empty(dev); try { sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size); } catch (...) { // FIXME: document why this retry is here sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size); } dev->cmd_set->end_scan(dev, &dev->reg, true); dev->interface->sleep_ms(1000); seconds++; dev->cmd_set->begin_scan(dev, sensor, &dev->reg, false); wait_until_buffer_non_empty(dev); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); dev->cmd_set->end_scan(dev, &dev->reg, true); /* compute difference between the two scans */ for (pixel = 0; pixel < total_size; pixel++) { // 16 bit data if (dev->session.params.depth == 16) { first_average += (first_line[pixel] + first_line[pixel + 1] * 256); second_average += (second_line[pixel] + second_line[pixel + 1] * 256); pixel++; } else { first_average += first_line[pixel]; second_average += second_line[pixel]; } } if (dev->session.params.depth == 16) { first_average /= pixel; second_average /= pixel; difference = static_cast(std::fabs(first_average - second_average)); DBG(DBG_info, "%s: average = %.2f, diff = %.3f\n", __func__, 100 * ((second_average) / (256 * 256)), 100 * (difference / second_average)); if (second_average > (100 * 256) && (difference / second_average) < 0.002) break; } else { first_average /= pixel; second_average /= pixel; if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl_warmup1.pnm", first_line.data(), 8, channels, total_size / (lines * channels), lines); sanei_genesys_write_pnm_file("gl_warmup2.pnm", second_line.data(), 8, channels, total_size / (lines * channels), lines); } DBG(DBG_info, "%s: average 1 = %.2f, average 2 = %.2f\n", __func__, first_average, second_average); /* if delta below 15/255 ~= 5.8%, lamp is considred warm enough */ if (fabs (first_average - second_average) < 15 && second_average > 55) break; } /* sleep another second before next loop */ dev->interface->sleep_ms(1000); seconds++; } while (seconds < WARMUP_TIME); if (seconds >= WARMUP_TIME) { throw SaneException(SANE_STATUS_IO_ERROR, "warmup timed out after %d seconds. Lamp defective?", seconds); } else { DBG(DBG_info, "%s: warmup succeeded after %d seconds\n", __func__, seconds); } } // High-level start of scanning static void genesys_start_scan(Genesys_Device* dev, bool lamp_off) { DBG_HELPER(dbg); unsigned int steps, expected; /* since not all scanners are set ot wait for head to park * we check we are not still parking before starting a new scan */ if (dev->parking) { sanei_genesys_wait_for_home(dev); } // disable power saving dev->cmd_set->save_power(dev, false); /* wait for lamp warmup : until a warmup for TRANSPARENCY is designed, skip * it when scanning from XPA. */ if (!(dev->model->flags & GENESYS_FLAG_SKIP_WARMUP) && (dev->settings.scan_method == ScanMethod::FLATBED)) { genesys_warmup_lamp(dev); } /* set top left x and y values by scanning the internals if flatbed scanners */ if (!dev->model->is_sheetfed) { /* do the geometry detection only once */ if ((dev->model->flags & GENESYS_FLAG_SEARCH_START) && (dev->model->y_offset_calib_white == 0)) { dev->cmd_set->search_start_position (dev); dev->parking = false; dev->cmd_set->move_back_home(dev, true); } else { /* Go home */ /* TODO: check we can drop this since we cannot have the scanner's head wandering here */ dev->parking = false; dev->cmd_set->move_back_home(dev, true); } } /* move to calibration area for transparency adapter */ if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { dev->cmd_set->move_to_ta(dev); } /* load document if needed (for sheetfed scanner for instance) */ if (dev->model->is_sheetfed) { dev->cmd_set->load_document(dev); } auto& sensor = sanei_genesys_find_sensor_for_write(dev, dev->settings.xres, dev->settings.get_channels(), dev->settings.scan_method); // send gamma tables. They have been set to device or user value // when setting option value */ dev->cmd_set->send_gamma_table(dev, sensor); /* try to use cached calibration first */ if (!genesys_restore_calibration (dev, sensor)) { /* calibration : sheetfed scanners can't calibrate before each scan */ /* and also those who have the NO_CALIBRATION flag */ if (!(dev->model->flags & GENESYS_FLAG_NO_CALIBRATION) && !dev->model->is_sheetfed) { genesys_scanner_calibration(dev, sensor); genesys_save_calibration (dev, sensor); } else { DBG(DBG_warn, "%s: no calibration done\n", __func__); } } /* build look up table for dynamic lineart */ if (dev->settings.scan_mode == ScanColorMode::LINEART) { sanei_genesys_load_lut(dev->lineart_lut, 8, 8, 50, 205, dev->settings.threshold_curve, dev->settings.threshold-127); } dev->cmd_set->wait_for_motor_stop(dev); if (dev->cmd_set->needs_home_before_init_regs_for_scan(dev)) { dev->cmd_set->move_back_home(dev, true); } if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { dev->cmd_set->move_to_ta(dev); } dev->cmd_set->init_regs_for_scan(dev, sensor); /* no lamp during scan */ if (lamp_off) { sanei_genesys_set_lamp_power(dev, sensor, dev->reg, false); } /* GL124 is using SHDAREA, so we have to wait for scan to be set up before * sending shading data */ if (dev->cmd_set->has_send_shading_data() && !(dev->model->flags & GENESYS_FLAG_NO_CALIBRATION)) { genesys_send_shading_coefficient(dev, sensor); } // now send registers for scan dev->interface->write_registers(dev->reg); // start effective scan dev->cmd_set->begin_scan(dev, sensor, &dev->reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("start_scan"); return; } /*do we really need this? the valid data check should be sufficent -- pierre*/ /* waits for head to reach scanning position */ expected = dev->reg.get8(0x3d) * 65536 + dev->reg.get8(0x3e) * 256 + dev->reg.get8(0x3f); do { // wait some time between each test to avoid overloading USB and CPU dev->interface->sleep_ms(100); sanei_genesys_read_feed_steps (dev, &steps); } while (steps < expected); wait_until_buffer_non_empty(dev); // we wait for at least one word of valid scan data // this is also done in sanei_genesys_read_data_from_scanner -- pierre if (!dev->model->is_sheetfed) { do { dev->interface->sleep_ms(100); sanei_genesys_read_valid_words(dev, &steps); } while (steps < 1); } } static void genesys_fill_read_buffer(Genesys_Device* dev) { DBG_HELPER(dbg); /* for sheetfed scanner, we must check is document is shorter than * the requested scan */ if (dev->model->is_sheetfed) { dev->cmd_set->detect_document_end(dev); } std::size_t size = dev->read_buffer.size() - dev->read_buffer.avail(); /* due to sensors and motors, not all data can be directly used. It * may have to be read from another intermediate buffer and then processed. * There are currently 3 intermediate stages: * - handling of odd/even sensors * - handling of line interpolation for motors that can't have low * enough dpi * - handling of multi-segments sensors * * This is also the place where full duplex data will be handled. */ dev->pipeline_buffer.get_data(size, dev->read_buffer.get_write_pos(size)); dev->read_buffer.produce(size); } /* this function does the effective data read in a manner that suits the scanner. It does data reordering and resizing if need. It also manages EOF and I/O errors, and line distance correction. Returns true on success, false on end-of-file. */ static void genesys_read_ordered_data(Genesys_Device* dev, SANE_Byte* destination, size_t* len) { DBG_HELPER(dbg); size_t bytes = 0; uint8_t *work_buffer_src; Genesys_Buffer *src_buffer; if (!dev->read_active) { *len = 0; throw SaneException("read is not active"); } DBG(DBG_info, "%s: frontend requested %zu bytes\n", __func__, *len); DBG(DBG_info, "%s: bytes_to_read=%zu, total_bytes_read=%zu\n", __func__, dev->total_bytes_to_read, dev->total_bytes_read); /* is there data left to scan */ if (dev->total_bytes_read >= dev->total_bytes_to_read) { /* issue park command immediatly in case scanner can handle it * so we save time */ if (!dev->model->is_sheetfed && !(dev->model->flags & GENESYS_FLAG_MUST_WAIT) && !dev->parking) { dev->cmd_set->move_back_home(dev, false); dev->parking = true; } throw SaneException(SANE_STATUS_EOF, "nothing more to scan: EOF"); } /* convert data */ /* 0. fill_read_buffer -------------- read_buffer ---------------------- 1a). (opt)uncis (assumes color components to be laid out planar) 1b). (opt)reverse_RGB (assumes pixels to be BGR or BBGGRR)) -------------- lines_buffer ---------------------- 2a). (opt)line_distance_correction (assumes RGB or RRGGBB) 2b). (opt)unstagger (assumes pixels to be depth*channels/8 bytes long, unshrinked) ------------- shrink_buffer --------------------- 3. (opt)shrink_lines (assumes component separation in pixels) -------------- out_buffer ----------------------- 4. memcpy to destination (for lineart with bit reversal) */ /*FIXME: for lineart we need sub byte addressing in buffers, or conversion to bytes at 0. and back to bits at 4. Problems with the first approach: - its not clear how to check if we need to output an incomplete byte because it is the last one. */ /*FIXME: add lineart support for gl646. in the meantime add logic to convert from gray to lineart at the end? would suffer the above problem, total_bytes_to_read and total_bytes_read help in that case. */ if (is_testing_mode()) { if (dev->total_bytes_read + *len > dev->total_bytes_to_read) { *len = dev->total_bytes_to_read - dev->total_bytes_read; } dev->total_bytes_read += *len; } else { genesys_fill_read_buffer(dev); src_buffer = &(dev->read_buffer); /* move data to destination */ bytes = std::min(src_buffer->avail(), *len); work_buffer_src = src_buffer->get_read_pos(); std::memcpy(destination, work_buffer_src, bytes); *len = bytes; /* avoid signaling some extra data because we have treated a full block * on the last block */ if (dev->total_bytes_read + *len > dev->total_bytes_to_read) { *len = dev->total_bytes_to_read - dev->total_bytes_read; } /* count bytes sent to frontend */ dev->total_bytes_read += *len; src_buffer->consume(bytes); } /* end scan if all needed data have been read */ if(dev->total_bytes_read >= dev->total_bytes_to_read) { dev->cmd_set->end_scan(dev, &dev->reg, true); if (dev->model->is_sheetfed) { dev->cmd_set->eject_document (dev); } } DBG(DBG_proc, "%s: completed, %zu bytes read\n", __func__, bytes); } /* ------------------------------------------------------------------------ */ /* Start of higher level functions */ /* ------------------------------------------------------------------------ */ static size_t max_string_size (const SANE_String_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; } static std::size_t max_string_size(const std::vector& strings) { std::size_t max_size = 0; for (const auto& s : strings) { if (!s) { continue; } max_size = std::max(max_size, std::strlen(s)); } return max_size; } static unsigned pick_resolution(const std::vector& resolutions, unsigned resolution, const char* direction) { DBG_HELPER(dbg); if (resolutions.empty()) throw SaneException("Empty resolution list"); unsigned best_res = resolutions.front(); unsigned min_diff = abs_diff(best_res, resolution); for (auto it = std::next(resolutions.begin()); it != resolutions.end(); ++it) { unsigned curr_diff = abs_diff(*it, resolution); if (curr_diff < min_diff) { min_diff = curr_diff; best_res = *it; } } if (best_res != resolution) { DBG(DBG_warn, "%s: using resolution %d that is nearest to %d for direction %s\n", __func__, best_res, resolution, direction); } return best_res; } static void calc_parameters(Genesys_Scanner* s) { DBG_HELPER(dbg); double tl_x = 0, tl_y = 0, br_x = 0, br_y = 0; tl_x = SANE_UNFIX(s->pos_top_left_x); tl_y = SANE_UNFIX(s->pos_top_left_y); br_x = SANE_UNFIX(s->pos_bottom_right_x); br_y = SANE_UNFIX(s->pos_bottom_right_y); s->params.last_frame = true; /* only single pass scanning supported */ if (s->mode == SANE_VALUE_SCAN_MODE_GRAY || s->mode == SANE_VALUE_SCAN_MODE_LINEART) { s->params.format = SANE_FRAME_GRAY; } else { s->params.format = SANE_FRAME_RGB; } if (s->mode == SANE_VALUE_SCAN_MODE_LINEART) { s->params.depth = 1; } else { s->params.depth = s->bit_depth; } s->dev->settings.scan_method = s->scan_method; const auto& resolutions = s->dev->model->get_resolution_settings(s->dev->settings.scan_method); s->dev->settings.depth = s->bit_depth; /* interpolation */ s->dev->settings.disable_interpolation = s->disable_interpolation; // FIXME: use correct sensor const auto& sensor = sanei_genesys_find_sensor_any(s->dev); // hardware settings if (static_cast(s->resolution) > sensor.optical_res && s->dev->settings.disable_interpolation) { s->dev->settings.xres = sensor.optical_res; } else { s->dev->settings.xres = s->resolution; } s->dev->settings.yres = s->resolution; s->dev->settings.xres = pick_resolution(resolutions.resolutions_x, s->dev->settings.xres, "X"); s->dev->settings.yres = pick_resolution(resolutions.resolutions_y, s->dev->settings.yres, "Y"); s->params.lines = static_cast(((br_y - tl_y) * s->dev->settings.yres) / MM_PER_INCH); unsigned pixels_per_line = static_cast(((br_x - tl_x) * s->dev->settings.xres) / MM_PER_INCH); /* we need an even pixels number * TODO invert test logic or generalize behaviour across all ASICs */ if ((s->dev->model->flags & GENESYS_FLAG_SIS_SENSOR) || s->dev->model->asic_type == AsicType::GL847 || s->dev->model->asic_type == AsicType::GL124 || s->dev->model->asic_type == AsicType::GL845 || s->dev->model->asic_type == AsicType::GL846 || s->dev->model->asic_type == AsicType::GL843) { if (s->dev->settings.xres <= 1200) { pixels_per_line = (pixels_per_line / 4) * 4; } else if (s->dev->settings.xres < s->dev->settings.yres) { // BUG: this is an artifact of the fact that the resolution was twice as large than // the actual resolution when scanning above the supported scanner X resolution pixels_per_line = (pixels_per_line / 8) * 8; } else { pixels_per_line = (pixels_per_line / 16) * 16; } } /* corner case for true lineart for sensor with several segments * or when xres is doubled to match yres */ if (s->dev->settings.xres >= 1200 && ( s->dev->model->asic_type == AsicType::GL124 || s->dev->model->asic_type == AsicType::GL847 || s->dev->session.params.xres < s->dev->session.params.yres)) { if (s->dev->settings.xres < s->dev->settings.yres) { // FIXME: this is an artifact of the fact that the resolution was twice as large than // the actual resolution when scanning above the supported scanner X resolution pixels_per_line = (pixels_per_line / 8) * 8; } else { pixels_per_line = (pixels_per_line / 16) * 16; } } unsigned xres_factor = s->resolution / s->dev->settings.xres; unsigned bytes_per_line = 0; if (s->params.depth > 8) { s->params.depth = 16; bytes_per_line = 2 * pixels_per_line; } else if (s->params.depth == 1) { // round down pixel number. This will is lossy operation, at most 7 pixels will be lost pixels_per_line = (pixels_per_line / 8) * 8; bytes_per_line = pixels_per_line / 8; } else { bytes_per_line = pixels_per_line; } if (s->params.format == SANE_FRAME_RGB) { bytes_per_line *= 3; } s->dev->settings.scan_mode = option_string_to_scan_color_mode(s->mode); s->dev->settings.lines = s->params.lines; s->dev->settings.pixels = pixels_per_line; s->dev->settings.requested_pixels = pixels_per_line * xres_factor; s->params.pixels_per_line = pixels_per_line * xres_factor; s->params.bytes_per_line = bytes_per_line * xres_factor; s->dev->settings.tl_x = tl_x; s->dev->settings.tl_y = tl_y; // threshold setting s->dev->settings.threshold = static_cast(2.55 * (SANE_UNFIX(s->threshold))); // color filter if (s->color_filter == "Red") { s->dev->settings.color_filter = ColorFilter::RED; } else if (s->color_filter == "Green") { s->dev->settings.color_filter = ColorFilter::GREEN; } else if (s->color_filter == "Blue") { s->dev->settings.color_filter = ColorFilter::BLUE; } else { s->dev->settings.color_filter = ColorFilter::NONE; } // true gray if (s->color_filter == "None") { s->dev->settings.true_gray = 1; } else { s->dev->settings.true_gray = 0; } // threshold curve for dynamic rasterization s->dev->settings.threshold_curve = s->threshold_curve; /* some digital processing requires the whole picture to be buffered */ /* no digital processing takes place when doing preview, or when bit depth is * higher than 8 bits */ if ((s->swdespeck || s->swcrop || s->swdeskew || s->swderotate ||(SANE_UNFIX(s->swskip)>0)) && (!s->preview) && (s->bit_depth <= 8)) { s->dev->buffer_image = true; } else { s->dev->buffer_image = false; } /* brigthness and contrast only for for 8 bit scans */ if(s->bit_depth <= 8) { s->dev->settings.contrast = (s->contrast * 127) / 100; s->dev->settings.brightness = (s->brightness * 127) / 100; } else { s->dev->settings.contrast=0; s->dev->settings.brightness=0; } /* cache expiration time */ s->dev->settings.expiration_time = s->expiration_time; } static void create_bpp_list (Genesys_Scanner * s, const std::vector& bpp) { s->bpp_list[0] = bpp.size(); std::reverse_copy(bpp.begin(), bpp.end(), s->bpp_list + 1); } /** @brief this function initialize a gamma vector based on the ASIC: * Set up a default gamma table vector based on device description * gl646: 12 or 14 bits gamma table depending on GENESYS_FLAG_14BIT_GAMMA * gl84x: 16 bits * gl12x: 16 bits * @param scanner pointer to scanner session to get options * @param option option number of the gamma table to set */ static void init_gamma_vector_option (Genesys_Scanner * scanner, int option) { /* the option is inactive until the custom gamma control * is enabled */ scanner->opt[option].type = SANE_TYPE_INT; scanner->opt[option].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; scanner->opt[option].unit = SANE_UNIT_NONE; scanner->opt[option].constraint_type = SANE_CONSTRAINT_RANGE; if (scanner->dev->model->asic_type == AsicType::GL646) { if ((scanner->dev->model->flags & GENESYS_FLAG_14BIT_GAMMA) != 0) { scanner->opt[option].size = 16384 * sizeof (SANE_Word); scanner->opt[option].constraint.range = &u14_range; } else { /* 12 bits gamma tables */ scanner->opt[option].size = 4096 * sizeof (SANE_Word); scanner->opt[option].constraint.range = &u12_range; } } else { /* other asics have 16 bits words gamma table */ scanner->opt[option].size = 256 * sizeof (SANE_Word); scanner->opt[option].constraint.range = &u16_range; } } /** * allocate a geometry range * @param size maximum size of the range * @return a pointer to a valid range or nullptr */ static SANE_Range create_range(float size) { SANE_Range range; range.min = SANE_FIX(0.0); range.max = SANE_FIX(size); range.quant = SANE_FIX(0.0); return range; } /** @brief generate calibration cache file nam * Generates the calibration cache file name to use. * Tries to store the chache in $HOME/.sane or * then fallbacks to $TMPDIR or TMP. The filename * uses the model name if only one scanner is plugged * else is uses the device name when several identical * scanners are in use. * @param currdev current scanner device * @return an allocated string containing a file name */ static std::string calibration_filename(Genesys_Device *currdev) { std::string ret; ret.resize(PATH_MAX); char filename[80]; unsigned int count; unsigned int i; /* first compute the DIR where we can store cache: * 1 - home dir * 2 - $TMPDIR * 3 - $TMP * 4 - tmp dir * 5 - temp dir * 6 - then resort to current dir */ char* ptr = std::getenv("HOME"); if (ptr == nullptr) { ptr = std::getenv("USERPROFILE"); } if (ptr == nullptr) { ptr = std::getenv("TMPDIR"); } if (ptr == nullptr) { ptr = std::getenv("TMP"); } /* now choose filename: * 1 - if only one scanner, name of the model * 2 - if several scanners of the same model, use device name, * replacing special chars */ count=0; /* count models of the same names if several scanners attached */ if(s_devices->size() > 1) { for (const auto& dev : *s_devices) { if (dev.model->model_id == currdev->model->model_id) { count++; } } } if(count>1) { std::snprintf(filename, sizeof(filename), "%s.cal", currdev->file_name.c_str()); for(i=0;imodel->name); } /* build final final name : store dir + filename */ if (ptr == nullptr) { int size = std::snprintf(&ret.front(), ret.size(), "%s", filename); ret.resize(size); } else { int size = 0; #ifdef HAVE_MKDIR /* make sure .sane directory exists in existing store dir */ size = std::snprintf(&ret.front(), ret.size(), "%s%c.sane", ptr, PATH_SEP); ret.resize(size); mkdir(ret.c_str(), 0700); ret.resize(PATH_MAX); #endif size = std::snprintf(&ret.front(), ret.size(), "%s%c.sane%c%s", ptr, PATH_SEP, PATH_SEP, filename); ret.resize(size); } DBG(DBG_info, "%s: calibration filename >%s<\n", __func__, ret.c_str()); return ret; } static void set_resolution_option_values(Genesys_Scanner& s, bool reset_resolution_value) { auto resolutions = s.dev->model->get_resolutions(s.scan_method); s.opt_resolution_values.resize(resolutions.size() + 1, 0); s.opt_resolution_values[0] = resolutions.size(); std::copy(resolutions.begin(), resolutions.end(), s.opt_resolution_values.begin() + 1); s.opt[OPT_RESOLUTION].constraint.word_list = s.opt_resolution_values.data(); if (reset_resolution_value) { s.resolution = *std::min_element(resolutions.begin(), resolutions.end()); } } static void set_xy_range_option_values(Genesys_Scanner& s) { if (s.scan_method == ScanMethod::FLATBED) { s.opt_x_range = create_range(static_cast(s.dev->model->x_size)); s.opt_y_range = create_range(static_cast(s.dev->model->y_size)); } else { s.opt_x_range = create_range(static_cast(s.dev->model->x_size_ta)); s.opt_y_range = create_range(static_cast(s.dev->model->y_size_ta)); } s.opt[OPT_TL_X].constraint.range = &s.opt_x_range; s.opt[OPT_TL_Y].constraint.range = &s.opt_y_range; s.opt[OPT_BR_X].constraint.range = &s.opt_x_range; s.opt[OPT_BR_Y].constraint.range = &s.opt_y_range; s.pos_top_left_x = 0; s.pos_top_left_y = 0; s.pos_bottom_right_x = s.opt_x_range.max; s.pos_bottom_right_y = s.opt_y_range.max; } static void init_options(Genesys_Scanner* s) { DBG_HELPER(dbg); SANE_Int option; Genesys_Model *model = s->dev->model; memset (s->opt, 0, sizeof (s->opt)); for (option = 0; option < NUM_OPTIONS; ++option) { s->opt[option].size = sizeof (SANE_Word); s->opt[option].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].name = "scanmode-group"; s->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].size = 0; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint.string_list = mode_list; s->mode = SANE_VALUE_SCAN_MODE_GRAY; /* scan source */ s->opt_source_values.clear(); for (const auto& resolution_setting : model->resolutions) { for (auto method : resolution_setting.methods) { s->opt_source_values.push_back(scan_method_to_option_string(method)); } } s->opt_source_values.push_back(nullptr); s->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_SOURCE].type = SANE_TYPE_STRING; s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].size = max_string_size(s->opt_source_values); s->opt[OPT_SOURCE].constraint.string_list = s->opt_source_values.data(); if (s->opt_source_values.size() < 2) { throw SaneException("No scan methods specified for scanner"); } s->scan_method = model->default_method; /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->opt[OPT_PREVIEW].unit = SANE_UNIT_NONE; s->opt[OPT_PREVIEW].constraint_type = SANE_CONSTRAINT_NONE; s->preview = false; /* bit depth */ s->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; s->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_BIT_DEPTH].size = sizeof (SANE_Word); s->opt[OPT_BIT_DEPTH].constraint.word_list = s->bpp_list; create_bpp_list (s, model->bpp_gray_values); s->bit_depth = model->bpp_gray_values[0]; // resolution s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; set_resolution_option_values(*s, true); /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].name = SANE_NAME_GEOMETRY; s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].size = 0; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; s->opt_x_range = create_range(static_cast(model->x_size)); s->opt_y_range = create_range(static_cast(model->y_size)); // scan area s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; set_xy_range_option_values(*s); /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].name = SANE_NAME_ENHANCEMENT; s->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_ENHANCEMENT_GROUP].size = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* custom-gamma table */ s->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_ADVANCED; s->custom_gamma = false; /* grayscale gamma vector */ s->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; init_gamma_vector_option (s, OPT_GAMMA_VECTOR); /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; init_gamma_vector_option (s, OPT_GAMMA_VECTOR_R); /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; init_gamma_vector_option (s, OPT_GAMMA_VECTOR_G); /* blue gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; init_gamma_vector_option (s, OPT_GAMMA_VECTOR_B); /* currently, there are only gamma table options in this group, * so if the scanner doesn't support gamma table, disable the * whole group */ if (!(model->flags & GENESYS_FLAG_CUSTOM_GAMMA)) { s->opt[OPT_ENHANCEMENT_GROUP].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; DBG(DBG_info, "%s: custom gamma disabled\n", __func__); } /* software base image enhancements, these are consuming as many * memory than used by the full scanned image and may fail at high * resolution */ /* software deskew */ s->opt[OPT_SWDESKEW].name = "swdeskew"; s->opt[OPT_SWDESKEW].title = "Software deskew"; s->opt[OPT_SWDESKEW].desc = "Request backend to rotate skewed pages digitally"; s->opt[OPT_SWDESKEW].type = SANE_TYPE_BOOL; s->opt[OPT_SWDESKEW].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; s->swdeskew = false; /* software deskew */ s->opt[OPT_SWDESPECK].name = "swdespeck"; s->opt[OPT_SWDESPECK].title = "Software despeck"; s->opt[OPT_SWDESPECK].desc = "Request backend to remove lone dots digitally"; s->opt[OPT_SWDESPECK].type = SANE_TYPE_BOOL; s->opt[OPT_SWDESPECK].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; s->swdespeck = false; /* software despeckle radius */ s->opt[OPT_DESPECK].name = "despeck"; s->opt[OPT_DESPECK].title = "Software despeckle diameter"; s->opt[OPT_DESPECK].desc = "Maximum diameter of lone dots to remove from scan"; s->opt[OPT_DESPECK].type = SANE_TYPE_INT; s->opt[OPT_DESPECK].unit = SANE_UNIT_NONE; s->opt[OPT_DESPECK].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_DESPECK].constraint.range = &swdespeck_range; s->opt[OPT_DESPECK].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED | SANE_CAP_INACTIVE; s->despeck = 1; /* crop by software */ s->opt[OPT_SWCROP].name = "swcrop"; s->opt[OPT_SWCROP].title = SANE_I18N ("Software crop"); s->opt[OPT_SWCROP].desc = SANE_I18N ("Request backend to remove border from pages digitally"); s->opt[OPT_SWCROP].type = SANE_TYPE_BOOL; s->opt[OPT_SWCROP].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; s->opt[OPT_SWCROP].unit = SANE_UNIT_NONE; s->swcrop = false; /* Software blank page skip */ s->opt[OPT_SWSKIP].name = "swskip"; s->opt[OPT_SWSKIP].title = SANE_I18N ("Software blank skip percentage"); s->opt[OPT_SWSKIP].desc = SANE_I18N("Request driver to discard pages with low numbers of dark pixels"); s->opt[OPT_SWSKIP].type = SANE_TYPE_FIXED; s->opt[OPT_SWSKIP].unit = SANE_UNIT_PERCENT; s->opt[OPT_SWSKIP].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_SWSKIP].constraint.range = &(percentage_range); s->opt[OPT_SWSKIP].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; s->swskip = 0; // disable by default /* Software Derotate */ s->opt[OPT_SWDEROTATE].name = "swderotate"; s->opt[OPT_SWDEROTATE].title = SANE_I18N ("Software derotate"); s->opt[OPT_SWDEROTATE].desc = SANE_I18N("Request driver to detect and correct 90 degree image rotation"); s->opt[OPT_SWDEROTATE].type = SANE_TYPE_BOOL; s->opt[OPT_SWDEROTATE].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; s->opt[OPT_SWDEROTATE].unit = SANE_UNIT_NONE; s->swderotate = false; /* Software brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &(enhance_range); s->opt[OPT_BRIGHTNESS].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->brightness = 0; // disable by default /* Sowftware contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_INT; s->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &(enhance_range); s->opt[OPT_CONTRAST].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->contrast = 0; // disable by default /* "Extras" group: */ s->opt[OPT_EXTRAS_GROUP].name = "extras-group"; s->opt[OPT_EXTRAS_GROUP].title = SANE_I18N ("Extras"); s->opt[OPT_EXTRAS_GROUP].desc = ""; s->opt[OPT_EXTRAS_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_EXTRAS_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_EXTRAS_GROUP].size = 0; s->opt[OPT_EXTRAS_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* BW threshold */ s->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; s->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; s->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; s->opt[OPT_THRESHOLD].type = SANE_TYPE_FIXED; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &percentage_range; s->threshold = SANE_FIX(50); /* BW threshold curve */ s->opt[OPT_THRESHOLD_CURVE].name = "threshold-curve"; s->opt[OPT_THRESHOLD_CURVE].title = SANE_I18N ("Threshold curve"); s->opt[OPT_THRESHOLD_CURVE].desc = SANE_I18N ("Dynamic threshold curve, from light to dark, normally 50-65"); s->opt[OPT_THRESHOLD_CURVE].type = SANE_TYPE_INT; s->opt[OPT_THRESHOLD_CURVE].unit = SANE_UNIT_NONE; s->opt[OPT_THRESHOLD_CURVE].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD_CURVE].constraint.range = &threshold_curve_range; s->threshold_curve = 50; /* disable_interpolation */ s->opt[OPT_DISABLE_INTERPOLATION].name = "disable-interpolation"; s->opt[OPT_DISABLE_INTERPOLATION].title = SANE_I18N ("Disable interpolation"); s->opt[OPT_DISABLE_INTERPOLATION].desc = SANE_I18N ("When using high resolutions where the horizontal resolution is smaller " "than the vertical resolution this disables horizontal interpolation."); s->opt[OPT_DISABLE_INTERPOLATION].type = SANE_TYPE_BOOL; s->opt[OPT_DISABLE_INTERPOLATION].unit = SANE_UNIT_NONE; s->opt[OPT_DISABLE_INTERPOLATION].constraint_type = SANE_CONSTRAINT_NONE; s->disable_interpolation = false; /* color filter */ s->opt[OPT_COLOR_FILTER].name = "color-filter"; s->opt[OPT_COLOR_FILTER].title = SANE_I18N ("Color filter"); s->opt[OPT_COLOR_FILTER].desc = SANE_I18N ("When using gray or lineart this option selects the used color."); s->opt[OPT_COLOR_FILTER].type = SANE_TYPE_STRING; s->opt[OPT_COLOR_FILTER].constraint_type = SANE_CONSTRAINT_STRING_LIST; /* true gray not yet supported for GL847 and GL124 scanners */ if (!model->is_cis || model->asic_type==AsicType::GL847 || model->asic_type==AsicType::GL124) { s->opt[OPT_COLOR_FILTER].size = max_string_size (color_filter_list); s->opt[OPT_COLOR_FILTER].constraint.string_list = color_filter_list; s->color_filter = s->opt[OPT_COLOR_FILTER].constraint.string_list[1]; } else { s->opt[OPT_COLOR_FILTER].size = max_string_size (cis_color_filter_list); s->opt[OPT_COLOR_FILTER].constraint.string_list = cis_color_filter_list; /* default to "None" ie true gray */ s->color_filter = s->opt[OPT_COLOR_FILTER].constraint.string_list[3]; } // no support for color filter for cis+gl646 scanners if (model->asic_type == AsicType::GL646 && model->is_cis) { DISABLE (OPT_COLOR_FILTER); } /* 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"); s->opt[OPT_CALIBRATION_FILE].type = SANE_TYPE_STRING; s->opt[OPT_CALIBRATION_FILE].unit = SANE_UNIT_NONE; s->opt[OPT_CALIBRATION_FILE].size = PATH_MAX; s->opt[OPT_CALIBRATION_FILE].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; s->opt[OPT_CALIBRATION_FILE].constraint_type = SANE_CONSTRAINT_NONE; s->calibration_file.clear(); /* disable option if ran as root */ #ifdef HAVE_GETUID if(geteuid()==0) { DISABLE (OPT_CALIBRATION_FILE); } #endif /* expiration time for calibration cache entries */ s->opt[OPT_EXPIRATION_TIME].name = "expiration-time"; s->opt[OPT_EXPIRATION_TIME].title = SANE_I18N ("Calibration cache expiration time"); s->opt[OPT_EXPIRATION_TIME].desc = SANE_I18N ("Time (in minutes) before a cached calibration expires. " "A value of 0 means cache is not used. A negative value means cache never expires."); s->opt[OPT_EXPIRATION_TIME].type = SANE_TYPE_INT; s->opt[OPT_EXPIRATION_TIME].unit = SANE_UNIT_NONE; s->opt[OPT_EXPIRATION_TIME].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_EXPIRATION_TIME].constraint.range = &expiration_range; s->expiration_time = 60; // 60 minutes by default /* Powersave time (turn lamp off) */ s->opt[OPT_LAMP_OFF_TIME].name = "lamp-off-time"; s->opt[OPT_LAMP_OFF_TIME].title = SANE_I18N ("Lamp off time"); s->opt[OPT_LAMP_OFF_TIME].desc = SANE_I18N ("The lamp will be turned off after the given time (in minutes). " "A value of 0 means, that the lamp won't be turned off."); s->opt[OPT_LAMP_OFF_TIME].type = SANE_TYPE_INT; s->opt[OPT_LAMP_OFF_TIME].unit = SANE_UNIT_NONE; s->opt[OPT_LAMP_OFF_TIME].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_LAMP_OFF_TIME].constraint.range = &time_range; s->lamp_off_time = 15; // 15 minutes /* turn lamp off during scan */ s->opt[OPT_LAMP_OFF].name = "lamp-off-scan"; s->opt[OPT_LAMP_OFF].title = SANE_I18N ("Lamp off during scan"); s->opt[OPT_LAMP_OFF].desc = SANE_I18N ("The lamp will be turned off during scan. "); s->opt[OPT_LAMP_OFF].type = SANE_TYPE_BOOL; s->opt[OPT_LAMP_OFF].unit = SANE_UNIT_NONE; s->opt[OPT_LAMP_OFF].constraint_type = SANE_CONSTRAINT_NONE; s->lamp_off = false; s->opt[OPT_SENSOR_GROUP].name = SANE_NAME_SENSORS; s->opt[OPT_SENSOR_GROUP].title = SANE_TITLE_SENSORS; s->opt[OPT_SENSOR_GROUP].desc = SANE_DESC_SENSORS; s->opt[OPT_SENSOR_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_SENSOR_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_SENSOR_GROUP].size = 0; s->opt[OPT_SENSOR_GROUP].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_SCAN_SW].name = SANE_NAME_SCAN; s->opt[OPT_SCAN_SW].title = SANE_TITLE_SCAN; s->opt[OPT_SCAN_SW].desc = SANE_DESC_SCAN; s->opt[OPT_SCAN_SW].type = SANE_TYPE_BOOL; s->opt[OPT_SCAN_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_SCAN_SW) s->opt[OPT_SCAN_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_SCAN_SW].cap = SANE_CAP_INACTIVE; /* SANE_NAME_FILE is not for buttons */ s->opt[OPT_FILE_SW].name = "file"; s->opt[OPT_FILE_SW].title = SANE_I18N ("File button"); s->opt[OPT_FILE_SW].desc = SANE_I18N ("File button"); s->opt[OPT_FILE_SW].type = SANE_TYPE_BOOL; s->opt[OPT_FILE_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_FILE_SW) s->opt[OPT_FILE_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_FILE_SW].cap = SANE_CAP_INACTIVE; s->opt[OPT_EMAIL_SW].name = SANE_NAME_EMAIL; s->opt[OPT_EMAIL_SW].title = SANE_TITLE_EMAIL; s->opt[OPT_EMAIL_SW].desc = SANE_DESC_EMAIL; s->opt[OPT_EMAIL_SW].type = SANE_TYPE_BOOL; s->opt[OPT_EMAIL_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_EMAIL_SW) s->opt[OPT_EMAIL_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_EMAIL_SW].cap = SANE_CAP_INACTIVE; s->opt[OPT_COPY_SW].name = SANE_NAME_COPY; s->opt[OPT_COPY_SW].title = SANE_TITLE_COPY; s->opt[OPT_COPY_SW].desc = SANE_DESC_COPY; s->opt[OPT_COPY_SW].type = SANE_TYPE_BOOL; s->opt[OPT_COPY_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_COPY_SW) s->opt[OPT_COPY_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_COPY_SW].cap = SANE_CAP_INACTIVE; s->opt[OPT_PAGE_LOADED_SW].name = SANE_NAME_PAGE_LOADED; s->opt[OPT_PAGE_LOADED_SW].title = SANE_TITLE_PAGE_LOADED; s->opt[OPT_PAGE_LOADED_SW].desc = SANE_DESC_PAGE_LOADED; s->opt[OPT_PAGE_LOADED_SW].type = SANE_TYPE_BOOL; s->opt[OPT_PAGE_LOADED_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_PAGE_LOADED_SW) s->opt[OPT_PAGE_LOADED_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_PAGE_LOADED_SW].cap = SANE_CAP_INACTIVE; /* OCR button */ s->opt[OPT_OCR_SW].name = "ocr"; s->opt[OPT_OCR_SW].title = SANE_I18N ("OCR button"); s->opt[OPT_OCR_SW].desc = SANE_I18N ("OCR button"); s->opt[OPT_OCR_SW].type = SANE_TYPE_BOOL; s->opt[OPT_OCR_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_OCR_SW) s->opt[OPT_OCR_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_OCR_SW].cap = SANE_CAP_INACTIVE; /* power button */ s->opt[OPT_POWER_SW].name = "power"; s->opt[OPT_POWER_SW].title = SANE_I18N ("Power button"); s->opt[OPT_POWER_SW].desc = SANE_I18N ("Power button"); s->opt[OPT_POWER_SW].type = SANE_TYPE_BOOL; s->opt[OPT_POWER_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_POWER_SW) s->opt[OPT_POWER_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_POWER_SW].cap = SANE_CAP_INACTIVE; /* extra button */ s->opt[OPT_EXTRA_SW].name = "extra"; s->opt[OPT_EXTRA_SW].title = SANE_I18N ("Extra button"); s->opt[OPT_EXTRA_SW].desc = SANE_I18N ("Extra button"); s->opt[OPT_EXTRA_SW].type = SANE_TYPE_BOOL; s->opt[OPT_EXTRA_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_EXTRA_SW) s->opt[OPT_EXTRA_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_EXTRA_SW].cap = SANE_CAP_INACTIVE; /* calibration needed */ s->opt[OPT_NEED_CALIBRATION_SW].name = "need-calibration"; s->opt[OPT_NEED_CALIBRATION_SW].title = SANE_I18N ("Needs calibration"); s->opt[OPT_NEED_CALIBRATION_SW].desc = SANE_I18N ("The scanner needs calibration for the current settings"); s->opt[OPT_NEED_CALIBRATION_SW].type = SANE_TYPE_BOOL; s->opt[OPT_NEED_CALIBRATION_SW].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_CALIBRATE) s->opt[OPT_NEED_CALIBRATION_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else s->opt[OPT_NEED_CALIBRATION_SW].cap = SANE_CAP_INACTIVE; /* button group */ s->opt[OPT_BUTTON_GROUP].name = "buttons"; s->opt[OPT_BUTTON_GROUP].title = SANE_I18N ("Buttons"); s->opt[OPT_BUTTON_GROUP].desc = ""; s->opt[OPT_BUTTON_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_BUTTON_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_BUTTON_GROUP].size = 0; s->opt[OPT_BUTTON_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* calibrate button */ s->opt[OPT_CALIBRATE].name = "calibrate"; s->opt[OPT_CALIBRATE].title = SANE_I18N ("Calibrate"); s->opt[OPT_CALIBRATE].desc = SANE_I18N ("Start calibration using special sheet"); s->opt[OPT_CALIBRATE].type = SANE_TYPE_BUTTON; s->opt[OPT_CALIBRATE].unit = SANE_UNIT_NONE; if (model->buttons & GENESYS_HAS_CALIBRATE) s->opt[OPT_CALIBRATE].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED | SANE_CAP_AUTOMATIC; else s->opt[OPT_CALIBRATE].cap = SANE_CAP_INACTIVE; /* clear calibration cache button */ s->opt[OPT_CLEAR_CALIBRATION].name = "clear-calibration"; s->opt[OPT_CLEAR_CALIBRATION].title = SANE_I18N ("Clear calibration"); s->opt[OPT_CLEAR_CALIBRATION].desc = SANE_I18N ("Clear calibration cache"); s->opt[OPT_CLEAR_CALIBRATION].type = SANE_TYPE_BUTTON; s->opt[OPT_CLEAR_CALIBRATION].unit = SANE_UNIT_NONE; s->opt[OPT_CLEAR_CALIBRATION].size = 0; s->opt[OPT_CLEAR_CALIBRATION].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_CLEAR_CALIBRATION].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; /* force calibration cache button */ s->opt[OPT_FORCE_CALIBRATION].name = "force-calibration"; s->opt[OPT_FORCE_CALIBRATION].title = SANE_I18N("Force calibration"); s->opt[OPT_FORCE_CALIBRATION].desc = SANE_I18N("Force calibration ignoring all and any calibration caches"); s->opt[OPT_FORCE_CALIBRATION].type = SANE_TYPE_BUTTON; s->opt[OPT_FORCE_CALIBRATION].unit = SANE_UNIT_NONE; s->opt[OPT_FORCE_CALIBRATION].size = 0; s->opt[OPT_FORCE_CALIBRATION].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_FORCE_CALIBRATION].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; // ignore offsets option s->opt[OPT_IGNORE_OFFSETS].name = "ignore-internal-offsets"; s->opt[OPT_IGNORE_OFFSETS].title = SANE_I18N("Ignore internal offsets"); s->opt[OPT_IGNORE_OFFSETS].desc = SANE_I18N("Acquires the image including the internal calibration areas of the scanner"); s->opt[OPT_IGNORE_OFFSETS].type = SANE_TYPE_BUTTON; s->opt[OPT_IGNORE_OFFSETS].unit = SANE_UNIT_NONE; s->opt[OPT_IGNORE_OFFSETS].size = 0; s->opt[OPT_IGNORE_OFFSETS].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_IGNORE_OFFSETS].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; calc_parameters(s); } static bool present; // this function is passed to C API, it must not throw static SANE_Status check_present (SANE_String_Const devname) noexcept { DBG_HELPER_ARGS(dbg, "%s detected.", devname); present = true; return SANE_STATUS_GOOD; } static Genesys_Device* attach_usb_device(const char* devname, std::uint16_t vendor_id, std::uint16_t product_id) { Genesys_USB_Device_Entry* found_usb_dev = nullptr; for (auto& usb_dev : *s_usb_devices) { if (usb_dev.vendor == vendor_id && usb_dev.product == product_id) { found_usb_dev = &usb_dev; break; } } if (found_usb_dev == nullptr) { throw SaneException("vendor 0x%xd product 0x%xd is not supported by this backend", vendor_id, product_id); } s_devices->emplace_back(); Genesys_Device* dev = &s_devices->back(); dev->file_name = devname; dev->model = &found_usb_dev->model; dev->vendorId = found_usb_dev->vendor; dev->productId = found_usb_dev->product; dev->usb_mode = 0; // i.e. unset dev->already_initialized = false; return dev; } static Genesys_Device* attach_device_by_name(SANE_String_Const devname, bool may_wait) { DBG_HELPER_ARGS(dbg, " devname: %s, may_wait = %d", devname, may_wait); if (!devname) { throw SaneException("devname must not be nullptr"); } for (auto& dev : *s_devices) { if (dev.file_name == devname) { DBG(DBG_info, "%s: device `%s' was already in device list\n", __func__, devname); return &dev; } } DBG(DBG_info, "%s: trying to open device `%s'\n", __func__, devname); UsbDevice usb_dev; usb_dev.open(devname); DBG(DBG_info, "%s: device `%s' successfully opened\n", __func__, devname); int vendor, product; usb_dev.get_vendor_product(vendor, product); usb_dev.close(); /* KV-SS080 is an auxiliary device which requires a master device to be here */ if(vendor == 0x04da && product == 0x100f) { present = false; sanei_usb_find_devices (vendor, 0x1006, check_present); sanei_usb_find_devices (vendor, 0x1007, check_present); sanei_usb_find_devices (vendor, 0x1010, check_present); if (present == false) { throw SaneException("master device not present"); } } Genesys_Device* dev = attach_usb_device(devname, vendor, product); DBG(DBG_info, "%s: found %s flatbed scanner %s at %s\n", __func__, dev->model->vendor, dev->model->model, dev->file_name.c_str()); return dev; } // this function is passed to C API and must not throw static SANE_Status attach_one_device(SANE_String_Const devname) noexcept { DBG_HELPER(dbg); return wrap_exceptions_to_status_code(__func__, [=]() { attach_device_by_name(devname, false); }); } /* configuration framework functions */ // this function is passed to C API, it must not throw static SANE_Status config_attach_genesys(SANEI_Config __sane_unused__ *config, const char *devname) noexcept { /* the devname has been processed and is ready to be used * directly. Since the backend is an USB only one, we can * call sanei_usb_attach_matching_devices straight */ sanei_usb_attach_matching_devices (devname, attach_one_device); return SANE_STATUS_GOOD; } /* probes for scanner to attach to the backend */ static void probe_genesys_devices() { DBG_HELPER(dbg); if (is_testing_mode()) { attach_usb_device(get_testing_device_name().c_str(), get_testing_vendor_id(), get_testing_product_id()); return; } SANEI_Config config; // set configuration options structure : no option for this backend config.descriptors = nullptr; config.values = nullptr; config.count = 0; TIE(sanei_configure_attach(GENESYS_CONFIG_FILE, &config, config_attach_genesys)); DBG(DBG_info, "%s: %zu devices currently attached\n", __func__, s_devices->size()); } /** * This should be changed if one of the substructures of Genesys_Calibration_Cache change, but it must be changed if there are changes that don't change size -- at least for now, as we store most of Genesys_Calibration_Cache as is. */ static const char* CALIBRATION_IDENT = "sane_genesys"; static const int CALIBRATION_VERSION = 21; bool read_calibration(std::istream& str, Genesys_Device::Calibration& calibration, const std::string& path) { DBG_HELPER(dbg); std::string ident; serialize(str, ident); if (ident != CALIBRATION_IDENT) { DBG(DBG_info, "%s: Incorrect calibration file '%s' header\n", __func__, path.c_str()); return false; } size_t version; serialize(str, version); if (version != CALIBRATION_VERSION) { DBG(DBG_info, "%s: Incorrect calibration file '%s' version\n", __func__, path.c_str()); return false; } calibration.clear(); serialize(str, calibration); return true; } /** * reads previously cached calibration data * from file defined in dev->calib_file */ static bool sanei_genesys_read_calibration(Genesys_Device::Calibration& calibration, const std::string& path) { DBG_HELPER(dbg); std::ifstream str; str.open(path); if (!str.is_open()) { DBG(DBG_info, "%s: Cannot open %s\n", __func__, path.c_str()); return false; } return read_calibration(str, calibration, path); } void write_calibration(std::ostream& str, Genesys_Device::Calibration& calibration) { std::string ident = CALIBRATION_IDENT; serialize(str, ident); size_t version = CALIBRATION_VERSION; serialize(str, version); serialize_newline(str); serialize(str, calibration); } static void write_calibration(Genesys_Device::Calibration& calibration, const std::string& path) { DBG_HELPER(dbg); std::ofstream str; str.open(path); if (!str.is_open()) { throw SaneException("Cannot open calibration for writing"); } write_calibration(str, calibration); } /** @brief buffer scanned picture * In order to allow digital processing, we must be able to put all the * scanned picture in a buffer. */ static void genesys_buffer_image(Genesys_Scanner *s) { DBG_HELPER(dbg); size_t maximum; /**> maximum bytes size of the scan */ size_t len; /**> length of scanned data read */ size_t total; /**> total of butes read */ size_t size; /**> size of image buffer */ size_t read_size; /**> size of reads */ int lines; /** number of lines of the scan */ Genesys_Device *dev = s->dev; /* compute maximum number of lines for the scan */ if (s->params.lines > 0) { lines = s->params.lines; } else { lines = static_cast((dev->model->y_size * dev->settings.yres) / MM_PER_INCH); } DBG(DBG_info, "%s: buffering %d lines of %d bytes\n", __func__, lines, s->params.bytes_per_line); /* maximum bytes to read */ maximum = s->params.bytes_per_line * lines; if (s->dev->settings.scan_mode == ScanColorMode::LINEART) { maximum *= 8; } /* initial size of the read buffer */ size = ((2048 * 2048) / s->params.bytes_per_line) * s->params.bytes_per_line; /* read size */ read_size = size / 2; dev->img_buffer.resize(size); /* loop reading data until we reach maximum or EOF */ total = 0; while (total < maximum) { len = size - maximum; if (len > read_size) { len = read_size; } try { genesys_read_ordered_data(dev, dev->img_buffer.data() + total, &len); } catch (const SaneException& e) { if (e.status() == SANE_STATUS_EOF) { // ideally we shouldn't end up here, but because computations are duplicated and // slightly different everywhere in the genesys backend, we have no other choice break; } throw; } total += len; // do we need to enlarge read buffer ? if (total + read_size > size) { size += read_size; dev->img_buffer.resize(size); } } /* since digital processing is going to take place, * issue head parking command so that the head move while * computing so we can save time */ if (!dev->model->is_sheetfed && !dev->parking) { dev->cmd_set->move_back_home(dev, dev->model->flags & GENESYS_FLAG_MUST_WAIT); dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT); } /* in case of dynamic lineart, we have buffered gray data which * must be converted to lineart first */ if (s->dev->settings.scan_mode == ScanColorMode::LINEART) { total/=8; std::vector lineart(total); genesys_gray_lineart (dev, dev->img_buffer.data(), lineart.data(), dev->settings.pixels, (total*8)/dev->settings.pixels, dev->settings.threshold); dev->img_buffer = lineart; } /* update counters */ dev->total_bytes_to_read = total; dev->total_bytes_read = 0; /* update params */ s->params.lines = total / s->params.bytes_per_line; if (DBG_LEVEL >= DBG_io2) { sanei_genesys_write_pnm_file("gl_unprocessed.pnm", dev->img_buffer.data(), s->params.depth, s->params.format==SANE_FRAME_RGB ? 3 : 1, s->params.pixels_per_line, s->params.lines); } } /* -------------------------- SANE API functions ------------------------- */ void sane_init_impl(SANE_Int * version_code, SANE_Auth_Callback authorize) { DBG_INIT (); DBG_HELPER_ARGS(dbg, "authorize %s null", authorize ? "!=" : "=="); DBG(DBG_init, "SANE Genesys backend from %s\n", PACKAGE_STRING); if (!is_testing_mode()) { #ifdef HAVE_LIBUSB DBG(DBG_init, "SANE Genesys backend built with libusb-1.0\n"); #endif #ifdef HAVE_LIBUSB_LEGACY DBG(DBG_init, "SANE Genesys backend built with libusb\n"); #endif } if (version_code) { *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, SANE_CURRENT_MINOR, 0); } if (!is_testing_mode()) { sanei_usb_init(); } /* init sanei_magic */ sanei_magic_init(); s_scanners.init(); s_devices.init(); s_sane_devices.init(); s_sane_devices_data.init(); s_sane_devices_ptrs.init(); genesys_init_sensor_tables(); genesys_init_frontend_tables(); genesys_init_gpo_tables(); genesys_init_motor_tables(); genesys_init_motor_profile_tables(); genesys_init_usb_device_tables(); DBG(DBG_info, "%s: %s endian machine\n", __func__, #ifdef WORDS_BIGENDIAN "big" #else "little" #endif ); // cold-plug case :detection of allready connected scanners probe_genesys_devices(); } SANE_GENESYS_API_LINKAGE SANE_Status sane_init(SANE_Int * version_code, SANE_Auth_Callback authorize) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_init_impl(version_code, authorize); }); } void sane_exit_impl(void) { DBG_HELPER(dbg); if (!is_testing_mode()) { sanei_usb_exit(); } run_functions_at_backend_exit(); } SANE_GENESYS_API_LINKAGE void sane_exit() { catch_all_exceptions(__func__, [](){ sane_exit_impl(); }); } void sane_get_devices_impl(const SANE_Device *** device_list, SANE_Bool local_only) { DBG_HELPER_ARGS(dbg, "local_only = %s", local_only ? "true" : "false"); if (!is_testing_mode()) { // hot-plug case : detection of newly connected scanners */ sanei_usb_scan_devices(); } probe_genesys_devices(); s_sane_devices->clear(); s_sane_devices_data->clear(); s_sane_devices_ptrs->clear(); s_sane_devices->reserve(s_devices->size()); s_sane_devices_data->reserve(s_devices->size()); s_sane_devices_ptrs->reserve(s_devices->size() + 1); for (auto dev_it = s_devices->begin(); dev_it != s_devices->end();) { if (is_testing_mode()) { present = true; } else { present = false; sanei_usb_find_devices(dev_it->vendorId, dev_it->productId, check_present); } if (present) { s_sane_devices->emplace_back(); s_sane_devices_data->emplace_back(); auto& sane_device = s_sane_devices->back(); auto& sane_device_data = s_sane_devices_data->back(); sane_device_data.name = dev_it->file_name; sane_device.name = sane_device_data.name.c_str(); sane_device.vendor = dev_it->model->vendor; sane_device.model = dev_it->model->model; sane_device.type = "flatbed scanner"; s_sane_devices_ptrs->push_back(&sane_device); dev_it++; } else { dev_it = s_devices->erase(dev_it); } } s_sane_devices_ptrs->push_back(nullptr); *const_cast(device_list) = s_sane_devices_ptrs->data(); } SANE_GENESYS_API_LINKAGE SANE_Status sane_get_devices(const SANE_Device *** device_list, SANE_Bool local_only) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_get_devices_impl(device_list, local_only); }); } static void sane_open_impl(SANE_String_Const devicename, SANE_Handle * handle) { DBG_HELPER_ARGS(dbg, "devicename = %s", devicename); Genesys_Device* dev = nullptr; /* devicename="" or devicename="genesys" are default values that use * first available device */ if (devicename[0] && strcmp ("genesys", devicename) != 0) { /* search for the given devicename in the device list */ for (auto& d : *s_devices) { if (d.file_name == devicename) { dev = &d; break; } } if (dev) { DBG(DBG_info, "%s: found `%s' in devlist\n", __func__, dev->model->name); } else if (is_testing_mode()) { DBG(DBG_info, "%s: couldn't find `%s' in devlist, not attaching", __func__, devicename); } else { DBG(DBG_info, "%s: couldn't find `%s' in devlist, trying attach\n", __func__, devicename); dbg.status("attach_device_by_name"); dev = attach_device_by_name(devicename, true); dbg.clear(); } } else { // empty devicename or "genesys" -> use first device if (!s_devices->empty()) { dev = &s_devices->front(); DBG(DBG_info, "%s: empty devicename, trying `%s'\n", __func__, dev->file_name.c_str()); } } if (!dev) { throw SaneException("could not find the device to open: %s", devicename); } if (dev->model->flags & GENESYS_FLAG_UNTESTED) { DBG(DBG_error0, "WARNING: Your scanner is not fully supported or at least \n"); DBG(DBG_error0, " had only limited testing. Please be careful and \n"); DBG(DBG_error0, " report any failure/success to \n"); DBG(DBG_error0, " sane-devel@alioth-lists.debian.net. Please provide as many\n"); DBG(DBG_error0, " details as possible, e.g. the exact name of your\n"); DBG(DBG_error0, " scanner and what does (not) work.\n"); } dbg.vstatus("open device '%s'", dev->file_name.c_str()); if (is_testing_mode()) { auto interface = std::unique_ptr{new TestScannerInterface{dev}}; interface->set_checkpoint_callback(get_testing_checkpoint_callback()); dev->interface = std::move(interface); } else { dev->interface = std::unique_ptr{new ScannerInterfaceUsb{dev}}; } dev->interface->get_usb_device().open(dev->file_name.c_str()); dbg.clear(); s_scanners->push_back(Genesys_Scanner()); auto* s = &s_scanners->back(); s->dev = dev; s->scanning = false; s->dev->parking = false; s->dev->read_active = false; s->dev->force_calibration = 0; s->dev->line_count = 0; *handle = s; if (!dev->already_initialized) { sanei_genesys_init_structs (dev); } init_options(s); sanei_genesys_init_cmd_set(s->dev); // FIXME: we create sensor tables for the sensor, this should happen when we know which sensor // we will select dev->cmd_set->init(dev); // some hardware capabilities are detected through sensors s->dev->cmd_set->update_hardware_sensors (s); /* here is the place to fetch a stored calibration cache */ if (s->dev->force_calibration == 0) { auto path = calibration_filename(s->dev); s->calibration_file = path; s->dev->calib_file = path; DBG(DBG_info, "%s: Calibration filename set to:\n", __func__); DBG(DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file.c_str()); catch_all_exceptions(__func__, [&]() { sanei_genesys_read_calibration(s->dev->calibration_cache, s->dev->calib_file); }); } } SANE_GENESYS_API_LINKAGE SANE_Status sane_open(SANE_String_Const devicename, SANE_Handle* handle) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_open_impl(devicename, handle); }); } void sane_close_impl(SANE_Handle handle) { DBG_HELPER(dbg); /* remove handle from list of open handles: */ auto it = s_scanners->end(); for (auto it2 = s_scanners->begin(); it2 != s_scanners->end(); it2++) { if (&*it2 == handle) { it = it2; break; } } if (it == s_scanners->end()) { DBG(DBG_error, "%s: invalid handle %p\n", __func__, handle); return; /* oops, not a handle we know about */ } Genesys_Scanner* s = &*it; /* eject document for sheetfed scanners */ if (s->dev->model->is_sheetfed) { catch_all_exceptions(__func__, [&](){ s->dev->cmd_set->eject_document(s->dev); }); } else { /* in case scanner is parking, wait for the head * to reach home position */ if (s->dev->parking) { sanei_genesys_wait_for_home(s->dev); } } // enable power saving before leaving s->dev->cmd_set->save_power(s->dev, true); // here is the place to store calibration cache if (s->dev->force_calibration == 0 && !is_testing_mode()) { catch_all_exceptions(__func__, [&](){ write_calibration(s->dev->calibration_cache, s->dev->calib_file); }); } s->dev->already_initialized = false; s->dev->clear(); // LAMP OFF : same register across all the ASICs */ s->dev->interface->write_register(0x03, 0x00); catch_all_exceptions(__func__, [&](){ s->dev->interface->get_usb_device().clear_halt(); }); // we need this to avoid these ASIC getting stuck in bulk writes catch_all_exceptions(__func__, [&](){ s->dev->interface->get_usb_device().reset(); }); // not freeing s->dev because it's in the dev list catch_all_exceptions(__func__, [&](){ s->dev->interface->get_usb_device().close(); }); s_scanners->erase(it); } SANE_GENESYS_API_LINKAGE void sane_close(SANE_Handle handle) { catch_all_exceptions(__func__, [=]() { sane_close_impl(handle); }); } const SANE_Option_Descriptor * sane_get_option_descriptor_impl(SANE_Handle handle, SANE_Int option) { DBG_HELPER(dbg); Genesys_Scanner* s = reinterpret_cast(handle); if (static_cast(option) >= NUM_OPTIONS) { return nullptr; } DBG(DBG_io2, "%s: option = %s (%d)\n", __func__, s->opt[option].name, option); return s->opt + option; } SANE_GENESYS_API_LINKAGE const SANE_Option_Descriptor* sane_get_option_descriptor(SANE_Handle handle, SANE_Int option) { const SANE_Option_Descriptor* ret = nullptr; catch_all_exceptions(__func__, [&]() { ret = sane_get_option_descriptor_impl(handle, option); }); return ret; } static void print_option(DebugMessageHelper& dbg, const Genesys_Scanner& s, int option, void* val) { switch (s.opt[option].type) { case SANE_TYPE_INT: { dbg.vlog(DBG_proc, "value: %d", *reinterpret_cast(val)); return; } case SANE_TYPE_BOOL: { dbg.vlog(DBG_proc, "value: %s", *reinterpret_cast(val) ? "true" : "false"); return; } case SANE_TYPE_FIXED: { dbg.vlog(DBG_proc, "value: %f", SANE_UNFIX(*reinterpret_cast(val))); return; } case SANE_TYPE_STRING: { dbg.vlog(DBG_proc, "value: %s", reinterpret_cast(val)); return; } default: break; } dbg.log(DBG_proc, "value: (non-printable)"); } static void get_option_value(Genesys_Scanner* s, int option, void* val) { DBG_HELPER_ARGS(dbg, "option: %s (%d)", s->opt[option].name, option); unsigned int i; SANE_Word* table = nullptr; std::vector gamma_table; unsigned option_size = 0; const Genesys_Sensor* sensor = nullptr; if (sanei_genesys_has_sensor(s->dev, s->dev->settings.xres, s->dev->settings.get_channels(), s->dev->settings.scan_method)) { sensor = &sanei_genesys_find_sensor(s->dev, s->dev->settings.xres, s->dev->settings.get_channels(), s->dev->settings.scan_method); } switch (option) { /* geometry */ case OPT_TL_X: *reinterpret_cast(val) = s->pos_top_left_x; break; case OPT_TL_Y: *reinterpret_cast(val) = s->pos_top_left_y; break; case OPT_BR_X: *reinterpret_cast(val) = s->pos_bottom_right_x; break; case OPT_BR_Y: *reinterpret_cast(val) = s->pos_bottom_right_y; break; /* word options: */ case OPT_NUM_OPTS: *reinterpret_cast(val) = NUM_OPTIONS; break; case OPT_RESOLUTION: *reinterpret_cast(val) = s->resolution; break; case OPT_BIT_DEPTH: *reinterpret_cast(val) = s->bit_depth; break; case OPT_PREVIEW: *reinterpret_cast(val) = s->preview; break; case OPT_THRESHOLD: *reinterpret_cast(val) = s->threshold; break; case OPT_THRESHOLD_CURVE: *reinterpret_cast(val) = s->threshold_curve; break; case OPT_DISABLE_INTERPOLATION: *reinterpret_cast(val) = s->disable_interpolation; break; case OPT_LAMP_OFF: *reinterpret_cast(val) = s->lamp_off; break; case OPT_LAMP_OFF_TIME: *reinterpret_cast(val) = s->lamp_off_time; break; case OPT_SWDESKEW: *reinterpret_cast(val) = s->swdeskew; break; case OPT_SWCROP: *reinterpret_cast(val) = s->swcrop; break; case OPT_SWDESPECK: *reinterpret_cast(val) = s->swdespeck; break; case OPT_SWDEROTATE: *reinterpret_cast(val) = s->swderotate; break; case OPT_SWSKIP: *reinterpret_cast(val) = s->swskip; break; case OPT_DESPECK: *reinterpret_cast(val) = s->despeck; break; case OPT_CONTRAST: *reinterpret_cast(val) = s->contrast; break; case OPT_BRIGHTNESS: *reinterpret_cast(val) = s->brightness; break; case OPT_EXPIRATION_TIME: *reinterpret_cast(val) = s->expiration_time; break; case OPT_CUSTOM_GAMMA: *reinterpret_cast(val) = s->custom_gamma; break; /* string options: */ case OPT_MODE: std::strcpy(reinterpret_cast(val), s->mode.c_str()); break; case OPT_COLOR_FILTER: std::strcpy(reinterpret_cast(val), s->color_filter.c_str()); break; case OPT_CALIBRATION_FILE: std::strcpy(reinterpret_cast(val), s->calibration_file.c_str()); break; case OPT_SOURCE: std::strcpy(reinterpret_cast(val), scan_method_to_option_string(s->scan_method)); break; /* word array options */ case OPT_GAMMA_VECTOR: if (!sensor) throw SaneException("Unsupported scanner mode selected"); table = reinterpret_cast(val); if (s->color_filter == "Red") { gamma_table = get_gamma_table(s->dev, *sensor, GENESYS_RED); } else if (s->color_filter == "Blue") { gamma_table = get_gamma_table(s->dev, *sensor, GENESYS_BLUE); } else { gamma_table = get_gamma_table(s->dev, *sensor, GENESYS_GREEN); } option_size = s->opt[option].size / sizeof (SANE_Word); if (gamma_table.size() != option_size) { throw std::runtime_error("The size of the gamma tables does not match"); } for (i = 0; i < option_size; i++) { table[i] = gamma_table[i]; } break; case OPT_GAMMA_VECTOR_R: if (!sensor) throw SaneException("Unsupported scanner mode selected"); table = reinterpret_cast(val); gamma_table = get_gamma_table(s->dev, *sensor, GENESYS_RED); option_size = s->opt[option].size / sizeof (SANE_Word); if (gamma_table.size() != option_size) { throw std::runtime_error("The size of the gamma tables does not match"); } for (i = 0; i < option_size; i++) { table[i] = gamma_table[i]; } break; case OPT_GAMMA_VECTOR_G: if (!sensor) throw SaneException("Unsupported scanner mode selected"); table = reinterpret_cast(val); gamma_table = get_gamma_table(s->dev, *sensor, GENESYS_GREEN); option_size = s->opt[option].size / sizeof (SANE_Word); if (gamma_table.size() != option_size) { throw std::runtime_error("The size of the gamma tables does not match"); } for (i = 0; i < option_size; i++) { table[i] = gamma_table[i]; } break; case OPT_GAMMA_VECTOR_B: if (!sensor) throw SaneException("Unsupported scanner mode selected"); table = reinterpret_cast(val); gamma_table = get_gamma_table(s->dev, *sensor, GENESYS_BLUE); option_size = s->opt[option].size / sizeof (SANE_Word); if (gamma_table.size() != option_size) { throw std::runtime_error("The size of the gamma tables does not match"); } for (i = 0; i < option_size; i++) { table[i] = gamma_table[i]; } break; /* sensors */ case OPT_SCAN_SW: case OPT_FILE_SW: case OPT_EMAIL_SW: case OPT_COPY_SW: case OPT_PAGE_LOADED_SW: case OPT_OCR_SW: case OPT_POWER_SW: case OPT_EXTRA_SW: s->dev->cmd_set->update_hardware_sensors(s); *reinterpret_cast(val) = s->buttons[genesys_option_to_button(option)].read(); break; case OPT_NEED_CALIBRATION_SW: { if (!sensor) { throw SaneException("Unsupported scanner mode selected"); } // scanner needs calibration for current mode unless a matching calibration cache is // found bool result = true; auto session = s->dev->cmd_set->calculate_scan_session(s->dev, *sensor, s->dev->settings); for (auto& cache : s->dev->calibration_cache) { if (sanei_genesys_is_compatible_calibration(s->dev, session, &cache, false)) { *reinterpret_cast(val) = SANE_FALSE; } } *reinterpret_cast(val) = result; break; } default: DBG(DBG_warn, "%s: can't get unknown option %d\n", __func__, option); } print_option(dbg, *s, option, val); } /** @brief set calibration file value * Set calibration file value. Load new cache values from file if it exists, * else creates the file*/ static void set_calibration_value(Genesys_Scanner* s, const char* val) { DBG_HELPER(dbg); std::string new_calib_path = val; Genesys_Device::Calibration new_calibration; bool is_calib_success = false; catch_all_exceptions(__func__, [&]() { is_calib_success = sanei_genesys_read_calibration(new_calibration, new_calib_path); }); if (!is_calib_success) { return; } s->dev->calibration_cache = std::move(new_calibration); s->dev->calib_file = new_calib_path; s->calibration_file = new_calib_path; DBG(DBG_info, "%s: Calibration filename set to '%s':\n", __func__, new_calib_path.c_str()); } /* sets an option , called by sane_control_option */ static void set_option_value(Genesys_Scanner* s, int option, void *val, SANE_Int* myinfo) { DBG_HELPER_ARGS(dbg, "option: %s (%d)", s->opt[option].name, option); print_option(dbg, *s, option, val); SANE_Word *table; unsigned int i; unsigned option_size = 0; switch (option) { case OPT_TL_X: s->pos_top_left_x = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_TL_Y: s->pos_top_left_y = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_BR_X: s->pos_bottom_right_x = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_BR_Y: s->pos_bottom_right_y = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_RESOLUTION: s->resolution = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_THRESHOLD: s->threshold = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_THRESHOLD_CURVE: s->threshold_curve = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_SWCROP: s->swcrop = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_SWDESKEW: s->swdeskew = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_DESPECK: s->despeck = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_SWDEROTATE: s->swderotate = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_SWSKIP: s->swskip = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_DISABLE_INTERPOLATION: s->disable_interpolation = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_LAMP_OFF: s->lamp_off = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_PREVIEW: s->preview = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_BRIGHTNESS: s->brightness = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_CONTRAST: s->contrast = *reinterpret_cast(val); calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_SWDESPECK: s->swdespeck = *reinterpret_cast(val); if (s->swdespeck) { ENABLE(OPT_DESPECK); } else { DISABLE(OPT_DESPECK); } calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; break; /* software enhancement functions only apply to 8 or 1 bits data */ case OPT_BIT_DEPTH: s->bit_depth = *reinterpret_cast(val); if(s->bit_depth>8) { DISABLE(OPT_SWDESKEW); DISABLE(OPT_SWDESPECK); DISABLE(OPT_SWCROP); DISABLE(OPT_DESPECK); DISABLE(OPT_SWDEROTATE); DISABLE(OPT_SWSKIP); DISABLE(OPT_CONTRAST); DISABLE(OPT_BRIGHTNESS); } else { ENABLE(OPT_SWDESKEW); ENABLE(OPT_SWDESPECK); ENABLE(OPT_SWCROP); ENABLE(OPT_DESPECK); ENABLE(OPT_SWDEROTATE); ENABLE(OPT_SWSKIP); ENABLE(OPT_CONTRAST); ENABLE(OPT_BRIGHTNESS); } calc_parameters(s); *myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; break; case OPT_SOURCE: { auto scan_method = option_string_to_scan_method(reinterpret_cast(val)); if (s->scan_method != scan_method) { s->scan_method = scan_method; set_xy_range_option_values(*s); set_resolution_option_values(*s, false); *myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } break; } case OPT_MODE: s->mode = reinterpret_cast(val); if (s->mode == SANE_VALUE_SCAN_MODE_LINEART) { ENABLE (OPT_THRESHOLD); ENABLE (OPT_THRESHOLD_CURVE); DISABLE (OPT_BIT_DEPTH); if (s->dev->model->asic_type != AsicType::GL646 || !s->dev->model->is_cis) { ENABLE(OPT_COLOR_FILTER); } } else { DISABLE (OPT_THRESHOLD); DISABLE (OPT_THRESHOLD_CURVE); if (s->mode == SANE_VALUE_SCAN_MODE_GRAY) { if (s->dev->model->asic_type != AsicType::GL646 || !s->dev->model->is_cis) { ENABLE(OPT_COLOR_FILTER); } create_bpp_list (s, s->dev->model->bpp_gray_values); s->bit_depth = s->dev->model->bpp_gray_values[0]; } else { DISABLE (OPT_COLOR_FILTER); create_bpp_list (s, s->dev->model->bpp_color_values); s->bit_depth = s->dev->model->bpp_color_values[0]; } } calc_parameters(s); /* if custom gamma, toggle gamma table options according to the mode */ if (s->custom_gamma) { if (s->mode == SANE_VALUE_SCAN_MODE_COLOR) { DISABLE (OPT_GAMMA_VECTOR); ENABLE (OPT_GAMMA_VECTOR_R); ENABLE (OPT_GAMMA_VECTOR_G); ENABLE (OPT_GAMMA_VECTOR_B); } else { ENABLE (OPT_GAMMA_VECTOR); DISABLE (OPT_GAMMA_VECTOR_R); DISABLE (OPT_GAMMA_VECTOR_G); DISABLE (OPT_GAMMA_VECTOR_B); } } *myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; break; case OPT_COLOR_FILTER: s->color_filter = reinterpret_cast(val); calc_parameters(s); break; case OPT_CALIBRATION_FILE: if (s->dev->force_calibration == 0) { set_calibration_value(s, reinterpret_cast(val)); } break; case OPT_LAMP_OFF_TIME: if (*reinterpret_cast(val) != s->lamp_off_time) { s->lamp_off_time = *reinterpret_cast(val); s->dev->cmd_set->set_powersaving(s->dev, s->lamp_off_time); } break; case OPT_EXPIRATION_TIME: if (*reinterpret_cast(val) != s->expiration_time) { s->expiration_time = *reinterpret_cast(val); // BUG: this is most likely not intended behavior, found out during refactor s->dev->cmd_set->set_powersaving(s->dev, s->expiration_time); } break; case OPT_CUSTOM_GAMMA: *myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; s->custom_gamma = *reinterpret_cast(val); if (s->custom_gamma) { if (s->mode == SANE_VALUE_SCAN_MODE_COLOR) { DISABLE (OPT_GAMMA_VECTOR); ENABLE (OPT_GAMMA_VECTOR_R); ENABLE (OPT_GAMMA_VECTOR_G); ENABLE (OPT_GAMMA_VECTOR_B); } else { ENABLE (OPT_GAMMA_VECTOR); DISABLE (OPT_GAMMA_VECTOR_R); DISABLE (OPT_GAMMA_VECTOR_G); DISABLE (OPT_GAMMA_VECTOR_B); } } else { DISABLE (OPT_GAMMA_VECTOR); DISABLE (OPT_GAMMA_VECTOR_R); DISABLE (OPT_GAMMA_VECTOR_G); DISABLE (OPT_GAMMA_VECTOR_B); for (auto& table : s->dev->gamma_override_tables) { table.clear(); } } break; case OPT_GAMMA_VECTOR: table = reinterpret_cast(val); option_size = s->opt[option].size / sizeof (SANE_Word); s->dev->gamma_override_tables[GENESYS_RED].resize(option_size); s->dev->gamma_override_tables[GENESYS_GREEN].resize(option_size); s->dev->gamma_override_tables[GENESYS_BLUE].resize(option_size); for (i = 0; i < option_size; i++) { s->dev->gamma_override_tables[GENESYS_RED][i] = table[i]; s->dev->gamma_override_tables[GENESYS_GREEN][i] = table[i]; s->dev->gamma_override_tables[GENESYS_BLUE][i] = table[i]; } break; case OPT_GAMMA_VECTOR_R: table = reinterpret_cast(val); option_size = s->opt[option].size / sizeof (SANE_Word); s->dev->gamma_override_tables[GENESYS_RED].resize(option_size); for (i = 0; i < option_size; i++) { s->dev->gamma_override_tables[GENESYS_RED][i] = table[i]; } break; case OPT_GAMMA_VECTOR_G: table = reinterpret_cast(val); option_size = s->opt[option].size / sizeof (SANE_Word); s->dev->gamma_override_tables[GENESYS_GREEN].resize(option_size); for (i = 0; i < option_size; i++) { s->dev->gamma_override_tables[GENESYS_GREEN][i] = table[i]; } break; case OPT_GAMMA_VECTOR_B: table = reinterpret_cast(val); option_size = s->opt[option].size / sizeof (SANE_Word); s->dev->gamma_override_tables[GENESYS_BLUE].resize(option_size); for (i = 0; i < option_size; i++) { s->dev->gamma_override_tables[GENESYS_BLUE][i] = table[i]; } break; case OPT_CALIBRATE: { auto& sensor = sanei_genesys_find_sensor_for_write(s->dev, s->dev->settings.xres, s->dev->settings.get_channels(), s->dev->settings.scan_method); catch_all_exceptions(__func__, [&]() { s->dev->cmd_set->save_power(s->dev, false); genesys_scanner_calibration(s->dev, sensor); }); catch_all_exceptions(__func__, [&]() { s->dev->cmd_set->save_power(s->dev, true); }); *myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; break; } case OPT_CLEAR_CALIBRATION: s->dev->calibration_cache.clear(); /* remove file */ unlink(s->dev->calib_file.c_str()); /* signals that sensors will have to be read again */ *myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; break; case OPT_FORCE_CALIBRATION: s->dev->force_calibration = 1; s->dev->calibration_cache.clear(); s->dev->calib_file.clear(); /* signals that sensors will have to be read again */ *myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; break; case OPT_IGNORE_OFFSETS: { s->dev->ignore_offsets = true; break; } default: DBG(DBG_warn, "%s: can't set unknown option %d\n", __func__, option); } } /* sets and gets scanner option values */ void sane_control_option_impl(SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Genesys_Scanner* s = reinterpret_cast(handle); auto action_str = (action == SANE_ACTION_GET_VALUE) ? "get" : (action == SANE_ACTION_SET_VALUE) ? "set" : (action == SANE_ACTION_SET_AUTO) ? "set_auto" : "unknown"; DBG_HELPER_ARGS(dbg, "action = %s, option = %s (%d)", action_str, s->opt[option].name, option); SANE_Word cap; SANE_Int myinfo = 0; if (info) { *info = 0; } if (s->scanning) { throw SaneException(SANE_STATUS_DEVICE_BUSY, "don't call this function while scanning (option = %s (%d))", s->opt[option].name, option); } if (option >= NUM_OPTIONS || option < 0) { throw SaneException("option %d >= NUM_OPTIONS || option < 0", option); } cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { throw SaneException("option %d is inactive", option); } switch (action) { case SANE_ACTION_GET_VALUE: get_option_value(s, option, val); break; case SANE_ACTION_SET_VALUE: if (!SANE_OPTION_IS_SETTABLE (cap)) { throw SaneException("option %d is not settable", option); } TIE(sanei_constrain_value(s->opt + option, val, &myinfo)); set_option_value(s, option, val, &myinfo); break; case SANE_ACTION_SET_AUTO: throw SaneException("SANE_ACTION_SET_AUTO unsupported since no option " "has SANE_CAP_AUTOMATIC"); default: throw SaneException("unknown action %d for option %d", action, option); } if (info) *info = myinfo; } SANE_GENESYS_API_LINKAGE SANE_Status sane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_control_option_impl(handle, option, action, val, info); }); } void sane_get_parameters_impl(SANE_Handle handle, SANE_Parameters* params) { DBG_HELPER(dbg); Genesys_Scanner* s = reinterpret_cast(handle); /* don't recompute parameters once data reading is active, ie during scan */ if (!s->dev->read_active) { calc_parameters(s); } if (params) { *params = s->params; /* in the case of a sheetfed scanner, when full height is specified * we override the computed line number with -1 to signal that we * don't know the real document height. * We don't do that doing buffering image for digital processing */ if (s->dev->model->is_sheetfed && !s->dev->buffer_image && s->pos_bottom_right_y == s->opt[OPT_BR_Y].constraint.range->max) { params->lines = -1; } } debug_dump(DBG_proc, *params); } SANE_GENESYS_API_LINKAGE SANE_Status sane_get_parameters(SANE_Handle handle, SANE_Parameters* params) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_get_parameters_impl(handle, params); }); } void sane_start_impl(SANE_Handle handle) { DBG_HELPER(dbg); Genesys_Scanner* s = reinterpret_cast(handle); if (s->pos_top_left_x >= s->pos_bottom_right_x) { throw SaneException("top left x >= bottom right x"); } if (s->pos_top_left_y >= s->pos_bottom_right_y) { throw SaneException("top left y >= bottom right y"); } /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ calc_parameters(s); genesys_start_scan(s->dev, s->lamp_off); s->scanning = true; /* allocate intermediate buffer when doing dynamic lineart */ if (s->dev->settings.scan_mode == ScanColorMode::LINEART) { s->dev->binarize_buffer.clear(); s->dev->binarize_buffer.alloc(s->dev->settings.pixels); s->dev->local_buffer.clear(); s->dev->local_buffer.alloc(s->dev->binarize_buffer.size() * 8); } /* if one of the software enhancement option is selected, * we do the scan internally, process picture then put it an internal * buffer. Since cropping may change scan parameters, we recompute them * at the end */ if (s->dev->buffer_image) { genesys_buffer_image(s); /* check if we need to skip this page, sheetfed scanners * can go to next doc while flatbed ones can't */ if (s->swskip > 0 && IS_ACTIVE(OPT_SWSKIP)) { auto status = sanei_magic_isBlank(&s->params, s->dev->img_buffer.data(), SANE_UNFIX(s->swskip)); if (status == SANE_STATUS_NO_DOCS && s->dev->model->is_sheetfed) { DBG(DBG_info, "%s: blank page, recurse\n", __func__); sane_start(handle); return; } if (status != SANE_STATUS_GOOD) { throw SaneException(status); } } if (s->swdeskew) { const auto& sensor = sanei_genesys_find_sensor(s->dev, s->dev->settings.xres, s->dev->settings.get_channels(), s->dev->settings.scan_method); catch_all_exceptions(__func__, [&](){ genesys_deskew(s, sensor); }); } if (s->swdespeck) { catch_all_exceptions(__func__, [&](){ genesys_despeck(s); }); } if(s->swcrop) { catch_all_exceptions(__func__, [&](){ genesys_crop(s); }); } if(s->swderotate) { catch_all_exceptions(__func__, [&](){ genesys_derotate(s); }); } } } SANE_GENESYS_API_LINKAGE SANE_Status sane_start(SANE_Handle handle) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_start_impl(handle); }); } void sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int* len) { DBG_HELPER(dbg); Genesys_Scanner* s = reinterpret_cast(handle); Genesys_Device *dev; size_t local_len; if (!s) { throw SaneException("handle is nullptr"); } dev=s->dev; if (!dev) { throw SaneException("dev is nullptr"); } if (!buf) { throw SaneException("buf is nullptr"); } if (!len) { throw SaneException("len is nullptr"); } *len = 0; if (!s->scanning) { throw SaneException(SANE_STATUS_CANCELLED, "scan was cancelled, is over or has not been initiated yet"); } DBG(DBG_proc, "%s: start, %d maximum bytes required\n", __func__, max_len); DBG(DBG_io2, "%s: bytes_to_read=%zu, total_bytes_read=%zu\n", __func__, dev->total_bytes_to_read, dev->total_bytes_read); if(dev->total_bytes_read>=dev->total_bytes_to_read) { DBG(DBG_proc, "%s: nothing more to scan: EOF\n", __func__); /* issue park command immediatly in case scanner can handle it * so we save time */ if (!dev->model->is_sheetfed && !(dev->model->flags & GENESYS_FLAG_MUST_WAIT) && !dev->parking) { dev->cmd_set->move_back_home(dev, false); dev->parking = true; } throw SaneException(SANE_STATUS_EOF); } local_len = max_len; /* in case of image processing, all data has been stored in * buffer_image. So read data from it if it exists, else from scanner */ if(!dev->buffer_image) { /* dynamic lineart is another kind of digital processing that needs * another layer of buffering on top of genesys_read_ordered_data */ if (dev->settings.scan_mode == ScanColorMode::LINEART) { /* if buffer is empty, fill it with genesys_read_ordered_data */ if(dev->binarize_buffer.avail() == 0) { /* store gray data */ local_len=dev->local_buffer.size(); dev->local_buffer.reset(); genesys_read_ordered_data(dev, dev->local_buffer.get_write_pos(local_len), &local_len); dev->local_buffer.produce(local_len); dev->binarize_buffer.reset(); if (!is_testing_mode()) { genesys_gray_lineart(dev, dev->local_buffer.get_read_pos(), dev->binarize_buffer.get_write_pos(local_len / 8), dev->settings.pixels, local_len / dev->settings.pixels, dev->settings.threshold); } dev->binarize_buffer.produce(local_len / 8); } /* return data from lineart buffer if any, up to the available amount */ local_len = max_len; if (static_cast(max_len) > dev->binarize_buffer.avail()) { local_len=dev->binarize_buffer.avail(); } if(local_len) { memcpy(buf, dev->binarize_buffer.get_read_pos(), local_len); dev->binarize_buffer.consume(local_len); } } else { // most usual case, direct read of data from scanner */ genesys_read_ordered_data(dev, buf, &local_len); } } else /* read data from buffer */ { if(dev->total_bytes_read+local_len>dev->total_bytes_to_read) { local_len=dev->total_bytes_to_read-dev->total_bytes_read; } memcpy(buf, dev->img_buffer.data() + dev->total_bytes_read, local_len); dev->total_bytes_read+=local_len; } *len = local_len; if (local_len > static_cast(max_len)) { fprintf (stderr, "[genesys] sane_read: returning incorrect length!!\n"); } DBG(DBG_proc, "%s: %d bytes returned\n", __func__, *len); } SANE_GENESYS_API_LINKAGE SANE_Status sane_read(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int* len) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_read_impl(handle, buf, max_len, len); }); } void sane_cancel_impl(SANE_Handle handle) { DBG_HELPER(dbg); Genesys_Scanner* s = reinterpret_cast(handle); s->scanning = false; s->dev->read_active = false; s->dev->img_buffer.clear(); /* no need to end scan if we are parking the head */ if (!s->dev->parking) { s->dev->cmd_set->end_scan(s->dev, &s->dev->reg, true); } /* park head if flatbed scanner */ if (!s->dev->model->is_sheetfed) { if (!s->dev->parking) { s->dev->cmd_set->move_back_home (s->dev, s->dev->model->flags & GENESYS_FLAG_MUST_WAIT); s->dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT); } } else { /* in case of sheetfed scanners, we have to eject the document if still present */ s->dev->cmd_set->eject_document(s->dev); } /* enable power saving mode unless we are parking .... */ if (!s->dev->parking) { s->dev->cmd_set->save_power(s->dev, true); } return; } SANE_GENESYS_API_LINKAGE void sane_cancel(SANE_Handle handle) { catch_all_exceptions(__func__, [=]() { sane_cancel_impl(handle); }); } void sane_set_io_mode_impl(SANE_Handle handle, SANE_Bool non_blocking) { DBG_HELPER_ARGS(dbg, "handle = %p, non_blocking = %s", handle, non_blocking == SANE_TRUE ? "true" : "false"); Genesys_Scanner* s = reinterpret_cast(handle); if (!s->scanning) { throw SaneException("not scanning"); } if (non_blocking) { throw SaneException(SANE_STATUS_UNSUPPORTED); } } SANE_GENESYS_API_LINKAGE SANE_Status sane_set_io_mode(SANE_Handle handle, SANE_Bool non_blocking) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_set_io_mode_impl(handle, non_blocking); }); } void sane_get_select_fd_impl(SANE_Handle handle, SANE_Int* fd) { DBG_HELPER_ARGS(dbg, "handle = %p, fd = %p", handle, reinterpret_cast(fd)); Genesys_Scanner* s = reinterpret_cast(handle); if (!s->scanning) { throw SaneException("not scanning"); } throw SaneException(SANE_STATUS_UNSUPPORTED); } SANE_GENESYS_API_LINKAGE SANE_Status sane_get_select_fd(SANE_Handle handle, SANE_Int* fd) { return wrap_exceptions_to_status_code(__func__, [=]() { sane_get_select_fd_impl(handle, fd); }); } GenesysButtonName genesys_option_to_button(int option) { switch (option) { case OPT_SCAN_SW: return BUTTON_SCAN_SW; case OPT_FILE_SW: return BUTTON_FILE_SW; case OPT_EMAIL_SW: return BUTTON_EMAIL_SW; case OPT_COPY_SW: return BUTTON_COPY_SW; case OPT_PAGE_LOADED_SW: return BUTTON_PAGE_LOADED_SW; case OPT_OCR_SW: return BUTTON_OCR_SW; case OPT_POWER_SW: return BUTTON_POWER_SW; case OPT_EXTRA_SW: return BUTTON_EXTRA_SW; default: throw std::runtime_error("Unknown option to convert to button index"); } } } // namespace genesys sane-backends-1.0.29/backend/genesys/conv.cpp0000666000000000000000000001557613615534521015734 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2005, 2006 Pierre Willenbrock Copyright (C) 2010-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "conv.h" #include "sane/sanei_magic.h" namespace genesys { /** * uses the threshold/threshold_curve to control software binarization * This code was taken from the epjistsu backend by m. allan noah * @param dev device set up for the scan * @param src pointer to raw data * @param dst pointer where to store result * @param width width of the processed line * */ void binarize_line(Genesys_Device* dev, std::uint8_t* src, std::uint8_t* dst, int width) { DBG_HELPER(dbg); int j, windowX, sum = 0; int thresh; int offset, addCol, dropCol; unsigned char mask; int x; std::uint8_t min, max; /* normalize line */ min = 255; max = 0; for (x = 0; x < width; x++) { if (src[x] > max) { max = src[x]; } if (src[x] < min) { min = src[x]; } } /* safeguard against dark or white areas */ if(min>80) min=0; if(max<80) max=255; for (x = 0; x < width; x++) { src[x] = ((src[x] - min) * 255) / (max - min); } /* ~1mm works best, but the window needs to have odd # of pixels */ windowX = (6 * dev->settings.xres) / 150; if (!(windowX % 2)) windowX++; /* second, prefill the sliding sum */ for (j = 0; j < windowX; j++) sum += src[j]; /* third, walk the input buffer, update the sliding sum, */ /* determine threshold, output bits */ for (j = 0; j < width; j++) { /* output image location */ offset = j % 8; mask = 0x80 >> offset; thresh = dev->settings.threshold; /* move sum/update threshold only if there is a curve */ if (dev->settings.threshold_curve) { addCol = j + windowX / 2; dropCol = addCol - windowX; if (dropCol >= 0 && addCol < width) { sum -= src[dropCol]; sum += src[addCol]; } thresh = dev->lineart_lut[sum / windowX]; } /* use average to lookup threshold */ if (src[j] > thresh) *dst &= ~mask; /* white */ else *dst |= mask; /* black */ if (offset == 7) dst++; } } /** * software lineart using data from a 8 bit gray scan. We assume true gray * or monochrome scan as input. */ void genesys_gray_lineart(Genesys_Device* dev, std::uint8_t* src_data, std::uint8_t* dst_data, std::size_t pixels, std::size_t lines, std::uint8_t threshold) { DBG_HELPER(dbg); std::size_t y; DBG(DBG_io2, "%s: converting %zu lines of %zu pixels\n", __func__, lines, pixels); DBG(DBG_io2, "%s: threshold=%d\n", __func__, threshold); for (y = 0; y < lines; y++) { binarize_line (dev, src_data + y * pixels, dst_data, pixels); dst_data += pixels / 8; } } /** Look in image for likely left/right/bottom paper edges, then crop image. */ void genesys_crop(Genesys_Scanner* s) { DBG_HELPER(dbg); Genesys_Device *dev = s->dev; int top = 0; int bottom = 0; int left = 0; int right = 0; // first find edges if any TIE(sanei_magic_findEdges(&s->params, dev->img_buffer.data(), dev->settings.xres, dev->settings.yres, &top, &bottom, &left, &right)); DBG (DBG_io, "%s: t:%d b:%d l:%d r:%d\n", __func__, top, bottom, left, right); // now crop the image TIE(sanei_magic_crop (&(s->params), dev->img_buffer.data(), top, bottom, left, right)); /* update counters to new image size */ dev->total_bytes_to_read = s->params.bytes_per_line * s->params.lines; } /** Look in image for likely upper and left paper edges, then rotate * image so that upper left corner of paper is upper left of image. */ void genesys_deskew(Genesys_Scanner *s, const Genesys_Sensor& sensor) { DBG_HELPER(dbg); Genesys_Device *dev = s->dev; int x = 0, y = 0, bg; double slope = 0; bg=0; if(s->params.format==SANE_FRAME_GRAY && s->params.depth == 1) { bg=0xff; } TIE(sanei_magic_findSkew(&s->params, dev->img_buffer.data(), sensor.optical_res, sensor.optical_res, &x, &y, &slope)); DBG(DBG_info, "%s: slope=%f => %f\n", __func__, slope, slope * 180 / M_PI); // rotate image slope is in [-PI/2,PI/2]. Positive values rotate trigonometric direction wise TIE(sanei_magic_rotate(&s->params, dev->img_buffer.data(), x, y, slope, bg)); } /** remove lone dots */ void genesys_despeck(Genesys_Scanner* s) { DBG_HELPER(dbg); TIE(sanei_magic_despeck(&s->params, s->dev->img_buffer.data(), s->despeck)); } /** Look if image needs rotation and apply it * */ void genesys_derotate(Genesys_Scanner* s) { DBG_HELPER(dbg); int angle = 0; TIE(sanei_magic_findTurn(&s->params, s->dev->img_buffer.data(), s->resolution, s->resolution, &angle)); // apply rotation angle found TIE(sanei_magic_turn(&s->params, s->dev->img_buffer.data(), angle)); // update counters to new image size s->dev->total_bytes_to_read = s->params.bytes_per_line * s->params.lines; } } // namespace genesys sane-backends-1.0.29/backend/genesys/image_pipeline.cpp0000666000000000000000000006650313615534521017732 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "image_pipeline.h" #include "image.h" #include "low.h" #include #include namespace genesys { ImagePipelineNode::~ImagePipelineNode() {} std::size_t ImagePipelineNodeBytesSource::consume_remaining_bytes(std::size_t bytes) { if (bytes > remaining_bytes_) { bytes = remaining_bytes_; } remaining_bytes_ -= bytes; return bytes; } bool ImagePipelineNodeCallableSource::get_next_row_data(std::uint8_t* out_data) { bool got_data = producer_(get_row_bytes(), out_data); if (!got_data) eof_ = true; return got_data; } ImagePipelineNodeBufferedCallableSource::ImagePipelineNodeBufferedCallableSource( std::size_t width, std::size_t height, PixelFormat format, std::size_t input_batch_size, ProducerCallback producer) : width_{width}, height_{height}, format_{format}, buffer_{input_batch_size, producer} { set_remaining_bytes(height_ * get_row_bytes()); } bool ImagePipelineNodeBufferedCallableSource::get_next_row_data(std::uint8_t* out_data) { if (curr_row_ >= get_height()) { DBG(DBG_warn, "%s: reading out of bounds. Row %zu, height: %zu\n", __func__, curr_row_, get_height()); eof_ = true; return false; } bool got_data = true; auto row_bytes = get_row_bytes(); auto bytes_to_ask = consume_remaining_bytes(row_bytes); if (bytes_to_ask < row_bytes) { got_data = false; } got_data &= buffer_.get_data(bytes_to_ask, out_data); curr_row_++; if (!got_data) { eof_ = true; } return got_data; } ImagePipelineNodeBufferedGenesysUsb::ImagePipelineNodeBufferedGenesysUsb( std::size_t width, std::size_t height, PixelFormat format, std::size_t total_size, const FakeBufferModel& buffer_model, ProducerCallback producer) : width_{width}, height_{height}, format_{format}, buffer_{total_size, buffer_model, producer} { set_remaining_bytes(total_size); } bool ImagePipelineNodeBufferedGenesysUsb::get_next_row_data(std::uint8_t* out_data) { if (remaining_bytes() != buffer_.remaining_size() + buffer_.available()) { buffer_.set_remaining_size(remaining_bytes() - buffer_.available()); } bool got_data = true; std::size_t row_bytes = get_row_bytes(); std::size_t ask_bytes = consume_remaining_bytes(row_bytes); if (ask_bytes < row_bytes) { got_data = false; } got_data &= buffer_.get_data(ask_bytes, out_data); if (!got_data) { eof_ = true; } return got_data; } ImagePipelineNodeArraySource::ImagePipelineNodeArraySource(std::size_t width, std::size_t height, PixelFormat format, std::vector data) : width_{width}, height_{height}, format_{format}, data_{std::move(data)}, next_row_{0} { auto size = get_row_bytes() * height_; if (data_.size() < size) { throw SaneException("The given array is too small (%zu bytes). Need at least %zu", data_.size(), size); } set_remaining_bytes(size); } bool ImagePipelineNodeArraySource::get_next_row_data(std::uint8_t* out_data) { if (next_row_ >= height_) { eof_ = true; return false; } bool got_data = true; auto row_bytes = get_row_bytes(); auto bytes_to_ask = consume_remaining_bytes(row_bytes); if (bytes_to_ask < row_bytes) { got_data = false; } std::memcpy(out_data, data_.data() + get_row_bytes() * next_row_, bytes_to_ask); next_row_++; if (!got_data) { eof_ = true; } return got_data; } ImagePipelineNodeImageSource::ImagePipelineNodeImageSource(const Image& source) : source_{source} {} bool ImagePipelineNodeImageSource::get_next_row_data(std::uint8_t* out_data) { if (next_row_ >= get_height()) { return false; } std::memcpy(out_data, source_.get_row_ptr(next_row_), get_row_bytes()); next_row_++; return true; } bool ImagePipelineNodeFormatConvert::get_next_row_data(std::uint8_t* out_data) { auto src_format = source_.get_format(); if (src_format == dst_format_) { return source_.get_next_row_data(out_data); } buffer_.clear(); buffer_.resize(source_.get_row_bytes()); bool got_data = source_.get_next_row_data(buffer_.data()); convert_pixel_row_format(buffer_.data(), src_format, out_data, dst_format_, get_width()); return got_data; } ImagePipelineNodeDesegment::ImagePipelineNodeDesegment(ImagePipelineNode& source, std::size_t output_width, const std::vector& segment_order, std::size_t segment_pixels, std::size_t interleaved_lines, std::size_t pixels_per_chunk) : source_(source), output_width_{output_width}, segment_order_{segment_order}, segment_pixels_{segment_pixels}, interleaved_lines_{interleaved_lines}, pixels_per_chunk_{pixels_per_chunk}, buffer_{source_.get_row_bytes()} { DBG_HELPER_ARGS(dbg, "segment_count=%zu, segment_size=%zu, interleaved_lines=%zu, " "pixels_per_shunk=%zu", segment_order.size(), segment_pixels, interleaved_lines, pixels_per_chunk); if (source_.get_height() % interleaved_lines_ > 0) { throw SaneException("Height is not a multiple of the number of lines to interelave %zu/%zu", source_.get_height(), interleaved_lines_); } } ImagePipelineNodeDesegment::ImagePipelineNodeDesegment(ImagePipelineNode& source, std::size_t output_width, std::size_t segment_count, std::size_t segment_pixels, std::size_t interleaved_lines, std::size_t pixels_per_chunk) : source_(source), output_width_{output_width}, segment_pixels_{segment_pixels}, interleaved_lines_{interleaved_lines}, pixels_per_chunk_{pixels_per_chunk}, buffer_{source_.get_row_bytes()} { DBG_HELPER_ARGS(dbg, "segment_count=%zu, segment_size=%zu, interleaved_lines=%zu, " "pixels_per_shunk=%zu", segment_count, segment_pixels, interleaved_lines, pixels_per_chunk); segment_order_.resize(segment_count); std::iota(segment_order_.begin(), segment_order_.end(), 0); } bool ImagePipelineNodeDesegment::get_next_row_data(uint8_t* out_data) { bool got_data = true; buffer_.clear(); for (std::size_t i = 0; i < interleaved_lines_; ++i) { buffer_.push_back(); got_data &= source_.get_next_row_data(buffer_.get_row_ptr(i)); } if (!buffer_.is_linear()) { throw SaneException("Buffer is not linear"); } auto format = get_format(); auto segment_count = segment_order_.size(); const std::uint8_t* in_data = buffer_.get_row_ptr(0); std::size_t groups_count = output_width_ / (segment_order_.size() * pixels_per_chunk_); for (std::size_t igroup = 0; igroup < groups_count; ++igroup) { for (std::size_t isegment = 0; isegment < segment_count; ++isegment) { auto input_offset = igroup * pixels_per_chunk_; input_offset += segment_pixels_ * segment_order_[isegment]; auto output_offset = (igroup * segment_count + isegment) * pixels_per_chunk_; for (std::size_t ipixel = 0; ipixel < pixels_per_chunk_; ++ipixel) { auto pixel = get_raw_pixel_from_row(in_data, input_offset + ipixel, format); set_raw_pixel_to_row(out_data, output_offset + ipixel, pixel, format); } } } return got_data; } ImagePipelineNodeDeinterleaveLines::ImagePipelineNodeDeinterleaveLines( ImagePipelineNode& source, std::size_t interleaved_lines, std::size_t pixels_per_chunk) : ImagePipelineNodeDesegment(source, source.get_width() * interleaved_lines, interleaved_lines, source.get_width(), interleaved_lines, pixels_per_chunk) {} ImagePipelineNodeSwap16BitEndian::ImagePipelineNodeSwap16BitEndian(ImagePipelineNode& source) : source_(source), needs_swapping_{false} { if (get_pixel_format_depth(source_.get_format()) == 16) { needs_swapping_ = true; } else { DBG(DBG_info, "%s: this pipeline node does nothing for non 16-bit formats", __func__); } } bool ImagePipelineNodeSwap16BitEndian::get_next_row_data(std::uint8_t* out_data) { bool got_data = source_.get_next_row_data(out_data); if (needs_swapping_) { std::size_t pixels = get_row_bytes() / 2; for (std::size_t i = 0; i < pixels; ++i) { std::swap(*out_data, *(out_data + 1)); out_data += 2; } } return got_data; } ImagePipelineNodeMergeMonoLines::ImagePipelineNodeMergeMonoLines(ImagePipelineNode& source, ColorOrder color_order) : source_(source), buffer_(source_.get_row_bytes()) { DBG_HELPER_ARGS(dbg, "color_order %d", static_cast(color_order)); output_format_ = get_output_format(source_.get_format(), color_order); } bool ImagePipelineNodeMergeMonoLines::get_next_row_data(std::uint8_t* out_data) { bool got_data = true; buffer_.clear(); for (unsigned i = 0; i < 3; ++i) { buffer_.push_back(); got_data &= source_.get_next_row_data(buffer_.get_row_ptr(i)); } const auto* row0 = buffer_.get_row_ptr(0); const auto* row1 = buffer_.get_row_ptr(1); const auto* row2 = buffer_.get_row_ptr(2); auto format = source_.get_format(); for (std::size_t x = 0, width = get_width(); x < width; ++x) { std::uint16_t ch0 = get_raw_channel_from_row(row0, x, 0, format); std::uint16_t ch1 = get_raw_channel_from_row(row1, x, 0, format); std::uint16_t ch2 = get_raw_channel_from_row(row2, x, 0, format); set_raw_channel_to_row(out_data, x, 0, ch0, output_format_); set_raw_channel_to_row(out_data, x, 1, ch1, output_format_); set_raw_channel_to_row(out_data, x, 2, ch2, output_format_); } return got_data; } PixelFormat ImagePipelineNodeMergeMonoLines::get_output_format(PixelFormat input_format, ColorOrder order) { switch (input_format) { case PixelFormat::I1: { if (order == ColorOrder::RGB) { return PixelFormat::RGB111; } break; } case PixelFormat::I8: { if (order == ColorOrder::RGB) { return PixelFormat::RGB888; } if (order == ColorOrder::BGR) { return PixelFormat::BGR888; } break; } case PixelFormat::I16: { if (order == ColorOrder::RGB) { return PixelFormat::RGB161616; } if (order == ColorOrder::BGR) { return PixelFormat::BGR161616; } break; } default: break; } throw SaneException("Unsupported format combidation %d %d", static_cast(input_format), static_cast(order)); } ImagePipelineNodeSplitMonoLines::ImagePipelineNodeSplitMonoLines(ImagePipelineNode& source) : source_(source), next_channel_{0} { output_format_ = get_output_format(source_.get_format()); } bool ImagePipelineNodeSplitMonoLines::get_next_row_data(std::uint8_t* out_data) { bool got_data = true; if (next_channel_ == 0) { buffer_.resize(source_.get_row_bytes()); got_data &= source_.get_next_row_data(buffer_.data()); } const auto* row = buffer_.data(); auto format = source_.get_format(); for (std::size_t x = 0, width = get_width(); x < width; ++x) { std::uint16_t ch = get_raw_channel_from_row(row, x, next_channel_, format); set_raw_channel_to_row(out_data, x, 0, ch, output_format_); } next_channel_ = (next_channel_ + 1) % 3; return got_data; } PixelFormat ImagePipelineNodeSplitMonoLines::get_output_format(PixelFormat input_format) { switch (input_format) { case PixelFormat::RGB111: return PixelFormat::I1; case PixelFormat::RGB888: case PixelFormat::BGR888: return PixelFormat::I8; case PixelFormat::RGB161616: case PixelFormat::BGR161616: return PixelFormat::I16; default: break; } throw SaneException("Unsupported input format %d", static_cast(input_format)); } ImagePipelineNodeComponentShiftLines::ImagePipelineNodeComponentShiftLines( ImagePipelineNode& source, unsigned shift_r, unsigned shift_g, unsigned shift_b) : source_(source), buffer_{source.get_row_bytes()} { DBG_HELPER_ARGS(dbg, "shifts={%d, %d, %d}", shift_r, shift_g, shift_b); switch (source.get_format()) { case PixelFormat::RGB111: case PixelFormat::RGB888: case PixelFormat::RGB161616: { channel_shifts_ = { shift_r, shift_g, shift_b }; break; } case PixelFormat::BGR888: case PixelFormat::BGR161616: { channel_shifts_ = { shift_b, shift_g, shift_r }; break; } default: throw SaneException("Unsupported input format %d", static_cast(source.get_format())); } extra_height_ = *std::max_element(channel_shifts_.begin(), channel_shifts_.end()); } bool ImagePipelineNodeComponentShiftLines::get_next_row_data(std::uint8_t* out_data) { bool got_data = true; if (!buffer_.empty()) { buffer_.pop_front(); } while (buffer_.height() < extra_height_ + 1) { buffer_.push_back(); got_data &= source_.get_next_row_data(buffer_.get_back_row_ptr()); } auto format = get_format(); const auto* row0 = buffer_.get_row_ptr(channel_shifts_[0]); const auto* row1 = buffer_.get_row_ptr(channel_shifts_[1]); const auto* row2 = buffer_.get_row_ptr(channel_shifts_[2]); for (std::size_t x = 0, width = get_width(); x < width; ++x) { std::uint16_t ch0 = get_raw_channel_from_row(row0, x, 0, format); std::uint16_t ch1 = get_raw_channel_from_row(row1, x, 1, format); std::uint16_t ch2 = get_raw_channel_from_row(row2, x, 2, format); set_raw_channel_to_row(out_data, x, 0, ch0, format); set_raw_channel_to_row(out_data, x, 1, ch1, format); set_raw_channel_to_row(out_data, x, 2, ch2, format); } return got_data; } ImagePipelineNodePixelShiftLines::ImagePipelineNodePixelShiftLines( ImagePipelineNode& source, const std::vector& shifts) : source_(source), pixel_shifts_{shifts}, buffer_{get_row_bytes()} { DBG_HELPER(dbg); DBG(DBG_proc, "%s: shifts={", __func__); for (auto el : pixel_shifts_) { DBG(DBG_proc, " %zu", el); } DBG(DBG_proc, " }\n"); if (pixel_shifts_.size() > MAX_SHIFTS) { throw SaneException("Unsupported number of shift configurations %zu", pixel_shifts_.size()); } extra_height_ = *std::max_element(pixel_shifts_.begin(), pixel_shifts_.end()); } bool ImagePipelineNodePixelShiftLines::get_next_row_data(std::uint8_t* out_data) { bool got_data = true; if (!buffer_.empty()) { buffer_.pop_front(); } while (buffer_.height() < extra_height_ + 1) { buffer_.push_back(); got_data &= source_.get_next_row_data(buffer_.get_back_row_ptr()); } auto format = get_format(); auto shift_count = pixel_shifts_.size(); std::array rows; for (std::size_t irow = 0; irow < shift_count; ++irow) { rows[irow] = buffer_.get_row_ptr(pixel_shifts_[irow]); } for (std::size_t x = 0, width = get_width(); x < width;) { for (std::size_t irow = 0; irow < shift_count && x < width; irow++, x++) { RawPixel pixel = get_raw_pixel_from_row(rows[irow], x, format); set_raw_pixel_to_row(out_data, x, pixel, format); } } return got_data; } ImagePipelineNodeExtract::ImagePipelineNodeExtract(ImagePipelineNode& source, std::size_t offset_x, std::size_t offset_y, std::size_t width, std::size_t height) : source_(source), offset_x_{offset_x}, offset_y_{offset_y}, width_{width}, height_{height} { cached_line_.resize(source_.get_row_bytes()); } ImagePipelineNodeExtract::~ImagePipelineNodeExtract() {} ImagePipelineNodeScaleRows::ImagePipelineNodeScaleRows(ImagePipelineNode& source, std::size_t width) : source_(source), width_{width} { cached_line_.resize(source_.get_row_bytes()); } bool ImagePipelineNodeScaleRows::get_next_row_data(std::uint8_t* out_data) { auto src_width = source_.get_width(); auto dst_width = width_; bool got_data = source_.get_next_row_data(cached_line_.data()); const auto* src_data = cached_line_.data(); auto format = get_format(); auto channels = get_pixel_channels(format); if (src_width > dst_width) { // average std::uint32_t counter = src_width / 2; unsigned src_x = 0; for (unsigned dst_x = 0; dst_x < dst_width; dst_x++) { unsigned avg[3] = {0, 0, 0}; unsigned count = 0; while (counter < src_width && src_x < src_width) { counter += dst_width; for (unsigned c = 0; c < channels; c++) { avg[c] += get_raw_channel_from_row(src_data, src_x, c, format); } src_x++; count++; } counter -= src_width; for (unsigned c = 0; c < channels; c++) { set_raw_channel_to_row(out_data, dst_x, c, avg[c] / count, format); } } } else { // interpolate and copy pixels std::uint32_t counter = dst_width / 2; unsigned dst_x = 0; for (unsigned src_x = 0; src_x < src_width; src_x++) { unsigned avg[3] = {0, 0, 0}; for (unsigned c = 0; c < channels; c++) { avg[c] += get_raw_channel_from_row(src_data, src_x, c, format); } while ((counter < dst_width || src_x + 1 == src_width) && dst_x < dst_width) { counter += src_width; for (unsigned c = 0; c < channels; c++) { set_raw_channel_to_row(out_data, dst_x, c, avg[c], format); } dst_x++; } counter -= dst_width; } } return got_data; } bool ImagePipelineNodeExtract::get_next_row_data(std::uint8_t* out_data) { bool got_data = true; while (current_line_ < offset_y_) { got_data &= source_.get_next_row_data(cached_line_.data()); current_line_++; } if (current_line_ >= offset_y_ + source_.get_height()) { std::fill(out_data, out_data + get_row_bytes(), 0); current_line_++; return got_data; } // now we're sure that the following holds: // offset_y_ <= current_line_ < offset_y_ + source_.get_height()) got_data &= source_.get_next_row_data(cached_line_.data()); auto format = get_format(); auto x_src_width = source_.get_width() > offset_x_ ? source_.get_width() - offset_x_ : 0; x_src_width = std::min(x_src_width, width_); auto x_pad_after = width_ > x_src_width ? width_ - x_src_width : 0; if (get_pixel_format_depth(format) < 8) { // we need to copy pixels one-by-one as there's no per-bit addressing for (std::size_t i = 0; i < x_src_width; ++i) { auto pixel = get_raw_pixel_from_row(cached_line_.data(), i + offset_x_, format); set_raw_pixel_to_row(out_data, i, pixel, format); } for (std::size_t i = 0; i < x_pad_after; ++i) { set_raw_pixel_to_row(out_data, i + x_src_width, RawPixel{}, format); } } else { std::size_t bpp = get_pixel_format_depth(format) / 8; if (x_src_width > 0) { std::memcpy(out_data, cached_line_.data() + offset_x_ * bpp, x_src_width * bpp); } if (x_pad_after > 0) { std::fill(out_data + x_src_width * bpp, out_data + (x_src_width + x_pad_after) * bpp, 0); } } current_line_++; return got_data; } ImagePipelineNodeCalibrate::ImagePipelineNodeCalibrate(ImagePipelineNode& source, const std::vector& bottom, const std::vector& top) : source_{source} { auto size = std::min(bottom.size(), top.size()); offset_.reserve(size); multiplier_.reserve(size); for (std::size_t i = 0; i < size; ++i) { offset_.push_back(bottom[i] / 65535.0f); multiplier_.push_back(65535.0f / (top[i] - bottom[i])); } } bool ImagePipelineNodeCalibrate::get_next_row_data(std::uint8_t* out_data) { bool ret = source_.get_next_row_data(out_data); auto format = get_format(); auto depth = get_pixel_format_depth(format); std::size_t max_value = 1; switch (depth) { case 8: max_value = 255; break; case 16: max_value = 65535; break; default: throw SaneException("Unsupported depth for calibration %d", depth); } unsigned channels = get_pixel_channels(format); std::size_t max_calib_i = offset_.size(); std::size_t curr_calib_i = 0; for (std::size_t x = 0, width = get_width(); x < width && curr_calib_i < max_calib_i; ++x) { for (unsigned ch = 0; ch < channels && curr_calib_i < max_calib_i; ++ch) { std::int32_t value = get_raw_channel_from_row(out_data, x, ch, format); float value_f = static_cast(value) / max_value; value_f = (value_f - offset_[curr_calib_i]) * multiplier_[curr_calib_i]; value_f = std::round(value_f * max_value); value = clamp(static_cast(value_f), 0, max_value); set_raw_channel_to_row(out_data, x, ch, value, format); curr_calib_i++; } } return ret; } ImagePipelineNodeDebug::ImagePipelineNodeDebug(ImagePipelineNode& source, const std::string& path) : source_(source), path_{path}, buffer_{source_.get_row_bytes()} {} ImagePipelineNodeDebug::~ImagePipelineNodeDebug() { catch_all_exceptions(__func__, [&]() { if (buffer_.empty()) return; auto format = get_format(); buffer_.linearize(); sanei_genesys_write_pnm_file(path_.c_str(), buffer_.get_front_row_ptr(), get_pixel_format_depth(format), get_pixel_channels(format), get_width(), buffer_.height()); }); } bool ImagePipelineNodeDebug::get_next_row_data(std::uint8_t* out_data) { buffer_.push_back(); bool got_data = source_.get_next_row_data(out_data); std::memcpy(buffer_.get_back_row_ptr(), out_data, get_row_bytes()); return got_data; } std::size_t ImagePipelineStack::get_input_width() const { ensure_node_exists(); return nodes_.front()->get_width(); } std::size_t ImagePipelineStack::get_input_height() const { ensure_node_exists(); return nodes_.front()->get_height(); } PixelFormat ImagePipelineStack::get_input_format() const { ensure_node_exists(); return nodes_.front()->get_format(); } std::size_t ImagePipelineStack::get_input_row_bytes() const { ensure_node_exists(); return nodes_.front()->get_row_bytes(); } std::size_t ImagePipelineStack::get_output_width() const { ensure_node_exists(); return nodes_.back()->get_width(); } std::size_t ImagePipelineStack::get_output_height() const { ensure_node_exists(); return nodes_.back()->get_height(); } PixelFormat ImagePipelineStack::get_output_format() const { ensure_node_exists(); return nodes_.back()->get_format(); } std::size_t ImagePipelineStack::get_output_row_bytes() const { ensure_node_exists(); return nodes_.back()->get_row_bytes(); } void ImagePipelineStack::ensure_node_exists() const { if (nodes_.empty()) { throw SaneException("The pipeline does not contain any nodes"); } } void ImagePipelineStack::clear() { // we need to destroy the nodes back to front, so that the destructors still have valid // references to sources for (auto it = nodes_.rbegin(); it != nodes_.rend(); ++it) { it->reset(); } nodes_.clear(); } std::vector ImagePipelineStack::get_all_data() { auto row_bytes = get_output_row_bytes(); auto height = get_output_height(); std::vector ret; ret.resize(row_bytes * height); for (std::size_t i = 0; i < height; ++i) { get_next_row_data(ret.data() + row_bytes * i); } return ret; } Image ImagePipelineStack::get_image() { auto height = get_output_height(); Image ret; ret.resize(get_output_width(), height, get_output_format()); for (std::size_t i = 0; i < height; ++i) { get_next_row_data(ret.get_row_ptr(i)); } return ret; } } // namespace genesys sane-backends-1.0.29/backend/genesys/enums.h0000666000000000000000000002754613615534521015563 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_ENUMS_H #define BACKEND_GENESYS_ENUMS_H #include #include "serialize.h" namespace genesys { enum class ScanMethod : unsigned { // normal scan method FLATBED = 0, // scan using transparency adaptor TRANSPARENCY = 1, // scan using transparency adaptor via infrared channel TRANSPARENCY_INFRARED = 2 }; inline std::ostream& operator<<(std::ostream& out, ScanMethod mode) { switch (mode) { case ScanMethod::FLATBED: out << "FLATBED"; return out; case ScanMethod::TRANSPARENCY: out << "TRANSPARENCY"; return out; case ScanMethod::TRANSPARENCY_INFRARED: out << "TRANSPARENCY_INFRARED"; return out; } return out; } inline void serialize(std::istream& str, ScanMethod& x) { unsigned value; serialize(str, value); x = static_cast(value); } inline void serialize(std::ostream& str, ScanMethod& x) { unsigned value = static_cast(x); serialize(str, value); } const char* scan_method_to_option_string(ScanMethod method); ScanMethod option_string_to_scan_method(const std::string& str); enum class ScanColorMode : unsigned { LINEART = 0, HALFTONE, GRAY, COLOR_SINGLE_PASS }; inline std::ostream& operator<<(std::ostream& out, ScanColorMode mode) { switch (mode) { case ScanColorMode::LINEART: out << "LINEART"; return out; case ScanColorMode::HALFTONE: out << "HALFTONE"; return out; case ScanColorMode::GRAY: out << "GRAY"; return out; case ScanColorMode::COLOR_SINGLE_PASS: out << "COLOR_SINGLE_PASS"; return out; } return out; } inline void serialize(std::istream& str, ScanColorMode& x) { unsigned value; serialize(str, value); x = static_cast(value); } inline void serialize(std::ostream& str, ScanColorMode& x) { unsigned value = static_cast(x); serialize(str, value); } const char* scan_color_mode_to_option_string(ScanColorMode mode); ScanColorMode option_string_to_scan_color_mode(const std::string& str); enum class ScanHeadId : unsigned { NONE = 0, PRIMARY = 1 << 0, SECONDARY = 1 << 1, ALL = PRIMARY | SECONDARY, }; inline ScanHeadId operator|(ScanHeadId left, ScanHeadId right) { return static_cast(static_cast(left) | static_cast(right)); } inline ScanHeadId operator&(ScanHeadId left, ScanHeadId right) { return static_cast(static_cast(left) & static_cast(right)); } enum class ColorFilter : unsigned { RED = 0, GREEN, BLUE, NONE }; std::ostream& operator<<(std::ostream& out, ColorFilter mode); inline void serialize(std::istream& str, ColorFilter& x) { unsigned value; serialize(str, value); x = static_cast(value); } inline void serialize(std::ostream& str, ColorFilter& x) { unsigned value = static_cast(x); serialize(str, value); } enum class ColorOrder { RGB, GBR, BGR, }; /* Enum value naming conventions: Full name must be included with the following exceptions: Canon scanners omit "Canoscan" if present */ enum class ModelId : unsigned { UNKNOWN = 0, CANON_4400F, CANON_5600F, CANON_8400F, CANON_8600F, CANON_IMAGE_FORMULA_101, CANON_LIDE_50, CANON_LIDE_60, CANON_LIDE_80, CANON_LIDE_100, CANON_LIDE_110, CANON_LIDE_120, CANON_LIDE_200, CANON_LIDE_210, CANON_LIDE_220, CANON_LIDE_700F, DCT_DOCKETPORT_487, HP_SCANJET_2300C, HP_SCANJET_2400C, HP_SCANJET_3670, HP_SCANJET_4850C, HP_SCANJET_G4010, HP_SCANJET_G4050, HP_SCANJET_N6310, MEDION_MD5345, PANASONIC_KV_SS080, PENTAX_DSMOBILE_600, PLUSTEK_OPTICBOOK_3800, PLUSTEK_OPTICFILM_7200I, PLUSTEK_OPTICFILM_7300, PLUSTEK_OPTICFILM_7500I, PLUSTEK_OPTICPRO_3600, PLUSTEK_OPTICPRO_ST12, PLUSTEK_OPTICPRO_ST24, SYSCAN_DOCKETPORT_465, SYSCAN_DOCKETPORT_467, SYSCAN_DOCKETPORT_485, SYSCAN_DOCKETPORT_665, SYSCAN_DOCKETPORT_685, UMAX_ASTRA_4500, VISIONEER_7100, VISIONEER_ROADWARRIOR, VISIONEER_STROBE_XP100_REVISION3, VISIONEER_STROBE_XP200, VISIONEER_STROBE_XP300, XEROX_2400, XEROX_TRAVELSCANNER_100, }; enum class SensorId : unsigned { UNKNOWN = 0, CCD_5345, CCD_CANON_4400F, CCD_CANON_8400F, CCD_CANON_8600F, CCD_DP665, CCD_DP685, CCD_DSMOBILE600, CCD_G4050, CCD_HP2300, CCD_HP2400, CCD_HP3670, CCD_HP_N6310, CCD_HP_4850C, CCD_IMG101, CCD_KVSS080, CCD_PLUSTEK_OPTICBOOK_3800, CCD_PLUSTEK_OPTICFILM_7200I, CCD_PLUSTEK_OPTICFILM_7300, CCD_PLUSTEK_OPTICFILM_7500I, CCD_PLUSTEK_OPTICPRO_3600, CCD_ROADWARRIOR, CCD_ST12, // SONY ILX548: 5340 Pixel ??? CCD_ST24, // SONY ILX569: 10680 Pixel ??? CCD_UMAX, CCD_XP300, CIS_CANON_LIDE_35, CIS_CANON_LIDE_80, CIS_CANON_LIDE_100, CIS_CANON_LIDE_110, CIS_CANON_LIDE_120, CIS_CANON_LIDE_200, CIS_CANON_LIDE_210, CIS_CANON_LIDE_220, CIS_CANON_LIDE_700F, CIS_XP200, }; inline void serialize(std::istream& str, SensorId& x) { unsigned value; serialize(str, value); x = static_cast(value); } inline void serialize(std::ostream& str, SensorId& x) { unsigned value = static_cast(x); serialize(str, value); } enum class AdcId : unsigned { UNKNOWN = 0, AD_XP200, CANON_LIDE_35, CANON_LIDE_80, CANON_LIDE_110, CANON_LIDE_120, CANON_LIDE_200, CANON_LIDE_700F, CANON_4400F, CANON_8400F, CANON_8600F, G4050, IMG101, KVSS080, PLUSTEK_OPTICBOOK_3800, PLUSTEK_OPTICFILM_7200I, PLUSTEK_OPTICFILM_7300, PLUSTEK_OPTICFILM_7500I, PLUSTEK_OPTICPRO_3600, WOLFSON_5345, WOLFSON_DSM600, WOLFSON_HP2300, WOLFSON_HP2400, WOLFSON_HP3670, WOLFSON_ST12, WOLFSON_ST24, WOLFSON_UMAX, WOLFSON_XP300, }; inline void serialize(std::istream& str, AdcId& x) { unsigned value; serialize(str, value); x = static_cast(value); } inline void serialize(std::ostream& str, AdcId& x) { unsigned value = static_cast(x); serialize(str, value); } enum class GpioId : unsigned { UNKNOWN = 0, CANON_LIDE_35, CANON_LIDE_80, CANON_LIDE_110, CANON_LIDE_120, CANON_LIDE_200, CANON_LIDE_210, CANON_LIDE_700F, CANON_4400F, CANON_8400F, CANON_8600F, DP665, DP685, G4050, HP2300, HP2400, HP3670, HP_N6310, IMG101, KVSS080, MD_5345, PLUSTEK_OPTICBOOK_3800, PLUSTEK_OPTICFILM_7200I, PLUSTEK_OPTICFILM_7300, PLUSTEK_OPTICFILM_7500I, PLUSTEK_OPTICPRO_3600, ST12, ST24, UMAX, XP200, XP300, }; enum class MotorId : unsigned { UNKNOWN = 0, CANON_LIDE_100, CANON_LIDE_110, CANON_LIDE_120, CANON_LIDE_200, CANON_LIDE_210, CANON_LIDE_35, CANON_LIDE_700, CANON_LIDE_80, CANON_4400F, CANON_8400F, CANON_8600F, DP665, DSMOBILE_600, G4050, HP2300, HP2400, HP3670, IMG101, KVSS080, MD_5345, PLUSTEK_OPTICBOOK_3800, PLUSTEK_OPTICFILM_7200I, PLUSTEK_OPTICFILM_7300, PLUSTEK_OPTICFILM_7500I, PLUSTEK_OPTICPRO_3600, ROADWARRIOR, ST24, UMAX, XP200, XP300, }; enum class StepType : unsigned { FULL = 0, HALF = 1, QUARTER = 2, EIGHTH = 3, }; std::ostream& operator<<(std::ostream& out, StepType type); inline bool operator<(StepType lhs, StepType rhs) { return static_cast(lhs) < static_cast(rhs); } inline bool operator<=(StepType lhs, StepType rhs) { return static_cast(lhs) <= static_cast(rhs); } inline bool operator>(StepType lhs, StepType rhs) { return static_cast(lhs) > static_cast(rhs); } inline bool operator>=(StepType lhs, StepType rhs) { return static_cast(lhs) >= static_cast(rhs); } enum class AsicType : unsigned { UNKNOWN = 0, GL646, GL841, GL843, GL845, GL846, GL847, GL124, }; enum class ScanFlag : unsigned { NONE = 0, SINGLE_LINE = 1 << 0, DISABLE_SHADING = 1 << 1, DISABLE_GAMMA = 1 << 2, DISABLE_BUFFER_FULL_MOVE = 1 << 3, IGNORE_LINE_DISTANCE = 1 << 4, DISABLE_LAMP = 1 << 5, CALIBRATION = 1 << 6, FEEDING = 1 << 7, USE_XPA = 1 << 8, ENABLE_LEDADD = 1 << 9, USE_XCORRECTION = 1 << 10, REVERSE = 1 << 11, }; inline ScanFlag operator|(ScanFlag left, ScanFlag right) { return static_cast(static_cast(left) | static_cast(right)); } inline ScanFlag& operator|=(ScanFlag& left, ScanFlag right) { left = left | right; return left; } inline ScanFlag operator&(ScanFlag left, ScanFlag right) { return static_cast(static_cast(left) & static_cast(right)); } inline bool has_flag(ScanFlag flags, ScanFlag which) { return (flags & which) == which; } inline void serialize(std::istream& str, ScanFlag& x) { unsigned value; serialize(str, value); x = static_cast(value); } inline void serialize(std::ostream& str, ScanFlag& x) { unsigned value = static_cast(x); serialize(str, value); } std::ostream& operator<<(std::ostream& out, ScanFlag flags); enum class MotorFlag : unsigned { NONE = 0, AUTO_GO_HOME = 1 << 0, DISABLE_BUFFER_FULL_MOVE = 1 << 2, FEED = 1 << 3, USE_XPA = 1 << 4, REVERSE = 1 << 5, }; inline MotorFlag operator|(MotorFlag left, MotorFlag right) { return static_cast(static_cast(left) | static_cast(right)); } inline MotorFlag& operator|=(MotorFlag& left, MotorFlag right) { left = left | right; return left; } inline MotorFlag operator&(MotorFlag left, MotorFlag right) { return static_cast(static_cast(left) & static_cast(right)); } inline bool has_flag(MotorFlag flags, MotorFlag which) { return (flags & which) == which; } enum class Direction : unsigned { FORWARD = 0, BACKWARD = 1 }; } // namespace genesys #endif // BACKEND_GENESYS_ENUMS_H sane-backends-1.0.29/backend/genesys/gl124_registers.h0000666000000000000000000003074213615534521017344 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL124_REGISTERS_H #define BACKEND_GENESYS_GL124_REGISTERS_H #include namespace genesys { namespace gl124 { using RegAddr = std::uint16_t; using RegMask = std::uint8_t; using RegShift = unsigned; static constexpr RegAddr REG_0x01 = 0x01; static constexpr RegMask REG_0x01_CISSET = 0x80; static constexpr RegMask REG_0x01_DOGENB = 0x40; static constexpr RegMask REG_0x01_DVDSET = 0x20; static constexpr RegMask REG_0x01_STAGGER = 0x10; static constexpr RegMask REG_0x01_COMPENB = 0x08; static constexpr RegMask REG_0x01_TRUEGRAY = 0x04; static constexpr RegMask REG_0x01_SHDAREA = 0x02; static constexpr RegMask REG_0x01_SCAN = 0x01; static constexpr RegAddr REG_0x02 = 0x02; static constexpr RegMask REG_0x02_NOTHOME = 0x80; static constexpr RegMask REG_0x02_ACDCDIS = 0x40; static constexpr RegMask REG_0x02_AGOHOME = 0x20; static constexpr RegMask REG_0x02_MTRPWR = 0x10; static constexpr RegMask REG_0x02_FASTFED = 0x08; static constexpr RegMask REG_0x02_MTRREV = 0x04; static constexpr RegMask REG_0x02_HOMENEG = 0x02; static constexpr RegMask REG_0x02_LONGCURV = 0x01; static constexpr RegAddr REG_0x03 = 0x03; static constexpr RegMask REG_0x03_LAMPDOG = 0x80; static constexpr RegMask REG_0x03_AVEENB = 0x40; static constexpr RegMask REG_0x03_XPASEL = 0x20; static constexpr RegMask REG_0x03_LAMPPWR = 0x10; static constexpr RegMask REG_0x03_LAMPTIM = 0x0f; static constexpr RegAddr REG_0x04 = 0x04; static constexpr RegMask REG_0x04_LINEART = 0x80; static constexpr RegMask REG_0x04_BITSET = 0x40; static constexpr RegMask REG_0x04_FILTER = 0x30; static constexpr RegMask REG_0x04_AFEMOD = 0x07; static constexpr RegAddr REG_0x05 = 0x05; static constexpr RegMask REG_0x05_DPIHW = 0xc0; static constexpr RegMask REG_0x05_DPIHW_600 = 0x00; static constexpr RegMask REG_0x05_DPIHW_1200 = 0x40; static constexpr RegMask REG_0x05_DPIHW_2400 = 0x80; static constexpr RegMask REG_0x05_DPIHW_4800 = 0xc0; static constexpr RegMask REG_0x05_MTLLAMP = 0x30; static constexpr RegMask REG_0x05_GMMENB = 0x08; static constexpr RegMask REG_0x05_ENB20M = 0x04; static constexpr RegMask REG_0x05_MTLBASE = 0x03; static constexpr RegAddr REG_0x06 = 0x06; static constexpr RegMask REG_0x06_SCANMOD = 0xe0; static constexpr RegMask REG_0x06S_SCANMOD = 5; static constexpr RegMask REG_0x06_PWRBIT = 0x10; static constexpr RegMask REG_0x06_GAIN4 = 0x08; static constexpr RegMask REG_0x06_OPTEST = 0x07; static constexpr RegMask REG_0x07_LAMPSIM = 0x80; static constexpr RegMask REG_0x08_DRAM2X = 0x80; static constexpr RegMask REG_0x08_MPENB = 0x20; static constexpr RegMask REG_0x08_CIS_LINE = 0x10; static constexpr RegMask REG_0x08_IR2_ENB = 0x08; static constexpr RegMask REG_0x08_IR1_ENB = 0x04; static constexpr RegMask REG_0x08_ENB24M = 0x01; static constexpr RegMask REG_0x09_MCNTSET = 0xc0; static constexpr RegMask REG_0x09_EVEN1ST = 0x20; static constexpr RegMask REG_0x09_BLINE1ST = 0x10; static constexpr RegMask REG_0x09_BACKSCAN = 0x08; static constexpr RegMask REG_0x09_OUTINV = 0x04; static constexpr RegMask REG_0x09_SHORTTG = 0x02; static constexpr RegShift REG_0x09S_MCNTSET = 6; static constexpr RegShift REG_0x09S_CLKSET = 4; static constexpr RegAddr REG_0x0A = 0x0a; static constexpr RegMask REG_0x0A_SIFSEL = 0xc0; static constexpr RegShift REG_0x0AS_SIFSEL = 6; static constexpr RegMask REG_0x0A_SHEETFED = 0x20; static constexpr RegMask REG_0x0A_LPWMEN = 0x10; static constexpr RegAddr REG_0x0B = 0x0b; static constexpr RegMask REG_0x0B_DRAMSEL = 0x07; static constexpr RegMask REG_0x0B_16M = 0x01; static constexpr RegMask REG_0x0B_64M = 0x02; static constexpr RegMask REG_0x0B_128M = 0x03; static constexpr RegMask REG_0x0B_256M = 0x04; static constexpr RegMask REG_0x0B_512M = 0x05; static constexpr RegMask REG_0x0B_1G = 0x06; static constexpr RegMask REG_0x0B_ENBDRAM = 0x08; static constexpr RegMask REG_0x0B_RFHDIS = 0x10; static constexpr RegMask REG_0x0B_CLKSET = 0xe0; static constexpr RegMask REG_0x0B_24MHZ = 0x00; static constexpr RegMask REG_0x0B_30MHZ = 0x20; static constexpr RegMask REG_0x0B_40MHZ = 0x40; static constexpr RegMask REG_0x0B_48MHZ = 0x60; static constexpr RegMask REG_0x0B_60MHZ = 0x80; static constexpr RegAddr REG_0x0D = 0x0d; static constexpr RegMask REG_0x0D_MTRP_RDY = 0x80; static constexpr RegMask REG_0x0D_FULLSTP = 0x10; static constexpr RegMask REG_0x0D_CLRMCNT = 0x04; static constexpr RegMask REG_0x0D_CLRDOCJM = 0x02; static constexpr RegMask REG_0x0D_CLRLNCNT = 0x01; static constexpr RegAddr REG_0x0F = 0x0f; static constexpr RegMask REG_0x16_CTRLHI = 0x80; static constexpr RegMask REG_0x16_TOSHIBA = 0x40; static constexpr RegMask REG_0x16_TGINV = 0x20; static constexpr RegMask REG_0x16_CK1INV = 0x10; static constexpr RegMask REG_0x16_CK2INV = 0x08; static constexpr RegMask REG_0x16_CTRLINV = 0x04; static constexpr RegMask REG_0x16_CKDIS = 0x02; static constexpr RegMask REG_0x16_CTRLDIS = 0x01; static constexpr RegMask REG_0x17_TGMODE = 0xc0; static constexpr RegMask REG_0x17_SNRSYN = 0x0f; static constexpr RegAddr REG_0x18 = 0x18; static constexpr RegMask REG_0x18_CNSET = 0x80; static constexpr RegMask REG_0x18_DCKSEL = 0x60; static constexpr RegMask REG_0x18_CKTOGGLE = 0x10; static constexpr RegMask REG_0x18_CKDELAY = 0x0c; static constexpr RegMask REG_0x18_CKSEL = 0x03; static constexpr RegMask REG_0x1A_SW2SET = 0x80; static constexpr RegMask REG_0x1A_SW1SET = 0x40; static constexpr RegMask REG_0x1A_MANUAL3 = 0x02; static constexpr RegMask REG_0x1A_MANUAL1 = 0x01; static constexpr RegMask REG_0x1A_CK4INV = 0x08; static constexpr RegMask REG_0x1A_CK3INV = 0x04; static constexpr RegMask REG_0x1A_LINECLP = 0x02; static constexpr RegMask REG_0x1C_TBTIME = 0x07; static constexpr RegAddr REG_0x1D = 0x1d; static constexpr RegMask REG_0x1D_CK4LOW = 0x80; static constexpr RegMask REG_0x1D_CK3LOW = 0x40; static constexpr RegMask REG_0x1D_CK1LOW = 0x20; static constexpr RegMask REG_0x1D_LINESEL = 0x1f; static constexpr RegShift REG_0x1DS_LINESEL = 0; static constexpr RegAddr REG_0x1E = 0x1e; static constexpr RegMask REG_0x1E_WDTIME = 0xf0; static constexpr RegShift REG_0x1ES_WDTIME = 4; static constexpr RegAddr REG_0x30 = 0x30; static constexpr RegAddr REG_0x31 = 0x31; static constexpr RegAddr REG_0x32 = 0x32; static constexpr RegMask REG_0x32_GPIO16 = 0x80; static constexpr RegMask REG_0x32_GPIO15 = 0x40; static constexpr RegMask REG_0x32_GPIO14 = 0x20; static constexpr RegMask REG_0x32_GPIO13 = 0x10; static constexpr RegMask REG_0x32_GPIO12 = 0x08; static constexpr RegMask REG_0x32_GPIO11 = 0x04; static constexpr RegMask REG_0x32_GPIO10 = 0x02; static constexpr RegMask REG_0x32_GPIO9 = 0x01; static constexpr RegAddr REG_0x33 = 0x33; static constexpr RegAddr REG_0x34 = 0x34; static constexpr RegAddr REG_0x35 = 0x35; static constexpr RegAddr REG_0x36 = 0x36; static constexpr RegAddr REG_0x37 = 0x37; static constexpr RegAddr REG_0x38 = 0x38; static constexpr RegAddr REG_0x39 = 0x39; static constexpr RegAddr REG_0x60 = 0x60; static constexpr RegMask REG_0x60_LED4TG = 0x80; static constexpr RegMask REG_0x60_YENB = 0x40; static constexpr RegMask REG_0x60_YBIT = 0x20; static constexpr RegMask REG_0x60_ACYNCNRLC = 0x10; static constexpr RegMask REG_0x60_ENOFFSET = 0x08; static constexpr RegMask REG_0x60_LEDADD = 0x04; static constexpr RegMask REG_0x60_CK4ADC = 0x02; static constexpr RegMask REG_0x60_AUTOCONF = 0x01; static constexpr RegAddr REG_0x80 = 0x80; static constexpr RegAddr REG_0x81 = 0x81; static constexpr RegAddr REG_0xA0 = 0xa0; static constexpr RegMask REG_0xA0_FSTPSEL = 0x38; static constexpr RegShift REG_0xA0S_FSTPSEL = 3; static constexpr RegMask REG_0xA0_STEPSEL = 0x07; static constexpr RegShift REG_0xA0S_STEPSEL = 0; static constexpr RegAddr REG_0xA1 = 0xa1; static constexpr RegAddr REG_0xA2 = 0xa2; static constexpr RegAddr REG_0xA3 = 0xa3; static constexpr RegAddr REG_0xA4 = 0xa4; static constexpr RegAddr REG_0xA5 = 0xa5; static constexpr RegAddr REG_0xA6 = 0xa6; static constexpr RegAddr REG_0xA7 = 0xa7; static constexpr RegAddr REG_0xA8 = 0xa8; static constexpr RegAddr REG_0xA9 = 0xa9; static constexpr RegAddr REG_0xAA = 0xaa; static constexpr RegAddr REG_0xAB = 0xab; static constexpr RegAddr REG_0xAC = 0xac; static constexpr RegAddr REG_0xAD = 0xad; static constexpr RegAddr REG_0xAE = 0xae; static constexpr RegAddr REG_0xAF = 0xaf; static constexpr RegAddr REG_0xB0 = 0xb0; static constexpr RegAddr REG_0xB1 = 0xb1; static constexpr RegAddr REG_0xB2 = 0xb2; static constexpr RegMask REG_0xB2_Z1MOD = 0x1f; static constexpr RegAddr REG_0xB3 = 0xb3; static constexpr RegMask REG_0xB3_Z1MOD = 0xff; static constexpr RegAddr REG_0xB4 = 0xb4; static constexpr RegMask REG_0xB4_Z1MOD = 0xff; static constexpr RegAddr REG_0xB5 = 0xb5; static constexpr RegMask REG_0xB5_Z2MOD = 0x1f; static constexpr RegAddr REG_0xB6 = 0xb6; static constexpr RegMask REG_0xB6_Z2MOD = 0xff; static constexpr RegAddr REG_0xB7 = 0xb7; static constexpr RegMask REG_0xB7_Z2MOD = 0xff; static constexpr RegAddr REG_0x100 = 0x100; static constexpr RegMask REG_0x100_DOCSNR = 0x80; static constexpr RegMask REG_0x100_ADFSNR = 0x40; static constexpr RegMask REG_0x100_COVERSNR = 0x20; static constexpr RegMask REG_0x100_CHKVER = 0x10; static constexpr RegMask REG_0x100_DOCJAM = 0x08; static constexpr RegMask REG_0x100_HISPDFLG = 0x04; static constexpr RegMask REG_0x100_MOTMFLG = 0x02; static constexpr RegMask REG_0x100_DATAENB = 0x01; static constexpr RegAddr REG_0x114 = 0x114; static constexpr RegAddr REG_0x115 = 0x115; static constexpr RegAddr REG_LINCNT = 0x25; static constexpr RegAddr REG_MAXWD = 0x28; static constexpr RegAddr REG_DPISET = 0x2c; static constexpr RegAddr REG_FEEDL = 0x3d; static constexpr RegAddr REG_CK1MAP = 0x74; static constexpr RegAddr REG_CK3MAP = 0x77; static constexpr RegAddr REG_CK4MAP = 0x7a; static constexpr RegAddr REG_LPERIOD = 0x7d; static constexpr RegAddr REG_DUMMY = 0x80; static constexpr RegAddr REG_STRPIXEL = 0x82; static constexpr RegAddr REG_ENDPIXEL = 0x85; static constexpr RegAddr REG_EXPDMY = 0x88; static constexpr RegAddr REG_EXPR = 0x8a; static constexpr RegAddr REG_EXPG = 0x8d; static constexpr RegAddr REG_EXPB = 0x90; static constexpr RegAddr REG_SEGCNT = 0x93; static constexpr RegAddr REG_TG0CNT = 0x96; static constexpr RegAddr REG_SCANFED = 0xa2; static constexpr RegAddr REG_STEPNO = 0xa4; static constexpr RegAddr REG_FWDSTEP = 0xa6; static constexpr RegAddr REG_BWDSTEP = 0xa8; static constexpr RegAddr REG_FASTNO = 0xaa; static constexpr RegAddr REG_FSHDEC = 0xac; static constexpr RegAddr REG_FMOVNO = 0xae; static constexpr RegAddr REG_FMOVDEC = 0xb0; static constexpr RegAddr REG_Z1MOD = 0xb2; static constexpr RegAddr REG_Z2MOD = 0xb5; static constexpr RegAddr REG_TRUER = 0x110; static constexpr RegAddr REG_TRUEG = 0x111; static constexpr RegAddr REG_TRUEB = 0x112; } // namespace gl124 } // namespace genesys #endif // BACKEND_GENESYS_GL843_REGISTERS_H sane-backends-1.0.29/backend/genesys/sensor.h0000666000000000000000000003505713615534521015741 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_SENSOR_H #define BACKEND_GENESYS_SENSOR_H #include "enums.h" #include "register.h" #include "serialize.h" #include #include namespace genesys { template struct AssignableArray : public std::array { AssignableArray() = default; AssignableArray(const AssignableArray&) = default; AssignableArray& operator=(const AssignableArray&) = default; AssignableArray& operator=(std::initializer_list init) { if (init.size() != std::array::size()) throw std::runtime_error("An array of incorrect size assigned"); std::copy(init.begin(), init.end(), std::array::begin()); return *this; } }; class StaggerConfig { public: StaggerConfig() = default; StaggerConfig(unsigned min_resolution, unsigned lines_at_min) : min_resolution_{min_resolution}, lines_at_min_{lines_at_min} { } unsigned stagger_at_resolution(unsigned xresolution, unsigned yresolution) const { if (min_resolution_ == 0 || xresolution < min_resolution_) return 0; return yresolution / min_resolution_ * lines_at_min_; } unsigned min_resolution() const { return min_resolution_; } unsigned lines_at_min() const { return lines_at_min_; } bool operator==(const StaggerConfig& other) const { return min_resolution_ == other.min_resolution_ && lines_at_min_ == other.lines_at_min_; } private: unsigned min_resolution_ = 0; unsigned lines_at_min_ = 0; template friend void serialize(Stream& str, StaggerConfig& x); }; template void serialize(Stream& str, StaggerConfig& x) { serialize(str, x.min_resolution_); serialize(str, x.lines_at_min_); } std::ostream& operator<<(std::ostream& out, const StaggerConfig& config); enum class FrontendType : unsigned { UNKNOWN, WOLFSON, ANALOG_DEVICES }; inline void serialize(std::istream& str, FrontendType& x) { unsigned value; serialize(str, value); x = static_cast(value); } inline void serialize(std::ostream& str, FrontendType& x) { unsigned value = static_cast(x); serialize(str, value); } std::ostream& operator<<(std::ostream& out, const FrontendType& type); struct GenesysFrontendLayout { FrontendType type = FrontendType::UNKNOWN; std::array offset_addr = {}; std::array gain_addr = {}; bool operator==(const GenesysFrontendLayout& other) const { return type == other.type && offset_addr == other.offset_addr && gain_addr == other.gain_addr; } }; template void serialize(Stream& str, GenesysFrontendLayout& x) { serialize(str, x.type); serialize_newline(str); serialize(str, x.offset_addr); serialize_newline(str); serialize(str, x.gain_addr); } std::ostream& operator<<(std::ostream& out, const GenesysFrontendLayout& layout); /** @brief Data structure to set up analog frontend. The analog frontend converts analog value from image sensor to digital value. It has its own control registers which are set up with this structure. The values are written using fe_write_data. */ struct Genesys_Frontend { Genesys_Frontend() = default; // id of the frontend description AdcId id = AdcId::UNKNOWN; // all registers of the frontend. Note that the registers can hold 9-bit values RegisterSettingSet regs; // extra control registers std::array reg2 = {}; GenesysFrontendLayout layout; void set_offset(unsigned which, std::uint16_t value) { regs.set_value(layout.offset_addr[which], value); } void set_gain(unsigned which, std::uint16_t value) { regs.set_value(layout.gain_addr[which], value); } std::uint16_t get_offset(unsigned which) const { return regs.get_value(layout.offset_addr[which]); } std::uint16_t get_gain(unsigned which) const { return regs.get_value(layout.gain_addr[which]); } bool operator==(const Genesys_Frontend& other) const { return id == other.id && regs == other.regs && reg2 == other.reg2 && layout == other.layout; } }; std::ostream& operator<<(std::ostream& out, const Genesys_Frontend& frontend); template void serialize(Stream& str, Genesys_Frontend& x) { serialize(str, x.id); serialize_newline(str); serialize(str, x.regs); serialize_newline(str); serialize(str, x.reg2); serialize_newline(str); serialize(str, x.layout); } struct SensorExposure { std::uint16_t red = 0; std::uint16_t green = 0; std::uint16_t blue = 0; SensorExposure() = default; SensorExposure(std::uint16_t r, std::uint16_t g, std::uint16_t b) : red{r}, green{g}, blue{b} {} bool operator==(const SensorExposure& other) const { return red == other.red && green == other.green && blue == other.blue; } }; std::ostream& operator<<(std::ostream& out, const SensorExposure& exposure); class ResolutionFilter { public: struct Any {}; static constexpr Any ANY{}; ResolutionFilter() : matches_any_{false} {} ResolutionFilter(Any) : matches_any_{true} {} ResolutionFilter(std::initializer_list resolutions) : matches_any_{false}, resolutions_{resolutions} {} bool matches(unsigned resolution) const { if (matches_any_) return true; auto it = std::find(resolutions_.begin(), resolutions_.end(), resolution); return it != resolutions_.end(); } bool operator==(const ResolutionFilter& other) const { return matches_any_ == other.matches_any_ && resolutions_ == other.resolutions_; } bool matches_any() const { return matches_any_; } const std::vector& resolutions() const { return resolutions_; } private: bool matches_any_ = false; std::vector resolutions_; template friend void serialize(Stream& str, ResolutionFilter& x); }; std::ostream& operator<<(std::ostream& out, const ResolutionFilter& resolutions); template void serialize(Stream& str, ResolutionFilter& x) { serialize(str, x.matches_any_); serialize_newline(str); serialize(str, x.resolutions_); } struct Genesys_Sensor { Genesys_Sensor() = default; ~Genesys_Sensor() = default; // id of the sensor description SensorId sensor_id = SensorId::UNKNOWN; // sensor resolution in CCD pixels. Note that we may read more than one CCD pixel per logical // pixel, see ccd_pixels_per_system_pixel() unsigned optical_res = 0; // the resolution list that the sensor is usable at. ResolutionFilter resolutions = ResolutionFilter::ANY; // the channel list that the sensor is usable at std::vector channels = { 1, 3 }; // the scan method used with the sensor ScanMethod method = ScanMethod::FLATBED; // The scanner may be setup to use a custom dpihw that does not correspond to any actual // resolution. The value zero does not set the override. unsigned register_dpihw_override = 0; // The scanner may be setup to use a custom logical dpihw that does not correspond to any actual // resolution. The value zero does not set the override. unsigned logical_dpihw_override = 0; // The scanner may be setup to use a custom dpiset value that does not correspond to any actual // resolution. The value zero does not set the override. unsigned dpiset_override = 0; // CCD may present itself as half or quarter-size CCD on certain resolutions int ccd_size_divisor = 1; // Some scanners need an additional multiplier over the scan coordinates int pixel_count_multiplier = 1; int black_pixels = 0; // value of the dummy register int dummy_pixel = 0; // last pixel of CCD margin at optical resolution int ccd_start_xoffset = 0; // total pixels used by the sensor int sensor_pixels = 0; // TA CCD target code (reference gain) int fau_gain_white_ref = 0; // CCD target code (reference gain) int gain_white_ref = 0; // red, green and blue initial exposure values SensorExposure exposure; int exposure_lperiod = -1; // the number of pixels in a single segment. // only on gl843 unsigned segment_size = 0; // the order of the segments, if any, for the sensor. If the sensor is not segmented or uses // only single segment, this array can be empty // only on gl843 std::vector segment_order; // some CCDs use two arrays of pixels for double resolution. On such CCDs when scanning at // high-enough resolution, every other pixel column is shifted StaggerConfig stagger_config; GenesysRegisterSettingSet custom_base_regs; // gl646-specific GenesysRegisterSettingSet custom_regs; GenesysRegisterSettingSet custom_fe_regs; // red, green and blue gamma coefficient for default gamma tables AssignableArray gamma; std::function get_logical_hwdpi_fun; std::function get_register_hwdpi_fun; std::function get_ccd_size_divisor_fun; std::function get_hwdpi_divisor_fun; unsigned get_logical_hwdpi(unsigned xres) const { return get_logical_hwdpi_fun(*this, xres); } unsigned get_register_hwdpi(unsigned xres) const { return get_register_hwdpi_fun(*this, xres); } unsigned get_ccd_size_divisor_for_dpi(unsigned xres) const { return get_ccd_size_divisor_fun(*this, xres); } unsigned get_hwdpi_divisor_for_dpi(unsigned xres) const { return get_hwdpi_divisor_fun(*this, xres); } // how many CCD pixels are processed per system pixel time. This corresponds to CKSEL + 1 unsigned ccd_pixels_per_system_pixel() const { // same on GL646, GL841, GL843, GL846, GL847, GL124 constexpr unsigned REG_CKSEL = 0x03; return (custom_regs.get_value(0x18) & REG_CKSEL) + 1; } bool matches_channel_count(unsigned count) const { return std::find(channels.begin(), channels.end(), count) != channels.end(); } unsigned get_segment_count() const { if (segment_order.size() < 2) return 1; return segment_order.size(); } bool operator==(const Genesys_Sensor& other) const { return sensor_id == other.sensor_id && optical_res == other.optical_res && resolutions == other.resolutions && method == other.method && ccd_size_divisor == other.ccd_size_divisor && black_pixels == other.black_pixels && dummy_pixel == other.dummy_pixel && ccd_start_xoffset == other.ccd_start_xoffset && sensor_pixels == other.sensor_pixels && fau_gain_white_ref == other.fau_gain_white_ref && gain_white_ref == other.gain_white_ref && exposure == other.exposure && exposure_lperiod == other.exposure_lperiod && segment_size == other.segment_size && segment_order == other.segment_order && stagger_config == other.stagger_config && custom_base_regs == other.custom_base_regs && custom_regs == other.custom_regs && custom_fe_regs == other.custom_fe_regs && gamma == other.gamma; } }; template void serialize(Stream& str, Genesys_Sensor& x) { serialize(str, x.sensor_id); serialize(str, x.optical_res); serialize(str, x.resolutions); serialize(str, x.method); serialize(str, x.ccd_size_divisor); serialize(str, x.black_pixels); serialize(str, x.dummy_pixel); serialize(str, x.ccd_start_xoffset); serialize(str, x.sensor_pixels); serialize(str, x.fau_gain_white_ref); serialize(str, x.gain_white_ref); serialize_newline(str); serialize(str, x.exposure.blue); serialize(str, x.exposure.green); serialize(str, x.exposure.red); serialize(str, x.exposure_lperiod); serialize_newline(str); serialize(str, x.segment_size); serialize_newline(str); serialize(str, x.segment_order); serialize_newline(str); serialize(str, x.stagger_config); serialize_newline(str); serialize(str, x.custom_base_regs); serialize_newline(str); serialize(str, x.custom_regs); serialize_newline(str); serialize(str, x.custom_fe_regs); serialize_newline(str); serialize(str, x.gamma); serialize_newline(str); } std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor); } // namespace genesys #endif // BACKEND_GENESYS_SENSOR_H sane-backends-1.0.29/backend/genesys/image.h0000666000000000000000000000634013615534521015503 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_IMAGE_H #define BACKEND_GENESYS_IMAGE_H #include "image_pixel.h" #include namespace genesys { class Image { public: Image(); Image(std::size_t width, std::size_t height, PixelFormat format); std::size_t get_width() const { return width_; } std::size_t get_height() const { return height_; } PixelFormat get_format() const { return format_; } std::size_t get_row_bytes() const { return row_bytes_; } std::uint8_t* get_row_ptr(std::size_t y); const std::uint8_t* get_row_ptr(std::size_t y) const; Pixel get_pixel(std::size_t x, std::size_t y) const; void set_pixel(std::size_t x, std::size_t y, const Pixel& pixel); RawPixel get_raw_pixel(std::size_t x, std::size_t y) const; std::uint16_t get_raw_channel(std::size_t x, std::size_t y, unsigned channel) const; void set_raw_pixel(std::size_t x, std::size_t y, const RawPixel& pixel); void resize(std::size_t width, std::size_t height, PixelFormat format); private: std::size_t width_ = 0; std::size_t height_ = 0; PixelFormat format_ = PixelFormat::UNKNOWN; std::size_t row_bytes_ = 0; std::vector data_; }; void convert_pixel_row_format(const std::uint8_t* in_data, PixelFormat in_format, std::uint8_t* out_data, PixelFormat out_format, std::size_t count); } // namespace genesys #endif // ifndef BACKEND_GENESYS_IMAGE_H sane-backends-1.0.29/backend/genesys/status.cpp0000666000000000000000000000533313615534521016300 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "status.h" #include namespace genesys { std::ostream& operator<<(std::ostream& out, Status status) { out << "Status{\n" << " replugged: " << (status.is_replugged ? "yes" : "no") << '\n' << " is_buffer_empty: " << (status.is_buffer_empty ? "yes" : "no") << '\n' << " is_feeding_finished: " << (status.is_feeding_finished ? "yes" : "no") << '\n' << " is_scanning_finished: " << (status.is_scanning_finished ? "yes" : "no") << '\n' << " is_at_home: " << (status.is_at_home ? "yes" : "no") << '\n' << " is_lamp_on: " << (status.is_lamp_on ? "yes" : "no") << '\n' << " is_front_end_busy: " << (status.is_front_end_busy ? "yes" : "no") << '\n' << " is_motor_enabled: " << (status.is_motor_enabled ? "yes" : "no") << '\n' << "}\n"; return out; } } // namespace genesys sane-backends-1.0.29/backend/genesys/gl646_registers.h0000666000000000000000000001554313615534521017357 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL646_REGISTERS_H #define BACKEND_GENESYS_GL646_REGISTERS_H #include namespace genesys { namespace gl646 { using RegAddr = std::uint16_t; using RegMask = std::uint8_t; using RegShift = unsigned; static constexpr RegAddr REG_0x01 = 0x01; static constexpr RegMask REG_0x01_CISSET = 0x80; static constexpr RegMask REG_0x01_DOGENB = 0x40; static constexpr RegMask REG_0x01_DVDSET = 0x20; static constexpr RegMask REG_0x01_FASTMOD = 0x10; static constexpr RegMask REG_0x01_COMPENB = 0x08; static constexpr RegMask REG_0x01_DRAMSEL = 0x04; static constexpr RegMask REG_0x01_SHDAREA = 0x02; static constexpr RegMask REG_0x01_SCAN = 0x01; static constexpr RegMask REG_0x02_NOTHOME = 0x80; static constexpr RegMask REG_0x02_ACDCDIS = 0x40; static constexpr RegMask REG_0x02_AGOHOME = 0x20; static constexpr RegMask REG_0x02_MTRPWR = 0x10; static constexpr RegMask REG_0x02_FASTFED = 0x08; static constexpr RegMask REG_0x02_MTRREV = 0x04; static constexpr RegMask REG_0x02_STEPSEL = 0x03; static constexpr RegMask REG_0x02_FULLSTEP = 0x00; static constexpr RegMask REG_0x02_HALFSTEP = 0x01; static constexpr RegMask REG_0x02_QUATERSTEP = 0x02; static constexpr RegMask REG_0x03_TG3 = 0x80; static constexpr RegMask REG_0x03_AVEENB = 0x40; static constexpr RegMask REG_0x03_XPASEL = 0x20; static constexpr RegMask REG_0x03_LAMPPWR = 0x10; static constexpr RegMask REG_0x03_LAMPDOG = 0x08; static constexpr RegMask REG_0x03_LAMPTIM = 0x07; static constexpr RegMask REG_0x04_LINEART = 0x80; static constexpr RegMask REG_0x04_BITSET = 0x40; static constexpr RegMask REG_0x04_ADTYPE = 0x30; static constexpr RegMask REG_0x04_FILTER = 0x0c; static constexpr RegMask REG_0x04_FESET = 0x03; static constexpr RegMask REG_0x05_DPIHW = 0xc0; static constexpr RegMask REG_0x05_DPIHW_600 = 0x00; static constexpr RegMask REG_0x05_DPIHW_1200 = 0x40; static constexpr RegMask REG_0x05_DPIHW_2400 = 0x80; static constexpr RegMask REG_0x05_DPIHW_4800 = 0xc0; static constexpr RegMask REG_0x05_GMMTYPE = 0x30; static constexpr RegMask REG_0x05_GMM14BIT = 0x10; static constexpr RegMask REG_0x05_GMMENB = 0x08; static constexpr RegMask REG_0x05_LEDADD = 0x04; static constexpr RegMask REG_0x05_BASESEL = 0x03; static constexpr RegAddr REG_0x06 = 0x06; static constexpr RegMask REG_0x06_PWRBIT = 0x10; static constexpr RegMask REG_0x06_GAIN4 = 0x08; static constexpr RegMask REG_0x06_OPTEST = 0x07; static constexpr RegMask REG_0x07_DMASEL = 0x02; static constexpr RegMask REG_0x07_DMARDWR = 0x01; static constexpr RegMask REG_0x16_CTRLHI = 0x80; static constexpr RegMask REG_0x16_SELINV = 0x40; static constexpr RegMask REG_0x16_TGINV = 0x20; static constexpr RegMask REG_0x16_CK1INV = 0x10; static constexpr RegMask REG_0x16_CK2INV = 0x08; static constexpr RegMask REG_0x16_CTRLINV = 0x04; static constexpr RegMask REG_0x16_CKDIS = 0x02; static constexpr RegMask REG_0x16_CTRLDIS = 0x01; static constexpr RegMask REG_0x17_TGMODE = 0xc0; static constexpr RegMask REG_0x17_TGMODE_NO_DUMMY = 0x00; static constexpr RegMask REG_0x17_TGMODE_REF = 0x40; static constexpr RegMask REG_0x17_TGMODE_XPA = 0x80; static constexpr RegMask REG_0x17_TGW = 0x3f; static constexpr RegMask REG_0x18_CNSET = 0x80; static constexpr RegMask REG_0x18_DCKSEL = 0x60; static constexpr RegMask REG_0x18_CKTOGGLE = 0x10; static constexpr RegMask REG_0x18_CKDELAY = 0x0c; static constexpr RegMask REG_0x18_CKSEL = 0x03; static constexpr RegMask REG_0x1D_CKMANUAL = 0x80; static constexpr RegMask REG_0x1E_WDTIME = 0xf0; static constexpr RegMask REG_0x1E_LINESEL = 0x0f; static constexpr RegMask REG_0x41_PWRBIT = 0x80; static constexpr RegMask REG_0x41_BUFEMPTY = 0x40; static constexpr RegMask REG_0x41_FEEDFSH = 0x20; static constexpr RegMask REG_0x41_SCANFSH = 0x10; static constexpr RegMask REG_0x41_HOMESNR = 0x08; static constexpr RegMask REG_0x41_LAMPSTS = 0x04; static constexpr RegMask REG_0x41_FEBUSY = 0x02; static constexpr RegMask REG_0x41_MOTMFLG = 0x01; static constexpr RegMask REG_0x66_LOW_CURRENT = 0x10; static constexpr RegMask REG_0x6A_FSTPSEL = 0xc0; static constexpr RegMask REG_0x6A_FASTPWM = 0x3f; static constexpr RegMask REG_0x6C_TGTIME = 0xc0; static constexpr RegMask REG_0x6C_Z1MOD = 0x38; static constexpr RegMask REG_0x6C_Z2MOD = 0x07; static constexpr RegAddr REG_EXPR = 0x10; static constexpr RegAddr REG_EXPG = 0x12; static constexpr RegAddr REG_EXPB = 0x14; static constexpr RegAddr REG_SCANFED = 0x1f; static constexpr RegAddr REG_BUFSEL = 0x20; static constexpr RegAddr REG_LINCNT = 0x25; static constexpr RegAddr REG_DPISET = 0x2c; static constexpr RegAddr REG_STRPIXEL = 0x30; static constexpr RegAddr REG_ENDPIXEL = 0x32; static constexpr RegAddr REG_DUMMY = 0x34; static constexpr RegAddr REG_MAXWD = 0x35; static constexpr RegAddr REG_LPERIOD = 0x38; static constexpr RegAddr REG_FEEDL = 0x3d; static constexpr RegAddr REG_VALIDWORD = 0x42; static constexpr RegAddr REG_FEDCNT = 0x48; static constexpr RegAddr REG_SCANCNT = 0x4b; static constexpr RegAddr REG_Z1MOD = 0x60; static constexpr RegAddr REG_Z2MOD = 0x62; } // namespace gl646 } // namespace genesys #endif // BACKEND_GENESYS_GL646_REGISTERS_H sane-backends-1.0.29/backend/genesys/gl843.h0000666000000000000000000001301513615534521015257 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2010-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "genesys.h" #include "command_set.h" #ifndef BACKEND_GENESYS_GL843_H #define BACKEND_GENESYS_GL843_H namespace genesys { namespace gl843 { class CommandSetGl843 : public CommandSet { public: ~CommandSetGl843() override = default; bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const override; void init(Genesys_Device* dev) const override; void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const override; void init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const override; void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const override; void set_powersaving(Genesys_Device* dev, int delay) const override; void save_power(Genesys_Device* dev, bool enable) const override; void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, bool start_motor) const override; void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void search_start_position(Genesys_Device* dev) const override; void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const override; SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void wait_for_motor_stop(Genesys_Device* dev) const override; void move_back_home(Genesys_Device* dev, bool wait_until_home) const override; void update_hardware_sensors(struct Genesys_Scanner* s) const override; void load_document(Genesys_Device* dev) const override; void detect_document_end(Genesys_Device* dev) const override; void eject_document(Genesys_Device* dev) const override; void search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const override; void move_to_ta(Genesys_Device* dev) const override; void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const override; ScanSession calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const override; void asic_boot(Genesys_Device* dev, bool cold) const override; }; enum SlopeTable { SCAN_TABLE = 0, // table 1 at 0x4000 BACKTRACK_TABLE = 1, // table 2 at 0x4800 STOP_TABLE = 2, // table 3 at 0x5000 FAST_TABLE = 3, // table 4 at 0x5800 HOME_TABLE = 4, // table 5 at 0x6000 }; } // namespace gl843 } // namespace genesys #endif // BACKEND_GENESYS_GL843_H sane-backends-1.0.29/backend/genesys/genesys.h0000666000000000000000000001505413615534521016100 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2003, 2004 Henning Meier-Geinitz Copyright (C) 2005-2013 Stephane Voltz Copyright (C) 2006 Laurent Charpentier Copyright (C) 2009 Pierre Willenbrock 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef GENESYS_H #define GENESYS_H #ifndef BACKEND_NAME # define BACKEND_NAME genesys #endif #include "low.h" #include #ifndef PATH_MAX # define PATH_MAX 1024 #endif #if defined(_WIN32) || defined(HAVE_OS2_H) # define PATH_SEP '\\' #else # define PATH_SEP '/' #endif #define ENABLE(OPTION) s->opt[OPTION].cap &= ~SANE_CAP_INACTIVE #define DISABLE(OPTION) s->opt[OPTION].cap |= SANE_CAP_INACTIVE #define IS_ACTIVE(OPTION) (((s->opt[OPTION].cap) & SANE_CAP_INACTIVE) == 0) #define GENESYS_CONFIG_FILE "genesys.conf" #ifndef SANE_I18N #define SANE_I18N(text) text #endif #define STR_FLATBED SANE_I18N("Flatbed") #define STR_TRANSPARENCY_ADAPTER SANE_I18N("Transparency Adapter") #define STR_TRANSPARENCY_ADAPTER_INFRARED SANE_I18N("Transparency Adapter Infrared") namespace genesys { /** List of SANE options */ enum Genesys_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_SOURCE, OPT_PREVIEW, OPT_BIT_DEPTH, OPT_RESOLUTION, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ /* advanced image enhancement options */ OPT_ENHANCEMENT_GROUP, OPT_CUSTOM_GAMMA, /* toggle to enable custom gamma tables */ OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, OPT_SWDESKEW, OPT_SWCROP, OPT_SWDESPECK, OPT_DESPECK, OPT_SWSKIP, OPT_SWDEROTATE, OPT_BRIGHTNESS, OPT_CONTRAST, OPT_EXTRAS_GROUP, OPT_LAMP_OFF_TIME, OPT_LAMP_OFF, OPT_THRESHOLD, OPT_THRESHOLD_CURVE, OPT_DISABLE_INTERPOLATION, OPT_COLOR_FILTER, OPT_CALIBRATION_FILE, OPT_EXPIRATION_TIME, OPT_SENSOR_GROUP, OPT_SCAN_SW, OPT_FILE_SW, OPT_EMAIL_SW, OPT_COPY_SW, OPT_PAGE_LOADED_SW, OPT_OCR_SW, OPT_POWER_SW, OPT_EXTRA_SW, OPT_NEED_CALIBRATION_SW, OPT_BUTTON_GROUP, OPT_CALIBRATE, OPT_CLEAR_CALIBRATION, OPT_FORCE_CALIBRATION, OPT_IGNORE_OFFSETS, /* must come last: */ NUM_OPTIONS }; enum GenesysButtonName : unsigned { BUTTON_SCAN_SW = 0, BUTTON_FILE_SW, BUTTON_EMAIL_SW, BUTTON_COPY_SW, BUTTON_PAGE_LOADED_SW, BUTTON_OCR_SW, BUTTON_POWER_SW, BUTTON_EXTRA_SW, NUM_BUTTONS }; GenesysButtonName genesys_option_to_button(int option); class GenesysButton { public: void write(bool value) { if (value == value_) { return; } values_to_read_.push(value); value_ = value; } bool read() { if (values_to_read_.empty()) { return value_; } bool ret = values_to_read_.front(); values_to_read_.pop(); return ret; } private: bool value_ = false; std::queue values_to_read_; }; /** Scanner object. Should have better be called Session than Scanner */ struct Genesys_Scanner { Genesys_Scanner() = default; ~Genesys_Scanner() = default; // Next scanner in list struct Genesys_Scanner *next; // Low-level device object Genesys_Device* dev = nullptr; // SANE data // We are currently scanning bool scanning; // Option descriptors SANE_Option_Descriptor opt[NUM_OPTIONS]; std::vector opt_resolution_values; SANE_Range opt_x_range = {}; SANE_Range opt_y_range = {}; std::vector opt_source_values; // Option values SANE_Word bit_depth = 0; SANE_Word resolution = 0; bool preview = false; SANE_Word threshold = 0; SANE_Word threshold_curve = 0; bool disable_interpolation = false; bool lamp_off = false; SANE_Word lamp_off_time = 0; bool swdeskew = false; bool swcrop = false; bool swdespeck = false; bool swderotate = false; SANE_Word swskip = 0; SANE_Word despeck = 0; SANE_Word contrast = 0; SANE_Word brightness = 0; SANE_Word expiration_time = 0; bool custom_gamma = false; SANE_Word pos_top_left_y = 0; SANE_Word pos_top_left_x = 0; SANE_Word pos_bottom_right_y = 0; SANE_Word pos_bottom_right_x = 0; std::string mode, color_filter; // the value of the source option ScanMethod scan_method = ScanMethod::FLATBED; std::string calibration_file; // Button states GenesysButton buttons[NUM_BUTTONS]; // SANE Parameters SANE_Parameters params = {}; SANE_Int bpp_list[5] = {}; }; void write_calibration(std::ostream& str, Genesys_Device::Calibration& cache); bool read_calibration(std::istream& str, Genesys_Device::Calibration& cache, const std::string& path); } // namespace genesys #endif /* not GENESYS_H */ sane-backends-1.0.29/backend/genesys/gl847.cpp0000666000000000000000000021171413615534521015624 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2010-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "gl847.h" #include "gl847_registers.h" #include "test_settings.h" #include namespace genesys { namespace gl847 { /** * compute the step multiplier used */ static int gl847_get_step_multiplier (Genesys_Register_Set * regs) { GenesysRegister *r = sanei_genesys_get_address(regs, 0x9d); int value = 1; if (r != nullptr) { value = (r->value & 0x0f)>>1; value = 1 << value; } DBG (DBG_io, "%s: step multiplier is %d\n", __func__, value); return value; } /** @brief sensor specific settings */ static void gl847_setup_sensor(Genesys_Device * dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs) { DBG_HELPER(dbg); for (const auto& reg : sensor.custom_regs) { regs->set8(reg.address, reg.value); } regs->set16(REG_EXPR, sensor.exposure.red); regs->set16(REG_EXPG, sensor.exposure.green); regs->set16(REG_EXPB, sensor.exposure.blue); dev->segment_order = sensor.segment_order; } /** @brief set all registers to default values . * This function is called only once at the beginning and * fills register startup values for registers reused across scans. * Those that are rarely modified or not modified are written * individually. * @param dev device structure holding register set to initialize */ static void gl847_init_registers (Genesys_Device * dev) { DBG_HELPER(dbg); int lide700=0; uint8_t val; /* 700F class needs some different initial settings */ if (dev->model->model_id == ModelId::CANON_LIDE_700F) { lide700 = 1; } dev->reg.clear(); dev->reg.init_reg(0x01, 0x82); dev->reg.init_reg(0x02, 0x18); dev->reg.init_reg(0x03, 0x50); dev->reg.init_reg(0x04, 0x12); dev->reg.init_reg(0x05, 0x80); dev->reg.init_reg(0x06, 0x50); // FASTMODE + POWERBIT dev->reg.init_reg(0x08, 0x10); dev->reg.init_reg(0x09, 0x01); dev->reg.init_reg(0x0a, 0x00); dev->reg.init_reg(0x0b, 0x01); dev->reg.init_reg(0x0c, 0x02); // LED exposures dev->reg.init_reg(0x10, 0x00); dev->reg.init_reg(0x11, 0x00); dev->reg.init_reg(0x12, 0x00); dev->reg.init_reg(0x13, 0x00); dev->reg.init_reg(0x14, 0x00); dev->reg.init_reg(0x15, 0x00); dev->reg.init_reg(0x16, 0x10); // SENSOR_DEF dev->reg.init_reg(0x17, 0x08); // SENSOR_DEF dev->reg.init_reg(0x18, 0x00); // SENSOR_DEF // EXPDMY dev->reg.init_reg(0x19, 0x50); // SENSOR_DEF dev->reg.init_reg(0x1a, 0x34); // SENSOR_DEF dev->reg.init_reg(0x1b, 0x00); // SENSOR_DEF dev->reg.init_reg(0x1c, 0x02); // SENSOR_DEF dev->reg.init_reg(0x1d, 0x04); // SENSOR_DEF dev->reg.init_reg(0x1e, 0x10); dev->reg.init_reg(0x1f, 0x04); dev->reg.init_reg(0x20, 0x02); dev->reg.init_reg(0x21, 0x10); dev->reg.init_reg(0x22, 0x7f); dev->reg.init_reg(0x23, 0x7f); dev->reg.init_reg(0x24, 0x10); dev->reg.init_reg(0x25, 0x00); dev->reg.init_reg(0x26, 0x00); dev->reg.init_reg(0x27, 0x00); dev->reg.init_reg(0x2c, 0x09); dev->reg.init_reg(0x2d, 0x60); dev->reg.init_reg(0x2e, 0x80); dev->reg.init_reg(0x2f, 0x80); dev->reg.init_reg(0x30, 0x00); dev->reg.init_reg(0x31, 0x10); dev->reg.init_reg(0x32, 0x15); dev->reg.init_reg(0x33, 0x0e); dev->reg.init_reg(0x34, 0x40); dev->reg.init_reg(0x35, 0x00); dev->reg.init_reg(0x36, 0x2a); dev->reg.init_reg(0x37, 0x30); dev->reg.init_reg(0x38, 0x2a); dev->reg.init_reg(0x39, 0xf8); dev->reg.init_reg(0x3d, 0x00); dev->reg.init_reg(0x3e, 0x00); dev->reg.init_reg(0x3f, 0x00); dev->reg.init_reg(0x52, 0x03); // SENSOR_DEF dev->reg.init_reg(0x53, 0x07); // SENSOR_DEF dev->reg.init_reg(0x54, 0x00); // SENSOR_DEF dev->reg.init_reg(0x55, 0x00); // SENSOR_DEF dev->reg.init_reg(0x56, 0x00); // SENSOR_DEF dev->reg.init_reg(0x57, 0x00); // SENSOR_DEF dev->reg.init_reg(0x58, 0x2a); // SENSOR_DEF dev->reg.init_reg(0x59, 0xe1); // SENSOR_DEF dev->reg.init_reg(0x5a, 0x55); // SENSOR_DEF dev->reg.init_reg(0x5e, 0x41); dev->reg.init_reg(0x5f, 0x40); dev->reg.init_reg(0x60, 0x00); dev->reg.init_reg(0x61, 0x21); dev->reg.init_reg(0x62, 0x40); dev->reg.init_reg(0x63, 0x00); dev->reg.init_reg(0x64, 0x21); dev->reg.init_reg(0x65, 0x40); dev->reg.init_reg(0x67, 0x80); dev->reg.init_reg(0x68, 0x80); dev->reg.init_reg(0x69, 0x20); dev->reg.init_reg(0x6a, 0x20); // CK1MAP dev->reg.init_reg(0x74, 0x00); // SENSOR_DEF dev->reg.init_reg(0x75, 0x00); // SENSOR_DEF dev->reg.init_reg(0x76, 0x3c); // SENSOR_DEF // CK3MAP dev->reg.init_reg(0x77, 0x00); // SENSOR_DEF dev->reg.init_reg(0x78, 0x00); // SENSOR_DEF dev->reg.init_reg(0x79, 0x9f); // SENSOR_DEF // CK4MAP dev->reg.init_reg(0x7a, 0x00); // SENSOR_DEF dev->reg.init_reg(0x7b, 0x00); // SENSOR_DEF dev->reg.init_reg(0x7c, 0x55); // SENSOR_DEF dev->reg.init_reg(0x7d, 0x00); // NOTE: autoconf is a non working option dev->reg.init_reg(0x87, 0x02); dev->reg.init_reg(0x9d, 0x06); dev->reg.init_reg(0xa2, 0x0f); dev->reg.init_reg(0xbd, 0x18); dev->reg.init_reg(0xfe, 0x08); // gamma[0] and gamma[256] values dev->reg.init_reg(0xbe, 0x00); dev->reg.init_reg(0xc5, 0x00); dev->reg.init_reg(0xc6, 0x00); dev->reg.init_reg(0xc7, 0x00); dev->reg.init_reg(0xc8, 0x00); dev->reg.init_reg(0xc9, 0x00); dev->reg.init_reg(0xca, 0x00); /* LiDE 700 fixups */ if (lide700) { dev->reg.init_reg(0x5f, 0x04); dev->reg.init_reg(0x7d, 0x80); /* we write to these registers only once */ val=0; dev->interface->write_register(REG_0x7E, val); dev->interface->write_register(REG_0x9E, val); dev->interface->write_register(REG_0x9F, val); dev->interface->write_register(REG_0xAB, val); } const auto& sensor = sanei_genesys_find_sensor_any(dev); sanei_genesys_set_dpihw(dev->reg, sensor, sensor.optical_res); /* initalize calibration reg */ dev->calib_reg = dev->reg; } /**@brief send slope table for motor movement * Send slope_table in machine byte order * @param dev device to send slope table * @param table_nr index of the slope table in ASIC memory * Must be in the [0-4] range. * @param slope_table pointer to 16 bit values array of the slope table * @param steps number of elements in the slope table */ static void gl847_send_slope_table(Genesys_Device* dev, int table_nr, const std::vector& slope_table, int steps) { DBG_HELPER_ARGS(dbg, "table_nr = %d, steps = %d", table_nr, steps); int i; char msg[10000]; /* sanity check */ if(table_nr<0 || table_nr>4) { throw SaneException("invalid table number %d", table_nr); } std::vector table(steps * 2); for (i = 0; i < steps; i++) { table[i * 2] = slope_table[i] & 0xff; table[i * 2 + 1] = slope_table[i] >> 8; } if (DBG_LEVEL >= DBG_io) { std::sprintf(msg, "write slope %d (%d)=", table_nr, steps); for (i = 0; i < steps; i++) { std::sprintf(msg + std::strlen(msg), "%d", slope_table[i]); } DBG (DBG_io, "%s: %s\n", __func__, msg); } if (dev->interface->is_mock()) { dev->interface->record_slope_table(table_nr, slope_table); } // slope table addresses are fixed dev->interface->write_ahb(0x10000000 + 0x4000 * table_nr, steps * 2, table.data()); } /** * Set register values of Analog Device type frontend * */ static void gl847_set_ad_fe(Genesys_Device* dev, uint8_t set) { DBG_HELPER(dbg); int i; // wait for FE to be ready auto status = scanner_read_status(*dev); while (status.is_front_end_busy) { dev->interface->sleep_ms(10); status = scanner_read_status(*dev); }; if (set == AFE_INIT) { DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, static_cast(dev->model->adc_id)); dev->frontend = dev->frontend_initial; } // reset DAC dev->interface->write_fe_register(0x00, 0x80); // write them to analog frontend dev->interface->write_fe_register(0x00, dev->frontend.regs.get_value(0x00)); dev->interface->write_fe_register(0x01, dev->frontend.regs.get_value(0x01)); for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x02 + i, dev->frontend.get_gain(i)); } for (i = 0; i < 3; i++) { dev->interface->write_fe_register(0x05 + i, dev->frontend.get_offset(i)); } } // Set values of analog frontend void CommandSetGl847::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const { DBG_HELPER_ARGS(dbg, "%s", set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == AFE_POWER_SAVE ? "powersave" : "huh?"); (void) sensor; uint8_t val = dev->interface->read_register(REG_0x04); uint8_t frontend_type = val & REG_0x04_FESET; // route to AD devices if (frontend_type == 0x02) { gl847_set_ad_fe(dev, set); return; } throw SaneException("unsupported frontend type %d", frontend_type); } // @brief set up motor related register for scan static void gl847_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const Motor_Profile& motor_profile, unsigned int scan_exposure_time, unsigned scan_yres, unsigned int scan_lines, unsigned int scan_dummy, unsigned int feed_steps, MotorFlag flags) { DBG_HELPER_ARGS(dbg, "scan_exposure_time=%d, can_yres=%d, step_type=%d, scan_lines=%d, " "scan_dummy=%d, feed_steps=%d, flags=%x", scan_exposure_time, scan_yres, static_cast(motor_profile.step_type), scan_lines, scan_dummy, feed_steps, static_cast(flags)); int use_fast_fed; unsigned int fast_dpi; unsigned int feedl, dist; GenesysRegister *r; uint32_t z1, z2; unsigned int min_restep = 0x20; uint8_t val; unsigned int ccdlmt,tgtime; unsigned step_multiplier = gl847_get_step_multiplier (reg); use_fast_fed=0; /* no fast fed since feed works well */ if (dev->settings.yres==4444 && feed_steps > 100 && (!has_flag(flags, MotorFlag::FEED))) { use_fast_fed=1; } DBG(DBG_io, "%s: use_fast_fed=%d\n", __func__, use_fast_fed); reg->set24(REG_LINCNT, scan_lines); DBG(DBG_io, "%s: lincnt=%d\n", __func__, scan_lines); /* compute register 02 value */ r = sanei_genesys_get_address(reg, REG_0x02); r->value = 0x00; sanei_genesys_set_motor_power(*reg, true); if (use_fast_fed) { r->value |= REG_0x02_FASTFED; } else { r->value &= ~REG_0x02_FASTFED; } if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) { r->value |= REG_0x02_AGOHOME | REG_0x02_NOTHOME; } if (has_flag(flags, MotorFlag::DISABLE_BUFFER_FULL_MOVE) ||(scan_yres>=sensor.optical_res)) { r->value |= REG_0x02_ACDCDIS; } if (has_flag(flags, MotorFlag::REVERSE)) { r->value |= REG_0x02_MTRREV; } else { r->value &= ~REG_0x02_MTRREV; } /* scan and backtracking slope table */ auto scan_table = sanei_genesys_slope_table(dev->model->asic_type, scan_yres, scan_exposure_time, dev->motor.base_ydpi, step_multiplier, motor_profile); gl847_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); gl847_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); /* fast table */ fast_dpi=sanei_genesys_get_lowest_ydpi(dev); StepType fast_step_type = motor_profile.step_type; if (static_cast(motor_profile.step_type) >= static_cast(StepType::QUARTER)) { fast_step_type = StepType::QUARTER; } Motor_Profile fast_motor_profile = motor_profile; fast_motor_profile.step_type = fast_step_type; auto fast_table = sanei_genesys_slope_table(dev->model->asic_type, fast_dpi, scan_exposure_time, dev->motor.base_ydpi, step_multiplier, fast_motor_profile); gl847_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count); gl847_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); gl847_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.steps_count); /* correct move distance by acceleration and deceleration amounts */ feedl=feed_steps; if (use_fast_fed) { feedl <<= static_cast(fast_step_type); dist = (scan_table.steps_count + 2 * fast_table.steps_count); /* TODO read and decode REG_0xAB */ r = sanei_genesys_get_address (reg, 0x5e); dist += (r->value & 31); /* FEDCNT */ r = sanei_genesys_get_address (reg, REG_FEDCNT); dist += r->value; } else { feedl <<= static_cast(motor_profile.step_type); dist = scan_table.steps_count; if (has_flag(flags, MotorFlag::FEED)) { dist *= 2; } } DBG(DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* check for overflow */ if (dist < feedl) { feedl -= dist; } else { feedl = 0; } reg->set24(REG_FEEDL, feedl); DBG(DBG_io ,"%s: feedl=%d\n", __func__, feedl); r = sanei_genesys_get_address(reg, REG_0x0C); ccdlmt = (r->value & REG_0x0C_CCDLMT) + 1; r = sanei_genesys_get_address(reg, REG_0x1C); tgtime = 1<<(r->value & REG_0x1C_TGTIME); // hi res motor speed GPIO uint8_t effective = dev->interface->read_register(REG_0x6C); // if quarter step, bipolar Vref2 if (motor_profile.step_type == StepType::QUARTER) { val = effective & ~REG_0x6C_GPIO13; } else if (static_cast(motor_profile.step_type) > static_cast(StepType::QUARTER)) { val = effective | REG_0x6C_GPIO13; } else { val = effective; } dev->interface->write_register(REG_0x6C, val); // effective scan effective = dev->interface->read_register(REG_0x6C); val = effective | REG_0x6C_GPIO10; dev->interface->write_register(REG_0x6C, val); min_restep = scan_table.steps_count / (2 * step_multiplier) - 1; if (min_restep < 1) { min_restep = 1; } r = sanei_genesys_get_address(reg, REG_FWDSTEP); r->value = min_restep; r = sanei_genesys_get_address(reg, REG_BWDSTEP); r->value = min_restep; sanei_genesys_calculate_zmod(use_fast_fed, scan_exposure_time*ccdlmt*tgtime, scan_table.table, scan_table.steps_count, feedl, min_restep * step_multiplier, &z1, &z2); DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); reg->set24(REG_0x60, z1 | (static_cast(motor_profile.step_type) << (16+REG_0x60S_STEPSEL))); DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); reg->set24(REG_0x63, z2 | (static_cast(motor_profile.step_type) << (16+REG_0x63S_FSTPSEL))); r = sanei_genesys_get_address (reg, 0x1e); r->value &= 0xf0; /* 0 dummy lines */ r->value |= scan_dummy; /* dummy lines */ r = sanei_genesys_get_address(reg, REG_0x67); r->value = REG_0x67_MTRPWM; r = sanei_genesys_get_address(reg, REG_0x68); r->value = REG_0x68_FASTPWM; reg->set8(REG_STEPNO, scan_table.steps_count / step_multiplier); reg->set8(REG_FASTNO, scan_table.steps_count / step_multiplier); reg->set8(REG_FSHDEC, scan_table.steps_count / step_multiplier); reg->set8(REG_FMOVNO, fast_table.steps_count / step_multiplier); reg->set8(REG_FMOVDEC, fast_table.steps_count / step_multiplier); } /** @brief set up registers related to sensor * Set up the following registers 0x01 0x03 0x10-0x015 R/G/B exposures 0x19 EXPDMY 0x2e BWHI 0x2f BWLO 0x04 0x87 0x05 0x2c,0x2d DPISET 0x30,0x31 STRPIXEL 0x32,0x33 ENDPIXEL 0x35,0x36,0x37 MAXWD [25:2] (>>2) 0x38,0x39 LPERIOD 0x34 DUMMY */ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, unsigned int exposure_time, const ScanSession& session) { DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time); unsigned dpihw; GenesysRegister *r; // resolution is divided according to ccd_pixels_per_system_pixel() unsigned ccd_pixels_per_system_pixel = sensor.ccd_pixels_per_system_pixel(); DBG(DBG_io2, "%s: ccd_pixels_per_system_pixel=%d\n", __func__, ccd_pixels_per_system_pixel); // to manage high resolution device while keeping good low resolution scanning speed, we make // hardware dpi vary dpihw = sensor.get_register_hwdpi(session.params.xres * ccd_pixels_per_system_pixel); DBG(DBG_io2, "%s: dpihw=%d\n", __func__, dpihw); gl847_setup_sensor(dev, sensor, reg); dev->cmd_set->set_fe(dev, sensor, AFE_SET); /* enable shading */ regs_set_optical_off(dev->model->asic_type, *reg); r = sanei_genesys_get_address(reg, REG_0x01); r->value |= REG_0x01_SHDAREA; if (has_flag(session.params.flags, ScanFlag::DISABLE_SHADING) || (dev->model->flags & GENESYS_FLAG_NO_CALIBRATION)) { r->value &= ~REG_0x01_DVDSET; } else { r->value |= REG_0x01_DVDSET; } r = sanei_genesys_get_address (reg, REG_0x03); r->value &= ~REG_0x03_AVEENB; sanei_genesys_set_lamp_power(dev, sensor, *reg, !has_flag(session.params.flags, ScanFlag::DISABLE_LAMP)); /* BW threshold */ r = sanei_genesys_get_address (reg, 0x2e); r->value = dev->settings.threshold; r = sanei_genesys_get_address (reg, 0x2f); r->value = dev->settings.threshold; /* monochrome / color scan */ r = sanei_genesys_get_address (reg, REG_0x04); switch (session.params.depth) { case 8: r->value &= ~(REG_0x04_LINEART | REG_0x04_BITSET); break; case 16: r->value &= ~REG_0x04_LINEART; r->value |= REG_0x04_BITSET; break; } r->value &= ~(REG_0x04_FILTER | REG_0x04_AFEMOD); if (session.params.channels == 1) { switch (session.params.color_filter) { case ColorFilter::RED: r->value |= 0x14; break; case ColorFilter::BLUE: r->value |= 0x1c; break; case ColorFilter::GREEN: r->value |= 0x18; break; default: break; // should not happen } } else { r->value |= 0x10; // mono } sanei_genesys_set_dpihw(*reg, sensor, dpihw); if (should_enable_gamma(session, sensor)) { reg->find_reg(REG_0x05).value |= REG_0x05_GMMENB; } else { reg->find_reg(REG_0x05).value &= ~REG_0x05_GMMENB; } /* CIS scanners can do true gray by setting LEDADD */ /* we set up LEDADD only when asked */ if (dev->model->is_cis) { r = sanei_genesys_get_address (reg, 0x87); r->value &= ~REG_0x87_LEDADD; if (session.enable_ledadd) { r->value |= REG_0x87_LEDADD; } /* RGB weighting r = sanei_genesys_get_address (reg, 0x01); r->value &= ~REG_0x01_TRUEGRAY; if (session.enable_ledadd) { r->value |= REG_0x01_TRUEGRAY; } */ } unsigned dpiset = session.params.xres * ccd_pixels_per_system_pixel; reg->set16(REG_DPISET, dpiset); DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); reg->set16(REG_STRPIXEL, session.pixel_startx); reg->set16(REG_ENDPIXEL, session.pixel_endx); build_image_pipeline(dev, session); /* MAXWD is expressed in 4 words unit */ // BUG: we shouldn't multiply by channels here reg->set24(REG_MAXWD, (session.output_line_bytes_raw * session.params.channels >> 2)); reg->set16(REG_LPERIOD, exposure_time); DBG(DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time); r = sanei_genesys_get_address (reg, 0x34); r->value = sensor.dummy_pixel; } void CommandSetGl847::init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const { DBG_HELPER(dbg); session.assert_computed(); int move; int exposure_time; int slope_dpi = 0; int dummy = 0; dummy = 3 - session.params.channels; /* slope_dpi */ /* cis color scan is effectively a gray scan with 3 gray lines per color line and a FILTER of 0 */ if (dev->model->is_cis) { slope_dpi = session.params.yres * session.params.channels; } else { slope_dpi = session.params.yres; } slope_dpi = slope_dpi * (1 + dummy); exposure_time = sensor.exposure_lperiod; const auto& motor_profile = sanei_genesys_get_motor_profile(*gl847_motor_profiles, dev->model->motor_id, exposure_time); DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, static_cast(motor_profile.step_type)); /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode */ gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session); move = session.params.starty; DBG(DBG_info, "%s: move=%d steps\n", __func__, move); MotorFlag mflags = MotorFlag::NONE; if (has_flag(session.params.flags, ScanFlag::DISABLE_BUFFER_FULL_MOVE)) { mflags |= MotorFlag::DISABLE_BUFFER_FULL_MOVE; } if (has_flag(session.params.flags, ScanFlag::FEEDING)) { mflags |= MotorFlag::FEED; } if (has_flag(session.params.flags, ScanFlag::REVERSE)) { mflags |= MotorFlag::REVERSE; } gl847_init_motor_regs_scan(dev, sensor, reg, motor_profile, exposure_time, slope_dpi, dev->model->is_cis ? session.output_line_count * session.params.channels : session.output_line_count, dummy, move, mflags); dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); dev->read_active = true; dev->session = session; dev->total_bytes_read = 0; dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines; DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read); } ScanSession CommandSetGl847::calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const { int start; DBG(DBG_info, "%s ", __func__); debug_dump(DBG_info, settings); /* start */ start = static_cast(dev->model->x_offset); start = static_cast(start + settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = settings.xres; session.params.yres = settings.yres; session.params.startx = start; // not used session.params.starty = 0; // not used session.params.pixels = settings.pixels; session.params.requested_pixels = settings.requested_pixels; session.params.lines = settings.lines; session.params.depth = settings.depth; session.params.channels = settings.get_channels(); session.params.scan_method = settings.scan_method; session.params.scan_mode = settings.scan_mode; session.params.color_filter = settings.color_filter; session.params.flags = ScanFlag::NONE; compute_session(dev, session, sensor); return session; } // for fast power saving methods only, like disabling certain amplifiers void CommandSetGl847::save_power(Genesys_Device* dev, bool enable) const { DBG_HELPER_ARGS(dbg, "enable = %d", enable); (void) dev; } void CommandSetGl847::set_powersaving(Genesys_Device* dev, int delay /* in minutes */) const { (void) dev; DBG_HELPER_ARGS(dbg, "delay = %d", delay); } // Send the low-level scan command void CommandSetGl847::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, bool start_motor) const { DBG_HELPER(dbg); (void) sensor; uint8_t val; GenesysRegister *r; // clear GPIO 10 if (dev->model->gpio_id != GpioId::CANON_LIDE_700F) { val = dev->interface->read_register(REG_0x6C); val &= ~REG_0x6C_GPIO10; dev->interface->write_register(REG_0x6C, val); } val = REG_0x0D_CLRLNCNT; dev->interface->write_register(REG_0x0D, val); val = REG_0x0D_CLRMCNT; dev->interface->write_register(REG_0x0D, val); val = dev->interface->read_register(REG_0x01); val |= REG_0x01_SCAN; dev->interface->write_register(REG_0x01, val); r = sanei_genesys_get_address (reg, REG_0x01); r->value = val; scanner_start_action(*dev, start_motor); dev->advance_head_pos_by_session(ScanHeadId::PRIMARY); } // Send the stop scan command void CommandSetGl847::end_scan(Genesys_Device* dev, Genesys_Register_Set* reg, bool check_stop) const { (void) reg; DBG_HELPER_ARGS(dbg, "check_stop = %d", check_stop); if (!dev->model->is_sheetfed) { scanner_stop_action(*dev); } } /** 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 */ void CommandSetGl847::move_back_home(Genesys_Device* dev, bool wait_until_home) const { scanner_move_back_home(*dev, wait_until_home); } // Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi // from very top of scanner void CommandSetGl847::search_start_position(Genesys_Device* dev) const { DBG_HELPER(dbg); int size; Genesys_Register_Set local_reg; int pixels = 600; int dpi = 300; local_reg = dev->reg; /* sets for a 200 lines * 600 pixels */ /* normal scan with no shading */ // FIXME: the current approach of doing search only for one resolution does not work on scanners // whith employ different sensors with potentially different settings. const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method); ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; /*we should give a small offset here~60 steps */ session.params.pixels = 600; session.params.lines = dev->model->search_lines; session.params.depth = 8; session.params.channels = 1; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::GREEN; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &local_reg, session); // send to scanner dev->interface->write_registers(local_reg); size = pixels * dev->model->search_lines; std::vector data(size); begin_scan(dev, sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_start_position"); end_scan(dev, &local_reg, true); dev->reg = local_reg; return; } wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl847_search_position.pnm", data.data(), 8, 1, pixels, dev->model->search_lines); } end_scan(dev, &local_reg, true); /* update regs to copy ASIC internal state */ dev->reg = local_reg; // TODO: find out where sanei_genesys_search_reference_point stores information, // and use that correctly for (auto& sensor_update : sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) { sanei_genesys_search_reference_point(dev, sensor_update, data.data(), 0, dpi, pixels, dev->model->search_lines); } } // sets up register for coarse gain calibration // todo: check it for scanners using it void CommandSetGl847::init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; session.params.pixels = sensor.optical_res / sensor.ccd_pixels_per_system_pixel(); session.params.lines = 20; session.params.depth = 16; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, ®s, session); DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, sensor.optical_res / sensor.ccd_pixels_per_system_pixel(), dev->settings.xres); dev->interface->write_registers(regs); } // init registers for shading calibration void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); dev->calib_channels = 3; /* initial calibration reg values */ regs = dev->reg; dev->calib_resolution = sensor.get_register_hwdpi(dev->settings.xres); const auto& calib_sensor = sanei_genesys_find_sensor(dev, dev->calib_resolution, dev->calib_channels, dev->settings.scan_method); dev->calib_total_bytes_to_read = 0; dev->calib_lines = dev->model->shading_lines; if (dev->calib_resolution == 4800) { dev->calib_lines *= 2; } dev->calib_pixels = (calib_sensor.sensor_pixels * dev->calib_resolution) / calib_sensor.optical_res; DBG(DBG_io, "%s: calib_lines = %zu\n", __func__, dev->calib_lines); DBG(DBG_io, "%s: calib_pixels = %zu\n", __func__, dev->calib_pixels); ScanSession session; session.params.xres = dev->calib_resolution; session.params.yres = dev->motor.base_ydpi; session.params.startx = 0; session.params.starty = 20; session.params.pixels = dev->calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; session.params.channels = dev->calib_channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::DISABLE_BUFFER_FULL_MOVE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); dev->interface->write_registers(regs); /* we use GENESYS_FLAG_SHADING_REPARK */ dev->set_head_pos_zero(ScanHeadId::PRIMARY); } /** @brief set up registers for the actual scan */ void CommandSetGl847::init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const { DBG_HELPER(dbg); float move; int move_dpi; float start; debug_dump(DBG_info, dev->settings); /* steps to move to reach scanning area: - first we move to physical start of scanning either by a fixed steps amount from the black strip or by a fixed amount from parking position, minus the steps done during shading calibration - then we move by the needed offset whitin physical scanning area assumption: steps are expressed at maximum motor resolution we need: float y_offset; float y_size; float y_offset_calib; mm_to_steps()=motor dpi / 2.54 / 10=motor dpi / MM_PER_INCH */ /* if scanner uses GENESYS_FLAG_SEARCH_START y_offset is relative from origin, else, it is from parking position */ move_dpi = dev->motor.base_ydpi; move = static_cast(dev->model->y_offset); move = static_cast(move + dev->settings.tl_y); move = static_cast((move * move_dpi) / MM_PER_INCH); move -= dev->head_pos(ScanHeadId::PRIMARY); 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 * computing acceleration/deceleration distance for scan * resolution. So leave a remainder for it so scan makes the final * move tuning */ if (dev->settings.get_channels() * dev->settings.yres >= 600 && move > 700) { scanner_move(*dev, dev->model->default_method, static_cast(move - 500), Direction::FORWARD); move=500; } DBG(DBG_info, "%s: move=%f steps\n", __func__, move); DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = static_cast(dev->model->x_offset); start = static_cast(start + dev->settings.tl_x); start = static_cast((start * sensor.optical_res) / MM_PER_INCH); ScanSession session; session.params.xres = dev->settings.xres; session.params.yres = dev->settings.yres; session.params.startx = static_cast(start); session.params.starty = static_cast(move); session.params.pixels = dev->settings.pixels; session.params.requested_pixels = dev->settings.requested_pixels; session.params.lines = dev->settings.lines; session.params.depth = dev->settings.depth; session.params.channels = dev->settings.get_channels(); session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; // backtracking isn't handled well, so don't enable it session.params.flags = ScanFlag::DISABLE_BUFFER_FULL_MOVE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, &dev->reg, session); } /** * Send shading calibration data. The buffer is considered to always hold values * for all the channels. */ void CommandSetGl847::send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const { DBG_HELPER_ARGS(dbg, "writing %d bytes of shading data", size); uint32_t addr, length, i, x, factor, pixels; uint32_t dpiset, dpihw; uint8_t val,*ptr,*src; /* shading data is plit in 3 (up to 5 with IR) areas write(0x10014000,0x00000dd8) URB 23429 bulk_out len 3544 wrote 0x33 0x10 0x.... write(0x1003e000,0x00000dd8) write(0x10068000,0x00000dd8) */ length = static_cast(size / 3); std::uint32_t strpixel = dev->session.pixel_startx; std::uint32_t endpixel = dev->session.pixel_endx; /* compute deletion factor */ dpiset = dev->reg.get16(REG_DPISET); dpihw = sensor.get_register_hwdpi(dpiset); factor=dpihw/dpiset; DBG(DBG_io2, "%s: factor=%d\n", __func__, factor); pixels=endpixel-strpixel; /* since we're using SHDAREA, substract startx coordinate from shading */ strpixel -= (sensor.ccd_start_xoffset * 600) / sensor.optical_res; /* turn pixel value into bytes 2x16 bits words */ strpixel*=2*2; pixels*=2*2; dev->interface->record_key_value("shading_offset", std::to_string(strpixel)); dev->interface->record_key_value("shading_pixels", std::to_string(pixels)); dev->interface->record_key_value("shading_length", std::to_string(length)); dev->interface->record_key_value("shading_factor", std::to_string(factor)); std::vector buffer(pixels, 0); 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 */ /* write actual color channel data */ for(i=0;i<3;i++) { /* build up actual shading data by copying the part from the full width one * to the one corresponding to SHDAREA */ ptr = buffer.data(); /* iterate on both sensor segment */ for(x=0;xinterface->read_register(0xd0+i); addr = val * 8192 + 0x10000000; dev->interface->write_ahb(addr, pixels, buffer.data()); } } /** @brief calibrates led exposure * Calibrate exposure by scanning a white area until the used exposure gives * data white enough. * @param dev device to calibrate */ SensorExposure CommandSetGl847::led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); int num_pixels; int total_size; int used_res; int i, j; int val; int channels; int avg[3], top[3], bottom[3]; int turn; uint16_t exp[3]; float move; move = static_cast(dev->model->y_offset_calib_white); move = static_cast((move * (dev->motor.base_ydpi / 4)) / MM_PER_INCH); if (move > 20) { scanner_move(*dev, dev->model->default_method, static_cast(move), Direction::FORWARD); } DBG(DBG_io, "%s: move=%f steps\n", __func__, move); /* offset calibration is always done in color mode */ channels = 3; used_res = sensor.get_register_hwdpi(dev->settings.xres); const auto& calib_sensor = sanei_genesys_find_sensor(dev, used_res, channels, dev->settings.scan_method); num_pixels = (calib_sensor.sensor_pixels * used_res) / calib_sensor.optical_res; /* initial calibration reg values */ regs = dev->reg; ScanSession session; session.params.xres = used_res; session.params.yres = used_res; session.params.startx = 0; session.params.starty = 0; session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, calib_sensor); init_regs_for_scan_session(dev, calib_sensor, ®s, session); total_size = num_pixels * channels * (session.params.depth/8) * 1; std::vector line(total_size); // initial loop values and boundaries exp[0] = calib_sensor.exposure.red; exp[1] = calib_sensor.exposure.green; exp[2] = calib_sensor.exposure.blue; bottom[0] = 28000; bottom[1] = 28000; bottom[2] = 28000; top[0] = 32000; top[1] = 32000; top[2] = 32000; turn = 0; /* no move during led calibration */ bool acceptable = false; sanei_genesys_set_motor_power(regs, false); do { // set up exposure regs.set16(REG_EXPR,exp[0]); regs.set16(REG_EXPG,exp[1]); regs.set16(REG_EXPB,exp[2]); // write registers and scan data dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting line reading\n", __func__); begin_scan(dev, calib_sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("led_calibration"); scanner_stop_action(*dev); move_back_home(dev, true); return calib_sensor.exposure; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); // stop scanning scanner_stop_action(*dev); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl847_led_%02d.pnm", turn); sanei_genesys_write_pnm_file(fn, line.data(), session.params.depth, channels, num_pixels, 1); } /* compute average */ for (j = 0; j < channels; j++) { avg[j] = 0; for (i = 0; i < num_pixels; i++) { if (dev->model->is_cis) val = line[i * 2 + j * 2 * num_pixels + 1] * 256 + line[i * 2 + j * 2 * num_pixels]; else val = line[i * 2 * channels + 2 * j + 1] * 256 + line[i * 2 * channels + 2 * j]; avg[j] += val; } avg[j] /= num_pixels; } DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); /* check if exposure gives average within the boundaries */ acceptable = true; for(i=0;i<3;i++) { if (avg[i] < bottom[i] || avg[i] > top[i]) { auto target = (bottom[i] + top[i]) / 2; exp[i] = (exp[i] * target) / avg[i]; acceptable = false; } } turn++; } while (!acceptable && turn < 100); DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]); // set these values as final ones for scan dev->reg.set16(REG_EXPR, exp[0]); dev->reg.set16(REG_EXPG, exp[1]); dev->reg.set16(REG_EXPB, exp[2]); // go back home if (move>20) { move_back_home(dev, true); } return { exp[0], exp[1], exp[2] }; } /** * set up GPIO/GPOE for idle state */ static void gl847_init_gpio(Genesys_Device* dev) { DBG_HELPER(dbg); int idx=0; /* search GPIO profile */ while(gpios[idx].gpio_id != GpioId::UNKNOWN && dev->model->gpio_id != gpios[idx].gpio_id) { idx++; } if (gpios[idx].gpio_id == GpioId::UNKNOWN) { throw SaneException("failed to find GPIO profile for sensor_id=%d", static_cast(dev->model->sensor_id)); } dev->interface->write_register(REG_0xA7, gpios[idx].ra7); dev->interface->write_register(REG_0xA6, gpios[idx].ra6); dev->interface->write_register(REG_0x6E, gpios[idx].r6e); dev->interface->write_register(REG_0x6C, 0x00); dev->interface->write_register(REG_0x6B, gpios[idx].r6b); dev->interface->write_register(REG_0x6C, gpios[idx].r6c); dev->interface->write_register(REG_0x6D, gpios[idx].r6d); dev->interface->write_register(REG_0x6E, gpios[idx].r6e); dev->interface->write_register(REG_0x6F, gpios[idx].r6f); dev->interface->write_register(REG_0xA8, gpios[idx].ra8); dev->interface->write_register(REG_0xA9, gpios[idx].ra9); } /** * set memory layout by filling values in dedicated registers */ static void gl847_init_memory_layout(Genesys_Device* dev) { DBG_HELPER(dbg); int idx = 0; uint8_t val; /* point to per model memory layout */ idx = 0; if (dev->model->model_id == ModelId::CANON_LIDE_100) { idx = 0; } if (dev->model->model_id == ModelId::CANON_LIDE_200) { idx = 1; } if (dev->model->model_id == ModelId::CANON_5600F) { idx = 2; } if (dev->model->model_id == ModelId::CANON_LIDE_700F) { idx = 3; } /* CLKSET nd DRAMSEL */ val = layouts[idx].dramsel; dev->interface->write_register(REG_0x0B, val); dev->reg.find_reg(0x0b).value = val; /* prevent further writings by bulk write register */ dev->reg.remove_reg(0x0b); /* setup base address for shading data. */ /* values must be multiplied by 8192=0x4000 to give address on AHB */ /* R-Channel shading bank0 address setting for CIS */ dev->interface->write_register(0xd0, layouts[idx].rd0); /* G-Channel shading bank0 address setting for CIS */ dev->interface->write_register(0xd1, layouts[idx].rd1); /* B-Channel shading bank0 address setting for CIS */ dev->interface->write_register(0xd2, layouts[idx].rd2); /* setup base address for scanned data. */ /* values must be multiplied by 1024*2=0x0800 to give address on AHB */ /* R-Channel ODD image buffer 0x0124->0x92000 */ /* size for each buffer is 0x16d*1k word */ dev->interface->write_register(0xe0, layouts[idx].re0); dev->interface->write_register(0xe1, layouts[idx].re1); /* R-Channel ODD image buffer end-address 0x0291->0x148800 => size=0xB6800*/ dev->interface->write_register(0xe2, layouts[idx].re2); dev->interface->write_register(0xe3, layouts[idx].re3); /* R-Channel EVEN image buffer 0x0292 */ dev->interface->write_register(0xe4, layouts[idx].re4); dev->interface->write_register(0xe5, layouts[idx].re5); /* R-Channel EVEN image buffer end-address 0x03ff*/ dev->interface->write_register(0xe6, layouts[idx].re6); dev->interface->write_register(0xe7, layouts[idx].re7); /* same for green, since CIS, same addresses */ dev->interface->write_register(0xe8, layouts[idx].re0); dev->interface->write_register(0xe9, layouts[idx].re1); dev->interface->write_register(0xea, layouts[idx].re2); dev->interface->write_register(0xeb, layouts[idx].re3); dev->interface->write_register(0xec, layouts[idx].re4); dev->interface->write_register(0xed, layouts[idx].re5); dev->interface->write_register(0xee, layouts[idx].re6); dev->interface->write_register(0xef, layouts[idx].re7); /* same for blue, since CIS, same addresses */ dev->interface->write_register(0xf0, layouts[idx].re0); dev->interface->write_register(0xf1, layouts[idx].re1); dev->interface->write_register(0xf2, layouts[idx].re2); dev->interface->write_register(0xf3, layouts[idx].re3); dev->interface->write_register(0xf4, layouts[idx].re4); dev->interface->write_register(0xf5, layouts[idx].re5); dev->interface->write_register(0xf6, layouts[idx].re6); dev->interface->write_register(0xf7, layouts[idx].re7); } /* * * initialize ASIC from power on condition */ void CommandSetGl847::asic_boot(Genesys_Device* dev, bool cold) const { DBG_HELPER(dbg); // reset ASIC if cold boot if (cold) { dev->interface->write_register(0x0e, 0x01); dev->interface->write_register(0x0e, 0x00); } // test CHKVER uint8_t val = dev->interface->read_register(REG_0x40); if (val & REG_0x40_CHKVER) { val = dev->interface->read_register(0x00); DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ gl847_init_registers (dev); // Write initial registers dev->interface->write_registers(dev->reg); /* Enable DRAM by setting a rising edge on bit 3 of reg 0x0b */ val = dev->reg.find_reg(0x0b).value & REG_0x0B_DRAMSEL; val = (val | REG_0x0B_ENBDRAM); dev->interface->write_register(REG_0x0B, val); dev->reg.find_reg(0x0b).value = val; /* CIS_LINE */ dev->reg.init_reg(0x08, REG_0x08_CIS_LINE); dev->interface->write_register(0x08, dev->reg.find_reg(0x08).value); // set up end access dev->interface->write_0x8c(0x10, 0x0b); dev->interface->write_0x8c(0x13, 0x0e); // setup gpio gl847_init_gpio(dev); // setup internal memory layout gl847_init_memory_layout (dev); dev->reg.init_reg(0xf8, 0x01); dev->interface->write_register(0xf8, dev->reg.find_reg(0xf8).value); } /** * initialize backend and ASIC : registers, motor tables, and gamma tables * then ensure scanner's head is at home */ void CommandSetGl847::init(Genesys_Device* dev) const { DBG_INIT (); DBG_HELPER(dbg); sanei_genesys_asic_init(dev, 0); } void CommandSetGl847::update_hardware_sensors(Genesys_Scanner* s) const { DBG_HELPER(dbg); /* do what is needed to get a new set of events, but try to not lose any of them. */ uint8_t val; uint8_t scan, file, email, copy; switch(s->dev->model->gpio_id) { case GpioId::CANON_LIDE_700F: scan=0x04; file=0x02; email=0x01; copy=0x08; break; default: scan=0x01; file=0x02; email=0x04; copy=0x08; } val = s->dev->interface->read_register(REG_0x6D); s->buttons[BUTTON_SCAN_SW].write((val & scan) == 0); s->buttons[BUTTON_FILE_SW].write((val & file) == 0); s->buttons[BUTTON_EMAIL_SW].write((val & email) == 0); s->buttons[BUTTON_COPY_SW].write((val & copy) == 0); } void CommandSetGl847::update_home_sensor_gpio(Genesys_Device& dev) const { DBG_HELPER(dbg); if (dev.model->gpio_id == GpioId::CANON_LIDE_700F) { std::uint8_t val = dev.interface->read_register(REG_0x6C); val &= ~REG_0x6C_GPIO10; dev.interface->write_register(REG_0x6C, val); } else { std::uint8_t val = dev.interface->read_register(REG_0x6C); val |= REG_0x6C_GPIO10; dev.interface->write_register(REG_0x6C, val); } } /** @brief search for a full width black or white strip. * This function searches for a black or white stripe across the scanning area. * When searching backward, the searched area must completely be of the desired * color since this area will be used for calibration which scans forward. * @param dev scanner device * @param forward true if searching forward, false if searching backward * @param black true if searching for a black strip, false for a white strip */ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const { DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse"); unsigned int pixels, lines, channels; Genesys_Register_Set local_reg; size_t size; unsigned int pass, count, found, x, y; char title[80]; set_fe(dev, sensor, AFE_SET); scanner_stop_action(*dev); // set up for a gray scan at lowest dpi const auto& resolution_settings = dev->model->get_resolution_settings(dev->settings.scan_method); unsigned dpi = resolution_settings.get_min_resolution_x(); channels = 1; /* 10 MM */ /* lines = (10 * dpi) / MM_PER_INCH; */ /* shading calibation is done with dev->motor.base_ydpi */ lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi; pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res; dev->set_head_pos_zero(ScanHeadId::PRIMARY); local_reg = dev->reg; ScanSession session; session.params.xres = dpi; session.params.yres = dpi; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::GRAY; session.params.color_filter = ColorFilter::RED; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA; if (!forward) { session.params.flags |= ScanFlag::REVERSE; } compute_session(dev, session, sensor); size = pixels * channels * lines * (session.params.depth / 8); std::vector data(size); init_regs_for_scan_session(dev, sensor, &local_reg, session); dev->interface->write_registers(local_reg); begin_scan(dev, sensor, &local_reg, true); if (is_testing_mode()) { dev->interface->test_checkpoint("search_strip"); scanner_stop_action(*dev); return; } wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); scanner_stop_action(*dev); pass = 0; if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl847_search_strip_%s_%s%02d.pnm", black ? "black" : "white", forward ? "fwd" : "bwd", pass); sanei_genesys_write_pnm_file(title, data.data(), session.params.depth, channels, pixels, lines); } /* loop until strip is found or maximum pass number done */ found = 0; while (pass < 20 && !found) { dev->interface->write_registers(local_reg); // now start scan begin_scan(dev, sensor, &local_reg, true); wait_until_buffer_non_empty(dev); // now we're on target, we can read data sanei_genesys_read_data_from_scanner(dev, data.data(), size); scanner_stop_action(*dev); if (DBG_LEVEL >= DBG_data) { std::sprintf(title, "gl847_search_strip_%s_%s%02d.pnm", black ? "black" : "white", forward ? "fwd" : "bwd", static_cast(pass)); sanei_genesys_write_pnm_file(title, data.data(), session.params.depth, channels, pixels, lines); } /* search data to find black strip */ /* when searching forward, we only need one line of the searched color since we * will scan forward. But when doing backward search, we need all the area of the * same color */ if (forward) { for (y = 0; y < lines && !found; y++) { count = 0; /* count of white/black pixels depending on the color searched */ for (x = 0; x < pixels; x++) { /* when searching for black, detect white pixels */ if (black && data[y * pixels + x] > 90) { count++; } /* when searching for white, detect black pixels */ if (!black && data[y * pixels + x] < 60) { count++; } } /* at end of line, if count >= 3%, line is not fully of the desired color * so we must go to next line of the buffer */ /* count*100/pixels < 3 */ if ((count * 100) / pixels < 3) { found = 1; DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, pass, y); } else { DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, (100 * count) / pixels); } } } else /* since calibration scans are done forward, we need the whole area to be of the required color when searching backward */ { count = 0; for (y = 0; y < lines; y++) { /* count of white/black pixels depending on the color searched */ for (x = 0; x < pixels; x++) { /* when searching for black, detect white pixels */ if (black && data[y * pixels + x] > 90) { count++; } /* when searching for white, detect black pixels */ if (!black && data[y * pixels + x] < 60) { count++; } } } /* at end of area, if count >= 3%, area is not fully of the desired color * so we must go to next buffer */ if ((count * 100) / (pixels * lines) < 3) { found = 1; DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, (100 * count) / pixels); } } pass++; } if (found) { DBG(DBG_info, "%s: %s strip found\n", __func__, black ? "black" : "white"); } else { throw SaneException(SANE_STATUS_UNSUPPORTED, "%s strip not found", black ? "black" : "white"); } } /** * average dark pixels of a 8 bits scan */ static int dark_average (uint8_t * data, unsigned int pixels, unsigned int lines, unsigned int channels, unsigned int black) { unsigned int i, j, k, average, count; unsigned int avg[3]; uint8_t val; /* computes average value on black margin */ for (k = 0; k < channels; k++) { avg[k] = 0; count = 0; for (i = 0; i < lines; i++) { for (j = 0; j < black; j++) { val = data[i * channels * pixels + j + k]; avg[k] += val; count++; } } if (count) avg[k] /= count; DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } average = 0; for (i = 0; i < channels; i++) average += avg[i]; average /= channels; DBG(DBG_info, "%s: average = %d\n", __func__, average); return average; } void CommandSetGl847::offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const { DBG_HELPER(dbg); unsigned channels; int pass = 0, avg, total_size; int topavg, bottomavg, lines; int top, bottom, black_pixels, pixels; // no gain nor offset for AKM AFE uint8_t reg04 = dev->interface->read_register(REG_0x04); if ((reg04 & REG_0x04_FESET) == 0x02) { return; } /* offset calibration is always done in color mode */ channels = 3; dev->calib_pixels = sensor.sensor_pixels; lines=1; pixels= (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res; black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res; DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); ScanSession session; session.params.xres = sensor.optical_res; session.params.yres = sensor.optical_res; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; session.params.lines = lines; session.params.depth = 8; session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); init_regs_for_scan_session(dev, sensor, ®s, session); sanei_genesys_set_motor_power(regs, false); /* allocate memory for scans */ total_size = pixels * channels * lines * (session.params.depth / 8); /* colors * bytes_per_color * scan lines */ std::vector first_line(total_size); std::vector second_line(total_size); /* init gain */ dev->frontend.set_gain(0, 0); dev->frontend.set_gain(1, 0); dev->frontend.set_gain(2, 0); /* scan with no move */ bottom = 10; dev->frontend.set_offset(0, bottom); dev->frontend.set_offset(1, bottom); dev->frontend.set_offset(2, bottom); set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting first line reading\n", __func__); begin_scan(dev, sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("offset_calibration"); return; } sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl847_offset%03d.pnm", bottom); sanei_genesys_write_pnm_file(fn, first_line.data(), session.params.depth, channels, pixels, lines); } bottomavg = dark_average (first_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_io2, "%s: bottom avg=%d\n", __func__, bottomavg); /* now top value */ top = 255; dev->frontend.set_offset(0, top); dev->frontend.set_offset(1, top); dev->frontend.set_offset(2, top); set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting second line reading\n", __func__); begin_scan(dev, sensor, ®s, true); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); topavg = dark_average(second_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg); /* loop until acceptable level */ while ((pass < 32) && (top - bottom > 1)) { pass++; /* settings for new scan */ dev->frontend.set_offset(0, (top + bottom) / 2); dev->frontend.set_offset(1, (top + bottom) / 2); dev->frontend.set_offset(2, (top + bottom) / 2); // scan with no move set_fe(dev, sensor, AFE_SET); dev->interface->write_registers(regs); DBG(DBG_info, "%s: starting second line reading\n", __func__); begin_scan(dev, sensor, ®s, true); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { char fn[30]; std::snprintf(fn, 30, "gl847_offset%03d.pnm", dev->frontend.get_offset(1)); sanei_genesys_write_pnm_file(fn, second_line.data(), session.params.depth, channels, pixels, lines); } avg = dark_average(second_line.data(), pixels, lines, channels, black_pixels); DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.get_offset(1)); /* compute new boundaries */ if (topavg == avg) { topavg = avg; top = dev->frontend.get_offset(1); } else { bottomavg = avg; bottom = dev->frontend.get_offset(1); } } DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.get_offset(0), dev->frontend.get_offset(1), dev->frontend.get_offset(2)); } void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const { DBG_HELPER_ARGS(dbg, "dpi = %d", dpi); int pixels; int total_size; int i, j, channels; int max[3]; float gain[3],coeff; int val, code, lines; // no gain nor offset for AKM AFE uint8_t reg04 = dev->interface->read_register(REG_0x04); if ((reg04 & REG_0x04_FESET) == 0x02) { return; } /* coarse gain calibration is always done in color mode */ channels = 3; /* follow CKSEL */ if(dev->settings.xressettings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; session.params.flags = ScanFlag::DISABLE_SHADING | ScanFlag::DISABLE_GAMMA | ScanFlag::SINGLE_LINE | ScanFlag::IGNORE_LINE_DISTANCE; compute_session(dev, session, sensor); try { init_regs_for_scan_session(dev, sensor, ®s, session); } catch (...) { catch_all_exceptions(__func__, [&](){ sanei_genesys_set_motor_power(regs, false); }); throw; } sanei_genesys_set_motor_power(regs, false); dev->interface->write_registers(regs); total_size = pixels * channels * (16 / session.params.depth) * lines; std::vector line(total_size); set_fe(dev, sensor, AFE_SET); begin_scan(dev, sensor, ®s, true); if (is_testing_mode()) { dev->interface->test_checkpoint("coarse_gain_calibration"); scanner_stop_action(*dev); move_back_home(dev, true); return; } sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); if (DBG_LEVEL >= DBG_data) { sanei_genesys_write_pnm_file("gl847_gain.pnm", line.data(), session.params.depth, channels, pixels, lines); } /* average value on each channel */ for (j = 0; j < channels; j++) { max[j] = 0; for (i = pixels/4; i < (pixels*3/4); i++) { if (dev->model->is_cis) { val = line[i + j * pixels]; } else { val = line[i * channels + j]; } max[j] += val; } max[j] = max[j] / (pixels/2); gain[j] = (static_cast(sensor.gain_white_ref) * coeff) / max[j]; /* turn logical gain value into gain code, checking for overflow */ code = static_cast(283 - 208 / gain[j]); if (code > 255) code = 255; else if (code < 0) code = 0; dev->frontend.set_gain(j, code); DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j], dev->frontend.get_gain(j)); } if (dev->model->is_cis) { uint8_t gain0 = dev->frontend.get_gain(0); if (gain0 > dev->frontend.get_gain(1)) { gain0 = dev->frontend.get_gain(1); } if (gain0 > dev->frontend.get_gain(2)) { gain0 = dev->frontend.get_gain(2); } dev->frontend.set_gain(0, gain0); dev->frontend.set_gain(1, gain0); dev->frontend.set_gain(2, gain0); } if (channels == 1) { dev->frontend.set_gain(0, dev->frontend.get_gain(1)); dev->frontend.set_gain(2, dev->frontend.get_gain(1)); } scanner_stop_action(*dev); move_back_home(dev, true); } bool CommandSetGl847::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const { (void) dev; return false; } void CommandSetGl847::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const { (void) dev; (void) sensor; (void) regs; (void) channels; (void) total_size; throw SaneException("not implemented"); } void CommandSetGl847::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const { sanei_genesys_send_gamma_table(dev, sensor); } void CommandSetGl847::wait_for_motor_stop(Genesys_Device* dev) const { (void) dev; } void CommandSetGl847::load_document(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl847::detect_document_end(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl847::eject_document(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } void CommandSetGl847::move_to_ta(Genesys_Device* dev) const { (void) dev; throw SaneException("not implemented"); } std::unique_ptr create_gl847_cmd_set() { return std::unique_ptr(new CommandSetGl847{}); } } // namespace gl847 } // namespace genesys sane-backends-1.0.29/backend/genesys/low.h0000666000000000000000000004776513615534521015242 00000000000000/* sane - Scanner Access Now Easy. 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) 2005-2009 Pierre Willenbrock Copyright (C) 2006 Laurent Charpentier Parts of the structs have been taken from the gt68xx backend by Sergey Vlasov et al. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef GENESYS_LOW_H #define GENESYS_LOW_H #include "../include/sane/config.h" #include #include #include #include #include #include #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_MKDIR #include #include #endif #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_usb.h" #include "../include/_stdint.h" #include "device.h" #include "enums.h" #include "error.h" #include "fwd.h" #include "usb_device.h" #include "sensor.h" #include "serialize.h" #include "settings.h" #include "static_init.h" #include "status.h" #include "register.h" #include #include #include #include #include #include #include #include #include #include #include #define GENESYS_RED 0 #define GENESYS_GREEN 1 #define GENESYS_BLUE 2 /* Flags */ #define GENESYS_FLAG_UNTESTED (1 << 0) /**< Print a warning for these scanners */ #define GENESYS_FLAG_14BIT_GAMMA (1 << 1) /**< use 14bit Gamma table instead of 12 */ #define GENESYS_FLAG_XPA (1 << 3) #define GENESYS_FLAG_SKIP_WARMUP (1 << 4) /**< skip genesys_warmup() */ /** @brief offset calibration flag * signals that the scanner does offset calibration. In this case off_calibration() and * coarse_gain_calibration() functions must be implemented */ #define GENESYS_FLAG_OFFSET_CALIBRATION (1 << 5) #define GENESYS_FLAG_SEARCH_START (1 << 6) /**< do start search before scanning */ #define GENESYS_FLAG_REPARK (1 << 7) /**< repark head (and check for lock) by moving without scanning */ #define GENESYS_FLAG_DARK_CALIBRATION (1 << 8) /**< do dark calibration */ #define GENESYS_FLAG_MUST_WAIT (1 << 10) /**< tells wether the scanner must wait for the head when parking */ #define GENESYS_FLAG_HAS_UTA (1 << 11) /**< scanner has a transparency adapter */ #define GENESYS_FLAG_DARK_WHITE_CALIBRATION (1 << 12) /**< yet another calibration method. does white and dark shading in one run, depending on a black and a white strip*/ #define GENESYS_FLAG_CUSTOM_GAMMA (1 << 13) /**< allow custom gamma tables */ #define GENESYS_FLAG_NO_CALIBRATION (1 << 14) /**< allow scanners to use skip the calibration, needed for sheetfed scanners */ #define GENESYS_FLAG_SIS_SENSOR (1 << 16) /**< handling of multi-segments sensors in software */ #define GENESYS_FLAG_SHADING_NO_MOVE (1 << 17) /**< scanner doesn't move sensor during shading calibration */ #define GENESYS_FLAG_SHADING_REPARK (1 << 18) /**< repark head between shading scans */ #define GENESYS_FLAG_FULL_HWDPI_MODE (1 << 19) /**< scanner always use maximum hw dpi to setup the sensor */ // scanner has infrared transparency scanning capability #define GENESYS_FLAG_HAS_UTA_INFRARED (1 << 20) // scanner calibration is handled on the host side #define GENESYS_FLAG_CALIBRATION_HOST_SIDE (1 << 21) #define GENESYS_FLAG_16BIT_DATA_INVERTED (1 << 22) #define GENESYS_HAS_NO_BUTTONS 0 /**< scanner has no supported button */ #define GENESYS_HAS_SCAN_SW (1 << 0) /**< scanner has SCAN button */ #define GENESYS_HAS_FILE_SW (1 << 1) /**< scanner has FILE button */ #define GENESYS_HAS_COPY_SW (1 << 2) /**< scanner has COPY button */ #define GENESYS_HAS_EMAIL_SW (1 << 3) /**< scanner has EMAIL button */ #define GENESYS_HAS_PAGE_LOADED_SW (1 << 4) /**< scanner has paper in detection */ #define GENESYS_HAS_OCR_SW (1 << 5) /**< scanner has OCR button */ #define GENESYS_HAS_POWER_SW (1 << 6) /**< scanner has power button */ #define GENESYS_HAS_CALIBRATE (1 << 7) /**< scanner has 'calibrate' software button to start calibration */ #define GENESYS_HAS_EXTRA_SW (1 << 8) /**< scanner has extra function button */ /* USB control message values */ #define REQUEST_TYPE_IN (USB_TYPE_VENDOR | USB_DIR_IN) #define REQUEST_TYPE_OUT (USB_TYPE_VENDOR | USB_DIR_OUT) #define REQUEST_REGISTER 0x0c #define REQUEST_BUFFER 0x04 #define VALUE_BUFFER 0x82 #define VALUE_SET_REGISTER 0x83 #define VALUE_READ_REGISTER 0x84 #define VALUE_WRITE_REGISTER 0x85 #define VALUE_INIT 0x87 #define GPIO_OUTPUT_ENABLE 0x89 #define GPIO_READ 0x8a #define GPIO_WRITE 0x8b #define VALUE_BUF_ENDACCESS 0x8c #define VALUE_GET_REGISTER 0x8e #define INDEX 0x00 /* todo: used? #define VALUE_READ_STATUS 0x86 */ /* Read/write bulk data/registers */ #define BULK_OUT 0x01 #define BULK_IN 0x00 #define BULK_RAM 0x00 #define BULK_REGISTER 0x11 #define BULKOUT_MAXSIZE 0xF000 /* AFE values */ #define AFE_INIT 1 #define AFE_SET 2 #define AFE_POWER_SAVE 4 #define LOWORD(x) ((uint16_t)((x) & 0xffff)) #define HIWORD(x) ((uint16_t)((x) >> 16)) #define LOBYTE(x) ((uint8_t)((x) & 0xFF)) #define HIBYTE(x) ((uint8_t)((x) >> 8)) /* Global constants */ /* TODO: emove this leftover of early backend days */ #define MOTOR_SPEED_MAX 350 #define DARK_VALUE 0 #define MAX_RESOLUTIONS 13 #define MAX_DPI 4 namespace genesys { struct Genesys_USB_Device_Entry { Genesys_USB_Device_Entry(unsigned v, unsigned p, const Genesys_Model& m) : vendor(v), product(p), model(m) {} // USB vendor identifier std::uint16_t vendor; // USB product identifier std::uint16_t product; // Scanner model information Genesys_Model model; }; /** * structure for motor database */ struct Motor_Profile { MotorId motor_id; int exposure; // used only to select the wanted motor StepType step_type; // default step type for given exposure MotorSlope slope; }; extern StaticInit> gl843_motor_profiles; extern StaticInit> gl846_motor_profiles; extern StaticInit> gl847_motor_profiles; extern StaticInit> gl124_motor_profiles; /*--------------------------------------------------------------------------*/ /* common functions needed by low level specific functions */ /*--------------------------------------------------------------------------*/ inline GenesysRegister* sanei_genesys_get_address(Genesys_Register_Set* regs, uint16_t addr) { auto* ret = regs->find_reg_address(addr); if (ret == nullptr) { DBG(DBG_error, "%s: failed to find address for register 0x%02x, crash expected !\n", __func__, addr); } return ret; } extern void sanei_genesys_init_cmd_set(Genesys_Device* dev); // reads the status of the scanner Status scanner_read_status(Genesys_Device& dev); // reads the status of the scanner reliably. This is done by reading the status twice. The first // read sometimes returns the home sensor as engaged when this is not true. Status scanner_read_reliable_status(Genesys_Device& dev); // reads and prints the scanner status void scanner_read_print_status(Genesys_Device& dev); void debug_print_status(DebugMessageHelper& dbg, Status status); extern void sanei_genesys_write_ahb(Genesys_Device* dev, uint32_t addr, uint32_t size, uint8_t* data); extern void sanei_genesys_init_structs (Genesys_Device * dev); const Genesys_Sensor& sanei_genesys_find_sensor_any(Genesys_Device* dev); const Genesys_Sensor& sanei_genesys_find_sensor(Genesys_Device* dev, unsigned dpi, unsigned channels, ScanMethod scan_method); bool sanei_genesys_has_sensor(Genesys_Device* dev, unsigned dpi, unsigned channels, ScanMethod scan_method); Genesys_Sensor& sanei_genesys_find_sensor_for_write(Genesys_Device* dev, unsigned dpi, unsigned channels, ScanMethod scan_method); std::vector> sanei_genesys_find_sensors_all(Genesys_Device* dev, ScanMethod scan_method); std::vector> sanei_genesys_find_sensors_all_for_write(Genesys_Device* dev, ScanMethod scan_method); extern void sanei_genesys_init_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, int pixels_per_line); extern void sanei_genesys_read_valid_words(Genesys_Device* dev, unsigned int* steps); extern void sanei_genesys_read_scancnt(Genesys_Device* dev, unsigned int* steps); extern void sanei_genesys_read_feed_steps(Genesys_Device* dev, unsigned int* steps); void sanei_genesys_set_lamp_power(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, bool set); void sanei_genesys_set_motor_power(Genesys_Register_Set& regs, bool set); bool should_enable_gamma(const ScanSession& session, const Genesys_Sensor& sensor); /** Calculates the values of the Z{1,2}MOD registers. They are a phase correction to synchronize with the line clock during acceleration and deceleration. two_table is true if moving is done by two tables, false otherwise. acceleration_steps is the number of steps for acceleration, i.e. the number written to REG_STEPNO. move_steps number of steps to move, i.e. the number written to REG_FEEDL. buffer_acceleration_steps, the number of steps for acceleration when buffer condition is met, i.e. the number written to REG_FWDSTEP. */ void sanei_genesys_calculate_zmod(bool two_table, uint32_t exposure_time, const std::vector& slope_table, unsigned acceleration_steps, unsigned move_steps, unsigned buffer_acceleration_steps, uint32_t* out_z1, uint32_t* out_z2); extern void sanei_genesys_set_buffer_address(Genesys_Device* dev, uint32_t addr); unsigned sanei_genesys_get_bulk_max_size(AsicType asic_type); SANE_Int sanei_genesys_exposure_time2(Genesys_Device * dev, float ydpi, StepType step_type, int endpixel, int led_exposure); MotorSlopeTable sanei_genesys_create_slope_table3(AsicType asic_type, const Genesys_Motor& motor, StepType step_type, int exposure_time, unsigned yres); void sanei_genesys_create_default_gamma_table(Genesys_Device* dev, std::vector& gamma_table, float gamma); std::vector get_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor, int color); void sanei_genesys_send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor); extern void sanei_genesys_stop_motor(Genesys_Device* dev); extern void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& sensor, const uint8_t* src_data, int start_pixel, int dpi, int width, int height); // moves the scan head by the specified steps at the motor base dpi void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, Direction direction); void scanner_move_back_home(Genesys_Device& dev, bool wait_until_home); void scanner_move_back_home_ta(Genesys_Device& dev); void scanner_clear_scan_and_feed_counts(Genesys_Device& dev); extern void sanei_genesys_write_file(const char* filename, const std::uint8_t* data, std::size_t length); extern void sanei_genesys_write_pnm_file(const char* filename, const std::uint8_t* data, int depth, int channels, int pixels_per_line, int lines); void sanei_genesys_write_pnm_file(const char* filename, const Image& image); extern void sanei_genesys_write_pnm_file16(const char* filename, const uint16_t *data, unsigned channels, unsigned pixels_per_line, unsigned lines); void wait_until_buffer_non_empty(Genesys_Device* dev, bool check_status_twice = false); extern void sanei_genesys_read_data_from_scanner(Genesys_Device* dev, uint8_t* data, size_t size); Image read_unshuffled_image_from_scanner(Genesys_Device* dev, const ScanSession& session, std::size_t total_bytes); void regs_set_exposure(AsicType asic_type, Genesys_Register_Set& regs, const SensorExposure& exposure); void regs_set_optical_off(AsicType asic_type, Genesys_Register_Set& regs); void sanei_genesys_set_dpihw(Genesys_Register_Set& regs, const Genesys_Sensor& sensor, unsigned dpihw); inline uint16_t sanei_genesys_fixup_exposure_value(uint16_t value) { if ((value & 0xff00) == 0) { value |= 0x100; } if ((value & 0x00ff) == 0) { value |= 0x1; } return value; } inline SensorExposure sanei_genesys_fixup_exposure(SensorExposure exposure) { exposure.red = sanei_genesys_fixup_exposure_value(exposure.red); exposure.green = sanei_genesys_fixup_exposure_value(exposure.green); exposure.blue = sanei_genesys_fixup_exposure_value(exposure.blue); return exposure; } bool get_registers_gain4_bit(AsicType asic_type, const Genesys_Register_Set& regs); extern void sanei_genesys_wait_for_home(Genesys_Device* dev); extern void sanei_genesys_asic_init(Genesys_Device* dev, bool cold); void scanner_start_action(Genesys_Device& dev, bool start_motor); void scanner_stop_action(Genesys_Device& dev); void scanner_stop_action_no_move(Genesys_Device& dev, Genesys_Register_Set& regs); bool scanner_is_motor_stopped(Genesys_Device& dev); const Motor_Profile& sanei_genesys_get_motor_profile(const std::vector& motors, MotorId motor_id, int exposure); MotorSlopeTable sanei_genesys_slope_table(AsicType asic_type, int dpi, int exposure, int base_dpi, unsigned step_multiplier, const Motor_Profile& motor_profile); MotorSlopeTable create_slope_table_fastest(AsicType asic_type, unsigned step_multiplier, const Motor_Profile& motor_profile); /** @brief find lowest motor resolution for the device. * Parses the resolution list for motor and * returns the lowest value. * @param dev for which to find the lowest motor resolution * @return the lowest available motor resolution for the device */ extern int sanei_genesys_get_lowest_ydpi(Genesys_Device *dev); /** @brief find lowest resolution for the device. * Parses the resolution list for motor and sensor and * returns the lowest value. * @param dev for which to find the lowest resolution * @return the lowest available resolution for the device */ extern int sanei_genesys_get_lowest_dpi(Genesys_Device *dev); bool sanei_genesys_is_compatible_calibration(Genesys_Device* dev, const ScanSession& session, const Genesys_Calibration_Cache* cache, bool for_overwrite); extern void sanei_genesys_load_lut(unsigned char* lut, int in_bits, int out_bits, int out_min, int out_max, int slope, int offset); extern void sanei_genesys_generate_gamma_buffer(Genesys_Device* dev, const Genesys_Sensor& sensor, int bits, int max, int size, uint8_t* gamma); void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor); void build_image_pipeline(Genesys_Device* dev, const ScanSession& session); std::uint8_t compute_frontend_gain(float value, float target_value, FrontendType frontend_type); template inline T abs_diff(T a, T b) { if (a < b) { return b - a; } else { return a - b; } } inline uint64_t align_multiple_floor(uint64_t x, uint64_t multiple) { return (x / multiple) * multiple; } inline uint64_t align_multiple_ceil(uint64_t x, uint64_t multiple) { return ((x + multiple - 1) / multiple) * multiple; } inline uint64_t multiply_by_depth_ceil(uint64_t pixels, uint64_t depth) { if (depth == 1) { return (pixels / 8) + ((pixels % 8) ? 1 : 0); } else { return pixels * (depth / 8); } } template inline T clamp(const T& value, const T& lo, const T& hi) { if (value < lo) return lo; if (value > hi) return hi; return value; } /*---------------------------------------------------------------------------*/ /* ASIC specific functions declarations */ /*---------------------------------------------------------------------------*/ extern StaticInit> s_sensors; extern StaticInit> s_frontends; extern StaticInit> s_gpo; extern StaticInit> s_motors; extern StaticInit> s_usb_devices; void genesys_init_sensor_tables(); void genesys_init_frontend_tables(); void genesys_init_gpo_tables(); void genesys_init_motor_tables(); void genesys_init_motor_profile_tables(); void genesys_init_usb_device_tables(); template void debug_dump(unsigned level, const T& value) { std::stringstream out; out << value; DBG(level, "%s\n", out.str().c_str()); } } // namespace genesys #endif /* not GENESYS_LOW_H */ sane-backends-1.0.29/backend/genesys/test_scanner_interface.cpp0000666000000000000000000001456313615534521021472 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "test_scanner_interface.h" #include "device.h" #include namespace genesys { TestScannerInterface::TestScannerInterface(Genesys_Device* dev) : dev_{dev} { // initialize status registers if (dev_->model->asic_type == AsicType::GL124) { write_register(0x101, 0x00); } else { write_register(0x41, 0x00); } if (dev_->model->asic_type == AsicType::GL841 || dev_->model->asic_type == AsicType::GL843 || dev_->model->asic_type == AsicType::GL845 || dev_->model->asic_type == AsicType::GL846 || dev_->model->asic_type == AsicType::GL847) { write_register(0x40, 0x00); } // initialize other registers that we read on init if (dev_->model->asic_type == AsicType::GL124) { write_register(0x33, 0x00); write_register(0xbd, 0x00); write_register(0xbe, 0x00); write_register(0x100, 0x00); } if (dev_->model->asic_type == AsicType::GL845 || dev_->model->asic_type == AsicType::GL846 || dev_->model->asic_type == AsicType::GL847) { write_register(0xbd, 0x00); write_register(0xbe, 0x00); write_register(0xd0, 0x00); write_register(0xd1, 0x01); write_register(0xd2, 0x02); write_register(0xd3, 0x03); write_register(0xd4, 0x04); write_register(0xd5, 0x05); write_register(0xd6, 0x06); write_register(0xd7, 0x07); write_register(0xd8, 0x08); write_register(0xd9, 0x09); } } TestScannerInterface::~TestScannerInterface() = default; bool TestScannerInterface::is_mock() const { return true; } std::uint8_t TestScannerInterface::read_register(std::uint16_t address) { return cached_regs_.get(address); } void TestScannerInterface::write_register(std::uint16_t address, std::uint8_t value) { cached_regs_.update(address, value); } void TestScannerInterface::write_registers(const Genesys_Register_Set& regs) { cached_regs_.update(regs); } void TestScannerInterface::write_0x8c(std::uint8_t index, std::uint8_t value) { (void) index; (void) value; } void TestScannerInterface::bulk_read_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) { (void) addr; std::memset(data, 0, size); } void TestScannerInterface::bulk_write_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) { (void) addr; (void) data; (void) size; } void TestScannerInterface::write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags) { (void) type; (void) addr; (void) data; (void) size; (void) flags; } void TestScannerInterface::write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags) { (void) type; (void) addr; (void) data; (void) size; (void) flags; } void TestScannerInterface::write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) { (void) addr; (void) size; (void) data; } std::uint16_t TestScannerInterface::read_fe_register(std::uint8_t address) { return cached_fe_regs_.get(address); } void TestScannerInterface::write_fe_register(std::uint8_t address, std::uint16_t value) { cached_fe_regs_.update(address, value); } IUsbDevice& TestScannerInterface::get_usb_device() { return usb_dev_; } void TestScannerInterface::sleep_us(unsigned microseconds) { (void) microseconds; } void TestScannerInterface::record_slope_table(unsigned table_nr, const std::vector& steps) { slope_tables_[table_nr] = steps; } std::map>& TestScannerInterface::recorded_slope_tables() { return slope_tables_; } void TestScannerInterface::record_progress_message(const char* msg) { last_progress_message_ = msg; } const std::string& TestScannerInterface::last_progress_message() const { return last_progress_message_; } void TestScannerInterface::record_key_value(const std::string& key, const std::string& value) { key_values_[key] = value; } std::map& TestScannerInterface::recorded_key_values() { return key_values_; } void TestScannerInterface::test_checkpoint(const std::string& name) { if (checkpoint_callback_) { checkpoint_callback_(*dev_, *this, name); } } void TestScannerInterface::set_checkpoint_callback(TestCheckpointCallback callback) { checkpoint_callback_ = callback; } } // namespace genesys sane-backends-1.0.29/backend/genesys/image_pixel.cpp0000666000000000000000000004762113615534521017246 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "image.h" #include namespace genesys { struct PixelFormatDesc { PixelFormat format; unsigned depth; unsigned channels; ColorOrder order; }; const PixelFormatDesc s_known_pixel_formats[] = { { PixelFormat::I1, 1, 1, ColorOrder::RGB }, { PixelFormat::I8, 8, 1, ColorOrder::RGB }, { PixelFormat::I16, 16, 1, ColorOrder::RGB }, { PixelFormat::RGB111, 1, 3, ColorOrder::RGB }, { PixelFormat::RGB888, 8, 3, ColorOrder::RGB }, { PixelFormat::RGB161616, 16, 3, ColorOrder::RGB }, { PixelFormat::BGR888, 8, 3, ColorOrder::BGR }, { PixelFormat::BGR161616, 16, 3, ColorOrder::BGR }, }; ColorOrder get_pixel_format_color_order(PixelFormat format) { for (const auto& desc : s_known_pixel_formats) { if (desc.format == format) return desc.order; } throw SaneException("Unknown pixel format %d", static_cast(format)); } unsigned get_pixel_format_depth(PixelFormat format) { for (const auto& desc : s_known_pixel_formats) { if (desc.format == format) return desc.depth; } throw SaneException("Unknown pixel format %d", static_cast(format)); } unsigned get_pixel_channels(PixelFormat format) { for (const auto& desc : s_known_pixel_formats) { if (desc.format == format) return desc.channels; } throw SaneException("Unknown pixel format %d", static_cast(format)); } std::size_t get_pixel_row_bytes(PixelFormat format, std::size_t width) { std::size_t depth = get_pixel_format_depth(format) * get_pixel_channels(format); std::size_t total_bits = depth * width; return total_bits / 8 + ((total_bits % 8 > 0) ? 1 : 0); } std::size_t get_pixels_from_row_bytes(PixelFormat format, std::size_t row_bytes) { std::size_t depth = get_pixel_format_depth(format) * get_pixel_channels(format); return (row_bytes * 8) / depth; } PixelFormat create_pixel_format(unsigned depth, unsigned channels, ColorOrder order) { for (const auto& desc : s_known_pixel_formats) { if (desc.depth == depth && desc.channels == channels && desc.order == order) { return desc.format; } } throw SaneException("Unknown pixel format %d %d %d", depth, channels, static_cast(order)); } static inline unsigned read_bit(const std::uint8_t* data, std::size_t x) { return (data[x / 8] >> (7 - (x % 8))) & 0x1; } static inline void write_bit(std::uint8_t* data, std::size_t x, unsigned value) { value = (value & 0x1) << (7 - (x % 8)); std::uint8_t mask = 0x1 << (7 - (x % 8)); data[x / 8] = (data[x / 8] & ~mask) | (value & mask); } Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x, PixelFormat format) { switch (format) { case PixelFormat::I1: { std::uint16_t val = read_bit(data, x) ? 0xffff : 0x0000; return Pixel(val, val, val); } case PixelFormat::RGB111: { x *= 3; std::uint16_t r = read_bit(data, x) ? 0xffff : 0x0000; std::uint16_t g = read_bit(data, x + 1) ? 0xffff : 0x0000; std::uint16_t b = read_bit(data, x + 2) ? 0xffff : 0x0000; return Pixel(r, g, b); } case PixelFormat::I8: { std::uint16_t val = std::uint16_t(data[x]) | (data[x] << 8); return Pixel(val, val, val); } case PixelFormat::I16: { x *= 2; std::uint16_t val = std::uint16_t(data[x]) | (data[x + 1] << 8); return Pixel(val, val, val); } case PixelFormat::RGB888: { x *= 3; std::uint16_t r = std::uint16_t(data[x]) | (data[x] << 8); std::uint16_t g = std::uint16_t(data[x + 1]) | (data[x + 1] << 8); std::uint16_t b = std::uint16_t(data[x + 2]) | (data[x + 2] << 8); return Pixel(r, g, b); } case PixelFormat::BGR888: { x *= 3; std::uint16_t b = std::uint16_t(data[x]) | (data[x] << 8); std::uint16_t g = std::uint16_t(data[x + 1]) | (data[x + 1] << 8); std::uint16_t r = std::uint16_t(data[x + 2]) | (data[x + 2] << 8); return Pixel(r, g, b); } case PixelFormat::RGB161616: { x *= 6; std::uint16_t r = std::uint16_t(data[x]) | (data[x + 1] << 8); std::uint16_t g = std::uint16_t(data[x + 2]) | (data[x + 3] << 8); std::uint16_t b = std::uint16_t(data[x + 4]) | (data[x + 5] << 8); return Pixel(r, g, b); } case PixelFormat::BGR161616: { x *= 6; std::uint16_t b = std::uint16_t(data[x]) | (data[x + 1] << 8); std::uint16_t g = std::uint16_t(data[x + 2]) | (data[x + 3] << 8); std::uint16_t r = std::uint16_t(data[x + 4]) | (data[x + 5] << 8); return Pixel(r, g, b); } default: throw SaneException("Unknown pixel format %d", static_cast(format)); } } void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel, PixelFormat format) { switch (format) { case PixelFormat::I1: write_bit(data, x, pixel.r & 0x8000 ? 1 : 0); return; case PixelFormat::RGB111: { x *= 3; write_bit(data, x, pixel.r & 0x8000 ? 1 : 0); write_bit(data, x + 1,pixel.g & 0x8000 ? 1 : 0); write_bit(data, x + 2, pixel.b & 0x8000 ? 1 : 0); return; } case PixelFormat::I8: { float val = (pixel.r >> 8) * 0.3f; val += (pixel.g >> 8) * 0.59f; val += (pixel.b >> 8) * 0.11f; data[x] = static_cast(val); return; } case PixelFormat::I16: { x *= 2; float val = pixel.r * 0.3f; val += pixel.g * 0.59f; val += pixel.b * 0.11f; auto val16 = static_cast(val); data[x] = val16 & 0xff; data[x + 1] = (val16 >> 8) & 0xff; return; } case PixelFormat::RGB888: { x *= 3; data[x] = pixel.r >> 8; data[x + 1] = pixel.g >> 8; data[x + 2] = pixel.b >> 8; return; } case PixelFormat::BGR888: { x *= 3; data[x] = pixel.b >> 8; data[x + 1] = pixel.g >> 8; data[x + 2] = pixel.r >> 8; return; } case PixelFormat::RGB161616: { x *= 6; data[x] = pixel.r & 0xff; data[x + 1] = (pixel.r >> 8) & 0xff; data[x + 2] = pixel.g & 0xff; data[x + 3] = (pixel.g >> 8) & 0xff; data[x + 4] = pixel.b & 0xff; data[x + 5] = (pixel.b >> 8) & 0xff; return; } case PixelFormat::BGR161616: x *= 6; data[x] = pixel.b & 0xff; data[x + 1] = (pixel.b >> 8) & 0xff; data[x + 2] = pixel.g & 0xff; data[x + 3] = (pixel.g >> 8) & 0xff; data[x + 4] = pixel.r & 0xff; data[x + 5] = (pixel.r >> 8) & 0xff; return; default: throw SaneException("Unknown pixel format %d", static_cast(format)); } } RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x, PixelFormat format) { switch (format) { case PixelFormat::I1: return RawPixel(read_bit(data, x)); case PixelFormat::RGB111: { x *= 3; return RawPixel(read_bit(data, x) << 2 | (read_bit(data, x + 1) << 1) | (read_bit(data, x + 2))); } case PixelFormat::I8: return RawPixel(data[x]); case PixelFormat::I16: { x *= 2; return RawPixel(data[x], data[x + 1]); } case PixelFormat::RGB888: case PixelFormat::BGR888: { x *= 3; return RawPixel(data[x], data[x + 1], data[x + 2]); } case PixelFormat::RGB161616: case PixelFormat::BGR161616: { x *= 6; return RawPixel(data[x], data[x + 1], data[x + 2], data[x + 3], data[x + 4], data[x + 5]); } default: throw SaneException("Unknown pixel format %d", static_cast(format)); } } void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel, PixelFormat format) { switch (format) { case PixelFormat::I1: write_bit(data, x, pixel.data[0] & 0x1); return; case PixelFormat::RGB111: { x *= 3; write_bit(data, x, (pixel.data[0] >> 2) & 0x1); write_bit(data, x + 1, (pixel.data[0] >> 1) & 0x1); write_bit(data, x + 2, (pixel.data[0]) & 0x1); return; } case PixelFormat::I8: data[x] = pixel.data[0]; return; case PixelFormat::I16: { x *= 2; data[x] = pixel.data[0]; data[x + 1] = pixel.data[1]; return; } case PixelFormat::RGB888: case PixelFormat::BGR888: { x *= 3; data[x] = pixel.data[0]; data[x + 1] = pixel.data[1]; data[x + 2] = pixel.data[2]; return; } case PixelFormat::RGB161616: case PixelFormat::BGR161616: { x *= 6; data[x] = pixel.data[0]; data[x + 1] = pixel.data[1]; data[x + 2] = pixel.data[2]; data[x + 3] = pixel.data[3]; data[x + 4] = pixel.data[4]; data[x + 5] = pixel.data[5]; return; } default: throw SaneException("Unknown pixel format %d", static_cast(format)); } } std::uint16_t get_raw_channel_from_row(const std::uint8_t* data, std::size_t x, unsigned channel, PixelFormat format) { switch (format) { case PixelFormat::I1: return read_bit(data, x); case PixelFormat::RGB111: return read_bit(data, x * 3 + channel); case PixelFormat::I8: return data[x]; case PixelFormat::I16: { x *= 2; return data[x] | (data[x + 1] << 8); } case PixelFormat::RGB888: case PixelFormat::BGR888: return data[x * 3 + channel]; case PixelFormat::RGB161616: case PixelFormat::BGR161616: return data[x * 6 + channel * 2] | (data[x * 6 + channel * 2 + 1]) << 8; default: throw SaneException("Unknown pixel format %d", static_cast(format)); } } void set_raw_channel_to_row(std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel, PixelFormat format) { switch (format) { case PixelFormat::I1: write_bit(data, x, pixel & 0x1); return; case PixelFormat::RGB111: { write_bit(data, x * 3 + channel, pixel & 0x1); return; } case PixelFormat::I8: data[x] = pixel; return; case PixelFormat::I16: { x *= 2; data[x] = pixel; data[x + 1] = pixel >> 8; return; } case PixelFormat::RGB888: case PixelFormat::BGR888: { x *= 3; data[x + channel] = pixel; return; } case PixelFormat::RGB161616: case PixelFormat::BGR161616: { x *= 6; data[x + channel * 2] = pixel; data[x + channel * 2 + 1] = pixel >> 8; return; } default: throw SaneException("Unknown pixel format %d", static_cast(format)); } } template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x) { return get_pixel_from_row(data, x, Format); } template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel) { set_pixel_to_row(data, x, pixel, Format); } template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x) { return get_raw_pixel_from_row(data, x, Format); } template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel) { set_raw_pixel_to_row(data, x, pixel, Format); } template std::uint16_t get_raw_channel_from_row(const std::uint8_t* data, std::size_t x, unsigned channel) { return get_raw_channel_from_row(data, x, channel, Format); } template void set_raw_channel_to_row(std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel) { set_raw_channel_to_row(data, x, channel, pixel, Format); } template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template std::uint16_t get_raw_channel_from_row( const std::uint8_t* data, std::size_t x, unsigned channel); template std::uint16_t get_raw_channel_from_row( const std::uint8_t* data, std::size_t x, unsigned channel); template std::uint16_t get_raw_channel_from_row( const std::uint8_t* data, std::size_t x, unsigned channel); template std::uint16_t get_raw_channel_from_row( const std::uint8_t* data, std::size_t x, unsigned channel); template std::uint16_t get_raw_channel_from_row( const std::uint8_t* data, std::size_t x, unsigned channel); template std::uint16_t get_raw_channel_from_row( const std::uint8_t* data, std::size_t x, unsigned channel); template std::uint16_t get_raw_channel_from_row( const std::uint8_t* data, std::size_t x, unsigned channel); template std::uint16_t get_raw_channel_from_row (const std::uint8_t* data, std::size_t x, unsigned channel); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template void set_raw_channel_to_row( std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); template void set_raw_channel_to_row( std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); template void set_raw_channel_to_row( std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); template void set_raw_channel_to_row( std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); template void set_raw_channel_to_row( std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); template void set_raw_channel_to_row( std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); template void set_raw_channel_to_row( std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); template void set_raw_channel_to_row( std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); } // namespace genesys sane-backends-1.0.29/backend/genesys/scanner_interface_usb.cpp0000666000000000000000000004044713615534521021304 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "scanner_interface_usb.h" #include "low.h" #include namespace genesys { ScannerInterfaceUsb::~ScannerInterfaceUsb() = default; ScannerInterfaceUsb::ScannerInterfaceUsb(Genesys_Device* dev) : dev_{dev} {} bool ScannerInterfaceUsb::is_mock() const { return false; } std::uint8_t ScannerInterfaceUsb::read_register(std::uint16_t address) { DBG_HELPER(dbg); std::uint8_t value = 0; if (dev_->model->asic_type == AsicType::GL847 || dev_->model->asic_type == AsicType::GL845 || dev_->model->asic_type == AsicType::GL846 || dev_->model->asic_type == AsicType::GL124) { std::uint8_t value2x8[2]; std::uint16_t address16 = 0x22 + (address << 8); std::uint16_t usb_value = VALUE_GET_REGISTER; if (address > 0xff) { usb_value |= 0x100; } usb_dev_.control_msg(REQUEST_TYPE_IN, REQUEST_BUFFER, usb_value, address16, 2, value2x8); // check usb link status if (value2x8[1] != 0x55) { throw SaneException(SANE_STATUS_IO_ERROR, "invalid read, scanner unplugged?"); } DBG(DBG_io, "%s (0x%02x, 0x%02x) completed\n", __func__, address, value2x8[0]); value = value2x8[0]; } else { if (address > 0xff) { throw SaneException("Invalid register address 0x%04x", address); } std::uint8_t address8 = address & 0xff; usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, INDEX, 1, &address8); usb_dev_.control_msg(REQUEST_TYPE_IN, REQUEST_REGISTER, VALUE_READ_REGISTER, INDEX, 1, &value); } DBG(DBG_proc, "%s (0x%02x, 0x%02x) completed\n", __func__, address, value); return value; } void ScannerInterfaceUsb::write_register(std::uint16_t address, std::uint8_t value) { DBG_HELPER_ARGS(dbg, "address: 0x%04x, value: 0x%02x", static_cast(address), static_cast(value)); if (dev_->model->asic_type == AsicType::GL847 || dev_->model->asic_type == AsicType::GL845 || dev_->model->asic_type == AsicType::GL846 || dev_->model->asic_type == AsicType::GL124) { std::uint8_t buffer[2]; buffer[0] = address & 0xff; buffer[1] = value; std::uint16_t usb_value = VALUE_SET_REGISTER; if (address > 0xff) { usb_value |= 0x100; } usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_BUFFER, usb_value, INDEX, 2, buffer); } else { if (address > 0xff) { throw SaneException("Invalid register address 0x%04x", address); } std::uint8_t address8 = address & 0xff; usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, INDEX, 1, &address8); usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_WRITE_REGISTER, INDEX, 1, &value); } DBG(DBG_io, "%s (0x%02x, 0x%02x) completed\n", __func__, address, value); } void ScannerInterfaceUsb::write_registers(const Genesys_Register_Set& regs) { DBG_HELPER(dbg); if (dev_->model->asic_type == AsicType::GL646 || dev_->model->asic_type == AsicType::GL841) { uint8_t outdata[8]; std::vector buffer; buffer.reserve(regs.size() * 2); /* copy registers and values in data buffer */ for (const auto& r : regs) { buffer.push_back(r.address); buffer.push_back(r.value); } DBG(DBG_io, "%s (elems= %zu, size = %zu)\n", __func__, regs.size(), buffer.size()); if (dev_->model->asic_type == AsicType::GL646) { outdata[0] = BULK_OUT; outdata[1] = BULK_REGISTER; outdata[2] = 0x00; outdata[3] = 0x00; outdata[4] = (buffer.size() & 0xff); outdata[5] = ((buffer.size() >> 8) & 0xff); outdata[6] = ((buffer.size() >> 16) & 0xff); outdata[7] = ((buffer.size() >> 24) & 0xff); usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_BUFFER, VALUE_BUFFER, INDEX, sizeof(outdata), outdata); size_t write_size = buffer.size(); usb_dev_.bulk_write(buffer.data(), &write_size); } else { for (std::size_t i = 0; i < regs.size();) { std::size_t c = regs.size() - i; if (c > 32) /*32 is max on GL841. checked that.*/ c = 32; usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_BUFFER, VALUE_SET_REGISTER, INDEX, c * 2, buffer.data() + i * 2); i += c; } } } else { for (const auto& r : regs) { write_register(r.address, r.value); } } DBG(DBG_io, "%s: wrote %zu registers\n", __func__, regs.size()); } void ScannerInterfaceUsb::write_0x8c(std::uint8_t index, std::uint8_t value) { DBG_HELPER_ARGS(dbg, "0x%02x,0x%02x", index, value); usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_BUF_ENDACCESS, index, 1, &value); } static void bulk_read_data_send_header(UsbDevice& usb_dev, AsicType asic_type, size_t size) { DBG_HELPER(dbg); uint8_t outdata[8]; if (asic_type == AsicType::GL124 || asic_type == AsicType::GL846 || asic_type == AsicType::GL847) { // hard coded 0x10000000 address outdata[0] = 0; outdata[1] = 0; outdata[2] = 0; outdata[3] = 0x10; } else if (asic_type == AsicType::GL841 || asic_type == AsicType::GL843) { outdata[0] = BULK_IN; outdata[1] = BULK_RAM; outdata[2] = 0x82; // outdata[3] = 0x00; } else { outdata[0] = BULK_IN; outdata[1] = BULK_RAM; outdata[2] = 0x00; outdata[3] = 0x00; } /* data size to transfer */ outdata[4] = (size & 0xff); outdata[5] = ((size >> 8) & 0xff); outdata[6] = ((size >> 16) & 0xff); outdata[7] = ((size >> 24) & 0xff); usb_dev.control_msg(REQUEST_TYPE_OUT, REQUEST_BUFFER, VALUE_BUFFER, 0x00, sizeof(outdata), outdata); } void ScannerInterfaceUsb::bulk_read_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) { // currently supported: GL646, GL841, GL843, GL846, GL847, GL124 DBG_HELPER(dbg); unsigned is_addr_used = 1; unsigned has_header_before_each_chunk = 0; if (dev_->model->asic_type == AsicType::GL124 || dev_->model->asic_type == AsicType::GL846 || dev_->model->asic_type == AsicType::GL847) { is_addr_used = 0; has_header_before_each_chunk = 1; } if (is_addr_used) { DBG(DBG_io, "%s: requesting %zu bytes from 0x%02x addr\n", __func__, size, addr); } else { DBG(DBG_io, "%s: requesting %zu bytes\n", __func__, size); } if (size == 0) return; if (is_addr_used) { usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, 0x00, 1, &addr); } std::size_t target_size = size; std::size_t max_in_size = sanei_genesys_get_bulk_max_size(dev_->model->asic_type); if (!has_header_before_each_chunk) { bulk_read_data_send_header(usb_dev_, dev_->model->asic_type, size); } // loop until computed data size is read while (target_size > 0) { std::size_t block_size = std::min(target_size, max_in_size); if (has_header_before_each_chunk) { bulk_read_data_send_header(usb_dev_, dev_->model->asic_type, block_size); } DBG(DBG_io2, "%s: trying to read %zu bytes of data\n", __func__, block_size); usb_dev_.bulk_read(data, &block_size); DBG(DBG_io2, "%s: read %zu bytes, %zu remaining\n", __func__, block_size, target_size - block_size); target_size -= block_size; data += block_size; } } void ScannerInterfaceUsb::bulk_write_data(std::uint8_t addr, std::uint8_t* data, std::size_t len) { DBG_HELPER_ARGS(dbg, "writing %zu bytes", len); // supported: GL646, GL841, GL843 std::size_t size; std::uint8_t outdata[8]; usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, INDEX, 1, &addr); std::size_t max_out_size = sanei_genesys_get_bulk_max_size(dev_->model->asic_type); while (len) { if (len > max_out_size) size = max_out_size; else size = len; if (dev_->model->asic_type == AsicType::GL841) { outdata[0] = BULK_OUT; outdata[1] = BULK_RAM; // both 0x82 and 0x00 works on GL841. outdata[2] = 0x82; outdata[3] = 0x00; } else { outdata[0] = BULK_OUT; outdata[1] = BULK_RAM; // 8600F uses 0x82, but 0x00 works too. 8400F uses 0x02 for certain transactions. outdata[2] = 0x00; outdata[3] = 0x00; } outdata[4] = (size & 0xff); outdata[5] = ((size >> 8) & 0xff); outdata[6] = ((size >> 16) & 0xff); outdata[7] = ((size >> 24) & 0xff); usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_BUFFER, VALUE_BUFFER, 0x00, sizeof(outdata), outdata); usb_dev_.bulk_write(data, &size); DBG(DBG_io2, "%s: wrote %zu bytes, %zu remaining\n", __func__, size, len - size); len -= size; data += size; } } void ScannerInterfaceUsb::write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags) { DBG_HELPER_ARGS(dbg, "type: 0x%02x, addr: 0x%08x, size: 0x%08zx", type, addr, size); if (dev_->model->asic_type != AsicType::GL646 && dev_->model->asic_type != AsicType::GL841 && dev_->model->asic_type != AsicType::GL843) { throw SaneException("Unsupported transfer mode"); } if (dev_->model->asic_type == AsicType::GL843) { if (flags & FLAG_SWAP_REGISTERS) { if (!(flags & FLAG_SMALL_ADDRESS)) { write_register(0x29, ((addr >> 20) & 0xff)); } write_register(0x2a, ((addr >> 12) & 0xff)); write_register(0x2b, ((addr >> 4) & 0xff)); } else { write_register(0x2b, ((addr >> 4) & 0xff)); write_register(0x2a, ((addr >> 12) & 0xff)); if (!(flags & FLAG_SMALL_ADDRESS)) { write_register(0x29, ((addr >> 20) & 0xff)); } } } else { write_register(0x2b, ((addr >> 4) & 0xff)); write_register(0x2a, ((addr >> 12) & 0xff)); } bulk_write_data(type, data, size); } void ScannerInterfaceUsb::write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags) { DBG_HELPER_ARGS(dbg, "type: 0x%02x, addr: 0x%08x, size: 0x%08zx", type, addr, size); if (dev_->model->asic_type != AsicType::GL646 && dev_->model->asic_type != AsicType::GL841 && dev_->model->asic_type != AsicType::GL843) { throw SaneException("Unsupported transfer mode"); } if (flags & FLAG_SWAP_REGISTERS) { write_register(0x5b, ((addr >> 12) & 0xff)); write_register(0x5c, ((addr >> 4) & 0xff)); } else { write_register(0x5c, ((addr >> 4) & 0xff)); write_register(0x5b, ((addr >> 12) & 0xff)); } bulk_write_data(type, data, size); } void ScannerInterfaceUsb::write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) { DBG_HELPER_ARGS(dbg, "address: 0x%08x, size: %d", static_cast(addr), static_cast(size)); if (dev_->model->asic_type != AsicType::GL845 && dev_->model->asic_type != AsicType::GL846 && dev_->model->asic_type != AsicType::GL847 && dev_->model->asic_type != AsicType::GL124) { throw SaneException("Unsupported transfer type"); } std::uint8_t outdata[8]; outdata[0] = addr & 0xff; outdata[1] = ((addr >> 8) & 0xff); outdata[2] = ((addr >> 16) & 0xff); outdata[3] = ((addr >> 24) & 0xff); outdata[4] = (size & 0xff); outdata[5] = ((size >> 8) & 0xff); outdata[6] = ((size >> 16) & 0xff); outdata[7] = ((size >> 24) & 0xff); // write addr and size for AHB usb_dev_.control_msg(REQUEST_TYPE_OUT, REQUEST_BUFFER, VALUE_BUFFER, 0x01, 8, outdata); std::size_t max_out_size = sanei_genesys_get_bulk_max_size(dev_->model->asic_type); // write actual data std::size_t written = 0; do { std::size_t block_size = std::min(size - written, max_out_size); usb_dev_.bulk_write(data + written, &block_size); written += block_size; } while (written < size); } std::uint16_t ScannerInterfaceUsb::read_fe_register(std::uint8_t address) { DBG_HELPER(dbg); Genesys_Register_Set reg; reg.init_reg(0x50, address); // set up read address write_registers(reg); // read data std::uint16_t value = read_register(0x46) << 8; value |= read_register(0x47); DBG(DBG_io, "%s (0x%02x, 0x%04x)\n", __func__, address, value); return value; } void ScannerInterfaceUsb::write_fe_register(std::uint8_t address, std::uint16_t value) { DBG_HELPER_ARGS(dbg, "0x%02x, 0x%04x", address, value); Genesys_Register_Set reg(Genesys_Register_Set::SEQUENTIAL); reg.init_reg(0x51, address); if (dev_->model->asic_type == AsicType::GL124) { reg.init_reg(0x5d, (value / 256) & 0xff); reg.init_reg(0x5e, value & 0xff); } else { reg.init_reg(0x3a, (value / 256) & 0xff); reg.init_reg(0x3b, value & 0xff); } write_registers(reg); } IUsbDevice& ScannerInterfaceUsb::get_usb_device() { return usb_dev_; } void ScannerInterfaceUsb::sleep_us(unsigned microseconds) { if (sanei_usb_is_replay_mode_enabled()) { return; } std::this_thread::sleep_for(std::chrono::microseconds{microseconds}); } void ScannerInterfaceUsb::record_progress_message(const char* msg) { sanei_usb_testing_record_message(msg); } void ScannerInterfaceUsb::record_slope_table(unsigned table_nr, const std::vector& steps) { (void) table_nr; (void) steps; } void ScannerInterfaceUsb::record_key_value(const std::string& key, const std::string& value) { (void) key; (void) value; } void ScannerInterfaceUsb::test_checkpoint(const std::string& name) { (void) name; } } // namespace genesys sane-backends-1.0.29/backend/genesys/gl847_registers.h0000666000000000000000000003175213615534521017362 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL847_REGISTERS_H #define BACKEND_GENESYS_GL847_REGISTERS_H #include namespace genesys { namespace gl847 { using RegAddr = std::uint16_t; using RegMask = std::uint8_t; using RegShift = unsigned; static constexpr RegAddr REG_0x01 = 0x01; static constexpr RegMask REG_0x01_CISSET = 0x80; static constexpr RegMask REG_0x01_DOGENB = 0x40; static constexpr RegMask REG_0x01_DVDSET = 0x20; static constexpr RegMask REG_0x01_STAGGER = 0x10; static constexpr RegMask REG_0x01_COMPENB = 0x08; static constexpr RegMask REG_0x01_TRUEGRAY = 0x04; static constexpr RegMask REG_0x01_SHDAREA = 0x02; static constexpr RegMask REG_0x01_SCAN = 0x01; static constexpr RegAddr REG_0x02 = 0x02; static constexpr RegMask REG_0x02_NOTHOME = 0x80; static constexpr RegMask REG_0x02_ACDCDIS = 0x40; static constexpr RegMask REG_0x02_AGOHOME = 0x20; static constexpr RegMask REG_0x02_MTRPWR = 0x10; static constexpr RegMask REG_0x02_FASTFED = 0x08; static constexpr RegMask REG_0x02_MTRREV = 0x04; static constexpr RegMask REG_0x02_HOMENEG = 0x02; static constexpr RegMask REG_0x02_LONGCURV = 0x01; static constexpr RegAddr REG_0x03 = 0x03; static constexpr RegMask REG_0x03_LAMPDOG = 0x80; static constexpr RegMask REG_0x03_AVEENB = 0x40; static constexpr RegMask REG_0x03_XPASEL = 0x20; static constexpr RegMask REG_0x03_LAMPPWR = 0x10; static constexpr RegMask REG_0x03_LAMPTIM = 0x0f; static constexpr RegAddr REG_0x04 = 0x04; static constexpr RegMask REG_0x04_LINEART = 0x80; static constexpr RegMask REG_0x04_BITSET = 0x40; static constexpr RegMask REG_0x04_AFEMOD = 0x30; static constexpr RegMask REG_0x04_FILTER = 0x0c; static constexpr RegMask REG_0x04_FESET = 0x03; static constexpr RegShift REG_0x04S_AFEMOD = 4; static constexpr RegAddr REG_0x05 = 0x05; static constexpr RegMask REG_0x05_DPIHW = 0xc0; static constexpr RegMask REG_0x05_DPIHW_600 = 0x00; static constexpr RegMask REG_0x05_DPIHW_1200 = 0x40; static constexpr RegMask REG_0x05_DPIHW_2400 = 0x80; static constexpr RegMask REG_0x05_DPIHW_4800 = 0xc0; static constexpr RegMask REG_0x05_MTLLAMP = 0x30; static constexpr RegMask REG_0x05_GMMENB = 0x08; static constexpr RegMask REG_0x05_MTLBASE = 0x03; static constexpr RegAddr REG_0x06 = 0x06; static constexpr RegMask REG_0x06_SCANMOD = 0xe0; static constexpr RegMask REG_0x06S_SCANMOD = 5; static constexpr RegMask REG_0x06_PWRBIT = 0x10; static constexpr RegMask REG_0x06_GAIN4 = 0x08; static constexpr RegMask REG_0x06_OPTEST = 0x07; static constexpr RegMask REG_0x07_LAMPSIM = 0x80; static constexpr RegMask REG_0x08_DRAM2X = 0x80; static constexpr RegMask REG_0x08_MPENB = 0x20; static constexpr RegMask REG_0x08_CIS_LINE = 0x10; static constexpr RegMask REG_0x08_IR1ENB = 0x08; static constexpr RegMask REG_0x08_IR2ENB = 0x04; static constexpr RegMask REG_0x08_ENB24M = 0x01; static constexpr RegMask REG_0x09_MCNTSET = 0xc0; static constexpr RegMask REG_0x09_EVEN1ST = 0x20; static constexpr RegMask REG_0x09_BLINE1ST = 0x10; static constexpr RegMask REG_0x09_BACKSCAN = 0x08; static constexpr RegMask REG_0x09_ENHANCE = 0x04; static constexpr RegMask REG_0x09_SHORTTG = 0x02; static constexpr RegMask REG_0x09_NWAIT = 0x01; static constexpr RegShift REG_0x09S_MCNTSET = 6; static constexpr RegShift REG_0x09S_CLKSET = 4; static constexpr RegMask REG_0x0A_LPWMEN = 0x10; static constexpr RegAddr REG_0x0B = 0x0b; static constexpr RegMask REG_0x0B_DRAMSEL = 0x07; static constexpr RegMask REG_0x0B_ENBDRAM = 0x08; static constexpr RegMask REG_0x0B_RFHDIS = 0x10; static constexpr RegMask REG_0x0B_CLKSET = 0xe0; static constexpr RegMask REG_0x0B_24MHZ = 0x00; static constexpr RegMask REG_0x0B_30MHZ = 0x20; static constexpr RegMask REG_0x0B_40MHZ = 0x40; static constexpr RegMask REG_0x0B_48MHZ = 0x60; static constexpr RegMask REG_0x0B_60MHZ = 0x80; static constexpr RegAddr REG_0x0C = 0x0c; static constexpr RegMask REG_0x0C_CCDLMT = 0x0f; static constexpr RegAddr REG_0x0D = 0x0d; static constexpr RegMask REG_0x0D_FULLSTP = 0x10; static constexpr RegMask REG_0x0D_SEND = 0x80; static constexpr RegMask REG_0x0D_CLRMCNT = 0x04; static constexpr RegMask REG_0x0D_CLRDOCJM = 0x02; static constexpr RegMask REG_0x0D_CLRLNCNT = 0x01; static constexpr RegAddr REG_0x0F = 0x0f; static constexpr RegMask REG_0x16_CTRLHI = 0x80; static constexpr RegMask REG_0x16_TOSHIBA = 0x40; static constexpr RegMask REG_0x16_TGINV = 0x20; static constexpr RegMask REG_0x16_CK1INV = 0x10; static constexpr RegMask REG_0x16_CK2INV = 0x08; static constexpr RegMask REG_0x16_CTRLINV = 0x04; static constexpr RegMask REG_0x16_CKDIS = 0x02; static constexpr RegMask REG_0x16_CTRLDIS = 0x01; static constexpr RegMask REG_0x17_TGMODE = 0xc0; static constexpr RegMask REG_0x17_TGMODE_NO_DUMMY = 0x00; static constexpr RegMask REG_0x17_TGMODE_REF = 0x40; static constexpr RegMask REG_0x17_TGMODE_XPA = 0x80; static constexpr RegMask REG_0x17_TGW = 0x3f; static constexpr RegMask REG_0x17S_TGW = 0; static constexpr RegAddr REG_0x18 = 0x18; static constexpr RegMask REG_0x18_CNSET = 0x80; static constexpr RegMask REG_0x18_DCKSEL = 0x60; static constexpr RegMask REG_0x18_CKTOGGLE = 0x10; static constexpr RegMask REG_0x18_CKDELAY = 0x0c; static constexpr RegMask REG_0x18_CKSEL = 0x03; static constexpr RegMask REG_0x1A_SW2SET = 0x80; static constexpr RegMask REG_0x1A_SW1SET = 0x40; static constexpr RegMask REG_0x1A_MANUAL3 = 0x02; static constexpr RegMask REG_0x1A_MANUAL1 = 0x01; static constexpr RegMask REG_0x1A_CK4INV = 0x08; static constexpr RegMask REG_0x1A_CK3INV = 0x04; static constexpr RegMask REG_0x1A_LINECLP = 0x02; static constexpr RegAddr REG_0x1C = 0x1c; static constexpr RegMask REG_0x1C_TGTIME = 0x07; static constexpr RegMask REG_0x1D_CK4LOW = 0x80; static constexpr RegMask REG_0x1D_CK3LOW = 0x40; static constexpr RegMask REG_0x1D_CK1LOW = 0x20; static constexpr RegMask REG_0x1D_TGSHLD = 0x1f; static constexpr RegMask REG_0x1DS_TGSHLD = 0; static constexpr RegMask REG_0x1E_WDTIME = 0xf0; static constexpr RegMask REG_0x1ES_WDTIME = 4; static constexpr RegMask REG_0x1E_LINESEL = 0x0f; static constexpr RegMask REG_0x1ES_LINESEL = 0; static constexpr RegAddr REG_FEDCNT = 0x1f; static constexpr RegAddr REG_0x24 = 0x1c; static constexpr RegAddr REG_0x40 = 0x40; static constexpr RegMask REG_0x40_CHKVER = 0x10; static constexpr RegMask REG_0x40_HISPDFLG = 0x04; static constexpr RegMask REG_0x40_MOTMFLG = 0x02; static constexpr RegMask REG_0x40_DATAENB = 0x01; static constexpr RegMask REG_0x41_PWRBIT = 0x80; static constexpr RegMask REG_0x41_BUFEMPTY = 0x40; static constexpr RegMask REG_0x41_FEEDFSH = 0x20; static constexpr RegMask REG_0x41_SCANFSH = 0x10; static constexpr RegMask REG_0x41_HOMESNR = 0x08; static constexpr RegMask REG_0x41_LAMPSTS = 0x04; static constexpr RegMask REG_0x41_FEBUSY = 0x02; static constexpr RegMask REG_0x41_MOTORENB = 0x01; static constexpr RegMask REG_0x58_VSMP = 0xf8; static constexpr RegShift REG_0x58S_VSMP = 3; static constexpr RegMask REG_0x58_VSMPW = 0x07; static constexpr RegShift REG_0x58S_VSMPW = 0; static constexpr RegMask REG_0x59_BSMP = 0xf8; static constexpr RegShift REG_0x59S_BSMP = 3; static constexpr RegMask REG_0x59_BSMPW = 0x07; static constexpr RegShift REG_0x59S_BSMPW = 0; static constexpr RegMask REG_0x5A_ADCLKINV = 0x80; static constexpr RegMask REG_0x5A_RLCSEL = 0x40; static constexpr RegMask REG_0x5A_CDSREF = 0x30; static constexpr RegShift REG_0x5AS_CDSREF = 4; static constexpr RegMask REG_0x5A_RLC = 0x0f; static constexpr RegShift REG_0x5AS_RLC = 0; static constexpr RegMask REG_0x5E_DECSEL = 0xe0; static constexpr RegShift REG_0x5ES_DECSEL = 5; static constexpr RegMask REG_0x5E_STOPTIM = 0x1f; static constexpr RegShift REG_0x5ES_STOPTIM = 0; static constexpr RegAddr REG_0x60 = 0x60; static constexpr RegMask REG_0x60_Z1MOD = 0x1f; static constexpr RegAddr REG_0x61 = 0x61; static constexpr RegMask REG_0x61_Z1MOD = 0xff; static constexpr RegAddr REG_0x62 = 0x62; static constexpr RegMask REG_0x62_Z1MOD = 0xff; static constexpr RegAddr REG_0x63 = 0x63; static constexpr RegMask REG_0x63_Z2MOD = 0x1f; static constexpr RegAddr REG_0x64 = 0x64; static constexpr RegMask REG_0x64_Z2MOD = 0xff; static constexpr RegAddr REG_0x65 = 0x65; static constexpr RegMask REG_0x65_Z2MOD = 0xff; static constexpr RegShift REG_0x60S_STEPSEL = 5; static constexpr RegMask REG_0x60_STEPSEL = 0xe0; static constexpr RegMask REG_0x60_FULLSTEP = 0x00; static constexpr RegMask REG_0x60_HALFSTEP = 0x20; static constexpr RegMask REG_0x60_EIGHTHSTEP = 0x60; static constexpr RegMask REG_0x60_16THSTEP = 0x80; static constexpr RegShift REG_0x63S_FSTPSEL = 5; static constexpr RegMask REG_0x63_FSTPSEL = 0xe0; static constexpr RegMask REG_0x63_FULLSTEP = 0x00; static constexpr RegMask REG_0x63_HALFSTEP = 0x20; static constexpr RegMask REG_0x63_EIGHTHSTEP = 0x60; static constexpr RegMask REG_0x63_16THSTEP = 0x80; static constexpr RegAddr REG_0x67 = 0x67; static constexpr RegMask REG_0x67_MTRPWM = 0x80; static constexpr RegAddr REG_0x68 = 0x68; static constexpr RegMask REG_0x68_FASTPWM = 0x80; static constexpr RegAddr REG_0x6B = 0x6b; static constexpr RegMask REG_0x6B_MULTFILM = 0x80; static constexpr RegMask REG_0x6B_GPOM13 = 0x40; static constexpr RegMask REG_0x6B_GPOM12 = 0x20; static constexpr RegMask REG_0x6B_GPOM11 = 0x10; static constexpr RegMask REG_0x6B_GPO18 = 0x02; static constexpr RegMask REG_0x6B_GPO17 = 0x01; static constexpr RegShift REG_0x6C = 0x6c; static constexpr RegMask REG_0x6C_GPIO16 = 0x80; static constexpr RegMask REG_0x6C_GPIO15 = 0x40; static constexpr RegMask REG_0x6C_GPIO14 = 0x20; static constexpr RegMask REG_0x6C_GPIO13 = 0x10; static constexpr RegMask REG_0x6C_GPIO12 = 0x08; static constexpr RegMask REG_0x6C_GPIO11 = 0x04; static constexpr RegMask REG_0x6C_GPIO10 = 0x02; static constexpr RegMask REG_0x6C_GPIO9 = 0x01; static constexpr RegMask REG_0x6C_GPIOH = 0xff; static constexpr RegMask REG_0x6C_GPIOL = 0xff; static constexpr RegAddr REG_0x6D = 0x6d; static constexpr RegAddr REG_0x6E = 0x6e; static constexpr RegAddr REG_0x6F = 0x6f; static constexpr RegAddr REG_0x7E = 0x7e; static constexpr RegMask REG_0x87_LEDADD = 0x04; static constexpr RegAddr REG_0x9E = 0x9e; static constexpr RegAddr REG_0x9F = 0x9f; static constexpr RegAddr REG_0xA6 = 0xa6; static constexpr RegAddr REG_0xA7 = 0xa7; static constexpr RegAddr REG_0xA8 = 0xa8; static constexpr RegAddr REG_0xA9 = 0xa9; static constexpr RegAddr REG_0xAB = 0xab; static constexpr RegAddr REG_EXPR = 0x10; static constexpr RegAddr REG_EXPG = 0x12; static constexpr RegAddr REG_EXPB = 0x14; static constexpr RegAddr REG_EXPDMY = 0x19; static constexpr RegAddr REG_STEPNO = 0x21; static constexpr RegAddr REG_FWDSTEP = 0x22; static constexpr RegAddr REG_BWDSTEP = 0x23; static constexpr RegAddr REG_FASTNO = 0x24; static constexpr RegAddr REG_DPISET = 0x2c; static constexpr RegAddr REG_STRPIXEL = 0x30; static constexpr RegAddr REG_ENDPIXEL = 0x32; static constexpr RegAddr REG_LINCNT = 0x25; static constexpr RegAddr REG_MAXWD = 0x35; static constexpr RegAddr REG_LPERIOD = 0x38; static constexpr RegAddr REG_FEEDL = 0x3d; static constexpr RegAddr REG_FMOVDEC = 0x5f; static constexpr RegAddr REG_FSHDEC = 0x69; static constexpr RegAddr REG_FMOVNO = 0x6a; static constexpr RegAddr REG_CK1MAP = 0x74; static constexpr RegAddr REG_CK3MAP = 0x77; static constexpr RegAddr REG_CK4MAP = 0x7a; } // namespace gl847 } // namespace genesys #endif // BACKEND_GENESYS_GL847_REGISTERS_H sane-backends-1.0.29/backend/genesys/tables_motor.cpp0000666000000000000000000002662013615534521017451 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "low.h" namespace genesys { StaticInit> s_motors; void genesys_init_motor_tables() { s_motors.init(); Genesys_Motor motor; motor.id = MotorId::UMAX; motor.base_ydpi = 1200; motor.optical_ydpi = 2400; motor.slopes.push_back(MotorSlope::create_from_steps(11000, 3000, 128)); motor.slopes.push_back(MotorSlope::create_from_steps(11000, 3000, 128)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::MD_5345; // MD5345/6228/6471 motor.base_ydpi = 1200; motor.optical_ydpi = 2400; motor.slopes.push_back(MotorSlope::create_from_steps(2000, 1375, 128)); motor.slopes.push_back(MotorSlope::create_from_steps(2000, 1375, 128)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::ST24; motor.base_ydpi = 2400; motor.optical_ydpi = 2400; motor.slopes.push_back(MotorSlope::create_from_steps(2289, 2100, 128)); motor.slopes.push_back(MotorSlope::create_from_steps(2289, 2100, 128)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::HP3670; motor.base_ydpi = 1200; motor.optical_ydpi = 1200; motor.slopes.push_back(MotorSlope::create_from_steps(11000, 3000, 128)); motor.slopes.push_back(MotorSlope::create_from_steps(11000, 3000, 128)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::HP2400; motor.base_ydpi = 1200; motor.optical_ydpi = 1200; motor.slopes.push_back(MotorSlope::create_from_steps(11000, 3000, 128)); motor.slopes.push_back(MotorSlope::create_from_steps(11000, 3000, 128)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::HP2300; motor.base_ydpi = 600; motor.optical_ydpi = 1200; motor.slopes.push_back(MotorSlope::create_from_steps(3200, 1200, 128)); motor.slopes.push_back(MotorSlope::create_from_steps(3200, 1200, 128)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_LIDE_35; motor.base_ydpi = 1200; motor.optical_ydpi = 2400; motor.slopes.push_back(MotorSlope::create_from_steps(3500, 1300, 60)); motor.slopes.push_back(MotorSlope::create_from_steps(3500, 1400, 60)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::XP200; motor.base_ydpi = 600; motor.optical_ydpi = 600; motor.slopes.push_back(MotorSlope::create_from_steps(3500, 1300, 60)); motor.slopes.push_back(MotorSlope::create_from_steps(3500, 1300, 60)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::XP300; motor.base_ydpi = 300; motor.optical_ydpi = 600; // works best with GPIO10, GPIO14 off motor.slopes.push_back(MotorSlope::create_from_steps(3700, 3700, 2)); motor.slopes.push_back(MotorSlope::create_from_steps(11000, 11000, 2)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::DP665; motor.base_ydpi = 750; motor.optical_ydpi = 1500; motor.slopes.push_back(MotorSlope::create_from_steps(3000, 2500, 10)); motor.slopes.push_back(MotorSlope::create_from_steps(11000, 11000, 2)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::ROADWARRIOR; motor.base_ydpi = 750; motor.optical_ydpi = 1500; motor.slopes.push_back(MotorSlope::create_from_steps(3000, 2600, 10)); motor.slopes.push_back(MotorSlope::create_from_steps(11000, 11000, 2)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::DSMOBILE_600; motor.base_ydpi = 750; motor.optical_ydpi = 1500; motor.slopes.push_back(MotorSlope::create_from_steps(6666, 3700, 8)); motor.slopes.push_back(MotorSlope::create_from_steps(6666, 3700, 8)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_LIDE_100; motor.base_ydpi = 1200; motor.optical_ydpi = 6400; motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1000, 127)); motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1500, 127)); motor.slopes.push_back(MotorSlope::create_from_steps(3 * 2712, 3 * 2712, 16)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_LIDE_200; motor.base_ydpi = 1200; motor.optical_ydpi = 6400; motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1000, 127)); motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1500, 127)); motor.slopes.push_back(MotorSlope::create_from_steps(3 * 2712, 3 * 2712, 16)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_LIDE_700; motor.base_ydpi = 1200; motor.optical_ydpi = 6400; motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1000, 127)); motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1500, 127)); motor.slopes.push_back(MotorSlope::create_from_steps(3 * 2712, 3 * 2712, 16)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::KVSS080; motor.base_ydpi = 1200; motor.optical_ydpi = 1200; motor.slopes.push_back(MotorSlope::create_from_steps(22222, 500, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(22222, 500, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(22222, 500, 246)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::G4050; motor.base_ydpi = 2400; motor.optical_ydpi = 9600; motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_4400F; motor.base_ydpi = 2400; motor.optical_ydpi = 9600; motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_8400F; motor.base_ydpi = 1600; motor.optical_ydpi = 6400; motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_8600F; motor.base_ydpi = 2400; motor.optical_ydpi = 9600; motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); motor.slopes.push_back(MotorSlope::create_from_steps(3961, 240, 246)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_LIDE_110; motor.base_ydpi = 4800; motor.optical_ydpi = 9600; motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1000, 256)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_LIDE_120; motor.base_ydpi = 4800; motor.optical_ydpi = 9600; motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1000, 256)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_LIDE_210; motor.base_ydpi = 4800; motor.optical_ydpi = 9600; motor.slopes.push_back(MotorSlope::create_from_steps(3000, 1000, 256)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::PLUSTEK_OPTICPRO_3600; motor.base_ydpi = 1200; motor.optical_ydpi = 2400; motor.slopes.push_back(MotorSlope::create_from_steps(3500, 1300, 60)); motor.slopes.push_back(MotorSlope::create_from_steps(3500, 3250, 60)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::PLUSTEK_OPTICFILM_7200I; motor.base_ydpi = 3600; motor.optical_ydpi = 3600; s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::PLUSTEK_OPTICFILM_7300; motor.base_ydpi = 3600; motor.optical_ydpi = 3600; s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::PLUSTEK_OPTICFILM_7500I; motor.base_ydpi = 3600; motor.optical_ydpi = 3600; s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::IMG101; motor.base_ydpi = 600; motor.optical_ydpi = 1200; motor.slopes.push_back(MotorSlope::create_from_steps(3500, 1300, 60)); motor.slopes.push_back(MotorSlope::create_from_steps(3500, 3250, 60)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::PLUSTEK_OPTICBOOK_3800; motor.base_ydpi = 600; motor.optical_ydpi = 1200; motor.slopes.push_back(MotorSlope::create_from_steps(3500, 1300, 60)); motor.slopes.push_back(MotorSlope::create_from_steps(3500, 3250, 60)); s_motors->push_back(std::move(motor)); motor = Genesys_Motor(); motor.id = MotorId::CANON_LIDE_80; motor.base_ydpi = 2400; motor.optical_ydpi = 4800; // 9600 motor.slopes.push_back(MotorSlope::create_from_steps(9560, 1912, 31)); s_motors->push_back(std::move(motor)); } } // namespace genesys sane-backends-1.0.29/backend/genesys/fwd.h0000666000000000000000000000631013615534521015176 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_FWD_H #define BACKEND_GENESYS_FWD_H namespace genesys { // buffer.h struct Genesys_Buffer; // calibration.h struct Genesys_Calibration_Cache; // command_set.h class CommandSet; // device.h class FixedFloat; struct Genesys_Gpo; struct MethodResolutions; struct Genesys_Model; struct Genesys_Device; // error.h class DebugMessageHelper; class SaneException; // genesys.h class GenesysButton; struct Genesys_Scanner; // image.h class Image; // image_buffer.h class ImageBuffer; class FakeBufferModel; class ImageBufferGenesysUsb; // image_pipeline.h class ImagePipelineNode; // ImagePipelineNode* skipped class ImagePipelineStack; // image_pixel.h struct Pixel; struct RawPixel; // low.h struct Genesys_USB_Device_Entry; struct Motor_Profile; // motor.h struct Genesys_Motor; struct MotorSlope; struct MotorSlopeTable; // register.h class Genesys_Register_Set; struct GenesysRegisterSetState; // row_buffer.h class RowBuffer; // usb_device.h class IUsbDevice; class UsbDevice; // scanner_interface.h class ScannerInterface; class ScannerInterfaceUsb; class TestScannerInterface; // sensor.h class ResolutionFilter; struct GenesysFrontendLayout; struct Genesys_Frontend; struct SensorExposure; struct Genesys_Sensor; // settings.h struct Genesys_Settings; struct SetupParams; struct ScanSession; // test_usb_device.h class TestUsbDevice; } // namespace genesys #endif sane-backends-1.0.29/backend/genesys/tables_motor_profile.cpp0000666000000000000000000003271713615534521021175 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "low.h" namespace genesys { StaticInit> gl843_motor_profiles; void genesys_init_motor_profile_tables_gl843() { gl843_motor_profiles.init(); auto profile = Motor_Profile(); profile.motor_id = MotorId::KVSS080; profile.exposure = 8000; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(44444, 500, 489); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::G4050; profile.exposure = 8016; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(7842, 320, 602); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::G4050; profile.exposure = 15624; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(9422, 254, 1004); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::G4050; profile.exposure = 42752; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(42752, 1706, 610); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::G4050; profile.exposure = 56064; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(28032, 2238, 604); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_4400F; profile.exposure = 11640; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(49152, 484, 1014); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_8400F; profile.exposure = 50000; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(8743, 300, 794); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_8600F; profile.exposure = 0x59d8; profile.step_type = StepType::QUARTER; // FIXME: if the exposure is lower then we'll select another motor profile.slope = MotorSlope::create_from_steps(54612, 1500, 219); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::PLUSTEK_OPTICFILM_7200I; profile.exposure = 0; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(39682, 1191, 15); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::PLUSTEK_OPTICFILM_7300; profile.exposure = 0x2f44; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(31250, 1512, 6); gl843_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::PLUSTEK_OPTICFILM_7500I; profile.exposure = 0; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(31250, 1375, 7); gl843_motor_profiles->push_back(profile); } StaticInit> gl846_motor_profiles; void genesys_init_motor_profile_tables_gl846() { gl846_motor_profiles.init(); auto profile = Motor_Profile(); profile.motor_id = MotorId::IMG101; profile.exposure = 11000; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(22000, 1000, 1017); gl846_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::PLUSTEK_OPTICBOOK_3800; profile.exposure = 11000; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(22000, 1000, 1017); gl846_motor_profiles->push_back(profile); } /** * database of motor profiles */ StaticInit> gl847_motor_profiles; void genesys_init_motor_profile_tables_gl847() { gl847_motor_profiles.init(); auto profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_100; profile.exposure = 2848; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_100; profile.exposure = 1424; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_100; profile.exposure = 1432; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_100; profile.exposure = 2712; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(46876, 534, 279); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_100; profile.exposure = 5280; profile.step_type = StepType::EIGHTH; profile.slope = MotorSlope::create_from_steps(31680, 534, 247); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_200; profile.exposure = 2848; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_200; profile.exposure = 1424; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_200; profile.exposure = 1432; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_200; profile.exposure = 2712; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(46876, 534, 279); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_200; profile.exposure = 5280; profile.step_type = StepType::EIGHTH; profile.slope = MotorSlope::create_from_steps(31680, 534, 247); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_200; profile.exposure = 10416; profile.step_type = StepType::EIGHTH; profile.slope = MotorSlope::create_from_steps(31680, 534, 247); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_700; profile.exposure = 2848; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_700; profile.exposure = 1424; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_700; profile.exposure = 1504; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 534, 255); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_700; profile.exposure = 2696; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(46876, 2022, 127); gl847_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_700; profile.exposure = 10576; profile.step_type = StepType::EIGHTH; profile.slope = MotorSlope::create_from_steps(46876, 15864, 2); gl847_motor_profiles->push_back(profile); } StaticInit> gl124_motor_profiles; void genesys_init_motor_profile_tables_gl124() { gl124_motor_profiles.init(); // NEXT LPERIOD=PREVIOUS*2-192 Motor_Profile profile; profile.motor_id = MotorId::CANON_LIDE_110; profile.exposure = 2768; profile.step_type = StepType::FULL; profile.slope = MotorSlope::create_from_steps(62496, 335, 255); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_110; profile.exposure = 5360; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(62496, 335, 469); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_110; profile.exposure = 10528; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(62496, 2632, 3); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_110; profile.exposure = 20864; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(62496, 10432, 3); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_120; profile.exposure = 4608; profile.step_type = StepType::FULL; profile.slope = MotorSlope::create_from_steps(62496, 864, 127); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_120; profile.exposure = 5360; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(62496, 2010, 63); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_120; profile.exposure = 10528; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(62464, 2632, 3); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_120; profile.exposure = 20864; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(62592, 10432, 5); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_210; profile.exposure = 2768; profile.step_type = StepType::FULL; profile.slope = MotorSlope::create_from_steps(62496, 335, 255); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_210; profile.exposure = 5360; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(62496, 335, 469); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_210; profile.exposure = 10528; profile.step_type = StepType::HALF; profile.slope = MotorSlope::create_from_steps(62496, 2632, 3); gl124_motor_profiles->push_back(profile); profile = Motor_Profile(); profile.motor_id = MotorId::CANON_LIDE_210; profile.exposure = 20864; profile.step_type = StepType::QUARTER; profile.slope = MotorSlope::create_from_steps(62496, 10432, 4); gl124_motor_profiles->push_back(profile); } void genesys_init_motor_profile_tables() { genesys_init_motor_profile_tables_gl843(); genesys_init_motor_profile_tables_gl846(); genesys_init_motor_profile_tables_gl847(); genesys_init_motor_profile_tables_gl124(); } } // namespace genesys sane-backends-1.0.29/backend/genesys/gl646.h0000666000000000000000000005174613615534521015275 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2003-2004 Henning Meier-Geinitz Copyright (C) 2004-2005 Gerhard Jaeger Copyright (C) 2004-2013 Stéphane Voltz Copyright (C) 2005-2009 Pierre Willenbrock 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL646_H #define BACKEND_GENESYS_GL646_H #include "genesys.h" #include "command_set.h" #include "motor.h" namespace genesys { namespace gl646 { static void gl646_set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set, int dpi); /** * sets up the scanner for a scan, registers, gamma tables, shading tables * and slope tables, based on the parameter struct. * @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 * compute Y, ie add top margins */ static void setup_for_scan(Genesys_Device* device, const Genesys_Sensor& sensor, Genesys_Register_Set*regs, Genesys_Settings settings, bool split, bool xcorrection, bool ycorrection, bool reverse); /** * Does a simple move of the given distance by doing a scan at lowest resolution * shading correction. Memory for data is allocated in this function * and must be freed by caller. * @param dev device of the scanner * @param distance distance to move in MM */ static void simple_move(Genesys_Device* dev, SANE_Int distance); /** * Does a simple scan of the area given by the settings. Scanned data * it put in an allocated area which must be freed by the caller. * and slope tables, based on the parameter struct. There is no shading * correction while gamma correction is active. * @param dev device to set up * @param settings settings of the scan * @param move flag to enable scanhead to move * @param forward flag to tell movement direction * @param shading flag to tell if shading correction should be done * @param data pointer that will point to the scanned data */ static void simple_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Settings settings, bool move, bool forward, bool shading, std::vector& data, const char* test_identifier); /** * Send the stop scan command * */ static void end_scan_impl(Genesys_Device* dev, Genesys_Register_Set* reg, bool check_stop, bool eject); /** * writes control data to an area behind the last motor table. */ static void write_control(Genesys_Device* dev, const Genesys_Sensor& sensor, int resolution); /** * initialize scanner's registers at SANE init time */ static void gl646_init_regs (Genesys_Device * dev); /** * master motor settings table entry */ typedef struct { /* key */ MotorId motor_id; unsigned dpi; unsigned channels; /* settings */ StepType steptype; bool fastmod; // fast scanning bool fastfed; // fast fed slope tables SANE_Int mtrpwm; MotorSlope slope1; MotorSlope slope2; SANE_Int fwdbwd; /* forward/backward steps */ } Motor_Master; /** * master motor settings, for a given motor and dpi, * it gives steps and speed informations */ static Motor_Master motor_master[] = { /* HP3670 motor settings */ {MotorId::HP3670, 50, 3, StepType::HALF, false, true, 1, MotorSlope::create_from_steps(2329, 120, 229), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 75, 3, StepType::FULL, false, true, 1, MotorSlope::create_from_steps(3429, 305, 200), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 100, 3, StepType::HALF, false, true, 1, MotorSlope::create_from_steps(2905, 187, 143), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 150, 3, StepType::HALF, false, true, 1, MotorSlope::create_from_steps(3429, 305, 73), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 300, 3, StepType::HALF, false, true, 1, MotorSlope::create_from_steps(1055, 563, 11), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 600, 3, StepType::FULL, false, true, 0, MotorSlope::create_from_steps(10687, 5126, 3), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670,1200, 3, StepType::HALF, false, true, 0, MotorSlope::create_from_steps(15937, 6375, 3), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 50, 1, StepType::HALF, false, true, 1, MotorSlope::create_from_steps(2329, 120, 229), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 75, 1, StepType::FULL, false, true, 1, MotorSlope::create_from_steps(3429, 305, 200), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 100, 1, StepType::HALF, false, true, 1, MotorSlope::create_from_steps(2905, 187, 143), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 150, 1, StepType::HALF, false, true, 1, MotorSlope::create_from_steps(3429, 305, 73), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 300, 1, StepType::HALF, false, true, 1, MotorSlope::create_from_steps(1055, 563, 11), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670, 600, 1, StepType::FULL, false, true, 0, MotorSlope::create_from_steps(10687, 5126, 3), MotorSlope::create_from_steps(3399, 337, 192), 192}, {MotorId::HP3670,1200, 1, StepType::HALF, false, true, 0, MotorSlope::create_from_steps(15937, 6375, 3), MotorSlope::create_from_steps(3399, 337, 192), 192}, /* HP2400/G2410 motor settings base motor dpi = 600 */ {MotorId::HP2400, 50, 3, StepType::FULL, false, true, 63, MotorSlope::create_from_steps(8736, 601, 120), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400, 100, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(8736, 601, 120), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400, 150, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(15902, 902, 67), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400, 300, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(16703, 2188, 32), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400, 600, 3, StepType::FULL, false, true, 63, MotorSlope::create_from_steps(18761, 18761, 3), MotorSlope::create_from_steps(4905, 627, 192), 192}, {MotorId::HP2400,1200, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(43501, 43501, 3), MotorSlope::create_from_steps(4905, 627, 192), 192}, {MotorId::HP2400, 50, 1, StepType::FULL, false, true, 63, MotorSlope::create_from_steps(8736, 601, 120), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400, 100, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(8736, 601, 120), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400, 150, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(15902, 902, 67), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400, 300, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(16703, 2188, 32), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400, 600, 1, StepType::FULL, false, true, 63, MotorSlope::create_from_steps(18761, 18761, 3), MotorSlope::create_from_steps(4905, 337, 192), 192}, {MotorId::HP2400,1200, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(43501, 43501, 3), MotorSlope::create_from_steps(4905, 337, 192), 192}, /* XP 200 motor settings */ {MotorId::XP200, 75, 3, StepType::HALF, true, false, 0, MotorSlope::create_from_steps(6000, 2136, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 100, 3, StepType::HALF, true, false, 0, MotorSlope::create_from_steps(6000, 2850, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 200, 3, StepType::HALF, true, false, 0, MotorSlope::create_from_steps(6999, 5700, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 250, 3, StepType::HALF, true, false, 0, MotorSlope::create_from_steps(6999, 6999, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 300, 3, StepType::HALF, true, false, 0, MotorSlope::create_from_steps(13500, 13500, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 600, 3, StepType::HALF, true, true, 0, MotorSlope::create_from_steps(31998, 31998, 4), MotorSlope::create_from_steps(12000, 1200, 2), 1}, {MotorId::XP200, 75, 1, StepType::HALF, true, false, 0, MotorSlope::create_from_steps(6000, 2000, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 100, 1, StepType::HALF, true, false, 0, MotorSlope::create_from_steps(6000, 1300, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 200, 1, StepType::HALF, true, true, 0, MotorSlope::create_from_steps(6000, 3666, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 300, 1, StepType::HALF, true, false, 0, MotorSlope::create_from_steps(6500, 6500, 4), MotorSlope::create_from_steps(12000, 1200, 8), 1}, {MotorId::XP200, 600, 1, StepType::HALF, true, true, 0, MotorSlope::create_from_steps(24000, 24000, 4), MotorSlope::create_from_steps(12000, 1200, 2), 1}, /* HP scanjet 2300c */ {MotorId::HP2300, 75, 3, StepType::FULL, false, true, 63, MotorSlope::create_from_steps(8139, 560, 120), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300, 150, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(7903, 543, 67), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300, 300, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(2175, 1087, 3), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300, 600, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(8700, 4350, 3), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300,1200, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(17400, 8700, 3), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300, 75, 1, StepType::FULL, false, true, 63, MotorSlope::create_from_steps(8139, 560, 120), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300, 150, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(7903, 543, 67), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300, 300, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(2175, 1087, 3), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300, 600, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(8700, 4350, 3), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300,1200, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(17400, 8700, 3), MotorSlope::create_from_steps(4905, 337, 120), 16}, /* non half ccd settings for 300 dpi {MotorId::HP2300, 300, 3, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(5386, 2175, 44), MotorSlope::create_from_steps(4905, 337, 120), 16}, {MotorId::HP2300, 300, 1, StepType::HALF, false, true, 63, MotorSlope::create_from_steps(5386, 2175, 44), MotorSlope::create_from_steps(4905, 337, 120), 16}, */ /* MD5345/6471 motor settings */ /* vfinal=(exposure/(1200/dpi))/step_type */ {MotorId::MD_5345, 50, 3, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 250, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 75, 3, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 343, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 100, 3, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 458, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 150, 3, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 687, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 200, 3, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 916, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 300, 3, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 1375, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 400, 3, StepType::HALF, false, true, 0, MotorSlope::create_from_steps(2000, 1833, 32), MotorSlope::create_from_steps(2000, 300, 255), 32}, {MotorId::MD_5345, 500, 3, StepType::HALF, false, true, 0, MotorSlope::create_from_steps(2291, 2291, 32), MotorSlope::create_from_steps(2000, 300, 255), 32}, {MotorId::MD_5345, 600, 3, StepType::HALF, false, true, 0, MotorSlope::create_from_steps(2750, 2750, 32), MotorSlope::create_from_steps(2000, 300, 255), 32}, {MotorId::MD_5345, 1200, 3, StepType::QUARTER, false, true, 0, MotorSlope::create_from_steps(2750, 2750, 16), MotorSlope::create_from_steps(2000, 300, 255), 146}, {MotorId::MD_5345, 2400, 3, StepType::QUARTER, false, true, 0, MotorSlope::create_from_steps(5500, 5500, 16), MotorSlope::create_from_steps(2000, 300, 255), 146}, {MotorId::MD_5345, 50, 1, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 250, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 75, 1, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 343, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 100, 1, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 458, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 150, 1, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 687, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 200, 1, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 916, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 300, 1, StepType::HALF, false, true, 2, MotorSlope::create_from_steps(2500, 1375, 255), MotorSlope::create_from_steps(2000, 300, 255), 64}, {MotorId::MD_5345, 400, 1, StepType::HALF, false, true, 0, MotorSlope::create_from_steps(2000, 1833, 32), MotorSlope::create_from_steps(2000, 300, 255), 32}, {MotorId::MD_5345, 500, 1, StepType::HALF, false, true, 0, MotorSlope::create_from_steps(2291, 2291, 32), MotorSlope::create_from_steps(2000, 300, 255), 32}, {MotorId::MD_5345, 600, 1, StepType::HALF, false, true, 0, MotorSlope::create_from_steps(2750, 2750, 32), MotorSlope::create_from_steps(2000, 300, 255), 32}, {MotorId::MD_5345, 1200, 1, StepType::QUARTER, false, true, 0, MotorSlope::create_from_steps(2750, 2750, 16), MotorSlope::create_from_steps(2000, 300, 255), 146}, {MotorId::MD_5345, 2400, 1, StepType::QUARTER, false, true, 0, MotorSlope::create_from_steps(5500, 5500, 16), MotorSlope::create_from_steps(2000, 300, 255), 146}, /* 5500 guessed */ }; class CommandSetGl646 : public CommandSet { public: ~CommandSetGl646() override = default; bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const override; void init(Genesys_Device* dev) const override; void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const override; void init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const override; void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const override; void set_powersaving(Genesys_Device* dev, int delay) const override; void save_power(Genesys_Device* dev, bool enable) const override; void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, bool start_motor) const override; void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void search_start_position(Genesys_Device* dev) const override; void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const override; SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void wait_for_motor_stop(Genesys_Device* dev) const override; void move_back_home(Genesys_Device* dev, bool wait_until_home) const override; void update_hardware_sensors(struct Genesys_Scanner* s) const override; void load_document(Genesys_Device* dev) const override; void detect_document_end(Genesys_Device* dev) const override; void eject_document(Genesys_Device* dev) const override; void search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const override; void move_to_ta(Genesys_Device* dev) const override; void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const override; bool has_send_shading_data() const override { return false; } ScanSession calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const override; void asic_boot(Genesys_Device* dev, bool cold) const override; }; } // namespace gl646 } // namespace genesys #endif // BACKEND_GENESYS_GL646_H sane-backends-1.0.29/backend/genesys/image_pixel.h0000666000000000000000000001260213615534521016702 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_IMAGE_PIXEL_H #define BACKEND_GENESYS_IMAGE_PIXEL_H #include "enums.h" #include #include #include namespace genesys { enum class PixelFormat { UNKNOWN, I1, RGB111, I8, RGB888, BGR888, I16, RGB161616, BGR161616, }; struct Pixel { Pixel() = default; Pixel(std::uint16_t red, std::uint16_t green, std::uint16_t blue) : r{red}, g{green}, b{blue} {} std::uint16_t r = 0; std::uint16_t g = 0; std::uint16_t b = 0; bool operator==(const Pixel& other) const { return r == other.r && g == other.g && b == other.b; } }; struct RawPixel { RawPixel() = default; RawPixel(std::uint8_t d0) : data{d0, 0, 0, 0, 0, 0} {} RawPixel(std::uint8_t d0, std::uint8_t d1) : data{d0, d1, 0, 0, 0, 0} {} RawPixel(std::uint8_t d0, std::uint8_t d1, std::uint8_t d2) : data{d0, d1, d2, 0, 0, 0} {} RawPixel(std::uint8_t d0, std::uint8_t d1, std::uint8_t d2, std::uint8_t d3, std::uint8_t d4, std::uint8_t d5) : data{d0, d1, d2, d3, d4, d5} {} std::uint8_t data[6] = {}; bool operator==(const RawPixel& other) const { return std::equal(std::begin(data), std::end(data), std::begin(other.data)); } }; ColorOrder get_pixel_format_color_order(PixelFormat format); unsigned get_pixel_format_depth(PixelFormat format); unsigned get_pixel_channels(PixelFormat format); std::size_t get_pixel_row_bytes(PixelFormat format, std::size_t width); std::size_t get_pixels_from_row_bytes(PixelFormat format, std::size_t row_bytes); PixelFormat create_pixel_format(unsigned depth, unsigned channels, ColorOrder order); // retrieves or sets the logical pixel values in 16-bit range. Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x, PixelFormat format); void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel, PixelFormat format); // retrieves or sets the physical pixel values. The low bytes of the RawPixel are interpreted as // the retrieved values / values to set RawPixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x, PixelFormat format); void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel, PixelFormat format); // retrieves or sets the physical value of specific channel of the pixel. The channels are numbered // in the same order as the pixel is laid out in memory, that is, whichever channel comes first // has the index 0. E.g. 0-th channel in RGB888 is the red byte, but in BGR888 is the blue byte. std::uint16_t get_raw_channel_from_row(const std::uint8_t* data, std::size_t x, unsigned channel, PixelFormat format); void set_raw_channel_to_row(std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel, PixelFormat format); template Pixel get_pixel_from_row(const std::uint8_t* data, std::size_t x); template void set_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template Pixel get_raw_pixel_from_row(const std::uint8_t* data, std::size_t x); template void set_raw_pixel_to_row(std::uint8_t* data, std::size_t x, RawPixel pixel); template std::uint16_t get_raw_channel_from_row(const std::uint8_t* data, std::size_t x, unsigned channel); template void set_raw_channel_to_row(std::uint8_t* data, std::size_t x, unsigned channel, std::uint16_t pixel); } // namespace genesys #endif // BACKEND_GENESYS_IMAGE_PIXEL_H sane-backends-1.0.29/backend/genesys/gl846_registers.h0000666000000000000000000003323513615534521017357 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL846_REGISTERS_H #define BACKEND_GENESYS_GL846_REGISTERS_H #include namespace genesys { namespace gl846 { using RegAddr = std::uint16_t; using RegMask = std::uint8_t; using RegShift = unsigned; static constexpr RegAddr REG_0x01 = 0x01; static constexpr RegMask REG_0x01_CISSET = 0x80; static constexpr RegMask REG_0x01_DOGENB = 0x40; static constexpr RegMask REG_0x01_DVDSET = 0x20; static constexpr RegMask REG_0x01_STAGGER = 0x10; static constexpr RegMask REG_0x01_COMPENB = 0x08; static constexpr RegMask REG_0x01_TRUEGRAY = 0x04; static constexpr RegMask REG_0x01_SHDAREA = 0x02; static constexpr RegMask REG_0x01_SCAN = 0x01; static constexpr RegAddr REG_0x02 = 0x02; static constexpr RegMask REG_0x02_NOTHOME = 0x80; static constexpr RegMask REG_0x02_ACDCDIS = 0x40; static constexpr RegMask REG_0x02_AGOHOME = 0x20; static constexpr RegMask REG_0x02_MTRPWR = 0x10; static constexpr RegMask REG_0x02_FASTFED = 0x08; static constexpr RegMask REG_0x02_MTRREV = 0x04; static constexpr RegMask REG_0x02_HOMENEG = 0x02; static constexpr RegMask REG_0x02_LONGCURV = 0x01; static constexpr RegAddr REG_0x03 = 0x03; static constexpr RegMask REG_0x03_LAMPDOG = 0x80; static constexpr RegMask REG_0x03_AVEENB = 0x40; static constexpr RegMask REG_0x03_XPASEL = 0x20; static constexpr RegMask REG_0x03_LAMPPWR = 0x10; static constexpr RegMask REG_0x03_LAMPTIM = 0x0f; static constexpr RegAddr REG_0x04 = 0x04; static constexpr RegMask REG_0x04_LINEART = 0x80; static constexpr RegMask REG_0x04_BITSET = 0x40; static constexpr RegMask REG_0x04_AFEMOD = 0x30; static constexpr RegMask REG_0x04_FILTER = 0x0c; static constexpr RegMask REG_0x04_FESET = 0x03; static constexpr RegShift REG_0x04S_AFEMOD = 4; static constexpr RegAddr REG_0x05 = 0x05; static constexpr RegMask REG_0x05_DPIHW = 0xc0; static constexpr RegMask REG_0x05_DPIHW_600 = 0x00; static constexpr RegMask REG_0x05_DPIHW_1200 = 0x40; static constexpr RegMask REG_0x05_DPIHW_2400 = 0x80; static constexpr RegMask REG_0x05_DPIHW_4800 = 0xc0; static constexpr RegMask REG_0x05_MTLLAMP = 0x30; static constexpr RegMask REG_0x05_GMMENB = 0x08; static constexpr RegMask REG_0x05_MTLBASE = 0x03; static constexpr RegAddr REG_0x06 = 0x06; static constexpr RegMask REG_0x06_SCANMOD = 0xe0; static constexpr RegShift REG_0x06S_SCANMOD = 5; static constexpr RegMask REG_0x06_PWRBIT = 0x10; static constexpr RegMask REG_0x06_GAIN4 = 0x08; static constexpr RegMask REG_0x06_OPTEST = 0x07; static constexpr RegMask REG_0x07_LAMPSIM = 0x80; static constexpr RegMask REG_0x08_DRAM2X = 0x80; static constexpr RegMask REG_0x08_MPENB = 0x20; static constexpr RegMask REG_0x08_CIS_LINE = 0x10; static constexpr RegMask REG_0x08_IR1ENB = 0x08; static constexpr RegMask REG_0x08_IR2ENB = 0x04; static constexpr RegMask REG_0x08_ENB24M = 0x01; static constexpr RegMask REG_0x09_MCNTSET = 0xc0; static constexpr RegMask REG_0x09_EVEN1ST = 0x20; static constexpr RegMask REG_0x09_BLINE1ST = 0x10; static constexpr RegMask REG_0x09_BACKSCAN = 0x08; static constexpr RegMask REG_0x09_ENHANCE = 0x04; static constexpr RegMask REG_0x09_SHORTTG = 0x02; static constexpr RegMask REG_0x09_NWAIT = 0x01; static constexpr RegShift REG_0x09S_MCNTSET = 6; static constexpr RegShift REG_0x09S_CLKSET = 4; static constexpr RegAddr REG_0x0A_LPWMEN = 0x10; static constexpr RegAddr REG_0x0B = 0x0b; static constexpr RegMask REG_0x0B_DRAMSEL = 0x07; static constexpr RegMask REG_0x0B_ENBDRAM = 0x08; static constexpr RegMask REG_0x0B_RFHDIS = 0x10; static constexpr RegMask REG_0x0B_CLKSET = 0xe0; static constexpr RegMask REG_0x0B_24MHZ = 0x00; static constexpr RegMask REG_0x0B_30MHZ = 0x20; static constexpr RegMask REG_0x0B_40MHZ = 0x40; static constexpr RegMask REG_0x0B_48MHZ = 0x60; static constexpr RegMask REG_0x0B_60MHZ = 0x80; static constexpr RegAddr REG_0x0C = 0x0c; static constexpr RegMask REG_0x0C_CCDLMT = 0x0f; static constexpr RegAddr REG_0x0D = 0x0d; static constexpr RegMask REG_0x0D_SCSYNC = 0x40; static constexpr RegMask REG_0x0D_CLRERR = 0x20; static constexpr RegMask REG_0x0D_FULLSTP = 0x10; static constexpr RegMask REG_0x0D_SEND = 0x80; static constexpr RegMask REG_0x0D_CLRMCNT = 0x04; static constexpr RegMask REG_0x0D_CLRDOCJM = 0x02; static constexpr RegMask REG_0x0D_CLRLNCNT = 0x01; static constexpr RegAddr REG_0x0F = 0x0f; static constexpr RegMask REG_0x16_CTRLHI = 0x80; static constexpr RegMask REG_0x16_TOSHIBA = 0x40; static constexpr RegMask REG_0x16_TGINV = 0x20; static constexpr RegMask REG_0x16_CK1INV = 0x10; static constexpr RegMask REG_0x16_CK2INV = 0x08; static constexpr RegMask REG_0x16_CTRLINV = 0x04; static constexpr RegMask REG_0x16_CKDIS = 0x02; static constexpr RegMask REG_0x16_CTRLDIS = 0x01; static constexpr RegMask REG_0x17_TGMODE = 0xc0; static constexpr RegMask REG_0x17_TGMODE_NO_DUMMY = 0x00; static constexpr RegMask REG_0x17_TGMODE_REF = 0x40; static constexpr RegMask REG_0x17_TGMODE_XPA = 0x80; static constexpr RegMask REG_0x17_TGW = 0x3f; static constexpr RegAddr REG_0x17S_TGW = 0; static constexpr RegAddr REG_0x18 = 0x18; static constexpr RegMask REG_0x18_CNSET = 0x80; static constexpr RegMask REG_0x18_DCKSEL = 0x60; static constexpr RegMask REG_0x18_CKTOGGLE = 0x10; static constexpr RegMask REG_0x18_CKDELAY = 0x0c; static constexpr RegMask REG_0x18_CKSEL = 0x03; static constexpr RegMask REG_0x1A_SW2SET = 0x80; static constexpr RegMask REG_0x1A_SW1SET = 0x40; static constexpr RegMask REG_0x1A_MANUAL3 = 0x02; static constexpr RegMask REG_0x1A_MANUAL1 = 0x01; static constexpr RegMask REG_0x1A_CK4INV = 0x08; static constexpr RegMask REG_0x1A_CK3INV = 0x04; static constexpr RegMask REG_0x1A_LINECLP = 0x02; static constexpr RegAddr REG_0x1C = 0x1c; static constexpr RegMask REG_0x1C_TGTIME = 0x07; static constexpr RegMask REG_0x1D_CK4LOW = 0x80; static constexpr RegMask REG_0x1D_CK3LOW = 0x40; static constexpr RegMask REG_0x1D_CK1LOW = 0x20; static constexpr RegMask REG_0x1D_TGSHLD = 0x1f; static constexpr RegShift REG_0x1DS_TGSHLD = 0; static constexpr RegMask REG_0x1E_WDTIME = 0xf0; static constexpr RegShift REG_0x1ES_WDTIME = 4; static constexpr RegMask REG_0x1E_LINESEL = 0x0f; static constexpr RegShift REG_0x1ES_LINESEL = 0; static constexpr RegAddr REG_FEDCNT = 0x1f; static constexpr RegAddr REG_0x24 = 0x1c; static constexpr RegAddr REG_0x40 = 0x40; static constexpr RegMask REG_0x40_DOCSNR = 0x80; static constexpr RegMask REG_0x40_ADFSNR = 0x40; static constexpr RegMask REG_0x40_COVERSNR = 0x20; static constexpr RegMask REG_0x40_CHKVER = 0x10; static constexpr RegMask REG_0x40_DOCJAM = 0x08; static constexpr RegMask REG_0x40_HISPDFLG = 0x04; static constexpr RegMask REG_0x40_MOTMFLG = 0x02; static constexpr RegMask REG_0x40_DATAENB = 0x01; static constexpr RegMask REG_0x41_PWRBIT = 0x80; static constexpr RegMask REG_0x41_BUFEMPTY = 0x40; static constexpr RegMask REG_0x41_FEEDFSH = 0x20; static constexpr RegMask REG_0x41_SCANFSH = 0x10; static constexpr RegMask REG_0x41_HOMESNR = 0x08; static constexpr RegMask REG_0x41_LAMPSTS = 0x04; static constexpr RegMask REG_0x41_FEBUSY = 0x02; static constexpr RegMask REG_0x41_MOTORENB = 0x01; static constexpr RegMask REG_0x58_VSMP = 0xf8; static constexpr RegShift REG_0x58S_VSMP = 3; static constexpr RegMask REG_0x58_VSMPW = 0x07; static constexpr RegAddr REG_0x58S_VSMPW = 0; static constexpr RegMask REG_0x59_BSMP = 0xf8; static constexpr RegAddr REG_0x59S_BSMP = 3; static constexpr RegMask REG_0x59_BSMPW = 0x07; static constexpr RegShift REG_0x59S_BSMPW = 0; static constexpr RegMask REG_0x5A_ADCLKINV = 0x80; static constexpr RegMask REG_0x5A_RLCSEL = 0x40; static constexpr RegMask REG_0x5A_CDSREF = 0x30; static constexpr RegShift REG_0x5AS_CDSREF = 4; static constexpr RegMask REG_0x5A_RLC = 0x0f; static constexpr RegShift REG_0x5AS_RLC = 0; static constexpr RegMask REG_0x5E_DECSEL = 0xe0; static constexpr RegShift REG_0x5ES_DECSEL = 5; static constexpr RegMask REG_0x5E_STOPTIM = 0x1f; static constexpr RegShift REG_0x5ES_STOPTIM = 0; static constexpr RegAddr REG_0x60 = 0x60; static constexpr RegMask REG_0x60_Z1MOD = 0x1f; static constexpr RegAddr REG_0x61 = 0x61; static constexpr RegMask REG_0x61_Z1MOD = 0xff; static constexpr RegAddr REG_0x62 = 0x62; static constexpr RegMask REG_0x62_Z1MOD = 0xff; static constexpr RegAddr REG_0x63 = 0x63; static constexpr RegMask REG_0x63_Z2MOD = 0x1f; static constexpr RegAddr REG_0x64 = 0x64; static constexpr RegMask REG_0x64_Z2MOD = 0xff; static constexpr RegAddr REG_0x65 = 0x65; static constexpr RegMask REG_0x65_Z2MOD = 0xff; static constexpr RegShift REG_0x60S_STEPSEL = 5; static constexpr RegMask REG_0x60_STEPSEL = 0xe0; static constexpr RegMask REG_0x60_FULLSTEP = 0x00; static constexpr RegMask REG_0x60_HALFSTEP = 0x20; static constexpr RegMask REG_0x60_EIGHTHSTEP = 0x60; static constexpr RegMask REG_0x60_16THSTEP = 0x80; static constexpr RegShift REG_0x63S_FSTPSEL = 5; static constexpr RegMask REG_0x63_FSTPSEL = 0xe0; static constexpr RegMask REG_0x63_FULLSTEP = 0x00; static constexpr RegMask REG_0x63_HALFSTEP = 0x20; static constexpr RegMask REG_0x63_EIGHTHSTEP = 0x60; static constexpr RegMask REG_0x63_16THSTEP = 0x80; static constexpr RegAddr REG_0x67 = 0x67; static constexpr RegMask REG_0x67_MTRPWM = 0x80; static constexpr RegAddr REG_0x68 = 0x68; static constexpr RegMask REG_0x68_FASTPWM = 0x80; static constexpr RegAddr REG_0x6B = 0x6b; static constexpr RegMask REG_0x6B_MULTFILM = 0x80; static constexpr RegMask REG_0x6B_GPOM13 = 0x40; static constexpr RegMask REG_0x6B_GPOM12 = 0x20; static constexpr RegMask REG_0x6B_GPOM11 = 0x10; static constexpr RegMask REG_0x6B_GPO18 = 0x02; static constexpr RegMask REG_0x6B_GPO17 = 0x01; static constexpr RegAddr REG_0x6C = 0x6c; static constexpr RegMask REG_0x6C_GPIO16 = 0x80; static constexpr RegMask REG_0x6C_GPIO15 = 0x40; static constexpr RegMask REG_0x6C_GPIO14 = 0x20; static constexpr RegMask REG_0x6C_GPIO13 = 0x10; static constexpr RegMask REG_0x6C_GPIO12 = 0x08; static constexpr RegMask REG_0x6C_GPIO11 = 0x04; static constexpr RegMask REG_0x6C_GPIO10 = 0x02; static constexpr RegMask REG_0x6C_GPIO9 = 0x01; static constexpr RegMask REG_0x6C_GPIOH = 0xff; static constexpr RegMask REG_0x6C_GPIOL = 0xff; static constexpr RegAddr REG_0x6D = 0x6d; static constexpr RegAddr REG_0x6E = 0x6e; static constexpr RegAddr REG_0x6F = 0x6f; static constexpr RegAddr REG_0x7E = 0x7e; static constexpr RegMask REG_0x87_ACYCNRLC = 0x10; static constexpr RegMask REG_0x87_ENOFFSET = 0x08; static constexpr RegMask REG_0x87_LEDADD = 0x04; static constexpr RegMask REG_0x87_CK4ADC = 0x02; static constexpr RegMask REG_0x87_AUTOCONF = 0x01; static constexpr RegAddr REG_0x9E = 0x9e; static constexpr RegAddr REG_0x9F = 0x9f; static constexpr RegAddr REG_0xA6 = 0xa6; static constexpr RegAddr REG_0xA7 = 0xa7; static constexpr RegAddr REG_0xA8 = 0xa8; static constexpr RegAddr REG_0xA9 = 0xa9; static constexpr RegAddr REG_0xAB = 0xab; static constexpr RegAddr REG_EXPR = 0x10; static constexpr RegAddr REG_EXPG = 0x12; static constexpr RegAddr REG_EXPB = 0x14; static constexpr RegAddr REG_EXPDMY = 0x19; static constexpr RegAddr REG_STEPNO = 0x21; static constexpr RegAddr REG_FWDSTEP = 0x22; static constexpr RegAddr REG_BWDSTEP = 0x23; static constexpr RegAddr REG_FASTNO = 0x24; static constexpr RegAddr REG_DPISET = 0x2c; static constexpr RegAddr REG_STRPIXEL = 0x30; static constexpr RegAddr REG_ENDPIXEL = 0x32; static constexpr RegAddr REG_LINCNT = 0x25; static constexpr RegAddr REG_MAXWD = 0x35; static constexpr RegAddr REG_LPERIOD = 0x38; static constexpr RegAddr REG_FEEDL = 0x3d; static constexpr RegAddr REG_FMOVDEC = 0x5f; static constexpr RegAddr REG_FSHDEC = 0x69; static constexpr RegAddr REG_FMOVNO = 0x6a; static constexpr RegAddr REG_CK1MAP = 0x74; static constexpr RegAddr REG_CK3MAP = 0x77; static constexpr RegAddr REG_CK4MAP = 0x7a; static constexpr RegAddr REG_0xF8 = 0xf8; static constexpr RegMask REG_0xF8_MAXSEL = 0xf0; static constexpr RegShift REG_0xF8_SMAXSEL = 4; static constexpr RegMask REG_0xF8_MINSEL = 0x0f; } // namespace gl846 } // namespace genesys #endif // BACKEND_GENESYS_GL846_REGISTERS_H sane-backends-1.0.29/backend/genesys/image.cpp0000666000000000000000000001570113615534521016037 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "image.h" #include namespace genesys { Image::Image() = default; Image::Image(std::size_t width, std::size_t height, PixelFormat format) : width_{width}, height_{height}, format_{format}, row_bytes_{get_pixel_row_bytes(format_, width_)} { data_.resize(get_row_bytes() * height); } std::uint8_t* Image::get_row_ptr(std::size_t y) { return data_.data() + row_bytes_ * y; } const std::uint8_t* Image::get_row_ptr(std::size_t y) const { return data_.data() + row_bytes_ * y; } Pixel Image::get_pixel(std::size_t x, std::size_t y) const { return get_pixel_from_row(get_row_ptr(y), x, format_); } void Image::set_pixel(std::size_t x, std::size_t y, const Pixel& pixel) { set_pixel_to_row(get_row_ptr(y), x, pixel, format_); } RawPixel Image::get_raw_pixel(std::size_t x, std::size_t y) const { return get_raw_pixel_from_row(get_row_ptr(y), x, format_); } std::uint16_t Image::get_raw_channel(std::size_t x, std::size_t y, unsigned channel) const { return get_raw_channel_from_row(get_row_ptr(y), x, channel, format_); } void Image::set_raw_pixel(std::size_t x, std::size_t y, const RawPixel& pixel) { set_raw_pixel_to_row(get_row_ptr(y), x, pixel, format_); } void Image::resize(std::size_t width, std::size_t height, PixelFormat format) { width_ = width; height_ = height; format_ = format; row_bytes_ = get_pixel_row_bytes(format_, width_); data_.resize(get_row_bytes() * height); } template void convert_pixel_row_impl2(const std::uint8_t* in_data, std::uint8_t* out_data, std::size_t count) { for (std::size_t i = 0; i < count; ++i) { Pixel pixel = get_pixel_from_row(in_data, i, SrcFormat); set_pixel_to_row(out_data, i, pixel, DstFormat); } } template void convert_pixel_row_impl(const std::uint8_t* in_data, std::uint8_t* out_data, PixelFormat out_format, std::size_t count) { switch (out_format) { case PixelFormat::I1: { convert_pixel_row_impl2(in_data, out_data, count); return; } case PixelFormat::RGB111: { convert_pixel_row_impl2(in_data, out_data, count); return; } case PixelFormat::I8: { convert_pixel_row_impl2(in_data, out_data, count); return; } case PixelFormat::RGB888: { convert_pixel_row_impl2(in_data, out_data, count); return; } case PixelFormat::BGR888: { convert_pixel_row_impl2(in_data, out_data, count); return; } case PixelFormat::I16: { convert_pixel_row_impl2(in_data, out_data, count); return; } case PixelFormat::RGB161616: { convert_pixel_row_impl2(in_data, out_data, count); return; } case PixelFormat::BGR161616: { convert_pixel_row_impl2(in_data, out_data, count); return; } default: throw SaneException("Unknown pixel format %d", static_cast(out_format)); } } void convert_pixel_row_format(const std::uint8_t* in_data, PixelFormat in_format, std::uint8_t* out_data, PixelFormat out_format, std::size_t count) { if (in_format == out_format) { std::memcpy(out_data, in_data, get_pixel_row_bytes(in_format, count)); return; } switch (in_format) { case PixelFormat::I1: { convert_pixel_row_impl(in_data, out_data, out_format, count); return; } case PixelFormat::RGB111: { convert_pixel_row_impl(in_data, out_data, out_format, count); return; } case PixelFormat::I8: { convert_pixel_row_impl(in_data, out_data, out_format, count); return; } case PixelFormat::RGB888: { convert_pixel_row_impl(in_data, out_data, out_format, count); return; } case PixelFormat::BGR888: { convert_pixel_row_impl(in_data, out_data, out_format, count); return; } case PixelFormat::I16: { convert_pixel_row_impl(in_data, out_data, out_format, count); return; } case PixelFormat::RGB161616: { convert_pixel_row_impl(in_data, out_data, out_format, count); return; } case PixelFormat::BGR161616: { convert_pixel_row_impl(in_data, out_data, out_format, count); return; } default: throw SaneException("Unknown pixel format %d", static_cast(in_format)); } } } // namespace genesys sane-backends-1.0.29/backend/genesys/status.h0000666000000000000000000000456713615534521015755 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_STATUS_H #define BACKEND_GENESYS_STATUS_H #include namespace genesys { /// Represents the scanner status register struct Status { bool is_replugged = false; bool is_buffer_empty = false; bool is_feeding_finished = false; bool is_scanning_finished = false; bool is_at_home = false; bool is_lamp_on = false; bool is_front_end_busy = false; bool is_motor_enabled = false; }; std::ostream& operator<<(std::ostream& out, Status status); } // namespace genesys #endif // BACKEND_GENESYS_STATUS_H sane-backends-1.0.29/backend/genesys/test_scanner_interface.h0000666000000000000000000001067313615534521021135 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_TEST_SCANNER_INTERFACE_H #define BACKEND_GENESYS_TEST_SCANNER_INTERFACE_H #include "scanner_interface.h" #include "register_cache.h" #include "test_usb_device.h" #include "test_settings.h" #include namespace genesys { class TestScannerInterface : public ScannerInterface { public: TestScannerInterface(Genesys_Device* dev); ~TestScannerInterface() override; bool is_mock() const override; const RegisterCache& cached_regs() const { return cached_regs_; } const RegisterCache& cached_fe_regs() const { return cached_fe_regs_; } std::uint8_t read_register(std::uint16_t address) override; void write_register(std::uint16_t address, std::uint8_t value) override; void write_registers(const Genesys_Register_Set& regs) override; void write_0x8c(std::uint8_t index, std::uint8_t value) override; void bulk_read_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) override; void bulk_write_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) override; void write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags) override; void write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, std::size_t size, Flags flags) override; void write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) override; std::uint16_t read_fe_register(std::uint8_t address) override; void write_fe_register(std::uint8_t address, std::uint16_t value) override; IUsbDevice& get_usb_device() override; void sleep_us(unsigned microseconds) override; void record_progress_message(const char* msg) override; const std::string& last_progress_message() const; void record_slope_table(unsigned table_nr, const std::vector& steps) override; std::map>& recorded_slope_tables(); void record_key_value(const std::string& key, const std::string& value) override; std::map& recorded_key_values(); void test_checkpoint(const std::string& name) override; void set_checkpoint_callback(TestCheckpointCallback callback); private: Genesys_Device* dev_; RegisterCache cached_regs_; RegisterCache cached_fe_regs_; TestUsbDevice usb_dev_; TestCheckpointCallback checkpoint_callback_; std::map> slope_tables_; std::string last_progress_message_; std::map key_values_; }; } // namespace genesys #endif sane-backends-1.0.29/backend/genesys/gl847.h0000666000000000000000000001544113615534521015270 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2010-2013 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_GL847_H #define BACKEND_GENESYS_GL847_H #include "genesys.h" #include "command_set.h" namespace genesys { namespace gl847 { typedef struct { GpioId gpio_id; uint8_t r6b; uint8_t r6c; uint8_t r6d; uint8_t r6e; uint8_t r6f; uint8_t ra6; uint8_t ra7; uint8_t ra8; uint8_t ra9; } Gpio_Profile; static Gpio_Profile gpios[]={ { GpioId::CANON_LIDE_200, 0x02, 0xf9, 0x20, 0xff, 0x00, 0x04, 0x04, 0x00, 0x00}, { GpioId::CANON_LIDE_700F, 0x06, 0xdb, 0xff, 0xff, 0x80, 0x15, 0x07, 0x20, 0x10}, { GpioId::UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, }; typedef struct { uint8_t dramsel; uint8_t rd0; uint8_t rd1; uint8_t rd2; uint8_t re0; uint8_t re1; uint8_t re2; uint8_t re3; uint8_t re4; uint8_t re5; uint8_t re6; uint8_t re7; } Memory_layout; static Memory_layout layouts[]={ /* LIDE 100 */ { 0x29, 0x0a, 0x15, 0x20, 0x00, 0xac, 0x02, 0x55, 0x02, 0x56, 0x03, 0xff }, /* LIDE 200 */ { 0x29, 0x0a, 0x1f, 0x34, 0x01, 0x24, 0x02, 0x91, 0x02, 0x92, 0x03, 0xff }, /* 5600F */ { 0x29, 0x0a, 0x1f, 0x34, 0x01, 0x24, 0x02, 0x91, 0x02, 0x92, 0x03, 0xff }, /* LIDE 700F */ { 0x2a, 0x0a, 0x33, 0x5c, 0x02, 0x14, 0x09, 0x09, 0x09, 0x0a, 0x0f, 0xff } }; class CommandSetGl847 : public CommandSet { public: ~CommandSetGl847() override = default; bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const override; void init(Genesys_Device* dev) const override; void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, int* channels, int* total_size) const override; void init_regs_for_coarse_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void init_regs_for_scan(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* reg, const ScanSession& session) const override; void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const override; void set_powersaving(Genesys_Device* dev, int delay) const override; void save_power(Genesys_Device* dev, bool enable) const override; void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set* regs, bool start_motor) const override; void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void search_start_position(Genesys_Device* dev) const override; void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs, int dpi) const override; SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; void wait_for_motor_stop(Genesys_Device* dev) const override; void move_back_home(Genesys_Device* dev, bool wait_until_home) const override; void update_hardware_sensors(struct Genesys_Scanner* s) const override; bool needs_update_home_sensor_gpio() const override { return true; } void update_home_sensor_gpio(Genesys_Device& dev) const override; void load_document(Genesys_Device* dev) const override; void detect_document_end(Genesys_Device* dev) const override; void eject_document(Genesys_Device* dev) const override; void search_strip(Genesys_Device* dev, const Genesys_Sensor& sensor, bool forward, bool black) const override; void move_to_ta(Genesys_Device* dev) const override; void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data, int size) const override; ScanSession calculate_scan_session(const Genesys_Device* dev, const Genesys_Sensor& sensor, const Genesys_Settings& settings) const override; void asic_boot(Genesys_Device* dev, bool cold) const override; }; enum SlopeTable { SCAN_TABLE = 0, // table 1 at 0x4000 BACKTRACK_TABLE = 1, // table 2 at 0x4800 STOP_TABLE = 2, // table 3 at 0x5000 FAST_TABLE = 3, // table 4 at 0x5800 HOME_TABLE = 4, // table 5 at 0x6000 }; } // namespace gl847 } // namespace genesys #endif // BACKEND_GENESYS_GL847_H sane-backends-1.0.29/backend/genesys/tables_model.cpp0000666000000000000000000025021413615534521017407 00000000000000/* sane - Scanner Access Now Easy. 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) 2005-2009 Pierre Willenbrock Copyright (C) 2007 Luke Copyright (C) 2010 Jack McGill Copyright (C) 2010 Andrey Loginov , xerox travelscan device entry Copyright (C) 2010 Chris Berry and Michael Rickmann for Plustek Opticbook 3600 support Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define DEBUG_DECLARE_ONLY #include "low.h" namespace genesys { StaticInit> s_usb_devices; void genesys_init_usb_device_tables() { s_usb_devices.init(); Genesys_Model model; model.name = "umax-astra-4500"; model.vendor = "UMAX"; model.model = "Astra 4500"; model.model_id = ModelId::UMAX_ASTRA_4500; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 150, 75 }, { 2400, 1200, 600, 300, 150, 75 } } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 3.5; model.y_offset = 7.5; model.x_size = 218.0; model.y_size = 299.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 1.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 8; model.ld_shift_b = 16; model.line_mode_color_order = ColorOrder::BGR; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_UMAX; model.adc_id = AdcId::WOLFSON_UMAX; model.gpio_id = GpioId::UMAX; model.motor_id = MotorId::UMAX; model.flags = GENESYS_FLAG_UNTESTED; model.buttons = GENESYS_HAS_NO_BUTTONS; model.shading_lines = 20; model.shading_ta_lines = 0; model.search_lines = 200; s_usb_devices->emplace_back(0x0638, 0x0a10, model); model = Genesys_Model(); model.name = "canon-lide-50"; model.vendor = "Canon"; model.model = "LiDE 35/40/50"; model.model_id = ModelId::CANON_LIDE_50; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 200, 150, 75 }, { 2400, 1200, 600, 300, 200, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.42; model.y_offset = 7.9; model.x_size = 218.0; model.y_size = 299.0; model.y_offset_calib_white = 6.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_35; model.adc_id = AdcId::CANON_LIDE_35; model.gpio_id = GpioId::CANON_LIDE_35; model.motor_id = MotorId::CANON_LIDE_35; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 280; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x2213, model); model = Genesys_Model(); model.name = "panasonic-kv-ss080"; model.vendor = "Panasonic"; model.model = "KV-SS080"; model.model_id = ModelId::PANASONIC_KV_SS080; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::FLATBED }, { 600, /* 500, 400,*/ 300, 200, 150, 100, 75 }, { 1200, 600, /* 500, 400, */ 300, 200, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 7.2; model.y_offset = 14.7; model.x_size = 217.7; model.y_size = 300.0; model.y_offset_calib_white = 9.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 0.0; model.y_size_ta = 0.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 8; model.ld_shift_b = 16; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_KVSS080; model.adc_id = AdcId::KVSS080; model.gpio_id = GpioId::KVSS080; model.motor_id = MotorId::KVSS080; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 100; s_usb_devices->emplace_back(0x04da, 0x100f, model); model = Genesys_Model(); model.name = "hewlett-packard-scanjet-4850c"; model.vendor = "Hewlett Packard"; model.model = "ScanJet 4850C"; model.model_id = ModelId::HP_SCANJET_4850C; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::FLATBED }, { 2400, 1200, 600, 400, 300, 200, 150, 100 }, { 2400, 1200, 600, 400, 300, 200, 150, 100 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 7.9; model.y_offset = 10.0; model.x_size = 219.6; model.y_size = 314.5; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_HP_4850C; model.adc_id = AdcId::G4050; model.gpio_id = GpioId::G4050; model.motor_id = MotorId::G4050; model.flags = GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 100; s_usb_devices->emplace_back(0x03f0, 0x1b05, model); model = Genesys_Model(); model.name = "hewlett-packard-scanjet-g4010"; model.vendor = "Hewlett Packard"; model.model = "ScanJet G4010"; model.model_id = ModelId::HP_SCANJET_G4010; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::FLATBED }, { 2400, 1200, 600, 400, 300, 200, 150, 100 }, { 2400, 1200, 600, 400, 300, 200, 150, 100 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 8.0; model.y_offset = 13.00; model.x_size = 217.9; model.y_size = 315.0; model.y_offset_calib_white = 3.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_G4050; model.adc_id = AdcId::G4050; model.gpio_id = GpioId::G4050; model.motor_id = MotorId::G4050; model.flags = GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 100; s_usb_devices->emplace_back(0x03f0, 0x4505, model); model = Genesys_Model(); model.name = "hewlett-packard-scanjet-g4050"; model.vendor = "Hewlett Packard"; model.model = "ScanJet G4050"; model.model_id = ModelId::HP_SCANJET_G4050; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::FLATBED }, { 2400, 1200, 600, 400, 300, 200, 150, 100 }, { 2400, 1200, 600, 400, 300, 200, 150, 100 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 8.0; model.y_offset = 10.00; model.x_size = 217.9; model.y_size = 315.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 8.0; model.y_offset_ta = 13.00; model.x_size_ta = 217.9; model.y_size_ta = 250.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 40.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_G4050; model.adc_id = AdcId::G4050; model.gpio_id = GpioId::G4050; model.motor_id = MotorId::G4050; model.flags = GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 100; s_usb_devices->emplace_back(0x03f0, 0x4605, model); model = Genesys_Model(); model.name = "canon-canoscan-4400f"; model.vendor = "Canon"; model.model = "Canoscan 4400f"; model.model_id = ModelId::CANON_4400F; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300 }, { 1200, 600, 300 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 6.0; model.y_offset = 12.00; model.x_size = 215.9; model.y_size = 297.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 8.0; model.y_offset_ta = 13.00; model.x_size_ta = 217.9; model.y_size_ta = 250.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 40.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 96; model.ld_shift_g = 48; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_CANON_4400F; model.adc_id = AdcId::CANON_4400F; model.gpio_id = GpioId::CANON_4400F; model.motor_id = MotorId::CANON_4400F; model.flags = GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_FULL_HWDPI_MODE | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SHADING_REPARK; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 100; s_usb_devices->emplace_back(0x04a9, 0x2228, model); model = Genesys_Model(); model.name = "canon-canoscan-8400f"; model.vendor = "Canon"; model.model = "Canoscan 8400f"; model.model_id = ModelId::CANON_8400F; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::FLATBED }, { 3200, 1600, 800, 400 }, { 3200, 1600, 800, 400 }, }, { { ScanMethod::TRANSPARENCY }, { 3200, 1600, 800, 400 }, { 3200, 1600, 800, 400 }, }, { { ScanMethod::TRANSPARENCY_INFRARED }, { 3200, 1600, 800, 400 }, { 3200, 1600, 800, 400 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 3.5; model.y_offset = 17.00; model.x_size = 219.9; model.y_size = 300.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 10.0; model.x_offset_ta = 75.0; model.y_offset_ta = 45.00; model.x_size_ta = 75.0; model.y_size_ta = 230.0; model.y_offset_sensor_to_ta = 22.0; model.y_offset_calib_white_ta = 25.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_CANON_8400F; model.adc_id = AdcId::CANON_8400F; model.gpio_id = GpioId::CANON_8400F; model.motor_id = MotorId::CANON_8400F; model.flags = GENESYS_FLAG_HAS_UTA | GENESYS_FLAG_HAS_UTA_INFRARED | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_FULL_HWDPI_MODE | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SHADING_REPARK; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 100; model.shading_ta_lines = 50; model.search_lines = 100; s_usb_devices->emplace_back(0x04a9, 0x221e, model); model = Genesys_Model(); model.name = "canon-canoscan-8600f"; model.vendor = "Canon"; model.model = "Canoscan 8600f"; model.model_id = ModelId::CANON_8600F; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300 }, { 1200, 600, 300 }, }, { { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { 4800, 2400, 1200, 600, 300 }, { 4800, 2400, 1200, 600, 300 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 24.0; model.y_offset = 10.0; model.x_size = 216.0; model.y_size = 297.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 8.0; model.x_offset_ta = 85.0; model.y_offset_ta = 26.0; model.x_size_ta = 70.0; model.y_size_ta = 230.0; model.y_offset_sensor_to_ta = 11.5; model.y_offset_calib_white_ta = 14.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 48; model.ld_shift_b = 96; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_CANON_8600F; model.adc_id = AdcId::CANON_8600F; model.gpio_id = GpioId::CANON_8600F; model.motor_id = MotorId::CANON_8600F; model.flags = GENESYS_FLAG_HAS_UTA | GENESYS_FLAG_HAS_UTA_INFRARED | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_FULL_HWDPI_MODE | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SHADING_REPARK; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 50; model.shading_ta_lines = 50; model.search_lines = 100; s_usb_devices->emplace_back(0x04a9, 0x2229, model); model = Genesys_Model(); model.name = "canon-lide-100"; model.vendor = "Canon"; model.model = "LiDE 100"; model.model_id = ModelId::CANON_LIDE_100; model.asic_type = AsicType::GL847; model.resolutions = { { { ScanMethod::FLATBED }, { 2400, 1200, 600, 300, 200, 150, 100, 75 }, { 4800, 2400, 1200, 600, 300, 200, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 1.1; model.y_offset = 8.3; model.x_size = 216.07; model.y_size = 299.0; model.y_offset_calib_white = 1.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_100; model.adc_id = AdcId::CANON_LIDE_200; model.gpio_id = GpioId::CANON_LIDE_200; model.motor_id = MotorId::CANON_LIDE_100; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_SIS_SENSOR | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW; model.shading_lines = 50; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x1904, model); model = Genesys_Model(); model.name = "canon-lide-110"; model.vendor = "Canon"; model.model = "LiDE 110"; model.model_id = ModelId::CANON_LIDE_110; model.asic_type = AsicType::GL124; model.resolutions = { { { ScanMethod::FLATBED }, { 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75 }, { 4800, 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 2.2; model.y_offset = 9.0; model.x_size = 216.70; model.y_size = 300.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_110; model.adc_id = AdcId::CANON_LIDE_110; model.gpio_id = GpioId::CANON_LIDE_110; model.motor_id = MotorId::CANON_LIDE_110; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW; model.shading_lines = 25; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x1909, model); model = Genesys_Model(); model.name = "canon-lide-120"; model.vendor = "Canon"; model.model = "LiDE 120"; model.model_id = ModelId::CANON_LIDE_120; model.asic_type = AsicType::GL124; model.resolutions = { { { ScanMethod::FLATBED }, { 2400, 1200, 600, 300, 150, 100, 75 }, { 4800, 2400, 1200, 600, 300, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 8.0; model.x_size = 216.0; model.y_size = 300.0; model.y_offset_calib_white = 1.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_120; model.adc_id = AdcId::CANON_LIDE_120; model.gpio_id = GpioId::CANON_LIDE_120; model.motor_id = MotorId::CANON_LIDE_120; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW; model.shading_lines = 50; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x190e, model); model = Genesys_Model(); model.name = "canon-lide-210"; model.vendor = "Canon"; model.model = "LiDE 210"; model.model_id = ModelId::CANON_LIDE_210; model.asic_type = AsicType::GL124; model.resolutions = { { { ScanMethod::FLATBED }, // BUG: 4800 resolution crashes { /*4800,*/ 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75 }, { /*4800,*/ 2400, 1200, 600, /* 400,*/ 300, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 2.2; model.y_offset = 8.7; model.x_size = 216.70; model.y_size = 297.5; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_210; model.adc_id = AdcId::CANON_LIDE_110; model.gpio_id = GpioId::CANON_LIDE_210; model.motor_id = MotorId::CANON_LIDE_210; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_EXTRA_SW; model.shading_lines = 60; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x190a, model); model = Genesys_Model(); model.name = "canon-lide-220"; model.vendor = "Canon"; model.model = "LiDE 220"; model.model_id = ModelId::CANON_LIDE_220; model.asic_type = AsicType::GL124; // or a compatible one model.resolutions = { { { ScanMethod::FLATBED }, // BUG: 4800 resolution crashes { /*4800,*/ 2400, 1200, 600, 300, 150, 100, 75 }, { /*4800,*/ 2400, 1200, 600, 300, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 2.2; model.y_offset = 8.7; model.x_size = 216.70; model.y_size = 297.5; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_220; model.adc_id = AdcId::CANON_LIDE_110; model.gpio_id = GpioId::CANON_LIDE_210; model.motor_id = MotorId::CANON_LIDE_210; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_EXTRA_SW; model.shading_lines = 60; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x190f, model); model = Genesys_Model(); model.name = "canon-5600f"; model.vendor = "Canon"; model.model = "5600F"; model.model_id = ModelId::CANON_5600F; model.asic_type = AsicType::GL847; model.resolutions = { { { ScanMethod::FLATBED }, { 4800, 2400, 1200, 600, 400, 300, 200, 150, 100, 75 }, { 4800, 2400, 1200, 600, 400, 300, 200, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 1.1; model.y_offset = 8.3; model.x_size = 216.07; model.y_size = 299.0; model.y_offset_calib_white = 3.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_200; model.adc_id = AdcId::CANON_LIDE_200; model.gpio_id = GpioId::CANON_LIDE_200; model.motor_id = MotorId::CANON_LIDE_200; model.flags = GENESYS_FLAG_UNTESTED | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_SIS_SENSOR | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW; model.shading_lines = 50; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x1906, model); model = Genesys_Model(); model.name = "canon-lide-700f"; model.vendor = "Canon"; model.model = "LiDE 700F"; model.model_id = ModelId::CANON_LIDE_700F; model.asic_type = AsicType::GL847; model.resolutions = { { { ScanMethod::FLATBED }, { 4800, 2400, 1200, 600, 300, 200, 150, 100, 75 }, { 4800, 2400, 1200, 600, 300, 200, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 3.1; model.y_offset = 8.1; model.x_size = 216.07; model.y_size = 297.0; model.y_offset_calib_white = 1.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_700F; model.adc_id = AdcId::CANON_LIDE_700F; model.gpio_id = GpioId::CANON_LIDE_700F; model.motor_id = MotorId::CANON_LIDE_700; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_SIS_SENSOR | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW; model.shading_lines = 70; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x1907, model); model = Genesys_Model(); model.name = "canon-lide-200"; model.vendor = "Canon"; model.model = "LiDE 200"; model.model_id = ModelId::CANON_LIDE_200; model.asic_type = AsicType::GL847; model.resolutions = { { { ScanMethod::FLATBED }, { 4800, 2400, 1200, 600, 300, 200, 150, 100, 75 }, { 4800, 2400, 1200, 600, 300, 200, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 1.1; model.y_offset = 8.3; model.x_size = 216.07; model.y_size = 299.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_200; model.adc_id = AdcId::CANON_LIDE_200; model.gpio_id = GpioId::CANON_LIDE_200; model.motor_id = MotorId::CANON_LIDE_200; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_SIS_SENSOR | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW; model.shading_lines = 50; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x1905, model); model = Genesys_Model(); model.name = "canon-lide-60"; model.vendor = "Canon"; model.model = "LiDE 60"; model.model_id = ModelId::CANON_LIDE_60; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 150, 75 }, { 2400, 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.42; model.y_offset = 7.9; model.x_size = 218.0; model.y_size = 299.0; model.y_offset_calib_white = 6.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_35; model.adc_id = AdcId::CANON_LIDE_35; model.gpio_id = GpioId::CANON_LIDE_35; model.motor_id = MotorId::CANON_LIDE_35; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_EMAIL_SW; model.shading_lines = 300; model.shading_ta_lines = 0; model.search_lines = 400; // this is completely untested s_usb_devices->emplace_back(0x04a9, 0x221c, model); model = Genesys_Model(); model.name = "canon-lide-80"; model.vendor = "Canon"; model.model = "LiDE 80"; model.model_id = ModelId::CANON_LIDE_80; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 150, 100, 75 }, { 2400, 1200, 600, 300, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.42; model.y_offset = 7.90; model.x_size = 216.07; model.y_size = 299.0; model.y_offset_calib_white = 4.5; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = false; model.sensor_id = SensorId::CIS_CANON_LIDE_80; model.adc_id = AdcId::CANON_LIDE_80; model.gpio_id = GpioId::CANON_LIDE_80; model.motor_id = MotorId::CANON_LIDE_80; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_WHITE_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 160; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a9, 0x2214, model); model = Genesys_Model(); model.name = "hewlett-packard-scanjet-2300c"; model.vendor = "Hewlett Packard"; model.model = "ScanJet 2300c"; model.model_id = ModelId::HP_SCANJET_2300C; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 2.0; model.y_offset = 7.5; model.x_size = 215.9; model.y_size = 295.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 1.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 16; model.ld_shift_g = 8; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_HP2300; model.adc_id = AdcId::WOLFSON_HP2300; model.gpio_id = GpioId::HP2300; model.motor_id = MotorId::HP2300; model.flags = GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_SEARCH_START | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW; model.shading_lines = 40; model.shading_ta_lines = 0; model.search_lines = 132; s_usb_devices->emplace_back(0x03f0, 0x0901, model); model = Genesys_Model(); model.name = "hewlett-packard-scanjet-2400c"; model.vendor = "Hewlett Packard"; model.model = "ScanJet 2400c"; model.model_id = ModelId::HP_SCANJET_2400C; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 150, 100, 50 }, { 1200, 600, 300, 150, 100, 50 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 6.5; model.y_offset = 2.5; model.x_size = 220.0; model.y_size = 297.2; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 1.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_HP2400; model.adc_id = AdcId::WOLFSON_HP2400; model.gpio_id = GpioId::HP2400; model.motor_id = MotorId::HP2400; model.flags = GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_SCAN_SW; model.shading_lines = 20; model.shading_ta_lines = 0; model.search_lines = 132; s_usb_devices->emplace_back(0x03f0, 0x0a01, model); model = Genesys_Model(); model.name = "visioneer-strobe-xp200"; model.vendor = "Visioneer"; model.model = "Strobe XP200"; model.model_id = ModelId::VISIONEER_STROBE_XP200; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 200, 100, 75 }, { 600, 300, 200, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.5; model.y_offset = 16.0; model.x_size = 215.9; model.y_size = 297.2; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CIS_XP200; model.adc_id = AdcId::AD_XP200; model.gpio_id = GpioId::XP200; model.motor_id = MotorId::XP200; model.flags = GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 120; model.shading_ta_lines = 0; model.search_lines = 132; s_usb_devices->emplace_back(0x04a7, 0x0426, model); model = Genesys_Model(); model.name = "hewlett-packard-scanjet-3670"; model.vendor = "Hewlett Packard"; model.model = "ScanJet 3670"; model.model_id = ModelId::HP_SCANJET_3670; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 150, 100, 75, 50 }, { 1200, 600, 300, 150, 100, 75, 50 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 8.5; model.y_offset = 11.0; model.x_size = 215.9; model.y_size = 300.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 1.0; model.x_offset_ta = 104.0; model.y_offset_ta = 55.6; model.x_size_ta = 25.6; model.y_size_ta = 78.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 76.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_HP3670; model.adc_id = AdcId::WOLFSON_HP3670; model.gpio_id = GpioId::HP3670; model.motor_id = MotorId::HP3670; model.flags = GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_XPA | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_SCAN_SW; model.shading_lines = 20; model.shading_ta_lines = 0; model.search_lines = 200; s_usb_devices->emplace_back(0x03f0, 0x1405, model); model = Genesys_Model(); model.name = "plustek-opticpro-st12"; model.vendor = "Plustek"; model.model = "OpticPro ST12"; model.model_id = ModelId::PLUSTEK_OPTICPRO_ST12; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 3.5; model.y_offset = 7.5; model.x_size = 218.0; model.y_size = 299.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 1.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 8; model.ld_shift_b = 16; model.line_mode_color_order = ColorOrder::BGR; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_ST12; model.adc_id = AdcId::WOLFSON_ST12; model.gpio_id = GpioId::ST12; model.motor_id = MotorId::UMAX; model.flags = GENESYS_FLAG_UNTESTED | GENESYS_FLAG_14BIT_GAMMA; model.buttons = GENESYS_HAS_NO_BUTTONS; model.shading_lines = 20; model.shading_ta_lines = 0; model.search_lines = 200; s_usb_devices->emplace_back(0x07b3, 0x0600, model); model = Genesys_Model(); model.name = "plustek-opticpro-st24"; model.vendor = "Plustek"; model.model = "OpticPro ST24"; model.model_id = ModelId::PLUSTEK_OPTICPRO_ST24; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 150, 75 }, { 2400, 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 3.5; model.y_offset = 7.5; model.x_size = 218.0; model.y_size = 299.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 1.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 8; model.ld_shift_b = 16; model.line_mode_color_order = ColorOrder::BGR; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_ST24; model.adc_id = AdcId::WOLFSON_ST24; model.gpio_id = GpioId::ST24; model.motor_id = MotorId::ST24; model.flags = GENESYS_FLAG_UNTESTED | GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SEARCH_START | GENESYS_FLAG_OFFSET_CALIBRATION; model.buttons = GENESYS_HAS_NO_BUTTONS; model.shading_lines = 20; model.shading_ta_lines = 0; model.search_lines = 200; s_usb_devices->emplace_back(0x07b3, 0x0601, model); model = Genesys_Model(); model.name = "medion-md5345-model"; model.vendor = "Medion"; model.model = "MD5345/MD6228/MD6471"; model.model_id = ModelId::MEDION_MD5345; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 400, 300, 200, 150, 100, 75, 50 }, { 2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.30; model.y_offset = 0.80; model.x_size = 220.0; model.y_size = 296.4; model.y_offset_calib_white = 0.00; model.x_offset_calib_black = 0.00; model.x_offset_ta = 0.00; model.y_offset_ta = 0.00; model.x_size_ta = 0.00; model.y_size_ta = 0.00; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.00; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 48; model.ld_shift_g = 24; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_5345; model.adc_id = AdcId::WOLFSON_5345; model.gpio_id = GpioId::MD_5345; model.motor_id = MotorId::MD_5345; model.flags = GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_SEARCH_START | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_SHADING_NO_MOVE | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_POWER_SW | GENESYS_HAS_OCR_SW | GENESYS_HAS_SCAN_SW; model.shading_lines = 40; model.shading_ta_lines = 0; model.search_lines = 200; s_usb_devices->emplace_back(0x0461, 0x0377, model); model = Genesys_Model(); model.name = "visioneer-strobe-xp300"; model.vendor = "Visioneer"; model.model = "Strobe XP300"; model.model_id = ModelId::VISIONEER_STROBE_XP300; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 1.0; model.x_size = 435.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 26.5; // this is larger than needed -- accounts for second sensor head, which is a calibration item model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_XP300; model.adc_id = AdcId::WOLFSON_XP300; model.gpio_id = GpioId::XP300; model.motor_id = MotorId::XP300; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a7, 0x0474, model); model = Genesys_Model(); model.name = "syscan-docketport-665"; model.vendor = "Syscan/Ambir"; model.model = "DocketPORT 665"; model.model_id = ModelId::SYSCAN_DOCKETPORT_665; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 108.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 17.5; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_DP665; model.adc_id = AdcId::WOLFSON_XP300; model.gpio_id = GpioId::DP665; model.motor_id = MotorId::DP665; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x0a82, 0x4803, model); model = Genesys_Model(); model.name = "visioneer-roadwarrior"; model.vendor = "Visioneer"; model.model = "Readwarrior"; model.model_id = ModelId::VISIONEER_ROADWARRIOR; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 220.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 16.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_ROADWARRIOR; model.adc_id = AdcId::WOLFSON_XP300; model.gpio_id = GpioId::DP665; model.motor_id = MotorId::ROADWARRIOR; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_DARK_CALIBRATION; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a7, 0x0494, model); model = Genesys_Model(); model.name = "syscan-docketport-465"; model.vendor = "Syscan"; model.model = "DocketPORT 465"; model.model_id = ModelId::SYSCAN_DOCKETPORT_465; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 220.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 16.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_ROADWARRIOR; model.adc_id = AdcId::WOLFSON_XP300; model.gpio_id = GpioId::DP665; model.motor_id = MotorId::ROADWARRIOR; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_NO_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_UNTESTED; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW; model.shading_lines = 300; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x0a82, 0x4802, model); model = Genesys_Model(); model.name = "visioneer-xp100-revision3"; model.vendor = "Visioneer"; model.model = "XP100 Revision 3"; model.model_id = ModelId::VISIONEER_STROBE_XP100_REVISION3; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 220.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 16.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_ROADWARRIOR; model.adc_id = AdcId::WOLFSON_XP300; model.gpio_id = GpioId::DP665; model.motor_id = MotorId::ROADWARRIOR; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_DARK_CALIBRATION; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a7, 0x049b, model); model = Genesys_Model(); model.name = "pentax-dsmobile-600"; model.vendor = "Pentax"; model.model = "DSmobile 600"; model.model_id = ModelId::PENTAX_DSMOBILE_600; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 220.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 16.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_DSMOBILE600; model.adc_id = AdcId::WOLFSON_DSM600; model.gpio_id = GpioId::DP665; model.motor_id = MotorId::DSMOBILE_600; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_DARK_CALIBRATION; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x0a17, 0x3210, model); // clone, only usb id is different s_usb_devices->emplace_back(0x04f9, 0x2038, model); model = Genesys_Model(); model.name = "syscan-docketport-467"; model.vendor = "Syscan"; model.model = "DocketPORT 467"; model.model_id = ModelId::SYSCAN_DOCKETPORT_467; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 220.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 16.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_DSMOBILE600; model.adc_id = AdcId::WOLFSON_DSM600; model.gpio_id = GpioId::DP665; model.motor_id = MotorId::DSMOBILE_600; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_DARK_CALIBRATION; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x1dcc, 0x4812, model); model = Genesys_Model(); model.name = "syscan-docketport-685"; model.vendor = "Syscan/Ambir"; model.model = "DocketPORT 685"; model.model_id = ModelId::SYSCAN_DOCKETPORT_685; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 1.0; model.x_size = 212.0; model.y_size = 500; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 26.5; // this is larger than needed -- accounts for second sensor head, which is a calibration item model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_DP685; model.adc_id = AdcId::WOLFSON_DSM600; model.gpio_id = GpioId::DP685; model.motor_id = MotorId::XP300; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_DARK_CALIBRATION; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x0a82, 0x480c, model); model = Genesys_Model(); model.name = "syscan-docketport-485"; model.vendor = "Syscan/Ambir"; model.model = "DocketPORT 485"; model.model_id = ModelId::SYSCAN_DOCKETPORT_485; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 1.0; model.x_size = 435.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 26.5; // this is larger than needed -- accounts for second sensor head, which is a calibration item model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_XP300; model.adc_id = AdcId::WOLFSON_XP300; model.gpio_id = GpioId::XP300; model.motor_id = MotorId::XP300; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_DARK_CALIBRATION; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x0a82, 0x4800, model); model = Genesys_Model(); model.name = "dct-docketport-487"; model.vendor = "DCT"; model.model = "DocketPORT 487"; model.model_id = ModelId::DCT_DOCKETPORT_487; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.0; model.y_offset = 1.0; model.x_size = 435.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 26.5; // this is larger than needed -- accounts for second sensor head, which is a calibration item model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_XP300; model.adc_id = AdcId::WOLFSON_XP300; model.gpio_id = GpioId::XP300; model.motor_id = MotorId::XP300; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_UNTESTED; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x1dcc, 0x4810, model); model = Genesys_Model(); model.name = "visioneer-7100-model"; model.vendor = "Visioneer"; model.model = "OneTouch 7100"; model.model_id = ModelId::VISIONEER_7100; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 400, 300, 200, 150, 100, 75, 50 }, { 2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 4.00; model.y_offset = 0.80; model.x_size = 215.9; model.y_size = 296.4; model.y_offset_calib_white = 0.00; model.x_offset_calib_black = 0.00; model.x_offset_ta = 0.00; model.y_offset_ta = 0.00; model.x_size_ta = 0.00; model.y_size_ta = 0.00; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.00; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 48; model.ld_shift_g = 24; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_5345; model.adc_id = AdcId::WOLFSON_5345; model.gpio_id = GpioId::MD_5345; model.motor_id = MotorId::MD_5345; model.flags = GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_SEARCH_START | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_POWER_SW | GENESYS_HAS_OCR_SW | GENESYS_HAS_SCAN_SW; model.shading_lines = 40; model.shading_ta_lines = 0; model.search_lines = 200; s_usb_devices->emplace_back(0x04a7, 0x0229, model); model = Genesys_Model(); model.name = "xerox-2400-model"; model.vendor = "Xerox"; model.model = "OneTouch 2400"; model.model_id = ModelId::XEROX_2400; model.asic_type = AsicType::GL646; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 400, 300, 200, 150, 100, 75, 50 }, { 2400, 1200, 600, 400, 300, 200, 150, 100, 75, 50 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 4.00; model.y_offset = 0.80; model.x_size = 215.9; model.y_size = 296.4; model.y_offset_calib_white = 0.00; model.x_offset_calib_black = 0.00; model.x_offset_ta = 0.00; model.y_offset_ta = 0.00; model.x_size_ta = 0.00; model.y_size_ta = 0.00; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.00; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 48; model.ld_shift_g = 24; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_5345; model.adc_id = AdcId::WOLFSON_5345; model.gpio_id = GpioId::MD_5345; model.motor_id = MotorId::MD_5345; model.flags = GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_SEARCH_START | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_POWER_SW | GENESYS_HAS_OCR_SW | GENESYS_HAS_SCAN_SW; model.shading_lines = 40; model.shading_ta_lines = 0; model.search_lines = 200; s_usb_devices->emplace_back(0x0461, 0x038b, model); model = Genesys_Model(); model.name = "xerox-travelscanner"; model.vendor = "Xerox"; model.model = "Travelscanner 100"; model.model_id = ModelId::XEROX_TRAVELSCANNER_100; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { 600, 300, 150, 75 }, { 1200, 600, 300, 150, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 4.0; model.y_offset = 0.0; model.x_size = 220.0; model.y_size = 511; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 16.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = true; model.is_sheetfed = true; model.sensor_id = SensorId::CCD_ROADWARRIOR; model.adc_id = AdcId::WOLFSON_XP300; model.gpio_id = GpioId::DP665; model.motor_id = MotorId::ROADWARRIOR; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_DARK_CALIBRATION; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_PAGE_LOADED_SW | GENESYS_HAS_CALIBRATE; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 400; s_usb_devices->emplace_back(0x04a7, 0x04ac, model); model = Genesys_Model(); model.name = "plustek-opticbook-3600"; model.vendor = "PLUSTEK"; model.model = "OpticBook 3600"; model.model_id = ModelId::PLUSTEK_OPTICPRO_3600; model.asic_type = AsicType::GL841; model.resolutions = { { { ScanMethod::FLATBED }, { /*1200,*/ 600, 400, 300, 200, 150, 100, 75 }, { /*2400,*/ 1200, 600, 400, 300, 200, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 0.42; model.y_offset = 6.75; model.x_size = 216.0; model.y_size = 297.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 0.0; model.y_size_ta = 0.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_PLUSTEK_OPTICPRO_3600; model.adc_id = AdcId::PLUSTEK_OPTICPRO_3600; model.gpio_id = GpioId::PLUSTEK_OPTICPRO_3600; model.motor_id = MotorId::PLUSTEK_OPTICPRO_3600; model.flags = GENESYS_FLAG_UNTESTED | // not fully working yet GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION; model.buttons = GENESYS_HAS_NO_BUTTONS; model.shading_lines = 7; model.shading_ta_lines = 0; model.search_lines = 200; s_usb_devices->emplace_back(0x07b3, 0x0900, model); model = Genesys_Model(); model.name = "plustek-opticfilm-7200i"; model.vendor = "PLUSTEK"; model.model = "OpticFilm 7200i"; model.model_id = ModelId::PLUSTEK_OPTICFILM_7200I; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { 7200, 3600, 1800, 900 }, { 7200, 3600, 1800, 900 }, } }; model.bpp_gray_values = { 16 }; model.bpp_color_values = { 16 }; model.default_method = ScanMethod::TRANSPARENCY; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 36.0; model.y_size = 44.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 6.5; model.x_offset_ta = 0.0; model.y_offset_ta = 29.0; model.x_size_ta = 36.0; model.y_size_ta = 24.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_black_ta = 6.5; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 12; model.ld_shift_b = 24; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_PLUSTEK_OPTICFILM_7200I; model.adc_id = AdcId::PLUSTEK_OPTICFILM_7200I; model.gpio_id = GpioId::PLUSTEK_OPTICFILM_7200I; model.motor_id = MotorId::PLUSTEK_OPTICFILM_7200I; model.flags = GENESYS_FLAG_HAS_UTA | GENESYS_FLAG_HAS_UTA_INFRARED | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_HAS_NO_BUTTONS | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CALIBRATION_HOST_SIDE | GENESYS_FLAG_16BIT_DATA_INVERTED; model.shading_lines = 7; model.shading_ta_lines = 50; model.search_lines = 200; s_usb_devices->emplace_back(0x07b3, 0x0c04, model); model = Genesys_Model(); model.name = "plustek-opticfilm-7300"; model.vendor = "PLUSTEK"; model.model = "OpticFilm 7300"; model.model_id = ModelId::PLUSTEK_OPTICFILM_7300; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::TRANSPARENCY }, { 7200, 3600, 1800, 900 }, { 7200, 3600, 1800, 900 }, } }; model.bpp_gray_values = { 16 }; model.bpp_color_values = { 16 }; model.default_method = ScanMethod::TRANSPARENCY; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 36.0; model.y_size = 44.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 6.5; model.x_offset_ta = 0.0; model.y_offset_ta = 29.0; model.x_size_ta = 36.0; model.y_size_ta = 24.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_black_ta = 6.5; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 12; model.ld_shift_b = 24; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_PLUSTEK_OPTICFILM_7300; model.adc_id = AdcId::PLUSTEK_OPTICFILM_7300; model.gpio_id = GpioId::PLUSTEK_OPTICFILM_7300; model.motor_id = MotorId::PLUSTEK_OPTICFILM_7300; model.flags = GENESYS_FLAG_HAS_UTA | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_HAS_NO_BUTTONS | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CALIBRATION_HOST_SIDE; model.shading_lines = 7; model.shading_ta_lines = 50; model.search_lines = 200; s_usb_devices->emplace_back(0x07b3, 0x0c12, model); model = Genesys_Model(); model.name = "plustek-opticfilm-7500i"; model.vendor = "PLUSTEK"; model.model = "OpticFilm 7500i"; model.model_id = ModelId::PLUSTEK_OPTICFILM_7500I; model.asic_type = AsicType::GL843; model.resolutions = { { { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { 7200, 3600, 1800, 900 }, { 7200, 3600, 1800, 900 }, } }; model.bpp_gray_values = { 16 }; model.bpp_color_values = { 16 }; model.default_method = ScanMethod::TRANSPARENCY; model.x_offset = 0.0; model.y_offset = 0.0; model.x_size = 36.0; model.y_size = 44.0; model.y_offset_calib_white = 0.0; model.x_offset_calib_black = 6.5; model.x_offset_ta = 0.0; model.y_offset_ta = 29.0; model.x_size_ta = 36.0; model.y_size_ta = 24.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_black_ta = 6.5; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 12; model.ld_shift_b = 24; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_PLUSTEK_OPTICFILM_7500I; model.adc_id = AdcId::PLUSTEK_OPTICFILM_7500I; model.gpio_id = GpioId::PLUSTEK_OPTICFILM_7500I; model.motor_id = MotorId::PLUSTEK_OPTICFILM_7500I; model.flags = GENESYS_FLAG_HAS_UTA | GENESYS_FLAG_HAS_UTA_INFRARED | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_HAS_NO_BUTTONS | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CALIBRATION_HOST_SIDE; model.shading_lines = 7; model.shading_ta_lines = 50; model.search_lines = 200; s_usb_devices->emplace_back(0x07b3, 0x0c13, model); model = Genesys_Model(); model.name = "hewlett-packard-scanjet-N6310"; model.vendor = "Hewlett Packard"; model.model = "ScanJet N6310"; model.model_id = ModelId::HP_SCANJET_N6310; model.asic_type = AsicType::GL847; model.resolutions = { { { ScanMethod::FLATBED }, { 2400, 1200, 600, 400, 300, 200, 150, 100, 75 }, { 2400, 1200, 600, 400, 300, 200, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 6; model.y_offset = 2; model.x_size = 216; model.y_size = 511; model.y_offset_calib_white = 3.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 100.0; model.y_size_ta = 100.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0; model.post_scan = 0; model.eject_feed = 0; model.ld_shift_r = 0; model.ld_shift_g = 0; model.ld_shift_b = 0; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_HP_N6310; model.adc_id = AdcId::CANON_LIDE_200; // Not defined yet for N6310 model.gpio_id = GpioId::HP_N6310; model.motor_id = MotorId::CANON_LIDE_200; // Not defined yet for N6310 model.flags = GENESYS_FLAG_UNTESTED | GENESYS_FLAG_14BIT_GAMMA | GENESYS_FLAG_DARK_CALIBRATION | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_NO_CALIBRATION; model.buttons = GENESYS_HAS_NO_BUTTONS; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 100; s_usb_devices->emplace_back(0x03f0, 0x4705, model); model = Genesys_Model(); model.name = "plustek-opticbook-3800"; model.vendor = "PLUSTEK"; model.model = "OpticBook 3800"; model.model_id = ModelId::PLUSTEK_OPTICBOOK_3800; model.asic_type = AsicType::GL845; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 150, 100, 75 }, { 1200, 600, 300, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 7.2; model.y_offset = 14.7; model.x_size = 217.7; model.y_size = 300.0; model.y_offset_calib_white = 9.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 0.0; model.y_size_ta = 0.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_PLUSTEK_OPTICBOOK_3800; model.adc_id = AdcId::PLUSTEK_OPTICBOOK_3800; model.gpio_id = GpioId::PLUSTEK_OPTICBOOK_3800; model.motor_id = MotorId::PLUSTEK_OPTICBOOK_3800; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA; model.buttons = GENESYS_HAS_NO_BUTTONS; // TODO there are 4 buttons to support model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 100; s_usb_devices->emplace_back(0x07b3, 0x1300, model); model = Genesys_Model(); model.name = "canon-image-formula-101"; model.vendor = "Canon"; model.model = "Image Formula 101"; model.model_id = ModelId::CANON_IMAGE_FORMULA_101; model.asic_type = AsicType::GL846; model.resolutions = { { { ScanMethod::FLATBED }, { 1200, 600, 300, 150, 100, 75 }, { 1200, 600, 300, 150, 100, 75 }, } }; model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; model.x_offset = 7.2; model.y_offset = 14.7; model.x_size = 217.7; model.y_size = 300.0; model.y_offset_calib_white = 9.0; model.x_offset_calib_black = 0.0; model.x_offset_ta = 0.0; model.y_offset_ta = 0.0; model.x_size_ta = 0.0; model.y_size_ta = 0.0; model.y_offset_sensor_to_ta = 0.0; model.y_offset_calib_white_ta = 0.0; model.post_scan = 0.0; model.eject_feed = 0.0; model.ld_shift_r = 0; model.ld_shift_g = 24; model.ld_shift_b = 48; model.line_mode_color_order = ColorOrder::RGB; model.is_cis = false; model.is_sheetfed = false; model.sensor_id = SensorId::CCD_IMG101; model.adc_id = AdcId::IMG101; model.gpio_id = GpioId::IMG101; model.motor_id = MotorId::IMG101; model.flags = GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_CUSTOM_GAMMA | GENESYS_FLAG_UNTESTED; model.buttons = GENESYS_HAS_NO_BUTTONS ; model.shading_lines = 100; model.shading_ta_lines = 0; model.search_lines = 100; s_usb_devices->emplace_back(0x1083, 0x162e, model); } } // namespace genesys sane-backends-1.0.29/backend/genesys/test_usb_device.h0000666000000000000000000000566013615534521017574 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_TEST_USB_DEVICE_H #define BACKEND_GENESYS_TEST_USB_DEVICE_H #include "usb_device.h" namespace genesys { class TestUsbDevice : public IUsbDevice { public: TestUsbDevice(std::uint16_t vendor, std::uint16_t product); TestUsbDevice() = default; ~TestUsbDevice() override; bool is_open() const override { return is_open_; } const std::string& name() const override { return name_; } void open(const char* dev_name) override; void clear_halt() override; void reset() override; void close() override; void get_vendor_product(int& vendor, int& product) override; void control_msg(int rtype, int reg, int value, int index, int length, std::uint8_t* data) override; void bulk_read(std::uint8_t* buffer, std::size_t* size) override; void bulk_write(const std::uint8_t* buffer, std::size_t* size) override; private: void assert_is_open() const; std::string name_; bool is_open_ = false; std::uint16_t vendor_ = 0; std::uint16_t product_ = 0; }; } // namespace genesys #endif // BACKEND_GENESYS_TEST_USB_DEVICE_H sane-backends-1.0.29/backend/genesys/image_pipeline.h0000666000000000000000000004546413615534521017402 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Povilas Kanapickas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BACKEND_GENESYS_IMAGE_PIPELINE_H #define BACKEND_GENESYS_IMAGE_PIPELINE_H #include "image.h" #include "image_pixel.h" #include "image_buffer.h" #include #include #include namespace genesys { class ImagePipelineNode { public: virtual ~ImagePipelineNode(); virtual std::size_t get_width() const = 0; virtual std::size_t get_height() const = 0; virtual PixelFormat get_format() const = 0; std::size_t get_row_bytes() const { return get_pixel_row_bytes(get_format(), get_width()); } virtual bool eof() const = 0; // returns true if the row was filled successfully, false otherwise (e.g. if not enough data // was available. virtual bool get_next_row_data(std::uint8_t* out_data) = 0; }; class ImagePipelineNodeBytesSource : public ImagePipelineNode { public: std::size_t remaining_bytes() const { return remaining_bytes_; } void set_remaining_bytes(std::size_t bytes) { remaining_bytes_ = bytes; } std::size_t consume_remaining_bytes(std::size_t bytes); private: std::size_t remaining_bytes_ = 0; }; // A pipeline node that produces data from a callable class ImagePipelineNodeCallableSource : public ImagePipelineNode { public: using ProducerCallback = std::function; ImagePipelineNodeCallableSource(std::size_t width, std::size_t height, PixelFormat format, ProducerCallback producer) : producer_{producer}, width_{width}, height_{height}, format_{format} {} std::size_t get_width() const override { return width_; } std::size_t get_height() const override { return height_; } PixelFormat get_format() const override { return format_; } bool eof() const override { return eof_; } bool get_next_row_data(std::uint8_t* out_data) override; private: ProducerCallback producer_; std::size_t width_ = 0; std::size_t height_ = 0; PixelFormat format_ = PixelFormat::UNKNOWN; bool eof_ = false; }; // A pipeline node that produces data from a callable requesting fixed-size chunks. class ImagePipelineNodeBufferedCallableSource : public ImagePipelineNodeBytesSource { public: using ProducerCallback = std::function; ImagePipelineNodeBufferedCallableSource(std::size_t width, std::size_t height, PixelFormat format, std::size_t input_batch_size, ProducerCallback producer); std::size_t get_width() const override { return width_; } std::size_t get_height() const override { return height_; } PixelFormat get_format() const override { return format_; } bool eof() const override { return eof_; } bool get_next_row_data(std::uint8_t* out_data) override; std::size_t buffer_size() const { return buffer_.size(); } std::size_t buffer_available() const { return buffer_.available(); } private: ProducerCallback producer_; std::size_t width_ = 0; std::size_t height_ = 0; PixelFormat format_ = PixelFormat::UNKNOWN; bool eof_ = false; std::size_t curr_row_ = 0; ImageBuffer buffer_; }; class ImagePipelineNodeBufferedGenesysUsb : public ImagePipelineNodeBytesSource { public: using ProducerCallback = std::function; ImagePipelineNodeBufferedGenesysUsb(std::size_t width, std::size_t height, PixelFormat format, std::size_t total_size, const FakeBufferModel& buffer_model, ProducerCallback producer); std::size_t get_width() const override { return width_; } std::size_t get_height() const override { return height_; } PixelFormat get_format() const override { return format_; } bool eof() const override { return eof_; } bool get_next_row_data(std::uint8_t* out_data) override; std::size_t buffer_available() const { return buffer_.available(); } private: ProducerCallback producer_; std::size_t width_ = 0; std::size_t height_ = 0; PixelFormat format_ = PixelFormat::UNKNOWN; bool eof_ = false; ImageBufferGenesysUsb buffer_; }; // A pipeline node that produces data from the given array. class ImagePipelineNodeArraySource : public ImagePipelineNodeBytesSource { public: ImagePipelineNodeArraySource(std::size_t width, std::size_t height, PixelFormat format, std::vector data); std::size_t get_width() const override { return width_; } std::size_t get_height() const override { return height_; } PixelFormat get_format() const override { return format_; } bool eof() const override { return eof_; } bool get_next_row_data(std::uint8_t* out_data) override; private: std::size_t width_ = 0; std::size_t height_ = 0; PixelFormat format_ = PixelFormat::UNKNOWN; bool eof_ = false; std::vector data_; std::size_t next_row_ = 0; }; /// A pipeline node that produces data from the given image class ImagePipelineNodeImageSource : public ImagePipelineNode { public: ImagePipelineNodeImageSource(const Image& source); std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height(); } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return next_row_ >= get_height(); } bool get_next_row_data(std::uint8_t* out_data) override; private: const Image& source_; std::size_t next_row_ = 0; }; // A pipeline node that converts between pixel formats class ImagePipelineNodeFormatConvert : public ImagePipelineNode { public: ImagePipelineNodeFormatConvert(ImagePipelineNode& source, PixelFormat dst_format) : source_(source), dst_format_{dst_format} {} ~ImagePipelineNodeFormatConvert() override = default; std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height(); } PixelFormat get_format() const override { return dst_format_; } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; PixelFormat dst_format_; std::vector buffer_; }; // A pipeline node that handles data that comes out of segmented sensors. Note that the width of // the output data does not necessarily match the input data width, because in many cases almost // all width of the image needs to be read in order to desegment it. class ImagePipelineNodeDesegment : public ImagePipelineNode { public: ImagePipelineNodeDesegment(ImagePipelineNode& source, std::size_t output_width, const std::vector& segment_order, std::size_t segment_pixels, std::size_t interleaved_lines, std::size_t pixels_per_chunk); ImagePipelineNodeDesegment(ImagePipelineNode& source, std::size_t output_width, std::size_t segment_count, std::size_t segment_pixels, std::size_t interleaved_lines, std::size_t pixels_per_chunk); ~ImagePipelineNodeDesegment() override = default; std::size_t get_width() const override { return output_width_; } std::size_t get_height() const override { return source_.get_height() / interleaved_lines_; } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; std::size_t output_width_; std::vector segment_order_; std::size_t segment_pixels_ = 0; std::size_t interleaved_lines_ = 0; std::size_t pixels_per_chunk_ = 0; RowBuffer buffer_; }; // A pipeline node that deinterleaves data on multiple lines class ImagePipelineNodeDeinterleaveLines : public ImagePipelineNodeDesegment { public: ImagePipelineNodeDeinterleaveLines(ImagePipelineNode& source, std::size_t interleaved_lines, std::size_t pixels_per_chunk); }; // A pipeline that swaps bytes in 16-bit components on big-endian systems class ImagePipelineNodeSwap16BitEndian : public ImagePipelineNode { public: ImagePipelineNodeSwap16BitEndian(ImagePipelineNode& source); std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height(); } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; bool needs_swapping_ = false; }; // A pipeline node that merges 3 mono lines into a color channel class ImagePipelineNodeMergeMonoLines : public ImagePipelineNode { public: ImagePipelineNodeMergeMonoLines(ImagePipelineNode& source, ColorOrder color_order); std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height() / 3; } PixelFormat get_format() const override { return output_format_; } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: static PixelFormat get_output_format(PixelFormat input_format, ColorOrder order); ImagePipelineNode& source_; PixelFormat output_format_ = PixelFormat::UNKNOWN; RowBuffer buffer_; }; // A pipeline node that splits a color channel into 3 mono lines class ImagePipelineNodeSplitMonoLines : public ImagePipelineNode { public: ImagePipelineNodeSplitMonoLines(ImagePipelineNode& source); std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height() * 3; } PixelFormat get_format() const override { return output_format_; } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: static PixelFormat get_output_format(PixelFormat input_format); ImagePipelineNode& source_; PixelFormat output_format_ = PixelFormat::UNKNOWN; std::vector buffer_; unsigned next_channel_ = 0; }; // A pipeline node that shifts colors across lines by the given offsets class ImagePipelineNodeComponentShiftLines : public ImagePipelineNode { public: ImagePipelineNodeComponentShiftLines(ImagePipelineNode& source, unsigned shift_r, unsigned shift_g, unsigned shift_b); std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height() - extra_height_; } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; std::size_t extra_height_ = 0; std::array channel_shifts_; RowBuffer buffer_; }; // A pipeline node that shifts pixels across lines by the given offsets (performs unstaggering) class ImagePipelineNodePixelShiftLines : public ImagePipelineNode { public: constexpr static std::size_t MAX_SHIFTS = 2; ImagePipelineNodePixelShiftLines(ImagePipelineNode& source, const std::vector& shifts); std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height() - extra_height_; } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; std::size_t extra_height_ = 0; std::vector pixel_shifts_; RowBuffer buffer_; }; // A pipeline node that extracts a sub-image from the image. Padding and cropping is done as needed. // The class can't pad to the left of the image currently, as only positive offsets are accepted. class ImagePipelineNodeExtract : public ImagePipelineNode { public: ImagePipelineNodeExtract(ImagePipelineNode& source, std::size_t offset_x, std::size_t offset_y, std::size_t width, std::size_t height); ~ImagePipelineNodeExtract() override; std::size_t get_width() const override { return width_; } std::size_t get_height() const override { return height_; } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; std::size_t offset_x_ = 0; std::size_t offset_y_ = 0; std::size_t width_ = 0; std::size_t height_ = 0; std::size_t current_line_ = 0; std::vector cached_line_; }; // A pipeline node that scales rows to the specified width by using a point filter class ImagePipelineNodeScaleRows : public ImagePipelineNode { public: ImagePipelineNodeScaleRows(ImagePipelineNode& source, std::size_t width); std::size_t get_width() const override { return width_; } std::size_t get_height() const override { return source_.get_height(); } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; std::size_t width_ = 0; std::vector cached_line_; }; // A pipeline node that mimics the calibration behavior on Genesys chips class ImagePipelineNodeCalibrate : public ImagePipelineNode { public: ImagePipelineNodeCalibrate(ImagePipelineNode& source, const std::vector& bottom, const std::vector& top); std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height(); } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; std::vector offset_; std::vector multiplier_; }; class ImagePipelineNodeDebug : public ImagePipelineNode { public: ImagePipelineNodeDebug(ImagePipelineNode& source, const std::string& path); ~ImagePipelineNodeDebug() override; std::size_t get_width() const override { return source_.get_width(); } std::size_t get_height() const override { return source_.get_height(); } PixelFormat get_format() const override { return source_.get_format(); } bool eof() const override { return source_.eof(); } bool get_next_row_data(std::uint8_t* out_data) override; private: ImagePipelineNode& source_; std::string path_; RowBuffer buffer_; }; class ImagePipelineStack { public: ImagePipelineStack() {} ~ImagePipelineStack() { clear(); } std::size_t get_input_width() const; std::size_t get_input_height() const; PixelFormat get_input_format() const; std::size_t get_input_row_bytes() const; std::size_t get_output_width() const; std::size_t get_output_height() const; PixelFormat get_output_format() const; std::size_t get_output_row_bytes() const; ImagePipelineNode& front() { return *(nodes_.front().get()); } bool eof() const { return nodes_.back()->eof(); } void clear(); template void push_first_node(Args&&... args) { if (!nodes_.empty()) { throw SaneException("Trying to append first node when there are existing nodes"); } nodes_.emplace_back(std::unique_ptr(new Node(std::forward(args)...))); } template void push_node(Args&&... args) { ensure_node_exists(); nodes_.emplace_back(std::unique_ptr(new Node(*nodes_.back(), std::forward(args)...))); } bool get_next_row_data(std::uint8_t* out_data) { return nodes_.back()->get_next_row_data(out_data); } std::vector get_all_data(); Image get_image(); private: void ensure_node_exists() const; std::vector> nodes_; }; } // namespace genesys #endif // ifndef BACKEND_GENESYS_IMAGE_PIPELINE_H sane-backends-1.0.29/backend/mustek.conf.in0000666000000000000000000000410713615534521015356 00000000000000# See sane-mustek(5) for documentation. #--------------------------- Global options --------------------------------- #option strip-height 1 # some SCSI adapters need this; scanning may # be faster without this option #option force-wait # wait for scanner to be ready (only necessary # when scanner freezes) #option disable-double-buffering # try this if you have SCSI trouble #-------------------------- SCSI scanners ----------------------------------- scsi MUSTEK * Scanner # option linedistance-fix # stripes may go away in color mode # option buffersize 1024 # set non standard buffer size (in kb) # option blocksize 2048 # set non standard block size (in kb) # option lineart-fix # lineart may be faster with this option off. # option disable-backtracking # faster, but may produce stripes scsi SCANNER # option linedistance-fix # stripes may go away in color mode # option buffersize 1024 # set non standard buffer size (in kb) # option blocksize 2048 # set non standard block size (in kb) # option lineart-fix # lineart may be faster with this option off. # option disable-backtracking # faster, but may produce stripes /dev/scanner # option linedistance-fix # stripes may go away in color mode # option buffersize 1024 # set non standard buffer size (in kb) # option blocksize 2048 # set non standard block size (in kb) # option lineart-fix # lineart may be faster with this option off. # option disable-backtracking # faster, but may produce stripes #-------------------------- 600 II N ---------------------------------------- #0x2eb # For the 600 II N try one of 0x26b, 0x2ab, # 0x2eb, 0x22b, 0x32b, 0x36b, 0x3ab, 0x3eb. # option linedistance-fix # only neccessary with firmware 2.x #-------------------------- 600 II EP --------------------------------------- #parport0 # parport0, parport1, ..., # or: 0x378(=lpt1), 0x278(=lpt2), 0x3bc(=lpt3) sane-backends-1.0.29/backend/s9036.h0000666000000000000000000000422713615534521013532 00000000000000/* sane - Scanner Access Now Easy. This file (C) 1997 Ingo Schneider This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef s9036_h #define s9036_h enum S9036_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_DEPTH, OPT_RESOLUTION, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_BRIGHTNESS, OPT_CONTRAST, OPT_BRIGHT_ADJUST, OPT_CONTR_ADJUST, /* must come last: */ NUM_OPTIONS }; typedef struct S9036_Device { struct S9036_Device *next; SANE_Device sane; SANE_Handle handle; } S9036_Device; typedef struct S9036_Scanner { /* all the state needed to define a scan request: */ SANE_Option_Descriptor opt[NUM_OPTIONS]; SANE_Word val[NUM_OPTIONS]; /* Parsed option values and variables that are valid only during actual scanning: */ SANE_Bool scanning; SANE_Parameters params; size_t bufsize; /* about SCSI_MAX_REQUEST_SIZE */ SANE_Byte *buffer; /* buffer of size 'bufsize' */ SANE_Byte *bufstart; /* Start of data for next read */ size_t in_buffer; /* bytes already in buffer */ int lines_in_scanner; /* Lines in scanner memory */ int lines_read; /* Total lines read for now */ int fd; /* SCSI filedescriptor */ /* scanner dependent/low-level state: */ S9036_Device *hw; } S9036_Scanner; #endif /* s9036_h */ sane-backends-1.0.29/backend/umax-uc1200se.c0000666000000000000000000001051613615534521015151 00000000000000 /* ------------------------------------------------------------------------- */ /* umax-uc1200se.c: inquiry for UMAX scanner uc1200se (C) 1998-2002 Oliver Rauch 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* ------------------------------------------------------------------------- */ #include "umax-scanner.h" /* ------------------------------------------------------------------------- */ static unsigned char UC1200SE_INQUIRY[] = { #define UC1200SE_INQUIRY_LEN 0x9d /* 24 F/W support function */ 0x03, /* 25 -27 exposure-times */ 0x00, 0x00, 0x00, /* 28 - 29 reserved */ 0x00, 0x00, /* 2a - 35 exposure times */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 36 - 37 reserved */ 0x00, 0x00, /* 38 - 5f scsi reserved */ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, /* 60 -62 scanner capability*/ 0x3e, 0x0c, 0x03, /* 63 reserved */ 0x00, /* 64 gamma */ 0x83, /* 65 reserved */ 0x00, /* 66 GIB */ 0x04, /* 67 reserved */ 0x00, /* 68 GOB */ 0x01, /* 69 - 6a halftone */ 0x00, 0x2f, /* 6b - 6c reserved */ 0x00, 0x00, /* 6d color sequence */ 0xe1, /* 0xe8, 0xe9 or 0xe1 ? */ /* 6e - 71 video memory */ 0x00, 0x20, 0x00, 0x00, /* 72 reserved */ 0x00, /* 73 max optical res in 100 dpi */ 0x06, /* 74 max x_res in 100 dpi */ 0x06, /* 75 max y_res in 100 dpi */ 0x0c, /* 76-77 fb max scan width in 0.01 inch */ 0x03, 0x20, /* 78-79 fb max scan length in 0.01 inch */ 0x04, 0x4c, /* 7a-7b uta x original point, may be 0x05, 0x89 */ 0x00, 0x76, /* 7c-7d uta y original point, may be 0x06, 0x75 */ 0x00, 0x89, /* 7e-7f uta max scan width in 0.01 inch */ 0x02, 0x4e, /* 80-81 uta max scan length in 0.01 inch */ 0x03, 0x65, /* 82-85 reserved */ 00, 00, 00, 00, /* 86-87 dor x original point */ 0x00, 0x00, /* 88-89 dor x original point */ 0x00, 0x00, /* 8a-8b dor max scan width in 0.01 inch */ 0x00, 0x00, /* 8c-8d dor max scan length in 0.01 inch */ 0x00, 0x00, /* 8e reserved */ 0x00, /* 8f last calibration lamp density */ 0x00, /* 90 reserved */ 0x00, /* 91 lamp warmup max time */ 0x00, /* 92-93 window descriptor block length */ 0x00, 0x31, /* 94 optical resolution residue (1dpi) */ 0x00, /* 95 x_resolution residue (1dpi) */ 0x00, /* 96 y_resolution residue (1dpi) */ 0x00, /* 97 analog gamma table */ 0x00, /* 98-99 reserved */ 0x00, 0x00, /* 9a max calibration data lines */ 0x00, /* 9b fb/uta colour-sequnce-mode */ 0x01, /* 9c adf colour-sequnce-mode */ 0x01, /* 9d line-distance of ccd */ 0x08 }; static inquiry_blk inquiry_uc1200se = { "UC1200SE ",UC1200SE_INQUIRY, UC1200SE_INQUIRY_LEN }; sane-backends-1.0.29/backend/epsonds-jpeg.c0000666000000000000000000001203213615534521015330 00000000000000/* * epsonds-jpeg.c - Epson ESC/I-2 driver, JPEG support. * * Copyright (C) 2015 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" #include #include "epsonds.h" #include "epsonds-jpeg.h" #include "epsonds-ops.h" #define min(A,B) (((A)<(B)) ? (A) : (B)) typedef struct { struct jpeg_source_mgr pub; epsonds_scanner *s; JOCTET *buffer; SANE_Byte *linebuffer; SANE_Int linebuffer_size; SANE_Int linebuffer_index; } epsonds_src_mgr; METHODDEF(void) jpeg_init_source(j_decompress_ptr __sane_unused__ cinfo) { } METHODDEF(void) jpeg_term_source(j_decompress_ptr __sane_unused__ cinfo) { } METHODDEF(boolean) jpeg_fill_input_buffer(j_decompress_ptr cinfo) { epsonds_src_mgr *src = (epsonds_src_mgr *)cinfo->src; int avail, size; /* read from the scanner or the ring buffer */ avail = eds_ring_avail(src->s->current); if (avail == 0) { return FALSE; } /* read from scanner if no data? */ size = min(1024, avail); eds_ring_read(src->s->current, src->buffer, size); src->pub.next_input_byte = src->buffer; src->pub.bytes_in_buffer = size; return TRUE; } METHODDEF (void) jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes) { epsonds_src_mgr *src = (epsonds_src_mgr *)cinfo->src; if (num_bytes > 0) { while (num_bytes > (long)src->pub.bytes_in_buffer) { num_bytes -= (long)src->pub.bytes_in_buffer; jpeg_fill_input_buffer(cinfo); } src->pub.next_input_byte += (size_t) num_bytes; src->pub.bytes_in_buffer -= (size_t) num_bytes; } } SANE_Status eds_jpeg_start(epsonds_scanner *s) { epsonds_src_mgr *src; s->jpeg_cinfo.err = jpeg_std_error(&s->jpeg_err); jpeg_create_decompress(&s->jpeg_cinfo); s->jpeg_cinfo.src = (struct jpeg_source_mgr *)(*s->jpeg_cinfo.mem->alloc_small)((j_common_ptr)&s->jpeg_cinfo, JPOOL_PERMANENT, sizeof(epsonds_src_mgr)); memset(s->jpeg_cinfo.src, 0x00, sizeof(epsonds_src_mgr)); src = (epsonds_src_mgr *)s->jpeg_cinfo.src; src->s = s; src->buffer = (JOCTET *)(*s->jpeg_cinfo.mem->alloc_small)((j_common_ptr)&s->jpeg_cinfo, JPOOL_PERMANENT, 1024 * sizeof(JOCTET)); src->pub.init_source = jpeg_init_source; src->pub.fill_input_buffer = jpeg_fill_input_buffer; src->pub.skip_input_data = jpeg_skip_input_data; src->pub.resync_to_restart = jpeg_resync_to_restart; src->pub.term_source = jpeg_term_source; src->pub.bytes_in_buffer = 0; src->pub.next_input_byte = NULL; s->jpeg_header_seen = 0; return SANE_STATUS_GOOD; } SANE_Status eds_jpeg_read_header(epsonds_scanner *s) { epsonds_src_mgr *src = (epsonds_src_mgr *)s->jpeg_cinfo.src; if (jpeg_read_header(&s->jpeg_cinfo, TRUE)) { s->jdst = sanei_jpeg_jinit_write_ppm(&s->jpeg_cinfo); if (jpeg_start_decompress(&s->jpeg_cinfo)) { int size; DBG(3, "%s: w: %d, h: %d, components: %d\n", __func__, s->jpeg_cinfo.output_width, s->jpeg_cinfo.output_height, s->jpeg_cinfo.output_components); size = s->jpeg_cinfo.output_width * s->jpeg_cinfo.output_components * 1; src->linebuffer = (*s->jpeg_cinfo.mem->alloc_large)((j_common_ptr)&s->jpeg_cinfo, JPOOL_PERMANENT, size); src->linebuffer_size = 0; src->linebuffer_index = 0; s->jpeg_header_seen = 1; return SANE_STATUS_GOOD; } else { DBG(0, "%s: decompression failed\n", __func__); return SANE_STATUS_IO_ERROR; } } else { DBG(0, "%s: cannot read JPEG header\n", __func__); return SANE_STATUS_IO_ERROR; } } void eds_jpeg_finish(epsonds_scanner *s) { jpeg_destroy_decompress(&s->jpeg_cinfo); } void eds_jpeg_read(SANE_Handle handle, SANE_Byte *data, SANE_Int max_length, SANE_Int *length) { epsonds_scanner *s = handle; struct jpeg_decompress_struct cinfo = s->jpeg_cinfo; epsonds_src_mgr *src = (epsonds_src_mgr *)s->jpeg_cinfo.src; int l; *length = 0; /* copy from line buffer if available */ if (src->linebuffer_size && src->linebuffer_index < src->linebuffer_size) { *length = src->linebuffer_size - src->linebuffer_index; if (*length > max_length) *length = max_length; memcpy(data, src->linebuffer + src->linebuffer_index, *length); src->linebuffer_index += *length; return; } if (cinfo.output_scanline >= cinfo.output_height) { *length = 0; return; } /* scanlines of decompressed data will be in s->jdst->buffer * only one line at time is supported */ l = jpeg_read_scanlines(&cinfo, s->jdst->buffer, 1); if (l == 0) { return; } /* from s->jdst->buffer to linebuffer * linebuffer holds width * bytesperpixel */ (*s->jdst->put_pixel_rows)(&cinfo, s->jdst, 1, (char *)src->linebuffer); *length = cinfo.output_width * cinfo.output_components * 1; src->linebuffer_size = *length; src->linebuffer_index = 0; if (*length > max_length) *length = max_length; memcpy(data, src->linebuffer + src->linebuffer_index, *length); src->linebuffer_index += *length; } sane-backends-1.0.29/backend/plustek-pp_ptdrv.c0000666000000000000000000013450413615534521016266 00000000000000/* @file plustek-pp_ptdrv.c * @brief this is the driver interface * * based on sources acquired from Plustek Inc. * Copyright (C) 1998 Plustek Inc. * Copyright (C) 2000-2013 Gerhard Jaeger * also based on the work done by Rick Bronson * * History: * - 0.30 - initial version * - 0.31 - Added some comments * - added claiming/release of parallel port resources for this driver * - added scaling function for high resolution modes where dpix < dpiy * - 0.32 - Revised lamp-off behaviour * - removed function ptdrvIsLampOn * - fixed misbehaviour when using cat /dev/pt_drv * - moved parport-functions to module misc.c * - 0.33 - added parameter lOffonEnd * - revised parport concurrency * - removed calls to ps->PositionLamp * - 0.34 - no changes * - 0.35 - removed _PTDRV_PUT_SCANNER_MODEL from ioctl interface * - added Kevins' changes (MiscRestorePort) * - added parameter legal and function PtDrvLegalRequested() * - 0.36 - removed a bug in the shutdown function * - removed all OP600P specific stuff because of the Primax tests * - added version code to ioctl interface * - added new parameter mov - model override * - removed parameter legal * - removed function PtDrvLegalRequested * - changes, due to define renaming * - patch for OpticPro 4800P * - added multiple device support * - added proc fs support/also for Kernel2.4 * - 0.37 - cleanup work, moved the procfs stuff to file procfs.c * - and some definitions to plustek_scan.h * - moved MODELSTR to misc.c * - output of the error-code after initialization * - 0.38 - added P12 stuff * - removed function ptdrvIdleMode * - moved function ptdrvP96Calibration() to p48xxCalibration * - moved function ptdrvP98Calibration() to p9636Calibration * - added devfs support (patch by Gordon Heydon ) * - 0.39 - added schedule stuff after reading one line to have a better * system response in SPP modes * - added forceMode switch * - 0.40 - added MODULE_LICENSE stuff * - 0.41 - added _PTDRV_ADJUST functionality * - changed ioctl call to PutImage * - 0.42 - added _PTDRV_SETMAP functionality * - improved the cancel functionality * - 0.43 - added LINUX_26 stuff * - changed include names * - changed version string stuff * - 0.44 - added support for more recent kernels * - fix format string issues, as Long types default to int32_t * now * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #ifdef __KERNEL__ # include # include # ifdef CONFIG_DEVFS_FS # include # if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,69)) # define DEVFS_26_STYLE # endif # endif #endif #include "plustek-pp_scan.h" #ifdef __KERNEL__ # include #endif /****************************** static vars **********************************/ /* default port is at 0x378 */ static int port[_MAX_PTDEVS] = { 0x378, 0, 0, 0 }; #ifdef __KERNEL__ static pScanData PtDrvDevices[_MAX_PTDEVS] = { [0 ... (_MAX_PTDEVS-1)] = NULL}; /* default is 180 secs for lamp switch off */ static int lampoff[_MAX_PTDEVS] = { [0 ... (_MAX_PTDEVS-1)] = 180 }; /* warmup period for lamp (30 secs) */ static int warmup[_MAX_PTDEVS] = { [0 ... (_MAX_PTDEVS-1)] = 30 }; /* switch lamp off on unload (default = no)*/ static int lOffonEnd[_MAX_PTDEVS] = { [0 ... (_MAX_PTDEVS-1)] = 0 }; /* model override (0-->none) */ static UShort mov[_MAX_PTDEVS] = { [0 ... (_MAX_PTDEVS-1)] = 0 }; /* forceMode (0--> auto, 1: SPP, 2:EPP, others: auto) */ static UShort forceMode[_MAX_PTDEVS] = { [0 ... (_MAX_PTDEVS-1)] = 0 }; /* to use delayed I/O for each device */ static Bool slowIO[_MAX_PTDEVS] = { [0 ... (_MAX_PTDEVS-1)] = _FALSE }; #else static pScanData PtDrvDevices[_MAX_PTDEVS]= { NULL, NULL, NULL, NULL }; static int lampoff[_MAX_PTDEVS] = { 180, 180, 180, 180 }; static int warmup[_MAX_PTDEVS] = { 30, 30, 30, 30 }; static int lOffonEnd[_MAX_PTDEVS] = { 0, 0, 0, 0 }; static UShort mov[_MAX_PTDEVS] = { 0, 0, 0, 0 }; static UShort forceMode[_MAX_PTDEVS] = { 0, 0, 0, 0 }; #endif /* timers for warmup checks */ static TimerDef toTimer[_MAX_PTDEVS]; #ifndef __KERNEL__ static Bool PtDrvInitialized = _FALSE; #ifdef HAVE_SETITIMER static struct itimerval saveSettings; #endif #else static Bool deviceScanning = _FALSE; static struct timer_list tl[_MAX_PTDEVS]; /* for calculation of the timer expiration */ extern volatile unsigned long jiffies; /* the parameter interface */ #if ((LINUX_VERSION_CODE > 0x020111) && defined(MODULE)) MODULE_AUTHOR("Gerhard Jaeger "); MODULE_DESCRIPTION("Plustek parallelport-scanner driver"); /* addresses this 'new' license feature... */ #ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); #endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)) MODULE_PARM(port, "1-" __MODULE_STRING(_MAX_PTDEVS) "i"); MODULE_PARM(lampoff, "1-" __MODULE_STRING(_MAX_PTDEVS) "i"); MODULE_PARM(warmup,"1-" __MODULE_STRING(_MAX_PTDEVS) "i"); MODULE_PARM(lOffonEnd, "1-" __MODULE_STRING(_MAX_PTDEVS) "i"); MODULE_PARM(mov, "1-" __MODULE_STRING(_MAX_PTDEVS) "i"); MODULE_PARM(slowIO,"1-" __MODULE_STRING(_MAX_PTDEVS) "i"); MODULE_PARM(forceMode,"1-" __MODULE_STRING(_MAX_PTDEVS) "i"); #else static int array_len = _MAX_PTDEVS; module_param_array(port, int, &array_len, 0); module_param_array(lampoff, int, &array_len, 0); module_param_array(warmup, int, &array_len, 0); module_param_array(lOffonEnd, int, &array_len, 0); module_param_array(mov, ushort, &array_len, 0); module_param_array(slowIO, int, &array_len, 0); module_param_array(forceMode, ushort, &array_len, 0); #endif MODULE_PARM_DESC(port, "I/O base address of parport"); MODULE_PARM_DESC(lampoff, "Lamp-Off timer preset in seconds"); MODULE_PARM_DESC(warmup, "Minimum warmup time in seconds"); MODULE_PARM_DESC(lOffonEnd, "1 - switchoff lamp on unload"); MODULE_PARM_DESC(mov, "Modell-override switch"); MODULE_PARM_DESC(slowIO, "0 = Fast I/O, 1 = Delayed I/O"); MODULE_PARM_DESC(forceMode, "0 = use auto detection, " "1 = use SPP mode, 2 = use EPP mode"); #endif #if defined (CONFIG_DEVFS_FS) # ifndef (DEVFS_26_STYLE) static devfs_handle_t devfs_handle = NULL; # endif #else # ifdef LINUX_26 static class_t *ptdrv_class; # endif #endif /* * the module interface */ static int pt_drv_open ( struct inode *, struct file *); static CLOSETYPE pt_drv_close( struct inode *, struct file *); #ifdef LINUX_20 static int pt_drv_read( struct inode*, struct file*, char*, int ); static int pt_drv_write( struct inode*, struct file*, const char*, int ); #else static ssize_t pt_drv_read ( struct file *file, char *buffer, size_t count, loff_t *); static ssize_t pt_drv_write( struct file *file, const char *buffer, size_t tmp,loff_t *count); #endif #ifdef NOLOCK_IOCTL static long pt_drv_ioctl( struct file *, UInt, unsigned long ); #else static int pt_drv_ioctl( struct inode *, struct file *, UInt, unsigned long ); #endif /* * the driver interface */ #ifdef LINUX_20 static struct file_operations pt_drv_fops = { NULL, /* seek */ pt_drv_read, /* read */ pt_drv_write, /* write */ NULL, /* readdir */ NULL, /* select */ pt_drv_ioctl, /* ioctl */ NULL, /* mmap */ pt_drv_open, /* open */ pt_drv_close, /* release */ NULL, /* fsync */ NULL, /* fasync */ NULL, /* check_media_change */ NULL /* revalidate */ }; #else /* 2.2.x and higher stuff */ static struct file_operations pt_drv_fops = { #ifdef LINUX_24 owner: THIS_MODULE, #endif read: pt_drv_read, write: pt_drv_write, IOCTL: pt_drv_ioctl, open: pt_drv_open, release: pt_drv_close, }; #endif #endif /* guard __KERNEL */ /****************************** some prototypes ******************************/ static void ptdrvStartLampTimer( pScanData ps ); /****************************** local functions ******************************/ #ifdef __KERNEL__ /** depending on the device, return the data structure */ static pScanData get_pt_from_inode(struct inode *ip) { int minor = _MINOR(ip); /* * unit out of range */ if (minor >= _MAX_PTDEVS ) return NULL; return( PtDrvDevices[minor] ); } #endif /** copy user-space data into kernel memory */ static int getUserPtr(const pVoid useraddr, pVoid where, UInt size ) { int err = _OK; /* do parameter checks */ if((NULL == useraddr) || ( 0 == size)) return _E_INVALID; #ifdef __KERNEL__ if ((err = verify_area_20(VERIFY_READ, useraddr, size))) return err; #endif switch (size) { #ifdef __KERNEL__ case sizeof(u_char): GET_USER_RET(*(u_char *)where, (u_char *) useraddr, -EFAULT); break; case sizeof(u_short): GET_USER_RET(*(u_short *)where, (u_short *) useraddr, -EFAULT); break; case sizeof(u_long): GET_USER_RET(*(u_long *)where, (u_long *) useraddr, -EFAULT); break; default: if (copy_from_user(where, useraddr, size)) return -EFAULT; #else default: memcpy( where, useraddr, size ); #endif } return err; } /** copy kernel data into user mode address space */ static int putUserPtr( const pVoid ptr, pVoid useraddr, UInt size ) { int err = _OK; if (NULL == useraddr) return _E_INVALID; #ifdef __KERNEL__ if ((err = verify_area_20(VERIFY_WRITE, useraddr, size))) return err; if (copy_to_user(useraddr, ptr, size )) return -EFAULT; #else memcpy( useraddr, ptr, size ); #endif return err; } #ifndef __KERNEL__ static unsigned long copy_from_user( pVoid dest, pVoid src, unsigned long len ) { memcpy( dest, src, len ); return 0; } static unsigned long copy_to_user( pVoid dest, pVoid src, unsigned long len ) { memcpy( dest, src, len ); return 0; } #endif /** */ static int putUserVal(const ULong value, pVoid useraddr, UInt size) { #ifdef __KERNEL__ int err; #endif if (NULL == useraddr) return _E_INVALID; #ifdef __KERNEL__ if ((err = verify_area_20(VERIFY_WRITE, useraddr, size))) return err; #endif switch (size) { #ifdef __KERNEL__ case sizeof(u_char): PUT_USER_RET((u_char)value, (u_char *) useraddr, -EFAULT); break; case sizeof(u_short): PUT_USER_RET((u_short)value, (u_short *) useraddr, -EFAULT); break; case sizeof(u_long): PUT_USER_RET((u_long)value, (u_long *) useraddr, -EFAULT); break; #else case sizeof(UChar): *(pUChar)useraddr = (UChar)value; break; case sizeof(UShort): *(pUShort)useraddr = (UShort)value; break; case sizeof(ULong): *(pULong)useraddr = (ULong)value; break; #endif default: return _E_INVALID; } return 0; } /** switch lamp 0 on */ static void ptDrvSwitchLampOn( pScanData ps ) { DBG( DBG_LOW, "Switching lamp 0 on.\n" ); if( _IS_ASIC98(ps->sCaps.AsicID)) { ps->AsicReg.RD_ScanControl |= _SCAN_NORMALLAMP_ON; ps->bLastLampStatus = _SCAN_NORMALLAMP_ON; } else { ps->AsicReg.RD_ScanControl |= ps->bLampOn; ps->bLastLampStatus = ps->bLampOn; } IOCmdRegisterToScanner(ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl); } /** check the lamp warmup */ static void ptdrvLampWarmup( pScanData ps ) { Bool warmupNeeded; TimerDef timer; if( 0 == ps->warmup ) return; warmupNeeded = _FALSE; /* * do we have to warmup again ? Timer has not elapsed... */ if( _OK == MiscCheckTimer( &toTimer[ps->devno] )) { DBG( DBG_LOW, "Startup warmup needed!\n" ); warmupNeeded = _TRUE; } else { warmupNeeded = ps->fWarmupNeeded; } if( warmupNeeded ) { /* * correct lamp should have been switched on but * before doing anything else wait until warmup has been done */ DBG( DBG_LOW, "Waiting on warmup - %u s\n", ps->warmup ); MiscStartTimer( &timer, _SECOND * ps->warmup ); while( !MiscCheckTimer( &timer )) { /* on break, we setup the initial timer again... */ if( _FALSE == ps->fScanningStatus ) { MiscStartTimer( &toTimer[ps->devno], (_SECOND * ps->warmup)); return; } }; } #ifdef DEBUG else { DBG( DBG_LOW, "No warm-up needed \n" ); } #endif /* * start a timer here again with only a second timeout * because we need this one only for startup (Force timeout!!) */ MiscStartTimer( &toTimer[ps->devno], _SECOND ); } /** */ #ifdef __KERNEL__ static void ptdrvLampTimerIrq( unsigned long ptr ) #else static void ptdrvLampTimerIrq( int sig_num ) #endif { pScanData ps; DBG( DBG_HIGH, "!! IRQ !! Lamp-Timer stopped.\n" ); #ifdef __KERNEL__ ps = (pScanData)ptr; #else _VAR_NOT_USED( sig_num ); ps = PtDrvDevices[0]; #endif /* * paranoia check! */ if( NULL == ps ) return; if( _NO_BASE == ps->sCaps.wIOBase ) return; if( _IS_ASIC98(ps->sCaps.AsicID)) { ps->AsicReg.RD_ScanControl &= ~_SCAN_LAMPS_ON; } else { ps->AsicReg.RD_ScanControl &= ~_SCAN_LAMP_ON; } /* force warmup... */ ps->bLastLampStatus = 0xFF; /* * claim parallel port if necessary... * if the port is busy, restart the timer */ if( _OK != MiscClaimPort(ps)) { ptdrvStartLampTimer( ps ); return; } IOCmdRegisterToScanner( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl ); MiscReleasePort(ps); } /** */ static void ptdrvStartLampTimer( pScanData ps ) { #ifndef __KERNEL__ sigset_t block, pause_mask; struct sigaction s; #ifdef HAVE_SETITIMER struct itimerval interval; #endif /* block SIGALRM */ sigemptyset( &block ); sigaddset ( &block, SIGALRM ); sigprocmask( SIG_BLOCK, &block, &pause_mask ); /* setup handler */ sigemptyset( &s.sa_mask ); sigaddset ( &s.sa_mask, SIGINT ); s.sa_flags = 0; s.sa_handler = ptdrvLampTimerIrq; if( sigaction( SIGALRM, &s, NULL ) < 0 ) { DBG(DBG_HIGH,"pt_drv%u: Can't setup timer-irq handler\n",ps->devno); } sigprocmask( SIG_UNBLOCK, &block, &pause_mask ); #ifdef HAVE_SETITIMER /* * define a one-shot timer */ interval.it_value.tv_usec = 0; interval.it_value.tv_sec = ps->lampoff; interval.it_interval.tv_usec = 0; interval.it_interval.tv_sec = 0; if( 0 != ps->lampoff ) setitimer( ITIMER_REAL, &interval, &saveSettings ); #else alarm( ps->lampoff ); #endif #else init_timer( &tl[ps->devno] ); /* timeout val in seconds */ tl[ps->devno].expires = jiffies + ps->lampoff * HZ; tl[ps->devno].data = (unsigned long)ps; tl[ps->devno].function = ptdrvLampTimerIrq; if( 0 != ps->lampoff ) add_timer( &tl[ps->devno] ); #endif DBG( DBG_HIGH, "Lamp-Timer started!\n" ); } /** */ static void ptdrvStopLampTimer( pScanData ps ) { #ifndef __KERNEL__ sigset_t block, pause_mask; /* block SIGALRM */ sigemptyset( &block ); sigaddset ( &block, SIGALRM ); sigprocmask( SIG_BLOCK, &block, &pause_mask ); #ifdef HAVE_SETITIMER if( 0 != ps->lampoff ) setitimer( ITIMER_REAL, &saveSettings, NULL ); #else _VAR_NOT_USED( ps ); alarm(0); #endif #else if( 0 != ps->lampoff ) del_timer( &tl[ps->devno] ); #endif DBG( DBG_HIGH, "Lamp-Timer stopped!\n" ); } /** claim and initialize the requested port */ static int ptdrvOpen( pScanData ps, int portBase ) { int retval; DBG( DBG_HIGH, "ptdrvOpen(port=0x%x)\n", (int32_t)portBase ); if( NULL == ps ) return _E_NULLPTR; /* * claim port resources... */ retval = MiscClaimPort(ps); if( _OK != retval ) return retval; return MiscInitPorts( ps, portBase ); } /** free used memory (if necessary) * restore the parallel port settings and release the port */ static int ptdrvClose( pScanData ps ) { DBG( DBG_HIGH, "ptdrvClose()\n" ); if( NULL == ps ) return _E_NULLPTR; /* * should be cleared by ioctl(close) */ if ( NULL != ps->driverbuf ) { DBG( DBG_LOW, "*** cleanup buffers ***\n" ); _VFREE( ps->driverbuf ); ps->driverbuf = NULL; } if ( NULL != ps->Shade.pHilight ) { _VFREE( ps->Shade.pHilight ); ps->Shade.pHilight = NULL; } /* * restore/release port resources... */ MiscRestorePort( ps ); MiscReleasePort( ps ); return _OK; } /** will be called during OPEN_DEVICE ioctl call */ static int ptdrvOpenDevice( pScanData ps ) { int retval, iobase; UShort asic; UChar lastStat; UShort lastMode; ULong devno; #ifdef __KERNEL__ UShort flags; struct pardevice *pd; struct parport *pp; ProcDirDef procDir; #else int pd; #endif /* * push some values from the struct */ #ifdef __KERNEL__ flags = ps->flags; pp = ps->pp; procDir = ps->procDir; #endif pd = ps->pardev; iobase = ps->sCaps.wIOBase; asic = ps->sCaps.AsicID; lastStat = ps->bLastLampStatus; lastMode = ps->IO.lastPortMode; devno = ps->devno; /* * reinit the show */ ptdrvStopLampTimer( ps ); MiscReinitStruct ( ps ); /* * pop the val(s) */ #ifdef __KERNEL__ ps->flags = flags; ps->pp = pp; ps->procDir = procDir; #endif ps->pardev = pd; ps->bLastLampStatus = lastStat; ps->IO.lastPortMode = lastMode; ps->devno = devno; #ifdef __KERNEL__ if( _TRUE == slowIO[devno] ) { DBG( DBG_LOW, "Using slow I/O\n" ); ps->IO.slowIO = _TRUE; ps->IO.fnOut = IOOutDelayed; ps->IO.fnIn = IOInDelayed; } else { DBG( DBG_LOW, "Using fast I/O\n" ); ps->IO.slowIO = _FALSE; ps->IO.fnOut = IOOut; ps->IO.fnIn = IOIn; } #endif ps->ModelOverride = mov[devno]; ps->warmup = warmup[devno]; ps->lampoff = lampoff[devno]; ps->lOffonEnd = lOffonEnd[devno]; ps->IO.forceMode = forceMode[devno]; /* * try to find scanner again */ retval = ptdrvOpen( ps, iobase ); if( _OK == retval ) retval = DetectScanner( ps, asic ); else ptdrvStartLampTimer( ps ); return retval; } /*............................................................................. * initialize the driver * allocate memory for the ScanData structure and do some presets */ static int ptdrvInit( int devno ) { int retval; pScanData ps; DBG( DBG_HIGH, "ptdrvInit(%u)\n", devno ); if( devno >= _MAX_PTDEVS ) return _E_NO_DEV; /* * allocate memory for our large ScanData-structure */ ps = MiscAllocAndInitStruct(); if( NULL == ps ) { return _E_ALLOC; } #ifdef __KERNEL__ if( _TRUE == slowIO[devno] ) { DBG( DBG_LOW, "Using slow I/O\n" ); ps->IO.slowIO = _TRUE; ps->IO.fnOut = IOOutDelayed; ps->IO.fnIn = IOInDelayed; } else { DBG( DBG_LOW, "Using fast I/O\n" ); ps->IO.slowIO = _FALSE; ps->IO.fnOut = IOOut; ps->IO.fnIn = IOIn; } #endif ps->ModelOverride = mov[devno]; ps->warmup = warmup[devno]; ps->lampoff = lampoff[devno]; ps->lOffonEnd = lOffonEnd[devno]; ps->IO.forceMode = forceMode[devno]; ps->devno = devno; /* assign it right here, to allow correct shutdown */ PtDrvDevices[devno] = ps; /* * try to register the port */ retval = MiscRegisterPort( ps, port[devno] ); if( _OK == retval ) { retval = ptdrvOpen( ps, port[devno] ); } /* * try to detect a scanner... */ if( _OK == retval ) { retval = DetectScanner( ps, 0 ); /* do this here before releasing the port */ if( _OK == retval ) { ptDrvSwitchLampOn( ps ); } ptdrvClose( ps ); } if( _OK == retval ) { #ifdef __KERNEL__ _PRINT( "pt_drv%u: %s found on port 0x%04x\n", devno, MiscGetModelName(ps->sCaps.Model), ps->IO.pbSppDataPort ); #else DBG( DBG_LOW, "pt_drv%u: %s found\n", devno, MiscGetModelName(ps->sCaps.Model)); #endif /* * initialize the timespan timer */ MiscStartTimer( &toTimer[ps->devno], (_SECOND * ps->warmup)); if( 0 == ps->lampoff ) #ifdef __KERNEL__ _PRINT( #else DBG( DBG_LOW, #endif "pt_drv%u: Lamp-Timer switched off.\n", devno ); else { #ifdef __KERNEL__ _PRINT( #else DBG( DBG_LOW, #endif "pt_drv%u: Lamp-Timer set to %u seconds.\n", devno, ps->lampoff ); } #ifdef __KERNEL__ _PRINT( #else DBG( DBG_LOW, #endif "pt_drv%u: WarmUp period set to %u seconds.\n", devno, ps->warmup ); if( 0 == ps->lOffonEnd ) { #ifdef __KERNEL__ _PRINT( #else DBG( DBG_LOW, #endif "pt_drv%u: Lamp untouched on driver unload.\n", devno ); } else { #ifdef __KERNEL__ _PRINT( #else DBG( DBG_LOW, #endif "pt_drv%u: Lamp switch-off on driver unload.\n", devno ); } ptdrvStartLampTimer( ps ); } return retval; } /*............................................................................. * shutdown the driver: * switch the lights out * stop the motor * free memory */ static int ptdrvShutdown( pScanData ps ) { int devno; DBG( DBG_HIGH, "ptdrvShutdown()\n" ); if( NULL == ps ) return _E_NULLPTR; devno = ps->devno; DBG( DBG_HIGH, "cleanup device %u\n", devno ); if( _NO_BASE != ps->sCaps.wIOBase ) { ptdrvStopLampTimer( ps ); if( _OK == MiscClaimPort(ps)) { ps->PutToIdleMode( ps ); if( 0 != ps->lOffonEnd ) { if( _IS_ASIC98(ps->sCaps.AsicID)) { ps->AsicReg.RD_ScanControl &= ~_SCAN_LAMPS_ON; } else { ps->AsicReg.RD_ScanControl &= ~_SCAN_LAMP_ON; } IOCmdRegisterToScanner( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl ); } } MiscReleasePort( ps ); } /* unregister the driver */ MiscUnregisterPort( ps ); _KFREE( ps ); if( devno < _MAX_PTDEVS ) PtDrvDevices[devno] = NULL; return _OK; } /*............................................................................. * the IOCTL interface */ static int ptdrvIoctl( pScanData ps, UInt cmd, pVoid arg ) { UShort dir; UShort version; UInt size; ULong argVal; int cancel; int retval; /* * do the preliminary stuff here */ if( NULL == ps ) return _E_NULLPTR; retval = _OK; dir = _IOC_DIR(cmd); size = _IOC_SIZE(cmd); if ((_IOC_WRITE == dir) && size && (size <= sizeof(ULong))) { if (( retval = getUserPtr( arg, &argVal, size))) { DBG( DBG_HIGH, "ioctl() failed - result = %i\n", retval ); return retval; } } switch( cmd ) { /* open */ case _PTDRV_OPEN_DEVICE: DBG( DBG_LOW, "ioctl(_PTDRV_OPEN_DEVICE)\n" ); if (copy_from_user(&version, arg, sizeof(UShort))) return _E_FAULT; if( _PTDRV_IOCTL_VERSION != version ) { DBG( DBG_HIGH, "Version mismatch: Backend=0x%04X(0x%04X)", version, _PTDRV_IOCTL_VERSION ); return _E_VERSION; } retval = ptdrvOpenDevice( ps ); break; /* close */ case _PTDRV_CLOSE_DEVICE: DBG( DBG_LOW, "ioctl(_PTDRV_CLOSE_DEVICE)\n" ); if ( NULL != ps->driverbuf ) { DBG( DBG_LOW, "*** cleanup buffers ***\n" ); _VFREE( ps->driverbuf ); ps->driverbuf = NULL; } if ( NULL != ps->Shade.pHilight ) { _VFREE( ps->Shade.pHilight ); ps->Shade.pHilight = NULL; } ps->PutToIdleMode( ps ); ptdrvStartLampTimer( ps ); break; /* get caps - no scanner connection necessary */ case _PTDRV_GET_CAPABILITIES: DBG( DBG_LOW, "ioctl(_PTDRV_GET_CAPABILITES)\n" ); return putUserPtr( &ps->sCaps, arg, size); break; /* get lens-info - no scanner connection necessary */ case _PTDRV_GET_LENSINFO: DBG( DBG_LOW, "ioctl(_PTDRV_GET_LENSINFO)\n" ); return putUserPtr( &ps->LensInf, arg, size); break; /* put the image info - no scanner connection necessary */ case _PTDRV_PUT_IMAGEINFO: { short tmpcx, tmpcy; ImgDef img; DBG( DBG_LOW, "ioctl(_PTDRV_PUT_IMAGEINFO)\n" ); if (copy_from_user( &img, (pImgDef)arg, size)) return _E_FAULT; tmpcx = (short)img.crArea.cx; tmpcy = (short)img.crArea.cy; if(( 0 >= tmpcx ) || ( 0 >= tmpcy )) { DBG( DBG_LOW, "CX or CY <= 0!!\n" ); return _E_INVALID; } _ASSERT( ps->GetImageInfo ); ps->GetImageInfo( ps, &img ); } break; /* get crop area - no scanner connection necessary */ case _PTDRV_GET_CROPINFO: { CropInfo outBuffer; pCropInfo pcInf = &outBuffer; DBG( DBG_LOW, "ioctl(_PTDRV_GET_CROPINFO)\n" ); memset( pcInf, 0, sizeof(CropInfo)); pcInf->dwPixelsPerLine = ps->DataInf.dwAppPixelsPerLine; pcInf->dwBytesPerLine = ps->DataInf.dwAppBytesPerLine; pcInf->dwLinesPerArea = ps->DataInf.dwAppLinesPerArea; return putUserPtr( pcInf, arg, size ); } break; /* adjust the driver settings */ case _PTDRV_ADJUST: { PPAdjDef adj; DBG( DBG_LOW, "ioctl(_PTDRV_ADJUST)\n" ); if (copy_from_user(&adj, (pPPAdjDef)arg, sizeof(PPAdjDef))) return _E_FAULT; DBG( DBG_LOW, "Adjusting device %u\n", ps->devno ); DBG( DBG_LOW, "warmup: %i\n", adj.warmup ); DBG( DBG_LOW, "lampOff: %i\n", adj.lampOff ); DBG( DBG_LOW, "lampOffOnEnd: %i\n", adj.lampOffOnEnd ); if( ps->devno < _MAX_PTDEVS ) { if( adj.warmup >= 0 ) { warmup[ps->devno] = adj.warmup; ps->warmup = adj.warmup; } if( adj.lampOff >= 0 ) { lampoff[ps->devno] = adj.lampOff; ps->lampoff = adj.lampOff; } if( adj.lampOffOnEnd >= 0 ) { lOffonEnd[ps->devno] = adj.lampOffOnEnd; ps->lOffonEnd = adj.lampOffOnEnd; } } } break; /* set a specific map (r,g,b or gray) */ case _PTDRV_SETMAP: { int i, x_len; MapDef map; DBG( DBG_LOW, "ioctl(_PTDRV_SETMAP)\n" ); if (copy_from_user( &map, (pMapDef)arg, sizeof(MapDef))) return _E_FAULT; DBG( DBG_LOW, "maplen=%u, mapid=%u, addr=0x%08lx\n", map.len, map.map_id, (u_long)map.map ); x_len = 256; if( _IS_ASIC98(ps->sCaps.AsicID)) x_len = 4096; /* check for 0 pointer and len */ if((NULL == map.map) || (x_len != map.len)) { DBG( DBG_LOW, "map pointer == 0, or map len invalid!!\n" ); return _E_INVALID; } if( _MAP_MASTER == map.map_id ) { for( i = 0; i < 3; i++ ) { if (copy_from_user((pVoid)&ps->a_bMapTable[x_len * i], map.map, x_len )) { return _E_FAULT; } } } else { u_long idx = 0; if( map.map_id == _MAP_GREEN ) idx = 1; if( map.map_id == _MAP_BLUE ) idx = 2; if (copy_from_user((pVoid)&ps->a_bMapTable[x_len * idx], map.map, x_len )) { return _E_FAULT; } } /* here we adjust the maps according to * the brightness and contrast settings */ MapAdjust( ps, map.map_id ); } break; /* set environment - no scanner connection necessary */ case _PTDRV_SET_ENV: { ScanInfo sInf; DBG( DBG_LOW, "ioctl(_PTDRV_SET_ENV)\n" ); if (copy_from_user(&sInf, (pScanInfo)arg, sizeof(ScanInfo))) return _E_FAULT; /* * to make the OpticPro 4800P work, we need to invert the * Inverse flag */ if( _ASIC_IS_96001 == ps->sCaps.AsicID ) { if( SCANDEF_Inverse & sInf.ImgDef.dwFlag ) sInf.ImgDef.dwFlag &= ~SCANDEF_Inverse; else sInf.ImgDef.dwFlag |= SCANDEF_Inverse; } _ASSERT( ps->SetupScanSettings ); retval = ps->SetupScanSettings( ps, &sInf ); /* CHANGE preset map here */ if( _OK == retval ) { MapInitialize ( ps ); MapSetupDither( ps ); ps->DataInf.dwVxdFlag |= _VF_ENVIRONMENT_READY; if (copy_to_user((pScanInfo)arg, &sInf, sizeof(ScanInfo))) return _E_FAULT; } } break; /* start scan */ case _PTDRV_START_SCAN: { StartScan outBuffer; pStartScan pstart = (pStartScan)&outBuffer; DBG( DBG_LOW, "ioctl(_PTDRV_START_SCAN)\n" ); retval = IOIsReadyForScan( ps ); if( _OK == retval ) { ps->dwDitherIndex = 0; ps->fScanningStatus = _TRUE; pstart->dwBytesPerLine = ps->DataInf.dwAppBytesPerLine; pstart->dwLinesPerScan = ps->DataInf.dwAppLinesPerArea; pstart->dwFlag = ps->DataInf.dwScanFlag; ps->DataInf.dwVxdFlag |= _VF_FIRSTSCANLINE; ps->DataInf.dwScanFlag&=~(_SCANNER_SCANNING|_SCANNER_PAPEROUT); if (copy_to_user((pStartScan)arg, pstart, sizeof(StartScan))) return _E_FAULT; } } break; /* stop scan */ case _PTDRV_STOP_SCAN: DBG( DBG_LOW, "ioctl(_PTDRV_STOP_SCAN)\n" ); if (copy_from_user(&cancel, arg, sizeof(short))) return _E_FAULT; /* we may use this to abort scanning! */ ps->fScanningStatus = _FALSE; /* when using this to cancel, then that's all */ if( _FALSE == cancel ) { MotorToHomePosition( ps ); ps->DataInf.dwAppLinesPerArea = 0; ps->DataInf.dwScanFlag &= ~_SCANNER_SCANNING; /* if environment was never set */ if (!(ps->DataInf.dwVxdFlag & _VF_ENVIRONMENT_READY)) retval = _E_SEQUENCE; ps->DataInf.dwVxdFlag &= ~_VF_ENVIRONMENT_READY; } else { DBG( DBG_LOW, "CANCEL Mode set\n" ); } retval = putUserVal(retval, arg, size); break; /* read the flag status register, when reading the action button, you must * only do this call and none of the other ioctl's * like open, etc or it will always show up as "1" */ case _PTDRV_ACTION_BUTTON: DBG( DBG_LOW, "ioctl(_PTDRV_ACTION_BUTTON)\n" ); IODataRegisterFromScanner( ps, ps->RegStatus ); retval = putUserVal( argVal, arg, size ); break; default: retval = _E_NOSUPP; break; } return retval; } /*............................................................................. * read the data */ static int ptdrvRead( pScanData ps, pUChar buffer, int count ) { pUChar scaleBuf; ULong dwLinesRead = 0; int retval = _OK; #ifdef _ASIC_98001_SIM #ifdef __KERNEL__ _PRINT( #else DBG( DBG_LOW, #endif "pt_drv : Software-Emulation active, can't read!\n" ); return _E_INVALID; #endif if((NULL == buffer) || (NULL == ps)) { #ifdef __KERNEL__ _PRINT( #else DBG( DBG_HIGH, #endif "pt_drv : Internal NULL-pointer!\n" ); return _E_NULLPTR; } if( 0 == count ) { #ifdef __KERNEL__ _PRINT( #else DBG( DBG_HIGH, #endif "pt_drv%u: reading 0 bytes makes no sense!\n", ps->devno ); return _E_INVALID; } if( _FALSE == ps->fScanningStatus ) return _E_ABORT; /* * has the environment been set ? * this should prevent the driver from causing a seg-fault * when using the cat /dev/pt_drv command! */ if (!(ps->DataInf.dwVxdFlag & _VF_ENVIRONMENT_READY)) { #ifdef __KERNEL__ _PRINT( #else DBG( DBG_HIGH, #endif "pt_drv%u: Cannot read, driver not initialized!\n",ps->devno); return _E_SEQUENCE; } /* * get some memory */ ps->Scan.bp.pMonoBuf = _KALLOC( ps->DataInf.dwAppPhyBytesPerLine, GFP_KERNEL); if ( NULL == ps->Scan.bp.pMonoBuf ) { #ifdef __KERNEL__ _PRINT( #else DBG( DBG_HIGH, #endif "pt_drv%u: Not enough memory available!\n", ps->devno ); return _E_ALLOC; } /* if we have to do some scaling, we need another buffer... */ if( ps->DataInf.XYRatio > 1000 ) { scaleBuf = _KALLOC( ps->DataInf.dwAppPhyBytesPerLine, GFP_KERNEL); if ( NULL == scaleBuf ) { _KFREE( ps->Scan.bp.pMonoBuf ); #ifdef __KERNEL__ _PRINT( #else DBG( DBG_HIGH, #endif "pt_drv%u: Not enough memory available!\n", ps->devno ); return _E_ALLOC; } } else { scaleBuf = NULL; } DBG( DBG_LOW, "PtDrvRead(%u bytes)*****************\n", count ); DBG( DBG_LOW, "MonoBuf = 0x%08lx[%u], scaleBuf = 0x%lx\n", (unsigned long)ps->Scan.bp.pMonoBuf, ps->DataInf.dwAppPhyBytesPerLine, (unsigned long)scaleBuf ); /* * in case of a previous problem, move the sensor back home */ MotorToHomePosition( ps ); if( _FALSE == ps->fScanningStatus ) { retval = _E_ABORT; goto ReadFinished; } dwLinesRead = 0; /* * first of all calibrate the show */ ps->bMoveDataOutFlag = _DataInNormalState; ps->fHalfStepTableFlag = _FALSE; ps->fReshaded = _FALSE; ps->fScanningStatus = _TRUE; if( _ASIC_IS_98003 == ps->sCaps.AsicID ) ps->Scan.fRefreshState = _FALSE; else ps->Scan.fRefreshState = _TRUE; ptdrvLampWarmup( ps ); if( _FALSE == ps->fScanningStatus ) { retval = _E_ABORT; goto ReadFinished; } retval = ps->Calibration( ps ); if( _OK != retval ) { #ifdef __KERNEL__ _PRINT( #else DBG( DBG_HIGH, #endif "pt_drv%u: calibration failed, result = %i\n", ps->devno, retval ); goto ReadFinished; } if( _ASIC_IS_98003 == ps->sCaps.AsicID ) { ps->OpenScanPath( ps ); MotorP98003ForceToLeaveHomePos( ps ); } _ASSERT(ps->SetupScanningCondition); ps->SetupScanningCondition(ps); if( _ASIC_IS_98003 != ps->sCaps.AsicID ) { ps->SetMotorSpeed( ps, ps->bCurrentSpeed, _TRUE ); IOSetToMotorRegister( ps ); } else { ps->WaitForPositionY( ps ); _DODELAY( 70 ); ps->Scan.bOldScanState = IOGetScanState( ps, _TRUE ) & _SCANSTATE_MASK; } ps->DataInf.dwScanFlag |= _SCANNER_SCANNING; if( _FALSE == ps->fScanningStatus ) { DBG( DBG_HIGH, "read aborted!\n" ); retval = _E_ABORT; goto ReadFinished; } /* * now get the picture data */ DBG( DBG_HIGH, "dwAppLinesPerArea = %d\n", ps->DataInf.dwAppLinesPerArea); DBG( DBG_HIGH, "dwAppBytesPerLine = %d\n", ps->DataInf.dwAppBytesPerLine); /* HEINER: A3I ps->bMoveDataOutFlag = _DataFromStopState; */ if ( 0 != ps->DataInf.dwAppLinesPerArea ) { ps->Scan.dwLinesToRead = count / ps->DataInf.dwAppBytesPerLine; if( ps->Scan.dwLinesToRead ) { DBG( DBG_HIGH, "dwLinesToRead = %d\n", ps->Scan.dwLinesToRead ); if( ps->Scan.dwLinesToRead > ps->DataInf.dwAppLinesPerArea ) ps->Scan.dwLinesToRead = ps->DataInf.dwAppLinesPerArea; ps->DataInf.dwAppLinesPerArea -= ps->Scan.dwLinesToRead; if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) buffer += ((ps->Scan.dwLinesToRead - 1) * ps->DataInf.dwAppBytesPerLine); if (ps->DataInf.dwVxdFlag & _VF_DATATOUSERBUFFER) ps->DataInf.pCurrentBuffer = ps->Scan.bp.pMonoBuf; while(ps->fScanningStatus && ps->Scan.dwLinesToRead) { _ASSERT(ps->ReadOneImageLine); if (!ps->ReadOneImageLine(ps)) { ps->fScanningStatus = _FALSE; DBG( DBG_HIGH, "ReadOneImageLine() failed at line %u!\n", dwLinesRead ); break; } /* * as we might scan images that exceed the CCD-capabilities * in x-resolution, we have to enlarge the line data * i.e.: scanning at 1200dpi generates on a P9636 600 dpi in * x-direction but 1200dpi in y-direction... */ if( NULL != scaleBuf ) { ScaleX( ps, ps->Scan.bp.pMonoBuf, scaleBuf ); if (copy_to_user( buffer, scaleBuf, ps->DataInf.dwAppPhyBytesPerLine)) { return _E_FAULT; } } else { if (copy_to_user( buffer, ps->Scan.bp.pMonoBuf, ps->DataInf.dwAppPhyBytesPerLine)) { return _E_FAULT; } } buffer += ps->Scan.lBufferAdjust; dwLinesRead++; ps->Scan.dwLinesToRead--; /* needed, esp. to avoid freezing the system in SPP mode */ #ifdef __KERNEL__ schedule(); /*#else sched_yield(); */ #endif } if (ps->fScanningStatus) { if( _IS_ASIC96(ps->sCaps.AsicID)) MotorP96SetSpeedToStopProc(ps); } else { if (ps->DataInf.dwScanFlag & (SCANDEF_StopWhenPaperOut | SCANDEF_UnlimitLength)) { ps->DataInf.dwAppLinesPerArea = 0; } else { if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) buffer -= (ps->DataInf.dwAppBytesPerLine * (ps->Scan.dwLinesToRead - 1)); memset( buffer, 0xff, ps->Scan.dwLinesToRead * ps->DataInf.dwAppBytesPerLine ); dwLinesRead += ps->Scan.dwLinesToRead; } } } else { retval = _E_INTERNAL; } } if( _FALSE == ps->fScanningStatus ) { DBG( DBG_HIGH, "read aborted!\n" ); retval = _E_ABORT; } ReadFinished: if( _ASIC_IS_98003 == ps->sCaps.AsicID ) ps->CloseScanPath( ps ); if( NULL != ps->Scan.bp.pMonoBuf ) _KFREE( ps->Scan.bp.pMonoBuf ); if( NULL != scaleBuf ) _KFREE( scaleBuf ); /* * on success return number of bytes red */ if ( _OK == retval ) return (ps->DataInf.dwAppPhyBytesPerLine * dwLinesRead); return retval; } /*************************** the module interface ****************************/ #ifdef __KERNEL__ /* the kernel module interface */ /* Designed to be used as a module */ #ifdef MODULE /*............................................................................. * gets called upon module initialization */ #ifdef LINUX_26 static int __init ptdrv_init( void ) #else int init_module( void ) #endif { UInt devCount; UInt i; int retval = _OK; int result = _OK; #if (defined(CONFIG_DEVFS_FS) && !defined(DEVFS_26_STYLE)) char controlname[24]; #endif # ifdef LINUX_26 char devname[20]; #endif DBG( DBG_HIGH, "*********************************************\n" ); DBG( DBG_HIGH, "pt_drv: init_module()\n" ); #if (defined(CONFIG_DEVFS_FS) && !defined(DEVFS_26_STYLE)) devfs_handle = devfs_mk_dir(NULL, "scanner", NULL); if( devfs_register_chrdev(_PTDRV_MAJOR, _DRV_NAME, &pt_drv_fops)) { #else if( register_chrdev(_PTDRV_MAJOR, _DRV_NAME, &pt_drv_fops)) { #endif _PRINT(KERN_INFO "pt_drv: unable to get major %d for pt_drv devices\n", _PTDRV_MAJOR); return -EIO; } printk( KERN_INFO "pt_drv : driver version "_PTDRV_VERSTR"\n" ); #if !defined (CONFIG_DEVFS_FS) && defined (LINUX_26) ptdrv_class = class_create(THIS_MODULE, "scanner"); if (IS_ERR(ptdrv_class)) goto out_devfs; #endif /* register the proc_fs */ ProcFsInitialize(); /* go through the list of defined ports and try to find a device */ devCount = 0; for( i = 0; i < _MAX_PTDEVS; i++ ) { if( 0 != port[i] ) { result = ptdrvInit( i ); if ( _OK == result ) { PtDrvDevices[i]->flags |= _PTDRV_INITALIZED; #ifdef CONFIG_DEVFS_FS # ifndef DEVFS_26_STYLE sprintf( controlname, "scanner/pt_drv%d", devCount ); devfs_register( NULL, controlname, DEVFS_FL_DEFAULT, _PTDRV_MAJOR, 0, (S_IFCHR | S_IRUGO | S_IWUGO | S_IFCHR), &pt_drv_fops, NULL ); # else /* DEVFS_26_STYLE */ devfs_mk_cdev(MKDEV(_PTDRV_MAJOR, devCount), (S_IFCHR | S_IRUGO | S_IWUGO | S_IFCHR), "scanner/pt_drv%d", devCount); # endif #else # ifdef LINUX_26 sprintf(devname, "pt_drv%d", devCount); CLASS_DEV_CREATE(ptdrv_class, MKDEV(_PTDRV_MAJOR, devCount), NULL, devname); # endif /* LINUX_26 */ #endif /* CONFIG_DEVFS_FS */ ProcFsRegisterDevice( PtDrvDevices[i] ); devCount++; } else { retval = result; ptdrvShutdown( PtDrvDevices[i] ); PtDrvDevices[i] = NULL; } } } /* * if something went wrong, shutdown all... */ if( devCount == 0 ) { #if !defined (CONFIG_DEVFS_FS) && defined (LINUX_26) out_devfs: class_destroy(ptdrv_class); #endif #if (defined(CONFIG_DEVFS_FS) && !defined(DEVFS_26_STYLE)) devfs_unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME ); #else unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME ); #endif ProcFsShutdown(); #ifdef __KERNEL__ _PRINT( KERN_INFO "pt_drv : no device(s) detected, (%i)\n", retval ); #endif } else { DBG( DBG_HIGH, "pt_drv : init done, %u device(s) found\n", devCount ); retval = _OK; } DBG( DBG_HIGH, "---------------------------------------------\n" ); deviceScanning = _FALSE; return retval; } /*............................................................................. * cleanup the show */ #ifdef LINUX_26 static void __exit ptdrv_exit( void ) #else void cleanup_module( void ) #endif { UInt i; pScanData ps; #if (defined(CONFIG_DEVFS_FS) && !defined(DEVFS_26_STYLE)) char controlname[24]; devfs_handle_t master; #endif DBG( DBG_HIGH, "pt_drv: cleanup_module()\n" ); for ( i = 0; i < _MAX_PTDEVS; i++ ) { ps = PtDrvDevices[i]; PtDrvDevices[i] = NULL; if ( NULL != ps ) { #ifdef CONFIG_DEVFS_FS # ifndef DEVFS_26_STYLE sprintf( controlname, "scanner/pt_drv%d", i ); master = devfs_find_handle( NULL,controlname, 0, 0, DEVFS_SPECIAL_CHR, 0 ); devfs_unregister( master ); # else devfs_remove("scanner/pt_drv%d", i); # endif #else # ifdef LINUX_26 CLASS_DEV_DESTROY(ptdrv_class, MKDEV(_PTDRV_MAJOR, i)); # endif /* LINUX_26 */ #endif /* CONFIG_DEVFS_FS */ ptdrvShutdown( ps ); ProcFsUnregisterDevice( ps ); } } #if (defined(CONFIG_DEVFS_FS) && !defined(DEVFS_26_STYLE)) devfs_unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME ); #else unregister_chrdev( _PTDRV_MAJOR, _DRV_NAME ); #endif ProcFsShutdown(); #if !defined (CONFIG_DEVFS_FS) && defined (LINUX_26) class_destroy(ptdrv_class); #endif DBG( DBG_HIGH, "pt_drv: cleanup done.\n" ); DBG( DBG_HIGH, "*********************************************\n" ); } #ifdef LINUX_26 module_init(ptdrv_init); module_exit(ptdrv_exit); #endif #endif /*MODULE*/ /*............................................................................. * device open... */ static int pt_drv_open(struct inode *inode, struct file *file) { pScanData ps; DBG( DBG_HIGH, "pt_drv_open()\n" ); ps = get_pt_from_inode(inode); if ( NULL == ps ) { return(-ENXIO); } /* device not found ? */ if (!(ps->flags & _PTDRV_INITALIZED)) { return(-ENXIO); } /* device is busy ? */ if (ps->flags & _PTDRV_OPEN) { return(-EBUSY); } #ifdef LINUX_26 if (!try_module_get(THIS_MODULE)) return -EAGAIN; #else MOD_INC_USE_COUNT; #endif ps->flags |= _PTDRV_OPEN; return _OK; } /*............................................................................. * device close... */ static CLOSETYPE pt_drv_close(struct inode * inode, struct file * file) { pScanData ps; DBG( DBG_HIGH, "pt_drv_close()\n" ); if ((ps = get_pt_from_inode(inode)) ) { ptdrvClose( ps ); ps->flags &= ~_PTDRV_OPEN; #ifdef LINUX_26 module_put(THIS_MODULE); #else MOD_DEC_USE_COUNT; #endif CLOSERETURN(0); } else { DBG( DBG_HIGH, "pt_drv: - close failed!\n" ); CLOSERETURN(-ENXIO); } } /*............................................................................. * read data from device */ #ifdef LINUX_20 static int pt_drv_read(struct inode *inode, struct file *file, char *buffer, int count) { int result; pScanData ps; if ( !(ps = get_pt_from_inode(inode))) return(-ENXIO); #else static ssize_t pt_drv_read( struct file *file, char *buffer, size_t count, loff_t *tmp ) { int result; pScanData ps; if ( !(ps = get_pt_from_inode(file->f_dentry->d_inode)) ) return(-ENXIO); #endif if ((result = verify_area_20(VERIFY_WRITE, buffer, count))) return result; /* * as the driver contains some global vars, it is not * possible to scan simultaenously with two or more devices */ if( _TRUE == deviceScanning ) { printk( KERN_INFO "pt_drv: device %u busy!!!\n", ps->devno ); return(-EBUSY); } deviceScanning = _TRUE; result = ptdrvRead( ps, buffer, count ); deviceScanning = _FALSE; return result; } /*............................................................................. * writing makes no sense */ #ifdef LINUX_20 static int pt_drv_write(struct inode * inode, struct file * file, const char * buffer, int count) { return -EPERM; } #else static ssize_t pt_drv_write( struct file * file,const char * buffer, size_t tmp,loff_t* count) { return -EPERM; } #endif /*............................................................................. * the ioctl interface */ #ifdef NOLOCK_IOCTL static long pt_drv_ioctl( struct file *file, UInt cmd, unsigned long arg ) { pScanData ps; if ( !(ps = get_pt_from_inode(file->f_dentry->d_inode)) ) return(-ENXIO); return ptdrvIoctl( ps, cmd, (pVoid)arg); } #else static int pt_drv_ioctl( struct inode *inode, struct file *file, UInt cmd, unsigned long arg ) { pScanData ps; if ( !(ps = get_pt_from_inode(inode)) ) return(-ENXIO); return ptdrvIoctl( ps, cmd, (pVoid)arg); } #endif #else /* the user-mode interface */ /*............................................................................. * here we only have wrapper functions */ static int PtDrvInit( const char *dev_name, UShort model_override ) { int fd; int result = _OK; if( _TRUE == PtDrvInitialized ) return _OK; result = sanei_pp_open( dev_name, &fd ); if( SANE_STATUS_GOOD != result ) return result; port[0] = fd; mov[0] = model_override; result = ptdrvInit( 0 ); if( _OK == result ) { PtDrvInitialized = _TRUE; } else { ptdrvShutdown( PtDrvDevices[0] ); } return result; } static int PtDrvShutdown( void ) { int result; if( _FALSE == PtDrvInitialized ) return _E_NOT_INIT; result = ptdrvShutdown( PtDrvDevices[0] ); PtDrvInitialized = _FALSE; return result; } static int PtDrvOpen( void ) { if( _FALSE == PtDrvInitialized ) return _E_NOT_INIT; return _OK; } static int PtDrvClose( void ) { if( _FALSE == PtDrvInitialized ) return _E_NOT_INIT; return ptdrvClose( PtDrvDevices[0] ); } static int PtDrvIoctl( UInt cmd, pVoid arg ) { if( _FALSE == PtDrvInitialized ) return _E_NOT_INIT; return ptdrvIoctl( PtDrvDevices[0], cmd, arg); } static int PtDrvRead ( pUChar buffer, int count ) { if( _FALSE == PtDrvInitialized ) return _E_NOT_INIT; return ptdrvRead( PtDrvDevices[0], buffer, count ); } #endif /* guard __KERNEL__ */ /* END PLUSTEK-PP_PTDRV.C ...................................................*/ sane-backends-1.0.29/backend/matsushita.c0000666000000000000000000020231113615534521015115 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002, 2004 Frank Zago (sane at zago dot net) Copyright (C) 2002 Other SANE contributors 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* $Id$ Matsushita/Panasonic KV-SS25, KV-SS50, KV-SS55, KV-SS50EX, KV-SS55EX, KV-SS850, KV-SS855 SCSI scanners. This backend may support more Panasonic scanners. */ /*--------------------------------------------------------------------------*/ #define BUILD 7 /* 2004-02-11 */ #define BACKEND_NAME matsushita #define MATSUSHITA_CONFIG_FILE "matsushita.conf" /*--------------------------------------------------------------------------*/ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/lassert.h" #include "matsushita.h" /*--------------------------------------------------------------------------*/ /* Lists of possible scan modes. */ static SANE_String_Const scan_mode_list_1[] = { BLACK_WHITE_STR, NULL }; static SANE_String_Const scan_mode_list_3[] = { BLACK_WHITE_STR, GRAY4_STR, GRAY8_STR, NULL }; /*--------------------------------------------------------------------------*/ /* Lists of supported resolutions (in DPI). * 200 DPI scanners are using resolutions_list_200 * 300 DPI scanners are using resolutions_list_300 * 400 DPI scanners are using resolutions_list_400 * * The resolutions_rounds_* lists provide the value with which round * up the X value given by the interface. */ #ifdef unused_yet static const SANE_Word resolutions_list_200[4] = { 3, 100, 150, 200 }; static const SANE_Word resolutions_rounds_200[4] = { 3, 0x100, 0x40, 0x20 }; #endif static const SANE_Word resolutions_list_300[5] = { 4, 150, 200, 240, 300 }; static const SANE_Word resolutions_rounds_300[5] = { 4, 0x100, 0x40, 0x20, 0x80 }; static const SANE_Word resolutions_list_400[8] = { 7, 100, 150, 200, 240, 300, 360, 400 }; static const SANE_Word resolutions_rounds_400[8] = { 7, 0x100, 0x100, 0x40, 0x20, 0x80, 0x100, 0x100 /* TO FIX */ }; /*--------------------------------------------------------------------------*/ /* Lists of supported halftone. They are only valid with * for the Black&White mode. */ static SANE_String_Const halftone_pattern_list[] = { SANE_I18N ("None"), SANE_I18N ("Bayer Dither 16"), SANE_I18N ("Bayer Dither 64"), SANE_I18N ("Halftone Dot 32"), SANE_I18N ("Halftone Dot 64"), SANE_I18N ("Error Diffusion"), NULL }; static const int halftone_pattern_val[] = { -1, 0x01, 0x00, 0x02, 0x03, 0x04 }; /*--------------------------------------------------------------------------*/ /* List of automatic threshold options */ static SANE_String_Const automatic_threshold_list[] = { SANE_I18N ("None"), SANE_I18N ("Mode 1"), SANE_I18N ("Mode 2"), SANE_I18N ("Mode 3"), NULL }; static const int automatic_threshold_val[] = { 0, 0x80, 0x81, 0x82 }; /*--------------------------------------------------------------------------*/ /* List of white level base. */ static SANE_String_Const white_level_list[] = { SANE_I18N ("From white stick"), SANE_I18N ("From paper"), SANE_I18N ("Automatic"), NULL }; static const int white_level_val[] = { 0x00, 0x80, 0x81 }; /*--------------------------------------------------------------------------*/ /* List of noise reduction options. */ static SANE_String_Const noise_reduction_list[] = { SANE_I18N ("None"), "1x1", "2x2", "3x3", "4x4", "5x5", NULL }; static const int noise_reduction_val[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; /*--------------------------------------------------------------------------*/ /* List of image emphasis options, 5 steps */ static SANE_String_Const image_emphasis_list_5[] = { SANE_I18N ("Smooth"), SANE_I18N ("None"), SANE_I18N ("Low"), SANE_I18N ("Medium"), /* default */ SANE_I18N ("High"), NULL }; static const int image_emphasis_val_5[] = { 0x80, 0x00, 0x01, 0x30, 0x50 }; /* List of image emphasis options, 3 steps */ static SANE_String_Const image_emphasis_list_3[] = { SANE_I18N ("Low"), SANE_I18N ("Medium"), /* default ? */ SANE_I18N ("High"), NULL }; static const int image_emphasis_val_3[] = { 0x01, 0x30, 0x50 }; /*--------------------------------------------------------------------------*/ /* List of gamma */ static SANE_String_Const gamma_list[] = { SANE_I18N ("Normal"), SANE_I18N ("CRT"), NULL }; static const int gamma_val[] = { 0x00, 0x01 }; /*--------------------------------------------------------------------------*/ /* Page feeder options */ static SANE_String_Const feeder_mode_list[] = { SANE_I18N ("One page"), SANE_I18N ("All pages"), NULL }; static const int feeder_mode_val[] = { 0x00, 0xff }; /*--------------------------------------------------------------------------*/ /* Paper size in millimeters. * Values from http://www.twics.com/~eds/paper/. */ static const struct paper_sizes paper_sizes[] = { {"2A0", 1189, 1682}, {"4A0", 1682, 2378}, {"A0", 841, 1189}, {"A1", 594, 841}, {"A2", 420, 594}, {"A3", 297, 420}, {"A4", 210, 297}, {"A5", 148, 210}, {"A6", 105, 148}, {"A7", 74, 105}, {"A8", 52, 74}, {"A9", 37, 52}, {"A10", 26, 37}, {"B0", 1000, 1414}, {"B1", 707, 1000}, {"B2", 500, 707}, {"B3", 353, 500}, {"B4", 250, 353}, {"B5", 176, 250}, {"B6", 125, 176}, {"B7", 88, 125}, {"B8", 62, 88}, {"B9", 44, 62}, {"B10", 31, 44}, {"C0", 917, 1297}, {"C1", 648, 917}, {"C2", 458, 648}, {"C3", 324, 458}, {"C4", 229, 324}, {"C5", 162, 229}, {"C6", 114, 162}, {"C7", 81, 114}, {"C8", 57, 81}, {"C9", 40, 57}, {"C10", 28, 40}, {"Legal", 8.5 * MM_PER_INCH, 14 * MM_PER_INCH}, {"Letter", 8.5 * MM_PER_INCH, 11 * MM_PER_INCH} }; /*--------------------------------------------------------------------------*/ /* Define the supported scanners and their characteristics. */ static const struct scanners_supported scanners[] = { /* Panasonic KV-SS25 */ { 0x06, "K.M.E. ", "KV-SS25A ", {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 431.8 mm */ {1, 255, 1}, /* brightness range */ {1, 255, 1}, /* contrast range */ scan_mode_list_3, resolutions_list_300, resolutions_rounds_300, image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_DUPLEX | MAT_CAP_CONTRAST | MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION}, /* Panasonic KV-SS25D */ { 0x06, "K.M.E. ", "KV-SS25D ", /* TO FIX */ {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 431.8 mm */ {1, 255, 1}, /* brightness range */ {1, 255, 1}, /* contrast range */ scan_mode_list_3, resolutions_list_300, resolutions_rounds_300, image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_DUPLEX | MAT_CAP_CONTRAST | MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION}, /* Panasonic KV-SS50 */ { 0x06, "K.M.E. ", "KV-SS50 ", /* TO FIX */ {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (14 * MM_PER_INCH), 0}, /* y range 0 to 355.6 mm */ {1, 5, 1}, /* brightness range, TO FIX */ {0, 0, 0}, /* contrast range */ scan_mode_list_1, resolutions_list_300, resolutions_rounds_300, /* TO FIX */ image_emphasis_list_3, image_emphasis_val_3, MAT_CAP_PAPER_DETECT | MAT_CAP_MIRROR_IMAGE}, /* Panasonic KV-SS55 */ { 0x06, "K.M.E. ", "KV-SS55 ", /* TO FIX */ {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (14 * MM_PER_INCH), 0}, /* y range 0 to 355.6 mm */ {1, 5, 1}, /* brightness range, TO FIX */ {1, 255, 1}, /* contrast range, TO FIX */ scan_mode_list_1, resolutions_list_300, resolutions_rounds_300, /* TO FIX */ image_emphasis_list_3, image_emphasis_val_3, MAT_CAP_DUPLEX | MAT_CAP_CONTRAST | MAT_CAP_PAPER_DETECT | MAT_CAP_MIRROR_IMAGE}, /* Panasonic KV-SS50EX */ { 0x06, "K.M.E. ", "KV-SS50EX ", /* TO FIX */ {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 355.6 mm */ {1, 255, 1}, /* brightness range */ {0, 0, 0}, /* contrast range */ scan_mode_list_3, resolutions_list_300, resolutions_rounds_300, /* TO FIX */ image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION | MAT_CAP_PAPER_DETECT | MAT_CAP_MIRROR_IMAGE}, /* Panasonic KV-SS55EX */ { 0x06, "K.M.E. ", "KV-SS55EX ", {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 431.8 mm */ {1, 255, 1}, /* brightness range */ {1, 255, 1}, /* contrast range */ scan_mode_list_3, resolutions_list_300, resolutions_rounds_300, image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_DUPLEX | MAT_CAP_CONTRAST | MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION}, /* Panasonic KV-SS850 */ { 0x06, "K.M.E. ", "KV-SS850 ", /* TO FIX */ {SANE_FIX (0), SANE_FIX (11.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 355.6 mm */ {1, 255, 1}, /* brightness range */ {0, 0, 0}, /* contrast range */ scan_mode_list_3, resolutions_list_300, resolutions_rounds_300, /* TO FIX */ image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION | MAT_CAP_PAPER_DETECT | MAT_CAP_DETECT_DOUBLE_FEED | MAT_CAP_MANUAL_FEED}, /* Panasonic KV-SS855 */ { 0x06, "K.M.E. ", "KV-SS855 ", /* TO FIX */ {SANE_FIX (0), SANE_FIX (11.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 355.6 mm */ {1, 255, 1}, /* brightness range */ {1, 255, 1}, /* contrast range, TO FIX */ scan_mode_list_3, resolutions_list_400, resolutions_rounds_400, /* TO FIX */ image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_DUPLEX | MAT_CAP_CONTRAST | MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION | MAT_CAP_PAPER_DETECT | MAT_CAP_DETECT_DOUBLE_FEED | MAT_CAP_MANUAL_FEED}, /* Panasonic KV-S2065L */ { 0x06, "K.M.E. ", "KV-S2065L ", {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 431.8 mm */ {1, 255, 1}, /* brightness range */ {1, 255, 1}, /* contrast range */ scan_mode_list_3, resolutions_list_300, resolutions_rounds_300, image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_DUPLEX | MAT_CAP_CONTRAST | MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION}, /* Panasonic KV-S2025C */ { 0x06, "K.M.E. ", "KV-S2025C ", {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 431.8 mm */ {1, 255, 1}, /* brightness range */ {1, 255, 1}, /* contrast range */ scan_mode_list_3, resolutions_list_300, resolutions_rounds_300, image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_DUPLEX | MAT_CAP_CONTRAST | MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION}, /* Panasonic KV-S2045C */ { 0x06, "K.M.E. ", "KV-S2045C ", {SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0}, /* x range 0 to 215.9 mm */ {SANE_FIX (0), SANE_FIX (17 * MM_PER_INCH), 0}, /* y range 0 to 431.8 mm */ {1, 255, 1}, /* brightness range */ {1, 255, 1}, /* contrast range */ scan_mode_list_3, resolutions_list_300, resolutions_rounds_300, image_emphasis_list_5, image_emphasis_val_5, MAT_CAP_DUPLEX | MAT_CAP_CONTRAST | MAT_CAP_AUTOMATIC_THRESHOLD | MAT_CAP_WHITE_LEVEL | MAT_CAP_GAMMA | MAT_CAP_NOISE_REDUCTION} }; /*--------------------------------------------------------------------------*/ /* List of scanner attached. */ static Matsushita_Scanner *first_dev = NULL; static int num_devices = 0; static const SANE_Device **devlist = NULL; /* Local functions. */ /* Display a buffer in the log. */ static void hexdump (int level, const char *comment, unsigned char *p, int l) { int i; char line[128]; char *ptr; DBG (level, "%s\n", comment); ptr = line; for (i = 0; i < l; i++, p++) { if ((i % 16) == 0) { if (ptr != line) { *ptr = '\0'; DBG (level, "%s\n", line); ptr = line; } sprintf (ptr, "%3.3d:", i); ptr += 4; } sprintf (ptr, " %2.2x", *p); ptr += 3; } *ptr = '\0'; DBG (level, "%s\n", line); } /* Returns the length of the longest string, including the terminating * character. */ static size_t max_string_size (SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) { max_size = size; } } return max_size; } /* After the windows has been set, issue that command to get the * document size. */ static SANE_Status matsushita_read_document_size (Matsushita_Scanner * dev) { CDB cdb; SANE_Status status; size_t size; DBG (DBG_proc, "matsushita_read_document_size: enter\n"); size = 0x10; MKSCSI_READ_10 (cdb, 0x80, 0, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status != SANE_STATUS_GOOD || size != 0x10) { DBG (DBG_error, "matsushita_read_document_size: cannot read document size\n"); return (SANE_STATUS_IO_ERROR); } hexdump (DBG_info2, "document size", dev->buffer, 16); /* Check that X and Y are the same values the backend computed. */ assert (dev->params.lines == B32TOI (&dev->buffer[4])); assert (dev->params.pixels_per_line == B32TOI (&dev->buffer[0])); DBG (DBG_proc, "matsushita_read_document_size: exit, %ld bytes read\n", (long)size); return (SANE_STATUS_GOOD); } /* Initialize a scanner entry. Return an allocated scanner with some * preset values. */ static Matsushita_Scanner * matsushita_init (void) { Matsushita_Scanner *dev; DBG (DBG_proc, "matsushita_init: enter\n"); /* Allocate a new scanner entry. */ dev = malloc (sizeof (Matsushita_Scanner)); if (dev == NULL) { return NULL; } memset (dev, 0, sizeof (Matsushita_Scanner)); /* Allocate the buffer used to transfer the SCSI data. */ dev->buffer_size = 64 * 1024; dev->buffer = malloc (dev->buffer_size); if (dev->buffer == NULL) { free (dev); return NULL; } /* Allocate a buffer to store the temporary image. */ dev->image_size = 64 * 1024; /* enough for 1 line at max res */ dev->image = malloc (dev->image_size); if (dev->image == NULL) { free (dev->buffer); free (dev); return NULL; } dev->sfd = -1; DBG (DBG_proc, "matsushita_init: exit\n"); return (dev); } /* Closes an open scanner. */ static void matsushita_close (Matsushita_Scanner * dev) { DBG (DBG_proc, "matsushita_close: enter\n"); if (dev->sfd != -1) { sanei_scsi_close (dev->sfd); dev->sfd = -1; } DBG (DBG_proc, "matsushita_close: exit\n"); } /* Frees the memory used by a scanner. */ static void matsushita_free (Matsushita_Scanner * dev) { int i; DBG (DBG_proc, "matsushita_free: enter\n"); if (dev == NULL) return; matsushita_close (dev); if (dev->devicename) { free (dev->devicename); } if (dev->buffer) { free (dev->buffer); } if (dev->image) { free (dev->image); } for (i = 1; i < OPT_NUM_OPTIONS; i++) { if (dev->opt[i].type == SANE_TYPE_STRING && dev->val[i].s) { free (dev->val[i].s); } } free (dev->paper_sizes_list); free (dev->paper_sizes_val); free (dev); DBG (DBG_proc, "matsushita_free: exit\n"); } /* Inquiry a device and returns TRUE if is supported. */ static int matsushita_identify_scanner (Matsushita_Scanner * dev) { CDB cdb; SANE_Status status; size_t size; int i; DBG (DBG_proc, "matsushita_identify_scanner: enter\n"); size = 5; MKSCSI_INQUIRY (cdb, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status) { DBG (DBG_error, "matsushita_identify_scanner: inquiry failed with status %s\n", sane_strstatus (status)); return (SANE_FALSE); } size = dev->buffer[4] + 5; /* total length of the inquiry data */ if (size < 36) { DBG (DBG_error, "matsushita_identify_scanner: not enough data to identify device\n"); return (SANE_FALSE); } MKSCSI_INQUIRY (cdb, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status) { DBG (DBG_error, "matsushita_identify_scanner: inquiry failed with status %s\n", sane_strstatus (status)); return (SANE_FALSE); } hexdump (DBG_info2, "inquiry", dev->buffer, size); dev->scsi_type = dev->buffer[0] & 0x1f; memcpy (dev->scsi_vendor, dev->buffer + 0x08, 0x08); dev->scsi_vendor[0x08] = 0; memcpy (dev->scsi_product, dev->buffer + 0x10, 0x010); dev->scsi_product[0x10] = 0; memcpy (dev->scsi_version, dev->buffer + 0x20, 0x04); dev->scsi_version[0x04] = 0; DBG (DBG_info, "device is \"%s\" \"%s\" \"%s\"\n", dev->scsi_vendor, dev->scsi_product, dev->scsi_version); /* Lookup through the supported scanners table to find if this * backend supports that one. */ for (i = 0; i < NELEMS (scanners); i++) { if (dev->scsi_type == scanners[i].scsi_type && strcmp (dev->scsi_vendor, scanners[i].scsi_vendor) == 0 && strcmp (dev->scsi_product, scanners[i].scsi_product) == 0) { DBG (DBG_error, "matsushita_identify_scanner: scanner supported\n"); dev->scnum = i; return (SANE_TRUE); } } DBG (DBG_proc, "matsushita_identify_scanner: exit, device not supported\n"); return (SANE_FALSE); } /* The interface can show different paper sizes. Show only the sizes * available for that scanner. */ static int matsushita_build_paper_sizes (Matsushita_Scanner * dev) { SANE_String_Const *psl; /* string list */ int *psv; /* value list */ int num; int i; DBG (DBG_proc, "matsushita_build_paper_sizes: enter\n"); psl = malloc ((sizeof (SANE_String_Const) + 1) * NELEMS (paper_sizes)); if (psl == NULL) { DBG (DBG_error, "ERROR: not enough memory\n"); return SANE_STATUS_NO_MEM; } psv = malloc ((sizeof (int) + 1) * NELEMS (paper_sizes)); if (psv == NULL) { DBG (DBG_error, "ERROR: not enough memory\n"); free (psl); return SANE_STATUS_NO_MEM; } for (i = 0, num = 0; i < NELEMS (paper_sizes); i++) { if (SANE_UNFIX (scanners[dev->scnum].x_range.max) >= paper_sizes[i].width && SANE_UNFIX (scanners[dev->scnum].y_range.max) >= paper_sizes[i].length) { /* This paper size fits into the scanner. */ psl[num] = paper_sizes[i].name; psv[num] = i; num++; } } psl[num] = NULL; /* terminate the list */ dev->paper_sizes_list = psl; dev->paper_sizes_val = psv; DBG (DBG_proc, "matsushita_build_paper_sizes: exit (%d)\n", num); return SANE_STATUS_GOOD; } /* Lookup a string list from one array and return its index. */ static int get_string_list_index (SANE_String_Const list[], SANE_String_Const name) { int index; index = 0; while (list[index] != NULL) { if (strcmp (list[index], name) == 0) { return (index); } index++; } DBG (DBG_error, "name %s not found in list\n", name); assert (0 == 1); /* bug in backend, core dump */ return (-1); } /* Lookup an int list from one array and return its index. */ static int get_int_list_index (const SANE_Word list[], const SANE_Word value) { int index; int size; /* number of elements */ index = 1; size = list[0]; while (index <= size) { if (list[index] == value) { return (index); } index++; } DBG (DBG_error, "word %d not found in list\n", value); assert (0 == 1); /* bug in backend, core dump */ return (-1); } /* SCSI sense handler. Callback for SANE. */ static SANE_Status matsushita_sense_handler (int scsi_fd, unsigned char *result, void __sane_unused__ *arg) { int asc, ascq, sensekey; int len; DBG (DBG_proc, "matsushita_sense_handler (scsi_fd = %d)\n", scsi_fd); sensekey = get_RS_sense_key (result); len = 7 + get_RS_additional_length (result); hexdump (DBG_info2, "sense", result, len); if (get_RS_error_code (result) != 0x70) { DBG (DBG_error, "matsushita_sense_handler: invalid sense key error code (%d)\n", get_RS_error_code (result)); return SANE_STATUS_IO_ERROR; } if (get_RS_ILI (result) != 0) { DBG (DBG_sense, "matsushita_sense_handler: short read\n"); } if (len < 14) { DBG (DBG_error, "matsushita_sense_handler: sense too short, no ASC/ASCQ\n"); return SANE_STATUS_IO_ERROR; } asc = get_RS_ASC (result); ascq = get_RS_ASCQ (result); DBG (DBG_sense, "matsushita_sense_handler: sense=%d, ASC/ASCQ=%02x%02x\n", sensekey, asc, ascq); switch (sensekey) { case 0x00: /* no sense */ if (get_RS_EOM (result) && asc == 0x00 && ascq == 0x00) { DBG (DBG_sense, "matsushita_sense_handler: EOF\n"); return SANE_STATUS_EOF; } return SANE_STATUS_GOOD; break; case 0x02: /* not ready */ if (asc == 0x04 && ascq == 0x81) { /* Jam door open. */ return SANE_STATUS_COVER_OPEN; } break; case 0x03: /* medium error */ if (asc == 0x3a) { /* No paper in the feeder. */ return SANE_STATUS_NO_DOCS; } if (asc == 0x80) { /* Probably a paper jam. ascq might give more info. */ return SANE_STATUS_JAMMED; } break; case 0x05: if (asc == 0x20 || asc == 0x24 || asc == 0x26) { /* Invalid command, invalid field in CDB or invalid field in data. * The backend has prepared some wrong combination of options. * Shot the backend maintainer. */ return SANE_STATUS_IO_ERROR; } else if (asc == 0x2c && ascq == 0x80) { /* The scanner does have enough memory to scan the whole * area. For instance the KV-SS25 has only 4MB of memory, * which is not enough to scan a A4 page at 300dpi in gray * 8 bits. */ return SANE_STATUS_NO_MEM; } break; case 0x06: if (asc == 0x29) { /* Reset occured. May be the backend should retry the * command. */ return SANE_STATUS_GOOD; } break; } DBG (DBG_sense, "matsushita_sense_handler: unknown error condition. Please report it to the backend maintainer\n"); return SANE_STATUS_IO_ERROR; } /* Check that a new page is available by issuing an empty read. The * sense handler might return SANE_STATUS_NO_DOCS which indicates that * the feeder is now empty. */ static SANE_Status matsushita_check_next_page (Matsushita_Scanner * dev) { CDB cdb; SANE_Status status; DBG (DBG_proc, "matsushita_check_next_page: enter\n"); MKSCSI_READ_10 (cdb, 0, 0, 0); cdb.data[4] = dev->page_num; /* May be cdb.data[3] too? */ cdb.data[5] = dev->page_side; status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); DBG (DBG_proc, "matsushita_check_next_page: exit with status %d\n", status); return (status); } /* Attach a scanner to this backend. */ static SANE_Status attach_scanner (const char *devicename, Matsushita_Scanner ** devp) { Matsushita_Scanner *dev; int sfd; DBG (DBG_sane_proc, "attach_scanner: %s\n", devicename); if (devp) *devp = NULL; /* Check if we know this device name. */ for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { if (devp) { *devp = dev; } DBG (DBG_info, "device is already known\n"); return SANE_STATUS_GOOD; } } /* Allocate a new scanner entry. */ dev = matsushita_init (); if (dev == NULL) { DBG (DBG_error, "ERROR: not enough memory\n"); return SANE_STATUS_NO_MEM; } DBG (DBG_info, "attach_scanner: opening %s\n", devicename); if (sanei_scsi_open (devicename, &sfd, matsushita_sense_handler, dev) != 0) { DBG (DBG_error, "ERROR: attach_scanner: open failed\n"); matsushita_free (dev); return SANE_STATUS_INVAL; } /* Fill some scanner specific values. */ dev->devicename = strdup (devicename); dev->sfd = sfd; /* Now, check that it is a scanner we support. */ if (matsushita_identify_scanner (dev) == SANE_FALSE) { DBG (DBG_error, "ERROR: attach_scanner: scanner-identification failed\n"); matsushita_free (dev); return SANE_STATUS_INVAL; } matsushita_close (dev); /* Set the default options for that scanner. */ dev->sane.name = dev->devicename; dev->sane.vendor = "Panasonic"; dev->sane.model = dev->scsi_product; dev->sane.type = SANE_I18N ("sheetfed scanner"); /* Link the scanner with the others. */ dev->next = first_dev; first_dev = dev; if (devp) { *devp = dev; } num_devices++; DBG (DBG_proc, "attach_scanner: exit\n"); return SANE_STATUS_GOOD; } static SANE_Status attach_one (const char *dev) { attach_scanner (dev, NULL); return SANE_STATUS_GOOD; } /* Reset the options for that scanner. */ static void matsushita_init_options (Matsushita_Scanner * dev) { int i; /* Pre-initialize the options. */ memset (dev->opt, 0, sizeof (dev->opt)); memset (dev->val, 0, sizeof (dev->val)); for (i = 0; i < OPT_NUM_OPTIONS; ++i) { dev->opt[i].size = sizeof (SANE_Word); dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* Number of options. */ dev->opt[OPT_NUM_OPTS].name = ""; dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; dev->val[OPT_NUM_OPTS].w = OPT_NUM_OPTIONS; /* Mode group */ dev->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); dev->opt[OPT_MODE_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_MODE_GROUP].cap = 0; dev->opt[OPT_MODE_GROUP].size = 0; dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Scanner supported modes */ 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 (scanners[dev->scnum].scan_mode_list); dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_MODE].constraint.string_list = scanners[dev->scnum].scan_mode_list; dev->val[OPT_MODE].s = (SANE_Char *) strdup (""); /* will be set later */ /* X and Y resolution */ 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].unit = SANE_UNIT_DPI; dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; dev->opt[OPT_RESOLUTION].constraint.word_list = scanners[dev->scnum].resolutions_list; dev->val[OPT_RESOLUTION].w = resolutions_list_300[1]; /* Duplex */ dev->opt[OPT_DUPLEX].name = SANE_NAME_DUPLEX; dev->opt[OPT_DUPLEX].title = SANE_TITLE_DUPLEX; dev->opt[OPT_DUPLEX].desc = SANE_DESC_DUPLEX; dev->opt[OPT_DUPLEX].type = SANE_TYPE_BOOL; dev->opt[OPT_DUPLEX].unit = SANE_UNIT_NONE; dev->val[OPT_DUPLEX].w = SANE_FALSE; if ((scanners[dev->scnum].cap & MAT_CAP_DUPLEX) == 0) dev->opt[OPT_DUPLEX].cap |= SANE_CAP_INACTIVE; /* Feeder mode */ dev->opt[OPT_FEEDER_MODE].name = "feeder-mode"; dev->opt[OPT_FEEDER_MODE].title = SANE_I18N ("Feeder mode"); dev->opt[OPT_FEEDER_MODE].desc = SANE_I18N ("Sets the feeding mode"); dev->opt[OPT_FEEDER_MODE].type = SANE_TYPE_STRING; dev->opt[OPT_FEEDER_MODE].size = max_string_size (feeder_mode_list); dev->opt[OPT_FEEDER_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_FEEDER_MODE].constraint.string_list = feeder_mode_list; dev->val[OPT_FEEDER_MODE].s = strdup (feeder_mode_list[0]); /* Geometry group */ dev->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); dev->opt[OPT_GEOMETRY_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_GEOMETRY_GROUP].cap = 0; dev->opt[OPT_GEOMETRY_GROUP].size = 0; dev->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Paper sizes list. */ dev->opt[OPT_PAPER_SIZE].name = SANE_NAME_PAPER_SIZE; dev->opt[OPT_PAPER_SIZE].title = SANE_TITLE_PAPER_SIZE; dev->opt[OPT_PAPER_SIZE].desc = SANE_DESC_PAPER_SIZE; dev->opt[OPT_PAPER_SIZE].type = SANE_TYPE_STRING; dev->opt[OPT_PAPER_SIZE].size = max_string_size (dev->paper_sizes_list); dev->opt[OPT_PAPER_SIZE].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_PAPER_SIZE].constraint.string_list = dev->paper_sizes_list; dev->val[OPT_PAPER_SIZE].s = strdup (""); /* will do it later */ /* Upper left X */ dev->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; dev->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; dev->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; dev->opt[OPT_TL_X].type = SANE_TYPE_FIXED; dev->opt[OPT_TL_X].unit = SANE_UNIT_MM; dev->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_X].constraint.range = &(scanners[dev->scnum].x_range); /* Upper left Y */ dev->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; dev->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; dev->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; dev->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; dev->opt[OPT_TL_Y].unit = SANE_UNIT_MM; dev->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_Y].constraint.range = &(scanners[dev->scnum].y_range); /* Bottom-right x */ dev->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; dev->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; dev->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; dev->opt[OPT_BR_X].type = SANE_TYPE_FIXED; dev->opt[OPT_BR_X].unit = SANE_UNIT_MM; dev->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_X].constraint.range = &(scanners[dev->scnum].x_range); /* Bottom-right y */ dev->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; dev->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; dev->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; dev->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; dev->opt[OPT_BR_Y].unit = SANE_UNIT_MM; dev->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_Y].constraint.range = &(scanners[dev->scnum].y_range); /* Enhancement group */ dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); dev->opt[OPT_ENHANCEMENT_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; dev->opt[OPT_ENHANCEMENT_GROUP].size = 0; dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Brightness */ dev->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; dev->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; dev->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; dev->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; dev->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; dev->opt[OPT_BRIGHTNESS].size = sizeof (SANE_Int); dev->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BRIGHTNESS].constraint.range = &(scanners[dev->scnum].brightness_range); dev->val[OPT_BRIGHTNESS].w = 128; /* Contrast */ dev->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; dev->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; dev->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; dev->opt[OPT_CONTRAST].type = SANE_TYPE_INT; dev->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE; dev->opt[OPT_CONTRAST].size = sizeof (SANE_Int); dev->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_CONTRAST].constraint.range = &(scanners[dev->scnum].contrast_range); dev->val[OPT_CONTRAST].w = 128; if ((scanners[dev->scnum].cap & MAT_CAP_CONTRAST) == 0) dev->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; /* Automatic threshold */ dev->opt[OPT_AUTOMATIC_THRESHOLD].name = "automatic-threshold"; dev->opt[OPT_AUTOMATIC_THRESHOLD].title = SANE_I18N ("Automatic threshold"); dev->opt[OPT_AUTOMATIC_THRESHOLD].desc = SANE_I18N ("Automatically sets brightness, contrast, white level, gamma, noise reduction and image emphasis"); dev->opt[OPT_AUTOMATIC_THRESHOLD].type = SANE_TYPE_STRING; dev->opt[OPT_AUTOMATIC_THRESHOLD].size = max_string_size (automatic_threshold_list); dev->opt[OPT_AUTOMATIC_THRESHOLD].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_AUTOMATIC_THRESHOLD].constraint.string_list = automatic_threshold_list; dev->val[OPT_AUTOMATIC_THRESHOLD].s = strdup (automatic_threshold_list[0]); if ((scanners[dev->scnum].cap & MAT_CAP_AUTOMATIC_THRESHOLD) == 0) dev->opt[OPT_AUTOMATIC_THRESHOLD].cap |= SANE_CAP_INACTIVE; /* Halftone pattern */ dev->opt[OPT_HALFTONE_PATTERN].name = SANE_NAME_HALFTONE_PATTERN; dev->opt[OPT_HALFTONE_PATTERN].title = SANE_TITLE_HALFTONE_PATTERN; dev->opt[OPT_HALFTONE_PATTERN].desc = SANE_DESC_HALFTONE_PATTERN; dev->opt[OPT_HALFTONE_PATTERN].type = SANE_TYPE_STRING; dev->opt[OPT_HALFTONE_PATTERN].size = max_string_size (halftone_pattern_list); dev->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_HALFTONE_PATTERN].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_HALFTONE_PATTERN].constraint.string_list = halftone_pattern_list; dev->val[OPT_HALFTONE_PATTERN].s = strdup (halftone_pattern_list[0]); /* Automatic separation */ dev->opt[OPT_AUTOMATIC_SEPARATION].name = SANE_NAME_AUTOSEP; dev->opt[OPT_AUTOMATIC_SEPARATION].title = SANE_TITLE_AUTOSEP; dev->opt[OPT_AUTOMATIC_SEPARATION].desc = SANE_DESC_AUTOSEP; dev->opt[OPT_AUTOMATIC_SEPARATION].type = SANE_TYPE_BOOL; dev->opt[OPT_AUTOMATIC_SEPARATION].unit = SANE_UNIT_NONE; dev->val[OPT_AUTOMATIC_SEPARATION].w = SANE_FALSE; /* White level base */ dev->opt[OPT_WHITE_LEVEL].name = SANE_NAME_WHITE_LEVEL; dev->opt[OPT_WHITE_LEVEL].title = SANE_TITLE_WHITE_LEVEL; dev->opt[OPT_WHITE_LEVEL].desc = SANE_DESC_WHITE_LEVEL; dev->opt[OPT_WHITE_LEVEL].type = SANE_TYPE_STRING; dev->opt[OPT_WHITE_LEVEL].size = max_string_size (white_level_list); dev->opt[OPT_WHITE_LEVEL].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_WHITE_LEVEL].constraint.string_list = white_level_list; dev->val[OPT_WHITE_LEVEL].s = strdup (white_level_list[0]); if ((scanners[dev->scnum].cap & MAT_CAP_WHITE_LEVEL) == 0) dev->opt[OPT_WHITE_LEVEL].cap |= SANE_CAP_INACTIVE; /* Noise reduction */ dev->opt[OPT_NOISE_REDUCTION].name = "noise-reduction"; dev->opt[OPT_NOISE_REDUCTION].title = SANE_I18N ("Noise reduction"); dev->opt[OPT_NOISE_REDUCTION].desc = SANE_I18N ("Reduce the isolated dot noise"); dev->opt[OPT_NOISE_REDUCTION].type = SANE_TYPE_STRING; dev->opt[OPT_NOISE_REDUCTION].size = max_string_size (noise_reduction_list); dev->opt[OPT_NOISE_REDUCTION].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_NOISE_REDUCTION].constraint.string_list = noise_reduction_list; dev->val[OPT_NOISE_REDUCTION].s = strdup (noise_reduction_list[0]); if ((scanners[dev->scnum].cap & MAT_CAP_NOISE_REDUCTION) == 0) dev->opt[OPT_NOISE_REDUCTION].cap |= SANE_CAP_INACTIVE; /* Image emphasis */ dev->opt[OPT_IMAGE_EMPHASIS].name = "image-emphasis"; dev->opt[OPT_IMAGE_EMPHASIS].title = SANE_I18N ("Image emphasis"); dev->opt[OPT_IMAGE_EMPHASIS].desc = SANE_I18N ("Sets the image emphasis"); dev->opt[OPT_IMAGE_EMPHASIS].type = SANE_TYPE_STRING; dev->opt[OPT_IMAGE_EMPHASIS].size = max_string_size (scanners[dev->scnum].image_emphasis_list); dev->opt[OPT_IMAGE_EMPHASIS].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_IMAGE_EMPHASIS].constraint.string_list = scanners[dev->scnum].image_emphasis_list; dev->val[OPT_IMAGE_EMPHASIS].s = strdup (SANE_I18N ("Medium")); /* Gamma */ dev->opt[OPT_GAMMA].name = "gamma"; dev->opt[OPT_GAMMA].title = SANE_I18N ("Gamma"); dev->opt[OPT_GAMMA].desc = SANE_I18N ("Gamma"); dev->opt[OPT_GAMMA].type = SANE_TYPE_STRING; dev->opt[OPT_GAMMA].size = max_string_size (gamma_list); dev->opt[OPT_GAMMA].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_GAMMA].constraint.string_list = gamma_list; dev->val[OPT_GAMMA].s = strdup (gamma_list[0]); /* Lastly, set the default scan mode. This might change some * values previously set here. */ sane_control_option (dev, OPT_PAPER_SIZE, SANE_ACTION_SET_VALUE, (SANE_String_Const *) dev->paper_sizes_list[0], NULL); sane_control_option (dev, OPT_MODE, SANE_ACTION_SET_VALUE, (SANE_String_Const *) scanners[dev->scnum]. scan_mode_list[0], NULL); } /* Wait until the scanner is ready. * * The only reason I know the scanner is not ready is because it is * moving the CCD. */ static SANE_Status matsushita_wait_scanner (Matsushita_Scanner * dev) { SANE_Status status; int timeout; CDB cdb; DBG (DBG_proc, "matsushita_wait_scanner: enter\n"); MKSCSI_TEST_UNIT_READY (cdb); /* Set the timeout to 60 seconds. */ timeout = 60; while (timeout > 0) { /* test unit ready */ status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); if (status == SANE_STATUS_GOOD) { return SANE_STATUS_GOOD; } sleep (1); }; DBG (DBG_proc, "matsushita_wait_scanner: scanner not ready\n"); return (SANE_STATUS_IO_ERROR); } /* Reset a window. This is used to re-initialize the scanner. */ static SANE_Status matsushita_reset_window (Matsushita_Scanner * dev) { CDB cdb; SANE_Status status; DBG (DBG_proc, "matsushita_reset_window: enter\n"); MKSCSI_SET_WINDOW (cdb, 0); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); DBG (DBG_proc, "matsushita_reset_window: exit, status=%d\n", status); return status; } /* Set a window. */ static SANE_Status matsushita_set_window (Matsushita_Scanner * dev, int side) { size_t size; CDB cdb; unsigned char window[72]; SANE_Status status; int i; DBG (DBG_proc, "matsushita_set_window: enter\n"); size = sizeof (window); MKSCSI_SET_WINDOW (cdb, size); memset (window, 0, size); /* size of the windows descriptor block */ window[7] = sizeof (window) - 8; /* Page side */ window[8] = side; /* X and Y resolution */ Ito16 (dev->resolution, &window[10]); Ito16 (dev->resolution, &window[12]); /* Upper Left (X,Y) */ Ito32 (dev->x_tl, &window[14]); Ito32 (dev->y_tl, &window[18]); /* Width and length */ Ito32 (dev->width, &window[22]); Ito32 (dev->length, &window[26]); Ito32 (dev->width, &window[56]); /* again, verso? */ Ito32 (dev->length, &window[60]); /* again, verso? */ /* Brightness */ window[30] = 255 - dev->val[OPT_BRIGHTNESS].w; window[31] = window[30]; /* same as brightness. */ /* Contrast */ window[32] = dev->val[OPT_CONTRAST].w; /* Image Composition */ switch (dev->scan_mode) { case MATSUSHITA_BW: window[33] = 0x00; break; case MATSUSHITA_HALFTONE: window[33] = 0x01; break; case MATSUSHITA_GRAYSCALE: window[33] = 0x02; break; } /* Depth */ window[34] = dev->depth; /* Halftone pattern. */ if (dev->scan_mode == MATSUSHITA_HALFTONE) { i = get_string_list_index (halftone_pattern_list, dev->val[OPT_HALFTONE_PATTERN].s); window[36] = halftone_pattern_val[i]; } /* Gamma */ if (dev->scan_mode == MATSUSHITA_GRAYSCALE) { i = get_string_list_index (gamma_list, dev->val[OPT_GAMMA].s); window[52] = gamma_val[i]; } /* Feeder mode */ i = get_string_list_index (feeder_mode_list, dev->val[OPT_FEEDER_MODE].s); window[65] = feeder_mode_val[i]; /* Image emphasis */ i = get_string_list_index (scanners[dev->scnum].image_emphasis_list, dev->val[OPT_IMAGE_EMPHASIS].s); window[51] = scanners[dev->scnum].image_emphasis_val[i]; /* White level */ i = get_string_list_index (white_level_list, dev->val[OPT_WHITE_LEVEL].s); window[68] = white_level_val[i]; if (dev->scan_mode == MATSUSHITA_BW || dev->scan_mode == MATSUSHITA_HALFTONE) { /* Noise reduction */ i = get_string_list_index (noise_reduction_list, dev->val[OPT_NOISE_REDUCTION].s); window[69] = noise_reduction_val[i]; /* Automatic separation */ if (dev->val[OPT_AUTOMATIC_SEPARATION].w) { window[67] = 0x80; } /* Automatic threshold. Must be last because it may override * some previous options. */ i = get_string_list_index (automatic_threshold_list, dev->val[OPT_AUTOMATIC_THRESHOLD].s); window[66] = automatic_threshold_val[i]; if (automatic_threshold_val[i] != 0) { /* Automatic threshold is enabled. */ window[30] = 0; /* brightness. */ window[31] = 0; /* same as brightness. */ window[32] = 0; /* contrast */ window[33] = 0; /* B&W mode */ window[36] = 0; /* Halftone pattern. */ window[51] = 0; /* Image emphasis */ window[67] = 0; /* Automatic separation */ window[68] = 0; /* White level */ window[69] = 0; /* Noise reduction */ } } hexdump (DBG_info2, "windows", window, 72); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, window, sizeof (window), NULL, NULL); DBG (DBG_proc, "matsushita_set_window: exit, status=%d\n", status); return status; } /* Read the image from the scanner and fill the temporary buffer with it. */ static SANE_Status matsushita_fill_image (Matsushita_Scanner * dev) { SANE_Status status; size_t size; CDB cdb; DBG (DBG_proc, "matsushita_fill_image: enter\n"); assert (dev->image_begin == dev->image_end); assert (dev->real_bytes_left > 0); dev->image_begin = 0; dev->image_end = 0; while (dev->real_bytes_left) { /* * Try to read the maximum number of bytes. * * The windows driver reads no more than 0x8000 byte. * * This backend operates differently than the windows * driver. The windows TWAIN driver always read 2 more bytes * at the end, so it gets a CHECK CONDITION with a short read * sense. Since the linux scsi layer seem to be buggy * regarding the resid, always read exactly the number of * remaining bytes. */ size = dev->real_bytes_left; if (size > dev->image_size - dev->image_end) size = dev->image_size - dev->image_end; if (size > 0x8000) size = 0x8000; if (size == 0) { /* Probably reached the end of the buffer. * Check, just in case. */ assert (dev->image_end != 0); return (SANE_STATUS_GOOD); } DBG (DBG_info, "sane_read: to read = %ld bytes (bpl=%d)\n", (long) size, dev->params.bytes_per_line); MKSCSI_READ_10 (cdb, 0, 0, size); cdb.data[4] = dev->page_num; /* May be cdb.data[3] too? */ cdb.data[5] = dev->page_side; hexdump (DBG_info2, "sane_read: READ_10 CDB", cdb.data, 10); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status == SANE_STATUS_EOF) { DBG (DBG_proc, "sane_read: exit, end of page scan\n"); return (SANE_STATUS_EOF); } if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "sane_read: cannot read from the scanner\n"); return status; } dev->real_bytes_left -= size; switch (dev->depth) { case 1: { /* For Black & White, the bits in every bytes are mirrored. * for instance 11010001 is coded as 10001011 */ unsigned char *src = dev->buffer; unsigned char *dest = dev->image + dev->image_end; unsigned char s; unsigned char d; size_t i; for (i = 0; i < size; i++) { s = *src; d = 0; if (s & 0x01) d |= 0x80; if (s & 0x02) d |= 0x40; if (s & 0x04) d |= 0x20; if (s & 0x08) d |= 0x10; if (s & 0x10) d |= 0x08; if (s & 0x20) d |= 0x04; if (s & 0x40) d |= 0x02; if (s & 0x80) d |= 0x01; *dest = d; src++; dest++; } } break; case 4: { /* Adjust from a depth of 4 bits ([0..15]) to * a depth of 8 bits ([0..255]) */ unsigned char *src = dev->buffer; unsigned char *dest = dev->image + dev->image_end; size_t i; /* n bytes from image --> 2*n bytes in buf. */ for (i = 0; i < size; i++) { *dest = ((*src & 0x0f) >> 0) * 17; dest++; *dest = ((*src & 0xf0) >> 4) * 17; dest++; src++; } size *= 2; } break; default: memcpy (dev->image + dev->image_end, dev->buffer, size); break; } dev->image_end += size; } return (SANE_STATUS_GOOD); /* unreachable */ } /* Copy from the raw buffer to the buffer given by the backend. * * len in input is the maximum length available in buf, and, in * output, is the length written into buf. */ static void matsushita_copy_raw_to_frontend (Matsushita_Scanner * dev, SANE_Byte * buf, size_t * len) { size_t size; size = dev->image_end - dev->image_begin; if (size > *len) { size = *len; } *len = size; memcpy (buf, dev->image + dev->image_begin, size); dev->image_begin += size; } /* Stop a scan. */ static SANE_Status do_cancel (Matsushita_Scanner * dev) { DBG (DBG_sane_proc, "do_cancel enter\n"); if (dev->scanning == SANE_TRUE) { /* Reset the scanner */ matsushita_reset_window (dev); matsushita_close (dev); } dev->scanning = SANE_FALSE; DBG (DBG_sane_proc, "do_cancel exit\n"); return SANE_STATUS_CANCELLED; } /*--------------------------------------------------------------------------*/ /* Entry points */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { FILE *fp; char dev_name[PATH_MAX]; size_t len; DBG_INIT (); DBG (DBG_sane_init, "sane_init\n"); DBG (DBG_error, "This is sane-matsushita version %d.%d-%d\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (DBG_error, "(C) 2002 by Frank Zago\n"); if (version_code) { *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); } fp = sanei_config_open (MATSUSHITA_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ attach_scanner ("/dev/scanner", 0); return SANE_STATUS_GOOD; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ sanei_config_attach_matching_devices (dev_name, attach_one); } fclose (fp); DBG (DBG_proc, "sane_init: leave\n"); return SANE_STATUS_GOOD; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { Matsushita_Scanner *dev; int i; DBG (DBG_proc, "sane_get_devices: enter\n"); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (DBG_proc, "sane_get_devices: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Matsushita_Scanner *dev; SANE_Status status; DBG (DBG_proc, "sane_open: enter\n"); /* search for devicename */ if (devicename[0]) { DBG (DBG_info, "sane_open: devicename=%s\n", devicename); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { break; } } if (!dev) { status = attach_scanner (devicename, &dev); if (status != SANE_STATUS_GOOD) { return status; } } } else { DBG (DBG_sane_info, "sane_open: no devicename, opening first device\n"); dev = first_dev; /* empty devicename -> use first device */ } if (!dev) { DBG (DBG_error, "No scanner found\n"); return SANE_STATUS_INVAL; } /* Build a list a paper size that fit into this scanner. */ matsushita_build_paper_sizes (dev); matsushita_init_options (dev); *handle = dev; DBG (DBG_proc, "sane_open: exit\n"); return SANE_STATUS_GOOD; } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Matsushita_Scanner *dev = handle; DBG (DBG_proc, "sane_get_option_descriptor: enter, option %d\n", option); if ((unsigned) option >= OPT_NUM_OPTIONS) { return NULL; } DBG (DBG_proc, "sane_get_option_descriptor: exit\n"); return dev->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Matsushita_Scanner *dev = handle; SANE_Status status; SANE_Word cap; SANE_String_Const name; int i; SANE_Word value; int rc; DBG (DBG_proc, "sane_control_option: enter, option %d, action %d\n", option, action); if (info) { *info = 0; } if (dev->scanning) { return SANE_STATUS_DEVICE_BUSY; } if (option < 0 || option >= OPT_NUM_OPTIONS) { return SANE_STATUS_INVAL; } cap = dev->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { return SANE_STATUS_INVAL; } name = dev->opt[option].name; if (!name) { name = "(no name)"; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options */ case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_TL_Y: case OPT_BR_Y: case OPT_TL_X: case OPT_BR_X: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_DUPLEX: case OPT_AUTOMATIC_SEPARATION: *(SANE_Word *) val = dev->val[option].w; return SANE_STATUS_GOOD; /* string options */ case OPT_MODE: case OPT_FEEDER_MODE: case OPT_HALFTONE_PATTERN: case OPT_PAPER_SIZE: case OPT_AUTOMATIC_THRESHOLD: case OPT_WHITE_LEVEL: case OPT_NOISE_REDUCTION: case OPT_IMAGE_EMPHASIS: case OPT_GAMMA: strcpy (val, dev->val[option].s); return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (DBG_error, "could not set option, not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (dev->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "could not set option, invalid value\n"); return status; } switch (option) { /* Side-effect options */ case OPT_TL_Y: case OPT_BR_Y: case OPT_RESOLUTION: if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } dev->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* The length of X must be rounded (up). */ case OPT_TL_X: case OPT_BR_X: value = mmToIlu (SANE_UNFIX (*(SANE_Word *) val)); i = get_int_list_index (scanners[dev->scnum].resolutions_list, dev->val[OPT_RESOLUTION].w); if (value & (scanners[dev->scnum].resolutions_round[i] - 1)) { value = (value | (scanners[dev->scnum].resolutions_round[i] - 1)) + 1; if (info) { *info |= SANE_INFO_INEXACT; } } *(SANE_Word *) val = SANE_FIX (iluToMm (value)); dev->val[option].w = *(SANE_Word *) val; if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; /* Side-effect free options */ case OPT_CONTRAST: case OPT_BRIGHTNESS: case OPT_DUPLEX: case OPT_AUTOMATIC_SEPARATION: dev->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* String mode */ case OPT_WHITE_LEVEL: case OPT_NOISE_REDUCTION: case OPT_IMAGE_EMPHASIS: case OPT_GAMMA: case OPT_FEEDER_MODE: free (dev->val[option].s); dev->val[option].s = (SANE_String) strdup (val); return SANE_STATUS_GOOD; case OPT_MODE: if (strcmp (dev->val[option].s, val) == 0) return SANE_STATUS_GOOD; free (dev->val[OPT_MODE].s); dev->val[OPT_MODE].s = (SANE_Char *) strdup (val); /* Set default options for the scan modes. */ dev->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_AUTOMATIC_THRESHOLD].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_AUTOMATIC_SEPARATION].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_NOISE_REDUCTION].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA].cap |= SANE_CAP_INACTIVE; if (strcmp (dev->val[OPT_MODE].s, BLACK_WHITE_STR) == 0) { dev->depth = 1; dev->opt[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_AUTOMATIC_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_AUTOMATIC_SEPARATION].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_NOISE_REDUCTION].cap &= ~SANE_CAP_INACTIVE; i = get_string_list_index (halftone_pattern_list, dev->val[OPT_HALFTONE_PATTERN].s); if (halftone_pattern_val[i] == -1) { dev->scan_mode = MATSUSHITA_BW; } else { dev->scan_mode = MATSUSHITA_HALFTONE; } } else if (strcmp (dev->val[OPT_MODE].s, GRAY4_STR) == 0) { dev->scan_mode = MATSUSHITA_GRAYSCALE; dev->depth = 4; dev->opt[OPT_GAMMA].cap &= ~SANE_CAP_INACTIVE; } else if (strcmp (dev->val[OPT_MODE].s, GRAY8_STR) == 0) { dev->scan_mode = MATSUSHITA_GRAYSCALE; dev->depth = 8; dev->opt[OPT_GAMMA].cap &= ~SANE_CAP_INACTIVE; } else { assert (0 == 1); } /* Some options might not be supported by the scanner. */ if ((scanners[dev->scnum].cap & MAT_CAP_GAMMA) == 0) dev->opt[OPT_GAMMA].cap |= SANE_CAP_INACTIVE; if (info) { *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; case OPT_HALFTONE_PATTERN: free (dev->val[option].s); dev->val[option].s = (SANE_String) strdup (val); i = get_string_list_index (halftone_pattern_list, dev->val[OPT_HALFTONE_PATTERN].s); if (halftone_pattern_val[i] == -1) { dev->scan_mode = MATSUSHITA_BW; } else { dev->scan_mode = MATSUSHITA_HALFTONE; } return SANE_STATUS_GOOD; case OPT_PAPER_SIZE: if (strcmp (dev->val[option].s, val) == 0) return SANE_STATUS_GOOD; free (dev->val[OPT_PAPER_SIZE].s); dev->val[OPT_PAPER_SIZE].s = (SANE_Char *) strdup (val); i = get_string_list_index (dev->paper_sizes_list, dev->val[OPT_PAPER_SIZE].s); i = dev->paper_sizes_val[i]; /* Set the 4 corners values. */ value = 0; rc = sane_control_option (handle, OPT_TL_X, SANE_ACTION_SET_VALUE, &value, info); assert (rc == SANE_STATUS_GOOD); value = 0; rc = sane_control_option (handle, OPT_TL_Y, SANE_ACTION_SET_VALUE, &value, info); assert (rc == SANE_STATUS_GOOD); value = SANE_FIX (paper_sizes[i].width); rc = sane_control_option (handle, OPT_BR_X, SANE_ACTION_SET_VALUE, &value, info); assert (rc == SANE_STATUS_GOOD); value = SANE_FIX (paper_sizes[i].length); rc = sane_control_option (handle, OPT_BR_Y, SANE_ACTION_SET_VALUE, &value, info); assert (rc == SANE_STATUS_GOOD); if (info) *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_AUTOMATIC_THRESHOLD: if (strcmp (dev->val[option].s, val) == 0) return SANE_STATUS_GOOD; free (dev->val[option].s); dev->val[option].s = (SANE_Char *) strdup (val); /* If the threshold is not set to none, some option must * disappear. */ dev->opt[OPT_WHITE_LEVEL].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_NOISE_REDUCTION].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_IMAGE_EMPHASIS].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_AUTOMATIC_SEPARATION].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; if (strcmp (dev->val[option].s, automatic_threshold_list[0]) == 0) { dev->opt[OPT_WHITE_LEVEL].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_NOISE_REDUCTION].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_IMAGE_EMPHASIS].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_AUTOMATIC_SEPARATION].cap &= ~SANE_CAP_INACTIVE; if (dev->scan_mode == MATSUSHITA_BW || dev->scan_mode == MATSUSHITA_HALFTONE) { dev->opt[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; } } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } DBG (DBG_proc, "sane_control_option: exit, bad\n"); return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Matsushita_Scanner *dev = handle; DBG (DBG_proc, "sane_get_parameters: enter\n"); if (!(dev->scanning)) { /* Setup the parameters for the scan. These values will be re-used * in the SET WINDOWS command. */ dev->resolution = dev->val[OPT_RESOLUTION].w; dev->x_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_X].w)); dev->y_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_Y].w)); dev->x_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_X].w)); dev->y_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_Y].w)); /* Check the corners are OK. */ if (dev->x_tl > dev->x_br) { int s; s = dev->x_tl; dev->x_tl = dev->x_br; dev->x_br = s; } if (dev->y_tl > dev->y_br) { int s; s = dev->y_tl; dev->y_tl = dev->y_br; dev->y_br = s; } dev->width = dev->x_br - dev->x_tl; dev->length = dev->y_br - dev->y_tl; /* Prepare the parameters for the caller. */ memset (&dev->params, 0, sizeof (SANE_Parameters)); dev->params.format = SANE_FRAME_GRAY; dev->params.last_frame = SANE_TRUE; dev->params.pixels_per_line = (((dev->width * dev->resolution) / 1200) + 7) & ~0x7; if (dev->depth == 4) { dev->params.depth = 8; } else { dev->params.depth = dev->depth; } dev->params.bytes_per_line = (dev->params.pixels_per_line / 8) * dev->params.depth; dev->params.lines = (dev->length * dev->resolution) / 1200; } /* Return the current values. */ if (params) { *params = (dev->params); } DBG (DBG_proc, "sane_get_parameters: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Matsushita_Scanner *dev = handle; SANE_Status status; DBG (DBG_proc, "sane_start: enter\n"); if (!(dev->scanning)) { sane_get_parameters (dev, NULL); if (dev->image == NULL) { dev->image_size = 3 * dev->buffer_size; dev->image = malloc (dev->image_size); if (dev->image == NULL) { return SANE_STATUS_NO_MEM; } } /* Open again the scanner. */ if (sanei_scsi_open (dev->devicename, &(dev->sfd), matsushita_sense_handler, dev) != 0) { DBG (DBG_error, "ERROR: sane_start: open failed\n"); return SANE_STATUS_INVAL; } dev->page_side = 0; /* page front */ dev->page_num = 0; /* first page */ /* The scanner must be ready. */ status = matsushita_wait_scanner (dev); if (status) { matsushita_close (dev); return status; } status = matsushita_reset_window (dev); if (status) { matsushita_close (dev); return status; } status = matsushita_set_window (dev, PAGE_FRONT); if (status) { matsushita_close (dev); return status; } if (dev->val[OPT_DUPLEX].w == SANE_TRUE) { status = matsushita_set_window (dev, PAGE_BACK); if (status) { matsushita_close (dev); return status; } } status = matsushita_read_document_size (dev); if (status) { matsushita_close (dev); return status; } } else { if (dev->val[OPT_DUPLEX].w == SANE_TRUE && dev->page_side == PAGE_FRONT) { dev->page_side = PAGE_BACK; } else { /* new sheet. */ dev->page_side = PAGE_FRONT; dev->page_num++; } status = matsushita_check_next_page (dev); if (status) { return status; } } dev->bytes_left = dev->params.bytes_per_line * dev->params.lines; dev->real_bytes_left = dev->params.bytes_per_line * dev->params.lines; if (dev->depth == 4) { /* Every byte read will be expanded into 2 bytes. */ dev->real_bytes_left /= 2; } dev->image_end = 0; dev->image_begin = 0; dev->scanning = SANE_TRUE; DBG (DBG_proc, "sane_start: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { SANE_Status status; Matsushita_Scanner *dev = handle; size_t size; int buf_offset; /* offset into buf */ DBG (DBG_proc, "sane_read: enter\n"); *len = 0; if (!(dev->scanning)) { /* OOPS, not scanning */ return do_cancel (dev); } if (dev->bytes_left <= 0) { return (SANE_STATUS_EOF); } buf_offset = 0; do { if (dev->image_begin == dev->image_end) { /* Fill image */ status = matsushita_fill_image (dev); if (status != SANE_STATUS_GOOD) { return (status); } } /* Something must have been read */ if (dev->image_begin == dev->image_end) { DBG (DBG_info, "sane_read: nothing read\n"); return SANE_STATUS_IO_ERROR; } /* Copy the data to the frontend buffer. */ size = max_len - buf_offset; if (size > dev->bytes_left) { size = dev->bytes_left; } matsushita_copy_raw_to_frontend (dev, buf + buf_offset, &size); buf_offset += size; dev->bytes_left -= size; *len += size; } while ((buf_offset != max_len) && dev->bytes_left); DBG (DBG_info, "sane_read: leave, bytes_left=%ld\n", (long)dev->bytes_left); return SANE_STATUS_GOOD; } SANE_Status sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { SANE_Status status; Matsushita_Scanner *dev = handle; DBG (DBG_proc, "sane_set_io_mode: enter\n"); if (dev->scanning == SANE_FALSE) { return (SANE_STATUS_INVAL); } if (non_blocking == SANE_FALSE) { status = SANE_STATUS_GOOD; } else { status = SANE_STATUS_UNSUPPORTED; } DBG (DBG_proc, "sane_set_io_mode: exit\n"); return status; } SANE_Status sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { DBG (DBG_proc, "sane_get_select_fd: enter\n"); DBG (DBG_proc, "sane_get_select_fd: exit\n"); return SANE_STATUS_UNSUPPORTED; } void sane_cancel (SANE_Handle handle) { Matsushita_Scanner *dev = handle; DBG (DBG_proc, "sane_cancel: enter\n"); do_cancel (dev); DBG (DBG_proc, "sane_cancel: exit\n"); } void sane_close (SANE_Handle handle) { Matsushita_Scanner *dev = handle; Matsushita_Scanner *dev_tmp; DBG (DBG_proc, "sane_close: enter\n"); do_cancel (dev); matsushita_close (dev); /* Unlink dev. */ if (first_dev == dev) { first_dev = dev->next; } else { dev_tmp = first_dev; while (dev_tmp->next && dev_tmp->next != dev) { dev_tmp = dev_tmp->next; } if (dev_tmp->next != NULL) { dev_tmp->next = dev_tmp->next->next; } } matsushita_free (dev); num_devices--; DBG (DBG_proc, "sane_close: exit\n"); } void sane_exit (void) { DBG (DBG_proc, "sane_exit: enter\n"); while (first_dev) { sane_close (first_dev); } if (devlist) { free (devlist); devlist = NULL; } DBG (DBG_proc, "sane_exit: exit\n"); } sane-backends-1.0.29/backend/bh.h0000666000000000000000000006744213615534521013347 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1999,2000 Tom Martone This file is part of a SANE backend for Bell and Howell Copiscan II Scanners using the Remote SCSI Controller(RSC). 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef BH_H #define BH_H 1 #ifndef PATH_MAX #define PATH_MAX (1024) #endif #define BH_CONFIG_FILE "bh.conf" /* number of barcode types that can be searched at one time */ #define NUM_SEARCH_BARS 6 /* number of additional scanning/decoding sections supported */ #define NUM_SECTIONS 8 /* number of possible reads per scan plus the extra one for * the barcode file */ #define NUM_READS 56 + 1 /* specify sanity limits for autoborder detection and barcode decoding */ #define BH_AUTOBORDER_TRIES 100 #define BH_DECODE_TRIES 100 /* specify a fudge factor in mm for border around decoded barcodes */ #define BH_DECODE_FUDGE 1.0 /* section flags - what operation(s) to perform on section */ #define BH_SECTION_FRONT_IMAGE (1 << 0) #define BH_SECTION_BACK_IMAGE (1 << 1) #define BH_SECTION_FRONT_BAR (1 << 2) #define BH_SECTION_BACK_BAR (1 << 3) #define BH_SECTION_FRONT_PATCH (1 << 4) #define BH_SECTION_BACK_PATCH (1 << 5) typedef enum { BH_UNIT_INCH, BH_UNIT_MM, BH_UNIT_POINT } bh_measureUnit; typedef enum { BH_COMP_NONE, BH_COMP_G31D, BH_COMP_G32D, BH_COMP_G42D } bh_compress; typedef enum { BH_ROTATION_0, BH_ROTATION_90, BH_ROTATION_180, BH_ROTATION_270 } bh_rotation; typedef enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, /* inquiry string */ OPT_INQUIRY, /* preview mode */ OPT_PREVIEW, /* scan mode */ OPT_SCAN_MODE, /* resolution */ OPT_RESOLUTION, /* hardware compression */ OPT_COMPRESSION, OPT_GEOMETRY_GROUP, /* automatic border detection */ OPT_AUTOBORDER, /* hardware rotation */ OPT_ROTATION, /* hardware deskew */ OPT_DESKEW, /* paper size */ OPT_PAPER_SIZE, /* top-left x */ OPT_TL_X, /* top-left y */ OPT_TL_Y, /* bottom-right x */ OPT_BR_X, /* bottom-right y */ OPT_BR_Y, OPT_FEEDER_GROUP, /* scan source (eg. ADF) */ OPT_SCAN_SOURCE, /* scan in batch mode */ OPT_BATCH, /* scan both sides of the page */ OPT_DUPLEX, /* timeout in seconds with manual feed */ OPT_TIMEOUT_MANUAL, /* timeout in seconds with ADF */ OPT_TIMEOUT_ADF, /* check for page in ADF before scanning */ OPT_CHECK_ADF, OPT_ENHANCEMENT_GROUP, /* Enables the scanner's control panel */ OPT_CONTROL_PANEL, /* ACE Function */ OPT_ACE_FUNCTION, /* ACE Sensitivity */ OPT_ACE_SENSITIVITY, /* Brightness */ OPT_BRIGHTNESS, /* Threshold */ OPT_THRESHOLD, /* Contrast */ OPT_CONTRAST, /* Negative (reverse image) */ OPT_NEGATIVE, OPT_ICON_GROUP, /* Width of icon (thumbnail) image in pixels */ OPT_ICON_WIDTH, /* Length of icon (thumbnail) image in pixels */ OPT_ICON_LENGTH, OPT_BARCODE_GROUP, /* Add to barcode search priority. */ OPT_BARCODE_SEARCH_BAR, /* Barcode search count (1-7, default 3). */ OPT_BARCODE_SEARCH_COUNT, /* Barcode search mode. * (1 = horizontal,2 = vertical, 6 = v then h, 9 = h then v). */ OPT_BARCODE_SEARCH_MODE, /* Patch code min height (def=127 (5mm)) */ OPT_BARCODE_HMIN, /* Barcode search timeout in ms * (20-65535,default is disabled). */ OPT_BARCODE_SEARCH_TIMEOUT, /* Specify image sections and functions */ OPT_SECTION, /* Specifies the maximum relation from the widest to * the smallest bar */ OPT_BARCODE_RELMAX, /* Specifies the minimum number of bars in Bar/Patch code */ OPT_BARCODE_BARMIN, /* Specifies the maximum number of bars in a Bar/Patch code */ OPT_BARCODE_BARMAX, /* Specifies the image contrast used in decoding. * Use higher values when there are more white pixels * in the code */ OPT_BARCODE_CONTRAST, /* Controls Patch Code detection. */ OPT_BARCODE_PATCHMODE, /* must come last: */ NUM_OPTIONS } BH_Option; /* macros for accessing the value for an option within a scanning context */ #define _OPT_VAL_WORD(s, o) ((s)->val[(o)].w) #define _OPT_VAL_WORD_THOUSANDTHS(s, o) \ (SANE_UNFIX(_OPT_VAL_WORD((s), (o))) * 1000.0 / MM_PER_INCH) #define _OPT_VAL_STRING(s, o) ((s)->val[(o)].s) #define _OPT_VAL_WORD_ARRAY(s, o) ((s)->val[(o)].wa) typedef struct _BH_Paper { SANE_String name; /* paper dimensions in mm */ double width, length; } BH_Paper; typedef struct _BH_Section { /* section dimensions - in millimeters */ u_long top, left, width, length; /* compression type/arg/frameformat */ SANE_Byte compressiontype; SANE_Byte compressionarg; SANE_Frame format; /* Flags (see BH_SECTION_...) indicating operation(s) to perform * on the section. If zero, the section is completely disabled * and will not even be defined in set_window. */ SANE_Word flags; } BH_Section; typedef struct _BH_Info { SANE_Range x_range; SANE_Range y_range; SANE_Int res_default; SANE_Bool autoborder_default; SANE_Bool batch_default; SANE_Bool deskew_default; SANE_Bool check_adf_default; SANE_Bool duplex_default; SANE_Int timeout_adf_default; SANE_Int timeout_manual_default; SANE_Bool control_panel_default; /* additional discovered/guessed capabilities */ SANE_Bool canACE; SANE_Bool canDuplex; SANE_Bool canCheckADF; /* standard information */ SANE_Byte devtype; SANE_Char vendor[9]; /* model name */ SANE_Char product[17]; /* product name */ SANE_Char revision[5]; /* revision */ /* VPD information */ SANE_Bool canADF; /* is there an ADF available */ SANE_Bool colorBandW; /* can scanner do black and white */ SANE_Bool colorHalftone; /* can scanner do Halftone */ SANE_Bool canWhiteFrame; /* data processing: White Framing */ SANE_Bool canBlackFrame; /* data processing: Black Framing */ SANE_Bool canEdgeExtract; /* data processing: ACE: Edge Extraction */ SANE_Bool canNoiseFilter; /* data processing: ACE: Noise Filtering */ SANE_Bool canSmooth; /* data processing: ACE: Smoothing */ SANE_Bool canLineBold; /* data processing: ACE: LineBolding */ SANE_Bool comprG3_1D; /* compression: Group 3, 1 dimensional */ SANE_Bool comprG3_2D; /* compression: Group 3, 2 dimensional */ SANE_Bool comprG4; /* compression: Group 4 */ SANE_Bool canBorderRecog; /* can do border recognition */ SANE_Bool canBarCode; /* bar code support available */ SANE_Bool canIcon; /* icon support available */ SANE_Bool canSection; /* section support available */ SANE_Int lineMaxBytes; /* maximum bytes per scan-line */ /* jis information */ SANE_Int resBasicX; /* basic X resolution */ SANE_Int resBasicY; /* basic Y resolution */ SANE_Int resMaxX; /* maximum X resolution */ SANE_Int resMaxY; /* maximum Y resolution */ SANE_Int resMinX; /* minimum X resolution */ SANE_Int resMinY; /* minimum Y resolution */ SANE_Int resStdList[16+1]; /* list of available standard resolutions * (first slot is the length) */ SANE_Int winWidth; /* length of window (in BasicX res DPI) */ SANE_Int winHeight; /* height of window (in BasicY res DPI) */ } BH_Info; typedef struct _BH_Device BH_Device; struct _BH_Device { BH_Device *next; SANE_Device sane; BH_Info info; }; typedef struct _BH_Scanner BH_Scanner; struct _BH_Scanner { /* all the state needed to define a scan request: */ /* linked list for housekeeping */ BH_Scanner *next; /* scanner dependent/low-level state: */ BH_Device *hw; /* SCSI filedescriptor */ int fd; /* tempfile which is used to send decoded barcode data */ FILE *barf; char barfname[PATH_MAX+1]; /* SANE option descriptors and values */ SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; /* additional values that don't fit into Option_Value representation */ SANE_Byte search_bars[NUM_SEARCH_BARS]; BH_Section sections[NUM_SECTIONS]; SANE_Int num_sections; /* SANE image parameters */ SANE_Parameters params; /* state information - not options */ /* Basic Measurement Unit */ SANE_Int bmu; /* Measurement Unit Divisor */ SANE_Int mud; /* track data to be read. ReadList contains the codes of the read types * (see BH_READ_TYPE...) to perform, readcnt is the total number of reads * for this scan and readptr points to the current read operation. */ SANE_Byte readlist[NUM_READS]; SANE_Int readcnt, readptr; u_long InvalidBytes; SANE_Bool scanning; SANE_Bool cancelled; SANE_Bool backpage; SANE_Bool barcodes; SANE_Bool patchcodes; SANE_Bool icons; u_long iconwidth, iconlength; SANE_Bool barcode_not_found; }; static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; static const SANE_Range u16_range = { 0, /* minimum */ 65535, /* maximum */ 0 /* quantization */ }; static const SANE_Range icon_range = { 0, /* minimum */ 3600, /* maximum */ 8 /* quantization */ }; static const SANE_Range barcode_search_timeout_range = { 20, /* minimum */ 65535, /* maximum */ 0 /* quantization */ }; static const SANE_Range barcode_hmin_range = { 1, /* minimum */ 1660, /* maximum (when converted from mm * to thousandths will still be less * than 65536) */ 0 /* quantization */ }; static const SANE_Range barcode_search_count_range = { 1, /* minimum */ 7, /* maximum */ 0 /* quantization */ }; static const SANE_Range barcode_relmax_range = { 0, /* minimum */ 6, /* maximum */ 0 /* quantization */ }; static const SANE_Range barcode_contrast_range = { 0, /* minimum */ 6, /* maximum */ 0 /* quantization */ }; static const SANE_Range barcode_patchmode_range = { 0, /* minimum */ 1, /* maximum */ 0 /* quantization */ }; static const SANE_Range ace_function_range = { -4, /* minimum */ 4, /* maximum */ 0 /* quantization */ }; static const SANE_Range ace_sensitivity_range = { 0, /* minimum */ 9, /* maximum */ 0 /* quantization */ }; static SANE_String_Const scan_mode_list[] = { "lineart", "halftone", 0 }; static SANE_String_Const scan_mode_min_list[] = { "lineart", 0 }; static SANE_String_Const barcode_search_mode_list[] = { "horiz-vert", /* 9 */ "horizontal", /* 1 */ "vertical", /* 2 */ "vert-horiz", /* 6 */ 0 }; static SANE_String_Const scan_source_list[] = { "Automatic Document Feeder", "Manual Feed Tray", 0 }; static SANE_String_Const compression_list[] = { "none", "g31d", "g32d", "g42d", 0 }; /* list of supported bar/patch codes */ static SANE_String_Const barcode_search_bar_list[] = { "none", "ean-8", "ean-13", "reserved-ean-add", "code39", "code2-5-interleaved", "code2-5-3lines-matrix", "code2-5-3lines-datalogic", "code2-5-5lines-industrial", "patchcode", "codabar", "codabar-with-start-stop", "code39ascii", "code128", "code2-5-5lines-iata", 0 }; /* list of supported rotation angles */ static SANE_String_Const rotation_list[] = { "0", "90", "180", "270", 0 }; /* list of support paper sizes */ /* 'custom' MUST be item 0; otherwise a width or length of 0 indicates * the maximum value supported by the scanner */ static const BH_Paper paper_sizes[] = { {"Custom", 0.0, 0.0}, {"Letter", 215.9, 279.4}, {"Legal", 215.9, 355.6}, {"A3", 297, 420}, {"A4", 210, 297}, {"A5", 148.5, 210}, {"A6", 105, 148.5}, {"B4", 250, 353}, {"B5", 182, 257}, {"Full", 0.0, 0.0}, }; /* MUST be kept in sync with paper_sizes */ static SANE_String_Const paper_list[] = { "Custom", "Letter", "Legal", "A3", "A4", "A5", "A6", "B4", "B5", "Full", 0 }; static /* inline */ int _is_host_little_endian(void); static /* inline */ int _is_host_little_endian() { SANE_Int val = 255; unsigned char *firstbyte = (unsigned char *) &val; return (*firstbyte == 255) ? SANE_TRUE : SANE_FALSE; } static /* inline */ void _lto2b(u_long val, SANE_Byte *bytes) { bytes[0] = (val >> 8) & 0xff; bytes[1] = val & 0xff; } static /* inline */ void _lto3b(u_long val, SANE_Byte *bytes) { bytes[0] = (val >> 16) & 0xff; bytes[1] = (val >> 8) & 0xff; bytes[2] = val & 0xff; } static /* inline */ void _lto4b(u_long val, SANE_Byte *bytes) { bytes[0] = (val >> 24) & 0xff; bytes[1] = (val >> 16) & 0xff; bytes[2] = (val >> 8) & 0xff; bytes[3] = val & 0xff; } static /* inline */ u_long _2btol(SANE_Byte *bytes) { u_long rv; rv = (bytes[0] << 8) | bytes[1]; return rv; } static /* inline */ u_long _4btol(SANE_Byte *bytes) { u_long rv; rv = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; return rv; } #define SANE_TITLE_SCAN_MODE_GROUP "Scan Mode" #define SANE_TITLE_GEOMETRY_GROUP "Geometry" #define SANE_TITLE_FEEDER_GROUP "Feeder" #define SANE_TITLE_ENHANCEMENT_GROUP "Enhancement" #define SANE_TITLE_ICON_GROUP "Icon" #define SANE_TITLE_BARCODE_GROUP "Barcode" #define SANE_NAME_AUTOBORDER "autoborder" #define SANE_TITLE_AUTOBORDER "Autoborder" #define SANE_DESC_AUTOBORDER "Enable Automatic Border Detection" #define SANE_NAME_COMPRESSION "compression" #define SANE_TITLE_COMPRESSION "Data Compression" #define SANE_DESC_COMPRESSION "Sets the compression mode of the scanner" #define SANE_NAME_ROTATION "rotation" #define SANE_TITLE_ROTATION "Page Rotation" #define SANE_DESC_ROTATION "Sets the page rotation mode of the scanner" #define SANE_NAME_DESKEW "deskew" #define SANE_TITLE_DESKEW "Page Deskew" #define SANE_DESC_DESKEW "Enable Deskew Mode" #define SANE_NAME_TIMEOUT_ADF "timeout-adf" #define SANE_TITLE_TIMEOUT_ADF "ADF Timeout" #define SANE_DESC_TIMEOUT_ADF "Sets the timeout in seconds for the ADF" #define SANE_NAME_TIMEOUT_MANUAL "timeout-manual" #define SANE_TITLE_TIMEOUT_MANUAL "Manual Timeout" #define SANE_DESC_TIMEOUT_MANUAL "Sets the timeout in seconds for manual feeder" #define SANE_NAME_BATCH "batch" #define SANE_TITLE_BATCH "Batch" #define SANE_DESC_BATCH "Enable Batch Mode" #define SANE_NAME_CHECK_ADF "check-adf" #define SANE_TITLE_CHECK_ADF "Check ADF" #define SANE_DESC_CHECK_ADF "Check ADF Status prior to starting scan" #define SANE_NAME_DUPLEX "duplex" #define SANE_TITLE_DUPLEX "Duplex" #define SANE_DESC_DUPLEX "Enable Duplex (Dual-Sided) Scanning" #define SANE_NAME_BARCODE_SEARCH_COUNT "barcode-search-count" #define SANE_TITLE_BARCODE_SEARCH_COUNT "Barcode Search Count" #define SANE_DESC_BARCODE_SEARCH_COUNT "Number of barcodes to search for in the scanned image" #define SANE_NAME_BARCODE_HMIN "barcode-hmin" #define SANE_TITLE_BARCODE_HMIN "Barcode Minimum Height" #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" #define SANE_DESC_BARCODE_SEARCH_MODE "Chooses the orientation of barcodes to be searched" #define SANE_NAME_BARCODE_SEARCH_TIMEOUT "barcode-search-timeout" #define SANE_TITLE_BARCODE_SEARCH_TIMEOUT "Barcode Search Timeout" #define SANE_DESC_BARCODE_SEARCH_TIMEOUT "Sets the timeout for barcode searching" #define SANE_NAME_BARCODE_SEARCH_BAR "barcode-search-bar" #define SANE_TITLE_BARCODE_SEARCH_BAR "Barcode Search Bar" #define SANE_DESC_BARCODE_SEARCH_BAR "Specifies the barcode type to search for" #define SANE_NAME_SECTION "section" #define SANE_TITLE_SECTION "Image/Barcode Search Sections" #define SANE_DESC_SECTION "Specifies an image section and/or a barcode search region" #define SANE_NAME_BARCODE_RELMAX "barcode-relmax" #define SANE_TITLE_BARCODE_RELMAX "Barcode RelMax" #define SANE_DESC_BARCODE_RELMAX "Specifies the maximum relation from the widest to the smallest bar" #define SANE_NAME_BARCODE_BARMIN "barcode-barmin" #define SANE_TITLE_BARCODE_BARMIN "Barcode Bar Minimum" #define SANE_DESC_BARCODE_BARMIN "Specifies the minimum number of bars in Bar/Patch code" #define SANE_NAME_BARCODE_BARMAX "barcode-barmax" #define SANE_TITLE_BARCODE_BARMAX "Barcode Bar Maximum" #define SANE_DESC_BARCODE_BARMAX "Specifies the maximum number of bars in a Bar/Patch code" #define SANE_NAME_BARCODE_CONTRAST "barcode-contrast" #define SANE_TITLE_BARCODE_CONTRAST "Barcode Contrast" #define SANE_DESC_BARCODE_CONTRAST "Specifies the image contrast used in decoding. Use higher values when " \ "there are more white pixels in the code" #define SANE_NAME_BARCODE_PATCHMODE "barcode-patchmode" #define SANE_TITLE_BARCODE_PATCHMODE "Barcode Patch Mode" #define SANE_DESC_BARCODE_PATCHMODE "Controls Patch Code detection." #define SANE_NAME_CONTROL_PANEL "control-panel" #define SANE_TITLE_CONTROL_PANEL "Control Panel " #define SANE_DESC_CONTROL_PANEL "Enables the scanner's control panel" #define SANE_NAME_ACE_FUNCTION "ace-function" #define SANE_TITLE_ACE_FUNCTION "ACE Function" #define SANE_DESC_ACE_FUNCTION "ACE Function" #define SANE_NAME_ACE_SENSITIVITY "ace-sensitivity" #define SANE_TITLE_ACE_SENSITIVITY "ACE Sensitivity" #define SANE_DESC_ACE_SENSITIVITY "ACE Sensitivity" #define SANE_NAME_ICON_WIDTH "icon-width" #define SANE_TITLE_ICON_WIDTH "Icon Width" #define SANE_DESC_ICON_WIDTH "Width of icon (thumbnail) image in pixels" #define SANE_NAME_ICON_LENGTH "icon-length" #define SANE_TITLE_ICON_LENGTH "Icon Length" #define SANE_DESC_ICON_LENGTH "Length of icon (thumbnail) image in pixels" #define SANE_NAME_PAPER_SIZE "paper-size" #define SANE_TITLE_PAPER_SIZE "Paper Size" #define SANE_DESC_PAPER_SIZE "Specify the scan window geometry by specifying the paper size " \ "of the documents to be scanned" #define SANE_NAME_INQUIRY "inquiry" #define SANE_TITLE_INQUIRY "Inquiry Data" #define SANE_DESC_INQUIRY "Displays scanner inquiry data" /* low level SCSI commands and buffers */ /* SCSI commands */ #define BH_SCSI_TEST_UNIT_READY 0x00 #define BH_SCSI_SET_WINDOW 0x24 #define BH_SCSI_GET_WINDOW 0x25 #define BH_SCSI_READ_SCANNED_DATA 0x28 #define BH_SCSI_INQUIRY 0x12 #define BH_SCSI_MODE_SELECT 0x15 #define BH_SCSI_START_SCAN 0x1b #define BH_SCSI_MODE_SENSE 0x1a #define BH_SCSI_GET_BUFFER_STATUS 0x34 #define BH_SCSI_OBJECT_POSITION 0x31 /* page codes used with BH_SCSI_INQUIRY */ #define BH_INQUIRY_STANDARD_PAGE_CODE 0x00 #define BH_INQUIRY_VPD_PAGE_CODE 0xC0 #define BH_INQUIRY_JIS_PAGE_CODE 0xF0 /* page codes used with BH_SCSI_MODE_SELECT and BH_SCSI_MODE_SENSE */ #define BH_MODE_MEASUREMENT_PAGE_CODE 0x03 #define BH_MODE_TIMEOUT_PAGE_CODE 0x20 #define BH_MODE_ICON_PAGE_CODE 0x21 #define BH_MODE_BARCODE_PRIORITY_PAGE_CODE 0x30 #define BH_MODE_BARCODE_PARAM1_PAGE_CODE 0x31 #define BH_MODE_BARCODE_PARAM2_PAGE_CODE 0x32 #define BH_MODE_BARCODE_PARAM3_PAGE_CODE 0x32 /* data type codes used with BH_SCSI_READ_SCANNED_DATA */ #define BH_SCSI_READ_TYPE_FRONT 0x80 /* 0x81 thru 0x88 read front page sections 1 thru 8 respectively */ #define BH_SCSI_READ_TYPE_BACK 0x90 /* 0x91 thru 0x98 read back page sections 1 thru 8 respectively */ #define BH_SCSI_READ_TYPE_FRONT_BARCODE 0xA0 /* 0xA1 thru 0xA8 read front page barcodes in sections 1 thru 8 respectively */ #define BH_SCSI_READ_TYPE_BACK_BARCODE 0xB0 /* 0xB1 thru 0xB8 read back page barcodes in sections 1 thru 8 respectively */ #define BH_SCSI_READ_TYPE_FRONT_PATCHCODE 0xC0 /* 0xC1 thru 0xC8 read front page patchcodes in sections 1 thru 8 respectively */ #define BH_SCSI_READ_TYPE_BACK_PATCHCODE 0xD0 /* 0xD1 thru 0xD8 read back page patchcodes in sections 1 thru 8 respectively */ #define BH_SCSI_READ_TYPE_FRONT_ICON 0x89 #define BH_SCSI_READ_TYPE_BACK_ICON 0x99 /* this one is not a real readtype; it's used to help transfer the barcode file */ #define BH_SCSI_READ_TYPE_SENDBARFILE 0xBB #define BH_HAS_IMAGE_DATA(i) ((i) >= BH_SCSI_READ_TYPE_FRONT && \ (i) <= BH_SCSI_READ_TYPE_BACK_ICON) /* batchmode codes used with BH_SCSI_SET_WINDOW */ #define BH_BATCH_DISABLE 0x00 #define BH_BATCH_ENABLE 0x01 #define BH_BATCH_TERMINATE 0x02 #define BH_BATCH_ABORT 0x03 /* deskew mode codes used with BH_SCSI_SET_WINDOW */ #define BH_DESKEW_DISABLE 0x00 /* border detection is assumed, see page 3-37 of 8000 manual */ #define BH_DESKEW_ENABLE 0x04 /* deskew and border detection */ /* used with BH_SCSI_SET_WINDOW, BH_SCSI_GET_WINDOW */ typedef struct _BH_SectionBlock { SANE_Byte ul_x[4]; SANE_Byte ul_y[4]; SANE_Byte width[4]; SANE_Byte length[4]; SANE_Byte compressiontype; SANE_Byte compressionarg; SANE_Byte reserved[6]; } BH_SectionBlock; /* used with BH_SCSI_SET_WINDOW, BH_SCSI_GET_WINDOW */ struct window_data { /* window descriptor block byte layout */ SANE_Byte windowid; /* 0 */ SANE_Byte autoborder; /* 1 */ SANE_Byte xres[2]; /* 2,3 */ SANE_Byte yres[2]; /* 4,5 */ SANE_Byte ulx[4]; /* 6-9 */ SANE_Byte uly[4]; /* 10-13 */ SANE_Byte windowwidth[4]; /* 14-17 */ SANE_Byte windowlength[4]; /* 18-21 */ SANE_Byte brightness; /* 22 */ SANE_Byte threshold; /* 23 */ SANE_Byte contrast; /* 24 */ SANE_Byte imagecomposition; /* 25 */ SANE_Byte bitsperpixel; /* 26 */ SANE_Byte halftonecode; /* 27 */ SANE_Byte halftoneid; /* 28 */ SANE_Byte paddingtype; /* 29 */ SANE_Byte bitordering[2]; /* 30,31 */ SANE_Byte compressiontype; /* 32 */ SANE_Byte compressionarg; /* 33 */ SANE_Byte reserved2[6]; /* 34-39 */ SANE_Byte remote; /* 40 */ SANE_Byte acefunction; /* 41 */ SANE_Byte acesensitivity; /* 42 */ SANE_Byte batchmode; /* 43 */ SANE_Byte reserved3[2]; /* 44,45 */ SANE_Byte border_rotation; /* 46 added this for copiscan 8080 */ SANE_Byte reserved4[17]; /* 47-63 added this for copiscan 8080 */ BH_SectionBlock sectionblock[NUM_SECTIONS]; }; /* used with BH_SCSI_READ_SCANNED_DATA */ /* structure for returned decoded barcode data */ struct barcode_data { SANE_Byte reserved1[2]; SANE_Byte barcodetype[2]; SANE_Byte statusflag[2]; SANE_Byte barcodeorientation[2]; SANE_Byte posxa[2]; SANE_Byte posya[2]; SANE_Byte posxb[2]; SANE_Byte posyb[2]; SANE_Byte posxc[2]; SANE_Byte posyc[2]; SANE_Byte posxd[2]; SANE_Byte posyd[2]; SANE_Byte barcodesearchtime[2]; SANE_Byte reserved2[13]; SANE_Byte barcodelen; SANE_Byte barcodedata[160]; }; /* structure for returned icon data block */ struct icon_data { SANE_Byte windowwidth[4]; SANE_Byte windowlength[4]; SANE_Byte iconwidth[4]; SANE_Byte iconwidthbytes[4]; SANE_Byte iconlength[4]; SANE_Byte bitordering; SANE_Byte reserved[7]; SANE_Byte icondatalen[4]; }; /* used with BH_SCSI_INQUIRY */ /* Standard Data [EVPD=0] */ struct inquiry_standard_data { SANE_Byte devtype; SANE_Byte reserved[7]; SANE_Byte vendor[8]; SANE_Byte product[16]; SANE_Byte revision[4]; }; /* VPD Information [EVPD=1, PageCode=C0H] */ struct inquiry_vpd_data { SANE_Byte devtype; SANE_Byte pagecode; SANE_Byte reserved1; SANE_Byte alloclen; SANE_Byte adf; SANE_Byte reserved2[2]; SANE_Byte imagecomposition; SANE_Byte imagedataprocessing[2]; SANE_Byte compression; SANE_Byte reserved3; SANE_Byte sizerecognition; SANE_Byte optionalfeatures; SANE_Byte xmaxoutputbytes[2]; }; /* JIS Information [EVPD=1, PageCode=F0H] */ struct inquiry_jis_data { SANE_Byte devtype; SANE_Byte pagecode; SANE_Byte jisversion; SANE_Byte reserved1; SANE_Byte alloclen; SANE_Byte basicxres[2]; SANE_Byte basicyres[2]; SANE_Byte resolutionstep; SANE_Byte maxxres[2]; SANE_Byte maxyres[2]; SANE_Byte minxres[2]; SANE_Byte minyres[2]; SANE_Byte standardres[2]; SANE_Byte windowwidth[4]; SANE_Byte windowlength[4]; SANE_Byte functions; SANE_Byte reserved2; }; /* used with BH_SCSI_MODE_SELECT and BH_SCSI_MODE_SENSE */ /* Scanning Measurement Parameters PageCode=03H */ struct mode_page_03 { SANE_Byte modedatalen; SANE_Byte mediumtype; SANE_Byte devicespecificparam; SANE_Byte blockdescriptorlen; SANE_Byte pagecode; SANE_Byte paramlen; SANE_Byte bmu; SANE_Byte reserved1; SANE_Byte mud[2]; SANE_Byte reserved2[2]; }; /* Scan Command Timeout PageCode=20H */ struct mode_page_20 { SANE_Byte modedatalen; SANE_Byte mediumtype; SANE_Byte devicespecificparam; SANE_Byte blockdescriptorlen; SANE_Byte pagecode; SANE_Byte paramlen; SANE_Byte timeoutmanual; SANE_Byte timeoutadf; SANE_Byte reserved[4]; }; /* Icon Definition PageCode=21H */ struct mode_page_21 { SANE_Byte modedatalen; SANE_Byte mediumtype; SANE_Byte devicespecificparam; SANE_Byte blockdescriptorlen; SANE_Byte pagecode; SANE_Byte paramlen; SANE_Byte iconwidth[2]; SANE_Byte iconlength[2]; SANE_Byte reserved[2]; }; /* Bar/Patch Code search priority order PageCode=30H */ struct mode_page_30 { SANE_Byte modedatalen; SANE_Byte mediumtype; SANE_Byte devicespecificparam; SANE_Byte blockdescriptorlen; SANE_Byte pagecode; SANE_Byte paramlen; SANE_Byte priority[6]; }; /* Bar/Patch Code search parameters 1 of 3 PageCode=31H */ struct mode_page_31 { SANE_Byte modedatalen; SANE_Byte mediumtype; SANE_Byte devicespecificparam; SANE_Byte blockdescriptorlen; SANE_Byte pagecode; SANE_Byte paramlen; SANE_Byte minbarheight[2]; SANE_Byte searchcount; SANE_Byte searchmode; SANE_Byte searchtimeout[2]; }; /* Bar/Patch Code search parameters 2 of 3 PageCode=32H */ struct mode_page_32 { SANE_Byte modedatalen; SANE_Byte mediumtype; SANE_Byte devicespecificparam; SANE_Byte blockdescriptorlen; SANE_Byte pagecode; SANE_Byte paramlen; SANE_Byte relmax[2]; SANE_Byte barmin[2]; SANE_Byte barmax[2]; }; /* Bar/Patch Code search parameters 3 of 3 PageCode=33H */ struct mode_page_33 { SANE_Byte modedatalen; SANE_Byte mediumtype; SANE_Byte devicespecificparam; SANE_Byte blockdescriptorlen; SANE_Byte pagecode; SANE_Byte paramlen; SANE_Byte barcodecontrast[2]; SANE_Byte patchmode[2]; SANE_Byte reserved[2]; }; #ifndef sane_isbasicframe #define SANE_FRAME_TEXT 10 #define SANE_FRAME_JPEG 11 #define SANE_FRAME_G31D 12 #define SANE_FRAME_G32D 13 #define SANE_FRAME_G42D 14 #define sane_strframe(f) ( (f) == SANE_FRAME_GRAY ? "gray" : \ (f) == SANE_FRAME_RGB ? "RGB" : \ (f) == SANE_FRAME_RED ? "red" : \ (f) == SANE_FRAME_GREEN ? "green" : \ (f) == SANE_FRAME_BLUE ? "blue" : \ (f) == SANE_FRAME_TEXT ? "text" : \ (f) == SANE_FRAME_JPEG ? "jpeg" : \ (f) == SANE_FRAME_G31D ? "g31d" : \ (f) == SANE_FRAME_G32D ? "g32d" : \ (f) == SANE_FRAME_G42D ? "g42d" : \ "unknown" ) #define sane_isbasicframe(f) ( (f) == SANE_FRAME_GRAY || \ (f) == SANE_FRAME_RGB || \ (f) == SANE_FRAME_RED || \ (f) == SANE_FRAME_GREEN || \ (f) == SANE_FRAME_BLUE ) #endif #endif /* BH_H */ sane-backends-1.0.29/backend/abaton.conf.in0000666000000000000000000000003113615534521015302 00000000000000scsi ABATON /dev/scanner sane-backends-1.0.29/backend/ricoh.h0000666000000000000000000001777113615534521014062 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1998, Feico W. Dillema 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* $Id$ */ #ifndef ricoh_h #define ricoh_h 1 #include #include "../include/sane/config.h" /* defines for scan_image_mode field */ #define RICOH_BINARY_MONOCHROME 0 #define RICOH_DITHERED_MONOCHROME 1 #define RICOH_GRAYSCALE 2 /* sizes for mode parameter's base_measurement_unit */ #define INCHES 0 #define MILLIMETERS 1 #define POINTS 2 #define DEFAULT_MUD 1200 #define MEASUREMENTS_PAGE (SANE_Byte)(0x03) /* Mode Page Control */ #define PC_CURRENT 0x00 #define PC_CHANGE 0x40 #define PC_DEFAULT 0x80 #define PC_SAVED 0xc0 static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_HALFTONE, SANE_VALUE_SCAN_MODE_GRAY, 0 }; static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; static const SANE_Range is50_res_range = { 75, /* minimum */ 400, /* maximum */ 0 /* quantization */ }; static const SANE_Range is60_res_range = { 100, /* minimum */ 600, /* maximum */ 0 /* quantization */ }; static const SANE_Range default_x_range = { 0, /* minimum */ (SANE_Word) (8 * DEFAULT_MUD), /* maximum */ 2 /* quantization */ }; static const SANE_Range default_y_range = { 0, /* minimum */ (SANE_Word) (14 * DEFAULT_MUD), /* maximum */ 2 /* quantization */ }; static inline void _lto2b(SANE_Int val, SANE_Byte *bytes) { bytes[0] = (val >> 8) & 0xff; bytes[1] = val & 0xff; } static inline void _lto3b(SANE_Int val, SANE_Byte *bytes) { bytes[0] = (val >> 16) & 0xff; bytes[1] = (val >> 8) & 0xff; bytes[2] = val & 0xff; } static inline void _lto4b(SANE_Int val, SANE_Byte *bytes) { bytes[0] = (val >> 24) & 0xff; bytes[1] = (val >> 16) & 0xff; bytes[2] = (val >> 8) & 0xff; bytes[3] = val & 0xff; } static inline SANE_Int _2btol(SANE_Byte *bytes) { SANE_Int rv; rv = (bytes[0] << 8) | bytes[1]; return (rv); } static inline SANE_Int _3btol(SANE_Byte *bytes) { SANE_Int rv; rv = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2]; return (rv); } static inline SANE_Int _4btol(SANE_Byte *bytes) { SANE_Int rv; rv = (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; return (rv); } typedef enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_X_RESOLUTION, OPT_Y_RESOLUTION, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_BRIGHTNESS, OPT_CONTRAST, /* must come last: */ NUM_OPTIONS } Ricoh_Option; typedef struct Ricoh_Info { SANE_Range xres_range; SANE_Range yres_range; SANE_Range x_range; SANE_Range y_range; SANE_Range brightness_range; SANE_Range contrast_range; SANE_Int xres_default; SANE_Int yres_default; SANE_Int image_mode_default; SANE_Int brightness_default; SANE_Int contrast_default; SANE_Int bmu; SANE_Int mud; } Ricoh_Info; typedef struct Ricoh_Device { struct Ricoh_Device *next; SANE_Device sane; Ricoh_Info info; } Ricoh_Device; typedef struct Ricoh_Scanner { /* all the state needed to define a scan request: */ struct Ricoh_Scanner *next; int fd; /* SCSI filedescriptor */ SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Parameters params; /* scanner dependent/low-level state: */ Ricoh_Device *hw; SANE_Int xres; SANE_Int yres; SANE_Int ulx; SANE_Int uly; SANE_Int width; SANE_Int length; SANE_Int brightness; SANE_Int contrast; SANE_Int image_composition; SANE_Int bpp; SANE_Bool reverse; size_t bytes_to_read; int scanning; } Ricoh_Scanner; struct inquiry_data { SANE_Byte devtype; SANE_Byte byte2; SANE_Byte byte3; SANE_Byte byte4; SANE_Byte byte5; SANE_Byte res1[2]; SANE_Byte flags; SANE_Byte vendor[8]; SANE_Byte product[8]; SANE_Byte revision[4]; SANE_Byte byte[60]; }; #define RICOH_WINDOW_DATA_SIZE 328 struct ricoh_window_data { /* header */ SANE_Byte reserved[6]; SANE_Byte len[2]; /* data */ SANE_Byte window_id; /* must be zero */ SANE_Byte auto_bit; SANE_Byte x_res[2]; SANE_Byte y_res[2]; SANE_Byte x_org[4]; SANE_Byte y_org[4]; SANE_Byte width[4]; SANE_Byte length[4]; SANE_Byte brightness; SANE_Byte threshold; SANE_Byte contrast; SANE_Byte image_comp; /* image composition (data type) */ SANE_Byte bits_per_pixel; SANE_Byte halftone_pattern[2]; SANE_Byte pad_type; SANE_Byte bit_ordering[2]; SANE_Byte compression_type; SANE_Byte compression_arg; SANE_Byte res3[6]; /* Vendor Specific parameter byte(s) */ /* Ricoh specific, follow the scsi2 standard ones */ SANE_Byte byte1; SANE_Byte byte2; SANE_Byte mrif_filtering_gamma_id; SANE_Byte byte3; SANE_Byte byte4; SANE_Byte binary_filter; SANE_Byte reserved2[18]; SANE_Byte reserved3[256]; }; struct measurements_units_page { SANE_Byte page_code; /* 0x03 */ SANE_Byte parameter_length; /* 0x06 */ SANE_Byte bmu; SANE_Byte res1; SANE_Byte mud[2]; SANE_Byte res2[2]; /* anybody know what `COH' may mean ??? */ #if 0 SANE_Byte more_pages[243]; /* maximum size 255 bytes (incl header) */ #endif }; struct mode_pages { SANE_Byte page_code; SANE_Byte parameter_length; SANE_Byte rest[6]; #if 0 SANE_Byte more_pages[243]; /* maximum size 255 bytes (incl header) */ #endif }; #endif /* ricoh_h */ sane-backends-1.0.29/backend/cardscan.h0000666000000000000000000001444213615534521014524 00000000000000#ifndef CARDSCAN_H #define CARDSCAN_H /* * Part of SANE - Scanner Access Now Easy. * Please see opening comment in cardscan.c */ /* ------------------------------------------------------------------------- * This option list has to contain all options for all scanners supported by * this driver. If a certain scanner cannot handle a certain option, there's * still the possibility to say so, later. */ enum scanner_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, /*mono/gray/color*/ /* must come last: */ NUM_OPTIONS }; /* values common to calib and image data */ #define HEADER_SIZE 64 #define PIXELS_PER_LINE 1208 /* values for calib data */ #define CAL_COLOR_SIZE (PIXELS_PER_LINE * 3) #define CAL_GRAY_SIZE PIXELS_PER_LINE /* values for image data */ #define MAX_PAPERLESS_LINES 210 struct scanner { /* --------------------------------------------------------------------- */ /* immutable values which are set during init of scanner. */ struct scanner *next; char *device_name; /* The name of the scanner device for sane */ /* --------------------------------------------------------------------- */ /* immutable values which are set during inquiry probing of the scanner. */ SANE_Device sane; char * vendor_name; char * product_name; /* --------------------------------------------------------------------- */ /* immutable values which are set during reading of config file. */ int has_cal_buffer; int lines_per_block; int color_block_size; int gray_block_size; /* --------------------------------------------------------------------- */ /* changeable SANE_Option structs provide our interface to frontend. */ /* long array of option structs */ SANE_Option_Descriptor opt[NUM_OPTIONS]; /* --------------------------------------------------------------------- */ /* some options require lists of strings or numbers, we keep them here */ /* instead of in global vars so that they can differ for each scanner */ /*mode group*/ SANE_String_Const mode_list[3]; /* --------------------------------------------------------------------- */ /* changeable vars to hold user input. modified by SANE_Options above */ /*mode group*/ int mode; /*color,lineart,etc*/ /* --------------------------------------------------------------------- */ /* values which are derived from setting the options above */ /* the user never directly modifies these */ /* this is defined in sane spec as a struct containing: SANE_Frame format; SANE_Bool last_frame; SANE_Int lines; SANE_Int depth; ( binary=1, gray=8, color=8 (!24) ) SANE_Int pixels_per_line; SANE_Int bytes_per_line; */ SANE_Parameters params; /* --------------------------------------------------------------------- */ /* calibration data read once */ unsigned char cal_color_b[CAL_COLOR_SIZE]; unsigned char cal_gray_b[CAL_GRAY_SIZE]; unsigned char cal_color_w[CAL_COLOR_SIZE]; unsigned char cal_gray_w[CAL_GRAY_SIZE]; /* --------------------------------------------------------------------- */ /* values which are set by scanning functions to keep track of pages, etc */ int started; int paperless_lines; /* buffer part of image */ unsigned char buffer[PIXELS_PER_LINE * 3 * 32]; /* how far we have read from scanner into buffer */ int bytes_rx; /* how far we have written from buffer to frontend */ int bytes_tx; /* --------------------------------------------------------------------- */ /* values used by the command and data sending function */ int fd; /* The scanner device file descriptor. */ }; #define USB_COMMAND_TIME 10000 #define USB_DATA_TIME 10000 #define MODE_COLOR 0 #define MODE_GRAYSCALE 1 /* ------------------------------------------------------------------------- */ #define MM_PER_UNIT_UNFIX SANE_UNFIX(SANE_FIX(MM_PER_INCH / 1200.0)) #define MM_PER_UNIT_FIX SANE_FIX(SANE_UNFIX(SANE_FIX(MM_PER_INCH / 1200.0))) #define SCANNER_UNIT_TO_FIXED_MM(number) SANE_FIX((number) * MM_PER_UNIT_UNFIX) #define FIXED_MM_TO_SCANNER_UNIT(number) SANE_UNFIX(number) / MM_PER_UNIT_UNFIX #define CONFIG_FILE "cardscan.conf" #ifndef PATH_MAX # define PATH_MAX 1024 #endif /* ------------------------------------------------------------------------- */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize); SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only); SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle); SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking); SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fdp); const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option); SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info); SANE_Status sane_start (SANE_Handle handle); SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params); SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len); void sane_cancel (SANE_Handle h); void sane_close (SANE_Handle h); void sane_exit (void); /* ------------------------------------------------------------------------- */ static SANE_Status attach_one (const char *devicename); static SANE_Status connect_fd (struct scanner *s); static SANE_Status disconnect_fd (struct scanner *s); static SANE_Status do_cmd(struct scanner *s, int shortTime, unsigned char * cmdBuff, size_t cmdLen, unsigned char * outBuff, size_t outLen, unsigned char * inBuff, size_t * inLen ); static SANE_Status load_calibration (struct scanner *s); static SANE_Status heat_lamp_color(struct scanner *s); static SANE_Status heat_lamp_gray(struct scanner *s); static SANE_Status read_from_scanner_color(struct scanner *s); static SANE_Status read_from_scanner_gray(struct scanner *s); static SANE_Status power_down(struct scanner *s); static void hexdump (int level, char *comment, unsigned char *p, int l); static size_t maxStringSize (const SANE_String_Const strings[]); #endif /* CARDSCAN_H */ sane-backends-1.0.29/backend/plustek-usbdevs.c0000666000000000000000000033147613615534521016112 00000000000000/*............................................................................. * Project : SANE library for Plustek flatbed scanners. *............................................................................. */ /** @file plustek-usbdevs.c * @brief Here we have our USB device definitions. * * Based on sources acquired from Plustek Inc.
* Copyright (C) 2001-2013 Gerhard Jaeger * * History: * - 0.40 - starting version of the USB support * - 0.41 - added EPSON1250 entries * - changed reg 0x58 of EPSON Hw0x04B8_0x010F to 0x0d * - reduced memory size of EPSON to 512 * - adjusted tpa origin of UT24 * - 0.42 - added register 0x27, 0x2c-0x37 * - tweaked EPSON1250 settings according to Gene and Reinhard * - tweaked HP2200 settings according to Stefan * - added UMAX 3400 entries * - added HP2100 settings according to Craig Smoothey * - added LM9832 based U24 * - added Canon N650U entry * - 0.43 - tweaked HP 2200C entries * - added _WAF_MISC_IO5 for HP lamp switching * - added motor profiles * - cleanup * - 0.44 - added EPSON 1260 and 660 * - added Genius Model strings * - added Canon N670U entry * - added bStepsToReverse to the HwDesc structure * - tweaked EPSON1250 settings for TPA (thanks to Till Kamppeter) * - 0.45 - added UMAX motor settings * - added UMAX 5400 settings * - added CanoScan1240 settings (thanks to Johann Philipp) * - tweaked EPSON 1260 settings * - removed EPSON 660 stuff * - added Canon 1220U entry * - added entry for Compaq S4-100 * - 0.46 - fine-tuning for the CanoScan devices * - fixed HP2200 shading position * - renamed to plustek-usbdevs.c * - 0.47 - added BearPaw 1200 settings for PID 0x4001 (LM9832) * - tweaked the LiDE20 MCLK setting for 75DPI grayscale * - enlarged the scan-area of the UMAX3400 to 11.7" * - added CanoScan D660U * - 0.48 - added another incarnation of the UMAX 3400 * - added parameters for UMAX 3450 TPA * - parameter tuning for CanoScan D660U * - cleanup * - 0.49 - tweaked motor settings for EPSON and CANON1200 * - added support for CanoScan LiDE25 * - 0.50 - cleanup * - removed obsolete _WAF_BLACKFINE * - LiDE20 does not seem to have a reliable black calibration area * so the devices now will switch off the lamp for dark calibration * - added Stephan Februarys' LiDE25 changes * - fixed high-speed feature of CanoScan D660U * - tweaked LiDE25, LiDE30 and N1220U settings * - changed high-speed setting for UMAX 3400, due to bugreport #302317 * - fixed CanoScan N650U settings * - fixed CanoScan N670U settings, see (bugreport #302738) * - added high-speed setting for HP2200 * - 0.51 - tweaked CanoScan N1220U settings again * - added settings for Syscan TravelScan 662 * - tweaked settings for Bearpaw 1200 * - fixed CanoScan LiDE20 settings, cause of various reports, seems * Canon has built-in different motortypes * - also fixed Motorsettings for LiDE30 * - 0.52 - added Q-Scan USB001 settings * - added Q-Scan USB201 settings (thanks to Hiroshi Miura) * - tweaked motor settings for Bearpaw 1200 * - added TravelScan 464 settings * - tweaked highspeed motor settings for Epson 1260 * - tweaked CanoScan N650U motor settings * *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ /* the other stuff is included by plustek.c ...*/ #include "plustek-usb.h" /** for Register 0x26 */ #define _ONE_CH_COLOR 0x04 #define _RED_CH 0x00 #define _GREEN_CH 0x08 #define _BLUE_CH 0x10 /* Plustek Model: UT12/UT16 * KH: NS9831 + TPA + Button + NEC3799 */ static DCapsDef Cap0x07B3_0x0017_0 = { { /* Normal */ {0, 93}, /* DataOrigin (X: 0, Y: 8mm from home) */ 0, -1, /* ShadingOriginY, DarkShadOrgY */ {2550, 3508}, /* Size */ {50, 50} /* MinDpi */ }, { /* Positive */ {1040 + 15, 744 - 32},/* DataOrigin (X: 7cm + 1.8cm, Y: 8mm + 5.5cm)*/ 543, -1, /* ShadingOriginY (Y: 8mm + 3.8cm) */ {473, 414}, /* Size (X: 4cm, Y: 3.5cm) */ {150, 150} /* MinDpi */ }, { /* Negative */ {1004 + 55, 744 + 12}, /* DataOrigin (X: 7cm + 1.5cm, Y: 8mm + 5.5cm)*/ /* 533 blaustichig */ 537 /* hell */ /* 543 gruenstichig */ /*543*/, -1, /* ShadingOriginY (Y: 8mm + 3.8cm) */ {567, 414}, /* Size (X: 4.8cm, Y: 3.5cm) */ {150, 150} /* MinDpi */ }, { /* Adf */ {0, 95}, /* DataOrigin (X: 0, Y: 8mm from home) */ 0, -1, /* ShadingOriginY, DarkShadOrgY */ {2550, 3508}, /* Size */ {50, 50} /* MinDpi */ }, {600, 600}, /* OpticDpi */ DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, /* wFlags */ SENSORORDER_rgb, /* bSensorOrder */ 4, /* bSensorDistance */ 4, /* bButtons */ kNEC3799, /* bCCD */ 0x07, /* bPCB */ _WAF_NONE, /* no workarounds or other special stuff needed */ _NO_MIO /* does not use misc I/O for lamp */ }; /* Plustek Model: U24 * Description of the entries, see above... */ static DCapsDef Cap0x07B3_0x0015_0 = { {{0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, {473, 414}, {150, 150}}, {{1004 + 20, 744 + 32}, 543, -1, {567, 414}, {150, 150}}, {{0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {600, 600}, 0, SENSORORDER_rgb, 4, 4, kNEC3799, 0x05, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? * KH: NS9831 + TPA + Button + NEC3799 */ static DCapsDef Cap0x07B3_0x0014_0 = { {{0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, {473, 414}, {150, 150}}, {{1004 + 20, 744 + 32}, 543, -1, {567, 414}, {150, 150}}, {{0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {600, 600}, 0, SENSORORDER_rgb, 4, 0, kNEC3799, 0x04, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? and Genius ColorPage-HR6 V2 * KH: NS9831 + TPA + Button + NEC3799 */ static DCapsDef Cap0x07B3_0x0007_0 = { {{0, 124}, 36, -1, {2550, 3508}, { 50, 50 }}, {{1040, 744}, 543, -1, { 473, 414 }, {150, 150}}, {{1004, 744}, 543, -1, { 567, 414 }, {150, 150}}, {{0, 95}, 0, -1, {2550, 3508}, { 50, 50 }}, {600, 600}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_rgb, 4, 5, kNEC3799, 0x07, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? * Tokyo: NS9832 + Button + SONY548 */ static DCapsDef Cap0x07B3_0x0005_2 = { {{ 0, 64}, 0, -1, {2550, 3508}, { 50, 50 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {600, 600}, 0, SENSORORDER_rgb, 8, 2, kSONY548, 0x05, _WAF_NONE, _NO_MIO }; /* Genius ColorPage-HR7 * Hualien: NS9832 + TPA + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0007_4 = { {{ 0, 111 - 4 }, 0, -1, {2550, 3508}, { 50, 50 }}, {{1040 + 5, 744 - 32}, 543, -1, { 473, 414 }, {150, 150}}, {{1040 - 20, 768 }, 543, -1, { 567, 414 }, {150, 150}}, {{ 0, 95 }, 0, -1, {2550, 3508}, { 50, 50 }}, {1200, 1200}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_rgb, 12, 5, kNEC3778, 0x07, _WAF_NONE, _NO_MIO }; /* Genius ColorPage-HR7LE and ColorPage-HR6X * Hualien: NS9832 + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0005_4 = { {{ 0, 111 - 4 }, 0, -1, {2550, 3508}, {50, 50}}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {1200, 1200}, 0, SENSORORDER_rgb, 12, 5, kNEC3778, 0x05, _WAF_NONE, _NO_MIO }; /* Plustek Model: ???, Genius ColorPage HR6A * KH: NS9831 + TPA + Button + NEC3799 */ static DCapsDef Cap0x07B3_0x000F_0 = { {{ 0, 130}, 12, -1, {2550, 3508}, { 50, 50 }}, {{1040, 744}, 543, -1, { 473, 414 }, {150, 150}}, {{1004, 744}, 543, -1, { 567, 414 }, {150, 150}}, {{ 0, 244}, 12, -1, {2550, 4200}, { 50, 50 }}, {600, 600}, DEVCAPSFLAG_Normal + DEVCAPSFLAG_Adf, SENSORORDER_rgb, 4, 5, kNEC3799, 0x0F, _WAF_NONE, _NO_MIO }; /* Plustek Model: UT12 * KH: NS9831 + TPA + Button + NEC3799 */ static DCapsDef Cap0x07B3_0x0013_0 = { {{ 0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 30, 744 + 32}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {600, 600}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_rgb, 4, 4, kNEC3799, 0x03, _WAF_NONE, _NO_MIO }; /* Plustek Model: U24 * KH: NS9831 + Button + NEC3799 // */ static DCapsDef Cap0x07B3_0x0011_0 = { {{ 0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 + 32}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {600, 600}, 0, SENSORORDER_rgb, 4, 4, kNEC3799, 0x01, _WAF_NONE, _NO_MIO }; /* Plustek Model: U12 * KH: NS9831 + TPA + Button + NEC3799 */ static DCapsDef Cap0x07B3_0x0010_0 = { {{ 0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 + 32}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {600, 600}, 0, SENSORORDER_rgb, 4, 0, kNEC3799, 0x00, _WAF_BSHIFT7_BUG, _NO_MIO }; /* Plustek Model: ??? * KH: NS9831 + TPA + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0013_4 = { {{ 0, 99 /*114*/}, 0, -1, {2550, 3508}, { 50, 50}}, {{ 1055, 744 - 84}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 - 20}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {1200, 1200}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_rgb, 12, 4, kNEC3778, 0x03, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? * KH: NS9831 + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0011_4 = { {{ 0, 99 /*114*/}, 0, -1, {2550, 3508}, { 50, 50}}, {{ 1055, 744 - 84}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 - 20}, 543, -1 ,{ 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {1200, 1200}, 0, SENSORORDER_rgb, 12, 4, kNEC3778, 0x01, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? * KH: NS9831 + TPA + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0010_4 = { {{ 0, 99 /*114*/}, 0, -1, {2550, 3508}, { 50, 50}}, {{ 1055, 744 - 84}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 - 20}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {1200, 1200}, 0, SENSORORDER_rgb, 12, 0, kNEC3778, 0x00, _WAF_NONE, _NO_MIO }; /* Plustek Model: UA18? * KH: NS9831 + TPA + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x000F_4 = { {{ 0, 107}, 0, -1, {2550, 3508}, { 50, 50}}, {{ 1040 + 5, 744 - 32}, 543, -1, { 473, 414}, {150, 150}}, {{1040 - 20, 768}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 244}, 0, -1, {2550, 4200}, { 50, 50}}, {1200, 1200}, DEVCAPSFLAG_Normal + DEVCAPSFLAG_Adf, SENSORORDER_rgb, 12, 5, kNEC3778, 0x0F, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? * KH: NS9831 + TPA + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0016_4 = { {{ 0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{ 954, 422}, 272, -1, { 624, 1940}, {150, 150}}, {{1120, 438}, 275, -1, { 304, 1940}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {1200, 1200}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_rgb, 12, 4, kNEC3778, 0x06, _WAF_NONE, _NO_MIO }; /* Plustek Model: UT24 * KH: NS9832 + TPA + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0017_4 = { {{ 0, 99 - 6}, 0, -1, {2550, 3508}, { 50, 50}}, {{1025 /*1055*/, 744 - 84}, 543, -1, { 473, 414}, {150, 150}}, {{1048 /*1024*/, 754/*724*/}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {1200, 1200}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_rgb, 12, 4, kNEC3778, 0x07, _WAF_NONE, _NO_MIO }; /* Plustek Model: U24 * KH: NS9832 + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0015_4 = { {{ 0, 99 - 6}, 0, -1, {2550, 3508}, { 50, 50}}, {{ 1055, 744 - 84}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 - 20}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {1200, 1200}, 0, SENSORORDER_rgb, 12, 4, kNEC3778, 0x05, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? * KH: NS9832 + TPA + Button + NEC3778 */ static DCapsDef Cap0x07B3_0x0014_4 = { {{ 0, 99 - 6}, 0, -1, {2550, 3508}, { 50, 50}}, {{ 1055, 744 - 84}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 - 20}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {1200, 1200}, 0, SENSORORDER_rgb, 12, 0, kNEC3778, 0x04, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? A3 model * KH: NS9831 + TPA + Button + SONY518 */ static DCapsDef Cap0x07B3_0x0014_1 = { {{ 0, 93}, 0, -1, {3600, 5100}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 + 32}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {400, 400}, 0, SENSORORDER_rgb, 8, 0, kSONY518, 0x04, _WAF_NONE, _NO_MIO }; /* Model: ??? * KH: NS9832 + NEC3799 + 600 DPI Motor (for Brother demo only) */ static DCapsDef Cap0x07B3_0x0012_0 = { {{ 0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 20, 744 + 32}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {600, 600}, 0, SENSORORDER_rgb, 4, 0, kNEC3799, 0x02, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? * KH: NS9831 + TPA + Button + SONY548 */ static DCapsDef Cap0x07B3_0x0017_2 = { {{ 0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, { 473, 414}, {150, 150}}, {{ 1004, 744}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {600, 600}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_bgr, 8, 4, kSONY548, 0x07, _WAF_NONE, _NO_MIO }; /* Plustek Model: ??? * KH: NS9831 + TPA + Button + NEC3799 */ static DCapsDef Cap0x07B3_0x0017_3 = { {{ 0, 93}, 0, -1, {2550, 3508}, { 50, 50}}, {{1040 + 15, 744 - 32}, 543, -1, { 473, 414}, {150, 150}}, {{1004 + 30, 744 + 32}, 543, -1, { 567, 414}, {150, 150}}, {{ 0, 95}, 0, -1, {2550, 3508}, { 50, 50}}, {600, 600}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_rgb, 8, 4, kNEC8861, 0x07, _WAF_NONE, _NO_MIO }; /* Model: HP Scanjet 2100c */ static DCapsDef Cap0x03F0_0x0505 = { {{ 0, 65}, 10, -1, {2550, 3508}, { 50, 50}}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {600, 600}, 0, SENSORORDER_rgb, 4, 0, kNECSLIM, 0x00, _WAF_NONE, _NO_MIO }; /* Model: HP Scanjet 2200c (thanks to Stefan Nilsen) * NS9832 + 2 Buttons + NEC3799 + 600 DPI Motor */ static DCapsDef Cap0x03F0_0x0605 = { /* DataOrigin (x, y), ShadingOriginY */ {{ 0, 209}, 40, -1, {2550, 3508}, { 50, 50}}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {600, 600}, 0, SENSORORDER_rgb, 4, 2, kNECSLIM, 0x00, _WAF_NONE, _NO_MIO }; /* Mustek BearPaw 1200 (thanks to Henning Meier-Geinitz) * NS9831 + 5 Buttons + NEC3798 */ static DCapsDef Cap0x0400_0x1000_0 = { {{ 0, 130}, 20, -1, {2550, 3508}, { 50, 50 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {600, 600}, 0, SENSORORDER_rgb, 8, 5, kNEC8861, 0x00, _WAF_MISC_IO_LAMPS | _WAF_LOFF_ON_START | _WAF_USE_ALT_DESC, _NO_MIO }; /* Mustek BearPaw 2400 * NS9832 + 5 Buttons + SONY548 */ static DCapsDef Cap0x0400_0x1001_0 = { {{ 0, 130/*209*/}, 35/*20*/, -1, {2550, 3508}, { 50, 50 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, { 600, 600 }, /*{ 1200, 1200 }, */ 0, SENSORORDER_rgb, 4,/*16*/ /* sensor distance */ 5, /* number of buttons */ kSONY548, /* CCD type */ 0, _WAF_USE_ALT_DESC, _NO_MIO }; /* Epson Perfection/Photo1250 (thanks to Gene Heskett and Reinhard Max) * Epson Perfection/Photo1260 (thanks to Till Kamppeter) * NS9832 + 4 Buttons + CCD???? */ static DCapsDef Cap0x04B8_0x010F = { /* Normal */ {{ 25, 85}, 10, -1, {2550, 3508}, { 100, 100 }}, /* Positive */ {{ 1100, 972}, 720, -1, { 473, 414}, { 150, 150 }}, /* Negative */ {{ 1116, 1049}, 720, -1, { 567, 414}, { 150, 150 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {1200, 1200}, 0, SENSORORDER_rgb, 8, /* sensor distance */ 4, /* number of buttons */ kEPSON, /* use default settings during calibration */ 0, /* not used here... */ _WAF_MISC_IO_LAMPS, /* use miscio 6 for lamp switching */ _MIO6 + _TPA(_MIO1) /* and miscio 1 for optional TPA */ }; /* Umax 3400/3450 */ static DCapsDef Cap0x1606_0x0060 = { /* Normal */ {{ 30, 105 }, 15, -1, {2550, 3508}, { 100, 100 }}, /* Positive */ {{ 700, 760 }, 650, -1, {1200, 1500}, { 150, 150 }}, /* Negative */ {{ 700, 760 }, 650, -1, {1200, 1500}, { 150, 150 }}, {{ 0, 0 }, 0, -1, {0, 0}, { 0, 0 }}, {600, 600}, DEVCAPSFLAG_LargeTPA, SENSORORDER_bgr, 8, /* sensor distance */ 4, /* number of buttons */ kNEC8861, /* use default settings during calibration */ 0, /* not used here... */ _WAF_MISC_IO_LAMPS, /* use miscio 3 for lamp switching */ _MIO3 + _TPA(_MIO6) /* and miscio 6 for optional TPA */ }; /* Umax 5400 */ static DCapsDef Cap0x1606_0x0160 = { {{ 30, 165}, 0, -1, {2550, 3508}, {100, 100}}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, -1, {0, 0}, { 0, 0 }}, {1200, 1200}, 0, SENSORORDER_bgr, 12, /* sensor distance */ 4, /* number of buttons */ kNEC3778, /* use default settings during calibration */ 0, /* not used here... */ _WAF_MISC_IO_LAMPS, /* use miscio 3 for lamp switching */ _MIO3 }; /* Canon N650U/N656U */ static DCapsDef Cap0x04A9_0x2206 = { {{ 0, 90}, 45, 10, {2550, 3508}, {75, 75}}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {600, 600}, 0, SENSORORDER_rgb, 8, /* sensor distance */ 1, /* number of buttons */ kCIS650, /* use default settings during calibration */ 0, /* not used here... */ _WAF_MISC_IO_LAMPS, _NO_MIO }; /* Canon N1220U */ static DCapsDef Cap0x04A9_0x2207 = { {{ 0, 85}, 45, 10, {2550, 3508}, {75, 75}}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {1200, 1200}, 0, SENSORORDER_rgb, 16, /* sensor distance */ 1, /* number of buttons */ kCIS1220, /* use default settings during calibration */ 0, /* not used here... */ _WAF_MISC_IO_LAMPS, _NO_MIO }; /* Canon D660U */ static DCapsDef Cap0x04A9_0x2208 = { {{ 45, 125}, 15, -1, {2550, 3508}, { 50, 50}}, {{1060, 744}, 510, -1, { 473, 414}, {150, 150}}, {{1082, 842}, 610, -1, { 567, 414}, {150, 150}}, {{ 0, 0}, 0, 0, { 0, 0}, { 0, 0}}, {600, 600}, DEVCAPSFLAG_Positive + DEVCAPSFLAG_Negative, SENSORORDER_rgb, 4, 1, kNEC8861, /* use default settings during calibration */ 0, (_WAF_MISC_IO_LAMPS | _WAF_BIN_FROM_COLOR | _WAF_GRAY_FROM_COLOR), _MIO5 + _TPA(_MIO6) }; /* Canon N670U/N676U/LiDE20 */ static DCapsDef Cap0x04A9_0x220D = { {{ 0, 110}, 45, -1, {2550, 3508}, {75, 75}}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {600, 600}, 0, SENSORORDER_rgb, 8, /* sensor distance */ 3, /* number of buttons */ kCIS670, 0, /* not used here... */ _WAF_MISC_IO_LAMPS, _NO_MIO }; /* Canon N1240U/LiDE30 */ static DCapsDef Cap0x04A9_0x220E = { {{ 0, 100}, 50, 10, {2550, 3508}, {75, 75}}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {1200, 1200}, 0, SENSORORDER_rgb, 16, /* sensor distance */ 3, /* number of buttons */ kCIS1240, 0, /* not used here... */ _WAF_MISC_IO_LAMPS, _NO_MIO }; /* Canon LiDE25 */ static DCapsDef Cap0x04A9_0x2220 = { {{ 0, 100}, 50, 10, {2550, 3508}, {75, 75}}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {1200, 1200}, 0, SENSORORDER_rgb, 16, /* sensor distance */ 3, /* number of buttons */ kCIS1240, 0, /* not used here... */ _WAF_MISC_IO_LAMPS, _NO_MIO }; /* Syscan TravelScan 662 A6 sheet-fed scanner */ static DCapsDef Cap0x0A82_0x6620 = { {{ 0, 0}, 100, -1, {1226, 3508}, {75, 75}}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {600, 600}, DEVCAPSFLAG_SheetFed, SENSORORDER_rgb, 8, 1, kNEC8861, /* use default settings during calibration */ 0, /* not used here... */ (_WAF_MISC_IO_LAMPS | _WAF_MISC_IO_BUTTONS | _WAF_BIN_FROM_COLOR | _WAF_GRAY_FROM_COLOR), _MIO5 + _PORT1 + _PS_INP_MIO2 }; /* Syscan TravelScan 464 A4 sheet-fed scanner */ static DCapsDef Cap0x0A82_0x4600 = { {{ 0, 0}, 150, -1, {2550, 3508}, {75, 75}}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {600, 600}, DEVCAPSFLAG_SheetFed, SENSORORDER_rgb, 8, 1, kNEC8861, /* use default settings during calibration */ 0, /* not used here... */ (_WAF_MISC_IO_LAMPS | _WAF_MISC_IO_BUTTONS | _WAF_BIN_FROM_COLOR | _WAF_GRAY_FROM_COLOR), _MIO5 + _PORT1 + _PS_INP_MIO2 }; /* IRIScan/Q-Scan USB001 A4 sheet-fed scanner */ static DCapsDef Cap0x0A53_0x1000 = { {{ 0, 0}, 150, -1, {2550, 3508}, {150, 150}}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {300, 300}, DEVCAPSFLAG_SheetFed, SENSORORDER_gbr, 2, /* sensor distance */ 0, /* number of buttons */ kNEC8861, /* use default settings during calibration */ 200, /* threshold for resetting sensor-order */ (_WAF_MISC_IO_LAMPS | _WAF_RESET_SO_TO_RGB | _WAF_ONLY_8BIT), _PS_INP1 }; /* PandP USB201 Q-Scan A6 Scanner */ static DCapsDef Cap0x0A53_0x2000 = { {{ 0, 0}, 0, -1, {1226, 3508}, { 50, 50 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {{ 0, 0}, 0, 0, {0, 0}, { 0, 0 }}, {600, 600}, DEVCAPSFLAG_SheetFed, SENSORORDER_rgb, 4, 0, kNEC8861, 0, _WAF_NONE, _PS_INP1 }; /******************* additional Hardware descriptions ************************/ /** U24, UT12 and UT16 */ static HWDef Hw0x07B3_0x0017_0 = { 1.5, /* dMaxMotorSpeed */ 1.2, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 9, /* dIntegrationTimeLowLamp */ 9, /* dIntegrationTimeHighLamp */ 300, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 4, /* dMinIntegrationTimeLowres (ms) */ 5, /* dMinIntegrationTimeHighres (ms) */ 3000, /* wGreenPWMDutyCycleLow */ 4095, /* wGreenPWMDutyCycleHigh */ 0x02, /* bSensorConfiguration (0x0b) */ 0x04, /* bReg_0x0c */ 0x37, /* bReg_0x0d */ 0x13, /* bReg_0x0e */ /* bReg_0x0f_Mono [10] (0x0f to 0x18) */ {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, /* bReg_0x0f_Color [10] (0x0f to 0x18) */ {5, 23, 1, 3, 0, 0, 0, 12, 10, 22}, _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, /* StepperPhaseCorrection (0x1a & 0x1b) */ 14, /* 15, bOpticBlackStart (0x1c) */ 62, /* 60, bOpticBlackEnd (0x1d) */ 110, /* 65, wActivePixelsStart (0x1e & 0x1f) */ 5400, /* 5384 ,wLineEnd (0x20 & 0x21) */ 0, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 0, /* green lamp on (reg 0x30 + 0x31) */ 0, /* green lamp off (reg 0x32 + 0x33) */ 0, /* blue lamp on (reg 0x34 + 0x35) */ 16383, /* blue lamp off (reg 0x36 + 0x37) */ /* Misc */ 3, /* bReg_0x45 */ 0, /* wStepsAfterPaperSensor2 (0x4c & 0x4d) */ 0x1e, /* bstepsToReverse reg 0x50) */ 0xa8, /* 0xfc -bReg_0x51 */ 0, /* bReg_0x54 */ 0xff, /* 0xa3 - bReg_0x55 */ 64, /* bReg_0x56 */ 20, /* bReg_0x57 */ 0x0d, /* bReg_0x58 */ 0x22, /* bReg_0x59 */ 0x82, /* bReg_0x5a */ 0x88, /* bReg_0x5b */ 0, /* bReg_0x5c */ 0, /* bReg_0x5d */ 0, /* bReg_0x5e */ _LM9832, /* chip type */ MODEL_KaoHsiung,/* motorModel */ 1.0 }; /** Genius ColorPage-HR6 V2 and ColorPage-HR6X */ static HWDef Hw0x07B3_0x0007_0 = { 1.5, 1.2, 0.0, 9, 9, 300, 512, 4, 5, 3000, 4095, 0x02, 0x14, 0x27, 0x13, {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, {5, 23, 1, 3, 0, 0, 0, 6, 10, 22}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 14, 62, 110, 5384, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 64, 20, 0x0d, 0x88, 0x28, 0x3b, 0, 0, 0, _LM9832, MODEL_HuaLien, 1.0 }; /** unknown */ static HWDef Hw0x07B3_0x0007_2 = { 1.4, 1.2, 0.0, 9, 9, 600, 512, 4, 5, 3000, 4095, 0x02, 0x3f, 0x2f, 0x36, {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, {7, 20, 1, 4, 7, 10, 0, 6, 12, 0}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 16, 64, 152, 5416, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xfc, 0, 0xff, 64, 20, 0x0d, 0x88, 0x28, 0x3b, 0, 0, 0, _LM9832, MODEL_Tokyo600, 1.0 }; /** Genius ColorPage-HR7 and ColorPage-HR7LE */ static HWDef Hw0x07B3_0x0007_4 = { 1.1, 0.9, 0.0, 12, 12, 600, 2048, 8, 8, 4095, 4095, 0x06, 0x30, 0x2f, 0x2a, {2, 7, 5, 6, 6, 7, 0, 0, 0, 5}, {20, 4, 13, 16, 19, 22, 0, 6, 23, 11}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 13, 62, 304, 10684, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 24, 40, 0x0d, 0x88, 0x28, 0x3b, 0, 0, 0, _LM9832, MODEL_HuaLien, 1.0 }; /** Genius ColorPage-HR6A */ static HWDef Hw0x07B3_0x000F_0 = { 1.5, 1.0, 0.0, 9, 9, 300, 512, 4, 5, 3000, 4095, 0x02, 0x14, 0x27, 0x13, {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, {5, 23, 1, 3, 0, 0, 0, 6, 10, 22}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 14, 62, 110, 5384, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 64, 20, 0x05, 0x88, 0x08, 0x3b, 0, 0, 0, _LM9832, MODEL_HuaLien, 1.0 }; /** U12/UT12 and U24 */ static HWDef Hw0x07B3_0x0013_0 = { 1.5, 1.2, 0.0, 9, 9, 300, 512, 4, 5, 3000, 4095, 0x02, 0x04, 0x37, 0x13, {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, {5, 23, 1, 3, 0, 0, 0, 12, 10, 22}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 14, 62, 110, 5400, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 64, 20, 0x0d, 0x22, 0x82, 0x88, 0, 0, 0, _LM9831, MODEL_KaoHsiung, 1.0 }; /** unknown */ static HWDef Hw0x07B3_0x0013_4 = { 1.0, 0.9, 0.0, 12, 12, 600, 2048, 8, 8, 4095, 4095, 0x06, 0x20, 0x2f, 0x2a, {2, 7, 5, 6, 6, 7, 0, 0, 0, 5}, {20, 4, 13, 16, 19, 22, 0, 0, 23, 11}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 13, 62, 320, 10684, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 10, 48, 0x0d, 0x22, 0x82, 0x88, 0, 0, 0, _LM9831, MODEL_KaoHsiung, 1.0 }; /** unknown */ static HWDef Hw0x07B3_0x000F_4 = { 1.1, 0.9, 0.0, 12, 12, 600, 2048, 8, 8, 4095, 4095, 0x06, 0x30, 0x2f, 0x2a, {2, 7, 5, 6, 6, 7, 0, 0, 0, 5}, {20, 4, 13, 16, 19, 22, 0, 6, 23, 11}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 13, 62, 304, 10684, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 24, 40, 0x05, 0x88, 0x08, 0x3b, 0, 0, 0, _LM9832, MODEL_HuaLien, 1.0 }; /** unknown */ static HWDef Hw0x07B3_0x0016_4 = { 1.0, 0.9, 0.0, 12, 12, 600, 2048, 8, 8, 4095, 4095, 0x06, 0x20, 0x2f, 0x2a, {2, 7, 5, 6, 6, 7, 0, 0, 0, 5}, {20, 4, 13, 16, 19, 22, 0, 0, 23, 11}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 13, 62, 320, 10684, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 10, 48, 0x0d, 0x22, 0x82, 0x88, 0, 0, 0, _LM9832, MODEL_KaoHsiung, 1.0 }; /** Plustek OpticPro UT24 and others... */ static HWDef Hw0x07B3_0x0017_4 = { 1.0, 0.9, 0.0, 12, 12, 600, 2048, 8, 8, 4095, 4095, 0x06, 0x20, 0x2f, 0x2a, {2, 7, 5, 6, 6, 7, 0, 0, 0, 5}, {20, 4, 13, 16, 19, 22, 0, 0, 23, 11}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 13, 62, 320, 10684, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 10, 48, 0x0d, 0x22, 0x82, 0x88, 0, 0, 0, _LM9832, MODEL_KaoHsiung, 1.0 }; /** unknown */ static HWDef Hw0x07B3_0x0017_1 = { 1.5, 1.5, 0.0, 9, 9, 200, 2048, 4, 5, 3000, 4095, 0x02, 0x08, 0x2f, 0x36, {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, {5, 23, 1, 4, 7, 10, 0, 0, 10, 12}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 15, 60, 110, 5415, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 64, 20, 0x0d, 0x22, 0x82, 0x88, 0, 0, 0, _LM9832, MODEL_KaoHsiung, 1.0 }; /** unknown */ static HWDef Hw0x07B3_0x0012_0 = { 1.5, 1.4, 0.0, 9, 9, 600, 2048, 4, 5, 3000, 4095, 0x02, 0x04, 0x37, 0x13, {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, {5, 23, 1, 3, 0, 0, 0, 12, 10, 22}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 14, 62, 110, 5400, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 64, 20, 0x0d, 0x22, 0x82, 0x88, 0, 0, 0, _LM9832, MODEL_KaoHsiung, 1.0 }; /** unknown */ static HWDef Hw0x07B3_0x0017_2 = { 1.5, 1.2, 0.0, 9, 9, 300, 512, 4, 5, 3000, 4095, 0x02, 0, 0x2f, 0x36, {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, {5, 0, 1, 4, 7, 10, 0, 0, 12, 0}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 16, 64, 110, 5416, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 64, 20, 0x0d, 0x22, 0x82, 0x88, 0, 0, 0, _LM9832, MODEL_KaoHsiung, 1.0 }; /** unknown */ static HWDef Hw0x07B3_0x0017_3 = { 1.5, 1.2, 0.0, 9, 9, 300, 512, 4, 5, 3000, 4095, 0x02, 0x04, 0x37, 0x13, {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, {5, 23, 1, 4, 7, 10, 0, 0, 11, 23}, _GREEN_CH, 0, 1, /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, 14, 62, 110, 5400, 0, 16383, 0, 0, 0, 16383, 3, 0, 0x1e, 0xa8, 0, 0xff, 64, 20, 0x0d, 0x22, 0x82, 0x88, 0, 0, 0, _LM9832, MODEL_KaoHsiung, 1.0 }; /** HP Scanjet 2100C */ static HWDef Hw0x03F0_0x0505 = { 1.05, /* dMaxMotorSpeed */ 1.05, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 6, /* dIntegrationTimeLowLamp */ 8, /* dIntegrationTimeHighLamp */ 600, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 6, /* dMinIntegrationTimeLowres (ms) */ 6, /* dMinIntegrationTimeHighres (ms) */ 0, /* wGreenPWMDutyCycleLow */ 0, /* wGreenPWMDutyCycleHigh */ 0x02, /* bSensorConfiguration (0x0b) */ 0x00, /* bReg_0x0c */ 0x2F, /* bReg_0x0d */ 0x13, /* bReg_0x0e */ /* bReg_0x0f_Mono[10] (0x0f to 0x18) */ { 0x02, 0x07, 0x01, 0x02, 0x02, 0x03, 0x00, 0x00, 0x04, 0x07 }, /* bReg_0x0f_Color[10] (0x0f to 0x18) */ { 0x08, 0x17, 0x00, 0x03, 0x08, 0x0b, 0x00, 0x00, 0x0a, 0x14 }, _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, /* StepperPhaseCorrection (0x1a & 0x1b) */ 15, /* bOpticBlackStart (0x1c) */ 50, /* bOpticBlackEnd (0x1d) */ 140, /* wActivePixelsStart (0x1e & 0x1f) */ 5414, /* wLineEnd=(0x20 & 0x21) */ 1, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 16383, /* green lamp on (reg 0x30 + 0x31) */ 1, /* green lamp off (reg 0x32 + 0x33) */ 16383, /* blue lamp on (reg 0x34 + 0x35) */ 1, /* blue lamp off (reg 0x36 + 0x37) */ /* Misc */ 0x13, /* bReg_0x45 */ 0, /* wStepsAfterPaperSensor2 (0x4c & 0x4d) */ 0x1e, /* steps to reverse on buffer full reg 0x50 */ 0xfc, /* 0xa8 -bReg_0x51 */ 0, /* bReg_0x54 */ 0x18, /* bReg_0x55 */ 8, /* bReg_0x56 */ 60, /* bReg_0x57 */ 0x0d, /* bReg_0x58 */ 0xaa, /* bReg_0x59 */ 0xba, /* bReg_0x5a */ 0xbb, /* bReg_0x5b */ 0, /* bReg_0x5c */ 0, /* bReg_0x5d */ 0, /* bReg_0x5e */ _LM9831, MODEL_HP, 1.0 }; /** HP Scanjet 2200C */ static HWDef Hw0x03F0_0x0605 = { 1.05, /* dMaxMotorSpeed */ 1.05, /* dMaxMoveSpeed */ 2.2, /* dHighSpeed */ 6, /* dIntegrationTimeLowLamp */ 8, /* dIntegrationTimeHighLamp */ 600, /* ok wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 6, /* dMinIntegrationTimeLowres (ms) */ 6, /* dMinIntegrationTimeHighres (ms) */ 0, /* wGreenPWMDutyCycleLow */ 0, /* wGreenPWMDutyCycleHigh */ 0x02, /* bSensorConfiguration (0x0b) */ 0x04, /* bReg_0x0c */ 0x2F, /* bReg_0x0d */ 0x1F, /* bReg_0x0e */ /* bReg_0x0f_Mono[10] (0x0f to 0x18) */ { 0x02, 0x07, 0x01, 0x02, 0x02, 0x03, 0x00, 0x00, 0x04, 0x07 }, /* bReg_0x0f_Color[10] (0x0f to 0x18) */ { 0x08, 0x17, 0x00, 0x03, 0x08, 0x0b, 0x00, 0x00, 0x0a, 0x14 }, _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices)*/ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, /* StepperPhaseCorrection (0x1a & 0x1b) */ 14, /* bOpticBlackStart (0x1c) */ 63, /* bOpticBlackEnd (0x1d) */ 140, /* wActivePixelsStart (0x1e & 0x1f) */ 5367, /* wLineEnd=(0x20 & 0x21) */ 1, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 16383, /* green lamp on (reg 0x30 + 0x31) */ 1, /* green lamp off (reg 0x32 + 0x33) */ 16383, /* blue lamp on (reg 0x34 + 0x35) */ 1, /* blue lamp off (reg 0x36 + 0x37) */ /* Misc */ 0x13, /* bReg_0x45 */ 0, /* wStepsAfterPaperSensor2 (0x4c & 0x4d) */ 0x1e, /* steps to reverse on buffer full (0x50) */ 0xfc, /* 0xa8 -bReg_0x51 */ 0, /* bReg_0x54 */ 0x18, /* bReg_0x55 */ 8, /* bReg_0x56 */ 60, /* bReg_0x57 */ 0x0d, /* bReg_0x58 */ 0xcc, /* bReg_0x59 */ 0xbc, /* bReg_0x5a */ 0xbb, /* bReg_0x5b */ 0, /* bReg_0x5c */ 0, /* bReg_0x5d */ 0, /* bReg_0x5e */ _LM9832, MODEL_HP, 1.0 }; /** Mustek BearPaw 1200 */ static HWDef Hw0x0400_0x1000_0 = { 1.75, /* ok dMaxMotorSpeed */ 1.25, /* ok dMaxMoveSpeed */ 0.0, /* ok dHighSpeed */ 12, /* ok dIntegrationTimeLowLamp */ 12, /* ok dIntegrationTimeHighLamp */ 600, /* ok wMotorDpi (Full step DPI) */ 512, /* ok wRAMSize (KB) */ 9, /* ok dMinIntegrationTimeLowres (ms) */ 9, /* ok dMinIntegrationTimeHighres (ms) */ 1169, /* ok wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 1169, /* ok wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x02, /* ok bSensorConfiguration (0x0b) */ 0x7c, /* ok sensor control settings (reg 0x0c) */ 0x3f, /* ok sensor control settings (reg 0x0d) */ 0x15, /* ok sensor control settings (reg 0x0e) */ /* ok mono (reg 0x0f to 0x18) */ { 0x04, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x03, 0x06}, /* ok color (reg 0x0f to 0x18) */ { 0x04, 0x16, 0x01, 0x02, 0x05, 0x06, 0x00, 0x00, 0x0a, 0x16}, _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices)*/ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 257, /* ok StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x0e, /* ok bOpticBlackStart (reg 0x1c) */ 0x1d, /* ok bOpticBlackEnd (reg 0x1d) */ 140, /* ok wActivePixelsStart (reg 0x1e + 0x1f) */ 5369, /* ok wLineEnd (reg 0x20 + 0x21) */ 0, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 0, /* green lamp on (reg 0x30 + 0x31) */ 0, /* green lamp off (reg 0x32 + 0x33) */ 0, /* blue lamp on (reg 0x34 + 0x35) */ 16383, /* blue lamp off (reg 0x36 + 0x37) */ 0x13, /* ok stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x1e, /* steps to reverse on buffer full (reg 0x50) */ 0xfc, /* ok acceleration profile (reg 0x51) */ 0, /* ok lines to process (reg 0x54) */ 0x13, /* ok kickstart (reg 0x55) */ 0x03, /* ok pwm freq (reg 0x56) */ 0x20, /* ok pwm duty cycle (reg 0x57) */ 0x0d, /* ok Paper sense (reg 0x58) */ 0x44, /* ok misc io12 (reg 0x59) */ 0x44, /* ok misc io34 (reg 0x5a) */ 0x16, /* ok misc io56 (reg 0x5b) */ 0, /* ok test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* ok test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* ok test mode (reg 0x5e) */ _LM9831, MODEL_MUSTEK600, 1.5 }; /** Mustek BearPaw 1200 (LM9832) */ static HWDef Hw0x0400_0x1001_1 = { 1.25, /* ok dMaxMotorSpeed */ 1.25, /* ok dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 12, /* ok dIntegrationTimeLowLamp */ 12, /* ok dIntegrationTimeHighLamp */ 600, /* ok wMotorDpi (Full step DPI) */ 512, /* ok wRAMSize (KB) */ 9, /* ok dMinIntegrationTimeLowres (ms) */ 9, /* ok dMinIntegrationTimeHighres (ms) */ 1169, /* ok wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 1169, /* ok wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x02, /* ok bSensorConfiguration (0x0b) */ 0x7c, /* ok sensor control settings (reg 0x0c) */ 0x3f, /* ok sensor control settings (reg 0x0d) */ 0x15, /* ok sensor control settings (reg 0x0e) */ /* ok mono (reg 0x0f to 0x18) */ { 0x04, 0x07, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x03, 0x06}, /* ok color (reg 0x0f to 0x18) */ { 0x04, 0x16, 0x01, 0x02, 0x05, 0x06, 0x00, 0x00, 0x0a, 0x16}, _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices)*/ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 257, /* ok StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x0e, /* ok bOpticBlackStart (reg 0x1c) */ 0x1d, /* ok bOpticBlackEnd (reg 0x1d) */ 140, /* ok wActivePixelsStart (reg 0x1e + 0x1f) */ 5369, /* ok wLineEnd (reg 0x20 + 0x21) */ 0, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 0, /* green lamp on (reg 0x30 + 0x31) */ 0, /* green lamp off (reg 0x32 + 0x33) */ 0, /* blue lamp on (reg 0x34 + 0x35) */ 16383, /* blue lamp off (reg 0x36 + 0x37) */ 0x13, /* ok stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x1e, /* steps to reverse on buffer full (reg 0x50) */ 0xfc, /* ok acceleration profile (reg 0x51) */ 0, /* ok lines to process (reg 0x54) */ 0x13, /* ok kickstart (reg 0x55) */ 0x03, /* ok pwm freq (reg 0x56) */ 0x20, /* ok pwm duty cycle (reg 0x57) */ 0x0d, /* ok Paper sense (reg 0x58) */ 0x44, /* ok misc io12 (reg 0x59) */ 0x44, /* ok misc io34 (reg 0x5a) */ 0x16, /* ok misc io56 (reg 0x5b) */ 0, /* ok test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* ok test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* ok test mode (reg 0x5e) */ _LM9832, MODEL_MUSTEK600, 1.5 }; /** BearPaw 2400 */ static HWDef Hw0x0400_0x1001_0 = { 1.0/*1.8*/, /* ok dMaxMotorSpeed */ 0.9/*1.8*/, /* ok dMaxMoveSpeed */ 0.0, /* ok dHighSpeed */ 12, /* ok dIntegrationTimeLowLamp */ 12, /* ok dIntegrationTimeHighLamp */ 1200 /* 600*/ , /* ok wMotorDpi (Full step DPI) */ 2048, /* ok wRAMSize (KB) */ 9, /* ok dMinIntegrationTimeLowres (ms) */ 9, /* ok dMinIntegrationTimeHighres (ms) */ 1169, /* ok wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 1169, /* ok wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x02 /*0x06*/, /* ok bSensorConfiguration (0x0b) */ 0x3c, /* ok sensor control settings (reg 0x0c) */ 0x3f, /* ok sensor control settings (reg 0x0d) */ 0x11, /* ok sensor control settings (reg 0x0e) */ /* ok mono (reg 0x0f to 0x18) */ {2, 7, 0, 1, 0, 0, 0, 0, 4, 0}, /* {5, 14, 12, 15, 18, 21, 0, 0, 0, 9 },*/ {1, 4, 4, 5, 6, 7, 0, 0, 0, 3 }, _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices)*/ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 257, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 13, /* bOpticBlackStart (reg 0x1c) */ 60, /* bOpticBlackEnd (reg 0x1d) */ 10, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 5416 /* 11000*/, /* wLineEnd (reg 0x20 + 0x21) */ 1, /* ok red lamp on (reg 0x2c + 0x2d) */ 16383, /* ok red lamp off (reg 0x2e + 0x2f) */ 1, /* ok green lamp on (reg 0x30 + 0x31) */ 16383, /* ok green lamp off (reg 0x32 + 0x33) */ 1, /* ok blue lamp on (reg 0x34 + 0x35) */ 16383, /* ok blue lamp off (reg 0x36 + 0x37) */ 0x03, /* ok stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x1e, /* steps to reverse on buffer full (reg 0x50) */ 0xfc, /* ok acceleration profile (reg 0x51) */ 0x03, /* ok lines to process (reg 0x54) */ 0x13, /* Kickstart 0x55 */ 2, /* PWM frequency 0x56 */ 32, /* PWM duty cycle 0x57 */ 0x15, /* paper sense 0x58 */ 0x44, /* misc I/O 0x59 */ 0x44, /* misc I/O 0x5a, */ 0x46, /* misc I/O 0x5b */ 0, 0, 0,/* test registers, set to 0 (0x5c, 0x5d, 0x5e) */ _LM9832, MODEL_MUSTEK1200, 1.0 }; /** EPSON Perfection/Photo 1250 */ static HWDef Hw0x04B8_0x010F = { 0.8, /* dMaxMotorSpeed */ 0.8, /* dMaxMoveSpeed */ 4.1, /* dHighSpeed */ 12, /* dIntegrationTimeLowLamp */ 12, /* dIntegrationTimeHighLamp */ 600, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 4, /* dMinIntegrationTimeLowres (ms) */ 5, /* dMinIntegrationTimeHighres (ms) */ 1, /* ok wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 1, /* ok wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x02, /* ok bSensorConfiguration (0x0b) */ 0x04, /* ok sensor control settings (reg 0x0c) */ 0x7d, /* ok sensor control settings (reg 0x0d) */ 0x37, /* ok sensor control settings (reg 0x0e) */ {0x02, 0x07, 0x00, 0x01, 0x04, 0x07, 0x00, 0x00, 0x03, 0x07}, /* ok mono (reg 0x0f to 0x18) */ {0x06, 0x16, 0x00, 0x05, 0x0c, 0x17, 0x00, 0x00, 0x0a, 0x17}, /* ok color (reg 0x0f to 0x18) */ _GREEN_CH, /* ok bReg_0x26 color mode - bits 4 and 5 */ 0x40, /* ok bReg 0x27 color mode */ 3, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices)*/ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, /* ok StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x00, /* ok bOpticBlackStart (reg 0x1c) */ 0x42, /* ok bOpticBlackEnd (reg 0x1d) */ 69, /* ok wActivePixelsStart (reg 0x1e + 0x1f) */ 10758, /* ok wLineEnd (reg 0x20 + 0x21) */ 16383, /* ok red lamp on (reg 0x2c + 0x2d) */ 0, /* ok red lamp off (reg 0x2e + 0x2f) */ 16383, /* ok green lamp on (reg 0x30 + 0x31) */ 0, /* ok green lamp off (reg 0x32 + 0x33) */ 16383, /* ok blue lamp on (reg 0x34 + 0x35) */ 0, /* ok blue lamp off (reg 0x36 + 0x37) */ 3, /* ok stepper motor control (reg 0x45) */ 0, /* ok wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x1e, /* steps to reverse on buffer full (reg 0x50) */ 0x0c, /* ok acceleration profile (reg 0x51) */ 0, /* ok lines to process (reg 0x54) */ 0x0f, /* ok kickstart (reg 0x55) */ 0x02, /* ok pwm freq (reg 0x56) */ 1, /* ok pwm duty cycle (reg 0x57) */ 0x0d, /* ok Paper sense (reg 0x58) */ 0x41, /* ok misc io12 (reg 0x59) */ 0x44, /* ok misc io34 (reg 0x5a) */ 0x14, /* ok misc io56 (reg 0x5b) */ 0, /* ok test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* ok test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* ok test mode (reg 0x5e) */ _LM9832, MODEL_EPSON, 1.0 }; /** EPSON Perfection/Photo 1260 */ static HWDef Hw0x04B8_0x011D = { 0.9, /* dMaxMotorSpeed */ 0.8, /* dMaxMoveSpeed */ 3.0, /* dHighSpeed */ 12, /* dIntegrationTimeLowLamp */ 12, /* dIntegrationTimeHighLamp */ 600, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 4, /* dMinIntegrationTimeLowres (ms) */ 5, /* dMinIntegrationTimeHighres (ms) */ 1, /* ok wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 1, /* ok wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x02, /* ok bSensorConfiguration (0x0b) */ 0x04, /* ok sensor control settings (reg 0x0c) */ 0x7d, /* ok sensor control settings (reg 0x0d) */ 0x37, /* ok sensor control settings (reg 0x0e) */ {0x02, 0x07, 0x00, 0x01, 0x04, 0x07, 0x00, 0x00, 0x03, 0x07}, /* ok mono (reg 0x0f to 0x18) */ {0x06, 0x0b, 0x00, 0x05, 0x0c, 0x17, 0x00, 0x00, 0x0a, 0x17}, /* ok color (reg 0x0f to 0x18) */ _GREEN_CH, /* ok bReg_0x26 color mode - bits 4 and 5 */ 0x42, /* ok bReg 0x27 color mode */ 3, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices)*/ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, /* ok StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x00, /* ok bOpticBlackStart (reg 0x1c) */ 0x42, /* ok bOpticBlackEnd (reg 0x1d) */ 69, /* ok wActivePixelsStart (reg 0x1e + 0x1f) */ 10766, /* ok wLineEnd (reg 0x20 + 0x21) */ 16383, /* ok red lamp on (reg 0x2c + 0x2d) */ 0, /* ok red lamp off (reg 0x2e + 0x2f) */ 16383, /* ok green lamp on (reg 0x30 + 0x31) */ 0, /* ok green lamp off (reg 0x32 + 0x33) */ 16383, /* ok blue lamp on (reg 0x34 + 0x35) */ 0, /* ok blue lamp off (reg 0x36 + 0x37) */ 3, /* ok stepper motor control (reg 0x45) */ 0, /* ok wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x1e, /* steps to reverse on buffer full (reg 0x50) */ 0x0c, /* ok acceleration profile (reg 0x51) */ 0, /* ok lines to process (reg 0x54) */ 0x0f, /* ok kickstart (reg 0x55) */ 0x02, /* ok pwm freq (reg 0x56) */ 1, /* ok pwm duty cycle (reg 0x57) */ 0x0d, /* ok Paper sense (reg 0x58) */ 0x41, /* ok misc io12 (reg 0x59) */ 0x44, /* ok misc io34 (reg 0x5a) */ 0x14, /* ok misc io56 (reg 0x5b) */ 0, /* ok test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* ok test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* ok test mode (reg 0x5e) */ _LM9832, MODEL_EPSON, 1.5 }; /** Umax 3400/3450 */ static HWDef Hw0x1606_0x0060 = { 1.5, /* dMaxMotorSpeed */ 0.8, /* dMaxMoveSpeed */ 2.75, /* dHighSpeed */ 9, /* dIntegrationTimeLowLamp */ 9, /* dIntegrationTimeHighLamp */ 600, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 8, /* dMinIntegrationTimeLowres (ms) */ 8, /* dMinIntegrationTimeHighres (ms) */ 4095, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 4095, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x06, /* bSensorConfiguration (0x0b) */ 0x73, /* sensor control settings (reg 0x0c) */ 0x77, /* sensor control settings (reg 0x0d) */ 0x15, /* sensor control settings (reg 0x0e) */ {0x00, 0x03, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03}, /* mono (reg 0x0f to 0x18) */ {0x01, 0x0c, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0c}, /* color (reg 0x0f to 0x18) */ _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0x40, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x2f, /* bOpticBlackStart (reg 0x1c) */ 0x3e, /* bOpticBlackEnd (reg 0x1d) */ 110, /* ? wActivePixelsStart (reg 0x1e + 0x1f) */ 5469, /* wLineEnd (reg 0x20 + 0x21) */ 1, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 0, /* green lamp on (reg 0x30 + 0x31) */ 0, /* green lamp off (reg 0x32 + 0x33) */ 32, /* blue lamp on (reg 0x34 + 0x35) */ 48, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 11, /* steps to reverse on buffer full (reg 0x50)*/ 0xfc, /* acceleration profile (reg 0x51) */ 3, /* lines to process (reg 0x54) */ 0xcb, /* kickstart (reg 0x55) */ 0x05, /* pwm freq (reg 0x56) */ 5, /* pwm duty cycle (reg 0x57) */ 0x0d, /* Paper sense (reg 0x58) */ 0x44, /* misc io12 (reg 0x59) */ 0x45, /* misc io34 (reg 0x5a) */ 0x74, /* misc io56 (reg 0x5b) */ 0, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9832, MODEL_UMAX, 1.0 }; /** Umax 5400 */ static HWDef Hw0x1606_0x0160 = { 1.1, /* dMaxMotorSpeed */ 0.9, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 9, /* dIntegrationTimeLowLamp */ 9, /* dIntegrationTimeHighLamp */ 600, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 8, /* dMinIntegrationTimeLowres (ms) */ 8, /* dMinIntegrationTimeHighres (ms) */ 4095, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 4095, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x06, /* bSensorConfiguration (0x0b) */ 0x73, /* sensor control settings (reg 0x0c) */ 0x77, /* sensor control settings (reg 0x0d) */ 0x25, /* sensor control settings (reg 0x0e) */ /* mono (reg 0x0f to 0x18) */ {0x00, 0x03, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03}, /* color (reg 0x0f to 0x18) */ {0x01, 0x0c, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x16, 0x0c}, _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0x40, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 20, /* bOpticBlackStart (reg 0x1c) */ 45, /* bOpticBlackEnd (reg 0x1d) */ 110, /* ? wActivePixelsStart (reg 0x1e + 0x1f) */ 10669, /* wLineEnd (reg 0x20 + 0x21) */ 1, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 0, /* green lamp on (reg 0x30 + 0x31) */ 0, /* green lamp off (reg 0x32 + 0x33) */ 32, /* blue lamp on (reg 0x34 + 0x35) */ 48, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 11, /* steps to reverse on buffer full (reg 0x50)*/ 0xfc, /* acceleration profile (reg 0x51) */ 3, /* lines to process (reg 0x54) */ 0xcb, /* kickstart (reg 0x55) */ 0x05, /* pwm freq (reg 0x56) */ 5, /* pwm duty cycle (reg 0x57) */ 0x0d, /* Paper sense (reg 0x58) */ 0x44, /* misc io12 (reg 0x59) */ 0x45, /* misc io34 (reg 0x5a) */ 0x7c, /* misc io56 (reg 0x5b) */ 0, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9832, MODEL_UMAX1200, 1.0 }; /** Canon N650U/N656U */ static HWDef Hw0x04A9_0x2206 = { 0.76, /* dMaxMotorSpeed */ 0.243, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* dIntegrationTimeLowLamp */ 100, /* dIntegrationTimeHighLamp */ 1200, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 0, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 0, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x15, /* bSensorConfiguration (0x0b) */ 0x4c, /* sensor control settings (reg 0x0c) */ 0x2f, /* sensor control settings (reg 0x0d) */ 0x00, /* sensor control settings (reg 0x0e) */ /* mono & color (reg 0x0f to 0x18) the same for CIS devices */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode (runtime) */ /* illumination mode settings */ { 3, 0, 0, 23, 850, 0, 0 }, { 2, 23, 2500, 23, 1800, 23, 950 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0, /* bOpticBlackStart (reg 0x1c) */ 0, /* bOpticBlackEnd (reg 0x1d) */ 89, /* ? wActivePixelsStart (reg 0x1e + 0x1f) */ 6074, /* wLineEnd (reg 0x20 + 0x21) */ 23, /* red lamp on (reg 0x2c + 0x2d) */ 2500, /* red lamp off (reg 0x2e + 0x2f) */ 23, /* green lamp on (reg 0x30 + 0x31) */ 1800, /* green lamp off (reg 0x32 + 0x33) */ 23, /* blue lamp on (reg 0x34 + 0x35) */ 950, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x3f, /* steps to reverse when buffer is full reg 0x50) */ 0xfc, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x0f, /* kickstart (reg 0x55) */ 0x08, /* pwm freq (reg 0x56) */ 0x1f, /* pwm duty cycle (reg 0x57) */ 0x05, /* Paper sense (reg 0x58) */ 0x66, /* misc io12 (reg 0x59) */ 0x16, /* misc io34 (reg 0x5a) */ 0x91, /* misc io56 (reg 0x5b) */ 0x01, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9832, MODEL_CANON600, 2.0 }; /** Canon N1220U */ static HWDef Hw0x04A9_0x2207 = { 0.72, /* dMaxMotorSpeed */ 0.36, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* wIntegrationTimeLowLamp */ 100, /* wIntegrationTimeHighLamp */ 1200, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 0, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 0, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x15, /* bSensorConfiguration (0x0b) */ 0x4c, /* sensor control settings (reg 0x0c) */ 0x2f, /* sensor control settings (reg 0x0d) */ 0x00, /* sensor control settings (reg 0x0e) */ /* mono (reg 0x0f to 0x18) */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, /* color (reg 0x0f to 0x18) */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode */ { 3, 0, 0, 23, 2200, 0, 0 }, { 2, 23, 16383, 23, 15000, 23, 6600 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0, /* bOpticBlackStart (reg 0x1c) */ 0, /* bOpticBlackEnd (reg 0x1d) */ 124, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 10586, /* wLineEnd (reg 0x20 + 0x21) */ 23, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 23, /* green lamp on (reg 0x30 + 0x31) */ 15000, /* green lamp off (reg 0x32 + 0x33) */ 23, /* blue lamp on (reg 0x34 + 0x35) */ 6600, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0, /* steps to reverse when buffer is full reg 0x50) */ 0xfc, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x0f, /* kickstart (reg 0x55) */ 0x08, /* pwm freq (reg 0x56) */ 0x1f, /* pwm duty cycle (reg 0x57) */ 0x05, /* Paper sense (reg 0x58) */ 0x66, /* misc io12 (reg 0x59) */ 0x16, /* misc io34 (reg 0x5a) */ 0x91, /* misc io56 (reg 0x5b) */ 0x01, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9832, MODEL_CANON1200, 2.0 }; /** Canon D660U */ static HWDef Hw0x04A9_0x2208 = { 1.2, /* dMaxMotorSpeed */ 1.1, /* dMaxMoveSpeed */ 2.75, /* dHighSpeed */ 9, /* dIntegrationTimeLowLamp */ 9, /* dIntegrationTimeHighLamp */ 300, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 8, /* dMinIntegrationTimeLowres (ms) */ 8, /* dMinIntegrationTimeHighres (ms) */ 4095, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 4095, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x02, /* bSensorConfiguration (0x0b) */ 0x60, /* sensor control settings (reg 0x0c) */ 0x2f, /* sensor control settings (reg 0x0d) */ 0x13, /* sensor control settings (reg 0x0e) */ {0x06, 0x17, 0x01, 0x03, 0x05, 0x07, 0x00, 0x00, 0x0b }, {0x06, 0x17, 0x01, 0x03, 0x05, 0x07, 0x00, 0x00, 0x0b }, _GREEN_CH, 0, /* bReg 0x27 color mode */ 1, /* bReg 0x29 illumination mode */ /* illumination mode settings (not used for CCD devices) */ { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, 0, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 13, /* bOpticBlackStart (reg 0x1c) */ 33, /* bOpticBlackEnd (reg 0x1d) */ 64, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 5440, /* wLineEnd (reg 0x20 + 0x21) */ 16383, /* red lamp on (reg 0x2c + 0x2d) */ 1, /* red lamp off (reg 0x2e + 0x2f) */ 0, /* green lamp on (reg 0x30 + 0x31) */ 0, /* green lamp off (reg 0x32 + 0x33) */ 0, /* blue lamp on (reg 0x34 + 0x35) */ 0, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x20, /* steps to reverse when buffer is full reg 0x50) */ 0xfc, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0, /* kickstart (reg 0x55) */ 0x02, /* pwm freq (reg 0x56) */ 0x1f, /* pwm duty cycle (reg 0x57) */ 0x05, /* Paper sense (reg 0x58) */ 0x44, /* misc io12 (reg 0x59) */ 0x14, /* misc io34 (reg 0x5a) */ 0x11, /* misc io56 (reg 0x5b) */ 0, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9832, MODEL_CANONCCD1200, 1.5 }; /** Canon 670/676/LiDE20 */ static HWDef Hw0x04A9_0x220D = { 0.72, /* dMaxMotorSpeed */ 0.23, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* dIntegrationTimeLowLamp */ 100, /* dIntegrationTimeHighLamp */ 1200, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 0, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 0, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x15, /* bSensorConfiguration (0x0b) */ 0x4c, /* sensor control settings (reg 0x0c) */ 0x2f, /* sensor control settings (reg 0x0d) */ 0x00, /* sensor control settings (reg 0x0e) */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, /* mono (reg 0x0f to 0x18) */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, /* color (reg 0x0f to 0x18) */ (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode (runtime) */ { 3, 0, 0, 23, 1800, 0, 0 }, { 2, 23, 3800, 23, 3300, 23, 2700 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0, /* bOpticBlackStart (reg 0x1c) */ 0, /* bOpticBlackEnd (reg 0x1d) */ 75, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 6074, /* wLineEnd (reg 0x20 + 0x21) */ 23, /* red lamp on (reg 0x2c + 0x2d) */ 3800, /* red lamp off (reg 0x2e + 0x2f) */ 23, /* green lamp on (reg 0x30 + 0x31) */ 3300, /* green lamp off (reg 0x32 + 0x33) */ 23, /* blue lamp on (reg 0x34 + 0x35) */ 2700, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x3f, /* steps to reverse when buffer is full reg 0x50) */ 0xfc, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x0f, /* kickstart (reg 0x55) */ 0x08, /* pwm freq (reg 0x56) */ 0x1f, /* pwm duty cycle (reg 0x57) */ 0x04, /* Paper sense (reg 0x58) */ 0x66, /* misc io12 (reg 0x59) */ 0x16, /* misc io34 (reg 0x5a) */ 0x91, /* misc io56 (reg 0x5b) */ 0x01, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9833, MODEL_CANON600, 2.0 }; /** Canon N1240U/LiDE30 */ static HWDef Hw0x04A9_0x220E = { 0.72, /* dMaxMotorSpeed */ 0.30, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* wIntegrationTimeLowLamp */ 100, /* wIntegrationTimeHighLamp */ 1200, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 0, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 0, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x15, /* bSensorConfiguration (0x0b) */ 0x4c, /* sensor control settings (reg 0x0c) */ 0x2f, /* sensor control settings (reg 0x0d) */ 0x00, /* sensor control settings (reg 0x0e) */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, /* mono (reg 0x0f to 0x18) */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, /* color (reg 0x0f to 0x18) */ (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode */ { 3, 0, 0, 23, 3000, 0, 0 }, { 2, 23, 16383, 23, 6500, 23, 4900 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0, /* bOpticBlackStart (reg 0x1c) */ 0, /* bOpticBlackEnd (reg 0x1d) */ 52, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 10586, /* wLineEnd (reg 0x20 + 0x21) */ 23, /* red lamp on (reg 0x2c + 0x2d) */ 16383, /* red lamp off (reg 0x2e + 0x2f) */ 23, /* green lamp on (reg 0x30 + 0x31) */ 6500, /* green lamp off (reg 0x32 + 0x33) */ 23, /* blue lamp on (reg 0x34 + 0x35) */ 4900, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x20, /* steps to reverse when buffer is full reg 0x50) */ 0xfc, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x0f, /* kickstart (reg 0x55) */ 0x08, /* pwm freq (reg 0x56) */ 0x1f, /* pwm duty cycle (reg 0x57) */ 0x04, /* Paper sense (reg 0x58) */ 0x66, /* misc io12 (reg 0x59) */ 0x16, /* misc io34 (reg 0x5a) */ 0x91, /* misc io56 (reg 0x5b) */ 0x01, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9833, MODEL_CANON1200, 2.0 }; /** Canon LiDE25 */ static HWDef Hw0x04A9_0x2220 = { 0.70, /* dMaxMotorSpeed */ 0.25, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* wIntegrationTimeLowLamp */ 100, /* wIntegrationTimeHighLamp */ 1200, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 0, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 0, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x11, /* bSensorConfiguration (0x0b) */ 0x4d, /* sensor control settings (reg 0x0c) */ 0x2f, /* sensor control settings (reg 0x0d) */ 0x00, /* sensor control settings (reg 0x0e) */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x07}, /* mono (reg 0x0f to 0x18) */ {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x07}, /* color (reg 0x0f to 0x18) */ (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode */ { 3, 0, 0, 50, 3700, 0, 0 }, { 2, 50, 5600, 50, 7100, 50, 4600 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0, /* bOpticBlackStart (reg 0x1c) */ 0, /* bOpticBlackEnd (reg 0x1d) */ 0x7f, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 10559, /* wLineEnd (reg 0x20 + 0x21) */ 50, /* red lamp on (reg 0x2c + 0x2d) */ 5600, /* red lamp off (reg 0x2e + 0x2f) */ 50, /* green lamp on (reg 0x30 + 0x31) */ 7100, /* green lamp off (reg 0x32 + 0x33) */ 50, /* blue lamp on (reg 0x34 + 0x35) */ 4600, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0x20, /* steps to reverse when buffer is full reg 0x50) */ 0xfc, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x0f, /* kickstart (reg 0x55) */ 0x08, /* pwm freq (reg 0x56) */ 0x1f, /* pwm duty cycle (reg 0x57) */ 0x04, /* Paper sense (reg 0x58) */ 0x66, /* misc io12 (reg 0x59) */ 0x16, /* misc io34 (reg 0x5a) */ 0x91, /* misc io56 (reg 0x5b) */ 0x01, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9833, MODEL_CANON_LIDE25, 2.0 }; /** TravelScan 662 */ static HWDef Hw0x0A82_0x6620 = { 0.72, /* dMaxMotorSpeed */ 0.188, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* wIntegrationTimeLowLamp */ 100, /* wIntegrationTimeHighLamp */ 740, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 3000, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 3000, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x0d, /* bSensorConfiguration (0x0b) */ 0x00, /* sensor control settings (reg 0x0c) */ 0x25, /* sensor control settings (reg 0x0d) */ 0x00, /* sensor control settings (reg 0x0e) */ {0x18, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07}, /* mono (reg 0x0f to 0x18) */ {0x18, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07}, /* color (reg 0x0f to 0x18) */ (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode */ { 3, 0, 0, 10, 450, 0, 0 }, { 2, 10, 1000, 10, 880, 10, 630 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 1, /* bOpticBlackStart (reg 0x1c) */ 2, /* bOpticBlackEnd (reg 0x1d) */ 0x17, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 2600, /* wLineEnd (reg 0x20 + 0x21) */ 10, /* red lamp on (reg 0x2c + 0x2d) */ 1000, /* red lamp off (reg 0x2e + 0x2f) */ 10, /* green lamp on (reg 0x30 + 0x31) */ 880, /* green lamp off (reg 0x32 + 0x33) */ 10, /* blue lamp on (reg 0x34 + 0x35) */ 630, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0, /* steps to reverse when buffer is full reg 0x50) */ 0, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x09, /* kickstart (reg 0x55) */ 0x02, /* pwm freq (reg 0x56) */ 0x16, /* pwm duty cycle (reg 0x57) */ 0x01, /* Paper sense (reg 0x58) */ 0x0e, /* misc io12 (reg 0x59) */ 0x96, /* misc io34 (reg 0x5a) */ 0x01, /* misc io56 (reg 0x5b) */ 0, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9833, MODEL_TSCAN, 1.8 }; /** TravelScan 464 */ static HWDef Hw0x0A82_0x4600 = { 0.72, /* dMaxMotorSpeed */ 0.26, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* wIntegrationTimeLowLamp */ 100, /* wIntegrationTimeHighLamp */ 740, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 3000, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 3000, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x0d, /* bSensorConfiguration (0x0b) */ 0x00, /* sensor control settings (reg 0x0c) */ 0x25, /* sensor control settings (reg 0x0d) */ 0x00, /* sensor control settings (reg 0x0e) */ {0x18, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07}, /* mono (reg 0x0f to 0x18) */ {0x18, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07}, /* color (reg 0x0f to 0x18) */ (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode */ { 3, 500, 1045, 500, 990, 500, 990 }, { 2, 500, 1045, 500, 990, 500, 990 }, 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 1, /* bOpticBlackStart (reg 0x1c) */ 2, /* bOpticBlackEnd (reg 0x1d) */ 0x17, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 5300, /* wLineEnd (reg 0x20 + 0x21) */ 500, /* red lamp on (reg 0x2c + 0x2d) */ 1045, /* red lamp off (reg 0x2e + 0x2f) */ 500, /* green lamp on (reg 0x30 + 0x31) */ 990, /* green lamp off (reg 0x32 + 0x33) */ 500, /* blue lamp on (reg 0x34 + 0x35) */ 990, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0, /* steps to reverse when buffer is full reg 0x50) */ 0, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x09, /* kickstart (reg 0x55) */ 0x02, /* pwm freq (reg 0x56) */ 0x16, /* pwm duty cycle (reg 0x57) */ 0x01, /* Paper sense (reg 0x58) */ 0x0e, /* misc io12 (reg 0x59) */ 0x96, /* misc io34 (reg 0x5a) */ 0x01, /* misc io56 (reg 0x5b) */ 0, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9833, MODEL_TSCAN_A4, 1.8 }; /** IRIScan/Q-Scan USB001 - Portable Peripheral Co., Ltd. */ static HWDef Hw0x0A53_0x1000 = { 0.50, /* dMaxMotorSpeed */ 0.40, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* wIntegrationTimeLowLamp */ 100, /* wIntegrationTimeHighLamp */ 300, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 4095, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 4095, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x09, /* bSensorConfiguration (0x0b) */ 0x00, /* sensor control settings (reg 0x0c) */ 0x65, /* sensor control settings (reg 0x0d) */ 0x13, /* sensor control settings (reg 0x0e) */ {0x02, 0x07, 0x05, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0x02}, /* mono (reg 0x0f to 0x18) */ {0x02, 0x07, 0x05, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0x02}, /* color (reg 0x0f to 0x18) */ (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode */ { 3, 0, 0, 2593, 4600, 0, 0 }, { 2, 2593, 7100, 2593, 4600, 2593, 4480 }, 256, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0, /* bOpticBlackStart (reg 0x1c) */ 0x15, /* bOpticBlackEnd (reg 0x1d) */ 0x15, /* wActivePixelsStart (reg 0x1e + 0x1f) */ 5500, /* wLineEnd (reg 0x20 + 0x21) */ 2593, /* red lamp on (reg 0x2c + 0x2d) */ 7100, /* red lamp off (reg 0x2e + 0x2f) */ 2593, /* green lamp on (reg 0x30 + 0x31) */ 4600, /* green lamp off (reg 0x32 + 0x33) */ 2593, /* blue lamp on (reg 0x34 + 0x35) */ 4480, /* blue lamp off (reg 0x36 + 0x37) */ 3, /* stepper motor control (reg 0x45) */ 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0, /* steps to reverse when buffer is full reg 0x50) */ 0, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x1b, /* kickstart (reg 0x55) */ 0x08, /* pwm freq (reg 0x56) */ 0x15, /* pwm duty cycle (reg 0x57) */ 0x00, /* Paper sense (reg 0x58) */ 0x00, /* misc io12 (reg 0x59) */ 0x00, /* misc io34 (reg 0x5a) */ 0x00, /* misc io56 (reg 0x5b) */ 0, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9832, MODEL_QSCAN, 1.1 }; /** PandP USB201 Q-Scan A6 Scanner */ static HWDef Hw0x0A53_0x2000 = { 0.5, /* dMaxMotorSpeed */ 0.2, /* dMaxMoveSpeed */ 0.0, /* dHighSpeed */ 100, /* wIntegrationTimeLowLamp */ 100, /* wIntegrationTimeHighLamp */ 570, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ 3.75, /* dMinIntegrationTimeLowres (ms) */ 5.75, /* dMinIntegrationTimeHighres (ms) */ 0x0fff, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 0x0fff, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x02, /* bSensorConfiguration (0x0b) */ 0x00, /* sensor control settings (reg 0x0c) */ 0x25, /* sensor control settings (reg 0x0d) */ 0x06, /* sensor control settings (reg 0x0e) */ {0x05, 0x0a, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x04, 0x07}, /* mono (reg 0x0f to 0x18) */ {0x05, 0x0a, 0x01, 0x02, 0x00, 0x01, 0x00, 0x00, 0x04, 0x07}, /* color (reg 0x0f to 0x18) */ (_BLUE_CH | _ONE_CH_COLOR), /* bReg_0x26 color mode */ 0x00, /* bReg 0x27 color mode */ 2, /* bReg 0x29 illumination mode */ { 3, 0, 0, 10, 450, 0, 0 }, /* initial illumination settings - mono */ { 2, 10, 1000, 10, 880, 10, 630 }, /* initial illumination settings - color */ 0x0101, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x004d, /* bOpticBlackStart (reg 0x22 + 0x23) */ 0x11, /* bOpticBlackEnd */ 0x0011, /* wActivePixelsStart */ 0x0bb8, /* wLineEnd (reg 0x20 + 0x21) */ 10, /* red lamp on (reg 0x2c + 0x2d) */ 1000, /* red lamp off (reg 0x2e + 0x2f) */ 10, /* green lamp on (reg 0x30 + 0x31) */ 880, /* green lamp off (reg 0x32 + 0x33) */ 10, /* blue lamp on (reg 0x34 + 0x35) */ 630, /* blue lamp off (reg 0x36 + 0x37) */ 0x13, /* stepper motor control (reg 0x45) */ 0x0000, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ 0, /* steps to reverse when buffer is full reg 0x50) */ 0, /* acceleration profile (reg 0x51) */ 0, /* lines to process (reg 0x54) */ 0x1b, /* kickstart (reg 0x55) */ 0x08, /* pwm freq (reg 0x56) */ 0x15, /* pwm duty cycle (reg 0x57) */ 0x00, /* Paper sense (reg 0x58) */ 0x20, /* misc io12 (reg 0x59) */ 0x02, /* misc io34 (reg 0x5a) */ 0x90, /* misc io56 (reg 0x5b) */ 0, /* test mode ADC Output CODE MSB (reg 0x5c) */ 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ 0, /* test mode (reg 0x5e) */ _LM9832, MODEL_QSCAN_A6, 1.8 }; /******************** all available combinations *****************************/ /** here we have all supported devices and their settings... */ static SetDef Settings[] = { /* Plustek devices... */ /* LM9831 based */ {"0x07B3-0x0010-0", &Cap0x07B3_0x0010_0, &Hw0x07B3_0x0013_0, "OpticPro U12" }, {"0x07B3-0x0011-0", &Cap0x07B3_0x0011_0, &Hw0x07B3_0x0013_0, "OpticPro U24" }, {"0x07B3-0x0013-0", &Cap0x07B3_0x0013_0, &Hw0x07B3_0x0013_0, "OpticPro UT12" }, /* LM9832 based */ {"0x07B3-0x0017-0", &Cap0x07B3_0x0017_0, &Hw0x07B3_0x0017_0, "OpticPro UT12/UT16" }, {"0x07B3-0x0015-0", &Cap0x07B3_0x0015_0, &Hw0x07B3_0x0017_0, "OpticPro U24" }, {"0x07B3-0x0015-4", &Cap0x07B3_0x0015_4, &Hw0x07B3_0x0017_4, "OpticPro U24" }, {"0x07B3-0x0017-4", &Cap0x07B3_0x0017_4, &Hw0x07B3_0x0017_4, "OpticPro UT24" }, /* never seen yet */ {"0x07B3-0x0013-4", &Cap0x07B3_0x0013_4, &Hw0x07B3_0x0013_4, "Unknown device" }, {"0x07B3-0x0011-4", &Cap0x07B3_0x0011_4, &Hw0x07B3_0x0013_4, "Unknown device" }, {"0x07B3-0x0010-4", &Cap0x07B3_0x0010_4, &Hw0x07B3_0x0013_4, "Unknown device" }, {"0x07B3-0x0014-0", &Cap0x07B3_0x0014_0, &Hw0x07B3_0x0017_0, "Unknown device" }, {"0x07B3-0x0014-4", &Cap0x07B3_0x0014_4, &Hw0x07B3_0x0017_4, "Unknown device" }, {"0x07B3-0x0016-4", &Cap0x07B3_0x0016_4, &Hw0x07B3_0x0016_4, "Unknown device" }, {"0x07B3-0x0017-2", &Cap0x07B3_0x0017_2, &Hw0x07B3_0x0017_2, "Unknown device" }, {"0x07B3-0x0017-3", &Cap0x07B3_0x0017_3, &Hw0x07B3_0x0017_3, "Unknown device" }, {"0x07B3-0x0007", &Cap0x07B3_0x0007_0, &Hw0x07B3_0x0007_0, "Unknown device" }, {"0x07B3-0x000F", &Cap0x07B3_0x000F_0, &Hw0x07B3_0x000F_0, "Unknown device" }, {"0x07B3-0x000F-4", &Cap0x07B3_0x000F_4, &Hw0x07B3_0x000F_4, "Unknown device" }, {"0x07B3-0x0005-2", &Cap0x07B3_0x0005_2, &Hw0x07B3_0x0007_2, "Unknown device" }, /* TOKYO 600 */ {"0x07B3-0x0014-1", &Cap0x07B3_0x0014_1, &Hw0x07B3_0x0017_1, "Unknown device" }, /* A3 */ {"0x07B3-0x0012-0", &Cap0x07B3_0x0012_0, &Hw0x07B3_0x0012_0, "Unknown device" }, /* Brother Demo */ /* Mustek BearPaw...*/ {"0x0400-0x1000-0", &Cap0x0400_0x1000_0, &Hw0x0400_0x1000_0, "BearPaw 1200" }, {"0x0400-0x1001-1", &Cap0x0400_0x1000_0, &Hw0x0400_0x1001_1, "BearPaw 1200" }, {"0x0400-0x1001-0", &Cap0x0400_0x1001_0, &Hw0x0400_0x1001_0, "BearPaw 2400" }, /* Genius devices... */ {"0x0458-0x2007", &Cap0x07B3_0x0007_0, &Hw0x07B3_0x0007_0, "ColorPage-HR6 V2" }, {"0x0458-0x2008", &Cap0x07B3_0x0007_0, &Hw0x07B3_0x0007_0, "ColorPage-HR6 V2" }, {"0x0458-0x2009", &Cap0x07B3_0x000F_0, &Hw0x07B3_0x000F_0, "ColorPage-HR6A" }, {"0x0458-0x2013", &Cap0x07B3_0x0007_4, &Hw0x07B3_0x0007_4, "ColorPage-HR7" }, {"0x0458-0x2015", &Cap0x07B3_0x0005_4, &Hw0x07B3_0x0007_4, "ColorPage-HR7LE" }, {"0x0458-0x2016", &Cap0x07B3_0x0005_4, &Hw0x07B3_0x0007_0, "ColorPage-HR6X" }, /* Hewlett Packard... */ {"0x03F0-0x0505", &Cap0x03F0_0x0505, &Hw0x03F0_0x0505, "Scanjet 2100c" }, {"0x03F0-0x0605", &Cap0x03F0_0x0605, &Hw0x03F0_0x0605, "Scanjet 2200c" }, /* EPSON... */ {"0x04B8-0x010F", &Cap0x04B8_0x010F, &Hw0x04B8_0x010F, "Perfection 1250/Photo" }, {"0x04B8-0x011D", &Cap0x04B8_0x010F, &Hw0x04B8_0x011D, "Perfection 1260/Photo" }, /* UMAX... */ {"0x1606-0x0050", &Cap0x1606_0x0060, &Hw0x1606_0x0060, "3400" }, {"0x1606-0x0060", &Cap0x1606_0x0060, &Hw0x1606_0x0060, "3400" }, {"0x1606-0x0160", &Cap0x1606_0x0160, &Hw0x1606_0x0160, "5400" }, /* COMPAQ... */ {"0x049F-0x001A", &Cap0x1606_0x0060, &Hw0x1606_0x0060, "S4-100" }, /* CANON... */ {"0x04A9-0x2206", &Cap0x04A9_0x2206, &Hw0x04A9_0x2206, "CanoScan N650U/N656U" }, {"0x04A9-0x2207", &Cap0x04A9_0x2207, &Hw0x04A9_0x2207, "CanoScan N1220U" }, {"0x04A9-0x2208", &Cap0x04A9_0x2208, &Hw0x04A9_0x2208, "CanoScan D660U" }, {"0x04A9-0x220D", &Cap0x04A9_0x220D, &Hw0x04A9_0x220D, "CanoScan N670U/N676U/LiDE20" }, {"0x04A9-0x220E", &Cap0x04A9_0x220E, &Hw0x04A9_0x220E, "CanoScan N1240U/LiDE30" }, {"0x04A9-0x2220", &Cap0x04A9_0x2220, &Hw0x04A9_0x2220, "CanoScan LiDE25" }, /* SYSCAN... */ {"0x0A82-0x4600", &Cap0x0A82_0x4600, &Hw0x0A82_0x4600, "TravelScan 460/464" }, {"0x0A82-0x6620", &Cap0x0A82_0x6620, &Hw0x0A82_0x6620, "TravelScan 662" }, /* Visioneer... */ {"0x04A7-0x0427", &Cap0x0A82_0x4600, &Hw0x0A82_0x4600, "Strobe XP100" }, /* Portable Peripheral Co., Ltd. */ {"0x0A53-0x1000", &Cap0x0A53_0x1000, &Hw0x0A53_0x1000, "Q-Scan USB001" }, {"0x0A53-0x2000", &Cap0x0A53_0x2000, &Hw0x0A53_0x2000, "Q-Scan USB201" }, /* Please add other devices here... * The first entry is a string, composed out of the vendor and product id, * it's used by the driver to select the device settings. For other devices * than those of Plustek, you'll not need to add the second '-' part * * The second entry decribes the capabilities of the device, you may find * one suitable for your scanner, for a better description of the entries * have a look at the beginning of this file at Cap0x07B3_0x0017_0 for * the UT12 * * The third entry is for the default setting of the LM983x register * settings, you can often find these in your Windoze driver ini * Have a look at the Hw0x0400_0x1000_0 or Hw0x07B3_0x0017_0 for further * description * * The fourth entry is simply the name of the device, which will be * displayed by the frontend */ { NULL, NULL, NULL, NULL } /* last entry, never remove... */ }; /** * tables for the motor settings * The models KaoHsiung, HuaLien and Tokyo600 are currently set * within the code in conjunction with some CCD combinations. * NOTE: the touples PWM and PWM_Duty are used to set the registers * 0x56 and 0x57, the recommended setting is 8,10 * if you notice a whining noise and the motor does not move, * you might increase the MCLK variable. */ static ClkMotorDef Motors[] = { { MODEL_KaoHsiung, 64, 20, 6, /* PWM, PWM_Duty, MCLK for fast move */ 0, 0, /* for lineend adjustment, here disabled */ /* Motor settings (PWM and PWM_Duty) */ {{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}, /* Color mode MCLK settings */ { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, /* Gray mode MCLK settings */ { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 } }, { MODEL_HuaLien, 64, 20, 6, 0, 0, /* Motor settings (PWM and PWM_Duty) */ {{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}, /* Color mode MCLK settings */ { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, /* Gray mode MCLK settings */ { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 } }, { MODEL_Tokyo600, 4, 4, 6, 0, 0, /* Motor settings (PWM and PWM_Duty) */ {{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}, /* Color mode MCLK settings */ { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, /* Gray mode MCLK settings */ { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, { 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 } }, { MODEL_MUSTEK600, 4, 4, 6, 0, 0, /* Motor settings (PWM and PWM_Duty) */ {{ 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }}, /* Color mode MCLK settings */ { 4.0, 3.5, 3.5, 4.0, 4.0, 5.0, 5.0, 7.5, 7.5, 7.5 }, { 4.0, 3.5, 3.5, 4.0, 4.0, 5.0, 5.0, 7.5, 7.5, 7.5 }, /* Gray mode MCLK settings */ { 7.5, 7.0, 6.5, 5.5, 5.5, 5.5, 7.0, 7.0, 7.0, 7.0 }, { 7.5, 7.0, 6.5, 5.5, 5.5, 5.5, 7.0, 7.0, 7.0, 7.0 } }, { MODEL_MUSTEK1200, 2, 32, 3, 0, 0, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 2, 32, 1 }, { 2, 32, 1 }, { 2, 32, 1 }, { 2, 32, 1 }, { 2, 32, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 2, 32, 1 }, { 2, 32, 1 }, { 2, 32, 1 }, { 2, 32, 1 }, { 2, 32, 1 }}, /* Color mode MCLK settings */ { 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5 }, { 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5 }, /* Gray mode MCLK settings */ { 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 }, { 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 } }, /* settings good for the HP models (tested with 2200)*/ { MODEL_HP, 8, 60, 6, 0, 0, /* Motor settings (PWM and PWM_Duty) */ {{ 8, 60, 1 }, { 8, 60, 1 }, { 8, 60, 1 }, { 8, 60, 1 }, { 8, 60, 1 }, { 8, 60, 1 }, { 8, 60, 1 }, { 8, 60, 1 }, { 8, 60, 1 }, { 8, 60, 1 }}, /* Color mode MCLK settings */ { 4.0, 4.0, 4.0, 4.0, 3.0, 4.0, 6.0, 6.0, 6.0, 6.0 }, { 4.0, 4.0, 4.0, 4.0, 3.0, 4.0, 6.0, 6.0, 6.0, 6.0 }, /* Gray mode MCLK settings */ { 8.0, 8.0, 8.0, 8.0, 8.0, 13.0, 13.0, 13.0, 13.0, 13.0 }, { 8.0, 8.0, 8.0, 8.0, 8.0, 13.0, 13.0, 13.0, 13.0, 13.0 } }, { MODEL_CANON600, 8, 31, 12, 0, 0, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }}, /* Color mode MCLK settings */ { 7.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, { 7.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, /* Gray mode MCLK settings */ { 15.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0 }, { 15.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0, 12.0 } }, { MODEL_CANON1200, 8, 31, 8, 0, 0, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }}, /* Color mode MCLK settings */ { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 }, { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 5.0, 6.0, 6.0, 6.0 }, /* Gray mode MCLK settings */ { 8.5, 7.0, 5.0, 4.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5 }, { 8.5, 6.5, 6.0, 6.0, 6.0, 6.0, 8.0, 12.0, 12.0, 12.0 } }, /* settings good for the UMAX models (tested with 3400) */ { MODEL_UMAX, 16, 4, 6, 0, 0, /* Motor settings (PWM and PWM_Duty) */ {{ 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }}, /* Color mode MCLK settings */ { 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5 }, { 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5 }, /* Gray mode MCLK settings */ { 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5 }, { 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5, 10.5 } }, { MODEL_UMAX1200, 16, 4, 6, 0, 0, /* Motor settings (PWM and PWM_Duty) */ {{ 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }, { 16, 4, 1 }}, /* Color mode MCLK settings */ { 3.0, 3.0, 3.0, 3.0, 3.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, { 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 }, /* Gray mode MCLK settings */ { 6.0, 6.0, 6.0, 6.0, 6.0, 13.0, 13.0, 13.0, 13.0, 13.0 }, { 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0, 13.0 } }, /* settings good for the EPSON models */ { MODEL_EPSON, 2, 1, 6, 0, 0, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 2, 1, 1 }, { 2, 1, 1 }, { 2, 1, 1 }, { 2, 1, 1 }, { 2, 1, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 2, 1, 1 }, { 2, 1, 1 }, { 2, 1, 1 }, { 2, 1, 1 }, { 2, 1, 1 }}, /* Color mode MCLK settings */ { 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 4.0, 4.0, 6.0, 6.0 }, { 2.0, 2.0, 2.5, 2.5, 3.0, 3.0, 3.0, 4.0, 6.0, 6.0 }, /* Gray mode MCLK settings */ { 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 9.0, 9.0, 18.0, 18.0 }, { 6.0, 6.0, 6.0, 6.0, 6.0, 8.0, 9.0, 9.0, 18.0, 18.0 } }, { MODEL_CANONCCD1200, 2, 31, 3, 0, 0, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 2, 31, 1 }, { 2, 31, 1 }, { 2, 31, 1 }, { 2, 31, 1 }, { 2, 31, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 2, 31, 1 }, { 2, 31, 1 }, { 2, 31, 1 }, { 2, 31, 1 }, { 2, 31, 1 }}, /* Color mode MCLK settings */ { 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 3.0, 3.5, 5.0, 5.0 }, { 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 5.0, 5.0 }, /* Gray mode MCLK settings */ { 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, { 6.5, 6.5, 6.5, 7.0, 8.0, 8.0, 8.0, 10.0, 10.0, 10.0 } }, { MODEL_CANON_LIDE25, 8, 31, 3, 0, 0, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }, { 8, 31, 1 }}, /* Color mode MCLK settings */ { 3.0, 3.0, 3.0, 3.0, 3.5, 3.0, 3.0, 3.0, 3.0, 3.0 }, { 3.0, 3.0, 3.0, 3.0, 3.5, 3.5, 5.0, 6.0, 6.0, 6.0 }, /* Gray mode MCLK settings */ { 8.5, 7.0, 5.0, 4.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5 }, { 7.5, 6.5, 6.0, 6.0, 6.0, 6.0, 8.0, 12.0, 12.0, 12.0 } }, { MODEL_TSCAN, 2, 22, 6, 75, 4000, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }}, /* Color mode MCLK settings */ { 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, { 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, /* Gray mode MCLK settings */ { 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0 }, { 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0 }, }, { MODEL_TSCAN_A4, 2, 22, 6, 75, 8400, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }, { 2, 22, 1 }}, /* Color mode MCLK settings */ { 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, { 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, /* Gray mode MCLK settings */ { 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0 }, { 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0, 16.0 }, }, { MODEL_QSCAN, 8, 21, 6, 300, 4600, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 8, 21, 1 }, { 8, 21, 1 }, { 8, 21, 1 }, { 8, 21, 1 }, { 8, 21, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 8, 21, 1 }, { 8, 21, 1 }, { 8, 21, 1 }, { 8, 21, 1 }, { 8, 21, 1 }}, /* Color mode MCLK settings */ { 6.5, 6.5, 6.5, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, { 6.5, 6.5, 6.5, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, /* Gray mode MCLK settings */ { 6.5, 6.5, 6.5, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, { 6.5, 6.5, 6.5, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0 }, }, { MODEL_QSCAN_A6, 8, 15, 6, 0, 0, /* Motor settings (PWM and PWM_Duty) */ /* <=75dpi <=100dpi <=150dpi <=200dpi <=300dpi */ {{ 8, 15, 1}, { 8, 15, 1 }, { 8, 15, 1 }, { 8, 15, 1 }, { 8, 15, 1 }, /* <=400dpi <=600dpi <=800dpi <=1200dpi <=2400dpi */ { 8, 15, 1 }, { 8, 15, 1 }, { 8, 15, 1 }, { 8, 15, 1 }, { 8, 15, 1 }}, /* Color mode MCLK settings */ { 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5 }, { 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 7.5 }, /* Gray mode MCLK settings */ { 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0 }, { 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0 }, } }; /* END PLUSTEK-USBDEVS.C ....................................................*/ sane-backends-1.0.29/backend/bh.conf.in0000666000000000000000000000003513615534521014433 00000000000000scsi "B&H SCSI" /dev/scanner sane-backends-1.0.29/backend/plustek-usb.c0000666000000000000000000012362513615534521015223 00000000000000/*............................................................................. * Project : SANE library for Plustek flatbed scanners. *............................................................................. */ /** @file plustek-usb.c * @brief The interface functions to the USB driver stuff. * * Based on sources acquired from Plustek Inc.
* Copyright (C) 2001-2007 Gerhard Jaeger * * History: * - 0.40 - starting version of the USB support * - 0.41 - removed CHECK * - added Canon to the manufacturer list * - 0.42 - added warmup stuff * - added setmap function * - changed detection stuff, so we first check whether * - the vendor and product Ids match with the ones in our list * - 0.43 - cleanup * - 0.44 - changes to integration CIS based devices * - 0.45 - added skipFine assignment * - added auto device name detection if only product and vendor id
* has been specified * - made 16-bit gray mode work * - added special handling for Genius devices * - added TPA autodetection for EPSON Photo * - fixed bug that causes warmup each time autodetected
* TPA on EPSON is used * - removed Genius from PCB-Id check * - added Compaq to the list * - removed the scaler stuff for CIS devices * - removed homeing stuff from readline function * - fixed flag setting in usbDev_startScan() * - 0.46 - added additional branch to support alternate calibration * - 0.47 - added special handling with 0x400 vendor ID and model override * - removed PATH_MAX * - change usbDev_stopScan and usbDev_open prototype * - cleanup * - 0.48 - added function usb_CheckAndCopyAdjs() * - 0.49 - changed autodetection * - added support for LiDE25 (pid 0x2220) * - 0.50 - minor fix for startup reset * removed unnecessary calls to usbio_ResetLM983x() * 1200DPI CIS devices don't use GrayFromColor any longer * - 0.51 - added Syscan to the vendor list * - added SCANFLAG_Calibration handling * - 0.52 - added _WAF_LOFF_ON_START and _WAF_INC_DARKTGT * handling in usbDev_startScan() * added Visioneer * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ /** useful for description tables */ typedef struct { int id; char *desc; char *desc_alt; } TabDef, *pTabDef; /** to allow different vendors... */ static TabDef usbVendors[] = { { 0x07B3, "Plustek", NULL }, { 0x0400, "NSC", "Mustek" }, { 0x0458, "KYE/Genius", NULL }, { 0x03F0, "Hewlett-Packard", NULL }, { 0x04B8, "Epson", NULL }, { 0x04A7, "Visioneer", NULL }, { 0x04A9, "Canon", NULL }, { 0x1606, "UMAX", NULL }, { 0x049F, "Compaq", NULL }, { 0x0A82, "Syscan", NULL }, { 0x0A53, "PandP Co., Ltd.", NULL }, { 0xFFFF, NULL, NULL } }; /** we use at least 8 megs for scanning... */ #define _SCANBUF_SIZE (8 * 1024 * 1024) /********************** the USB scanner interface ****************************/ /** remove the slash out of the model-name to obtain a valid filename */ static SANE_Bool usb_normFileName( char *fname, char* buffer, u_long max_len ) { char *src, *dst; if( NULL == fname ) return SANE_FALSE; if( strlen( fname ) >= max_len ) return SANE_FALSE; src = fname; dst = buffer; while( *src != '\0' ) { if((*src == '/') || isspace(*src) || ispunct(*src)) *dst = '_'; else *dst = *src; dst++; src++; } *dst = '\0'; return SANE_TRUE; } /** do some range checking and copy the adjustment values from the * frontend to our internal structures, so that the backend can take * care of them. */ static void usb_CheckAndCopyAdjs( Plustek_Device *dev ) { if( dev->adj.lampOff >= 0 ) dev->usbDev.dwLampOnPeriod = dev->adj.lampOff; if( dev->adj.lampOffOnEnd >= 0 ) dev->usbDev.bLampOffOnEnd = dev->adj.lampOffOnEnd; if( dev->adj.skipCalibration > 0 ) dev->usbDev.Caps.workaroundFlag |= _WAF_BYPASS_CALIBRATION; if( dev->adj.skipFine > 0 ) dev->usbDev.Caps.workaroundFlag |= _WAF_SKIP_FINE; if( dev->adj.skipFineWhite > 0 ) dev->usbDev.Caps.workaroundFlag |= _WAF_SKIP_WHITEFINE; if( dev->adj.incDarkTgt > 0 ) dev->usbDev.Caps.workaroundFlag |= _WAF_INC_DARKTGT; if( dev->adj.skipDarkStrip > 0 ) dev->usbDev.Caps.Normal.DarkShadOrgY = -1; if( dev->adj.invertNegatives > 0 ) dev->usbDev.Caps.workaroundFlag |= _WAF_INV_NEGATIVE_MAP; } /** * assign the values to the structures used by the currently found scanner */ static void usb_initDev( Plustek_Device *dev, int idx, int handle, int vendor ) { char *ptr; char tmp_str1[PATH_MAX]; char tmp_str2[PATH_MAX]; int i; ScanParam sParam; u_short tmp = 0; int ret = 0; DBG( _DBG_INFO, "usb_initDev(%d,0x%04x,%i)\n", idx, vendor, dev->initialized ); /* save capability flags... */ if( dev->initialized >= 0 ) { tmp = DEVCAPSFLAG_TPA; } /* copy the original values... */ memcpy( &dev->usbDev.Caps, Settings[idx].pDevCaps, sizeof(DCapsDef)); memcpy( &dev->usbDev.HwSetting, Settings[idx].pHwDef, sizeof(HWDef)); /* restore capability flags... */ if( dev->initialized >= 0 ) { dev->usbDev.Caps.wFlags |= tmp; } usb_CheckAndCopyAdjs( dev ); DBG( _DBG_INFO, "Device WAF : 0x%08lx\n", dev->usbDev.Caps.workaroundFlag ); DBG( _DBG_INFO, "Transferrate: %lu Bytes/s\n", dev->transferRate ); /* adjust data origin */ dev->usbDev.Caps.Positive.DataOrigin.x -= dev->adj.tpa.x; dev->usbDev.Caps.Positive.DataOrigin.y -= dev->adj.tpa.y; dev->usbDev.Caps.Negative.DataOrigin.x -= dev->adj.neg.x; dev->usbDev.Caps.Negative.DataOrigin.y -= dev->adj.neg.y; dev->usbDev.Caps.Normal.DataOrigin.x -= dev->adj.pos.x; dev->usbDev.Caps.Normal.DataOrigin.y -= dev->adj.pos.y; /** adjust shading position */ if( dev->adj.posShadingY >= 0 ) dev->usbDev.Caps.Normal.ShadingOriginY = dev->adj.posShadingY; if( dev->adj.tpaShadingY >= 0 ) dev->usbDev.Caps.Positive.ShadingOriginY = dev->adj.tpaShadingY; if( dev->adj.negShadingY >= 0 ) dev->usbDev.Caps.Negative.ShadingOriginY = dev->adj.negShadingY; /* adjust the gamma settings... */ if( dev->adj.rgamma == 1.0 ) dev->adj.rgamma = dev->usbDev.HwSetting.gamma; if( dev->adj.ggamma == 1.0 ) dev->adj.ggamma = dev->usbDev.HwSetting.gamma; if( dev->adj.bgamma == 1.0 ) dev->adj.bgamma = dev->usbDev.HwSetting.gamma; if( dev->adj.graygamma == 1.0 ) dev->adj.graygamma = dev->usbDev.HwSetting.gamma; /* the following you normally get from the registry... */ bMaxITA = 0; /* Maximum integration time adjust */ dev->usbDev.ModelStr = Settings[idx].pModelString; dev->fd = handle; if( dev->initialized < 0 ) { if( usb_HasTPA( dev )) dev->usbDev.Caps.wFlags |= DEVCAPSFLAG_TPA; } DBG( _DBG_INFO, "Device Flags: 0x%08x\n", dev->usbDev.Caps.wFlags ); /* well now we patch the vendor string... * if not found, the default vendor will be Plustek */ for( i = 0; usbVendors[i].desc != NULL; i++ ) { if( usbVendors[i].id == vendor ) { dev->sane.vendor = usbVendors[i].desc; if (dev->usbDev.Caps.workaroundFlag & _WAF_USE_ALT_DESC ) if (usbVendors[i].desc_alt ) dev->sane.vendor = usbVendors[i].desc_alt; DBG( _DBG_INFO, "Vendor adjusted to: >%s<\n", dev->sane.vendor ); break; } } dev->usbDev.dwTicksLampOn = 0; dev->usbDev.currentLamp = usb_GetLampStatus( dev ); usb_ResetRegisters( dev ); if( dev->initialized >= 0 ) return; usb_IsScannerReady( dev ); sParam.bBitDepth = 8; sParam.bCalibration = PARAM_Scan; sParam.bChannels = 3; sParam.bDataType = SCANDATATYPE_Color; sParam.bSource = SOURCE_Reflection; sParam.Origin.x = 0; sParam.Origin.y = 0; sParam.UserDpi.x = 150; sParam.UserDpi.y = 150; sParam.dMCLK = 4; sParam.Size.dwPixels = 0; /* create calibration-filename */ sprintf( tmp_str2, "%s-%s", dev->sane.vendor, dev->usbDev.ModelStr ); if( !usb_normFileName( tmp_str2, tmp_str1, PATH_MAX )) { strcpy( tmp_str1, "plustek-default" ); } ptr = getenv ("HOME"); ret = ( NULL == ptr )? snprintf( tmp_str2, sizeof(tmp_str2), "/tmp/%s", tmp_str1 ): snprintf( tmp_str2, sizeof(tmp_str2), "%s/.sane/%s", ptr, tmp_str1 ); if ((ret < 0) || (ret > (int)sizeof(tmp_str2))) { DBG( _DBG_WARNING, "Failed to generate calibration file path. Default substituted.\n" ); snprintf(tmp_str2, sizeof(tmp_str2), "/tmp/plustek-default"); } dev->calFile = strdup( tmp_str2 ); DBG( _DBG_INFO, "Calibration file-names set to:\n" ); DBG( _DBG_INFO, ">%s-coarse.cal<\n", dev->calFile ); DBG( _DBG_INFO, ">%s-fine.cal<\n", dev->calFile ); /* initialize the ASIC registers */ usb_SetScanParameters( dev, &sParam ); /* check and move sensor to its home position */ usb_ModuleToHome( dev, SANE_FALSE ); /* set the global flag, that we are initialized so far */ dev->initialized = idx; } /** * will be used for retrieving a Plustek device */ static int usb_CheckForPlustekDevice( int handle, Plustek_Device *dev ) { char tmp[50]; char pcbStr[10]; u_char reg59[3], reg59s[3], pcbID; int i, result; /* * Plustek uses the misc IO 12 to get the PCB ID * (PCB = printed circuit board), so it's possible to have one * product ID and up to 7 different devices... */ DBG( _DBG_INFO, "Trying to get the pcbID of a Plustek device...\n" ); /* get the PCB-ID */ result = sanei_lm983x_read( handle, 0x59, reg59s, 3, SANE_TRUE ); if( SANE_STATUS_GOOD != result ) { sanei_usb_close( handle ); return -1; } reg59[0] = 0x22; /* PIO1: Input, PIO2: Input */ reg59[1] = 0x02; /* PIO3: Input, PIO4: Output as low */ reg59[2] = 0x03; result = sanei_lm983x_write( handle, 0x59, reg59, 3, SANE_TRUE ); if( SANE_STATUS_GOOD != result ) { sanei_usb_close( handle ); return -1; } result = sanei_lm983x_read ( handle, 0x02, &pcbID, 1, SANE_TRUE ); if( SANE_STATUS_GOOD != result ) { sanei_usb_close( handle ); return -1; } pcbID = (u_char)((pcbID >> 2) & 0x07); result = sanei_lm983x_read( handle, 0x59, reg59s, 3, SANE_TRUE ); if( SANE_STATUS_GOOD != result ) { sanei_usb_close( handle ); return -1; } DBG( _DBG_INFO, "pcbID=0x%02x\n", pcbID ); /* now roam through the setting list... */ strncpy( tmp, dev->usbId, 13 ); tmp[13] = '\0'; sprintf( pcbStr, "-%u", pcbID ); strcat ( tmp, pcbStr ); DBG( _DBG_INFO, "Checking for device >%s<\n", tmp ); for( i = 0; NULL != Settings[i].pIDString; i++ ) { if( 0 == strcmp( Settings[i].pIDString, tmp )) { DBG(_DBG_INFO, "Device description for >%s< found.\n", tmp ); usb_initDev( dev, i, handle, dev->usbDev.vendor ); return handle; } } return -1; } /** * will be called upon sane_exit */ static void usbDev_shutdown( Plustek_Device *dev ) { SANE_Int handle; DBG( _DBG_INFO, "Shutdown called (dev->fd=%d, %s)\n", dev->fd, dev->sane.name ); if( NULL == dev->usbDev.ModelStr ) { DBG( _DBG_INFO, "Function ignored!\n" ); return; } if( SANE_STATUS_GOOD == sanei_usb_open( dev->sane.name, &handle )) { dev->fd = handle; DBG( _DBG_INFO, "Waiting for scanner-ready...\n" ); usb_IsScannerReady( dev ); if( 0 != dev->usbDev.bLampOffOnEnd ) { DBG( _DBG_INFO, "Switching lamp off...\n" ); usb_LampOn( dev, SANE_FALSE, SANE_FALSE ); } dev->fd = -1; sanei_usb_close( handle ); } usb_StopLampTimer( dev ); } /** * This function checks wether a device, described by a given * string(vendor and product ID), is support by this backend or not * * @param usbIdStr - sting consisting out of product and vendor ID * format: "0xVVVVx0xPPPP" VVVV = Vendor ID, PPP = Product ID * @returns; SANE_TRUE if supported, SANE_FALSE if not */ static SANE_Bool usb_IsDeviceInList( char *usbIdStr ) { int i; for( i = 0; NULL != Settings[i].pIDString; i++ ) { if( 0 == strncmp( Settings[i].pIDString, usbIdStr, 13 )) return SANE_TRUE; } return SANE_FALSE; } /** get last valid entry of a list */ static DevList* getLast( DevList *l ) { if( l == NULL ) return NULL; while( l->next != NULL ) l = l->next; return l; } /** add a new entry to our internal device list, when a device is detected */ static SANE_Status usb_attach( SANE_String_Const dev_name ) { int len; DevList *tmp, *last; /* get some memory for the entry... */ len = sizeof(DevList) + strlen(dev_name) + 1; tmp = (DevList*)malloc(len); /* initialize and set the values */ memset(tmp, 0, len ); /* the device name is part of our structure space */ tmp->dev_name = &((char*)tmp)[sizeof(DevList)]; strcpy( tmp->dev_name, dev_name ); tmp->attached = SANE_FALSE; /* root set ? */ if( usbDevs == NULL ) { usbDevs = tmp; } else { last = getLast(usbDevs); /* append... */ last->next = tmp; } return SANE_STATUS_GOOD; } /** */ static void usbGetList( DevList **devs ) { int i; SANE_Bool il; SANE_Word v, p; DevList *tmp; DBG( _DBG_INFO, "Retrieving all supported and conntected devices\n" ); for( i = 0; NULL != Settings[i].pIDString; i++ ) { v = strtol( &(Settings[i].pIDString)[0], 0, 0 ); p = strtol( &(Settings[i].pIDString)[7], 0, 0 ); /* check if this vendor- and product-ID has already been added, needed * for Plustek devices - here one product-ID is used for more than one * device type... */ il = SANE_FALSE; for( tmp = *devs; tmp ; tmp = tmp->next ) { if( tmp->device_id == p && tmp->vendor_id == v ) { il = SANE_TRUE; break; } } if( il ) { DBG( _DBG_INFO2, "Already in list: 0x%04x-0x%04x\n", v, p ); continue; } /* get the last entry... */ tmp = getLast(*devs); DBG( _DBG_INFO2, "Checking for 0x%04x-0x%04x\n", v, p ); sanei_usb_find_devices( v, p, usb_attach ); if( getLast(*devs) != tmp ) { if( tmp == NULL ) tmp = *devs; else tmp = tmp->next; while( tmp != NULL ) { tmp->vendor_id = v; tmp->device_id = p; tmp = tmp->next; } } } DBG( _DBG_INFO, "Available and supported devices:\n" ); if( *devs == NULL ) DBG( _DBG_INFO, "NONE.\n" ); for( tmp = *devs; tmp; tmp = tmp->next ) { DBG( _DBG_INFO, "Device: >%s< - 0x%04xx0x%04x\n", tmp->dev_name, tmp->vendor_id, tmp->device_id ); } } /** */ static int usbDev_open( Plustek_Device *dev, DevList *devs, int keep_lock ) { char dn[512]; char devStr[50]; int result; int i; int lc; SANE_Int handle; SANE_Byte version; SANE_Word vendor, product; SANE_Bool was_empty; SANE_Status status; DevList *tmp; DBG( _DBG_INFO, "usbDev_open(%s,%s) - %p\n", dev->name, dev->usbId, (void*)devs ); /* preset our internal usb device structure */ memset( &dev->usbDev, 0, sizeof(DeviceDef)); /* devs is NULL, when called from sane_start */ if( devs ) { dn[0] = '\0'; if( !strcmp( dev->name, "auto" )) { /* use the first "unattached"... */ for( tmp = devs; tmp; tmp = tmp->next ) { if( !tmp->attached ) { tmp->attached = SANE_TRUE; strcpy( dn, tmp->dev_name ); break; } } } else { vendor = strtol( &dev->usbId[0], 0, 0 ); product = strtol( &dev->usbId[7], 0, 0 ); /* check the first match... */ for( tmp = devs; tmp; tmp = tmp->next ) { if( tmp->vendor_id == vendor && tmp->device_id == product ) { if( !tmp->attached ) { tmp->attached = SANE_TRUE; strcpy( dn, tmp->dev_name ); break; } } } } if( !dn[0] ) { DBG( _DBG_ERROR, "No supported device found!\n" ); return -1; } status = sanei_access_lock( dn, 5 ); if( SANE_STATUS_GOOD != status ) { DBG( _DBG_ERROR, "sanei_access_lock failed: %d\n", status ); return -1; } status = sanei_usb_open( dn, &handle ); if( SANE_STATUS_GOOD != status ) { DBG( _DBG_ERROR, "sanei_usb_open failed: %s (%d)\n", strerror(errno), errno); sanei_access_unlock( dev->sane.name ); return -1; } /* replace the old devname, so we are able to have multiple * auto-detected devices */ free( dev->name ); dev->name = strdup(dn); dev->sane.name = dev->name; } else { status = sanei_access_lock( dev->sane.name, 5 ); if( SANE_STATUS_GOOD != status ) { DBG( _DBG_ERROR, "sanei_access_lock failed: %d\n", status ); return -1; } status = sanei_usb_open( dev->name, &handle ); if( SANE_STATUS_GOOD != status ) { DBG( _DBG_ERROR, "sanei_usb_open failed: %s (%d)\n", strerror(errno), errno); sanei_access_unlock( dev->sane.name ); return -1; } } was_empty = SANE_FALSE; result = sanei_usb_get_vendor_product( handle, &vendor, &product ); if( SANE_STATUS_GOOD == result ) { sprintf( devStr, "0x%04X-0x%04X", vendor, product ); DBG(_DBG_INFO,"Vendor ID=0x%04X, Product ID=0x%04X\n",vendor,product); if( dev->usbId[0] != '\0' ) { if( 0 != strcmp( dev->usbId, devStr )) { DBG( _DBG_ERROR, "Specified Vendor and Product ID " "doesn't match with the ones\n" "in the config file\n" ); sanei_access_unlock( dev->sane.name ); sanei_usb_close( handle ); return -1; } } else { sprintf( dev->usbId, "0x%04X-0x%04X", vendor, product ); was_empty = SANE_TRUE; } } else { DBG( _DBG_INFO, "Can't get vendor & product ID from driver...\n" ); /* if the ioctl stuff is not supported by the kernel and we have * nothing specified, we have to give up... */ if( dev->usbId[0] == '\0' ) { DBG( _DBG_ERROR, "Cannot autodetect Vendor an Product ID, " "please specify in config file.\n" ); sanei_access_unlock( dev->sane.name ); sanei_usb_close( handle ); return -1; } vendor = strtol( &dev->usbId[0], 0, 0 ); product = strtol( &dev->usbId[7], 0, 0 ); DBG( _DBG_INFO, "... using the specified: " "0x%04X-0x%04X\n", vendor, product ); } /* before accessing the scanner, check if supported! */ if( !usb_IsDeviceInList( dev->usbId )) { DBG( _DBG_ERROR, "Device >%s<, is not supported!\n", dev->usbId ); sanei_access_unlock( dev->sane.name ); sanei_usb_close( handle ); return -1; } status = usbio_DetectLM983x( handle, &version ); if( SANE_STATUS_GOOD != status ) { sanei_usb_close( handle ); sanei_access_unlock( dev->sane.name ); return -1; } if ((version < 3) || (version > 4)) { DBG( _DBG_ERROR, "This is not a LM9831 or LM9832 chip based scanner.\n" ); sanei_usb_close( handle ); sanei_access_unlock( dev->sane.name ); return -1; } /* need to set the handle and the detected chiptype... */ dev->fd = handle; dev->usbDev.HwSetting.chip = (version==3 ? _LM9831:_LM9832); usbio_ResetLM983x( dev ); dev->fd = -1; dev->usbDev.vendor = vendor; dev->usbDev.product = product; DBG( _DBG_INFO, "Detected vendor & product ID: " "0x%04X-0x%04X\n", vendor, product ); /* * Plustek uses the misc IO 1/2 to get the PCB ID * (PCB = printed circuit board), so it's possible to have one * product ID and up to 7 different devices... */ if( 0x07B3 == vendor ) { handle = usb_CheckForPlustekDevice( handle, dev ); if( was_empty ) dev->usbId[0] = '\0'; if( handle >= 0 ) { if( !keep_lock ) sanei_access_unlock( dev->sane.name ); return handle; } } else { /* now roam through the setting list... */ lc = 13; strncpy( devStr, dev->usbId, lc ); devStr[lc] = '\0'; if( 0x400 == vendor ) { if((dev->adj.mov < 0) || (dev->adj.mov > 1)) { DBG(_DBG_INFO, "BearPaw MOV out of range: %d\n", dev->adj.mov); dev->adj.mov = 0; } sprintf( devStr, "%s-%d", dev->usbId, dev->adj.mov ); lc = strlen(devStr); DBG( _DBG_INFO, "BearPaw device: %s (%d)\n", devStr, lc ); } if( was_empty ) dev->usbId[0] = '\0'; /* if we don't use the PCD ID extension... */ for( i = 0; NULL != Settings[i].pIDString; i++ ) { if( 0 == strncmp( Settings[i].pIDString, devStr, lc )) { DBG( _DBG_INFO, "Device description for >%s< found.\n", devStr ); usb_initDev( dev, i, handle, vendor ); if( !keep_lock ) sanei_access_unlock( dev->sane.name ); return handle; } } } sanei_access_unlock( dev->sane.name ); sanei_usb_close( handle ); DBG( _DBG_ERROR, "No matching device found >%s<\n", devStr ); return -1; } /** */ static int usbDev_close( Plustek_Device *dev ) { DBG( _DBG_INFO, "usbDev_close()\n" ); sanei_usb_close( dev->fd ); dev->fd = -1; return 0; } /** convert the stuff */ static int usbDev_getCaps( Plustek_Device *dev ) { DCapsDef *scaps = &dev->usbDev.Caps; DBG( _DBG_INFO, "usbDev_getCaps()\n" ); dev->caps.dwFlag = 0; if(((DEVCAPSFLAG_Positive & scaps->wFlags) && (DEVCAPSFLAG_Negative & scaps->wFlags)) || (DEVCAPSFLAG_TPA & scaps->wFlags)) { dev->caps.dwFlag |= SFLAG_TPA; } dev->caps.wMaxExtentX = scaps->Normal.Size.x; dev->caps.wMaxExtentY = scaps->Normal.Size.y; return 0; } /** usbDev_getCropInfo * function to set the image relevant stuff */ static int usbDev_getCropInfo( Plustek_Device *dev, CropInfo *ci ) { WinInfo size; DBG( _DBG_INFO, "usbDev_getCropInfo()\n" ); usb_GetImageInfo( dev, &ci->ImgDef, &size ); ci->dwPixelsPerLine = size.dwPixels; ci->dwLinesPerArea = size.dwLines; ci->dwBytesPerLine = size.dwBytes; if( ci->ImgDef.dwFlag & SCANFLAG_DWORDBoundary ) ci->dwBytesPerLine = (ci->dwBytesPerLine + 3UL) & 0xfffffffcUL; DBG( _DBG_INFO, "PPL = %lu\n", ci->dwPixelsPerLine ); DBG( _DBG_INFO, "LPA = %lu\n", ci->dwLinesPerArea ); DBG( _DBG_INFO, "BPL = %lu\n", ci->dwBytesPerLine ); return 0; } /** */ static int usbDev_setMap( Plustek_Device *dev, SANE_Word *map, SANE_Word length, SANE_Word channel ) { SANE_Word i, idx; DBG(_DBG_INFO,"Setting map[%u] at 0x%08lx\n",channel,(unsigned long)map); _VAR_NOT_USED( dev ); if( channel == _MAP_MASTER ) { for( i = 0; i < length; i++ ) { a_bMap[i] = (SANE_Byte)map[i]; a_bMap[length +i] = (SANE_Byte)map[i]; a_bMap[(length*2)+i] = (SANE_Byte)map[i]; } } else { idx = 0; if( channel == _MAP_GREEN ) idx = 1; if( channel == _MAP_BLUE ) idx = 2; for( i = 0; i < length; i++ ) { a_bMap[(length * idx)+i] = (SANE_Byte)map[i]; } } return 0; } /** */ static int usbDev_setScanEnv( Plustek_Device *dev, ScanInfo *si ) { ScanDef *scan = &dev->scanning; DCapsDef *caps = &dev->usbDev.Caps; DBG( _DBG_INFO, "usbDev_setScanEnv()\n" ); /* clear all the stuff */ memset( scan, 0, sizeof(ScanDef)); if((si->ImgDef.dwFlag & SCANDEF_Adf) && (si->ImgDef.dwFlag & SCANDEF_ContinuousScan)) { scan->sParam.dMCLK = dMCLK_ADF; } /* Save necessary informations */ scan->fGrayFromColor = 0; /* for some devices and settings, we tweak the physical settings * how to get the image - but not in calibration mode */ if((si->ImgDef.dwFlag & SCANFLAG_Calibration) == 0) { if( si->ImgDef.wDataType == COLOR_256GRAY ) { if( !(si->ImgDef.dwFlag & SCANDEF_Adf) && !usb_IsCISDevice(dev) && (caps->OpticDpi.x == 1200 && si->ImgDef.xyDpi.x <= 300)) { scan->fGrayFromColor = 2; si->ImgDef.wDataType = COLOR_TRUE24; DBG( _DBG_INFO, "* Gray from color set!\n" ); } if( caps->workaroundFlag & _WAF_GRAY_FROM_COLOR ) { DBG( _DBG_INFO, "* Gray(8-bit) from color set!\n" ); scan->fGrayFromColor = 2; si->ImgDef.wDataType = COLOR_TRUE24; } } else if ( si->ImgDef.wDataType == COLOR_GRAY16 ) { if( caps->workaroundFlag & _WAF_GRAY_FROM_COLOR ) { DBG( _DBG_INFO, "* Gray(16-bit) from color set!\n" ); scan->fGrayFromColor = 2; si->ImgDef.wDataType = COLOR_TRUE48; } } else if ( si->ImgDef.wDataType == COLOR_BW ) { if( caps->workaroundFlag & _WAF_BIN_FROM_COLOR ) { DBG( _DBG_INFO, "* Binary from color set!\n" ); scan->fGrayFromColor = 10; si->ImgDef.wDataType = COLOR_TRUE24; } } } usb_SaveImageInfo( dev, &si->ImgDef ); usb_GetImageInfo ( dev, &si->ImgDef, &scan->sParam.Size ); /* mask the flags */ scan->dwFlag = si->ImgDef.dwFlag & (SCANFLAG_bgr | SCANFLAG_BottomUp | SCANFLAG_Calibration | SCANFLAG_DWORDBoundary | SCANFLAG_RightAlign | SCANFLAG_StillModule | SCANDEF_Adf | SCANDEF_ContinuousScan); if( !(SCANDEF_QualityScan & si->ImgDef.dwFlag)) { DBG( _DBG_INFO, "* Preview Mode set!\n" ); } else { DBG( _DBG_INFO, "* Preview Mode NOT set!\n" ); scan->dwFlag |= SCANDEF_QualityScan; } scan->sParam.brightness = si->siBrightness; scan->sParam.contrast = si->siContrast; if( scan->sParam.bBitDepth <= 8 ) scan->dwFlag &= ~SCANFLAG_RightAlign; if( scan->dwFlag & SCANFLAG_DWORDBoundary ) { if( scan->fGrayFromColor && scan->fGrayFromColor < 10) scan->dwBytesLine = (scan->sParam.Size.dwBytes / 3 + 3) & 0xfffffffcUL; else scan->dwBytesLine = (scan->sParam.Size.dwBytes + 3UL) & 0xfffffffcUL; } else { if( scan->fGrayFromColor && scan->fGrayFromColor < 10) scan->dwBytesLine = scan->sParam.Size.dwBytes / 3; else scan->dwBytesLine = scan->sParam.Size.dwBytes; } /* on CIS based devices we have to reconfigure the illumination * settings for the gray modes */ usb_AdjustCISLampSettings( dev, SANE_TRUE ); if( scan->dwFlag & SCANFLAG_BottomUp) scan->lBufAdjust = -(long)scan->dwBytesLine; else scan->lBufAdjust = scan->dwBytesLine; /* LM9831 has a BUG in 16-bit mode, * so we generate pseudo 16-bit data from 8-bit */ if( scan->sParam.bBitDepth > 8 ) { if( _LM9831 == dev->usbDev.HwSetting.chip ) { scan->sParam.bBitDepth = 8; scan->dwFlag |= SCANFLAG_Pseudo48; scan->sParam.Size.dwBytes >>= 1; } } /* Source selection */ if( scan->sParam.bSource == SOURCE_Reflection ) { dev->usbDev.pSource = &caps->Normal; scan->sParam.Origin.x += dev->usbDev.pSource->DataOrigin.x + (u_long)dev->usbDev.Normal.lLeft; scan->sParam.Origin.y += dev->usbDev.pSource->DataOrigin.y + (u_long)dev->usbDev.Normal.lUp; } else if( scan->sParam.bSource == SOURCE_Transparency ) { dev->usbDev.pSource = &caps->Positive; scan->sParam.Origin.x += dev->usbDev.pSource->DataOrigin.x + (u_long)dev->usbDev.Positive.lLeft; scan->sParam.Origin.y += dev->usbDev.pSource->DataOrigin.y + (u_long)dev->usbDev.Positive.lUp; } else if( scan->sParam.bSource == SOURCE_Negative ) { dev->usbDev.pSource = &caps->Negative; scan->sParam.Origin.x += dev->usbDev.pSource->DataOrigin.x + (u_long)dev->usbDev.Negative.lLeft; scan->sParam.Origin.y += dev->usbDev.pSource->DataOrigin.y + (u_long)dev->usbDev.Negative.lUp; } else { dev->usbDev.pSource = &dev->usbDev.Caps.Adf; scan->sParam.Origin.x += dev->usbDev.pSource->DataOrigin.x + (u_long)dev->usbDev.Normal.lLeft; scan->sParam.Origin.y += dev->usbDev.pSource->DataOrigin.y + (u_long)dev->usbDev.Normal.lUp; } if( scan->sParam.bSource == SOURCE_ADF ) { if( scan->dwFlag & SCANDEF_ContinuousScan ) dev->usbDev.fLastScanIsAdf = SANE_TRUE; else dev->usbDev.fLastScanIsAdf = SANE_FALSE; } return 0; } /** */ static int usbDev_stopScan( Plustek_Device *dev ) { DBG( _DBG_INFO, "usbDev_stopScan()\n" ); /* in cancel-mode we first stop the motor */ usb_ScanEnd( dev ); dev->scanning.dwFlag = 0; if( NULL != dev->scanning.pScanBuffer ) { free( dev->scanning.pScanBuffer ); dev->scanning.pScanBuffer = NULL; usb_StartLampTimer( dev ); } return 0; } /** */ static int usbDev_startScan( Plustek_Device *dev ) { ScanDef *scan = &dev->scanning; DBG( _DBG_INFO, "usbDev_startScan()\n" ); /* HEINER: Preview currently not working correctly */ #if 0 if( scan->dwFlag & SCANDEF_QualityScan ) dev->usbDev.a_bRegs[0x0a] = 0; else dev->usbDev.a_bRegs[0x0a] = 1; #endif dev->usbDev.a_bRegs[0x0a] = 0; if((scan->dwFlag & SCANDEF_Adf) && (scan->dwFlag & SCANDEF_ContinuousScan)) { scan->fCalibrated = SANE_TRUE; } else { scan->fCalibrated = SANE_FALSE; } scan->sParam.PhyDpi.x = usb_SetAsicDpiX(dev,scan->sParam.UserDpi.x); scan->sParam.PhyDpi.y = usb_SetAsicDpiY(dev,scan->sParam.UserDpi.y); /* Allocate shading/scan buffer */ scan->pScanBuffer = (u_long*)malloc( _SCANBUF_SIZE ); if( scan->pScanBuffer == NULL ) return _E_ALLOC; scan->dwFlag |= SCANFLAG_StartScan; /* some devices (esp. BearPaw) do need a lamp switch off before * switching it on again. Otherwise it might happen that the lamp * remains off */ if(dev->usbDev.Caps.workaroundFlag & _WAF_LOFF_ON_START) { if (usb_GetLampStatus(dev)) usb_LampOn( dev, SANE_FALSE, SANE_TRUE ); } usb_LampOn( dev, SANE_TRUE, SANE_TRUE ); m_fStart = m_fFirst = SANE_TRUE; m_fAutoPark = (scan->dwFlag&SCANFLAG_StillModule)?SANE_FALSE:SANE_TRUE; if( usb_IsSheetFedDevice(dev)) if(usb_InCalibrationMode(dev)) m_fAutoPark = SANE_FALSE; usb_StopLampTimer( dev ); return 0; } /** * do the reading stuff here... * first we perform the calibration step, and then we read the image * line for line */ static int usbDev_Prepare( Plustek_Device *dev, SANE_Byte *buf ) { int result; SANE_Bool use_alt_cal = SANE_FALSE; ScanDef *scan = &dev->scanning; DCapsDef *scaps = &dev->usbDev.Caps; HWDef *hw = &dev->usbDev.HwSetting; DBG( _DBG_INFO, "usbDev_PrepareScan()\n" ); /* check the current position of the sensor and move it back * to it's home position if necessary... */ if( !usb_IsSheetFedDevice(dev)) usb_SensorStatus( dev ); /* CIS devices need special handling... */ if( usb_IsCISDevice(dev)) { use_alt_cal = SANE_TRUE; } else { if( dev->adj.altCalibrate ) use_alt_cal = SANE_TRUE; } /* for the skip functionality use the "old" calibration functions */ if( dev->usbDev.Caps.workaroundFlag & _WAF_BYPASS_CALIBRATION ) { use_alt_cal = SANE_FALSE; } if( use_alt_cal ) { result = cano_DoCalibration( dev ); } else { result = usb_DoCalibration( dev ); } if( SANE_TRUE != result ) { DBG( _DBG_ERROR, "calibration failed!!!\n" ); return _E_ABORT; } if( dev->adj.cacheCalData ) usb_SaveCalData( dev ); DBG( _DBG_INFO, "calibration done.\n" ); if( usb_InCalibrationMode(dev)) return 0; if( !(scan->dwFlag & SCANFLAG_Scanning)) { usleep( 10 * 1000 ); /* need to preset that here, as we need it during parameter setting */ scan->bLinesToSkip = (u_char)(scan->sParam.PhyDpi.y / 50); scan->dwLinesDiscard = 0; if( scan->sParam.bChannels == 3 ) { scan->dwLinesDiscard = (u_long)scaps->bSensorDistance * scan->sParam.PhyDpi.y / scaps->OpticDpi.y; scan->dwLinesDiscard <<= 1; } if( !usb_SetScanParameters( dev, &scan->sParam )) { DBG( _DBG_ERROR, "Setting Scan Parameters failed!\n" ); return 0; } /* if we bypass the calibration step, we wait on lamp warmup here... */ if( scaps->workaroundFlag & _WAF_BYPASS_CALIBRATION ) { if( !usb_Wait4Warmup( dev )) { DBG( _DBG_INFO, "usbDev_Prepare() - Cancel detected...\n" ); return 0; } } scan->pbScanBufBegin = (u_char*)scan->pScanBuffer; if((dev->caps.dwFlag & SFLAG_ADF) && (scaps->OpticDpi.x == 600)) scan->dwLinesScanBuf = 8; else scan->dwLinesScanBuf = 32; scan->dwBytesScanBuf = scan->dwLinesScanBuf * scan->sParam.Size.dwPhyBytes; scan->dwNumberOfScanBufs = _SCANBUF_SIZE / scan->dwBytesScanBuf; scan->dwLinesPerScanBufs = scan->dwNumberOfScanBufs * scan->dwLinesScanBuf; scan->pbScanBufEnd = scan->pbScanBufBegin + scan->dwLinesPerScanBufs * scan->sParam.Size.dwPhyBytes; scan->dwRedShift = 0; scan->dwBlueShift = 0; scan->dwGreenShift = 0; /* CCD scanner */ if( scan->sParam.bChannels == 3 ) { scan->dwLinesDiscard = (u_long)scaps->bSensorDistance * scan->sParam.PhyDpi.y / scaps->OpticDpi.y; switch( scaps->bSensorOrder ) { case SENSORORDER_rgb: scan->Red.pb = scan->pbScanBufBegin; scan->Green.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes; scan->Blue.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes * 2UL; break; case SENSORORDER_rbg: scan->Red.pb = scan->pbScanBufBegin; scan->Blue.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes; scan->Green.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes * 2UL; break; case SENSORORDER_gbr: scan->Green.pb = scan->pbScanBufBegin; scan->Blue.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes; scan->Red.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes * 2UL; break; case SENSORORDER_grb: scan->Green.pb = scan->pbScanBufBegin; scan->Red.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes; scan->Blue.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes * 2UL; break; case SENSORORDER_brg: scan->Blue.pb = scan->pbScanBufBegin; scan->Red.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes; scan->Green.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes * 2UL; break; case SENSORORDER_bgr: scan->Blue.pb = scan->pbScanBufBegin; scan->Green.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes; scan->Red.pb = scan->pbScanBufBegin + scan->dwLinesDiscard * scan->sParam.Size.dwPhyBytes * 2UL; } /* double it for last channel */ scan->dwLinesDiscard <<= 1; scan->dwGreenShift = (7UL+scan->sParam.bBitDepth) >> 3; scan->Green.pb += scan->dwGreenShift; scan->Blue.pb += (scan->dwGreenShift * 2); if( scan->dwFlag & SCANFLAG_bgr) { u_char *pb = scan->Blue.pb; scan->Blue.pb = scan->Red.pb; scan->Red.pb = pb; scan->dwBlueShift = 0; scan->dwRedShift = scan->dwGreenShift << 1; } else { scan->dwRedShift = 0; scan->dwBlueShift = scan->dwGreenShift << 1; } } else { /* CIS section */ /* this might be a simple gray operation or AFE 1 channel op */ scan->dwLinesDiscard = 0; scan->Green.pb = scan->pbScanBufBegin; if(( scan->sParam.bDataType == SCANDATATYPE_Color ) && ( hw->bReg_0x26 & _ONE_CH_COLOR )) { u_char so; u_long len = scan->sParam.Size.dwPhyBytes / 3; so = scaps->bSensorOrder; if (_WAF_RESET_SO_TO_RGB & scaps->workaroundFlag) { if (scaps->bPCB != 0) { if (scan->sParam.PhyDpi.x > scaps->bPCB) { so = SENSORORDER_rgb; DBG(_DBG_INFO, "* Resetting sensororder to RGB\n"); } } } switch( so ) { case SENSORORDER_rgb: scan->Red.pb = scan->pbScanBufBegin; scan->Green.pb = scan->pbScanBufBegin + len; scan->Blue.pb = scan->pbScanBufBegin + len * 2UL; break; case SENSORORDER_gbr: scan->Green.pb = scan->pbScanBufBegin; scan->Blue.pb = scan->pbScanBufBegin + len; scan->Red.pb = scan->pbScanBufBegin + len * 2UL; break; default: DBG( _DBG_ERROR, "CIS: This bSensorOrder " "is not defined\n" ); return _E_INTERNAL; } } } /* set a funtion to process the RAW data... */ usb_GetImageProc( dev ); if( scan->sParam.bSource == SOURCE_ADF ) scan->dwFlag |= SCANFLAG_StillModule; DBG( _DBG_INFO, "* scan->dwFlag=0x%08lx\n", scan->dwFlag ); if( !usb_ScanBegin( dev, (scan->dwFlag&SCANFLAG_StillModule) ? SANE_FALSE:SANE_TRUE)) { return _E_INTERNAL; } scan->dwFlag |= SCANFLAG_Scanning; if( scan->sParam.UserDpi.y != scan->sParam.PhyDpi.y ) { if( scan->sParam.UserDpi.y < scan->sParam.PhyDpi.y ) { scan->wSumY = scan->sParam.PhyDpi.y - scan->sParam.UserDpi.y; scan->dwFlag |= SCANFLAG_SampleY; DBG( _DBG_INFO, "SampleY Flag set (%u != %u, wSumY=%u)\n", scan->sParam.UserDpi.y, scan->sParam.PhyDpi.y, scan->wSumY ); } } } dumpPicInit( &scan->sParam, "plustek-pic.raw" ); /* here the NT driver uses an extra reading thread... * as the SANE stuff already forked the driver to read data, I think * we should only read data by using a function... */ scan->dwLinesUser = scan->sParam.Size.dwLines; if( !scan->dwLinesUser ) return _E_BUFFER_TOO_SMALL; if( scan->sParam.Size.dwLines < scan->dwLinesUser ) scan->dwLinesUser = scan->sParam.Size.dwLines; scan->sParam.Size.dwLines -= scan->dwLinesUser; if( scan->dwFlag & SCANFLAG_BottomUp ) scan->UserBuf.pb = buf + (scan->dwLinesUser - 1) * scan->dwBytesLine; else scan->UserBuf.pb = buf; DBG(_DBG_INFO,"Reading the data now!\n" ); DBG(_DBG_INFO,"PhyDpi.x = %u\n", scan->sParam.PhyDpi.x ); DBG(_DBG_INFO,"PhyDpi.y = %u\n", scan->sParam.PhyDpi.y ); DBG(_DBG_INFO,"UserDpi.x = %u\n", scan->sParam.UserDpi.x ); DBG(_DBG_INFO,"UserDpi.y = %u\n", scan->sParam.UserDpi.y ); DBG(_DBG_INFO,"NumberOfScanBufs = %lu\n",scan->dwNumberOfScanBufs); DBG(_DBG_INFO,"LinesPerScanBufs = %lu\n",scan->dwLinesPerScanBufs); DBG(_DBG_INFO,"dwPhyBytes = %lu\n",scan->sParam.Size.dwPhyBytes); DBG(_DBG_INFO,"dwPhyPixels = %lu\n",scan->sParam.Size.dwPhyPixels); DBG(_DBG_INFO,"dwTotalBytes = %lu\n",scan->sParam.Size.dwTotalBytes); DBG(_DBG_INFO,"dwPixels = %lu\n",scan->sParam.Size.dwPixels); DBG(_DBG_INFO,"dwBytes = %lu\n",scan->sParam.Size.dwBytes); DBG(_DBG_INFO,"dwValidPixels = %lu\n",scan->sParam.Size.dwValidPixels); DBG(_DBG_INFO,"dwBytesScanBuf = %lu\n",scan->dwBytesScanBuf ); DBG(_DBG_INFO,"dwLinesDiscard = %lu\n",scan->dwLinesDiscard ); DBG(_DBG_INFO,"dwLinesToSkip = %u\n", scan->bLinesToSkip ); DBG(_DBG_INFO,"dwLinesUser = %lu\n",scan->dwLinesUser ); DBG(_DBG_INFO,"dwBytesLine = %lu\n",scan->dwBytesLine ); scan->pbGetDataBuf = scan->pbScanBufBegin; scan->dwLinesToProcess = usb_ReadData( dev ); if( 0 == scan->dwLinesToProcess ) return _E_DATAREAD; return 0; } /** as the name says, read one line... */ static int usbDev_ReadLine( Plustek_Device *dev ) { int wrap; u_long cur; ScanDef *scan = &dev->scanning; HWDef *hw = &dev->usbDev.HwSetting; cur = scan->dwLinesUser; /* we stay within this sample loop until one line has been processed for * the user... */ while( cur == scan->dwLinesUser ) { if( usb_IsEscPressed()) { DBG( _DBG_INFO, "readLine() - Cancel detected...\n" ); return _E_ABORT; } if( !(scan->dwFlag & SCANFLAG_SampleY)) { scan->pfnProcess( dev ); /* Adjust user buffer pointer */ scan->UserBuf.pb += scan->lBufAdjust; scan->dwLinesUser--; } else { scan->wSumY += scan->sParam.UserDpi.y; if( scan->wSumY >= scan->sParam.PhyDpi.y ) { scan->wSumY -= scan->sParam.PhyDpi.y; scan->pfnProcess( dev ); /* Adjust user buffer pointer */ scan->UserBuf.pb += scan->lBufAdjust; scan->dwLinesUser--; } } /* Adjust get buffer pointers */ wrap = 0; if( scan->sParam.bDataType == SCANDATATYPE_Color ) { scan->Red.pb += scan->sParam.Size.dwPhyBytes; if( scan->Red.pb >= scan->pbScanBufEnd ) { scan->Red.pb = scan->pbScanBufBegin + scan->dwRedShift; wrap = 1; } scan->Green.pb += scan->sParam.Size.dwPhyBytes; if( scan->Green.pb >= scan->pbScanBufEnd ) { scan->Green.pb = scan->pbScanBufBegin + scan->dwGreenShift; wrap = 1; } scan->Blue.pb += scan->sParam.Size.dwPhyBytes; if( scan->Blue.pb >= scan->pbScanBufEnd ) { scan->Blue.pb = scan->pbScanBufBegin + scan->dwBlueShift; wrap = 1; } } else { scan->Green.pb += scan->sParam.Size.dwPhyBytes; if( scan->Green.pb >= scan->pbScanBufEnd ) scan->Green.pb = scan->pbScanBufBegin + scan->dwGreenShift; } /* on any wrap-around of the get pointers in one channel mode * we have to reset them */ if( wrap ) { u_long len = scan->sParam.Size.dwPhyBytes; if( hw->bReg_0x26 & _ONE_CH_COLOR ) { if(scan->sParam.bDataType == SCANDATATYPE_Color) { len /= 3; } scan->Red.pb = scan->pbScanBufBegin; scan->Green.pb = scan->pbScanBufBegin + len; scan->Blue.pb = scan->pbScanBufBegin + len * 2UL; } } /* line processed, check if we have to get more... */ scan->dwLinesToProcess--; if( 0 == scan->dwLinesToProcess ) { scan->dwLinesToProcess = usb_ReadData( dev ); if( 0 == scan->dwLinesToProcess ) { if( usb_IsEscPressed()) return _E_ABORT; } } } return 0; } /* END PLUSTEK-USB.C ........................................................*/ sane-backends-1.0.29/backend/abaton.c0000666000000000000000000011500113615534521014176 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1998 David Huggins-Daines, heavily based on the Apple scanner driver (since Abaton scanners are very similar to old Apple scanners), which is (C) 1998 Milon Firikis, which is, in turn, based on the Mustek driver, (C) 1996-7 David Mosberger-Tang. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Abaton flatbed scanners. */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "../include/_stdint.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #define BACKEND_NAME abaton #include "../include/sane/sanei_backend.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #include "../include/sane/sanei_config.h" #define ABATON_CONFIG_FILE "abaton.conf" #include "abaton.h" static const SANE_Device **devlist = 0; static int num_devices; static Abaton_Device *first_dev; static Abaton_Scanner *first_handle; static SANE_String_Const mode_list[5]; static const SANE_String_Const halftone_pattern_list[] = { "spiral", "bayer", 0 }; static const SANE_Range dpi_range = { /* min, max, quant */ 72, 300, 1 }; static const SANE_Range enhance_range = { 1, 255, 1 }; static const SANE_Range x_range = { 0, 8.5 * MM_PER_INCH, 1 }; static const SANE_Range y_range = { 0, 14.0 * MM_PER_INCH, 1 }; #define ERROR_MESSAGE 1 #define USER_MESSAGE 5 #define FLOW_CONTROL 50 #define VARIABLE_CONTROL 70 #define DEBUG_SPECIAL 100 #define IO_MESSAGE 110 #define INNER_LOOP 120 /* SCSI commands that the Abaton scanners understand: */ #define TEST_UNIT_READY 0x00 #define REQUEST_SENSE 0x03 #define INQUIRY 0x12 #define START_STOP 0x1b #define SET_WINDOW 0x24 #define READ_10 0x28 #define WRITE_10 0x2b /* not used, AFAIK */ #define GET_DATA_STATUS 0x34 #define INQ_LEN 0x60 static const uint8_t inquiry[] = { INQUIRY, 0x00, 0x00, 0x00, INQ_LEN, 0x00 }; static const uint8_t test_unit_ready[] = { TEST_UNIT_READY, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* convenience macros */ #define ENABLE(OPTION) s->opt[OPTION].cap &= ~SANE_CAP_INACTIVE #define DISABLE(OPTION) s->opt[OPTION].cap |= SANE_CAP_INACTIVE #define IS_ACTIVE(OPTION) (((s->opt[OPTION].cap) & SANE_CAP_INACTIVE) == 0) /* store an 8-bit-wide value at the location specified by ptr */ #define STORE8(ptr, val) (*((uint8_t *) ptr) = val) /* store a 16-bit-wide value in network (big-endian) byte order */ #define STORE16(ptr, val) \ { \ *((uint8_t *) ptr) = (val >> 8) & 0xff; \ *((uint8_t *) ptr+1) = val & 0xff; \ } /* store a 24-bit-wide value in network (big-endian) byte order */ #define STORE24(ptr, val) \ { \ *((uint8_t *) ptr) = (val >> 16) & 0xff; \ *((uint8_t *) ptr+1) = (val >> 8) & 0xff; \ *((uint8_t *) ptr+2) = val & 0xff; \ } /* store a 32-bit-wide value in network (big-endian) byte order */ #define STORE32(ptr, val) \ { \ *((uint8_t *) ptr) = (val >> 24) & 0xff; \ *((uint8_t *) ptr+1) = (val >> 16) & 0xff; \ *((uint8_t *) ptr+2) = (val >> 8) & 0xff; \ *((uint8_t *) ptr+3) = val & 0xff; \ } /* retrieve a 24-bit-wide big-endian value at ptr */ #define GET24(ptr) \ (*((uint8_t *) ptr) << 16) + \ (*((uint8_t *) ptr+1) << 8) + \ (*((uint8_t *) ptr+2)) static SANE_Status wait_ready (int fd) { #define MAX_WAITING_TIME 60 /* one minute, at most */ struct timeval now, start; SANE_Status status; gettimeofday (&start, 0); while (1) { DBG (USER_MESSAGE, "wait_ready: sending TEST_UNIT_READY\n"); status = sanei_scsi_cmd (fd, test_unit_ready, sizeof (test_unit_ready), 0, 0); switch (status) { default: /* Ignore errors while waiting for scanner to become ready. Some SCSI drivers return EIO while the scanner is returning to the home position. */ DBG (ERROR_MESSAGE, "wait_ready: test unit ready failed (%s)\n", sane_strstatus (status)); /* fall through */ case SANE_STATUS_DEVICE_BUSY: gettimeofday (&now, 0); if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME) { DBG (ERROR_MESSAGE, "wait_ready: timed out after %ld seconds\n", (long) (now.tv_sec - start.tv_sec)); return SANE_STATUS_INVAL; } usleep (100000); /* retry after 100ms */ break; case SANE_STATUS_GOOD: return status; } } return SANE_STATUS_INVAL; } static SANE_Status sense_handler (int scsi_fd, u_char * result, void *arg) { scsi_fd = scsi_fd; /* silence gcc */ arg = arg; /* silence gcc */ switch (result[2] & 0x0F) { case 0: DBG (USER_MESSAGE, "Sense: No sense Error\n"); return SANE_STATUS_GOOD; case 2: DBG (ERROR_MESSAGE, "Sense: Scanner not ready\n"); return SANE_STATUS_DEVICE_BUSY; case 4: DBG (ERROR_MESSAGE, "Sense: Hardware Error. Read more...\n"); return SANE_STATUS_IO_ERROR; case 5: DBG (ERROR_MESSAGE, "Sense: Illegal request\n"); return SANE_STATUS_UNSUPPORTED; case 6: DBG (ERROR_MESSAGE, "Sense: Unit Attention (Wait until scanner " "boots)\n"); return SANE_STATUS_DEVICE_BUSY; case 9: DBG (ERROR_MESSAGE, "Sense: Vendor Unique. Read more...\n"); return SANE_STATUS_IO_ERROR; default: DBG (ERROR_MESSAGE, "Sense: Unknown Sense Key. Read more...\n"); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } static SANE_Status request_sense (Abaton_Scanner * s) { uint8_t cmd[6]; uint8_t result[22]; size_t size = sizeof (result); SANE_Status status; memset (cmd, 0, sizeof (cmd)); memset (result, 0, sizeof (result)); cmd[0] = REQUEST_SENSE; STORE8 (cmd + 4, sizeof (result)); sanei_scsi_cmd (s->fd, cmd, sizeof (cmd), result, &size); if (result[7] != 14) { DBG (ERROR_MESSAGE, "Additional Length %u\n", (unsigned int) result[7]); status = SANE_STATUS_IO_ERROR; } status = sense_handler (s->fd, result, NULL); if (status == SANE_STATUS_IO_ERROR) { /* Since I haven't figured out the vendor unique error codes on this thing, I'll just handle the normal ones for now */ if (result[18] & 0x80) DBG (ERROR_MESSAGE, "Sense: Dim Light (output of lamp below 70%%).\n"); if (result[18] & 0x40) DBG (ERROR_MESSAGE, "Sense: No Light at all.\n"); if (result[18] & 0x20) DBG (ERROR_MESSAGE, "Sense: No Home.\n"); if (result[18] & 0x10) DBG (ERROR_MESSAGE, "Sense: No Limit. Tried to scan out of range.\n"); } DBG (USER_MESSAGE, "Sense: Optical gain %u.\n", (unsigned int) result[20]); return status; } static SANE_Status set_window (Abaton_Scanner * s) { uint8_t cmd[10 + 40]; uint8_t *window = cmd + 10 + 8; int invert; memset (cmd, 0, sizeof (cmd)); cmd[0] = SET_WINDOW; cmd[8] = 40; /* Just like the Apple scanners, we put the resolution here */ STORE16 (window + 2, s->val[OPT_X_RESOLUTION].w); STORE16 (window + 4, s->val[OPT_Y_RESOLUTION].w); /* Unlike Apple scanners, these are pixel values */ STORE16 (window + 6, s->ULx); STORE16 (window + 8, s->ULy); STORE16 (window + 10, s->Width); STORE16 (window + 12, s->Height); STORE8 (window + 14, s->val[OPT_BRIGHTNESS].w); STORE8 (window + 15, s->val[OPT_THRESHOLD].w); STORE8 (window + 16, s->val[OPT_CONTRAST].w); invert = s->val[OPT_NEGATIVE].w; if (!strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART)) { STORE8 (window + 17, 0); } else if (!strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_HALFTONE)) { STORE8 (window + 17, 1); } else if (!strcmp (s->val[OPT_MODE].s, "Gray256") || !strcmp (s->val[OPT_MODE].s, "Gray16")) { STORE8 (window + 17, 2); invert = !s->val[OPT_NEGATIVE].w; } else { DBG (ERROR_MESSAGE, "Can't match mode %s\n", s->val[OPT_MODE].s); return SANE_STATUS_INVAL; } STORE8 (window + 18, s->bpp); if (!strcmp (s->val[OPT_HALFTONE_PATTERN].s, "spiral")) { STORE8 (window + 20, 0); } else if (!strcmp (s->val[OPT_HALFTONE_PATTERN].s, "bayer")) { STORE8 (window + 20, 1); } else { DBG (ERROR_MESSAGE, "Can't match haftone pattern %s\n", s->val[OPT_HALFTONE_PATTERN].s); return SANE_STATUS_INVAL; } /* We have to invert these ones for some reason, so why not let the scanner do it for us... */ STORE8 (window + 21, invert ? 0x80 : 0); STORE16 (window + 22, (s->val[OPT_MIRROR].w != 0)); return sanei_scsi_cmd (s->fd, cmd, sizeof (cmd), 0, 0); } static SANE_Status start_scan (Abaton_Scanner * s) { SANE_Status status; uint8_t start[7]; memset (start, 0, sizeof (start)); start[0] = START_STOP; start[4] = 1; status = sanei_scsi_cmd (s->fd, start, sizeof (start), 0, 0); return status; } static SANE_Status attach (const char *devname, Abaton_Device ** devp, int may_wait) { char result[INQ_LEN]; const char *model_name = result + 44; int fd, abaton_scanner; Abaton_Device *dev; SANE_Status status; size_t size; for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devname) == 0) { if (devp) *devp = dev; return SANE_STATUS_GOOD; } DBG (USER_MESSAGE, "attach: opening %s\n", devname); status = sanei_scsi_open (devname, &fd, sense_handler, 0); if (status != SANE_STATUS_GOOD) { DBG (ERROR_MESSAGE, "attach: open failed (%s)\n", sane_strstatus (status)); return SANE_STATUS_INVAL; } if (may_wait) wait_ready (fd); DBG (USER_MESSAGE, "attach: sending INQUIRY\n"); size = sizeof (result); status = sanei_scsi_cmd (fd, inquiry, sizeof (inquiry), result, &size); if (status != SANE_STATUS_GOOD) { DBG (ERROR_MESSAGE, "attach: inquiry failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (fd); return status; } status = wait_ready (fd); sanei_scsi_close (fd); if (status != SANE_STATUS_GOOD) return status; /* check that we've got an Abaton */ abaton_scanner = (strncmp (result + 8, "ABATON ", 8) == 0); model_name = result + 16; /* make sure it's a scanner ;-) */ abaton_scanner = abaton_scanner && (result[0] == 0x06); if (!abaton_scanner) { DBG (ERROR_MESSAGE, "attach: device doesn't look like an Abaton scanner " "(result[0]=%#02x)\n", result[0]); return SANE_STATUS_INVAL; } dev = malloc (sizeof (*dev)); if (!dev) return SANE_STATUS_NO_MEM; memset (dev, 0, sizeof (*dev)); dev->sane.name = strdup (devname); dev->sane.vendor = "Abaton"; dev->sane.model = strndup (model_name, 16); dev->sane.type = "flatbed scanner"; if (!strncmp (model_name, "SCAN 300/GS", 11)) { dev->ScannerModel = ABATON_300GS; } else if (!strncmp (model_name, "SCAN 300/S", 10)) { dev->ScannerModel = ABATON_300S; } DBG (USER_MESSAGE, "attach: found Abaton scanner model %s (%s)\n", dev->sane.model, dev->sane.type); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; return SANE_STATUS_GOOD; } static SANE_Status attach_one (const char *devname) { return attach (devname, 0, SANE_FALSE); } static SANE_Status calc_parameters (Abaton_Scanner * s) { SANE_String val = s->val[OPT_MODE].s; SANE_Status status = SANE_STATUS_GOOD; SANE_Int dpix = s->val[OPT_X_RESOLUTION].w; SANE_Int dpiy = s->val[OPT_Y_RESOLUTION].w; double ulx, uly, width, height; DBG (FLOW_CONTROL, "Entering calc_parameters\n"); if (!strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) || !strcmp (val, SANE_VALUE_SCAN_MODE_HALFTONE)) { s->params.depth = 1; s->bpp = 1; } else if (!strcmp (val, "Gray16")) { s->params.depth = 8; s->bpp = 4; } else if (!strcmp (val, "Gray256")) { s->params.depth = 8; s->bpp = 8; } else { DBG (ERROR_MESSAGE, "calc_parameters: Invalid mode %s\n", (char *) val); status = SANE_STATUS_INVAL; } /* in inches */ ulx = (double) s->val[OPT_TL_X].w / MM_PER_INCH; uly = (double) s->val[OPT_TL_Y].w / MM_PER_INCH; width = (double) s->val[OPT_BR_X].w / MM_PER_INCH - ulx; height = (double) s->val[OPT_BR_Y].w / MM_PER_INCH - uly; DBG (VARIABLE_CONTROL, "(inches) ulx: %f, uly: %f, width: %f, height: %f\n", ulx, uly, width, height); /* turn 'em into pixel quantities */ s->ULx = ulx * dpix; s->ULy = uly * dpiy; s->Width = width * dpix; s->Height = height * dpiy; DBG (VARIABLE_CONTROL, "(pixels) ulx: %d, uly: %d, width: %d, height: %d\n", s->ULx, s->ULy, s->Width, s->Height); /* floor width to a byte multiple */ if ((s->Width * s->bpp) % 8) { s->Width /= 8; s->Width *= 8; DBG (VARIABLE_CONTROL, "Adapting to width %d\n", s->Width); } s->params.pixels_per_line = s->Width; s->params.lines = s->Height; s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8; DBG (VARIABLE_CONTROL, "format=%d\n", s->params.format); DBG (VARIABLE_CONTROL, "last_frame=%d\n", s->params.last_frame); DBG (VARIABLE_CONTROL, "lines=%d\n", s->params.lines); DBG (VARIABLE_CONTROL, "depth=%d (%d)\n", s->params.depth, s->bpp); DBG (VARIABLE_CONTROL, "pixels_per_line=%d\n", s->params.pixels_per_line); DBG (VARIABLE_CONTROL, "bytes_per_line=%d\n", s->params.bytes_per_line); DBG (VARIABLE_CONTROL, "Pixels %dx%dx%d\n", s->params.pixels_per_line, s->params.lines, 1 << s->params.depth); DBG (FLOW_CONTROL, "Leaving calc_parameters\n"); return status; } static SANE_Status mode_update (SANE_Handle handle, char *val) { Abaton_Scanner *s = handle; if (!strcmp (val, SANE_VALUE_SCAN_MODE_LINEART)) { DISABLE (OPT_BRIGHTNESS); DISABLE (OPT_CONTRAST); ENABLE (OPT_THRESHOLD); DISABLE (OPT_HALFTONE_PATTERN); } else if (!strcmp (val, SANE_VALUE_SCAN_MODE_HALFTONE)) { ENABLE (OPT_BRIGHTNESS); ENABLE (OPT_CONTRAST); DISABLE (OPT_THRESHOLD); ENABLE (OPT_HALFTONE_PATTERN); } else if (!strcmp (val, "Gray16") || !strcmp (val, "Gray256")) { ENABLE (OPT_BRIGHTNESS); ENABLE (OPT_CONTRAST); DISABLE (OPT_THRESHOLD); DISABLE (OPT_HALFTONE_PATTERN); } /* End of Gray */ else { DBG (ERROR_MESSAGE, "Invalid mode %s\n", (char *) val); return SANE_STATUS_INVAL; } calc_parameters (s); return SANE_STATUS_GOOD; } /* find the longest of a list of strings */ static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } static SANE_Status init_options (Abaton_Scanner * s) { int i; memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = "Scan Mode"; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; mode_list[0]=SANE_VALUE_SCAN_MODE_LINEART; switch (s->hw->ScannerModel) { case ABATON_300GS: mode_list[1]=SANE_VALUE_SCAN_MODE_HALFTONE; mode_list[2]="Gray16"; mode_list[3]="Gray256"; mode_list[4]=NULL; break; case ABATON_300S: default: mode_list[1]=NULL; break; } /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].s = strdup (mode_list[0]); /* resolution - horizontal */ s->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_X_RESOLUTION; s->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_X_RESOLUTION; s->opt[OPT_X_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_X_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_X_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_X_RESOLUTION].constraint.range = &dpi_range; s->val[OPT_X_RESOLUTION].w = 150; /* resolution - vertical */ s->opt[OPT_Y_RESOLUTION].name = SANE_NAME_SCAN_Y_RESOLUTION; s->opt[OPT_Y_RESOLUTION].title = SANE_TITLE_SCAN_Y_RESOLUTION; s->opt[OPT_Y_RESOLUTION].desc = SANE_DESC_SCAN_Y_RESOLUTION; s->opt[OPT_Y_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_Y_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_Y_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_Y_RESOLUTION].constraint.range = &dpi_range; s->val[OPT_Y_RESOLUTION].w = 150; /* constrain resolutions */ s->opt[OPT_RESOLUTION_BIND].name = SANE_NAME_RESOLUTION_BIND; s->opt[OPT_RESOLUTION_BIND].title = SANE_TITLE_RESOLUTION_BIND; s->opt[OPT_RESOLUTION_BIND].desc = SANE_DESC_RESOLUTION_BIND; s->opt[OPT_RESOLUTION_BIND].type = SANE_TYPE_BOOL; s->opt[OPT_RESOLUTION_BIND].unit = SANE_UNIT_NONE; s->opt[OPT_RESOLUTION_BIND].constraint_type = SANE_CONSTRAINT_NONE; /* until I fix it */ s->val[OPT_RESOLUTION_BIND].w = SANE_FALSE; /* preview mode */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_PREVIEW].w = SANE_FALSE; /* halftone pattern */ s->opt[OPT_HALFTONE_PATTERN].name = SANE_NAME_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].title = SANE_TITLE_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].desc = SANE_DESC_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].size = max_string_size (halftone_pattern_list); s->opt[OPT_HALFTONE_PATTERN].type = SANE_TYPE_STRING; s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_PATTERN].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_HALFTONE_PATTERN].constraint.string_list = halftone_pattern_list; s->val[OPT_HALFTONE_PATTERN].s = strdup (halftone_pattern_list[0]); /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_INT; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &x_range; s->val[OPT_TL_X].w = 0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_INT; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &y_range; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_INT; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &x_range; s->val[OPT_BR_X].w = x_range.max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_INT; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &y_range; s->val[OPT_BR_Y].w = y_range.max; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &enhance_range; s->val[OPT_BRIGHTNESS].w = 150; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_INT; s->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE; s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &enhance_range; s->val[OPT_CONTRAST].w = 150; /* threshold */ s->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; s->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; s->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; s->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &enhance_range; s->val[OPT_THRESHOLD].w = 150; /* negative */ s->opt[OPT_NEGATIVE].name = SANE_NAME_NEGATIVE; s->opt[OPT_NEGATIVE].title = SANE_TITLE_NEGATIVE; s->opt[OPT_NEGATIVE].desc = SANE_DESC_NEGATIVE; s->opt[OPT_NEGATIVE].type = SANE_TYPE_BOOL; s->opt[OPT_NEGATIVE].unit = SANE_UNIT_NONE; s->opt[OPT_NEGATIVE].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_NEGATIVE].w = SANE_FALSE; /* mirror-image */ s->opt[OPT_MIRROR].name = "mirror"; s->opt[OPT_MIRROR].title = "Mirror Image"; s->opt[OPT_MIRROR].desc = "Scan in mirror-image"; s->opt[OPT_MIRROR].type = SANE_TYPE_BOOL; s->opt[OPT_MIRROR].unit = SANE_UNIT_NONE; s->opt[OPT_MIRROR].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_MIRROR].w = SANE_FALSE; return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char dev_name[PATH_MAX]; size_t len; FILE *fp; authorize = authorize; /* silence gcc */ DBG_INIT (); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (ABATON_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ attach ("/dev/scanner", 0, SANE_FALSE); return SANE_STATUS_GOOD; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ if (strncmp (dev_name, "option", 6) == 0 && isspace (dev_name[6])) { const char *str = dev_name + 7; while (isspace (*str)) ++str; continue; } sanei_config_attach_matching_devices (dev_name, attach_one); } fclose (fp); return SANE_STATUS_GOOD; } void sane_exit (void) { Abaton_Device *dev, *next; for (dev = first_dev; dev; dev = next) { next = dev->next; free ((void *) dev->sane.name); free ((void *) dev->sane.model); free (dev); } if (devlist) free (devlist); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Abaton_Device *dev; int i; local_only = local_only; /* silence gcc */ if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Abaton_Device *dev; SANE_Status status; Abaton_Scanner *s; if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; if (!dev) { status = attach (devicename, &dev, SANE_TRUE); if (status != SANE_STATUS_GOOD) return status; } } else /* empty devicname -> use first device */ dev = first_dev; if (!dev) return SANE_STATUS_INVAL; s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->fd = -1; s->hw = dev; init_options (s); /* set up some universal parameters */ s->params.last_frame = SANE_TRUE; s->params.format = SANE_FRAME_GRAY; /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Abaton_Scanner *prev, *s; /* remove handle from list of open handles: */ prev = 0; for (s = first_handle; s; s = s->next) { if (s == (Abaton_Scanner *) handle) break; prev = s; } if (!s) { DBG (ERROR_MESSAGE, "close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (prev) prev->next = s->next; else first_handle = s->next; free (handle); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Abaton_Scanner *s = handle; if ((unsigned) option >= NUM_OPTIONS) return NULL; return s->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Abaton_Scanner *s = handle; SANE_Status status; SANE_Word cap; if (option < 0 || option >= NUM_OPTIONS) return SANE_STATUS_INVAL; if (info != NULL) *info = 0; if (s->scanning) return SANE_STATUS_DEVICE_BUSY; cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) return SANE_STATUS_INVAL; if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_NUM_OPTS: case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_RESOLUTION_BIND: case OPT_PREVIEW: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_THRESHOLD: case OPT_NEGATIVE: case OPT_MIRROR: *(SANE_Word *) val = s->val[option].w; return SANE_STATUS_GOOD; /* string options */ case OPT_MODE: case OPT_HALFTONE_PATTERN: status = sanei_constrain_value (s->opt + option, s->val[option].s, info); strcpy (val, s->val[option].s); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) return SANE_STATUS_INVAL; status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { /* resolution should be uniform for previews, or when the user says so. */ case OPT_PREVIEW: s->val[option].w = *(SANE_Word *) val; if (*(SANE_Word *) val) { s->val[OPT_Y_RESOLUTION].w = s->val[OPT_X_RESOLUTION].w; if (info) *info |= SANE_INFO_RELOAD_OPTIONS; } /* always recalculate! */ calc_parameters (s); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_RESOLUTION_BIND: s->val[option].w = *(SANE_Word *) val; if (*(SANE_Word *) val) { s->val[OPT_Y_RESOLUTION].w = s->val[OPT_X_RESOLUTION].w; calc_parameters (s); if (info) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_X_RESOLUTION: if (s->val[OPT_PREVIEW].w || s->val[OPT_RESOLUTION_BIND].w) { s->val[OPT_Y_RESOLUTION].w = *(SANE_Word *)val; if (info) *info |= SANE_INFO_RELOAD_OPTIONS; } s->val[option].w = *(SANE_Word *) val; calc_parameters (s); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_Y_RESOLUTION: if (s->val[OPT_PREVIEW].w || s->val[OPT_RESOLUTION_BIND].w) { s->val[OPT_X_RESOLUTION].w = *(SANE_Word *)val; if (info) *info |= SANE_INFO_RELOAD_OPTIONS; } s->val[option].w = *(SANE_Word *) val; calc_parameters (s); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; /* these ones don't have crazy side effects */ case OPT_TL_X: case OPT_TL_Y: case OPT_BR_Y: s->val[option].w = *(SANE_Word *) val; calc_parameters (s); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; /* this one is somewhat imprecise */ case OPT_BR_X: s->val[option].w = *(SANE_Word *) val; calc_parameters (s); if (info) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_INEXACT; return SANE_STATUS_GOOD; /* no side-effects whatsoever */ case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_THRESHOLD: case OPT_NEGATIVE: case OPT_MIRROR: s->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* string options */ case OPT_HALFTONE_PATTERN: if (info) *info |= SANE_INFO_RELOAD_OPTIONS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); return SANE_STATUS_GOOD; case OPT_MODE: status = mode_update (s, val); if (status != SANE_STATUS_GOOD) return status; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; } /* End of switch */ } /* End of SET_VALUE */ return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Abaton_Scanner *s = handle; DBG (FLOW_CONTROL, "Entering sane_get_parameters\n"); calc_parameters (s); if (params) *params = s->params; return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Abaton_Scanner *s = handle; SANE_Status status; /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ calc_parameters (s); if (s->fd < 0) { /* this is the first (and maybe only) pass... */ status = sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, 0); if (status != SANE_STATUS_GOOD) { DBG (ERROR_MESSAGE, "open: open of %s failed: %s\n", s->hw->sane.name, sane_strstatus (status)); return status; } } status = wait_ready (s->fd); if (status != SANE_STATUS_GOOD) { DBG (ERROR_MESSAGE, "open: wait_ready() failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = request_sense (s); if (status != SANE_STATUS_GOOD) { DBG (ERROR_MESSAGE, "sane_start: request_sense revealed error: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = set_window (s); if (status != SANE_STATUS_GOOD) { DBG (ERROR_MESSAGE, "open: set scan area command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } s->scanning = SANE_TRUE; s->AbortedByUser = SANE_FALSE; status = start_scan (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; return SANE_STATUS_GOOD; stop_scanner_and_return: s->scanning = SANE_FALSE; s->AbortedByUser = SANE_FALSE; return status; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { Abaton_Scanner *s = handle; SANE_Status status; uint8_t get_data_status[10]; uint8_t read[10]; uint8_t result[12]; size_t size; SANE_Int data_av = 0; SANE_Int data_length = 0; SANE_Int offset = 0; SANE_Int rread = 0; SANE_Bool Pseudo8bit = SANE_FALSE; *len = 0; /* don't let bogus read requests reach the scanner */ /* this is a sub-optimal way of doing this, I'm sure */ if (!s->scanning) return SANE_STATUS_EOF; if (!strcmp (s->val[OPT_MODE].s, "Gray16")) Pseudo8bit = SANE_TRUE; memset (get_data_status, 0, sizeof (get_data_status)); get_data_status[0] = GET_DATA_STATUS; /* This means "block" for Apple scanners, it seems to be the same for Abaton. The scanner will do non-blocking I/O, but I don't want to go there right now. */ get_data_status[1] = 1; STORE8 (get_data_status + 8, sizeof (result)); memset (read, 0, sizeof (read)); read[0] = READ_10; do { size = sizeof (result); /* this isn't necessary */ /* memset (result, 0, size); */ status = sanei_scsi_cmd (s->fd, get_data_status, sizeof (get_data_status), result, &size); if (status != SANE_STATUS_GOOD) return status; if (!size) { DBG (ERROR_MESSAGE, "sane_read: cannot get_data_status.\n"); return SANE_STATUS_IO_ERROR; } /* this is not an accurate name, but oh well... */ data_length = GET24 (result); data_av = GET24 (result + 9); /* don't check result[3] here, because that screws things up somewhat */ if (data_length) { DBG (IO_MESSAGE, "sane_read: (status) Available in scanner buffer %u.\n", data_av); if (Pseudo8bit) { if ((data_av * 2) + offset > max_len) rread = (max_len - offset) / 2; else rread = data_av; } else if (data_av + offset > max_len) { rread = max_len - offset; } else { rread = data_av; } DBG (IO_MESSAGE, "sane_read: (action) Actual read request for %u bytes.\n", rread); size = rread; STORE24 (read + 6, rread); status = sanei_scsi_cmd (s->fd, read, sizeof (read), buf + offset, &size); if (Pseudo8bit) { SANE_Int byte; SANE_Int pos = offset + (rread << 1) - 1; SANE_Byte B; for (byte = offset + rread - 1; byte >= offset; byte--) { B = buf[byte]; /* don't invert these! */ buf[pos--] = B << 4; /* low (right) nibble */ buf[pos--] = B & 0xF0; /* high (left) nibble */ } /* putting an end to bitop abuse here */ offset += size * 2; } else offset += size; DBG (IO_MESSAGE, "sane_read: Buffer %u of %u full %g%%\n", offset, max_len, (double) (offset * 100. / max_len)); } } while (offset < max_len && data_length != 0 && !s->AbortedByUser); if (s->AbortedByUser) { s->scanning = SANE_FALSE; if (status != SANE_STATUS_GOOD) { DBG (ERROR_MESSAGE, "sane_read: request_sense revealed error: %s\n", sane_strstatus (status)); return status; } status = sanei_scsi_cmd (s->fd, test_unit_ready, sizeof (test_unit_ready), 0, 0); if (status != SANE_STATUS_GOOD || status != SANE_STATUS_INVAL) return status; return SANE_STATUS_CANCELLED; } if (!data_length) { s->scanning = SANE_FALSE; DBG (IO_MESSAGE, "sane_read: (status) No more data..."); if (!offset) { /* this shouldn't happen */ *len = 0; DBG (IO_MESSAGE, "EOF\n"); return SANE_STATUS_EOF; } else { *len = offset; DBG (IO_MESSAGE, "GOOD\n"); return SANE_STATUS_GOOD; } } DBG (FLOW_CONTROL, "sane_read: Normal Exiting, Aborted=%u, data_length=%u\n", s->AbortedByUser, data_av); *len = offset; return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Abaton_Scanner *s = handle; if (s->scanning) { if (s->AbortedByUser) { DBG (FLOW_CONTROL, "sane_cancel: Already Aborted. Please Wait...\n"); } else { s->scanning = SANE_FALSE; s->AbortedByUser = SANE_TRUE; DBG (FLOW_CONTROL, "sane_cancel: Signal Caught! Aborting...\n"); } } else { if (s->AbortedByUser) { DBG (FLOW_CONTROL, "sane_cancel: Scan has not been initiated yet." "we probably received a signal while writing data.\n"); s->AbortedByUser = SANE_FALSE; } else { DBG (FLOW_CONTROL, "sane_cancel: Scan has not been initiated " "yet (or it's over).\n"); } } return; } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { handle = handle; /* silence gcc */ non_blocking = non_blocking; /* silence gcc */ DBG (FLOW_CONTROL, "sane_set_io_mode: Don't call me please. " "Unimplemented function\n"); return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { handle = handle; /* silence gcc */ fd = fd; /* silence gcc */ DBG (FLOW_CONTROL, "sane_get_select_fd: Don't call me please. " "Unimplemented function\n"); return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/magicolor.h0000666000000000000000000001223613615534521014721 00000000000000/* * magicolor.h - SANE library for Magicolor scanners. * * (C) 2010 Reinhold Kainhofer * * Based on the epson2 sane backend: * Based on Kazuhiro Sasayama previous * Work on epson.[ch] file from the SANE package. * Please see those files for original copyrights. * Copyright (C) 2006 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. */ #ifndef magicolor_h #define magicolor_h #undef BACKEND_NAME #define BACKEND_NAME magicolor #define DEBUG_NOT_STATIC #include #ifdef HAVE_STDDEF_H #include #endif #ifdef HAVE_STDLIB_H #include #endif #ifdef NEED_SYS_TYPES_H #include #endif #include #include "../include/sane/sane.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" /* Silence the compiler for unused arguments */ #define NOT_USED(x) ( (void)(x) ) #define MAGICOLOR_CONFIG_FILE "magicolor.conf" #define NUM_OF_HEX_ELEMENTS (16) /* number of hex numbers per line for data dump */ #define DEVICE_NAME_LEN (16) /* length of device name in extended status */ /* misc constants */ #define NET 0x04 #define CMD 0x03 /* status values */ #define STATUS_READY 0x00 /* scanner is ready */ #define STATUS_ADF_JAM 0x01 /* ADF paper jam */ #define STATUS_OPEN 0x02 /* scanner is open */ #define STATUS_NOT_READY 0x03 /* scanner is in use on another interface */ #define ADF_LOADED 0x01 /* ADF is loaded */ #define MAGICOLOR_CAP_DEFAULT 0 #define MAGICOLOR_LEVEL_1690mf 0 #define MAGICOLOR_LEVEL_DEFAULT MAGICOLOR_LEVEL_1690mf #define MAGICOLOR_LEVEL_NET MAGICOLOR_LEVEL_1690mf /* Structure holding the command set for a device */ struct MagicolorCmd { const char *level; unsigned char scanner_cmd; unsigned char start_scanning; unsigned char request_error; unsigned char stop_scanning; unsigned char request_scan_parameters; unsigned char set_scan_parameters; unsigned char request_status; unsigned char request_data; unsigned char unknown1; unsigned char unknown2; unsigned char net_wrapper_cmd; unsigned char net_welcome; unsigned char net_lock; unsigned char net_lock_ack; unsigned char net_unlock; }; /* Structure holding the device capabilities */ struct MagicolorCap { unsigned int id; const char *cmds; const char *model; const char *OID; SANE_Int out_ep, in_ep; /* USB bulk out/in endpoints */ SANE_Int optical_res; /* optical resolution */ SANE_Range dpi_range; /* max/min resolutions */ SANE_Int *res_list; /* list of resolutions */ SANE_Int res_list_size; /* number of entries in this list */ SANE_Int maxDepth; /* max. color depth */ SANE_Word *depth_list; /* list of color depths */ SANE_Range brightness; /* brightness range */ SANE_Range fbf_x_range; /* flattbed x range */ SANE_Range fbf_y_range; /* flattbed y range */ SANE_Bool ADF; /* ADF is installed */ SANE_Bool adf_duplex; /* does the ADF handle duplex scanning */ SANE_Range adf_x_range; /* autom. document feeder x range */ SANE_Range adf_y_range; /* autom. document feeder y range */ }; enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_BIT_DEPTH, OPT_BRIGHTNESS, OPT_RESOLUTION, OPT_PREVIEW, OPT_SOURCE, OPT_ADF_MODE, OPT_GEOMETRY_GROUP, OPT_TL_X, OPT_TL_Y, OPT_BR_X, OPT_BR_Y, NUM_OPTIONS }; typedef enum { /* hardware connection to the scanner */ SANE_MAGICOLOR_NODEV, /* default, no HW specified yet */ SANE_MAGICOLOR_USB, /* USB interface */ SANE_MAGICOLOR_NET /* network interface */ } Magicolor_Connection_Type; /* Structure holding the hardware description */ struct Magicolor_Device { struct Magicolor_Device *next; int missing; char *name; char *model; SANE_Device sane; SANE_Range *x_range; /* x range w/out extension */ SANE_Range *y_range; /* y range w/out extension */ Magicolor_Connection_Type connection; struct MagicolorCmd *cmd; struct MagicolorCap *cap; }; typedef struct Magicolor_Device Magicolor_Device; /* Structure holding an instance of a scanner (i.e. scanner has been opened) */ struct Magicolor_Scanner { struct Magicolor_Scanner *next; struct Magicolor_Device *hw; int fd; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Parameters params; SANE_Bool eof; SANE_Byte *buf, *end, *ptr; SANE_Bool canceling; SANE_Int left, top; SANE_Int width, height; /* image block data */ SANE_Int data_len; SANE_Int block_len; SANE_Int last_len; SANE_Int blocks; SANE_Int counter; /* store how many bytes of the current pixel line we have already * read in previous read attempts. Since each line will be padded * to multiples of 512 bytes, this is needed to know which bytes * to ignore */ SANE_Int bytes_read_in_line; SANE_Byte *line_buffer; /* How many bytes are scanned per line (multiple of 512 bytes */ SANE_Int scan_bytes_per_line; }; typedef struct Magicolor_Scanner Magicolor_Scanner; struct mode_param { int flags; int colors; int depth; }; enum { MODE_BINARY, MODE_GRAY, MODE_COLOR }; #endif sane-backends-1.0.29/backend/mustek_pp.conf.in0000666000000000000000000000733113615534521016057 00000000000000# For documentation see sane-mustek_pp(5) # Global options: # =============== # # option no_epp # # Disable parallel port mode EPP: works around a known bug in # the Linux parport code. Enable this option, if the backend # hangs when trying to access the parallel port in EPP mode: # # # SANE_DEBUG_SANEI_PA4S2=128 scanimage -L # ... # hangs here -> [sanei_pa4s2] sanei_pa4s2_readbyte: read in EPP mode # # Scanner definition template: # ============================ # # scanner # option ? # option ? # ... # # where: # # is an arbitrary name for the scanner (eg. Mustek-1200CP) # # is the parallel port to which the scanner is connected # Possible values are 0x378, 0x278, and 0x3bc. For Linux, the # mapping between ports an numbers is different for kernel # version 2.2 and 2.4. Port 0x378 corresponds to lp0 on 2.4 kernel. # If you are using libieee1284, you can as well use parport0, etc.. # If you use the magic value * the port is probed. # # is an identification of the scanner type. # Possible values are: # - cis600 (for Mustek 600CP & OEM versions), # - cis1200 (for Mustek 1200CP & OEM versions), # - cis1200+ (for Mustek 1200CP+ & OEM versions), # - ccd300 (for Mustek 600 III EPP & OEM versions) # - ... more types will be added in the future # # is a name of an option, and an optional value # for the option. # Currently available options for *CIS* type scanners are: # - top_adjust : # Vertical adjustment of origin, in millimeter. # Values between -5.0 and +5.0 mm are possible # (floating point). # Default: 0.0 # - slow_skip: # Boolean option. Disables fast skipping to the start # of the scan region. May be necessary in case fast # skipping results in inaccuracies. # Default: fast skipping enabled # - bw : # Black/white discrimination value for lineart scans. # Pixel values below that value are considered black, # others are considered white. Range: 0-255. # Default: 127 # # Currently available options for *CCD* type scanners are: # - wait_bank # usecs to wait for a bank change. Positive integer # values are possible. You shouldn't mess with this # parameter. # Default: 700 # - bw # Black/white discrimination value for lineart scans. # Pixel values below that value are considered black, # others are considered white. Range: 0-255. # Default: 127 # - top # Scanlines to skip to the top area. Positive integer # values are possible. 47 and 56 are values I know of. # Default: 47 # # # Example for a LifeTec LT9350 (Mustek 1200CP clone): # # scanner LT9350 0x378 cis1200 # option top_adjust 0 # option bw 127 # # Example for Mustek 6000P # # scanner 6000P 0x378 ccd300 # option top 56 # # # Uncomment/customize to your needs # # scanner Mustek-600CP 0x378 cis600 # scanner Mustek-1200CP 0x378 cis1200 # scanner Mustek-1200CP+ 0x378 cis1200+ # scanner Mustek-600-IIIEP 0x378 ccd300 # # auto probing: # # scanner mustek-cis600 * cis600 # scanner mustek-cis1200 * cis1200 # scanner mustek-cis1200+ * cis1200+ # scanner mustek-ccd300 * ccd300 sane-backends-1.0.29/backend/sane_strstatus.c0000666000000000000000000000667713615534521016036 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996, 1997 David Mosberger-Tang and Andreas Beck 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements the backend-independent parts of SANE. */ #include #include "../include/sane/sane.h" #ifndef SANE_I18N #define SANE_I18N(text) text #endif SANE_String_Const sane_strstatus (SANE_Status status) { static char buf[80]; switch (status) { case SANE_STATUS_GOOD: return SANE_I18N("Success"); case SANE_STATUS_UNSUPPORTED: return SANE_I18N("Operation not supported"); case SANE_STATUS_CANCELLED: return SANE_I18N("Operation was canceled"); case SANE_STATUS_DEVICE_BUSY: return SANE_I18N("Device busy"); case SANE_STATUS_INVAL: return SANE_I18N("Invalid argument"); case SANE_STATUS_EOF: return SANE_I18N("End of file reached"); case SANE_STATUS_JAMMED: return SANE_I18N("Document feeder jammed"); case SANE_STATUS_NO_DOCS: return SANE_I18N("Document feeder out of documents"); case SANE_STATUS_COVER_OPEN: return SANE_I18N("Scanner cover is open"); case SANE_STATUS_IO_ERROR: return SANE_I18N("Error during device I/O"); case SANE_STATUS_NO_MEM: return SANE_I18N("Out of memory"); case SANE_STATUS_ACCESS_DENIED: return SANE_I18N("Access to resource has been denied"); #ifdef SANE_STATUS_WARMING_UP case SANE_STATUS_WARMING_UP: return SANE_I18N("Lamp not ready, please retry"); #endif #ifdef SANE_STATUS_HW_LOCKED case SANE_STATUS_HW_LOCKED: return SANE_I18N("Scanner mechanism locked for transport"); #endif default: /* non-reentrant, but better than nothing */ sprintf (buf, "Unknown SANE status code %d", status); return buf; } } sane-backends-1.0.29/backend/ma1509.c0000666000000000000000000015200513615534521013653 00000000000000/* sane - Scanner Access Now Easy. (C) 2003 Henning Meier-Geinitz . Based on the mustek (SCSI) backend. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for scanners based on the Mustek MA-1509 chipset. Currently the Mustek BearPaw 1200F is known to work. */ /**************************************************************************/ /* ma1509 backend version */ #define BUILD 3 /**************************************************************************/ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_usb.h" #define BACKEND_NAME ma1509 #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "ma1509.h" #ifndef SANE_I18N #define SANE_I18N(text) text #endif /* Debug level from sanei_init_debug */ static SANE_Int debug_level; static SANE_Int num_devices; static Ma1509_Device *first_dev; static Ma1509_Scanner *first_handle; static const SANE_Device **devlist = 0; static int warmup_time = MA1509_WARMUP_TIME; /* Array of newly attached devices */ static Ma1509_Device **new_dev; /* Length of new_dev array */ static SANE_Int new_dev_len; /* Number of entries alloced for new_dev */ static SANE_Int new_dev_alloced; static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, 0 }; static SANE_String_Const ta_source_list[] = { SANE_I18N ("Flatbed"), SANE_I18N ("Transparency Adapter"), 0 }; static SANE_Word resolution_list[] = { 9, 50, 100, 150, 200, 300, 400, 450, 500, 600 }; static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; /* "SCSI" command buffers used by the backend */ static const SANE_Byte scsi_inquiry[] = { 0x12, 0x01, 0x00, 0x00, 0x00, 0x00, INQ_LEN, 0x00 }; static const SANE_Byte scsi_test_unit_ready[] = { 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00 }; static const SANE_Byte scsi_set_window[] = { 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00 }; static void print_data_buffer (const SANE_Byte * buffer, size_t len) { SANE_Byte buffer_byte_list[50]; SANE_Byte buffer_byte[5]; const SANE_Byte *pp; buffer_byte_list[0] = '\0'; for (pp = buffer; pp < (buffer + len); pp++) { sprintf ((SANE_String) buffer_byte, " %02x", *pp); strcat ((SANE_String) buffer_byte_list, (SANE_String) buffer_byte); if (((pp - buffer) % 0x10 == 0x0f) || (pp >= (buffer + len - 1))) { DBG (5, "buffer: %s\n", buffer_byte_list); buffer_byte_list[0] = '\0'; } } } static SANE_Status ma1509_cmd (Ma1509_Scanner * s, const SANE_Byte * cmd, SANE_Byte * data, size_t * data_size) { SANE_Status status; size_t size; #define MA1509_WRITE_LIMIT (1024 * 64) #define MA1509_READ_LIMIT (1024 * 256) DBG (5, "ma1509_cmd: fd=%d, cmd=%p, data=%p, data_size=%ld\n", s->fd, cmd, data, (long int) (data_size ? *data_size : 0)); DBG (5, "ma1509_cmd: cmd = %02x %02x %02x %02x %02x %02x %02x %02x \n", cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], cmd[7]); size = MA1509_COMMAND_LENGTH; status = sanei_usb_write_bulk (s->fd, cmd, &size); if (status != SANE_STATUS_GOOD || size != MA1509_COMMAND_LENGTH) { DBG (5, "ma1509_cmd: sanei_usb_write_bulk returned %s (size = %ld, expected %d)\n", sane_strstatus (status), (long int) size, MA1509_COMMAND_LENGTH); return status; } if (cmd[1] == 1) { /* receive data */ if (data && data_size && *data_size) { size_t bytes_left = *data_size; DBG (5, "ma1509_cmd: trying to receive %ld bytes of data\n", (long int) *data_size); while (status == SANE_STATUS_GOOD && bytes_left > 0) { size = bytes_left; if (size > MA1509_READ_LIMIT) size = MA1509_READ_LIMIT; status = sanei_usb_read_bulk (s->fd, data + *data_size - bytes_left, &size); if (status != SANE_STATUS_GOOD) { DBG (1, "ma1509_cmd: sanei_usb_read_bulk returned %s\n", sane_strstatus (status)); return status; } bytes_left -= size; DBG (5, "ma1509_cmd: read %ld bytes, %ld bytes to go\n", (long int) size, (long int) bytes_left); } if (debug_level >= 5) print_data_buffer (data, *data_size); } } else { /* send data */ if (data && data_size && *data_size) { size_t bytes_left = *data_size; DBG (5, "ma1509_cmd: sending %ld bytes of data\n", (long int) *data_size); if (debug_level >= 5) print_data_buffer (data, *data_size); while (status == SANE_STATUS_GOOD && bytes_left > 0) { size = bytes_left; if (size > MA1509_WRITE_LIMIT) size = MA1509_WRITE_LIMIT; status = sanei_usb_write_bulk (s->fd, data + *data_size - bytes_left, &size); if (status != SANE_STATUS_GOOD) { DBG (1, "ma1509_cmd: sanei_usb_write_bulk returned %s\n", sane_strstatus (status)); return status; } bytes_left -= size; DBG (5, "ma1509_cmd: wrote %ld bytes, %ld bytes to go\n", (long int) size, (long int) bytes_left); } } } DBG (5, "ma1509_cmd: finished: data_size=%ld, status=%s\n", (long int) (data_size ? *data_size : 0), sane_strstatus (status)); return status; } static SANE_Status test_unit_ready (Ma1509_Scanner * s) { SANE_Status status; SANE_Byte buffer[0x04]; size_t size = sizeof (buffer); status = ma1509_cmd (s, scsi_test_unit_ready, buffer, &size); if (status != SANE_STATUS_GOOD) { DBG (1, "test_unit_ready: ma1509_cmd failed: %s\n", sane_strstatus (status)); return status; } if (buffer[1] == 0x14) s->hw->has_adf = SANE_TRUE; else s->hw->has_adf = SANE_FALSE; return status; } static SANE_Status attach (SANE_String_Const devname, Ma1509_Device ** devp) { SANE_Int fw_revision; SANE_Byte result[INQ_LEN]; SANE_Byte inquiry_byte_list[50], inquiry_text_list[17]; SANE_Byte inquiry_byte[5], inquiry_text[5]; SANE_Byte *model_name = result + 44; Ma1509_Scanner s; Ma1509_Device *dev, new_dev; SANE_Status status; size_t size; SANE_Byte *pp; SANE_Word vendor, product; if (devp) *devp = 0; for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devname) == 0) { if (devp) *devp = dev; return SANE_STATUS_GOOD; } memset (&new_dev, 0, sizeof (new_dev)); memset (&s, 0, sizeof (s)); s.hw = &new_dev; DBG (3, "attach: trying device %s\n", devname); status = sanei_usb_open (devname, &s.fd); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: sanei_usb_open failed: %s\n", sane_strstatus (status)); return status; } status = sanei_usb_get_vendor_product (s.fd, &vendor, &product); if (status != SANE_STATUS_GOOD && status != SANE_STATUS_UNSUPPORTED) { DBG (1, "attach: sanei_usb_get_vendor_product failed: %s\n", sane_strstatus (status)); sanei_usb_close (s.fd); return status; } if (status == SANE_STATUS_UNSUPPORTED) { DBG (3, "attach: can't detect vendor/product, trying anyway\n"); } else if (vendor != 0x055f || product != 0x0010) { DBG (1, "attach: unknown vendor/product (0x%x/0x%x)\n", vendor, product); sanei_usb_close (s.fd); return SANE_STATUS_UNSUPPORTED; } DBG (4, "attach: sending TEST_UNIT_READY\n"); status = test_unit_ready (&s); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: test_unit_ready device %s failed (%s)\n", devname, sane_strstatus (status)); sanei_usb_close (s.fd); return status; } DBG (4, "attach: sending INQUIRY\n"); size = sizeof (result); memset (result, 0, sizeof (result)); status = ma1509_cmd (&s, scsi_inquiry, result, &size); if (status != SANE_STATUS_GOOD || size != INQ_LEN) { DBG (1, "attach: inquiry for device %s failed (%s)\n", devname, sane_strstatus (status)); sanei_usb_close (s.fd); return status; } sanei_usb_close (s.fd); if ((result[0] & 0x1f) != 0x06) { DBG (1, "attach: device %s doesn't look like a scanner at all (%d)\n", devname, result[0] & 0x1f); return SANE_STATUS_INVAL; } if (debug_level >= 5) { /* print out inquiry */ DBG (5, "attach: inquiry output:\n"); inquiry_byte_list[0] = '\0'; inquiry_text_list[0] = '\0'; for (pp = result; pp < (result + INQ_LEN); pp++) { sprintf ((SANE_String) inquiry_text, "%c", (*pp < 127) && (*pp > 31) ? *pp : '.'); strcat ((SANE_String) inquiry_text_list, (SANE_String) inquiry_text); sprintf ((SANE_String) inquiry_byte, " %02x", *pp); strcat ((SANE_String) inquiry_byte_list, (SANE_String) inquiry_byte); if ((pp - result) % 0x10 == 0x0f) { DBG (5, "%s %s\n", inquiry_byte_list, inquiry_text_list); inquiry_byte_list[0] = '\0'; inquiry_text_list[0] = '\0'; } } } /* get firmware revision as BCD number: */ fw_revision = (result[32] - '0') << 8 | (result[34] - '0') << 4 | (result[35] - '0'); DBG (4, "attach: firmware revision %d.%02x\n", fw_revision >> 8, fw_revision & 0xff); dev = malloc (sizeof (*dev)); if (!dev) return SANE_STATUS_NO_MEM; memcpy (dev, &new_dev, sizeof (*dev)); dev->name = strdup (devname); if (!dev->name) return SANE_STATUS_NO_MEM; dev->sane.name = (SANE_String_Const) dev->name; dev->sane.vendor = "Mustek"; dev->sane.type = "flatbed scanner"; dev->x_range.min = 0; dev->y_range.min = 0; dev->x_range.quant = SANE_FIX (0.1); dev->y_range.quant = SANE_FIX (0.1); dev->x_trans_range.min = 0; dev->y_trans_range.min = 0; /* default to something really small to be on the safe side: */ dev->x_trans_range.max = SANE_FIX (8.0 * MM_PER_INCH); dev->y_trans_range.max = SANE_FIX (5.0 * MM_PER_INCH); dev->x_trans_range.quant = SANE_FIX (0.1); dev->y_trans_range.quant = SANE_FIX (0.1); DBG (3, "attach: scanner id: %.11s\n", model_name); /* BearPaw 1200F (SCSI-over-USB) */ if (strncmp ((SANE_String) model_name, " B06", 4) == 0) { dev->x_range.max = SANE_FIX (211.3); dev->y_range.min = SANE_FIX (0); dev->y_range.max = SANE_FIX (296.7); dev->x_trans_range.min = SANE_FIX (0); dev->y_trans_range.min = SANE_FIX (0); dev->x_trans_range.max = SANE_FIX (150.0); dev->y_trans_range.max = SANE_FIX (175.0); dev->sane.model = "BearPaw 1200F"; } else { DBG (0, "attach: this scanner (ID: %s) is not supported yet\n", model_name); DBG (0, "attach: please set the debug level to 5 and send a debug " "report\n"); DBG (0, "attach: to henning@meier-geinitz.de (export " "SANE_DEBUG_MA1509=5\n"); DBG (0, "attach: scanimage -L 2>debug.txt). Thank you.\n"); free (dev); return SANE_STATUS_INVAL; } DBG (2, "attach: found Mustek %s %s %s%s\n", dev->sane.model, dev->sane.type, dev->has_ta ? "(TA)" : "", dev->has_adf ? "(ADF)" : ""); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; return SANE_STATUS_GOOD; } static size_t max_string_size (const SANE_String_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; } static SANE_Status init_options (Ma1509_Scanner * s) { SANE_Int i; memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].name = ""; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].size = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].s = strdup (mode_list[1]); if (!s->val[OPT_MODE].s) return SANE_STATUS_NO_MEM; /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_RESOLUTION].constraint.word_list = resolution_list; s->val[OPT_RESOLUTION].w = 50; /* source */ s->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_SOURCE].type = SANE_TYPE_STRING; s->opt[OPT_SOURCE].size = max_string_size (ta_source_list); s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].constraint.string_list = ta_source_list; s->val[OPT_SOURCE].s = strdup (ta_source_list[0]); if (!s->val[OPT_SOURCE].s) return SANE_STATUS_NO_MEM; s->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->val[OPT_PREVIEW].w = 0; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].size = 0; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->val[OPT_TL_X].w = s->hw->x_range.min; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->val[OPT_TL_Y].w = s->hw->y_range.min; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->val[OPT_BR_X].w = s->hw->x_range.max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; s->val[OPT_BR_Y].w = s->hw->y_range.max; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].size = 0; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* threshold */ s->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; s->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; s->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; s->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &u8_range; s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; s->val[OPT_THRESHOLD].w = 128; /* custom-gamma table */ s->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; s->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_R].size = MA1509_GAMMA_SIZE * sizeof (SANE_Word); s->val[OPT_GAMMA_VECTOR_R].wa = &s->red_gamma_table[0]; s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &u8_range; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; for (i = 0; i < MA1509_GAMMA_SIZE; i++) s->red_gamma_table[i] = i * MA1509_GAMMA_SIZE / 256; /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_G].size = MA1509_GAMMA_SIZE * sizeof (SANE_Word); s->val[OPT_GAMMA_VECTOR_G].wa = &s->green_gamma_table[0]; s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &u8_range; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; for (i = 0; i < MA1509_GAMMA_SIZE; i++) s->green_gamma_table[i] = i * MA1509_GAMMA_SIZE / 256; /* blue gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_B].size = MA1509_GAMMA_SIZE * sizeof (SANE_Word); s->val[OPT_GAMMA_VECTOR_B].wa = &s->blue_gamma_table[0]; s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &u8_range; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; for (i = 0; i < MA1509_GAMMA_SIZE; i++) s->blue_gamma_table[i] = i * MA1509_GAMMA_SIZE / 256; return SANE_STATUS_GOOD; } static SANE_Status attach_one_device (SANE_String_Const devname) { Ma1509_Device *dev; attach (devname, &dev); if (dev) { /* Keep track of newly attached devices so we can set options as necessary. */ if (new_dev_len >= new_dev_alloced) { new_dev_alloced += 4; if (new_dev) new_dev = realloc (new_dev, new_dev_alloced * sizeof (new_dev[0])); else new_dev = malloc (new_dev_alloced * sizeof (new_dev[0])); if (!new_dev) { DBG (1, "attach_one_device: out of memory\n"); return SANE_STATUS_NO_MEM; } } new_dev[new_dev_len++] = dev; } return SANE_STATUS_GOOD; } static SANE_Status set_window (Ma1509_Scanner * s) { SANE_Byte buffer[0x30], *cp; double pixels_per_mm; size_t size = sizeof (buffer); SANE_Status status; SANE_Int tlx, tly, width, height; SANE_Int offset = 0; struct timeval now; long remaining_time; /* check if lamp is warmed up */ gettimeofday (&now, 0); remaining_time = warmup_time - (now.tv_sec - s->lamp_time); if (remaining_time > 0) { DBG (0, "Warm-up in progress: please wait %2ld seconds\n", remaining_time); sleep (remaining_time); } memset (buffer, 0, size); cp = buffer; STORE16B (cp, 0); /* window identifier */ STORE16B (cp, s->val[OPT_RESOLUTION].w); STORE16B (cp, 0); /* not used acc. to specs */ pixels_per_mm = s->val[OPT_RESOLUTION].w / MM_PER_INCH; tlx = SANE_UNFIX (s->val[OPT_TL_X].w) * pixels_per_mm + 0.5; tly = SANE_UNFIX (s->val[OPT_TL_Y].w) * pixels_per_mm + 0.5; width = (SANE_UNFIX (s->val[OPT_BR_X].w) - SANE_UNFIX (s->val[OPT_TL_X].w)) * pixels_per_mm + 0.5; height = (SANE_UNFIX (s->val[OPT_BR_Y].w) - SANE_UNFIX (s->val[OPT_TL_Y].w)) * pixels_per_mm + 0.5 + offset; if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) { width /= 64; width *= 64; if (!width) width = 64; } else { width /= 8; width *= 8; if (!width) width = 8; } DBG (4, "set_window: tlx=%d (%d mm); tly=%d (%d mm); width=%d (%d mm); " "height=%d (%d mm)\n", tlx, (int) (tlx / pixels_per_mm), tly, (int) (tly / pixels_per_mm), width, (int) (width / pixels_per_mm), height, (int) (height / pixels_per_mm)); STORE16B (cp, 0); STORE16B (cp, tlx); STORE16B (cp, 0); STORE16B (cp, tly); *cp++ = 0x14; *cp++ = 0xc0; STORE16B (cp, width); *cp++ = 0x28; *cp++ = 0x20; STORE16B (cp, height); s->hw->ppl = width; s->hw->bpl = s->hw->ppl; s->hw->lines = height; *cp++ = 0x00; /* brightness, not impl. */ /* threshold */ if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) *cp++ = (SANE_Byte) s->val[OPT_THRESHOLD].w; else *cp++ = 0x80; *cp++ = 0x00; /* contrast, not impl. */ *cp++ = 0x00; /* ??? . */ /* Note that 'image composition' has no meaning for the SE series */ /* Mode selection is accomplished solely by bits/pixel (1, 8, 24) */ if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) { *cp++ = 24; /* 24 bits/pixel in color mode */ s->hw->bpl *= 3; } else if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY) == 0) *cp++ = 8; /* 8 bits/pixel in gray mode */ else { *cp++ = 1; /* 1 bit/pixel in lineart mode */ s->hw->bpl /= 8; } cp += 13; /* skip reserved bytes */ *cp++ = 0x00; /* lamp mode */ if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) != 0) *cp++ = 0x02; /* ??? */ status = ma1509_cmd (s, scsi_set_window, buffer, &size); if (status != SANE_STATUS_GOOD) { DBG (1, "set_window: ma1509_cmd failed: %s\n", sane_strstatus (status)); return status; } return status; } static SANE_Status calibration (Ma1509_Scanner * s) { SANE_Byte cmd[0x08], *buffer, *calibration_buffer; SANE_Status status; SANE_Int ppl = 5312; SANE_Int lines = 40; size_t total_size = lines * ppl; SANE_Int color, column, line; buffer = malloc (total_size * 3); if (!buffer) { DBG (1, "calibration: couldn't malloc %lu bytes for calibration buffer\n", (u_long) (total_size * 3)); return SANE_STATUS_NO_MEM; } memset (buffer, 0x00, total_size); memset (cmd, 0, 8); cmd[0] = 0x28; /* read data */ cmd[1] = 0x01; /* read */ cmd[2] = 0x01; /* calibration */ cmd[4] = (total_size >> 16) & 0xff; cmd[5] = (total_size >> 8) & 0xff; cmd[6] = total_size & 0xff; total_size *= 3; status = ma1509_cmd (s, cmd, buffer, &total_size); if (status != SANE_STATUS_GOOD) { DBG (1, "calibration: ma1509_cmd read data failed: %s\n", sane_strstatus (status)); free (buffer); return status; } calibration_buffer = malloc (ppl); if (!calibration_buffer) { DBG (1, "calibration: couldn't malloc %d bytes for calibration buffer\n", ppl); return SANE_STATUS_NO_MEM; } memset (calibration_buffer, 0x00, ppl); memset (cmd, 0, 8); cmd[0] = 0x2a; /* send data */ cmd[1] = 0x00; /* write */ cmd[2] = 0x01; /* calibration */ cmd[5] = (ppl >> 8) & 0xff; cmd[6] = ppl & 0xff; for (color = 1; color < 4; color++) { cmd[4] = color; for (column = 0; column < ppl; column++) { SANE_Int average = 0; for (line = 0; line < lines; line++) average += buffer[line * ppl * 3 + column * 3 + (color - 1)]; average /= lines; if (average < 1) average = 1; if (average > 255) average = 255; average = (256 * 256) / average - 256; if (average < 0) average = 0; if (average > 255) average = 255; calibration_buffer[column] = average; } total_size = ppl; status = ma1509_cmd (s, cmd, calibration_buffer, &total_size); if (status != SANE_STATUS_GOOD) { DBG (1, "calibration: ma1509_cmd send data failed: %s\n", sane_strstatus (status)); free (buffer); free (calibration_buffer); return status; } } free (buffer); free (calibration_buffer); DBG (4, "calibration: done\n"); return status; } static SANE_Status send_gamma (Ma1509_Scanner * s) { SANE_Byte cmd[0x08], *buffer; SANE_Status status; size_t total_size = MA1509_GAMMA_SIZE; SANE_Int color; buffer = malloc (total_size); if (!buffer) { DBG (1, "send_gamma: couldn't malloc %lu bytes for gamma buffer\n", (u_long) total_size); return SANE_STATUS_NO_MEM; } memset (cmd, 0, 8); cmd[0] = 0x2a; /* send data */ cmd[1] = 0x00; /* write */ cmd[2] = 0x03; /* gamma */ cmd[5] = (total_size >> 8) & 0xff; cmd[6] = total_size & 0xff; for (color = 1; color < 4; color++) { unsigned int i; if (s->val[OPT_CUSTOM_GAMMA].w) { SANE_Int *int_buffer; if (color == 1) int_buffer = s->red_gamma_table; else if (color == 2) int_buffer = s->green_gamma_table; else int_buffer = s->blue_gamma_table; for (i = 0; i < total_size; i++) buffer[i] = int_buffer[i]; } else { /* linear tables */ for (i = 0; i < total_size; i++) buffer[i] = i * 256 / total_size; } cmd[4] = color; status = ma1509_cmd (s, cmd, buffer, &total_size); if (status != SANE_STATUS_GOOD) { DBG (1, "send_gamma: ma1509_cmd send data failed: %s\n", sane_strstatus (status)); free (buffer); return status; } } if (!s->val[OPT_CUSTOM_GAMMA].w) free (buffer); DBG (4, "send_gamma: done\n"); return status; } static SANE_Status start_scan (Ma1509_Scanner * s) { SANE_Byte cmd[8]; SANE_Status status; DBG (4, "start_scan\n"); memset (cmd, 0, 8); cmd[0] = 0x1b; cmd[1] = 0x01; cmd[2] = 0x01; status = ma1509_cmd (s, cmd, NULL, NULL); if (status != SANE_STATUS_GOOD) { DBG (1, "start_scan: ma1509_cmd failed: %s\n", sane_strstatus (status)); return status; } return status; } static SANE_Status turn_lamp (Ma1509_Scanner * s, SANE_Bool is_on) { SANE_Status status; SANE_Byte buffer[0x30]; size_t size = sizeof (buffer); struct timeval lamp_time; DBG (4, "turn_lamp %s\n", is_on ? "on" : "off"); memset (buffer, 0, size); if (is_on) buffer[0x28] = 0x01; else buffer[0x28] = 0x02; status = ma1509_cmd (s, scsi_set_window, buffer, &size); if (status != SANE_STATUS_GOOD) { DBG (1, "turn_lamp: ma1509_cmd set_window failed: %s\n", sane_strstatus (status)); return status; } gettimeofday (&lamp_time, 0); s->lamp_time = lamp_time.tv_sec; return status; } static SANE_Status stop_scan (Ma1509_Scanner * s) { SANE_Byte cmd[8]; SANE_Status status; DBG (4, "stop_scan\n"); memset (cmd, 0, 8); cmd[0] = 0x1b; cmd[1] = 0x01; cmd[2] = 0x00; status = ma1509_cmd (s, cmd, NULL, NULL); if (status != SANE_STATUS_GOOD) { DBG (1, "stop_scan: ma1509_cmd failed: %s\n", sane_strstatus (status)); return status; } DBG (4, "stop_scan: scan stopped\n"); return status; } static SANE_Status start_read_data (Ma1509_Scanner * s) { SANE_Byte cmd[8]; SANE_Status status; SANE_Int total_size = s->hw->ppl * s->hw->lines; if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) total_size /= 8; memset (cmd, 0, 8); cmd[0] = 0x28; /* read data */ cmd[1] = 0x01; /* read */ cmd[2] = 0x00; /* scan data */ cmd[3] = (total_size >> 24) & 0xff; cmd[4] = (total_size >> 16) & 0xff; cmd[5] = (total_size >> 8) & 0xff; cmd[6] = total_size & 0xff; status = ma1509_cmd (s, cmd, NULL, NULL); if (status != SANE_STATUS_GOOD) { DBG (1, "stop_scan: ma1509_cmd failed: %s\n", sane_strstatus (status)); return status; } return status; } static SANE_Status read_data (Ma1509_Scanner * s, SANE_Byte * buffer, SANE_Int * size) { size_t local_size = *size; SANE_Status status; status = sanei_usb_read_bulk (s->fd, buffer, &local_size); if (status != SANE_STATUS_GOOD) { DBG (1, "read_data: sanei_usb_read_bulk failed: %s\n", sane_strstatus (status)); return status; } *size = local_size; return status; } /**************************************************************************/ /* SANE API calls */ /**************************************************************************/ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { SANE_Char line[PATH_MAX], *word, *end; SANE_String_Const cp; SANE_Int linenumber; FILE *fp; DBG_INIT (); #ifdef DBG_LEVEL debug_level = DBG_LEVEL; #else debug_level = 0; #endif DBG (2, "SANE ma1509 backend version %d.%d build %d from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (4, "sane_init: authorize %s null\n", authorize ? "!=" : "=="); sanei_usb_init (); num_devices = 0; first_dev = 0; first_handle = 0; devlist = 0; new_dev = 0; new_dev_len = 0; new_dev_alloced = 0; fp = sanei_config_open (MA1509_CONFIG_FILE); if (!fp) { /* default to /dev/usb/scanner0 instead of insisting on config file */ DBG (3, "sane_init: couldn't find config file (%s), trying " "/dev/usb/scanner0 directly\n", MA1509_CONFIG_FILE); attach ("/dev/usb/scanner0", 0); return SANE_STATUS_GOOD; } linenumber = 0; DBG (4, "sane_init: reading config file `%s'\n", MA1509_CONFIG_FILE); while (sanei_config_read (line, sizeof (line), fp)) { word = 0; linenumber++; cp = sanei_config_get_string (line, &word); if (!word || cp == line) { DBG (5, "sane_init: config file line %d: ignoring empty line\n", linenumber); if (word) free (word); continue; } if (word[0] == '#') { DBG (5, "sane_init: config file line %d: ignoring comment line\n", linenumber); free (word); continue; } if (strcmp (word, "option") == 0) { free (word); word = 0; cp = sanei_config_get_string (cp, &word); if (!word) { DBG (1, "sane_init: config file line %d: missing quotation mark?\n", linenumber); continue; } if (strcmp (word, "warmup-time") == 0) { long local_warmup_time; free (word); word = 0; cp = sanei_config_get_string (cp, &word); if (!word) { DBG (1, "sane_init: config file line %d: missing quotation mark?\n", linenumber); continue; } errno = 0; local_warmup_time = strtol (word, &end, 0); if (end == word) { DBG (3, "sane-init: config file line %d: warmup-time must " "have a parameter; using default (%d)\n", linenumber, warmup_time); } else if (errno) { DBG (3, "sane-init: config file line %d: warmup-time `%s' " "is invalid (%s); using default (%d)\n", linenumber, word, strerror (errno), warmup_time); } else { warmup_time = local_warmup_time; DBG (4, "sane_init: config file line %d: warmup-time set " "to %d seconds\n", linenumber, warmup_time); } if (word) free (word); word = 0; } else { DBG (3, "sane_init: config file line %d: ignoring unknown " "option `%s'\n", linenumber, word); if (word) free (word); word = 0; } } else { new_dev_len = 0; DBG (4, "sane_init: config file line %d: trying to attach `%s'\n", linenumber, line); sanei_usb_attach_matching_devices (line, attach_one_device); if (word) free (word); word = 0; } } if (new_dev_alloced > 0) { new_dev_len = new_dev_alloced = 0; free (new_dev); } fclose (fp); return SANE_STATUS_GOOD; } void sane_exit (void) { Ma1509_Device *dev, *next; DBG (4, "sane_exit\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free (dev->name); free (dev); } if (devlist) free (devlist); devlist = 0; first_dev = 0; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Ma1509_Device *dev; SANE_Int i; DBG (4, "sane_get_devices: %d devices %s\n", num_devices, local_only ? "(local only)" : ""); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (5, "sane_get_devices: end\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Ma1509_Device *dev; SANE_Status status; Ma1509_Scanner *s; if (!devicename) { DBG (1, "sane_open: devicename is null!\n"); return SANE_STATUS_INVAL; } if (!handle) { DBG (1, "sane_open: handle is null!\n"); return SANE_STATUS_INVAL; } DBG (4, "sane_open: devicename=%s\n", devicename); if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; if (!dev) { status = attach (devicename, &dev); if (status != SANE_STATUS_GOOD) return status; } } else /* empty devicname -> use first device */ dev = first_dev; if (!dev) { DBG (1, "sane_open: %s doesn't seem to exist\n", devicename); return SANE_STATUS_INVAL; } s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->fd = -1; s->hw = dev; init_options (s); /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; status = sanei_usb_open (s->hw->sane.name, &s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_open: couldn't open %s: %s\n", s->hw->sane.name, sane_strstatus (status)); return status; } status = turn_lamp (s, SANE_TRUE); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_open: couldn't turn on lamp: %s\n", sane_strstatus (status)); return status; } status = turn_lamp (s, SANE_TRUE); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_open: couldn't turn on lamp: %s\n", sane_strstatus (status)); return status; } *handle = s; DBG (5, "sane_open: finished (handle=%p)\n", (void *) s); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Ma1509_Scanner *prev, *s; SANE_Status status; DBG (4, "sane_close: handle=%p\n", handle); /* 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) { DBG (1, "sane_close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (s->val[OPT_MODE].s) free (s->val[OPT_MODE].s); if (s->val[OPT_SOURCE].s) free (s->val[OPT_SOURCE].s); status = turn_lamp (s, SANE_FALSE); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_close: couldn't turn off lamp: %s\n", sane_strstatus (status)); return; } sanei_usb_close (s->fd); if (prev) prev->next = s->next; else first_handle = s->next; free (handle); handle = 0; } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Ma1509_Scanner *s = handle; if (((unsigned) option >= NUM_OPTIONS) || (option < 0)) { DBG (3, "sane_get_option_descriptor: option %d >= NUM_OPTIONS or < 0\n", option); return 0; } if (!s) { DBG (1, "sane_get_option_descriptor: handle is null!\n"); return 0; } if (s->opt[option].name && s->opt[option].name[0] != 0) DBG (4, "sane_get_option_descriptor for option %s (%sactive%s)\n", s->opt[option].name, s->opt[option].cap & SANE_CAP_INACTIVE ? "in" : "", s->opt[option].cap & SANE_CAP_ADVANCED ? ", advanced" : ""); else DBG (4, "sane_get_option_descriptor for option \"%s\" (%sactive%s)\n", s->opt[option].title, s->opt[option].cap & SANE_CAP_INACTIVE ? "in" : "", s->opt[option].cap & SANE_CAP_ADVANCED ? ", advanced" : ""); return s->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Ma1509_Scanner *s = handle; SANE_Status status; SANE_Word cap; SANE_Word w; if (((unsigned) option >= NUM_OPTIONS) || (option < 0)) { DBG (3, "sane_control_option: option %d < 0 or >= NUM_OPTIONS\n", option); return SANE_STATUS_INVAL; } if (!s) { DBG (1, "sane_control_option: handle is null!\n"); return SANE_STATUS_INVAL; } if (!val && s->opt[option].type != SANE_TYPE_BUTTON) { DBG (1, "sane_control_option: val is null!\n"); return SANE_STATUS_INVAL; } if (s->opt[option].name && s->opt[option].name[0] != 0) DBG (4, "sane_control_option (%s option %s)\n", action == SANE_ACTION_GET_VALUE ? "get" : (action == SANE_ACTION_SET_VALUE ? "set" : "unknown action with"), s->opt[option].name); else DBG (4, "sane_control_option (%s option \"%s\")\n", action == SANE_ACTION_GET_VALUE ? "get" : (action == SANE_ACTION_SET_VALUE ? "set" : "unknown action with"), s->opt[option].title); if (info) *info = 0; if (s->scanning) { DBG (3, "sane_control_option: don't use while scanning (option %s)\n", s->opt[option].name); return SANE_STATUS_DEVICE_BUSY; } cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { DBG (3, "sane_control_option: option %s is inactive\n", s->opt[option].name); return SANE_STATUS_INVAL; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_PREVIEW: case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_THRESHOLD: case OPT_CUSTOM_GAMMA: case OPT_NUM_OPTS: *(SANE_Word *) val = s->val[option].w; return SANE_STATUS_GOOD; /* word-array options: */ case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (val, s->val[option].wa, s->opt[option].size); return SANE_STATUS_GOOD; /* string options: */ case OPT_SOURCE: case OPT_MODE: strcpy (val, s->val[option].s); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (3, "sane_control_option: option %s is not setable\n", s->opt[option].name); return SANE_STATUS_INVAL; } status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (4, "sane_control_option: constrain_value error (option %s)\n", s->opt[option].name); return status; } switch (option) { /* (mostly) side-effect-free word options: */ case OPT_RESOLUTION: case OPT_TL_X: case OPT_BR_X: case OPT_TL_Y: case OPT_BR_Y: if (info) *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_THRESHOLD: case OPT_PREVIEW: s->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* side-effect-free word-array options: */ case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (s->val[option].wa, val, s->opt[option].size); return SANE_STATUS_GOOD; case OPT_MODE: { SANE_Char *old_val = s->val[option].s; if (old_val) { if (strcmp (old_val, val) == 0) return SANE_STATUS_GOOD; /* no change */ free (old_val); } if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; s->val[option].s = strdup (val); if (!s->val[option].s) return SANE_STATUS_NO_MEM; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; if (strcmp (s->val[option].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) { s->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; } else { s->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (s->val[OPT_CUSTOM_GAMMA].w) { s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } return SANE_STATUS_GOOD; } case OPT_SOURCE: if (info) *info |= SANE_INFO_RELOAD_OPTIONS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); if (!s->val[option].s) return SANE_STATUS_NO_MEM; if (strcmp (val, "Transparency Adapter") == 0) { s->opt[OPT_TL_X].constraint.range = &s->hw->x_trans_range; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_trans_range; s->opt[OPT_BR_X].constraint.range = &s->hw->x_trans_range; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_trans_range; } else { s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; } return SANE_STATUS_GOOD; /* options with side-effects: */ case OPT_CUSTOM_GAMMA: w = *(SANE_Word *) val; if (w == s->val[OPT_CUSTOM_GAMMA].w) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; s->val[OPT_CUSTOM_GAMMA].w = w; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; if (w && strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) != 0) { s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; } } DBG (4, "sane_control_option: unknown action for option %s\n", s->opt[option].name); return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Ma1509_Scanner *s = handle; SANE_String_Const mode; if (!s) { DBG (1, "sane_get_parameters: handle is null!\n"); return SANE_STATUS_INVAL; } if (!s->scanning) { double width, height, dpi; memset (&s->params, 0, sizeof (s->params)); width = SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w); height = SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w); dpi = s->val[OPT_RESOLUTION].w; /* make best-effort guess at what parameters will look like once scanning starts. */ if (dpi > 0.0 && width > 0.0 && height > 0.0) { double dots_per_mm = dpi / MM_PER_INCH; s->params.pixels_per_line = width * dots_per_mm; s->params.lines = height * dots_per_mm; } mode = s->val[OPT_MODE].s; if (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = (s->params.pixels_per_line + 7) / 8; s->params.depth = 1; } else if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; } else { /* it's one of the color modes... */ s->params.bytes_per_line = 3 * s->params.pixels_per_line; s->params.depth = 8; s->params.format = SANE_FRAME_RGB; } } s->params.last_frame = SANE_TRUE; if (params) *params = s->params; DBG (4, "sane_get_parameters: frame = %d; last_frame = %s; depth = %d\n", s->params.format, s->params.last_frame ? "true" : "false", s->params.depth); DBG (4, "sane_get_parameters: lines = %d; ppl = %d; bpl = %d\n", s->params.lines, s->params.pixels_per_line, s->params.bytes_per_line); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Ma1509_Scanner *s = handle; SANE_Status status; struct timeval start; if (!s) { DBG (1, "sane_start: handle is null!\n"); return SANE_STATUS_INVAL; } DBG (4, "sane_start\n"); status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; /* Check for inconsistencies */ if (s->val[OPT_TL_X].w > s->val[OPT_BR_X].w) { DBG (0, "sane_start: %s (%.1f mm) is bigger than %s (%.1f mm) " "-- aborting\n", s->opt[OPT_TL_X].title, SANE_UNFIX (s->val[OPT_TL_X].w), s->opt[OPT_BR_X].title, SANE_UNFIX (s->val[OPT_BR_X].w)); return SANE_STATUS_INVAL; } if (s->val[OPT_TL_Y].w > s->val[OPT_BR_Y].w) { DBG (0, "sane_start: %s (%.1f mm) is bigger than %s (%.1f mm) " "-- aborting\n", s->opt[OPT_TL_Y].title, SANE_UNFIX (s->val[OPT_TL_Y].w), s->opt[OPT_BR_Y].title, SANE_UNFIX (s->val[OPT_BR_Y].w)); return SANE_STATUS_INVAL; } s->total_bytes = 0; s->read_bytes = 0; /* save start time */ gettimeofday (&start, 0); s->start_time = start.tv_sec; status = set_window (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: set window command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = test_unit_ready (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: test_unit_ready failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) != 0) { status = calibration (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: calibration failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = send_gamma (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: send_gamma failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } } s->scanning = SANE_TRUE; s->cancelled = SANE_FALSE; status = start_scan (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: start_scan command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = start_read_data (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: start_read_data command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } s->params.bytes_per_line = s->hw->bpl; s->params.pixels_per_line = s->params.bytes_per_line; if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) s->params.pixels_per_line /= 3; else if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) s->params.pixels_per_line *= 8; s->params.lines = s->hw->lines; s->buffer = (SANE_Byte *) malloc (MA1509_BUFFER_SIZE); if (!s->buffer) return SANE_STATUS_NO_MEM; s->buffer_bytes = 0; DBG (5, "sane_start: finished\n"); return SANE_STATUS_GOOD; stop_scanner_and_return: sanei_usb_close (s->fd); s->scanning = SANE_FALSE; return status; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { Ma1509_Scanner *s = handle; SANE_Status status; SANE_Int total_size = s->hw->lines * s->hw->bpl; SANE_Int i; if (!s) { DBG (1, "sane_read: handle is null!\n"); return SANE_STATUS_INVAL; } if (!buf) { DBG (1, "sane_read: buf is null!\n"); return SANE_STATUS_INVAL; } if (!len) { DBG (1, "sane_read: len is null!\n"); return SANE_STATUS_INVAL; } DBG (5, "sane_read\n"); *len = 0; if (s->cancelled) { DBG (4, "sane_read: scan was cancelled\n"); return SANE_STATUS_CANCELLED; } if (!s->scanning) { DBG (1, "sane_read: must call sane_start before sane_read\n"); return SANE_STATUS_INVAL; } if (total_size - s->read_bytes <= 0) { DBG (4, "sane_read: EOF\n"); stop_scan (s); s->scanning = SANE_FALSE; return SANE_STATUS_EOF; } if (s->buffer_bytes == 0) { SANE_Int size = MA1509_BUFFER_SIZE; if (size > (total_size - s->total_bytes)) size = total_size - s->total_bytes; DBG (4, "sane_read: trying to read %d bytes\n", size); status = read_data (s, s->buffer, &size); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_read: read_data failed: %s\n", sane_strstatus (status)); *len = 0; return status; } s->total_bytes += size; s->buffer_start = s->buffer; s->buffer_bytes = size; } *len = max_len; if (*len > s->buffer_bytes) *len = s->buffer_bytes; memcpy (buf, s->buffer_start, *len); s->buffer_start += (*len); s->buffer_bytes -= (*len); s->read_bytes += (*len); /* invert for lineart mode */ if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) { for (i = 0; i < *len; i++) buf[i] = ~buf[i]; } DBG (4, "sane_read: read %d/%d bytes (%d bytes to go, %d total)\n", *len, max_len, total_size - s->read_bytes, total_size); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Ma1509_Scanner *s = handle; if (!s) { DBG (1, "sane_cancel: handle is null!\n"); return; } DBG (4, "sane_cancel\n"); if (s->scanning) { s->cancelled = SANE_TRUE; stop_scan (s); free (s->buffer); } s->scanning = SANE_FALSE; DBG (4, "sane_cancel finished\n"); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Ma1509_Scanner *s = handle; if (!s) { DBG (1, "sane_set_io_mode: handle is null!\n"); return SANE_STATUS_INVAL; } DBG (4, "sane_set_io_mode: %s\n", non_blocking ? "non-blocking" : "blocking"); if (!s->scanning) { DBG (1, "sane_set_io_mode: call sane_start before sane_set_io_mode"); return SANE_STATUS_INVAL; } if (non_blocking) return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Ma1509_Scanner *s = handle; if (!s) { DBG (1, "sane_get_select_fd: handle is null!\n"); return SANE_STATUS_INVAL; } if (!fd) { DBG (1, "sane_get_select_fd: fd is null!\n"); return SANE_STATUS_INVAL; } DBG (4, "sane_get_select_fd\n"); if (!s->scanning) return SANE_STATUS_INVAL; return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/snapscan-scsi.c0000666000000000000000000017237013615534521015513 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997, 1998, 2001, 2002, 2013 Franck Schnefra, Michel Roelofs, Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang, Wolfgang Goeller, Petter Reinholdtsen, Gary Plewa, Sebastien Sable, Mikael Magnusson, Max Ushakov, Andrew Goodbody, Oliver Schwartz and Kevin Charter 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is a component of the implementation of a backend for many of the AGFA SnapScan and Acer Vuego/Prisa flatbed scanners. */ /* $Id$ SnapScan backend scsi command functions */ /* scanner scsi commands */ static SANE_Status download_firmware(SnapScan_Scanner * pss); static SANE_Status wait_scanner_ready (SnapScan_Scanner * pss); #include "snapscan-usb.h" /* find model by SCSI ID string or USB vendor/product ID */ static SnapScan_Model snapscani_get_model_id(char* model_str, int fd, SnapScan_Bus bus_type) { static char me[] = "snapscani_get_model_id"; SnapScan_Model model_id = UNKNOWN; SANE_Word vendor_id, product_id; int i; DBG(DL_CALL_TRACE, "%s(%s, %d, %d)\n",me, model_str, fd, bus_type); for (i = 0; i < known_scanners; i++) { if (0 == strcasecmp (model_str, scanners[i].scsi_name)) { model_id = scanners[i].id; break; } } /* Also test USB vendor and product ID numbers, since some USB models use identical model names. */ if ((bus_type == USB) && (sanei_usb_get_vendor_product(fd, &vendor_id, &product_id) == SANE_STATUS_GOOD)) { DBG(DL_MINOR_INFO, "%s: looking up scanner for ID 0x%04x,0x%04x.\n", me, vendor_id, product_id); for (i = 0; i < known_usb_scanners; i++) { if ((usb_scanners[i].vendor_id == vendor_id) && (usb_scanners[i].product_id == product_id)) { model_id = usb_scanners[i].id; DBG(DL_MINOR_INFO, "%s: scanner identified\n", me); break; } } } return model_id; } /* a sensible sense handler, courtesy of Franck; the last argument is expected to be a pointer to the associated SnapScan_Scanner structure */ static SANE_Status sense_handler (int scsi_fd, u_char * result, void *arg) { static char me[] = "sense_handler"; SnapScan_Scanner *pss = (SnapScan_Scanner *) arg; u_char sense, asc, ascq; char *sense_str = NULL, *as_str = NULL; SANE_Status status = SANE_STATUS_GOOD; DBG (DL_CALL_TRACE, "%s(%ld, %p, %p)\n", me, (long) scsi_fd, (void *) result, (void *) arg); sense = result[2] & 0x0f; asc = result[12]; ascq = result[13]; if (pss) { pss->asi1 = result[18]; pss->asi2 = result[19]; } if ((result[0] & 0x80) == 0) { DBG (DL_DATA_TRACE, "%s: sense key is invalid.\n", me); return SANE_STATUS_GOOD; /* sense key invalid */ } else { DBG (DL_DATA_TRACE, "%s: sense key: 0x%02x, asc: 0x%02x, ascq: 0x%02x, i1: 0x%02x, i2: 0x%02x\n", me, sense, asc, ascq, result[18], result[19]); } switch (sense) { case 0x00: /* no sense */ sense_str = "No sense."; DBG (DL_MINOR_INFO, "%s: %s\n", me, sense_str); break; case 0x02: /* not ready */ sense_str = "Not ready."; DBG (DL_MINOR_INFO, "%s: %s\n", me, sense_str); if (asc == 0x04 && ascq == 0x01) { /* warming up; byte 18 contains remaining seconds */ as_str = "Logical unit is in process of becoming ready."; DBG (DL_MINOR_INFO, "%s: %s (%d seconds)\n", me, as_str, result[18]); status = SANE_STATUS_DEVICE_BUSY; DBG (DL_MINOR_INFO, "%s: %s\n", me, sense_str); } break; case 0x04: /* hardware error */ sense_str = "Hardware error."; /* byte 18 and 19 detail the hardware problems */ DBG (DL_MINOR_INFO, "%s: %s (0x%02x, 0x%02x)\n", me, sense_str, result[18], result[19]); status = SANE_STATUS_IO_ERROR; break; case 0x05: /* illegal request */ sense_str = "Illegal request."; DBG (DL_MINOR_INFO, "%s: %s\n", me, sense_str); if (asc == 0x25 && ascq == 0x00) as_str = "Logical unit not supported."; DBG (DL_MINOR_INFO, "%s: %s\n", me, as_str); status = SANE_STATUS_IO_ERROR; break; case 0x09: /* process error */ sense_str = "Process error."; DBG (DL_MINOR_INFO, "%s: %s\n", me, sense_str); if (asc == 0x00 && ascq == 0x05) { /* no documents in ADF */ as_str = "End of data detected."; DBG (DL_MINOR_INFO, "%s: %s\n", me, as_str); status = SANE_STATUS_NO_DOCS; } else if (asc == 0x3b && ascq == 0x05) { /* paper jam in ADF */ as_str = "Paper jam."; DBG (DL_MINOR_INFO, "%s: %s\n", me, as_str); status = SANE_STATUS_JAMMED; } else if (asc == 0x3b && ascq == 0x09) { /* scanning area exceeds end of paper in ADF */ as_str = "Read past end of medium."; DBG (DL_MINOR_INFO, "%s: %s\n", me, as_str); status = SANE_STATUS_EOF; } break; case 0x0b: /* Aborted command */ sense_str = "Aborted Command."; DBG (DL_MINOR_INFO, "%s: %s\n", me, sense_str); status = SANE_STATUS_IO_ERROR; break; default: DBG (DL_MINOR_ERROR, "%s: no handling for sense %x.\n", me, sense); break; } if (pss) { pss->sense_str = sense_str; pss->as_str = as_str; } return status; } static SANE_Status open_scanner (SnapScan_Scanner *pss) { SANE_Status status; DBG (DL_CALL_TRACE, "open_scanner\n"); if (!pss->opens) { if(pss->pdev->bus == SCSI) { status = sanei_scsi_open (pss->devname, &(pss->fd), sense_handler, (void *) pss); } else { status = snapscani_usb_open (pss->devname, &(pss->fd), sense_handler, (void *) pss); } } else { /* already open */ status = SANE_STATUS_GOOD; } if (status == SANE_STATUS_GOOD) pss->opens++; return status; } static void close_scanner (SnapScan_Scanner *pss) { static char me[] = "close_scanner"; DBG (DL_CALL_TRACE, "%s\n", me); if (pss->opens) { pss->opens--; if (!pss->opens) { if(pss->pdev->bus == SCSI) { sanei_scsi_close (pss->fd); } else if(pss->pdev->bus == USB) { snapscani_usb_close (pss->fd); } } else { DBG(DL_INFO, "%s: handles left: %d\n,",me, pss->opens); } } } static SANE_Status snapscan_cmd(SnapScan_Bus bus, int fd, const void *src, size_t src_size, void *dst, size_t * dst_size) { SANE_Status status; DBG (DL_CALL_TRACE, "snapscan_cmd\n"); if(bus == USB) { status = snapscani_usb_cmd(fd, src, src_size, dst, dst_size); } else { status = sanei_scsi_cmd(fd, src, src_size, dst, dst_size); } return status; } /* SCSI commands */ #define TEST_UNIT_READY 0x00 #define INQUIRY 0x12 #define SEND 0x2A #define SET_WINDOW 0x24 #define SCAN 0x1B #define READ 0x28 #define REQUEST_SENSE 0x03 #define RESERVE_UNIT 0x16 #define RELEASE_UNIT 0x17 #define SEND_DIAGNOSTIC 0x1D #define OBJECT_POSITION 0x31 #define GET_DATA_BUFFER_STATUS 0x34 #define SCAN_LEN 6 #define READ_LEN 10 /* buffer tools */ static void zero_buf (u_char * buf, size_t len) { size_t i; for (i = 0; i < len; i++) buf[i] = 0x00; } #define BYTE_SIZE 8 static u_short u_char_to_u_short (u_char * pc) { u_short r = 0; r |= pc[0]; r = r << BYTE_SIZE; r |= pc[1]; return r; } static void u_short_to_u_charp (u_short x, u_char * pc) { pc[0] = (0xFF00 & x) >> BYTE_SIZE; pc[1] = (0x00FF & x); } static void u_int_to_u_char3p (u_int x, u_char * pc) { pc[0] = (0xFF0000 & x) >> 2 * BYTE_SIZE; pc[1] = (0x00FF00 & x) >> BYTE_SIZE; pc[2] = (0x0000FF & x); } static void u_int_to_u_char4p (u_int x, u_char * pc) { pc[0] = (0xFF000000 & x) >> 3 * BYTE_SIZE; pc[1] = (0x00FF0000 & x) >> 2 * BYTE_SIZE; pc[2] = (0x0000FF00 & x) >> BYTE_SIZE; pc[3] = (0x000000FF & x); } /* Convert 'STRING ' to 'STRING' by adding 0 after last non-space */ static void remove_trailing_space (char *s) { int position; if (NULL == s) return; for (position = strlen (s); position > 0 && ' ' == s[position - 1]; position--) { /* dummy */; } s[position] = 0; } static void check_range (int *v, SANE_Range r) { if (*v < r.min) *v = r.min; if (*v > r.max) *v = r.max; } #define INQUIRY_LEN 6 #define INQUIRY_RET_LEN 120 #define INQUIRY_RET_LEN_EPSON 139 #define INQUIRY_RET_LEN_5000 138 #define INQUIRY_VENDOR 8 /* Offset in reply data to vendor name */ #define INQUIRY_PRODUCT 16 /* Offset in reply data to product id */ #define INQUIRY_REV 32 /* Offset in reply data to revision level */ #define INQUIRY_PRL2 36 /* Product Revision Level 2 (AGFA) */ #define INQUIRY_HCFG 37 /* Hardware Configuration (AGFA) */ #define INQUIRY_HWST 40 /* Hardware status */ #define INQUIRY_HWMI 41 /* HARDWARE Model ID */ #define INQUIRY_PIX_PER_LINE 42 /* Pixels per scan line (AGFA) */ #define INQUIRY_BYTE_PER_LINE 44 /* Bytes per scan line (AGFA) */ #define INQUIRY_NUM_LINES 46 /* number of scan lines (AGFA) */ #define INQUIRY_OPT_RES 48 /* optical resolution (AGFA) */ #define INQUIRY_SCAN_SPEED 51 /* scan speed (AGFA) */ #define INQUIRY_EXPTIME1 52 /* exposure time, first digit (AGFA) */ #define INQUIRY_EXPTIME2 53 /* exposure time, second digit (AGFA) */ #define INQUIRY_G2R_DIFF 54 /* green to red difference (AGFA) */ #define INQUIRY_B2R_DIFF 55 /* green to red difference (AGFA) */ #define INQUIRY_FIRMWARE 96 /* firmware date and time (AGFA) */ #define INQUIRY_BYTE_PER_LINE_MSB 132 /* ?? top byte of bytes per scan line - epson 2480 */ #define INQUIRY_EPSON_HCFG 138 /* ?? Hardware configuration (Epson) */ /* a mini-inquiry reads only the first 36 bytes of inquiry data, and returns the vendor(7 chars) and model(16 chars); vendor and model must point to character buffers of size at least 8 and 17 respectively */ static SANE_Status mini_inquiry (SnapScan_Bus bus, int fd, char *vendor, char *model) { static const char *me = "mini_inquiry"; size_t read_bytes; char cmd[] = {INQUIRY, 0, 0, 0, 36, 0}; char data[36]; SANE_Status status; read_bytes = 36; DBG (DL_CALL_TRACE, "%s\n", me); status = snapscan_cmd (bus, fd, cmd, sizeof (cmd), data, &read_bytes); CHECK_STATUS (status, me, "snapscan_cmd"); memcpy (vendor, data + 8, 7); vendor[7] = 0; memcpy (model, data + 16, 16); model[16] = 0; remove_trailing_space (vendor); remove_trailing_space (model); return SANE_STATUS_GOOD; } /* TODO: Remove */ static char *snapscani_debug_data(char *str,const SANE_Byte *data, int len) { char tmpstr[10]; int i; str[0]=0; for(i=0; i < (len < 20 ? len : 20); i++) { sprintf(tmpstr," 0x%02x",((int)data[i]) & 0xff); if(i%16 == 0 && i != 0) strcat(str,"\n"); strcat(str,tmpstr); } if(i < len) strcat(str," ..."); return str; } static SANE_Status inquiry (SnapScan_Scanner *pss) { static const char *me = "inquiry"; char tmpstr[150]; /* TODO: Remove */ SANE_Status status; switch (pss->pdev->model) { case PERFECTION2480: case PERFECTION3490: if (pss->firmware_loaded) pss->read_bytes = INQUIRY_RET_LEN_EPSON; else pss->read_bytes = INQUIRY_RET_LEN; break; case PRISA5000: case PRISA5150: pss->read_bytes = INQUIRY_RET_LEN_5000; break; default: pss->read_bytes = INQUIRY_RET_LEN; break; } zero_buf (pss->cmd, MAX_SCSI_CMD_LEN); pss->cmd[0] = INQUIRY; pss->cmd[4] = pss->read_bytes; DBG (DL_CALL_TRACE, "%s\n", me); status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->cmd, INQUIRY_LEN, pss->buf, &pss->read_bytes); CHECK_STATUS (status, me, "snapscan_cmd"); /* record current parameters */ { char exptime[4] = {' ', '.', ' ', 0}; exptime[0] = (char) (pss->buf[INQUIRY_EXPTIME1] + '0'); exptime[2] = (char) (pss->buf[INQUIRY_EXPTIME2] + '0'); pss->ms_per_line = atof (exptime)*(float) pss->buf[INQUIRY_SCAN_SPEED]; DBG (DL_DATA_TRACE, "%s: exposure time: %s ms\n", me, exptime); DBG (DL_DATA_TRACE, "%s: ms per line: %f\n", me, pss->ms_per_line); } switch (pss->pdev->model) { case SNAPSCAN: case ACER300F: pss->chroma_offset[R_CHAN] = pss->chroma_offset[G_CHAN] = pss->chroma_offset[B_CHAN] = 0; pss->chroma = 0; break; case PERFECTION2480: case PERFECTION3490: if (pss->firmware_loaded) { snapscani_debug_data(tmpstr, pss->buf+120, 19); DBG (DL_DATA_TRACE, "%s: Epson additional inquiry data:\n%s\n", me, tmpstr); pss->hconfig_epson = pss->buf[INQUIRY_EPSON_HCFG]; } /* fall through */ default: { signed char min_diff; u_char r_off, g_off, b_off; signed char g = (pss->buf[INQUIRY_G2R_DIFF] & 0x80) ? -(pss->buf[INQUIRY_G2R_DIFF] & 0x7F) : pss->buf[INQUIRY_G2R_DIFF]; signed char b = (pss->buf[INQUIRY_B2R_DIFF] & 0x80) ? -(pss->buf[INQUIRY_B2R_DIFF] & 0x7F) : pss->buf[INQUIRY_B2R_DIFF]; DBG (DL_DATA_TRACE, "%s: G2R_DIFF: %d\n", me, pss->buf[INQUIRY_G2R_DIFF]); DBG (DL_DATA_TRACE, "%s: B2R_DIFF: %d\n", me, pss->buf[INQUIRY_B2R_DIFF]); min_diff = MIN (MIN (b, g), 0); r_off = (u_char) (0 - min_diff); g_off = (u_char) (g - min_diff); b_off = (u_char) (b - min_diff); pss->chroma_offset[R_CHAN] = r_off; pss->chroma_offset[G_CHAN] = g_off; pss->chroma_offset[B_CHAN] = b_off; pss->chroma = MAX(MAX(r_off, g_off), b_off); DBG (DL_DATA_TRACE, "%s: Chroma offsets=%d; Red=%u, Green:=%u, Blue=%u\n", me, pss->chroma, pss->chroma_offset[R_CHAN], pss->chroma_offset[G_CHAN], pss->chroma_offset[B_CHAN]); } break; } pss->actual_res = u_char_to_u_short (pss->buf + INQUIRY_OPT_RES); pss->pixels_per_line = u_char_to_u_short (pss->buf + INQUIRY_PIX_PER_LINE); pss->bytes_per_line = u_char_to_u_short (pss->buf + INQUIRY_BYTE_PER_LINE); if ((pss->pdev->model == PERFECTION2480) || (pss->pdev->model == PERFECTION3490)) pss->bytes_per_line += pss->buf[INQUIRY_BYTE_PER_LINE_MSB] << 16; pss->lines = u_char_to_u_short (pss->buf + INQUIRY_NUM_LINES) - pss->chroma; /* effective buffer size must be a whole number of scan lines */ if (pss->lines) pss->buf_sz = (pss->phys_buf_sz/pss->bytes_per_line)*pss->bytes_per_line; else pss->buf_sz = 0; pss->bytes_remaining = pss->bytes_per_line * (pss->lines + pss->chroma); pss->expected_read_bytes = 0; pss->read_bytes = 0; pss->hwst = pss->buf[INQUIRY_HWST]; if ((pss->pdev->bus == USB) && !(pss->hwst & 0x02)) { pss->firmware_loaded = SANE_TRUE; } pss->hconfig = pss->buf[INQUIRY_HCFG]; switch (pss->pdev->model) { case PERFECTION1270: case PERFECTION1670: case PERFECTION2480: case PERFECTION3490: case PRISA5150: case PRISA5000: pss->bpp = 14; break; case STYLUS_CX1500: case SCANWIT2720S: pss->bpp = 12; break; default: pss->bpp = 8; if (pss->hconfig & HCFG_ADC) pss->bpp = 10; break; } DBG (DL_DATA_TRACE, "%s: hardware config = 0x%02x\n", me, pss->hconfig); DBG (DL_DATA_TRACE, "%s: bits per pixel = %lu\n", me, (u_long) pss->bpp); DBG (DL_DATA_TRACE, "%s: pixels per scan line = %lu\n", me, (u_long) pss->pixels_per_line); DBG (DL_DATA_TRACE, "%s: bytes per scan line = %lu\n", me, (u_long) pss->bytes_per_line); DBG (DL_DATA_TRACE, "%s: number of scan lines = %lu\n", me, (u_long) pss->lines); DBG (DL_DATA_TRACE, "%s: effective buffer size = %lu bytes, %lu lines\n", me, (u_long) pss->buf_sz, (u_long) (pss->lines ? pss->buf_sz / pss->lines : 0)); DBG (DL_DATA_TRACE, "%s: expected total scan data: %lu bytes\n", me, (u_long) pss->bytes_remaining); return status; } static SANE_Status test_unit_ready (SnapScan_Scanner *pss) { static const char *me = "test_unit_ready"; char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0}; SANE_Status status; DBG (DL_CALL_TRACE, "%s\n", me); status = snapscan_cmd (pss->pdev->bus, pss->fd, cmd, sizeof (cmd), NULL, NULL); CHECK_STATUS (status, me, "snapscan_cmd"); return status; } static void reserve_unit (SnapScan_Scanner *pss) { static const char *me = "reserve_unit"; char cmd[] = {RESERVE_UNIT, 0, 0, 0, 0, 0}; SANE_Status status; DBG (DL_CALL_TRACE, "%s\n", me); status = snapscan_cmd (pss->pdev->bus, pss->fd, cmd, sizeof (cmd), NULL, NULL); if (status != SANE_STATUS_GOOD) { DBG (DL_MAJOR_ERROR, "%s: scsi command error: %s\n", me, sane_strstatus (status)); } } static void release_unit (SnapScan_Scanner *pss) { static const char *me = "release_unit"; char cmd[] = {RELEASE_UNIT, 0, 0, 0, 0, 0}; SANE_Status status; DBG (DL_CALL_TRACE, "%s\n", me); status = snapscan_cmd (pss->pdev->bus, pss->fd, cmd, sizeof (cmd), NULL, NULL); if (status != SANE_STATUS_GOOD) { DBG (DL_MAJOR_ERROR, "%s: scsi command error: %s\n", me, sane_strstatus (status)); } } #define SEND_LENGTH 10 #define DTC_HALFTONE 0x02 #define DTC_GAMMA 0x03 #define DTC_GAMMA2 0x04 #define DTC_SPEED 0x81 #define DTC_CALIBRATION 0x82 #define DTC_CALIBRATION_BLACK 0x89 #define DTCQ_HALFTONE_BW8 0x00 #define DTCQ_HALFTONE_COLOR8 0x01 #define DTCQ_HALFTONE_BW16 0x80 #define DTCQ_HALFTONE_COLOR16 0x81 #define DTCQ_GAMMA_GRAY8 0x00 #define DTCQ_GAMMA_RED8 0x01 #define DTCQ_GAMMA_GREEN8 0x02 #define DTCQ_GAMMA_BLUE8 0x03 #define DTCQ_GAMMA_GRAY10 0x80 #define DTCQ_GAMMA_RED10 0x81 #define DTCQ_GAMMA_GREEN10 0x82 #define DTCQ_GAMMA_BLUE10 0x83 #define DTCQ_GAMMA_GRAY12 0x90 #define DTCQ_GAMMA_RED12 0x91 #define DTCQ_GAMMA_GREEN12 0x92 #define DTCQ_GAMMA_BLUE12 0x93 #define DTCQ_GAMMA_GRAY14 0x95 /* ? */ #define DTCQ_GAMMA_RED14 0x96 #define DTCQ_GAMMA_GREEN14 0x97 #define DTCQ_GAMMA_BLUE14 0x98 #define DTCQ_GAMMA_GRAY12_16BIT 0xa0 #define DTCQ_GAMMA_RED12_16BIT 0xa1 #define DTCQ_GAMMA_GREEN12_16BIT 0xa2 #define DTCQ_GAMMA_BLUE12_16BIT 0xa3 #define DTCQ_GAMMA_GRAY14_16BIT 0xa5 /* ? */ #define DTCQ_GAMMA_RED14_16BIT 0xa6 #define DTCQ_GAMMA_GREEN14_16BIT 0xa7 #define DTCQ_GAMMA_BLUE14_16BIT 0xa8 static SANE_Status send (SnapScan_Scanner *pss, u_char dtc, u_char dtcq) { static char me[] = "send"; SANE_Status status; u_short tl; /* transfer length */ DBG (DL_CALL_TRACE, "%s\n", me); zero_buf (pss->buf, SEND_LENGTH); switch (dtc) { case DTC_HALFTONE: /* halftone mask */ switch (dtcq) { case DTCQ_HALFTONE_BW8: tl = 64; /* bw 8x8 table */ break; case DTCQ_HALFTONE_COLOR8: tl = 3 * 64; /* rgb 8x8 tables */ break; case DTCQ_HALFTONE_BW16: tl = 256; /* bw 16x16 table */ break; case DTCQ_HALFTONE_COLOR16: tl = 3 * 256; /* rgb 16x16 tables */ break; default: DBG (DL_MAJOR_ERROR, "%s: bad halftone data type qualifier 0x%x\n", me, dtcq); return SANE_STATUS_INVAL; } break; case DTC_GAMMA: /* gamma function */ case DTC_GAMMA2: switch (dtcq) { case DTCQ_GAMMA_GRAY8: /* 8-bit tables */ case DTCQ_GAMMA_RED8: case DTCQ_GAMMA_GREEN8: case DTCQ_GAMMA_BLUE8: tl = 256; break; case DTCQ_GAMMA_GRAY10: /* 10-bit tables */ case DTCQ_GAMMA_RED10: case DTCQ_GAMMA_GREEN10: case DTCQ_GAMMA_BLUE10: tl = 1024; break; case DTCQ_GAMMA_GRAY12: /* 12-bit tables */ case DTCQ_GAMMA_RED12: case DTCQ_GAMMA_GREEN12: case DTCQ_GAMMA_BLUE12: tl = 4096; break; case DTCQ_GAMMA_GRAY12_16BIT: /* 12-bit tables with 16 bit data */ case DTCQ_GAMMA_RED12_16BIT: case DTCQ_GAMMA_GREEN12_16BIT: case DTCQ_GAMMA_BLUE12_16BIT: tl = 8192; break; case DTCQ_GAMMA_GRAY14: /* 14-bit tables */ case DTCQ_GAMMA_RED14: case DTCQ_GAMMA_GREEN14: case DTCQ_GAMMA_BLUE14: tl = 16384; break; case DTCQ_GAMMA_GRAY14_16BIT: /* 14-bit tables with 16 bit data */ case DTCQ_GAMMA_RED14_16BIT: case DTCQ_GAMMA_GREEN14_16BIT: case DTCQ_GAMMA_BLUE14_16BIT: tl = 32768; break; default: DBG (DL_MAJOR_ERROR, "%s: bad gamma data type qualifier 0x%x\n", me, dtcq); return SANE_STATUS_INVAL; } break; case DTC_SPEED: /* static transfer speed */ tl = 2; break; case DTC_CALIBRATION: tl = calibration_line_length(pss); break; default: DBG (DL_MAJOR_ERROR, "%s: unsupported data type code 0x%x\n", me, (unsigned) dtc); return SANE_STATUS_INVAL; } pss->buf[0] = SEND; pss->buf[2] = dtc; pss->buf[5] = dtcq; pss->buf[7] = (tl >> 8) & 0xff; pss->buf[8] = tl & 0xff; status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->buf, SEND_LENGTH + tl, NULL, NULL); CHECK_STATUS (status, me, "snapscan_cmd"); return status; } #include "snapscan-data.c" static SANE_Status send_calibration_5150(SnapScan_Scanner *pss) { static const int length = sizeof(calibration_data_5150); SANE_Byte* buf = malloc (length + SEND_LENGTH); SANE_Status status; zero_buf (buf, SEND_LENGTH); *buf = SEND; *(buf + 2) = DTC_CALIBRATION; *(buf + 6) = (length >> 16) & 0xff; *(buf + 7) = (length >> 8) & 0xff; *(buf + 8) = length & 0xff; memcpy(buf + SEND_LENGTH, calibration_data_5150, length); status = snapscan_cmd ( pss->pdev->bus, pss->fd, buf, SEND_LENGTH + length, NULL, NULL); free (buf); return status; } #define SET_WINDOW_LEN 10 #define SET_WINDOW_HEADER 10 /* header starts */ #define SET_WINDOW_HEADER_LEN 8 #define SET_WINDOW_DESC 18 /* window descriptor starts */ #define SET_WINDOW_DESC_LEN 48 #define SET_WINDOW_TRANSFER_LEN 56 #define SET_WINDOW_TOTAL_LEN 66 #define SET_WINDOW_RET_LEN 0 /* no returned data */ #define SET_WINDOW_P_TRANSFER_LEN 6 #define SET_WINDOW_P_DESC_LEN 6 #define SET_WINDOW_P_WIN_ID 0 #define SET_WINDOW_P_XRES 2 #define SET_WINDOW_P_YRES 4 #define SET_WINDOW_P_TLX 6 #define SET_WINDOW_P_TLY 10 #define SET_WINDOW_P_WIDTH 14 #define SET_WINDOW_P_LENGTH 18 #define SET_WINDOW_P_BRIGHTNESS 22 #define SET_WINDOW_P_THRESHOLD 23 #define SET_WINDOW_P_CONTRAST 24 #define SET_WINDOW_P_COMPOSITION 25 #define SET_WINDOW_P_BITS_PER_PIX 26 #define SET_WINDOW_P_HALFTONE_PATTERN 27 #define SET_WINDOW_P_PADDING_TYPE 29 #define SET_WINDOW_P_BIT_ORDERING 30 #define SET_WINDOW_P_COMPRESSION_TYPE 32 #define SET_WINDOW_P_COMPRESSION_ARG 33 #define SET_WINDOW_P_HALFTONE_FLAG 35 #define SET_WINDOW_P_DEBUG_MODE 40 #define SET_WINDOW_P_GAMMA_NO 41 #define SET_WINDOW_P_OPERATION_MODE 42 #define SET_WINDOW_P_RED_UNDER_COLOR 43 #define SET_WINDOW_P_BLUE_UNDER_COLOR 45 #define SET_WINDOW_P_GREEN_UNDER_COLOR 44 static SANE_Status prepare_set_window (SnapScan_Scanner *pss) { static const char *me = "prepare_set_window"; u_char *pc; DBG (DL_CALL_TRACE, "%s\n", me); zero_buf (pss->cmd, MAX_SCSI_CMD_LEN); /* basic command */ pc = pss->cmd; pc[0] = SET_WINDOW; u_int_to_u_char3p ((u_int) SET_WINDOW_TRANSFER_LEN, pc + SET_WINDOW_P_TRANSFER_LEN); /* header; we support only one window */ pc += SET_WINDOW_LEN; u_short_to_u_charp (SET_WINDOW_DESC_LEN, pc + SET_WINDOW_P_DESC_LEN); /* the sole window descriptor */ pc += SET_WINDOW_HEADER_LEN; pc[SET_WINDOW_P_WIN_ID] = 0; u_short_to_u_charp (pss->res, pc + SET_WINDOW_P_XRES); u_short_to_u_charp (pss->res, pc + SET_WINDOW_P_YRES); DBG (DL_CALL_TRACE, "%s Resolution: %d\n", me, pss->res); pc[SET_WINDOW_P_BRIGHTNESS] = 128; pc[SET_WINDOW_P_THRESHOLD] = (u_char) (255.0*(pss->threshold / 100.0)); pc[SET_WINDOW_P_CONTRAST] = 128; { SnapScan_Mode mode = pss->mode; pss->bpp_scan = pss->val[OPT_BIT_DEPTH].w; if (pss->preview) { mode = pss->preview_mode; if (pss->pdev->model != SCANWIT2720S) pss->bpp_scan = 8; } DBG (DL_MINOR_INFO, "%s Mode: %d\n", me, mode); switch (mode) { case MD_COLOUR: pc[SET_WINDOW_P_COMPOSITION] = 0x05; /* multi-level RGB */ break; case MD_BILEVELCOLOUR: if (pss->halftone) pc[SET_WINDOW_P_COMPOSITION] = 0x04; /* halftone RGB */ else pc[SET_WINDOW_P_COMPOSITION] = 0x03; /* bi-level RGB */ pss->bpp_scan = 1; break; case MD_GREYSCALE: pc[SET_WINDOW_P_COMPOSITION] = 0x02; /* grayscale */ break; case MD_LINEART: if (pss->halftone) pc[SET_WINDOW_P_COMPOSITION] = 0x01; /* b&w halftone */ else pc[SET_WINDOW_P_COMPOSITION] = 0x00; /* b&w (lineart) */ pss->bpp_scan = 1; break; default: break; } pc[SET_WINDOW_P_BITS_PER_PIX] = pss->bpp_scan; DBG (DL_INFO, "%s: bits-per-pixel set to %d\n", me, (int) pss->bpp_scan); } /* the RIF bit is the high bit of the padding type */ pc[SET_WINDOW_P_PADDING_TYPE] = 0x00 /*| (pss->negative ? 0x00 : 0x80) */ ; pc[SET_WINDOW_P_HALFTONE_PATTERN] = 0; pc[SET_WINDOW_P_HALFTONE_FLAG] = 0x80; /* always set; image composition determines whether halftone is actually used */ u_short_to_u_charp (0x0000, pc + SET_WINDOW_P_BIT_ORDERING); /* used? */ pc[SET_WINDOW_P_COMPRESSION_TYPE] = 0; /* none */ pc[SET_WINDOW_P_COMPRESSION_ARG] = 0; /* none applicable */ if(pss->pdev->model != ACER300F && pss->pdev->model != SNAPSCAN310 && pss->pdev->model != PRISA310 && pss->pdev->model != PRISA610 ) { pc[SET_WINDOW_P_DEBUG_MODE] = 2; /* use full 128k buffer */ if (pss->mode != MD_LINEART) { pc[SET_WINDOW_P_GAMMA_NO] = 0x01; /* downloaded gamma table */ } } pc[SET_WINDOW_P_RED_UNDER_COLOR] = 0xff; /* defaults */ pc[SET_WINDOW_P_BLUE_UNDER_COLOR] = 0xff; pc[SET_WINDOW_P_GREEN_UNDER_COLOR] = 0xff; return SANE_STATUS_GOOD; } static SANE_Status set_window (SnapScan_Scanner *pss) { static const char *me = "set_window"; SANE_Status status; unsigned char source; u_char *pc; int pos_factor; DBG (DL_CALL_TRACE, "%s\n", me); status = prepare_set_window(pss); CHECK_STATUS (status, me, "prepare_set_window"); pc = pss->cmd; /* header; we support only one window */ pc += SET_WINDOW_LEN; /* the sole window descriptor */ pc += SET_WINDOW_HEADER_LEN; switch (pss->pdev->model) { case PRISA5000: case PRISA5000E: case PRISA5150: pos_factor = (pss->res > 600) ? 1200 : 600; break; case PERFECTION1270: case PERFECTION1670: pos_factor = (pss->res > 800) ? 1600 : 800; break; case PERFECTION2480: pos_factor = (pss->res > 1200) ? 2400 : 1200; break; case PERFECTION3490: pos_factor = (pss->res > 1600) ? 3200 : 1600; break; default: pos_factor = pss->actual_res; break; } /* it's an ugly sound if the scanner drives against the rear wall, and with changing max values we better be sure */ check_range(&(pss->brx), pss->pdev->x_range); check_range(&(pss->bry), pss->pdev->y_range); { int tlxp = (int) (pos_factor*IN_PER_MM*SANE_UNFIX(pss->tlx)); int tlyp = (int) (pos_factor*IN_PER_MM*SANE_UNFIX(pss->tly)); int brxp = (int) (pos_factor*IN_PER_MM*SANE_UNFIX(pss->brx)); int bryp = (int) (pos_factor*IN_PER_MM*SANE_UNFIX(pss->bry)); /* Check for brx > tlx and bry > tly */ if (brxp <= tlxp) { tlxp = MAX (0, brxp - 75); } if (bryp <= tlyp) { tlyp = MAX (0, bryp - 75); } u_int_to_u_char4p (tlxp, pc + SET_WINDOW_P_TLX); u_int_to_u_char4p (tlyp, pc + SET_WINDOW_P_TLY); u_int_to_u_char4p (MAX (((unsigned) (brxp - tlxp)), 75), pc + SET_WINDOW_P_WIDTH); u_int_to_u_char4p (MAX (((unsigned) (bryp - tlyp)), 75), pc + SET_WINDOW_P_LENGTH); DBG (DL_INFO, "%s Width: %d\n", me, brxp-tlxp); DBG (DL_INFO, "%s Length: %d\n", me, bryp-tlyp); } source = 0x0; if (pss->preview) { source |= 0x80; /* no high quality in preview */ } else { source |= 0x40; /* no preview */ } if (!pss->highquality) { source |= 0x80; /* no high quality */ } if ((pss->pdev->model == PERFECTION2480) || (pss->pdev->model == PERFECTION3490)) { source |= 0x40; /* 2480/3490 always need no_preview bit */ } if (pss->source == SRC_TPO) { source |= 0x08; } if (pss->source == SRC_ADF) { source |= 0x10; } pc[SET_WINDOW_P_OPERATION_MODE] = source; DBG (DL_MINOR_INFO, "%s: operation mode set to 0x%02x\n", me, (int) source); do { status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->cmd, SET_WINDOW_TOTAL_LEN, NULL, NULL); if (status == SANE_STATUS_DEVICE_BUSY) { DBG (DL_MINOR_INFO, "%s: waiting for scanner to warm up\n", me); wait_scanner_ready (pss); } } while (status == SANE_STATUS_DEVICE_BUSY); CHECK_STATUS (status, me, "snapscan_cmd"); return status; } static SANE_Status set_window_autofocus (SnapScan_Scanner *copy) { static char me[] = "set_window_autofocus"; SANE_Status status; DBG (DL_CALL_TRACE, "%s(%p)\n", me, (void*)copy); copy->res = copy->actual_res; status = prepare_set_window (copy); CHECK_STATUS (status, me, "prepare_set_window"); u_int_to_u_char4p (1700, copy->cmd + SET_WINDOW_DESC + SET_WINDOW_P_TLY); /* fill in width & height */ u_int_to_u_char4p (2550, copy->cmd + SET_WINDOW_DESC + SET_WINDOW_P_WIDTH); u_int_to_u_char4p (128, copy->cmd + SET_WINDOW_DESC + SET_WINDOW_P_LENGTH); copy->cmd[SET_WINDOW_DESC + SET_WINDOW_P_BITS_PER_PIX] = 12; copy->cmd[SET_WINDOW_DESC + SET_WINDOW_P_OPERATION_MODE] = 0x49; /* focusing mode */ return snapscan_cmd (copy->pdev->bus, copy->fd, copy->cmd, SET_WINDOW_TOTAL_LEN, NULL, NULL); } #define SET_FRAME_LEN 10 static SANE_Status set_frame (SnapScan_Scanner *pss, SANE_Byte frame_no) { static const char *me = "set_frame"; SANE_Status status; DBG (DL_CALL_TRACE, "%s\n", me); DBG (DL_VERBOSE, "%s setting frame to %d\n", me, frame_no); zero_buf (pss->cmd, MAX_SCSI_CMD_LEN); pss->cmd[0] = OBJECT_POSITION; pss->cmd[1] = 2; /* Absolute position used here to select the frame */ pss->cmd[4] = frame_no; status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->cmd, SET_FRAME_LEN, NULL, NULL); CHECK_STATUS (status, me, "snapscan_cmd"); return status; } static SANE_Status set_focus (SnapScan_Scanner *pss, SANE_Int focus) { static const char *me = "set_focus"; SANE_Status status; DBG (DL_CALL_TRACE, "%s(%d)\n", me, focus); zero_buf (pss->cmd, MAX_SCSI_CMD_LEN); pss->cmd[0] = OBJECT_POSITION; pss->cmd[1] = 4; /* Rotate object but here it sets the focus point */ pss->cmd[3] = (focus >> 8) & 0xFF; pss->cmd[4] = focus & 0xFF; status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->cmd, SET_FRAME_LEN, NULL, NULL); CHECK_STATUS (status, me, "snapscan_cmd"); return status; } static SANE_Int get_8 (u_char *p) { SANE_Int b; b = p[0] | (p[1] << 8); return b; } static double get_val (u_char *p, SANE_Int len, SANE_Int x) { return get_8 (p + ((x + len) << 1)) / 255.0; } static double sum_pixel_differences (u_char *p, int len) { double v, m, s; SANE_Int i; s = 0; for (i = 0; i < len-1; i++) { v = get_val (p, len, i); m = get_val (p, len, i+1); s += fabs (v - m); } return s; } static SANE_Status scan (SnapScan_Scanner *pss) { static const char *me = "scan"; SANE_Status status; DBG (DL_CALL_TRACE, "%s\n", me); zero_buf (pss->cmd, MAX_SCSI_CMD_LEN); pss->cmd[0] = SCAN; status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->cmd, SCAN_LEN, NULL, NULL); CHECK_STATUS (status, me, "snapscan_cmd"); return status; } /* supported read operations */ #define READ_IMAGE 0x00 #define READ_TRANSTIME 0x80 /* number of bytes expected must be in pss->expected_read_bytes */ static SANE_Status scsi_read (SnapScan_Scanner *pss, u_char read_type) { static const char *me = "scsi_read"; SANE_Status status; DBG (DL_CALL_TRACE, "%s\n", me); zero_buf (pss->cmd, MAX_SCSI_CMD_LEN); pss->cmd[0] = READ; pss->cmd[2] = read_type; if (read_type == READ_TRANSTIME && pss->pdev->model == PERFECTION2480) pss->cmd[5] = 1; u_int_to_u_char3p (pss->expected_read_bytes, pss->cmd + 6); pss->read_bytes = pss->expected_read_bytes; status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->cmd, READ_LEN, pss->buf, &pss->read_bytes); CHECK_STATUS (status, me, "snapscan_cmd"); return status; } static SANE_Status get_focus (SnapScan_Scanner *pss) { static const char *me = "get_focus"; SANE_Int focus_point, max_focus_point; double sum, max; SANE_Status status; SnapScan_Scanner copy; copy = *pss; DBG (DL_CALL_TRACE, "%s\n", me); reserve_unit(©); status = set_window_autofocus (©); CHECK_STATUS (status, me, "set_window_autofocus"); status = inquiry (©); CHECK_STATUS (status, me, "inquiry"); status = scan (©); CHECK_STATUS (status, me, "scan"); status = set_frame (©, copy.frame_no); CHECK_STATUS (status, me, "set_frame"); DBG (DL_VERBOSE, "%s: Expected number of bytes for each read %d\n", me, (int)copy.bytes_per_line); DBG (DL_VERBOSE, "%s: Expected number of pixels per line %d\n", me, (int)copy.pixels_per_line); max_focus_point = -1; max = -1; for (focus_point = 0; focus_point <= 0x300; focus_point += 6) { status = set_focus (©, focus_point); CHECK_STATUS (status, me, "set_focus"); copy.expected_read_bytes = copy.bytes_per_line; status = scsi_read (©, READ_IMAGE); CHECK_STATUS (status, me, "scsi_read"); sum = sum_pixel_differences (copy.buf, copy.pixels_per_line); if (sum > max) { max = sum; max_focus_point = focus_point; } } pss->focus = max_focus_point; DBG (DL_VERBOSE, "%s: Focus point found to be at 0x%x\n", me, max_focus_point); release_unit (©); wait_scanner_ready (©); CHECK_STATUS (status, me, "wait_scanner_ready"); return status; } /* static SANE_Status request_sense (SnapScan_Scanner *pss) { static const char *me = "request_sense"; size_t read_bytes = 0; u_char cmd[] = {REQUEST_SENSE, 0, 0, 0, 20, 0}; u_char data[20]; SANE_Status status; read_bytes = 20; DBG (DL_CALL_TRACE, "%s\n", me); status = snapscan_cmd (pss->pdev->bus, pss->fd, cmd, sizeof (cmd), data, &read_bytes); if (status != SANE_STATUS_GOOD) { DBG (DL_MAJOR_ERROR, "%s: scsi command error: %s\n", me, sane_strstatus (status)); } else { status = sense_handler (pss->fd, data, (void *) pss); } return status; } */ static SANE_Status send_diagnostic (SnapScan_Scanner *pss) { static const char *me = "send_diagnostic"; u_char cmd[] = {SEND_DIAGNOSTIC, 0x04, 0, 0, 0, 0}; /* self-test */ SANE_Status status; if (pss->pdev->model == PRISA620 || pss->pdev->model == PRISA610 || pss->pdev->model == SNAPSCAN1236 || pss->pdev->model == SCANWIT2720S || pss->pdev->model == ARCUS1200) { return SANE_STATUS_GOOD; } DBG (DL_CALL_TRACE, "%s\n", me); status = snapscan_cmd (pss->pdev->bus, pss->fd, cmd, sizeof (cmd), NULL, NULL); CHECK_STATUS (status, me, "snapscan_cmd"); return status; } static SANE_Status wait_scanner_ready (SnapScan_Scanner *pss) { static char me[] = "wait_scanner_ready"; SANE_Status status; int retries; DBG (DL_CALL_TRACE, "%s\n", me); /* if the tray is returning to the start position no time to wait is returned by the scanner. We'll try several times and sleep 1 second between each try. */ for (retries = 20; retries; retries--) { status = test_unit_ready (pss); switch (status) { case SANE_STATUS_GOOD: return status; case SANE_STATUS_DEVICE_BUSY: /* first additional sense byte contains time to wait */ { int delay = pss->asi1; if (delay > 0) { DBG (0, "Scanner warming up - waiting %d seconds.\n", delay); sleep (delay); } else { /* This seems to happen for Epson scanners. Return SANE_STATUS_GOOD and hope the scanner accepts the next command... */ DBG (DL_CALL_TRACE, "%s: No timeout specified, returning immediately\n", me); return SANE_STATUS_GOOD; } } break; case SANE_STATUS_IO_ERROR: /* hardware error; bail */ DBG (DL_MAJOR_ERROR, "%s: hardware error detected.\n", me); return status; case SANE_STATUS_JAMMED: case SANE_STATUS_NO_DOCS: return status; default: DBG (DL_MAJOR_ERROR, "%s: unhandled request_sense result; trying again.\n", me); break; } } return status; } #define READ_CALIBRATION 0x82 #define READ_CALIBRATION_BLACK 0x89 #define NUM_CALIBRATION_LINES 16 #define NUM_CALIBRATION_LINES_EPSON 48 #define NUM_CALIBRATION_LINES_EPSON_BLACK 128 static SANE_Status calibrate_epson (SnapScan_Scanner *pss) { u_char *buf, *pbuf; int *bins; static const char *me = "calibrate_epson"; /* pixels_per_line = 8.5 inch * resolution of one sensor */ int pixels_per_line = pss->actual_res * 17/4; int num_bins = pixels_per_line; int i, j, k, loop_inc, tl; int r, g, b; size_t expected_read_bytes; size_t read_bytes; SANE_Status status; int pass; int cal_lines = NUM_CALIBRATION_LINES_EPSON; int dtc = READ_CALIBRATION; int bytes_per_bin = 1; /* in 16 bit mode we get two bytes of cal data per bin */ if (pss->bpp_scan == 16) bytes_per_bin = 2; /* calculate number of bins depending on mode and resolution * colour mode requires bins for each of rgb * full resolution doubles it because of second sensor line */ if (is_colour_mode(actual_mode(pss))) { num_bins *= 3; } if (pss->res >= (SANE_Int)pss->actual_res) { num_bins *= 2; } /* allocate memory for bins, all the red, then green, then blue */ bins = (int *) malloc (num_bins * sizeof (int)); if (!bins) { DBG (DL_MAJOR_ERROR, "%s: out of memory allocating bins, %ld bytes.", me, (u_long)num_bins * sizeof (int)); return SANE_STATUS_NO_MEM; } /* allocate buffer for receive data */ expected_read_bytes = pixels_per_line * 3 * 4; buf = (u_char *) malloc (expected_read_bytes); if (!buf) { DBG (DL_MAJOR_ERROR, "%s: out of memory allocating calibration, %ld bytes.", me, (u_long)expected_read_bytes); free (bins); return SANE_STATUS_NO_MEM; } loop_inc = expected_read_bytes / (num_bins * bytes_per_bin); /* do two passes, first pass does basic calibration, second does transparency adaptor if in use */ for (pass = 0; pass < 2; pass++) { if (pass == 1) { if (pss->source == SRC_TPO) { /* pass 1 is for black level calibration of transparency adaptor */ cal_lines = NUM_CALIBRATION_LINES_EPSON_BLACK; dtc = READ_CALIBRATION_BLACK; } else continue; } /* empty the bins */ for (i = 0; i < num_bins; i++) bins[i] = 0; for (i = 0; i < cal_lines; i += loop_inc) { /* get the calibration data */ zero_buf (pss->cmd, MAX_SCSI_CMD_LEN); pss->cmd[0] = READ; pss->cmd[2] = dtc; pss->cmd[5] = cal_lines; if (cal_lines - i > loop_inc) expected_read_bytes = loop_inc * (num_bins * bytes_per_bin); else expected_read_bytes = (cal_lines - i) * (num_bins * bytes_per_bin); u_int_to_u_char3p (expected_read_bytes, pss->cmd + 6); read_bytes = expected_read_bytes; status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->cmd, READ_LEN, buf, &read_bytes); if (status != SANE_STATUS_GOOD) { DBG(DL_MAJOR_ERROR, "%s: %s command failed: %s\n", me, "read_cal_2480", sane_strstatus(status)); free (bins); free (buf); return status; } if (read_bytes != expected_read_bytes) { DBG (DL_MAJOR_ERROR, "%s: read %lu of %lu calibration data\n", me, (u_long) read_bytes, (u_long) expected_read_bytes); free (bins); free (buf); return SANE_STATUS_IO_ERROR; } /* add calibration results into bins */ pbuf = buf; for (j = 0; j < (int)expected_read_bytes / (num_bins * bytes_per_bin); j++) { for (k = 0; k < num_bins; k++) { bins[k] += *pbuf++; /* add in second byte for 16bit mode */ if (bytes_per_bin == 2) { bins[k] += *pbuf++ * 256; } } } } /* now make averages */ for (k = 0; k < num_bins; k++) { bins[k] /= cal_lines; /* also divide by 64 for 16bit mode */ if (bytes_per_bin == 2) bins[k] /= 64; } /* now fill up result buffer */ r = g = b = 0; /* create data to send back: start with r g b values, and follow with differences * to previous value */ pbuf = pss->buf + SEND_LENGTH; if (is_colour_mode(actual_mode(pss))) { for (k = 0; k < num_bins / 3; k++) { *pbuf++ = bins[k] - r; r = bins[k]; *pbuf++ = bins[k + num_bins/3] - g; g = bins[k + num_bins/3]; *pbuf++ = bins[k + 2*num_bins/3] - b; b = bins[k + 2*num_bins/3]; } } else { for (k = 0; k < num_bins; k++) { *pbuf++ = bins[k] - g; g = bins[k]; } } /* send back the calibration data; round up transfer length (to match windows driver) */ zero_buf (pss->buf, SEND_LENGTH); pss->buf[0] = SEND; pss->buf[2] = dtc; tl = (num_bins + 0xff) & ~0xff; u_int_to_u_char3p (tl, pss->buf + 6); status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->buf, SEND_LENGTH + tl, NULL, NULL); if (status != SANE_STATUS_GOOD) { DBG(DL_MAJOR_ERROR, "%s: %s command failed: %s\n", me, "send_cal_2480", sane_strstatus(status)); free (bins); free (buf); return status; } } free (bins); free (buf); return SANE_STATUS_GOOD; } static SANE_Status read_calibration_data (SnapScan_Scanner *pss, void *buf, u_char num_lines) { static const char *me = "read_calibration_data"; SANE_Status status; size_t expected_read_bytes = num_lines * calibration_line_length(pss); size_t read_bytes; DBG (DL_CALL_TRACE, "%s\n", me); zero_buf (pss->cmd, MAX_SCSI_CMD_LEN); pss->cmd[0] = READ; pss->cmd[2] = READ_CALIBRATION; pss->cmd[5] = num_lines; u_int_to_u_char3p (expected_read_bytes, pss->cmd + 6); read_bytes = expected_read_bytes; status = snapscan_cmd (pss->pdev->bus, pss->fd, pss->cmd, READ_LEN, buf, &read_bytes); CHECK_STATUS (status, me, "snapscan_cmd"); if(read_bytes != expected_read_bytes) { DBG (DL_MAJOR_ERROR, "%s: read %lu of %lu calibration data\n", me, (u_long) read_bytes, (u_long) expected_read_bytes); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } static SANE_Status calibrate (SnapScan_Scanner *pss) { int r; int c; u_char *buf; static const char *me = "calibrate"; SANE_Status status; int line_length = calibration_line_length(pss); if ((pss->pdev->model == PERFECTION2480) || (pss->pdev->model == PERFECTION3490)) { return calibrate_epson (pss); } if (pss->pdev->model == PRISA5150) { return send_calibration_5150(pss); } DBG (DL_CALL_TRACE, "%s\n", me); if (line_length) { int num_lines = pss->phys_buf_sz / line_length; if (num_lines > NUM_CALIBRATION_LINES) { num_lines = NUM_CALIBRATION_LINES; } else if (num_lines == 0) { DBG(DL_MAJOR_ERROR, "%s: scsi request size underflow (< %d bytes)", me, line_length); return SANE_STATUS_IO_ERROR; } buf = (u_char *) malloc(num_lines * line_length); if (!buf) { DBG (DL_MAJOR_ERROR, "%s: out of memory allocating calibration, %d bytes.", me, num_lines * line_length); return SANE_STATUS_NO_MEM; } DBG (DL_MAJOR_ERROR, "%s: reading calibration data (%d lines)\n", me, num_lines); status = read_calibration_data(pss, buf, num_lines); CHECK_STATUS(status, me, "read_calibration_data"); for(c=0; c < line_length; c++) { u_int sum = 0; for(r=0; r < num_lines; r++) { sum += buf[c + r * line_length]; } pss->buf[c + SEND_LENGTH] = sum / num_lines; } status = send (pss, DTC_CALIBRATION, 1); CHECK_STATUS(status, me, "send calibration"); free(buf); } return SANE_STATUS_GOOD; } static SANE_Status download_firmware(SnapScan_Scanner * pss) { static const char *me = "download_firmware"; unsigned char *pFwBuf, *pCDB; char* firmware = NULL; FILE *fd; size_t bufLength,cdbLength; SANE_Status status = SANE_STATUS_GOOD; char cModelName[8], cModel[255]; unsigned char bModelNo; bModelNo =*(pss->buf + INQUIRY_HWMI); zero_buf((unsigned char *)cModel, 255); sprintf(cModelName, "%d", bModelNo); DBG(DL_INFO, "Looking up %s\n", cModelName); if (pss->pdev->firmware_filename) { firmware = pss->pdev->firmware_filename; } else if (default_firmware_filename) { firmware = default_firmware_filename; } else { DBG (0, "%s: No firmware entry found in config file %s.\n", me, SNAPSCAN_CONFIG_FILE ); status = SANE_STATUS_INVAL; } if (status == SANE_STATUS_GOOD) { cdbLength = 10; DBG(DL_INFO, "Downloading %s\n", firmware); fd = fopen(firmware,"rb"); if(fd == NULL) { DBG (0, "Cannot open firmware file %s.\n", firmware); DBG (0, "Edit the firmware file entry in %s.\n", SNAPSCAN_CONFIG_FILE); status = SANE_STATUS_INVAL; } else { switch (pss->pdev->model) { case PRISA610: case PRISA310: case PRISA620: case PRISA1240: case PRISA640: case PRISA4300: case PRISA4300_2: case PRISA5000: case PRISA5000E: case PRISA5150: case PRISA5300: case STYLUS_CX1500: /* ACER firmware files do not contain an info block */ fseek(fd, 0, SEEK_END); bufLength = ftell(fd); fseek(fd, 0, SEEK_SET); break; case PERFECTION1270: case PERFECTION1670: case PERFECTION2480: case PERFECTION3490: /* Epson firmware files contain an info block which specifies the length of the firmware data. The length information is stored at offset 0x64 from end of file */ { unsigned char size_l, size_h; fseek(fd, -0x64, SEEK_END); fread(&size_l, 1, 1, fd); fread(&size_h, 1, 1, fd); fseek(fd, 0, SEEK_SET); bufLength = (size_h << 8) + size_l; } break; default: /* AGFA firmware files contain an info block which specifies the length of the firmware data. The length information is stored at offset 0x5e from end of file */ { unsigned char size_l, size_h; fseek(fd, -0x5e, SEEK_END); fread(&size_l, 1, 1, fd); fread(&size_h, 1, 1, fd); fseek(fd, 0, SEEK_SET); bufLength = (size_h << 8) + size_l; } break; } DBG(DL_INFO, "Size of firmware: %lu\n", (u_long) bufLength); pCDB = (unsigned char *)malloc(bufLength + cdbLength); pFwBuf = pCDB + cdbLength; zero_buf (pCDB, cdbLength); (void)fread(pFwBuf,1,bufLength,fd); *pCDB = SEND; *(pCDB + 2) = 0x87; *(pCDB + 6) = (bufLength >> 16) & 0xff; *(pCDB + 7) = (bufLength >> 8) & 0xff; *(pCDB + 8) = bufLength & 0xff; status = snapscan_cmd ( pss->pdev->bus, pss->fd, pCDB, bufLength+cdbLength, NULL, NULL); pss->firmware_loaded = SANE_TRUE; free(pCDB); fclose(fd); } } return status; } /* * $Log$ * Revision 1.58 2006/09/03 10:00:11 oliver-guest * Bugfix for firmware download by Paul Smedley * * Revision 1.57 2006/03/20 18:20:10 oliver-guest * Limit inquiry length to 120 bytes if firmware is not yet loaded * * Revision 1.56 2006/01/10 19:32:16 oliver-guest * Added 12 bit gamma tables for Epson Stylus CX-1500 * * Revision 1.55 2006/01/06 20:59:17 oliver-guest * Some fixes for the Epson Stylus CX 1500 * * Revision 1.54 2006/01/01 22:57:01 oliver-guest * Added calibration data for Benq 5150 / 5250, preliminary support for Epson Stylus CX 1500 * * Revision 1.53 2005/12/05 20:38:22 oliver-guest * Small bugfix for Benq 5150 * * Revision 1.52 2005/12/04 15:03:00 oliver-guest * Some fixes for Benq 5150 * * Revision 1.51 2005/11/26 18:53:03 oliver-guest * Fix inquiry bug for Benq 5000 * * Revision 1.50 2005/11/17 23:47:10 oliver-guest * Revert previous 'fix', disable 2400 dpi for Epson 3490, use 1600 dpi instead * * Revision 1.49 2005/11/17 23:32:22 oliver-guest * Fixes for Epson 3490 @ 2400 DPI * * Revision 1.48 2005/11/15 20:11:19 oliver-guest * Enabled quality calibration for the Epson 3490 * * Revision 1.47 2005/11/02 19:22:06 oliver-guest * Fixes for Benq 5000 * * Revision 1.46 2005/10/31 21:08:47 oliver-guest * Distinguish between Benq 5000/5000E/5000U * * Revision 1.45 2005/10/24 19:46:40 oliver-guest * Preview and range fix for Epson 2480/2580 * * Revision 1.44 2005/10/23 21:28:58 oliver-guest * Fix for buffer size in high res modes, fixes for delay code * * Revision 1.43 2005/10/20 21:23:53 oliver-guest * Fixes for 16 bit quality calibration by Simon Munton * * Revision 1.42 2005/10/13 22:43:30 oliver-guest * Fixes for 16 bit scan mode from Simon Munton * * Revision 1.41 2005/10/11 18:47:07 oliver-guest * Fixes for Epson 3490 and 16 bit scan mode * * Revision 1.40 2005/09/28 22:09:26 oliver-guest * Reenabled enhanced inquiry command for Epson scanners (duh\!) * * Revision 1.39 2005/09/28 21:33:10 oliver-guest * Added 16 bit option for Epson scanners (untested) * * Revision 1.38 2005/09/25 08:19:12 oliver-guest * Removed debugging code for Epson scanners * * Revision 1.37 2005/09/03 11:31:31 oliver-guest * Another small bugfix * * Revision 1.36 2005/09/03 10:52:11 oliver-guest * Fixed debugging code for epson scanners * * Revision 1.35 2005/08/16 17:19:20 oliver-guest * Make compileable again * * Revision 1.34 2005/08/15 18:56:55 oliver-guest * Added temporary debug code for 2480/2580 distinction * * Revision 1.33 2005/08/15 18:06:37 oliver-guest * Added support for Epson 3490/3590 (thanks to Matt Judge) * * Revision 1.32 2005/07/18 17:37:37 oliver-guest * ZETA changes for SnapScan backend * * Revision 1.31 2004/12/09 23:21:48 oliver-guest * Added quality calibration for Epson 2480 (by Simon Munton) * * Revision 1.30 2004/12/01 22:12:03 oliver-guest * Added support for Epson 1270 * * Revision 1.29 2004/10/03 17:34:36 hmg-guest * 64 bit platform fixes (bug #300799). * * Revision 1.28 2004/09/02 20:59:11 oliver-guest * Added support for Epson 2480 * * Revision 1.27 2004/04/02 20:19:24 oliver-guest * Various bugfixes for gamma corretion (thanks to Robert Tsien) * * Revision 1.26 2003/11/07 23:26:49 oliver-guest * Final bugfixes for bascic support of Epson 1670 * * Revision 1.25 2003/10/21 20:43:25 oliver-guest * Bugfixes for SnapScan backend * * Revision 1.24 2003/10/07 19:41:34 oliver-guest * Updates for Epson Perfection 1670 * * Revision 1.23 2003/08/19 21:05:08 oliverschwartz * Scanner ID cleanup * * Revision 1.22 2003/04/30 20:49:39 oliverschwartz * SnapScan backend 1.4.26 * * Revision 1.37 2003/04/30 20:42:19 oliverschwartz * Added support for Agfa Arcus 1200 (supplied by Valtteri Vuorikoski) * * Revision 1.36 2003/04/02 21:17:13 oliverschwartz * Fix for 1200 DPI with Acer 5000 * * Revision 1.35 2003/02/08 10:45:09 oliverschwartz * Use 600 DPI as optical resolution for Benq 5000 * * Revision 1.34 2002/12/10 20:14:12 oliverschwartz * Enable color offset correction for SnapScan300 * * Revision 1.33 2002/09/24 16:07:48 oliverschwartz * Added support for Benq 5000 * * Revision 1.32 2002/06/06 20:40:01 oliverschwartz * Changed default scan area for transparancy unit of SnapScan e50 * * Revision 1.31 2002/05/02 18:28:44 oliverschwartz * Added ADF support * * Revision 1.30 2002/04/27 14:41:22 oliverschwartz * Print number of open handles in close_scanner() * * Revision 1.29 2002/04/10 21:46:48 oliverschwartz * Removed illegal character * * Revision 1.28 2002/04/10 21:01:02 oliverschwartz * Disable send_diagnostic() for 1236s * * Revision 1.27 2002/03/24 12:11:20 oliverschwartz * Get name of firmware file in sane_init * * Revision 1.26 2002/01/23 20:42:41 oliverschwartz * Improve recognition of Acer 320U * Add sense_handler code for sense code 0x0b * Fix for spaces in model strings * * Revision 1.25 2001/12/12 19:44:59 oliverschwartz * Clean up CVS log * * Revision 1.24 2001/12/09 23:01:00 oliverschwartz * - use sense handler for USB * - fix scan mode * * Revision 1.23 2001/12/08 11:53:31 oliverschwartz * - Additional logging in sense handler * - Fix wait_scanner_ready() if device reports busy * - Fix scanning mode (preview/normal) * * Revision 1.22 2001/11/27 23:16:17 oliverschwartz * - Fix color alignment for SnapScan 600 * - Added documentation in snapscan-sources.c * - Guard against TL_X < BR_X and TL_Y < BR_Y * * Revision 1.21 2001/10/21 08:49:37 oliverschwartz * correct number of scan lines for calibration thanks to Mikko Ty���vi * * Revision 1.20 2001/10/12 20:54:04 oliverschwartz * enable gamma correction for Snapscan 1236, e20 and e50 scanners * * Revision 1.19 2001/10/11 14:02:10 oliverschwartz * Distinguish between e20/e25 and e40/e50 * * Revision 1.18 2001/10/09 22:34:23 oliverschwartz * fix compiler warnings * * Revision 1.17 2001/10/08 19:26:01 oliverschwartz * - Disable quality calibration for scanners that do not support it * * Revision 1.16 2001/10/08 18:22:01 oliverschwartz * - Disable quality calibration for Acer Vuego 310F * - Use sanei_scsi_max_request_size as scanner buffer size * for SCSI devices * - Added new devices to snapscan.desc * * Revision 1.15 2001/09/18 15:01:07 oliverschwartz * - Read scanner id string again after firmware upload * to indentify correct model * - Make firmware upload work for AGFA scanners * - Change copyright notice * * Revision 1.14 2001/09/17 10:01:08 sable * Added model AGFA 1236U * * Revision 1.13 2001/09/09 18:06:32 oliverschwartz * add changes from Acer (new models; automatic firmware upload for USB scanners); fix distorted colour scans after greyscale scans (call set_window only in sane_start); code cleanup * * Revision 1.12 2001/04/10 13:00:31 sable * Moving sanei_usb_* to snapscani_usb* * * Revision 1.11 2001/04/10 11:04:31 sable * Adding support for snapscan e40 an e50 thanks to Giuseppe Tanzilli * * Revision 1.10 2001/03/17 22:53:21 sable * Applying Mikael Magnusson patch concerning Gamma correction * Support for 1212U_2 * * Revision 1.9 2000/11/10 01:01:59 sable * USB (kind of) autodetection * * Revision 1.8 2000/11/01 01:26:43 sable * Support for 1212U * * Revision 1.7 2000/10/30 22:32:20 sable * Support for vuego310s vuego610s and 1236s * * Revision 1.6 2000/10/29 22:44:55 sable * Bug correction for 1236s * * Revision 1.5 2000/10/28 14:16:10 sable * Bug correction for SnapScan310 * * Revision 1.4 2000/10/28 14:06:35 sable * Add support for Acer300f * * Revision 1.3 2000/10/15 19:52:06 cbagwell * Changed USB support to a 1 line modification instead of multi-file * changes. * * Revision 1.2 2000/10/13 03:50:27 cbagwell * Updating to source from SANE 1.0.3. Calling this versin 1.1 * * */ sane-backends-1.0.29/backend/hp-hpmem.c0000666000000000000000000000745613615534521014463 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Geoffrey T. Dairiki 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP Scanners supporting HP Scanner Control Language (SCL). */ /* #define STUBS extern int sanei_debug_hp;*/ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include #include #include "../include/lassert.h" #include "hp.h" typedef struct hp_alloc_s Alloc; struct hp_alloc_s { Alloc * prev; Alloc * next; hp_byte_t buf[1]; }; static Alloc head[] = {{ head, head, {0} }}; #define DATA_OFFSET (head->buf - (hp_byte_t *)head) #define VOID_TO_ALLOCP(p) ((Alloc *)((hp_byte_t *)(p) - DATA_OFFSET)) #define ALLOCSIZE(sz) (sz + DATA_OFFSET) void * sanei_hp_alloc (size_t sz) { Alloc * new = malloc(ALLOCSIZE(sz)); if (!new) return 0; (new->next = head->next)->prev = new; (new->prev = head)->next = new; return new->buf; } void * sanei_hp_allocz (size_t sz) { void * new = sanei_hp_alloc(sz); if (!new) return 0; memset(new, 0, sz); return new; } void * sanei_hp_memdup (const void * src, size_t sz) { char * new = sanei_hp_alloc(sz); if (!new) return 0; return memcpy(new, src, sz); } char * sanei_hp_strdup (const char * str) { return sanei_hp_memdup(str, strlen(str) + 1); } void * sanei_hp_realloc (void * ptr, size_t sz) { if (ptr) { Alloc * old = VOID_TO_ALLOCP(ptr); Alloc copy = *old; Alloc * new = realloc(old, ALLOCSIZE(sz)); if (!new) return 0; if (new != old) (new->prev = copy.prev)->next = (new->next = copy.next)->prev = new; return new->buf; } else return sanei_hp_alloc(sz); } void sanei_hp_free (void * ptr) { Alloc * old = VOID_TO_ALLOCP(ptr); assert(old && old != head); (old->next->prev = old->prev)->next = old->next; old->next = old->prev = 0; /* so we can puke on multiple free's */ free(old); } void sanei_hp_free_all (void) { Alloc * ptr; Alloc * next; for (ptr = head->next; ptr != head; ptr = next) { next = ptr->next; free(ptr); } head->next = head->prev = head; } sane-backends-1.0.29/backend/p5.h0000666000000000000000000001256113615534521013272 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2009-2012 stef.dev@free.fr 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** @file p5.h * @brief Declaration of high level structures used by the p5 backend. * * The structures and functions declared here are used to do the deal with * the SANE API. */ #ifndef P5_H #define P5_H #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_backend.h" /**< macro to enable an option */ #define ENABLE(OPTION) session->options[OPTION].descriptor.cap &= ~SANE_CAP_INACTIVE /**< macro to disable an option */ #define DISABLE(OPTION) session->options[OPTION].descriptor.cap |= SANE_CAP_INACTIVE /** macro to test is an option is active */ #define IS_ACTIVE(OPTION) (((s->opt[OPTION].cap) & SANE_CAP_INACTIVE) == 0) /**< name of the configuration file */ #define P5_CONFIG_FILE "p5.conf" /**< macro to define texts that should translated */ #ifndef SANE_I18N #define SANE_I18N(text) text #endif /** color mode names */ /* @{ */ #define COLOR_MODE "Color" #define GRAY_MODE "Gray" #define LINEART_MODE "Lineart" /* @} */ #include "p5_device.h" /** * List of all SANE options available for the frontend. Given a specific * device, some options may be set to inactive when the scanner model is * detected. The default values and the ranges they belong maybe also model * dependent. */ enum P5_Options { OPT_NUM_OPTS = 0, /** first enum which must be zero */ /** @name standard options group */ /* @{ */ OPT_STANDARD_GROUP, OPT_MODE, /** set the mode: color, grey levels or lineart */ OPT_PREVIEW, /** set up for preview */ OPT_RESOLUTION, /** set scan's resolution */ /* @} */ /** @name geometry group * geometry related options */ /* @{ */ OPT_GEOMETRY_GROUP, /** group of options defining the position and size of the scanned area */ OPT_TL_X, /** top-left x of the scanned area*/ OPT_TL_Y, /** top-left y of the scanned area*/ OPT_BR_X, /** bottom-right x of the scanned area*/ OPT_BR_Y, /** bottom-right y of the scanned area*/ /* @} */ /** @name sensor group * detectors group */ /* @{ */ OPT_SENSOR_GROUP, OPT_PAGE_LOADED_SW, OPT_NEED_CALIBRATION_SW, /* @} */ /** @name button group * buttons group */ /* @{ */ OPT_BUTTON_GROUP, OPT_CALIBRATE, OPT_CLEAR_CALIBRATION, /* @} */ /** @name option list terminator * must come last so it can be used for array and list size */ NUM_OPTIONS }; /** * Contains one SANE option description and its value. */ typedef struct P5_Option { SANE_Option_Descriptor descriptor; /** option description */ Option_Value value; /** option value */ } P5_Option; /** * Frontend session. This struct holds informations usefull for * the functions defined in SANE's standard. Informations closer * to the hardware are in the P5_Device structure. There is * as many session structure than frontends using the backend. */ typedef struct P5_Session { /** * Point to the next session in a linked list */ struct P5_Session *next; /** * low-level device object used by the session */ P5_Device *dev; /** * array of possible options and their values for the backend */ P5_Option options[NUM_OPTIONS]; /** * SANE_True if a scan is in progress, ie sane_start has been called. * Stay SANE_True until sane_cancel() is called. */ SANE_Bool scanning; /** @brief non blocking flag * SANE_TRUE if sane_read are non-blocking, ie returns immediatly if there * is no data available from the scanning device. Modified by sane_set_io_mode() */ SANE_Bool non_blocking; /** * SANE Parameters describes what the next or current scan will be * according to the current values of the options */ SANE_Parameters params; /** * bytes to send to frontend for the scan */ SANE_Int to_send; /** * bytes currently sent to frontend during the scan */ SANE_Int sent; } P5_Session; static SANE_Status probe_p5_devices (void); static P5_Model *probe (const char *devicename); static SANE_Status config_attach (SANEI_Config * config, const char *devname); static SANE_Status attach_p5 (const char *name, SANEI_Config * config); static SANE_Status init_options (struct P5_Session *session); static SANE_Status compute_parameters (struct P5_Session *session); /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ #endif /* not P5_H */ sane-backends-1.0.29/backend/mustek_usb2_reflective.c0000666000000000000000000014464313615534521017423 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2005 Mustek. Originally maintained by Mustek Author:Jack Roy 2005.5.24 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for the Mustek BearPaw 2448 TA Pro and similar USB2 scanners. */ /* forward declarations */ static SANE_Bool Reflective_Reset (void); static SANE_Bool Reflective_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest); static SANE_Bool Reflective_SetupScan (COLORMODE ColorMode, unsigned short XDpi, unsigned short YDpi, SANE_Bool isInvert, unsigned short X, unsigned short Y, unsigned short Width, unsigned short Height); static SANE_Bool Reflective_StopScan (void); static SANE_Bool Reflective_GetRows (SANE_Byte * lpBlock, unsigned short * Rows, SANE_Bool isOrderInvert); static SANE_Bool Reflective_AdjustAD (void); static SANE_Bool Reflective_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY); static SANE_Bool Reflective_LineCalibration16Bits (void); static SANE_Bool Reflective_PrepareScan (void); /*function description*/ /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: reset the scanner status Parameters: none Return value: if operation is success return TRUE els return FALSE ***********************************************************************/ static SANE_Bool Reflective_Reset () { DBG (DBG_FUNC, "Reflective_Reset: call in\n"); if (g_bOpened) { DBG (DBG_FUNC, "Reflective_Reset: scanner has been opened\n"); return FALSE; } if (STATUS_GOOD != Asic_Open (&g_chip, g_pDeviceFile)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_Open return error\n"); return FALSE; } if (STATUS_GOOD != Asic_Reset (&g_chip)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_Reset return error\n"); return FALSE; } if (STATUS_GOOD != Asic_SetSource (&g_chip, LS_REFLECTIVE)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_SetSource return error\n"); return FALSE; } if (STATUS_GOOD != Asic_TurnLamp (&g_chip, TRUE)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_TurnLamp return error\n"); return FALSE; } if (STATUS_GOOD != Asic_Close (&g_chip)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_Close return error\n"); return FALSE; } g_Y = 0; g_X = 0; g_Width = 0; g_SWWidth = 0; g_Height = 0; g_SWHeight = 0; g_wLineartThreshold = 128; g_dwTotalTotalXferLines = 0; g_bFirstReadImage = TRUE; g_pGammaTable = NULL; if (NULL != g_pDeviceFile) { free (g_pDeviceFile); g_pDeviceFile = NULL; } DBG (DBG_FUNC, "Reflective_Reset: exit\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: get the suggest parameter of scaning Parameters: pTarget: the information of scaning pSuggest: suggest parameter of scaning Return value: if the operation is success return TRUE els return FALSE ***********************************************************************/ static SANE_Bool Reflective_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest) { int i; unsigned short wMaxWidth, wMaxHeight; DBG (DBG_FUNC, "Reflective_ScanSuggest: call in\n"); if (NULL == pTarget || NULL == pSuggest) { DBG (DBG_FUNC, "Reflective_ScanSuggest: parameters error\n"); return FALSE; } /*1. Looking up Optical Y Resolution */ for (i = 0; s_wOpticalYDpi[i] != 0; i++) { if (s_wOpticalYDpi[i] <= pTarget->wDpi) { pSuggest->wYDpi = s_wOpticalYDpi[i]; break; } } if (s_wOpticalYDpi[i] == 0) { i--; pSuggest->wYDpi = s_wOpticalYDpi[i]; } /*2. Looking up Optical X Resolution */ for (i = 0; s_wOpticalXDpi[i] != 0; i++) { if (s_wOpticalXDpi[i] <= pTarget->wDpi) { pSuggest->wXDpi = s_wOpticalXDpi[i]; break; } } if (s_wOpticalXDpi[i] == 0) { i--; pSuggest->wXDpi = s_wOpticalXDpi[i]; } DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wDpi = %d\n", pTarget->wDpi); DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wXDpi = %d\n", pSuggest->wXDpi); DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wYDpi = %d\n", pSuggest->wYDpi); /*3. suggest scan area */ pSuggest->wX = (unsigned short) (((unsigned int) (pTarget->wX) * (unsigned int) (pSuggest->wXDpi)) / (unsigned int) (pTarget->wDpi)); pSuggest->wY = (unsigned short) (((unsigned int) (pTarget->wY) * (unsigned int) (pSuggest->wYDpi)) / (unsigned int) (pTarget->wDpi)); pSuggest->wWidth = (unsigned short) (((unsigned int) (pTarget->wWidth) * (unsigned int) (pSuggest->wXDpi)) / (unsigned int) (pTarget->wDpi)); pSuggest->wHeight = (unsigned short) (((unsigned int) (pTarget->wHeight) * (unsigned int) (pSuggest->wYDpi)) / (unsigned int) (pTarget->wDpi)); pSuggest->wWidth = (pSuggest->wWidth / 2) * 2; DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wX = %d\n", pTarget->wX); DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wY = %d\n", pTarget->wY); DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wWidth = %d\n", pTarget->wWidth); DBG (DBG_FUNC, "Reflective_ScanSuggest: pTarget->wHeight = %d\n", pTarget->wHeight); DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wX = %d\n", pSuggest->wX); DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wY = %d\n", pSuggest->wY); DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wWidth = %d\n", pSuggest->wWidth); DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->wHeight = %d\n", pSuggest->wHeight); if (pTarget->cmColorMode == CM_TEXT) { pSuggest->wWidth = ((pSuggest->wWidth + 7) >> 3) << 3; if (pSuggest->wWidth < 8) pSuggest->wWidth = 8; } /*4. check width and height */ wMaxWidth = (MAX_SCANNING_WIDTH * pSuggest->wXDpi) / 300; wMaxHeight = (3480 * pSuggest->wYDpi) / 300; /* 3480 for bumping */ DBG (DBG_FUNC, "Reflective_ScanSuggest: wMaxWidth = %d\n", wMaxWidth); DBG (DBG_FUNC, "Reflective_ScanSuggest: wMaxHeight = %d\n", wMaxHeight); if (CM_TEXT == pTarget->cmColorMode) { wMaxWidth = (wMaxWidth >> 3) << 3; } if (pSuggest->wWidth > wMaxWidth) { pSuggest->wWidth = wMaxWidth; } if (pSuggest->wHeight > wMaxHeight) { pSuggest->wHeight = wMaxHeight; } DBG (DBG_FUNC, "Reflective_ScanSuggest: g_Width=%d\n", g_Width); g_Width = ((pSuggest->wWidth + 15) >> 4) << 4; /*Real Scan Width */ DBG (DBG_FUNC, "Reflective_ScanSuggest: again, g_Width=%d\n", g_Width); g_Height = pSuggest->wHeight; if (pTarget->isOptimalSpeed) { switch (pTarget->cmColorMode) { case CM_RGB48: pSuggest->cmScanMode = CM_RGB48; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6); break; case CM_RGB24: pSuggest->cmScanMode = CM_RGB24ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3); break; case CM_GRAY16: pSuggest->cmScanMode = CM_GRAY16ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2); break; case CM_GRAY8: pSuggest->cmScanMode = CM_GRAY8ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth)); break; case CM_TEXT: pSuggest->cmScanMode = CM_TEXT; pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8; break; default: break; } } else { switch (pTarget->cmColorMode) { case CM_RGB48: pSuggest->cmScanMode = CM_RGB48; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6); break; case CM_RGB24: pSuggest->cmScanMode = CM_RGB24ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3); break; case CM_GRAY16: pSuggest->cmScanMode = CM_GRAY16ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2); break; case CM_GRAY8: pSuggest->cmScanMode = CM_GRAY8ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth)); break; case CM_TEXT: pSuggest->cmScanMode = CM_TEXT; pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8; break; default: break; } } DBG (DBG_FUNC, "Reflective_ScanSuggest: pSuggest->dwBytesPerRow = %d\n", pSuggest->dwBytesPerRow); DBG (DBG_FUNC, "Reflective_ScanSuggest: leave Reflective_ScanSuggest\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: setup scanning process Parameters: ColorMode: ScanMode of Scanning, CM_RGB48, CM_GRAY and so on XDpi: X Resolution YDpi: Y Resolution isInvert: the RGB order X: X start coordinate Y: Y start coordinate Width: Width of Scan Image Height: Height of Scan Image Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Reflective_SetupScan (COLORMODE ColorMode, unsigned short XDpi, unsigned short YDpi, SANE_Bool isInvert, unsigned short X, unsigned short Y, unsigned short Width, unsigned short Height) { isInvert = isInvert; DBG (DBG_FUNC, "Reflective_SetupScan: Call in\n"); if (g_bOpened) { DBG (DBG_FUNC, "Reflective_SetupScan: scanner has been opened\n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Reflective_SetupScan: scanner not prepared\n"); return FALSE; } g_ScanMode = ColorMode; g_XDpi = XDpi; g_YDpi = YDpi; g_SWWidth = Width; g_SWHeight = Height; switch (g_YDpi) { case 1200: g_wPixelDistance = 4; /*even & odd sensor problem */ g_wLineDistance = 24; g_Height += g_wPixelDistance; break; case 600: g_wPixelDistance = 0; /*no even & odd problem */ g_wLineDistance = 12; break; case 300: g_wPixelDistance = 0; g_wLineDistance = 6; break; case 150: g_wPixelDistance = 0; g_wLineDistance = 3; break; case 75: case 50: g_wPixelDistance = 0; g_wLineDistance = 1; break; default: g_wLineDistance = 0; } switch (g_ScanMode) { case CM_RGB48: g_BytesPerRow = 6 * g_Width; g_SWBytesPerRow = 6 * g_SWWidth; g_bScanBits = 48; g_Height += g_wLineDistance * 2; /*add height to do line distance */ break; case CM_RGB24ext: g_BytesPerRow = 3 * g_Width; g_SWBytesPerRow = 3 * g_SWWidth; g_bScanBits = 24; g_Height += g_wLineDistance * 2; /*add height to do line distance */ break; case CM_GRAY16ext: g_BytesPerRow = 2 * g_Width; g_SWBytesPerRow = 2 * g_SWWidth; g_bScanBits = 16; break; case CM_GRAY8ext: case CM_TEXT: g_BytesPerRow = g_Width; g_SWBytesPerRow = g_SWWidth; g_bScanBits = 8; break; default: break; } if (Asic_Open (&g_chip, g_pDeviceFile) != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_SetupScan: Asic_Open return error\n"); return FALSE; } DBG (DBG_FUNC, "Reflective_SetupScan: Asic_Open successfully\n"); g_bOpened = TRUE; Asic_TurnLamp (&g_chip, FALSE); Asic_TurnTA (&g_chip, FALSE); Asic_TurnLamp (&g_chip, TRUE); if (1200 == g_XDpi) { g_XDpi = 600; if (Reflective_AdjustAD () == FALSE) { DBG (DBG_FUNC, "Reflective_SetupScan: Reflective_AdjustAD return error\n"); return FALSE; } DBG (DBG_FUNC, "Reflective_SetupScan: Reflective_AdjustAD successfully\n"); if (Reflective_FindTopLeft (&g_X, &g_Y) == FALSE) { g_X = 187; g_Y = 43; } g_XDpi = 1200; if (Reflective_AdjustAD () == FALSE) { DBG (DBG_FUNC, "Reflective_SetupScan: Reflective_AdjustAD return error\n"); return FALSE; } DBG (DBG_FUNC, "Reflective_SetupScan: Reflective_AdjustAD successfully\n"); } else { if (Reflective_AdjustAD () == FALSE) { DBG (DBG_FUNC, "Reflective_SetupScan: Reflective_AdjustAD return error\n"); return FALSE; } DBG (DBG_FUNC, "Reflective_SetupScan: Reflective_AdjustAD successfully\n"); if (Reflective_FindTopLeft (&g_X, &g_Y) == FALSE) { g_X = 187; g_Y = 43; } } DBG (DBG_FUNC, "after find top left,g_X=%d,g_Y=%d\n", g_X, g_Y); if (1200 == g_XDpi) { g_X = g_X * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + X * 1200 / g_XDpi + 47; } else { if (75 == g_XDpi) { g_X = g_X + X * 600 / g_XDpi; } else { g_X = g_X + X * 600 / g_XDpi + 23; } } g_Y = g_Y * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + Y * 1200 / g_YDpi + 47; DBG (DBG_FUNC, "before line calibration,g_X=%d,g_Y=%d\n", g_X, g_Y); if (Reflective_LineCalibration16Bits () == FALSE) { DBG (DBG_FUNC, "Reflective_SetupScan: Reflective_LineCalibration16Bits return error\n"); return FALSE; } DBG (DBG_FUNC, "Reflective_SetupScan: after Reflective_LineCalibration16Bits,g_X=%d,g_Y=%d\n", g_X, g_Y); DBG (DBG_FUNC, "Reflective_SetupScan: before Asic_SetWindow\n"); DBG (DBG_FUNC, "Reflective_SetupScan: g_bScanBits=%d, g_XDpi=%d, g_YDpi=%d, g_X=%d, g_Y=%d, g_Width=%d, g_Height=%d\n", g_bScanBits, g_XDpi, g_YDpi, g_X, g_Y, g_Width, g_Height); if (g_Y > 300) { Asic_MotorMove (&g_chip, TRUE, g_Y - 300); } else { Asic_MotorMove (&g_chip, FALSE, 300 - g_Y); } g_Y = 300; Asic_SetWindow (&g_chip, g_bScanBits, g_XDpi, g_YDpi, g_X, g_Y, g_Width, g_Height); DBG (DBG_FUNC, "Reflective_SetupScan: leave Reflective_SetupScan\n"); return Reflective_PrepareScan (); } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: To adjust the value of offset gain of R/G/B Parameters: none Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Reflective_AdjustAD () { SANE_Byte * lpCalData; unsigned short wCalWidth; int nTimesOfCal; unsigned short wMaxValueR, wMinValueR, wMaxValueG, wMinValueG, wMaxValueB, wMinValueB; #if 0 SANE_Byte bDarkMaxLevel; SANE_Byte bDarkMinLevel; SANE_Byte bLastMinR, bLastROffset, bROffsetUpperBound = 255, bROffsetLowerBound = 0; SANE_Byte bLastMinG, bLastGOffset, bGOffsetUpperBound = 255, bGOffsetLowerBound = 0; SANE_Byte bLastMinB, bLastBOffset, bBOffsetUpperBound = 255, bBOffsetLowerBound = 0; float fRFactor = 1.0; float fGFactor = 1.0; float fBFactor = 1.0; #endif unsigned short wAdjustADResolution; DBG (DBG_FUNC, "Reflective_AdjustAD: call in\n"); if (!g_bOpened) { DBG (DBG_FUNC, "Reflective_AdjustAD: scanner has been opened\n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Reflective_AdjustAD: scanner not prepared\n"); return FALSE; } g_chip.AD.DirectionR = R_DIRECTION; g_chip.AD.DirectionG = G_DIRECTION; g_chip.AD.DirectionB = B_DIRECTION; g_chip.AD.GainR = R_GAIN; g_chip.AD.GainG = G_GAIN; g_chip.AD.GainB = B_GAIN; g_chip.AD.OffsetR = 152; g_chip.AD.OffsetG = 56; g_chip.AD.OffsetB = 8; if (g_XDpi <= 600) { wAdjustADResolution = 600; } else { wAdjustADResolution = 1200; } wCalWidth = 10240; lpCalData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * wCalWidth * 3); if (lpCalData == NULL) { DBG (DBG_FUNC, "Reflective_AdjustAD: lpCalData malloc error\n"); return FALSE; } Asic_SetMotorType (&g_chip, FALSE, TRUE); Asic_SetCalibrate (&g_chip, 24, wAdjustADResolution, wAdjustADResolution, 0, 0, wCalWidth, 1, FALSE); MustScanner_PrepareCalculateMaxMin (wAdjustADResolution); nTimesOfCal = 0; #ifdef DEBUG_SAVE_IMAGE Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpCalData, wCalWidth * 3, 24); Asic_ScanStop (&g_chip); FILE *stream = NULL; SANE_Byte * lpBuf = (SANE_Byte *) malloc (50); if (NULL == lpBuf) { return FALSE; } memset (lpBuf, 0, 50); stream = fopen ("/root/AD(Ref).pnm\n", "wb+\n"); sprintf (lpBuf, "P6\n%d %d\n255\n\n", wCalWidth, 1); fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream); fwrite (lpCalData, sizeof (SANE_Byte), wCalWidth * 3, stream); fclose (stream); free (lpBuf); #endif do { DBG (DBG_FUNC, "Reflective_AdjustAD: run in first adjust offset do-while\n"); Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpCalData, wCalWidth * 3, 24); Asic_ScanStop (&g_chip); MustScanner_CalculateMaxMin (lpCalData, &wMaxValueR, &wMinValueR, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth, &wMaxValueG, &wMinValueG, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth * 2, &wMaxValueB, &wMinValueB, wAdjustADResolution); if (g_chip.AD.DirectionR == 0) { if (wMinValueR > 15) { if (g_chip.AD.OffsetR < 8) g_chip.AD.DirectionR = 1; else g_chip.AD.OffsetR -= 8; } else if (wMinValueR < 5) g_chip.AD.OffsetR += 8; } else { if (wMinValueR > 15) g_chip.AD.OffsetR += 8; else if (wMinValueR < 5) g_chip.AD.OffsetR -= 8; } if (g_chip.AD.DirectionG == 0) { if (wMinValueG > 15) { if (g_chip.AD.OffsetG < 8) g_chip.AD.DirectionG = 1; else g_chip.AD.OffsetG -= 8; } else if (wMinValueG < 5) g_chip.AD.OffsetG += 8; } else { if (wMinValueG > 15) g_chip.AD.OffsetG += 8; else if (wMinValueG < 5) g_chip.AD.OffsetG -= 8; } if (g_chip.AD.DirectionB == 0) { if (wMinValueB > 15) { if (g_chip.AD.OffsetB < 8) g_chip.AD.DirectionB = 1; else g_chip.AD.OffsetB -= 8; } else if (wMinValueB < 5) g_chip.AD.OffsetB += 8; } else { if (wMinValueB > 15) g_chip.AD.OffsetB += 8; else if (wMinValueB < 5) g_chip.AD.OffsetB -= 8; } nTimesOfCal++; if (nTimesOfCal > 10) break; } while (wMinValueR > 15 || wMinValueR < 5 || wMinValueG > 15 || wMinValueG < 5 || wMinValueB > 15 || wMinValueB < 5); DBG (DBG_FUNC, "Reflective_AdjustAD: run out first adjust offset do-while\n"); DBG (DBG_FUNC, "Reflective_AdjustAD: \ g_chip.AD.OffsetR=%d,\ g_chip.AD.OffsetG=%d,\ g_chip.AD.OffsetB=%d\n", g_chip.AD.OffsetR, g_chip.AD.OffsetG, g_chip.AD.OffsetB); g_chip.AD.GainR = 1 - (double) (wMaxValueR - wMinValueR) / 210 > 0 ? (SANE_Byte) (((1 - (double) (wMaxValueR - wMinValueR) / 210)) * 63 * 6 / 5) : 0; g_chip.AD.GainG = 1 - (double) (wMaxValueG - wMinValueG) / 210 > 0 ? (SANE_Byte) (((1 - (double) (wMaxValueG - wMinValueG) / 210)) * 63 * 6 / 5) : 0; g_chip.AD.GainB = 1 - (double) (wMaxValueB - wMinValueB) / 210 > 0 ? (SANE_Byte) (((1 - (double) (wMaxValueB - wMinValueB) / 210)) * 63 * 6 / 5) : 0; if (g_chip.AD.GainR > 63) g_chip.AD.GainR = 63; if (g_chip.AD.GainG > 63) g_chip.AD.GainG = 63; if (g_chip.AD.GainB > 63) g_chip.AD.GainB = 63; DBG (DBG_FUNC, "Reflective_AdjustAD: " "g_chip.AD.GainR = %d," "g_chip.AD.GainG = %d," "g_chip.AD.GainB = %d\n", g_chip.AD.GainR, g_chip.AD.GainG, g_chip.AD.GainB); nTimesOfCal = 0; do { Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpCalData, wCalWidth * 3, 24); Asic_ScanStop (&g_chip); MustScanner_CalculateMaxMin (lpCalData, &wMaxValueR, &wMinValueR, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth, &wMaxValueG, &wMinValueG, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth * 2, &wMaxValueB, &wMinValueB, wAdjustADResolution); DBG (DBG_FUNC, "Reflective_AdjustAD: " "RGain=%d, ROffset=%d, RDir=%d GGain=%d, GOffset=%d, GDir=%d BGain=%d, BOffset=%d, BDir=%d\n", g_chip.AD.GainR, g_chip.AD.OffsetR, g_chip.AD.DirectionR, g_chip.AD.GainG, g_chip.AD.OffsetG, g_chip.AD.DirectionG, g_chip.AD.GainB, g_chip.AD.OffsetB, g_chip.AD.DirectionB); DBG (DBG_FUNC, "Reflective_AdjustAD: " "MaxR=%d, MinR=%d MaxG=%d, MinG=%d MaxB=%d, MinB=%d\n", wMaxValueR, wMinValueR, wMaxValueG, wMinValueG, wMaxValueB, wMinValueB); /*R Channel */ if ((wMaxValueR - wMinValueR) > REFL_MAX_LEVEL_RANGE) { if (g_chip.AD.GainR > 0) g_chip.AD.GainR--; } else { if ((wMaxValueR - wMinValueR) < REFL_MIN_LEVEL_RANGE) { if (wMaxValueR < REFL_WHITE_MIN_LEVEL) { g_chip.AD.GainR++; if (g_chip.AD.GainR > 63) g_chip.AD.GainR = 63; } else { if (wMaxValueR > REFL_WHITE_MAX_LEVEL) { if (g_chip.AD.GainR < 1) g_chip.AD.GainR = 0; else g_chip.AD.GainR--; } else { if (g_chip.AD.GainR > 63) g_chip.AD.GainR = 63; else g_chip.AD.GainR++; } } } else { if (wMaxValueR > REFL_WHITE_MAX_LEVEL) { if (g_chip.AD.GainR < 1) g_chip.AD.GainR = 0; else g_chip.AD.GainR--; } if (wMaxValueR < REFL_WHITE_MIN_LEVEL) { if (g_chip.AD.GainR > 63) g_chip.AD.GainR = 63; else g_chip.AD.GainR++; } } } /*G Channel */ if ((wMaxValueG - wMinValueG) > REFL_MAX_LEVEL_RANGE) { if (g_chip.AD.GainG > 0) g_chip.AD.GainG--; } else { if ((wMaxValueG - wMinValueG) < REFL_MIN_LEVEL_RANGE) { if (wMaxValueG < REFL_WHITE_MIN_LEVEL) { g_chip.AD.GainG++; if (g_chip.AD.GainG > 63) g_chip.AD.GainG = 63; } else { if (wMaxValueG > REFL_WHITE_MAX_LEVEL) { if (g_chip.AD.GainG < 1) g_chip.AD.GainG = 0; else g_chip.AD.GainG--; } else { if (g_chip.AD.GainG > 63) g_chip.AD.GainG = 63; else g_chip.AD.GainG++; } } } else { if (wMaxValueG > REFL_WHITE_MAX_LEVEL) { if (g_chip.AD.GainG < 1) g_chip.AD.GainG = 0; else g_chip.AD.GainG--; } if (wMaxValueG < REFL_WHITE_MIN_LEVEL) { if (g_chip.AD.GainG > 63) g_chip.AD.GainG = 63; else g_chip.AD.GainG++; } } } /* B Channel */ if ((wMaxValueB - wMinValueB) > REFL_MAX_LEVEL_RANGE) { if (g_chip.AD.GainB > 0) g_chip.AD.GainB--; } else { if ((wMaxValueB - wMinValueB) < REFL_MIN_LEVEL_RANGE) { if (wMaxValueB < REFL_WHITE_MIN_LEVEL) { g_chip.AD.GainB++; if (g_chip.AD.GainB > 63) g_chip.AD.GainB = 63; } else { if (wMaxValueB > REFL_WHITE_MAX_LEVEL) { if (g_chip.AD.GainB < 1) g_chip.AD.GainB = 0; else g_chip.AD.GainB--; } else { if (g_chip.AD.GainB > 63) g_chip.AD.GainB = 63; else g_chip.AD.GainB++; } } } else { if (wMaxValueB > REFL_WHITE_MAX_LEVEL) { if (g_chip.AD.GainB < 1) g_chip.AD.GainB = 0; else g_chip.AD.GainB--; } if (wMaxValueB < REFL_WHITE_MIN_LEVEL) { if (g_chip.AD.GainB > 63) g_chip.AD.GainB = 63; else g_chip.AD.GainB++; } } } nTimesOfCal++; if (nTimesOfCal > 10) break; } while ((wMaxValueR - wMinValueR) > REFL_MAX_LEVEL_RANGE || (wMaxValueR - wMinValueR) < REFL_MIN_LEVEL_RANGE || (wMaxValueG - wMinValueG) > REFL_MAX_LEVEL_RANGE || (wMaxValueG - wMinValueG) < REFL_MIN_LEVEL_RANGE || (wMaxValueB - wMinValueB) > REFL_MAX_LEVEL_RANGE || (wMaxValueB - wMinValueB) < REFL_MIN_LEVEL_RANGE); /* Adjust Offset 2nd */ nTimesOfCal = 0; do { DBG (DBG_FUNC, "Reflective_AdjustAD: run in second adjust offset do-while\n"); Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpCalData, wCalWidth * 3, 24); Asic_ScanStop (&g_chip); MustScanner_CalculateMaxMin (lpCalData, &wMaxValueR, &wMinValueR, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth, &wMaxValueG, &wMinValueG, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth * 2, &wMaxValueB, &wMinValueB, wAdjustADResolution); DBG (DBG_FUNC, "Reflective_AdjustAD: " "RGain=%d, ROffset=%d, RDir=%d GGain=%d, GOffset=%d, GDir=%d BGain=%d, BOffset=%d, BDir=%d\n", g_chip.AD.GainR, g_chip.AD.OffsetR, g_chip.AD.DirectionR, g_chip.AD.GainG, g_chip.AD.OffsetG, g_chip.AD.DirectionG, g_chip.AD.GainB, g_chip.AD.OffsetB, g_chip.AD.DirectionB); DBG (DBG_FUNC, "Reflective_AdjustAD: " "MaxR=%d, MinR=%d MaxG=%d, MinG=%d MaxB=%d, MinB=%d\n", wMaxValueR, wMinValueR, wMaxValueG, wMinValueG, wMaxValueB, wMinValueB); if (g_chip.AD.DirectionR == 0) { if (wMinValueR > 20) { if (g_chip.AD.OffsetR < 8) g_chip.AD.DirectionR = 1; else g_chip.AD.OffsetR -= 8; } else if (wMinValueR < 10) g_chip.AD.OffsetR += 8; } else { if (wMinValueR > 20) g_chip.AD.OffsetR += 8; else if (wMinValueR < 10) g_chip.AD.OffsetR -= 8; } if (g_chip.AD.DirectionG == 0) { if (wMinValueG > 20) { if (g_chip.AD.OffsetG < 8) g_chip.AD.DirectionG = 1; else g_chip.AD.OffsetG -= 8; } else if (wMinValueG < 10) g_chip.AD.OffsetG += 8; } else { if (wMinValueG > 20) g_chip.AD.OffsetG += 8; else if (wMinValueG < 10) g_chip.AD.OffsetG -= 8; } if (g_chip.AD.DirectionB == 0) { if (wMinValueB > 20) { if (g_chip.AD.OffsetB < 8) g_chip.AD.DirectionB = 1; else g_chip.AD.OffsetB -= 8; } else if (wMinValueB < 10) g_chip.AD.OffsetB += 8; } else { if (wMinValueB > 20) g_chip.AD.OffsetB += 8; else if (wMinValueB < 10) g_chip.AD.OffsetB -= 8; } nTimesOfCal++; if (nTimesOfCal > 8) break; } while (wMinValueR > 20 || wMinValueR < 10 || wMinValueG > 20 || wMinValueG < 10 || wMinValueB > 20 || wMinValueB < 10); DBG (DBG_FUNC, "Reflective_AdjustAD: run in second adjust offset do-while\n"); DBG (DBG_FUNC, "Reflective_AdjustAD:after ad gain\n"); DBG (DBG_FUNC, "Reflective_AdjustAD: " "g_chip.AD.GainR = %d," "g_chip.AD.GainG = %d," "g_chip.AD.GainB = %d\n", g_chip.AD.GainR, g_chip.AD.GainG, g_chip.AD.GainB); free (lpCalData); DBG (DBG_FUNC, "Reflective_AdjustAD: leave Reflective_AdjustAD\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/14 Routine Description: Find top and left side Parameters: lpwStartX: the left side lpwStartY: the top side Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Reflective_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY) { unsigned short wCalWidth = FIND_LEFT_TOP_WIDTH_IN_DIP; unsigned short wCalHeight = FIND_LEFT_TOP_HEIGHT_IN_DIP; int i, j; unsigned short wLeftSide; unsigned short wTopSide; int nScanBlock; SANE_Byte * lpCalData; unsigned int dwTotalSize; unsigned short wXResolution, wYResolution; DBG (DBG_FUNC, "Reflective_FindTopLeft: call in\n"); if (!g_bOpened) { DBG (DBG_FUNC, "Reflective_FindTopLeft: scanner has been opened\n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Reflective_FindTopLeft: scanner not prepared\n"); return FALSE; } wXResolution = wYResolution = FIND_LEFT_TOP_CALIBRATE_RESOLUTION; lpCalData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * wCalWidth * wCalHeight); if (lpCalData == NULL) { DBG (DBG_FUNC, "Reflective_FindTopLeft: lpCalData malloc error\n"); return FALSE; } dwTotalSize = wCalWidth * wCalHeight; nScanBlock = (int) (dwTotalSize / g_dwCalibrationSize); Asic_SetMotorType (&g_chip, TRUE, TRUE); Asic_SetCalibrate (&g_chip, 8, wXResolution, wYResolution, 0, 0, wCalWidth, wCalHeight, FALSE); Asic_SetAFEGainOffset (&g_chip); if (Asic_ScanStart (&g_chip) != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_FindTopLeft: Asic_ScanStart return error\n"); free (lpCalData); return FALSE; } for (i = 0; i < nScanBlock; i++) { if (STATUS_GOOD != Asic_ReadCalibrationData (&g_chip, lpCalData + i * g_dwCalibrationSize, g_dwCalibrationSize, 8)) { DBG (DBG_FUNC, "Reflective_FindTopLeft: Asic_ReadCalibrationData return error\n"); free (lpCalData); return FALSE; } } if (STATUS_GOOD != Asic_ReadCalibrationData (&g_chip, lpCalData + (nScanBlock) * g_dwCalibrationSize, (dwTotalSize - g_dwCalibrationSize * nScanBlock), 8)) { DBG (DBG_FUNC, "Reflective_FindTopLeft: Asic_ReadCalibrationData return error\n"); free (lpCalData); return FALSE; } Asic_ScanStop (&g_chip); #ifdef DEBUG_SAVE_IMAGE FILE *stream = NULL; stream = fopen ("/root/bound(Ref).pnm", "wb+\n"); SANE_Byte * lpBuf = (SANE_Byte *) malloc (50); if (NULL == lpBuf) { return FALSE; } memset (lpBuf, 0, 50); sprintf (lpBuf, "P5\n%d %d\n255\n", wCalWidth, wCalHeight); fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream); fwrite (lpCalData, sizeof (SANE_Byte), wCalWidth * wCalHeight, stream); fclose (stream); free (lpBuf); #endif wLeftSide = 0; wTopSide = 0; /* Find Left Side */ for (i = wCalWidth - 1; i > 0; i--) { wLeftSide = *(lpCalData + i); wLeftSide += *(lpCalData + wCalWidth * 2 + i); wLeftSide += *(lpCalData + wCalWidth * 4 + i); wLeftSide += *(lpCalData + wCalWidth * 6 + i); wLeftSide += *(lpCalData + wCalWidth * 8 + i); wLeftSide /= 5; if (wLeftSide < 60) { if (i == wCalWidth - 1) { break; } *lpwStartX = i; { break; } } } /*Find Top Side i=left side */ for (j = 0; j < wCalHeight; j++) { wTopSide = *(lpCalData + wCalWidth * j + i - 2); wTopSide += *(lpCalData + wCalWidth * j + i - 4); wTopSide += *(lpCalData + wCalWidth * j + i - 6); wTopSide += *(lpCalData + wCalWidth * j + i - 8); wTopSide += *(lpCalData + wCalWidth * j + i - 10); wTopSide /= 5; if (wTopSide > 60) { if (j == 0) { break; } *lpwStartY = j; { break; } } } if ((*lpwStartX < 100) || (*lpwStartX > 250)) { *lpwStartX = 187; } if ((*lpwStartY < 10) || (*lpwStartY > 100)) { *lpwStartY = 43; } DBG (DBG_FUNC, "Reflective_FindTopLeft: *lpwStartY = %d, *lpwStartX = %d\n", *lpwStartY, *lpwStartX); Asic_MotorMove (&g_chip, FALSE, (wCalHeight - *lpwStartY + BEFORE_SCANNING_MOTOR_FORWARD_PIXEL) * 1200 / wYResolution); free (lpCalData); DBG (DBG_FUNC, "Reflective_FindTopLeft: leave Reflective_FindTopLeft\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/14 Routine Description: Stop scan Parameters: none Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Reflective_StopScan () { DBG (DBG_FUNC, "Reflective_StopScan: call in\n"); if (!g_bOpened) { DBG (DBG_FUNC, "Reflective_StopScan: scanner not opened\n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Reflective_StopScan: scanner not prepared\n"); return FALSE; } g_isCanceled = TRUE; /*tell parent process stop read image */ pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "Reflective_StopScan: thread exit\n"); Asic_ScanStop (&g_chip); Asic_Close (&g_chip); g_bOpened = FALSE; DBG (DBG_FUNC, "Reflective_StopScan: leave Reflective_StopScan\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Get the calibration data Parameters: none Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Reflective_LineCalibration16Bits () { STATUS status; SANE_Byte * lpWhiteData; SANE_Byte * lpDarkData; unsigned int dwWhiteTotalSize; unsigned int dwDarkTotalSize; unsigned short wCalHeight = LINE_CALIBRATION__16BITS_HEIGHT; unsigned short wCalWidth; unsigned short *lpWhiteShading; unsigned short *lpDarkShading; double wRWhiteLevel = 0; double wGWhiteLevel = 0; double wBWhiteLevel = 0; unsigned int dwRDarkLevel = 0; unsigned int dwGDarkLevel = 0; unsigned int dwBDarkLevel = 0; unsigned int dwREvenDarkLevel = 0; unsigned int dwGEvenDarkLevel = 0; unsigned int dwBEvenDarkLevel = 0; unsigned short * lpRWhiteSort; unsigned short * lpGWhiteSort; unsigned short * lpBWhiteSort; unsigned short * lpRDarkSort; unsigned short * lpGDarkSort; unsigned short * lpBDarkSort; int i, j; DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: call in\n"); if (!g_bOpened) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: scanner not opened\n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: scanner not prepared\n"); return FALSE; } wCalWidth = g_Width; dwWhiteTotalSize = wCalWidth * wCalHeight * 3 * 2; dwDarkTotalSize = wCalWidth * wCalHeight * 3 * 2; lpWhiteData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * dwWhiteTotalSize); lpDarkData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * dwDarkTotalSize); if (lpWhiteData == NULL || lpDarkData == NULL) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: lpWhiteData or lpDarkData malloc error \n"); return FALSE; } Asic_SetMotorType (&g_chip, TRUE, TRUE); Asic_SetAFEGainOffset (&g_chip); status = Asic_SetCalibrate (&g_chip, 48, g_XDpi, g_YDpi, g_X, 0, wCalWidth, wCalHeight, TRUE); if (status != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: Asic_SetCalibrate return error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } status = Asic_ScanStart (&g_chip); if (status != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: Asic_ScanStart return error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } status = Asic_ReadCalibrationData (&g_chip, lpWhiteData, dwWhiteTotalSize, 8); if (status != STATUS_GOOD) { free (lpWhiteData); free (lpDarkData); return FALSE; } Asic_ScanStop (&g_chip); /*Read dark level data */ status = Asic_SetMotorType (&g_chip, FALSE, TRUE); if (status != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: Asic_SetMotorType return error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } status = Asic_SetCalibrate (&g_chip, 48, g_XDpi, g_YDpi, g_X, 0, wCalWidth, wCalHeight, TRUE); if (status != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: Asic_SetCalibrate return error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } status = Asic_TurnLamp (&g_chip, FALSE); if (status != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: Asic_TurnLamp return error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } usleep (500000); status = Asic_ScanStart (&g_chip); if (status != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: Asic_ScanStart return error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } status = Asic_ReadCalibrationData (&g_chip, lpDarkData, dwDarkTotalSize, 8); if (status != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: Asic_ReadCalibrationData return error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } Asic_ScanStop (&g_chip); /* Turn on lamp */ status = Asic_TurnLamp (&g_chip, TRUE); if (status != STATUS_GOOD) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: Asic_TurnLamp return error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } #ifdef DEBUG_SAVE_IMAGE FILE *stream = NULL; SANE_Byte * lpBuf = (SANE_Byte *) malloc (50); if (NULL == lpBuf) { return FALSE; } memset (lpBuf, 0, 50); stream = fopen ("/root/whiteshading(Ref).pnm", "wb+\n"); sprintf (lpBuf, "P6\n%d %d\n65535\n", wCalWidth, wCalHeight); fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream); fwrite (lpWhiteData, sizeof (SANE_Byte), wCalWidth * wCalHeight * 3 * 2, stream); fclose (stream); memset (lpBuf, 0, 50); stream = fopen ("/root/darkshading(Ref).pnm", "wb+\n"); sprintf (lpBuf, "P6\n%d %d\n65535\n", wCalWidth, wCalHeight); fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream); fwrite (lpDarkData, sizeof (SANE_Byte), wCalWidth * wCalHeight * 3 * 2, stream); fclose (stream); free (lpBuf); #endif sleep (1); lpWhiteShading = (unsigned short *) malloc (sizeof (unsigned short) * wCalWidth * 3); lpDarkShading = (unsigned short *) malloc (sizeof (unsigned short) * wCalWidth * 3); lpRWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpGWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpBWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpRDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpGDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpBDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); if (lpWhiteShading == NULL || lpDarkShading == NULL || lpRWhiteSort == NULL || lpGWhiteSort == NULL || lpBWhiteSort == NULL || lpRDarkSort == NULL || lpGDarkSort == NULL || lpBDarkSort == NULL) { DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: malloc error \n"); free (lpWhiteData); free (lpDarkData); return FALSE; } /* create dark level shading */ dwRDarkLevel = 0; dwGDarkLevel = 0; dwBDarkLevel = 0; dwREvenDarkLevel = 0; dwGEvenDarkLevel = 0; dwBEvenDarkLevel = 0; DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: wCalWidth = %d, wCalHeight = %d\n", wCalWidth, wCalHeight); for (i = 0; i < wCalWidth; i++) { for (j = 0; j < wCalHeight; j++) { lpRDarkSort[j] = (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 0)); lpRDarkSort[j] += (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 1) << 8); lpGDarkSort[j] = (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 2)); lpGDarkSort[j] += (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 3) << 8); lpBDarkSort[j] = (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 4)); lpBDarkSort[j] += (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 5) << 8); } if (g_XDpi == 1200) { /*do dark shading table with mean */ if (i % 2) { dwRDarkLevel += (unsigned int) MustScanner_FiltLower (lpRDarkSort, wCalHeight, 20, 30); dwGDarkLevel += (unsigned int) MustScanner_FiltLower (lpGDarkSort, wCalHeight, 20, 30); dwBDarkLevel += (unsigned int) MustScanner_FiltLower (lpBDarkSort, wCalHeight, 20, 30); } else { dwREvenDarkLevel += (unsigned int) MustScanner_FiltLower (lpRDarkSort, wCalHeight, 20, 30); dwGEvenDarkLevel += (unsigned int) MustScanner_FiltLower (lpGDarkSort, wCalHeight, 20, 30); dwBEvenDarkLevel += (unsigned int) MustScanner_FiltLower (lpBDarkSort, wCalHeight, 20, 30); } } else { dwRDarkLevel += (unsigned int) MustScanner_FiltLower (lpRDarkSort, wCalHeight, 20, 30); dwGDarkLevel += (unsigned int) MustScanner_FiltLower (lpGDarkSort, wCalHeight, 20, 30); dwBDarkLevel += (unsigned int) MustScanner_FiltLower (lpBDarkSort, wCalHeight, 20, 30); } } if (g_XDpi == 1200) { dwRDarkLevel = (unsigned int) (dwRDarkLevel / (wCalWidth / 2)); dwGDarkLevel = (unsigned int) (dwGDarkLevel / (wCalWidth / 2)); dwBDarkLevel = (unsigned int) (dwBDarkLevel / (wCalWidth / 2)); dwREvenDarkLevel = (unsigned int) (dwREvenDarkLevel / (wCalWidth / 2)); dwGEvenDarkLevel = (unsigned int) (dwGEvenDarkLevel / (wCalWidth / 2)); dwBEvenDarkLevel = (unsigned int) (dwBEvenDarkLevel / (wCalWidth / 2)); } else { dwRDarkLevel = (unsigned int) (dwRDarkLevel / wCalWidth); dwGDarkLevel = (unsigned int) (dwGDarkLevel / wCalWidth); dwBDarkLevel = (unsigned int) (dwBDarkLevel / wCalWidth); } /*Create white shading */ for (i = 0; i < wCalWidth; i++) { wRWhiteLevel = 0; wGWhiteLevel = 0; wBWhiteLevel = 0; for (j = 0; j < wCalHeight; j++) { lpRWhiteSort[j] = (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 0)); lpRWhiteSort[j] += (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 1) << 8); lpGWhiteSort[j] = (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 2)); lpGWhiteSort[j] += (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 3) << 8); lpBWhiteSort[j] = (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 4)); lpBWhiteSort[j] += (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 5) << 8); } if (g_XDpi == 1200) { if (i % 2) { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwRDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) dwGDarkLevel; *(lpDarkShading + i * 3 + 2) = (unsigned short) dwBDarkLevel; } else { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwREvenDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) dwGEvenDarkLevel; *(lpDarkShading + i * 3 + 2) = (unsigned short) dwBEvenDarkLevel; } } else { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwRDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) dwGDarkLevel; *(lpDarkShading + i * 3 + 2) = (unsigned short) dwBDarkLevel; } /*Create white shading */ wRWhiteLevel = (double) (MustScanner_FiltLower (lpRWhiteSort, wCalHeight, 20, 30) - *(lpDarkShading + i * 3 + 0)); wGWhiteLevel = (double) (MustScanner_FiltLower (lpGWhiteSort, wCalHeight, 20, 30) - *(lpDarkShading + i * 3 + 1)); wBWhiteLevel = (double) (MustScanner_FiltLower (lpBWhiteSort, wCalHeight, 20, 30) - *(lpDarkShading + i * 3 + 2)); if (wRWhiteLevel > 0) *(lpWhiteShading + i * 3 + 0) = (unsigned short) (((float) 65535 / wRWhiteLevel * 0x2000)); else *(lpWhiteShading + i * 3 + 0) = 0x2000; if (wGWhiteLevel > 0) *(lpWhiteShading + i * 3 + 1) = (unsigned short) (((float) 65535 / wGWhiteLevel * 0x2000)); else *(lpWhiteShading + i * 3 + 1) = 0x2000; if (wBWhiteLevel > 0) *(lpWhiteShading + i * 3 + 2) = (unsigned short) (((float) 65535 / wBWhiteLevel * 0x2000)); else *(lpWhiteShading + i * 3 + 2) = 0x2000; } free (lpWhiteData); free (lpDarkData); free (lpRWhiteSort); free (lpGWhiteSort); free (lpBWhiteSort); free (lpRDarkSort); free (lpGDarkSort); free (lpBDarkSort); Asic_SetShadingTable (&g_chip, lpWhiteShading, lpDarkShading, g_XDpi, wCalWidth, 0); free (lpWhiteShading); free (lpDarkShading); DBG (DBG_FUNC, "Reflective_LineCalibration16Bits: leave Reflective_LineCalibration16Bits\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/14 Routine Description: Prepare scan image Parameters: none Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Reflective_PrepareScan () { g_wScanLinesPerBlock = g_dwBufferSize / g_BytesPerRow; g_wMaxScanLines = g_dwImageBufferSize / g_BytesPerRow; g_wMaxScanLines = (g_wMaxScanLines / g_wScanLinesPerBlock) * g_wScanLinesPerBlock; g_isCanceled = FALSE; g_dwScannedTotalLines = 0; g_wReadedLines = 0; g_wtheReadyLines = 0; g_wReadImageLines = 0; g_wReadyShadingLine = 0; g_wStartShadingLinePos = 0; switch (g_ScanMode) { case CM_RGB48: g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance; DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n", g_wtheReadyLines); DBG (DBG_FUNC, "Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n", g_dwImageBufferSize); g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Reflective_PrepareScan: g_lpReadImageHead malloc error \n"); return FALSE; } break; case CM_RGB24ext: g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance; DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n", g_wtheReadyLines); DBG (DBG_FUNC, "Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n", g_dwImageBufferSize); g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Reflective_PrepareScan: g_lpReadImageHead malloc error \n"); return FALSE; } break; case CM_GRAY16ext: g_wtheReadyLines = g_wPixelDistance; DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n", g_wtheReadyLines); DBG (DBG_FUNC, "Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n", g_dwImageBufferSize); g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Reflective_PrepareScan: g_lpReadImageHead malloc error \n"); return FALSE; } break; case CM_GRAY8ext: g_wtheReadyLines = g_wPixelDistance; DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n", g_wtheReadyLines); DBG (DBG_FUNC, "Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n", g_dwImageBufferSize); g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Reflective_PrepareScan: g_lpReadImageHead malloc error \n"); return FALSE; } break; case CM_TEXT: g_wtheReadyLines = g_wPixelDistance; DBG (DBG_FUNC, "Reflective_PrepareScan:g_wtheReadyLines=%d\n", g_wtheReadyLines); DBG (DBG_FUNC, "Reflective_PrepareScan:g_lpReadImageHead malloc %d Bytes\n", g_dwImageBufferSize); g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Reflective_PrepareScan: g_lpReadImageHead malloc error \n"); return FALSE; } break; default: break; } Asic_ScanStart (&g_chip); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Get the data of image Parameters: lpBlock: the data of image Rows: the rows of image isOrderInvert: the RGB order Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Reflective_GetRows (SANE_Byte * lpBlock, unsigned short * Rows, SANE_Bool isOrderInvert) { DBG (DBG_FUNC, "Reflective_GetRows: call in \n"); if (!g_bOpened) { DBG (DBG_FUNC, "Reflective_GetRows: scanner not opened \n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Reflective_GetRows: scanner not prepared \n"); return FALSE; } switch (g_ScanMode) { case CM_RGB48: if (g_XDpi == 1200) return MustScanner_GetRgb48BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetRgb48BitLine (lpBlock, isOrderInvert, Rows); case CM_RGB24ext: if (g_XDpi == 1200) return MustScanner_GetRgb24BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetRgb24BitLine (lpBlock, isOrderInvert, Rows); case CM_GRAY16ext: if (g_XDpi == 1200) return MustScanner_GetMono16BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetMono16BitLine (lpBlock, isOrderInvert, Rows); case CM_GRAY8ext: if (g_XDpi == 1200) return MustScanner_GetMono8BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetMono8BitLine (lpBlock, isOrderInvert, Rows); case CM_TEXT: if (g_XDpi == 1200) return MustScanner_GetMono1BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetMono1BitLine (lpBlock, isOrderInvert, Rows); default: return FALSE; } DBG (DBG_FUNC, "Reflective_GetRows: leave Reflective_GetRows \n"); return FALSE; } /* end of the file ScannerReflective.c */ sane-backends-1.0.29/backend/plustek.c0000666000000000000000000024331413615534521014432 00000000000000/*............................................................................. * Project : SANE library for Plustek flatbed scanners. *............................................................................. */ /** @file plustek.c * @brief SANE backend for Plustek scanner * * Based on Kazuhiro Sasayama previous work on * plustek.[ch] file from the SANE package.
* Original code taken from sane-0.71
* Copyright (C) 1997 Hypercore Software Design, Ltd.
* Also based on the work done by Rick Bronson
* Copyright (C) 2000-2007 Gerhard Jaeger
* * History: * - 0.30 - initial version * - 0.31 - no changes * - 0.32 - no changes * - 0.33 - no changes * - 0.34 - moved some definitions and typedefs to plustek.h * - 0.35 - removed Y-correction for 12000P model
* - getting Y-size of scan area from driver * - 0.36 - disabled Dropout, as this does currently not work
* - enabled Halftone selection only for Halftone-mode
* - made the cancel button work by using a child process during read
* - added version code to driver interface
* - cleaned up the code
* - fixed sane compatibility problems
* - added multiple device support
* - 12bit color-depth are now available for scanimage * - 0.37 - removed X/Y autocorrection, now correcting the stuff * before scanning * - applied Michaels' patch to solve the sane_get_parameter problem
* - getting X-size of scan area from driver
* - applied Michaels patch for OPT_RESOLUTION (SANE_INFO_INEXACT stuff) * - 0.38 - now using the information from the driver * - some minor fixes
* - removed dropout stuff
* - removed some warning conditions * - 0.39 - added stuff to use the backend completely in user mode
* - fixed a potential buffer problem
* - removed function attach_one()
* - added USB interface stuff * - 0.40 - USB scanning works now * - 0.41 - added some configuration stuff and also changed .conf file
* - added call to sanei_usb_init() and sanei_lm983x_init() * - 0.42 - added adjustment stuff
* - added custom gamma tables
* - fixed a problem with the "size-sliders"
* - fixed a bug that causes segfault when using the autodetection for * USB devices
* - added OS/2 switch to disable the USB stuff for OS/2 * - 0.43 - added support for PREVIEW flag * - 0.44 - added _DBG_DUMP debug level
* - fixed a bug, that stops our lamp timer * - 0.45 - added additional flags * - added WIFSIGNALED to check result of child termination * - changed readImage interface for USB devices * - homeing of USB scanner is now working correctly * - 0.46 - added plustek-usbcal.c for extra CIS device calibration * based on Montys' great work * - added altCalibration option * - removed parallelport support --> new backend: plustek_pp * - cleanup * - added sanei_thread support * - 0.47 - added mov-option (model override) * - removed drvOpen * - added call to usb_StartLampTimer, when we're using * SIGALRM for lamp timer * - closing now writer pipe, when reader_process is done * - 0.48 - added additional options * split scanmode and bit-depth * - 0.49 - improved multi-device capability * - tweaked some device settings * - added button support * - moved AFE stuff to enhanced options * - 0.50 - cleanup * - activated IPC stuff * - added _DBG_DCALDATA for fine calibration data logging * - added OPT_SPEEDUP handling * - fixed constraint_type for OPT_BUTTON * - 0.51 - added fine calibration caching * - removed #define _PLUSTEK_USB * - 0.52 - added skipDarkStrip and OPT_LOFF4DARK to frontend options * - fixed batch scanning *. *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ /** @mainpage * @verbinclude Plustek-USB.txt */ #ifdef _AIX # include "../include/lalloca.h" #endif #include "../include/sane/config.h" #include "../include/lalloca.h" #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_SYS_TIME_H #include #endif #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #define BACKEND_VERSION "0.52-12" #define BACKEND_NAME plustek #include "../include/sane/sanei_access.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_thread.h" #define USE_IPC #include "plustek-usb.h" #include "plustek.h" /*********************** the debug levels ************************************/ #define _DBG_FATAL 0 #define _DBG_ERROR 1 #define _DBG_WARNING 3 #define _DBG_INFO 5 #define _DBG_PROC 7 #define _DBG_SANE_INIT 10 #define _DBG_INFO2 15 #define _DBG_DREGS 20 #define _DBG_DCALDATA 22 #define _DBG_DPIC 25 #define _DBG_READ 30 /*****************************************************************************/ #define _SECTION "[usb]" #define _DEFAULT_DEVICE "auto" /** to disable the backend... */ /* declare it here, as it's used in plustek-usbscan.c too :-( */ static SANE_Bool cancelRead; static DevList *usbDevs; /* the USB-stuff... I know this is in general no good idea, but it works */ #include "plustek-usbio.c" #include "plustek-usbdevs.c" #include "plustek-usbhw.c" #include "plustek-usbmap.c" #include "plustek-usbscan.c" #include "plustek-usbimg.c" #include "plustek-usbcalfile.c" #include "plustek-usbshading.c" #include "plustek-usbcal.c" #include "plustek-usb.c" /************************** global vars **************************************/ static int num_devices; static Plustek_Device *first_dev; static Plustek_Scanner *first_handle; static const SANE_Device **devlist = 0; static unsigned long tsecs = 0; static Plustek_Scanner *sc = NULL; static const SANE_Int bpp_lm9832_list [] = { 2, 8, 14 }; static const SANE_Int bpp_lm9833_list [] = { 2, 8, 16 }; static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, NULL }; static const SANE_String_Const source_list[] = { SANE_I18N("Normal"), SANE_I18N("Transparency"), SANE_I18N("Negative"), NULL }; static const SANE_Range percentage_range = { SANE_FIX(-100), /* minimum */ SANE_FIX( 100), /* maximum */ SANE_FIX( 1) /* quantization */ }; static const SANE_Range warmup_range = { -1, 999, 1 }; static const SANE_Range offtimer_range = { 0, 999, 1 }; static const SANE_Range gain_range = { -1, 63, 1 }; static const SANE_Range loff_range = { -1, 16363, 1 }; /* authorization stuff */ static SANE_Auth_Callback auth = NULL; /* prototype... */ static SANE_Status local_sane_start(Plustek_Scanner *, int); /****************************** the backend... *******************************/ #define _YN(x) (x?"yes":"no") /** function to display the configuration options for the current device * @param cnf - pointer to the configuration structure whose content should be * displayed */ static void show_cnf( CnfDef *cnf ) { DBG( _DBG_SANE_INIT,"Device configuration:\n" ); DBG( _DBG_SANE_INIT,"device name : >%s<\n",cnf->devName ); DBG( _DBG_SANE_INIT,"USB-ID : >%s<\n",cnf->usbId ); DBG( _DBG_SANE_INIT,"model ovr. : %d\n", cnf->adj.mov ); DBG( _DBG_SANE_INIT,"warmup : %ds\n", cnf->adj.warmup ); DBG( _DBG_SANE_INIT,"lampOff : %d\n", cnf->adj.lampOff ); DBG( _DBG_SANE_INIT,"lampOffOnEnd : %s\n", _YN(cnf->adj.lampOffOnEnd )); DBG( _DBG_SANE_INIT,"cacheCalData : %s\n", _YN(cnf->adj.cacheCalData )); DBG( _DBG_SANE_INIT,"altCalibrate : %s\n", _YN(cnf->adj.altCalibrate )); DBG( _DBG_SANE_INIT,"skipCalibr. : %s\n", _YN(cnf->adj.skipCalibration)); DBG( _DBG_SANE_INIT,"skipFine : %s\n", _YN(cnf->adj.skipFine )); DBG( _DBG_SANE_INIT,"skipFineWhite: %s\n", _YN(cnf->adj.skipFineWhite )); DBG( _DBG_SANE_INIT,"skipDarkStrip: %s\n", _YN(cnf->adj.skipDarkStrip )); DBG( _DBG_SANE_INIT,"incDarkTarget: %s\n", _YN(cnf->adj.incDarkTgt )); DBG( _DBG_SANE_INIT,"invertNegs. : %s\n", _YN(cnf->adj.invertNegatives)); DBG( _DBG_SANE_INIT,"dis.Speedup : %s\n", _YN(cnf->adj.disableSpeedup )); DBG( _DBG_SANE_INIT,"pos_x : %d\n", cnf->adj.pos.x ); DBG( _DBG_SANE_INIT,"pos_y : %d\n", cnf->adj.pos.y ); DBG( _DBG_SANE_INIT,"pos_shading_y: %d\n", cnf->adj.posShadingY ); DBG( _DBG_SANE_INIT,"neg_x : %d\n", cnf->adj.neg.x ); DBG( _DBG_SANE_INIT,"neg_y : %d\n", cnf->adj.neg.y ); DBG( _DBG_SANE_INIT,"neg_shading_y: %d\n", cnf->adj.negShadingY ); DBG( _DBG_SANE_INIT,"tpa_x : %d\n", cnf->adj.tpa.x ); DBG( _DBG_SANE_INIT,"tpa_y : %d\n", cnf->adj.tpa.y ); DBG( _DBG_SANE_INIT,"tpa_shading_y: %d\n", cnf->adj.tpaShadingY ); DBG( _DBG_SANE_INIT,"red gain : %d\n", cnf->adj.rgain ); DBG( _DBG_SANE_INIT,"green gain : %d\n", cnf->adj.ggain ); DBG( _DBG_SANE_INIT,"blue gain : %d\n", cnf->adj.bgain ); DBG( _DBG_SANE_INIT,"red offset : %d\n", cnf->adj.rofs ); DBG( _DBG_SANE_INIT,"green offset : %d\n", cnf->adj.gofs ); DBG( _DBG_SANE_INIT,"blue offset : %d\n", cnf->adj.bofs ); DBG( _DBG_SANE_INIT,"red lampoff : %d\n", cnf->adj.rlampoff ); DBG( _DBG_SANE_INIT,"green lampoff: %d\n", cnf->adj.glampoff ); DBG( _DBG_SANE_INIT,"blue lampoff : %d\n", cnf->adj.blampoff ); DBG( _DBG_SANE_INIT,"red Gamma : %.2f\n",cnf->adj.rgamma ); DBG( _DBG_SANE_INIT,"green Gamma : %.2f\n",cnf->adj.ggamma ); DBG( _DBG_SANE_INIT,"blue Gamma : %.2f\n",cnf->adj.bgamma ); DBG( _DBG_SANE_INIT,"gray Gamma : %.2f\n",cnf->adj.graygamma ); DBG( _DBG_SANE_INIT,"---------------------\n" ); } /** Calls the device specific stop and close functions. * @param dev - pointer to the device specific structure * @return The function always returns SANE_STATUS_GOOD */ static SANE_Status drvclose( Plustek_Device *dev ) { if( dev->fd >= 0 ) { DBG( _DBG_INFO, "drvclose()\n" ); if( 0 != tsecs ) { DBG( _DBG_INFO, "TIME END 1: %lus\n", time(NULL)-tsecs); } /* don't check the return values, simply do it */ usbDev_stopScan( dev ); usbDev_close ( dev ); sanei_access_unlock( dev->sane.name ); } dev->fd = -1; return SANE_STATUS_GOOD; } /** according to the mode and source we return the corresponding scanmode and * bit-depth per pixel */ static int getScanMode( Plustek_Scanner *scanner ) { int mode; int scanmode; /* are we in TPA-mode? */ mode = scanner->val[OPT_MODE].w; if( scanner->val[OPT_EXT_MODE].w != 0 ) mode += 2; scanner->params.depth = scanner->val[OPT_BIT_DEPTH].w; if( mode == 0 ) { scanmode = COLOR_BW; scanner->params.depth = 1; } else if( scanner->params.depth == 8 ) { if( mode == 1 ) scanmode = COLOR_256GRAY; else scanmode = COLOR_TRUE24; } else { scanner->params.depth = 16; if( mode == 1 ) scanmode = COLOR_GRAY16; else scanmode = COLOR_TRUE48; } return scanmode; } /** return the len of the largest string in the array */ static size_t max_string_size (const SANE_String_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; } /** shutdown open pipes */ static SANE_Status close_pipe( Plustek_Scanner *scanner ) { if( scanner->r_pipe >= 0 ) { DBG( _DBG_PROC, "close_pipe (r_pipe)\n" ); close( scanner->r_pipe ); scanner->r_pipe = -1; } if( scanner->w_pipe >= 0 ) { DBG( _DBG_PROC, "close_pipe (w_pipe)\n" ); close( scanner->w_pipe ); scanner->w_pipe = -1; } return SANE_STATUS_EOF; } /** will be called when a child is going down */ static void sig_chldhandler( int signo ) { DBG( _DBG_PROC, "(SIG) Child is down (signal=%d)\n", signo ); if (sc) { sc->calibrating = SANE_FALSE; sc = NULL; } } /** signal handler to kill the child process */ 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 void usb_reader_process_sigterm_handler( int signo ) { DBG( _DBG_PROC, "(SIG) reader_process: terminated by signal %d\n", signo ); cancelRead = SANE_TRUE; } static void sigalarm_handler( int signo ) { _VAR_NOT_USED( signo ); DBG( _DBG_PROC, "ALARM!!!\n" ); } /** */ static void thread_entry(void) { struct SIGACTION act; sigset_t ignore_set; sigfillset ( &ignore_set ); sigdelset ( &ignore_set, SIGTERM ); #if defined (__APPLE__) && defined (__MACH__) sigdelset ( &ignore_set, SIGUSR2 ); #endif sigprocmask( SIG_SETMASK, &ignore_set, 0 ); memset(&act, 0, sizeof (act)); sigaction( SIGTERM, &act, 0 ); cancelRead = SANE_FALSE; /* install the signal handler */ sigemptyset(&(act.sa_mask)); act.sa_flags = 0; act.sa_handler = reader_process_sigterm_handler; sigaction( SIGTERM, &act, 0 ); act.sa_handler = usb_reader_process_sigterm_handler; sigaction( SIGUSR1, &act, 0 ); } /** executed as a child process * read the data from the driver and send them to the parent process */ static int reader_process( void *args ) { int line, lerrn; unsigned char *buf; unsigned long status; unsigned long data_length; Plustek_Scanner *scanner = (Plustek_Scanner *)args; Plustek_Device *dev = scanner->hw; #ifdef USE_IPC IPCDef ipc; #endif if( sanei_thread_is_forked()) { DBG( _DBG_PROC, "reader_process started (forked)\n" ); close( scanner->r_pipe ); scanner->r_pipe = -1; } else { DBG( _DBG_PROC, "reader_process started (as thread)\n" ); } thread_entry(); data_length = scanner->params.lines * scanner->params.bytes_per_line; DBG( _DBG_PROC, "reader_process:" "starting to READ data (%lu bytes)\n", data_length ); DBG( _DBG_PROC, "buf = 0x%08lx\n", (unsigned long)scanner->buf ); if( NULL == scanner->buf ) { DBG( _DBG_FATAL, "NULL Pointer !!!!\n" ); return SANE_STATUS_IO_ERROR; } /* prepare for scanning: speed-test, warmup, calibration */ buf = scanner->buf; status = usbDev_Prepare( scanner->hw, buf ); #ifdef USE_IPC /* prepare IPC structure */ memset(&ipc, 0, sizeof(ipc)); ipc.transferRate = DEFAULT_RATE; if( dev->transferRate > 0 && dev->transferRate != DEFAULT_RATE ) ipc.transferRate = dev->transferRate; /* write ipc back to parent in any case... */ write( scanner->w_pipe, &ipc, sizeof(ipc)); #endif /* on success, we read all data from the driver... */ if( 0 == status ) { if( !usb_InCalibrationMode(dev)) { DBG( _DBG_INFO, "reader_process: READING....\n" ); for( line = 0; line < scanner->params.lines; line++ ) { status = usbDev_ReadLine( scanner->hw ); if((int)status < 0 ) { break; } write( scanner->w_pipe, buf, scanner->params.bytes_per_line ); buf += scanner->params.bytes_per_line; } } } /* on error, there's no need to clean up, as this is done by the parent */ lerrn = errno; close( scanner->w_pipe ); scanner->w_pipe = -1; if((int)status < 0 ) { DBG( _DBG_ERROR,"reader_process: read failed, status = %i, errno %i\n", (int)status, lerrn ); if( _E_ABORT == (int)status ) return SANE_STATUS_CANCELLED; if( lerrn == EBUSY ) return SANE_STATUS_DEVICE_BUSY; return SANE_STATUS_IO_ERROR; } DBG( _DBG_PROC, "reader_process: finished reading data\n" ); return SANE_STATUS_GOOD; } /** stop the current scan process */ static SANE_Status do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe ) { struct SIGACTION act; SANE_Pid res; DBG( _DBG_PROC,"do_cancel\n" ); scanner->scanning = SANE_FALSE; if( sanei_thread_is_valid (scanner->reader_pid) ) { DBG( _DBG_PROC, "---- killing reader_process ----\n" ); cancelRead = SANE_TRUE; scanner->calibrating = SANE_FALSE; sigemptyset(&(act.sa_mask)); act.sa_flags = 0; act.sa_handler = sigalarm_handler; sigaction( SIGALRM, &act, 0 ); /* kill our child process and wait until done */ sanei_thread_sendsig( scanner->reader_pid, SIGUSR1 ); /* give'em 10 seconds 'til done...*/ alarm(10); res = sanei_thread_waitpid( scanner->reader_pid, 0 ); alarm(0); if( res != scanner->reader_pid ) { DBG( _DBG_PROC,"sanei_thread_waitpid() failed !\n"); /* do it the hard way...*/ #ifdef USE_PTHREAD sanei_thread_kill( scanner->reader_pid ); #else sanei_thread_sendsig( scanner->reader_pid, SIGKILL ); #endif } sanei_thread_invalidate( scanner->reader_pid ); DBG( _DBG_PROC,"reader_process killed\n"); #ifndef HAVE_SETITIMER usb_StartLampTimer( scanner->hw ); #endif } scanner->calibrating = SANE_FALSE; if( SANE_TRUE == closepipe ) { close_pipe( scanner ); } drvclose( scanner->hw ); if( tsecs != 0 ) { DBG( _DBG_INFO, "TIME END 2: %lus\n", time(NULL)-tsecs); tsecs = 0; } return SANE_STATUS_CANCELLED; } /** As we support only LM9831/2/3 chips we use the same * sizes for each device... * @param s - pointer to the scanner specific structure * @return The function always returns SANE_STATUS_GOOD */ static SANE_Status initGammaSettings( Plustek_Scanner *s ) { int i, j, val; double gamma; s->gamma_length = 4096; s->gamma_range.min = 0; s->gamma_range.max = 255; s->gamma_range.quant = 0; DBG( _DBG_INFO, "Presetting Gamma tables (len=%u)\n", s->gamma_length ); /* preset the gamma maps */ for( i = 0; i < 4; i++ ) { switch( i ) { case 1: gamma = s->hw->adj.rgamma; break; case 2: gamma = s->hw->adj.ggamma; break; case 3: gamma = s->hw->adj.bgamma; break; default: gamma = s->hw->adj.graygamma; break; } DBG( _DBG_INFO, "* Channel[%u], gamma %.3f\n", i, gamma ); for( j = 0; j < s->gamma_length; j++ ) { val = (s->gamma_range.max * pow((double)j / (double)(s->gamma_length-1.0), 1.0 / gamma )); if( val > s->gamma_range.max ) val = s->gamma_range.max; s->gamma_table[i][j] = val; } } DBG( _DBG_INFO, "----------------------------------\n" ); return SANE_STATUS_GOOD; } /** Check the gamma vectors we got back and limit if necessary * @param s - pointer to the scanner specific structure * @return nothing */ static void checkGammaSettings( Plustek_Scanner *s ) { int i, j; DBG( _DBG_INFO, "Maps changed...\n" ); for( i = 0; i < 4 ; i++ ) { for( j = 0; j < s->gamma_length; j++ ) { if( s->gamma_table[i][j] > s->gamma_range.max ) { s->gamma_table[i][j] = s->gamma_range.max; } } } } /** initialize the options for the backend according to the device we have */ static SANE_Status init_options( Plustek_Scanner *s ) { int i; Plustek_Device *dev = s->hw; AdjDef *adj = &dev->adj; DCapsDef *caps = &dev->usbDev.Caps; memset(s->opt, 0, sizeof(s->opt)); for( i = 0; i < NUM_OPTIONS; ++i ) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[i].unit = SANE_UNIT_NONE; } s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->opt[OPT_NUM_OPTS].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Scan Mode" group: */ s->opt[OPT_MODE_GROUP].title = SANE_I18N("Scan Mode"); s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = max_string_size(mode_list); s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].w = 2; /* Color */ /* bit depth */ s->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; s->opt[OPT_BIT_DEPTH].unit = SANE_UNIT_BIT; s->opt[OPT_BIT_DEPTH].size = sizeof (SANE_Word); s->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; if( _LM9833 == dev->usbDev.HwSetting.chip ) s->opt[OPT_BIT_DEPTH].constraint.word_list = bpp_lm9833_list; else s->opt[OPT_BIT_DEPTH].constraint.word_list = bpp_lm9832_list; s->val[OPT_BIT_DEPTH].w = 8; if (caps->workaroundFlag & _WAF_ONLY_8BIT) _DISABLE(OPT_BIT_DEPTH); /* scan source */ s->opt[OPT_EXT_MODE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_EXT_MODE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_EXT_MODE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_EXT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_EXT_MODE].size = max_string_size(source_list); s->opt[OPT_EXT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_EXT_MODE].constraint.string_list = source_list; s->val[OPT_EXT_MODE].w = 0; /* Normal */ /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_FIXED; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_PERCENT; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &percentage_range; s->val[OPT_BRIGHTNESS].w = 0; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_FIXED; s->opt[OPT_CONTRAST].unit = SANE_UNIT_PERCENT; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &percentage_range; s->val[OPT_CONTRAST].w = 0; /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_RESOLUTION].constraint.range = &s->hw->dpi_range; s->val[OPT_RESOLUTION].w = s->hw->dpi_range.min; /* custom-gamma table */ s->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; s->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->val[OPT_PREVIEW].w = 0; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N("Geometry"); s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->val[OPT_TL_X].w = SANE_FIX(_DEFAULT_TLX); /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->val[OPT_TL_Y].w = SANE_FIX(_DEFAULT_TLY); /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->val[OPT_BR_X].w = SANE_FIX(_DEFAULT_BRX); /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; s->val[OPT_BR_Y].w = SANE_FIX(_DEFAULT_BRY); /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N("Enhancement"); s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; initGammaSettings( s ); /* grayscale gamma vector */ s->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR].wa = &(s->gamma_table[0][0]); s->opt[OPT_GAMMA_VECTOR].constraint.range = &(s->gamma_range); s->opt[OPT_GAMMA_VECTOR].size = s->gamma_length * sizeof(SANE_Word); /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_R].wa = &(s->gamma_table[1][0]); s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &(s->gamma_range); s->opt[OPT_GAMMA_VECTOR_R].size = s->gamma_length * sizeof(SANE_Word); /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_G].wa = &(s->gamma_table[2][0]); s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &(s->gamma_range); s->opt[OPT_GAMMA_VECTOR_G].size = s->gamma_length * sizeof(SANE_Word); /* blue gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_B].wa = &(s->gamma_table[3][0]); s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &(s->gamma_range); s->opt[OPT_GAMMA_VECTOR_B].size = s->gamma_length * sizeof(SANE_Word); /* GAMMA stuff is disabled per default */ _DISABLE(OPT_GAMMA_VECTOR); _DISABLE(OPT_GAMMA_VECTOR_R); _DISABLE(OPT_GAMMA_VECTOR_G); _DISABLE(OPT_GAMMA_VECTOR_B); /* disable extended mode list for devices without TPA */ if( 0 == (s->hw->caps.dwFlag & SFLAG_TPA)) _DISABLE(OPT_EXT_MODE); /* "Device settings" group: */ s->opt[OPT_DEVICE_GROUP].title = SANE_I18N("Device-Settings"); s->opt[OPT_DEVICE_GROUP].desc = ""; s->opt[OPT_DEVICE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_DEVICE_GROUP].cap = 0; s->opt[OPT_DEVICE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_LAMPSWITCH].name = "lamp-switch"; s->opt[OPT_LAMPSWITCH].title = SANE_I18N("Lampswitch");; s->opt[OPT_LAMPSWITCH].desc = SANE_I18N("Manually switching the lamp(s)."); s->opt[OPT_LAMPSWITCH].type = SANE_TYPE_BOOL; s->val[OPT_LAMPSWITCH].w = SANE_FALSE; s->opt[OPT_LOFF4DARK].name = "lamp-off-during-dcal"; s->opt[OPT_LOFF4DARK].title = SANE_I18N("Lamp off during dark calibration");; s->opt[OPT_LOFF4DARK].desc = SANE_I18N("Always switches lamp off when doing dark calibration."); s->opt[OPT_LOFF4DARK].type = SANE_TYPE_BOOL; s->val[OPT_LOFF4DARK].w = adj->skipDarkStrip; if (dev->usbDev.Caps.Normal.DarkShadOrgY < 0) _DISABLE(OPT_LOFF4DARK); s->opt[OPT_CACHECAL].name = "calibration-cache"; s->opt[OPT_CACHECAL].title = SANE_I18N("Calibration data cache");; s->opt[OPT_CACHECAL].desc = SANE_I18N("Enables or disables calibration data cache."); s->opt[OPT_CACHECAL].type = SANE_TYPE_BOOL; s->val[OPT_CACHECAL].w = adj->cacheCalData; s->opt[OPT_CALIBRATE].name = "calibrate"; s->opt[OPT_CALIBRATE].title = SANE_I18N("Calibrate");; s->opt[OPT_CALIBRATE].desc = SANE_I18N("Performs calibration"); s->opt[OPT_CALIBRATE].type = SANE_TYPE_BUTTON; s->opt[OPT_CALIBRATE].size = sizeof (SANE_Word); s->opt[OPT_CALIBRATE].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_CALIBRATE].constraint.range = 0; s->opt[OPT_CALIBRATE].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_AUTOMATIC; _ENABLE(OPT_CALIBRATE); if( !adj->cacheCalData ) _DISABLE(OPT_CALIBRATE); s->val[OPT_CALIBRATE].w = 0; /* it's currently not available for CCD devices */ if( !usb_IsCISDevice(dev) && !dev->adj.altCalibrate) _DISABLE(OPT_CALIBRATE); s->opt[OPT_SPEEDUP].name = "speedup-switch"; s->opt[OPT_SPEEDUP].title = SANE_I18N("Speedup sensor");; s->opt[OPT_SPEEDUP].desc = SANE_I18N("Enables or disables speeding up sensor movement."); s->opt[OPT_SPEEDUP].type = SANE_TYPE_BOOL; s->val[OPT_SPEEDUP].w = !(adj->disableSpeedup); if( s->hw->usbDev.HwSetting.dHighSpeed == 0.0 ) _DISABLE(OPT_SPEEDUP); s->opt[OPT_LAMPOFF_ONEND].name = SANE_NAME_LAMP_OFF_AT_EXIT; s->opt[OPT_LAMPOFF_ONEND].title = SANE_TITLE_LAMP_OFF_AT_EXIT; s->opt[OPT_LAMPOFF_ONEND].desc = SANE_DESC_LAMP_OFF_AT_EXIT; s->opt[OPT_LAMPOFF_ONEND].type = SANE_TYPE_BOOL; s->val[OPT_LAMPOFF_ONEND].w = adj->lampOffOnEnd; s->opt[OPT_WARMUPTIME].name = "warmup-time"; s->opt[OPT_WARMUPTIME].title = SANE_I18N("Warmup-time");; s->opt[OPT_WARMUPTIME].desc = SANE_I18N("Warmup-time in seconds."); s->opt[OPT_WARMUPTIME].type = SANE_TYPE_INT; s->opt[OPT_WARMUPTIME].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_WARMUPTIME].constraint.range = &warmup_range; s->val[OPT_WARMUPTIME].w = adj->warmup; /* only available for CCD devices*/ if( usb_IsCISDevice( dev )) { _DISABLE(OPT_WARMUPTIME); s->val[OPT_WARMUPTIME].w = 0; } s->opt[OPT_LAMPOFF_TIMER].name = "lampoff-time"; s->opt[OPT_LAMPOFF_TIMER].title = SANE_I18N("Lampoff-time");; s->opt[OPT_LAMPOFF_TIMER].desc = SANE_I18N("Lampoff-time in seconds."); s->opt[OPT_LAMPOFF_TIMER].type = SANE_TYPE_INT; s->opt[OPT_LAMPOFF_TIMER].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_LAMPOFF_TIMER].constraint.range = &offtimer_range; s->val[OPT_LAMPOFF_TIMER].w = adj->lampOff; /* "Analog Frontend" group*/ s->opt[OPT_AFE_GROUP].title = SANE_I18N("Analog frontend"); s->opt[OPT_AFE_GROUP].desc = ""; s->opt[OPT_AFE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_AFE_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_OVR_REDGAIN].name = "red-gain"; s->opt[OPT_OVR_REDGAIN].title = SANE_I18N("Red gain"); s->opt[OPT_OVR_REDGAIN].desc = SANE_I18N("Red gain value of the AFE"); s->opt[OPT_OVR_REDGAIN].type = SANE_TYPE_INT; s->opt[OPT_OVR_REDGAIN].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_REDGAIN].constraint.range = &gain_range; s->val[OPT_OVR_REDGAIN].w = adj->rgain; s->opt[OPT_OVR_REDOFS].name = "red-offset"; s->opt[OPT_OVR_REDOFS].title = SANE_I18N("Red offset"); s->opt[OPT_OVR_REDOFS].desc = SANE_I18N("Red offset value of the AFE"); s->opt[OPT_OVR_REDOFS].type = SANE_TYPE_INT; s->opt[OPT_OVR_REDOFS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_REDOFS].constraint.range = &gain_range; s->val[OPT_OVR_REDOFS].w = adj->rofs; s->opt[OPT_OVR_GREENGAIN].name = "green-gain"; s->opt[OPT_OVR_GREENGAIN].title = SANE_I18N("Green gain"); s->opt[OPT_OVR_GREENGAIN].desc = SANE_I18N("Green gain value of the AFE"); s->opt[OPT_OVR_GREENGAIN].type = SANE_TYPE_INT; s->opt[OPT_OVR_GREENGAIN].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_GREENGAIN].constraint.range = &gain_range; s->val[OPT_OVR_GREENGAIN].w = adj->ggain; s->opt[OPT_OVR_GREENOFS].name = "green-offset"; s->opt[OPT_OVR_GREENOFS].title = SANE_I18N("Green offset"); s->opt[OPT_OVR_GREENOFS].desc = SANE_I18N("Green offset value of the AFE"); s->opt[OPT_OVR_GREENOFS].type = SANE_TYPE_INT; s->opt[OPT_OVR_GREENOFS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_GREENOFS].constraint.range = &gain_range; s->val[OPT_OVR_GREENOFS].w = adj->gofs; s->opt[OPT_OVR_BLUEGAIN].name = "blue-gain"; s->opt[OPT_OVR_BLUEGAIN].title = SANE_I18N("Blue gain"); s->opt[OPT_OVR_BLUEGAIN].desc = SANE_I18N("Blue gain value of the AFE"); s->opt[OPT_OVR_BLUEGAIN].type = SANE_TYPE_INT; s->opt[OPT_OVR_BLUEGAIN].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_BLUEGAIN].constraint.range = &gain_range; s->val[OPT_OVR_BLUEGAIN].w = adj->bgain; s->opt[OPT_OVR_BLUEOFS].name = "blue-offset"; s->opt[OPT_OVR_BLUEOFS].title = SANE_I18N("Blue offset"); s->opt[OPT_OVR_BLUEOFS].desc = SANE_I18N("Blue offset value of the AFE"); s->opt[OPT_OVR_BLUEOFS].type = SANE_TYPE_INT; s->opt[OPT_OVR_BLUEOFS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_BLUEOFS].constraint.range = &gain_range; s->val[OPT_OVR_BLUEOFS].w = adj->bofs; s->opt[OPT_OVR_RED_LOFF].name = "redlamp-off"; s->opt[OPT_OVR_RED_LOFF].title = SANE_I18N("Red lamp off"); s->opt[OPT_OVR_RED_LOFF].desc = SANE_I18N("Defines red lamp off parameter"); s->opt[OPT_OVR_RED_LOFF].type = SANE_TYPE_INT; s->opt[OPT_OVR_RED_LOFF].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_RED_LOFF].constraint.range = &loff_range; s->val[OPT_OVR_RED_LOFF].w = adj->rlampoff; s->opt[OPT_OVR_GREEN_LOFF].name = "greenlamp-off"; s->opt[OPT_OVR_GREEN_LOFF].title = SANE_I18N("Green lamp off"); s->opt[OPT_OVR_GREEN_LOFF].desc = SANE_I18N("Defines green lamp off parameter"); s->opt[OPT_OVR_GREEN_LOFF].type = SANE_TYPE_INT; s->opt[OPT_OVR_GREEN_LOFF].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_GREEN_LOFF].constraint.range = &loff_range; s->val[OPT_OVR_GREEN_LOFF].w = adj->glampoff; s->opt[OPT_OVR_BLUE_LOFF].name = "bluelamp-off"; s->opt[OPT_OVR_BLUE_LOFF].title = SANE_I18N("Blue lamp off"); s->opt[OPT_OVR_BLUE_LOFF].desc = SANE_I18N("Defines blue lamp off parameter"); s->opt[OPT_OVR_BLUE_LOFF].type = SANE_TYPE_INT; s->opt[OPT_OVR_BLUE_LOFF].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_OVR_BLUE_LOFF].constraint.range = &loff_range; s->val[OPT_OVR_BLUE_LOFF].w = adj->blampoff; /* only available for CIS devices*/ if( !usb_IsCISDevice( dev )) { _DISABLE(OPT_OVR_RED_LOFF); _DISABLE(OPT_OVR_GREEN_LOFF); _DISABLE(OPT_OVR_BLUE_LOFF); } /* "Button" group*/ s->opt[OPT_BUTTON_GROUP].title = SANE_I18N("Buttons"); s->opt[OPT_BUTTON_GROUP].desc = ""; s->opt[OPT_BUTTON_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_BUTTON_GROUP].cap = SANE_CAP_ADVANCED; /* scanner buttons */ for( i = OPT_BUTTON_0; i <= OPT_BUTTON_LAST; i++ ) { char buf [128]; snprintf (buf, sizeof(buf), "button %d", i - OPT_BUTTON_0); s->opt[i].name = strdup(buf); snprintf (buf, sizeof(buf), "Scanner button %d", i - OPT_BUTTON_0); s->opt[i].title = strdup(buf); s->opt[i].desc = SANE_I18N("This option reflects the status " "of the scanner buttons."); s->opt[i].type = SANE_TYPE_BOOL; s->opt[i].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; if (i - OPT_BUTTON_0 >= dev->usbDev.Caps.bButtons ) _DISABLE(i); s->opt[i].unit = SANE_UNIT_NONE; s->opt[i].size = sizeof (SANE_Word); s->opt[i].constraint_type = SANE_CONSTRAINT_NONE; s->opt[i].constraint.range = 0; s->val[i].w = SANE_FALSE; } usb_UpdateButtonStatus( s ); return SANE_STATUS_GOOD; } /** Function to retrieve the vendor and product id from a given string * @param src - string, that should be investigated * @param dest - pointer to a string to receive the USB ID */ static void decodeUsbIDs( char *src, char **dest ) { const char *name; char *tmp = *dest; int len = strlen(_SECTION); if( isspace(src[len])) { strncpy( tmp, &src[len+1], (strlen(src)-(len+1))); tmp[(strlen(src)-(len+1))] = '\0'; } name = tmp; name = sanei_config_skip_whitespace( name ); if( '\0' == name[0] ) { DBG( _DBG_SANE_INIT, "next device uses autodetection\n" ); } else { u_short pi = 0, vi = 0; if( *name ) { name = sanei_config_get_string( name, &tmp ); if( tmp ) { vi = strtol( tmp, 0, 0 ); free( tmp ); } } name = sanei_config_skip_whitespace( name ); if( *name ) { name = sanei_config_get_string( name, &tmp ); if( tmp ) { pi = strtol( tmp, 0, 0 ); free( tmp ); } } /* create what we need to go through our device list...*/ sprintf( *dest, "0x%04X-0x%04X", vi, pi ); DBG( _DBG_SANE_INIT, "next device is a USB device (%s)\n", *dest ); } } #define _INT 0 #define _FLOAT 1 /** function to decode an value and give it back to the caller. * @param src - pointer to the source string to check * @param opt - string that keeps the option name to check src for * @param what - _FLOAT or _INT * @param result - pointer to the var that should receive our result * @param def - default value that result should be in case of any error * @return The function returns SANE_TRUE if the option has been found, * if not, it returns SANE_FALSE */ static SANE_Bool decodeVal( char *src, char *opt, int what, void *result, void *def ) { char *tmp, *tmp2; const char *name; /* skip the option string */ name = (const char*)&src[strlen("option")]; /* get the name of the option */ name = sanei_config_get_string( name, &tmp ); if( tmp ) { /* on success, compare wiht the given one */ if( 0 == strcmp( tmp, opt )) { DBG( _DBG_SANE_INIT, "Decoding option >%s<\n", opt ); if( _INT == what ) { /* assign the default value for this option... */ *((int*)result) = *((int*)def); if( *name ) { /* get the configuration value and decode it */ name = sanei_config_get_string( name, &tmp2 ); if( tmp2 ) { *((int*)result) = strtol( tmp2, 0, 0 ); free( tmp2 ); } } free( tmp ); return SANE_TRUE; } else if( _FLOAT == what ) { /* assign the default value for this option... */ *((double*)result) = *((double*)def); if( *name ) { /* get the configuration value and decode it */ name = sanei_config_get_string( name, &tmp2 ); if( tmp2 ) { *((double*)result) = strtod( tmp2, 0 ); free( tmp2 ); } } free( tmp ); return SANE_TRUE; } } free( tmp ); } return SANE_FALSE; } /** function to retrive the device name of a given string * @param src - string that keeps the option name to check src for * @param dest - pointer to the string, that should receive the detected * devicename * @return The function returns SANE_TRUE if the devicename has been found, * if not, it returns SANE_FALSE */ static SANE_Bool decodeDevName( char *src, char *dest ) { char *tmp; const char *name; if( 0 == strncmp( "device", src, 6 )) { name = (const char*)&src[strlen("device")]; name = sanei_config_skip_whitespace( name ); DBG( _DBG_SANE_INIT, "Decoding device name >%s<\n", name ); if( *name ) { name = sanei_config_get_string( name, &tmp ); if( tmp ) { strcpy( dest, tmp ); free( tmp ); return SANE_TRUE; } } } return SANE_FALSE; } /** attach a device to the backend */ static SANE_Status attach( const char *dev_name, CnfDef *cnf, Plustek_Device **devp ) { int cntr; int result; int handle; Plustek_Device *dev; DBG( _DBG_SANE_INIT, "attach (%s, %p, %p)\n", dev_name, (void *)cnf, (void *)devp); /* already attached ?*/ for( dev = first_dev; dev; dev = dev->next ) { if( 0 == strcmp( dev->sane.name, dev_name )) { if( devp ) *devp = dev; return SANE_STATUS_GOOD; } } /* allocate some memory for the device */ dev = malloc( sizeof (*dev)); if( NULL == dev ) return SANE_STATUS_NO_MEM; /* assign all the stuff we need fo this device... */ memset(dev, 0, sizeof (*dev)); dev->fd = -1; dev->name = strdup(dev_name); /* hold it double to avoid */ dev->sane.name = dev->name; /* compiler warnings */ dev->sane.vendor = "Plustek"; dev->initialized = -1; /* will be used as index too */ dev->calFile = NULL; dev->transferRate = DEFAULT_RATE; memcpy( &dev->adj, &cnf->adj, sizeof(AdjDef)); show_cnf( cnf ); strncpy( dev->usbId, cnf->usbId, _MAX_ID_LEN ); if( cnf->adj.lampOff >= 0 ) dev->usbDev.dwLampOnPeriod = cnf->adj.lampOff; if( cnf->adj.lampOffOnEnd >= 0 ) dev->usbDev.bLampOffOnEnd = cnf->adj.lampOffOnEnd; /* go ahead and open the scanner device */ handle = usbDev_open( dev, usbDevs, SANE_FALSE ); if( handle < 0 ) { DBG( _DBG_ERROR,"open failed: %d\n", handle ); return SANE_STATUS_IO_ERROR; } /* okay, so assign the handle and the scanner type */ dev->fd = handle; if( usb_IsSheetFedDevice( dev )) dev->sane.type = SANE_I18N("sheetfed scanner"); else dev->sane.type = SANE_I18N("flatbed scanner"); result = usbDev_getCaps( dev ); if( result < 0 ) { DBG( _DBG_ERROR, "usbDev_getCaps() failed(%d)\n", result); usbDev_close(dev); return SANE_STATUS_IO_ERROR; } /* save the info we got from the driver */ DBG( _DBG_INFO, "Scanner information:\n" ); if( NULL != dev->usbDev.ModelStr ) dev->sane.model = dev->usbDev.ModelStr; else dev->sane.model = "USB-Device"; DBG( _DBG_INFO, "Vendor : %s\n", dev->sane.vendor ); DBG( _DBG_INFO, "Model : %s\n", dev->sane.model ); DBG( _DBG_INFO, "Flags : 0x%08lx\n", dev->caps.dwFlag ); dev->max_x = dev->caps.wMaxExtentX*MM_PER_INCH/_MEASURE_BASE; dev->max_y = dev->caps.wMaxExtentY*MM_PER_INCH/_MEASURE_BASE; /* calculate the size of the resolution list + * one more to avoid a buffer overflow, then allocate it... */ dev->res_list = (SANE_Int *) calloc((((dev->usbDev.Caps.OpticDpi.x*16)-_DEF_DPI)/25+1), sizeof (SANE_Int)); if (NULL == dev->res_list) { DBG( _DBG_ERROR, "calloc failed: %s\n", strerror(errno)); usbDev_close(dev); return SANE_STATUS_INVAL; } /* build up the resolution table */ dev->res_list_size = 0; for(cntr = _DEF_DPI; cntr <= (dev->usbDev.Caps.OpticDpi.x*16); cntr += 25){ dev->res_list_size++; dev->res_list[dev->res_list_size - 1] = (SANE_Int)cntr; } /* set the limits */ dev->dpi_range.min = _DEF_DPI; dev->dpi_range.max = dev->usbDev.Caps.OpticDpi.x * 2; dev->x_range.max = SANE_FIX(dev->max_x); dev->y_range.max = SANE_FIX(dev->max_y); dev->fd = handle; drvclose( dev ); DBG( _DBG_SANE_INIT, "attach: model = >%s<\n", dev->sane.model ); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; return SANE_STATUS_GOOD; } /** function to preset a configuration structure * @param cnf - pointer to the structure that should be initialized */ static void init_config_struct( CnfDef *cnf ) { memset(cnf, 0, sizeof(CnfDef)); cnf->adj.warmup = -1; cnf->adj.lampOff = -1; cnf->adj.lampOffOnEnd = -1; cnf->adj.posShadingY = -1; cnf->adj.tpaShadingY = -1; cnf->adj.negShadingY = -1; cnf->adj.rgain = -1; cnf->adj.ggain = -1; cnf->adj.bgain = -1; cnf->adj.rofs = -1; cnf->adj.gofs = -1; cnf->adj.bofs = -1; cnf->adj.rlampoff = -1; cnf->adj.glampoff = -1; cnf->adj.blampoff = -1; cnf->adj.incDarkTgt = 1; cnf->adj.graygamma = 1.0; cnf->adj.rgamma = 1.0; cnf->adj.ggamma = 1.0; cnf->adj.bgamma = 1.0; } /** intialize the backend */ SANE_Status sane_init( SANE_Int *version_code, SANE_Auth_Callback authorize ) { char str[PATH_MAX] = _DEFAULT_DEVICE; CnfDef config; size_t len; FILE *fp; DBG_INIT(); sanei_usb_init(); sanei_lm983x_init(); sanei_thread_init(); sanei_access_init(STRINGIFY(BACKEND_NAME)); #if defined PACKAGE && defined VERSION DBG( _DBG_INFO, "Plustek backend V"BACKEND_VERSION", part of " PACKAGE " " VERSION "\n"); #else DBG( _DBG_INFO, "Plustek backend V"BACKEND_VERSION"\n" ); #endif /* do some presettings... */ auth = authorize; first_dev = NULL; first_handle = NULL; num_devices = 0; usbDevs = NULL; /* initialize the configuration structure */ init_config_struct( &config ); /* try and get a list of all connected AND supported devices */ usbGetList( &usbDevs ); if( version_code != NULL ) *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open( PLUSTEK_CONFIG_FILE ); /* default to _DEFAULT_DEVICE instead of insisting on config file */ if( NULL == fp ) { return attach( _DEFAULT_DEVICE, &config, 0 ); } while( sanei_config_read( str, sizeof(str), fp)) { DBG( _DBG_SANE_INIT, ">%s<\n", str ); if( str[0] == '#') /* ignore line comments */ continue; len = strlen(str); if( 0 == len ) continue; /* ignore empty lines */ /* check for options */ if( 0 == strncmp(str, "option", 6)) { int ival; double dval; ival = -1; decodeVal( str, "warmup", _INT, &config.adj.warmup, &ival); decodeVal( str, "lampOff", _INT, &config.adj.lampOff, &ival); decodeVal( str, "lOffOnEnd", _INT, &config.adj.lampOffOnEnd,&ival); decodeVal( str, "posShadingY",_INT, &config.adj.posShadingY,&ival); decodeVal( str, "tpaShadingY",_INT, &config.adj.tpaShadingY,&ival); decodeVal( str, "negShadingY",_INT, &config.adj.negShadingY,&ival); decodeVal( str, "red_gain", _INT, &config.adj.rgain, &ival); decodeVal( str, "green_gain", _INT, &config.adj.ggain, &ival); decodeVal( str, "blue_gain", _INT, &config.adj.bgain, &ival); decodeVal( str, "red_offset", _INT, &config.adj.rofs, &ival); decodeVal( str, "green_offset" , _INT, &config.adj.gofs, &ival); decodeVal( str, "blue_offset", _INT, &config.adj.bofs, &ival); decodeVal( str, "red_lampoff", _INT, &config.adj.rlampoff,&ival); decodeVal( str, "green_lampoff", _INT, &config.adj.glampoff,&ival); decodeVal( str, "blue_lampoff", _INT, &config.adj.blampoff,&ival); ival = 0; decodeVal( str, "enableTPA", _INT, &config.adj.enableTpa, &ival); decodeVal( str, "cacheCalData", _INT, &config.adj.cacheCalData,&ival); decodeVal( str, "altCalibration", _INT, &config.adj.altCalibrate,&ival); decodeVal( str, "skipCalibration", _INT, &config.adj.skipCalibration,&ival); decodeVal( str, "skipFine", _INT, &config.adj.skipFine,&ival); decodeVal( str, "skipFineWhite", _INT, &config.adj.skipFineWhite,&ival); decodeVal( str, "skipDarkStrip", _INT, &config.adj.skipDarkStrip,&ival); decodeVal( str, "incDarkTarget", _INT, &config.adj.incDarkTgt,&ival); decodeVal( str, "invertNegatives", _INT, &config.adj.invertNegatives,&ival); decodeVal( str, "disableSpeedup", _INT, &config.adj.disableSpeedup,&ival); decodeVal( str, "posOffX", _INT, &config.adj.pos.x, &ival ); decodeVal( str, "posOffY", _INT, &config.adj.pos.y, &ival ); decodeVal( str, "negOffX", _INT, &config.adj.neg.x, &ival ); decodeVal( str, "negOffY", _INT, &config.adj.neg.y, &ival ); decodeVal( str, "tpaOffX", _INT, &config.adj.tpa.x, &ival ); decodeVal( str, "tpaOffY", _INT, &config.adj.tpa.y, &ival ); decodeVal( str, "mov", _INT, &config.adj.mov, &ival); dval = 1.0; decodeVal( str, "grayGamma", _FLOAT, &config.adj.graygamma,&dval); decodeVal( str, "redGamma", _FLOAT, &config.adj.rgamma, &dval ); decodeVal( str, "greenGamma", _FLOAT, &config.adj.ggamma, &dval ); decodeVal( str, "blueGamma", _FLOAT, &config.adj.bgamma, &dval ); continue; /* check for sections: */ } else if( 0 == strncmp( str, _SECTION, strlen(_SECTION))) { char *tmp; /* new section, try and attach previous device */ if( config.devName[0] != '\0' ) { attach( config.devName, &config, 0 ); } else { if( first_dev != NULL ) { DBG( _DBG_WARNING, "section contains no device name," " ignored!\n" ); } } /* re-initialize the configuration structure */ init_config_struct( &config ); tmp = config.usbId; decodeUsbIDs( str, &tmp ); DBG( _DBG_SANE_INIT, "... next device\n" ); continue; } else if( SANE_TRUE == decodeDevName( str, config.devName )) { continue; } /* ignore other stuff... */ DBG( _DBG_SANE_INIT, "ignoring >%s<\n", str ); } fclose (fp); /* try to attach the last device in the config file... */ if( config.devName[0] != '\0' ) attach( config.devName, &config, 0 ); return SANE_STATUS_GOOD; } /** cleanup the backend... */ void sane_exit( void ) { DevList *tmp; Plustek_Device *dev, *next; DBG( _DBG_SANE_INIT, "sane_exit\n" ); for( dev = first_dev; dev; ) { next = dev->next; /* call the shutdown function of each device... */ usbDev_shutdown( dev ); /* we're doin' this to avoid compiler warnings as dev->sane.name * is defined as const char* */ if( dev->sane.name ) free( dev->name ); if( dev->calFile ) free( dev->calFile ); if( dev->res_list ) free( dev->res_list ); free( dev ); dev = next; } if( devlist ) free( devlist ); while( usbDevs ) { tmp = usbDevs->next; free( usbDevs ); usbDevs = tmp; } usbDevs = NULL; devlist = NULL; auth = NULL; first_dev = NULL; first_handle = NULL; } /** return a list of all devices */ SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only ) { int i; Plustek_Device *dev; DBG(_DBG_SANE_INIT, "sane_get_devices (%p, %ld)\n", (void *)device_list, (long) local_only); /* already called, so cleanup */ if( devlist ) free( devlist ); devlist = malloc((num_devices + 1) * sizeof (devlist[0])); if ( NULL == devlist ) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } /** open the sane device */ SANE_Status sane_open( SANE_String_Const devicename, SANE_Handle* handle ) { SANE_Status status; Plustek_Device *dev; Plustek_Scanner *s; CnfDef config; DBG( _DBG_SANE_INIT, "sane_open - %s\n", devicename ); if( devicename[0] ) { for( dev = first_dev; dev; dev = dev->next ) { if( strcmp( dev->sane.name, devicename ) == 0 ) break; } if( !dev ) { memset(&config, 0, sizeof(CnfDef)); status = attach( devicename, &config, &dev ); if( SANE_STATUS_GOOD != status ) return status; } } else { /* empty devicename -> use first device */ dev = first_dev; } if( !dev ) return SANE_STATUS_INVAL; s = malloc (sizeof (*s)); if( NULL == s ) return SANE_STATUS_NO_MEM; memset(s, 0, sizeof (*s)); s->r_pipe = -1; s->w_pipe = -1; s->hw = dev; s->scanning = SANE_FALSE; s->calibrating = SANE_FALSE; init_options(s); /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; return SANE_STATUS_GOOD; } /** */ void sane_close( SANE_Handle handle ) { Plustek_Scanner *prev, *s = handle; DBG( _DBG_SANE_INIT, "sane_close\n" ); if( s->calibrating ) do_cancel( s, SANE_FALSE ); /* 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) { DBG( _DBG_ERROR, "close: invalid handle %p\n", handle); return; } close_pipe( s ); if( NULL != s->buf ) free(s->buf); drvclose( s->hw ); if (prev) prev->next = s->next; else first_handle = s->next; free(s); } /** goes through a string list and returns the start-address of the string * that has been found, or NULL on error */ static const SANE_String_Const* search_string_list( const SANE_String_Const *list, SANE_String value ) { while( *list != NULL && strcmp(value, *list) != 0 ) ++list; if( *list == NULL ) return NULL; return list; } /** */ static int do_calibration( void *args ) { Plustek_Scanner *s = (Plustek_Scanner *)args; Plustek_Device *dev = s->hw; DCapsDef *caps = &dev->usbDev.Caps; int scanmode, rc; int modes[] = { COLOR_BW, COLOR_256GRAY, COLOR_GRAY16, COLOR_TRUE24, COLOR_TRUE48 }; thread_entry(); /* if the device does only support color scanning, there's no need * to calibrate the gray modes */ if (caps->workaroundFlag & _WAF_GRAY_FROM_COLOR) scanmode = 3; else scanmode = 0; for ( ; scanmode < 5; scanmode++ ) { if (caps->workaroundFlag & _WAF_ONLY_8BIT) { if ((modes[scanmode] == COLOR_GRAY16) || (modes[scanmode] == COLOR_TRUE48)) { continue; } } dev->scanning.dwFlag |= SCANFLAG_Calibration; if (SANE_STATUS_GOOD == local_sane_start(s, modes[scanmode])) { /* prepare for scanning: speed-test, warmup, calibration */ rc = usbDev_Prepare( dev, s->buf ); if( rc != 0 || scanmode == 4) { if (rc != 0 ) DBG(_DBG_INFO,"Calibration canceled!\n"); m_fStart = SANE_TRUE; m_fAutoPark = SANE_TRUE; } drvclose( dev ); if( rc != 0 ) break; } else { DBG(_DBG_ERROR, "local_sane_start() failed!\n"); break; } } /* restore the settings */ dev->scanning.dwFlag &= ~SCANFLAG_Calibration; s->calibrating = SANE_FALSE; return 0; } /** return or set the parameter values, also do some checks */ SANE_Status sane_control_option( SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int *info ) { Plustek_Scanner *s = (Plustek_Scanner *)handle; Plustek_Device *dev = s->hw; AdjDef *adj = &dev->adj; DCapsDef *caps = &dev->usbDev.Caps; SANE_Status status; const SANE_String_Const *optval; int scanmode; if (s->scanning) return SANE_STATUS_DEVICE_BUSY; /* in calibration mode, we do not allow setting any value! */ if(s->calibrating) { if (action == SANE_ACTION_SET_VALUE) { if (option == OPT_CALIBRATE) { if( NULL != info ) *info |= SANE_INFO_RELOAD_OPTIONS; do_cancel(s, SANE_TRUE); return SANE_STATUS_GOOD; } /* okay, we need some exceptions */ switch (option) { case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: break; default: return SANE_STATUS_DEVICE_BUSY; } } } if ((option < 0) || (option >= NUM_OPTIONS)) return SANE_STATUS_INVAL; if (NULL != info) *info = 0; switch( action ) { case SANE_ACTION_GET_VALUE: switch (option) { case OPT_PREVIEW: case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_BIT_DEPTH: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_LAMPSWITCH: case OPT_CUSTOM_GAMMA: case OPT_LAMPOFF_ONEND: case OPT_LOFF4DARK: case OPT_CACHECAL: case OPT_SPEEDUP: case OPT_OVR_REDGAIN: case OPT_OVR_GREENGAIN: case OPT_OVR_BLUEGAIN: case OPT_OVR_REDOFS: case OPT_OVR_GREENOFS: case OPT_OVR_BLUEOFS: case OPT_OVR_RED_LOFF: case OPT_OVR_GREEN_LOFF: case OPT_OVR_BLUE_LOFF: case OPT_LAMPOFF_TIMER: case OPT_WARMUPTIME: *(SANE_Word *)value = s->val[option].w; break; case OPT_BUTTON_0: if(!s->calibrating) usb_UpdateButtonStatus(s); // fall through case OPT_BUTTON_1: case OPT_BUTTON_2: case OPT_BUTTON_3: case OPT_BUTTON_4: /* copy the button state */ *(SANE_Word*)value = s->val[option].w; /* clear the button state */ s->val[option].w = SANE_FALSE; break; case OPT_CONTRAST: case OPT_BRIGHTNESS: *(SANE_Word *)value = (s->val[option].w << SANE_FIXED_SCALE_SHIFT); break; case OPT_MODE: case OPT_EXT_MODE: strcpy ((char *) value, s->opt[option].constraint.string_list[s->val[option].w]); break; /* word array options: */ case OPT_GAMMA_VECTOR: DBG( _DBG_INFO, "Reading MASTER gamma.\n" ); memcpy( value, s->val[option].wa, s->opt[option].size ); break; case OPT_GAMMA_VECTOR_R: DBG( _DBG_INFO, "Reading RED gamma.\n" ); memcpy( value, s->val[option].wa, s->opt[option].size ); break; case OPT_GAMMA_VECTOR_G: DBG( _DBG_INFO, "Reading GREEN gamma.\n" ); memcpy( value, s->val[option].wa, s->opt[option].size ); break; case OPT_GAMMA_VECTOR_B: DBG( _DBG_INFO, "Reading BLUE gamma.\n" ); memcpy( value, s->val[option].wa, s->opt[option].size ); break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_VALUE: status = sanei_constrain_value( s->opt + option, value, info ); if( SANE_STATUS_GOOD != status ) return status; optval = NULL; if( SANE_CONSTRAINT_STRING_LIST == s->opt[option].constraint_type ) { optval = search_string_list( s->opt[option].constraint.string_list, (char *) value); if( NULL == optval ) return SANE_STATUS_INVAL; } switch (option) { case OPT_RESOLUTION: { int n; int min_d = dev->res_list[dev->res_list_size - 1]; int v = *(SANE_Word *)value; int best = v; for( n = 0; n < dev->res_list_size; n++ ) { int d = abs(v - dev->res_list[n]); if( d < min_d ) { min_d = d; best = dev->res_list[n]; } } s->val[option].w = (SANE_Word)best; if( v != best ) *(SANE_Word *)value = best; if( NULL != info ) { if( v != best ) *info |= SANE_INFO_INEXACT; *info |= SANE_INFO_RELOAD_PARAMS; } break; } case OPT_PREVIEW: case OPT_BIT_DEPTH: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: s->val[option].w = *(SANE_Word *)value; if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_CACHECAL: s->val[option].w = *(SANE_Word *)value; dev->adj.cacheCalData = s->val[option].w; if( !dev->adj.cacheCalData ) _DISABLE(OPT_CALIBRATE); else { if( usb_IsCISDevice(dev) || dev->adj.altCalibrate) _ENABLE(OPT_CALIBRATE); } if( NULL != info ) *info |= SANE_INFO_RELOAD_OPTIONS; break; case OPT_CALIBRATE: if (s->calibrating) { do_cancel( s, SANE_FALSE ); s->calibrating = SANE_FALSE; } else { sc = s; s->r_pipe = -1; s->w_pipe = -1; s->reader_pid = sanei_thread_begin(do_calibration, s); s->calibrating = SANE_TRUE; signal( SIGCHLD, sig_chldhandler ); } if (NULL != info) *info |= SANE_INFO_RELOAD_OPTIONS; break; case OPT_SPEEDUP: s->val[option].w = *(SANE_Word *)value; dev->adj.disableSpeedup = !(s->val[option].w); break; case OPT_LOFF4DARK: s->val[option].w = *(SANE_Word *)value; dev->adj.skipDarkStrip = !(s->val[option].w); break; case OPT_LAMPSWITCH: s->val[option].w = *(SANE_Word *)value; usb_LampSwitch( dev, s->val[option].w ); if( s->val[option].w == 0 ) usb_StopLampTimer( dev ); else usb_StartLampTimer( dev ); break; case OPT_LAMPOFF_ONEND: s->val[option].w = *(SANE_Word *)value; dev->adj.lampOffOnEnd = s->val[option].w; usb_CheckAndCopyAdjs( dev ); break; case OPT_CUSTOM_GAMMA: s->val[option].w = *(SANE_Word *)value; if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; scanmode = getScanMode( s ); _DISABLE(OPT_GAMMA_VECTOR); _DISABLE(OPT_GAMMA_VECTOR_R); _DISABLE(OPT_GAMMA_VECTOR_G); _DISABLE(OPT_GAMMA_VECTOR_B); if( SANE_TRUE == s->val[option].w ) { DBG( _DBG_INFO, "Using custom gamma settings.\n" ); if((scanmode == COLOR_256GRAY) || (scanmode == COLOR_GRAY16)) { _ENABLE(OPT_GAMMA_VECTOR); } else { _ENABLE(OPT_GAMMA_VECTOR_R); _ENABLE(OPT_GAMMA_VECTOR_G); _ENABLE(OPT_GAMMA_VECTOR_B); } } else { DBG( _DBG_INFO, "NOT using custom gamma settings.\n" ); initGammaSettings( s ); if((scanmode == COLOR_256GRAY) || (scanmode == COLOR_GRAY16)) { _DISABLE(OPT_GAMMA_VECTOR); } else { _DISABLE(OPT_GAMMA_VECTOR_R); _DISABLE(OPT_GAMMA_VECTOR_G); _DISABLE(OPT_GAMMA_VECTOR_B); } } break; case OPT_LAMPOFF_TIMER: s->val[option].w = (*(SANE_Word *)value); adj->lampOff = (*(SANE_Word *)value); usb_CheckAndCopyAdjs( dev ); break; case OPT_WARMUPTIME: s->val[option].w = (*(SANE_Word *)value); adj->warmup = (*(SANE_Word *)value); usb_CheckAndCopyAdjs( dev ); break; case OPT_OVR_REDGAIN: s->val[option].w = (*(SANE_Word *)value); adj->rgain = (*(SANE_Word *)value); break; case OPT_OVR_GREENGAIN: s->val[option].w = (*(SANE_Word *)value); adj->ggain = (*(SANE_Word *)value); break; case OPT_OVR_BLUEGAIN: s->val[option].w = (*(SANE_Word *)value); adj->bgain = (*(SANE_Word *)value); break; case OPT_OVR_REDOFS: s->val[option].w = (*(SANE_Word *)value); adj->rofs = (*(SANE_Word *)value); break; case OPT_OVR_GREENOFS: s->val[option].w = (*(SANE_Word *)value); adj->gofs = (*(SANE_Word *)value); break; case OPT_OVR_BLUEOFS: s->val[option].w = (*(SANE_Word *)value); adj->bofs = (*(SANE_Word *)value); break; case OPT_OVR_RED_LOFF: s->val[option].w = (*(SANE_Word *)value); adj->rlampoff = (*(SANE_Word *)value); break; case OPT_OVR_GREEN_LOFF: s->val[option].w = (*(SANE_Word *)value); adj->glampoff = (*(SANE_Word *)value); break; case OPT_OVR_BLUE_LOFF: s->val[option].w = (*(SANE_Word *)value); adj->blampoff = (*(SANE_Word *)value); break; case OPT_CONTRAST: case OPT_BRIGHTNESS: s->val[option].w = ((*(SANE_Word *)value) >> SANE_FIXED_SCALE_SHIFT); break; case OPT_MODE: s->val[option].w = optval - s->opt[option].constraint.string_list; scanmode = getScanMode( s ); _ENABLE(OPT_CONTRAST); _ENABLE(OPT_BIT_DEPTH); _ENABLE(OPT_CUSTOM_GAMMA); if (scanmode == COLOR_BW) { _DISABLE(OPT_CONTRAST); _DISABLE(OPT_CUSTOM_GAMMA); _DISABLE(OPT_BIT_DEPTH); } if (caps->workaroundFlag & _WAF_ONLY_8BIT) _DISABLE(OPT_BIT_DEPTH); _DISABLE(OPT_GAMMA_VECTOR); _DISABLE(OPT_GAMMA_VECTOR_R); _DISABLE(OPT_GAMMA_VECTOR_G); _DISABLE(OPT_GAMMA_VECTOR_B); if( s->val[OPT_CUSTOM_GAMMA].w && !(s->opt[OPT_CUSTOM_GAMMA].cap & SANE_CAP_INACTIVE)) { if((scanmode == COLOR_256GRAY) || (scanmode == COLOR_GRAY16)) { _ENABLE(OPT_GAMMA_VECTOR); } else { _ENABLE(OPT_GAMMA_VECTOR_R); _ENABLE(OPT_GAMMA_VECTOR_G); _ENABLE(OPT_GAMMA_VECTOR_B); } } if( NULL != info ) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; break; case OPT_EXT_MODE: { s->val[option].w = optval - s->opt[option].constraint.string_list; /* change the area and mode_list when changing the source */ if( s->val[option].w == 0 ) { dev->scanning.sParam.bSource = SOURCE_Reflection; dev->dpi_range.min = _DEF_DPI; dev->x_range.max = SANE_FIX(dev->max_x); dev->y_range.max = SANE_FIX(dev->max_y); s->val[OPT_TL_X].w = SANE_FIX(_DEFAULT_TLX); s->val[OPT_TL_Y].w = SANE_FIX(_DEFAULT_TLY); s->val[OPT_BR_X].w = SANE_FIX(_DEFAULT_BRX); s->val[OPT_BR_Y].w = SANE_FIX(_DEFAULT_BRY); s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].w = 2; /* HEINER COLOR_TRUE24;*/ } else { dev->dpi_range.min = _TPAMinDpi; if( s->val[option].w == 1 ) { dev->scanning.sParam.bSource = SOURCE_Transparency; if( dev->usbDev.Caps.wFlags & DEVCAPSFLAG_LargeTPA ) { dev->x_range.max = SANE_FIX(_SCALE(_TPALargePageWidth)); dev->y_range.max = SANE_FIX(_SCALE(_TPALargePageHeight)); } else { dev->x_range.max = SANE_FIX(_SCALE(_TPAPageWidth)); dev->y_range.max = SANE_FIX(_SCALE(_TPAPageHeight)); } s->val[OPT_TL_X].w = SANE_FIX(_DEFAULT_TP_TLX); s->val[OPT_TL_Y].w = SANE_FIX(_DEFAULT_TP_TLY); s->val[OPT_BR_X].w = SANE_FIX(_DEFAULT_TP_BRX); s->val[OPT_BR_Y].w = SANE_FIX(_DEFAULT_TP_BRY); } else { dev->scanning.sParam.bSource = SOURCE_Negative; if( dev->usbDev.Caps.wFlags & DEVCAPSFLAG_LargeTPA ) { dev->x_range.max = SANE_FIX(_SCALE(_NegLargePageWidth)); dev->y_range.max = SANE_FIX(_SCALE(_NegLargePageHeight)); } else { dev->x_range.max = SANE_FIX(_SCALE(_NegPageWidth)); dev->y_range.max = SANE_FIX(_SCALE(_NegPageHeight)); } s->val[OPT_TL_X].w = SANE_FIX(_DEFAULT_NEG_TLX); s->val[OPT_TL_Y].w = SANE_FIX(_DEFAULT_NEG_TLY); s->val[OPT_BR_X].w = SANE_FIX(_DEFAULT_NEG_BRX); s->val[OPT_BR_Y].w = SANE_FIX(_DEFAULT_NEG_BRY); } s->opt[OPT_MODE].constraint.string_list = &mode_list[2]; s->val[OPT_MODE].w = 0; /* COLOR_24 is the default */ } if( s->val[OPT_LAMPSWITCH].w != 0 ) { usb_LampSwitch( dev, s->val[OPT_LAMPSWITCH].w ); if( s->val[OPT_LAMPSWITCH].w == 0 ) usb_StopLampTimer( dev ); else usb_StartLampTimer( dev ); } _ENABLE(OPT_CONTRAST); if( NULL != info ) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; break; } case OPT_GAMMA_VECTOR: DBG( _DBG_INFO, "Setting MASTER gamma.\n" ); memcpy( s->val[option].wa, value, s->opt[option].size ); checkGammaSettings(s); if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_GAMMA_VECTOR_R: DBG( _DBG_INFO, "Setting RED gamma.\n" ); memcpy( s->val[option].wa, value, s->opt[option].size ); checkGammaSettings(s); if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_GAMMA_VECTOR_G: DBG( _DBG_INFO, "Setting GREEN gamma.\n" ); memcpy( s->val[option].wa, value, s->opt[option].size ); checkGammaSettings(s); if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_GAMMA_VECTOR_B: DBG( _DBG_INFO, "Setting BLUE gamma.\n" ); memcpy( s->val[option].wa, value, s->opt[option].size ); checkGammaSettings(s); if( NULL != info ) *info |= SANE_INFO_RELOAD_PARAMS; break; default: return SANE_STATUS_INVAL; } break; default: return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /** according to the option number, return a pointer to a descriptor */ const SANE_Option_Descriptor* sane_get_option_descriptor( SANE_Handle handle, SANE_Int option ) { Plustek_Scanner *s = (Plustek_Scanner *)handle; if((option < 0) || (option >= NUM_OPTIONS)) return NULL; return &(s->opt[option]); } /** return the current parameter settings */ SANE_Status sane_get_parameters( SANE_Handle handle, SANE_Parameters *params ) { int ndpi; int scanmode; Plustek_Scanner *s = (Plustek_Scanner *)handle; /* if we're calling from within, calc best guess * do the same, if sane_get_parameters() is called * by a frontend before sane_start() is called */ if((NULL == params) || (s->scanning != SANE_TRUE)) { memset(&s->params, 0, sizeof (SANE_Parameters)); ndpi = s->val[OPT_RESOLUTION].w; s->params.pixels_per_line = SANE_UNFIX(s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) / MM_PER_INCH * ndpi; s->params.lines = SANE_UNFIX( s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) / MM_PER_INCH * ndpi; /* pixels_per_line seems to be 8 * n. */ /* s->params.pixels_per_line = s->params.pixels_per_line & ~7; debug only */ s->params.last_frame = SANE_TRUE; scanmode = getScanMode( s ); if( scanmode == COLOR_TRUE24 || scanmode == COLOR_TRUE48 ) { s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line = 3 * s->params.pixels_per_line; } else { s->params.format = SANE_FRAME_GRAY; if (s->params.depth == 1) s->params.bytes_per_line = (s->params.pixels_per_line + 7) / 8; else s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8; } /* if sane_get_parameters() was called before sane_start() */ /* pass new values to the caller */ if ((NULL != params) && (s->scanning != SANE_TRUE)) *params = s->params; } else { *params = s->params; } return SANE_STATUS_GOOD; } /** initiate the scan process */ static SANE_Status local_sane_start(Plustek_Scanner *s, int scanmode ) { Plustek_Device *dev; int result; int ndpi; int left, top; int width, height; double dpi_x, dpi_y; CropInfo crop; ScanInfo sinfo; SANE_Word tmp; /* clear it out just in case */ memset(&crop, 0, sizeof(crop)); dev = s->hw; /* check if we're called from the option dialog! */ if (usb_InCalibrationMode(dev)) crop.ImgDef.dwFlag = SCANFLAG_Calibration; /* open the driver and get some information about the scanner */ dev->fd = usbDev_open( dev, NULL, SANE_TRUE ); if( dev->fd < 0 ) { DBG( _DBG_ERROR, "sane_start: open failed: %d\n", errno); if( errno == EBUSY ) return SANE_STATUS_DEVICE_BUSY; return SANE_STATUS_IO_ERROR; } result = usbDev_getCaps( dev ); if( result < 0 ) { DBG( _DBG_ERROR, "usbDev_getCaps() failed(%d)\n", result); sanei_access_unlock( dev->sane.name ); usbDev_close( dev ); return SANE_STATUS_IO_ERROR; } /* All ready to go. Set image def and see what the scanner * says for crop info. */ ndpi = s->val[OPT_RESOLUTION].w; /* exchange the values as we can't deal with * negative heights and so on...*/ tmp = s->val[OPT_TL_X].w; if( tmp > s->val[OPT_BR_X].w ) { DBG( _DBG_INFO, "exchanging BR-X - TL-X\n" ); s->val[OPT_TL_X].w = s->val[OPT_BR_X].w; s->val[OPT_BR_X].w = tmp; } tmp = s->val[OPT_TL_Y].w; if( tmp > s->val[OPT_BR_Y].w ) { DBG( _DBG_INFO, "exchanging BR-Y - TL-Y\n" ); s->val[OPT_TL_Y].w = s->val[OPT_BR_Y].w; s->val[OPT_BR_Y].w = tmp; } /* position and extent are always relative to 300 dpi */ dpi_x = (double)dev->usbDev.Caps.OpticDpi.x; dpi_y = (double)dev->usbDev.Caps.OpticDpi.x * 2; left = (int)(SANE_UNFIX (s->val[OPT_TL_X].w)*dpi_x/ (MM_PER_INCH*(dpi_x/300.0))); top = (int)(SANE_UNFIX (s->val[OPT_TL_Y].w)*dpi_y/ (MM_PER_INCH*(dpi_y/300.0))); width = (int)(SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) * dpi_x / (MM_PER_INCH *(dpi_x/300.0))); height = (int)(SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) * dpi_y / (MM_PER_INCH *(dpi_y/300.0))); /* adjust mode list according to the model we use and the * source we have */ DBG( _DBG_INFO, "scanmode = %u\n", scanmode ); crop.ImgDef.xyDpi.x = ndpi; crop.ImgDef.xyDpi.y = ndpi; crop.ImgDef.crArea.x = left; /* offset from left edge to area you want to scan */ crop.ImgDef.crArea.y = top; /* offset from top edge to area you want to scan */ crop.ImgDef.crArea.cx = width; /* always relative to 300 dpi */ crop.ImgDef.crArea.cy = height; crop.ImgDef.wDataType = scanmode; crop.ImgDef.dwFlag |= SCANDEF_QualityScan; switch( s->val[OPT_EXT_MODE].w ) { case 1: crop.ImgDef.dwFlag |= SCANDEF_Transparency; break; case 2: crop.ImgDef.dwFlag |= SCANDEF_Negative; break; default: break; } result = usbDev_getCropInfo( dev, &crop ); if( result < 0 ) { DBG( _DBG_ERROR, "usbDev_getCropInfo() failed(%d)\n", result ); usbDev_close( dev ); sanei_access_unlock( dev->sane.name ); return SANE_STATUS_IO_ERROR; } /* DataInf.dwAppPixelsPerLine = crop.dwPixelsPerLine; */ s->params.pixels_per_line = crop.dwPixelsPerLine; s->params.bytes_per_line = crop.dwBytesPerLine; s->params.lines = crop.dwLinesPerArea; /* build a SCANINFO block and get ready to scan it */ crop.ImgDef.dwFlag |= SCANDEF_QualityScan; /* remove that for preview scans */ if( s->val[OPT_PREVIEW].w ) crop.ImgDef.dwFlag &= (~SCANDEF_QualityScan); /* set adjustments for brightness and contrast */ sinfo.siBrightness = s->val[OPT_BRIGHTNESS].w; sinfo.siContrast = s->val[OPT_CONTRAST].w; memcpy( &sinfo.ImgDef, &crop.ImgDef, sizeof(ImgDef)); DBG( _DBG_SANE_INIT, "brightness %i, contrast %i\n", sinfo.siBrightness, sinfo.siContrast ); result = usbDev_setScanEnv( dev, &sinfo ); if( result < 0 ) { DBG( _DBG_ERROR, "usbDev_setScanEnv() failed(%d)\n", result ); usbDev_close( dev ); sanei_access_unlock( dev->sane.name ); return SANE_STATUS_IO_ERROR; } /* download gamma correction tables... */ if( scanmode <= COLOR_GRAY16 ) { usbDev_setMap( dev, s->gamma_table[0], s->gamma_length, _MAP_MASTER); } else { usbDev_setMap( dev, s->gamma_table[1], s->gamma_length, _MAP_RED ); usbDev_setMap( dev, s->gamma_table[2], s->gamma_length, _MAP_GREEN ); usbDev_setMap( dev, s->gamma_table[3], s->gamma_length, _MAP_BLUE ); } tsecs = 0; /* reset timer */ result = usbDev_startScan( dev ); if( result < 0 ) { DBG( _DBG_ERROR, "usbDev_startScan() failed(%d)\n", result ); usbDev_close( dev ); sanei_access_unlock( dev->sane.name ); return SANE_STATUS_IO_ERROR; } DBG( _DBG_SANE_INIT, "dwflag = 0x%lx dwBytesLine = %ld\n", dev->scanning.dwFlag, dev->scanning.dwBytesLine ); DBG( _DBG_SANE_INIT, "Lines = %d\n", s->params.lines); DBG( _DBG_SANE_INIT, "Bytes per Line = %d\n", s->params.bytes_per_line ); DBG( _DBG_SANE_INIT, "Bitdepth = %d\n", s->params.depth ); if (usb_InCalibrationMode(dev)) { if (s->buf) free(s->buf); s->buf = NULL; } else { if (s->params.lines == 0 || s->params.bytes_per_line == 0) { DBG( _DBG_ERROR, "nothing to scan!\n" ); usbDev_close( dev ); sanei_access_unlock( dev->sane.name ); return SANE_STATUS_INVAL; } s->buf = realloc( s->buf, (s->params.lines) * s->params.bytes_per_line ); if( NULL == s->buf ) { DBG( _DBG_ERROR, "realloc failed\n" ); usbDev_close( dev ); sanei_access_unlock( dev->sane.name ); return SANE_STATUS_NO_MEM; } } tsecs = (unsigned long)time(NULL); DBG( _DBG_INFO, "TIME START\n" ); DBG( _DBG_SANE_INIT, "local_sane_start done\n" ); return SANE_STATUS_GOOD; } /** initiate the scan process */ SANE_Status sane_start( SANE_Handle handle ) { Plustek_Scanner *s = (Plustek_Scanner *)handle; Plustek_Device *dev = s->hw; SANE_Status status; int fds[2]; DBG( _DBG_SANE_INIT, "sane_start\n" ); if (s->scanning) return SANE_STATUS_DEVICE_BUSY; /* in the end we wait until the calibration is done... */ if (s->calibrating) { while (s->calibrating) { sleep(1); } /* we have been cancelled? */ if (cancelRead) return SANE_STATUS_CANCELLED; } status = sane_get_parameters (handle, NULL); if (status != SANE_STATUS_GOOD) { DBG( _DBG_ERROR, "sane_get_parameters failed\n" ); return status; } status = local_sane_start(s, getScanMode(s)); if (status != SANE_STATUS_GOOD) { return status; } s->scanning = SANE_TRUE; /* * everything prepared, so start the child process and a pipe to communicate * pipe --> fds[0]=read-fd, fds[1]=write-fd */ if( pipe(fds) < 0 ) { DBG( _DBG_ERROR, "ERROR: could not create pipe\n" ); s->scanning = SANE_FALSE; usbDev_close( dev ); return SANE_STATUS_IO_ERROR; } /* create reader routine as new process */ s->bytes_read = 0; s->r_pipe = fds[0]; s->w_pipe = fds[1]; s->ipc_read_done = SANE_FALSE; s->reader_pid = sanei_thread_begin( reader_process, s ); cancelRead = SANE_FALSE; 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 ); return SANE_STATUS_IO_ERROR; } signal( SIGCHLD, sig_chldhandler ); if( sanei_thread_is_forked()) { close( s->w_pipe ); s->w_pipe = -1; } DBG( _DBG_SANE_INIT, "sane_start done\n" ); return SANE_STATUS_GOOD; } /** function to read the data from our child process */ SANE_Status sane_read( SANE_Handle handle, SANE_Byte *data, SANE_Int max_length, SANE_Int *length ) { Plustek_Scanner *s = (Plustek_Scanner*)handle; ssize_t nread; #ifdef USE_IPC static IPCDef ipc; unsigned char *buf; static unsigned long c = 0; #endif *length = 0; #ifdef USE_IPC /* first try and read IPC... */ if( !s->ipc_read_done ) { buf = (unsigned char*)&ipc; for( c = 0; c < sizeof(ipc); ) { nread = read( s->r_pipe, buf, sizeof(ipc)); if( nread < 0 ) { if( EAGAIN != errno ) { do_cancel( s, SANE_TRUE ); return SANE_STATUS_IO_ERROR; } else { return SANE_STATUS_GOOD; } } else { c += nread; buf += nread; if( c == sizeof(ipc)) { s->ipc_read_done = SANE_TRUE; break; } } } s->hw->transferRate = ipc.transferRate; DBG( _DBG_INFO, "IPC: Transferrate = %lu Bytes/s\n", ipc.transferRate ); } #endif /* here we read all data from the driver... */ nread = read( s->r_pipe, data, max_length ); DBG( _DBG_READ, "sane_read - read %ld bytes\n", (long)nread ); if (!(s->scanning)) { return do_cancel( s, SANE_TRUE ); } if( nread < 0 ) { if( EAGAIN == errno ) { /* if we already had red the picture, so it's okay and stop */ if( s->bytes_read == (unsigned long)(s->params.lines * s->params.bytes_per_line)) { sanei_thread_waitpid( s->reader_pid, 0 ); sanei_thread_invalidate( s->reader_pid ); s->scanning = SANE_FALSE; drvclose( s->hw ); return close_pipe(s); } /* else force the frontend to try again*/ return SANE_STATUS_GOOD; } else { DBG( _DBG_ERROR, "ERROR: errno=%d\n", errno ); do_cancel( s, SANE_TRUE ); return SANE_STATUS_IO_ERROR; } } *length = nread; s->bytes_read += nread; /* nothing red means that we're finished OR we had a problem... */ if( 0 == nread ) { drvclose( s->hw ); s->exit_code = sanei_thread_get_status( s->reader_pid ); if( SANE_STATUS_GOOD != s->exit_code ) { close_pipe(s); return s->exit_code; } sanei_thread_invalidate( s->reader_pid ); s->scanning = SANE_FALSE; return close_pipe(s); } return SANE_STATUS_GOOD; } /** cancel the scanning process */ void sane_cancel( SANE_Handle handle ) { Plustek_Scanner *s = (Plustek_Scanner *)handle; DBG( _DBG_SANE_INIT, "sane_cancel\n" ); if (s->scanning || s->calibrating) do_cancel( s, SANE_FALSE ); } /** set the pipe to blocking/non blocking mode */ SANE_Status sane_set_io_mode( SANE_Handle handle, SANE_Bool non_blocking ) { Plustek_Scanner *s = (Plustek_Scanner *)handle; DBG( _DBG_SANE_INIT, "sane_set_io_mode: non_blocking=%d\n",non_blocking ); if ( !s->scanning ) { DBG( _DBG_ERROR, "ERROR: not scanning !\n" ); return SANE_STATUS_INVAL; } if( -1 == s->r_pipe ) { DBG( _DBG_ERROR, "ERROR: not supported !\n" ); return SANE_STATUS_UNSUPPORTED; } if( fcntl (s->r_pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) { DBG( _DBG_ERROR, "ERROR: could not set to non-blocking mode !\n" ); return SANE_STATUS_IO_ERROR; } DBG( _DBG_SANE_INIT, "sane_set_io_mode done\n" ); return SANE_STATUS_GOOD; } /** return the descriptor if available */ SANE_Status sane_get_select_fd( SANE_Handle handle, SANE_Int * fd ) { Plustek_Scanner *s = (Plustek_Scanner *)handle; DBG( _DBG_SANE_INIT, "sane_get_select_fd\n" ); if( !s->scanning ) { DBG( _DBG_ERROR, "ERROR: not scanning !\n" ); return SANE_STATUS_INVAL; } *fd = s->r_pipe; DBG( _DBG_SANE_INIT, "sane_get_select_fd done\n" ); return SANE_STATUS_GOOD; } /* END PLUSTEK.C ............................................................*/ sane-backends-1.0.29/backend/mustek_usb_low.c0000666000000000000000000020462713615534521016011 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000 Mustek. Originally maintained by Tom Wang Copyright (C) 2001 - 2004 by Henning Meier-Geinitz. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Mustek 1200UB and similar USB flatbed scanners. */ #include #include "../include/sane/sane.h" #include "../include/sane/sanei_usb.h" #include "mustek_usb_low.h" SANE_Status usb_low_init (ma1017 ** chip_address) { SANE_Int i; ma1017 *chip; DBG (7, "usb_low_init: start\n"); if (!chip_address) return SANE_STATUS_INVAL; chip = (ma1017 *) malloc (sizeof (ma1017)); if (!chip) { DBG (3, "usb_low_init: couldn't malloc %ld bytes for chip\n", (long int) sizeof (ma1017)); *chip_address = 0; return SANE_STATUS_NO_MEM; } *chip_address = chip; /* io */ chip->is_rowing = SANE_FALSE; chip->is_opened = SANE_FALSE; chip->fd = -1; /* Construction/Destruction */ chip->is_opened = SANE_FALSE; chip->is_rowing = SANE_FALSE; /* A2 */ chip->append = 0x00; chip->test_sram = 0x00; chip->fix_pattern = 0x00; /* A4 */ chip->select = 0x00; chip->frontend = 0x00; /* A6 */ chip->rgb_sel_pin = 0x02; chip->asic_io_pins = 0x9c; /* A7 */ chip->timing = 0xe8; chip->sram_bank = 0x02; /* A8 */ chip->dummy_msb = 0x00; chip->ccd_width_msb = 0x00; chip->cmt_table_length = 0x00; /* A9 */ chip->cmt_second_pos = 0x00; /* A10 + A8ID5 */ chip->ccd_width = 0x0c80; /* A11 + A8ID6 */ chip->dummy = 0x0020; /* A12 + A13 */ chip->byte_width = 0x09f6; /* A14 + A30W */ chip->loop_count = 0x0db5; /* A15 */ chip->motor_enable = 0x00; chip->motor_movement = 0x60; chip->motor_direction = 0x10; chip->motor_signal = 0x00; chip->motor_home = 0x00; /* A16 */ chip->pixel_depth = 0x00; chip->image_invert = 0x00; chip->optical_600 = 0x00; chip->sample_way = 0x06; /* A17 + A18 + A19 */ chip->red_ref = 0xff; chip->green_ref = 0xff; chip->blue_ref = 0xff; /* A20 + A21 + A22 */ chip->red_pd = 0x00; chip->green_pd = 0x00; chip->blue_pd = 0x00; /* A23 */ chip->a23 = 0x80; /* A24 */ chip->fy1_delay = 0x00; chip->special_ad = 0x00; /* A27 */ chip->sclk = 0x00; chip->sen = 0x00; chip->serial_length = 0x10; /* Use for Rowing */ chip->get_row = NULL; chip->cmt_table_length_word = 0x00000000; chip->cmt_second_pos_word = 0x00000000; chip->row_size = 0x00; chip->soft_resample = 0x01; chip->total_lines = 0x00; chip->lines_left = 0x00; for (i = 0; i < 32; i++) chip->is_transfer_table[i] = SANE_FALSE; chip->sensor = ST_CANON600; chip->motor = MT_1200; chip->total_read_urbs = 0; chip->total_write_urbs = 0; DBG (7, "usb_low_init: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_exit (ma1017 * chip) { DBG (7, "usb_low_exit: chip = %p\n", (void *) chip); if (chip) { if (chip->fd >= 0 && chip->is_opened) usb_low_close (chip); DBG (7, "usb_low_exit: freeing chip\n"); free (chip); } DBG (5, "usb_low_exit: read %d URBs, wrote %d URBs\n", chip->total_read_urbs, chip->total_write_urbs); DBG (7, "usb_low_exit: exit\n"); return SANE_STATUS_GOOD; } /* A0 ~ A1 */ SANE_Status usb_low_set_cmt_table (ma1017 * chip, SANE_Int index, Channel channel, SANE_Bool is_move_motor, SANE_Bool is_transfer) { SANE_Byte pattern = ((SANE_Byte) index) << 4; SANE_Byte reg_no = 0; SANE_Status status; DBG (7, "usb_low_set_cmt_table: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_cmt_table: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_cmt_table: stop rowing first\n"); return SANE_STATUS_INVAL; } if ((unsigned int) index > 31) { DBG (7, "usb_low_set_cmt_table: CMT index (%d) exceed 31", index); return SANE_STATUS_INVAL; } switch (channel) { case CH_RED: pattern |= 0x04; break; case CH_GREEN: pattern |= 0x08; break; case CH_BLUE: pattern |= 0x0c; break; default: break; } if (is_move_motor) pattern |= 0x02; if (is_transfer) pattern |= 0x01; if (index > 15) reg_no++; RIE (usb_low_write_reg (chip, reg_no, pattern)); chip->is_transfer_table[index] = is_transfer; DBG (7, "usb_low_set_cmt_table: exit\n"); return SANE_STATUS_GOOD; } /* A2 */ SANE_Status usb_low_get_a2 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a2: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a2: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a2: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 2, &pattern)); chip->append = pattern & 0x10; chip->test_sram = pattern & 0x20; chip->fix_pattern = pattern & 0x80; if (value) *value = pattern; DBG (7, "usb_low_get_a2: exit, value =%d\n", pattern); return SANE_STATUS_GOOD; } SANE_Status usb_low_start_cmt_table (ma1017 * chip) { SANE_Byte data_field[2]; SANE_Status status; size_t n; DBG (7, "usb_low_start_cmt_table: start\n"); data_field[0] = 0x02 | chip->append | chip->test_sram | chip->fix_pattern; data_field[1] = 2; if (!chip->is_opened) { DBG (3, "usb_low_start_cmt_table: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (7, "usb_low_start_cmt_table: Already Rowing\n"); return SANE_STATUS_INVAL; } data_field[1] |= 0x60; n = 2; status = sanei_usb_write_bulk (chip->fd, data_field, &n); if (status != SANE_STATUS_GOOD || n != 2) { DBG (3, "usb_low_start_cmt_table: can't write, wanted 2 bytes, " "wrote %lu bytes\n", (unsigned long int) n); return SANE_STATUS_IO_ERROR; } chip->total_write_urbs++; chip->is_rowing = SANE_TRUE; DBG (7, "usb_low_start_cmt_table: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_stop_cmt_table (ma1017 * chip) { SANE_Byte data_field[2]; SANE_Byte read_byte; size_t n; SANE_Status status; DBG (7, "usb_low_stop_cmt_table: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_stop_cmt_table: not opened yet\n"); return SANE_STATUS_INVAL; } if (!chip->is_rowing) { DBG (7, "usb_low_stop_cmt_table: Not Rowing yet\n"); return SANE_STATUS_INVAL; } data_field[0] = 0x01 | chip->append | chip->test_sram | chip->fix_pattern; data_field[1] = 2; data_field[1] |= 0x80; n = 2; status = sanei_usb_write_bulk (chip->fd, data_field, &n); if (status != SANE_STATUS_GOOD || n != 2) { DBG (3, "usb_low_stop_cmt_table: couldn't write, wanted 2 bytes, wrote " "%lu bytes\n", (unsigned long int) n); return SANE_STATUS_IO_ERROR; } chip->total_write_urbs++; n = 1; status = sanei_usb_read_bulk (chip->fd, &read_byte, &n); if (status != SANE_STATUS_GOOD || n != 1) { DBG (3, "usb_low_stop_cmt_table: couldn't read, wanted 1 byte, got %lu " "bytes\n", (unsigned long int) n); return SANE_STATUS_IO_ERROR; } chip->total_read_urbs++; chip->is_rowing = SANE_FALSE; DBG (7, "usb_low_stop_cmt_table: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_test_sram_mode (ma1017 * chip, SANE_Bool is_test) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_test_sram_mode: start\n"); data = chip->append | chip->test_sram | chip->fix_pattern; reg_no = 2; if (!chip->is_opened) { DBG (3, "usb_low_set_test_sram_mode: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_test_sram_mode: stop rowing first\n"); return SANE_STATUS_INVAL; } if (is_test) chip->test_sram = 0x20; else chip->test_sram = 0x00; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_test_sram_mode: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_fix_pattern (ma1017 * chip, SANE_Bool is_fix) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_fix_pattern: start\n"); data = chip->append | chip->test_sram | chip->fix_pattern; reg_no = 2; if (!chip->is_opened) { DBG (3, "usb_low_set_fix_pattern: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_fix_pattern: stop rowing first\n"); return SANE_STATUS_INVAL; } if (is_fix) chip->fix_pattern = 0x80; else chip->fix_pattern = 0x00; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_fix_pattern: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_adjust_timing (ma1017 * chip, SANE_Byte data) { SANE_Status status; SANE_Byte reg_no; DBG (7, "usb_low_adjust_timing: start\n"); reg_no = 3; if (!chip->is_opened) { DBG (3, "usb_low_adjust_timing: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_adjust_timing: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_adjust_timing: exit\n"); return SANE_STATUS_GOOD; } /* A4 */ SANE_Status usb_low_get_a4 (ma1017 * chip, SANE_Byte * value) { SANE_Status status; SANE_Byte pattern; DBG (7, "usb_low_get_a4: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a4: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a4: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 4, &pattern)); chip->select = pattern & 0xfe; chip->frontend = pattern & 0x01; if (value) *value = pattern; DBG (7, "usb_low_get_a4: exit, value=%d\n", pattern); return SANE_STATUS_GOOD; } SANE_Status usb_low_select_timing (ma1017 * chip, SANE_Byte data) { SANE_Status status; SANE_Byte reg_no; DBG (7, "usb_low_select_timing: start\n"); reg_no = 4; if (!chip->is_opened) { DBG (3, "usb_low_select_timing: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_select_timing: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->select = data & 0xfe; chip->frontend = data & 0x01; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_select_timing: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_turn_frontend_mode (ma1017 * chip, SANE_Bool is_on) { SANE_Status status; SANE_Byte data, reg_no; DBG (7, "usb_low_turn_frontend_mode: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_turn_frontend_mode: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_turn_frontend_mode: stop rowing first\n"); return SANE_STATUS_INVAL; } if (is_on) chip->frontend = 0x01; else chip->frontend = 0x00; data = chip->select | chip->frontend; reg_no = 4; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_turn_frontend_mode: exit\n"); return SANE_STATUS_GOOD; } /* A6 */ SANE_Status usb_low_get_a6 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a6: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a6: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a6: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 6, &pattern)); chip->asic_io_pins = pattern & 0xdc; chip->rgb_sel_pin = pattern & 0x03; if (value) *value = pattern; DBG (7, "usb_low_get_a6: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_asic_io_pins (ma1017 * chip, SANE_Byte data) { SANE_Status status; SANE_Byte reg_no; DBG (7, "usb_low_set_asic_io_pins: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_asic_io_pins: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_asic_io_pins: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->asic_io_pins = data & 0xdc; data = chip->asic_io_pins | chip->rgb_sel_pin; reg_no = 6; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_asic_io_pins: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_rgb_sel_pins (ma1017 * chip, SANE_Byte data) { SANE_Status status; SANE_Byte reg_no; DBG (7, "usb_low_set_rgb_sel_pins: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_rgb_sel_pins: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_rgb_sel_pins: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->rgb_sel_pin = data & 0x03; data = chip->asic_io_pins | chip->rgb_sel_pin; reg_no = 6; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_rgb_sel_pins: exit\n"); return SANE_STATUS_GOOD; /* was false? */ } /* A7 */ SANE_Status usb_low_get_a7 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a7: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a7: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a7: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 7, &pattern)); if (value) *value = pattern; chip->timing = pattern & 0xfc; chip->sram_bank = pattern & 0x03; DBG (7, "usb_low_get_a7: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_timing (ma1017 * chip, SANE_Byte data) { SANE_Status status; SANE_Byte reg_no; DBG (7, "usb_low_set_timing: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_timing: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_timing: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->timing = data & 0xfc; data = chip->timing | chip->sram_bank; reg_no = 7; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_timing: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_sram_bank (ma1017 * chip, Banksize banksize) { SANE_Status status; SANE_Byte data, reg_no; DBG (7, "usb_low_set_sram_bank: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_sram_bank: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_sram_bank: stop rowing first\n"); return SANE_STATUS_INVAL; } switch (banksize) { case BS_4K: chip->sram_bank = 0x00; break; case BS_8K: chip->sram_bank = 0x01; break; case BS_16K: chip->sram_bank = 0x02; break; default: DBG (3, "usb_low_set_sram_bank: bsBankSize error\n"); return SANE_STATUS_INVAL; break; } data = chip->timing | chip->sram_bank; reg_no = 7; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_sram_bank: exit\n"); return SANE_STATUS_GOOD; } /* A8 */ SANE_Status usb_low_get_a8 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a8: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a8: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a8: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 8, &pattern)); chip->dummy_msb = pattern & 0x40; chip->ccd_width_msb = pattern & 0x20; chip->cmt_table_length = pattern & 0x1f; chip->ccd_width = ((chip->ccd_width / 32) & 0x00ff) * 32 + ((chip->ccd_width_msb == 0) ? 0 : 0x0100 * 32); chip->dummy = ((chip->dummy / 32) & 0x00ff) * 32 + ((chip->dummy_msb == 0) ? 0 : 0x0100 * 32); if (value) *value = pattern; DBG (7, "usb_low_get_a8: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_cmt_table_length (ma1017 * chip, SANE_Byte table_length) { SANE_Status status; SANE_Byte data, reg_no; DBG (7, "usb_low_set_cmt_table_length: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_cmt_table_length: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_cmt_table_length: stop rowing first\n"); return SANE_STATUS_INVAL; } if (table_length > 32) { DBG (3, "usb_low_set_cmt_table_length: length %d exceeds 32\n", (int) table_length); return SANE_STATUS_INVAL; } if (table_length == 0) { DBG (3, "usb_low_set_cmt_table_length: length is 0\n"); return SANE_STATUS_INVAL; } chip->cmt_table_length = table_length - 1; chip->cmt_table_length_word = (SANE_Word) table_length; data = chip->cmt_table_length | chip->ccd_width_msb | chip->dummy_msb; reg_no = 8; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_cmt_table_length: exit\n"); return SANE_STATUS_GOOD; } /* A9 */ SANE_Status usb_low_get_a9 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a9: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a9: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a9: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 9, &pattern)); chip->cmt_second_pos = pattern & 0x1f; if (value) *value = pattern; DBG (7, "usb_low_get_a9: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_cmt_second_position (ma1017 * chip, SANE_Byte position) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_cmt_second_position: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_cmt_second_position: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_cmt_second_position: stop rowing first\n"); return SANE_STATUS_INVAL; } if (position > 31) { DBG (3, "usb_low_set_cmt_second_position: length: %d exceeds 31\n", (int) position); return SANE_STATUS_INVAL; } chip->cmt_second_pos = position; chip->cmt_second_pos_word = (SANE_Word) (position); data = chip->cmt_second_pos; reg_no = 9; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_cmt_second_position: exit\n"); return SANE_STATUS_GOOD; } /* A10 + A8ID5 */ SANE_Status usb_low_get_a10 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a10: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a10: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a10: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 10, &pattern)); chip->ccd_width = ((SANE_Word) (pattern)) * 32 + ((chip->ccd_width_msb == 0) ? 0 : 0x0100 * 32); if (value) *value = pattern; DBG (7, "usb_low_get_a10: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_ccd_width (ma1017 * chip, SANE_Word ccd_width) { SANE_Status status; SANE_Byte data, reg_no; DBG (7, "usb_low_set_ccd_width: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_ccd_width: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_ccd_width: stop rowing first\n"); return SANE_STATUS_INVAL; } if (ccd_width / 32 > 0x01ff) { DBG (3, "usb_low_set_ccd_width: width %d too high\n", (int) ccd_width); return SANE_STATUS_INVAL; } chip->ccd_width = ccd_width; ccd_width /= 32; if (HIBYTE (ccd_width) == 0x01) chip->ccd_width_msb = 0x20; else chip->ccd_width_msb = 0x00; data = chip->cmt_table_length | chip->ccd_width_msb | chip->dummy_msb; reg_no = 8; RIE (usb_low_write_reg (chip, reg_no, data)); data = LOBYTE (ccd_width); reg_no = 10; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_ccd_width: exit\n"); return SANE_STATUS_GOOD; } /* A11 + A8ID6 */ SANE_Status usb_low_get_a11 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a11: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a11: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a11: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 11, &pattern)); chip->dummy = ((SANE_Word) (pattern)) * 32 + ((chip->dummy_msb == 0) ? 0 : 0x0100 * 32); if (value) *value = pattern; DBG (7, "usb_low_get_a11: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_dummy (ma1017 * chip, SANE_Word dummy) { SANE_Status status; SANE_Byte data, reg_no; DBG (7, "usb_low_set_dummy: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_dummy: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_dummy: stop rowing first\n"); return SANE_STATUS_INVAL; } if (dummy / 32 > 0x01ff) { DBG (7, "usb_low_set_dummy: width %d exceeded\n", (int) dummy); return SANE_STATUS_INVAL; } chip->dummy = dummy; dummy /= 32; dummy++; if (HIBYTE (dummy) == 0x01) chip->dummy_msb = 0x40; else chip->dummy_msb = 0x00; data = chip->cmt_table_length | chip->ccd_width_msb | chip->dummy_msb; reg_no = 8; RIE (usb_low_write_reg (chip, reg_no, data)); data = LOBYTE (dummy); reg_no = 11; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_dummy: exit\n"); return SANE_STATUS_GOOD; } /* A12 + A13 */ SANE_Status usb_low_get_a12 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a12: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a12: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a12: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 12, &pattern)); chip->byte_width = (chip->byte_width & 0x3f00) + ((SANE_Word) pattern); chip->soft_resample = (chip->soft_resample == 0) ? 1 : chip->soft_resample; chip->get_row = (chip->soft_resample == 1) ? &usb_low_get_row_direct : &usb_low_get_row_resample; chip->row_size = chip->byte_width / chip->soft_resample; if (value) *value = pattern; DBG (7, "usb_low_get_a12: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_get_a13 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a13: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a13: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a13: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 13, &pattern)); chip->byte_width = (chip->byte_width & 0x00ff) + (((SANE_Word) (pattern & 0x3f)) << 8); chip->soft_resample = (chip->soft_resample == 0) ? 1 : chip->soft_resample; chip->get_row = (chip->soft_resample == 1) ? &usb_low_get_row_direct : &usb_low_get_row_resample; chip->row_size = chip->byte_width / chip->soft_resample; if (value) *value = pattern; DBG (7, "usb_low_get_a13: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_image_byte_width (ma1017 * chip, SANE_Word row_size) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_image_byte_width: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_image_byte_width: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_image_byte_width: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->row_size = row_size; chip->soft_resample = (chip->soft_resample == 0) ? 1 : chip->soft_resample; chip->get_row = (chip->soft_resample == 1) ? &usb_low_get_row_direct : &usb_low_get_row_resample; chip->byte_width = chip->row_size * chip->soft_resample; if (chip->byte_width > 0x3fff) { DBG (3, "usb_low_set_image_byte_width: width %d exceeded\n", (int) chip->byte_width); return SANE_STATUS_INVAL; } data = LOBYTE (chip->byte_width); reg_no = 12; RIE (usb_low_write_reg (chip, reg_no, data)); data = HIBYTE (chip->byte_width); reg_no = 13; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_image_byte_width: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_soft_resample (ma1017 * chip, SANE_Word soft_resample) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_soft_resample: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_soft_resample: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_soft_resample: stop rowing first\n"); return SANE_STATUS_INVAL; } if (soft_resample == 0x00) { DBG (3, "usb_low_set_soft_resample: soft_resample==0\n"); return SANE_STATUS_INVAL; } chip->soft_resample = soft_resample; chip->get_row = (chip->soft_resample == 1) ? &usb_low_get_row_direct : &usb_low_get_row_resample; chip->byte_width = chip->row_size * chip->soft_resample; if (chip->byte_width > 0x3fff) { DBG (3, "usb_low_set_soft_resample: width %d exceeded", (int) chip->byte_width); return SANE_STATUS_INVAL; } data = LOBYTE (chip->byte_width); reg_no = 12; RIE (usb_low_write_reg (chip, reg_no, data)); data = HIBYTE (chip->byte_width); reg_no = 13; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_soft_resample: exit\n"); return SANE_STATUS_GOOD; } /* A14 + A30W */ SANE_Status usb_low_set_cmt_loop_count (ma1017 * chip, SANE_Word loop_count) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_cmt_loop_count: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_cmt_loop_count: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_cmt_loop_count: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->loop_count = loop_count; data = LOBYTE (loop_count); reg_no = 14; RIE (usb_low_write_reg (chip, reg_no, data)); data = HIBYTE (loop_count); reg_no = 30; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_cmt_loop_count: exit\n"); return SANE_STATUS_GOOD; } /* A15 */ SANE_Status usb_low_get_a15 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a15: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a15: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a15: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 15, &pattern)); chip->motor_enable = pattern & 0x80; chip->motor_movement = pattern & 0x68; chip->motor_direction = pattern & 10; chip->motor_signal = pattern & 0x06; chip->motor_home = pattern & 0x01; if (value) *value = pattern; DBG (7, "usb_low_get_a15: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_enable_motor (ma1017 * chip, SANE_Bool is_enable) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_enable_motor: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_enable_motor: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_enable_motor: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->motor_enable = 0x00; if (is_enable) chip->motor_enable |= 0x80; data = chip->motor_enable | chip->motor_movement | chip->motor_direction | chip->motor_signal | chip->motor_home; reg_no = 15; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_enable_motor: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_motor_movement (ma1017 * chip, SANE_Bool is_full_step, SANE_Bool is_double_phase, SANE_Bool is_two_step) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_motor_movement: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_motor_movement: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_motor_movement: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->motor_movement = 0x00; if (is_full_step) chip->motor_movement |= 0x40; if (is_double_phase) chip->motor_movement |= 0x20; if (is_two_step) chip->motor_movement |= 0x08; data = chip->motor_enable | chip->motor_movement | chip->motor_direction | chip->motor_signal | chip->motor_home; reg_no = 15; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_motor_movement: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_motor_direction (ma1017 * chip, SANE_Bool is_backward) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_motor_direction: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_motor_direction: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_motor_direction: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->motor_direction = 0x00; if (is_backward) chip->motor_direction |= 0x10; data = chip->motor_enable | chip->motor_movement | chip->motor_direction | chip->motor_signal | chip->motor_home; reg_no = 15; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_motor_direction: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_motor_signal (ma1017 * chip, SANE_Byte signal) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_motor_signal: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_motor_signal: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_motor_signal: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->motor_signal = signal & 0x06; data = chip->motor_enable | chip->motor_movement | chip->motor_direction | chip->motor_signal | chip->motor_home; reg_no = 15; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_motor_signal: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_move_motor_home (ma1017 * chip, SANE_Bool is_home, SANE_Bool is_backward) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_move_motor_home: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_move_motor_home: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_move_motor_home: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->motor_enable = 0x00; chip->motor_direction = 0x00; chip->motor_home = 0x00; if (is_backward) chip->motor_direction |= 0x10; if (is_home) { chip->motor_enable |= 0x80; chip->motor_home |= 0x01; } data = chip->motor_enable | chip->motor_movement | chip->motor_direction | chip->motor_signal | chip->motor_home; reg_no = 15; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_move_motor_home: exit\n"); return SANE_STATUS_GOOD; } /* A16 */ SANE_Status usb_low_get_a16 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a16: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a16: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a16: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 16, &pattern)); chip->pixel_depth = pattern & 0xe0; chip->image_invert = pattern & 0x10; chip->optical_600 = pattern & 0x08; chip->sample_way = pattern & 0x07; if (value) *value = pattern; DBG (7, "usb_low_get_a16: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_image_dpi (ma1017 * chip, SANE_Bool is_optical600, Sampleway sampleway) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_image_dpi: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_image_dpi: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_image_dpi: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->optical_600 = 0x00; chip->sample_way = 0x00; if (is_optical600) chip->optical_600 |= 0x08; switch (sampleway) { case SW_P1P6: chip->sample_way = 0x01; break; case SW_P2P6: chip->sample_way = 0x02; break; case SW_P3P6: chip->sample_way = 0x03; break; case SW_P4P6: chip->sample_way = 0x04; break; case SW_P5P6: chip->sample_way = 0x05; break; case SW_P6P6: chip->sample_way = 0x06; break; default: DBG (3, "usb_low_set_image_dpi: swsample_way error\n"); return SANE_STATUS_INVAL; break; } data = chip->pixel_depth | chip->image_invert | chip->optical_600 | chip->sample_way; reg_no = 16; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_image_dpi: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_pixel_depth (ma1017 * chip, Pixeldepth pixeldepth) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_pixel_depth: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_pixel_depth: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_pixel_depth: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->pixel_depth = 0x00; switch (pixeldepth) { case PD_1BIT: chip->pixel_depth = 0x80; break; case PD_4BIT: chip->pixel_depth = 0xc0; break; case PD_8BIT: chip->pixel_depth = 0x00; break; case PD_12BIT: chip->pixel_depth = 0x20; break; default: DBG (3, "usb_low_set_pixel_depth: pdPixelDepth error\n"); return SANE_STATUS_INVAL; } data = chip->pixel_depth | chip->image_invert | chip->optical_600 | chip->sample_way; reg_no = 16; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_SetPixelDeepth: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_invert_image (ma1017 * chip, SANE_Bool is_invert) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_invert_image: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_invert_image: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_invert_image: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->image_invert = 0x00; if (is_invert) chip->image_invert |= 0x10; data = chip->pixel_depth | chip->image_invert | chip->optical_600 | chip->sample_way; reg_no = 16; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_invert_image: exit\n"); return SANE_STATUS_GOOD; } /* A17 + A18 + A19 */ SANE_Status usb_low_get_a17 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a17: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a17: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a17: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 17, &pattern)); chip->red_ref = pattern; if (value) *value = pattern; DBG (7, "usb_low_get_a17: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_get_a18 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a18: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a18: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a18: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 18, &pattern)); chip->green_ref = pattern; if (value) *value = pattern; DBG (7, "usb_low_get_a18: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_get_a19 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a19: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a19: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a19:stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 19, &pattern)); chip->blue_ref = pattern; if (value) *value = pattern; DBG (7, "usb_low_get_a19: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_red_ref (ma1017 * chip, SANE_Byte red_ref) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_red_ref: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_red_ref: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_red_ref: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->red_ref = red_ref; data = red_ref; reg_no = 17; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_red_ref: stop\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_green_ref (ma1017 * chip, SANE_Byte green_ref) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_green_ref: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_green_ref: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_green_ref: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->green_ref = green_ref; data = green_ref; reg_no = 18; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_green_ref: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_blue_ref (ma1017 * chip, SANE_Byte blue_ref) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_blue_ref: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_blue_ref: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_blue_ref: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->blue_ref = blue_ref; data = blue_ref; reg_no = 19; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_blue_ref: stop\n"); return SANE_STATUS_GOOD; } /* A20 + A21 + A22 */ SANE_Status usb_low_get_a20 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a20: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a20: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a20: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 20, &pattern)); chip->red_pd = pattern; if (value) *value = pattern; DBG (7, "usb_low_get_a20: stop\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_get_a21 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a21: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a21: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a21: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 21, &pattern)); chip->green_pd = pattern; if (value) *value = pattern; DBG (7, "usb_low_get_a21: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_get_a22 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a22: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a22: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a22: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 22, &pattern)); chip->blue_pd = pattern; if (value) *value = pattern; DBG (7, "usb_low_get_a22: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_red_pd (ma1017 * chip, SANE_Byte red_pd) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_red_pd: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_red_pd: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_red_pd: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->red_pd = red_pd; data = chip->red_pd; reg_no = 20; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_red_pd: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_green_pd (ma1017 * chip, SANE_Byte green_pd) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_green_pd: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_green_pd: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_green_pd: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->green_pd = green_pd; data = chip->green_pd; reg_no = 21; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_green_pd: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_blue_pd (ma1017 * chip, SANE_Byte blue_pd) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_blue_pd: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_blue_pd: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_blue_pd: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->blue_pd = blue_pd; data = chip->blue_pd; reg_no = 22; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_blue_pd: exit\n"); return SANE_STATUS_GOOD; } /* A23 */ SANE_Status usb_low_get_a23 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a23: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a23: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a23: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 23, &pattern)); chip->a23 = pattern; if (value) *value = pattern; DBG (7, "usb_low_get_a23: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_turn_peripheral_power (ma1017 * chip, SANE_Bool is_on) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_turn_peripheral_power: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_turn_peripheral_power: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_turn_peripheral_power: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->a23 &= 0x7f; if (is_on) chip->a23 |= 0x80; data = chip->a23; reg_no = 23; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_turn_peripheral_power: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_turn_lamp_power (ma1017 * chip, SANE_Bool is_on) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_turn_lamp_power: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_turn_lamp_power: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_turn_lamp_power: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->a23 &= 0xbf; if (is_on) chip->a23 |= 0x40; data = chip->a23; reg_no = 23; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_turn_lamp_power: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_io_3 (ma1017 * chip, SANE_Bool is_high) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_io_3: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_io_3: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_io_3: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->a23 &= 0xf7; if (is_high) chip->a23 |= 0x08; data = chip->a23; reg_no = 23; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_io_3: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_led_light_all (ma1017 * chip, SANE_Bool is_light_all) { SANE_Byte data, reg_no; SANE_Status status; DBG (7, "usb_low_set_led_light_all: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_led_light_all: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_led_light_all: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->a23 &= 0xfe; if (is_light_all) chip->a23 |= 0x01; data = chip->a23; reg_no = 23; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_led_light_all: exit\n"); return SANE_STATUS_GOOD; } /* A24 */ SANE_Status usb_low_get_a24 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a24: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a24: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a24: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 24, &pattern)); chip->fy1_delay = pattern & 0x01; chip->special_ad = pattern & 0x02; if (value) *value = pattern; DBG (7, "usb_low_get_a24: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_ad_timing (ma1017 * chip, SANE_Byte data) { SANE_Byte reg_no; SANE_Status status; DBG (7, "usb_low_set_ad_timing: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_ad_timing: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_ad_timing: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->fy1_delay = data & 0x01; chip->special_ad = data & 0x02; data = chip->special_ad | chip->fy1_delay; reg_no = 24; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_ad_timing: exit\n"); return SANE_STATUS_GOOD; } /* A25 + A26 */ SANE_Status usb_low_set_serial_byte1 (ma1017 * chip, SANE_Byte data) { SANE_Byte reg_no; SANE_Status status; DBG (7, "usb_low_set_serial_byte1: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_serial_byte1: not opened\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_serial_byte1: stop rowing first\n"); return SANE_STATUS_INVAL; } reg_no = 25; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_serial_byte1: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_serial_byte2 (ma1017 * chip, SANE_Byte data) { SANE_Byte reg_no; SANE_Status status; DBG (7, "usb_low_set_serial_byte2: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_serial_byte2: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_serial_byte2: stop rowing first\n"); return SANE_STATUS_INVAL; } reg_no = 26; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_serial_byte2: exit\n"); return SANE_STATUS_GOOD; } /* A27 */ SANE_Status usb_low_get_a27 (ma1017 * chip, SANE_Byte * value) { SANE_Byte pattern; SANE_Status status; DBG (7, "usb_low_get_a27: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_a27: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_a27: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 27, &pattern)); chip->sclk = pattern & 0x80; chip->sen = pattern & 0x40; chip->serial_length = pattern & 0x1f; if (value) *value = pattern; DBG (7, "usb_low_get_a27: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_set_serial_format (ma1017 * chip, SANE_Byte data) { SANE_Byte reg_no; SANE_Status status; DBG (7, "usb_low_set_serial_format: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_set_serial_format: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_set_serial_format: stop rowing first\n"); return SANE_STATUS_INVAL; } chip->sclk = data & 0x80; chip->sen = data & 0x40; chip->serial_length = data & 0x1f; reg_no = 27; RIE (usb_low_write_reg (chip, reg_no, data)); DBG (7, "usb_low_set_serial_format: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_get_home_sensor (ma1017 * chip) { SANE_Byte data; SANE_Status status; DBG (7, "usb_low_get_home_sensor: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_get_home_sensor: not opened yet\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_get_home_sensor: stop rowing first\n"); return SANE_STATUS_INVAL; } RIE (usb_low_read_reg (chip, 31, &data)); DBG (7, "usb_low_get_home_sensor: exit\n"); if ((data & 0x80) != 0) return SANE_STATUS_GOOD; else return SANE_STATUS_IO_ERROR; } /* Special Mode */ SANE_Status usb_low_start_rowing (ma1017 * chip) { SANE_Word line_of_first = 0; SANE_Word line_of_second = 0; SANE_Int i; SANE_Status status; DBG (7, "usb_low_start_rowing: start\n"); if (chip->loop_count == 0) { DBG (3, "usb_low_start_rowing loop_count hasn't been set yet\n"); return SANE_STATUS_INVAL; } if (chip->cmt_table_length_word == 0) { DBG (3, "usb_low_start_rowing: cmt_table_length_word hasn't been set " "yet\n"); return SANE_STATUS_INVAL; } if (chip->cmt_table_length_word <= chip->cmt_second_pos_word) { DBG (3, "usb_low_start_rowing: cmt_second_pos_word cannot be larger " "than cmt_table_length_word\n"); return SANE_STATUS_INVAL; } for (i = 0; i < (int) chip->cmt_second_pos_word; i++) { if (chip->is_transfer_table[i]) line_of_first++; } for (; i < (int) chip->cmt_table_length_word; i++) { if (chip->is_transfer_table[i]) { line_of_first++; line_of_second++; } } chip->total_lines = ((SANE_Word) (chip->loop_count - 1)) * line_of_second + line_of_first; chip->lines_left = chip->total_lines; RIE (usb_low_start_cmt_table (chip)); DBG (7, "usb_low_start_rowing: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_stop_rowing (ma1017 * chip) { SANE_Status status; DBG (7, "usb_low_stop_rowing: start\n"); RIE (usb_low_stop_cmt_table (chip)); DBG (7, "usb_low_stop_rowing: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_wait_rowing_stop (ma1017 * chip) { SANE_Status status; DBG (7, "usb_low_wait_rowing_stop: start\n"); if (chip->total_lines != 0) { DBG (3, "usb_low_wait_rowing_stop: total_lines must be 0\n"); return SANE_STATUS_INVAL; } RIE (usb_low_wait_rowing (chip)); chip->is_rowing = SANE_FALSE; DBG (7, "usb_low_wait_rowing_stop: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_read_all_registers (ma1017 * chip) { SANE_Status status; DBG (7, "usb_low_read_all_registers: start\n"); RIE (usb_low_get_a2 (chip, 0)); RIE (usb_low_get_a4 (chip, 0)); RIE (usb_low_get_a6 (chip, 0)); RIE (usb_low_get_a7 (chip, 0)); RIE (usb_low_get_a8 (chip, 0)); RIE (usb_low_get_a9 (chip, 0)); RIE (usb_low_get_a10 (chip, 0)); RIE (usb_low_get_a11 (chip, 0)); RIE (usb_low_get_a12 (chip, 0)); RIE (usb_low_get_a13 (chip, 0)); RIE (usb_low_get_a15 (chip, 0)); RIE (usb_low_get_a16 (chip, 0)); RIE (usb_low_get_a17 (chip, 0)); RIE (usb_low_get_a18 (chip, 0)); RIE (usb_low_get_a19 (chip, 0)); RIE (usb_low_get_a20 (chip, 0)); RIE (usb_low_get_a21 (chip, 0)); RIE (usb_low_get_a22 (chip, 0)); RIE (usb_low_get_a23 (chip, 0)); RIE (usb_low_get_a24 (chip, 0)); RIE (usb_low_get_a27 (chip, 0)); return SANE_STATUS_GOOD; DBG (7, "usb_low_read_all_registers: exit\n"); } SANE_Status usb_low_get_row (ma1017 * chip, SANE_Byte * data, SANE_Word * lines_left) { SANE_Status status; DBG (7, "usb_low_get_row: start\n"); RIE ((*chip->get_row) (chip, data, lines_left)); DBG (7, "usb_low_get_row: exit\n"); return SANE_STATUS_GOOD;; } SANE_Status usb_low_get_row_direct (ma1017 * chip, SANE_Byte * data, SANE_Word * lines_left) { SANE_Status status; DBG (7, "usb_low_get_row_direct: start\n"); if (chip->lines_left == 0) { DBG (3, "usb_low_get_row_direct: lines_left == 0\n"); return SANE_STATUS_INVAL; } if (chip->lines_left <= 1) { RIE (usb_low_read_rows (chip, data, chip->byte_width)); RIE (usb_low_wait_rowing (chip)); chip->lines_left = 0x00; chip->is_rowing = SANE_FALSE; *lines_left = 0; } else { RIE (usb_low_read_rows (chip, data, chip->byte_width)); chip->lines_left--; *lines_left = chip->lines_left; } DBG (7, "usb_low_get_row_direct: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_get_row_resample (ma1017 * chip, SANE_Byte * data, SANE_Word * lines_left) { static SANE_Byte resample_buffer[8 * 1024]; SANE_Word *pixel_temp; SANE_Word i; SANE_Word j; SANE_Word k; SANE_Status status; DBG (7, "usb_low_get_row_resample: start\n"); if (chip->lines_left == 0) { DBG (3, "usb_low_get_row_resample: lines_left == 0\n"); return SANE_STATUS_INVAL; } if (chip->lines_left <= 1) { RIE (usb_low_read_rows (chip, resample_buffer, chip->byte_width)); if ((chip->sensor == ST_CANON600) && (chip->pixel_depth == 0x20)) { pixel_temp = (SANE_Word *) malloc (6 * 1024 * sizeof (SANE_Word)); if (!pixel_temp) return SANE_STATUS_NO_MEM; j = 0; for (i = 0; i < chip->byte_width; i += 3) { pixel_temp[j] = (SANE_Word) resample_buffer[i]; pixel_temp[j] |= ((SANE_Word) (resample_buffer[i + 1] & 0xf0)) << 4; j++; pixel_temp[j] = ((SANE_Word) (resample_buffer[i + 1] & 0x0f)) << 8; pixel_temp[j] |= (SANE_Word) resample_buffer[i + 2]; j++; } k = 0; for (i = 0; i < j; i += chip->soft_resample * 2) { data[k] = (SANE_Byte) (pixel_temp[i] & 0x00ff); k++; data[k] = (SANE_Byte) ((pixel_temp[i] & 0x0f00) >> 4); data[k] |= (SANE_Byte) ((pixel_temp[i + 2] & 0x0f00) >> 8); k++; data[k] = (SANE_Byte) (pixel_temp[i + 2] & 0x00ff); k++; } free (pixel_temp); } else /* fixme ? */ { for (i = 0; i < chip->byte_width; i += chip->soft_resample) *(data++) = resample_buffer[i]; } RIE (usb_low_wait_rowing (chip)); chip->lines_left = 0x00; chip->is_rowing = SANE_FALSE; *lines_left = 0; } else { RIE (usb_low_read_rows (chip, resample_buffer, chip->byte_width)); if ((chip->sensor == ST_CANON600) && (chip->pixel_depth == 0x20)) { pixel_temp = (SANE_Word *) malloc (6 * 1024 * sizeof (SANE_Word)); if (!pixel_temp) return SANE_STATUS_NO_MEM; j = 0; for (i = 0; i < chip->byte_width; i += 3) { pixel_temp[j] = (SANE_Word) resample_buffer[i]; pixel_temp[j] |= ((SANE_Word) (resample_buffer[i + 1] & 0xf0)) << 4; j++; pixel_temp[j] = ((SANE_Word) (resample_buffer[i + 1] & 0x0f)) << 8; pixel_temp[j] |= (SANE_Word) resample_buffer[i + 2]; j++; } k = 0; for (i = 0; i < j; i += chip->soft_resample * 2) { data[k] = (SANE_Byte) (pixel_temp[i] & 0x00ff); k++; data[k] = (SANE_Byte) ((pixel_temp[i] & 0x0f00) >> 4); data[k] |= (SANE_Byte) ((pixel_temp[i + 2] & 0x0f00) >> 8); k++; data[k] = (SANE_Byte) (pixel_temp[i + 2] & 0x00ff); k++; } free (pixel_temp); } else /* fixme? */ { for (i = 0; i < chip->byte_width; i += chip->soft_resample) *(data++) = resample_buffer[i]; } chip->lines_left--; *lines_left = chip->lines_left; } DBG (7, "usb_low_get_row_resample: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_wait_rowing (ma1017 * chip) { SANE_Byte read_byte; size_t n; SANE_Status status; DBG (7, "usb_low_wait_rowing: start\n"); if (!chip->is_opened) { DBG (3, "usb_low_wait_rowing: open first\n"); return SANE_STATUS_INVAL; } if (!chip->is_rowing) { DBG (3, "usb_low_wait_rowing: not rowing\n"); return SANE_STATUS_INVAL; } n = 1; status = sanei_usb_read_bulk (chip->fd, (SANE_Byte *) & read_byte, &n); if (status != SANE_STATUS_GOOD || n != 1) { DBG (3, "usb_low_wait_rowing: couldn't read: %s\n", sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } chip->total_read_urbs++; chip->is_rowing = SANE_FALSE; DBG (7, "usb_low_wait_rowing: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_read_rows (ma1017 * chip, SANE_Byte * data, SANE_Word byte_count) { size_t n, bytes_total; SANE_Status status; DBG (7, "usb_low_read_rows: start\n"); if (!(chip->is_opened)) { DBG (3, "usb_low_read_rows: is_opened==SANE_FALSE\n"); return SANE_STATUS_INVAL; } if (!(chip->is_rowing)) { DBG (3, "usb_low_read_rows: is_rowing==SANE_FALSE\n"); return SANE_STATUS_INVAL; } n = MIN (byte_count, chip->max_block_size); bytes_total = 0; while ((SANE_Word) bytes_total < byte_count) { status = sanei_usb_read_bulk (chip->fd, (SANE_Byte *) (data + bytes_total), &n); if (status != SANE_STATUS_GOOD) { DBG (7, "usb_low_read_rows: problems during read: %s -- exiting\n", sane_strstatus (status)); return status; } /* Count the number of URBs. This is a bit tricky, as we are reading bigger chunks here but the scanner can only handle 64 bytes at once. */ chip->total_read_urbs += ((n + 63) / 64); bytes_total += n; if ((SANE_Word) bytes_total != byte_count) { DBG (7, "usb_low_read_rows: wanted %d, got %d " "bytes (%d in total) -- retrying\n", byte_count, (SANE_Word) n, (SANE_Word) bytes_total); } n = MIN ((byte_count - (SANE_Word) bytes_total), chip->max_block_size); } DBG (7, "usb_low_read_rows: exit, read %d bytes\n", (SANE_Word) bytes_total); return SANE_STATUS_GOOD; } SANE_Status usb_low_write_reg (ma1017 * chip, SANE_Byte reg_no, SANE_Byte data) { size_t n; SANE_Status status; SANE_Byte data_field[2]; data_field[0] = data; data_field[1] = reg_no; if (!chip->is_opened) { DBG (3, "usb_low_write_reg: open first\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_write_reg: rowing, stop first\n"); return SANE_STATUS_INVAL; } if (reg_no > 0x20) { DBG (3, "usb_low_write_reg: reg_no out of range\n"); return SANE_STATUS_INVAL; } n = 2; status = sanei_usb_write_bulk (chip->fd, data_field, &n); if (status != SANE_STATUS_GOOD || n != 2) { DBG (3, "usb_low_write_reg: couldn't write, tried to write %d, " "wrote %lu: %s\n", 2, (unsigned long int) n, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } chip->total_write_urbs++; DBG (7, "usb_low_write_reg: reg: 0x%02x, value: 0x%02x\n", reg_no, data); return SANE_STATUS_GOOD; } SANE_Status usb_low_read_reg (ma1017 * chip, SANE_Byte reg_no, SANE_Byte * data) { SANE_Byte data_field[2]; SANE_Byte read_byte; size_t n; SANE_Status status; data_field[0] = 0x00; data_field[1] = reg_no | 0x20; if (!chip->is_opened) { DBG (3, "usb_low_read_reg: open first\n"); return SANE_STATUS_INVAL; } if (chip->is_rowing) { DBG (3, "usb_low_read_reg: rowing, stop first\n"); return SANE_STATUS_INVAL; } if (reg_no > 0x20) { DBG (3, "usb_low_read_reg: reg_no out of range\n"); return SANE_STATUS_INVAL; } n = 2; DBG (5, "usb_low_read_reg: trying to write %lu bytes\n", (unsigned long int) n); status = sanei_usb_write_bulk (chip->fd, data_field, &n); if (status != SANE_STATUS_GOOD || n != 2) { DBG (3, "usb_low_read_reg: couldn't write, tried to write %d, " "wrote %lu: %s\n", 2, (unsigned long int) n, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } chip->total_write_urbs++; n = 1; DBG (5, "usb_low_read_reg: trying to read %lu bytes\n", (unsigned long int) n); status = sanei_usb_read_bulk (chip->fd, (SANE_Byte *) & read_byte, &n); if (status != SANE_STATUS_GOOD || n != 1) { DBG (3, "usb_low_read_reg: couldn't read, tried to read %lu, " "read %lu: %s\n", (unsigned long int) 1, (unsigned long int) n, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } chip->total_read_urbs++; if (data) *data = read_byte; DBG (7, "usb_low_read_reg: Reg: 0x%02x, Value: 0x%02x\n", reg_no, read_byte); return SANE_STATUS_GOOD; } SANE_Status usb_low_identify_scanner (SANE_Int fd, Mustek_Type * scanner_type) { SANE_Status status; SANE_Word devvendor, devproduct; Mustek_Type devtype; DBG (7, "usb_low_identify_scanner: start\n"); status = sanei_usb_get_vendor_product (fd, &devvendor, &devproduct); devtype = MT_UNKNOWN; if (status == SANE_STATUS_GOOD) { if (devvendor == 0x055f) { switch (devproduct) { case 0x0001: devtype = MT_1200CU; break; case 0x0002: devtype = MT_600CU; break; case 0x0003: devtype = MT_1200USB; break; case 0x0006: devtype = MT_1200UB; break; case 0x0008: devtype = MT_1200CU_PLUS; break; case 0x0873: devtype = MT_600USB; break; default: if (scanner_type) *scanner_type = devtype; DBG (3, "usb_low_identify_scanner: unknown product id: " "0x%04x\n", devproduct); return SANE_STATUS_INVAL; break; } } else { if (scanner_type) *scanner_type = devtype; DBG (3, "usb_low_identify_scanner: unknown vendor id: 0x%04d\n", devvendor); return SANE_STATUS_INVAL; } } if (scanner_type) *scanner_type = devtype; DBG (7, "usb_low_identify_scanner: exit\n"); return SANE_STATUS_GOOD; } SANE_Status usb_low_open (ma1017 * chip, SANE_String_Const devname) { SANE_Status status; Mustek_Type scanner_type; DBG (7, "usb_low_open: start: chip = %p\n", (void *) chip); if (chip->is_rowing) { DBG (3, "usb_low_open: already rowing\n"); return SANE_STATUS_INVAL; } if (chip->is_opened) { DBG (3, "usb_low_open: already opened\n"); return SANE_STATUS_INVAL; } status = sanei_usb_open ((SANE_String_Const) devname, &chip->fd); if (status == SANE_STATUS_GOOD) { DBG (7, "usb_low_open: device %s successfully opened\n", devname); chip->is_opened = SANE_TRUE; /* Try to get vendor and device ids */ DBG (7, "usb_low_open: trying to identify device `%s'\n", devname); status = usb_low_identify_scanner (chip->fd, &scanner_type); if (status != SANE_STATUS_GOOD) { DBG (3, "usb_low_open: device `%s' doesn't look like a supported " "scanner\n", devname); sanei_usb_close (chip->fd); return status; } else { if (scanner_type == MT_UNKNOWN) { DBG (3, "usb_low_open: device `%s' can't be identified\n", devname); } else if (scanner_type != chip->scanner_type) { DBG (3, "usb_low_open: device `%s' is supported but" "it's not the same as at the start\n", devname); return SANE_STATUS_INVAL; } } } else { DBG (1, "usb_low_open: device %s couldn't be opened: %s\n", devname, sane_strstatus (status)); return status; } chip->is_opened = SANE_TRUE; RIE (usb_low_read_all_registers (chip)); DBG (7, "usb_low_open: exit, type is %d\n", scanner_type); return SANE_STATUS_GOOD; } SANE_Status usb_low_close (ma1017 * chip) { DBG (7, "usb_low_close: start, chip=%p\n", (void *) chip); if (!chip->is_opened) { DBG (3, "usb_low_close: already close or never opened\n"); return SANE_STATUS_INVAL; } if (chip->fd >= 0) { SANE_Byte dummy; if (chip->is_rowing) usb_low_stop_rowing (chip); /* Now make sure that both the number of written and read URBs is even. Use some dummy writes/reads. That's to avoid a nasty bug in the MA 1017 chipset that causes timeouts when the number of URBs is odd (toggle bug). */ if ((chip->total_read_urbs % 2) == 1) usb_low_get_a4 (chip, &dummy); if ((chip->total_write_urbs % 2) == 1) usb_low_set_fix_pattern (chip, SANE_FALSE); sanei_usb_close (chip->fd); chip->fd = -1; } chip->is_opened = SANE_FALSE; chip->is_rowing = SANE_FALSE; DBG (7, "usb_low_close: exit\n"); return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/plustek-pp.h0000666000000000000000000005151113615534521015050 00000000000000/** @file plustek-pp.h * @brief Definitions for the backend. * * Based on Kazuhiro Sasayama previous * Work on plustek.[ch] file from the SANE package.
* * original code taken from sane-0.71
* Copyright (C) 1997 Hypercore Software Design, Ltd.
* Copyright (C) 2001-2013 Gerhard Jaeger * * History: * - 0.01 - initial version * - 0.43 - bumped up version to reflect the former module code version * - removed Version from ScannerCaps * - added _E_FAULT * - 0.44 - fix UL issues, as Long types default to int32_t now * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #ifndef __PLUSTEKPP_H__ #define __PLUSTEKPP_H__ /*............................................................................. * the structures for driver communication */ typedef struct { unsigned short x; unsigned short y; } XY, *pXY; typedef struct { unsigned short x; unsigned short y; unsigned short cx; unsigned short cy; } CropRect, *pCropRect; typedef struct image { unsigned long dwFlag; CropRect crArea; XY xyDpi; unsigned short wDataType; } ImgDef, *pImgDef; typedef struct { unsigned long dwPixelsPerLine; unsigned long dwBytesPerLine; unsigned long dwLinesPerArea; struct image ImgDef; } CropInfo, *pCropInfo; /** definition of gamma maps */ typedef struct { int len; /**< gamma table len */ int depth; /**< entry bit depth */ int map_id; /**< what map */ void *map; /**< pointer for map */ } MapDef, *pMapDef; /** for offset stuff */ typedef struct { int x; int y; } OffsDef, *pOffsDef; /** useful for description tables */ typedef struct { int id; char *desc; } TabDef, *pTabDef; /** for defining the scanmodes */ typedef const struct mode_param { int color; int depth; int scanmode; } ModeParam, *pModeParam; /** */ #define SFLAG_ADF 0x00000010 /* Automatic document feeder */ #define SFLAG_MFP 0x00000020 /* MF-Keypad support */ #define SFLAG_SheetFed 0x00000040 /* Sheetfed support */ #define SFLAG_TPA 0x00000080 /* has transparency adapter */ #define SFLAG_CUSTOM_GAMMA 0x00000200 /* driver supports custom gamma */ /** */ #define SCANDEF_Inverse 0x00000001 #define SCANDEF_UnlimitLength 0x00000002 #define SCANDEF_StopWhenPaperOut 0x00000004 #define SCANDEF_BoundaryDWORD 0x00000008 #define SCANDEF_ColorBGROrder 0x00000010 #define SCANDEF_BmpStyle 0x00000020 #define SCANDEF_BoundaryWORD 0x00000040 #define SCANDEF_NoMap 0x00000080 /* specified this flag will */ /* cause system ignores the */ /* siBrightness & siContrast */ #define SCANDEF_Transparency 0x00000100 /* Scanning from transparency*/ #define SCANDEF_Negative 0x00000200 /* Scanning from negative */ #define SCANDEF_QualityScan 0x00000400 /* Scanning in quality mode */ #define SCANDEF_BuildBwMap 0x00000800 /* Set default map */ #define SCANDEF_ContinuousScan 0x00001000 #define SCANDEF_DontBackModule 0x00002000 /* module will not back to */ /* home after image scanned */ #define SCANDEF_RightAlign 0x00008000 /* 12-bit */ #define SCANDEF_TPA (SCANDEF_Transparency | SCANDEF_Negative) #define SCANDEF_Adf 0x00020000 /* Scan from ADF tray */ /* these values will be combined with ScannerInfo.dwFlag */ #define _SCANNER_SCANNING 0x8000000 #define _SCANNER_PAPEROUT 0x4000000 /* for GetLensInformation */ #if 0 #define SOURCE_Reflection 0 #define SOURCE_Transparency 1 #define SOURCE_Negative 2 #define SOURCE_ADF 3 #endif /****************************************************************************** * Section 6 - additional definitions */ /* scan modes */ #define COLOR_BW 0 #define COLOR_HALFTONE 1 #define COLOR_256GRAY 2 #define COLOR_TRUE24 3 #define COLOR_TRUE32 4 #define COLOR_TRUE48 4 /* not sure if this should be the same as 32 */ #define COLOR_TRUE36 5 /* We don't support halftone mode now --> Plustek statement for USB */ #define COLOR_GRAY16 6 #define _MEASURE_BASE 300UL /** transparency/negative mode set ranges */ #define _TPAPageWidth 500U /* org. was 450 = 38.1 mm */ #define _TPAPageHeight 510U /* org. was 460 = 38.9 mm */ #define _TPAModeSupportMin COLOR_TRUE24 #define _TPAModeSupportMax COLOR_TRUE48 #define _TPAModeSupportDef COLOR_TRUE24 #define _TPAMinDpi 150 #define _NegativePageWidth 460U /* 38.9 mm */ #define _NegativePageHeight 350U /* 29.6 mm */ #define _DEF_DPI 50 /* * additional shared stuff between user-world and kernel mode */ #define _VAR_NOT_USED(x) ((x)=(x)) /* * for Gamma tables */ #define _MAP_RED 0 #define _MAP_GREEN 1 #define _MAP_BLUE 2 #define _MAP_MASTER 3 /* * generic error codes... */ #define _OK 0 #define _FIRST_ERR -9000 #define _E_INIT (_FIRST_ERR-1) /* already initialized */ #define _E_NOT_INIT (_FIRST_ERR-2) /* not initialized */ #define _E_NULLPTR (_FIRST_ERR-3) /* internal NULL-PTR detected */ #define _E_ALLOC (_FIRST_ERR-4) /* error allocating memory */ #define _E_TIMEOUT (_FIRST_ERR-5) /* signals a timeout condition */ #define _E_INVALID (_FIRST_ERR-6) /* invalid parameter detected */ #define _E_INTERNAL (_FIRST_ERR-7) /* internal error */ #define _E_BUSY (_FIRST_ERR-8) /* device is already in use */ #define _E_ABORT (_FIRST_ERR-9) /* operation aborted */ #define _E_LOCK (_FIRST_ERR-10) /* can't lock resource */ #define _E_NOSUPP (_FIRST_ERR-11) /* feature or device not supported */ #define _E_NORESOURCE (_FIRST_ERR-12) /* out of memo, resource busy... */ #define _E_VERSION (_FIRST_ERR-19) /* version conflict */ #define _E_NO_DEV (_FIRST_ERR-20) /* device does not exist */ #define _E_NO_CONN (_FIRST_ERR-21) /* nothing connected */ #define _E_PORTSEARCH (_FIRST_ERR-22) /* parport_enumerate failed */ #define _E_NO_PORT (_FIRST_ERR-23) /* requested port does not exist */ #define _E_REGISTER (_FIRST_ERR-24) /* cannot register this device */ #define _E_SEQUENCE (_FIRST_ERR-30) /* caller sequence does not match */ #define _E_NO_ASIC (_FIRST_ERR-31) /* can't detect ASIC */ #ifdef __KERNEL__ # define _E_FAULT (-EFAULT) #else # define _E_FAULT (_E_INTERNAL) /* should never happen in userspace */ #endif #define _E_LAMP_NOT_IN_POS (_FIRST_ERR-40) #define _E_LAMP_NOT_STABLE (_FIRST_ERR-41) #define _E_NODATA (_FIRST_ERR-42) #define _E_BUFFER_TOO_SMALL (_FIRST_ERR-43) #define _E_DATAREAD (_FIRST_ERR-44) /************************ some definitions ***********************************/ /* NOTE: needs to be kept in sync with table below */ #define MODELSTR static char *ModelStr[] = { \ "unknown", \ "Primax 4800", \ "Primax 4800 Direct", \ "Primax 4800 Direct 30Bit", \ "Primax 9600 Direct 30Bit", \ "4800P", \ "4830P", \ "600P/6000P", \ "4831P", \ "9630P", \ "9630PL", \ "9636P", \ "A3I", \ "12000P/96000P", \ "9636P+/Turbo", \ "9636T/12000T", \ "P8", \ "P12", \ "PT12", \ "Genius Colorpage Vivid III V2", \ "USB-Device" \ } /* the models */ #define MODEL_OP_UNKNOWN 0 /* unknown */ #define MODEL_PMX_4800 1 /* Primax Colorado 4800 like OP 4800 */ #define MODEL_PMX_4800D 2 /* Primax Compact 4800 Direct, OP 600 R->G, G->R */ #define MODEL_PMX_4800D3 3 /* Primax Compact 4800 Direct 30 */ #define MODEL_PMX_9600D3 4 /* Primax Compact 9600 Direct 30 */ #define MODEL_OP_4800P 5 /* 32k, 96001 ASIC, 24 bit, 300x600, 8.5x11.69 */ #define MODEL_OP_4830P 6 /* 32k, 96003 ASIC, 30 bit, 300x600, 8.5x11.69 */ #define MODEL_OP_600P 7 /* 32k, 96003 ASIC, 30 bit, 300x600, 8.5x11.69 */ #define MODEL_OP_4831P 8 /* 128k, 96003 ASIC, 30 bit, 300x600, 8.5x11.69 */ #define MODEL_OP_9630P 9 /* 128k, 96003 ASIC, 30 bit, 600x1200, 8.5x11.69 */ #define MODEL_OP_9630PL 10 /* 128k, 96003 ASIC, 30 bit, 600x1200, 8.5x14 */ #define MODEL_OP_9636P 11 /* 512k, 98001 ASIC, 36 bit, 600x1200, 8.5x11.69 */ #define MODEL_OP_A3I 12 /* 128k, 96003 ASIC, 30 bit, 400x800, 11.69x17 */ #define MODEL_OP_12000P 13 /* 128k, 96003 ASIC, 30 bit, 600x1200, 8.5x11.69 */ #define MODEL_OP_9636PP 14 /* 512k, 98001 ASIC, 36 bit, 600x1200, 8.5x11.69 */ #define MODEL_OP_9636T 15 /* like OP_9636PP + transparency */ #define MODEL_OP_P8 16 /* 512k, 98003 ASIC, 36 bit, 300x600, 8.5x11.69 */ #define MODEL_OP_P12 17 /* 512k, 98003 ASIC, 36 bit, 600x1200, 8.5x11.69 */ #define MODEL_OP_PT12 18 /* like OP_P12 + transparency */ #define MODEL_GEN_CPV2 19 /* Genius Colorpage Vivid III V2, ASIC 98003 */ #define MODEL_UNKNOWN 20 /* not known/supported */ #define _NO_BASE 0xFFFF /******************** from former plustek-share.h ***************************/ /* * for other OS than Linux, we might have to define the _IO macros */ #ifndef _IOC #define _IOC(dir,type,nr,size) \ (((dir) << 30) | \ ((type) << 8) | \ ((nr) << 0) | \ ((size) << 16)) #endif #ifndef _IOC_DIR #define _IOC_DIR(cmd) (((cmd) >> 30) & 0x3) #endif #ifndef _IOC_SIZE #define _IOC_SIZE(cmd) (((cmd) >> 16) & 0x3FFF) #endif #ifndef _IOC_WRITE #define _IOC_WRITE 1U #endif #ifndef _IO #define _IO(type,nr) _IOC(0U,(type),(nr),0) #endif #ifndef _IOR #define _IOR(type,nr,size) _IOC(2U,(type),(nr),((UInt)sizeof(size))) #endif #ifndef _IOW #define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),((UInt)sizeof(size))) #endif #ifndef _IOWR #define _IOWR(type,nr,size) _IOC(3U,(type),(nr),((UInt)sizeof(size))) #endif /*............................................................................. * the ioctl interface */ #define _PTDRV_OPEN_DEVICE _IOW('x', 1, unsigned short)/* open */ #define _PTDRV_GET_CAPABILITIES _IOR('x', 2, ScannerCaps) /* get caps */ #define _PTDRV_GET_LENSINFO _IOR('x', 3, LensInfo) /* get lenscaps */ #define _PTDRV_PUT_IMAGEINFO _IOW('x', 4, ImgDef) /* put image info*/ #define _PTDRV_GET_CROPINFO _IOR('x', 5, CropInfo) /* get crop */ #define _PTDRV_SET_ENV _IOWR('x',6, ScanInfo) /* set env. */ #define _PTDRV_START_SCAN _IOR('x', 7, StartScan) /* start scan */ #define _PTDRV_STOP_SCAN _IOWR('x', 8, short) /* stop scan */ #define _PTDRV_CLOSE_DEVICE _IO('x', 9) /* close */ #define _PTDRV_ACTION_BUTTON _IOR('x', 10, unsigned char)/* rd act. button*/ #define _PTDRV_ADJUST _IOR('x', 11, AdjDef) /* adjust driver */ #define _PTDRV_SETMAP _IOR('x', 12, MapDef) /* download gamma*/ /* * this version MUST match the one inside the driver to make sure, that * both sides use the same structures. This version changes each time * the ioctl interface changes */ #define _PTDRV_COMPAT_IOCTL_VERSION 0x0102 #define _PTDRV_IOCTL_VERSION 0x0104 /** for adjusting the parport stuff */ typedef struct { int lampOff; int lampOffOnEnd; int warmup; int enableTpa; OffsDef pos; /* for adjusting normal scan area */ OffsDef tpa; /* for adjusting transparency scan area */ OffsDef neg; /* for adjusting negative scan area */ /* for adjusting the default gamma settings */ double rgamma; double ggamma; double bgamma; double graygamma; } PPAdjDef, *pPPAdjDef; /** for adjusting the scanner settings */ typedef struct { int direct_io; int mov; int lampOff; int lampOffOnEnd; int warmup; OffsDef pos; /* for adjusting normal scan area */ OffsDef tpa; /* for adjusting transparency scan area */ OffsDef neg; /* for adjusting negative scan area */ /* for adjusting the default gamma settings */ double rgamma; double ggamma; double bgamma; double graygamma; } AdjDef, *pAdjDef; typedef struct { unsigned long dwFlag; /* refer to SECTION (1.2) */ unsigned long dwBytesPerLine; unsigned long dwLinesPerScan; } StartScan, *pStartScan; typedef struct { unsigned short wMin; /* minimum value */ unsigned short wDef; /* default value */ unsigned short wMax; /* software maximum value */ unsigned short wPhyMax; /* hardware maximum value (for DPI only)*/ } RANGE, *PRANGE; typedef struct { RANGE rDataType; /* available scan modes */ unsigned long dwFlag; /* refer to SECTION (1.2) */ unsigned short wIOBase; /* refer to SECTION (1.3) */ unsigned short wMaxExtentX; /* scanarea width */ unsigned short wMaxExtentY; /* scanarea height */ unsigned short AsicID; /* copy of RegAsicID */ unsigned short Model; /* model as best we can determine */ } ScannerCaps, *pScannerCaps; typedef struct { RANGE rDpiX; RANGE rDpiY; RANGE rExtentX; RANGE rExtentY; unsigned short wBeginX; /* offset from left */ unsigned short wBeginY; /* offset from top */ } LensInfo, *pLensInfo; typedef struct { unsigned char* pDither; void* pMap; ImgDef ImgDef; unsigned short wMapType; /* refer to SECTION (3.2) */ unsigned short wDither; /* refer to SECTION (3.3) */ short siBrightness; /* refer to SECTION (3.5) */ short siContrast; /* refer to SECTION (3.6) */ } ScanInfo, *pScanInfo; /* IDs the ASIC returns */ #define _ASIC_IS_96001 0x0f /* value for 96001 */ #define _ASIC_IS_96003 0x10 /* value for 96003 */ #define _ASIC_IS_98001 0x81 /* value for 98001 */ #define _ASIC_IS_98003 0x83 /* value for 98003 */ #define _Transparency48OriginOffsetX 375 #define _Transparency48OriginOffsetY 780 #define _Transparency96OriginOffsetX 0x03DB /* org. was 0x0430 */ #define _Negative96OriginOffsetX 0x03F3 /* org. was 0x0428 */ /** Scanmodes */ #define _ScanMode_Color 0 #define _ScanMode_AverageOut 1 /* CCD averaged 2 pixels value for output*/ #define _ScanMode_Mono 2 /* not color mode */ #ifndef __KERNEL__ #define PLUSTEK_CONFIG_FILE "plustek_pp.conf" #ifndef PATH_MAX # define PATH_MAX 1024 #endif /* * the default image size */ #define _DEFAULT_TLX 0 /* 0..216 mm */ #define _DEFAULT_TLY 0 /* 0..297 mm */ #define _DEFAULT_BRX 126 /* 0..216 mm*/ #define _DEFAULT_BRY 76.21 /* 0..297 mm */ #define _DEFAULT_TP_TLX 3.5 /* 0..42.3 mm */ #define _DEFAULT_TP_TLY 10.5 /* 0..43.1 mm */ #define _DEFAULT_TP_BRX 38.5 /* 0..42.3 mm */ #define _DEFAULT_TP_BRY 33.5 /* 0..43.1 mm */ #define _DEFAULT_NEG_TLX 1.5 /* 0..38.9 mm */ #define _DEFAULT_NEG_TLY 1.5 /* 0..29.6 mm */ #define _DEFAULT_NEG_BRX 37.5 /* 0..38.9 mm */ #define _DEFAULT_NEG_BRY 25.5 /* 0..29.6 mm */ /** image sizes for normal, transparent and negative modes */ #define _TP_X ((double)_TPAPageWidth/300.0 * MM_PER_INCH) #define _TP_Y ((double)_TPAPageHeight/300.0 * MM_PER_INCH) #define _NEG_X ((double)_NegativePageWidth/300.0 * MM_PER_INCH) #define _NEG_Y ((double)_NegativePageHeight/300.0 * MM_PER_INCH) /************************ some structures ************************************/ enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_EXT_MODE, OPT_RESOLUTION, OPT_PREVIEW, OPT_GEOMETRY_GROUP, OPT_TL_X, OPT_TL_Y, OPT_BR_X, OPT_BR_Y, OPT_ENHANCEMENT_GROUP, OPT_HALFTONE, OPT_BRIGHTNESS, OPT_CONTRAST, OPT_CUSTOM_GAMMA, OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, NUM_OPTIONS }; /** for compatiblity to version 0x0102 drivers */ typedef struct { int lampOff; int lampOffOnEnd; int warmup; OffsDef pos; /* for adjusting normal scan area */ OffsDef tpa; /* for adjusting transparency scan area */ OffsDef neg; /* for adjusting negative scan area */ } CompatAdjDef, *pCompatAdjDef; /** */ typedef struct Plustek_Device { SANE_Int initialized; /* device already initialized? */ struct Plustek_Device *next; /* pointer to next dev in list */ int fd; /* device handle */ char *name; /* (to avoid compiler warnings!)*/ SANE_Device sane; /* info struct */ SANE_Int max_x; /* max XY-extension of the scan-*/ SANE_Int max_y; /* area */ SANE_Range dpi_range; /* resolution range */ SANE_Range x_range; /* x-range of the scan-area */ SANE_Range y_range; /* y-range of the scan-area */ SANE_Int *res_list; /* to hold the available phys. */ SANE_Int res_list_size; /* resolution values */ ScannerCaps caps; /* caps reported by the driver */ AdjDef adj; /* for driver adjustment */ /* * each device we support may need other access functions... */ int (*open) ( const char*, void* ); int (*close) ( struct Plustek_Device* ); void (*shutdown) ( struct Plustek_Device* ); int (*getCaps) ( struct Plustek_Device* ); int (*getLensInfo)( struct Plustek_Device*, pLensInfo ); int (*getCropInfo)( struct Plustek_Device*, pCropInfo ); int (*putImgInfo) ( struct Plustek_Device*, pImgDef ); int (*setScanEnv) ( struct Plustek_Device*, pScanInfo ); int (*setMap) ( struct Plustek_Device*, SANE_Word*, SANE_Word, SANE_Word ); int (*startScan) ( struct Plustek_Device*, pStartScan ); int (*stopScan) ( struct Plustek_Device*, short* ); int (*readImage) ( struct Plustek_Device*, SANE_Byte*, unsigned long ); int (*prepare) ( struct Plustek_Device*, SANE_Byte* ); int (*readLine) ( struct Plustek_Device* ); } Plustek_Device, *pPlustek_Device; #ifndef SANE_OPTION /* for compatibility with older versions */ typedef union { SANE_Word w; SANE_Word *wa; /* word array */ SANE_String s; } Option_Value; #endif typedef struct Plustek_Scanner { struct Plustek_Scanner *next; SANE_Pid reader_pid; /* process id of reader */ SANE_Status exit_code; /* status of the reader process */ int r_pipe; /* pipe to reader process */ int w_pipe; /* pipe from reader process */ unsigned long bytes_read; /* number of bytes currently read*/ Plustek_Device *hw; /* pointer to current device */ Option_Value val[NUM_OPTIONS]; SANE_Byte *buf; /* the image buffer */ SANE_Bool scanning; /* TRUE during scan-process */ SANE_Parameters params; /* for keeping the parameter */ /************************** gamma tables *********************************/ SANE_Word gamma_table[4][4096]; SANE_Range gamma_range; int gamma_length; SANE_Option_Descriptor opt[NUM_OPTIONS]; } Plustek_Scanner, *pPlustek_Scanner; /** for collecting configuration info... */ typedef struct { char devName[PATH_MAX]; /* contains the stuff to adjust... */ AdjDef adj; } CnfDef, *pCnfDef; #endif /* guard __KERNEL__ */ #endif /* guard __PLUSTEKPP_H__ */ /* END PLUSTEK-PP.H .........................................................*/ sane-backends-1.0.29/backend/teco3.conf.in0000666000000000000000000000033113615534521015056 00000000000000# VM3552 scsi "" "Flat-bed scanner" Scanner scsi "RELISYS" "Scorpio" # Trust Imagery 2400SP scsi "Aashima" "IMAGERY 2400SP" Scanner * * * 0 # Trust Imagery 4800 SP +: scsi "Aashima" "IMAGERY 4800SP +" /dev/scanner sane-backends-1.0.29/backend/mustek_scsi_pp.c0000666000000000000000000006630613615534521015777 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2003 James Perry 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements the Mustek SCSI-over-parallel port protocol used by, for example, the Paragon 600 II EP */ /**************************************************************************/ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_pa4s2.h" /* * Number of times to retry sending a SCSI command before giving up */ #define MUSTEK_SCSI_PP_NUM_RETRIES 4 /* * Internal middle-level API functionality */ static int mustek_scsi_pp_timeout = 5000; /* FIXME: use same method as mustek.c ? */ static int mustek_scsi_pp_get_time () { struct timeval tv; int retval; gettimeofday (&tv, 0); retval = tv.tv_sec * 1000 + tv.tv_usec / 1000; return retval; } static u_char mustek_scsi_pp_register = 0; static SANE_Status mustek_scsi_pp_select_register (int fd, u_char reg) { DBG (5, "mustek_scsi_pp_select_register: selecting register %d on fd %d\n", reg, fd); mustek_scsi_pp_register = reg; return sanei_pa4s2_scsi_pp_reg_select (fd, reg); } static SANE_Status mustek_scsi_pp_wait_for_valid_status (int fd) { int start_time; u_char status; DBG (5, "mustek_scsi_pp_wait_for_valid_status: entering\n"); start_time = mustek_scsi_pp_get_time (); do { if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_valid_status: I/O error while getting status\n"); return SANE_STATUS_IO_ERROR; } status &= 0xf0; if ((status != 0xf0) && (!(status & 0x40)) && (status & 0x20)) { DBG (5, "mustek_scsi_pp_wait_for_valid_status: returning success\n"); return SANE_STATUS_GOOD; } } while ((mustek_scsi_pp_get_time () - start_time) < mustek_scsi_pp_timeout); DBG (2, "mustek_scsi_pp_wait_for_valid_status: timed out\n"); return SANE_STATUS_DEVICE_BUSY; } static SANE_Status mustek_scsi_pp_wait_for_status_bit_5_set (int fd) { int t; u_char status; DBG (5, "mustek_scsi_pp_wait_for_status_bit_5_set: entering\n"); t = mustek_scsi_pp_get_time (); do { if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_5_set: I/O error\n"); return SANE_STATUS_IO_ERROR; } if (status & 0x20) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_5_set: returning success\n"); return SANE_STATUS_GOOD; } } while ((mustek_scsi_pp_get_time () - t) < mustek_scsi_pp_timeout); DBG (2, "mustek_scsi_pp_wait_for_status_bit_5_set: timed out\n"); return SANE_STATUS_DEVICE_BUSY; } static SANE_Status mustek_scsi_pp_wait_for_status_bit_5_clear (int fd) { int t; u_char status; DBG (5, "mustek_scsi_pp_wait_for_status_bit_5_clear: entering\n"); t = mustek_scsi_pp_get_time (); do { if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_5_clear: I/O error\n"); return SANE_STATUS_IO_ERROR; } if (!(status & 0x20)) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_5_clear: returning success\n"); return SANE_STATUS_GOOD; } } while ((mustek_scsi_pp_get_time () - t) < mustek_scsi_pp_timeout); DBG (2, "mustek_scsi_pp_wait_for_status_bit_5_clear: timed out\n"); return SANE_STATUS_DEVICE_BUSY; } static SANE_Status mustek_scsi_pp_wait_for_status_bit_7_set (int fd) { int t; u_char status; DBG (5, "mustek_scsi_pp_wait_for_status_bit_7_set: entering\n"); t = mustek_scsi_pp_get_time (); do { if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_7_set: I/O error\n"); return SANE_STATUS_IO_ERROR; } if (status & 0x80) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_7_set: returning success\n"); return SANE_STATUS_GOOD; } } while ((mustek_scsi_pp_get_time () - t) < mustek_scsi_pp_timeout); mustek_scsi_pp_select_register (fd, 0); DBG (2, "mustek_scsi_pp_wait_for_status_bit_7_set: timed out\n"); return SANE_STATUS_DEVICE_BUSY; } static SANE_Status mustek_scsi_pp_wait_for_status_bit_7_clear (int fd) { int t; u_char status; DBG (5, "mustek_scsi_pp_wait_for_status_bit_7_clear: entering\n"); t = mustek_scsi_pp_get_time (); do { if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_7_clear: I/O error\n"); return SANE_STATUS_IO_ERROR; } if (!(status & 0x80)) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_7_clear: returning success\n"); return SANE_STATUS_GOOD; } } while ((mustek_scsi_pp_get_time () - t) < mustek_scsi_pp_timeout); mustek_scsi_pp_select_register (fd, 0); DBG (2, "mustek_scsi_pp_wait_for_status_bit_7_clear: timed out\n"); return SANE_STATUS_DEVICE_BUSY; } static SANE_Status mustek_scsi_pp_wait_for_status_bit_4_set (int fd) { int t; u_char status; DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_set: entering\n"); if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_4_set: I/O error\n"); return SANE_STATUS_IO_ERROR; } if (status & 0x10) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_set: returning success\n"); return SANE_STATUS_GOOD; } t = mustek_scsi_pp_get_time (); do { if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_4_set: I/O error\n"); return SANE_STATUS_IO_ERROR; } if (status & 0x40) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_4_set: bit 6 set\n"); return SANE_STATUS_IO_ERROR; } if (status & 0x10) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_set: returning success\n"); return SANE_STATUS_GOOD; } } while ((mustek_scsi_pp_get_time () - t) < mustek_scsi_pp_timeout); DBG (2, "mustek_scsi_pp_wait_for_status_bit_4_set: timed out\n"); return SANE_STATUS_DEVICE_BUSY; } static SANE_Status mustek_scsi_pp_wait_for_status_bit_4_clear (int fd) { int t; u_char status; DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_clear: entering\n"); if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_4_clear: I/O error\n"); return SANE_STATUS_IO_ERROR; } if (!(status & 0x10)) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_clear: returning success\n"); return SANE_STATUS_GOOD; } t = mustek_scsi_pp_get_time (); do { if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_4_clear: I/O error\n"); return SANE_STATUS_IO_ERROR; } if (status & 0x40) { DBG (2, "mustek_scsi_pp_wait_for_status_bit_4_clear: bit 6 set\n"); return SANE_STATUS_IO_ERROR; } if (!(status & 0x10)) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_clear: returning success\n"); return SANE_STATUS_GOOD; } } while ((mustek_scsi_pp_get_time () - t) < mustek_scsi_pp_timeout); DBG (2, "mustek_scsi_pp_wait_for_status_bit_4_clear: timed out\n"); return SANE_STATUS_DEVICE_BUSY; } static u_char mustek_scsi_pp_bit_4_state = 0; static SANE_Status mustek_scsi_pp_wait_for_status_bit_4_toggle (int fd) { SANE_Status result; DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_toggle: entering\n"); mustek_scsi_pp_bit_4_state ^= 0xff; if (mustek_scsi_pp_bit_4_state) { DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_toggle: waiting for set\n"); result = mustek_scsi_pp_wait_for_status_bit_4_set (fd); mustek_scsi_pp_timeout = 5000; } else { DBG (5, "mustek_scsi_pp_wait_for_status_bit_4_toggle: waiting for clear\n"); result = mustek_scsi_pp_wait_for_status_bit_4_clear (fd); } return result; } static SANE_Status mustek_scsi_pp_send_command_byte (int fd, u_char cmd) { DBG (5, "mustek_scsi_pp_send_command byte: sending 0x%02X\n", cmd); mustek_scsi_pp_select_register (fd, 0); if (mustek_scsi_pp_wait_for_status_bit_7_clear (fd) != SANE_STATUS_GOOD) { mustek_scsi_pp_select_register (fd, 0); return SANE_STATUS_IO_ERROR; } if (sanei_pa4s2_writebyte (fd, mustek_scsi_pp_register, cmd) != SANE_STATUS_GOOD) { return SANE_STATUS_IO_ERROR; } mustek_scsi_pp_select_register (fd, 1); if (mustek_scsi_pp_wait_for_status_bit_7_set (fd) != SANE_STATUS_GOOD) { mustek_scsi_pp_select_register (fd, 0); return SANE_STATUS_IO_ERROR; } mustek_scsi_pp_select_register (fd, 0); DBG (5, "mustek_scsi_pp_send_command_byte: returning success\n"); return SANE_STATUS_GOOD; } static u_char mustek_scsi_pp_read_response (int fd) { u_char result; DBG (5, "mustek_scsi_pp_read_response: entering\n"); if (mustek_scsi_pp_wait_for_status_bit_7_set (fd) != SANE_STATUS_GOOD) { mustek_scsi_pp_select_register (fd, 0); return 0xff; } if (sanei_pa4s2_readbegin (fd, mustek_scsi_pp_register) != SANE_STATUS_GOOD) { return 0xff; } if (sanei_pa4s2_readbyte (fd, &result) != SANE_STATUS_GOOD) { return 0xff; } if (sanei_pa4s2_readend (fd) != SANE_STATUS_GOOD) { return 0xff; } mustek_scsi_pp_select_register (fd, 1); if (mustek_scsi_pp_wait_for_status_bit_7_clear (fd) != SANE_STATUS_GOOD) { result = 0xff; } mustek_scsi_pp_select_register (fd, 0); DBG (5, "mustek_scsi_pp_read_response: returning 0x%02X\n", result); return result; } static SANE_Status mustek_scsi_pp_check_response (int fd) { if (mustek_scsi_pp_wait_for_status_bit_5_clear (fd) != SANE_STATUS_GOOD) { return SANE_STATUS_IO_ERROR; } if (mustek_scsi_pp_read_response (fd) != 0xA5) { DBG (2, "mustek_scsi_pp_check_response: response!=0xA5\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "mustek_scsi_pp_check_response: returning success\n"); return SANE_STATUS_GOOD; } static SANE_Status mustek_scsi_pp_send_command (int fd, const u_char * cmd) { int i; signed char checksum; DBG (5, "mustek_scsi_pp_send_command: sending SCSI command 0x%02X\n", cmd[0]); /* Set timeout depending on command type */ switch (cmd[0]) { case 0xf: case 0x8: mustek_scsi_pp_timeout = 1000; break; case 0x2: mustek_scsi_pp_timeout = 80; break; case 0x12: case 0x3: case 0x11: mustek_scsi_pp_timeout = 500; break; default: mustek_scsi_pp_timeout = 1000; break; } if (mustek_scsi_pp_wait_for_status_bit_5_set (fd) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_send_command: timed out waiting for bit 5 to set\n"); return SANE_STATUS_DEVICE_BUSY; } checksum = 0; for (i = 0; i < 6; i++) { if (mustek_scsi_pp_send_command_byte (fd, cmd[i]) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_send_command: error sending byte %d (0x%02X)\n", i, cmd[i]); return SANE_STATUS_IO_ERROR; } checksum += cmd[i]; } if (mustek_scsi_pp_send_command_byte (fd, -checksum) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_send_command: error sending checksum (0x%02X)\n", -checksum); return SANE_STATUS_IO_ERROR; } return mustek_scsi_pp_check_response (fd); } static SANE_Status mustek_scsi_pp_send_data_block (int fd, const u_char * data, int len) { int i; signed char checksum; DBG (5, "mustek_scsi_pp_send_data_block: sending block of length %d\n", len); if (mustek_scsi_pp_wait_for_status_bit_5_set (fd) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_send_data_block: timed out waiting for bit 5 to set\n"); return SANE_STATUS_DEVICE_BUSY; } checksum = 0; for (i = 0; i < len; i++) { if (mustek_scsi_pp_send_command_byte (fd, data[i]) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_send_data_block: error sending byte %d (0x%02X)\n", i, data[i]); return SANE_STATUS_IO_ERROR; } checksum += data[i]; } if (mustek_scsi_pp_send_command_byte (fd, -checksum) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_send_data_block: error sending checksum (0x%02X)\n", -checksum); return SANE_STATUS_IO_ERROR; } return mustek_scsi_pp_check_response (fd); } static SANE_Status mustek_scsi_pp_read_data_block (int fd, u_char * buffer, int len) { int i; signed char checksum; DBG (5, "mustek_scsi_pp_read_data_block: reading block of length %d\n", len); if (mustek_scsi_pp_wait_for_status_bit_5_clear (fd) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_read_data_block: timed out waiting for bit 5 to clear\n"); return SANE_STATUS_DEVICE_BUSY; } checksum = 0; for (i = 0; i < len; i++) { buffer[i] = mustek_scsi_pp_read_response (fd); checksum += buffer[i]; } if ((signed char) mustek_scsi_pp_read_response (fd) != (-checksum)) { mustek_scsi_pp_send_command_byte (fd, 0xff); DBG (2, "mustek_scsi_pp_read_data_block: checksums do not match\n"); return SANE_STATUS_IO_ERROR; } if (mustek_scsi_pp_wait_for_status_bit_5_set (fd) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_read_data_block: error waiting for bit 5 to set\n"); return SANE_STATUS_IO_ERROR; } if (mustek_scsi_pp_send_command_byte (fd, 0) != SANE_STATUS_GOOD) { mustek_scsi_pp_send_command_byte (fd, 0xff); DBG (2, "mustek_scsi_pp_read_data_block: error sending final 0 byte\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "mustek_scsi_pp_read_data_block: returning success\n"); return SANE_STATUS_GOOD; } /* * Externally visible functions */ SANE_Status mustek_scsi_pp_open (const char *dev, int *fd) { SANE_Status status; status = sanei_pa4s2_scsi_pp_open (dev, fd); if (status == SANE_STATUS_GOOD) { DBG (5, "mustek_scsi_pp_open: device %s opened as fd %d\n", dev, *fd); } else { DBG (2, "mustek_scsi_pp_open: error opening device %s\n", dev); } return status; } static void mustek_scsi_pp_close (int fd) { DBG (5, "mustek_scsi_pp_close: closing fd %d\n", fd); sanei_pa4s2_close (fd); } static void mustek_scsi_pp_exit (void) { DBG (5, "mustek_scsi_pp_exit: entering\n"); } static SANE_Status mustek_scsi_pp_test_ready (int fd) { u_char status; SANE_Status retval; DBG (5, "mustek_scsi_pp_test_ready: entering with fd=%d\n", fd); if (sanei_pa4s2_enable (fd, SANE_TRUE) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_test_ready: error enabling scanner\n"); return SANE_STATUS_IO_ERROR; } if (sanei_pa4s2_scsi_pp_get_status (fd, &status) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_test_ready: error getting status\n"); sanei_pa4s2_enable (fd, SANE_FALSE); return SANE_STATUS_INVAL; } retval = SANE_STATUS_GOOD; status &= 0xf0; if (status == 0xf0) { retval = SANE_STATUS_DEVICE_BUSY; } if (status & 0x40) { retval = SANE_STATUS_DEVICE_BUSY; } if (!(status & 0x20)) { retval = SANE_STATUS_DEVICE_BUSY; } if (sanei_pa4s2_enable (fd, SANE_FALSE) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_test_ready: error disabling scanner\n"); return SANE_STATUS_IO_ERROR; } if (retval == SANE_STATUS_GOOD) { DBG (5, "mustek_scsi_pp_test_ready: returning SANE_STATUS_GOOD\n"); } else { DBG (5, "mustek_scsi_pp_test_ready: returning SANE_STATUS_DEVICE_BUSY\n"); } return retval; } static SANE_Status mustek_scsi_pp_cmd (int fd, const void *src, size_t src_size, void *dst, size_t * dst_size) { SANE_Status stat; int num_tries = 0; static u_char scan_options = 0; const u_char *cmd; u_char stop_cmd[6] = { 0x1b, 0, 0, 0, 0, 0 }; int max_tries; max_tries = MUSTEK_SCSI_PP_NUM_RETRIES; cmd = (const u_char *) src; DBG (5, "mustek_scsi_pp_cmd: sending command 0x%02X to device %d\n", cmd[0], fd); if (sanei_pa4s2_enable (fd, SANE_TRUE) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_cmd: error enabling scanner\n"); return SANE_STATUS_IO_ERROR; } if (cmd[0] == 0x1b) { if (!(cmd[4] & 0x1)) { unsigned char c; int i; DBG (5, "mustek_scsi_pp_cmd: doing stop-specific stuff\n"); /* * Remembers what flags were sent with a 'start' command, and * replicate them with a stop command. */ stop_cmd[4] = scan_options & 0xfe; cmd = &stop_cmd[0]; /* * In color mode at least, the scanner doesn't seem to like stopping at * the end. It's a bit of a horrible hack, but reading loads of bytes and * allowing 20 tries for the stop command is the only way I've found that * solves the problem. */ max_tries = 20; if (sanei_pa4s2_readbegin (fd, mustek_scsi_pp_register) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_cmd: error in readbegin for stop\n"); } for (i = 0; i < 10000; i++) { if (sanei_pa4s2_readbyte (fd, &c) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_cmd: error reading byte for stop\n"); break; } DBG (5, "mustek_scsi_pp_cmd: successfully read byte %d\n", i); } if (sanei_pa4s2_readend (fd) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_cmd: error in readend for stop\n"); } } } if (cmd[0] == 0x08) { DBG (5, "mustek_scsi_pp_cmd: doing read-specific stuff\n"); mustek_scsi_pp_timeout = 30000; mustek_scsi_pp_bit_4_state = 0xff; } /* * Send the command itself in one block, then any extra input data in a second * block. Not sure if that's necessary. */ if (src_size < 6) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_cmd: source size is only %lu (<6)\n", (u_long) src_size); return SANE_STATUS_INVAL; } /* * Retry the command several times, as occasionally it doesn't * work first time. */ do { stat = mustek_scsi_pp_send_command (fd, cmd); num_tries++; } while ((stat != SANE_STATUS_GOOD) && (num_tries < max_tries)); if (stat != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_cmd: sending command failed\n"); return stat; } if (src_size > 6) { DBG (5, "mustek_scsi_pp_cmd: sending data block of length %lu\n", (u_long) (src_size - 6)); stat = mustek_scsi_pp_send_data_block (fd, ((const u_char *) src) + 6, src_size - 6); if (stat != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_cmd: sending data block failed\n"); return stat; } } if (dst) { unsigned int length; /* check buffer is big enough to receive data */ length = (cmd[3] << 8) | cmd[4]; DBG (5, "mustek_scsi_pp_cmd: reading %d bytes\n", length); if (length > *dst_size) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_cmd: buffer (size %lu) not big enough for data (size %d)\n", (u_long) *dst_size, length); return SANE_STATUS_INVAL; } stat = mustek_scsi_pp_read_data_block (fd, dst, length); if (stat != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_cmd: error reading data block\n"); } } if (cmd[0] == 0x1b) { if (cmd[4] & 0x1) { DBG (5, "mustek_scsi_pp_cmd: doing start-specific stuff\n"); scan_options = cmd[4]; /* 'Start' command - wait for valid status */ mustek_scsi_pp_timeout = 70000; stat = mustek_scsi_pp_wait_for_valid_status (fd); if (stat != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_cmd: error waiting for valid status after start\n"); } } } if (sanei_pa4s2_enable (fd, SANE_FALSE) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_cmd: error disabling scanner\n"); return SANE_STATUS_IO_ERROR; } if (stat == SANE_STATUS_GOOD) { DBG (5, "mustek_scsi_pp_cmd: returning success\n"); } return stat; } static SANE_Status mustek_scsi_pp_rdata (int fd, int planes, SANE_Byte * buf, int lines, int bpl) { int i, j; DBG (5, "mustek_scsi_pp_rdata: reading %d lines at %d bpl, %d planes from %d\n", lines, bpl, planes, fd); if ((planes != 1) && (planes != 3)) { DBG (2, "mustek_scsi_pp_rdata: invalid number of planes (%d)\n", planes); return SANE_STATUS_INVAL; } if (sanei_pa4s2_enable (fd, SANE_TRUE) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_rdata: error enabling scanner\n"); return SANE_STATUS_IO_ERROR; } for (i = 0; i < lines; i++) { if (planes == 3) { if (mustek_scsi_pp_wait_for_status_bit_4_toggle (fd) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error waiting for bit 4 toggle for red, line %d\n", i); return SANE_STATUS_IO_ERROR; } if (sanei_pa4s2_readbegin (fd, mustek_scsi_pp_register) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error in readbegin for red, line %d\n", i); return SANE_STATUS_IO_ERROR; } for (j = 0; j < (bpl / 3); j++) { if (sanei_pa4s2_readbyte (fd, &buf[j]) != SANE_STATUS_GOOD) { sanei_pa4s2_readend (fd); sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error reading red byte, line %d, byte %d\n", i, j); return SANE_STATUS_IO_ERROR; } } if (sanei_pa4s2_readend (fd) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error in readend for red, line %d\n", i); return SANE_STATUS_IO_ERROR; } if (mustek_scsi_pp_wait_for_status_bit_4_toggle (fd) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error waiting for bit 4 toggle for green, line %d\n", i); return SANE_STATUS_IO_ERROR; } if (sanei_pa4s2_readbegin (fd, mustek_scsi_pp_register) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error in readbegin for green, line %d\n", i); return SANE_STATUS_IO_ERROR; } for (j = 0; j < (bpl / 3); j++) { if (sanei_pa4s2_readbyte (fd, &buf[j + (bpl / 3)]) != SANE_STATUS_GOOD) { sanei_pa4s2_readend (fd); sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error reading green byte, line %d, byte %d\n", i, j); return SANE_STATUS_IO_ERROR; } } if (sanei_pa4s2_readend (fd) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error in readend for green, line %d\n", i); return SANE_STATUS_IO_ERROR; } if (mustek_scsi_pp_wait_for_status_bit_4_toggle (fd) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error waiting for bit 4 toggle for blue, line %d\n", i); return SANE_STATUS_IO_ERROR; } if (sanei_pa4s2_readbegin (fd, mustek_scsi_pp_register) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error in readbegin for blue, line %d\n", i); return SANE_STATUS_IO_ERROR; } for (j = 0; j < (bpl / 3); j++) { if (sanei_pa4s2_readbyte (fd, &buf[j + (2 * (bpl / 3))]) != SANE_STATUS_GOOD) { sanei_pa4s2_readend (fd); sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error reading blue byte, line %d, byte %d\n", i, j); return SANE_STATUS_IO_ERROR; } } if (sanei_pa4s2_readend (fd) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error in readend for blue, line %d\n", i); return SANE_STATUS_IO_ERROR; } } else { if (mustek_scsi_pp_wait_for_status_bit_4_toggle (fd) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error waiting for bit 4 toggle, line %d\n", i); return SANE_STATUS_IO_ERROR; } if (sanei_pa4s2_readbegin (fd, mustek_scsi_pp_register) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error in readbegin, line %d\n", i); return SANE_STATUS_IO_ERROR; } for (j = 0; j < bpl; j++) { if (sanei_pa4s2_readbyte (fd, &buf[j]) != SANE_STATUS_GOOD) { sanei_pa4s2_readend (fd); sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error reading byte, line %d, byte %d\n", i, j); return SANE_STATUS_IO_ERROR; } } if (sanei_pa4s2_readend (fd) != SANE_STATUS_GOOD) { sanei_pa4s2_enable (fd, SANE_FALSE); DBG (2, "mustek_scsi_pp_rdata: error in readend, line %d\n", i); return SANE_STATUS_IO_ERROR; } } buf += bpl; } if (sanei_pa4s2_enable (fd, SANE_FALSE) != SANE_STATUS_GOOD) { DBG (2, "mustek_scsi_pp_rdata: error enabling scanner\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "mustek_scsi_pp_rdata: returning success\n"); return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/test.h0000666000000000000000000000746513615534521013734 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002-2006 Henning Meier-Geinitz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This backend is for testing frontends. */ #ifndef test_h #define test_h typedef enum { param_none = 0, param_bool, param_int, param_fixed, param_string } parameter_type; typedef enum { opt_num_opts = 0, opt_mode_group, opt_mode, opt_depth, opt_hand_scanner, opt_three_pass, /* 5 */ opt_three_pass_order, opt_resolution, opt_scan_source, opt_special_group, opt_test_picture, opt_invert_endianess, opt_read_limit, opt_read_limit_size, opt_read_delay, opt_read_delay_duration, opt_read_status_code, opt_ppl_loss, opt_fuzzy_parameters, opt_non_blocking, opt_select_fd, opt_enable_test_options, opt_print_options, opt_geometry_group, opt_tl_x, opt_tl_y, opt_br_x, opt_br_y, opt_bool_group, opt_bool_soft_select_soft_detect, opt_bool_hard_select_soft_detect, opt_bool_hard_select, opt_bool_soft_detect, opt_bool_soft_select_soft_detect_emulated, opt_bool_soft_select_soft_detect_auto, opt_int_group, opt_int, opt_int_constraint_range, opt_int_constraint_word_list, opt_int_array, opt_int_array_constraint_range, opt_int_array_constraint_word_list, opt_fixed_group, opt_fixed, opt_fixed_constraint_range, opt_fixed_constraint_word_list, opt_string_group, opt_string, opt_string_constraint_string_list, opt_string_constraint_long_string_list, opt_button_group, opt_button, /* must come last: */ num_options } test_opts; typedef struct Test_Device { struct Test_Device *next; SANE_Device sane; SANE_Option_Descriptor opt[num_options]; Option_Value val[num_options]; SANE_Bool loaded[num_options]; SANE_Parameters params; SANE_String name; SANE_Pid reader_pid; SANE_Int reader_fds; SANE_Int pipe; FILE *pipe_handle; SANE_Word pass; SANE_Word bytes_per_line; SANE_Word pixels_per_line; SANE_Word lines; SANE_Int bytes_total; SANE_Bool open; SANE_Bool scanning; SANE_Bool cancelled; SANE_Bool eof; SANE_Int number_of_scans; } Test_Device; #endif /* test_h */ sane-backends-1.0.29/backend/snapscan-usb.c0000666000000000000000000004664113615534521015344 00000000000000/* Snapscan 1212U modifications for the Snapscan SANE backend Copyright (C) 2000 Henrik Johansson Henrik Johansson (henrikjo@post.urfors.se) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements USB equivalents to the SCSI routines used by the Snapscan backend. History 0.1 2000-02-01 First version released 0.2 2000-02-12 The Send Diagnostics SCSI command seems to hang some 1212U scanners. Bypassing this command fixes the problem. This bug was reported by Dmitri (dmitri@advantrix.com). 0.3 2000-02-13 The "Set window" command returns with status "Device busy" when the scanner is busy. One consequence is that some frontends exits with an error message if it's started when the scanner is warming up. A solution was suggested by Dmitri (dmitri@advantrix.com) The idea is that a SCSI command which returns "device busy" is stored in a "TODO" queue. The send command function is modified to first send commands in the queue before the intended command. So far this strategy has worked flawlessly. Thanks Dmitri! */ /* $Id$ SnapScan backend scan data sources */ #include "snapscan-usb.h" #include "snapscan-mutex.c" #ifndef SHM_R #define SHM_R 0 #endif #ifndef SHM_W #define SHM_W 0 #endif /* Global variables */ static snapscan_mutex_t snapscan_mutex; static sense_handler_type usb_sense_handler; static void* usb_pss; struct urb_counters_t { unsigned long read_urbs; unsigned long write_urbs; }; static struct urb_counters_t* urb_counters = NULL; /* Forward declarations */ static SANE_Status usb_request_sense(SnapScan_Scanner *pss); static SANE_Status snapscani_usb_cmd(int fd, const void *src, size_t src_size, void *dst, size_t * dst_size) { static const char me[] = "snapscani_usb_cmd"; int status; DBG (DL_CALL_TRACE, "%s(%d,0x%lx,%lu,0x%lx,0x%lx (%lu))\n", me, fd, (u_long) src,(u_long) src_size,(u_long) dst, (u_long) dst_size,(u_long) (dst_size ? *dst_size : 0)); while(bqhead) { status = atomic_usb_cmd(fd, bqhead->src, bqhead->src_size, NULL, NULL); if(status == SANE_STATUS_DEVICE_BUSY) { if(is_queueable(src)) { enqueue_bq(fd,src,src_size); return SANE_STATUS_GOOD; } else { sleep(1); continue; } } dequeue_bq(); } status = atomic_usb_cmd(fd,src,src_size,dst,dst_size); if ((status == SANE_STATUS_DEVICE_BUSY) && is_queueable(src) ) { enqueue_bq(fd,src,src_size); return SANE_STATUS_GOOD; } return status; } static SANE_Status atomic_usb_cmd(int fd, const void *src, size_t src_size, void *dst, size_t * dst_size) { static const char me[] = "atomic_usb_cmd"; int status; sigset_t all,oldset; DBG (DL_CALL_TRACE, "%s(%d,0x%lx,%lu,0x%lx,0x%lx (%lu))\n", me, fd, (u_long) src,(u_long) src_size,(u_long) dst, (u_long) dst_size,(u_long) (dst_size ? *dst_size : 0)); /* Prevent the calling process from being killed */ sigfillset(&all); sigprocmask(SIG_BLOCK, &all, &oldset); /* Make sure we are alone */ snapscani_mutex_lock(&snapscan_mutex); status = usb_cmd(fd,src,src_size,dst,dst_size); snapscani_mutex_unlock(&snapscan_mutex); /* Now it is ok to be killed */ sigprocmask(SIG_SETMASK, &oldset, NULL); return status; } static SANE_Status snapscani_usb_open(const char *dev, int *fdp, sense_handler_type sense_handler, void* pss) { static const char me[] = "snapscani_usb_open"; DBG (DL_CALL_TRACE, "%s(%s)\n", me, dev); if(!snapscani_mutex_open(&snapscan_mutex, dev)) { DBG (DL_MAJOR_ERROR, "%s: Can't get semaphore\n", me); return SANE_STATUS_INVAL; } usb_sense_handler=sense_handler; usb_pss = pss; urb_counters->read_urbs = 0; urb_counters->write_urbs = 0; return sanei_usb_open(dev, fdp); } static void snapscani_usb_close(int fd) { static const char me[] = "snapscani_usb_close"; SANE_Word vendor_id, product_id; DBG (DL_CALL_TRACE, "%s(%d)\n", me, fd); DBG (DL_DATA_TRACE,"1st read %ld write %ld\n", urb_counters->read_urbs, urb_counters->write_urbs); /* Check if URB counting is needed. If yes, ensure the number of sent and received URBs is even. Odd number of URBs only cause problems with libusb and certain scanner models. On other scanner models, sending additional commands seems to cause problems (e.g. 1212u_2). If sanei_usb_get_vendor_product returns an error there's probably no libusb, so everything's fine. */ if (sanei_usb_get_vendor_product(fd, &vendor_id, &product_id) == SANE_STATUS_GOOD) { /* Exclude 1212u_2 */ if (!((vendor_id == USB_VENDOR_AGFA) && (product_id == USB_PRODUCT_1212U2))) { if ((urb_counters->read_urbs & 0x01) && (urb_counters->write_urbs & 0x01)) { char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0}; snapscani_usb_cmd (fd, cmd, sizeof (cmd), NULL, 0); } else if (urb_counters->read_urbs & 0x01) { size_t read_bytes; char cmd[] = {TEST_UNIT_READY, 0, 0, 0, 0, 0}; char cmd2[] = {INQUIRY, 0, 0, 0, 120, 0}; char data[120]; read_bytes = 120; snapscani_usb_cmd (fd, cmd2, sizeof (cmd2), data, &read_bytes); snapscani_usb_cmd (fd, cmd, sizeof (cmd), NULL, 0); } else if (urb_counters->write_urbs & 0x01) { size_t read_bytes; char cmd[] = {INQUIRY, 0, 0, 0, 120, 0}; char data[120]; read_bytes = 120; snapscani_usb_cmd (fd, cmd, sizeof (cmd), data, &read_bytes); } DBG (DL_DATA_TRACE,"2nd read %ld write %ld\n", urb_counters->read_urbs, urb_counters->write_urbs); } } urb_counters->read_urbs = 0; urb_counters->write_urbs = 0; snapscani_mutex_close(&snapscan_mutex); sanei_usb_close(fd); } static int usb_cmdlen(int cmd) { switch(cmd) { case TEST_UNIT_READY: case INQUIRY: case SCAN: case REQUEST_SENSE: case RESERVE_UNIT: case RELEASE_UNIT: case SEND_DIAGNOSTIC: return 6; case SEND: case SET_WINDOW: case READ: case GET_DATA_BUFFER_STATUS: return 10; } return 0; } static char *usb_debug_data(char *str,const char *data, int len) { char tmpstr[10]; int i; str[0]=0; for(i=0; i < (len < 10 ? len : 10); i++) { sprintf(tmpstr," 0x%02x",((int)data[i]) & 0xff); if(i%16 == 0 && i != 0) strcat(str,"\n"); strcat(str,tmpstr); } if(i < len) strcat(str," ..."); return str; } #define RETURN_ON_FAILURE(x) if((status = x) != SANE_STATUS_GOOD) return status; static SANE_Status usb_write(int fd, const void *buf, size_t n) { char dbgmsg[16384]; SANE_Status status; size_t bytes_written = n; static const char me[] = "usb_write"; DBG(DL_DATA_TRACE, "%s: writing: %s\n",me,usb_debug_data(dbgmsg,buf,n)); status = sanei_usb_write_bulk(fd, (const SANE_Byte*)buf, &bytes_written); if(bytes_written != n) { DBG (DL_MAJOR_ERROR, "%s Only %lu bytes written\n",me, (u_long) bytes_written); status = SANE_STATUS_IO_ERROR; } urb_counters->write_urbs += (bytes_written + 7) / 8; DBG (DL_DATA_TRACE, "Written %lu bytes\n", (u_long) bytes_written); return status; } static SANE_Status usb_read(SANE_Int fd, void *buf, size_t n) { char dbgmsg[16384]; static const char me[] = "usb_read"; SANE_Status status; size_t bytes_read = n; status = sanei_usb_read_bulk(fd, (SANE_Byte*)buf, &bytes_read); if (bytes_read != n) { DBG (DL_MAJOR_ERROR, "%s Only %lu bytes read\n",me, (u_long) bytes_read); status = SANE_STATUS_IO_ERROR; } urb_counters->read_urbs += ((63 + bytes_read) / 64); DBG(DL_DATA_TRACE, "%s: reading: %s\n",me,usb_debug_data(dbgmsg,buf,n)); DBG(DL_DATA_TRACE, "Read %lu bytes\n", (u_long) bytes_read); return status; } static SANE_Status usb_read_status(int fd, int *scsistatus, int *transaction_status, char command) { static const char me[] = "usb_read_status"; unsigned char status_buf[8]; int scsistat; int status; RETURN_ON_FAILURE(usb_read(fd,status_buf,8)); if(transaction_status) *transaction_status = status_buf[0]; scsistat = (status_buf[1] & STATUS_MASK) >> 1; if(scsistatus) *scsistatus = scsistat; switch(scsistat) { case GOOD: return SANE_STATUS_GOOD; case CHECK_CONDITION: if (usb_pss != NULL) { if (command != REQUEST_SENSE) { return usb_request_sense(usb_pss); } else { /* Avoid recursive calls of usb_request_sense */ return SANE_STATUS_GOOD; } } else { DBG (DL_MAJOR_ERROR, "%s: scanner structure not set, returning default error\n", me); return SANE_STATUS_DEVICE_BUSY; } break; case BUSY: return SANE_STATUS_DEVICE_BUSY; default: return SANE_STATUS_IO_ERROR; } } static SANE_Status usb_cmd(int fd, const void *src, size_t src_size, void *dst, size_t * dst_size) { static const char me[] = "usb_cmd"; int status,tstatus; int cmdlen,datalen; char command; DBG (DL_CALL_TRACE, "%s(%d,0x%lx,%lu,0x%lx,0x%lx (%lu))\n", me, fd, (u_long) src,(u_long) src_size,(u_long) dst, (u_long) dst_size,(u_long) (dst_size ? *dst_size : 0)); /* Since the "Send Diagnostic" command isn't supported by all Snapscan USB-scanners it's disabled . */ command = ((const char *)src)[0]; if(command == SEND_DIAGNOSTIC) return(SANE_STATUS_GOOD); cmdlen = usb_cmdlen(*((const char *)src)); datalen = src_size - cmdlen; DBG(DL_DATA_TRACE, "%s: cmdlen=%d, datalen=%d\n",me,cmdlen,datalen); /* Send command to scanner */ RETURN_ON_FAILURE( usb_write(fd,src,cmdlen) ); /* Read status */ RETURN_ON_FAILURE( usb_read_status(fd, NULL, &tstatus, command) ); /* Send data only if the scanner is expecting it */ if(datalen > 0 && (tstatus == TRANSACTION_WRITE)) { /* Send data to scanner */ RETURN_ON_FAILURE( usb_write(fd, ((const SANE_Byte *) src) + cmdlen, datalen) ); /* Read status */ RETURN_ON_FAILURE( usb_read_status(fd, NULL, &tstatus, command) ); } /* Receive data only when new data is waiting */ if(dst_size && *dst_size && (tstatus == TRANSACTION_READ)) { RETURN_ON_FAILURE( usb_read(fd,dst,*dst_size) ); /* Read status */ RETURN_ON_FAILURE( usb_read_status(fd, NULL, &tstatus, command) ); } if(tstatus != TRANSACTION_COMPLETED) { if(tstatus == TRANSACTION_WRITE) DBG(DL_MAJOR_ERROR, "%s: The transaction should now be completed, but the scanner is expecting more data" ,me); else DBG(DL_MAJOR_ERROR, "%s: The transaction should now be completed, but the scanner has more data to send" ,me); return SANE_STATUS_IO_ERROR; } return status; } /* Busy queue data structures and function implementations*/ static int is_queueable(const char *src) { switch(src[0]) { case SEND: case SET_WINDOW: case SEND_DIAGNOSTIC: return 1; default: return 0; } } static struct usb_busy_queue *bqhead=NULL,*bqtail=NULL; static int bqelements=0; static int enqueue_bq(int fd,const void *src, size_t src_size) { static const char me[] = "enqueue_bq"; struct usb_busy_queue *bqe; DBG (DL_CALL_TRACE, "%s(%d,%p,%lu)\n", me, fd,src, (u_long) src_size); if((bqe = malloc(sizeof(struct usb_busy_queue))) == NULL) return -1; if((bqe->src = malloc(src_size)) == NULL) return -1; memcpy(bqe->src,src,src_size); bqe->src_size=src_size; bqe->next=NULL; if(bqtail) { bqtail->next=bqe; bqtail = bqe; } else bqhead = bqtail = bqe; bqelements++; DBG(DL_DATA_TRACE, "%s: Busy queue: elements=%d, bqhead=%p, bqtail=%p\n", me,bqelements,(void*)bqhead,(void*)bqtail); return 0; } static void dequeue_bq() { static const char me[] = "dequeue_bq"; struct usb_busy_queue *tbqe; DBG (DL_CALL_TRACE, "%s()\n", me); if(!bqhead) return; tbqe = bqhead; bqhead = bqhead->next; if(!bqhead) bqtail=NULL; if(tbqe->src) free(tbqe->src); free(tbqe); bqelements--; DBG(DL_DATA_TRACE, "%s: Busy queue: elements=%d, bqhead=%p, bqtail=%p\n", me,bqelements,(void*)bqhead,(void*)bqtail); } static SANE_Status usb_request_sense(SnapScan_Scanner *pss) { static const char *me = "usb_request_sense"; size_t read_bytes = 0; u_char cmd[] = {REQUEST_SENSE, 0, 0, 0, 20, 0}; u_char data[20]; SANE_Status status; read_bytes = 20; DBG (DL_CALL_TRACE, "%s\n", me); status = usb_cmd (pss->fd, cmd, sizeof (cmd), data, &read_bytes); if (status != SANE_STATUS_GOOD) { DBG (DL_MAJOR_ERROR, "%s: usb command error: %s\n", me, sane_strstatus (status)); } else { if (usb_sense_handler) { status = usb_sense_handler (pss->fd, data, (void *) pss); } else { DBG (DL_MAJOR_ERROR, "%s: No sense handler for USB\n", me); status = SANE_STATUS_UNSUPPORTED; } } return status; } #if defined USE_PTHREAD || defined HAVE_OS2_H || defined __BEOS__ static SANE_Status snapscani_usb_shm_init(void) { unsigned int shm_size = sizeof(struct urb_counters_t); urb_counters = (struct urb_counters_t*) malloc(shm_size); if (urb_counters == NULL) { return SANE_STATUS_NO_MEM; } memset(urb_counters, 0, shm_size); return SANE_STATUS_GOOD; } static void snapscani_usb_shm_exit(void) { if (urb_counters) { free ((void*)urb_counters); urb_counters = NULL; } } #else #include #include static SANE_Status snapscani_usb_shm_init(void) { unsigned int shm_size = sizeof(struct urb_counters_t); void* shm_area = NULL; int shm_id = shmget (IPC_PRIVATE, shm_size, IPC_CREAT | SHM_R | SHM_W); if (shm_id == -1) { DBG (DL_MAJOR_ERROR, "snapscani_usb_shm_init: cannot create shared memory segment: %s\n", strerror (errno)); return SANE_STATUS_NO_MEM; } shm_area = shmat (shm_id, NULL, 0); if (shm_area == (void *) -1) { DBG (DL_MAJOR_ERROR, "snapscani_usb_shm_init: cannot attach to shared memory segment: %s\n", strerror (errno)); shmctl (shm_id, IPC_RMID, NULL); return SANE_STATUS_NO_MEM; } if (shmctl (shm_id, IPC_RMID, NULL) == -1) { DBG (DL_MAJOR_ERROR, "snapscani_usb_shm_init: cannot remove shared memory segment id: %s\n", strerror (errno)); shmdt (shm_area); shmctl (shm_id, IPC_RMID, NULL); return SANE_STATUS_NO_MEM; } urb_counters = (struct urb_counters_t*) shm_area; memset(urb_counters, 0, shm_size); return SANE_STATUS_GOOD; } static void snapscani_usb_shm_exit(void) { if (urb_counters) { shmdt (urb_counters); urb_counters = NULL; } } #endif /* * $Log$ * Revision 1.22 2006/01/26 17:42:30 hmg-guest * Added #defines for SHM_R/W for cygwin (patch from Philip Aston ). * * Revision 1.21 2005/11/02 19:22:06 oliver-guest * Fixes for Benq 5000 * * Revision 1.20 2005/07/18 17:37:37 oliver-guest * ZETA changes for SnapScan backend * * Revision 1.19 2004/10/03 17:34:36 hmg-guest * 64 bit platform fixes (bug #300799). * * Revision 1.18 2004/06/16 19:52:26 oliver-guest * Don't enforce even number of URB packages on 1212u_2. Fixes bug #300753. * * Revision 1.17 2004/06/06 14:50:36 oliver-guest * Use shared memory functions only when needed * * Revision 1.16 2004/05/26 22:37:01 oliver-guest * Use shared memory for urb counters in snapscan backend * * Revision 1.15 2004/04/09 11:59:02 oliver-guest * Fixes for pthread implementation * * Revision 1.14 2004/04/08 22:48:13 oliver-guest * Use URB counting in snapscan-usb.c (thanks to Jose Alberto Reguero) * * Revision 1.13 2003/11/08 09:50:27 oliver-guest * Fix TPO scanning range for Epson 1670 * * Revision 1.12 2003/07/26 17:16:55 oliverschwartz * Changed licence to GPL + SANE exception for snapscan-usb.[ch] * * Revision 1.11 2002/07/12 23:29:06 oliverschwartz * SnapScan backend 1.4.15 * * Revision 1.21 2002/07/12 22:52:42 oliverschwartz * use sanei_usb_read_bulk() and sanei_usb_write_bulk() * * Revision 1.20 2002/04/27 14:36:25 oliverschwartz * Pass a char as 'proj' argument for ftok() * * Revision 1.19 2002/04/10 21:00:33 oliverschwartz * Make bqelements static * * Revision 1.18 2002/03/24 12:16:09 oliverschwartz * Better error report in usb_read * * Revision 1.17 2002/02/05 19:32:39 oliverschwartz * Only define union semun if not already defined in . Fixes * compilation bugs on Irix and FreeBSD. Fixed by Henning Meier-Geinitz. * * Revision 1.16 2002/01/14 21:11:56 oliverschwartz * Add workaround for bug semctl() call in libc for PPC * * Revision 1.15 2001/12/09 23:06:44 oliverschwartz * - use sense handler for USB if scanner reports CHECK_CONDITION * * Revision 1.14 2001/11/16 20:23:16 oliverschwartz * Merge with sane-1.0.6 * - Check USB vendor IDs to avoid hanging scanners * - fix bug in dither matrix computation * * Revision 1.13 2001/10/09 22:34:23 oliverschwartz * fix compiler warnings * * Revision 1.12 2001/09/18 15:01:07 oliverschwartz * - Read scanner id string again after firmware upload * to indentify correct model * - Make firmware upload work for AGFA scanners * - Change copyright notice * * */ sane-backends-1.0.29/backend/apple.conf.in0000666000000000000000000000003013615534521015136 00000000000000scsi APPLE /dev/scanner sane-backends-1.0.29/backend/saned.conf.in0000666000000000000000000000203413615534521015135 00000000000000# saned.conf # Configuration for the saned daemon ## Daemon options # Port range for the data connection. Choose a range inside [1024 - 65535]. # Avoid specifying too large a range, for performance reasons. # # ONLY use this if your saned server is sitting behind a firewall. If your # firewall is a Linux machine, we strongly recommend using the # Netfilter nf_conntrack_sane connection tracking module instead. # # data_portrange = 10000 - 10100 ## Access list # A list of host names, IP addresses or IP subnets (CIDR notation) that # are permitted to use local SANE devices. IPv6 addresses must be enclosed # in brackets, and should always be specified in their compressed form. # # The hostname matching is not case-sensitive. #scan-client.somedomain.firm #192.168.0.1 #192.168.0.1/29 #[2001:db8:185e::42:12] #[2001:db8:185e::42:12]/64 # NOTE: /etc/inetd.conf (or /etc/xinetd.conf) and # /etc/services must also be properly configured to start # the saned daemon as documented in saned(8), services(4) # and inetd.conf(4) (or xinetd.conf(5)). sane-backends-1.0.29/backend/umax_pp.h0000666000000000000000000001132213615534521014411 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001-2012 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Umax PP flatbed scanners. */ #ifndef umax_pp_h #define umax_pp_h #include #include #include <../include/sane/sanei_debug.h> enum Umax_PP_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_RESOLUTION, OPT_PREVIEW, OPT_GRAY_PREVIEW, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_LAMP_CONTROL, OPT_UTA_CONTROL, OPT_CUSTOM_GAMMA, /* use custom gamma tables? */ /* The gamma vectors MUST appear in the order gray, red, green, blue. */ OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, OPT_MANUAL_GAIN, OPT_GRAY_GAIN, OPT_RED_GAIN, OPT_GREEN_GAIN, OPT_BLUE_GAIN, OPT_MANUAL_OFFSET, OPT_GRAY_OFFSET, OPT_RED_OFFSET, OPT_GREEN_OFFSET, OPT_BLUE_OFFSET, /* must come last: */ NUM_OPTIONS }; typedef struct Umax_PP_Descriptor { SANE_Device sane; SANE_String port; SANE_String ppdevice; SANE_Int max_res; SANE_Int ccd_res; SANE_Int max_h_size; SANE_Int max_v_size; long int buf_size; u_char revision; /* default values */ SANE_Int gray_gain; SANE_Int red_gain; SANE_Int blue_gain; SANE_Int green_gain; SANE_Int gray_offset; SANE_Int red_offset; SANE_Int blue_offset; SANE_Int green_offset; } Umax_PP_Descriptor; typedef struct Umax_PP_Device { struct Umax_PP_Device *next; Umax_PP_Descriptor *desc; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Int gamma_table[4][256]; int state; int mode; int TopX; int TopY; int BottomX; int BottomY; int dpi; int gain; int color; int bpp; /* bytes per pixel */ int tw; /* target width in pixels */ int th; /* target height in pixels */ SANE_Byte *calibration; SANE_Byte *buf; long int bufsize; /* size of read buffer */ long int buflen; /* size of data length in buffer */ long int bufread; /* number of bytes read in the buffer */ long int read; /* bytes read from previous start scan */ SANE_Parameters params; SANE_Range dpi_range; SANE_Range x_range; SANE_Range y_range; SANE_Int gray_gain; SANE_Int red_gain; SANE_Int blue_gain; SANE_Int green_gain; SANE_Int gray_offset; SANE_Int red_offset; SANE_Int blue_offset; SANE_Int green_offset; } Umax_PP_Device; /** * enumeration of configuration options */ enum Umax_PP_Configure_Option { CFG_BUFFER = 0, CFG_RED_GAIN, CFG_GREEN_GAIN, CFG_BLUE_GAIN, CFG_RED_OFFSET, CFG_GREEN_OFFSET, CFG_BLUE_OFFSET, CFG_VENDOR, CFG_NAME, CFG_MODEL, CFG_ASTRA, NUM_CFG_OPTIONS }; #define DEBUG() DBG(4, "%s(v%d.%d.%d-%s): line %d: debug exception\n", \ __func__, SANE_CURRENT_MAJOR, V_MINOR, \ UMAX_PP_BUILD, UMAX_PP_STATE, __LINE__) #endif /* umax_pp_h */ sane-backends-1.0.29/backend/plustek-pp_dac.c0000666000000000000000000023114313615534521015653 00000000000000/* @file plustek-pp_dac.c * @brief all the shading function formerly found in shading.c. * don't ask me why I called this file dac.c... * * based on sources acquired from Plustek Inc. * Copyright (C) 1998 Plustek Inc. * Copyright (C) 2000-2004 Gerhard Jaeger * also based on the work done by Rick Bronson * * History: * - 0.30 - initial version * - 0.31 - no changes * - 0.32 - no changes * - 0.33 - added some comments * - 0.34 - slight changes * - 0.35 - removed SetInitialGainRAM from structure pScanData * - 0.36 - added dacP96001WaitForShading and changed dacP96WaitForShading to * dacP96003WaitForShading * - changes, due to define renaming * - 0.37 - removed dacP98FillShadingDarkToShadingRegister() * - removed // comments * - some code cleanup * - 0.38 - added P12 stuff * - 0.39 - no changes * - 0.40 - disabled the A3I stuff * - 0.41 - no changes * - 0.42 - changed include names * - 0.43 - no changes * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #include "plustek-pp_scan.h" /************************** local definitions ********************************/ /***************************** global vars ***********************************/ static const Byte a_bCorrectTimesTable[4] = {0, 1, 2, 4}; static ULong dwADCPipeLine = 4 * 4; static ULong dwReadyLen; /*************************** local functions *********************************/ /** */ static void dacP98AdjustGainAverage( pScanData ps ) { pUChar pDest, pSrce; ULong dw, dw1; UShort wSum; pDest = pSrce = ps->pScanBuffer1; for (dw1 = 0; dw1 < (2560 * 3) / 16; dw1++, pDest++) { for (dw = 0, wSum = 0; dw < 16; dw++, pSrce++) wSum += *pSrce; *pDest = wSum / 16; } } /** */ static void dacP98FillDarkDAC( pScanData ps ) { IODataRegisterToDAC( ps, 0x20, ps->bRedDAC ); IODataRegisterToDAC( ps, 0x21, ps->bGreenDAC ); IODataRegisterToDAC( ps, 0x22, ps->bBlueDAC ); } /** */ static void dacP98SetReadFBKRegister( pScanData ps ) { IODataToRegister( ps, ps->RegModeControl, _ModeIdle ); ps->AsicReg.RD_ScanControl = _SCAN_12BITMODE + _SCAN_1ST_AVERAGE; IOSelectLampSource( ps ); IODataToRegister( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl ); ps->AsicReg.RD_Motor0Control = _MotorOn; ps->AsicReg.RD_StepControl = _MOTOR0_SCANSTATE; ps->AsicReg.RD_Origin = 4; ps->AsicReg.RD_Pixels = 512; ps->AsicReg.RD_Motor1Control = 0; ps->AsicReg.RD_Motor0Control = 0; ps->AsicReg.RD_ModelControl = _LED_CONTROL + _LED_ACTIVITY; if( ps->bSetScanModeFlag & _ScanMode_AverageOut ) { ps->AsicReg.RD_Dpi = 300; ps->AsicReg.RD_ModelControl += _ModelDpi300; } else { ps->AsicReg.RD_Dpi = 600; ps->AsicReg.RD_ModelControl += _ModelDpi600; } } /** */ static UShort dacP98CalDarkOff( pScanData ps, UShort wChDarkOff, UShort wDACCompareHigh, UShort wDACOffset ) { UShort wTemp; if ((_CCD_518 == ps->Device.bCCDID) || (_CCD_535 == ps->Device.bCCDID)) { wTemp = wChDarkOff + wDACOffset; } else { if (_CCD_3797 == ps->Device.bCCDID) { if (wChDarkOff > wDACOffset) { wTemp = wChDarkOff - wDACOffset; } else { wTemp = 0; } } else { if (wChDarkOff > wDACCompareHigh) { wTemp = wChDarkOff - wDACCompareHigh; } else { wTemp = 0; } } } return wTemp; } /** */ static Bool dacP98AdjustDAC( UShort DarkOff, UShort wHigh, UShort wLow, pUChar pbReg, Bool *fDACStopFlag ) { if (DarkOff > wHigh) { if ((DarkOff - wHigh) > 10) { if ((DarkOff - wHigh) > 2550) *pbReg += ((DarkOff - wHigh) / 20); else *pbReg += ((DarkOff - wHigh) / 10); } else *pbReg += 1; if (!(*pbReg)) *pbReg = 0xff; *fDACStopFlag = _FALSE; return _FALSE; } else { if (DarkOff < wLow) { if (DarkOff > 0) *pbReg -= 2; else *pbReg -= 10; *fDACStopFlag = _FALSE; return _FALSE; } else return _TRUE; } } /** */ static Bool dacP98CheckChannelDarkLevel( pScanData ps ) { Bool fDACStopFlag = _TRUE; dacP98AdjustDAC( ps->Shade.DarkOffset.Colors.Red, ps->Shade.pCcdDac->DarkCmpHi.Colors.Red, ps->Shade.pCcdDac->DarkCmpLo.Colors.Red, &ps->bRedDAC, &fDACStopFlag ); dacP98AdjustDAC( ps->Shade.DarkOffset.Colors.Green, ps->Shade.pCcdDac->DarkCmpHi.Colors.Green, ps->Shade.pCcdDac->DarkCmpLo.Colors.Green, &ps->bGreenDAC, &fDACStopFlag ); dacP98AdjustDAC( ps->Shade.DarkOffset.Colors.Blue, ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue, ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue, &ps->bBlueDAC, &fDACStopFlag ); return fDACStopFlag; } /** Average left offset 30, 16 pixels as each color's dark level */ static void dacP98FillChannelDarkLevelControl( pScanData ps ) { DataPointer p; ULong dwPos, dw, dwSum; if( ps->bSetScanModeFlag & _ScanMode_AverageOut ) { dwPos = 0x10 * 3; } else { dwPos = 0x20 * 2; } for (p.pw = (pUShort)(ps->pScanBuffer1 + dwPos), dwSum = 0, dw = 16; dw; dw--, p.pw++) { dwSum += (ULong)(*p.pw); } ps->Shade.DarkOffset.Colors.Red = (UShort)(dwSum / 16); for (p.pw = (pUShort)(ps->pScanBuffer1 + dwPos + 1024), dwSum = 0, dw = 16; dw; dw--, p.pw++) { dwSum += (ULong)(*p.pw); } ps->Shade.DarkOffset.Colors.Green = (UShort)(dwSum / 16); for (p.pw = (pUShort)(ps->pScanBuffer1 + dwPos + 1024 * 2), dwSum = 0, dw = 16; dw; dw--, p.pw++) { dwSum += (ULong)(*p.pw); } ps->Shade.DarkOffset.Colors.Blue = (UShort)(dwSum / 16); } /** */ static void dacP98AdjustGain( pScanData ps ) { DataPointer p; ULong dw; UShort w; Byte b[3]; pUChar pbReg[3]; dacP98AdjustGainAverage( ps ); pbReg[0] = &ps->bRedGainIndex; pbReg[1] = &ps->bGreenGainIndex; pbReg[2] = &ps->bBlueGainIndex; for (w = 0, p.pb = ps->pScanBuffer1; w < 3; w++) { for (dw = 2560 / 16, b [w] = 0; dw; dw--, p.pb++) { if (b [w] < *p.pb) b [w] = *p.pb; } if (b[w] < _GAIN_LOW) { if ((_GAIN_P98_HIGH - b[w]) < b[w]) *(pbReg[w]) += 1; else *(pbReg[w]) += 4; } else { if (b[w] > _GAIN_P98_HIGH) *(pbReg[w]) -= 1; } } } /** */ static void dacP98CheckLastGain( pScanData ps ) { DataPointer p; ULong dw; UShort w; Byte b[3]; pUChar pbReg[3]; dacP98AdjustGainAverage( ps ); pbReg[0] = &ps->bRedGainIndex; pbReg[1] = &ps->bGreenGainIndex; pbReg[2] = &ps->bBlueGainIndex; for (w = 0, p.pb = ps->pScanBuffer1; w < 3; w++) { for (dw = 2560 / 16, b [w] = 0; dw; dw--, p.pb++) { if (b[w] < *p.pb) b[w] = *p.pb; } if (b[w] > _GAIN_P98_HIGH) { *(pbReg [w]) -= 1; } } } /** */ static void dacP98FillGainInitialRestRegister( pScanData ps ) { ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegThresholdGapControl, ps->AsicReg.RD_ThresholdGapCtrl ); IODataToRegister( ps, ps->RegModelControl, ps->AsicReg.RD_ModelControl ); ps->CloseScanPath( ps ); } /** */ static void dacP98SetInitialGainRegister( pScanData ps ) { DacP98FillGainOutDirectPort( ps ); /* R/G/B GainOut to scanner */ dacP98FillGainInitialRestRegister( ps );/* Model Control2, LED, Correct.*/ } /** Find the most ideal intensity for each color (RGB) */ static void dacP98SetRGBGainRegister( pScanData ps ) { IOCmdRegisterToScanner( ps, ps->RegModeControl, _ModeIdle ); ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE; IOSelectLampSource( ps ); IOCmdRegisterToScanner( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl); dacP98SetInitialGainRegister( ps ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_StepControl = _MOTOR0_SCANSTATE; ps->AsicReg.RD_Motor0Control = _MotorOn + _MotorDirForward + _MotorHEightStep; ps->AsicReg.RD_XStepTime = ps->bSpeed4; if( ps->bSetScanModeFlag & _ScanMode_AverageOut ) { ps->AsicReg.RD_ModelControl = _LED_CONTROL + _ModelDpi300; ps->AsicReg.RD_Origin = 32 + 60 + 4; } else { ps->AsicReg.RD_ModelControl = _LED_CONTROL + _ModelDpi600; ps->AsicReg.RD_Origin = 64 + 120 + 4; } ps->AsicReg.RD_Dpi = 300; ps->AsicReg.RD_Pixels = 2560; IOPutOnAllRegisters( ps ); } /** */ static void dacP98FillRGBMap( pUChar pBuffer ) { ULong dw, dw1; pULong pdw = (pULong)(pBuffer); for( dw = 256, dw1 = 0; dw; dw--, dw1 += 0x01010101 ) { *pdw++ = dw1; *pdw++ = dw1; *pdw++ = dw1; *pdw++ = dw1; } } /** here we download the current mapping table */ static void dacP98DownloadMapTable( pScanData ps, pUChar pBuffer ) { Byte bAddr; ULong i; IODataToRegister( ps, ps->RegScanControl, (Byte)((ps->AsicReg.RD_ScanControl & 0xfc) | _SCAN_BYTEMODE)); for( i = 3, bAddr = _MAP_ADDR_RED; i--; bAddr += _MAP_ADDR_SIZE ) { IODataToRegister( ps, ps->RegModeControl, _ModeMappingMem ); IODataToRegister( ps, ps->RegMemoryLow, 0); IODataToRegister( ps, ps->RegMemoryHigh, bAddr ); IOMoveDataToScanner( ps, pBuffer, 4096 ); pBuffer += 4096; } IODataToRegister( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl ); } /** */ static void dacP98DownloadShadingTable( pScanData ps, pUChar pBuffer, ULong size ) { IODataToRegister( ps, ps->RegModeControl, _ModeShadingMem ); IODataToRegister( ps, ps->RegMemoryLow, 0 ); IODataToRegister( ps, ps->RegMemoryHigh, 0 ); /* set 12 bits output color */ IODataToRegister( ps, ps->RegScanControl, (Byte)(ps->AsicReg.RD_ScanControl | _SCAN_12BITMODE)); /* MoveDataToShadingRam() */ IOMoveDataToScanner( ps ,pBuffer, size ); if( _ASIC_IS_98003 == ps->sCaps.AsicID ) IODataToRegister( ps, ps->RegModeControl, _ModeScan ); else IODataToRegister( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl ); DacP98FillShadingDarkToShadingRegister( ps ); } /** Build a linear map for asic (this model is 12-bit scanner, there are 4096 * map entries but just generate 256 level output, so the content must be 0 to * 255), then fill the shading buffer (the first 3k), and map table (the last * 1k) to asic for R & G & B channels. * * I need pScanBuffer2 size = 5400 * 2 * 3 * pScanBuffer1 size = 256 * 16 * 2 */ static void dacP98SetInitialGainRAM( pScanData ps ) { memset( ps->pScanBuffer2, 0xff, (5400 * 2 * 3)); dacP98DownloadShadingTable( ps, ps->pScanBuffer2, (5400 * 2 * 3)); dacP98FillRGBMap( ps->pScanBuffer1 ); /* Fill 12 Bits R Map */ dacP98FillRGBMap( ps->pScanBuffer1 + 4096 ); /* Fill 12 Bits G Map */ dacP98FillRGBMap( ps->pScanBuffer1 + 8192 ); /* Fill 12 Bits B Map */ dacP98DownloadMapTable( ps, ps->pScanBuffer1 ); } /** Find the most ideal intensity for each color (RGB) */ static void dacP98AdjustRGBGain( pScanData ps ) { int bCorrectTimes; DBG( DBG_LOW, "dacP98AdjustRGBGain()\n" ); ps->OpenScanPath( ps ); dacP98SetInitialGainRAM( ps ); /* set shading ram and read out data to */ ps->CloseScanPath( ps ); ps->bRedGainIndex = 0x02; ps->bGreenGainIndex = 0x02; ps->bBlueGainIndex = 0x02; for (bCorrectTimes = 10; bCorrectTimes; bCorrectTimes-- ) { dacP98SetRGBGainRegister( ps ); /* shading the most brightness &*/ ps->PauseColorMotorRunStates( ps ); /* stop scan states */ IOReadOneShadingLine( ps, ps->pScanBuffer1, 2560UL ); dacP98AdjustGain( ps ); } dacP98SetRGBGainRegister( ps ); /* shading the most brightness & */ ps->PauseColorMotorRunStates( ps ); /* stop scan states */ IOReadOneShadingLine( ps, ps->pScanBuffer1, 2560UL ); dacP98CheckLastGain( ps ); DacP98FillGainOutDirectPort( ps ); } /** */ static void dacP98SetAdjustShadingRegister( pScanData ps ) { DBG( DBG_LOW, "dacP98SetAdjustShadingRegister()\n" ); IOCmdRegisterToScanner( ps, ps->RegModeControl, _ModeIdle ); ps->AsicReg.RD_ScanControl = _SCAN_12BITMODE + _SCAN_1ST_AVERAGE; IOSelectLampSource( ps ); IOCmdRegisterToScanner( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_Motor0Control = _MotorOn + _MotorHEightStep + _MotorDirForward; ps->AsicReg.RD_XStepTime = ps->bSpeed1; ps->AsicReg.RD_ModelControl = _LED_ACTIVITY + _LED_CONTROL; if (ps->bSetScanModeFlag & _ScanMode_AverageOut) { ps->AsicReg.RD_Dpi = 300; ps->AsicReg.RD_Pixels = 2700; ps->AsicReg.RD_ModelControl += _ModelDpi300; } else { ps->AsicReg.RD_Dpi = 600; ps->AsicReg.RD_Pixels = 5400; ps->AsicReg.RD_ModelControl += _ModelDpi600; } ps->AsicReg.RD_Origin = 4; IOPutOnAllRegisters( ps ); } /** */ static void dacP98ReadShadingScanLine( pScanData ps ) { TimerDef timer; MiscStartTimer( &timer, _SECOND ); ps->Scan.bFifoSelect = ps->RegGFifoOffset; while((IOReadFifoLength( ps ) < dwReadyLen) && !MiscCheckTimer(&timer)) { _DO_UDELAY( 1 ); } IOReadColorData( ps, ps->pScanBuffer2, ps->dwShadingLen ); } /** */ static void dacP98GainResize( pUShort pValue, UShort wResize) { DataType Data; Byte bTemp; Data.dwValue = ((ULong) *pValue) * (ULong) wResize / 100; if (0x1000 <= Data.dwValue) Data.wValue = 0xfff; Data.wValue *= 16; bTemp = Data.wOverlap.b1st; Data.wOverlap.b1st = Data.wOverlap.b2nd; Data.wOverlap.b2nd = bTemp; *pValue = Data.wValue; } /** */ static void dacP98SortHilightShadow( pScanData ps, pUShort pwData, ULong dwHilightOff, ULong dwShadowOff ) { ULong dwLines, dwPixels; UShort wVCmp, wTmp; pUShort pw; for (dwPixels = 0; dwPixels < (ps->dwShadingPixels - 4); dwPixels++) { pw = (pUShort)ps->Shade.pHilight + dwHilightOff + dwPixels; wVCmp = pwData[dwPixels] & 0xfffU; for (dwLines = _DEF_BRIGHTEST_SKIP; dwLines--; pw += 5400UL) { if (wVCmp > *pw) { wTmp = wVCmp; wVCmp = *pw; *pw = wTmp; } } } for (dwPixels = 0; dwPixels < (ps->dwShadingPixels - 4); dwPixels++) { pw = ps->pwShadow + dwShadowOff + dwPixels; wVCmp = pwData [dwPixels] & 0xfffU; for (dwLines = _DEF_DARKEST_SKIP; dwLines--; pw += 5400UL) { if (wVCmp < *pw) { wTmp = wVCmp; wVCmp = *pw; *pw = wTmp; } } } } /** */ static void dacP98WriteBackToShadingRAM( pScanData ps ) { ULong dw; pUShort pBuffer = (pUShort)ps->pScanBuffer2; DBG( DBG_LOW, "dacP98WriteBackToShadingRAM()\n" ); if (ps->DataInf.wPhyDataType >= COLOR_TRUE24) { for (dw = 0; dw < 5400; dw++) { *pBuffer = ((pUShort)ps->pScanBuffer1)[dw] - ps->Shade.DarkOffset.Colors.Red; dacP98GainResize( pBuffer, ps->Shade.pCcdDac->GainResize.Colors.Red ); pBuffer ++; *pBuffer = ((pUShort)ps->pScanBuffer1)[dw + 5400] - ps->Shade.DarkOffset.Colors.Green; dacP98GainResize( pBuffer, ps->Shade.pCcdDac->GainResize.Colors.Green ); pBuffer ++; *pBuffer = ((pUShort)ps->pScanBuffer1)[dw + 5400 * 2] - ps->Shade.DarkOffset.Colors.Blue; dacP98GainResize( pBuffer, ps->Shade.pCcdDac->GainResize.Colors.Blue ); pBuffer ++; } } else { for (dw = 0; dw < 5400; dw++) { DataType Data; Byte bTemp; *pBuffer = ((pUShort)ps->pScanBuffer1)[dw + 5400] - ps->Shade.DarkOffset.Colors.Green; Data.wValue = (*pBuffer) * 16; bTemp = Data.wOverlap.b1st; Data.wOverlap.b1st = Data.wOverlap.b2nd; Data.wOverlap.b2nd = bTemp; *pBuffer = Data.wValue; pBuffer++; } } dacP98DownloadShadingTable( ps, ps->pScanBuffer2, (5400 * 2 * 3)); } /** */ static void dacP98ShadingRunLoop( pScanData ps ) { int i; DataPointer p; p.pb = ps->a_nbNewAdrPointer; switch( ps->IO.portMode ) { case _PORT_SPP: case _PORT_BIDI: *p.pw++ = 0; for (i = 0; i < 7; i++) *p.pdw++ = 0x00800700; *p.pw = 0; break; default: *p.pb++ = 0; for (i = 0; i < 15; i++) *p.pw++ = 0xf888; *p.pb = 0; } IOSetToMotorRegister( ps ); } /** */ static void dacP98Adjust12BitShading( pScanData ps ) { DataPointer pd, pt; ULong dw, dw1, dwLoop; DBG( DBG_LOW, "dacP98Adjust12BitShading()\n" ); memset( ps->pScanBuffer1, 0, (5400 * 4 * 3)); if( ps->Shade.pHilight && (_Shading_32Times == ps->bShadingTimeFlag)) { memset( ps->Shade.pHilight, 0, (ps->dwHilight * 2UL)); for (dw = 0; dw < ps->dwShadow; dw++) ps->pwShadow[dw] = 0xfff; } /* * in the original code this function does not exist ! * (of course the code behind the function does ;-) */ dacP98SetAdjustShadingRegister( ps ); dacP98ShadingRunLoop( ps ); _DODELAY( 24 ); if ((ps->DataInf.dwScanFlag & SCANDEF_TPA ) || (_Shading_32Times == ps->bShadingTimeFlag)) { dwLoop = 32; } else { if (_Shading_16Times == ps->bShadingTimeFlag) { dwLoop = 16; } else { dwLoop = 4; } } for (dw1 = 0; dw1 < dwLoop; dw1++) { ps->Scan.bFifoSelect = ps->RegGFifoOffset; dacP98ReadShadingScanLine( ps ); if((_Shading_32Times == ps->bShadingTimeFlag) && ps->Shade.pHilight ) { dacP98SortHilightShadow( ps, (pUShort)ps->pScanBuffer2, 0, 0 ); dacP98SortHilightShadow( ps, (pUShort)ps->pScanBuffer2 + ps->dwShadingPixels, ps->dwHilightCh, ps->dwShadowCh ); dacP98SortHilightShadow( ps, (pUShort)ps->pScanBuffer2 + ps->dwShadingPixels * 2, ps->dwHilightCh * 2, ps->dwShadowCh * 2); } /* SumAdd12BitShadingR */ pd.pw = (pUShort)ps->pScanBuffer2; pt.pdw = (pULong)(ps->pScanBuffer1 + dwADCPipeLine); for (dw = 5400 - 4; dw; dw--, pd.pw++, pt.pdw++) *pt.pdw += (ULong)(*pd.pw & 0x0fff); /* SumAdd10BitShadingG */ if( ps->bSetScanModeFlag & _ScanMode_AverageOut ) pd.pw = (pUShort)(ps->pScanBuffer2 + 2700 * 2); else pd.pw = (pUShort)(ps->pScanBuffer2 + 5400 * 2); pt.pdw = (pULong)(ps->pScanBuffer1 + 5400 * 4 + dwADCPipeLine); for (dw = 5400 - 4; dw; dw--, pd.pw++, pt.pdw++) *pt.pdw += (ULong)(*pd.pw & 0x0fff); /* SumAdd12BitShadingB */ if( ps->bSetScanModeFlag & _ScanMode_AverageOut ) pd.pw = (pUShort)(ps->pScanBuffer2 + 2700 * 4); else pd.pw = (pUShort)(ps->pScanBuffer2 + 5400 * 4); pt.pdw = (pULong)(ps->pScanBuffer1 + 5400 * 8 + dwADCPipeLine); for (dw = 5400 - 4; dw; dw--, pd.pw++, pt.pdw++) *pt.pdw += (ULong)(*pd.pw * 94 / 100 & 0x0fff); /* one line */ if (IOReadFifoLength( ps ) <= 2500) IORegisterDirectToScanner( ps, ps->RegRefreshScanState ); } TPAP98001AverageShadingData( ps ); ps->OpenScanPath( ps ); dacP98WriteBackToShadingRAM( ps ); ps->CloseScanPath( ps ); } /** */ static Bool dacP98WaitForShading( pScanData ps ) { Byte oldLineControl; DBG( DBG_LOW, "dacP98WaitForShading()\n" ); /* * before getting the shading data, (re)init the ASIC */ ps->InitialSetCurrentSpeed( ps ); ps->ReInitAsic( ps, _TRUE ); IOCmdRegisterToScanner( ps, ps->RegLineControl, ps->AsicReg.RD_LineControl ); ps->Shade.DarkOffset.Colors.Red = 0; ps->Shade.DarkOffset.Colors.Green = 0; ps->Shade.DarkOffset.Colors.Blue = 0; /* * according to the scan mode, switch on the lamp */ IOSelectLampSource( ps ); IOCmdRegisterToScanner(ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl); if( ps->bSetScanModeFlag & _ScanMode_AverageOut ) { ps->AsicReg.RD_ModelControl = _LED_CONTROL + _ModelDpi300; } else { ps->AsicReg.RD_ModelControl = _LED_CONTROL + _ModelDpi600; } IOCmdRegisterToScanner( ps, ps->RegModelControl, ps->AsicReg.RD_ModelControl ); IOCmdRegisterToScanner( ps, ps->RegModeControl, _ModeScan); oldLineControl = ps->AsicReg.RD_LineControl; IOSetXStepLineScanTime( ps, _DEFAULT_LINESCANTIME ); /* set line control */ IOCmdRegisterToScanner( ps, ps->RegLineControl, ps->AsicReg.RD_LineControl ); /* Wait for Sensor to position */ if( !ps->GotoShadingPosition( ps )) return _FALSE; ps->AsicReg.RD_LineControl = oldLineControl; IOCmdRegisterToScanner( ps, ps->RegLineControl, ps->AsicReg.RD_LineControl ); dwADCPipeLine = 4 * 4; if( ps->bSetScanModeFlag & _ScanMode_AverageOut ) { dwReadyLen = 2500; ps->dwShadingLen = 2700 * 2; ps->dwShadingPixels = 2700; } else { dwReadyLen = 5000; ps->dwShadingLen = 5400 * 2; ps->dwShadingPixels = 5400; } dacP98AdjustRGBGain ( ps ); DacP98AdjustDark ( ps ); dacP98Adjust12BitShading( ps ); ps->OpenScanPath( ps ); DacP98FillShadingDarkToShadingRegister( ps ); if ( COLOR_BW != ps->DataInf.wPhyDataType ) dacP98DownloadMapTable( ps, ps->a_bMapTable ); ps->CloseScanPath( ps ); return _TRUE; } /** Set RAM bank and size, then write the data to it */ static void dacP96FillWhole4kRAM( pScanData ps, pUChar pBuf ) { ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegMemAccessControl, ps->Asic96Reg.RD_MemAccessControl ); ps->AsicReg.RD_ModeControl = _ModeProgram; IODataToRegister( ps, ps->RegModeControl, ps->AsicReg.RD_ModeControl ); IOMoveDataToScanner( ps, pBuf, ps->ShadingBankSize ); ps->AsicReg.RD_ModeControl = _ModeScan; IODataToRegister( ps, ps->RegModeControl, ps->AsicReg.RD_ModeControl ); ps->CloseScanPath( ps ); } /** */ static void dacP96FillChannelDarkOffset( pScanData ps ) { ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegRedChDarkOffset, ps->Asic96Reg.RD_RedChDarkOff ); IODataToRegister( ps, ps->RegGreenChDarkOffset, ps->Asic96Reg.RD_GreenChDarkOff ); IODataToRegister( ps, ps->RegBlueChDarkOffset, ps->Asic96Reg.RD_BlueChDarkOff ); ps->CloseScanPath( ps ); } /** */ static void dacP96FillEvenOddControl( pScanData ps ) { ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegRedChEvenOffset, ps->Asic96Reg.RD_RedChEvenOff ); IODataToRegister( ps, ps->RegGreenChEvenOffset, ps->Asic96Reg.RD_GreenChEvenOff ); IODataToRegister( ps, ps->RegBlueChEvenOffset, ps->Asic96Reg.RD_BlueChEvenOff ); IODataToRegister( ps, ps->RegRedChOddOffset, ps->Asic96Reg.RD_RedChOddOff ); IODataToRegister( ps, ps->RegGreenChOddOffset, ps->Asic96Reg.RD_GreenChOddOff ); IODataToRegister( ps, ps->RegBlueChOddOffset, ps->Asic96Reg.RD_BlueChOddOff ); ps->CloseScanPath( ps ); } /** Used for capture data to pScanData->pPrescan16. * Used to replace: * 1) ReadFBKScanLine (3 * 1024, 5) * 2) ReadOneScanLine (3 * 2560, 11) * 4) ReadShadingScanLine (3 * 1280, 6) */ static void dacP96ReadDataWithinOneSecond( pScanData ps, ULong dwLen, Byte bBlks ) { TimerDef timer; MiscStartTimer( &timer, _SECOND ); while((IODataRegisterFromScanner( ps, ps->RegFifoOffset) < bBlks) && !MiscCheckTimer(&timer)); IOReadScannerImageData( ps, ps->pPrescan16, dwLen ); } /** */ static void dacP96GetEvenOddOffset( pUChar pb, pWordVal pwv ) { ULong dw; UShort we, wo; for (dw = 8, we = wo = 0; dw; dw-- ) { we += *pb++; wo += *pb++; } pwv->b1st = (Byte)(we >> 3); pwv->b2nd = (Byte)(wo >> 3); } /** */ static void dacP96SumAverageShading( pScanData ps, pUChar pDest, pUChar pSrce ) { ULong dw; UShort wLeft[6]; UShort wSumL, wSumR; pSrce += ps->Offset70 + ps->Device.DataOriginX; pDest += ps->Offset70 + ps->Device.DataOriginX; wLeft[0] = wLeft[1] = wLeft[2] = wLeft[3] = wLeft[4] = wLeft[5] = (UShort)*pSrce; wSumL = wLeft[0] * 6; wSumR = (UShort)pSrce[1] + pSrce[2] + pSrce[3] + pSrce[4] + pSrce[5] + pSrce[6]; /* for (dw = 2772; dw; dw--, pSrce++, pDest++) */ for (dw = ps->BufferSizePerModel - 6; dw; dw--, pSrce++, pDest++) { *pDest = (Byte)(((UShort)*pSrce * 4 + wSumL + wSumR) / 16); wSumL = wSumL - wLeft [0] + (UShort)*pSrce; wLeft[0] = wLeft[1]; wLeft[1] = wLeft[2]; wLeft[2] = wLeft[3]; wLeft[3] = wLeft[4]; wLeft[4] = wLeft[5]; wLeft[5] = (UShort)*pSrce; wSumR = wSumR - (UShort) *(pSrce + 1) + (UShort) *(pSrce + 7); } } /** */ static void dacP96WriteLinearGamma( pScanData ps, pUChar pBuf, ULong dwEntries, Byte bBank ) { ULong dw; pULong pdw = (pULong)(pBuf + ps->ShadingBufferSize); for (dw = 0; dwEntries; pdw++, dwEntries--, dw += 0x01010101) *pdw = dw; ps->Asic96Reg.RD_MemAccessControl = bBank; dacP96FillWhole4kRAM( ps, pBuf ); } /** */ static void dacP96FillChannelShadingOffset( pScanData ps ) { ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegRedChShadingOffset, ps->Asic96Reg.u28.RD_RedChShadingOff); IODataToRegister( ps, ps->RegGreenChShadingOffset, ps->Asic96Reg.u29.RD_GreenChShadingOff); IODataToRegister( ps, ps->RegBlueChShadingOffset, ps->Asic96Reg.RD_BlueChShadingOff); ps->CloseScanPath( ps ); } /** */ static void dacP96GetHilightShadow( pScanData ps, pUChar pBuf, pUChar pChOff, pUChar pHigh ) { ULong dw; /* GetShadingImageExtent (ps) */ if (ps->DataInf.wAppDataType < COLOR_256GRAY) dw = (ULong)(ps->DataInf.crImage.cx & 0xfff8); else dw = (ULong)ps->DataInf.crImage.cx; for( pBuf += ps->DataInf.crImage.x, *pChOff = 0xff, *pHigh = 0; dw; dw--, pBuf++ ) { if (*pChOff < *pBuf) { if (*pHigh < *pBuf) *pHigh = *pBuf; /* brightest */ } else *pChOff = *pBuf; /* darkest */ } } /** */ static void dacP96ReadColorShadingLine( pScanData ps ) { Byte b2ndDiscard, b3rdDiscard, b1stReadLines, b2ndReadLines; Byte b3rdReadLines; ULong dw; DataType Data; /* ClearScanBuffer1 (ps) */ /* buffer to keep sum of data */ memset( ps->pScanBuffer1, 0, ps->BufferForDataRead1 ); b2ndDiscard = ps->b2ndLinesOffset; b3rdDiscard = ps->b1stLinesOffset; b1stReadLines = b2ndReadLines = b3rdReadLines = 8; while( _TRUE ) { /* ReadShadingScanLine(ps) */ dacP96ReadDataWithinOneSecond( ps, ps->ShadingScanLineLen, ps->ShadingScanLineBlks ); if (b1stReadLines) { b1stReadLines--; /* SumAdd10BitShadingR */ for (dw = 0; dw < ps->BufferSizeBase; dw++) ((pUShort)ps->pScanBuffer1)[dw] += (UShort)ps->pPrescan16 [dw]; } if (!b2ndDiscard) { if (b2ndReadLines) { b2ndReadLines--; /* SumAdd10BitShadingG */ for (dw = ps->BufferSizeBase;dw < (ULong)ps->BufferSizeBase * 2;dw++) { ((pUShort)ps->pScanBuffer1)[dw] += (UShort)ps->pPrescan16[dw]; } } } else b2ndDiscard--; if (!b3rdDiscard) { if (b3rdReadLines) { b3rdReadLines--; /* SumAdd10BitShadingB */ for (dw = ps->BufferSizeBase * 2; dw < (ULong)ps->BufferSizeBase * 3; dw++) { ((pUShort)ps->pScanBuffer1)[dw] += (UShort)ps->pPrescan16[dw]; } } else break; } else b3rdDiscard--; IORegisterDirectToScanner( ps, ps->RegRefreshScanState ); } for (dw = 0; dw < (ULong)ps->BufferSizeBase * 3; dw++) { Data.wOverlap.b1st = Data.wOverlap.b2nd = (Byte)(((pUShort)ps->pScanBuffer1)[dw] / 8); ((pUShort)ps->pPrescan16)[dw] = Data.wValue; } } /** */ static void dacP96SetShadingGainProc( pScanData ps, Byte bHigh, ULong dwCh ) { Byte bDark, bGain, bGainX2, bGainX4, bMask; pUChar pbChDark, pbSrce, pbDest; ULong dw; pbChDark = NULL, pbSrce = NULL, pbDest = NULL; bDark = 0, bGain = 0, bGainX2 = 0, bGainX4 = 0, bMask = 0; switch( dwCh ) { case 0: /* red */ pbChDark = &ps->Asic96Reg.u28.RD_RedChShadingOff; pbSrce = ps->pPrescan16; pbDest = ps->pScanBuffer1 + ps->Offset70 + ps->Device.DataOriginX; bGainX2 = 1; bGainX4 = 3; bMask = 0x3c; break; case 1: /* green */ pbChDark = &ps->Asic96Reg.u29.RD_GreenChShadingOff; pbSrce = ps->pPrescan16 + ps->BufferSizePerModel; pbDest = ps->pScanBuffer1 + ps->Offset70 + ps->ShadingBankSize + ps->Device.DataOriginX; bGainX2 = 4; bGainX4 = 0x0c; bMask = 0x33; break; case 2: pbChDark = &ps->Asic96Reg.RD_BlueChShadingOff; pbSrce = ps->pPrescan16 + ps->BufferSizePerModel * 2; pbDest = ps->pScanBuffer1 + ps->Offset70 + ps->ShadingBankSize * 2 + ps->Device.DataOriginX; bGainX2 = 0x10; bGainX4 = 0x30; bMask = 0x0f; } bDark = *pbChDark; if ((bHigh -= bDark) > 60U) { /* Hilight - Shadow > 60, Quality not so good */ bGain = bGainX2; /* Gain x 2 */ if (bHigh > 120U) bGain = bGainX4; /* Poor quality, Gain x 4 */ } else bGain = 0; ps->Asic96Reg.RD_ShadingCorrectCtrl &= bMask; ps->Asic96Reg.RD_ShadingCorrectCtrl |= bGain; if (!bGain) { /* GammaGain1 (ps) */ for (dw = ps->BufferSizePerModel; dw; dw--, pbSrce++, pbDest++) if (*pbSrce > bDark) *pbDest = (*pbSrce - bDark) * 4; else *pbDest = 0; } else if (bGain == bGainX2) { /* GammaGain2 */ for (dw = ps->BufferSizePerModel; dw; dw--, pbSrce++, pbDest++) if (*pbSrce > bDark) *pbDest = (*pbSrce - bDark) * 2; else *pbDest = 0; } else { /* GammaGain4 (ps) */ memcpy( pbDest, pbSrce, ps->BufferSizePerModel ); *pbChDark = 0; } } /** */ static void dacP96FillShadingAndGammaTable( pScanData ps ) { ps->Asic96Reg.RD_MemAccessControl = ps->ShadingBankRed; /* R */ dacP96FillWhole4kRAM( ps, ps->pPrescan16 ); ps->Asic96Reg.RD_MemAccessControl = ps->ShadingBankGreen; /* G */ dacP96FillWhole4kRAM( ps, ps->pPrescan16 ); ps->Asic96Reg.RD_MemAccessControl = ps->ShadingBankBlue; /* B */ dacP96FillWhole4kRAM( ps, ps->pPrescan16 ); } /** */ static void dacP96SetInitialGainRAM( pScanData ps ) { ULong dw, dw1; pULong pdw = (pULong)(ps->pPrescan16 + ps->ShadingBufferSize); memset( ps->pPrescan16, 0xff, ps->ShadingBufferSize ); for (dw = 256, dw1 = 0; dw; dw--, dw1 += 0x01010101, pdw++) *pdw = dw1; dacP96FillShadingAndGammaTable( ps ); } /** */ static void dacP96Adjust10BitShading( pScanData ps ) { pULong pdw; ULong dw; Byte bRedHigh, bGreenHigh, bBlueHigh; /* ShadingMotorRunLoop(ps) * set scan states as: * 40h, 00, 00, 00, 40h, 01, 03, 02, ... (repeat) * so, read a R/G/B line every 2 steps */ pdw = (pULong)ps->a_nbNewAdrPointer; for (dw = 0; dw < 4; dw++) { *pdw++ = 0x40; *pdw++ = 0x02030140; } dacP96SetInitialGainRAM( ps); /* initiates the shading buffers and maps */ /* SetAdjustShadingRegister(ps) */ /* Prepare Physical/2 dpi, 8.5" scanning condition for reading the shading area */ ps->AsicReg.RD_ScanControl = ps->bLampOn | _SCAN_BYTEMODE; ps->Asic96Reg.RD_MotorControl = ps->IgnorePF | ps->MotorOn | _MotorDirForward; ps->AsicReg.RD_ModelControl = ps->Device.ModelCtrl | _ModelWhiteIs0; ps->AsicReg.RD_Dpi = ps->PhysicalDpi / 2; ps->AsicReg.RD_Origin = (UShort)(ps->Offset70 + ps->Device.DataOriginX); ps->AsicReg.RD_Pixels = ps->BufferSizeBase; IOPutOnAllRegisters( ps ); ps->Asic96Reg.RD_ShadingCorrectCtrl = _ShadingRCorrectX4|_ShadingGCorrectX4| _ShadingBCorrectX4; IOCmdRegisterToScanner( ps, ps->RegShadingCorrectCtrl, ps->Asic96Reg.RD_ShadingCorrectCtrl ); /* Read shaded data and do average */ dacP96ReadColorShadingLine( ps ); /* ExpandAndAverage (ps) ------------------------------------------------*/ /* for (dw = 0; dw < 1280 * 3; dw++) { Data.wOverlap.b1st = Data.wOverlap.b2nd = (Byte)(((pUShort) ps->pScanBuffer1)[dw] / 8); ((pULong) ps->pPrescan16)[dw] = Data.wValue; } */ /* CalculateShadingOffset (ps); */ dacP96GetHilightShadow( ps, ps->pPrescan16, &ps->Asic96Reg.u28.RD_RedChShadingOff, &bRedHigh ); dacP96GetHilightShadow( ps, ps->pPrescan16 + ps->BufferSizePerModel, &ps->Asic96Reg.u29.RD_GreenChShadingOff, &bGreenHigh ); dacP96GetHilightShadow( ps, ps->pPrescan16 + ps->BufferSizePerModel * 2, &ps->Asic96Reg.RD_BlueChShadingOff, &bBlueHigh ); /* SubTheImageDataBase (ps) */ dacP96SetShadingGainProc( ps, bRedHigh, 0 ); /* red */ dacP96SetShadingGainProc( ps, bGreenHigh, 1 ); /* green */ dacP96SetShadingGainProc( ps, bBlueHigh, 2 ); /* blue */ dacP96FillChannelShadingOffset( ps ); IOCmdRegisterToScanner( ps, ps->RegShadingCorrectCtrl, ps->Asic96Reg.RD_ShadingCorrectCtrl ); dacP96SumAverageShading( ps, ps->pPrescan16, ps->pScanBuffer1 ); dacP96SumAverageShading( ps, ps->pPrescan16 + ps->ShadingBankSize, ps->pScanBuffer1 + ps->ShadingBankSize ); dacP96SumAverageShading( ps, ps->pPrescan16 + ps->ShadingBankSize * 2, ps->pScanBuffer1 + ps->ShadingBankSize * 2 ); /* --------------------------------------------------------------------- */ /* PrewriteBackToGammaShadingRAM( ps) */ dacP96WriteLinearGamma( ps, ps->pPrescan16, 256, ps->ShadingBankRed ); dacP96WriteLinearGamma( ps, ps->pPrescan16 + ps->ShadingBankSize, 256, ps->ShadingBankGreen ); dacP96WriteLinearGamma( ps, ps->pPrescan16 + ps->ShadingBankSize * 2, 256, ps->ShadingBankBlue ); } /** */ static Bool dacP96003WaitForShading( pScanData ps ) { int bCorrectTimes; DataPointer p; ULong dw; UShort w; WordVal wv; pUChar pbReg[3]; Byte b[3]; DBG( DBG_LOW, "dacP96003WaitForShading()\n" ); /* TurnOnLamp () */ ps->AsicReg.RD_ScanControl |= ps->bLampOn; IOCmdRegisterToScanner(ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl); ps->Asic96Reg.RD_LedControl = _LedActControl | _LedMotorActEnable; IOCmdRegisterToScanner(ps, ps->RegLedControl, ps->Asic96Reg.RD_LedControl); if ( ps->GotoShadingPosition( ps )) { /* AdjustRGBGain () =================================================*/ ps->Asic96Reg.RD_RedGainOut = ps->Asic96Reg.RD_GreenGainOut = ps->Asic96Reg.RD_BlueGainOut = 8; ps->Asic96Reg.u26.RD_ModelControl2 = _Model2DirectOutPort; IOCmdRegisterToScanner(ps, ps->RegModelControl2, _Model2DirectOutPort); for ( bCorrectTimes = 4; bCorrectTimes >= 1; bCorrectTimes-- ) { ps->PauseColorMotorRunStates( ps ); /* SetRGBGainRegister () ----------------------------------------*/ ps->AsicReg.RD_ScanControl = ps->bLampOn | _SCAN_BYTEMODE; dacP96SetInitialGainRAM( ps ); /* SetInitialGainRegister () ++++++++++++++++++++++++++++++++++++*/ ps->Asic96Reg.u28.RD_RedChShadingOff = ps->Asic96Reg.u29.RD_GreenChShadingOff = ps->Asic96Reg.RD_BlueChShadingOff = ps->Asic96Reg.RD_RedChDarkOff = ps->Asic96Reg.RD_GreenChDarkOff = ps->Asic96Reg.RD_BlueChDarkOff = ps->Asic96Reg.RD_RedChEvenOff = ps->Asic96Reg.RD_GreenChEvenOff = ps->Asic96Reg.RD_BlueChEvenOff = ps->Asic96Reg.RD_RedChOddOff = ps->Asic96Reg.RD_GreenChOddOff = ps->Asic96Reg.RD_BlueChOddOff = 0; ps->Asic96Reg.RD_ShadingCorrectCtrl = _ShadingRCorrectX4 | _ShadingGCorrectX4 | _ShadingBCorrectX4; dacP96FillChannelShadingOffset( ps ); dacP96FillChannelDarkOffset( ps ); dacP96FillEvenOddControl( ps ); /* FillGainOutDirectPort (); */ ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegRedGainOutDirect, ps->Asic96Reg.RD_RedGainOut ); IODataToRegister( ps, ps->RegGreenGainOutDirect, ps->Asic96Reg.RD_GreenGainOut ); IODataToRegister( ps, ps->RegBlueGainOutDirect, ps->Asic96Reg.RD_BlueGainOut ); /* FillGainInitialRestRegister (); */ IODataToRegister( ps, ps->RegModelControl2, ps->Asic96Reg.u26.RD_ModelControl2 ); IODataToRegister( ps, ps->RegThresholdGapControl, ps->AsicReg.RD_ThresholdGapCtrl ); IODataToRegister( ps, ps->RegLedControl, ps->Asic96Reg.RD_LedControl ); IODataToRegister( ps, ps->RegShadingCorrectCtrl, ps->Asic96Reg.RD_ShadingCorrectCtrl ); ps->CloseScanPath( ps ); ps->Asic96Reg.RD_MotorControl = 0; IOCmdRegisterToScanner( ps, ps->RegMotorControl, 0 ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_ScanControl = ps->bLampOn | _SCAN_BYTEMODE; ps->Asic96Reg.RD_MotorControl = (ps->IgnorePF | ps->MotorOn | _MotorDirForward); ps->AsicReg.RD_Origin = 142; ps->AsicReg.RD_ModelControl = ps->Device.ModelCtrl | _ModelWhiteIs0; ps->AsicReg.RD_Dpi = ps->PhysicalDpi; ps->AsicReg.RD_Pixels = ps->BufferSizePerModel; IOPutOnAllRegisters( ps ); /*---------------------------------------------------------------*/ /* ReadOneScanLine (); */ dacP96ReadDataWithinOneSecond( ps, ps->OneScanLineLen, 11 ); /* AdjustGain () */ /* FindTheMaxGain (), AdjustGainOutData (); */ pbReg[0] = &ps->Asic96Reg.RD_RedGainOut; pbReg[1] = &ps->Asic96Reg.RD_GreenGainOut; pbReg[2] = &ps->Asic96Reg.RD_BlueGainOut; for (w = 0, p.pb = ps->pPrescan16; w < 3; w++) { /* CHANGE: org was: for (dw = 2560, b[w] = 0; dw; dw--, p.pb++) { */ for (dw = (ps->OneScanLineLen/3), b[w] = 0; dw; dw--, p.pb++) { if (b[w] < *p.pb) b[w] = *p.pb; } if (b[w] < _GAIN_LOW) *(pbReg[w]) += a_bCorrectTimesTable[bCorrectTimes - 1]; else if (b[w] > _GAIN_P96_HIGH) *(pbReg[w]) -= a_bCorrectTimesTable[bCorrectTimes - 1]; } } /*===================================================================*/ /* SonyFBK ()/ToshibaFBK ()====================================*/ /*FillRGBDarkLevel0Table (); */ memset( ps->pPrescan16, 0xff, ps->ShadingBankSize ); for( dw = 0, p.pb = ps->pPrescan16 + ps->ShadingBufferSize; dw <=255; dw++, p.pb++ ) { *p.pb = (Byte) dw; } dacP96FillShadingAndGammaTable( ps ); ps->PauseColorMotorRunStates( ps ); /* SetReadFBKRegister () */ ps->Asic96Reg.RD_MotorControl = 0; IOCmdRegisterToScanner( ps, ps->RegMotorControl, 0 ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_ScanControl = ps->bLampOn | _SCAN_BYTEMODE; ps->Asic96Reg.RD_MotorControl = ps->IgnorePF | ps->MotorOn | _MotorDirForward; ps->AsicReg.RD_Origin = 22; ps->AsicReg.RD_ModelControl = ps->Device.ModelCtrl | _ModelWhiteIs0; ps->AsicReg.RD_Dpi = ps->PhysicalDpi; ps->AsicReg.RD_Pixels = ps->FBKScanLineLenBase; IOPutOnAllRegisters( ps ); /* ReadFBKScanLine () */ dacP96ReadDataWithinOneSecond( ps, ps->FBKScanLineLen, ps->FBKScanLineBlks ); /*===================================================================*/ if ( ps->fSonyCCD ) { /* FillChannelDarkLevelControl (); */ for ( p.pb = ps->pPrescan16 + 32, w = 0, dw = 16; dw; dw--, p.pb++) { w += (UShort) *p.pb; } ps->Asic96Reg.RD_RedChDarkOff = (Byte)(w / 16); for ( p.pb = ps->pPrescan16 + 32 + ps->FBKScanLineLenBase, w = 0, dw = 16; dw; dw--, p.pb++ ) { w += (UShort)*p.pb; } ps->Asic96Reg.RD_GreenChDarkOff = (Byte)(w / 16); for ( p.pb = ps->pPrescan16 + 32 + ps->FBKScanLineLenBase * 2, w = 0, dw = 16; dw; dw--, p.pb++) { w += (UShort)*p.pb; } ps->Asic96Reg.RD_BlueChDarkOff = (Byte)(w / 16); dacP96FillChannelDarkOffset( ps ); } else { /* FillToshibaDarkLevelControl (); */ dacP96GetEvenOddOffset( ps->pPrescan16 + 32, &wv ); ps->Asic96Reg.RD_RedChEvenOff = wv.b1st; ps->Asic96Reg.RD_RedChOddOff = wv.b2nd; dacP96GetEvenOddOffset( ps->pPrescan16 + 32 + ps->FBKScanLineLenBase, &wv ); ps->Asic96Reg.RD_GreenChEvenOff = wv.b1st; ps->Asic96Reg.RD_GreenChOddOff = wv.b2nd; dacP96GetEvenOddOffset( ps->pPrescan16 + 32 + ps->FBKScanLineLenBase * 2, &wv ); ps->Asic96Reg.RD_BlueChEvenOff = wv.b1st; ps->Asic96Reg.RD_BlueChOddOff = wv.b2nd; dacP96FillEvenOddControl( ps ); } /* SetInitialGainRAM (); */ dacP96Adjust10BitShading( ps ); return _TRUE; } return _FALSE; } /** */ static void dacP96001ToSetShadingAddress( pScanData ps, pUChar pData ) { ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegMemAccessControl, ps->Asic96Reg.RD_MemAccessControl); ps->AsicReg.RD_ModeControl = _ModeProgram; IODataToRegister( ps, ps->RegModeControl, _ModeProgram ); ps->Asic96Reg.RD_MotorControl = ps->FullStep | _MotorDirForward; IODataToRegister( ps, ps->RegMotorControl, ps->Asic96Reg.RD_MotorControl); memset( ps->pScanBuffer1, 0, (64 + 8 + ps->Offset70)); memcpy( ps->pScanBuffer1 + 64 + 8 + ps->Offset70, pData, _BUF_SIZE_BASE_CONST * 2 ); IOMoveDataToScanner( ps, ps->pScanBuffer1, _BUF_SIZE_BASE_CONST * 2 + 64 + 8 + ps->Offset70 ); ps->AsicReg.RD_ModeControl = _ModeScan; IODataToRegister( ps, ps->RegModeControl, _ModeScan ); ps->CloseScanPath( ps ); } /** */ static void dacP96001WriteBackToColorShadingRam( pScanData ps ) { ps->Asic96Reg.RD_MemAccessControl = (_MemBankSize4k96001 | 0x3a); dacP96001ToSetShadingAddress( ps, ps->pPrescan16 ); ps->Asic96Reg.RD_MemAccessControl = (_MemBankSize4k96001 | 0x3e); dacP96001ToSetShadingAddress( ps, ps->pPrescan16 + _BUF_SIZE_BASE_CONST*2); ps->Asic96Reg.RD_MemAccessControl = (_MemBankSize4k96001 | 0x3c); dacP96001ToSetShadingAddress( ps, ps->pPrescan16 + _BUF_SIZE_BASE_CONST*4); } /** */ static void dacP96001ModifyShadingColor( pByte pData, Byte bMul ) { UShort w; ULong dw; for ( dw = 0; dw < _BUF_SIZE_BASE_CONST * 2; dw++ ) { w = (UShort)(Byte)(~pData[dw]) * bMul / 100U; if (w >= 255U) pData[dw] = 0; else pData[dw] = (Byte)~w; } } /** */ static Byte dacP96001FBKReading( pScanData ps, Byte bValue, Byte bReg, pByte pbSave, Bool bFBKModify ) { TimerDef timer; UShort w, wSum; Byte addrSeq[8] = { 0x40, 0x20, 0x10, 0x08, 4, 2, 1, 0 }; Byte bTemp, bFBKTemp, bFBKIndex; if( bFBKModify ) { bFBKIndex = 3; bFBKTemp = *pbSave; } else { bFBKTemp = 0x80; bFBKIndex = 0; } while( _TRUE ) { *pbSave = bFBKTemp; IOCmdRegisterToScanner( ps, bReg, bFBKTemp ); /* SetColorRunTable (BYTE) */ memset( ps->a_nbNewAdrPointer, bValue, _SCANSTATE_BYTES ); MotorSetConstantMove( ps, 0 ); /* SetReadFBK (pScanData) */ ps->Asic96Reg.RD_MotorControl = ps->FullStep | _MotorDirForward; IOCmdRegisterToScanner( ps, ps->RegMotorControl, ps->Asic96Reg.RD_MotorControl ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE | ps->bLampOn; ps->AsicReg.RD_ModelControl = (_ModelMemSize32k96001 | _ModelDpi300 | _ModelWhiteIs0 ); ps->AsicReg.RD_Dpi = 300; ps->AsicReg.RD_Origin = 22; ps->AsicReg.RD_Pixels = 1024; IOPutOnAllRegisters( ps ); ps->Asic96Reg.RD_MotorControl = (ps->FullStep | ps->MotorOn | _MotorDirForward); IOCmdRegisterToScanner( ps, ps->RegMotorControl, ps->Asic96Reg.RD_MotorControl ); MiscStartTimer( &timer, _SECOND ); while((IODataRegisterFromScanner( ps, ps->RegFifoOffset) < 1) && !MiscCheckTimer( &timer )); IOCmdRegisterToScanner( ps, ps->RegMotorControl, 0 ); IOReadScannerImageData( ps, ps->pScanBuffer1, 64 ); for( w = 26, wSum = 0; w < 42; w++) wSum += ps->pScanBuffer1[w]; wSum >>= 4; bTemp = addrSeq[bFBKIndex++]; if( bTemp ) { if( wSum < 0xfe ) bFBKTemp += bTemp; else bFBKTemp -= bTemp; } else { return bFBKTemp; } } } /** */ static Bool dacP96001WaitForShading( pScanData ps ) { Bool bFBKModify; Byte bRSave; Byte bGSave; Byte bBSave; ULong dw; pULong pdw; DBG( DBG_LOW, "dacP96001WaitForShading()\n" ); ps->AsicReg.RD_ScanControl |= ps->bLampOn; IOCmdRegisterToScanner(ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl); if ( ps->GotoShadingPosition( ps )) { _DODELAY( 250 ); /* AdjustMostWideOffset70 (pScanData) -------------------------------*/ /* FillABitGray (pScanData)*/ memset( ps->a_nbNewAdrPointer, 0, _SCANSTATE_BYTES ); ps->a_nbNewAdrPointer[8] = ps->a_nbNewAdrPointer[24] = 0x30; MotorSetConstantMove( ps, 32 ); /* SetMaxWideRegister (pScanData) */ ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE | ps->bLampOn; ps->Asic96Reg.RD_MotorControl = (ps->MotorOn | ps->IgnorePF | _MotorDirForward); ps->AsicReg.RD_ModelControl = (_ModelMemSize32k96001 | _ModelDpi300 | _ModelWhiteIs0); ps->AsicReg.RD_Dpi = 300; ps->AsicReg.RD_Origin = 64 + 8; ps->AsicReg.RD_Pixels = 2700; IOPutOnAllRegisters( ps ); IOCmdRegisterToScanner( ps, ps->RegMotorControl, ps->Asic96Reg.RD_MotorControl ); /* ReadMaxWideLine */ dacP96ReadDataWithinOneSecond( ps, 2700, 5 ); /* AdjustOffset70Proc (pScanData)------------------------------------*/ { ULong dwSum, dw, dwLeft, dwCenter; /* AverageWideBank (pScanData) */ for( dwSum = 0, dw = 0; dw < 2700; dw++ ) dwSum += (ULong)ps->pPrescan16[dw]; dwSum /= 2700UL; if( dwSum <= 0x80 ) { memcpy( ps->pScanBuffer1, ps->pPrescan16, 140 ); memcpy( ps->pScanBuffer1 + 140, ps->pPrescan16 + _BUF_SIZE_BASE_CONST * 2, 140); /* BlackOffsetCheck (pScanData) */ for( dw = dwLeft = 0; dw < 140; dw++ ) { if( ps->pScanBuffer1[dw] >= 0xe0 ) dwLeft++; else break; } /* WhiteOffsetCheck (pScanData) */ for( dw = 140, dwCenter = 0; dw < 280; dw++ ) { if( ps->pScanBuffer1[dw] < 0xe0 ) dwCenter++; else break; } if (dwLeft) { ps->Offset70 = (dwLeft + dwCenter) / 2 + 14; } else { if (dwCenter == 140) ps->Offset70 = 70; else ps->Offset70 = dwCenter / 2 + 2; } } } memset( ps->pPrescan16, 0, ps->BufferSizePerModel * 3 ); dacP96001WriteBackToColorShadingRam( ps ); /* SetFBK */ if((IODataRegisterFromScanner(ps, ps->RegReadIOBufBus) & 0x0f) == 0x0f) bFBKModify = 0; else bFBKModify = 1; dacP96001FBKReading(ps, 0x10, ps->RegRedDCAdjust, &bRSave,bFBKModify); dacP96001FBKReading(ps, 0x30, ps->RegGreenDCAdjust,&bGSave,bFBKModify); dacP96001FBKReading(ps, 0x20, ps->RegBlueDCAdjust, &bBSave,bFBKModify); ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegRedDCAdjust, (Byte)(bRSave + 2)); IODataToRegister( ps, ps->RegGreenDCAdjust, (Byte)(bGSave + 2)); IODataToRegister( ps, ps->RegBlueDCAdjust, bBSave); ps->CloseScanPath( ps ); /* Turn off and then turn on motor */ IOCmdRegisterToScanner( ps, ps->RegMotorControl, (Byte)(ps->Asic96Reg.RD_MotorControl & ~ps->MotorOn)); IOCmdRegisterToScanner( ps, ps->RegMotorControl, ps->Asic96Reg.RD_MotorControl ); /* FillABitColor (pScanData) */ pdw = (pULong)ps->a_nbNewAdrPointer; for( dw = 0; dw < 4; dw++) { *pdw++ = 0x40; *pdw++ = 0x2030140; } IOSetToMotorRegister( ps ); /* SetShadingRegister (pScanData) */ ps->Asic96Reg.RD_MotorControl = ps->FullStep | _MotorDirForward; IOCmdRegisterToScanner( ps, ps->RegMotorControl, ps->Asic96Reg.RD_MotorControl ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_LineControl = ps->TimePerLine; ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE | ps->bLampOn; ps->Asic96Reg.RD_MotorControl = ps->FullStep | _MotorDirForward; ps->AsicReg.RD_ModelControl = (_ModelMemSize32k96001 | _ModelDpi300 | _ModelWhiteIs0); ps->AsicReg.RD_Dpi = 150; ps->AsicReg.RD_Origin = (UShort)(64 + 8 + ps->Offset70); ps->AsicReg.RD_Pixels = ps->BufferSizeBase; IOPutOnAllRegisters( ps ); IOCmdRegisterToScanner( ps, ps->RegMotorControl, (Byte)(ps->MotorOn | ps->IgnorePF | _MotorDirForward)); dacP96ReadColorShadingLine( ps ); /* ModifyShadingColor (pScanData) */ dacP96001ModifyShadingColor( ps->pPrescan16, 103 ); dacP96001ModifyShadingColor( ps->pPrescan16 + _BUF_SIZE_BASE_CONST * 2 * 2, 97); dacP96001WriteBackToColorShadingRam( ps ); return _TRUE; } return _FALSE; } /** */ static void dacP98003GainOffsetToDAC( pScanData ps, Byte ch, Byte reg, Byte d ) { if( ps->Device.bDACType == _DA_SAMSUNG8531 ) { IODataToRegister( ps, ps->RegADCAddress, 0 ); IODataToRegister( ps, ps->RegADCData, ch ); IODataToRegister( ps, ps->RegADCSerialOutStr, ch); } IODataToRegister( ps, ps->RegADCAddress, reg ); IODataToRegister( ps, ps->RegADCData, d ); IODataToRegister( ps, ps->RegADCSerialOutStr, d ); } /** */ static void dacP98003AdjustRGBGain( pScanData ps ) { ULong i; Byte bHi[3]; DBG( DBG_LOW, "dacP98003AdjustRGBGain()\n" ); ps->Shade.Gain.Colors.Red = ps->Shade.Gain.Colors.Green = ps->Shade.Gain.Colors.Blue = ps->Shade.bUniGain; ps->Shade.Hilight.Colors.Red = ps->Shade.Hilight.Colors.Green = ps->Shade.Hilight.Colors.Blue = 0; ps->Shade.bGainHigh = _GAIN_P98003_HIGH; ps->Shade.bGainLow = _GAIN_P98003_LOW; ps->Shade.fStop = _FALSE; for( i = 10; i-- && !ps->Shade.fStop; ) { ps->Shade.fStop = _TRUE; /* SetRGBGainRegister () */ IODataToRegister( ps, ps->RegModeControl, _ModeIdle ); ps->AsicReg.RD_ScanControl = _SCAN_BYTEMODE; IOSelectLampSource( ps ); IODataToRegister( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl ); DacP98003FillToDAC( ps, &ps->Device.RegDACGain, &ps->Shade.Gain ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_StepControl = _MOTOR0_SCANSTATE; ps->AsicReg.RD_Motor0Control = _FORWARD_MOTOR; if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) ps->AsicReg.RD_Origin = (UShort)ps->Device.DataOriginX >> 1; else ps->AsicReg.RD_Origin = (UShort)ps->Device.DataOriginX; ps->AsicReg.RD_Dpi = 300; ps->AsicReg.RD_Pixels = 2560; /* PauseColorMotorRunStates () */ memset( ps->a_nbNewAdrPointer, 0, _SCANSTATE_BYTES ); ps->a_nbNewAdrPointer[1] = 0x77; IOPutOnAllRegisters( ps ); _DODELAY( 70 ); /* read one shading line and work on it */ if( IOReadOneShadingLine( ps, (pUChar)ps->Bufs.b1.pShadingRam, 2560)) { if ( ps->DataInf.wPhyDataType <= COLOR_256GRAY ) { bHi[1] = DacP98003SumGains( (pUChar)ps->Bufs.b1.pShadingRam + 2560, 2560); if( bHi[1] ) DacP98003AdjustGain( ps, _CHANNEL_GREEN, bHi[1] ); else { ps->Shade.fStop = _FALSE; } } else { bHi[0] = DacP98003SumGains((pUChar)ps->Bufs.b1.pShadingRam, 2560); bHi[1] = DacP98003SumGains((pUChar)ps->Bufs.b1.pShadingRam + 2560, 2560); bHi[2] = DacP98003SumGains((pUChar)ps->Bufs.b1.pShadingRam + 5120, 2560); if (!bHi[0] || !bHi[1] || !bHi[2] ) { ps->Shade.fStop = _FALSE; } else { DacP98003AdjustGain( ps, _CHANNEL_RED, bHi[0] ); DacP98003AdjustGain( ps, _CHANNEL_GREEN, bHi[1] ); DacP98003AdjustGain( ps, _CHANNEL_BLUE, bHi[2] ); } } } else ps->Shade.fStop = _FALSE; } #ifdef DEBUG if( !ps->Shade.fStop ) DBG( DBG_LOW, "dacP98003AdjustRGBGain() - all loops done!!!\n" ); #endif DacP98003FillToDAC( ps, &ps->Device.RegDACGain, &ps->Shade.Gain ); } /** */ static UShort dacP98003SumDarks( pScanData ps, pUShort data ) { UShort i, loop; if( ps->Device.bCCDID == _CCD_3799 ) { if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) data += 0x18; else data += 0x30; } else { if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) data += 0x18; else data += 0x20; } for( i = 0, loop = 16; loop--; data++ ) i += *data; i >>= 4; return i; } /** */ static void dacP98003AdjustShadingWaveform( pScanData ps ) { Byte b; UShort count, wR, wG, wB, tmp; DataType var; DataPointer pvar, psum; RBGPtrDef cp; pRGBUShortDef pRGB, pwsum; DBG( DBG_LOW, "dacP98003AdjustShadingWaveForm()\n" ); memset( &cp, 0, sizeof(RBGPtrDef)); memset( ps->Bufs.b2.pSumBuf, 0, (5400 * 3 * 2)); /* SetAdjustShadingRegister () */ IODataToRegister( ps, ps->RegModeControl, _ModeIdle ); ps->AsicReg.RD_LineControl = _LOBYTE(ps->Shade.wExposure); ps->AsicReg.RD_ExtLineControl = _HIBYTE(ps->Shade.wExposure); IODataToRegister( ps, ps->RegExtendedLineControl, ps->AsicReg.RD_ExtLineControl ); IODataToRegister( ps, ps->RegLineControl, ps->AsicReg.RD_LineControl ); ps->AsicReg.RD_XStepTime = _LOBYTE(ps->Shade.wExposure); ps->AsicReg.RD_ExtXStepTime = _HIBYTE(ps->Shade.wExposure); IODataToRegister( ps, ps->RegExtendedXStep, ps->AsicReg.RD_ExtXStepTime ); IODataToRegister( ps, ps->RegXStepTime, ps->AsicReg.RD_XStepTime ); ps->AsicReg.RD_ModeControl = _ModeScan; ps->AsicReg.RD_StepControl = _MOTOR0_SCANSTATE; ps->AsicReg.RD_Motor0Control = _FORWARD_MOTOR; if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) { ps->AsicReg.RD_Dpi = 300; ps->AsicReg.RD_Pixels = 2700; ps->Shade.shadingBytes = 2700 * 2; } else { ps->AsicReg.RD_Dpi = 600; ps->AsicReg.RD_Pixels = 5400; ps->Shade.shadingBytes = 5400 * 2; } ps->AsicReg.RD_Origin = _SHADING_BEGINX; for( pvar.pdw = (pULong)ps->a_nbNewAdrPointer, var.dwValue = _SCANSTATE_BYTES >> 2; var.dwValue--; pvar.pdw++) { *pvar.pdw = 0x00f00080; } ps->Scan.fRefreshState = _FALSE; IOPutOnAllRegisters( ps ); _DODELAY( 55 ); /* SetupHilightShadow () */ if( ps->Shade.pHilight ) { memset( ps->Shade.pHilight, 0, ps->Shade.shadingBytes * ps->Shade.skipHilight * 3 ); memset((pUChar)ps->Shade.pHilight + ps->Shade.shadingBytes * ps->Shade.skipHilight * 3, 0xff, ps->Shade.shadingBytes * ps->Shade.skipShadow * 3 ); } for( count = 32; count--;) { IOReadOneShadingLine( ps, ((pUChar)ps->Bufs.b1.pShadingRam)+_SHADING_BEGINX, ps->Shade.shadingBytes ); /* SaveHilightShadow() */ if( ps->Shade.pHilight ) { if ( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { cp.red.usp = ps->Bufs.b1.pShadingRam + _SHADING_BEGINX; cp.green.usp = cp.red.usp + ps->AsicReg.RD_Pixels; cp.blue.usp = cp.green.usp + ps->AsicReg.RD_Pixels; pvar.pusrgb = (pRGBUShortDef)ps->Shade.pHilight + _SHADING_BEGINX; for( var.dwValue = ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { pRGB = pvar.pusrgb++; wR = *cp.red.usp; wG = *cp.green.usp; wB = *cp.blue.usp; for( b = ps->Shade.skipHilight; b--; pRGB += ps->AsicReg.RD_Pixels) { if( wR > pRGB->Red ) { tmp = wR; wR = pRGB->Red; pRGB->Red = tmp; } if( wG > pRGB->Green ) { tmp = wG; wG = pRGB->Green; pRGB->Green = tmp; } if( wB > pRGB->Blue ) { tmp = wB; wB = pRGB->Blue; pRGB->Blue = tmp; } } wR = *cp.red.usp++; wG = *cp.green.usp++; wB = *cp.blue.usp++; for(b = ps->Shade.skipShadow; b--; pRGB += ps->AsicReg.RD_Pixels) { if (wR < pRGB->Red) { tmp = wR; wR = pRGB->Red; pRGB->Red = tmp; } if (wG < pRGB->Green) { tmp = wG; wG = pRGB->Green; pRGB->Green = tmp; } if (wB < pRGB->Blue) { tmp = wB; wB = pRGB->Blue; pRGB->Blue = tmp; } } } } else { cp.green.usp = ps->Bufs.b1.pShadingRam + ps->AsicReg.RD_Pixels + _SHADING_BEGINX; cp.blue.usp = (pUShort) ps->Shade.pHilight + _SHADING_BEGINX; for (var.dwValue = ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { cp.red.usp = cp.blue.usp++; wG = *cp.green.usp; for( b = ps->Shade.skipHilight; b--; cp.red.usp += ps->AsicReg.RD_Pixels) { if( wG > *cp.red.usp ) { tmp = wG; wG = *cp.red.usp; *cp.red.usp = tmp; } } wG = *cp.green.usp++; for (b = ps->Shade.skipShadow; b--; cp.red.usp += ps->AsicReg.RD_Pixels) { if( wG < *cp.red.usp ) { tmp = wG; wG = *cp.red.usp; *cp.red.usp = tmp; } } } } } /* AddToSumBuffer() */ if ( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { cp.red.usp = ps->Bufs.b1.pShadingRam + _SHADING_BEGINX; cp.green.usp = cp.red.usp + ps->AsicReg.RD_Pixels; cp.blue.usp = cp.green.usp + ps->AsicReg.RD_Pixels; pvar.pulrgb = (pRGBULongDef)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = (ULong)ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--; pvar.pulrgb++, cp.red.usp++, cp.green.usp++, cp.blue.usp++) { pvar.pulrgb->Red += (ULong)*cp.red.usp; pvar.pulrgb->Green += (ULong)*cp.green.usp; pvar.pulrgb->Blue += (ULong)*cp.blue.usp; } } else { cp.green.usp = ps->Bufs.b1.pShadingRam + ps->AsicReg.RD_Pixels + _SHADING_BEGINX; pvar.pdw = (pULong)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; for(var.dwValue = (ULong)ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--; pvar.pdw++, cp.green.usp++) { *pvar.pdw += (ULong)*cp.green.usp; } } if( IOReadFifoLength( ps ) < ps->AsicReg.RD_Pixels ) IORegisterToScanner( ps, ps->RegRefreshScanState ); } /* AverageAfterSubHilightShadow() */ if( ps->Shade.pHilight ) { if ( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { psum.pulrgb = (pRGBULongDef)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; pwsum = (pRGBUShortDef)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; pvar.pusrgb = (pRGBUShortDef)ps->Shade.pHilight + _SHADING_BEGINX; for( var.dwValue = ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { pRGB = pvar.pusrgb++; for( b = ps->Shade.skipHilight + ps->Shade.skipShadow; b--; pRGB += ps->AsicReg.RD_Pixels ) { psum.pulrgb->Red -= (ULong)pRGB->Red; psum.pulrgb->Green -= (ULong)pRGB->Green; psum.pulrgb->Blue -= (ULong)pRGB->Blue; } pwsum->Red = (UShort)(psum.pulrgb->Red / ps->Shade.dwDiv); pwsum->Green = (UShort)(psum.pulrgb->Green / ps->Shade.dwDiv); pwsum->Blue = (UShort)(psum.pulrgb->Blue / ps->Shade.dwDiv); psum.pulrgb++; pwsum++; } } else { cp.green.ulp = (pULong)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; cp.blue.usp = (pUShort)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; pvar.pw = (pUShort)ps->Shade.pHilight + _SHADING_BEGINX; for( var.dwValue = ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { cp.red.usp = pvar.pw++; for( b = ps->Shade.skipHilight + ps->Shade.skipShadow; b--; cp.red.usp += ps->AsicReg.RD_Pixels ) *cp.green.ulp -= *cp.red.usp; *cp.blue.usp = (UShort)(*cp.green.ulp / ps->Shade.dwDiv); cp.blue.usp++; cp.green.ulp++; } } } else { if ( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { psum.pulrgb = (pRGBULongDef)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; pwsum = (pRGBUShortDef)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; for (var.dwValue = ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { pwsum->Red = (UShort)(psum.pulrgb->Red >> 5); pwsum->Green = (UShort)(psum.pulrgb->Green >> 5); pwsum->Blue = (UShort)(psum.pulrgb->Blue >> 5); psum.pulrgb++; pwsum++; } } else { cp.green.ulp = (pULong)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; cp.blue.usp = (pUShort)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; for (var.dwValue = ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { *cp.blue.usp = (UShort)(*cp.green.ulp >> 5); cp.blue.usp++; cp.green.ulp++; } } } /* Process negative & transparency here */ if( ps->DataInf.dwScanFlag & SCANDEF_TPA ) TPAP98003FindCenterPointer( ps ); if( ps->DataInf.dwScanFlag & SCANDEF_Negative ) TPAP98003Reshading( ps ); pRGB = (pRGBUShortDef)&ps->Shade.pCcdDac->GainResize; if ( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { pwsum = (pRGBUShortDef)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { if ((short)(pwsum->Red -= ps->Shade.DarkOffset.Colors.Red) > 0) { pwsum->Red = pwsum->Red * pRGB->Red / 100U; if( pwsum->Red > 0xfff ) pwsum->Red = 0xfff; } else pwsum->Red = 0; if((short)(pwsum->Green -= ps->Shade.DarkOffset.Colors.Green) > 0) { pwsum->Green = pwsum->Green * pRGB->Green / 100U; if( pwsum->Green > 0xfff ) pwsum->Green = 0xfff; } else pwsum->Green = 0; if ((short)(pwsum->Blue -= ps->Shade.DarkOffset.Colors.Blue) > 0) { pwsum->Blue = pwsum->Blue * pRGB->Blue / 100U; if( pwsum->Blue > 0xfff ) pwsum->Blue = 0xfff; } else pwsum->Blue = 0; wR = (UShort)(pwsum->Red >> 4); pwsum->Red <<= 12; pwsum->Red |= wR; wR = (UShort)(pwsum->Green >> 4); pwsum->Green <<= 12; pwsum->Green |= wR; wR = (UShort)(pwsum->Blue>> 4); pwsum->Blue <<= 12; pwsum->Blue |= wR; pwsum++; } } else { cp.green.usp = (pUShort)ps->Bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = ps->AsicReg.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { if((short)(*cp.green.usp -= ps->Shade.DarkOffset.Colors.Green) > 0) { *cp.green.usp = *cp.green.usp * pRGB->Green / 100U; if( *cp.green.usp > 0xfff ) *cp.green.usp = 0xfff; } else *cp.green.usp = 0; wR = (UShort)(*cp.green.usp >> 4); *cp.green.usp <<= 12; *cp.green.usp |= wR; cp.green.usp++; } } /* DownloadShadingAndSetDark() */ dacP98DownloadShadingTable( ps, ps->Bufs.b2.pSumBuf, (5400 * 3 * 2)); } /** */ static void dacP98003AdjustDark( pScanData ps ) { ULong i; UShort wDarks[3]; DBG( DBG_LOW, "dacP98003AdjustDark()\n" ); ps->Shade.DarkDAC.Colors = ps->Shade.pCcdDac->DarkDAC.Colors; ps->Shade.fStop = _FALSE; for( i = 16; i-- && !ps->Shade.fStop;) { ps->Shade.fStop = _TRUE; /* FillDarkToDAC() */ DacP98003FillToDAC( ps, &ps->Device.RegDACOffset, &ps->Shade.DarkDAC ); IODataToRegister( ps, ps->RegModeControl, _ModeIdle ); ps->AsicReg.RD_ScanControl = (_SCAN_12BITMODE + _SCAN_1ST_AVERAGE); IOSelectLampSource( ps ); IODataToRegister( ps, ps->RegScanControl, ps->AsicReg.RD_ScanControl ); ps->AsicReg.RD_StepControl = _MOTOR0_SCANSTATE; ps->AsicReg.RD_Motor0Control = _FORWARD_MOTOR; ps->AsicReg.RD_Origin = _SHADING_BEGINX; ps->AsicReg.RD_Pixels = 512; if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) ps->AsicReg.RD_Dpi = 300; else ps->AsicReg.RD_Dpi = 600; /* PauseColorMotorRunStates () */ memset( ps->a_nbNewAdrPointer, 0, _SCANSTATE_BYTES ); ps->a_nbNewAdrPointer[1] = 0x77; IOPutOnAllRegisters( ps ); _DODELAY( 70 ); /* read one shading line and work on it */ if( IOReadOneShadingLine(ps, (pUChar)ps->Bufs.b1.pShadingRam, 512*2)) { if ( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { wDarks[0] = dacP98003SumDarks( ps, ps->Bufs.b1.pShadingRam ); wDarks[1] = dacP98003SumDarks( ps, ps->Bufs.b1.pShadingRam + ps->AsicReg.RD_Pixels ); wDarks[2] = dacP98003SumDarks( ps, ps->Bufs.b1.pShadingRam + ps->AsicReg.RD_Pixels * 2UL); if( !wDarks[0] || !wDarks[1] || !wDarks[2] ) { ps->Shade.fStop = _FALSE; } else { ps->Shade.DarkOffset.wColors[0] = wDarks[0]; ps->Shade.DarkOffset.wColors[1] = wDarks[1]; ps->Shade.DarkOffset.wColors[2] = wDarks[2]; (*(ps->Device).fnDACDark)( ps, ps->Shade.pCcdDac, _CHANNEL_RED, wDarks[0] ); (*(ps->Device).fnDACDark)( ps, ps->Shade.pCcdDac, _CHANNEL_GREEN, wDarks[1] ); (*(ps->Device).fnDACDark)( ps, ps->Shade.pCcdDac, _CHANNEL_BLUE, wDarks[2] ); } } else { wDarks[1] = dacP98003SumDarks( ps, ps->Bufs.b1.pShadingRam + ps->AsicReg.RD_Pixels ); if (!wDarks[1] ) ps->Shade.fStop = _FALSE; else { ps->Shade.DarkOffset.wColors[1] = wDarks[1]; (*(ps->Device).fnDACDark)( ps, ps->Shade.pCcdDac, _CHANNEL_GREEN, wDarks[1] ); } } } else ps->Shade.fStop = _FALSE; } /* CalculateDarkDependOnCCD() */ if ( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { (*(ps->Device).fnDarkOffset)( ps, ps->Shade.pCcdDac, _CHANNEL_RED ); (*(ps->Device).fnDarkOffset)( ps, ps->Shade.pCcdDac, _CHANNEL_GREEN ); (*(ps->Device).fnDarkOffset)( ps, ps->Shade.pCcdDac, _CHANNEL_BLUE ); } else (*(ps->Device).fnDarkOffset)( ps, ps->Shade.pCcdDac, _CHANNEL_GREEN ); } /** */ static Bool dacP98003WaitForShading( pScanData ps ) { ULong i, tmp; Byte bScanControl; DBG( DBG_LOW, "dacP98003WaitForShading()\n" ); /* * before getting the shading data, (re)init the ASIC */ ps->ReInitAsic( ps, _TRUE ); ps->Shade.DarkOffset.Colors.Red = 0; ps->Shade.DarkOffset.Colors.Green = 0; ps->Shade.DarkOffset.Colors.Blue = 0; IORegisterToScanner( ps, ps->RegResetMTSC ); IODataToRegister( ps, ps->RegModelControl, ps->AsicReg.RD_ModelControl); IODataToRegister( ps, ps->RegMotorDriverType, ps->AsicReg.RD_MotorDriverType ); IODataToRegister( ps, ps->RegScanControl1, (_SCANSTOPONBUFFULL| _MFRC_BY_XSTEP)); ps->GotoShadingPosition( ps ); bScanControl = ps->AsicReg.RD_ScanControl; /* SetShadingMapForGainDark */ memset( ps->Bufs.b2.pSumBuf, 0xff, (5400 * 3 * 2)); /* DownloadShadingAndSetDark() */ dacP98DownloadShadingTable( ps, ps->Bufs.b2.pSumBuf, (5400 * 3 * 2)); for( i = 0, tmp = 0; i < 1024; tmp += 0x01010101, i += 4 ) { ps->Bufs.b1.Buf.pdw[i] = ps->Bufs.b1.Buf.pdw[i+1] = ps->Bufs.b1.Buf.pdw[i+2] = ps->Bufs.b1.Buf.pdw[i+3] = tmp; } memcpy( ps->Bufs.b1.pShadingMap + 4096, ps->Bufs.b1.pShadingMap, 4096 ); memcpy( ps->Bufs.b1.pShadingMap + 8192, ps->Bufs.b1.pShadingMap, 4096 ); dacP98DownloadMapTable( ps, ps->Bufs.b1.pShadingMap ); DBG( DBG_LOW, "wExposure = %u\n", ps->Shade.wExposure); DBG( DBG_LOW, "wXStep = %u\n", ps->Shade.wXStep); ps->AsicReg.RD_LineControl = (_LOBYTE(ps->Shade.wExposure)); ps->AsicReg.RD_ExtLineControl = (_HIBYTE(ps->Shade.wExposure)); IODataToRegister(ps, ps->RegExtendedLineControl, ps->AsicReg.RD_ExtLineControl ); IODataToRegister(ps, ps->RegLineControl, ps->AsicReg.RD_LineControl ); dacP98003AdjustRGBGain( ps ); dacP98003AdjustDark( ps ); dacP98003AdjustShadingWaveform( ps ); ps->AsicReg.RD_ScanControl = bScanControl; /* here we have to download the table in any case...*/ dacP98DownloadMapTable( ps, ps->a_bMapTable ); MotorP98003BackToHomeSensor( ps ); return _TRUE; } /************************ exported functions *********************************/ /** */ _LOC int DacInitialize( pScanData ps ) { DBG( DBG_HIGH, "DacInitialize()\n" ); if( NULL == ps ) return _E_NULLPTR; /* * depending on the asic, we set some functions */ if( _ASIC_IS_98003 == ps->sCaps.AsicID ) { ps->WaitForShading = dacP98003WaitForShading; } else if( _ASIC_IS_98001 == ps->sCaps.AsicID ) { ps->WaitForShading = dacP98WaitForShading; } else if( _ASIC_IS_96003 == ps->sCaps.AsicID ) { ps->WaitForShading = dacP96003WaitForShading; } else if( _ASIC_IS_96001 == ps->sCaps.AsicID ) { ps->WaitForShading = dacP96001WaitForShading; } else { DBG( DBG_HIGH , "NOT SUPPORTED ASIC !!!\n" ); return _E_NOSUPP; } return _OK; } /** Fill out the R/G/B GainOut value */ _LOC void DacP98FillGainOutDirectPort( pScanData ps ) { ps->OpenScanPath( ps ); IODataRegisterToDAC( ps, 0x28, ps->bRedGainIndex ); IODataRegisterToDAC( ps, 0x29, ps->bGreenGainIndex ); IODataRegisterToDAC( ps, 0x2a, ps->bBlueGainIndex ); ps->CloseScanPath( ps ); } /** */ _LOC void DacP98FillShadingDarkToShadingRegister( pScanData ps ) { pUChar pValue; Byte bReg; DBG( DBG_LOW, "DacP98FillShadingDarkToShadingRegister()\n" ); ps->AsicReg.RD_RedDarkOff = ps->Shade.DarkOffset.Colors.Red; ps->AsicReg.RD_GreenDarkOff = ps->Shade.DarkOffset.Colors.Green; ps->AsicReg.RD_BlueDarkOff = ps->Shade.DarkOffset.Colors.Blue; pValue = (pUChar)&ps->AsicReg.RD_RedDarkOff; for (bReg = ps->RegRedChDarkOffsetLow; bReg <= ps->RegBlueChDarkOffsetHigh; bReg++, pValue++) { IODataToRegister( ps, bReg, *pValue ); } } /** */ _LOC void DacP98AdjustDark( pScanData ps ) { Byte bCorrectTimes; /* used to be a global var !*/ DBG( DBG_LOW, "DacP98AdjustDark()\n" ); ps->Shade.pCcdDac->DarkDAC.Colors.Red = ps->bsPreRedDAC; ps->Shade.pCcdDac->DarkDAC.Colors.Green = ps->bsPreGreenDAC; ps->Shade.pCcdDac->DarkDAC.Colors.Blue = ps->bsPreBlueDAC; if( ps->DataInf.dwScanFlag & SCANDEF_Negative ) { bCorrectTimes = 6; } else { bCorrectTimes = 5; } /* CHANGE ** original code seems to be buggy : for (bCorrectTimes ; bCorrectTimes--;) { */ for (;bCorrectTimes ; bCorrectTimes-- ) { ps->OpenScanPath( ps ); dacP98FillDarkDAC( ps ); dacP98SetReadFBKRegister( ps ); ps->CloseScanPath( ps ); IOPutOnAllRegisters( ps ); ps->PauseColorMotorRunStates( ps ); /* stop scan states */ IOReadOneShadingLine( ps, ps->pScanBuffer1, 512*2 ); dacP98FillChannelDarkLevelControl( ps ); if(dacP98CheckChannelDarkLevel( ps )) break; } ps->Shade.DarkOffset.Colors.Red= dacP98CalDarkOff( ps, ps->Shade.DarkOffset.Colors.Red, ps->Shade.pCcdDac->DarkCmpHi.Colors.Red, ps->Shade.pCcdDac->DarkOffSub.Colors.Red ); ps->Shade.DarkOffset.Colors.Green = dacP98CalDarkOff( ps, ps->Shade.DarkOffset.Colors.Green, ps->Shade.pCcdDac->DarkCmpHi.Colors.Green, ps->Shade.pCcdDac->DarkOffSub.Colors.Green ); ps->Shade.DarkOffset.Colors.Blue = dacP98CalDarkOff( ps, ps->Shade.DarkOffset.Colors.Blue, ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue, ps->Shade.pCcdDac->DarkOffSub.Colors.Blue ); } /** */ _LOC void DacP96WriteBackToGammaShadingRAM( pScanData ps ) { /* ModifyGammaShadingOffset(ps) */ ps->OpenScanPath( ps); IODataToRegister( ps, ps->RegRedChShadingOffset, ps->Asic96Reg.u28.RD_RedChShadingOff ); IODataToRegister( ps, ps->RegGreenChShadingOffset, (Byte)((ULong)ps->Asic96Reg.u29.RD_GreenChShadingOff * 96UL/100UL)); IODataToRegister( ps, ps->RegBlueChShadingOffset, (Byte)((ULong)ps->Asic96Reg.RD_BlueChShadingOff * 91UL/100UL)); ps->CloseScanPath( ps ); dacP96WriteLinearGamma( ps, ps->pPrescan16, 256, ps->ShadingBankRed); dacP96WriteLinearGamma( ps, ps->pPrescan16 + ps->ShadingBankSize, 256, ps->ShadingBankGreen); dacP96WriteLinearGamma( ps, ps->pPrescan16 + ps->ShadingBankSize * 2, 256, ps->ShadingBankBlue); } /** */ _LOC void DacP98003FillToDAC( pScanData ps, pRGBByteDef regs, pColorByte data ) { if ( ps->DataInf.wPhyDataType > COLOR_256GRAY ) { dacP98003GainOffsetToDAC( ps, _DAC_RED, regs->Red, data->Colors.Red ); dacP98003GainOffsetToDAC( ps, _DAC_GREENCOLOR, regs->Green, data->Colors.Green ); dacP98003GainOffsetToDAC( ps, _DAC_BLUE, regs->Blue, data->Colors.Blue ); } else { dacP98003GainOffsetToDAC( ps, _DAC_GREENMONO, regs->Green, data->Colors.Green ); } } /** */ _LOC void DacP98003AdjustGain( pScanData ps, ULong color, Byte hilight ) { if( hilight < ps->Shade.bGainLow ) { if( ps->Shade.Hilight.bColors[color] < ps->Shade.bGainHigh ) { ps->Shade.fStop = _FALSE; ps->Shade.Hilight.bColors[color] = hilight; if( hilight <= (Byte)(ps->Shade.bGainLow - hilight)) ps->Shade.Gain.bColors[color] += ps->Shade.bGainDouble; else ps->Shade.Gain.bColors[color]++; } } else { if( hilight > ps->Shade.bGainHigh ) { ps->Shade.fStop = _FALSE; ps->Shade.Hilight.bColors[color] = hilight; ps->Shade.Gain.bColors[color]--; } else ps->Shade.Hilight.bColors[color] = hilight; } if( ps->Shade.Gain.bColors[color] > ps->Shade.bMaxGain ) { ps->Shade.Gain.bColors[color] = ps->Shade.bMaxGain; } } /** */ _LOC Byte DacP98003SumGains( pUChar pb, ULong pixelsLine ) { Byte bHilight, tmp; ULong dwPixels, dwAve; UShort sum; for( bHilight = 0, dwPixels = pixelsLine >> 4; dwPixels--; ) { for( sum = 0, dwAve = 16; dwAve--; pb++) sum += (UShort)*pb; sum >>= 4; tmp = (Byte)sum; if( tmp > bHilight ) bHilight = tmp; } return bHilight; } /* END PLUSTEK-PP_DAC.C .....................................................*/ sane-backends-1.0.29/backend/hp-device.c0000666000000000000000000003371013615534521014604 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Geoffrey T. Dairiki 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP Scanners supporting HP Scanner Control Language (SCL). */ /*#define STUBS extern int sanei_debug_hp;*/ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include #include #include "../include/lassert.h" #include "hp-device.h" #include "hp-accessor.h" #include "hp-option.h" #include "hp-scsi.h" #include "hp-scl.h" /* Mark an scl-command to be simulated */ SANE_Status sanei_hp_device_simulate_set (const char *devname, HpScl scl, int flag) {HpDeviceInfo *info; int inqid; info = sanei_hp_device_info_get ( devname ); if (!info) return SANE_STATUS_INVAL; inqid = SCL_INQ_ID(scl)-HP_SCL_INQID_MIN; info->simulate.sclsimulate[inqid] = flag; DBG(3, "hp_device_simulate_set: %d set to %ssimulated\n", inqid+HP_SCL_INQID_MIN, flag ? "" : "not "); return SANE_STATUS_GOOD; } /* Clear all simulation flags */ void sanei_hp_device_simulate_clear (const char *devname) {HpDeviceInfo *info; info = sanei_hp_device_info_get ( devname ); if (!info) return; memset (&(info->simulate.sclsimulate[0]), 0, sizeof (info->simulate.sclsimulate)); info->simulate.gamma_simulate = 0; } /* Get simulate flag for an scl-command */ hp_bool_t sanei_hp_device_simulate_get (const char *devname, HpScl scl) {HpDeviceInfo *info; int inqid; info = sanei_hp_device_info_get ( devname ); if (!info) return 0; inqid = SCL_INQ_ID(scl)-HP_SCL_INQID_MIN; return info->simulate.sclsimulate[inqid]; } SANE_Status sanei_hp_device_support_get (const char *devname, HpScl scl, int *minval, int *maxval) {HpDeviceInfo *info; HpSclSupport *sclsupport; int inqid; /* #define HP_TEST_SIMULATE */ #ifdef HP_TEST_SIMULATE if (scl == SCL_BRIGHTNESS) return SANE_STATUS_UNSUPPORTED; if (scl == SCL_CONTRAST) return SANE_STATUS_UNSUPPORTED; if (scl == SCL_DOWNLOAD_TYPE) { *minval = 2; *maxval = 14; return SANE_STATUS_GOOD; } #endif info = sanei_hp_device_info_get ( devname ); if (!info) return SANE_STATUS_INVAL; inqid = SCL_INQ_ID(scl)-HP_SCL_INQID_MIN; sclsupport = &(info->sclsupport[inqid]); if ( !(sclsupport->checked) ) return SANE_STATUS_INVAL; if ( !(sclsupport->is_supported) ) return SANE_STATUS_UNSUPPORTED; if (minval) *minval = sclsupport->minval; if (maxval) *maxval = sclsupport->maxval; return SANE_STATUS_GOOD; } /* Update the list of supported commands */ SANE_Status sanei_hp_device_support_probe (HpScsi scsi) {HpDeviceInfo *info; HpSclSupport *sclsupport; SANE_Status status; int k, val, inqid; static HpScl sclprobe[] = /* The commands that should be probed */ { SCL_AUTO_BKGRND, SCL_COMPRESSION, SCL_DOWNLOAD_TYPE, SCL_X_SCALE, SCL_Y_SCALE, SCL_DATA_WIDTH, SCL_INVERSE_IMAGE, SCL_BW_DITHER, SCL_CONTRAST, SCL_BRIGHTNESS, #ifdef SCL_SHARPENING SCL_SHARPENING, #endif SCL_MIRROR_IMAGE, SCL_X_RESOLUTION, SCL_Y_RESOLUTION, SCL_OUTPUT_DATA_TYPE, SCL_PRELOAD_ADF, SCL_MEDIA, SCL_X_EXTENT, SCL_Y_EXTENT, SCL_X_POS, SCL_Y_POS, SCL_SPEED, SCL_FILTER, SCL_TONE_MAP, SCL_MATRIX, SCL_UNLOAD, SCL_CHANGE_DOC, SCL_ADF_BFEED }; enum hp_device_compat_e compat; DBG(1, "hp_device_support_probe: Check supported commands for %s\n", sanei_hp_scsi_devicename (scsi) ); info = sanei_hp_device_info_get ( sanei_hp_scsi_devicename (scsi) ); assert (info); memset (&(info->sclsupport[0]), 0, sizeof (info->sclsupport)); for (k = 0; k < (int)(sizeof (sclprobe) / sizeof (sclprobe[0])); k++) { inqid = SCL_INQ_ID(sclprobe[k])-HP_SCL_INQID_MIN; sclsupport = &(info->sclsupport[inqid]); status = sanei_hp_scl_inquire (scsi, sclprobe[k], &val, &(sclsupport->minval), &(sclsupport->maxval)); sclsupport->is_supported = (status == SANE_STATUS_GOOD); sclsupport->checked = 1; /* The OfficeJets seem to ignore brightness and contrast settings, * so we'll pretend they're not supported at all. */ if (((sclprobe[k]==SCL_BRIGHTNESS) || (sclprobe[k]==SCL_CONTRAST)) && (sanei_hp_device_probe (&compat, scsi) == SANE_STATUS_GOOD) && (compat & HP_COMPAT_OJ_1150C)) { sclsupport->is_supported=0; } if (sclsupport->is_supported) { DBG(1, "hp_device_support_probe: %d supported (%d..%d, %d)\n", inqid+HP_SCL_INQID_MIN, sclsupport->minval, sclsupport->maxval, val); } else { DBG(1, "hp_device_support_probe: %d not supported\n", inqid+HP_SCL_INQID_MIN); } } return SANE_STATUS_GOOD; } SANE_Status sanei_hp_device_probe_model (enum hp_device_compat_e *compat, HpScsi scsi, int *model_num, const char **model_name) { static struct { HpScl cmd; int model_num; const char * model; enum hp_device_compat_e flag; } probes[] = { { SCL_HP_MODEL_1, 1, "ScanJet Plus", HP_COMPAT_PLUS }, { SCL_HP_MODEL_2, 2, "ScanJet IIc", HP_COMPAT_2C }, { SCL_HP_MODEL_3, 3, "ScanJet IIp", HP_COMPAT_2P }, { SCL_HP_MODEL_4, 4, "ScanJet IIcx", HP_COMPAT_2CX }, { SCL_HP_MODEL_5, 5, "ScanJet 3c/4c/6100C", HP_COMPAT_4C }, { SCL_HP_MODEL_6, 6, "ScanJet 3p", HP_COMPAT_3P }, { SCL_HP_MODEL_8, 8, "ScanJet 4p", HP_COMPAT_4P }, { SCL_HP_MODEL_9, 9, "ScanJet 5p/4100C/5100C", HP_COMPAT_5P }, { SCL_HP_MODEL_10,10,"PhotoSmart Photo Scanner", HP_COMPAT_PS }, { SCL_HP_MODEL_11,11,"OfficeJet 1150C", HP_COMPAT_OJ_1150C }, { SCL_HP_MODEL_12,12,"OfficeJet 1170C or later", HP_COMPAT_OJ_1170C }, { SCL_HP_MODEL_14,14,"ScanJet 62x0C", HP_COMPAT_6200C }, { SCL_HP_MODEL_16,15,"ScanJet 5200C", HP_COMPAT_5200C }, { SCL_HP_MODEL_17,17,"ScanJet 63x0C", HP_COMPAT_6300C } }; int i; char buf[8]; SANE_Status status; static char *last_device = NULL; static enum hp_device_compat_e last_compat; static int last_model_num = -1; static const char *last_model_name = "Model Unknown"; assert(scsi); DBG(1, "probe_scanner: Probing %s\n", sanei_hp_scsi_devicename (scsi)); if (last_device != NULL) /* Look if we already probed the device */ { if (strcmp (last_device, sanei_hp_scsi_devicename (scsi)) == 0) { DBG(3, "probe_scanner: use cached compatibility flags\n"); *compat = last_compat; if (model_num) *model_num = last_model_num; if (model_name) *model_name = last_model_name; return SANE_STATUS_GOOD; } sanei_hp_free (last_device); last_device = NULL; } *compat = 0; last_model_num = -1; last_model_name = "Model Unknown"; for (i = 0; i < (int)(sizeof(probes)/sizeof(probes[0])); i++) { DBG(1,"probing %s\n",probes[i].model); if (!FAILED( status = sanei_hp_scl_upload(scsi, probes[i].cmd, buf, sizeof(buf)) )) { DBG(1, "probe_scanner: %s compatible (%5s)\n", probes[i].model, buf); last_model_name = probes[i].model; /* Some scanners have different responses */ if (probes[i].model_num == 9) { if (strncmp (buf, "5110A", 5) == 0) last_model_name = "ScanJet 5p"; else if (strncmp (buf, "5190A", 5) == 0) last_model_name = "ScanJet 5100C"; else if (strncmp (buf, "6290A", 5) == 0) last_model_name = "ScanJet 4100C"; } *compat |= probes[i].flag; last_model_num = probes[i].model_num; } else if (!UNSUPPORTED( status )) return status; /* SCL inquiry failed */ } /* Save values for next call */ last_device = sanei_hp_strdup (sanei_hp_scsi_devicename (scsi)); last_compat = *compat; if (model_num) *model_num = last_model_num; if (model_name) *model_name = last_model_name; return SANE_STATUS_GOOD; } SANE_Status sanei_hp_device_probe (enum hp_device_compat_e *compat, HpScsi scsi) { return sanei_hp_device_probe_model (compat, scsi, 0, 0); } hp_bool_t sanei_hp_device_compat (HpDevice this, enum hp_device_compat_e which) { return (this->compat & which) != 0; } static SANE_Status hp_nonscsi_device_new (HpDevice * newp, const char * devname, HpConnect connect) { HpDevice this; HpScsi scsi; SANE_Status status; const char * model_name = "ScanJet"; if (FAILED( sanei_hp_nonscsi_new(&scsi, devname, connect) )) { DBG(1, "%s: Can't open nonscsi device\n", devname); return SANE_STATUS_INVAL; /* Can't open device */ } /* reset scanner; returns all parameters to defaults */ if (FAILED( sanei_hp_scl_reset(scsi) )) { DBG(1, "hp_nonscsi_device_new: SCL reset failed\n"); sanei_hp_scsi_destroy(scsi,1); return SANE_STATUS_IO_ERROR; } /* Things seem okay, allocate new device */ this = sanei_hp_allocz(sizeof(*this)); this->data = sanei_hp_data_new(); if (!this || !this->data) return SANE_STATUS_NO_MEM; this->sanedev.name = sanei_hp_strdup(devname); if (!this->sanedev.name) return SANE_STATUS_NO_MEM; this->sanedev.vendor = "Hewlett-Packard"; this->sanedev.type = "flatbed scanner"; status = sanei_hp_device_probe_model (&(this->compat), scsi, 0, &model_name); if (!FAILED(status)) { sanei_hp_device_support_probe (scsi); status = sanei_hp_optset_new(&(this->options), scsi, this); } sanei_hp_scsi_destroy(scsi,1); if (!model_name) model_name = "ScanJet"; this->sanedev.model = sanei_hp_strdup (model_name); if (!this->sanedev.model) return SANE_STATUS_NO_MEM; if (FAILED(status)) { DBG(1, "hp_nonscsi_device_new: %s: probe failed (%s)\n", devname, sane_strstatus(status)); sanei_hp_data_destroy(this->data); sanei_hp_free((void *)this->sanedev.name); sanei_hp_free((void *)this->sanedev.model); sanei_hp_free(this); return status; } DBG(1, "hp_nonscsi_device_new: %s: found HP ScanJet model %s\n", devname, this->sanedev.model); *newp = this; return SANE_STATUS_GOOD; } SANE_Status sanei_hp_device_new (HpDevice * newp, const char * devname) { HpDevice this; HpScsi scsi; HpConnect connect; SANE_Status status; char * str; DBG(3, "sanei_hp_device_new: %s\n", devname); connect = sanei_hp_get_connect (devname); if ( connect != HP_CONNECT_SCSI ) return hp_nonscsi_device_new (newp, devname, connect); if (FAILED( sanei_hp_scsi_new(&scsi, devname) )) { DBG(1, "%s: Can't open scsi device\n", devname); return SANE_STATUS_INVAL; /* Can't open device */ } if (sanei_hp_scsi_inq(scsi)[0] != 0x03 || memcmp(sanei_hp_scsi_vendor(scsi), "HP ", 8) != 0) { DBG(1, "%s: does not seem to be an HP scanner\n", devname); sanei_hp_scsi_destroy(scsi,1); return SANE_STATUS_INVAL; } /* reset scanner; returns all parameters to defaults */ if (FAILED( sanei_hp_scl_reset(scsi) )) { DBG(1, "sanei_hp_device_new: SCL reset failed\n"); sanei_hp_scsi_destroy(scsi,1); return SANE_STATUS_IO_ERROR; } /* Things seem okay, allocate new device */ this = sanei_hp_allocz(sizeof(*this)); this->data = sanei_hp_data_new(); if (!this || !this->data) return SANE_STATUS_NO_MEM; this->sanedev.name = sanei_hp_strdup(devname); str = sanei_hp_strdup(sanei_hp_scsi_model(scsi)); if (!this->sanedev.name || !str) return SANE_STATUS_NO_MEM; this->sanedev.model = str; if ((str = strchr(str, ' ')) != 0) *str = '\0'; this->sanedev.vendor = "Hewlett-Packard"; this->sanedev.type = "flatbed scanner"; status = sanei_hp_device_probe(&(this->compat), scsi); if (!FAILED(status)) { sanei_hp_device_support_probe (scsi); status = sanei_hp_optset_new(&this->options, scsi, this); } sanei_hp_scsi_destroy(scsi,1); if (FAILED(status)) { DBG(1, "sanei_hp_device_new: %s: probe failed (%s)\n", devname, sane_strstatus(status)); sanei_hp_data_destroy(this->data); sanei_hp_free((void *)this->sanedev.name); sanei_hp_free((void *)this->sanedev.model); sanei_hp_free(this); return status; } DBG(1, "sanei_hp_device_new: %s: found HP ScanJet model %s\n", devname, this->sanedev.model); *newp = this; return SANE_STATUS_GOOD; } const SANE_Device * sanei_hp_device_sanedevice (HpDevice this) { return &this->sanedev; } sane-backends-1.0.29/backend/plustek_pp.conf.in0000666000000000000000000000165613615534521016242 00000000000000# Plustek-PP SANE Backend configuration file # For use with Plustek parallel-port scanners # # # user either [direct] or [kernel] to access the scanner # when using [kernel], device specifies the device-node, which is created # by the kernel-module loader (applies only to Linux) # when using [direct], device is used to set the parallel-port base address # or a device-name suitable for libieee1284, i.e. parport0 # #[direct] #device 0x378 # # example for accessing the scanner via libieee1284 # [direct] device parport0 # # leave the default values as specified in /etc/modules.conf # option warmup -1 option lOffOnEnd -1 option lampOff -1 # model override switch, mostly for cosmetic changes, if the autodetection # does not work or could not work correctly #option mov 7 # # example for accessing the scanner via the kernel module # #[kernel] #device /dev/pt_drv # #option warmup -1 #option lOffOnEnd -1 #option lampOff -1 sane-backends-1.0.29/backend/stv680.c0000666000000000000000000015727013615534521014022 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2004 - 2006 Gerard Klaver The teco2 and gl646 backend (Frank Zago) are used as a template for this backend. For the usb commands and bayer decoding parts of the following program are used: The pencam2 program (GNU GPL license 2) For the usb commands parts of the following programs are used: The libgphoto2 (camlib stv0680) (GNU GPL license 2) The stv680.c/.h kernel module (GNU GPL license 2) For the stv680_add_text routine the add_text routine and font_6x11.h file are taken from the webcam.c file, part of xawtv program, (c) 1998-2002 Gerd Knorr (GNU GPL license 2). 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ------------------------------------------------------------------ */ /* $Id$ stv680 vidcam driver Gerard Klaver */ /*SANE FLOW DIAGRAM - sane_init() : initialize backend, attach vidcams . - sane_get_devices() : query list of vidcam devices . - sane_open() : open a particular vidcam device . . - sane_set_io_mode : set blocking mode . . - sane_get_select_fd : get vidcam fd . . - sane_get_option_descriptor() : get option information . . - sane_control_option() : change option values . . . . - sane_start() : start image acquisition . . - sane_get_parameters() : returns actual scan parameters . . - sane_read() : read image data (from pipe) . . (sane_read called multiple times; . . after sane_read returns EOF) . . go back to sane_start() if more frames desired . . - sane_cancel() : cancel operation . - sane_close() : close opened vidcam device - sane_exit() : terminate use of backend */ /*--------------------------------------------------------------------------*/ #define BUILD 1 /* 2004/09/09 update 20-04-2006 */ #define BACKEND_NAME stv680 #define STV680_CONFIG_FILE "stv680.conf" /* --------------------- SANE INTERNATIONALISATION ------------------------ */ /* must be first include */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/lassert.h" /* for add-text routine */ #include #include "../include/font_6x11.h" /*-----------------------*/ #include "stv680.h" #define TIMEOUT 1000 /*--------------------------------------------------------------------------*/ /* Lists of possible scan modes. */ static SANE_String_Const scan_mode_list[] = { COLOR_RGB_STR, COLOR_RGB_TEXT_STR, SANE_VALUE_SCAN_MODE_COLOR, COLOR_RAW_STR, NULL }; /*-----------------------------------------minium, maximum, quantization----*/ static const SANE_Range brightness_range = { -128, 128, 1 }; static const SANE_Range red_level_range = { -32, 32, 1 }; static const SANE_Range green_level_range = { -32, 32, 1 }; static const SANE_Range blue_level_range = { -32, 32, 1 }; /*--------------------------------------------------------------------------*/ static const struct dpi_color_adjust stv680_dpi_color_adjust[] = { /*dpi, y, x, color sequence R G or B */ {176, 144, 0, 1, 2}, /* QCIF selected by dev->CIF */ {352, 288, 0, 1, 2}, /* CIF ,, */ {160, 120, 0, 1, 2}, /* QSIF ,, dev->VGA */ {320, 240, 0, 1, 2}, /* QVGA (SIF) ,, */ {640, 480, 0, 1, 2}, /* VGA ,, */ /* must be the last entry */ {0, 0, 0, 0, 0} }; static const struct vidcam_hardware vidcams[] = { {0x0553, 0x0202, USB_CLASS_VENDOR_SPEC, "AIPTEK", "PENCAM STV0680", stv680_dpi_color_adjust}, {0x04c8, 0x0722, USB_CLASS_VENDOR_SPEC, "Konica", "e-mini", stv680_dpi_color_adjust}, {0x1183, 0x0001, USB_CLASS_VENDOR_SPEC, "DigitalDream", "l'espion XS", stv680_dpi_color_adjust}, {0x041e, 0x4007, USB_CLASS_VENDOR_SPEC, "Creative", "WebCam Go mini", stv680_dpi_color_adjust} }; /* List of vidcams attached. */ static Stv680_Vidcam *first_dev = NULL; static int num_devices = 0; /* used by sane_get_devices */ static const SANE_Device **devlist = NULL; /*----------------------------------------------------------- */ /* Local functions. */ /* Display a buffer in the log. Display by lines of 16 bytes. */ static void hexdump (int level, const char *comment, unsigned char *buf, const int length) { int i; char line[128]; char *ptr; char asc_buf[17]; char *asc_ptr; DBG (level, " %s\n", comment); i = 0; goto start; do { if (i < length) { ptr += sprintf (ptr, " %2.2x", *buf); if (*buf >= 32 && *buf <= 127) { asc_ptr += sprintf (asc_ptr, "%c", *buf); } else { asc_ptr += sprintf (asc_ptr, "."); } } else { /* After the length; do nothing. */ ptr += sprintf (ptr, " "); } i++; buf++; if ((i % 16) == 0) { /* It's a new line */ DBG (level, " %s %s\n", line, asc_buf); start: ptr = line; *ptr = '\0'; asc_ptr = asc_buf; *asc_ptr = '\0'; ptr += sprintf (ptr, " %3.3d:", i); } } while (i < ((length + 15) & ~15)); } /* Returns the length of the longest string, including the terminating * character. */ static size_t max_string_size (SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) { max_size = size; } } return max_size; } /* Initialize a vidcam entry. Return an allocated vidcam with some * */ static Stv680_Vidcam * stv680_init (void) { Stv680_Vidcam *dev; DBG (DBG_proc, "stv680_init: enter\n"); /* Allocate a new vidcam entry. */ dev = malloc (sizeof (Stv680_Vidcam)); if (dev == NULL) { return NULL; } memset (dev, 0, sizeof (Stv680_Vidcam)); /* Allocate the windoww buffer*/ dev->windoww_size = 0x20; dev->windoww = malloc (dev->windoww_size); if (dev->windoww == NULL) { free (dev); return NULL; } /* Allocate the windowr buffer*/ dev->windowr_size = 0x20; dev->windowr = malloc (dev->windowr_size); if (dev->windowr == NULL) { free (dev->windoww); free (dev); return NULL; } dev->fd = -1; DBG (DBG_proc, "stv680_init: exit\n"); return (dev); } static SANE_Status stv680_init_2 (Stv680_Vidcam * dev) { SANE_Status status; DBG (DBG_proc, "stv680_init_2: enter\n"); /* Allocate the buffer used to transfer the USB data */ /* Check for max. format image size so buffer size can * be adjusted, format from camera is bayer 422 */ if (dev->CIF) dev->buffer_size = 356 * 292; if (dev->VGA) dev->buffer_size = 644 * 484; DBG (DBG_proc, "stv680_init_2: dev->bufffer = 0x%lx\n", (unsigned long) (size_t) dev->buffer_size); dev->buffer = malloc (dev->buffer_size); if (dev->buffer == NULL) { free (dev->windowr); free (dev->windoww); free (dev); return SANE_STATUS_NO_MEM; } /* Allocate the output buffer used for bayer conversion */ dev->output_size = dev->buffer_size * 3; dev->output = malloc (dev->output_size); if (dev->output == NULL) { free (dev->windowr); free (dev->windoww); free (dev->buffer); free (dev); return SANE_STATUS_NO_MEM; } dev->image_size = dev->buffer_size; dev->image = malloc (dev->image_size); if (dev->image == NULL) { free (dev->windowr); free (dev->windoww); free (dev->buffer); free (dev->output); free (dev); return SANE_STATUS_NO_MEM; } DBG (DBG_proc, "stv680_init_2: exit\n"); status = SANE_STATUS_GOOD; return status; } /* Closes an open vidcams. */ static void stv680_close (Stv680_Vidcam * dev) { DBG (DBG_proc, "stv680_close: enter \n"); if (dev->fd != -1) { DBG (DBG_proc, "stv680_close: fd !=-1 \n"); sanei_usb_close (dev->fd); dev->fd = -1; } DBG (DBG_proc, "stv680_close: exit\n"); } /* Frees the memory used by a vidcam. */ static void stv680_free (Stv680_Vidcam * dev) { int i; DBG (DBG_proc, "stv680_free: enter\n"); if (dev == NULL) return; stv680_close (dev); if (dev->devicename) { free (dev->devicename); } if (dev->buffer) { free (dev->buffer); } if (dev->output) { free (dev->output); } if (dev->image) { free (dev->image); } if (dev->windoww) { free (dev->windoww); } if (dev->windowr) { free (dev->windowr); } for (i = 1; i < OPT_NUM_OPTIONS; i++) { if (dev->opt[i].type == SANE_TYPE_STRING && dev->val[i].s) { free (dev->val[i].s); } } if (dev->resolutions_list) free (dev->resolutions_list); free (dev); DBG (DBG_proc, "stv680_free: exit\n"); } static SANE_Status stv680_set_config (Stv680_Vidcam * dev, int configuration, int interface, int alternate) { SANE_Status status; DBG (DBG_proc, "stv680_set_config: open\n"); /* seems a problem on some systems (Debian amd64 unstable 19042006) * not calling usb_set_configuration seems to help reason ? status = sanei_usb_set_configuration (dev->fd, configuration); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_set_config: STV680 FAILED to set configuration %d\n", configuration); return status; } */ status = sanei_usb_claim_interface (dev->fd, interface); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_set_config: STV0680 FAILED to claim interface\n"); return status; } status = sanei_usb_set_altinterface (dev->fd, alternate); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_set_config: STV0680 FAILED to set alternate interface %d\n", alternate); return status; } DBG (DBG_proc, "stv680_set_config: configuration=%d, interface=%d, alternate=%d\n", configuration, interface, alternate); DBG (DBG_proc, "stv680_set_config: exit\n"); return status; } /* Reset vidcam */ static SANE_Status stv680_reset_vidcam (Stv680_Vidcam * dev) { SANE_Status status; size_t sizew; /* significant size of window */ size_t sizer; DBG (DBG_proc, "stv680_reset_vidcam: enter\n"); sizew = dev->windoww_size; sizer = dev->windowr_size; memset (dev->windoww, 0, sizew); memset (dev->windowr, 0, sizer); sizew = 0x00; /* was 0 ? */ status = sanei_usb_control_msg (dev->fd, 0x41, 0x0a, 0x0000, 0, sizew, dev->windoww); if (status != SANE_STATUS_GOOD) { return status; } DBG (DBG_proc, "stv680_reset_vidcam: CMDID_STOP_VIDEO end\n"); /* this is a high priority command; it stops all lower order commands */ sizew = 0x00; /* was 0 */ status = sanei_usb_control_msg (dev->fd, 0x41, 0x04, 0x0000, 0, sizew, dev->windoww); if (status != SANE_STATUS_GOOD) { return status; } DBG (DBG_proc, "stv680_reset_vidcam: CMDID_CANCEL_TRANSACTION end\n"); sizer = 0x02; DBG (DBG_proc, "stv680_reset_vidcam: CMDID_GET_LAST_ERROR begin\n"); status = sanei_usb_control_msg (dev->fd, 0xc1, 0x80, 0x0000, 0, sizer, dev->windowr); if (status != SANE_STATUS_GOOD) { /* Get Last Error; 2 = busy */ DBG (DBG_proc, "stv680_reset_vidcam: last error: %i, command = 0x%x\n", dev->windowr[0], dev->windowr[1]); return status; } else { DBG (DBG_proc, "stv680_reset_vidcam: Camera reset to idle mode.\n"); } hexdump (DBG_info2, "stv680_reset_vidcam: CMDID_GET_LAST_ERROR", dev->windowr, sizer); /* configuration = 1, interface = 0, alternate = 0 */ /* status = stv680_set_config (dev, 1, 0, 0); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_reset_vidcam: STV680 FAILED to set configure\n"); return status; } */ status = SANE_STATUS_GOOD; DBG (DBG_proc, "stv680_reset_vidcam: exit\n"); return status; } /* Inquiry a device and returns TRUE if is supported. */ static int stv680_identify_vidcam (Stv680_Vidcam * dev) { SANE_Status status; SANE_Word vendor; SANE_Word product; int i; size_t sizer; DBG (DBG_info, "stv680_identify_vidcam: open\n"); status = sanei_usb_get_vendor_product (dev->fd, &vendor, &product); /* Loop through our list to make sure this scanner is supported. */ for (i = 0; i < NELEMS (vidcams); i++) { if (vidcams[i].vendor == vendor && vidcams[i].product == product) { DBG (DBG_info, "stv680_identify_vidcam: vidcam %x:%x is in list\n", vendor, product); dev->hw = &(vidcams[i]); sizer = dev->windowr_size; memset (dev->windowr, 0, sizer); /* configuration = 1, interface = 0, alternate = 0 */ /* status = stv680_set_config (dev, 1, 0, 0); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_vidcam_init: STV680 FAILED to set configure\n"); return status; } */ sizer = 0x02; status = sanei_usb_control_msg (dev->fd, 0xc1, 0x88, 0x5678, 0, sizer, dev->windowr); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_identify_vidcam: this is not a STV680 (idVendor = %d, bProduct = %d) writing register failed with %s\n", vendor, product, sane_strstatus (status)); return SANE_FALSE; } if ((dev->windowr[0] != 0x56) || (dev->windowr[1] != 0x78)) { DBG (DBG_proc, "STV(e): camera ping failed!!, checkvalue !=0x5678\n"); sizer = 0x02; hexdump (DBG_info2, "urb12 window", dev->windowr, sizer); return SANE_FALSE; } sizer = 0x02; hexdump (DBG_info2, "urb12 ping data", dev->windowr, sizer); sizer = 0x10; status = sanei_usb_control_msg (dev->fd, 0xc1, 0x85, 0x0000, 0, sizer, dev->windowr); if (status != SANE_STATUS_GOOD) return SANE_FALSE; hexdump (DBG_info2, "urbxx CMDID_GET_CAMERA_INFO", dev->windowr, sizer); dev->SupportedModes = dev->windowr[7]; i = dev->SupportedModes; dev->QSIF = 0; dev->CIF = 0; dev->QCIF = 0; dev->VGA = 0; dev->QVGA = 0; if (i & 1) dev->CIF = 1; if (i & 2) dev->VGA = 1; if (i & 8) dev->QVGA = 1; if (i & 4) dev->QCIF = 1; dev->QSIF = dev->QVGA; /* for software subsample */ if (dev->SupportedModes == 0) { DBG (DBG_proc, "STV(e): There are NO supported STV680 modes!!\n"); i = -1; return SANE_FALSE; } else { if (dev->VGA) DBG (DBG_proc, "STV(i): VGA is supported\n"); if (dev->CIF) DBG (DBG_proc, "STV(i): CIF is supported\n"); if (dev->QVGA) DBG (DBG_proc, "STV(i): QVGA is supported\n"); if (dev->QCIF) DBG (DBG_proc, "STV(i): QCIF is supported\n"); } /* FW rev, ASIC rev, sensor ID */ DBG (DBG_proc, "STV(i): Firmware rev is %i.%i\n", dev->windowr[0], dev->windowr[1]); DBG (DBG_proc, "STV(i): ASIC rev is %i.%i\n", dev->windowr[2], dev->windowr[3]); DBG (DBG_proc, "STV(i): Sensor ID is %i.%i\n", (dev->windowr[4]), (dev->windowr[5])); /* Hardware config */ dev->HardwareConfig = dev->windowr[6]; i = dev->HardwareConfig; /* Comms link, Flicker freq, Mem size */ if (i & 1) DBG (DBG_proc, "STV(i): Comms link is serial\n"); else DBG (DBG_proc, "STV(i): Comms link is USB\n"); if (i & 2) DBG (DBG_proc, "STV(i): Flicker freq = 60 Hz\n"); else DBG (DBG_proc, "STV(i): Flicker freq = 50 Hz\n"); if (i & 4) DBG (DBG_proc, "STV(i): Mem size = 16Mbit\n"); else DBG (DBG_proc, "STV(i): Mem size = 64Mbit\n"); if (i & 8) DBG (DBG_proc, "STV(i): Thumbnails supported\n"); else DBG (DBG_proc, "STV(i): Thumbnails N/A\n"); if (i & 16) DBG (DBG_proc, "STV(i): Video supported\n"); else DBG (DBG_proc, "STV(i): Video N/A\n"); if (i & 32) DBG (DBG_proc, "STV(i): Startup Complete\n"); else DBG (DBG_proc, "STV(i): Startup Not Complete\n"); if (i & 64) DBG (DBG_proc, "STV(i): Monochrome\n"); else DBG (DBG_proc, "STV(i): Color\n"); if (i & 128) DBG (DBG_proc, "STV(i): Mem fitted\n"); else DBG (DBG_proc, "STV(i): Mem not fitted\n"); DBG (DBG_proc, "urb 25 CMDID_GET_IMAGE_INFO\n"); sizer = 0x10; status = sanei_usb_control_msg (dev->fd, 0xc1, 0x86, 0x0000, 0, sizer, dev->windowr); if (status != SANE_STATUS_GOOD) { return SANE_FALSE; } hexdump (DBG_info2, "urb25 CMDID_GET_IMAGE_INFO", dev->windowr, sizer); DBG (DBG_proc, "STV(i): Current image index %d\n", ((dev->windowr[0] << 8) + (dev->windowr[1]))); DBG (DBG_proc, "If images are stored in camera, they will be lost when captering images is started!!!!!\n"); DBG (DBG_proc, "STV(i): Max images %d\n", ((dev->windowr[2] << 8) + (dev->windowr[3]))); DBG (DBG_proc, "STV(i): Image width (pix) %d\n", ((dev->windowr[4] << 8) + (dev->windowr[5]))); DBG (DBG_proc, "STV(i): Image height (pix) %d\n", ((dev->windowr[6] << 8) + (dev->windowr[7]))); DBG (DBG_proc, "STV(i): Image size camera %d bytes\n", ((dev->windowr[8] << 24) + (dev->windowr[9] << 16) + (dev->windowr[10] << 8) + (dev->windowr[11]))); /* configuration = 1, interface = 0, alternate = 1 */ status = stv680_set_config (dev, 1, 0, 1); /* if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_vidcam_init: STV680 FAILED to set configure\n"); return status; } DBG (DBG_info, "stv680_identify_vidcam: exit vidcam supported\n"); */ return SANE_TRUE; } } DBG (DBG_error, "stv680_identify_vidcam: exit this is not a STV680 exit\n"); return SANE_FALSE; } static SANE_Status stv680_vidcam_init (Stv680_Vidcam * dev) { SANE_Status status; SANE_Byte i = 0; SANE_Byte val = 0; size_t sizer; size_t sizew; DBG (DBG_proc, "stv680_vidcam_init: open\n"); sizew = dev->windoww_size; sizer = dev->windowr_size; memset (dev->windoww, 0, sizew); memset (dev->windowr, 0, sizer); DBG (DBG_proc, "stv680_vidcam_init: urb 13 CMDID_GET_USER_INFO\n"); dev->video_status = 0x04; /* dummy value busy */ while (dev->video_status == 0x04) { sizer = 0x08; status = sanei_usb_control_msg (dev->fd, 0xc1, 0x8d, 0x0000, 0, sizer, dev->windowr); if (status != SANE_STATUS_GOOD) return status; hexdump (DBG_info2, "stv680_vidcam_init: urb13 CMDID_GET_USER_INFO", dev->windowr, sizer); dev->video_status = dev->windowr[1]; if (dev->video_status == 0x02) { DBG (DBG_proc, "stv680_vidcam_init: status = video\n"); } else if ((dev->video_status == 0x01) || (dev->video_status == 0x08)) { DBG (DBG_proc, "stv680_vidcam_init: status=%d\n", dev->video_status); } else if (dev->video_status != 0x04) { DBG (DBG_proc, "stv680_vidcam_init: status = busy\n"); /* CMDID_CANCEL_TRANSACTION */ status = sanei_usb_control_msg (dev->fd, 0x41, 0x04, 0x0000, 0, 0, 0); if (status != SANE_STATUS_GOOD) { DBG (DBG_info, "stv680_vidcam_init: urb13 CMDID_CANCEL_TRANSACTION NOK\n"); return status; } } } if (dev->video_status == 0x01 || dev->video_status == 0x08) { DBG (DBG_proc, "stv680_vidcam_init: urb 21 CMDID_GET_COLDATA_SIZE\n"); sizer = 0x02; status = sanei_usb_control_msg (dev->fd, 0xc1, 0x8a, 0x0000, 0, sizer, dev->windowr); if (status != SANE_STATUS_GOOD) return status; val = dev->windowr[0]; hexdump (DBG_info2, "stv680_vidcam_init: urb21 CMDID_GET_COLDATA_SIZE", dev->windowr, sizer); if (dev->windowr[0] &= 0x00) DBG (DBG_info, "stv680_vidcam_init: no camera defaults, must be downloaded?\n"); sizer = 0x10; for (i = 0; i < val; i += 0x10) { DBG (DBG_proc, "stv680_vidcam_init: urb 22, 23, 24 CMDID_GET_COLDATA i=0x%x, val=0x%x\n", i, val); status = sanei_usb_control_msg (dev->fd, 0xc1, 0x8b, (i << 8), 0, sizer, dev->windowr); if (status != SANE_STATUS_GOOD) return status; hexdump (DBG_info2, "stv680_vidcam_init: urb22, 23, 24 CMDID_GET_COLDATA", dev->windowr, sizer); } sizer = 0x12; status = sanei_usb_control_msg (dev->fd, 0x80, 0x06, 0x0100, 0, sizer, dev->windowr); if (status != SANE_STATUS_GOOD) return status; /* if (!(i > 0) && (dev->windowr[8] == 0x53) && (dev->windowr[9] == 0x05)) { DBG (DBG_proc, "STV(e): Could not get descriptor 0100."); *//* return status; *//* } */ sizer = 0x12; hexdump (DBG_info2, "stv680_vidcam_init: CMDID_SET_IMAGE_INDEX", dev->windowr, sizer); /* configuration = 1, interface = 0, alternate = 1 */ status = stv680_set_config (dev, 1, 0, 1); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_vidcam_init: STV680 FAILED to set configure\n"); return status; } } /* Switch to Video mode: 0x0000 = CIF (352x288), 0x0200 = QCIF (176x144) */ /* Switch to Video mode: 0x0100 = VGA (640x480), 0x0300 = QVGA (320x240) */ sizew = 0x0; status = sanei_usb_control_msg (dev->fd, 0x41, 0x09, dev->video_mode, 0, sizew, dev->windoww); if (status != SANE_STATUS_GOOD) { DBG (DBG_proc, "stv680_vidcam_init: video_mode = 0x%x\n", dev->video_mode); return status; } DBG (DBG_proc, "stv680_vidcam_init: CMDID_START_VIDEO: video_mode=0x%x\n", dev->video_mode); if (dev->x_resolution == 176) { usleep (1000); /* delay time needed */ } status = SANE_STATUS_GOOD; if (status) { DBG (DBG_error, "stv680_vidcam_init failed : %s\n", sane_strstatus (status)); return status; } DBG (DBG_proc, "stv680_vidcam_init: exit\n"); return status; } /* Attach a vidcam to this backend. */ static SANE_Status attach_vidcam (SANE_String_Const devicename, Stv680_Vidcam ** devp) { Stv680_Vidcam *dev; int fd; SANE_Status status; DBG (DBG_proc, "attach_vidcam: %s\n", devicename); if (devp) *devp = NULL; /* Check if we know this device name. */ for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { if (devp) { *devp = dev; } DBG (DBG_info, "device is already known\n"); return SANE_STATUS_GOOD; } } /* Allocate a new vidcam entry. */ dev = stv680_init (); if (dev == NULL) { DBG (DBG_error, "stv680_init ERROR: not enough memory\n"); return SANE_STATUS_NO_MEM; } DBG (DBG_info, "attach_vidcam: opening USB device %s\n", devicename); if (sanei_usb_open (devicename, &fd) != 0) { DBG (DBG_error, "ERROR: attach_vidcam: open failed\n"); stv680_free (dev); return SANE_STATUS_INVAL; } /* Fill some scanner specific values. */ dev->devicename = strdup (devicename); dev->fd = fd; /* Now, check that it is a vidcam we support. */ if (stv680_identify_vidcam (dev) == SANE_FALSE) { DBG (DBG_error, "ERROR: attach_vidcam: vidcam-identification failed\n"); stv680_free (dev); return SANE_STATUS_INVAL; } /* Allocate a buffer memory. */ status = stv680_init_2 (dev); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "stv680_initi_2, ERROR: not enough memory\n"); return SANE_STATUS_NO_MEM; } stv680_close (dev); DBG (DBG_info, "attach_vidcam: opening USB device %s\n", devicename); /* Build list of vidcam supported resolutions. */ DBG (DBG_proc, "attach_vidcam: build resolution list\n"); if (dev->hw->color_adjust[0].resolution_x != 0) { int num_entries; int i; num_entries = 0; while (dev->hw->color_adjust[num_entries].resolution_x != 0) num_entries++; dev->resolutions_list = malloc (sizeof (SANE_Word) * (num_entries + 1)); if (dev->resolutions_list == NULL) { DBG (DBG_error, "ERROR: attach_vidcam: vidcam resolution list failed\n"); stv680_free (dev); return SANE_STATUS_NO_MEM; } /* for CIF or VGA sensor different resolutions */ if (dev->CIF) num_entries = 2; if (dev->VGA) num_entries = 3; dev->resolutions_list[0] = num_entries; DBG (DBG_proc, "attach_vidcam: make color resolution table \n"); for (i = 0; i < num_entries; i++) { dev->resolutions_list[i + 1 + dev->VGA + dev->QVGA] = dev->hw->color_adjust[i].resolution_x; } } else { dev->resolutions_list = NULL; } /* Set the default options for that vidcam. */ dev->sane.name = dev->devicename; dev->sane.vendor = dev->hw->vendor_name; dev->sane.model = dev->hw->product_name; dev->sane.type = SANE_I18N ("webcam"); /* Link the vidcam with the others. */ dev->next = first_dev; first_dev = dev; if (devp) { *devp = dev; } num_devices++; DBG (DBG_proc, "attach_vidcam: exit\n"); return SANE_STATUS_GOOD; } static SANE_Status attach_one (const char *dev) { DBG (DBG_proc, "attach_one: open \n"); attach_vidcam (dev, NULL); DBG (DBG_proc, "attach_one: exit \n"); return SANE_STATUS_GOOD; } /* Reset the options for that vidcam. */ static void stv680_init_options (Stv680_Vidcam * dev) { int i; DBG (DBG_proc, "stv680_init_options: open\n"); /* Pre-initialize the options. */ memset (dev->opt, 0, sizeof (dev->opt)); memset (dev->val, 0, sizeof (dev->val)); for (i = 0; i < OPT_NUM_OPTIONS; ++i) { dev->opt[i].size = sizeof (SANE_Word); dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } DBG (DBG_proc, "stv680_init_options: done loop opt_num_options=%d, i=%d \n", OPT_NUM_OPTIONS, i); /* Number of options. */ dev->opt[OPT_NUM_OPTS].name = ""; dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; dev->val[OPT_NUM_OPTS].w = OPT_NUM_OPTIONS; /* Mode group */ dev->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); dev->opt[OPT_MODE_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_MODE_GROUP].cap = 0; dev->opt[OPT_MODE_GROUP].size = 0; dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Vidcam supported modes */ 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_mode_list); dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_MODE].constraint.string_list = scan_mode_list; dev->val[OPT_MODE].s = (SANE_Char *) strdup (""); /* will be set later */ /* X and Y resolution */ 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].unit = SANE_UNIT_DPI; dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; dev->val[OPT_RESOLUTION].w = dev->resolutions_list[dev->CIF + dev->QCIF + dev->VGA + dev->QVGA + dev->QSIF]; /* value will be 2 or 3 */ /* brightness */ dev->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; dev->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; dev->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; dev->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; dev->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; dev->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BRIGHTNESS].constraint.range = &brightness_range; dev->val[OPT_BRIGHTNESS].w = 0; /* to get middle value */ /* Enhancement group */ dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); dev->opt[OPT_ENHANCEMENT_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; dev->opt[OPT_ENHANCEMENT_GROUP].size = 0; dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* red level calibration manual correction */ dev->opt[OPT_WHITE_LEVEL_R].name = SANE_NAME_WHITE_LEVEL_R; dev->opt[OPT_WHITE_LEVEL_R].title = SANE_TITLE_WHITE_LEVEL_R; dev->opt[OPT_WHITE_LEVEL_R].desc = SANE_DESC_WHITE_LEVEL_R; dev->opt[OPT_WHITE_LEVEL_R].type = SANE_TYPE_INT; dev->opt[OPT_WHITE_LEVEL_R].unit = SANE_UNIT_NONE; dev->opt[OPT_WHITE_LEVEL_R].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_WHITE_LEVEL_R].constraint.range = &red_level_range; dev->val[OPT_WHITE_LEVEL_R].w = 00; /* to get middle value */ /* green level calibration manual correction */ dev->opt[OPT_WHITE_LEVEL_G].name = SANE_NAME_WHITE_LEVEL_G; dev->opt[OPT_WHITE_LEVEL_G].title = SANE_TITLE_WHITE_LEVEL_G; dev->opt[OPT_WHITE_LEVEL_G].desc = SANE_DESC_WHITE_LEVEL_G; dev->opt[OPT_WHITE_LEVEL_G].type = SANE_TYPE_INT; dev->opt[OPT_WHITE_LEVEL_G].unit = SANE_UNIT_NONE; dev->opt[OPT_WHITE_LEVEL_G].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_WHITE_LEVEL_G].constraint.range = &green_level_range; dev->val[OPT_WHITE_LEVEL_G].w = 00; /* to get middle value */ /* blue level calibration manual correction */ dev->opt[OPT_WHITE_LEVEL_B].name = SANE_NAME_WHITE_LEVEL_B; dev->opt[OPT_WHITE_LEVEL_B].title = SANE_TITLE_WHITE_LEVEL_B; dev->opt[OPT_WHITE_LEVEL_B].desc = SANE_DESC_WHITE_LEVEL_B; dev->opt[OPT_WHITE_LEVEL_B].type = SANE_TYPE_INT; dev->opt[OPT_WHITE_LEVEL_B].unit = SANE_UNIT_NONE; dev->opt[OPT_WHITE_LEVEL_B].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_WHITE_LEVEL_B].constraint.range = &blue_level_range; dev->val[OPT_WHITE_LEVEL_B].w = 00; /* to get middle value */ DBG (DBG_proc, "stv680_init_options: after blue level\n"); /* Lastly, set the default scan mode. This might change some * values previously set here. */ sane_control_option (dev, OPT_MODE, SANE_ACTION_SET_VALUE, (SANE_String_Const *) scan_mode_list[0], NULL); DBG (DBG_proc, "stv680_init_options: exit\n"); } /* Read the image from the vidcam and fill the temporary buffer with it. */ static SANE_Status stv680_fill_image (Stv680_Vidcam * dev) { SANE_Status status; size_t size; size_t bulk_size_read; assert (dev->image_begin == dev->image_end); assert (dev->real_bytes_left > 0); DBG (DBG_proc, "stv680_fill_image: enter\n"); DBG (DBG_proc, "stv680_fill_image: real dev bytes left=0x%lx \n", (unsigned long) (size_t) dev->real_bytes_left); bulk_size_read = dev->real_bytes_left; while (dev->real_bytes_left) { /* Try to read the maximum number of bytes. */ DBG (DBG_proc, "stv680_fill_image: real dev bytes left, while loop=0x%lx \n", (unsigned long) (size_t) dev->real_bytes_left); size = dev->real_bytes_left; if (size < bulk_size_read) { size = bulk_size_read; /* it seems size can not be smaller then read by bulk */ } if (size == 0) { /* Probably reached the end of the buffer. Check, just in case. */ assert (dev->image_end != 0); return (SANE_STATUS_GOOD); } /* Do the transfer */ DBG (DBG_proc, "stv680_fill_image: dev->real_bytes_left: 0x%lx size: 0x%lx\n", (unsigned long) (size_t) dev->real_bytes_left, (unsigned long) (size_t) size); usleep (3000); /* urb 44 first read bulk */ status = sanei_usb_read_bulk (dev->fd, dev->buffer, &size); if (status != SANE_STATUS_GOOD) { return status; } DBG (DBG_info, "stv680_fill_image: size (read) = 0x%lx bytes (bpl=0x%lx)\n", (unsigned long) (size_t) size, (unsigned long) (size_t) dev->params.bytes_per_line); memcpy (dev->image + dev->image_end, dev->buffer, size); dev->image_end += size; bulk_size_read = size; if (dev->real_bytes_left > size) dev->real_bytes_left -= size; else if (dev->real_bytes_left <= size) /* last loop */ dev->real_bytes_left = 0; DBG (DBG_info, "stv680_fill_image: real bytes left = 0x%lx\n", (unsigned long) (size_t) dev->real_bytes_left); } /* i = stv_sndctrl (0, dev, 0x80, 0, &window, 0x02); *//* Get Last Error */ /* DBG (DBG_proc, "STV(i): last error: %i, command = 0x%x", window[0], window[1]); return -1; */ /* } return 0; */ DBG (DBG_proc, "stv680_fill_image: exit\n"); return (SANE_STATUS_GOOD); /* unreachable */ } #define MSG_MAXLEN 45 #define TEXT_CHAR_HEIGHT 11 #define TEXT_CHAR_WIDTH 6 #define CHAR_START 4 static SANE_Status stv680_add_text (SANE_Byte * image, int width, int height, char *txt) { SANE_Status status; time_t t; struct tm *tm; char line[MSG_MAXLEN + 1]; SANE_Byte *ptr; int i, x, y, f, len; char fmtstring[25] = " %Y-%m-%d %H:%M:%S"; char fmttxt[46]; DBG (DBG_proc, "stv680_add_text: enter\n"); time (&t); tm = localtime (&t); if (strlen (txt) > (MSG_MAXLEN - 23)) strncpy (fmttxt, txt, (MSG_MAXLEN - 23)); else strcpy (fmttxt, txt); strcat (fmttxt, fmtstring); len = strftime (line, MSG_MAXLEN, fmttxt, tm); for (y = 0; y < TEXT_CHAR_HEIGHT; y++) { ptr = image + 3 * width * (height - TEXT_CHAR_HEIGHT - 2 + y) + 12; for (x = 0; x < len; x++) { f = fontdata[line[x] * TEXT_CHAR_HEIGHT + y]; for (i = TEXT_CHAR_WIDTH - 1; i >= 0; i--) { if (f & (CHAR_START << i)) { ptr[0] = 255; ptr[1] = 255; ptr[2] = 255; } ptr += 3; } /* for i */ } /* for x */ } /* for y */ DBG (DBG_proc, "stv680_add_text: exit vw=%d, vh=%d\n", width, height); status = (SANE_STATUS_GOOD); return status; } /* ************************** Video Decoding ********************* */ static SANE_Status stv680_bayer_unshuffle (Stv680_Vidcam * dev, SANE_Byte * buf, size_t * size) { SANE_Status status; int x, y; int i = 0; int RED, GREEN, BLUE; int w = dev->cwidth; int vw = dev->x_resolution; int vh = dev->y_resolution; SANE_Byte p = 0; int colour = 0, bayer = 0; int bright_red; int bright_green; int bright_blue; int count; RED = dev->red_s; GREEN = dev->green_s; BLUE = dev->blue_s; DBG (DBG_proc, "stv680_bayer_unshuffle: enter\n"); #define AD(x, y, w) (((y)*(w)+(x))*3) DBG (DBG_proc, "stv680_bayer_unshuffle: color read RED=%d, GREEN=%d, BLUE=%d\n", RED, GREEN, BLUE); DBG (DBG_proc, "stv680_bayer_unshuffle: w=%d, vw=%d, vh=%d, len=0x%lx\n", w, vw, vh, (unsigned long) (size_t) size); for (y = 0; y < vh; y++) { for (x = 0; x < vw; x++) { if (x & 1) { p = dev->image[y * w + (x >> 1)]; } else { p = dev->image[y * w + (x >> 1) + (w >> 1)]; } if (y & 1) bayer = 2; else bayer = 0; if (x & 1) bayer++; switch (bayer) { case 0: case 3: colour = 1; break; case 1: colour = 0; break; case 2: colour = 2; break; } i = (y * vw + x) * 3; *(dev->output + i + colour) = (SANE_Byte) p; } /* for x */ } /* for y */ /****** gamma correction plus hardcoded white balance */ /* Correction values red[], green[], blue[], are generated by (pow(i/256.0, GAMMA)*255.0)*white balanceRGB where GAMMA=0.55, 1scan_mode == STV680_COLOR_RGB || dev->scan_mode == STV680_COLOR_RGB_TEXT) { for (y = 0; y < vh; y++) { for (x = 0; x < vw; x++) { i = (y * vw + x) * 3; *(dev->output + i) = red_g[*(dev->output + i)]; *(dev->output + i + 1) = green_g[*(dev->output + i + 1)]; *(dev->output + i + 2) = blue_g[*(dev->output + i + 2)]; } } } DBG (DBG_proc, "stv680_bayer_unshuffle: gamma correction done\n"); if (dev->scan_mode != STV680_COLOR_RAW) { /****** bayer demosaic ******/ for (y = 1; y < (vh - 1); y++) { for (x = 1; x < (vw - 1); x++) { /* work out pixel type */ if (y & 1) bayer = 0; else bayer = 2; if (!(x & 1)) bayer++; switch (bayer) { case 0: /* green. blue lr, red tb */ *(dev->output + AD (x, y, vw) + BLUE) = ((int) *(dev->output + AD (x - 1, y, vw) + BLUE) + (int) *(dev->output + AD (x + 1, y, vw) + BLUE)) >> 1; *(dev->output + AD (x, y, vw) + RED) = ((int) *(dev->output + AD (x, y - 1, vw) + RED) + (int) *(dev->output + AD (x, y + 1, vw) + RED)) >> 1; break; case 1: /* blue. green lrtb, red diagonals */ *(dev->output + AD (x, y, vw) + GREEN) = ((int) *(dev->output + AD (x - 1, y, vw) + GREEN) + (int) *(dev->output + AD (x + 1, y, vw) + GREEN) + (int) *(dev->output + AD (x, y - 1, vw) + GREEN) + (int) *(dev->output + AD (x, y + 1, vw) + GREEN)) >> 2; *(dev->output + AD (x, y, vw) + RED) = ((int) *(dev->output + AD (x - 1, y - 1, vw) + RED) + (int) *(dev->output + AD (x - 1, y + 1, vw) + RED) + (int) *(dev->output + AD (x + 1, y - 1, vw) + RED) + (int) *(dev->output + AD (x + 1, y + 1, vw) + RED)) >> 2; break; case 2: /* red. green lrtb, blue diagonals */ *(dev->output + AD (x, y, vw) + GREEN) = ((int) *(dev->output + AD (x - 1, y, vw) + GREEN) + (int) *(dev->output + AD (x + 1, y, vw) + GREEN) + (int) *(dev->output + AD (x, y - 1, vw) + GREEN) + (int) *(dev->output + AD (x, y + 1, vw) + GREEN)) >> 2; *(dev->output + AD (x, y, vw) + BLUE) = ((int) *(dev->output + AD (x - 1, y - 1, vw) + BLUE) + (int) *(dev->output + AD (x + 1, y - 1, vw) + BLUE) + (int) *(dev->output + AD (x - 1, y + 1, vw) + BLUE) + (int) *(dev->output + AD (x + 1, y + 1, vw) + BLUE)) >> 2; break; case 3: /* green. red lr, blue tb */ *(dev->output + AD (x, y, vw) + RED) = ((int) *(dev->output + AD (x - 1, y, vw) + RED) + (int) *(dev->output + AD (x + 1, y, vw) + RED)) >> 1; *(dev->output + AD (x, y, vw) + BLUE) = ((int) *(dev->output + AD (x, y - 1, vw) + BLUE) + (int) *(dev->output + AD (x, y + 1, vw) + BLUE)) >> 1; break; } /* switch */ } /* for x */ } /* for y - end demosaic */ } /* no bayer demosaic */ DBG (DBG_proc, "stv680_bayer_unshuffle: bayer demosaic done\n"); /* fix top and bottom row, left and right side */ i = vw * 3; memcpy (dev->output, (dev->output + i), i); memcpy ((dev->output + (vh * i)), (dev->output + ((vh - 1) * i)), i); for (y = 0; y < vh; y++) { i = y * vw * 3; memcpy ((dev->output + i), (dev->output + i + 3), 3); memcpy ((dev->output + i + (vw * 3)), (dev->output + i + (vw - 1) * 3), 3); } /* process all raw data, then trim to size if necessary */ if (dev->subsample == 160) { i = 0; for (y = 0; y < vh; y++) { if (!(y & 1)) { for (x = 0; x < vw; x++) { p = (y * vw + x) * 3; if (!(x & 1)) { *(dev->output + i) = *(dev->output + p); *(dev->output + i + 1) = *(dev->output + p + 1); *(dev->output + i + 2) = *(dev->output + p + 2); i += 3; } } /* for x */ } } /* for y */ DBG (DBG_proc, "stv680_bayer_unshuffle: if needed, trim to size 160 done\n"); } /* reset to proper width */ if ((dev->subsample == 160)) { vw = 160; vh = 120; } /* brightness adjustment */ count = vw * vh * 3; bright_red = (dev->val[OPT_BRIGHTNESS].w) + (dev->val[OPT_WHITE_LEVEL_R].w); bright_green = (dev->val[OPT_BRIGHTNESS].w) + (dev->val[OPT_WHITE_LEVEL_G].w); bright_blue = (dev->val[OPT_BRIGHTNESS].w) + (dev->val[OPT_WHITE_LEVEL_B].w); for (x = 0; x < count; x++) { y = x + 1; i = x + 2; if ((*(dev->output + x) + bright_red) >= 255) *(buf + x) = 255; else if ((*(dev->output + x) + bright_red) <= 0) *(buf + x) = 0; else *(buf + x) = (*(dev->output + x) + bright_red); if ((*(dev->output + y) + bright_green) >= 255) *(buf + y) = 255; else if ((*(dev->output + y) + bright_green) <= 0) *(buf + y) = 0; else *(buf + y) = (*(dev->output + y) + bright_green); if ((*(dev->output + i) + bright_blue) >= 255) *(buf + i) = 255; else if ((*(dev->output + i) + bright_blue) <= 0) *(buf + i) = 0; else *(buf + i) = (*(dev->output + i) + bright_blue); x += 2; } if (dev->scan_mode == STV680_COLOR_RGB_TEXT) { strcpy (dev->picmsg_ps, "STVcam "); status = stv680_add_text (buf, vw, vh, dev->picmsg_ps); if (status != SANE_STATUS_GOOD) { DBG (DBG_info, "stv680_bayer_unshuffle status NOK\n"); return (status); } } DBG (DBG_proc, "stv680_bayer_unshuffle: exit vw=%d, vh=%d\n", vw, vh); status = (SANE_STATUS_GOOD); return status; } /* Sane entry points */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { FILE *fp; char line[PATH_MAX]; size_t len; num_devices = 0; devlist = NULL; first_dev = NULL; DBG_INIT (); DBG (DBG_sane_init, "sane_init\n"); authorize = authorize; /* silence gcc */ DBG (DBG_error, "This is sane-stv680 version %d.%d-%d\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (DBG_error, "(C) 2004-2006 by Gerard Klaver\n"); if (version_code) { *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); } DBG (DBG_proc, "sane_init: authorize %s null\n", authorize ? "!=" : "=="); sanei_usb_init (); fp = sanei_config_open (STV680_CONFIG_FILE); if (!fp) { /* No default vidcam? */ DBG (DBG_warning, "configuration file not found (%s)\n", STV680_CONFIG_FILE); return SANE_STATUS_GOOD; } while (sanei_config_read (line, sizeof (line), fp)) { SANE_Word vendor; SANE_Word product; if (line[0] == '#') /* ignore line comments */ continue; len = strlen (line); if (!len) continue; /* ignore empty lines */ if (sscanf (line, "usb %i %i", &vendor, &product) == 2) { sanei_usb_attach_matching_devices (line, attach_one); } else { /* Garbage. Ignore. */ DBG (DBG_warning, "bad configuration line: \"%s\" - ignoring.\n", line); } } fclose (fp); DBG (DBG_proc, "sane_init: leave\n"); return SANE_STATUS_GOOD; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Stv680_Vidcam *dev; int i; DBG (DBG_proc, "sane_get_devices: enter\n"); local_only = local_only; /* silence gcc */ if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (DBG_proc, "sane_get_devices: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Stv680_Vidcam *dev; SANE_Status status; DBG (DBG_proc, "sane_open: enter\n"); /* search for devicename */ if (devicename[0]) { DBG (DBG_info, "sane_open: devicename=%s\n", devicename); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { break; } } if (!dev) { status = attach_vidcam (devicename, &dev); if (status != SANE_STATUS_GOOD) { return status; } } } else { DBG (DBG_sane_info, "sane_open: no devicename, opening first device\n"); dev = first_dev; /* empty devicename -> use first device */ } if (!dev) { DBG (DBG_error, "No vidcam found\n"); return SANE_STATUS_INVAL; } stv680_init_options (dev); *handle = dev; DBG (DBG_proc, "sane_open: exit\n"); return SANE_STATUS_GOOD; } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Stv680_Vidcam *dev = handle; DBG (DBG_proc, "sane_get_option_descriptor: enter, option %d\n", option); if ((unsigned) option >= OPT_NUM_OPTIONS) { return NULL; } DBG (DBG_proc, "sane_get_option_descriptor: exit\n"); return dev->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Stv680_Vidcam *dev = handle; SANE_Status status; SANE_Word cap; DBG (DBG_proc, "sane_control_option: enter, option %d, action %d\n", option, action); if (info) { *info = 0; } if (dev->scanning) { return SANE_STATUS_DEVICE_BUSY; } if (option < 0 || option >= OPT_NUM_OPTIONS) { return SANE_STATUS_INVAL; } cap = dev->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { return SANE_STATUS_INVAL; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options */ case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_BRIGHTNESS: case OPT_WHITE_LEVEL_R: case OPT_WHITE_LEVEL_G: case OPT_WHITE_LEVEL_B: *(SANE_Word *) val = dev->val[option].w; return SANE_STATUS_GOOD; case OPT_MODE: strcpy (val, dev->val[option].s); return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (DBG_error, "could not set option, not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (dev->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "could not set option, invalid value\n"); return status; } switch (option) { /* Numeric side-effect options */ case OPT_RESOLUTION: case OPT_BRIGHTNESS: case OPT_WHITE_LEVEL_R: case OPT_WHITE_LEVEL_G: case OPT_WHITE_LEVEL_B: if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } dev->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* String side-effect options */ case OPT_MODE: if (strcmp (dev->val[option].s, val) == 0) return SANE_STATUS_GOOD; free (dev->val[OPT_MODE].s); dev->val[OPT_MODE].s = (SANE_Char *) strdup (val); dev->opt[OPT_WHITE_LEVEL_R].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_WHITE_LEVEL_G].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_WHITE_LEVEL_B].cap &= ~SANE_CAP_INACTIVE; if (strcmp (dev->val[OPT_MODE].s, COLOR_RAW_STR) == 0) { dev->scan_mode = STV680_COLOR_RAW; } else if (strcmp (dev->val[OPT_MODE].s, COLOR_RGB_STR) == 0) { dev->scan_mode = STV680_COLOR_RGB; } else if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dev->scan_mode = STV680_COLOR; } else if (strcmp (dev->val[OPT_MODE].s, COLOR_RGB_TEXT_STR) == 0) { dev->scan_mode = STV680_COLOR_RGB_TEXT; } /* The STV680 supports only a handful of resolution. */ /* This the default resolution range for the STV680 */ dev->depth = 8; if (dev->resolutions_list != NULL) { int i; dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; dev->opt[OPT_RESOLUTION].constraint.word_list = dev->resolutions_list; /* If the resolution isn't in the list, set a default. */ for (i = 1; i <= dev->resolutions_list[0]; i++) { if (dev->resolutions_list[i] >= dev->val[OPT_RESOLUTION].w) break; } if (i > dev->resolutions_list[0]) { /* Too big. Take lowest. */ dev->val[OPT_RESOLUTION].w = dev->resolutions_list[1]; } else { /* Take immediate superioir value. */ dev->val[OPT_RESOLUTION].w = dev->resolutions_list[i]; } } /* String side-effect options */ if (info) { *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } DBG (DBG_proc, "sane_control_option: exit, bad\n"); return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Stv680_Vidcam *dev = handle; int i; DBG (DBG_proc, "sane_get_parameters: enter\n"); if (!(dev->scanning)) { dev->x_resolution = dev->val[OPT_RESOLUTION].w; /* Prepare the parameters for the caller. */ memset (&dev->params, 0, sizeof (SANE_Parameters)); dev->params.last_frame = SANE_TRUE; switch (dev->scan_mode) { case STV680_COLOR_RAW: dev->bytes_pixel = 1; /* raw image is 422 code, 1 byte/pixel */ break; case STV680_COLOR_RGB: case STV680_COLOR_RGB_TEXT: case STV680_COLOR: dev->bytes_pixel = 3; break; } dev->params.format = SANE_FRAME_RGB; dev->params.pixels_per_line = dev->x_resolution; dev->params.bytes_per_line = dev->params.pixels_per_line * dev->bytes_pixel; dev->params.depth = 8; if (dev->resolutions_list != NULL) { /* This vidcam has a fixed number of supported * resolutions. Find the color sequence for that * resolution. */ for (i = 0; dev->hw->color_adjust[i].resolution_x != dev->x_resolution; i++); dev->red_s = dev->hw->color_adjust[i].z1_color_0; dev->green_s = dev->hw->color_adjust[i].z1_color_1; dev->blue_s = dev->hw->color_adjust[i].z1_color_2; dev->y_resolution = dev->hw->color_adjust[i].resolution_y; } dev->subsample = 0; switch (dev->val[OPT_RESOLUTION].w) { case 176: dev->video_mode = 0x0200; dev->cwidth = dev->x_resolution + 2; dev->cheight = dev->y_resolution + 2; break; case 160: /* 160x120 subsampled */ dev->x_resolution = 320; dev->y_resolution = 240; dev->video_mode = 0x0300; dev->cwidth = dev->x_resolution + 2; dev->cheight = dev->y_resolution + 2; dev->subsample = 160; break; case 320: dev->video_mode = 0x0300; dev->cwidth = dev->x_resolution + 2; dev->cheight = dev->y_resolution + 2; break; case 352: dev->video_mode = 0x0000; dev->cwidth = dev->x_resolution + 4; dev->cheight = dev->y_resolution + 4; break; case 640: dev->video_mode = 0x0100; dev->cwidth = dev->x_resolution + 4; dev->cheight = dev->y_resolution + 4; break; } dev->params.pixels_per_line = dev->x_resolution; dev->params.lines = dev->y_resolution; DBG (DBG_info, "sane_get_parameters: x=%d, y=%d\n", dev->x_resolution, dev->y_resolution); } /* Return the current values. */ if (params) { *params = (dev->params); } DBG (DBG_proc, "sane_get_parameters: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Stv680_Vidcam *dev = handle; SANE_Status status; DBG (DBG_proc, "sane_start: enter\n"); if (!(dev->scanning)) { sane_get_parameters (dev, NULL); /* Open again the vidcam */ if (sanei_usb_open (dev->devicename, &(dev->fd)) != 0) { DBG (DBG_error, "ERROR: sane_start: open failed\n"); return SANE_STATUS_INVAL; } /* Initialize the vidcam. */ status = stv680_vidcam_init (dev); if (status) { DBG (DBG_error, "ERROR: failed to init the vidcam\n"); stv680_close (dev); return status; } } dev->image_end = 0; dev->image_begin = 0; /* real_byte_left is bulk read bytes, bytes_left is frontend buffer bytes */ dev->real_bytes_left = dev->cwidth * dev->cheight; dev->bytes_left = dev->params.bytes_per_line * dev->params.lines; dev->scanning = SANE_TRUE; DBG (DBG_proc, "sane_start: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { SANE_Status status; Stv680_Vidcam *dev = handle; size_t size; DBG (DBG_proc, "sane_read: enter\n"); *len = 0; if (dev->deliver_eof) { dev->deliver_eof = 0; return SANE_STATUS_EOF; } if (!(dev->scanning)) { /* OOPS, not scanning, stop a scan. */ stv680_reset_vidcam (dev); stv680_close (dev); dev->scanning = SANE_FALSE; return SANE_STATUS_CANCELLED; } if (dev->bytes_left <= 0) { return (SANE_STATUS_EOF); } if (dev->image_begin == dev->image_end) { /* Fill image */ status = stv680_fill_image (dev); if (status != SANE_STATUS_GOOD) { DBG (DBG_info, "sane_read: stv680_fill_image status NOK\n"); return (status); } } /* Something must have been read */ if (dev->image_begin == dev->image_end) { DBG (DBG_info, "sane_read: nothing read\n"); return SANE_STATUS_IO_ERROR; } size = dev->bytes_left; if (((unsigned int) max_len) < size) { DBG (DBG_error, "sane_read: max_len < size\n"); return (SANE_FALSE); } if ((dev->image_end - dev->image_begin) > size) { size = dev->image_end - dev->image_begin; DBG (DBG_proc, "sane_read: size < dev->image_end - dev->image_begin\n"); } /* diff between size an dev->bytes_left because of 356/352 and 292/288 */ DBG (DBG_info, "sane_read: size =0x%lx bytes, max_len=0x%lx bytes\n", (unsigned long) (size_t) size, (unsigned long) (size_t) max_len); *len = dev->bytes_left; /* needed */ size = dev->bytes_left; dev->bytes_left = 0; /* needed for frontend or ? */ if (dev->scan_mode != STV680_COLOR_RAW) { /* do bayer unshuffle after complete frame is read */ status = stv680_bayer_unshuffle (dev, buf, &size); if (status != SANE_STATUS_GOOD) { DBG (DBG_info, "sane_read: stv680_bayer_unshuffle status NOK\n"); return (status); } } else { /* Copy the raw data to the frontend buffer. */ memcpy (buf, dev->image, size); DBG (DBG_info, "sane_read: raw mode\n"); } DBG (DBG_info, "sane_read: exit\n"); status = SANE_STATUS_GOOD; return status; } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { DBG (DBG_proc, "sane_set_io_mode: enter\n"); handle = handle; /* silence gcc */ non_blocking = non_blocking; /* silence gcc */ DBG (DBG_proc, "sane_set_io_mode: exit\n"); return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { DBG (DBG_proc, "sane_get_select_fd: enter\n"); handle = handle; /* silence gcc */ fd = fd; /* silence gcc */ DBG (DBG_proc, "sane_get_select_fd: exit\n"); return SANE_STATUS_UNSUPPORTED; } void sane_cancel (SANE_Handle handle) { Stv680_Vidcam *dev = handle; DBG (DBG_proc, "sane_cancel: enter\n"); /* Stop a scan. */ if (dev->scanning == SANE_TRUE) { /* Reset the vidcam */ stv680_reset_vidcam (dev); stv680_close (dev); } dev->scanning = SANE_FALSE; dev->deliver_eof = 0; /* return SANE_STATUS_CANCELLED; */ DBG (DBG_proc, "sane_cancel: exit\n"); } void sane_close (SANE_Handle handle) { Stv680_Vidcam *dev = handle; Stv680_Vidcam *dev_tmp; DBG (DBG_proc, "sane_close: enter\n"); /* Stop a scan. */ if (dev->scanning == SANE_TRUE) { stv680_reset_vidcam (dev); stv680_close (dev); } dev->scanning = SANE_FALSE; /* Unlink dev. */ if (first_dev == dev) { first_dev = dev->next; } else { dev_tmp = first_dev; while (dev_tmp->next && dev_tmp->next != dev) { dev_tmp = dev_tmp->next; } if (dev_tmp->next != NULL) { dev_tmp->next = dev_tmp->next->next; } } stv680_free (dev); num_devices--; DBG (DBG_proc, "sane_close: exit\n"); } void sane_exit (void) { DBG (DBG_proc, "sane_exit: enter\n"); while (first_dev) { sane_close (first_dev); } if (devlist) { free (devlist); devlist = NULL; } DBG (DBG_proc, "sane_exit: exit\n"); } sane-backends-1.0.29/backend/mustek_usb.conf.in0000666000000000000000000000145013615534521016225 00000000000000# mustek_usb.conf: Configuration file for Mustek USB scanner # Read man sane-mustek_usb for documentation # If USB errors occur, using this option may help #option max_block_size 1024 # Autodetect 1200 UB and Trust Compact Scan USB 19200 usb 0x055f 0x0006 # Autodetect 1200 USB (not supported) # usb 0x055f 0x0003 # Autodetect 1200 CU usb 0x055f 0x0001 # Autodetect 1200 CU Plus usb 0x055f 0x0008 # Autodetect 600 CU usb 0x055f 0x0002 # Autodetect 600 USB (not supported) usb 0x055f 0x0873 # If autodetection doesn't work uncomment or add your device file and one # suitable option (1200ub is also for Trust Compact Scan USB 19200). #/dev/usb/scanner0 #option 1200ub #option 1200cu #option 1200cu_plus #option 600cu #/dev/usbscanner0 #option 1200ub #option 1200cu #option 1200cu_plus #option 600cu sane-backends-1.0.29/backend/hp4200.c0000666000000000000000000022475513615534521013670 00000000000000/* Copyright (C) 2000 by Adrian Perez Jorge 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Developers: Adrian Perez Jorge (APJ) - Creator of the original HP4200C backend code. adrianpj@easynews.com Andrew John Lewis (AJL) - lewi0235@tc.umn.edu Arnar Mar Hrafnkelsson (AMH) - addi@umich.edu Frank Zago some cleanups and integration into SANE Henning Meier-Geinitz more cleanups, bug fixes TODO: - support more scanning resolutions. - support different color depths. - support gray and lineart. - improve scanning speed. Compute scanning parameters based on the image size and the scanner-to-host bandwidth. - improve image quality. - fix problem concerning mangled images */ #define BUILD 2 #define BACKEND_NAME hp4200 #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_pv8630.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_backend.h" #include "hp4200.h" #include "hp4200_lm9830.c" #define HP4200_CONFIG_FILE "hp4200.conf" /*--------------------------------------------------------------------------*/ #if 0 /* Some of these resolution need work in color shifting. */ static const SANE_Int dpi_list[] = { 8, 50, 75, 100, 150, 200, 300, 400, 600 }; #else static const SANE_Int dpi_list[] = { 4, 75, 150, 300, 600 }; #endif static SANE_Range x_range = { SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0 }; static SANE_Range y_range = { SANE_FIX (0), SANE_FIX (11.75 * MM_PER_INCH), 0 }; static const SANE_Range u8_range = { 0, 255, 0 }; struct coarse_t { int min_red; int min_green; int min_blue; int max_red; int max_green; int max_blue; int red_gain; int red_offset; int green_gain; int green_offset; int blue_gain; int blue_offset; }; static const double hdpi_mapping[8] = { 1, 1.5, 2, 3, 4, 6, 8, 12 }; static HP4200_Device *first_device = NULL; /* device list head */ static int n_devices = 0; /* the device count */ static const SANE_Device **devlist = NULL; static unsigned char getreg (HP4200_Scanner * s, unsigned char reg) { unsigned char reg_value; if ((reg > 0x08) && (reg < 0x5b)) return (unsigned char) LOBYTE (s->regs[reg]); else { lm9830_read_register (s->fd, reg, ®_value); return reg_value; } } static void setreg (HP4200_Scanner * s, unsigned char reg, unsigned char reg_value) { s->regs[reg] = reg_value; /* dirty bit should be clear with this */ if ((reg < 0x08) || (reg > 0x5b)) { lm9830_write_register (s->fd, reg, reg_value); } } static void setbits (HP4200_Scanner * s, unsigned char reg, unsigned char bitmap) { s->regs[reg] = (s->regs[reg] & 0xff) | bitmap; if ((reg < 0x08) || (reg > 0x5b)) { lm9830_write_register (s->fd, reg, LOBYTE (s->regs[reg])); } } static void clearbits (HP4200_Scanner * s, unsigned char reg, unsigned char mask) { s->regs[reg] = (s->regs[reg] & ~mask) & 0xff; if ((reg < 0x08) || (reg > 0x5b)) { lm9830_write_register (s->fd, reg, LOBYTE (s->regs[reg])); } } static int cache_write (HP4200_Scanner * s) { int i; #ifdef DEBUG_REG_CACHE int counter = 0; #endif DBG (DBG_proc, "Writing registers\n"); for (i = 0; i < 0x80; i++) if (!(s->regs[i] & 0x100)) { /* modified register */ #ifdef DEBUG_REG_CACHE fprintf (stderr, "%.2x", i); if (counter == 8) fprintf (stderr, "\n"); else fprintf (stderr, ", "); counter = (counter + 1) % 9; #endif lm9830_write_register (s->fd, i, s->regs[i]); s->regs[i] |= 0x100; /* register is updated */ } return 0; } /* * HP4200-dependent register initialization. */ static int hp4200_init_registers (HP4200_Scanner * s) { /* set up hardware parameters */ s->hw_parms.crystal_frequency = 48000000; s->hw_parms.SRAM_size = 128; /* Kb */ s->hw_parms.scan_area_width = 5100; /* pixels */ s->hw_parms.scan_area_length = 11; /* inches */ s->hw_parms.min_pixel_data_buffer_limit = 1024; /* bytes */ s->hw_parms.sensor_line_separation = 4; /* lines */ s->hw_parms.sensor_max_integration_time = 12; /* milliseconds */ s->hw_parms.home_sensor = 2; s->hw_parms.sensor_resolution = 1; /* 600 dpi */ s->hw_parms.motor_full_steps_per_inch = 300; s->hw_parms.motor_max_speed = 1.4; /* inches/second */ s->hw_parms.num_tr_pulses = 1; s->hw_parms.guard_band_duration = 1; s->hw_parms.pulse_duration = 3; s->hw_parms.fsteps_25_speed = 3; s->hw_parms.fsteps_50_speed = 3; s->hw_parms.target_value.red = 1000; s->hw_parms.target_value.green = 1000; s->hw_parms.target_value.blue = 1000; { int i; /* * we are using a cache-like data structure so registers whose * values were written to the lm9830 and aren't volatile, have * bit 0x100 activated. This bit must be cleared if you want the * value to be written to the chip once cache_write() is called. */ /* clears the registers cache */ memset (s->regs, 0, sizeof (s->regs)); /* * registers 0x00 - 0x07 are non-cacheable/volatile, so don't * read the values using the cache. Instead use direct functions * to read/write registers. */ for (i = 0; i < 0x08; i++) s->regs[i] = 0x100; } setreg (s, 0x70, 0x70); /* noise filter */ setreg (s, 0x0b, INPUT_SIGNAL_POLARITY_NEGATIVE | CDS_ON | SENSOR_STANDARD | SENSOR_RESOLUTION_600 | LINE_SKIPPING_COLOR_PHASE_DELAY (0)); setreg (s, 0x0c, PHI1_POLARITY_POSITIVE | PHI2_POLARITY_POSITIVE | RS_POLARITY_POSITIVE | CP1_POLARITY_POSITIVE | CP2_POLARITY_POSITIVE | TR1_POLARITY_NEGATIVE | TR2_POLARITY_NEGATIVE); setreg (s, 0x0d, PHI1_ACTIVE | PHI2_ACTIVE | RS_ACTIVE | CP1_ACTIVE | CP2_OFF | TR1_ACTIVE | TR2_OFF | NUMBER_OF_TR_PULSES (s->hw_parms.num_tr_pulses)); setreg (s, 0x0e, TR_PULSE_DURATION (s->hw_parms.pulse_duration) | TR_PHI1_GUARDBAND_DURATION (s->hw_parms.guard_band_duration)); /* for pixel rate timing */ setreg (s, 0x0f, 6); setreg (s, 0x10, 23); setreg (s, 0x11, 1); setreg (s, 0x12, 3); setreg (s, 0x13, 3); /* 0 */ setreg (s, 0x14, 5); /* 0 */ setreg (s, 0x15, 0); setreg (s, 0x16, 0); setreg (s, 0x17, 11); setreg (s, 0x18, 2); /* 1 */ setreg (s, 0x19, CIS_TR1_TIMING_OFF | FAKE_OPTICAL_BLACK_PIXELS_OFF); setreg (s, 0x1a, 0); setreg (s, 0x1b, 0); setreg (s, 0x1c, 0x0d); setreg (s, 0x1d, 0x21); setreg (s, 0x27, TR_RED_DROP (0) | TR_GREEN_DROP (0) | TR_BLUE_DROP (0)); setreg (s, 0x28, 0x00); setreg (s, 0x29, ILLUMINATION_MODE (1)); setreg (s, 0x2a, HIBYTE (0)); /* 0 */ setreg (s, 0x2b, LOBYTE (0)); /* 0 */ setreg (s, 0x2c, HIBYTE (16383)); setreg (s, 0x2d, LOBYTE (16383)); setreg (s, 0x2e, HIBYTE (2)); /* 2 */ setreg (s, 0x2f, LOBYTE (2)); /* 1 */ setreg (s, 0x30, HIBYTE (0)); setreg (s, 0x31, LOBYTE (0)); setreg (s, 0x32, HIBYTE (0)); setreg (s, 0x33, LOBYTE (0)); setreg (s, 0x34, HIBYTE (32)); setreg (s, 0x35, LOBYTE (32)); setreg (s, 0x36, HIBYTE (48)); setreg (s, 0x37, LOBYTE (48)); setreg (s, 0x42, EPP_MODE | PPORT_DRIVE_CURRENT (3)); setreg (s, 0x43, RAM_SIZE_128 | SRAM_DRIVER_CURRENT (3) | SRAM_BANDWIDTH_8 | SCANNING_FULL_DUPLEX); setreg (s, 0x45, MICRO_STEPPING | CURRENT_SENSING_PHASES (2) | PHASE_A_POLARITY_POSITIVE | PHASE_B_POLARITY_POSITIVE | STEPPER_MOTOR_OUTPUT); setreg (s, 0x4a, HIBYTE (100)); setreg (s, 0x4b, LOBYTE (100)); setreg (s, 0x4c, HIBYTE (0)); setreg (s, 0x4d, LOBYTE (0)); /* resume scan threshold */ setreg (s, 0x4f, 64); /* steps to reverse */ setreg (s, 0x50, 40); setreg (s, 0x51, ACCELERATION_PROFILE_STOPPED (3) | ACCELERATION_PROFILE_25P (s->hw_parms.fsteps_25_speed) | ACCELERATION_PROFILE_50P (s->hw_parms.fsteps_50_speed)); setreg (s, 0x54, NON_REVERSING_EXTRA_LINES (0) | FIRST_LINE_TO_PROCESS (0)); setreg (s, 0x55, KICKSTART_STEPS (0) | HOLD_CURRENT_TIMEOUT (2)); /* stepper PWM frequency */ setreg (s, 0x56, 8); /* stepper pwm duty cycle */ setreg (s, 0x57, 23); setreg (s, 0x58, PAPER_SENSOR_1_POLARITY_HIGH | PAPER_SENSOR_1_TRIGGER_EDGE | PAPER_SENSOR_1_NO_STOP_SCAN | PAPER_SENSOR_2_POLARITY_HIGH | PAPER_SENSOR_2_TRIGGER_EDGE | PAPER_SENSOR_2_STOP_SCAN); setreg (s, 0x59, MISCIO_1_TYPE_OUTPUT | MISCIO_1_POLARITY_HIGH | MISCIO_1_TRIGGER_EDGE | MISCIO_1_OUTPUT_STATE_HIGH | MISCIO_2_TYPE_OUTPUT | MISCIO_2_POLARITY_HIGH | MISCIO_2_TRIGGER_EDGE | MISCIO_2_OUTPUT_STATE_HIGH); return 0; } #ifdef DEBUG static int dump_register_cache (HP4200_Scanner * s) { int i; for (i = 0; i < 0x80; i++) { fprintf (stderr, "%.2x:0x%.2x", i, s->regs[i]); if ((i + 1) % 8) fprintf (stderr, ", "); else fprintf (stderr, "\n"); } fputs ("", stderr); return 0; } #endif /* * returns the scanner head to home position */ static int hp4200_goto_home (HP4200_Scanner * s) { unsigned char cmd_reg; unsigned char status_reg; unsigned char old_paper_sensor_reg; cmd_reg = getreg (s, 0x07); if (cmd_reg != 2) { unsigned char paper_sensor_reg; unsigned char sensor_bit[2] = { 0x02, 0x10 }; /* sensor head is not returning */ /* let's see if it's already at home */ /* first put paper (head) sensor level sensitive */ paper_sensor_reg = getreg (s, 0x58); old_paper_sensor_reg = paper_sensor_reg; paper_sensor_reg &= ~sensor_bit[s->hw_parms.home_sensor - 1]; setreg (s, 0x58, paper_sensor_reg); cache_write (s); /* if the scan head is not at home then move motor backwards */ status_reg = getreg (s, 0x02); setreg (s, 0x58, old_paper_sensor_reg); cache_write (s); if (!(status_reg & s->hw_parms.home_sensor)) { setreg (s, 0x07, 0x08); usleep (10 * 1000); setreg (s, 0x07, 0x00); usleep (10 * 1000); setreg (s, 0x07, 0x02); } } return 0; } #define HP4200_CHECK_INTERVAL 1000 /* usecs between status checks */ static int hp4200_wait_homed (HP4200_Scanner * s) { unsigned char cmd_reg; cmd_reg = getreg (s, 0x07); while (cmd_reg != 0) { usleep (HP4200_CHECK_INTERVAL); cmd_reg = getreg (s, 0x07); } return 0; } static int compute_fastfeed_step_size (unsigned long crystal_freq, int mclk, float max_speed, int steps_per_inch, int color_mode) { int aux; int r; if (color_mode == 0) r = 24; else r = 8; aux = floor (crystal_freq / ((double) mclk * max_speed * 4.0 * steps_per_inch * r)); if (aux < 2) aux = 2; return aux; } static SANE_Status read_available_data (HP4200_Scanner * s, SANE_Byte * buffer, size_t * byte_count) { SANE_Status status; unsigned char scankb1; unsigned char scankb2; size_t to_read; size_t really_read; size_t chunk; assert (buffer != NULL); *byte_count = 0; do { scankb1 = getreg (s, 0x01); scankb2 = getreg (s, 0x01); if (s->aborted_by_user) return SANE_STATUS_CANCELLED; } while ((scankb1 != scankb2) || (scankb1 < 12)); to_read = scankb1 * 1024; while (to_read) { if (s->aborted_by_user) return SANE_STATUS_CANCELLED; chunk = (to_read > 0xffff) ? 0xffff : to_read; sanei_pv8630_write_byte (s->fd, PV8630_REPPADDRESS, 0x00); sanei_pv8630_prep_bulkread (s->fd, chunk); really_read = chunk; if ((status = sanei_usb_read_bulk (s->fd, buffer, &really_read)) != SANE_STATUS_GOOD) { DBG (DBG_error, "sanei_usb_read_bulk failed (%s)\n", sane_strstatus (status)); return status; } if (really_read > to_read) { DBG (DBG_error, "USB stack read more bytes than requested!\n"); return SANE_STATUS_IO_ERROR; } *byte_count += really_read; buffer += really_read; to_read -= really_read; #ifdef DEBUG fprintf (stderr, "read %d bytes\n", really_read); #endif } return SANE_STATUS_GOOD; } #ifdef unused static int compute_datalink_bandwidth (HP4200_Scanner * s) { int line_size; int pause_limit; unsigned int color_mode; /* * Line size for 8 bpp, the entire scan area width (plus the * status byte) at optical resolution. */ if (s->user_parms.color) { line_size = 3 * s->hw_parms.scan_area_width + 1; color_mode = 0; setreg (s, 0x26, color_mode); /* 3 channel pixel rate color */ } else { line_size = s->hw_parms.scan_area_width + 1; color_mode = 4; setreg (s, 0x26, 0x08 | color_mode); /* 1 channel mode A (green) */ } setreg (s, 0x09, (3 << 3)); /* h-divider = 1, 8 bpp */ { int first_white_pixel; unsigned int line_end; first_white_pixel = s->hw_parms.sensor_pixel_end - 10; line_end = first_white_pixel + s->hw_parms.scan_area_width; if (line_end > (s->hw_parms.sensor_num_pixels - 20)) line_end = s->hw_parms.sensor_num_pixels - 20; setreg (s, 0x1c, HIBYTE (s->hw_parms.sensor_pixel_start)); setreg (s, 0x1d, LOBYTE (s->hw_parms.sensor_pixel_end)); setreg (s, 0x1e, HIBYTE (first_white_pixel)); setreg (s, 0x1f, LOBYTE (first_white_pixel)); setreg (s, 0x20, HIBYTE (s->hw_parms.sensor_num_pixels)); setreg (s, 0x21, LOBYTE (s->hw_parms.sensor_num_pixels)); setreg (s, 0x22, getreg (s, 0x1e)); setreg (s, 0x23, getreg (s, 0x1f)); setreg (s, 0x24, HIBYTE (line_end)); setreg (s, 0x25, LOBYTE (line_end)); } /* * During transfer rate calculation don't forward scanner sensor. * Stay in the calibration region. */ setreg (s, 0x4f, 0); clearbits (s, 0x45, 0x10); /* * Pause the scan when memory is full. */ pause_limit = s->hw_parms.SRAM_size - (line_size / 1024) - 1; setreg (s, 0x4e, pause_limit & 0xff); s->mclk = compute_min_mclk (s->hw_parms.SRAM_bandwidth, s->hw_parms.crystal_frequency); /* * Set step size to fast speed. */ { int step_size; step_size = compute_fastfeed_step_size (s->hw_parms.crystal_frequency, s->mclk, s->hw_parms.scan_bar_max_speed, s->hw_parms.motor_full_steps_per_inch, color_mode); setreg (s, 0x46, HIBYTE (step_size)); setreg (s, 0x47, LOBYTE (step_size)); setreg (s, 0x48, HIBYTE (step_size)); setreg (s, 0x49, LOBYTE (step_size)); } cache_write (s); /* dump_register_cache (s); */ /* * scan during 1 sec. aprox. */ setreg (s, 0x07, 0x08); setreg (s, 0x07, 0x03); { struct timeval tv_before; struct timeval tv_after; int elapsed_time_ms = 0; long bytes_read_total; SANE_Byte *buffer; buffer = malloc (2 * 98304); /* check this */ if (!buffer) { DBG (DBG_error, "compute_datalink_bandwidth: malloc failed\n"); return 0; } bytes_read_total = 0; gettimeofday (&tv_before, NULL); do { size_t bytes_read; SANE_Status status; status = read_available_data (s, buffer, &bytes_read); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "read_available_data failed (%s)\n", sane_strstatus (status)); return 0; } bytes_read_total += bytes_read; gettimeofday (&tv_after, NULL); elapsed_time_ms = (tv_after.tv_sec - tv_before.tv_sec) * 1000; elapsed_time_ms += (tv_after.tv_usec - tv_before.tv_usec) / 1000; } while (elapsed_time_ms < 1000); setreg (s, 0x07, 0x00); free (buffer); s->msrd_parms.datalink_bandwidth = bytes_read_total / (elapsed_time_ms / 1000); #ifdef DEBUG fprintf (stderr, "PC Transfer rate = %d bytes/sec. (%ld/%d)\n", s->msrd_parms.datalink_bandwidth, bytes_read_total, elapsed_time_ms); #endif } return 0; } #endif static void compute_first_gain_offset (int target, int max, int min, int *gain, int *offset, int *max_gain, int *min_offset) { *gain = (int) 15.0 *(target / (max - min) - 0.933); *offset = (int) (-1.0 * min / (512.0 * 0.0195)); if (*gain >= 32) { *gain = (int) 15.0 *(target / 3.0 / (max - min) - 0.933); *offset = (int) -3.0 * min / (512.0 * 0.0195); } if (*gain < 0) *gain = 0; else if (*gain > 63) *gain = 63; if (*offset < -31) *offset = -31; else if (*offset > 31) *offset = 31; *max_gain = 63; *min_offset = -31; } #define DATA_PORT_READ (1 << 5) #define DATA_PORT_WRITE 0 static int write_gamma (HP4200_Scanner * s) { int color; int i; unsigned char gamma[1024]; unsigned char read_gamma[1024]; int retval; size_t to_read; size_t to_write; for (color = 0; color < 3; color++) { for (i = 0; i < 1024; i++) gamma[i] = s->user_parms.gamma[color][i]; setreg (s, 0x03, color << 1); setreg (s, 0x04, DATA_PORT_WRITE); setreg (s, 0x05, 0x00); sanei_pv8630_write_byte (s->fd, PV8630_REPPADDRESS, 0x06); sanei_pv8630_prep_bulkwrite (s->fd, sizeof (gamma)); to_write = sizeof (gamma); sanei_usb_write_bulk (s->fd, gamma, &to_write); /* check if gamma vector was correctly written */ setreg (s, 0x03, color << 1); setreg (s, 0x04, DATA_PORT_READ); setreg (s, 0x05, 0x00); sanei_pv8630_write_byte (s->fd, PV8630_REPPADDRESS, 0x06); sanei_pv8630_prep_bulkread (s->fd, sizeof (read_gamma)); to_read = sizeof (read_gamma); sanei_usb_read_bulk (s->fd, read_gamma, &to_read); retval = memcmp (read_gamma, gamma, sizeof (read_gamma)); if (retval != 0) { DBG (DBG_error, "error: color %d has bad gamma table\n", color); } #ifdef DEBUG else fprintf (stderr, "color %d gamma table is good\n", color); #endif } return 0; } static int write_default_offset_gain (HP4200_Scanner * s, SANE_Byte * gain_offset, int size, int color) { SANE_Byte *check_data; int retval; size_t to_read; size_t to_write; setreg (s, 0x03, (color << 1) | 1); setreg (s, 0x04, DATA_PORT_WRITE); setreg (s, 0x05, 0x00); sanei_pv8630_write_byte (s->fd, PV8630_REPPADDRESS, 0x06); sanei_pv8630_prep_bulkwrite (s->fd, size); to_write = size; sanei_usb_write_bulk (s->fd, gain_offset, &to_write); check_data = malloc (size); setreg (s, 0x03, (color << 1) | 1); setreg (s, 0x04, DATA_PORT_READ); setreg (s, 0x05, 0x00); sanei_pv8630_write_byte (s->fd, PV8630_REPPADDRESS, 0x06); sanei_pv8630_prep_bulkread (s->fd, size); to_read = size; sanei_usb_read_bulk (s->fd, check_data, &to_read); retval = memcmp (gain_offset, check_data, size); free (check_data); if (retval != 0) { DBG (DBG_error, "error: color %d has bad gain/offset table\n", color); } #ifdef DEBUG else fprintf (stderr, "color %d gain/offset table is good\n", color); #endif return 0; } static int compute_gain_offset (int target, int max, int min, int *gain, int *offset, int *max_gain, int *min_offset) { int gain_stable; int is_unstable; gain_stable = 1; /* unless the opposite is said */ is_unstable = 0; if (max > target) { if (*gain > 0) { (*gain)--; *max_gain = *gain; gain_stable = 0; is_unstable |= 1; } else { DBG (DBG_error, "error: integration time too long.\n"); return -1; } } else { if (*gain < *max_gain) { (*gain)++; gain_stable = 0; is_unstable |= 1; } } if (min == 0) { if (*offset < 31) { (*offset)++; if (gain_stable) *min_offset = *offset; is_unstable |= 1; } else { DBG (DBG_error, "error: max static has pixel value == 0\n"); return -1; } } else { if (*offset > *min_offset) { (*offset)--; is_unstable |= 1; } } return is_unstable; } static int compute_bytes_per_line (int width_in_pixels, unsigned char hdpi_code, unsigned char pixel_packing, unsigned char data_mode, unsigned char AFE_operation, int m) { const int dpi_qot_mul[] = { 1, 2, 1, 1, 1, 1, 1, 1 }; const int dpi_qot_div[] = { 1, 3, 2, 3, 4, 6, 8, 12 }; int pixels_per_line; int bytes_per_line; int pixels_per_byte; int status_bytes; const int pixels_per_byte_mapping[] = { 8, 4, 2, 1 }; assert (hdpi_code <= 7); pixels_per_line = (width_in_pixels * dpi_qot_mul[hdpi_code]) / dpi_qot_div[hdpi_code]; if ((width_in_pixels * dpi_qot_mul[hdpi_code]) % dpi_qot_div[hdpi_code]) pixels_per_line++; status_bytes = (m == 0) ? 1 : m; if (data_mode == 1) pixels_per_byte = 1; /* should be 0.5 but later bytes_per_line will be multiplied by 2, and also the number of status bytes, that in this case should be 2. umm.. maybe this should be done in the cleaner way. */ else { assert (pixel_packing <= 3); pixels_per_byte = pixels_per_byte_mapping[pixel_packing]; } switch (AFE_operation) { case PIXEL_RATE_3_CHANNELS: bytes_per_line = ((pixels_per_line * 3) / pixels_per_byte) + status_bytes; break; case MODEA_1_CHANNEL: bytes_per_line = (pixels_per_line / pixels_per_byte) + status_bytes; break; default: /* Not implemented! (yet?) and not used. * This case should not happen. */ assert (0); } if (data_mode == 1) /* see big note above */ bytes_per_line *= 2; return bytes_per_line; } static int compute_pause_limit (hardware_parameters_t * hw_parms, int bytes_per_line) { int coef_size; const int coef_mapping[] = { 16, 32 }; int pause_limit; coef_size = coef_mapping[hw_parms->sensor_resolution & 0x01]; pause_limit = hw_parms->SRAM_size - coef_size - (bytes_per_line / 1024) - 1; if (pause_limit > 2) pause_limit -= 2; return pause_limit; } static int compute_dpd (HP4200_Scanner * s, int step_size, int line_end) { int tr, dpd; tr = 1 /* color mode */ * (line_end + ((s->hw_parms.num_tr_pulses + 1) * (2 * s->hw_parms.guard_band_duration + s->hw_parms.pulse_duration + 1) + 3 - s->hw_parms.num_tr_pulses)); if (tr == 0) return 0; dpd = (((s->hw_parms.fsteps_25_speed * 4) + (s->hw_parms.fsteps_50_speed * 2) + s->hw_parms.steps_to_reverse) * 4 * step_size) % tr; dpd = tr - dpd; return dpd; } static SANE_Status read_required_bytes (HP4200_Scanner * s, int required, SANE_Byte * buffer) { int read_count = 0; unsigned char scankb1; unsigned char scankb2; size_t to_read; size_t really_read; size_t chunk; SANE_Status status; assert (buffer != NULL); while (required) { do { scankb1 = getreg (s, 0x01); scankb2 = getreg (s, 0x01); if (s->aborted_by_user) return SANE_STATUS_CANCELLED; } while ((scankb1 != scankb2) || (scankb1 < 12)); to_read = min (required, (scankb1 * 1024)); while (to_read) { if (s->aborted_by_user) return SANE_STATUS_CANCELLED; chunk = (to_read > 0xffff) ? 0xffff : to_read; sanei_pv8630_write_byte (s->fd, PV8630_REPPADDRESS, 0x00); sanei_pv8630_prep_bulkread (s->fd, chunk); really_read = chunk; if ((status = sanei_usb_read_bulk (s->fd, buffer, &really_read)) != SANE_STATUS_GOOD) { DBG (DBG_error, "sanei_usb_read_bulk failed (%s)\n", sane_strstatus (status)); return status; } if (really_read > chunk) { DBG (DBG_error, "USB stack read more bytes than requested!\n"); return SANE_STATUS_IO_ERROR; } buffer += really_read; required -= really_read; to_read -= really_read; read_count += really_read; } } return SANE_STATUS_GOOD; } static SANE_Status scanner_buffer_init (scanner_buffer_t * sb, int size_in_kb) { sb->size = size_in_kb * 1024 + 3; sb->buffer = malloc (sb->size); if (!sb->buffer) return SANE_STATUS_NO_MEM; sb->num_bytes = 0; sb->data_ptr = sb->buffer; return SANE_STATUS_GOOD; } static SANE_Status scanner_buffer_read (HP4200_Scanner * s) { SANE_Status status; size_t num_bytes_read_now; assert (s->scanner_buffer.num_bytes <= 3); memcpy (s->scanner_buffer.buffer, s->scanner_buffer.data_ptr, 3); status = read_available_data (s, s->scanner_buffer.buffer + s->scanner_buffer.num_bytes, &num_bytes_read_now); s->scanner_buffer.data_ptr = s->scanner_buffer.buffer; s->scanner_buffer.num_bytes += num_bytes_read_now; return status; } #define OFFSET_CODE_SIGN(off) (((off) < 0) ? (-(off) & 0x1f) | 0x20 : (off)) #define OFFSET_DECODE_SIGN(off) (((off) & 0x20) ? -(off & 0x1f) : (off)) static SANE_Status do_coarse_calibration (HP4200_Scanner * s, struct coarse_t *coarse) { SANE_Status status; unsigned char *cal_line = NULL; unsigned char *cal_line_ptr; int cal_line_size; /* local scanning params */ int active_pixels_start; int line_end; int data_pixels_start; int data_pixels_end; int dpd; int step_size; int ff_step_size; char steps_to_reverse; char line_rate_color; int vdpi; /* vertical dots per inch */ int hdpi_code; int calibrated; int first_time; int red_offset = 0; int green_offset = 0; int blue_offset = 0; int red_gain = 1; int green_gain = 1; int blue_gain = 1; int min_red_offset = -31; int min_green_offset = -31; int min_blue_offset = -31; int max_red_gain = 63; int max_green_gain = 63; int max_blue_gain = 63; int max_red; int min_red; int max_green; int min_green; int max_blue; int min_blue; static char me[] = "do_coarse_calibration"; DBG (DBG_proc, "%s\n", me); setreg (s, 0x07, 0x00); usleep (10 * 1000); vdpi = 150; hdpi_code = 0; active_pixels_start = 0x40; line_end = 0x2ee0; s->mclk_div = 2; data_pixels_start = 0x40; data_pixels_end = (int) (data_pixels_start + s->hw_parms.scan_area_width); data_pixels_end = min (data_pixels_end, line_end - 20); cal_line_size = s->hw_parms.scan_area_width * 3 * 2 + 2; setreg (s, 0x1e, HIBYTE (active_pixels_start)); setreg (s, 0x1f, LOBYTE (active_pixels_start)); setreg (s, 0x20, HIBYTE (line_end)); setreg (s, 0x21, LOBYTE (line_end)); setreg (s, 0x22, HIBYTE (data_pixels_start)); setreg (s, 0x23, LOBYTE (data_pixels_start)); setreg (s, 0x24, HIBYTE (data_pixels_end)); setreg (s, 0x25, LOBYTE (data_pixels_end)); setreg (s, 0x26, PIXEL_RATE_3_CHANNELS | GRAY_CHANNEL_RED | TR_RED (0) | TR_GREEN (0) | TR_BLUE (0)); setreg (s, 0x08, (s->mclk_div - 1) * 2); setreg (s, 0x09, hdpi_code | PIXEL_PACKING (3) | DATAMODE (1)); setreg (s, 0x0a, 0); /* reserved and strange register */ setreg (s, 0x38, red_offset); setreg (s, 0x39, green_offset); setreg (s, 0x3a, blue_offset); setreg (s, 0x3b, red_gain); setreg (s, 0x3c, green_gain); setreg (s, 0x3d, blue_gain); setreg (s, 0x5e, 0x80); setreg (s, 0x3e, 0x00); /* 1.5:1, 6/10 bits, 2*fixed */ setreg (s, 0x3f, 0x00); setreg (s, 0x40, 0x00); setreg (s, 0x41, 0x00); setreg (s, 0x4e, 0x5b - 0x3c); /* max Kb to pause */ setreg (s, 0x4f, 0x02); /* min Kb to resume */ line_rate_color = 1; step_size = (vdpi * line_end * line_rate_color) / (4 * s->hw_parms.motor_full_steps_per_inch); dpd = compute_dpd (s, step_size, line_end); /* 0x0ada; */ #ifdef DEBUG fprintf (stderr, "dpd = %d\n", dpd); #endif setreg (s, 0x52, HIBYTE (dpd)); setreg (s, 0x53, LOBYTE (dpd)); setreg (s, 0x46, HIBYTE (step_size)); setreg (s, 0x47, LOBYTE (step_size)); ff_step_size = compute_fastfeed_step_size (s->hw_parms.crystal_frequency, s->mclk_div, s->hw_parms.motor_max_speed, s->hw_parms.motor_full_steps_per_inch, 0); /* 0x0190; */ setreg (s, 0x48, HIBYTE (ff_step_size)); setreg (s, 0x49, LOBYTE (ff_step_size)); setreg (s, 0x4b, 0x15); steps_to_reverse = 0x3f; setreg (s, 0x50, steps_to_reverse); setreg (s, 0x51, 0x15); /* accel profile */ /* this is to stay the motor stopped */ clearbits (s, 0x45, (1 << 4)); cache_write (s); calibrated = 0; first_time = 1; cal_line = malloc (cal_line_size + 1024); do { unsigned char cmd_reg; /* resets the lm9830 before start scanning */ setreg (s, 0x07, 0x08); do { setreg (s, 0x07, 0x03); cmd_reg = getreg (s, 0x07); } while (cmd_reg != 0x03); cal_line_ptr = cal_line; status = read_required_bytes (s, cal_line_size, cal_line_ptr); if (status != SANE_STATUS_GOOD) goto done; setreg (s, 0x07, 0x00); { unsigned int i; min_red = max_red = (cal_line[0] * 256 + cal_line[1]) >> 2; min_green = max_green = (cal_line[2] * 256 + cal_line[3]) >> 2; min_blue = max_blue = (cal_line[4] * 256 + cal_line[5]) >> 2; for (i = 6; i < (s->hw_parms.scan_area_width * 3 * 2); i += 6) { int value; value = cal_line[i] * 256 + cal_line[i + 1]; value >>= 2; if (value > max_red) max_red = value; value = cal_line[i + 2] * 256 + cal_line[i + 3]; value >>= 2; if (value > max_green) max_green = value; value = cal_line[i + 4] * 256 + cal_line[i + 5]; value >>= 2; if (value > max_blue) max_blue = value; value = cal_line[i] * 256 + cal_line[i + 1]; value >>= 2; if (value < min_red) min_red = value; value = cal_line[i + 2] * 256 + cal_line[i + 3]; value >>= 2; if (value < min_green) min_green = value; value = cal_line[i + 4] * 256 + cal_line[i + 5]; value >>= 2; if (value < min_blue) min_blue = value; } #ifdef DEBUG fprintf (stderr, "max_red:%d max_green:%d max_blue:%d\n", max_red, max_green, max_blue); fprintf (stderr, "min_red:%d min_green:%d min_blue:%d\n", min_red, min_green, min_blue); #endif if (first_time) { first_time = 0; compute_first_gain_offset (s->hw_parms.target_value.red, max_red, min_red, &red_gain, &red_offset, &max_red_gain, &min_red_offset); compute_first_gain_offset (s->hw_parms.target_value.green, max_green, min_green, &green_gain, &green_offset, &max_green_gain, &min_green_offset); compute_first_gain_offset (s->hw_parms.target_value.blue, max_blue, min_blue, &blue_gain, &blue_offset, &max_blue_gain, &min_blue_offset); } else { int retval; /* this code should check return value -1 for error */ retval = compute_gain_offset (s->hw_parms.target_value.red, max_red, min_red, &red_gain, &red_offset, &max_red_gain, &min_red_offset); if (retval < 0) break; retval |= compute_gain_offset (s->hw_parms.target_value.green, max_green, min_green, &green_gain, &green_offset, &max_green_gain, &min_green_offset); if (retval < 0) break; retval |= compute_gain_offset (s->hw_parms.target_value.blue, max_blue, min_blue, &blue_gain, &blue_offset, &max_blue_gain, &min_blue_offset); if (retval < 0) break; calibrated = !retval; } setreg (s, 0x3b, red_gain); setreg (s, 0x3c, green_gain); setreg (s, 0x3d, blue_gain); setreg (s, 0x38, OFFSET_CODE_SIGN (red_offset)); setreg (s, 0x39, OFFSET_CODE_SIGN (green_offset)); setreg (s, 0x3a, OFFSET_CODE_SIGN (blue_offset)); #ifdef DEBUG fprintf (stderr, "%d, %d, %d %d, %d, %d\n", red_gain, green_gain, blue_gain, red_offset, green_offset, blue_offset); #endif cache_write (s); } } while (!calibrated); coarse->min_red = min_red; coarse->min_green = min_green; coarse->min_blue = min_blue; coarse->max_red = max_red; coarse->max_green = max_green; coarse->max_blue = max_blue; coarse->red_gain = red_gain; coarse->green_gain = green_gain; coarse->blue_gain = blue_gain; coarse->red_offset = red_offset; coarse->green_offset = green_offset; coarse->blue_offset = blue_offset; status = SANE_STATUS_GOOD; done: if (cal_line) free (cal_line); return status; } static int compute_corr_code (int average, int min_color, int range, int target) { int value; int corr_code; value = average - min_color; if (value > 0) corr_code = (int) (range * ((double) target / (double) value - 1.0) + 0.5); else corr_code = 0; if (corr_code < 0) corr_code = 0; else if (corr_code > 2048) corr_code = 0; else if (corr_code > 1023) corr_code = 1023; return corr_code; } static int compute_hdpi_code (int hres) { int hdpi_code; /* Calculate the horizontal DPI code based on the requested horizontal resolution. Defaults to 150dpi. */ switch (hres) { case 600: hdpi_code = 0; break; case 400: hdpi_code = 1; break; case 300: hdpi_code = 2; break; case 200: hdpi_code = 3; break; case 150: hdpi_code = 4; break; case 100: hdpi_code = 5; break; case 75: hdpi_code = 6; break; case 50: hdpi_code = 7; break; default: hdpi_code = 4; } return hdpi_code; } static SANE_Status do_fine_calibration (HP4200_Scanner * s, struct coarse_t *coarse) { SANE_Status status; unsigned char *cal_line; unsigned char *cal_line_ptr; int *average; SANE_Byte red_gain_offset[5460 * 2]; SANE_Byte green_gain_offset[5460 * 2]; SANE_Byte blue_gain_offset[5460 * 2]; int *corr_red = NULL; int *corr_green = NULL; int *corr_blue = NULL; int registro[30][5460 * 3]; int cal_line_size; /* local scanning params */ int active_pixels_start; int line_end; int line_length; int data_pixels_start; int data_pixels_end; int dpd; 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; int calibrated; int lines_to_process; static char me[] = "do_fine_calibration"; DBG (DBG_proc, "%s\n", me); setreg (s, 0x07, 0x00); usleep (10 * 1000); vdpi = 150; hdpi_code = compute_hdpi_code (s->user_parms.horizontal_resolution); /* figure out which horizontal divider to use based on the calculated horizontal dpi code */ hdpi_div = hdpi_mapping[hdpi_code]; active_pixels_start = 0x40; line_end = 0x2ee0; line_length = s->user_parms.image_width * hdpi_div; s->mclk_div = 2; data_pixels_start = 0x72 + s->runtime_parms.first_pixel * hdpi_div; data_pixels_end = (int) (data_pixels_start + s->user_parms.image_width * hdpi_div); data_pixels_end = min (data_pixels_end, line_end - 20); cal_line_size = line_length * 3 * 2 + 2; setreg (s, 0x1e, HIBYTE (active_pixels_start)); setreg (s, 0x1f, LOBYTE (active_pixels_start)); setreg (s, 0x20, HIBYTE (line_end)); setreg (s, 0x21, LOBYTE (line_end)); setreg (s, 0x22, HIBYTE (data_pixels_start)); setreg (s, 0x23, LOBYTE (data_pixels_start)); setreg (s, 0x24, HIBYTE (data_pixels_end)); setreg (s, 0x25, LOBYTE (data_pixels_end)); setreg (s, 0x26, PIXEL_RATE_3_CHANNELS | GRAY_CHANNEL_RED | TR_RED (0) | TR_GREEN (0) | TR_BLUE (0)); setreg (s, 0x08, (s->mclk_div - 1) * 2); setreg (s, 0x09, 0 | PIXEL_PACKING (3) | DATAMODE (1)); setreg (s, 0x0a, 0); /* reserved and strange register */ setreg (s, 0x38, 1); setreg (s, 0x39, 1); setreg (s, 0x3a, 1); setreg (s, 0x3b, coarse->red_gain); setreg (s, 0x3c, coarse->green_gain); setreg (s, 0x3d, coarse->blue_gain); setreg (s, 0x5e, 0x80); setreg (s, 0x3e, 0x00); /* 1.5:1, 6/10 bits, 2*fixed */ setreg (s, 0x3f, 0x00); setreg (s, 0x40, 0x00); setreg (s, 0x41, 0x00); setreg (s, 0x4e, 0x5b - 0x3c); /* max Kb to pause */ setreg (s, 0x4f, 0x02); /* min Kb to resume */ line_rate_color = 1; step_size = (vdpi * line_end * line_rate_color) / (4 * s->hw_parms.motor_full_steps_per_inch); dpd = compute_dpd (s, step_size, line_end); /* 0x0ada; */ #ifdef DEBUG fprintf (stderr, "dpd = %d\n", dpd); #endif setreg (s, 0x52, HIBYTE (dpd)); setreg (s, 0x53, LOBYTE (dpd)); setreg (s, 0x46, HIBYTE (step_size)); setreg (s, 0x47, LOBYTE (step_size)); ff_step_size = compute_fastfeed_step_size (s->hw_parms.crystal_frequency, s->mclk_div, s->hw_parms.motor_max_speed, s->hw_parms.motor_full_steps_per_inch, 0); /* 0x0190; */ setreg (s, 0x48, HIBYTE (ff_step_size)); setreg (s, 0x49, LOBYTE (ff_step_size)); setreg (s, 0x4b, 0x15); steps_to_reverse = 0x3f; setreg (s, 0x50, steps_to_reverse); setreg (s, 0x51, 0x15); /* accel profile */ /* this is to activate the motor */ setbits (s, 0x45, (1 << 4)); lines_to_process = 8 * step_size * 4 / line_end; if (lines_to_process < 1) lines_to_process = 1; #ifdef DEBUG fprintf (stderr, "lines to process = %d\n", lines_to_process); #endif setreg (s, 0x58, 0); cache_write (s); calibrated = 0; cal_line = malloc (cal_line_size + 1024); average = malloc (sizeof (int) * line_length * 3); memset (average, 0, sizeof (int) * line_length * 3); { int i; for (i = 0; i < 12; i++) { memset (registro[i], 0, 5460 * 3 * sizeof(registro[0])); } } /* resets the lm9830 before start scanning */ setreg (s, 0x07, 0x08); setreg (s, 0x07, 0x03); usleep (100); do { cal_line_ptr = cal_line; status = read_required_bytes (s, cal_line_size, cal_line_ptr); if (status != SANE_STATUS_GOOD) goto done; { int i, j; if (calibrated == 0) for (j = 0, i = 0; i < (line_length * 3); i++, j += 2) { average[i] = (cal_line[j] * 256 + cal_line[j + 1]) >> 2; registro[calibrated][i] = average[i]; } else for (j = 0, i = 0; i < (line_length * 3); i++, j += 2) { int value; value = (cal_line[j] * 256 + cal_line[j + 1]) >> 2; average[i] += value; average[i] /= 2; registro[calibrated][i] = value; } } calibrated++; } while (calibrated < lines_to_process); lm9830_write_register (s->fd, 0x07, 0x00); usleep (10 * 1000); #if 0 { int i; int j = 0; do { for (i = 3; (i + 6) < (line_length * 3); i += 3) { average[i] = (2 * average[i - 3] + average[i] + 2 * average[i + 3]) / 5; average[i + 1] = (2 * average[i - 2] + average[i + 1] + 2 * average[i + 4]) / 5; average[i + 2] = (2 * average[i - 1] + average[i + 2] + 2 * average[i + 5]) / 5; } j++; } while (j < 3); } #endif { int i; int max_red; int min_red; int max_green; int min_green; int max_blue; int min_blue; min_red = max_red = average[0]; min_green = max_green = average[1]; min_blue = max_blue = average[2]; for (i = 3; i < (line_length * 3); i += 3) { int value; value = average[i]; if (value > max_red) max_red = value; value = average[i + 1]; if (value > max_green) max_green = value; value = average[i + 2]; if (value > max_blue) max_blue = value; value = average[i]; if (value < min_red) min_red = value; value = average[i + 1]; if (value < min_green) min_green = value; value = average[i + 2]; if (value < min_blue) min_blue = value; } #ifdef DEBUG fprintf (stderr, "max_red:%d max_green:%d max_blue:%d\n", max_red, max_green, max_blue); fprintf (stderr, "min_red:%d min_green:%d min_blue:%d\n", min_red, min_green, min_blue); #endif /* do fine calibration */ { int min_white_red; int min_white_green; int min_white_blue; double ratio; int range; double aux; int min_white_err; int j; min_white_red = min_white_green = min_white_blue = 0x3ff; for (i = 0; i < (line_length * 3); i += 3) { int value; value = average[i] - coarse->min_red; if ((value > 0) && (value < min_white_red)) min_white_red = value; value = average[i + 1] - coarse->min_green; if ((value > 0) && (value < min_white_green)) min_white_green = value; value = average[i + 2] - coarse->min_blue; if ((value > 0) && (value < min_white_blue)) min_white_blue = value; } ratio = 0; min_white_err = 0x3ff; aux = (double) s->hw_parms.target_value.red / min_white_red; if (aux > ratio) ratio = aux; if (min_white_err > min_white_red) min_white_err = min_white_red; aux = (double) s->hw_parms.target_value.green / min_white_green; if (aux > ratio) ratio = aux; if (min_white_err > min_white_green) min_white_err = min_white_green; aux = (double) s->hw_parms.target_value.blue / min_white_blue; if (aux > ratio) ratio = aux; if (min_white_err > min_white_blue) min_white_err = min_white_blue; #ifdef DEBUG fprintf (stderr, "min_white_err = %d, ratio = %f\n", min_white_err, ratio); #endif if (ratio <= 1.5) range = 2048; else if (ratio <= 2.0) range = 1024; else range = 512; corr_red = malloc (sizeof (int) * line_length); corr_green = malloc (sizeof (int) * line_length); corr_blue = malloc (sizeof (int) * line_length); for (i = 0, j = 0; i < (line_length * 3); i += 3, j++) { corr_red[j] = compute_corr_code (average[i], coarse->min_red, range, s->hw_parms.target_value.red); corr_green[j] = compute_corr_code (average[i + 1], coarse->min_green, range, s->hw_parms.target_value.green); corr_blue[j] = compute_corr_code (average[i + 2], coarse->min_blue, range, s->hw_parms.target_value.blue); } #ifdef DEBUG { FILE *kaka; int i; kaka = fopen ("corr.raw", "w"); for (i = 0; i < line_length; i++) { fprintf (kaka, "%d %d %d %d %d %d ", corr_red[i], corr_green[i], corr_blue[i], average[3 * i], average[3 * i + 1], average[3 * i + 2]); fprintf (kaka, "%d %d %d %d %d %d %d %d %d ", registro[0][3 * i], registro[0][3 * i + 1], registro[0][3 * i + 2], registro[1][3 * i], registro[1][3 * i + 1], registro[1][3 * i + 2], registro[2][3 * i], registro[2][3 * i + 1], registro[2][3 * i + 2]); fprintf (kaka, "%d %d %d %d %d %d %d %d %d\n", registro[3][3 * i], registro[3][3 * i + 1], registro[3][3 * i + 2], registro[4][3 * i], registro[4][3 * i + 1], registro[4][3 * i + 2], registro[5][3 * i], registro[5][3 * i + 1], registro[5][3 * i + 2]); } fclose (kaka); } #endif { int max_black; int use_six_eight_bits; max_black = max (coarse->min_red, coarse->min_green); max_black = max (max_black, coarse->min_blue); use_six_eight_bits = (max_black < 64); if (use_six_eight_bits) { setreg (s, 0x3e, (1 << 4) | (1 << 3) | (1024 / range)); } else { setreg (s, 0x3e, (1 << 4) | (1 << 3) | (1 << 2) | (1024 / range)); } memset (red_gain_offset, 0, sizeof (red_gain_offset)); memset (green_gain_offset, 0, sizeof (green_gain_offset)); memset (blue_gain_offset, 0, sizeof (blue_gain_offset)); for (i = 0, j = (data_pixels_start - active_pixels_start) * 2; i < line_length; i++, j += 2) { if (use_six_eight_bits) { red_gain_offset[j] = (coarse->min_red << 2) | ((corr_red[i] >> 8) & 0x03); red_gain_offset[j + 1] = corr_red[i] & 0xff; green_gain_offset[j] = (coarse->min_green << 2) | ((corr_green[i] >> 8) & 0x03); green_gain_offset[j + 1] = corr_green[i] & 0xff; blue_gain_offset[j] = (coarse->min_blue << 2) | ((corr_blue[i] >> 8) & 0x03); blue_gain_offset[j + 1] = corr_blue[i] & 0xff; } else { red_gain_offset[j] = coarse->min_red; red_gain_offset[j + 1] = corr_red[j] >> 2; green_gain_offset[j] = coarse->min_green; green_gain_offset[j + 1] = corr_green[j] >> 2; blue_gain_offset[j] = coarse->min_blue; blue_gain_offset[j + 1] = corr_blue[j] >> 2; } } write_default_offset_gain (s, red_gain_offset, 5460 * 2, 0); write_default_offset_gain (s, green_gain_offset, 5460 * 2, 1); write_default_offset_gain (s, blue_gain_offset, 5460 * 2, 2); } } } status = SANE_STATUS_GOOD; done: if (corr_red) free (corr_red); if (corr_green) free (corr_green); if (corr_blue) free (corr_blue); if (cal_line) free (cal_line); if (average) free (average); return status; } static void ciclic_buffer_init_offset_correction (ciclic_buffer_t * cb, int vres) { cb->blue_idx = 0; switch (vres) { case 600: cb->green_idx = 4; cb->red_idx = 8; cb->first_good_line = 8; break; case 400: cb->green_idx = 3; cb->red_idx = 6; cb->first_good_line = 6; break; case 300: cb->green_idx = 2; cb->red_idx = 4; cb->first_good_line = 4; break; case 200: cb->blue_idx = 0; cb->green_idx = 1; cb->red_idx = 2; cb->first_good_line = 4; break; case 150: cb->green_idx = 1; cb->red_idx = 2; cb->first_good_line = 2; break; case 75: cb->green_idx = 1; cb->red_idx = 2; cb->first_good_line = 2; break; default: cb->green_idx = 0; cb->red_idx = 0; cb->first_good_line = 0; break; } cb->buffer_position = cb->buffer_ptrs[cb->first_good_line]; } static SANE_Status ciclic_buffer_init (ciclic_buffer_t * cb, SANE_Int bytes_per_line, int vres, int status_bytes) { cb->good_bytes = 0; cb->num_lines = 12; cb->size = bytes_per_line * cb->num_lines; cb->can_consume = cb->size + cb->num_lines * status_bytes; cb->buffer = malloc (cb->size); if (!cb->buffer) return SANE_STATUS_NO_MEM; { int i; unsigned char *buffer; unsigned char **ptrs; ptrs = cb->buffer_ptrs = (unsigned char **) malloc (sizeof (unsigned char *) * cb->num_lines); if (!cb->buffer_ptrs) return SANE_STATUS_NO_MEM; buffer = cb->buffer; for (i = 0; i < cb->num_lines; i++) { ptrs[i] = buffer; buffer += bytes_per_line; } } cb->current_line = 0; cb->pixel_position = 0; ciclic_buffer_init_offset_correction (cb, vres); return SANE_STATUS_GOOD; } static int prepare_for_a_scan (HP4200_Scanner * s) { /* local scanning params */ int active_pixels_start; int line_end; int data_pixels_start; int data_pixels_end; int ff_step_size; int dpd; int step_size; char steps_to_reverse; char hdpi_div; char line_rate_color; int hdpi_code; unsigned char pixel_packing; unsigned char data_mode; unsigned char AFE_operation; int pause_limit; int n = 0, m = 0; setreg (s, 0x07, 0x00); usleep (10 * 1000); hdpi_code = compute_hdpi_code (s->user_parms.horizontal_resolution); /* figure out which horizontal divider to use based on the calculated horizontal dpi code */ hdpi_div = hdpi_mapping[hdpi_code]; /* image_width is set to the correct number of pixels by calling fxn. This might be the reason we can't do high res full width scans though...not sure. */ /*s->user_parms.image_width /= 4; */ active_pixels_start = 0x40; line_end = 0x2ee0; /* 2ee0 */ s->mclk_div = 2; data_pixels_start = 0x72 + s->runtime_parms.first_pixel * hdpi_div; data_pixels_end = (int) (data_pixels_start + s->user_parms.image_width * hdpi_div); data_pixels_end = min (data_pixels_end, line_end - 20); setreg (s, 0x1e, HIBYTE (active_pixels_start)); setreg (s, 0x1f, LOBYTE (active_pixels_start)); setreg (s, 0x20, HIBYTE (line_end)); setreg (s, 0x21, LOBYTE (line_end)); setreg (s, 0x22, HIBYTE (data_pixels_start)); setreg (s, 0x23, LOBYTE (data_pixels_start)); setreg (s, 0x24, HIBYTE (data_pixels_end)); setreg (s, 0x25, LOBYTE (data_pixels_end)); AFE_operation = PIXEL_RATE_3_CHANNELS; setreg (s, 0x26, AFE_operation | GRAY_CHANNEL_RED | TR_RED (0) | TR_GREEN (0) | TR_BLUE (0)); setreg (s, 0x08, (s->mclk_div - 1) * 2); pixel_packing = 3; data_mode = 0; setreg (s, 0x09, hdpi_code | PIXEL_PACKING (pixel_packing) | DATAMODE (data_mode)); setreg (s, 0x0a, 0); /* reserved and strange register */ setreg (s, 0x5c, 0x00); setreg (s, 0x5d, 0x00); setreg (s, 0x5e, 0x00); if (s->user_parms.vertical_resolution == 1200) { /* 1 out of 2 */ n = 1; m = 2; } setreg (s, 0x44, (256 - n) & 0xff); setreg (s, 0x5a, m); s->runtime_parms.status_bytes = (m == 0) ? 1 : m; if (data_mode == 1) s->runtime_parms.status_bytes *= 2; s->runtime_parms.scanner_line_size = compute_bytes_per_line (data_pixels_end - data_pixels_start, hdpi_code, pixel_packing, data_mode, AFE_operation, m); pause_limit = compute_pause_limit (&(s->hw_parms), s->runtime_parms.scanner_line_size); #ifdef DEBUG fprintf (stderr, "scanner_line_size = %d\npause_limit = %d\n", s->runtime_parms.scanner_line_size, pause_limit); #endif setreg (s, 0x4e, pause_limit); /* max Kb to pause */ setreg (s, 0x4f, 0x02); /* min Kb to resume */ line_rate_color = 1; step_size = (s->user_parms.vertical_resolution * line_end * line_rate_color) / (4 * s->hw_parms.motor_full_steps_per_inch); if (s->val[OPT_BACKTRACK].b) { steps_to_reverse = 0x3f; setreg (s, 0x50, steps_to_reverse); setreg (s, 0x51, 0x15); /* accel profile */ } else { s->hw_parms.steps_to_reverse = 0; setreg (s, 0x50, s->hw_parms.steps_to_reverse); setreg (s, 0x51, 0); /* accel profile */ s->hw_parms.fsteps_25_speed = 0; s->hw_parms.fsteps_50_speed = 0; } dpd = compute_dpd (s, step_size, line_end); /* 0x0ada; */ #ifdef DEBUG fprintf (stderr, "dpd = %d\n", dpd); #endif setreg (s, 0x52, HIBYTE (dpd)); setreg (s, 0x53, LOBYTE (dpd)); setreg (s, 0x46, HIBYTE (step_size)); setreg (s, 0x47, LOBYTE (step_size)); ff_step_size = compute_fastfeed_step_size (s->hw_parms.crystal_frequency, s->mclk_div, s->hw_parms.motor_max_speed, s->hw_parms. motor_full_steps_per_inch, 0); setreg (s, 0x48, HIBYTE (ff_step_size)); setreg (s, 0x49, LOBYTE (ff_step_size)); setreg (s, 0x4b, 0x15); /* this is to stay the motor running */ setbits (s, 0x45, (1 << 4)); setreg (s, 0x4a, HIBYTE (47 + s->runtime_parms.steps_to_skip)); setreg (s, 0x4b, LOBYTE (47 + s->runtime_parms.steps_to_skip)); setreg (s, 0x58, 0); ciclic_buffer_init (&(s->ciclic_buffer), s->runtime_parms.image_line_size, s->user_parms.vertical_resolution, s->runtime_parms.status_bytes); s->runtime_parms.num_bytes_left_to_scan = s->user_parms.lines_to_scan * s->runtime_parms.image_line_size; #ifdef DEBUG fprintf (stderr, "bytes to scan = %ld\n", s->runtime_parms.num_bytes_left_to_scan); #endif cache_write (s); #ifdef DEBUG lm9830_dump_registers (s->fd); #endif lm9830_reset (s->fd); setreg (s, 0x07, 0x03); usleep (100); return SANE_STATUS_GOOD; } static SANE_Status end_scan (HP4200_Scanner * s) { s->scanning = SANE_FALSE; setreg (s, 0x07, 0x00); lm9830_reset (s->fd); setbits (s, 0x58, PAPER_SENSOR_2_STOP_SCAN); cache_write (s); setreg (s, 0x07, 0x02); /* Free some buffers */ if (s->ciclic_buffer.buffer) { free (s->ciclic_buffer.buffer); s->ciclic_buffer.buffer = NULL; } if (s->ciclic_buffer.buffer_ptrs) { free (s->ciclic_buffer.buffer_ptrs); s->ciclic_buffer.buffer_ptrs = NULL; } if (s->scanner_buffer.buffer) { free (s->scanner_buffer.buffer); s->scanner_buffer.buffer = NULL; } return SANE_STATUS_GOOD; } static int hp4200_init_scanner (HP4200_Scanner * s) { int ff_step_size; int mclk_div; lm9830_ini_scanner (s->fd, NULL); hp4200_init_registers (s); scanner_buffer_init (&(s->scanner_buffer), s->hw_parms.SRAM_size); setreg (s, 0x07, 0x08); usleep (10 * 1000); setreg (s, 0x07, 0x00); usleep (10 * 1000); mclk_div = 2; setreg (s, 0x08, (mclk_div - 1) * 2); ff_step_size = compute_fastfeed_step_size (s->hw_parms.crystal_frequency, mclk_div, s->hw_parms.motor_max_speed, s->hw_parms.motor_full_steps_per_inch, 0); setreg (s, 0x48, HIBYTE (ff_step_size)); setreg (s, 0x49, LOBYTE (ff_step_size)); setbits (s, 0x45, (1 << 4)); cache_write (s); return 0; } static void ciclic_buffer_copy (ciclic_buffer_t * cb, SANE_Byte * buf, SANE_Int num_bytes, int image_line_size, int status_bytes) { int biggest_upper_block_size; int upper_block_size; int lower_block_size; int bytes_to_be_a_entire_line; /* copy the upper block */ biggest_upper_block_size = cb->size - (cb->buffer_position - cb->buffer); upper_block_size = min (biggest_upper_block_size, num_bytes); memcpy (buf, cb->buffer_position, upper_block_size); cb->good_bytes -= upper_block_size; bytes_to_be_a_entire_line = (cb->buffer_position - cb->buffer) % image_line_size; cb->can_consume += upper_block_size + status_bytes * (((bytes_to_be_a_entire_line + upper_block_size) / image_line_size) - 1); if (num_bytes < biggest_upper_block_size) { cb->buffer_position += num_bytes; return; } /* copy the lower block */ lower_block_size = num_bytes - biggest_upper_block_size; if (lower_block_size > 0) { memcpy (buf + biggest_upper_block_size, cb->buffer, lower_block_size); cb->good_bytes -= lower_block_size; cb->can_consume += lower_block_size + status_bytes * (lower_block_size / image_line_size); cb->buffer_position = cb->buffer + lower_block_size; } else { cb->buffer_position = cb->buffer; } assert (cb->good_bytes >= 0); assert (lower_block_size >= 0); } static void ciclic_buffer_consume (ciclic_buffer_t * cb, scanner_buffer_t * scanner_buffer, int image_width, int status_bytes) { int to_consume; int to_consume_now; int i; int processed; to_consume = min (cb->can_consume, scanner_buffer->num_bytes); while (to_consume) { if (cb->pixel_position == image_width) { if (scanner_buffer->num_bytes >= status_bytes) { /* forget status bytes */ scanner_buffer->data_ptr += status_bytes; scanner_buffer->num_bytes -= status_bytes; cb->can_consume -= status_bytes; to_consume -= status_bytes; cb->pixel_position = 0; /* back to the start pixel */ cb->red_idx = (cb->red_idx + 1) % cb->num_lines; cb->green_idx = (cb->green_idx + 1) % cb->num_lines; cb->blue_idx = (cb->blue_idx + 1) % cb->num_lines; cb->current_line++; } else break; } to_consume_now = min ((image_width - cb->pixel_position) * 3, to_consume); if (to_consume_now < 3) break; for (i = cb->pixel_position * 3; to_consume_now >= 3; i += 3, to_consume_now -= 3) { cb->buffer_ptrs[cb->red_idx][i] = scanner_buffer->data_ptr[0]; cb->buffer_ptrs[cb->green_idx][i + 1] = scanner_buffer->data_ptr[1]; cb->buffer_ptrs[cb->blue_idx][i + 2] = scanner_buffer->data_ptr[2]; scanner_buffer->data_ptr += 3; } processed = i - (cb->pixel_position * 3); cb->pixel_position = i / 3; to_consume -= processed; cb->can_consume -= processed; scanner_buffer->num_bytes -= processed; if (cb->current_line > cb->first_good_line) cb->good_bytes += processed; } } SANE_Status sane_read (SANE_Handle h, SANE_Byte * buf, SANE_Int maxlen, SANE_Int * len) { SANE_Status status; int to_copy_now; int bytes_to_copy_to_frontend; HP4200_Scanner *s = h; static char me[] = "sane_read"; DBG (DBG_proc, "%s\n", me); if (!(s->scanning)) { /* OOPS, not scanning */ return SANE_STATUS_CANCELLED; } if (!buf || !len) return SANE_STATUS_INVAL; *len = 0; if (s->runtime_parms.num_bytes_left_to_scan == 0) { end_scan (s); return SANE_STATUS_EOF; } bytes_to_copy_to_frontend = min (s->runtime_parms.num_bytes_left_to_scan, maxlen); /* first copy available data from the ciclic buffer */ to_copy_now = min (s->ciclic_buffer.good_bytes, bytes_to_copy_to_frontend); if (to_copy_now > 0) { ciclic_buffer_copy (&(s->ciclic_buffer), buf, to_copy_now, s->runtime_parms.image_line_size, s->runtime_parms.status_bytes); buf += to_copy_now; bytes_to_copy_to_frontend -= to_copy_now; *len += to_copy_now; } /* if not enough bytes, get data from the scanner */ while (bytes_to_copy_to_frontend) { if (s->scanner_buffer.num_bytes < 3) { /* cicl buf consumes modulo 3 bytes at least now for rgb color 8 bpp fixme: but this is ugly and not generic */ status = scanner_buffer_read (s); if (status == SANE_STATUS_CANCELLED) { end_scan (s); s->aborted_by_user = SANE_FALSE; return status; } if (status != SANE_STATUS_GOOD) return status; } while ((s->scanner_buffer.num_bytes > 3) && bytes_to_copy_to_frontend) { ciclic_buffer_consume (&(s->ciclic_buffer), &(s->scanner_buffer), s->user_parms.image_width, s->runtime_parms.status_bytes); to_copy_now = min (s->ciclic_buffer.good_bytes, bytes_to_copy_to_frontend); if (to_copy_now > 0) { ciclic_buffer_copy (&(s->ciclic_buffer), buf, to_copy_now, s->runtime_parms.image_line_size, s->runtime_parms.status_bytes); buf += to_copy_now; bytes_to_copy_to_frontend -= to_copy_now; *len += to_copy_now; } } } s->runtime_parms.num_bytes_left_to_scan -= *len; if (s->runtime_parms.num_bytes_left_to_scan < 0) *len += s->runtime_parms.num_bytes_left_to_scan; return SANE_STATUS_GOOD; } static HP4200_Device * find_device (SANE_String_Const name) { static char me[] = "find_device"; HP4200_Device *dev; DBG (DBG_proc, "%s\n", me); for (dev = first_device; dev; dev = dev->next) { if (strcmp (dev->dev.name, name) == 0) { return dev; } } return NULL; } static SANE_Status add_device (SANE_String_Const name, HP4200_Device ** argpd) { int fd; HP4200_Device *pd; static const char me[] = "add_device"; SANE_Status status; DBG (DBG_proc, "%s(%s)\n", me, name); /* Avoid adding the same device more than once */ if ((pd = find_device (name))) { if (argpd) *argpd = pd; return SANE_STATUS_GOOD; } /* open the device file, but read only or read/write to perform ioctl's ? */ if ((status = sanei_usb_open (name, &fd)) != SANE_STATUS_GOOD) { DBG (DBG_error, "%s: open(%s) failed: %s\n", me, name, sane_strstatus (status)); return SANE_STATUS_INVAL; } /* put here some code to probe that the device attached to the device file is a supported scanner. Maybe some ioctl */ sanei_usb_close (fd); pd = (HP4200_Device *) calloc (1, sizeof (HP4200_Device)); if (!pd) { DBG (DBG_error, "%s: out of memory allocating device.\n", me); return SANE_STATUS_NO_MEM; } pd->dev.name = strdup (name); pd->dev.vendor = "Hewlett-Packard"; pd->dev.model = "HP-4200"; pd->dev.type = "flatbed scanner"; if (!pd->dev.name || !pd->dev.vendor || !pd->dev.model || !pd->dev.type) { DBG (DBG_error, "%s: out of memory allocating device descriptor strings.\n", me); free (pd); return SANE_STATUS_NO_MEM; } pd->handle = NULL; pd->next = first_device; first_device = pd; n_devices++; if (argpd) *argpd = pd; return SANE_STATUS_GOOD; } static SANE_Status attach (SANE_String_Const name) { static char me[] = "attach"; DBG (DBG_proc, "%s\n", me); return add_device (name, NULL); } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { static const char me[] = "sane_hp4200_init"; char dev_name[PATH_MAX]; FILE *fp; authorize = authorize; /* keep gcc quiet */ DBG_INIT (); DBG (DBG_proc, "%s\n", me); DBG (DBG_error, "SANE hp4200 backend version %d.%d build %d from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); /* put some version_code checks here */ if (NULL != version_code) { *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); } sanei_usb_init (); sanei_pv8630_init (); fp = sanei_config_open (HP4200_CONFIG_FILE); if (!fp) { DBG (DBG_error, "%s: configuration file not found!\n", me); return SANE_STATUS_INVAL; } else { while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; if (strlen (dev_name) == 0) continue; /* ignore empty lines */ DBG (DBG_info, "%s: looking for devices matching %s\n", me, dev_name); sanei_usb_attach_matching_devices (dev_name, attach); } fclose (fp); } return SANE_STATUS_GOOD; } void sane_exit (void) { HP4200_Device *device, *next; DBG (DBG_proc, "sane_hp4200_exit\n"); for (device = first_device; device; device = next) { next = device->next; if (device->handle) { sane_close (device->handle); } if (device->dev.name) { free ((void *) device->dev.name); } free (device); } first_device = NULL; if (devlist) { free (devlist); devlist = NULL; } n_devices = 0; DBG (DBG_proc, "sane_exit: exit\n"); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { int i; HP4200_Device *pdev; DBG (DBG_proc, "sane_get_devices (%p, %d)\n", (void *) device_list, local_only); /* Waste the last list returned from this function */ if (devlist) free (devlist); devlist = (const SANE_Device **) malloc ((n_devices + 1) * sizeof (SANE_Device *)); if (!devlist) { DBG (DBG_error, "sane_get_devices: out of memory\n"); return SANE_STATUS_NO_MEM; } for (i = 0, pdev = first_device; pdev; i++, pdev = pdev->next) { devlist[i] = &(pdev->dev); } devlist[i] = NULL; *device_list = devlist; DBG (DBG_proc, "sane_get_devices: exit\n"); return SANE_STATUS_GOOD; } static void init_options (HP4200_Scanner * s) { s->opt[OPT_NUM_OPTS].name = ""; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].unit = SANE_UNIT_NONE; s->opt[OPT_NUM_OPTS].size = sizeof (SANE_Word); s->opt[OPT_NUM_OPTS].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; s->opt[OPT_RES].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RES].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RES].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RES].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_RES].type = SANE_TYPE_INT; s->opt[OPT_RES].size = sizeof (SANE_Word); s->opt[OPT_RES].unit = SANE_UNIT_DPI; s->opt[OPT_RES].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_RES].constraint.word_list = dpi_list; s->val[OPT_RES].w = 150; s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].size = sizeof (SANE_Fixed); s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &x_range; s->val[OPT_TL_X].w = x_range.min; s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].size = sizeof (SANE_Fixed); s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &y_range; s->val[OPT_TL_Y].w = y_range.min; s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].size = sizeof (SANE_Fixed); s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &x_range; s->val[OPT_BR_X].w = x_range.max; s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].size = sizeof (SANE_Fixed); s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &y_range; s->val[OPT_BR_Y].w = y_range.max; s->opt[OPT_BACKTRACK].name = SANE_NAME_BACKTRACK; s->opt[OPT_BACKTRACK].title = SANE_TITLE_BACKTRACK; s->opt[OPT_BACKTRACK].desc = SANE_DESC_BACKTRACK; s->opt[OPT_BACKTRACK].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_BACKTRACK].type = SANE_TYPE_BOOL; s->opt[OPT_BACKTRACK].size = sizeof (SANE_Bool); s->opt[OPT_BACKTRACK].unit = SANE_UNIT_NONE; s->opt[OPT_BACKTRACK].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_BACKTRACK].b = SANE_TRUE; s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].size = 1024 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_R].wa = s->user_parms.gamma[0]; s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].size = 1024 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_G].wa = s->user_parms.gamma[1]; s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].size = 1024 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_B].wa = s->user_parms.gamma[2]; { int i; double gamma = 2.0; for (i = 0; i < 1024; i++) { s->user_parms.gamma[0][i] = 255 * pow (((double) i + 1) / 1024, 1.0 / gamma); s->user_parms.gamma[1][i] = s->user_parms.gamma[0][i]; s->user_parms.gamma[2][i] = s->user_parms.gamma[0][i]; #ifdef DEBUG printf ("%d %d\n", i, s->user_parms.gamma[0][i]); #endif } } /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->opt[OPT_PREVIEW].size = sizeof (SANE_Word); s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->val[OPT_PREVIEW].w = SANE_FALSE; } SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h) { static const char me[] = "sane_hp4200_open"; SANE_Status status; HP4200_Device *dev; HP4200_Scanner *s; DBG (DBG_proc, "%s (%s, %p)\n", me, name, (void *) h); if (name && name[0]) { dev = find_device (name); if (!dev) { status = add_device (name, &dev); if (status != SANE_STATUS_GOOD) return status; } } else { dev = first_device; } if (!dev) return SANE_STATUS_INVAL; if (!h) return SANE_STATUS_INVAL; s = *h = (HP4200_Scanner *) calloc (1, sizeof (HP4200_Scanner)); if (!s) { DBG (DBG_error, "%s: out of memory creating scanner structure.\n", me); return SANE_STATUS_NO_MEM; } dev->handle = s; s->aborted_by_user = SANE_FALSE; s->ciclic_buffer.buffer = NULL; s->scanner_buffer.buffer = NULL; s->dev = dev; s->user_parms.image_width = 0; s->user_parms.lines_to_scan = 0; s->user_parms.vertical_resolution = 0; s->scanning = SANE_FALSE; s->fd = -1; init_options (s); if ((sanei_usb_open (dev->dev.name, &s->fd) != SANE_STATUS_GOOD)) { DBG (DBG_error, "%s: Can't open %s.\n", me, dev->dev.name); return SANE_STATUS_IO_ERROR; /* fixme: return busy when file is being accessed already */ } return SANE_STATUS_GOOD; } void sane_close (SANE_Handle h) { HP4200_Scanner *s = (HP4200_Scanner *) h; DBG (DBG_proc, "sane_hp4200_close (%p)\n", (void *) h); if (s) { s->dev->handle = NULL; if (s->fd != -1) { sanei_usb_close (s->fd); } free (s); } } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle h, SANE_Int n) { static char me[] = "sane_get_option_descriptor"; HP4200_Scanner *s = (HP4200_Scanner *) h; DBG (DBG_proc, "%s\n", me); if ((n < 0) || (n >= NUM_OPTIONS)) return NULL; return s->opt + n; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { HP4200_Scanner *s = (HP4200_Scanner *) handle; SANE_Status status; SANE_Int myinfo = 0; SANE_Word cap; DBG (DBG_proc, "sane_control_option\n"); if (info) *info = 0; if (s->scanning) { return SANE_STATUS_DEVICE_BUSY; } if (option < 0 || option >= NUM_OPTIONS) { return SANE_STATUS_INVAL; } cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { return SANE_STATUS_INVAL; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { case OPT_NUM_OPTS: case OPT_RES: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_PREVIEW: *(SANE_Word *) val = s->val[option].w; break; case OPT_BACKTRACK: *(SANE_Bool *) val = s->val[option].b; break; case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (val, s->val[option].wa, s->opt[option].size); break; default: return SANE_STATUS_UNSUPPORTED; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (DBG_error, "could not set option, not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (s->opt + option, val, &myinfo); if (status != SANE_STATUS_GOOD) return status; switch (option) { /* Numeric side-effect free options */ case OPT_PREVIEW: s->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* Numeric side-effect options */ case OPT_RES: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: myinfo |= SANE_INFO_RELOAD_PARAMS; s->val[option].w = *(SANE_Word *) val; break; case OPT_BACKTRACK: s->val[option].b = *(SANE_Bool *) val; break; case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (s->val[option].wa, val, s->opt[option].size); break; default: return SANE_STATUS_UNSUPPORTED; } } else { return SANE_STATUS_UNSUPPORTED; } if (info) *info = myinfo; return SANE_STATUS_GOOD; } static void compute_parameters (HP4200_Scanner * s) { int resolution; int opt_tl_x; int opt_br_x; int opt_tl_y; int opt_br_y; if (s->val[OPT_PREVIEW].w == SANE_TRUE) { resolution = 50; opt_tl_x = SANE_UNFIX (x_range.min); opt_tl_y = SANE_UNFIX (y_range.min); opt_br_x = SANE_UNFIX (x_range.max); opt_br_y = SANE_UNFIX (y_range.max); } else { resolution = s->val[OPT_RES].w; opt_tl_x = SANE_UNFIX (s->val[OPT_TL_X].w); opt_tl_y = SANE_UNFIX (s->val[OPT_TL_Y].w); opt_br_x = SANE_UNFIX (s->val[OPT_BR_X].w); opt_br_y = SANE_UNFIX (s->val[OPT_BR_Y].w); } s->user_parms.horizontal_resolution = resolution; s->user_parms.vertical_resolution = resolution; s->runtime_parms.steps_to_skip = floor (300.0 / MM_PER_INCH * opt_tl_y); s->user_parms.lines_to_scan = floor ((opt_br_y - opt_tl_y) / MM_PER_INCH * resolution); s->user_parms.image_width = floor ((opt_br_x - opt_tl_x) / MM_PER_INCH * resolution); s->runtime_parms.first_pixel = floor (opt_tl_x / MM_PER_INCH * resolution); /* fixme: add support for more depth's and bpp's. */ s->runtime_parms.image_line_size = s->user_parms.image_width * 3; } SANE_Status sane_get_parameters (SANE_Handle h, SANE_Parameters * p) { static char me[] = "sane_get_parameters"; HP4200_Scanner *s = (HP4200_Scanner *) h; DBG (DBG_proc, "%s\n", me); if (!p) return SANE_STATUS_INVAL; p->format = SANE_FRAME_RGB; p->last_frame = SANE_TRUE; p->depth = 8; if (!s->scanning) { compute_parameters (s); } p->lines = s->user_parms.lines_to_scan; p->pixels_per_line = s->user_parms.image_width; p->bytes_per_line = s->runtime_parms.image_line_size; return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle h) { HP4200_Scanner *s = (HP4200_Scanner *) h; struct coarse_t coarse; static char me[] = "sane_start"; DBG (DBG_proc, "%s\n", me); s->scanning = SANE_TRUE; s->aborted_by_user = SANE_FALSE; s->user_parms.color = SANE_TRUE; compute_parameters (s); hp4200_init_scanner (s); hp4200_goto_home (s); hp4200_wait_homed (s); /* restore default register values here... */ write_gamma (s); hp4200_init_registers (s); lm9830_ini_scanner (s->fd, NULL); /* um... do not call cache_write() here, don't know why :( */ do_coarse_calibration (s, &coarse); do_fine_calibration (s, &coarse); prepare_for_a_scan (s); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle h) { static char me[] = "sane_cancel"; HP4200_Scanner *s = (HP4200_Scanner *) h; DBG (DBG_proc, "%s\n", me); s->aborted_by_user = SANE_TRUE; end_scan (s); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { HP4200_Scanner *dev = handle; SANE_Status status; non_blocking = non_blocking; /* silence gcc */ if (dev->scanning == SANE_FALSE) { return SANE_STATUS_INVAL; } if (non_blocking == SANE_FALSE) { status = SANE_STATUS_GOOD; } else { status = SANE_STATUS_UNSUPPORTED; } DBG (DBG_proc, "sane_set_io_mode: exit\n"); return status; } SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fd) { static char me[] = "sane_get_select_fd"; h = h; /* keep gcc quiet */ fd = fd; /* keep gcc quiet */ DBG (DBG_proc, "%s\n", me); return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/hpsj5s.h0000666000000000000000000000526513615534521014165 00000000000000#ifndef __HPSJ5S_MIDDLE_LEVEL_API_HEADER__ #define __HPSJ5S_MIDDLE_LEVEL_API_HEADER__ #include /*Scanner hardware registers*/ #define REGISTER_FUNCTION_CODE 0x70 /*Here goes function code */ #define REGISTER_FUNCTION_PARAMETER 0x60 /*Here goes function param */ #define ADDRESS_RESULT 0x20 /*Here we get result */ /*Scanner functions (not all - some of them I cann't identify)*/ #define FUNCTION_SETUP_HARDWARE 0xA0 /*Scanner hardware control flags:*/ /*Set this flag and non-zero speed to start rotation*/ #define FLAGS_HW_MOTOR_READY 0x1 /*Set this flag to turn on lamp*/ #define FLAGS_HW_LAMP_ON 0x2 /*Set this flag to turn indicator lamp off*/ #define FLAGS_HW_INDICATOR_OFF 0x4 /* Types: */ /*Color modes we support: 1-bit Drawing, 2-bit Halftone, 8-bit Gray Scale, 24-bt True Color*/ typedef enum { Drawing, Halftone, GrayScale, TrueColor } enumColorDepth; /*Middle-level API:*/ static int OpenScanner (const char *scanner_path); static void CloseScanner (int handle); static int DetectScanner (void); static void StandByScanner (void); static void SwitchHardwareState (SANE_Byte mask, SANE_Byte invert_mask); static int CheckPaperPresent (void); static int ReleasePaper (void); static int PaperFeed (SANE_Word wLinesToFeed); static void TransferScanParameters (enumColorDepth enColor, SANE_Word wResolution, SANE_Word wCorrectedLength); static void TurnOnPaperPulling (enumColorDepth enColor, SANE_Word wResolution); static void TurnOffPaperPulling (void); static SANE_Byte GetCalibration (void); static void CalibrateScanElements (void); /*Internal-use functions:*/ static int OutputCheck (void); static int InputCheck (void); static int CallCheck (void); static void LoadingPaletteToScanner (void); /*Low level warappers:*/ static void WriteAddress (SANE_Byte Address); static void WriteData (SANE_Byte Data); static void WriteScannerRegister (SANE_Byte Address, SANE_Byte Data); static void CallFunctionWithParameter (SANE_Byte Function, SANE_Byte Parameter); static SANE_Byte CallFunctionWithRetVal (SANE_Byte Function); static SANE_Byte ReadDataByte (void); static void ReadDataBlock (SANE_Byte * Buffer, int lenght); /*Daisy chaining API: (should be moved to ieee1284 library in future)*/ /*Deselect all devices in chain on this port.*/ static void daisy_deselect_all (struct parport *port); /*Select device with number 'daisy' in 'mode'.*/ static int daisy_select (struct parport *port, int daisy, int mode); /*Setup address for device in chain on this port*/ static int assign_addr (struct parport *port, int daisy); /* Send a daisy-chain-style CPP command packet. */ static int cpp_daisy (struct parport *port, int cmd); #endif sane-backends-1.0.29/backend/Makefile.am0000666000000000000000000021474213615534521014636 00000000000000## Makefile.am -- an automake template for Makefile.in file ## Copyright (C) 2009 Chris Bagwell, Olaf Meeuwissen, and Sane Developers. ## ## This file is part of the "Sane" build infra-structure. See ## included LICENSE file for license information. 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. DIST_SANELIBS_LDFLAGS = $(AM_LDFLAGS) -rpath '$(libdir)/sane' -version-number $(V_MAJOR):$(V_MINOR):$(V_REV) $(DYNAMIC_FLAG) 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 += --silent FIRMWARE_DIRS = artec_eplus48u gt68xx snapscan epjitsu # Needed by most backends as they add sane_strstatus.lo to their list # of libraries to link with via libsane_${BACKEND}_la_LIBADD. Due to # the implicit dependency, automake does not notice the need to clean # up the dependency tracking file. EXTRA_DIST = sane_strstatus.c CLEANFILES = $(DEPDIR)/sane_strstatus.Plo all: becfg 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 $(AM_V_at)rm -f $@ $(AM_V_at)$(LN_S) $(srcdir)/stubs.c $@ %-s.cpp: $(srcdir)/stubs.c $(AM_V_at)rm -f $@ $(AM_V_at)$(LN_S) $(srcdir)/stubs.c $@ dll-preload.h: $(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[] = {" >> $@; \ sep=""; \ list="$(PRELOADABLE_BACKENDS)"; \ if test -z "$${list}"; then \ echo { 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }} >> $@; \ else \ for be in $$list; do \ echo "$${sep}PRELOAD_DEFN($$be)" >> $@; \ sep=","; \ done; \ fi; \ echo "};" >> $@ # TODO: This really belongs together with the saned sources and # should be installed there as well. EXTRA_DIST += saned.conf.in # Backends are not required to have a config file. Any backend # that wants to install a config file should list it here. BACKEND_CONFS= abaton.conf agfafocus.conf apple.conf artec.conf \ artec_eplus48u.conf avision.conf bh.conf \ canon630u.conf canon.conf canon_dr.conf \ canon_pp.conf cardscan.conf coolscan2.conf coolscan3.conf \ coolscan.conf dc210.conf dc240.conf dc25.conf \ dell1600n_net.conf dmc.conf epjitsu.conf epson2.conf \ epson.conf epsonds.conf escl.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 \ p5.conf \ pie.conf pieusb.conf pixma.conf plustek.conf plustek_pp.conf \ qcam.conf ricoh.conf rts8891.conf s9036.conf sceptre.conf \ sharp.conf sm3840.conf snapscan.conf sp15c.conf \ st400.conf stv680.conf tamarack.conf \ teco1.conf teco2.conf teco3.conf test.conf \ u12.conf umax1220u.conf umax.conf umax_pp.conf v4l.conf \ xerox_mfp.conf dll.conf saned.conf # Although ./configure sets up BACKEND_CONFS_ENABLED it does not take # into account the fact that some backends don't have a configuration # file. The becfg should depend on BACKEND_CONFS. The install-becfg # target uses BACKEND_CONFS_ENABLED and silently skips missing files. becfg: $(BACKEND_CONFS) SUFFIXES = .conf.in .conf .conf.in.conf: @echo Generating $@ from $^ @sed -e 's|@DATADIR@|$(datadir)|g' \ -e 's|@CONFIGDIR@|$(configdir)|g' \ -e 's|@DOCDIR@|$(docdir)|g' \ -e 's|@LIBDIR@|$(libdir)/sane|g' \ -e 's|@BINDIR@|$(bindir)|g' \ -e 's|@SBINDIR@|$(sbindir)|g' \ -e 's|@PACKAGEVERSION@|$(PACKAGE_VERSION)|g' $? > $@ install-data-hook: install-becfg install-firmware-path $(INSTALL_LOCKPATH) # Custom install target to install config files. Do not overwrite # files that have been previously installed so that user modifications # are not lost. install-becfg: becfg @# Libtool has a bug where it will sometimes symlink the last @# installed library in $(sanelibdir) to $(sanelibdir)/libsane.*. @# Having two libsane's can cause issues so get rid of it. -rm -f $(DESTDIR)$(sanelibdir)/libsane.* test -z "$(configdir)" || $(MKDIR_P) "$(DESTDIR)$(configdir)" test -z "$(configdir)/dll.d" || $(MKDIR_P) "$(DESTDIR)$(configdir)/dll.d" @list="$(BACKEND_CONFS_ENABLED) saned.conf dll.conf"; for cfg in $$list; do \ if test ! -r $${cfg}; then continue; fi; \ if test -f $(DESTDIR)$(configdir)/$${cfg}; then \ echo NOT overwriting $${cfg} in $(configdir)...; \ else \ echo installing $${cfg} in $(configdir)/$${cfg}...; \ $(INSTALL_DATA) $${cfg} $(DESTDIR)$(configdir)/$${cfg} \ || exit 1; \ fi; \ done install-firmware-path: for dir in $(FIRMWARE_DIRS) ; do \ $(mkinstalldirs) $(DESTDIR)$(datadir)/sane/$${dir} ; \ done install-lockpath: $(mkinstalldirs) -m 775 $(DESTDIR)$(locksanedir) uninstall-hook: rm -rf $(DESTDIR)$(libdir)/sane $(DESTDIR)$(configdir) $(DESTDIR)$(locksanedir) rm -f $(DESTDIR)$(libdir)/libsane.* -for dir in $(FIRMWARE_DIRS) ; do \ rmdir $(DESTDIR)$(datadir)/sane/$${dir} ; \ done CLEANFILES += $(BACKEND_CONFS) $(be_convenience_libs) clean-local: find . -type l -name \*-s.c | xargs rm -f # Backends # # All possible backends should be listed here. As a first step, we create # a convenience library containing all files needed to link a backend # directly into libsane.la. Convenience library should have the # form of lib${backend}.la to match what configure will list to # build. # Occasionally, this approach will have name conflicts with external # libraries that need to be linked in. See libgphoto2_i.la for # example of working around that issue. be_convenience_libs = libabaton.la libagfafocus.la \ libapple.la libartec.la libartec_eplus48u.la \ libas6e.la libavision.la libbh.la \ libcanon.la libcanon630u.la libcanon_dr.la \ libcanon_pp.la libcardscan.la libcoolscan.la \ libcoolscan2.la libcoolscan3.la libdc25.la \ libdc210.la libdc240.la libdell1600n_net.la \ libdmc.la libdll.la libdll_preload.la libepjitsu.la libepson.la \ libepson2.la libepsonds.la libescl.la libfujitsu.la libgenesys.la \ libgphoto2_i.la libgt68xx.la libhp.la \ libhp3500.la libhp3900.la libhp4200.la \ libhp5400.la libhp5590.la libhpljm1005.la \ libhpsj5s.la libhs2p.la libibm.la libkodak.la libkodakaio.la\ libkvs1025.la libkvs20xx.la libkvs40xx.la \ libleo.la liblexmark.la libma1509.la libmagicolor.la \ libmatsushita.la libmicrotek.la libmicrotek2.la \ libmustek.la libmustek_pp.la libmustek_usb.la \ libmustek_usb2.la libnec.la libnet.la \ libniash.la libp5.la \ libpie.la libpieusb.la libpint.la libpixma.la \ libplustek.la libplustek_pp.la libpnm.la \ libqcam.la libricoh.la libricoh2.la librts8891.la \ libs9036.la libsceptre.la libsharp.la \ libsm3600.la libsm3840.la libsnapscan.la \ libsp15c.la libst400.la libstv680.la \ libtamarack.la libtest.la libteco1.la \ libteco2.la libteco3.la libu12.la libumax.la \ libumax1220u.la libumax_pp.la libv4l.la \ libxerox_mfp.la # Each stand alone backend thats possible to be built should be listed # here. There are the libraries that are installed under $(libdir)/sane. # Format is libsane-${backend}.la. be_dlopen_libs = libsane-abaton.la libsane-agfafocus.la \ libsane-apple.la libsane-artec.la libsane-artec_eplus48u.la \ libsane-as6e.la libsane-avision.la libsane-bh.la \ libsane-canon.la libsane-canon630u.la libsane-canon_dr.la \ libsane-canon_pp.la libsane-cardscan.la libsane-coolscan.la \ libsane-coolscan2.la libsane-coolscan3.la libsane-dc25.la \ libsane-dc210.la libsane-dc240.la libsane-dell1600n_net.la \ libsane-dmc.la libsane-epjitsu.la libsane-epson.la \ libsane-epson2.la libsane-epsonds.la libsane-escl.la libsane-fujitsu.la \ libsane-genesys.la libsane-gphoto2.la libsane-gt68xx.la libsane-hp.la \ libsane-hp3500.la libsane-hp3900.la libsane-hp4200.la \ libsane-hp5400.la libsane-hp5590.la libsane-hpljm1005.la \ libsane-hpsj5s.la libsane-hs2p.la libsane-ibm.la libsane-kodak.la libsane-kodakaio.la\ libsane-kvs1025.la libsane-kvs20xx.la libsane-kvs40xx.la \ libsane-leo.la \ libsane-lexmark.la libsane-ma1509.la libsane-magicolor.la \ libsane-matsushita.la libsane-microtek.la libsane-microtek2.la \ libsane-mustek.la libsane-mustek_pp.la libsane-mustek_usb.la \ libsane-mustek_usb2.la libsane-nec.la libsane-net.la \ libsane-niash.la libsane-p5.la \ libsane-pie.la libsane-pieusb.la libsane-pint.la libsane-pixma.la \ libsane-plustek.la libsane-plustek_pp.la libsane-pnm.la \ libsane-qcam.la libsane-ricoh.la libsane-ricoh2.la libsane-rts8891.la \ libsane-s9036.la libsane-sceptre.la libsane-sharp.la \ libsane-sm3600.la libsane-sm3840.la libsane-snapscan.la \ libsane-sp15c.la libsane-st400.la libsane-stv680.la \ libsane-tamarack.la libsane-test.la libsane-teco1.la \ libsane-teco2.la libsane-teco3.la libsane-u12.la libsane-umax.la \ libsane-umax1220u.la libsane-umax_pp.la libsane-v4l.la \ libsane-xerox_mfp.la EXTRA_LTLIBRARIES = $(be_convenience_libs) $(be_dlopen_libs) lib_LTLIBRARIES = libsane.la sanelibdir = $(libdir)/sane sanelib_LTLIBRARIES = $(BACKEND_LIBS_ENABLED) libsane-dll.la COMMON_LIBS = ../lib/liblib.la $(XML_LIBS) # Each backend should define a convenience library that compiles # all related files within backend directory. General guideline # is to have a ${backend}.c and ${backend}.h. Some backends also # add a few support source files to convience library. # Note: automake doesn't really use header files listed here. # They are indications that they need to be distributed only. libabaton_la_SOURCES = abaton.c abaton.h libabaton_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=abaton # Each backend should define a stand alone library that gets installed. # This will need to link in a special file ${backend}-s.c that allows # the backend to be stand alone and contain all SANE API functions. # Also, it will need to link in related convenience library as well as # any external libraries required to resolve symbols. # # All backends should include $(DIST_SANELIBS_LDFLAGS) so that # library is correctly versioned. # # If a backend has a config file, it must be listed here to get distributed. nodist_libsane_abaton_la_SOURCES = abaton-s.c libsane_abaton_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=abaton libsane_abaton_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_abaton_la_LIBADD = $(COMMON_LIBS) libabaton.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += abaton.conf.in libagfafocus_la_SOURCES = agfafocus.c agfafocus.h libagfafocus_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=agfafocus nodist_libsane_agfafocus_la_SOURCES = agfafocus-s.c libsane_agfafocus_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=agfafocus libsane_agfafocus_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_agfafocus_la_LIBADD = $(COMMON_LIBS) libagfafocus.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_thread.lo ../sanei/sanei_scsi.lo $(SCSI_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += agfafocus.conf.in libapple_la_SOURCES = apple.c apple.h libapple_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=apple nodist_libsane_apple_la_SOURCES = apple-s.c libsane_apple_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=apple libsane_apple_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_apple_la_LIBADD = $(COMMON_LIBS) libapple.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += apple.conf.in libartec_la_SOURCES = artec.c artec.h libartec_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=artec nodist_libsane_artec_la_SOURCES = artec-s.c libsane_artec_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_artec_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=artec libsane_artec_la_LIBADD = $(COMMON_LIBS) libartec.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += artec.conf.in libartec_eplus48u_la_SOURCES = artec_eplus48u.c artec_eplus48u.h libartec_eplus48u_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=artec_eplus48u nodist_libsane_artec_eplus48u_la_SOURCES = artec_eplus48u-s.c libsane_artec_eplus48u_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=artec_eplus48u libsane_artec_eplus48u_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_artec_eplus48u_la_LIBADD = $(COMMON_LIBS) libartec_eplus48u.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) $(SANEI_THREAD_LIBS) $(RESMEG_LIBS) EXTRA_DIST += artec_eplus48u.conf.in libas6e_la_SOURCES = as6e.c as6e.h libas6e_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=as6e nodist_libsane_as6e_la_SOURCES = as6e-s.c libsane_as6e_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=as6e libsane_as6e_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_as6e_la_LIBADD = $(COMMON_LIBS) libas6e.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo libavision_la_SOURCES = avision.c avision.h libavision_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=avision nodist_libsane_avision_la_SOURCES = avision-s.c libsane_avision_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=avision libsane_avision_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_avision_la_LIBADD = $(COMMON_LIBS) libavision.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_thread.lo ../sanei/sanei_scsi.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += avision.conf.in libbh_la_SOURCES = bh.c bh.h libbh_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=bh nodist_libsane_bh_la_SOURCES = bh-s.c libsane_bh_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=bh libsane_bh_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_bh_la_LIBADD = $(COMMON_LIBS) libbh.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += bh.conf.in libcanon_la_SOURCES = canon.c canon.h libcanon_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon nodist_libsane_canon_la_SOURCES = canon-s.c libsane_canon_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon libsane_canon_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_canon_la_LIBADD = $(COMMON_LIBS) libcanon.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) EXTRA_DIST += canon.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += canon-sane.c canon-scsi.c libcanon630u_la_SOURCES = canon630u.c libcanon630u_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon630u nodist_libsane_canon630u_la_SOURCES = canon630u-s.c libsane_canon630u_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon630u libsane_canon630u_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_canon630u_la_LIBADD = $(COMMON_LIBS) libcanon630u.la ../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) EXTRA_DIST += canon630u.conf.in # TODO: Why are this distributed but not compiled? EXTRA_DIST += canon630u-common.c lm9830.h libcanon_dr_la_SOURCES = canon_dr.c canon_dr.h canon_dr-cmd.h 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 ../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 libcanon_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon_pp nodist_libsane_canon_pp_la_SOURCES = canon_pp-s.c libsane_canon_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=canon_pp libsane_canon_pp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_canon_pp_la_LIBADD = $(COMMON_LIBS) libcanon_pp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(IEEE1284_LIBS) EXTRA_DIST += canon_pp.conf.in libcardscan_la_SOURCES = cardscan.c cardscan.h libcardscan_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=cardscan nodist_libsane_cardscan_la_SOURCES = cardscan-s.c libsane_cardscan_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=cardscan libsane_cardscan_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_cardscan_la_LIBADD = $(COMMON_LIBS) libcardscan.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += cardscan.conf.in libcoolscan_la_SOURCES = coolscan.c coolscan.h coolscan-scsidef.h libcoolscan_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=coolscan nodist_libsane_coolscan_la_SOURCES = coolscan-s.c libsane_coolscan_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=coolscan libsane_coolscan_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_coolscan_la_LIBADD = $(COMMON_LIBS) libcoolscan.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_thread.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += coolscan.conf.in libcoolscan2_la_SOURCES = coolscan2.c libcoolscan2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=coolscan2 nodist_libsane_coolscan2_la_SOURCES = coolscan2-s.c libsane_coolscan2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=coolscan2 libsane_coolscan2_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_coolscan2_la_LIBADD = $(COMMON_LIBS) libcoolscan2.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 $(SCSI_LIBS) $(MATH_LIB) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += coolscan2.conf.in libcoolscan3_la_SOURCES = coolscan3.c libcoolscan3_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=coolscan3 nodist_libsane_coolscan3_la_SOURCES = coolscan3-s.c libsane_coolscan3_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=coolscan3 libsane_coolscan3_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_coolscan3_la_LIBADD = $(COMMON_LIBS) libcoolscan3.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 $(SCSI_LIBS) $(MATH_LIB) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += coolscan3.conf.in libdc25_la_SOURCES = dc25.c dc25.h libdc25_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc25 nodist_libsane_dc25_la_SOURCES = dc25-s.c libsane_dc25_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dc25 libsane_dc25_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_dc25_la_LIBADD = $(COMMON_LIBS) libdc25.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(MATH_LIB) EXTRA_DIST += dc25.conf.in libdc210_la_SOURCES = dc210.c dc210.h 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) EXTRA_DIST += dc210.conf.in 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) EXTRA_DIST += dc240.conf.in 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 libsane_dell1600n_net_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dell1600n_net libsane_dell1600n_net_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_dell1600n_net_la_LIBADD = $(COMMON_LIBS) libdell1600n_net.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(TIFF_LIBS) $(JPEG_LIBS) $(SOCKET_LIBS) EXTRA_DIST += dell1600n_net.conf.in libdmc_la_SOURCES = dmc.c dmc.h libdmc_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dmc nodist_libsane_dmc_la_SOURCES = dmc-s.c libsane_dmc_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dmc libsane_dmc_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_dmc_la_LIBADD = $(COMMON_LIBS) libdmc.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += dmc.conf.in if have_libavahi if have_libcurl if have_libxml2 libescl_la_SOURCES = escl/escl.c escl/escl_capabilities.c escl/escl_devices.c escl/escl.h escl/escl_newjob.c escl/escl_reset.c escl/escl_scan.c escl/escl_status.c escl/escl_jpeg.c escl/escl_png.c escl/escl_tiff.c libescl_la_CPPFLAGS = $(AM_CPPFLAGS) $(JPEG_CFLAGS) $(PNG_CFLAGS) $(TIFF_CFLAGS) $(XML_CFLAGS) $(libcurl_CFLAGS) $(AVAHI_CFLAGS) -DBACKEND_NAME=escl nodist_libsane_escl_la_SOURCES = escl-s.c libsane_escl_la_CPPFLAGS = $(AM_CPPFLAGS) $(JPEG_CFLAGS) $(PNG_CFLAGS) $(TIFF_CFLAGS) $(XML_CFLAGS) $(libcurl_CFLAGS) $(AVAHI_CFLAGS) -DBACKEND_NAME=escl libsane_escl_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_escl_la_LIBADD = $(COMMON_LIBS) libescl.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(JPEG_LIBS) $(PNG_LIBS) $(TIFF_LIBS) $(XML_LIBS) $(libcurl_LIBS) $(AVAHI_LIBS) endif endif endif EXTRA_DIST += escl.conf.in libepjitsu_la_SOURCES = epjitsu.c epjitsu.h epjitsu-cmd.h libepjitsu_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epjitsu nodist_libsane_epjitsu_la_SOURCES = epjitsu-s.c libsane_epjitsu_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epjitsu libsane_epjitsu_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_epjitsu_la_LIBADD = $(COMMON_LIBS) libepjitsu.la ../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) EXTRA_DIST += epjitsu.conf.in libepson_la_SOURCES = epson.c epson.h epson_scsi.c epson_scsi.h epson_usb.c epson_usb.h libepson_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epson nodist_libsane_epson_la_SOURCES = epson-s.c libsane_epson_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epson libsane_epson_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_epson_la_LIBADD = $(COMMON_LIBS) libepson.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 $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += epson.conf.in libepson2_la_SOURCES = epson2.c epson2.h epson2_scsi.c epson2_scsi.h epson2_usb.c epson2_net.c epson2_net.h epson2-io.c epson2-io.h epson2-commands.c epson2-commands.h epson2-ops.c epson2-ops.h epson2-cct.c libepson2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epson2 nodist_libsane_epson2_la_SOURCES = epson2-s.c 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) 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-net.c epsonds-net.h libepsonds_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epsonds nodist_libsane_epsonds_la_SOURCES = epsonds-s.c libsane_epsonds_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=epsonds 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_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 libfujitsu_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=fujitsu nodist_libsane_fujitsu_la_SOURCES = fujitsu-s.c libsane_fujitsu_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=fujitsu libsane_fujitsu_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_fujitsu_la_LIBADD = $(COMMON_LIBS) libfujitsu.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 += fujitsu.conf.in libgenesys_la_SOURCES = genesys/genesys.cpp genesys/genesys.h \ genesys/buffer.h genesys/buffer.cpp \ genesys/calibration.h \ genesys/command_set.h \ genesys/conv.h genesys/conv.cpp \ genesys/device.h genesys/device.cpp \ genesys/enums.h genesys/enums.cpp \ genesys/error.h genesys/error.cpp \ genesys/fwd.h \ genesys/gl646.cpp genesys/gl646.h genesys/gl646_registers.h \ genesys/gl124.cpp genesys/gl124.h genesys/gl124_registers.h \ genesys/gl841.cpp genesys/gl841.h genesys/gl841_registers.h \ genesys/gl843.cpp genesys/gl843.h genesys/gl843_registers.h \ genesys/gl846.cpp genesys/gl846.h genesys/gl846_registers.h \ genesys/gl847.cpp genesys/gl847.h genesys/gl847_registers.h \ genesys/row_buffer.h \ genesys/image_buffer.h genesys/image_buffer.cpp \ genesys/image_pipeline.h genesys/image_pipeline.cpp \ genesys/image_pixel.h genesys/image_pixel.cpp \ genesys/image.h genesys/image.cpp \ genesys/motor.h genesys/motor.cpp \ genesys/register.h \ genesys/register_cache.h \ genesys/scanner_interface.h genesys/scanner_interface.cpp \ genesys/scanner_interface_usb.h genesys/scanner_interface_usb.cpp \ genesys/sensor.h genesys/sensor.cpp \ genesys/settings.h genesys/settings.cpp \ genesys/serialize.h \ genesys/static_init.h genesys/static_init.cpp \ genesys/status.h genesys/status.cpp \ genesys/tables_frontend.cpp \ genesys/tables_gpo.cpp \ genesys/tables_model.cpp \ genesys/tables_motor.cpp \ genesys/tables_motor_profile.cpp \ genesys/tables_sensor.cpp \ genesys/test_scanner_interface.h genesys/test_scanner_interface.cpp \ genesys/test_settings.h genesys/test_settings.cpp \ genesys/test_usb_device.h genesys/test_usb_device.cpp \ genesys/usb_device.h genesys/usb_device.cpp \ genesys/low.cpp genesys/low.h \ genesys/utilities.h libgenesys_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=genesys nodist_libsane_genesys_la_SOURCES = genesys-s.cpp 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) EXTRA_DIST += genesys.conf.in libgphoto2_i_la_SOURCES = gphoto2.c gphoto2.h 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) EXTRA_DIST += gphoto2.conf.in libgt68xx_la_SOURCES = gt68xx.c gt68xx.h libgt68xx_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=gt68xx nodist_libsane_gt68xx_la_SOURCES = gt68xx-s.c libsane_gt68xx_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=gt68xx libsane_gt68xx_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_gt68xx_la_LIBADD = $(COMMON_LIBS) libgt68xx.la ../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) EXTRA_DIST += gt68xx.conf.in # TODO: Why are this distributed but not compiled? EXTRA_DIST += gt68xx_devices.c gt68xx_generic.c gt68xx_generic.h gt68xx_gt6801.c gt68xx_gt6801.h gt68xx_gt6816.c gt68xx_gt6816.h gt68xx_high.c gt68xx_high.h gt68xx_low.c gt68xx_low.h gt68xx_mid.c gt68xx_mid.h gt68xx_shm_channel.c gt68xx_shm_channel.h libhp_la_SOURCES = hp.c hp.h hp-accessor.c hp-accessor.h hp-device.c hp-device.h hp-handle.c hp-handle.h hp-hpmem.c hp-option.c hp-option.h hp-scl.c hp-scl.h hp-scsi.h libhp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp nodist_libsane_hp_la_SOURCES = hp-s.c libsane_hp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp libsane_hp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_hp_la_LIBADD = $(COMMON_LIBS) libhp.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_thread.lo $(SCSI_LIBS) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += hp.conf.in # TODO: These should be moved to ../docs/hp; don't belong here. EXTRA_DIST += hp.README hp.TODO libhp3500_la_SOURCES = hp3500.c 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 $(MATH_LIB) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) libhp3900_la_SOURCES = hp3900.c libhp3900_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp3900 nodist_libsane_hp3900_la_SOURCES = hp3900-s.c libsane_hp3900_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp3900 libsane_hp3900_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_hp3900_la_LIBADD = $(COMMON_LIBS) libhp3900.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(MATH_LIB) $(TIFF_LIBS) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += hp3900.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += hp3900_config.c hp3900_debug.c hp3900_rts8822.c hp3900_sane.c hp3900_types.c hp3900_usb.c libhp4200_la_SOURCES = hp4200.c hp4200.h libhp4200_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp4200 nodist_libsane_hp4200_la_SOURCES = hp4200-s.c libsane_hp4200_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp4200 libsane_hp4200_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_hp4200_la_LIBADD = $(COMMON_LIBS) libhp4200.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_pv8630.lo $(MATH_LIB) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += hp4200.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += hp4200_lm9830.c hp4200_lm9830.h libhp5400_la_SOURCES = hp5400.c hp5400.h libhp5400_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp5400 nodist_libsane_hp5400_la_SOURCES = hp5400-s.c libsane_hp5400_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp5400 libsane_hp5400_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_hp5400_la_LIBADD = $(COMMON_LIBS) libhp5400.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += hp5400.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += hp5400_debug.c hp5400_debug.h hp5400_internal.c hp5400_internal.h hp5400_sane.c hp5400_sanei.c hp5400_sanei.h hp5400_xfer.h libhp5590_la_SOURCES = hp5590.c libhp5590_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp5590 nodist_libsane_hp5590_la_SOURCES = hp5590-s.c libsane_hp5590_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hp5590 libsane_hp5590_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_hp5590_la_LIBADD = $(COMMON_LIBS) libhp5590.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(USB_LIBS) $(RESMGR_LIBS) # TODO: Why are these distributed but not compiled? EXTRA_DIST += hp5590_cmds.c hp5590_cmds.h hp5590_low.c hp5590_low.h libhpljm1005_la_SOURCES = hpljm1005.c libhpljm1005_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hpljm1005 nodist_libsane_hpljm1005_la_SOURCES = hpljm1005-s.c libsane_hpljm1005_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hpljm1005 libsane_hpljm1005_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_hpljm1005_la_LIBADD = $(COMMON_LIBS) libhpljm1005.la ../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) libhpsj5s_la_SOURCES = hpsj5s.c hpsj5s.h libhpsj5s_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hpsj5s nodist_libsane_hpsj5s_la_SOURCES = hpsj5s-s.c libsane_hpsj5s_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hpsj5s libsane_hpsj5s_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_hpsj5s_la_LIBADD = $(COMMON_LIBS) libhpsj5s.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(IEEE1284_LIBS) EXTRA_DIST += hpsj5s.conf.in libhs2p_la_SOURCES = hs2p.c hs2p.h hs2p-saneopts.h libhs2p_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hs2p nodist_libsane_hs2p_la_SOURCES = hs2p-s.c libsane_hs2p_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=hs2p libsane_hs2p_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_hs2p_la_LIBADD = $(COMMON_LIBS) libhs2p.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += hs2p.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += hs2p-scsi.c hs2p-scsi.h libibm_la_SOURCES = ibm.c ibm.h libibm_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=ibm nodist_libsane_ibm_la_SOURCES = ibm-s.c libsane_ibm_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=ibm libsane_ibm_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_ibm_la_LIBADD = $(COMMON_LIBS) libibm.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += ibm.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += ibm-scsi.c libkodak_la_SOURCES = kodak.c kodak.h kodak-cmd.h libkodak_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kodak nodist_libsane_kodak_la_SOURCES = kodak-s.c libsane_kodak_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kodak libsane_kodak_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_kodak_la_LIBADD = $(COMMON_LIBS) libkodak.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) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += kodak.conf.in libkodakaio_la_SOURCES = kodakaio.c kodakaio.h libkodakaio_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kodakaio nodist_libsane_kodakaio_la_SOURCES = kodakaio-s.c libsane_kodakaio_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kodakaio libsane_kodakaio_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_kodakaio_la_LIBADD = $(COMMON_LIBS) libkodakaio.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 $(USB_LIBS) $(SOCKET_LIBS) $(AVAHI_LIBS) $(MATH_LIB) $(RESMGR_LIBS) EXTRA_DIST += kodakaio.conf.in libkvs1025_la_SOURCES = kvs1025.c kvs1025_low.c kvs1025_opt.c kvs1025_usb.c \ kvs1025.h kvs1025_low.h kvs1025_usb.h kvs1025_cmds.h libkvs1025_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kvs1025 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 libkvs20xx_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kvs20xx nodist_libsane_kvs20xx_la_SOURCES = kvs20xx-s.c libsane_kvs20xx_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kvs20xx libsane_kvs20xx_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_kvs20xx_la_LIBADD = $(COMMON_LIBS) libkvs20xx.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) libkvs40xx_la_SOURCES = kvs40xx.c kvs40xx_cmd.c kvs40xx_opt.c \ kvs40xx.h libkvs40xx_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kvs40xx nodist_libsane_kvs40xx_la_SOURCES = kvs40xx-s.c libsane_kvs40xx_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=kvs40xx libsane_kvs40xx_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_kvs40xx_la_LIBADD = $(COMMON_LIBS) libkvs40xx.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_scsi.lo $(SCSI_LIBS) $(USB_LIBS) $(PTHREAD_LIBS) $(RESMGR_LIBS) libleo_la_SOURCES = leo.c leo.h libleo_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=leo nodist_libsane_leo_la_SOURCES = leo-s.c libsane_leo_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=leo libsane_leo_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_leo_la_LIBADD = $(COMMON_LIBS) libleo.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += leo.conf.in liblexmark_la_SOURCES = lexmark.c lexmark.h lexmark_low.c liblexmark_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=lexmark nodist_libsane_lexmark_la_SOURCES = lexmark-s.c libsane_lexmark_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=lexmark libsane_lexmark_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_lexmark_la_LIBADD = $(COMMON_LIBS) liblexmark.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += lexmark.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += lexmark_models.c lexmark_sensors.c libma1509_la_SOURCES = ma1509.c ma1509.h libma1509_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=ma1509 nodist_libsane_ma1509_la_SOURCES = ma1509-s.c libsane_ma1509_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=ma1509 libsane_ma1509_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_ma1509_la_LIBADD = $(COMMON_LIBS) libma1509.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += ma1509.conf.in libmagicolor_la_SOURCES = magicolor.c magicolor.h libmagicolor_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=magicolor $(SNMP_CFLAGS) nodist_libsane_magicolor_la_SOURCES = magicolor-s.c libsane_magicolor_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=magicolor libsane_magicolor_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_magicolor_la_LIBADD = $(COMMON_LIBS) libmagicolor.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 $(USB_LIBS) $(SOCKET_LIBS) $(MATH_LIB) $(RESMGR_LIBS) $(SNMP_LIBS) EXTRA_DIST += magicolor.conf.in libmatsushita_la_SOURCES = matsushita.c matsushita.h libmatsushita_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=matsushita nodist_libsane_matsushita_la_SOURCES = matsushita-s.c libsane_matsushita_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=matsushita libsane_matsushita_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_matsushita_la_LIBADD = $(COMMON_LIBS) libmatsushita.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += matsushita.conf.in libmicrotek_la_SOURCES = microtek.c microtek.h libmicrotek_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=microtek nodist_libsane_microtek_la_SOURCES = microtek-s.c libsane_microtek_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=microtek libsane_microtek_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_microtek_la_LIBADD = $(COMMON_LIBS) libmicrotek.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) EXTRA_DIST += microtek.conf.in libmicrotek2_la_SOURCES = microtek2.c microtek2.h libmicrotek2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=microtek2 nodist_libsane_microtek2_la_SOURCES = microtek2-s.c libsane_microtek2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=microtek2 libsane_microtek2_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_microtek2_la_LIBADD = $(COMMON_LIBS) libmicrotek2.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 ../sanei/sanei_thread.lo $(MATH_LIB) $(SCSI_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += microtek2.conf.in libmustek_la_SOURCES = mustek.c mustek.h libmustek_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=mustek nodist_libsane_mustek_la_SOURCES = mustek-s.c libsane_mustek_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=mustek libsane_mustek_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_mustek_la_LIBADD = $(COMMON_LIBS) libmustek.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 ../sanei/sanei_thread.lo ../sanei/sanei_ab306.lo ../sanei/sanei_pa4s2.lo $(IEEE1284_LIBS) $(SCSI_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += mustek.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += mustek_scsi_pp.c mustek_scsi_pp.h libmustek_pp_la_SOURCES = mustek_pp.c mustek_pp.h mustek_pp_decl.h mustek_pp_drivers.h libmustek_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=mustek_pp nodist_libsane_mustek_pp_la_SOURCES = mustek_pp-s.c libsane_mustek_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=mustek_pp libsane_mustek_pp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_mustek_pp_la_LIBADD = $(COMMON_LIBS) libmustek_pp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_pa4s2.lo $(MATH_LIB) $(IEEE1284_LIBS) EXTRA_DIST += mustek_pp.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += mustek_pp_ccd300.c mustek_pp_ccd300.h mustek_pp_cis.c mustek_pp_cis.h mustek_pp_null.c libmustek_usb_la_SOURCES = mustek_usb.c mustek_usb.h libmustek_usb_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=mustek_usb nodist_libsane_mustek_usb_la_SOURCES = mustek_usb-s.c libsane_mustek_usb_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=mustek_usb libsane_mustek_usb_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_mustek_usb_la_LIBADD = $(COMMON_LIBS) libmustek_usb.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += mustek_usb.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += mustek_usb_high.c mustek_usb_high.h mustek_usb_low.c mustek_usb_low.h mustek_usb_mid.c mustek_usb_mid.h libmustek_usb2_la_SOURCES = mustek_usb2.c mustek_usb2.h libmustek_usb2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=mustek_usb2 nodist_libsane_mustek_usb2_la_SOURCES = mustek_usb2-s.c libsane_mustek_usb2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=mustek_usb2 libsane_mustek_usb2_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_mustek_usb2_la_LIBADD = $(COMMON_LIBS) libmustek_usb2.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(MATH_LIB) $(PTHREAD_LIBS) $(USB_LIBS) $(RESMGR_LIBS) # TODO: Why are these distributed but not compiled? EXTRA_DIST += mustek_usb2_asic.c mustek_usb2_asic.h mustek_usb2_high.c mustek_usb2_high.h mustek_usb2_reflective.c mustek_usb2_transparent.c libnec_la_SOURCES = nec.c nec.h libnec_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=nec nodist_libsane_nec_la_SOURCES = nec-s.c 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) EXTRA_DIST += nec.conf.in libnet_la_SOURCES = net.c net.h 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_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 libniash_la_SOURCES = niash.c libniash_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=niash nodist_libsane_niash_la_SOURCES = niash-s.c libsane_niash_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=niash libsane_niash_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_niash_la_LIBADD = $(COMMON_LIBS) libniash.la ../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) # TODO: Why are these distributed but not compiled? EXTRA_DIST += niash_core.c niash_core.h niash_xfer.c niash_xfer.h libpie_la_SOURCES = pie.c pie-scsidef.h libpie_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pie nodist_libsane_pie_la_SOURCES = pie-s.c libsane_pie_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pie libsane_pie_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_pie_la_LIBADD = $(COMMON_LIBS) libpie.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 ../sanei/sanei_thread.lo $(SCSI_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += pie.conf.in libpieusb_la_SOURCES = pieusb.h pieusb_buffer.c pieusb_buffer.h pieusb_scancmd.c pieusb_scancmd.h pieusb_specific.c pieusb_specific.h pieusb_usb.c pieusb_usb.h pieusb.c libpieusb_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pieusb nodist_libsane_pieusb_la_SOURCES = pieusb-s.c libsane_pieusb_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pieusb libsane_pieusb_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_pieusb_la_LIBADD = $(COMMON_LIBS) libpieusb.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 ../sanei/sanei_thread.lo ../sanei/sanei_usb.lo ../sanei/sanei_ir.lo ../sanei/sanei_magic.lo $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) $(USB_LIBS) $(MATH_LIB) EXTRA_DIST += pieusb.conf.in libp5_la_SOURCES = p5.c p5.h p5_device.h libp5_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=p5 nodist_libsane_p5_la_SOURCES = p5-s.c libsane_p5_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=p5 libsane_p5_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_p5_la_LIBADD = $(COMMON_LIBS) libp5.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo EXTRA_DIST += p5.conf.in p5_device.c libpint_la_SOURCES = pint.c pint.h libpint_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pint nodist_libsane_pint_la_SOURCES = pint-s.c libsane_pint_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pint libsane_pint_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_pint_la_LIBADD = $(COMMON_LIBS) libpint.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo libpixma_la_SOURCES = pixma/pixma.c \ pixma/pixma.h \ pixma/pixma_io_sanei.c \ pixma/pixma_io.h \ pixma/pixma_common.c \ pixma/pixma_common.h \ pixma/pixma_mp150.c \ pixma/pixma_mp730.c \ pixma/pixma_mp750.c \ pixma/pixma_mp800.c \ pixma/pixma_imageclass.c \ pixma/pixma_bjnp.c \ pixma/pixma_bjnp.h \ pixma/pixma_bjnp_private.h \ pixma/pixma_rename.h libpixma_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pixma nodist_libsane_pixma_la_SOURCES = pixma-s.c libsane_pixma_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pixma libsane_pixma_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_pixma_la_LIBADD = $(COMMON_LIBS) libpixma.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 $(SANEI_SANEI_JPEG_LO) $(JPEG_LIBS) $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += pixma.conf.in # included in pixma.c EXTRA_DIST += pixma/pixma_sane_options.c pixma/pixma_sane_options.h libplustek_la_SOURCES = plustek.c plustek.h libplustek_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=plustek nodist_libsane_plustek_la_SOURCES = plustek-s.c libsane_plustek_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=plustek libsane_plustek_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_plustek_la_LIBADD = $(COMMON_LIBS) libplustek.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 ../sanei/sanei_lm983x.lo ../sanei/sanei_access.lo $(MATH_LIB) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += plustek.conf.in EXTRA_DIST += plustek-usb.c plustek-usb.h plustek-usbcal.c plustek-usbcalfile.c plustek-usbdevs.c plustek-usbhw.c plustek-usbimg.c plustek-usbio.c plustek-usbmap.c plustek-usbscan.c plustek-usbshading.c libplustek_pp_la_SOURCES = plustek_pp.c plustek-pp.h libplustek_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=plustek_pp nodist_libsane_plustek_pp_la_SOURCES = plustek_pp-s.c libsane_plustek_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=plustek_pp libsane_plustek_pp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_plustek_pp_la_LIBADD = $(COMMON_LIBS) libplustek_pp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_pp.lo ../sanei/sanei_thread.lo $(MATH_LIB) $(IEEE1284_LIBS) $(SANEI_THREAD_LIBS) EXTRA_DIST += plustek_pp.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += plustek-pp_dac.c plustek-pp_dbg.h plustek-pp_detect.c plustek-pp_genericio.c plustek-pp_hwdefs.h plustek-pp_image.c plustek-pp_io.c plustek-pp_map.c plustek-pp_misc.c plustek-pp_models.c plustek-pp_motor.c plustek-pp_p12.c plustek-pp_p12ccd.c plustek-pp_p48xx.c plustek-pp_p9636.c plustek-pp_procfs.c plustek-pp_procs.h plustek-pp_ptdrv.c plustek-pp_scale.c plustek-pp_scan.h plustek-pp_scandata.h plustek-pp_sysdep.h plustek-pp_tpa.c plustek-pp_types.h plustek-pp_wrapper.c libpnm_la_SOURCES = pnm.c libpnm_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pnm nodist_libsane_pnm_la_SOURCES = pnm-s.c libsane_pnm_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=pnm libsane_pnm_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_pnm_la_LIBADD = $(COMMON_LIBS) libpnm.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo libqcam_la_SOURCES = qcam.c qcam.h libqcam_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=qcam nodist_libsane_qcam_la_SOURCES = qcam-s.c libsane_qcam_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=qcam libsane_qcam_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_qcam_la_LIBADD = $(COMMON_LIBS) libqcam.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_pio.lo EXTRA_DIST += qcam.conf.in libricoh_la_SOURCES = ricoh.c ricoh.h libricoh_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=ricoh nodist_libsane_ricoh_la_SOURCES = ricoh-s.c libsane_ricoh_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=ricoh libsane_ricoh_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_ricoh_la_LIBADD = $(COMMON_LIBS) libricoh.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += ricoh.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += ricoh-scsi.c libricoh2_la_SOURCES = ricoh2.c libricoh2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=ricoh2 nodist_libsane_ricoh2_la_SOURCES = ricoh2-s.c libsane_ricoh2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=ricoh2 libsane_ricoh2_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_ricoh2_la_LIBADD = $(COMMON_LIBS) libricoh2.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_usb.lo ../sanei/sanei_config.lo sane_strstatus.lo $(USB_LIBS) EXTRA_DIST += ricoh2_buffer.c librts8891_la_SOURCES = rts8891.c rts8891.h rts88xx_lib.c rts88xx_lib.h librts8891_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=rts8891 nodist_libsane_rts8891_la_SOURCES = rts8891-s.c libsane_rts8891_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=rts8891 libsane_rts8891_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_rts8891_la_LIBADD = $(COMMON_LIBS) librts8891.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_scsi.lo ../sanei/sanei_usb.lo $(SCSI_LIBS) $(USB_LIBS) $(RESMGR_LIBS) $(RESMGR_LIBS) EXTRA_DIST += rts8891.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += rts8891_devices.c rts8891_low.c rts8891_low.h libs9036_la_SOURCES = s9036.c s9036.h libs9036_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=s9036 nodist_libsane_s9036_la_SOURCES = s9036-s.c libsane_s9036_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=s9036 libsane_s9036_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_s9036_la_LIBADD = $(COMMON_LIBS) libs9036.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += s9036.conf.in libsceptre_la_SOURCES = sceptre.c sceptre.h libsceptre_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sceptre nodist_libsane_sceptre_la_SOURCES = sceptre-s.c libsane_sceptre_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sceptre libsane_sceptre_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_sceptre_la_LIBADD = $(COMMON_LIBS) libsceptre.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += sceptre.conf.in libsharp_la_SOURCES = sharp.c sharp.h libsharp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sharp nodist_libsane_sharp_la_SOURCES = sharp-s.c libsane_sharp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sharp libsane_sharp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_sharp_la_LIBADD = $(COMMON_LIBS) libsharp.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) EXTRA_DIST += sharp.conf.in libsm3600_la_SOURCES = sm3600.c sm3600.h libsm3600_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sm3600 nodist_libsane_sm3600_la_SOURCES = sm3600-s.c libsane_sm3600_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sm3600 libsane_sm3600_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_sm3600_la_LIBADD = $(COMMON_LIBS) libsm3600.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(USB_LIBS) $(RESMGR_LIBS) # TODO: Why are these distributed but not compiled? EXTRA_DIST += sm3600-color.c sm3600-gray.c sm3600-homerun.c sm3600-scanmtek.c sm3600-scantool.h sm3600-scanusb.c sm3600-scanutil.c libsm3840_la_SOURCES = sm3840.c sm3840.h sm3840_params.h libsm3840_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sm3840 nodist_libsane_sm3840_la_SOURCES = sm3840-s.c libsane_sm3840_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sm3840 libsane_sm3840_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_sm3840_la_LIBADD = $(COMMON_LIBS) libsm3840.la ../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) EXTRA_DIST += sm3840.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += sm3840_lib.c sm3840_lib.h sm3840_scan.c libsnapscan_la_SOURCES = snapscan.c snapscan.h libsnapscan_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=snapscan nodist_libsane_snapscan_la_SOURCES = snapscan-s.c libsane_snapscan_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=snapscan libsane_snapscan_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_snapscan_la_LIBADD = $(COMMON_LIBS) libsnapscan.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_thread.lo ../sanei/sanei_scsi.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += snapscan.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += snapscan-data.c snapscan-mutex.c snapscan-options.c snapscan-scsi.c snapscan-sources.c snapscan-sources.h snapscan-usb.c snapscan-usb.h libsp15c_la_SOURCES = sp15c.c sp15c.h sp15c-scsi.h libsp15c_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sp15c nodist_libsane_sp15c_la_SOURCES = sp15c-s.c libsane_sp15c_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=sp15c libsane_sp15c_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_sp15c_la_LIBADD = $(COMMON_LIBS) libsp15c.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_thread.lo ../sanei/sanei_scsi.lo $(SCSI_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += sp15c.conf.in libst400_la_SOURCES = st400.c st400.h libst400_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=st400 nodist_libsane_st400_la_SOURCES = st400-s.c ../sanei/sanei_scsi.lo libsane_st400_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=st400 libsane_st400_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_st400_la_LIBADD = $(COMMON_LIBS) libst400.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += st400.conf.in libstv680_la_SOURCES = stv680.c stv680.h libstv680_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=stv680 nodist_libsane_stv680_la_SOURCES = stv680-s.c libsane_stv680_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=stv680 libsane_stv680_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_stv680_la_LIBADD = $(COMMON_LIBS) libstv680.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += stv680.conf.in libtamarack_la_SOURCES = tamarack.c tamarack.h libtamarack_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=tamarack nodist_libsane_tamarack_la_SOURCES = tamarack-s.c libsane_tamarack_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=tamarack libsane_tamarack_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_tamarack_la_LIBADD = $(COMMON_LIBS) libtamarack.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo ../sanei/sanei_config2.lo sane_strstatus.lo ../sanei/sanei_thread.lo ../sanei/sanei_scsi.lo $(SCSI_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += tamarack.conf.in libtest_la_SOURCES = test.c test.h libtest_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=test nodist_libsane_test_la_SOURCES = test-s.c libsane_test_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=test libsane_test_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_test_la_LIBADD = $(COMMON_LIBS) libtest.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_thread.lo $(SANEI_THREAD_LIBS) EXTRA_DIST += test.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += test-picture.c libteco1_la_SOURCES = teco1.c teco1.h libteco1_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=teco1 nodist_libsane_teco1_la_SOURCES = teco1-s.c libsane_teco1_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=teco1 libsane_teco1_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_teco1_la_LIBADD = $(COMMON_LIBS) libteco1.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += teco1.conf.in libteco2_la_SOURCES = teco2.c teco2.h libteco2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=teco2 nodist_libsane_teco2_la_SOURCES = teco2-s.c libsane_teco2_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=teco2 libsane_teco2_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_teco2_la_LIBADD = $(COMMON_LIBS) libteco2.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += teco2.conf.in libteco3_la_SOURCES = teco3.c teco3.h libteco3_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=teco3 nodist_libsane_teco3_la_SOURCES = teco3-s.c libsane_teco3_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=teco3 libsane_teco3_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_teco3_la_LIBADD = $(COMMON_LIBS) libteco3.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 $(SCSI_LIBS) $(RESMGR_LIBS) EXTRA_DIST += teco3.conf.in libu12_la_SOURCES = u12.c u12.h libu12_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=u12 nodist_libsane_u12_la_SOURCES = u12-s.c libsane_u12_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=u12 libsane_u12_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_u12_la_LIBADD = $(COMMON_LIBS) libu12.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) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += u12.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += u12-ccd.c u12-hw.c u12-hwdef.h u12-if.c u12-image.c u12-io.c u12-map.c u12-motor.c u12-scanner.h u12-shading.c u12-tpa.c libumax_la_SOURCES = umax.c umax.h libumax_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=umax nodist_libsane_umax_la_SOURCES = umax-s.c libsane_umax_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=umax libsane_umax_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_umax_la_LIBADD = $(COMMON_LIBS) libumax.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_thread.lo ../sanei/sanei_scsi.lo ../sanei/sanei_pv8630.lo $(MATH_LIB) $(SCSI_LIBS) $(USB_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) EXTRA_DIST += umax.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += umax-scanner.c umax-scanner.h umax-scsidef.h umax-uc1200s.c umax-uc1200se.c umax-uc1260.c umax-uc630.c umax-uc840.c umax-ug630.c umax-ug80.c umax-usb.c libumax1220u_la_SOURCES = umax1220u.c libumax1220u_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=umax1220u nodist_libsane_umax1220u_la_SOURCES = umax1220u-s.c libsane_umax1220u_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=umax1220u libsane_umax1220u_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_umax1220u_la_LIBADD = $(COMMON_LIBS) libumax1220u.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_pv8630.lo $(MATH_LIB) $(USB_LIBS) $(RESMGR_LIBS) EXTRA_DIST += umax1220u.conf.in # TODO: Why are these distributed but not compiled? EXTRA_DIST += umax1220u-common.c libumax_pp_la_SOURCES = umax_pp.c umax_pp.h umax_pp_low.c umax_pp_low.h umax_pp_mid.c umax_pp_mid.h libumax_pp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=umax_pp nodist_libsane_umax_pp_la_SOURCES = umax_pp-s.c 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) 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 nodist_libsane_v4l_la_SOURCES = v4l-s.c libsane_v4l_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=v4l libsane_v4l_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_v4l_la_LIBADD = $(COMMON_LIBS) libv4l.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(LIBV4L_LIBS) EXTRA_DIST += v4l.conf.in libxerox_mfp_la_SOURCES = xerox_mfp.c xerox_mfp-usb.c xerox_mfp-tcp.c xerox_mfp.h 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_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 libdll_preload_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dll -DENABLE_PRELOAD libdll_preload_la_LIBADD = ../sanei/sanei_usb.lo $(USB_LIBS) $(XML_LIBS) libdll_la_SOURCES = dll.c libdll_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dll libdll_la_LIBADD = ../sanei/sanei_usb.lo $(USB_LIBS) $(XML_LIBS) BUILT_SOURCES = dll-preload.h CLEANFILES += dll-preload.h nodist_libsane_dll_la_SOURCES = dll-s.c libsane_dll_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dll libsane_dll_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS) libsane_dll_la_LIBADD = $(COMMON_LIBS) libdll.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo $(DL_LIBS) EXTRA_DIST += dll.conf.in # TODO: Why is this distributed but not installed? EXTRA_DIST += dll.aliases # libsane.la and libsane-dll.la are the same thing except for # the addition of backends listed by PRELOADABLE_BACKENDS that are # statically linked in. # Also, libsane.la goes into $(libdir) where as all libsane-* # (including libsane-dll.la) go into $(libdir)/sane # FIXME: Since we are throwing in the kitchen sink, might as # well link in ../sanei/libsanei.la instead. But currently, # libsanei.la is linking in sanei_auth which requires md5. # Shipping md5 could cause symbol conflicts with commonly used # md5 external libraries. Either need to prefix md5 with sanei_ # (see liblib.la and snprintf), or move sanei_auth outside # of libsanei. # # FIXME: This is using every possibly needed library and dependency # when the user is using any PRELOADABLE_BACKENDS, irrespective of # what backends are preloaded. It should include what is needed by # those backends that are actually preloaded. if preloadable_backends_enabled PRELOADABLE_BACKENDS_LIBS = ../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 $(LIBV4L_LIBS) $(MATH_LIB) $(IEEE1284_LIBS) $(TIFF_LIBS) $(JPEG_LIBS) $(GPHOTO2_LIBS) $(SOCKET_LIBS) $(USB_LIBS) $(AVAHI_LIBS) $(SCSI_LIBS) $(SANEI_THREAD_LIBS) $(RESMGR_LIBS) $(XML_LIBS) PRELOADABLE_BACKENDS_DEPS = ../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) endif 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 $(PRELOADABLE_BACKENDS_LIBS) $(DL_LIBS) $(XML_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 $(PRELOADABLE_BACKENDS_DEPS) sane-backends-1.0.29/backend/mustek_usb.h0000666000000000000000000000463513615534521015132 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000 Mustek. Originally maintained by Tom Wang Copyright (C) 2001, 2002 by Henning Meier-Geinitz. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Mustek 1200UB and similar USB flatbed scanners. */ #ifndef mustek_usb_h #define mustek_usb_h #include #include "mustek_usb_high.h" #define ENABLE(OPTION) s->opt[OPTION].cap &= ~SANE_CAP_INACTIVE #define DISABLE(OPTION) s->opt[OPTION].cap |= SANE_CAP_INACTIVE #define IS_ACTIVE(OPTION) (((s->opt[OPTION].cap) & SANE_CAP_INACTIVE) == 0) #define MUSTEK_USB_CONFIG_FILE "mustek_usb.conf" #define SCAN_BUFFER_SIZE (64 * 1024) #endif /* mustek_usb_h */ sane-backends-1.0.29/backend/canon-sane.c0000666000000000000000000017124313615534521014766 00000000000000SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { char devnam[PATH_MAX] = "/dev/scanner"; FILE *fp; int i, j; SANE_Byte primary, secondary, inmask, priMask, secMask; DBG_INIT (); DBG (1, ">> sane_init\n"); /****** for lineart mode of FB1200S ******/ for (i = 0; i < 256; i++) { primary = secondary = 0; inmask = 0x80; priMask = 0x40; secMask = 0x80; for (j = 0; j < 4; j++) { if (i & inmask) { primary |= priMask; secondary |= secMask; } priMask = priMask >> 2; secMask = secMask >> 2; inmask = inmask >> 1; } primaryHigh[i] = primary; secondaryHigh[i] = secondary; primary = secondary = 0; priMask = 0x40; secMask = 0x80; for (j = 0; j < 4; j++) { if (i & inmask) { primary |= priMask; secondary |= secMask; } priMask = priMask >> 2; secMask = secMask >> 2; inmask = inmask >> 1; } primaryLow[i] = primary; secondaryLow[i] = secondary; } /******************************************/ #if defined PACKAGE && defined VERSION DBG (2, "sane_init: " PACKAGE " " VERSION "\n"); #endif if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (CANON_CONFIG_FILE); if (fp) { char line[PATH_MAX]; size_t len; /* read config file */ /* while (fgets (line, sizeof (line), fp)) */ while (sanei_config_read (line, sizeof (line), fp)) { if (line[0] == '#') /* ignore line comments */ continue; len = strlen (line); /*if (line[len - 1] == '\n') line[--len] = '\0'; */ if (!len) continue; /* ignore empty lines */ strcpy (devnam, line); } fclose (fp); } sanei_config_attach_matching_devices (devnam, attach_one); DBG (1, "<< sane_init\n"); return SANE_STATUS_GOOD; } /**************************************************************************/ void sane_exit (void) { CANON_Device *dev, *next; DBG (1, ">> sane_exit\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free ((void *) dev->sane.name); free ((void *) dev->sane.model); free ((void *) dev); } DBG (1, "<< sane_exit\n"); } /**************************************************************************/ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { static const SANE_Device **devlist = 0; CANON_Device *dev; int i; DBG (1, ">> sane_get_devices\n"); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return (SANE_STATUS_NO_MEM); i = 0; for (dev = first_dev; dev; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (1, "<< sane_get_devices\n"); return SANE_STATUS_GOOD; } /**************************************************************************/ SANE_Status sane_open (SANE_String_Const devnam, SANE_Handle * handle) { SANE_Status status; CANON_Device *dev; CANON_Scanner *s; int i, j, c; DBG (1, ">> sane_open\n"); if (devnam[0] == '\0') { for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devnam) == 0) break; } } else dev = first_dev; if (!dev) { status = attach (devnam, &dev); if (status != SANE_STATUS_GOOD) return (status); } if (!dev) return (SANE_STATUS_INVAL); s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->fd = -1; s->hw = dev; if (s->hw->info.model == FS2710) { for (i = 0; i < 4; i++) { s->gamma_map[i][0] = '\0'; s->gamma_table[i][0] = 0; } for (j = 1; j < 4096; ++j) { /* FS2710 needs inital gamma 2.0 */ c = (int) (256.0 * pow (((double) j) / 4096.0, 0.5)); for (i = 0; i < 4; i++) { s->gamma_map[i][j] = (u_char) c; if ((j & 0xf) == 0) s->gamma_table[i][j >> 4] = c; } } s->colour = 1; s->auxbuf_len = 0; } else { for (i = 0; i < 4; ++i) { for (j = 0; j < 256; ++j) s->gamma_table[i][j] = j; } } init_options (s); if (s->hw->info.model == FB1200) s->inbuffer = malloc (30894); /* modification for FB1200S */ else s->inbuffer = malloc (15312); /* modification for FB620S */ if (!s->inbuffer) return SANE_STATUS_NO_MEM; if (s->hw->info.model == FB1200) s->outbuffer = malloc (30894); /* modification for FB1200S */ else s->outbuffer = malloc (15312); /* modification for FB620S */ if (!s->outbuffer) { free (s->inbuffer); return SANE_STATUS_NO_MEM; } s->next = first_handle; first_handle = s; *handle = s; DBG (1, "<< sane_open\n"); return SANE_STATUS_GOOD; } /**************************************************************************/ void sane_close (SANE_Handle handle) { CANON_Scanner *s = (CANON_Scanner *) handle; SANE_Status status; DBG (1, ">> sane_close\n"); if (s->val[OPT_EJECT_BEFOREEXIT].w) { if (s->fd == -1) sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, s->hw); status = medium_position (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_close: MEDIUM POSITION failed\n"); sanei_scsi_close (s->fd); s->fd = -1; } s->AF_NOW = SANE_TRUE; DBG (1, "sane_close AF_NOW = '%d'\n", s->AF_NOW); } if (s->fd != -1) sanei_scsi_close (s->fd); if (s->inbuffer) free (s->inbuffer); /* modification for FB620S */ if (s->outbuffer) free (s->outbuffer); /* modification for FB620S */ if (s->auxbuf_len > 0) free (s->auxbuf); /* modification for FS2710S */ free (s); DBG (1, ">> sane_close\n"); } /**************************************************************************/ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { CANON_Scanner *s = handle; DBG (21, ">> sane_get_option_descriptor option number %d\n", option); if ((unsigned) option >= NUM_OPTIONS) return (0); DBG (21, " sane_get_option_descriptor option name %s\n", option_name[option]); DBG (21, "<< sane_get_option_descriptor option number %d\n", option); return (s->opt + option); } /**************************************************************************/ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { CANON_Scanner *s = handle; SANE_Status status; SANE_Word w, cap; SANE_Byte gbuf[4096]; size_t buf_size; int i, neg, gamma_component, int_t, transfer_data_type; time_t dtime, rt; DBG (21, ">> sane_control_option %s\n", option_name[option]); if (info) *info = 0; if (s->scanning == SANE_TRUE) { DBG (21, ">> sane_control_option: device is busy scanning\n"); return (SANE_STATUS_DEVICE_BUSY); } if (option >= NUM_OPTIONS) return (SANE_STATUS_INVAL); cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) return (SANE_STATUS_INVAL); if (action == SANE_ACTION_GET_VALUE) { DBG (21, "sane_control_option get value of %s\n", option_name[option]); switch (option) { /* word options: */ case OPT_FLATBED_ONLY: case OPT_TPU_ON: case OPT_TPU_PN: case OPT_TPU_TRANSPARENCY: case OPT_RESOLUTION_BIND: case OPT_HW_RESOLUTION_ONLY: /* 990320, ss */ case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_CUSTOM_GAMMA: case OPT_CUSTOM_GAMMA_BIND: case OPT_HNEGATIVE: /* case OPT_GRC: */ case OPT_MIRROR: case OPT_AE: case OPT_PREVIEW: case OPT_BIND_HILO: case OPT_HILITE_R: case OPT_SHADOW_R: case OPT_HILITE_G: case OPT_SHADOW_G: case OPT_HILITE_B: case OPT_SHADOW_B: case OPT_EJECT_AFTERSCAN: case OPT_EJECT_BEFOREEXIT: case OPT_THRESHOLD: case OPT_AF: case OPT_AF_ONCE: case OPT_FOCUS: if ((option >= OPT_NEGATIVE) && (option <= OPT_SHADOW_B)) { DBG (21, "GET_VALUE for %s: s->val[%s].w = %d\n", option_name[option], option_name[option], s->val[option].w); } *(SANE_Word *) val = s->val[option].w; DBG (21, "value for option %s: %d\n", option_name[option], s->val[option].w); return (SANE_STATUS_GOOD); case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memset (gbuf, 0, sizeof (gbuf)); buf_size = 256; transfer_data_type = 0x03; DBG (21, "sending GET_DENSITY_CURVE\n"); if (s->val[OPT_CUSTOM_GAMMA_BIND].w == SANE_TRUE) /* If using bind analog gamma, option will be OPT_GAMMA_VECTOR. In this case, use the curve for green */ gamma_component = 2; else /* Else use a different index for each curve */ gamma_component = option - OPT_GAMMA_VECTOR; /* Now get the values from the scanner */ if (s->hw->info.model != FS2710) { sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, s->hw); status = get_density_curve (s->fd, gamma_component, gbuf, &buf_size, transfer_data_type); sanei_scsi_close (s->fd); s->fd = -1; if (status != SANE_STATUS_GOOD) { DBG (21, "GET_DENSITY_CURVE\n"); return (SANE_STATUS_INVAL); } } else status = get_density_curve_fs2710 (s, gamma_component, gbuf, &buf_size); neg = (s->hw->info.is_filmscanner) ? strcmp (filmtype_list[1], s->val[OPT_NEGATIVE].s) : s->val[OPT_HNEGATIVE].w; for (i = 0; i < 256; i++) { if (!neg) s->gamma_table[option - OPT_GAMMA_VECTOR][i] = (SANE_Int) gbuf[i]; else s->gamma_table[option - OPT_GAMMA_VECTOR][i] = 255 - (SANE_Int) gbuf[255 - i]; } memcpy (val, s->val[option].wa, s->opt[option].size); DBG (21, "value for option %s: %d\n", option_name[option], s->val[option].w); return (SANE_STATUS_GOOD); /* string options: */ case OPT_TPU_DCM: case OPT_TPU_FILMTYPE: case OPT_MODE: case OPT_NEGATIVE: case OPT_NEGATIVE_TYPE: case OPT_SCANNING_SPEED: strcpy (val, s->val[option].s); DBG (21, "value for option %s: %s\n", option_name[option], s->val[option].s); return (SANE_STATUS_GOOD); default: val = 0; return (SANE_STATUS_GOOD); } } else if (action == SANE_ACTION_SET_VALUE) { DBG (21, "sane_control_option set value for %s\n", option_name[option]); if (!SANE_OPTION_IS_SETTABLE (cap)) return (SANE_STATUS_INVAL); status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { /* (mostly) side-effect-free word options: */ case OPT_TPU_PN: case OPT_TPU_TRANSPARENCY: case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: if (info && s->val[option].w != *(SANE_Word *) val) *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_NUM_OPTS: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_THRESHOLD: case OPT_HNEGATIVE: /* case OPT_GRC: */ case OPT_MIRROR: case OPT_AE: case OPT_PREVIEW: case OPT_HILITE_R: case OPT_SHADOW_R: case OPT_HILITE_G: case OPT_SHADOW_G: case OPT_HILITE_B: case OPT_SHADOW_B: case OPT_AF_ONCE: case OPT_FOCUS: case OPT_EJECT_AFTERSCAN: case OPT_EJECT_BEFOREEXIT: s->val[option].w = *(SANE_Word *) val; DBG (21, "SET_VALUE for %s: s->val[%s].w = %d\n", option_name[option], option_name[option], s->val[option].w); return (SANE_STATUS_GOOD); case OPT_RESOLUTION_BIND: if (s->val[option].w != *(SANE_Word *) val) { s->val[option].w = *(SANE_Word *) val; if (info) *info |= SANE_INFO_RELOAD_OPTIONS; if (!s->val[option].w) { /* don't bind */ s->opt[OPT_Y_RESOLUTION].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_X_RESOLUTION; s->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_X_RESOLUTION; } else { /* bind */ s->opt[OPT_Y_RESOLUTION].cap |= SANE_CAP_INACTIVE; s->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; } } return SANE_STATUS_GOOD; /* 990320, ss: switch between slider and option menue for resolution */ case OPT_HW_RESOLUTION_ONLY: if (s->val[option].w != *(SANE_Word *) val) { int iPos, xres, yres; s->val[option].w = *(SANE_Word *) val; if (info) *info |= SANE_INFO_RELOAD_OPTIONS; if (!s->val[option].w) /* use complete range */ { s->opt[OPT_X_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_X_RESOLUTION].constraint.range = &s->hw->info.xres_range; s->opt[OPT_Y_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_Y_RESOLUTION].constraint.range = &s->hw->info.yres_range; } else /* use only hardware resolutions */ { s->opt[OPT_X_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_X_RESOLUTION].constraint.word_list = s->xres_word_list; s->opt[OPT_Y_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_Y_RESOLUTION].constraint.word_list = s->yres_word_list; /* adjust resolutions */ xres = s->xres_word_list[1]; for (iPos = 0; iPos < s->xres_word_list[0]; iPos++) { if (s->val[OPT_X_RESOLUTION].w >= s->xres_word_list[iPos + 1]) xres = s->xres_word_list[iPos + 1]; } s->val[OPT_X_RESOLUTION].w = xres; yres = s->yres_word_list[1]; for (iPos = 0; iPos < s->yres_word_list[0]; iPos++) { if (s->val[OPT_Y_RESOLUTION].w >= s->yres_word_list[iPos + 1]) yres = s->yres_word_list[iPos + 1]; } s->val[OPT_Y_RESOLUTION].w = yres; } } return (SANE_STATUS_GOOD); case OPT_BIND_HILO: if (s->val[option].w != *(SANE_Word *) val) { s->val[option].w = *(SANE_Word *) val; if (info) *info |= SANE_INFO_RELOAD_OPTIONS; if (!s->val[option].w) { /* don't bind */ s->opt[OPT_HILITE_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_SHADOW_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_HILITE_B].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_SHADOW_B].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_HILITE_G].title = SANE_TITLE_HIGHLIGHT_G; s->opt[OPT_HILITE_G].name = SANE_NAME_HIGHLIGHT_G; s->opt[OPT_HILITE_G].desc = SANE_DESC_HIGHLIGHT_G; s->opt[OPT_SHADOW_G].title = SANE_TITLE_SHADOW_G; s->opt[OPT_SHADOW_G].name = SANE_NAME_SHADOW_G; s->opt[OPT_SHADOW_G].desc = SANE_DESC_SHADOW_G; } else { /* bind */ s->opt[OPT_HILITE_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SHADOW_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HILITE_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SHADOW_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HILITE_G].title = SANE_TITLE_HIGHLIGHT; s->opt[OPT_HILITE_G].name = SANE_NAME_HIGHLIGHT; s->opt[OPT_HILITE_G].desc = SANE_DESC_HIGHLIGHT; s->opt[OPT_SHADOW_G].title = SANE_TITLE_SHADOW; s->opt[OPT_SHADOW_G].name = SANE_NAME_SHADOW; s->opt[OPT_SHADOW_G].desc = SANE_DESC_SHADOW; } } return SANE_STATUS_GOOD; case OPT_AF: if (info && s->val[option].w != *(SANE_Word *) val) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; s->val[option].w = *(SANE_Word *) val; w = *(SANE_Word *) val; if (w) { s->opt[OPT_AF_ONCE].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_FOCUS].cap |= SANE_CAP_INACTIVE; } else { s->opt[OPT_AF_ONCE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_FOCUS].cap &= ~SANE_CAP_INACTIVE; } return (SANE_STATUS_GOOD); case OPT_FLATBED_ONLY: s->val[option].w = *(SANE_Word *) val; if (s->hw->adf.Status != ADF_STAT_NONE && s->val[option].w) { /* switch on */ s->hw->adf.Priority |= 0x03; /* flatbed mode */ s->hw->adf.Feeder &= 0x00; /* autofeed off (default) */ s->hw->adf.Status = ADF_STAT_DISABLED; } /* if it isn't connected, don't bother fixing */ return SANE_STATUS_GOOD; case OPT_TPU_ON: s->val[option].w = *(SANE_Word *) val; if (s->val[option].w) /* switch on */ { s->hw->tpu.Status = TPU_STAT_ACTIVE; s->opt[OPT_TPU_TRANSPARENCY].cap &= (s->hw->tpu.ControlMode == 3) ? ~SANE_CAP_INACTIVE : ~0; s->opt[OPT_TPU_FILMTYPE].cap &= (s->hw->tpu.ControlMode == 1) ? ~SANE_CAP_INACTIVE : ~0; } else /* switch off */ { s->hw->tpu.Status = TPU_STAT_INACTIVE; s->opt[OPT_TPU_TRANSPARENCY].cap |= SANE_CAP_INACTIVE; s->opt[OPT_TPU_FILMTYPE].cap |= SANE_CAP_INACTIVE; } s->opt[OPT_TPU_PN].cap ^= SANE_CAP_INACTIVE; s->opt[OPT_TPU_DCM].cap ^= SANE_CAP_INACTIVE; if (info) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_TPU_DCM: if (s->val[OPT_TPU_DCM].s) free (s->val[OPT_TPU_DCM].s); s->val[OPT_TPU_DCM].s = strdup (val); s->opt[OPT_TPU_TRANSPARENCY].cap |= SANE_CAP_INACTIVE; s->opt[OPT_TPU_FILMTYPE].cap |= SANE_CAP_INACTIVE; if (!strcmp (s->val[OPT_TPU_DCM].s, SANE_I18N("Correction according to transparency ratio"))) { s->hw->tpu.ControlMode = 3; s->opt[OPT_TPU_TRANSPARENCY].cap &= ~SANE_CAP_INACTIVE; } else if (!strcmp (s->val[OPT_TPU_DCM].s, SANE_I18N("Correction according to film type"))) { s->hw->tpu.ControlMode = 1; s->opt[OPT_TPU_FILMTYPE].cap &= ~SANE_CAP_INACTIVE; } else s->hw->tpu.ControlMode = 0; if (info) *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_TPU_FILMTYPE: if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); return SANE_STATUS_GOOD; case OPT_MODE: if (info && strcmp (s->val[option].s, (SANE_String) val)) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); if (!strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) || !strcmp (val, SANE_VALUE_SCAN_MODE_HALFTONE)) { /* For Lineart and Halftone: */ /* Enable "threshold" */ s->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; /* Disable "custom gamma" and "brightness & contrast" */ s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; } else { /* For Gray and Color modes: */ /* Disable "threshold" */ s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; /* Enable "custom gamma" and "brightness & contrast" */ s->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (s->val[OPT_CUSTOM_GAMMA].w) { if (!strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) || !strcmp (val, SANE_I18N("Fine color"))) { s->opt[OPT_CUSTOM_GAMMA_BIND].cap &= ~SANE_CAP_INACTIVE; if (s->val[OPT_CUSTOM_GAMMA_BIND].w == SANE_TRUE) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } else { s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } else { s->opt[OPT_CUSTOM_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } } else { s->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; } } return (SANE_STATUS_GOOD); case OPT_NEGATIVE: if (info && strcmp (s->val[option].s, (SANE_String) val)) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); if (!strcmp (val, SANE_I18N("Negatives"))) { s->RIF = 0; s->opt[OPT_NEGATIVE_TYPE].cap &= ~SANE_CAP_INACTIVE; if (SANE_OPTION_IS_SETTABLE(s->opt[OPT_SCANNING_SPEED].cap)) s->opt[OPT_SCANNING_SPEED].cap &= ~SANE_CAP_INACTIVE; } else { s->RIF = 1; s->opt[OPT_NEGATIVE_TYPE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SCANNING_SPEED].cap |= SANE_CAP_INACTIVE; } return (SANE_STATUS_GOOD); case OPT_NEGATIVE_TYPE: if (info && strcmp (s->val[option].s, (SANE_String) val)) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); for (i = 0; strcmp (val, negative_filmtype_list[i]); i++); s->negative_filmtype = i; return (SANE_STATUS_GOOD); case OPT_SCANNING_SPEED: if (info && strcmp (s->val[option].s, (SANE_String) val)) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); for (i = 0; strcmp (val, scanning_speed_list[i]); i++); s->scanning_speed = i; return (SANE_STATUS_GOOD); /* modification for FB620S */ case OPT_CALIBRATION_NOW: sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, s->hw); if (status == SANE_STATUS_GOOD) { status = execute_calibration (s->fd); if (status != SANE_STATUS_GOOD) { DBG (21, "EXECUTE CALIBRATION failed\n"); sanei_scsi_close (s->fd); s->fd = -1; return (SANE_STATUS_INVAL); } DBG (21, "EXECUTE CALIBRATION\n"); sanei_scsi_close (s->fd); } else DBG (1, "calibration: cannot open device file\n"); s->fd = -1; return status; case OPT_SCANNER_SELF_DIAGNOSTIC: sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, s->hw); if (status == SANE_STATUS_GOOD) { status = send_diagnostic (s->fd); { if (status != SANE_STATUS_GOOD) { DBG (21, "SEND DIAGNOSTIC error: %s\n", sane_strstatus (status)); sanei_scsi_close (s->fd); s->fd = -1; return (status); } DBG (21, "SEND DIAGNOSTIC result: %s\n", sane_strstatus (status)); sanei_scsi_close (s->fd); } } else DBG (1, "send diagnostic: cannot open device file\n"); s->fd = -1; return status; case OPT_RESET_SCANNER: sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, s->hw); if (status == SANE_STATUS_GOOD) { time (&(s->time1)); DBG (11, "time0 = %ld\n", s->time0); DBG (11, "time1 = %ld\n", s->time1); dtime = (s->time1) - (s->time0); DBG (11, "dtime = %ld\n", dtime); DBG (11, "switch_preview = %d\n", s->switch_preview); if (s->switch_preview == 0) { rt = sqrt (15 * 15 * (SANE_UNFIX (s->val[OPT_BR_Y].w)) / 297) + 0.5; rt = rt + 2; } else rt = 17; DBG (11, "SANE_UNFIX(s->val[OPT_BR_Y].w) = %f\n", SANE_UNFIX (s->val[OPT_BR_Y].w)); DBG (11, "rt = %ld\n", rt); if (dtime < rt) { int_t = (int) (rt - dtime); DBG (11, "int_t = %d\n", int_t); sleep (int_t); } status = reset_scanner (s->fd); { if (status != SANE_STATUS_GOOD) { DBG (21, "RESET SCANNER failed\n"); sanei_scsi_close (s->fd); s->fd = -1; return (status); } DBG (21, "RESET SCANNER\n"); sanei_scsi_close (s->fd); } } else DBG (1, "reset scanner: cannot open device file\n"); s->fd = -1; return status; case OPT_EJECT_NOW: sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, s->hw); status = medium_position (s->fd); if (status != SANE_STATUS_GOOD) { DBG (21, "MEDIUM POSITION failed\n"); sanei_scsi_close (s->fd); s->fd = -1; return (SANE_STATUS_INVAL); } DBG (21, "AF_NOW before = '%d'\n", s->AF_NOW); s->AF_NOW = SANE_TRUE; DBG (21, "AF_NOW after = '%d'\n", s->AF_NOW); sanei_scsi_close (s->fd); s->fd = -1; return status; case OPT_CUSTOM_GAMMA: w = *(SANE_Word *) val; if (w == s->val[OPT_CUSTOM_GAMMA].w) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; s->val[OPT_CUSTOM_GAMMA].w = w; if (w) { const char *mode = s->val[OPT_MODE].s; if (!strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY)) s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; else if (!strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) || !strcmp (mode, SANE_I18N("Fine color"))) { s->opt[OPT_CUSTOM_GAMMA_BIND].cap &= ~SANE_CAP_INACTIVE; if (s->val[OPT_CUSTOM_GAMMA_BIND].w) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } else { s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; } else { s->opt[OPT_CUSTOM_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; case OPT_CUSTOM_GAMMA_BIND: w = *(SANE_Word *) val; if (w == s->val[OPT_CUSTOM_GAMMA_BIND].w) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; s->val[OPT_CUSTOM_GAMMA_BIND].w = w; if (w) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } else { s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (s->val[option].wa, val, s->opt[option].size); DBG (21, "setting gamma vector\n"); /* if (info) */ /* *info |= SANE_INFO_RELOAD_OPTIONS; */ return (SANE_STATUS_GOOD); } } DBG (1, "<< sane_control_option %s\n", option_name[option]); return (SANE_STATUS_INVAL); } /**************************************************************************/ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters *params) { CANON_Scanner *s = handle; DBG (1, ">> sane_get_parameters\n"); if (!s->scanning) { int width, length, xres, yres; const char *mode; memset (&s->params, 0, sizeof (s->params)); width = SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) * s->hw->info.mud / MM_PER_INCH; length = SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) * s->hw->info.mud / MM_PER_INCH; xres = s->val[OPT_X_RESOLUTION].w; yres = s->val[OPT_Y_RESOLUTION].w; if (s->val[OPT_RESOLUTION_BIND].w || s->val[OPT_PREVIEW].w) yres = xres; /* make best-effort guess at what parameters will look like once scanning starts. */ if (xres > 0 && yres > 0 && width > 0 && length > 0) { DBG (11, "sane_get_parameters: width='%d', xres='%d', mud='%d'\n", width, xres, s->hw->info.mud); s->params.pixels_per_line = width * xres / s->hw->info.mud; DBG (11, "sane_get_parameters: length='%d', yres='%d', mud='%d'\n", length, yres, s->hw->info.mud); s->params.lines = length * yres / s->hw->info.mud; DBG (11, "sane_get_parameters: pixels_per_line='%d', lines='%d'\n", s->params.pixels_per_line, s->params.lines); } mode = s->val[OPT_MODE].s; if (!strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) || !strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE)) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line / 8; /* workaround rounding problems */ s->params.pixels_per_line = s->params.bytes_per_line * 8; s->params.depth = 1; } else if (!strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY)) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; } else if (!strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) || !strcmp (mode, SANE_I18N("Fine color"))) { s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line = 3 * s->params.pixels_per_line; s->params.depth = 8; } else { s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line = 6 * s->params.pixels_per_line; s->params.depth = 16; } s->params.last_frame = SANE_TRUE; } DBG (11, "sane_get_parameters: xres='%d', yres='%d', pixels_per_line='%d', " "bytes_per_line='%d', lines='%d'\n", s->xres, s->yres, s->params.pixels_per_line, s->params.bytes_per_line, s->params.lines); if (params) *params = s->params; DBG (1, "<< sane_get_parameters\n"); return (SANE_STATUS_GOOD); } /**************************************************************************/ SANE_Status sane_start (SANE_Handle handle) { char *mode_str; CANON_Scanner *s = handle; SANE_Status status; u_char wbuf[72], dbuf[28], ebuf[72]; u_char cbuf[2]; /* modification for FB620S */ size_t buf_size, i; char tmpfilename[] = "/tmp/canon.XXXXXX"; /* for FB1200S */ char *thistmpfile; /* for FB1200S */ DBG (1, ">> sane_start\n"); s->tmpfile = -1; /* for FB1200S */ /******* making a tempfile for 1200 dpi scanning of FB1200S ******/ if (s->hw->info.model == FB1200) { thistmpfile = strdup(tmpfilename); if (thistmpfile != NULL) { if (!mkstemp(thistmpfile)) { DBG(1, "mkstemp(thistmpfile) is failed\n"); return (SANE_STATUS_INVAL); } } else { DBG(1, "strdup(thistmpfile) is failed\n"); return (SANE_STATUS_INVAL); } s->tmpfile = open(thistmpfile, O_RDWR | O_CREAT | O_EXCL, 0600); if (s->tmpfile == -1) { DBG(1, "error opening temp file %s\n", thistmpfile); DBG(1, "errno: %i; %s\n", errno, strerror(errno)); errno = 0; return (SANE_STATUS_INVAL); } DBG(1, " ****** tmpfile is opened ****** \n"); unlink(thistmpfile); free (thistmpfile); DBG(1, "free thistmpfile\n"); } /******************************************************************/ s->scanning = SANE_FALSE; if ((s->hw->adf.Status != ADF_STAT_NONE) && (s->val[OPT_FLATBED_ONLY].w != SANE_TRUE) && (s->hw->adf.Problem != 0)) { DBG (3, "SCANNER ADF HAS A PROBLEM\n"); if (s->hw->adf.Problem & 0x08) { status = SANE_STATUS_COVER_OPEN; DBG (3, "ADF Cover Open\n"); } else if (s->hw->adf.Problem & 0x04) { status = SANE_STATUS_JAMMED; DBG (3, "ADF Paper Jam\n"); } else /* adf.Problem = 0x02 */ { status = SANE_STATUS_NO_DOCS; DBG (3, "ADF No More Documents\n"); } return status; } else if ((s->hw->adf.Status != ADF_STAT_NONE) && (s->val[OPT_FLATBED_ONLY].w == SANE_TRUE)) { set_adf_mode (s->fd, s->hw->adf.Priority); /* 2.23 define ADF Mode */ } /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; status = sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, s->hw); if (status != SANE_STATUS_GOOD) { DBG (1, "open of %s failed: %s\n", s->hw->sane.name, sane_strstatus (status)); return (status); } #if 0 /* code moved after define_scan() calls */ /* Do focus, but not for the preview */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_FOCUS_GROUP].cap) && !s->val[OPT_PREVIEW].w && s->AF_NOW) { if ((status = do_focus (s)) != SANE_STATUS_GOOD) return (status); if (s->val[OPT_AF_ONCE].w) s->AF_NOW = SANE_FALSE; } #endif if (s->val[OPT_CUSTOM_GAMMA].w) { if ((status = do_gamma (s)) != SANE_STATUS_GOOD) return (status); } DBG (3, "attach: sending GET SCAN MODE for scan control conditions\n"); memset (ebuf, 0, sizeof (ebuf)); buf_size = 20; status = get_scan_mode (s->fd, (u_char) SCAN_CONTROL_CONDITIONS, ebuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: GET SCAN MODE for scan control conditions failed\n"); sanei_scsi_close (s->fd); return (SANE_STATUS_INVAL); } for (i = 0; i < buf_size; i++) DBG (3, "scan mode control byte[%d] = %d\n", (int) i, ebuf[i]); if (s->hw->adf.Status != ADF_STAT_NONE) { DBG (3, "attach: sending GET SCAN MODE for transparency unit\n"); memset (ebuf, 0, sizeof (ebuf)); buf_size = 12; status = get_scan_mode (s->fd, (u_char) TRANSPARENCY_UNIT, ebuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: GET SCAN MODE for transparency unit failed\n"); sanei_scsi_close (s->fd); return (SANE_STATUS_INVAL); } for (i = 0; i < buf_size; i++) DBG (3, "scan mode control byte[%d] = %d\n", (int) i, ebuf[i]); } mode_str = s->val[OPT_MODE].s; s->xres = s->val[OPT_X_RESOLUTION].w; s->yres = s->val[OPT_Y_RESOLUTION].w; if (s->val[OPT_RESOLUTION_BIND].w || s->val[OPT_PREVIEW].w) s->yres = s->xres; s->ulx = SANE_UNFIX (s->val[OPT_TL_X].w) * s->hw->info.mud / MM_PER_INCH; s->uly = SANE_UNFIX (s->val[OPT_TL_Y].w) * s->hw->info.mud / MM_PER_INCH; s->width = SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) * s->hw->info.mud / MM_PER_INCH; s->length = SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) * s->hw->info.mud / MM_PER_INCH; DBG (11, "s->width='%d', s->length='%d'\n", s->width, s->length); if (s->hw->info.model != CS2700 && s->hw->info.model != FS2710) { if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_LINEART) || !strcmp (mode_str, SANE_VALUE_SCAN_MODE_HALFTONE)) s->RIF = s->val[OPT_HNEGATIVE].w; else s->RIF = !s->val[OPT_HNEGATIVE].w; } s->brightness = s->val[OPT_BRIGHTNESS].w; s->contrast = s->val[OPT_CONTRAST].w; s->threshold = s->val[OPT_THRESHOLD].w; s->bpp = s->params.depth; s->GRC = s->val[OPT_CUSTOM_GAMMA].w; s->Mirror = s->val[OPT_MIRROR].w; s->AE = s->val[OPT_AE].w; s->HiliteG = s->val[OPT_HILITE_G].w; s->ShadowG = s->val[OPT_SHADOW_G].w; if (s->val[OPT_BIND_HILO].w) { s->HiliteR = s->val[OPT_HILITE_G].w; s->ShadowR = s->val[OPT_SHADOW_G].w; s->HiliteB = s->val[OPT_HILITE_G].w; s->ShadowB = s->val[OPT_SHADOW_G].w; } else { s->HiliteR = s->val[OPT_HILITE_R].w; s->ShadowR = s->val[OPT_SHADOW_R].w; s->HiliteB = s->val[OPT_HILITE_B].w; s->ShadowB = s->val[OPT_SHADOW_B].w; } if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_LINEART)) { s->image_composition = 0; } else if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_HALFTONE)) { s->image_composition = 1; } else if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_GRAY)) { s->image_composition = 2; } else if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_COLOR) || !strcmp (mode_str, SANE_I18N("Fine color"))) { s->image_composition = 5; } else if (!strcmp (mode_str, SANE_I18N("Raw"))) { s->image_composition = 5; } else { s->image_composition = 5; } memset (wbuf, 0, sizeof (wbuf)); wbuf[7] = 64; wbuf[10] = s->xres >> 8; wbuf[11] = s->xres; wbuf[12] = s->yres >> 8; wbuf[13] = s->yres; wbuf[14] = s->ulx >> 24; wbuf[15] = s->ulx >> 16; wbuf[16] = s->ulx >> 8; wbuf[17] = s->ulx; wbuf[18] = s->uly >> 24; wbuf[19] = s->uly >> 16; wbuf[20] = s->uly >> 8; wbuf[21] = s->uly; wbuf[22] = s->width >> 24; wbuf[23] = s->width >> 16; wbuf[24] = s->width >> 8; wbuf[25] = s->width; wbuf[26] = s->length >> 24; wbuf[27] = s->length >> 16; wbuf[28] = s->length >> 8; wbuf[29] = s->length; wbuf[30] = s->brightness; wbuf[31] = s->threshold; wbuf[32] = s->contrast; wbuf[33] = s->image_composition; wbuf[34] = (s->hw->info.model == FS2710) ? 12 : s->bpp; wbuf[36] = 1; wbuf[37] = (1 << 7) + 0x03; wbuf[50] = (s->GRC << 3) | (s->Mirror << 2); #if 1 wbuf[50] |= s->AE; /* AE also for preview; needed by frontend controls */ #else if (!s->val[OPT_PREVIEW].w) wbuf[50] |= s->AE; /* AE not during preview */ #endif wbuf[54] = 2; wbuf[57] = 1; wbuf[58] = 1; wbuf[59] = s->HiliteR; wbuf[60] = s->ShadowR; wbuf[62] = s->HiliteG; wbuf[64] = s->ShadowG; wbuf[70] = s->HiliteB; wbuf[71] = s->ShadowB; DBG (7, "RIF=%d, GRC=%d, Mirror=%d, AE=%d, Speed=%d\n", s->RIF, s->GRC, s->Mirror, s->AE, s->scanning_speed); DBG (7, "HR=%d, SR=%d, HG=%d, SG=%d, HB=%d, SB=%d\n", s->HiliteR, s->ShadowR, s->HiliteG, s->ShadowG, s->HiliteB, s->ShadowB); if (s->hw->info.model == FB620) /* modification for FB620S */ { wbuf[36] = 0; wbuf[37] = (s->RIF << 7) + 0x3; wbuf[50] = s->GRC << 3; wbuf[54] = 0; wbuf[57] = 0; wbuf[58] = 0; } else if (s->hw->info.model == FB1200) /* modification for FB1200S */ { #if 0 wbuf[34] = (((600 < s->val[OPT_X_RESOLUTION].w) || (600 < s->val[OPT_Y_RESOLUTION].w)) && (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) != 0)) ? 12 : s->bpp; #endif wbuf[36] = 0; wbuf[37] = (s->RIF << 7) + 0x3; wbuf[50] = (1 << 4) | (s->GRC << 3); wbuf[57] = 1; wbuf[58] = 1; } else if (s->hw->info.model == IX4015) /* modification for IX-4015 */ { wbuf[36] = 0; wbuf[37] = (s->RIF << 7); wbuf[57] = 0; wbuf[58] = 0; /* no highlight and shadow control */ wbuf[59] = 0; wbuf[60] = 0; wbuf[62] = 0; wbuf[64] = 0; wbuf[70] = 0; wbuf[71] = 0; } buf_size = sizeof (wbuf); status = set_window (s->fd, wbuf); if (status != SANE_STATUS_GOOD) { DBG (1, "SET WINDOW failed: %s\n", sane_strstatus (status)); return (status); } if (s->hw->info.model == FS2710) status = set_parameters_fs2710 (s); buf_size = sizeof (wbuf); memset (wbuf, 0, buf_size); status = get_window (s->fd, wbuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "GET WINDOW failed: %s\n", sane_strstatus (status)); return (status); } DBG (5, "xres=%d\n", (wbuf[10] << 8) + wbuf[11]); DBG (5, "yres=%d\n", (wbuf[12] << 8) + wbuf[13]); DBG (5, "ulx=%d\n", (wbuf[14] << 24) + (wbuf[15] << 16) + (wbuf[16] << 8) + wbuf[17]); DBG (5, "uly=%d\n", (wbuf[18] << 24) + (wbuf[19] << 16) + (wbuf[20] << 8) + wbuf[21]); DBG (5, "width=%d\n", (wbuf[22] << 24) + (wbuf[23] << 16) + (wbuf[24] << 8) + wbuf[25]); DBG (5, "length=%d\n", (wbuf[26] << 24) + (wbuf[27] << 16) + (wbuf[28] << 8) + wbuf[29]); DBG (5, "Highlight Red=%d\n", wbuf[59]); DBG (5, "Shadow Red=%d\n", wbuf[60]); DBG (5, "Highlight (Green)=%d\n", wbuf[62]); DBG (5, "Shadow (Green)=%d\n", wbuf[64]); DBG (5, "Highlight Blue=%d\n", wbuf[70]); DBG (5, "Shadow Blue=%d\n", wbuf[71]); if (s->hw->tpu.Status == TPU_STAT_ACTIVE || s->hw->info.is_filmscanner) { DBG (3, "sane_start: sending DEFINE SCAN MODE for transparency unit, " "NP=%d, Negative film type=%d\n", !s->RIF, s->negative_filmtype); memset (wbuf, 0, sizeof (wbuf)); wbuf[0] = 0x02; wbuf[1] = 6; wbuf[2] = 0x80; wbuf[3] = 0x05; wbuf[4] = 39; wbuf[5] = 16; wbuf[6] = !s->RIF; wbuf[7] = s->negative_filmtype; status = define_scan_mode (s->fd, TRANSPARENCY_UNIT, wbuf); /* note: If we implement a TPU for the FB1200S, we need TRANSPARENCY_UNIT_FB1200 here. */ if (status != SANE_STATUS_GOOD) { DBG (1, "define scan mode failed: %s\n", sane_strstatus (status)); return (status); } } DBG (3, "sane_start: sending DEFINE SCAN MODE for scan control " "conditions\n"); memset (wbuf, 0, sizeof (wbuf)); wbuf[0] = 0x20; if (s->hw->info.model == FB1200) { wbuf[1] = 17; wbuf[16] = 3; wbuf[17] = 8; wbuf[18] = (1 << 7) | (1 << 3); DBG (3, "sane_start: sending DEFINE SCAN MODE for scan control " "conditions of FB1200\n"); status = define_scan_mode (s->fd, SCAN_CONTROL_CON_FB1200, wbuf); } else { wbuf[1] = 14; /* For preview use always normal speed: */ if (!s->val[OPT_PREVIEW].w && s->hw->info.is_filmscanner) wbuf[11] = s->scanning_speed; wbuf[15] = (s->hw->info.model == FB620 && !strcmp (mode_str, SANE_I18N("Fine color")) && !s->val[OPT_PREVIEW].w) ? 1 << 3 : 0; status = define_scan_mode (s->fd, SCAN_CONTROL_CONDITIONS, wbuf); } if (status != SANE_STATUS_GOOD) { DBG (1, "define scan mode failed: %s\n", sane_strstatus (status)); return (status); } DBG (3, "sane_start: sending GET SCAN MODE for scan control conditions\n"); memset (ebuf, 0, sizeof (ebuf)); buf_size = sizeof (ebuf); status = get_scan_mode (s->fd, SCAN_CONTROL_CONDITIONS, ebuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: GET SCAN MODE for scan control conditions " "failed\n"); sanei_scsi_close (s->fd); return (SANE_STATUS_INVAL); } for (i = 0; i < buf_size; i++) DBG (3, "scan mode byte[%d] = %d\n", (int) i, ebuf[i]); /* Focus, but not for previews or negatives with speed control */ if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_FOCUS_GROUP].cap) && !s->val[OPT_PREVIEW].w && s->AF_NOW && (s->RIF || s->AE || s->scanning_speed == 0)) { if ((status = do_focus (s)) != SANE_STATUS_GOOD) return (status); if (s->val[OPT_AF_ONCE].w) s->AF_NOW = SANE_FALSE; } /* ============= modification for FB620S ============= */ DBG (3, "TEST_UNIT_READY\n"); status = test_unit_ready (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "test unit ready failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (s->fd); s->fd = -1; return (status); } if (s->hw->info.can_calibrate) { DBG (3, "sane_start: sending GET_CALIBRATION_STATUS\n"); buf_size = sizeof (cbuf); memset (cbuf, 0, buf_size); status = get_calibration_status (s->fd, cbuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: GET_CALIBRATION_STATUS failed: %s\n", sane_strstatus (status)); sanei_scsi_close (s->fd); s->fd = -1; return (status); } DBG (1, "cbuf[0] = %d\n", cbuf[0]); DBG (1, "cbuf[1] = %d\n", cbuf[1]); cbuf[0] &= 3; if (cbuf[0] == 1 || cbuf[0] == 2 || cbuf[0] == 3) { status = execute_calibration (s->fd); DBG (3, "sane_start: EXECUTE_CALIBRATION\n"); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: EXECUTE_CALIBRATION failed\n"); sanei_scsi_close (s->fd); s->fd = -1; return (status); } DBG (3, "after calibration: GET_CALIBRATION_STATUS\n"); buf_size = sizeof (cbuf); memset (cbuf, 0, buf_size); status = get_calibration_status (s->fd, cbuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "after calibration: GET_CALIBRATION_STATUS failed: %s\n", sane_strstatus (status)); sanei_scsi_close (s->fd); s->fd = -1; return (status); } DBG (1, "cbuf[0] = %d\n", cbuf[0]); DBG (1, "cbuf[1] = %d\n", cbuf[1]); } } status = scan (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "start of scan failed: %s\n", sane_strstatus (status)); return (status); } buf_size = sizeof (dbuf); memset (dbuf, 0, buf_size); status = get_data_status (s->fd, dbuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "GET DATA STATUS failed: %s\n", sane_strstatus (status)); return (status); } DBG (5, ">> GET DATA STATUS\n"); DBG (5, "Scan Data Available=%d\n", (dbuf[9] << 16) + (dbuf[10] << 8) + dbuf[11]); DBG (5, "Magnified Width=%d\n", (dbuf[12] <<24) + (dbuf[13] << 16) + (dbuf[14] << 8) + dbuf[15]); DBG (5, "Magnified Length=%d\n", (dbuf[16] << 24) + (dbuf[17] << 16) + (dbuf[18] << 8) + dbuf[19]); DBG (5, "Rest Data=%d bytes\n", (dbuf[20] << 24) + (dbuf[21] << 16) + (dbuf[22] << 8) + dbuf[23]); DBG (5, "Filled Data Buffer=%d\n", (dbuf[24] << 24) + (dbuf[25] << 16) + (dbuf[26] << 8) + dbuf[27]); DBG (5, "<< GET DATA STATUS\n"); s->bytes_to_read = s->params.bytes_per_line * s->params.lines; if (s->hw->info.model == FB1200) { if (s->bytes_to_read != (((size_t) dbuf[9] << 16) + ((size_t) dbuf[10] << 8) + (size_t) dbuf[11])) { s->params.bytes_per_line = (((size_t) dbuf[12] << 24) + ((size_t) dbuf[13] << 16) + ((size_t) dbuf[14] << 8) + (size_t)dbuf[15]); s->params.lines = (((size_t) dbuf[16] << 24) + ((size_t) dbuf[17] << 16) + ((size_t) dbuf[18] << 8) + (size_t) dbuf[19]); s->bytes_to_read = s->params.bytes_per_line * s->params.lines; mode_str = s->val[OPT_MODE].s; if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_LINEART)) { if (((600 < s->val[OPT_X_RESOLUTION].w) || (600 < s->val[OPT_Y_RESOLUTION].w))) { s->params.bytes_per_line *= 2; s->params.lines /= 2; } s->params.pixels_per_line = s->params.bytes_per_line * 8; } else if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_GRAY)) s->params.pixels_per_line = s->params.bytes_per_line; else if (!strcmp (mode_str, SANE_VALUE_SCAN_MODE_COLOR) || !strcmp (mode_str, SANE_I18N("Fine color"))) s->params.pixels_per_line = s->params.bytes_per_line / 3; else s->params.pixels_per_line = s->params.bytes_per_line / 6; } } DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, " "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line, s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_X_RESOLUTION].w); /**************************************************/ /* modification for FB620S and FB1200S */ s->buf_used = 0; s->buf_pos = 0; /**************************************************/ s->scanning = SANE_TRUE; DBG (1, "<< sane_start\n"); return (SANE_STATUS_GOOD); } /**************************************************************************/ static SANE_Status sane_read_direct (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { CANON_Scanner *s = handle; SANE_Status status; size_t nread; DBG (21, ">> sane_read\n"); *len = 0; nread = max_len; DBG (21, " sane_read: nread=%d, bytes_to_read=%d\n", (int) nread, (int) s->bytes_to_read); if (s->bytes_to_read == 0) { do_cancel (s); return (SANE_STATUS_EOF); } if (!s->scanning) return (do_cancel (s)); if (nread > s->bytes_to_read) nread = s->bytes_to_read; status = read_data (s->fd, buf, &nread); if (status != SANE_STATUS_GOOD) { do_cancel (s); return (SANE_STATUS_IO_ERROR); } *len = nread; s->bytes_to_read -= nread; DBG (21, " sane_read: nread=%d, bytes_to_read=%d\n", (int) nread, (int) s->bytes_to_read); DBG (21, "<< sane_read\n"); return (SANE_STATUS_GOOD); } /**************************************************************************/ static SANE_Status read_fs2710 (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { CANON_Scanner *s = handle; SANE_Status status; int c; size_t i, nread, nread2; u_char *p; #if defined(WORDS_BIGENDIAN) u_char b; #endif DBG (21, ">> sane_read\n"); *len = 0; nread = max_len; DBG (21, " sane_read: nread=%d, bytes_to_read=%d\n", (int) nread, (int) s->bytes_to_read); if (nread > s->bytes_to_read) nread = s->bytes_to_read; if (s->bytes_to_read == 0) { do_cancel (s); return (SANE_STATUS_EOF); } if (!s->scanning) return (do_cancel (s)); /* We must receive 2 little-endian bytes per pixel and colour. In raw mode we must swap the bytes if we are running a big-endian architecture (SANE standard 3.2.1), and pass them both. Otherwise the other subroutines expect only 1 byte, so we must set up an intermediate buffer which is twice as large as buf, and then map this buffer to buf. */ if (!strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR)) { if (max_len > s->auxbuf_len) { /* extend buffer? */ if (s->auxbuf_len > 0) free (s->auxbuf); s->auxbuf_len = max_len; if ((s->auxbuf = (u_char *) malloc (2 * max_len)) == NULL) { DBG (1, "sane_read buffer size insufficient\n"); do_cancel (s); return SANE_STATUS_NO_MEM; } } nread2 = 2 * nread; if ((status = read_data (s->fd, s->auxbuf, &nread2)) != SANE_STATUS_GOOD) { do_cancel (s); return (SANE_STATUS_IO_ERROR); } nread = nread2 / 2; for (i = 0, p = s->auxbuf; i < nread; i++) { c = *p++ >> 4; c |= *p++ << 4; *buf++ = s->gamma_map[s->colour++][c]; if (s->colour > 3) s->colour = 1; /* cycle through RGB */ } } else { if ((status = read_data (s->fd, buf, &nread)) != SANE_STATUS_GOOD) { do_cancel (s); return (SANE_STATUS_IO_ERROR); } #if defined(WORDS_BIGENDIAN) for (p = buf; p < buf + nread; p++) { b = *p; *p = *(p + 1); p++; *p = b; } #endif } *len = nread; s->bytes_to_read -= nread; DBG (21, " sane_read: nread=%d, bytes_to_read=%d\n", (int) nread, (int) s->bytes_to_read); DBG (21, "<< sane_read\n"); return (SANE_STATUS_GOOD); } /**************************************************************************/ /* modification for FB620S */ static SANE_Status read_fb620 (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { CANON_Scanner *s = handle; SANE_Status status; SANE_Byte *out, *red, *green, *blue; SANE_Int ncopy; size_t nread = 0, i, pixel_per_line; DBG (21, ">> read_fb620\n"); *len = 0; DBG (21, " read_fb620: nread=%d, bytes_to_read=%d\n", (int) nread, (int) s->bytes_to_read); if (s->bytes_to_read == 0 && s->buf_pos == s->buf_used) { s->reset_flag = 0; /* no reset */ do_cancel (s); DBG (21, "do_cancel(EOF)\n"); DBG (21, "reset_flag = %d\n", s->reset_flag); return (SANE_STATUS_EOF); } else { s->reset_flag = 1; /* do reset */ DBG (21, "reset_flag = %d\n", s->reset_flag); } DBG (21, " read_fb620: buf_pos=%d, buf_used=%d\n", s->buf_pos, s->buf_used); if (!s->scanning) return (do_cancel (s)); if (s->buf_pos < s->buf_used) { ncopy = s->buf_used - s->buf_pos; if (ncopy > max_len) ncopy = max_len; memcpy (buf, &(s->outbuffer[s->buf_pos]), ncopy); max_len -= ncopy; *len += ncopy; buf = &(buf[ncopy]); s->buf_pos += ncopy; } if (s->buf_pos >= s->buf_used && s->bytes_to_read) { /* buffer is empty: read in scan line and sort color data as shown above */ nread = s->params.bytes_per_line; if (nread > s->bytes_to_read) nread = s->bytes_to_read; status = read_data (s->fd, s->inbuffer, &nread); if (status != SANE_STATUS_GOOD) { do_cancel (s); return (SANE_STATUS_IO_ERROR); } s->buf_used = s->params.bytes_per_line; out = s->outbuffer; pixel_per_line = s->params.pixels_per_line; red = s->inbuffer; green = &(s->inbuffer[pixel_per_line]); blue = &(s->inbuffer[2 * pixel_per_line]); for (i = 0; i < pixel_per_line; i++) { *out++ = *red++; *out++ = *green++; *out++ = *blue++; } s->buf_pos = 0; s->bytes_to_read -= s->buf_used; } if (max_len && s->buf_pos < s->buf_used) { ncopy = s->buf_used - s->buf_pos; if (ncopy > max_len) ncopy = max_len; memcpy (buf, &(s->outbuffer[s->buf_pos]), ncopy); *len += ncopy; s->buf_pos += ncopy; } DBG (21, "<< read_fb620\n"); return (SANE_STATUS_GOOD); } /**************************************************************************/ /* modification for FB1200S */ static SANE_Status read_fb1200 (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { CANON_Scanner *s = handle; SANE_Status status; SANE_Byte *firstimage, *secondimage/*, inmask, outmask, outbyte, primaryHigh[256], primaryLow[256], secondaryHigh[256], secondaryLow[256] */; SANE_Int ncopy; u_char dbuf[28]; size_t buf_size, nread, remain, nwritten, nremain, pos, pix, pixel_per_line, byte, byte_per_line/*, bit*/; ssize_t wres, readres; int maxpix; DBG (21, ">> read_fb1200\n"); buf_size = sizeof (dbuf); memset (dbuf, 0, buf_size); status = get_data_status (s->fd, dbuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "GET DATA STATUS failed: %s\n", sane_strstatus (status)); return (status); } DBG (5, ">> GET DATA STATUS\n"); DBG (5, "Scan Data Available=%d\n", (dbuf[9] << 16) + (dbuf[10] << 8) + dbuf[11]); DBG (5, "Rest Data=%d bytes\n", (dbuf[20] << 24) + (dbuf[21] << 16) + (dbuf[22] << 8) + dbuf[23]); DBG (5, "Filled Data Buffer=%d\n", (dbuf[24] << 24) + (dbuf[25] << 16) + (dbuf[26] << 8) + dbuf[27]); DBG (5, "temp file position:%u\n", (unsigned int) lseek(s->tmpfile, 0, SEEK_CUR)); DBG (5, "<< GET DATA STATUS\n"); *len = 0; DBG (21, " read_fb1200: bytes_to_read=%d\n", (int) s->bytes_to_read); if (s->bytes_to_read == 0 && s->buf_pos == s->buf_used) { do_cancel (s); DBG (21, "do_cancel(EOF)\n"); return (SANE_STATUS_EOF); } DBG (21, " read_fb1200: buf_pos=%d, buf_used=%d\n", s->buf_pos, s->buf_used); if (!s->scanning) return (do_cancel (s)); if (s->buf_pos >= s->buf_used && s->bytes_to_read) { nread = s->params.bytes_per_line / 2; if (nread > s->bytes_to_read) nread = s->bytes_to_read; status = read_data (s->fd, s->inbuffer, &nread); if (status != SANE_STATUS_GOOD) { do_cancel (s); return (SANE_STATUS_IO_ERROR); } /**** save the primary scan data to tmpfile ****/ if ((SANE_Int) s->bytes_to_read > s->params.bytes_per_line * s->params.lines / 2) { remain = nread; nwritten = 0; while (remain) { errno = 0; wres = write (s->tmpfile, &s->inbuffer[nwritten], remain); if (wres == -1) { DBG(1, "error write tmp file: %i, %s\n", errno, strerror(errno)); do_cancel(s); return (SANE_STATUS_NO_MEM); } remain -= wres; nwritten += wres; } s->bytes_to_read -= nread; if ((SANE_Int) s->bytes_to_read <= s->params.bytes_per_line * s->params.lines / 2) { if ((SANE_Int) s->bytes_to_read < s->params.bytes_per_line * s->params.lines / 2) DBG(1, "warning: read more data for the primary scan " "than expected\n"); lseek (s->tmpfile, 0L, SEEK_SET); *len = 0; *buf = 0; return (SANE_STATUS_GOOD); } DBG(1, "writing: the primary data to tmp file\n"); *len = 0; *buf = 0; return (SANE_STATUS_GOOD); } /** the primary scan data from tmpfile and the secondary scan data are merged **/ s->buf_used = s->params.bytes_per_line; byte_per_line = s->params.bytes_per_line; pixel_per_line = s->params.pixels_per_line; /** read an entire scan line from the primary scan **/ remain = nread; pos = 0; firstimage = &(s->inbuffer[byte_per_line/2]); while (remain > 0) { nremain = (remain < SSIZE_MAX)? remain: SSIZE_MAX; errno = 0; readres = read (s->tmpfile, &(firstimage[pos]), nremain); if (readres == -1) { DBG(1, "error reading tmp file: %i %s\n", errno, strerror(errno)); do_cancel(s); return (SANE_STATUS_IO_ERROR); } if (readres == 0) { DBG(1, "0 byte read from temp file. premature EOF?\n"); return (SANE_STATUS_INVAL); /* perhaps an error return? */ } DBG(1, "reading: the primary data from tmp file\n"); remain -= readres; pos += readres; } secondimage = s->inbuffer; if (!strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR)) { maxpix = pixel_per_line / 2; for (pix = 0; (int) pix < maxpix; pix++) { s->outbuffer[6 * pix] = secondimage[3 * pix]; s->outbuffer[6 * pix + 1] = secondimage[3 * pix + 1]; s->outbuffer[6 * pix + 2] = secondimage[3 * pix + 2]; s->outbuffer[6 * pix + 3] = firstimage[3 * pix]; s->outbuffer[6 * pix + 4] = firstimage[3 * pix + 1]; s->outbuffer[6 * pix + 5] = firstimage[3 * pix + 2]; } } else if (!strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY)) { for (pix = 0; pix < pixel_per_line / 2; pix++) { s->outbuffer[2 * pix] = secondimage[pix]; s->outbuffer[2 * pix + 1] = firstimage[pix]; } } else /* for lineart mode */ { maxpix = byte_per_line / 2; for (byte = 0; (int) byte < maxpix; byte++) { s->outbuffer[2 * byte] = primaryHigh[firstimage[byte]] | secondaryHigh[secondimage[byte]]; s->outbuffer[2 * byte + 1] = primaryLow[firstimage[byte]] | secondaryLow[secondimage[byte]]; #if 0 inmask = 128; outmask = 128; outbyte = 0; for (bit = 0; bit < 4; bit++) { if (inmask == (secondimage[byte] & inmask)) outbyte = outbyte | outmask; outmask = outmask >> 1; if (inmask == (firstimage[byte] & inmask)) outbyte = outbyte | outmask; outmask = outmask >> 1; inmask = inmask >> 1; } s->outbuffer[2 * byte] = outbyte; outmask = 128; outbyte = 0; for (bit = 0; bit < 4; bit++) { if (inmask == (secondimage[byte] & inmask)) outbyte = outbyte | outmask; outmask = outmask >> 1; if (inmask == (firstimage[byte] & inmask)) outbyte = outbyte | outmask; outmask = outmask >> 1; inmask = inmask >> 1; } s->outbuffer[2 * byte + 1] = outbyte; #endif } } s->buf_pos = 0; s->bytes_to_read -= nread; } if (max_len && s->buf_pos < s->buf_used) { ncopy = s->buf_used - s->buf_pos; if (ncopy > max_len) ncopy = max_len; memcpy (buf, &(s->outbuffer[s->buf_pos]), ncopy * 2); *len += ncopy; s->buf_pos += ncopy; } DBG (21, "<< read_fb1200\n"); return (SANE_STATUS_GOOD); } /**************************************************************************/ SANE_Status sane_read (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { CANON_Scanner *s = handle; SANE_Status status; if (s->hw->info.model == FB620 && s->params.format == SANE_FRAME_RGB) status = read_fb620 (handle, buf, max_len, len); else if (s->hw->info.model == FS2710) status = read_fs2710 (handle, buf, max_len, len); else if (s->hw->info.model == FB1200 && ((600 < s->val[OPT_X_RESOLUTION].w) || (600 < s->val[OPT_Y_RESOLUTION].w))) status = read_fb1200 (handle, buf, max_len, len); else status = sane_read_direct (handle, buf, max_len, len); if (s->time0 == -1) s->time0 = 0; else time (&(s->time0)); DBG (11, "sane_read: time0 = %ld\n", s->time0); s->switch_preview = s->val[OPT_PREVIEW].w; return (status); } /**************************************************************************/ void sane_cancel (SANE_Handle handle) { CANON_Scanner *s = handle; DBG (1, ">> sane_cancel\n"); /******** for FB1200S ************/ if(s->hw->info.model == FB1200) { if (s->tmpfile != -1) { close (s->tmpfile); DBG(1, " ****** tmpfile is closed ****** \n"); } else { DBG(1, "tmpfile is failed\n"); /* return (SANE_STATUS_INVAL);*/ } } /*********************************/ s->scanning = SANE_FALSE; DBG (1, "<< sane_cancel\n"); } /**************************************************************************/ SANE_Status 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"); return SANE_STATUS_UNSUPPORTED; } /**************************************************************************/ SANE_Status 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"); return SANE_STATUS_UNSUPPORTED; } /**************************************************************************/ sane-backends-1.0.29/backend/umax_pp.c0000666000000000000000000022410313615534521014407 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001-2012 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Umax PP flatbed scanners. */ /* CREDITS: Started by being a mere copy of mustek_pp by Jochen Eisinger then evolved in its own thing support for the 610P has been made possible thank to an hardware donation from William Stuart */ #include "../include/sane/config.h" #include #include #include #include #include #include #ifdef HAVE_UNISTD_H #include #endif #include #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #define DEBUG_NOT_STATIC #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #define BACKEND_NAME umax_pp #include "../include/sane/sanei_backend.h" #include "umax_pp_mid.h" #include "umax_pp.h" #ifdef DMALLOC #include "dmalloc.h" #endif #define UMAX_PP_CONFIG_FILE "umax_pp.conf" #define MIN(a,b) ((a) < (b) ? (a) : (b)) /* DEBUG * for debug output, set SANE_DEBUG_UMAX_PP to * 0 for nothing * 1 for errors * 2 for warnings * 3 for additional information * 4 for debug information * 5 for code flow protocol (there isn't any) * 129 if you want to know which parameters are unused */ #define UMAX_PP_BUILD 2301 #define UMAX_PP_STATE "release" static int num_devices = 0; static Umax_PP_Descriptor *devlist = NULL; static const SANE_Device **devarray = NULL; static Umax_PP_Device *first_dev = NULL; /* 2 Meg scan buffer */ static SANE_Word buf_size = 2048 * 1024; static SANE_Word red_gain = 0; static SANE_Word green_gain = 0; static SANE_Word blue_gain = 0; static SANE_Word red_offset = 0; static SANE_Word green_offset = 0; static SANE_Word blue_offset = 0; static SANE_Char scanner_vendor[128]=""; static SANE_Char scanner_name[128]=""; static SANE_Char scanner_model[128]=""; static SANE_Char astra[128]; static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, 0 }; static const SANE_Range u4_range = { 0, /* minimum */ 15, /* maximum */ 0 /* quantization */ }; static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; /* range for int value in [0-15] */ static const SANE_Range value16_range = { 0, /* minimum */ 15, /* maximum */ 1 /* quantization */ }; /* range for buffer size */ static const SANE_Range buffer_range = { 2048, /* minimum */ 4096 * 4096, /* maximum */ 1 /* quantization */ }; /* list of astra models */ static const SANE_String_Const astra_models[] = { "610", "1220", "1600", "2000", NULL }; #define UMAX_PP_CHANNEL_RED 0 #define UMAX_PP_CHANNEL_GREEN 1 #define UMAX_PP_CHANNEL_BLUE 2 #define UMAX_PP_CHANNEL_GRAY 1 #define UMAX_PP_STATE_SCANNING 2 #define UMAX_PP_STATE_CANCELLED 1 #define UMAX_PP_STATE_IDLE 0 #define UMAX_PP_MODE_LINEART 0 #define UMAX_PP_MODE_GRAYSCALE 1 #define UMAX_PP_MODE_COLOR 2 #define MM_TO_PIXEL(mm, res) (SANE_UNFIX(mm) * (float )res / MM_PER_INCH) #define PIXEL_TO_MM(px, res) (SANE_FIX((float )(px * MM_PER_INCH / (res / 10)) / 10.0)) #define UMAX_PP_DEFAULT_PORT "/dev/parport0" #define UMAX_PP_RESERVE 259200 /* * devname may be either an hardware address for direct I/O (0x378 for instance) * or the device name used by ppdev on linux systems (/dev/parport0 ) */ static SANE_Status umax_pp_attach (SANEI_Config * config, const char *devname) { Umax_PP_Descriptor *dev; int i; SANE_Status status = SANE_STATUS_GOOD; int ret, prt = 0, mdl; char model[32]; const char *name = NULL; const char *val; if (!devname || (strlen (devname) < 3)) return SANE_STATUS_INVAL; sanei_umax_pp_setastra (atoi((SANE_Char *) config->values[CFG_ASTRA])); /* if the name begins with a slash, it's a device, else it's an addr */ if ((devname[0] == '/')) { name = devname; } else { if ((devname[0] == '0') && ((devname[1] == 'x') || (devname[1] == 'X'))) prt = strtol (devname + 2, NULL, 16); else prt = atoi (devname); } for (i = 0; i < num_devices; i++) { if (devname[0] == '/') { if (strcmp (devlist[i].ppdevice, devname) == 0) return SANE_STATUS_GOOD; } else { if (strcmp (devlist[i].port, devname) == 0) return SANE_STATUS_GOOD; } } ret = sanei_umax_pp_attach (prt, name); switch (ret) { case UMAX1220P_OK: status = SANE_STATUS_GOOD; break; case UMAX1220P_BUSY: status = SANE_STATUS_DEVICE_BUSY; break; case UMAX1220P_TRANSPORT_FAILED: DBG (1, "umax_pp_attach: failed to init transport layer on %s\n", devname); status = SANE_STATUS_IO_ERROR; break; case UMAX1220P_PROBE_FAILED: DBG (1, "umax_pp_attach: failed to probe scanner on %s\n", devname); status = SANE_STATUS_IO_ERROR; break; } if (status != SANE_STATUS_GOOD) { DBG (2, "umax_pp_attach: couldn't attach to `%s' (%s)\n", devname, sane_strstatus (status)); DEBUG (); return status; } /* now look for the model */ do { ret = sanei_umax_pp_model (prt, &mdl); if (ret != UMAX1220P_OK) { DBG (1, "umax_pp_attach: waiting for busy scanner on %s\n", devname); } } while (ret == UMAX1220P_BUSY); if (ret != UMAX1220P_OK) { DBG (1, "umax_pp_attach: failed to recognize scanner model on %s\n", devname); return SANE_STATUS_IO_ERROR; } snprintf (model, sizeof(model), "Astra %dP", mdl); dev = malloc (sizeof (Umax_PP_Descriptor) * (num_devices + 1)); if (dev == NULL) { DBG (2, "umax_pp_attach: not enough memory for device descriptor\n"); DEBUG (); return SANE_STATUS_NO_MEM; } memset (dev, 0, sizeof (Umax_PP_Descriptor) * (num_devices + 1)); if (num_devices > 0) { memcpy (dev + 1, devlist, sizeof (Umax_PP_Descriptor) * (num_devices)); free (devlist); } devlist = dev; num_devices++; /* if there are user provided values, use them */ val=(const SANE_Char *) config->values[CFG_NAME]; if(strlen(val)==0) dev->sane.name = strdup (devname); else dev->sane.name = strdup (val); val=(const SANE_Char *) config->values[CFG_VENDOR]; if(strlen(val)==0) dev->sane.vendor = strdup ("UMAX"); else dev->sane.vendor = strdup (val); dev->sane.type = "flatbed scanner"; if (devname[0] == '/') dev->ppdevice = strdup (devname); else dev->port = strdup (devname); dev->buf_size = buf_size; if (mdl > 610) { /* Astra 1220, 1600 and 2000 */ dev->max_res = 1200; dev->ccd_res = 600; dev->max_h_size = 5100; dev->max_v_size = 7000 - 8; /* -8: workaround 'y overflow bug at 600 dpi' */ } else { /* Astra 610 */ dev->max_res = 600; dev->ccd_res = 300; dev->max_h_size = 2550; dev->max_v_size = 3500; } val=(const SANE_Char *) config->values[CFG_MODEL]; if(strlen(val)==0) dev->sane.model = strdup (model); else dev->sane.model = strdup (val); DBG (3, "umax_pp_attach: device %s attached\n", devname); return SANE_STATUS_GOOD; } /* * walk a port list and try to attach to them * */ static SANE_Int umax_pp_try_ports (SANEI_Config * config, char **ports) { int i; int rc = SANE_STATUS_INVAL; if (ports != NULL) { i = 0; rc = SANE_STATUS_INVAL; while (ports[i] != NULL) { if (rc != SANE_STATUS_GOOD) { DBG (3, "umax_pp_try_ports: trying port `%s'\n", ports[i]); rc = umax_pp_attach (config, ports[i]); if (rc != SANE_STATUS_GOOD) DBG (3, "umax_pp_try_ports: couldn't attach to port `%s'\n", ports[i]); else DBG (3, "umax_pp_try_ports: attach to port `%s' successful\n", ports[i]); } free (ports[i]); i++; } free (ports); } return rc; } /* * attempt to auto detect right parallel port * if safe set to SANE_TRUE, no direct hardware access * is tried */ static SANE_Int umax_pp_auto_attach (SANEI_Config * config, SANE_Int safe) { char **ports; int rc = SANE_STATUS_INVAL; /* safe tests: user parallel port devices */ ports = sanei_parport_find_device (); if (ports != NULL) rc = umax_pp_try_ports (config, ports); /* try for direct hardware access */ if ((safe != SANE_TRUE) && (rc != SANE_STATUS_GOOD)) { ports = sanei_parport_find_port (); if (ports != NULL) rc = umax_pp_try_ports (config, ports); } return rc; } /** callback use by sanei_configure_attach, it is called with the * device name to use for attach try. */ static SANE_Status umax_pp_configure_attach (SANEI_Config * config, const char *devname) { const char *lp; SANE_Char *token; SANE_Status status = SANE_STATUS_INVAL; /* check for mandatory 'port' token */ lp = sanei_config_get_string (devname, &token); if (strncmp (token, "port", 4) != 0) { DBG (3, "umax_pp_configure_attach: invalid port line `%s'\n", devname); free (token); return SANE_STATUS_INVAL; } free (token); /* get argument */ lp = sanei_config_get_string (lp, &token); /* if "safe-auto" or "auto" devname, use umax_pp_attach_auto */ if (strncmp (token, "safe-auto", 9) == 0) { status = umax_pp_auto_attach (config, SANE_TRUE); } else if (strncmp (token, "auto", 4) == 0) { status = umax_pp_auto_attach (config, SANE_FALSE); } else { status = umax_pp_attach (config, token); } free (token); return status; } static SANE_Int umax_pp_get_sync (SANE_Int dpi) { /* delta between color frames */ if (sanei_umax_pp_getastra () > 610) { switch (dpi) { case 1200: return 8; case 600: return 4; case 300: return 2; case 150: return 1; default: return 0; } } else { switch (dpi) { case 600: return 16; case 300: return 8; /* 8 double-checked */ case 150: /* wrong: 2, 3, 5 * double-checked : 4 */ return 4; default: return 2; /* 2 double-checked */ } } } static SANE_Status init_options (Umax_PP_Device * dev) { int i; /* sets initial option value to zero */ memset (dev->opt, 0, sizeof (dev->opt)); memset (dev->val, 0, sizeof (dev->val)); for (i = 0; i < NUM_OPTIONS; ++i) { dev->opt[i].size = sizeof (SANE_Word); dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } dev->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; dev->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ dev->opt[OPT_MODE_GROUP].title = SANE_TITLE_SCAN_MODE; dev->opt[OPT_MODE_GROUP].name = ""; dev->opt[OPT_MODE_GROUP].desc = ""; dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_MODE_GROUP].size = 0; dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ 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].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_MODE].size = 10; dev->opt[OPT_MODE].constraint.string_list = mode_list; dev->val[OPT_MODE].s = strdup (mode_list[1]); /* resolution */ 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_FIXED; dev->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_RESOLUTION].constraint.range = &dev->dpi_range; dev->val[OPT_RESOLUTION].w = dev->dpi_range.min; /* preview */ dev->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; dev->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; dev->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; dev->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; dev->opt[OPT_PREVIEW].size = sizeof (SANE_Word); dev->opt[OPT_PREVIEW].unit = SANE_UNIT_NONE; dev->val[OPT_PREVIEW].w = SANE_FALSE; /* gray preview */ dev->opt[OPT_GRAY_PREVIEW].name = SANE_NAME_GRAY_PREVIEW; dev->opt[OPT_GRAY_PREVIEW].title = SANE_TITLE_GRAY_PREVIEW; dev->opt[OPT_GRAY_PREVIEW].desc = SANE_DESC_GRAY_PREVIEW; dev->opt[OPT_GRAY_PREVIEW].type = SANE_TYPE_BOOL; dev->opt[OPT_GRAY_PREVIEW].size = sizeof (SANE_Word); dev->opt[OPT_GRAY_PREVIEW].unit = SANE_UNIT_NONE; dev->val[OPT_GRAY_PREVIEW].w = SANE_FALSE; /* "Geometry" group: */ dev->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); dev->opt[OPT_GEOMETRY_GROUP].desc = ""; dev->opt[OPT_GEOMETRY_GROUP].name = ""; dev->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_GEOMETRY_GROUP].size = 0; dev->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ dev->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; dev->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; dev->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; dev->opt[OPT_TL_X].type = SANE_TYPE_INT; dev->opt[OPT_TL_X].unit = SANE_UNIT_PIXEL; dev->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_X].constraint.range = &dev->x_range; dev->val[OPT_TL_X].w = 0; /* top-left y */ dev->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; dev->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; dev->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; dev->opt[OPT_TL_Y].type = SANE_TYPE_INT; dev->opt[OPT_TL_Y].unit = SANE_UNIT_PIXEL; dev->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_Y].constraint.range = &dev->y_range; dev->val[OPT_TL_Y].w = 0; /* bottom-right x */ dev->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; dev->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; dev->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; dev->opt[OPT_BR_X].type = SANE_TYPE_INT; dev->opt[OPT_BR_X].unit = SANE_UNIT_PIXEL; dev->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_X].constraint.range = &dev->x_range; dev->val[OPT_BR_X].w = dev->x_range.max; /* bottom-right y */ dev->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; dev->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; dev->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; dev->opt[OPT_BR_Y].type = SANE_TYPE_INT; dev->opt[OPT_BR_Y].unit = SANE_UNIT_PIXEL; dev->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_Y].constraint.range = &dev->y_range; dev->val[OPT_BR_Y].w = dev->y_range.max; /* "Enhancement" group: */ dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); dev->opt[OPT_ENHANCEMENT_GROUP].desc = ""; dev->opt[OPT_ENHANCEMENT_GROUP].name = ""; dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_ENHANCEMENT_GROUP].size = 0; dev->opt[OPT_ENHANCEMENT_GROUP].cap |= SANE_CAP_ADVANCED; dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* lamp control */ dev->opt[OPT_LAMP_CONTROL].name = "lamp-control"; dev->opt[OPT_LAMP_CONTROL].title = SANE_I18N ("Lamp on"); dev->opt[OPT_LAMP_CONTROL].desc = SANE_I18N ("Sets lamp on/off"); dev->opt[OPT_LAMP_CONTROL].type = SANE_TYPE_BOOL; dev->opt[OPT_LAMP_CONTROL].size = sizeof (SANE_Word); dev->opt[OPT_LAMP_CONTROL].unit = SANE_UNIT_NONE; dev->val[OPT_LAMP_CONTROL].w = SANE_TRUE; dev->opt[OPT_LAMP_CONTROL].cap |= SANE_CAP_ADVANCED; /* UTA control */ dev->opt[OPT_UTA_CONTROL].name = "UTA-control"; dev->opt[OPT_UTA_CONTROL].title = SANE_I18N ("UTA on"); dev->opt[OPT_UTA_CONTROL].desc = SANE_I18N ("Sets UTA on/off"); dev->opt[OPT_UTA_CONTROL].type = SANE_TYPE_BOOL; dev->opt[OPT_UTA_CONTROL].size = sizeof (SANE_Word); dev->opt[OPT_UTA_CONTROL].unit = SANE_UNIT_NONE; dev->val[OPT_UTA_CONTROL].w = SANE_TRUE; dev->opt[OPT_UTA_CONTROL].cap |= SANE_CAP_ADVANCED | SANE_CAP_INACTIVE; /* custom-gamma table */ dev->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_ADVANCED; dev->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* grayscale gamma vector */ dev->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR].size = 256 * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR].constraint.range = &u8_range; dev->val[OPT_GAMMA_VECTOR].wa = &dev->gamma_table[0][0]; /* red gamma vector */ dev->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_R].size = 256 * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_R].constraint.range = &u8_range; dev->val[OPT_GAMMA_VECTOR_R].wa = &dev->gamma_table[1][0]; /* green gamma vector */ dev->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_G].size = 256 * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_G].constraint.range = &u8_range; dev->val[OPT_GAMMA_VECTOR_G].wa = &dev->gamma_table[2][0]; /* blue gamma vector */ dev->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_B].size = 256 * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_B].constraint.range = &u8_range; dev->val[OPT_GAMMA_VECTOR_B].wa = &dev->gamma_table[3][0]; /* gain group */ dev->opt[OPT_MANUAL_GAIN].name = "manual-channel-gain"; dev->opt[OPT_MANUAL_GAIN].title = SANE_I18N ("Gain"); dev->opt[OPT_MANUAL_GAIN].desc = SANE_I18N ("Color channels gain settings"); dev->opt[OPT_MANUAL_GAIN].type = SANE_TYPE_BOOL; dev->opt[OPT_MANUAL_GAIN].cap |= SANE_CAP_ADVANCED; dev->val[OPT_MANUAL_GAIN].w = SANE_FALSE; /* gray gain */ dev->opt[OPT_GRAY_GAIN].name = "gray-gain"; dev->opt[OPT_GRAY_GAIN].title = SANE_I18N ("Gray gain"); dev->opt[OPT_GRAY_GAIN].desc = SANE_I18N ("Sets gray channel gain"); dev->opt[OPT_GRAY_GAIN].type = SANE_TYPE_INT; dev->opt[OPT_GRAY_GAIN].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_GRAY_GAIN].unit = SANE_UNIT_NONE; dev->opt[OPT_GRAY_GAIN].size = sizeof (SANE_Int); dev->opt[OPT_GRAY_GAIN].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GRAY_GAIN].constraint.range = &u4_range; dev->val[OPT_GRAY_GAIN].w = dev->gray_gain; /* red gain */ dev->opt[OPT_RED_GAIN].name = "red-gain"; dev->opt[OPT_RED_GAIN].title = SANE_I18N ("Red gain"); dev->opt[OPT_RED_GAIN].desc = SANE_I18N ("Sets red channel gain"); dev->opt[OPT_RED_GAIN].type = SANE_TYPE_INT; dev->opt[OPT_RED_GAIN].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_RED_GAIN].unit = SANE_UNIT_NONE; dev->opt[OPT_RED_GAIN].size = sizeof (SANE_Int); dev->opt[OPT_RED_GAIN].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_RED_GAIN].constraint.range = &u4_range; dev->val[OPT_RED_GAIN].w = dev->red_gain; /* green gain */ dev->opt[OPT_GREEN_GAIN].name = "green-gain"; dev->opt[OPT_GREEN_GAIN].title = SANE_I18N ("Green gain"); dev->opt[OPT_GREEN_GAIN].desc = SANE_I18N ("Sets green channel gain"); dev->opt[OPT_GREEN_GAIN].type = SANE_TYPE_INT; dev->opt[OPT_GREEN_GAIN].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_GREEN_GAIN].unit = SANE_UNIT_NONE; dev->opt[OPT_GREEN_GAIN].size = sizeof (SANE_Int); dev->opt[OPT_GREEN_GAIN].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GREEN_GAIN].constraint.range = &u4_range; dev->val[OPT_GREEN_GAIN].w = dev->green_gain; /* blue gain */ dev->opt[OPT_BLUE_GAIN].name = "blue-gain"; dev->opt[OPT_BLUE_GAIN].title = SANE_I18N ("Blue gain"); dev->opt[OPT_BLUE_GAIN].desc = SANE_I18N ("Sets blue channel gain"); dev->opt[OPT_BLUE_GAIN].type = SANE_TYPE_INT; dev->opt[OPT_BLUE_GAIN].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_BLUE_GAIN].unit = SANE_UNIT_NONE; dev->opt[OPT_BLUE_GAIN].size = sizeof (SANE_Int); dev->opt[OPT_BLUE_GAIN].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BLUE_GAIN].constraint.range = &u4_range; dev->val[OPT_BLUE_GAIN].w = dev->blue_gain; /* offset group */ dev->opt[OPT_MANUAL_OFFSET].name = "manual-offset"; dev->opt[OPT_MANUAL_OFFSET].title = SANE_I18N ("Offset"); dev->opt[OPT_MANUAL_OFFSET].desc = SANE_I18N ("Color channels offset settings"); dev->opt[OPT_MANUAL_OFFSET].type = SANE_TYPE_BOOL; dev->opt[OPT_MANUAL_OFFSET].cap |= SANE_CAP_ADVANCED; dev->val[OPT_MANUAL_OFFSET].w = SANE_FALSE; /* gray offset */ dev->opt[OPT_GRAY_OFFSET].name = "gray-offset"; dev->opt[OPT_GRAY_OFFSET].title = SANE_I18N ("Gray offset"); dev->opt[OPT_GRAY_OFFSET].desc = SANE_I18N ("Sets gray channel offset"); dev->opt[OPT_GRAY_OFFSET].type = SANE_TYPE_INT; dev->opt[OPT_GRAY_OFFSET].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_GRAY_OFFSET].unit = SANE_UNIT_NONE; dev->opt[OPT_GRAY_OFFSET].size = sizeof (SANE_Int); dev->opt[OPT_GRAY_OFFSET].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GRAY_OFFSET].constraint.range = &u4_range; dev->val[OPT_GRAY_OFFSET].w = dev->gray_offset; /* red offset */ dev->opt[OPT_RED_OFFSET].name = "red-offset"; dev->opt[OPT_RED_OFFSET].title = SANE_I18N ("Red offset"); dev->opt[OPT_RED_OFFSET].desc = SANE_I18N ("Sets red channel offset"); dev->opt[OPT_RED_OFFSET].type = SANE_TYPE_INT; dev->opt[OPT_RED_OFFSET].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_RED_OFFSET].unit = SANE_UNIT_NONE; dev->opt[OPT_RED_OFFSET].size = sizeof (SANE_Int); dev->opt[OPT_RED_OFFSET].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_RED_OFFSET].constraint.range = &u4_range; dev->val[OPT_RED_OFFSET].w = dev->red_offset; /* green offset */ dev->opt[OPT_GREEN_OFFSET].name = "green-offset"; dev->opt[OPT_GREEN_OFFSET].title = SANE_I18N ("Green offset"); dev->opt[OPT_GREEN_OFFSET].desc = SANE_I18N ("Sets green channel offset"); dev->opt[OPT_GREEN_OFFSET].type = SANE_TYPE_INT; dev->opt[OPT_GREEN_OFFSET].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_GREEN_OFFSET].unit = SANE_UNIT_NONE; dev->opt[OPT_GREEN_OFFSET].size = sizeof (SANE_Int); dev->opt[OPT_GREEN_OFFSET].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GREEN_OFFSET].constraint.range = &u4_range; dev->val[OPT_GREEN_OFFSET].w = dev->green_offset; /* blue offset */ dev->opt[OPT_BLUE_OFFSET].name = "blue-offset"; dev->opt[OPT_BLUE_OFFSET].title = SANE_I18N ("Blue offset"); dev->opt[OPT_BLUE_OFFSET].desc = SANE_I18N ("Sets blue channel offset"); dev->opt[OPT_BLUE_OFFSET].type = SANE_TYPE_INT; dev->opt[OPT_BLUE_OFFSET].cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; dev->opt[OPT_BLUE_OFFSET].unit = SANE_UNIT_NONE; dev->opt[OPT_BLUE_OFFSET].size = sizeof (SANE_Int); dev->opt[OPT_BLUE_OFFSET].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BLUE_OFFSET].constraint.range = &u4_range; dev->val[OPT_BLUE_OFFSET].w = dev->blue_offset; return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { SANE_Status status; SANEI_Config config; SANE_Option_Descriptor *options[NUM_CFG_OPTIONS]; void *values[NUM_CFG_OPTIONS]; int i = 0; DBG_INIT (); if (authorize != NULL) { DBG (2, "init: SANE_Auth_Callback not supported ...\n"); } if (version_code != NULL) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, UMAX_PP_BUILD); DBG (3, "init: SANE v%s, backend v%d.%d.%d-%s\n", VERSION, SANE_CURRENT_MAJOR, V_MINOR, UMAX_PP_BUILD, UMAX_PP_STATE); /* set up configuration options to parse */ options[CFG_BUFFER] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_BUFFER]->name = "buffer"; options[CFG_BUFFER]->type = SANE_TYPE_INT; options[CFG_BUFFER]->unit = SANE_UNIT_NONE; options[CFG_BUFFER]->size = sizeof (SANE_Word); options[CFG_BUFFER]->cap = SANE_CAP_SOFT_SELECT; options[CFG_BUFFER]->constraint_type = SANE_CONSTRAINT_RANGE; options[CFG_BUFFER]->constraint.range = &buffer_range; values[CFG_BUFFER] = &buf_size; options[CFG_RED_GAIN] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_RED_GAIN]->name = "red-gain"; options[CFG_RED_GAIN]->type = SANE_TYPE_INT; options[CFG_RED_GAIN]->unit = SANE_UNIT_NONE; options[CFG_RED_GAIN]->size = sizeof (SANE_Word); options[CFG_RED_GAIN]->cap = SANE_CAP_SOFT_SELECT; options[CFG_RED_GAIN]->constraint_type = SANE_CONSTRAINT_RANGE; options[CFG_RED_GAIN]->constraint.range = &value16_range; values[CFG_RED_GAIN] = &red_gain; options[CFG_GREEN_GAIN] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_GREEN_GAIN]->name = "green-gain"; options[CFG_GREEN_GAIN]->type = SANE_TYPE_INT; options[CFG_GREEN_GAIN]->unit = SANE_UNIT_NONE; options[CFG_GREEN_GAIN]->size = sizeof (SANE_Word); options[CFG_GREEN_GAIN]->cap = SANE_CAP_SOFT_SELECT; options[CFG_GREEN_GAIN]->constraint_type = SANE_CONSTRAINT_RANGE; options[CFG_GREEN_GAIN]->constraint.range = &value16_range; values[CFG_GREEN_GAIN] = &green_gain; options[CFG_BLUE_GAIN] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_BLUE_GAIN]->name = "blue-gain"; options[CFG_BLUE_GAIN]->type = SANE_TYPE_INT; options[CFG_BLUE_GAIN]->unit = SANE_UNIT_NONE; options[CFG_BLUE_GAIN]->size = sizeof (SANE_Word); options[CFG_BLUE_GAIN]->cap = SANE_CAP_SOFT_SELECT; options[CFG_BLUE_GAIN]->constraint_type = SANE_CONSTRAINT_RANGE; options[CFG_BLUE_GAIN]->constraint.range = &value16_range; values[CFG_BLUE_GAIN] = &blue_gain; options[CFG_RED_OFFSET] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_RED_OFFSET]->name = "red-offset"; options[CFG_RED_OFFSET]->type = SANE_TYPE_INT; options[CFG_RED_OFFSET]->unit = SANE_UNIT_NONE; options[CFG_RED_OFFSET]->size = sizeof (SANE_Word); options[CFG_RED_OFFSET]->cap = SANE_CAP_SOFT_SELECT; options[CFG_RED_OFFSET]->constraint_type = SANE_CONSTRAINT_RANGE; options[CFG_RED_OFFSET]->constraint.range = &value16_range; values[CFG_RED_OFFSET] = &red_offset; options[CFG_GREEN_OFFSET] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_GREEN_OFFSET]->name = "green-offset"; options[CFG_GREEN_OFFSET]->type = SANE_TYPE_INT; options[CFG_GREEN_OFFSET]->unit = SANE_UNIT_NONE; options[CFG_GREEN_OFFSET]->size = sizeof (SANE_Word); options[CFG_GREEN_OFFSET]->cap = SANE_CAP_SOFT_SELECT; options[CFG_GREEN_OFFSET]->constraint_type = SANE_CONSTRAINT_RANGE; options[CFG_GREEN_OFFSET]->constraint.range = &value16_range; values[CFG_GREEN_OFFSET] = &green_offset; options[CFG_BLUE_OFFSET] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_BLUE_OFFSET]->name = "blue-offset"; options[CFG_BLUE_OFFSET]->type = SANE_TYPE_INT; options[CFG_BLUE_OFFSET]->unit = SANE_UNIT_NONE; options[CFG_BLUE_OFFSET]->size = sizeof (SANE_Word); options[CFG_BLUE_OFFSET]->cap = SANE_CAP_SOFT_SELECT; options[CFG_BLUE_OFFSET]->constraint_type = SANE_CONSTRAINT_RANGE; options[CFG_BLUE_OFFSET]->constraint.range = &value16_range; values[CFG_BLUE_OFFSET] = &blue_offset; options[CFG_VENDOR] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_VENDOR]->name = "vendor"; options[CFG_VENDOR]->type = SANE_TYPE_STRING; options[CFG_VENDOR]->unit = SANE_UNIT_NONE; options[CFG_VENDOR]->size = 128; options[CFG_VENDOR]->cap = SANE_CAP_SOFT_SELECT; values[CFG_VENDOR] = scanner_vendor; options[CFG_NAME] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_NAME]->name = "name"; options[CFG_NAME]->type = SANE_TYPE_STRING; options[CFG_NAME]->unit = SANE_UNIT_NONE; options[CFG_NAME]->size = 128; options[CFG_NAME]->cap = SANE_CAP_SOFT_SELECT; values[CFG_NAME] = scanner_name; options[CFG_MODEL] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_MODEL]->name = "model"; options[CFG_MODEL]->type = SANE_TYPE_STRING; options[CFG_MODEL]->unit = SANE_UNIT_NONE; options[CFG_MODEL]->size = 128; options[CFG_MODEL]->cap = SANE_CAP_SOFT_SELECT; values[CFG_MODEL] = scanner_model; options[CFG_ASTRA] = (SANE_Option_Descriptor *) malloc (sizeof (SANE_Option_Descriptor)); options[CFG_ASTRA]->name = "astra"; options[CFG_ASTRA]->type = SANE_TYPE_STRING; options[CFG_ASTRA]->unit = SANE_UNIT_NONE; options[CFG_ASTRA]->size = 128; options[CFG_ASTRA]->cap = SANE_CAP_SOFT_SELECT; options[CFG_ASTRA]->constraint_type = SANE_CONSTRAINT_STRING_LIST; options[CFG_ASTRA]->constraint.string_list = astra_models; values[CFG_ASTRA] = astra; config.descriptors = options; config.values = values; config.count = NUM_CFG_OPTIONS; /* generic configure and attach function */ status = sanei_configure_attach (UMAX_PP_CONFIG_FILE, &config, umax_pp_configure_attach); /* free option descriptors */ for (i = 0; i < NUM_CFG_OPTIONS; i++) { free (options[i]); } return status; } void sane_exit (void) { int i; Umax_PP_Device *dev; DBG (3, "sane_exit: (...)\n"); if (first_dev) DBG (3, "exit: closing open devices\n"); while (first_dev) { dev = first_dev; sane_close (dev); } for (i = 0; i < num_devices; i++) { free (devlist[i].port); free ((void *) devlist[i].sane.name); free ((void *) devlist[i].sane.model); free ((void *) devlist[i].sane.vendor); } if (devlist != NULL) { free (devlist); devlist = NULL; } if (devarray != NULL) { free (devarray); devarray = NULL; } /* reset values */ num_devices = 0; first_dev = NULL; red_gain = 0; green_gain = 0; blue_gain = 0; red_offset = 0; green_offset = 0; blue_offset = 0; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { int i; DBG (3, "get_devices\n"); DBG (129, "unused arg: local_only = %d\n", (int) local_only); if (devarray != NULL) { free (devarray); devarray = NULL; } devarray = malloc ((num_devices + 1) * sizeof (devarray[0])); if (devarray == NULL) { DBG (2, "get_devices: not enough memory for device list\n"); DEBUG (); return SANE_STATUS_NO_MEM; } for (i = 0; i < num_devices; i++) devarray[i] = &devlist[i].sane; devarray[num_devices] = NULL; *device_list = devarray; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Umax_PP_Device *dev; Umax_PP_Descriptor *desc; int i, j; int rc, prt = 0; char *name = NULL; DBG (3, "open: device `%s'\n", devicename); /* if no device given or 'umax_pp' default value given */ if (devicename == NULL || devicename[0] == 0 || strncmp (devicename, "umax_pp", 7) == 0) { if (num_devices == 0) { DBG (1, "open: no devices present\n"); return SANE_STATUS_INVAL; } DBG (3, "open: trying default device %s, port=%s,ppdev=%s\n", devlist[0].sane.name, devlist[0].port, devlist[0].ppdevice); if (devlist[0].port != NULL) { if ((devlist[0].port[0] == '0') && ((devlist[0].port[1] == 'x') || (devlist[0].port[1] == 'X'))) prt = strtol (devlist[0].port + 2, NULL, 16); else prt = atoi (devlist[0].port); rc = sanei_umax_pp_open (prt, NULL); } else { rc = sanei_umax_pp_open (0, devlist[0].ppdevice); } desc = &devlist[0]; } else /* specific value */ { for (i = 0; i < num_devices; i++) if (strcmp (devlist[i].sane.name, devicename) == 0) break; if (i >= num_devices) for (i = 0; i < num_devices; i++) if (strcmp (devlist[i].port, devicename) == 0) break; if (i >= num_devices) { DBG (2, "open: device doesn't exist\n"); DEBUG (); return SANE_STATUS_INVAL; } desc = &devlist[i]; if (devlist[i].ppdevice != NULL) { if (devlist[i].ppdevice[0] == '/') { name = devlist[i].ppdevice; } } else { if ((devlist[i].port[0] == '0') && ((devlist[i].port[1] == 'x') || (devlist[i].port[1] == 'X'))) prt = strtol (devlist[i].port + 2, NULL, 16); else prt = atoi (devlist[i].port); DBG (64, "open: devlist[i].port='%s' -> port=0x%X\n", devlist[i].port, prt); } rc = sanei_umax_pp_open (prt, name); } /* treat return code from open */ switch (rc) { case UMAX1220P_TRANSPORT_FAILED: if (name == NULL) { DBG (1, "failed to init transport layer on port 0x%03X\n", prt); } else { DBG (1, "failed to init transport layer on device %s\n", name); } return SANE_STATUS_IO_ERROR; case UMAX1220P_SCANNER_FAILED: if (name == NULL) { DBG (1, "failed to initialize scanner on port 0x%03X\n", prt); } else { DBG (1, "failed to initialize scanner on device %s\n", name); } return SANE_STATUS_IO_ERROR; case UMAX1220P_BUSY: if (name == NULL) { DBG (1, "busy scanner on port 0x%03X\n", prt); } else { DBG (1, "busy scanner on device %s\n", name); } return SANE_STATUS_DEVICE_BUSY; } dev = (Umax_PP_Device *) malloc (sizeof (*dev)); if (dev == NULL) { DBG (2, "open: not enough memory for device descriptor\n"); DEBUG (); return SANE_STATUS_NO_MEM; } memset (dev, 0, sizeof (*dev)); dev->desc = desc; for (i = 0; i < 4; ++i) for (j = 0; j < 256; ++j) dev->gamma_table[i][j] = j; /* the extra amount of UMAX_PP_RESERVE bytes is to handle */ /* the data needed to resync the color frames */ dev->buf = malloc (dev->desc->buf_size + UMAX_PP_RESERVE); dev->bufsize = dev->desc->buf_size; dev->dpi_range.min = SANE_FIX (75); dev->dpi_range.max = SANE_FIX (dev->desc->max_res); dev->dpi_range.quant = 0; dev->x_range.min = 0; dev->x_range.max = dev->desc->max_h_size; dev->x_range.quant = 0; dev->y_range.min = 0; dev->y_range.max = dev->desc->max_v_size; dev->y_range.quant = 0; dev->gray_gain = 0; /* use pre defined settings read from umax_pp.conf */ dev->red_gain = red_gain; dev->green_gain = green_gain; dev->blue_gain = blue_gain; dev->red_offset = red_offset; dev->green_offset = green_offset; dev->blue_offset = blue_offset; if (dev->buf == NULL) { DBG (2, "open: not enough memory for scan buffer (%lu bytes)\n", (long int) dev->desc->buf_size); DEBUG (); free (dev); return SANE_STATUS_NO_MEM; } init_options (dev); dev->next = first_dev; first_dev = dev; if (sanei_umax_pp_UTA () == 1) dev->opt[OPT_UTA_CONTROL].cap &= ~SANE_CAP_INACTIVE; *handle = dev; DBG (3, "open: success\n"); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Umax_PP_Device *prev, *dev; int rc; DBG (3, "sane_close: ...\n"); /* remove handle from list of open handles: */ prev = NULL; for (dev = first_dev; dev; dev = dev->next) { if (dev == handle) break; prev = dev; } if (dev == NULL) { DBG (2, "close: unknown device\n"); DEBUG (); return; /* oops, not a handle we know about */ } if (dev->state == UMAX_PP_STATE_SCANNING) sane_cancel (handle); /* remember: sane_cancel is a macro and expands to sane_umax_pp_cancel ()... */ /* if the scanner is parking head, we wait it to finish */ while (dev->state == UMAX_PP_STATE_CANCELLED) { DBG (2, "close: waiting scanner to park head\n"); rc = sanei_umax_pp_status (); /* check if scanner busy parking */ if (rc != UMAX1220P_BUSY) { DBG (2, "close: scanner head parked\n"); dev->state = UMAX_PP_STATE_IDLE; } } /* then we switch off gain if needed */ if (dev->val[OPT_LAMP_CONTROL].w == SANE_TRUE) { rc = sanei_umax_pp_lamp (0); if (rc == UMAX1220P_TRANSPORT_FAILED) { DBG (1, "close: switch off gain failed (ignored....)\n"); } } sanei_umax_pp_close (); if (prev != NULL) prev->next = dev->next; else first_dev = dev->next; free (dev->buf); DBG (3, "close: device closed\n"); free (handle); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Umax_PP_Device *dev = handle; if ((unsigned) option >= NUM_OPTIONS) { DBG (2, "get_option_descriptor: option %d doesn't exist\n", option); DEBUG (); return NULL; } DBG (6, "get_option_descriptor: requested option %d (%s)\n", option, dev->opt[option].name); return dev->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Umax_PP_Device *dev = handle; SANE_Status status; SANE_Word w, cap, tmpw; int dpi, rc; DBG (6, "control_option: option %d, action %d\n", option, action); if (info) *info = 0; if (dev->state == UMAX_PP_STATE_SCANNING) { DBG (2, "control_option: device is scanning\n"); return SANE_STATUS_DEVICE_BUSY; } if ((unsigned int) option >= NUM_OPTIONS) { DBG (2, "control_option: option doesn't exist\n"); return SANE_STATUS_INVAL; } cap = dev->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { DBG (2, "control_option: option isn't active\n"); return SANE_STATUS_INVAL; } DBG (6, "control_option: option <%s>, action ... %d\n", dev->opt[option].name, action); if (action == SANE_ACTION_GET_VALUE) { DBG (6, " get value\n"); switch (option) { /* word options: */ case OPT_PREVIEW: case OPT_GRAY_PREVIEW: case OPT_LAMP_CONTROL: case OPT_UTA_CONTROL: case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_CUSTOM_GAMMA: case OPT_MANUAL_GAIN: case OPT_GRAY_GAIN: case OPT_GREEN_GAIN: case OPT_RED_GAIN: case OPT_BLUE_GAIN: case OPT_MANUAL_OFFSET: case OPT_GRAY_OFFSET: case OPT_GREEN_OFFSET: case OPT_RED_OFFSET: case OPT_BLUE_OFFSET: *(SANE_Word *) val = dev->val[option].w; return SANE_STATUS_GOOD; /* word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (val, dev->val[option].wa, dev->opt[option].size); return SANE_STATUS_GOOD; /* string options: */ case OPT_MODE: strcpy (val, dev->val[option].s); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { DBG (6, " set value\n"); if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (2, "control_option: option can't be set\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (dev->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (2, "control_option: constrain_value failed (%s)\n", sane_strstatus (status)); return status; } if (option == OPT_RESOLUTION) { DBG (16, "control_option: setting resolution to %d\n", *(SANE_Int *) val); } if (option == OPT_PREVIEW) { DBG (16, "control_option: setting preview to %d\n", *(SANE_Word *) val); } switch (option) { /* (mostly) side-effect-free word options: */ case OPT_PREVIEW: case OPT_GRAY_PREVIEW: case OPT_TL_Y: case OPT_BR_Y: if (info) *info |= SANE_INFO_RELOAD_PARAMS; // fall through case OPT_GRAY_GAIN: case OPT_GREEN_GAIN: case OPT_RED_GAIN: case OPT_BLUE_GAIN: case OPT_GRAY_OFFSET: case OPT_GREEN_OFFSET: case OPT_RED_OFFSET: case OPT_BLUE_OFFSET: dev->val[option].w = *(SANE_Word *) val; /* sanity check */ if (dev->val[OPT_BR_Y].w < dev->val[OPT_TL_Y].w) { tmpw = dev->val[OPT_BR_Y].w; dev->val[OPT_BR_Y].w = dev->val[OPT_TL_Y].w; dev->val[OPT_TL_Y].w = tmpw; if (info) *info |= SANE_INFO_INEXACT; DBG (16, "control_option: swapping Y coordinates\n"); } if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dpi = (int) (SANE_UNFIX (dev->val[OPT_RESOLUTION].w)); if (dev->val[OPT_TL_Y].w < 2 * umax_pp_get_sync (dpi)) { DBG (16, "control_option: correcting TL_Y coordinates\n"); dev->val[OPT_TL_Y].w = 2 * umax_pp_get_sync (dpi); if (info) *info |= SANE_INFO_INEXACT; } } return SANE_STATUS_GOOD; /* side-effect-free word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (dev->val[option].wa, val, dev->opt[option].size); return SANE_STATUS_GOOD; /* options with side-effects: */ case OPT_UTA_CONTROL: dev->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; case OPT_LAMP_CONTROL: if (dev->state != UMAX_PP_STATE_IDLE) { rc = sanei_umax_pp_status (); /* check if scanner busy parking */ if (rc == UMAX1220P_BUSY) { DBG (2, "control_option: scanner busy\n"); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_DEVICE_BUSY; } dev->state = UMAX_PP_STATE_IDLE; } dev->val[option].w = *(SANE_Word *) val; if (dev->val[option].w == SANE_TRUE) rc = sanei_umax_pp_lamp (1); else rc = sanei_umax_pp_lamp (0); if (rc == UMAX1220P_TRANSPORT_FAILED) return SANE_STATUS_IO_ERROR; return SANE_STATUS_GOOD; case OPT_TL_X: case OPT_BR_X: if (info) *info |= SANE_INFO_RELOAD_PARAMS; dpi = (int) (SANE_UNFIX (dev->val[OPT_RESOLUTION].w)); dev->val[option].w = *(SANE_Word *) val; /* coords rounded to allow 32 bit IO/transfer */ /* at high resolution */ if (dpi >= 600) { if (dev->val[option].w & 0x03) { if (info) *info |= SANE_INFO_INEXACT; dev->val[option].w = dev->val[option].w & 0xFFFC; *(SANE_Word *) val = dev->val[option].w; DBG (16, "control_option: rounding X to %d\n", *(SANE_Word *) val); } } /* sanity check */ if (dev->val[OPT_BR_X].w < dev->val[OPT_TL_X].w) { tmpw = dev->val[OPT_BR_X].w; dev->val[OPT_BR_X].w = dev->val[OPT_TL_X].w; dev->val[OPT_TL_X].w = tmpw; if (info) *info |= SANE_INFO_INEXACT; DBG (16, "control_option: swapping X coordinates\n"); } return SANE_STATUS_GOOD; case OPT_RESOLUTION: if (info) *info |= SANE_INFO_RELOAD_PARAMS; /* resolution : only have 75, 150, 300, 600 and 1200 */ dpi = (int) (SANE_UNFIX (*(SANE_Word *) val)); if ((dpi != 75) && (dpi != 150) && (dpi != 300) && (dpi != 600) && (dpi != 1200)) { if (dpi <= 75) dpi = 75; else if (dpi <= 150) dpi = 150; else if (dpi <= 300) dpi = 300; else if (dpi <= 600) dpi = 600; else dpi = 1200; if (info) *info |= SANE_INFO_INEXACT; *(SANE_Word *) val = SANE_FIX ((SANE_Word) dpi); } dev->val[option].w = *(SANE_Word *) val; /* correct top x and bottom x if needed */ if (dpi >= 600) { dev->val[OPT_TL_X].w = dev->val[OPT_TL_X].w & 0xFFFC; dev->val[OPT_BR_X].w = dev->val[OPT_BR_X].w & 0xFFFC; } /* corrects top y for offset */ if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) { if (dev->val[OPT_TL_Y].w < 2 * umax_pp_get_sync (dpi)) { DBG (16, "control_option: correcting TL_Y coordinates\n"); dev->val[OPT_TL_Y].w = 2 * umax_pp_get_sync (dpi); if (info) *info |= SANE_INFO_INEXACT; } } return SANE_STATUS_GOOD; case OPT_MANUAL_OFFSET: w = *(SANE_Word *) val; if (w == dev->val[OPT_MANUAL_OFFSET].w) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; dev->val[OPT_MANUAL_OFFSET].w = w; if (w == SANE_TRUE) { const char *mode = dev->val[OPT_MODE].s; if ((strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) || (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0)) dev->opt[OPT_GRAY_OFFSET].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dev->opt[OPT_GRAY_OFFSET].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_RED_OFFSET].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GREEN_OFFSET].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_BLUE_OFFSET].cap &= ~SANE_CAP_INACTIVE; } } else { dev->opt[OPT_GRAY_OFFSET].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_RED_OFFSET].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GREEN_OFFSET].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_BLUE_OFFSET].cap |= SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; case OPT_MANUAL_GAIN: w = *(SANE_Word *) val; if (w == dev->val[OPT_MANUAL_GAIN].w) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; dev->val[OPT_MANUAL_GAIN].w = w; if (w == SANE_TRUE) { const char *mode = dev->val[OPT_MODE].s; if ((strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) || (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0)) dev->opt[OPT_GRAY_GAIN].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dev->opt[OPT_GRAY_GAIN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_RED_GAIN].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GREEN_GAIN].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_BLUE_GAIN].cap &= ~SANE_CAP_INACTIVE; } } else { dev->opt[OPT_GRAY_GAIN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_RED_GAIN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GREEN_GAIN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_BLUE_GAIN].cap |= SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; case OPT_CUSTOM_GAMMA: w = *(SANE_Word *) val; if (w == dev->val[OPT_CUSTOM_GAMMA].w) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; dev->val[OPT_CUSTOM_GAMMA].w = w; if (w == SANE_TRUE) { const char *mode = dev->val[OPT_MODE].s; if ((strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) || (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0)) { dev->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; sanei_umax_pp_gamma (NULL, dev->val[OPT_GAMMA_VECTOR].wa, NULL); } else if (strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dev->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; sanei_umax_pp_gamma (dev->val[OPT_GAMMA_VECTOR_R].wa, dev->val[OPT_GAMMA_VECTOR_G].wa, dev->val[OPT_GAMMA_VECTOR_B].wa); } } else { dev->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; sanei_umax_pp_gamma (NULL, NULL, NULL); } return SANE_STATUS_GOOD; case OPT_MODE: { char *old_val = dev->val[option].s; if (old_val) { if (strcmp (old_val, val) == 0) return SANE_STATUS_GOOD; /* no change */ free (old_val); } if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; dev->val[option].s = strdup (val); /* corrects top y for offset */ if (strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dpi = (int) (SANE_UNFIX (dev->val[OPT_RESOLUTION].w)); if (dev->val[OPT_TL_Y].w < 2 * umax_pp_get_sync (dpi)) { dev->val[OPT_TL_Y].w = 2 * umax_pp_get_sync (dpi); DBG (16, "control_option: correcting TL_Y coordinates\n"); if (info) *info |= SANE_INFO_INEXACT; } } dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; sanei_umax_pp_gamma (NULL, NULL, NULL); if (dev->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE) { if ((strcmp (val, SANE_VALUE_SCAN_MODE_GRAY) == 0) || (strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) == 0)) { dev->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; sanei_umax_pp_gamma (NULL, dev->val[OPT_GAMMA_VECTOR].wa, NULL); } else if (strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dev->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; sanei_umax_pp_gamma (dev->val[OPT_GAMMA_VECTOR_R].wa, dev->val[OPT_GAMMA_VECTOR_G].wa, dev->val[OPT_GAMMA_VECTOR_B].wa); } } /* rebuild OPT OFFSET */ dev->opt[OPT_GRAY_OFFSET].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_RED_OFFSET].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GREEN_OFFSET].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_BLUE_OFFSET].cap |= SANE_CAP_INACTIVE; if (dev->val[OPT_MANUAL_OFFSET].w == SANE_TRUE) { if ((strcmp (val, SANE_VALUE_SCAN_MODE_GRAY) == 0) || (strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) == 0)) dev->opt[OPT_GRAY_OFFSET].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dev->opt[OPT_RED_OFFSET].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GREEN_OFFSET].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_BLUE_OFFSET].cap &= ~SANE_CAP_INACTIVE; } } /* rebuild OPT GAIN */ dev->opt[OPT_GRAY_GAIN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_RED_GAIN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GREEN_GAIN].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_BLUE_GAIN].cap |= SANE_CAP_INACTIVE; if (dev->val[OPT_MANUAL_GAIN].w == SANE_TRUE) { if ((strcmp (val, SANE_VALUE_SCAN_MODE_GRAY) == 0) || (strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) == 0)) dev->opt[OPT_GRAY_GAIN].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) == 0) { dev->opt[OPT_RED_GAIN].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GREEN_GAIN].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_BLUE_GAIN].cap &= ~SANE_CAP_INACTIVE; } } return SANE_STATUS_GOOD; } } } DBG (2, "control_option: unknown action %d \n", action); return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Umax_PP_Device *dev = handle; int dpi, remain; memset (&(dev->params), 0, sizeof (dev->params)); DBG (64, "sane_get_parameters\n"); /* color/gray */ if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) != 0) { if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY) != 0) dev->color = UMAX_PP_MODE_LINEART; else dev->color = UMAX_PP_MODE_GRAYSCALE; } else dev->color = UMAX_PP_MODE_COLOR; /* offset control */ if (dev->val[OPT_MANUAL_OFFSET].w == SANE_TRUE) { if (dev->color != UMAX_PP_MODE_COLOR) { dev->red_offset = 0; dev->green_offset = (int) (dev->val[OPT_GRAY_OFFSET].w); dev->blue_offset = 0; } else { dev->red_offset = (int) (dev->val[OPT_RED_OFFSET].w); dev->green_offset = (int) (dev->val[OPT_GREEN_OFFSET].w); dev->blue_offset = (int) (dev->val[OPT_BLUE_OFFSET].w); } } else { dev->red_offset = 6; dev->green_offset = 6; dev->blue_offset = 6; } /* gain control */ if (dev->val[OPT_MANUAL_GAIN].w == SANE_TRUE) { if (dev->color != UMAX_PP_MODE_COLOR) { dev->red_gain = 0; dev->green_gain = (int) (dev->val[OPT_GRAY_GAIN].w); dev->blue_gain = 0; } else { dev->red_gain = (int) (dev->val[OPT_RED_GAIN].w); dev->green_gain = (int) (dev->val[OPT_GREEN_GAIN].w); dev->blue_gain = (int) (dev->val[OPT_BLUE_GAIN].w); } } else { dev->red_gain = red_gain; dev->green_gain = green_gain; dev->blue_gain = blue_gain; } /* geometry */ dev->TopX = dev->val[OPT_TL_X].w; dev->TopY = dev->val[OPT_TL_Y].w; dev->BottomX = dev->val[OPT_BR_X].w; dev->BottomY = dev->val[OPT_BR_Y].w; /* resolution : only have 75, 150, 300, 600 and 1200 */ dpi = (int) (SANE_UNFIX (dev->val[OPT_RESOLUTION].w)); if (dpi <= 75) dpi = 75; else if (dpi <= 150) dpi = 150; else if (dpi <= 300) dpi = 300; else if (dpi <= 600) dpi = 600; else dpi = 1200; dev->dpi = dpi; DBG (16, "sane_get_parameters: dpi set to %d\n", dpi); /* for highest resolutions , width must be aligned on 32 bit word */ if (dpi >= 600) { remain = (dev->BottomX - dev->TopX) & 0x03; if (remain) { DBG (64, "sane_get_parameters: %d-%d -> remain is %d\n", dev->BottomX, dev->TopX, remain); if (dev->BottomX + remain < dev->desc->max_h_size) dev->BottomX += remain; else { remain -= (dev->desc->max_h_size - dev->BottomX); dev->BottomX = dev->desc->max_h_size; dev->TopX -= remain; } } } if (dev->val[OPT_PREVIEW].w == SANE_TRUE) { if (dev->val[OPT_GRAY_PREVIEW].w == SANE_TRUE) { DBG (16, "sane_get_parameters: gray preview\n"); dev->color = UMAX_PP_MODE_GRAYSCALE; dev->params.format = SANE_FRAME_GRAY; } else { DBG (16, "sane_get_parameters: color preview\n"); dev->color = UMAX_PP_MODE_COLOR; dev->params.format = SANE_FRAME_RGB; } dev->dpi = 75; dev->TopX = 0; dev->TopY = 0; dev->BottomX = dev->desc->max_h_size; dev->BottomY = dev->desc->max_v_size; } /* fill params */ dev->params.last_frame = SANE_TRUE; dev->params.lines = ((dev->BottomY - dev->TopY) * dev->dpi) / dev->desc->ccd_res; if (dev->dpi >= dev->desc->ccd_res) dpi = dev->desc->ccd_res; else dpi = dev->dpi; dev->params.pixels_per_line = ((dev->BottomX - dev->TopX) * dpi) / dev->desc->ccd_res; if (dev->color == UMAX_PP_MODE_COLOR) { dev->params.bytes_per_line = dev->params.pixels_per_line * 3; dev->params.format = SANE_FRAME_RGB; } else { dev->params.bytes_per_line = dev->params.pixels_per_line; dev->params.format = SANE_FRAME_GRAY; } dev->params.depth = 8; /* success */ if (params != NULL) memcpy (params, &(dev->params), sizeof (dev->params)); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Umax_PP_Device *dev = handle; int rc, autoset; int delta = 0, points; /* sanity check */ if (dev->state == UMAX_PP_STATE_SCANNING) { DBG (2, "sane_start: device is already scanning\n"); DEBUG (); return SANE_STATUS_DEVICE_BUSY; } /* if cancelled, check if head is back home */ if (dev->state == UMAX_PP_STATE_CANCELLED) { DBG (2, "sane_start: checking if scanner is parking head .... \n"); rc = sanei_umax_pp_status (); points = 0; /* check if scanner busy parking */ /* if so, wait parking completion */ DBG (2, "sane_start: scanner busy\n"); while ((rc == UMAX1220P_BUSY) && (points < 30)) { sleep (1); rc = sanei_umax_pp_status (); points++; } /* timeout waiting for scanner */ if (rc == UMAX1220P_BUSY) { DBG (2, "sane_start: scanner still busy\n"); return SANE_STATUS_DEVICE_BUSY; } dev->state = UMAX_PP_STATE_IDLE; } /* get values from options */ sane_get_parameters (handle, NULL); /* sets lamp flag to TRUE */ dev->val[OPT_LAMP_CONTROL].w = SANE_TRUE; /* tests if we do auto setting */ if (dev->val[OPT_MANUAL_GAIN].w == SANE_TRUE) autoset = 0; else autoset = 1; /* call start scan */ if (dev->color == UMAX_PP_MODE_COLOR) { delta = umax_pp_get_sync (dev->dpi); points = 2 * delta; /* first lines are 'garbage' for 610P */ if (sanei_umax_pp_getastra () < 1210) points *= 2; DBG (64, "sane_start:umax_pp_start(%d,%d,%d,%d,%d,1,%X,%X)\n", dev->TopX, dev->TopY - points, dev->BottomX - dev->TopX, dev->BottomY - dev->TopY + points, dev->dpi, (dev->red_gain << 8) + (dev->green_gain << 4) + dev->blue_gain, (dev->red_offset << 8) + (dev->green_offset << 4) + dev->blue_offset); rc = sanei_umax_pp_start (dev->TopX, dev->TopY - points, dev->BottomX - dev->TopX, dev->BottomY - dev->TopY + points, dev->dpi, 2, autoset, (dev->red_gain << 8) | (dev->green_gain << 4) | dev->blue_gain, (dev->red_offset << 8) | (dev->green_offset << 4) | dev->blue_offset, &(dev->bpp), &(dev->tw), &(dev->th)); /* we enlarged the scanning zone */ /* to allow reordering, we must */ /* substract it from real scanning */ /* zone */ dev->th -= points; DBG (64, "sane_start: bpp=%d,tw=%d,th=%d\n", dev->bpp, dev->tw, dev->th); } else { DBG (64, "sane_start:umax_pp_start(%d,%d,%d,%d,%d,0,%X,%X)\n", dev->TopX, dev->TopY, dev->BottomX - dev->TopX, dev->BottomY - dev->TopY, dev->dpi, dev->gray_gain << 4, dev->gray_offset << 4); rc = sanei_umax_pp_start (dev->TopX, dev->TopY, dev->BottomX - dev->TopX, dev->BottomY - dev->TopY, dev->dpi, 1, autoset, dev->gray_gain << 4, dev->gray_offset << 4, &(dev->bpp), &(dev->tw), &(dev->th)); DBG (64, "sane_start: bpp=%d,tw=%d,th=%d\n", dev->bpp, dev->tw, dev->th); } if (rc != UMAX1220P_OK) { DBG (2, "sane_start: failure\n"); return SANE_STATUS_IO_ERROR; } /* scan started, no bytes read */ dev->state = UMAX_PP_STATE_SCANNING; dev->buflen = 0; dev->bufread = 0; dev->read = 0; /* leading lines for 610P aren't complete in color mode */ /* and should be discarded */ if ((sanei_umax_pp_getastra () < 1210) && (dev->color == UMAX_PP_MODE_COLOR)) { rc = sanei_umax_pp_read (2 * delta * dev->tw * dev->bpp, dev->tw, dev->dpi, 0, dev->buf + UMAX_PP_RESERVE - 2 * delta * dev->tw * dev->bpp); if (rc != UMAX1220P_OK) { DBG (2, "sane_start: first lines discarding failed\n"); return SANE_STATUS_IO_ERROR; } } /* in case of color, we have to preload blue and green */ /* data to allow reordering while later read */ if ((dev->color == UMAX_PP_MODE_COLOR) && (delta > 0)) { rc = sanei_umax_pp_read (2 * delta * dev->tw * dev->bpp, dev->tw, dev->dpi, 0, dev->buf + UMAX_PP_RESERVE - 2 * delta * dev->tw * dev->bpp); if (rc != UMAX1220P_OK) { DBG (2, "sane_start: preload buffer failed\n"); return SANE_STATUS_IO_ERROR; } } /* OK .... */ return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { Umax_PP_Device *dev = handle; long int length; int last, rc; int x, y, nl, ll; SANE_Byte *lbuf; int max = 0; int min = 255; int delta = 0; /* no data until further notice */ *len = 0; DBG (64, "sane_read(max_len=%d)\n", max_len); ll = dev->tw * dev->bpp; /* sanity check */ if (dev->state == UMAX_PP_STATE_CANCELLED) { DBG (2, "sane_read: scan cancelled\n"); DEBUG (); return SANE_STATUS_CANCELLED; } /* eof test */ if (dev->read >= dev->th * ll) { DBG (2, "sane_read: end of scan reached\n"); return SANE_STATUS_EOF; } /* read data from scanner if needed */ if ((dev->buflen == 0) || (dev->bufread >= dev->buflen)) { DBG (64, "sane_read: reading data from scanner\n"); /* absolute number of bytes needed */ length = ll * dev->th - dev->read; /* does all fit in a single last read ? */ if (length <= dev->bufsize) { last = 1; } else { last = 0; /* round number of scan lines */ length = (dev->bufsize / ll) * ll; } if (dev->color == UMAX_PP_MODE_COLOR) { delta = umax_pp_get_sync (dev->dpi); rc = sanei_umax_pp_read (length, dev->tw, dev->dpi, last, dev->buf + UMAX_PP_RESERVE); } else rc = sanei_umax_pp_read (length, dev->tw, dev->dpi, last, dev->buf); if (rc != UMAX1220P_OK) return SANE_STATUS_IO_ERROR; dev->buflen = length; DBG (64, "sane_read: got %ld bytes of data from scanner\n", length); /* we transform data for software lineart */ if (dev->color == UMAX_PP_MODE_LINEART) { DBG (64, "sane_read: software lineart\n"); for (y = 0; y < length; y++) { if (dev->buf[y] > max) max = dev->buf[y]; if (dev->buf[y] < min) min = dev->buf[y]; } max = (min + max) / 2; for (y = 0; y < length; y++) { if (dev->buf[y] > max) dev->buf[y] = 255; else dev->buf[y] = 0; } } else if (dev->color == UMAX_PP_MODE_COLOR) { /* number of lines */ nl = dev->buflen / ll; DBG (64, "sane_read: reordering %ld bytes of data (lines=%d)\n", length, nl); lbuf = (SANE_Byte *) malloc (dev->bufsize + UMAX_PP_RESERVE); if (lbuf == NULL) { DBG (1, "sane_read: couldn't allocate %ld bytes\n", dev->bufsize + UMAX_PP_RESERVE); return SANE_STATUS_NO_MEM; } /* reorder data in R,G,B values */ for (y = 0; y < nl; y++) { for (x = 0; x < dev->tw; x++) { switch (sanei_umax_pp_getastra ()) { case 610: /* green value: sync'ed */ lbuf[x * dev->bpp + y * ll + 1 + UMAX_PP_RESERVE] = dev->buf[x + y * ll + 2 * dev->tw + UMAX_PP_RESERVE]; /* blue value, +delta line ahead of sync */ lbuf[x * dev->bpp + y * ll + 2 + UMAX_PP_RESERVE] = dev->buf[x + (y - delta) * ll + dev->tw + UMAX_PP_RESERVE]; /* red value, +2*delta line ahead of sync */ lbuf[x * dev->bpp + y * ll + UMAX_PP_RESERVE] = dev->buf[x + (y - 2 * delta) * ll + UMAX_PP_RESERVE]; break; default: /* red value: sync'ed */ lbuf[x * dev->bpp + y * ll + UMAX_PP_RESERVE] = dev->buf[x + y * ll + 2 * dev->tw + UMAX_PP_RESERVE]; /* green value, +delta line ahead of sync */ lbuf[x * dev->bpp + y * ll + 1 + UMAX_PP_RESERVE] = dev->buf[x + (y - delta) * ll + dev->tw + UMAX_PP_RESERVE]; /* blue value, +2*delta line ahead of sync */ lbuf[x * dev->bpp + y * ll + 2 + UMAX_PP_RESERVE] = dev->buf[x + (y - 2 * delta) * ll + UMAX_PP_RESERVE]; } } } /* store last data lines for next reordering */ if (!last) memcpy (lbuf + UMAX_PP_RESERVE - 2 * delta * ll, dev->buf + UMAX_PP_RESERVE + dev->buflen - 2 * delta * ll, 2 * delta * ll); free (dev->buf); dev->buf = lbuf; } dev->bufread = 0; } /* how much get data we can get from memory buffer */ length = dev->buflen - dev->bufread; DBG (64, "sane_read: %ld bytes of data available\n", length); if (length > max_len) length = max_len; if (dev->color == UMAX_PP_MODE_COLOR) memcpy (buf, dev->buf + dev->bufread + UMAX_PP_RESERVE, length); else memcpy (buf, dev->buf + dev->bufread, length); *len = length; dev->bufread += length; dev->read += length; DBG (64, "sane_read: %ld bytes read\n", length); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Umax_PP_Device *dev = handle; int rc; DBG (64, "sane_cancel\n"); if (dev->state == UMAX_PP_STATE_IDLE) { DBG (3, "cancel: cancelling idle \n"); return; } if (dev->state == UMAX_PP_STATE_SCANNING) { DBG (3, "cancel: stopping current scan\n"); dev->buflen = 0; dev->state = UMAX_PP_STATE_CANCELLED; sanei_umax_pp_cancel (); } else { /* STATE_CANCELLED */ DBG (2, "cancel: checking if scanner is still parking head .... \n"); rc = sanei_umax_pp_status (); /* check if scanner busy parking */ if (rc == UMAX1220P_BUSY) { DBG (2, "cancel: scanner busy\n"); return; } dev->state = UMAX_PP_STATE_IDLE; } } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { DBG (129, "unused arg: handle = %p, non_blocking = %d\n", handle, (int) non_blocking); DBG (2, "set_io_mode: not supported\n"); return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { DBG (129, "unused arg: handle = %p, fd = %p\n", handle, (void *) fd); DBG (2, "get_select_fd: not supported\n"); return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/epsonds-usb.h0000666000000000000000000000113613615534521015204 00000000000000/* * epsonds-usb.h - Epson ESC/I-2 driver, USB device list. * * Copyright (C) 2015 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. */ #include "sane/sane.h" #ifndef _EPSONDS_USB_H_ #define _EPSONDS_USB_H_ #define SANE_EPSONDS_VENDOR_ID (0x4b8) extern SANE_Word epsonds_usb_product_ids[]; extern int epsonds_get_number_of_ids(void); #endif sane-backends-1.0.29/backend/teco3.h0000666000000000000000000003073613615534521013767 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002 Frank Zago (sane at zago dot net) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* $Id$ */ /* Commands supported by the scanner. */ #define SCSI_TEST_UNIT_READY 0x00 #define SCSI_REQUEST_SENSE 0x03 #define SCSI_VENDOR_09 0x09 #define SCSI_VENDOR_0E 0x0E #define SCSI_INQUIRY 0x12 #define SCSI_MODE_SELECT 0x15 #define SCSI_SCAN 0x1b #define SCSI_SET_WINDOW 0x24 #define SCSI_SEND_10 0x2a #define SCSI_READ_10 0x28 #define SCSI_OBJECT_POSITION 0x31 #define SCSI_GET_DATA_BUFFER_STATUS 0x34 typedef struct { unsigned char data[16]; int len; } CDB; /* Set a specific bit depending on a boolean. * MKSCSI_BIT(TRUE, 3) will generate 0x08. */ #define MKSCSI_BIT(bit, pos) ((bit)? 1<<(pos): 0) /* Set a value in a range of bits. * MKSCSI_I2B(5, 3, 5) will generate 0x28 */ #define MKSCSI_I2B(bits, pos_b, pos_e) ((bits) << (pos_b) & ((1<<((pos_e)-(pos_b)+1))-1)) /* Store an integer in 2, 3 or 4 byte in an array. */ #define Ito16(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 0) & 0xff; \ } #define Ito24(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 16) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[2] = ((val) >> 0) & 0xff; \ } #define Ito32(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 24) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 16) & 0xff; \ ((unsigned char *)buf)[2] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[3] = ((val) >> 0) & 0xff; \ } #define MKSCSI_GET_DATA_BUFFER_STATUS(cdb, wait, buflen) \ cdb.data[0] = SCSI_GET_DATA_BUFFER_STATUS; \ cdb.data[1] = MKSCSI_BIT(wait, 0); \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.data[6] = 0; \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_INQUIRY(cdb, buflen) \ cdb.data[0] = SCSI_INQUIRY; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = buflen; \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_MODE_SELECT(cdb, pf, sp, buflen) \ cdb.data[0] = SCSI_MODE_SELECT; \ cdb.data[1] = MKSCSI_BIT(pf, 4) | MKSCSI_BIT(sp, 0); \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = buflen; \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_OBJECT_POSITION(cdb, position) \ cdb.data[0] = SCSI_OBJECT_POSITION; \ cdb.data[1] = 0; \ cdb.data[2] = (((position) >> 16) & 0xff); \ cdb.data[3] = (((position) >> 8) & 0xff); \ cdb.data[4] = (((position) >> 0) & 0xff); \ cdb.data[5] = 0; \ cdb.data[6] = 0; \ cdb.data[7] = 0; \ cdb.data[8] = 0; \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_SET_WINDOW(cdb, buflen) \ cdb.data[0] = SCSI_SET_WINDOW; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_READ_10(cdb, dtc, dtq, buflen) \ cdb.data[0] = SCSI_READ_10; \ cdb.data[1] = 0; \ cdb.data[2] = (dtc); \ cdb.data[3] = 0; \ cdb.data[4] = (((dtq) >> 8) & 0xff); \ cdb.data[5] = (((dtq) >> 0) & 0xff); \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_REQUEST_SENSE(cdb, buflen) \ cdb.data[0] = SCSI_REQUEST_SENSE; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = (buflen); \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_SCAN(cdb) \ cdb.data[0] = SCSI_SCAN; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_SEND_10(cdb, dtc, dtq, buflen) \ cdb.data[0] = SCSI_SEND_10; \ cdb.data[1] = 0; \ cdb.data[2] = (dtc); \ cdb.data[3] = 0; \ cdb.data[4] = (((dtq) >> 8) & 0xff); \ cdb.data[5] = (((dtq) >> 0) & 0xff); \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_TEST_UNIT_READY(cdb) \ cdb.data[0] = SCSI_TEST_UNIT_READY; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.len = 6; /*--------------------------------------------------------------------------*/ static inline int getbitfield (unsigned char *pageaddr, int mask, int shift) { return ((*pageaddr >> shift) & mask); } /* defines for request sense return block */ #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7) #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0) #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7) #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6) #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5) #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0) #define get_RS_information(b) getnbyte(b+0x03, 4) #define get_RS_additional_length(b) b[0x07] #define get_RS_ASC(b) b[0x0c] #define get_RS_ASCQ(b) b[0x0d] #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /*--------------------------------------------------------------------------*/ #define mmToIlu(mm) (((mm) * 300) / MM_PER_INCH) #define iluToMm(ilu) (((ilu) * MM_PER_INCH) / 300) /*--------------------------------------------------------------------------*/ #define GAMMA_LENGTH 0x400 /* number of value per color */ /*--------------------------------------------------------------------------*/ enum Teco_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, /* scanner modes */ OPT_RESOLUTION, /* X and Y resolution */ OPT_GEOMETRY_GROUP, OPT_TL_X, /* upper left X */ OPT_TL_Y, /* upper left Y */ OPT_BR_X, /* bottom right X */ OPT_BR_Y, /* bottom right Y */ OPT_ENHANCEMENT_GROUP, OPT_CUSTOM_GAMMA, /* Use the custom gamma tables */ OPT_GAMMA_VECTOR_R, /* Custom Red gamma table */ OPT_GAMMA_VECTOR_G, /* Custom Green Gamma table */ OPT_GAMMA_VECTOR_B, /* Custom Blue Gamma table */ OPT_GAMMA_VECTOR_GRAY, /* Custom Grayscale Gamma table */ OPT_THRESHOLD, /* Threshold */ OPT_DITHER, OPT_PREVIEW, /* must come last: */ OPT_NUM_OPTIONS }; /*--------------------------------------------------------------------------*/ /* * Scanner supported by this backend. */ struct scanners_supported { int scsi_type; char scsi_teco_name[12]; /* real name of the scanner */ enum { TECO_VM3552 } tecoref; char *real_vendor; /* brand on the box */ char *real_product; /* name on the box */ SANE_Range res_range; int x_resolution_max; /* maximum X dpi */ int y_resolution_max; /* maximum Y dpi */ }; /*--------------------------------------------------------------------------*/ #define BLACK_WHITE_STR SANE_VALUE_SCAN_MODE_LINEART #define GRAY_STR SANE_VALUE_SCAN_MODE_GRAY #define COLOR_STR SANE_VALUE_SCAN_MODE_COLOR /*--------------------------------------------------------------------------*/ /* Define a scanner occurence. */ typedef struct Teco_Scanner { struct Teco_Scanner *next; SANE_Device sane; char *devicename; int sfd; /* device handle */ /* Infos from inquiry. */ char scsi_type; char scsi_vendor[9]; char scsi_product[17]; char scsi_version[5]; char scsi_teco_name[12]; /* real name of the scanner */ /* SCSI handling */ size_t buffer_size; /* size of the buffer */ SANE_Byte *buffer; /* for SCSI transfer. */ /* Scanner infos. */ const struct scanners_supported *def; /* default options for that scanner */ /* Scanning handling. */ int scanning; /* TRUE if a scan is running. */ int x_resolution; /* X resolution in DPI */ int y_resolution; /* Y resolution in DPI */ int x_tl; /* X top left */ int y_tl; /* Y top left */ int x_br; /* X bottom right */ int y_br; /* Y bottom right */ int width; /* width of the scan area in mm */ int length; /* length of the scan area in mm */ enum { TECO_BW, TECO_GRAYSCALE, TECO_COLOR } scan_mode; int depth; /* depth per color */ size_t bytes_left; /* number of bytes left to give to the backend */ size_t real_bytes_left; /* number of bytes left the scanner will return. */ size_t bytes_per_raster; /* bytes per raster. In B&W and Gray, that the same as param.bytes_per_lines. In Color, it's a third. */ SANE_Byte *image; /* keep the raw image here */ size_t image_size; /* allocated size of image */ size_t image_begin; /* first significant byte in image */ size_t image_end; /* first free byte in image */ int does_color_shift; /* in color mode only, do we need to * apply the color shifting algorithm? * It is necessary for the VM3552 * without a RAM extension. With the * RAM extension, the scanner does * it. */ int color_shift; /* for color scan: number of lines to * shift the colors. The higher the * resolution, the higher this * number. */ int raster_size; /* size of a raster */ int raster_num; /* for color scan, current raster read */ int raster_real; /* real number of raster in the * scan. This is necessary since I * don't know how to reliably compute * the number of lines */ int raster_ahead; /* max size of the incomplete lines */ int line; /* current line of the scan */ SANE_Parameters params; /* Options */ SANE_Option_Descriptor opt[OPT_NUM_OPTIONS]; Option_Value val[OPT_NUM_OPTIONS]; /* Gamma table. 1 array per colour. */ SANE_Word gamma_GRAY[GAMMA_LENGTH]; SANE_Word gamma_R[GAMMA_LENGTH]; SANE_Word gamma_G[GAMMA_LENGTH]; SANE_Word gamma_B[GAMMA_LENGTH]; } Teco_Scanner; /*--------------------------------------------------------------------------*/ /* Debug levels. * Should be common to all backends. */ #define DBG_error0 0 #define DBG_error 1 #define DBG_sense 2 #define DBG_warning 3 #define DBG_inquiry 4 #define DBG_info 5 #define DBG_info2 6 #define DBG_proc 7 #define DBG_read 8 #define DBG_sane_init 10 #define DBG_sane_proc 11 #define DBG_sane_info 12 #define DBG_sane_option 13 /*--------------------------------------------------------------------------*/ /* 32 bits from an array to an integer (eg ntohl). */ #define B32TOI(buf) \ ((((unsigned char *)buf)[0] << 24) | \ (((unsigned char *)buf)[1] << 16) | \ (((unsigned char *)buf)[2] << 8) | \ (((unsigned char *)buf)[3] << 0)) #define B24TOI(buf) \ ((((unsigned char *)buf)[0] << 16) | \ (((unsigned char *)buf)[1] << 8) | \ (((unsigned char *)buf)[2] << 0)) #define B16TOI(buf) \ ((((unsigned char *)buf)[0] << 8) | \ (((unsigned char *)buf)[1] << 0)) sane-backends-1.0.29/backend/u12-shading.c0000666000000000000000000006306613615534521014771 00000000000000/* @file u12-shading.c - * @brief all the shading functions * * based on sources acquired from Plustek Inc. * Copyright (C) 2003-2004 Gerhard Jaeger * * History: * - 0.01 - initial version * - 0.02 - * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #define _GAIN_HIGH 240 /* Volt. max. value */ #define _GAIN_LOW 220 /* Volt. min. value */ #define _CHANNEL_RED 0 #define _CHANNEL_GREEN 1 #define _CHANNEL_BLUE 2 /* for DAC programming */ #define _VALUE_CONFIG 0x51 #define _DAC_RED (SANE_Byte)(_VALUE_CONFIG | 0x00) #define _DAC_GREENCOLOR (SANE_Byte)(_VALUE_CONFIG | 0x04) #define _DAC_GREENMONO (SANE_Byte)(_VALUE_CONFIG | 0x06) #define _DAC_BLUE (SANE_Byte)(_VALUE_CONFIG | 0x08) /* forward declarations ... */ static void u12tpa_Reshading( U12_Device * ); static void u12tpa_FindCenterPointer( U12_Device * ); /** */ static void u12shading_DownloadShadingTable( U12_Device *dev, SANE_Byte *buf, u_long len ) { SANE_Byte *val, *rb; SANE_Byte reg, regs[20]; int c; DBG( _DBG_INFO, "u12shading_DownloadShadingTable()\n" ); u12io_DataToRegister( dev, REG_MODECONTROL, _ModeShadingMem ); u12io_DataToRegister( dev, REG_MEMORYLO, 0 ); u12io_DataToRegister( dev, REG_MEMORYHI, 0 ); /* set 12 bits output color */ u12io_DataToRegister( dev, REG_SCANCONTROL, (SANE_Byte)(dev->regs.RD_ScanControl | _SCAN_12BITMODE)); u12io_MoveDataToScanner( dev, buf, len ); regs[0] = REG_MODECONTROL; regs[1] = _ModeScan; /* FillShadingDarkToShadingRegister() */ dev->regs.RD_RedDarkOff = dev->shade.DarkOffset.Colors.Red; dev->regs.RD_GreenDarkOff = dev->shade.DarkOffset.Colors.Green; dev->regs.RD_BlueDarkOff = dev->shade.DarkOffset.Colors.Blue; val = (SANE_Byte*)&dev->regs.RD_RedDarkOff; rb = ®s[2]; c = 1; for( reg = REG_REDCHDARKOFFSETLO; reg <= REG_BLUECHDARKOFFSETHI; reg++, val++) { *(rb++) = reg; *(rb++) = *val; c++; } u12io_DataToRegs( dev, regs, c ); } /** */ static SANE_Status u12shadingAdjustShadingWaveform( U12_Device *dev ) { SANE_Byte b; u_short count, wR, wG, wB, tmp; DataType var; DataPointer pvar, psum; RBGPtrDef cp; RGBUShortDef *pRGB, *pwsum; u_long shadingBytes; DBG( _DBG_INFO, "u12shading_AdjustShadingWaveForm()\n" ); memset( &cp, 0, sizeof(RBGPtrDef)); memset( dev->bufs.b2.pSumBuf, 0, (5400 * 3 * 2)); u12io_DataToRegister( dev, REG_MODECONTROL, _ModeIdle ); dev->regs.RD_LineControl = _LOBYTE(dev->shade.wExposure); dev->regs.RD_ExtLineControl = _HIBYTE(dev->shade.wExposure); u12io_DataToRegister( dev, REG_EXTENDEDLINECONTROL, dev->regs.RD_ExtLineControl ); u12io_DataToRegister( dev, REG_LINECONTROL, dev->regs.RD_LineControl ); dev->regs.RD_XStepTime = _LOBYTE(dev->shade.wExposure); dev->regs.RD_ExtXStepTime = _HIBYTE(dev->shade.wExposure); u12io_DataToRegister( dev, REG_EXTENDEDXSTEP, dev->regs.RD_ExtXStepTime ); u12io_DataToRegister( dev, REG_XSTEPTIME, dev->regs.RD_XStepTime ); dev->regs.RD_ModeControl = _ModeScan; dev->regs.RD_StepControl = _MOTOR0_SCANSTATE; dev->regs.RD_Motor0Control = _FORWARD_MOTOR; if( dev->shade.intermediate & _ScanMode_AverageOut ) { dev->regs.RD_Dpi = 300; dev->regs.RD_Pixels = 2700; shadingBytes = 2700 * 2; } else { dev->regs.RD_Dpi = 600; dev->regs.RD_Pixels = 5400; shadingBytes = 5400 * 2; } dev->regs.RD_Origin = _SHADING_BEGINX; for( pvar.pdw = (u_long*)dev->scanStates, var.dwValue = _SCANSTATE_BYTES >> 2; var.dwValue--; pvar.pdw++) { *pvar.pdw = 0x00f00080; } dev->scan.refreshState = SANE_FALSE; u12io_PutOnAllRegisters( dev ); /* _DODELAY( 100 ); */ if( dev->shade.pHilight ) { memset( dev->shade.pHilight, 0, shadingBytes * dev->shade.skipHilight * 3 ); memset((SANE_Byte*)dev->shade.pHilight + shadingBytes * dev->shade.skipHilight * 3, 0xff, shadingBytes * dev->shade.skipShadow * 3 ); } for( count = 32; count--; ) { if( u12io_IsEscPressed()) { DBG( _DBG_INFO, "* CANCEL detected!\n" ); return SANE_STATUS_CANCELLED; } u12io_ReadOneShadingLine( dev, ((SANE_Byte*)dev->bufs.b1.pShadingRam)+ _SHADING_BEGINX, shadingBytes ); if( dev->shade.pHilight ) { if ( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { cp.red.usp = dev->bufs.b1.pShadingRam + _SHADING_BEGINX; cp.green.usp = cp.red.usp + dev->regs.RD_Pixels; cp.blue.usp = cp.green.usp + dev->regs.RD_Pixels; pvar.pusrgb = (RGBUShortDef*)dev->shade.pHilight + _SHADING_BEGINX; for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { pRGB = pvar.pusrgb++; wR = *cp.red.usp; wG = *cp.green.usp; wB = *cp.blue.usp; for( b = dev->shade.skipHilight; b--; pRGB += dev->regs.RD_Pixels ) { if( wR > pRGB->Red ) { tmp = wR; wR = pRGB->Red; pRGB->Red = tmp; } if( wG > pRGB->Green ) { tmp = wG; wG = pRGB->Green; pRGB->Green = tmp; } if( wB > pRGB->Blue ) { tmp = wB; wB = pRGB->Blue; pRGB->Blue = tmp; } } wR = *cp.red.usp++; wG = *cp.green.usp++; wB = *cp.blue.usp++; for( b = dev->shade.skipShadow; b--; pRGB += dev->regs.RD_Pixels ) { if( wR < pRGB->Red ) { tmp = wR; wR = pRGB->Red; pRGB->Red = tmp; } if( wG < pRGB->Green ) { tmp = wG; wG = pRGB->Green; pRGB->Green = tmp; } if( wB < pRGB->Blue ) { tmp = wB; wB = pRGB->Blue; pRGB->Blue = tmp; } } } } else { cp.green.usp = dev->bufs.b1.pShadingRam + dev->regs.RD_Pixels + _SHADING_BEGINX; cp.blue.usp = (u_short*)dev->shade.pHilight + _SHADING_BEGINX; for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { cp.red.usp = cp.blue.usp++; wG = *cp.green.usp; for( b = dev->shade.skipHilight; b--; cp.red.usp += dev->regs.RD_Pixels) { if( wG > *cp.red.usp ) { tmp = wG; wG = *cp.red.usp; *cp.red.usp = tmp; } } wG = *cp.green.usp++; for( b = dev->shade.skipShadow; b--; cp.red.usp += dev->regs.RD_Pixels ) { if( wG < *cp.red.usp ) { tmp = wG; wG = *cp.red.usp; *cp.red.usp = tmp; } } } } } /* AddToSumBuffer() */ if( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { cp.red.usp = dev->bufs.b1.pShadingRam + _SHADING_BEGINX; cp.green.usp = cp.red.usp + dev->regs.RD_Pixels; cp.blue.usp = cp.green.usp + dev->regs.RD_Pixels; pvar.pulrgb = (RGBULongDef*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = (u_long)dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--; pvar.pulrgb++, cp.red.usp++, cp.green.usp++, cp.blue.usp++) { pvar.pulrgb->Red += (u_long)*cp.red.usp; pvar.pulrgb->Green += (u_long)*cp.green.usp; pvar.pulrgb->Blue += (u_long)*cp.blue.usp; } } else { cp.green.usp = dev->bufs.b1.pShadingRam + dev->regs.RD_Pixels + _SHADING_BEGINX; pvar.pdw = (u_long*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = (u_long)dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--; pvar.pdw++, cp.green.usp++) { *pvar.pdw += (u_long)*cp.green.usp; } } u12io_ResetFifoLen(); if( u12io_GetFifoLength( dev ) < dev->regs.RD_Pixels ) u12io_RegisterToScanner( dev, REG_REFRESHSCANSTATE ); } /* AverageAfterSubHilightShadow() */ if( dev->shade.pHilight ) { if( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { psum.pulrgb = (RGBULongDef*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; pwsum = (RGBUShortDef*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; pvar.pusrgb = (RGBUShortDef*)dev->shade.pHilight + _SHADING_BEGINX; for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { pRGB = pvar.pusrgb++; for( b = dev->shade.skipHilight + dev->shade.skipShadow; b--; pRGB += dev->regs.RD_Pixels ) { psum.pulrgb->Red -= (u_long)pRGB->Red; psum.pulrgb->Green -= (u_long)pRGB->Green; psum.pulrgb->Blue -= (u_long)pRGB->Blue; } pwsum->Red = (u_short)(psum.pulrgb->Red / dev->shade.dwDiv); pwsum->Green = (u_short)(psum.pulrgb->Green / dev->shade.dwDiv); pwsum->Blue = (u_short)(psum.pulrgb->Blue / dev->shade.dwDiv); psum.pulrgb++; pwsum++; } } else { cp.green.ulp = (u_long*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; cp.blue.usp = (u_short*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; pvar.pw = (u_short*)dev->shade.pHilight + _SHADING_BEGINX; for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { cp.red.usp = pvar.pw++; for( b = dev->shade.skipHilight + dev->shade.skipShadow; b--; cp.red.usp += dev->regs.RD_Pixels ) *cp.green.ulp -= *cp.red.usp; *cp.blue.usp = (u_short)(*cp.green.ulp / dev->shade.dwDiv); cp.blue.usp++; cp.green.ulp++; } } } else { if( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { psum.pulrgb = (RGBULongDef*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; pwsum = (RGBUShortDef*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { pwsum->Red = (u_short)(psum.pulrgb->Red >> 5); pwsum->Green = (u_short)(psum.pulrgb->Green >> 5); pwsum->Blue = (u_short)(psum.pulrgb->Blue >> 5); psum.pulrgb++; pwsum++; } } else { cp.green.ulp = (u_long*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; cp.blue.usp = (u_short*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { *cp.blue.usp = (u_short)(*cp.green.ulp >> 5); cp.blue.usp++; cp.green.ulp++; } } } /* Process negative & transparency here */ if( dev->DataInf.dwScanFlag & _SCANDEF_TPA ) u12tpa_FindCenterPointer( dev ); if( dev->DataInf.dwScanFlag & _SCANDEF_Negative ) u12tpa_Reshading( dev ); pRGB = (RGBUShortDef*)&dev->shade.pCcdDac->GainResize; if ( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { pwsum = (RGBUShortDef*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { if ((short)(pwsum->Red -= dev->shade.DarkOffset.Colors.Red) > 0) { pwsum->Red = pwsum->Red * pRGB->Red / 100U; if( pwsum->Red > 0xfff ) pwsum->Red = 0xfff; } else pwsum->Red = 0; if((short)(pwsum->Green -= dev->shade.DarkOffset.Colors.Green) > 0) { pwsum->Green = pwsum->Green * pRGB->Green / 100U; if( pwsum->Green > 0xfff ) pwsum->Green = 0xfff; } else pwsum->Green = 0; if ((short)(pwsum->Blue -= dev->shade.DarkOffset.Colors.Blue) > 0) { pwsum->Blue = pwsum->Blue * pRGB->Blue / 100U; if( pwsum->Blue > 0xfff ) pwsum->Blue = 0xfff; } else pwsum->Blue = 0; wR = (u_short)(pwsum->Red >> 4); pwsum->Red <<= 12; pwsum->Red |= wR; wR = (u_short)(pwsum->Green >> 4); pwsum->Green <<= 12; pwsum->Green |= wR; wR = (u_short)(pwsum->Blue>> 4); pwsum->Blue <<= 12; pwsum->Blue |= wR; pwsum++; } } else { cp.green.usp = (u_short*)dev->bufs.b2.pSumBuf + _SHADING_BEGINX; for( var.dwValue = dev->regs.RD_Pixels - _SHADING_BEGINX; var.dwValue--;) { if((short)(*cp.green.usp -= dev->shade.DarkOffset.Colors.Green) > 0) { *cp.green.usp = *cp.green.usp * pRGB->Green / 100U; if( *cp.green.usp > 0xfff ) *cp.green.usp = 0xfff; } else *cp.green.usp = 0; wR = (u_short)(*cp.green.usp >> 4); *cp.green.usp <<= 12; *cp.green.usp |= wR; cp.green.usp++; } } u12shading_DownloadShadingTable(dev, dev->bufs.b2.pSumBuf, (5400 * 3 * 2)); return SANE_STATUS_GOOD; } /** */ static void u12shading_GainOffsetToDAC( U12_Device *dev, SANE_Byte ch, SANE_Byte reg, SANE_Byte d ) { if( dev->DACType == _DA_SAMSUNG8531 ) { u12io_DataRegisterToDAC( dev, 0, ch ); } u12io_DataRegisterToDAC( dev, reg, d ); } /** */ static void u12shading_FillToDAC( U12_Device *dev, RGBByteDef *regs, ColorByte *data ) { if( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { u12shading_GainOffsetToDAC(dev, _DAC_RED, regs->Red, data->Colors.Red); u12shading_GainOffsetToDAC(dev, _DAC_GREENCOLOR, regs->Green, data->Colors.Green); u12shading_GainOffsetToDAC(dev, _DAC_BLUE, regs->Blue, data->Colors.Blue); } else { u12shading_GainOffsetToDAC(dev, _DAC_GREENMONO, regs->Green, data->Colors.Green); } } /** */ static SANE_Byte u12shading_SumGains( SANE_Byte *pb, u_long pixelsLine ) { SANE_Byte hilight, tmp; u_long dwPixels, dwAve; u_short sum; hilight = 0; for( dwPixels = pixelsLine >> 4; dwPixels--; ) { for( sum = 0, dwAve = 16; dwAve--; pb++ ) sum += (u_short)*pb; sum >>= 4; tmp = (SANE_Byte)sum; if( tmp > hilight ) hilight = tmp; } return hilight; } /** */ static void u12shading_AdjustGain( U12_Device *dev, u_long color, SANE_Byte hilight ) { if( hilight < dev->shade.bGainLow ) { if( dev->shade.Hilight.bColors[color] < dev->shade.bGainHigh ) { dev->shade.fStop = SANE_FALSE; dev->shade.Hilight.bColors[color] = hilight; if( hilight <= (SANE_Byte)(dev->shade.bGainLow - hilight)) dev->shade.Gain.bColors[color] += dev->shade.bGainDouble; else dev->shade.Gain.bColors[color]++; } } else { if( hilight > dev->shade.bGainHigh ) { dev->shade.fStop = SANE_FALSE; dev->shade.Hilight.bColors[color] = hilight; dev->shade.Gain.bColors[color]--; } else { dev->shade.Hilight.bColors[color] = hilight; } } if( dev->shade.Gain.bColors[color] > dev->shade.bMaxGain ) { dev->shade.Gain.bColors[color] = dev->shade.bMaxGain; } } /** */ static SANE_Status u12shading_AdjustRGBGain( U12_Device *dev ) { int i; SANE_Byte hi[3]; DBG( _DBG_INFO, "u12shading_AdjustRGBGain()\n" ); dev->shade.Gain.Colors.Red = dev->shade.Gain.Colors.Green = dev->shade.Gain.Colors.Blue = dev->shade.bUniGain; dev->shade.Hilight.Colors.Red = dev->shade.Hilight.Colors.Green = dev->shade.Hilight.Colors.Blue = 0; dev->shade.bGainHigh = _GAIN_HIGH; dev->shade.bGainLow = _GAIN_LOW; dev->shade.fStop = SANE_FALSE; for( i = 10; i-- && !dev->shade.fStop; ) { if( u12io_IsEscPressed()) { DBG( _DBG_INFO, "* CANCEL detected!\n" ); return SANE_STATUS_CANCELLED; } dev->shade.fStop = SANE_TRUE; u12io_DataToRegister( dev, REG_MODECONTROL, _ModeIdle ); dev->regs.RD_ScanControl = _SCAN_BYTEMODE; u12hw_SelectLampSource( dev ); u12io_DataToRegister( dev, REG_SCANCONTROL, dev->regs.RD_ScanControl ); u12shading_FillToDAC( dev, &dev->RegDACGain, &dev->shade.Gain ); dev->regs.RD_ModeControl = _ModeScan; dev->regs.RD_StepControl = _MOTOR0_SCANSTATE; dev->regs.RD_Motor0Control = _FORWARD_MOTOR; if( dev->shade.intermediate & _ScanMode_AverageOut ) dev->regs.RD_Origin = (u_short)_DATA_ORIGIN_X >> 1; else dev->regs.RD_Origin = (u_short)_DATA_ORIGIN_X; dev->regs.RD_Dpi = 300; dev->regs.RD_Pixels = 2560; memset( dev->scanStates, 0, _SCANSTATE_BYTES ); dev->scanStates[1] = 0x77; u12io_PutOnAllRegisters( dev ); /* _DODELAY( 100 ); */ /* read one shading line and work on it */ if( u12io_ReadOneShadingLine( dev, (SANE_Byte*)dev->bufs.b1.pShadingRam, 2560)) { if( dev->DataInf.wPhyDataType <= COLOR_256GRAY ) { hi[1] = u12shading_SumGains( (SANE_Byte*)dev->bufs.b1.pShadingRam + 2560, 2560); if( hi[1] ) { u12shading_AdjustGain( dev, _CHANNEL_GREEN, hi[1] ); } else { dev->shade.fStop = SANE_FALSE; } } else { hi[0] = u12shading_SumGains( (SANE_Byte*)dev->bufs.b1.pShadingRam, 2560); hi[1] = u12shading_SumGains( (SANE_Byte*)dev->bufs.b1.pShadingRam + 2560, 2560); hi[2] = u12shading_SumGains( (SANE_Byte*)dev->bufs.b1.pShadingRam + 5120, 2560); if (!hi[0] || !hi[1] || !hi[2] ) { dev->shade.fStop = SANE_FALSE; } else { u12shading_AdjustGain( dev, _CHANNEL_RED, hi[0] ); u12shading_AdjustGain( dev, _CHANNEL_GREEN, hi[1] ); u12shading_AdjustGain( dev, _CHANNEL_BLUE, hi[2] ); } } } else dev->shade.fStop = SANE_FALSE; } if( !dev->shade.fStop ) DBG( _DBG_INFO, "u12shading_AdjustRGBGain() - all loops done!!!\n" ); u12shading_FillToDAC( dev, &dev->RegDACGain, &dev->shade.Gain ); return SANE_STATUS_GOOD; } /** */ static u_short u12shading_SumDarks( U12_Device *dev, u_short *data ) { u_short i, loop; if( dev->CCDID == _CCD_3799 ) { if( dev->shade.intermediate & _ScanMode_AverageOut ) data += 0x18; else data += 0x30; } else { if( dev->shade.intermediate & _ScanMode_AverageOut ) data += 0x18; else data += 0x20; } for( i = 0, loop = 16; loop--; data++ ) i += *data; i >>= 4; return i; } /** */ static SANE_Status u12shadingAdjustDark( U12_Device *dev ) { u_long i; u_short wDarks[3]; DBG( _DBG_INFO, "u12shadingAdjustDark()\n" ); dev->shade.DarkDAC.Colors = dev->shade.pCcdDac->DarkDAC.Colors; dev->shade.fStop = SANE_FALSE; for( i = 16; i-- && !dev->shade.fStop;) { if( u12io_IsEscPressed()) { DBG( _DBG_INFO, "* CANCEL detected!\n" ); return SANE_STATUS_CANCELLED; } dev->shade.fStop = SANE_TRUE; u12shading_FillToDAC( dev, &dev->RegDACOffset, &dev->shade.DarkDAC ); u12io_DataToRegister( dev, REG_MODECONTROL, _ModeIdle ); dev->regs.RD_ScanControl = (_SCAN_12BITMODE + _SCAN_1ST_AVERAGE); u12hw_SelectLampSource( dev ); u12io_DataToRegister( dev, REG_SCANCONTROL, dev->regs.RD_ScanControl ); dev->regs.RD_StepControl = _MOTOR0_SCANSTATE; dev->regs.RD_Motor0Control = _FORWARD_MOTOR; dev->regs.RD_Origin = _SHADING_BEGINX; dev->regs.RD_Pixels = 512; if( dev->shade.intermediate & _ScanMode_AverageOut ) dev->regs.RD_Dpi = 300; else dev->regs.RD_Dpi = 600; memset( dev->scanStates, 0, _SCANSTATE_BYTES ); dev->scanStates[1] = 0x77; u12io_PutOnAllRegisters( dev ); /* _DODELAY( 100 ); */ /* read one shading line and work on it */ if( u12io_ReadOneShadingLine(dev, (SANE_Byte*)dev->bufs.b1.pShadingRam, 512*2)) { if ( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { wDarks[0] = u12shading_SumDarks(dev, dev->bufs.b1.pShadingRam); wDarks[1] = u12shading_SumDarks(dev, dev->bufs.b1.pShadingRam + dev->regs.RD_Pixels ); wDarks[2] = u12shading_SumDarks(dev, dev->bufs.b1.pShadingRam + dev->regs.RD_Pixels * 2UL); if( !wDarks[0] || !wDarks[1] || !wDarks[2] ) { dev->shade.fStop = SANE_FALSE; } else { dev->shade.DarkOffset.wColors[0] = wDarks[0]; dev->shade.DarkOffset.wColors[1] = wDarks[1]; dev->shade.DarkOffset.wColors[2] = wDarks[2]; (*dev->fnDACDark)( dev,dev->shade.pCcdDac, _CHANNEL_RED, wDarks[0] ); (*dev->fnDACDark)( dev, dev->shade.pCcdDac, _CHANNEL_GREEN, wDarks[1] ); (*dev->fnDACDark)( dev, dev->shade.pCcdDac, _CHANNEL_BLUE, wDarks[2] ); } } else { wDarks[1] = u12shading_SumDarks(dev, dev->bufs.b1.pShadingRam + dev->regs.RD_Pixels ); if(!wDarks[1] ) { dev->shade.fStop = SANE_FALSE; } else { dev->shade.DarkOffset.wColors[1] = wDarks[1]; (*dev->fnDACDark)( dev, dev->shade.pCcdDac, _CHANNEL_GREEN, wDarks[1] ); } } } else { dev->shade.fStop = SANE_FALSE; } } /* CalculateDarkDependOnCCD() */ if ( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { (*dev->fnDarkOffset)( dev, dev->shade.pCcdDac, _CHANNEL_RED ); (*dev->fnDarkOffset)( dev, dev->shade.pCcdDac, _CHANNEL_GREEN ); (*dev->fnDarkOffset)( dev, dev->shade.pCcdDac, _CHANNEL_BLUE ); } else { (*dev->fnDarkOffset)( dev, dev->shade.pCcdDac, _CHANNEL_GREEN ); } return SANE_STATUS_GOOD; } /** here we download the current mapping table */ static void u12shading_DownloadMapTable( U12_Device *dev, SANE_Byte *buf ) { SANE_Byte addr, regs[6]; int i; u12io_DataToRegister( dev, REG_SCANCONTROL, (SANE_Byte)((dev->regs.RD_ScanControl & 0xfc) | _SCAN_BYTEMODE)); /* prepare register settings... */ regs[0] = REG_MODECONTROL; regs[1] = _ModeMappingMem; regs[2] = REG_MEMORYLO; regs[3] = 0; regs[4] = REG_MEMORYHI; for( i = 3, addr = _MAP_ADDR_RED; i--; addr += _MAP_ADDR_SIZE ) { regs[5] = addr; u12io_DataToRegs( dev, regs, 3 ); u12io_MoveDataToScanner( dev, buf, 4096 ); buf += 4096; } u12io_DataToRegister( dev, REG_SCANCONTROL, dev->regs.RD_ScanControl ); } /** */ static SANE_Status u12shading_DoCalibration( U12_Device *dev ) { SANE_Byte tb[4096*3]; u_long i, tmp; SANE_Byte bScanControl, rb[20]; SANE_Status res; int c; DBG( _DBG_INFO, "u12shading_DoCalibration()\n" ); /** before getting the shading data, (re)init the ASIC */ u12hw_InitAsic( dev, SANE_TRUE ); dev->shade.DarkOffset.Colors.Red = 0; dev->shade.DarkOffset.Colors.Green = 0; dev->shade.DarkOffset.Colors.Blue = 0; c = 0; _SET_REG( rb, c, REG_RESETMTSC, 0 ); _SET_REG( rb, c, REG_MODELCONTROL, dev->regs.RD_ModelControl); _SET_REG( rb, c, REG_MOTORDRVTYPE, dev->regs.RD_MotorDriverType ); _SET_REG( rb, c, REG_SCANCONTROL1, (_SCANSTOPONBUFFULL| _MFRC_BY_XSTEP)); u12io_DataToRegs( dev, rb, c ); res = u12motor_GotoShadingPosition( dev ); if( SANE_STATUS_GOOD != res ) return res; bScanControl = dev->regs.RD_ScanControl; /* SetShadingMapForGainDark */ memset( dev->bufs.b2.pSumBuf, 0xff, (5400 * 3 * 2)); u12shading_DownloadShadingTable( dev, dev->bufs.b2.pSumBuf, (5400*3*2)); for( i = 0, tmp = 0; i < 1024; tmp += 0x01010101, i += 4 ) { dev->bufs.b1.Buf.pdw[i] = dev->bufs.b1.Buf.pdw[i+1] = dev->bufs.b1.Buf.pdw[i+2] = dev->bufs.b1.Buf.pdw[i+3] = tmp; } memcpy( dev->bufs.b1.pShadingMap + 4096, dev->bufs.b1.pShadingMap, 4096 ); memcpy( dev->bufs.b1.pShadingMap + 8192, dev->bufs.b1.pShadingMap, 4096 ); u12shading_DownloadMapTable( dev, dev->bufs.b1.pShadingMap ); DBG( _DBG_INFO, "* wExposure = %u\n", dev->shade.wExposure); DBG( _DBG_INFO, "* wXStep = %u\n", dev->shade.wXStep); dev->regs.RD_LineControl = (_LOBYTE(dev->shade.wExposure)); dev->regs.RD_ExtLineControl = (_HIBYTE(dev->shade.wExposure)); u12io_DataToRegister( dev, REG_EXTENDEDLINECONTROL, dev->regs.RD_ExtLineControl ); u12io_DataToRegister( dev, REG_LINECONTROL, dev->regs.RD_LineControl ); res = u12shading_AdjustRGBGain( dev ); if( SANE_STATUS_GOOD != res ) return res; res = u12shadingAdjustDark( dev ); if( SANE_STATUS_GOOD != res ) return res; res = u12shadingAdjustShadingWaveform( dev ); if( SANE_STATUS_GOOD != res ) return res; dev->regs.RD_ScanControl = bScanControl; /* here we have to prepare and download the table in any case...*/ if( dev->DataInf.wPhyDataType <= COLOR_256GRAY ) { u12map_Adjust( dev, _MAP_MASTER, tb ); } else { u12map_Adjust( dev, _MAP_RED, tb ); u12map_Adjust( dev, _MAP_GREEN, tb ); u12map_Adjust( dev, _MAP_BLUE, tb ); } u12shading_DownloadMapTable( dev, tb ); u12motor_BackToHomeSensor( dev ); DBG( _DBG_INFO, "u12shading_DoCalibration() - done.\n" ); return SANE_STATUS_GOOD; } /* END U12-SHADING ..........................................................*/ sane-backends-1.0.29/backend/dc25.conf.in0000666000000000000000000000127713615534521014610 00000000000000# Serial port where the camera is connected ## Linux port=/dev/ttyS0 ## IRIX #port=/dev/ttyd1 ## Solaris #port=/dev/term/a ## HP-UX #port=/dev/tty0p0 ## Digital UNIX #port=/dev/tty01 # Max baud rate for download. Camera always starts at 9600 baud, then # switches to the higher rate ## This works for Linux. Also works for IRIX (6.3 or higher), providing that ## the host is an O2, OCTANE, Origin2000/200, Onyx2, Origin3000/300, Onyx3 or ## a newer SGI hardware [see serial(7)]. #baud=115200 ## This works for most UNIX's baud=38400 # Prints some extra information during the init phase. This can be # handy, but note that printing anything to stderr breaks the saned # network scanning. #dumpinquiry sane-backends-1.0.29/backend/coolscan.c0000666000000000000000000034667013615534521014555 00000000000000/* ------------------------------------------------------------------------- */ /* sane - Scanner Access Now Easy. coolscan.c , version 0.4.4 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for COOLSCAN flatbed scanners. */ /* ------------------------------------------------------------------------- */ /* SANE-FLOW-DIAGRAMM - sane_init() : initialize backend, attach scanners . - sane_get_devices() : query list of scanner-devices . - sane_open() : open a particular scanner-device . . - sane_set_io_mode : set blocking-mode . . - sane_get_select_fd : get scanner-fd . . - sane_get_option_descriptor() : get option informations . . - sane_control_option() : change option values . . . . - sane_start() : start image aquisition . . - sane_get_parameters() : returns actual scan-parameters . . - sane_read() : read image-data (from pipe) . . . . - sane_cancel() : cancel operation . - sane_close() : close opened scanner-device - sane_exit() : terminate use of backend */ #ifdef _AIX # include "lalloca.h" /* MUST come first for AIX! */ #endif #include "../include/sane/config.h" #include "lalloca.h" #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_thread.h" #include "../include/sane/sanei_config.h" #define COOLSCAN_CONFIG_FILE "coolscan.conf" #include "../include/sane/sanei_backend.h" #include "coolscan.h" #include "coolscan-scsidef.h" #ifndef PATH_MAX #define PATH_MAX 1024 #endif /* ------------------------------------------------------------------------- */ static const SANE_Int resolution_list[] = { 25, 2700, 1350, 900, 675, 540, 450, 385, 337, 300, 270, 245, 225, 207, 192, 180, 168, 158, 150, 142, 135, 128, 122, 117, 112, 108 }; #define coolscan_do_scsi_open(dev, fd, handler) sanei_scsi_open(dev, fd, handler) #define coolscan_do_scsi_close(fd) sanei_scsi_close(fd) #define COOLSCAN_MAX_RETRY 25 static SANE_Status sense_handler (int scsi_fd, unsigned char * result, void *arg); static int coolscan_check_values (Coolscan_t * s); static int get_internal_info (Coolscan_t *); static void coolscan_get_inquiry_values (Coolscan_t *); static void hexdump (int level, char *comment, unsigned char *p, int l); static int swap_res (Coolscan_t * s); /* --------------------------- COOLSCAN_DO_SCSI_CMD ----------------------- */ static int do_scsi_cmd (int fd, unsigned char *cmd, int cmd_len, unsigned char *out, size_t out_len) { int ret; size_t ol = out_len; hexdump (20, "", cmd, cmd_len); ret = sanei_scsi_cmd (fd, cmd, cmd_len, out, &ol); if ((out_len != 0) && (out_len != ol)) { DBG (1, "sanei_scsi_cmd: asked %lu bytes, got %lu\n", (u_long) out_len, (u_long) ol); } if (ret) { DBG (1, "sanei_scsi_cmd: returning 0x%08x\n", ret); } DBG (10, "sanei_scsi_cmd: returning %lu bytes:\n", (u_long) ol); if (out != NULL && out_len != 0) hexdump (15, "", out, (out_len > 0x60) ? 0x60 : out_len); return ret; } static int request_sense_parse (unsigned char *sensed_data) { int ret, sense, asc, ascq; sense = get_RS_sense_key (sensed_data); asc = get_RS_ASC (sensed_data); ascq = get_RS_ASCQ (sensed_data); ret = SANE_STATUS_IO_ERROR; switch (sense) { case 0x0: DBG (5, "\t%d/%d/%d: Scanner ready\n", sense, asc, ascq); return SANE_STATUS_GOOD; case 0x1: if ((0x37 == asc) && (0x00 == ascq)) { DBG (1, "\t%d/%d/%d: Rounded Parameter\n", sense, asc, ascq); ret = SANE_STATUS_GOOD; } else if ((0x61 == asc) && (0x02 == ascq)) DBG (1, "\t%d/%d/%d: Out Of Focus\n", sense, asc, ascq); else DBG (1, "\tUnknown - Sense=%d, ASC=%d, ASCQ=%d\n", sense, asc, ascq); break; case 0x2: if ((0x4 == asc) && (0x1 == ascq)) { DBG (10, "\t%d/%d/%d: Logical unit is in process of becoming ready\n", sense, asc, ascq); ret = SANE_STATUS_DEVICE_BUSY; } else if ((0x3A == asc) && (0x00 == ascq)) { DBG (1, "\t%d/%d/%d: No Diapo inserted\n", sense, asc, ascq); ret = SANE_STATUS_GOOD; } else if ((0x60 == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Lamp Failure\n", sense, asc, ascq); else { DBG (1, "\tUnknown - Sense=%d, ASC=%d, ASCQ=%d\n", sense, asc, ascq); ret = SANE_STATUS_GOOD; } break; case 0x3: if ((0x3b == asc) && (0xe == ascq)) DBG (1, "\t%d/%d/%d: Medium source element empty\n", sense, asc, ascq); else if ((0x53 == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Media Load of Eject Failed\n", sense, asc, ascq); else DBG (1, "\tUnknown - Sense=%d, ASC=%d, ASCQ=%d\n", sense, asc, ascq); break; case 0x4: if ((0x15 == asc) && (0x1 == ascq)) DBG (1, "\t%d/%d/%d: Mechanical Positioning Error\n", sense, asc, ascq); else DBG (1, "\tUnknown - Sense=%d, ASC=%d, ASCQ=%d\n", sense, asc, ascq); break; case 0x5: if ((0x00 == asc) && (0x5 == ascq)) DBG (1, "\t%d/%d/%d: End-Of-Data Detected\n", sense, asc, ascq); else if ((0x1a == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Parameter List Length Error\n", sense, asc, ascq); else if ((0x20 == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Invalid Command Operation Code\n", sense, asc, ascq); else if ((0x24 == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Invalid Field In CDB\n", sense, asc, ascq); else if ((0x25 == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Logical Unit Not Supported\n", sense, asc, ascq); else if ((0x26 == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Invalid Field in Parameter List\n", sense, asc, ascq); else if ((0x2c == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Command Sequence Error\n", sense, asc, ascq); else if ((0x39 == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Saving Parameters Not Supported\n", sense, asc, ascq); else if ((0x3d == asc) && (0x00 == ascq)) DBG (1, "\t%d/%d/%d: Invalid Bits In Identify Message\n", sense, asc, ascq); else DBG (1, "\tUnknown - Sense=%d, ASC=%d, ASCQ=%d\n", sense, asc, ascq); break; case 0x6: if ((0x29 == asc) && (0x0 == 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 DBG (1, "\tUnknown - Sense=%d, ASC=%d, ASCQ=%d\n", sense, asc, ascq); break; case 0xb: if ((0x43 == asc) && (0x0 == ascq)) DBG (1, "\t%d/%d/%d: Message Error\n", sense, asc, ascq); else if ((0x47 == asc) && (0x0 == ascq)) DBG (1, "\t%d/%d/%d: SCSI Parity Error\n", sense, asc, ascq); else if ((0x48 == asc) && (0x0 == ascq)) DBG (1, "\t%d/%d/%d: Initiator Detected Error Message Received\n", sense, asc, ascq); else if ((0x49 == asc) && (0x0 == ascq)) DBG (1, "\t%d/%d/%d: Invalid Message Error\n", sense, asc, ascq); else if ((0x4e == asc) && (0x0 == ascq)) DBG (1, "\t%d/%d/%d: Overlapped Commands Attempted\n", sense, asc, ascq); else DBG (1, "\tUnknown - Sense=%d, ASC=%d, ASCQ=%d\n", sense, asc, ascq); break; default: DBG (1, "\tUnknown - Sense=%d, ASC=%d, ASCQ=%d\n", sense, asc, ascq); break; } /* switch */ return ret; } /* * wait_scanner should spin until TEST_UNIT_READY returns 0 (GOOD) * returns 0 on success, * returns -1 on error. */ static int wait_scanner (Coolscan_t * s) { int ret = -1; int cnt = 0; DBG (10, "wait_scanner: Testing if scanner is ready\n"); while (ret != 0) { ret = do_scsi_cmd (s->sfd, test_unit_ready.cmd, test_unit_ready.size, 0, 0); if (ret == SANE_STATUS_DEVICE_BUSY) { usleep (500000); /* wait 0.5 seconds */ if (cnt++ > 40) { /* 20 sec. max (prescan takes up to 15 sec. */ DBG (1, "wait_scanner: scanner does NOT get ready\n"); return -1; } } else if (ret == SANE_STATUS_GOOD) { DBG (10, "wait_scanner: scanner is ready\n"); return ret; } else { DBG (1, "wait_scanner: test unit ready failed (%s)\n", sane_strstatus (ret)); } } return 0; } /* ------------------------- COOLSCAN GRAB SCANNER ----------------------------- */ /* coolscan_grab_scanner should go through the following command sequence: * TEST UNIT READY * CHECK CONDITION \ * REQUEST SENSE > These should be handled automagically by * UNIT ATTENTION / the kernel if they happen (powerup/reset) * TEST UNIT READY * GOOD * RESERVE UNIT * GOOD * * It is then responsible for installing appropriate signal handlers * to call emergency_give_scanner() if user aborts. */ static int coolscan_grab_scanner (Coolscan_t * s) { int ret; DBG (10, "grabbing scanner\n"); wait_scanner (s); /* wait for scanner ready, if not print sense and return 1 */ ret = do_scsi_cmd (s->sfd, reserve_unit.cmd, reserve_unit.size, NULL, 0); if (ret) return ret; DBG (10, "scanner reserved\n"); return 0; } /* * Convert a size in ilu to the units expected by the scanner */ static int resDivToVal (int res_div) { if (res_div < 1 || res_div > resolution_list[0]) { DBG (1, "Invalid resolution divisor %d \n", res_div); return 2700; } else { return resolution_list[res_div]; } } static int resValToDiv (int res_val) { int res_div; int max_res = resolution_list[0]; for (res_div = 1; res_div <= max_res; res_div++) { if (resolution_list[res_div] == res_val) break; } if (res_div > max_res) { DBG (1, "Invalid resolution value\n"); return 1; } else { return res_div; } } /* * use mode select to force a mesurement divisor of 2700 */ static unsigned char mode_select[] = { MODE_SELECT, 0x10, 0, 0, 20, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 1, 3, 6, 0, 0, 0xA, 0x8C, 0, 0}; static int select_MUD (Coolscan_t * s) { return do_scsi_cmd (s->sfd, mode_select, 26, NULL, 0); } static int coolscan_autofocus_LS30 (Coolscan_t * s) { int x, y; wait_scanner(s); memcpy(s->buffer, autofocusLS30.cmd, autofocusLS30.size); memcpy(s->buffer+ autofocusLS30.size, autofocuspos, 9); x = s->xmaxpix - (s->brx + s->tlx) / 2; y = (s->bry + s->tly) / 2; DBG (10, "Attempting AutoFocus at x=%d, y=%d\n", x, y); do_scsi_cmd (s->sfd, s->buffer, autofocusLS30.size + 9, NULL, 0); /* Trashes when used in combination with scsi-driver AM53C974.o */ do_scsi_cmd (s->sfd, command_c1.cmd, command_c1.size, NULL, 0); DBG (10, "\tWaiting end of Autofocus\n"); wait_scanner (s); DBG (10, "AutoFocused.\n"); return 0; } static int coolscan_autofocus (Coolscan_t * s) { int x, y; if(s->LS>=2) { return coolscan_autofocus_LS30(s); } wait_scanner(s); memcpy(s->buffer, autofocus.cmd, autofocus.size); x = s->xmaxpix - (s->brx + s->tlx) / 2; y = (s->bry + s->tly) / 2; DBG (10, "Attempting AutoFocus at x=%d, y=%d\n", x, y); set_AF_XPoint (s->buffer, x); set_AF_YPoint (s->buffer, y); set_AF_transferlength (s->buffer, 0); /* should be 8 !*/ do_scsi_cmd (s->sfd, s->buffer, autofocus.size + AF_Point_length, NULL, 0); sleep(5); /* autofocus takes a minimum of 5 sec. */ DBG (10, "\tWaiting end of Autofocus\n"); wait_scanner (s); DBG (10, "AutoFocused.\n"); return 0; } /* static int coolscan_abort_scan (Coolscan_t * s) { int ret; DBG (5, "Aborting scan...\n"); ret = do_scsi_cmd (s->sfd, sabort.cmd, sabort.size, NULL, 0); if (ret) DBG (5, "Scan Aborted\n"); else DBG (5, "Not scanning\n"); return 0; } */ static int coolscan_mode_sense (Coolscan_t * s) { int ret, len; DBG (10, "Mode Sense...\n"); len = 12; set_MS_DBD (mode_sense.cmd, 1); set_MS_len (mode_sense.cmd, len); ret = do_scsi_cmd (s->sfd, mode_sense.cmd, mode_sense.size, s->buffer, len); if (ret == 0) { s->MUD = get_MS_MUD (s->buffer); DBG (10, "\tMode Sensed (MUD is %d)\n", s->MUD); } return ret; } static int coolscan_object_discharge (Coolscan_t * s) { int ret; DBG (10, "Trying to discharge object...\n"); memcpy (s->buffer, object_position.cmd, object_position.size); set_OP_autofeed (s->buffer, OP_Discharge); ret = do_scsi_cmd (s->sfd, s->buffer, object_position.size, NULL, 0); wait_scanner (s); DBG (10, "Object discharged.\n"); return ret; } static int coolscan_object_feed (Coolscan_t * s) { int ret; DBG (10, "Trying to feed object...\n"); if (!s->asf) { DBG (10, "\tAutofeeder not present.\n"); return 0; } memcpy (s->buffer, object_position.cmd, object_position.size); set_OP_autofeed (s->buffer, OP_Feed); ret = do_scsi_cmd (s->sfd, s->buffer, object_position.size, NULL, 0); wait_scanner (s); DBG (10, "Object fed.\n"); return ret; } /* coolscan_give_scanner should go through the following sequence: * OBJECT POSITION DISCHARGE * GOOD * RELEASE UNIT * GOOD */ static int coolscan_give_scanner (Coolscan_t * s) { DBG (10, "trying to release scanner ...\n"); coolscan_object_discharge (s); wait_scanner (s); do_scsi_cmd (s->sfd, release_unit.cmd, release_unit.size, NULL, 0); DBG (10, "scanner released\n"); return 0; } static int coolscan_set_window_param_LS20 (Coolscan_t * s, int prescan) { unsigned char buffer_r[max_WDB_size]; int ret; wait_scanner (s); memset (buffer_r, '\0', max_WDB_size); /* clear buffer */ memcpy (buffer_r, window_descriptor_block.cmd, window_descriptor_block.size); /* copy preset data */ set_WD_wid (buffer_r, WD_wid_all); /* window identifier */ set_WD_auto (buffer_r, s->set_auto); /* 0 or 1: don't know what it is */ set_WD_negative (buffer_r, s->negative); /* Negative/positive slide */ if (prescan) { set_WD_scanmode (buffer_r, WD_Prescan); } else { set_WD_scanmode (buffer_r, WD_Scan); /* geometry */ set_WD_Xres (buffer_r, resDivToVal (s->x_nres)); /* x resolution in dpi */ set_WD_Yres (buffer_r, resDivToVal (s->y_nres)); /* y resolution in dpi */ /* the coolscan uses the upper right corner as the origin of coordinates */ /* xmax and ymax are given in 1200 dpi */ set_WD_ULX (buffer_r, (s->xmaxpix - s->brx)); set_WD_ULY (buffer_r, s->tly); /* upper_edge y */ set_WD_width (buffer_r, (s->brx - s->tlx + 1)); set_WD_length (buffer_r, (s->bry - s->tly + 1)); /* BTC */ if (s->brightness == 128) { set_WD_brightness (buffer_r, 0); } else { set_WD_brightness (buffer_r, s->brightness); /* brightness */ } if (s->contrast == 128) { set_WD_contrast (buffer_r, 0); } else { set_WD_contrast (buffer_r, s->contrast); /* contrast */ } /* scanmode */ if (s->colormode == GREYSCALE) set_WD_composition (buffer_r, WD_comp_grey); /* GRAY composition */ else set_WD_composition (buffer_r, WD_comp_rgb_full); /* RGB composition */ set_WD_dropoutcolor (buffer_r, s->dropoutcolor); /* Which color to scan with when grayscale scan */ set_WD_transfermode (buffer_r, WD_LineSequence); set_WD_gammaselection (buffer_r, s->gammaselection); /* monitor/linear */ set_WD_shading (buffer_r, WD_Shading_ON); /* default for non-manufacturing */ if (1 == s->LS) { /* Analog gamma reserved on LS-1000 */ set_WD_analog_gamma_R (buffer_r, 0); set_WD_analog_gamma_G (buffer_r, 0); set_WD_analog_gamma_R (buffer_r, 0); } else { /* Quote spec: "It is recomended that analog gamma bits 5, 4 and 3 be * set to 1 (OFF) when the object type of byte 48 is positive and the * gamma specificateion of byte 51 is linear, and to 0 (ON) in all * other cases." */ /* int foo; if ((buffer_r[48] == WD_Positive) && (buffer_r[51] == WD_Linear)) foo = WD_Analog_Gamma_OFF; else foo = WD_Analog_Gamma_ON; set_WD_analog_gamma_R (buffer_r, foo); set_WD_analog_gamma_G (buffer_r, foo); set_WD_analog_gamma_B (buffer_r, foo); */ set_WD_analog_gamma_R (buffer_r, s->analog_gamma_r); set_WD_analog_gamma_G (buffer_r, s->analog_gamma_g); set_WD_analog_gamma_B (buffer_r, s->analog_gamma_b); if (s->gamma_bind) { set_WD_LUT_R (buffer_r, 1); set_WD_LUT_G (buffer_r, 1); set_WD_LUT_B (buffer_r, 1); } else { set_WD_LUT_R (buffer_r, 1); set_WD_LUT_G (buffer_r, 2); set_WD_LUT_B (buffer_r, 3); } } set_WD_averaging (buffer_r, s->averaging); set_WD_brightness_R (buffer_r, s->brightness_R); set_WD_brightness_G (buffer_r, s->brightness_G); set_WD_brightness_B (buffer_r, s->brightness_B); set_WD_contrast_R (buffer_r, s->contrast_R); set_WD_contrast_G (buffer_r, s->contrast_G); set_WD_contrast_B (buffer_r, s->contrast_B); set_WD_exposure_R (buffer_r, s->exposure_R); set_WD_exposure_G (buffer_r, s->exposure_G); set_WD_exposure_B (buffer_r, s->exposure_B); set_WD_shift_R (buffer_r, s->shift_R); set_WD_shift_G (buffer_r, s->shift_G); set_WD_shift_B (buffer_r, s->shift_B); /* FIXME: LUT-[RGB] */ /* FIXME: stop on/off */ } DBG (10, "\tx_nres=%d, y_nres=%d, upper left-x=%d, upper left-y=%d\n", s->x_nres, s->y_nres, s->tlx, s->tly); DBG (10, "\twindow width=%d, MUD=%d, brx=%d\n", s->brx - s->tlx, s->MUD, s->brx); DBG (10, "\tcolormode=%d, bits per pixel=%d\n", s->colormode, s->bits_per_color); DBG (10, "\tnegative=%d, dropoutcolor=%d, preview=%d, transfermode=%d, gammasel=%d\n", s->negative, s->dropoutcolor, s->preview, s->transfermode, s->gammaselection); /* prepare SCSI-BUFFER */ memcpy (s->buffer, set_window.cmd, set_window.size); /* SET-WINDOW cmd */ memcpy ((s->buffer + set_window.size), /* add WPDB */ window_parameter_data_block.cmd, window_parameter_data_block.size); set_WPDB_wdblen ((s->buffer + set_window.size), used_WDB_size); /* set WD_len */ memcpy (s->buffer + set_window.size + window_parameter_data_block.size, buffer_r, window_descriptor_block.size); hexdump (15, "Window set", buffer_r, s->wdb_len); set_SW_xferlen (s->buffer, (window_parameter_data_block.size + window_descriptor_block.size)); ret = do_scsi_cmd (s->sfd, s->buffer, set_window.size + window_parameter_data_block.size + window_descriptor_block.size, NULL, 0); DBG (10, "window set.\n"); return ret; } static int coolscan_set_window_param_LS30 (Coolscan_t * s, int wid, int prescan) { unsigned char buffer_r[max_WDB_size]; int ret; wait_scanner (s); memset (buffer_r, '\0', max_WDB_size); /* clear buffer */ memcpy (buffer_r, window_descriptor_block_LS30.cmd, window_descriptor_block_LS30.size); /* copy preset data */ set_WD_wid (buffer_r, wid); /* window identifier */ set_WD_auto (buffer_r, s->set_auto); /* 0 or 1: don't know what it is */ /* geometry */ set_WD_Xres (buffer_r, resDivToVal (s->x_nres)); /* x resolution in dpi */ set_WD_Yres (buffer_r, resDivToVal (s->y_nres)); /* y resolution in dpi */ if (prescan) { set_WD_scanmode_LS30 (buffer_r, WD_Prescan); set_WD_Xres (buffer_r, resDivToVal (1)); /* x res. in dpi */ set_WD_Yres (buffer_r, resDivToVal (1)); /* y res. in dpi */ buffer_r[0x29]=0x81; buffer_r[0x2a]=0x04; buffer_r[0x2b]=0x02; buffer_r[0x2c]=0x01; buffer_r[0x2d]=0xff; buffer_r[0x30]=0x00; buffer_r[0x31]=0x00; buffer_r[0x32]=0x00; buffer_r[0x33]=0x00; set_WD_width (buffer_r,(2592)); set_WD_length (buffer_r,(3894)); } else { set_WD_scanmode_LS30 (buffer_r, WD_Scan); /* the coolscan LS-30 uses the upper left corner as the origin of coordinates */ /* xmax and ymax are given in 1200 dpi */ set_WD_ULX (buffer_r, s->tlx); set_WD_ULY (buffer_r, s->tly); /* upper_edge y */ set_WD_width (buffer_r, (s->brx - s->tlx+1)); set_WD_length (buffer_r, (s->bry - s->tly+1)); /* BTC */ if (s->brightness == 128) { buffer_r[0x32]=0x00; } else { buffer_r[0x32]=s->brightness; /* brightness */ } if (s->contrast == 128) { buffer_r[0x33]=0x00; } else { buffer_r[0x33]=s->contrast; /* contrast */ } /* scanmode */ if (s->colormode == GREYSCALE) set_WD_composition (buffer_r, WD_comp_grey); /* GRAY composition */ else set_WD_composition (buffer_r, WD_comp_rgb_full); /* RGB composition */ set_WD_composition (buffer_r, WD_comp_rgb_full); /* allways RGB composition */ /* Bits per pixel */ set_WD_bitsperpixel(buffer_r, s->bits_per_color); buffer_r[0x29]=0x81; buffer_r[0x2a]=0x01; buffer_r[0x2b]=0x02; buffer_r[0x2c]=0x01; buffer_r[0x2d]=0xff; buffer_r[0x30]=0x00; } set_WD_negative_LS30(buffer_r, s->negative); /* Negative/positive slide */ switch(wid) { case 1: set_gain_LS30(buffer_r,(s->exposure_R*s->pretv_r)/50); break; case 2: set_gain_LS30(buffer_r,(s->exposure_G*s->pretv_g)/50); break; case 3: set_gain_LS30(buffer_r,(s->exposure_B*s->pretv_b)/50); break; } DBG (10, "\texpo_r=%d, expo_g=%d, expob=%d\n", s->exposure_R, s->exposure_G, s->exposure_B); DBG (10, "\tpre_r=%d, pre_g=%d, preb=%d\n", s->pretv_r, s->pretv_g, s->pretv_b); DBG (10, "\tx_nres=%d, y_nres=%d, upper left-x=%d, upper left-y=%d\n", s->x_nres, s->y_nres, s->tlx, s->tly); DBG (10, "\twindow width=%d, MUD=%d, brx=%d\n", s->brx - s->tlx, s->MUD, s->brx); DBG (10, "\tcolormode=%d, bits per pixel=%d\n", s->colormode, s->bits_per_color); DBG (10, "\tnegative=%d, dropoutcolor=%d, preview=%d, transfermode=%d, gammasel=%d\n", s->negative, s->dropoutcolor, s->preview, s->transfermode, s->gammaselection); /* prepare SCSI-BUFFER */ memcpy (s->buffer, set_window.cmd, set_window.size); /* SET-WINDOW cmd */ memcpy ((s->buffer + set_window.size), /* add WPDB */ window_parameter_data_block.cmd, window_parameter_data_block.size); set_WPDB_wdblen ((s->buffer + set_window.size), used_WDB_size_LS30); /* set WD_len */ memcpy (s->buffer + set_window.size + window_parameter_data_block.size, buffer_r, window_descriptor_block_LS30.size); hexdump (15, "Window set", buffer_r, s->wdb_len); set_SW_xferlen (s->buffer, (window_parameter_data_block.size + window_descriptor_block_LS30.size)); ret = do_scsi_cmd (s->sfd, s->buffer, set_window.size + window_parameter_data_block.size + window_descriptor_block_LS30.size, NULL, 0); DBG (10, "window set.\n"); return ret; } static int coolscan_set_window_param (Coolscan_t * s, int prescan) { int ret; ret=0; DBG (10, "set_window_param\n"); if(s->LS<2) /* distinquish between old and new scanners */ { ret=coolscan_set_window_param_LS20 (s,prescan); } else { do_scsi_cmd (s->sfd,commande1.cmd,commande1.size,s->buffer,0x0d); wait_scanner (s); wait_scanner (s); coolscan_set_window_param_LS30(s,1,prescan); ret=coolscan_set_window_param_LS30(s,2,prescan); ret=coolscan_set_window_param_LS30(s,3,prescan); if(s->colormode&0x08) { ret=coolscan_set_window_param_LS30(s,9,prescan); } } return ret; } /* * The only purpose of get_window is debugging. None of the return parameters * is currently used. */ static int coolscan_get_window_param_LS30 (Coolscan_t * s, int wid,int prescanok) { int translen; unsigned char *buf; DBG (10, "GET_WINDOW_PARAM\n"); /* wait_scanner (s); */ translen = window_parameter_data_block.size + window_descriptor_block_LS30.size; /* prepare SCSI-BUFFER */ memset (s->buffer, '\0', max_WDB_size); /* clear buffer */ set_SW_xferlen (get_window.cmd, translen); /* Transfer length */ get_window.cmd[5]= wid; /* window identifier */ hexdump (15, "Get window cmd", get_window.cmd, get_window.size); do_scsi_cmd (s->sfd, get_window.cmd, get_window.size, s->buffer, translen); buf = s->buffer + window_parameter_data_block.size; hexdump (10, "Window get", buf, 117); s->brightness = buf[0x32]; /* brightness */ s->contrast = buf[0x33]; /* contrast */ DBG (10, "\tbrightness=%d, contrast=%d\n", s->brightness, s->contrast); /* Useful? */ s->bits_per_color = get_WD_bitsperpixel (buf); /* bits/pixel (8) */ DBG (10, "\tcolormode=%d, bits per pixel=%d\n", s->colormode, s->bits_per_color); if(prescanok) { switch(wid) { case 1: s->pretv_r = get_gain_LS30(buf); break; case 2: s->pretv_g = get_gain_LS30(buf); break; case 3: s->pretv_b = get_gain_LS30(buf); break; } } /* Should this one be set at all, here? */ s->transfermode = get_WD_transfermode (buf); s->gammaselection = get_WD_gammaselection (buf); /* monitor/linear */ DBG (10, "\tpre_r=%d, pre_g=%d, preb=%d\n", s->pretv_r, s->pretv_g, s->pretv_b); DBG (5, "\tnegative=%d, dropoutcolor=%d, preview=%d, transfermode=%d, gammasel=%d\n", s->negative, s->dropoutcolor, s->preview, s->transfermode, s->gammaselection); DBG (10, "get_window_param - return\n"); return 0; } /* * The only purpose of get_window is debugging. None of the return parameters * is currently used. */ static int coolscan_get_window_param_LS20 (Coolscan_t * s) { int translen; unsigned char *buf; DBG (10, "GET_WINDOW_PARAM\n"); wait_scanner (s); translen = window_parameter_data_block.size + window_descriptor_block.size; /* prepare SCSI-BUFFER */ memset (s->buffer, '\0', max_WDB_size); /* clear buffer */ set_SW_xferlen (get_window.cmd, translen); /* Transfer length */ hexdump (15, "Get window cmd", get_window.cmd, get_window.size); do_scsi_cmd (s->sfd, get_window.cmd, get_window.size, s->buffer, translen); buf = s->buffer + window_parameter_data_block.size; hexdump (10, "Window get", buf, 117); /* BTC */ s->brightness = get_WD_brightness (buf); /* brightness */ s->contrast = get_WD_contrast (buf); /* contrast */ DBG (10, "\tbrightness=%d, contrast=%d\n", s->brightness, s->contrast); if (WD_comp_gray == get_WD_composition (buf)) s->colormode = GREYSCALE; else s->colormode = RGB; /* Useful? */ s->bits_per_color = get_WD_bitsperpixel (buf); /* bits/pixel (8) */ DBG (10, "\tcolormode=%d, bits per pixel=%d\n", s->colormode, s->bits_per_color); s->dropoutcolor = get_WD_dropoutcolor (buf); /* Which color to scan with when grayscale scan */ /* Should this one be set at all, here? */ s->transfermode = get_WD_transfermode (buf); s->gammaselection = get_WD_gammaselection (buf); /* monitor/linear */ DBG (5, "\tnegative=%d, dropoutcolor=%d, preview=%d, transfermode=%d, gammasel=%d\n", s->negative, s->dropoutcolor, s->preview, s->transfermode, s->gammaselection); /* Should this one be set at all? */ s->shading = get_WD_shading (buf); s->averaging = get_WD_averaging (buf); DBG (10, "get_window_param - return\n"); return 0; } /* * The only purpose of get_window is debugging. None of the return parameters * is currently used. */ static int coolscan_get_window_param (Coolscan_t * s, int prescanok) { int ret; DBG (10, "get_window_param\n"); ret=0; if(s->LS<2) /* distinquish between old and new scanners */ { ret=coolscan_get_window_param_LS20 (s); } else { ret=coolscan_get_window_param_LS30(s,1,prescanok); ret=coolscan_get_window_param_LS30(s,2,prescanok); ret=coolscan_get_window_param_LS30(s,3,prescanok); if(s->colormode&0x08) { ret=coolscan_get_window_param_LS30(s,9,prescanok); } } return ret; } static int coolscan_start_scanLS30 (Coolscan_t * s) { int channels; DBG (10, "starting scan\n"); channels=1; memcpy (s->buffer, scan.cmd, scan.size); switch(s->colormode) { case RGB: case GREYSCALE: channels=s->buffer[4]=0x03; /* window 1 */ s->buffer[6]=0x01; /* window 1 */ s->buffer[7]=0x02; /* window 2 */ s->buffer[8]=0x03; /* window 3 */ break; case RGBI: channels=s->buffer[4]=0x04; /* window 1 */ s->buffer[6]=0x01; /* window 1 */ s->buffer[7]=0x02; /* window 2 */ s->buffer[8]=0x03; /* window 3 */ s->buffer[9]=0x09; /* window 3 */ break; case IRED: channels=s->buffer[4]=0x01; /* window 1 */ s->buffer[8]=0x09; /* window 3 */ break; } return do_scsi_cmd (s->sfd, s->buffer, scan.size+channels, NULL, 0); } static int coolscan_start_scan (Coolscan_t * s) { DBG (10, "starting scan\n"); if(s->LS>=2) { return coolscan_start_scanLS30(s); } return do_scsi_cmd (s->sfd, scan.cmd, scan.size, NULL, 0); } static int prescan (Coolscan_t * s) { int ret; DBG (10, "Starting prescan...\n"); if(s->LS<2) { coolscan_set_window_param (s, 1); } else { do_scsi_cmd (s->sfd,commande1.cmd,commande1.size,s->buffer,0x0d); wait_scanner (s); wait_scanner (s); coolscan_set_window_param_LS30 (s,1,1); coolscan_set_window_param_LS30 (s,2,1); coolscan_set_window_param_LS30 (s,3,1); } ret = coolscan_start_scan(s); sleep(8); /* prescan takes a minimum of 10 sec. */ wait_scanner (s); DBG (10, "Prescan done\n"); return ret; } static SANE_Status do_prescan_now (Coolscan_t * scanner) { DBG (10, "do_prescan_now \n"); if (scanner->scanning == SANE_TRUE) return SANE_STATUS_DEVICE_BUSY; if (scanner->sfd < 0) { /* first call */ if (sanei_scsi_open (scanner->sane.name, &(scanner->sfd), sense_handler, 0) != SANE_STATUS_GOOD) { DBG (1, "do_prescan_now: open of %s failed:\n", scanner->sane.name); return SANE_STATUS_INVAL; } } scanner->scanning = SANE_TRUE; if (coolscan_check_values (scanner) != 0) { /* Verify values */ DBG (1, "ERROR: invalid scan-values\n"); scanner->scanning = SANE_FALSE; coolscan_give_scanner (scanner); sanei_scsi_close (scanner->sfd); scanner->sfd = -1; return SANE_STATUS_INVAL; } if (coolscan_grab_scanner (scanner)) { sanei_scsi_close (scanner->sfd); scanner->sfd = -1; DBG (5, "WARNING: unable to reserve scanner: device busy\n"); scanner->scanning = SANE_FALSE; return SANE_STATUS_DEVICE_BUSY; } prescan (scanner); if(scanner->LS<2) { get_internal_info(scanner); } coolscan_get_window_param (scanner,1); scanner->scanning = SANE_FALSE; coolscan_give_scanner (scanner); return SANE_STATUS_GOOD; } static int send_one_LUT (Coolscan_t * s, SANE_Word * LUT, int reg) { int i; short lutval; short bytesperval; unsigned char *gamma, *gamma_p; unsigned short *gamma_s; DBG (10, "send LUT\n"); if(s->LS<2) { set_S_datatype_code (send.cmd, R_user_reg_gamma); bytesperval=1; } else { send.cmd[0x02]=3; send.cmd[0x05]=1; bytesperval=2; } set_S_xfer_length (send.cmd, s->lutlength*bytesperval); set_S_datatype_qual_upper (send.cmd, reg); gamma = alloca (send.size + s->lutlength*2); memcpy (gamma, send.cmd, send.size); if(s->LS<2) { gamma_p = &gamma[send.size]; for (i = 0; i < s->lutlength; i++) { if (LUT[i] > 255) LUT[i] = 255; /* broken gtk */ *gamma_p++ = (unsigned char) LUT[i]; } } else if(s->LS==2) { gamma_s = (unsigned short*)( &gamma[send.size]); for (i = 0; i < s->lutlength; i++) { if(s->negative) { lutval=(unsigned short)(LUT[(s->lutlength-i)]); } else { lutval=(unsigned short)(LUT[i]); } if (LUT[i] >= s->max_lut_val) LUT[i] = s->max_lut_val-1; /* broken gtk */ if(s->low_byte_first) /* if on little endian machine: */ { lutval=((lutval&0x00ff)<<8)+((lutval&0xff00)>>8); /* inverse byteorder */ } *gamma_s++ = lutval; } } else if(s->LS==3) { gamma_s = (unsigned short*)( &gamma[send.size]); for (i = 0; i < s->lutlength; i++) { if(s->negative) { lutval=(unsigned short)(LUT[s->lutlength-i]); } else { lutval=(unsigned short)(LUT[i]); } if (LUT[i] >= s->max_lut_val) LUT[i] = s->max_lut_val-1; /* broken gtk */ if(s->low_byte_first) /* if on little endian machine: */ { lutval=((lutval&0x00ff)<<8)+((lutval&0xff00)>>8); /* inverse byteorder */ } *gamma_s++ = lutval; } } return do_scsi_cmd (s->sfd, gamma, send.size + s->lutlength*bytesperval, NULL, 0); } static int send_LUT (Coolscan_t * s) { wait_scanner (s); if (s->gamma_bind) { send_one_LUT (s, s->gamma, S_DQ_Reg1); if(s->LS>=2) { send_one_LUT (s, s->gamma, S_DQ_Reg2); send_one_LUT (s, s->gamma, S_DQ_Reg3); if(s->colormode&0x08) { send_one_LUT (s, s->gamma, S_DQ_Reg9); } } } else { send_one_LUT (s, s->gamma_r, S_DQ_Reg1); send_one_LUT (s, s->gamma_g, S_DQ_Reg2); send_one_LUT (s, s->gamma_b, S_DQ_Reg3); if(s->colormode&0x08) { send_one_LUT (s, s->gamma_r, S_DQ_Reg9); } } return 0; } static int coolscan_read_data_block (Coolscan_t * s, unsigned int datatype, unsigned int length) { int r; DBG (10, "read_data_block (type= %x length = %d)\n",datatype,length); /*wait_scanner(s); */ set_R_datatype_code (sread.cmd, datatype); sread.cmd[4]=00; sread.cmd[5]=00; set_R_xfer_length (sread.cmd, length); r = do_scsi_cmd (s->sfd, sread.cmd, sread.size, s->buffer, length); return ((r != 0) ? -1 : (int) length); } static void coolscan_do_inquiry (Coolscan_t * s) { int size; DBG (10, "do_inquiry\n"); memset (s->buffer, '\0', 256); /* clear buffer */ size = 36; /* Hardcoded, and as specified by Nikon */ /* then get inquiry with actual size */ set_inquiry_return_size (inquiry.cmd, size); do_scsi_cmd (s->sfd, inquiry.cmd, inquiry.size, s->buffer, size); } static int coolscan_identify_scanner (Coolscan_t * s) { unsigned char vendor[9]; unsigned char product[0x11]; unsigned char version[5]; unsigned char *pp; int i; vendor[8] = product[0x10] = version[4] = 0; DBG (10, "identify_scanner\n"); coolscan_do_inquiry (s); /* get inquiry */ if (get_inquiry_periph_devtype (s->buffer) != IN_periph_devtype_scanner) { DBG (5, "identify_scanner: not a scanner\n"); return 1; } /* no, continue searching */ coolscan_get_inquiry_values (s); get_inquiry_vendor ((char *)s->buffer, (char *)vendor); get_inquiry_product ((char *)s->buffer, (char *)product); get_inquiry_version ((char *)s->buffer, (char *)version); if (strncmp ("Nikon ", (char *)vendor, 8)) { DBG (5, "identify_scanner: \"%s\" isn't a Nikon product\n", vendor); return 1; } /* Not a Nikon product */ pp = &vendor[8]; vendor[8] = ' '; while (*pp == ' ') { *pp-- = '\0'; } pp = &product[0x10]; product[0x10] = ' '; while (*(pp - 1) == ' ') { *pp-- = '\0'; } /* leave one blank at the end! */ pp = &version[4]; version[4] = ' '; while (*pp == ' ') { *pp-- = '\0'; } DBG (10, "Found Nikon scanner %sversion %s on device %s\n", product, version, s->devicename); /* look for scanners that do not give all inquiry-informations */ /* and if possible use driver-known inquiry-data */ if (get_inquiry_additional_length (s->buffer) >= 0x1f) { /* Now identify full supported scanners */ for (i = 0; i < known_scanners; i++) { if (!strncmp ((char *)product, scanner_str[i], strlen (scanner_str[i]))) { s->LS = i; return 0; } } if (s->cont) return 0; else return 1; } else return 1; } static int pixels_per_line (Coolscan_t * s) { int pic_dot; if(s->LS<2) { pic_dot = (s->brx - s->tlx + s->x_nres) / s->x_nres; } else { pic_dot = (s->brx - s->tlx + 1) / s->x_nres; } DBG (10, "pic_dot=%d\n", pic_dot); return pic_dot; } static int lines_per_scan (Coolscan_t * s) { int pic_line; if(s->LS<2) { pic_line = (s->bry - s->tly + s->y_nres) / s->y_nres; } else { pic_line = (( s->bry - s->tly + 1.0 ) / s->y_nres); } DBG (10, "pic_line=%d\n", pic_line); return pic_line; } static int scan_bytes_per_line (Coolscan_t * s) { int bpl; switch(s->colormode) { case RGB: case GREYSCALE: bpl=pixels_per_line (s) * 3; if(s->bits_per_color>8) bpl=bpl*2; return bpl; break; case RGBI: case IRED: bpl=pixels_per_line (s) * 4; if(s->bits_per_color>8) bpl=bpl*2; return bpl; break; } return 0; } static int write_bytes_per_line (Coolscan_t * s) { int bpl; switch(s->colormode) { case RGB: bpl=pixels_per_line (s) * 3; if(s->bits_per_color>8) bpl=bpl*2; return bpl; break; case RGBI: bpl=pixels_per_line (s) * 4; if(s->bits_per_color>8) bpl=bpl*2; return bpl; break; case IRED: case GREYSCALE: bpl= pixels_per_line (s) ; if(s->bits_per_color>8) bpl=bpl*2; return bpl; break; } return 0; } static void coolscan_trim_rowbufsize (Coolscan_t * s) { unsigned int row_len; row_len = scan_bytes_per_line (s); s->row_bufsize = (s->row_bufsize < row_len) ? s->row_bufsize : s->row_bufsize - (s->row_bufsize % row_len); DBG (10, "trim_bufsize to %d\n", s->row_bufsize); } static int coolscan_check_values (Coolscan_t * s) { DBG (10, "check_values\n"); /* -------------------------- asf --------------------------------- */ if (s->asf != 0) { if (s->autofeeder == 0) { DBG (1, "ERROR: ASF-MODE NOT SUPPORTED BY SCANNER, ABORTING\n"); return (1); } } return (0); } /* test_little_endian */ static SANE_Bool coolscan_test_little_endian(void) { SANE_Int testvalue = 255; unsigned char *firstbyte = (unsigned char *) &testvalue; if (*firstbyte == 255) { return SANE_TRUE; } return SANE_FALSE; } static int get_inquiery_part_LS30 (Coolscan_t * s, unsigned char part) { int size; /* Get length of reponse */ inquiry.cmd[1]=0x01; inquiry.cmd[2]=part; size=4; set_inquiry_return_size (inquiry.cmd, 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); do_scsi_cmd (s->sfd, inquiry.cmd, inquiry.size, s->buffer, size); return size; } static int coolscan_read_var_data_block (Coolscan_t * s,int datatype) { int r; int size; DBG (10, "read_data_block (type= %x)\n",datatype); /*wait_scanner(s); */ sread.cmd[2]=datatype; sread.cmd[4]=00; sread.cmd[5]=03; size=6; set_R_xfer_length (sread.cmd, size); r = do_scsi_cmd (s->sfd, sread.cmd, sread.size, s->buffer, size); size=s->buffer[5]; set_R_xfer_length (sread.cmd, size); r = do_scsi_cmd (s->sfd, sread.cmd, sread.size, s->buffer, size); return ((r != 0) ? -1 : size); } static int get_inquiery_LS30 (Coolscan_t * s) { unsigned char part; unsigned char parts[5]; int i; /* Get vector of inquiery parts */ 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]; get_inquiery_part_LS30 (s, part); switch(part) { case 0x0c1:/* max size and resolution */ s->adbits = 8; s->outputbits = 8; s->maxres = getnbyte(s->buffer+0x12,2)-1; s->xmaxpix = getnbyte(s->buffer+0x53,2)-1; s->ymaxpix = getnbyte(s->buffer+0x3c,2)-1; break; case 0x0d1: break; case 0x0e1: break; case 0x0f0: break; case 0x0f8: break; } } /* get windows */ coolscan_get_window_param_LS30 (s,0,0); s->xmax = get_WD_width(s->buffer); s->ymax = get_WD_length(s->buffer); coolscan_get_window_param_LS30 (s,1,0); coolscan_get_window_param_LS30 (s,2,0); coolscan_get_window_param_LS30 (s,3,0); coolscan_get_window_param_LS30 (s,4,0); coolscan_get_window_param_LS30 (s,9,0); s->analoggamma = 0; return 1; } static int get_feeder_type_LS30 (Coolscan_t * s) { int size; unsigned char *ptr; int ima; /* find out about Film-strip-feeder or Mount-Feeder */ size=get_inquiery_part_LS30(s, (unsigned char) 1); if(strncmp((char *)s->buffer+5,"Strip",5)==0) { s->feeder=STRIP_FEEDER; s->autofeeder = 1; } if(strncmp((char *)s->buffer+5,"Mount",5)==0) { s->feeder=MOUNT_FEEDER; } /* find out about Film-strip-feeder positions*/ if(s->feeder==STRIP_FEEDER) { size=coolscan_read_var_data_block (s,(int)0x88); if(size>=4) { s->numima=s->buffer[3]; if(s->numima>6) s->numima=6; /* limit to 6 images for now */ if(s->numima>(size-4)/16) s->numima=(size-4)/16; ptr=s->buffer+4; for(ima=0;imanumima;ima++) { s->ipos[ima].start=getnbyte(ptr,4); s->ipos[ima].offset=getnbyte(ptr+4,4); s->ipos[ima].end=getnbyte(ptr+8,4); s->ipos[ima].height=getnbyte(ptr+12,4); ptr+=16; } } s->posima=0; } return 1; } static int get_internal_info_LS20 (Coolscan_t * s) { int ret; DBG (10, "get_internal_info\n"); wait_scanner (s); memset (s->buffer, '\0', DI_length); /* clear buffer */ set_R_datatype_code (sread.cmd, R_device_internal_info); set_R_datatype_qual_upper (sread.cmd, R_DQ_none); set_R_xfer_length (sread.cmd, DI_length); /* then get inquiry with actual size */ ret = do_scsi_cmd (s->sfd, sread.cmd, sread.size, s->buffer, DI_length); s->adbits = get_DI_ADbits (s->buffer); s->outputbits = get_DI_Outputbits (s->buffer); s->maxres = get_DI_MaxResolution (s->buffer); s->xmax = get_DI_Xmax (s->buffer); s->ymax = get_DI_Ymax (s->buffer); s->xmaxpix = get_DI_Xmaxpixel (s->buffer); s->ymaxpix = get_DI_Ymaxpixel (s->buffer); s->ycurrent = get_DI_currentY (s->buffer); s->currentfocus = get_DI_currentFocus (s->buffer); s->currentscanpitch = get_DI_currentscanpitch (s->buffer); s->autofeeder = get_DI_autofeeder (s->buffer); s->analoggamma = get_DI_analoggamma (s->buffer); s->derr[0] = get_DI_deviceerror0 (s->buffer); s->derr[1] = get_DI_deviceerror1 (s->buffer); s->derr[2] = get_DI_deviceerror2 (s->buffer); s->derr[3] = get_DI_deviceerror3 (s->buffer); s->derr[4] = get_DI_deviceerror4 (s->buffer); s->derr[5] = get_DI_deviceerror5 (s->buffer); s->derr[6] = get_DI_deviceerror6 (s->buffer); s->derr[7] = get_DI_deviceerror7 (s->buffer); s->wbetr_r = get_DI_WBETR_R (s->buffer); s->webtr_g = get_DI_WBETR_G (s->buffer); s->webtr_b = get_DI_WBETR_B (s->buffer); s->pretv_r = get_DI_PRETV_R (s->buffer); s->pretv_g = get_DI_PRETV_G (s->buffer); s->pretv_r = get_DI_PRETV_R (s->buffer); s->cetv_r = get_DI_CETV_R (s->buffer); s->cetv_g = get_DI_CETV_G (s->buffer); s->cetv_b = get_DI_CETV_B (s->buffer); s->ietu_r = get_DI_IETU_R (s->buffer); s->ietu_g = get_DI_IETU_G (s->buffer); s->ietu_b = get_DI_IETU_B (s->buffer); s->limitcondition = get_DI_limitcondition (s->buffer); s->offsetdata_r = get_DI_offsetdata_R (s->buffer); s->offsetdata_g = get_DI_offsetdata_G (s->buffer); s->offsetdata_b = get_DI_offsetdata_B (s->buffer); get_DI_poweron_errors (s->buffer, s->power_on_errors); DBG (10, "\tadbits=%d\toutputbits=%d\tmaxres=%d\txmax=%d\tymax=%d\n" "\txmaxpix=%d\tymaxpix=%d\tycurrent=%d\tcurrentfocus=%d\n" "\tautofeeder=%s\tanaloggamma=%s\tcurrentscanpitch=%d\n", s->adbits, s->outputbits, s->maxres, s->xmax, s->ymax, s->xmaxpix, s->ymaxpix, s->ycurrent, s->currentfocus, s->autofeeder ? "Yes" : "No", s->analoggamma ? "Yes" : "No", s->currentscanpitch); DBG (10, "\tWhite balance exposure time var [RGB]=\t%d %d %d\n" "\tPrescan result exposure time var [RGB]=\t%d %d %d\n" "\tCurrent exposure time var.[RGB]=\t%d %d %d\n" "\tInternal exposure time unit[RGB]=\t%d %d %d\n", s->wbetr_r, s->webtr_g, s->webtr_b, s->pretv_r, s->pretv_g, s->pretv_r, s->cetv_r, s->cetv_g, s->cetv_b, s->ietu_r, s->ietu_g, s->ietu_b); DBG (10, "\toffsetdata_[rgb]=\t0x%x 0x%x 0x%x\n" "\tlimitcondition=0x%x\n" "\tdevice error code = 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n" "\tpower-on errors = 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", s->offsetdata_r, s->offsetdata_g, s->offsetdata_b, s->limitcondition, s->derr[0], s->derr[1], s->derr[2], s->derr[3], s->derr[4], s->derr[5], s->derr[6], s->derr[7], s->power_on_errors[0], s->power_on_errors[1], s->power_on_errors[2], s->power_on_errors[3], s->power_on_errors[4], s->power_on_errors[5], s->power_on_errors[6], s->power_on_errors[7]); return ret; } static int get_internal_info (Coolscan_t * s) { int ret; DBG (10, "get_internal_info\n"); if(s->LS<2) /* distinquish between old and new scanners */ { ret=get_internal_info_LS20 (s); } else { ret=get_inquiery_LS30 (s); } return ret; } static void coolscan_get_inquiry_values (Coolscan_t * s) { unsigned char *inquiry_block; DBG (10, "get_inquiry_values\n"); inquiry_block = (unsigned char *) s->buffer; s->inquiry_len = 36; get_inquiry_vendor ((char *)inquiry_block, (char *)s->vendor); s->vendor[8] = '\0'; get_inquiry_product ((char *)inquiry_block, (char *)s->product); s->product[16] = '\0'; get_inquiry_version ((char *)inquiry_block, (char *)s->version); s->version[4] = '\0'; if (s->inquiry_len < 36) { DBG (1, "WARNING: inquiry return block is unexpected short (%d instead of 36).\n", s->inquiry_len); } s->inquiry_wdb_len = 117; return; } static void coolscan_initialize_values (Coolscan_t * s) { int i; DBG (10, "initialize_values\n"); /* Initialize us structure */ if(s->LS<2) /* LS-20 or LS-10000 */ { select_MUD (s); /* must be before mode_sense - not for LS-30*/ coolscan_mode_sense (s); /* Obtain MUD (Measurement Unit Divisor) */ get_internal_info (s); /* MUST be called first. */ s->wdb_len = 117; } if(s->LS>=2) /* LS-30 */ { get_inquiery_LS30(s); /* Info about scanner*/ select_MUD (s); /* must be before mode_sense */ get_feeder_type_LS30(s); s->wdb_len = 117; } s->cont = 0; /* do not continue if scanner is unknown */ s->verbose = 2; /* 1=verbose,2=very verbose */ s->x_nres = s->y_nres = 2; /* 2 => 1350 dpi */ s->x_p_nres = s->y_p_nres = 9; /* 9 => 300 dpi */ s->tlx = 0; s->tly = 0; s->brx = s->xmaxpix; /* 2700 / 1200; */ s->bry = s->ymaxpix; /* 2700 / 1200; */ s->set_auto = 0; /* Always 0 on Nikon LS-{100|2}0 */ s->preview = 0; /* 1 for preview */ s->colormode = RGB; /* GREYSCALE or RGB */ s->colormode_p = RGB; /* GREYSCALE or RGB for preview*/ s->asf = 0; /* 1 if asf shall be used */ s->gammaselection = WD_Linear; s->brightness = 128; s->brightness_R = 128; s->brightness_G = 128; s->brightness_B = 128; s->contrast = 128; s->contrast_R = 128; s->contrast_G = 128; s->contrast_B = 128; s->exposure_R = 50; s->exposure_G = 50; s->exposure_B = 50; s->pretv_r=40000; s->pretv_g=40000; s->pretv_b=40000; s->shift_R = 128; s->shift_G = 128; s->shift_B = 128; s->ired_red=60; s->ired_green=1; s->ired_blue=1; s->prescan = 1; s->bits_per_color = 8; s->rgb_control = 0; s->gamma_bind = 1; switch(s->LS) { case 0:s->lutlength=2048; s->max_lut_val=256; break; case 1:s->lutlength=512; s->max_lut_val=512; break; case 2:s->lutlength=1024; s->max_lut_val=1024; break; case 3:s->lutlength=4096; s->max_lut_val=4096; break; } for (i = 0; i < s->lutlength; i++) { s->gamma[i] =((short)((((double)i)/s->lutlength)*s->max_lut_val)); s->gamma_r[i] = s->gamma[i]; s->gamma_g[i] = s->gamma[i]; s->gamma_b[i] = s->gamma[i]; } if (coolscan_test_little_endian() == SANE_TRUE) { s->low_byte_first = 1; /* in 2 byte mode send lowbyte first */ DBG(10,"backend runs on little endian machine\n"); } else { s->low_byte_first = 0; /* in 2 byte mode send highbyte first */ DBG(10,"backend runs on big endian machine\n"); } } static void hexdump (int level, char *comment, unsigned char *p, int l) { int i; char line[128]; char *ptr; DBG (level, "%s\n", comment); ptr = line; for (i = 0; i < l; i++, p++) { if ((i % 16) == 0) { if (ptr != line) { *ptr = '\0'; DBG (level, "%s\n", line); ptr = line; } sprintf (ptr, "%3.3d:", i); ptr += 4; } sprintf (ptr, " %2.2x", *p); ptr += 3; } *ptr = '\0'; DBG (level, "%s\n", line); } static SANE_Status sense_handler (int scsi_fd, unsigned char * result, void *arg) { scsi_fd = scsi_fd; arg = arg; if (result[0] != 0x70) { return SANE_STATUS_IO_ERROR; /* we only know about this one */ } return request_sense_parse(result); } /* ------------------------------------------------------------------------- */ /* ilu per mm */ #define length_quant SANE_UNFIX(SANE_FIX(MM_PER_INCH / 2700.0)) #define mmToIlu(mm) ((mm) / length_quant) #define iluToMm(ilu) ((ilu) * length_quant) #define P_200_TO_255(per) SANE_UNFIX((per + 100) * 255/200 ) #define P_100_TO_255(per) SANE_UNFIX(per * 255/100 ) static const char negativeStr[] = "Negative"; static const char positiveStr[] = "Positive"; static SANE_String_Const type_list[] = { positiveStr, negativeStr, 0 }; static const char colorStr[] = SANE_VALUE_SCAN_MODE_COLOR; static const char grayStr[] = SANE_VALUE_SCAN_MODE_GRAY; static const char rgbiStr[] = "RGBI"; static const char iredStr[] = "Infrared"; static SANE_String_Const scan_mode_list_LS20[] = { colorStr, grayStr, NULL }; static SANE_String_Const scan_mode_list_LS30[] = { colorStr, grayStr, #ifdef HAS_IRED rgbiStr, #endif /* HAS_IRED */ NULL }; static SANE_Int bit_depth_list[9]; static const char neverStr[] = "never"; static const char previewStr[] = "before preview"; static const char scanStr[] = "before scan"; static const char preandscanStr[] = "before preview and scan"; static SANE_String_Const autofocus_mode_list[] = { neverStr, previewStr, scanStr, preandscanStr, NULL }; static SANE_String_Const source_list[4] = {NULL, NULL, NULL, NULL}; static const SANE_Range gamma_range_8 = { 0, /* minimum */ 255, /* maximum */ 1 /* quantization */ }; static const SANE_Range gamma_range_9 = { 0, /* minimum */ 511, /* maximum */ 1 /* quantization */ }; static const SANE_Range gamma_range_10 = { 0, /* minimum */ 1023, /* maximum */ 1 /* quantization */ }; static const SANE_Range gamma_range_12 = { 0, /* minimum */ 4096, /* maximum */ 1 /* quantization */ }; static const SANE_Range brightness_range = { -5, +5, 1 }; static const SANE_Range contrast_range = { -5, +5, 0 }; static const SANE_Range exposure_range = { 24, 400, 2 }; static const SANE_Range shift_range = { -15, +15, 0 }; static const SANE_Device **devlist = 0; static int num_devices; static Coolscan_t *first_dev; static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } static SANE_Status do_eof (Coolscan_t * scanner) { DBG (10, "do_eof\n"); if (scanner->pipe >= 0) { close (scanner->pipe); scanner->pipe = -1; } return SANE_STATUS_EOF; } static SANE_Status do_cancel (Coolscan_t * scanner) { DBG (10, "do_cancel\n"); swap_res (scanner); scanner->scanning = SANE_FALSE; do_eof (scanner); /* close pipe and reposition scanner */ if (sanei_thread_is_valid (scanner->reader_pid)) { int exit_status; DBG (10, "do_cancel: kill reader_process\n"); /* ensure child knows it's time to stop: */ sanei_thread_kill (scanner->reader_pid); while (sanei_thread_waitpid(scanner->reader_pid, &exit_status) != scanner->reader_pid ); sanei_thread_invalidate (scanner->reader_pid); } if (scanner->sfd >= 0) { coolscan_give_scanner (scanner); DBG (10, "do_cancel: close filedescriptor\n"); sanei_scsi_close (scanner->sfd); scanner->sfd = -1; } return SANE_STATUS_CANCELLED; } static SANE_Status attach_scanner (const char *devicename, Coolscan_t ** devp) { Coolscan_t *dev; int sfd; DBG (10, "attach_scanner: %s\n", devicename); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { if (devp) { *devp = dev; } DBG (5, "attach_scanner: scanner already attached (is ok)!\n"); return SANE_STATUS_GOOD; } } DBG (10, "attach_scanner: opening %s\n", devicename); if (sanei_scsi_open (devicename, &sfd, sense_handler, 0) != 0) { DBG (1, "attach_scanner: open failed\n"); return SANE_STATUS_INVAL; } if (NULL == (dev = malloc (sizeof (*dev)))) return SANE_STATUS_NO_MEM; dev->row_bufsize = (sanei_scsi_max_request_size < (64 * 1024)) ? sanei_scsi_max_request_size : 64 * 1024; if ((dev->buffer = malloc (dev->row_bufsize)) == NULL) /* if ((dev->buffer = malloc (sanei_scsi_max_request_size)) == NULL)*/ return SANE_STATUS_NO_MEM; if ((dev->obuffer = malloc (dev->row_bufsize)) == NULL) return SANE_STATUS_NO_MEM; dev->devicename = strdup (devicename); dev->sfd = sfd; /* Nikon manual: Step 1 */ if (coolscan_identify_scanner (dev) != 0) { DBG (1, "attach_scanner: scanner-identification failed\n"); sanei_scsi_close (dev->sfd); free (dev->buffer); free (dev); return SANE_STATUS_INVAL; } /* Get MUD (via mode_sense), internal info (via get_internal_info), and * initialize values */ coolscan_initialize_values (dev); /* Why? */ sanei_scsi_close (dev->sfd); dev->sfd = -1; dev->sane.name = dev->devicename; dev->sane.vendor = dev->vendor; dev->sane.model = dev->product; dev->sane.type = "slide scanner"; dev->x_range.min = SANE_FIX (0); dev->x_range.quant = SANE_FIX (length_quant); dev->x_range.max = SANE_FIX ((double) ((dev->xmaxpix) * length_quant)); dev->y_range.min = SANE_FIX (0.0); dev->y_range.quant = SANE_FIX (length_quant); dev->y_range.max = SANE_FIX ((double) ((dev->ymaxpix) * length_quant)); /* ...and this?? */ dev->dpi_range.min = SANE_FIX (108); dev->dpi_range.quant = SANE_FIX (0); dev->dpi_range.max = SANE_FIX (dev->maxres); DBG (10, "attach: dev->dpi_range.max = %f\n", SANE_UNFIX (dev->dpi_range.max)); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) { *devp = dev; } DBG (10, "attach_scanner done\n"); return SANE_STATUS_GOOD; } static SANE_Status attach_one (const char *devName) { return attach_scanner(devName, 0); } static void sigterm_handler (int signal) { signal = signal; sanei_scsi_req_flush_all (); /* flush SCSI queue */ _exit (SANE_STATUS_GOOD); } typedef struct Color_correct_s { int sum; /* number of pixels summed so far */ double sumr; /* sum of red pixel values*/ double sumi; /* sum of infrared pixel values*/ double sumri; /* sum of red*ired pixel values*/ double sumii; /* sum of ired*ired pixel values*/ double sumrr; /* sum of ired*ired pixel values*/ int mr; /* factor between red and ired values (*256) */ int br; /* offset of ired values */ } ColorCorrect; /* --------------------------------------------------------------- function: RGBIfix taks: Correct the infrared channel import: unsigned char * rgbimat - RGBI - matrix from scanner int size - number of pixels to correct int *lutr - lookup table for red correction int *lutg - lookup table for red correction int *lutb - lookup table for red correction int *lutr - lookup table for red correction export: unsigned char * orgbimat - RGBI - corrected matrix written by: Andreas RICK 19.6.1999 ----------------------------------------------------------------*/ static int Calc_fix_LUT(Coolscan_t * s) { int uselutr,uselutg,uselutb,useluti; /* static int irmulr= -34*25; */ int irmulr= -64*25; int irmulg= -1*25; int irmulb= -0*25; int irmuli= 256*25; int div; int i; irmulr=s->ired_red*(25); irmulg=s->ired_green*(25); irmulb=s->ired_blue*(25); irmuli=25*256; if(s->LS==2) /* TODO: right conversion factors for 10 and 12 bit */ { div=4; } else if(s->LS==3) { div=16; } else { return 0; } memset(s->lutr, 0,256*4); memset(s->lutg, 0,256*4); memset(s->lutb, 0,256*4); memset(s->luti, 0,256*4); for(i=0;ilutlength;i++) { if(s->gamma_bind) { uselutr=uselutg=uselutb=useluti=s->gamma[i]/div; } else { uselutr=s->gamma_r[i]/div; uselutg=s->gamma_g[i]/div; uselutb=s->gamma_b[i]/div; useluti=s->gamma_r[i]/div; } s->lutr[uselutr]=(int)(irmulr*pow((double)i,(double)0.333333)); s->lutg[uselutg]=(int)(irmulg*pow((double)i,(double)0.333333)); s->lutb[uselutb]=(int)(irmulb*pow((double)i,(double)0.333333)); s->luti[useluti]=(int)(irmuli*pow((double)i,(double)0.333333)); if(uselutr<255) { if(s->lutr[uselutr+1]==0) s->lutr[uselutr+1]=s->lutr[uselutr]; } if(uselutg<255) { if(s->lutg[uselutg+1]==0) s->lutg[uselutg+1]=s->lutg[uselutg]; } if(uselutb<255) { if(s->lutb[uselutb+1]==0) s->lutb[uselutb+1]=s->lutb[uselutb]; } if(useluti<255) { if(s->luti[useluti+1]==0) s->luti[useluti+1]=s->luti[useluti]; } } /* DEBUG for(i=0;i<255;i++) { fprintf(stderr,"%d %d %d %d\n" ,s->lutr[i],s->lutg[i],s->lutb[i],s->luti[i]); } */ return 1; } /* --------------------------------------------------------------- function: RGBIfix taks: Correct the infrared channel import: unsigned char * rgbimat - RGBI - matrix from scanner int size - number of pixels to correct int *lutr - lookup table for red correction int *lutg - lookup table for red correction int *lutb - lookup table for red correction int *lutr - lookup table for red correction export: unsigned char * orgbimat - RGBI - corrected matrix written by: Andreas RICK 19.6.1999 ----------------------------------------------------------------*/ static int RGBIfix(Coolscan_t * scanner, unsigned char* rgbimat, unsigned char* orgbimat, int size, int *lutr, int *lutg, int *lutb, int *luti) { unsigned char *pr,*pg,*pb,*pi; unsigned char *opr,*opg,*opb,*opi; int r,g,b,i; int ii; int x; for(x=0;x255*256)ii=255*256; if(scanner->negative) { (*opi)=(unsigned char)(255-(ii>>8)); } else { (*opi)=(unsigned char)(ii>>8); } } return 1; } /* --------------------------------------------------------------- function: RGBIfix16 taks: Correct the infrared channel for 16 bit images (doesn't do anything for now) import: unsigned char * rgbimat - RGBI - matrix from scanner int size - number of pixels to correct int *lutr - lookup table for red correction int *lutg - lookup table for red correction int *lutb - lookup table for red correction int *lutr - lookup table for red correction export: unsigned char * orgbimat - RGBI - corrected matrix written by: Andreas RICK 19.6.1999 ----------------------------------------------------------------*/ static int RGBIfix16(Coolscan_t * scanner, unsigned short* rgbimat, unsigned short* orgbimat, int size, int *lutr, int *lutg, int *lutb, int *luti) { unsigned short *pr,*pg,*pb,*pi; unsigned short *opr,*opg,*opb,*opi; int x; scanner = scanner; lutr = lutr; lutg = lutg; lutb = lutb; luti = luti; for(x=0;x>8); (*opg)=(((*pg)&0x00ff)<<8)+(((*pg)&0xff00)>>8); (*opb)=(((*pb)&0x00ff)<<8)+(((*pb)&0xff00)>>8); (*opi)=(((*pi)&0x00ff)<<8)+(((*pi)&0xff00)>>8); } return 1; } /* --------------------------------------------------------------- function: rgb2g taks: Convert RGB data to grey import: unsigned char * rgbimat - RGB - matrix from scanner int size - size of input data (num pixel) export: unsigned char * gomat - Grey matrix written by: Andreas RICK 13.7.1999 ----------------------------------------------------------------*/ #define RtoG ((int)(0.27*256)) #define GtoG ((int)(0.54*256)) #define BtoG ((int)(0.19*256)) static int rgb2g(unsigned char* rgbimat,unsigned char* gomat, int size) { unsigned char *pr,*pg,*pb; unsigned char *opg; int g; int x; for(x=0;x>8); } return 1; } /* --------------------------------------------------------------- function: RGBIfix1 taks: Correct the infrared channel. The input image data is the output of scaning with LUT. To calculate the original values the lutr and luti is applied. The infrared values is corrected by: Ir=mr*lutr(r)+luti(i) import: unsigned char * rgbimat - RGBI - matrix from scanner int size - number of pixels to correct ColorCorrect *cc, int *lutr - lookup table for red correction int *luti - lookup table for ired correction export: unsigned char * orgbimat - RGBI - corrected matrix written by: Andreas RICK 3.7.1999 ----------------------------------------------------------------*/ #if 0 static int RGBIfix1(unsigned char* rgbimat,unsigned char* orgbimat, int size, int *lutr, int *lutg, int *lutb, int *luti) { unsigned char *pr,*pg,*pb,*pi; unsigned char *opr,*opg,*opb,*opi; ColorCorrect cc; int r,i; static int thresi=100; int ii; int x; lutg = lutg; lutb = lutb; /* calculate regression between r and ir */ cc.sum=0; cc.sumr=cc.sumii=cc.sumrr=cc.sumi=cc.sumri=0.0; for(x=0;xthresi) { cc.sum++; cc.sumr+=r; cc.sumii+=(i*i); cc.sumrr+=(r*r); cc.sumi+=i; cc.sumri+=(i*r); } } if((cc.sumii!=0)&&(cc.sum!=0)) { double dn,dz,dm; dz=(cc.sumri-cc.sumr*cc.sumi/cc.sum); dn=(cc.sumrr-cc.sumr*cc.sumr/cc.sum); DBG (2, "Reg:dz:%e dn:%e\n",dz,dn); if(dn!=0) { dm=(dz/dn); cc.mr=(int)(dm*1024); } else { cc.mr=0; dm=0; } cc.br=(int)((cc.sumi-dm*cc.sumr)/cc.sum); } else { cc.mr=0; } DBG (2, "Regression: size:%d I=%d/1024*R b:%d s:%d sr:%e si:%e sii:%e sri:%e srr:%e\n", size,cc.mr,cc.br,cc.sum,cc.sumr,cc.sumi,cc.sumii,cc.sumri,cc.sumrr); for(x=0;x>10)-cc.br)>>2) +128; (*opr)=(*pr); (*opg)=(*pg); (*opb)=(*pb); if(ii<0) ii=0; if(ii>255) ii=255; (*opi)=(unsigned char)(ii); } return 1; } #endif /* This function is executed as a child process. */ static int reader_process (void *data ) { int status; unsigned int i; unsigned char h; unsigned int data_left; unsigned int data_to_read; unsigned int data_to_write; FILE *fp; sigset_t sigterm_set, ignore_set; struct SIGACTION act; unsigned int bpl, linesPerBuf, lineOffset; unsigned char r_data, g_data, b_data; unsigned int j, line; Coolscan_t * scanner = (Coolscan_t*)data; if (sanei_thread_is_forked ()) { DBG (10, "reader_process started (forked)\n"); close (scanner->pipe); scanner->pipe = -1; sigfillset ( &ignore_set ); sigdelset ( &ignore_set, SIGTERM ); #if defined (__APPLE__) && defined (__MACH__) sigdelset ( &ignore_set, SIGUSR2 ); #endif sigprocmask( SIG_SETMASK, &ignore_set, 0 ); memset (&act, 0, sizeof (act)); sigaction (SIGTERM, &act, 0); } else { DBG (10, "reader_process started (as thread)\n"); } sigemptyset (&sigterm_set); sigaddset (&sigterm_set, SIGTERM); fp = fdopen ( scanner->reader_fds, "w"); if (!fp) { DBG (1, "reader_process: couldn't open pipe!\n"); return 1; } DBG (10, "reader_process: starting to READ data\n"); data_left = scan_bytes_per_line (scanner) * lines_per_scan (scanner); /*scanner->row_bufsize = sanei_scsi_max_request_size;*/ coolscan_trim_rowbufsize (scanner); /* trim bufsize */ DBG (10, "reader_process: reading %u bytes in blocks of %u bytes\n", data_left, scanner->row_bufsize); memset (&act, 0, sizeof (act)); act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, 0); /* wait_scanner(scanner); */ do { data_to_read = (data_left < scanner->row_bufsize) ? data_left : scanner->row_bufsize; data_to_write=data_to_read; status = coolscan_read_data_block (scanner ,R_datatype_imagedata,data_to_read); if (status == 0) { continue; } if (status == -1) { DBG (1, "reader_process: unable to get image data from scanner!\n"); fclose (fp); return (-1); } if (scanner->LS == 1) { /* mirror image for LS-1000 */ bpl = scan_bytes_per_line(scanner); linesPerBuf = data_to_read / bpl; for (line = 0, lineOffset = 0; line < linesPerBuf; line++, lineOffset += bpl ) { if (scanner->colormode == RGB) { for (j = 0; j < bpl/2 ; j += 3) { r_data=scanner->buffer[lineOffset + j]; g_data=scanner->buffer[lineOffset + j + 1]; b_data=scanner->buffer[lineOffset + j + 2]; scanner->buffer[lineOffset + j] = scanner->buffer[lineOffset + bpl -1 - j - 2 ]; scanner->buffer[lineOffset + j + 1] = scanner->buffer[lineOffset + bpl -1 - j - 1 ]; scanner->buffer[lineOffset + j + 2] = scanner->buffer[lineOffset + bpl -1 - j ]; scanner->buffer[lineOffset + bpl -1 - j - 2 ] = r_data; scanner->buffer[lineOffset + bpl -1 - j - 1] = g_data; scanner->buffer[lineOffset + bpl -1 - j] = b_data; } } else { for (j = 0; j < bpl/2; j++) { r_data=scanner->buffer[lineOffset + j]; scanner->buffer[lineOffset + j] = scanner->buffer[lineOffset + bpl - 1 - j]; scanner->buffer[lineOffset + bpl - 1 - j] = r_data; } } } } if(scanner->colormode==RGBI) { /* Correct Infrared Channel */ if(scanner->bits_per_color>8) { RGBIfix16(scanner, (unsigned short * ) scanner->buffer, (unsigned short * )scanner->obuffer, data_to_read/8,scanner->lutr, scanner->lutg,scanner->lutb,scanner->luti); } else { RGBIfix(scanner,scanner->buffer,scanner->obuffer, data_to_read/4,scanner->lutr, scanner->lutg,scanner->lutb,scanner->luti); } } else if((scanner->colormode==GREYSCALE)&&(scanner->LS>=2)) { /* Convert to Grey */ data_to_write/=3; rgb2g(scanner->buffer,scanner->obuffer,data_to_write); } else { /* or just copy */ memcpy (scanner->obuffer, scanner->buffer,data_to_read); } if((!scanner->low_byte_first)&&(scanner->bits_per_color>8)) { for(i=0;iobuffer[i]; scanner->obuffer[i]=scanner->obuffer[i+1]; i++; scanner->obuffer[i]=h; } } fwrite (scanner->obuffer, 1, data_to_write, fp); fflush (fp); data_left -= data_to_read; DBG (10, "reader_process: buffer of %d bytes read; %d bytes to go\n", data_to_read, data_left); } while (data_left); fclose (fp); DBG (10, "reader_process: finished reading data\n"); return 0; } static SANE_Status init_options (Coolscan_t * scanner) { int i; int bit_depths; DBG (10, "init_options\n"); memset (scanner->opt, 0, sizeof (scanner->opt)); for (i = 0; i < NUM_OPTIONS; ++i) { scanner->opt[i].size = sizeof (SANE_Word); scanner->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } scanner->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; scanner->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; scanner->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; scanner->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; /* "Mode" group: */ scanner->opt[OPT_MODE_GROUP].title = "Scan Mode"; scanner->opt[OPT_MODE_GROUP].desc = ""; scanner->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_MODE_GROUP].cap = 0; scanner->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ scanner->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; scanner->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; scanner->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; scanner->opt[OPT_MODE].type = SANE_TYPE_STRING; if(scanner->LS<2) { scanner->opt[OPT_MODE].size = max_string_size (scan_mode_list_LS20); scanner->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_MODE].constraint.string_list = scan_mode_list_LS20; } else { scanner->opt[OPT_MODE].size = max_string_size (scan_mode_list_LS30); scanner->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_MODE].constraint.string_list = scan_mode_list_LS30; } /* source */ source_list[0] = "Slide"; source_list[1] = "Automatic Slide Feeder"; source_list[2] = NULL; if (!scanner->autofeeder) { scanner->opt[OPT_SOURCE].cap = SANE_CAP_INACTIVE; } scanner->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; scanner->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; scanner->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; scanner->opt[OPT_SOURCE].type = SANE_TYPE_STRING; scanner->opt[OPT_SOURCE].size = max_string_size (source_list); scanner->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_SOURCE].constraint.string_list = source_list; /* negative */ scanner->opt[OPT_TYPE].name = "type"; scanner->opt[OPT_TYPE].title = "Film type"; scanner->opt[OPT_TYPE].desc = "Select the film type (positive (slide) or negative)"; scanner->opt[OPT_TYPE].type = SANE_TYPE_STRING; scanner->opt[OPT_TYPE].size = max_string_size (type_list); scanner->opt[OPT_TYPE].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_TYPE].constraint.string_list = type_list; scanner->opt[OPT_PRESCAN].name = "prescan"; scanner->opt[OPT_PRESCAN].title = "Prescan"; scanner->opt[OPT_PRESCAN].desc = "Perform a prescan during preview"; scanner->opt[OPT_PRESCAN].type = SANE_TYPE_BOOL; scanner->opt[OPT_PRESCAN].unit = SANE_UNIT_NONE; scanner->opt[OPT_PRESCAN_NOW].name = "prescan now"; scanner->opt[OPT_PRESCAN_NOW].title = "Prescan now"; scanner->opt[OPT_PRESCAN_NOW].desc = "Perform a prescan now"; scanner->opt[OPT_PRESCAN_NOW].type = SANE_TYPE_BUTTON; scanner->opt[OPT_PRESCAN_NOW].unit = SANE_UNIT_NONE; scanner->opt[OPT_PRESCAN_NOW].size = 0; scanner->opt[OPT_PRESCAN_NOW].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; scanner->opt[OPT_PRESCAN_NOW].constraint_type = SANE_CONSTRAINT_NONE; scanner->opt[OPT_PRESCAN_NOW].constraint.string_list = 0; /* bit depth */ bit_depths=0; bit_depth_list[++bit_depths] = 8; if (scanner->LS==2) { bit_depth_list[++bit_depths] = 10; } if (scanner->LS==3) { bit_depth_list[++bit_depths] = 12; } bit_depth_list[0] = bit_depths; scanner->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; scanner->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; scanner->opt[OPT_BIT_DEPTH].unit = SANE_UNIT_BIT; scanner->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; scanner->opt[OPT_BIT_DEPTH].constraint.word_list = bit_depth_list; /* resolution */ scanner->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; scanner->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; scanner->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; scanner->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; scanner->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; scanner->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; scanner->opt[OPT_RESOLUTION].constraint.word_list = resolution_list; scanner->opt[OPT_PREVIEW_RESOLUTION].name = "preview-resolution"; scanner->opt[OPT_PREVIEW_RESOLUTION].title = "Preview resolution"; scanner->opt[OPT_PREVIEW_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; scanner->opt[OPT_PREVIEW_RESOLUTION].type = SANE_TYPE_INT; scanner->opt[OPT_PREVIEW_RESOLUTION].unit = SANE_UNIT_DPI; scanner->opt[OPT_PREVIEW_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; scanner->opt[OPT_PREVIEW_RESOLUTION].constraint.word_list = resolution_list; /* "Geometry" group: */ scanner->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; scanner->opt[OPT_GEOMETRY_GROUP].desc = ""; scanner->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; scanner->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ scanner->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; scanner->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; scanner->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; scanner->opt[OPT_TL_X].type = SANE_TYPE_FIXED; scanner->opt[OPT_TL_X].unit = SANE_UNIT_MM; scanner->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_TL_X].constraint.range = &(scanner->x_range); /* top-left y */ scanner->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; scanner->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; scanner->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; scanner->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; scanner->opt[OPT_TL_Y].unit = SANE_UNIT_MM; scanner->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_TL_Y].constraint.range = &(scanner->y_range); /* bottom-right x */ scanner->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; scanner->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; scanner->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; scanner->opt[OPT_BR_X].type = SANE_TYPE_FIXED; scanner->opt[OPT_BR_X].unit = SANE_UNIT_MM; scanner->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BR_X].constraint.range = &(scanner->x_range); /* bottom-right y */ scanner->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; scanner->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; scanner->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; scanner->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; scanner->opt[OPT_BR_Y].unit = SANE_UNIT_MM; scanner->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BR_Y].constraint.range = &(scanner->y_range); /* ------------------------------ */ /* "Enhancement" group: */ scanner->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; scanner->opt[OPT_ENHANCEMENT_GROUP].desc = ""; scanner->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_ENHANCEMENT_GROUP].cap = 0; scanner->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; scanner->opt[OPT_GAMMA_BIND].name = "gamma-bind"; scanner->opt[OPT_GAMMA_BIND].title = "Gamma bind"; scanner->opt[OPT_GAMMA_BIND].desc = "Use same gamma correction for all colours"; scanner->opt[OPT_GAMMA_BIND].type = SANE_TYPE_BOOL; scanner->opt[OPT_GAMMA_BIND].unit = SANE_UNIT_NONE; scanner->opt[OPT_ANALOG_GAMMA].name = "analog_gamma"; scanner->opt[OPT_ANALOG_GAMMA].title = "Analog Gamma"; scanner->opt[OPT_ANALOG_GAMMA].desc = "Analog Gamma"; scanner->opt[OPT_ANALOG_GAMMA].type = SANE_TYPE_BOOL; scanner->opt[OPT_ANALOG_GAMMA].unit = SANE_UNIT_NONE; if (!scanner->analoggamma) { scanner->opt[OPT_ANALOG_GAMMA].cap = SANE_CAP_INACTIVE; } scanner->opt[OPT_AVERAGING].name = "averaging"; scanner->opt[OPT_AVERAGING].title = "Averaging"; scanner->opt[OPT_AVERAGING].desc = "Averaging"; scanner->opt[OPT_AVERAGING].type = SANE_TYPE_BOOL; scanner->opt[OPT_AVERAGING].unit = SANE_UNIT_NONE; scanner->opt[OPT_RGB_CONTROL].name = "rgb-control"; scanner->opt[OPT_RGB_CONTROL].title = "RGB control"; scanner->opt[OPT_RGB_CONTROL].desc = "toggles brightness/contrast control over individual colours"; scanner->opt[OPT_RGB_CONTROL].type = SANE_TYPE_BOOL; scanner->opt[OPT_RGB_CONTROL].unit = SANE_UNIT_NONE; if(scanner->LS>=2) { scanner->opt[OPT_RGB_CONTROL].cap |= SANE_CAP_INACTIVE; } /* brightness */ scanner->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; scanner->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; scanner->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; scanner->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; scanner->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; scanner->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_BRIGHTNESS].constraint.range = &brightness_range; if(scanner->LS>=2) { scanner->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_R_BRIGHTNESS].name = "red-brightness"; scanner->opt[OPT_R_BRIGHTNESS].title = "Red brightness"; scanner->opt[OPT_R_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; scanner->opt[OPT_R_BRIGHTNESS].type = SANE_TYPE_INT; scanner->opt[OPT_R_BRIGHTNESS].unit = SANE_UNIT_NONE; scanner->opt[OPT_R_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_R_BRIGHTNESS].constraint.range = &brightness_range; scanner->opt[OPT_R_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_G_BRIGHTNESS].name = "green-brightness"; scanner->opt[OPT_G_BRIGHTNESS].title = "Green brightness"; scanner->opt[OPT_G_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; scanner->opt[OPT_G_BRIGHTNESS].type = SANE_TYPE_INT; scanner->opt[OPT_G_BRIGHTNESS].unit = SANE_UNIT_NONE; scanner->opt[OPT_G_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_G_BRIGHTNESS].constraint.range = &brightness_range; scanner->opt[OPT_G_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_B_BRIGHTNESS].name = "blue-brightness"; scanner->opt[OPT_B_BRIGHTNESS].title = "Blue brightness"; scanner->opt[OPT_B_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; scanner->opt[OPT_B_BRIGHTNESS].type = SANE_TYPE_INT; scanner->opt[OPT_B_BRIGHTNESS].unit = SANE_UNIT_NONE; scanner->opt[OPT_B_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_B_BRIGHTNESS].constraint.range = &brightness_range; scanner->opt[OPT_B_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; /* contrast */ scanner->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; scanner->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; scanner->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; scanner->opt[OPT_CONTRAST].type = SANE_TYPE_INT; scanner->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE; scanner->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_CONTRAST].constraint.range = &contrast_range; if(scanner->LS>=2) { scanner->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_R_CONTRAST].name = "red-contrast"; scanner->opt[OPT_R_CONTRAST].title = "Red contrast"; scanner->opt[OPT_R_CONTRAST].desc = SANE_DESC_CONTRAST; scanner->opt[OPT_R_CONTRAST].type = SANE_TYPE_INT; scanner->opt[OPT_R_CONTRAST].unit = SANE_UNIT_NONE; scanner->opt[OPT_R_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_R_CONTRAST].constraint.range = &contrast_range; scanner->opt[OPT_R_CONTRAST].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_G_CONTRAST].name = "green-contrast"; scanner->opt[OPT_G_CONTRAST].title = "Green contrast"; scanner->opt[OPT_G_CONTRAST].desc = SANE_DESC_CONTRAST; scanner->opt[OPT_G_CONTRAST].type = SANE_TYPE_INT; scanner->opt[OPT_G_CONTRAST].unit = SANE_UNIT_NONE; scanner->opt[OPT_G_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_G_CONTRAST].constraint.range = &contrast_range; scanner->opt[OPT_G_CONTRAST].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_B_CONTRAST].name = "blue-contrast"; scanner->opt[OPT_B_CONTRAST].title = "Blue contrast"; scanner->opt[OPT_B_CONTRAST].desc = SANE_DESC_CONTRAST; scanner->opt[OPT_B_CONTRAST].type = SANE_TYPE_INT; scanner->opt[OPT_B_CONTRAST].unit = SANE_UNIT_NONE; scanner->opt[OPT_B_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_B_CONTRAST].constraint.range = &contrast_range; scanner->opt[OPT_B_CONTRAST].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_EXPOSURE].name = "exposure"; scanner->opt[OPT_EXPOSURE].title = "Exposure"; scanner->opt[OPT_EXPOSURE].desc = ""; scanner->opt[OPT_EXPOSURE].type = SANE_TYPE_INT; scanner->opt[OPT_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_EXPOSURE].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_EXPOSURE].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_EXPOSURE].constraint.range = &exposure_range; scanner->opt[OPT_R_EXPOSURE].name = "red-exposure"; scanner->opt[OPT_R_EXPOSURE].title = "Red exposure"; scanner->opt[OPT_R_EXPOSURE].desc = ""; scanner->opt[OPT_R_EXPOSURE].type = SANE_TYPE_INT; scanner->opt[OPT_R_EXPOSURE].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_R_EXPOSURE].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_R_EXPOSURE].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_R_EXPOSURE].constraint.range = &exposure_range; scanner->opt[OPT_G_EXPOSURE].name = "green-exposure"; scanner->opt[OPT_G_EXPOSURE].title = "Green exposure"; scanner->opt[OPT_G_EXPOSURE].desc = ""; scanner->opt[OPT_G_EXPOSURE].type = SANE_TYPE_INT; scanner->opt[OPT_G_EXPOSURE].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_G_EXPOSURE].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_G_EXPOSURE].constraint.range = &exposure_range; scanner->opt[OPT_G_EXPOSURE].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_B_EXPOSURE].name = "blue-exposure"; scanner->opt[OPT_B_EXPOSURE].title = "Blue exposre"; scanner->opt[OPT_B_EXPOSURE].desc = ""; scanner->opt[OPT_B_EXPOSURE].type = SANE_TYPE_INT; scanner->opt[OPT_B_EXPOSURE].unit = SANE_UNIT_PERCENT; scanner->opt[OPT_B_EXPOSURE].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_B_EXPOSURE].constraint.range = &exposure_range; scanner->opt[OPT_B_EXPOSURE].cap |= SANE_CAP_INACTIVE; if(scanner->LS>=2) { scanner->opt[OPT_R_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_G_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_B_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_R_SHIFT].name = "red-shift"; scanner->opt[OPT_R_SHIFT].title = "Red shift"; scanner->opt[OPT_R_SHIFT].desc = ""; scanner->opt[OPT_R_SHIFT].type = SANE_TYPE_INT; scanner->opt[OPT_R_SHIFT].unit = SANE_UNIT_NONE; scanner->opt[OPT_R_SHIFT].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_R_SHIFT].constraint.range = &shift_range; if(scanner->LS>=2) { scanner->opt[OPT_R_SHIFT].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_G_SHIFT].name = "green-shift"; scanner->opt[OPT_G_SHIFT].title = "Green shift"; scanner->opt[OPT_G_SHIFT].desc = ""; scanner->opt[OPT_G_SHIFT].type = SANE_TYPE_INT; scanner->opt[OPT_G_SHIFT].unit = SANE_UNIT_NONE; scanner->opt[OPT_G_SHIFT].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_G_SHIFT].constraint.range = &shift_range; if(scanner->LS>=2) { scanner->opt[OPT_G_SHIFT].cap |= SANE_CAP_INACTIVE; } scanner->opt[OPT_B_SHIFT].name = "blue-shift"; scanner->opt[OPT_B_SHIFT].title = "Blue shift"; scanner->opt[OPT_B_SHIFT].desc = ""; scanner->opt[OPT_B_SHIFT].type = SANE_TYPE_INT; scanner->opt[OPT_B_SHIFT].unit = SANE_UNIT_NONE; scanner->opt[OPT_B_SHIFT].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_B_SHIFT].constraint.range = &shift_range; if(scanner->LS>=2) { scanner->opt[OPT_B_SHIFT].cap |= SANE_CAP_INACTIVE; } /* R+G+B gamma vector */ scanner->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; scanner->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; scanner->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; scanner->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; if (scanner->LS == 1) { scanner->opt[OPT_GAMMA_VECTOR].cap = SANE_CAP_INACTIVE; } scanner->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; switch(scanner->LS) { case 0: scanner->opt[OPT_GAMMA_VECTOR].constraint.range = &gamma_range_8; scanner->lutlength=2048; break; case 1: scanner->opt[OPT_GAMMA_VECTOR].constraint.range = &gamma_range_9; scanner->lutlength=512; break; case 2: scanner->opt[OPT_GAMMA_VECTOR].constraint.range = &gamma_range_10; scanner->lutlength=1024; break; case 3: scanner->opt[OPT_GAMMA_VECTOR].constraint.range = &gamma_range_12; scanner->lutlength=4096; break; } scanner->opt[OPT_GAMMA_VECTOR].size = scanner->lutlength * sizeof (SANE_Word); scanner->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; /* red gamma vector */ scanner->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; scanner->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; scanner->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; scanner->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; scanner->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; switch(scanner->LS) { case 0: scanner->opt[OPT_GAMMA_VECTOR_R].constraint.range = &gamma_range_8; scanner->lutlength=2048; break; case 1: scanner->opt[OPT_GAMMA_VECTOR_R].constraint.range = &gamma_range_9; scanner->lutlength=512; break; case 2: scanner->opt[OPT_GAMMA_VECTOR_R].constraint.range = &gamma_range_10; scanner->lutlength=1024; break; case 3: scanner->opt[OPT_GAMMA_VECTOR_R].constraint.range = &gamma_range_12; scanner->lutlength=4096; break; } scanner->opt[OPT_GAMMA_VECTOR_R].size = scanner->lutlength * sizeof (SANE_Word); scanner->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; /* green gamma vector */ scanner->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; scanner->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; scanner->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; scanner->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; scanner->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; switch(scanner->LS) { case 0: scanner->opt[OPT_GAMMA_VECTOR_G].constraint.range = &gamma_range_8; scanner->lutlength=2048; break; case 1: scanner->opt[OPT_GAMMA_VECTOR_G].constraint.range = &gamma_range_9; scanner->lutlength=512; break; case 2: scanner->opt[OPT_GAMMA_VECTOR_G].constraint.range = &gamma_range_10; scanner->lutlength=1024; break; case 3: scanner->opt[OPT_GAMMA_VECTOR_G].constraint.range = &gamma_range_12; scanner->lutlength=4096; break; } scanner->opt[OPT_GAMMA_VECTOR_G].size = scanner->lutlength * sizeof (SANE_Word); scanner->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; /* blue gamma vector */ scanner->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; scanner->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; scanner->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; scanner->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; scanner->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; switch(scanner->LS) { case 0: scanner->opt[OPT_GAMMA_VECTOR_B].constraint.range = &gamma_range_8; scanner->lutlength=2048; break; case 1: scanner->opt[OPT_GAMMA_VECTOR_B].constraint.range = &gamma_range_9; scanner->lutlength=512; break; case 2: scanner->opt[OPT_GAMMA_VECTOR_B].constraint.range = &gamma_range_10; scanner->lutlength=1024; break; case 3: scanner->opt[OPT_GAMMA_VECTOR_B].constraint.range = &gamma_range_12; scanner->lutlength=4096; break; } scanner->opt[OPT_GAMMA_VECTOR_B].size = scanner->lutlength * sizeof (SANE_Word); scanner->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; /* ------------------------------ */ /* "Advanced" group: */ scanner->opt[OPT_ADVANCED_GROUP].title = "Advanced"; scanner->opt[OPT_ADVANCED_GROUP].desc = ""; scanner->opt[OPT_ADVANCED_GROUP].type = SANE_TYPE_GROUP; scanner->opt[OPT_ADVANCED_GROUP].cap = SANE_CAP_ADVANCED; scanner->opt[OPT_ADVANCED_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* preview */ scanner->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; scanner->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; scanner->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; scanner->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; /* Autofocus */ scanner->opt[OPT_AUTOFOCUS].name = "Autofocus"; scanner->opt[OPT_AUTOFOCUS].title ="Autofocus"; scanner->opt[OPT_AUTOFOCUS].desc = "When to do autofocussing"; scanner->opt[OPT_AUTOFOCUS].type = SANE_TYPE_STRING; scanner->opt[OPT_AUTOFOCUS].size = max_string_size (autofocus_mode_list); scanner->opt[OPT_AUTOFOCUS].constraint_type = SANE_CONSTRAINT_STRING_LIST; scanner->opt[OPT_AUTOFOCUS].constraint.string_list = autofocus_mode_list; scanner->opt[OPT_IRED_RED].name = "IRED cor. red"; scanner->opt[OPT_IRED_RED].title ="IRED cor. red"; scanner->opt[OPT_IRED_RED].desc = "Correction of infrared from red"; scanner->opt[OPT_IRED_RED].type = SANE_TYPE_INT; scanner->opt[OPT_IRED_RED].unit = SANE_UNIT_NONE; scanner->opt[OPT_IRED_RED].constraint_type = SANE_CONSTRAINT_RANGE; scanner->opt[OPT_IRED_RED].constraint.range = &gamma_range_8; scanner->opt[OPT_IRED_RED].cap |= SANE_CAP_ADVANCED; if(scanner->LS<2) { scanner->opt[OPT_IRED_RED].cap |= SANE_CAP_INACTIVE; } /* scanner->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; */ return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char dev_name[PATH_MAX]; size_t len; FILE *fp; authorize = authorize; DBG_INIT (); sanei_thread_init (); DBG (10, "sane_init\n"); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (COOLSCAN_CONFIG_FILE); if (!fp) { attach_scanner ("/dev/scanner", 0); /* no config-file: /dev/scanner */ return SANE_STATUS_GOOD; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') continue; /* ignore line comments */ len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ sanei_config_attach_matching_devices (dev_name, attach_one); /*attach_scanner (dev_name, 0);*/ } fclose (fp); return SANE_STATUS_GOOD; } void sane_exit (void) { Coolscan_t *dev, *next; DBG (10, "sane_exit\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free (dev->devicename); free (dev->buffer); free (dev->obuffer); free (dev); } if (devlist) free (devlist); } /* ----------------------------- SANE GET DEVICES -------------------------- */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Coolscan_t *dev; int i; local_only = local_only; DBG (10, "sane_get_devices\n"); if (devlist) free (devlist); devlist = calloc (num_devices + 1, sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Coolscan_t *dev; SANE_Status status; DBG (10, "sane_open\n"); if (devicename[0]) { /* search for devicename */ for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { break; } } if (!dev) { status = attach_scanner (devicename, &dev); if (status != SANE_STATUS_GOOD) { return status; } } } else { dev = first_dev; /* empty devicname -> use first device */ } if (!dev) return SANE_STATUS_INVAL; dev->sfd = -1; dev->pipe = -1; dev->scanning = SANE_FALSE; init_options (dev); *handle = dev; return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { DBG (10, "sane_close\n"); if (((Coolscan_t *) handle)->scanning) do_cancel (handle); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Coolscan_t *scanner = handle; DBG (10, "sane_get_option_descriptor %d\n", option); if ((unsigned) option >= NUM_OPTIONS) return 0; return &scanner->opt[option]; } /* static void worddump(char *comment, SANE_Word * p, int l) { int i; char line[128]; char *ptr; DBG (5, "%s\n", comment); ptr = line; for (i = 0; i < l; i++, p++) { if ((i % 8) == 0) { if (ptr != line) { *ptr = '\0'; DBG (5, "%s\n", line); ptr = line; } sprintf (ptr, "%3.3d:", i); ptr += 4; } sprintf (ptr, " %4.4d", *p); ptr += 5; } *ptr = '\0'; DBG (5, "%s\n", line); } */ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Coolscan_t *scanner = handle; SANE_Status status; SANE_Word cap; if (info) *info = 0; if (scanner->scanning) return SANE_STATUS_DEVICE_BUSY; if (option >= NUM_OPTIONS) return SANE_STATUS_INVAL; cap = scanner->opt[option].cap; if (action == SANE_ACTION_GET_VALUE) { DBG (10, "sane_control_option %d, get value\n", option); switch (option) { /* word options: */ case OPT_TL_X: *(SANE_Word *) val = SANE_FIX (iluToMm (scanner->tlx)); return SANE_STATUS_GOOD; case OPT_TL_Y: *(SANE_Word *) val = SANE_FIX (iluToMm (scanner->tly)); return SANE_STATUS_GOOD; case OPT_BR_X: *(SANE_Word *) val = SANE_FIX (iluToMm (scanner->brx)); return SANE_STATUS_GOOD; case OPT_BR_Y: *(SANE_Word *) val = SANE_FIX (iluToMm (scanner->bry)); return SANE_STATUS_GOOD; case OPT_PREVIEW: *(SANE_Word *) val = scanner->preview; return SANE_STATUS_GOOD; case OPT_AUTOFOCUS: switch(scanner->autofocus) { case AF_NEVER: strcpy (val,neverStr); break; case AF_PREVIEW:strcpy (val,previewStr); break; case AF_SCAN:if(scanner->LS>=2) strcpy (val,scanStr); break; case AF_PREANDSCAN:if(scanner->LS>=2) strcpy (val,preandscanStr); break; } return SANE_STATUS_GOOD; case OPT_NUM_OPTS: *(SANE_Word *) val = NUM_OPTIONS; return SANE_STATUS_GOOD; case OPT_RESOLUTION: *(SANE_Word *) val = resDivToVal (scanner->x_nres); return SANE_STATUS_GOOD; case OPT_PREVIEW_RESOLUTION: *(SANE_Word *) val = resDivToVal (scanner->x_p_nres); return SANE_STATUS_GOOD; case OPT_BIT_DEPTH: *(SANE_Word *) val = scanner->bits_per_color; return SANE_STATUS_GOOD; case OPT_CONTRAST: *(SANE_Word *) val = scanner->contrast - 128; return SANE_STATUS_GOOD; case OPT_R_CONTRAST: *(SANE_Word *) val = scanner->contrast_R - 128; return SANE_STATUS_GOOD; case OPT_G_CONTRAST: *(SANE_Word *) val = scanner->contrast_G - 128; return SANE_STATUS_GOOD; case OPT_B_CONTRAST: *(SANE_Word *) val = scanner->contrast_B - 128; return SANE_STATUS_GOOD; case OPT_BRIGHTNESS: *(SANE_Word *) val = scanner->brightness - 128; return SANE_STATUS_GOOD; case OPT_R_BRIGHTNESS: *(SANE_Word *) val = scanner->brightness_R - 128; return SANE_STATUS_GOOD; case OPT_G_BRIGHTNESS: *(SANE_Word *) val = scanner->brightness_G - 128; return SANE_STATUS_GOOD; case OPT_B_BRIGHTNESS: *(SANE_Word *) val = scanner->brightness_B - 128; return SANE_STATUS_GOOD; case OPT_EXPOSURE: *(SANE_Word *) val = scanner->exposure_R * 2; return SANE_STATUS_GOOD; case OPT_R_EXPOSURE: *(SANE_Word *) val = scanner->exposure_R * 2; return SANE_STATUS_GOOD; case OPT_G_EXPOSURE: *(SANE_Word *) val = scanner->exposure_G * 2; return SANE_STATUS_GOOD; case OPT_B_EXPOSURE: *(SANE_Word *) val = scanner->exposure_B * 2; return SANE_STATUS_GOOD; case OPT_R_SHIFT: *(SANE_Word *) val = scanner->shift_R - 128; return SANE_STATUS_GOOD; case OPT_G_SHIFT: *(SANE_Word *) val = scanner->shift_G - 128; return SANE_STATUS_GOOD; case OPT_B_SHIFT: *(SANE_Word *) val = scanner->shift_B - 128; return SANE_STATUS_GOOD; case OPT_IRED_RED: *(SANE_Word *) val = scanner->ired_red; return SANE_STATUS_GOOD; /* string options: */ case OPT_TYPE: strcpy (val, ((scanner->negative) ? negativeStr : positiveStr)); return SANE_STATUS_GOOD; case OPT_MODE: switch(scanner->colormode) { case RGB: strcpy (val,colorStr); break; case GREYSCALE:strcpy (val,grayStr); break; case RGBI:if(scanner->LS>=2) strcpy (val,rgbiStr); else strcpy (val,colorStr); break; case IRED:if(scanner->LS>=2) strcpy (val,iredStr); else strcpy (val,grayStr); break; } if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; case OPT_PRESCAN: *(SANE_Word *) val = (scanner->prescan) ? SANE_TRUE : SANE_FALSE; return SANE_STATUS_GOOD; case OPT_PRESCAN_NOW: return SANE_STATUS_GOOD; case OPT_RGB_CONTROL: *(SANE_Word *) val = (scanner->rgb_control) ? SANE_TRUE : SANE_FALSE; return SANE_STATUS_GOOD; case OPT_GAMMA_BIND: *(SANE_Word *) val = (scanner->gamma_bind) ? SANE_TRUE : SANE_FALSE; return SANE_STATUS_GOOD; case OPT_ANALOG_GAMMA: *(SANE_Word *) val = (scanner->analog_gamma_r) ? SANE_TRUE : SANE_FALSE; return SANE_STATUS_GOOD; case OPT_AVERAGING: *(SANE_Word *) val = (scanner->averaging) ? SANE_TRUE : SANE_FALSE; return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR: memcpy (val, scanner->gamma, scanner->opt[option].size); return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR_R: memcpy (val, scanner->gamma_r, scanner->opt[option].size); return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR_G: memcpy (val, scanner->gamma_g, scanner->opt[option].size); return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR_B: memcpy (val, scanner->gamma_b, scanner->opt[option].size); return SANE_STATUS_GOOD; case OPT_SOURCE: if (strcmp (val, "Automatic Slide Feeder") == 0) { /* Feed/Discharge/update filename/etc */ } else { /* Reset above */ } if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } } } else if (action == SANE_ACTION_SET_VALUE) { DBG (10, "sane_control_option %d, set value\n", option); if (!SANE_OPTION_IS_ACTIVE (cap)) return SANE_STATUS_INVAL; if (!SANE_OPTION_IS_SETTABLE (cap)) return SANE_STATUS_INVAL; status = sanei_constrain_value (scanner->opt + option, val, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { case OPT_GAMMA_BIND: scanner->gamma_bind = (*(SANE_Word *) val == SANE_TRUE); if (scanner->LS != 1) { if (scanner->gamma_bind) { scanner->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } else { scanner->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_ANALOG_GAMMA: scanner->analog_gamma_r = scanner->analog_gamma_g = scanner->analog_gamma_b = (*(SANE_Word *) val == SANE_TRUE); return SANE_STATUS_GOOD; case OPT_AVERAGING: scanner->averaging = (*(SANE_Word *) val == SANE_TRUE); return SANE_STATUS_GOOD; case OPT_PRESCAN: scanner->prescan = (*(SANE_Word *) val == SANE_TRUE); return SANE_STATUS_GOOD; case OPT_PRESCAN_NOW: do_prescan_now(scanner); return SANE_STATUS_GOOD; case OPT_BIT_DEPTH: scanner->bits_per_color=(*(SANE_Word *)val); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_RGB_CONTROL: scanner->rgb_control = (*(SANE_Word *) val == SANE_TRUE); if (scanner->rgb_control) { scanner->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_EXPOSURE].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_R_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_G_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_B_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_R_CONTRAST].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_G_CONTRAST].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_B_CONTRAST].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_R_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_G_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_B_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; scanner->contrast_R = 128; scanner->contrast_G = 128; scanner->contrast_B = 128; scanner->brightness_R = 128; scanner->brightness_G = 128; scanner->brightness_B = 128; scanner->exposure_R = 50; scanner->exposure_G = 50; scanner->exposure_B = 50; } else { scanner->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; scanner->opt[OPT_EXPOSURE].cap &= ~SANE_CAP_INACTIVE; scanner->contrast = 128; scanner->brightness = 128; scanner->exposure_R = 50; scanner->exposure_G = 50; scanner->exposure_B = 50; scanner->opt[OPT_R_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_G_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_B_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_R_CONTRAST].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_G_CONTRAST].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_B_CONTRAST].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_R_EXPOSURE].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_G_EXPOSURE].cap |= SANE_CAP_INACTIVE; scanner->opt[OPT_B_EXPOSURE].cap |= SANE_CAP_INACTIVE; } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_RESOLUTION: scanner->y_nres = scanner->x_nres = resValToDiv (*(SANE_Word *) val); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_PREVIEW_RESOLUTION: scanner->y_p_nres = scanner->x_p_nres = resValToDiv (*(SANE_Word *) val); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_TL_X: scanner->tlx = mmToIlu (SANE_UNFIX (*(SANE_Word *) val)); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_TL_Y: scanner->tly = mmToIlu (SANE_UNFIX (*(SANE_Word *) val)); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_BR_X: scanner->brx = mmToIlu (SANE_UNFIX (*(SANE_Word *) val)); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_BR_Y: scanner->bry = mmToIlu (SANE_UNFIX (*(SANE_Word *) val)); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; case OPT_NUM_OPTS: return SANE_STATUS_GOOD; case OPT_PREVIEW: scanner->preview = *(SANE_Word *) val; return SANE_STATUS_GOOD; case OPT_AUTOFOCUS: if(strcmp(val,neverStr)==0) { scanner->autofocus=AF_NEVER; } if(strcmp(val,previewStr)==0) { scanner->autofocus=AF_PREVIEW; } if(strcmp(val,scanStr)==0) { scanner->autofocus=AF_SCAN; } if(strcmp(val,preandscanStr)==0) { scanner->autofocus=AF_PREANDSCAN;; } return SANE_STATUS_GOOD; case OPT_CONTRAST: scanner->contrast = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_R_CONTRAST: scanner->contrast_R = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_G_CONTRAST: scanner->contrast_G = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_B_CONTRAST: scanner->contrast_B = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_BRIGHTNESS: scanner->brightness = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_R_BRIGHTNESS: scanner->brightness_R = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_G_BRIGHTNESS: scanner->brightness_G = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_B_BRIGHTNESS: scanner->brightness_B = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_EXPOSURE: scanner->exposure_R = *(SANE_Word *) val / 2; scanner->exposure_G = *(SANE_Word *) val / 2; scanner->exposure_B = *(SANE_Word *) val / 2; return SANE_STATUS_GOOD; case OPT_R_EXPOSURE: scanner->exposure_R = *(SANE_Word *) val / 2; return SANE_STATUS_GOOD; case OPT_G_EXPOSURE: scanner->exposure_G = *(SANE_Word *) val / 2; return SANE_STATUS_GOOD; case OPT_B_EXPOSURE: scanner->exposure_B = *(SANE_Word *) val / 2; return SANE_STATUS_GOOD; case OPT_R_SHIFT: scanner->shift_R = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_G_SHIFT: scanner->shift_G = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_B_SHIFT: scanner->shift_B = *(SANE_Word *) val + 128; return SANE_STATUS_GOOD; case OPT_IRED_RED: scanner->ired_red= *(SANE_Word *) val; return SANE_STATUS_GOOD; case OPT_SOURCE: scanner->asf = (strcmp (val, "Automatic...") == 0); return SANE_STATUS_GOOD; case OPT_TYPE: scanner->negative = (strcmp (val, negativeStr) == 0); if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; case OPT_MODE: if(strcmp(val,colorStr)==0) { scanner->colormode=RGB; scanner->colormode_p=RGB; } if(strcmp(val,grayStr)==0) { scanner->colormode=GREYSCALE; scanner->colormode_p=GREYSCALE; } if(strcmp(val,rgbiStr)==0) { scanner->colormode=RGBI; scanner->colormode_p=RGB; } if(strcmp(val,iredStr)==0) { scanner->colormode=IRED; scanner->colormode_p=GREYSCALE; } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR: memcpy (scanner->gamma, val, scanner->opt[option].size); if(scanner->LS>2) Calc_fix_LUT(scanner); return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR_R: memcpy (scanner->gamma_r, val, scanner->opt[option].size); if(scanner->LS>2) Calc_fix_LUT(scanner); return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR_G: memcpy (scanner->gamma_g, val, scanner->opt[option].size); if(scanner->LS>2) Calc_fix_LUT(scanner); return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR_B: memcpy (scanner->gamma_b, val, scanner->opt[option].size); if(scanner->LS>2) Calc_fix_LUT(scanner); return SANE_STATUS_GOOD; } /* switch */ } /* else */ return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Coolscan_t *scanner = handle; DBG (10, "sane_get_parameters"); switch(scanner->colormode) { case RGB: params->format = SANE_FRAME_RGB; break; #ifdef HAS_IRED case RGBI: params->format = SANE_FRAME_RGBA; break; #endif /* HAS_RGBI */ case GREYSCALE: params->format = SANE_FRAME_GRAY; break; } params->depth = scanner->bits_per_color>8?16:8; params->pixels_per_line = pixels_per_line (scanner); params->lines = lines_per_scan (scanner); params->bytes_per_line = write_bytes_per_line (scanner); params->last_frame = 1; return SANE_STATUS_GOOD; } static int swap_res (Coolscan_t * s) { if (s->preview) { /* swap preview/scan resolutions */ int xres, yres, cmode; xres = s->x_nres; yres = s->y_nres; s->x_nres = s->x_p_nres; s->y_nres = s->y_p_nres; s->x_p_nres = xres; s->y_p_nres = yres; cmode=s->colormode; s->colormode=s->colormode_p; s->colormode_p=cmode; } return 0; } SANE_Status sane_start (SANE_Handle handle) { Coolscan_t *scanner = handle; int fds[2]; DBG (10, "sane_start\n"); if (scanner->scanning == SANE_TRUE) return SANE_STATUS_DEVICE_BUSY; if (scanner->sfd < 0) { /* first call */ if (sanei_scsi_open (scanner->sane.name, &(scanner->sfd), sense_handler, 0) != SANE_STATUS_GOOD) { DBG (1, "sane_start: open of %s failed:\n", scanner->sane.name); return SANE_STATUS_INVAL; } } scanner->scanning = SANE_TRUE; if (coolscan_check_values (scanner) != 0) { /* Verify values */ DBG (1, "ERROR: invalid scan-values\n"); scanner->scanning = SANE_FALSE; coolscan_give_scanner (scanner); sanei_scsi_close (scanner->sfd); scanner->sfd = -1; return SANE_STATUS_INVAL; } if (coolscan_grab_scanner (scanner)) { sanei_scsi_close (scanner->sfd); scanner->sfd = -1; DBG (5, "WARNING: unable to reserve scanner: device busy\n"); scanner->scanning = SANE_FALSE; return SANE_STATUS_DEVICE_BUSY; } /* hoho, step 2c, -perm */ coolscan_object_feed (scanner); swap_res (scanner); if (!scanner->preview) { if(scanner->autofocus & 0x02) { coolscan_autofocus (scanner); } } else { if(scanner->autofocus & 0x01) { coolscan_autofocus (scanner); } if (scanner->prescan) { prescan (scanner); if(scanner->LS<2) { get_internal_info(scanner); } coolscan_get_window_param (scanner,1); } } /*read_LUT(scanner); */ if(scanner->LS<2) { send_LUT (scanner); coolscan_set_window_param (scanner, 0); coolscan_get_window_param (scanner,0); coolscan_start_scan (scanner); } else { coolscan_set_window_param (scanner, 0); send_LUT (scanner); Calc_fix_LUT(scanner); coolscan_start_scan (scanner); wait_scanner (scanner); coolscan_get_window_param (scanner,0); } DBG (10, "bytes per line = %d\n", scan_bytes_per_line (scanner)); DBG (10, "pixels_per_line = %d\n", pixels_per_line (scanner)); DBG (10, "lines = %d\n", lines_per_scan (scanner)); DBG (10, "negative = %d\n", scanner->negative); DBG (10, "brightness (halftone) = %d\n", scanner->brightness); DBG (10, "contrast (halftone) = %d\n", scanner->contrast); DBG (10, "fast preview function = %d\n", scanner->preview); /* create a pipe, fds[0]=read-fd, fds[1]=write-fd */ if (pipe (fds) < 0) { DBG (1, "ERROR: could not create pipe\n"); swap_res (scanner); scanner->scanning = SANE_FALSE; coolscan_give_scanner (scanner); sanei_scsi_close (scanner->sfd); scanner->sfd = -1; return SANE_STATUS_IO_ERROR; } scanner->pipe = fds[0]; scanner->reader_fds = fds[1]; scanner->reader_pid = sanei_thread_begin( reader_process, (void*)scanner ); if (!sanei_thread_is_valid (scanner->reader_pid)) { DBG (1, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno)); return SANE_STATUS_NO_MEM; } if (sanei_thread_is_forked ()) { close (scanner->reader_fds); scanner->reader_fds = -1; } return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { Coolscan_t *scanner = handle; ssize_t nread; *len = 0; nread = read (scanner->pipe, buf, max_len); DBG (10, "sane_read: read %ld bytes\n", (long) nread); if (!(scanner->scanning)) { return do_cancel (scanner); } if (nread < 0) { if (errno == EAGAIN) { return SANE_STATUS_GOOD; } else { do_cancel (scanner); return SANE_STATUS_IO_ERROR; } } *len = nread; if (nread == 0) return do_eof (scanner); /* close pipe */ return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Coolscan_t *s = handle; if (sanei_thread_is_valid (s->reader_pid)) { sanei_thread_kill ( s->reader_pid ); sanei_thread_waitpid( s->reader_pid, NULL ); sanei_thread_invalidate (s->reader_pid); } swap_res (s); s->scanning = SANE_FALSE; } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Coolscan_t *scanner = handle; DBG (10, "sane_set_io_mode: non_blocking=%d\n", non_blocking); if (!scanner->scanning) return SANE_STATUS_INVAL; if (fcntl (scanner->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) return SANE_STATUS_IO_ERROR; return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Coolscan_t *scanner = handle; DBG (10, "sane_get_select_fd\n"); if (!scanner->scanning) { return SANE_STATUS_INVAL; } *fd = scanner->pipe; return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/teco1.c0000666000000000000000000015413013615534521013753 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002 Frank Zago (sane at zago dot net) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* $Id$ Some Relisys scanners AVEC and RELI series */ /*--------------------------------------------------------------------------*/ #define BUILD 10 /* 2004/02/08 */ #define BACKEND_NAME teco1 #define TECO_CONFIG_FILE "teco1.conf" /*--------------------------------------------------------------------------*/ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/lassert.h" #include "teco1.h" #undef sim #ifdef sim #define sanei_scsi_cmd2(a, b, c, d, e, f, g) SANE_STATUS_GOOD #define sanei_scsi_open(a, b, c, d) 0 #define sanei_scsi_cmd(a, b, c, d, e) SANE_STATUS_GOOD #define sanei_scsi_close(a) SANE_STATUS_GOOD #endif /*--------------------------------------------------------------------------*/ /* Lists of possible scan modes. */ static SANE_String_Const scan_mode_list[] = { BLACK_WHITE_STR, GRAY_STR, COLOR_STR, NULL }; /*--------------------------------------------------------------------------*/ /* Minimum and maximum width and length supported. */ static SANE_Range x_range = { SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0 }; static SANE_Range y_range = { SANE_FIX (0), SANE_FIX (14 * MM_PER_INCH), 0 }; /*--------------------------------------------------------------------------*/ /* Gamma range */ static const SANE_Range gamma_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; /*--------------------------------------------------------------------------*/ /* List of dithering options. */ static SANE_String_Const dither_list[] = { "Line art", "2x2", "3x3", "4x4 bayer", "4x4 smooth", "8x8 bayer", "8x8 smooth", "8x8 horizontal", "8x8 vertical", NULL }; static const int dither_val[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; /*--------------------------------------------------------------------------*/ static const SANE_Range threshold_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; /*--------------------------------------------------------------------------*/ /* Define the supported scanners and their characteristics. */ static const struct scanners_supported scanners[] = { {6, "TECO VM3510", /* *fake id*, see teco_identify_scanner */ TECO_VM3510, "Dextra", "DF-600P", {1, 600, 1}, /* resolution */ 300, 600, /* max x and Y res */ 3, /* color 3 pass */ 256, /* number of bytes per gamma color */ 80 /* number of bytes in a window */ }, {6, "TECO VM353A", TECO_VM353A, "Relisys", "RELI 2412", {1, 1200, 1}, /* resolution */ 300, 1200, /* max x and Y resolution */ 1, /* color 1 pass */ 256, /* number of bytes per gamma color */ 99 /* number of bytes in a window */ }, {6, "TECO VM3520", TECO_VM3520, "Relisys", "AVEC Colour Office 2400", {1, 600, 1}, /* resolution */ 300, 600, /* max x and Y resolution */ 3, /* color 3 pass */ 256, /* number of bytes per gamma color */ 99 /* number of bytes in a window */ }, {6, "TECO VM352A", TECO_VM3520, /* same as AVEC 2400 */ "Relisys", "AVEC Colour 2412", {1, 600, 1}, 300, 600, 3, 256, 99 }, {6, "TECO VM4540", TECO_VM4540, "Relisys", "RELI 4816", {1, 1600, 1}, /* resolution */ 400, 1600, /* max x and Y resolution */ 1, /* color 1 pass */ 256, /* number of bytes per gamma color */ 99 /* number of bytes in a window */ }, {6, "TECO VM4542", TECO_VM4542, "Relisys", "RELI 4830", {1, 400, 1}, /* resolution */ 400, 400, /* max x and Y resolution */ 1, /* color 1 pass */ 1024, /* number of bytes per gamma color */ 99 /* number of bytes in a window */ } }; /*--------------------------------------------------------------------------*/ /* List of scanner attached. */ static Teco_Scanner *first_dev = NULL; static int num_devices = 0; static const SANE_Device **devlist = NULL; /* Local functions. */ /* Display a buffer in the log. */ static void hexdump (int level, const char *comment, unsigned char *p, int l) { int i; char line[128]; char *ptr; char asc_buf[17]; char *asc_ptr; DBG (level, "%s\n", comment); ptr = line; *ptr = '\0'; asc_ptr = asc_buf; *asc_ptr = '\0'; for (i = 0; i < l; i++, p++) { if ((i % 16) == 0) { if (ptr != line) { DBG (level, "%s %s\n", line, asc_buf); ptr = line; *ptr = '\0'; asc_ptr = asc_buf; *asc_ptr = '\0'; } sprintf (ptr, "%3.3d:", i); ptr += 4; } ptr += sprintf (ptr, " %2.2x", *p); if (*p >= 32 && *p <= 127) { asc_ptr += sprintf (asc_ptr, "%c", *p); } else { asc_ptr += sprintf (asc_ptr, "."); } } *ptr = '\0'; DBG (level, "%s %s\n", line, asc_buf); } /* Returns the length of the longest string, including the terminating * character. */ static size_t max_string_size (SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) { max_size = size; } } return max_size; } /* Lookup a string list from one array and return its index. */ static int get_string_list_index (SANE_String_Const list[], SANE_String_Const name) { int index; index = 0; while (list[index] != NULL) { if (strcmp (list[index], name) == 0) { return (index); } index++; } DBG (DBG_error, "name %s not found in list\n", name); assert (0 == 1); /* bug in backend, core dump */ return (-1); } /* Initialize a scanner entry. Return an allocated scanner with some * preset values. */ static Teco_Scanner * teco_init (void) { Teco_Scanner *dev; DBG (DBG_proc, "teco_init: enter\n"); /* Allocate a new scanner entry. */ dev = malloc (sizeof (Teco_Scanner)); if (dev == NULL) { return NULL; } memset (dev, 0, sizeof (Teco_Scanner)); /* Allocate the buffer used to transfer the SCSI data. */ dev->buffer_size = 64 * 1024; dev->buffer = malloc (dev->buffer_size); if (dev->buffer == NULL) { free (dev); return NULL; } /* Allocate a buffer to store the temporary image. */ dev->image_size = 64 * 1024; /* enough for 1 line at max res */ dev->image = malloc (dev->image_size); if (dev->image == NULL) { free (dev->buffer); free (dev); return NULL; } dev->sfd = -1; DBG (DBG_proc, "teco_init: exit\n"); return (dev); } /* Closes an open scanner. */ static void teco_close (Teco_Scanner * dev) { DBG (DBG_proc, "teco_close: enter\n"); if (dev->sfd != -1) { sanei_scsi_close (dev->sfd); dev->sfd = -1; } DBG (DBG_proc, "teco_close: exit\n"); } /* Frees the memory used by a scanner. */ static void teco_free (Teco_Scanner * dev) { int i; DBG (DBG_proc, "teco_free: enter\n"); if (dev == NULL) return; teco_close (dev); if (dev->devicename) { free (dev->devicename); } if (dev->buffer) { free (dev->buffer); } if (dev->image) { free (dev->image); } for (i = 1; i < OPT_NUM_OPTIONS; i++) { if (dev->opt[i].type == SANE_TYPE_STRING && dev->val[i].s) { free (dev->val[i].s); } } free (dev); DBG (DBG_proc, "teco_free: exit\n"); } /* Inquiry a device and returns TRUE if is supported. */ static int teco_identify_scanner (Teco_Scanner * dev) { CDB cdb; SANE_Status status; size_t size; int i; DBG (DBG_proc, "teco_identify_scanner: enter\n"); size = 5; MKSCSI_INQUIRY (cdb, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status) { DBG (DBG_error, "teco_identify_scanner: inquiry failed with status %s\n", sane_strstatus (status)); return (SANE_FALSE); } #ifdef sim { #if 1 /* vm3510 / Dextra DF-600P */ unsigned char table[] = { 0x06, 0x00, 0x02, 0x02, 0x24, 0x00, 0x00, 0x10, 0x44, 0x46, 0x2D, 0x36, 0x30, 0x30, 0x4D, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x31, 0x2E, 0x31, 0x37, 0x31, 0x2E, 0x31, 0x37, 0x02 }; #endif #if 0 /* vm4542 */ unsigned char table[] = { 0x06, 0x00, 0x02, 0x02, 0x30, 0x00, 0x00, 0x10, 0x52, 0x45, 0x4c, 0x49, 0x53, 0x59, 0x53, 0x20, 0x52, 0x45, 0x4c, 0x49, 0x20, 0x34, 0x38, 0x33, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x31, 0x2e, 0x30, 0x33, 0x31, 0x2e, 0x30, 0x33, 0x02, 0x00, 0x54, 0x45, 0x43, 0x4f, 0x20, 0x56, 0x4d, 0x34, 0x35, 0x34, 0x32 }; #endif memcpy (dev->buffer, table, sizeof (table)); } #endif size = dev->buffer[4] + 5; /* total length of the inquiry data */ MKSCSI_INQUIRY (cdb, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status) { DBG (DBG_error, "teco_identify_scanner: inquiry failed with status %s\n", sane_strstatus (status)); return (SANE_FALSE); } /* Hack to recognize the dextra as a TECO scanner. */ if (memcmp (dev->buffer + 0x08, "DF-600M ", 8) == 0) { memcpy (dev->buffer + 0x29, "\0TECO VM3510", 12); dev->buffer[4] = 0x30; /* change length */ size = 0x35; } if (size < 53) { DBG (DBG_error, "teco_identify_scanner: not enough data to identify device\n"); return (SANE_FALSE); } hexdump (DBG_info2, "inquiry", dev->buffer, size); dev->scsi_type = dev->buffer[0] & 0x1f; memcpy (dev->scsi_vendor, dev->buffer + 0x08, 0x08); dev->scsi_vendor[0x08] = 0; memcpy (dev->scsi_product, dev->buffer + 0x10, 0x010); dev->scsi_product[0x10] = 0; memcpy (dev->scsi_version, dev->buffer + 0x20, 0x04); dev->scsi_version[0x04] = 0; memcpy (dev->scsi_teco_name, dev->buffer + 0x2A, 0x0B); dev->scsi_teco_name[0x0B] = 0; DBG (DBG_info, "device is \"%s\" \"%s\" \"%s\" \"%s\"\n", dev->scsi_vendor, dev->scsi_product, dev->scsi_version, dev->scsi_teco_name); /* Lookup through the supported scanners table to find if this * backend supports that one. */ for (i = 0; i < NELEMS (scanners); i++) { if (dev->scsi_type == scanners[i].scsi_type && strcmp (dev->scsi_teco_name, scanners[i].scsi_teco_name) == 0) { DBG (DBG_error, "teco_identify_scanner: scanner supported\n"); dev->def = &(scanners[i]); return (SANE_TRUE); } } DBG (DBG_proc, "teco_identify_scanner: exit, device not supported\n"); return (SANE_FALSE); } /* Get the inquiry page 0x82. */ static int teco_get_inquiry_82 (Teco_Scanner * dev) { CDB cdb; SANE_Status status; size_t size; DBG (DBG_proc, "teco_get_inquiry_82: enter\n"); size = 0x4; MKSCSI_INQUIRY (cdb, size); cdb.data[1] = 1; /* evpd */ cdb.data[2] = 0x82; /* page code number */ status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status) { DBG (DBG_error, "teco_get_inquiry_82: inquiry page 0x82 failed with status %s\n", sane_strstatus (status)); return (SANE_FALSE); } size = dev->buffer[3] + 4; MKSCSI_INQUIRY (cdb, size); cdb.data[1] = 1; /* evpd */ cdb.data[2] = 0x82; /* page code number */ status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status) { DBG (DBG_error, "teco_get_inquiry_82: inquiry page 0x82 failed with status %s\n", sane_strstatus (status)); return (SANE_FALSE); } hexdump (DBG_info2, "inquiry page 0x82", dev->buffer, size); DBG (DBG_proc, "teco_get_inquiry_82: leave\n"); return (status); } /* SCSI sense handler. Callback for SANE. * These scanners never set asc or ascq. */ static SANE_Status teco_sense_handler (int __sane_unused__ scsi_fd, unsigned char *result, void __sane_unused__ *arg) { int sensekey; int len; DBG (DBG_proc, "teco_sense_handler: enter\n"); sensekey = get_RS_sense_key (result); len = 7 + get_RS_additional_length (result); hexdump (DBG_info2, "sense", result, len); if (get_RS_error_code (result) != 0x70) { DBG (DBG_error, "teco_sense_handler: invalid sense key error code (%d)\n", get_RS_error_code (result)); return SANE_STATUS_IO_ERROR; } if (len < 14) { DBG (DBG_error, "teco_sense_handler: sense too short, no ASC/ASCQ\n"); return SANE_STATUS_IO_ERROR; } DBG (DBG_sense, "teco_sense_handler: sense=%d\n", sensekey); if (sensekey == 0x00) { return SANE_STATUS_GOOD; } return SANE_STATUS_IO_ERROR; } /* Send the mode select to the scanner. */ static int teco_mode_select (Teco_Scanner * dev) { CDB cdb; SANE_Status status; size_t size; unsigned char select[24] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00 }; DBG (DBG_proc, "teco_mode_select: enter\n"); size = 24; MKSCSI_MODE_SELECT (cdb, 1, 0, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, select, size, NULL, NULL); DBG (DBG_proc, "teco_mode_select: exit\n"); return (status); } /* Set a window. */ static SANE_Status teco_set_window (Teco_Scanner * dev) { size_t size; /* significant size of window */ CDB cdb; unsigned char window[99]; SANE_Status status; int i; DBG (DBG_proc, "teco_set_window: enter\n"); size = dev->def->window_size; MKSCSI_SET_WINDOW (cdb, size); memset (window, 0, size); /* size of the windows descriptor block */ window[7] = size - 8; /* X and Y resolution */ Ito16 (dev->x_resolution, &window[10]); Ito16 (dev->y_resolution, &window[12]); /* Upper Left (X,Y) */ Ito32 (dev->x_tl, &window[14]); Ito32 (dev->y_tl, &window[18]); /* Width and length */ Ito32 (dev->width, &window[22]); Ito32 (dev->length, &window[26]); /* Image Composition */ switch (dev->scan_mode) { case TECO_BW: window[33] = 0x00; i = get_string_list_index (dither_list, dev->val[OPT_DITHER].s); window[36] = dither_val[i]; break; case TECO_GRAYSCALE: window[33] = 0x02; break; case TECO_COLOR: window[33] = 0x05; break; } /* Depth */ window[34] = dev->depth; /* Unknown - invariants */ window[31] = 0x80; window[37] = 0x80; window[55] = 0x80; window[57] = 0x80; window[59] = 0x80; window[61] = 0x80; window[65] = 0x80; window[67] = 0x80; window[69] = 0x80; window[71] = 0x80; window[73] = 0x80; window[75] = 0x80; window[77] = 0x80; window[79] = 0x80; window[85] = 0xff; window[89] = 0xff; window[93] = 0xff; window[97] = 0xff; hexdump (DBG_info2, "windows", window, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, window, size, NULL, NULL); DBG (DBG_proc, "teco_set_window: exit, status=%d\n", status); return status; } /* Return the number of byte that can be read. */ static SANE_Status get_filled_data_length (Teco_Scanner * dev, size_t * to_read) { size_t size; CDB cdb; SANE_Status status; DBG (DBG_proc, "get_filled_data_length: enter\n"); *to_read = 0; size = 0x12; MKSCSI_GET_DATA_BUFFER_STATUS (cdb, 1, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (size < 0x10) { DBG (DBG_error, "get_filled_data_length: not enough data returned (%ld)\n", (long) size); } hexdump (DBG_info2, "get_filled_data_length return", dev->buffer, size); *to_read = B24TOI (&dev->buffer[9]); DBG (DBG_info, "%d %d - %d %d\n", dev->params.lines, B16TOI (&dev->buffer[12]), dev->params.bytes_per_line, B16TOI (&dev->buffer[14])); if (dev->real_bytes_left == 0) { /* Beginning of a scan. */ dev->params.lines = B16TOI (&dev->buffer[12]); switch (dev->scan_mode) { case TECO_BW: dev->params.bytes_per_line = B16TOI (&dev->buffer[14]); dev->params.pixels_per_line = dev->params.bytes_per_line * 8; break; case TECO_GRAYSCALE: dev->params.pixels_per_line = B16TOI (&dev->buffer[14]); dev->params.bytes_per_line = dev->params.pixels_per_line; break; case TECO_COLOR: dev->params.pixels_per_line = B16TOI (&dev->buffer[14]); if (dev->def->pass == 3) { dev->params.bytes_per_line = dev->params.pixels_per_line; } else { dev->params.bytes_per_line = dev->params.pixels_per_line * 3; } break; } } DBG (DBG_info, "get_filled_data_length: to read = %ld\n", (long) *to_read); DBG (DBG_proc, "get_filled_data_length: exit, status=%d\n", status); return (status); } /* Start a scan. */ static SANE_Status teco_scan (Teco_Scanner * dev) { CDB cdb; SANE_Status status; DBG (DBG_proc, "teco_scan: enter\n"); MKSCSI_SCAN (cdb); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); DBG (DBG_proc, "teco_scan: exit, status=%d\n", status); return status; } #if 0 /* Do some vendor specific stuff. */ static SANE_Status teco_vendor_spec (Teco_Scanner * dev) { CDB cdb; SANE_Status status; size_t size; DBG (DBG_proc, "teco_vendor_spec: enter\n"); size = 0x7800; cdb.data[0] = 0x09; cdb.data[1] = 0; cdb.data[2] = 0; cdb.data[3] = (size >> 8) & 0xff; cdb.data[4] = (size >> 0) & 0xff; cdb.data[5] = 0; cdb.len = 6; status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); /*hexdump (DBG_info2, "calibration:", dev->buffer, size); */ cdb.data[0] = 0x0E; cdb.data[1] = 0; cdb.data[2] = 0; cdb.data[3] = 0; cdb.data[4] = 0; cdb.data[5] = 0; cdb.len = 6; status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); return status; } #endif /* Send the gamma * The order is RGB. The last color is unused. * G is also the gray gamma (if gray scan). * * Some scanner have 4 tables of 256 bytes, and some 4 tables of 1024 bytes. */ static SANE_Status teco_send_gamma (Teco_Scanner * dev) { CDB cdb; SANE_Status status; struct { unsigned char gamma[4 * MAX_GAMMA_LENGTH]; } param; size_t i; size_t size; DBG (DBG_proc, "teco_send_gamma: enter\n"); size = 4 * GAMMA_LENGTH; MKSCSI_SEND_10 (cdb, 0x03, 0x02, size); if (dev->val[OPT_CUSTOM_GAMMA].w) { /* Use the custom gamma. */ if (dev->scan_mode == TECO_GRAYSCALE) { /* Gray */ for (i = 0; i < GAMMA_LENGTH; i++) { param.gamma[0 * GAMMA_LENGTH + i] = 0; param.gamma[1 * GAMMA_LENGTH + i] = dev->gamma_GRAY[i]; param.gamma[2 * GAMMA_LENGTH + i] = 0; param.gamma[3 * GAMMA_LENGTH + i] = 0; } } else { /* Color */ for (i = 0; i < GAMMA_LENGTH; i++) { param.gamma[0 * GAMMA_LENGTH + i] = dev->gamma_R[i]; param.gamma[1 * GAMMA_LENGTH + i] = dev->gamma_G[i]; param.gamma[2 * GAMMA_LENGTH + i] = dev->gamma_B[i]; param.gamma[3 * GAMMA_LENGTH + i] = 0; } } } else { if (dev->scan_mode == TECO_BW) { /* Map threshold from a 0..255 scale to a * 0..GAMMA_LENGTH scale. */ unsigned int threshold = dev->val[OPT_THRESHOLD].w * (GAMMA_LENGTH / 256); for (i = 0; i < GAMMA_LENGTH; i++) { param.gamma[0 * GAMMA_LENGTH + i] = 0; if (i < threshold) param.gamma[1 * GAMMA_LENGTH + i] = 0; else param.gamma[1 * GAMMA_LENGTH + i] = 255; param.gamma[2 * GAMMA_LENGTH + i] = 0; param.gamma[3 * GAMMA_LENGTH + i] = 0; } } else { /* * Shift is 1 for GAMMA_LENGTH == 256 * and 4 for GAMMA_LENGTH == 1024 */ int shift = GAMMA_LENGTH >> 8; for (i = 0; i < GAMMA_LENGTH; i++) { param.gamma[0 * GAMMA_LENGTH + i] = i / shift; param.gamma[1 * GAMMA_LENGTH + i] = i / shift; param.gamma[2 * GAMMA_LENGTH + i] = i / shift; param.gamma[3 * GAMMA_LENGTH + i] = 0; } } } hexdump (DBG_info2, "teco_send_gamma:", cdb.data, cdb.len); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, ¶m, size, NULL, NULL); DBG (DBG_proc, "teco_send_gamma: exit, status=%d\n", status); return (status); } /* Attach a scanner to this backend. */ static SANE_Status attach_scanner (const char *devicename, Teco_Scanner ** devp) { Teco_Scanner *dev; int sfd; DBG (DBG_sane_proc, "attach_scanner: %s\n", devicename); if (devp) *devp = NULL; /* Check if we know this device name. */ for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { if (devp) { *devp = dev; } DBG (DBG_info, "device is already known\n"); return SANE_STATUS_GOOD; } } /* Allocate a new scanner entry. */ dev = teco_init (); if (dev == NULL) { DBG (DBG_error, "ERROR: not enough memory\n"); return SANE_STATUS_NO_MEM; } DBG (DBG_info, "attach_scanner: opening %s\n", devicename); if (sanei_scsi_open (devicename, &sfd, teco_sense_handler, dev) != 0) { DBG (DBG_error, "ERROR: attach_scanner: open failed\n"); teco_free (dev); return SANE_STATUS_INVAL; } /* Fill some scanner specific values. */ dev->devicename = strdup (devicename); dev->sfd = sfd; /* Now, check that it is a scanner we support. */ if (teco_identify_scanner (dev) == SANE_FALSE) { DBG (DBG_error, "ERROR: attach_scanner: scanner-identification failed\n"); teco_free (dev); return SANE_STATUS_INVAL; } /* Get the page 0x82. It doesn't appear to be usefull yet. */ teco_get_inquiry_82 (dev); teco_close (dev); /* Set the default options for that scanner. */ dev->sane.name = dev->devicename; dev->sane.vendor = dev->def->real_vendor; dev->sane.model = dev->def->real_product; dev->sane.type = "flatbed scanner"; /* Link the scanner with the others. */ dev->next = first_dev; first_dev = dev; if (devp) { *devp = dev; } num_devices++; DBG (DBG_proc, "attach_scanner: exit\n"); return SANE_STATUS_GOOD; } static SANE_Status attach_one (const char *dev) { attach_scanner (dev, NULL); return SANE_STATUS_GOOD; } /* Reset the options for that scanner. */ static void teco_init_options (Teco_Scanner * dev) { int i; /* Pre-initialize the options. */ memset (dev->opt, 0, sizeof (dev->opt)); memset (dev->val, 0, sizeof (dev->val)); for (i = 0; i < OPT_NUM_OPTIONS; ++i) { dev->opt[i].size = sizeof (SANE_Word); dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* Number of options. */ dev->opt[OPT_NUM_OPTS].name = ""; dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; dev->val[OPT_NUM_OPTS].w = OPT_NUM_OPTIONS; /* Mode group */ dev->opt[OPT_MODE_GROUP].title = SANE_TITLE_SCAN_MODE; dev->opt[OPT_MODE_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_MODE_GROUP].cap = 0; dev->opt[OPT_MODE_GROUP].size = 0; dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Scanner supported modes */ 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_mode_list); dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_MODE].constraint.string_list = scan_mode_list; dev->val[OPT_MODE].s = (SANE_Char *) strdup (""); /* will be set later */ /* X and Y resolution */ 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].unit = SANE_UNIT_DPI; dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_RESOLUTION].constraint.range = &dev->def->res_range; dev->val[OPT_RESOLUTION].w = 100; /* Geometry group */ dev->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); dev->opt[OPT_GEOMETRY_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_GEOMETRY_GROUP].cap = 0; dev->opt[OPT_GEOMETRY_GROUP].size = 0; dev->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Upper left X */ dev->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; dev->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; dev->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; dev->opt[OPT_TL_X].type = SANE_TYPE_FIXED; dev->opt[OPT_TL_X].unit = SANE_UNIT_MM; dev->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_X].constraint.range = &x_range; dev->val[OPT_TL_X].w = x_range.min; /* Upper left Y */ dev->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; dev->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; dev->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; dev->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; dev->opt[OPT_TL_Y].unit = SANE_UNIT_MM; dev->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_Y].constraint.range = &y_range; dev->val[OPT_TL_Y].w = y_range.min; /* Bottom-right x */ dev->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; dev->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; dev->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; dev->opt[OPT_BR_X].type = SANE_TYPE_FIXED; dev->opt[OPT_BR_X].unit = SANE_UNIT_MM; dev->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_X].constraint.range = &x_range; dev->val[OPT_BR_X].w = x_range.max; /* Bottom-right y */ dev->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; dev->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; dev->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; dev->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; dev->opt[OPT_BR_Y].unit = SANE_UNIT_MM; dev->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_Y].constraint.range = &y_range; dev->val[OPT_BR_Y].w = y_range.max; /* Enhancement group */ dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); dev->opt[OPT_ENHANCEMENT_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; dev->opt[OPT_ENHANCEMENT_GROUP].size = 0; dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Halftone pattern */ dev->opt[OPT_DITHER].name = "dither"; dev->opt[OPT_DITHER].title = SANE_I18N ("Dither"); dev->opt[OPT_DITHER].desc = SANE_I18N ("Dither"); dev->opt[OPT_DITHER].type = SANE_TYPE_STRING; dev->opt[OPT_DITHER].size = max_string_size (dither_list); dev->opt[OPT_DITHER].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_DITHER].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_DITHER].constraint.string_list = dither_list; dev->val[OPT_DITHER].s = strdup (dither_list[0]); /* custom-gamma table */ dev->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; dev->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* red gamma vector */ dev->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_R].size = GAMMA_LENGTH * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_R].constraint.range = &gamma_range; dev->val[OPT_GAMMA_VECTOR_R].wa = dev->gamma_R; /* green and gamma vector */ dev->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_G].size = GAMMA_LENGTH * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_G].constraint.range = &gamma_range; dev->val[OPT_GAMMA_VECTOR_G].wa = dev->gamma_G; /* blue gamma vector */ dev->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_B].size = GAMMA_LENGTH * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_B].constraint.range = &gamma_range; dev->val[OPT_GAMMA_VECTOR_B].wa = dev->gamma_B; /* grayscale gamma vector */ dev->opt[OPT_GAMMA_VECTOR_GRAY].name = SANE_NAME_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR_GRAY].title = SANE_TITLE_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR_GRAY].desc = SANE_DESC_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR_GRAY].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_GRAY].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_GRAY].size = GAMMA_LENGTH * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint.range = &gamma_range; dev->val[OPT_GAMMA_VECTOR_GRAY].wa = dev->gamma_GRAY; /* Threshold */ dev->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; dev->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; dev->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; dev->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; dev->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; dev->opt[OPT_THRESHOLD].size = sizeof (SANE_Int); dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_THRESHOLD].constraint.range = &threshold_range; dev->val[OPT_THRESHOLD].w = 128; /* preview */ dev->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; dev->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; dev->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; dev->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; dev->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; dev->val[OPT_PREVIEW].w = SANE_FALSE; /* Lastly, set the default scan mode. This might change some * values previously set here. */ sane_control_option (dev, OPT_MODE, SANE_ACTION_SET_VALUE, (SANE_String_Const *) scan_mode_list[0], NULL); } /* * Wait until the scanner is ready. */ static SANE_Status teco_wait_scanner (Teco_Scanner * dev) { SANE_Status status; int timeout; CDB cdb; DBG (DBG_proc, "teco_wait_scanner: enter\n"); MKSCSI_TEST_UNIT_READY (cdb); /* Set the timeout to 60 seconds. */ timeout = 60; while (timeout > 0) { /* test unit ready */ status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); if (status == SANE_STATUS_GOOD) { return SANE_STATUS_GOOD; } sleep (1); }; DBG (DBG_proc, "teco_wait_scanner: scanner not ready\n"); return (SANE_STATUS_IO_ERROR); } /* Read the image from the scanner and fill the temporary buffer with it. */ static SANE_Status teco_fill_image (Teco_Scanner * dev) { SANE_Status status; size_t size; CDB cdb; unsigned char *image; DBG (DBG_proc, "teco_fill_image: enter\n"); assert (dev->image_begin == dev->image_end); assert (dev->real_bytes_left > 0); dev->image_begin = 0; dev->image_end = 0; while (dev->real_bytes_left) { /* * Try to read the maximum number of bytes. */ size = 0; while (size == 0) { status = get_filled_data_length (dev, &size); if (status) return (status); if (size == 0) usleep (100000); /* sleep 1/10th of second */ } if (size > dev->real_bytes_left) size = dev->real_bytes_left; if (size > dev->image_size - dev->image_end) size = dev->image_size - dev->image_end; /* Always read a multiple of a line. */ size = size - (size % dev->params.bytes_per_line); if (size == 0) { /* Probably reached the end of the buffer. * Check, just in case. */ assert (dev->image_end != 0); return (SANE_STATUS_GOOD); } DBG (DBG_info, "teco_fill_image: to read = %ld bytes (bpl=%d)\n", (long) size, dev->params.bytes_per_line); MKSCSI_READ_10 (cdb, 0, 0, size); hexdump (DBG_info2, "teco_fill_image: READ_10 CDB", cdb.data, 10); image = dev->image + dev->image_end; status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, image, &size); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "teco_fill_image: cannot read from the scanner\n"); return status; } /* The size this scanner returns is always a multiple of lines. */ assert ((size % dev->params.bytes_per_line) == 0); DBG (DBG_info, "teco_fill_image: real bytes left = %ld\n", (long) dev->real_bytes_left); if (dev->scan_mode == TECO_COLOR) { if (dev->def->pass == 1) { /* Reorder the lines. The scanner gives color by color for * each line. */ unsigned char *src = image; int nb_lines = size / dev->params.bytes_per_line; int i, j; for (i = 0; i < nb_lines; i++) { unsigned char *dest = dev->buffer; for (j = 0; j < dev->params.pixels_per_line; j++) { *dest = src[j + 0 * dev->params.pixels_per_line]; dest++; *dest = src[j + 1 * dev->params.pixels_per_line]; dest++; *dest = src[j + 2 * dev->params.pixels_per_line]; dest++; } /* Copy the line back. */ memcpy (src, dev->buffer, dev->params.bytes_per_line); src += dev->params.bytes_per_line; } } } dev->image_end += size; dev->real_bytes_left -= size; } return (SANE_STATUS_GOOD); /* unreachable */ } /* Copy from the raw buffer to the buffer given by the backend. * * len in input is the maximum length available in buf, and, in * output, is the length written into buf. */ static void teco_copy_raw_to_frontend (Teco_Scanner * dev, SANE_Byte * buf, size_t * len) { size_t size; size = dev->image_end - dev->image_begin; if (size > *len) { size = *len; } *len = size; switch (dev->scan_mode) { case TECO_BW: { /* Invert black and white. */ unsigned char *src = dev->image + dev->image_begin; size_t i; for (i = 0; i < size; i++) { *buf = *src ^ 0xff; src++; buf++; } } break; case TECO_GRAYSCALE: case TECO_COLOR: memcpy (buf, dev->image + dev->image_begin, size); break; } dev->image_begin += size; } /* Stop a scan. */ static SANE_Status do_cancel (Teco_Scanner * dev) { DBG (DBG_sane_proc, "do_cancel enter\n"); if (dev->scanning == SANE_TRUE) { /* Reset the scanner */ dev->x_resolution = 300; dev->y_resolution = 300; dev->x_tl = 0; dev->y_tl = 0; dev->width = 0; dev->length = 0; teco_set_window (dev); teco_scan (dev); teco_close (dev); } dev->scanning = SANE_FALSE; DBG (DBG_sane_proc, "do_cancel exit\n"); return SANE_STATUS_CANCELLED; } /*--------------------------------------------------------------------------*/ /* Sane entry points */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { FILE *fp; char dev_name[PATH_MAX]; size_t len; DBG_INIT (); DBG (DBG_sane_init, "sane_init\n"); DBG (DBG_error, "This is sane-teco1 version %d.%d-%d\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (DBG_error, "(C) 2002 by Frank Zago\n"); if (version_code) { *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); } fp = sanei_config_open (TECO_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ attach_scanner ("/dev/scanner", 0); return SANE_STATUS_GOOD; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ sanei_config_attach_matching_devices (dev_name, attach_one); } fclose (fp); DBG (DBG_proc, "sane_init: leave\n"); return SANE_STATUS_GOOD; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { Teco_Scanner *dev; int i; DBG (DBG_proc, "sane_get_devices: enter\n"); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (DBG_proc, "sane_get_devices: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Teco_Scanner *dev; SANE_Status status; DBG (DBG_proc, "sane_open: enter\n"); /* search for devicename */ if (devicename[0]) { DBG (DBG_info, "sane_open: devicename=%s\n", devicename); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { break; } } if (!dev) { status = attach_scanner (devicename, &dev); if (status != SANE_STATUS_GOOD) { return status; } } } else { DBG (DBG_sane_info, "sane_open: no devicename, opening first device\n"); dev = first_dev; /* empty devicename -> use first device */ } if (!dev) { DBG (DBG_error, "No scanner found\n"); return SANE_STATUS_INVAL; } teco_init_options (dev); /* Initialize the gamma table. */ { /* * Shift is 1 for GAMMA_LENGTH == 256 * and 4 for GAMMA_LENGTH == 1024 */ int shift = GAMMA_LENGTH >> 8; size_t i; for (i = 0; i < GAMMA_LENGTH; i++) { dev->gamma_R[i] = i / shift; dev->gamma_G[i] = i / shift; dev->gamma_B[i] = i / shift; dev->gamma_GRAY[i] = i / shift; } } *handle = dev; DBG (DBG_proc, "sane_open: exit\n"); return SANE_STATUS_GOOD; } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Teco_Scanner *dev = handle; DBG (DBG_proc, "sane_get_option_descriptor: enter, option %d\n", option); if ((unsigned) option >= OPT_NUM_OPTIONS) { return NULL; } DBG (DBG_proc, "sane_get_option_descriptor: exit\n"); return dev->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Teco_Scanner *dev = handle; SANE_Status status; SANE_Word cap; SANE_String_Const name; DBG (DBG_proc, "sane_control_option: enter, option %d, action %d\n", option, action); if (info) { *info = 0; } if (dev->scanning) { return SANE_STATUS_DEVICE_BUSY; } if (option < 0 || option >= OPT_NUM_OPTIONS) { return SANE_STATUS_INVAL; } cap = dev->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { return SANE_STATUS_INVAL; } name = dev->opt[option].name; if (!name) { name = "(no name)"; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options */ case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_TL_Y: case OPT_BR_Y: case OPT_TL_X: case OPT_BR_X: case OPT_CUSTOM_GAMMA: case OPT_THRESHOLD: case OPT_PREVIEW: *(SANE_Word *) val = dev->val[option].w; return SANE_STATUS_GOOD; /* string options */ case OPT_MODE: case OPT_DITHER: strcpy (val, dev->val[option].s); return SANE_STATUS_GOOD; /* Gamma */ case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: case OPT_GAMMA_VECTOR_GRAY: memcpy (val, dev->val[option].wa, dev->opt[option].size); return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (DBG_error, "could not set option, not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (dev->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "could not set option, invalid value\n"); return status; } switch (option) { /* Numeric side-effect options */ case OPT_TL_Y: case OPT_BR_Y: case OPT_TL_X: case OPT_BR_X: case OPT_RESOLUTION: if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } dev->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* Numeric side-effect free options */ case OPT_THRESHOLD: case OPT_PREVIEW: dev->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* String side-effect free options */ case OPT_DITHER: free (dev->val[option].s); dev->val[option].s = (SANE_String) strdup (val); return SANE_STATUS_GOOD; /* String side-effect options */ case OPT_MODE: if (strcmp (dev->val[option].s, val) == 0) return SANE_STATUS_GOOD; free (dev->val[OPT_MODE].s); dev->val[OPT_MODE].s = (SANE_Char *) strdup (val); dev->opt[OPT_DITHER].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; if (strcmp (dev->val[OPT_MODE].s, BLACK_WHITE_STR) == 0) { dev->depth = 8; dev->scan_mode = TECO_BW; dev->opt[OPT_DITHER].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; } else if (strcmp (dev->val[OPT_MODE].s, GRAY_STR) == 0) { dev->scan_mode = TECO_GRAYSCALE; dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (dev->val[OPT_CUSTOM_GAMMA].w) { dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= ~SANE_CAP_INACTIVE; } dev->depth = 8; } else if (strcmp (dev->val[OPT_MODE].s, COLOR_STR) == 0) { dev->scan_mode = TECO_COLOR; dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (dev->val[OPT_CUSTOM_GAMMA].w) { dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } dev->depth = 8; } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: case OPT_GAMMA_VECTOR_GRAY: memcpy (dev->val[option].wa, val, dev->opt[option].size); return SANE_STATUS_GOOD; case OPT_CUSTOM_GAMMA: dev->val[OPT_CUSTOM_GAMMA].w = *(SANE_Word *) val; if (dev->val[OPT_CUSTOM_GAMMA].w) { /* use custom_gamma_table */ if (dev->scan_mode == TECO_GRAYSCALE) { dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= ~SANE_CAP_INACTIVE; } else { /* color mode */ dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } else { dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } DBG (DBG_proc, "sane_control_option: exit, bad\n"); return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Teco_Scanner *dev = handle; DBG (DBG_proc, "sane_get_parameters: enter\n"); if (!(dev->scanning)) { /* Setup the parameters for the scan. These values will be re-used * in the SET WINDOWS command. */ if (dev->val[OPT_PREVIEW].w == SANE_TRUE) { dev->x_resolution = 22; dev->y_resolution = 22; dev->x_tl = 0; dev->y_tl = 0; dev->x_br = mmToIlu (SANE_UNFIX (x_range.max)); dev->y_br = mmToIlu (SANE_UNFIX (y_range.max)); } else { dev->x_resolution = dev->val[OPT_RESOLUTION].w; dev->y_resolution = dev->val[OPT_RESOLUTION].w; if (dev->x_resolution > dev->def->x_resolution_max) { dev->x_resolution = dev->def->x_resolution_max; } dev->x_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_X].w)); dev->y_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_Y].w)); dev->x_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_X].w)); dev->y_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_Y].w)); } /* Check the corners are OK. */ if (dev->x_tl > dev->x_br) { int s; s = dev->x_tl; dev->x_tl = dev->x_br; dev->x_br = s; } if (dev->y_tl > dev->y_br) { int s; s = dev->y_tl; dev->y_tl = dev->y_br; dev->y_br = s; } dev->width = dev->x_br - dev->x_tl; dev->length = dev->y_br - dev->y_tl; /* Prepare the parameters for the caller. */ memset (&dev->params, 0, sizeof (SANE_Parameters)); dev->params.last_frame = SANE_TRUE; switch (dev->scan_mode) { case TECO_BW: dev->params.format = SANE_FRAME_GRAY; dev->params.pixels_per_line = ((dev->width * dev->x_resolution) / 300) & ~0x7; dev->params.bytes_per_line = dev->params.pixels_per_line / 8; dev->params.depth = 1; dev->pass = 1; break; case TECO_GRAYSCALE: dev->params.format = SANE_FRAME_GRAY; dev->params.pixels_per_line = ((dev->width * dev->x_resolution) / 300); dev->params.bytes_per_line = dev->params.pixels_per_line; dev->params.depth = 8; dev->pass = 1; break; case TECO_COLOR: dev->params.format = SANE_FRAME_RGB; dev->params.pixels_per_line = ((dev->width * dev->x_resolution) / 300); dev->pass = dev->def->pass; dev->params.bytes_per_line = dev->params.pixels_per_line * 3; dev->params.depth = 8; break; } dev->params.lines = (dev->length * dev->y_resolution) / 300; } /* Return the current values. */ if (params) { *params = (dev->params); } DBG (DBG_proc, "sane_get_parameters: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Teco_Scanner *dev = handle; SANE_Status status; size_t size; DBG (DBG_proc, "sane_start: enter\n"); if (!(dev->scanning)) { /* Open again the scanner. */ if (sanei_scsi_open (dev->devicename, &(dev->sfd), teco_sense_handler, dev) != 0) { DBG (DBG_error, "ERROR: sane_start: open failed\n"); return SANE_STATUS_INVAL; } /* Set the correct parameters. */ sane_get_parameters (dev, NULL); /* The scanner must be ready. */ status = teco_wait_scanner (dev); if (status) { teco_close (dev); return status; } status = teco_mode_select (dev); if (status) { teco_close (dev); return status; } if (dev->scan_mode == TECO_COLOR) { dev->pass = dev->def->pass; } else { dev->pass = 1; } if (dev->def->tecoref != TECO_VM3510) { status = teco_set_window (dev); if (status) { teco_close (dev); return status; } dev->real_bytes_left = 0; status = get_filled_data_length (dev, &size); if (status) { teco_close (dev); return status; } } #if 0 /* The windows driver does that, but some scanners don't like it. */ teco_vendor_spec (dev); if (status) { teco_close (dev); return status; } #endif status = teco_send_gamma (dev); if (status) { teco_close (dev); return status; } status = teco_set_window (dev); if (status) { teco_close (dev); return status; } status = teco_scan (dev); if (status) { teco_close (dev); return status; } if (dev->def->tecoref == TECO_VM3510) { dev->real_bytes_left = 0; status = get_filled_data_length (dev, &size); if (status) { teco_close (dev); return status; } } } else { /* Scan has already started. */ dev->pass--; } /* Set the frame parameter. */ if (dev->scan_mode == TECO_COLOR && dev->def->pass > 1) { SANE_Frame frames[] = { 0, SANE_FRAME_BLUE, SANE_FRAME_GREEN, SANE_FRAME_RED }; dev->params.format = frames[dev->pass]; } /* Is it the last frame? */ if (dev->pass > 1) { dev->params.last_frame = SANE_FALSE; } else { dev->params.last_frame = SANE_TRUE; } dev->image_end = 0; dev->image_begin = 0; dev->bytes_left = dev->params.bytes_per_line * dev->params.lines; dev->real_bytes_left = dev->params.bytes_per_line * dev->params.lines; dev->scanning = SANE_TRUE; DBG (DBG_proc, "sane_start: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { SANE_Status status; Teco_Scanner *dev = handle; size_t size; int buf_offset; /* offset into buf */ DBG (DBG_proc, "sane_read: enter\n"); *len = 0; if (!(dev->scanning)) { /* OOPS, not scanning */ return do_cancel (dev); } if (dev->bytes_left <= 0) { return (SANE_STATUS_EOF); } buf_offset = 0; do { if (dev->image_begin == dev->image_end) { /* Fill image */ status = teco_fill_image (dev); if (status != SANE_STATUS_GOOD) { return (status); } } /* Something must have been read */ if (dev->image_begin == dev->image_end) { DBG (DBG_info, "sane_read: nothing read\n"); return SANE_STATUS_IO_ERROR; } /* Copy the data to the frontend buffer. */ size = max_len - buf_offset; if (size > dev->bytes_left) { size = dev->bytes_left; } teco_copy_raw_to_frontend (dev, buf + buf_offset, &size); buf_offset += size; dev->bytes_left -= size; *len += size; } while ((buf_offset != max_len) && dev->bytes_left); DBG (DBG_info, "sane_read: leave, bytes_left=%ld\n", (long) dev->bytes_left); return SANE_STATUS_GOOD; } SANE_Status sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { SANE_Status status; Teco_Scanner *dev = handle; DBG (DBG_proc, "sane_set_io_mode: enter\n"); if (dev->scanning == SANE_FALSE) { return SANE_STATUS_INVAL; } if (non_blocking == SANE_FALSE) { status = SANE_STATUS_GOOD; } else { status = SANE_STATUS_UNSUPPORTED; } DBG (DBG_proc, "sane_set_io_mode: exit\n"); return status; } SANE_Status sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ *fd) { DBG (DBG_proc, "sane_get_select_fd: enter\n"); DBG (DBG_proc, "sane_get_select_fd: exit\n"); return SANE_STATUS_UNSUPPORTED; } void sane_cancel (SANE_Handle handle) { Teco_Scanner *dev = handle; DBG (DBG_proc, "sane_cancel: enter\n"); do_cancel (dev); DBG (DBG_proc, "sane_cancel: exit\n"); } void sane_close (SANE_Handle handle) { Teco_Scanner *dev = handle; Teco_Scanner *dev_tmp; DBG (DBG_proc, "sane_close: enter\n"); do_cancel (dev); teco_close (dev); /* Unlink dev. */ if (first_dev == dev) { first_dev = dev->next; } else { dev_tmp = first_dev; while (dev_tmp->next && dev_tmp->next != dev) { dev_tmp = dev_tmp->next; } if (dev_tmp->next != NULL) { dev_tmp->next = dev_tmp->next->next; } } teco_free (dev); num_devices--; DBG (DBG_proc, "sane_close: exit\n"); } void sane_exit (void) { DBG (DBG_proc, "sane_exit: enter\n"); while (first_dev) { sane_close (first_dev); } if (devlist) { free (devlist); devlist = NULL; } DBG (DBG_proc, "sane_exit: exit\n"); } sane-backends-1.0.29/backend/teco3.c0000666000000000000000000015372313615534521013764 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002 Frank Zago (sane at zago dot net) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* $Id$ VM3552 (and maybe VM4552 and VM6552) */ /*--------------------------------------------------------------------------*/ #define BUILD 1 /* 2002/08/06 */ #define BACKEND_NAME teco3 #define TECO_CONFIG_FILE "teco3.conf" /*--------------------------------------------------------------------------*/ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/lassert.h" #include "teco3.h" /*--------------------------------------------------------------------------*/ /* Lists of possible scan modes. */ static SANE_String_Const scan_mode_list[] = { BLACK_WHITE_STR, GRAY_STR, COLOR_STR, NULL }; /*--------------------------------------------------------------------------*/ /* Minimum and maximum width and length supported. */ static SANE_Range x_range = { SANE_FIX (0), SANE_FIX (8.5 * MM_PER_INCH), 0 }; static SANE_Range y_range = { SANE_FIX (0), SANE_FIX (14 * MM_PER_INCH), 0 }; /*--------------------------------------------------------------------------*/ /* Gamma range */ static const SANE_Range gamma_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; /*--------------------------------------------------------------------------*/ /* List of dithering options. */ static SANE_String_Const dither_list[] = { "Line art", "2x2", "3x3", "4x4 bayer", "4x4 smooth", "8x8 bayer", "8x8 smooth", "8x8 horizontal", "8x8 vertical", NULL }; static const int dither_val[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; /*--------------------------------------------------------------------------*/ static const SANE_Range threshold_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; /*--------------------------------------------------------------------------*/ /* Define the supported scanners and their characteristics. */ static const struct scanners_supported scanners[] = { { 6, "TECO VM3552", TECO_VM3552, "Relisys", "Scorpio", {1, 1200, 1}, /* resolution range */ 300, 1200 /* max x and Y resolution */ } }; /*--------------------------------------------------------------------------*/ /* List of scanner attached. */ static Teco_Scanner *first_dev = NULL; static int num_devices = 0; static const SANE_Device **devlist = NULL; /* Local functions. */ /* Display a buffer in the log. */ static void hexdump (int level, const char *comment, unsigned char *p, int l) { int i; char line[128]; char *ptr; char asc_buf[17]; char *asc_ptr; DBG (level, "%s\n", comment); ptr = line; *ptr = '\0'; asc_ptr = asc_buf; *asc_ptr = '\0'; for (i = 0; i < l; i++, p++) { if ((i % 16) == 0) { if (ptr != line) { DBG (level, "%s %s\n", line, asc_buf); ptr = line; *ptr = '\0'; asc_ptr = asc_buf; *asc_ptr = '\0'; } sprintf (ptr, "%3.3d:", i); ptr += 4; } ptr += sprintf (ptr, " %2.2x", *p); if (*p >= 32 && *p <= 127) { asc_ptr += sprintf (asc_ptr, "%c", *p); } else { asc_ptr += sprintf (asc_ptr, "."); } } *ptr = '\0'; DBG (level, "%s %s\n", line, asc_buf); } /* Returns the length of the longest string, including the terminating * character. */ static size_t max_string_size (SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) { max_size = size; } } return max_size; } /* Lookup a string list from one array and return its index. */ static int get_string_list_index (SANE_String_Const list[], SANE_String_Const name) { int index; index = 0; while (list[index] != NULL) { if (strcmp (list[index], name) == 0) { return (index); } index++; } DBG (DBG_error, "name %s not found in list\n", name); assert (0 == 1); /* bug in backend, core dump */ return (-1); } /* Initialize a scanner entry. Return an allocated scanner with some * preset values. */ static Teco_Scanner * teco_init (void) { Teco_Scanner *dev; DBG (DBG_proc, "teco_init: enter\n"); /* Allocate a new scanner entry. */ dev = malloc (sizeof (Teco_Scanner)); if (dev == NULL) { return NULL; } memset (dev, 0, sizeof (Teco_Scanner)); /* Allocate the buffer used to transfer the SCSI data. */ dev->buffer_size = 64 * 1024; dev->buffer = malloc (dev->buffer_size); if (dev->buffer == NULL) { free (dev); return NULL; } dev->sfd = -1; DBG (DBG_proc, "teco_init: exit\n"); return (dev); } /* Closes an open scanner. */ static void teco_close (Teco_Scanner * dev) { DBG (DBG_proc, "teco_close: enter\n"); if (dev->sfd != -1) { sanei_scsi_close (dev->sfd); dev->sfd = -1; } DBG (DBG_proc, "teco_close: exit\n"); } /* Frees the memory used by a scanner. */ static void teco_free (Teco_Scanner * dev) { int i; DBG (DBG_proc, "teco_free: enter\n"); if (dev == NULL) return; teco_close (dev); if (dev->devicename) { free (dev->devicename); } if (dev->buffer) { free (dev->buffer); } if (dev->image) { free (dev->image); } for (i = 1; i < OPT_NUM_OPTIONS; i++) { if (dev->opt[i].type == SANE_TYPE_STRING && dev->val[i].s) { free (dev->val[i].s); } } free (dev); DBG (DBG_proc, "teco_free: exit\n"); } /* Inquiry a device and returns TRUE if is supported. */ static int teco_identify_scanner (Teco_Scanner * dev) { CDB cdb; SANE_Status status; size_t size; int i; DBG (DBG_proc, "teco_identify_scanner: enter\n"); size = 5; MKSCSI_INQUIRY (cdb, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status) { DBG (DBG_error, "teco_identify_scanner: inquiry failed with status %s\n", sane_strstatus (status)); return (SANE_FALSE); } size = dev->buffer[4] + 5; /* total length of the inquiry data */ if (size < 53) { DBG (DBG_error, "teco_identify_scanner: not enough data to identify device\n"); return (SANE_FALSE); } MKSCSI_INQUIRY (cdb, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (status) { DBG (DBG_error, "teco_identify_scanner: inquiry failed with status %s\n", sane_strstatus (status)); return (SANE_FALSE); } hexdump (DBG_info2, "inquiry", dev->buffer, size); dev->scsi_type = dev->buffer[0] & 0x1f; memcpy (dev->scsi_vendor, dev->buffer + 0x08, 0x08); dev->scsi_vendor[0x08] = 0; memcpy (dev->scsi_product, dev->buffer + 0x10, 0x010); dev->scsi_product[0x10] = 0; memcpy (dev->scsi_version, dev->buffer + 0x20, 0x04); dev->scsi_version[0x04] = 0; memcpy (dev->scsi_teco_name, dev->buffer + 0x2A, 0x0B); dev->scsi_teco_name[0x0B] = 0; DBG (DBG_info, "device is \"%s\" \"%s\" \"%s\" \"%s\"\n", dev->scsi_vendor, dev->scsi_product, dev->scsi_version, dev->scsi_teco_name); /* Lookup through the supported scanners table to find if this * backend supports that one. */ for (i = 0; i < NELEMS (scanners); i++) { if (dev->scsi_type == scanners[i].scsi_type && strcmp (dev->scsi_teco_name, scanners[i].scsi_teco_name) == 0) { DBG (DBG_error, "teco_identify_scanner: scanner supported\n"); dev->def = &(scanners[i]); return (SANE_TRUE); } } DBG (DBG_proc, "teco_identify_scanner: exit, device not supported\n"); return (SANE_FALSE); } /* SCSI sense handler. Callback for SANE. * These scanners never set asc or ascq. */ static SANE_Status teco_sense_handler (int __sane_unused__ scsi_fd, unsigned char *result, void __sane_unused__ *arg) { int sensekey; int len; DBG (DBG_proc, "teco_sense_handler: enter\n"); sensekey = get_RS_sense_key (result); len = 7 + get_RS_additional_length (result); hexdump (DBG_info2, "sense", result, len); if (get_RS_error_code (result) != 0x70) { DBG (DBG_error, "teco_sense_handler: invalid sense key error code (%d)\n", get_RS_error_code (result)); return SANE_STATUS_IO_ERROR; } if (len < 14) { DBG (DBG_error, "teco_sense_handler: sense too short, no ASC/ASCQ\n"); return SANE_STATUS_IO_ERROR; } DBG (DBG_sense, "teco_sense_handler: sense=%d\n", sensekey); if (sensekey == 0x00) { return SANE_STATUS_GOOD; } return SANE_STATUS_IO_ERROR; } /* Set a window. */ static SANE_Status teco_set_window (Teco_Scanner * dev) { size_t window_size; CDB cdb; unsigned char window[255]; SANE_Status status; int i; DBG (DBG_proc, "teco_set_window: enter\n"); /* size of the whole windows block */ switch (dev->def->tecoref) { case TECO_VM3552: window_size = 69; break; default: assert(0); } MKSCSI_SET_WINDOW (cdb, window_size); memset (window, 0, window_size); /* size of the windows descriptor block */ window[7] = window_size - 8; /* X and Y resolution */ Ito16 (dev->x_resolution, &window[10]); Ito16 (dev->y_resolution, &window[12]); /* Upper Left (X,Y) */ Ito32 (dev->x_tl, &window[14]); Ito32 (dev->y_tl, &window[18]); /* Width and length */ Ito32 (dev->width, &window[22]); Ito32 (dev->length, &window[26]); /* Image Composition */ switch (dev->scan_mode) { case TECO_BW: window[31] = dev->val[OPT_THRESHOLD].w; window[33] = 0x00; i = get_string_list_index (dither_list, dev->val[OPT_DITHER].s); window[36] = dither_val[i]; break; case TECO_GRAYSCALE: window[31] = 0x80; window[33] = 0x02; break; case TECO_COLOR: window[31] = 0x80; window[33] = 0x05; break; } /* Depth */ window[34] = dev->depth; /* Unknown - invariants */ window[37] = 0x80; switch (dev->def->tecoref) { case TECO_VM3552: window[48] = 0x01; window[50] = 0x02; window[53] = 0xff; window[57] = 0xff; window[61] = 0xff; window[65] = 0xff; break; } hexdump (DBG_info2, "windows", window, window_size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, window, window_size, NULL, NULL); DBG (DBG_proc, "teco_set_window: exit, status=%d\n", status); return status; } /* Park the CCD */ static SANE_Status teco_reset_window (Teco_Scanner * dev) { SANE_Status status; CDB cdb; DBG (DBG_proc, "teco_reset_window: enter\n"); MKSCSI_OBJECT_POSITION (cdb, 0); hexdump (DBG_info2, "CDB:", cdb.data, cdb.len); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); DBG (DBG_proc, "teco_reset_window: leave, status=%d\n", status); return status; } /* Return the number of byte that can be read. */ static SANE_Status get_filled_data_length (Teco_Scanner * dev, size_t * to_read) { size_t size; CDB cdb; SANE_Status status; DBG (DBG_proc, "get_filled_data_length: enter\n"); *to_read = 0; size = 0x12; MKSCSI_GET_DATA_BUFFER_STATUS (cdb, 1, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); if (size < 0x10) { DBG (DBG_error, "get_filled_data_length: not enough data returned (%ld)\n", (long) size); } hexdump (DBG_info2, "get_filled_data_length return", dev->buffer, size); *to_read = B24TOI (&dev->buffer[9]); DBG (DBG_info, "%d %d - %d %d\n", dev->params.lines, B16TOI (&dev->buffer[12]), dev->params.bytes_per_line, B16TOI (&dev->buffer[14])); if (dev->real_bytes_left == 0) { DBG (DBG_error, "get_filled_data_length: internal scanner buffer size is %d bytes\n", B24TOI (&dev->buffer[6])); /* Beginning of a scan. */ dev->params.lines = B16TOI (&dev->buffer[12]); dev->bytes_per_raster = B16TOI (&dev->buffer[14]); switch (dev->scan_mode) { case TECO_BW: dev->params.bytes_per_line = B16TOI (&dev->buffer[14]); dev->params.pixels_per_line = dev->params.bytes_per_line * 8; break; case TECO_GRAYSCALE: dev->params.pixels_per_line = B16TOI (&dev->buffer[14]); dev->params.bytes_per_line = dev->params.pixels_per_line; break; case TECO_COLOR: dev->params.pixels_per_line = B16TOI (&dev->buffer[14]); dev->params.bytes_per_line = dev->params.pixels_per_line * 3; if (dev->buffer[17] == 0x07) { /* There is no RAM extension present. The colors will * be shifted and the backend will need to fix that. */ dev->does_color_shift = 1; } else { dev->does_color_shift = 0; } break; } } DBG (DBG_info, "get_filled_data_length: to read = %ld\n", (long) *to_read); DBG (DBG_proc, "get_filled_data_length: exit, status=%d\n", status); return (status); } /* Start a scan. */ static SANE_Status teco_scan (Teco_Scanner * dev) { CDB cdb; SANE_Status status; DBG (DBG_proc, "teco_scan: enter\n"); MKSCSI_SCAN (cdb); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); DBG (DBG_proc, "teco_scan: exit, status=%d\n", status); return status; } /* Do some vendor specific stuff. */ static SANE_Status teco_vendor_spec (Teco_Scanner * dev) { CDB cdb; SANE_Status status; size_t size; DBG (DBG_proc, "teco_vendor_spec: enter\n"); size = 0x7800; cdb.data[0] = 0x09; cdb.data[1] = 0; cdb.data[2] = 0; cdb.data[3] = (size >> 8) & 0xff; cdb.data[4] = (size >> 0) & 0xff; cdb.data[5] = 0; cdb.len = 6; status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, dev->buffer, &size); /*hexdump (DBG_info2, "calibration:", dev->buffer, size); */ cdb.data[0] = 0x0E; cdb.data[1] = 0; cdb.data[2] = 0; cdb.data[3] = 0; cdb.data[4] = 0; cdb.data[5] = 0; cdb.len = 6; status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); return status; } /* Send the gamma */ static SANE_Status teco_send_gamma (Teco_Scanner * dev) { CDB cdb; SANE_Status status; struct { unsigned char gamma_R[GAMMA_LENGTH]; unsigned char gamma_G[GAMMA_LENGTH]; /* also gray */ unsigned char gamma_B[GAMMA_LENGTH]; unsigned char gamma_unused[GAMMA_LENGTH]; } param; size_t i; size_t size; DBG (DBG_proc, "teco_send_gamma: enter\n"); size = sizeof (param); assert (size == 4 * GAMMA_LENGTH); MKSCSI_SEND_10 (cdb, 0x03, 0x02, size); if (dev->val[OPT_CUSTOM_GAMMA].w) { /* Use the custom gamma. */ if (dev->scan_mode == TECO_GRAYSCALE) { /* Gray */ for (i = 0; i < GAMMA_LENGTH; i++) { param.gamma_R[i] = 0; param.gamma_G[i] = dev->gamma_GRAY[i]; param.gamma_B[i] = 0; param.gamma_unused[i] = 0; } } else { /* Color */ for (i = 0; i < GAMMA_LENGTH; i++) { param.gamma_R[i] = dev->gamma_R[i]; param.gamma_G[i] = dev->gamma_G[i]; param.gamma_B[i] = dev->gamma_B[i]; param.gamma_unused[i] = 0; } } } else { for (i = 0; i < GAMMA_LENGTH; i++) { param.gamma_R[i] = i / 4; param.gamma_G[i] = i / 4; param.gamma_B[i] = i / 4; param.gamma_unused[i] = 0; } } hexdump (DBG_info2, "teco_send_gamma:", cdb.data, cdb.len); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, ¶m, size, NULL, NULL); DBG (DBG_proc, "teco_send_gamma: exit, status=%d\n", status); return (status); } /* Attach a scanner to this backend. */ static SANE_Status attach_scanner (const char *devicename, Teco_Scanner ** devp) { Teco_Scanner *dev; SANE_Status status; int sfd; DBG (DBG_sane_proc, "attach_scanner: %s\n", devicename); if (devp) *devp = NULL; /* Check if we know this device name. */ for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { if (devp) { *devp = dev; } DBG (DBG_info, "device is already known\n"); return SANE_STATUS_GOOD; } } /* Allocate a new scanner entry. */ dev = teco_init (); if (dev == NULL) { DBG (DBG_error, "ERROR: not enough memory\n"); return SANE_STATUS_NO_MEM; } DBG (DBG_info, "attach_scanner: opening %s\n", devicename); status = sanei_scsi_open (devicename, &sfd, teco_sense_handler, dev); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "ERROR: attach_scanner: open failed (%s)\n", sane_strstatus (status)); teco_free (dev); return SANE_STATUS_INVAL; } /* Fill some scanner specific values. */ dev->devicename = strdup (devicename); dev->sfd = sfd; /* Now, check that it is a scanner we support. */ if (teco_identify_scanner (dev) == SANE_FALSE) { DBG (DBG_error, "ERROR: attach_scanner: scanner-identification failed\n"); teco_free (dev); return SANE_STATUS_INVAL; } teco_close (dev); /* Set the default options for that scanner. */ dev->sane.name = dev->devicename; dev->sane.vendor = dev->def->real_vendor; dev->sane.model = dev->def->real_product; dev->sane.type = "flatbed scanner"; /* Link the scanner with the others. */ dev->next = first_dev; first_dev = dev; if (devp) { *devp = dev; } num_devices++; DBG (DBG_proc, "attach_scanner: exit\n"); return SANE_STATUS_GOOD; } static SANE_Status attach_one (const char *dev) { attach_scanner (dev, NULL); return SANE_STATUS_GOOD; } /* Reset the options for that scanner. */ static void teco_init_options (Teco_Scanner * dev) { int i; /* Pre-initialize the options. */ memset (dev->opt, 0, sizeof (dev->opt)); memset (dev->val, 0, sizeof (dev->val)); for (i = 0; i < OPT_NUM_OPTIONS; ++i) { dev->opt[i].size = sizeof (SANE_Word); dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* Number of options. */ dev->opt[OPT_NUM_OPTS].name = ""; dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; dev->val[OPT_NUM_OPTS].w = OPT_NUM_OPTIONS; /* Mode group */ dev->opt[OPT_MODE_GROUP].title = SANE_TITLE_SCAN_MODE; dev->opt[OPT_MODE_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_MODE_GROUP].cap = 0; dev->opt[OPT_MODE_GROUP].size = 0; dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Scanner supported modes */ 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_mode_list); dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_MODE].constraint.string_list = scan_mode_list; dev->val[OPT_MODE].s = (SANE_Char *) strdup (""); /* will be set later */ /* X and Y resolution */ 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].unit = SANE_UNIT_DPI; dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_RESOLUTION].constraint.range = &dev->def->res_range; dev->val[OPT_RESOLUTION].w = 100; /* Geometry group */ dev->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); dev->opt[OPT_GEOMETRY_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_GEOMETRY_GROUP].cap = 0; dev->opt[OPT_GEOMETRY_GROUP].size = 0; dev->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Upper left X */ dev->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; dev->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; dev->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; dev->opt[OPT_TL_X].type = SANE_TYPE_FIXED; dev->opt[OPT_TL_X].unit = SANE_UNIT_MM; dev->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_X].constraint.range = &x_range; dev->val[OPT_TL_X].w = x_range.min; /* Upper left Y */ dev->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; dev->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; dev->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; dev->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; dev->opt[OPT_TL_Y].unit = SANE_UNIT_MM; dev->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_TL_Y].constraint.range = &y_range; dev->val[OPT_TL_Y].w = y_range.min; /* Bottom-right x */ dev->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; dev->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; dev->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; dev->opt[OPT_BR_X].type = SANE_TYPE_FIXED; dev->opt[OPT_BR_X].unit = SANE_UNIT_MM; dev->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_X].constraint.range = &x_range; dev->val[OPT_BR_X].w = x_range.max; /* Bottom-right y */ dev->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; dev->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; dev->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; dev->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; dev->opt[OPT_BR_Y].unit = SANE_UNIT_MM; dev->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_BR_Y].constraint.range = &y_range; dev->val[OPT_BR_Y].w = y_range.max; /* Enhancement group */ dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); dev->opt[OPT_ENHANCEMENT_GROUP].desc = ""; /* not valid for a group */ dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; dev->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; dev->opt[OPT_ENHANCEMENT_GROUP].size = 0; dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Halftone pattern */ dev->opt[OPT_DITHER].name = "dither"; dev->opt[OPT_DITHER].title = SANE_I18N ("Dither"); dev->opt[OPT_DITHER].desc = SANE_I18N ("Dither"); dev->opt[OPT_DITHER].type = SANE_TYPE_STRING; dev->opt[OPT_DITHER].size = max_string_size (dither_list); dev->opt[OPT_DITHER].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_DITHER].constraint_type = SANE_CONSTRAINT_STRING_LIST; dev->opt[OPT_DITHER].constraint.string_list = dither_list; dev->val[OPT_DITHER].s = strdup (dither_list[0]); /* custom-gamma table */ dev->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; dev->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; dev->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* red gamma vector */ dev->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; dev->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_R].size = GAMMA_LENGTH * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_R].constraint.range = &gamma_range; dev->val[OPT_GAMMA_VECTOR_R].wa = dev->gamma_R; /* green and gamma vector */ dev->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; dev->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_G].size = GAMMA_LENGTH * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_G].constraint.range = &gamma_range; dev->val[OPT_GAMMA_VECTOR_G].wa = dev->gamma_G; /* blue gamma vector */ dev->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; dev->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_B].size = GAMMA_LENGTH * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_B].constraint.range = &gamma_range; dev->val[OPT_GAMMA_VECTOR_B].wa = dev->gamma_B; /* grayscale gamma vector */ dev->opt[OPT_GAMMA_VECTOR_GRAY].name = SANE_NAME_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR_GRAY].title = SANE_TITLE_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR_GRAY].desc = SANE_DESC_GAMMA_VECTOR; dev->opt[OPT_GAMMA_VECTOR_GRAY].type = SANE_TYPE_INT; dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_GRAY].unit = SANE_UNIT_NONE; dev->opt[OPT_GAMMA_VECTOR_GRAY].size = GAMMA_LENGTH * sizeof (SANE_Word); dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint.range = &gamma_range; dev->val[OPT_GAMMA_VECTOR_GRAY].wa = dev->gamma_GRAY; /* Threshold */ dev->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; dev->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; dev->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; dev->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; dev->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; dev->opt[OPT_THRESHOLD].size = sizeof (SANE_Int); dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; dev->opt[OPT_THRESHOLD].constraint.range = &threshold_range; dev->val[OPT_THRESHOLD].w = 128; /* preview */ dev->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; dev->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; dev->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; dev->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; dev->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; dev->val[OPT_PREVIEW].w = SANE_FALSE; /* Lastly, set the default scan mode. This might change some * values previously set here. */ sane_control_option (dev, OPT_MODE, SANE_ACTION_SET_VALUE, (SANE_String_Const *) scan_mode_list[0], NULL); } /* * Wait until the scanner is ready. */ static SANE_Status teco_wait_scanner (Teco_Scanner * dev) { SANE_Status status; int timeout; CDB cdb; DBG (DBG_proc, "teco_wait_scanner: enter\n"); MKSCSI_TEST_UNIT_READY (cdb); /* Set the timeout to 60 seconds. */ timeout = 60; while (timeout > 0) { /* test unit ready */ status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); if (status == SANE_STATUS_GOOD) { return SANE_STATUS_GOOD; } sleep (1); }; DBG (DBG_proc, "teco_wait_scanner: scanner not ready\n"); return (SANE_STATUS_IO_ERROR); } /* * Get the sense */ static SANE_Status teco_query_sense (Teco_Scanner * dev) { SANE_Status status; unsigned char buf[255]; CDB cdb; size_t size; DBG (DBG_proc, "teco_wait_scanner: enter\n"); size = sizeof (buf); MKSCSI_REQUEST_SENSE (cdb, size); status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, buf, &size); hexdump (DBG_info2, "sense", buf, size); DBG (DBG_error, "teco_query_sense: return (%s)\n", sane_strstatus (status)); return (status); } /* * Adjust the rasters. This function is used during a color scan, * because the scanner does not present a format sane can interpret * directly. * * The scanner sends the colors by rasters (B then G then R), whereas * sane is waiting for a group of 3 bytes per color. To make things * funnier, the rasters are shifted. The format of those raster is: * BGR...BGR * * For a proper scan, the first 2 R and 1 G, and the last 1 G and 2 B * must be ignored. (TODO) * * So this function reorders all that mess. It gets the input from * dev->buffer and write the output in dev->image. size_in the the * length of the valid data in dev->buffer. */ /* 0=red, 1=green, 2=blue */ #define COLOR_0 2 #define COLOR_1 1 #define COLOR_2 0 #define line_shift ( - dev->color_shift) static void teco_adjust_raster (Teco_Scanner * dev, size_t size_in) { int nb_rasters; /* number of rasters in dev->buffer */ int raster; /* current raster number in buffer */ int line; /* line number for that raster */ int color = -1; /* color for that raster */ size_t offset; DBG (DBG_proc, "teco_adjust_raster: enter\n"); assert (dev->scan_mode == TECO_COLOR); assert ((size_in % dev->bytes_per_raster) == 0); if (size_in == 0) { return; } /* * The color coding is one line for each color (in the RGB order). * Recombine that stuff to create a RGB value for each pixel. */ nb_rasters = size_in / dev->raster_size; for (raster = 0; raster < nb_rasters; raster++) { /* * Find the color to which this raster belongs to. */ line = 0; if (dev->raster_num < dev->color_shift) { color = COLOR_0; line = dev->raster_num; } else if (dev->raster_num < (3 * dev->color_shift)) { if ((dev->raster_num - line_shift) % 2) { color = COLOR_1; line = (dev->raster_num + line_shift) / 2; } else { color = COLOR_0; line = (dev->raster_num - line_shift) / 2; } } else if (dev->raster_num >= dev->raster_real - dev->color_shift) { color = COLOR_2; line = dev->line; } else if (dev->raster_num >= dev->raster_real - 3 * dev->color_shift) { if ((dev->raster_real - dev->raster_num - line_shift) % 2) { color = COLOR_2; line = dev->line; } else { color = COLOR_1; line = dev->line - line_shift; } } else { switch ((dev->raster_num - 3 * line_shift) % 3) { case 0: color = COLOR_0; line = (dev->raster_num - 3 * line_shift) / 3; break; case 1: color = COLOR_1; line = dev->raster_num / 3; break; case 2: color = COLOR_2; line = (dev->raster_num + 3 * line_shift) / 3; break; } } /* Adjust the line number relative to the image. */ line -= dev->line; offset = dev->image_end + line * dev->params.bytes_per_line; assert (offset <= (dev->image_size - dev->params.bytes_per_line)); /* Copy the raster to the temporary image. */ { int i; unsigned char *src = dev->buffer + raster * dev->raster_size; unsigned char *dest = dev->image + offset + color; for (i = 0; i < dev->raster_size; i++) { *dest = *src; src++; dest += 3; } assert (dest <= (dev->image + dev->image_size + 2)); } DBG (DBG_info, "raster=%d, line=%d, color=%d\n", dev->raster_num, dev->line + line, color); if (color == COLOR_2) { /* This raster completes a new line */ dev->line++; dev->image_end += dev->params.bytes_per_line; } dev->raster_num++; } DBG (DBG_proc, "teco_adjust_raster: exit\n"); } /* Read the image from the scanner and fill the temporary buffer with it. */ static SANE_Status teco_fill_image (Teco_Scanner * dev) { SANE_Status status; size_t size; CDB cdb; unsigned char *image; DBG (DBG_proc, "teco_fill_image: enter\n"); assert (dev->image_begin == dev->image_end); assert (dev->real_bytes_left > 0); /* Copy the complete lines, plus the incompletes * ones. We don't keep the real end of data used * in image, so we copy the biggest possible. */ if (dev->scan_mode == TECO_COLOR) { memmove (dev->image, dev->image + dev->image_begin, dev->raster_ahead); } dev->image_begin = 0; dev->image_end = 0; while (dev->real_bytes_left) { /* todo: teco2 too */ /* Check that we can at least one line. */ if (dev->raster_ahead + dev->image_end + dev->params.bytes_per_line > dev->image_size) { /* Probably reached the end of the buffer. * Check, just in case. */ assert (dev->image_end != 0); return (SANE_STATUS_GOOD); } /* * Try to read the maximum number of bytes. */ size = 0; while (size == 0) { status = get_filled_data_length (dev, &size); if (status) return (status); if (size == 0) usleep (100000); /* sleep 1/10th of second */ } if (size > dev->real_bytes_left) size = dev->real_bytes_left; if (size > dev->image_size - dev->raster_ahead - dev->image_end) size = dev->image_size - dev->raster_ahead - dev->image_end; if (size > dev->buffer_size) { size = dev->buffer_size; } /* Always read a multiple of a raster. */ size = size - (size % dev->bytes_per_raster); if (size == 0) { /* Probably reached the end of the buffer. * Check, just in case. */ assert (dev->image_end != 0); return (SANE_STATUS_GOOD); } DBG (DBG_info, "teco_fill_image: to read = %ld bytes (bpl=%d)\n", (long) size, dev->params.bytes_per_line); MKSCSI_READ_10 (cdb, 0, 0, size); hexdump (DBG_info2, "teco_fill_image: READ_10 CDB", cdb.data, 10); DBG (DBG_info, " image_end=%lu\n", (u_long) dev->image_end); if (dev->scan_mode == TECO_COLOR && dev->does_color_shift) { image = dev->buffer; } else { image = dev->image + dev->image_end; } status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, image, &size); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "teco_fill_image: cannot read from the scanner\n"); return status; } /* The size this scanner returns is always a multiple of a * raster size. */ assert ((size % dev->bytes_per_raster) == 0); DBG (DBG_info, "teco_fill_image: real bytes left = %ld\n", (long) dev->real_bytes_left); if (dev->scan_mode == TECO_COLOR && dev->does_color_shift) { teco_adjust_raster (dev, size); } else { /* Already in dev->image. */ dev->image_end += size; } dev->real_bytes_left -= size; } return (SANE_STATUS_GOOD); /* unreachable */ } /* Copy from the raw buffer to the buffer given by the backend. * * len in input is the maximum length available in buf, and, in * output, is the length written into buf. */ static void teco_copy_raw_to_frontend (Teco_Scanner * dev, SANE_Byte * buf, size_t * len) { size_t size; size = dev->image_end - dev->image_begin; if (size > *len) { size = *len; } *len = size; switch (dev->scan_mode) { case TECO_BW: { /* For Black & White, the bits in every bytes are mirrored. * for instance 11010001 is coded as 10001011 */ unsigned char *src = dev->image + dev->image_begin; size_t i; unsigned char s; unsigned char d; for (i = 0; i < size; i++) { s = *src ^ 0xff; d = 0; if (s & 0x01) d |= 0x80; if (s & 0x02) d |= 0x40; if (s & 0x04) d |= 0x20; if (s & 0x08) d |= 0x10; if (s & 0x10) d |= 0x08; if (s & 0x20) d |= 0x04; if (s & 0x40) d |= 0x02; if (s & 0x80) d |= 0x01; *buf = d; src++; buf++; } } break; case TECO_GRAYSCALE: case TECO_COLOR: memcpy (buf, dev->image + dev->image_begin, size); break; } dev->image_begin += size; } /* Stop a scan. */ static SANE_Status do_cancel (Teco_Scanner * dev) { DBG (DBG_sane_proc, "do_cancel enter\n"); if (dev->scanning == SANE_TRUE) { teco_reset_window (dev); teco_close (dev); } dev->scanning = SANE_FALSE; DBG (DBG_sane_proc, "do_cancel exit\n"); return SANE_STATUS_CANCELLED; } /*--------------------------------------------------------------------------*/ /* Sane entry points */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { FILE *fp; char dev_name[PATH_MAX]; size_t len; DBG_INIT (); DBG (DBG_sane_init, "sane_init\n"); DBG (DBG_error, "This is sane-teco3 version %d.%d-%d\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (DBG_error, "(C) 2002 by Frank Zago\n"); if (version_code) { *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); } fp = sanei_config_open (TECO_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ attach_scanner ("/dev/scanner", 0); return SANE_STATUS_GOOD; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ sanei_config_attach_matching_devices (dev_name, attach_one); } fclose (fp); DBG (DBG_proc, "sane_init: leave\n"); return SANE_STATUS_GOOD; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { Teco_Scanner *dev; int i; DBG (DBG_proc, "sane_get_devices: enter\n"); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (DBG_proc, "sane_get_devices: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Teco_Scanner *dev; SANE_Status status; int i; DBG (DBG_proc, "sane_open: enter\n"); /* search for devicename */ if (devicename[0]) { DBG (DBG_info, "sane_open: devicename=%s\n", devicename); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { break; } } if (!dev) { status = attach_scanner (devicename, &dev); if (status != SANE_STATUS_GOOD) { return status; } } } else { DBG (DBG_sane_info, "sane_open: no devicename, opening first device\n"); dev = first_dev; /* empty devicename -> use first device */ } if (!dev) { DBG (DBG_error, "No scanner found\n"); return SANE_STATUS_INVAL; } teco_init_options (dev); /* Initialize the gamma table. */ for (i = 0; i < GAMMA_LENGTH; i++) { dev->gamma_R[i] = i / 4; dev->gamma_G[i] = i / 4; dev->gamma_B[i] = i / 4; dev->gamma_GRAY[i] = i / 4; } *handle = dev; DBG (DBG_proc, "sane_open: exit\n"); return SANE_STATUS_GOOD; } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Teco_Scanner *dev = handle; DBG (DBG_proc, "sane_get_option_descriptor: enter, option %d\n", option); if ((unsigned) option >= OPT_NUM_OPTIONS) { return NULL; } DBG (DBG_proc, "sane_get_option_descriptor: exit\n"); return dev->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Teco_Scanner *dev = handle; SANE_Status status; SANE_Word cap; SANE_String_Const name; DBG (DBG_proc, "sane_control_option: enter, option %d, action %d\n", option, action); if (info) { *info = 0; } if (dev->scanning) { return SANE_STATUS_DEVICE_BUSY; } if (option < 0 || option >= OPT_NUM_OPTIONS) { return SANE_STATUS_INVAL; } cap = dev->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { return SANE_STATUS_INVAL; } name = dev->opt[option].name; if (!name) { name = "(no name)"; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options */ case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_TL_Y: case OPT_BR_Y: case OPT_TL_X: case OPT_BR_X: case OPT_CUSTOM_GAMMA: case OPT_THRESHOLD: case OPT_PREVIEW: *(SANE_Word *) val = dev->val[option].w; return SANE_STATUS_GOOD; /* string options */ case OPT_MODE: case OPT_DITHER: strcpy (val, dev->val[option].s); return SANE_STATUS_GOOD; /* Gamma */ case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: case OPT_GAMMA_VECTOR_GRAY: memcpy (val, dev->val[option].wa, dev->opt[option].size); return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (DBG_error, "could not set option, not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (dev->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "could not set option, invalid value\n"); return status; } switch (option) { /* Numeric side-effect options */ case OPT_TL_Y: case OPT_BR_Y: case OPT_TL_X: case OPT_BR_X: case OPT_THRESHOLD: case OPT_RESOLUTION: if (info) { *info |= SANE_INFO_RELOAD_PARAMS; } dev->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* Numeric side-effect free options */ case OPT_PREVIEW: dev->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* String side-effect free options */ case OPT_DITHER: free (dev->val[option].s); dev->val[option].s = (SANE_String) strdup (val); return SANE_STATUS_GOOD; /* String side-effect options */ case OPT_MODE: if (strcmp (dev->val[option].s, val) == 0) return SANE_STATUS_GOOD; free (dev->val[OPT_MODE].s); dev->val[OPT_MODE].s = (SANE_Char *) strdup (val); dev->opt[OPT_DITHER].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; if (strcmp (dev->val[OPT_MODE].s, BLACK_WHITE_STR) == 0) { dev->depth = 8; dev->scan_mode = TECO_BW; dev->opt[OPT_DITHER].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; } else if (strcmp (dev->val[OPT_MODE].s, GRAY_STR) == 0) { dev->scan_mode = TECO_GRAYSCALE; dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (dev->val[OPT_CUSTOM_GAMMA].w) { dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= ~SANE_CAP_INACTIVE; } dev->depth = 8; } else if (strcmp (dev->val[OPT_MODE].s, COLOR_STR) == 0) { dev->scan_mode = TECO_COLOR; dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (dev->val[OPT_CUSTOM_GAMMA].w) { dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } dev->depth = 8; } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; } return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: case OPT_GAMMA_VECTOR_GRAY: memcpy (dev->val[option].wa, val, dev->opt[option].size); return SANE_STATUS_GOOD; case OPT_CUSTOM_GAMMA: dev->val[OPT_CUSTOM_GAMMA].w = *(SANE_Word *) val; if (dev->val[OPT_CUSTOM_GAMMA].w) { /* use custom_gamma_table */ if (dev->scan_mode == TECO_GRAYSCALE) { dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= ~SANE_CAP_INACTIVE; } else { /* color mode */ dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } else { dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; } if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } DBG (DBG_proc, "sane_control_option: exit, bad\n"); return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Teco_Scanner *dev = handle; DBG (DBG_proc, "sane_get_parameters: enter\n"); if (!(dev->scanning)) { /* Setup the parameters for the scan. These values will be re-used * in the SET WINDOWS command. */ if (dev->val[OPT_PREVIEW].w == SANE_TRUE) { dev->x_resolution = 50; dev->y_resolution = 50; dev->x_tl = 0; dev->y_tl = 0; dev->x_br = mmToIlu (SANE_UNFIX (x_range.max)); dev->y_br = mmToIlu (SANE_UNFIX (y_range.max)); } else { dev->x_resolution = dev->val[OPT_RESOLUTION].w; dev->y_resolution = dev->val[OPT_RESOLUTION].w; if (dev->x_resolution > dev->def->x_resolution_max) { dev->x_resolution = dev->def->x_resolution_max; } dev->x_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_X].w)); dev->y_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_Y].w)); dev->x_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_X].w)); dev->y_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_Y].w)); } /* Check the corners are OK. */ if (dev->x_tl > dev->x_br) { int s; s = dev->x_tl; dev->x_tl = dev->x_br; dev->x_br = s; } if (dev->y_tl > dev->y_br) { int s; s = dev->y_tl; dev->y_tl = dev->y_br; dev->y_br = s; } dev->width = dev->x_br - dev->x_tl; dev->length = dev->y_br - dev->y_tl; /* Prepare the parameters for the caller. */ memset (&dev->params, 0, sizeof (SANE_Parameters)); dev->params.last_frame = SANE_TRUE; switch (dev->scan_mode) { case TECO_BW: dev->params.format = SANE_FRAME_GRAY; dev->params.pixels_per_line = ((dev->width * dev->x_resolution) / 300) & ~0x7; dev->params.bytes_per_line = dev->params.pixels_per_line / 8; dev->params.depth = 1; dev->color_shift = 0; break; case TECO_GRAYSCALE: dev->params.format = SANE_FRAME_GRAY; dev->params.pixels_per_line = ((dev->width * dev->x_resolution) / 300); dev->params.bytes_per_line = dev->params.pixels_per_line; dev->params.depth = 8; dev->color_shift = 0; break; case TECO_COLOR: dev->params.format = SANE_FRAME_RGB; dev->params.pixels_per_line = ((dev->width * dev->x_resolution) / 300); dev->params.bytes_per_line = dev->params.pixels_per_line * 3; dev->params.depth = 8; /* If the scanner does not have enough memory, it will * send the raw rasters instead of returning a full * interleaved line. Unfortunatly this does not work well, * because I don't know how to compute the color * shifting. So here is the result of some trial and error * process. This is ignored if the scanner has a RAM * module. */ dev->color_shift = dev->x_resolution / 75; break; } dev->params.lines = (dev->length * dev->y_resolution) / 300; } /* Return the current values. */ if (params) { *params = (dev->params); } DBG (DBG_proc, "sane_get_parameters: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Teco_Scanner *dev = handle; SANE_Status status; size_t size; DBG (DBG_proc, "sane_start: enter\n"); if (!(dev->scanning)) { /* Open again the scanner. */ if (sanei_scsi_open (dev->devicename, &(dev->sfd), teco_sense_handler, dev) != 0) { DBG (DBG_error, "ERROR: sane_start: open failed\n"); return SANE_STATUS_INVAL; } /* Set the correct parameters. */ sane_get_parameters (dev, NULL); /* The scanner must be ready. */ status = teco_wait_scanner (dev); if (status) { teco_close (dev); return status; } teco_query_sense (dev); teco_reset_window (dev); status = teco_set_window (dev); if (status) { teco_close (dev); return status; } dev->real_bytes_left = 0; status = get_filled_data_length (dev, &size); if (status) { teco_close (dev); return status; } /* Compute the length necessary in image. The first part will store * the complete lines, and the rest is used to stored ahead * rasters. * Align image_size to a multiple of lines. (important) */ dev->raster_ahead = (2 * dev->color_shift + 1) * dev->params.bytes_per_line; dev->image_size = dev->buffer_size + dev->raster_ahead; dev->image_size = dev->image_size - (dev->image_size % dev->params.bytes_per_line); dev->image = malloc (dev->image_size); if (dev->image == NULL) { return SANE_STATUS_NO_MEM; } /* Rasters are meaningfull only in color mode. */ dev->raster_size = dev->params.pixels_per_line; dev->raster_real = dev->params.lines * 3; dev->raster_num = 0; dev->line = 0; teco_vendor_spec (dev); if (status) { teco_close (dev); return status; } status = teco_send_gamma (dev); if (status) { teco_close (dev); return status; } status = teco_set_window (dev); if (status) { teco_close (dev); return status; } status = teco_scan (dev); if (status) { teco_close (dev); return status; } } dev->image_end = 0; dev->image_begin = 0; dev->bytes_left = dev->params.bytes_per_line * dev->params.lines; dev->real_bytes_left = dev->params.bytes_per_line * dev->params.lines; dev->scanning = SANE_TRUE; DBG (DBG_proc, "sane_start: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { SANE_Status status; Teco_Scanner *dev = handle; size_t size; int buf_offset; /* offset into buf */ DBG (DBG_proc, "sane_read: enter\n"); *len = 0; if (!(dev->scanning)) { /* OOPS, not scanning */ return do_cancel (dev); } if (dev->bytes_left <= 0) { return (SANE_STATUS_EOF); } buf_offset = 0; do { if (dev->image_begin == dev->image_end) { /* Fill image */ status = teco_fill_image (dev); if (status != SANE_STATUS_GOOD) { return (status); } } /* Something must have been read */ if (dev->image_begin == dev->image_end) { DBG (DBG_info, "sane_read: nothing read\n"); return SANE_STATUS_IO_ERROR; } /* Copy the data to the frontend buffer. */ size = max_len - buf_offset; if (size > dev->bytes_left) { size = dev->bytes_left; } teco_copy_raw_to_frontend (dev, buf + buf_offset, &size); buf_offset += size; dev->bytes_left -= size; *len += size; } while ((buf_offset != max_len) && dev->bytes_left); DBG (DBG_info, "sane_read: leave, bytes_left=%ld\n", (long) dev->bytes_left); return SANE_STATUS_GOOD; } SANE_Status sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { SANE_Status status; Teco_Scanner *dev = handle; DBG (DBG_proc, "sane_set_io_mode: enter\n"); if (dev->scanning == SANE_FALSE) { return SANE_STATUS_INVAL; } if (non_blocking == SANE_FALSE) { status = SANE_STATUS_GOOD; } else { status = SANE_STATUS_UNSUPPORTED; } DBG (DBG_proc, "sane_set_io_mode: exit\n"); return status; } SANE_Status sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { DBG (DBG_proc, "sane_get_select_fd: enter\n"); DBG (DBG_proc, "sane_get_select_fd: exit\n"); return SANE_STATUS_UNSUPPORTED; } void sane_cancel (SANE_Handle handle) { Teco_Scanner *dev = handle; DBG (DBG_proc, "sane_cancel: enter\n"); do_cancel (dev); DBG (DBG_proc, "sane_cancel: exit\n"); } void sane_close (SANE_Handle handle) { Teco_Scanner *dev = handle; Teco_Scanner *dev_tmp; DBG (DBG_proc, "sane_close: enter\n"); do_cancel (dev); teco_close (dev); /* Unlink dev. */ if (first_dev == dev) { first_dev = dev->next; } else { dev_tmp = first_dev; while (dev_tmp->next && dev_tmp->next != dev) { dev_tmp = dev_tmp->next; } if (dev_tmp->next != NULL) { dev_tmp->next = dev_tmp->next->next; } } teco_free (dev); num_devices--; DBG (DBG_proc, "sane_close: exit\n"); } void sane_exit (void) { DBG (DBG_proc, "sane_exit: enter\n"); while (first_dev) { sane_close (first_dev); } if (devlist) { free (devlist); devlist = NULL; } DBG (DBG_proc, "sane_exit: exit\n"); } sane-backends-1.0.29/backend/microtek.c0000666000000000000000000042307613615534521014565 00000000000000/*************************************************************************** * SANE - Scanner Access Now Easy. microtek.c This file Copyright 2002 Matthew Marjanovic 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. *************************************************************************** This file implements a SANE backend for Microtek scanners. (feedback to: mtek-bugs@mir.com) (for latest info: http://www.mir.com/mtek/) ***************************************************************************/ #define MICROTEK_MAJOR 0 #define MICROTEK_MINOR 13 #define MICROTEK_PATCH 1 #include "../include/sane/config.h" #include #include #include #include #include #include "../include/_stdint.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/saneopts.h" #define BACKEND_NAME microtek #include "../include/sane/sanei_backend.h" #include "microtek.h" #define MICROTEK_CONFIG_FILE "microtek.conf" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #define SCSI_BUFF_SIZE sanei_scsi_max_request_size #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) static int num_devices = 0; static Microtek_Device *first_dev = NULL; /* list of known devices */ static Microtek_Scanner *first_handle = NULL; /* list of open scanners */ static const SANE_Device **devlist = NULL; /* sane_get_devices() */ static SANE_Bool inhibit_clever_precal = SANE_FALSE; static SANE_Bool inhibit_real_calib = SANE_FALSE; #define M_GSS_WAIT 5 /* seconds */ #define M_LINEART SANE_VALUE_SCAN_MODE_LINEART #define M_HALFTONE SANE_VALUE_SCAN_MODE_HALFTONE #define M_GRAY SANE_VALUE_SCAN_MODE_GRAY #define M_COLOR SANE_VALUE_SCAN_MODE_COLOR #define M_OPAQUE "Opaque/Normal" #define M_TRANS "Transparency" #define M_AUTOFEED "AutoFeeder" #define M_NONE "None" #define M_SCALAR "Scalar" #define M_TABLE "Table" static SANE_String_Const gamma_mode_list[4] = { M_NONE, M_SCALAR, M_TABLE, NULL }; /* These are for the E6. Does this hold for other models? */ static SANE_String_Const halftone_mode_list[13] = { " 1 53-dot screen (53 gray levels)", " 2 Horiz. screen (65 gray levels)", " 3 Vert. screen (65 gray levels)", " 4 Mixed page (33 gray levels)", " 5 71-dot screen (29 gray levels)", " 6 60-dot #1 (26 gray levels)", " 7 60-dot #2 (26 gray levels)", " 8 Fine detail #1 (17 gray levels)", " 9 Fine detail #2 (17 gray levels)", "10 Slant line (17 gray levels)", "11 Posterizing (10 gray levels)", "12 High Contrast (5 gray levels)", NULL }; static SANE_Range speed_range = {1, 7, 1}; static SANE_Range brightness_range = {-100, 100, 1}; /*static SANE_Range brightness_range = {0, 255, 1};*/ /*static SANE_Range exposure_range = {-18, 21, 3};*/ /*static SANE_Range contrast_range = {-42, 49, 7};*/ static SANE_Range u8_range = {0, 255, 1}; static SANE_Range analog_gamma_range = { SANE_FIX(0.1), SANE_FIX(4.0), SANE_FIX(0) }; #define MAX_MDBG_LENGTH 1024 static char _mdebug_string[MAX_MDBG_LENGTH]; static void MDBG_INIT(const char *format, ...) { va_list ap; va_start(ap, format); vsnprintf(_mdebug_string, MAX_MDBG_LENGTH, format, ap); va_end(ap); } static void MDBG_ADD(const char *format, ...) { int len = strlen(_mdebug_string); va_list ap; va_start(ap, format); vsnprintf(_mdebug_string+len, MAX_MDBG_LENGTH-len, format, ap); va_end(ap); } static void MDBG_FINISH(int dbglvl) { DBG(dbglvl, "%s\n", _mdebug_string); } /********************************************************************/ /********************************************************************/ /*** Utility Functions **********************************************/ /********************************************************************/ /********************************************************************/ static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen(strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } /********************************************************************/ /* Allocate/create a new ring buffer */ /********************************************************************/ static ring_buffer * ring_alloc (size_t initial_size, size_t bpl, size_t ppl) { ring_buffer *rb; uint8_t *buff; if ((rb = (ring_buffer *)malloc(sizeof(*rb))) == NULL) return NULL; if ((buff = (uint8_t *)malloc(initial_size * sizeof(*buff))) == NULL) { free(rb); return NULL; } rb->base = buff; rb->size = initial_size; rb->initial_size = initial_size; rb->bpl = bpl; rb->ppl = ppl; rb->tail_red = 0; rb->tail_green = 1; rb->tail_blue = 2; rb->head_complete = 0; rb->red_extra = 0; rb->green_extra = 0; rb->blue_extra = 0; rb->complete_count = 0; return rb; } /********************************************************************/ /* Enlarge an existing ring buffer */ /********************************************************************/ static SANE_Status ring_expand (ring_buffer *rb, size_t amount) { uint8_t *buff; size_t oldsize; if (rb == NULL) return SANE_STATUS_INVAL; buff = (uint8_t *)realloc(rb->base, (rb->size + amount) * sizeof(*buff)); if (buff == NULL) return SANE_STATUS_NO_MEM; rb->base = buff; oldsize = rb->size; rb->size += amount; DBG(23, "ring_expand: old, new, inc size: %lu, %lu, %lu\n", (u_long)oldsize, (u_long)rb->size, (u_long)amount); DBG(23, "ring_expand: old tr: %lu tg: %lu tb: %lu hc: %lu\n", (u_long)rb->tail_red, (u_long)rb->tail_green, (u_long)rb->tail_blue, (u_long)rb->head_complete); /* if necessary, move data and fix up them pointers */ /* (will break subtly if ring is filled with G or B bytes, and tail_g or tail_b have rolled over...) */ if (((rb->complete_count) || (rb->red_extra) || (rb->green_extra) || (rb->blue_extra)) && ((rb->tail_red <= rb->head_complete) || (rb->tail_green <= rb->head_complete) || (rb->tail_blue <= rb->head_complete))) { memmove(rb->base + rb->head_complete + amount, rb->base + rb->head_complete, oldsize - rb->head_complete); if ((rb->tail_red > rb->head_complete) || ((rb->tail_red == rb->head_complete) && !(rb->complete_count) && !(rb->red_extra))) rb->tail_red += amount; if ((rb->tail_green > rb->head_complete) || ((rb->tail_green == rb->head_complete) && !(rb->complete_count) && !(rb->green_extra))) rb->tail_green += amount; if ((rb->tail_blue > rb->head_complete) || ((rb->tail_blue == rb->head_complete) && !(rb->complete_count) && !(rb->blue_extra))) rb->tail_blue += amount; rb->head_complete += amount; } DBG(23, "ring_expand: new tr: %lu tg: %lu tb: %lu hc: %lu\n", (u_long)rb->tail_red, (u_long)rb->tail_green, (u_long)rb->tail_blue, (u_long)rb->head_complete); return SANE_STATUS_GOOD; } /********************************************************************/ /* Deallocate a ring buffer */ /********************************************************************/ static void ring_free (ring_buffer *rb) { free(rb->base); free(rb); } /********************************************************************/ /********************************************************************/ /*** Basic SCSI Commands ********************************************/ /********************************************************************/ /********************************************************************/ /********************************************************************/ /* parse sense from scsi error */ /* (even though microtek sense codes are non-standard and */ /* typically misinterpreted/munged by the low-level scsi driver) */ /********************************************************************/ static SANE_Status sense_handler (int scsi_fd, u_char *sense, void *arg) { int *sense_flags = (int *)arg; SANE_Status stat; DBG(10, "SENSE! fd = %d\n", scsi_fd); DBG(10, "sense = %02x %02x %02x %02x.\n", sense[0], sense[1], sense[2], sense[3]); switch(sense[0]) { case 0x00: return SANE_STATUS_GOOD; case 0x81: /* COMMAND/DATA ERROR */ stat = SANE_STATUS_GOOD; if (sense[1] & 0x01) { if ((sense_flags != NULL) && (*sense_flags & MS_SENSE_IGNORE)) DBG(10, "sense: ERR_SCSICMD -- ignored\n"); else { DBG(10, "sense: ERR_SCSICMD\n"); stat = SANE_STATUS_IO_ERROR; } } if (sense[1] & 0x02) { DBG(10, "sense: ERR_TOOMANY\n"); stat = SANE_STATUS_IO_ERROR; } return stat; case 0x82 : /* SCANNER HARDWARE ERROR */ if (sense[1] & 0x01) DBG(10, "sense: ERR_CPURAMFAIL\n"); if (sense[1] & 0x02) DBG(10, "sense: ERR_SYSRAMFAIL\n"); if (sense[1] & 0x04) DBG(10, "sense: ERR_IMGRAMFAIL\n"); if (sense[1] & 0x10) DBG(10, "sense: ERR_CALIBRATE\n"); if (sense[1] & 0x20) DBG(10, "sense: ERR_LAMPFAIL\n"); if (sense[1] & 0x40) DBG(10, "sense: ERR_MOTORFAIL\n"); if (sense[1] & 0x80) DBG(10, "sense: ERR_FEEDERFAIL\n"); if (sense[2] & 0x01) DBG(10, "sense: ERR_POWERFAIL\n"); if (sense[2] & 0x02) DBG(10, "sense: ERR_ILAMPFAIL\n"); if (sense[2] & 0x04) DBG(10, "sense: ERR_IMOTORFAIL\n"); if (sense[2] & 0x08) DBG(10, "sense: ERR_PAPERFAIL\n"); if (sense[2] & 0x10) DBG(10, "sense: ERR_FILTERFAIL\n"); return SANE_STATUS_IO_ERROR; case 0x83 : /* OPERATION ERROR */ if (sense[1] & 0x01) DBG(10, "sense: ERR_ILLGRAIN\n"); if (sense[1] & 0x02) DBG(10, "sense: ERR_ILLRES\n"); if (sense[1] & 0x04) DBG(10, "sense: ERR_ILLCOORD\n"); if (sense[1] & 0x10) DBG(10, "sense: ERR_ILLCNTR\n"); if (sense[1] & 0x20) DBG(10, "sense: ERR_ILLLENGTH\n"); if (sense[1] & 0x40) DBG(10, "sense: ERR_ILLADJUST\n"); if (sense[1] & 0x80) DBG(10, "sense: ERR_ILLEXPOSE\n"); if (sense[2] & 0x01) DBG(10, "sense: ERR_ILLFILTER\n"); if (sense[2] & 0x02) DBG(10, "sense: ERR_NOPAPER\n"); if (sense[2] & 0x04) DBG(10, "sense: ERR_ILLTABLE\n"); if (sense[2] & 0x08) DBG(10, "sense: ERR_ILLOFFSET\n"); if (sense[2] & 0x10) DBG(10, "sense: ERR_ILLBPP\n"); return SANE_STATUS_IO_ERROR; default : DBG(10, "sense: unknown error\n"); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /********************************************************************/ /* wait (via polling) until scanner seems "ready" */ /********************************************************************/ static SANE_Status wait_ready(Microtek_Scanner *ms) { uint8_t comm[6] = { 0, 0, 0, 0, 0, 0 }; SANE_Status status; int retry = 0; DBG(23, ".wait_ready %d...\n", ms->sfd); while ((status = sanei_scsi_cmd(ms->sfd, comm, 6, 0, 0)) != SANE_STATUS_GOOD) { DBG(23, "wait_ready failed (%d)\n", retry); if (retry > 5) return SANE_STATUS_IO_ERROR; /* XXXXXXXX */ retry++; sleep(3); } return SANE_STATUS_GOOD; } /********************************************************************/ /* send scan region coordinates */ /********************************************************************/ static SANE_Status scanning_frame(Microtek_Scanner *ms) { uint8_t *data, comm[15] = { 0x04, 0, 0, 0, 0x09, 0 }; int x1, y1, x2, y2; DBG(23, ".scanning_frame...\n"); x1 = ms->x1; x2 = ms->x2; y1 = ms->y1; y2 = ms->y2; /* E6 weirdness (other models too?) */ if (ms->unit_type == MS_UNIT_18INCH) { x1 /= 2; x2 /= 2; y1 /= 2; y2 /= 2; } DBG(23, ".scanning_frame: in- %d,%d %d,%d\n", ms->x1, ms->y1, ms->x2, ms->y2); DBG(23, ".scanning_frame: out- %d,%d %d,%d\n", x1, y1, x2, y2); data = comm + 6; data[0] = ((ms->unit_type == MS_UNIT_PIXELS) ? 0x08 : 0 ) | ((ms->mode == MS_MODE_HALFTONE) ? 0x01 : 0 ); data[1] = x1 & 0xFF; data[2] = (x1 >> 8) & 0xFF; data[3] = y1 & 0xFF; data[4] = (y1 >> 8) & 0xFF; data[5] = x2 & 0xFF; data[6] = (x2 >> 8) & 0xFF; data[7] = y2 & 0xFF; data[8] = (y2 >> 8) & 0xFF; if (DBG_LEVEL >= 192) { int i; #if 0 fprintf(stderr, "SF: "); for (i=0;i<6+0x09;i++) fprintf(stderr, "%2x ", comm[i]); fprintf(stderr, "\n"); #endif MDBG_INIT("SF: "); for (i=0;i<6+0x09;i++) MDBG_ADD("%2x ", comm[i]); MDBG_FINISH(192); } return sanei_scsi_cmd(ms->sfd, comm, 6 + 0x09, 0, 0); } /********************************************************************/ /* send "mode_select" */ /********************************************************************/ static SANE_Status mode_select(Microtek_Scanner *ms) { uint8_t *data, comm[19] = { 0x15, 0, 0, 0, 0, 0 }; DBG(23, ".mode_select %d...\n", ms->sfd); data = comm + 6; data[0] = 0x81 | ((ms->unit_type == MS_UNIT_18INCH) ? 0 : 0x08) | ((ms->res_type == MS_RES_5PER) ? 0 : 0x02); data[1] = ms->resolution_code; data[2] = ms->exposure; data[3] = ms->contrast; data[4] = ms->pattern; data[5] = ms->velocity; data[6] = ms->shadow; data[7] = ms->highlight; DBG(23, ".mode_select: pap_len: %d\n", ms->paper_length); data[8] = ms->paper_length & 0xFF; data[9] = (ms->paper_length >> 8) & 0xFF; data[10] = ms->midtone; /* set command/data length */ comm[4] = (ms->midtone_support) ? 0x0B : 0x0A; if (DBG_LEVEL >= 192) { int i; #if 0 fprintf(stderr, "MSL: "); for (i=0;i<6+comm[4];i++) fprintf(stderr, "%2x ", comm[i]); fprintf(stderr, "\n"); #endif MDBG_INIT("MSL: "); for (i=0;i<6+comm[4];i++) MDBG_ADD("%2x ", comm[i]); MDBG_FINISH(192); } return sanei_scsi_cmd(ms->sfd, comm, 6 + comm[4], 0, 0); } /********************************************************************/ /* send "mode_select_1" */ /********************************************************************/ static SANE_Status mode_select_1(Microtek_Scanner *ms) { uint8_t *data, comm[16] = { 0x16, 0, 0, 0, 0x0A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; DBG(23, ".mode_select_1 %d...\n", ms->sfd); data = comm + 6; data[1] = ms->bright_r; data[3] = ((ms->allow_calibrate) ? 0 : 0x02); /* | 0x01; */ if (DBG_LEVEL >= 192) { int i; #if 0 fprintf(stderr, "MSL1: "); for (i=0;i<6+0x0A;i++) fprintf(stderr, "%2x ", comm[i]); fprintf(stderr, "\n"); #endif MDBG_INIT("MSL1: "); for (i=0;i<6+0x0A;i++) MDBG_ADD("%2x ", comm[i]); MDBG_FINISH(192); } return sanei_scsi_cmd(ms->sfd, comm, 6 + 0x0A, 0, 0); } /********************************************************************/ /* record mode_sense results in the mode_sense buffer */ /* (this is to tell if something catastrophic has happened */ /* to the scanner in-between scans) */ /********************************************************************/ static SANE_Status save_mode_sense(Microtek_Scanner *ms) { uint8_t data[20], comm[6] = { 0x1A, 0, 0, 0, 0, 0}; size_t lenp; SANE_Status status; int i; DBG(23, ".save_mode_sense %d...\n", ms->sfd); if (ms->onepass) comm[4] = 0x13; else if (ms->midtone_support) comm[4] = 0x0B; else comm[4] = 0x0A; lenp = comm[4]; status = sanei_scsi_cmd(ms->sfd, comm, 6, data, &lenp); for (i=0; i<10; i++) ms->mode_sense_cache[i] = data[i]; if (DBG_LEVEL >= 192) { unsigned int i; #if 0 fprintf(stderr, "SMS: "); for (i=0;isfd); if (ms->onepass) comm[4] = 0x13; else if (ms->midtone_support) comm[4] = 0x0B; else comm[4] = 0x0A; lenp = comm[4]; status = sanei_scsi_cmd(ms->sfd, comm, 6, data, &lenp); *match = 1; for (i=0; i<10; i++) *match = *match && (ms->mode_sense_cache[i] == data[i]); if (DBG_LEVEL >= 192) { unsigned int i; #if 0 fprintf(stderr, "CMS: "); for (i=0;imode_sense_cache[i]); fprintf(stderr, "\n"); #endif MDBG_INIT("CMS: "); for (i=0;imode_sense_cache[i]); MDBG_FINISH(192); } return status; } /********************************************************************/ /* send mode_sense_1, and upset every scsi driver known to mankind */ /********************************************************************/ #if 0 static SANE_Status mode_sense_1(Microtek_Scanner *ms) { uint8_t *data, comm[36] = { 0x19, 0, 0, 0, 0x1E, 0 }; DBG(23, ".mode_sense_1...\n"); data = comm + 6; memset(data, 0, 30); data[1] = ms->bright_r; data[2] = ms->bright_g; data[3] = ms->bright_b; if (DBG_LEVEL >= 192) { int i; fprintf(stderr, "MS1: "); for (i=0;i<6+0x1E;i++) fprintf(stderr, "%2x ", comm[i]); fprintf(stderr, "\n"); } return sanei_scsi_cmd(ms->sfd, comm, 6 + 0x1E, 0, 0); } #endif /********************************************************************/ /* send "accessory" command */ /********************************************************************/ static SANE_Status accessory(Microtek_Scanner *ms) { uint8_t comm[6] = { 0x10, 0, 0, 0, 0, 0 }; DBG(23, ".accessory...\n"); comm[4] = ((ms->useADF) ? 0x41 : 0x40) | ((ms->prescan) ? 0x18 : 0x10) | ((ms->transparency) ? 0x24 : 0x20) | ((ms->allowbacktrack) ? 0x82 : 0x80); if (DBG_LEVEL >= 192) { int i; #if 0 fprintf(stderr, "AC: "); for (i=0;i<6;i++) fprintf(stderr, "%2x ", comm[i]); fprintf(stderr, "\n"); #endif MDBG_INIT("AC: "); for (i=0;i<6;i++) MDBG_ADD("%2x ", comm[i]); MDBG_FINISH(192); } return sanei_scsi_cmd(ms->sfd, comm, 6, 0, 0); } /********************************************************************/ /* start the scanner a-scannin' */ /********************************************************************/ static SANE_Status start_scan(Microtek_Scanner *ms) { uint8_t comm[6] = { 0x1B, 0, 0, 0, 0, 0 }; DBG(23, ".start_scan...\n"); comm[4] = 0x01 | /* "start" */ ((ms->expandedresolution) ? 0x80 : 0) | ((ms->multibit) ? 0x40 : 0) | ((ms->onepasscolor) ? 0x20 : 0) | ((ms->reversecolors) ? 0x04 : 0) | ((ms->fastprescan) ? 0x02 : 0) | ((ms->filter == MS_FILT_RED) ? 0x08 : 0) | ((ms->filter == MS_FILT_GREEN) ? 0x10 : 0) | ((ms->filter == MS_FILT_BLUE) ? 0x18 : 0) ; if (DBG_LEVEL >= 192) { int i; #if 0 fprintf(stderr, "SS: "); for (i=0;i<6;i++) fprintf(stderr, "%2x ", comm[i]); fprintf(stderr, "\n"); #endif MDBG_INIT("SS: "); for (i=0;i<6;i++) MDBG_ADD("%2x ", comm[i]); MDBG_FINISH(192); } return sanei_scsi_cmd(ms->sfd, comm, 6, 0, 0); } /********************************************************************/ /* stop the scanner a-scannin' */ /********************************************************************/ static SANE_Status stop_scan(Microtek_Scanner *ms) { uint8_t comm[6] = { 0x1B, 0, 0, 0, 0, 0 }; DBG(23, ".stop_scan...\n"); if (DBG_LEVEL >= 192) { int i; #if 0 fprintf(stderr, "SPS:"); for (i=0;i<6;i++) fprintf(stderr, "%2x ", comm[i]); fprintf(stderr, "\n"); #endif MDBG_INIT("SPS:"); for (i=0;i<6;i++) MDBG_ADD("%2x ", comm[i]); MDBG_FINISH(192); } return sanei_scsi_cmd(ms->sfd, comm, 6, 0, 0); } /********************************************************************/ /* get scan status */ /********************************************************************/ static SANE_Status get_scan_status(Microtek_Scanner *ms, SANE_Int *busy, SANE_Int *bytes_per_line, SANE_Int *lines) { uint8_t data[6], comm[6] = { 0x0F, 0, 0, 0, 0x06, 0 }; SANE_Status status; size_t lenp; int retry = 0; DBG(23, ".get_scan_status %d...\n", ms->sfd); do { lenp = 6; /* do some retry stuff in here, too */ status = sanei_scsi_cmd(ms->sfd, comm, 6, data, &lenp); if (status != SANE_STATUS_GOOD) { DBG(20, "get_scan_status: scsi error\n"); return status; } *busy = data[0]; *bytes_per_line = (data[1]) + (data[2] << 8); *lines = (data[3]) + (data[4] << 8) + (data[5] << 16); DBG(20, "get_scan_status(%lu): %d, %d, %d -> #%d\n", (u_long) lenp, *busy, *bytes_per_line, *lines, retry); DBG(20, "> %2x %2x %2x %2x %2x %2x\n", data[0], data[1], data[2], data[3], data[4], data[5]); if (*busy != 0) { retry++; DBG(23, "get_scan_status: busy, retry in %d...\n", M_GSS_WAIT * retry); sleep(M_GSS_WAIT * retry); } } while ((*busy != 0) && (retry < 4)); if (*busy == 0) return status; else return SANE_STATUS_IO_ERROR; } /********************************************************************/ /* get scanlines from scanner */ /********************************************************************/ static SANE_Status read_scan_data(Microtek_Scanner *ms, int lines, uint8_t *buffer, size_t *bufsize) { uint8_t comm[6] = { 0x08, 0, 0, 0, 0, 0 }; DBG(23, ".read_scan_data...\n"); comm[2] = (lines >> 16) & 0xFF; comm[3] = (lines >> 8) & 0xFF; comm[4] = (lines) & 0xFF; return sanei_scsi_cmd(ms->sfd, comm, 6, buffer, bufsize); } /********************************************************************/ /* download color LUT to scanner (if it takes one) */ /********************************************************************/ static SANE_Status download_gamma(Microtek_Scanner *ms) { uint8_t *data, *comm; /* commbytes[10] = { 0x55, 0, 0x27, 0, 0, 0, 0, 0, 0, 0 };*/ int i, pl; int commsize; int bit_depth = 8; /* hard-code for now, should match bpp XXXXXXX */ int max_entry; SANE_Status status; DBG(23, ".download_gamma...\n"); /* skip if scanner doesn't take 'em */ if (!(ms->gamma_entries)) { DBG(23, ".download_gamma: no entries; skipping\n"); return SANE_STATUS_GOOD; } if ((ms->gamma_entry_size != 1) && (ms->gamma_entry_size != 2)) { DBG(23, ".download_gamma: entry size %d?!?!?\n", ms->gamma_entry_size); return SANE_STATUS_INVAL; /* XXXXXXXxx */ } max_entry = (1 << bit_depth) - 1; DBG(23, ".download_gamma: %d entries of %d bytes, max %d\n", ms->gamma_entries, ms->gamma_entry_size, max_entry); commsize = 10 + (ms->gamma_entries * ms->gamma_entry_size); comm = calloc(commsize, sizeof(uint8_t)); if (comm == NULL) { DBG(23, ".download_gamma: couldn't allocate %d bytes for comm buffer!\n", commsize); return SANE_STATUS_NO_MEM; } data = comm + 10; comm[0] = 0x55; comm[1] = 0; comm[2] = 0x27; comm[3] = 0; comm[4] = 0; comm[5] = 0; comm[6] = 0; comm[7] = ((ms->gamma_entries * ms->gamma_entry_size) >> 8) & 0xFF; comm[8] = (ms->gamma_entries * ms->gamma_entry_size) & 0xFF; comm[9] = (ms->gamma_entry_size == 2) ? 1 : 0; if (!(strcmp(ms->val[OPT_CUSTOM_GAMMA].s, M_TABLE))) { /***** Gamma by TABLE *****/ int table_shift = (ms->gamma_bit_depth - bit_depth); DBG(23, ".download_gamma: by table (%d bpe, %d shift)\n", ms->gamma_bit_depth, table_shift); if (ms->val[OPT_GAMMA_BIND].w == SANE_TRUE) { for (i=0; igamma_entries; i++) { int val = ms->gray_lut[i] >> table_shift; switch (ms->gamma_entry_size) { case 1: data[i] = (uint8_t) val; break; case 2: data[i*2] = val & 0xFF; data[(i*2)+1] = (val>>8) & 0xFF; break; } } status = sanei_scsi_cmd(ms->sfd, comm, commsize, 0, 0); } else { pl = 1; do { SANE_Int *pl_lut; switch (pl) { case 1: pl_lut = ms->red_lut; break; case 2: pl_lut = ms->green_lut; break; case 3: pl_lut = ms->blue_lut; break; default: DBG(23, ".download_gamma: uh, exceeded pl bound!\n"); free(comm); return SANE_STATUS_INVAL; /* XXXXXXXxx */ break; } for (i=0; igamma_entries; i++) { int val = pl_lut[i] >> table_shift; switch (ms->gamma_entry_size) { case 1: data[i] = (uint8_t) val; break; case 2: data[i*2] = val & 0xFF; data[(i*2)+1] = (val>>8) & 0xFF; break; } } /* XXXXXXX */ comm[9] = (comm[9] & 0x3F) | (pl << 6); status = sanei_scsi_cmd(ms->sfd, comm, commsize, 0, 0); pl++; } while ((pl < 4) && (status == SANE_STATUS_GOOD)); } } else if (!(strcmp(ms->val[OPT_CUSTOM_GAMMA].s, M_SCALAR))) { /***** Gamma by SCALAR *****/ DBG(23, ".download_gamma: by scalar\n"); if (ms->val[OPT_GAMMA_BIND].w == SANE_TRUE) { double gamma = SANE_UNFIX(ms->val[OPT_ANALOG_GAMMA].w); for (i=0; igamma_entries; i++) { int val = (max_entry * pow((double) i / ((double) ms->gamma_entries - 1.0), 1.0 / gamma)); switch (ms->gamma_entry_size) { case 1: data[i] = (uint8_t) val; break; case 2: data[i*2] = val & 0xFF; data[(i*2)+1] = (val>>8) & 0xFF; break; } } status = sanei_scsi_cmd(ms->sfd, comm, commsize, 0, 0); } else { double gamma; pl = 1; do { switch (pl) { case 1: gamma = SANE_UNFIX(ms->val[OPT_ANALOG_GAMMA_R].w); break; case 2: gamma = SANE_UNFIX(ms->val[OPT_ANALOG_GAMMA_G].w); break; case 3: gamma = SANE_UNFIX(ms->val[OPT_ANALOG_GAMMA_B].w); break; default: gamma = 1.0; break; /* should never happen */ } for (i=0; igamma_entries; i++) { int val = (max_entry * pow((double) i / ((double) ms->gamma_entries - 1.0), 1.0 / gamma)); switch (ms->gamma_entry_size) { case 1: data[i] = (uint8_t) val; break; case 2: data[i*2] = val & 0xFF; data[(i*2)+1] = (val>>8) & 0xFF; break; } } comm[9] = (comm[9] & 0x3F) | (pl << 6); status = sanei_scsi_cmd(ms->sfd, comm, commsize, 0, 0); pl++; } while ((pl < 4) && (status == SANE_STATUS_GOOD)); } } else { /***** No custom Gamma *****/ DBG(23, ".download_gamma: by default\n"); for (i=0; igamma_entries; i++) { /* int val = (((double) max_entry * (double) i / ((double) ms->gamma_entries - 1.0)) + 0.5); ROUNDING????*/ int val = (double) max_entry * (double) i / ((double) ms->gamma_entries - 1.0); switch (ms->gamma_entry_size) { case 1: data[i] = (uint8_t) val; break; case 2: data[i*2] = val & 0xFF; data[(i*2)+1] = (val >> 8) & 0xFF; break; } } status = sanei_scsi_cmd(ms->sfd, comm, commsize, 0, 0); } free(comm); return status; } /********************************************************************/ /* magic command to start calibration */ /********************************************************************/ static SANE_Status start_calibration(Microtek_Scanner *ms) { uint8_t comm[8] = { 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x0a }; DBG(23, ".start_calibrate...\n"); if (DBG_LEVEL >= 192) { int i; #if 0 fprintf(stderr, "STCal:"); for (i=0;i<8;i++) fprintf(stderr, "%2x ", comm[i]); fprintf(stderr, "\n"); #endif MDBG_INIT("STCal:"); for (i=0;i<8;i++) MDBG_ADD("%2x ", comm[i]); MDBG_FINISH(192); } return sanei_scsi_cmd(ms->sfd, comm, 8, 0, 0); } /********************************************************************/ /* magic command to download calibration values */ /********************************************************************/ static SANE_Status download_calibration(Microtek_Scanner *ms, uint8_t *comm, uint8_t letter, int linewidth) { DBG(23, ".download_calibration... %c %d\n", letter, linewidth); comm[0] = 0x0c; comm[1] = 0x00; comm[2] = 0x00; comm[3] = (linewidth >> 8) & 0xFF; comm[4] = linewidth & 0xFF; comm[5] = 0x00; comm[6] = 0x00; switch (letter) { case 'R': comm[7] = 0x40; break; case 'G': comm[7] = 0x80; break; case 'B': comm[7] = 0xc0; break; default: /* XXXXXXX */ break; } return sanei_scsi_cmd(ms->sfd, comm, 6 + linewidth, 0, 0); } /********************************************************************/ /********************************************************************/ /* */ /* Myriad of internal functions */ /* */ /********************************************************************/ /********************************************************************/ /********************************************************************/ /* Initialize the options registry */ /********************************************************************/ static SANE_Status init_options(Microtek_Scanner *ms) { int i; SANE_Option_Descriptor *sod = ms->sod; Option_Value *val = ms->val; DBG(15, "init_options...\n"); memset(ms->sod, 0, sizeof(ms->sod)); memset(ms->val, 0, sizeof(ms->val)); /* default: software selectable word options... */ for (i=0; idev->info.modes & MI_MODES_COLOR) mode_list[i++] = M_COLOR; if (ms->dev->info.modes & MI_MODES_GRAY) mode_list[i++] = M_GRAY; if (ms->dev->info.modes & MI_MODES_HALFTONE) mode_list[i++] = M_HALFTONE; if (ms->dev->info.modes & MI_MODES_LINEART) mode_list[i++] = M_LINEART; mode_list[i] = NULL; sod[OPT_MODE].constraint.string_list = mode_list; sod[OPT_MODE].size = max_string_size(mode_list); val[OPT_MODE].s = strdup(mode_list[0]); } sod[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; sod[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; sod[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; sod[OPT_RESOLUTION].type = SANE_TYPE_FIXED; sod[OPT_RESOLUTION].unit = SANE_UNIT_DPI; sod[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; { SANE_Int maxres = ms->dev->info.base_resolution; ms->res_range.max = SANE_FIX(maxres); ms->exp_res_range.max = SANE_FIX(2 * maxres); if (ms->dev->info.res_step & MI_RESSTEP_1PER) { DBG(23, "init_options: quant yes\n"); ms->res_range.min = SANE_FIX( maxres / 100 ); ms->res_range.quant = ms->res_range.min; ms->exp_res_range.min = SANE_FIX(2 * maxres / 100); ms->exp_res_range.quant = ms->exp_res_range.min; } else { /* XXXXXXXXXXX */ DBG(23, "init_options: quant no\n"); ms->res_range.quant = SANE_FIX( 0 ); } sod[OPT_RESOLUTION].constraint.range = &(ms->res_range); } val[OPT_RESOLUTION].w = SANE_FIX(100); sod[OPT_HALFTONE_PATTERN].name = SANE_NAME_HALFTONE_PATTERN; sod[OPT_HALFTONE_PATTERN].title = SANE_TITLE_HALFTONE_PATTERN; sod[OPT_HALFTONE_PATTERN].desc = SANE_DESC_HALFTONE_PATTERN; sod[OPT_HALFTONE_PATTERN].type = SANE_TYPE_STRING; sod[OPT_HALFTONE_PATTERN].size = max_string_size(halftone_mode_list); sod[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; sod[OPT_HALFTONE_PATTERN].constraint_type = SANE_CONSTRAINT_STRING_LIST; sod[OPT_HALFTONE_PATTERN].constraint.string_list = halftone_mode_list; val[OPT_HALFTONE_PATTERN].s = strdup(halftone_mode_list[0]); sod[OPT_NEGATIVE].name = SANE_NAME_NEGATIVE; sod[OPT_NEGATIVE].title = SANE_TITLE_NEGATIVE; sod[OPT_NEGATIVE].desc = SANE_DESC_NEGATIVE; sod[OPT_NEGATIVE].type = SANE_TYPE_BOOL; sod[OPT_NEGATIVE].cap |= (ms->dev->info.modes & MI_MODES_NEGATIVE) ? 0 : SANE_CAP_INACTIVE; val[OPT_NEGATIVE].w = SANE_FALSE; sod[OPT_SPEED].name = SANE_NAME_SCAN_SPEED; sod[OPT_SPEED].title = SANE_TITLE_SCAN_SPEED; /* sod[OPT_SPEED].desc = SANE_DESC_SCAN_SPEED;*/ sod[OPT_SPEED].desc = "Scan speed throttle -- higher values are *slower*."; sod[OPT_SPEED].type = SANE_TYPE_INT; sod[OPT_SPEED].cap |= SANE_CAP_ADVANCED; sod[OPT_SPEED].unit = SANE_UNIT_NONE; sod[OPT_SPEED].size = sizeof(SANE_Word); sod[OPT_SPEED].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_SPEED].constraint.range = &speed_range; val[OPT_SPEED].w = 1; sod[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; sod[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; sod[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; sod[OPT_SOURCE].type = SANE_TYPE_STRING; sod[OPT_SOURCE].unit = SANE_UNIT_NONE; sod[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; { SANE_String_Const *source_list; source_list = (SANE_String_Const *) malloc(4 * sizeof(SANE_String_Const)); if (source_list == NULL) return SANE_STATUS_NO_MEM; i = 0; source_list[i++] = M_OPAQUE; if (ms->dev->info.source_options & MI_SRC_HAS_TRANS) source_list[i++] = M_TRANS; if (ms->dev->info.source_options & MI_SRC_HAS_FEED) source_list[i++] = M_AUTOFEED; source_list[i] = NULL; sod[OPT_SOURCE].constraint.string_list = source_list; sod[OPT_SOURCE].size = max_string_size(source_list); if (i < 2) sod[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; val[OPT_SOURCE].s = strdup(source_list[0]); } sod[OPT_PREVIEW].name = SANE_NAME_PREVIEW; sod[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; sod[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; sod[OPT_PREVIEW].type = SANE_TYPE_BOOL; sod[OPT_PREVIEW].unit = SANE_UNIT_NONE; sod[OPT_PREVIEW].size = sizeof(SANE_Word); val[OPT_PREVIEW].w = SANE_FALSE; sod[OPT_GEOMETRY_GROUP].name = ""; sod[OPT_GEOMETRY_GROUP].title = "Geometry"; sod[OPT_GEOMETRY_GROUP].desc = ""; sod[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; sod[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; sod[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; sod[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; sod[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; sod[OPT_TL_X].type = SANE_TYPE_FIXED; sod[OPT_TL_X].unit = SANE_UNIT_MM; sod[OPT_TL_X].size = sizeof(SANE_Word); sod[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; sod[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; sod[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; sod[OPT_TL_Y].type = SANE_TYPE_FIXED; sod[OPT_TL_Y].unit = SANE_UNIT_MM; sod[OPT_TL_Y].size = sizeof(SANE_Word); sod[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; sod[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; sod[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; sod[OPT_BR_X].type = SANE_TYPE_FIXED; sod[OPT_BR_X].unit = SANE_UNIT_MM; sod[OPT_BR_X].size = sizeof(SANE_Word); sod[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; sod[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; sod[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; sod[OPT_BR_Y].type = SANE_TYPE_FIXED; sod[OPT_BR_Y].unit = SANE_UNIT_MM; sod[OPT_BR_Y].size = sizeof(SANE_Word); sod[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_TL_X].constraint.range = sod[OPT_BR_X].constraint.range = &(ms->dev->info.doc_x_range); sod[OPT_TL_Y].constraint.range = sod[OPT_BR_Y].constraint.range = &(ms->dev->info.doc_y_range); /* set default scan region to be maximum size */ val[OPT_TL_X].w = sod[OPT_TL_X].constraint.range->min; val[OPT_TL_Y].w = sod[OPT_TL_Y].constraint.range->min; val[OPT_BR_X].w = sod[OPT_BR_X].constraint.range->max; val[OPT_BR_Y].w = sod[OPT_BR_Y].constraint.range->max; sod[OPT_ENHANCEMENT_GROUP].name = ""; sod[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; sod[OPT_ENHANCEMENT_GROUP].desc = ""; sod[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; sod[OPT_ENHANCEMENT_GROUP].cap = 0; sod[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_EXPOSURE].name = "exposure"; sod[OPT_EXPOSURE].title = "Exposure"; sod[OPT_EXPOSURE].desc = "Analog exposure control"; sod[OPT_EXPOSURE].type = SANE_TYPE_INT; sod[OPT_EXPOSURE].unit = SANE_UNIT_PERCENT; sod[OPT_EXPOSURE].size = sizeof(SANE_Word); sod[OPT_EXPOSURE].constraint_type = SANE_CONSTRAINT_RANGE; ms->exposure_range.min = ms->dev->info.min_exposure; ms->exposure_range.max = ms->dev->info.max_exposure; ms->exposure_range.quant = 3; sod[OPT_EXPOSURE].constraint.range = &(ms->exposure_range); val[OPT_EXPOSURE].w = 0; sod[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; sod[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; sod[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; sod[OPT_BRIGHTNESS].type = SANE_TYPE_INT; sod[OPT_BRIGHTNESS].unit = SANE_UNIT_PERCENT; sod[OPT_BRIGHTNESS].size = sizeof(SANE_Word); sod[OPT_BRIGHTNESS].cap |= ((ms->dev->info.extra_cap & MI_EXCAP_OFF_CTL) ? 0: SANE_CAP_INACTIVE); sod[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_BRIGHTNESS].constraint.range = &brightness_range; val[OPT_BRIGHTNESS].w = 0; sod[OPT_CONTRAST].name = SANE_NAME_CONTRAST; sod[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; sod[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; sod[OPT_CONTRAST].type = SANE_TYPE_INT; sod[OPT_CONTRAST].unit = SANE_UNIT_PERCENT; sod[OPT_CONTRAST].size = sizeof(SANE_Word); sod[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; ms->contrast_range.min = ms->dev->info.min_contrast; ms->contrast_range.max = ms->dev->info.max_contrast; ms->contrast_range.quant = 7; sod[OPT_CONTRAST].constraint.range = &(ms->contrast_range); val[OPT_CONTRAST].w = 0; sod[OPT_HIGHLIGHT].name = SANE_NAME_WHITE_LEVEL; sod[OPT_HIGHLIGHT].title = SANE_TITLE_WHITE_LEVEL; sod[OPT_HIGHLIGHT].desc = SANE_DESC_WHITE_LEVEL; sod[OPT_HIGHLIGHT].type = SANE_TYPE_INT; sod[OPT_HIGHLIGHT].unit = SANE_UNIT_NONE; sod[OPT_HIGHLIGHT].size = sizeof(SANE_Word); sod[OPT_HIGHLIGHT].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_HIGHLIGHT].constraint.range = &u8_range; val[OPT_HIGHLIGHT].w = 255; sod[OPT_SHADOW].name = SANE_NAME_BLACK_LEVEL; sod[OPT_SHADOW].title = SANE_TITLE_BLACK_LEVEL; sod[OPT_SHADOW].desc = SANE_DESC_BLACK_LEVEL; sod[OPT_SHADOW].type = SANE_TYPE_INT; sod[OPT_SHADOW].unit = SANE_UNIT_NONE; sod[OPT_SHADOW].size = sizeof(SANE_Word); sod[OPT_SHADOW].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_SHADOW].constraint.range = &u8_range; val[OPT_SHADOW].w = 0; if (ms->dev->info.enhance_cap & MI_ENH_CAP_SHADOW) { sod[OPT_HIGHLIGHT].cap |= SANE_CAP_ADVANCED; sod[OPT_SHADOW].cap |= SANE_CAP_ADVANCED; } else { sod[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; } sod[OPT_MIDTONE].name = "midtone"; sod[OPT_MIDTONE].title = "Midtone Level"; sod[OPT_MIDTONE].desc = "Midtone Level"; sod[OPT_MIDTONE].type = SANE_TYPE_INT; sod[OPT_MIDTONE].unit = SANE_UNIT_NONE; sod[OPT_MIDTONE].size = sizeof(SANE_Word); sod[OPT_MIDTONE].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_MIDTONE].constraint.range = &u8_range; val[OPT_MIDTONE].w = 128; if (ms->midtone_support) { sod[OPT_MIDTONE].cap |= SANE_CAP_ADVANCED; } else { sod[OPT_MIDTONE].cap |= SANE_CAP_INACTIVE; } /* XXXXXXXX is this supported by all scanners?? if ((strcmp(M_COLOR, val[OPT_MODE].s)) && (strcmp(M_GRAY, val[OPT_MODE].s))) { sod[OPT_HIGHLIGHT].cap |= SANE_CAP_INACTIVE; sod[OPT_SHADOW].cap |= SANE_CAP_INACTIVE; sod[OPT_MIDTONE].cap |= SANE_CAP_INACTIVE; } */ sod[OPT_GAMMA_GROUP].name = ""; sod[OPT_GAMMA_GROUP].title = "Gamma Control"; sod[OPT_GAMMA_GROUP].desc = ""; sod[OPT_GAMMA_GROUP].type = SANE_TYPE_GROUP; if (!(ms->gamma_entries)) sod[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_GROUP].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_CUSTOM_GAMMA].name = "gamma-mode"; sod[OPT_CUSTOM_GAMMA].title = "Gamma Control Mode"; sod[OPT_CUSTOM_GAMMA].desc = "How to specify gamma correction, if at all"; sod[OPT_CUSTOM_GAMMA].type = SANE_TYPE_STRING; sod[OPT_CUSTOM_GAMMA].size = max_string_size(gamma_mode_list); sod[OPT_CUSTOM_GAMMA].constraint_type = SANE_CONSTRAINT_STRING_LIST; sod[OPT_CUSTOM_GAMMA].constraint.string_list = gamma_mode_list; if (!(ms->gamma_entries)) sod[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; val[OPT_CUSTOM_GAMMA].s = strdup(gamma_mode_list[0]); sod[OPT_GAMMA_BIND].name = SANE_NAME_ANALOG_GAMMA_BIND; sod[OPT_GAMMA_BIND].title = SANE_TITLE_ANALOG_GAMMA_BIND; sod[OPT_GAMMA_BIND].desc = SANE_DESC_ANALOG_GAMMA_BIND; sod[OPT_GAMMA_BIND].type = SANE_TYPE_BOOL; sod[OPT_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; val[OPT_GAMMA_BIND].w = SANE_TRUE; sod[OPT_ANALOG_GAMMA].name = SANE_NAME_ANALOG_GAMMA; sod[OPT_ANALOG_GAMMA].title = SANE_TITLE_ANALOG_GAMMA; sod[OPT_ANALOG_GAMMA].desc = SANE_DESC_ANALOG_GAMMA; sod[OPT_ANALOG_GAMMA].type = SANE_TYPE_FIXED; sod[OPT_ANALOG_GAMMA].unit = SANE_UNIT_NONE; sod[OPT_ANALOG_GAMMA].size = sizeof(SANE_Word); sod[OPT_ANALOG_GAMMA].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_ANALOG_GAMMA].constraint.range = &analog_gamma_range; val[OPT_ANALOG_GAMMA].w = SANE_FIX(1.0); sod[OPT_ANALOG_GAMMA_R].name = SANE_NAME_ANALOG_GAMMA_R; sod[OPT_ANALOG_GAMMA_R].title = SANE_TITLE_ANALOG_GAMMA_R; sod[OPT_ANALOG_GAMMA_R].desc = SANE_DESC_ANALOG_GAMMA_R; sod[OPT_ANALOG_GAMMA_R].type = SANE_TYPE_FIXED; sod[OPT_ANALOG_GAMMA_R].unit = SANE_UNIT_NONE; sod[OPT_ANALOG_GAMMA_R].size = sizeof(SANE_Word); sod[OPT_ANALOG_GAMMA_R].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_R].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_ANALOG_GAMMA_R].constraint.range = &analog_gamma_range; val[OPT_ANALOG_GAMMA_R].w = SANE_FIX(1.0); sod[OPT_ANALOG_GAMMA_G].name = SANE_NAME_ANALOG_GAMMA_G; sod[OPT_ANALOG_GAMMA_G].title = SANE_TITLE_ANALOG_GAMMA_G; sod[OPT_ANALOG_GAMMA_G].desc = SANE_DESC_ANALOG_GAMMA_G; sod[OPT_ANALOG_GAMMA_G].type = SANE_TYPE_FIXED; sod[OPT_ANALOG_GAMMA_G].unit = SANE_UNIT_NONE; sod[OPT_ANALOG_GAMMA_G].size = sizeof(SANE_Word); sod[OPT_ANALOG_GAMMA_G].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_G].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_ANALOG_GAMMA_G].constraint.range = &analog_gamma_range; val[OPT_ANALOG_GAMMA_G].w = SANE_FIX(1.0); sod[OPT_ANALOG_GAMMA_B].name = SANE_NAME_ANALOG_GAMMA_B; sod[OPT_ANALOG_GAMMA_B].title = SANE_TITLE_ANALOG_GAMMA_B; sod[OPT_ANALOG_GAMMA_B].desc = SANE_DESC_ANALOG_GAMMA_B; sod[OPT_ANALOG_GAMMA_B].type = SANE_TYPE_FIXED; sod[OPT_ANALOG_GAMMA_B].unit = SANE_UNIT_NONE; sod[OPT_ANALOG_GAMMA_B].size = sizeof(SANE_Word); sod[OPT_ANALOG_GAMMA_B].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_B].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_ANALOG_GAMMA_B].constraint.range = &analog_gamma_range; val[OPT_ANALOG_GAMMA_B].w = SANE_FIX(1.0); sod[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; sod[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; sod[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; sod[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; sod[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; sod[OPT_GAMMA_VECTOR].size = ms->gamma_entries * sizeof(SANE_Word); sod[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_GAMMA_VECTOR].constraint.range = &(ms->gamma_entry_range); val[OPT_GAMMA_VECTOR].wa = ms->gray_lut; sod[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; sod[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; sod[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; sod[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; sod[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; sod[OPT_GAMMA_VECTOR_R].size = ms->gamma_entries * sizeof(SANE_Word); sod[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_GAMMA_VECTOR_R].constraint.range = &(ms->gamma_entry_range); val[OPT_GAMMA_VECTOR_R].wa = ms->red_lut; sod[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; sod[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; sod[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; sod[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; sod[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; sod[OPT_GAMMA_VECTOR_G].size = ms->gamma_entries * sizeof(SANE_Word); sod[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_GAMMA_VECTOR_G].constraint.range = &(ms->gamma_entry_range); val[OPT_GAMMA_VECTOR_G].wa = ms->green_lut; sod[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; sod[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; sod[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; sod[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; sod[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; sod[OPT_GAMMA_VECTOR_B].size = ms->gamma_entries * sizeof(SANE_Word); sod[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; sod[OPT_GAMMA_VECTOR_B].constraint.range = &(ms->gamma_entry_range); val[OPT_GAMMA_VECTOR_B].wa = ms->blue_lut; sod[OPT_EXP_RES].name = "exp_res"; sod[OPT_EXP_RES].title = "Expanded Resolution"; sod[OPT_EXP_RES].desc = "Enable double-resolution scans"; sod[OPT_EXP_RES].type = SANE_TYPE_BOOL; sod[OPT_EXP_RES].cap |= SANE_CAP_ADVANCED; if (!(ms->dev->info.expanded_resolution)) sod[OPT_EXP_RES].cap |= SANE_CAP_INACTIVE; val[OPT_EXP_RES].w = SANE_FALSE; sod[OPT_CALIB_ONCE].name = "calib_once"; sod[OPT_CALIB_ONCE].title = "Calibrate Only Once"; sod[OPT_CALIB_ONCE].desc = "Avoid CCD calibration on every scan" \ "(toggle off/on to cause calibration on next scan)"; sod[OPT_CALIB_ONCE].type = SANE_TYPE_BOOL; sod[OPT_CALIB_ONCE].cap |= SANE_CAP_ADVANCED; if (!(ms->do_real_calib)) { sod[OPT_CALIB_ONCE].cap |= SANE_CAP_INACTIVE; val[OPT_CALIB_ONCE].w = SANE_FALSE; } else val[OPT_CALIB_ONCE].w = SANE_TRUE; /* sod[OPT_].name = SANE_NAME_; sod[OPT_].title = SANE_TITLE_; sod[OPT_].desc = SANE_DESC_; sod[OPT_].type = SANE_TYPE_; sod[OPT_].unit = SANE_UNIT_NONE; sod[OPT_].size = sizeof(SANE_Word); sod[OPT_].cap = 0; sod[OPT_].constraint_type = SANE_CONSTRAINT_NONE; sod[OPT_].constraint = ; val[OPT_].w = ; */ DBG(15, "init_options: done.\n"); return SANE_STATUS_GOOD; } /********************************************************************/ /* Parse an INQUIRY information block, as returned by scanner */ /********************************************************************/ static SANE_Status parse_inquiry(Microtek_Info *mi, unsigned char *result) { #if 0 unsigned char result[0x60] = { 0x06,0x31,0x23,0x01,0x5b,0x00,0x00,0x00,0x41,0x47,0x46,0x41,0x20,0x20,0x20,0x20, 0x53,0x74,0x75,0x64,0x69,0x6f,0x53,0x63,0x61,0x6e,0x20,0x49,0x49,0x20,0x20,0x20, 0x32,0x2e,0x33,0x30,0x53,0x43,0x53,0x49,0x20,0x46,0x2f,0x57,0x56,0x33,0x2e,0x31, 0x20,0x43,0x54,0x4c,0x35,0x33,0x38,0x30,0x03,0x4f,0x8c,0xc5,0x00,0xee,0x5b,0x43, 0x01,0x01,0x02,0x00,0x00,0x03,0x00,0x01,0x00,0x4a,0x01,0x04,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff }; #endif DBG(15, "parse_inquiry...\n"); strncpy(mi->vendor_id, (char *)&result[8], 8); strncpy(mi->model_name, (char *)&result[16], 16); strncpy(mi->revision_num, (char *)&result[32], 4); strncpy(mi->vendor_string, (char *)&result[36], 20); mi->vendor_id[8] = 0; mi->model_name[16] = 0; mi->revision_num[4] = 0; mi->vendor_string[20] = 0; mi->device_type = (SANE_Byte)(result[0] & 0x1f); mi->SCSI_firmware_ver_major = (SANE_Byte)((result[1] & 0xf0) >> 4); mi->SCSI_firmware_ver_minor = (SANE_Byte)(result[1] & 0x0f); mi->scanner_firmware_ver_major = (SANE_Byte)((result[2] & 0xf0) >> 4); mi->scanner_firmware_ver_minor = (SANE_Byte)(result[2] & 0x0f); mi->response_data_format = (SANE_Byte)(result[3]); mi->res_step = (SANE_Byte)(result[56] & 0x03); mi->modes = (SANE_Byte)(result[57]); mi->pattern_count = (SANE_Int)(result[58] & 0x7f); mi->pattern_dwnld = (SANE_Byte)(result[58] & 0x80) > 0; mi->feed_type = (SANE_Byte)(result[59] & 0x0F); mi->compress_type = (SANE_Byte)(result[59] & 0x30); mi->unit_type = (SANE_Byte)(result[59] & 0xC0); mi->doc_size_code = (SANE_Byte)result[60]; /* we'll compute the max sizes after we know base resolution... */ /* why are these things set in two places (and probably wrong anyway)? */ mi->cont_settings = (SANE_Int)((result[61] & 0xf0) >> 4); if ((SANE_Int)(result[72])) mi->cont_settings = (SANE_Int)(result[72]); mi->min_contrast = -42; mi->max_contrast = (mi->cont_settings * 7) - 49; mi->exp_settings = (SANE_Int)(result[61] & 0x0f); if ((SANE_Int)(result[73])) mi->exp_settings = (SANE_Int)(result[73]); mi->min_exposure = -18; mi->max_exposure = (mi->exp_settings * 3) - 21; #if 0 mi->contrast_vals = (SANE_Int)(result[72]); mi->min_contrast = -42; mi->max_contrast = 49; if (mi->contrast_vals) mi->max_contrast = (mi->contrast_vals * 7) - 49; mi->exposure_vals = (SANE_Int)(result[73]); mi->min_exposure = -18; mi->max_exposure = 21; if (mi->exposure_vals) mi->max_exposure = (mi->exposure_vals * 3) - 21; #endif mi->model_code = (SANE_Byte)(result[62]); switch (mi->model_code) { case 0x16: /* the other ScanMaker 600ZS */ case 0x50: /* ScanMaker II/IIXE */ case 0x54: /* ScanMaker IISP */ case 0x55: /* ScanMaker IIER */ case 0x58: /* ScanMaker IIG */ case 0x5a: /* Agfa StudioScan (untested!) */ case 0x5f: /* ScanMaker E3 */ case 0x56: /* ScanMaker A3t */ case 0x64: /* ScanMaker E2 (,Vobis RealScan) */ case 0x65: /* Color PageWiz */ case 0xC8: /* ScanMaker 600ZS */ mi->base_resolution = 300; break; case 0x5b: /* Agfa StudioScan II/IIsi (untested!) */ mi->base_resolution = 400; break; case 0x57: /* ScanMaker IIHR */ case 0x59: /* ScanMaker III */ case 0x5c: /* Agfa Arcus II */ case 0x5e: /* Agfa StudioStar */ case 0x63: /* ScanMaker E6 */ case 0x66: /* ScanMaker E6 (new)*/ mi->base_resolution = 600; break; case 0x51: /* ScanMaker 45t */ case 0x5d: /* Agfa DuoScan */ mi->base_resolution = 1000; break; case 0x52: /* ScanMaker 35t */ mi->base_resolution = 1828; break; case 0x62: /* ScanMaker 35t+, Polaroid 35/LE */ mi->base_resolution = 1950; break; default: mi->base_resolution = 300; DBG(15, "parse_inquiry: Unknown base resolution for 0x%x!\n", mi->model_code); break; } /* Our max_x,y is in pixels. `Some scanners think in 1/8", though.' */ /* max pixel is, of course, total - 1 */ switch (mi->doc_size_code) { case 0x00: mi->max_x = 8.5 * mi->base_resolution - 1; mi->max_y = 14.0 * mi->base_resolution - 1; break; case 0x01: mi->max_x = 8.5 * mi->base_resolution - 1; mi->max_y = 11.0 * mi->base_resolution - 1; break; case 0x02: mi->max_x = 8.5 * mi->base_resolution - 1; mi->max_y = 11.69 * mi->base_resolution - 1; break; case 0x03: mi->max_x = 8.5 * mi->base_resolution - 1; mi->max_y = 13.0 * mi->base_resolution - 1; break; case 0x04: mi->max_x = 8.0 * mi->base_resolution - 1; mi->max_y = 10.0 * mi->base_resolution - 1; break; case 0x05: mi->max_x = 8.3 * mi->base_resolution - 1; mi->max_y = 14.0 * mi->base_resolution - 1; break; case 0x06: mi->max_x = 8.3 * mi->base_resolution - 1; mi->max_y = 13.5 * mi->base_resolution - 1; break; case 0x07: mi->max_x = 8.0 * mi->base_resolution - 1; mi->max_y = 14.0 * mi->base_resolution - 1; break; case 0x80: /* Slide format, size is mm */ mi->max_x = (35.0 / MM_PER_INCH) * mi->base_resolution - 1; mi->max_y = (35.0 / MM_PER_INCH) * mi->base_resolution - 1; break; case 0x81: mi->max_x = 5.0 * mi->base_resolution - 1; mi->max_y = 5.0 * mi->base_resolution - 1; break; case 0x82: /* Slide format, size is mm */ mi->max_x = (36.0 / MM_PER_INCH) * mi->base_resolution - 1; mi->max_y = (36.0 / MM_PER_INCH) * mi->base_resolution - 1; break; default: /* Undefined document format code */ mi->max_x = mi->max_y = 0; DBG(15, "parse_inquiry: Unknown doc_size_code! 0x%x\n", mi->doc_size_code); } /* create the proper range constraints, given the doc size */ { /* we need base resolution in dots-per-millimeter... */ float base_res_dpmm = (float) mi->base_resolution / MM_PER_INCH; mi->doc_x_range.min = SANE_FIX(0); mi->doc_x_range.max = SANE_FIX((float)mi->max_x / base_res_dpmm); mi->doc_x_range.quant = SANE_FIX(0); mi->doc_y_range.min = SANE_FIX(0); mi->doc_y_range.max = SANE_FIX((float)mi->max_y / base_res_dpmm); mi->doc_y_range.quant = SANE_FIX(0); } mi->source_options = (SANE_Byte)(result[63]); mi->expanded_resolution = (result[64] & 0x01); /* my E6 reports exp-res capability incorrectly */ if ((mi->model_code == 0x66) || (mi->model_code == 0x63)) { mi->expanded_resolution = 0xFF; DBG(4, "parse_inquiry: E6 falsely denies expanded resolution.\n"); } /* the StudioScan II(si) does the expanded-mode aspect correction within the scanner... (do others too?) */ if (mi->model_code == 0x5b) { DBG(4, "parse_inquiry: does expanded-mode expansion internally.\n"); mi->does_expansion = 1; } else mi->does_expansion = 0; mi->enhance_cap = (result[65] & 0x03); /* switch (result[66] & 0x0F) { case 0x00: mi->max_lookup_size = 0; break; case 0x01: mi->max_lookup_size = 256; break; case 0x03: mi->max_lookup_size = 1024; break; case 0x05: mi->max_lookup_size = 4096; break; case 0x09: mi->max_lookup_size = 65536; break; default: mi->max_lookup_size = 0; DBG(15, "parse_inquiry: Unknown gamma LUT size! 0x%x\n", result[66]); } */ /* This is not how the vague documentation specifies this register. We're going to take it literally here -- i.e. if the bit is set, the scanner supports the value, otherwise it doesn't. (The docs say all lower values are always supported. This is not the case for the StudioScan IIsi, at least, which only specifies 0x02==1024-byte table, and only supports that, too.) All-in-all, it doesn't matter, since we take the largest allowed LUT size anyway. */ if (result[66] & 0x08) mi->max_lookup_size = 65536; else if (result[66] & 0x04) mi->max_lookup_size = 4096; else if (result[66] & 0x02) mi->max_lookup_size = 1024; else if (result[66] & 0x01) mi->max_lookup_size = 256; else mi->max_lookup_size = 0; /* my E6 reports incorrectly */ if ((mi->model_code == 0x66) || (mi->model_code == 0x63)) { mi->max_lookup_size = 1024; DBG(4, "parse_inquiry: E6 falsely denies 1024-byte LUT.\n"); } /* switch (result[66] >> 5) { case 0x00: mi->max_gamma_val = 255; mi->gamma_size = 1; break; case 0x01: mi->max_gamma_val = 1023; mi->gamma_size = 2; break; case 0x02: mi->max_gamma_val = 4095; mi->gamma_size = 2; break; case 0x03: mi->max_gamma_val = 65535; mi->gamma_size = 2; break; default: mi->max_gamma_val = 0; mi->gamma_size = 0; DBG(15, "parse_inquiry: Unknown gamma max val! 0x%x\n", result[66]); } */ switch (result[66] >> 5) { case 0x00: mi->max_gamma_bit_depth = 8; mi->gamma_size = 1; break; case 0x01: mi->max_gamma_bit_depth = 10; mi->gamma_size = 2; break; case 0x02: mi->max_gamma_bit_depth = 12; mi->gamma_size = 2; break; case 0x03: mi->max_gamma_bit_depth = 16; mi->gamma_size = 2; break; default: mi->max_gamma_bit_depth = 0; mi->gamma_size = 0; DBG(15, "parse_inquiry: Unknown gamma max val! 0x%x\n", result[66]); } mi->fast_color_preview = (SANE_Byte)(result[67] & 0x01); mi->xfer_format_select = (SANE_Byte)(result[68] & 0x01); mi->color_sequence = (SANE_Byte)(result[69] & 0x7f); mi->does_3pass = (SANE_Byte)(!(result[69] & 0x80)); mi->does_mode1 = (SANE_Byte)(result[71] & 0x01); mi->bit_formats = (SANE_Byte)(result[74] & 0x0F); mi->extra_cap = (SANE_Byte)(result[75] & 0x07); /* XXXXXX a quick hack to disable any [pre/real]cal stuff for anything but an E6... */ if (!((mi->model_code == 0x66) || (mi->model_code == 0x63))) { mi->extra_cap &= ~MI_EXCAP_DIS_RECAL; DBG(4, "parse_inquiry: Not an E6 -- pretend recal cannot be disabled.\n"); } /* The E2 lies... */ if (mi->model_code == 0x64) { DBG(4, "parse_inquiry: The E2 lies about it's 3-pass heritage.\n"); mi->does_3pass = 1; mi->modes &= ~MI_MODES_ONEPASS; } return SANE_STATUS_GOOD; } /********************************************************************/ /* Dump all we know about scanner to stderr */ /********************************************************************/ static SANE_Status dump_inquiry(Microtek_Info *mi, unsigned char *result) { int i; DBG(15, "dump_inquiry...\n"); DBG(1, " === SANE/Microtek backend v%d.%d.%d ===\n", MICROTEK_MAJOR, MICROTEK_MINOR, MICROTEK_PATCH); DBG(1, "========== Scanner Inquiry Block ========mm\n"); for (i=0; i<96; ) { if (!(i % 16)) MDBG_INIT(""); MDBG_ADD("%02x ", (int)result[i++]); if (!(i % 16)) MDBG_FINISH(1); } DBG(1, "========== Scanner Inquiry Report ==========\n"); DBG(1, "===== Scanner ID...\n"); DBG(1, "Device Type Code: 0x%02x\n", mi->device_type); DBG(1, "Model Code: 0x%02x\n", mi->model_code); DBG(1, "Vendor Name: '%s' Model Name: '%s'\n", mi->vendor_id, mi->model_name); DBG(1, "Vendor Specific String: '%s'\n", mi->vendor_string); DBG(1, "Firmware Rev: '%s'\n", mi->revision_num); DBG(1, "SCSI F/W version: %1d.%1d Scanner F/W version: %1d.%1d\n", mi->SCSI_firmware_ver_major, mi->SCSI_firmware_ver_minor, mi->scanner_firmware_ver_major, mi->scanner_firmware_ver_minor); DBG(1, "Response data format: 0x%02x\n", mi->response_data_format); DBG(1, "===== Imaging Capabilities...\n"); DBG(1, "Modes: %s%s%s%s%s%s%s\n", (mi->modes & MI_MODES_LINEART) ? "Lineart " : "", (mi->modes & MI_MODES_HALFTONE) ? "Halftone " : "", (mi->modes & MI_MODES_GRAY) ? "Gray " : "", (mi->modes & MI_MODES_COLOR) ? "Color " : "", (mi->modes & MI_MODES_TRANSMSV) ? "(X-msv) " : "", (mi->modes & MI_MODES_ONEPASS) ? "(OnePass) " : "", (mi->modes & MI_MODES_NEGATIVE) ? "(Negative) " : ""); DBG(1, "Resolution Step Sizes: %s%s Expanded Resolution Support? %s%s\n", (mi->res_step & MI_RESSTEP_1PER) ? "1% " : "", (mi->res_step & MI_RESSTEP_5PER) ? "5%" : "", (mi->expanded_resolution) ? "yes" : "no", (mi->expanded_resolution == 0xFF) ? "(but says no)" : ""); DBG(1, "Supported Bits Per Sample: %s8 %s%s%s\n", (mi->bit_formats & MI_FMT_CAP_4BPP) ? "4 " : "", (mi->bit_formats & MI_FMT_CAP_10BPP) ? "10 " : "", (mi->bit_formats & MI_FMT_CAP_12BPP) ? "12 " : "", (mi->bit_formats & MI_FMT_CAP_16BPP) ? "16 " : ""); DBG(1, "Max. document size code: 0x%02x\n", mi->doc_size_code); DBG(1, "Max. document size: %d x %d pixels\n", mi->max_x, mi->max_y); DBG(1, "Frame units: %s%s\n", (mi->unit_type & MI_UNIT_PIXELS) ? "pixels " : "", (mi->unit_type & MI_UNIT_8TH_INCH) ? "1/8\"'s " : ""); DBG(1, "# of built-in halftones: %d Downloadable patterns? %s\n", mi->pattern_count, (mi->pattern_dwnld) ? "Yes" : "No"); DBG(1, "Data Compression: %s%s\n", (mi->compress_type & MI_COMPRSS_HUFF) ? "huffman " : "", (mi->compress_type & MI_COMPRSS_RD) ? "read-data " : ""); DBG(1, "Contrast Settings: %d Exposure Settings: %d\n", mi->cont_settings, mi->exp_settings); DBG(1, "Adjustable Shadow/Highlight? %s Adjustable Midtone? %s\n", (mi->enhance_cap & MI_ENH_CAP_SHADOW) ? "yes" : "no ", (mi->enhance_cap & MI_ENH_CAP_MIDTONE) ? "yes" : "no "); DBG(1, "Digital brightness/offset? %s\n", (mi->extra_cap & MI_EXCAP_OFF_CTL) ? "yes" : "no"); /* fprintf(stderr, "Gamma Table Size: %d entries of %d bytes (max. value: %d)\n", mi->max_lookup_size, mi->gamma_size, mi->max_gamma_val); */ DBG(1, "Gamma Table Size: %d entries of %d bytes (max. depth: %d)\n", mi->max_lookup_size, mi->gamma_size, mi->max_gamma_bit_depth); DBG(1, "===== Source Options...\n"); DBG(1, "Feed type: %s%s ADF support? %s\n", (mi->feed_type & MI_FEED_FLATBED) ? "flatbed " : "", (mi->feed_type & MI_FEED_EDGEFEED) ? "edge-feed " : "", (mi->feed_type & MI_FEED_AUTOSUPP) ? "yes" : "no"); DBG(1, "Document Feeder Support? %s Feeder Backtracking? %s\n", (mi->source_options & MI_SRC_FEED_SUPP) ? "yes" : "no ", (mi->source_options & MI_SRC_FEED_BT) ? "yes" : "no "); DBG(1, "Feeder Installed? %s Feeder Ready? %s\n", (mi->source_options & MI_SRC_HAS_FEED) ? "yes" : "no ", (mi->source_options & MI_SRC_FEED_RDY) ? "yes" : "no "); DBG(1, "Transparency Adapter Installed? %s\n", (mi->source_options & MI_SRC_HAS_TRANS) ? "yes" : "no "); /* GET_TRANS GET_FEED XXXXXXXXX */ /* mt_SWslct ???? XXXXXXXXXXX */ /*#define DOC_ON_FLATBED 0x00 #define DOC_IN_FEEDER 0x01 #define TRANSPARENCY 0x10 */ DBG(1, "Fast Color Prescan? %s\n", (mi->fast_color_preview) ? "yes" : "no"); DBG(1, "Selectable Transfer Format? %s\n", (mi->xfer_format_select) ? "yes" : "no"); MDBG_INIT("Color Transfer Sequence: "); switch (mi->color_sequence) { case MI_COLSEQ_PLANE: MDBG_ADD("plane-by-plane (3-pass)"); break; case MI_COLSEQ_PIXEL: MDBG_ADD("pixel-by-pixel RGB"); break; case MI_COLSEQ_RGB: MDBG_ADD("line-by-line, R-G-B sequence"); break; case MI_COLSEQ_NONRGB: MDBG_ADD("line-by-line, non-sequential with headers"); break; case MI_COLSEQ_2PIXEL: MDBG_ADD("2pixel-by-2pixel RRGGBB"); break; default: MDBG_ADD("UNKNOWN CODE (0x%02x)", mi->color_sequence); } MDBG_FINISH(1); /* if (mi->modes & MI_MODES_ONEPASS) XXXXXXXXXXX */ DBG(1, "Three pass scan support? %s\n", (mi->does_3pass ? "yes" : "no")); DBG(1, "ModeSelect-1 and ModeSense-1 Support? %s\n", (mi->does_mode1) ? "yes" : "no"); DBG(1, "Can Disable Linearization Table? %s\n", (mi->extra_cap & MI_EXCAP_DIS_LNTBL) ? "yes" : "no"); DBG(1, "Can Disable Start-of-Scan Recalibration? %s\n", (mi->extra_cap & MI_EXCAP_DIS_RECAL) ? "yes" : "no"); DBG(1, "Internal expanded expansion? %s\n", mi->does_expansion ? "yes" : "no"); /* fprintf(stderr, "cntr_vals = %d, min_cntr = %d, max_cntr = %d\n", cntr_vals, min_cntr, max_cntr); fprintf(stderr, "exp_vals = %d, min_exp = %d, max_exp = %d\n", exp_vals, min_exp, max_exp); */ DBG(1, "====== End of Scanner Inquiry Report =======\n"); return SANE_STATUS_GOOD; } /********************************************************************/ /* Dump all we know about some unknown scanner to stderr */ /********************************************************************/ static SANE_Status dump_suspect_inquiry(unsigned char *result) { int i; char vendor_id[64], model_name[64], revision_num[16]; SANE_Byte device_type, model_code; SANE_Byte SCSI_firmware_ver_major, SCSI_firmware_ver_minor; SANE_Byte scanner_firmware_ver_major, scanner_firmware_ver_minor; SANE_Byte response_data_format; DBG(15, "dump_suspect_inquiry...\n"); DBG(1, " === SANE/Microtek backend v%d.%d.%d ===\n", MICROTEK_MAJOR, MICROTEK_MINOR, MICROTEK_PATCH); DBG(1, "========== Scanner Inquiry Block ========mm\n"); for (i=0; i<96; ) { if (!(i % 16)) MDBG_INIT(""); MDBG_ADD("%02x ", (int)result[i++]); if (!(i % 16)) MDBG_FINISH(1); } #if 0 for (i=0; i<96; i++) { if (!(i % 16) && (i)) fprintf(stderr, "\n"); fprintf(stderr, "%02x ", (int)result[i]); } fprintf(stderr, "\n\n"); #endif strncpy(vendor_id, (char *)&result[8], 8); strncpy(model_name, (char *)&result[16], 16); strncpy(revision_num, (char *)&result[32], 4); vendor_id[8] = 0; model_name[16] = 0; revision_num[5] = 0; device_type = (SANE_Byte)(result[0] & 0x1f); SCSI_firmware_ver_major = (SANE_Byte)((result[1] & 0xf0) >> 4); SCSI_firmware_ver_minor = (SANE_Byte)(result[1] & 0x0f); scanner_firmware_ver_major = (SANE_Byte)((result[2] & 0xf0) >> 4); scanner_firmware_ver_minor = (SANE_Byte)(result[2] & 0x0f); response_data_format = (SANE_Byte)(result[3]); model_code = (SANE_Byte)(result[62]); DBG(1, "========== Scanner Inquiry Report ==========\n"); DBG(1, "===== Scanner ID...\n"); DBG(1, "Device Type Code: 0x%02x\n", device_type); DBG(1, "Model Code: 0x%02x\n", model_code); DBG(1, "Vendor Name: '%s' Model Name: '%s'\n", vendor_id, model_name); DBG(1, "Firmware Rev: '%s'\n", revision_num); DBG(1, "SCSI F/W version: %1d.%1d Scanner F/W version: %1d.%1d\n", SCSI_firmware_ver_major, SCSI_firmware_ver_minor, scanner_firmware_ver_major, scanner_firmware_ver_minor); DBG(1, "Response data format: 0x%02x\n", response_data_format); DBG(1, "====== End of Scanner Inquiry Report =======\n"); return SANE_STATUS_GOOD; } /********************************************************************/ /* Determine if device is a Microtek Scanner (from INQUIRY info) */ /********************************************************************/ static SANE_Status id_microtek(uint8_t *result, char **model_string) { SANE_Byte device_type, response_data_format; int forcewarn = 0; DBG(15, "id_microtek...\n"); /* check device type first... */ device_type = (SANE_Byte)(result[0] & 0x1f); if (device_type != 0x06) { DBG(15, "id_microtek: not even a scanner: dev_type = %d\n", device_type); return SANE_STATUS_INVAL; } if (!(strncmp("MICROTEK", (char *)&(result[8]), 8)) || !(strncmp("MII SC31", (char *)&(result[8]), 8)) || /* the IISP */ !(strncmp("MII SC21", (char *)&(result[8]), 8)) || /* the 600ZS */ !(strncmp("MII SC23", (char *)&(result[8]), 8)) || /* the other 600ZS */ !(strncmp("MII SC25", (char *)&(result[8]), 8)) || /* some other 600GS */ !(strncmp("AGFA ", (char *)&(result[8]), 8)) || /* Arcus II */ !(strncmp("Microtek", (char *)&(result[8]), 8)) || /* some 35t+'s */ !(strncmp("Polaroid", (char *)&(result[8]), 8)) || /* SprintScan 35LE */ !(strncmp(" ", (char *)&(result[8]), 8)) ) { switch (result[62]) { case 0x16 : *model_string = "ScanMaker 600ZS"; break; case 0x50 : *model_string = "ScanMaker II/IIXE"; break; case 0x51 : *model_string = "ScanMaker 45t"; break; case 0x52 : *model_string = "ScanMaker 35t"; break; case 0x54 : *model_string = "ScanMaker IISP"; break; case 0x55 : *model_string = "ScanMaker IIER"; break; case 0x56 : *model_string = "ScanMaker A3t"; break; case 0x57 : *model_string = "ScanMaker IIHR"; break; case 0x58 : *model_string = "ScanMaker IIG"; break; case 0x59 : *model_string = "ScanMaker III"; break; case 0x5A : *model_string = "Agfa StudioScan"; break; case 0x5B : *model_string = "Agfa StudioScan II"; break; case 0x5C : *model_string = "Agfa Arcus II"; break; case 0x5f : *model_string = "ScanMaker E3"; break; case 0x62 : if (!(strncmp("Polaroid", (char *)&(result[8]), 8))) *model_string = "Polaroid SprintScan 35/LE"; else *model_string = "ScanMaker 35t+"; break; case 0x63 : case 0x66 : *model_string = "ScanMaker E6"; break; case 0x64 : /* and "Vobis RealScan" */ *model_string = "ScanMaker E2"; break; case 0x65: *model_string = "Color PageWiz"; break; case 0xC8: *model_string = "ScanMaker 600ZS"; break; /* the follow are listed in the docs, but are otherwise a mystery... */ case 0x5D: *model_string = "Agfa DuoScan"; forcewarn = 1; break; case 0x5E: *model_string = "SS3"; forcewarn = 1; break; case 0x60: *model_string = "HR1"; forcewarn = 1; break; case 0x61: *model_string = "45T+"; forcewarn = 1; break; case 0x67: *model_string = "TR3"; forcewarn = 1; break; default : /* this might be a newer scanner, which uses the SCSI II command set. */ /* that's unfortunate, but we'll warn the user anyway.... */ response_data_format = (SANE_Byte)(result[3]); if (response_data_format == 0x02) { DBG(15, "id_microtek: (uses new SCSI II command set)\n"); if (DBG_LEVEL >= 15) { DBG(1, "\n"); DBG(1, "\n"); DBG(1, "\n"); DBG(1, "========== Congratulations! ==========\n"); DBG(1, "You appear to be the proud owner of a \n"); DBG(1, "brand-new Microtek scanner, which uses\n"); DBG(1, "a new SCSI II command set. \n"); DBG(1, "\n"); DBG(1, "Try the `microtek2' backend instead. \n"); DBG(1, "\n"); DBG(1, "\n"); DBG(1, "\n"); } } return SANE_STATUS_INVAL; } if (forcewarn) { /* force debugging on, to encourage user to send in a report */ #ifndef NDEBUG DBG_LEVEL = 1; #endif DBG(1, "\n"); DBG(1, "\n"); DBG(1, "\n"); DBG(1, "========== Congratulations! ==========\n"); DBG(1, "Your scanner appears to be supported \n"); DBG(1, "by the microtek backend. However, it \n"); DBG(1, "has never been tried before, and some \n"); DBG(1, "parameters are bound to be wrong. \n"); DBG(1, "\n"); DBG(1, "Please send the scanner inquiry log in\n"); DBG(1, "its entirety to mtek-bugs@mir.com and \n"); DBG(1, "include a description of the scanner, \n"); DBG(1, "including the base optical resolution.\n"); DBG(1, "\n"); DBG(1, "You'll find complete instructions for \n"); DBG(1, "submitting an error/debug log in the \n"); DBG(1, "'sane-microtek' man-page. \n"); DBG(1, "\n"); DBG(1, "\n"); DBG(1, "\n"); } return SANE_STATUS_GOOD; } DBG(15, "id_microtek: not microtek: %d, %d, %d\n", strncmp("MICROTEK", (char *)&(result[8]), 8), strncmp(" ", (char *)&(result[8]), 8), result[62]); return SANE_STATUS_INVAL; } /********************************************************************/ /* Try to attach a device as a Microtek scanner */ /********************************************************************/ static SANE_Status attach_scanner(const char *devicename, Microtek_Device **devp) { Microtek_Device *dev; int sfd; size_t size; unsigned char result[0x60]; SANE_Status status; char *model_string; uint8_t inquiry[] = { 0x12, 0, 0, 0, 0x60, 0 }; DBG(15,"attach_scanner: %s\n", devicename); /* check if device is already known... */ for (dev = first_dev; dev; dev = dev->next) { if (strcmp(dev->sane.name, devicename) == 0) { if (devp) *devp = dev; return SANE_STATUS_GOOD; } } /* open scsi device... */ DBG(20, "attach_scanner: opening %s\n", devicename); if (sanei_scsi_open(devicename, &sfd, sense_handler, NULL) != 0) { DBG(20, "attach_scanner: open failed\n"); return SANE_STATUS_INVAL; } /* say hello... */ DBG(20, "attach_scanner: sending INQUIRY\n"); size = sizeof(result); status = sanei_scsi_cmd(sfd, inquiry, sizeof(inquiry), result, &size); sanei_scsi_close (sfd); if (status != SANE_STATUS_GOOD || size != 0x60) { DBG(20, "attach_scanner: inquiry failed (%s)\n", sane_strstatus (status)); return status; } if (id_microtek(result, &model_string) != SANE_STATUS_GOOD) { DBG(15, "attach_scanner: device doesn't look like a Microtek scanner."); if (DBG_LEVEL >= 5) dump_suspect_inquiry(result); return SANE_STATUS_INVAL; } dev=malloc(sizeof(*dev)); if (!dev) return SANE_STATUS_NO_MEM; memset(dev, 0, sizeof(*dev)); parse_inquiry(&(dev->info), result); if (DBG_LEVEL > 0) dump_inquiry(&(dev->info), result); /* initialize dev structure */ dev->sane.name = strdup(devicename); dev->sane.vendor = "Microtek"; dev->sane.model = strdup(model_string); dev->sane.type = "flatbed scanner"; /* link into device list... */ ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; DBG(15, "attach_scanner: happy.\n"); return SANE_STATUS_GOOD; } /********************************************************************/ /* Attach a scanner (convenience wrapper for find_scanners...) */ /********************************************************************/ static SANE_Status attach_one (const char *dev) { attach_scanner (dev, 0); return SANE_STATUS_GOOD; } /********************************************************************/ /* End a scan, and clean up afterwards */ /********************************************************************/ static SANE_Status end_scan(Microtek_Scanner *s, SANE_Status ostat) { SANE_Status status; DBG(15, "end_scan...\n"); if (s->scanning) { s->scanning = SANE_FALSE; /* stop the scanner */ if (s->scan_started) { status = stop_scan(s); if (status != SANE_STATUS_GOOD) DBG(23, "end_scan: OY! on stop_scan\n"); s->scan_started = SANE_FALSE; } /* close the SCSI device */ if (s->sfd != -1) { sanei_scsi_close(s->sfd); s->sfd = -1; } /* free the buffers we malloc'ed */ if (s->scsi_buffer != NULL) { free(s->scsi_buffer); s->scsi_buffer = NULL; } if (s->rb != NULL) { ring_free(s->rb); s->rb = NULL; } } /* if this -was- pass 3, or cancel, then we must be done */ if ((s->this_pass == 3) || (s->cancel)) s->this_pass = 0; return ostat; } /********************************************************************/ /********************************************************************/ /***** Scan-time operations *****/ /********************************************************************/ /********************************************************************/ /* number of lines of calibration data returned by scanner */ #define STRIPS 12 /* well, that's what it seems to be for the E6 */ /* simple comparison for the qsort below */ static int comparo(const void *a, const void *b) { return (*(const int *)a - *(const int *)b); } /* extract values from scanlines and sort */ static void sort_values(int *result, uint8_t *scanline[], int pix) { int i; for (i=0; i= bot) && (sorted[j] <= top)) { sum += sorted[j]; count++; } } if (count) caldata[i] = (sum + (count / 2)) / count; else { DBG(23, "zero: i=%d b/t=%d/%d ", i, bot, top); if (DBG_LEVEL >= 23) { MDBG_INIT(""); for (j=0; j 0; nleft -= ntoget, spot += buffsize) { ntoget = (nleft > nmax) ? nmax : nleft; buffsize = ntoget * 3 * linewidth; DBG(23, "...nleft %d toget %d size %lu spot %d input+spot %p\n", nleft, ntoget, (u_long) buffsize, spot, input+spot); if ((statusA = read_scan_data(s, ntoget, input+spot, &buffsize)) != SANE_STATUS_GOOD) { DBG(23, "...read scan failed\n"); break; } } status = stop_scan(s); if ((statusA != SANE_STATUS_GOOD) || (status != SANE_STATUS_GOOD)) { free(input); free(combuff); return ((statusA != SANE_STATUS_GOOD) ? statusA : status); } /* calculate calibration data for each element and download */ for (letter = 'R'; letter != 'X'; ) { DBG(23, "do_real_calibrate: working on %c\n", letter); for (spot=0, i=0; spot < linewidth * STRIPS * 3; spot += linewidth) { if (input[spot+1] == letter) { DBG(23, " found %d (at %d)\n", i, spot); if (i >= STRIPS) { DBG(23, "WHOA!!! %i have already been found!\n", i); break; } scanline[i] = &(input[spot+2]); i++; } } calc_calibration(combuff + 8, scanline, linewidth - 2); if ((status = download_calibration(s, combuff, letter, linewidth)) != SANE_STATUS_GOOD) { DBG(23, "...download_calibration failed\n"); free(input); free(combuff); return status; } switch (letter) { case 'R': letter = 'G'; break; case 'G': letter = 'B'; break; case 'B': default: letter = 'X'; break; } } /* clean up */ free(input); free(combuff); return SANE_STATUS_GOOD; } /********************************************************************/ /* Cause scanner to calibrate, but don't really scan anything */ /* (i.e. do everything but read data) */ /********************************************************************/ static SANE_Status do_precalibrate(SANE_Handle handle) { Microtek_Scanner *s = handle; SANE_Status status, statusA; SANE_Int busy, linewidth, lines; DBG(10, "do_precalibrate...\n"); if ((status = wait_ready(s)) != SANE_STATUS_GOOD) return status; { SANE_Int y1 = s->y1; SANE_Int y2 = s->y2; /* some small range, but large enough to cause the scanner to think it'll scan *something*... */ s->y1 = 0; s->y2 = (s->resolution > s->dev->info.base_resolution) ? 4 : 4 * s->dev->info.base_resolution / s->resolution; status = scanning_frame(s); s->y1 = y1; s->y2 = y2; if (status != SANE_STATUS_GOOD) return status; } if (s->dev->info.source_options & (MI_SRC_FEED_BT | MI_SRC_HAS_TRANS | MI_SRC_FEED_SUPP | MI_SRC_HAS_FEED)) { /* ZZZZZZZZZZZ */ if ((status = accessory(s)) != SANE_STATUS_GOOD) return status; } if ((status = mode_select(s)) != SANE_STATUS_GOOD) return status; /* why would we even try if this were not true?... */ /*if (s->dev->info.extra_cap & MI_EXCAP_DIS_RECAL) */ { SANE_Bool allow_calibrate = s->allow_calibrate; s->allow_calibrate = SANE_TRUE; status = mode_select_1(s); s->allow_calibrate = allow_calibrate; if (status != SANE_STATUS_GOOD) return status; } if ((status = wait_ready(s)) != SANE_STATUS_GOOD) return status; if ((status = start_scan(s)) != SANE_STATUS_GOOD) return status; if ((statusA = get_scan_status(s, &busy, &linewidth, &lines)) != SANE_STATUS_GOOD) { DBG(10, "do_precalibrate: get_scan_status fails\n"); } if ((status = stop_scan(s)) != SANE_STATUS_GOOD) return status; if ((status = wait_ready(s)) != SANE_STATUS_GOOD) return status; DBG(10, "do_precalibrate done.\n"); if (statusA != SANE_STATUS_GOOD) return statusA; else return SANE_STATUS_GOOD; } /********************************************************************/ /* Calibrate scanner, if necessary; record results */ /********************************************************************/ static SANE_Status finagle_precal(SANE_Handle handle) { Microtek_Scanner *s = handle; SANE_Status status; int match; /* try to check if scanner has been reset */ /* if so, calibrate it (either for real, or via a fake scan, with calibration */ /* (but only bother if you *could* disable calibration) */ DBG(23, "finagle_precal...\n"); if ((s->do_clever_precal) || (s->do_real_calib)) { if ((status = compare_mode_sense(s, &match)) != SANE_STATUS_GOOD) return status; if (((s->do_real_calib) && (!s->calib_once)) || /* user want recal */ (!match) || /* or, possible reset */ ((s->mode == MS_MODE_COLOR) && /* or, other weirdness */ (s->precal_record < MS_PRECAL_COLOR)) || ((s->mode == MS_MODE_COLOR) && (s->expandedresolution) && (s->precal_record < MS_PRECAL_EXP_COLOR))) { DBG(23, "finagle_precal: must precalibrate!\n"); s->precal_record = MS_PRECAL_NONE; if (s->do_real_calib) { /* do a real calibration if allowed */ if ((status = do_real_calibrate(s)) != SANE_STATUS_GOOD) return status; } else if (s->do_clever_precal) {/* otherwise do the fake-scan version */ if ((status = do_precalibrate(s)) != SANE_STATUS_GOOD) return status; } if (s->mode == MS_MODE_COLOR) { if (s->expandedresolution) s->precal_record = MS_PRECAL_EXP_COLOR; else s->precal_record = MS_PRECAL_COLOR; } else s->precal_record = MS_PRECAL_GRAY; } else DBG(23, "finagle_precal: no precalibrate necessary.\n"); } return SANE_STATUS_GOOD; } /********************************************************************/ /* Set pass-dependent parameters (for 3-pass color scans) */ /********************************************************************/ static void set_pass_parameters (SANE_Handle handle) { Microtek_Scanner *s = handle; if (s->threepasscolor) { s->this_pass += 1; DBG(23, "set_pass_parameters: three-pass, on %d\n", s->this_pass); switch (s->this_pass) { case 1: s->filter = MS_FILT_RED; s->params.format = SANE_FRAME_RED; s->params.last_frame = SANE_FALSE; break; case 2: s->filter = MS_FILT_GREEN; s->params.format = SANE_FRAME_GREEN; s->params.last_frame = SANE_FALSE; break; case 3: s->filter = MS_FILT_BLUE; s->params.format = SANE_FRAME_BLUE; s->params.last_frame = SANE_TRUE; break; default: s->filter = MS_FILT_CLEAR; DBG(23, "set_pass_parameters: What?!? pass %d = filter?\n", s->this_pass); break; } } else s->this_pass = 0; } /********************************************************************/ /********************************************************************/ /***** Packing functions *****/ /***** ...process raw scanner bytes, and shove into *****/ /***** the ring buffer *****/ /********************************************************************/ /********************************************************************/ /********************************************************************/ /* Process flat (byte-by-byte) data */ /********************************************************************/ static SANE_Status pack_flat_data(Microtek_Scanner *s, size_t nlines) { SANE_Status status; ring_buffer *rb = s->rb; size_t nbytes = nlines * rb->bpl; size_t start = (rb->head_complete + rb->complete_count) % rb->size; size_t max_xfer = (start < rb->head_complete) ? (rb->head_complete - start) : (rb->size - start + rb->head_complete); size_t length = MIN(nbytes, max_xfer); if (nbytes > max_xfer) { DBG(23, "pack_flat: must expand ring, %lu + %lu\n", (u_long)rb->size, (u_long)(nbytes - max_xfer)); status = ring_expand(rb, (nbytes - max_xfer)); if (status != SANE_STATUS_GOOD) return status; } if (s->doexpansion) { unsigned int line, bit; SANE_Byte *sb, *db, byte; size_t pos; sb = s->scsi_buffer; db = rb->base; pos = start; if (!(s->multibit)) { for (line=0; lineexp_aspect, n1 = 0.0, n2 = floor(x2); i < rb->bpl; i++) { byte = 0; for (bit=0; bit < 8; bit++, x1 = x2, n1 = n2, x2 += s->exp_aspect, n2 = floor(x2)) { /* #define getbit(byte, index) (((byte)>>(index))&1) */ byte |= (( (x2 == n2) ? (((sb[(int)n1 / 8])>>(7 - ((int)n1) % 8))&1) : (((double)(((sb[(int)n1/8])>>(7-(int)n1%8))&1) * (n2 - x1) + (double)(((sb[(int)n2/8])>>(7-(int)n2%8))&1) * (x2 - n2) ) / s->exp_aspect) ) > 0.5) << (7 - bit); } db[pos] = byte; if (++pos >= rb->size) pos = 0; } sb += s->pixel_bpl; } } else { /* multibit scan (8 is assumed!) */ for (line=0; lineexp_aspect, n1 = 0.0, n2 = floor(x2); i < s->dest_ppl; i++, x1 = x2, n1 = n2, x2 += s->exp_aspect, n2 = floor(x2)) { db[pos] = (x2 == n2) ? sb[(int)n1] : (int)(((double)sb[(int)n1] * (n2 - x1) + (double)sb[(int)n2] * (x2 - n2)) / s->exp_aspect); if (++pos >= rb->size) pos = 0; } sb += s->pixel_bpl; } } } else { /* adjust for rollover!!! */ if ((start + length) < rb->size) { memcpy(rb->base + start, s->scsi_buffer, length); } else { size_t chunk1 = rb->size - start; size_t chunk2 = length - chunk1; memcpy(rb->base + start, s->scsi_buffer, chunk1); memcpy(rb->base, s->scsi_buffer + chunk1, chunk2); } } rb->complete_count += length; return SANE_STATUS_GOOD; } /********************************************************************/ /* Process sequential R-G-B scan lines (who uses this??? ) */ /********************************************************************/ static SANE_Status pack_seqrgb_data (Microtek_Scanner *s, size_t nlines) { ring_buffer *rb = s->rb; unsigned int seg; SANE_Byte *db = rb->base; SANE_Byte *sb = s->scsi_buffer; size_t completed; size_t spot; SANE_Byte id; { size_t ar, ag, ab; /* allowed additions */ size_t dr, dg, db; /* additions which will occur */ SANE_Status status; dr = dg = db = nlines * rb->bpl; ar = rb->size - (rb->complete_count + rb->red_extra * 3); ag = rb->size - (rb->complete_count + rb->green_extra * 3); ab = rb->size - (rb->complete_count + rb->blue_extra * 3); DBG(23, "pack_seq: dr/ar: %lu/%lu dg/ag: %lu/%lu db/ab: %lu/%lu\n", (u_long)dr, (u_long)ar, (u_long)dg, (u_long)ag, (u_long)db, (u_long)ab); if ((dr > ar) || (dg > ag) || (db > ab)) { size_t increase = 0; if (dr > ar) increase = (dr - ar); if (dg > ag) increase = MAX(increase, (dg - ag)); if (db > ab) increase = MAX(increase, (db - ab)); DBG(23, "pack_seq: must expand ring, %lu + %lu\n", (u_long)rb->size, (u_long)increase); status = ring_expand(rb, increase); if (status != SANE_STATUS_GOOD) return status; } } for (seg = 0, id = 0; seg < nlines * 3; seg++, id = (id+1)%3) { switch (id) { case 0: spot = rb->tail_red; break; case 1: spot = rb->tail_green; break; case 2: spot = rb->tail_blue; break; default: DBG(18, "pack_seq: missing scanline RGB header!\n"); return SANE_STATUS_IO_ERROR; } if (s->doexpansion) { int i; double x1, x2, n1, n2; for (i = 0, x1 = 0.0, x2 = s->exp_aspect, n1 = 0.0, n2 = floor(x2); i < s->dest_ppl; i++, x1 = x2, n1 = n2, x2 += s->exp_aspect, n2 = floor(x2)) { db[spot] = (x2 == n2) ? sb[(int)n1] : (int)(((double)sb[(int)n1] * (n2 - x1) + (double)sb[(int)n2] * (x2 - n2)) / s->exp_aspect); if ((spot += 3) >= rb->size) spot -= rb->size; } sb += s->ppl; } else { size_t i; for (i=0; i < rb->ppl; i++) { db[spot] = *sb; sb++; if ((spot += 3) >= rb->size) spot -= rb->size; } } switch (id) { case 0: rb->tail_red = spot; rb->red_extra += rb->ppl; break; case 1: rb->tail_green = spot; rb->green_extra += rb->ppl; break; case 2: rb->tail_blue = spot; rb->blue_extra += rb->ppl; break; } } completed = MIN(rb->red_extra, MIN(rb->green_extra, rb->blue_extra)); rb->complete_count += completed * 3; /* 3 complete bytes per pixel! */ rb->red_extra -= completed; rb->green_extra -= completed; rb->blue_extra -= completed; DBG(18, "pack_seq: extra r: %lu g: %lu b: %lu\n", (u_long)rb->red_extra, (u_long)rb->green_extra, (u_long)rb->blue_extra); DBG(18, "pack_seq: completed: %lu complete: %lu\n", (u_long)completed, (u_long)rb->complete_count); return SANE_STATUS_GOOD; } /********************************************************************/ /* Process non-sequential R,G, and B scan-lines */ /********************************************************************/ static SANE_Status pack_goofyrgb_data(Microtek_Scanner *s, size_t nlines) { ring_buffer *rb = s->rb; unsigned int seg; /* , i;*/ SANE_Byte *db; SANE_Byte *sb = s->scsi_buffer; size_t completed; size_t spot; SANE_Byte id; /* prescan to decide if ring should be expanded */ { size_t ar, ag, ab; /* allowed additions */ size_t dr, dg, db; /* additions which will occur */ SANE_Status status; SANE_Byte *pt; for (dr = dg = db = 0, seg = 0, pt = s->scsi_buffer + 1; seg < nlines * 3; seg++, pt += s->ppl + 2) { switch (*pt) { case 'R': dr += rb->bpl; break; case 'G': dg += rb->bpl; break; case 'B': db += rb->bpl; break; } } ar = rb->size - (rb->complete_count + rb->red_extra * 3); ag = rb->size - (rb->complete_count + rb->green_extra * 3); ab = rb->size - (rb->complete_count + rb->blue_extra * 3); DBG(23, "pack_goofy: dr/ar: %lu/%lu dg/ag: %lu/%lu db/ab: %lu/%lu\n", (u_long)dr, (u_long)ar, (u_long)dg, (u_long)ag, (u_long)db, (u_long)ab); /* >, or >= ???????? */ if ((dr > ar) || (dg > ag) || (db > ab)) { size_t increase = 0; if (dr > ar) increase = (dr - ar); if (dg > ag) increase = MAX(increase, (dg - ag)); if (db > ab) increase = MAX(increase, (db - ab)); DBG(23, "pack_goofy: must expand ring, %lu + %lu\n", (u_long)rb->size, (u_long)increase); status = ring_expand(rb, increase); if (status != SANE_STATUS_GOOD) return status; } } db = rb->base; for (seg = 0; seg < nlines * 3; seg++) { sb++; /* skip first byte in line (two byte header) */ id = *sb; switch (id) { case 'R': spot = rb->tail_red; break; case 'G': spot = rb->tail_green; break; case 'B': spot = rb->tail_blue; break; default: DBG(18, "pack_goofy: missing scanline RGB header!\n"); return SANE_STATUS_IO_ERROR; } sb++; /* skip the other header byte */ if (s->doexpansion) { int i; double x1, x2, n1, n2; for (i = 0, x1 = 0.0, x2 = s->exp_aspect, n1 = 0.0, n2 = floor(x2); i < s->dest_ppl; i++, x1 = x2, n1 = n2, x2 += s->exp_aspect, n2 = floor(x2)) { db[spot] = (x2 == n2) ? sb[(int)n1] : (int)(((double)sb[(int)n1] * (n2 - x1) + (double)sb[(int)n2] * (x2 - n2)) / s->exp_aspect); if ((spot += 3) >= rb->size) spot -= rb->size; } sb += s->ppl; } else { unsigned int i; for (i=0; i < rb->ppl; i++) { db[spot] = *sb; sb++; if ((spot += 3) >= rb->size) spot -= rb->size; } } switch (id) { case 'R': rb->tail_red = spot; rb->red_extra += rb->ppl; break; case 'G': rb->tail_green = spot; rb->green_extra += rb->ppl; break; case 'B': rb->tail_blue = spot; rb->blue_extra += rb->ppl; break; } } completed = MIN(rb->red_extra, MIN(rb->green_extra, rb->blue_extra)); rb->complete_count += completed * 3; /* 3 complete bytes per pixel! */ rb->red_extra -= completed; rb->green_extra -= completed; rb->blue_extra -= completed; DBG(18, "pack_goofy: extra r: %lu g: %lu b: %lu\n", (u_long)rb->red_extra, (u_long)rb->green_extra, (u_long)rb->blue_extra); DBG(18, "pack_goofy: completed: %lu complete: %lu\n", (u_long)completed, (u_long)rb->complete_count); return SANE_STATUS_GOOD; } /********************************************************************/ /* Process R1R2-G1G2-B1B2 double pixels (AGFA StudioStar) */ /********************************************************************/ static SANE_Status pack_seq2r2g2b_data(Microtek_Scanner *s, size_t nlines) { SANE_Status status; ring_buffer *rb = s->rb; size_t nbytes = nlines * rb->bpl; size_t start = (rb->head_complete + rb->complete_count) % rb->size; size_t max_xfer = (start < rb->head_complete) ? (rb->head_complete - start) : (rb->size - start + rb->head_complete); size_t length = MIN(nbytes, max_xfer); if (nbytes > max_xfer) { DBG(23, "pack_2r2g2b: must expand ring, %lu + %lu\n", (u_long)rb->size, (u_long)(nbytes - max_xfer)); status = ring_expand(rb, (nbytes - max_xfer)); if (status != SANE_STATUS_GOOD) return status; } { unsigned int line; int p; size_t pos = start; SANE_Byte *sb = s->scsi_buffer; SANE_Byte *db = rb->base; for (line = 0; line < nlines; line++) { for (p = 0; p < s->dest_ppl; p += 2){ /* first pixel */ db[pos] = sb[0]; if (++pos >= rb->size) pos = 0; /* watch out for ringbuff end? */ db[pos] = sb[2]; if (++pos >= rb->size) pos = 0; db[pos] = sb[4]; if (++pos >= rb->size) pos = 0; /* second pixel */ db[pos] = sb[1]; if (++pos >= rb->size) pos = 0; db[pos] = sb[3]; if (++pos >= rb->size) pos = 0; db[pos] = sb[5]; if (++pos >= rb->size) pos = 0; sb += 6; } } } rb->complete_count += length; return SANE_STATUS_GOOD; } /********************************************************************/ /********************************************************************/ /***** the basic scanning chunks for sane_read() *****/ /********************************************************************/ /********************************************************************/ /********************************************************************/ /* Request bytes from scanner (and put in scsi_buffer) */ /********************************************************************/ static SANE_Status read_from_scanner (Microtek_Scanner *s, int *nlines) { SANE_Status status; SANE_Int busy, linewidth, remaining; size_t buffsize; DBG(23, "read_from_scanner...\n"); if (s->unscanned_lines > 0) { status = get_scan_status(s, &busy, &linewidth, &remaining); if (status != SANE_STATUS_GOOD) { DBG(18, "read_from_scanner: bad get_scan_status!\n"); return status; } DBG(18, "read_from_scanner: gss busy, linewidth, remaining: %d, %d, %d\n", busy, linewidth, remaining); } else { DBG(18, "read_from_scanner: no gss/no unscanned\n"); remaining = 0; } *nlines = MIN(remaining, s->max_scsi_lines); DBG(18, "sane_read: max_scsi: %d, rem: %d, nlines: %d\n", s->max_scsi_lines, remaining, *nlines); /* grab them bytes! (only if the scanner still has bytes to give...) */ if (*nlines > 0) { buffsize = *nlines * (s->pixel_bpl + s->header_bpl);/* == "* linewidth" */ status = read_scan_data(s, *nlines, s->scsi_buffer, &buffsize); if (status != SANE_STATUS_GOOD) { DBG(18, "sane_read: bad read_scan_data!\n"); return status; } s->unscanned_lines -= *nlines; DBG(18, "sane_read: buffsize: %lu, unscanned: %d\n", (u_long) buffsize, s->unscanned_lines); } return SANE_STATUS_GOOD; } /********************************************************************/ /* Process scanner bytes, and shove in ring_buffer */ /********************************************************************/ static SANE_Status pack_into_ring(Microtek_Scanner *s, int nlines) { SANE_Status status; DBG(23, "pack_into_ring...\n"); switch (s->line_format) { case MS_LNFMT_FLAT: status = pack_flat_data(s, nlines); break; case MS_LNFMT_SEQ_RGB: status = pack_seqrgb_data(s, nlines); break; case MS_LNFMT_GOOFY_RGB: status = pack_goofyrgb_data(s, nlines); break; case MS_LNFMT_SEQ_2R2G2B: status = pack_seq2r2g2b_data(s, nlines); break; default: status = SANE_STATUS_JAMMED; } return status; } /********************************************************************/ /* Pack processed image bytes into frontend destination buffer */ /********************************************************************/ static SANE_Int pack_into_dest(SANE_Byte *dest_buffer, size_t dest_length, ring_buffer *rb) { size_t ret_length = MIN(rb->complete_count, dest_length); DBG(23, "pack_into_dest...\n"); DBG(23, "pack_into_dest: rl: %lu sz: %lu hc: %lu\n", (u_long)ret_length, (u_long)rb->size, (u_long)rb->head_complete); /* adjust for rollover!!! */ if ((rb->head_complete + ret_length) < rb->size) { memcpy(dest_buffer, rb->base + rb->head_complete, ret_length); rb->head_complete += ret_length; } else { size_t chunk1 = rb->size - rb->head_complete; size_t chunk2 = ret_length - chunk1; memcpy(dest_buffer, rb->base + rb->head_complete, chunk1); memcpy(dest_buffer + chunk1, rb->base, chunk2); rb->head_complete = chunk2; } rb->complete_count -= ret_length; return ret_length; } /********************************************************************/ /********************************************************************/ /****** "Registered" SANE API Functions *****************************/ /********************************************************************/ /********************************************************************/ /********************************************************************/ /* sane_init() */ /********************************************************************/ SANE_Status sane_init(SANE_Int *version_code, SANE_Auth_Callback authorize) { char dev_name[PATH_MAX]; size_t len; FILE *fp; authorize = authorize; DBG_INIT(); DBG(1, "sane_init: MICROTEK says hello! (v%d.%d.%d)\n", MICROTEK_MAJOR, MICROTEK_MINOR, MICROTEK_PATCH); /* return the SANE version we got compiled under */ if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); /* parse config file */ fp = sanei_config_open (MICROTEK_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ DBG(1, "sane_init: missing config file '%s'\n", MICROTEK_CONFIG_FILE); attach_scanner("/dev/scanner", 0); return SANE_STATUS_GOOD; } while (sanei_config_read(dev_name, sizeof (dev_name), fp)) { DBG(23, "sane_init: config-> %s\n", dev_name); if (dev_name[0] == '#') continue; /* ignore comments */ if (!(strncmp("noprecal", dev_name, 8))) { DBG(23, "sane_init: Clever Precalibration will be forcibly disabled...\n"); inhibit_clever_precal = SANE_TRUE; continue; } if (!(strncmp("norealcal", dev_name, 9))) { DBG(23, "sane_init: Real calibration will be forcibly disabled...\n"); inhibit_real_calib = SANE_TRUE; continue; } len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ sanei_config_attach_matching_devices (dev_name, attach_one); } fclose (fp); return SANE_STATUS_GOOD; } /********************************************************************/ /* sane_get_devices */ /********************************************************************/ SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only) { Microtek_Device *dev; int i; local_only = local_only; DBG(10, "sane_get_devices\n"); /* we keep an internal copy */ if (devlist) free(devlist); /* hmm, free it if we want a new one, I guess. YYYYY*/ devlist = malloc((num_devices + 1) * sizeof(devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; for (i=0, dev=first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } /********************************************************************/ /* sane_open */ /********************************************************************/ SANE_Status sane_open(SANE_String_Const devicename, SANE_Handle *handle) { Microtek_Scanner *scanner; Microtek_Device *dev; SANE_Status status; DBG(10, "sane_open\n"); /* find device... */ DBG(23, "sane_open: find device...\n"); if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) { if (strcmp(dev->sane.name, devicename) == 0) break; } if (!dev) { /* not in list, try manually... */ status = attach_scanner(devicename, &dev); if (status != SANE_STATUS_GOOD) return status; } } else { /* no device specified, so use first */ dev = first_dev; } if (!dev) return SANE_STATUS_INVAL; /* create a scanner... */ DBG(23, "sane_open: create scanner...\n"); scanner = malloc(sizeof(*scanner)); if (!scanner) return SANE_STATUS_NO_MEM; memset(scanner, 0, sizeof(*scanner)); /* initialize scanner dependent stuff */ DBG(23, "sane_open: initialize scanner dependent stuff...\n"); /* ZZZZZZZZZZZZZZ */ scanner->unit_type = (dev->info.unit_type & MI_UNIT_PIXELS) ? MS_UNIT_PIXELS : MS_UNIT_18INCH; scanner->res_type = (dev->info.res_step & MI_RESSTEP_1PER) ? MS_RES_1PER : MS_RES_5PER; scanner->midtone_support = (dev->info.enhance_cap & MI_ENH_CAP_MIDTONE) ? SANE_TRUE : SANE_FALSE; scanner->paper_length = (scanner->unit_type == MS_UNIT_PIXELS) ? dev->info.max_y : (SANE_Int)((double)dev->info.max_y * 8.0 / (double)dev->info.base_resolution); /* (SANE_Int)(SANE_UNFIX(dev->info.max_y) * dev->info.base_resolution) : (SANE_Int)(SANE_UNFIX(dev->info.max_y) * 8); ZZZZZZZ */ scanner->bright_r = 0; scanner->bright_g = 0; scanner->bright_b = 0; /* calibration shenanigans */ if ((dev->info.extra_cap & MI_EXCAP_DIS_RECAL) && (!(inhibit_real_calib))) { DBG(23, "sane_open: Real calibration enabled.\n"); scanner->allow_calibrate = SANE_FALSE; scanner->do_real_calib = SANE_TRUE; scanner->do_clever_precal = SANE_FALSE; } else if ((dev->info.extra_cap & MI_EXCAP_DIS_RECAL) && (!(inhibit_clever_precal))) { DBG(23, "sane_open: Clever precalibration enabled.\n"); scanner->allow_calibrate = SANE_FALSE; scanner->do_real_calib = SANE_FALSE; scanner->do_clever_precal = SANE_TRUE; } else { DBG(23, "sane_open: All calibration routines disabled.\n"); scanner->allow_calibrate = SANE_TRUE; scanner->do_real_calib = SANE_FALSE; scanner->do_clever_precal = SANE_FALSE; } scanner->onepass = (dev->info.modes & MI_MODES_ONEPASS); scanner->allowbacktrack = SANE_TRUE; /* ??? XXXXXXX */ scanner->reversecolors = SANE_FALSE; scanner->fastprescan = SANE_FALSE; scanner->bits_per_color = 8; /* init gamma tables */ if (dev->info.max_lookup_size) { int j, v, max_entry; DBG(23, "sane_open: init gamma tables...\n"); scanner->gamma_entries = dev->info.max_lookup_size; scanner->gamma_entry_size = dev->info.gamma_size; scanner->gamma_bit_depth = dev->info.max_gamma_bit_depth; max_entry = (1 << scanner->gamma_bit_depth) - 1; scanner->gamma_entry_range.min = 0; scanner->gamma_entry_range.max = max_entry; scanner->gamma_entry_range.quant = 1; scanner->gray_lut = calloc(scanner->gamma_entries, sizeof(scanner->gray_lut[0])); scanner->red_lut = calloc(scanner->gamma_entries, sizeof(scanner->red_lut[0])); scanner->green_lut = calloc(scanner->gamma_entries, sizeof(scanner->green_lut[0])); scanner->blue_lut = calloc(scanner->gamma_entries, sizeof(scanner->blue_lut[0])); if ((scanner->gray_lut == NULL) || (scanner->red_lut == NULL) || (scanner->green_lut == NULL) || (scanner->blue_lut == NULL)) { DBG(23, "sane_open: unable to allocate space for %d-entry LUT's;\n", scanner->gamma_entries); DBG(23, " so, gamma tables now DISABLED.\n"); free(scanner->gray_lut); free(scanner->red_lut); free(scanner->green_lut); free(scanner->blue_lut); } for (j=0; jgamma_entries; j += scanner->gamma_entry_size) { v = (SANE_Int) ((double) j * (double) max_entry / ((double) scanner->gamma_entries - 1.0) + 0.5); scanner->gray_lut[j] = v; scanner->red_lut[j] = v; scanner->green_lut[j] = v; scanner->blue_lut[j] = v; } } else { DBG(23, "sane_open: NO gamma tables. (max size = %lu)\n", (u_long)dev->info.max_lookup_size); scanner->gamma_entries = 0; scanner->gray_lut = NULL; scanner->red_lut = NULL; scanner->green_lut = NULL; scanner->blue_lut = NULL; } DBG(23, "sane_open: init pass-time variables...\n"); scanner->scanning = SANE_FALSE; scanner->this_pass = 0; scanner->sfd = -1; scanner->dev = dev; scanner->sense_flags = 0; scanner->scan_started = SANE_FALSE; scanner->woe = SANE_FALSE; scanner->cancel = SANE_FALSE; DBG(23, "sane_open: init clever cache...\n"); /* clear out that clever cache, so it doesn't match anything */ { int j; for (j=0; j<10; j++) scanner->mode_sense_cache[j] = 0; scanner->precal_record = MS_PRECAL_NONE; } DBG(23, "sane_open: initialize options: \n"); if ((status = init_options(scanner)) != SANE_STATUS_GOOD) return status; scanner->next = first_handle; first_handle = scanner; *handle = scanner; return SANE_STATUS_GOOD; } /********************************************************************/ /* sane_close */ /********************************************************************/ void sane_close (SANE_Handle handle) { Microtek_Scanner *ms = handle; DBG(10, "sane_close...\n"); /* free malloc'ed stuff (strdup counts too!) */ free((void *) ms->sod[OPT_MODE].constraint.string_list); free((void *) ms->sod[OPT_SOURCE].constraint.string_list); free(ms->val[OPT_MODE].s); free(ms->val[OPT_HALFTONE_PATTERN].s); free(ms->val[OPT_SOURCE].s); free(ms->val[OPT_CUSTOM_GAMMA].s); free(ms->gray_lut); free(ms->red_lut); free(ms->green_lut); free(ms->blue_lut); /* remove Scanner from linked list */ if (first_handle == ms) first_handle = ms->next; else { Microtek_Scanner *ts = first_handle; while ((ts != NULL) && (ts->next != ms)) ts = ts->next; ts->next = ts->next->next; /* == ms->next */ } /* finally, say goodbye to the Scanner */ free(ms); } /********************************************************************/ /* sane_get_option_descriptor */ /********************************************************************/ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Microtek_Scanner *scanner = handle; DBG(96, "sane_get_option_descriptor (%d)...\n", option); if ((unsigned)option >= NUM_OPTIONS) return NULL; return &(scanner->sod[option]); } /********************************************************************/ /* sane_control_option */ /********************************************************************/ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int *info) { Microtek_Scanner *scanner = handle; SANE_Option_Descriptor *sod; Option_Value *val; SANE_Status status; DBG(96, "sane_control_option (opt=%d,act=%d,val=%p,info=%p)\n", option, action, value, (void*) info); sod = scanner->sod; val = scanner->val; /* no changes while in mid-pass! */ if (scanner->scanning) return SANE_STATUS_DEVICE_BUSY; /* and... no changes while in middle of three-pass series! */ if (scanner->this_pass != 0) return SANE_STATUS_DEVICE_BUSY; if ( ((option >= NUM_OPTIONS) || (option < 0)) || (!SANE_OPTION_IS_ACTIVE(scanner->sod[option].cap)) ) return SANE_STATUS_INVAL; if (info) *info = 0; /* choose by action */ switch (action) { case SANE_ACTION_GET_VALUE: switch (option) { /* word options... */ case OPT_RESOLUTION: case OPT_SPEED: case OPT_BACKTRACK: case OPT_NEGATIVE: case OPT_PREVIEW: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_EXPOSURE: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_HIGHLIGHT: case OPT_SHADOW: case OPT_MIDTONE: case OPT_GAMMA_BIND: case OPT_ANALOG_GAMMA: case OPT_ANALOG_GAMMA_R: case OPT_ANALOG_GAMMA_G: case OPT_ANALOG_GAMMA_B: case OPT_EXP_RES: case OPT_CALIB_ONCE: *(SANE_Word *)value = val[option].w; return SANE_STATUS_GOOD; /* word-array options... */ /* case OPT_HALFTONE_PATTERN:*/ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy(value, val[option].wa, sod[option].size); return SANE_STATUS_GOOD; /* string options... */ case OPT_MODE: case OPT_HALFTONE_PATTERN: case OPT_CUSTOM_GAMMA: case OPT_SOURCE: strcpy(value, val[option].s); return SANE_STATUS_GOOD; /* others.... */ case OPT_NUM_OPTS: *(SANE_Word *) value = NUM_OPTIONS; return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_VALUE: { status = sanei_constrain_value(sod + option, value, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { /* set word options... */ case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_RESOLUTION: if (info) *info |= SANE_INFO_RELOAD_PARAMS; // fall through case OPT_SPEED: case OPT_PREVIEW: case OPT_BACKTRACK: case OPT_NEGATIVE: case OPT_EXPOSURE: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_ANALOG_GAMMA: case OPT_ANALOG_GAMMA_R: case OPT_ANALOG_GAMMA_G: case OPT_ANALOG_GAMMA_B: val[option].w = *(SANE_Word *)value; return SANE_STATUS_GOOD; case OPT_HIGHLIGHT: case OPT_SHADOW: case OPT_MIDTONE: val[option].w = *(SANE_Word *)value; /* we need to (silently) make sure shadow <= midtone <= highlight */ if (scanner->midtone_support) { if (val[OPT_SHADOW].w > val[OPT_MIDTONE].w) { if (option == OPT_SHADOW) val[OPT_SHADOW].w = val[OPT_MIDTONE].w; else val[OPT_MIDTONE].w = val[OPT_SHADOW].w; } if (val[OPT_HIGHLIGHT].w < val[OPT_MIDTONE].w) { if (option == OPT_HIGHLIGHT) val[OPT_HIGHLIGHT].w = val[OPT_MIDTONE].w; else val[OPT_MIDTONE].w = val[OPT_HIGHLIGHT].w; } } else { if (val[OPT_SHADOW].w > val[OPT_HIGHLIGHT].w) { if (option == OPT_SHADOW) val[OPT_SHADOW].w = val[OPT_HIGHLIGHT].w; else val[OPT_HIGHLIGHT].w = val[OPT_SHADOW].w; } } return SANE_STATUS_GOOD; case OPT_EXP_RES: if (val[option].w != *(SANE_Word *) value) { val[option].w = *(SANE_Word *)value; if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; if (val[OPT_EXP_RES].w) { sod[OPT_RESOLUTION].constraint.range = &(scanner->exp_res_range); val[OPT_RESOLUTION].w *= 2; } else { sod[OPT_RESOLUTION].constraint.range = &(scanner->res_range); val[OPT_RESOLUTION].w /= 2; } } return SANE_STATUS_GOOD; case OPT_CALIB_ONCE: val[option].w = *(SANE_Word *)value; /* toggling off and on should force a recalibration... */ if (!(val[option].w)) scanner->precal_record = MS_PRECAL_NONE; return SANE_STATUS_GOOD; case OPT_GAMMA_BIND: case OPT_CUSTOM_GAMMA: if (option == OPT_GAMMA_BIND) { if (val[option].w != *(SANE_Word *) value) if (info) *info |= SANE_INFO_RELOAD_OPTIONS; val[option].w = *(SANE_Word *) value; } else if (option == OPT_CUSTOM_GAMMA) { if (val[option].s) { if (strcmp(value, val[option].s)) if (info) *info |= SANE_INFO_RELOAD_OPTIONS; free(val[option].s); } val[option].s = strdup(value); } if ( !(strcmp(val[OPT_CUSTOM_GAMMA].s, M_NONE)) || !(strcmp(val[OPT_CUSTOM_GAMMA].s, M_SCALAR)) ) { sod[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } if ( !(strcmp(val[OPT_CUSTOM_GAMMA].s, M_NONE)) || !(strcmp(val[OPT_CUSTOM_GAMMA].s, M_TABLE)) ) { sod[OPT_ANALOG_GAMMA].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_R].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_G].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_B].cap |= SANE_CAP_INACTIVE; } if (!(strcmp(val[OPT_CUSTOM_GAMMA].s, M_SCALAR))) { if (val[OPT_GAMMA_BIND].w == SANE_TRUE) { sod[OPT_ANALOG_GAMMA].cap &= ~SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_R].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_G].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_B].cap |= SANE_CAP_INACTIVE; } else { sod[OPT_ANALOG_GAMMA].cap |= SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_ANALOG_GAMMA_B].cap &= ~SANE_CAP_INACTIVE; } } if (!(strcmp(val[OPT_CUSTOM_GAMMA].s, M_TABLE))) { if (val[OPT_GAMMA_BIND].w == SANE_TRUE) { sod[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } else { sod[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; sod[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } if (!(strcmp(val[OPT_CUSTOM_GAMMA].s, M_NONE))) sod[OPT_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; else if (!(strcmp(val[OPT_MODE].s, M_COLOR))) sod[OPT_GAMMA_BIND].cap &= ~SANE_CAP_INACTIVE; return SANE_STATUS_GOOD; case OPT_MODE: if (val[option].s) { if (strcmp(val[option].s, value)) if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; free(val[option].s); } val[option].s = strdup(value); if (strcmp(val[option].s, M_HALFTONE)) { sod[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; } else { sod[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; } if (strcmp(val[option].s, M_COLOR)) { /* not color */ /*val[OPT_GAMMA_BIND].w = SANE_TRUE;*/ DBG(23, "FLIP ma LID! bind is %d\n", val[OPT_GAMMA_BIND].w); { SANE_Bool Trueness = SANE_TRUE; SANE_Status status; status = sane_control_option(handle, OPT_GAMMA_BIND, SANE_ACTION_SET_VALUE, &Trueness, NULL); DBG(23, "stat is: %d\n", status); } DBG(23, "LID be FLIPPED! bind is %d\n", val[OPT_GAMMA_BIND].w); sod[OPT_GAMMA_BIND].cap |= SANE_CAP_INACTIVE; /* sod[OPT_FORCE_3PASS].cap |= SANE_CAP_INACTIVE;*/ } else { sod[OPT_GAMMA_BIND].cap &= ~SANE_CAP_INACTIVE; /* if (scanner->dev->info.modes & MI_MODES_ONEPASS) sod[OPT_FORCE_3PASS].cap &= ~SANE_CAP_INACTIVE;*/ } return SANE_STATUS_GOOD; case OPT_HALFTONE_PATTERN: case OPT_SOURCE: if (val[option].s) free(val[option].s); val[option].s = strdup(value); return SANE_STATUS_GOOD; case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy(val[option].wa, value, sod[option].size); return SANE_STATUS_GOOD; default: return SANE_STATUS_INVAL; } } break; case SANE_ACTION_SET_AUTO: return SANE_STATUS_UNSUPPORTED; /* We are DUMB. */ } return SANE_STATUS_GOOD; } /********************************************************************/ /* sane_get_parameters */ /********************************************************************/ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters *params) { Microtek_Scanner *s = handle; DBG(23, "sane_get_parameters...\n"); if (!s->scanning) { /* decipher scan mode */ if (!(strcmp(s->val[OPT_MODE].s, M_LINEART))) s->mode = MS_MODE_LINEART; else if (!(strcmp(s->val[OPT_MODE].s, M_HALFTONE))) s->mode = MS_MODE_HALFTONE; else if (!(strcmp(s->val[OPT_MODE].s, M_GRAY))) s->mode = MS_MODE_GRAY; else if (!(strcmp(s->val[OPT_MODE].s, M_COLOR))) s->mode = MS_MODE_COLOR; if (s->mode == MS_MODE_COLOR) { if (s->onepass) { /* regular one-pass */ DBG(23, "sane_get_parameters: regular 1-pass color\n"); s->threepasscolor = SANE_FALSE; s->onepasscolor = SANE_TRUE; s->color_seq = s->dev->info.color_sequence; } else { /* 3-pass scanner */ DBG(23, "sane_get_parameters: regular 3-pass color\n"); s->threepasscolor = SANE_TRUE; s->onepasscolor = SANE_FALSE; s->color_seq = s->dev->info.color_sequence; } } else { /* not color! */ DBG(23, "sane_get_parameters: non-color\n"); s->threepasscolor = SANE_FALSE; s->onepasscolor = SANE_FALSE; s->color_seq = s->dev->info.color_sequence; } s->transparency = !(strcmp(s->val[OPT_SOURCE].s, M_TRANS)); s->useADF = !(strcmp(s->val[OPT_SOURCE].s, M_AUTOFEED)); /* disallow exp. res. during preview scan XXXXXXXXXXX */ /*s->expandedresolution = (s->val[OPT_EXP_RES].w) && !(s->val[OPT_PREVIEW].w);*/ s->expandedresolution = (s->val[OPT_EXP_RES].w); s->doexpansion = (s->expandedresolution && !(s->dev->info.does_expansion)); if (s->res_type == MS_RES_1PER) { s->resolution = (SANE_Int)(SANE_UNFIX(s->val[OPT_RESOLUTION].w)); s->resolution_code = 0xFF & ((s->resolution * 100) / s->dev->info.base_resolution / (s->expandedresolution ? 2 : 1)); DBG(23, "sane_get_parameters: res_code = %d (%2x)\n", s->resolution_code, s->resolution_code); } else { DBG(23, "sane_get_parameters: 5 percent!!!\n"); /* XXXXXXXXXXXXX */ } s->calib_once = s->val[OPT_CALIB_ONCE].w; s->reversecolors = s->val[OPT_NEGATIVE].w; s->prescan = s->val[OPT_PREVIEW].w; s->exposure = (s->val[OPT_EXPOSURE].w / 3) + 7; s->contrast = (s->val[OPT_CONTRAST].w / 7) + 7; s->velocity = s->val[OPT_SPEED].w; s->shadow = s->val[OPT_SHADOW].w; s->highlight = s->val[OPT_HIGHLIGHT].w; s->midtone = s->val[OPT_MIDTONE].w; if (SANE_OPTION_IS_ACTIVE(s->sod[OPT_BRIGHTNESS].cap)) { #if 1 /* this is _not_ what the docs specify! */ if (s->val[OPT_BRIGHTNESS].w >= 0) s->bright_r = (SANE_Byte) (s->val[OPT_BRIGHTNESS].w); else s->bright_r = (SANE_Byte) (0x80 | (- s->val[OPT_BRIGHTNESS].w)); #else s->bright_r = (SANE_Byte) (s->val[OPT_BRIGHTNESS].w); #endif s->bright_g = s->bright_b = s->bright_r; DBG(23, "bright_r of %d set to 0x%0x\n", s->val[OPT_BRIGHTNESS].w, s->bright_r); } else { s->bright_r = s->bright_g = s->bright_b = 0; } /* figure out halftone pattern selection... */ if (s->mode == MS_MODE_HALFTONE) { int i = 0; while ((halftone_mode_list[i] != NULL) && (strcmp(halftone_mode_list[i], s->val[OPT_HALFTONE_PATTERN].s))) i++; s->pattern = ((i < s->dev->info.pattern_count) ? i : 0); } else s->pattern = 0; { /* need to 'round' things properly! XXXXXXXX */ SANE_Int widthpix; double dots_per_mm = s->resolution / MM_PER_INCH; double units_per_mm = (s->unit_type == MS_UNIT_18INCH) ? (8.0 / MM_PER_INCH) : /* 1/8 inches */ (s->dev->info.base_resolution / MM_PER_INCH); /* pixels */ DBG(23, "sane_get_parameters: dots_per_mm: %f\n", dots_per_mm); DBG(23, "sane_get_parameters: units_per_mm: %f\n", units_per_mm); /* calculate frame coordinates... * scanner coords are in 'units' -- pixels or 1/8" * option coords are MM */ s->x1 = (SANE_Int)(SANE_UNFIX(s->val[OPT_TL_X].w) * units_per_mm + 0.5); s->y1 = (SANE_Int)(SANE_UNFIX(s->val[OPT_TL_Y].w) * units_per_mm + 0.5); s->x2 = (SANE_Int)(SANE_UNFIX(s->val[OPT_BR_X].w) * units_per_mm + 0.5); s->y2 = (SANE_Int)(SANE_UNFIX(s->val[OPT_BR_Y].w) * units_per_mm + 0.5); /* bug out if length or width is <= zero... */ if ((s->x1 >= s->x2) || (s->y1 >= s->y2)) return SANE_STATUS_INVAL; /* these are just an estimate... (but *should* be completely accurate) * real values come from scanner after sane_start. */ if (s->unit_type == MS_UNIT_18INCH) { /* who *knows* what happens */ widthpix = (SANE_Int)((double)(s->x2 - s->x1 + 1) / 8.0 * (double)s->resolution); s->params.lines = (SANE_Int)((double)(s->y2 - s->y1 + 1) / 8.0 * (double)s->resolution); } else { /* calculate pixels per scanline returned by scanner... */ /* scanner (E6 at least) always seems to return an -even- number of -bytes- */ if (s->resolution <= s->dev->info.base_resolution) widthpix = (SANE_Int)((double)(s->x2 - s->x1 + 1) * (double)(s->resolution) / (double)(s->dev->info.base_resolution)); else widthpix = (s->x2 - s->x1 + 1); if ((s->mode == MS_MODE_LINEART) || (s->mode == MS_MODE_HALFTONE)) { DBG(23, "WIDTHPIX: before: %d", widthpix); widthpix = ((widthpix / 8) & ~0x1) * 8; DBG(23, "after: %d", widthpix); } else { widthpix = widthpix & ~0x1; } DBG(23, "WIDTHPIX: before exp: %d\n", widthpix); /* ok, now fix up expanded-mode conversions */ if (s->resolution > s->dev->info.base_resolution) widthpix = (SANE_Int) ((double)widthpix * (double)s->resolution / (double)s->dev->info.base_resolution); s->params.pixels_per_line = widthpix; s->params.lines = (SANE_Int)((double)(s->y2 - s->y1 + 1) * (double)(s->resolution) / (double)(s->dev->info.base_resolution)); } } switch (s->mode) { case MS_MODE_LINEART: case MS_MODE_HALFTONE: s->multibit = SANE_FALSE; s->params.format = SANE_FRAME_GRAY; s->params.depth = 1; s->filter = MS_FILT_CLEAR; s->params.bytes_per_line = s->params.pixels_per_line / 8; break; case MS_MODE_GRAY: s->multibit = SANE_TRUE; s->params.format = SANE_FRAME_GRAY; s->params.depth = s->bits_per_color; s->filter = MS_FILT_CLEAR; s->params.bytes_per_line = s->params.pixels_per_line; break; case MS_MODE_COLOR: s->multibit = SANE_TRUE; if (s->onepasscolor) { /* a single-pass color scan */ s->params.format = SANE_FRAME_RGB; s->params.depth = s->bits_per_color; s->filter = MS_FILT_CLEAR; s->params.bytes_per_line = s->params.pixels_per_line * 3; } else { /* a three-pass color scan */ s->params.depth = s->bits_per_color; /* this will be correctly set in sane_start */ s->params.format = SANE_FRAME_RED; s->params.bytes_per_line = s->params.pixels_per_line; } break; } DBG(23, "sane_get_parameters: lines: %d ppl: %d bpl: %d\n", s->params.lines, s->params.pixels_per_line, s->params.bytes_per_line); /* also fixed in sane_start for multi-pass scans */ s->params.last_frame = SANE_TRUE; /* ?? XXXXXXXX */ } if (params) *params = s->params; return SANE_STATUS_GOOD; } /********************************************************************/ /* sane_start */ /********************************************************************/ static SANE_Status sane_start_guts (SANE_Handle handle) { Microtek_Scanner *s = handle; SANE_Status status; SANE_Int busy, linewidth; DBG(10, "sane_start...\n"); if (s->sfd != -1) { DBG(23, "sane_start: sfd already set!\n"); return SANE_STATUS_DEVICE_BUSY; } if ((status = sane_get_parameters(s, 0)) != SANE_STATUS_GOOD) return end_scan(s, status); set_pass_parameters(s); s->scanning = SANE_TRUE; s->cancel = SANE_FALSE; status = sanei_scsi_open(s->dev->sane.name, &(s->sfd), sense_handler, &(s->sense_flags)); if (status != SANE_STATUS_GOOD) { DBG(10, "sane_start: open of %s failed: %s\n", s->dev->sane.name, sane_strstatus (status)); s->sfd = -1; return end_scan(s, status); } if ((status = wait_ready(s)) != SANE_STATUS_GOOD) return end_scan(s, status); if ((status = finagle_precal(s)) != SANE_STATUS_GOOD) return end_scan(s, status); if ((status = scanning_frame(s)) != SANE_STATUS_GOOD) return end_scan(s, status); if (s->dev->info.source_options & (MI_SRC_FEED_BT | MI_SRC_HAS_TRANS | MI_SRC_FEED_SUPP | MI_SRC_HAS_FEED)) { /* ZZZZZZZZZZZ */ if ((status = accessory(s)) != SANE_STATUS_GOOD) return end_scan(s, status); /* if SWslct ???? XXXXXXXXXXXXXXX */ } if ((status = download_gamma(s)) != SANE_STATUS_GOOD) return end_scan(s, status); if ((status = mode_select(s)) != SANE_STATUS_GOOD) return end_scan(s, status); if (s->dev->info.does_mode1) { if ((status = mode_select_1(s)) != SANE_STATUS_GOOD) return end_scan(s, status); } if ((s->do_clever_precal) || (s->do_real_calib)) { if ((status = save_mode_sense(s)) != SANE_STATUS_GOOD) return end_scan(s, status); } if ((status = wait_ready(s)) != SANE_STATUS_GOOD) return end_scan(s, status); s->scan_started = SANE_TRUE; if ((status = start_scan(s)) != SANE_STATUS_GOOD) return end_scan(s, status); if ((status = get_scan_status(s, &busy, &linewidth, &(s->unscanned_lines))) != SANE_STATUS_GOOD) { DBG(10, "sane_start: get_scan_status fails\n"); return end_scan(s, status); } /* check for a bizarre linecount */ if ((s->unscanned_lines < 0) || (s->unscanned_lines > (s->params.lines * 2 * (s->expandedresolution ? 2 : 1)))) { DBG(10, "sane_start: get_scan_status returns weird line count %d\n", s->unscanned_lines); return end_scan(s, SANE_STATUS_DEVICE_BUSY); } /* figure out image format parameters */ switch (s->mode) { case MS_MODE_LINEART: case MS_MODE_HALFTONE: s->pixel_bpl = linewidth; s->header_bpl = 0; s->ppl = linewidth * 8; s->planes = 1; s->line_format = MS_LNFMT_FLAT; break; case MS_MODE_GRAY: if (s->bits_per_color < 8) { s->pixel_bpl = linewidth; s->ppl = linewidth * (8 / s->bits_per_color); } else { s->pixel_bpl = linewidth * ((s->bits_per_color + 7) / 8); s->ppl = linewidth; } s->header_bpl = 0; s->planes = 1; s->line_format = MS_LNFMT_FLAT; break; case MS_MODE_COLOR: switch (s->color_seq) { case MI_COLSEQ_PLANE: s->pixel_bpl = linewidth * ((s->bits_per_color + 7) / 8); s->ppl = linewidth; s->header_bpl = 0; s->planes = 1; s->line_format = MS_LNFMT_FLAT; break; case MI_COLSEQ_NONRGB: s->pixel_bpl = (linewidth - 2) * 3 * ((s->bits_per_color + 7) / 8); s->ppl = linewidth - 2; s->header_bpl = 2 * 3; s->planes = 3; s->line_format = MS_LNFMT_GOOFY_RGB; break; case MI_COLSEQ_PIXEL: s->pixel_bpl = linewidth * 3 * ((s->bits_per_color + 7) / 8); s->ppl = linewidth; s->header_bpl = 0; s->planes = 3; s->line_format = MS_LNFMT_FLAT; break; case MI_COLSEQ_2PIXEL: s->pixel_bpl = linewidth * 3 * ((s->bits_per_color + 7) / 8); s->ppl = linewidth; s->header_bpl = 0; s->planes = 3; s->line_format = MS_LNFMT_SEQ_2R2G2B; break; case MI_COLSEQ_RGB: s->pixel_bpl = linewidth * 3 * ((s->bits_per_color + 7) / 8); s->ppl = linewidth; s->header_bpl = 0; s->planes = 3; s->line_format = MS_LNFMT_SEQ_RGB; break; default: DBG(10, "sane_start: Unknown color_sequence: %d\n", s->dev->info.color_sequence); return end_scan(s, SANE_STATUS_INVAL); } break; default: DBG(10, "sane_start: Unknown scan mode: %d\n", s->mode); return end_scan(s, SANE_STATUS_INVAL); } if ((s->doexpansion) && (s->resolution > s->dev->info.base_resolution)) { s->dest_ppl = (int) ((double)s->ppl * (double)s->resolution / (double)s->dev->info.base_resolution); /*+ 0.5 XXXXXX */ s->exp_aspect = (double)s->ppl / (double)s->dest_ppl; s->dest_pixel_bpl = (int) ceil((double)s->pixel_bpl / s->exp_aspect); /*s->exp_aspect = (double) s->dev->info.base_resolution / (double) s->resolution;*/ /* s->dest_pixel_bpl = s->pixel_bpl / s->exp_aspect; s->dest_ppl = s->ppl / s->exp_aspect;*/ /*s->dest_ppl = s->ppl / s->exp_aspect; s->dest_pixel_bpl = (int) ceil((double)s->dest_ppl * (double)s->pixel_bpl / (double)s->ppl);*/ } else { s->exp_aspect = 1.0; s->dest_pixel_bpl = s->pixel_bpl; s->dest_ppl = s->ppl; } s->params.lines = s->unscanned_lines; s->params.pixels_per_line = s->dest_ppl; s->params.bytes_per_line = s->dest_pixel_bpl; /* calculate maximum line capacity of SCSI buffer */ s->max_scsi_lines = SCSI_BUFF_SIZE / (s->pixel_bpl + s->header_bpl); if (s->max_scsi_lines < 1) { DBG(10, "sane_start: SCSI buffer smaller that one scan line!\n"); return end_scan(s, SANE_STATUS_NO_MEM); } s->scsi_buffer = (uint8_t *) malloc(SCSI_BUFF_SIZE * sizeof(uint8_t)); if (s->scsi_buffer == NULL) return SANE_STATUS_NO_MEM; /* what's a good initial size for this? */ s->rb = ring_alloc(s->max_scsi_lines * s->dest_pixel_bpl, s->dest_pixel_bpl, s->dest_ppl); s->undelivered_bytes = s->unscanned_lines * s->dest_pixel_bpl; DBG(23, "Scan Param:\n"); DBG(23, "pix bpl: %d hdr bpl: %d ppl: %d\n", s->pixel_bpl, s->header_bpl, s->ppl); DBG(23, "undel bytes: %d unscan lines: %d planes: %d\n", s->undelivered_bytes, s->unscanned_lines, s->planes); DBG(23, "dest bpl: %d dest ppl: %d aspect: %f\n", s->dest_pixel_bpl, s->dest_ppl, s->exp_aspect); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Microtek_Scanner *s = handle; SANE_Status status; s->woe = SANE_TRUE; status = sane_start_guts(handle); s->woe = SANE_FALSE; return status; } /********************************************************************/ /* sane_read */ /********************************************************************/ static SANE_Status sane_read_guts (SANE_Handle handle, SANE_Byte *dest_buffer, SANE_Int dest_length, SANE_Int *ret_length) { Microtek_Scanner *s = handle; SANE_Status status; int nlines; ring_buffer *rb = s->rb; DBG(10, "sane_read...\n"); *ret_length = 0; /* default: no data */ /* we have been cancelled... */ if (s->cancel) return end_scan(s, SANE_STATUS_CANCELLED); /* we're not really scanning!... */ if (!(s->scanning)) return SANE_STATUS_INVAL; /* we are done scanning... */ if (s->undelivered_bytes <= 0) return end_scan(s, SANE_STATUS_EOF); /* get more bytes if our ring is empty... */ while (rb->complete_count == 0) { if ((status = read_from_scanner(s, &nlines)) != SANE_STATUS_GOOD) { DBG(18, "sane_read: read_from_scanner failed.\n"); return end_scan(s, status); } if ((status = pack_into_ring(s, nlines)) != SANE_STATUS_GOOD) { DBG(18, "sane_read: pack_into_ring failed.\n"); return end_scan(s, status); } } /* return some data to caller */ *ret_length = pack_into_dest(dest_buffer, dest_length, rb); s->undelivered_bytes -= *ret_length; if (s->cancel) return end_scan(s, SANE_STATUS_CANCELLED); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte *dest_buffer, SANE_Int dest_length, SANE_Int *ret_length) { Microtek_Scanner *s = handle; SANE_Status status; s->woe = SANE_TRUE; status = sane_read_guts(handle, dest_buffer, dest_length, ret_length); s->woe = SANE_FALSE; return status; } /********************************************************************/ /* sane_exit */ /********************************************************************/ void sane_exit (void) { Microtek_Device *next; DBG(10, "sane_exit...\n"); /* close all leftover Scanners */ /*(beware of how sane_close interacts with linked list) */ while (first_handle != NULL) sane_close(first_handle); /* free up device list */ while (first_dev != NULL) { next = first_dev->next; free((void *) first_dev->sane.name); free((void *) first_dev->sane.model); free(first_dev); first_dev = next; } /* the devlist allocated by sane_get_devices */ free(devlist); DBG(10, "sane_exit: MICROTEK says goodbye.\n"); } /********************************************************************/ /* sane_cancel */ /********************************************************************/ void sane_cancel (SANE_Handle handle) { Microtek_Scanner *ms = handle; DBG(10, "sane_cancel...\n"); ms->cancel = SANE_TRUE; if (!(ms->woe)) end_scan(ms, SANE_STATUS_CANCELLED); } /********************************************************************/ /* sane_set_io_mode */ /********************************************************************/ SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { DBG(10, "sane_set_io_mode...\n"); handle = handle; if (non_blocking) return SANE_STATUS_UNSUPPORTED; else return SANE_STATUS_GOOD; } /********************************************************************/ /* sane_get_select_fd */ /********************************************************************/ SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { DBG(10, "sane_get_select_fd...\n"); handle = handle, fd = fd; return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/ricoh2.c0000666000000000000000000006031613615534521014130 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2018, 2019 Stanislav Yuzvinsky Based on the work done by viruxx 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "../include/sane/config.h" #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_debug.h" #include "ricoh2_buffer.c" #define MAX_OPTION_STRING_SIZE 255 #define MAX_LINE_SIZE 240 * 256 /* = 61440 */ #define HEIGHT_PIXELS_300DPI 3508 #define WIDTH_BYTES_300DPI 2560 #define WIDTH_PIXELS_300DPI 2550 #define INFO_SIZE (WIDTH_BYTES_300DPI - WIDTH_PIXELS_300DPI) #define USB_TIMEOUT_MS 20000 #define MAX_COMMAND_SIZE 64 #define CHECK_IF(x) if (!(x)) return SANE_STATUS_INVAL typedef enum { OPT_NUM_OPTS = 0, OPT_MODE, OPT_RESOLUTION, /* must come last: */ NUM_OPTIONS } Ricoh_Options; typedef enum { SCAN_MODE_COLOR, SCAN_MODE_GRAY } Scan_Mode; typedef struct Ricoh2_Device { struct Ricoh2_Device *next; SANE_Device sane; SANE_Bool active; /* options */ SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; /* acquiring session */ SANE_Int dn; SANE_Bool cancelled; Scan_Mode mode; SANE_Int resolution; SANE_Bool eof; size_t bytes_to_read; ricoh2_buffer *buffer; } Ricoh2_Device; typedef struct Ricoh2_device_info { SANE_Int product_id; SANE_String_Const device_name; } Ricoh2_device_info; static Ricoh2_device_info supported_devices[] = { { 0x042c, "Aficio SP-100SU" }, { 0x0438, "Aficio SG-3100SNw" }, { 0x0439, "Aficio SG-3110SFNw" }, { 0x0448, "Aficio SP-111SU/SP-112SU" } }; static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_COLOR, SANE_VALUE_SCAN_MODE_GRAY, NULL }; static SANE_String_Const default_mode = SANE_VALUE_SCAN_MODE_COLOR; static SANE_Int resolution_list[] = { 2, 300, 600 }; static SANE_Int default_resolution = 300; static SANE_Bool initialized = SANE_FALSE; static Ricoh2_Device *ricoh2_devices = NULL; static const SANE_Device **sane_devices = NULL; static SANE_Int num_devices = 0; static Ricoh2_Device * lookup_handle(SANE_Handle handle) { Ricoh2_Device *device; for (device = ricoh2_devices; device; device = device->next) { if (device == handle) return device; } return NULL; } static SANE_String_Const get_model_by_productid(SANE_Int id) { size_t i = 0; for (; i < sizeof (supported_devices) / sizeof (supported_devices[0]); ++i) { if (supported_devices[i].product_id == id) { return supported_devices[i].device_name; } } return "Unidentified device"; } static SANE_Status attach (SANE_String_Const devname) { SANE_Int dn = -1; SANE_Status status = SANE_STATUS_GOOD; Ricoh2_Device *device = NULL; SANE_Int vendor, product; for (device = ricoh2_devices; device; device = device->next) { if (strcmp (device->sane.name, devname) == 0) { device->active = SANE_TRUE; return SANE_STATUS_GOOD; } } device = (Ricoh2_Device *) malloc (sizeof (Ricoh2_Device)); if (!device) { return SANE_STATUS_NO_MEM; } DBG (8, "attach %s\n", devname); status = sanei_usb_open (devname, &dn); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: couldn't open device `%s': %s\n", devname, sane_strstatus (status)); return status; } status = sanei_usb_get_vendor_product (dn, &vendor, &product); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: couldn't get vendor and product ids of device `%s': %s\n", devname, sane_strstatus (status)); sanei_usb_close (dn); return status; } sanei_usb_close (dn); device->sane.name = strdup (devname); device->sane.vendor = "Ricoh"; device->sane.model = get_model_by_productid (product); device->sane.type = "flatbed scanner"; device->active = SANE_TRUE; device->buffer = NULL; device->next = ricoh2_devices; ricoh2_devices = device; DBG (2, "Found device %s\n", device->sane.name); ++num_devices; return SANE_STATUS_GOOD; } static SANE_Status init_options(Ricoh2_Device *dev) { SANE_Option_Descriptor *od; DBG (8, "init_options: dev = %p\n", (void *) dev); /* number of options */ od = &(dev->opt[OPT_NUM_OPTS]); od->name = SANE_NAME_NUM_OPTIONS; od->title = SANE_TITLE_NUM_OPTIONS; od->desc = SANE_DESC_NUM_OPTIONS; od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; dev->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* mode - sets the scan mode: Color, Gray */ od = &(dev->opt[OPT_MODE]); od->name = SANE_NAME_SCAN_MODE; od->title = SANE_TITLE_SCAN_MODE; od->desc = SANE_DESC_SCAN_MODE; od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = MAX_OPTION_STRING_SIZE; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = mode_list; dev->val[OPT_MODE].s = malloc (od->size); if (!dev->val[OPT_MODE].s) return SANE_STATUS_NO_MEM; strcpy (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR); /* resolution */ od = &(dev->opt[OPT_RESOLUTION]); od->name = SANE_NAME_SCAN_RESOLUTION; od->title = SANE_TITLE_SCAN_RESOLUTION; od->desc = SANE_DESC_SCAN_RESOLUTION; od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_DPI; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_WORD_LIST; od->constraint.word_list = resolution_list; dev->val[OPT_RESOLUTION].w = 300; return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int *vc, SANE_Auth_Callback __sane_unused__ cb) { size_t i = 0; DBG_INIT (); DBG(8, ">sane_init\n"); sanei_usb_init (); sanei_usb_set_timeout (USB_TIMEOUT_MS); num_devices = 0; for (; i < sizeof (supported_devices) / sizeof (supported_devices[0]); ++i) { sanei_usb_find_devices (0x5ca, supported_devices[i].product_id, attach); } if (vc) *vc = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); DBG(8, "sane_get_devices\n"); num_devices = 0; sanei_usb_find_devices (0x5ca, 0x042c, attach); sanei_usb_find_devices (0x5ca, 0x0448, attach); if (sane_devices) free (sane_devices); sane_devices = (const SANE_Device **) malloc (sizeof (const SANE_Device *) * (num_devices + 1)); if (!sane_devices) return SANE_STATUS_NO_MEM; for (device = ricoh2_devices; device; device = device->next) if (device->active) { sane_devices[i++] = &(device->sane); } sane_devices[i] = NULL; *dl = sane_devices; DBG(2, "found %i devices\n", i); DBG(8, "sane_open: devicename=\"%s\", handle=%p\n", name, (void *) handle); CHECK_IF (initialized); CHECK_IF (handle); /* walk the linked list of scanner device until there is a match * with the device name */ for (device = ricoh2_devices; device; device = device->next) { DBG (2, "sane_open: devname from list: %s\n", device->sane.name); if (strcmp (name, "") == 0 || strcmp (name, "ricoh") == 0 || strcmp (name, device->sane.name) == 0) break; } *handle = device; if (!device) { DBG (1, "sane_open: Not a Ricoh device\n"); return SANE_STATUS_INVAL; } status = init_options (device); if (status != SANE_STATUS_GOOD) return status; DBG (8, "= NUM_OPTIONS)) return NULL; if (!(device = lookup_handle(handle))) return NULL; if (device->opt[option].name) { DBG (8, ">sane_get_option_descriptor: name=%s\n", device->opt[option].name); } return &(device->opt[option]); } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Word *info) { Ricoh2_Device *device; SANE_Status status; DBG (8, ">sane_control_option: handle=%p, opt=%d, act=%d, val=%p, info=%p\n", (void *) handle, option, action, (void *) value, (void *) info); CHECK_IF (initialized); device = lookup_handle (handle); CHECK_IF (device); CHECK_IF (value); CHECK_IF (option >= 0 && option < NUM_OPTIONS); CHECK_IF (device->opt[option].type != SANE_TYPE_GROUP); switch (action) { case SANE_ACTION_SET_AUTO: CHECK_IF (SANE_OPTION_IS_SETTABLE (device->opt[option].cap)); CHECK_IF (device->opt[option].cap & SANE_CAP_AUTOMATIC); switch (option) { case OPT_RESOLUTION: DBG (2, "Setting value to default value of '%d' for option '%s'\n", default_resolution, device->opt[option].name); device->val[option].w = default_resolution; break; case OPT_MODE: DBG (2, "Setting value to default value of '%s' for option '%s'\n", (SANE_String_Const) default_mode, device->opt[option].name); strcpy (device->val[option].s, default_mode); break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_VALUE: CHECK_IF (SANE_OPTION_IS_SETTABLE (device->opt[option].cap)); if (device->opt[option].type == SANE_TYPE_BOOL) { SANE_Bool bool_value = *(SANE_Bool *) value; CHECK_IF (bool_value == SANE_TRUE || bool_value == SANE_FALSE); } if (device->opt[option].constraint_type == SANE_CONSTRAINT_RANGE) { status = sanei_constrain_value (&(device->opt[option]), value, info); CHECK_IF (status == SANE_STATUS_GOOD); } switch (option) { case OPT_RESOLUTION: DBG (2, "Setting value to '%d' for option '%s'\n", *(SANE_Word *) value, device->opt[option].name); device->val[option].w = *(SANE_Word *) value; break; case OPT_MODE: DBG (2, "Setting value to '%s' for option '%s'\n", (SANE_String_Const)value, device->opt[option].name); strcpy (device->val[option].s, value); break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_GET_VALUE: switch (option) { case OPT_NUM_OPTS: case OPT_RESOLUTION: *(SANE_Word *) value = device->val[option].w; DBG (2, "Option value = %d (%s)\n", *(SANE_Word *) value, device->opt[option].name); break; case OPT_MODE: strcpy (value, device->val[option].s); break; default: return SANE_STATUS_INVAL; } break; default: return SANE_STATUS_INVAL; } DBG (8, "val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) { device->mode = SCAN_MODE_COLOR; } else { device->mode = SCAN_MODE_GRAY; } /* resolution: 300 or 600dpi */ device->resolution = device->val[OPT_RESOLUTION].w; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters *params) { Ricoh2_Device *device; DBG (8, "sane_get_parameters: handle=%p, params=%p\n", (void *) handle, (void *) params); CHECK_IF (initialized); device = lookup_handle (handle); CHECK_IF (device); CHECK_IF (params); update_scan_params (device); params->format = device->mode == SCAN_MODE_COLOR ? SANE_FRAME_RGB : SANE_FRAME_GRAY; params->last_frame = SANE_TRUE; params->pixels_per_line = WIDTH_PIXELS_300DPI; params->bytes_per_line = params->pixels_per_line; params->lines = HEIGHT_PIXELS_300DPI; params->depth = 8; if (device->resolution == 600) { params->bytes_per_line *= 2; params->pixels_per_line *= 2; params->lines *= 2; } if (device->mode == SCAN_MODE_COLOR) { params->bytes_per_line *= 3; } DBG (8, ">sane_get_parameters: format = %s bytes_per_line = %d " "depth = %d " "pixels_per_line = %d " "lines = %d\n", (params->format == SANE_FRAME_RGB ? "rgb" : "gray"), params->bytes_per_line, params->depth, params->pixels_per_line, params->lines); return SANE_STATUS_GOOD; } typedef struct { SANE_Byte *send_buffer; size_t to_send; SANE_Byte *receive_buffer; size_t to_receive; } Send_Receive_Pair; static SANE_Status send_receive (SANE_Int dn, Send_Receive_Pair *transfer) { SANE_Status status; size_t io_size; SANE_Byte send_buffer[MAX_COMMAND_SIZE]; assert(transfer->to_send <= MAX_COMMAND_SIZE); memset(send_buffer, 0, MAX_COMMAND_SIZE); /* send a command */ io_size = MAX_COMMAND_SIZE; DBG (128, "sending a packet of size %lu\n", io_size); memcpy (send_buffer, transfer->send_buffer, transfer->to_send); status = sanei_usb_write_bulk (dn, send_buffer, &io_size); if (status != SANE_STATUS_GOOD) { DBG (1, "could not send packet: %s\n", sane_strstatus (status)); return status; } /* receive a result */ io_size = transfer->to_receive; DBG (128, "receiving a packet of size %lu\n", io_size); if (io_size) { status = sanei_usb_read_bulk (dn, transfer->receive_buffer, &io_size); if (status != SANE_STATUS_GOOD) { DBG (1, "could not get a response for packet: %s\n", sane_strstatus (status)); return status; } if (io_size != transfer->to_receive) { DBG (1, "unexpected size of received packet: expected %lu, " "received %lu\n", transfer->to_receive, io_size); return SANE_STATUS_IO_ERROR; } } return SANE_STATUS_GOOD; } static SANE_Status init_scan(SANE_Int dn, Scan_Mode mode, SANE_Int resolution) { SANE_Status status = SANE_STATUS_GOOD; SANE_Byte dummy_buffer[11]; /* the longest expected reply */ size_t i; SANE_Byte urb_init[] = { 0x03, 0x09, 0x01 }; SANE_Byte magic0[] = { 0x03, 0x0d, 0x0b }; SANE_Byte magic1[] = { 0x03, 0x0c, 0x11, 0x00, 0x00, 0x00, 0x01, 0x02, 0x05, 0xff, 0x00, 0x00, 0x00, 0x00, 0xec, 0x13, 0x6c, 0x1b }; SANE_Byte magic2[] = { 0x03, 0x0b, 0x08 }; SANE_Byte magic3[] = { 0x03, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x50, 0x6d, 0x06, 0x01 }; Send_Receive_Pair transfer[] = { { urb_init, sizeof (urb_init), dummy_buffer, 1 }, { magic0, sizeof (magic0), dummy_buffer, 11 }, { magic1, sizeof (magic1), dummy_buffer, 0 }, { magic2, sizeof (magic2), dummy_buffer, 8 }, { magic3, sizeof (magic3), dummy_buffer, 0 } }; if (resolution == 600) magic1[6] = 0x02; if (mode == SCAN_MODE_COLOR) magic1[7] = 0x03; for (i = 0; i < sizeof (transfer) / sizeof (transfer[0]) && (status == SANE_STATUS_GOOD); ++i) { DBG (128, "sending initialization packet %zi\n", i); status = send_receive (dn, transfer + i); } return status; } void teardown_scan(SANE_Int dn) { SANE_Byte cancel_command[] = { 0x03, 0x0a }; SANE_Byte end_command[] = { 0x03, 0x09, 0x01 }; SANE_Byte dummy_buffer; Send_Receive_Pair transfer; DBG (128, "Sending cancel command\n"); transfer.send_buffer = cancel_command; transfer.to_send = sizeof (cancel_command); transfer.receive_buffer = &dummy_buffer; transfer.to_receive = 0; send_receive (dn, &transfer); transfer.send_buffer = end_command; transfer.to_send = sizeof (end_command); transfer.receive_buffer = &dummy_buffer; transfer.to_receive = 1; send_receive (dn, &transfer); } SANE_Status sane_start (SANE_Handle handle) { Ricoh2_Device *device; SANE_Status status; SANE_Int pixels_per_line; SANE_Int resolution_factor = 1; DBG (8, ">sane_start: handle=%p\n", (void *) handle); CHECK_IF (initialized); device = lookup_handle (handle); CHECK_IF (device); update_scan_params (device); device->cancelled = SANE_FALSE; status = sanei_usb_open (device->sane.name, &(device->dn)); if (status != SANE_STATUS_GOOD) { DBG (1, "could not open device %s: %s\n", device->sane.name, sane_strstatus (status)); return status; } DBG (2, "usb device %s opened, device number is %d\n", device->sane.name, device->dn); status = sanei_usb_claim_interface (device->dn, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "could not claim interface 0: %s\n", sane_strstatus (status)); sanei_usb_close (device->dn); return status; } sanei_usb_set_endpoint (device->dn, USB_DIR_OUT | USB_ENDPOINT_TYPE_BULK, 0x03); sanei_usb_set_endpoint (device->dn, USB_DIR_IN | USB_ENDPOINT_TYPE_BULK, 0x85); status = sanei_usb_reset (device->dn); if (status != SANE_STATUS_GOOD) { DBG (1, "could not reset device %s: %s\n", device->sane.name, sane_strstatus (status)); sanei_usb_close (device->dn); return status; } status = init_scan (device->dn, device->mode, device->resolution); if (status != SANE_STATUS_GOOD) { sanei_usb_close (device->dn); return status; } resolution_factor = device->resolution == 600 ? 2 : 1; pixels_per_line = WIDTH_PIXELS_300DPI * resolution_factor; device->bytes_to_read = WIDTH_PIXELS_300DPI * resolution_factor * HEIGHT_PIXELS_300DPI * resolution_factor * (device->mode == SCAN_MODE_COLOR ? 3 : 1); device->buffer = ricoh2_buffer_create (MAX_LINE_SIZE, pixels_per_line, INFO_SIZE * resolution_factor, device->mode == SCAN_MODE_COLOR); DBG (8, "bytes_to_read); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte *data, SANE_Int maxlen, SANE_Int *length) { SANE_Byte read_next_command[] = { 0x03, 0x0E, 0x04, 0, 0, 0, 0, 240 }; Ricoh2_Device *device; SANE_Status status; Send_Receive_Pair transfer; DBG (16, ">sane_read: handle=%p, data=%p, maxlen = %d, length=%p\n", (void *) handle, (void *) data, maxlen, (void *) length); CHECK_IF (initialized); device = lookup_handle (handle); CHECK_IF (device); CHECK_IF (length); CHECK_IF (maxlen); /* EOF has already been reached before or acquisition process hasn't been initiated at all */ if (device->bytes_to_read <= 0) { return SANE_STATUS_EOF; } if (!ricoh2_buffer_get_bytes_remain (device->buffer)) { transfer.send_buffer = read_next_command; transfer.to_send = sizeof (read_next_command); transfer.receive_buffer = ricoh2_buffer_get_internal_buffer (device->buffer); transfer.to_receive = MAX_LINE_SIZE; read_next_command[7] = transfer.to_receive / 256; DBG (128, "Receiving data of size %zi\n", transfer.to_receive); status = send_receive (device->dn, &transfer); if (status != SANE_STATUS_GOOD) { device->bytes_to_read = 0; return status; } } *length = ricoh2_buffer_get_data (device->buffer, data, min(maxlen, device->bytes_to_read)); device->bytes_to_read -= *length; DBG (128, "Read length %d, left to read %lu\n", *length, device->bytes_to_read); DBG (128, "%d bytes remain in the buffer\n", ricoh2_buffer_get_bytes_remain(device->buffer)); /* we've just reached expected data size */ if (device->bytes_to_read <= 0) { ricoh2_buffer_dispose(device->buffer); device->buffer = NULL; return SANE_STATUS_EOF; } DBG (16, "sane_cancel: handle = %p\n", (void *) handle); if (!initialized) return; if (!(device = lookup_handle (handle))) return; if (device->cancelled) return; device->cancelled = SANE_TRUE; teardown_scan (device->dn); if (device->buffer) { ricoh2_buffer_dispose (device->buffer); device->buffer = NULL; } sanei_usb_close(device->dn); DBG (8, "sane_close\n"); if (!initialized) return; device = lookup_handle (handle); if (!device) return; /* noop */ DBG (8, "sane_exit\n"); if (!initialized) return; for (device = ricoh2_devices, next = device; device; device = next) { next = device->next; free (device); } if (sane_devices) free (sane_devices); sanei_usb_exit (); initialized = SANE_FALSE; DBG (8, ">8; puchGamma[2*i+0]=nVal&0xFF; } for (i=0; rc==SANE_STATUS_GOOD && i<0x2000; i+=0x1000) rc=MemWriteArray(this,(i+iByteAddress)>>1,0x1000,puchGamma+i); free(puchGamma); return rc; } /* ********************************************************************** UploadGainCorrection() ********************************************************************** */ __SM3600EXPORT__ TState UploadGainCorrection(TInstance *this, int iTableOffset) { { struct TGain { unsigned char uchLow; unsigned char uchHigh; } aGain[0x2000]; /* 16 KB */ int i,iOff; unsigned short uwGain; /* Oopsi: correction data starts at the left of the scanning window! */ iOff=this->param.x/2+this->calibration.xMargin; memset(aGain,0xFF,sizeof(aGain)); RegWrite(this,0x3D,1,0x0F | 0x80); /* 10XXXXXX : one offset table */ RegWrite(this,0x3F,1, iTableOffset==0x6000 ? 0x18 : 0x08); /* 16KB gain at 0x06000 or 0x02000 */ for (i=iOff; icalibration.achStripeY[i]<<4; aGain[i-iOff].uchLow =(unsigned char)(uwGain&0xFF); aGain[i-iOff].uchHigh=(unsigned char)(uwGain>>8); } for (i=0; i<0x4000; i+=0x1000) MemWriteArray(this,(iTableOffset+i)>>1,0x1000,((unsigned char*)aGain)+i); } return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/umax-scsidef.h0000666000000000000000000012372413615534521015342 00000000000000/* --------------------------------------------------------------------------------------------------------- */ /* umax-scsidef.h: scsi-definiton header file for UMAX scanner driver. Copyright (C) 1996-1997 Michael K. Johnson Copyright (C) 1997-2002 Oliver Rauch 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* --------------------------------------------------------------------------------------------------------- */ #ifndef UMAX_SCSIDEF_H #define UMAX_SCSIDEF_H #include "umax.h" /* --------------------------------------------------------------------------------------------------------- */ /* I'm using functions derived from Eric Youngdale's scsiinfo * program here for dealing with parts of SCSI commands. */ static inline void setbitfield(unsigned char * pageaddr, int mask, int shift, int val) \ { *pageaddr = (*pageaddr & ~(mask << shift)) | ((val & mask) << shift); } static inline void resetbitfield(unsigned char * pageaddr, int mask, int shift, int val) \ { *pageaddr = (*pageaddr & ~(mask << shift)) | (((!val) & mask) << shift); } static inline int getbitfield(unsigned char * pageaddr, int mask, int shift) \ { return ((*pageaddr >> shift) & mask); } /* ------------------------------------------------------------------------- */ static inline int getnbyte(unsigned char * pnt, int nbytes) \ { unsigned int result = 0; int i; for(i=0; i= 0; i--) \ { pnt[i] = value & 0xff; value = value >> 8; } } /* --------------------------------------------------------------------------------------------------------- */ /* Not all of these are defined in scsi.h, so we'll make sure * we agree about them here... */ #define TEST_UNIT_READY 0x00 #define REQUEST_SENSE 0x03 #define INQUIRY 0x12 #define RESERVE_UNIT 0x16 #define RELEASE_UNIT 0x17 #define SCAN 0x1B #define SET_WINDOW 0x24 #define READ 0x28 #define SEND 0x2A #define OBJECT_POSITION 0x31 #define GET_DATA_BUFFER_STATUS 0x34 #undef WRITE_BUFFER /* correct write_buffer for scanner */ #define WRITE_BUFFER 0x3B #define GET_LAMP_STATUS 0x5E #define SET_LAMP_STATUS 0x5F /* --------------------------------------------------------------------------------------------------------- */ #define STD_WDB_LEN 0x28 /* wdb_len if nothing is set by inquiry */ /* --------------------------------------------------------------------------------------------------------- */ /* SCSI commands */ typedef struct { unsigned char *cmd; size_t size; } scsiblk; /* --------------------------------------------------------------------------------------------------------- */ #define set_inquiry_return_size(icb,val) icb[0x04]=val static unsigned char inquiryC[] = { INQUIRY, 0x00, 0x02, 0x00, 0xff, 0x00 }; static scsiblk inquiry = { inquiryC, sizeof(inquiryC) }; /* --------------------------------------------------------------------------------------------------------- */ #define get_inquiry_periph_qual(in) getbitfield(in, 0x07, 5) # define IN_periph_qual_lun 0x00 # define IN_periph_qual_nolun 0x03 #define get_inquiry_periph_devtype(in) getbitfield(in, 0x1f, 0) # define IN_periph_devtype_scanner 0x06 # define IN_periph_devtype_unknown 0x1f #define get_inquiry_rmb(in) getbitfield(in + 0x01, 0x01, 7) #define get_inquiry_0x01_bit6(in) getbitfield(in + 0x01, 0x01, 6) #define get_inquiry_0x01_bit5(in) getbitfield(in + 0x01, 0x01, 5) #define get_inquiry_CBHS(in) getbitfield(in + 0x01, 0x03, 3) #define set_inquiry_CBHS(in, val) setbitfield(in + 0x01, 0x03, 3, val) # define IN_CBHS_50 0x00 # define IN_CBHS_255 0x01 # define IN_CBHS_auto 0x02 #define get_inquiry_translamp(in) getbitfield(in + 0x01, 0x01, 2) #define get_inquiry_transavail(in) getbitfield(in + 0x01, 0x01, 1) #define get_inquiry_scanmode(in) getbitfield(in + 0x01, 0x01, 0) # define IN_flatbed 0x00 # define IN_adf 0x01 #define get_inquiry_iso_version(in) getbitfield(in + 0x02, 0x03, 6) #define get_inquiry_ecma_version(in) getbitfield(in + 0x02, 0x07, 3) #define get_inquiry_ansi_version(in) getbitfield(in + 0x02, 0x07, 0) #define get_inquiry_aenc(in) getbitfield(in + 0x03, 0x01, 7) #define get_inquiry_tmiop(in) getbitfield(in + 0x03, 0x01, 6) #define get_inquiry_0x03_bit5(in) getbitfield(in + 0x03, 0x01, 5) #define get_inquiry_0x03_bit4(in) getbitfield(in + 0x03, 0x01, 4) #define get_inquiry_response_format(in) getbitfield(in + 0x03, 0x0f, 0) # define IN_recognized 0x02 #define get_inquiry_additional_length(in) in[0x04] #define set_inquiry_length(out,n) out[0x04]=n-5 #define get_inquiry_0x05(in) in[0x05] #define get_inquiry_0x06(in) in[0x06] #define get_inquiry_scsi_byte(in) in[0x07] #define get_inquiry_scsi_reladr(in) getbitfield(in + 0x07, 0x01, 7) #define get_inquiry_scsi_wbus32(in) getbitfield(in + 0x07, 0x01, 6) #define get_inquiry_scsi_wbus16(in) getbitfield(in + 0x07, 0x01, 5) #define get_inquiry_scsi_sync(in) getbitfield(in + 0x07, 0x01, 4) #define get_inquiry_scsi_linked(in) getbitfield(in + 0x07, 0x01, 3) #define get_inquiry_scsi_R(in) getbitfield(in + 0x07, 0x01, 2) #define get_inquiry_scsi_cmdqueue(in) getbitfield(in + 0x07, 0x01, 1) #define get_inquiry_scsi_sftre(in) getbitfield(in + 0x07, 0x01, 0) #define get_inquiry_vendor(in, buf) strncpy(buf, in + 0x08, 0x08) #define get_inquiry_product(in, buf) strncpy(buf, in + 0x10, 0x010) #define get_inquiry_version(in, buf) strncpy(buf, in + 0x20, 0x04) #define set_inquiry_fw_quality(in, val) setbitfield(in + 0x24, 1, 0, val) #define get_inquiry_fw_quality(in) getbitfield(in + 0x24, 1, 0) #define get_inquiry_fw_fast_preview(in) getbitfield(in + 0x24, 1, 1) #define get_inquiry_fw_shadow_comp(in) getbitfield(in + 0x24, 1, 2) #define get_inquiry_fw_reselection(in) getbitfield(in + 0x24, 1, 3) #define get_inquiry_fw_lamp_int_cont(in) getbitfield(in + 0x24, 1, 4) #define get_inquiry_fw_batch_scan(in) getbitfield(in + 0x24, 1, 5) #define get_inquiry_fw_calibration(in) getbitfield(in + 0x24, 1, 6) #define get_inquiry_fw_adjust_exposure_tf(in) getbitfield(in + 0x24, 1, 7) #define get_inquiry_exposure_time_step_unit(in) in[0x25] #define get_inquiry_exposure_time_max(in) getnbyte(in + 0x26, 2) #define get_inquiry_exposure_time_lhg_min(in) in[0x2a] #define get_inquiry_exposure_time_color_min(in) in[0x2b] #define get_inquiry_exposure_time_lh_def_fb(in) in[0x2c] #define get_inquiry_exposure_time_lh_def_uta(in) in[0x2d] #define get_inquiry_exposure_time_gray_def_fb(in) in[0x2e] #define get_inquiry_exposure_time_gray_def_uta(in) in[0x2f] #define get_inquiry_exposure_time_def_r_fb(in) in[0x30] #define get_inquiry_exposure_time_def_g_fb(in) in[0x31] #define get_inquiry_exposure_time_def_b_fb(in) in[0x32] #define get_inquiry_exposure_time_def_r_uta(in) in[0x33] #define get_inquiry_exposure_time_def_g_uta(in) in[0x34] #define get_inquiry_exposure_time_def_b_uta(in) in[0x35] #define get_inquiry_0x36(in) in[0x36] #define get_inquiry_0x37(in) in[0x37] /* bytes 0x38 - 0x5f reserved by SCSI */ #define get_inquiry_sc_feature_byte0(in) in[0x60] #define get_inquiry_sc_three_pass_color(in) getbitfield(in + 0x60, 1, 0) #define get_inquiry_sc_one_pass_color(in) getbitfield(in + 0x60, 1, 1) #define get_inquiry_sc_lineart(in) getbitfield(in + 0x60, 1, 2) #define get_inquiry_sc_halftone(in) getbitfield(in + 0x60, 1, 3) #define get_inquiry_sc_gray(in) getbitfield(in + 0x60, 1, 4) #define get_inquiry_sc_color(in) getbitfield(in + 0x60, 1, 5) #define get_inquiry_sc_uta(in) getbitfield(in + 0x60, 1, 6) #define get_inquiry_sc_adf(in) getbitfield(in + 0x60, 1, 7) #define set_inquiry_sc_three_pass_color(in,val) setbitfield(in + 0x60, 1, 0, val) #define set_inquiry_sc_one_pass_color(in,val) setbitfield(in + 0x60, 1, 1, val) #define set_inquiry_sc_lineart(in,val) setbitfield(in + 0x60, 1, 2, val) #define set_inquiry_sc_halftone(in,val) setbitfield(in + 0x60, 1, 3, val) #define set_inquiry_sc_gray(in,val) setbitfield(in + 0x60, 1, 4, val) #define set_inquiry_sc_color(in,val) setbitfield(in + 0x60, 1, 5, val) #define set_inquiry_sc_uta(in,val) setbitfield(in + 0x60, 1, 6, val) #define set_inquiry_sc_adf(in,val) setbitfield(in + 0x60, 1, 7, val) #define get_inquiry_sc_feature_byte1(in) in[0x61] #define get_inquiry_sc_double_res(in) getbitfield(in + 0x61, 1, 0) #define get_inquiry_sc_high_byte_first(in) getbitfield(in + 0x61, 1, 1) #define get_inquiry_sc_bi_image_reverse(in) getbitfield(in + 0x61, 1, 2) #define get_inquiry_sc_multi_image_reverse(in) getbitfield(in + 0x61, 1, 3) #define get_inquiry_sc_no_shadow(in) getbitfield(in + 0x61, 1, 4) #define get_inquiry_sc_no_highlight(in) getbitfield(in + 0x61, 1, 5) #define get_inquiry_sc_downloadable_fw(in) getbitfield(in + 0x61, 1, 6) #define get_inquiry_sc_paper_length_14(in) getbitfield(in + 0x61, 1, 7) #define get_inquiry_sc_feature_byte2(in) in[0x62] #define get_inquiry_sc_uploadable_shade(in) getbitfield(in + 0x62, 1, 0) #define get_inquiry_fw_support_color(in) getbitfield(in + 0x62, 1, 1) #define get_inquiry_analog_gamma(in) getbitfield(in + 0x62, 1, 2) #define get_inquiry_xy_coordinate_base(in) getbitfield(in + 0x62, 1, 3) #define get_inquiry_lineart_order(in) getbitfield(in + 0x62, 1, 4) #define get_inquiry_start_density(in) getbitfield(in + 0x62, 1, 5) #define get_inquiry_hw_x_scaling(in) getbitfield(in + 0x62, 1, 6) #define get_inquiry_hw_y_scaling(in) getbitfield(in + 0x62, 1, 7) #define get_inquiry_sc_feature_byte3(in) in[0x63] #define get_inquiry_ADF_no_paper(in) getbitfield(in + 0x63, 1, 0) #define get_inquiry_ADF_cover_open(in) getbitfield(in + 0x63, 1, 1) #define get_inquiry_ADF_paper_jam(in) getbitfield(in + 0x63, 1, 2) #define get_inquiry_0x63_bit3(in) getbitfield(in + 0x63, 1, 3) #define get_inquiry_0x63_bit4(in) getbitfield(in + 0x63, 1, 4) #define get_inquiry_lens_cal_in_doc_pos(in) getbitfield(in + 0x63, 1, 5) #define get_inquiry_manual_focus(in) getbitfield(in + 0x63, 1, 6) #define get_inquiry_sel_uta_lens_cal_pos(in) getbitfield(in + 0x63, 1, 7) #define get_inquiry_gamma_download_available(in) getbitfield(in + 0x64, 1, 7) #define get_inquiry_0x64_bit6(in) getbitfield(in + 0x64, 1, 6) #define get_inquiry_gamma_type_2(in) getbitfield(in + 0x64, 1, 5) #define get_inquiry_0x64_bit4(in) getbitfield(in + 0x64, 1, 4) #define get_inquiry_0x64_bit3(in) getbitfield(in + 0x64, 1, 3) #define get_inquiry_0x64_bit2(in) getbitfield(in + 0x64, 1, 2) #define get_inquiry_gamma_lines(in) getbitfield(in + 0x64, 0x03, 0) # define IN_3_pass 0x01 # define IN_3_line 0x03 #define get_inquiry_0x65(in) in[0x65] #define get_inquiry_gib(in) in[0x66] #define get_inquiry_gib_8bpp(in) getbitfield(in + 0x66, 1, 0) #define get_inquiry_gib_9bpp(in) getbitfield(in + 0x66, 1, 1) #define get_inquiry_gib_10bpp(in) getbitfield(in + 0x66, 1, 2) #define get_inquiry_gib_12bpp(in) getbitfield(in + 0x66, 1, 3) #define get_inquiry_gib_14bpp(in) getbitfield(in + 0x66, 1, 4) #define get_inquiry_gib_16bpp(in) getbitfield(in + 0x66, 1, 5) #define get_inquiry_0x66_bit6(in) getbitfield(in + 0x66, 1, 6) #define get_inquiry_0x66_bit7(in) getbitfield(in + 0x66, 1, 7) # define IN_gib_8bpp 0x01 # define IN_gib_10bpp 0x04 #define get_inquiry_0x67(in) in[0x67] #define get_inquiry_gob(in) in[0x68] #define get_inquiry_gob_8bpp(in) getbitfield(in + 0x68, 1, 0) #define get_inquiry_gob_9bpp(in) getbitfield(in + 0x68, 1, 1) #define get_inquiry_gob_10bpp(in) getbitfield(in + 0x68, 1, 2) #define get_inquiry_gob_12bpp(in) getbitfield(in + 0x68, 1, 3) #define get_inquiry_gob_14bpp(in) getbitfield(in + 0x68, 1, 4) #define get_inquiry_gob_16bpp(in) getbitfield(in + 0x68, 1, 5) #define get_inquiry_0x68_bit6(in) getbitfield(in + 0x68, 1, 6) #define get_inquiry_0x68_bit7(in) getbitfield(in + 0x68, 1, 7) # define IN_gob_8bpp 0x01 # define IN_gob_10bpp 0x04 #define get_inquiry_hda(in) getbitfield(in + 0x69, 0x01, 7) #define get_inquiry_max_halftone_matrix(in) getbitfield(in + 0x69, 0x7f, 0) #define get_inquiry_halftones_supported(in) in[0x6a] #define get_inquiry_halftones_2x2(in) getbitfield(in + 0x6a, 1, 0) #define get_inquiry_halftones_4x4(in) getbitfield(in + 0x6a, 1, 1) #define get_inquiry_halftones_6x6(in) getbitfield(in + 0x6a, 1, 2) #define get_inquiry_halftones_8x8(in) getbitfield(in + 0x6a, 1, 3) #define get_inquiry_halftones_12x12(in) getbitfield(in + 0x6a, 1, 5) # define IN_halftone_2x2 0x01 # define IN_halftone_4x4 0x02 # define IN_halftone_6x6 0x04 # define IN_halftone_8x8 0x08 # define IN_halftone_12x12 0x20 #define get_inquiry_0x6b(in) in[0x6b] #define get_inquiry_0x6c(in) in[0x6c] #define get_inquiry_colorseq(in) getbitfield(in + 0x6d, 0x07, 5) # define IN_color_sequence_RGB 0x00 # define IN_color_sequence_RBG 0x01 # define IN_color_sequence_GBR 0x02 # define IN_color_sequence_GRB 0x03 # define IN_color_sequence_BRG 0x04 # define IN_color_sequence_BGR 0x05 # define IN_color_sequence_all 0x07 #define get_inquiry_color_order(in) getbitfield(in + 0x6d, 0x1f, 0) #define set_inquiry_color_order(in,val) setbitfield(in + 0x6d, 0x1f, 0, val) #define get_inquiry_color_order_pixel(in) getbitfield(in + 0x6d, 1, 0) #define get_inquiry_color_order_line_no_ccd(in) getbitfield(in + 0x6d, 1, 1) #define get_inquiry_color_order_plane(in) getbitfield(in + 0x6d, 1, 2) #define get_inquiry_color_order_line_w_ccd(in) getbitfield(in + 0x6d, 1, 3) #define get_inquiry_color_order_reserved(in) getbitfield(in + 0x6d, 1, 4) # define IN_color_ordering_pixel 0x01 # define IN_color_ordering_line_no_ccd 0x02 # define IN_color_ordering_plane 0x04 # define IN_color_ordering_line_w_ccd 0x08 #define get_inquiry_max_vidmem(in) getnbyte(in + 0x6e, 4) #define get_inquiry_0x72(in) in[0x72] #define get_inquiry_max_opt_res(in) in[0x73] #define get_inquiry_max_x_res(in) in[0x74] #define get_inquiry_max_y_res(in) in[0x75] #define get_inquiry_fb_max_scan_width(in) getnbyte(in + 0x76, 2) #define get_inquiry_fb_max_scan_length(in) getnbyte(in + 0x78, 2) #define get_inquiry_uta_x_original_point(in) getnbyte(in + 0x7a, 2) #define get_inquiry_uta_y_original_point(in) getnbyte(in + 0x7c, 2) #define get_inquiry_uta_max_scan_width(in) getnbyte(in + 0x7e, 2) #define get_inquiry_uta_max_scan_length(in) getnbyte(in + 0x80, 2) #define get_inquiry_0x82(in) in[0x82] #define get_inquiry_dor_max_opt_res(in) in[0x83] #define get_inquiry_dor_max_x_res(in) in[0x84] #define get_inquiry_dor_max_y_res(in) in[0x85] #define get_inquiry_dor_x_original_point(in) getnbyte(in + 0x86, 2) #define get_inquiry_dor_y_original_point(in) getnbyte(in + 0x88, 2) #define get_inquiry_dor_max_scan_width(in) getnbyte(in + 0x8a, 2) #define get_inquiry_dor_max_scan_length(in) getnbyte(in + 0x8c, 2) #define get_inquiry_0x8e(in) in[0x8e] #define get_inquiry_last_calibration_lamp_density(in) in[0x8f] # define IN_min_lamp_density 0x01 # define IN_max_lamp_density 0xff #define get_inquiry_0x90(in) in[0x90] #define get_inquiry_lamp_warmup_maximum_time(in) in[0x91] #define get_inquiry_wdb_length(in) getnbyte(in + 0x92, 2) #define get_inquiry_optical_resolution_residue(in) in[0x94] #define get_inquiry_x_resolution_residue(in) in[0x95] #define get_inquiry_y_resolution_residue(in) in[0x96] #define get_inquiry_analog_gamma_table(in) in[0x97] #define get_inquiry_0x98(in) in[0x98] #define get_inquiry_0x99(in) in[0x99] #define get_inquiry_max_calibration_data_lines(in) in[0x9a] #define get_inquiry_fb_uta_line_arrangement_mode(in) in[0x9b] #define get_inquiry_adf_line_arrangement_mode(in) in[0x9c] #define get_inquiry_CCD_line_distance(in) in[0x9d] #define set_inquiry_max_calibration_data_lines(out,val) out[0x9a]=val #define set_inquiry_fb_uta_line_arrangement_mode(out,val) out[0x9b]=val #define set_inquiry_adf_line_arrangement_mode(out,val) out[0x9c]=val #define set_inquiry_CCD_line_distance(out,val) out[0x9d]=val #define get_inquiry_0x9e(in) in[0x9e] #define get_inquiry_dor_optical_resolution_residue(in) in[0xa0] #define get_inquiry_dor_x_resolution_residue(in) in[0xa1] #define get_inquiry_dor_y_resolution_residue(in) in[0xa2] /* --------------------------------------------------------------------------------------------------------- */ /* although the command is defined with 6 bytes length in the doc, 10 bytes seems to be the correct length */ static unsigned char get_lamp_statusC[] = { GET_LAMP_STATUS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk get_lamp_status = { get_lamp_statusC,sizeof(get_lamp_statusC) }; #define get_lamp_status_lamp_on(in) getbitfield(in, 1, 0) /* --------------------------------------------------------------------------------------------------------- */ /* although the command is defined with 6 bytes length in the doc, 10 bytes seems to be the correct length */ static unsigned char set_lamp_statusC[] = { SET_LAMP_STATUS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk set_lamp_status = { set_lamp_statusC,sizeof(set_lamp_statusC) }; #define set_lamp_status_lamp_on(in,val) setbitfield(in + 0x03, 1, 7, val) /* --------------------------------------------------------------------------------------------------------- */ static unsigned char test_unit_readyC[] = { TEST_UNIT_READY, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk test_unit_ready = { test_unit_readyC,sizeof(test_unit_readyC) }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char reserve_unitC[] = { RESERVE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk reserve_unit = { reserve_unitC, sizeof(reserve_unitC) }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char release_unitC[] = { RELEASE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk release_unit = { release_unitC, sizeof(release_unitC) }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char set_windowC[] = { SET_WINDOW, 0x00, /* opcode, lun */ 0x00, 0x00, 0x00, 0x00, /* reserved */ 0x00, 0x00, 0x00, /* transfer length; needs to be set */ 0x00 /* control byte */ }; #define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) static scsiblk set_window = { set_windowC, sizeof(set_windowC) }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char window_parameter_data_blockC[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* reserved */ 0x00, 0x00 /* Window Descriptor Length, value must be set by SHORT_WDB define */ }; #define set_WPDB_wdblen(sb, len) putnbyte(sb + 0x06, len, 2) static scsiblk window_parameter_data_block = { window_parameter_data_blockC, sizeof(window_parameter_data_blockC) }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char window_descriptor_blockC[] = { #define max_WDB_size 0xff #define used_WDB_size 0x53 /* 0x00 */ 0x00, /* Window Identifier */ #define set_WD_wid(sb, val) sb[0] = val # define WD_wid_bw 0x00 # define WD_wid_red 0x01 # define WD_wid_green 0x02 # define WD_wid_blue 0x03 # define WD_wid_all 0x00 /* 0x01 */ 0x00, /* reserved, AUTO */ #define set_WD_auto(sb, val) setbitfield(sb + 0x01, 1, 0, val) /* 0x02 */ 0x00, 0x00, /* X Resolution in dpi */ #define set_WD_Xres(sb, val) putnbyte(sb + 0x02, val, 2) /* 0x04 */ 0x00, 0x00, /* Y Resolution in dpi */ #define set_WD_Yres(sb, val) putnbyte(sb + 0x04, val, 2) /* 0x06 */ 0x00, 0x00, 0x00, 0x00, /* Upper Left X in 1200pt/inch */ #define set_WD_ULX(sb, val) putnbyte(sb + 0x06, val, 4) /* 0x0a */ 0x00, 0x00, 0x00, 0x00, /* Upper Left Y in 1200pt/inch */ #define set_WD_ULY(sb, val) putnbyte(sb + 0x0a, val, 4) /* 0x0e */ 0x00, 0x00, 0x00, 0x00, /* Width 1200pt/inch */ #define set_WD_width(sb, val) putnbyte(sb + 0x0e, val, 4) /* 0x12 */ 0x00, 0x00, 0x00, 0x00, /* Length 1200pt/inch */ #define set_WD_length(sb, val) putnbyte(sb + 0x12, val, 4) /* 0x16 */ 0xff, /* Brightness */ #define set_WD_brightness(sb, val) sb[0x16] = val /* 0x17 */ 0x80, /* Threshold */ #define set_WD_threshold(sb, val) sb[0x17] = val /* 0x18 */ 0x80, /* Contrast */ #define set_WD_contrast(sb, val) sb[0x18] = val /* 0x19 */ 0x05, /* Image Composition */ #define set_WD_composition(sb, val) sb[0x19] = val # define WD_comp_lineart 0x00 # define WD_comp_dithered 0x01 # define WD_comp_gray 0x02 # define WD_comp_gray 0x02 # define WD_comp_rgb_bilevel 0x03 # define WD_comp_rgb_dithered 0x04 # define WD_comp_rgb_full 0x05 /* 0x1a */ 0x08, /* Bits/Pixel */ #define set_WD_bitsperpixel(sb, val) sb[0x1a] = val # define WD_bits_1 0x01 # define WD_bits_8 0x08 # define WD_bits_10 0x0a /* 0x1b */ 0x00, 0x03, /* Halftone pattern */ #define set_WD_halftone(sb, val) putnbyte(sb + 0x1b, val, 2) # define WD_halftone_download 0x00 # define WD_halftone_12x12_1 0x01 # define WD_halftone_12x12_2 0x02 # define WD_halftone_8x8_1 0x03 # define WD_halftone_8x8_2 0x04 # define WD_halftone_8x8_3 0x05 # define WD_halftone_8x8_4 0x06 # define WD_halftone_8x8_5 0x07 # define WD_halftone_6x6_1 0x08 # define WD_halftone_6x6_2 0x09 # define WD_halftone_6x6_3 0x0a # define WD_halftone_4x4_1 0x0b # define WD_halftone_4x4_2 0x0c # define WD_halftone_4x4_3 0x0d # define WD_halftone_2x2_1 0x0e # define WD_halftone_2x2_2 0x0f /* 0x1d */ 0x03, /* RIF, reserved, padding type */ #define set_WD_RIF(sb, val) setbitfield(sb + 0x1d, 1, 7, val) #define set_WD_padding_type(sb,val) setbitfield(sb + 0x1d, 0x07, 0, val) # define WD_padding_byte 0x03 # define WD_padding_word 0x07 /* 0x1e */ 0x00, 0x00, /* Bit Ordering (0 = left to right;) */ /* 0x20 */ 0x00, /* Compression Type (reserved) */ /* 0x21 */ 0x00, /* Compr. Argument (reserved) */ /* 0x22 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Reserved */ /* 0x28 */ 0x01, /* Speed */ #define set_WD_speed(sb, val) sb[0x28] = val # define WD_speed_fastsmear 0x81 # define WD_speed_slowsmear 0x82 # define WD_speed_fastclear 0x01 # define WD_speed_slowclear 0x02 # define WD_speed_speedbit 0x03 # define WD_speed_smearbit 0x80 # define WD_speed_fast 0x01 # define WD_speed_slow 0x02 # define WD_speed_smear 0x80 /* 0x29 */ 0x00, /* Select Color */ #define set_WD_select_color(sb,val) setbitfield(sb+0x29, 0x07, 5, val) # define WD_color_gray 0x00 # define WD_color_red 0x04 # define WD_color_green 0x02 # define WD_color_blue 0x01 /* 0x2a */ 0xff, /* Highlight */ #define set_WD_highlight(sb, val) sb[0x2a] = val /* 0x2b */ 0x00, /* Shadow */ #define set_WD_shadow(sb, val) sb[0x2b] = val /* 0x2c */ 0x00, 0x00, /* Paper Length */ #define set_WD_paperlength(sb, val) putnbyte(sb + 0x2c, val, 2) /* 0x2e */ 0x0f, /* Gamma Function */ #define set_WD_gamma(sb, val) sb[0x2e] = val # define WD_gamma_download 0x00 # define WD_gamma_builtin1 0x01 # define WD_gamma_builtin2 0x02 # define WD_gamma_builtin3 0x03 # define WD_gamma_builtin4 0x04 # define WD_gamma_normal 0x0f /* 0x2f */ 0x11, /* Scan Module */ #define set_WD_module(sb, val) sb[0x2f] = val # define WD_module_flatbed 0x11 # define WD_module_transparency 0xff /* 0x30 */ 0x01, /* HBT, DOR, reserved, RMIF, CBHS Type */ /* CBHS = Contrast, Brightness, Highlight, Shadow */ #define set_WD_CBHS(sb, val) setbitfield(sb + 0x30, 1, 0, val) # define WD_CBHS_50 0 # define WD_CBHS_255 1 #define set_WD_FF(sb, val) setbitfield(sb + 0x30, 1, 1, val) /* FF = Fix Focus position */ #define set_WD_RMIF(sb, val) setbitfield(sb + 0x30, 1, 2, val) /* Reverse Multil Image Frmt */ #define set_WD_FDC(sb, val) setbitfield(sb + 0x30, 1, 3, val) /* document calibration */ #define set_WD_PF(sb, val) setbitfield(sb + 0x30, 1, 4, val) /* PF pre focus */ #define set_WD_LCL(sb, val) setbitfield(sb + 0x30, 1, 5, val) /* LCL (focus position) */ #define set_WD_DOR(sb, val) setbitfield(sb + 0x30, 1, 6, val) /* Double Optical Resolution */ #define set_WD_HBT(sb, val) setbitfield(sb + 0x30, 1, 7, val) /* High Byte Transfer */ # define WD_HBT_HBF 0x00 # define WD_HBT_LBF 0x01 /* 0x31 */ 0x00, 0x00, /* scan exposure level */ #define set_WD_scan_exposure_level(sb, val) putnbyte(sb+0x31, val, 2) /* 0x33 */ 0x00, 0x00, /* calibration exposure level */ #define set_WD_calibration_exposure_level(sb, val) putnbyte(sb+0x33, val, 2) /* 0x35 */ 0x00, /* reserved */ /* 0x36 */ 0x00, /* reserved */ /* 0x37 */ 0x00, /* reserved */ /* 0x38 */ 0x00, /* reserved (For Autoexposure) */ /* 0x39 */ 0x00, /* BS, reserved, Calibration Mode */ #define set_WD_batch(sb, val) setbitfield(sb + 0x39, 1, 7, val) #define set_WD_MF(sb, val) setbitfield(sb + 0x39, 1, 6, val) /* manual focus */ #define set_WD_line_arrangement(sb, val) setbitfield(sb + 0x39, 1, 5, val) # define WD_line_arrengement_by_driver 0x01 # define WD_line_arrengement_by_fw 0x00 #define set_WD_warmup(sb, val) setbitfield(sb + 0x39, 1, 4, val) #define set_WD_calibration(sb, val) setbitfield(sb + 0x39, 0x0f, 0, val) # define WD_calibration_image 0x00 # define WD_calibration_lineart 0x0f # define WD_calibration_dither 0x0e # define WD_calibration_gray 0x0d # define WD_calibration_rgb 0x0a # define WD_calibration_ignore 0x09 /* 0x3a */ 0x01, /* Color Sequence, Color Ordering Support */ #define set_WD_color_sequence(sb,val) setbitfield(sb+0x3a,0x07,5, val) # define WD_color_sequence_RGB 0x00 # define WD_color_sequence_RBG 0x01 # define WD_color_sequence_GBR 0x02 # define WD_color_sequence_GRB 0x03 # define WD_color_sequence_BRG 0x04 # define WD_color_sequence_BGR 0x05 #define set_WD_color_ordering(sb,val) setbitfield(sb+0x3a,0x1f,0, val) # define WD_color_ordering_pixel 0x01 # define WD_color_ordering_line_no_ccd 0x02 # define WD_color_ordering_plane 0x04 # define WD_color_ordering_line_w_ccd 0x08 /* 0x3b */ 0x00, /* analog gamma code (set to 1.0) */ #define set_WD_analog_gamma(sb, gamma) sb[0x3b] = gamma /* see analog_gamma_table */ /* 0x3c */ 0x00, /* Reserved */ /* 0x3d */ 0x00, /* Next Calibration Lamp Density */ #define set_WD_lamp_c_density(sb, val) sb[0x3d] = val # define WD_lamp_c_density_auto 0x00 # define WD_lamp_c_density_min 0x01 # define WD_lamp_c_density_max 0xff /* 0x3e */ 0x00, /* Reserved */ /* 0x3f */ 0x00, /* Next Scan Lamp Density */ #define set_WD_lamp_s_density(sb, val) sb[0x3f] = val # define WD_lamp_s_density_auto 0x00 # define WD_lamp_s_density_min 0x01 # define WD_lamp_s_density_max 0xff /* 0x40 */ 0x00, 0x00, 0x00, 0x00, /* Next Upper Left Y in 1200 dpt/inch */ #define set_WD_next_upper_left(sb, val) putnbyte(sb + 0x40, val, 4) /* 0x44 */ 0x00, 0x00, 0x00, 0x00, /* Pixel Count */ #define set_WD_pixel_count(sb, val) putnbyte(sb + 0x44, val, 4) /* 0x48 */ 0x00, 0x00, 0x00, 0x00, /* Line Count */ #define set_WD_line_count(sb, val) putnbyte(sb + 0x48, val, 4) /* 0x4c */ 4, 176, /* x coordiante base 1200 (pts/inch) */ #define set_WD_x_coordinate_base(sb, val) putnbyte(sb + 0x4c, val, 2) /* 0x4e */ 4, 176, /* y coordinate base 1200 (pts/inch) */ #define set_WD_y_coordinate_base(sb, val) putnbyte(sb + 0x4e, val, 2) /* 0x50 */ 0x00, /* reserved */ /* 0x51 */ 0x00, /* driver calibration need image data lines */ #define set_WD_calibration_data_lines(sb, val) sb[0x51] = val /* 0x52 */ 0x00 /* start density */ #define set_WD_start_density(sb, val) sb[0x52] = val /* if somone adds here anything, please change used_WDB_size in this file !! */ }; static scsiblk window_descriptor_block = { window_descriptor_blockC, sizeof(window_descriptor_blockC) }; /* --------------------------------------------------------------------------------------------------------- */ #define set_WDB_length(length) (window_descriptor_block.size = (length)) #define WPDB_OFF(b) (b + set_window.size) #define WDB_OFF(b, n) (b + set_window.size + \ window_parameter_data_block.size + \ ( window_descriptor_block.size * (n - 1) ) ) #define set_WPDB_wdbnum(sb,n) set_WPDB_wdblen(sb,window_descriptor_block.size*n) /* --------------------------------------------------------------------------------------------------------- */ static unsigned char scanC[] = { SCAN, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00 }; static scsiblk scan = { scanC, sizeof(scanC) - 3 }; #define set_SC_xfer_length(sb, val) sb[0x04] = val #define set_SC_quality(sb, val) setbitfield(sb + 0x05, 1, 5, val) #define set_SC_adf(sb, val) setbitfield(sb + 0x05, 1, 6, val) #define set_SC_preview(sb, val) setbitfield(sb + 0x05, 1, 7, val) #define set_SC_wid(sb, n, val) sb[0x05 + n] = val /* --------------------------------------------------------------------------------------------------------- */ /* sread instead of read because read is a libc primitive */ static unsigned char sreadC[] = { READ, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk sread = { sreadC, sizeof(sreadC) }; #define set_R_datatype_code(sb, val) sb[0x02] = val # define R_datatype_imagedata 0x00 # define R_datatype_vendorspecific 0x01 # define R_datatype_halftone 0x02 # define R_datatype_gamma 0x03 # define R_datatype_shading 0x80 # define R_datatype_gain 0x81 #define set_R_datatype_qual_winid(sb, val) sb[0x05] = val #define set_R_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3) /* --------------------------------------------------------------------------------------------------------- */ static unsigned char sendC[] = { SEND, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk send = { sendC, sizeof(sendC) }; #define set_S_datatype_code(sb, val) sb[0x02] = val # define S_datatype_imagedata 0x00 # define S_datatype_vendorspecific 0x01 # define S_datatype_halftone 0x02 # define S_datatype_gamma 0x03 # define S_datatype_shading 0x80 # define S_datatype_gain 0x81 #define set_S_datatype_qual_winid(sb, val) sb[0x05] = val #define set_S_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3) # define S_xfer_length_gamma(l) ((l * (1024 + 1)) + 1) # define S_xfer_length_1line 0x0402 # define S_xfer_length_2line 0x0803 # define S_xfer_length_3line 0x0c04 /* FIXME: add Type 0 download curve format */ /* FIXME: add Type 1 download curve format */ static unsigned char gamma_DCF0C[] = { 0x00 }; static scsiblk gamma_DCF0 = { gamma_DCF0C, sizeof(gamma_DCF0C) }; #define set_DCF0_gamma_color(dc,col,val) dc[1 + (1025 * col)] = val # define DCF0_gamma_color_gray 0 # define DCF0_gamma_color_red 1 # define DCF0_gamma_color_green 2 # define DCF0_gamma_color_blue 3 #define set_DCF0_gamma_lines(dc,val) setbitfield(dc + 0x00, 3, 0, val) # define DCF0_gamma_one_line 1 # define DCF0_gamma_three_lines 3 static unsigned char gamma_DCF1C[] = { 0x00, 0x00 }; static scsiblk gamma_DCF1 = { gamma_DCF1C, sizeof(gamma_DCF1C) }; #define set_DCF1_gamma_color(dc,val) dc[1] = val # define DCF1_gamma_color_gray 0 # define DCF1_gamma_color_red 1 # define DCF1_gamma_color_green 2 # define DCF1_gamma_color_blue 3 static unsigned char gamma_DCF2C[] = { 0x21, 0x00, 0x01, 0x00, 0x01, 0x00 }; static scsiblk gamma_DCF2 = { gamma_DCF2C, sizeof(gamma_DCF2C) }; #define set_DCF2_gamma_color(dc,val) setbitfield(dc + 0x00, 3, 2, val) # define DCF2_gamma_color_gray 0 # define DCF2_gamma_color_red 1 # define DCF2_gamma_color_green 2 # define DCF2_gamma_color_blue 3 #define set_DCF2_gamma_lines(dc,val) setbitfield(dc + 0x00, 3, 0, val) # define DCF2_gamma_one_line 1 # define DCF2_gamma_three_lines 3 #define set_DCF2_gamma_input_bits(dc,val) dc[0x02]=val #define set_DCF2_gamma_output_bits(dc,val) dc[0x04]=val # define DCF2_gamma_8_bits 1 # define DCF2_gamma_10_bits 4 /* --------------------------------------------------------------------------------------------------------- */ static unsigned char object_positionC[] = { OBJECT_POSITION, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk object_position = { object_positionC, sizeof(object_positionC) }; /* --------------------------------------------------------------------------------------------------------- */ #ifndef UMAX_HIDE_UNUSED static unsigned char get_data_buffer_statusC[] = { GET_DATA_BUFFER_STATUS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00 }; #define set_GDBS_wait(sb, val) setbitfield(sb + 0x01, 1, 0, val) #define set_GDBS_len(sb, nwins) putnbyte(sb + 0x07, (4 + (nwins * 8)), 2) static scsiblk get_data_buffer_status = { get_data_buffer_statusC, sizeof(get_data_buffer_statusC) }; /* DBS is Data Buffer Status, the header that is returned */ #define get_DBS_data_buffer_status_length(sb) getnbyte(sb, 3) #define get_DBSD_block_bit(sb) getbitfield(sb + 3, 1, 0) /* DBSD are the Data Buffer Status Descriptors, the records that * are returned following the DBS header. */ /* order is the number of the DBSD, from 1 to (length/8) */ #define get_DBSD_winid(sb, order) sb[4 + ((order - 1) * 8)] #define get_DBSD_available_data_buffer(sb,order) getnbyte(sb+4+((order-1)*8)+2,3) #define get_DBSD_filled_data_buffer(sb,order) getnbyte(sb+4+((order-1)*8)+5,3) #define gdbs_return_block_size 12 #endif /* --------------------------------------------------------------------------------------------------------- */ #ifndef UMAX_HIDE_UNUSED static unsigned char write_bufferC[] = { WRITE_BUFFER, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk write_buffer = { write_bufferC, sizeof(write_bufferC) }; #endif /* --------------------------------------------------------------------------------------------------------- */ static double analog_gamma_table[16]={1.0000, 1.0434, 1.0887, 1.1361, \ 1.1859, 1.2382, 1.2933, 1.3516, \ 1.4134, 1.4792, 1.5495, 1.6251, \ 1.7067, 1.7954, 1.8926, 2.0000 }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char request_senseC[] = { REQUEST_SENSE, 0x00, 0x00, 0x00, 0x00, 0x00 }; #define set_RS_allocation_length(sb,val) sb[0x04]=val #define set_RS_LUN(sb,val) setbitfield(sb + 0x01, 7, 5) /* ??? */ static scsiblk request_sense = { request_senseC, sizeof(request_senseC) }; /* defines for request sense return block */ #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7) #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0) #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7) #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6) #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5) #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0) #define get_RS_information(b) getnbyte(b+0x03, 4) #define get_RS_additional_length(b) b[0x07] #define get_RS_ASC(b) b[0x0c] #define get_RS_ASCQ(b) b[0x0d] #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /* valid */ #define get_RS_CD(b) getbitfield(b+0x0f,1,6) /* 1=CDB */ #define get_RS_field_pointer(b) getnbyte(b+0x10, 2) #define get_RS_additional_sense(b) getnbyte(b+0x12, 2) #define get_RS_asb_dim_light(b) getbitfield(b+0x12,1,7) #define get_RS_asb_no_light(b) getbitfield(b+0x12,1,6) #define get_RS_asb_sensor_motor(b) getbitfield(b+0x12,1,5) #define get_RS_asb_too_light(b) getbitfield(b+0x12,1,4) #define get_RS_asb_calibration(b) getbitfield(b+0x12,1,3) #define get_RS_asb_rom(b) getbitfield(b+0x12,1,2) #define get_RS_asb_ram(b) getbitfield(b+0x12,1,1) #define get_RS_asb_cpu(b) getbitfield(b+0x12,1,0) #define get_RS_asb_scsi(b) getbitfield(b+0x13,1,7) #define get_RS_asb_timer(b) getbitfield(b+0x13,1,6) #define get_RS_asb_filter_motor(b) getbitfield(b+0x13,1,5) #define get_RS_asb_dc_adjust(b) getbitfield(b+0x13,1,1) #define get_RS_asb_uta_sensor(b) getbitfield(b+0x13,1,0) #define get_RS_scanner_error_code(b) b[0x15] #define get_RS_SCC_condition_code(b) b[0x17] #define get_RS_SCC_calibration_bytesperline(b) getnbyte(b+0x18, 4) #define get_RS_SCC_calibration_lines(b) getnbyte(b+0x1c, 2) #define get_RS_SCC_calibration_bytespp(b) b[0x1e] #define rs_return_block_size 0x1f /* --------------------------------------------------------------------------------------------------------- */ static char *cbhs_str[] = { "0-50","0-255", "0-255 autoexposure", "reserved" }; static char *scanmode_str[] = { "flatbed (FB)", "automatic document feeder (ADF)" }; static char *gamma_lines_str[]= { "reserved", "one line (gray), three pass (color) download", "reserved", "one line (gray), three lines (color) download" }; static char *color_sequence_str[]= { "R->G->B","R->B->G", "G->B->R","G->R->B", "B->R->G","B->G->R", "reserved","all supported"}; /* --------------------------------------------------------------------------------------------------------- */ static char *sense_str[] = {"NO SENSE", "RECOVERED ERROR", "NOT READY", "MEDIUM ERROR", "HARDWARE ERROR", "ILLEGAL REQUEST", "UNIT ATTENTION", "DATA PROTECT", "BLANK CHECK", "VENDOR SPECIFIC", "COPY ABORTED", "ABORTED COMMAND", "EQUAL", "VOLUME OVERFLOW", "MISCOMPARE", "??? - SENSE 0FH" }; /* --------------------------------------------------------------------------------------------------------- */ static char *scanner_error_str[] = {"no error", /* 0 */ "CPU error", "err 2", "err 3", "ROM error", "err 5", "err 6", "err 7", "err 8", "err 9", "buffer error", /* 10 */ "system buffer error", "shading buffer error", "video buffer error", "stack buffer error", "control buffer error", "gamma buffer error", "err 17", "err 18", "err 19", "lamp error", /* 20 */ "dark error", "dim error", "light error", "lamp adjust control error (by darken)", "err 25", "err 26", "err 27", "err 28", "err 29", "calibration error", /* 30 */ "dc offset error", "gain error", "auto focus error", "err 34", "err 35", "err 36", "err 37", "err 38", "err 39", "scsi error", /* 40 */ "err 41", "asic error", "timer error", "ccd error", "err 45", "err 46", "err 47", "err 48", "err 49", "uta error", /* 50 */ "uta home or motor sensor error", "err 52", "err 53", "err 54", "err 55", "err 56", "err 57", "err 58", "err 59", "adf error", /* 60 */ "adf paper jam", "adf no paper", "adf cover open", "err 64", "err 65", "err 66", "err 67", "err 68", "err 69", "fb sensor error", /* 70 */ "fb home or motor sensor error", "fb filter or motor sensor error", "fb lens or motor sensor error" "first line position error (LER error, vertical)", "first pixel position error (SER error, horizontal)", "first pixel position error for lens 2 (SER2 error, horizontal)", "err 77", "err 78", "err 79", "err", /* 80 */ "err", "err", "err", "err", "err", "err", "err", "err", "err", "err", /* 90 */ "err", "err", "err", "err", "err", "err", "err", "err", "err" /* 99 */ }; /* --------------------------------------------------------------------------------------------------------- */ #endif sane-backends-1.0.29/backend/leo.conf.in0000666000000000000000000000016013615534521014620 00000000000000# The FS-1130 respond to all luns scsi ACROSS * Scanner * * * 0 # LEO S3 scsi "LEO" "LEOScan-S3" /dev/scanner sane-backends-1.0.29/backend/canon_dr-cmd.h0000666000000000000000000005350513615534521015275 00000000000000#ifndef CANON_DR_CMD_H #define CANON_DR_CMD_H /* * Part of SANE - Scanner Access Now Easy. * Please see opening comments in canon_dr.c */ /****************************************************/ #define USB_HEADER_LEN 12 #define USB_COMMAND_LEN 12 #define USB_STATUS_LEN 4 #define USB_COMMAND_TIME 30000 #define USB_DATA_TIME 30000 #define USB_STATUS_TIME 30000 /*static inline void */ static void setbitfield (unsigned char *pageaddr, int mask, int shift, int val) { *pageaddr = (*pageaddr & ~(mask << shift)) | ((val & mask) << shift); } /* ------------------------------------------------------------------------- */ /*static inline int */ static int getbitfield (unsigned char *pageaddr, int mask, int shift) { return ((*pageaddr >> shift) & mask); } /* ------------------------------------------------------------------------- */ static int getnbyte (unsigned char *pnt, int nbytes) { unsigned int result = 0; int i; #ifdef DEBUG assert (nbytes < 5); #endif for (i = 0; i < nbytes; i++) result = (result << 8) | (pnt[i] & 0xff); return result; } /* ------------------------------------------------------------------------- */ /*static inline void */ static void putnbyte (unsigned char *pnt, unsigned int value, unsigned int nbytes) { int i; #ifdef DEBUG assert (nbytes < 5); #endif for (i = nbytes - 1; i >= 0; i--) { pnt[i] = value & 0xff; value = value >> 8; } } /* ==================================================================== */ /* extended status packet */ #define get_ES_length(b) getnbyte(b+0x04, 4) /* ==================================================================== */ /* SCSI commands */ #define set_SCSI_opcode(out, val) out[0]=val #define set_SCSI_lun(out, val) setbitfield(out + 1, 7, 5, val) /* ==================================================================== */ /* TEST_UNIT_READY */ #define TEST_UNIT_READY_code 0x00 #define TEST_UNIT_READY_len 6 /* ==================================================================== */ /* REQUEST_SENSE */ #define REQUEST_SENSE_code 0x03 #define REQUEST_SENSE_len 6 #define RS_return_size 0x0e #define set_RS_return_size(icb,val) icb[0x04]=val /* defines for request sense return block */ #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7) #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0) #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7) #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6) #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5) #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0) #define get_RS_information(b) getnbyte(b+0x03, 4) /* normally 0 */ #define get_RS_additional_length(b) b[0x07] /* always 6? */ #define get_RS_ASC(b) b[0x0c] #define get_RS_ASCQ(b) b[0x0d] #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /* valid=0 */ #define get_RS_SKSB(b) getnbyte(b+0x0f, 3) /* when RS is 0x05/0x26 bad bytes listed in sksb */ /* #define get_RS_offending_byte(b) getnbyte(b+0x10, 2) */ /* ==================================================================== */ /* INQUIRY */ #define INQUIRY_code 0x12 #define INQUIRY_len 6 #define INQUIRY_std_len 0x30 #define INQUIRY_vpd_len 0x1e #define set_IN_evpd(icb, val) setbitfield(icb + 1, 1, 0, val) #define set_IN_page_code(icb, val) icb[0x02]=val #define set_IN_return_size(icb,val) icb[0x04]=val #define get_IN_periph_qual(in) getbitfield(in, 0x07, 5) #define IN_periph_qual_lun 0x00 #define IN_periph_qual_nolun 0x03 #define get_IN_periph_devtype(in) getbitfield(in, 0x1f, 0) #define IN_periph_devtype_scanner 0x06 #define IN_periph_devtype_unknown 0x1f #define get_IN_response_format(in) getbitfield(in + 0x03, 0x07, 0) #define IN_recognized 0x02 #define get_IN_vendor(in, buf) strncpy(buf, (char *)in + 0x08, 0x08) #define get_IN_product(in, buf) strncpy(buf, (char *)in + 0x10, 0x010) #define get_IN_version(in, buf) strncpy(buf, (char *)in + 0x20, 0x04) /* the VPD response */ #define get_IN_page_length(in) in[0x04] #define get_IN_basic_x_res(in) getnbyte(in + 0x05, 2) #define get_IN_basic_y_res(in) getnbyte(in + 0x07, 2) #define get_IN_step_x_res(in) getbitfield(in+0x09, 1, 0) #define get_IN_step_y_res(in) getbitfield(in+0x09, 1, 4) #define get_IN_max_x_res(in) getnbyte(in + 0x0a, 2) #define get_IN_max_y_res(in) getnbyte(in + 0x0c, 2) #define get_IN_min_x_res(in) getnbyte(in + 0x0e, 2) #define get_IN_min_y_res(in) getnbyte(in + 0x10, 2) #define get_IN_std_res_60(in) getbitfield(in+ 0x12, 1, 7) #define get_IN_std_res_75(in) getbitfield(in+ 0x12, 1, 6) #define get_IN_std_res_100(in) getbitfield(in+ 0x12, 1, 5) #define get_IN_std_res_120(in) getbitfield(in+ 0x12, 1, 4) #define get_IN_std_res_150(in) getbitfield(in+ 0x12, 1, 3) #define get_IN_std_res_160(in) getbitfield(in+ 0x12, 1, 2) #define get_IN_std_res_180(in) getbitfield(in+ 0x12, 1, 1) #define get_IN_std_res_200(in) getbitfield(in+ 0x12, 1, 0) #define get_IN_std_res_240(in) getbitfield(in+ 0x13, 1, 7) #define get_IN_std_res_300(in) getbitfield(in+ 0x13, 1, 6) #define get_IN_std_res_320(in) getbitfield(in+ 0x13, 1, 5) #define get_IN_std_res_400(in) getbitfield(in+ 0x13, 1, 4) #define get_IN_std_res_480(in) getbitfield(in+ 0x13, 1, 3) #define get_IN_std_res_600(in) getbitfield(in+ 0x13, 1, 2) #define get_IN_std_res_800(in) getbitfield(in+ 0x13, 1, 1) #define get_IN_std_res_1200(in) getbitfield(in+ 0x13, 1, 0) #define get_IN_window_width(in) getnbyte(in + 0x14, 4) #define get_IN_window_length(in) getnbyte(in + 0x18, 4) #define get_IN_awd(in) getbitfield(in+0x1c, 1, 7) #define get_IN_ce_emphasis(in) getbitfield(in+0x1c, 1, 6) #define get_IN_c_emphasis(in) getbitfield(in+0x1c, 1, 5) #define get_IN_high_quality(in) getbitfield(in+0x1c, 1, 4) #define get_IN_multilevel(in) getbitfield(in+0x1c, 1, 3) #define get_IN_half_tone(in) getbitfield(in+0x1c, 1, 2) #define get_IN_monochrome(in) getbitfield(in+0x1c, 1, 1) #define get_IN_overflow(in) getbitfield(in+0x1c, 1, 0) /* some scanners need evpd inquiry data manipulated */ #define set_IN_page_length(in,val) in[0x04]=val /* ==================================================================== */ /* RESERVE_UNIT */ #define RESERVE_UNIT_code 0x16 #define RESERVE_UNIT_len 6 /* ==================================================================== */ /* RELEASE_UNIT */ #define RELEASE_UNIT_code 0x17 #define RELEASE_UNIT_len 6 /* ==================================================================== */ /* SCAN */ #define SCAN_code 0x1b #define SCAN_len 6 #define set_SC_xfer_length(sb, val) sb[0x04] = (unsigned char)val /* ==================================================================== */ /* SET_WINDOW */ #define SET_WINDOW_code 0x24 #define SET_WINDOW_len 10 #define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) #define SW_header_len 8 #define SW_desc_len 0x2c /* ==================================================================== */ /* GET_WINDOW */ #define GET_WINDOW_code 0x25 #define GET_WINDOW_len 0 /* ==================================================================== */ /* READ/SEND page codes */ #define SR_datatype_image 0x00 #define SR_datatype_lut 0x03 #define SR_datatype_pixelsize 0x80 /*DR-G1130*/ #define SR_datatype_panel 0x84 #define SR_datatype_sensors 0x8b #define SR_datatype_counters 0x8c #define SR_datatype_endorser 0x90 #define SR_datatype_fineoffset 0x90 #define SR_datatype_finegain 0x91 /* ==================================================================== */ /* READ */ #define READ_code 0x28 #define READ_len 10 #define set_R_datatype_code(sb, val) sb[0x02] = val #define set_R_xfer_uid(sb, val) sb[4] = val #define set_R_xfer_lid(sb, val) sb[5] = val #define set_R_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3) /*image needs no macros?*/ /*lut unread?*/ /*panel*/ #define R_PANEL_len 0x08 #define get_R_PANEL_start(in) getbitfield(in, 1, 7) #define get_R_PANEL_stop(in) getbitfield(in, 1, 6) #define get_R_PANEL_butt3(in) getbitfield(in, 1, 2) #define get_R_PANEL_new_file(in) getbitfield(in+1, 1, 0) #define get_R_PANEL_count_only(in) getbitfield(in+1, 1, 1) #define get_R_PANEL_bypass_mode(in) getbitfield(in+1, 1, 2) #define get_R_PANEL_enable_led(in) getbitfield(in+2, 1, 0) #define get_R_PANEL_counter(in) getnbyte(in + 0x04, 4) /*sensors*/ #define R_SENSORS_len 0x01 #define get_R_SENSORS_card(in) getbitfield(in, 1, 3) #define get_R_SENSORS_adf(in) getbitfield(in, 1, 0) /*counters*/ #define R_COUNTERS_len 0x80 #define get_R_COUNTERS_scans(in) getnbyte(in + 0x04, 4) /*endorser unread?*/ /*fine gain*/ #define R_FINE_uid_gray 0x07 #define R_FINE_uid_red 0x0c #define R_FINE_uid_green 0x0a #define R_FINE_uid_blue 0x09 #define R_FINE_uid_unknown 0x14 /* get pixel size */ #define R_PSIZE_len 16 #define get_R_PSIZE_width(in) getnbyte(in + 0x08, 4) #define get_R_PSIZE_length(in) getnbyte(in + 0x0c, 4) /* ==================================================================== */ /* SEND */ #define SEND_code 0x2a #define SEND_len 10 #define set_S_xfer_datatype(sb, val) sb[0x02] = (unsigned char)val #define set_S_xfer_id(sb, val) putnbyte(sb + 4, val, 2) #define set_S_xfer_length(sb, val) putnbyte(sb + 6, val, 3) /*lut*/ #define S_LUT_len 0x100 #define S_LUT_id_front 0x82 #define S_LUT_id_unk1 0x84 #define S_LUT_id_unk2 0x88 #define S_LUT_id_unk3 0x90 /*panel*/ #define S_PANEL_len 0x08 #define set_S_PANEL_enable_led(in,val) setbitfield(in+2, 1, 0, val) #define set_S_PANEL_counter(sb,val) putnbyte(sb + 0x04, val, 4) /*counters*/ /*endorser*/ /* ==================================================================== */ /* OBJECT_POSITION */ #define OBJECT_POSITION_code 0x31 #define OBJECT_POSITION_len 10 #define set_OP_autofeed(b,val) setbitfield(b+0x01, 0x07, 0, val) #define OP_Discharge 0x00 #define OP_Feed 0x01 /* ==================================================================== */ /* Page codes used by GET/SET SCAN MODE */ #define SM_pc_adf 0x01 #define SM_pc_tpu 0x02 #define SM_pc_scan_ctl 0x20 #define SM_pc_df 0x30 #define SM_pc_buffer 0x32 #define SM_pc_imprinter 0x34 #define SM_pc_dropout 0x36 #define SM_pc_unknown 0x37 #define SM_pc_all_pc 0x3F /* ==================================================================== */ /* GET SCAN MODE */ #define GET_SCAN_MODE_code 0xd5 #define GET_SCAN_MODE_len 6 #define set_GSM_unknown(sb, val) sb[0x01] = val #define set_GSM_page_code(sb, val) sb[0x02] = val #define set_GSM_len(sb, val) sb[0x04] = val #define GSM_PSIZE_len 0x5a /* ==================================================================== */ /* SET SCAN MODE */ #define SET_SCAN_MODE_code 0xd6 #define SET_SCAN_MODE_len 6 #define set_SSM_pf(sb, val) setbitfield(sb + 1, 1, 4, val) #define set_SSM_pay_len(sb, val) sb[0x04] = val /* the payload */ #define SSM_PAY_len 0x14 #define SSM_PAY_HEAD_len 0x13 #define set_SSM_pay_head_len(sb, val) sb[0x01] = val #define set_SSM_page_code(sb, val) sb[0x04] = val #define SSM_PAGE_len 0x0e #define set_SSM_page_len(sb, val) sb[0x05] = val /* for DF (0x30) page */ #define set_SSM_DF_deskew_roll(sb, val) setbitfield(sb+7, 1, 5, val) #define set_SSM_DF_staple(sb, val) setbitfield(sb+7, 1, 4, val) #define set_SSM_DF_thick(sb, val) setbitfield(sb+7, 1, 2, val) #define set_SSM_DF_len(sb, val) setbitfield(sb+7, 1, 0, val) #define set_SSM_DF_textdir(sb, val) setbitfield(sb+9, 0xf, 0, val) /* for BUFFER (0x32) page */ #define set_SSM_BUFF_duplex(sb, val) setbitfield(sb+6, 1, 1, val) #define set_SSM_BUFF_unk(sb, val) sb[0x07] = val #define set_SSM_BUFF_async(sb, val) setbitfield(sb+0x0a, 1, 6, val) #define set_SSM_BUFF_ald(sb, val) setbitfield(sb+0x0a, 1, 5, val) #define set_SSM_BUFF_fb(sb, val) setbitfield(sb+0x0a, 1, 4, val) #define set_SSM_BUFF_card(sb, val) setbitfield(sb+0x0a, 1, 3, val) /* for DO (0x36) page */ #define SSM_DO_none 0 #define SSM_DO_red 1 #define SSM_DO_green 2 #define SSM_DO_blue 3 #define set_SSM_DO_unk1(sb, val) sb[0x07] = val #define set_SSM_DO_unk2(sb, val) sb[0x09] = val #define set_SSM_DO_f_do(sb, val) sb[0x0b] = val #define set_SSM_DO_b_do(sb, val) sb[0x0c] = val #define set_SSM_DO_f_en(sb, val) sb[0x0d] = val #define set_SSM_DO_b_en(sb, val) sb[0x0e] = val /* ==================================================================== */ /* Cancel */ #define CANCEL_code 0xd8 #define CANCEL_len 6 /* ==================================================================== */ /* Coarse Calibration */ #define COR_CAL_code 0xe1 #define COR_CAL_len 10 #define set_CC_version(sb, val) sb[5] = val #define set_CC_xferlen(sb, len) putnbyte(sb + 0x06, len, 3) /* the payload */ #define CC_pay_len 0x20 #define CC_pay_ver 0x00 #define set_CC_f_gain(sb, val) sb[0] = val #define set_CC_unk1(sb, val) sb[1] = val #define set_CC_f_offset(sb, val) sb[2] = val #define set_CC_unk2(sb, val) sb[3] = val #define set_CC_exp_f_r1(sb, val) putnbyte(sb + 0x04, val, 2) #define set_CC_exp_f_g1(sb, val) putnbyte(sb + 0x06, val, 2) #define set_CC_exp_f_b1(sb, val) putnbyte(sb + 0x08, val, 2) #define set_CC_exp_f_r2(sb, val) putnbyte(sb + 0x0a, val, 2) #define set_CC_exp_f_g2(sb, val) putnbyte(sb + 0x0c, val, 2) #define set_CC_exp_f_b2(sb, val) putnbyte(sb + 0x0e, val, 2) #define set_CC_b_gain(sb, val) sb[0x10] = val #define set_CC_b_offset(sb, val) sb[0x12] = val #define set_CC_exp_b_r1(sb, val) putnbyte(sb + 0x14, val, 2) #define set_CC_exp_b_g1(sb, val) putnbyte(sb + 0x16, val, 2) #define set_CC_exp_b_b1(sb, val) putnbyte(sb + 0x18, val, 2) #define set_CC_exp_b_r2(sb, val) putnbyte(sb + 0x1a, val, 2) #define set_CC_exp_b_g2(sb, val) putnbyte(sb + 0x1c, val, 2) #define set_CC_exp_b_b2(sb, val) putnbyte(sb + 0x1e, val, 2) /* the 'version 3' payload (P-208 and P-215) */ #define CC3_pay_len 0x28 #define CC3_pay_ver 0x03 #define set_CC3_gain_f_r(sb, val) sb[0] = val #define set_CC3_gain_f_g(sb, val) sb[1] = val #define set_CC3_gain_f_b(sb, val) sb[2] = val #define set_CC3_off_f_r(sb, val) sb[4] = val #define set_CC3_off_f_g(sb, val) sb[5] = val #define set_CC3_off_f_b(sb, val) sb[6] = val #define set_CC3_exp_f_r(sb, val) putnbyte(sb + 0x08, val, 2) #define set_CC3_exp_f_g(sb, val) putnbyte(sb + 0x0a, val, 2) #define set_CC3_exp_f_b(sb, val) putnbyte(sb + 0x0c, val, 2) #define set_CC3_gain_b_r(sb, val) sb[0x14] = val #define set_CC3_gain_b_g(sb, val) sb[0x15] = val #define set_CC3_gain_b_b(sb, val) sb[0x16] = val #define set_CC3_off_b_r(sb, val) sb[0x18] = val #define set_CC3_off_b_g(sb, val) sb[0x19] = val #define set_CC3_off_b_b(sb, val) sb[0x1a] = val #define set_CC3_exp_b_r(sb, val) putnbyte(sb + 0x1c, val, 2) #define set_CC3_exp_b_g(sb, val) putnbyte(sb + 0x1e, val, 2) #define set_CC3_exp_b_b(sb, val) putnbyte(sb + 0x20, val, 2) /* ==================================================================== */ /* Page codes used by GET/SET SCAN MODE 2 */ #define SM2_pc_df 0x00 #define SM2_pc_ultra 0x01 #define SM2_pc_buffer 0x02 #define SM2_pc_hw_enhancement 0x03 #define SM2_pc_dropout 0x06 /* ==================================================================== */ /* SET SCAN MODE 2 */ #define SET_SCAN_MODE2_code 0xe5 #define SET_SCAN_MODE2_len 12 #define set_SSM2_page_code(sb, val) sb[0x02] = val #define set_SSM2_pay_len(sb, val) sb[0x08] = val /* the payload */ #define SSM2_PAY_len 0x10 /* for DF (0x00) page */ #define set_SSM2_DF_thick(sb, val) setbitfield(sb+3, 1, 2, val) #define set_SSM2_DF_len(sb, val) setbitfield(sb+3, 1, 0, val) #define set_SSM2_DF_staple(sb, val) setbitfield(sb+3, 1, 4, val) /* for ULTRA (0x01) page */ #define set_SSM2_ULTRA_top(sb, val) putnbyte(sb + 0x07, val, 2) #define set_SSM2_ULTRA_bot(sb, val) putnbyte(sb + 0x09, val, 2) /* for BUFFER (0x02) page */ #define set_SSM2_BUFF_unk(sb, val) sb[0x03] = val #define set_SSM2_BUFF_unk2(sb, val) sb[0x06] = val #define set_SSM2_BUFF_sync(sb, val) sb[0x09] = val /* for HARDWARE ENHANCEMENT (0x03) */ #define set_SSM2_roller_deskew(sb, val) setbitfield(sb+6, 1, 3, val) #define set_SSM2_hw_crop(sb, val) setbitfield(sb+6, 1, 5, val) /* for DROPOUT (0x06) page */ #define set_SSM2_DO_do(sb, val) sb[0x09] = val #define set_SSM2_DO_en(sb, val) sb[0x0a] = val #define set_SSM2_DO_side(sb, val) sb[0x05] = val /* ==================================================================== */ /* window descriptor macros for SET_WINDOW and GET_WINDOW */ #define set_WPDB_wdblen(sb, len) putnbyte(sb + 0x06, len, 2) /* ==================================================================== */ /* 0x00 - Window Identifier */ #define set_WD_wid(sb, val) sb[0] = val #define WD_wid_front 0x00 #define WD_wid_back 0x01 /* 0x01 - Reserved (bits 7-1), AUTO (bit 0) */ #define set_WD_auto(sb, val) setbitfield(sb + 0x01, 1, 0, val) #define get_WD_auto(sb) getbitfield(sb + 0x01, 1, 0) /* 0x02,0x03 - X resolution in dpi */ #define set_WD_Xres(sb, val) putnbyte(sb + 0x02, val, 2) #define get_WD_Xres(sb) getnbyte(sb + 0x02, 2) /* 0x04,0x05 - Y resolution in dpi */ #define set_WD_Yres(sb, val) putnbyte(sb + 0x04, val, 2) #define get_WD_Yres(sb) getnbyte(sb + 0x04, 2) /* 0x06-0x09 - Upper Left X in 1/1200 inch */ #define set_WD_ULX(sb, val) putnbyte(sb + 0x06, val, 4) #define get_WD_ULX(sb) getnbyte(sb + 0x06, 4) /* 0x0a-0x0d - Upper Left Y in 1/1200 inch */ #define set_WD_ULY(sb, val) putnbyte(sb + 0x0a, val, 4) #define get_WD_ULY(sb) getnbyte(sb + 0x0a, 4) /* 0x0e-0x11 - Width in 1/1200 inch */ #define set_WD_width(sb, val) putnbyte(sb + 0x0e, val, 4) #define get_WD_width(sb) getnbyte(sb + 0x0e, 4) /* 0x12-0x15 - Height in 1/1200 inch */ #define set_WD_length(sb, val) putnbyte(sb + 0x12, val, 4) #define get_WD_length(sb) getnbyte(sb + 0x12, 4) /* 0x16 - Brightness */ #define set_WD_brightness(sb, val) sb[0x16] = val #define get_WD_brightness(sb) sb[0x16] /* 0x17 - Threshold */ #define set_WD_threshold(sb, val) sb[0x17] = val #define get_WD_threshold(sb) sb[0x17] /* 0x18 - Contrast */ #define set_WD_contrast(sb, val) sb[0x18] = val #define get_WD_contrast(sb) sb[0x18] /* 0x19 - Image Composition (color mode) */ #define set_WD_composition(sb, val) sb[0x19] = val #define get_WD_composition(sb) sb[0x19] #define WD_comp_LA 0 #define WD_comp_HT 1 #define WD_comp_GS 2 #define WD_comp_CL 3 #define WD_comp_CH 4 #define WD_comp_CG 5 /* 0x1a - Depth */ #define set_WD_bitsperpixel(sb, val) sb[0x1a] = val #define get_WD_bitsperpixel(sb) sb[0x1a] /* 0x1b,0x1c - Halftone Pattern */ #define set_WD_ht_type(sb, val) sb[0x1b] = val #define get_WD_ht_type(sb) sb[0x1b] #define WD_ht_type_DEFAULT 0 #define WD_ht_type_DITHER 1 #define WD_ht_type_DIFFUSION 2 #define set_WD_ht_pattern(sb, val) sb[0x1c] = val #define get_WD_ht_pattern(sb) sb[0x1c] /* 0x1d - Reverse image, reserved area, padding type */ #define set_WD_rif(sb, val) setbitfield(sb + 0x1d, 1, 7, val) #define get_WD_rif(sb) getbitfield(sb + 0x1d, 1, 7) #define set_WD_rgb(sb, val) setbitfield(sb + 0x1d, 7, 4, val) #define get_WD_rgb(sb) getbitfield(sb + 0x1d, 7, 4) #define set_WD_padding(sb, val) setbitfield(sb + 0x1d, 7, 0, val) #define get_WD_padding(sb) getbitfield(sb + 0x1d, 7, 0) /* 0x1e,0x1f - Bit ordering */ #define set_WD_bitorder(sb, val) putnbyte(sb + 0x1e, val, 2) #define get_WD_bitorder(sb) getnbyte(sb + 0x1e, 2) /* 0x20 - compression type */ #define set_WD_compress_type(sb, val) sb[0x20] = val #define get_WD_compress_type(sb) sb[0x20] #define WD_cmp_NONE 0 #define WD_cmp_MH 1 #define WD_cmp_MR 2 #define WD_cmp_MMR 3 #define WD_cmp_JPEG 0x80 /* 0x21 - compression argument * specify "k" parameter with MR compress, * or with JPEG- Q param, 0-7 */ #define set_WD_compress_arg(sb, val) sb[0x21] = val #define get_WD_compress_arg(sb) sb[0x21] /* 0x22-0x27 - reserved */ /* 0x28-0x2c - vendor unique */ /* FIXME: more params here? */ #define set_WD_reserved2(sb, val) sb[0x2a] = val #define get_WD_reserved2(sb) sb[0x2a] /* ==================================================================== */ #endif sane-backends-1.0.29/backend/gt68xx_gt6801.h0000666000000000000000000000517413615534521015131 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002 Sergey Vlasov GT6801 support by Andreas Nowack 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef GT68XX_GT6801_H #define GT68XX_GT6801_H static SANE_Status gt6801_check_firmware (GT68xx_Device * dev, SANE_Bool * loaded); static SANE_Status gt6801_check_plustek_firmware (GT68xx_Device * dev, SANE_Bool * loaded); static SANE_Status gt6801_download_firmware (GT68xx_Device * dev, SANE_Byte * data, SANE_Word size); static SANE_Status gt6801_get_power_status (GT68xx_Device * dev, SANE_Bool * power_ok); static SANE_Status gt6801_lamp_control (GT68xx_Device * dev, SANE_Bool fb_lamp, SANE_Bool ta_lamp); static SANE_Status gt6801_is_moving (GT68xx_Device * dev, SANE_Bool * moving); static SANE_Status gt6801_carriage_home (GT68xx_Device * dev); static SANE_Status gt6801_stop_scan (GT68xx_Device * dev); #endif /* not GT68XX_GT6801_H */ sane-backends-1.0.29/backend/v4l.conf.in0000666000000000000000000000031413615534521014547 00000000000000# # In order to use the v4linux backend you have to give the device # You can enable multiple lines if # you really have multible v4l devices. # /dev/bttv0 /dev/video0 /dev/video1 /dev/video2 /dev/video3 sane-backends-1.0.29/backend/sharp.conf.in0000666000000000000000000000266213615534521015167 00000000000000# The options are only meaningful if the backend was # compiled with USE_FORK defined # # option buffersize: size of one buffer allocated as shared # memory for data transfer between the reader process # and the parent process # option buffers: number of these buffers # The minimum is 2 # option readqueue: number of queued read requests. This is # with the current SANE version (1.01) only useful for # Linux, since queued read requests are not supported # for other operating systems. # # For Linux, a value of 2 is recommended, at least if a # JX-250 is used. Bigger values are only a waste of memory. # # For other operationg systems, set this value to zero # # option stop_on_fsu_error: should be 0 or 1. If set to 0, # the "FSU light dispersion error" does not cause the abortion # of a scan. # # option default_scan_source: valid values are "auto", "fsu", "adf" # and "flatbed". For "auto", the backend will enable an ADF or # or FSU, if installed. # # global options: option buffers 4 option buffersize 131072 option readqueue 2 option stop_on_fsu_error 1 option default_scan_source auto # look for all devices with vendor ID "SHARP" and type "Scanner" scsi SHARP * Scanner # no options specific to these devices listed -> use global options /dev/scanner # options specific to /dev/scanner option buffers 6 option buffersize 262144 option readqueue 2 # example for another (Linux) device name: #/dev/sg1 sane-backends-1.0.29/backend/pixma/0000755000000000000000000000000013615535552013767 500000000000000sane-backends-1.0.29/backend/pixma/pixma.c0000666000000000000000000016140613615534521015200 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2007-2008 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "../include/sane/config.h" #include #include #include #ifdef USE_PTHREAD # include #endif #include /* sigaction(POSIX) */ #include /* POSIX: write read close pipe */ #ifdef HAVE_FCNTL_H # include #endif #include "pixma_rename.h" #include "pixma.h" # define DEBUG_NOT_STATIC # include "../include/sane/sane.h" # include "../include/sane/sanei.h" # include "../include/sane/saneopts.h" # include "../include/sane/sanei_thread.h" # include "../include/sane/sanei_backend.h" # include "../include/sane/sanei_config.h" # include "../include/sane/sanei_jpeg.h" #ifdef NDEBUG # define PDBG(x) #else # define PDBG(x) IF_DBG(x) #endif /* NDEBUG */ #ifdef __GNUC__ # define UNUSED(v) (void) v #else # define UNUSED(v) #endif #define DECL_CTX pixma_sane_t *ss = check_handle(h) #define OPT_IN_CTX ss->opt #define SOD(opt) OPT_IN_CTX[opt].sod #define OVAL(opt) OPT_IN_CTX[opt].val #define AUTO_GAMMA 2.2 /* pixma_sane_options.h generated by * scripts/pixma_gen_options.py h < pixma.c > pixma_sane_options.h */ #include "pixma_sane_options.h" #define BUTTON_GROUP_SIZE ( opt_scan_resolution - opt_button_1 + 1 ) #define BUTTON_GROUP_INDEX(x) ( x - opt_button_1 ) typedef struct pixma_sane_t { struct pixma_sane_t *next; pixma_t *s; pixma_scan_param_t sp; SANE_Bool cancel; /* valid states: idle, !idle && scanning, !idle && !scanning */ SANE_Bool idle; SANE_Bool scanning; SANE_Status last_read_status; /* valid if !idle && !scanning */ option_descriptor_t opt[opt_last]; char button_option_is_cached[BUTTON_GROUP_SIZE]; SANE_Range xrange, yrange; SANE_Word dpi_list[9]; /* up to 9600 dpi */ SANE_String_Const mode_list[6]; pixma_scan_mode_t mode_map[6]; uint8_t gamma_table[4096]; SANE_String_Const source_list[4]; pixma_paper_source_t source_map[4]; unsigned byte_pos_in_line, output_line_size; uint64_t image_bytes_read; unsigned page_count; /* valid for ADF */ SANE_Pid reader_taskid; int wpipe, rpipe; SANE_Bool reader_stop; /* Valid for JPEG source */ djpeg_dest_ptr jdst; struct jpeg_decompress_struct jpeg_cinfo; struct jpeg_error_mgr jpeg_err; SANE_Bool jpeg_header_seen; } pixma_sane_t; typedef struct { struct jpeg_source_mgr jpeg; pixma_sane_t *s; JOCTET *buffer; SANE_Byte *linebuffer; SANE_Int linebuffer_size; SANE_Int linebuffer_index; } pixma_jpeg_src_mgr; static const char vendor_str[] = "CANON"; static const char type_str[] = "multi-function peripheral"; static pixma_sane_t *first_scanner = NULL; static const SANE_Device **dev_list = NULL; static const char* conf_devices[MAX_CONF_DEVICES]; static void mark_all_button_options_cached ( struct pixma_sane_t * ss ) { int i; for (i = 0; i < (opt__group_5 - opt_button_1); i++ ) ss -> button_option_is_cached[i] = 1; } static SANE_Status config_attach_pixma(SANEI_Config * config, const char *devname) { int i; UNUSED(config); for (i=0; i < (MAX_CONF_DEVICES -1); i++) { if(conf_devices[i] == NULL) { conf_devices[i] = strdup(devname); return SANE_STATUS_GOOD; } } return SANE_STATUS_INVAL; } static SANE_Status map_error (int error) { if (error >= 0) return SANE_STATUS_GOOD; switch (error) { case PIXMA_ENOMEM: return SANE_STATUS_NO_MEM; case PIXMA_ECANCELED: return SANE_STATUS_CANCELLED; case PIXMA_EBUSY: return SANE_STATUS_DEVICE_BUSY; case PIXMA_EINVAL: return SANE_STATUS_INVAL; case PIXMA_EACCES: return SANE_STATUS_ACCESS_DENIED; case PIXMA_EPAPER_JAMMED: return SANE_STATUS_JAMMED; case PIXMA_ENO_PAPER: return SANE_STATUS_NO_DOCS; case PIXMA_ECOVER_OPEN: return SANE_STATUS_COVER_OPEN; case PIXMA_ENOTSUP: return SANE_STATUS_UNSUPPORTED; case PIXMA_EPROTO: case PIXMA_ENODEV: case PIXMA_EIO: case PIXMA_ETIMEDOUT: return SANE_STATUS_IO_ERROR; } PDBG (pixma_dbg (1, "BUG: unmapped error %d\n", error)); return SANE_STATUS_IO_ERROR; } static int getenv_atoi (const char *name, int def) { const char *str = getenv (name); return (str) ? atoi (str) : def; } #define CONST_CAST(t,x) (t)(x) static void free_block (const void * ptr) { free (CONST_CAST (void *, ptr)); } static void cleanup_device_list (void) { if (dev_list) { int i; for (i = 0; dev_list[i]; i++) { free_block ((const void *) dev_list[i]->name); free_block ((const void *) dev_list[i]->model); free_block ((const void *) dev_list[i]); } } free (dev_list); dev_list = NULL; } static void find_scanners (SANE_Bool local_only) { unsigned i, nscanners; cleanup_device_list (); nscanners = pixma_find_scanners (conf_devices, local_only); PDBG (pixma_dbg (3, "pixma_find_scanners() found %u devices\n", nscanners)); dev_list = (const SANE_Device **) calloc (nscanners + 1, sizeof (*dev_list)); if (!dev_list) return; for (i = 0; i != nscanners; i++) { SANE_Device *sdev = (SANE_Device *) calloc (1, sizeof (*sdev)); char *name, *model; if (!sdev) goto nomem; name = strdup (pixma_get_device_id (i)); model = strdup (pixma_get_device_model (i)); if (!name || !model) { free (name); free (model); free (sdev); goto nomem; } sdev->name = name; sdev->model = model; sdev->vendor = vendor_str; sdev->type = type_str; dev_list[i] = sdev; } /* dev_list is already NULL terminated by calloc(). */ return; nomem: PDBG (pixma_dbg (1, "WARNING:not enough memory for device list\n")); return; } static pixma_sane_t * check_handle (SANE_Handle h) { pixma_sane_t *p; for (p = first_scanner; p && (SANE_Handle) p != h; p = p->next) { } return p; } static void update_button_state (pixma_sane_t * ss, SANE_Int * info) { SANE_Int b1 = OVAL (opt_button_1).w; SANE_Int b2 = OVAL (opt_button_2).w; uint32_t ev = pixma_wait_event (ss->s, 300); switch (ev & ~PIXMA_EV_ACTION_MASK) { case PIXMA_EV_BUTTON1: b1 = 1; break; case PIXMA_EV_BUTTON2: b2 = 1; break; } if (b1 != OVAL (opt_button_1).w || b2 != OVAL (opt_button_2).w) { *info |= SANE_INFO_RELOAD_OPTIONS; OVAL (opt_button_1).w = b1; OVAL (opt_button_2).w = b2; OVAL (opt_original).w = GET_EV_ORIGINAL(ev); OVAL (opt_target).w = GET_EV_TARGET(ev); OVAL (opt_scan_resolution).w = GET_EV_DPI(ev); } mark_all_button_options_cached(ss); } static SANE_Bool enable_option (pixma_sane_t * ss, SANE_Int o, SANE_Bool enable) { SANE_Word save = SOD (o).cap; if (enable) SOD (o).cap &= ~SANE_CAP_INACTIVE; else SOD (o).cap |= SANE_CAP_INACTIVE; return (save != SOD (o).cap); } static void clamp_value (pixma_sane_t * ss, SANE_Int n, void *v, SANE_Int * info) { SANE_Option_Descriptor *sod = &SOD (n); SANE_Word *va = (SANE_Word *) v; const SANE_Range *range = sod->constraint.range; int i, nmemb; nmemb = sod->size / sizeof (SANE_Word); for (i = 0; i < nmemb; i++) { SANE_Word value = va[i]; if (value < range->min) { value = range->min; } else if (value > range->max) { value = range->max; } if (range->quant != 0) { value = (value - range->min + range->quant / 2) / range->quant * range->quant; } if (value != va[i]) { va[i] = value; *info |= SANE_INFO_INEXACT; } } } /* create dynamic mode_list * ss: scanner device * tpu = 0: flatbed or ADF mode * 1 bit lineart, 8 bit grayscale and 24 bit color scans * tpu = 1: TPU mode * 16 bit grayscale and 48 bit color scans */ static void create_mode_list (pixma_sane_t * ss) { SANE_Bool tpu; const pixma_config_t *cfg; int i; cfg = pixma_get_config (ss->s); tpu = (ss->source_map[OVAL (opt_source).w] == PIXMA_SOURCE_TPU); /* setup available mode */ i = 0; ss->mode_list[i] = SANE_VALUE_SCAN_MODE_COLOR; ss->mode_map[i] = PIXMA_SCAN_MODE_COLOR; i++; if (cfg->cap & PIXMA_CAP_GRAY) { ss->mode_list[i] = SANE_VALUE_SCAN_MODE_GRAY; ss->mode_map[i] = PIXMA_SCAN_MODE_GRAY; i++; } if (tpu && (cfg->cap & PIXMA_CAP_NEGATIVE)) { ss->mode_list[i] = SANE_I18N ("Negative color"); ss->mode_map[i] = PIXMA_SCAN_MODE_NEGATIVE_COLOR; i++; if (cfg->cap & PIXMA_CAP_GRAY) { ss->mode_list[i] = SANE_I18N ("Negative gray"); ss->mode_map[i] = PIXMA_SCAN_MODE_NEGATIVE_GRAY; i++; } } if (tpu && (cfg->cap & PIXMA_CAP_TPUIR) == PIXMA_CAP_TPUIR) { ss->mode_list[i] = SANE_I18N ("Infrared"); ss->mode_map[i] = PIXMA_SCAN_MODE_TPUIR; i++; } if (!tpu && (cfg->cap & PIXMA_CAP_48BIT)) { ss->mode_list[i] = SANE_I18N ("48 bits color"); ss->mode_map[i] = PIXMA_SCAN_MODE_COLOR_48; i++; if (cfg->cap & PIXMA_CAP_GRAY) { ss->mode_list[i] = SANE_I18N ("16 bits gray"); ss->mode_map[i] = PIXMA_SCAN_MODE_GRAY_16; i++; } } if (!tpu && (cfg->cap & PIXMA_CAP_LINEART)) { ss->mode_list[i] = SANE_VALUE_SCAN_MODE_LINEART; ss->mode_map[i] = PIXMA_SCAN_MODE_LINEART; i++; } /* terminate mode_list and mode_map */ ss->mode_list[i] = 0; ss->mode_map[i] = 0; } /* create dynamic dpi_list * ss: scanner device */ static void create_dpi_list (pixma_sane_t * ss) { const pixma_config_t *cfg; int i, j; int min; unsigned min_dpi; unsigned max_dpi; cfg = pixma_get_config (ss->s); /* get min/max dpi */ max_dpi = cfg->xdpi; min_dpi = 75; if (ss->source_map[OVAL (opt_source).w] == PIXMA_SOURCE_TPU && ss->mode_map[OVAL (opt_mode).w] == PIXMA_SCAN_MODE_TPUIR) { /* IR mode */ /*PDBG (pixma_dbg (4, "*create_dpi_list***** TPUIR mode\n"));*/ min_dpi = (cfg->tpuir_min_dpi) ? cfg->tpuir_min_dpi : 75; max_dpi = (cfg->tpuir_max_dpi) ? cfg->tpuir_max_dpi : cfg->xdpi; } else if (ss->source_map[OVAL (opt_source).w] == PIXMA_SOURCE_TPU || ss->source_map[OVAL (opt_source).w] == PIXMA_SOURCE_ADF || ss->source_map[OVAL (opt_source).w] == PIXMA_SOURCE_ADFDUP) { /* ADF / TPU mode */ /*PDBG (pixma_dbg (4, "*create_dpi_list***** ADF/TPU mode\n"));*/ min_dpi = (cfg->adftpu_min_dpi) ? cfg->adftpu_min_dpi : 75; max_dpi = (cfg->adftpu_max_dpi) ? cfg->adftpu_max_dpi : cfg->xdpi; } else if (ss->source_map[OVAL (opt_source).w] == PIXMA_SOURCE_FLATBED && (ss->mode_map[OVAL (opt_mode).w] == PIXMA_SCAN_MODE_COLOR_48 || ss->mode_map[OVAL (opt_mode).w] == PIXMA_SCAN_MODE_GRAY_16)) { /* 48 bits flatbed */ /*PDBG (pixma_dbg (4, "*create_dpi_list***** 48 bits flatbed mode\n"));*/ min_dpi = 150; } /* set j for min. dpi * 75 dpi: j = 0 * 150 dpi: j = 1 \ * 300 dpi: j = 2 |--> from cfg->adftpu_min_dpi or cfg->tpuir_min_dpi * 600 dpi: j = 3 / * */ j = -1; min = min_dpi / 75; do { j++; min >>= 1; } while (min > 0); /* create dpi_list * use j for min. dpi */ i = 0; do { i++; j++; ss->dpi_list[i] = 75 * (1 << (j - 1)); /* 75 x 2^(j-1) */ } while ((unsigned) ss->dpi_list[i] < max_dpi); ss->dpi_list[0] = i; /*PDBG (pixma_dbg (4, "*create_dpi_list***** min_dpi = %d, max_dpi = %d\n", min_dpi, max_dpi));*/ } static void select_value_from_list (pixma_sane_t * ss, SANE_Int n, void *v, SANE_Int * info) { SANE_Option_Descriptor *sod = &SOD (n); SANE_Word *va = (SANE_Word *) v; const SANE_Word *list = sod->constraint.word_list; int i, j, nmemb; nmemb = sod->size / sizeof (SANE_Word); for (i = 0; i < nmemb; i++) { SANE_Word value = va[i]; SANE_Word mindelta = abs (value - list[1]); SANE_Word nearest = list[1]; for (j = 2; j <= list[0]; j++) { SANE_Word delta = abs (value - list[j]); if (delta < mindelta) { mindelta = delta; nearest = list[j]; } if (mindelta == 0) break; } if (va[i] != nearest) { va[i] = nearest; *info |= SANE_INFO_INEXACT; } } } static SANE_Status control_scalar_option (pixma_sane_t * ss, SANE_Int n, SANE_Action a, void *v, SANE_Int * info) { option_descriptor_t *opt = &(OPT_IN_CTX[n]); SANE_Word val; switch (a) { case SANE_ACTION_GET_VALUE: switch (opt->sod.type) { case SANE_TYPE_BOOL: case SANE_TYPE_INT: case SANE_TYPE_FIXED: *(SANE_Word *) v = opt->val.w; break; default: return SANE_STATUS_UNSUPPORTED; } return SANE_STATUS_GOOD; case SANE_ACTION_SET_VALUE: switch (opt->sod.type) { case SANE_TYPE_BOOL: val = *(SANE_Word *) v; if (val != SANE_TRUE && val != SANE_FALSE) return SANE_STATUS_INVAL; opt->val.w = val; break; case SANE_TYPE_INT: case SANE_TYPE_FIXED: if (opt->sod.constraint_type == SANE_CONSTRAINT_RANGE) clamp_value (ss, n, v, info); else if (opt->sod.constraint_type == SANE_CONSTRAINT_WORD_LIST) select_value_from_list (ss, n, v, info); opt->val.w = *(SANE_Word *) v; break; default: return SANE_STATUS_UNSUPPORTED; } *info |= opt->info; return SANE_STATUS_GOOD; case SANE_ACTION_SET_AUTO: switch (opt->sod.type) { case SANE_TYPE_BOOL: case SANE_TYPE_INT: case SANE_TYPE_FIXED: opt->val.w = opt->def.w; break; default: return SANE_STATUS_UNSUPPORTED; } *info |= opt->info; return SANE_STATUS_GOOD; } return SANE_STATUS_UNSUPPORTED; } static SANE_Status control_string_option (pixma_sane_t * ss, SANE_Int n, SANE_Action a, void *v, SANE_Int * info) { option_descriptor_t *opt = &(OPT_IN_CTX[n]); const SANE_String_Const *slist = opt->sod.constraint.string_list; SANE_String str = (SANE_String) v; if (opt->sod.constraint_type == SANE_CONSTRAINT_NONE) { switch (a) { case SANE_ACTION_GET_VALUE: strcpy (str, opt->val.s); break; case SANE_ACTION_SET_AUTO: str = opt->def.s; /* fall through */ case SANE_ACTION_SET_VALUE: strncpy (opt->val.s, str, opt->sod.size - 1); *info |= opt->info; break; } return SANE_STATUS_GOOD; } else { int i; switch (a) { case SANE_ACTION_GET_VALUE: strcpy (str, slist[opt->val.w]); break; case SANE_ACTION_SET_AUTO: str = opt->def.ptr; /* fall through */ case SANE_ACTION_SET_VALUE: i = 0; while (slist[i] && strcasecmp (str, slist[i]) != 0) i++; if (!slist[i]) return SANE_STATUS_INVAL; if (strcmp (slist[i], str) != 0) { strcpy (str, slist[i]); *info |= SANE_INFO_INEXACT; } opt->val.w = i; *info |= opt->info; break; } return SANE_STATUS_GOOD; } } static SANE_Status control_option (pixma_sane_t * ss, SANE_Int n, SANE_Action a, void *v, SANE_Int * info) { int result, i; const pixma_config_t *cfg; SANE_Int dummy; /* info may be null, better to set a dummy here then test everywhere */ if (info == NULL) info = &dummy; cfg = pixma_get_config (ss->s); /* PDBG (pixma_dbg (4, "*control_option***** n = %u, a = %u\n", n, a)); */ /* first deal with options that require special treatment */ result = SANE_STATUS_UNSUPPORTED; switch (n) { case opt_gamma_table: switch (a) { case SANE_ACTION_SET_VALUE: clamp_value (ss, n, v, info); for (i = 0; i != 4096; i++) ss->gamma_table[i] = *((SANE_Int *) v + i); break; case SANE_ACTION_GET_VALUE: for (i = 0; i != 4096; i++) *((SANE_Int *) v + i) = ss->gamma_table[i]; break; case SANE_ACTION_SET_AUTO: pixma_fill_gamma_table (AUTO_GAMMA, ss->gamma_table, sizeof (ss->gamma_table)); break; default: return SANE_STATUS_UNSUPPORTED; } return SANE_STATUS_GOOD; case opt_button_update: if (a == SANE_ACTION_SET_VALUE) { update_button_state (ss, info); return SANE_STATUS_GOOD; } else { return SANE_STATUS_INVAL; } break; case opt_button_1: case opt_button_2: case opt_original: case opt_target: case opt_scan_resolution: /* poll scanner if option is not cached */ if (! ss->button_option_is_cached[ BUTTON_GROUP_INDEX(n) ] ) update_button_state (ss, info); /* mark this option as read */ ss->button_option_is_cached[ BUTTON_GROUP_INDEX(n) ] = 0; } /* now deal with getting and setting of options */ switch (SOD (n).type) { case SANE_TYPE_BOOL: case SANE_TYPE_INT: case SANE_TYPE_FIXED: result = control_scalar_option (ss, n, a, v, info); break; case SANE_TYPE_STRING: result = control_string_option (ss, n, a, v, info); break; case SANE_TYPE_BUTTON: case SANE_TYPE_GROUP: PDBG (pixma_dbg (1, "BUG:control_option():Unhandled option\n")); result = SANE_STATUS_INVAL; break; } if (result != SANE_STATUS_GOOD) return result; /* deal with dependencies between options */ switch (n) { case opt_custom_gamma: if (a == SANE_ACTION_SET_VALUE || a == SANE_ACTION_SET_AUTO) { if (enable_option (ss, opt_gamma_table, OVAL (opt_custom_gamma).b)) *info |= SANE_INFO_RELOAD_OPTIONS; } break; case opt_gamma: if (a == SANE_ACTION_SET_VALUE || a == SANE_ACTION_SET_AUTO) { /* PDBG (pixma_dbg (4, "*control_option***** gamma = %f *\n", SANE_UNFIX (OVAL (opt_gamma).w))); */ pixma_fill_gamma_table (SANE_UNFIX (OVAL (opt_gamma).w), ss->gamma_table, sizeof (ss->gamma_table)); } break; case opt_mode: if (cfg->cap & (PIXMA_CAP_48BIT|PIXMA_CAP_LINEART|PIXMA_CAP_TPUIR) && (a == SANE_ACTION_SET_VALUE || a == SANE_ACTION_SET_AUTO)) { /* new mode selected: Color, Gray, ... */ /* PDBG (pixma_dbg (4, "*control_option***** mode = %u *\n", ss->mode_map[OVAL (opt_mode).w])); */ /* recreate dynamic lists */ create_dpi_list (ss); if (ss->mode_map[OVAL (opt_mode).w] == PIXMA_SCAN_MODE_LINEART) { /* lineart */ enable_option (ss, opt_threshold, SANE_TRUE); enable_option (ss, opt_threshold_curve, SANE_TRUE); } else { /* all other modes */ enable_option (ss, opt_threshold, SANE_FALSE); enable_option (ss, opt_threshold_curve, SANE_FALSE); } *info |= SANE_INFO_RELOAD_OPTIONS; } break; case opt_source: if ((cfg->cap & (PIXMA_CAP_ADF|PIXMA_CAP_ADFDUP|PIXMA_CAP_TPU)) && (a == SANE_ACTION_SET_VALUE || a == SANE_ACTION_SET_AUTO)) { /* new source selected: flatbed, ADF, TPU, ... */ /* to avoid fatal errors, * select first entry of dynamic mode_list * identifiers are unknown here */ OVAL (opt_mode).w = ss->mode_map[0]; /* recreate dynamic lists */ create_mode_list (ss); create_dpi_list (ss); /* to avoid fatal errors, * select first entry of dynamic dpi_list * identifiers are unknown here */ OVAL (opt_resolution).w = ss->dpi_list[1]; if (ss->mode_map[OVAL (opt_mode).w] == PIXMA_SCAN_MODE_LINEART) { /* lineart */ enable_option (ss, opt_threshold, SANE_TRUE); enable_option (ss, opt_threshold_curve, SANE_TRUE); } else { /* all other modes */ 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; } return result; } #ifndef NDEBUG static void print_scan_param (int level, const pixma_scan_param_t * sp) { pixma_dbg (level, "Scan parameters\n"); pixma_dbg (level, " line_size=%"PRIu64" image_size=%"PRIu64" channels=%u depth=%u\n", sp->line_size, sp->image_size, sp->channels, sp->depth); pixma_dbg (level, " dpi=%ux%u offset=(%u,%u) dimension=%ux%u\n", 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 static int calc_scan_param (pixma_sane_t * ss, pixma_scan_param_t * sp) { int x1, y1, x2, y2; int error; memset (sp, 0, sizeof (*sp)); sp->channels = (OVAL (opt_mode).w == 0) ? 3 : 1; sp->depth = (OVAL (opt_mode).w == 2) ? 1 : 8; sp->xdpi = sp->ydpi = OVAL (opt_resolution).w; #define PIXEL(x,dpi) (int)((SANE_UNFIX(x) / 25.4 * (dpi)) + 0.5) x1 = PIXEL (OVAL (opt_tl_x).w, sp->xdpi); x2 = PIXEL (OVAL (opt_br_x).w, sp->xdpi); if (x2 < x1) { int temp = x1; x1 = x2; x2 = temp; } y1 = PIXEL (OVAL (opt_tl_y).w, sp->ydpi); y2 = PIXEL (OVAL (opt_br_y).w, sp->ydpi); if (y2 < y1) { int temp = y1; y1 = y2; y2 = temp; } #undef PIXEL sp->x = x1; sp->y = y1; sp->w = x2 - x1; sp->h = y2 - y1; if (sp->w == 0) sp->w = 1; if (sp->h == 0) sp->h = 1; sp->tpu_offset_added = 0; sp->gamma_table = (OVAL (opt_custom_gamma).b) ? ss->gamma_table : NULL; sp->source = ss->source_map[OVAL (opt_source).w]; sp->mode = ss->mode_map[OVAL (opt_mode).w]; 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) { PDBG (pixma_dbg (1, "BUG:calc_scan_param() failed %d\n", error)); PDBG (print_scan_param (1, sp)); } return error; } static void init_option_descriptors (pixma_sane_t * ss) { const pixma_config_t *cfg; int i; cfg = pixma_get_config (ss->s); /* setup range for the scan area. */ ss->xrange.min = SANE_FIX (0); ss->xrange.max = SANE_FIX (cfg->width / 75.0 * 25.4); ss->xrange.quant = SANE_FIX (0); ss->yrange.min = SANE_FIX (0); ss->yrange.max = SANE_FIX (cfg->height / 75.0 * 25.4); ss->yrange.quant = SANE_FIX (0); /* mode_list and source_list were already NULL-terminated, * because the whole pixma_sane_t was cleared during allocation. */ /* setup available mode. */ create_mode_list (ss); /* setup dpi up to the value supported by the scanner. */ create_dpi_list (ss); /* setup paper source */ i = 0; ss->source_list[i] = SANE_I18N ("Flatbed"); ss->source_map[i] = PIXMA_SOURCE_FLATBED; i++; if (cfg->cap & PIXMA_CAP_ADF) { ss->source_list[i] = SANE_I18N ("Automatic Document Feeder"); ss->source_map[i] = PIXMA_SOURCE_ADF; i++; } if ((cfg->cap & PIXMA_CAP_ADFDUP) == PIXMA_CAP_ADFDUP) { ss->source_list[i] = SANE_I18N ("ADF Duplex"); ss->source_map[i] = PIXMA_SOURCE_ADFDUP; i++; } if (cfg->cap & PIXMA_CAP_TPU) { ss->source_list[i] = SANE_I18N ("Transparency Unit"); ss->source_map[i] = PIXMA_SOURCE_TPU; i++; } build_option_descriptors (ss); /* Enable options that are available only in some scanners. */ if (cfg->cap & PIXMA_CAP_GAMMA_TABLE) { enable_option (ss, opt_gamma, SANE_TRUE); enable_option (ss, opt_custom_gamma, SANE_TRUE); sane_control_option (ss, opt_custom_gamma, SANE_ACTION_SET_AUTO, NULL, NULL); pixma_fill_gamma_table (AUTO_GAMMA, ss->gamma_table, 4096); } enable_option (ss, opt_button_controlled, ((cfg->cap & PIXMA_CAP_EVENTS) != 0)); } /* Writing to reader_ss outside reader_process() is a BUG! */ static pixma_sane_t *reader_ss = NULL; static void reader_signal_handler (int sig) { if (reader_ss) { reader_ss->reader_stop = SANE_TRUE; /* reader process is ended by SIGTERM, so no cancel in this case */ if (sig != SIGTERM) pixma_cancel (reader_ss->s); } } static int write_all (pixma_sane_t * ss, void *buf_, size_t size) { uint8_t *buf = (uint8_t *) buf_; int count; while (size != 0 && !ss->reader_stop) { count = write (ss->wpipe, buf, size); if (count == -1 && errno != EINTR) break; if (count == -1 && errno == EINTR) continue; buf += count; size -= count; } return buf - (uint8_t *) buf_; } /* NOTE: reader_loop() runs either in a separate thread or process. */ static SANE_Status reader_loop (pixma_sane_t * ss) { void *buf; unsigned bufsize; int count = 0; PDBG (pixma_dbg (3, "Reader task started\n")); /*bufsize = ss->sp.line_size + 1;*/ /* XXX: "odd" bufsize for testing pixma_read_image() */ bufsize = ss->sp.line_size; /* bufsize EVEN needed by Xsane for 48 bits depth */ buf = malloc (bufsize); if (!buf) { count = PIXMA_ENOMEM; goto done; } count = pixma_activate_connection (ss->s); if (count < 0) goto done; pixma_enable_background (ss->s, 1); if (OVAL (opt_button_controlled).b && ss->page_count == 0) { int start = 0; #ifndef NDEBUG pixma_dbg (1, "==== Button-controlled scan mode is enabled.\n"); pixma_dbg (1, "==== To proceed, press 'SCAN' or 'COLOR' button. " "To cancel, press 'GRAY' or 'END' button.\n"); #endif while (pixma_wait_event (ss->s, 10) != 0) { } while (!start) { uint32_t events; if (ss->reader_stop) { count = PIXMA_ECANCELED; goto done; } events = pixma_wait_event (ss->s, 1000); switch (events & ~PIXMA_EV_ACTION_MASK) { case PIXMA_EV_BUTTON1: start = 1; break; case PIXMA_EV_BUTTON2: count = PIXMA_ECANCELED; goto done; } } } count = pixma_scan (ss->s, &ss->sp); if (count >= 0) { while ((count = pixma_read_image (ss->s, buf, bufsize)) > 0) { if (write_all (ss, buf, count) != count) pixma_cancel (ss->s); } } done: pixma_enable_background (ss->s, 0); pixma_deactivate_connection (ss->s); free (buf); close (ss->wpipe); ss->wpipe = -1; if (count >= 0) { PDBG (pixma_dbg (3, "Reader task terminated\n")); } else { PDBG (pixma_dbg (2, "Reader task terminated: %s\n", pixma_strerror (count))); } return map_error (count); } static int reader_process (void *arg) { pixma_sane_t *ss = (pixma_sane_t *) arg; struct SIGACTION sa; reader_ss = ss; memset (&sa, 0, sizeof (sa)); sigemptyset (&sa.sa_mask); sa.sa_handler = reader_signal_handler; /* FIXME: which signal else? */ sigaction (SIGHUP, &sa, NULL); sigaction (SIGINT, &sa, NULL); sigaction (SIGPIPE, &sa, NULL); sigaction (SIGTERM, &sa, NULL); close (ss->rpipe); ss->rpipe = -1; return reader_loop (ss); } static int reader_thread (void *arg) { pixma_sane_t *ss = (pixma_sane_t *) arg; #ifdef USE_PTHREAD /* Block SIGPIPE. We will handle this in reader_loop() by checking ss->reader_stop and the return value from write(). */ sigset_t sigs; sigemptyset (&sigs); sigaddset (&sigs, SIGPIPE); pthread_sigmask (SIG_BLOCK, &sigs, NULL); #endif /* USE_PTHREAD */ return reader_loop (ss); } static SANE_Pid terminate_reader_task (pixma_sane_t * ss, int *exit_code) { SANE_Pid result, pid; int status = 0; pid = ss->reader_taskid; if (!sanei_thread_is_valid (pid)) return pid; if (sanei_thread_is_forked ()) { sanei_thread_kill (pid); } else { ss->reader_stop = SANE_TRUE; /* pixma_cancel (ss->s); What is this for ? Makes end-of-scan buggy => removing */ } result = sanei_thread_waitpid (pid, &status); sanei_thread_invalidate (ss->reader_taskid); if (ss->sp.source != PIXMA_SOURCE_ADF && ss->sp.source != PIXMA_SOURCE_ADFDUP) ss->idle = SANE_TRUE; if (result == pid) { if (exit_code) *exit_code = status; return pid; } else { PDBG (pixma_dbg (1, "WARNING:waitpid() failed %s\n", strerror (errno))); sanei_thread_invalidate (pid); return pid; } } static int start_reader_task (pixma_sane_t * ss) { int fds[2]; SANE_Pid pid; int is_forked; if (ss->rpipe != -1 || ss->wpipe != -1) { PDBG (pixma_dbg (1, "BUG:rpipe = %d, wpipe = %d\n", ss->rpipe, ss->wpipe)); close (ss->rpipe); close (ss->wpipe); ss->rpipe = -1; ss->wpipe = -1; } if (sanei_thread_is_valid (ss->reader_taskid)) { PDBG (pixma_dbg (1, "BUG:reader_taskid(%ld) != -1\n", (long) ss->reader_taskid)); terminate_reader_task (ss, NULL); } if (pipe (fds) == -1) { PDBG (pixma_dbg (1, "ERROR:start_reader_task():pipe() failed %s\n", strerror (errno))); return PIXMA_ENOMEM; } ss->rpipe = fds[0]; ss->wpipe = fds[1]; ss->reader_stop = SANE_FALSE; is_forked = sanei_thread_is_forked (); if (is_forked) { pid = sanei_thread_begin (reader_process, ss); if (sanei_thread_is_valid (pid)) { close (ss->wpipe); ss->wpipe = -1; } } else { pid = sanei_thread_begin (reader_thread, ss); } if (!sanei_thread_is_valid (pid)) { close (ss->wpipe); close (ss->rpipe); ss->wpipe = -1; ss->rpipe = -1; PDBG (pixma_dbg (1, "ERROR:unable to start reader task\n")); return PIXMA_ENOMEM; } PDBG (pixma_dbg (3, "Reader task id=%ld (%s)\n", (long) pid, (is_forked) ? "forked" : "threaded")); ss->reader_taskid = pid; return 0; } /* libJPEG API callbacks */ static void jpeg_init_source(j_decompress_ptr __sane_unused__ cinfo) { /* No-op */ } static void jpeg_term_source(j_decompress_ptr __sane_unused__ cinfo) { /* No-op */ } static boolean jpeg_fill_input_buffer(j_decompress_ptr cinfo) { pixma_jpeg_src_mgr *mgr = (pixma_jpeg_src_mgr *)cinfo->src; int size; int retry; for (retry = 0; retry < 30; retry ++ ) { size = read (mgr->s->rpipe, mgr->buffer, 1024); if (size == 0) { return FALSE; } else if (size < 0) { sleep (1); } else { mgr->jpeg.next_input_byte = mgr->buffer; mgr->jpeg.bytes_in_buffer = size; return TRUE; } } return FALSE; } static void jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes) { pixma_jpeg_src_mgr *mgr = (pixma_jpeg_src_mgr *)cinfo->src; if (num_bytes > 0) { /* Read and throw away extra */ while (num_bytes > (long)mgr->jpeg.bytes_in_buffer) { num_bytes -= (long)mgr->jpeg.bytes_in_buffer; jpeg_fill_input_buffer(cinfo); } /* Update jpeg info structure with leftover */ mgr->jpeg.next_input_byte += (size_t) num_bytes; mgr->jpeg.bytes_in_buffer -= (size_t) num_bytes; } } /* Pixma JPEG reader helpers */ static SANE_Status pixma_jpeg_start(pixma_sane_t *s) { pixma_jpeg_src_mgr *mgr; s->jpeg_cinfo.err = jpeg_std_error(&s->jpeg_err); jpeg_create_decompress(&s->jpeg_cinfo); s->jpeg_cinfo.src = (struct jpeg_source_mgr *)(*s->jpeg_cinfo.mem->alloc_small)((j_common_ptr)&s->jpeg_cinfo, JPOOL_PERMANENT, sizeof(pixma_jpeg_src_mgr)); memset(s->jpeg_cinfo.src, 0, sizeof(pixma_jpeg_src_mgr)); mgr = (pixma_jpeg_src_mgr *)s->jpeg_cinfo.src; mgr->s = s; mgr->buffer = (JOCTET *)(*s->jpeg_cinfo.mem->alloc_small)((j_common_ptr)&s->jpeg_cinfo, JPOOL_PERMANENT, 1024 * sizeof(JOCTET)); mgr->jpeg.init_source = jpeg_init_source; mgr->jpeg.fill_input_buffer = jpeg_fill_input_buffer; mgr->jpeg.skip_input_data = jpeg_skip_input_data; mgr->jpeg.resync_to_restart = jpeg_resync_to_restart; mgr->jpeg.term_source = jpeg_term_source; mgr->jpeg.bytes_in_buffer = 0; mgr->jpeg.next_input_byte = NULL; s->jpeg_header_seen = 0; return SANE_STATUS_GOOD; } static SANE_Status pixma_jpeg_read_header(pixma_sane_t *s) { pixma_jpeg_src_mgr *src = (pixma_jpeg_src_mgr *)s->jpeg_cinfo.src; if (jpeg_read_header(&s->jpeg_cinfo, TRUE)) { s->jdst = sanei_jpeg_jinit_write_ppm(&s->jpeg_cinfo); if (jpeg_start_decompress(&s->jpeg_cinfo)) { int size; DBG(3, "%s: w: %d, h: %d, components: %d\n", __func__, s->jpeg_cinfo.output_width, s->jpeg_cinfo.output_height, s->jpeg_cinfo.output_components); size = s->jpeg_cinfo.output_width * s->jpeg_cinfo.output_components * 1; src->linebuffer = (*s->jpeg_cinfo.mem->alloc_large)((j_common_ptr)&s->jpeg_cinfo, JPOOL_PERMANENT, size); src->linebuffer_size = 0; src->linebuffer_index = 0; s->jpeg_header_seen = 1; return SANE_STATUS_GOOD; } else { DBG(0, "%s: decompression failed\n", __func__); return SANE_STATUS_IO_ERROR; } } else { DBG(0, "%s: cannot read JPEG header\n", __func__); return SANE_STATUS_IO_ERROR; } } static void pixma_jpeg_finish(pixma_sane_t *ss) { jpeg_destroy_decompress(&ss->jpeg_cinfo); } static void pixma_jpeg_read(pixma_sane_t *ss, SANE_Byte *data, SANE_Int max_length, SANE_Int *length) { struct jpeg_decompress_struct cinfo = ss->jpeg_cinfo; pixma_jpeg_src_mgr *src = (pixma_jpeg_src_mgr *)ss->jpeg_cinfo.src; int l; *length = 0; /* copy from line buffer if available */ if (src->linebuffer_size && src->linebuffer_index < src->linebuffer_size) { *length = src->linebuffer_size - src->linebuffer_index; if (*length > max_length) *length = max_length; memcpy(data, src->linebuffer + src->linebuffer_index, *length); src->linebuffer_index += *length; return; } if (cinfo.output_scanline >= cinfo.output_height) { *length = 0; return; } /* scanlines of decompressed data will be in ss->jdst->buffer * only one line at time is supported */ l = jpeg_read_scanlines(&cinfo, ss->jdst->buffer, 1); if (l == 0) return; /* from ss->jdst->buffer to linebuffer * linebuffer holds width * bytesperpixel */ (*ss->jdst->put_pixel_rows)(&cinfo, ss->jdst, 1, (char *)src->linebuffer); *length = ss->sp.w * ss->sp.channels; /* Convert RGB into grayscale */ if (ss->sp.channels == 1) { unsigned int i; unsigned char *d = (unsigned char *)src->linebuffer; unsigned char *s = (unsigned char *)src->linebuffer; for (i = 0; i < ss->sp.w; i++) { /* Using BT.709 luma formula, fixed-point */ int sum = ( s[0]*2126 + s[1]*7152 + s[2]*722 ); *d = sum / 10000; d ++; s += 3; } } /* Maybe pack into lineary binary image */ if (ss->sp.depth == 1) { *length /= 8; unsigned int i; unsigned char *d = (unsigned char *)src->linebuffer; unsigned char *s = (unsigned char *)src->linebuffer; unsigned char b = 0; for (i = 1; i < ss->sp.w + 1; i++) { if (*(s++) > 127) b = (b << 1) | 0; else b = (b << 1) | 1; } if ((i % 8) == 0) *(d++) = b; } src->linebuffer_size = *length; src->linebuffer_index = 0; if (*length > max_length) *length = max_length; memcpy(data, src->linebuffer + src->linebuffer_index, *length); src->linebuffer_index += *length; } static SANE_Status read_image (pixma_sane_t * ss, void *buf, unsigned size, int *readlen) { int count, status; if (readlen) *readlen = 0; if (ss->image_bytes_read >= ss->sp.image_size) return SANE_STATUS_EOF; do { if (ss->cancel) /* ss->rpipe has already been closed by sane_cancel(). */ return SANE_STATUS_CANCELLED; if (ss->sp.mode_jpeg && !ss->jpeg_header_seen) { status = pixma_jpeg_read_header(ss); if (status != SANE_STATUS_GOOD) { close (ss->rpipe); pixma_jpeg_finish(ss); ss->rpipe = -1; if (sanei_thread_is_valid (terminate_reader_task (ss, &status)) && status != SANE_STATUS_GOOD) { return status; } else { /* either terminate_reader_task failed or rpipe was closed but we expect more data */ return SANE_STATUS_IO_ERROR; } } } if (ss->sp.mode_jpeg) { count = -1; pixma_jpeg_read(ss, buf, size, &count); } else count = read (ss->rpipe, buf, size); } while (count == -1 && errno == EINTR); if (count == -1) { if (errno == EAGAIN) return SANE_STATUS_GOOD; if (!ss->cancel) { PDBG (pixma_dbg (1, "WARNING:read_image():read() failed %s\n", strerror (errno))); } close (ss->rpipe); ss->rpipe = -1; terminate_reader_task (ss, NULL); if (ss->sp.mode_jpeg) pixma_jpeg_finish(ss); return SANE_STATUS_IO_ERROR; } /* here count >= 0 */ ss->image_bytes_read += count; if (ss->image_bytes_read > ss->sp.image_size) { PDBG (pixma_dbg (1, "BUG:ss->image_bytes_read > ss->sp.image_size\n")); } if (ss->image_bytes_read >= ss->sp.image_size) { close (ss->rpipe); ss->rpipe = -1; terminate_reader_task (ss, NULL); if (ss->sp.mode_jpeg) pixma_jpeg_finish(ss); } else if (count == 0) { PDBG (pixma_dbg (3, "read_image():reader task closed the pipe:%" PRIu64" bytes received, %"PRIu64" bytes expected\n", ss->image_bytes_read, ss->sp.image_size)); close (ss->rpipe); if (ss->sp.mode_jpeg) pixma_jpeg_finish(ss); ss->rpipe = -1; if (sanei_thread_is_valid (terminate_reader_task (ss, &status)) && status != SANE_STATUS_GOOD) { return status; } else { /* either terminate_reader_task failed or rpipe was closed but we expect more data */ return SANE_STATUS_IO_ERROR; } } if (readlen) *readlen = count; return SANE_STATUS_GOOD; } /******************************************************************* ** SANE API *******************************************************************/ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { int status, myversion, i; SANEI_Config config; UNUSED (authorize); if (!version_code) return SANE_STATUS_INVAL; myversion = 100 * PIXMA_VERSION_MAJOR + PIXMA_VERSION_MINOR; *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, myversion); DBG_INIT (); sanei_thread_init (); pixma_set_debug_level (DBG_LEVEL); PDBG(pixma_dbg(2, "pixma is compiled %s pthread support.\n", (sanei_thread_is_forked () ? "without" : "with"))); for (i = 0; i < MAX_CONF_DEVICES; i++) conf_devices[i] = NULL; config.count = 0; config.descriptors = NULL; config.values = NULL; if (sanei_configure_attach(PIXMA_CONFIG_FILE, &config, config_attach_pixma) != SANE_STATUS_GOOD) PDBG(pixma_dbg(2, "Could not read pixma configuration file: %s\n", PIXMA_CONFIG_FILE)); status = pixma_init (); if (status < 0) { PDBG (pixma_dbg (2, "pixma_init() failed %s\n", pixma_strerror (status))); } return map_error (status); } void sane_exit (void) { while (first_scanner) sane_close (first_scanner); cleanup_device_list (); pixma_cleanup (); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { if (!device_list) return SANE_STATUS_INVAL; find_scanners (local_only); *device_list = dev_list; return (dev_list) ? SANE_STATUS_GOOD : SANE_STATUS_NO_MEM; } SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h) { unsigned i, j, nscanners; int error = 0; pixma_sane_t *ss = NULL; const pixma_config_t *cfg; if (!name || !h) return SANE_STATUS_INVAL; *h = NULL; nscanners = pixma_find_scanners (conf_devices, SANE_FALSE); if (nscanners == 0) return SANE_STATUS_INVAL; if (name[0] == '\0') name = pixma_get_device_id (0); /* Have we already opened the scanner? */ for (ss = first_scanner; ss; ss = ss->next) { if (strcmp (pixma_get_string (ss->s, PIXMA_STRING_ID), name) == 0) { /* We have already opened it! */ return SANE_STATUS_DEVICE_BUSY; } } i = 0; while (strcmp (pixma_get_device_id (i), name) != 0) { if (++i >= nscanners) return SANE_STATUS_INVAL; } cfg = pixma_get_device_config (i); if ((cfg->cap & PIXMA_CAP_EXPERIMENT) != 0) { #ifndef NDEBUG pixma_dbg (1, "WARNING:" "Experimental backend CAN DAMAGE your hardware!\n"); if (getenv_atoi ("PIXMA_EXPERIMENT", 0) == 0) { pixma_dbg (1, "Experimental SANE backend for %s is disabled " "by default.\n", pixma_get_device_model (i)); pixma_dbg (1, "To enable it, set the environment variable " "PIXMA_EXPERIMENT to non-zero.\n"); return SANE_STATUS_UNSUPPORTED; } #else return SANE_STATUS_UNSUPPORTED; #endif } ss = (pixma_sane_t *) calloc (1, sizeof (*ss)); if (!ss) return SANE_STATUS_NO_MEM; ss->next = first_scanner; first_scanner = ss; sanei_thread_initialize (ss->reader_taskid); ss->wpipe = -1; 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); if (error < 0) { sane_close (ss); return map_error (error); } pixma_enable_background (ss->s, 0); init_option_descriptors (ss); *h = ss; return SANE_STATUS_GOOD; } void sane_close (SANE_Handle h) { pixma_sane_t **p, *ss; for (p = &first_scanner; *p && *p != (pixma_sane_t *) h; p = &((*p)->next)) { } if (!(*p)) return; ss = *p; sane_cancel (ss); pixma_close (ss->s); *p = ss->next; free (ss); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle h, SANE_Int n) { DECL_CTX; if (ss && 0 <= n && n < opt_last) return &SOD (n); return NULL; } SANE_Status sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int * i) { DECL_CTX; SANE_Int info = 0; int error; option_descriptor_t *opt; if (i) *i = 0; if (!ss) return SANE_STATUS_INVAL; if (n < 0 || n >= opt_last) return SANE_STATUS_UNSUPPORTED; if (!ss->idle && a != SANE_ACTION_GET_VALUE) { PDBG (pixma_dbg (3, "Warning: !idle && !SANE_ACTION_GET_VALUE\n")); if (ss->sp.source != PIXMA_SOURCE_ADF && ss->sp.source != PIXMA_SOURCE_ADFDUP) return SANE_STATUS_INVAL; } opt = &(OPT_IN_CTX[n]); if (!SANE_OPTION_IS_ACTIVE (opt->sod.cap)) return SANE_STATUS_INVAL; switch (a) { case SANE_ACTION_SET_VALUE: if ((opt->sod.type != SANE_TYPE_BUTTON && !v) || !SANE_OPTION_IS_SETTABLE (opt->sod.cap)) return SANE_STATUS_INVAL; /* or _UNSUPPORTED? */ break; case SANE_ACTION_SET_AUTO: if (!(opt->sod.cap & SANE_CAP_AUTOMATIC) || !SANE_OPTION_IS_SETTABLE (opt->sod.cap)) return SANE_STATUS_INVAL; /* or _UNSUPPORTED? */ break; case SANE_ACTION_GET_VALUE: if (!v || !(opt->sod.cap & SANE_CAP_SOFT_DETECT)) return SANE_STATUS_INVAL; /* or _UNSUPPORTED? */ break; default: return SANE_STATUS_UNSUPPORTED; } error = control_option (ss, n, a, v, &info); if (error == SANE_STATUS_GOOD && i) *i = info; return error; } SANE_Status sane_get_parameters (SANE_Handle h, SANE_Parameters * p) { DECL_CTX; pixma_scan_param_t temp, *sp; if (!ss || !p) return SANE_STATUS_INVAL; if (!ss->idle) { sp = &ss->sp; /* sp is calculated in sane_start() */ } else { calc_scan_param (ss, &temp); sp = &temp; } p->format = (sp->channels == 3) ? SANE_FRAME_RGB : SANE_FRAME_GRAY; p->last_frame = SANE_TRUE; p->lines = sp->h; p->depth = sp->depth; p->pixels_per_line = sp->w; /* p->bytes_per_line = sp->line_size; NOTE: It should work this way, but it doesn't. No SANE frontend can cope with this. */ p->bytes_per_line = (sp->w * sp->channels * sp->depth) / 8; return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle h) { DECL_CTX; int error = 0; if (!ss) return SANE_STATUS_INVAL; if (!ss->idle && ss->scanning) { PDBG (pixma_dbg (3, "Warning in Sane_start: !idle && scanning. idle=%d, ss->scanning=%d\n", ss->idle, ss->scanning)); if (ss->sp.source != PIXMA_SOURCE_ADF && ss->sp.source != PIXMA_SOURCE_ADFDUP) return SANE_STATUS_INVAL; } ss->cancel = SANE_FALSE; if (ss->idle || ss->source_map[OVAL (opt_source).w] == PIXMA_SOURCE_FLATBED || ss->source_map[OVAL (opt_source).w] == PIXMA_SOURCE_TPU) ss->page_count = 0; /* start from idle state or scan from flatbed or TPU */ else ss->page_count++; if (calc_scan_param (ss, &ss->sp) < 0) return SANE_STATUS_INVAL; /* Prepare the JPEG decompressor, if needed */ if (ss->sp.mode_jpeg) { SANE_Status status; status = pixma_jpeg_start(ss); if (status != SANE_STATUS_GOOD) { PDBG (pixma_dbg(1, "%s: pixma_jpeg_start: %s\n", __func__, sane_strstatus(status)) ); return status; } } ss->image_bytes_read = 0; /* TODO: Check paper here in sane_start(). A function like pixma_get_status() is needed. */ error = start_reader_task (ss); if (error >= 0) { ss->output_line_size = (ss->sp.w * ss->sp.channels * ss->sp.depth) / 8; ss->byte_pos_in_line = 0; ss->last_read_status = SANE_STATUS_GOOD; ss->scanning = SANE_TRUE; ss->idle = SANE_FALSE; if (ss->sp.mode_jpeg && !ss->jpeg_header_seen) { SANE_Status status; status = pixma_jpeg_read_header(ss); if (status != SANE_STATUS_GOOD) { close (ss->rpipe); pixma_jpeg_finish(ss); ss->rpipe = -1; if (sanei_thread_is_valid (terminate_reader_task (ss, &error)) && error != SANE_STATUS_GOOD) { return error; } } } } return map_error (error); } SANE_Status sane_read (SANE_Handle h, SANE_Byte * buf, SANE_Int maxlen, SANE_Int * len) { DECL_CTX; int sum, n; /* Due to 32 pixels alignment, sizeof(temp) is to be greater than: * max(nchannels) * max (sp.line_size - output_line_size) * so currently: 3 * 32 = 96 for better end line cropping efficiency */ SANE_Byte temp[100]; SANE_Status status; if (len) *len = 0; if (!ss || !buf || !len) return SANE_STATUS_INVAL; if (ss->cancel) return SANE_STATUS_CANCELLED; if ((ss->idle) && (ss->sp.source == PIXMA_SOURCE_ADF || ss->sp.source == PIXMA_SOURCE_ADFDUP)) return SANE_STATUS_INVAL; if (!ss->scanning) return ss->last_read_status; status = SANE_STATUS_GOOD; /* CCD scanners use software lineart * the scanner must scan 24 bit color or 8 bit grayscale for one bit lineart */ if ((ss->sp.line_size - ((ss->sp.software_lineart == 1) ? (ss->output_line_size * 8) : ss->output_line_size)) == 0) { status = read_image (ss, buf, maxlen, &sum); } else { /* FIXME: Because there is no frontend that can cope with padding at the end of line, we've to remove it here in the backend! */ PDBG (pixma_dbg (1, "*sane_read***** Warning: padding may cause incomplete scan results\n")); sum = 0; while (sum < maxlen) { if (ss->byte_pos_in_line < ss->output_line_size) { n = ss->output_line_size - ss->byte_pos_in_line; if ((maxlen - sum) < n) n = maxlen - sum; status = read_image (ss, buf, n, &n); if (n == 0) break; sum += n; buf += n; ss->byte_pos_in_line += n; } else { /* skip padding */ n = ss->sp.line_size - ss->byte_pos_in_line; if (n > (int) sizeof (temp)) { PDBG (pixma_dbg (3, "Inefficient skip buffer. Should be %d\n", n)); n = sizeof (temp); } status = read_image (ss, temp, n, &n); if (n == 0) break; ss->byte_pos_in_line += n; if (ss->byte_pos_in_line == ss->sp.line_size) ss->byte_pos_in_line = 0; } } } if (ss->cancel) status = SANE_STATUS_CANCELLED; else if ((status == SANE_STATUS_GOOD || status == SANE_STATUS_EOF) && sum > 0) { *len = sum; status = SANE_STATUS_GOOD; } ss->scanning = (status == SANE_STATUS_GOOD); ss->last_read_status = status; return status; } void sane_cancel (SANE_Handle h) { DECL_CTX; if (!ss) return; ss->cancel = SANE_TRUE; ss->sp.frontend_cancel = SANE_TRUE; if (ss->idle) return; close (ss->rpipe); if (ss->sp.mode_jpeg) pixma_jpeg_finish(ss); ss->rpipe = -1; terminate_reader_task (ss, NULL); ss->idle = SANE_TRUE; } SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool m) { DECL_CTX; if (!ss || ss->idle || ss->rpipe == -1) return SANE_STATUS_INVAL; #ifdef HAVE_FCNTL_H PDBG (pixma_dbg (2, "Setting %sblocking mode\n", (m) ? "non-" : "")); if (fcntl (ss->rpipe, F_SETFL, (m) ? O_NONBLOCK : 0) == -1) { PDBG (pixma_dbg (1, "WARNING:fcntl(F_SETFL) failed %s\n", strerror (errno))); return SANE_STATUS_UNSUPPORTED; } return SANE_STATUS_GOOD; #else return (m) ? SANE_STATUS_UNSUPPORTED : SANE_STATUS_GOOD; #endif } SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fd) { DECL_CTX; *fd = -1; if (!ss || !fd || ss->idle || ss->rpipe == -1) return SANE_STATUS_INVAL; *fd = ss->rpipe; return SANE_STATUS_GOOD; } /* BEGIN SANE_Option_Descriptor rem ------------------------------------------- type group title Scan mode type int resolution unit dpi constraint @word_list = ss->dpi_list default 75 title @SANE_TITLE_SCAN_RESOLUTION desc @SANE_DESC_SCAN_RESOLUTION cap soft_select soft_detect automatic info reload_params type string mode[30] constraint @string_list = ss->mode_list default @s = SANE_VALUE_SCAN_MODE_COLOR title @SANE_TITLE_SCAN_MODE desc @SANE_DESC_SCAN_MODE cap soft_select soft_detect automatic info reload_params type string source[30] constraint @string_list = ss->source_list title @SANE_TITLE_SCAN_SOURCE desc Selects the scan source (such as a document-feeder). Set source before mode and resolution. Resets mode and resolution to auto values. default Flatbed cap soft_select soft_detect type bool button-controlled title Button-controlled scan desc When enabled, scan process will not start immediately. To proceed, press \"SCAN\" button (for MP150) or \"COLOR\" button (for other models). To cancel, press \"GRAY\" button. default SANE_FALSE cap soft_select soft_detect inactive rem ------------------------------------------- type group title Gamma type bool custom-gamma default SANE_TRUE title @SANE_TITLE_CUSTOM_GAMMA desc @SANE_DESC_CUSTOM_GAMMA cap soft_select soft_detect automatic inactive type int gamma-table[4096] constraint (0,255,0) title @SANE_TITLE_GAMMA_VECTOR desc @SANE_DESC_GAMMA_VECTOR cap soft_select soft_detect automatic inactive type fixed gamma default AUTO_GAMMA constraint (0.3,5,0) title Gamma function exponent desc Changes intensity of midtones cap soft_select soft_detect automatic inactive rem ------------------------------------------- type group title Geometry type fixed tl-x unit mm default 0 constraint @range = &ss->xrange title @SANE_TITLE_SCAN_TL_X desc @SANE_DESC_SCAN_TL_X cap soft_select soft_detect automatic info reload_params type fixed tl-y unit mm default 0 constraint @range = &ss->yrange title @SANE_TITLE_SCAN_TL_Y desc @SANE_DESC_SCAN_TL_Y cap soft_select soft_detect automatic info reload_params type fixed br-x unit mm default _MAX constraint @range = &ss->xrange title @SANE_TITLE_SCAN_BR_X desc @SANE_DESC_SCAN_BR_X cap soft_select soft_detect automatic info reload_params type fixed br-y unit mm default _MAX constraint @range = &ss->yrange title @SANE_TITLE_SCAN_BR_Y desc @SANE_DESC_SCAN_BR_Y cap soft_select soft_detect automatic info reload_params rem ------------------------------------------- type group title Buttons type button button-update title Update button state cap soft_select soft_detect advanced type int button-1 default 0 title Button 1 cap soft_detect advanced type int button-2 default 0 title Button 2 cap soft_detect advanced type int original default 0 title Type of original to scan cap soft_detect advanced type int target default 0 title Target operation type cap soft_detect advanced type int scan-resolution default 0 title Scan resolution cap soft_detect advanced rem ------------------------------------------- type group title Extras type int threshold unit PERCENT default 50 constraint (0,100,1) title @SANE_TITLE_THRESHOLD desc @SANE_DESC_THRESHOLD cap soft_select soft_detect automatic inactive type int threshold-curve constraint (0,127,1) title 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 */ /* pixma_sane_options.c generated by * scripts/pixma_gen_options.py < pixma.c > pixma_sane_options.c * * pixma_sane_options.h generated by * scripts/pixma_gen_options.py h < pixma.c > pixma_sane_options.h */ #include "pixma_sane_options.c" sane-backends-1.0.29/backend/pixma/pixma_bjnp_private.h0000666000000000000000000003013313615534521017740 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2008 by Louis Lagendijk This file is part of the SANE package. Data structures and definitions for bjnp backend for the Common UNIX Printing System (CUPS). These coded instructions, statements, and computer programs are the property of Louis Lagendijk and are protected by Federal copyright law. Distribution and use rights are outlined in the file "LICENSE.txt" "LICENSE" which should have been included with this file. If this file is missing or damaged, see the license at "http://www.cups.org/". This file is subject to the Apple OS-Developed Software exception. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* * BJNP definitions */ /* selection of options */ /* This works now, disable when it gives you problems */ #define PIXMA_BJNP_USE_STATUS 1 /* sizes */ #define BJNP_PRINTBUF_MAX 1400 /* size of printbuffer */ #define BJNP_CMD_MAX 2048 /* size of BJNP response buffer */ #define BJNP_RESP_MAX 2048 /* size of BJNP response buffer */ #define BJNP_SOCK_MAX 256 /* maximum number of open sockets */ #define BJNP_MODEL_MAX 64 /* max allowed size for make&model */ #define BJNP_STATUS_MAX 256 /* max size for status string */ #define BJNP_IEEE1284_MAX 1024 /* max. allowed size of IEEE1284 id */ #define BJNP_METHOD_MAX 16 /* max length of method */ #define BJNP_HOST_MAX 128 /* max length of hostname or address */ #define BJNP_PORT_MAX 64 /* max length of port string */ #define BJNP_ARGS_MAX 128 /* max length of argument string */ #define BJNP_SERIAL_MAX 16 /* maximum length of serial number */ #define BJNP_NO_DEVICES 16 /* max number of open devices */ #define BJNP_SCAN_BUF_MAX 65536 /* size of scanner data intermediate buffer */ #define BJNP_BLOCKSIZE_START 512 /* startsize for last block detection */ /* timers */ #define BJNP_BROADCAST_INTERVAL 10 /* ms between broadcasts */ #define BJNP_BC_RESPONSE_TIMEOUT 500 /* waiting time for broadc. responses */ #define BJNP_TIMEOUT_DEFAULT 10000 /* minimum tiemout value for network operations */ #define BJNP_TIMEOUT_TCP_CONNECT 2000 /* timeout for tcp connect attempts in ms */ #define BJNP_USLEEP_MS 1000 /* sleep for 1 msec */ #define BJNP_TCP_CONNECT_INTERVAL 100 /* TCP retry interval in ms */ /* retries */ #define BJNP_MAX_SELECT_ATTEMPTS 3 /* max nr of retries on select (EINTR) */ #define BJNP_MAX_BROADCAST_ATTEMPTS 2 /* number of broadcast packets to be sent */ #define BJNP_UDP_RETRY_MAX 3 /* max nt of retries on a udp command */ #define bjnp_dbg DBG #include "../include/sane/sanei_debug.h" /* loglevel definitions */ #define LOG_CRIT 0 #define LOG_NOTICE 1 #define LOG_INFO 2 #define LOG_DEBUG 3 #define LOG_DEBUG2 4 #define LOG_DEBUG3 5 #define BJNP_RESTART_POLL -1 /*************************************/ /* BJNP protocol related definitions */ /*************************************/ /* port numbers */ typedef enum bjnp_port_e { MFNP_PORT_SCAN = 8610, BJNP_PORT_PRINT = 8611, BJNP_PORT_SCAN = 8612, BJNP_PORT_3 = 8613, BJNP_PORT_4 = 8614 } bjnp_port_t; typedef enum { PROTOCOL_BJNP = 0, PROTOCOL_MFNP = 1, PROTOCOL_NONE =2 } bjnp_protocol_t; typedef struct { bjnp_protocol_t protocol_version; int default_port; char * proto_string; char * method_string; } bjnp_protocol_defs_t; bjnp_protocol_defs_t bjnp_protocol_defs[] = { {PROTOCOL_BJNP, BJNP_PORT_SCAN,"BJNP", "bjnp"}, {PROTOCOL_MFNP, MFNP_PORT_SCAN,"MFNP", "mfnp"}, {PROTOCOL_NONE, -1, NULL, NULL} }; /* commands */ typedef enum bjnp_cmd_e { CMD_UDP_DISCOVER = 0x01, /* discover if service type is listening at this port */ CMD_UDP_START_SCAN = 0x02, /* start scan pressed, sent from scanner to 224.0.0.1 */ CMD_UDP_JOB_DETAILS = 0x10, /* send print/ scanner job owner details */ CMD_UDP_CLOSE = 0x11, /* request connection closure */ CMD_UDP_GET_STATUS = 0x20, /* get printer status */ CMD_TCP_REQ = 0x20, /* read data from device */ CMD_TCP_SEND = 0x21, /* send data to device */ CMD_UDP_GET_ID = 0x30, /* get printer identity */ CMD_UDP_POLL = 0x32 /* poll scanner for button status */ } bjnp_cmd_t; /* command type */ typedef enum uint8_t { BJNP_CMD_PRINT = 0x1, /* printer command */ BJNP_CMD_SCAN = 0x2, /* scanner command */ BJNP_RES_PRINT = 0x81, /* printer response */ BJNP_RES_SCAN = 0x82 /* scanner response */ } bjnp_cmd_type_t; /***************************/ /* BJNP protocol structure */ /***************************/ /* The common protocol header */ struct __attribute__ ((__packed__)) BJNP_command { char BJNP_id[4]; /* string: BJNP */ uint8_t dev_type; /* 1 = printer, 2 = scanner */ /* responses have MSB set */ uint8_t cmd_code; /* command code/response code */ int16_t unknown1; /* unknown, always 0? */ int16_t seq_no; /* sequence number */ uint16_t session_id; /* session id for printing */ uint32_t payload_len; /* length of command buffer */ }; /* Layout of the init response buffer */ struct __attribute__ ((__packed__)) DISCOVER_RESPONSE { struct BJNP_command response; /* reponse header */ char unknown1[4]; /* 00 01 08 00 */ char mac_len; /* length of mac address */ char addr_len; /* length of address field */ unsigned char mac_addr[6]; /* printers mac address */ union { struct __attribute__ ((__packed__)) { unsigned char ipv4_addr[4]; } ipv4; struct __attribute__ ((__packed__)) { unsigned char ipv6_addr_1[16]; unsigned char ipv6_addr_2[16]; } ipv6; } addresses; }; /* layout of payload for the JOB_DETAILS command */ struct __attribute__ ((__packed__)) JOB_DETAILS { struct BJNP_command cmd; /* command header */ char unknown[8]; /* don't know what these are for */ char hostname[64]; /* hostname of sender */ char username[64]; /* username */ char jobtitle[256]; /* job title */ }; /* layout of the poll command, not everything is complete */ struct __attribute__ ((__packed__)) POLL_DETAILS { struct BJNP_command cmd; /* command header */ uint16_t type; /* 0, 1, 2 or 5 */ /* 05 = reset status */ union { struct __attribute__ ((__packed__)) { char empty0[78]; /* type 0 has only 0 */ } type0; /* length = 80 */ struct __attribute__ ((__packed__)) { char empty1[6]; /* 0 */ char user_host[64]; /* unicode user hostname */ uint64_t emtpy2; /* 0 */ } type1; /* length = 80 */ struct __attribute__ ((__packed__)) { uint16_t empty_1; /* 00 00 */ uint32_t dialog; /* constant dialog id, from previous response */ char user_host[64]; /* unicode user hostname */ uint32_t unknown_1; /* 00 00 00 14 */ uint32_t empty_2[5]; /* only 0 */ uint32_t unknown_2; /* 00 00 00 10 */ char ascii_date[16]; /* YYYYMMDDHHMMSS only for type 2 */ } type2; /* length = 116 */ struct __attribute__ ((__packed__)) { uint16_t empty_1; /* 00 00 */ uint32_t dialog; /* constant dialog id, from previous response */ char user_host[64]; /* unicode user hostname */ uint32_t unknown_1; /* 00 00 00 14 */ uint32_t key; /* copied from key field in status msg */ uint32_t unknown_3[5]; /* only 0 */ } type5; /* length = 100 */ } extensions; }; /* the poll response layout */ struct __attribute__ ((__packed__)) POLL_RESPONSE { struct BJNP_command cmd; /* command header */ unsigned char result[4]; /* unknown stuff, result[2] = 80 -> status is available*/ /* result[8] is dialog, size? */ uint32_t dialog; /* to be returned in next request */ uint32_t unknown_2; /* returns the 00 00 00 14 from unknown_2 in request */ uint32_t key; /* to be returned in type 5 status reset */ unsigned char status[20]; /* interrupt status */ }; /* Layout of ID and status responses */ struct __attribute__ ((__packed__)) IDENTITY { struct BJNP_command cmd; union __attribute__ ((__packed__)) { struct __attribute__ ((__packed__)) payload_s { uint16_t id_len; /* length of identity */ char id[BJNP_IEEE1284_MAX]; /* identity */ } bjnp; struct __attribute__ ((__packed__)) mfnp { char id[BJNP_IEEE1284_MAX]; } mfnp; } payload; }; /* response to TCP print command */ struct __attribute__ ((__packed__)) SCAN_BUF { struct BJNP_command cmd; char scan_data[65536]; }; /**************************/ /* Local enum definitions */ /**************************/ typedef enum bjnp_paper_status_e { BJNP_PAPER_UNKNOWN = -1, BJNP_PAPER_OK = 0, BJNP_PAPER_OUT = 1 } bjnp_paper_status_t; typedef enum { BJNP_STATUS_GOOD, BJNP_STATUS_INVAL, BJNP_STATUS_ALREADY_ALLOCATED } BJNP_Status; /* button polling */ typedef enum { BJNP_POLL_STOPPED = 0, BJNP_POLL_STARTED = 1, BJNP_POLL_STATUS_RECEIVED = 2 } BJNP_polling_status_e; typedef union { struct sockaddr_storage storage; struct sockaddr addr; struct sockaddr_in ipv4; struct sockaddr_in6 ipv6; } bjnp_sockaddr_t; typedef enum { BJNP_ADDRESS_IS_LINK_LOCAL = 0, BJNP_ADDRESS_IS_GLOBAL = 1, BJNP_ADDRESS_HAS_FQDN = 2 } bjnp_address_type_t; /* * Device information for opened devices */ typedef struct device_s { int open; /* connection to scanner is opened */ /* protocol version */ int protocol; char *protocol_string; /* sockets */ int tcp_socket; /* open tcp socket for communcation to scannner */ int16_t serial; /* sequence number of command */ /* communication state */ int session_id; /* session id used in bjnp protocol for TCP packets */ int last_cmd; /* last command sent */ /* TCP bulk read state information */ size_t blocksize; /* size of (TCP) blocks returned by the scanner */ size_t scanner_data_left; /* TCP data left from last read request */ char last_block; /* last TCP read command was shorter than blocksize */ /* device information */ char mac_address[BJNP_HOST_MAX]; /* mac-address, used as device serial no */ bjnp_sockaddr_t * addr; /* ip-address of the scanner */ int address_level; /* link local, public or has a FQDN */ int bjnp_scanner_timeout; /* timeout (msec) for next poll command */ int bjnp_ip_timeout; /* device specific min timeout for the IP-protocol */ #ifdef PIXMA_BJNP_USE_STATUS /* polling state information */ char polling_status; /* status polling ongoing */ uint32_t dialog; /* poll dialog */ uint32_t status_key; /* key of last received status message */ #endif } bjnp_device_t; sane-backends-1.0.29/backend/pixma/pixma_io_sanei.c0000666000000000000000000003265413615534521017050 00000000000000/* SANE - Scanner Access Now Easy. * For limitations, see function sanei_usb_get_vendor_product(). Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "../include/sane/config.h" #include #include #include #include /* INT_MAX */ #include "pixma_rename.h" #include "pixma_common.h" #include "pixma_io.h" #include "pixma_bjnp.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sane.h" #ifdef __GNUC__ # define UNUSED(v) (void) v #else # define UNUSED(v) #endif /* MAC OS X does not support timeouts in darwin/libusb interrupt reads * This is a very basic turnaround for MAC OS X * Button scan will not work with this wrapper */ #ifdef __APPLE__ # define sanei_usb_read_int sanei_usb_read_bulk #endif struct pixma_io_t { pixma_io_t *next; int interface; SANE_Int dev; }; typedef struct scanner_info_t { struct scanner_info_t *next; char *devname; int interface; const pixma_config_t *cfg; char serial[PIXMA_MAX_ID_LEN + 1]; /* "xxxxyyyy_zzzzzzz..." x = vid, y = pid, z = serial */ } scanner_info_t; #define INT_USB 0 #define INT_BJNP 1 static scanner_info_t *first_scanner = NULL; static pixma_io_t *first_io = NULL; static unsigned nscanners; static scanner_info_t * get_scanner_info (unsigned devnr) { scanner_info_t *si; for (si = first_scanner; si && devnr != 0; --devnr, si = si->next) { } return si; } static SANE_Status attach (SANE_String_Const devname) { scanner_info_t *si; si = (scanner_info_t *) calloc (1, sizeof (*si)); if (!si) return SANE_STATUS_NO_MEM; si->devname = strdup (devname); if (!si->devname) return SANE_STATUS_NO_MEM; si -> interface = INT_USB; si->next = first_scanner; first_scanner = si; nscanners++; return SANE_STATUS_GOOD; } static SANE_Status attach_bjnp (SANE_String_Const devname, SANE_String_Const serial, const struct pixma_config_t *cfg) { scanner_info_t *si; si = (scanner_info_t *) calloc (1, sizeof (*si)); if (!si) return SANE_STATUS_NO_MEM; si->devname = strdup (devname); if (!si->devname) return SANE_STATUS_NO_MEM; si->cfg = cfg; sprintf(si->serial, "%s_%s", cfg->model, serial); si -> interface = INT_BJNP; si->next = first_scanner; first_scanner = si; nscanners++; return SANE_STATUS_GOOD; } static void clear_scanner_list (void) { scanner_info_t *si = first_scanner; while (si) { scanner_info_t *temp = si; free (si->devname); si = si->next; free (temp); } nscanners = 0; first_scanner = NULL; } static SANE_Status get_descriptor (SANE_Int dn, SANE_Int type, SANE_Int descidx, SANE_Int index, SANE_Int length, SANE_Byte * data) { return sanei_usb_control_msg (dn, 0x80, USB_REQ_GET_DESCRIPTOR, ((type & 0xff) << 8) | (descidx & 0xff), index, length, data); } static SANE_Status get_string_descriptor (SANE_Int dn, SANE_Int index, SANE_Int lang, SANE_Int length, SANE_Byte * data) { return get_descriptor (dn, USB_DT_STRING, index, lang, length, data); } static void u16tohex (uint16_t x, char *str) { static const char hdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; str[0] = hdigit[(x >> 12) & 0xf]; str[1] = hdigit[(x >> 8) & 0xf]; str[2] = hdigit[(x >> 4) & 0xf]; str[3] = hdigit[x & 0xf]; str[4] = '\0'; } static void read_serial_number (scanner_info_t * si) { uint8_t unicode[2 * (PIXMA_MAX_ID_LEN - 9) + 2]; uint8_t ddesc[18]; int iSerialNumber; SANE_Int usb; char *serial = si->serial; u16tohex (si->cfg->vid, serial); u16tohex (si->cfg->pid, serial + 4); if (SANE_STATUS_GOOD != sanei_usb_open (si->devname, &usb)) return; if (get_descriptor (usb, USB_DT_DEVICE, 0, 0, 18, ddesc) != SANE_STATUS_GOOD) goto done; iSerialNumber = ddesc[16]; if (iSerialNumber != 0) { int i, len; SANE_Status status; /*int iSerialNumber = ddesc[16];*/ /* Read the first language code. Assumed that there is at least one. */ if (get_string_descriptor (usb, 0, 0, 4, unicode) != SANE_STATUS_GOOD) goto done; /* Read the serial number string. */ status = get_string_descriptor (usb, iSerialNumber, unicode[3] * 256 + unicode[2], sizeof (unicode), unicode); if (status != SANE_STATUS_GOOD) goto done; /* Assumed charset: Latin1 */ len = unicode[0]; if (len > (int) sizeof (unicode)) { len = sizeof (unicode); PDBG (pixma_dbg (1, "WARNING:Truncated serial number\n")); } serial[8] = '_'; for (i = 2; i < len; i += 2) { serial[9 + i / 2 - 1] = unicode[i]; } serial[9 + i / 2 - 1] = '\0'; } else { PDBG (pixma_dbg (1, "WARNING:No serial number\n")); } done: sanei_usb_close (usb); } static int map_error (SANE_Status ss) { switch (ss) { case SANE_STATUS_GOOD: return 0; case SANE_STATUS_UNSUPPORTED: return PIXMA_ENODEV; case SANE_STATUS_DEVICE_BUSY: return PIXMA_EBUSY; case SANE_STATUS_INVAL: return PIXMA_EINVAL; case SANE_STATUS_IO_ERROR: return PIXMA_EIO; case SANE_STATUS_NO_MEM: return PIXMA_ENOMEM; case SANE_STATUS_ACCESS_DENIED: return PIXMA_EACCES; case SANE_STATUS_CANCELLED: return PIXMA_ECANCELED; case SANE_STATUS_JAMMED: return PIXMA_EPAPER_JAMMED; case SANE_STATUS_COVER_OPEN: return PIXMA_ECOVER_OPEN; case SANE_STATUS_NO_DOCS: return PIXMA_ENO_PAPER; case SANE_STATUS_EOF: return PIXMA_EOF; #ifdef SANE_STATUS_HW_LOCKED case SANE_STATUS_HW_LOCKED: /* unused by pixma */ #endif #ifdef SANE_STATUS_WARMING_UP case SANE_STATUS_WARMING_UP: /* unused by pixma */ #endif break; } PDBG (pixma_dbg (1, "BUG:Unmapped SANE Status code %d\n", ss)); return PIXMA_EIO; /* should not happen */ } int pixma_io_init (void) { sanei_usb_init (); sanei_bjnp_init(); nscanners = 0; return 0; } void pixma_io_cleanup (void) { while (first_io) pixma_disconnect (first_io); clear_scanner_list (); } unsigned pixma_collect_devices (const char **conf_devices, const struct pixma_config_t *const pixma_devices[], SANE_Bool local_only) { unsigned i, j; struct scanner_info_t *si; const struct pixma_config_t *cfg; clear_scanner_list (); j = 0; for (i = 0; pixma_devices[i]; i++) { for (cfg = pixma_devices[i]; cfg->name; cfg++) { sanei_usb_find_devices (cfg->vid, cfg->pid, attach); si = first_scanner; while (j < nscanners) { PDBG (pixma_dbg (3, "pixma_collect_devices() found %s at %s\n", cfg->name, si->devname)); si->cfg = cfg; read_serial_number (si); si = si->next; j++; } } } if (! local_only) sanei_bjnp_find_devices(conf_devices, attach_bjnp, pixma_devices); si = first_scanner; while (j < nscanners) { PDBG (pixma_dbg (3, "pixma_collect_devices() found %s at %s\n", si->cfg->name, si->devname)); si = si->next; j++; } return nscanners; } const pixma_config_t * pixma_get_device_config (unsigned devnr) { const scanner_info_t *si = get_scanner_info (devnr); return (si) ? si->cfg : NULL; } const char * pixma_get_device_id (unsigned devnr) { const scanner_info_t *si = get_scanner_info (devnr); return (si) ? si->serial : NULL; } int pixma_connect (unsigned devnr, pixma_io_t ** handle) { pixma_io_t *io; SANE_Int dev; const scanner_info_t *si; int error; *handle = NULL; si = get_scanner_info (devnr); if (!si) return PIXMA_EINVAL; if (si-> interface == INT_BJNP) error = map_error (sanei_bjnp_open (si->devname, &dev)); else error = map_error (sanei_usb_open (si->devname, &dev)); if (error < 0) return error; io = (pixma_io_t *) calloc (1, sizeof (*io)); if (!io) { if (si -> interface == INT_BJNP) sanei_bjnp_close (dev); else sanei_usb_close (dev); return PIXMA_ENOMEM; } io->next = first_io; first_io = io; io->dev = dev; io->interface = si->interface; *handle = io; return 0; } void pixma_disconnect (pixma_io_t * io) { pixma_io_t **p; if (!io) return; for (p = &first_io; *p && *p != io; p = &((*p)->next)) { } PASSERT (*p); if (!(*p)) return; if (io-> interface == INT_BJNP) sanei_bjnp_close (io->dev); else sanei_usb_close (io->dev); *p = io->next; free (io); } int pixma_activate (pixma_io_t * io) { int error; if (io->interface == INT_BJNP) { error = map_error(sanei_bjnp_activate (io->dev)); } else /* noop for USB interface */ error = 0; return error; } int pixma_deactivate (pixma_io_t * io) { int error; if (io->interface == INT_BJNP) { error = map_error(sanei_bjnp_deactivate (io->dev)); } else /* noop for USB interface */ error = 0; return error; } int pixma_reset_device (pixma_io_t * io) { UNUSED (io); return PIXMA_ENOTSUP; } int pixma_write (pixma_io_t * io, const void *cmd, unsigned len) { size_t count = len; int error; if (io->interface == INT_BJNP) { sanei_bjnp_set_timeout (io->dev, PIXMA_BULKOUT_TIMEOUT); error = map_error (sanei_bjnp_write_bulk (io->dev, cmd, &count)); } else { #ifdef HAVE_SANEI_USB_SET_TIMEOUT sanei_usb_set_timeout (PIXMA_BULKOUT_TIMEOUT); #endif error = map_error (sanei_usb_write_bulk (io->dev, cmd, &count)); } if (error == PIXMA_EIO) error = PIXMA_ETIMEDOUT; /* FIXME: SANE doesn't have ETIMEDOUT!! */ if (count != len) { PDBG (pixma_dbg (1, "WARNING:pixma_write(): count(%u) != len(%u)\n", (unsigned) count, len)); error = PIXMA_EIO; } if (error >= 0) error = count; PDBG (pixma_dump (10, "OUT ", cmd, error, len, 128)); return error; } int pixma_read (pixma_io_t * io, void *buf, unsigned size) { size_t count = size; int error; if (io-> interface == INT_BJNP) { sanei_bjnp_set_timeout (io->dev, PIXMA_BULKIN_TIMEOUT); error = map_error (sanei_bjnp_read_bulk (io->dev, buf, &count)); } else { #ifdef HAVE_SANEI_USB_SET_TIMEOUT sanei_usb_set_timeout (PIXMA_BULKIN_TIMEOUT); #endif error = map_error (sanei_usb_read_bulk (io->dev, buf, &count)); } if (error == PIXMA_EIO) error = PIXMA_ETIMEDOUT; /* FIXME: SANE doesn't have ETIMEDOUT!! */ if (error >= 0) error = count; PDBG (pixma_dump (10, "IN ", buf, error, -1, 128)); return error; } int pixma_wait_interrupt (pixma_io_t * io, void *buf, unsigned size, int timeout) { size_t count = size; int error; /* FIXME: What is the meaning of "timeout" in sanei_usb? */ if (timeout < 0) timeout = INT_MAX; else if (timeout < 100) timeout = 100; if (io-> interface == INT_BJNP) { sanei_bjnp_set_timeout (io->dev, timeout); error = map_error (sanei_bjnp_read_int (io->dev, buf, &count)); } else { #ifdef HAVE_SANEI_USB_SET_TIMEOUT sanei_usb_set_timeout (timeout); #endif error = map_error (sanei_usb_read_int (io->dev, buf, &count)); } if (error == PIXMA_EIO || (io->interface == INT_BJNP && error == PIXMA_EOF)) /* EOF is a bjnp timeout error! */ error = PIXMA_ETIMEDOUT; /* FIXME: SANE doesn't have ETIMEDOUT!! */ if (error == 0) error = count; if (error != PIXMA_ETIMEDOUT) PDBG (pixma_dump (10, "INTR", buf, error, -1, -1)); return error; } int pixma_set_interrupt_mode (pixma_io_t * s, int background) { UNUSED (s); return (background) ? PIXMA_ENOTSUP : 0; } sane-backends-1.0.29/backend/pixma/pixma_mp730.c0000666000000000000000000005316713615534521016132 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2007-2008 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "../include/sane/config.h" #include #include #include #include /* localtime(C90) */ #include "pixma_rename.h" #include "pixma_common.h" #include "pixma_io.h" #ifdef __GNUC__ # define UNUSED(v) (void) v #else # define UNUSED(v) #endif #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 MP740_PID 0x264c /* Untested */ #define MP710_PID 0x264d #define MF5730_PID 0x265d /* Untested */ #define MF5750_PID 0x265e /* Untested */ #define MF5770_PID 0x265f #define MF3110_PID 0x2660 #define IR1020_PID 0x26e6 enum mp730_state_t { state_idle, state_warmup, state_scanning, state_transfering, state_finished }; enum mp730_cmd_t { cmd_start_session = 0xdb20, cmd_select_source = 0xdd20, cmd_gamma = 0xee20, cmd_scan_param = 0xde20, cmd_status = 0xf320, cmd_abort_session = 0xef20, cmd_time = 0xeb80, cmd_read_image = 0xd420, cmd_error_info = 0xff20, cmd_activate = 0xcf60, cmd_calibrate = 0xe920 }; typedef struct mp730_t { enum mp730_state_t state; pixma_cmdbuf_t cb; unsigned raw_width; uint8_t current_status[12]; uint8_t *buf, *imgbuf, *lbuf; unsigned imgbuf_len; unsigned last_block:1; } mp730_t; static void mp730_finish_scan (pixma_t * s); static int has_paper (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; return (mp->current_status[1] == 0); } static void drain_bulk_in (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; while (pixma_read (s->io, mp->imgbuf, IMAGE_BLOCK_SIZE) >= 0); } static int abort_session (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; return pixma_exec_short_cmd (s, &mp->cb, cmd_abort_session); } static int query_status (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mp->cb, cmd_status, 0, 12); error = pixma_exec (s, &mp->cb); if (error >= 0) { memcpy (mp->current_status, data, 12); PDBG (pixma_dbg (3, "Current status: paper=%u cal=%u lamp=%u\n", data[1], data[8], data[7])); } return error; } static int activate (pixma_t * s, uint8_t x) { mp730_t *mp = (mp730_t *) s->subdriver; uint8_t *data = pixma_newcmd (&mp->cb, cmd_activate, 10, 0); data[0] = 1; data[3] = x; return pixma_exec (s, &mp->cb); } static int start_session (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; return pixma_exec_short_cmd (s, &mp->cb, cmd_start_session); } static int select_source (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; uint8_t *data = pixma_newcmd (&mp->cb, cmd_select_source, 10, 0); switch (s->param->source) { case PIXMA_SOURCE_ADF: data[0] = 2; break; case PIXMA_SOURCE_ADFDUP: data[0] = 2; data[5] = 3; break; default: data[0] = 1; break; } return pixma_exec (s, &mp->cb); } static int send_scan_param (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; uint8_t *data; data = pixma_newcmd (&mp->cb, cmd_scan_param, 0x2e, 0); pixma_set_be16 (s->param->xdpi | 0x1000, data + 0x04); pixma_set_be16 (s->param->ydpi | 0x1000, data + 0x06); pixma_set_be32 (s->param->x, data + 0x08); pixma_set_be32 (s->param->y, data + 0x0c); pixma_set_be32 (mp->raw_width, data + 0x10); pixma_set_be32 (s->param->h, data + 0x14); if (s->param->channels == 1) { if (s->param->depth == 1) data[0x18] = 0x01; else data[0x18] = 0x04; } else data[0x18] = 0x08; data[0x19] = s->param->channels * s->param->depth; /* bits per pixel, for lineart should be 0x01 */ data[0x1e] = (s->param->depth == 1) ? 0x80 : 0x00; /* modify for lineart: 0x80 NEW */ data[0x1f] = (s->param->depth == 1) ? 0x80 : 0x7f; /* modify for lineart: 0x80 */ data[0x20] = (s->param->depth == 1) ? 0x01 : 0xff; /* modify for lineart: 0x01 */ data[0x23] = 0x81; return pixma_exec (s, &mp->cb); } static int calibrate (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; return pixma_exec_short_cmd (s, &mp->cb, cmd_calibrate); } static int read_image_block (pixma_t * s, uint8_t * header, uint8_t * data) { static const uint8_t cmd[10] = /* 0xd420 cmd */ { 0xd4, 0x20, 0, 0, 0, 0, 0, IMAGE_BLOCK_SIZE / 256, 4, 0 }; mp730_t *mp = (mp730_t *) s->subdriver; const int hlen = 2 + 4; int error, datalen; mp->state = state_transfering; mp->cb.reslen = pixma_cmd_transaction (s, cmd, sizeof (cmd), mp->cb.buf, 512); datalen = mp->cb.reslen; if (datalen < 0) return datalen; memcpy (header, mp->cb.buf, hlen); if (datalen >= hlen) { datalen -= hlen; memcpy (data, mp->cb.buf + hlen, datalen); data += datalen; if (mp->cb.reslen == 512) { error = pixma_read (s->io, data, IMAGE_BLOCK_SIZE - 512 + hlen); if (error < 0) return error; datalen += error; } } mp->state = state_scanning; mp->cb.expected_reslen = 0; error = pixma_check_result (&mp->cb); if (error < 0) return error; if (mp->cb.reslen < hlen) return PIXMA_EPROTO; return datalen; } static int send_time (pixma_t * s) { /* Why does a scanner need a time? */ time_t now; struct tm *t; uint8_t *data; mp730_t *mp = (mp730_t *) s->subdriver; data = pixma_newcmd (&mp->cb, cmd_time, 20, 0); pixma_get_time (&now, NULL); t = localtime (&now); strftime ((char *) data, 16, "%y/%m/%d %H:%M", t); PDBG (pixma_dbg (3, "Sending time: '%s'\n", (char *) data)); return pixma_exec (s, &mp->cb); } static int handle_interrupt (pixma_t * s, int timeout) { uint8_t buf[16]; int len; len = pixma_wait_interrupt (s->io, buf, sizeof (buf), timeout); if (len == PIXMA_ETIMEDOUT) return 0; if (len < 0) return len; switch (s->cfg->pid) { case MP360_PID: case MP370_PID: case MP375R_PID: case MP390_PID: case MF5730_PID: case MF5750_PID: case MF5770_PID: case MF3110_PID: case IR1020_PID: if (len != 16) { PDBG (pixma_dbg (1, "WARNING:unexpected interrupt packet length %d\n", len)); return PIXMA_EPROTO; } if (buf[12] & 0x40) query_status (s); if (buf[10] & 0x40) send_time (s); /* FIXME: following is unverified! */ if (buf[15] & 1) s->events = PIXMA_EV_BUTTON2; /* b/w scan */ if (buf[15] & 2) s->events = PIXMA_EV_BUTTON1; /* color scan */ break; case MP5_PID: case MP10_PID: case MP700_PID: case MP730_PID: case MP710_PID: case MP740_PID: if (len != 8) { PDBG (pixma_dbg (1, "WARNING:unexpected interrupt packet length %d\n", len)); return PIXMA_EPROTO; } if (buf[7] & 0x10) s->events = PIXMA_EV_BUTTON1; if (buf[5] & 8) send_time (s); break; default: PDBG (pixma_dbg (1, "WARNING:unknown interrupt, please report!\n")); PDBG (pixma_hexdump (1, buf, len)); } return 1; } static int has_ccd_sensor (pixma_t * s) { return (s->cfg->pid == MP360_PID || s->cfg->pid == MP370_PID || s->cfg->pid == MP375R_PID || s->cfg->pid == MP390_PID || s->cfg->pid == MF5730_PID || s->cfg->pid == MF5750_PID || s->cfg->pid == MF5770_PID); } static int read_error_info (pixma_t * s, void *buf, unsigned size) { unsigned len = 16; mp730_t *mp = (mp730_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mp->cb, cmd_error_info, 0, len); error = pixma_exec (s, &mp->cb); if (error < 0) return error; if (buf && len < size) { size = len; /* NOTE: I've absolutely no idea what the returned data mean. */ memcpy (buf, data, size); error = len; } return error; } static int step1 (pixma_t * s) { int error; error = query_status (s); if (error < 0) return error; if ((s->param->source == PIXMA_SOURCE_ADF || s->param->source == PIXMA_SOURCE_ADFDUP) && !has_paper (s)) return PIXMA_ENO_PAPER; if (has_ccd_sensor (s)) { switch (s->cfg->pid) { case MF5730_PID: case MF5750_PID: case MF5770_PID: /* MF57x0: Wait 10 sec before starting for 1st page only */ if (s->param->adf_pageid == 0) { int tmo = 10; /* like Windows driver, 10 sec CCD calibration ? */ while (--tmo >= 0) { error = handle_interrupt (s, 1000); \ if (s->cancel) \ return PIXMA_ECANCELED; \ if (error != PIXMA_ECANCELED && error < 0) \ return error; PDBG (pixma_dbg (2, "CCD Calibration ends in %d sec.\n", tmo)); } } break; default: break; } activate (s, 0); error = calibrate (s); switch (s->cfg->pid) { case MF5730_PID: case MF5750_PID: case MF5770_PID: /* MF57x0: calibration returns PIXMA_STATUS_FAILED */ if (error == PIXMA_ECANCELED) error = read_error_info (s, NULL, 0); break; default: break; } // ignore result from calibrate() // don't interrupt @ PIXMA_STATUS_BUSY error = 0; } if (error >= 0) error = activate (s, 0); if (error >= 0) error = activate (s, 4); return error; } static void pack_rgb (const uint8_t * src, unsigned nlines, unsigned w, uint8_t * dst) { unsigned w2, stride; w2 = 2 * w; stride = 3 * w; for (; nlines != 0; nlines--) { unsigned x; for (x = 0; x != w; x++) { *dst++ = src[x + 0]; *dst++ = src[x + w]; *dst++ = src[x + w2]; } src += stride; } } static int mp730_open (pixma_t * s) { mp730_t *mp; uint8_t *buf; mp = (mp730_t *) calloc (1, sizeof (*mp)); if (!mp) return PIXMA_ENOMEM; buf = (uint8_t *) malloc (CMDBUF_SIZE); if (!buf) { free (mp); return PIXMA_ENOMEM; } s->subdriver = mp; mp->state = state_idle; mp->cb.buf = buf; mp->cb.size = CMDBUF_SIZE; mp->cb.res_header_len = 2; mp->cb.cmd_header_len = 10; mp->cb.cmd_len_field_ofs = 7; PDBG (pixma_dbg (3, "Trying to clear the interrupt buffer...\n")); if (handle_interrupt (s, 200) == 0) { PDBG (pixma_dbg (3, " no packets in buffer\n")); } return 0; } static void mp730_close (pixma_t * s) { mp730_t *mp = (mp730_t *) s->subdriver; mp730_finish_scan (s); free (mp->cb.buf); free (mp->buf); free (mp); s->subdriver = NULL; } static unsigned calc_raw_width (pixma_t * s, const pixma_scan_param_t * sp) { unsigned raw_width; /* FIXME: Does MP730 need the alignment? */ /* TODO test: MP710/740 */ if (sp->channels == 1) { if (sp->depth == 8) /* grayscale */ { 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 || s->cfg->pid == MP375R_PID || s->cfg->pid == MP390_PID || s->cfg->pid == IR1020_PID) raw_width = ALIGN_SUP (sp->w, 4); else raw_width = ALIGN_SUP (sp->w, 12); } else /* depth = 1 : LINEART */ raw_width = ALIGN_SUP (sp->w, 16); } else raw_width = ALIGN_SUP (sp->w, 4); return raw_width; } static int mp730_check_param (pixma_t * s, pixma_scan_param_t * sp) { uint8_t k = 1; /* check if channels is 3, or if depth is 1 then channels also 1 else set depth to 8 */ if ((sp->channels==3) || !(sp->channels==1 && sp->depth==1)) { sp->depth=8; } /* 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 || s->cfg->pid == MP375R_PID || s->cfg->pid == MP390_PID) { if (sp->channels == 1) k = sp->xdpi / MIN (sp->xdpi, 600); } sp->x /= k; sp->y /= k; sp->h /= k; sp->xdpi /= k; sp->ydpi = sp->xdpi; sp->w = calc_raw_width (s, sp); sp->w /= k; sp->line_size = (calc_raw_width (s, sp) * sp->channels * sp->depth) / 8; return 0; } static int mp730_scan (pixma_t * s) { int error, n; mp730_t *mp = (mp730_t *) s->subdriver; uint8_t *buf; if (mp->state != state_idle) return PIXMA_EBUSY; /* clear interrupt packets buffer */ while (handle_interrupt (s, 0) > 0) { } mp->raw_width = calc_raw_width (s, s->param); PDBG (pixma_dbg (3, "raw_width = %u\n", mp->raw_width)); n = IMAGE_BLOCK_SIZE / s->param->line_size + 1; buf = (uint8_t *) malloc ((n + 1) * s->param->line_size + IMAGE_BLOCK_SIZE); if (!buf) return PIXMA_ENOMEM; mp->buf = buf; mp->lbuf = buf; mp->imgbuf = buf + n * s->param->line_size; mp->imgbuf_len = 0; error = step1 (s); if (error >= 0) error = start_session (s); if (error >= 0) mp->state = state_scanning; if (error >= 0) error = select_source (s); if (error >= 0) error = send_scan_param (s); if (error < 0) { mp730_finish_scan (s); return error; } mp->last_block = 0; return 0; } static int mp730_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) { int error, n; mp730_t *mp = (mp730_t *) s->subdriver; unsigned block_size, bytes_received; uint8_t header[16]; do { do { if (s->cancel) return PIXMA_ECANCELED; if (mp->last_block) /* end of image */ return 0; error = read_image_block (s, header, mp->imgbuf + mp->imgbuf_len); if (error < 0) return error; bytes_received = error; block_size = pixma_get_be16 (header + 4); mp->last_block = ((header[2] & 0x28) == 0x28); if (mp->last_block) { /* end of image */ mp->state = state_finished; } if ((header[2] & ~0x38) != 0) { PDBG (pixma_dbg (1, "WARNING: Unexpected result header\n")); PDBG (pixma_hexdump (1, header, 16)); } PASSERT (bytes_received == block_size); if (block_size == 0) { /* no image data at this moment. */ /*pixma_sleep(100000); *//* FIXME: too short, too long? */ handle_interrupt (s, 100); } } while (block_size == 0); /* TODO: simplify! */ mp->imgbuf_len += bytes_received; n = mp->imgbuf_len / s->param->line_size; /* n = number of full lines (rows) we have in the buffer. */ if (n != 0) { if (s->param->channels != 1 && s->cfg->pid != MF5730_PID && s->cfg->pid != MF5750_PID && s->cfg->pid != MF5770_PID && s->cfg->pid != MF3110_PID && s->cfg->pid != IR1020_PID) { /* color, and not an MF57x0 nor MF3110 */ pack_rgb (mp->imgbuf, n, mp->raw_width, mp->lbuf); } else /* grayscale/lineart or MF57x0 or MF3110 */ memcpy (mp->lbuf, mp->imgbuf, n * s->param->line_size); block_size = n * s->param->line_size; mp->imgbuf_len -= block_size; memcpy (mp->imgbuf, mp->imgbuf + block_size, mp->imgbuf_len); } } while (n == 0); ib->rptr = mp->lbuf; ib->rend = mp->lbuf + block_size; return ib->rend - ib->rptr; } static void mp730_finish_scan (pixma_t * s) { int error, aborted = 0; mp730_t *mp = (mp730_t *) s->subdriver; switch (mp->state) { case state_transfering: drain_bulk_in (s); /* fall through */ case state_scanning: case state_warmup: aborted = 1; error = abort_session (s); if (error < 0) PDBG (pixma_dbg (1, "WARNING:abort_session() failed %s\n", pixma_strerror (error))); /* fall through */ case state_finished: 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 */ case state_idle: break; } } static void mp730_wait_event (pixma_t * s, int timeout) { /* FIXME: timeout is not correct. See usbGetCompleteUrbNoIntr() for * instance. */ while (s->events == 0 && handle_interrupt (s, timeout) > 0) { } } static int mp730_get_status (pixma_t * s, pixma_device_status_t * status) { int error; error = query_status (s); if (error < 0) return error; status->hardware = PIXMA_HARDWARE_OK; status->adf = (has_paper (s)) ? PIXMA_ADF_OK : PIXMA_ADF_NO_PAPER; return 0; } static const pixma_scan_ops_t pixma_mp730_ops = { mp730_open, mp730_close, mp730_scan, mp730_fill_buffer, mp730_finish_scan, mp730_wait_event, mp730_check_param, mp730_get_status }; /* TODO: implement adftpu_min_dpi & adftpu_max_dpi for grayscale & lineart */ #define DEVICE(name, model, pid, dpi, w, h, cap) { \ name, /* name */ \ model, /* model */ \ 0x04a9, pid, /* vid pid */ \ 1, /* iface */ \ &pixma_mp730_ops, /* ops */ \ 0, /* min_xdpi not used in this subdriver */ \ dpi, dpi, /* xdpi, ydpi */ \ 0, 0, /* adftpu_min_dpi & adftpu_max_dpi not used in this subdriver */ \ 0, 0, /* tpuir_min_dpi & tpuir_max_dpi not used in this subdriver */ \ w, h, /* width, height */ \ PIXMA_CAP_GRAY|PIXMA_CAP_EVENTS|cap \ } 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), DEVICE ("PIXMA MP390", "MP390", MP390_PID, 1200, 636, 868, PIXMA_CAP_LINEART), DEVICE ("PIXMA MP700", "MP700", MP700_PID, 1200, 638, 877 /*1035 */ , PIXMA_CAP_LINEART), DEVICE ("PIXMA MP710", "MP710", MP710_PID, 1200, 637, 868, PIXMA_CAP_LINEART), DEVICE ("PIXMA MP730", "MP730", MP730_PID, 1200, 637, 868, PIXMA_CAP_ADF | PIXMA_CAP_LINEART), DEVICE ("PIXMA MP740", "MP740", MP740_PID, 1200, 637, 868, PIXMA_CAP_ADF | PIXMA_CAP_LINEART), DEVICE ("Canon imageCLASS MF5730", "MF5730", MF5730_PID, 1200, 636, 868, PIXMA_CAP_ADF), DEVICE ("Canon imageCLASS MF5750", "MF5750", MF5750_PID, 1200, 636, 868, PIXMA_CAP_ADF), DEVICE ("Canon imageCLASS MF5770", "MF5770", MF5770_PID, 1200, 636, 868, PIXMA_CAP_ADF), DEVICE ("Canon imageCLASS MF3110", "MF3110", MF3110_PID, 600, 636, 868, 0), DEVICE ("Canon iR 1020/1024/1025", "iR1020", IR1020_PID, 600, 636, 868, PIXMA_CAP_ADFDUP), DEVICE (NULL, NULL, 0, 0, 0, 0, 0) }; sane-backends-1.0.29/backend/pixma/pixma_mp800.c0000666000000000000000000023162513615534521016125 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2007-2009 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* test cases 1. short USB packet (must be no -ETIMEDOUT) 2. cancel using button on the printer (look for abort command) 3. start scan while busy (status 0x1414) 4. cancel using ctrl-c (must send abort command) */ #define TPU_48 /* uncomment to activate TPU scan at 48 bits */ /*#define DEBUG_TPU_48*//* uncomment to debug 48 bits TPU on a non TPU device */ /*#define DEBUG_TPU_24*//* uncomment to debug 24 bits TPU on a non TPU device */ /*#define TPUIR_USE_RGB*/ /* uncomment to use RGB channels and convert them to gray; otherwise use R channel only */ #include "../include/sane/config.h" #include #include #include #include /* localtime(C90) */ #include "pixma_rename.h" #include "pixma_common.h" #include "pixma_io.h" /* Some macro code to enhance readability */ #define RET_IF_ERR(x) do { \ if ((error = (x)) < 0) \ return error; \ } while(0) #define WAIT_INTERRUPT(x) do { \ error = handle_interrupt (s, x); \ if (s->cancel) \ return PIXMA_ECANCELED; \ if (error != PIXMA_ECANCELED && error < 0) \ return error; \ } while(0) #ifdef __GNUC__ # define UNUSED(v) (void) v #else # define UNUSED(v) #endif /* Size of the command buffer should be multiple of wMaxPacketLength and greater than 4096+24. 4096 = size of gamma table. 24 = header + checksum */ #define IMAGE_BLOCK_SIZE (512*1024) #define CMDBUF_SIZE (4096 + 24) #define DEFAULT_GAMMA 2.0 /***** Gamma different from 1.0 is potentially impacting color profile generation *****/ #define UNKNOWN_PID 0xffff #define CANON_VID 0x04a9 /* Generation 1 */ #define MP800_PID 0x170d #define MP800R_PID 0x170e #define MP830_PID 0x1713 /* Generation 2 */ #define MP810_PID 0x171a #define MP960_PID 0x171b /* Generation 3 */ /* PIXMA 2007 vintage */ #define MP970_PID 0x1726 /* Flatbed scanner CCD (2007) */ #define CS8800F_PID 0x1901 /* PIXMA 2008 vintage */ #define MP980_PID 0x172d /* Generation 4 */ #define MP990_PID 0x1740 /* Flatbed scanner CCD (2010) */ #define CS9000F_PID 0x1908 /* 2010 new device (untested) */ #define MG8100_PID 0x174b /* CCD */ /* 2011 new device (untested) */ #define MG8200_PID 0x1756 /* CCD */ /* 2013 new device */ #define CS9000F_MII_PID 0x190d /* Generation 4 XML messages that encapsulates the Pixma protocol messages */ #define XML_START_1 \ "\ \ StartJob\ 00000001\ 1" #define XML_START_2 \ "\ \ VendorCmd\ 00000001\ ModeShift1\ " #define XML_END \ "\ \ EndJob\ 00000001\ " #define XML_OK "OK" enum mp810_state_t { state_idle, state_warmup, state_scanning, state_transfering, state_finished }; enum mp810_cmd_t { cmd_start_session = 0xdb20, cmd_select_source = 0xdd20, cmd_gamma = 0xee20, cmd_scan_param = 0xde20, cmd_status = 0xf320, cmd_abort_session = 0xef20, cmd_time = 0xeb80, cmd_read_image = 0xd420, cmd_error_info = 0xff20, cmd_start_calibrate_ccd_3 = 0xd520, cmd_end_calibrate_ccd_3 = 0xd720, cmd_scan_param_3 = 0xd820, cmd_scan_start_3 = 0xd920, cmd_status_3 = 0xda20, cmd_get_tpu_info_3 = 0xf520, cmd_set_tpu_info_3 = 0xea20, cmd_e920 = 0xe920 /* seen in MP800 */ }; typedef struct mp810_t { enum mp810_state_t state; pixma_cmdbuf_t cb; uint8_t *imgbuf; uint8_t current_status[16]; unsigned last_block; uint8_t generation; /* for Generation 3 and CCD shift */ uint8_t *linebuf; uint8_t *data_left_ofs; unsigned data_left_len; int shift[3]; unsigned color_shift; unsigned stripe_shift; unsigned stripe_shift2; /* added for MP810, MP960 at 4800dpi & 9000F at 9600dpi */ unsigned jumplines; /* added for MP810, MP960 at 4800dpi & 9000F at 9600dpi */ uint8_t tpu_datalen; uint8_t tpu_data[0x40]; } mp810_t; /* STAT: 0x0606 = ok, 0x1515 = failed (PIXMA_ECANCELED), 0x1414 = busy (PIXMA_EBUSY) Transaction scheme 1. command_header/data | result_header 2. command_header | result_header/data 3. command_header | result_header/image_data - data has checksum in the last byte. - image_data has no checksum. - data and image_data begins in the same USB packet as command_header or result_header. command format #1: u16be cmd u8[6] 0 u8[4] 0 u32be PLEN parameter length u8[PLEN-1] parameter u8 parameter check sum result: u16be STAT u8 0 u8 0 or 0x21 if STAT == 0x1414 u8[4] 0 command format #2: u16be cmd u8[6] 0 u8[4] 0 u32be RLEN result length result: u16be STAT u8[6] 0 u8[RLEN-1] result u8 result check sum command format #3: (only used by read_image_block) u16be 0xd420 u8[6] 0 u8[4] 0 u32be max. block size + 8 result: u16be STAT u8[6] 0 u8 block info bitfield: 0x8 = end of scan, 0x10 = no more paper, 0x20 = no more data u8[3] 0 u32be ILEN image data size u8[ILEN] image data */ static void mp810_finish_scan (pixma_t * s); 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 int is_scanning_from_tpu (pixma_t * s) { return (s->param->source == PIXMA_SOURCE_TPU); } static int send_xml_dialog (pixma_t * s, const char * xml_message) { mp810_t *mp = (mp810_t *) s->subdriver; int datalen; datalen = pixma_cmd_transaction (s, xml_message, strlen (xml_message), mp->cb.buf, 1024); if (datalen < 0) return datalen; mp->cb.buf[datalen] = 0; PDBG(pixma_dbg (10, "XML message sent to scanner:\n%s\n", xml_message)); PDBG(pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf)); return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL); } static void new_cmd_tpu_msg (pixma_t *s, pixma_cmdbuf_t * cb, uint16_t cmd) { pixma_newcmd (cb, cmd, 0, 0); cb->buf[3] = (is_scanning_from_tpu (s)) ? 0x01 : 0x00; } static int start_session (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; new_cmd_tpu_msg (s, &mp->cb, cmd_start_session); return pixma_exec (s, &mp->cb); } static int start_scan_3 (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; new_cmd_tpu_msg (s, &mp->cb, cmd_scan_start_3); return pixma_exec (s, &mp->cb); } static int send_cmd_start_calibrate_ccd_3 (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; pixma_newcmd (&mp->cb, cmd_start_calibrate_ccd_3, 0, 0); mp->cb.buf[3] = 0x01; return pixma_exec (s, &mp->cb); } static int is_calibrated (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; if (mp->generation >= 3) { return ((mp->current_status[0] & 0x01) == 1); } if (mp->generation == 1) { return (mp->current_status[8] == 1); } else { return (mp->current_status[9] == 1); } } static int has_paper (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; if (is_scanning_from_adfdup (s)) return (mp->current_status[1] == 0 || mp->current_status[2] == 0); else return (mp->current_status[1] == 0); } static void drain_bulk_in (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; while (pixma_read (s->io, mp->imgbuf, IMAGE_BLOCK_SIZE) >= 0) ; } static int abort_session (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; return pixma_exec_short_cmd (s, &mp->cb, cmd_abort_session); } static int send_cmd_e920 (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; return pixma_exec_short_cmd (s, &mp->cb, cmd_e920); } static int select_source (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; uint8_t *data; data = pixma_newcmd (&mp->cb, cmd_select_source, 12, 0); data[5] = ((mp->generation == 2) ? 1 : 0); switch (s->param->source) { case PIXMA_SOURCE_FLATBED: data[0] = 1; data[1] = 1; break; case PIXMA_SOURCE_ADF: data[0] = 2; data[5] = 1; data[6] = 1; break; case PIXMA_SOURCE_ADFDUP: data[0] = 2; data[5] = 3; data[6] = 3; break; case PIXMA_SOURCE_TPU: data[0] = 4; data[1] = 2; break; } return pixma_exec (s, &mp->cb); } static int send_get_tpu_info_3 (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mp->cb, cmd_get_tpu_info_3, 0, 0x34); RET_IF_ERR(pixma_exec (s, &mp->cb)); memcpy (mp->tpu_data, data, 0x34); return error; } static int send_set_tpu_info (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; uint8_t *data; if (mp->tpu_datalen == 0) return 0; data = pixma_newcmd (&mp->cb, cmd_set_tpu_info_3, 0x34, 0); memcpy (data, mp->tpu_data, 0x34); return pixma_exec (s, &mp->cb); } static int send_gamma_table (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; const uint8_t *lut = s->param->gamma_table; uint8_t *data; if (mp->generation == 1) { data = pixma_newcmd (&mp->cb, cmd_gamma, 4096 + 8, 0); data[0] = (s->param->channels == 3) ? 0x10 : 0x01; pixma_set_be16 (0x1004, data + 2); if (lut) memcpy (data + 4, lut, 4096); else pixma_fill_gamma_table (DEFAULT_GAMMA, data + 4, 4096); } else { /* FIXME: Gamma table for 2nd generation: 1024 * uint16_le */ data = pixma_newcmd (&mp->cb, cmd_gamma, 2048 + 8, 0); data[0] = 0x10; pixma_set_be16 (0x0804, data + 2); if (lut) { int i; for (i = 0; i < 1024; i++) { int j = (i << 2) + (i >> 8); data[4 + 2 * i + 0] = lut[j]; data[4 + 2 * i + 1] = lut[j]; } } else { int i; pixma_fill_gamma_table (DEFAULT_GAMMA, data + 4, 2048); for (i = 0; i < 1024; i++) { int j = (i << 1) + (i >> 9); data[4 + 2 * i + 0] = data[4 + j]; data[4 + 2 * i + 1] = data[4 + j]; } } } return pixma_exec (s, &mp->cb); } static unsigned calc_raw_width (const mp810_t * mp, const pixma_scan_param_t * param) { unsigned raw_width; /* NOTE: Actually, we can send arbitary width to MP810. Lines returned are always padded to multiple of 4 or 12 pixels. Is this valid for other models, too? */ if (mp->generation >= 2) { raw_width = ALIGN_SUP (param->w + param->xs, 32); /* PDBG (pixma_dbg (4, "*calc_raw_width***** width %u extended by %u and rounded to %u *****\n", param->w, param->xs, raw_width)); */ } else if (param->channels == 1) { raw_width = ALIGN_SUP (param->w + param->xs, 12); } else { raw_width = ALIGN_SUP (param->w + param->xs, 4); } return raw_width; } static int has_ccd_sensor (pixma_t * s) { return ((s->cfg->cap & PIXMA_CAP_CCD) != 0); } #if 0 static int is_color (pixma_t * s) { return (s->param->mode == PIXMA_SCAN_MODE_COLOR); } static int is_color_48 (pixma_t * s) { return (s->param->mode == PIXMA_SCAN_MODE_COLOR_48); } static int is_color_negative (pixma_t * s) { return (s->param->mode == PIXMA_SCAN_MODE_NEGATIVE_COLOR); } static int is_color_all (pixma_t * s) { return (is_color (s) || is_color_48 (s) || is_color_negative (s)); } #endif static int is_gray (pixma_t * s) { return (s->param->mode == PIXMA_SCAN_MODE_GRAY); } static int is_gray_16 (pixma_t * s) { return (s->param->mode == PIXMA_SCAN_MODE_GRAY_16); } static int is_gray_negative (pixma_t * s) { return (s->param->mode == PIXMA_SCAN_MODE_NEGATIVE_GRAY); } static int is_gray_all (pixma_t * s) { return (is_gray (s) || is_gray_16 (s) || is_gray_negative (s)); } static int is_lineart (pixma_t * s) { return (s->param->mode == PIXMA_SCAN_MODE_LINEART); } static int is_tpuir (pixma_t * s) { return (s->param->mode == PIXMA_SCAN_MODE_TPUIR); } /* CCD sensors don't have neither a Grayscale mode nor a Lineart mode, * but use color mode instead */ static unsigned get_cis_ccd_line_size (pixma_t * s) { return (( s->param->wx ? s->param->line_size / s->param->w * s->param->wx : s->param->line_size) * ((is_tpuir (s) || is_gray_all (s) || is_lineart (s)) ? 3 : 1)); } static unsigned calc_shifting (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; /* If stripes shift needed (CCD devices), how many pixels shift */ mp->stripe_shift = 0; mp->stripe_shift2 = 0; mp->jumplines = 0; switch (s->cfg->pid) { case MP800_PID: case MP800R_PID: case MP830_PID: if (s->param->xdpi == 2400) { if (is_scanning_from_tpu(s)) mp->stripe_shift = 6; else mp->stripe_shift = 3; } if (s->param->ydpi > 75) { mp->color_shift = s->param->ydpi / ((s->param->ydpi < 1200) ? 150 : 75); if (is_scanning_from_tpu (s)) mp->color_shift = s->param->ydpi / 75; /* If you're trying to decipher this color-shifting code, the following line is where the magic is revealed. */ mp->shift[1] = mp->color_shift * get_cis_ccd_line_size (s); if (is_scanning_from_adf (s)) { /* ADF */ mp->shift[0] = 0; mp->shift[2] = 2 * mp->shift[1]; } else { /* Flatbed or TPU */ mp->shift[0] = 2 * mp->shift[1]; mp->shift[2] = 0; } } break; case MP970_PID: /* MP970 at 4800 dpi */ case CS8800F_PID: /* CanoScan 8800F at 4800 dpi */ if (s->param->xdpi == 4800) { if (is_scanning_from_tpu (s)) mp->stripe_shift = 6; else mp->stripe_shift = 3; } break; case CS9000F_PID: /* CanoScan 9000F at 4800 dpi */ case CS9000F_MII_PID: if (s->param->xdpi == 4800) { if (is_scanning_from_tpu (s)) mp->stripe_shift = 6; /* should work for CS9000F same as manual */ else mp->stripe_shift = 3; } if (s->param->xdpi == 9600) { if (is_scanning_from_tpu (s)) { /* need to double up for TPU */ mp->stripe_shift = 6; /* for 1st set of 4 images */ /* unfortunately there are 2 stripe shifts */ mp->stripe_shift2 = 6; /* for 2nd set of 4 images */ mp->jumplines = 32; /* try 33 or 34 */ } /* there is no 9600dpi support in flatbed mode */ } break; case MP960_PID: if (s->param->xdpi == 2400) { if (is_scanning_from_tpu (s)) mp->stripe_shift = 6; else mp->stripe_shift = 3; } if (s->param->xdpi == 4800) { if (is_scanning_from_tpu (s)) { mp->stripe_shift = 6; mp->stripe_shift2 = 6; } else { mp->stripe_shift = 3; mp->stripe_shift2 = 3; } mp->jumplines = 33; /* better than 32 or 34 : applies to flatbed & TPU */ } break; case MP810_PID: if (s->param->xdpi == 2400) { if (is_scanning_from_tpu (s)) mp->stripe_shift = 6; else mp->stripe_shift = 3; } if (s->param->xdpi == 4800) { if (is_scanning_from_tpu (s)) { mp->stripe_shift = 6; mp->stripe_shift2 = 6; } else { mp->stripe_shift = 3; mp->stripe_shift2 = 3; } mp->jumplines = 33; /* better than 32 or 34 : applies to flatbed & TPU */ } break; case MP990_PID: if (s->param->xdpi == 4800) { if (is_scanning_from_tpu (s)) { mp->stripe_shift = 6; mp->stripe_shift2 = 6; } else { mp->stripe_shift = 3; mp->stripe_shift2 = 3; } mp->jumplines = 34; /* better than 32 or 34 : applies to flatbed & TPU */ } break; default: /* Default, and all CIS devices */ break; } /* If color plane shift (CCD devices), how many pixels shift */ mp->color_shift = mp->shift[0] = mp->shift[1] = mp->shift[2] = 0; if (s->param->ydpi > 75) { switch (s->cfg->pid) { case MP970_PID: case CS8800F_PID: /* CanoScan 8800F */ mp->color_shift = s->param->ydpi / 50; mp->shift[1] = mp->color_shift * get_cis_ccd_line_size (s); mp->shift[0] = 0; mp->shift[2] = 2 * mp->shift[1]; break; case CS9000F_PID: /* CanoScan 9000F */ case CS9000F_MII_PID: mp->color_shift = s->param->ydpi / 30; mp->shift[1] = mp->color_shift * get_cis_ccd_line_size (s); mp->shift[0] = 0; mp->shift[2] = 2 * mp->shift[1]; break; case MP980_PID: case MP990_PID: case MG8200_PID: if (s->param->ydpi > 150) { mp->color_shift = s->param->ydpi / 75; mp->shift[1] = mp->color_shift * get_cis_ccd_line_size (s); mp->shift[0] = 0; mp->shift[2] = 2 * mp->shift[1]; } break; case MP810_PID: case MP960_PID: mp->color_shift = s->param->ydpi / 50; if (is_scanning_from_tpu (s)) mp->color_shift = s->param->ydpi / 50; mp->shift[1] = mp->color_shift * get_cis_ccd_line_size (s); mp->shift[0] = 2 * mp->shift[1]; mp->shift[2] = 0; break; default: break; } } /* special settings for 16 bit flatbed mode @ 75 dpi * minimum of 150 dpi is used yet */ /* else if (!is_scanning_from_tpu (s)) { switch (s->cfg->pid) { case CS9000F_PID: case CS9000F_MII_PID: if (is_color_48 (s) || is_gray_16 (s)) { mp->color_shift = 5; mp->shift[1] = 0; mp->shift[0] = 0; mp->shift[2] = 0; } break; } } */ /* PDBG (pixma_dbg (4, "*calc_shifing***** color_shift = %u, stripe_shift = %u, jumplines = %u *****\n", mp->color_shift, mp->stripe_shift, mp->jumplines)); */ return (2 * mp->color_shift + mp->stripe_shift + mp->jumplines); /* note impact of stripe shift2 later if needed! */ } static int send_scan_param (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; uint8_t *data; unsigned raw_width = calc_raw_width (mp, s->param); unsigned h, h1, h2, shifting; /* TPU scan does not support lineart */ if (is_scanning_from_tpu (s) && is_lineart (s)) { return PIXMA_ENOTSUP; } shifting = calc_shifting (s); h1 = s->param->h + shifting; /* add lines for color shifting */ /* PDBG (pixma_dbg (4, "* send_scan_param: height calc (choose lesser) 1 %u \n", h1 )); */ if (mp->generation >= 4) /* use most global condition */ { /* tested for MP960, 9000F */ /* add lines for color shifting */ /* otherwise you cannot scan all lines defined for flatbed mode */ /* this shouldn't affect TPU mode */ h2 = s->cfg->height * s->param->ydpi / 75 + shifting; /* PDBG (pixma_dbg (4, "* send_scan_param: height calc (choose lesser) 2 %u = %u max. lines for scanner + %u lines for color shifting \n", h2, s->cfg->height * s->param->ydpi / 75, shifting )); */ } else { /* TODO: Check for other scanners. */ h2 = s->cfg->height * s->param->ydpi / 75; /* this might be causing problems for generation 1 devices */ /* PDBG (pixma_dbg (4, "* send_scan_param: height calc (choose lesser) 2 %u \n", h2 )); */ } h = MIN (h1, h2); if (mp->generation <= 2) { data = pixma_newcmd (&mp->cb, cmd_scan_param, 0x30, 0); pixma_set_be16 (s->param->xdpi | 0x8000, data + 0x04); pixma_set_be16 (s->param->ydpi | 0x8000, data + 0x06); pixma_set_be32 (s->param->x, data + 0x08); if (mp->generation == 2) pixma_set_be32 (s->param->x - s->param->xs, data + 0x08); pixma_set_be32 (s->param->y, data + 0x0c); pixma_set_be32 (raw_width, data + 0x10); pixma_set_be32 (h, data + 0x14); data[0x18] = ((s->param->channels != 1) || is_gray_all (s) || is_lineart (s)) ? 0x08 : 0x04; data[0x19] = ((s->param->software_lineart) ? 8 : s->param->depth) * ((is_gray_all (s) || is_lineart (s)) ? 3 : s->param->channels); /* bits per pixel */ data[0x1a] = (is_scanning_from_tpu (s) ? 1 : 0); data[0x20] = 0xff; data[0x23] = 0x81; data[0x26] = 0x02; data[0x27] = 0x01; } else { /* scan parameters: * ================ * * byte | # of | mode | value / description * | bytes | | * -----+-------+---------+--------------------------- * 0x00 | 1 | default | 0x01 * | | adf | 0x02 * | | tpu | 0x04 * | | tpuir | cs9000f: 0x03 * -----+-------+---------+--------------------------- * 0x01 | 1 | default | 0x00 * | | tpu | 0x02 * -----+-------+---------+--------------------------- * 0x02 | 1 | default | 0x01 * | | adfdup | 0x03 * -----+-------+---------+--------------------------- * 0x03 | 1 | default | 0x00 * | | adfdup | 0x03 * -----+-------+---------+--------------------------- * 0x04 | 1 | all | 0x00 * -----+-------+---------+--------------------------- * 0x05 | 1 | all | 0x01: This one also seen at 0. Don't know yet what's used for. * -----+-------+---------+--------------------------- * ... | 1 | all | 0x00 * -----+-------+---------+--------------------------- * 0x08 | 2 | all | xdpi | 0x8000 * -----+-------+---------+--------------------------- * 0x0a | 2 | all | ydpi | 0x8000: Must be the same as xdpi. * -----+-------+---------+--------------------------- * 0x0c | 4 | all | x position of start pixel * -----+-------+---------+--------------------------- * 0x10 | 4 | all | y position of start pixel * -----+-------+---------+--------------------------- * 0x14 | 4 | all | # of pixels in 1 line * -----+-------+---------+--------------------------- * 0x18 | 4 | all | # of scan lines * -----+-------+---------+--------------------------- * 0x1c | 1 | all | 0x08 * | | | 0x04 = relict from cis scanners? * -----+-------+---------+--------------------------- * 0x1d | 1 | all | # of bits per pixel * -----+-------+---------+--------------------------- * 0x1e | 1 | default | 0x00: paper * | | tpu | 0x01: positives * | | tpu | 0x02: negatives * | | tpuir | 0x01: positives * -----+-------+---------+--------------------------- * 0x1f | 1 | all | 0x01 * | | | cs9000f: 0x00: Not sure if that is because of positives. * -----+-------+---------+--------------------------- * 0x20 | 1 | all | 0xff * -----+-------+---------+--------------------------- * 0x21 | 1 | all | 0x81 * -----+-------+---------+--------------------------- * 0x22 | 1 | all | 0x00 * -----+-------+---------+--------------------------- * 0x23 | 1 | all | 0x02 * -----+-------+---------+--------------------------- * 0x24 | 1 | all | 0x01 * -----+-------+---------+--------------------------- * 0x25 | 1 | default | 0x00; cs8800f: 0x01 * | | tpu | 0x00; cs9000f, mg8200, mp990: 0x01 * | | tpuir | cs9000f: 0x00 * -----+-------+---------+--------------------------- * ... | 1 | all | 0x00 * -----+-------+---------+--------------------------- * 0x30 | 1 | all | 0x01 * */ data = pixma_newcmd (&mp->cb, cmd_scan_param_3, 0x38, 0); data[0x00] = is_scanning_from_adf (s) ? 0x02 : 0x01; data[0x01] = 0x01; if (is_scanning_from_tpu (s)) { data[0x00] = is_tpuir (s) ? 0x03 : 0x04; data[0x01] = 0x02; data[0x1e] = 0x02; /* NB: CanoScan 8800F: 0x02->negatives, 0x01->positives, paper->0x00 */ } data[0x02] = 0x01; if (is_scanning_from_adfdup (s)) { data[0x02] = 0x03; data[0x03] = 0x03; } if (s->cfg->pid != MG8200_PID) data[0x05] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ /* the scanner controls the scan */ /* no software control needed */ pixma_set_be16 (s->param->xdpi | 0x8000, data + 0x08); pixma_set_be16 (s->param->ydpi | 0x8000, data + 0x0a); /*PDBG (pixma_dbg (4, "*send_scan_param***** Setting: xdpi=%hi ydpi=%hi x=%u y=%u w=%u h=%u ***** \n", s->param->xdpi,s->param->ydpi,(s->param->x)-(s->param->xs),s->param->y,raw_width,h));*/ pixma_set_be32 (s->param->x - s->param->xs, data + 0x0c); pixma_set_be32 (s->param->y, data + 0x10); pixma_set_be32 (raw_width, data + 0x14); pixma_set_be32 (h, data + 0x18); data[0x1c] = ((s->param->channels != 1) || is_tpuir (s) || is_gray_all (s) || is_lineart (s)) ? 0x08 : 0x04; #ifdef DEBUG_TPU_48 data[0x1d] = 24; #else data[0x1d] = (is_scanning_from_tpu (s)) ? 48 : (((s->param->software_lineart) ? 8 : s->param->depth) * ((is_tpuir (s) || is_gray_all (s) || is_lineart (s)) ? 3 : s->param->channels)); /* bits per pixel */ #endif data[0x1f] = 0x01; /* for 9000F this appears to be 0x00, not sure if that is because of positives */ if (s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID || s->cfg->pid == MG8200_PID) { data[0x1f] = 0x00; } data[0x20] = 0xff; data[0x21] = 0x81; data[0x23] = 0x02; data[0x24] = 0x01; /* MG8200 & MP990 addition */ if (s->cfg->pid == MG8200_PID || s->cfg->pid == MP990_PID) { if (is_scanning_from_tpu (s)) { data[0x25] = 0x01; } } /* CS8800F & CS9000F addition */ if (s->cfg->pid == CS8800F_PID || s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) { if (is_scanning_from_tpu (s)) { /* TPU */ /* 0x02->negatives, 0x01->positives, paper->0x00 * no paper in TPU mode */ if (s->param->mode == PIXMA_SCAN_MODE_NEGATIVE_COLOR || s->param->mode == PIXMA_SCAN_MODE_NEGATIVE_GRAY) { PDBG( pixma_dbg (4, "*send_scan_param***** TPU scan negatives *****\n")); data[0x1e] = 0x02; } else { PDBG( pixma_dbg (4, "*send_scan_param***** TPU scan positives *****\n")); data[0x1e] = 0x01; } /* CS8800F: 0x00 for TPU color management */ if (s->cfg->pid == CS8800F_PID) data[0x25] = 0x00; /* CS9000F: 0x01 for TPU */ if (s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) data[0x25] = 0x01; if (s->param->mode == PIXMA_SCAN_MODE_TPUIR) data[0x25] = 0x00; } else { /* flatbed and ADF */ /* paper->0x00 */ data[0x1e] = 0x00; /* CS8800F: 0x01 normally */ if (s->cfg->pid == CS8800F_PID) data[0x25] = 0x01; /* CS9000F: 0x00 normally */ if (s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) data[0x25] = 0x00; } } data[0x30] = 0x01; } return pixma_exec (s, &mp->cb); } static int query_status_3 (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; uint8_t *data; int error, status_len; status_len = 8; data = pixma_newcmd (&mp->cb, cmd_status_3, 0, status_len); RET_IF_ERR(pixma_exec (s, &mp->cb)); memcpy (mp->current_status, data, status_len); return error; } static int query_status (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; uint8_t *data; int error, status_len; status_len = (mp->generation == 1) ? 12 : 16; data = pixma_newcmd (&mp->cb, cmd_status, 0, status_len); RET_IF_ERR(pixma_exec (s, &mp->cb)); memcpy (mp->current_status, data, status_len); PDBG( pixma_dbg (3, "Current status: paper=%u cal=%u lamp=%u busy=%u\n", data[1], data[8], data[7], data[9])); return error; } #if 0 static int send_time (pixma_t * s) { /* Why does a scanner need a time? */ time_t now; struct tm *t; uint8_t *data; mp810_t *mp = (mp810_t *) s->subdriver; data = pixma_newcmd (&mp->cb, cmd_time, 20, 0); pixma_get_time (&now, NULL); t = localtime (&now); strftime ((char *) data, 16, "%y/%m/%d %H:%M", t); 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) { uint8_t cmd[16]; mp810_t *mp = (mp810_t *) s->subdriver; const int hlen = 8 + 8; int error, datalen; memset (cmd, 0, sizeof(cmd)); /* PDBG (pixma_dbg (4, "* read_image_block: last_block\n", mp->last_block)); */ pixma_set_be16 (cmd_read_image, cmd); if ((mp->last_block & 0x20) == 0) pixma_set_be32 ((IMAGE_BLOCK_SIZE / 65536) * 65536 + 8, cmd + 0xc); else pixma_set_be32 (32 + 8, cmd + 0xc); mp->state = state_transfering; mp->cb.reslen = pixma_cmd_transaction (s, cmd, sizeof(cmd), mp->cb.buf, 512); /* read 1st 512 bytes of image block */ datalen = mp->cb.reslen; if (datalen < 0) return datalen; memcpy (header, mp->cb.buf, hlen); /* PDBG (pixma_dbg (4, "* read_image_block: datalen %i\n", datalen)); */ /* PDBG (pixma_dbg (4, "* read_image_block: hlen %i\n", hlen)); */ if (datalen >= hlen) { datalen -= hlen; memcpy (data, mp->cb.buf + hlen, datalen); data += datalen; if (mp->cb.reslen == 512) { /* read the rest of the image block */ error = pixma_read (s->io, data, IMAGE_BLOCK_SIZE - 512 + hlen); RET_IF_ERR(error); datalen += error; } } mp->state = state_scanning; mp->cb.expected_reslen = 0; RET_IF_ERR(pixma_check_result (&mp->cb)); if (mp->cb.reslen < hlen) return PIXMA_EPROTO; return datalen; } static int read_error_info (pixma_t * s, void *buf, unsigned size) { unsigned len = 16; mp810_t *mp = (mp810_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mp->cb, cmd_error_info, 0, len); RET_IF_ERR(pixma_exec (s, &mp->cb)); if (buf && len < size) { size = len; /* NOTE: I've absolutely no idea what the returned data mean. */ memcpy (buf, data, size); error = len; } return error; } /* handle_interrupt() waits until it receives an interrupt packet or times out. It calls send_time() and query_status() if necessary. Therefore, make sure that handle_interrupt() is only called from a safe context for send_time() and query_status(). Returns: 0 timed out 1 an interrupt packet received PIXMA_ECANCELED interrupted by signal <0 error */ static int handle_interrupt (pixma_t * s, int timeout) { uint8_t buf[64]; /* check max. packet size with 'lsusb -v' for "EP 9 IN" */ int len; len = pixma_wait_interrupt (s->io, buf, sizeof(buf), timeout); if (len == PIXMA_ETIMEDOUT) return 0; if (len < 0) return len; if (len%16) /* len must be a multiple of 16 bytes */ { PDBG(pixma_dbg (1, "WARNING:unexpected interrupt packet length %d\n", len)); return PIXMA_EPROTO; } /* s->event = 0x0brroott * b: button * oo: original * tt: target * rr: scan resolution * poll event with 'scanimage -A' */ if (s->cfg->pid == MG8200_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 * dpi in buf[12] 01=75; 02=150; 03=300; 04=600 * target = format; original = size; scan-resolution = dpi */ { if (buf[7] & 1) s->events = PIXMA_EV_BUTTON1 | buf[11] | buf[10]<<8 | buf[12]<<16; /* color scan */ if (buf[7] & 2) s->events = PIXMA_EV_BUTTON2 | buf[11] | buf[10]<<8 | buf[12]<<16; /* b/w scan */ } else if (s->cfg->pid == CS8800F_PID || s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) /* button no. in buf[1] * target = button no. * "Finish PDF" is Button-2, all others are Button-1 */ { if ((s->cfg->pid == CS8800F_PID && buf[1] == 0x70) || (s->cfg->pid != CS8800F_PID && buf[1] == 0x50)) s->events = PIXMA_EV_BUTTON2 | buf[1] >> 4; /* button 2 = cancel / end scan */ else s->events = PIXMA_EV_BUTTON1 | buf[1] >> 4; /* button 1 = start scan */ } else /* button no. in buf[0] * original in buf[0] * target in buf[1] */ { /* 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) s->events = PIXMA_EV_BUTTON2 | buf[1] | ((buf[0] & 0xf0) << 4); /* b/w scan */ if (buf[0] & 1) s->events = PIXMA_EV_BUTTON1 | buf[1] | ((buf[0] & 0xf0) << 4); /* color scan */ } return 1; } static int init_ccd_lamp_3 (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; uint8_t *data; int error, status_len, tmo; status_len = 8; RET_IF_ERR(query_status (s)); RET_IF_ERR(query_status (s)); RET_IF_ERR(send_cmd_start_calibrate_ccd_3 (s)); RET_IF_ERR(query_status (s)); tmo = 20; /* like Windows driver, CCD lamp adjustment */ while (--tmo >= 0) { data = pixma_newcmd (&mp->cb, cmd_end_calibrate_ccd_3, 0, status_len); RET_IF_ERR(pixma_exec (s, &mp->cb)); memcpy (mp->current_status, data, status_len); PDBG(pixma_dbg (3, "Lamp status: %u , timeout in: %u\n", data[0], tmo)); if (mp->current_status[0] == 3 || !is_scanning_from_tpu (s)) break; WAIT_INTERRUPT(1000); } return error; } static int wait_until_ready (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; int error, tmo = 60; RET_IF_ERR((mp->generation >= 3) ? query_status_3 (s) : query_status (s)); while (!is_calibrated (s)) { WAIT_INTERRUPT(1000); if (mp->generation >= 3) RET_IF_ERR(query_status_3 (s)); else if (s->cfg->pid == MP800R_PID) RET_IF_ERR (query_status (s)); if (--tmo == 0) { PDBG(pixma_dbg (1, "WARNING: Timed out in wait_until_ready()\n")); PDBG(query_status (s)); return PIXMA_ETIMEDOUT; } } return 0; } /* the RGB images are shifted by # of lines */ /* the R image is shifted by colshift[0] */ /* the G image is shifted by colshift[1] */ /* the B image is shifted by colshift[2] */ /* usually one of the RGB images must not be shifted */ /* which one depends on the scanner */ /* some scanners have an additional stripe shift */ /* e.g. colshift[0]=0, colshift[1]=1, colshift[2]=2 */ /* R image is OK: RGBRGBRGB... */ /* ^^ ^^ ^^ */ /* || || || */ /* shift G image: RG|RG|RG|... */ /* | | | */ /* shift B image: RGBRGBRGB... */ /* this doesn't affect the G and B images */ /* G image will become the R image in the next run */ /* B image will become the G image in the next run */ /* the next line will become the B image in the next run */ static uint8_t * shift_colors (uint8_t * dptr, uint8_t * sptr, unsigned w, unsigned dpi, unsigned pid, unsigned c, int * colshft, unsigned strshft) { unsigned i, sr, sg, sb, st; UNUSED(dpi); UNUSED(pid); sr = colshft[0]; sg = colshft[1]; sb = colshft[2]; /* PDBG (pixma_dbg (4, "*shift_colors***** c=%u, w=%i, sr=%u, sg=%u, sb=%u, strshft=%u ***** \n", c, w, sr, sg, sb, strshft)); */ for (i = 0; i < w; i++) { /* stripes shift for MP970 at 4800 dpi, MP810 at 2400 dpi */ st = (i % 2 == 0) ? strshft : 0; *sptr++ = *(dptr++ + sr + st); if (c == 6) *sptr++ = *(dptr++ + sr + st); *sptr++ = *(dptr++ + sg + st); if (c == 6) *sptr++ = *(dptr++ + sg + st); *sptr++ = *(dptr++ + sb + st); if (c == 6) *sptr++ = *(dptr++ + sb + st); } return dptr; } static uint8_t * shift_colorsCS9000 (uint8_t * dptr, uint8_t * sptr, unsigned w, unsigned dpi, unsigned pid, unsigned c, int * colshft, unsigned strshft, unsigned strshft2, unsigned jump) { unsigned i, sr, sg, sb, st, st2; UNUSED(dpi); UNUSED(pid); sr = colshft[0]; sg = colshft[1]; sb = colshft[2]; for (i = 0; i < w; i++) { if (i < (w / 2)) { /* stripes shift for 1st 4 images for Canoscan 9000F at 9600dpi */ st = (i % 2 == 0) ? strshft : 0; *sptr++ = *(dptr++ + sr + st); if (c == 6) *sptr++ = *(dptr++ + sr + st); *sptr++ = *(dptr++ + sg + st); if (c == 6) *sptr++ = *(dptr++ + sg + st); *sptr++ = *(dptr++ + sb + st); if (c == 6) *sptr++ = *(dptr++ + sb + st); } if (i >= (w / 2)) { /* stripes shift for 2nd 4 images for Canoscan 9000F at 9600dpi */ st2 = (i % 2 == 0) ? strshft2 : 0; *sptr++ = *(dptr++ + sr + jump + st2); if (c == 6) *sptr++ = *(dptr++ + sr + jump + st2); *sptr++ = *(dptr++ + sg + jump + st2); if (c == 6) *sptr++ = *(dptr++ + sg + jump + st2); *sptr++ = *(dptr++ + sb + jump + st2); if (c == 6) *sptr++ = *(dptr++ + sb + jump + st2); } } return dptr; } static uint8_t * shift_colorsCS9000_4800 (uint8_t * dptr, uint8_t * sptr, unsigned w, unsigned dpi, unsigned pid, unsigned c, int * colshft, unsigned strshft, unsigned strshft2, unsigned jump) { unsigned i, sr, sg, sb, st2; UNUSED(dpi); UNUSED(pid); UNUSED(strshft); sr = colshft[0]; sg = colshft[1]; sb = colshft[2]; for (i = 0; i < w; i++) { /* stripes shift for 2nd 4 images * for Canoscan 9000F with 16 bit flatbed scans at 4800dpi */ st2 = (i % 2 == 0) ? strshft2 : 0; *sptr++ = *(dptr++ + sr + jump + st2); if (c == 6) *sptr++ = *(dptr++ + sr + jump + st2); *sptr++ = *(dptr++ + sg + jump + st2); if (c == 6) *sptr++ = *(dptr++ + sg + jump + st2); *sptr++ = *(dptr++ + sb + jump + st2); if (c == 6) *sptr++ = *(dptr++ + sb + jump + st2); } return dptr; } /* under some conditions some scanners have sub images in one line */ /* e.g. doubled image, line size = 8 */ /* line before reordering: px1 px3 px5 px7 px2 px4 px6 px8 */ /* line after reordering: px1 px2 px3 px4 px5 px6 px7 px8 */ static void reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, unsigned m, unsigned w, unsigned line_size) { unsigned i; for (i = 0; i < w; i++) { /* process complete line */ memcpy (linebuf + c * (n * (i % m) + i / m), sptr + c * i, c); } memcpy (sptr, linebuf, line_size); } /* special reorder matrix for mp960 */ static void mp960_reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, unsigned m, unsigned w, unsigned line_size) { unsigned i, i2; /* try and copy 2 px at once */ for (i = 0; i < w; i++) { /* process complete line */ i2 = i % 2; if (i < w / 2) { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m)), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m)), sptr + c * i, c); } else { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 1), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 1), sptr + c * i, c); } } memcpy (sptr, linebuf, line_size); } /* special reorder matrix for mp970 */ static void mp970_reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned w, unsigned line_size) { unsigned i, i8; for (i = 0; i < w; i++) { /* process complete line */ i8 = i % 8; memcpy (linebuf + c * (i + i8 - ((i8 > 3) ? 7 : 0)), sptr + c * i, c); } memcpy (sptr, linebuf, line_size); } /* special reorder matrix for CS9000F */ static void cs9000f_initial_reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, unsigned m, unsigned w, unsigned line_size) { unsigned i, i2; /* try and copy 2 px at once */ for (i = 0; i < w; i++) { /* process complete line */ i2 = i % 2; if (i < w / 8) { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m)), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m)), sptr + c * i, c); } else if (i >= w / 8 && i < w / 4) { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 1), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 1), sptr + c * i, c); } else if (i >= w / 4 && i < 3 * w / 8) { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 2), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 2), sptr + c * i, c); } else if (i >= 3 * w / 8 && i < w / 2) { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 3), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 3), sptr + c * i, c); } else if (i >= w / 2 && i < 5 * w / 8) { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 4), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 4), sptr + c * i, c); } else if (i >= 5 * w / 8 && i < 3 * w / 4) { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 5), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 5), sptr + c * i, c); } else if (i >= 3 * w / 4 && i < 7 * w / 8) { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 6), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 6), sptr + c * i, c); } else { if (i2 == 0) memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 7), sptr + c * i, c); else memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 7), sptr + c * i, c); } } memcpy (sptr, linebuf, line_size); } /* CS9000F 9600dpi reorder: actually 4800dpi since each pixel is doubled */ /* need to rearrange each sequence of 16 pairs of pixels as follows: */ /* start px : 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 */ /* before : p1a p1b p1c p1d p2a p2b p2c p2d p3a p3b p3c p3d p4a p4b p4c p4d */ /* after : p1a p3a p1b p3b p1c p3c p1d p3d p2a p4a p2b p4b p2c p4c p2d p4d */ /* start px : 0 16 2 18 4 20 6 22 8 24 10 26 12 28 14 30 */ /* change : * * * * * * * * * * * * * * */ /* no change: * * */ /* so the 1st and the 3rd set are interleaved, followed by the 2nd and 4th sets interleaved */ static void cs9000f_second_reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned w, unsigned line_size) { unsigned i, i8; static const int shifts[8] = { 2, 4, 6, 8, -8, -6, -4, -2 }; for (i = 0; i < w; i += 2) { /* process complete line */ i8 = (i >> 1) & 0x7; /* Copy 2 pixels at once */ memcpy (linebuf + c * (i + shifts[i8]), sptr + c * i, c * 2); } memcpy (sptr, linebuf, line_size); } #ifndef TPU_48 static unsigned pack_48_24_bpc (uint8_t * sptr, unsigned n) { unsigned i; uint8_t *cptr, lsb; static uint8_t offset = 0; cptr = sptr; if (n % 2 != 0) PDBG (pixma_dbg (3, "WARNING: misaligned image.\n")); for (i = 0; i < n; i += 2) { /* offset = 1 + (offset % 3); */ lsb = *sptr++; *cptr++ = ((*sptr++) << offset) | lsb >> (8 - offset); } return (n / 2); } #endif /* This function deals both with PIXMA CCD sensors producing shifted color * planes images, Grayscale CCD scan and Generation >= 3 high dpi images. * Each complete line in mp->imgbuf is processed for shifting CCD sensor * color planes, reordering pixels above 600 dpi for Generation >= 3, and * converting to Grayscale for CCD sensors. */ static unsigned post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) { mp810_t *mp = (mp810_t *) s->subdriver; unsigned c, lines, line_size, n, m, cw, cx, reducelines; uint8_t *sptr, *dptr, *gptr, *cptr; unsigned /*color_shift, stripe_shift, stripe_shift2,*/ jumplines /*, height*/; int test; /* For testers: */ /* set this to 1 in order to get unprocessed images next to one another at 9600dpi */ /* other resolutions should not be affected */ /* set this to 2 if you want to see the same with jumplines=0 */ test = 0; jumplines = 0; c = ((is_tpuir (s) || is_gray_all (s) || is_lineart (s)) ? 3 : s->param->channels) * ((s->param->software_lineart) ? 8 : s->param->depth) / 8; cw = c * s->param->w; cx = c * s->param->xs; /* PDBG (pixma_dbg (4, "*post_process_image_data***** c = %u, cw = %u, cx = %u *****\n", c, cw, cx)); */ if (mp->generation >= 3) n = s->param->xdpi / 600; else /* FIXME: maybe need different values for CIS and CCD sensors */ n = s->param->xdpi / 2400; /* Some exceptions to global rules here */ if (s->cfg->pid == MP970_PID || s->cfg->pid == MP990_PID || s->cfg->pid == MG8200_PID || s->cfg->pid == CS8800F_PID || s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) n = MIN (n, 4); /* exception for 9600dpi on Canoscan 9000F */ if ((s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) && (s->param->xdpi == 9600)) { n = 8; if (test > 0) n = 1; /* test if 8 images are next to one another */ } /* test if 2 images are next to one another */ if ((s->cfg->pid == MP960_PID) && (s->param->xdpi == 4800) && (test > 0)) { n = 1; } m = (n > 0) ? s->param->wx / n : 1; sptr = dptr = gptr = cptr = mp->imgbuf; line_size = get_cis_ccd_line_size (s); /* PDBG (pixma_dbg (4, "*post_process_image_data***** ----- Set n=%u, m=%u, line_size=%u ----- ***** \n", n, m, line_size)); */ /* PDBG (pixma_dbg (4, "*post_process_image_data***** ----- spr=dpr=%u, linebuf=%u ----- ***** \n", sptr, mp->linebuf)); */ lines = (mp->data_left_ofs - mp->imgbuf) / line_size; /* PDBG (pixma_dbg (4, "*post_process_image_data***** lines = %i > 2 * mp->color_shift + mp->stripe_shift = %i ***** \n", lines, 2 * mp->color_shift + mp->stripe_shift)); */ /* PDBG (pixma_dbg (4, "*post_process_image_data***** mp->color_shift = %u, mp->stripe_shift = %u, , mp->stripe_shift2 = %u ***** \n", mp->color_shift, mp->stripe_shift, mp->stripe_shift2)); */ /*color_shift = mp->color_shift;*/ /*stripe_shift = mp->stripe_shift;*/ /*stripe_shift2 = mp->stripe_shift2;*/ jumplines = mp->jumplines; /* height not needed here! */ /* removed to avoid confusion */ /* height = MIN (s->param->h + calc_shifting (s), s->cfg->height * s->param->ydpi / 75); */ /* have to test if rounding down is OK or not -- currently 0.5 lines is rounded down */ /* note stripe shifts doubled already in definitions */ if ((s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) && (s->param->xdpi == 9600) && (test > 0)) { /* using test==2 you can check in GIMP the required offset, and use the below line (uncommented) and replace XXX with that number, and then compile again with test set to 1. */ jumplines = 32; if (test == 2) jumplines = 0; } /* mp960 test */ if ((s->cfg->pid == MP960_PID) && (s->param->xdpi == 4800) && (test > 0)) { jumplines = 32; if (test == 2) jumplines = 0; } reducelines = ((2 * mp->color_shift + mp->stripe_shift) + jumplines); /* PDBG (pixma_dbg (4, "*post_process_image_data: lines %u, reducelines %u \n", lines, reducelines)); */ if (lines > reducelines) { /* (line - reducelines) of image lines can be converted */ unsigned i; lines -= reducelines; for (i = 0; i < lines; i++, sptr += line_size) { /* convert only full image lines */ /* Color plane and stripes shift needed by e.g. CCD */ /* PDBG (pixma_dbg (4, "*post_process_image_data***** Processing with c=%u, n=%u, m=%u, w=%i, line_size=%u ***** \n", c, n, m, s->param->wx, line_size)); */ if (c >= 3) { if (((s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) && (s->param->xdpi == 9600)) || ((s->cfg->pid == MP960_PID) && (s->param->xdpi == 4800)) || ((s->cfg->pid == MP810_PID) && (s->param->xdpi == 4800))) { dptr = shift_colorsCS9000 (dptr, sptr, s->param->wx, s->param->xdpi, s->cfg->pid, c, mp->shift, mp->stripe_shift, mp->stripe_shift2, jumplines * line_size); } else if ((s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) /* 9000F: 16 bit flatbed scan at 4800dpi */ && ((s->param->mode == PIXMA_SCAN_MODE_COLOR_48) || (s->param->mode == PIXMA_SCAN_MODE_GRAY_16)) && (s->param->xdpi == 4800) && (s->param->source == PIXMA_SOURCE_FLATBED)) dptr = shift_colorsCS9000_4800 (dptr, sptr, s->param->wx, s->param->xdpi, s->cfg->pid, c, mp->shift, mp->stripe_shift, mp->stripe_shift2, jumplines * line_size); else /* all except 9000F at 9600dpi */ dptr = shift_colors (dptr, sptr, s->param->wx, s->param->xdpi, s->cfg->pid, c, mp->shift, mp->stripe_shift); } /*PDBG (pixma_dbg (4, "*post_process_image_data***** test = %i *****\n", test)); */ /*--comment out all between this line and the one below for 9000F tests at 9600dpi or MP960 at 4800dpi ------*/ /* if ( 0 ) */ if ((((s->cfg->pid != CS9000F_PID && s->cfg->pid != CS9000F_MII_PID) || (s->param->xdpi < 9600)) && ((s->cfg->pid != MP960_PID) || (s->param->xdpi < 4800)) && ((s->cfg->pid != MP810_PID) || (s->param->xdpi < 4800))) || (test == 0)) { /* PDBG (pixma_dbg (4, "*post_process_image_data***** MUST GET HERE WHEN TEST == 0 *****\n")); */ if (!((s->cfg->pid == MP810_PID) && (s->param->xdpi == 4800)) && !((s->cfg->pid == MP960_PID) && (s->param->xdpi == 4800)) && !((s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) && (s->param->xdpi == 9600))) { /* for both flatbed & TPU */ /* PDBG (pixma_dbg (4, "*post_process_image_data***** reordering pixels normal n = %i *****\n", n)); */ reorder_pixels (mp->linebuf, sptr, c, n, m, s->param->wx, line_size); } if ((s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) && (s->param->xdpi == 9600)) { /* PDBG (pixma_dbg (4, "*post_process_image_data***** cs900f_initial_reorder_pixels n = %i *****\n", n)); */ /* this combines pixels from 8 images 2px at a time from left to right: 1122334455667788... */ cs9000f_initial_reorder_pixels (mp->linebuf, sptr, c, n, m, s->param->wx, line_size); /* final interleaving */ cs9000f_second_reorder_pixels (mp->linebuf, sptr, c, s->param->wx, line_size); } /* comment: special image format for MP960 in flatbed mode at 4800dpi. It is actually 2400dpi, with each pixel doubled. The TPU mode has proper pixel ordering */ if ((((s->cfg->pid == MP960_PID) || (s->cfg->pid == MP810_PID)) && (s->param->xdpi == 4800)) && (n > 0)) { /* for both flatbed & TPU */ /* PDBG (pixma_dbg (4, "*post_process_image_data***** flatbed mp960_reordering pixels n = %i *****\n", n)); */ mp960_reorder_pixels (mp->linebuf, sptr, c, n, m, s->param->wx, line_size); } /* comment: MP970, CS8800F, CS9000F specific reordering for 4800 dpi */ if ((s->cfg->pid == MP970_PID || s->cfg->pid == CS8800F_PID || s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID || s->cfg->pid == MP990_PID) && (s->param->xdpi == 4800)) { /*PDBG (pixma_dbg (4, "*post_process_image_data***** mp970_reordering pixels n = %i *****\n", n)); */ mp970_reorder_pixels (mp->linebuf, sptr, c, s->param->wx, line_size); } } /*-------------------------------------------------------*/ /* PDBG (pixma_dbg (4, "*post_process_image_data: sptr=%u, dptr=%u \n", sptr, dptr)); */ /* Crop line to selected borders */ memmove (cptr, sptr + cx, cw); /* PDBG (pixma_dbg (4, "*post_process_image_data***** crop line: cx=%u, cw=%u ***** \n", cx, cw)); */ /* Color to Lineart convert for CCD sensor */ if (is_lineart (s)) cptr = gptr = pixma_binarize_line (s->param, gptr, cptr, s->param->w, c); #ifndef TPUIR_USE_RGB /* save IR only for CCD sensor */ else if (is_tpuir (s)) cptr = gptr = pixma_r_to_ir (gptr, cptr, s->param->w, c); /* Color to Grayscale convert for CCD sensor */ else if (is_gray_all (s)) #else /* IR *and* Color to Grayscale convert for CCD sensor */ else if (is_tpuir (s) || is_gray_all (s)) #endif cptr = gptr = pixma_rgb_to_gray (gptr, cptr, s->param->w, c); else cptr += cw; } /* PDBG (pixma_dbg (4, "*post_process_image_data: sptr=%u, dptr=%u \n", sptr, dptr)); */ } ib->rptr = mp->imgbuf; ib->rend = cptr; return mp->data_left_ofs - sptr; /* # of non processed bytes */ /* contains shift color data for new lines */ /* and already received data for the next line */ } static int mp810_open (pixma_t * s) { mp810_t *mp; uint8_t *buf; mp = (mp810_t *) calloc (1, sizeof(*mp)); if (!mp) return PIXMA_ENOMEM; buf = (uint8_t *) malloc (CMDBUF_SIZE + IMAGE_BLOCK_SIZE); if (!buf) { free (mp); return PIXMA_ENOMEM; } s->subdriver = mp; mp->state = state_idle; mp->cb.buf = buf; mp->cb.size = CMDBUF_SIZE; mp->cb.res_header_len = 8; mp->cb.cmd_header_len = 16; mp->cb.cmd_len_field_ofs = 14; mp->imgbuf = buf + CMDBUF_SIZE; /* General rules for setting Pixma protocol generation # */ mp->generation = (s->cfg->pid >= MP810_PID) ? 2 : 1; if (s->cfg->pid >= MP970_PID) mp->generation = 3; if (s->cfg->pid >= MP990_PID) mp->generation = 4; /* And exceptions to be added here */ if (s->cfg->pid == CS8800F_PID) mp->generation = 3; if (s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID) mp->generation = 4; /* TPU info data setup */ mp->tpu_datalen = 0; if (mp->generation < 4) { /* Canoscan 8800F ignores commands if not initialized */ if (s->cfg->pid == CS8800F_PID) abort_session (s); else { query_status (s); handle_interrupt (s, 200); if (mp->generation == 3 && has_ccd_sensor (s)) send_cmd_start_calibrate_ccd_3 (s); } } return 0; } static void mp810_close (pixma_t * s) { mp810_t *mp = (mp810_t *) s->subdriver; mp810_finish_scan (s); free (mp->cb.buf); free (mp); s->subdriver = NULL; } static int mp810_check_param (pixma_t * s, pixma_scan_param_t * sp) { mp810_t *mp = (mp810_t *) s->subdriver; unsigned w_max; /* PDBG (pixma_dbg (4, "*mp810_check_param***** Initially: channels=%u, depth=%u, x=%u, y=%u, w=%u, h=%u, xs=%u, wx=%u *****\n", sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->h, sp->xs, sp->wx)); */ sp->channels = 3; sp->software_lineart = 0; switch (sp->mode) { /* standard scan modes * 8 bit per channel in color and grayscale mode * 16 bit per channel with TPU */ case PIXMA_SCAN_MODE_GRAY: case PIXMA_SCAN_MODE_NEGATIVE_GRAY: case PIXMA_SCAN_MODE_TPUIR: sp->channels = 1; /* fall through */ case PIXMA_SCAN_MODE_COLOR: case PIXMA_SCAN_MODE_NEGATIVE_COLOR: sp->depth = 8; #ifdef TPU_48 #ifndef DEBUG_TPU_48 if (sp->source == PIXMA_SOURCE_TPU) #endif sp->depth = 16; /* TPU in 16 bits mode */ #endif break; /* extended scan modes for 48 bit flatbed scanners * 16 bit per channel in color and grayscale mode */ case PIXMA_SCAN_MODE_GRAY_16: sp->channels = 1; sp->depth = 16; break; case PIXMA_SCAN_MODE_COLOR_48: sp->channels = 3; sp->depth = 16; break; /* software lineart * 1 bit per channel */ case PIXMA_SCAN_MODE_LINEART: sp->software_lineart = 1; sp->channels = 1; sp->depth = 1; break; } /* for software lineart w must be a multiple of 8 * I don't know why is_lineart(s) doesn't work here */ if (sp->software_lineart == 1 && sp->w % 8) { sp->w += 8 - (sp->w % 8); /* do not exceed the scanner capability */ w_max = s->cfg->width * s->cfg->xdpi / 75; w_max -= w_max % 8; if (sp->w > w_max) sp->w = w_max; } if (sp->source == PIXMA_SOURCE_TPU && !sp->tpu_offset_added) { unsigned fixed_offset_y; /* TPU offsets for CanoScan 8800F, or other CCD at 300dpi. */ unsigned max_y; /* max TPU height for CS9000F at 75 dpi */ /* CanoScan 8800F and others adding an offset depending on resolution */ /* CS9000F and others maximum TPU height */ switch (s->cfg->pid) { case CS8800F_PID: fixed_offset_y = 140; max_y = MIN (740, s->cfg->height); break; case CS9000F_PID: case CS9000F_MII_PID: fixed_offset_y = 146; max_y = MIN (740, s->cfg->height); break; default: fixed_offset_y = 0; max_y = s->cfg->height; break; } /* cropping y and h to scanable area */ max_y *= (sp->ydpi) / 75; sp->y = MIN(sp->y, max_y); sp->h = MIN(sp->h, max_y - sp->y); /* PDBG (pixma_dbg (4, "*mp810_check_param***** Cropping: y=%u, h=%u *****\n", sp->y, sp->h)); */ if (!sp->h) return SANE_STATUS_INVAL; /* no lines */ /* Convert the offsets from 300dpi to actual resolution */ fixed_offset_y = fixed_offset_y * (sp->xdpi) / 300; /* In TPU mode, the CS9000F appears to always subtract 146 from the vertical starting position, but clamps its at 0. Therefore vertical offsets 0 through 146 (@300 dpi) get all mapped onto the same physical starting position: line 0. Then, starting from 147, the offsets get mapped onto successive physical lines: y line 0 -> 0 1 -> 0 2 -> 0 ... 146 -> 0 147 -> 1 148 -> 2 ... Since a preview scan is typically made starting from y = 0, but partial image scans usually start at y >> 147, this results in a discontinuity in the y to line mapping, resulting in wrong offsets. To prevent this, we must always add (at least) 146 to the y offset before it is sent to the scanner. The scanner will then map y = 0 (146) to the first line, y = 1 (147) to the second line, and so on. Any distance that is then measured on the preview scan, can be translated without any discontinuity. However, there is one complication: during a preview scan, which normally covers the whole scan area of the scanner, we should _not_ add the offset because it will result in a reduced number of lines being returned (the scan height is clamped in pixma_check_scan_param()). Since the frontend has no way of telling that the scan area has been reduced, it would derive an incorrect effective scan resolution, and any position calculations based on this would therefore be inaccurate. To prevent this, we don't add the offset in case y = 0, which is typically the case during a preview scan (the scanner effectively adds the offset for us, see above). In that way we keep the linearity and we don't affect the scan area during previews. */ if (sp->y > 0) sp->y += fixed_offset_y; /* Prevent repeated corrections as check_param may be called multiple times */ sp->tpu_offset_added = 1; } if (mp->generation >= 2) { /* mod 32 and expansion of the X scan limits */ /* PDBG (pixma_dbg (4, "*mp810_check_param***** (gen>=2) xs=mod32 ----- Initially: x=%u, y=%u, w=%u, h=%u *****\n", sp->x, sp->y, sp->w, sp->h)); */ sp->xs = (sp->x) % 32; } else { sp->xs = 0; /* PDBG (pixma_dbg (4, "*mp810_check_param***** (else) xs=0 Selected origin, origin shift: %u, %u *****\n", sp->x, sp->xs)); */ } sp->wx = calc_raw_width (mp, sp); sp->line_size = sp->w * sp->channels * (((sp->software_lineart) ? 8 : sp->depth) / 8); /* bytes per line per color after cropping */ /* PDBG (pixma_dbg (4, "*mp810_check_param***** (else) Final scan width and line-size: %u, %"PRIu64" *****\n", sp->wx, sp->line_size)); */ /* highest res is 600, 2400, 4800 or 9600 dpi */ { uint8_t k; if ((sp->source == PIXMA_SOURCE_ADF || sp->source == PIXMA_SOURCE_ADFDUP) && mp->generation >= 4) /* ADF/ADF duplex mode: max scan res is 600 dpi, at least for generation 4 */ k = sp->xdpi / MIN (sp->xdpi, 600); else if (sp->source == PIXMA_SOURCE_TPU && sp->mode == PIXMA_SCAN_MODE_TPUIR) /* TPUIR mode: max scan res is 2400 dpi */ k = sp->xdpi / MIN (sp->xdpi, 2400); else if (sp->source == PIXMA_SOURCE_TPU && (s->cfg->pid == CS9000F_PID || s->cfg->pid == CS9000F_MII_PID)) /* CS9000F in TPU mode */ k = sp->xdpi / MIN (sp->xdpi, 9600); else /* default */ k = sp->xdpi / MIN (sp->xdpi, 4800); sp->x /= k; sp->xs /= k; sp->y /= k; sp->w /= k; sp->wx /= k; sp->h /= k; sp->xdpi /= k; sp->ydpi = sp->xdpi; } /* lowest res is 75, 150, 300 or 600 dpi */ { uint8_t k; if (sp->source == PIXMA_SOURCE_TPU && sp->mode == PIXMA_SCAN_MODE_TPUIR) /* TPUIR mode */ k = MAX (sp->xdpi, 600) / sp->xdpi; else if (sp->source == PIXMA_SOURCE_TPU && ((mp->generation >= 3) || (s->cfg->pid == MP810_PID) || (s->cfg->pid == MP960_PID))) /* TPU mode for generation 3+ scanners * MP810, MP960 appear to have a 200dpi mode for low-res scans, not 150 dpi */ k = MAX (sp->xdpi, 300) / sp->xdpi; else if (sp->source == PIXMA_SOURCE_TPU || sp->mode == PIXMA_SCAN_MODE_COLOR_48 || sp->mode == PIXMA_SCAN_MODE_GRAY_16) /* TPU mode and 16 bit flatbed scans * TODO: either the frontend (xsane) cannot handle 48 bit flatbed scans @ 75 dpi (prescan) * or there is a bug in this subdriver */ k = MAX (sp->xdpi, 150) / sp->xdpi; else /* default */ k = MAX (sp->xdpi, 75) / sp->xdpi; sp->x *= k; sp->xs *= k; sp->y *= k; sp->w *= k; sp->wx *= k; sp->h *= k; sp->xdpi *= k; sp->ydpi = sp->xdpi; } /* PDBG (pixma_dbg (4, "*mp810_check_param***** Finally: channels=%u, depth=%u, x=%u, y=%u, w=%u, h=%u, xs=%u, wx=%u *****\n", sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->h, sp->xs, sp->wx)); */ return 0; } static int mp810_scan (pixma_t * s) { int error = 0, tmo; mp810_t *mp = (mp810_t *) s->subdriver; if (mp->state != state_idle) return PIXMA_EBUSY; /* Generation 4: send XML dialog */ if (mp->generation == 4 && s->param->adf_pageid == 0) { if (!send_xml_dialog (s, XML_START_1)) return PIXMA_EPROTO; if (!send_xml_dialog (s, XML_START_2)) return PIXMA_EPROTO; } /* clear interrupt packets buffer */ while (handle_interrupt (s, 0) > 0) { } /* FIXME: Duplex ADF: check paper status only before odd pages (1,3,5,...). */ if (is_scanning_from_adf (s)) { if ((error = query_status (s)) < 0) return error; tmo = 10; while (!has_paper (s) && --tmo >= 0) { WAIT_INTERRUPT(1000); PDBG(pixma_dbg (2, "No paper in ADF. Timed out in %d sec.\n", tmo)); } if (!has_paper (s)) return PIXMA_ENO_PAPER; } if (has_ccd_sensor (s) && (mp->generation <= 2)) { error = send_cmd_e920 (s); switch (error) { case PIXMA_ECANCELED: case PIXMA_EBUSY: PDBG(pixma_dbg (2, "cmd e920 or d520 returned %s\n", pixma_strerror (error))); /* fall through */ case 0: query_status (s); break; default: PDBG(pixma_dbg (1, "WARNING: cmd e920 or d520 failed %s\n", pixma_strerror (error))); return error; } tmo = 3; /* like Windows driver, CCD calibration ? */ while (--tmo >= 0) { WAIT_INTERRUPT(1000); PDBG(pixma_dbg (2, "CCD Calibration ends in %d sec.\n", tmo)); } /* pixma_sleep(2000000); */ } tmo = 10; if (s->param->adf_pageid == 0 || mp->generation <= 2) { error = start_session (s); while (error == PIXMA_EBUSY && --tmo >= 0) { if (s->cancel) { error = PIXMA_ECANCELED; break; } PDBG(pixma_dbg (2, "Scanner is busy. Timed out in %d sec.\n", tmo + 1)); pixma_sleep (1000000); error = start_session (s); } if (error == PIXMA_EBUSY || error == PIXMA_ETIMEDOUT) { /* The scanner maybe hangs. We try to empty output buffer of the * scanner and issue the cancel command. */ PDBG(pixma_dbg (2, "Scanner hangs? Sending abort_session command.\n")); drain_bulk_in (s); abort_session (s); pixma_sleep (500000); error = start_session (s); } if ((error >= 0) || (mp->generation >= 3)) mp->state = state_warmup; if ((error >= 0) && (mp->generation <= 2)) error = select_source (s); if ((error >= 0) && (mp->generation >= 3) && has_ccd_sensor (s)) error = init_ccd_lamp_3 (s); if ((error >= 0) && !is_scanning_from_tpu (s)) { int i; /* FIXME: 48 bit flatbed scans don't need gamma tables * the code below doesn't run */ /*if (is_color_48 (s) || is_gray_16 (s)) error = 0; else*/ for (i = (mp->generation >= 3) ? 3 : 1; i > 0 && error >= 0; i--) error = send_gamma_table (s); } else if (error >= 0) /* in TPU mode, for gen 1, 2, and 3 */ error = send_set_tpu_info (s); } else /* ADF pageid != 0 and gen3 or above */ pixma_sleep (1000000); if ((error >= 0) || (mp->generation >= 3)) mp->state = state_warmup; if (error >= 0) error = send_scan_param (s); if ((error >= 0) && (mp->generation >= 3)) error = start_scan_3 (s); if (error < 0) { mp->last_block = 0x38; /* Force abort session if ADF scan */ mp810_finish_scan (s); return error; } return 0; } static int mp810_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) { int error; mp810_t *mp = (mp810_t *) s->subdriver; unsigned block_size, bytes_received, proc_buf_size, line_size; uint8_t header[16]; if (mp->state == state_warmup) { /* prepare read image data */ /* PDBG (pixma_dbg (4, "**mp810_fill_buffer***** warmup *****\n")); */ RET_IF_ERR(wait_until_ready (s)); pixma_sleep (1000000); /* No need to sleep, actually, but Window's driver * sleep 1.5 sec. */ mp->state = state_scanning; mp->last_block = 0; line_size = get_cis_ccd_line_size (s); proc_buf_size = (2 * calc_shifting (s) + 2) * line_size; mp->cb.buf = realloc (mp->cb.buf, CMDBUF_SIZE + IMAGE_BLOCK_SIZE + proc_buf_size); if (!mp->cb.buf) return PIXMA_ENOMEM; mp->linebuf = mp->cb.buf + CMDBUF_SIZE; mp->imgbuf = mp->data_left_ofs = mp->linebuf + line_size; mp->data_left_len = 0; } do { /* read complete image data from the scanner */ if (s->cancel) return PIXMA_ECANCELED; if ((mp->last_block & 0x28) == 0x28) { /* end of image */ mp->state = state_finished; /* PDBG (pixma_dbg (4, "**mp810_fill_buffer***** end of image *****\n")); */ return 0; } /* PDBG (pixma_dbg (4, "*mp810_fill_buffer***** moving %u bytes into buffer *****\n", mp->data_left_len)); */ memmove (mp->imgbuf, mp->data_left_ofs, mp->data_left_len); error = read_image_block (s, header, mp->imgbuf + mp->data_left_len); if (error < 0) { if (error == PIXMA_ECANCELED) { /* NOTE: I see this in traffic logs but I don't know its meaning. */ read_error_info (s, NULL, 0); } return error; } bytes_received = error; /*PDBG (pixma_dbg (4, "*mp810_fill_buffer***** %u bytes received by read_image_block *****\n", bytes_received));*/ block_size = pixma_get_be32 (header + 12); mp->last_block = header[8] & 0x38; if ((header[8] & ~0x38) != 0) { PDBG(pixma_dbg (1, "WARNING: Unexpected result header\n")); PDBG(pixma_hexdump (1, header, 16)); } PASSERT(bytes_received == block_size); if (block_size == 0) { /* no image data at this moment. */ pixma_sleep (10000); } /* For TPU at 48 bits/pixel to output at 24 bits/pixel */ #ifndef DEBUG_TPU_48 #ifndef TPU_48 PDBG (pixma_dbg (1, "WARNING: 9000F using 24 instead of 48 bit processing \n")); #ifndef DEBUG_TPU_24 if (is_scanning_from_tpu (s)) #endif bytes_received = pack_48_24_bpc (mp->imgbuf + mp->data_left_len, bytes_received); #endif #endif /* Post-process the image data */ mp->data_left_ofs = mp->imgbuf + mp->data_left_len + bytes_received; mp->data_left_len = post_process_image_data (s, ib); mp->data_left_ofs -= mp->data_left_len; /* PDBG (pixma_dbg (4, "* mp810_fill_buffer: data_left_len %u \n", mp->data_left_len)); */ /* PDBG (pixma_dbg (4, "* mp810_fill_buffer: data_left_ofs %u \n", mp->data_left_ofs)); */ } while (ib->rend == ib->rptr); return ib->rend - ib->rptr; } static void mp810_finish_scan (pixma_t * s) { int error; mp810_t *mp = (mp810_t *) s->subdriver; switch (mp->state) { case state_transfering: drain_bulk_in (s); /* fall through */ case state_scanning: case state_warmup: case state_finished: /* Send the get TPU info message */ if (is_scanning_from_tpu (s) && mp->tpu_datalen == 0) send_get_tpu_info_3 (s); /* FIXME: to process several pages ADF scan, must not send * abort_session and start_session between pages (last_block=0x28) */ if (mp->generation <= 2 || !is_scanning_from_adf (s) || mp->last_block == 0x38) { error = abort_session (s); /* FIXME: it probably doesn't work in duplex mode! */ if (error < 0) PDBG(pixma_dbg (1, "WARNING:abort_session() failed %d\n", error)); /* Generation 4: send XML end of scan dialog */ if (mp->generation == 4) { if (!send_xml_dialog (s, XML_END)) PDBG(pixma_dbg (1, "WARNING:XML_END dialog failed \n")); } } mp->state = state_idle; /* fall through */ case state_idle: break; } } static void mp810_wait_event (pixma_t * s, int timeout) { /* FIXME: timeout is not correct. See usbGetCompleteUrbNoIntr() for * instance. */ while (s->events == 0 && handle_interrupt (s, timeout) > 0) { } } static int mp810_get_status (pixma_t * s, pixma_device_status_t * status) { int error; RET_IF_ERR(query_status (s)); status->hardware = PIXMA_HARDWARE_OK; status->adf = (has_paper (s)) ? PIXMA_ADF_OK : PIXMA_ADF_NO_PAPER; status->cal = (is_calibrated (s)) ? PIXMA_CALIBRATION_OK : PIXMA_CALIBRATION_OFF; return 0; } static const pixma_scan_ops_t pixma_mp800_ops = { mp810_open, mp810_close, mp810_scan, mp810_fill_buffer, mp810_finish_scan, mp810_wait_event, mp810_check_param, mp810_get_status }; #define DEVICE(name, model, pid, dpi, adftpu_min_dpi, adftpu_max_dpi, tpuir_min_dpi, tpuir_max_dpi, w, h, cap) { \ name, /* name */ \ model, /* model */ \ CANON_VID, pid, /* vid pid */ \ 0, /* iface */ \ &pixma_mp800_ops, /* ops */ \ 0, /* min_xdpi not used in this subdriver */ \ dpi, 2*(dpi), /* xdpi, ydpi */ \ adftpu_min_dpi, adftpu_max_dpi, /* adftpu_min_dpi, adftpu_max_dpi */ \ tpuir_min_dpi, tpuir_max_dpi, /* tpuir_min_dpi, tpuir_max_dpi */ \ w, h, /* width, height */ \ PIXMA_CAP_CCD| /* all scanners with CCD*/ \ PIXMA_CAP_EASY_RGB| \ PIXMA_CAP_GRAY| /* all scanners with software grayscale */ \ PIXMA_CAP_LINEART| /* all scanners with software lineart */ \ PIXMA_CAP_GAMMA_TABLE|PIXMA_CAP_EVENTS|cap \ } #define END_OF_DEVICE_LIST DEVICE(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0) const pixma_config_t pixma_mp800_devices[] = { /* Generation 1: CCD */ DEVICE ("Canon PIXMA MP800", "MP800", MP800_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), DEVICE ("Canon PIXMA MP800R", "MP800R", MP800R_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), DEVICE ("Canon PIXMA MP830", "MP830", MP830_PID, 2400, 150, 0, 0, 0, 638, 877, PIXMA_CAP_ADFDUP), /* Generation 2: CCD */ DEVICE ("Canon PIXMA MP810", "MP810", MP810_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), DEVICE ("Canon PIXMA MP960", "MP960", MP960_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Generation 3 CCD not managed as Generation 2 */ DEVICE ("Canon Pixma MP970", "MP970", MP970_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Flatbed scanner CCD (2007) */ DEVICE ("Canoscan 8800F", "8800F", CS8800F_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU /*| PIXMA_CAP_NEGATIVE*/ | PIXMA_CAP_48BIT), /* PIXMA 2008 vintage CCD */ DEVICE ("Canon MP980 series", "MP980", MP980_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Generation 4 CCD */ DEVICE ("Canon MP990 series", "MP990", MP990_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Flatbed scanner (2010) */ DEVICE ("Canoscan 9000F", "9000F", CS9000F_PID, 4800, 300, 9600, 600, 2400, 638, 877, PIXMA_CAP_TPUIR /*| PIXMA_CAP_NEGATIVE*/ | PIXMA_CAP_48BIT), /* Latest devices (2010) Generation 4 CCD untested */ DEVICE ("Canon PIXMA MG8100", "MG8100", MG8100_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Latest devices (2011) Generation 4 CCD untested */ DEVICE ("Canon PIXMA MG8200", "MG8200", MG8200_PID, 4800, 300, 0, 0, 0, 638, 877, PIXMA_CAP_TPU), /* Flatbed scanner (2013) */ DEVICE ("Canoscan 9000F Mark II", "9000FMarkII", CS9000F_MII_PID, 4800, 300, 9600, 600, 2400, 638, 877, PIXMA_CAP_TPUIR | PIXMA_CAP_48BIT), END_OF_DEVICE_LIST }; sane-backends-1.0.29/backend/pixma/pixma_bjnp.h0000666000000000000000000001434313615534521016213 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2008 by Louis Lagendijk based on sane_usb.h: Copyright (C) 2003, 2005 Rene Rebe (sanei_read_int,sanei_set_timeout) Copyright (C) 2001, 2002 Henning Meier-Geinitz This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /** @file sanei_bjnp.h * This file provides a generic BJNP interface. */ #ifndef sanei_bjnp_h #define sanei_bjnp_h #include "../include/sane/config.h" #include "../include/sane/sane.h" #include "pixma.h" #ifdef HAVE_STDLIB_H #include /* for size_t */ #endif /** Initialize sanei_bjnp. * * Call this before any other sanei_bjnp function. */ extern void sanei_bjnp_init (void); /** Find scanners responding to a BJNP broadcast. * * 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 * 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 * * @return SANE_STATUS_GOOD - on success (even if no scanner was found) */ #define SERIAL_MAX 16 extern SANE_Status sanei_bjnp_find_devices (const char **conf_devices, SANE_Status (*attach_bjnp) (SANE_String_Const devname, SANE_String_Const serial, const struct pixma_config_t *cfg), const struct pixma_config_t *const pixma_devices[]); /** Open a BJNP device. * * The device is opened by its name devname and the device number is * returned in dn on success. * * Device names consist of an URI * Where: * method = bjnp * hostname = resolvable name or IP-address * port = 8612 for a bjnp scanner, 8610 for a mfnp device * An example could look like this: bjnp://host.domain:8612 * * @param devname name of the device to open * @param dn device number * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_ACCESS_DENIED - if the file couldn't be accessed due to * permissions * - SANE_STATUS_INVAL - on every other error */ extern SANE_Status sanei_bjnp_open (SANE_String_Const devname, SANE_Int * dn); /** Close a BJNP device. * * @param dn device number */ extern void sanei_bjnp_close (SANE_Int dn); /** Activate a BJNP device connection * * @param dn device number */ extern SANE_Status sanei_bjnp_activate (SANE_Int dn); /** De-activate a BJNP device connection * * @param dn device number */ extern SANE_Status sanei_bjnp_deactivate (SANE_Int dn); /** Set the libbjnp timeout for bulk and interrupt reads. * * @param devno device number * @param timeout the new timeout in ms */ extern void sanei_bjnp_set_timeout (SANE_Int devno, SANE_Int timeout); /** Check if sanei_bjnp_set_timeout() is available. */ #define HAVE_SANEI_BJNP_SET_TIMEOUT /** Initiate a bulk transfer read. * * Read up to size bytes from the device to buffer. After the read, size * contains the number of bytes actually read. * * @param dn device number * @param buffer buffer to store read data in * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_bjnp_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size); /** Initiate a bulk transfer write. * * Write up to size bytes from buffer to the device. After the write size * contains the number of bytes actually written. * * @param dn device number * @param buffer buffer to write to device * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_IO_ERROR - if an error occured during the write * - SANE_STATUS_INVAL - on every other error */ extern SANE_Status sanei_bjnp_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size); /** Initiate a interrupt transfer read. * * Read up to size bytes from the interrupt endpoint from the device to * buffer. After the read, size contains the number of bytes actually read. * * @param dn device number * @param buffer buffer to store read data in * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_bjnp_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size); /*------------------------------------------------------*/ #endif /* sanei_bjnp_h */ sane-backends-1.0.29/backend/pixma/pixma_mp750.c0000666000000000000000000006076213615534521016133 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /**************************************************************************** * Credits should go to Martin Schewe (http://pixma.schewe.com) who analysed * the protocol of MP750. ****************************************************************************/ #include "../include/sane/config.h" #include #include #include "pixma_rename.h" #include "pixma_common.h" #include "pixma_io.h" /* TODO: remove lines marked with SIM. They are inserted so that I can test the subdriver with the simulator. WY */ #ifdef __GNUC__ # define UNUSED(v) (void) v #else # define UNUSED(v) #endif #define IMAGE_BLOCK_SIZE 0xc000 #define CMDBUF_SIZE 512 #define HAS_PAPER(s) (s[1] == 0) #define IS_WARMING_UP(s) (s[7] != 3) #define IS_CALIBRATED(s) (s[8] == 0xf) #define MP750_PID 0x1706 #define MP760_PID 0x1708 #define MP780_PID 0x1707 enum mp750_state_t { state_idle, state_warmup, state_scanning, state_transfering, state_finished }; enum mp750_cmd_t { cmd_start_session = 0xdb20, cmd_select_source = 0xdd20, cmd_scan_param = 0xde20, cmd_status = 0xf320, cmd_abort_session = 0xef20, cmd_time = 0xeb80, cmd_read_image = 0xd420, cmd_activate = 0xcf60, cmd_calibrate = 0xe920, cmd_error_info = 0xff20 }; typedef struct mp750_t { enum mp750_state_t state; pixma_cmdbuf_t cb; unsigned raw_width, raw_height; uint8_t current_status[12]; uint8_t *buf, *rawimg, *img; /* make new buffer for rgb_to_gray to act on */ uint8_t *imgcol; unsigned line_size; /* need in 2 functions */ unsigned rawimg_left, imgbuf_len, last_block_size, imgbuf_ofs; int shifted_bytes; int stripe_shift; /* for 2400dpi */ unsigned last_block; unsigned monochrome:1; unsigned needs_abort:1; } mp750_t; static void mp750_finish_scan (pixma_t * s); static void check_status (pixma_t * s); static int has_paper (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; return HAS_PAPER (mp->current_status); } static int is_warming_up (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; return IS_WARMING_UP (mp->current_status); } static int is_calibrated (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; return IS_CALIBRATED (mp->current_status); } static void drain_bulk_in (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; while (pixma_read (s->io, mp->buf, IMAGE_BLOCK_SIZE) >= 0); } static int abort_session (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; return pixma_exec_short_cmd (s, &mp->cb, cmd_abort_session); } static int query_status (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mp->cb, cmd_status, 0, 12); error = pixma_exec (s, &mp->cb); if (error >= 0) { memcpy (mp->current_status, data, 12); PDBG (pixma_dbg (3, "Current status: paper=%u cal=%u lamp=%u\n", data[1], data[8], data[7])); } return error; } static int activate (pixma_t * s, uint8_t x) { mp750_t *mp = (mp750_t *) s->subdriver; uint8_t *data = pixma_newcmd (&mp->cb, cmd_activate, 10, 0); data[0] = 1; data[3] = x; return pixma_exec (s, &mp->cb); } static int activate_cs (pixma_t * s, uint8_t x) { /*SIM*/ check_status (s); return activate (s, x); } static int start_session (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; return pixma_exec_short_cmd (s, &mp->cb, cmd_start_session); } static int select_source (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; uint8_t *data = pixma_newcmd (&mp->cb, cmd_select_source, 10, 0); data[0] = (s->param->source == PIXMA_SOURCE_ADF) ? 2 : 1; data[1] = 1; return pixma_exec (s, &mp->cb); } static int has_ccd_sensor (pixma_t * s) { return ((s->cfg->cap & PIXMA_CAP_CCD) != 0); } static int is_ccd_grayscale (pixma_t * s) { return (has_ccd_sensor (s) && (s->param->channels == 1)); } /* CCD sensors don't have a Grayscale mode, but use color mode instead */ static unsigned get_cis_ccd_line_size (pixma_t * s) { return (s->param->wx ? s->param->line_size / s->param->w * s->param->wx : s->param->line_size) * ((is_ccd_grayscale (s)) ? 3 : 1); } static int send_scan_param (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; uint8_t *data; data = pixma_newcmd (&mp->cb, cmd_scan_param, 0x2e, 0); pixma_set_be16 (s->param->xdpi | 0x8000, data + 0x04); pixma_set_be16 (s->param->ydpi | 0x8000, data + 0x06); pixma_set_be32 (s->param->x, data + 0x08); pixma_set_be32 (s->param->y, data + 0x0c); pixma_set_be32 (mp->raw_width, data + 0x10); pixma_set_be32 (mp->raw_height, data + 0x14); data[0x18] = 8; /* 8 = color, 4 = grayscale(?) */ /* GH: No, there is no grayscale for CCD devices, Windows shows same */ data[0x19] = s->param->depth * ((is_ccd_grayscale (s)) ? 3 : s->param->channels); /* bits per pixel */ data[0x20] = 0xff; data[0x23] = 0x81; data[0x26] = 0x02; data[0x27] = 0x01; data[0x29] = mp->monochrome ? 0 : 1; return pixma_exec (s, &mp->cb); } static int calibrate (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; return pixma_exec_short_cmd (s, &mp->cb, cmd_calibrate); } static int calibrate_cs (pixma_t * s) { /*SIM*/ check_status (s); return calibrate (s); } static int request_image_block_ex (pixma_t * s, unsigned *size, uint8_t * info, unsigned flag) { mp750_t *mp = (mp750_t *) s->subdriver; int error; memset (mp->cb.buf, 0, 10); pixma_set_be16 (cmd_read_image, mp->cb.buf); mp->cb.buf[7] = *size >> 8; mp->cb.buf[8] = 4 | flag; mp->cb.reslen = pixma_cmd_transaction (s, mp->cb.buf, 10, mp->cb.buf, 6); mp->cb.expected_reslen = 0; error = pixma_check_result (&mp->cb); if (error >= 0) { if (mp->cb.reslen == 6) { *info = mp->cb.buf[2]; *size = pixma_get_be16 (mp->cb.buf + 4); } else { error = PIXMA_EPROTO; } } return error; } static int request_image_block (pixma_t * s, unsigned *size, uint8_t * info) { return request_image_block_ex (s, size, info, 0); } static int request_image_block2 (pixma_t * s, uint8_t * info) { unsigned temp = 0; return request_image_block_ex (s, &temp, info, 0x20); } static int read_image_block (pixma_t * s, uint8_t * data) { int count, temp; count = pixma_read (s->io, data, IMAGE_BLOCK_SIZE); if (count < 0) return count; if (count == IMAGE_BLOCK_SIZE) { int error = pixma_read (s->io, &temp, 0); if (error < 0) { PDBG (pixma_dbg (1, "WARNING: reading zero-length packet failed %d\n", error)); } } return count; } static int read_error_info (pixma_t * s, void *buf, unsigned size) { unsigned len = 16; mp750_t *mp = (mp750_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mp->cb, cmd_error_info, 0, len); error = pixma_exec (s, &mp->cb); if (error >= 0 && buf) { if (len < size) size = len; /* NOTE: I've absolutely no idea what the returned data mean. */ memcpy (buf, data, size); error = len; } return error; } static int send_time (pixma_t * s) { /* TODO: implement send_time() */ UNUSED (s); PDBG (pixma_dbg (3, "send_time() is not yet implemented.\n")); return 0; } static int handle_interrupt (pixma_t * s, int timeout) { int error; uint8_t intr[16]; error = pixma_wait_interrupt (s->io, intr, sizeof (intr), timeout); if (error == PIXMA_ETIMEDOUT) return 0; if (error < 0) return error; if (error != 16) { PDBG (pixma_dbg (1, "WARNING: unexpected interrupt packet length %d\n", error)); return PIXMA_EPROTO; } if (intr[10] & 0x40) send_time (s); if (intr[12] & 0x40) query_status (s); if (intr[15] & 1) s->events = PIXMA_EV_BUTTON2; /* b/w scan */ if (intr[15] & 2) s->events = PIXMA_EV_BUTTON1; /* color scan */ return 1; } static void check_status (pixma_t * s) { while (handle_interrupt (s, 0) > 0); } static int step1 (pixma_t * s) { int error, tmo; error = activate (s, 0); if (error < 0) return error; error = query_status (s); if (error < 0) return error; if (s->param->source == PIXMA_SOURCE_ADF && !has_paper (s)) return PIXMA_ENO_PAPER; error = activate_cs (s, 0); /*SIM*/ if (error < 0) return error; error = activate_cs (s, 0x20); if (error < 0) return error; tmo = 60; error = calibrate_cs (s); while (error == PIXMA_EBUSY && --tmo >= 0) { if (s->cancel) return PIXMA_ECANCELED; PDBG (pixma_dbg (2, "Scanner is busy. Timed out in %d sec.\n", tmo + 1)); pixma_sleep (1000000); error = calibrate_cs (s); } return error; } static void shift_rgb (const uint8_t * src, unsigned pixels, int sr, int sg, int sb, int stripe_shift, int line_size, uint8_t * dst) { unsigned st; for (; pixels != 0; pixels--) { st = (pixels % 2 == 0) ? -2 * stripe_shift * line_size : 0; *(dst++ + sr + st) = *src++; *(dst++ + sg + st) = *src++; *(dst++ + sb + st) = *src++; } } static uint8_t * rgb_to_gray (uint8_t * gptr, const uint8_t * cptr, unsigned pixels, unsigned c) { unsigned i, j, g; /* gptr: destination gray scale buffer */ /* cptr: source color scale buffer */ /* c: 3 for 3-channel single-byte data, 6 for double-byte data */ for (i=0; i < pixels; i++) { for (j = 0, g = 0; j < 3; j++) { g += *cptr++; if (c == 6) g += (*cptr++ << 8); } g /= 3; *gptr++ = g; if (c == 6) *gptr++ = (g >> 8); } return gptr; } static int calc_component_shifting (pixma_t * s) { switch (s->cfg->pid) { case MP760_PID: switch (s->param->ydpi) { case 300: return 3; case 600: return 6; default: return s->param->ydpi / 75; } /* never reached */ break; case MP750_PID: case MP780_PID: default: return 2 * s->param->ydpi / 75; } } static void workaround_first_command (pixma_t * s) { /* FIXME: Send a dummy command because the device doesn't response to the first command that is sent directly after the USB interface has been set up. Why? USB isn't set up properly? */ uint8_t cmd[10]; int error; if (s->cfg->pid == MP750_PID) return; /* MP750 doesn't have this problem(?) */ PDBG (pixma_dbg (1, "Work-around for the problem: device doesn't response to the first command.\n")); memset (cmd, 0, sizeof (cmd)); pixma_set_be16 (cmd_calibrate, cmd); error = pixma_write (s->io, cmd, 10); if (error != 10) { if (error < 0) { PDBG (pixma_dbg (1, " Sending a dummy command failed: %s\n", pixma_strerror (error))); } else { PDBG (pixma_dbg (1, " Sending a dummy command failed: count = %d\n", error)); } return; } error = pixma_read (s->io, cmd, sizeof (cmd)); if (error >= 0) { PDBG (pixma_dbg (1, " Got %d bytes response from a dummy command.\n", error)); } else { PDBG (pixma_dbg (1, " Reading response of a dummy command failed: %s\n", pixma_strerror (error))); } } static int mp750_open (pixma_t * s) { mp750_t *mp; uint8_t *buf; mp = (mp750_t *) calloc (1, sizeof (*mp)); if (!mp) return PIXMA_ENOMEM; buf = (uint8_t *) malloc (CMDBUF_SIZE); if (!buf) { free (mp); return PIXMA_ENOMEM; } s->subdriver = mp; mp->state = state_idle; /* ofs: 0 1 2 3 4 5 6 7 8 9 cmd: cmd1 cmd2 00 00 00 00 00 00 00 00 data length-^^^^^ => cmd_len_field_ofs |--------- cmd_header_len --------| res: res1 res2 |---------| res_header_len */ mp->cb.buf = buf; mp->cb.size = CMDBUF_SIZE; mp->cb.res_header_len = 2; mp->cb.cmd_header_len = 10; mp->cb.cmd_len_field_ofs = 7; handle_interrupt (s, 200); workaround_first_command (s); return 0; } static void mp750_close (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; mp750_finish_scan (s); free (mp->cb.buf); free (mp); s->subdriver = NULL; } static int mp750_check_param (pixma_t * s, pixma_scan_param_t * sp) { unsigned raw_width; UNUSED (s); sp->depth = 8; /* FIXME: Does MP750 supports other depth? */ /* GH: my implementation */ /* if ((sp->channels == 3) || (is_ccd_grayscale (s))) raw_width = ALIGN_SUP (sp->w, 4); else raw_width = ALIGN_SUP (sp->w, 12);*/ /* the above code gives segmentation fault?!? why... it seems to work in the mp750_scan function */ raw_width = ALIGN_SUP (sp->w, 4); /*sp->line_size = raw_width * sp->channels;*/ sp->line_size = raw_width * sp->channels * (sp->depth / 8); /* no cropping? */ return 0; } static int mp750_scan (pixma_t * s) { mp750_t *mp = (mp750_t *) s->subdriver; int error; uint8_t *buf; unsigned size, dpi, spare; dpi = s->param->ydpi; /* add a stripe shift for 2400dpi */ mp->stripe_shift = (dpi == 2400) ? 4 : 0; if (mp->state != state_idle) return PIXMA_EBUSY; /* clear interrupt packets buffer */ while (handle_interrupt (s, 0) > 0) { } /* if (s->param->channels == 1) mp->raw_width = ALIGN_SUP (s->param->w, 12); else mp->raw_width = ALIGN_SUP (s->param->w, 4);*/ /* change to use CCD grayscale mode --- why does this give segmentation error at runtime in mp750_check_param? */ if ((s->param->channels == 3) || (is_ccd_grayscale (s))) mp->raw_width = ALIGN_SUP (s->param->w, 4); else mp->raw_width = ALIGN_SUP (s->param->w, 12); /* not sure about MP750, but there is no need for aligning at 12 for the MP760/770, MP780/790 since always use CCD color mode */ /* modify for stripe shift */ spare = 2 * calc_component_shifting (s) + 2 * mp->stripe_shift; /* FIXME: or maybe (2*... + 1)? */ mp->raw_height = s->param->h + spare; PDBG (pixma_dbg (3, "raw_width=%u raw_height=%u dpi=%u\n", mp->raw_width, mp->raw_height, dpi)); /* PDBG (pixma_dbg (4, "line_size=%"PRIu64"\n",s->param->line_size)); */ mp->line_size = get_cis_ccd_line_size (s); /* scanner hardware line_size multiplied by 3 for CCD grayscale */ size = 8 + 2 * IMAGE_BLOCK_SIZE + spare * mp->line_size; buf = (uint8_t *) malloc (size); if (!buf) return PIXMA_ENOMEM; mp->buf = buf; mp->rawimg = buf; mp->imgbuf_ofs = spare * mp->line_size; mp->imgcol = mp->rawimg + IMAGE_BLOCK_SIZE + 8; /* added to make rgb->gray */ mp->img = mp->rawimg + IMAGE_BLOCK_SIZE + 8; mp->imgbuf_len = IMAGE_BLOCK_SIZE + mp->imgbuf_ofs; mp->rawimg_left = 0; mp->last_block_size = 0; mp->shifted_bytes = -(int) mp->imgbuf_ofs; error = step1 (s); if (error >= 0) error = start_session (s); if (error >= 0) mp->state = state_warmup; if (error >= 0) error = select_source (s); if (error >= 0) error = send_scan_param (s); if (error < 0) { mp750_finish_scan (s); return error; } return 0; } static int mp750_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) { mp750_t *mp = (mp750_t *) s->subdriver; int error; uint8_t info; unsigned block_size, bytes_received, n; int shift[3], base_shift; int c; c = ((is_ccd_grayscale (s)) ? 3 : s->param->channels) * s->param->depth / 8; /* single-byte or double-byte data */ if (mp->state == state_warmup) { int tmo = 60; query_status (s); check_status (s); /*SIM*/ while (!is_calibrated (s) && --tmo >= 0) { if (s->cancel) return PIXMA_ECANCELED; if (handle_interrupt (s, 1000) > 0) { block_size = 0; error = request_image_block (s, &block_size, &info); /*SIM*/ if (error < 0) return error; } } if (tmo < 0) { PDBG (pixma_dbg (1, "WARNING: Timed out waiting for calibration\n")); return PIXMA_ETIMEDOUT; } pixma_sleep (100000); query_status (s); if (is_warming_up (s) || !is_calibrated (s)) { PDBG (pixma_dbg (1, "WARNING: Wrong status: wup=%d cal=%d\n", is_warming_up (s), is_calibrated (s))); return PIXMA_EPROTO; } block_size = 0; request_image_block (s, &block_size, &info); /*SIM*/ mp->state = state_scanning; mp->last_block = 0; } /* TODO: Move to other place, values are constant. */ base_shift = calc_component_shifting (s) * mp->line_size; if (s->param->source == PIXMA_SOURCE_ADF) { shift[0] = 0; shift[1] = -base_shift; shift[2] = -2 * base_shift; } else { shift[0] = -2 * base_shift; shift[1] = -base_shift; shift[2] = 0; } do { if (mp->last_block_size > 0) { block_size = mp->imgbuf_len - mp->last_block_size; memcpy (mp->img, mp->img + mp->last_block_size, block_size); } do { if (s->cancel) return PIXMA_ECANCELED; if (mp->last_block) { /* end of image */ info = mp->last_block; if (info != 0x38) { query_status (s); /*SIM*/ while ((info & 0x28) != 0x28) { pixma_sleep (10000); error = request_image_block2 (s, &info); if (s->cancel) return PIXMA_ECANCELED; /* FIXME: Is it safe to cancel here? */ if (error < 0) return error; } } mp->needs_abort = (info != 0x38); mp->last_block = info; mp->state = state_finished; return 0; } check_status (s); /*SIM*/ while (handle_interrupt (s, 1) > 0); /*SIM*/ block_size = IMAGE_BLOCK_SIZE; error = request_image_block (s, &block_size, &info); if (error < 0) { if (error == PIXMA_ECANCELED) read_error_info (s, NULL, 0); return error; } mp->last_block = info; if ((info & ~0x38) != 0) { PDBG (pixma_dbg (1, "WARNING: Unknown info byte %x\n", info)); } if (block_size == 0) { /* no image data at this moment. */ pixma_sleep (10000); } } while (block_size == 0); error = read_image_block (s, mp->rawimg + mp->rawimg_left); if (error < 0) { mp->state = state_transfering; return error; } bytes_received = error; PASSERT (bytes_received == block_size); /* TODO: simplify! */ mp->rawimg_left += bytes_received; n = mp->rawimg_left / 3; /* n = number of pixels in the buffer? */ /* Color to Grayscale converion for CCD sensor */ if (is_ccd_grayscale (s)) { shift_rgb (mp->rawimg, n, shift[0], shift[1], shift[2], mp->stripe_shift, mp->line_size, mp->imgcol + mp->imgbuf_ofs); /* dst: img, src: imgcol */ rgb_to_gray (mp->img, mp->imgcol, n, c); /* cropping occurs later? */ PDBG (pixma_dbg (4, "*fill_buffer: did grayscale conversion \n")); } /* Color image processing */ else { shift_rgb (mp->rawimg, n, shift[0], shift[1], shift[2], mp->stripe_shift, mp->line_size, mp->img + mp->imgbuf_ofs); PDBG (pixma_dbg (4, "*fill_buffer: no grayscale conversion---keep color \n")); } /* entering remaining unprocessed bytes after last complete pixel into mp->rawimg buffer -- no influence on mp->img */ n *= 3; mp->shifted_bytes += n; mp->rawimg_left -= n; /* rawimg_left = 0, 1 or 2 bytes left in the buffer. */ mp->last_block_size = n; memcpy (mp->rawimg, mp->rawimg + n, mp->rawimg_left); } while (mp->shifted_bytes <= 0); if ((unsigned) mp->shifted_bytes < mp->last_block_size) { if (is_ccd_grayscale (s)) ib->rptr = mp->img + mp->last_block_size/3 - mp->shifted_bytes/3; /* testing---works OK */ else ib->rptr = mp->img + mp->last_block_size - mp->shifted_bytes; } else ib->rptr = mp->img; if (is_ccd_grayscale (s)) ib->rend = mp->img + mp->last_block_size/3; /* testing---works OK */ else ib->rend = mp->img + mp->last_block_size; return ib->rend - ib->rptr; } static void mp750_finish_scan (pixma_t * s) { int error; mp750_t *mp = (mp750_t *) s->subdriver; switch (mp->state) { case state_transfering: drain_bulk_in (s); /* fall through */ case state_scanning: case state_warmup: error = abort_session (s); if (error == PIXMA_ECANCELED) read_error_info (s, NULL, 0); /* fall through */ case state_finished: if (s->param->source == PIXMA_SOURCE_FLATBED) { /*SIM*/ query_status (s); if (abort_session (s) == PIXMA_ECANCELED) { read_error_info (s, NULL, 0); query_status (s); } } query_status (s); /*SIM*/ activate (s, 0); if (mp->needs_abort) { mp->needs_abort = 0; abort_session (s); } free (mp->buf); mp->buf = mp->rawimg = NULL; mp->state = state_idle; /* fall through */ case state_idle: break; } } static void mp750_wait_event (pixma_t * s, int timeout) { /* FIXME: timeout is not correct. See usbGetCompleteUrbNoIntr() for * instance. */ while (s->events == 0 && handle_interrupt (s, timeout) > 0) { } } static int mp750_get_status (pixma_t * s, pixma_device_status_t * status) { int error; error = query_status (s); if (error < 0) return error; status->hardware = PIXMA_HARDWARE_OK; status->adf = (has_paper (s)) ? PIXMA_ADF_OK : PIXMA_ADF_NO_PAPER; status->cal = (is_calibrated (s)) ? PIXMA_CALIBRATION_OK : PIXMA_CALIBRATION_OFF; status->lamp = (is_warming_up (s)) ? PIXMA_LAMP_WARMING_UP : PIXMA_LAMP_OK; return 0; } static const pixma_scan_ops_t pixma_mp750_ops = { mp750_open, mp750_close, mp750_scan, mp750_fill_buffer, mp750_finish_scan, mp750_wait_event, mp750_check_param, mp750_get_status }; #define DEVICE(name, model, pid, dpi, cap) { \ name, /* name */ \ model, /* model */ \ 0x04a9, pid, /* vid pid */ \ 0, /* iface */ \ &pixma_mp750_ops, /* ops */ \ 0, /* min_xdpi not used in this subdriver */ \ dpi, 2*(dpi), /* xdpi, ydpi */ \ 0, 0, /* adftpu_min_dpi & adftpu_max_dpi not used in this subdriver */ \ 0, 0, /* tpuir_min_dpi & tpuir_max_dpi not used in this subdriver */ \ 637, 877, /* width, height */ \ PIXMA_CAP_CCD| /* all scanners with CCD */ \ PIXMA_CAP_GRAY|PIXMA_CAP_EVENTS|cap \ } const pixma_config_t pixma_mp750_devices[] = { DEVICE ("Canon PIXMA MP750", "MP750", MP750_PID, 2400, PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MP760/770", "MP760/770", MP760_PID, 2400, PIXMA_CAP_TPU), DEVICE ("Canon PIXMA MP780/790", "MP780/790", MP780_PID, 2400, PIXMA_CAP_ADF), DEVICE (NULL, NULL, 0, 0, 0) }; sane-backends-1.0.29/backend/pixma/pixma.h0000666000000000000000000004053513615534521015204 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2007-2008 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef PIXMA_H #define PIXMA_H #include "../include/sane/sane.h" /*! * \mainpage Scanner driver for Canon PIXMA MP series * \section example Sample code for application * \code * pixma_set_debug_level(level); * pixma_init(); * nscanners = pixma_find_scanners(); * devnr = choose_scanner(nscanners); * scanner = pixma_open(devnr); * setup_param(param); * pixma_check_scan_param(scanner, param); * do { * if (I_need_events && * (ev = pixma_wait_event(scanner, timeout)) > 0) { * handle_event(ev); * } * pixma_scan(scanner, param); * while ((count = pixma_read_image(scanner, buf, len)) > 0) { * write(buf, count); * if (error_occured_in_write) { * pixma_cancel(scanner); * } * } * } while (!enough); * pixma_close(scanner); * pixma_cleanup(); * \endcode * * Note: pixma_cancel() can be called asynchronously to * interrupt pixma_read_image(). It does not cancel the operation * immediately. pixma_read_image() must be called until it * returns zero or an error (probably \c PIXMA_ECANCELED). * * \section reference Reference * - \subpage API * - \subpage IO * - \subpage subdriver * - \subpage debug */ /*! * \defgroup API The driver API * \brief The driver API. * * The return value of functions that returns \c int has the following * meaning if not otherwise specified: * - >= 0 if succeeded * - < 0 if failed */ #ifdef HAVE_STDINT_H # include /* available in ISO C99 */ #else # include typedef uint8_t uint8_t; typedef uint16_t uint16_t; typedef uint32_t uint32_t; #endif /* HAVE_STDINT_H */ #ifdef HAVE_INTTYPES_H # include /* available in ISO C99 */ #endif /* HAVE_INTTYPES_H */ /** \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 27 #define PIXMA_VERSION_BUILD 0 /**@}*/ /** \name Error codes */ /**@{*/ #define PIXMA_EIO -1 #define PIXMA_ENODEV -2 #define PIXMA_EACCES -3 #define PIXMA_ENOMEM -4 #define PIXMA_EINVAL -5 #define PIXMA_EBUSY -6 #define PIXMA_ECANCELED -7 #define PIXMA_ENOTSUP -8 #define PIXMA_ETIMEDOUT -9 #define PIXMA_EPROTO -10 #define PIXMA_EPAPER_JAMMED -11 #define PIXMA_ECOVER_OPEN -12 #define PIXMA_ENO_PAPER -13 #define PIXMA_EOF -14 /**@}*/ /** \name Capabilities for using with pixma_config_t::cap */ /**@{*/ #define PIXMA_CAP_EASY_RGB (1 << 0) #define PIXMA_CAP_GRAY (1 << 1) #define PIXMA_CAP_ADF (1 << 2) #define PIXMA_CAP_48BIT (1 << 3) #define PIXMA_CAP_GAMMA_TABLE (1 << 4) #define PIXMA_CAP_EVENTS (1 << 5) #define PIXMA_CAP_TPU (1 << 6) #define PIXMA_CAP_ADFDUP ((1 << 7) | PIXMA_CAP_ADF) #define PIXMA_CAP_CIS (0) #define PIXMA_CAP_CCD (1 << 8) #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_ADF_JPEG (1 << 13) #define PIXMA_CAP_EXPERIMENT (1 << 31) /**@}*/ /** \name Button events and related information returned by pixma_wait_event() */ /**@{*/ #define PIXMA_EV_NONE 0 #define PIXMA_EV_ACTION_MASK (0xffffff) #define PIXMA_EV_BUTTON1 (1 << 24) #define PIXMA_EV_BUTTON2 (2 << 24) #define PIXMA_EV_TARGET_MASK (0xff) #define PIXMA_EV_ORIGINAL_MASK (0xff00) #define PIXMA_EV_DPI_MASK (0xff0000) #define GET_EV_TARGET(x) (x & PIXMA_EV_TARGET_MASK) #define GET_EV_ORIGINAL(x) ( (x & PIXMA_EV_ORIGINAL_MASK) >> 8 ) #define GET_EV_DPI(x) ( (x & PIXMA_EV_DPI_MASK) >> 16 ) /**@}*/ /** @} end of API group */ #define PIXMA_CONFIG_FILE "pixma.conf" #define MAX_CONF_DEVICES 15 struct pixma_t; struct pixma_scan_ops_t; struct pixma_scan_param_t; struct pixma_config_t; struct pixma_cmdbuf_t; struct pixma_imagebuf_t; struct pixma_device_status_t; typedef struct pixma_t pixma_t; typedef struct pixma_scan_ops_t pixma_scan_ops_t; typedef struct pixma_scan_param_t pixma_scan_param_t; typedef struct pixma_config_t pixma_config_t; typedef struct pixma_cmdbuf_t pixma_cmdbuf_t; typedef struct pixma_imagebuf_t pixma_imagebuf_t; typedef struct pixma_device_status_t pixma_device_status_t; /** \addtogroup API * @{ */ /** String index constants */ typedef enum pixma_string_index_t { PIXMA_STRING_MODEL, PIXMA_STRING_ID, PIXMA_STRING_LAST } pixma_string_index_t; /** Paper sources */ typedef enum pixma_paper_source_t { PIXMA_SOURCE_FLATBED, PIXMA_SOURCE_ADF, PIXMA_SOURCE_TPU, PIXMA_SOURCE_ADFDUP /* duplex */ } pixma_paper_source_t; /** Scan modes */ typedef enum pixma_scan_mode_t { /* standard scan modes */ PIXMA_SCAN_MODE_COLOR, PIXMA_SCAN_MODE_GRAY, /* TPU scan modes for negatives */ PIXMA_SCAN_MODE_NEGATIVE_COLOR, PIXMA_SCAN_MODE_NEGATIVE_GRAY, /* extended scan modes for 48 bit flatbed scanners */ PIXMA_SCAN_MODE_COLOR_48, PIXMA_SCAN_MODE_GRAY_16, /* 1 bit lineart scan mode */ PIXMA_SCAN_MODE_LINEART, /* TPUIR scan mode */ PIXMA_SCAN_MODE_TPUIR } pixma_scan_mode_t; typedef enum pixma_hardware_status_t { PIXMA_HARDWARE_OK, PIXMA_HARDWARE_ERROR } pixma_hardware_status_t; typedef enum pixma_lamp_status_t { PIXMA_LAMP_OK, PIXMA_LAMP_WARMING_UP, PIXMA_LAMP_OFF, PIXMA_LAMP_ERROR } pixma_lamp_status_t; typedef enum pixma_adf_status_t { PIXMA_ADF_OK, PIXMA_ADF_NO_PAPER, PIXMA_ADF_JAMMED, PIXMA_ADF_COVER_OPEN, PIXMA_ADF_ERROR } pixma_adf_status_t; typedef enum pixma_calibration_status_t { PIXMA_CALIBRATION_OK, PIXMA_CALIBRATION_IN_PROGRESS, PIXMA_CALIBRATION_OFF, PIXMA_CALIBRATION_ERROR } pixma_calibration_status_t; /** Device status. */ struct pixma_device_status_t { pixma_hardware_status_t hardware; pixma_lamp_status_t lamp; pixma_adf_status_t adf; pixma_calibration_status_t cal; }; /** Scan parameters. */ struct pixma_scan_param_t { /** Size in bytes of one image line (row). * line_size >= depth / 8 * channels * w
* This field will be set by pixma_check_scan_param(). */ uint64_t line_size; /** Size in bytes of the whole image. * image_size = line_size * h
* This field will be set by pixma_check_scan_param(). */ uint64_t image_size; /** Channels per pixel. 1 = grayscale and lineart, 3 = color */ unsigned channels; /** Bits per channels. * 1 = 1 bit B/W lineart (flatbed) * 8 = 8 bit grayscale, * 24 bit color (both flatbed) * 16 = 16 bit grayscale (TPU, flatbed not implemeted), * 48 bit color (TPU, flatbed not implemented) */ unsigned depth; /*@{ */ /** Resolution. Valid values are 75,150,300,600,1200... */ unsigned xdpi, ydpi; /*@} */ /*! \name Scan area in pixels * (0,0) = top left; positive x extends to the right; positive y to the * bottom; in pixels. * xs is the offset in x direction of the selected scan range relative * to the range read from the scanner and wx the width in x direction * of the scan line read from scanner. */ /*@{ */ unsigned x, y, w, h, xs, wx; /*@} */ /** Flag indicating whether the offset correction for TPU scans * was already performed (to avoid repeated corrections). * Currently only used in pixma_mp800.c sub-driver */ unsigned tpu_offset_added; /* Flag indicating if data from scanner will be in JPEG format */ unsigned mode_jpeg; /** Flag indicating whether a software-lineart scan is in progress * 0 = other scan * 1 = software-lineart scan */ unsigned software_lineart; /** Threshold for software-lineart scans */ unsigned threshold; /** lineart threshold curve for dynamic rasterization */ unsigned threshold_curve; /* look up table used in dynamic rasterization */ unsigned char lineart_lut[256]; /** Gamma table. 4096 entries, 12 bit => 8 bit. If \c NULL, default gamma * specified by subdriver will be used. */ const uint8_t *gamma_table; /** \see #pixma_paper_source_t */ pixma_paper_source_t source; /** \see #pixma_scan_mode_t */ pixma_scan_mode_t mode; /** 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 */ struct pixma_config_t { /* If you change this structure, don't forget to update the device list in * subdrivers. */ const char *name; /**< Model name. */ const char *model; /**< Short model */ uint16_t vid; /**< USB Vendor ID */ uint16_t pid; /**< USB Product ID */ unsigned iface; /**< USB Interface number */ const pixma_scan_ops_t *ops; /**< Subdriver ops */ unsigned min_xdpi; /**< Minimum horizontal resolution[DPI] */ unsigned xdpi; /**< Maximum horizontal resolution[DPI] */ unsigned ydpi; /**< Maximum vertical resolution[DPI] */ unsigned adftpu_min_dpi; /**< Maximum horizontal resolution[DPI] for adf/tpu * only needed if ADF/TPU has another min. dpi value than 75 dpi */ unsigned adftpu_max_dpi; /**< Maximum vertical resolution[DPI] for adf/tpu * only needed if ADF/TPU has another max. dpi value than xdpi */ unsigned tpuir_min_dpi; /**< Minimum resolution[DPI] for tpu-ir * only needed if TPU-IR has another min. dpi value than 75 dpi */ unsigned tpuir_max_dpi; /**< Maximum resolution[DPI] for tpu-ir * only needed if TPU-IR has another max. dpi value than xdpi */ unsigned width; /**< Maximum width of scannable area in pixels at 75DPI */ unsigned height; /**< Maximum height of scannable area in pixels at 75DPI */ unsigned cap; /**< Capability bitfield \see PIXMA_CAP_* */ }; /* Defined in pixma_common.c */ /** Initialize the driver. It must be called before any other functions * except pixma_set_debug_level(). */ int pixma_init (void); /** Free resources allocated by the driver. */ void pixma_cleanup (void); /** Set the debug level. * \param[in] level the debug level * - 0 No debug output at all * - 1 Only errors and warning * - 2 General information * - 3 Debugging messages * - 10 USB traffic dump */ void pixma_set_debug_level (int level); /** Find scanners. The device number used in pixma_open(), * pixma_get_device_model(), pixma_get_device_id() and * pixma_get_device_config() must be less than the value returned by the last * call of this function. * * \return The number of scanners found currently. The return value is * guaranteed to be valid until the next call to pixma_find_scanners(). */ int pixma_find_scanners (const char **conf_devices, SANE_Bool local_only); /** Return the model name of the device \a devnr. */ const char *pixma_get_device_model (unsigned devnr); /** Return the unique ID of the device \a devnr. */ const char *pixma_get_device_id (unsigned devnr); /** Return the device configuration of the device \a devnr. */ const struct pixma_config_t *pixma_get_device_config (unsigned devnr); /** Open a connection to the scanner \a devnr. * \param[in] devnr The scanner number * \param[out] handle The device handle * \see pixma_find_scanners() */ int pixma_open (unsigned devnr, pixma_t ** handle); /** Close the connection to the scanner. The scanning process is aborted * if necessary before the function returns. */ void pixma_close (pixma_t * s); /** Initiate an image acquisition process. You must keep \a sp valid until the * image acquisition process has finished. */ int pixma_scan (pixma_t *, pixma_scan_param_t * sp); /** Read a block of image data. It blocks until there is at least one byte * available or an error occurs. * * \param[out] buf Pointer to the buffer * \param[in] len Size of the buffer * * \retval count Number of bytes written to the buffer or error. Possible * return value: * - count = 0 for end of image * - count = \a len * - 0 < count < \a len if and only if it is the last block. * - count < 0 for error */ int pixma_read_image (pixma_t *, void *buf, unsigned len); #if 0 /** Read a block of image data and write to \a fd. * \param[in] fd output file descriptor * \see pixma_read_image() */ int pixma_read_image_write (pixma_t *, int fd); #endif /** Cancel the scanning process. No effect if no scanning process is in * progress. It can be called asynchronously e.g. within a signal * handle. pixma_cancel() doesn't abort the operation immediately. It * guarantees that the current call or, at the latest, the next call to * pixma_read_image() will return zero or an error (probably PIXMA_ECANCELED). */ void pixma_cancel (pixma_t *); /** Check the scan parameters. This function can change your parameters to * match the device capability, e.g. adjust width and height to the available * area. * \return PIXMA_EINVAL for invalid parameters. */ int pixma_check_scan_param (pixma_t *, pixma_scan_param_t *); /** Wait until a scanner button is pressed or it times out. It should not be * called during image acquisition is in progress. * \param[in] timeout in milliseconds, less than 0 means forever * \return * - \c PIXMA_EV_NONE if it timed out. * - non-zero value indicates which button was pressed. * \see PIXMA_EV_* */ uint32_t pixma_wait_event (pixma_t *, int timeout); /** Activate connection to scanner */ int pixma_activate_connection (pixma_t *); /** De-activate connection to scanner */ int pixma_deactivate_connection (pixma_t *); /** Enable or disable background tasks. Currently, the only one task * is submitting interrupt URB in background. * \param[in] enabled if not zero, enable background task. * \see pixma_set_interrupt_mode() */ int pixma_enable_background (pixma_t *, int enabled); /** Read the current device status. * \param[out] status the current device status * \return 0 if succeeded. Otherwise, failed. */ int pixma_get_device_status (pixma_t *, pixma_device_status_t * status); const char *pixma_get_string (pixma_t *, pixma_string_index_t); const pixma_config_t *pixma_get_config (pixma_t *); void pixma_fill_gamma_table (double gamma, uint8_t * table, unsigned n); const char *pixma_strerror (int error); /** @} end of API group */ #endif sane-backends-1.0.29/backend/pixma/pixma_sane_options.h0000666000000000000000000000151513615534521017760 00000000000000/* Automatically generated from pixma_sane.c */ typedef union { SANE_Word w; SANE_Int i; SANE_Bool b; SANE_Fixed f; SANE_String s; void *ptr; } option_value_t; typedef enum { opt_opt_num_opts, opt__group_1, opt_resolution, opt_mode, opt_source, opt_button_controlled, opt__group_2, opt_custom_gamma, opt_gamma_table, opt_gamma, opt__group_3, opt_tl_x, opt_tl_y, opt_br_x, opt_br_y, opt__group_4, opt_button_update, opt_button_1, opt_button_2, opt_original, opt_target, opt_scan_resolution, opt__group_5, opt_threshold, opt_threshold_curve, opt_adf_wait, opt_last } option_t; typedef struct { SANE_Option_Descriptor sod; option_value_t val,def; SANE_Word info; } option_descriptor_t; struct pixma_sane_t; static int build_option_descriptors(struct pixma_sane_t *ss); sane-backends-1.0.29/backend/pixma/pixma_rename.h0000666000000000000000000001070313615534521016525 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef PIXMA_RENAME_H #define PIXMA_RENAME_H #undef BACKEND_NAME #define BACKEND_NAME pixma #define pixma_cancel sanei_pixma_cancel #define pixma_check_dpi sanei_pixma_check_dpi #define pixma_check_result sanei_pixma_check_result #define pixma_check_scan_param sanei_pixma_check_scan_param #define pixma_cleanup sanei_pixma_cleanup #define pixma_close sanei_pixma_close #define pixma_cmd_transaction sanei_pixma_cmd_transaction #define pixma_collect_devices sanei_pixma_collect_devices #define pixma_connect sanei_pixma_connect #define pixma_dbg DBG #define pixma_disconnect sanei_pixma_disconnect #define pixma_dump sanei_pixma_dump #define pixma_enable_background sanei_pixma_enable_background #define pixma_exec sanei_pixma_exec #define pixma_exec_short_cmd sanei_pixma_exec_short_cmd #define pixma_fill_gamma_table sanei_pixma_fill_gamma_table #define pixma_find_scanners sanei_pixma_find_scanners #define pixma_get_be16 sanei_pixma_get_be16 #define pixma_get_be32 sanei_pixma_get_be32 #define pixma_get_config sanei_pixma_get_config #define pixma_get_device_config sanei_pixma_get_device_config #define pixma_get_device_id sanei_pixma_get_device_id #define pixma_get_device_model sanei_pixma_get_device_model #define pixma_get_device_status sanei_pixma_get_device_status #define pixma_get_string sanei_pixma_get_string #define pixma_get_time sanei_pixma_get_time #define pixma_hexdump sanei_pixma_hexdump #define pixma_init sanei_pixma_init #define pixma_io_cleanup sanei_pixma_io_cleanup #define pixma_io_init sanei_pixma_io_init #define pixma_map_status_errno sanei_pixma_map_status_errno #define pixma_mp150_devices sanei_pixma_mp150_devices #define pixma_mp730_devices sanei_pixma_mp730_devices #define pixma_mp750_devices sanei_pixma_mp750_devices #define pixma_mp800_devices sanei_pixma_mp800_devices #define pixma_iclass_devices sanei_pixma_iclass_devices #define pixma_newcmd sanei_pixma_newcmd #define pixma_open sanei_pixma_open #define pixma_print_supported_devices sanei_pixma_print_supported_devices #define pixma_read_image sanei_pixma_read_image #define pixma_read sanei_pixma_read #define pixma_reset_device sanei_pixma_reset_device #define pixma_scan sanei_pixma_scan #define pixma_set_be16 sanei_pixma_set_be16 #define pixma_set_be32 sanei_pixma_set_be32 #define pixma_set_debug_level sanei_pixma_set_debug_level #define pixma_set_interrupt_mode sanei_pixma_set_interrupt_mode #define pixma_sleep sanei_pixma_sleep #define pixma_strerror sanei_pixma_strerror #define pixma_sum_bytes sanei_pixma_sum_bytes #define pixma_wait_event sanei_pixma_wait_event #define pixma_wait_interrupt sanei_pixma_wait_interrupt #define pixma_write sanei_pixma_write #endif sane-backends-1.0.29/backend/pixma/pixma_common.h0000666000000000000000000001705113615534521016551 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef PIXMA_COMMON_H #define PIXMA_COMMON_H #include /* time_t */ #include "pixma.h" /*! \defgroup subdriver Subdriver Interface * \brief Subdriver interface. */ /*! \defgroup debug Debug utilities * \brief Debug utilities. */ #ifdef NDEBUG # define PDBG(x) do {} while(0) # define PASSERT(x) do {} while(0) #else # define PDBG(x) x # define PASSERT(x) do { \ if (!(x)) \ pixma_dbg(1, "ASSERT failed:%s:%d: " \ #x "\n", __FILE__, __LINE__); \ } while(0) #endif #define PIXMA_STATUS_OK 0x0606 #define PIXMA_STATUS_FAILED 0x1515 #define PIXMA_STATUS_BUSY 0x1414 #define PIXMA_MAX_ID_LEN 30 /* These may have been defined elsewhere */ #ifndef MIN #define MIN(x,y) (((x) < (y)) ? (x):(y)) #endif #ifndef MAX #define MAX(x,y) (((x) < (y)) ? (y):(x)) #endif #define ALIGN_SUP(x,n) (((x) + (n) - 1) / (n) * (n)) #define ALIGN_INF(x,n) (((x) / (n)) * (n)) struct pixma_io_t; struct pixma_limits_t { unsigned xdpi, ydpi; unsigned width, height; }; struct pixma_cmdbuf_t { unsigned cmd_header_len, res_header_len, cmd_len_field_ofs; unsigned expected_reslen, cmdlen; int reslen; unsigned size; uint8_t *buf; }; struct pixma_imagebuf_t { uint8_t *wptr, *wend; const uint8_t *rptr, *rend; }; struct pixma_t { pixma_t *next; struct pixma_io_t *io; const pixma_scan_ops_t *ops; pixma_scan_param_t *param; const pixma_config_t *cfg; char id[PIXMA_MAX_ID_LEN + 1]; 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; pixma_imagebuf_t imagebuf; unsigned scanning:1; unsigned underrun:1; }; /** \addtogroup subdriver * @{ */ /** Scan operations for subdriver. */ struct pixma_scan_ops_t { /** Allocate a data structure for the subdriver. It is called after the * core driver connected to the scanner. The subdriver should reset the * scanner to a known state in this function. */ int (*open) (pixma_t *); /** Free resources allocated by the subdriver. Don't forget to send abort * command to the scanner if it is scanning. */ void (*close) (pixma_t *); /** Setup the scanner for scan parameters defined in \a s->param. */ int (*scan) (pixma_t * s); /** Fill a buffer with image data. The subdriver has two choices: * -# Fill the buffer pointed by ib->wptr directly and leave * ib->rptr and ib->rend untouched. The length of the buffer is * ib->wend - ib->wptr. It must update ib->wptr accordingly. * -# Update ib->rptr and ib->rend to point to the beginning and * the end of the internal buffer resp. The length of the buffer * is ib->rend - ib->rptr. This function is called again if * and only if pixma_read_image() has copied the whole buffer. * * The subdriver must wait until there is at least one byte to read or * return 0 for the end of image. */ int (*fill_buffer) (pixma_t *, pixma_imagebuf_t * ib); /** Cancel the scan operation if necessary and free resources allocated in * scan(). */ void (*finish_scan) (pixma_t *); /** [Optional] Wait for a user's event, e.g. button event. \a timeout is * in milliseconds. If an event occured before it's timed out, flags in * \a s->events should be set accordingly. * \see PIXMA_EV_* */ void (*wait_event) (pixma_t * s, int timeout); /** Check the scan parameters. The parameters can be adjusted if they are * out of range, e.g. width > max_width. */ int (*check_param) (pixma_t *, pixma_scan_param_t *); /** Read the device status. \see pixma_get_device_status() */ int (*get_status) (pixma_t *, pixma_device_status_t *); }; /** \name Funtions for read and write big-endian integer values */ /**@{*/ void pixma_set_be16 (uint16_t x, uint8_t * buf); void pixma_set_be32 (uint32_t x, uint8_t * buf); uint16_t pixma_get_be16 (const uint8_t * buf); uint32_t pixma_get_be32 (const uint8_t * buf); /**@}*/ /** \name Utility functions */ /**@{*/ uint8_t pixma_sum_bytes (const void *data, unsigned len); int pixma_check_dpi (unsigned dpi, unsigned max); void pixma_sleep (unsigned long usec); void pixma_get_time (time_t * sec, uint32_t * usec); uint8_t * pixma_r_to_ir (uint8_t * gptr, uint8_t * sptr, unsigned w, unsigned c); uint8_t * pixma_rgb_to_gray (uint8_t * gptr, uint8_t * sptr, unsigned w, unsigned c); uint8_t * pixma_binarize_line(pixma_scan_param_t *, uint8_t * dst, uint8_t * src, unsigned width, unsigned c); /**@}*/ /** \name Command related functions */ /**@{*/ int pixma_cmd_transaction (pixma_t *, const void *cmd, unsigned cmdlen, void *data, unsigned expected_len); int pixma_check_result (pixma_cmdbuf_t *); uint8_t *pixma_newcmd (pixma_cmdbuf_t *, unsigned cmd, unsigned dataout, unsigned datain); int pixma_exec (pixma_t *, pixma_cmdbuf_t *); int pixma_exec_short_cmd (pixma_t *, pixma_cmdbuf_t *, unsigned cmd); int pixma_map_status_errno (unsigned status); /**@}*/ #define pixma_fill_checksum(start, end) do { \ *(end) = -pixma_sum_bytes(start, (end)-(start)); \ } while(0) /** @} end of group subdriver */ /** \addtogroup debug * @{ */ void pixma_set_debug_level (int level); #ifndef NDEBUG void pixma_hexdump (int level, const void *d_, unsigned len); /* len: length of data or error code. size: if >= 0, force to print 'size' bytes. max: maximum number of bytes to print(-1 means no limit). */ void pixma_dump (int level, const char *type, const void *data, int len, int size, int max); # define DEBUG_DECLARE_ONLY # include "../include/sane/sanei_debug.h" #endif /* NDEBUG */ /** @} end of group debug */ #endif sane-backends-1.0.29/backend/pixma/pixma_mp150.c0000666000000000000000000017610413615534521016123 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2007-2009 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* test cases 1. short USB packet (must be no -ETIMEDOUT) 2. cancel using button on the printer (look for abort command) 3. start scan while busy (status 0x1414) 4. cancel using ctrl-c (must send abort command) */ #include "../include/sane/config.h" #include #include #include #include /* localtime(C90) */ #include "pixma_rename.h" #include "pixma_common.h" #include "pixma_io.h" /* Some macro code to enhance readability */ #define RET_IF_ERR(x) do { \ if ((error = (x)) < 0) \ return error; \ } while(0) #define WAIT_INTERRUPT(x) do { \ error = handle_interrupt (s, x); \ if (s->cancel) \ return PIXMA_ECANCELED; \ if (error != PIXMA_ECANCELED && error < 0) \ return error; \ } while(0) #ifdef __GNUC__ # define UNUSED(v) (void) v #else # define UNUSED(v) #endif /* Size of the command buffer should be multiple of wMaxPacketLength and greater than 4096+24. 4096 = size of gamma table. 24 = header + checksum */ #define IMAGE_BLOCK_SIZE (512*1024) #define CMDBUF_SIZE (4096 + 24) #define DEFAULT_GAMMA 2.0 /***** Gamma different from 1.0 is potentially impacting color profile generation *****/ #define UNKNOWN_PID 0xffff #define CANON_VID 0x04a9 /* Generation 1 */ #define MP150_PID 0x1709 #define MP170_PID 0x170a #define MP450_PID 0x170b #define MP500_PID 0x170c #define MP530_PID 0x1712 /* Generation 2 */ #define MP160_PID 0x1714 #define MP180_PID 0x1715 #define MP460_PID 0x1716 #define MP510_PID 0x1717 #define MP600_PID 0x1718 #define MP600R_PID 0x1719 #define MP140_PID 0x172b /* Generation 3 */ /* PIXMA 2007 vintage */ #define MX7600_PID 0x171c #define MP210_PID 0x1721 #define MP220_PID 0x1722 #define MP470_PID 0x1723 #define MP520_PID 0x1724 #define MP610_PID 0x1725 #define MX300_PID 0x1727 #define MX310_PID 0x1728 #define MX700_PID 0x1729 #define MX850_PID 0x172c /* PIXMA 2008 vintage */ #define MP630_PID 0x172e #define MP620_PID 0x172f #define MP540_PID 0x1730 #define MP480_PID 0x1731 #define MP240_PID 0x1732 #define MP260_PID 0x1733 #define MP190_PID 0x1734 /* PIXMA 2009 vintage */ #define MX860_PID 0x1735 #define MX320_PID 0x1736 /* untested */ #define MX330_PID 0x1737 /* Generation 4 */ #define MP250_PID 0x173a #define MP270_PID 0x173b #define MP490_PID 0x173c #define MP550_PID 0x173d #define MP560_PID 0x173e #define MP640_PID 0x173f /* PIXMA 2010 vintage */ #define MX340_PID 0x1741 #define MX350_PID 0x1742 #define MX870_PID 0x1743 /* 2010 new devices (untested) */ #define MP280_PID 0x1746 #define MP495_PID 0x1747 #define MG5100_PID 0x1748 #define MG5200_PID 0x1749 #define MG6100_PID 0x174a /* PIXMA 2011 vintage */ #define MX360_PID 0x174d #define MX410_PID 0x174e #define MX420_PID 0x174f #define MX880_PID 0x1750 /* Generation 5 */ /* 2011 new devices (untested) */ #define MG2100_PID 0x1751 #define MG3100_PID 0x1752 #define MG4100_PID 0x1753 #define MG5300_PID 0x1754 #define MG6200_PID 0x1755 #define MP493_PID 0x1757 #define E500_PID 0x1758 /* 2012 new devices (untested) */ #define MX370_PID 0x1759 #define MX430_PID 0x175B #define MX510_PID 0x175C #define MX710_PID 0x175D #define MX890_PID 0x175E #define E600_PID 0x175A #define MG4200_PID 0x1763 /* 2013 new devices */ #define MP230_PID 0x175F #define MG6300_PID 0x1765 /* 2013 new devices (untested) */ #define MG2200_PID 0x1760 #define E510_PID 0x1761 #define MG3200_PID 0x1762 #define MG5400_PID 0x1764 #define MX390_PID 0x1766 #define E610_PID 0x1767 #define MX450_PID 0x1768 #define MX520_PID 0x1769 #define MX720_PID 0x176a #define MX920_PID 0x176b #define MG2400_PID 0x176c #define MG2500_PID 0x176d #define MG3500_PID 0x176e #define MG6500_PID 0x176f #define MG6400_PID 0x1770 #define MG5500_PID 0x1771 #define MG7100_PID 0x1772 /* 2014 new devices (untested) */ #define MX470_PID 0x1774 #define MX530_PID 0x1775 #define MB5000_PID 0x1776 #define MB5300_PID 0x1777 #define MB2000_PID 0x1778 #define MB2300_PID 0x1779 #define E400_PID 0x177a #define E560_PID 0x177b #define MG7500_PID 0x177c #define MG6600_PID 0x177e #define MG5600_PID 0x177f #define MG2900_PID 0x1780 #define E460_PID 0x1788 /* 2015 new devices (untested) */ #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 MB2700_PID 0x1792 #define MB2100_PID 0x1793 #define G3000_PID 0x1794 #define G2000_PID 0x1795 #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 E410_PID 0x181e /* 2017 new devices (untested) */ #define G4000_PID 0x181d #define TS6100_PID 0x1822 #define TS5100_PID 0x1825 #define TS3100_PID 0x1827 #define E3100_PID 0x1828 /* 2018 new devices (untested) */ #define MB5400_PID 0x178f #define MB5100_PID 0x1790 #define TS9100_PID 0x1820 #define TR8500_PID 0x1823 #define TR7500_PID 0x1824 #define TS9500_PID 0x185c #define LIDE400_PID 0x1912 /* tested */ #define LIDE300_PID 0x1913 /* tested */ /* 2019 new devices (untested) */ #define TS8100_PID 0x1821 #define G2010_PID 0x183a #define G3010_PID 0x183b #define G4010_PID 0x183d #define TS9180_PID 0x183e #define TS8180_PID 0x183f #define TS6180_PID 0x1840 #define TR8580_PID 0x1841 #define TS8130_PID 0x1842 #define TS6130_PID 0x1843 #define TR8530_PID 0x1844 #define TR7530_PID 0x1845 #define XK50_PID 0x1846 #define XK70_PID 0x1847 #define TR4500_PID 0x1854 #define E4200_PID 0x1855 #define TS6200_PID 0x1856 #define TS6280_PID 0x1857 #define TS6230_PID 0x1858 #define TS8200_PID 0x1859 #define TS8280_PID 0x185a #define TS8230_PID 0x185b #define TS9580_PID 0x185d #define TR9530_PID 0x185e #define G6000_PID 0x1865 #define G6080_PID 0x1866 #define XK80_PID 0x1873 #define TS5300_PID 0x188b #define TS5380_PID 0x188c #define TS6300_PID 0x188d #define TS6380_PID 0x188e #define TS7330_PID 0x188f #define TS8300_PID 0x1890 #define TS8380_PID 0x1891 #define TS8330_PID 0x1892 #define XK60_PID 0x1893 #define TS6330_PID 0x1894 #define TS3300_PID 0x18a2 #define E3300_PID 0x18a3 /* Generation 4 XML messages that encapsulates the Pixma protocol messages */ #define XML_START_1 \ "\ \ StartJob\ 00000001\ 1" #define XML_START_2 \ "\ \ VendorCmd\ 00000001\ ModeShift1\ " #define XML_END \ "\ \ EndJob\ 00000001\ " #define XML_OK "OK" enum mp150_state_t { state_idle, state_warmup, state_scanning, state_transfering, state_finished }; enum mp150_cmd_t { cmd_start_session = 0xdb20, cmd_select_source = 0xdd20, cmd_gamma = 0xee20, cmd_scan_param = 0xde20, cmd_status = 0xf320, cmd_abort_session = 0xef20, cmd_time = 0xeb80, cmd_read_image = 0xd420, cmd_error_info = 0xff20, cmd_scan_param_3 = 0xd820, cmd_scan_start_3 = 0xd920, cmd_status_3 = 0xda20, }; typedef struct mp150_t { enum mp150_state_t state; pixma_cmdbuf_t cb; uint8_t *imgbuf; uint8_t current_status[16]; unsigned last_block; uint8_t generation; /* for Generation 3 shift */ uint8_t *linebuf; uint8_t *data_left_ofs; unsigned data_left_len; uint8_t adf_state; /* handle adf scanning */ unsigned scale; /* Scale factor for lower resolutions, the * scanner doesn't support. We scale down the * image after scanning minimum possible * resolution. */ } mp150_t; /* STAT: 0x0606 = ok, 0x1515 = failed (PIXMA_ECANCELED), 0x1414 = busy (PIXMA_EBUSY) Transaction scheme 1. command_header/data | result_header 2. command_header | result_header/data 3. command_header | result_header/image_data - data has checksum in the last byte. - image_data has no checksum. - data and image_data begins in the same USB packet as command_header or result_header. command format #1: u16be cmd u8[6] 0 u8[4] 0 u32be PLEN parameter length u8[PLEN-1] parameter u8 parameter check sum result: u16be STAT u8 0 u8 0 or 0x21 if STAT == 0x1414 u8[4] 0 command format #2: u16be cmd u8[6] 0 u8[4] 0 u32be RLEN result length result: u16be STAT u8[6] 0 u8[RLEN-1] result u8 result check sum command format #3: (only used by read_image_block) u16be 0xd420 u8[6] 0 u8[4] 0 u32be max. block size + 8 result: u16be STAT u8[6] 0 u8 block info bitfield: 0x8 = end of scan, 0x10 = no more paper, 0x20 = no more data u8[3] 0 u32be ILEN image data size u8[ILEN] image data */ static void mp150_finish_scan (pixma_t * s); 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 int is_scanning_jpeg (pixma_t *s) { return s->param->mode_jpeg; } static int send_xml_dialog (pixma_t * s, const char * xml_message) { mp150_t *mp = (mp150_t *) s->subdriver; int datalen; datalen = pixma_cmd_transaction (s, xml_message, strlen (xml_message), mp->cb.buf, 1024); if (datalen < 0) return datalen; mp->cb.buf[datalen] = 0; PDBG (pixma_dbg (10, "XML message sent to scanner:\n%s\n", xml_message)); PDBG (pixma_dbg (10, "XML response back from scanner:\n%s\n", mp->cb.buf)); return (strcasestr ((const char *) mp->cb.buf, XML_OK) != NULL); } static int start_session (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; pixma_newcmd (&mp->cb, cmd_start_session, 0, 0); mp->cb.buf[3] = 0x00; return pixma_exec (s, &mp->cb); } static int start_scan_3 (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; pixma_newcmd (&mp->cb, cmd_scan_start_3, 0, 0); mp->cb.buf[3] = 0x00; return pixma_exec (s, &mp->cb); } static int is_calibrated (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; if (mp->generation >= 3) { return ((mp->current_status[0] & 0x01) == 1 || (mp->current_status[0] & 0x02) == 2); } if (mp->generation == 1) { return (mp->current_status[8] == 1); } else { return (mp->current_status[9] == 1); } } static int has_paper (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; if (is_scanning_from_adfdup (s)) return (mp->current_status[1] == 0 || mp->current_status[2] == 0); else return (mp->current_status[1] == 0); } static void drain_bulk_in (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; while (pixma_read (s->io, mp->imgbuf, IMAGE_BLOCK_SIZE) >= 0); } static int abort_session (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; mp->adf_state = state_idle; /* reset adf scanning */ return pixma_exec_short_cmd (s, &mp->cb, cmd_abort_session); } static int select_source (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; uint8_t *data; data = pixma_newcmd (&mp->cb, cmd_select_source, 12, 0); data[5] = ((mp->generation == 2) ? 1 : 0); switch (s->param->source) { case PIXMA_SOURCE_FLATBED: data[0] = 1; data[1] = 1; break; case PIXMA_SOURCE_ADF: data[0] = 2; data[5] = 1; data[6] = 1; break; case PIXMA_SOURCE_ADFDUP: data[0] = 2; data[5] = 3; data[6] = 3; break; default: return PIXMA_EPROTO; } return pixma_exec (s, &mp->cb); } static int send_gamma_table (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; const uint8_t *lut = s->param->gamma_table; uint8_t *data; if (mp->generation == 1) { data = pixma_newcmd (&mp->cb, cmd_gamma, 4096 + 8, 0); data[0] = (s->param->channels == 3) ? 0x10 : 0x01; pixma_set_be16 (0x1004, data + 2); if (lut) memcpy (data + 4, lut, 4096); else pixma_fill_gamma_table (DEFAULT_GAMMA, data + 4, 4096); } else { /* FIXME: Gamma table for 2nd generation: 1024 * uint16_le */ data = pixma_newcmd (&mp->cb, cmd_gamma, 2048 + 8, 0); data[0] = 0x10; pixma_set_be16 (0x0804, data + 2); if (lut) { int i; for (i = 0; i < 1024; i++) { int j = (i << 2) + (i >> 8); data[4 + 2 * i + 0] = lut[j]; data[4 + 2 * i + 1] = lut[j]; } } else { int i; pixma_fill_gamma_table (DEFAULT_GAMMA, data + 4, 2048); for (i = 0; i < 1024; i++) { int j = (i << 1) + (i >> 9); data[4 + 2 * i + 0] = data[4 + j]; data[4 + 2 * i + 1] = data[4 + j]; } } } return pixma_exec (s, &mp->cb); } static unsigned calc_raw_width (const mp150_t * mp, const pixma_scan_param_t * param) { unsigned raw_width; /* NOTE: Actually, we can send arbitary width to MP150. Lines returned are always padded to multiple of 4 or 12 pixels. Is this valid for other models, too? */ if (mp->generation >= 2) { raw_width = ALIGN_SUP ((param->w * mp->scale) + param->xs, 32); /* PDBG (pixma_dbg (4, "*calc_raw_width***** width %i extended by %i and rounded to %i *****\n", param->w, param->xs, raw_width)); */ } else if (param->channels == 1) { raw_width = ALIGN_SUP (param->w + param->xs, 12); } else { raw_width = ALIGN_SUP (param->w + param->xs, 4); } return raw_width; } static unsigned get_cis_line_size (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; /*PDBG (pixma_dbg (4, "%s: line_size=%ld, w=%d, wx=%d, scale=%d\n", __func__, s->param->line_size, s->param->w, s->param->wx, mp->scale));*/ return (s->param->wx ? s->param->line_size / s->param->w * s->param->wx : s->param->line_size) * mp->scale; } static int send_scan_param (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; uint8_t *data; unsigned xdpi = s->param->xdpi * mp->scale; unsigned ydpi = s->param->xdpi * mp->scale; unsigned x = s->param->x * mp->scale; unsigned xs = s->param->xs; unsigned y = s->param->y * mp->scale; unsigned wx = calc_raw_width (mp, s->param); unsigned h = MIN (s->param->h, s->cfg->height * s->param->ydpi / 75) * mp->scale; if (mp->generation <= 2) { PDBG (pixma_dbg (4, "*send_scan_param gen. 1-2 ***** Setting: xdpi=%hi ydpi=%hi x=%i y=%i wx=%i ***** \n", xdpi, ydpi, x-xs, y, wx)); data = pixma_newcmd (&mp->cb, cmd_scan_param, 0x30, 0); pixma_set_be16 (xdpi | 0x8000, data + 0x04); pixma_set_be16 (ydpi | 0x8000, data + 0x06); pixma_set_be32 (x, data + 0x08); if (mp->generation == 2) pixma_set_be32 (x - s->param->xs, data + 0x08); pixma_set_be32 (y, data + 0x0c); pixma_set_be32 (wx, data + 0x10); pixma_set_be32 (h, data + 0x14); data[0x18] = (s->param->channels != 1) ? 0x08 : 0x04; data[0x19] = ((s->param->software_lineart) ? 8 : s->param->depth) * s->param->channels; /* bits per pixel */ data[0x1a] = 0; data[0x20] = 0xff; data[0x23] = 0x81; data[0x26] = 0x02; data[0x27] = 0x01; } else { PDBG (pixma_dbg (4, "*send_scan_param gen. 3+ ***** Setting: xdpi=%hi ydpi=%hi x=%i xs=%i y=%i wx=%i h=%i ***** \n", xdpi, ydpi, x, xs, y, wx, h)); data = pixma_newcmd (&mp->cb, cmd_scan_param_3, 0x38, 0); data[0x00] = (is_scanning_from_adf (s)) ? 0x02 : 0x01; data[0x01] = 0x01; data[0x02] = 0x01; if (is_scanning_from_adfdup (s)) { data[0x02] = 0x03; data[0x03] = 0x03; } if (is_scanning_jpeg (s)) { data[0x03] = 0x01; } else { data[0x05] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ } pixma_set_be16 (xdpi | 0x8000, data + 0x08); pixma_set_be16 (ydpi | 0x8000, data + 0x0a); pixma_set_be32 (x - xs, data + 0x0c); pixma_set_be32 (y, data + 0x10); pixma_set_be32 (wx, data + 0x14); pixma_set_be32 (h, data + 0x18); data[0x1c] = (s->param->channels != 1) ? 0x08 : 0x04; data[0x1d] = ((s->param->software_lineart) ? 8 : s->param->depth) * s->param->channels; /* bits per pixel */ data[0x1f] = 0x01; /* This one also seen at 0. Don't know yet what's used for */ data[0x20] = 0xff; if (is_scanning_jpeg (s)) { data[0x21] = 0x83; } else { data[0x21] = 0x81; } data[0x23] = 0x02; data[0x24] = 0x01; switch (s->cfg->pid) { case MG5300_PID: /* unknown values (perhaps counter) for MG5300 series---values must be 0x30-0x39: decimal 0-9 */ data[0x26] = 0x32; /* using example values from a real scan here */ data[0x27] = 0x31; data[0x28] = 0x34; data[0x29] = 0x35; break; default: break; } data[0x30] = 0x01; } return pixma_exec (s, &mp->cb); } static int query_status_3 (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; uint8_t *data; int error, status_len; status_len = 8; data = pixma_newcmd (&mp->cb, cmd_status_3, 0, status_len); RET_IF_ERR (pixma_exec (s, &mp->cb)); memcpy (mp->current_status, data, status_len); return error; } static int query_status (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; uint8_t *data; int error, status_len; status_len = (mp->generation == 1) ? 12 : 16; data = pixma_newcmd (&mp->cb, cmd_status, 0, status_len); RET_IF_ERR (pixma_exec (s, &mp->cb)); memcpy (mp->current_status, data, status_len); PDBG (pixma_dbg (3, "Current status: paper=%u cal=%u lamp=%u busy=%u\n", data[1], data[8], data[7], data[9])); return error; } #if 0 static int send_time (pixma_t * s) { /* Why does a scanner need a time? */ time_t now; struct tm *t; uint8_t *data; mp150_t *mp = (mp150_t *) s->subdriver; data = pixma_newcmd (&mp->cb, cmd_time, 20, 0); pixma_get_time (&now, NULL); t = localtime (&now); strftime ((char *) data, 16, "%y/%m/%d %H:%M", t); 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) { uint8_t cmd[16]; mp150_t *mp = (mp150_t *) s->subdriver; const int hlen = 8 + 8; int error, datalen; memset (cmd, 0, sizeof (cmd)); pixma_set_be16 (cmd_read_image, cmd); if ((mp->last_block & 0x20) == 0) pixma_set_be32 ((IMAGE_BLOCK_SIZE / 65536) * 65536 + 8, cmd + 0xc); else pixma_set_be32 (32 + 8, cmd + 0xc); mp->state = state_transfering; mp->cb.reslen = pixma_cmd_transaction (s, cmd, sizeof (cmd), mp->cb.buf, 512); datalen = mp->cb.reslen; if (datalen < 0) return datalen; memcpy (header, mp->cb.buf, hlen); if (datalen >= hlen) { datalen -= hlen; memcpy (data, mp->cb.buf + hlen, datalen); data += datalen; if (mp->cb.reslen == 512) { error = pixma_read (s->io, data, IMAGE_BLOCK_SIZE - 512 + hlen); RET_IF_ERR (error); datalen += error; } } mp->state = state_scanning; mp->cb.expected_reslen = 0; RET_IF_ERR (pixma_check_result (&mp->cb)); if (mp->cb.reslen < hlen) return PIXMA_EPROTO; return datalen; } static int read_error_info (pixma_t * s, void *buf, unsigned size) { unsigned len = 16; mp150_t *mp = (mp150_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mp->cb, cmd_error_info, 0, len); RET_IF_ERR (pixma_exec (s, &mp->cb)); if (buf && len < size) { size = len; /* NOTE: I've absolutely no idea what the returned data mean. */ memcpy (buf, data, size); error = len; } return error; } /* handle_interrupt() waits until it receives an interrupt packet or times out. It calls send_time() and query_status() if necessary. Therefore, make sure that handle_interrupt() is only called from a safe context for send_time() and query_status(). Returns: 0 timed out 1 an interrupt packet received PIXMA_ECANCELED interrupted by signal <0 error */ static int handle_interrupt (pixma_t * s, int timeout) { uint8_t buf[64]; int len; len = pixma_wait_interrupt (s->io, buf, sizeof (buf), timeout); if (len == PIXMA_ETIMEDOUT) return 0; if (len < 0) return len; if (len%16) /* len must be a multiple of 16 bytes */ { PDBG (pixma_dbg (1, "WARNING:unexpected interrupt packet length %d\n", len)); return PIXMA_EPROTO; } /* s->event = 0x0brroott * b: button * oo: original * tt: target * rr: scan resolution * poll event with 'scanimage -A' */ if (s->cfg->pid == MG5300_PID || 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 == MB2300_PID || s->cfg->pid == MB5000_PID || s->cfg->pid == MB5400_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 * dpi in buf[12] 01=75; 02=150; 03=300; 04=600 * target = format; original = size; scan-resolution = dpi */ { if (buf[7] & 1) s->events = PIXMA_EV_BUTTON1 | buf[11] | buf[10]<<8 | buf[12]<<16; /* color scan */ if (buf[7] & 2) s->events = PIXMA_EV_BUTTON2 | buf[11] | buf[10]<<8 | buf[12]<<16; /* b/w scan */ } else if (s->cfg->pid == LIDE300_PID || s->cfg->pid == LIDE400_PID) /* unknown value in buf[4] * target in buf[0x13] * always set button-1 */ { if (buf[0x13]) s->events = PIXMA_EV_BUTTON1 | buf[0x13]; } else /* button no. in buf[0] * original in buf[0] * target in buf[1] */ { /* 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) s->events = PIXMA_EV_BUTTON2 | buf[1] | ((buf[0] & 0xf0) << 4); /* b/w scan */ if (buf[0] & 1) s->events = PIXMA_EV_BUTTON1 | buf[1] | ((buf[0] & 0xf0) << 4); /* color scan */ } return 1; } static int wait_until_ready (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; int error, tmo = 120; /* some scanners need a long timeout */ RET_IF_ERR ((mp->generation >= 3) ? query_status_3 (s) : query_status (s)); while (!is_calibrated (s)) { WAIT_INTERRUPT (1000); if (mp->generation >= 3) RET_IF_ERR (query_status_3 (s)); else if (s->cfg->pid == MP600_PID || s->cfg->pid == MP600R_PID) RET_IF_ERR (query_status (s)); if (--tmo == 0) { PDBG (pixma_dbg (1, "WARNING:Timed out in wait_until_ready()\n")); PDBG (query_status (s)); return PIXMA_ETIMEDOUT; } } return 0; } static void reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c, unsigned n, unsigned m, unsigned w, unsigned line_size) { unsigned i; for (i = 0; i < w; i++) { memcpy (linebuf + c * (n * (i % m) + i / m), sptr + c * i, c); } memcpy (sptr, linebuf, line_size); } /* the scanned image must be shrinked by factor "scale" * the image can be formatted as rgb (c=3) or gray (c=1) * we need to crop the left side (xs) * we ignore more pixels inside scanned line (wx), behind needed line (w) * * example (scale=2): * line | pixel[0] | pixel[1] | ... | pixel[w-1] * --------- * 0 | rgbrgb | rgbrgb | ... | rgbrgb * wx*c | rgbrgb | rgbrgb | ... | rgbrgb */ uint8_t * shrink_image (uint8_t * dptr, uint8_t * sptr, unsigned xs, unsigned w, unsigned wx, unsigned scale, unsigned c) { unsigned i, ic; uint16_t pixel; uint8_t *dst = dptr; /* don't change dptr */ uint8_t *src = sptr; /* don't change sptr */ /*PDBG (pixma_dbg (4, "%s: w=%d, wx=%d, c=%d, scale=%d\n", __func__, w, wx, c, scale)); PDBG (pixma_dbg (4, "\tdptr=%ld, sptr=%ld\n", dptr, sptr));*/ /* crop left side */ src += c * xs; /* process line */ for (i = 0; i < w; i++) { /* process rgb or gray pixel */ for (ic = 0; ic < c; ic++) { #if 0 dst[ic] = src[ic]; #else pixel = 0; /* sum shrink pixels */ for (unsigned m = 0; m < scale; m++) /* get pixels from shrinked lines */ { for (unsigned n = 0; n < scale; n++) /* get pixels from same line */ { pixel += src[ic + c * n + wx * c * m]; } } dst[ic] = pixel / (scale * scale); #endif } /* jump over shrinked data */ src += c * scale; /* next pixel */ dst += c; } return dst; } /* This function deals with Generation >= 3 high dpi images. * Each complete line in mp->imgbuf is processed for reordering pixels above * 600 dpi for Generation >= 3. */ static unsigned post_process_image_data (pixma_t * s, pixma_imagebuf_t * ib) { mp150_t *mp = (mp150_t *) s->subdriver; unsigned c, lines, line_size, n, m, cw, cx; uint8_t *sptr, *dptr, *gptr, *cptr; if (s->param->mode_jpeg) { /* No post-processing, send raw JPEG data to main */ ib->rptr = mp->imgbuf; ib->rend = mp->data_left_ofs; return 0; /* # of non processed bytes */ } /* process image sizes */ c = s->param->channels * ((s->param->software_lineart) ? 8 : s->param->depth) / 8; /* color channels count */ cw = c * s->param->w; /* image width */ cx = c * s->param->xs; /* x-offset */ /* special image format parameters * n: no. of sub-images * m: sub-image width */ if (mp->generation >= 3) n = s->param->xdpi / 600; else n = s->param->xdpi / 2400; if (s->cfg->pid == MP600_PID || s->cfg->pid == MP600R_PID) n = s->param->xdpi / 1200; m = (n > 0) ? s->param->wx / n : 1; /* Initialize pointers */ sptr = dptr = gptr = cptr = mp->imgbuf; /* walk through complete received lines */ line_size = get_cis_line_size (s); lines = (mp->data_left_ofs - mp->imgbuf) / line_size; if (lines > 0) { unsigned i; /*PDBG (pixma_dbg (4, "*post_process_image_data***** Processing with c=%u, n=%u, m=%u, wx=%i, line_size=%u, cx=%u, cw=%u ***** \n", c, n, m, s->param->wx, line_size, cx, cw));*/ /*PDBG (pixma_dbg (4, "*post_process_image_data***** lines = %i ***** \n", lines));*/ for (i = 0; i < lines; i++, sptr += line_size) { /*PDBG (pixma_dbg (4, "*post_process_image_data***** Processing with c=%u, n=%u, m=%u, w=%i, line_size=%u ***** \n", c, n, m, s->param->wx, line_size));*/ /*PDBG (pixma_dbg (4, "*post_process_image_data***** Pointers: sptr=%lx, dptr=%lx, linebuf=%lx ***** \n", sptr, dptr, mp->linebuf));*/ /* special image format for *most* devices at high dpi. * MP220, MX360 and generation 5 scanners are exceptions */ if (n > 1 && s->cfg->pid != MP220_PID && s->cfg->pid != MP490_PID && s->cfg->pid != MX360_PID && (mp->generation < 5 /* generation 5 scanners *with* special image format */ || s->cfg->pid == MG2200_PID || s->cfg->pid == MG3200_PID || s->cfg->pid == MG4200_PID || s->cfg->pid == MG5600_PID || s->cfg->pid == MG5700_PID || s->cfg->pid == MG6200_PID || s->cfg->pid == MP230_PID || s->cfg->pid == MX470_PID || s->cfg->pid == MX510_PID || s->cfg->pid == MX520_PID)) reorder_pixels (mp->linebuf, sptr, c, n, m, s->param->wx, line_size); /* scale image */ if (mp->scale > 1) { /* Crop line inside shrink_image() */ shrink_image(cptr, sptr, s->param->xs, s->param->w, s->param->wx, mp->scale, c); } else { /* Crop line to selected borders */ memmove(cptr, sptr + cx, cw); } /* Color / Gray to Lineart convert */ if (s->param->software_lineart) cptr = gptr = pixma_binarize_line (s->param, gptr, cptr, s->param->w, c); else cptr += cw; } } ib->rptr = mp->imgbuf; ib->rend = cptr; return mp->data_left_ofs - sptr; /* # of non processed bytes */ } static int mp150_open (pixma_t * s) { mp150_t *mp; uint8_t *buf; mp = (mp150_t *) calloc (1, sizeof (*mp)); if (!mp) return PIXMA_ENOMEM; buf = (uint8_t *) malloc (CMDBUF_SIZE + IMAGE_BLOCK_SIZE); if (!buf) { free (mp); return PIXMA_ENOMEM; } s->subdriver = mp; mp->state = state_idle; mp->cb.buf = buf; mp->cb.size = CMDBUF_SIZE; mp->cb.res_header_len = 8; mp->cb.cmd_header_len = 16; mp->cb.cmd_len_field_ofs = 14; mp->imgbuf = buf + CMDBUF_SIZE; /* General rules for setting Pixma protocol generation # */ mp->generation = (s->cfg->pid >= MP160_PID) ? 2 : 1; if (s->cfg->pid >= MX7600_PID) mp->generation = 3; if (s->cfg->pid >= MP250_PID) mp->generation = 4; if (s->cfg->pid >= MG2100_PID) /* this scanners generation doesn't need */ mp->generation = 5; /* special image conversion @ high dpi */ /* And exceptions to be added here */ if (s->cfg->pid == MP140_PID) mp->generation = 2; PDBG (pixma_dbg (3, "*mp150_open***** This is a generation %d scanner. *****\n", mp->generation)); /* adf scanning */ mp->adf_state = state_idle; if (mp->generation < 4) { query_status (s); handle_interrupt (s, 200); } return 0; } static void mp150_close (pixma_t * s) { mp150_t *mp = (mp150_t *) s->subdriver; mp150_finish_scan (s); free (mp->cb.buf); free (mp); s->subdriver = NULL; } static int mp150_check_param (pixma_t * s, pixma_scan_param_t * sp) { mp150_t *mp = (mp150_t *) s->subdriver; /* PDBG (pixma_dbg (4, "*mp150_check_param***** Initially: channels=%u, depth=%u, x=%u, y=%u, w=%u, h=%u, xs=%u, wx=%u *****\n", sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->h, sp->xs, sp->wx)); */ /* MP150 only supports 8 bit per channel in color and grayscale mode */ if (sp->depth != 1) { sp->software_lineart = 0; sp->depth = 8; } else { /* software lineart */ sp->software_lineart = 1; sp->depth = 1; sp->channels = 1; } /* for software lineart w must be a multiple of 8 */ if (sp->software_lineart == 1 && sp->w % 8) { unsigned w_max; sp->w += 8 - (sp->w % 8); /* do not exceed the scanner capability */ w_max = s->cfg->width * s->cfg->xdpi / 75; w_max -= w_max % 8; if (sp->w > w_max) sp->w = w_max; } if (mp->generation >= 2) { /* mod 32 and expansion of the X scan limits */ /*PDBG (pixma_dbg (4, "*mp150_check_param***** ----- Initially: x=%i, y=%i, w=%i, h=%i *****\n", sp->x, sp->y, sp->w, sp->h));*/ sp->xs = (sp->x * mp->scale) % 32; } else sp->xs = 0; /*PDBG (pixma_dbg (4, "*mp150_check_param***** Selected origin, origin shift: %i, %i *****\n", sp->x, sp->xs));*/ sp->wx = calc_raw_width (mp, sp); sp->line_size = sp->w * sp->channels * (((sp->software_lineart) ? 8 : sp->depth) / 8); /* bytes per line per color after cropping */ /*PDBG (pixma_dbg (4, "*mp150_check_param***** Final scan width and line-size: %i, %li *****\n", sp->wx, sp->line_size));*/ /* Some exceptions here for particular devices */ /* Those devices can scan up to legal 14" with ADF, but A4 11.7" in flatbed */ /* PIXMA_CAP_ADF also works for PIXMA_CAP_ADFDUP */ if ((s->cfg->cap & PIXMA_CAP_ADF) && sp->source == PIXMA_SOURCE_FLATBED) sp->h = MIN (sp->h, 877 * sp->xdpi / 75); if (sp->source == PIXMA_SOURCE_ADF || sp->source == PIXMA_SOURCE_ADFDUP) { uint8_t k = 1; /* ADF/ADF duplex mode: max scan res is 600 dpi, at least for generation 4+ */ if (mp->generation >= 4) k = sp->xdpi / MIN (sp->xdpi, 600); sp->x /= k; sp->xs /= k; sp->y /= k; sp->w /= k; sp->wx /= k; sp->h /= k; sp->xdpi /= k; sp->ydpi = sp->xdpi; } sp->mode_jpeg = (s->cfg->cap & PIXMA_CAP_ADF_JPEG) && (sp->source == PIXMA_SOURCE_ADF || sp->source == PIXMA_SOURCE_ADFDUP); mp->scale = 1; if (s->cfg->min_xdpi && sp->xdpi < s->cfg->min_xdpi) { mp->scale = s->cfg->min_xdpi / sp->xdpi; } /*PDBG (pixma_dbg (4, "*mp150_check_param***** xdpi=%u, min_xdpi=%u, scale=%u *****\n", sp->xdpi, s->cfg->min_xdpi, mp->scale));*/ /*PDBG (pixma_dbg (4, "*mp150_check_param***** Finally: channels=%u, depth=%u, x=%u, y=%u, w=%u, h=%u, xs=%u, wx=%u *****\n", sp->channels, sp->depth, sp->x, sp->y, sp->w, sp->h, sp->xs, sp->wx));*/ return 0; } static int mp150_scan (pixma_t * s) { int error = 0, tmo; mp150_t *mp = (mp150_t *) s->subdriver; if (mp->state != state_idle) return PIXMA_EBUSY; /* no paper inserted after first adf page => abort session */ if (s->param->adf_pageid && is_scanning_from_adf(s) && mp->adf_state == state_idle) { return PIXMA_ENO_PAPER; } /* Generation 4+: send XML dialog */ /* adf: first page or idle */ if (mp->generation >= 4 && mp->adf_state == state_idle) { if (!send_xml_dialog (s, XML_START_1)) return PIXMA_EPROTO; if (!send_xml_dialog (s, XML_START_2)) return PIXMA_EPROTO; } /* clear interrupt packets buffer */ while (handle_interrupt (s, 0) > 0) { } /* FIXME: Duplex ADF: check paper status only before odd pages (1,3,5,...). */ if (is_scanning_from_adf (s)) { if ((error = query_status (s)) < 0) return error; /* wait for inserted paper * timeout: 10 sec */ tmo = 10; while (!has_paper (s) && --tmo >= 0) { if ((error = query_status (s)) < 0) return error; WAIT_INTERRUPT (1000); PDBG (pixma_dbg (2, "No paper in ADF. Timed out in %d sec.\n", tmo)); } /* no paper inserted * => abort session */ if (!has_paper (s)) { PDBG (pixma_dbg (4, "*mp150_scan***** no paper in ADF *****\n")); error = abort_session (s); if (error < 0) return error; /* Generation 4+: send XML dialog */ /* adf: first page or idle */ if (mp->generation >= 4 && mp->adf_state == state_idle) { if (!send_xml_dialog (s, XML_END)) return PIXMA_EPROTO; } return PIXMA_ENO_PAPER; } } tmo = 10; /* adf: first page or idle */ if (mp->generation <= 2 || mp->adf_state == state_idle) { /* single sheet or first sheet from ADF */ PDBG (pixma_dbg (4, "*mp150_scan***** start scanning *****\n")); error = start_session (s); while (error == PIXMA_EBUSY && --tmo >= 0) { if (s->cancel) { error = PIXMA_ECANCELED; break; } PDBG (pixma_dbg (2, "Scanner is busy. Timed out in %d sec.\n", tmo + 1)); pixma_sleep (1000000); error = start_session (s); } if (error == PIXMA_EBUSY || error == PIXMA_ETIMEDOUT) { /* The scanner maybe hangs. We try to empty output buffer of the * scanner and issue the cancel command. */ PDBG (pixma_dbg (2, "Scanner hangs? Sending abort_session command.\n")); drain_bulk_in (s); abort_session (s); pixma_sleep (500000); error = start_session (s); } if ((error >= 0) || (mp->generation >= 3)) mp->state = state_warmup; if ((error >= 0) && (mp->generation <= 2)) error = select_source (s); if ((error >= 0) && !is_scanning_jpeg (s)) { int i; for (i = (mp->generation >= 3) ? 3 : 1 ; i > 0 && error >= 0; i--) error = send_gamma_table (s); } } else /* ADF pageid != 0 and gen3 or above */ { /* next sheet from ADF */ PDBG (pixma_dbg (4, "*mp150_scan***** scan next sheet from ADF *****\n")); pixma_sleep (1000000); } if ((error >= 0) || (mp->generation >= 3)) mp->state = state_warmup; if (error >= 0) error = send_scan_param (s); if ((error >= 0) && (mp->generation >= 3)) error = start_scan_3 (s); if (error < 0) { mp->last_block = 0x38; /* Force abort session if ADF scan */ mp150_finish_scan (s); return error; } /* ADF scanning active */ if (is_scanning_from_adf (s)) mp->adf_state = state_scanning; return 0; } static int mp150_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib) { int error; mp150_t *mp = (mp150_t *) s->subdriver; unsigned block_size, bytes_received, proc_buf_size, line_size; uint8_t header[16]; if (mp->state == state_warmup) { RET_IF_ERR (wait_until_ready (s)); pixma_sleep (1000000); /* No need to sleep, actually, but Window's driver * sleep 1.5 sec. */ mp->state = state_scanning; mp->last_block = 0; line_size = get_cis_line_size (s); proc_buf_size = 2 * line_size; mp->cb.buf = realloc (mp->cb.buf, CMDBUF_SIZE + IMAGE_BLOCK_SIZE + proc_buf_size); if (!mp->cb.buf) return PIXMA_ENOMEM; mp->linebuf = mp->cb.buf + CMDBUF_SIZE; mp->imgbuf = mp->data_left_ofs = mp->linebuf + line_size; mp->data_left_len = 0; } do { if (s->cancel) { PDBG (pixma_dbg (4, "*mp150_fill_buffer***** s->cancel *****\n")); return PIXMA_ECANCELED; } if ((mp->last_block & 0x28) == 0x28) { /* end of image */ PDBG (pixma_dbg (4, "*mp150_fill_buffer***** end of image *****\n")); mp->state = state_finished; return 0; } /*PDBG (pixma_dbg (4, "*mp150_fill_buffer***** moving %u bytes into buffer *****\n", mp->data_left_len));*/ memmove (mp->imgbuf, mp->data_left_ofs, mp->data_left_len); error = read_image_block (s, header, mp->imgbuf + mp->data_left_len); if (error < 0) { PDBG (pixma_dbg (4, "*mp150_fill_buffer***** scanner error (%d): end scan *****\n", error)); mp->last_block = 0x38; /* end scan in mp150_finish_scan() */ if (error == PIXMA_ECANCELED) { /* NOTE: I see this in traffic logs but I don't know its meaning. */ read_error_info (s, NULL, 0); } return error; } bytes_received = error; /*PDBG (pixma_dbg (4, "*mp150_fill_buffer***** %u bytes received by read_image_block *****\n", bytes_received));*/ block_size = pixma_get_be32 (header + 12); mp->last_block = header[8] & 0x38; if ((header[8] & ~0x38) != 0) { PDBG (pixma_dbg (1, "WARNING: Unexpected result header\n")); PDBG (pixma_hexdump (1, header, 16)); } PASSERT (bytes_received == block_size); if (block_size == 0) { /* no image data at this moment. */ pixma_sleep (10000); } /* Post-process the image data */ mp->data_left_ofs = mp->imgbuf + mp->data_left_len + bytes_received; mp->data_left_len = post_process_image_data (s, ib); mp->data_left_ofs -= mp->data_left_len; } while (ib->rend == ib->rptr); return ib->rend - ib->rptr; } static void mp150_finish_scan (pixma_t * s) { int error; mp150_t *mp = (mp150_t *) s->subdriver; switch (mp->state) { case state_transfering: drain_bulk_in (s); /* fall through */ case state_scanning: case state_warmup: case state_finished: /* FIXME: to process several pages ADF scan, must not send * abort_session and start_session between pages (last_block=0x28) */ if (mp->generation <= 2 || !is_scanning_from_adf (s) || mp->last_block == 0x38) { PDBG (pixma_dbg (4, "*mp150_finish_scan***** abort session *****\n")); error = abort_session (s); /* FIXME: it probably doesn't work in duplex mode! */ if (error < 0) PDBG (pixma_dbg (1, "WARNING:abort_session() failed %d\n", error)); /* Generation 4+: send XML end of scan dialog */ if (mp->generation >= 4) { if (!send_xml_dialog (s, XML_END)) PDBG (pixma_dbg (1, "WARNING:XML_END dialog failed \n")); } } else PDBG (pixma_dbg (4, "*mp150_finish_scan***** wait for next page from ADF *****\n")); mp->state = state_idle; /* fall through */ case state_idle: break; } } static void mp150_wait_event (pixma_t * s, int timeout) { /* FIXME: timeout is not correct. See usbGetCompleteUrbNoIntr() for * instance. */ while (s->events == 0 && handle_interrupt (s, timeout) > 0) { } } static int mp150_get_status (pixma_t * s, pixma_device_status_t * status) { int error; RET_IF_ERR (query_status (s)); status->hardware = PIXMA_HARDWARE_OK; status->adf = (has_paper (s)) ? PIXMA_ADF_OK : PIXMA_ADF_NO_PAPER; status->cal = (is_calibrated (s)) ? PIXMA_CALIBRATION_OK : PIXMA_CALIBRATION_OFF; return 0; } static const pixma_scan_ops_t pixma_mp150_ops = { mp150_open, mp150_close, mp150_scan, mp150_fill_buffer, mp150_finish_scan, mp150_wait_event, mp150_check_param, mp150_get_status }; #define DEVICE(name, model, pid, min_dpi, dpi, adftpu_min_dpi, adftpu_max_dpi, w, h, cap) { \ name, /* name */ \ model, /* model */ \ CANON_VID, pid, /* vid pid */ \ 0, /* iface */ \ &pixma_mp150_ops, /* ops */ \ min_dpi, /* min_xdpi */ \ dpi, 2*(dpi), /* xdpi, ydpi */ \ adftpu_min_dpi, adftpu_max_dpi, /* adftpu_min_dpi, adftpu_max_dpi */ \ 0, 0, /* tpuir_min_dpi & tpuir_max_dpi not used in this subdriver */ \ w, h, /* width, height */ \ PIXMA_CAP_EASY_RGB| \ PIXMA_CAP_GRAY| /* CIS with native grayscale */ \ PIXMA_CAP_LINEART| /* all scanners with software lineart */ \ PIXMA_CAP_GAMMA_TABLE|PIXMA_CAP_EVENTS|cap \ } #define END_OF_DEVICE_LIST DEVICE(NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0) const pixma_config_t pixma_mp150_devices[] = { /* Generation 1: CIS */ DEVICE ("Canon PIXMA MP150", "MP150", MP150_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP170", "MP170", MP170_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP450", "MP450", MP450_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP500", "MP500", MP500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP530", "MP530", MP530_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), /* Generation 2: CIS */ DEVICE ("Canon PIXMA MP140", "MP140", MP140_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP160", "MP160", MP160_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP180", "MP180", MP180_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP460", "MP460", MP460_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP510", "MP510", MP510_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP600", "MP600", MP600_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP600R", "MP600R", MP600R_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Generation 3: CIS */ DEVICE ("Canon PIXMA MP210", "MP210", MP210_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP220", "MP220", MP220_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP470", "MP470", MP470_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP520", "MP520", MP520_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP610", "MP610", MP610_PID, 0, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MX300", "MX300", MX300_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MX310", "MX310", MX310_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX700", "MX700", MX700_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX850", "MX850", MX850_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon PIXMA MX7600", "MX7600", MX7600_PID, 0, 4800, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon PIXMA MP630", "MP630", MP630_PID, 0, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP620", "MP620", MP620_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP540", "MP540", MP540_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP480", "MP480", MP480_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP240", "MP240", MP240_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP260", "MP260", MP260_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP190", "MP190", MP190_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), /* PIXMA 2009 vintage */ DEVICE ("Canon PIXMA MX320", "MX320", MX320_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX330", "MX330", MX330_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX860", "MX860", MX860_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), /* width and height adjusted to flatbed size 21.8 x 30.2 cm^2 respective * Not sure if anything's going wrong here, leaving as is DEVICE ("Canon PIXMA MX860", "MX860", MX860_PID, 0, 2400, 0, 0, 638, 880, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP),*/ /* PIXMA 2010 vintage */ DEVICE ("Canon PIXMA MX340", "MX340", MX340_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX350", "MX350", MX350_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX870", "MX870", MX870_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), /* PIXMA 2011 vintage */ DEVICE ("Canon PIXMA MX360", "MX360", MX360_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX410", "MX410", MX410_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX420", "MX420", MX420_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX880 Series", "MX880", MX880_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), /* Generation 4: CIS */ DEVICE ("Canon PIXMA MP640", "MP640", MP640_PID, 0, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP560", "MP560", MP560_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP550", "MP550", MP550_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP490", "MP490", MP490_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP250", "MP250", MP250_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP270", "MP270", MP270_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2010) Generation 4 CIS */ DEVICE ("Canon PIXMA MP280", "MP280", MP280_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), /* TODO: 1200dpi doesn't work yet */ DEVICE ("Canon PIXMA MP495", "MP495", MP495_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5100", "MG5100", MG5100_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5200", "MG5200", MG5200_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6100", "MG6100", MG6100_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2011) Generation 5 CIS */ DEVICE ("Canon PIXMA MG2100", "MG2100", MG2100_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG3100", "MG3100", MG3100_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG4100", "MG4100", MG4100_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5300", "MG5300", MG5300_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6200", "MG6200", MG6200_PID, 0, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MP493", "MP493", MP493_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E500", "E500", E500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2012) Generation 5 CIS */ DEVICE ("Canon PIXMA MX370 Series", "MX370", MX370_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX430 Series", "MX430", MX430_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX510 Series", "MX510", MX510_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX710 Series", "MX710", MX710_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon PIXMA MX890 Series", "MX890", MX890_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon PIXMA E600 Series", "E600", E600_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MG4200", "MG4200", MG4200_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2013) Generation 5 CIS */ DEVICE ("Canon PIXMA E510", "E510", E510_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E610", "E610", E610_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MP230", "MP230", MP230_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG2200 Series", "MG2200", MG2200_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG3200 Series", "MG3200", MG3200_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5400 Series", "MG5400", MG5400_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6300 Series", "MG6300", MG6300_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MX390 Series", "MX390", MX390_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX450 Series", "MX450", MX450_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX520 Series", "MX520", MX520_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX720 Series", "MX720", MX720_PID, 0, 2400, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon PIXMA MX920 Series", "MX920", MX920_PID, 0, 2400, 0, 600, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon PIXMA MG2400 Series", "MG2400", MG2400_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG2500 Series", "MG2500", MG2500_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG3500 Series", "MG3500", MG3500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5500 Series", "MG5500", MG5500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6400 Series", "MG6400", MG6400_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6500 Series", "MG6500", MG6500_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG7100 Series", "MG7100", MG7100_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2014) Generation 5 CIS */ DEVICE ("Canon PIXMA MX470 Series", "MX470", MX470_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MX530 Series", "MX530", MX530_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon MAXIFY MB5000 Series", "MB5000", MB5000_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon MAXIFY MB5300 Series", "MB5300", MB5300_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon MAXIFY MB2000 Series", "MB2000", MB2000_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon MAXIFY MB2100 Series", "MB2100", MB2100_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon MAXIFY MB2300 Series", "MB2300", MB2300_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon MAXIFY MB2700 Series", "MB2700", MB2700_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon PIXMA E400", "E400", E400_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E560", "E560", E560_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG7500 Series", "MG7500", MG7500_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6600 Series", "MG6600", MG6600_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5600 Series", "MG5600", MG5600_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG2900 Series", "MG2900", MG2900_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E460 Series", "E460", E460_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2015) Generation 5 CIS */ DEVICE ("Canon PIXMA MX490 Series", "MX490", MX490_PID, 0, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA E480 Series", "E480", E480_PID, 0, 600, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA MG3600 Series", "MG3600", MG3600_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG7700 Series", "MG7700", MG7700_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6900 Series", "MG6900", MG6900_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG6800 Series", "MG6800", MG6800_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG5700 Series", "MG5700", MG5700_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2016) Generation 5 CIS */ DEVICE ("Canon PIXMA G3000", "G3000", G3000_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA G2000", "G2000", G2000_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS9000 Series", "TS9000", TS9000_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS8000 Series", "TS8000", TS8000_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6000 Series", "TS6000", TS6000_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS5000 Series", "TS5000", TS5000_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA MG3000 Series", "MG3000", MG3000_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E470 Series", "E470", E470_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E410 Series", "E410", E410_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2017) Generation 5 CIS */ DEVICE ("Canon PIXMA G4000", "G4000", G4000_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6100 Series", "TS6100", TS6100_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS5100 Series", "TS5100", TS5100_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS3100 Series", "TS3100", TS3100_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E3100 Series", "E3100", E3100_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2018) Generation 5 CIS */ DEVICE ("Canon MAXIFY MB5400 Series", "MB5400", MB5400_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP | PIXMA_CAP_ADF_JPEG), DEVICE ("Canon MAXIFY MB5100 Series", "MB5100", MB5100_PID, 0, 1200, 0, 0, 638, 1050, PIXMA_CAP_CIS | PIXMA_CAP_ADFDUP), DEVICE ("Canon PIXMA TS9100 Series", "TS9100", TS9100_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TR8500 Series", "TR8500", TR8500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA TR7500 Series", "TR7500", TR7500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA TS9500 Series", "TS9500", TS9500_PID, 0, 1200, 0, 600, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("CanoScan LiDE 400", "LIDE400", LIDE400_PID, 300, 4800, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("CanoScan LiDE 300", "LIDE300", LIDE300_PID, 300, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), /* Latest devices (2019) Generation 5 CIS */ DEVICE ("Canon PIXMA TS8100 Series", "TS8100", TS8100_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA G2010 Series", "G2010", G2010_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA G3010 Series", "G3010", G3010_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA G4010 Series", "G4010", G4010_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA TS9180 Series", "TS9180", TS9180_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS8180 Series", "TS8180", TS8180_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6180 Series", "TS6180", TS6180_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TR8580 Series", "TR8580", TR8580_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA TS8130 Series", "TS8130", TS8130_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6130 Series", "TS6130", TS6130_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TR8530 Series", "TR8530", TR8530_PID, 0, 2400, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA TR7530 Series", "TR7530", TR7530_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXUS XK50 Series", "XK50", XK50_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXUS XK70 Series", "XK70", XK70_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TR4500 Series", "TR4500", TR4500_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA E4200 Series", "E4200", E4200_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA TS6200 Series", "TS6200", TS6200_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6280 Series", "TS6280", TS6280_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6230 Series", "TS6230", TS6230_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS8200 Series", "TS8200", TS8200_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS8280 Series", "TS8280", TS8280_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS8230 Series", "TS8230", TS8230_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS9580 Series", "TS9580", TS9580_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA TR9530 Series", "TR9530", TR9530_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS | PIXMA_CAP_ADF), DEVICE ("Canon PIXMA G6000 Series", "G6000", G6000_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA G6080 Series", "G6080", G6080_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXUS XK80 Series", "XK80", XK80_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS5300 Series", "TS5300", TS5300_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS5380 Series", "TS5380", TS5380_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6300 Series", "TS6300", TS6300_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6380 Series", "TS6380", TS6380_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS7330 Series", "TS7330", TS7330_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS8380 Series", "TS8380", TS8380_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS8330 Series", "TS8330", TS8330_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA XK60 Series", "XK60", XK60_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS6330 Series", "TS6330", TS6330_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA TS3300 Series", "TS3300", TS3300_PID, 0, 1200, 0, 0, 638, 877, PIXMA_CAP_CIS), DEVICE ("Canon PIXMA E3300 Series", "E3300", E3300_PID, 0, 600, 0, 0, 638, 877, PIXMA_CAP_CIS), END_OF_DEVICE_LIST }; sane-backends-1.0.29/backend/pixma/pixma_io.h0000666000000000000000000001472513615534521015675 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef PIXMA_IO_H #define PIXMA_IO_H /* TODO: move to pixma_common.h, to reduce the number of files */ /*! * \defgroup IO IO interface * \brief The IO interface. * * Return value of functions that return \c int if not otherwise specified: * - >= if succeeded * - < 0 if failed (e.g. \c PIXMA_ETIMEDOUT) * . * @{ */ /** Timeout for pixma_read() in milliseconds */ #define PIXMA_BULKIN_TIMEOUT 1000 /** Timeout for pixma_write() in milliseconds */ #define PIXMA_BULKOUT_TIMEOUT 1000 struct pixma_io_t; struct pixma_config_t; /** IO handle */ typedef struct pixma_io_t pixma_io_t; /** Initialize IO module. It must be called before any other functions in this * module. * \return 0 on success or * - \c PIXMA_ENOMEM * - \c PIXMA_EACCES * - \c PIXMA_EIO */ int pixma_io_init (void); /** Shutdown all connections and free resources allocated in this module. */ void pixma_io_cleanup (void); /** Find devices currently connected to the computer. * \c devnr passed to functions * - pixma_get_device_config() * - pixma_get_device_id() * - pixma_connect() * . * should be less than the number of devices returned by this function. * \param[in] pixma_devices A \c NULL terminated array of pointers to * array of pixma_config_t which is terminated by setting * pixma_config_t::name to \c NULL. * \return Number of devices found */ unsigned pixma_collect_devices (const char ** conf_devices, const struct pixma_config_t *const pixma_devices[], SANE_Bool local_only); /** Get device configuration. */ const struct pixma_config_t *pixma_get_device_config (unsigned devnr); /** Get a unique ID of the device \a devnr. */ const char *pixma_get_device_id (unsigned devnr); /** Connect to the device and claim the scanner interface. * \param[in] devnr * \param[out] handle * \return 0 on success or * - \c PIXMA_ENODEV the device is gone from the system. * - \c PIXMA_EINVAL \a devnr is invalid. * - \c PIXMA_EBUSY * - \c PIXMA_EACCES * - \c PIXMA_ENOMEM * - \c PIXMA_EIO */ int pixma_connect (unsigned devnr, pixma_io_t ** handle); /** Release the scanner interface and disconnect from the device. */ void pixma_disconnect (pixma_io_t *); /** Activate connection to scanner */ int pixma_activate (pixma_io_t *); /** De-activate connection to scanner */ int pixma_deactivate (pixma_io_t *); /** Reset the USB interface. \warning Use with care! */ int pixma_reset_device (pixma_io_t *); /** Write data to the device. This function may not be interrupted by signals. * It will return iff * - \a len bytes have been successfully written or * - an error (inclusive timeout) occured. * . * \note Calling pixma_write(io, buf, n1) and pixma(io, buf+n1, n2) may * not be the same as pixma_write(io, buf, n1+n2) if n1 is not * multiple of the maximum packet size of the endpoint. * \param[in] cmd Data * \param[in] len Length of data * \return Number of bytes successfully written (always = \a len) or * - \c PIXMA_ETIMEDOUT * - \c PIXMA_EIO * - \c PIXMA_ENOMEM * \see #PIXMA_BULKOUT_TIMEOUT */ int pixma_write (pixma_io_t *, const void *cmd, unsigned len); /** Read data from the device. This function may not be interrupted by signals. * It will return iff * - \a size bytes have been successfully read, * - a short packet has been read or * - an error (inclusive timeout) occured. * . * \param[out] buf * \param[in] size of the buffer * \return Number of bytes successfully read. A return value of zero means that * a zero length USB packet was received. Or * - \c PIXMA_ETIMEDOUT * - \c PIXMA_EIO * - \c PIXMA_ENOMEM * \see #PIXMA_BULKIN_TIMEOUT */ int pixma_read (pixma_io_t *, void *buf, unsigned size); /** Wait for an interrupt. This function can be interrupted by signals. * \a size should be less than or equal to the maximum packet size. * \param[out] buf * \param[in] size of the buffer * \param[in] timeout in milliseconds; if < 0, wait forever. * \return Number of bytes successfully read or * - \c PIXMA_ETIMEDOUT * - \c PIXMA_EIO * - \c PIXMA_ENOMEM * - \c PIXMA_ECANCELED if it was interrupted by a signal. */ int pixma_wait_interrupt (pixma_io_t *, void *buf, unsigned size, int timeout); /** Enable or disable background interrupt monitoring. * Background mode is enabled by default. * \param[in] background if not zero, a URB is submitted in background * for interrupt endpoint. * \return 0 on success or * - \c PIXMA_ENOTSUP * - \c PIXMA_EIO * - \c PIXMA_ENOMEM */ int pixma_set_interrupt_mode (pixma_io_t *, int background); /** @} end of IO group */ #endif sane-backends-1.0.29/backend/pixma/pixma_imageclass.c0000666000000000000000000007727713615534521017404 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2007-2009 Nicolas Martin, Copyright (C) 2008 Dennis Lou, dlou 99 at yahoo dot com 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* * imageCLASS backend based on pixma_mp730.c */ #include "../include/sane/config.h" #include #include #include #include "pixma_rename.h" #include "pixma_common.h" #include "pixma_io.h" #ifdef __GNUC__ # define UNUSED(v) (void) v #else # define UNUSED(v) #endif #define IMAGE_BLOCK_SIZE (0x80000) #define MAX_CHUNK_SIZE (0x1000) #define MIN_CHUNK_SIZE (0x0200) #define CMDBUF_SIZE 512 #define MF4100_PID 0x26a3 #define MF4600_PID 0x26b0 #define MF4010_PID 0x26b4 #define MF4200_PID 0x26b5 #define MF4360_PID 0x26ec #define D480_PID 0x26ed #define MF4320_PID 0x26ee #define D420_PID 0x26ef #define MF3200_PID 0x2684 #define MF6500_PID 0x2686 /* generation 2 scanners (>=0x2707) */ #define MF8300_PID 0x2708 #define MF4500_PID 0x2736 #define MF4410_PID 0x2737 #define D550_PID 0x2738 #define MF3010_PID 0x2759 #define MF4570_PID 0x275a #define MF4800_PID 0x2773 #define MF4700_PID 0x2774 #define MF8200_PID 0x2779 /* the following are all untested */ #define MF5630_PID 0x264e #define MF5650_PID 0x264f #define MF8100_PID 0x2659 #define MF5880_PID 0x26f9 #define MF6680_PID 0x26fa #define MF8030_PID 0x2707 #define IR1133_PID 0x2742 #define MF5900_PID 0x2743 #define D530_PID 0x2775 #define MF8500_PID 0x277a #define MF6100_PID 0x278e #define MF820_PID 0x27a6 #define MF220_PID 0x27a8 #define MF210_PID 0x27a9 #define MF620_PID 0x27b4 #define MF410_PID 0x27c0 #define MF510_PID 0x27c2 #define MF230_PID 0x27d1 #define MF240_PID 0x27d2 #define MF630_PID 0x27e1 #define MF634_PID 0x27e2 #define MF730_PID 0x27e4 #define MF731_PID 0x27e5 #define D570_PID 0x27e8 #define MF110_PID 0x27ed #define MF520_PID 0x27f0 #define MF420_PID 0x27f1 #define MF260_PID 0x27f4 #define MF740_PID 0x27fb #define MF743_PID 0x27fc #define MF640_PID 0x27fe #define MF645_PID 0x27fd enum iclass_state_t { state_idle, state_warmup, /* MF4200 always warm/calibrated; others? */ state_scanning, state_finished }; enum iclass_cmd_t { cmd_start_session = 0xdb20, cmd_select_source = 0xdd20, cmd_scan_param = 0xde20, cmd_status = 0xf320, cmd_abort_session = 0xef20, cmd_read_image = 0xd420, cmd_read_image2 = 0xd460, /* New multifunctionals, such as MF4410 */ cmd_error_info = 0xff20, cmd_activate = 0xcf60 }; typedef struct iclass_t { enum iclass_state_t state; pixma_cmdbuf_t cb; unsigned raw_width; uint8_t current_status[12]; uint8_t *buf, *blkptr, *lineptr; unsigned buf_len, blk_len; 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 */ static int iclass_exec (pixma_t * s, pixma_cmdbuf_t * cb, char invcksum) { if (cb->cmdlen > cb->cmd_header_len) pixma_fill_checksum (cb->buf + cb->cmd_header_len, cb->buf + cb->cmdlen - 2); cb->buf[cb->cmdlen - 1] = invcksum ? -cb->buf[cb->cmdlen - 2] : 0; cb->reslen = pixma_cmd_transaction (s, cb->buf, cb->cmdlen, cb->buf, cb->expected_reslen); return pixma_check_result (cb); } 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 */ || mf->current_status[1] == 81); /* allow 0x51 as ADF paper OK */ } static int abort_session (pixma_t * s) { iclass_t *mf = (iclass_t *) s->subdriver; return pixma_exec_short_cmd (s, &mf->cb, cmd_abort_session); } static int query_status (pixma_t * s) { iclass_t *mf = (iclass_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mf->cb, cmd_status, 0, 12); error = pixma_exec (s, &mf->cb); if (error >= 0) { memcpy (mf->current_status, data, 12); /*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; } static int activate (pixma_t * s, uint8_t x) { iclass_t *mf = (iclass_t *) s->subdriver; uint8_t *data = pixma_newcmd (&mf->cb, cmd_activate, 10, 0); data[0] = 1; data[3] = x; switch (s->cfg->pid) { case MF4200_PID: case MF4600_PID: case MF6500_PID: case D480_PID: case D420_PID: case MF4360_PID: case MF4100_PID: case MF8300_PID: return iclass_exec (s, &mf->cb, 1); break; default: return pixma_exec (s, &mf->cb); } } static int start_session (pixma_t * s) { iclass_t *mf = (iclass_t *) s->subdriver; return pixma_exec_short_cmd (s, &mf->cb, cmd_start_session); } static int 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] = (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: case MF4600_PID: case MF6500_PID: case D480_PID: case D420_PID: case MF4360_PID: case MF4100_PID: case MF8300_PID: return iclass_exec (s, &mf->cb, 0); break; default: return pixma_exec (s, &mf->cb); } } static int send_scan_param (pixma_t * s) { iclass_t *mf = (iclass_t *) s->subdriver; uint8_t *data; data = pixma_newcmd (&mf->cb, cmd_scan_param, 0x2e, 0); pixma_set_be16 (s->param->xdpi | 0x1000, data + 0x04); pixma_set_be16 (s->param->ydpi | 0x1000, data + 0x06); pixma_set_be32 (s->param->x, data + 0x08); pixma_set_be32 (s->param->y, data + 0x0c); 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 == 1) ? 8 : s->param->depth); /* bits per pixel */ data[0x1f] = 0x7f; data[0x20] = 0xff; data[0x23] = 0x81; switch (s->cfg->pid) { case MF4200_PID: case MF4600_PID: case MF6500_PID: case D480_PID: case D420_PID: case MF4360_PID: case MF4100_PID: case MF8300_PID: return iclass_exec (s, &mf->cb, 0); break; default: return pixma_exec (s, &mf->cb); } } static int request_image_block (pixma_t * s, unsigned flag, uint8_t * info, unsigned * size, uint8_t * data, unsigned * datalen) { iclass_t *mf = (iclass_t *) s->subdriver; int error; unsigned expected_len; const int hlen = 2 + 6; memset (mf->cb.buf, 0, 11); /* 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 || s->cfg->pid == MF4600_PID || s->cfg->pid == MF6500_PID || s->cfg->pid == MF8030_PID) ? 512 : hlen; mf->cb.reslen = pixma_cmd_transaction (s, mf->cb.buf, 11, mf->cb.buf, expected_len); if (mf->cb.reslen >= hlen) { *info = mf->cb.buf[2]; *size = pixma_get_be16 (mf->cb.buf + 6); /* 16bit size */ error = 0; if (mf->generation >= 2 || s->cfg->pid == MF4600_PID || s->cfg->pid == MF6500_PID || s->cfg->pid == MF8030_PID) { /* 32bit size */ *datalen = mf->cb.reslen - hlen; *size = (*datalen + hlen == 512) ? pixma_get_be32 (mf->cb.buf + 4) - *datalen : *size; memcpy (data, mf->cb.buf + hlen, *datalen); } PDBG (pixma_dbg (11, "*request_image_block***** size = %u *****\n", *size)); } else { error = PIXMA_EPROTO; } return error; } static int read_image_block (pixma_t * s, uint8_t * data, unsigned size) { iclass_t *mf = (iclass_t *) s->subdriver; int error; unsigned maxchunksize, chunksize, count = 0; maxchunksize = MAX_CHUNK_SIZE * ((mf->generation >= 2 || s->cfg->pid == MF4600_PID || s->cfg->pid == MF6500_PID || s->cfg->pid == MF8030_PID) ? 4 : 1); while (size) { if (size >= maxchunksize) chunksize = maxchunksize; else if (size < MIN_CHUNK_SIZE) chunksize = size; else chunksize = size - (size % MIN_CHUNK_SIZE); error = pixma_read (s->io, data, chunksize); if (error < 0) return count; count += error; data += error; size -= error; } return count; } static int read_error_info (pixma_t * s, void *buf, unsigned size) { unsigned len = 16; iclass_t *mf = (iclass_t *) s->subdriver; uint8_t *data; int error; data = pixma_newcmd (&mf->cb, cmd_error_info, 0, len); switch (s->cfg->pid) { case MF4200_PID: case MF4600_PID: case MF6500_PID: case D480_PID: case D420_PID: case MF4360_PID: case MF4100_PID: case MF8300_PID: error = iclass_exec (s, &mf->cb, 0); break; default: error = pixma_exec (s, &mf->cb); } if (error < 0) return error; if (buf && len < size) { size = len; /* NOTE: I've absolutely no idea what the returned data mean. */ memcpy (buf, data, size); error = len; } return error; } static int handle_interrupt (pixma_t * s, int timeout) { uint8_t buf[16]; int len; len = pixma_wait_interrupt (s->io, buf, sizeof (buf), timeout); if (len == PIXMA_ETIMEDOUT) return 0; if (len < 0) return len; if (len != 16) { PDBG (pixma_dbg (1, "WARNING:unexpected interrupt packet length %d\n", len)); return PIXMA_EPROTO; } if (buf[12] & 0x40) query_status (s); if (buf[15] & 1) s->events = PIXMA_EV_BUTTON1; return 1; } 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; /* 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) { if (error >= 0) error = activate (s, 0); if (error >= 0) error = activate (s, 4); } return error; } /* line in=rrr... ggg... bbb... line out=rgbrgbrgb... */ static void pack_rgb (const uint8_t * src, unsigned nlines, unsigned w, uint8_t * dst) { unsigned w2, stride; w2 = 2 * w; stride = 3 * w; for (; nlines != 0; nlines--) { unsigned x; for (x = 0; x != w; x++) { *dst++ = src[x + 0]; *dst++ = src[x + w]; *dst++ = src[x + w2]; } src += stride; } } static int iclass_open (pixma_t * s) { iclass_t *mf; uint8_t *buf; mf = (iclass_t *) calloc (1, sizeof (*mf)); if (!mf) return PIXMA_ENOMEM; buf = (uint8_t *) malloc (CMDBUF_SIZE); if (!buf) { free (mf); return PIXMA_ENOMEM; } s->subdriver = mf; mf->state = state_idle; mf->cb.buf = buf; mf->cb.size = CMDBUF_SIZE; mf->cb.res_header_len = 2; 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)); PDBG (pixma_dbg (3, "Trying to clear the interrupt buffer...\n")); if (handle_interrupt (s, 200) == 0) { PDBG (pixma_dbg (3, " no packets in buffer\n")); } return 0; } static void iclass_close (pixma_t * s) { iclass_t *mf = (iclass_t *) s->subdriver; iclass_finish_scan (s); free (mf->cb.buf); free (mf->buf); free (mf); s->subdriver = NULL; } static int 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->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 */ /* PIXMA_CAP_ADF also works for PIXMA_CAP_ADFDUP */ 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; } static int iclass_scan (pixma_t * s) { int error, n; iclass_t *mf = (iclass_t *) s->subdriver; uint8_t *buf, ignore; unsigned buf_len, ignore2; if (mf->state != state_idle) return PIXMA_EBUSY; /* clear interrupt packets buffer */ while (handle_interrupt (s, 0) > 0) { } mf->raw_width = ALIGN_SUP (s->param->w, 32); PDBG (pixma_dbg (3, "raw_width = %u\n", mf->raw_width)); n = IMAGE_BLOCK_SIZE / s->param->line_size + 1; buf_len = (n + 1) * s->param->line_size + IMAGE_BLOCK_SIZE; if (buf_len > mf->buf_len) { buf = (uint8_t *) realloc (mf->buf, buf_len); if (!buf) return PIXMA_ENOMEM; mf->buf = buf; mf->buf_len = buf_len; } mf->lineptr = mf->buf; mf->blkptr = mf->buf + n * s->param->line_size; mf->blk_len = 0; error = step1 (s); 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); if (error >= 0) mf->state = state_scanning; if (error >= 0) error = select_source (s); } else if (error >= 0) { /* next sheet from ADF */ PDBG (pixma_dbg (3, "*iclass_scan***** scan next sheet from ADF *****\n")); mf->state = state_scanning; } if (error >= 0) error = send_scan_param (s); if (error >= 0) error = request_image_block (s, 0, &ignore, &ignore2, &ignore, &ignore2); if (error < 0) { iclass_finish_scan (s); return error; } mf->last_block = 0; /* ADF scanning active */ if (is_scanning_from_adf (s)) mf->adf_state = state_scanning; return 0; } static int 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, lineart_lines_size, first_block_size; uint8_t info; /* * 1. send a block request cmd (d4 20 00... 04 00 06) * 2. examine the response for block size and/or end-of-scan flag * 3. read the block one chunk at a time * 4. repeat until have enough to process >=1 lines */ do { do { if (s->cancel) return PIXMA_ECANCELED; if (mf->last_block) { /* end of image */ mf->state = state_finished; return 0; } first_block_size = 0; error = request_image_block (s, 4, &info, &block_size, mf->blkptr + mf->blk_len, &first_block_size); /* add current block to remainder of previous */ mf->blk_len += first_block_size; if (error < 0) { /* NOTE: seen in traffic logs but don't know the meaning. */ read_error_info (s, NULL, 0); if (error == PIXMA_ECANCELED) return error; } /* info: 0x28 = end; 0x38 = end + ADF empty */ mf->last_block = info & 0x38; if ((info & ~0x38) != 0) { PDBG (pixma_dbg (1, "WARNING: Unexpected result header\n")); PDBG (pixma_hexdump (1, &info, 1)); } if (block_size == 0) { /* no image data at this moment. */ /*pixma_sleep(100000); *//* FIXME: too short, too long? */ handle_interrupt (s, 100); } } while (block_size == 0 && first_block_size == 0); error = read_image_block (s, mf->blkptr + mf->blk_len, block_size); block_size = error; if (error < 0) return error; /* 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->mode == PIXMA_SCAN_MODE_LINEART) ? mf->raw_width : s->param->line_size); if (n != 0) { /* 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 && s->cfg->pid != MF8030_PID) { /* color and not MF46xx or MF65xx */ pack_rgb (mf->blkptr, n, mf->raw_width, mf->lineptr); } else { /* grayscale */ memcpy (mf->lineptr, mf->blkptr, 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 * ib->rptr : start of image buffer * ib->rend : end of image buffer */ ib->rptr = mf->lineptr; 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; } static void iclass_finish_scan (pixma_t * s) { int error; iclass_t *mf = (iclass_t *) s->subdriver; switch (mf->state) { /* fall through */ case state_warmup: case state_scanning: error = abort_session (s); if (error < 0) PDBG (pixma_dbg (1, "WARNING:abort_session() failed %s\n", pixma_strerror (error))); /* fall through */ case state_finished: query_status (s); query_status (s); if (mf->generation == 1) { /* activate only seen for generation 1 scanners */ activate (s, 0); query_status (s); } /* generation = 1: * 0x28 = last block (no multi page scan) * generation >= 2: * 0x38 = last block and ADF empty (generation >= 2) * 0x28 = last block and Paper in ADF (multi page scan) * some generation 2 scanners don't use 0x38 for ADF empty => check status */ if (mf->last_block==0x38 /* generation 2 scanner ADF empty */ || (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")); mf->state = state_idle; /* fall through */ case state_idle: break; } } static void iclass_wait_event (pixma_t * s, int timeout) { /* FIXME: timeout is not correct. See usbGetCompleteUrbNoIntr() for * instance. */ while (s->events == 0 && handle_interrupt (s, timeout) > 0) { } } static int iclass_get_status (pixma_t * s, pixma_device_status_t * status) { int error; error = query_status (s); if (error < 0) return error; status->hardware = PIXMA_HARDWARE_OK; status->adf = (has_paper (s)) ? PIXMA_ADF_OK : PIXMA_ADF_NO_PAPER; return 0; } static const pixma_scan_ops_t pixma_iclass_ops = { iclass_open, iclass_close, iclass_scan, iclass_fill_buffer, iclass_finish_scan, iclass_wait_event, iclass_check_param, iclass_get_status }; #define DEV(name, model, pid, dpi, adftpu_max_dpi, w, h, cap) { \ name, /* name */ \ model, /* model */ \ 0x04a9, pid, /* vid pid */ \ 1, /* iface */ \ &pixma_iclass_ops, /* ops */ \ 0, /* min_xdpi not used in this subdriver */ \ dpi, dpi, /* xdpi, ydpi */ \ 0, /* adftpu_min_dpi not used in this subdriver */ \ 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[] = { DEV ("Canon imageCLASS MF4270", "MF4270", MF4200_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon imageCLASS MF4150", "MF4100", MF4100_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon imageCLASS MF4690", "MF4690", MF4600_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon imageCLASS D420", "D420", D420_PID, 600, 0, 640, 877, PIXMA_CAP_ADFDUP), DEV ("Canon imageCLASS D480", "D480", D480_PID, 600, 0, 640, 877, PIXMA_CAP_ADFDUP), DEV ("Canon imageCLASS MF4360", "MF4360", MF4360_PID, 600, 0, 640, 877, PIXMA_CAP_ADFDUP), DEV ("Canon imageCLASS MF4320", "MF4320", MF4320_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon imageCLASS MF4010", "MF4010", MF4010_PID, 600, 0, 640, 877, 0), DEV ("Canon imageCLASS MF3240", "MF3240", MF3200_PID, 600, 0, 640, 877, 0), DEV ("Canon imageClass MF6500", "MF6500", MF6500_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon imageCLASS MF4410", "MF4410", MF4410_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon imageCLASS D550", "D550", D550_PID, 600, 0, 640, 1050, PIXMA_CAP_ADF), DEV ("Canon i-SENSYS MF4500 Series", "MF4500", MF4500_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon i-SENSYS MF3010", "MF3010", MF3010_PID, 600, 0, 640, 877, 0), DEV ("Canon i-SENSYS MF4700 Series", "MF4700", MF4700_PID, 600, 0, 640, 1050, PIXMA_CAP_ADF), DEV ("Canon i-SENSYS MF4800 Series", "MF4800", MF4800_PID, 600, 0, 640, 1050, PIXMA_CAP_ADF), DEV ("Canon imageCLASS MF4570dw", "MF4570dw", MF4570_PID, 600, 0, 640, 877, 0), DEV ("Canon i-SENSYS MF8200C Series", "MF8200C", MF8200_PID, 600, 300, 640, 1050, PIXMA_CAP_ADF), DEV ("Canon i-SENSYS MF8300 Series", "MF8300", MF8300_PID, 600, 0, 640, 1050, PIXMA_CAP_ADF), DEV ("Canon imageCLASS D530", "D530", D530_PID, 600, 0, 640, 877, 0), /* FIXME: the following capabilities all need updating/verifying */ DEV ("Canon imageCLASS MF5630", "MF5630", MF5630_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon laserBase MF5650", "MF5650", MF5650_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon imageCLASS MF8170c", "MF8170c", MF8100_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon imageClass MF8030", "MF8030", MF8030_PID, 600, 0, 640, 877, PIXMA_CAP_ADF), DEV ("Canon i-SENSYS MF5880dn", "MF5880", MF5880_PID, 600, 0, 640, 877, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF6680dn", "MF6680", MF6680_PID, 600, 0, 640, 877, PIXMA_CAP_ADFDUP), DEV ("Canon imageRUNNER 1133", "iR1133", IR1133_PID, 600, 0, 637, 877, PIXMA_CAP_ADFDUP), /* max. w = 216mm */ 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, 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, 637, 1050, PIXMA_CAP_ADFDUP), /* max. w = 216mm */ DEV ("Canon i-SENSYS MF210 Series", "MF210", MF210_PID, 600, 0, 637, 1050, PIXMA_CAP_ADF), /* max. w = 216mm */ DEV ("Canon i-SENSYS MF620 Series", "MF620", MF620_PID, 600, 0, 637, 1050, PIXMA_CAP_ADF), DEV ("Canon i-SENSYS MF410 Series", "MF410", MF410_PID, 600, 0, 637, 1050, PIXMA_CAP_ADFDUP), /* max. w = 216mm */ DEV ("Canon i-SENSYS MF510 Series", "MF510", MF510_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF230 Series", "MF230", MF230_PID, 600, 0, 637, 1050, PIXMA_CAP_ADF), /* max. w = 216mm */ DEV ("Canon i-SENSYS MF240 Series", "MF240", MF240_PID, 600, 300, 634, 1050, PIXMA_CAP_ADF), /* max. w = 215mm, */ /* TODO: fix black stripes for 216mm @ 600dpi */ DEV ("Canon i-SENSYS MF630 Series", "MF630", MF630_PID, 600, 0, 637, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF730 Series", "MF730", MF730_PID, 600, 0, 637, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF731C", "MF731", MF731_PID, 600, 0, 637, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF633C/MF635C", "MF633C/635C", MF630_PID, 600, 0, 637, 877, PIXMA_CAP_ADFDUP), /* max. w = 216mm */ DEV ("Canon imageCLASS MF634C", "MF632C/634C", MF634_PID, 600, 0, 637, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon imageCLASS MF733C", "MF731C/733C", MF731_PID, 600, 0, 637, 1050, PIXMA_CAP_ADFDUP), /* however, we need this for ethernet/wifi */ DEV ("Canon imageCLASS D570", "D570", D570_PID, 600, 0, 640, 877, 0), DEV ("Canon i-SENSYS MF110 Series", "MF110", MF110_PID, 600, 0, 640, 1050, 0), DEV ("Canon i-SENSYS MF520 Series", "MF520", MF520_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF420 Series", "MF420", MF420_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF260 Series", "MF260", MF260_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF740 Series", "MF740", MF740_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF741C/743C", "MF741C/743C", MF743_PID, 600, 300, 640, 1050, PIXMA_CAP_ADFDUP), /* ADFDUP restricted to 300dpi */ DEV ("Canon i-SENSYS MF640 Series", "MF642C/643C/644C", MF640_PID, 600, 0, 640, 1050, PIXMA_CAP_ADFDUP), DEV ("Canon i-SENSYS MF645C", "MF645C", MF645_PID, 600, 0, 637, 877, PIXMA_CAP_ADFDUP), /* max. w = 216mm */ DEV (NULL, NULL, 0, 0, 0, 0, 0, 0) }; sane-backends-1.0.29/backend/pixma/pixma_bjnp.c0000666000000000000000000022320413615534521016204 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2008 2012 by Louis Lagendijk This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #undef BACKEND_NAME #define BACKEND_NAME bjnp #include "../include/sane/config.h" #include "../include/sane/sane.h" /* * Standard types etc */ #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_STRING_H #include #endif #include #include #ifdef HAVE_STDINT_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #ifdef HAVE_UNISTD_H #include #endif /* * networking stuff */ #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #include #include #include #include #ifdef HAVE_IFADDRS_H #include #endif #ifdef HAVE_SYS_SELECT_H #include #endif #ifdef HAVE_PWD_H #include #endif #include #ifdef HAVE_FCNTL_H #include #endif #include "pixma_bjnp_private.h" #include "pixma_bjnp.h" /* #include "pixma_rename.h" */ #include "pixma.h" #include "pixma_common.h" #ifndef SSIZE_MAX # define SSIZE_MAX LONG_MAX #endif /* static data */ static bjnp_device_t device[BJNP_NO_DEVICES]; static int bjnp_no_devices = 0; /* * Private functions */ static const struct pixma_config_t *lookup_scanner(const char *makemodel, const struct pixma_config_t *const pixma_devices[]) { int i; const struct pixma_config_t *cfg; char *match; for (i = 0; pixma_devices[i]; i++) { /* loop through the device classes (mp150, mp730 etc) */ for (cfg = pixma_devices[i]; cfg->name; cfg++) { /* loop through devices in class */ PDBG( bjnp_dbg( LOG_DEBUG3, "lookup_scanner: Checking for %s in %s\n", makemodel, cfg->model)); if ((match = strcasestr (makemodel, cfg->model)) != NULL) { /* possible match found, make sure it is not a partial match */ /* MP600 and MP600R are different models! */ /* some models contain ranges, so check for a '-' too */ if ((match[strlen(cfg->model)] == ' ') || (match[strlen(cfg->model)] == '\0') || (match[strlen(cfg->model)] == '-')) { PDBG( bjnp_dbg (LOG_DEBUG, "lookup_scanner: Scanner model found: Name %s(%s) matches %s\n", cfg->model, cfg->name, makemodel)); return cfg; } } } } PDBG( bjnp_dbg (LOG_DEBUG, "lookup_scanner: Scanner model %s not found, giving up!\n", makemodel)); return NULL; } static void u8tohex (char *string, const uint8_t *value, int len ) { int i; int x; const char hdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; for (i = 0; i < len; i++) { x = value[i]; string[ 2 * i ] = hdigit[(x >> 4) & 0xf]; string[ 2 * i + 1] = hdigit[x & 0xf]; } string[2 * len ] = '\0'; } static void u32tohex (uint32_t x, char *str) { uint8_t uint8[4]; uint8[0] = (uint8_t)(x >> 24); uint8[1] = (uint8_t)(x >> 16); uint8[2] = (uint8_t)(x >> 8); uint8[3] = (uint8_t)x ; u8tohex(str, uint8, 4); } static void bjnp_hexdump (int level, const void *d_, unsigned len) { const uint8_t *d = (const uint8_t *) (d_); unsigned ofs, c, plen; char line[100]; /* actually only 1+8+1+8*3+1+8*3+1 = 61 bytes needed */ if (level > DBG_LEVEL) return; if (level == DBG_LEVEL) /* if debuglevel == exact match and buffer contains more than 3 lines, print 2 lines + .... */ plen = (len > 64) ? 32: len; else plen = len; ofs = 0; while (ofs < plen) { char *p; line[0] = ' '; u32tohex (ofs, line + 1); line[9] = ':'; p = line + 10; for (c = 0; c != 16 && (ofs + c) < plen; c++) { u8tohex (p, d + ofs + c, 1); p[2] = ' '; p += 3; if (c == 7) { p[0] = ' '; p++; } } p[0] = '\0'; bjnp_dbg (level, "%s\n", line); ofs += c; } if (len > plen) bjnp_dbg(level, "......\n"); } static int sa_is_equal( const bjnp_sockaddr_t * sa1, const bjnp_sockaddr_t * sa2) { if ((sa1 == NULL) || (sa2 == NULL) ) return 0; if (sa1->addr.sa_family == sa2-> addr.sa_family) { if( sa1 -> addr.sa_family == AF_INET) { if ( (sa1->ipv4.sin_port == sa2->ipv4.sin_port) && (sa1->ipv4.sin_addr.s_addr == sa2->ipv4.sin_addr.s_addr)) { return 1; } } #ifdef ENABLE_IPV6 else if (sa1 -> addr.sa_family == AF_INET6 ) { if ( (sa1-> ipv6.sin6_port == sa2->ipv6.sin6_port) && (memcmp(&(sa1->ipv6.sin6_addr), &(sa2->ipv6.sin6_addr), sizeof(struct in6_addr)) == 0)) { return 1; } } #endif } return 0; } static int sa_size( const bjnp_sockaddr_t *sa) { switch (sa -> addr.sa_family) { case AF_INET: return (sizeof(struct sockaddr_in) ); #ifdef ENABLE_IPV6 case AF_INET6: return (sizeof(struct sockaddr_in6) ); #endif default: /* should not occur */ return sizeof( bjnp_sockaddr_t ); } } static int get_protocol_family( const bjnp_sockaddr_t *sa) { switch (sa -> addr.sa_family) { case AF_INET: return PF_INET; break; #ifdef ENABLE_IPV6 case AF_INET6: return PF_INET6; break; #endif default: /* should not occur */ return -1; } } static void get_address_info ( const bjnp_sockaddr_t *addr, char * addr_string, int *port) { char tmp_addr[BJNP_HOST_MAX]; if ( addr->addr.sa_family == AF_INET) { inet_ntop( AF_INET, &(addr -> ipv4.sin_addr.s_addr), addr_string, BJNP_HOST_MAX); *port = ntohs (addr->ipv4.sin_port); } #ifdef ENABLE_IPV6 else if (addr->addr.sa_family == AF_INET6) { inet_ntop( AF_INET6, addr -> ipv6.sin6_addr.s6_addr, tmp_addr, sizeof(tmp_addr) ); if (IN6_IS_ADDR_LINKLOCAL( &(addr -> ipv6.sin6_addr) ) ) sprintf(addr_string, "[%s%%%d]", tmp_addr, addr -> ipv6.sin6_scope_id); *port = ntohs (addr->ipv6.sin6_port); } #endif else { /* unknown address family, should not occur */ strcpy(addr_string, "Unknown address family"); *port = 0; } } static int parse_IEEE1284_to_model (char *scanner_id, char *model) { /* * parses the IEEE1284 ID of the scanner to retrieve make and model * of the scanner * Returns: 0 = not found * 1 = found, model is set */ char s[BJNP_IEEE1284_MAX]; char *tok; char * model_str; strncpy (s, scanner_id, BJNP_IEEE1284_MAX); s[BJNP_IEEE1284_MAX - 1] = '\0'; model[0] = '\0'; tok = strtok (s, ";"); while (tok != NULL) { /* MDL contains make and model */ if (strncmp (tok, "MDL:", strlen("MDL:")) == 0) { model_str = tok + strlen("MDL:"); strncpy (model, model_str, BJNP_MODEL_MAX); model[BJNP_MODEL_MAX -1] = '\0'; return 1; } tok = strtok (NULL, ";"); } return 0; } static int charTo2byte (char *d, const char *s, int len) { /* * copy ASCII string to UTF-16 unicode string * len is length of destination buffer * Returns: number of characters copied */ int done = 0; int copied = 0; int i; len = len / 2; for (i = 0; i < len; i++) { d[2 * i] = '\0'; if (s[i] == '\0') { done = 1; } if (done == 0) { d[2 * i + 1] = s[i]; copied++; } else d[2 * i + 1] = '\0'; } return copied; } static bjnp_protocol_defs_t *get_protocol_by_method( char *method) { int i = 0; while ( bjnp_protocol_defs[i].method_string != NULL) { if (strcmp(method, bjnp_protocol_defs[i].method_string) == 0) { return &bjnp_protocol_defs[i]; } i++; } return NULL; } static bjnp_protocol_defs_t *get_protocol_by_proto_string( char *proto_string) { int i = 0; while ( bjnp_protocol_defs[i].proto_string != NULL) { if (strncmp(proto_string, bjnp_protocol_defs[i].proto_string, 4) == 0) { return &bjnp_protocol_defs[i]; } i++; } return NULL; } static char * getusername (void) { static char noname[] = "sane_pixma"; struct passwd *pwdent; #ifdef HAVE_PWD_H if (((pwdent = getpwuid (geteuid ())) != NULL) && (pwdent->pw_name != NULL)) return pwdent->pw_name; #endif return noname; } static char * determine_scanner_serial (const char *hostname, const char * mac_address, char *serial) { char *dot; char copy[BJNP_HOST_MAX]; /* determine a "serial number" for the scanner */ /* if available we use the hostname or ipv4 address of the printer */ /* if we only have a literal ipv6 address, we use the mac-address */ strcpy(copy, hostname); 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'; } } /* 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; } static int bjnp_open_tcp (int devno) { int sock; int val; bjnp_sockaddr_t *addr = device[devno].addr; char host[BJNP_HOST_MAX]; int port; int connect_timeout = BJNP_TIMEOUT_TCP_CONNECT; get_address_info( addr, host, &port); PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_open_tcp: Setting up a TCP socket, dest: %s port %d\n", host, port ) ); if ((sock = socket (get_protocol_family( addr ) , SOCK_STREAM, 0)) < 0) { PDBG (bjnp_dbg (LOG_CRIT, "bjnp_open_tcp: ERROR - Can not create socket: %s\n", strerror (errno))); return -1; } val = 1; setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof (val)); #if 0 val = 1; setsockopt (sock, SOL_SOCKET, SO_REUSEPORT, &val, sizeof (val)); val = 1; #endif /* * Using TCP_NODELAY improves responsiveness, especially on systems * with a slow loopback interface... */ val = 1; setsockopt (sock, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); /* * Close this socket when starting another process... */ fcntl (sock, F_SETFD, FD_CLOEXEC); while (connect_timeout > 0) { if (connect (sock, &(addr->addr), sa_size(device[devno].addr)) == 0) { device[devno].tcp_socket = sock; return 0; } PDBG (bjnp_dbg( LOG_INFO, "bjnp_open_tcp: INFO - Can not yet connect over TCP to scanner: %s, retrying\n", strerror(errno))); usleep(BJNP_TCP_CONNECT_INTERVAL * BJNP_USLEEP_MS); connect_timeout = connect_timeout - BJNP_TCP_CONNECT_INTERVAL; } PDBG (bjnp_dbg (LOG_CRIT, "bjnp_open_tcp: ERROR - Can not connect to scanner, giving up!")); return -1; } static int split_uri (const char *devname, char *method, char *host, char *port, char *args) { char copy[1024]; char *start; char next; int i; strncpy (copy, devname, 1024); copy[1023] = '\0'; start = copy; /* * retrieve method */ i = 0; while ((start[i] != '\0') && (start[i] != ':')) { i++; } if (((strncmp (start + i, "://", 3) != 0)) || (i > BJNP_METHOD_MAX -1 )) { PDBG (bjnp_dbg (LOG_NOTICE, "split_uri: ERROR - Can not find method in %s (offset %d)\n", devname, i)); return -1; } start[i] = '\0'; strcpy (method, start); start = start + i + 3; /* * retrieve host */ if (start[0] == '[') { /* literal IPv6 address */ char *end_of_address = strchr(start, ']'); if ( ( end_of_address == NULL) || ( (end_of_address[1] != ':') && (end_of_address[1] != '/' ) && (end_of_address[1] != '\0' )) || ( (end_of_address - start) >= BJNP_HOST_MAX ) ) { PDBG (bjnp_dbg (LOG_NOTICE, "split_uri: ERROR - Can not find hostname or address in %s\n", devname)); return -1; } next = end_of_address[1]; *end_of_address = '\0'; strcpy(host, start + 1); start = end_of_address + 2; } else { i = 0; while ((start[i] != '\0') && (start[i] != '/') && (start[i] != ':')) { i++; } next = start[i]; start[i] = '\0'; if ((i == 0) || (i >= BJNP_HOST_MAX ) ) { PDBG (bjnp_dbg (LOG_NOTICE, "split_uri: ERROR - Can not find hostname or address in %s\n", devname)); return -1; } strcpy (host, start); start = start + i +1; } /* * retrieve port number */ if (next != ':') strcpy(port, ""); else { char *end_of_port = strchr(start, '/'); if (end_of_port == NULL) { next = '\0'; } else { next = *end_of_port; *end_of_port = '\0'; } if ((strlen(start) == 0) || (strlen(start) >= BJNP_PORT_MAX ) ) { PDBG (bjnp_dbg (LOG_NOTICE, "split_uri: ERROR - Can not find port in %s (have \"%s\")\n", devname, start)); return -1; } strcpy(port, start); start = end_of_port + 1; } /* * Retrieve arguments */ if (next == '/') { i = strlen(start); if ( i >= BJNP_ARGS_MAX) { PDBG (bjnp_dbg (LOG_NOTICE, "split_uri: ERROR - Argument string too long in %s\n", devname)); } strcpy (args, start); } else strcpy (args, ""); return 0; } static void set_cmd_from_string (char* protocol_string, struct BJNP_command *cmd, char cmd_code, int payload_len) { /* * Set command buffer with command code, session_id and length of payload * Returns: sequence number of command */ memcpy (cmd->BJNP_id, protocol_string, sizeof (cmd->BJNP_id)); cmd->dev_type = BJNP_CMD_SCAN; cmd->cmd_code = cmd_code; cmd->unknown1 = htons (0); /* device not yet opened, use 0 for serial and session) */ cmd->seq_no = htons (0); cmd->session_id = htons (0); cmd->payload_len = htonl (payload_len); } static void set_cmd_for_dev (int devno, struct BJNP_command *cmd, char cmd_code, int payload_len) { /* * Set command buffer with command code, session_id and length of payload * Returns: sequence number of command */ memcpy(cmd->BJNP_id, device[devno].protocol_string, sizeof (cmd->BJNP_id)); cmd->dev_type = BJNP_CMD_SCAN; cmd->cmd_code = cmd_code; cmd->unknown1 = htons (0); cmd->seq_no = htons (++(device[devno].serial)); cmd->session_id = (cmd_code == CMD_UDP_POLL ) ? 0 : htons (device[devno].session_id); device[devno].last_cmd = cmd_code; cmd->payload_len = htonl (payload_len); } static int bjnp_setup_udp_socket ( const int dev_no ) { /* * Setup a udp socket for the given device * Returns the socket or -1 in case of error */ int sockfd; char addr_string[256]; int port; bjnp_sockaddr_t * addr = device[dev_no].addr; get_address_info( addr, addr_string, &port); PDBG (bjnp_dbg (LOG_DEBUG, "setup_udp_socket: Setting up a UDP socket, dest: %s port %d\n", addr_string, port ) ); if ((sockfd = socket (get_protocol_family( addr ), SOCK_DGRAM, IPPROTO_UDP)) == -1) { PDBG (bjnp_dbg (LOG_CRIT, "setup_udp_socket: ERROR - can not open socket - %s\n", strerror (errno))); return -1; } if (connect (sockfd, &(device[dev_no].addr->addr), sa_size(device[dev_no].addr) )!= 0) { PDBG (bjnp_dbg (LOG_CRIT, "setup_udp_socket: ERROR - connect failed- %s\n", strerror (errno))); close(sockfd); return -1; } return sockfd; } static int udp_command (const int dev_no, char *command, int cmd_len, char *response, int resp_len) { /* * send udp command to given device and recieve the response` * returns: the legth of the response or -1 */ int sockfd; struct timeval timeout; int result; int try, attempt; int numbytes; fd_set fdset; struct BJNP_command *resp = (struct BJNP_command *) response; struct BJNP_command *cmd = (struct BJNP_command *) command; if ( (sockfd = bjnp_setup_udp_socket(dev_no) ) == -1 ) { PDBG (bjnp_dbg( LOG_CRIT, "udp_command: ERROR - Can not setup socket\n") ); return -1; } for (try = 0; try < BJNP_UDP_RETRY_MAX; try++) { if ((numbytes = send (sockfd, command, cmd_len, 0)) != cmd_len) { PDBG (bjnp_dbg (LOG_NOTICE, "udp_command: ERROR - Sent %d bytes, expected %d\n", numbytes, cmd_len)); continue; } attempt = 0; /* wait for data to be received, ignore signals being received */ /* skip late udp responses (they have an incorrect sequence number */ do { FD_ZERO (&fdset); FD_SET (sockfd, &fdset); timeout.tv_sec = device[dev_no].bjnp_ip_timeout /1000; timeout.tv_usec = device[dev_no].bjnp_ip_timeout %1000; } while (((result = select (sockfd + 1, &fdset, NULL, NULL, &timeout)) <= 0) && (errno == EINTR) && (attempt++ < BJNP_MAX_SELECT_ATTEMPTS) && resp-> seq_no != cmd->seq_no); if (result <= 0) { PDBG (bjnp_dbg (LOG_NOTICE, "udp_command: ERROR - select failed: %s\n", result == 0 ? "timed out" : strerror (errno))); continue; } if ((numbytes = recv (sockfd, response, resp_len, 0)) == -1) { PDBG (bjnp_dbg (LOG_NOTICE, "udp_command: ERROR - recv failed: %s", strerror (errno))); continue; } close(sockfd); return numbytes; } /* no response even after retry */ close(sockfd); PDBG (bjnp_dbg (LOG_CRIT, "udp_command: ERROR - no data received (timeout = %d)\n", device[dev_no].bjnp_ip_timeout ) ); return -1; } static int get_scanner_id (const int dev_no, char *model) { /* * get scanner identity * Sets model (make and model) * Return 0 on success, -1 in case of errors */ struct BJNP_command cmd; struct IDENTITY *id; char scanner_id[BJNP_IEEE1284_MAX]; int resp_len; char resp_buf[BJNP_RESP_MAX]; int id_len; /* set defaults */ strcpy (model, "Unidentified scanner"); set_cmd_for_dev (dev_no, &cmd, CMD_UDP_GET_ID, 0); PDBG (bjnp_dbg (LOG_DEBUG2, "get_scanner_id: Get scanner identity\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, (char *) &cmd, sizeof (struct BJNP_command))); if ( ( resp_len = udp_command (dev_no, (char *) &cmd, sizeof (struct BJNP_command), resp_buf, BJNP_RESP_MAX) ) < (int)sizeof(struct BJNP_command) ) { PDBG (bjnp_dbg (LOG_DEBUG, "get_scanner_id: ERROR - Failed to retrieve scanner identity:\n")); return -1; } PDBG (bjnp_dbg (LOG_DEBUG2, "get_scanner_id: scanner identity:\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, resp_buf, resp_len)); id = (struct IDENTITY *) resp_buf; if (device[dev_no].protocol == PROTOCOL_BJNP) { id_len = MIN(ntohl( id-> cmd.payload_len ) - sizeof(id-> payload.bjnp.id_len), BJNP_IEEE1284_MAX); strncpy(scanner_id, id->payload.bjnp.id, id_len); scanner_id[id_len] = '\0'; } else { id_len = MIN(ntohl( id-> cmd.payload_len ), BJNP_IEEE1284_MAX); strncpy(scanner_id, id->payload.mfnp.id, id_len); scanner_id[id_len] = '\0'; } PDBG (bjnp_dbg (LOG_INFO, "get_scanner_id: Scanner identity string = %s - length = %d\n", scanner_id, id_len)); /* get make&model from IEEE1284 id */ if (model != NULL) { parse_IEEE1284_to_model (scanner_id, model); PDBG (bjnp_dbg (LOG_INFO, "get_scanner_id: Scanner model = %s\n", model)); } return 0; } static int get_scanner_name(const bjnp_sockaddr_t *scanner_sa, char *host) { /* * Parse identify command responses to ip-address * and hostname. Return qulity of the address */ struct addrinfo *results; struct addrinfo *result; char ip_address[BJNP_HOST_MAX]; int port; int error; int match = 0; int level; char service[64]; #ifdef ENABLE_IPV6 if ( ( scanner_sa -> addr.sa_family == AF_INET6 ) && ( IN6_IS_ADDR_LINKLOCAL( &(scanner_sa -> ipv6.sin6_addr ) ) ) ) level = BJNP_ADDRESS_IS_LINK_LOCAL; else #endif level = BJNP_ADDRESS_IS_GLOBAL; get_address_info( scanner_sa, ip_address, &port ); /* do reverse name lookup, if hostname can not be found return ip-address */ if( (error = getnameinfo( &(scanner_sa -> addr) , sa_size( scanner_sa), host, BJNP_HOST_MAX , NULL, 0, NI_NAMEREQD) ) != 0 ) { PDBG (bjnp_dbg(LOG_INFO, "get_scanner_name: Name for %s not found : %s\n", ip_address, gai_strerror(error) ) ); strcpy(host, ip_address); return level; } else { sprintf(service, "%d", port); /* some buggy routers return rubbish if reverse lookup fails, so * we do a forward lookup on the received name to see if the result matches */ if (getaddrinfo(host , service, NULL, &results) == 0) { result = results; while (result != NULL) { if(sa_is_equal( scanner_sa, (bjnp_sockaddr_t *)result-> ai_addr)) { /* found match, good */ PDBG (bjnp_dbg (LOG_INFO, "get_scanner_name: Forward lookup for %s succeeded, using as hostname\n", host)); match = 1; level = BJNP_ADDRESS_HAS_FQDN; break; } result = result-> ai_next; } freeaddrinfo(results); if (match != 1) { PDBG (bjnp_dbg (LOG_INFO, "get_scanner_name: Forward lookup for %s succeeded, IP-address does not match, using IP-address %s instead\n", host, ip_address)); strcpy (host, ip_address); } } else { /* forward lookup failed, use ip-address */ PDBG ( bjnp_dbg (LOG_INFO, "get_scanner_name: Forward lookup of %s failed, using IP-address", ip_address)); strcpy (host, ip_address); } } return level; } static int get_port_from_sa(const bjnp_sockaddr_t scanner_sa) { #ifdef ENABLE_IPV6 if ( scanner_sa.addr.sa_family == AF_INET6 ) { return ntohs(scanner_sa.ipv6.sin6_port); } else #endif if ( scanner_sa.addr.sa_family == AF_INET ) { return ntohs(scanner_sa.ipv4.sin_port); } return -1; } static int create_broadcast_socket( const bjnp_sockaddr_t * local_addr ) { int sockfd = -1; int broadcast = 1; int ipv6_v6only = 1; if ((sockfd = socket (local_addr-> addr.sa_family, SOCK_DGRAM, 0)) == -1) { PDBG (bjnp_dbg (LOG_CRIT, "create_broadcast_socket: ERROR - can not open socket - %s", strerror (errno))); return -1; } /* Set broadcast flag on socket */ if (setsockopt (sockfd, SOL_SOCKET, SO_BROADCAST, (const char *) &broadcast, sizeof (broadcast)) != 0) { PDBG (bjnp_dbg (LOG_CRIT, "create_broadcast_socket: ERROR - setting socket option SO_BROADCAST failed - %s", strerror (errno))); close (sockfd); return -1; }; /* For an IPv6 socket, bind to v6 only so a V6 socket can co-exist with a v4 socket */ if ( (local_addr -> addr.sa_family == AF_INET6) && ( setsockopt (sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (const char *) &ipv6_v6only, sizeof (ipv6_v6only)) != 0) ) { PDBG (bjnp_dbg (LOG_CRIT, "create_broadcast_socket: ERROR - setting socket option IPV6_V6ONLY failed - %s", strerror (errno))); close (sockfd); return -1; }; if (bind (sockfd, &(local_addr->addr), (socklen_t) sa_size( local_addr)) != 0) { PDBG (bjnp_dbg (LOG_CRIT, "create_broadcast_socket: ERROR - bind socket to local address failed - %s\n", strerror (errno))); close (sockfd); return -1; } return sockfd; } static int prepare_socket(const char *if_name, const bjnp_sockaddr_t *local_sa, const bjnp_sockaddr_t *broadcast_sa, bjnp_sockaddr_t * dest_sa) { /* * Prepare a socket for broadcast or multicast * Input: * if_name: the name of the interface * local_sa: local address to use * broadcast_sa: broadcast address to use, if NULL we use all hosts * dest_sa: (write) where to return destination address of broadcast * retuns: open socket or -1 */ int socket = -1; bjnp_sockaddr_t local_sa_copy; if ( local_sa == NULL ) { PDBG (bjnp_dbg (LOG_DEBUG, "prepare_socket: %s is not a valid IPv4 interface, skipping...\n", if_name)); return -1; } memset( &local_sa_copy, 0, sizeof(local_sa_copy) ); memcpy( &local_sa_copy, local_sa, sa_size(local_sa) ); switch( local_sa_copy.addr.sa_family ) { case AF_INET: { local_sa_copy.ipv4.sin_port = htons(BJNP_PORT_SCAN); if (local_sa_copy.ipv4.sin_addr.s_addr == htonl (INADDR_LOOPBACK) ) { /* not a valid interface */ PDBG (bjnp_dbg (LOG_DEBUG, "prepare_socket: %s is not a valid IPv4 interface, skipping...\n", if_name)); return -1; } /* send broadcasts to the broadcast address of the interface */ memcpy(dest_sa, broadcast_sa, sa_size(dest_sa) ); /* we fill port when we send the broadcast */ dest_sa -> ipv4.sin_port = htons(0); if ( (socket = create_broadcast_socket( &local_sa_copy) ) != -1) { PDBG (bjnp_dbg (LOG_INFO, "prepare_socket: %s is IPv4 capable, sending broadcast, socket = %d\n", if_name, socket)); } else { PDBG (bjnp_dbg (LOG_INFO, "prepare_socket: ERROR - %s is IPv4 capable, but failed to create a socket.\n", if_name)); return -1; } } break; #ifdef ENABLE_IPV6 case AF_INET6: { local_sa_copy.ipv6.sin6_port = htons(BJNP_PORT_SCAN); if (IN6_IS_ADDR_LOOPBACK( &(local_sa_copy.ipv6.sin6_addr) ) ) { /* not a valid interface */ PDBG (bjnp_dbg (LOG_DEBUG, "prepare_socket: %s is not a valid IPv6 interface, skipping...\n", if_name)); return -1; } else { dest_sa -> ipv6.sin6_family = AF_INET6; /* We fill port when we send the broadcast */ dest_sa -> ipv6.sin6_port = htons(0); inet_pton(AF_INET6, "ff02::1", dest_sa -> ipv6.sin6_addr.s6_addr); if ( (socket = create_broadcast_socket( &local_sa_copy ) ) != -1) { PDBG (bjnp_dbg (LOG_INFO, "prepare_socket: %s is IPv6 capable, sending broadcast, socket = %d\n", if_name, socket)); } else { PDBG (bjnp_dbg (LOG_INFO, "prepare_socket: ERROR - %s is IPv6 capable, but failed to create a socket.\n", if_name)); return -1; } } } break; #endif default: socket = -1; } return socket; } static int bjnp_send_broadcast (int sockfd, const bjnp_sockaddr_t * broadcast_addr, int port, struct BJNP_command cmd, int size) { int num_bytes; bjnp_sockaddr_t dest_addr; /* set address to send packet to broadcast address of interface, */ /* with port set to the destination port */ memcpy(&dest_addr, broadcast_addr, sizeof(dest_addr)); if( dest_addr.addr.sa_family == AF_INET) { dest_addr.ipv4.sin_port = htons(port); } #ifdef ENABLE_IPV6 if( dest_addr.addr.sa_family == AF_INET6) { dest_addr.ipv6.sin6_port = htons(port); } #endif if ((num_bytes = sendto (sockfd, &cmd, size, 0, &(dest_addr.addr), sa_size( broadcast_addr)) ) != size) { PDBG (bjnp_dbg (LOG_INFO, "bjnp_send_broadcast: Socket: %d: ERROR - sent only %x = %d bytes of packet, error = %s\n", sockfd, num_bytes, num_bytes, strerror (errno))); /* not allowed, skip this interface */ return -1; } return sockfd; } static void bjnp_finish_job (int devno) { /* * Signal end of scanjob to scanner */ char resp_buf[BJNP_RESP_MAX]; int resp_len; struct BJNP_command cmd; set_cmd_for_dev (devno, &cmd, CMD_UDP_CLOSE, 0); PDBG (bjnp_dbg (LOG_DEBUG2, "bjnp_finish_job: Finish scanjob\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, (char *) &cmd, sizeof (struct BJNP_command))); resp_len = udp_command (devno, (char *) &cmd, sizeof (struct BJNP_command), resp_buf, BJNP_RESP_MAX); if (resp_len != sizeof (struct BJNP_command)) { PDBG (bjnp_dbg (LOG_INFO, "bjnp_finish_job: ERROR - Received %d characters on close scanjob command, expected %d\n", resp_len, (int) sizeof (struct BJNP_command))); return; } PDBG (bjnp_dbg (LOG_DEBUG2, "bjnp_finish_job: Finish scanjob response\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, resp_buf, resp_len)); } #ifdef PIXMA_BJNP_USE_STATUS static int bjnp_poll_scanner (int devno, char type,char *hostname, char *user, SANE_Byte *status, int size) { /* * send details of user to the scanner */ char cmd_buf[BJNP_CMD_MAX]; char resp_buf[BJNP_RESP_MAX]; int resp_len; int len = 0; /* payload length */ int buf_len; /* length of the whole command buffer */ struct POLL_DETAILS *poll; struct POLL_RESPONSE *response; char user_host[256]; time_t t; int user_host_len; poll = (struct POLL_DETAILS *) cmd_buf; memset( poll, 0, sizeof( struct POLL_DETAILS)); memset( &resp_buf, 0, sizeof( resp_buf) ); /* create payload */ poll->type = htons(type); user_host_len = sizeof( poll -> extensions.type2.user_host); snprintf(user_host, (user_host_len /2) ,"%s %s", user, hostname); user_host[ user_host_len /2 + 1] = '\0'; switch( type) { case 0: len = 80; break; case 1: charTo2byte(poll->extensions.type1.user_host, user_host, user_host_len); len = 80; break; case 2: poll->extensions.type2.dialog = htonl(device[devno].dialog); charTo2byte(poll->extensions.type2.user_host, user_host, user_host_len); poll->extensions.type2.unknown_1 = htonl(0x14); poll->extensions.type2.unknown_2 = htonl(0x10); t = time (NULL); strftime (poll->extensions.type2.ascii_date, sizeof (poll->extensions.type2.ascii_date), "%Y%m%d%H%M%S", localtime (&t)); len = 116; break; case 5: poll->extensions.type5.dialog = htonl(device[devno].dialog); charTo2byte(poll->extensions.type5.user_host, user_host, user_host_len); poll->extensions.type5.unknown_1 = htonl(0x14); poll->extensions.type5.key = htonl(device[devno].status_key); len = 100; break; default: PDBG (bjnp_dbg (LOG_INFO, "bjnp_poll_scanner: unknown packet type: %d\n", type)); return -1; }; /* we can only now set the header as we now know the length of the payload */ set_cmd_for_dev (devno, (struct BJNP_command *) cmd_buf, CMD_UDP_POLL, len); buf_len = len + sizeof(struct BJNP_command); PDBG (bjnp_dbg (LOG_DEBUG2, "bjnp_poll_scanner: Poll details (type %d)\n", type)); PDBG (bjnp_hexdump (LOG_DEBUG2, cmd_buf, buf_len)); resp_len = udp_command (devno, cmd_buf, buf_len, resp_buf, BJNP_RESP_MAX); if (resp_len > 0) { PDBG (bjnp_dbg (LOG_DEBUG2, "bjnp_poll_scanner: Poll details response:\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, resp_buf, resp_len)); response = (struct POLL_RESPONSE *) resp_buf; device[devno].dialog = ntohl( response -> dialog ); if ( response -> result[3] == 1 ) { return BJNP_RESTART_POLL; } if ( (response -> result[2] & 0x80) != 0) { memcpy( status, response->status, size); PDBG( bjnp_dbg(LOG_INFO, "bjnp_poll_scanner: received button status!\n")); PDBG (bjnp_hexdump( LOG_DEBUG2, status, size )); device[devno].status_key = ntohl( response -> key ); return size; } } return 0; } #endif static void bjnp_send_job_details (int devno, char *hostname, char *user, char *title) { /* * send details of scanjob to scanner */ char cmd_buf[BJNP_CMD_MAX]; char resp_buf[BJNP_RESP_MAX]; int resp_len; struct JOB_DETAILS *job; struct BJNP_command *resp; /* send job details command */ set_cmd_for_dev (devno, (struct BJNP_command *) cmd_buf, CMD_UDP_JOB_DETAILS, sizeof (*job) - sizeof (struct BJNP_command)); /* create payload */ job = (struct JOB_DETAILS *) (cmd_buf); charTo2byte (job->unknown, "", sizeof (job->unknown)); charTo2byte (job->hostname, hostname, sizeof (job->hostname)); charTo2byte (job->username, user, sizeof (job->username)); charTo2byte (job->jobtitle, title, sizeof (job->jobtitle)); PDBG (bjnp_dbg (LOG_DEBUG2, "bjnp_send_job_details: Job details\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, cmd_buf, (sizeof (struct BJNP_command) + sizeof (*job)))); resp_len = udp_command (devno, cmd_buf, sizeof (struct JOB_DETAILS), resp_buf, BJNP_RESP_MAX); if (resp_len > 0) { PDBG (bjnp_dbg (LOG_DEBUG2, "bjnp_send_job_details: Job details response:\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, resp_buf, resp_len)); resp = (struct BJNP_command *) resp_buf; device[devno].session_id = ntohs (resp->session_id); } } static int bjnp_get_scanner_mac_address ( int devno, char *mac_address ) { /* * send discover to scanner */ char cmd_buf[BJNP_CMD_MAX]; char resp_buf[BJNP_RESP_MAX]; int resp_len; struct DISCOVER_RESPONSE *resp = (struct DISCOVER_RESPONSE * )&resp_buf;; /* send job details command */ set_cmd_for_dev (devno, (struct BJNP_command *) cmd_buf, CMD_UDP_DISCOVER, 0); resp_len = udp_command (devno, cmd_buf, sizeof (struct BJNP_command), resp_buf, BJNP_RESP_MAX); if (resp_len > 0) { PDBG (bjnp_dbg (LOG_DEBUG2, "bjnp_get_scanner_mac_address: Discover response:\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, resp_buf, resp_len)); u8tohex( mac_address, resp -> mac_addr, sizeof( resp -> mac_addr ) ); return 0; } return -1; } static int bjnp_write (int devno, const SANE_Byte * buf, size_t count) { /* * This function writes TCP data to the scanner. * Returns: number of bytes written to the scanner */ int sent_bytes; int terrno; struct SCAN_BUF bjnp_buf; if (device[devno].scanner_data_left) { PDBG (bjnp_dbg (LOG_CRIT, "bjnp_write: ERROR - scanner data left = 0x%lx = %ld\n", (unsigned long) device[devno].scanner_data_left, (unsigned long) device[devno].scanner_data_left)); } /* set BJNP command header */ set_cmd_for_dev (devno, (struct BJNP_command *) &bjnp_buf, CMD_TCP_SEND, count); memcpy (bjnp_buf.scan_data, buf, count); PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_write: sending 0x%lx = %ld bytes\n", (unsigned long) count, (unsigned long) count); PDBG (bjnp_hexdump (LOG_DEBUG2, (char *) &bjnp_buf, sizeof (struct BJNP_command) + count))); if ((sent_bytes = send (device[devno].tcp_socket, &bjnp_buf, sizeof (struct BJNP_command) + count, 0)) < (ssize_t) (sizeof (struct BJNP_command) + count)) { /* return result from write */ terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, "bjnp_write: ERROR - Could not send data!\n")); errno = terrno; return sent_bytes; } /* correct nr of bytes sent for length of command */ else if (sent_bytes != (int) (sizeof (struct BJNP_command) + count)) { errno = EIO; return -1; } return count; } static int bjnp_send_read_request (int devno) { /* * This function reads responses from the scanner. * Returns: 0 on success, else -1 * */ int sent_bytes; int terrno; struct BJNP_command bjnp_buf; if (device[devno].scanner_data_left) PDBG (bjnp_dbg (LOG_CRIT, "bjnp_send_read_request: ERROR - scanner data left = 0x%lx = %ld\n", (unsigned long) device[devno].scanner_data_left, (unsigned long) device[devno].scanner_data_left)); /* set BJNP command header */ set_cmd_for_dev (devno, (struct BJNP_command *) &bjnp_buf, CMD_TCP_REQ, 0); PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_send_read_req sending command\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, (char *) &bjnp_buf, sizeof (struct BJNP_command))); if ((sent_bytes = send (device[devno].tcp_socket, &bjnp_buf, sizeof (struct BJNP_command), 0)) < 0) { /* return result from write */ terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, "bjnp_send_read_request: ERROR - Could not send data!\n")); errno = terrno; return -1; } return 0; } static SANE_Status bjnp_recv_header (int devno, size_t *payload_size ) { /* * This function receives the response header to bjnp commands. * devno device number * size: return value for data size returned by scanner * Returns: * SANE_STATUS_IO_ERROR when any IO error occurs * SANE_STATUS_GOOD in case no errors were encountered */ struct BJNP_command resp_buf; fd_set input; struct timeval timeout; int recv_bytes; int terrno; int result; int fd; int attempt; PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_recv_header: receiving response header\n") ); fd = device[devno].tcp_socket; *payload_size = 0; attempt = 0; do { /* wait for data to be received, ignore signals being received */ FD_ZERO (&input); FD_SET (fd, &input); timeout.tv_sec = device[devno].bjnp_ip_timeout /1000; timeout.tv_usec = device[devno].bjnp_ip_timeout %1000; } while ( ( (result = select (fd + 1, &input, NULL, NULL, &timeout)) <= 0) && (errno == EINTR) && (attempt++ < BJNP_MAX_SELECT_ATTEMPTS)); if (result < 0) { terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_header: ERROR - could not read response header (select): %s!\n", strerror (terrno))); errno = terrno; return SANE_STATUS_IO_ERROR; } else if (result == 0) { terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_header: ERROR - could not read response header (select timed out after %d ms)!\n", device[devno].bjnp_ip_timeout ) ); errno = terrno; return SANE_STATUS_IO_ERROR; } /* get response header */ if ((recv_bytes = recv (fd, (char *) &resp_buf, sizeof (struct BJNP_command), 0)) != sizeof (struct BJNP_command)) { terrno = errno; if (recv_bytes == 0) { PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_header: ERROR - (recv) Scanner closed the TCP-connection!\n")); } else { PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_header: ERROR - (recv) could not read response header, received %d bytes!\n", recv_bytes)); PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_header: ERROR - (recv) error: %s!\n", strerror (terrno))); } errno = terrno; return SANE_STATUS_IO_ERROR; } if (resp_buf.cmd_code != device[devno].last_cmd) { PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_header: ERROR - Received response has cmd code %d, expected %d\n", resp_buf.cmd_code, device[devno].last_cmd)); return SANE_STATUS_IO_ERROR; } if (ntohs (resp_buf.seq_no) != (uint16_t) device[devno].serial) { PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_header: ERROR - Received response has serial %d, expected %d\n", (int) ntohs (resp_buf.seq_no), (int) device[devno].serial)); return SANE_STATUS_IO_ERROR; } /* got response header back, retrieve length of payload */ *payload_size = ntohl (resp_buf.payload_len); PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_recv_header: TCP response header(payload data = %ld bytes):\n", *payload_size) ); PDBG (bjnp_hexdump (LOG_DEBUG2, (char *) &resp_buf, sizeof (struct BJNP_command))); return SANE_STATUS_GOOD; } static int bjnp_init_device_structure(int dn, bjnp_sockaddr_t *sa, bjnp_protocol_defs_t *protocol_defs, int ip_timeout) { /* initialize device structure */ char name[BJNP_HOST_MAX]; device[dn].open = 0; #ifdef PIXMA_BJNP_USE_STATUS device[dn].polling_status = BJNP_POLL_STOPPED; device[dn].dialog = 0; device[dn].status_key = 0; #endif device[dn].protocol = protocol_defs->protocol_version; device[dn].protocol_string = protocol_defs->proto_string; device[dn].tcp_socket = -1; device[dn].addr = (bjnp_sockaddr_t *) malloc(sizeof ( bjnp_sockaddr_t) ); memset( device[dn].addr, 0, sizeof( bjnp_sockaddr_t ) ); memcpy(device[dn].addr, sa, sa_size((bjnp_sockaddr_t *)sa) ); device[dn].address_level = get_scanner_name(sa, name); device[dn].session_id = 0; device[dn].serial = -1; device[dn].bjnp_ip_timeout = ip_timeout; device[dn].bjnp_scanner_timeout = 1000; device[dn].scanner_data_left = 0; device[dn].last_cmd = 0; device[dn].blocksize = BJNP_BLOCKSIZE_START; device[dn].last_block = 0; /* fill mac_address */ if (bjnp_get_scanner_mac_address(dn, device[dn].mac_address) != 0 ) { PDBG (bjnp_dbg (LOG_CRIT, "bjnp_init_device_structure: Cannot read mac address, skipping this scanner\n" ) ); device[dn].open = 0; return -1; } device[dn].open = 1; return 0; } static void bjnp_free_device_structure( int dn) { if (device[dn].addr != NULL) { free (device[dn].addr ); device[dn].addr = NULL; } device[dn].open = 0; } static SANE_Status bjnp_recv_data (int devno, SANE_Byte * buffer, size_t start_pos, size_t * len) { /* * This function receives the payload data. * NOTE: len may not exceed SSIZE_MAX (as that is max for recv) * len will be restricted to SSIZE_MAX to be sure * Returns: number of bytes of payload received from device */ fd_set input; struct timeval timeout; ssize_t recv_bytes; int terrno; int result; int fd; int attempt; PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_recv_data: read response payload (0x%lx bytes max), buffer: 0x%lx, start_pos: 0x%lx\n", (long) *len, (long) buffer, (long) start_pos)); if (*len == 0) { /* nothing to do */ PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_recv_data: Nothing to do (%ld bytes requested)\n", (long) *len)); return SANE_STATUS_GOOD; } else if ( *len > SSIZE_MAX ) { PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_recv_data: WARNING - requested block size (%ld) exceeds maximum, setting to maximum %ld\n", (long)*len, SSIZE_MAX)); *len = SSIZE_MAX; } fd = device[devno].tcp_socket; attempt = 0; do { /* wait for data to be received, retry on a signal being received */ FD_ZERO (&input); FD_SET (fd, &input); timeout.tv_sec = device[devno].bjnp_ip_timeout /1000; timeout.tv_usec = device[devno].bjnp_ip_timeout %1000; } while (((result = select (fd + 1, &input, NULL, NULL, &timeout)) <= 0) && (errno == EINTR) && (attempt++ < BJNP_MAX_SELECT_ATTEMPTS)); if (result < 0) { terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_data: ERROR - could not read response payload (select failed): %s!\n", strerror (errno))); errno = terrno; *len = 0; return SANE_STATUS_IO_ERROR; } else if (result == 0) { terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_data: ERROR - could not read response payload (select timed out after %d ms)!\n", device[devno].bjnp_ip_timeout) ); errno = terrno; *len = 0; return SANE_STATUS_IO_ERROR; } if ((recv_bytes = recv (fd, buffer + start_pos, *len, 0)) < 0) { terrno = errno; PDBG (bjnp_dbg (LOG_CRIT, "bjnp_recv_data: ERROR - could not read response payload (%ld + %ld = %ld) (recv): %s!\n", (long) buffer, (long) start_pos, (long) buffer + start_pos, strerror (errno))); errno = terrno; *len = 0; return SANE_STATUS_IO_ERROR; } PDBG (bjnp_dbg (LOG_DEBUG2, "bjnp_recv_data: Received TCP response payload (%ld bytes):\n", (unsigned long) recv_bytes)); PDBG (bjnp_hexdump (LOG_DEBUG2, buffer, recv_bytes)); *len = recv_bytes; return SANE_STATUS_GOOD; } static BJNP_Status bjnp_allocate_device (SANE_String_Const devname, SANE_Int * dn, char *resulting_host) { char method[BJNP_METHOD_MAX]; char host[BJNP_HOST_MAX]; char port[BJNP_PORT_MAX] = ""; char args[BJNP_ARGS_MAX]; bjnp_protocol_defs_t *protocol_defs; struct addrinfo *res, *cur; struct addrinfo hints; int result; int i; int ip_timeout = BJNP_TIMEOUT_DEFAULT; PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_allocate_device(%s) %d\n", devname, bjnp_no_devices)); if (split_uri (devname, method, host, port, args) != 0) { return BJNP_STATUS_INVAL; } if (strlen (args) > 0) { /* get device specific ip timeout if any */ if (strncmp(args, "timeout=", strlen("timeout=")) == 0) { ip_timeout = atoi(args + strlen("timeout=")); } 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)); return BJNP_STATUS_INVAL; } if (strlen(port) == 0) { sprintf( port, "%d", protocol_defs->default_port ); } hints.ai_flags = 0; #ifdef ENABLE_IPV6 hints.ai_family = AF_UNSPEC; #else hints.ai_family = AF_INET; #endif hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = 0; hints.ai_addrlen = 0; hints.ai_addr = NULL; hints.ai_canonname = NULL; hints.ai_next = NULL; result = getaddrinfo (host, port, &hints, &res ); if (result != 0 ) { PDBG (bjnp_dbg (LOG_CRIT, "bjnp_allocate_device: ERROR - Cannot resolve host: %s port %s\n", host, port)); return SANE_STATUS_INVAL; } /* Check if a device number is already allocated to any of the scanner's addresses */ cur = res; while( cur != NULL) { /* create a new device structure for this address */ if (bjnp_no_devices == BJNP_NO_DEVICES) { PDBG (bjnp_dbg (LOG_CRIT, "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, ip_timeout) != 0) { /* giving up on this address, try next one if any */ cur = cur->ai_next; continue; } for (i = 0; i < bjnp_no_devices; i++) { /* 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 ) { /* use the new address instead as it is better */ free (device[i].addr); device[i].addr = device[bjnp_no_devices].addr; device[bjnp_no_devices].addr = NULL; device[i].address_level = device[bjnp_no_devices].address_level; } /* Leave timeout values unchanged, as they were probably specified by the user */ freeaddrinfo(res); *dn = i; bjnp_free_device_structure( bjnp_no_devices); return BJNP_STATUS_ALREADY_ALLOCATED; } } cur = cur->ai_next; } freeaddrinfo(res); if (device[bjnp_no_devices].open == 0) { PDBG (bjnp_dbg(LOG_NOTICE, "bjnp_allocate_device: Cannot access scanner, skipping!")); return BJNP_STATUS_INVAL; } PDBG (bjnp_dbg (LOG_INFO, "bjnp_allocate_device: Scanner not yet in our list, added it: %s:%s\n", host, port)); /* Commit new device structure */ *dn = bjnp_no_devices; bjnp_no_devices++; /* return hostname if required */ if (resulting_host != NULL) { strcpy (resulting_host, host); } return BJNP_STATUS_GOOD; } static void add_scanner(SANE_Int *dev_no, const char *uri, SANE_Status (*attach_bjnp) (SANE_String_Const devname, SANE_String_Const serial, const struct pixma_config_t *cfg), const struct pixma_config_t *const pixma_devices[]) { char scanner_host[BJNP_HOST_MAX]; char serial[BJNP_SERIAL_MAX]; char makemodel[BJNP_MODEL_MAX]; const struct pixma_config_t *cfg = NULL; /* Allocate device structure for scanner */ switch (bjnp_allocate_device (uri, dev_no, scanner_host)) { case BJNP_STATUS_GOOD: if (get_scanner_id (*dev_no, makemodel) != 0) { PDBG (bjnp_dbg (LOG_CRIT, "add_scanner: ERROR - Cannot read scanner make & model: %s\n", uri)); } else { /* * fetch scanner configuration */ if ((cfg = lookup_scanner(makemodel, pixma_devices)) == (struct pixma_config_t *)NULL) { PDBG (bjnp_dbg (LOG_CRIT, "add_scanner: Scanner %s is not supported, model is unknown! Please report upstream\n", makemodel)); break; } /* * inform caller of found scanner */ determine_scanner_serial (scanner_host, device[*dev_no].mac_address, serial); switch (attach_bjnp (uri, serial, cfg)) { case SANE_STATUS_GOOD: PDBG (bjnp_dbg (LOG_NOTICE, "add_scanner: New scanner added: %s, serial %s, mac address: %s.\n", uri, serial, device[*dev_no].mac_address)); break; default: PDBG (bjnp_dbg (LOG_CRIT, "add_scanner: unexpected error (out of memory?), adding %s\n", makemodel)); } } break; case BJNP_STATUS_ALREADY_ALLOCATED: PDBG (bjnp_dbg (LOG_NOTICE, "add_scanner: Scanner at %s was added before, good!\n", uri)); break; case BJNP_STATUS_INVAL: PDBG (bjnp_dbg (LOG_NOTICE, "add_scanner: Scanner at %s can not be added\n", uri)); break; } } int add_timeout_to_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; bjnp_protocol_defs_t *proto_struct; if (split_uri(uri, method, host, port_str, args ) != 0) { return -1; } port = atoi(port_str); if (port == 0) { proto_struct = get_protocol_by_method(method); if (proto_struct == NULL) { PDBG (bjnp_dbg (LOG_NOTICE, "uri: %s: Method %s cannot be recognized\n", uri, method)); } else { port = proto_struct-> default_port; } } /* add timeout value only if missing in URI */ if (strstr(args, "timeout=") == NULL) { sprintf(args, "timeout=%d", timeout); } snprintf(uri, max_len -1, "%s://%s:%d/%s", method,host, port, args); uri[max_len - 1] = '\0'; return 0; } /** Public functions **/ /** Initialize sanei_bjnp. * * Call this before any other sanei_bjnp function. */ extern void sanei_bjnp_init (void) { DBG_INIT(); bjnp_no_devices = 0; } /** * Find devices that implement the bjnp protocol * * The function attach is called for every device which has been found. * * @param attach attach function * * @return SANE_STATUS_GOOD - on success (even if no scanner was found) */ extern SANE_Status sanei_bjnp_find_devices (const char **conf_devices, SANE_Status (*attach_bjnp) (SANE_String_Const devname, SANE_String_Const serial, const struct pixma_config_t *cfg), const struct pixma_config_t *const pixma_devices[]) { int numbytes = 0; struct BJNP_command cmd; unsigned char resp_buf[2048]; struct DISCOVER_RESPONSE *disc_resp = ( struct DISCOVER_RESPONSE *) & resp_buf; int socket_fd[BJNP_SOCK_MAX]; int no_sockets; int i; int j; int attempt; int last_socketfd = 0; fd_set fdset; fd_set active_fdset; struct timeval timeout; char scanner_host[HOST_NAME_MAX]; char uri[HOST_NAME_MAX + 32]; int dev_no; int port; int auto_detect = 1; int timeout_default = BJNP_TIMEOUT_DEFAULT; bjnp_sockaddr_t broadcast_addr[BJNP_SOCK_MAX]; bjnp_sockaddr_t scanner_sa; socklen_t socklen; bjnp_protocol_defs_t *protocol_defs; memset( broadcast_addr, 0, sizeof( broadcast_addr) ); memset( &scanner_sa, 0 ,sizeof( scanner_sa ) ); PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_find_devices, pixma backend version: %d.%d.%d\n", PIXMA_VERSION_MAJOR, PIXMA_VERSION_MINOR, PIXMA_VERSION_BUILD)); bjnp_no_devices = 0; for (i=0; i < BJNP_SOCK_MAX; i++) { socket_fd[i] = -1; } /* parse config file */ if (conf_devices[0] != NULL) { if (strcmp(conf_devices[0], "networking=no") == 0) { /* networking=no may only occur on the first non-commented line */ PDBG (bjnp_dbg( LOG_DEBUG, "sanei_bjnp_find_devices: Networked scanner detection is disabled in configuration file.\n" ) ); return SANE_STATUS_GOOD; } /* parse configuration file */ 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=") ); PDBG ( bjnp_dbg (LOG_DEBUG, "Set new default timeout value: %d ms.", timeout_default)); continue; } else if (strncmp(conf_devices[i], "auto_detection=no", strlen("auto_detection=no"))== 0) { auto_detect = 0; PDBG ( bjnp_dbg (LOG_DEBUG, "sanei_bjnp_find_devices: auto detection of scanners disabled")); continue; } else { PDBG (bjnp_dbg (LOG_DEBUG, "sanei_bjnp_find_devices: Adding scanner from pixma.conf: %s\n", conf_devices[i])); memcpy(uri, conf_devices[i], sizeof(uri)); add_timeout_to_uri(uri, timeout_default, sizeof(uri)); add_scanner(&dev_no, uri, attach_bjnp, pixma_devices); } } PDBG (bjnp_dbg (LOG_DEBUG, "sanei_bjnp_find_devices: Added all specified scanners.\n")); } else { PDBG (bjnp_dbg( LOG_DEBUG, "sanei_bjnp_find_devices: Configuration file is empty, No devices specified.\n" ) ); } if (auto_detect == 0) { return SANE_STATUS_GOOD; } /* * Send UDP DISCOVER to discover scanners and return the list of scanners found */ PDBG (bjnp_dbg( LOG_DEBUG, "sanei_bjnp_find_devices: Start auto-detection.\n" ) ); FD_ZERO (&fdset); no_sockets = 0; #ifdef HAVE_IFADDRS_H { struct ifaddrs *interfaces = NULL; struct ifaddrs *interface; getifaddrs (&interfaces); /* create a socket for each suitable interface */ interface = interfaces; while ((no_sockets < BJNP_SOCK_MAX) && (interface != NULL)) { if ( ! (interface -> ifa_flags & IFF_POINTOPOINT) && ( (socket_fd[no_sockets] = prepare_socket( interface -> ifa_name, (bjnp_sockaddr_t *) interface -> ifa_addr, (bjnp_sockaddr_t *) interface -> ifa_broadaddr, &broadcast_addr[no_sockets] ) ) != -1 ) ) { /* track highest used socket for later use in select */ if (socket_fd[no_sockets] > last_socketfd) { last_socketfd = socket_fd[no_sockets]; } FD_SET (socket_fd[no_sockets], &fdset); no_sockets++; } interface = interface->ifa_next; } freeifaddrs (interfaces); } #else /* we have no easy way to find interfaces with their broadcast addresses. */ /* use global broadcast and all-hosts instead */ { bjnp_sockaddr_t local; bjnp_sockaddr_t bc_addr; memset( &local, 0, sizeof( local) ); local.ipv4.sin_family = AF_INET; local.ipv4.sin_addr.s_addr = htonl (INADDR_ANY); bc_addr.ipv4.sin_family = AF_INET; bc_addr.ipv4.sin_port = htons(0); bc_addr.ipv4.sin_addr.s_addr = htonl (INADDR_BROADCAST); socket_fd[no_sockets] = prepare_socket( "any_interface", &local, &bc_addr, &broadcast_addr[no_sockets] ); if (socket_fd[no_sockets] >= 0) { FD_SET (socket_fd[no_sockets], &fdset); if (socket_fd[no_sockets] > last_socketfd) { last_socketfd = socket_fd[no_sockets]; } no_sockets++; } #ifdef ENABLE_IPV6 local.ipv6.sin6_family = AF_INET6; local.ipv6.sin6_addr = in6addr_any; socket_fd[no_sockets] = prepare_socket( "any_interface", &local, NULL, &broadcast_addr[no_sockets] ); if (socket_fd[no_sockets] >= 0) { FD_SET (socket_fd[no_sockets], &fdset); if (socket_fd[no_sockets] > last_socketfd) { last_socketfd = socket_fd[no_sockets]; } no_sockets++; } #endif } #endif /* send BJNP_MAX_BROADCAST_ATTEMPTS broadcasts on each prepared socket */ for (attempt = 0; attempt < BJNP_MAX_BROADCAST_ATTEMPTS; attempt++) { for ( i=0; i < no_sockets; i++) { j = 0; while(bjnp_protocol_defs[j].protocol_version != PROTOCOL_NONE) { set_cmd_from_string (bjnp_protocol_defs[j].proto_string, &cmd, CMD_UDP_DISCOVER, 0); bjnp_send_broadcast ( socket_fd[i], &broadcast_addr[i], bjnp_protocol_defs[j].default_port, cmd, sizeof (cmd)); j++; } } /* wait for some time between broadcast packets */ usleep (BJNP_BROADCAST_INTERVAL * BJNP_USLEEP_MS); } /* wait for a UDP response */ timeout.tv_sec = 0; timeout.tv_usec = BJNP_BC_RESPONSE_TIMEOUT * BJNP_USLEEP_MS; active_fdset = fdset; while (select (last_socketfd + 1, &active_fdset, NULL, NULL, &timeout) > 0) { PDBG (bjnp_dbg (LOG_DEBUG, "sanei_bjnp_find_devices: Select returned, time left %d.%d....\n", (int) timeout.tv_sec, (int) timeout.tv_usec)); for (i = 0; i < no_sockets; i++) { if (FD_ISSET (socket_fd[i], &active_fdset)) { socklen = sizeof(scanner_sa); if ((numbytes = recvfrom (socket_fd[i], resp_buf, sizeof (resp_buf), 0, &(scanner_sa.addr), &socklen ) ) == -1) { PDBG (bjnp_dbg (LOG_INFO, "sanei_find_devices: no data received")); break; } else { PDBG (bjnp_dbg (LOG_DEBUG2, "sanei_find_devices: Discover response:\n")); PDBG (bjnp_hexdump (LOG_DEBUG2, &resp_buf, numbytes)); /* check if something sensible is returned */ protocol_defs = get_protocol_by_proto_string(disc_resp-> response.BJNP_id); if ( (numbytes < (int)sizeof (struct BJNP_command)) || (protocol_defs == NULL)) { /* not a valid response, assume not a scanner */ char bjnp_id[5]; strncpy(bjnp_id, disc_resp-> response.BJNP_id, 4); bjnp_id[4] = '\0'; PDBG (bjnp_dbg (LOG_INFO, "sanei_find_devices: Invalid discover response! Length = %d, Id = %s\n", numbytes, bjnp_id ) ); break; } if ( !(disc_resp -> response.dev_type & 0x80) ) { /* not a response, a command from somebody else or */ /* a discover command that we generated */ break; } }; port = get_port_from_sa(scanner_sa); /* scanner found, get IP-address or hostname */ get_scanner_name( &scanner_sa, scanner_host); /* construct URI */ 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); } } active_fdset = fdset; timeout.tv_sec = 0; timeout.tv_usec = BJNP_BC_RESPONSE_TIMEOUT * BJNP_USLEEP_MS; } PDBG (bjnp_dbg (LOG_DEBUG, "sanei_find_devices: scanner discovery finished...\n")); for (i = 0; i < no_sockets; i++) close (socket_fd[i]); return SANE_STATUS_GOOD; } /** Open a BJNP device. * * The device is opened by its name devname and the device number is * returned in dn on success. * * Device names consist of an URI * Where: * type = bjnp * hostname = resolvable name or IP-address * port = 8612 for a scanner * An example could look like this: bjnp://host.domain:8612 * * @param devname name of the device to open * @param dn device number * * @return * - SANE_STATUS_GOOD - on success * - SANE_STATUS_ACCESS_DENIED - if the file couldn't be accessed due to * permissions * - SANE_STATUS_INVAL - on every other error */ extern SANE_Status sanei_bjnp_open (SANE_String_Const devname, SANE_Int * dn) { int result; PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_open(%s, %d):\n", devname, *dn)); result = bjnp_allocate_device (devname, dn, NULL); if ( (result != BJNP_STATUS_GOOD) && (result != BJNP_STATUS_ALREADY_ALLOCATED ) ) { return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /** Close a BJNP device. * * @param dn device number */ void sanei_bjnp_close (SANE_Int dn) { PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_close(%d):\n", dn)); device[dn].open = 0; sanei_bjnp_deactivate(dn); } /** Activate BJNP device connection * * @param dn device number */ SANE_Status sanei_bjnp_activate (SANE_Int dn) { char hostname[256]; char pid_str[64]; PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_activate (%d)\n", dn)); gethostname (hostname, 256); hostname[255] = '\0'; sprintf (pid_str, "Process ID = %d", getpid ()); bjnp_send_job_details (dn, hostname, getusername (), pid_str); if (bjnp_open_tcp (dn) != 0) { return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /** Deactivate BJNP device connection * * @paran dn device number */ SANE_Status sanei_bjnp_deactivate (SANE_Int dn) { PDBG (bjnp_dbg (LOG_INFO, "sanei_bjnp_deactivate (%d)\n", dn)); if ( device[dn].tcp_socket != -1) { bjnp_finish_job (dn); close (device[dn].tcp_socket); device[dn].tcp_socket = -1; } return SANE_STATUS_GOOD; } /** Set the timeout for interrupt reads. * we do not use it for bulk reads! * @param timeout the new timeout in ms */ extern void sanei_bjnp_set_timeout (SANE_Int devno, SANE_Int timeout) { PDBG (bjnp_dbg (LOG_INFO, "bjnp_set_timeout to %d\n", timeout)); device[devno].bjnp_scanner_timeout = timeout; } /** Initiate a bulk transfer read. * * Read up to size bytes from the device to buffer. After the read, size * contains the number of bytes actually read. * * @param dn device number * @param buffer buffer to store read data in * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_bjnp_read_bulk (SANE_Int dn, SANE_Byte * buffer, size_t * size) { SANE_Status result; SANE_Status error; size_t recvd; size_t read_size; size_t read_size_max; size_t requested; PDBG (bjnp_dbg (LOG_INFO, "bjnp_read_bulk(dn=%d, bufferptr=%lx, 0x%lx = %ld)\n", dn, (long) buffer, (unsigned long) *size, (unsigned long) *size)); recvd = 0; requested = *size; PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: 0x%lx = %ld bytes available at start\n", (unsigned long) device[dn].scanner_data_left, (unsigned long) device[dn].scanner_data_left ) ); while ( (recvd < requested) && !( device[dn].last_block && (device[dn].scanner_data_left == 0)) ) { PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: Already received 0x%lx = %ld bytes, backend requested 0x%lx = %ld bytes\n", (unsigned long) recvd, (unsigned long) recvd, (unsigned long) requested, (unsigned long)requested )); /* Check first if there is data in flight from the scanner */ if (device[dn].scanner_data_left == 0) { /* There is no data in flight from the scanner, send new read request */ PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: No (more) scanner data available, requesting more( blocksize = %ld = %lx\n", (long int) device[dn].blocksize, (long int) device[dn].blocksize )); if ((error = bjnp_send_read_request (dn)) != SANE_STATUS_GOOD) { *size = recvd; return SANE_STATUS_IO_ERROR; } if ( ( error = bjnp_recv_header (dn, &(device[dn].scanner_data_left) ) ) != SANE_STATUS_GOOD) { *size = recvd; return SANE_STATUS_IO_ERROR; } /* correct blocksize if applicable */ device[dn].blocksize = MAX (device[dn].blocksize, device[dn].scanner_data_left); if ( device[dn].scanner_data_left < device[dn].blocksize) { /* the scanner will not react at all to a read request, when no more data is available */ /* we now determine end of data by comparing the payload size to the maximun blocksize */ /* this block is shorter than blocksize, so after this block we are done */ device[dn].last_block = 1; } } PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: In flight: 0x%lx = %ld bytes available\n", (unsigned long) device[dn].scanner_data_left, (unsigned long) device[dn].scanner_data_left)); /* read as many bytes as needed and available */ read_size_max = MIN( device[dn].scanner_data_left, (requested - recvd) ); read_size = read_size_max; PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: Try to read 0x%lx = %ld (of max 0x%lx = %ld) bytes\n", (unsigned long) read_size_max, (unsigned long) read_size_max, (unsigned long) device[dn].scanner_data_left, (unsigned long) device[dn].scanner_data_left) ); result = bjnp_recv_data (dn, buffer , recvd, &read_size); if (result != SANE_STATUS_GOOD) { *size = recvd; return SANE_STATUS_IO_ERROR; } PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: Expected at most %ld bytes, received this time: %ld\n", read_size_max, read_size) ); device[dn].scanner_data_left = device[dn].scanner_data_left - read_size; recvd = recvd + read_size; } PDBG (bjnp_dbg (LOG_DEBUG, "bjnp_read_bulk: %s: Returning %ld bytes, backend expexts %ld\n", (recvd == *size)? "OK": "NOTICE",recvd, *size ) ); *size = recvd; if ( *size == 0 ) return SANE_STATUS_EOF; return SANE_STATUS_GOOD; } /** Initiate a bulk transfer write. * * Write up to size bytes from buffer to the device. After the write size * contains the number of bytes actually written. * * @param dn device number * @param buffer buffer to write to device * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_IO_ERROR - if an error occured during the write * - SANE_STATUS_INVAL - on every other error */ extern SANE_Status sanei_bjnp_write_bulk (SANE_Int dn, const SANE_Byte * buffer, size_t * size) { ssize_t sent; size_t recvd; uint32_t buf; size_t payload_size; /* Write received data to scanner */ sent = bjnp_write (dn, buffer, *size); if (sent < 0) return SANE_STATUS_IO_ERROR; if (sent != (int) *size) { PDBG (bjnp_dbg (LOG_CRIT, "sanei_bjnp_write_bulk: ERROR - Sent only %ld bytes to scanner, expected %ld!!\n", (unsigned long) sent, (unsigned long) *size)); return SANE_STATUS_IO_ERROR; } if (bjnp_recv_header (dn, &payload_size) != SANE_STATUS_GOOD) { PDBG (bjnp_dbg (LOG_CRIT, "sanei_bjnp_write_bulk: ERROR - Could not read response to command!\n")); return SANE_STATUS_IO_ERROR; } if (payload_size != 4) { PDBG (bjnp_dbg (LOG_CRIT, "sanei_bjnp_write_bulk: ERROR - Scanner length of write confirmation = 0x%lx bytes = %ld, expected %d!!\n", (unsigned long) payload_size, (unsigned long) payload_size, 4)); return SANE_STATUS_IO_ERROR; } recvd = payload_size; if ((bjnp_recv_data (dn, (unsigned char *) &buf, 0, &recvd) != SANE_STATUS_GOOD) || (recvd != payload_size)) { PDBG (bjnp_dbg (LOG_CRIT, "sanei_bjnp_write_bulk: ERROR - Could not read length of data confirmed by device\n")); return SANE_STATUS_IO_ERROR; } recvd = ntohl (buf); if (recvd != *size) { PDBG (bjnp_dbg (LOG_CRIT, "sanei_bjnp_write_bulk: ERROR - Scanner confirmed %ld bytes, expected %ld!!\n", (unsigned long) recvd, (unsigned long) *size)); return SANE_STATUS_IO_ERROR; } /* we can expect data from the scanner */ device[dn].last_block = 0; return SANE_STATUS_GOOD; } /** Initiate a interrupt transfer read. * * Read up to size bytes from the interrupt endpoint from the device to * buffer. After the read, size contains the number of bytes actually read. * * @param dn device number * @param buffer buffer to store read data in * @param size size of the data * * @return * - SANE_STATUS_GOOD - on succes * - SANE_STATUS_EOF - if zero bytes have been read * - SANE_STATUS_IO_ERROR - if an error occured during the read * - SANE_STATUS_INVAL - on every other error * */ extern SANE_Status sanei_bjnp_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) { #ifndef PIXMA_BJNP_USE_STATUS PDBG (bjnp_dbg (LOG_INFO, "bjnp_read_int(%d, bufferptr, 0x%lx = %ld):\n", dn, (unsigned long) *size, (unsigned long) *size)); memset (buffer, 0, *size); sleep (1); return SANE_STATUS_IO_ERROR; #else char hostname[256]; int resp_len; int timeout; int interval; PDBG (bjnp_dbg (LOG_INFO, "bjnp_read_int(%d, bufferptr, 0x%lx = %ld):\n", dn, (unsigned long) *size, (unsigned long) *size)); memset (buffer, 0, *size); gethostname (hostname, 32); hostname[32] = '\0'; switch (device[dn].polling_status) { case BJNP_POLL_STOPPED: /* establish dialog */ if ( (bjnp_poll_scanner (dn, 0, hostname, getusername (), buffer, *size ) != 0) || (bjnp_poll_scanner (dn, 1, hostname, getusername (), buffer, *size ) != 0) ) { PDBG (bjnp_dbg (LOG_NOTICE, "bjnp_read_int: WARNING - Failed to setup read_intr dialog with device!\n")); device[dn].dialog = 0; device[dn].status_key = 0; return SANE_STATUS_IO_ERROR; } device[dn].polling_status = BJNP_POLL_STARTED; /* fall through */ case BJNP_POLL_STARTED: /* we use only seonds (rounded up) accuracy between poll attempts */ timeout = device[dn].bjnp_scanner_timeout /1000 + 1; if (device[dn].bjnp_scanner_timeout %1000 > 0) { timeout++; } interval = 1; do { if ( (resp_len = bjnp_poll_scanner (dn, 2, hostname, getusername (), buffer, *size ) ) < 0 ) { PDBG (bjnp_dbg (LOG_NOTICE, "bjnp_read_int: Poll failed, Restarting polling dialog!\n")); device[dn].polling_status = BJNP_POLL_STOPPED; *size = 0; return SANE_STATUS_EOF; } *size = (size_t) resp_len; if ( resp_len > 0 ) { device[dn].polling_status = BJNP_POLL_STATUS_RECEIVED; return SANE_STATUS_GOOD; } timeout = timeout - interval; if (timeout <= 0) return SANE_STATUS_EOF; sleep(interval); } while ( timeout > 0 ) ; break; case BJNP_POLL_STATUS_RECEIVED: if ( (resp_len = bjnp_poll_scanner (dn, 5, hostname, getusername (), buffer, *size ) ) < 0 ) { PDBG (bjnp_dbg (LOG_NOTICE, "bjnp_read_int: Restarting polling dialog!\n")); device[dn].polling_status = BJNP_POLL_STOPPED; *size = 0; break; } } return SANE_STATUS_EOF; #endif } sane-backends-1.0.29/backend/pixma/pixma_common.c0000666000000000000000000007331313615534521016547 00000000000000/* SANE - Scanner Access Now Easy. Copyright (C) 2011-2019 Rolf Bensch Copyright (C) 2007-2008 Nicolas Martin, Copyright (C) 2006-2007 Wittawat Yamwong 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "../include/sane/config.h" #include #include #include #include #include /* pow(C90) */ #include /* gettimeofday(4.3BSD) */ #include /* usleep */ #include "pixma_rename.h" #include "pixma_common.h" #include "pixma_io.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sane.h" #ifdef __GNUC__ # define UNUSED(v) (void) v #else # define UNUSED(v) #endif extern const pixma_config_t pixma_mp150_devices[]; extern const pixma_config_t pixma_mp750_devices[]; extern const pixma_config_t pixma_mp730_devices[]; extern const pixma_config_t pixma_mp800_devices[]; extern const pixma_config_t pixma_iclass_devices[]; static const pixma_config_t *const pixma_devices[] = { pixma_mp150_devices, pixma_mp750_devices, pixma_mp730_devices, pixma_mp800_devices, pixma_iclass_devices, NULL }; static pixma_t *first_pixma = NULL; static time_t tstart_sec = 0; static uint32_t tstart_usec = 0; static int debug_level = 1; #ifndef NDEBUG static void u8tohex (uint8_t x, char *str) { static const char hdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; str[0] = hdigit[(x >> 4) & 0xf]; str[1] = hdigit[x & 0xf]; str[2] = '\0'; } static void u32tohex (uint32_t x, char *str) { u8tohex (x >> 24, str); u8tohex (x >> 16, str + 2); u8tohex (x >> 8, str + 4); u8tohex (x, str + 6); } void pixma_hexdump (int level, const void *d_, unsigned len) { const uint8_t *d = (const uint8_t *) (d_); unsigned ofs, c, plen; char line[100]; /* actually only 1+8+1+8*3+1+8*3+1 = 61 bytes needed */ if (level > debug_level) return; if (level == debug_level) /* if debuglevel == exact match and buffer contains more than 3 lines, print 2 lines + .... */ plen = (len > 64) ? 32: len; else plen = len; ofs = 0; while (ofs < plen) { char *p; line[0] = ' '; u32tohex (ofs, line + 1); line[9] = ':'; p = line + 10; for (c = 0; c != 16 && (ofs + c) < plen; c++) { u8tohex (d[ofs + c], p); p[2] = ' '; p += 3; if (c == 7) { p[0] = ' '; p++; } } p[0] = '\0'; pixma_dbg (level, "%s\n", line); ofs += c; } if (len > plen) pixma_dbg(level, "......\n"); } static void time2str (char *buf, unsigned size) { time_t sec; uint32_t usec; pixma_get_time (&sec, &usec); sec -= tstart_sec; if (usec >= tstart_usec) { usec -= tstart_usec; } else { usec = 1000000 + usec - tstart_usec; sec--; } snprintf (buf, size, "%lu.%03u", (unsigned long) sec, (unsigned) (usec / 1000)); } void pixma_dump (int level, const char *type, const void *data, int len, int size, int max) { int actual_len, print_len; char buf[20]; if (level > debug_level) return; if (debug_level >= 20) max = -1; /* dump every bytes */ time2str (buf, sizeof (buf)); pixma_dbg (level, "%s T=%s len=%d\n", type, buf, len); actual_len = (size >= 0) ? size : len; print_len = (max >= 0 && max < actual_len) ? max : actual_len; if (print_len >= 0) { pixma_hexdump (level, data, print_len); if (print_len < actual_len) pixma_dbg (level, " ...\n"); } if (len < 0) pixma_dbg (level, " ERROR: %s\n", pixma_strerror (len)); pixma_dbg (level, "\n"); } #endif /* NDEBUG */ /* NOTE: non-reentrant */ const char * pixma_strerror (int error) { static char buf[50]; /* TODO: more human friendly messages */ switch (error) { case PIXMA_EIO: return "EIO"; case PIXMA_ENODEV: return "ENODEV"; case PIXMA_EACCES: return "EACCES"; case PIXMA_ENOMEM: return "ENOMEM"; case PIXMA_EINVAL: return "EINVAL"; case PIXMA_EBUSY: return "EBUSY"; case PIXMA_ECANCELED: return "ECANCELED"; case PIXMA_ENOTSUP: return "ENOTSUP"; case PIXMA_ETIMEDOUT: return "ETIMEDOUT"; case PIXMA_EPROTO: return "EPROTO"; case PIXMA_EPAPER_JAMMED: return "EPAPER_JAMMED"; case PIXMA_ECOVER_OPEN: return "ECOVER_OPEN"; case PIXMA_ENO_PAPER: return "ENO_PAPER"; case PIXMA_EOF: return "EEOF"; } snprintf (buf, sizeof (buf), "EUNKNOWN:%d", error); return buf; } void pixma_set_debug_level (int level) { debug_level = level; } void pixma_set_be16 (uint16_t x, uint8_t * buf) { buf[0] = x >> 8; buf[1] = x; } void pixma_set_be32 (uint32_t x, uint8_t * buf) { buf[0] = x >> 24; buf[1] = x >> 16; buf[2] = x >> 8; buf[3] = x; } uint16_t pixma_get_be16 (const uint8_t * buf) { return ((uint16_t) buf[0] << 8) | buf[1]; } uint32_t pixma_get_be32 (const uint8_t * buf) { return ((uint32_t) buf[0] << 24) + ((uint32_t) buf[1] << 16) + ((uint32_t) buf[2] << 8) + buf[3]; } uint8_t pixma_sum_bytes (const void *data, unsigned len) { const uint8_t *d = (const uint8_t *) data; unsigned i, sum = 0; for (i = 0; i != len; i++) sum += d[i]; return sum; } void pixma_sleep (unsigned long usec) { usleep (usec); } void pixma_get_time (time_t * sec, uint32_t * usec) { struct timeval tv; gettimeofday (&tv, NULL); if (sec) *sec = tv.tv_sec; if (usec) *usec = tv.tv_usec; } /* convert 24/48 bit RGB to 8/16 bit ir * * Formular: g = R * drop G + B * * sptr: source color scale buffer * gptr: destination gray scale buffer * c == 3: 24 bit RGB -> 8 bit ir * c == 6: 48 bit RGB -> 16 bit ir */ uint8_t * pixma_r_to_ir (uint8_t * gptr, uint8_t * sptr, unsigned w, unsigned c) { unsigned i; /* PDBG (pixma_dbg (4, "*pixma_rgb_to_ir*****\n")); */ for (i = 0; i < w; i++) { *gptr++ = *sptr++; if (c == 6) *gptr++ = *sptr++; /* 48 bit RGB: high byte */ sptr += (c == 6) ? 4 : 2; /* drop G + B */ } return gptr; } /* convert 24/48 bit RGB to 8/16 bit grayscale * * Formular: g = (R + G + B) / 3 * * sptr: source color scale buffer * gptr: destination gray scale buffer * c == 3: 24 bit RGB -> 8 bit gray * c == 6: 48 bit RGB -> 16 bit gray */ uint8_t * pixma_rgb_to_gray (uint8_t * gptr, uint8_t * sptr, unsigned w, unsigned c) { unsigned i, j, g; /* PDBG (pixma_dbg (4, "*pixma_rgb_to_gray*****\n")); */ for (i = 0; i < w; i++) { for (j = 0, g = 0; j < 3; j++) { g += *sptr++; if (c == 6) g += (*sptr++ << 8); /* 48 bit RGB: high byte */ } g /= 3; /* 8 or 16 bit gray */ *gptr++ = g; if (c == 6) *gptr++ = (g >> 8); /* 16 bit gray: high byte */ } return gptr; } /** * This code was taken from the genesys backend * uses threshold and threshold_curve to control software binarization * @param sp device set up for the scan * @param dst pointer where to store result * @param src pointer to raw data * @param width width of the processed line * @param c 1 for 1-channel single-byte data, * 3 for 3-channel single-byte data, * 6 for double-byte data * */ uint8_t * pixma_binarize_line(pixma_scan_param_t * sp, uint8_t * dst, uint8_t * src, unsigned width, unsigned c) { unsigned j, x, windowX, sum = 0; unsigned threshold; unsigned offset, addCol; int dropCol, offsetX; unsigned char mask; uint8_t min, max; /* PDBG (pixma_dbg (4, "*pixma_binarize_line***** src = %u, dst = %u, width = %u, c = %u, threshold = %u, threshold_curve = %u *****\n", src, dst, width, c, sp->threshold, sp->threshold_curve)); */ /* 16 bit grayscale not supported */ if (c == 6) { PDBG (pixma_dbg (1, "*pixma_binarize_line***** Error: 16 bit grayscale not supported\n")); return dst; } /* first, color convert to grayscale */ if (c != 1) pixma_rgb_to_gray(dst, src, width, c); /* second, normalize line */ min = 255; max = 0; for (x = 0; x < width; x++) { if (src[x] > max) { max = src[x]; } if (src[x] < min) { min = src[x]; } } /* safeguard against dark or white areas */ if(min>80) min=0; if(max<80) max=255; for (x = 0; x < width; x++) { src[x] = ((src[x] - min) * 255) / (max - min); } /* third, create sliding window, prefill the sliding sum */ /* ~1mm works best, but the window needs to have odd # of pixels */ windowX = (6 * sp->xdpi) / 150; if (!(windowX % 2)) windowX++; /* to avoid conflicts with *dst start with offset */ offsetX = 1 + (windowX / 2) / 8; for (j = offsetX; j <= windowX; j++) sum += src[j]; /* PDBG (pixma_dbg (4, " *pixma_binarize_line***** windowX = %u, startX = %u, sum = %u\n", windowX, startX, sum)); */ /* fourth, walk the input buffer, output bits */ for (j = 0; j < width; j++) { /* output image location */ offset = j % 8; mask = 0x80 >> offset; threshold = sp->threshold; /* move sum/update threshold only if there is a curve */ if (sp->threshold_curve) { addCol = j + windowX / 2; dropCol = addCol - windowX; if (dropCol >= offsetX && addCol < width) { sum += src[addCol]; sum -= (sum < src[dropCol] ? sum : src[dropCol]); /* no negative sum */ } threshold = sp->lineart_lut[sum / windowX]; /* PDBG (pixma_dbg (4, " *pixma_binarize_line***** addCol = %u, dropCol = %d, sum = %u, windowX = %u, lut-element = %d, threshold = %u\n", addCol, dropCol, sum, windowX, sum/windowX, threshold)); */ } /* lookup threshold */ if (src[j] > threshold) *dst &= ~mask; /* white */ else *dst |= mask; /* black */ if (offset == 7) dst++; } /* PDBG (pixma_dbg (4, " *pixma_binarize_line***** ready: src = %u, dst = %u *****\n", src, dst)); */ return dst; } /** This code was taken from the genesys backend Function to build a lookup table (LUT), often used by scanners to implement brightness/contrast/gamma or by backends to speed binarization/thresholding offset and slope inputs are -127 to +127 slope rotates line around central input/output val, 0 makes horizontal line pos zero neg . x . . x . x . . x out . x .xxxxxxxxxxx . x . x . . x ....x....... ............ .......x.... in in in offset moves line vertically, and clamps to output range 0 keeps the line crossing the center of the table high low . xxxxxxxx . . x . out x . x . . x ............ xxxxxxxx.... in in out_min/max provide bounds on output values, useful when building thresholding lut. 0 and 255 are good defaults otherwise. * */ static SANE_Status load_lut (unsigned char * lut, int in_bits, int out_bits, int out_min, int out_max, int slope, int offset) { int i, j; double shift, rise; int max_in_val = (1 << in_bits) - 1; int max_out_val = (1 << out_bits) - 1; unsigned char * lut_p = lut; /* PDBG (pixma_dbg (4, "*load_lut***** start %d %d *****\n", slope, offset)); */ /* slope is converted to rise per unit run: * first [-127,127] to [-1,1] * then multiply by PI/2 to convert to radians * then take the tangent (T.O.A) * then multiply by the normal linear slope * because the table may not be square, i.e. 1024x256*/ rise = tan((double)slope/127 * M_PI/2) * max_out_val / max_in_val; /* line must stay vertically centered, so figure * out vertical offset at central input value */ shift = (double)max_out_val/2 - (rise*max_in_val/2); /* convert the user offset setting to scale of output * first [-127,127] to [-1,1] * then to [-max_out_val/2,max_out_val/2]*/ shift += (double)offset / 127 * max_out_val / 2; for(i=0;i<=max_in_val;i++){ j = rise*i + shift; if(jout_max){ j=out_max; } *lut_p=j; lut_p++; } /* PDBG (pixma_dbg (4, "*load_lut***** finish *****\n")); */ /* PDBG (pixma_hexdump (4, lut, max_in_val+1)); */ return SANE_STATUS_GOOD; } int pixma_map_status_errno (unsigned status) { switch (status) { case PIXMA_STATUS_OK: return 0; case PIXMA_STATUS_FAILED: return PIXMA_ECANCELED; case PIXMA_STATUS_BUSY: return PIXMA_EBUSY; default: return PIXMA_EPROTO; } } int pixma_check_result (pixma_cmdbuf_t * cb) { const uint8_t *r = cb->buf; unsigned header_len = cb->res_header_len; unsigned expected_reslen = cb->expected_reslen; int error; unsigned len; if (cb->reslen < 0) return cb->reslen; len = (unsigned) cb->reslen; if (len >= header_len) { error = pixma_map_status_errno (pixma_get_be16 (r)); if (expected_reslen != 0) { if (len == expected_reslen) { if (pixma_sum_bytes (r + header_len, len - header_len) != 0) error = PIXMA_EPROTO; } else { /* This case will happen when a command cannot be completely executed, e.g. because you press the cancel button. The device will return only a header with PIXMA_STATUS_FAILED. */ if (len != header_len) error = PIXMA_EPROTO; } } } else error = PIXMA_EPROTO; #ifndef NDEBUG if (error == PIXMA_EPROTO) { pixma_dbg (1, "WARNING: result len=%d expected %d\n", len, cb->expected_reslen); pixma_hexdump (1, r, MIN (len, 64)); } #endif return error; } int pixma_cmd_transaction (pixma_t * s, const void *cmd, unsigned cmdlen, void *data, unsigned expected_len) { int error, tmo; error = pixma_write (s->io, cmd, cmdlen); if (error != (int) cmdlen) { if (error >= 0) { /* Write timeout is too low? */ PDBG (pixma_dbg (1, "ERROR: incomplete write, %u out of %u written\n", (unsigned) error, cmdlen)); error = PIXMA_ETIMEDOUT; } return error; } /* When you send the start_session command while the scanner optic is going back to the home position after the last scan session has been cancelled, you won't get the response before it arrives home. This takes about 5 seconds. If the last session was succeeded, the scanner will immediatly answer with PIXMA_STATUS_BUSY. Is 8 seconds timeout enough? This affects ALL commands that use 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)); #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); if (error < 0) { PDBG (pixma_dbg (1, "WARNING: Error in response phase. cmd:%02x%02x\n", ((const uint8_t *) cmd)[0], ((const uint8_t *) cmd)[1])); PDBG (pixma_dbg (1," If the scanner hangs, reset it and/or unplug the " "USB cable.\n")); } return error; /* length of the result packet or error */ } uint8_t * pixma_newcmd (pixma_cmdbuf_t * cb, unsigned cmd, unsigned dataout, unsigned datain) { unsigned cmdlen = cb->cmd_header_len + dataout; unsigned reslen = cb->res_header_len + datain; if (cmdlen > cb->size || reslen > cb->size) return NULL; memset (cb->buf, 0, cmdlen); cb->cmdlen = cmdlen; cb->expected_reslen = reslen; pixma_set_be16 (cmd, cb->buf); pixma_set_be16 (dataout + datain, cb->buf + cb->cmd_len_field_ofs); if (dataout != 0) return cb->buf + cb->cmd_header_len; else return cb->buf + cb->res_header_len; } int pixma_exec (pixma_t * s, pixma_cmdbuf_t * cb) { if (cb->cmdlen > cb->cmd_header_len) pixma_fill_checksum (cb->buf + cb->cmd_header_len, cb->buf + cb->cmdlen - 1); cb->reslen = pixma_cmd_transaction (s, cb->buf, cb->cmdlen, cb->buf, cb->expected_reslen); return pixma_check_result (cb); } int pixma_exec_short_cmd (pixma_t * s, pixma_cmdbuf_t * cb, unsigned cmd) { pixma_newcmd (cb, cmd, 0, 0); return pixma_exec (s, cb); } int pixma_check_dpi (unsigned dpi, unsigned max) { /* valid dpi = 75 * 2^n */ unsigned temp = dpi / 75; if (dpi > max || dpi < 75 || 75 * temp != dpi || (temp & (temp - 1)) != 0) return PIXMA_EINVAL; return 0; } int pixma_init (void) { PDBG (pixma_dbg (2, "pixma version %d.%d.%d\n", PIXMA_VERSION_MAJOR, PIXMA_VERSION_MINOR, PIXMA_VERSION_BUILD)); PASSERT (first_pixma == NULL); if (tstart_sec == 0) pixma_get_time (&tstart_sec, &tstart_usec); return pixma_io_init (); } void pixma_cleanup (void) { while (first_pixma) pixma_close (first_pixma); pixma_io_cleanup (); } int pixma_open (unsigned devnr, pixma_t ** handle) { int error; pixma_t *s; const pixma_config_t *cfg; *handle = NULL; cfg = pixma_get_device_config (devnr); if (!cfg) return PIXMA_EINVAL; /* invalid devnr */ PDBG (pixma_dbg (2, "pixma_open(): %s\n", cfg->name)); s = (pixma_t *) calloc (1, sizeof (s[0])); if (!s) return PIXMA_ENOMEM; s->next = first_pixma; 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) { PDBG (pixma_dbg (2, "pixma_connect() failed %s\n", pixma_strerror (error))); goto rollback; } strncpy (s->id, pixma_get_device_id (devnr), sizeof (s->id) - 1); s->ops = s->cfg->ops; s->scanning = 0; error = s->ops->open (s); if (error < 0) goto rollback; error = pixma_deactivate (s->io); if (error < 0) goto rollback; *handle = s; return 0; rollback: PDBG (pixma_dbg (2, "pixma_open() failed %s\n", pixma_strerror (error))); pixma_close (s); return error; } void pixma_close (pixma_t * s) { pixma_t **p; if (!s) return; for (p = &first_pixma; *p && *p != s; p = &((*p)->next)) { } PASSERT (*p); if (!(*p)) return; PDBG (pixma_dbg (2, "pixma_close(): %s\n", s->cfg->name)); if (s->io) { if (s->scanning) { PDBG (pixma_dbg (3, "pixma_close(): scanning in progress, call" " finish_scan()\n")); s->ops->finish_scan (s); } s->ops->close (s); pixma_disconnect (s->io); } *p = s->next; free (s); } int pixma_scan (pixma_t * s, pixma_scan_param_t * sp) { int error; error = pixma_check_scan_param (s, sp); if (error < 0) return error; if (sp->mode == PIXMA_SCAN_MODE_LINEART) { load_lut(sp->lineart_lut, 8, 8, 50, 205, sp->threshold_curve, sp->threshold-127); } #ifndef NDEBUG pixma_dbg (3, "\n"); pixma_dbg (3, "pixma_scan(): start\n"); pixma_dbg (3, " line_size=%"PRIu64" image_size=%"PRIu64" channels=%u depth=%u\n", sp->line_size, sp->image_size, sp->channels, sp->depth); pixma_dbg (3, " dpi=%ux%u offset=(%u,%u) dimension=%ux%u\n", 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 s->param = sp; s->cancel = 0; s->cur_image_size = 0; s->imagebuf.wptr = NULL; s->imagebuf.wend = NULL; s->imagebuf.rptr = NULL; s->imagebuf.rend = NULL; s->underrun = 0; error = s->ops->scan (s); if (error >= 0) { s->scanning = 1; } else { PDBG (pixma_dbg (3, "pixma_scan() failed %s\n", pixma_strerror (error))); } return error; } static uint8_t * fill_pixels (pixma_t * s, uint8_t * ptr, uint8_t * end, uint8_t value) { if (s->cur_image_size < s->param->image_size) { long n = s->param->image_size - s->cur_image_size; if (n > (end - ptr)) n = end - ptr; memset (ptr, value, n); s->cur_image_size += n; ptr += n; } return ptr; } int pixma_read_image (pixma_t * s, void *buf, unsigned len) { int result; pixma_imagebuf_t ib; if (!s->scanning) return 0; if (s->cancel) { result = PIXMA_ECANCELED; goto cancel; } ib = s->imagebuf; /* get rptr and rend */ ib.wptr = (uint8_t *) buf; ib.wend = ib.wptr + len; if (s->underrun) { if (s->cur_image_size < s->param->image_size) { ib.wptr = fill_pixels (s, ib.wptr, ib.wend, 0xff); } else { PDBG (pixma_dbg (3, "pixma_read_image(): completed (underrun detected)\n")); s->scanning = 0; } return ib.wptr - (uint8_t *) buf; } while (ib.wptr != ib.wend) { if (ib.rptr == ib.rend) { ib.rptr = ib.rend = NULL; result = s->ops->fill_buffer (s, &ib); if (result < 0) goto cancel; if (result == 0) { /* end of image? */ s->ops->finish_scan (s); if ((s->cur_image_size != s->param->image_size) && !s->param->mode_jpeg) { pixma_dbg (1, "WARNING:image size mismatches\n"); pixma_dbg (1, " %"PRIu64" expected (%d lines) but %"PRIu64" received (%"PRIu64" lines)\n", s->param->image_size, s->param->h, s->cur_image_size, s->cur_image_size / s->param->line_size); if ((s->cur_image_size % s->param->line_size) != 0) { pixma_dbg (1, "BUG:received data not multiple of line_size\n"); } } if ((s->cur_image_size < s->param->image_size) && !s->param->mode_jpeg) { s->underrun = 1; ib.wptr = fill_pixels (s, ib.wptr, ib.wend, 0xff); } else { PDBG (pixma_dbg (3, "pixma_read_image():completed\n")); s->scanning = 0; } break; } s->cur_image_size += result; PASSERT (s->cur_image_size <= s->param->image_size); } if (ib.rptr) { unsigned count = MIN (ib.rend - ib.rptr, ib.wend - ib.wptr); memcpy (ib.wptr, ib.rptr, count); ib.rptr += count; ib.wptr += count; } } s->imagebuf = ib; /* store rptr and rend */ return ib.wptr - (uint8_t *) buf; cancel: s->ops->finish_scan (s); s->scanning = 0; if (result == PIXMA_ECANCELED) { PDBG (pixma_dbg (3, "pixma_read_image(): cancelled by %sware\n", (s->cancel) ? "soft" : "hard")); } else { PDBG (pixma_dbg (3, "pixma_read_image() failed %s\n", pixma_strerror (result))); } return result; } void pixma_cancel (pixma_t * s) { s->cancel = 1; } int pixma_enable_background (pixma_t * s, int enabled) { return pixma_set_interrupt_mode (s->io, enabled); } int pixma_activate_connection(pixma_t * s) { return pixma_activate (s->io); } int pixma_deactivate_connection(pixma_t * s) { return pixma_deactivate (s->io); } uint32_t pixma_wait_event (pixma_t * s, int timeout /*ms */ ) { unsigned events; if (s->events == PIXMA_EV_NONE && s->ops->wait_event) s->ops->wait_event (s, timeout); events = s->events; s->events = PIXMA_EV_NONE; return events; } #define CLAMP2(x,w,min,max,dpi) do { \ unsigned m = (max) * (dpi) / 75; \ x = MIN(x, m - min); \ w = MIN(w, m - x); \ if (w < min) w = min; \ } while(0) int pixma_check_scan_param (pixma_t * s, pixma_scan_param_t * sp) { unsigned cfg_xdpi; if (!(sp->channels == 3 || (sp->channels == 1 && (s->cfg->cap & PIXMA_CAP_GRAY) != 0))) return PIXMA_EINVAL; /* flatbed: use s->cfg->xdpi * TPU/ADF: use s->cfg->adftpu_max_dpi, if configured with dpi value */ cfg_xdpi = ((sp->source == PIXMA_SOURCE_FLATBED || s->cfg->adftpu_max_dpi == 0) ? s->cfg->xdpi : s->cfg->adftpu_max_dpi); if (pixma_check_dpi (sp->xdpi, cfg_xdpi) < 0 || pixma_check_dpi (sp->ydpi, s->cfg->ydpi) < 0) return PIXMA_EINVAL; /* xdpi must be equal to ydpi except that xdpi = max_xdpi and ydpi = max_ydpi. */ if (!(sp->xdpi == sp->ydpi || (sp->xdpi == cfg_xdpi && sp->ydpi == s->cfg->ydpi))) return PIXMA_EINVAL; if (s->ops->check_param (s, sp) < 0) return PIXMA_EINVAL; /* FIXME: I assume the same minimum width and height for every model. * new scanners need minimum 16 px height * minimum image size: 16 px x 16 px */ CLAMP2 (sp->x, sp->w, 16, s->cfg->width, sp->xdpi); CLAMP2 (sp->y, sp->h, 16, s->cfg->height, sp->ydpi); switch (sp->source) { case PIXMA_SOURCE_FLATBED: break; case PIXMA_SOURCE_TPU: if ((s->cfg->cap & PIXMA_CAP_TPU) != PIXMA_CAP_TPU) { sp->source = PIXMA_SOURCE_FLATBED; PDBG (pixma_dbg (1, "WARNING: TPU unsupported, fallback to flatbed.\n")); } break; case PIXMA_SOURCE_ADF: if ((s->cfg->cap & PIXMA_CAP_ADF) != PIXMA_CAP_ADF) { sp->source = PIXMA_SOURCE_FLATBED; PDBG (pixma_dbg (1, "WARNING: ADF unsupported, fallback to flatbed.\n")); } break; case PIXMA_SOURCE_ADFDUP: if ((s->cfg->cap & PIXMA_CAP_ADFDUP) != PIXMA_CAP_ADFDUP) { if (s->cfg->cap & PIXMA_CAP_ADF) { sp->source = PIXMA_SOURCE_ADF; } else { sp->source = PIXMA_SOURCE_FLATBED; } PDBG (pixma_dbg (1, "WARNING: ADF duplex unsupported, fallback to %d.\n", sp->source)); } break; } if (sp->depth == 0) sp->depth = 8; if ((sp->depth % 8) != 0 && sp->depth != 1) return PIXMA_EINVAL; sp->line_size = 0; if (s->ops->check_param (s, sp) < 0) return PIXMA_EINVAL; if (sp->line_size == 0) sp->line_size = sp->depth / 8 * sp->channels * sp->w; sp->image_size = sp->line_size * sp->h; /* image_size for software lineart is counted in bits */ if (sp->software_lineart == 1) sp->image_size /= 8; return 0; } const char * pixma_get_string (pixma_t * s, pixma_string_index_t i) { switch (i) { case PIXMA_STRING_MODEL: return s->cfg->name; case PIXMA_STRING_ID: return s->id; case PIXMA_STRING_LAST: return NULL; } return NULL; } const pixma_config_t * pixma_get_config (pixma_t * s) { return s->cfg; } void pixma_fill_gamma_table (double gamma, uint8_t * table, unsigned n) { int i; double r_gamma = 1.0 / gamma; double out_scale = 255.0; double in_scale = 1.0 / (n - 1); for (i = 0; (unsigned) i != n; i++) { table[i] = (int) (out_scale * pow (i * in_scale, r_gamma) + 0.5); } } int pixma_find_scanners (const char **conf_devices, SANE_Bool local_only) { return pixma_collect_devices (conf_devices, pixma_devices, local_only); } const char * pixma_get_device_model (unsigned devnr) { const pixma_config_t *cfg = pixma_get_device_config (devnr); return (cfg) ? cfg->name : NULL; } int pixma_get_device_status (pixma_t * s, pixma_device_status_t * status) { if (!status) return PIXMA_EINVAL; memset (status, 0, sizeof (*status)); return s->ops->get_status (s, status); } sane-backends-1.0.29/backend/pixma/pixma_sane_options.c0000666000000000000000000003012213615534521017747 00000000000000/* Automatically generated from pixma_sane.c */ static const SANE_Range constraint_gamma_table = { 0,255,0 }; static const SANE_Range constraint_gamma = { SANE_FIX(0.3),SANE_FIX(5),SANE_FIX(0) }; 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 int find_string_in_list(SANE_String_Const str, const SANE_String_Const *list) { int i; for (i = 0; list[i] && strcmp(str, list[i]) != 0; i++) {} return i; } static int build_option_descriptors(struct pixma_sane_t *ss) { SANE_Option_Descriptor *sod; option_descriptor_t *opt; memset(OPT_IN_CTX, 0, sizeof(OPT_IN_CTX)); opt = &(OPT_IN_CTX[opt_opt_num_opts]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_TITLE_NUM_OPTIONS; sod->desc = SANE_DESC_NUM_OPTIONS; sod->name = ""; sod->unit = SANE_UNIT_NONE; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_DETECT; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_opt_num_opts].info = 0; opt->def.w = opt_last; opt->val.w = opt_last; opt = &(OPT_IN_CTX[opt__group_1]); sod = &opt->sod; sod->type = SANE_TYPE_GROUP; sod->title = SANE_I18N("Scan mode"); sod->desc = sod->title; opt = &(OPT_IN_CTX[opt_resolution]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_TITLE_SCAN_RESOLUTION; sod->desc = SANE_DESC_SCAN_RESOLUTION; sod->name = "resolution"; sod->unit = SANE_UNIT_DPI; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC; sod->constraint_type = SANE_CONSTRAINT_WORD_LIST; sod->constraint.word_list = ss->dpi_list; OPT_IN_CTX[opt_resolution].info = SANE_INFO_RELOAD_PARAMS; opt->def.w = 75; opt->val.w = 75; opt = &(OPT_IN_CTX[opt_mode]); sod = &opt->sod; sod->type = SANE_TYPE_STRING; sod->title = SANE_TITLE_SCAN_MODE; sod->desc = SANE_DESC_SCAN_MODE; sod->name = "mode"; sod->unit = SANE_UNIT_NONE; sod->size = 31; sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC; sod->constraint_type = SANE_CONSTRAINT_STRING_LIST; sod->constraint.string_list = ss->mode_list; OPT_IN_CTX[opt_mode].info = SANE_INFO_RELOAD_PARAMS; opt->def.s = SANE_VALUE_SCAN_MODE_COLOR; opt->val.w = find_string_in_list(opt->def.s, sod->constraint.string_list); opt = &(OPT_IN_CTX[opt_source]); sod = &opt->sod; sod->type = SANE_TYPE_STRING; sod->title = SANE_TITLE_SCAN_SOURCE; sod->desc = SANE_I18N("Selects the scan source (such as a document-feeder). Set source before mode and resolution. Resets mode and resolution to auto values."); sod->name = "source"; sod->unit = SANE_UNIT_NONE; sod->size = 31; sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT; sod->constraint_type = SANE_CONSTRAINT_STRING_LIST; sod->constraint.string_list = ss->source_list; OPT_IN_CTX[opt_source].info = 0; opt->def.s = SANE_I18N("Flatbed"); opt->val.w = find_string_in_list(opt->def.s, sod->constraint.string_list); opt = &(OPT_IN_CTX[opt_button_controlled]); sod = &opt->sod; sod->type = SANE_TYPE_BOOL; sod->title = SANE_I18N("Button-controlled scan"); sod->desc = SANE_I18N("When enabled, scan process will not start immediately. To proceed, press \"SCAN\" button (for MP150) or \"COLOR\" button (for other models). To cancel, press \"GRAY\" button."); sod->name = "button-controlled"; sod->unit = SANE_UNIT_NONE; sod->size = sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_INACTIVE; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_button_controlled].info = 0; opt->def.w = SANE_FALSE; opt->val.w = SANE_FALSE; opt = &(OPT_IN_CTX[opt__group_2]); sod = &opt->sod; sod->type = SANE_TYPE_GROUP; sod->title = SANE_I18N("Gamma"); sod->desc = sod->title; opt = &(OPT_IN_CTX[opt_custom_gamma]); sod = &opt->sod; sod->type = SANE_TYPE_BOOL; sod->title = SANE_TITLE_CUSTOM_GAMMA; sod->desc = SANE_DESC_CUSTOM_GAMMA; sod->name = "custom-gamma"; sod->unit = SANE_UNIT_NONE; sod->size = sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC|SANE_CAP_INACTIVE; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_custom_gamma].info = 0; opt->def.w = SANE_TRUE; opt->val.w = SANE_TRUE; opt = &(OPT_IN_CTX[opt_gamma_table]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_TITLE_GAMMA_VECTOR; sod->desc = SANE_DESC_GAMMA_VECTOR; sod->name = "gamma-table"; sod->unit = SANE_UNIT_NONE; sod->size = 4096 * 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_gamma_table; OPT_IN_CTX[opt_gamma_table].info = 0; opt = &(OPT_IN_CTX[opt_gamma]); sod = &opt->sod; sod->type = SANE_TYPE_FIXED; sod->title = SANE_I18N("Gamma function exponent"); sod->desc = SANE_I18N("Changes intensity of midtones"); sod->name = "gamma"; 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_gamma; OPT_IN_CTX[opt_gamma].info = 0; opt->def.w = SANE_FIX(AUTO_GAMMA); opt->val.w = SANE_FIX(AUTO_GAMMA); opt = &(OPT_IN_CTX[opt__group_3]); sod = &opt->sod; sod->type = SANE_TYPE_GROUP; sod->title = SANE_I18N("Geometry"); sod->desc = sod->title; opt = &(OPT_IN_CTX[opt_tl_x]); sod = &opt->sod; sod->type = SANE_TYPE_FIXED; sod->title = SANE_TITLE_SCAN_TL_X; sod->desc = SANE_DESC_SCAN_TL_X; sod->name = "tl-x"; sod->unit = SANE_UNIT_MM; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC; sod->constraint_type = SANE_CONSTRAINT_RANGE; sod->constraint.range = &ss->xrange; OPT_IN_CTX[opt_tl_x].info = SANE_INFO_RELOAD_PARAMS; opt->def.w = SANE_FIX(0); opt->val.w = SANE_FIX(0); opt = &(OPT_IN_CTX[opt_tl_y]); sod = &opt->sod; sod->type = SANE_TYPE_FIXED; sod->title = SANE_TITLE_SCAN_TL_Y; sod->desc = SANE_DESC_SCAN_TL_Y; sod->name = "tl-y"; sod->unit = SANE_UNIT_MM; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC; sod->constraint_type = SANE_CONSTRAINT_RANGE; sod->constraint.range = &ss->yrange; OPT_IN_CTX[opt_tl_y].info = SANE_INFO_RELOAD_PARAMS; opt->def.w = SANE_FIX(0); opt->val.w = SANE_FIX(0); opt = &(OPT_IN_CTX[opt_br_x]); sod = &opt->sod; sod->type = SANE_TYPE_FIXED; sod->title = SANE_TITLE_SCAN_BR_X; sod->desc = SANE_DESC_SCAN_BR_X; sod->name = "br-x"; sod->unit = SANE_UNIT_MM; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC; sod->constraint_type = SANE_CONSTRAINT_RANGE; sod->constraint.range = &ss->xrange; OPT_IN_CTX[opt_br_x].info = SANE_INFO_RELOAD_PARAMS; opt->def.w = sod->constraint.range->max; opt->val.w = sod->constraint.range->max; opt = &(OPT_IN_CTX[opt_br_y]); sod = &opt->sod; sod->type = SANE_TYPE_FIXED; sod->title = SANE_TITLE_SCAN_BR_Y; sod->desc = SANE_DESC_SCAN_BR_Y; sod->name = "br-y"; sod->unit = SANE_UNIT_MM; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_AUTOMATIC; sod->constraint_type = SANE_CONSTRAINT_RANGE; sod->constraint.range = &ss->yrange; OPT_IN_CTX[opt_br_y].info = SANE_INFO_RELOAD_PARAMS; opt->def.w = sod->constraint.range->max; opt->val.w = sod->constraint.range->max; opt = &(OPT_IN_CTX[opt__group_4]); sod = &opt->sod; sod->type = SANE_TYPE_GROUP; sod->title = SANE_I18N("Buttons"); sod->desc = sod->title; opt = &(OPT_IN_CTX[opt_button_update]); sod = &opt->sod; sod->type = SANE_TYPE_BUTTON; sod->title = SANE_I18N("Update button state"); sod->desc = sod->title; sod->name = "button-update"; sod->unit = SANE_UNIT_NONE; sod->size = 0; sod->cap = SANE_CAP_SOFT_SELECT|SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_button_update].info = 0; opt = &(OPT_IN_CTX[opt_button_1]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_I18N("Button 1"); sod->desc = sod->title; sod->name = "button-1"; sod->unit = SANE_UNIT_NONE; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_button_1].info = 0; opt->def.w = 0; opt->val.w = 0; opt = &(OPT_IN_CTX[opt_button_2]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_I18N("Button 2"); sod->desc = sod->title; sod->name = "button-2"; sod->unit = SANE_UNIT_NONE; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_button_2].info = 0; opt->def.w = 0; opt->val.w = 0; opt = &(OPT_IN_CTX[opt_original]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_I18N("Type of original to scan"); sod->desc = sod->title; sod->name = "original"; sod->unit = SANE_UNIT_NONE; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_original].info = 0; opt->def.w = 0; opt->val.w = 0; opt = &(OPT_IN_CTX[opt_target]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_I18N("Target operation type"); sod->desc = sod->title; sod->name = "target"; sod->unit = SANE_UNIT_NONE; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_target].info = 0; opt->def.w = 0; opt->val.w = 0; opt = &(OPT_IN_CTX[opt_scan_resolution]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_I18N("Scan resolution"); sod->desc = sod->title; sod->name = "scan-resolution"; sod->unit = SANE_UNIT_NONE; sod->size = 1 * sizeof(SANE_Word); sod->cap = SANE_CAP_SOFT_DETECT|SANE_CAP_ADVANCED; sod->constraint_type = SANE_CONSTRAINT_NONE; OPT_IN_CTX[opt_scan_resolution].info = 0; opt->def.w = 0; opt->val.w = 0; opt = &(OPT_IN_CTX[opt__group_5]); sod = &opt->sod; sod->type = SANE_TYPE_GROUP; sod->title = SANE_I18N("Extras"); sod->desc = sod->title; opt = &(OPT_IN_CTX[opt_threshold]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_TITLE_THRESHOLD; sod->desc = SANE_DESC_THRESHOLD; sod->name = "threshold"; sod->unit = SANE_UNIT_PERCENT; 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_threshold; OPT_IN_CTX[opt_threshold].info = 0; opt->def.w = 50; opt->val.w = 50; opt = &(OPT_IN_CTX[opt_threshold_curve]); sod = &opt->sod; sod->type = SANE_TYPE_INT; sod->title = SANE_I18N("Threshold curve"); sod->desc = SANE_I18N("Dynamic threshold curve, from light to dark, normally 50-65"); sod->name = "threshold-curve"; 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_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 waits upto the specified 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; } sane-backends-1.0.29/backend/mustek.c0000666000000000000000000061315013615534521014252 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996, 1997 David Mosberger-Tang and Andreas Czechanowski, 1998 Andreas Bolsch for extension to ScanExpress models version 0.6, 2000-2005 Henning Meier-Geinitz, 2003 James Perry (600 EP). 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Mustek and some Trust flatbed scanners with SCSI, parallel port (600 EP) or proprietary interface. */ /**************************************************************************/ /* Mustek backend version */ #define BUILD 138 /**************************************************************************/ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include "../include/_stdint.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_ab306.h" #include "../include/sane/sanei_thread.h" #define BACKEND_NAME mustek #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "mustek.h" #include "mustek_scsi_pp.h" #ifndef SANE_I18N #define SANE_I18N(text) text #endif /* Debug level from sanei_init_debug */ static SANE_Int debug_level; /* Maximum # of inches to scan in one swoop. 0 means "unlimited." This is here to be nice on the SCSI bus---Mustek scanners don't disconnect while scanning is in progress, which confuses some drivers that expect no reasonable SCSI request would take more than 10 seconds. That's not really true for Mustek scanners operating in certain modes, hence this limit. Usually you don't need to set it. */ static double strip_height; /* Should we wait for the scan slider to return after each scan? */ static SANE_Bool force_wait; /* Should we disable double buffering when reading data from the scanner? */ static SANE_Bool disable_double_buffering; static SANE_Int num_devices; static Mustek_Device *first_dev; static Mustek_Scanner *first_handle; static const SANE_Device **devlist = 0; /* Array of newly attached devices */ static Mustek_Device **new_dev; /* Length of new_dev array */ static SANE_Int new_dev_len; /* Number of entries alloced for new_dev */ static SANE_Int new_dev_alloced; static SANE_Int lamp_off_time = 60; /* Used for line-distance correction: */ static const SANE_Int color_seq[] = { 1, 2, 0 /* green, blue, red */ }; /* Which modes are supported? */ static SANE_String_Const mode_list_paragon[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_HALFTONE, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, 0 }; static SANE_String_Const mode_list_se[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, 0 }; static SANE_String_Const bit_depth_list_pro[] = { "8", "12", 0 }; /* Some scanners support setting speed manually */ static SANE_String_Const speed_list[] = { SANE_I18N ("Slowest"), SANE_I18N ("Slower"), SANE_I18N ("Normal"), SANE_I18N ("Faster"), SANE_I18N ("Fastest"), 0 }; /* Which scan-sources are supported? */ static const SANE_String_Const source_list[] = { SANE_I18N ("Flatbed"), 0 }; static SANE_String_Const adf_source_list[] = { SANE_I18N ("Flatbed"), SANE_I18N ("Automatic Document Feeder"), 0 }; static SANE_String_Const ta_source_list[] = { SANE_I18N ("Flatbed"), SANE_I18N ("Transparency Adapter"), 0 }; /* Range used for gamma and halftone pattern */ static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; /* Which kind of halftone patterns are available? */ static SANE_String_Const halftone_list[] = { SANE_I18N ("8x8 coarse"), SANE_I18N ("8x8 normal"), SANE_I18N ("8x8 fine"), SANE_I18N ("8x8 very fine"), SANE_I18N ("6x6 normal"), SANE_I18N ("5x5 coarse"), SANE_I18N ("5x5 fine"), SANE_I18N ("4x4 coarse"), SANE_I18N ("4x4 normal"), SANE_I18N ("4x4 fine"), SANE_I18N ("3x3 normal"), SANE_I18N ("2x2 normal"), SANE_I18N ("8x8 custom"), SANE_I18N ("6x6 custom"), SANE_I18N ("5x5 custom"), SANE_I18N ("4x4 custom"), SANE_I18N ("3x3 custom"), SANE_I18N ("2x2 custom"), 0 }; /* Range used for brightness and contrast */ static const SANE_Range percentage_range = { SANE_FIX(-100), /* minimum */ SANE_FIX(100), /* maximum */ SANE_FIX(1) /* quantization */ }; /* SCSI command buffers used by the backend */ static const SANE_Byte scsi_inquiry[] = { MUSTEK_SCSI_INQUIRY, 0x00, 0x00, 0x00, INQ_LEN, 0x00 }; static const SANE_Byte scsi_test_unit_ready[] = { MUSTEK_SCSI_TEST_UNIT_READY, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* Remove #ifdef and this comment when this SCSI command is used for something. Keeping this definition around so we don't loose info about the protocol. */ #ifdef ENABLE_MUSTEK_SCSI_AREA_AND_WINDOWS static const SANE_Byte scsi_area_and_windows[] = { MUSTEK_SCSI_AREA_AND_WINDOWS, 0x00, 0x00, 0x00, 0x09, 0x00 }; #endif static const SANE_Byte scsi_request_sense[] = { MUSTEK_SCSI_REQUEST_SENSE, 0x00, 0x00, 0x00, 0x04, 0x00 }; static const SANE_Byte scsi_start_stop[] = { MUSTEK_SCSI_START_STOP, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const SANE_Byte scsi_ccd_distance[] = { MUSTEK_SCSI_CCD_DISTANCE, 0x00, 0x00, 0x00, 0x05, 0x00 }; static const SANE_Byte scsi_get_image_status[] = { MUSTEK_SCSI_GET_IMAGE_STATUS, 0x00, 0x00, 0x00, 0x06, 0x00 }; static const SANE_Byte scsi_set_window[] = { MUSTEK_SCSI_SET_WINDOW, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00 }; static const SANE_Byte scsi_get_window[] = { MUSTEK_SCSI_GET_WINDOW, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00 }; static const SANE_Byte scsi_read_data[] = { MUSTEK_SCSI_READ_DATA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const SANE_Byte scsi_send_data[] = { MUSTEK_SCSI_SEND_DATA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* Remove #ifdef and this comment when this SCSI command is used for something. Keeping this definition around so we don't loose info about the protocol. */ #ifdef ENABLE_MUSTEK_SCSI_LOOKUP_TABLE static const SANE_Byte scsi_lookup_table[] = { MUSTEK_SCSI_LOOKUP_TABLE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #endif /* prototypes */ static SANE_Status area_and_windows (Mustek_Scanner * s); static SANE_Status inquiry (Mustek_Scanner * s); /* Test if this machine is little endian (from coolscan.c) */ static SANE_Bool little_endian (void) { SANE_Int testvalue = 255; uint8_t *firstbyte = (uint8_t *) & testvalue; if (*firstbyte == 255) return SANE_TRUE; return SANE_FALSE; } /* Used for Pro series. First value seems to be always 85, second one varies. First bit of second value clear == device ready (?) */ static SANE_Status scsi_sense_wait_ready (Mustek_Scanner * s) { struct timeval now, start; SANE_Status status; size_t len; SANE_Byte sense_buffer[4]; SANE_Byte bytetxt[300], dbgtxt[300], *pp; gettimeofday (&start, 0); while (1) { len = sizeof (sense_buffer); DBG (5, "scsi_sense_wait_ready: command size = %ld, sense size = %ld\n", (long int) sizeof (scsi_request_sense), (long int) len); status = sanei_scsi_cmd (s->fd, scsi_request_sense, sizeof (scsi_request_sense), sense_buffer, &len); if (status != SANE_STATUS_GOOD) { DBG (1, "scsi_sense_wait_ready: failed: %s\n", sane_strstatus (status)); return status; } dbgtxt[0] = '\0'; for (pp = sense_buffer; pp < (sense_buffer + 4); pp++) { sprintf ((SANE_String) bytetxt, " %02x", *pp); strcat ((SANE_String) dbgtxt, (SANE_String) bytetxt); } DBG (5, "scsi_sense_wait_ready: sensebuffer: %s\n", dbgtxt); if (!(sense_buffer[1] & 0x01)) { DBG (4, "scsi_sense_wait_ready: ok\n"); return SANE_STATUS_GOOD; } else { gettimeofday (&now, 0); if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME) { DBG (1, "scsi_sense_wait_ready: timed out after %lu seconds\n", (u_long) (now.tv_sec - start.tv_sec)); return SANE_STATUS_INVAL; } usleep (100000); /* retry after 100ms */ } } return SANE_STATUS_INVAL; } /* Used for 3pass series */ static SANE_Status scsi_area_wait_ready (Mustek_Scanner * s) { struct timeval now, start; SANE_Status status; gettimeofday (&start, 0); DBG (5, "scsi_area_wait_ready\n"); while (1) { status = area_and_windows (s); switch (status) { default: /* Ignore errors while waiting for scanner to become ready. Some SCSI drivers return EIO while the scanner is returning to the home position. */ DBG (3, "scsi_area_wait_ready: failed (%s)\n", sane_strstatus (status)); /* fall through */ case SANE_STATUS_DEVICE_BUSY: gettimeofday (&now, 0); if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME) { DBG (1, "scsi_area_wait_ready: timed out after %lu seconds\n", (u_long) (now.tv_sec - start.tv_sec)); return SANE_STATUS_INVAL; } usleep (100000); /* retry after 100ms */ break; case SANE_STATUS_GOOD: return status; } } return SANE_STATUS_INVAL; } static SANE_Status scsi_unit_wait_ready (Mustek_Scanner * s) { struct timeval now, start; SANE_Status status; gettimeofday (&start, 0); while (1) { DBG (5, "scsi_unit_wait_ready: sending TEST_UNIT_READY\n"); status = sanei_scsi_cmd (s->fd, scsi_test_unit_ready, sizeof (scsi_test_unit_ready), 0, 0); DBG (5, "scsi_unit_wait_ready: TEST_UNIT_READY finished\n"); switch (status) { default: /* Ignore errors while waiting for scanner to become ready. Some SCSI drivers return EIO while the scanner is returning to the home position. */ DBG (3, "scsi_unit_wait_ready: test unit ready failed (%s)\n", sane_strstatus (status)); /* fall through */ case SANE_STATUS_DEVICE_BUSY: gettimeofday (&now, 0); if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME) { DBG (1, "scsi_unit_wait_ready: timed out after %lu seconds\n", (u_long) (now.tv_sec - start.tv_sec)); return SANE_STATUS_INVAL; } usleep (100000); /* retry after 100ms */ break; case SANE_STATUS_GOOD: return status; } } return SANE_STATUS_INVAL; } static SANE_Status scsi_inquiry_wait_ready (Mustek_Scanner * s) { struct timeval now, start; SANE_Status status; gettimeofday (&start, 0); while (1) { DBG (5, "scsi_inquiry_wait_ready: sending INQUIRY\n"); status = inquiry (s); DBG (5, "scsi_inquiry_wait_ready: INQUIRY finished\n"); switch (status) { default: /* Ignore errors while waiting for scanner to become ready. Some SCSI drivers return EIO while the scanner is returning to the home position. */ DBG (3, "scsi_unit_wait_ready: inquiry failed (%s)\n", sane_strstatus (status)); /* fall through */ case SANE_STATUS_DEVICE_BUSY: gettimeofday (&now, 0); if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME) { DBG (1, "scsi_unit_wait_ready: timed out after %lu seconds\n", (u_long) (now.tv_sec - start.tv_sec)); return SANE_STATUS_INVAL; } usleep (500000); /* retry after 500ms */ break; case SANE_STATUS_GOOD: return status; } } return SANE_STATUS_INVAL; } static SANE_Status n_wait_ready (Mustek_Scanner * s) { struct timeval now, start; SANE_Status status; gettimeofday (&start, 0); DBG (5, "n_wait_ready\n"); while (1) { status = sanei_ab306_test_ready (s->fd); if (status == SANE_STATUS_GOOD) return SANE_STATUS_GOOD; gettimeofday (&now, 0); if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME) { DBG (1, "n_wait_ready: timed out after %lu seconds\n", (u_long) (now.tv_sec - start.tv_sec)); return SANE_STATUS_INVAL; } usleep (100000); /* retry after 100ms */ } } static SANE_Status scsi_pp_wait_ready (Mustek_Scanner * s) { struct timeval now, start; SANE_Status status; gettimeofday (&start, 0); DBG (5, "scsi_pp_wait_ready\n"); while (1) { status = mustek_scsi_pp_test_ready (s->fd); if (status == SANE_STATUS_GOOD) return SANE_STATUS_GOOD; gettimeofday (&now, 0); if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME) { DBG (1, "scsi_pp_wait_ready: timed out after %lu seconds\n", (u_long) (now.tv_sec - start.tv_sec)); return SANE_STATUS_INVAL; } usleep (100000); /* retry after 100ms */ } } static SANE_Status dev_wait_ready (Mustek_Scanner * s) { if (s->hw->flags & MUSTEK_FLAG_N) return n_wait_ready (s); else if (s->hw->flags & MUSTEK_FLAG_SCSI_PP) return scsi_pp_wait_ready (s); else if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { SANE_Status status; /* some 3-pass scanners seem to need the inquiry wait, too */ status = scsi_area_wait_ready (s); if (status != SANE_STATUS_GOOD) return status; return scsi_inquiry_wait_ready (s); } else if ((s->hw->flags & MUSTEK_FLAG_PARAGON_1) || (s->hw->flags & MUSTEK_FLAG_PARAGON_2)) return scsi_inquiry_wait_ready (s); else if (s->hw->flags & MUSTEK_FLAG_PRO) return scsi_sense_wait_ready (s); else return scsi_unit_wait_ready (s); } static SANE_Status dev_open (SANE_String_Const devname, Mustek_Scanner * s, SANEI_SCSI_Sense_Handler handler) { SANE_Status status; DBG (5, "dev_open %s\n", devname); #ifdef HAVE_SANEI_SCSI_OPEN_EXTENDED s->hw->buffer_size = s->hw->max_buffer_size; status = sanei_scsi_open_extended (devname, &s->fd, handler, 0, &s->hw->buffer_size); #else s->hw->buffer_size = MIN (sanei_scsi_max_request_size, s->hw->max_buffer_size); status = sanei_scsi_open (devname, &s->fd, handler, 0); #endif if (status == SANE_STATUS_GOOD) { DBG (3, "dev_open: %s is a SCSI device\n", devname); DBG (4, "dev_open: wanted %d kbytes, got %d kbytes buffer\n", s->hw->max_buffer_size / 1024, s->hw->buffer_size / 1024); if (s->hw->buffer_size < 4096) { DBG (1, "dev_open: sanei_scsi_open buffer too small\n"); sanei_scsi_close (s->fd); return SANE_STATUS_NO_MEM; } } else { DBG (3, "dev_open: %s: can't open %s as a SCSI device\n", sane_strstatus (status), devname); status = sanei_ab306_open (devname, &s->fd); if (status == SANE_STATUS_GOOD) { s->hw->flags |= MUSTEK_FLAG_N; DBG (3, "dev_open: %s is an AB306N device\n", devname); } else { DBG (3, "dev_open: %s: can't open %s as an AB306N device\n", sane_strstatus (status), devname); status = mustek_scsi_pp_open (devname, &s->fd); if (status == SANE_STATUS_GOOD) { s->hw->flags |= MUSTEK_FLAG_SCSI_PP; DBG (3, "dev_open: %s is a SCSI-over-parallel device\n", devname); } else { DBG (3, "dev_open: %s: can't open %s as a SCSI-over-parallel device\n", sane_strstatus (status), devname); DBG (1, "dev_open: can't open %s\n", devname); return SANE_STATUS_INVAL; } } } return SANE_STATUS_GOOD; } static SANE_Status dev_cmd (Mustek_Scanner * s, const void *src, size_t src_size, void *dst, size_t * dst_size) { SANE_Status status; SANE_Byte cmd_byte_list[50]; SANE_Byte cmd_byte[5]; const SANE_Byte *pp; DBG (5, "dev_cmd: fd=%d, src=%p, src_size=%ld, dst=%p, dst_size=%ld\n", s->fd, src, (long int) src_size, dst, (long int) (dst_size ? *dst_size : 0)); if (src && (debug_level >= 5)) /* output data sent to SCSI device */ { cmd_byte_list[0] = '\0'; for (pp = (const SANE_Byte *) src; pp < (((const SANE_Byte *) src) + src_size); pp++) { sprintf ((SANE_String) cmd_byte, " %02x", *pp); strcat ((SANE_String) cmd_byte_list, (SANE_String) cmd_byte); if (((pp - (const SANE_Byte *) src) % 0x10 == 0x0f) || (pp >= (((const SANE_Byte *) src) + src_size - 1))) { DBG (5, "dev_cmd: sending: %s\n", cmd_byte_list); cmd_byte_list[0] = '\0'; } } } if (s->hw->flags & MUSTEK_FLAG_N) status = sanei_ab306_cmd (s->fd, src, src_size, dst, dst_size); else if (s->hw->flags & MUSTEK_FLAG_SCSI_PP) status = mustek_scsi_pp_cmd (s->fd, src, src_size, dst, dst_size); else status = sanei_scsi_cmd (s->fd, src, src_size, dst, dst_size); if (dst && dst_size && (debug_level >= 5)) /* output data received from SCSI device */ { cmd_byte_list[0] = '\0'; for (pp = (const SANE_Byte *) dst; pp < (((const SANE_Byte *) dst) + *dst_size); pp++) { sprintf ((SANE_String) cmd_byte, " %02x", *pp); strcat ((SANE_String) cmd_byte_list, (SANE_String) cmd_byte); if (((pp - (const SANE_Byte *) dst) % 0x10 == 0x0f) || (pp >= (((const SANE_Byte *) dst) + *dst_size - 1))) { DBG (5, "dev_cmd: receiving: %s\n", cmd_byte_list); cmd_byte_list[0] = '\0'; } } } DBG (5, "dev_cmd: finished: dst_size=%ld, status=%s\n", (long int) (dst_size ? *dst_size : 0), sane_strstatus (status)); return status; } static SANE_Status dev_req_wait (void *id) { if (!id) return SANE_STATUS_GOOD; else return sanei_scsi_req_wait (id); } static SANE_Status dev_block_read_start (Mustek_Scanner * s, SANE_Int lines) { DBG (4, "dev_block_read_start: entering block for %d lines\n", lines); if (s->hw->flags & MUSTEK_FLAG_N) { SANE_Byte readlines[6]; memset (readlines, 0, sizeof (readlines)); readlines[0] = MUSTEK_SCSI_READ_SCANNED_DATA; readlines[2] = (lines >> 16) & 0xff; readlines[3] = (lines >> 8) & 0xff; readlines[4] = (lines >> 0) & 0xff; return sanei_ab306_cmd (s->fd, readlines, sizeof (readlines), 0, 0); } else if (s->hw->flags & MUSTEK_FLAG_SCSI_PP) { SANE_Byte readlines[6]; memset (readlines, 0, sizeof (readlines)); readlines[0] = MUSTEK_SCSI_READ_SCANNED_DATA; readlines[2] = (lines >> 16) & 0xff; readlines[3] = (lines >> 8) & 0xff; readlines[4] = (lines >> 0) & 0xff; return mustek_scsi_pp_cmd (s->fd, readlines, sizeof (readlines), 0, 0); } else if (s->hw->flags & MUSTEK_FLAG_PARAGON_2) { SANE_Byte buffer[6]; size_t len; SANE_Int color; SANE_Status status; /* reset line-distance values */ if (s->mode & MUSTEK_MODE_COLOR) { for (color = 0; color < 3; ++color) { s->ld.index[color] = -s->ld.dist[color]; } s->ld.lmod3 = -1; s->ld.ld_line = 0; } /* Get image status (necessary to start new block) */ len = sizeof (buffer); status = dev_cmd (s, scsi_get_image_status, sizeof (scsi_get_image_status), buffer, &len); if (status != SANE_STATUS_GOOD) return status; /* tell scanner how many lines to scan in one block */ memset (buffer, 0, sizeof (buffer)); buffer[0] = MUSTEK_SCSI_READ_SCANNED_DATA; buffer[2] = (lines >> 16) & 0xff; buffer[3] = (lines >> 8) & 0xff; buffer[4] = (lines >> 0) & 0xff; buffer[5] = 0x04; return sanei_scsi_cmd (s->fd, buffer, sizeof (buffer), 0, 0); } else return SANE_STATUS_GOOD; } static SANE_Status dev_read_req_enter (Mustek_Scanner * s, SANE_Byte * buf, SANE_Int lines, SANE_Int bpl, size_t * lenp, void **idp, SANE_Int bank, SANE_Byte * command) { *lenp = lines * bpl; if (s->hw->flags & MUSTEK_FLAG_N) { SANE_Int planes; *idp = 0; planes = (s->mode & MUSTEK_MODE_COLOR) ? 3 : 1; return sanei_ab306_rdata (s->fd, planes, buf, lines, bpl); } else if (s->hw->flags & MUSTEK_FLAG_SCSI_PP) { SANE_Int planes; *idp = 0; planes = (s->mode & MUSTEK_MODE_COLOR) ? 3 : 1; return mustek_scsi_pp_rdata (s->fd, planes, buf, lines, bpl); } else { if (s->hw->flags & MUSTEK_FLAG_SE) { if (s->mode & MUSTEK_MODE_COLOR) lines *= 3; memset (command, 0, 10); command[0] = MUSTEK_SCSI_READ_DATA; command[6] = bank; /* buffer bank not used ??? */ command[7] = (lines >> 8) & 0xff; command[8] = (lines >> 0) & 0xff; return sanei_scsi_req_enter (s->fd, command, 10, buf, lenp, idp); } else if (s->hw->flags & MUSTEK_FLAG_PRO) { memset (command, 0, 6); command[0] = MUSTEK_SCSI_READ_SCANNED_DATA; command[2] = ((lines * bpl) >> 16) & 0xff; command[3] = ((lines * bpl) >> 8) & 0xff; command[4] = ((lines * bpl) >> 0) & 0xff; return sanei_scsi_req_enter (s->fd, command, 6, buf, lenp, idp); } else /* Paragon series */ { memset (command, 0, 6); command[0] = MUSTEK_SCSI_READ_SCANNED_DATA; command[2] = (lines >> 16) & 0xff; command[3] = (lines >> 8) & 0xff; command[4] = (lines >> 0) & 0xff; return sanei_scsi_req_enter (s->fd, command, 6, buf, lenp, idp); } } } static void dev_close (Mustek_Scanner * s) { if (s->hw->flags & MUSTEK_FLAG_N) sanei_ab306_close (s->fd); else if (s->hw->flags & MUSTEK_FLAG_SCSI_PP) mustek_scsi_pp_close (s->fd); else sanei_scsi_close (s->fd); } static SANE_Status sense_handler (SANE_Int scsi_fd, SANE_Byte * result, void *arg) { if (!result) { DBG (5, "sense_handler: no sense buffer\n"); return SANE_STATUS_IO_ERROR; } if (!arg) DBG (5, "sense_handler: got sense code %02x for fd %d (arg = null)\n", result[0], scsi_fd); else DBG (5, "sense_handler: got sense code %02x for fd %d (arg = %uc)\n", result[0], scsi_fd, *(SANE_Byte *) arg); switch (result[0]) { case 0x00: break; case 0x82: if (result[1] & 0x80) { DBG (3, "sense_handler: ADF is jammed\n"); return SANE_STATUS_JAMMED; /* ADF is jammed */ } break; case 0x83: if (result[2] & 0x02) { DBG (3, "sense_handler: ADF is out of documents\n"); return SANE_STATUS_NO_DOCS; /* ADF out of documents */ } break; case 0x84: if (result[1] & 0x10) { DBG (3, "sense_handler: transparency adapter cover open\n"); return SANE_STATUS_COVER_OPEN; /* open transparency adapter cover */ } break; default: DBG (1, "sense_handler: got unknown sense code %02x for fd %d\n", result[0], scsi_fd); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } static SANE_Status inquiry (Mustek_Scanner * s) { SANE_Byte result[INQ_LEN]; size_t size; SANE_Status status; DBG (5, "inquiry: sending INQUIRY\n"); size = sizeof (result); memset (result, 0, size); status = dev_cmd (s, scsi_inquiry, sizeof (scsi_inquiry), result, &size); if (status != SANE_STATUS_GOOD) return status; /* checking ADF status */ if (s->hw->flags & MUSTEK_FLAG_ADF) { if (result[63] & (1 << 3)) { s->hw->flags |= MUSTEK_FLAG_ADF_READY; DBG (4, "inquiry: ADF ready\n"); } else { s->hw->flags &= ~MUSTEK_FLAG_ADF_READY; DBG (4, "inquiry: ADF not ready (out of paper)\n"); } } if (!result[0]) return SANE_STATUS_DEVICE_BUSY; return SANE_STATUS_GOOD; } static SANE_Status paragon_2_get_adf_status (Mustek_Scanner * s) { SANE_Status status; size_t len; SANE_Byte sense_buffer[4]; len = sizeof (sense_buffer); status = sanei_scsi_cmd (s->fd, scsi_request_sense, sizeof (scsi_request_sense), sense_buffer, &len); if (status != SANE_STATUS_GOOD) { DBG (1, "paragon_2_get_adf_status: %s\n", sane_strstatus (status)); return status; } DBG (5, "paragon_2_get_adf_status: sense_buffer: %x %x %x %x\n", sense_buffer[0], sense_buffer[1], sense_buffer[3], sense_buffer[3]); if (sense_buffer[0] == 0x00 && sense_buffer[1] == 0x00) return SANE_STATUS_GOOD; return SANE_STATUS_NO_DOCS; } static SANE_Bool ta_available_pro (Mustek_Scanner * s) { SANE_Status status; size_t len; SANE_Byte sense_buffer[4]; len = sizeof (sense_buffer); status = sanei_scsi_cmd (s->fd, scsi_request_sense, sizeof (scsi_request_sense), sense_buffer, &len); if (status != SANE_STATUS_GOOD) { DBG (1, "ta_available_pro: failed: %s\n", sane_strstatus (status)); return status; } DBG (5, "ta_available_pro: sense_buffer[2] = %x\n", sense_buffer[2]); scsi_unit_wait_ready (s); if (sense_buffer[2] == 0x40) return SANE_TRUE; return SANE_FALSE; } static SANE_Status attach (SANE_String_Const devname, Mustek_Device ** devp, SANE_Bool may_wait) { SANE_Int mustek_scanner, fw_revision; SANE_Byte result[INQ_LEN]; SANE_Byte inquiry_byte_list[50], inquiry_text_list[17]; SANE_Byte inquiry_byte[5], inquiry_text[5]; SANE_Byte *model_name = result + 44; Mustek_Scanner s; Mustek_Device *dev, new_dev; SANE_Status status; size_t size; SANE_String scsi_device_type[] = { "Direct-Access", "Sequential-Access", "Printer", "Processor", "Write-Once", "CD-ROM", "Scanner", "Optical Memory", "Medium Changer", "Communications" }; SANE_Byte scsi_vendor[9]; SANE_Byte scsi_product[17]; SANE_Byte scsi_revision[5]; SANE_Byte *pp; SANE_Bool warning = SANE_FALSE; SANE_Int firmware_format = 0; SANE_Int firmware_revision_system = 0; if (devp) *devp = 0; for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devname) == 0) { if (devp) *devp = dev; return SANE_STATUS_GOOD; } memset (&new_dev, 0, sizeof (new_dev)); memset (&s, 0, sizeof (s)); s.hw = &new_dev; s.hw->max_buffer_size = 8 * 1024; DBG (3, "attach: trying device %s\n", devname); status = dev_open (devname, &s, sense_handler); if (status != SANE_STATUS_GOOD) return status; if (may_wait || force_wait) dev_wait_ready (&s); DBG (5, "attach: sending INQUIRY\n"); size = sizeof (result); memset (result, 0, sizeof (result)); status = dev_cmd (&s, scsi_inquiry, sizeof (scsi_inquiry), result, &size); if (status != SANE_STATUS_GOOD || size != INQ_LEN) { DBG (1, "attach: inquiry for device %s failed (%s)\n", devname, sane_strstatus (status)); dev_close (&s); return status; } status = dev_wait_ready (&s); dev_close (&s); if (status != SANE_STATUS_GOOD) return status; if ((result[0] & 0x1f) != 0x06) { DBG (1, "attach: device %s doesn't look like a scanner at all (%d)\n", devname, result[0] & 0x1f); return SANE_STATUS_INVAL; } if (debug_level >= 3) { /* clear spaces and special chars */ strncpy ((SANE_String) scsi_vendor, (SANE_String) result + 8, 8); scsi_vendor[8] = '\0'; pp = scsi_vendor + 7; while (pp >= scsi_vendor && (*pp == ' ' || *pp >= 127)) *pp-- = '\0'; strncpy ((SANE_String) scsi_product, (SANE_String) result + 16, 16); scsi_product[16] = '\0'; pp = scsi_product + 15; while (pp >= scsi_product && (*pp == ' ' || *pp >= 127)) *pp-- = '\0'; strncpy ((SANE_String) scsi_revision, (SANE_String) result + 32, 4); scsi_revision[4] = '\0'; pp = scsi_revision + 3; while (pp >= scsi_revision && (*pp == ' ' || *pp >= 127)) *pp-- = '\0'; DBG (3, "attach: SCSI Vendor: `%-8s' Model: `%-16s' Rev.: `%-4s'\n", scsi_vendor, scsi_product, scsi_revision); DBG (3, "attach: SCSI Type: %s; ANSI rev.: %d\n", ((result[0] & 0x1f) < 0x10) ? scsi_device_type[result[0] & 0x1f] : "Unknown", result[2] & 0x03); DBG (3, "attach: SCSI flags: %s%s%s%s%s%s%s\n", (result[7] & 0x80) ? "RelAdr " : "", (result[7] & 0x40) ? "WBus32 " : "", (result[7] & 0x20) ? "WBus16 " : "", (result[7] & 0x10) ? "Sync " : "", (result[7] & 0x08) ? "Linked " : "", (result[7] & 0x02) ? "CmdQue " : "", (result[7] & 0x01) ? "SftRe " : ""); } if (debug_level >= 4) { /* print out inquiry */ DBG (4, "attach: inquiry output:\n"); inquiry_byte_list[0] = '\0'; inquiry_text_list[0] = '\0'; for (pp = result; pp < (result + INQ_LEN); pp++) { sprintf ((SANE_String) inquiry_text, "%c", (*pp < 127) && (*pp > 31) ? *pp : '.'); strcat ((SANE_String) inquiry_text_list, (SANE_String) inquiry_text); sprintf ((SANE_String) inquiry_byte, " %02x", *pp); strcat ((SANE_String) inquiry_byte_list, (SANE_String) inquiry_byte); if ((pp - result) % 0x10 == 0x0f) { DBG (4, "%s %s\n", inquiry_byte_list, inquiry_text_list); inquiry_byte_list[0] = '\0'; inquiry_text_list[0] = '\0'; } } } /* first check for new firmware format: */ mustek_scanner = (strncmp ((SANE_String) result + 36, "MUSTEK", 6) == 0); if (mustek_scanner) { if (result[43] == 'M') { DBG (3, "attach: found Mustek scanner (pro series firmware " "format)\n"); firmware_format = 2; model_name = result + 43; } else { DBG (3, "attach: found Mustek scanner (new firmware format)\n"); firmware_format = 1; } } else { /* check for old format: */ mustek_scanner = (strncmp ((SANE_String) result + 8, "MUSTEK", 6) == 0); if (mustek_scanner) { model_name = result + 16; DBG (3, "attach: found Mustek scanner (old firmware format)\n"); firmware_format = 0; } else { /* Check for some non-Mustek scanners an print warning */ if (strncmp ((SANE_String) result + 8, "Trust", 5) == 0) DBG (1, "attach: this is a real Trust scanner. It is not " " supported by this backend.\n"); if (strncmp ((SANE_String) result + 8, "Aashima", 7) == 0) DBG (1, "attach: this is an Aashima/Teco scanner. It is not " " supported by this backend.\n"); if (strncmp ((SANE_String) result + 16, "Flatbed Scanner", 15) == 0 && strncmp ((SANE_String) result + 42, "TECO", 4) == 0) DBG (1, "attach: this is a Relysis/Teco scanner. It is not " " supported by this backend.\n"); DBG (1, "attach: device %s doesn't look like a Mustek scanner\n", devname); return SANE_STATUS_INVAL; } } /* get firmware revision as BCD number: */ /* General format: x.yz */ /* Newer ScanExpress scanners (ID XC06): Vxyz */ if (result[33] == '.') { fw_revision = (result[32] - '0') << 8 | (result[34] - '0') << 4 | (result[35] - '0'); firmware_revision_system = 0; DBG (4, "attach: old firmware revision system\n"); } else { fw_revision = (result[33] - '0') << 8 | (result[34] - '0') << 4 | (result[35] - '0'); firmware_revision_system = 1; DBG (4, "attach: new firmware revision system\n"); } DBG (3, "attach: firmware revision %d.%02x\n", fw_revision >> 8, fw_revision & 0xff); dev = malloc (sizeof (*dev)); if (!dev) return SANE_STATUS_NO_MEM; memcpy (dev, &new_dev, sizeof (*dev)); dev->name = strdup (devname); if (!dev->name) return SANE_STATUS_NO_MEM; dev->sane.name = (SANE_String_Const) dev->name; dev->sane.vendor = "Mustek"; dev->sane.type = "flatbed scanner"; dev->x_range.min = 0; dev->y_range.min = 0; dev->x_range.quant = 0; dev->y_range.quant = 0; dev->x_trans_range.min = 0; dev->y_trans_range.min = 0; /* default to something really small to be on the safe side: */ dev->x_trans_range.max = SANE_FIX (8.0 * MM_PER_INCH); dev->y_trans_range.max = SANE_FIX (5.0 * MM_PER_INCH); dev->x_trans_range.quant = 0; dev->y_trans_range.quant = 0; dev->dpi_range.min = SANE_FIX (72); /* some scanners don't like low dpi */ dev->dpi_range.quant = SANE_FIX (1); /* default to 128 kB */ dev->max_buffer_size = 128 * 1024; /* SCSI buffer -> use 64 k per buffer */ dev->max_block_buffer_size = 1024 * 1024 * 1024; dev->firmware_format = firmware_format; dev->firmware_revision_system = firmware_revision_system; DBG (3, "attach: scanner id: %.11s\n", model_name); if (strncmp ((SANE_String) model_name + 10, "PRO", 3) == 0) DBG (3, "attach: this is probably a Paragon Pro series scanner\n"); else if (strncmp ((SANE_String) model_name, "MFC", 3) == 0) DBG (3, "attach: this is probably a Paragon series II scanner\n"); else if (strncmp ((SANE_String) model_name, "M", 1) == 0) DBG (3, "attach: this is probably a Paragon series I or 3-pass scanner\n"); else if (strncmp ((SANE_String) model_name, " C", 2) == 0) DBG (3, "attach: this is probably a ScanExpress series A4 scanner\n"); else if (strncmp ((SANE_String) model_name, " L", 2) == 0) DBG (3, "attach: this is probably a ScanExpress series A3 scanner\n"); else if (strncmp ((SANE_String) model_name, "XC", 2) == 0) DBG (3, "attach: this is probably a ScanExpress Plus series A4 scanner\n"); else DBG (3, "attach: I am not sure what type of scanner this is\n"); /* Paragon 3-pass series */ if (strncmp ((SANE_String) model_name, "MFS-12000CX", 11) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a Paragon MFS-12000CX v4.00 */ dev->x_range.min = SANE_FIX (0.0); dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.min = SANE_FIX (0.0); dev->y_range.max = SANE_FIX (14.00 * MM_PER_INCH); dev->x_trans_range.min = SANE_FIX (1.0); dev->y_trans_range.min = SANE_FIX (1.0); dev->x_trans_range.max = SANE_FIX (205.0); dev->y_trans_range.max = SANE_FIX (255.0); dev->dpi_range.max = SANE_FIX (1200); dev->sane.model = "MFS-12000CX"; } /* There are two different versions of the MFS-6000CX, one has the model name "MFS-06000CX", the other one is "MSF-06000CZ" */ else if (strncmp ((SANE_String) model_name, "MFS-06000CX", 11) == 0) { /* These values were measured and tested with a Paragon MFS-6000CX v4.06 */ dev->x_range.min = SANE_FIX (0.0); dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.min = SANE_FIX (0.0); dev->y_range.max = SANE_FIX (13.86 * MM_PER_INCH); dev->x_trans_range.min = SANE_FIX (1.0); dev->y_trans_range.min = SANE_FIX (2.0); dev->x_trans_range.max = SANE_FIX (203.0); dev->y_trans_range.max = SANE_FIX (255.0); dev->dpi_range.max = SANE_FIX (600); dev->sane.model = "MFS-6000CX"; } else if (strncmp ((SANE_String) model_name, "MSF-06000CZ", 11) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a Paragon MFS-6000CX v4.00 */ dev->x_range.min = SANE_FIX (0.0); dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.min = SANE_FIX (0.0); dev->y_range.max = SANE_FIX (13.85 * MM_PER_INCH); dev->x_trans_range.min = SANE_FIX (1.0); dev->y_trans_range.min = SANE_FIX (2.0); dev->x_trans_range.max = SANE_FIX (205.0); dev->y_trans_range.max = SANE_FIX (255.0); dev->dpi_range.max = SANE_FIX (600); dev->sane.model = "MFS-6000CX"; } /* Paragon 1-pass 14" series I */ /* I haven't seen a single report for this, but it is mentioned in the old man page. All reported Paragon 1200SP had a model name "MFS-12000SP" */ else if (strncmp ((SANE_String) model_name, "MSF-12000SP", 11) == 0) { /* These values are not tested and mostly guessed. */ dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.max = SANE_FIX (13.85 * MM_PER_INCH); dev->x_trans_range.min = SANE_FIX (1.0); dev->y_trans_range.min = SANE_FIX (1.0); dev->x_trans_range.max = SANE_FIX (200.0); dev->y_trans_range.max = SANE_FIX (250.0); dev->dpi_range.max = SANE_FIX (1200); dev->flags |= MUSTEK_FLAG_LD_NONE; dev->flags |= MUSTEK_FLAG_PARAGON_1; dev->flags |= MUSTEK_FLAG_USE_BLOCK; dev->sane.model = "MFS-12000SP"; warning = SANE_TRUE; } /* MFS-8000 SP v 1.x */ else if (strncmp ((SANE_String) model_name, "MSF-08000SP", 11) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a Paragon MFS-8000SP v1.20 */ dev->x_range.min = SANE_FIX (0.0); dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.min = SANE_FIX (0); dev->y_range.max = SANE_FIX (355.6); dev->x_trans_range.min = SANE_FIX (1.0); dev->y_trans_range.min = SANE_FIX (1.0); dev->x_trans_range.max = SANE_FIX (205.0); dev->y_trans_range.max = SANE_FIX (255.0); dev->dpi_range.max = SANE_FIX (800); /* At least scanners with firmware 1.20 need a gamma table upload in color mode, otherwise the image is red */ if (fw_revision == 0x120) dev->flags |= MUSTEK_FLAG_FORCE_GAMMA; dev->flags |= MUSTEK_FLAG_PARAGON_1; dev->sane.model = "MFS-8000SP"; } /* This model name exists */ else if (strncmp ((SANE_String) model_name, "MSF-06000SP", 11) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a Paragon MFS-6000SP v3.12 */ dev->x_range.min = SANE_FIX (0.0); dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.min = SANE_FIX (0.0); dev->y_range.max = SANE_FIX (355.6); dev->x_trans_range.min = SANE_FIX (1.0); dev->y_trans_range.min = SANE_FIX (1.0); dev->x_trans_range.max = SANE_FIX (205.0); dev->y_trans_range.max = SANE_FIX (255.0); dev->dpi_range.max = SANE_FIX (600); /* Looks like at least some versions of this scanner produce black images in gray and color mode if MUSTEK_FORCE_GAMMA is not set. At least versions 2.01, 2.02 and 2.10 are reported as having this bug. 3.12 doesn't need this workaround but it doesn't harm either. */ dev->flags |= MUSTEK_FLAG_FORCE_GAMMA; dev->flags |= MUSTEK_FLAG_PARAGON_1; dev->sane.model = "MFS-6000SP"; } /* This one was reported multiple times */ else if (strncmp ((SANE_String) model_name, "MFS-12000SP", 11) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a Paragon MFS-12000SP v1.02 and v1.00 */ dev->x_range.min = SANE_FIX (0.0); dev->x_range.max = SANE_FIX (217.0); dev->y_range.min = SANE_FIX (2.0); dev->y_range.max = SANE_FIX (352.0); dev->x_trans_range.min = SANE_FIX (0.0); dev->y_trans_range.min = SANE_FIX (0.0); dev->x_trans_range.max = SANE_FIX (205.0); dev->y_trans_range.max = SANE_FIX (250.0); dev->dpi_range.max = SANE_FIX (1200); /* Earlier versions of this source code used MUSTEK_FLAG_LD_MFS for firmware versions < 1.02 and LD_NONE for the rest. This didn't work for my scanners. 1.00 doesn't need any LD correction, 1.02, 1.07 and 1.11 do need normal LD corrections. Maybe all != 1.00 need normal LD */ dev->flags |= MUSTEK_FLAG_PARAGON_1; dev->flags |= MUSTEK_FLAG_LD_BLOCK; dev->flags |= MUSTEK_FLAG_USE_BLOCK; dev->sane.model = "MFS-12000SP"; } /* MFS-8000 SP v2.x */ else if (strncmp ((SANE_String) model_name, "MFS-08000SP", 11) == 0) { /* These values are tested with a MFS-08000SP v 2.04 */ dev->x_range.min = SANE_FIX (0.0); dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.min = SANE_FIX (0); dev->y_range.max = SANE_FIX (355.6); dev->x_trans_range.min = SANE_FIX (1.0); dev->y_trans_range.min = SANE_FIX (1.0); dev->x_trans_range.max = SANE_FIX (205.0); dev->y_trans_range.max = SANE_FIX (255.0); dev->dpi_range.max = SANE_FIX (800); /* At least scanners with firmware 1.20 need a gamma table upload in color mode, otherwise the image is red */ if (fw_revision == 0x120) dev->flags |= MUSTEK_FLAG_FORCE_GAMMA; dev->flags |= MUSTEK_FLAG_PARAGON_1; dev->sane.model = "MFS-8000SP"; } /* I have never seen one of those */ else if (strncmp ((SANE_String) model_name, "MFS-06000SP", 11) == 0) { /* These values are not tested. */ dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.max = SANE_FIX (13.84 * MM_PER_INCH); /* copied from MSF-06000SP */ dev->x_trans_range.min = SANE_FIX (1.0); dev->y_trans_range.min = SANE_FIX (1.0); dev->x_trans_range.max = SANE_FIX (205.0); dev->y_trans_range.max = SANE_FIX (255.0); dev->dpi_range.max = SANE_FIX (600); dev->flags |= MUSTEK_FLAG_PARAGON_1; dev->sane.model = "MFS-6000SP"; warning = SANE_TRUE; } /* Paragon 1-pass A4 series II */ else if (strncmp ((SANE_String) model_name, "MFC-08000CZ", 11) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a Paragon 800 II SP v1.06. */ dev->x_range.min = SANE_FIX (1.5); dev->x_range.max = SANE_FIX (218.0); dev->y_range.min = SANE_FIX (0.0); dev->y_range.max = SANE_FIX (293.0); dev->x_trans_range.min = SANE_FIX (0.0); dev->y_trans_range.min = SANE_FIX (0.0); dev->x_trans_range.max = SANE_FIX (205.0); dev->y_trans_range.max = SANE_FIX (254.0); dev->dpi_range.max = SANE_FIX (800); dev->max_block_buffer_size = 2 * 1024 * 1024; dev->flags |= MUSTEK_FLAG_PARAGON_2; dev->flags |= MUSTEK_FLAG_LD_BLOCK; dev->flags |= MUSTEK_FLAG_USE_BLOCK; dev->sane.model = "800S/800 II SP"; } else if (strncmp ((SANE_String) model_name, "MFC-06000CZ", 11) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a Paragon 600 II CD, a Paragon MFC-600S and a Paragon 600 II N. */ dev->x_range.min = SANE_FIX (0.0); dev->x_range.max = SANE_FIX (218.0); dev->y_range.min = SANE_FIX (0.0); dev->y_range.max = SANE_FIX (293.0); dev->x_trans_range.min = SANE_FIX (0.0); dev->y_trans_range.min = SANE_FIX (0.0); dev->x_trans_range.max = SANE_FIX (201.0); dev->y_trans_range.max = SANE_FIX (257.0); dev->dpi_range.max = SANE_FIX (600); /* This model comes in a non-scsi version, too. It is supplied with its own parallel-port like adapter, an AB306N. Two firmware revisions are known: 1.01 and 2.00. Each needs its own line-distance correction code. */ if (dev->flags & MUSTEK_FLAG_N) { if (fw_revision < 0x200) dev->flags |= MUSTEK_FLAG_LD_N1; else dev->flags |= MUSTEK_FLAG_LD_N2; dev->x_trans_range.min = SANE_FIX (33.0); dev->y_trans_range.min = SANE_FIX (62.0); dev->x_trans_range.max = SANE_FIX (183.0); dev->y_trans_range.max = SANE_FIX (238.0); dev->max_block_buffer_size = 1024 * 1024 * 1024; dev->sane.model = "600 II N"; } else if (dev->flags & MUSTEK_FLAG_SCSI_PP) { /* FIXME; experiment with different line distance codes later */ dev->dpi_range.min = SANE_FIX (75.0); dev->flags |= MUSTEK_FLAG_LD_NONE; dev->max_block_buffer_size = 2 * 1024 * 1024; dev->sane.model = "600 II EP"; } else { dev->sane.model = "600S/600 II CD"; dev->flags |= MUSTEK_FLAG_PARAGON_2; dev->flags |= MUSTEK_FLAG_LD_BLOCK; dev->flags |= MUSTEK_FLAG_USE_BLOCK; dev->max_block_buffer_size = 2 * 1024 * 1024; } } /* ScanExpress and ScanMagic series */ else if (strncmp ((SANE_String) model_name, " C03", 4) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a ScannExpress 6000SP 1.00 */ dev->x_range.max = SANE_FIX (215); dev->y_range.min = SANE_FIX (0); dev->y_range.max = SANE_FIX (293); dev->x_trans_range.min = SANE_FIX (0); dev->y_trans_range.min = SANE_FIX (0); dev->x_trans_range.max = SANE_FIX (150.0); dev->y_trans_range.max = SANE_FIX (175.0); dev->dpi_range.max = SANE_FIX (600); dev->dpi_range.min = SANE_FIX (60); dev->flags |= MUSTEK_FLAG_SE; /* At least the SE 6000SP with firmware 1.00 limits its x-resolution to 300 dpi and does *no* interpolation at higher resolutions. So this has to be done in software. */ dev->flags |= MUSTEK_FLAG_ENLARGE_X; dev->sane.model = "ScanExpress 6000SP"; } /* There are two different versions of the ScanExpress 12000SP, one has the model name " C06", the other one is "XC06". The latter seems to be used in the newer "Plus" models. Also there is the Mustek ScanExpress 1200 FS, which looks similar to the ScanExpress 12000 SP but has an "F" instead of the "V" in the firmware version. */ else if (strncmp ((SANE_String) model_name, " C06", 4) == 0) { if (result[32] == 'F') { /* Mustek ScanExpress 1200 FS. Completely untested. */ dev->x_range.min = SANE_FIX (0); dev->y_range.min = SANE_FIX (0); dev->x_range.max = SANE_FIX (215.9); dev->y_range.max = SANE_FIX (291.2); dev->x_trans_range.min = SANE_FIX (0); dev->y_trans_range.min = SANE_FIX (0); dev->x_trans_range.max = SANE_FIX (150.0); dev->y_trans_range.max = SANE_FIX (175.0); dev->dpi_range.max = SANE_FIX (1200); dev->dpi_range.min = SANE_FIX (60); dev->flags |= MUSTEK_FLAG_SE; /* The ScanExpress models limit their x-resolution to 600 dpi and do *no* interpolation at higher resolutions. So this has to be done in software. */ dev->flags |= MUSTEK_FLAG_ENLARGE_X; dev->flags |= MUSTEK_FLAG_COVER_SENSOR; dev->sane.model = "ScanExpress 12000 FS (untested)"; } else { /* These values were measured and compared to those from the Windows driver. Tested with a ScaneExpress 12000SP 2.02 and a ScanMagic 9636S v 1.01 */ dev->x_range.min = SANE_FIX (0); dev->y_range.min = SANE_FIX (0); dev->x_range.max = SANE_FIX (215.9); dev->y_range.max = SANE_FIX (291.2); dev->x_trans_range.min = SANE_FIX (0); dev->y_trans_range.min = SANE_FIX (0); dev->x_trans_range.max = SANE_FIX (150.0); dev->y_trans_range.max = SANE_FIX (175.0); dev->dpi_range.max = SANE_FIX (1200); dev->dpi_range.min = SANE_FIX (60); dev->flags |= MUSTEK_FLAG_SE; /* The ScanExpress models limit their x-resolution to 600 dpi and do *no* interpolation at higher resolutions. So this has to be done in software. */ dev->flags |= MUSTEK_FLAG_ENLARGE_X; dev->flags |= MUSTEK_FLAG_COVER_SENSOR; dev->sane.model = "ScanExpress 12000SP"; } } else if (strncmp ((SANE_String) model_name, "XC06", 4) == 0) { /* These values are tested with a SE 12000 SP Plus v 1.01 */ dev->x_range.max = SANE_FIX (216); dev->y_range.min = SANE_FIX (0); dev->y_range.max = SANE_FIX (294.5); dev->x_trans_range.min = SANE_FIX (0); dev->y_trans_range.min = SANE_FIX (0); dev->x_trans_range.max = SANE_FIX (152.0); dev->y_trans_range.max = SANE_FIX (177.0); dev->dpi_range.max = SANE_FIX (1200); dev->dpi_range.min = SANE_FIX (60); dev->flags |= MUSTEK_FLAG_SE; dev->flags |= MUSTEK_FLAG_SE_PLUS; /* The ScanExpress models limit their x-resolution to 600 dpi and do *no* interpolation at higher resolutions. So this has to be done in software. */ dev->flags |= MUSTEK_FLAG_ENLARGE_X; dev->flags |= MUSTEK_FLAG_COVER_SENSOR; dev->sane.model = "ScanExpress 12000SP Plus"; } /* ScanExpress A3 SP */ else if (strncmp ((SANE_String) model_name, " L03", 4) == 0) { /* These values were measured with a ScannExpress A3 SP 2.00 */ dev->x_range.max = SANE_FIX (297); dev->y_range.min = SANE_FIX (0); dev->y_range.max = SANE_FIX (430); /* TA couldn't be tested due to lack of equipment. So At least the TA IV (A4 size) is supported */ dev->x_trans_range.min = SANE_FIX (0); dev->y_trans_range.min = SANE_FIX (0); dev->x_trans_range.max = SANE_FIX (150.0); dev->y_trans_range.max = SANE_FIX (175.0); dev->dpi_range.max = SANE_FIX (600); dev->dpi_range.min = SANE_FIX (60); dev->flags |= MUSTEK_FLAG_SE; /* The ScanExpress models limit their x-resolution to 300 dpi and do *no* interpolation at higher resolutions. So this has to be done in software. */ dev->flags |= MUSTEK_FLAG_ENLARGE_X; dev->flags |= MUSTEK_FLAG_COVER_SENSOR; dev->sane.model = "ScanExpress A3 SP"; } /* Paragon 1200 SP Pro */ else if (strncmp ((SANE_String) model_name, "MFS-1200SPPRO", 13) == 0) { /* These values were measured with a Paragon 1200 SP Pro v2.01 */ dev->x_range.max = SANE_FIX (8.6 * MM_PER_INCH); dev->y_range.max = SANE_FIX (13.70 * MM_PER_INCH); dev->dpi_range.max = SANE_FIX (1200); dev->sane.model = "1200 SP PRO"; dev->flags |= MUSTEK_FLAG_LD_NONE; dev->flags |= MUSTEK_FLAG_ENLARGE_X; } /* No documentation, but it works: Paragon 1200 A3 PRO */ else if (strncmp ((SANE_String) model_name, "MFS-1200A3PRO", 13) == 0) { /* These values were measured and compared to those from the Windows driver. Tested with a Paragon 1200 A3 Pro v1.10 */ dev->x_range.max = SANE_FIX (11.7 * MM_PER_INCH); dev->y_range.max = SANE_FIX (424); dev->dpi_range.max = SANE_FIX (1200); dev->sane.model = "1200 A3 PRO"; dev->flags |= MUSTEK_FLAG_LD_NONE; dev->flags |= MUSTEK_FLAG_ENLARGE_X; } else { DBG (0, "attach: this Mustek scanner (ID: %s) is not supported yet\n", model_name); DBG (0, "attach: please set the debug level to 5 and send a debug " "report\n"); DBG (0, "attach: to henning@meier-geinitz.de (export " "SANE_DEBUG_MUSTEK=5\n"); DBG (0, "attach: scanimage -L 2>debug.txt). Thank you.\n"); free (dev); return SANE_STATUS_INVAL; } if (dev->flags & MUSTEK_FLAG_SE) { DBG (3, "attach: this is a single-pass scanner\n"); if (result[63] & (1 << 6)) { dev->flags |= MUSTEK_FLAG_TA; DBG (3, "attach: scanner supports transparency adapter (TA)\n"); } } else { if (result[57] & (1 << 6)) { DBG (3, "attach: this is a single-pass scanner\n"); if (dev->flags & MUSTEK_FLAG_LD_NONE) DBG (4, "attach: scanner doesn't need line-distance correction\n"); else if (dev->flags & MUSTEK_FLAG_LD_N1) DBG (4, "attach: scanner has N1 line-distance correction\n"); else if (dev->flags & MUSTEK_FLAG_LD_N2) DBG (4, "attach: scanner has N2 line-distance correction\n"); else if (dev->flags & MUSTEK_FLAG_LD_BLOCK) DBG (4, "attach: scanner has block line-distance correction\n"); else DBG (4, "attach: scanner has normal line-distance correction\n"); } else { dev->flags |= MUSTEK_FLAG_THREE_PASS; /* three-pass scanners quantize to 0.5% of the maximum resolution: */ dev->dpi_range.quant = dev->dpi_range.max / 200; dev->dpi_range.min = dev->dpi_range.quant; DBG (3, "attach: this is a three-pass scanner\n"); } if (result[57] & (1 << 5)) { DBG (3, "attach: this is a professional series scanner\n"); dev->flags |= MUSTEK_FLAG_PRO; status = dev_open (devname, &s, sense_handler); if (status == SANE_STATUS_GOOD) { if (ta_available_pro (&s)) { dev->flags |= MUSTEK_FLAG_TA; DBG (3, "attach: found transparency adapter (TA)\n"); } dev_close (&s); } else { DBG (1, "attach: couldn't open device: %s\n", sane_strstatus (status)); return status; } } if (result[63] & (1 << 2)) { dev->flags |= MUSTEK_FLAG_ADF; DBG (3, "attach: found automatic document feeder (ADF)\n"); if (result[63] & (1 << 3)) { dev->flags |= MUSTEK_FLAG_ADF_READY; DBG (4, "attach: automatic document feeder is ready\n"); } else { DBG (4, "attach: automatic document feeder is out of " "documents\n"); } } if (result[63] & (1 << 6)) { dev->flags |= MUSTEK_FLAG_TA; DBG (3, "attach: found transparency adapter (TA)\n"); } } if (dev->flags & MUSTEK_FLAG_COVER_SENSOR) { if (result[62] & (1 << 0)) DBG (4, "attach: scanner cover is closed\n"); else DBG (4, "attach: scanner cover is open\n"); } if (warning == SANE_TRUE) { 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 " "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@alioth-lists.debian.net. " "Please include\n the exact model name of your scanner and to " "which extend it works.\n"); } DBG (2, "attach: found Mustek %s %s, %s%s%s%s\n", dev->sane.model, dev->sane.type, (dev->flags & MUSTEK_FLAG_THREE_PASS) ? "3-pass" : "1-pass", (dev->flags & MUSTEK_FLAG_ADF) ? ", ADF" : "", (dev->flags & MUSTEK_FLAG_TA) ? ", TA" : "", (dev->flags & MUSTEK_FLAG_SE) ? ", SE" : ""); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; return SANE_STATUS_GOOD; } static size_t max_string_size (const SANE_String_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; } static SANE_Status constrain_value (Mustek_Scanner * s, SANE_Int option, void *value, SANE_Int * info) { SANE_Fixed w, dpi; SANE_Status status; if (value) w = *(SANE_Fixed *) value; else w = 0; if (option == OPT_RESOLUTION) { if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { /* The three pass scanners use a 0.5% of the maximum resolution increment for resolutions less than or equal to half of the maximum resolution. The MFS-06000CX uses a 5% of the maximum resolution increment for larger resolutions. The models MFS-12000CX and MSF-06000CZ use 1% of the maximum resolution. We can't represent this easily in SANE, so the constraint is simply for 0.5% and then we round to the 5% or 1% increments if necessary. */ SANE_Fixed max_dpi, quant, half_res; /*w = *(SANE_Word *) value; */ max_dpi = s->hw->dpi_range.max; half_res = max_dpi / 2; if (w > half_res) { /* quantizize to 1% step */ quant = max_dpi / 100; dpi = (w + quant / 2) / quant; dpi *= quant; if (dpi != w) { *(SANE_Word *) value = dpi; if (info) *info |= SANE_INFO_INEXACT; } } } } status = sanei_constrain_value (s->opt + option, value, info); if (s->opt[option].type == SANE_TYPE_FIXED) DBG (5, "constrain_value: %s = %.2f (was %.2f)\n", s->opt[option].name, SANE_UNFIX (*(SANE_Word *) value), SANE_UNFIX (w)); return status; } /* Quantize s->val[OPT_RESOLUTION].w and return the resolution code for the quantized resolution. Quantization depends on scanner type (single pass vs. three-pass) and resolution */ static SANE_Int encode_resolution (Mustek_Scanner * s) { SANE_Fixed max_dpi, dpi; SANE_Int code, mode = 0; dpi = s->val[OPT_RESOLUTION].w; if (!(s->hw->flags & MUSTEK_FLAG_THREE_PASS)) { code = dpi >> SANE_FIXED_SCALE_SHIFT; } else { SANE_Fixed quant, half_res; max_dpi = s->hw->dpi_range.max; half_res = max_dpi / 2; if (dpi <= half_res) { /* quantizize to 0.5% step */ quant = max_dpi / 200; } else { /* quantizize to 1% step */ quant = max_dpi / 100; mode = 0x100; /* indicate 5% or 1% quantization */ } code = (dpi + quant / 2) / quant; if (code < 1) code = 1; } DBG (5, "encode_resolution: code = 0x%x (%d); mode = %x\n", code, code, mode); return code | mode; } static SANE_Int encode_percentage (Mustek_Scanner * s, double value) { SANE_Int max, code, sign = 0; if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { code = (int) ((value / 100.0 * 12) + 12.5); max = 0x18; } else { if (value < 0.0) { value = -value; sign = 0x80; } code = (int) (value / 100.0 * 127 + 0.5); code |= sign; max = 0xff; } if (code > max) code = max; if (code < 0) code = 0x00; return code; } /* encode halftone pattern type and size */ static SANE_Status encode_halftone (Mustek_Scanner * s) { SANE_String selection = s->val[OPT_HALFTONE_DIMENSION].s; SANE_Int i = 0; while ((halftone_list[i] != 0) && (strcmp (selection, halftone_list[i]) != 0)) { i++; } if (halftone_list[i] == 0) return SANE_STATUS_INVAL; if (i < 0x0c) /* standard pattern */ { s->custom_halftone_pattern = SANE_FALSE; s->halftone_pattern_type = i; } else /* custom pattern */ { s->custom_halftone_pattern = SANE_TRUE; i -= 0x0c; i = 8 - i; if (i < 8) i--; i = i + (i << 4); s->halftone_pattern_type = i; } DBG (5, "encode_halftone: %s pattern type %x\n", s->custom_halftone_pattern ? "custom" : "standard", s->halftone_pattern_type); return SANE_STATUS_GOOD; } /* Paragon series */ static SANE_Status area_and_windows (Mustek_Scanner * s) { SANE_Byte cmd[117], *cp; SANE_Int i, offset; /* setup SCSI command (except length): */ memset (cmd, 0, sizeof (cmd)); cmd[0] = MUSTEK_SCSI_AREA_AND_WINDOWS; cp = cmd + 6; /* Some scanners need a larger scanarea for line-distance correction */ offset = 0; if (((s->hw->flags & MUSTEK_FLAG_LD_N1) || ((s->hw->flags & MUSTEK_FLAG_LD_BLOCK) && (s->hw->flags & MUSTEK_FLAG_PARAGON_1))) && (s->mode & MUSTEK_MODE_COLOR)) offset = MAX_LINE_DIST; /* fill in frame header: */ if (s->hw->flags & MUSTEK_FLAG_USE_EIGHTS) { double eights_per_mm = 8 / MM_PER_INCH; SANE_Int tlx, tly, brx, bry; /* * The MSF-06000CZ seems to lock-up if the pixel-unit is used. * Using 1/8" works. * This doesn't seem to be true with the current scheme. * This code isn't used at the moment. */ *cp++ = ((s->mode & MUSTEK_MODE_LINEART) ? 0x00 : 0x01); tlx = SANE_UNFIX (s->val[OPT_TL_X].w) * eights_per_mm + 0.5; tly = SANE_UNFIX (s->val[OPT_TL_Y].w) * eights_per_mm + 0.5; brx = SANE_UNFIX (s->val[OPT_BR_X].w) * eights_per_mm + 0.5; bry = SANE_UNFIX (s->val[OPT_BR_Y].w) * eights_per_mm + 0.5; STORE16L (cp, tlx); STORE16L (cp, tly); STORE16L (cp, brx); STORE16L (cp, bry); DBG (5, "area_and_windows: tlx=%d (%d mm); tly=%d (%d mm); " "brx=%d (%d mm); bry=%d (%d mm)\n", tlx, (int) (tlx / eights_per_mm), tly, (int) (tly / eights_per_mm), brx, (int) (brx / eights_per_mm), bry, (int) (bry / eights_per_mm)); } else { double pixels_per_mm = SANE_UNFIX (s->hw->dpi_range.max) / MM_PER_INCH; SANE_Int tlx, tly, brx, bry; if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) /* 3pass scanners use 1/2 of the max resolution as base */ pixels_per_mm /= 2; /* pixel unit and halftoning: */ *cp++ = 0x8 | ((s->mode & MUSTEK_MODE_LINEART) ? 0x00 : 0x01); /* fill in scanning area: */ if (strcmp (s->val[OPT_SOURCE].s, "Automatic Document Feeder") == 0) { /* must mirror the x coordinates */ brx = SANE_UNFIX (s->hw->x_range.max - s->val[OPT_TL_X].w) * pixels_per_mm + 0.5; tlx = SANE_UNFIX (s->hw->x_range.max - s->val[OPT_BR_X].w) * pixels_per_mm + 0.5; } else { tlx = SANE_UNFIX (s->val[OPT_TL_X].w) * pixels_per_mm + 0.5; brx = SANE_UNFIX (s->val[OPT_BR_X].w) * pixels_per_mm + 0.5; } tly = SANE_UNFIX (s->val[OPT_TL_Y].w) * pixels_per_mm + 0.5; bry = SANE_UNFIX (s->val[OPT_BR_Y].w) * pixels_per_mm + 0.5 + offset; STORE16L (cp, tlx); STORE16L (cp, tly); STORE16L (cp, brx); STORE16L (cp, bry); DBG (5, "area_and_windows: tlx=%d (%d mm); tly=%d (%d mm); " "brx=%d (%d mm); bry=%d (%d mm)\n", tlx, (int) (tlx / pixels_per_mm), tly, (int) (tly / pixels_per_mm), brx, (int) (brx / pixels_per_mm), bry, (int) (bry / pixels_per_mm)); } if (s->custom_halftone_pattern) { *cp++ = 0x40; /* mark presence of user pattern */ *cp++ = s->halftone_pattern_type; /* set pattern length */ for (i = 0; i < (s->halftone_pattern_type & 0x0f) * ((s->halftone_pattern_type >> 4) & 0x0f); ++i) *cp++ = s->val[OPT_HALFTONE_PATTERN].wa[i]; } cmd[4] = (cp - cmd) - 6; return dev_cmd (s, cmd, (cp - cmd), 0, 0); } /* ScanExpress */ static SANE_Status set_window_se (Mustek_Scanner * s, SANE_Int lamp) { SANE_Byte cmd[58], *cp; double pixels_per_mm; SANE_Int offset; SANE_Int tlx, tly, width, height; /* setup SCSI command (except length): */ memset (cmd, 0, sizeof (cmd)); cmd[0] = MUSTEK_SCSI_SET_WINDOW; cp = cmd + sizeof (scsi_set_window); /* skip command block */ if (s->mode & MUSTEK_MODE_COLOR) { /* We have to increase the specified resolution to the next */ /* "standard" resolution due to a firmware bug(?) in color mode */ /* It's possible to scan in 36, 75, 100, 150, 200, 250, 300, */ /* 400, 500, 600, 900, 1200 dpi but the speed is only different */ /* with 36, 150, 300, 600, 1200 dpi. */ /* Additionally we must increase the window length slightly to */ /* compensate for different line counts for r/g/b */ const SANE_Int resolution_list[] = { 36, 150, 300, 600, 1200, 0 }; SANE_Int entry = 0; while (resolution_list[entry] < s->resolution_code) entry++; s->ld.peak_res = resolution_list[entry]; offset = MAX_LINE_DIST; /* distance r/b lines */ } else { /* In gray and lineart modes all resolutions are possible */ s->ld.peak_res = s->resolution_code; offset = 0; } DBG (5, "set_window_se: hardware resolution is %d dpi; offset is %d\n", s->ld.peak_res, offset); STORE16B (cp, 0); /* window identifier */ STORE16B (cp, s->ld.peak_res); /* x and y resolution */ STORE16B (cp, 0); /* not used acc. to specs */ pixels_per_mm = SANE_UNFIX (s->hw->dpi_range.max) / MM_PER_INCH; /* fill in scanning area, begin and length(!) */ if ((strcmp (s->val[OPT_SOURCE].s, "Transparency Adapter") == 0) && !(s->hw->flags & MUSTEK_FLAG_TA)) { /* need to add the start values of the transparency adapter */ tlx = (SANE_UNFIX (s->val[OPT_TL_X].w) + 33.0) * pixels_per_mm + 0.5; tly = (SANE_UNFIX (s->val[OPT_TL_Y].w) + 60.0) * pixels_per_mm + 0.5; DBG (5, "set_window_se: added offset for transparency adapter\n"); } else { /* no transparency adapter selected or calculation done in firmware */ tlx = SANE_UNFIX (s->val[OPT_TL_X].w) * pixels_per_mm + 0.5; tly = SANE_UNFIX (s->val[OPT_TL_Y].w) * pixels_per_mm + 0.5; } width = (SANE_UNFIX (s->val[OPT_BR_X].w) - SANE_UNFIX (s->val[OPT_TL_X].w)) * pixels_per_mm + 0.5; height = (SANE_UNFIX (s->val[OPT_BR_Y].w) - SANE_UNFIX (s->val[OPT_TL_Y].w)) * pixels_per_mm + 0.5 + offset; DBG (5, "set_window_se: tlx=%d (%d mm); tly=%d (%d mm); width=%d (%d mm); " "height=%d (%d mm)\n", tlx, (int) (tlx / pixels_per_mm), tly, (int) (tly / pixels_per_mm), width, (int) (width / pixels_per_mm), height, (int) (height / pixels_per_mm)); STORE32B (cp, tlx); STORE32B (cp, tly); STORE32B (cp, width); STORE32B (cp, height); *cp++ = 0x00; /* brightness, not impl. */ *cp++ = 0x80; /* threshold, not impl. */ *cp++ = 0x00; /* contrast, not impl. */ /* Note that 'image composition' has no meaning for the SE series */ /* Mode selection is accomplished solely by bits/pixel (1, 8, 24) */ if (s->mode & MUSTEK_MODE_COLOR) { *cp++ = 0x05; /* actually not used! */ *cp++ = 24; /* 24 bits/pixel in color mode */ } else if (s->mode & MUSTEK_MODE_GRAY) { *cp++ = 0x02; /* actually not used! */ *cp++ = 8; /* 8 bits/pixel in gray mode */ } else { *cp++ = 0x00; /* actually not used! */ *cp++ = 1; /* 1 bit/pixel in lineart mode */ } cp += 14; /* skip reserved bytes */ *cp++ = lamp; /* 0 = normal, 1 = on, 2 = off */ if ((s->hw->flags & MUSTEK_FLAG_TA) && (strcmp (s->val[OPT_SOURCE].s, "Transparency Adapter") == 0)) *cp++ = 1; else *cp++ = 0; cp += 5; /* skip reserved bytes */ cmd[8] = cp - cmd - sizeof (scsi_set_window); return dev_cmd (s, cmd, (cp - cmd), 0, 0); } /* Pro series */ static SANE_Status set_window_pro (Mustek_Scanner * s) { SANE_Byte cmd[20], *cp; double pixels_per_mm; memset (cmd, 0, sizeof (cmd)); cmd[0] = MUSTEK_SCSI_SET_WINDOW; if (strcmp (s->hw->sane.model, "1200 SP PRO") == 0) cmd[8] = 0x09; else cmd[8] = 0x0a; cp = cmd + sizeof (scsi_set_window); /* skip command block */ *cp++ = 0; /* what's this? */ pixels_per_mm = SANE_UNFIX (s->hw->dpi_range.max) / MM_PER_INCH; /* The next for 16 bit values are x0, y0, x1, y1 in pixels at max res */ STORE16L (cp, SANE_UNFIX (s->val[OPT_TL_X].w) * pixels_per_mm + 0.5); STORE16L (cp, SANE_UNFIX (s->val[OPT_TL_Y].w) * pixels_per_mm + 0.5); STORE16L (cp, SANE_UNFIX (s->val[OPT_BR_X].w) * pixels_per_mm + 0.5); STORE16L (cp, SANE_UNFIX (s->val[OPT_BR_Y].w) * pixels_per_mm + 0.5); if (strcmp (s->hw->sane.model, "1200 SP PRO") != 0) *cp++ = lamp_off_time; /* Only needed for A3 Pro, default: 60 minutes until lamp-off */ DBG (5, "set_window_pro\n"); return dev_cmd (s, cmd, (cp - cmd), 0, 0); } /* Pro series calibration */ static SANE_Status get_calibration_size_pro (Mustek_Scanner * s) { SANE_Status status; SANE_Byte cmd[6]; SANE_Byte result[6]; size_t len; memset (cmd, 0, sizeof (cmd)); memset (result, 0, sizeof (result)); cmd[0] = MUSTEK_SCSI_GET_IMAGE_STATUS; cmd[4] = 0x06; /* size of result */ cmd[5] = 0x80; /* get back buffer size and number of buffers */ len = sizeof (result); status = dev_cmd (s, cmd, sizeof (cmd), result, &len); if (status != SANE_STATUS_GOOD) return status; s->hw->cal.bytes = result[1] | (result[2] << 8); s->hw->cal.lines = result[3] | (result[4] << 8); DBG (4, "get_calibration_size_pro: bytes=%d, lines=%d\n", s->hw->cal.bytes, s->hw->cal.lines); return SANE_STATUS_GOOD; } static SANE_Status get_calibration_lines_pro (Mustek_Scanner * s) { SANE_Status status; SANE_Byte cmd[10]; size_t len; SANE_Int line; DBG (2, "get_calibration_lines_pro: please wait for warmup\n"); memset (cmd, 0, sizeof (cmd)); cmd[0] = MUSTEK_SCSI_READ_DATA; len = s->hw->cal.bytes; cmd[6] = (len >> 16) & 0xff; cmd[7] = (len >> 8) & 0xff; cmd[8] = (len >> 0) & 0xff; for (line = 0; line < s->hw->cal.lines; line++) { status = dev_cmd (s, cmd, sizeof (scsi_read_data), s->hw->cal.buffer + line * len, &len); if ((status != SANE_STATUS_GOOD) || (len != (unsigned int) s->hw->cal.bytes)) { DBG (1, "get_calibration_lines_pro: read failed\n"); return status; } } DBG (5, "get_calibration_lines_pro finished. Assuming 12 bits per color\n"); return SANE_STATUS_GOOD; } static SANE_Status send_calibration_lines_pro (Mustek_Scanner * s) { SANE_Status status; SANE_Byte *cmd1, *cmd2; size_t buf_size; SANE_Word column, line, color; DBG (5, "send_calibration_lines_pro\n"); buf_size = s->hw->cal.bytes / 2; cmd1 = (SANE_Byte *) malloc (buf_size + sizeof (scsi_send_data)); cmd2 = (SANE_Byte *) malloc (buf_size + sizeof (scsi_send_data)); if (!cmd1 || !cmd2) { DBG (1, "send_calibration_lines_pro: failed to malloc %ld bytes for " "sending lines\n", (long int) (buf_size + sizeof (scsi_send_data))); return SANE_STATUS_NO_MEM; } memset (cmd1, 0, sizeof (scsi_send_data)); memset (cmd2, 0, sizeof (scsi_send_data)); cmd1[0] = cmd2[0] = MUSTEK_SCSI_SEND_DATA; cmd1[6] = cmd2[6] = (buf_size >> 16) & 0xff; cmd1[7] = cmd2[7] = (buf_size >> 8) & 0xff; cmd1[8] = cmd2[8] = (buf_size >> 0) & 0xff; cmd1[9] = 0; /* Least significant 8 bits */ cmd2[9] = 0x80; /* Most significant 2 bits */ for (color = 0; color < 3; color++) { for (column = 0; column < s->hw->cal.bytes / 6; column++) { SANE_Word calibration_word = 0; for (line = 0; line < s->hw->cal.lines; line++) { calibration_word += *(s->hw->cal.buffer + column * 6 + color_seq[color] * 2 + 0) + (*(s->hw->cal.buffer + column * 6 + color_seq[color] * 2 + 1) << 8); } if (!calibration_word) calibration_word = 1; calibration_word = (1024 * 65536 / calibration_word) - 1024; if (calibration_word > 1023) calibration_word = 1023; *(cmd1 + sizeof (scsi_send_data) + (buf_size / 3) * color + column) = calibration_word & 0xff; *(cmd2 + sizeof (scsi_send_data) + (buf_size / 3) * color + column) = (calibration_word >> 8) & 0xff; } } status = dev_cmd (s, cmd1, buf_size + sizeof (scsi_send_data), 0, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "send_calibration_lines_pro: send failed\n"); return status; } status = dev_cmd (s, cmd2, buf_size + sizeof (scsi_send_data), 0, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "send_calibration_lines_pro: send failed\n"); return status; } free (cmd1); free (cmd2); return SANE_STATUS_GOOD; } static SANE_Status calibration_pro (Mustek_Scanner * s) { SANE_Status status; if (s->val[OPT_QUALITY_CAL].w) DBG (4, "calibration_pro: doing calibration\n"); else { DBG (4, "calibration_pro: calibration not necessary\n"); return SANE_STATUS_GOOD; } status = get_calibration_size_pro (s); if (status != SANE_STATUS_GOOD) return status; s->hw->cal.buffer = (SANE_Byte *) malloc (s->hw->cal.bytes * s->hw->cal.lines); if (!s->hw->cal.buffer) { DBG (1, "calibration_pro: failed to malloc %d bytes for buffer\n", s->hw->cal.bytes * s->hw->cal.lines); return SANE_STATUS_NO_MEM; } status = get_calibration_lines_pro (s); if (status != SANE_STATUS_GOOD) return status; status = send_calibration_lines_pro (s); if (status != SANE_STATUS_GOOD) return status; free (s->hw->cal.buffer); return SANE_STATUS_GOOD; } /* ScanExpress series calibration */ static SANE_Status get_calibration_lines_se (Mustek_Scanner * s) { SANE_Status status; SANE_Byte cmd[10]; size_t len; SANE_Word lines, 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; } DBG (4, "get_calibration_lines_se: reading %d lines (%d bytes per color)\n", lines, bytes_per_color); memset (cmd, 0, sizeof (cmd)); cmd[0] = MUSTEK_SCSI_READ_DATA; cmd[2] = 1; cmd[7] = (lines >> 8) & 0xff; cmd[8] = (lines >> 0) & 0xff; len = lines * bytes_per_color; status = dev_cmd (s, cmd, sizeof (scsi_read_data), s->hw->cal.buffer, &len); if ((status != SANE_STATUS_GOOD) || (len != (unsigned int) (lines * bytes_per_color))) { DBG (1, "get_calibration_lines_se: read failed\n"); return status; } return SANE_STATUS_GOOD; } static SANE_Status send_calibration_lines_se (Mustek_Scanner * s, SANE_Word color) { SANE_Status status; SANE_Byte *cmd; size_t buf_size; SANE_Word column; SANE_Word bytes_per_color; if (s->mode == MUSTEK_MODE_COLOR) { bytes_per_color = s->hw->cal.bytes / 3; } else { bytes_per_color = s->hw->cal.bytes; } buf_size = bytes_per_color; DBG (5, "send_calibration_lines_se: %d bytes, color: %d\n", bytes_per_color, color + 1); cmd = (SANE_Byte *) malloc (buf_size + sizeof (scsi_send_data)); if (!cmd) { DBG (1, "send_calibration_lines_se: failed to malloc %ld bytes for " "sending lines\n", (long int) (buf_size + sizeof (scsi_send_data))); return SANE_STATUS_NO_MEM; } memset (cmd, 0, sizeof (scsi_send_data)); for (column = 0; column < bytes_per_color; column++) { SANE_Word line; SANE_Word cali_word = 0; SANE_Int color_seq[] = { 2, 0, 1 }; for (line = 0; line < s->hw->cal.lines; line++) cali_word += *(s->hw->cal.buffer + line * bytes_per_color + bytes_per_color * color_seq[color] + column); if (!cali_word) cali_word = 1; cali_word = 256 * s->hw->cal.lines * 255 / cali_word - 256; if (cali_word > 255) cali_word = 255; *(cmd + sizeof (scsi_send_data) + column) = cali_word; } cmd[0] = MUSTEK_SCSI_SEND_DATA; cmd[2] = 1; cmd[6] = color + 1; cmd[7] = (buf_size >> 8) & 0xff; cmd[8] = (buf_size >> 0) & 0xff; status = dev_cmd (s, cmd, buf_size + sizeof (scsi_send_data), 0, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "send_calibration_lines_se: send failed\n"); return status; } free (cmd); return SANE_STATUS_GOOD; } static SANE_Status calibration_se (Mustek_Scanner * s) { SANE_Status status; if (!s->val[OPT_QUALITY_CAL].w || s->val[OPT_PREVIEW].w || s->mode == MUSTEK_MODE_LINEART) return SANE_STATUS_GOOD; DBG (4, "calibration_se: doing calibration\n"); s->hw->cal.lines = MIN (s->hw->cal.lines, s->hw->buffer_size / s->hw->cal.bytes); s->hw->cal.buffer = (SANE_Byte *) malloc (s->hw->cal.bytes * s->hw->cal.lines); if (!s->hw->cal.buffer) { DBG (1, "calibration_se: failed to malloc %d bytes for buffer\n", s->hw->cal.bytes * s->hw->cal.lines); return SANE_STATUS_NO_MEM; } status = get_calibration_lines_se (s); if (status != SANE_STATUS_GOOD) return status; if (s->mode == MUSTEK_MODE_GRAY) status = send_calibration_lines_se (s, 0); else { status = send_calibration_lines_se (s, 0); status = send_calibration_lines_se (s, 1); status = send_calibration_lines_se (s, 2); } if (status != SANE_STATUS_GOOD) return status; free (s->hw->cal.buffer); return SANE_STATUS_GOOD; } /* ScanExpress series */ static SANE_Status send_gamma_table_se (Mustek_Scanner * s) { SANE_Status status; SANE_Byte gamma[10 + 4096], *cp; SANE_Int color, factor, val_a, val_b; SANE_Int i, j; # define CLIP(x) ((x) < 0 ? 0 : ((x) > 255 ? 255 : (x))) memset (gamma, 0, sizeof (scsi_send_data)); gamma[0] = MUSTEK_SCSI_SEND_DATA; gamma[2] = 0x03; /* indicates gamma table */ if ((s->mode & MUSTEK_MODE_GRAY) || (s->mode & MUSTEK_MODE_COLOR)) { if (s->hw->gamma_length + sizeof (scsi_send_data) > sizeof (gamma)) return SANE_STATUS_NO_MEM; gamma[7] = (s->hw->gamma_length >> 8) & 0xff; gamma[8] = (s->hw->gamma_length >> 0) & 0xff; factor = s->hw->gamma_length / 256; color = (s->mode & MUSTEK_MODE_COLOR) ? 1 : 0; do { gamma[6] = color; if (color == 0) { val_a = s->gamma_table[0][1]; val_b = s->gamma_table[0][0]; } else { /* compose intensity gamma and color channel gamma: */ val_a = s->gamma_table[0][s->gamma_table[color][1]]; val_b = s->gamma_table[0][s->gamma_table[color][0]]; } /* Now val_a is extrapolated from [0] and [1] */ val_a = MAX (2 * val_b - val_a, 0); /* Interpolate first entries from 256 entry table */ cp = gamma + sizeof (scsi_send_data); for (j = 0; j < factor; j++) *cp++ = CLIP (((factor - j) * val_a + j * val_b + factor / 2) / factor); for (i = 1; i < 256; i++) { if (color == 0) { val_a = s->gamma_table[0][i - 1]; val_b = s->gamma_table[0][i]; } else { /* compose intensity gamma and color channel gamma: */ val_a = s->gamma_table[0][s->gamma_table[color][i - 1]]; val_b = s->gamma_table[0][s->gamma_table[color][i]]; } /* Interpolate next entries from the 256 entry table */ for (j = 0; j < factor; j++) *cp++ = CLIP (((factor - j) * val_a + j * val_b + factor / 2) / factor); } DBG (5, "send_gamma_table_se: sending table for color %d\n", gamma[6]); status = dev_cmd (s, gamma, sizeof (scsi_send_data) + s->hw->gamma_length, 0, 0); ++color; } while ((color != 1) & (color < 4) & (status == SANE_STATUS_GOOD)); return status; } else { /* In lineart mode the threshold is encoded in byte 8 as follows */ /* brightest -> 00 01 02 ... 7F 80 81 82 ... FF <- darkest image */ gamma[6] = 0x04; gamma[8] = 128 - 127 * SANE_UNFIX (s->val[OPT_BRIGHTNESS].w) / 100.0; DBG (5, "send_gamma_table_se: sending lineart threshold %2X\n", gamma[8]); return dev_cmd (s, gamma, sizeof (scsi_send_data), 0, 0); } } /* Paragon series */ static SANE_Status mode_select_paragon (Mustek_Scanner * s, SANE_Int color_code) { SANE_Int speed_code; SANE_Byte mode[19], *cp; /* calculate funky speed code: */ for (speed_code = 0; speed_list[speed_code]; ++speed_code) { if (strcmp (speed_list[speed_code], s->val[OPT_SPEED].s) == 0) break; } if (speed_code > 4) speed_code = 4; else if (speed_code < 0) speed_code = 0; if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { speed_code = 5 - speed_code; /* 1 is fast, 5 is slow */ } else { speed_code = 4 - speed_code; /* 0 is fast, 4 is slow */ } memset (mode, 0, sizeof (mode)); mode[0] = MUSTEK_SCSI_MODE_SELECT; /* set command length and resolution code: */ if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { mode[4] = 0x0b; mode[7] = s->resolution_code; } else { mode[4] = 0x0d; cp = mode + 17; STORE16L (cp, s->resolution_code); } /* set mode byte: */ mode[6] = 0x83 | (color_code << 5); if (!(s->hw->flags & MUSTEK_FLAG_USE_EIGHTS)) mode[6] |= 0x08; if (s->custom_halftone_pattern) mode[6] |= 0x10; if (s->hw->flags & MUSTEK_FLAG_PARAGON_1) { if ((s->mode == MUSTEK_MODE_LINEART) || (s->mode == MUSTEK_MODE_HALFTONE)) { mode[8] = encode_percentage (s, SANE_UNFIX (s->val[OPT_BRIGHTNESS].w)); mode[9] = encode_percentage (s, SANE_UNFIX (s->val[OPT_CONTRAST].w)); } else { mode[8] = 0x0c; mode[9] = 0x0c; } mode[10] = 2; /* grain */ if (s->val[OPT_PREVIEW].w && s->val[OPT_FAST_PREVIEW].w) mode[11] = 0x01; else if ((s->mode == MUSTEK_MODE_COLOR) || (s->mode == MUSTEK_MODE_HALFTONE)) mode[11] = 0x00; /* speed */ else mode[11] = 0x02; /* speed */ mode[12] = 0x00; /* shadow param not used by Mustek */ mode[13] = 0xff; /* highlight only used by some scanners */ mode[14] = 0x70; /* paper- */ mode[15] = 0x00; /* length */ mode[16] = 0x53; /* midtone param not used by Mustek */ } else if (s->hw->flags & MUSTEK_FLAG_PARAGON_2) { mode[8] = encode_percentage (s, SANE_UNFIX (s->val[OPT_BRIGHTNESS].w)); mode[9] = encode_percentage (s, SANE_UNFIX (s->val[OPT_CONTRAST].w)); mode[10] = 2; /* grain */ if ((s->mode == MUSTEK_MODE_COLOR) || (s->mode == MUSTEK_MODE_HALFTONE)) mode[11] = 0x00; /* speed */ else mode[11] = 0x02; /* speed */ mode[12] = 0x00; /* shadow param not used by Mustek */ mode[13] = 0x00; /* highlight param not used by Mustek */ mode[14] = 0x5c; /* paper- */ mode[15] = 0x00; /* length */ mode[16] = 0x41; /* midtone param not used by Mustek */ } else if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { if (s->mode & MUSTEK_MODE_COLOR) { mode[8] = encode_percentage (s, SANE_UNFIX (s->val[OPT_BRIGHTNESS + s->pass + 1].w - 1)); mode[9] = encode_percentage (s, SANE_UNFIX (s->val[OPT_CONTRAST + s->pass + 1].w - 1)); } else { mode[8] = encode_percentage (s, SANE_UNFIX (s->val[OPT_BRIGHTNESS].w - 1)); mode[9] = encode_percentage (s, SANE_UNFIX (s->val[OPT_CONTRAST].w - 1)); } mode[10] = s->halftone_pattern_type; mode[11] = speed_code; /* lamp setting not supported yet */ mode[12] = 0; /* shadow param not used by Mustek */ mode[13] = 0; /* highlight param not used by Mustek */ mode[14] = mode[15] = 0; /* paperlength not used by Mustek */ mode[16] = 0; /* midtone param not used by Mustek */ } else { mode[8] = encode_percentage (s, SANE_UNFIX (s->val[OPT_BRIGHTNESS].w)); mode[9] = encode_percentage (s, SANE_UNFIX (s->val[OPT_CONTRAST].w)); mode[10] = s->halftone_pattern_type; mode[11] = speed_code; /* lamp setting not supported yet */ mode[12] = 0; /* shadow param not used by Mustek */ mode[13] = 0; /* highlight param not used by Mustek */ mode[14] = mode[15] = 0; /* paperlength not used by Mustek */ mode[16] = 0; /* midtone param not used by Mustek */ } DBG (5, "mode_select: resolution_code=%d (0x%x)\n", s->resolution_code, s->resolution_code); return dev_cmd (s, mode, 6 + mode[4], 0, 0); } /* Pro series */ static SANE_Status mode_select_pro (Mustek_Scanner * s) { SANE_Byte mode[19], *cp; memset (mode, 0, sizeof (mode)); mode[0] = MUSTEK_SCSI_MODE_SELECT; mode[4] = 0x0d; if (s->mode & MUSTEK_MODE_COLOR) { if (strcmp (s->val[OPT_BIT_DEPTH].s, "12") == 0) mode[6] = 0xE0; else mode[6] = 0x60; } else if (s->mode & MUSTEK_MODE_GRAY) { if (s->val[OPT_FAST_GRAY_MODE].w) mode[6] = 0x20; else mode[6] = 0x40; } else mode[6] = 0x00; /* lineart */ mode[7] = 0; mode[8] = 0; mode[9] = 0; mode[10] = 0; mode[11] = 0x00; mode[12] = 0x27; mode[13] = 0xb0; mode[14] = 0x04; mode[15] = 0x43; mode[16] = 0x41; cp = mode + 17; STORE16L (cp, s->resolution_code); DBG (5, "mode_select_pro: resolution_code=%d (0x%x), mode=0x%x\n", s->resolution_code, s->resolution_code, mode[6]); return dev_cmd (s, mode, 6 + mode[4], 0, 0); } /* Paragon and Pro series. According to Mustek, the only builtin gamma table is a linear table, so all we support here is user-defined gamma tables. */ static SANE_Status gamma_correction (Mustek_Scanner * s, SANE_Int color_code) { SANE_Int i, j, table = 0, len = 0, bytes_per_channel, num_channels = 1; SANE_Byte gamma[4096 + 10], val, *cp; /* for Paragon models 3 x 256 is the maximum. Pro needs 4096 bytes */ if ((s->hw->flags & MUSTEK_FLAG_N) && ((s->mode & MUSTEK_MODE_LINEART) || (s->mode & MUSTEK_MODE_HALFTONE))) { /* sigh! - the 600 II N needs a (dummy) table download even for lineart and halftone mode, else it produces a completely white image. Thank Mustek for their buggy firmware ! */ memset (gamma, 0, sizeof (gamma)); gamma[0] = MUSTEK_SCSI_LOOKUP_TABLE; gamma[2] = 0x0; /* indicate any preloaded gamma table */ DBG (5, "gamma_correction: sending dummy gamma table\n"); return dev_cmd (s, gamma, 6, 0, 0); } if (((s->mode & MUSTEK_MODE_LINEART) || (s->mode & MUSTEK_MODE_HALFTONE)) && !(s->hw->flags & MUSTEK_FLAG_PRO)) { DBG (5, "gamma_correction: nothing to do in lineart mode -- exiting\n"); return SANE_STATUS_GOOD; } if ((!s->val[OPT_CUSTOM_GAMMA].w) && (!(s->hw->flags & MUSTEK_FLAG_PRO))) { /* Do we need to upload a gamma table even if the user didn't select this option? Some scanners need this work around. */ if (!(s->hw->flags & MUSTEK_FLAG_FORCE_GAMMA) || !((s->mode & MUSTEK_MODE_COLOR) || (s->mode & MUSTEK_MODE_GRAY))) { DBG (5, "gamma_correction: no custom table selected -- exititing\n"); return SANE_STATUS_GOOD; } } if (s->mode & MUSTEK_MODE_COLOR) { table = 1; if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) table += s->pass; else { if ((color_code == MUSTEK_CODE_GRAY) && !(s->hw->flags & MUSTEK_FLAG_PRO)) num_channels = 3; else table = color_code; } } else if (s->hw->flags & MUSTEK_FLAG_N) { /* it seems 600 II N (firmware 1.x at least) wants 768 bytes in * gray mode too */ num_channels = 3; } memset (gamma, 0, sizeof (gamma)); gamma[0] = MUSTEK_SCSI_LOOKUP_TABLE; if (s->hw->flags & MUSTEK_FLAG_PRO) { bytes_per_channel = 4096; len = bytes_per_channel; if (s->mode == MUSTEK_MODE_COLOR) { gamma[9] = (color_code << 6); /* color */ if (strcmp (s->val[OPT_BIT_DEPTH].s, "12") == 0) gamma[2] = 0x7f; /* medium brightness */ } else if (s->mode == MUSTEK_MODE_GRAY) { gamma[9] = 0x80; /* grayscale */ if (s->val[OPT_FAST_GRAY_MODE].w) gamma[2] = 0x7f; /* medium brightness */ } else /* lineart */ { gamma[2] = 128 - 127 * SANE_UNFIX (s->val[OPT_BRIGHTNESS].w) / 100.0; gamma[9] = 0x80; /* grayscale/lineart */ DBG (5, "gamma_correction: sending brightness information\n"); } gamma[7] = (len >> 8) & 0xff; /* big endian! */ gamma[8] = (len >> 0) & 0xff; } else { bytes_per_channel = 256; len = num_channels * bytes_per_channel; gamma[2] = 0x27; /* indicate user-selected gamma table */ if (s->hw->flags & MUSTEK_FLAG_N) { /* 600 II N always uses 6-byte cdb */ gamma[3] = (len >> 8) & 0xff; /* big endian! */ gamma[4] = (len >> 0) & 0xff; /* no way to pass color_code (?) */ } else { gamma[7] = (len >> 8) & 0xff; /* big endian! */ gamma[8] = (len >> 0) & 0xff; gamma[9] = (color_code << 6); } } if (len > 0) { cp = gamma + 10; for (j = 0; j < num_channels; ++j) { for (i = 0; i < bytes_per_channel; ++i) { if (s->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE) val = s->gamma_table[table][i * 256 / bytes_per_channel]; else val = i * 256 / bytes_per_channel; if ((s->mode & MUSTEK_MODE_COLOR) && (s->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE)) /* compose intensity gamma and color channel gamma: */ val = s->gamma_table[0][val]; *cp++ = val; } if (!(s->hw->flags & MUSTEK_FLAG_N) || !(s->mode & MUSTEK_MODE_GRAY)) table++; } } DBG (5, "gamma_correction: sending gamma table of %d bytes\n", len); return dev_cmd (s, gamma, 10 + len, 0, 0); } static SANE_Status send_gamma_table (Mustek_Scanner * s) { SANE_Status status; if (s->one_pass_color_scan) { if (s->hw->flags & MUSTEK_FLAG_N) /* This _should_ work for all one-pass scanners (not just AB306N scanners), but it doesn't work for my Paragon 600 II SP with firmware rev 1.01. Too bad, since it would simplify the gamma correction code quite a bit. */ status = gamma_correction (s, MUSTEK_CODE_GRAY); else { status = gamma_correction (s, MUSTEK_CODE_RED); if (status != SANE_STATUS_GOOD) return status; status = gamma_correction (s, MUSTEK_CODE_GREEN); if (status != SANE_STATUS_GOOD) return status; status = gamma_correction (s, MUSTEK_CODE_BLUE); } } else status = gamma_correction (s, MUSTEK_CODE_GRAY); return status; } /* ScanExpress and Paragon series */ static SANE_Status start_scan (Mustek_Scanner * s) { SANE_Byte start[6]; SANE_Status status; memset (start, 0, sizeof (start)); start[0] = MUSTEK_SCSI_START_STOP; start[4] = 0x01; DBG (4, "start_scan\n"); /* ScanExpress and Pro models don't have any variants */ if (!(s->hw->flags & MUSTEK_FLAG_SE) && !(s->hw->flags & MUSTEK_FLAG_PRO)) { if (s->mode & MUSTEK_MODE_COLOR) { if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) start[4] |= ((s->pass + 1) << 3); else start[4] |= 0x20; } /* or in single/multi bit: */ start[4] |= ((s->mode & MUSTEK_MODE_LINEART) || (s->mode & MUSTEK_MODE_HALFTONE)) ? 0 : (1 << 6); /* or in expanded resolution bit: */ if (s->val[OPT_RESOLUTION].w > (s->hw->dpi_range.max / 2) && ((s->hw->flags & MUSTEK_FLAG_THREE_PASS) || (s->hw->flags & MUSTEK_FLAG_PARAGON_1) || (s->hw->flags & MUSTEK_FLAG_PARAGON_2))) start[4] |= 1 << 7; /* block mode (or whatever) */ if (s->hw->flags & MUSTEK_FLAG_USE_BLOCK) { start[5] = 0x08; DBG (4, "start_scan: using block mode\n"); } } status = dev_cmd (s, start, sizeof (start), 0, 0); if (status != SANE_STATUS_GOOD) DBG (1, "start_scan returned status %s\n", sane_strstatus (status)); return status; } static SANE_Status do_eof (Mustek_Scanner * s) { if (s->pipe >= 0) { close (s->pipe); s->pipe = -1; DBG (5, "do_eof: closing pipe\n"); } return SANE_STATUS_EOF; } static SANE_Status do_stop (Mustek_Scanner * s) { SANE_Status status = SANE_STATUS_GOOD; DBG (5, "do_stop\n"); if (s->cancelled) status = SANE_STATUS_CANCELLED; s->scanning = SANE_FALSE; s->pass = 0; if (sanei_thread_is_valid (s->reader_pid)) { SANE_Int exit_status; struct timeval now; long int scan_time; long int scan_size; SANE_Pid pid; /* print scanning time */ gettimeofday (&now, 0); scan_time = now.tv_sec - s->start_time; if (scan_time < 1) scan_time = 1; scan_size = s->hw->bpl * s->hw->lines / 1024; DBG (2, "Scanning time was %ld seconds, %ld kB/s\n", scan_time, scan_size / scan_time); if (s->total_bytes == s->params.lines * s->params.bytes_per_line) DBG (3, "Scanned %d bytes as expected\n", s->total_bytes); else if (s->total_bytes < s->params.lines * s->params.bytes_per_line) DBG (3, "Scanned %d bytes, expected %d bytes\n", s->total_bytes, s->params.lines * s->params.bytes_per_line); else DBG (1, "Warning: Scanned %d bytes, but expected only %d bytes\n", s->total_bytes, s->params.lines * s->params.bytes_per_line); /* ensure child knows it's time to stop: */ DBG (5, "do_stop: terminating reader process\n"); sanei_thread_kill (s->reader_pid); pid = sanei_thread_waitpid (s->reader_pid, &exit_status); if (!sanei_thread_is_valid (pid)) { DBG (1, "do_stop: sanei_thread_waitpid failed, already terminated? (%s)\n", strerror (errno)); } else { DBG (2, "do_stop: reader process terminated with status %s\n", sane_strstatus (exit_status)); if (status != SANE_STATUS_CANCELLED && exit_status != SANE_STATUS_GOOD) status = exit_status; } sanei_thread_invalidate (s->reader_pid); } if (s->fd >= 0) { if (!sanei_thread_is_forked ()) sanei_scsi_req_flush_all (); /* flush SCSI queue */ if (s->hw->flags & MUSTEK_FLAG_PRO) { if (s->total_bytes < s->params.lines * s->params.bytes_per_line) status = dev_cmd (s, scsi_start_stop, sizeof (scsi_start_stop), 0, 0); dev_wait_ready (s); } else if ((s->hw->flags & MUSTEK_FLAG_PARAGON_1) || (s->hw->flags & MUSTEK_FLAG_PARAGON_2) || (s->hw->flags & MUSTEK_FLAG_THREE_PASS)) { if (s->cancelled && (s->total_bytes < s->params.lines * s->params.bytes_per_line)) status = dev_cmd (s, scsi_start_stop, sizeof (scsi_start_stop), 0, 0); } else status = dev_cmd (s, scsi_start_stop, sizeof (scsi_start_stop), 0, 0); if (force_wait) { DBG (5, "do_stop: waiting for scanner to be ready\n"); dev_wait_ready (s); } do_eof (s); DBG (5, "do_stop: closing scanner\n"); dev_close (s); s->fd = -1; } DBG (5, "do_stop: finished\n"); return status; } /* Paragon I + II: Determine the CCD's distance between the primary color lines. */ static SANE_Status line_distance (Mustek_Scanner * s) { SANE_Int factor, color, res, peak_res; SANE_Status status; SANE_Byte result[5]; size_t len; memset (result, 0, 5); res = SANE_UNFIX (s->val[OPT_RESOLUTION].w) + 0.5; peak_res = SANE_UNFIX (s->hw->dpi_range.max) + 0.5; s->ld.buf[0] = NULL; len = sizeof (result); status = dev_cmd (s, scsi_ccd_distance, sizeof (scsi_ccd_distance), result, &len); if (status != SANE_STATUS_GOOD) return status; DBG (3, "line_distance: got factor=%d, (r/g/b)=(%d/%d/%d)\n", result[0] | (result[1] << 8), result[2], result[3], result[4]); if (s->hw->flags & MUSTEK_FLAG_LD_FIX) { result[0] = 0xff; result[1] = 0xff; if (s->mode & MUSTEK_MODE_COLOR) { if (s->hw->flags & MUSTEK_FLAG_N) { /* According to Andreas Czechanowski, the line-distance values returned for the AB306N scanners are garbage, so we have to fix things up manually. Not good. This seems to be true only for firmware 2.00 which is extremely seldom.. AB306N scanners with firmware 1.01 don't need this fix. */ if (peak_res == 600) { if (res < 51) { result[0] = 8; result[1] = 0; result[2] = 0; result[3] = 2; result[4] = 3; } else if (res < 75 || (res > 90 && res < 150)) { /* 51-74 and 91-149 dpi: */ result[0] = 4; result[1] = 0; result[2] = 0; result[3] = 3; result[4] = 5; } else if (res <= 90 || (res >= 150 && res <= 300)) { /* 75-90 and 150-300 dpi: */ result[0] = 2; result[1] = 0; result[2] = 0; result[3] = 5; result[4] = 9; } else { /* 301-600 dpi: */ result[0] = 1; result[1] = 0; result[2] = 0; result[3] = 9; result[4] = 23; } } else DBG (1, "don't know how to fix up line-distance for %d dpi\n", peak_res); } else if (!(s->hw->flags & MUSTEK_FLAG_LD_NONE)) { if (peak_res == 600) { if (res < 51) { /* 1-50 dpi: */ result[0] = 4; result[1] = 0; result[2] = 0; result[3] = 3; result[4] = 5; } else if (res <= 300) { /* 51-300 dpi: */ result[0] = 2; result[1] = 0; result[2] = 0; result[3] = 5; result[4] = 9; } else { /*301-600 dpi: */ result[0] = 1; result[1] = 0; result[2] = 0; result[3] = 9; result[4] = 17; } } else if (peak_res == 800) { if (res < 72) { /* 1-71 dpi: */ result[0] = 4; result[1] = 0; result[2] = 0; result[3] = 3; result[4] = 5; } else if (res <= 400) { /* 72-400 dpi: */ result[0] = 2; result[1] = 0; result[2] = 0; result[3] = 9; result[4] = 17; } else { /*401-800 dpi: */ result[0] = 1; result[1] = 0; result[2] = 0; result[3] = 16; result[4] = 32; } } } } DBG (4, "line_distance: fixed up to factor=%d, (r/g/b)=(%d/%d/%d)\n", result[0] | (result[1] << 8), result[2], result[3], result[4]); } factor = result[0] | (result[1] << 8); if (factor != 0xffff) { /* need to do line-distance adjustment ourselves... */ s->ld.max_value = peak_res; if (factor == 0) { if (res <= peak_res / 2) res *= 2; } else res *= factor; s->ld.peak_res = res; for (color = 0; color < 3; ++color) { s->ld.dist[color] = result[2 + color]; s->ld.quant[color] = s->ld.max_value; s->ld.index[color] = -s->ld.dist[color]; } s->ld.lmod3 = -1; DBG (4, "line_distance: max_value = %d, peak_res = %d, ld.quant = " "(%d, %d, %d)\n", s->ld.max_value, s->ld.peak_res, s->ld.quant[0], s->ld.quant[1], s->ld.quant[2]); } else s->ld.max_value = 0; return SANE_STATUS_GOOD; } /* Paragon + Pro series */ static SANE_Status get_image_status (Mustek_Scanner * s, SANE_Int * bpl, SANE_Int * lines) { SANE_Byte result[6]; SANE_Status status; size_t len; SANE_Int busy, offset; long res, half_res; memset (result, 0, 6); /* The 600 II N v1.01 and Paragon 12000SP need a larger scan-area for line-distance correction in color mode */ offset = 0; if ((s->hw->flags & MUSTEK_FLAG_LD_N1) && (s->mode & MUSTEK_MODE_COLOR)) offset = s->ld.dist[1]; else if ((s->hw->flags & MUSTEK_FLAG_LD_BLOCK) && (s->hw->flags & MUSTEK_FLAG_PARAGON_1) && (s->mode & MUSTEK_MODE_COLOR)) offset = MAX_LINE_DIST * SANE_UNFIX (s->val[OPT_RESOLUTION].w) / SANE_UNFIX (s->hw->dpi_range.max); do { len = sizeof (result); status = dev_cmd (s, scsi_get_image_status, sizeof (scsi_get_image_status), result, &len); if (status != SANE_STATUS_GOOD) return status; busy = result[0]; if (busy) usleep (100000); if (!s->scanning) /* ? */ if (!(s->hw->flags & MUSTEK_FLAG_PRO)) return do_stop (s); } while (busy); s->hw->bpl = result[1] | (result[2] << 8); s->hw->lines = result[3] | (result[4] << 8) | (result[5] << 16); res = SANE_UNFIX (s->val[OPT_RESOLUTION].w); half_res = SANE_UNFIX (s->hw->dpi_range.max) / 2; /* Need to interpolate resolutions > max x-resolution? */ if ((s->hw->flags & MUSTEK_FLAG_ENLARGE_X) && (res > half_res)) { *bpl = (s->hw->bpl * res) / half_res / 3; *bpl *= 3; DBG (4, "get_image_status: resolution > x-max; enlarge %d bpl to " "%d bpl\n", s->hw->bpl, *bpl); } else *bpl = s->hw->bpl; *lines = s->hw->lines - offset; DBG (3, "get_image_status: bytes_per_line=%d, lines=%d (offset = %d)\n", *bpl, *lines, offset); return SANE_STATUS_GOOD; } /* ScanExpress models */ static SANE_Status get_window (Mustek_Scanner * s, SANE_Int * bpl, SANE_Int * lines, SANE_Int * pixels) { SANE_Byte result[48]; SANE_Status status; size_t len; SANE_Int color; long res, half_res; res = s->resolution_code; half_res = SANE_UNFIX (s->hw->dpi_range.max) / 2; DBG (5, "get_window: resolution: %ld dpi (hardware: %d dpi)\n", res, s->ld.peak_res); len = sizeof (result); status = dev_cmd (s, scsi_get_window, sizeof (scsi_get_window), result, &len); if (status != SANE_STATUS_GOOD) return status; if (!s->scanning) return do_stop (s); s->hw->cal.bytes = (result[6] << 24) | (result[7] << 16) | (result[8] << 8) | (result[9] << 0); s->hw->cal.lines = (result[10] << 24) | (result[11] << 16) | (result[12] << 8) | (result[13] << 0); DBG (4, "get_window: calibration bpl=%d, lines=%d\n", s->hw->cal.bytes, s->hw->cal.lines); s->hw->bpl = (result[14] << 24) | (result[15] << 16) | (result[16] << 8) | result[17]; s->hw->lines = (result[18] << 24) | (result[19] << 16) | (result[20] << 8) | result[21]; DBG (4, "get_window: scan bpl=%d, lines=%d\n", s->hw->bpl, s->hw->lines); if ((s->hw->cal.bytes == 0) || (s->hw->cal.lines == 0) || (s->hw->bpl == 0) || (s->hw->lines == 0)) { DBG (1, "get_window: oops, none of these values should be 0 " "-- exiting\n"); return SANE_STATUS_INVAL; } s->hw->gamma_length = 1 << result[26]; DBG (4, "get_window: gamma length=%d\n", s->hw->gamma_length); if (s->mode & MUSTEK_MODE_COLOR) { s->ld.buf[0] = NULL; for (color = 0; color < 3; ++color) { s->ld.dist[color] = result[42 + color]; } DBG (4, "get_window: LD res=%d, (r/g/b)=(%d/%d/%d)\n", (result[40] << 8) | result[41], s->ld.dist[0], s->ld.dist[1], s->ld.dist[2]); s->ld.max_value = (result[40] << 8) | result[41]; if ((s->hw->flags & MUSTEK_FLAG_ENLARGE_X) && (res > half_res)) { /* We must interpolate resolutions > max x-resolution */ *bpl = *pixels = (((s->hw->bpl / 3) * res) / half_res) * 3; } else { /* Scale down the image according to desired resolution */ *bpl = *pixels = (((s->hw->bpl / 3) * res) / s->ld.peak_res) * 3; } *lines = (s->hw->lines - s->ld.dist[2]) * res / s->ld.peak_res; } else { if ((s->hw->flags & MUSTEK_FLAG_ENLARGE_X) && (res > half_res)) { /* We must interpolate resolutions > max x-resolution */ *bpl = s->hw->bpl * res / half_res; } else { *bpl = s->hw->bpl; } *lines = s->hw->lines; } DBG (4, "get_window: bpl = %d (hardware: %d), lines = %d (hardware: %d)\n", *bpl, s->hw->bpl, *lines, s->hw->lines); return SANE_STATUS_GOOD; } static SANE_Status adf_and_backtrack (Mustek_Scanner * s) { SANE_Byte backtrack[6]; SANE_Int code = 0x80; if (!(s->hw->flags & MUSTEK_FLAG_NO_BACKTRACK)) code |= 0x02; /* enable backtracking */ if (strcmp (s->val[OPT_SOURCE].s, "Automatic Document Feeder") == 0) code |= 0x01; else if (strcmp (s->val[OPT_SOURCE].s, "Transparency Adapter") == 0) code |= 0x04; memset (backtrack, 0, sizeof (backtrack)); backtrack[0] = MUSTEK_SCSI_ADF_AND_BACKTRACK; backtrack[4] = code; DBG (4, "adf_and_backtrack: backtrack: %s; ADF: %s; TA: %s\n", code & 0x02 ? "yes" : "no", code & 0x01 ? "yes" : "no", code & 0x04 ? "yes" : "no"); return dev_cmd (s, backtrack, sizeof (backtrack), 0, 0); } /* 600 II N firmware 2.x */ static SANE_Int fix_line_distance_n_2 (Mustek_Scanner * s, SANE_Int num_lines, SANE_Int bpl, SANE_Byte * raw, SANE_Byte * out) { SANE_Byte *out_end, *out_ptr, *raw_end = raw + num_lines * bpl; SANE_Int c, num_saved_lines, line; if (!s->ld.buf[0]) { /* This buffer must be big enough to hold maximum line distance times max_bpl bytes. The maximum line distance for the Paragon 600 II N scanner is 23, so 40 should be safe. */ DBG (5, "fix_line_distance_n_2: allocating temp buffer of %d*%d bytes\n", MAX_LINE_DIST, bpl); s->ld.buf[0] = malloc (MAX_LINE_DIST * (long) bpl); if (!s->ld.buf[0]) { DBG (1, "fix_line_distance_n_2: failed to malloc temporary buffer\n"); return 0; } } num_saved_lines = s->ld.index[0] - s->ld.index[2]; if (num_saved_lines > 0) /* restore the previously saved lines: */ memcpy (out, s->ld.buf[0], num_saved_lines * bpl); while (1) { if (++s->ld.lmod3 >= 3) s->ld.lmod3 = 0; c = color_seq[s->ld.lmod3]; if (s->ld.index[c] < 0) ++s->ld.index[c]; else if (s->ld.index[c] < s->params.lines) { s->ld.quant[c] += s->ld.peak_res; if (s->ld.quant[c] > s->ld.max_value) { s->ld.quant[c] -= s->ld.max_value; line = s->ld.index[c]++ - s->ld.ld_line; out_ptr = out + line * bpl + c; out_end = out_ptr + bpl; while (out_ptr != out_end) { *out_ptr = *raw++; out_ptr += 3; } if (raw >= raw_end) { DBG (3, "fix_line_distance_n_2: lmod3=%d, " "index=(%d,%d,%d)\n", s->ld.lmod3, s->ld.index[0], s->ld.index[1], s->ld.index[2]); num_lines = s->ld.index[2] - s->ld.ld_line; /* copy away the lines with at least one missing color component, so that we can interleave them with new scan data on the next call */ num_saved_lines = s->ld.index[0] - s->ld.index[2]; memcpy (s->ld.buf[0], out + num_lines * bpl, num_saved_lines * bpl); /* notice the number of lines we processed */ s->ld.ld_line = s->ld.index[2]; /* return number of complete (r+g+b) lines */ return num_lines; } } } } } /* 600 II N firmware 1.x */ static SANE_Int fix_line_distance_n_1 (Mustek_Scanner * s, SANE_Int num_lines, SANE_Int bpl, SANE_Byte * raw, SANE_Byte * out) { SANE_Byte *out_end, *out_ptr, *raw_end = raw + num_lines * bpl; SANE_Int c, num_saved_lines, line; /* For firmware 1.x the scanarea must be soemwhat bigger than needed because of the linedistance correction */ if (!s->ld.buf[0]) { /* This buffer must be big enough to hold maximum line distance times max_bpl bytes. The maximum line distance for the 600 II N is 23, so 40 is safe. */ DBG (5, "fix_line_distance_n_1: allocating temp buffer of %d*%d bytes\n", MAX_LINE_DIST, bpl); s->ld.buf[0] = malloc (MAX_LINE_DIST * (long) bpl); if (!s->ld.buf[0]) { DBG (1, "fix_line_distance_n_1: failed to malloc temporary buffer\n"); return 0; } } num_saved_lines = s->ld.index[0] - s->ld.index[1]; DBG (5, "fix_line_distance_n_1: got %d lines, %d bpl\n", num_lines, bpl); DBG (5, "fix_line_distance_n_1: num_saved_lines = %d; peak_res = %d; " "max_value = %d\n", num_saved_lines, s->ld.peak_res, s->ld.max_value); if (num_saved_lines > 0) /* restore the previously saved lines: */ memcpy (out, s->ld.buf[0], num_saved_lines * bpl); while (1) { if (++s->ld.lmod3 >= 3) s->ld.lmod3 = 0; c = s->ld.lmod3; if (s->ld.index[c] < 0) ++s->ld.index[c]; else { s->ld.quant[c] += s->ld.peak_res; if (s->ld.quant[c] > s->ld.max_value) { s->ld.quant[c] -= s->ld.max_value; line = s->ld.index[c]++ - s->ld.ld_line; out_ptr = out + line * bpl + c; out_end = out_ptr + bpl; while (out_ptr != out_end) { *out_ptr = *raw++; out_ptr += 3; } DBG (5, "fix_line_distance_n_1: copied line %d (color %d)\n", line, c); } } if ((raw >= raw_end) || ((s->ld.index[0] >= s->params.lines) && (s->ld.index[1] >= s->params.lines) && (s->ld.index[2] >= s->params.lines))) { DBG (3, "fix_line_distance_n_1: lmod3=%d, index=(%d,%d,%d)%s\n", s->ld.lmod3, s->ld.index[0], s->ld.index[1], s->ld.index[2], raw >= raw_end ? " raw >= raw_end" : ""); num_lines = s->ld.index[1] - s->ld.ld_line; if (num_lines < 0) num_lines = 0; DBG (4, "fix_line_distance_n_1: lines ready: %d\n", num_lines); /* copy away the lines with at least one missing color component, so that we can interleave them with new scan data on the next call */ num_saved_lines = s->ld.index[0] - s->ld.index[1]; DBG (4, "fix_line_distance_n_1: copied %d lines to " "ld.buf\n", num_saved_lines); memcpy (s->ld.buf[0], out + num_lines * bpl, num_saved_lines * bpl); /* notice the number of lines we processed */ s->ld.ld_line = s->ld.index[1]; if (s->ld.ld_line < 0) s->ld.ld_line = 0; /* return number of complete (r+g+b) lines */ return num_lines; } } } /* For ScanExpress models */ static SANE_Int fix_line_distance_se (Mustek_Scanner * s, SANE_Int num_lines, SANE_Int bpl, SANE_Byte * raw, SANE_Byte * out) { SANE_Byte *raw_end = raw + num_lines * bpl; SANE_Byte *out_ptr[3], *ptr; SANE_Int index[3], lines[3], quant[3], dist[3]; SANE_Int max_value; SANE_Int color, pixel, res, half_res, scale; SANE_Int bpc = bpl / 3; /* bytes per color (per line) */ SANE_Bool preview = SANE_FALSE; res = s->resolution_code; half_res = SANE_UNFIX (s->hw->dpi_range.max) / 2; max_value = s->ld.max_value; if ((s->val[OPT_PREVIEW].w == SANE_TRUE) && (s->val[OPT_FAST_PREVIEW].w == SANE_TRUE)) { preview = SANE_TRUE; /*max_value = 75; */ dist[0] = s->ld.dist[0]; dist[1] = s->ld.dist[1]; dist[2] = s->ld.dist[2]; } else { dist[0] = s->ld.dist[0]; dist[1] = s->ld.dist[1]; dist[2] = s->ld.dist[2]; } if (!s->ld.buf[0]) { /* This buffer must be big enough to hold maximum line distance times 3*bpl bytes. The maximum line distance for 1200 dpi is 32 */ DBG (5, "fix_line_distance_se: allocating temp buffer of %d*%d bytes\n", 3 * MAX_LINE_DIST, bpc); s->ld.buf[0] = malloc (3 * MAX_LINE_DIST * (long) bpc); if (!s->ld.buf[0]) { DBG (1, "fix_line_distance_se: failed to malloc temporary buffer\n"); return 0; } /* Note that either s->ld.buf[1] or s->ld.buf[2] is never used. */ s->ld.buf[1] = s->ld.buf[2] = s->ld.buf[0] + 2 * MAX_LINE_DIST * (long) bpc; /* Since the blocks don't start necessarily with red note color. */ s->ld.color = 0; /* The scan area must be longer than desired because of the line distance. So me must count complete (r+g+b) lines already submitted to the fronted. */ s->ld.ld_line = s->params.lines; for (color = 0; color < 3; ++color) { s->ld.index[color] = -dist[color]; s->ld.quant[color] = 0; s->ld.saved[color] = 0; } } num_lines *= 3; DBG (5, "fix_line_distance_se: start color: %d; %d lines \n", s->ld.color, num_lines); /* First scan the lines read and count red, green and blue ones. Since we will step through the lines a second time we must not alter any global variables here! */ for (color = 0; color < 3; ++color) { index[color] = s->ld.index[color]; lines[color] = s->ld.saved[color]; quant[color] = s->ld.quant[color]; } color = s->ld.color; while (num_lines > 0) { if (index[color] < 0) ++index[color]; else { quant[color] += res; if (quant[color] >= max_value) { /* This line must be processed, not dropped. */ quant[color] -= max_value; ++lines[color]; --num_lines; } else if (!preview) --num_lines; } if (++color > 2) color = 0; } /* Calculate how many triples of color lines we can output now. Because the number of available red lines is always greater than for the other colors we may ignore the red ones here. */ num_lines = MIN (lines[1], lines[2]); DBG (5, "fix_line_distance_se: saved lines: %d/%d/%d\n", s->ld.saved[0], s->ld.saved[1], s->ld.saved[2]); DBG (5, "fix_line_distance_se: available: %d/%d/%d --> triples: %d\n", lines[0], lines[1], lines[2], num_lines); lines[0] = lines[1] = lines[2] = num_lines; /* Output the color lines saved in previous call first. Note that data is converted in r/g/b interleave on the fly. */ for (color = 0; color < 3; ++color) { out_ptr[color] = out + color; ptr = s->ld.buf[color]; while ((s->ld.saved[color] > 0) && (lines[color] > 0)) { scale = 0; if ((s->hw->flags & MUSTEK_FLAG_ENLARGE_X) && (res > half_res)) { /* Need to enlarge x-resolution */ SANE_Byte *ptr_start = ptr; for (pixel = 0; pixel < s->params.pixels_per_line; ++pixel) { *out_ptr[color] = *ptr; out_ptr[color] += 3; scale += half_res; if (scale >= half_res) { scale -= res; ++ptr; } } DBG (5, "fix_line_distance_se: got saved line: %d; line: %d; " "color: %d; raw bytes: %lu; out bytes: %d\n", s->ld.saved[color], lines[color], color, (u_long) (ptr - ptr_start), s->params.pixels_per_line); ptr = ptr_start + bpc; } else { if (preview) { for (pixel = 0; pixel < bpc; ++pixel) { *out_ptr[color] = *ptr++; out_ptr[color] += 3; } } else { for (pixel = 0; pixel < bpc; ++pixel) { scale += res; if (scale >= max_value) { scale -= max_value; *out_ptr[color] = *ptr; out_ptr[color] += 3; } ++ptr; } } DBG (5, "fix_line_distance_se: got saved line: %d; line: %d; " "color: %d\n", s->ld.saved[color], lines[color], color); } --(s->ld.saved[color]); --lines[color]; } if (s->ld.saved[color] > 0) memmove (s->ld.buf[color], ptr, s->ld.saved[color] * bpc); } while (1) { if (s->ld.index[s->ld.color] < 0) ++(s->ld.index[s->ld.color]); else { s->ld.quant[s->ld.color] += res; if (s->ld.quant[s->ld.color] >= max_value) { /* This line must be processed, not dropped. */ s->ld.quant[s->ld.color] -= max_value; if (lines[s->ld.color] > 0) { /* There's still a line to be output for current color. Then shuffle current color line to output buffer. */ scale = 0; /* need to enlarge x-resolution? */ if ((s->hw->flags & MUSTEK_FLAG_ENLARGE_X) && (res > half_res)) { SANE_Byte *raw_start = raw; for (pixel = 0; pixel < s->params.pixels_per_line; ++pixel) { *out_ptr[s->ld.color] = *raw; out_ptr[s->ld.color] += 3; scale += half_res; if (scale >= half_res) { scale -= res; ++raw; } } DBG (5, "fix_line_distance_se: got line: %d; color: %d; " "raw bytes: %lu; out bytes: %d\n", lines[s->ld.color], s->ld.color, (u_long) (raw - raw_start), s->params.pixels_per_line); raw = raw_start + bpc; } else { if (preview) { for (pixel = 0; pixel < bpc; ++pixel) { *out_ptr[s->ld.color] = *raw++; out_ptr[s->ld.color] += 3; } } else { for (pixel = 0; pixel < bpc; ++pixel) { scale += res; if (scale >= max_value) { scale -= max_value; *out_ptr[s->ld.color] = *raw; out_ptr[s->ld.color] += 3; } ++raw; } } DBG (5, "fix_line_distance_se: got line: %d; color: " "%d\n", lines[s->ld.color], s->ld.color); } --lines[s->ld.color]; } else { /* At least one component missing, so save this line. */ memcpy (s->ld.buf[s->ld.color] + s->ld.saved[s->ld.color] * bpc, raw, bpc); DBG (5, "fix_line_distance_se: saved line %d; color %d\n", s->ld.saved[s->ld.color], s->ld.color); ++(s->ld.saved[s->ld.color]); raw += bpc; } } else { if (!preview) raw += bpc; DBG (5, "fix_line_distance_se: ignored line; color: %d\n", s->ld.color); } if (raw >= raw_end) { /* Reduce num_lines if we encounter excess lines. */ if (num_lines > s->ld.ld_line) num_lines = s->ld.ld_line; s->ld.ld_line -= num_lines; if (++s->ld.color > 2) s->ld.color = 0; return num_lines; } } if (++s->ld.color > 2) s->ld.color = 0; } } /* For Pro models. Not really a linedistance correction (they don't need one) only enlarging x-res here */ static void fix_line_distance_pro (Mustek_Scanner * s, SANE_Int num_lines, SANE_Int bpl, SANE_Byte * raw, SANE_Byte * out) { SANE_Byte *out_addr, *in_addr; SANE_Int res, half_res, y, x_out, x_in; res = SANE_UNFIX (s->val[OPT_RESOLUTION].w); half_res = SANE_UNFIX (s->hw->dpi_range.max) / 2; DBG (5, "fix_line_distance_pro: res=%d; halfres=%d; num_lines=%d; bpl=%d\n", res, half_res, num_lines, bpl); if (strcmp (s->val[OPT_BIT_DEPTH].s, "12") == 0) { if ((s->hw->flags & MUSTEK_FLAG_ENLARGE_X) && (res > half_res)) { /*12 bit, need to enlarge x-resolution */ DBG (5, "fix_line_distance_pro: res > half_res --> need to " "enlarge x\n"); if (little_endian ()) for (y = 0; y < num_lines; y++) { for (x_out = 0; x_out < s->params.pixels_per_line; x_out++) { x_in = x_out * bpl / s->params.bytes_per_line / 2; x_in *= 2; out_addr = out + y * s->params.bytes_per_line + x_out * 6; in_addr = raw + y * bpl + x_in * 6; *(out_addr) = *(in_addr) << 4; *(out_addr + 1) = (*(in_addr) >> 4) + (*(in_addr + 1) << 4); *(out_addr + 2) = *(in_addr + 2) << 4; *(out_addr + 3) = (*(in_addr + 2) >> 4) + (*(in_addr + 3) << 4); *(out_addr + 4) = *(in_addr + 4) << 4; *(out_addr + 5) = (*(in_addr + 4) >> 4) + (*(in_addr + 5) << 4); } } else /* big endian */ for (y = 0; y < num_lines; y++) { for (x_out = 0; x_out < s->params.pixels_per_line; x_out++) { x_in = x_out * bpl / s->params.bytes_per_line / 2; out_addr = out + y * s->params.bytes_per_line + x_out * 6; in_addr = raw + y * bpl + x_in * 6; *(out_addr) = (*(in_addr) >> 4) + (*(in_addr + 1) << 4); *(out_addr + 1) = *(in_addr) << 4; *(out_addr + 2) = (*(in_addr + 2) >> 4) + (*(in_addr + 3) << 4); *(out_addr + 3) = *(in_addr + 2) << 4; *(out_addr + 4) = (*(in_addr + 4) >> 4) + (*(in_addr + 5) << 4); *(out_addr + 5) = *(in_addr + 4) << 4; } } } else /* 12 bit, no need to enlarge x */ { SANE_Word pixel; if (little_endian ()) for (pixel = 0; pixel < (num_lines * bpl / 2); pixel++) { *(out + pixel * 2) = *(raw + pixel * 2) << 4; *(out + pixel * 2 + 1) = (*(raw + pixel * 2) >> 4) + (*(raw + pixel * 2 + 1) << 4); } else /* big endian */ for (pixel = 0; pixel < (num_lines * bpl / 2); pixel++) { *(out + pixel * 2) = (*(raw + pixel * 2) >> 4) + (*(raw + pixel * 2 + 1) << 4); *(out + pixel * 2 + 1) = *(raw + pixel * 2) << 4; } } } else /* 8 bit */ { /* need to enlarge x-resolution? */ if ((s->hw->flags & MUSTEK_FLAG_ENLARGE_X) && (res > half_res)) { DBG (5, "fix_line_distance_pro: res > half_res --> need to " "enlarge x\n"); for (y = 0; y < num_lines; y++) { for (x_out = 0; x_out < s->params.pixels_per_line; x_out++) { x_in = x_out * bpl / s->params.bytes_per_line; out_addr = out + y * s->params.bytes_per_line + x_out * 3; in_addr = raw + y * bpl + x_in * 3; *(out_addr) = *(in_addr); *(out_addr + 1) = *(in_addr + 1); *(out_addr + 2) = *(in_addr + 2); } } } else memcpy (out, raw, num_lines * bpl); } return; } /* For MFS-08000SP, MFS-06000SP. MFC-08000CZ, MFC-06000CZ */ static void fix_line_distance_normal (Mustek_Scanner * s, SANE_Int num_lines, SANE_Int bpl, SANE_Byte * raw, SANE_Byte * out) { SANE_Byte *out_end, *out_ptr, *raw_end = raw + num_lines * bpl; SANE_Int index[3]; /* index of the next output line for color C */ SANE_Int i, color; /* Initialize the indices with the line distances that were returned by the CCD linedistance command or set manually (option linedistance-fix). We want to skip data for the first OFFSET rounds, so we initialize the indices to the negative of this offset. */ DBG (5, "fix_line_distance_normal: %d lines, %d bpl\n", num_lines, bpl); for (color = 0; color < 3; ++color) index[color] = -s->ld.dist[color]; while (1) { for (i = 0; i < 3; ++i) { color = color_seq[i]; if (index[color] < 0) ++index[color]; else if (index[color] < num_lines) { s->ld.quant[color] += s->ld.peak_res; if (s->ld.quant[color] > s->ld.max_value) { s->ld.quant[color] -= s->ld.max_value; out_ptr = out + index[color] * bpl + color; out_end = out_ptr + bpl; while (out_ptr != out_end) { *out_ptr = *raw++; out_ptr += 3; } ++index[color]; if (raw >= raw_end) return; } } } } } /* Paragon series I + II. */ static SANE_Int fix_line_distance_block (Mustek_Scanner * s, SANE_Int num_lines, SANE_Int bpl, SANE_Byte * raw, SANE_Byte * out, SANE_Int num_lines_total) { SANE_Byte *out_end, *out_ptr, *raw_end = raw + num_lines * bpl; SANE_Int c, num_saved_lines, line, max_index, min_index; if (!s->ld.buf[0]) { DBG (5, "fix_line_distance_block: allocating temp buffer of %d*%d " "bytes\n", MAX_LINE_DIST, bpl); s->ld.buf[0] = malloc (MAX_LINE_DIST * (long) bpl); if (!s->ld.buf[0]) { DBG (1, "fix_line_distance_block: failed to malloc temporary " "buffer\n"); return 0; } } DBG (5, "fix_line_distance_block: s->ld.index = {%d, %d, %d}, " "s->ld.lmod3 = %d\n", s->ld.index[0], s->ld.index[1], s->ld.index[2], s->ld.lmod3); DBG (5, "fix_line_distance_block: s->ld.quant = {%d, %d, %d}, " "s->ld.max_value = %d\n", s->ld.quant[0], s->ld.quant[1], s->ld.quant[2], s->ld.max_value); DBG (5, "fix_line_distance_block: s->ld.peak_res = %d, s->ld.ld_line = %d\n", s->ld.peak_res, s->ld.ld_line); /* search maximum and minimum index */ max_index = MAX (s->ld.index[0], MAX (s->ld.index[1], s->ld.index[2])); min_index = MIN (s->ld.index[0], MIN (s->ld.index[1], s->ld.index[2])); num_saved_lines = max_index - min_index; if (s->ld.index[0] == 0) num_saved_lines = 0; /* restore the previously saved lines: */ memcpy (out, s->ld.buf[0], num_saved_lines * bpl); DBG (5, "fix_line_distance_block: copied %d lines from " "ld.buf to buffer (max=%d, min=%d)\n", num_saved_lines, max_index, min_index); while (1) { if (++s->ld.lmod3 >= 3) s->ld.lmod3 = 0; c = color_seq[s->ld.lmod3]; if (s->ld.index[c] < 0) ++s->ld.index[c]; else if (s->ld.index[c] < num_lines_total) { s->ld.quant[c] += s->ld.peak_res; if (s->ld.quant[c] > s->ld.max_value) { s->ld.quant[c] -= s->ld.max_value; line = s->ld.index[c]++ - s->ld.ld_line; out_ptr = out + line * bpl + c; out_end = out_ptr + bpl; while (out_ptr != out_end) { *out_ptr = *raw++; out_ptr += 3; } DBG (5, "fix_line_distance_block: copied line %d (color %d)\n", line + s->ld.ld_line, c); max_index = MAX (s->ld.index[0], MAX (s->ld.index[1], s->ld.index[2])); min_index = MIN (s->ld.index[0], MIN (s->ld.index[1], s->ld.index[2])); if ((raw >= raw_end) || ((min_index >= num_lines_total))) { DBG (5, "fix_line_distance_block: got num_lines: %d\n", num_lines); num_lines = min_index - s->ld.ld_line; if (num_lines < 0) num_lines = 0; if ((s->total_lines + num_lines) > s->params.lines) num_lines = s->params.lines - s->total_lines; s->total_lines += num_lines; /* copy away the lines with at least one missing color component, so that we can interleave them with new scan data on the next call */ num_saved_lines = max_index - min_index; DBG (5, "fix_line_distance_block: num_saved_lines = %d; " "num_lines = %d; bpl = %d\n", num_saved_lines, num_lines, bpl); memcpy (s->ld.buf[0], out + num_lines * bpl, num_saved_lines * bpl); DBG (5, "fix_line_distance_block: copied %d lines to " "ld.buf\n", num_saved_lines); /* notice the number of lines we processed */ s->ld.ld_line = min_index; if (s->ld.ld_line < 0) s->ld.ld_line = 0; DBG (4, "fix_line_distance_block: lmod3=%d, " "index=(%d,%d,%d), line = %d, lines = %d\n", s->ld.lmod3, s->ld.index[0], s->ld.index[1], s->ld.index[2], s->ld.ld_line, num_lines); /* return number of complete (r+g+b) lines */ return num_lines; } } } } } /* For MFS-1200SP 1.00 and others */ /* No LD correction necessary, just shuffle around data */ static SANE_Int fix_line_distance_none (Mustek_Scanner * s, SANE_Int num_lines, SANE_Int bpl, SANE_Byte * raw, SANE_Byte * out) { SANE_Byte *red_ptr, *grn_ptr, *blu_ptr, *ptr, *ptr_end; SANE_Word y; ptr = out; red_ptr = raw; DBG (5, "fix_line_distance_none: no ld correction necessary (%d lines)\n", num_lines); s->ld.ld_line += num_lines; if (s->ld.ld_line > s->params.lines) num_lines -= (s->ld.ld_line - s->params.lines); if (num_lines < 0) num_lines = 0; DBG (5, "fix_line_distance_none: using %d lines (ld_line = %d, " "s->params.lines = %d)\n", num_lines, s->ld.ld_line, s->params.lines); for (y = 0; y < num_lines; ++y) { grn_ptr = red_ptr + bpl / 3; blu_ptr = grn_ptr + bpl / 3; ptr_end = red_ptr + bpl; while (blu_ptr != ptr_end) { *ptr++ = *red_ptr++; *ptr++ = *grn_ptr++; *ptr++ = *blu_ptr++; } red_ptr = ptr_end; } return num_lines; } static SANE_Status init_options (Mustek_Scanner * s) { SANE_Int i, j, gammasize; memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].name = ""; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].size = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; if (s->hw->flags & MUSTEK_FLAG_SE) { s->opt[OPT_MODE].size = max_string_size (mode_list_se); s->opt[OPT_MODE].constraint.string_list = mode_list_se; s->val[OPT_MODE].s = strdup (mode_list_se[1]); if (!s->val[OPT_MODE].s) return SANE_STATUS_NO_MEM; } else { s->opt[OPT_MODE].size = max_string_size (mode_list_paragon); s->opt[OPT_MODE].constraint.string_list = mode_list_paragon; s->val[OPT_MODE].s = strdup (mode_list_paragon[2]); if (!s->val[OPT_MODE].s) return SANE_STATUS_NO_MEM; } /* fast gray mode (pro models) */ s->opt[OPT_FAST_GRAY_MODE].name = "fast-gray-mode"; s->opt[OPT_FAST_GRAY_MODE].title = SANE_I18N ("Fast gray mode"); s->opt[OPT_FAST_GRAY_MODE].desc = SANE_I18N ("Scan in fast gray mode " "(lower quality)."); s->opt[OPT_FAST_GRAY_MODE].type = SANE_TYPE_BOOL; s->val[OPT_FAST_GRAY_MODE].w = SANE_FALSE; s->opt[OPT_FAST_GRAY_MODE].cap |= SANE_CAP_INACTIVE; if (s->hw->flags & MUSTEK_FLAG_PRO) { /* Only Pro models support fast gray mode */ s->opt[OPT_FAST_GRAY_MODE].cap &= ~SANE_CAP_INACTIVE; } /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_FIXED; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_RESOLUTION].constraint.range = &s->hw->dpi_range; s->val[OPT_RESOLUTION].w = MAX (SANE_FIX (72), s->hw->dpi_range.min); /* bit depth */ s->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].type = SANE_TYPE_STRING; s->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BIT_DEPTH].size = max_string_size (bit_depth_list_pro); s->opt[OPT_BIT_DEPTH].constraint.string_list = bit_depth_list_pro; s->val[OPT_BIT_DEPTH].s = strdup (bit_depth_list_pro[0]); if (!s->val[OPT_BIT_DEPTH].s) return SANE_STATUS_NO_MEM; /* speed */ s->opt[OPT_SPEED].name = SANE_NAME_SCAN_SPEED; s->opt[OPT_SPEED].title = SANE_TITLE_SCAN_SPEED; s->opt[OPT_SPEED].desc = SANE_DESC_SCAN_SPEED; s->opt[OPT_SPEED].type = SANE_TYPE_STRING; s->opt[OPT_SPEED].size = max_string_size (speed_list); s->opt[OPT_SPEED].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SPEED].constraint.string_list = speed_list; s->val[OPT_SPEED].s = strdup (speed_list[4]); if (!s->val[OPT_SPEED].s) return SANE_STATUS_NO_MEM; if (!(s->hw->flags & MUSTEK_FLAG_THREE_PASS)) { /* Speed only supported by 3-pass scanners */ s->opt[OPT_SPEED].cap |= SANE_CAP_INACTIVE; } /* source */ s->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_SOURCE].type = SANE_TYPE_STRING; if ((s->hw->flags & MUSTEK_FLAG_SE) || (s->hw->flags & MUSTEK_FLAG_N) || (s->hw->flags & MUSTEK_FLAG_TA)) { s->opt[OPT_SOURCE].size = max_string_size (ta_source_list); s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].constraint.string_list = ta_source_list; s->val[OPT_SOURCE].s = strdup (ta_source_list[0]); if (!s->val[OPT_SOURCE].s) return SANE_STATUS_NO_MEM; } else if (s->hw->flags & MUSTEK_FLAG_ADF) { s->opt[OPT_SOURCE].size = max_string_size (adf_source_list); s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].constraint.string_list = adf_source_list; s->val[OPT_SOURCE].s = strdup (adf_source_list[0]); if (!s->val[OPT_SOURCE].s) return SANE_STATUS_NO_MEM; } else { s->opt[OPT_SOURCE].size = max_string_size (source_list); s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].constraint.string_list = source_list; s->val[OPT_SOURCE].s = strdup (source_list[0]); s->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; if (!s->val[OPT_SOURCE].s) return SANE_STATUS_NO_MEM; } /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->val[OPT_PREVIEW].w = 0; /* fast preview */ s->opt[OPT_FAST_PREVIEW].name = "fast-preview"; s->opt[OPT_FAST_PREVIEW].title = SANE_I18N ("Fast preview"); s->opt[OPT_FAST_PREVIEW].desc = SANE_I18N ("Request that all previews are " "done in the fastest (low-quality) mode. This may be a non-color " "mode or a low resolution mode."); s->opt[OPT_FAST_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_FAST_PREVIEW].w = SANE_FALSE; /* lamp off time*/ s->opt[OPT_LAMP_OFF_TIME].name = "lamp-off-time"; s->opt[OPT_LAMP_OFF_TIME].title = SANE_I18N ("Lamp off time (minutes)"); s->opt[OPT_LAMP_OFF_TIME].desc = SANE_I18N ("Set the time (in minutes) after " "which the lamp is shut off."); s->opt[OPT_LAMP_OFF_TIME].type = SANE_TYPE_INT; if (strcmp (s->hw->sane.model, "1200 A3 PRO") != 0) s->opt[OPT_LAMP_OFF_TIME].cap |= SANE_CAP_INACTIVE; s->opt[OPT_LAMP_OFF_TIME].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_LAMP_OFF_TIME].constraint.range = &u8_range; s->val[OPT_LAMP_OFF_TIME].w = 60; /* shut lamp off */ s->opt[OPT_LAMP_OFF_BUTTON].name = "lamp-off"; s->opt[OPT_LAMP_OFF_BUTTON].title = SANE_I18N ("Turn lamp off"); s->opt[OPT_LAMP_OFF_BUTTON].desc = SANE_I18N ("Turns the lamp off immediately."); s->opt[OPT_LAMP_OFF_BUTTON].type = SANE_TYPE_BUTTON; s->opt[OPT_LAMP_OFF_BUTTON].cap = SANE_CAP_SOFT_SELECT; if (strcmp (s->hw->sane.model, "1200 A3 PRO") != 0) s->opt[OPT_LAMP_OFF_BUTTON].cap |= SANE_CAP_INACTIVE; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].size = 0; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->val[OPT_TL_X].w = s->hw->x_range.min; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->val[OPT_TL_Y].w = s->hw->y_range.min; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->val[OPT_BR_X].w = s->hw->x_range.max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; s->val[OPT_BR_Y].w = s->hw->y_range.max; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].size = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_FIXED; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_PERCENT; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &percentage_range; if (!s->hw->flags & MUSTEK_FLAG_THREE_PASS) /* 1-pass scanners don't support brightness in multibit mode */ s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->val[OPT_BRIGHTNESS].w = 0; /* brightness red */ s->opt[OPT_BRIGHTNESS_R].name = "brightness-r"; s->opt[OPT_BRIGHTNESS_R].title = SANE_I18N ("Red brightness"); s->opt[OPT_BRIGHTNESS_R].desc = SANE_I18N ("Controls the brightness of " "the red channel of the " "acquired image."); s->opt[OPT_BRIGHTNESS_R].type = SANE_TYPE_FIXED; s->opt[OPT_BRIGHTNESS_R].unit = SANE_UNIT_PERCENT; s->opt[OPT_BRIGHTNESS_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS_R].constraint.range = &percentage_range; s->opt[OPT_BRIGHTNESS_R].cap |= SANE_CAP_INACTIVE; s->val[OPT_BRIGHTNESS_R].w = 0; /* brightness green */ s->opt[OPT_BRIGHTNESS_G].name = "brightness-g"; s->opt[OPT_BRIGHTNESS_G].title = SANE_I18N ("Green brightness"); s->opt[OPT_BRIGHTNESS_G].desc = SANE_I18N ("Controls the brightness of " "the green channel of the " "acquired image."); s->opt[OPT_BRIGHTNESS_G].type = SANE_TYPE_FIXED; s->opt[OPT_BRIGHTNESS_G].unit = SANE_UNIT_PERCENT; s->opt[OPT_BRIGHTNESS_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS_G].constraint.range = &percentage_range; s->opt[OPT_BRIGHTNESS_G].cap |= SANE_CAP_INACTIVE; s->val[OPT_BRIGHTNESS_G].w = 0; /* brightness blue */ s->opt[OPT_BRIGHTNESS_B].name = "brightness-b"; s->opt[OPT_BRIGHTNESS_B].title = SANE_I18N ("Blue brightness"); s->opt[OPT_BRIGHTNESS_B].desc = SANE_I18N ("Controls the brightness of " "the blue channel of the " "acquired image."); s->opt[OPT_BRIGHTNESS_B].type = SANE_TYPE_FIXED; s->opt[OPT_BRIGHTNESS_B].unit = SANE_UNIT_PERCENT; s->opt[OPT_BRIGHTNESS_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS_B].constraint.range = &percentage_range; s->opt[OPT_BRIGHTNESS_B].cap |= SANE_CAP_INACTIVE; s->val[OPT_BRIGHTNESS_B].w = 0; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_FIXED; s->opt[OPT_CONTRAST].unit = SANE_UNIT_PERCENT; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &percentage_range; if (!(s->hw->flags & MUSTEK_FLAG_THREE_PASS)) /* 1-pass scanners don't support contrast in multibit mode */ s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; s->val[OPT_CONTRAST].w = 0; /* contrast red */ s->opt[OPT_CONTRAST_R].name = "contrast-r"; s->opt[OPT_CONTRAST_R].title = SANE_I18N ("Contrast red channel"); s->opt[OPT_CONTRAST_R].desc = SANE_I18N ("Controls the contrast of " "the red channel of the " "acquired image."); s->opt[OPT_CONTRAST_R].type = SANE_TYPE_FIXED; s->opt[OPT_CONTRAST_R].unit = SANE_UNIT_PERCENT; s->opt[OPT_CONTRAST_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST_R].constraint.range = &percentage_range; s->opt[OPT_CONTRAST_R].cap |= SANE_CAP_INACTIVE; s->val[OPT_CONTRAST_R].w = 0; /* contrast green */ s->opt[OPT_CONTRAST_G].name = "contrast-g"; s->opt[OPT_CONTRAST_G].title = SANE_I18N ("Contrast green channel"); s->opt[OPT_CONTRAST_G].desc = SANE_I18N ("Controls the contrast of " "the green channel of the " "acquired image."); s->opt[OPT_CONTRAST_G].type = SANE_TYPE_FIXED; s->opt[OPT_CONTRAST_G].unit = SANE_UNIT_PERCENT; s->opt[OPT_CONTRAST_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST_G].constraint.range = &percentage_range; s->opt[OPT_CONTRAST_G].cap |= SANE_CAP_INACTIVE; s->val[OPT_CONTRAST_G].w = 0; /* contrast blue */ s->opt[OPT_CONTRAST_B].name = "contrast-b"; s->opt[OPT_CONTRAST_B].title = SANE_I18N ("Contrast blue channel"); s->opt[OPT_CONTRAST_B].desc = SANE_I18N ("Controls the contrast of " "the blue channel of the " "acquired image."); s->opt[OPT_CONTRAST_B].type = SANE_TYPE_FIXED; s->opt[OPT_CONTRAST_B].unit = SANE_UNIT_PERCENT; s->opt[OPT_CONTRAST_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST_B].constraint.range = &percentage_range; s->opt[OPT_CONTRAST_B].cap |= SANE_CAP_INACTIVE; s->val[OPT_CONTRAST_B].w = 0; /* gamma */ gammasize = 256; for (i = 0; i < 4; ++i) for (j = 0; j < gammasize; ++j) s->gamma_table[i][j] = j; /* custom-gamma table */ s->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; s->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* grayscale gamma vector */ s->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR].size = 256 * sizeof (SANE_Word); s->val[OPT_GAMMA_VECTOR].wa = &s->gamma_table[0][0]; s->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR].constraint.range = &u8_range; /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_R].size = 256 * sizeof (SANE_Word); s->val[OPT_GAMMA_VECTOR_R].wa = &s->gamma_table[1][0]; s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &u8_range; /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_G].size = 256 * sizeof (SANE_Word); s->val[OPT_GAMMA_VECTOR_G].wa = &s->gamma_table[2][0]; s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &u8_range; /* blue gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_B].size = 256 * sizeof (SANE_Word); s->val[OPT_GAMMA_VECTOR_B].wa = &s->gamma_table[3][0]; s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &u8_range; /* quality calibration */ s->opt[OPT_QUALITY_CAL].name = SANE_NAME_QUALITY_CAL; s->opt[OPT_QUALITY_CAL].title = SANE_TITLE_QUALITY_CAL; s->opt[OPT_QUALITY_CAL].desc = SANE_DESC_QUALITY_CAL; s->opt[OPT_QUALITY_CAL].type = SANE_TYPE_BOOL; if (s->hw->flags & MUSTEK_FLAG_PRO) s->val[OPT_QUALITY_CAL].w = SANE_TRUE; else s->val[OPT_QUALITY_CAL].w = SANE_FALSE; s->opt[OPT_QUALITY_CAL].cap |= SANE_CAP_INACTIVE; if ((s->hw->flags & MUSTEK_FLAG_PRO) || (s->hw->flags & MUSTEK_FLAG_SE_PLUS)) { /* Only Pro and SE Plus models support calibration */ s->opt[OPT_QUALITY_CAL].cap &= ~SANE_CAP_INACTIVE; } /* halftone dimension */ s->opt[OPT_HALFTONE_DIMENSION].name = SANE_NAME_HALFTONE_DIMENSION; s->opt[OPT_HALFTONE_DIMENSION].title = SANE_TITLE_HALFTONE_DIMENSION; s->opt[OPT_HALFTONE_DIMENSION].desc = SANE_DESC_HALFTONE_DIMENSION; s->opt[OPT_HALFTONE_DIMENSION].type = SANE_TYPE_STRING; s->opt[OPT_HALFTONE_DIMENSION].size = max_string_size (halftone_list); s->opt[OPT_HALFTONE_DIMENSION].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_HALFTONE_DIMENSION].constraint.string_list = halftone_list; s->val[OPT_HALFTONE_DIMENSION].s = strdup (halftone_list[0]); if (!s->val[OPT_HALFTONE_DIMENSION].s) return SANE_STATUS_NO_MEM; s->opt[OPT_HALFTONE_DIMENSION].cap |= SANE_CAP_INACTIVE; /* halftone pattern */ s->opt[OPT_HALFTONE_PATTERN].name = SANE_NAME_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].title = SANE_TITLE_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].desc = SANE_DESC_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].type = SANE_TYPE_INT; s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_PATTERN].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_HALFTONE_PATTERN].constraint.range = &u8_range; s->val[OPT_HALFTONE_PATTERN].wa = s->halftone_pattern; return SANE_STATUS_GOOD; } /* The following three functions execute as a child process. The reason for using a subprocess is that some (most?) generic SCSI interfaces block a SCSI request until it has completed. With a subprocess, we can let it block waiting for the request to finish while the main process can go about to do more important things (such as recognizing when the user presses a cancel button). WARNING: Since this is executed as a subprocess, it's NOT possible to update any of the variables in the main process (in particular the scanner state cannot be updated). NOTE: At least for Linux, it seems that we could get rid of the subprocess. Linux v2.0 does seem to allow select() on SCSI descriptors. */ static void output_data (Mustek_Scanner * s, FILE * fp, SANE_Byte * data, SANE_Int lines_per_buffer, SANE_Int bpl, SANE_Byte * extra) { SANE_Byte *ptr, *ptr_end; SANE_Int y, num_lines; DBG (5, "output_data: data=%p, lpb=%d, bpl=%d, extra=%p\n", data, lines_per_buffer, bpl, extra); /* convert to pixel-interleaved format: */ if ((s->mode & MUSTEK_MODE_COLOR) && !(s->hw->flags & MUSTEK_FLAG_THREE_PASS)) { num_lines = lines_per_buffer; /* need to correct for distance between r/g/b sensors: */ if (s->hw->flags & MUSTEK_FLAG_PRO) fix_line_distance_pro (s, num_lines, bpl, data, extra); else if (s->hw->flags & MUSTEK_FLAG_SE) { num_lines = fix_line_distance_se (s, num_lines, bpl, data, extra); } else if (s->hw->flags & MUSTEK_FLAG_N) { if (s->hw->flags & MUSTEK_FLAG_LD_N2) num_lines = fix_line_distance_n_2 (s, num_lines, bpl, data, extra); else num_lines = fix_line_distance_n_1 (s, num_lines, bpl, data, extra); } else if ((s->hw->flags & MUSTEK_FLAG_LD_BLOCK) && (s->ld.max_value != 0)) { if (s->hw->flags & MUSTEK_FLAG_PARAGON_1) num_lines = fix_line_distance_block (s, num_lines, bpl, data, extra, s->hw->lines); else num_lines = fix_line_distance_block (s, num_lines, bpl, data, extra, s->hw->lines_per_block); } else if (!(s->hw->flags & MUSTEK_FLAG_LD_NONE) && (s->ld.max_value != 0)) fix_line_distance_normal (s, num_lines, bpl, data, extra); else num_lines = fix_line_distance_none (s, num_lines, bpl, data, extra); if (strcmp (s->val[OPT_SOURCE].s, "Automatic Document Feeder") == 0) { /* need to revert line direction */ SANE_Int line_number; SANE_Int byte_number; DBG (5, "output_data: ADF found, mirroring lines\n"); for (line_number = 0; line_number < num_lines; line_number++) { for (byte_number = bpl - 3; byte_number >= 0; byte_number -= 3) { fputc (*(extra + line_number * bpl + byte_number), fp); fputc (*(extra + line_number * bpl + byte_number + 1), fp); fputc (*(extra + line_number * bpl + byte_number + 2), fp); } } } else fwrite (extra, num_lines, s->params.bytes_per_line, fp); } else { DBG (5, "output_data: write %d lpb; %d bpl\n", lines_per_buffer, bpl); /* Scale x-resolution above 1/2 of the maximum resolution for SE and Pro scanners */ if ((s->hw->flags & MUSTEK_FLAG_ENLARGE_X) && (s->val[OPT_RESOLUTION].w > (s->hw->dpi_range.max / 2))) { SANE_Int x; SANE_Int half_res = SANE_UNFIX (s->hw->dpi_range.max) / 2; SANE_Int res = SANE_UNFIX (s->val[OPT_RESOLUTION].w); SANE_Int res_counter; SANE_Int enlarged_x; DBG (5, "output_data: enlarge lines from %d bpl to %d bpl\n", s->hw->bpl, s->params.bytes_per_line); for (y = 0; y < lines_per_buffer; y++) { SANE_Byte byte = 0; x = 0; res_counter = 0; enlarged_x = 0; while (enlarged_x < s->params.pixels_per_line) { if (s->mode & MUSTEK_MODE_GRAY) { fputc (*(data + y * bpl + x), fp); res_counter += half_res; if (res_counter >= half_res) { res_counter -= res; x++; } enlarged_x++; } else /* lineart */ { /* need to invert image because of funny SANE 1-bit image polarity */ if (*(data + x / 8 + y * bpl) & (1 << (7 - (x % 8)))) byte |= 1 << (7 - (enlarged_x % 8)); if ((enlarged_x % 8) == 7) { fputc (~byte, fp); /* invert image */ byte = 0; } res_counter += half_res; if (res_counter >= half_res) { res_counter -= res; x++; } enlarged_x++; } } } } else /* lineart, gray or halftone (nothing to scale) */ { if ((s->mode & MUSTEK_MODE_LINEART) || (s->mode & MUSTEK_MODE_HALFTONE)) { /* need to invert image because of funny SANE 1-bit image polarity */ ptr = data; ptr_end = ptr + lines_per_buffer * bpl; if (strcmp (s->val[OPT_SOURCE].s, "Automatic Document Feeder") == 0) { while (ptr != ptr_end) { (*ptr) = ~(*ptr); ptr++; /* need to revert bit direction */ *ptr = ((*ptr & 0x80) >> 7) + ((*ptr & 0x40) >> 5) + ((*ptr & 0x20) >> 3) + ((*ptr & 0x10) >> 1) + ((*ptr & 0x08) << 1) + ((*ptr & 0x04) << 3) + ((*ptr & 0x02) << 5) + ((*ptr & 0x01) << 7); } } else while (ptr != ptr_end) { (*ptr) = ~(*ptr); ptr++; } } if (strcmp (s->val[OPT_SOURCE].s, "Automatic Document Feeder") == 0) { /* need to revert line direction */ SANE_Int line_number; SANE_Int byte_number; DBG (5, "output_data: ADF found, mirroring lines\n"); for (line_number = 0; line_number < lines_per_buffer; line_number++) { for (byte_number = bpl - 1; byte_number >= 0; byte_number--) { fputc (*(data + line_number * bpl + byte_number), fp); } } } else { fwrite (data, lines_per_buffer, bpl, fp); } } } DBG (5, "output_data: end\n"); } static void sigterm_handler (int signal) { DBG (4, "sigterm_handler: started, signal is %d, starting sanei_scsi_req_flush_all()\n", signal); sanei_scsi_req_flush_all (); /* flush SCSI queue */ DBG (4, "sigterm_handler: sanei_scsi_req_flush_all() finisheshed, _exiting()\n"); _exit (SANE_STATUS_GOOD); } static SANE_Int reader_process (void *data) { Mustek_Scanner *s = (Mustek_Scanner *) data; SANE_Int lines_per_buffer, bpl; SANE_Byte *extra = 0, *ptr; sigset_t sigterm_set; struct SIGACTION act; SANE_Status status; FILE *fp; int fd = s->reader_fds; SANE_Int buffernumber = 0; SANE_Int buffer_count, max_buffers; struct { void *id; /* scsi queue id */ SANE_Byte *data; /* data buffer */ SANE_Byte *command; /* command buffer */ SANE_Int lines; /* # lines in buffer */ size_t num_read; /* # of bytes read (return value) */ SANE_Int bank; /* needed by SE models */ SANE_Bool ready; /* ready to send to application? */ SANE_Bool finished; /* block is finished */ } bstat[2]; DBG (3, "reader_process: started\n"); if (sanei_thread_is_forked ()) { DBG (4, "reader_process: using fork ()\n"); close (s->pipe); s->pipe = -1; } else { DBG (4, "reader_process: using threads\n"); } if (sanei_thread_is_forked ()) { /* ignore SIGTERM while writing SCSI commands */ sigemptyset (&sigterm_set); sigaddset (&sigterm_set, SIGTERM); /* call our sigterm handler to clean up ongoing SCSI requests */ memset (&act, 0, sizeof (act)); act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, 0); } if (disable_double_buffering) DBG (3, "reader_process: disable_double_buffering is set, this may be " "slow\n"); fp = fdopen (fd, "w"); if (!fp) return SANE_STATUS_IO_ERROR; s->total_lines = 0; bpl = s->hw->bpl; /* buffer size is scanner dependant */ lines_per_buffer = s->hw->buffer_size / bpl / 2; if (strip_height > 0.0) { SANE_Int max_lines; double dpi; dpi = SANE_UNFIX (s->val[OPT_RESOLUTION].w); max_lines = (int) (strip_height * dpi + 0.5); if (lines_per_buffer > max_lines) { DBG (2, "reader_process: limiting strip height to %g inches " "(%d lines)\n", strip_height, max_lines); lines_per_buffer = max_lines; } } if (!lines_per_buffer) { DBG (1, "reader_process: bpl (%d) > SCSI buffer size / 2 (%d)\n", bpl, s->hw->buffer_size / 2); return SANE_STATUS_NO_MEM; /* resolution is too high */ } DBG (4, "reader_process: %d lines per buffer, %d bytes per line, " "%d bytes per buffer\n", lines_per_buffer, bpl, lines_per_buffer * bpl); bstat[0].data = malloc (2 * lines_per_buffer * (long) bpl); if (!bstat[0].data) { DBG (1, "reader_process: failed to malloc %ld bytes for data buffer\n", lines_per_buffer * (long) bpl); return SANE_STATUS_NO_MEM; } bstat[1].data = bstat[0].data + lines_per_buffer * (long) bpl; bstat[0].command = malloc (2 * 10); if (!bstat[0].command) { DBG (1, "reader_process: failed to malloc %d bytes for command buffer\n", 2 * 10); return SANE_STATUS_NO_MEM; } bstat[1].command = bstat[0].command + 10; /* Touch all pages of the buffer to fool the memory management. */ ptr = bstat[0].data + 2 * lines_per_buffer * (long) bpl - 1; while (ptr >= bstat[0].data) { *ptr = 0x00; ptr -= 256; } if (!(s->hw->flags & MUSTEK_FLAG_THREE_PASS)) { /* get temporary buffer for line-distance correction and/or bit expansion. For some scanners more space is needed because the data must be read in as single big block (cut up into pieces of lines_per_buffer). This requires that the line distance correction continues on every call exactly where it stopped if the image shall be reconstructed without any stripes. */ extra = malloc ((lines_per_buffer + MAX_LINE_DIST) * (long) s->params.bytes_per_line); if (!extra) { DBG (1, "reader_process: failed to malloc extra buffer\n"); return SANE_STATUS_NO_MEM; } } if (s->hw->flags & MUSTEK_FLAG_N) { /* reacquire port access rights (lost because of fork()): */ sanei_ab306_get_io_privilege (s->fd); } if ((s->hw->flags & MUSTEK_FLAG_N) || (s->hw->flags & MUSTEK_FLAG_LD_BLOCK)) { /* reset counter of line number for line-dictance correction */ s->ld.ld_line = 0; } max_buffers = s->hw->max_block_buffer_size / (lines_per_buffer * bpl); if (max_buffers < 1) { DBG (1, "reader_process: buffersize > blocksize!\n"); return SANE_STATUS_NO_MEM; } DBG (4, "reader_process: limiting block read to %d buffers (%d lines)\n", max_buffers, MIN (s->hw->lines, (max_buffers * lines_per_buffer))); while (s->line < s->hw->lines) { s->hw->lines_per_block = MIN (s->hw->lines - s->line, (max_buffers * lines_per_buffer)); status = dev_block_read_start (s, s->hw->lines_per_block); if (status != SANE_STATUS_GOOD) return status; for (buffernumber = 0; buffernumber < 2; buffernumber++) { bstat[buffernumber].ready = SANE_FALSE; bstat[buffernumber].finished = SANE_FALSE; } buffer_count = 0; buffernumber = 0; while (1) { /* omit reading first two buffers (not yet ready) */ if (bstat[buffernumber].ready == SANE_TRUE) { DBG (4, "reader_process: buffer %d: waiting for request to be " "ready\n", buffernumber + 1); status = dev_req_wait (bstat[buffernumber].id); if (status == SANE_STATUS_GOOD) { DBG (4, "reader_process: buffer %d is ready, wanted %d, " "got %ld bytes\n", buffernumber + 1, bstat[buffernumber].lines * bpl, (long int) bstat[buffernumber].num_read); } else { DBG (1, "reader_process: failed to read data, status: %s, " "buffer: %d\n", sane_strstatus (status), buffernumber + 1); if (status == SANE_STATUS_NO_MEM) { DBG (1, "Probably the size of the kernel SCSI buffer is " "too small for the\n selected buffersize " "in mustek.conf. Either decrease " "buffersize in\n mustek.conf to e.g. 32, " "increase SG_BIG_BUF in kernel to 130560, " "or\n use SANE_SG_BUFFERSIZE variable. " "See man sane-scsi and README for\n " "details.\n"); } return status; } DBG (4, "reader_process: buffer %d: sending %ld bytes to " "output_data\n", buffernumber + 1, (long int) bstat[buffernumber].num_read); output_data (s, fp, bstat[buffernumber].data, bstat[buffernumber].lines, bpl, extra); if (bstat[buffernumber].finished) break; /* everything written; exit loop */ } if (disable_double_buffering) { /* Enter only one buffer at once */ if (buffernumber == 1) buffernumber = 0; else buffernumber = 1; } /* enter read requests only if data left */ if ((s->line < s->hw->lines) && (buffer_count < max_buffers)) { if (s->line + lines_per_buffer >= s->hw->lines) { /* do the last few lines: */ bstat[buffernumber].lines = s->hw->lines - s->line; bstat[buffernumber].bank = 0x01; bstat[buffernumber].finished = SANE_TRUE; } else { bstat[buffernumber].lines = lines_per_buffer; bstat[buffernumber].bank = 0x00; } if ((buffer_count + 1) >= max_buffers) bstat[buffernumber].finished = SANE_TRUE; s->line += bstat[buffernumber].lines; bstat[buffernumber].ready = SANE_TRUE; buffer_count++; DBG (4, "reader_process: buffer %d: entering read request for %d " "bytes (buffer %d)\n", buffernumber + 1, bstat[buffernumber].lines * bpl, buffer_count); sigprocmask (SIG_BLOCK, &sigterm_set, 0); status = dev_read_req_enter (s, bstat[buffernumber].data, bstat[buffernumber].lines, bpl, &bstat[buffernumber].num_read, &bstat[buffernumber].id, bstat[buffernumber].bank, bstat[buffernumber].command); sigprocmask (SIG_UNBLOCK, &sigterm_set, 0); if (status == SANE_STATUS_GOOD) { DBG (5, "reader_process: buffer %d: entered (line %d of %d," " buffer %d)\n", buffernumber + 1, s->line, s->hw->lines, buffer_count); } else { DBG (1, "reader_process: buffer %d: failed to enter read " "request, status: %s\n", buffernumber + 1, sane_strstatus (status)); return status; } } if (!disable_double_buffering) { if (buffernumber == 1) buffernumber = 0; else buffernumber = 1; } /* This is said to fix the scanner hangs that reportedly show on some MFS-12000SP scanners. */ if (s->mode == 0 && (s->hw->flags & MUSTEK_FLAG_LINEART_FIX)) usleep (200000); } } fclose (fp); free (bstat[0].data); if (s->ld.buf[0]) free (s->ld.buf[0]); s->ld.buf[0] = NULL; if (extra) free (extra); close (fd); return SANE_STATUS_GOOD; } static SANE_Status attach_one_device (SANE_String_Const devname) { Mustek_Device *dev; attach (devname, &dev, SANE_FALSE); if (dev) { /* Keep track of newly attached devices so we can set options as necessary. */ if (new_dev_len >= new_dev_alloced) { new_dev_alloced += 4; if (new_dev) new_dev = realloc (new_dev, new_dev_alloced * sizeof (new_dev[0])); else new_dev = malloc (new_dev_alloced * sizeof (new_dev[0])); if (!new_dev) { DBG (1, "attach_one_device: out of memory\n"); return SANE_STATUS_NO_MEM; } } new_dev[new_dev_len++] = dev; } return SANE_STATUS_GOOD; } /**************************************************************************/ /* SANE API calls */ /**************************************************************************/ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { SANE_Char line[PATH_MAX], *word, *end; SANE_String_Const cp; SANE_Int linenumber; FILE *fp; DBG_INIT (); sanei_thread_init (); #ifdef DBG_LEVEL debug_level = DBG_LEVEL; #else debug_level = 0; #endif DBG (2, "SANE mustek backend version %d.%d build %d from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (5, "sane_init: authorize %s null\n", authorize ? "!=" : "=="); #ifdef HAVE_SANEI_SCSI_OPEN_EXTENDED DBG (5, "sane_init: using sanei_scsi_open_extended\n"); #else DBG (5, "sane_init: using sanei_scsi_open with buffer size = %d bytes\n", sanei_scsi_max_request_size); #endif num_devices = 0; force_wait = SANE_FALSE; disable_double_buffering = SANE_FALSE; first_dev = 0; first_handle = 0; devlist = 0; new_dev = 0; new_dev_len = 0; new_dev_alloced = 0; fp = sanei_config_open (MUSTEK_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ DBG (3, "sane_init: couldn't find config file (%s), trying " "/dev/scanner directly\n", MUSTEK_CONFIG_FILE); attach ("/dev/scanner", 0, SANE_FALSE); return SANE_STATUS_GOOD; } linenumber = 0; DBG (4, "sane_init: reading config file `%s'\n", MUSTEK_CONFIG_FILE); while (sanei_config_read (line, sizeof (line), fp)) { word = 0; linenumber++; cp = sanei_config_get_string (line, &word); if (!word || cp == line) { DBG (5, "sane_init: config file line %d: ignoring empty line\n", linenumber); if (word) free (word); continue; } if (word[0] == '#') { DBG (5, "sane_init: config file line %d: ignoring comment line\n", linenumber); free (word); continue; } if (strcmp (word, "option") == 0) { free (word); word = 0; cp = sanei_config_get_string (cp, &word); if (!word) { DBG (1, "sane_init: config file line %d: missing quotation mark?\n", linenumber); continue; } if (strcmp (word, "strip-height") == 0) { free (word); word = 0; cp = sanei_config_get_string (cp, &word); if (!word) { DBG (1, "sane_init: config file line %d: missing quotation mark?\n", linenumber); continue; } errno = 0; strip_height = strtod (word, &end); if (end == word) { DBG (3, "sane-init: config file line %d: strip-height " "must have a parameter; using 1 inch\n", linenumber); strip_height = 1.0; } if (errno) { DBG (3, "sane-init: config file line %d: strip-height `%s' " "is invalid (%s); using 1 inch\n", linenumber, word, strerror (errno)); strip_height = 1.0; } else { if (strip_height < 0.1) strip_height = 0.1; DBG (3, "sane_init: config file line %d: strip-height set " "to %g inches\n", linenumber, strip_height); } if (word) free (word); word = 0; } else if (strcmp (word, "force-wait") == 0) { DBG (3, "sane_init: config file line %d: enabling force-wait\n", linenumber); force_wait = SANE_TRUE; if (word) free (word); word = 0; } else if (strcmp (word, "disable-double-buffering") == 0) { DBG (3, "sane_init: config file line %d: disabling " "double-buffering\n", linenumber); disable_double_buffering = SANE_TRUE; if (word) free (word); word = 0; } else if (strcmp (word, "legal-size") == 0) { if (new_dev_len > 0) { /* Check for 12000 LS, no way to find out automatically */ if (strcmp (new_dev[new_dev_len - 1]->sane.model, "ScanExpress 12000SP") == 0) { new_dev[new_dev_len - 1]->x_range.max = SANE_FIX (220.0); new_dev[new_dev_len - 1]->y_range.max = SANE_FIX (360.0); new_dev[new_dev_len - 1]->sane.model = "Paragon 1200 LS"; DBG (3, "sane_init: config file line %d: enabling " "legal-size for %s\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "legal-size ignored, device %s is not a " "Paragon 1200 LS\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } } else { DBG (3, "sane_init: config file line %d: option " "legal-size ignored, was set before any device " "name\n", linenumber); } if (word) free (word); word = 0; } else if (strcmp (word, "linedistance-fix") == 0) { if (new_dev_len > 0) { new_dev[new_dev_len - 1]->flags |= MUSTEK_FLAG_LD_FIX; DBG (3, "sane_init: config file line %d: enabling " "linedistance-fix for %s\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "linedistance-fix ignored, was set before any device " "name\n", linenumber); } if (word) free (word); word = 0; } else if (strcmp (word, "disable-backtracking") == 0) { if (new_dev_len > 0) { new_dev[new_dev_len - 1]->flags |= MUSTEK_FLAG_NO_BACKTRACK; DBG (3, "sane_init: config file line %d: disabling " "backtracking for %s\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "disable-backtracking ignored, was set before any " "device name\n", linenumber); } if (word) free (word); word = 0; } else if (strcmp (word, "lineart-fix") == 0) { if (new_dev_len > 0) { new_dev[new_dev_len - 1]->flags |= MUSTEK_FLAG_LINEART_FIX; DBG (3, "sane_init: config file line %d: enabling " "lineart-fix for %s\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "lineart-fix ignored, was set before any device name\n", linenumber); } if (word) free (word); word = 0; } else if (strcmp (word, "buffersize") == 0) { long buffer_size; free (word); word = 0; cp = sanei_config_get_string (cp, &word); if (!word) { DBG (1, "sane_init: config file line %d: missing quotation mark?\n", linenumber); continue; } errno = 0; buffer_size = strtol (word, &end, 0); if (end == word) { DBG (3, "sane-init: config file line %d: buffersize must " "have a parameter; using default (%d kb)\n", linenumber, new_dev[new_dev_len - 1]->max_buffer_size); } if (errno) { DBG (3, "sane-init: config file line %d: buffersize `%s' " "is invalid (%s); using default (%d kb)\n", linenumber, word, strerror (errno), new_dev[new_dev_len - 1]->max_buffer_size); } else { if (new_dev_len > 0) { if (buffer_size < 32.0) buffer_size = 32.0; new_dev[new_dev_len - 1]->max_buffer_size = buffer_size * 1024; DBG (3, "sane_init: config file line %d: buffersize set " "to %ld kb for %s\n", linenumber, buffer_size, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "buffersize ignored, was set before any device " "name\n", linenumber); } } if (word) free (word); word = 0; } else if (strcmp (word, "blocksize") == 0) { long block_size; free (word); word = 0; cp = sanei_config_get_string (cp, &word); if (!word) { DBG (1, "sane_init: config file line %d: missing quotation mark?\n", linenumber); continue; } errno = 0; block_size = strtol (word, &end, 0); if (end == word) { DBG (3, "sane-init: config file line %d:: blocksize must " "have a parameter; using default (1 GB)\n", linenumber); } if (errno) { DBG (3, "sane-init: config file line %d: blocksize `%s' " "is invalid (%s); using default (1 GB)\n", linenumber, word, strerror (errno)); } else { if (new_dev_len > 0) { if (block_size < 256.0) block_size = 256.0; new_dev[new_dev_len - 1]->max_block_buffer_size = block_size * 1024; DBG (3, "sane_init: config file line %d: blocksize set " "to %ld kb for %s\n", linenumber, block_size, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "blocksize ignored, was set before any device " "name\n", linenumber); } } if (word) free (word); word = 0; } else { DBG (3, "sane_init: config file line %d: ignoring unknown " "option `%s'\n", linenumber, word); if (word) free (word); word = 0; } } else { new_dev_len = 0; DBG (4, "sane_init: config file line %d: trying to attach `%s'\n", linenumber, line); sanei_config_attach_matching_devices (line, attach_one_device); if (word) free (word); word = 0; } } if (new_dev_alloced > 0) { new_dev_len = new_dev_alloced = 0; free (new_dev); } fclose (fp); DBG (5, "sane_init: end\n"); return SANE_STATUS_GOOD; } void sane_exit (void) { Mustek_Device *dev, *next; DBG (4, "sane_exit\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free (dev->name); free (dev); } if (devlist) free (devlist); devlist = 0; first_dev = 0; sanei_ab306_exit (); /* may have to do some cleanup */ mustek_scsi_pp_exit (); DBG (5, "sane_exit: finished\n"); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Mustek_Device *dev; SANE_Int i; DBG (4, "sane_get_devices: %d devices %s\n", num_devices, local_only ? "(local only)" : ""); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (5, "sane_get_devices: end\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Mustek_Device *dev; SANE_Status status; Mustek_Scanner *s; if (!devicename) { DBG (1, "sane_open: devicename is null!\n"); return SANE_STATUS_INVAL; } if (!handle) { DBG (1, "sane_open: handle is null!\n"); return SANE_STATUS_INVAL; } DBG (4, "sane_open: devicename=%s\n", devicename); if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; if (!dev) { status = attach (devicename, &dev, SANE_TRUE); if (status != SANE_STATUS_GOOD) return status; } } else /* empty devicname -> use first device */ dev = first_dev; if (!dev) return SANE_STATUS_INVAL; s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->fd = -1; s->pipe = -1; s->hw = dev; s->ld.ld_line = 0; s->halftone_pattern = malloc (8 * 8 * sizeof (SANE_Int)); if (!s->halftone_pattern) return SANE_STATUS_NO_MEM; init_options (s); /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; DBG (4, "sane_open: finished (handle=%p)\n", (void *) s); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Mustek_Scanner *prev, *s; DBG (4, "sane_close: handle=%p\n", handle); /* 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) { DBG (1, "sane_close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (s->scanning) do_stop (handle); if (s->ld.buf[0]) free (s->ld.buf[0]); if (s->val[OPT_MODE].s) free (s->val[OPT_MODE].s); if (s->val[OPT_BIT_DEPTH].s) free (s->val[OPT_BIT_DEPTH].s); if (s->val[OPT_SPEED].s) free (s->val[OPT_SPEED].s); if (s->val[OPT_SOURCE].s) free (s->val[OPT_SOURCE].s); if (s->val[OPT_HALFTONE_DIMENSION].s) free (s->val[OPT_HALFTONE_DIMENSION].s); if (s->halftone_pattern) free (s->halftone_pattern); if (prev) prev->next = s->next; else first_handle = s->next; free (handle); handle = 0; DBG (5, "sane_close: finished\n"); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Mustek_Scanner *s = handle; if (((unsigned) option >= NUM_OPTIONS) || (option < 0)) { DBG (4, "sane_get_option_descriptor: option %d >= NUM_OPTIONS or < 0\n", option); return 0; } if (!s) { DBG (1, "sane_get_option_descriptor: handle is null!\n"); return 0; } if (s->opt[option].name && s->opt[option].name[0] != 0) DBG (5, "sane_get_option_descriptor for option %s (%sactive%s)\n", s->opt[option].name, s->opt[option].cap & SANE_CAP_INACTIVE ? "in" : "", s->opt[option].cap & SANE_CAP_ADVANCED ? ", advanced" : ""); else DBG (5, "sane_get_option_descriptor for option \"%s\" (%sactive%s)\n", s->opt[option].title, s->opt[option].cap & SANE_CAP_INACTIVE ? "in" : "", s->opt[option].cap & SANE_CAP_ADVANCED ? ", advanced" : ""); return s->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Mustek_Scanner *s = handle; SANE_Status status; SANE_Word w, cap; if (((unsigned) option >= NUM_OPTIONS) || (option < 0)) { DBG (4, "sane_control_option: option %d < 0 or >= NUM_OPTIONS\n", option); return SANE_STATUS_INVAL; } if (!s) { DBG (1, "sane_control_option: handle is null!\n"); return SANE_STATUS_INVAL; } if (s->opt[option].type != SANE_TYPE_BUTTON && !val) { DBG (1, "sane_control_option: val is null!\n"); return SANE_STATUS_INVAL; } if (s->opt[option].name && s->opt[option].name[0] != 0) DBG (5, "sane_control_option (%s option %s)\n", action == SANE_ACTION_GET_VALUE ? "get" : (action == SANE_ACTION_SET_VALUE ? "set" : "unknown action with"), s->opt[option].name); else DBG (5, "sane_control_option (%s option \"%s\")\n", action == SANE_ACTION_GET_VALUE ? "get" : (action == SANE_ACTION_SET_VALUE ? "set" : "unknown action with"), s->opt[option].title); if (info) *info = 0; if (s->scanning) { DBG (4, "sane_control_option: don't use while scanning (option %s)\n", s->opt[option].name); return SANE_STATUS_DEVICE_BUSY; } cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { DBG (4, "sane_control_option: option %s is inactive\n", s->opt[option].name); return SANE_STATUS_INVAL; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_PREVIEW: case OPT_FAST_PREVIEW: case OPT_RESOLUTION: case OPT_FAST_GRAY_MODE: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_BRIGHTNESS: case OPT_BRIGHTNESS_R: case OPT_BRIGHTNESS_G: case OPT_BRIGHTNESS_B: case OPT_CONTRAST: case OPT_CONTRAST_R: case OPT_CONTRAST_G: case OPT_CONTRAST_B: case OPT_CUSTOM_GAMMA: case OPT_QUALITY_CAL: case OPT_LAMP_OFF_TIME: *(SANE_Word *) val = s->val[option].w; return SANE_STATUS_GOOD; /* word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: case OPT_HALFTONE_PATTERN: memcpy (val, s->val[option].wa, s->opt[option].size); return SANE_STATUS_GOOD; /* string options: */ case OPT_SPEED: case OPT_SOURCE: case OPT_MODE: case OPT_BIT_DEPTH: case OPT_HALFTONE_DIMENSION: strcpy (val, s->val[option].s); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (4, "sane_control_option: option %s is not setable\n", s->opt[option].name); return SANE_STATUS_INVAL; } status = constrain_value (s, option, val, info); if (status != SANE_STATUS_GOOD) { DBG (4, "sane_control_option: constrain_value error (option %s)\n", s->opt[option].name); return status; } switch (option) { case OPT_LAMP_OFF_BUTTON: { SANE_Int old_time = lamp_off_time; SANE_Status status; status = dev_open (s->hw->sane.name, s, sense_handler); if (status != SANE_STATUS_GOOD) return status; lamp_off_time = 0; set_window_pro (s); lamp_off_time = old_time; dev_close (s); return SANE_STATUS_GOOD; } /* (mostly) side-effect-free word options: */ case OPT_RESOLUTION: case OPT_TL_X: case OPT_BR_X: case OPT_TL_Y: case OPT_BR_Y: if (info) *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_PREVIEW: case OPT_FAST_PREVIEW: case OPT_FAST_GRAY_MODE: case OPT_BRIGHTNESS: case OPT_BRIGHTNESS_R: case OPT_BRIGHTNESS_G: case OPT_BRIGHTNESS_B: case OPT_CONTRAST: case OPT_CONTRAST_R: case OPT_CONTRAST_G: case OPT_CONTRAST_B: case OPT_QUALITY_CAL: case OPT_LAMP_OFF_TIME: s->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* side-effect-free word-array options: */ case OPT_HALFTONE_PATTERN: case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (s->val[option].wa, val, s->opt[option].size); return SANE_STATUS_GOOD; /* side-effect-free single-string options: */ case OPT_SPEED: if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); if (!s->val[option].s) return SANE_STATUS_NO_MEM; return SANE_STATUS_GOOD; /* side-effect-free string list options: */ case OPT_BIT_DEPTH: { SANE_Char *old_val = s->val[option].s; if (old_val) { if (strcmp (old_val, val) == 0) return SANE_STATUS_GOOD; /* no change */ free (old_val); } s->val[option].s = strdup (val); if (!s->val[option].s) return SANE_STATUS_NO_MEM; return SANE_STATUS_GOOD; } /* options with side-effects: */ case OPT_CUSTOM_GAMMA: w = *(SANE_Word *) val; if (w == s->val[OPT_CUSTOM_GAMMA].w) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; s->val[OPT_CUSTOM_GAMMA].w = w; if (w) { SANE_String_Const mode = s->val[OPT_MODE].s; if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } else if ((strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) && (s->hw->flags & MUSTEK_FLAG_PRO)) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; } } else { s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; case OPT_MODE: { SANE_Char *old_val = s->val[option].s; SANE_Int halftoning, binary; if (old_val) { if (strcmp (old_val, val) == 0) return SANE_STATUS_GOOD; /* no change */ free (old_val); } if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; s->val[option].s = strdup (val); if (!s->val[option].s) return SANE_STATUS_NO_MEM; s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_DIMENSION].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; halftoning = strcmp (val, SANE_VALUE_SCAN_MODE_HALFTONE) == 0; binary = (halftoning || strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) == 0); if (binary) { /* enable brightness/contrast for when in a binary mode */ s->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; /* The SE and paragon models support only threshold in lineart */ if (!(s->hw->flags & MUSTEK_FLAG_SE) && !(s->hw->flags & MUSTEK_FLAG_PRO)) s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; if (halftoning) { s->opt[OPT_HALFTONE_DIMENSION].cap &= ~SANE_CAP_INACTIVE; encode_halftone (s); if (s->custom_halftone_pattern) { s->opt[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; } else { s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; } } } else { s->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; } if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) { s->opt[OPT_BRIGHTNESS_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_BRIGHTNESS_B].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST_B].cap &= ~SANE_CAP_INACTIVE; } else { s->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; } } else if (s->hw->flags & MUSTEK_FLAG_PRO) { if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY) == 0) s->opt[OPT_FAST_GRAY_MODE].cap &= ~SANE_CAP_INACTIVE; else s->opt[OPT_FAST_GRAY_MODE].cap |= SANE_CAP_INACTIVE; if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) s->opt[OPT_BIT_DEPTH].cap &= ~SANE_CAP_INACTIVE; else s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; } else if (s->hw->flags & MUSTEK_FLAG_SE_PLUS) { if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) s->opt[OPT_BIT_DEPTH].cap &= ~SANE_CAP_INACTIVE; else s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; } if (s->val[OPT_CUSTOM_GAMMA].w) { if (strcmp (val, SANE_VALUE_SCAN_MODE_GRAY) == 0) s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) == 0) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } return SANE_STATUS_GOOD; } case OPT_HALFTONE_DIMENSION: /* halftone pattern dimension affects halftone pattern option: */ { if (strcmp (s->val[option].s, (SANE_String) val) == 0) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; s->val[option].s = strdup (val); if (!s->val[option].s) return SANE_STATUS_NO_MEM; encode_halftone (s); s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; if (s->custom_halftone_pattern) { s->opt[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; /* BUG: The SANE standard does nor allow to change the option size at run time */ s->opt[OPT_HALFTONE_PATTERN].size = (s->halftone_pattern_type & 0x0f) * sizeof (SANE_Word); } return SANE_STATUS_GOOD; } case OPT_SOURCE: if (info) *info |= SANE_INFO_RELOAD_OPTIONS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); if (!s->val[option].s) return SANE_STATUS_NO_MEM; if (strcmp (val, "Transparency Adapter") == 0) { s->opt[OPT_TL_X].constraint.range = &s->hw->x_trans_range; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_trans_range; s->opt[OPT_BR_X].constraint.range = &s->hw->x_trans_range; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_trans_range; } else { s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; } return SANE_STATUS_GOOD; } } DBG (4, "sane_control_option: unknown action for option %s\n", s->opt[option].name); return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Mustek_Scanner *s = handle; SANE_String_Const mode; if (!s) { DBG (1, "sane_get_parameters: handle is null!\n"); return SANE_STATUS_INVAL; } if (!s->scanning) { double width, height, dpi; memset (&s->params, 0, sizeof (s->params)); width = SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w); height = SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w); dpi = SANE_UNFIX (s->val[OPT_RESOLUTION].w); /* make best-effort guess at what parameters will look like once scanning starts. */ if (dpi > 0.0 && width > 0.0 && height > 0.0) { double dots_per_mm = dpi / MM_PER_INCH; s->params.pixels_per_line = width * dots_per_mm; s->params.lines = height * dots_per_mm; } encode_halftone (s); mode = s->val[OPT_MODE].s; if (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0 || strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = (s->params.pixels_per_line + 7) / 8; s->params.depth = 1; } else if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; } else { /* it's one of the color modes... */ if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { s->params.format = SANE_FRAME_RED + s->pass; s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; } else /* 1-pass */ { if (strcmp (s->val[OPT_BIT_DEPTH].s, "12") == 0) { s->params.bytes_per_line = 6 * s->params.pixels_per_line; s->params.depth = 16; } else { s->params.bytes_per_line = 3 * s->params.pixels_per_line; s->params.depth = 8; } s->params.format = SANE_FRAME_RGB; } } } else if ((s->mode & MUSTEK_MODE_COLOR) && (s->hw->flags & MUSTEK_FLAG_THREE_PASS)) s->params.format = SANE_FRAME_RED + s->pass; s->params.last_frame = (s->params.format != SANE_FRAME_RED && s->params.format != SANE_FRAME_GREEN); if (params) *params = s->params; DBG (4, "sane_get_parameters: frame = %d; last_frame = %s; depth = %d\n", s->params.format, s->params.last_frame ? "true" : "false", s->params.depth); DBG (4, "sane_get_parameters: lines = %d; ppl = %d; bpl = %d\n", s->params.lines, s->params.pixels_per_line, s->params.bytes_per_line); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Mustek_Scanner *s = handle; SANE_Status status; int fds[2]; struct SIGACTION act; if (!s) { DBG (1, "sane_start: handle is null!\n"); return SANE_STATUS_INVAL; } DBG (4, "sane_start\n"); /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; /* Check for inconsistencies */ if (s->val[OPT_TL_X].w > s->val[OPT_BR_X].w) { DBG (0, "sane_start: %s (%.1f mm) is bigger than %s (%.1f mm) " "-- aborting\n", s->opt[OPT_TL_X].title, SANE_UNFIX (s->val[OPT_TL_X].w), s->opt[OPT_BR_X].title, SANE_UNFIX (s->val[OPT_BR_X].w)); return SANE_STATUS_INVAL; } if (s->val[OPT_TL_Y].w > s->val[OPT_BR_Y].w) { DBG (0, "sane_start: %s (%.1f mm) is bigger than %s (%.1f mm) " "-- aborting\n", s->opt[OPT_TL_Y].title, SANE_UNFIX (s->val[OPT_TL_Y].w), s->opt[OPT_BR_Y].title, SANE_UNFIX (s->val[OPT_BR_Y].w)); return SANE_STATUS_INVAL; } s->total_bytes = 0; if (s->fd < 0) { /* this is the first (and maybe only) pass... */ SANE_String_Const mode; struct timeval start; /* 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; if (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) s->mode = MUSTEK_MODE_LINEART; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) s->mode = MUSTEK_MODE_HALFTONE; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) s->mode = MUSTEK_MODE_GRAY; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) s->mode = MUSTEK_MODE_COLOR; /* scanner dependant specials */ s->one_pass_color_scan = SANE_FALSE; if ((s->mode & MUSTEK_MODE_COLOR) && !(s->hw->flags & MUSTEK_FLAG_THREE_PASS)) { s->one_pass_color_scan = SANE_TRUE; } s->resolution_code = encode_resolution (s); if (s->val[OPT_PREVIEW].w && s->val[OPT_FAST_PREVIEW].w) { if (s->hw->flags & MUSTEK_FLAG_THREE_PASS) { if (s->mode & MUSTEK_MODE_COLOR) { /* Force gray-scale mode when previewing. */ s->mode = MUSTEK_MODE_GRAY; s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->params.last_frame = SANE_TRUE; } } else if (s->hw->flags & MUSTEK_FLAG_SE) { /* use 36 dpi color in any case */ s->mode = MUSTEK_MODE_COLOR; s->params.format = SANE_FRAME_RGB; s->params.depth = 8; s->one_pass_color_scan = SANE_TRUE; s->resolution_code = 36; } else if (s->hw->flags & MUSTEK_FLAG_PARAGON_1) { /* use 36 dpi */ s->resolution_code = 36; } else if (s->hw->flags & MUSTEK_FLAG_PRO) { /* use 30 dpi color mode */ s->mode = MUSTEK_MODE_COLOR; s->params.format = SANE_FRAME_RGB; s->params.depth = 8; s->one_pass_color_scan = SANE_TRUE; s->resolution_code = 30; } DBG (4, "sane_start: use fast preview (res=%d dpi)\n", s->resolution_code); } status = dev_open (s->hw->sane.name, s, sense_handler); if (status != SANE_STATUS_GOOD) return status; } status = dev_wait_ready (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: wait_ready() failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } if (!(s->hw->flags & MUSTEK_FLAG_SCSI_PP)) { /* SCSI-over-parallel port doesn't seem to like being inquired here */ status = inquiry (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: inquiry command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } } if ((strcmp (s->val[OPT_SOURCE].s, "Automatic Document Feeder") == 0) && !(s->hw->flags & MUSTEK_FLAG_ADF_READY)) { DBG (2, "sane_start: automatic document feeder is out of documents\n"); status = SANE_STATUS_NO_DOCS; goto stop_scanner_and_return; } if (s->hw->flags & MUSTEK_FLAG_SE) { status = set_window_se (s, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: set window command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } s->scanning = SANE_TRUE; s->cancelled = SANE_FALSE; dev_wait_ready (s); status = get_window (s, &s->params.bytes_per_line, &s->params.lines, &s->params.pixels_per_line); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: get window command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = calibration_se (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = start_scan (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = send_gamma_table_se (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; } else if (s->hw->flags & MUSTEK_FLAG_PRO) { status = dev_wait_ready (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = set_window_pro (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; s->scanning = SANE_TRUE; s->cancelled = SANE_FALSE; status = adf_and_backtrack (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = mode_select_pro (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = scsi_sense_wait_ready (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = calibration_pro (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = send_gamma_table (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = start_scan (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = get_image_status (s, &s->params.bytes_per_line, &s->params.lines); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = scsi_sense_wait_ready (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; } else /* Paragon series */ { status = area_and_windows (s); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_start: set scan area command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = adf_and_backtrack (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; if (s->one_pass_color_scan) { status = mode_select_paragon (s, MUSTEK_CODE_RED); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = mode_select_paragon (s, MUSTEK_CODE_GREEN); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = mode_select_paragon (s, MUSTEK_CODE_BLUE); } else status = mode_select_paragon (s, MUSTEK_CODE_GRAY); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; s->scanning = SANE_TRUE; s->cancelled = SANE_FALSE; status = send_gamma_table (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = start_scan (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; if (!(s->hw->flags & MUSTEK_FLAG_SCSI_PP)) { /* This second gamma table download upsets the SCSI-over-parallel models */ status = send_gamma_table (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; } s->ld.max_value = 0; if (!(s->hw->flags & MUSTEK_FLAG_THREE_PASS)) { status = line_distance (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; } status = get_image_status (s, &s->params.bytes_per_line, &s->params.lines); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; if ((strcmp (s->val[OPT_SOURCE].s, "Automatic Document Feeder") == 0) && (s->hw->flags & MUSTEK_FLAG_PARAGON_2)) { status = paragon_2_get_adf_status (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; } } s->params.pixels_per_line = s->params.bytes_per_line; if (s->one_pass_color_scan) { if (strcmp (s->val[OPT_BIT_DEPTH].s, "12") == 0) s->params.pixels_per_line /= 6; else s->params.pixels_per_line /= 3; } else if ((s->mode & MUSTEK_MODE_LINEART) || (s->mode & MUSTEK_MODE_HALFTONE)) s->params.pixels_per_line *= 8; s->line = 0; /* don't call any SIGTERM or SIGCHLD handlers this is to stop xsane and other frontends from calling its quit handlers */ memset (&act, 0, sizeof (act)); sigaction (SIGTERM, &act, 0); sigaction (SIGCHLD, &act, 0); if (pipe (fds) < 0) return SANE_STATUS_IO_ERROR; s->reader_fds = fds[1]; /* create reader routine as new process or thread */ s->reader_pid = sanei_thread_begin (reader_process, (void *) s); if (!sanei_thread_is_valid (s->reader_pid)) { DBG (1, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno)); return SANE_STATUS_NO_MEM; } if (sanei_thread_is_forked ()) { close (s->reader_fds); s->reader_fds = -1; } s->pipe = fds[0]; return SANE_STATUS_GOOD; stop_scanner_and_return: do_stop (s); return status; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { Mustek_Scanner *s = handle; SANE_Status status; ssize_t nread; if (!s) { DBG (1, "sane_read: handle is null!\n"); return SANE_STATUS_INVAL; } if (!buf) { DBG (1, "sane_read: buf is null!\n"); return SANE_STATUS_INVAL; } if (!len) { DBG (1, "sane_read: len is null!\n"); return SANE_STATUS_INVAL; } DBG (5, "sane_read\n"); *len = 0; if (s->cancelled) { DBG (4, "sane_read: scan was cancelled\n"); return SANE_STATUS_CANCELLED; } if (!s->scanning) { DBG (3, "sane_read: must call sane_start before sane_read\n"); return SANE_STATUS_INVAL; } while (*len < max_len) { nread = read (s->pipe, buf + *len, max_len - *len); if (s->cancelled) { DBG (4, "sane_read: scan was cancelled\n"); *len = 0; return SANE_STATUS_CANCELLED; } if (nread < 0) { if (errno == EAGAIN) { if (*len == 0) DBG (5, "sane_read: no more data at the moment--try again\n"); else DBG (5, "sane_read: read buffer of %d bytes " "(%d bytes total)\n", *len, s->total_bytes); return SANE_STATUS_GOOD; } else { DBG (1, "sane_read: IO error\n"); do_stop (s); *len = 0; return SANE_STATUS_IO_ERROR; } } *len += nread; s->total_bytes += nread; if (nread == 0) { if (*len == 0) { if (!(s->hw->flags & MUSTEK_FLAG_THREE_PASS) || !(s->mode & MUSTEK_MODE_COLOR) || ++s->pass >= 3) { DBG (5, "sane_read: pipe was closed ... calling do_stop\n"); status = do_stop (s); if (status != SANE_STATUS_CANCELLED && status != SANE_STATUS_GOOD) return status; /* something went wrong */ } else /* 3pass color first or second pass */ { DBG (5, "sane_read: pipe was closed ... finishing pass %d\n", s->pass); } return do_eof (s); } else { DBG (5, "sane_read: read last buffer of %d bytes " "(%d bytes total)\n", *len, s->total_bytes); return SANE_STATUS_GOOD; } } } DBG (5, "sane_read: read full buffer of %d bytes (%d total bytes)\n", *len, s->total_bytes); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Mustek_Scanner *s = handle; if (!s) { DBG (1, "sane_cancel: handle is null!\n"); return; } DBG (4, "sane_cancel\n"); if (s->scanning) { s->cancelled = SANE_TRUE; do_stop (handle); } DBG (5, "sane_cancel: finished\n"); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Mustek_Scanner *s = handle; if (!s) { DBG (1, "sane_set_io_mode: handle is null!\n"); return SANE_STATUS_INVAL; } DBG (4, "sane_set_io_mode: %s\n", non_blocking ? "non-blocking" : "blocking"); if (!s->scanning) { DBG (1, "sane_set_io_mode: call sane_start before sane_set_io_mode"); return SANE_STATUS_INVAL; } if (fcntl (s->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) { DBG (1, "sane_set_io_mode: can't set io mode"); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Mustek_Scanner *s = handle; if (!s) { DBG (1, "sane_get_select_fd: handle is null!\n"); return SANE_STATUS_INVAL; } if (!fd) { DBG (1, "sane_get_select_fd: fd is null!\n"); return SANE_STATUS_INVAL; } DBG (4, "sane_get_select_fd\n"); if (!s->scanning) return SANE_STATUS_INVAL; *fd = s->pipe; return SANE_STATUS_GOOD; } #include "mustek_scsi_pp.c" sane-backends-1.0.29/backend/pieusb_specific.h0000666000000000000000000003720013615534521016077 00000000000000/* sane - Scanner Access Now Easy. pieusb_specific.h Copyright (C) 2012-2015 Jan Vleeshouwers, Michael Rickmann, Klaus Kaempf 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef PIEUSB_SPECIFIC_H #define PIEUSB_SPECIFIC_H #include "../include/sane/sanei_ir.h" #include "../include/sane/sanei_backend.h" #include "pieusb_scancmd.h" #include "pieusb_buffer.h" /* Settings for scan modes available to SANE */ /* In addition to those defined in sane.h */ #define SANE_VALUE_SCAN_MODE_RGBI "RGBI" /* Scanner settings for colors to scan */ #define SCAN_ONE_PASS_RGBI 0x90 #define SCAN_ONE_PASS_COLOR 0x80 #define SCAN_FILTER_INFRARED 0x10 #define SCAN_FILTER_BLUE 0x08 #define SCAN_FILTER_GREEN 0x04 #define SCAN_FILTER_RED 0x02 #define SCAN_FILTER_NEUTRAL 0x01 /* Settings for color depth of scan */ #define SCAN_COLOR_DEPTH_16 0x20 #define SCAN_COLOR_DEPTH_12 0x10 #define SCAN_COLOR_DEPTH_10 0x08 #define SCAN_COLOR_DEPTH_8 0x04 #define SCAN_COLOR_DEPTH_4 0x02 #define SCAN_COLOR_DEPTH_1 0x01 /* Settings for format of the scanned data */ #define SCAN_COLOR_FORMAT_INDEX 0x04 #define SCAN_COLOR_FORMAT_LINE 0x02 #define SCAN_COLOR_FORMAT_PIXEL 0x01 /* Settings for calibration mode */ #define SCAN_CALIBRATION_DEFAULT "default values" #define SCAN_CALIBRATION_AUTO "from internal test" #define SCAN_CALIBRATION_PREVIEW "from preview" #define SCAN_CALIBRATION_OPTIONS "from options" /* Settings for additional gain */ #define SCAN_GAIN_ADJUST_03 "* 0.3" #define SCAN_GAIN_ADJUST_05 "* 0.5" #define SCAN_GAIN_ADJUST_08 "* 0.8" #define SCAN_GAIN_ADJUST_10 "* 1.0" #define SCAN_GAIN_ADJUST_12 "* 1.2" #define SCAN_GAIN_ADJUST_16 "* 1.6" #define SCAN_GAIN_ADJUST_19 "* 1.9" #define SCAN_GAIN_ADJUST_24 "* 2.4" #define SCAN_GAIN_ADJUST_30 "* 3.0" /* Post-processing */ #define POST_SW_COLORS (1 << 0) /* gain, negatives, ..., can be done at any time */ #define POST_SW_IRED (1 << 1) /* remove spectral overlap, needs complete scan */ #define POST_SW_DIRT (1 << 2) /* our digital lavabo, needs complete scan */ #define POST_SW_GRAIN (1 << 3) /* smoothen a bit */ #define POST_SW_CROP (1 << 4) /* trim whole image in sane_start before sane_get_parameters() is answered */ #define POST_SW_IRED_MASK (POST_SW_IRED | POST_SW_DIRT) #define POST_SW_ACCUM_MASK (POST_SW_IRED_MASK | POST_SW_GRAIN | POST_SW_CROP) #define DEFAULT_GAIN 19 /* 0x13 */ #define DEFAULT_EXPOSURE 2937 /* 0xb79 minimum value, see Pieusb_Settings */ #define DEFAULT_OFFSET 0 #define DEFAULT_LIGHT 4 #define DEFAULT_ADDITIONAL_ENTRIES 1 #define DEFAULT_DOUBLE_TIMES 0 /* -------------------------------------------------------------------------- * * DEVICE DEFINITION STRUCTURES * * --------------------------------------------------------------------------*/ /* Options supported by the scanner */ enum Pieusb_Option { OPT_NUM_OPTS = 0, /* ------------------------------------------- */ OPT_MODE_GROUP, OPT_MODE, /* scan mode */ OPT_BIT_DEPTH, /* number of bits to encode a color */ OPT_RESOLUTION, /* number of pixels per inch */ OPT_HALFTONE_PATTERN, /* halftone pattern to use (see halftone_list) */ OPT_THRESHOLD, /* halftone threshold */ OPT_SHARPEN, /* create a sharper scan at the cost of scan time */ OPT_SHADING_ANALYSIS, /* do shading analysis before the scan */ OPT_FAST_INFRARED, /* scan infrared channel faster but less accurate */ OPT_ADVANCE_SLIDE, /* auto-advance slide after scan */ OPT_CALIBRATION_MODE, /* use auto-calibarion settings for scan */ /* ------------------------------------------- */ OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ /* ------------------------------------------- */ OPT_ENHANCEMENT_GROUP, OPT_CORRECT_SHADING, /* correct scanned data for lamp variations (shading) */ OPT_CORRECT_INFRARED, /* correct infrared for red crosstalk */ OPT_CLEAN_IMAGE, /* detect and remove dust and scratch artifacts */ OPT_GAIN_ADJUST, /* adjust gain (a simpler option than setting gain, exposure and offset directly) */ OPT_CROP_IMAGE, /* automatically crop image */ OPT_SMOOTH_IMAGE, /* smoothen image */ OPT_TRANSFORM_TO_SRGB, /* transform to approximate sRGB data */ OPT_INVERT_IMAGE, /* transform negative to positive */ /* ------------------------------------------- */ OPT_ADVANCED_GROUP, OPT_PREVIEW, /* scan a preview before the actual scan */ OPT_SAVE_SHADINGDATA, /* output shading data */ OPT_SAVE_CCDMASK, /* output CCD mask */ OPT_LIGHT, OPT_DOUBLE_TIMES, OPT_SET_EXPOSURE_R, /* exposure times for R */ OPT_SET_EXPOSURE_G, /* exposure times for G */ OPT_SET_EXPOSURE_B, /* exposure times for B */ OPT_SET_EXPOSURE_I, /* exposure times for I */ OPT_SET_GAIN_R, /* gain for R */ OPT_SET_GAIN_G, /* gain for G */ OPT_SET_GAIN_B, /* gain for B */ OPT_SET_GAIN_I, /* gain for I */ OPT_SET_OFFSET_R, /* offset for R */ OPT_SET_OFFSET_G, /* offset for G */ OPT_SET_OFFSET_B, /* offset for B */ OPT_SET_OFFSET_I, /* offset for I */ /* must come last: */ NUM_OPTIONS }; /* Forward declaration (see pieusb_scancmd.h) */ struct Pieusb_Shading_Parameters; /* Device characteristics of a Pieusb USB scanner */ struct Pieusb_Device_Definition { struct Pieusb_Device_Definition *next; SANE_Device sane; /* name = string like "libusb:001:006" == NO! this should be "CrystalScan 7200" or "ProScan 7200"... * vendor = "PIE/Pieusb" * model = "CrystalScan 7200" or "ProScan 7200" * type = "film scanner" */ /* char *devicename; => sane->name */ /* char *vendor; => sane->vendor */ /* char *product; => sane->model */ SANE_Word vendorId; SANE_Word productId; /* 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; SANE_Range x_range; SANE_Range y_range; SANE_Range exposure_range; /* Unit is a 8051 machine cycle, which is approximately 1 us. (Exactly: 12 cycles at 11.059 Mhz = 1.085 us.) */ SANE_Range dust_range; SANE_Range shadow_range; SANE_Range highlight_range; /* Enumerated ranges vor various quantities */ SANE_String scan_mode_list[7]; /* names of scan modes (see saneopts.h) */ SANE_String calibration_mode_list[6]; /* names of calibration modes */ SANE_String gain_adjust_list[10]; /* gain adjustment values */ SANE_Word bpp_list[5]; /* bit depths */ SANE_String halftone_list[17]; /* names of the halftone patterns from the scanner */ SANE_String speed_list[9]; /* names of available speeds */ SANE_String ir_sw_list[4]; SANE_String crop_sw_list[4]; SANE_Word grain_sw_list[6]; /* Maximum resolution values */ int maximum_resolution_x; /* maximum x-resolution */ int maximum_resolution_y; /* maximum y-resolution */ int maximum_resolution; /* Geometry */ double scan_bed_width; /* flatbed width in inches (horizontal) */ double scan_bed_height; /* flatbed height in inches (vertical) */ int slide_top_left_x; /* top-left location of slide w.r.t. scan bed */ int slide_top_left_y; /* top-left location of slide w.r.t. scan bed */ double slide_width; /* transparency width in inches */ double slide_height; /* transparency length in inches */ /* Integer and bit-encoded properties */ int halftone_patterns; /* number of halftones supported */ int color_filters; /* available colour filters: Infrared-0-0-OnePassColor-B-G-R-N */ int color_depths; /* available colour depths: 0-0-16-12-10-8-4-1 */ int color_formats; /* colour data format: 0-0-0-0-0-Index-Line-Pixel */ int image_formats; /* image data format: 0-0-0-0-OKLine-BlkOne-Motorola-Intel */ int scan_capabilities; /* additional scanner features, number of speeds: PowerSave-ExtCal-0-FastPreview-DisableCal-[CalSpeeds=3] */ int optional_devices; /* optional devices: MultiPageLoad-?-?-0-0-TransModule1-TransModule-AutoDocFeeder */ int enhancements; /* enhancements: unknown coding */ int gamma_bits; /* no of bits used for gamma table */ int fast_preview_resolution; /* fast preview resolution */ int minimum_highlight; /* min highlight % that can be used */ int maximum_shadow; /* max shadow % that can be used */ int calibration_equation; /* which calibration equation to use */ int minimum_exposure; /* min exposure */ int maximum_exposure; /* max exposure */ struct Pieusb_Shading_Parameters_Info shading_parameters[4]; /* array with shading data parameters */ int x0, y0, x1, y1; SANE_String production; SANE_String timestamp; SANE_String signature; }; typedef struct Pieusb_Device_Definition Pieusb_Device_Definition; /* -------------------------------------------------------------------------- * * CURRENTLY ACTIVE DEVICES * * --------------------------------------------------------------------------*/ /* This structure holds information about an instance of an active scanner */ struct Pieusb_Scanner { struct Pieusb_Scanner *next; struct Pieusb_Device_Definition *device; /* pointer to device definition */ int device_number; /* scanner device number (as determined by USB) */ /* SANE option descriptions and settings for this scanner instance */ SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; /* Scan state */ struct Pieusb_Scanner_State state; SANE_Int scanning; /* true if busy scanning */ SANE_Int cancel_request; /* if true, scanner should terminate a scan */ /* Scan settings */ struct Pieusb_Mode mode; struct Pieusb_Settings settings; struct Pieusb_Scan_Frame frame; SANE_Parameters scan_parameters; /* Shading data and CCD-mask */ #define PIEUSB_CCD_MASK_SIZE 0x1a1d /* pieusb 5340; */ /* cyberview: 6685 0x1a1d */ SANE_Byte *ccd_mask; /* malloc'ed in sane_open */ SANE_Int ccd_mask_size; SANE_Bool shading_data_present; /* don't correct shading if not present */ SANE_Int shading_mean[SHADING_PARAMETERS_INFO_COUNT]; /* mean shading value for each color (average all 45 lines) */ SANE_Int shading_max[SHADING_PARAMETERS_INFO_COUNT]; /* maximum shading value for each color (for all 45 lines) */ SANE_Int* shading_ref[SHADING_PARAMETERS_INFO_COUNT]; /* 4 arrays of shading references for each pixel on a line and for each color */ /* Calibration using preview */ SANE_Bool preview_done; SANE_Int preview_exposure[4]; /* exposure values used in preview */ SANE_Int preview_gain[4]; /* gain values used in preview */ SANE_Int preview_offset[4]; /* offset values used in preview */ SANE_Int preview_lower_bound[4]; /* lowest RGBI values in preview */ SANE_Int preview_upper_bound[4]; /* highest RGBI values in preview */ /* Post processing options */ /* SANE_Int processing; */ double *ln_lut; /* logarithmic lookup table */ /* Reading buffer */ struct Pieusb_Read_Buffer buffer; }; 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_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); SANE_Status sanei_pieusb_get_scan_data(Pieusb_Scanner * scanner, SANE_Int parameter_bytes); SANE_Status sanei_pieusb_get_parameters(Pieusb_Scanner * scanner, SANE_Int *parameter_bytes); SANE_Status sanei_pieusb_get_ccd_mask(Pieusb_Scanner * scanner); SANE_Status sanei_pieusb_get_shading_data(Pieusb_Scanner * scanner); SANE_Status sanei_pieusb_set_mode_from_options(Pieusb_Scanner * scanner); SANE_Status sanei_pieusb_set_gain_offset(Pieusb_Scanner * scanner, const char* calibration_mode); 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_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() */ SANE_Status sanei_pieusb_init_options (Pieusb_Scanner * scanner); /* sub to sane_start(), sane_read() and sane_close() */ SANE_Status sanei_pieusb_on_cancel (Pieusb_Scanner * scanner); SANE_Status sanei_pieusb_wait_ready(Pieusb_Scanner *scanner, SANE_Int device_number); SANE_Status sanei_pieusb_analyze_preview(Pieusb_Scanner * scanner); #endif /* PIEUSB_SPECIFIC_H */ sane-backends-1.0.29/backend/pieusb_scancmd.h0000666000000000000000000004475413615534521015736 00000000000000/* sane - Scanner Access Now Easy. pieusb_scancmd.h Copyright (C) 2012-2015 Jan Vleeshouwers, Michael Rickmann, Klaus Kaempf 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef PIEUSB_SCANCMD_H #define PIEUSB_SCANCMD_H #include "../include/sane/sane.h" /* ========================================================================= * * Data-structures used by scanner commands * * For SENSE descriptions, see SCSI-2 p158, table 67 (p469 ASC/Q alphabetically) * For the INQUIRY command, see SCSI-2 p141 table 45, 46, 47 * * 2-byte short ints are represented by 4-byte SANE_Int types * * ========================================================================= */ struct Pieusb_Scanner_Properties { SANE_Byte deviceType; /* 0x06 = scanner */ SANE_Byte additionalLength; /* including this byte: 0xb4 = 180, so total structure 184 bytes */ SANE_Char vendor[9]; /* actually 8 bytes, not null-terminated ...PIE ... */ SANE_Char product[17]; /* actually 16 bytes, null-terminated ...SF Scanner... */ SANE_Char productRevision[5]; /* actually 4 bytes, not null-terminated ...1.70... */ /* 1st Vendor-specific block, 20 bytes, see pie_get_inquiry_values(), partially: */ SANE_Int maxResolutionX; /* 7200 maximum scan resolution in x direction */ SANE_Int maxResolutionY; /* 7200 maximum scan resolution in y direction */ SANE_Int maxScanWidth; /* 10680 flatbed_max_scan_width (& calibration block size) */ SANE_Int maxScanHeight; /* 6888 flatbed_max_scan_height */ SANE_Byte filters; /* 0x9e = 10011110 ?-0-0-OnePassColor-B-G-R-N => additional infrared? */ SANE_Byte colorDepths; /* 0x35 = 00110101 0-0-16-12-10-8-4-1 */ SANE_Byte colorFormat; /* 0x07 = 00000111 0-0-0-0-0-Index-Line-Pixel */ SANE_Byte imageFormat; /* 0x09 = 00001001 0-0-0-0-OKLine-BlkOne-Motorola-Intel */ SANE_Byte scanCapability; /* 0x4b = 01001011 PowerSave-ExtCal-0-FastPreview-DisableCal-[CalSpeeds=3] * PowerSave: no * ExtCal: yes => * FastPreview: no * DisableCal: yes => can calibration be disabled? * CalSpeeds: 3 => 1 line, 13 lines, 31 lines */ SANE_Byte optionalDevices; /* 0x61 = 01100001 MultiPageLoad-?-?-0-0-TransModule1-TransModule-AutoDocFeeder => additional? * MultiPageLoad: no * ?: yes * ?: yes * TransModule1: no * TransModule: no * AutoDocFeeder: yes */ SANE_Byte enhancements; /* 0x02 = no info in pie.c */ SANE_Byte gammaBits; /* 0x0c = 00001100 = 12 ? used when downloading gamma table ... does not happen */ SANE_Byte lastFilter; /* 0x00 = ? no info in pie.c, not used */ SANE_Int previewScanResolution; /* 0x2c01 = 300 fast preview scan resolution */ /* Reserved (56-95) */ /* SANE_Byte div_56[40]; */ /* 2nd vendor specific block (36 bytes at offset 96) */ SANE_Char firmwareVersion[5]; /* actually 4 bytes, not null terminated "1.05" */ SANE_Byte halftones; /* 0x08 = halftones (4 LSbits) = 00001000 ? */ SANE_Byte minumumHighlight; /* 0x64 = 100 */ SANE_Byte maximumShadow; /* 0x64 = 100 */ SANE_Byte calibrationEquation; /* 0x01 ? see pie_perform_cal() */ SANE_Int maximumExposure; /* 0xc409 = 2500 (units?) */ SANE_Int minimumExposure; /* 0x6400 = 100 (units?) */ SANE_Int x0; /* 0xd002 = 720 transparency top left x */ SANE_Int y0; /* 0x8604 = 1158 transparency top left y */ SANE_Int x1; /* 0xbc10 = 4284 transparency bottom right x */ SANE_Int y1; /* 0xc015 = 5568 transparency bottom right y */ SANE_Int model; /* 0x3000 => model number */ /* SANE_Int div_118; 0x0000 meaning? */ SANE_Char production[4]; /* null terminated */ SANE_Char timestamp[20]; /* null terminated */ SANE_Byte signature[40]; /* null terminated */ }; struct Pieusb_Sense { /* 14 bytes according to SCSI-2 p158, table 67 (p469 ASC/Q alphabetically) */ SANE_Byte errorCode; /* 0x70 or 0x71 */ SANE_Byte segment; SANE_Byte senseKey; /* sense key is actually this value & 0x0F - table 69 */ SANE_Byte info[4]; SANE_Byte addLength; /* should be 0x07 (remaining struct length including this byte) */ SANE_Byte cmdInfo[4]; /* command specific information */ SANE_Byte senseCode; /* abbreviated ASC - table 71 */ SANE_Byte senseQualifier; /* abbreviated ASCQ - table 71 */ }; struct Pieusb_Scanner_State { SANE_Byte buttonPushed; /* 0x01 if pushed */ SANE_Byte warmingUp; /* 0x01 if warming up, 0x00 if not */ SANE_Byte scanning; /* bit 6 set if SCAN active, bit 7 motor direction inverted (not analysed in detail) */ }; struct Pieusb_Scan_Parameters { SANE_Int width; /* Number of pixels on a scan line */ SANE_Int lines; /* Number of lines in the scan. Value depends on color format, see Pieusb_Mode. */ SANE_Int bytes; /* Number of bytes on a scan line. Value depends on color format. */ SANE_Byte filterOffset1; /* 0x08 in the logs, but may also be set to 0x16, they seem to be used in “lineâ€-format only. */ SANE_Byte filterOffset2; /* 0x08 in the logs, but may also be set to 0x16, they seem to be used in “lineâ€-format only. */ SANE_Int period; /* Seems to be unused */ SANE_Int scsiTransferRate; /* Don't use, values cannot be trusted */ SANE_Int availableLines; /* The number of currently available scanned lines. Value depends on color format. Returns a value >0 if PARAM is called while scanning is in progress */ SANE_Byte motor; /* Motor direction in bit 0 */ }; struct Pieusb_Mode { /* SANE_Byte size; of remaining data, not useful */ SANE_Int resolution; /* in dpi */ SANE_Byte passes; /* 0x80 = One pass color; 0x90 = One pass RGBI; * bit 7 : one-pass-color bit (equivalent to RGB all set?) * bit 6 & 5: unused * bit 4 : Infrared * bit 3 : Blue * bit 2 : Green * bit 1 : Red * bit 0: Neutral (not supported, ignored) */ SANE_Byte colorDepth; /* 0x04 = 8, 0x20 = 16 bit * bit 7 & 6 : 0 (unused) * bit 5 : 16 bit * bit 4 : 12 bit * bit 3 : 10 bit * bit 2 : 8 bit * bit 1 : 4 bit * bit 0 : 1 bit */ SANE_Byte colorFormat; /* 0x04 = index, cf. INQUIRY * bit 7-3 : 0 (unused) * bit 2 : Index = scanned data are lines preceeded by a two-byte index, 'RR', 'GG', 'BB', or 'II' * bit 1 : Line = scanned data are (probably) lines in RGBI order (needs testing) * bit 0 : Pixel = scanned data are always RGB-pixels, i.e. 3x2 bytes at depth = 16 bits, 3 bytes * at depth = 8 bits, and 3 packed bytes at depth = 1. This is also the case in * a single color or gray scale scan; in these cases only the first pixel contains * valid data. */ SANE_Byte byteOrder; /* 0x01 = Intel; only bit 0 used */ SANE_Bool sharpen; /* byte 9 bit 1 */ SANE_Bool skipShadingAnalysis; /* byte 9 bit 3 */ SANE_Bool fastInfrared; /* byte 9 bit 7 */ /* bit 7 : “fast infrared†flag * bit 6,5,4 : 0 (unused) * bit 3 : “skip calibration†flag (skip collecting shading information) * bit 2 : 0 (unused) * bit 1 : “sharpen†flag (only effective with fastInfrared off, one-pass-color and no extra BADF-entries) * bit 0 : 0 (unused) */ SANE_Byte halftonePattern; /* 0x00 = no halftone pattern */ SANE_Byte lineThreshold; /* 0xFF = 100% */ }; struct Pieusb_Settings { SANE_Int saturationLevel[3]; /* The average pixel values for the three colors Red, Green and Blue, * which are the result of optimizing the Timer 1 counts so that Red and * Blue values are least 90% of full scale (58981) and the Green value is * at least 80% (52428). These levels are only determined during warming up. */ SANE_Int exposureTime[4]; /* Optimized exposure times for Red, Green and Blue. The exposure times are * Timer 1 counts which define when Timer 1 interrupts. These values are * only determined at startup. * Exposure time for Infrared. The value is optimized and set at startup * with the other exposure times. Quite often, it is subsequently reset to * a default value (0x0B79). */ SANE_Word offset[4]; /* Optimized offsets for Red, Green and Blue. See above. These values are * also updated before outputting the CCD-mask. * Element 4 is offset for Infrared. */ SANE_Word gain[4]; /* Optimized gains for Red, Green and Blue. See the remark for * exposureTime above. Element 4 is gain for Infrared. */ SANE_Byte light; /* Current light level. The stability of the light source is tested during * warming up. The check starts with a light value 7 or 6, and decrements * it when the light warms up. At a light value of 4, the scanner produces * stable scans (i.e. successive “white†scan values don't differ more * than 0x200). */ SANE_Int minimumExposureTime; /* Fixed value: 0x0b79 (2937) */ SANE_Byte extraEntries; SANE_Byte doubleTimes; /* Originally 20 unused bytes (uninitialized memory) * To complete the mapping to the Pieusb_Settings_Condensed struct, * the last two bytes are given an explicit meaning. */ /* SANE_Int exposureTimeIR; */ /* SANE_Byte offsetIR; */ /* SANE_Byte gainIR; */ }; /* Not used, Pieusb_Settings contains the same fields (after a bit of juggling) */ struct Pieusb_Settings_Condensed { SANE_Int exposureTime[4]; /* => Pieusb_Settings.exposureTime */ SANE_Byte offset[4]; /* => Pieusb_Settings.offset */ SANE_Byte gain[4]; /* => Pieusb_Settings.gain */ SANE_Byte light; /* => Pieusb_Settings.light */ SANE_Byte extraEntries; /* => Pieusb_Settings.extraEntries */ SANE_Byte doubleTimes; /* => Pieusb_Settings.doubleTimes */ }; struct Pieusb_Halftone_Pattern { SANE_Int code; /* 0x91 */ /*TODO */ }; struct Pieusb_Scan_Frame { SANE_Int index; /* scan frame index (0-7) */ SANE_Int x0; /* top left, is origin */ SANE_Int y0; SANE_Int x1; /* bottom right */ SANE_Int y1; }; struct Pieusb_Exposure_Time_Color { SANE_Int filter; /* color mask 0x02, 0x04 or 0x08 for R, G, B */ SANE_Int value; /* relative exposure time 0 - 100 */ }; struct Pieusb_Exposure_Time { SANE_Int code; /* 0x93 */ SANE_Int size; /* number of bytes in rest of structure */ struct Pieusb_Exposure_Time_Color color[3]; /* not all elements may actually be used */ }; struct Pieusb_Highlight_Shadow_Color { SANE_Int filter; /* color mask 0x02, 0x04 or 0x08 for R, G, B */ SANE_Int value; /* 0-100 */ }; struct Pieusb_Highlight_Shadow { SANE_Int code; /* 0x94 */ SANE_Int size; /* number of bytes in rest of structure */ struct Pieusb_Highlight_Shadow_Color color[3]; }; struct Pieusb_Shading_Parameters_Info { SANE_Byte type; /* 0x00, 0x08, 0x10, 0x20; RGBI(?) */ SANE_Byte sendBits; /* 0x10 = 16 */ SANE_Byte recieveBits; /* 0x10 = 16 */ SANE_Byte nLines; /* 0x2D = 45 */ SANE_Int pixelsPerLine; /* 0x14dc = 5340 */ }; #define SHADING_PARAMETERS_INFO_COUNT 4 struct Pieusb_Shading_Parameters { SANE_Byte code; /* 0x95 */ SANE_Int size; /* number of bytes in rest of structure (0x1c=28) */ SANE_Byte calInfoCount; /* number of individual info structures (=0x04) */ SANE_Byte calInfoSize; /* size of individual info structure (=0x06) */ SANE_Int div_6; /* 0x0004, meaning not clear */ struct Pieusb_Shading_Parameters_Info cal[SHADING_PARAMETERS_INFO_COUNT]; }; typedef enum { PIEUSB_STATUS_GOOD = 0, /* 0 everything A-OK */ PIEUSB_STATUS_UNSUPPORTED, /* 1 operation is not supported */ PIEUSB_STATUS_CANCELLED, /* 2 operation was cancelled */ PIEUSB_STATUS_DEVICE_BUSY, /* 3 device is busy; try again later */ PIEUSB_STATUS_INVAL, /* 4 data is invalid (includes no dev at open) */ PIEUSB_STATUS_EOF, /* 5 no more data available (end-of-file) */ PIEUSB_STATUS_JAMMED, /* 6 document feeder jammed */ PIEUSB_STATUS_NO_DOCS, /* 7 document feeder out of documents */ PIEUSB_STATUS_COVER_OPEN, /* 8 scanner cover is open */ PIEUSB_STATUS_IO_ERROR, /* 9 error during device I/O */ PIEUSB_STATUS_NO_MEM, /* 10 out of memory */ PIEUSB_STATUS_ACCESS_DENIED, /* 11 access to resource has been denied */ PIEUSB_STATUS_WARMING_UP, /* 12 lamp not ready, please retry */ PIEUSB_STATUS_HW_LOCKED, /* 13 scanner mechanism locked for transport */ PIEUSB_STATUS_MUST_CALIBRATE /* 14 */ } PIEUSB_Status; /* Structures used by the USB functions */ struct Pieusb_Command_Status { PIEUSB_Status pieusb_status; SANE_Byte senseKey; /* sense key: see Pieusb_Sense */ SANE_Byte senseCode; /* sense code */ SANE_Byte senseQualifier; /* sense code qualifier */ }; typedef struct Pieusb_Scanner_Properties Pieusb_Scanner_Properties; typedef enum { 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); /* Scanner commands */ void sanei_pieusb_cmd_test_unit_ready(SANE_Int device_number, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_sense(SANE_Int device_number, struct Pieusb_Sense* sense, struct Pieusb_Command_Status *status, PIEUSB_Status *ret); void sanei_pieusb_cmd_get_halftone_pattern(SANE_Int device_number, SANE_Int index, struct Pieusb_Halftone_Pattern* pattern, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_set_halftone_pattern(SANE_Int device_number, SANE_Int index, struct Pieusb_Halftone_Pattern* pattern, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_scan_frame(SANE_Int device_number, SANE_Int index, struct Pieusb_Scan_Frame* frame, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_set_scan_frame(SANE_Int device_number, SANE_Int index, struct Pieusb_Scan_Frame* frame, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_17(SANE_Int device_number, SANE_Int value, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_exposure_time(SANE_Int device_number, SANE_Int colorbits, struct Pieusb_Exposure_Time* time, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_set_exposure_time(SANE_Int device_number, struct Pieusb_Exposure_Time* time, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_highlight_shadow(SANE_Int device_number, SANE_Int colorbits, struct Pieusb_Highlight_Shadow* hgltshdw, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_set_highlight_shadow(SANE_Int device_number, struct Pieusb_Highlight_Shadow* hgltshdw, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_shading_parms(SANE_Int device_number, struct Pieusb_Shading_Parameters_Info* shading, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_scanned_lines(SANE_Int device_number, SANE_Byte* data, SANE_Int lines, SANE_Int size, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_ccd_mask(SANE_Int device_number, SANE_Byte* mask, SANE_Int mask_size, struct Pieusb_Command_Status *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); /* void cmdPrepareHalftonePattern(SANE_Int device_number, SANE_Int index, struct Pieusb_Command_Status *status); void cmdPrepareScanFrame(SANE_Int device_number, SANE_Int index, struct Pieusb_Command_Status *status); void cmdPrepareRelativeExposureTime(SANE_Int device_number, SANE_Int colorbits, struct Pieusb_Command_Status *status); void cmdPrepareHighlightShadow(SANE_Int device_number, SANE_Int colorbits, struct Pieusb_Command_Status *status); void cmdPrepareShadingParameters(SANE_Int device_number, struct Pieusb_Command_Status *status); */ void sanei_pieusb_cmd_get_parameters(SANE_Int device_number, struct Pieusb_Scan_Parameters* parameters, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_inquiry(SANE_Int device_number, struct Pieusb_Scanner_Properties* inq, SANE_Byte size, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_mode(SANE_Int device_number, struct Pieusb_Mode* mode, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_set_mode(SANE_Int device_number, struct Pieusb_Mode* mode, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_start_scan(SANE_Int device_number, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_stop_scan(SANE_Int device_number, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_set_scan_head(SANE_Int device_number, SANE_Int mode, SANE_Int steps, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_get_gain_offset(SANE_Int device_number, struct Pieusb_Settings* settings, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_set_gain_offset(SANE_Int device_number, struct Pieusb_Settings* settings, struct Pieusb_Command_Status *status); void sanei_pieusb_cmd_read_state(SANE_Int device_number, struct Pieusb_Scanner_State* state, struct Pieusb_Command_Status *status); #endif /* PIEUSB_SCANCMD_H */ sane-backends-1.0.29/backend/matsushita.conf.in0000666000000000000000000000123113615534521016223 00000000000000# # Panasonic / Matsushita scanners scsi "K.M.E. " "KV-SS25A " scsi "K.M.E. " "KV-SS55EX " scsi "K.M.E. " "KV-S2025C " scsi "K.M.E. " "KV-S2045C " scsi "K.M.E. " "KV-S2065L " # These scanners are untested. # If you have one: # - check that the vendor/product strings are correct # - uncomment the line # - test with a frontend (xscanimage, xsane, ...) #scsi "K.M.E. " "KV-SS25 " #scsi "K.M.E. " "KV-SS25D " #scsi "K.M.E. " "KV-SS50 " #scsi "K.M.E. " "KV-SS55 " #scsi "K.M.E. " "KV-SS50EX " #scsi "K.M.E. " "KV-SS850 " #scsi "K.M.E. " "KV-SS855 " /dev/scanner sane-backends-1.0.29/backend/umax-scanner.h0000666000000000000000000000424013615534521015342 00000000000000/* -------------------------------------------------------------------- */ /* umax-scanner.h: scanner-definiton header-file for UMAX scanner driver. (C) 1997-2002 Oliver Rauch 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* -------------------------------------------------------------------- */ #ifndef UMAX_SCANNER_H #define UMAX_SCANNER_H /* -------------------------------------------------------------------- */ typedef struct { char *scanner; unsigned char *inquiry; int inquiry_len; } inquiry_blk; #endif sane-backends-1.0.29/backend/epjitsu.c0000666000000000000000000044632213615534521014432 00000000000000/* sane - Scanner Access Now Easy. 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 published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. -------------------------------------------------------------------------- The source code is divided in sections which you can easily find by searching for the tag "@@". Section 1 - Init & static stuff Section 2 - sane_init, _get_devices, _open & friends Section 3 - sane_*_option functions Section 4 - sane_start, _get_param, _read & friends Section 5 - sane_close functions Section 6 - misc functions Changes: v0, 2007-08-08, MAN - initial alpha release, S300 raw data only v1, 2007-09-03, MAN - only supports 300dpi duplex binary for S300 v2, 2007-09-05, MAN - add resolution option (only one choice) - add simplex option v3, 2007-09-12, MAN - add support for 150 dpi resolution v4, 2007-10-03, MAN - change binarization algo to use average of all channels v5, 2007-10-10, MAN - move data blocks to separate file - add basic fi-60F support (600dpi color) v6, 2007-11-12, MAN - move various data vars into transfer structs - move most of read_from_scanner to sane_read - add single line reads to calibration code - generate calibration buffer from above reads v7, 2007-12-05, MAN - split calibration into fine and coarse functions - add S300 fine calibration code - add S300 color and grayscale support v8, 2007-12-06, MAN - change sane_start to call ingest earlier - enable SOURCE_ADF_BACK - add if() around memcopy and better debugs in sane_read - shorten default scan sizes from 15.4 to 11.75 inches v9, 2007-12-17, MAN - fi-60F 300 & 600 dpi support (150 is non-square?) - fi-60F gray & binary support - fi-60F improved calibration v10, 2007-12-19, MAN (SANE v1.0.19) - fix missing function (and memory leak) v11 2008-02-14, MAN - sanei_config_read has already cleaned string (#310597) v12 2008-02-28, MAN - cleanup double free bug with new destroy() v13 2008-09-18, MAN - add working page-height control - add working brightness, contrast and threshold controls - add disabled threshold curve and geometry controls - move initialization code to sane_get_devices, for hotplugging v14 2008-09-24, MAN - support S300 on USB power - support S300 225x200 and 600x600 scans - support for automatic paper length detection (parm.lines = -1) v15 2008-09-24, MAN - expose hardware buttons/sensors as options for S300 v16 2008-10-01, MAN - split fill_frontback_buffers_S300 into 3 functions - enable threshold_curve option - add 1-D dynamic binary thresholding code - remove y-resolution option - pad 225x200 data to 225x225 v17 2008-10-03, MAN - increase scan height ~1/2 inch due to head offset - change page length autodetection condition v18 2009-01-21, MAN - dont export private symbols v19 2009-08-31, RG - rewritten calibration routines v20 2010-02-09, MAN (SANE 1.0.21 to 1.0.24) - cleanup #include lines & copyright - add S1300 v21 2011-04-15, MAN - unreleased attempt at S1100 support v22 2014-05-15, MAN/Hiroshi Miura - port some S1100 changes from v21 - add paper size support v23 2014-05-20, MAN - add S1300i support - fix buffer overruns in read_from_scanner - set default page width - simplified the 225x200 resolution code v24 2014-06-01, MAN - enable fine calibration for S1300i 225 & 300 dpi, and S300 150 dpi v25 2014-06-04, MAN - initial support for fi-65F - initial support for S1100 v26 2014-06-28, MAN - add resolution scaling - fix 150 dpi settings for fi-60F and fi-65F - make adf_height_padding variable - make white_factor variable v27 2015-01-24, MAN - don't override br_x and br_y - 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 - sane_init() : initialize backend . - sane_get_devices() : query list of scanner devices . - sane_open() : open a particular scanner device . . - sane_set_io_mode : set blocking mode . . - sane_get_select_fd : get scanner fd . . . . - sane_get_option_descriptor() : get option information . . - sane_control_option() : change option values . . - sane_get_parameters() : returns estimated scan parameters . . - (repeat previous 3 functions) . . . . - sane_start() : start image acquisition . . - sane_get_parameters() : returns actual scan parameters . . - sane_read() : read image data (from pipe) . . (sane_read called multiple times; after sane_read returns EOF, . . loop may continue with sane_start which may return a 2nd page . . when doing duplex scans, or load the next page from the ADF) . . . . - sane_cancel() : cancel operation . - sane_close() : close opened scanner device - sane_exit() : terminate use of backend */ /* * @@ Section 1 - Init */ #include "../include/sane/config.h" #include /*memcpy...*/ #include /*isspace*/ #include /*tan*/ #include /*usleep*/ #include /*time*/ #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include "epjitsu.h" #include "epjitsu-cmd.h" #define DEBUG 1 #define BUILD 31 #ifndef MAX3 #define MAX3(a,b,c) ((a) > (b) ? ((a) > (c) ? a : c) : ((b) > (c) ? b : c)) #endif unsigned char global_firmware_filename[PATH_MAX]; /* values for SANE_DEBUG_EPJITSU env var: - errors 5 - function trace 10 - function detail 15 - get/setopt cmds 20 - usb cmd trace 25 - usb cmd detail 30 - useless noise 35 */ /* Calibration settings */ #define COARSE_OFFSET_TARGET 15 static int coarse_gain_min[3] = { 88, 88, 88 }; /* front, back, FI-60F 3rd plane */ static int coarse_gain_max[3] = { 92, 92, 92 }; static int fine_gain_target[3] = {185, 150, 170}; /* front, back, FI-60F is this ok? */ /* ------------------------------------------------------------------------- */ #define STRING_FLATBED SANE_I18N("Flatbed") #define STRING_ADFFRONT SANE_I18N("ADF Front") #define STRING_ADFBACK SANE_I18N("ADF Back") #define STRING_ADFDUPLEX SANE_I18N("ADF Duplex") #define STRING_LINEART SANE_VALUE_SCAN_MODE_LINEART #define STRING_GRAYSCALE SANE_VALUE_SCAN_MODE_GRAY #define STRING_COLOR SANE_VALUE_SCAN_MODE_COLOR /* * used by attach* and sane_get_devices * a ptr to a null term array of ptrs to SANE_Device structs * a ptr to a single-linked list of scanner structs */ static const SANE_Device **sane_devArray = NULL; static struct scanner *scanner_devList = NULL; /* * @@ Section 2 - SANE & scanner init code */ /* * Called by SANE initially. * * From the SANE spec: * This function must be called before any other SANE function can be * called. The behavior of a SANE backend is undefined if this * function is not called first. The version code of the backend is * returned in the value pointed to by version_code. If that pointer * is NULL, no version code is returned. Argument authorize is either * a pointer to a function that is invoked when the backend requires * authentication for a specific resource or NULL if the frontend does * not support authentication. */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { authorize = authorize; /* get rid of compiler warning */ DBG_INIT (); DBG (10, "sane_init: start\n"); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (5, "sane_init: epjitsu backend %d.%d.%d, from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); DBG (10, "sane_init: finish\n"); return SANE_STATUS_GOOD; } /* * Called by SANE to find out about supported devices. * * From the SANE spec: * This function can be used to query the list of devices that are * available. If the function executes successfully, it stores a * pointer to a NULL terminated array of pointers to SANE_Device * structures in *device_list. The returned list is guaranteed to * remain unchanged and valid until (a) another call to this function * is performed or (b) a call to sane_exit() is performed. This * function can be called repeatedly to detect when new devices become * available. If argument local_only is true, only local devices are * returned (devices directly attached to the machine that SANE is * running on). If it is false, the device list includes all remote * devices that are accessible to the SANE library. * * SANE does not require that this function is called before a * sane_open() call is performed. A device name may be specified * explicitly by a user which would make it unnecessary and * undesirable to call this function first. * * Read the config file, find scanners with help from sanei_* * store in global device structs */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { SANE_Status ret = SANE_STATUS_GOOD; struct scanner * s; struct scanner * prev = NULL; char line[PATH_MAX]; const char *lp; FILE *fp; int num_devices=0; int i=0; local_only = local_only; /* get rid of compiler warning */ DBG (10, "sane_get_devices: start\n"); /* mark all existing scanners as missing, attach_one will remove mark */ for (s = scanner_devList; s; s = s->next) { s->missing = 1; } sanei_usb_init(); fp = sanei_config_open (CONFIG_FILE); if (fp) { DBG (15, "sane_get_devices: reading config file %s\n", CONFIG_FILE); while (sanei_config_read (line, PATH_MAX, fp)) { lp = line; /* ignore comments */ if (*lp == '#') continue; /* skip empty lines */ if (*lp == 0) continue; if ((strncmp ("firmware", lp, 8) == 0) && isspace (lp[8])) { size_t firmware_len; lp += 8; lp = sanei_config_skip_whitespace (lp); DBG (15, "sane_get_devices: firmware '%s'\n", lp); firmware_len = strlen(lp); if (firmware_len > sizeof(global_firmware_filename) - 1) { DBG (5, "sane_get_devices: firmware file too long. ignoring '%s'\n", lp); } else { strcpy((char *)global_firmware_filename, lp); } } else if ((strncmp ("usb", lp, 3) == 0) && isspace (lp[3])) { DBG (15, "sane_get_devices: looking for '%s'\n", lp); sanei_usb_attach_matching_devices(lp, attach_one); } else{ DBG (5, "sane_get_devices: config line \"%s\" ignored.\n", lp); } } fclose (fp); } else { DBG (5, "sane_get_devices: no config file '%s'!\n", CONFIG_FILE); } /*delete missing scanners from list*/ for (s = scanner_devList; s;) { if(s->missing){ DBG (5, "sane_get_devices: missing scanner %s\n",s->sane.name); /*splice s out of list by changing pointer in prev to next*/ if(prev){ prev->next = s->next; free(s); s=prev->next; } /*remove s from head of list, using prev to cache it*/ else{ prev = s; s = s->next; free(prev); prev=NULL; /*reset head to next s*/ scanner_devList = s; } } else{ prev = s; s=prev->next; } } for (s = scanner_devList; s; s=s->next) { DBG (15, "sane_get_devices: found scanner %s\n",s->sane.name); num_devices++; } DBG (15, "sane_get_devices: found %d scanner(s)\n",num_devices); if (sane_devArray) free (sane_devArray); sane_devArray = calloc (num_devices + 1, sizeof (SANE_Device*)); if (!sane_devArray) return SANE_STATUS_NO_MEM; for (s = scanner_devList; s; s=s->next) { sane_devArray[i++] = (SANE_Device *)&s->sane; } sane_devArray[i] = 0; if(device_list){ *device_list = sane_devArray; } DBG (10, "sane_get_devices: finish\n"); return ret; } /* callback used by sane_init * build the scanner struct and link to global list * unless struct is already loaded, then pretend */ static SANE_Status attach_one (const char *name) { struct scanner *s; int ret, i; DBG (10, "attach_one: start '%s'\n", name); for (s = scanner_devList; s; s = s->next) { if (strcmp (s->sane.name, name) == 0) { DBG (10, "attach_one: already attached!\n"); s->missing = 0; return SANE_STATUS_GOOD; } } /* build a scanner struct to hold it */ DBG (15, "attach_one: init struct\n"); if ((s = calloc (sizeof (*s), 1)) == NULL) return SANE_STATUS_NO_MEM; /* copy the device name */ s->sane.name = strdup (name); if (!s->sane.name){ destroy(s); return SANE_STATUS_NO_MEM; } /* connect the fd */ DBG (15, "attach_one: connect fd\n"); s->fd = -1; ret = connect_fd(s); if(ret != SANE_STATUS_GOOD){ destroy(s); return ret; } /* load the firmware file into scanner */ ret = load_fw(s); if (ret != SANE_STATUS_GOOD) { destroy(s); DBG (5, "attach_one: firmware load failed\n"); return ret; } /* Now query the device to load its vendor/model/version */ ret = get_ident(s); if (ret != SANE_STATUS_GOOD) { destroy(s); DBG (5, "attach_one: identify failed\n"); return ret; } DBG (15, "attach_one: Found %s scanner %s at %s\n", s->sane.vendor, s->sane.model, s->sane.name); if (strstr (s->sane.model, "S1300i")){ unsigned char stat; DBG (15, "attach_one: Found S1300i\n"); stat = get_stat(s); if(stat & 0x01){ DBG (5, "attach_one: on USB power?\n"); s->usb_power=1; } s->model = MODEL_S1300i; s->has_adf = 1; s->has_adf_duplex = 1; s->min_res = 50; s->max_res = 600; s->adf_height_padding = 600; /* Blue, Red, Green */ s->white_factor[0] = 1.0; s->white_factor[1] = 0.93; s->white_factor[2] = 0.98; s->source = SOURCE_ADF_FRONT; s->mode = MODE_LINEART; s->resolution = 300; s->page_height = 11.5 * 1200; s->page_width = 8.5 * 1200; s->threshold = 120; s->threshold_curve = 55; } else if (strstr (s->sane.model, "S300") || strstr (s->sane.model, "S1300")){ unsigned char stat; DBG (15, "attach_one: Found S300/S1300\n"); stat = get_stat(s); if(stat & 0x01){ DBG (5, "attach_one: on USB power?\n"); s->usb_power=1; } s->model = MODEL_S300; s->has_adf = 1; s->has_adf_duplex = 1; s->min_res = 50; s->max_res = 600; s->adf_height_padding = 600; /* Blue, Red, Green */ s->white_factor[0] = 1.0; s->white_factor[1] = 0.93; s->white_factor[2] = 0.98; s->source = SOURCE_ADF_FRONT; s->mode = MODE_LINEART; s->resolution = 300; s->page_height = 11.5 * 1200; s->page_width = 8.5 * 1200; s->threshold = 120; s->threshold_curve = 55; } else if (strstr (s->sane.model, "S1100")){ DBG (15, "attach_one: Found S1100\n"); s->model = MODEL_S1100; s->usb_power = 1; s->has_adf = 1; s->has_adf_duplex = 0; s->min_res = 50; s->max_res = 600; s->adf_height_padding = 450; /* Blue, Red, Green */ s->white_factor[0] = 0.95; s->white_factor[1] = 1.0; s->white_factor[2] = 1.0; s->source = SOURCE_ADF_FRONT; s->mode = MODE_LINEART; s->resolution = 300; s->page_height = 11.5 * 1200; s->page_width = 8.5 * 1200; s->threshold = 120; s->threshold_curve = 55; } else if (strstr (s->sane.model, "fi-60F")){ DBG (15, "attach_one: Found fi-60F\n"); s->model = MODEL_FI60F; s->has_fb = 1; s->min_res = 50; s->max_res = 600; /* Blue, Red, Green */ s->white_factor[0] = 1.0; s->white_factor[1] = 0.93; s->white_factor[2] = 0.98; s->source = SOURCE_FLATBED; s->mode = MODE_COLOR; s->resolution = 300; s->page_height = 5.83 * 1200; s->page_width = 4.1 * 1200; s->threshold = 120; s->threshold_curve = 55; } else if (strstr (s->sane.model, "fi-65F")){ DBG (15, "attach_one: Found fi-65F\n"); s->model = MODEL_FI65F; s->has_fb = 1; s->min_res = 50; s->max_res = 600; /* Blue, Red, Green */ s->white_factor[0] = 1.0; s->white_factor[1] = 0.93; s->white_factor[2] = 0.98; s->source = SOURCE_FLATBED; s->mode = MODE_COLOR; s->resolution = 300; s->page_height = 5.83 * 1200; s->page_width = 4.1 * 1200; s->threshold = 120; s->threshold_curve = 55; } else{ DBG (15, "attach_one: Found other\n"); } /* set SANE option 'values' to good defaults */ DBG (15, "attach_one: init options\n"); /* go ahead and setup the first opt, because * frontend may call control_option on it * before calling get_option_descriptor */ memset (s->opt, 0, sizeof (s->opt)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].name = "filler"; s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_INACTIVE; } s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; DBG (15, "attach_one: init settings\n"); ret = change_params(s); /* we close the connection, so that another backend can talk to scanner */ disconnect_fd(s); s->next = scanner_devList; scanner_devList = s; DBG (10, "attach_one: finish\n"); return SANE_STATUS_GOOD; } /* * connect the fd in the scanner struct */ static SANE_Status connect_fd (struct scanner *s) { SANE_Status ret; DBG (10, "connect_fd: start\n"); if(s->fd > -1){ DBG (5, "connect_fd: already open\n"); ret = SANE_STATUS_GOOD; } else { DBG (15, "connect_fd: opening USB device\n"); ret = sanei_usb_open (s->sane.name, &(s->fd)); } if(ret != SANE_STATUS_GOOD){ DBG (5, "connect_fd: could not open device: %d\n", ret); } DBG (10, "connect_fd: finish\n"); return ret; } /* * try to load fw into scanner */ static SANE_Status load_fw (struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; int file, i; int len = 0; unsigned char * buf; unsigned char cmd[4]; size_t cmdLen; unsigned char stat[2]; size_t statLen; DBG (10, "load_fw: start\n"); /*check status*/ /*reuse stat buffer*/ stat[0] = get_stat(s); if(stat[0] & 0x10){ DBG (5, "load_fw: firmware already loaded?\n"); return SANE_STATUS_GOOD; } if(!global_firmware_filename[0]){ DBG (5, "load_fw: missing filename\n"); return SANE_STATUS_NO_DOCS; } file = open((char *)global_firmware_filename,O_RDONLY); if(!file){ DBG (5, "load_fw: failed to open file %s\n",global_firmware_filename); return SANE_STATUS_NO_DOCS; } /* skip first 256 (=0x100) bytes */ if(lseek(file,0x100,SEEK_SET) != 0x100){ DBG (5, "load_fw: failed to lseek file %s\n",global_firmware_filename); close(file); return SANE_STATUS_NO_DOCS; } buf = malloc(FIRMWARE_LENGTH); if(!buf){ DBG (5, "load_fw: failed to alloc mem\n"); close(file); return SANE_STATUS_NO_MEM; } len = read(file,buf,FIRMWARE_LENGTH); close(file); if(len != FIRMWARE_LENGTH){ DBG (5, "load_fw: firmware file %s wrong length\n", global_firmware_filename); free(buf); return SANE_STATUS_NO_DOCS; } DBG (15, "load_fw: read firmware file %s ok\n", global_firmware_filename); /* firmware upload is in three commands */ /*start/status*/ cmd[0] = 0x1b; cmd[1] = 0x06; cmdLen = 2; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "load_fw: error on cmd 1\n"); free(buf); return ret; } if(stat[0] != 6){ DBG (5, "load_fw: bad stat on cmd 1\n"); free(buf); return SANE_STATUS_IO_ERROR; } /*length/data*/ cmd[0] = 0x01; cmd[1] = 0x00; cmd[2] = 0x01; cmd[3] = 0x00; cmdLen = 4; ret = do_cmd( s, 0, cmd, cmdLen, buf, FIRMWARE_LENGTH, NULL, 0 ); if(ret){ DBG (5, "load_fw: error on cmd 2\n"); free(buf); return ret; } /*checksum/status*/ cmd[0] = 0; for(i=0;i= 0; i--){ in[i] = 0; } s->sane.vendor = strndup((char *)in, 8); for (i = 23; (in[i] == ' ' || in[i] == 0xff) && i >= 8; i--){ in[i] = 0; } s->sane.model= strndup((char *)in+8, 24); s->sane.type = "scanner"; DBG (10, "get_ident: finish\n"); return ret; } /* * From the SANE spec: * This function is used to establish a connection to a particular * device. The name of the device to be opened is passed in argument * name. If the call completes successfully, a handle for the device * is returned in *h. As a special case, specifying a zero-length * string as the device requests opening the first available device * (if there is such a device). */ SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle) { struct scanner *dev = NULL; struct scanner *s = NULL; SANE_Status ret; DBG (10, "sane_open: start\n"); if(scanner_devList){ DBG (15, "sane_open: searching currently attached scanners\n"); } else{ DBG (15, "sane_open: no scanners currently attached, attaching\n"); ret = sane_get_devices(NULL,0); if(ret != SANE_STATUS_GOOD){ return ret; } } if(name[0] == 0){ DBG (15, "sane_open: no device requested, using default\n"); s = scanner_devList; } else{ DBG (15, "sane_open: device %s requested, attaching\n", name); for (dev = scanner_devList; dev; dev = dev->next) { if (strcmp (dev->sane.name, name) == 0) { s = dev; break; } } } if (!s) { DBG (5, "sane_open: no device found\n"); return SANE_STATUS_INVAL; } DBG (15, "sane_open: device %s found\n", s->sane.name); *handle = s; /* connect the fd so we can talk to scanner */ ret = connect_fd(s); if(ret != SANE_STATUS_GOOD){ return ret; } DBG (10, "sane_open: finish\n"); return SANE_STATUS_GOOD; } /* * @@ Section 3 - SANE Options functions */ /* * Returns the options we know. * * From the SANE spec: * This function is used to access option descriptors. The function * returns the option descriptor for option number n of the device * represented by handle h. Option number 0 is guaranteed to be a * valid option. Its value is an integer that specifies the number of * options that are available for device handle h (the count includes * option 0). If n is not a valid option index, the function returns * NULL. The returned option descriptor is guaranteed to remain valid * (and at the returned address) until the device is closed. */ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct scanner *s = handle; int i; SANE_Option_Descriptor *opt = &s->opt[option]; DBG (20, "sane_get_option_descriptor: %d\n", option); if ((unsigned) option >= NUM_OPTIONS) return NULL; /* "Mode" group -------------------------------------------------------- */ if(option==OPT_MODE_GROUP){ opt->title = "Scan Mode"; opt->desc = ""; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* source */ else if(option==OPT_SOURCE){ i=0; if(s->has_fb){ s->source_list[i++]=STRING_FLATBED; } if(s->has_adf){ s->source_list[i++]=STRING_ADFFRONT; if(s->has_adf_duplex){ s->source_list[i++]=STRING_ADFBACK; s->source_list[i++]=STRING_ADFDUPLEX; } } s->source_list[i]=NULL; opt->name = SANE_NAME_SCAN_SOURCE; opt->title = SANE_TITLE_SCAN_SOURCE; opt->desc = SANE_DESC_SCAN_SOURCE; opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->source_list; opt->size = maxStringSize (opt->constraint.string_list); if(i > 1){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } } /* scan mode */ else if(option==OPT_MODE){ i=0; s->mode_list[i++]=STRING_LINEART; s->mode_list[i++]=STRING_GRAYSCALE; s->mode_list[i++]=STRING_COLOR; s->mode_list[i]=NULL; opt->name = SANE_NAME_SCAN_MODE; opt->title = SANE_TITLE_SCAN_MODE; opt->desc = SANE_DESC_SCAN_MODE; opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->mode_list; opt->size = maxStringSize (opt->constraint.string_list); if(i > 1){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } } else if(option==OPT_RES){ opt->name = SANE_NAME_SCAN_RESOLUTION; opt->title = SANE_TITLE_SCAN_RESOLUTION; opt->desc = SANE_DESC_SCAN_RESOLUTION; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_DPI; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; s->res_range.min = s->min_res; s->res_range.max = s->max_res; s->res_range.quant = 1; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->res_range; } /* "Geometry" group ---------------------------------------------------- */ if(option==OPT_GEOMETRY_GROUP){ opt->name = SANE_NAME_GEOMETRY; opt->title = SANE_TITLE_GEOMETRY; opt->desc = SANE_DESC_GEOMETRY; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* top-left x */ if(option==OPT_TL_X){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->tl_x_range.min = SCANNER_UNIT_TO_FIXED_MM(0); s->tl_x_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_width(s)-s->min_x); s->tl_x_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_TL_X; opt->title = SANE_TITLE_SCAN_TL_X; opt->desc = SANE_DESC_SCAN_TL_X; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->tl_x_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt->cap = SANE_CAP_INACTIVE; } /* top-left y */ if(option==OPT_TL_Y){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->tl_y_range.min = SCANNER_UNIT_TO_FIXED_MM(0); s->tl_y_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_height(s)-s->min_y); s->tl_y_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_TL_Y; opt->title = SANE_TITLE_SCAN_TL_Y; opt->desc = SANE_DESC_SCAN_TL_Y; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->tl_y_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* bottom-right x */ if(option==OPT_BR_X){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->br_x_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_x); s->br_x_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_width(s)); s->br_x_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_BR_X; opt->title = SANE_TITLE_SCAN_BR_X; opt->desc = SANE_DESC_SCAN_BR_X; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->br_x_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt->cap = SANE_CAP_INACTIVE; } /* bottom-right y */ if(option==OPT_BR_Y){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->br_y_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_y); s->br_y_range.max = SCANNER_UNIT_TO_FIXED_MM(get_page_height(s)); s->br_y_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_BR_Y; opt->title = SANE_TITLE_SCAN_BR_Y; opt->desc = SANE_DESC_SCAN_BR_Y; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->br_y_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt->cap = SANE_CAP_INACTIVE; } /* page width */ if(option==OPT_PAGE_WIDTH){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->paper_x_range.min = SCANNER_UNIT_TO_FIXED_MM(s->min_x); s->paper_x_range.max = SCANNER_UNIT_TO_FIXED_MM(s->max_x); s->paper_x_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_PAGE_WIDTH; opt->title = SANE_TITLE_PAGE_WIDTH; opt->desc = SANE_DESC_PAGE_WIDTH; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->paper_x_range; if(s->has_adf){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->source == SOURCE_FLATBED){ opt->cap |= SANE_CAP_INACTIVE; } } else{ opt->cap = SANE_CAP_INACTIVE; } } /* page height */ if(option==OPT_PAGE_HEIGHT){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->paper_y_range.min = SCANNER_UNIT_TO_FIXED_MM(0); s->paper_y_range.max = SCANNER_UNIT_TO_FIXED_MM(s->max_y); s->paper_y_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_PAGE_HEIGHT; opt->title = SANE_TITLE_PAGE_HEIGHT; opt->desc = "Specifies the height of the media, 0 will auto-detect."; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->paper_y_range; if(s->has_adf){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->source == SOURCE_FLATBED){ opt->cap |= SANE_CAP_INACTIVE; } } else{ opt->cap = SANE_CAP_INACTIVE; } } /* "Enhancement" group ------------------------------------------------- */ if(option==OPT_ENHANCEMENT_GROUP){ opt->name = SANE_NAME_ENHANCEMENT; opt->title = SANE_TITLE_ENHANCEMENT; opt->desc = SANE_DESC_ENHANCEMENT; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* brightness */ if(option==OPT_BRIGHTNESS){ opt->name = SANE_NAME_BRIGHTNESS; opt->title = SANE_TITLE_BRIGHTNESS; opt->desc = SANE_DESC_BRIGHTNESS; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->brightness_range; s->brightness_range.quant=1; s->brightness_range.min=-127; s->brightness_range.max=127; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* contrast */ if(option==OPT_CONTRAST){ opt->name = SANE_NAME_CONTRAST; opt->title = SANE_TITLE_CONTRAST; opt->desc = SANE_DESC_CONTRAST; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->contrast_range; s->contrast_range.quant=1; s->contrast_range.min=-127; s->contrast_range.max=127; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* gamma */ if(option==OPT_GAMMA){ opt->name = "gamma"; opt->title = "Gamma function exponent"; opt->desc = "Changes intensity of midtones"; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->gamma_range; /* value ranges from .3 to 5, should be log scale? */ s->gamma_range.quant=SANE_FIX(0.01); s->gamma_range.min=SANE_FIX(0.3); s->gamma_range.max=SANE_FIX(5); /*if (s->num_download_gamma){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; }*/ opt->cap = SANE_CAP_INACTIVE; } /*threshold*/ if(option==OPT_THRESHOLD){ opt->name = SANE_NAME_THRESHOLD; opt->title = SANE_TITLE_THRESHOLD; opt->desc = SANE_DESC_THRESHOLD; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->threshold_range; s->threshold_range.min=0; s->threshold_range.max=255; s->threshold_range.quant=1; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->mode != MODE_LINEART){ opt->cap |= SANE_CAP_INACTIVE; } } if(option==OPT_THRESHOLD_CURVE){ opt->name = "threshold-curve"; opt->title = "Threshold curve"; opt->desc = "Dynamic threshold curve, from light to dark, normally 50-65"; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->threshold_curve_range; s->threshold_curve_range.min=0; s->threshold_curve_range.max=127; s->threshold_curve_range.quant=1; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if(s->mode != MODE_LINEART){ opt->cap |= SANE_CAP_INACTIVE; } } /* "Sensor" group ------------------------------------------------------ */ if(option==OPT_SENSOR_GROUP){ opt->name = SANE_NAME_SENSORS; opt->title = SANE_TITLE_SENSORS; opt->desc = SANE_DESC_SENSORS; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; /*flaming hack to get scanimage to hide group*/ if (!s->has_adf) opt->type = SANE_TYPE_BOOL; } if(option==OPT_SCAN_SW){ opt->name = SANE_NAME_SCAN; opt->title = SANE_TITLE_SCAN; opt->desc = SANE_DESC_SCAN; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_adf) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_HOPPER){ opt->name = SANE_NAME_PAGE_LOADED; opt->title = SANE_TITLE_PAGE_LOADED; opt->desc = SANE_DESC_PAGE_LOADED; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_adf) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_TOP){ opt->name = "top-edge"; opt->title = "Top edge"; opt->desc = "Paper is pulled partly into adf"; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_adf) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_ADF_OPEN){ opt->name = SANE_NAME_COVER_OPEN; opt->title = SANE_TITLE_COVER_OPEN; opt->desc = SANE_DESC_COVER_OPEN; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_adf) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } if(option==OPT_SLEEP){ opt->name = "power-save"; opt->title = "Power saving"; opt->desc = "Scanner in power saving mode"; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->has_adf) opt->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; else opt->cap = SANE_CAP_INACTIVE; } return opt; } /** * Gets or sets an option value. * * From the SANE spec: * This function is used to set or inquire the current value of option * number n of the device represented by handle h. The manner in which * the option is controlled is specified by parameter action. The * possible values of this parameter are described in more detail * below. The value of the option is passed through argument val. It * is a pointer to the memory that holds the option value. The memory * area pointed to by v must be big enough to hold the entire option * value (determined by member size in the corresponding option * descriptor). * * The only exception to this rule is that when setting the value of a * string option, the string pointed to by argument v may be shorter * since the backend will stop reading the option value upon * encountering the first NUL terminator in the string. If argument i * is not NULL, the value of *i will be set to provide details on how * well the request has been met. */ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { struct scanner *s = (struct scanner *) handle; SANE_Int dummy = 0; /* Make sure that all those statements involving *info cannot break (better * than having to do "if (info) ..." everywhere!) */ if (info == 0) info = &dummy; if (option >= NUM_OPTIONS) { DBG (5, "sane_control_option: %d too big\n", option); return SANE_STATUS_INVAL; } if (!SANE_OPTION_IS_ACTIVE (s->opt[option].cap)) { DBG (5, "sane_control_option: %d inactive\n", option); return SANE_STATUS_INVAL; } /* * SANE_ACTION_GET_VALUE: We have to find out the current setting and * return it in a human-readable form (often, text). */ if (action == SANE_ACTION_GET_VALUE) { SANE_Word * val_p = (SANE_Word *) val; DBG (20, "sane_control_option: get value for '%s' (%d)\n", s->opt[option].name,option); switch (option) { case OPT_NUM_OPTS: *val_p = NUM_OPTIONS; return SANE_STATUS_GOOD; case OPT_SOURCE: if(s->source == SOURCE_FLATBED){ strcpy (val, STRING_FLATBED); } else if(s->source == SOURCE_ADF_FRONT){ strcpy (val, STRING_ADFFRONT); } else if(s->source == SOURCE_ADF_BACK){ strcpy (val, STRING_ADFBACK); } else if(s->source == SOURCE_ADF_DUPLEX){ strcpy (val, STRING_ADFDUPLEX); } else{ DBG(5,"missing option val for source\n"); } return SANE_STATUS_GOOD; case OPT_MODE: if(s->mode == MODE_LINEART){ strcpy (val, STRING_LINEART); } else if(s->mode == MODE_GRAYSCALE){ strcpy (val, STRING_GRAYSCALE); } else if(s->mode == MODE_COLOR){ strcpy (val, STRING_COLOR); } return SANE_STATUS_GOOD; case OPT_RES: *val_p = s->resolution; return SANE_STATUS_GOOD; case OPT_TL_X: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->tl_x); return SANE_STATUS_GOOD; case OPT_TL_Y: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->tl_y); return SANE_STATUS_GOOD; case OPT_BR_X: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->br_x); return SANE_STATUS_GOOD; case OPT_BR_Y: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->br_y); return SANE_STATUS_GOOD; case OPT_PAGE_WIDTH: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->page_width); return SANE_STATUS_GOOD; case OPT_PAGE_HEIGHT: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->page_height); return SANE_STATUS_GOOD; case OPT_BRIGHTNESS: *val_p = s->brightness; return SANE_STATUS_GOOD; case OPT_CONTRAST: *val_p = s->contrast; return SANE_STATUS_GOOD; case OPT_GAMMA: *val_p = SANE_FIX(s->gamma); return SANE_STATUS_GOOD; case OPT_THRESHOLD: *val_p = s->threshold; return SANE_STATUS_GOOD; case OPT_THRESHOLD_CURVE: *val_p = s->threshold_curve; return SANE_STATUS_GOOD; /* Sensor Group */ case OPT_SCAN_SW: get_hardware_status(s); *val_p = s->hw_scan_sw; return SANE_STATUS_GOOD; case OPT_HOPPER: get_hardware_status(s); *val_p = s->hw_hopper; return SANE_STATUS_GOOD; case OPT_TOP: get_hardware_status(s); *val_p = s->hw_top; return SANE_STATUS_GOOD; case OPT_ADF_OPEN: get_hardware_status(s); *val_p = s->hw_adf_open; return SANE_STATUS_GOOD; case OPT_SLEEP: get_hardware_status(s); *val_p = s->hw_sleep; return SANE_STATUS_GOOD; } } 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); if ( s->started ) { DBG (5, "sane_control_option: cant set, device busy\n"); return SANE_STATUS_DEVICE_BUSY; } if (!SANE_OPTION_IS_SETTABLE (s->opt[option].cap)) { DBG (5, "sane_control_option: not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (5, "sane_control_option: bad value\n"); 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 * exactly one of those values because that's what * sanei_constrain_value does. Hence no "else: invalid" branches * below. */ switch (option) { /* Mode Group */ case OPT_SOURCE: if (!strcmp (val, STRING_ADFFRONT)) { tmp = SOURCE_ADF_FRONT; } else if (!strcmp (val, STRING_ADFBACK)) { tmp = SOURCE_ADF_BACK; } else if (!strcmp (val, STRING_ADFDUPLEX)) { tmp = SOURCE_ADF_DUPLEX; } else{ tmp = SOURCE_FLATBED; } if (s->source == tmp) return SANE_STATUS_GOOD; s->source = tmp; *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_MODE: if (!strcmp (val, STRING_LINEART)) { tmp = MODE_LINEART; } else if (!strcmp (val, STRING_GRAYSCALE)) { tmp = MODE_GRAYSCALE; } else{ tmp = MODE_COLOR; } if (tmp == s->mode) return SANE_STATUS_GOOD; s->mode = tmp; *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_RES: if (s->resolution == val_c) return SANE_STATUS_GOOD; s->resolution = val_c; *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; /* Geometry Group */ case OPT_TL_X: if (s->tl_x == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->tl_x = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_TL_Y: if (s->tl_y == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->tl_y = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return change_params(s); case OPT_BR_X: if (s->br_x == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->br_x = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_BR_Y: if (s->br_y == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->br_y = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; case OPT_PAGE_WIDTH: if (s->page_width == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->page_width = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return change_params(s); case OPT_PAGE_HEIGHT: if (s->page_height == FIXED_MM_TO_SCANNER_UNIT(val_c)) return SANE_STATUS_GOOD; s->page_height = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return change_params(s); /* Enhancement Group */ case OPT_BRIGHTNESS: s->brightness = val_c; return SANE_STATUS_GOOD; case OPT_CONTRAST: s->contrast = val_c; return SANE_STATUS_GOOD; case OPT_GAMMA: s->gamma = SANE_UNFIX(val_c); return SANE_STATUS_GOOD; case OPT_THRESHOLD: s->threshold = val_c; return SANE_STATUS_GOOD; case OPT_THRESHOLD_CURVE: s->threshold_curve = val_c; return SANE_STATUS_GOOD; } /* switch */ } /* else */ return SANE_STATUS_INVAL; } /* use height and width to initialize rest of transfer vals */ static void update_transfer_totals(struct transfer * t) { if (t->image == NULL) return; t->total_bytes = t->line_stride * t->image->height; t->rx_bytes = 0; t->done = 0; } /* each model has various settings that differ based on X resolution */ /* 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; int max_x; int min_x; int max_y; int min_y; int line_stride; /* byte width of 1 raw side, with padding */ int plane_stride; /* byte width of 1 raw color plane, with padding */ int plane_width; /* byte width of 1 raw color plane, without padding */ int block_height; int cal_line_stride; int cal_plane_stride; int cal_plane_width; unsigned char * sw_coarsecal; unsigned char * sw_finecal; unsigned char * sw_sendcal; unsigned char * head_cal1; unsigned char * head_cal2; unsigned char * sw_scan; }; static struct model_res settings[] = { /*S300 AC*/ /* 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, 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, 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, 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 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, 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, 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, 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 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, 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, 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, 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 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, 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, 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, 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/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_g }, { 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_400_g }, { 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_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_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 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, 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, 0, NULL, NULL, NULL, NULL, NULL, NULL }, }; /* * clean up scanner struct vals when user changes mode, res, etc */ static SANE_Status change_params(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; int img_heads, img_pages, width; int i=0; DBG (10, "change_params: start\n"); do { 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 ){ break; } i++; } while (settings[i].model); if (!settings[i].model){ return SANE_STATUS_INVAL; } /*1200 dpi*/ s->max_x = PIX_TO_SCANNER_UNIT( settings[i].max_x, settings[i].x_res ); s->min_x = PIX_TO_SCANNER_UNIT( settings[i].min_x, settings[i].x_res ); s->max_y = PIX_TO_SCANNER_UNIT( settings[i].max_y, settings[i].y_res ); s->min_y = PIX_TO_SCANNER_UNIT( settings[i].min_y, settings[i].y_res ); /*current dpi*/ s->setWindowCoarseCal = settings[i].sw_coarsecal; s->setWindowCoarseCalLen = SET_WINDOW_LEN; s->setWindowFineCal = settings[i].sw_finecal; s->setWindowFineCalLen = SET_WINDOW_LEN; s->setWindowSendCal = settings[i].sw_sendcal; s->setWindowSendCalLen = SET_WINDOW_LEN; s->sendCal1Header = settings[i].head_cal1; s->sendCal1HeaderLen = 14; s->sendCal2Header = settings[i].head_cal2; s->sendCal2HeaderLen = 7; s->setWindowScan = settings[i].sw_scan; s->setWindowScanLen = SET_WINDOW_LEN; if (s->model == MODEL_S300 || s->model == MODEL_S1300i) { img_heads = 1; /* image width is the same as the plane width on the S300 */ img_pages = 2; } else if (s->model == MODEL_S1100) { img_heads = 1; /* image width is the same as the plane width on the S1000 */ img_pages = 1; } else /* MODEL_FI60F or MODEL_FI65F */ { img_heads = 3; /* image width is 3* the plane width on the FI-60F */ img_pages = 1; } /* height */ if (s->tl_y > s->max_y - s->min_y) s->tl_y = s->max_y - s->min_y - s->adf_height_padding; if (s->tl_y + s->page_height > s->max_y - s->adf_height_padding) s->page_height = s->max_y - s->adf_height_padding - s->tl_y; if (s->page_height < s->min_y && s->page_height > 0) s->page_height = s->min_y; if (s->tl_y + s->page_height > s->max_y) s->tl_y = s->max_y - s->adf_height_padding - s->page_height; if (s->tl_y < 0) s->tl_y = 0; if (s->page_height > 0) { s->br_y = s->tl_y + s->page_height; } else { s->br_y = s->max_y; } /*width*/ if (s->page_width > s->max_x) s->page_width = s->max_x; else if (s->page_width < s->min_x) s->page_width = s->min_x; s->tl_x = (s->max_x - s->page_width)/2; s->br_x = (s->max_x + s->page_width)/2; /*=============================================================*/ /* 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; s->cal_image.image = NULL; /* width is the same, but there are 2 bytes per pixel component */ 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 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; s->coarsecal.pages = s->darkcal.pages = s->lightcal.pages = img_pages; s->coarsecal.buffer = s->darkcal.buffer = s->lightcal.buffer = NULL; /* set up the calibration data block */ width = s->cal_data.plane_width * img_heads; 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 */ /* 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) { /* flatbed and adf in autodetect always ask for all*/ s->fullscan.height = SCANNER_UNIT_TO_PIX(s->max_y, s->fullscan.y_res); } else { /* adf with specified paper size requires padding on top of page_height (~1/2in) */ 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) { /* flatbed ignores the tly */ s->front.height = SCANNER_UNIT_TO_PIX(s->max_y - s->tl_y, s->front.y_res); } else if(!s->page_height) { /* adf in autodetect always asks for all */ s->front.height = SCANNER_UNIT_TO_PIX(s->max_y, s->front.y_res); } else { /* adf with specified paper size */ s->front.height = SCANNER_UNIT_TO_PIX(s->page_height, s->front.y_res); } s->front.width_pix = s->block_img.width_pix; s->front.x_start_offset = (s->block_xfr.image->width_pix - s->front.width_pix)/2; switch (s->mode) { case MODE_COLOR: s->front.width_bytes = s->front.width_pix*3; s->front.x_offset_bytes = s->front.x_start_offset *3; break; case MODE_GRAYSCALE: s->front.width_bytes = s->front.width_pix; s->front.x_offset_bytes = s->front.x_start_offset; break; default: /*binary*/ s->front.width_bytes = s->front.width_pix/8; s->front.width_pix = s->front.width_bytes * 8; /*s->page_width = PIX_TO_SCANNER_UNIT(s->front.width_pix, (img_heads * s->resolution_x));*/ s->front.x_offset_bytes = s->front.x_start_offset/8; break; } /* ADF front need to remove padding header */ if (s->source != SOURCE_FLATBED) { s->front.y_skip_offset = SCANNER_UNIT_TO_PIX(s->tl_y+s->adf_height_padding, s->fullscan.y_res); } else { s->front.y_skip_offset = SCANNER_UNIT_TO_PIX(s->tl_y, s->fullscan.y_res); } s->front.pages = 1; s->front.buffer = NULL; /* 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; s->back.x_start_offset = s->front.x_start_offset; s->back.x_offset_bytes = s->front.x_offset_bytes; s->back.y_skip_offset = SCANNER_UNIT_TO_PIX(s->tl_y, s->fullscan.y_res); s->back.pages = 1; s->back.buffer = NULL; /* 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; s->dt.pages = 1; s->dt.buffer = NULL; /* set up the pointers to the page images in the page structs */ s->pages[SIDE_FRONT].image = &s->front; s->pages[SIDE_BACK].image = &s->back; s->pages[SIDE_FRONT].done = 0; s->pages[SIDE_BACK].done = 0; DBG (10, "change_params: finish\n"); return ret; } /* Function to build a lookup table (LUT), often used by scanners to implement brightness/contrast/gamma or by backends to speed binarization/thresholding offset and slope inputs are -127 to +127 slope rotates line around central input/output val, 0 makes horizontal line pos zero neg . x . . x . x . . x out . x .xxxxxxxxxxx . x . x . . x ....x....... ............ .......x.... in in in offset moves line vertically, and clamps to output range 0 keeps the line crossing the center of the table high low . xxxxxxxx . . x . out x . x . . x ............ xxxxxxxx.... in in out_min/max provide bounds on output values, useful when building thresholding lut. 0 and 255 are good defaults otherwise. */ static SANE_Status load_lut (unsigned char * lut, int in_bits, int out_bits, int out_min, int out_max, int slope, int offset) { SANE_Status ret = SANE_STATUS_GOOD; int i, j; double shift, rise; int max_in_val = (1 << in_bits) - 1; int max_out_val = (1 << out_bits) - 1; unsigned char * lut_p = lut; DBG (10, "load_lut: start\n"); /* slope is converted to rise per unit run: * first [-127,127] to [-1,1] * then multiply by PI/2 to convert to radians * then take the tangent (T.O.A) * then multiply by the normal linear slope * because the table may not be square, i.e. 1024x256*/ rise = tan((double)slope/127 * M_PI/2) * max_out_val / max_in_val; /* line must stay vertically centered, so figure * out vertical offset at central input value */ shift = (double)max_out_val/2 - (rise*max_in_val/2); /* convert the user offset setting to scale of output * first [-127,127] to [-1,1] * then to [-max_out_val/2,max_out_val/2]*/ shift += (double)offset / 127 * max_out_val / 2; for(i=0;i<=max_in_val;i++){ j = rise*i + shift; if(jout_max){ j=out_max; } *lut_p=j; lut_p++; } hexdump(5, "load_lut: ", lut, max_in_val+1); DBG (10, "load_lut: finish\n"); return ret; } /* * @@ Section 4 - SANE scanning functions */ /* * Called by SANE to retrieve information about the type of data * that the current scan will return. * * From the SANE spec: * This function is used to obtain the current scan parameters. The * returned parameters are guaranteed to be accurate between the time * a scan has been started (sane_start() has been called) and the * completion of that request. Outside of that window, the returned * values are best-effort estimates of what the parameters will be * when sane_start() gets invoked. * * Calling this function before a scan has actually started allows, * for example, to get an estimate of how big the scanned image will * be. The parameters passed to this function are the handle h of the * device for which the parameters should be obtained and a pointer p * to a parameter structure. */ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { struct scanner *s = (struct scanner *) handle; DBG (10, "sane_get_parameters: start\n"); params->pixels_per_line = s->front.width_pix; params->bytes_per_line = s->front.width_bytes; if(!s->page_height){ params->lines = -1; } else{ params->lines = s->front.height; } params->last_frame = 1; if (s->mode == MODE_COLOR) { params->format = SANE_FRAME_RGB; params->depth = 8; } else if (s->mode == MODE_GRAYSCALE) { params->format = SANE_FRAME_GRAY; params->depth = 8; } else if (s->mode == MODE_LINEART) { params->format = SANE_FRAME_GRAY; params->depth = 1; } DBG (15, "\tdepth %d\n", params->depth); DBG (15, "\tlines %d\n", params->lines); DBG (15, "\tpixels_per_line %d\n", params->pixels_per_line); DBG (15, "\tbytes_per_line %d\n", params->bytes_per_line); DBG (10, "sane_get_parameters: finish\n"); return SANE_STATUS_GOOD; } /* * Called by SANE when a page acquisition operation is to be started. * FIXME: wont handle SOURCE_ADF_BACK */ SANE_Status sane_start (SANE_Handle handle) { struct scanner *s = handle; SANE_Status ret; int i; DBG (10, "sane_start: start\n"); /* set side marker on first page */ if(!s->started){ if(s->source == SOURCE_ADF_BACK){ s->side = SIDE_BACK; } else{ s->side = SIDE_FRONT; } } /* if already running, duplex needs to switch sides */ else if(s->source == SOURCE_ADF_DUPLEX){ s->side = !s->side; } /* recent scanners need ghs called before scanning */ ret = get_hardware_status(s); /* ingest paper with adf */ if( s->source == SOURCE_ADF_BACK || s->source == SOURCE_ADF_FRONT || (s->source == SOURCE_ADF_DUPLEX && s->side == SIDE_FRONT) ){ ret = object_position(s,EPJITSU_PAPER_INGEST); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to ingest\n"); sane_cancel((SANE_Handle)s); return ret; } } /* first page requires buffers, etc */ if(!s->started){ DBG(15,"sane_start: first page\n"); s->started=1; ret = teardown_buffers(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to teardown buffers\n"); sane_cancel((SANE_Handle)s); return SANE_STATUS_NO_MEM; } ret = change_params(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to change_params\n"); sane_cancel((SANE_Handle)s); return SANE_STATUS_NO_MEM; } ret = setup_buffers(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to setup buffers\n"); sane_cancel((SANE_Handle)s); return SANE_STATUS_NO_MEM; } ret = load_lut(s->dt_lut, 8, 8, 50, 205, s->threshold_curve, s->threshold-127); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to load_lut for dt\n"); sane_cancel((SANE_Handle)s); return ret; } ret = coarsecal(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to coarsecal\n"); sane_cancel((SANE_Handle)s); return ret; } ret = finecal(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to finecal\n"); sane_cancel((SANE_Handle)s); return ret; } ret = send_lut(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to send lut\n"); sane_cancel((SANE_Handle)s); return ret; } ret = lamp(s,1); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to heat lamp\n"); sane_cancel((SANE_Handle)s); return ret; } /*should this be between each page*/ ret = set_window(s,WINDOW_SCAN); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to set window\n"); sane_cancel((SANE_Handle)s); return ret; } } /* reset everything when starting any front, or just back */ if(s->side == SIDE_FRONT || s->source == SOURCE_ADF_BACK){ DBG(15,"sane_start: reset counters\n"); /* reset scan */ s->fullscan.done = 0; s->fullscan.rx_bytes = 0; s->fullscan.total_bytes = s->fullscan.width_bytes * s->fullscan.height; /* reset block */ update_transfer_totals(&s->block_xfr); /* reset front and back page counters */ for (i = 0; i < 2; i++) { struct image *page_img = s->pages[i].image; s->pages[i].bytes_total = page_img->width_bytes * page_img->height; s->pages[i].bytes_scanned = 0; s->pages[i].bytes_read = 0; s->pages[i].lines_rx = 0; s->pages[i].lines_pass = 0; s->pages[i].lines_tx = 0; s->pages[i].done = 0; } ret = scan(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: failed to start scan\n"); sane_cancel((SANE_Handle)s); return ret; } } else{ DBG(15,"sane_start: back side\n"); } DBG (10, "sane_start: finish\n"); return SANE_STATUS_GOOD; } /* the +8 on all the lengths is to makeup for potential block trailers */ static SANE_Status setup_buffers(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; DBG (10, "setup_buffers: start\n"); /* temporary cal data */ s->coarsecal.buffer = calloc (1,s->coarsecal.width_bytes * s->coarsecal.height * s->coarsecal.pages); if(!s->coarsecal.buffer){ DBG (5, "setup_buffers: ERROR: failed to setup coarse cal buffer\n"); return SANE_STATUS_NO_MEM; } s->darkcal.buffer = calloc (1,s->darkcal.width_bytes * s->darkcal.height * s->darkcal.pages); if(!s->darkcal.buffer){ DBG (5, "setup_buffers: ERROR: failed to setup fine cal buffer\n"); return SANE_STATUS_NO_MEM; } s->lightcal.buffer = calloc (1,s->lightcal.width_bytes * s->lightcal.height * s->lightcal.pages); if(!s->lightcal.buffer){ DBG (5, "setup_buffers: ERROR: failed to setup fine cal buffer\n"); return SANE_STATUS_NO_MEM; } s->sendcal.buffer = calloc (1,s->sendcal.width_bytes * s->sendcal.height * s->sendcal.pages); if(!s->sendcal.buffer){ DBG (5, "setup_buffers: ERROR: failed to setup send cal buffer\n"); return SANE_STATUS_NO_MEM; } s->cal_image.raw_data = calloc(1, s->cal_image.line_stride * 16 + 8); /* maximum 16 lines input for fine calibration */ if(!s->cal_image.raw_data){ DBG (5, "setup_buffers: ERROR: failed to setup calibration input raw data buffer\n"); return SANE_STATUS_NO_MEM; } s->cal_data.raw_data = calloc(1, s->cal_data.line_stride); /* only 1 line of data is sent */ if(!s->cal_data.raw_data){ DBG (5, "setup_buffers: ERROR: failed to setup calibration output raw data buffer\n"); return SANE_STATUS_NO_MEM; } /* grab up to 512K at a time */ s->block_img.buffer = calloc (1,s->block_img.width_bytes * s->block_img.height * s->block_img.pages); if(!s->block_img.buffer){ DBG (5, "setup_buffers: ERROR: failed to setup block image buffer\n"); return SANE_STATUS_NO_MEM; } s->block_xfr.raw_data = calloc(1, s->block_xfr.line_stride * s->block_img.height + 8); if(!s->block_xfr.raw_data){ DBG (5, "setup_buffers: ERROR: failed to setup block raw data buffer\n"); return SANE_STATUS_NO_MEM; } /* one grayscale line for dynamic threshold */ s->dt.buffer = calloc (1,s->dt.width_bytes * s->dt.height * s->dt.pages); if(!s->dt.buffer){ DBG (5, "setup_buffers: ERROR: failed to setup dt buffer\n"); return SANE_STATUS_NO_MEM; } /* make image buffer to hold frontside data */ if(s->source != SOURCE_ADF_BACK){ s->front.buffer = calloc (1,s->front.width_bytes * s->front.height * s->front.pages); if(!s->front.buffer){ DBG (5, "setup_buffers: ERROR: failed to setup front buffer\n"); return SANE_STATUS_NO_MEM; } } /* make image buffer to hold backside data */ if(s->source == SOURCE_ADF_DUPLEX || s->source == SOURCE_ADF_BACK){ s->back.buffer = calloc (1,s->back.width_bytes * s->back.height * s->back.pages); if(!s->back.buffer){ DBG (5, "setup_buffers: ERROR: failed to setup back buffer\n"); return SANE_STATUS_NO_MEM; } } DBG (10, "setup_buffers: finish\n"); return ret; } /* coarse calibration consists of: 1. turn lamp off (d0) 2. set window for single line of data (d1) 3. get line (d2) 4. update dark coarse cal (c6) 5. return to #3 if not dark enough 6. turn lamp on (d0) 7. get line (d2) 8. update light coarse cal (c6) 9. return to #7 if not light enough */ static SANE_Status coarsecal_send_cal(struct scanner *s, unsigned char *pay) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[2]; unsigned char stat[1]; size_t cmdLen,statLen,payLen; DBG (5, "coarsecal_send_cal: start\n"); /* send coarse cal (c6) */ cmd[0] = 0x1b; cmd[1] = 0xc6; cmdLen = 2; stat[0] = 0; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "coarsecal_send_cal: error sending c6 cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "coarsecal_send_cal: cmd bad c6 status?\n"); return SANE_STATUS_IO_ERROR; } /*send coarse cal payload*/ stat[0] = 0; statLen = 1; payLen = 28; ret = do_cmd( s, 0, pay, payLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "coarsecal_send_cal: error sending c6 payload\n"); return ret; } if(stat[0] != 6){ DBG (5, "coarsecal_send_cal: c6 payload bad status?\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "coarsecal_send_cal: finish\n"); return ret; } static SANE_Status coarsecal_get_line(struct scanner *s, struct image *img) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[2]; unsigned char stat[1]; size_t cmdLen,statLen; DBG (5, "coarsecal_get_line: start\n"); /* send scan d2 command */ cmd[0] = 0x1b; cmd[1] = 0xd2; cmdLen = 2; stat[0] = 0; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "coarsecal_get_line: error sending d2 cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "coarsecal_get_line: cmd bad d2 status?\n"); return SANE_STATUS_IO_ERROR; } s->cal_image.image = img; update_transfer_totals(&s->cal_image); while(!s->cal_image.done){ ret = read_from_scanner(s,&s->cal_image); if(ret){ DBG (5, "coarsecal_get_line: cant read from scanner\n"); return ret; } } /* convert the raw data into normal packed pixel data */ descramble_raw(s, &s->cal_image); DBG (5, "coarsecal_get_line: finish\n"); return ret; } static SANE_Status coarsecal_dark(struct scanner *s, unsigned char *pay) { SANE_Status ret = SANE_STATUS_GOOD; int try_count, cal_good[2], x, j; int param[2], zcount[2], high_param[2], low_param[2], avg[2], maxval[2]; DBG (5, "coarsecal_dark: start\n"); /* dark cal, lamp off */ ret = lamp(s,0); if(ret){ DBG (5, "coarsecal_dark: error lamp off\n"); return ret; } try_count = 8; param[0] = 63; param[1] = 63; low_param[0] = low_param[1] = -64; /* The S300 will accept coarse offsets from -128 to 127 */ high_param[0] = high_param[1] = 63; /* By our range is limited to converge faster */ cal_good[0] = cal_good[1] = 0; while (try_count > 0){ try_count--; /* update the coarsecal payload to use our new dark offset parameters */ if (s->model == MODEL_S300 || s->model == MODEL_S1300i) { pay[5] = param[0]; pay[7] = param[1]; } else /* MODEL_S1100 or MODEL_FI60F or MODEL_FI65F */ { pay[5] = param[0]; pay[7] = param[0]; pay[9] = param[0]; } ret = coarsecal_send_cal(s, pay); DBG(15, "coarsecal_dark offset: parameter front: %i back: %i\n", param[0], param[1]); ret = coarsecal_get_line(s, &s->coarsecal); /* gather statistics: count the proportion of 0-valued pixels */ /* since the lamp is off, there's no point in looking at the green or blue data - they're all from the same sensor anyway */ zcount[0] = zcount[1] = 0; avg[0] = avg[1] = 0; maxval[0] = maxval[1] = 0; for (j = 0; j < s->coarsecal.pages; j++) { int page_offset = j * s->coarsecal.width_bytes * s->coarsecal.height; for (x = 0; x < s->coarsecal.width_bytes; x++) { int val = s->coarsecal.buffer[page_offset + x]; avg[j] += val; if (val == 0) zcount[j]++; if (val > maxval[j]) maxval[j] = val; } } /* convert the zero counts from a pixel count to a proportion in tenths of a percent */ for (j = 0; j < s->coarsecal.pages; j++) { avg[j] /= s->coarsecal.width_bytes; zcount[j] = zcount[j] * 1000 / s->coarsecal.width_bytes; } DBG(15, "coarsecal_dark offset: average pixel values front: %i back: %i\n", avg[0], avg[1]); DBG(15, "coarsecal_dark offset: maximum pixel values front: %i back: %i\n", maxval[0], maxval[1]); DBG(15, "coarsecal_dark offset: 0-valued pixel count front: %f%% back: %f%%\n", zcount[0] / 10.0f, zcount[1] / 10.0f); /* check the values, adjust parameters if they are not within the target range */ for (j = 0; j < s->coarsecal.pages; j++) { if (!cal_good[j]) { if (avg[j] > COARSE_OFFSET_TARGET) { high_param[j] = param[j]; param[j] = (low_param[j] + high_param[j]) / 2; } else if (avg[j] < COARSE_OFFSET_TARGET) { low_param[j] = param[j]; param[j] = (low_param[j] + high_param[j]) / 2; } else cal_good[j] = 1; } } if (cal_good[0] + cal_good[1] == s->coarsecal.pages) break; } /* continue looping for up to 8 tries */ DBG (5, "coarsecal_dark: finish\n"); return ret; } static SANE_Status coarsecal_light(struct scanner *s, unsigned char *pay) { SANE_Status ret = SANE_STATUS_GOOD; int try_count, cal_good[2], x, i, j; int param[2], zcount[2], high_param[2], low_param[2], avg[2]; int rgb_avg[2][3], rgb_hicount[2][3]; DBG (5, "coarsecal_light: start\n"); /* light cal, lamp on */ ret = lamp(s,1); if(ret){ DBG (5, "coarsecal_light: error lamp on\n"); return ret; } try_count = 8; param[0] = pay[11]; param[1] = pay[13]; low_param[0] = low_param[1] = 0; high_param[0] = high_param[1] = 63; cal_good[0] = cal_good[1] = 0; while (try_count > 0){ try_count--; ret = coarsecal_send_cal(s, pay); DBG(15, "coarsecal_light gain: parameter front: %i back: %i\n", param[0], param[1]); ret = coarsecal_get_line(s, &s->coarsecal); /* gather statistics: count the proportion of 255-valued pixels in each color channel */ /* count the average pixel value in each color channel */ for (i = 0; i < s->coarsecal.pages; i++) for (j = 0; j < 3; j++) rgb_avg[i][j] = rgb_hicount[i][j] = 0; for (i = 0; i < s->coarsecal.pages; i++) { for (x = 0; x < s->coarsecal.width_pix; x++) { /* get color channel values and count of pixels pegged at 255 */ unsigned char *rgbpix = s->coarsecal.buffer + (i * s->coarsecal.width_bytes * s->coarsecal.height) + x * 3; for (j = 0; j < 3; j++) { rgb_avg[i][j] += rgbpix[j]; if (rgbpix[j] == 255) rgb_hicount[i][j]++; } } } /* apply the color correction factors to the averages */ for (i = 0; i < s->coarsecal.pages; i++) for (j = 0; j < 3; j++) rgb_avg[i][j] *= s->white_factor[j]; /* set the gain so that none of the color channels are clipping, ie take the highest channel values */ for (i = 0; i < s->coarsecal.pages; i++) { avg[i] = MAX3(rgb_avg[i][0], rgb_avg[i][1], rgb_avg[i][2]) / s->coarsecal.width_pix; for (j = 0; j < 3; j++) rgb_avg[i][j] /= s->coarsecal.width_pix; } /* convert the 255-counts from a pixel count to a proportion in tenths of a percent */ for (i = 0; i < s->coarsecal.pages; i++) { for (j = 0; j < 3; j++) { rgb_hicount[i][j] = rgb_hicount[i][j] * 1000 / s->coarsecal.width_pix; } zcount[i] = MAX3(rgb_hicount[i][0], rgb_hicount[i][1], rgb_hicount[i][2]); } DBG(15, "coarsecal_light gain: average RGB values front: (%i,%i,%i) back: (%i,%i,%i)\n", rgb_avg[0][0], rgb_avg[0][1], rgb_avg[0][2], rgb_avg[1][0], rgb_avg[1][1], rgb_avg[1][2]); DBG(15, "coarsecal_light gain: 255-valued pixel count front: (%g,%g,%g) back: (%g,%g,%g)\n", rgb_hicount[0][0]/10.0f, rgb_hicount[0][1]/10.0f, rgb_hicount[0][2]/10.0f, rgb_hicount[1][0]/10.0f, rgb_hicount[1][1]/10.0f, rgb_hicount[1][2]/10.0f); /* check the values, adjust parameters if they are not within the target range */ for (x = 0; x < s->coarsecal.pages; x++) { if (!cal_good[x]) { if (zcount[x] > 9 || avg[x] > coarse_gain_max[x]) { high_param[x] = param[x]; param[x] = (low_param[x] + high_param[x]) / 2; } else if (avg[x] < coarse_gain_min[x]) { low_param[x] = param[x]; param[x] = (low_param[x] + high_param[x]) / 2; } else cal_good[x] = 1; } } if (cal_good[0] + cal_good[1] == s->coarsecal.pages) break; /* update the coarsecal payload to use the new gain parameters */ if (s->model == MODEL_S300 || s->model == MODEL_S1300i) { pay[11] = param[0]; pay[13] = param[1]; } else /* MODEL_S1100 or MODEL_FI60F or MODEL_FI65F */ { pay[11] = param[0]; pay[13] = param[0]; pay[15] = param[0]; } } DBG (5, "coarsecal_light: finish\n"); return ret; } static SANE_Status coarsecal(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char pay[28]; size_t payLen; DBG (10, "coarsecal: start\n"); payLen = sizeof(pay); if(s->model == MODEL_S300){ memcpy(pay,coarseCalData_S300,payLen); } else if(s->model == MODEL_S1300i){ memcpy(pay,coarseCalData_S1300i,payLen); } else if(s->model == MODEL_S1100){ memcpy(pay,coarseCalData_S1100,payLen); } else{ memcpy(pay,coarseCalData_FI60F,payLen); } /* ask for 1 line */ ret = set_window(s, WINDOW_COARSECAL); if(ret){ DBG (5, "coarsecal: error sending setwindow\n"); return ret; } if(s->model == MODEL_S1100){ ret = coarsecal_send_cal(s, pay); } else{ ret = coarsecal_dark(s, pay); ret = coarsecal_light(s, pay); } DBG (10, "coarsecal: finish\n"); return ret; } static SANE_Status finecal_send_cal(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; size_t cmdLen = 2; unsigned char cmd[2]; size_t statLen = 1; unsigned char stat[2]; int i, j, k; unsigned char *p_out, *p_in = s->sendcal.buffer; int planes; if(s->model == MODEL_FI60F || s->model == MODEL_FI65F) planes = 3; if(s->model == MODEL_S300 || s->model == MODEL_S1300i) planes = 2; /* scramble the raster buffer data into scanner raw format */ /* this is reverse of descramble_raw */ memset(s->cal_data.raw_data, 0, s->cal_data.line_stride); if(s->model == MODEL_S1100){ planes = 1; for (k = 0; k < s->sendcal.width_pix; k++){ /* column (x) */ /* input is RrGgBb (capital is offset, small is gain) */ /* output is Bb...BbRr...RrGg...Gg*/ /*red*/ p_out = s->cal_data.raw_data + s->cal_data.plane_stride + k*2; *p_out = *p_in; p_out++; p_in++; *p_out = *p_in; p_in++; /*green*/ p_out = s->cal_data.raw_data + 2*s->cal_data.plane_stride + k*2; *p_out = *p_in; p_out++; p_in++; *p_out = *p_in; p_in++; /*blue*/ p_out = s->cal_data.raw_data + k*2; *p_out = *p_in; p_out++; p_in++; *p_out = *p_in; p_in++; } } else{ for (i = 0; i < planes; i++) for (j = 0; j < s->cal_data.plane_width; j++) for (k = 0; k < 3; k++) { p_out = (s->cal_data.raw_data + k * s->cal_data.plane_stride + j * 6 + i * 2); *p_out = *p_in++; /* dark offset */ p_out++; *p_out = *p_in++; /* gain */ } } ret = set_window(s, WINDOW_SENDCAL); if(ret){ DBG (5, "finecal_send_cal: error sending setwindow\n"); return ret; } /*first unknown cal block*/ cmd[0] = 0x1b; cmd[1] = 0xc3; stat[0] = 0; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "finecal_send_cal: error sending c3 cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "finecal_send_cal: cmd bad c3 status?\n"); return SANE_STATUS_IO_ERROR; } /*send header*/ /*send payload*/ statLen = 1; ret = do_cmd( s, 0, s->sendCal1Header, s->sendCal1HeaderLen, s->cal_data.raw_data, s->cal_data.line_stride, stat, &statLen ); if(ret){ DBG (5, "finecal_send_cal: error sending c3 payload\n"); return ret; } if(stat[0] != 6){ DBG (5, "finecal_send_cal: payload bad c3 status?\n"); return SANE_STATUS_IO_ERROR; } /*second unknown cal block*/ cmd[1] = 0xc4; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "finecal_send_cal: error sending c4 cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "finecal_send_cal: cmd bad c4 status?\n"); return SANE_STATUS_IO_ERROR; } /*send header*/ /*send payload*/ statLen = 1; ret = do_cmd( s, 0, s->sendCal2Header, s->sendCal2HeaderLen, s->cal_data.raw_data, s->cal_data.line_stride, stat, &statLen ); if(ret){ DBG (5, "finecal_send_cal: error sending c4 payload\n"); return ret; } if(stat[0] != 6){ DBG (5, "finecal_send_cal: payload bad c4 status?\n"); return SANE_STATUS_IO_ERROR; } return ret; } static SANE_Status finecal_get_line(struct scanner *s, struct image *img) { SANE_Status ret = SANE_STATUS_GOOD; size_t cmdLen = 2; unsigned char cmd[2]; size_t statLen = 1; unsigned char stat[2]; int round_offset = img->height / 2; int i, j, k; /* ask for 16 lines */ ret = set_window(s, WINDOW_FINECAL); if(ret){ DBG (5, "finecal_get_line: error sending setwindowcal\n"); return ret; } /* send scan d2 command */ cmd[0] = 0x1b; cmd[1] = 0xd2; stat[0] = 0; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "finecal_get_line: error sending d2 cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "finecal_get_line: cmd bad d2 status?\n"); return SANE_STATUS_IO_ERROR; } s->cal_image.image = img; update_transfer_totals(&s->cal_image); while(!s->cal_image.done){ ret = read_from_scanner(s,&s->cal_image); if(ret){ DBG (5, "finecal_get_line: cant read from scanner\n"); return ret; } } /* convert the raw data into normal packed pixel data */ descramble_raw(s, &s->cal_image); /* average the columns of pixels together and put the results in the top line(s) */ for (i = 0; i < img->pages; i++) { unsigned char *linepix = img->buffer + i * img->width_bytes * img->height; unsigned char *avgpix = img->buffer + i * img->width_bytes; for (j = 0; j < img->width_bytes; j++) { int total = 0; for (k = 0; k < img->height; k++) total += linepix[j + k * img->width_bytes]; avgpix[j] = (total + round_offset) / img->height; } } return ret; } /* roundf() is c99, so we provide our own, though this version wont return -0 */ static float round2(float x) { return (float)(x >= 0.0) ? (int)(x+0.5) : (int)(x-0.5); } static SANE_Status finecal(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; int max_pages; int gain_delta = 0xff - 0xbf; float *gain_slope, *last_error; int i, j, k, idx, try_count, cal_good; DBG (10, "finecal: start\n"); if (s->model == MODEL_S300 || s->model == MODEL_S1300i) { /* S300, S1300 */ max_pages = 2; } else /* fi-60f, S1100 */ { max_pages = 1; } /* set fine dark offset to 0 and fix all fine gains to lowest parameter (0xFF) */ for (i = 0; i < s->sendcal.width_bytes * s->sendcal.pages / 2; i++) { s->sendcal.buffer[i*2] = 0; s->sendcal.buffer[i*2+1] = 0xff; } ret = finecal_send_cal(s); if(ret) return ret; /* grab rows with lamp on */ ret = lamp(s,1); if(ret){ DBG (5, "finecal: error lamp on\n"); return ret; } /* read the low-gain average of 16 lines */ ret = finecal_get_line(s, &s->darkcal); if(ret) return ret; /* set fine dark offset to 0 and fine gain to a fixed higher-gain parameter (0xBF) */ for (i = 0; i < s->sendcal.width_bytes * s->sendcal.pages / 2; i++) { s->sendcal.buffer[i*2] = 0; s->sendcal.buffer[i*2+1] = 0xbf; } ret = finecal_send_cal(s); if(ret) return ret; /* read the high-gain average of 16 lines */ ret = finecal_get_line(s, &s->lightcal); if(ret) return ret; /* calculate the per pixel slope of pixel value delta over gain delta */ gain_slope = malloc(s->lightcal.width_bytes * s->lightcal.pages * sizeof(float)); if (!gain_slope) return SANE_STATUS_NO_MEM; idx = 0; for (i = 0; i < s->lightcal.pages; i++) { for (j = 0; j < s->lightcal.width_pix; j++) { for (k = 0; k < 3; k++) { int value_delta = s->lightcal.buffer[idx] - s->darkcal.buffer[idx]; /* limit this slope to 1 or less, to avoid overshoot if the lightcal ref input is clipped at 255 */ if (value_delta < gain_delta) gain_slope[idx] = -1.0; else gain_slope[idx] = (float) -gain_delta / value_delta; idx++; } } } /* keep track of the last iteration's pixel error. If we overshoot, we can reduce the value of the gain slope */ last_error = malloc(s->lightcal.width_bytes * s->lightcal.pages * sizeof(float)); if (!last_error) { free(gain_slope); return SANE_STATUS_NO_MEM; } for (i = 0; i < s->lightcal.width_bytes * s->lightcal.pages; i++) last_error[i] = 0.0; /* fine calibration feedback loop */ try_count = 8; while (try_count > 0) { int min_value[2][3], max_value[2][3]; float avg_value[2][3], variance[2][3]; int high_pegs = 0, low_pegs = 0; try_count--; /* clear statistics arrays */ for (i = 0; i < max_pages; i++) { for (k = 0; k < 3; k++) { min_value[i][k] = 0xff; max_value[i][k] = 0; avg_value[i][k] = 0; variance[i][k] = 0; } } /* gather statistics and calculate new fine gain parameters based on observed error and the value/gain slope */ idx = 0; for (i = 0; i < max_pages; i++) { for (j = 0; j < s->lightcal.width_pix; j++) { for (k = 0; k < 3; k++) { int pixvalue = s->lightcal.buffer[idx]; float pixerror = (fine_gain_target[i] * s->white_factor[k] - pixvalue); int oldgain = s->sendcal.buffer[idx * 2 + 1]; int newgain; /* if we overshot the last correction, reduce the gain_slope */ if (pixerror * last_error[idx] < 0.0) gain_slope[idx] *= 0.75; last_error[idx] = pixerror; /* set the new gain */ newgain = oldgain + (int) round2(pixerror * gain_slope[idx]); if (newgain < 0) { low_pegs++; s->sendcal.buffer[idx * 2 + 1] = 0; } else if (newgain > 0xff) { high_pegs++; s->sendcal.buffer[idx * 2 + 1] = 0xff; } else s->sendcal.buffer[idx * 2 + 1] = newgain; /* update statistics */ if (pixvalue < min_value[i][k]) min_value[i][k] = pixvalue; if (pixvalue > max_value[i][k]) max_value[i][k] = pixvalue; avg_value[i][k] += pixerror; variance[i][k] += (pixerror * pixerror); idx++; } } } /* finish the statistics calculations */ cal_good = 1; for (i = 0; i < max_pages; i++) { for (k = 0; k < 3; k++) { float sum = avg_value[i][k]; float sum2 = variance[i][k]; avg_value[i][k] = sum / s->lightcal.width_pix; variance[i][k] = ((sum2 - (sum * sum / s->lightcal.width_pix)) / s->lightcal.width_pix); /* if any color channel is too far out of whack, set cal_good to 0 so we'll iterate again */ if (fabs(avg_value[i][k]) > 1.0 || variance[i][k] > 3.0) cal_good = 0; } } /* print debug info */ DBG (15, "finecal: -------------------- Gain\n"); DBG (15, "finecal: RGB Average Error - Front: (%.1f,%.1f,%.1f) - Back: (%.1f,%.1f,%.1f)\n", avg_value[0][0], avg_value[0][1], avg_value[0][2], avg_value[1][0], avg_value[1][1], avg_value[1][2]); DBG (15, "finecal: RGB Maximum - Front: (%i,%i,%i) - Back: (%i,%i,%i)\n", max_value[0][0], max_value[0][1], max_value[0][2], max_value[1][0], max_value[1][1], max_value[1][2]); DBG (15, "finecal: RGB Minimum - Front: (%i,%i,%i) - Back: (%i,%i,%i)\n", min_value[0][0], min_value[0][1], min_value[0][2], min_value[1][0], min_value[1][1], min_value[1][2]); DBG (15, "finecal: Variance - Front: (%.1f,%.1f,%.1f) - Back: (%.1f,%.1f,%.1f)\n", variance[0][0], variance[0][1], variance[0][2], variance[1][0], variance[1][1], variance[1][2]); DBG (15, "finecal: Pegged gain parameters - High (0xff): %i - Low (0): %i\n", high_pegs, low_pegs); /* break out of the loop if our calibration is done */ if (cal_good) break; /* send the new calibration and read a new line */ ret = finecal_send_cal(s); if(ret) { free(gain_slope); free(last_error); return ret; } ret = finecal_get_line(s, &s->lightcal); if(ret) { free(gain_slope); free(last_error); return ret; } } /* release the memory for the reference slope data */ free(gain_slope); free(last_error); DBG (10, "finecal: finish\n"); return ret; } /* * set scanner lamp brightness */ static SANE_Status lamp(struct scanner *s, unsigned char set) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[2]; size_t cmdLen = 2; unsigned char stat[1]; size_t statLen = 1; DBG (10, "lamp: start (%d)\n", set); /*send cmd*/ cmd[0] = 0x1b; cmd[1] = 0xd0; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "lamp: error sending cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "lamp: cmd bad status?\n"); return SANE_STATUS_IO_ERROR; } /*send payload*/ cmd[0] = set; cmdLen = 1; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "lamp: error sending payload\n"); return ret; } if(stat[0] != 6){ DBG (5, "lamp: payload bad status?\n"); return SANE_STATUS_IO_ERROR; } DBG (10, "lamp: finish\n"); return ret; } static SANE_Status set_window(struct scanner *s, int window) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[] = {0x1b, 0xd1}; size_t cmdLen = sizeof(cmd); unsigned char stat[] = {0}; size_t statLen = sizeof(stat); unsigned char * payload; size_t paylen = SET_WINDOW_LEN; DBG (10, "set_window: start, window %d\n",window); switch (window) { case WINDOW_COARSECAL: payload = s->setWindowCoarseCal; paylen = s->setWindowCoarseCalLen; break; case WINDOW_FINECAL: payload = s->setWindowFineCal; paylen = s->setWindowFineCalLen; break; case WINDOW_SENDCAL: payload = s->setWindowSendCal; paylen = s->setWindowSendCalLen; break; case WINDOW_SCAN: payload = s->setWindowScan; paylen = s->setWindowScanLen; set_SW_ypix(payload,s->fullscan.height); break; default: DBG (5, "set_window: unknown window\n"); return SANE_STATUS_INVAL; } /*send cmd*/ ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "set_window: error sending cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "set_window: cmd bad status?\n"); return SANE_STATUS_IO_ERROR; } /*send payload*/ statLen = 1; ret = do_cmd( s, 0, payload, paylen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "set_window: error sending payload\n"); return ret; } if(stat[0] != 6){ DBG (5, "set_window: payload bad status?\n"); return SANE_STATUS_IO_ERROR; } DBG (10, "set_window: finish\n"); return ret; } /* instead of internal brightness/contrast/gamma scanners uses 12bit x 12bit LUT default is linear table of slope 1 brightness and contrast inputs are -127 to +127 contrast rotates slope of line around central input val high low . x . . x . xx out . x . xxxxxxxx . x xx ....x....... ............ in in then brightness moves line vertically, and clamps to 8bit bright dark . xxxxxxxx . . x . out x . x . . x ............ xxxxxxxx.... in in */ static SANE_Status send_lut (struct scanner *s) { SANE_Status ret=SANE_STATUS_GOOD; unsigned char cmd[] = {0x1b, 0xc5}; size_t cmdLen = 2; unsigned char stat[1]; size_t statLen = 1; unsigned char *out; size_t outLen; int i, j; double b, slope, offset; int width; int height; DBG (10, "send_lut: start\n"); if (s->model == MODEL_S1100){ outLen = 0x200; width = outLen / 2; /* 1 color, 2 bytes */ height = width; /* square table */ } else if (s->model == MODEL_FI65F){ outLen = 0x600; width = outLen / 6; /* 3 color, 2 bytes */ height = width; /* square table */ } else { outLen = 0x6000; width = outLen / 6; /* 3 colors, 2 bytes */ height = width; /* square table */ } out = ( unsigned char *)malloc(outLen*sizeof(unsigned char)); if (out == NULL){ return SANE_STATUS_NO_MEM; } /* contrast is converted to a slope [0,90] degrees: * first [-127,127] to [0,254] then to [0,1] * then multiply by PI/2 to convert to radians * then take the tangent to get slope (T.O.A) * then multiply by the normal linear slope * because the table may not be square, i.e. 1024x256*/ slope = tan(((double)s->contrast+127)/254 * M_PI/2); /* contrast slope must stay centered, so figure * out vertical offset at central input value */ offset = height/2 - slope*width/2; /* convert the user brightness setting (-127 to +127) * into a scale that covers the range required * to slide the contrast curve entirely off the table */ b = ((double)s->brightness/127) * (slope*(width-1) + offset); DBG (15, "send_lut: %d %f %d %f %f\n", s->brightness, b, s->contrast, slope, offset); for(i=0;i(height-1)){ j=height-1; } if (s->model == MODEL_S1100){ /*only one table, be order*/ out[i*2] = (j >> 8) & 0xff; out[i*2+1] = j & 0xff; } else if (s->model == MODEL_FI65F){ /*first table, be order*/ out[i*2] = (j >> 8) & 0xff; out[i*2+1] = j & 0xff; /*second table, be order*/ out[width*2 + i*2] = (j >> 8) & 0xff; out[width*2 + i*2+1] = j & 0xff; /*third table, be order*/ out[width*4 + i*2] = (j >> 8) & 0xff; out[width*4 + i*2+1] = j & 0xff; } else { /*first table, le order*/ out[i*2] = j & 0xff; out[i*2+1] = (j >> 8) & 0x0f; /*second table, le order*/ out[width*2 + i*2] = j & 0xff; out[width*2 + i*2+1] = (j >> 8) & 0x0f; /*third table, le order*/ out[width*4 + i*2] = j & 0xff; out[width*4 + i*2+1] = (j >> 8) & 0x0f; } } ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "send_lut: error sending cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "send_lut: cmd bad status?\n"); return SANE_STATUS_IO_ERROR; } statLen = 1; ret = do_cmd( s, 0, out, outLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "send_lut: error sending out\n"); return ret; } if(stat[0] != 6){ DBG (5, "send_lut: out bad status?\n"); return SANE_STATUS_IO_ERROR; } DBG (10, "send_lut: finish\n"); return ret; } static SANE_Status get_hardware_status (struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; DBG (10, "get_hardware_status: start\n"); /* only run this once every second */ if (s->last_ghs < time(NULL)) { unsigned char cmd[2]; size_t cmdLen = sizeof(cmd); unsigned char pay[4]; size_t payLen = sizeof(pay); DBG (15, "get_hardware_status: running\n"); cmd[0] = 0x1b; cmd[1] = 0x33; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, pay, &payLen ); if(ret){ DBG (5, "get_hardware_status: error sending cmd\n"); return ret; } hexdump(5,"ghspayload: ", pay, payLen); s->last_ghs = time(NULL); s->hw_top = ((pay[0] >> 7) & 0x01); s->hw_hopper = !((pay[0] >> 6) & 0x01); s->hw_adf_open = ((pay[0] >> 5) & 0x01); s->hw_sleep = ((pay[1] >> 7) & 0x01); s->hw_scan_sw = ((pay[1] >> 0) & 0x01); } DBG (10, "get_hardware_status: finish\n"); return ret; } static SANE_Status object_position(struct scanner *s, int ingest) { SANE_Status ret = SANE_STATUS_GOOD; int i; unsigned char cmd[2]; size_t cmdLen = sizeof(cmd); unsigned char stat[1]; size_t statLen = sizeof(stat); unsigned char pay[2]; size_t payLen = sizeof(pay); DBG (10, "object_position: start\n"); i = (ingest)?5:1; while(i--){ /*send paper load cmd*/ cmd[0] = 0x1b; cmd[1] = 0xd4; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "object_position: error sending cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "object_position: cmd bad status? %d\n",stat[0]); continue; } /*send payload*/ statLen = 1; payLen = 1; pay[0] = ingest; ret = do_cmd( s, 0, pay, payLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "object_position: error sending payload\n"); return ret; } if(stat[0] == 6){ DBG (5, "object_position: found paper?\n"); break; } else if(stat[0] == 0x15 || stat[0] == 0){ DBG (5, "object_position: no paper?\n"); ret=SANE_STATUS_NO_DOCS; continue; } else{ DBG (5, "object_position: payload bad status?\n"); return SANE_STATUS_IO_ERROR; } } DBG (10, "object_position: finish\n"); return ret; } static SANE_Status scan(struct scanner *s) { SANE_Status ret=SANE_STATUS_GOOD; unsigned char cmd[] = {0x1b, 0xd2}; size_t cmdLen = 2; unsigned char stat[1]; size_t statLen = 1; DBG (10, "scan: start\n"); if(s->model == MODEL_S300 || s->model == MODEL_S1100 || s->model == MODEL_S1300i){ cmd[1] = 0xd6; } ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "scan: error sending cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "scan: cmd bad status?\n"); return SANE_STATUS_IO_ERROR; } DBG (10, "scan: finish\n"); return ret; } /* * Called by SANE to read data. * * From the SANE spec: * This function is used to read image data from the device * represented by handle h. Argument buf is a pointer to a memory * area that is at least maxlen bytes long. The number of bytes * returned is stored in *len. A backend must set this to zero when * the call fails (i.e., when a status other than SANE_STATUS_GOOD is * returned). * * When the call succeeds, the number of bytes returned can be * anywhere in the range from 0 to maxlen bytes. */ SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { struct scanner *s = (struct scanner *) handle; SANE_Status ret=SANE_STATUS_GOOD; struct page * page; DBG (10, "sane_read: start si:%d len:%d max:%d\n",s->side,*len,max_len); *len = 0; /* cancelled? */ if(!s->started){ DBG (5, "sane_read: call sane_start first\n"); return SANE_STATUS_CANCELLED; } page = &s->pages[s->side]; /* have sent all of current buffer */ if(s->fullscan.done && page->done){ DBG (10, "sane_read: returning eof\n"); /*S1100 needs help to turn off button*/ if(s->model == MODEL_S1100){ usleep(15000); /* eject paper */ ret = object_position(s,EPJITSU_PAPER_EJECT); if (ret != SANE_STATUS_GOOD && ret != SANE_STATUS_NO_DOCS) { DBG (5, "sane_read: ERROR: failed to eject\n"); return ret; } /* reset flashing button? */ ret = six5(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_read: ERROR: failed to six5\n"); return ret; } } return SANE_STATUS_EOF; } /* scan not finished, get more into block buffer */ if(!s->fullscan.done) { /* block buffer currently empty, clean up */ if(!s->block_xfr.rx_bytes) { /* block buffer bigger than remainder of scan, shrink block */ int remainTotal = s->fullscan.total_bytes - s->fullscan.rx_bytes; if(remainTotal < s->block_xfr.total_bytes) { DBG (15, "sane_read: shrinking block to %lu\n", (unsigned long)remainTotal); s->block_xfr.total_bytes = remainTotal; } /* send d3 cmd for S300, S1100, S1300 */ if(s->model == MODEL_S300 || s->model == MODEL_S1100 || s->model == MODEL_S1300i) { unsigned char cmd[] = {0x1b, 0xd3}; size_t cmdLen = 2; unsigned char stat[1]; size_t statLen = 1; DBG (15, "sane_read: d3\n"); ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "sane_read: error sending d3 cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "sane_read: cmd bad status?\n"); return SANE_STATUS_IO_ERROR; } } } ret = read_from_scanner(s, &s->block_xfr); if(ret){ DBG (5, "sane_read: cant read from scanner\n"); return ret; } /* block filled, copy to front/back */ if(s->block_xfr.done) { DBG (15, "sane_read: block buffer full\n"); /* convert the raw color data into normal packed pixel data */ descramble_raw(s, &s->block_xfr); s->block_xfr.done = 0; /* get the 0x43 cmd for the S300, S1100, S1300 */ if(s->model == MODEL_S300 || s->model == MODEL_S1100 || s->model == MODEL_S1300i){ unsigned char cmd[] = {0x1b, 0x43}; size_t cmdLen = 2; unsigned char in[10]; size_t inLen = 10; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, in, &inLen ); hexdump(15, "cmd 43: ", in, inLen); if(ret){ DBG (5, "sane_read: error sending 43 cmd\n"); return ret; } /*copy backside data into buffer*/ if( s->source == SOURCE_ADF_DUPLEX || s->source == SOURCE_ADF_BACK ) ret = copy_block_to_page(s, SIDE_BACK); /*copy frontside data into buffer*/ if( s->source != SOURCE_ADF_BACK ) ret = copy_block_to_page(s, SIDE_FRONT); if(ret){ DBG (5, "sane_read: cant copy to front/back\n"); return ret; } s->fullscan.rx_bytes += s->block_xfr.rx_bytes; /* autodetect mode, check for change length */ if( s->source != SOURCE_FLATBED && !s->page_height ){ int get = (in[6] << 8) | in[7]; /*always have to get full blocks*/ if(get % s->block_img.height){ get += s->block_img.height - (get % s->block_img.height); } if(get < s->fullscan.height){ DBG (15, "sane_read: paper out? %d\n",get); s->fullscan.total_bytes = s->fullscan.width_bytes * get; } } } else { /*fi-60f*/ ret = copy_block_to_page(s, SIDE_FRONT); if(ret){ DBG (5, "sane_read: cant copy to front/back\n"); return ret; } s->fullscan.rx_bytes += s->block_xfr.rx_bytes; } /* reset for next pass */ update_transfer_totals(&s->block_xfr); /* scan now finished */ if(s->fullscan.rx_bytes == s->fullscan.total_bytes){ DBG (15, "sane_read: last block\n"); s->fullscan.done = 1; } } } *len = page->bytes_scanned - page->bytes_read; if(*len > max_len){ *len = max_len; } if(*len){ DBG (10, "sane_read: copy rx:%d tx:%d tot:%d len:%d\n", page->bytes_scanned, page->bytes_read, page->bytes_total,*len); memcpy(buf, page->image->buffer + page->bytes_read, *len); page->bytes_read += *len; /* sent it all, return eof on next read */ if(page->bytes_read == page->bytes_scanned && s->fullscan.done){ DBG (10, "sane_read: side done\n"); page->done = 1; } } DBG (10, "sane_read: finish si:%d len:%d max:%d\n",s->side,*len,max_len); return ret; } static SANE_Status six5 (struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[2]; size_t cmdLen = sizeof(cmd); unsigned char stat[1]; size_t statLen = sizeof(stat); DBG (10, "six5: start\n"); cmd[0] = 0x1b; cmd[1] = 0x65; statLen = 1; ret = do_cmd( s, 0, cmd, cmdLen, NULL, 0, stat, &statLen ); if(ret){ DBG (5, "six5: error sending cmd\n"); return ret; } if(stat[0] != 6){ DBG (5, "six5: cmd bad status? %d\n",stat[0]); return SANE_STATUS_IO_ERROR; } DBG (10, "six5: finish\n"); return ret; } /* 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) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char *p_out = tp->image->buffer; 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)*/ int curr_col = 0; int r=0, g=0, b=0, ppc=0; for (k = 0; k <= tp->plane_width; k++){ /* column (x) */ int this_col = k*tp->image->x_res/tp->x_res; /* going to change output pixel, dump rgb and reset */ if(ppc && curr_col != this_col){ *p_out = r/ppc; p_out++; *p_out = g/ppc; p_out++; *p_out = b/ppc; p_out++; r = g = b = ppc = 0; curr_col = this_col; } if(k == tp->plane_width || this_col >= tp->image->width_pix){ break; } /*red is first*/ r += tp->raw_data[j*tp->line_stride + k*3 + i]; /*green is second*/ g += tp->raw_data[j*tp->line_stride + tp->plane_stride + k*3 + i]; /*blue is third*/ b += tp->raw_data[j*tp->line_stride + 2*tp->plane_stride + k*3 + i]; ppc++; } } } } else if (s->model == MODEL_S1100){ for (j = 0; j < height; j++){ /* row (y)*/ int curr_col = 0; int r=0, g=0, b=0, ppc=0; for (k = 0; k <= tp->plane_width; k++){ /* column (x) */ int this_col = k*tp->image->x_res/tp->x_res; /* going to change output pixel, dump rgb and reset */ if(ppc && curr_col != this_col){ *p_out = r/ppc; p_out++; *p_out = g/ppc; p_out++; *p_out = b/ppc; p_out++; r = g = b = ppc = 0; curr_col = this_col; } if(k == tp->plane_width || this_col >= tp->image->width_pix){ break; } /*red is second*/ r += tp->raw_data[j*tp->line_stride + tp->plane_stride + k]; /*green is third*/ g += tp->raw_data[j*tp->line_stride + 2*tp->plane_stride + k]; /*blue is first*/ b += tp->raw_data[j*tp->line_stride + k]; ppc++; } } } else { /* MODEL_FI60F or MODEL_FI65F */ for (j = 0; j < height; j++){ /* row (y)*/ int curr_col = 0; for (i = 0; i < 3; i++){ /* read head */ int r=0, g=0, b=0, ppc=0; for (k = 0; k <= tp->plane_width; k++){ /* column (x) within the read head */ int this_col = (k+i*tp->plane_width)*tp->image->x_res/tp->x_res; /* going to change output pixel, dump rgb and reset */ if(ppc && curr_col != this_col){ *p_out = r/ppc; p_out++; *p_out = g/ppc; p_out++; *p_out = b/ppc; p_out++; r = g = b = ppc = 0; curr_col = this_col; } if(k == tp->plane_width || this_col >= tp->image->width_pix){ break; } /*red is first*/ r += tp->raw_data[j*tp->line_stride + k*3 + i]; /*green is second*/ g += tp->raw_data[j*tp->line_stride + tp->plane_stride + k*3 + i]; /*blue is third*/ b += tp->raw_data[j*tp->line_stride + 2*tp->plane_stride + k*3 + i]; ppc++; } } } } 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; } /* fills block buffer a little per pass */ static SANE_Status read_from_scanner(struct scanner *s, struct transfer * tp) { SANE_Status ret=SANE_STATUS_GOOD; size_t bytes = MAX_IMG_PASS; size_t remainBlock = tp->total_bytes - tp->rx_bytes + 8; unsigned char * buf; size_t bufLen; /* determine amount to ask for, S1300i wants big requests */ if(bytes > remainBlock && s->model != MODEL_S1300i){ bytes = remainBlock; } if (tp->image == NULL) { DBG(5, "internal error: read_from_scanner called with no destination image.\n"); return SANE_STATUS_INVAL; } DBG (10, "read_from_scanner: start rB:%lu len:%lu\n", (unsigned long)remainBlock, (unsigned long)bytes); if(!bytes){ DBG(10, "read_from_scanner: no bytes!\n"); return SANE_STATUS_INVAL; } bufLen = bytes; buf = malloc(bufLen); if(!buf){ DBG (5, "read_from_scanner: failed to alloc mem\n"); return SANE_STATUS_NO_MEM; } ret = do_cmd( s, 0, NULL, 0, NULL, 0, buf, &bytes ); /* full read or short read */ if (ret == SANE_STATUS_GOOD || (ret == SANE_STATUS_EOF && bytes) ) { DBG(15,"read_from_scanner: got GOOD/EOF (%lu)\n",(unsigned long)bytes); if(bytes > remainBlock){ DBG(15,"read_from_scanner: block too big?\n"); bytes = remainBlock; } if(bytes == remainBlock){ DBG(15,"read_from_scanner: block done, ignoring trailer\n"); bytes -= 8; tp->done = 1; } memcpy(tp->raw_data + tp->rx_bytes, buf, bytes); tp->rx_bytes += bytes; ret = SANE_STATUS_GOOD; } else { DBG(5, "read_from_scanner: error reading status = %d\n", ret); } free(buf); DBG (10, "read_from_scanner: finish rB:%lu len:%lu\n", (unsigned long)(tp->total_bytes - tp->rx_bytes + 8), (unsigned long)bytes); return ret; } /* copies block buffer into front or back image buffer */ /* 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) { SANE_Status ret = SANE_STATUS_GOOD; struct transfer * block = &s->block_xfr; struct page * page = &s->pages[side]; int image_height = block->total_bytes / block->line_stride; 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; int curr_in_row = s->fullscan.rx_bytes/s->fullscan.width_bytes; int last_out_row = (page->bytes_scanned / page->image->width_bytes) - 1; 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) { DBG (10, "copy_block_to_page: before the start? %d\n", side); return ret; } else if (s->fullscan.rx_bytes < block->line_stride * page->image->y_skip_offset) { k = page->image->y_skip_offset - s->fullscan.rx_bytes / block->line_stride; DBG (10, "copy_block_to_page: k start? %d\n", k); } /* loop over all the lines in the block */ for (i = k; i < image_height; i++) { /* determine source and dest rows (dpi scaling) */ int this_in_row = curr_in_row + i; int this_out_row = (this_in_row - page->image->y_skip_offset) * page->image->y_res / s->fullscan.y_res; DBG (15, "copy_block_to_page: in %d out %d lastout %d\n", this_in_row, this_out_row, last_out_row); DBG (15, "copy_block_to_page: bs %d wb %d\n", page->bytes_scanned, page->image->width_bytes); /* don't walk off the end of the output buffer */ if(this_out_row >= page->image->height || this_out_row < 0){ DBG (10, "copy_block_to_page: out of space? %d\n", side); DBG (10, "copy_block_to_page: rx:%d tx:%d tot:%d line:%d\n", page->bytes_scanned, page->bytes_read, page->bytes_total,page->image->width_bytes); return ret; } /* ok, different output row, so we do the math */ if(this_out_row > last_out_row){ unsigned char * p_in = block->image->buffer + (side * block_page_stride) + (i * block->image->width_bytes) + page->image->x_start_offset * 3; unsigned char * p_out = page->image->buffer + this_out_row * page->image->width_bytes; unsigned char * lineStart = p_out; last_out_row = this_out_row; 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++) { 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]; } else /* MODEL_FI60F or MODEL_FI65F or MODEL_S1100 */ { r = p_in[0]; g = p_in[1]; b = p_in[2]; } if (s->mode == MODE_COLOR) { *p_out++ = r; *p_out++ = g; *p_out++ = b; } else if (s->mode == MODE_GRAYSCALE) { *p_out++ = (r + g + b) / 3; } else if (s->mode == MODE_LINEART) { 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 */ if (line_reverse) p_in -= page->image->x_offset_bytes; else p_in += page->image->x_offset_bytes; /* for MODE_LINEART, binarize the gray line stored in the temp image buffer(dt) */ /* bacause dt.width = page_width, we pass page_width */ if (s->mode == MODE_LINEART) binarize_line(s, lineStart, page_width); page->bytes_scanned += page->image->width_bytes; } } DBG (10, "copy_block_to_page: finish\n"); return ret; } /*uses the threshold/threshold_curve to control binarization*/ static SANE_Status binarize_line(struct scanner *s, unsigned char *lineOut, int width) { SANE_Status ret = SANE_STATUS_GOOD; int j, windowX, sum = 0; /* ~1mm works best, but the window needs to have odd # of pixels */ windowX = 6 * s->resolution / 150; if (!(windowX % 2)) windowX++; /*second, prefill the sliding sum*/ for (j = 0; j < windowX; j++) sum += s->dt.buffer[j]; /* third, walk the dt buffer, update the sliding sum, */ /* determine threshold, output bits */ for (j = 0; j < width; j++) { /*output image location*/ int offset = j % 8; unsigned char mask = 0x80 >> offset; int thresh = s->threshold; /* move sum/update threshold only if there is a curve*/ if (s->threshold_curve) { int addCol = j + windowX/2; int dropCol = addCol - windowX; if (dropCol >= 0 && addCol < width) { sum -= s->dt.buffer[dropCol]; sum += s->dt.buffer[addCol]; } thresh = s->dt_lut[sum/windowX]; } /*use average to lookup threshold*/ if (s->dt.buffer[j] > thresh) *lineOut &= ~mask; /* white */ else *lineOut |= mask; /* black */ if (offset == 7) lineOut++; } return ret; } /* * @@ Section 4 - SANE cleanup functions */ /* * Cancels a scan. * * From the SANE spec: * This function is used to immediately or as quickly as possible * cancel the currently pending operation of the device represented by * handle h. This function can be called at any time (as long as * handle h is a valid handle) but usually affects long-running * operations only (such as image is acquisition). It is safe to call * this function asynchronously (e.g., from within a signal handler). * It is important to note that completion of this operaton does not * imply that the currently pending operation has been cancelled. It * only guarantees that cancellation has been initiated. Cancellation * completes only when the cancelled call returns (typically with a * status value of SANE_STATUS_CANCELLED). Since the SANE API does * not require any other operations to be re-entrant, this implies * that a frontend must not call any other operation until the * cancelled operation has returned. */ void sane_cancel (SANE_Handle handle) { /*FIXME: actually ask the scanner to stop?*/ struct scanner * s = (struct scanner *) handle; DBG (10, "sane_cancel: start\n"); s->started = 0; DBG (10, "sane_cancel: finish\n"); } /* * Ends use of the scanner. * * From the SANE spec: * This function terminates the association between the device handle * passed in argument h and the device it represents. If the device is * presently active, a call to sane_cancel() is performed first. After * this function returns, handle h must not be used anymore. */ void sane_close (SANE_Handle handle) { struct scanner * s = (struct scanner *) handle; DBG (10, "sane_close: start\n"); /* still connected- drop it */ if(s->fd >= 0){ sane_cancel(handle); lamp(s, 0); disconnect_fd(s); } DBG (10, "sane_close: finish\n"); } static SANE_Status disconnect_fd (struct scanner *s) { DBG (10, "disconnect_fd: start\n"); if(s->fd > -1){ DBG (15, "disconnecting usb device\n"); sanei_usb_close (s->fd); s->fd = -1; } DBG (10, "disconnect_fd: finish\n"); return SANE_STATUS_GOOD; } static SANE_Status destroy(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; DBG (10, "destroy: start\n"); teardown_buffers(s); if(s->sane.name){ free((void *) s->sane.name); } if(s->sane.vendor){ free((void *) s->sane.vendor); } if(s->sane.model){ free((void *) s->sane.model); } free(s); DBG (10, "destroy: finish\n"); return ret; } static SANE_Status teardown_buffers(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; DBG (10, "teardown_buffers: start\n"); /* temporary cal data */ if(s->coarsecal.buffer){ free(s->coarsecal.buffer); s->coarsecal.buffer = NULL; } if(s->darkcal.buffer){ free(s->darkcal.buffer); s->darkcal.buffer = NULL; } if(s->sendcal.buffer){ free(s->sendcal.buffer); s->sendcal.buffer = NULL; } if(s->cal_image.raw_data){ free(s->cal_image.raw_data); s->cal_image.raw_data = NULL; } if(s->cal_data.raw_data){ free(s->cal_data.raw_data); s->cal_data.raw_data = NULL; } /* image slice */ if(s->block_img.buffer){ free(s->block_img.buffer); s->block_img.buffer = NULL; } if(s->block_xfr.raw_data){ free(s->block_xfr.raw_data); s->block_xfr.raw_data = NULL; } /* dynamic thresh slice */ if(s->dt.buffer){ free(s->dt.buffer); s->dt.buffer = NULL; } /* image buffer to hold frontside data */ if(s->front.buffer){ free(s->front.buffer); s->front.buffer = NULL; } /* image buffer to hold backside data */ if(s->back.buffer){ free(s->back.buffer); s->back.buffer = NULL; } DBG (10, "teardown_buffers: finish\n"); return ret; } /* * Terminates the backend. * * From the SANE spec: * This function must be called to terminate use of a backend. The * function will first close all device handles that still might be * open (it is recommended to close device handles explicitly through * a call to sane_close(), but backends are required to release all * resources upon a call to this function). After this function * returns, no function other than sane_init() may be called * (regardless of the status value returned by sane_exit(). Neglecting * to call this function may result in some resources not being * released properly. */ void sane_exit (void) { struct scanner *dev, *next; DBG (10, "sane_exit: start\n"); for (dev = scanner_devList; dev; dev = next) { next = dev->next; destroy(dev); } if (sane_devArray) free (sane_devArray); scanner_devList = NULL; sane_devArray = NULL; DBG (10, "sane_exit: finish\n"); } /* * @@ Section 5 - misc helper functions */ /* * take a bunch of pointers, send commands to scanner */ static SANE_Status do_cmd(struct scanner *s, int shortTime, unsigned char * cmdBuff, size_t cmdLen, unsigned char * outBuff, size_t outLen, unsigned char * inBuff, size_t * inLen ) { /* sanei_usb overwrites the transfer size, so make some local copies */ size_t loc_cmdLen = cmdLen; size_t loc_outLen = outLen; size_t loc_inLen = 0; int cmdTime = USB_COMMAND_TIME; int outTime = USB_DATA_TIME; int inTime = USB_DATA_TIME; int ret = 0; DBG (10, "do_cmd: start\n"); if(shortTime){ cmdTime /= 20; outTime /= 20; inTime /= 20; } /* this command has a cmd component, and a place to get it */ if(cmdBuff && cmdLen && cmdTime){ /* change timeout */ sanei_usb_set_timeout(cmdTime); /* write the command out */ DBG(25, "cmd: writing %ld bytes, timeout %d\n", (long)cmdLen, cmdTime); hexdump(30, "cmd: >>", cmdBuff, cmdLen); ret = sanei_usb_write_bulk(s->fd, cmdBuff, &cmdLen); DBG(25, "cmd: wrote %ld bytes, retVal %d\n", (long)cmdLen, ret); if(ret == SANE_STATUS_EOF){ DBG(5,"cmd: got EOF, returning IO_ERROR\n"); return SANE_STATUS_IO_ERROR; } if(ret != SANE_STATUS_GOOD){ DBG(5,"cmd: return error '%s'\n",sane_strstatus(ret)); return ret; } if(loc_cmdLen != cmdLen){ DBG(5,"cmd: wrong size %ld/%ld\n", (long)loc_cmdLen, (long)cmdLen); return SANE_STATUS_IO_ERROR; } } /* this command has a write component, and a place to get it */ if(outBuff && outLen && outTime){ /* change timeout */ sanei_usb_set_timeout(outTime); DBG(25, "out: writing %ld bytes, timeout %d\n", (long)outLen, outTime); hexdump(30, "out: >>", outBuff, outLen); ret = sanei_usb_write_bulk(s->fd, outBuff, &outLen); DBG(25, "out: wrote %ld bytes, retVal %d\n", (long)outLen, ret); if(ret == SANE_STATUS_EOF){ DBG(5,"out: got EOF, returning IO_ERROR\n"); return SANE_STATUS_IO_ERROR; } if(ret != SANE_STATUS_GOOD){ DBG(5,"out: return error '%s'\n",sane_strstatus(ret)); return ret; } if(loc_outLen != outLen){ DBG(5,"out: wrong size %ld/%ld\n", (long)loc_outLen, (long)outLen); return SANE_STATUS_IO_ERROR; } } /* this command has a read component, and a place to put it */ if(inBuff && inLen && inTime){ loc_inLen = *inLen; DBG(25, "in: memset %ld bytes\n", (long)*inLen); memset(inBuff,0,*inLen); /* change timeout */ sanei_usb_set_timeout(inTime); DBG(25, "in: reading %ld bytes, timeout %d\n", (long)*inLen, inTime); ret = sanei_usb_read_bulk(s->fd, inBuff, inLen); DBG(25, "in: retVal %d\n", ret); if(ret == SANE_STATUS_EOF){ DBG(5,"in: got EOF, continuing\n"); } else if(ret != SANE_STATUS_GOOD){ DBG(5,"in: return error '%s'\n",sane_strstatus(ret)); return ret; } DBG(25, "in: read %ld bytes\n", (long)*inLen); if(*inLen){ hexdump(30, "in: <<", inBuff, *inLen); } if(loc_inLen != *inLen){ ret = SANE_STATUS_EOF; DBG(5,"in: short read %ld/%ld\n", (long)loc_inLen, (long)*inLen); } } DBG (10, "do_cmd: finish\n"); return ret; } /** * Convenience method to determine longest string size in a list. */ static size_t maxStringSize (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } /** * Prints a hex dump of the given buffer onto the debug output stream. */ static void hexdump (int level, char *comment, unsigned char *p, int l) { int i; char line[128]; char *ptr; if(DBG_LEVEL < level) return; DBG (level, "%s\n", comment); ptr = line; for (i = 0; i < l; i++, p++) { if ((i % 16) == 0) { if (ptr != line) { *ptr = '\0'; DBG (level, "%s\n", line); ptr = line; } sprintf (ptr, "%3.3x:", i); ptr += 4; } sprintf (ptr, " %2.2x", *p); ptr += 3; } *ptr = '\0'; DBG (level, "%s\n", line); } /** * An advanced method we don't support but have to define. */ SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking) { DBG (10, "sane_set_io_mode\n"); DBG (15, "%d %p\n", non_blocking, h); return SANE_STATUS_UNSUPPORTED; } /** * An advanced method we don't support but have to define. */ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int *fdp) { DBG (10, "sane_get_select_fd\n"); DBG (15, "%p %d\n", h, *fdp); return SANE_STATUS_UNSUPPORTED; } /* s->page_width stores the user setting * for the paper width in adf. sometimes, * we need a value that differs from this * due to using FB */ static int get_page_width(struct scanner *s) { /* scanner max for fb */ if(s->source == SOURCE_FLATBED){ return s->max_x; } return s->page_width; } /* s->page_height stores the user setting * for the paper height in adf. sometimes, * we need a value that differs from this * due to using FB. */ static int get_page_height(struct scanner *s) { /* scanner max for fb */ if(s->source == SOURCE_FLATBED){ return s->max_y; } return s->page_height; } sane-backends-1.0.29/backend/hp.conf.in0000666000000000000000000000076113615534521014457 00000000000000scsi HP # Uncomment the following if you have "Error during device I/O" on SCSI # option dumb-read # # The usual place for a SCSI-scanner on Linux /dev/scanner # # USB-scanners supported by the hp-backend # HP ScanJet 4100C usb 0x03f0 0x0101 # HP ScanJet 5200C usb 0x03f0 0x0401 # HP ScanJet 62X0C usb 0x03f0 0x0201 # HP ScanJet 63X0C usb 0x03f0 0x0601 # # Uncomment the following if your scanner is connected by USB, # but you are not using libusb # /dev/usb/scanner0 # option connect-device sane-backends-1.0.29/backend/sm3840.conf.in0000666000000000000000000000016313615534521015002 00000000000000# usb vendor product # Microtek ScanMaker 3840 ID usb 0x05da 0x30d4 # Microtek ScanMaker 4800 ID usb 0x05da 0x30cf sane-backends-1.0.29/backend/tamarack.c0000666000000000000000000011572013615534521014525 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1996 David Mosberger-Tang Copyright (C) 1997 R.E.Wolff@BitWizard.nl 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Note: The exception that is mentioned in the other source files is not here. If a case arises where you need the rights that that exception gives you, Please do contact me, and we'll work something out. R.E.Wolff@BitWizard.nl tel: +31-152137555 fax: +31-152138217 This file implements a SANE backend for Tamarack flatbed scanners. */ /* This driver was written initially by changing all occurances of "mustek" to "tamarack". This actuall worked without modification for the manufacturer detection code! :-) */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include "../include/_stdint.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_thread.h" #include "../include/sane/sanei_config.h" /* For timeval... */ #ifdef DEBUG #include #endif #define BACKEND_NAME tamarack #include "../include/sane/sanei_backend.h" #include "tamarack.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #define TAMARACK_CONFIG_FILE "tamarack.conf" static const SANE_Device **devlist = NULL; static int num_devices; static Tamarack_Device *first_dev; static Tamarack_Scanner *first_handle; static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_HALFTONE, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, 0 }; #if 0 static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; #endif /* David used " 100 << SANE_FIXED_SCALE_SHIFT ". This assumes that * it is implemented that way. I want to hide the datatype. */ static const SANE_Range percentage_range = { SANE_FIX(-100), /* minimum */ SANE_FIX( 100), /* maximum */ SANE_FIX( 1 ) /* quantization */ }; /* David used " 100 << SANE_FIXED_SCALE_SHIFT ". This assumes that * it is implemented that way. I want to hide the datatype. */ static const SANE_Range abs_percentage_range = { SANE_FIX( 0), /* minimum */ SANE_FIX( 100), /* maximum */ SANE_FIX( 1 ) /* quantization */ }; #define INQ_LEN 0x60 static const uint8_t inquiry[] = { TAMARACK_SCSI_INQUIRY, 0x00, 0x00, 0x00, INQ_LEN, 0x00 }; static const uint8_t test_unit_ready[] = { TAMARACK_SCSI_TEST_UNIT_READY, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uint8_t stop[] = { TAMARACK_SCSI_START_STOP, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uint8_t get_status[] = { TAMARACK_SCSI_GET_DATA_STATUS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00 }; static SANE_Status wait_ready (int fd) { SANE_Status status; int i; for (i = 0; i < 1000; ++i) { DBG(3, "wait_ready: sending TEST_UNIT_READY\n"); status = sanei_scsi_cmd (fd, test_unit_ready, sizeof (test_unit_ready), 0, 0); switch (status) { default: /* Ignore errors while waiting for scanner to become ready. Some SCSI drivers return EIO while the scanner is returning to the home position. */ DBG(1, "wait_ready: test unit ready failed (%s)\n", sane_strstatus (status)); /* fall through */ case SANE_STATUS_DEVICE_BUSY: usleep (100000); /* retry after 100ms */ break; case SANE_STATUS_GOOD: return status; } } DBG(1, "wait_ready: timed out after %d attempts\n", i); return SANE_STATUS_INVAL; } static SANE_Status sense_handler (int scsi_fd, u_char *result, void *arg) { scsi_fd = scsi_fd; arg = arg; /* silence compilation warnings */ switch (result[0]) { case 0x00: break; default: DBG(1, "sense_handler: got unknown sense code %02x\n", result[0]); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /* XXX This might leak the memory to a TAMARACK string */ static SANE_Status attach (const char *devname, Tamarack_Device **devp) { char result[INQ_LEN]; int fd; Tamarack_Device *dev; SANE_Status status; size_t size; char *mfg, *model; char *p; for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devname) == 0) { if (devp) *devp = dev; return SANE_STATUS_GOOD; } DBG(3, "attach: opening %s\n", devname); status = sanei_scsi_open (devname, &fd, sense_handler, 0); if (status != SANE_STATUS_GOOD) { DBG(1, "attach: open failed (%s)\n", sane_strstatus (status)); return SANE_STATUS_INVAL; } DBG(3, "attach: sending INQUIRY\n"); size = sizeof (result); status = sanei_scsi_cmd (fd, inquiry, sizeof (inquiry), result, &size); if (status != SANE_STATUS_GOOD || size != INQ_LEN) { DBG(1, "attach: inquiry failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (fd); return status; } status = wait_ready (fd); sanei_scsi_close (fd); if (status != SANE_STATUS_GOOD) return status; result[33]= '\0'; p = strchr(result+16,' '); if (p) *p = '\0'; model = strdup (result+16); result[16]= '\0'; p = strchr(result+8,' '); if (p) *p = '\0'; mfg = strdup (result+8); DBG(1, "attach: Inquiry gives mfg=%s, model=%s.\n", mfg, model); if (strcmp (mfg, "TAMARACK") != 0) { DBG(1, "attach: device doesn't look like a Tamarack scanner " "(result[0]=%#02x)\n", result[0]); return SANE_STATUS_INVAL; } dev = malloc (sizeof (*dev)); if (!dev) return SANE_STATUS_NO_MEM; memset (dev, 0, sizeof (*dev)); dev->sane.name = strdup (devname); dev->sane.vendor = "Tamarack"; dev->sane.model = model; dev->sane.type = "flatbed scanner"; dev->x_range.min = 0; dev->y_range.min = 0; dev->x_range.quant = 0; dev->y_range.quant = 0; dev->dpi_range.min = SANE_FIX (1); dev->dpi_range.quant = SANE_FIX (1); dev->x_range.max = SANE_FIX (8.5 * MM_PER_INCH); dev->y_range.max = SANE_FIX (11.0 * MM_PER_INCH); dev->dpi_range.max = SANE_FIX (600); DBG(3, "attach: found Tamarack scanner model %s (%s)\n", dev->sane.model, dev->sane.type); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; return SANE_STATUS_GOOD; } static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } static SANE_Status constrain_value (Tamarack_Scanner *s, SANE_Int option, void *value, SANE_Int *info) { return sanei_constrain_value (s->opt + option, value, info); } static unsigned char sign_mag (double val) { if (val > 100) val = 100; if (val < -100) val = -100; if (val >= 0) return ( val); else return ((unsigned char)(-val)) | 0x80; } static SANE_Status scan_area_and_windows (Tamarack_Scanner *s) { struct def_win_par dwp; memset (&dwp,'\0',sizeof (dwp)); dwp.dwph.opc = TAMARACK_SCSI_AREA_AND_WINDOWS; set_triple (dwp.dwph.len,8 + sizeof (dwp.wdb)); set_double (dwp.wdh.wpll, sizeof (dwp.wdb)); dwp.wdb.winid = WINID; set_double (dwp.wdb.xres, (int) SANE_UNFIX (s->val[OPT_RESOLUTION].w)); set_double (dwp.wdb.yres, (int) SANE_UNFIX (s->val[OPT_RESOLUTION].w)); set_quad (dwp.wdb.ulx, (int) (47.2 * SANE_UNFIX (s->val[OPT_TL_X].w))); set_quad (dwp.wdb.uly, (int) (47.2 * SANE_UNFIX (s->val[OPT_TL_Y].w))); set_quad (dwp.wdb.width, (int) (47.2 * SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w))); set_quad (dwp.wdb.length, (int) (47.2 * SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w))); dwp.wdb.brightness = sign_mag (SANE_UNFIX (s->val[OPT_BRIGHTNESS].w)); dwp.wdb.contrast = sign_mag (SANE_UNFIX (s->val[OPT_CONTRAST].w)); dwp.wdb.thresh = 0x80; switch (s->mode) { case THRESHOLDED: dwp.wdb.bpp = 1; dwp.wdb.image_comp = 0; dwp.wdb.thresh = 1 + 2.55 * (SANE_UNFIX (s->val[OPT_THRESHOLD].w)); break; case DITHERED: dwp.wdb.bpp = 1; dwp.wdb.image_comp = 1; break; case GREYSCALE: dwp.wdb.bpp = 8; dwp.wdb.image_comp = 2; break; case TRUECOLOR: dwp.wdb.bpp = 8; dwp.wdb.image_comp = 2; break; default: DBG(1, "Invalid mode. %d\n", s->mode); return SANE_STATUS_INVAL; } DBG(1, "bright, thresh, contrast = %d(%5.1f), %d, %d(%5.1f)\n", dwp.wdb.brightness, SANE_UNFIX (s->val[OPT_BRIGHTNESS].w), dwp.wdb.thresh , dwp.wdb.contrast , SANE_UNFIX (s->val[OPT_CONTRAST].w)); set_double (dwp.wdb.halftone, 1); /* XXX What does this do again ? */ dwp.wdb.pad_type = 3; /* This is the only usable pad-type. */ dwp.wdb.exposure = 0x6f; /* XXX Option? */ dwp.wdb.compr_type = 0; /* XXX Shouldn't this be sizeof (dwp) */ return sanei_scsi_cmd (s->fd, &dwp, (10+8+38), 0, 0); } static SANE_Status mode_select (Tamarack_Scanner *s) { struct { struct command_header cmd; struct page_header hdr; struct tamarack_page page; } c; memset (&c, '\0', sizeof (c)); c.cmd.opc = TAMARACK_SCSI_MODE_SELECT; c.cmd.pad0[0] = 0x10; /* Suddenly the pad bytes are no long pad... */ c.cmd.pad0[1] = 0; c.cmd.len = sizeof (struct page_header) + sizeof (struct tamarack_page); c.hdr.code = 0; c.hdr.length = 6; c.page.gamma = 2; c.page.thresh = 0x80; /* XXX Option? */ switch (s->mode) { case THRESHOLDED: case DITHERED: case GREYSCALE: c.page.masks = 0x80; break; case TRUECOLOR: c.page.masks = 0x40 >> s->pass; break; } c.page.delay = 0x10; /* XXX Option? */ c.page.features = (s->val[OPT_TRANS].w ? TAM_TRANS_ON:0) | 1; return sanei_scsi_cmd (s->fd, &c, sizeof (c), 0, 0); } static SANE_Status start_scan (Tamarack_Scanner *s) { struct { struct command_header cmd; unsigned char winid[1]; } c; memset (&c,'\0',sizeof (c)); c.cmd.opc = TAMARACK_SCSI_START_STOP; c.cmd.len = sizeof (c.winid); c.winid[0] = WINID; return sanei_scsi_cmd (s->fd, &c, sizeof (c), 0, 0); } static SANE_Status stop_scan (Tamarack_Scanner *s) { /* XXX I don't think a TAMARACK can stop in mid-scan. Just stop sending it requests for data.... */ return sanei_scsi_cmd (s->fd, stop, sizeof (stop), 0, 0); } static SANE_Status do_eof (Tamarack_Scanner *s) { if (s->pipe >= 0) { close (s->pipe); s->pipe = -1; } return SANE_STATUS_EOF; } static SANE_Status do_cancel (Tamarack_Scanner *s) { s->scanning = SANE_FALSE; s->pass = 0; do_eof (s); if (sanei_thread_is_valid (s->reader_pid)) { int exit_status; /* ensure child knows it's time to stop: */ sanei_thread_kill (s->reader_pid); sanei_thread_waitpid (s->reader_pid, &exit_status); sanei_thread_invalidate (s->reader_pid); } if (s->fd >= 0) { stop_scan (s); sanei_scsi_close (s->fd); s->fd = -1; } return SANE_STATUS_CANCELLED; } static SANE_Status get_image_status (Tamarack_Scanner *s) { uint8_t result[12]; SANE_Status status; size_t len; int busy; #if 1 do { len = sizeof (result); status = sanei_scsi_cmd (s->fd, get_status, sizeof (get_status), result, &len); if ((status != SANE_STATUS_GOOD) && (status != SANE_STATUS_DEVICE_BUSY)) return status; busy = (result[2] != 8) || (status == SANE_STATUS_DEVICE_BUSY); if (busy) usleep (100000); if (!s->scanning) return do_cancel (s); } while (busy); #else /* XXX Test if this works one day... */ wait_ready (s); #endif len = sizeof (result); status = sanei_scsi_cmd (s->fd, get_status, sizeof (get_status), result, &len); if ((status != SANE_STATUS_GOOD) && (status != SANE_STATUS_DEVICE_BUSY)) return status; s->params.bytes_per_line = result[ 8] | (result[ 7] << 8) | (result[6] << 16); s->params.lines = result[11] | (result[10] << 8) | (result[9] << 16); switch (s->mode) { case DITHERED: case THRESHOLDED: s->params.pixels_per_line = 8 * s->params.bytes_per_line; break; case GREYSCALE: case TRUECOLOR: s->params.pixels_per_line = s->params.bytes_per_line; break; } DBG(1, "get_image_status: bytes_per_line=%d, lines=%d\n", s->params.bytes_per_line, s->params.lines); return SANE_STATUS_GOOD; } static SANE_Status read_data (Tamarack_Scanner *s, SANE_Byte *buf, int lines, int bpl) { struct command_header_10 cmd; size_t nbytes; SANE_Status status; #ifdef DEBUG int dt; struct timeval tv_start,tv_end; #endif nbytes = bpl * lines; memset (&cmd,'\0',sizeof (cmd)); cmd.opc = 0x28; set_triple (cmd.len,nbytes); #ifdef DEBUG if (verbose) DBG (1, "Doing read_data... \n"); gettimeofday (&tv_start,NULL); #endif status = sanei_scsi_cmd (s->fd, &cmd, sizeof (cmd), buf, &nbytes); #ifdef DEBUG gettimeofday (&tv_end,NULL); dt = tv_end.tv_usec - tv_start.tv_usec + (tv_end.tv_sec - tv_start.tv_sec) * 1000000; if (verbose) DBG(1, "Read took %d.%06d seconds.", dt/1000000,dt%1000000); dt = 1000000 * nbytes / dt; if (verbose) DBG(1, "which is %d.%03d bytes per second.\n",dt,0); #endif return status; } static SANE_Status init_options (Tamarack_Scanner *s) { int i; memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = "Scan Mode"; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = "Select the scan mode"; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].s = strdup (mode_list[OPT_MODE_DEFAULT]); /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_FIXED; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_RESOLUTION].constraint.range = &s->hw->dpi_range; s->val[OPT_RESOLUTION].w = SANE_FIX (OPT_RESOLUTION_DEFAULT); /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->val[OPT_PREVIEW].w = 0; /* gray preview */ s->opt[OPT_GRAY_PREVIEW].name = SANE_NAME_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].title = SANE_TITLE_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].desc = SANE_DESC_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_GRAY_PREVIEW].w = SANE_FALSE; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->val[OPT_TL_X].w = 0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->val[OPT_BR_X].w = s->hw->x_range.max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; s->val[OPT_BR_Y].w = s->hw->y_range.max; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* transparency adapter. */ s->opt[OPT_TRANS].name = "transparency"; s->opt[OPT_TRANS].title = "transparency"; s->opt[OPT_TRANS].desc = "Turn on the transparency adapter."; s->opt[OPT_TRANS].type = SANE_TYPE_BOOL; s->opt[OPT_TRANS].unit = SANE_UNIT_NONE; s->val[OPT_TRANS].w = SANE_FALSE; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS " This option is active for lineart/halftone modes only. " "For multibit modes (grey/color) use the gamma-table(s)."; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_FIXED; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_PERCENT; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &percentage_range; s->val[OPT_BRIGHTNESS].w = SANE_FIX(0); /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST " This option is active for lineart/halftone modes only. " "For multibit modes (grey/color) use the gamma-table(s)."; s->opt[OPT_CONTRAST].type = SANE_TYPE_FIXED; s->opt[OPT_CONTRAST].unit = SANE_UNIT_PERCENT; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &percentage_range; s->val[OPT_CONTRAST].w = SANE_FIX(0); /* Threshold */ s->opt[OPT_THRESHOLD].name = "Threshold"; s->opt[OPT_THRESHOLD].title = "Threshold"; s->opt[OPT_THRESHOLD].desc = "Threshold: below this level is black, above is white" " This option is active for bitmap modes only. "; s->opt[OPT_THRESHOLD].type = SANE_TYPE_FIXED; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_PERCENT; s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &abs_percentage_range; s->val[OPT_THRESHOLD].w = SANE_FIX(50); s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; #if 0 /* custom-gamma table */ s->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; s->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* grayscale gamma vector */ s->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR].wa = &s->gamma_table[0][0]; /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_R].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_R].wa = &s->gamma_table[1][0]; /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_G].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_G].wa = &s->gamma_table[2][0]; /* blue gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_B].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_B].wa = &s->gamma_table[3][0]; #endif return SANE_STATUS_GOOD; } /* This function is executed as a child process. The reason this is executed as a subprocess is because some (most?) generic SCSI interfaces block a SCSI request until it has completed. With a subprocess, we can let it block waiting for the request to finish while the main process can go about to do more important things (such as recognizing when the user presses a cancel button). WARNING: Since this is executed as a subprocess, it's NOT possible to update any of the variables in the main process (in particular the scanner state cannot be updated). */ static int reader_process (void *scanner) { Tamarack_Scanner *s = (Tamarack_Scanner *) scanner; int fd = s->reader_pipe; SANE_Byte *data; int lines_per_buffer, bpl; SANE_Status status; sigset_t sigterm_set; sigset_t ignore_set; struct SIGACTION act; FILE *fp; if (sanei_thread_is_forked()) close (s->pipe); sigfillset (&ignore_set); sigdelset (&ignore_set, SIGTERM); #if defined (__APPLE__) && defined (__MACH__) sigdelset (&ignore_set, SIGUSR2); #endif sigprocmask (SIG_SETMASK, &ignore_set, 0); memset (&act, 0, sizeof (act)); sigaction (SIGTERM, &act, 0); sigemptyset (&sigterm_set); sigaddset (&sigterm_set, SIGTERM); fp = fdopen (fd, "w"); if (!fp) return 1; bpl = s->params.bytes_per_line; lines_per_buffer = sanei_scsi_max_request_size / bpl; if (!lines_per_buffer) return 2; /* resolution is too high */ /* Limit the size of a single transfer to one inch. XXX Add a stripsize option. */ if (lines_per_buffer > SANE_UNFIX (s->val[OPT_RESOLUTION].w)) lines_per_buffer = SANE_UNFIX (s->val[OPT_RESOLUTION].w); DBG(3, "lines_per_buffer=%d, bytes_per_line=%d\n", lines_per_buffer, bpl); data = malloc (lines_per_buffer * bpl); for (s->line = 0; s->line < s->params.lines; s->line += lines_per_buffer) { if (s->line + lines_per_buffer > s->params.lines) /* do the last few lines: */ lines_per_buffer = s->params.lines - s->line; sigprocmask (SIG_BLOCK, &sigterm_set, 0); status = read_data (s, data, lines_per_buffer, bpl); sigprocmask (SIG_UNBLOCK, &sigterm_set, 0); if (status != SANE_STATUS_GOOD) { DBG(1, "reader_process: read_data failed with status=%d\n", status); return 3; } DBG(3, "reader_process: read %d lines\n", lines_per_buffer); if ((s->mode == TRUECOLOR) || (s->mode == GREYSCALE)) { fwrite (data, lines_per_buffer, bpl, fp); } else { /* in singlebit mode, the scanner returns 1 for black. ;-( --DM */ /* Hah! Same for Tamarack... -- REW */ int i; for (i = 0; i < lines_per_buffer * bpl; ++i) fputc (~data[i], fp); } } fclose (fp); return 0; } static SANE_Status attach_one (const char *dev) { attach (dev, 0); return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int *version_code, SANE_Auth_Callback authorize) { char dev_name[PATH_MAX]; size_t len; FILE *fp; authorize = authorize; /* silence compilation warnings */ DBG_INIT(); sanei_thread_init(); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (TAMARACK_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ attach ("/dev/scanner", 0); return SANE_STATUS_GOOD; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ sanei_config_attach_matching_devices (dev_name, attach_one); } fclose (fp); return SANE_STATUS_GOOD; } void sane_exit (void) { Tamarack_Device *dev, *next; for (dev = first_dev; dev; dev = next) { next = dev->next; free ((void *) dev->sane.name); free ((void *) dev->sane.model); free (dev); } if (devlist) free (devlist); } SANE_Status sane_get_devices (const SANE_Device ***device_list, SANE_Bool local_only) { Tamarack_Device *dev; int i; local_only = local_only; /* silence compilation warnings */ if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle *handle) { Tamarack_Device *dev; SANE_Status status; Tamarack_Scanner *s; int i, j; if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; if (!dev) { status = attach (devicename, &dev); if (status != SANE_STATUS_GOOD) return status; } } else { /* empty devicname -> use first device */ dev = first_dev; } if (!dev) return SANE_STATUS_INVAL; s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->fd = -1; s->pipe = -1; s->hw = dev; for (i = 0; i < 4; ++i) for (j = 0; j < 256; ++j) s->gamma_table[i][j] = j; init_options (s); /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Tamarack_Scanner *prev, *s; /* 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) { DBG(1, "close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (s->scanning) do_cancel (handle); if (prev) prev->next = s->next; else first_handle = s->next; free (handle); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Tamarack_Scanner *s = handle; if ((unsigned) option >= NUM_OPTIONS) return 0; return s->opt + option; } static int make_mode (char *mode) { if (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) return THRESHOLDED; if (strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) return DITHERED; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) return GREYSCALE; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) return TRUECOLOR; return -1; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int *info) { Tamarack_Scanner *s = handle; SANE_Status status; SANE_Word cap; if (info) *info = 0; if (s->scanning) return SANE_STATUS_DEVICE_BUSY; if (option >= NUM_OPTIONS) return SANE_STATUS_INVAL; cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) return SANE_STATUS_INVAL; if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_PREVIEW: case OPT_GRAY_PREVIEW: case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_TRANS: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_THRESHOLD: #if 0 case OPT_CUSTOM_GAMMA: #endif *(SANE_Word *) val = s->val[option].w; return SANE_STATUS_GOOD; #if 0 /* word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (val, s->val[option].wa, s->opt[option].size); return SANE_STATUS_GOOD; #endif /* string options: */ case OPT_MODE: strcpy (val, s->val[option].s); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) return SANE_STATUS_INVAL; status = constrain_value (s, option, val, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { /* (mostly) side-effect-free word options: */ case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: if (info) *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_PREVIEW: case OPT_GRAY_PREVIEW: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_THRESHOLD: case OPT_TRANS: s->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; #if 0 /* side-effect-free word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (s->val[option].wa, val, s->opt[option].size); return SANE_STATUS_GOOD; /* options with side-effects: */ case OPT_CUSTOM_GAMMA: w = *(SANE_Word *) val; if (w == s->val[OPT_CUSTOM_GAMMA].w) return SANE_STATUS_GOOD; /* no change */ s->val[OPT_CUSTOM_GAMMA].w = w; if (w) { s->mode = make_mode (s->val[OPT_MODE].s); if (s->mode == GREYSCALE) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; } else if (s->mode == TRUECOLOR) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } else { s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } if (info) *info |= SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; #endif case OPT_MODE: { if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); s->mode = make_mode (s->val[OPT_MODE].s); if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; #if 0 s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; #endif if (strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) == 0) s->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; else { s->opt[OPT_BRIGHTNESS].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; } #if 0 if (!binary) s->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (s->val[OPT_CUSTOM_GAMMA].w) { if (strcmp (val, SANE_VALUE_SCAN_MODE_GRAY) == 0) s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) == 0) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } #endif return SANE_STATUS_GOOD; } } } return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters *params) { Tamarack_Scanner *s = handle; if (!s->scanning) { double width, height, dpi; memset (&s->params, 0, sizeof (s->params)); width = SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w); height = SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w); dpi = SANE_UNFIX (s->val[OPT_RESOLUTION].w); s->mode = make_mode (s->val[OPT_MODE].s); DBG(1, "got mode '%s' -> %d.\n", s->val[OPT_MODE].s, s->mode); /* make best-effort guess at what parameters will look like once scanning starts. */ if (dpi > 0.0 && width > 0.0 && height > 0.0) { double dots_per_mm = dpi / MM_PER_INCH; s->params.pixels_per_line = width * dots_per_mm; s->params.lines = height * dots_per_mm; } if ((s->mode == THRESHOLDED) || (s->mode == DITHERED)) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = (s->params.pixels_per_line + 7) / 8; s->params.depth = 1; } else if (s->mode == GREYSCALE) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; } else { s->params.format = SANE_FRAME_RED + s->pass; s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; } s->pass = 0; } else { if (s->mode == TRUECOLOR) s->params.format = SANE_FRAME_RED + s->pass; } s->params.last_frame = (s->mode != TRUECOLOR) || (s->pass == 2); if (params) *params = s->params; DBG(1, "Got parameters: format:%d, ppl: %d, bpl:%d, depth:%d, " "last %d pass %d\n", s->params.format, s->params.pixels_per_line, s->params.bytes_per_line, s->params.depth, s->params.last_frame, s->pass); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Tamarack_Scanner *s = handle; SANE_Status status; int fds[2]; /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; if (s->fd < 0) { /* translate options into s->mode for convenient access: */ s->mode = make_mode (s->val[OPT_MODE].s); if (s->mode == TRUECOLOR) { if (s->val[OPT_PREVIEW].w && s->val[OPT_GRAY_PREVIEW].w) { /* Force gray-scale mode when previewing. */ s->mode = GREYSCALE; s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->params.last_frame = SANE_TRUE; } } status = sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, 0); if (status != SANE_STATUS_GOOD) { DBG(1, "open: open of %s failed: %s\n", s->hw->sane.name, sane_strstatus (status)); return status; } } status = wait_ready (s->fd); if (status != SANE_STATUS_GOOD) { DBG(1, "open: wait_ready() failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = scan_area_and_windows (s); if (status != SANE_STATUS_GOOD) { DBG(1, "open: set scan area command failed: %s\n", sane_strstatus (status)); goto stop_scanner_and_return; } status = mode_select (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; s->scanning = SANE_TRUE; status = start_scan (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; status = get_image_status (s); if (status != SANE_STATUS_GOOD) goto stop_scanner_and_return; s->line = 0; if (pipe (fds) < 0) return SANE_STATUS_IO_ERROR; s->pipe = fds[0]; s->reader_pipe = fds[1]; s->reader_pid = sanei_thread_begin (reader_process, (void *) s); if (sanei_thread_is_forked()) close (s->reader_pipe); return SANE_STATUS_GOOD; stop_scanner_and_return: do_cancel (s); return status; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { Tamarack_Scanner *s = handle; ssize_t nread; *len = 0; nread = read (s->pipe, buf, max_len); DBG(3, "read %ld bytes\n", (long) nread); if (!s->scanning) return do_cancel (s); if (nread < 0) { if (errno == EAGAIN) { return SANE_STATUS_GOOD; } else { do_cancel (s); return SANE_STATUS_IO_ERROR; } } *len = nread; if (nread == 0) { s->pass++; return do_eof (s); } return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Tamarack_Scanner *s = handle; if (sanei_thread_is_valid (s->reader_pid)) sanei_thread_kill (s->reader_pid); s->scanning = SANE_FALSE; } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Tamarack_Scanner *s = handle; if (!s->scanning) return SANE_STATUS_INVAL; if (fcntl (s->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) return SANE_STATUS_IO_ERROR; return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int *fd) { Tamarack_Scanner *s = handle; if (!s->scanning) return SANE_STATUS_INVAL; *fd = s->pipe; return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/gphoto2.h0000666000000000000000000001155413615534521014331 00000000000000/*************************************************************************** * SANE - Scanner Access Now Easy. gphoto2.h 03/12/01 - Peter Fales Based on the dc210 driver, (C) 1998 Brian J. Murrell (which is based on dc25 driver (C) 1998 by Peter Fales) This file (C) 2001 by Peter Fales 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. *************************************************************************** This file implements a SANE backend for the Kodak DC-240 digital camera. THIS IS EXTREMELY ALPHA CODE! USE AT YOUR OWN RISK!! (feedback to: gphoto2-devel@fales-lorenz.net) This backend is based somewhat on the dc25 backend included in this package by Peter Fales, and the dc210 backend by Brian J. Murrell ***************************************************************************/ #include #include #include #include #include #include #ifndef TRUE #define TRUE (1==1) #endif #ifndef FALSE #define FALSE (!TRUE) #endif #ifndef NULL #define NULL 0L #endif typedef struct picture_info { int low_res; int size; } PictureInfo; typedef struct GPHOTO2_s { SANE_String port; /* the port name it's on */ SANE_Int speed; /* current port speed */ SANE_String camera_name; SANE_Bool scanning; /* currently scanning an image? */ SANE_Byte model; SANE_Byte ver_major; SANE_Byte ver_minor; SANE_Int pic_taken; SANE_Int pic_left; struct { unsigned int low_res:1; unsigned int low_batt:1; } flags; PictureInfo *Pictures; /* array of pictures */ SANE_Int current_picture_number; /* picture being operated on */ } GPHOTO2; typedef struct gphoto2_info_s { SANE_Byte model; SANE_Byte ver_major; SANE_Byte ver_minor; SANE_Int pic_taken; SANE_Int pic_left; struct { SANE_Int low_res:1; SANE_Int low_batt:1; } flags; } Gphoto2Info, *Gphoto2InfoPtr; static SANE_Int get_info (void); #define HIGH_RES 0 #define LOW_RES 1 #define HIGHRES_WIDTH highres_width #define HIGHRES_HEIGHT highres_height #define LOWRES_WIDTH lowres_width #define LOWRES_HEIGHT lowres_height #define THUMB_WIDTH thumb_width #define THUMB_HEIGHT thumb_height /* * External definitions */ extern char *__progname; /* Defined in /usr/lib/crt0.o */ struct cam_dirent { SANE_Char name[11]; SANE_Byte attr; SANE_Byte create_time[2]; SANE_Byte creat_date[2]; long size; }; struct cam_dirlist { SANE_Char name[48]; struct cam_dirlist *next; }; #include FILE *sanei_config_open (const char *filename); static SANE_Int init_gphoto2 (void); static void close_gphoto2 (void); static PictureInfo *get_pictures_info (void); static SANE_Int get_picture_info (PictureInfo * pic, SANE_Int p); static SANE_Status snap_pic (void); char *sanei_config_read (char *str, int n, FILE * stream); static SANE_Int read_dir (SANE_String dir, SANE_Bool read_files); static void set_res (SANE_Int lowres); static SANE_Int read_info (SANE_String_Const fname); static SANE_Status converter_do_scan_complete_cleanup (void); static SANE_Int converter_fill_buffer (void); static SANE_Bool converter_scan_complete (void); static SANE_Status converter_init (SANE_Handle handle); sane-backends-1.0.29/backend/gphoto2.c0000666000000000000000000014046113615534521014324 00000000000000/* Please note! Although intended to support multiple camera types * it's been tested with only cameras I have access to: the Kodak DC240 * and the Directory Browse "camera." I'm very interested * in learning what it would take to support more cameras. In * particular, the current incarnation will only support cameras * that directly generate jpeg files. * * Please report sucesses or failures using this backend! * * However, having said that, I've already found it to be quite useful * even in its current form - one reason is that gphoto2 provides access * to the camera via USB which is not supported by the regular DC240 * backend and is dramatically faster than the serial port. */ /*************************************************************************** * _S_A_N_E - Scanner Access Now Easy. gphoto2.c 03/12/01 - Peter Fales Based on the dc210 driver, (C) 1998 Brian J. Murrell (which is based on dc25 driver (C) 1998 by Peter Fales) This file (C) 2001 by Peter Fales 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. *************************************************************************** This file implements a SANE backend for digital cameras supported by the gphoto2 libraries. THIS IS EXTREMELY ALPHA CODE! USE AT YOUR OWN RISK!! (feedback to: gphoto2-devel@fales-lorenz.net) This backend is based somewhat on the dc25 backend included in this package by Peter Fales, and the dc210 backend by Brian J. Murrell ***************************************************************************/ #include "../include/sane/config.h" #include #include #include #include #include #include #include "../include/sane/sanei_jpeg.h" #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #define BACKEND_NAME gphoto2 #include "../include/sane/sanei_backend.h" /* PSF 1/12/02 - gphoto2.h does a #include of config.h. We don't have * config.h by that name (we call it sane/config.h), so the #undef of * HAVE_CONFIG_H will cause it to skip that. */ #undef HAVE_CONFIG_H #include "gphoto2.h" #include #include #define CHECK_RET(f) {int res = f; if (res < 0) {DBG (1,"ERROR: %s\n", gp_result_as_string (res)); return (SANE_STATUS_INVAL);}} #ifndef PATH_MAX # define PATH_MAX 1024 #endif #define MAGIC (void *)0xab730324 #define GPHOTO2_CONFIG_FILE "gphoto2.conf" static SANE_Bool is_open = 0; /* Options selected by frontend: */ static SANE_Bool gphoto2_opt_thumbnails; /* Read thumbnails */ static SANE_Bool gphoto2_opt_snap; /* Take new picture */ static SANE_Bool gphoto2_opt_lowres; /* Set low resolution */ static SANE_Bool gphoto2_opt_erase; /* Erase after downloading */ static SANE_Bool gphoto2_opt_autoinc; /* Increment image number */ static SANE_Bool dumpinquiry; /* Dump status info */ /* Used for jpeg decompression */ static struct jpeg_decompress_struct cinfo; static djpeg_dest_ptr dest_mgr = NULL; static SANE_Int highres_height = 960, highres_width = 1280; static SANE_Int thumb_height = 120, thumb_width = 160; static SANE_String TopFolder; /* Fixed part of path strings */ static SANE_Int SubDirs = 1; /* Search for Sub directories */ static GPHOTO2 Cam_data; /* Other camera data */ static SANE_Range image_range = { 0, 0, 0 }; static SANE_String *folder_list; static SANE_Int current_folder = 0; static SANE_Option_Descriptor sod[] = { { SANE_NAME_NUM_OPTIONS, SANE_TITLE_NUM_OPTIONS, SANE_DESC_NUM_OPTIONS, SANE_TYPE_INT, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define GPHOTO2_OPT_IMAGE_SELECTION 1 { "", "Image Selection", "Selection of the image to load.", SANE_TYPE_GROUP, SANE_UNIT_NONE, 0, 0, SANE_CONSTRAINT_NONE, {NULL} } , #define GPHOTO2_OPT_FOLDER 2 { "folder", "Folder", "Select folder within camera", SANE_TYPE_STRING, SANE_UNIT_NONE, 256, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_STRING_LIST, {NULL} } , #define GPHOTO2_OPT_IMAGE_NUMBER 3 { "image", "Image Number", "Select Image Number to load from camera", SANE_TYPE_INT, SANE_UNIT_NONE, 4, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(SANE_String_Const *) & image_range} /* this is ANSI conformant! */ } , #define GPHOTO2_OPT_THUMBS 4 { "thumbs", "Load Thumbnail", "Load the image as thumbnail.", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define GPHOTO2_OPT_SNAP 5 { "snap", "Snap new picture", "Take new picture and download it", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT /* | SANE_CAP_ADVANCED */ , SANE_CONSTRAINT_NONE, {NULL} } , #define GPHOTO2_OPT_LOWRES 6 { "lowres", "Low Resolution", "Resolution of new picture or selected image (must be manually specified)", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE /* Until we figure out how to support it */ /* | SANE_CAP_ADVANCED */ , SANE_CONSTRAINT_NONE, {NULL} } , #define GPHOTO2_OPT_ERASE 7 { "erase", "Erase", "Erase the picture after downloading", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define GPHOTO2_OPT_DEFAULT 8 { "default-enhancements", "Defaults", "Set default values for enhancement controls.", SANE_TYPE_BUTTON, SANE_UNIT_NONE, 0, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define GPHOTO2_OPT_INIT_GPHOTO2 9 { "camera-init", "Re-establish Communications", "Re-establish communications with camera (in case of timeout, etc.)", SANE_TYPE_BUTTON, SANE_UNIT_NONE, 0, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define GPHOTO2_OPT_AUTOINC 10 { "autoinc", "Auto Increment", "Increment image number after each scan", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED, SANE_CONSTRAINT_NONE, {NULL} } , }; static SANE_Parameters parms = { SANE_FRAME_RGB, 0, 0, /* Number of bytes returned per scan line: */ 0, /* Number of pixels per scan line. */ 0, /* Number of lines for the current scan. */ 8, /* Number of bits per sample. */ }; CameraList *dir_list; Camera *camera; /* Buffer to hold line currently being processed by sane_read */ static SANE_Byte *linebuffer = NULL; static SANE_Int linebuffer_size = 0; static SANE_Int linebuffer_index = 0; /* used for setting up commands */ static SANE_Char cmdbuf[256]; /* Structures used by gphoto2 API */ static CameraAbilities abilities; static CameraFile *data_file; static const unsigned char *data_ptr; static unsigned long data_file_total_size, data_file_current_index; static SANE_Int hack_fd; #include #include /* Device select/open/close */ static SANE_Device dev[] = { { "0", "Gphoto2", "Supported", "still camera"}, }; static const SANE_Device *devlist[] = { dev + 0, 0 }; /* * 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 __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"); } /* * init_gphoto2() - Initialize interface to camera using gphoto2 API */ static SANE_Int init_gphoto2 (void) { CameraList *list; GPPortInfoList *il; GPPortInfo info; SANE_Int n, m, port; CameraAbilitiesList *al; gp_log (GP_LOG_VERBOSE, "SANE", "Initializing\n"); if (!Cam_data.camera_name) { DBG (0, "init_gphoto2: Camera name not specified in config file\n"); return SANE_STATUS_INVAL; } if (camera) { /* * We get here if re-initializing the camera: either because * the user clicked the "re-establish" button, or we need to * recalculate the number of photos after taking a picture. * We must release the old camera before starting over. */ CHECK_RET (gp_camera_unref (camera)); } CHECK_RET (gp_camera_new (&camera)); CHECK_RET (gp_abilities_list_new (&al)); CHECK_RET (gp_abilities_list_load (al, NULL)); CHECK_RET (m = gp_abilities_list_lookup_model (al, (char *) Cam_data.camera_name)); CHECK_RET (gp_abilities_list_get_abilities (al, m, &abilities)); CHECK_RET (gp_abilities_list_free (al)); CHECK_RET (gp_camera_set_abilities (camera, abilities)); if (!Cam_data.port) { DBG (0, "init_gphoto2: Camera port not specified in config file\n"); return SANE_STATUS_INVAL; } CHECK_RET (gp_port_info_list_new (&il)); CHECK_RET (gp_port_info_list_load (il)); if (strcmp (Cam_data.port, "Browse") != 0) { CHECK_RET (port = gp_port_info_list_lookup_path (il, Cam_data.port)); CHECK_RET (gp_port_info_list_get_info (il, port, &info)); CHECK_RET (gp_camera_set_port_info (camera, info)); gp_port_info_list_free (il); } for (n = 0; abilities.speed[n]; n++) { if (abilities.speed[n] == Cam_data.speed) { break; } } if (abilities.speed[n] == 0 && !strncmp (Cam_data.port, "serial:", 7)) { DBG (0, "%s: error: %d is not a valid speed for this camers. Use \"gphoto2 --camera \"%s\" --abilities\" for list.\n", "init_gphoto2", Cam_data.speed, Cam_data.camera_name); return SANE_STATUS_INVAL; } DBG (4, "init_gphoto2: about to initialize port\n"); /* * Setting of speed only makes sense for serial ports. gphoto2 * knows that and will complain if we try to set the speed for * ports other than serial ones. Because we are paranoid here and * check every single error message returned by gphoto2, we need * to make sure that we have a serial port. */ if (Cam_data.speed && !strncmp (Cam_data.port, "serial:", 7)) { /* * Not sure why we need this hack. The API keeps opening/closing * the port, and that seems to confuse the camera. Holding * the port open seems to fix it. */ if ((hack_fd = open (Cam_data.port + 7, O_RDONLY)) < 0) { return SANE_STATUS_INVAL; } #ifdef HAVE_USLEEP usleep (200); #else sleep (1); #endif CHECK_RET (gp_camera_set_port_speed (camera, Cam_data.speed)); } CHECK_RET (gp_camera_init (camera, NULL)); if (!(abilities.operations & GP_OPERATION_CAPTURE_IMAGE)) { DBG (20, "init_gphoto2: Camera does not support image capture\n"); sod[GPHOTO2_OPT_SNAP].cap |= SANE_CAP_INACTIVE; } if (!(abilities.file_operations & GP_FILE_OPERATION_PREVIEW)) { DBG (20, "init_gphoto2: Camera does not support image preview\n"); sod[GPHOTO2_OPT_THUMBS].cap |= SANE_CAP_INACTIVE; } if (!(abilities.file_operations & GP_FILE_OPERATION_DELETE)) { DBG (20, "init_gphoto2: Camera does not support image deletion\n"); sod[GPHOTO2_OPT_ERASE].cap |= SANE_CAP_INACTIVE; } DBG (4, "init_gphoto2: about to get folders\n"); CHECK_RET (gp_list_new (&list)); CHECK_RET (gp_camera_folder_list_folders (camera, TopFolder, list, NULL)); n = gp_list_count (list); if (n < 0) { DBG (0, "init_gphoto2: Unable to get file list\n"); return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /* * close_gphoto2() - Shutdown camera interface */ static void close_gphoto2 (void) { /* * Put the camera back to 9600 baud */ if (gp_camera_unref (camera)) { DBG (1, "close_gphoto2: error: could not close device\n"); } camera = NULL; close (hack_fd); } /* * get_info() - Get overall information about camera: folder names, * number of pictures, etc. */ SANE_Int get_info (void) { SANE_String_Const val; SANE_Int n; if (Cam_data.pic_taken == 0) { sod[GPHOTO2_OPT_IMAGE_NUMBER].cap |= SANE_CAP_INACTIVE; image_range.min = 0; image_range.max = 0; } else { sod[GPHOTO2_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; image_range.min = 1; image_range.max = Cam_data.pic_taken; } if (SubDirs) { n = read_dir (TopFolder, 0); } else { n = 1; } /* If we've already got a folder_list, free it up before starting * the new one */ if (folder_list != NULL) { int tmp; for (tmp = 0; folder_list[tmp]; tmp++) { free (folder_list[tmp]); } free (folder_list); } folder_list = (SANE_String *) malloc ((n + 1) * sizeof (SANE_String_Const *)); if (SubDirs) { for (n = 0; n < gp_list_count (dir_list); n++) { gp_list_get_name (dir_list, n, &val); folder_list[n] = strdup (val); if (strchr ((const char *) folder_list[n], ' ')) { *strchr ((const char *) folder_list[n], ' ') = '\0'; } } if (n == 0) { folder_list[n++] = (SANE_String) strdup (""); } } else { n = 0; folder_list[n++] = "N/A"; } folder_list[n] = NULL; sod[GPHOTO2_OPT_FOLDER].constraint.string_list = (SANE_String_Const *) folder_list; Cam_data.pic_taken = 0; Cam_data.pic_left = 1; /* Just a guess! */ return SANE_STATUS_GOOD; } /* * erase() - erase file from camera corresponding to * current picture number. Does not update any of the other * backend data structures. */ static SANE_Int erase (void) { SANE_String_Const filename; if (SubDirs) { sprintf (cmdbuf, "%s/%s", (char *) TopFolder, (const char *) folder_list[current_folder]); } else { strcpy (cmdbuf, TopFolder); } CHECK_RET (gp_list_get_name (dir_list, Cam_data.current_picture_number - 1, &filename)); CHECK_RET (gp_camera_file_delete (camera, cmdbuf, filename, NULL)); return SANE_STATUS_GOOD; } /* * change_res() - FIXME: Would like to set resolution, but haven't figure * out how to control that yet. */ static SANE_Int change_res (SANE_Byte res) { return (res - res); } /* * sane_init() - Initialization function from SANE API. Initialize some * data structures, verify that all the necessary config information * is present, and initialize gphoto2 */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { SANE_Int n, entries; SANE_Char f[] = "sane_init"; SANE_Char dev_name[PATH_MAX], *p; SANE_Char buf[256]; CameraAbilitiesList *al; size_t len; FILE *fp; DBG_INIT (); DBG (1, "GPHOTO2 Backend $Id$\n"); if (getenv ("GP_DEBUG")) { gp_log_add_func (atoi (getenv ("GP_DEBUG")), debug_func, NULL); } if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (GPHOTO2_CONFIG_FILE); if (!fp) { /* Earlier versions why would try to keep going with compiled in * defaults if the config file is missing. But, now we have so * options and combinations of options, that success without a config * file is unlikely. So, give and return failure */ DBG (0, "warning: %s: missing config file '%s'\n" "If you aren't using gphoto2, you should disable it in dll.conf.\n" "If you do want to use gphoto2, you'll need to install the config\n" "file in %s.\n", f, GPHOTO2_CONFIG_FILE, GPHOTO2_CONFIG_FILE); return SANE_STATUS_INVAL; } else { while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { dev_name[sizeof (dev_name) - 1] = '\0'; DBG (20, "%s: config- %s\n", f, dev_name); if (dev_name[0] == '#') continue; /* ignore line comments */ len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ if (strncmp (dev_name, "port=", 5) == 0) { GPPortInfoList *list; GPPortInfo info; int result; p = dev_name + 5; if (p) Cam_data.port = strdup (p); DBG (20, "Config file port=%s\n", Cam_data.port); /* Validate port */ CHECK_RET (gp_port_info_list_new (&list)); result = gp_port_info_list_load (list); if (result < 0) { gp_port_info_list_free (list); return SANE_STATUS_INVAL; } entries = gp_port_info_list_count (list); if (entries < 0) { gp_port_info_list_free (list); return SANE_STATUS_INVAL; } for (n = 0; n < entries; n++) { #ifdef HAVE_GP_PORT_INFO_GET_PATH char *info_path = NULL; #endif result = gp_port_info_list_get_info (list, n, &info); if (result < 0) { gp_port_info_list_free (list); return SANE_STATUS_INVAL; } #ifdef HAVE_GP_PORT_INFO_GET_PATH gp_port_info_get_path (info, &info_path); if (strcmp (Cam_data.port, info_path) == 0) #else if (strcmp (Cam_data.port, info.path) == 0) #endif { break; } } if (n == entries) { DBG (0, "%s: error: %s is not a valid gphoto2 port. Use \"gphoto2 --list-ports\" for list.\n", "init_gphoto2", Cam_data.port); return SANE_STATUS_INVAL; } } else if (strncmp (dev_name, "camera=", 7) == 0) { Cam_data.camera_name = strdup (dev_name + 7); DBG (20, "Config file camera=%s\n", Cam_data.camera_name); sprintf (buf, "Image selection - %s", Cam_data.camera_name); CHECK_RET (gp_abilities_list_new (&al)); CHECK_RET (gp_abilities_list_load (al, NULL)); CHECK_RET (entries = gp_abilities_list_count (al)); for (n = 0; n < entries; n++) { CHECK_RET (gp_abilities_list_get_abilities (al, n, &abilities)); if (strcmp (Cam_data.camera_name, abilities.model) == 0) { break; } } if (n == entries) { DBG (0, "%s: error: %s is not a valid camera type. Use \"gphoto2 --list-cameras\" for list.\n", f, Cam_data.camera_name); return SANE_STATUS_INVAL; } /* Special case: Force port to special value for the * "Directory Browse" camera - overriding anything in * the config file - or more likely when not specified * in the config file. */ if (strcmp (Cam_data.camera_name, "Directory Browse") == 0) { Cam_data.port = "Browse"; } sod[GPHOTO2_OPT_IMAGE_SELECTION].title = strdup (buf); } else if (strcmp (dev_name, "dumpinquiry") == 0) { dumpinquiry = SANE_TRUE; } else if (strncmp (dev_name, "speed=", 6) == 0) { sscanf (&dev_name[6], "%d", &Cam_data.speed); DBG (20, "Config file speed=%u\n", Cam_data.speed); } else if (strncmp (dev_name, "resolution=", 11) == 0) { sscanf (&dev_name[11], "%dx%d", &highres_width, &highres_height); DBG (20, "Config file resolution=%ux%u\n", highres_width, highres_height); } else if (strncmp (dev_name, "thumb_resolution=", 17) == 0) { sscanf (&dev_name[17], "%dx%d", &thumb_width, &thumb_height); DBG (20, "Config file thumb_resolution=%ux%u\n", thumb_width, thumb_height); } else if (strncmp (dev_name, "topfolder=", 10) == 0) { /* Make sure TopFolder is non-null */ if (strlen (dev_name) > 10) { TopFolder = strdup (&dev_name[10]); DBG (20, "Config file topfolder=%s\n", TopFolder); } } else if (strncmp (dev_name, "subdirs=", 8) == 0) { SubDirs = atoi (&dev_name[8]); if (SubDirs == 0) { sod[GPHOTO2_OPT_FOLDER].cap |= SANE_CAP_INACTIVE; } DBG (20, "Config file subdirs=%d\n", SubDirs); } } fclose (fp); } DBG (3, "sane_init: about to init_gphoto2\n"); if (init_gphoto2 () != SANE_STATUS_GOOD) return SANE_STATUS_INVAL; dev[0].name = strdup (Cam_data.port); DBG (3, "sane_init: about to get_info\n"); if (get_info () != SANE_STATUS_GOOD) { DBG (1, "error: could not get info\n"); close_gphoto2 (); return SANE_STATUS_INVAL; } /* load the current images array */ DBG (3, "sane_init: about to get_pictures_info\n"); get_pictures_info (); if (Cam_data.pic_taken == 0) { Cam_data.current_picture_number = 0; parms.bytes_per_line = 0; parms.pixels_per_line = 0; parms.lines = 0; } else { Cam_data.current_picture_number = 1; /* OLD: set_res (Cam_data.Pictures[Cam_data.current_picture_number - 1].low_res); */ set_res (gphoto2_opt_lowres); } if (dumpinquiry) { SANE_Int x = 0; DBG (0, "\nCamera information:\n~~~~~~~~~~~~~~~~~\n\n"); DBG (0, "Model : %s\n", abilities.model); DBG (0, "Pictures : %d\n", Cam_data.pic_taken); DBG (0, "Serial port support : %s\n", (abilities.port & GP_PORT_SERIAL) ? "yes" : "no"); DBG (0, "USB support : %s\n", (abilities.port & GP_PORT_USB) ? "yes" : "no"); if (abilities.speed[0] != 0) { DBG (0, "Transfer speeds supported :\n"); do { DBG (0, " : %i\n", abilities.speed[x]); x++; } while (abilities.speed[x] != 0); } DBG (0, "Capture choices :\n"); if (abilities.operations & GP_OPERATION_CAPTURE_IMAGE) DBG (0, " : Image\n"); if (abilities.operations & GP_OPERATION_CAPTURE_VIDEO) DBG (0, " : Video\n"); if (abilities.operations & GP_OPERATION_CAPTURE_AUDIO) DBG (0, " : Audio\n"); if (abilities.operations & GP_OPERATION_CAPTURE_PREVIEW) DBG (0, " : Preview\n"); DBG (0, "Configuration support : %s\n", abilities.operations & GP_OPERATION_CONFIG ? "yes" : "no"); DBG (0, "Delete files on camera support : %s\n", abilities. file_operations & GP_FILE_OPERATION_DELETE ? "yes" : "no"); DBG (0, "File preview (thumbnail) support : %s\n", abilities. file_operations & GP_FILE_OPERATION_PREVIEW ? "yes" : "no"); DBG (0, "File upload support : %s\n", abilities. folder_operations & GP_FOLDER_OPERATION_PUT_FILE ? "yes" : "no"); } return SANE_STATUS_GOOD; } /* * sane_exit() - Required by SANE API. */ void sane_exit (void) { close_gphoto2 (); } /* * sane_get_devices() - From SANE API */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { DBG (127, "sane_get_devices called\n"); *device_list = devlist; return SANE_STATUS_GOOD; } /* * sane_open() - From SANE API */ SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { SANE_Int i; DBG (127, "sane_open for device %s\n", devicename); if (!devicename[0]) { i = 0; } else { for (i = 0; i < NELEMS (dev); ++i) { if (strcmp (devicename, dev[i].name) == 0) { break; } } } if (i >= NELEMS (dev)) { return SANE_STATUS_INVAL; } if (is_open) { return SANE_STATUS_DEVICE_BUSY; } is_open = 1; *handle = MAGIC; DBG (4, "sane_open: pictures taken=%d\n", Cam_data.pic_taken); return SANE_STATUS_GOOD; } /* * sane_close() - From SANE API */ void sane_close (SANE_Handle handle) { DBG (127, "sane_close called\n"); if (handle == MAGIC) is_open = 0; DBG (127, "sane_close returning\n"); } /* * sane_get_option_descriptor() - From SANE API */ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { if (handle != MAGIC || !is_open) return NULL; /* wrong device */ if (option < 0 || option >= NELEMS (sod)) return NULL; return &sod[option]; } static SANE_Int myinfo = 0; /* * sane_control_option() - From SANE API */ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { SANE_Status status; if (option < 0 || option >= NELEMS (sod)) return SANE_STATUS_INVAL; /* Unknown option ... */ /* Need to put this DBG line after the range check on option */ DBG (127, "control_option(handle=%p,opt=%s,act=%s,val=%p,info=%p)\n", handle, sod[option].title, (action == SANE_ACTION_SET_VALUE ? "SET" : (action == SANE_ACTION_GET_VALUE ? "GET" : "SETAUTO")), value, (void *) info); if (handle != MAGIC || !is_open) return SANE_STATUS_INVAL; /* Unknown handle ... */ if (option < 0 || option >= NELEMS (sod)) return SANE_STATUS_INVAL; /* Unknown option ... */ switch (action) { case SANE_ACTION_SET_VALUE: /* Can't set disabled options */ if (!SANE_OPTION_IS_ACTIVE (sod[option].cap)) { return (SANE_STATUS_INVAL); } /* initialize info to zero - we'll OR in various values later */ if (info) *info = 0; status = sanei_constrain_value (sod + option, value, &myinfo); if (status != SANE_STATUS_GOOD) { DBG (2, "Constraint error in control_option\n"); return status; } switch (option) { case GPHOTO2_OPT_IMAGE_NUMBER: if (*(SANE_Word *) value <= Cam_data.pic_taken) Cam_data.current_picture_number = *(SANE_Word *) value; else Cam_data.current_picture_number = Cam_data.pic_taken; /* * Setting a new image number could change image size (if * we supported that - which we hope to do someday! */ myinfo |= SANE_INFO_RELOAD_PARAMS; /* get the image's resolution, unless the camera has no * pictures yet */ if (Cam_data.pic_taken != 0) { /* OLD: set_res (Cam_data. Pictures[Cam_data.current_picture_number - 1].low_res); */ set_res (gphoto2_opt_lowres); } break; case GPHOTO2_OPT_THUMBS: gphoto2_opt_thumbnails = !!*(SANE_Word *) value; /* Thumbnail forces an image size change: */ myinfo |= SANE_INFO_RELOAD_PARAMS; if (Cam_data.pic_taken != 0) { /* OLD: set_res (Cam_data. Pictures[Cam_data.current_picture_number - 1].low_res); */ set_res (gphoto2_opt_lowres); } break; case GPHOTO2_OPT_SNAP: switch (*(SANE_Bool *) value) { case SANE_TRUE: gphoto2_opt_snap = SANE_TRUE; break; case SANE_FALSE: gphoto2_opt_snap = SANE_FALSE; break; default: return SANE_STATUS_INVAL; } /* Snap forces new image size and changes image range */ myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; /* if we are snapping a new one */ if (gphoto2_opt_snap) { /* activate the resolution setting */ /* Until we figure out how to do this sod[GPHOTO2_OPT_LOWRES].cap &= ~SANE_CAP_INACTIVE; */ /* and de-activate the image number selector */ sod[GPHOTO2_OPT_IMAGE_NUMBER].cap |= SANE_CAP_INACTIVE; } else { /* deactivate the resolution setting */ sod[GPHOTO2_OPT_LOWRES].cap |= SANE_CAP_INACTIVE; /* and activate the image number selector, if there are * pictures available */ if (Cam_data.current_picture_number) { sod[GPHOTO2_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; } } /* set params according to resolution settings */ set_res (gphoto2_opt_lowres); break; case GPHOTO2_OPT_LOWRES: gphoto2_opt_lowres = !!*(SANE_Word *) value; /* Lowres potentially changes image size */ myinfo |= SANE_INFO_RELOAD_PARAMS; /* FIXME - change the number of pictures left depending on resolution perhaps just call get_info again? */ set_res (gphoto2_opt_lowres); break; case GPHOTO2_OPT_ERASE: gphoto2_opt_erase = !!*(SANE_Word *) value; break; case GPHOTO2_OPT_AUTOINC: gphoto2_opt_autoinc = !!*(SANE_Word *) value; break; case GPHOTO2_OPT_FOLDER: DBG (1, "FIXME set folder not implemented yet\n"); break; case GPHOTO2_OPT_DEFAULT: gphoto2_opt_thumbnails = 0; gphoto2_opt_snap = 0; /* deactivate the resolution setting */ sod[GPHOTO2_OPT_LOWRES].cap |= SANE_CAP_INACTIVE; /* and activate the image number selector */ sod[GPHOTO2_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; DBG (1, "FIXME: Set all defaults here!\n"); break; case GPHOTO2_OPT_INIT_GPHOTO2: if (init_gphoto2 () != SANE_STATUS_GOOD) { return SANE_STATUS_INVAL; } if (get_info () != SANE_STATUS_GOOD) { DBG (1, "error: could not get info\n"); close_gphoto2 (); return SANE_STATUS_INVAL; } /* load the current images array */ get_pictures_info (); myinfo |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_GET_VALUE: /* Can't return status for disabled options */ if (!SANE_OPTION_IS_ACTIVE (sod[option].cap)) { return (SANE_STATUS_INVAL); } switch (option) { case 0: *(SANE_Word *) value = NELEMS (sod); break; case GPHOTO2_OPT_IMAGE_NUMBER: *(SANE_Word *) value = Cam_data.current_picture_number; break; case GPHOTO2_OPT_THUMBS: *(SANE_Word *) value = gphoto2_opt_thumbnails; break; case GPHOTO2_OPT_SNAP: *(SANE_Word *) value = gphoto2_opt_snap; break; case GPHOTO2_OPT_LOWRES: *(SANE_Word *) value = gphoto2_opt_lowres; break; case GPHOTO2_OPT_ERASE: *(SANE_Word *) value = gphoto2_opt_erase; break; case GPHOTO2_OPT_AUTOINC: *(SANE_Word *) value = gphoto2_opt_autoinc; break; case GPHOTO2_OPT_FOLDER: if (folder_list == NULL) { return SANE_STATUS_INVAL; } strncpy ((char *) value, (const char *) folder_list[current_folder], 256); break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_AUTO: switch (option) { default: return SANE_STATUS_UNSUPPORTED; /* We are DUMB */ } } if (info && action == SANE_ACTION_SET_VALUE) { *info = myinfo; myinfo = 0; } return SANE_STATUS_GOOD; } /* * sane_get_parameters() - From SANE API */ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { SANE_Int rc = SANE_STATUS_GOOD; DBG (127, "sane_get_params called, wid=%d,height=%d\n", parms.pixels_per_line, parms.lines); if (handle != MAGIC || !is_open) rc = SANE_STATUS_INVAL; /* Unknown handle ... */ parms.last_frame = SANE_TRUE; /* Have no idea what this does */ *params = parms; DBG (127, "sane_get_params return %d\n", rc); return rc; } typedef struct { struct jpeg_source_mgr pub; JOCTET *buffer; } my_source_mgr; typedef my_source_mgr *my_src_ptr; METHODDEF (void) jpeg_init_source (j_decompress_ptr __sane_unused__ cinfo) { /* nothing to do */ } METHODDEF (boolean) jpeg_fill_input_buffer (j_decompress_ptr cinfo) { int n; my_src_ptr src = (my_src_ptr) cinfo->src; if (data_file_current_index + 512 > data_file_total_size) { n = data_file_total_size - data_file_current_index; } else { n = 512; } memcpy (src->buffer, data_ptr + data_file_current_index, n); data_file_current_index += n; src->pub.next_input_byte = src->buffer; src->pub.bytes_in_buffer = n; return TRUE; } METHODDEF (void) jpeg_skip_input_data (j_decompress_ptr cinfo, long num_bytes) { my_src_ptr src = (my_src_ptr) cinfo->src; if (num_bytes > 0) { while (num_bytes > (long) src->pub.bytes_in_buffer) { num_bytes -= (long) src->pub.bytes_in_buffer; (void) jpeg_fill_input_buffer (cinfo); } } src->pub.next_input_byte += (size_t) num_bytes; src->pub.bytes_in_buffer -= (size_t) num_bytes; } METHODDEF (void) jpeg_term_source (j_decompress_ptr __sane_unused__ cinfo) { /* no work necessary here */ } /* * sane_start() - From SANE API */ SANE_Status sane_start (SANE_Handle handle) { SANE_String_Const filename, mime_type; DBG (127, "sane_start called\n"); if (handle != MAGIC || !is_open || (Cam_data.current_picture_number == 0 && gphoto2_opt_snap == SANE_FALSE)) return SANE_STATUS_INVAL; /* Unknown handle ... */ if (Cam_data.scanning) return SANE_STATUS_EOF; /* * This shouldn't normally happen, but we allow it as a special case * when batch/autoinc are in effect. The first illegal picture number * terminates the scan */ if (Cam_data.current_picture_number > Cam_data.pic_taken) { return SANE_STATUS_INVAL; } if (gphoto2_opt_snap) { /* * Don't allow picture unless there is room in the * camera. */ if (Cam_data.pic_left == 0) { DBG (3, "No room to store new picture\n"); return SANE_STATUS_INVAL; } if (snap_pic () == SANE_STATUS_INVAL) { DBG (1, "Failed to snap new picture\n"); return SANE_STATUS_INVAL; } } DBG (4, "sane_start: about to get file\n"); CHECK_RET (gp_file_new (&data_file)); if (SubDirs) { sprintf (cmdbuf, "%s/%s", (char *) TopFolder, (const char *) folder_list[current_folder]); } else { strcpy (cmdbuf, TopFolder); } CHECK_RET (gp_list_get_name (dir_list, Cam_data.current_picture_number - 1, &filename)); CHECK_RET (gp_camera_file_get (camera, cmdbuf, filename, gphoto2_opt_thumbnails ? GP_FILE_TYPE_PREVIEW : GP_FILE_TYPE_NORMAL, data_file, NULL)); CHECK_RET (gp_file_get_mime_type (data_file, &mime_type)); if (strcmp (GP_MIME_JPEG, mime_type) != 0) { DBG (0, "FIXME - Only jpeg files currently supported, can't do %s for file %s/%s\n", mime_type, cmdbuf, filename); return SANE_STATUS_INVAL; } CHECK_RET (gp_file_get_data_and_size (data_file, (const char **)&data_ptr, &data_file_total_size)); if ( converter_init (handle) != SANE_STATUS_GOOD ) return SANE_STATUS_INVAL; /* Check if a linebuffer has been allocated. If we had one * previously, free it up and allocate one for (possibly) new * size. parms.bytes_per_line is set by converter_init() */ if (linebuffer == NULL) { linebuffer = malloc (parms.bytes_per_line); } else { free (linebuffer); linebuffer = malloc (parms.bytes_per_line); } if (linebuffer == NULL) { return SANE_STATUS_INVAL; } Cam_data.scanning = SANE_TRUE; /* don't overlap scan requests */ return SANE_STATUS_GOOD; } /* * sane_read() - From SANE API */ SANE_Status sane_read (SANE_Handle __sane_unused__ handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { if (Cam_data.scanning == SANE_FALSE) { return SANE_STATUS_INVAL; } /* If there is anything in the buffer, satisfy the read from there */ if (linebuffer_size && linebuffer_index < linebuffer_size) { *length = linebuffer_size - linebuffer_index; if (*length > max_length) { *length = max_length; } memcpy (data, linebuffer + linebuffer_index, *length); linebuffer_index += *length; return SANE_STATUS_GOOD; } if (converter_scan_complete ()) { SANE_Status retval; *length = 0; retval = converter_do_scan_complete_cleanup (); if (retval != SANE_STATUS_GOOD) { return retval; } } *length = converter_fill_buffer (); linebuffer_size = *length; linebuffer_index = 0; if (*length > max_length) { *length = max_length; } memcpy (data, linebuffer + linebuffer_index, *length); linebuffer_index += *length; return SANE_STATUS_GOOD; } /* * sane_cancel() - From SANE API */ void sane_cancel (SANE_Handle __sane_unused__ handle) { if (Cam_data.scanning) { Cam_data.scanning = SANE_FALSE; /* done with scan */ } else DBG (4, "sane_cancel: not scanning - nothing to do\n"); } /* * sane_set_io_mode() - From SANE API */ SANE_Status 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) { if (non_blocking == SANE_FALSE) { return SANE_STATUS_GOOD; } else { return SANE_STATUS_UNSUPPORTED; } } else { /* We aren't currently scanning */ return SANE_STATUS_INVAL; } } /* * sane_get_select_fd() - From SANE API */ SANE_Status sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { return SANE_STATUS_UNSUPPORTED; } /* * get_pictures_info - load information about all pictures currently in * camera: Mainly the mapping of picture number * to picture name. We'ld like to get other * information such as image size, but the API * doesn't provide any support for that. */ static PictureInfo * get_pictures_info (void) { SANE_Char f[] = "get_pictures_info"; SANE_Char path[256]; SANE_Int num_pictures; SANE_Int p; PictureInfo *pics; if (Cam_data.Pictures) { free (Cam_data.Pictures); Cam_data.Pictures = NULL; } strcpy (path, TopFolder); if (SubDirs) { if (folder_list[current_folder] != NULL) { strcat (path, "/"); strcat (path, (const char *) folder_list[current_folder]); } } num_pictures = read_dir (path, 1); Cam_data.pic_taken = num_pictures; if (num_pictures > 0) { sod[GPHOTO2_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; image_range.min = 1; image_range.max = num_pictures; } if ((pics = (PictureInfo *) malloc (Cam_data.pic_taken * sizeof (PictureInfo))) == NULL) { DBG (1, "%s: error: allocate memory for pictures array\n", f); return NULL; } for (p = 0; p < Cam_data.pic_taken; p++) { if (get_picture_info (pics + p, p) == -1) { free (pics); return NULL; } } Cam_data.Pictures = pics; return pics; } /* * get_picture_info() - get info about picture p. Currently we have no * way to get information about a picture beyond it's name. */ static SANE_Int get_picture_info (PictureInfo * pic, SANE_Int p) { SANE_Char f[] = "get_picture_info"; const char *name; DBG (4, "%s: info for pic #%d\n", f, p); gp_list_get_name (dir_list, p, &name); DBG (4, "Name is %s\n", name); read_info (name); pic->low_res = SANE_FALSE; return 0; } /* * snap_pic - take a picture (and call get_pictures_info to re-create * the directory related data structures) */ static SANE_Status snap_pic (void) { SANE_Char f[] = "snap_pic"; CameraFilePath path; /* make sure camera is set to our settings state */ if (change_res (gphoto2_opt_lowres) == -1) { DBG (1, "%s: Failed to set resolution\n", f); return SANE_STATUS_INVAL; } /* * This is needed when the camera has no files and the first picture * is taken. I guess it's because a folder needs to be created and * the filesystem doesn't know about it. */ if (Cam_data.pic_taken == 0) { gp_filesystem_reset (camera->fs); } CHECK_RET (gp_camera_capture (camera, GP_CAPTURE_IMAGE, &path, NULL)); /* Can't just increment picture count, because if the camera has * zero pictures we may not know the folder name. Start over * with get_info and get_pictures_info. (We didn't have the call * to init_gphoto2() here before, but that was causing us to not * see the new image - need to use a biggger hammer to get it to * re-read the camera directory */ if (init_gphoto2 () != SANE_STATUS_GOOD) { return SANE_STATUS_INVAL; } if (get_info () != SANE_STATUS_GOOD) { DBG (1, "error: could not get info\n"); close_gphoto2 (); return SANE_STATUS_INVAL; } if (get_pictures_info () == NULL) { DBG (1, "%s: Failed to get new picture info\n", f); /* FIXME - I guess we should try to erase the image here */ return SANE_STATUS_INVAL; } sod[GPHOTO2_OPT_IMAGE_NUMBER].cap |= SANE_CAP_INACTIVE; Cam_data.current_picture_number = Cam_data.pic_taken; myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; return SANE_STATUS_GOOD; } /* * read_dir - read a list of file names from the specified directory * and create a linked list of file name entries in * alphabetical order. The first entry in the list will * be "picture #1", etc. */ static SANE_Int read_dir (SANE_String dir, SANE_Bool read_files) { SANE_Int retval = 0; SANE_Char f[] = "read_dir"; /* Free up current list */ if (dir_list != NULL) { if (gp_list_free (dir_list) < 0) { DBG (0, "%s: error: gp_list_free failed\n", f); } dir_list = NULL; } if (gp_list_new (&dir_list) < 0) { DBG (0, "%s: error: gp_list_new failed\n", f); } if (read_files) { CHECK_RET (gp_camera_folder_list_files (camera, dir, dir_list, NULL)); } else { CHECK_RET (gp_camera_folder_list_folders (camera, dir, dir_list, NULL)); } retval = gp_list_count (dir_list); return retval; } /* * read_info - read the info block from camera for the specified file * NOT YET SUPPORTED - If it were we could use it to do things * like update the image size parameters displayed by the GUI */ static SANE_Int read_info (SANE_String_Const fname) { SANE_Char path[256]; strcpy (path, "\\DCIM\\"); strcat (path, (const char *) folder_list[current_folder]); strcat (path, "\\"); strcat (path, fname); return 0; } /* * set_res - set picture size depending on resolution settings */ static void set_res (SANE_Int __sane_unused__ lowres) { if (gphoto2_opt_thumbnails) { parms.bytes_per_line = THUMB_WIDTH * 3; parms.pixels_per_line = THUMB_WIDTH; parms.lines = THUMB_HEIGHT; } else { parms.bytes_per_line = HIGHRES_WIDTH * 3; parms.pixels_per_line = HIGHRES_WIDTH; parms.lines = HIGHRES_HEIGHT; } } /* * converter_do_scan_complete_cleanup - do everything that needs to be * once a "scan" has been completed: Unref the file, Erase the image, * and increment image number to point to next picture. */ static SANE_Status converter_do_scan_complete_cleanup (void) { CameraList *tmp_list; SANE_Int i; SANE_String_Const filename; gp_file_unref (data_file); if (gphoto2_opt_erase) { DBG (127, "sane_read bp%d, erase image\n", __LINE__); if (erase () == -1) { DBG (1, "Failed to erase memory\n"); return SANE_STATUS_INVAL; } if (SubDirs) { sprintf (cmdbuf, "%s/%s", (char *) TopFolder, (const char *) folder_list[current_folder]); } else { strcpy (cmdbuf, TopFolder); } CHECK_RET (gp_list_get_name (dir_list, Cam_data.current_picture_number - 1, &filename)); Cam_data.pic_taken--; Cam_data.pic_left++; if (Cam_data.current_picture_number > Cam_data.pic_taken) { Cam_data.current_picture_number = Cam_data.pic_taken; } image_range.max--; if (image_range.max == 0) { sod[GPHOTO2_OPT_IMAGE_NUMBER].cap |= SANE_CAP_INACTIVE; } myinfo |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; /* Too bad we don't have an API function for deleting a * list item. Instead, we copy all the entries in the * current list, skipping over the deleted entry, and then * replace the current list with the new list. */ gp_list_new (&tmp_list); for (i = 0; i < gp_list_count (dir_list); i++) { SANE_String_Const tfilename; CHECK_RET (gp_list_get_name (dir_list, i, &tfilename)); /* If not the one to delete, copy to the new list */ if (strcmp (tfilename, filename) != 0) { CHECK_RET (gp_list_append (tmp_list, tfilename, NULL)); } } gp_list_free (dir_list); dir_list = tmp_list; } if (gphoto2_opt_autoinc) { if (Cam_data.current_picture_number <= Cam_data.pic_taken) { Cam_data.current_picture_number++; myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; /* get the image's resolution */ /* OLD: set_res (Cam_data.Pictures[Cam_data.current_picture_number - 1]. low_res); */ set_res (gphoto2_opt_lowres); } DBG (4, "Increment count to %d (total %d)\n", Cam_data.current_picture_number, Cam_data.pic_taken); } return SANE_STATUS_EOF; } /* * converter_fill_buffer - Fill line buffer with next input line from image. * Currently assumes jpeg, but this is where we would put the switch * to handle other image types. */ static SANE_Int converter_fill_buffer (void) { /* * FIXME: Current implementation reads one scan line at a time. Part * of the reason for this is in the original code is to give the frontend * a chance to update * the progress marker periodically. Since the gphoto2 * driver sucks in the whole image before decoding it, perhaps we could * come up with a simpler implementation. */ SANE_Int lines = 1; (void) jpeg_read_scanlines (&cinfo, dest_mgr->buffer, lines); (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, lines, (char *) linebuffer); return cinfo.output_width * cinfo.output_components * lines; } /* * converter_scan_complete - Check if all the data for the image has been read. * Currently assumes jpeg, but this is where we would put the * switch to handle other image types. */ static SANE_Bool converter_scan_complete (void) { if (cinfo.output_scanline >= cinfo.output_height) { return SANE_TRUE; } else { return SANE_FALSE; } } /* * converter_init - Initialize image conversion data. * Currently assumes jpeg, but this is where we would put the * switch to handle other image types. */ static SANE_Status converter_init (SANE_Handle handle) { struct jpeg_error_mgr jerr; my_src_ptr src; data_file_current_index = 0; /* Basic check to see if this is really a jpeg file */ if ( data_ptr[0] != 0xff || data_ptr[1] != 0xd8 ) { sane_cancel(handle); exit(1); return SANE_STATUS_INVAL; } cinfo.err = jpeg_std_error (&jerr); jpeg_create_decompress (&cinfo); cinfo.src = (struct jpeg_source_mgr *) (*cinfo.mem-> alloc_small) ((j_common_ptr) & cinfo, JPOOL_PERMANENT, sizeof (my_source_mgr)); src = (my_src_ptr) cinfo.src; src->buffer = (JOCTET *) (*cinfo.mem->alloc_small) ((j_common_ptr) & cinfo, JPOOL_PERMANENT, 1024 * sizeof (JOCTET)); src->pub.init_source = jpeg_init_source; src->pub.fill_input_buffer = jpeg_fill_input_buffer; src->pub.skip_input_data = jpeg_skip_input_data; src->pub.resync_to_restart = jpeg_resync_to_restart; /* default */ src->pub.term_source = jpeg_term_source; src->pub.bytes_in_buffer = 0; src->pub.next_input_byte = NULL; (void) jpeg_read_header (&cinfo, TRUE); dest_mgr = sanei_jpeg_jinit_write_ppm (&cinfo); (void) jpeg_start_decompress (&cinfo); parms.bytes_per_line = cinfo.output_width * 3; /* 3 colors */ parms.pixels_per_line = cinfo.output_width; parms.lines = cinfo.output_height; linebuffer_size = 0; linebuffer_index = 0; return(SANE_STATUS_GOOD); } sane-backends-1.0.29/backend/epson2-io.c0000666000000000000000000002241313615534521014551 00000000000000/* * I/O routines for Epson scanners * * Based on Kazuhiro Sasayama previous * Work on epson.[ch] file from the SANE package. * Please see those files for original copyrights. * * Copyright (C) 2006 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" #include #include "epson2.h" #include "epson2-io.h" #include "sane/sanei_scsi.h" #include "sane/sanei_usb.h" #include "sane/sanei_pio.h" #include "sane/sanei_tcp.h" #include "epson2_scsi.h" #include "epson_usb.h" #include "epson2_net.h" #include "byteorder.h" /* flaming hack to get USB scanners * working without timeouts under linux * (cribbed from fujitsu.c) */ unsigned int r_cmd_count = 0; unsigned int w_cmd_count = 0; int e2_send(Epson_Scanner * s, void *buf, size_t buf_size, size_t reply_len, SANE_Status * status) { DBG(15, "%s: size = %lu, reply = %lu\n", __func__, (u_long) buf_size, (u_long) reply_len); if (buf_size == 2) { char *cmd = buf; switch (cmd[0]) { case ESC: DBG(9, "%s: ESC %c\n", __func__, cmd[1]); break; case FS: DBG(9, "%s: FS %c\n", __func__, cmd[1]); break; } } if (DBG_LEVEL >= 125) { unsigned int k; const unsigned char *s = buf; for (k = 0; k < buf_size; k++) { DBG(125, "buf[%d] %02x %c\n", k, s[k], isprint(s[k]) ? s[k] : '.'); } } if (s->hw->connection == SANE_EPSON_NET) { if (reply_len == 0) { DBG(0, "Cannot send this command to a networked scanner\n"); return SANE_STATUS_INVAL; } return sanei_epson_net_write(s, 0x2000, buf, buf_size, reply_len, status); } else if (s->hw->connection == SANE_EPSON_SCSI) { return sanei_epson2_scsi_write(s->fd, buf, buf_size, status); } else if (s->hw->connection == SANE_EPSON_PIO) { size_t n; if (buf_size == (n = sanei_pio_write(s->fd, buf, buf_size))) *status = SANE_STATUS_GOOD; else *status = SANE_STATUS_INVAL; return n; } else if (s->hw->connection == SANE_EPSON_USB) { size_t n; n = buf_size; *status = sanei_usb_write_bulk(s->fd, buf, &n); w_cmd_count++; DBG(20, "%s: cmd count, r = %d, w = %d\n", __func__, r_cmd_count, w_cmd_count); return n; } *status = SANE_STATUS_INVAL; return 0; /* never reached */ } ssize_t e2_recv(Epson_Scanner *s, void *buf, ssize_t buf_size, SANE_Status *status) { 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) { 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) { 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 */ 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) { DBG(1, "%s: expected = %lu, got = %ld, canceling: %d\n", __func__, (u_long) buf_size, (long) n, s->canceling); *status = SANE_STATUS_IO_ERROR; } /* dump buffer if appropriate */ if (DBG_LEVEL >= 127 && n > 0) { int k; const unsigned char *s = buf; for (k = 0; k < n; k++) DBG(127, "buf[%d] %02x %c\n", k, s[k], isprint(s[k]) ? s[k] : '.'); } return n; } /* Simple function to exchange a fixed amount of * data with the scanner */ SANE_Status e2_txrx(Epson_Scanner * s, unsigned char *txbuf, size_t txlen, unsigned char *rxbuf, size_t rxlen) { SANE_Status status; size_t done; 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; } /* This function should be used to send codes that only requires the scanner * to give back an ACK or a NAK. */ SANE_Status e2_cmd_simple(Epson_Scanner * s, void *buf, size_t buf_size) { unsigned char result; SANE_Status status; DBG(12, "%s: size = %lu\n", __func__, (u_long) buf_size); status = e2_txrx(s, buf, buf_size, &result, 1); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: failed, %s\n", __func__, sane_strstatus(status)); return status; } if (result == ACK) return SANE_STATUS_GOOD; if (result == NAK) { DBG(3, "%s: NAK\n", __func__); return SANE_STATUS_INVAL; } DBG(1, "%s: result is neither ACK nor NAK but 0x%02x\n", __func__, result); return SANE_STATUS_GOOD; } /* receives a 4 or 6 bytes information block from the scanner*/ SANE_Status e2_recv_info_block(Epson_Scanner * s, unsigned char *scanner_status, size_t info_size, size_t * payload_size) { SANE_Status status; unsigned char info[6]; if (s->hw->connection == SANE_EPSON_PIO) e2_recv(s, info, 1, &status); else e2_recv(s, info, info_size, &status); if (status != SANE_STATUS_GOOD) return status; /* check for explicit NAK */ if (info[0] == NAK) { DBG(1, "%s: command not supported\n", __func__); return SANE_STATUS_UNSUPPORTED; } /* check the first byte: if it's not STX, bail out */ if (info[0] != STX) { DBG(1, "%s: expecting STX, got %02X\n", __func__, info[0]); return SANE_STATUS_INVAL; } /* if connection is PIO read the remaining bytes. */ if (s->hw->connection == SANE_EPSON_PIO) { e2_recv(s, &info[1], info_size - 1, &status); if (status != SANE_STATUS_GOOD) return status; } if (scanner_status) *scanner_status = info[1]; if (payload_size) { *payload_size = le16atoh(&info[2]); if (info_size == 6) *payload_size *= le16atoh(&info[4]); DBG(14, "%s: payload length: %lu\n", __func__, (u_long) *payload_size); } return SANE_STATUS_GOOD; } /* This function can be called for commands that * will be answered by the scanner with an info block of 4 bytes * and a variable payload. The payload is passed back to the caller * in **buf. The caller must free it if != NULL, * even if the status != SANE_STATUS_GOOD. */ SANE_Status e2_cmd_info_block(SANE_Handle handle, unsigned char *params, unsigned char params_len, size_t reply_len, unsigned char **buf, size_t * buf_len) { SANE_Status status; Epson_Scanner *s = (Epson_Scanner *) handle; size_t len; DBG(13, "%s, params len = %d, reply len = %lu, buf = %p\n", __func__, params_len, (u_long) reply_len, (void *) buf); if (buf == NULL) return SANE_STATUS_INVAL; /* initialize */ *buf = NULL; /* send command, we expect the info block + reply_len back */ e2_send(s, params, params_len, reply_len ? reply_len + 4 : 0, &status); if (status != SANE_STATUS_GOOD) goto end; status = e2_recv_info_block(s, NULL, 4, &len); if (status != SANE_STATUS_GOOD) goto end; /* do we need to provide the length of the payload? */ if (buf_len) *buf_len = len; /* no payload, stop here */ if (len == 0) goto end; /* if a reply_len has been specified and the actual * length differs, throw a warning */ if (reply_len && (len != reply_len)) { DBG(1, "%s: mismatched len - expected %lu, got %lu\n", __func__, (u_long) reply_len, (u_long) len); } /* allocate and receive the payload */ *buf = malloc(len); if (*buf) { memset(*buf, 0x00, len); e2_recv(s, *buf, len, &status); /* receive actual data */ } else status = SANE_STATUS_NO_MEM; end: if (status != SANE_STATUS_GOOD) { DBG(1, "%s: failed, %s\n", __func__, sane_strstatus(status)); if (*buf) { free(*buf); *buf = NULL; } } return status; } /* This is used for ESC commands with a single byte parameter. Scanner * will answer with ACK/NAK. */ SANE_Status e2_esc_cmd(Epson_Scanner * s, unsigned char cmd, unsigned char val) { SANE_Status status; unsigned char params[2]; DBG(8, "%s: cmd = 0x%02x, val = %d\n", __func__, cmd, val); if (!cmd) return SANE_STATUS_UNSUPPORTED; params[0] = ESC; params[1] = cmd; status = e2_cmd_simple(s, params, 2); if (status != SANE_STATUS_GOOD) return status; params[0] = val; return e2_cmd_simple(s, params, 1); } /* Send an ACK to the scanner */ SANE_Status e2_ack(Epson_Scanner * s) { SANE_Status status; e2_send(s, S_ACK, 1, 0, &status); return status; } SANE_Status e2_ack_next(Epson_Scanner * s, size_t reply_len) { SANE_Status status; e2_send(s, S_ACK, 1, reply_len, &status); return status; } SANE_Status e2_cancel(Epson_Scanner * s) { DBG(1, "%s\n", __func__); return e2_cmd_simple(s, S_CAN, 1); } sane-backends-1.0.29/backend/escl.conf.in0000666000000000000000000000153113615534521014772 00000000000000# escl.conf -- ESCL configuration # Lines starting with a # or a ; are comments. Comments must be on a # line of their own. End-of-line comments are not supported. # Explanation : if you can't detect your device but it's an eSCL device, modify this escl conf' file to use your device. # -> uncomment the lines below, from '[device]' to 'port'. # -> put your device name instead of 'EPSON X'. # -> put your type of protocol instead of 'https' : http or https. # -> put your device ip instead of '123.456.789.10'. # -> put the port that you use instead of '88'. # For example, the lines below are for one device, but if you have several devices to use, you can duplicate the lines below as many times as you have devices. #[device] #model EPSON X #type https #ip 123.456.789.10 #port 88 sane-backends-1.0.29/backend/umax.h0000666000000000000000000005453113615534521013723 00000000000000/* --------------------------------------------------------------------------------------------------------- */ /* umax.h - headerfile for SANE-backend for umax scanners (C) 1997-2002 Oliver Rauch 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* --------------------------------------------------------------------------------------------------------- */ #ifndef umax_h #define umax_h #include "sys/types.h" /* --------------------------------------------------------------------------------------------------------- */ /* COMPILER OPTIONS: */ #define UMAX_ENABLE_USB #define UMAX_HIDE_UNUSED /* #define SANE_UMAX_DEBUG_S12 */ /* #define UMAX_CALIBRATION_MODE_SELECTABLE */ /* --------------------------------------------------------------------------------------------------------- */ #define SANE_UMAX_SCSI_MAXQUEUE 8 /* --------------------------------------------------------------------------------------------------------- */ #define SANE_UMAX_FIX_ROUND(val) ((SANE_Word) ((val) * (1 << SANE_FIXED_SCALE_SHIFT) + 1.0 / (1 << (SANE_FIXED_SCALE_SHIFT+1)))) /* --------------------------------------------------------------------------------------------------------- */ enum Umax_Option { OPT_NUM_OPTS = 0, /* ------------------------------------------- */ OPT_MODE_GROUP, OPT_MODE, OPT_SOURCE, OPT_X_RESOLUTION, OPT_Y_RESOLUTION, OPT_RESOLUTION_BIND, /* bind x and y resolution */ OPT_NEGATIVE, /* ------------------------------------------- */ OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ /* ------------------------------------------- */ OPT_ENHANCEMENT_GROUP, OPT_BIT_DEPTH, /* output bit depth */ OPT_QUALITY, /* quality calibration */ OPT_DOR, /* double optical resolution */ OPT_WARMUP, OPT_RGB_BIND, /* use same rgb-values for each color in color-mode */ OPT_BRIGHTNESS, OPT_CONTRAST, OPT_THRESHOLD, OPT_HIGHLIGHT, /* highlight */ OPT_HIGHLIGHT_R, OPT_HIGHLIGHT_G, OPT_HIGHLIGHT_B, OPT_SHADOW, /* shadow */ OPT_SHADOW_R, OPT_SHADOW_G, OPT_SHADOW_B, OPT_ANALOG_GAMMA, /* analog gamma */ OPT_ANALOG_GAMMA_R, OPT_ANALOG_GAMMA_G, OPT_ANALOG_GAMMA_B, OPT_CUSTOM_GAMMA, /* use custom gamma tables */ /* The gamma vectors MUST appear in the order gray, red, green, blue. */ OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, OPT_HALFTONE_DIMENSION, OPT_HALFTONE_PATTERN, /* ------------------------------------------- */ OPT_ADVANCED_GROUP, OPT_CAL_EXPOS_TIME, /* exposure time for calibration */ OPT_CAL_EXPOS_TIME_R, OPT_CAL_EXPOS_TIME_G, OPT_CAL_EXPOS_TIME_B, OPT_SCAN_EXPOS_TIME, /* exposure time for scan */ OPT_SCAN_EXPOS_TIME_R, OPT_SCAN_EXPOS_TIME_G, OPT_SCAN_EXPOS_TIME_B, OPT_DISABLE_PRE_FOCUS, OPT_MANUAL_PRE_FOCUS, OPT_FIX_FOCUS_POSITION, OPT_LENS_CALIBRATION_DOC_POS, OPT_HOLDER_FOCUS_POS_0MM, OPT_CAL_LAMP_DEN, OPT_SCAN_LAMP_DEN, OPT_SELECT_EXPOSURE_TIME, OPT_SELECT_CAL_EXPOSURE_TIME, OPT_SELECT_LAMP_DENSITY, OPT_LAMP_ON, OPT_LAMP_OFF, OPT_LAMP_OFF_AT_EXIT, OPT_BATCH_SCAN_START, /* start batch scan function */ OPT_BATCH_SCAN_LOOP, /* loop batch scan function */ OPT_BATCH_SCAN_END, /* end batch scan function */ OPT_BATCH_NEXT_TL_Y, /* batch scan function next y position */ #ifdef UMAX_CALIBRATION_MODE_SELECTABLE OPT_CALIB_MODE, #endif OPT_PREVIEW, /* preview, sets preview-bit and bind x/y-resolution */ /* must come last: */ NUM_OPTIONS }; /* -------------------------------------------------------------------------------------------------------- */ /* LIST OF AVAILABLE SCANNERS, THE VALUES LISTED HERE ARE THE SAME FOR DIFFERENT APPLICATIONS THAT USE THE SAME DEVICE */ /* Umax_Device contains values relevant for the device that are not intersting for the sane interface */ typedef struct Umax_Device { struct Umax_Device *next; SANE_Device sane; int connection_type; #define SANE_UMAX_UNKNOWN 0 #define SANE_UMAX_SCSI 1 #define SANE_UMAX_USB 2 SANE_Range x_dpi_range; SANE_Range y_dpi_range; SANE_Range x_range; SANE_Range y_range; SANE_Range analog_gamma_range; unsigned flags; unsigned char *buffer[SANE_UMAX_SCSI_MAXQUEUE]; /* buffer used for scsi-transfer */ void *queue_id[SANE_UMAX_SCSI_MAXQUEUE]; /* scsi queue id */ size_t length_queued[SANE_UMAX_SCSI_MAXQUEUE]; /* length of queued data */ size_t length_read[SANE_UMAX_SCSI_MAXQUEUE]; /* length of returned data */ unsigned int bufsize; unsigned int row_bufsize; unsigned int request_scsi_maxqueue; unsigned int request_preview_lines; unsigned int request_scan_lines; unsigned int handle_bad_sense_error; unsigned int execute_request_sense; unsigned int force_preview_bit_rgb; unsigned int scsi_buffer_size_min; unsigned int scsi_buffer_size_max; unsigned int scsi_maxqueue; unsigned char *pixelbuffer; /* buffer used for pixel ordering */ unsigned int pixelline_max; /* number of lines that fit into pixelbuffer */ unsigned int pixelline_ready[3]; /* finished absolute line for each color */ unsigned int pixelline_next[3]; /* next line to write for each color */ unsigned int pixelline_del[3]; /* next line to delete in opt_res for col */ unsigned int pixelline_optic[3]; /* scanned line in opt_res for each color */ unsigned int pixelline_opt_res; /* number of scanned line in optical res */ unsigned int pixelline_read; /* number of read pixel-lines */ unsigned int pixelline_written; /* number of written pixel-lines */ unsigned int CCD_distance; /* color line distance in optical resolution */ unsigned int CCD_color[9]; /* color order */ /* 0 / 1 2 / 3 4 5 / 6 7 / 8 */ # define CCD_color_red 0 # define CCD_color_green 1 # define CCD_color_blue 2 char *devicename; /* name of the scanner device */ int sfd; /* output file descriptor, scanner device */ char vendor[9]; /* will be UMAX */ char product[17]; /* e.g. "SuperVista_S12" or so */ char version[5]; /* e.g. V1.3 */ int three_pass; /* used in RGB-mode if 3-pass => 1 */ int three_pass_color; /* select color for scanning in 3pass mode */ unsigned int row_len; /* len of one scan-line in bytes */ unsigned int lines_max; /* maximum number of lines to scan */ unsigned int max_value; /* used for pnm-file */ /* data defined by inquiry */ int inquiry_len; /* length of inquiry return block */ int inquiry_wdb_len; /* length of window descriptor block */ int inquiry_vidmem; /* size of video memory */ int inquiry_optical_res; /* optical resolution */ int inquiry_x_res; /* maximum x-resolution */ int inquiry_y_res; /* maximum y-resolution */ int inquiry_dor_optical_res; /* optical resolution for dor mode */ int inquiry_dor_x_res; /* maximum x-resolution for dor mode */ int inquiry_dor_y_res; /* maximum y-resolution for dor mode */ double inquiry_fb_width; /* flatbed width in inches */ double inquiry_fb_length; /* flatbed length in inches */ double inquiry_uta_width; /* transparency width in inches */ double inquiry_uta_length; /* transparency length in inches */ double inquiry_uta_x_off; /* transparency x offset in inches */ double inquiry_uta_y_off; /* transparency y offset in inches */ double inquiry_dor_width; /* double resolution width in inches */ double inquiry_dor_length; /* double resolution length in inches */ double inquiry_dor_x_off; /* double resolution x offset in inches */ double inquiry_dor_y_off; /* double resolution y offset in inches */ int inquiry_exposure_adj; /* 1 if exposure adjust is supported */ int inquiry_exposure_time_step_unit; /* exposure time unit in micro sec */ int inquiry_exposure_time_max; /* exposure time maximum */ int inquiry_exposure_time_l_min; /* exposure tine minimum for lineart */ int inquiry_exposure_time_l_fb_def; /* exposure time default for lineart/flatbed */ int inquiry_exposure_time_l_uta_def; /* exposure time default for lineart/uta */ int inquiry_exposure_time_h_min; /* exposure tine minimum for halftone */ int inquiry_exposure_time_h_fb_def; /* exposure time default for halftone/flatbed */ int inquiry_exposure_time_h_uta_def; /* exposure time default for halftone/uta */ int inquiry_exposure_time_g_min; /* exposure tine minimum for grayscale */ int inquiry_exposure_time_g_fb_def; /* exposure time default for grayscale/flatbed */ int inquiry_exposure_time_g_uta_def; /* exposure time default for grayscale/uta */ int inquiry_exposure_time_c_min; /* exposure tine minimum for color */ int inquiry_exposure_time_c_fb_def_r; /* exposure time default for color red/flatbed */ int inquiry_exposure_time_c_fb_def_g; /* exposure time default for color green/flatbed */ int inquiry_exposure_time_c_fb_def_b; /* exposure time default for color blue/flatbed */ int inquiry_exposure_time_c_uta_def_r; /* exposure time default for color red/uta */ int inquiry_exposure_time_c_uta_def_g; /* exposure time default for color green/uta */ int inquiry_exposure_time_c_uta_def_b; /* exposure time default for color blue/uta */ int inquiry_max_warmup_time; /* maximum lamp warmup time in sec */ int inquiry_cbhs; /* 50, 255, 255+autoexp. */ int inquiry_cbhs_min; /* minimum value for cbhs */ int inquiry_cbhs_max; /* maximum value for cbhs */ int inquiry_contrast_min; /* minimum value for c */ int inquiry_contrast_max; /* maximum value for c */ int inquiry_brightness_min; /* minimum value for b */ int inquiry_brightness_max; /* maximum value for b */ int inquiry_threshold_min; /* minimum value for t */ int inquiry_threshold_max; /* maximum value for t */ int inquiry_highlight_min; /* minimum value for h */ int inquiry_highlight_max; /* maximum value for h */ int inquiry_shadow_min; /* minimum value for s */ int inquiry_shadow_max; /* maximum value for s */ int inquiry_quality_ctrl; /* 1 = supported */ int inquiry_batch_scan; /* 1 = supported */ int inquiry_preview; /* 1 = supported */ int inquiry_lamp_ctrl; /* 1 = supported */ int inquiry_transavail; /* 1 = uta available */ int inquiry_adfmode; /* 1 = adf available */ int inquiry_uta; /* 1 = uta supported */ int inquiry_adf; /* 1 = adf supported */ int inquiry_dor; /* 1 = dor supported */ int inquiry_reverse; /* 1 = 1 bit reverse supported */ int inquiry_reverse_multi; /* 1 = multi bit reverse supported */ int inquiry_analog_gamma; /* 1 = analog gamma supported */ int inquiry_lineart_order; /* 1 = LSB first, 0 = MSB first */ int inquiry_lens_cal_in_doc_pos; /* 1 = lens calibration in doc pos supported */ int inquiry_manual_focus; /* 1 = manual focus supported */ int inquiry_sel_uta_lens_cal_pos; /* 1 = selection of lens calib pos for uta supported */ int inquiry_gamma_dwload; /* 1 = gamma download supported */ int inquiry_gamma_DCF; /* gamma download curve format */ int inquiry_one_pass_color; /* 1 = 1 pass supported */ int inquiry_three_pass_color; /* 1 = 3 pass supported */ int inquiry_color; /* 1 = color mode supported */ int inquiry_gray; /* 1 = grayscale mode supported */ int inquiry_halftone; /* 1 = halftone mode supported */ int inquiry_lineart; /* 1 = lineart mode supported */ int inquiry_calibration; /* 1 = calibration mode control supported */ int inquiry_highlight; /* 1 = highlight supported */ int inquiry_shadow; /* 1 = shadow supported */ int inquiry_GIB; /* gamma input bits */ int inquiry_GOB; /* gamma output bits */ int inquiry_max_calib_lines; /* maximum calibration lines */ int inquiry_color_order; /* color ordering support */ int inquiry_CCD_line_distance; /* color line distance */ int inquiry_fb_uta_color_arrangement; /* line arrangement for fb & uta */ int inquiry_adf_color_arrangement; /* line arrangement for adf */ unsigned int relevant_optical_res; /* optical resolution */ unsigned int relevant_max_x_res; /* maximum x-resolution */ unsigned int relevant_max_y_res; /* maximum y-resolution */ /* selected data */ int use_exposure_time_min; /* exposure tine minimum */ int use_exposure_time_def_r; /* exposure time default */ int use_exposure_time_def_g; /* exposure time default */ int use_exposure_time_def_b; /* exposure time default */ int wdb_len; /* use this length of WDB */ unsigned int width_in_pixels; /* thats the wanted width in pixels */ unsigned int length_in_pixels; /* thats the wanted length in pixels */ unsigned int scanwidth; /* thats the width in pixels at x_coordinate_base dpi */ unsigned int scanlength; /* thats the length in pixels at y_coordinate_base dpi */ unsigned int bytes_per_color; /* bytes per each color */ unsigned int x_resolution; /* scan-resolution for x in dpi */ unsigned int y_resolution; /* scan-resolution for y in dpi */ double scale_x; /* x-scaling of optical resolution */ double scale_y; /* y-scaling of optical resolution */ int upper_left_x; /* thats the left edge in points at 1200pt/inch */ int upper_left_y; /* thats the top edge in points at 1200pt/inch */ unsigned int x_coordinate_base; /* x base in pixels/inch, normaly 1200 */ unsigned int y_coordinate_base; /* y base in pixels/inch, normaly 1200 */ unsigned int bits_per_pixel; /* number of bits per pixel */ int bits_per_pixel_code; /* 1 = 24bpp, 4 = 30 bpp, 8 = 36 bpp */ int gamma_input_bits_code; /* 1 = 24bpp, 4 = 30 bpp, 8 = 36 bpp */ int set_auto; /* 0 or 1, don't know what it is */ int preview; /* 1 if preview */ int batch_scan; /* 1 = batch scan, 0 = normal scan */ int batch_end; /* 1 = reposition scanhead */ int batch_next_tl_y; /* top left y position for next batch scan */ int quality; /* 1 = quality_calibration, 0 = fast */ int reverse; /* 1: exchange black and white */ int reverse_multi; /* 1: invert color values */ int WD_speed; /* is a combination of slow and smear */ int slow; /* 1: slow scan speed */ int smear; /* 1: don't care about image smearing problem */ int dor; /* double resolution */ int cbhs_range; /* 50,255 or 255+autoexposure */ int fix_focus_position; /* fix focus position */ int lens_cal_in_doc_pos; /* lens calibration in document position */ int disable_pre_focus; /* disable pre focus */ int holder_focus_pos_0mm; /* 0.6mm <-> 0.0mm holder focus position */ int manual_focus; /* automatic <-> manual focus */ int warmup; /* 1=set warmup-bit */ int module; /* flatbed or transparency */ int adf; /* 1 if ADF turned on */ int uta; /* 1 if UTA turned on */ int calibration; /* calibration :0=ignore, 1=driver, 2=by image */ int low_byte_first; /* 10 bit mode: 0=high byte frist, 1=low byte frist */ int colormode; /* LINEART, HALFTONE, GRAYSCALE or RGB */ # define LINEART 1 # define HALFTONE 2 # define GRAYSCALE 3 # define RGB_LINEART 4 # define RGB_HALFTONE 5 # define RGB 6 int exposure_time_calibration_r; /* red exposure time for calibration */ int exposure_time_calibration_g; /* green exposure time for calibration */ int exposure_time_calibration_b; /* blue exposure time for calibration */ int exposure_time_scan_r; /* red exposure time for scan */ int exposure_time_scan_g; /* green exposure time for scan */ int exposure_time_scan_b; /* bue exposure time for scan */ int c_density; /* next calibration lamp density */ int s_density; /* next scan lamp density */ int threshold; /* (128) 0-255, lineart mode */ int brightness; /* (128) cbhs_range 0-255, halftone mode */ int contrast; /* (128) cbhs_range 0-255, halftone-mode */ int highlight_r; /* (255) cbhs_range 1-255, each mode */ int highlight_g; /* (255) cbhs_range 1-255, each mode */ int highlight_b; /* (255) cbhs_range 1-255, each mode */ int shadow_r; /* (0) cbhs_range 0-254, each mode */ int shadow_g; /* (0) cbhs_range 0-254, each mode */ int shadow_b; /* (0) cbhs_range 0-254, each mode */ int halftone; /* halftone pattern select */ int digital_gamma_r; /* gamma-select for red and gray */ int digital_gamma_g; /* gamma-select value for green */ int digital_gamma_b; /* gamma-select value for blue */ int analog_gamma_r; /* analog gamma red and gray */ int analog_gamma_g; /* analog gamma green */ int analog_gamma_b; /* analog gamma blue */ int calib_lines; /* request calibration lines */ int do_calibration; /* 1: do calibration by driver */ int do_color_ordering; /* 1: order line-mode to pixel-mode */ int button0_pressed; /* scan-button 0 on scanner is pressed => 1 */ int button1_pressed; /* scan-button 1 on scanner is pressed => 1 */ int button2_pressed; /* scan-button 2 on scanner is pressed => 1 */ int calibration_area; /* define calibration area if no area is given */ int calibration_width_offset; /* some scanners do calibrate with some additional pixels */ int calibration_width_offset_batch; /* the same for batch scanning */ int calibration_bytespp; /* correction of bytespp if driver knows about it */ int exposure_time_rgb_bind; /* exposure time can not be defined for each color */ int invert_shading_data; /* invert shading data before sending it to the scanner */ int common_xy_resolutions; /* do not allow different x and y resolution */ int pause_for_color_calibration; /* pause between start_scan and do_calibration in ms */ int pause_for_gray_calibration; /* pause between start_scan and do_calibration in ms */ int pause_after_calibration; /* pause between do_calibration and read data in ms */ int pause_after_reposition; /* pause for repositioning in ms */ int pause_for_moving; /* pause for moving scanhead over full scanarea in ms */ int lamp_control_available; /* is set when scanner supportes lamp control */ int gamma_lsb_padded; /* 16 bit gamma data is padded to lsb */ int force_quality_calibration; /* always set quality calibration */ } Umax_Device; /* --------------------------------------------------------------------------------------------------------- */ /* LIST OF OPEND DEVICES, A DEVICE MAY BE OPEND TWICE, ALL VALUES LISTED HERE MAY BE DIFFERENT FOR DIFFERENT APPLICATIONS */ /* Umax_Scanner contains values relevant for the sane interface */ typedef struct Umax_Scanner { struct Umax_Scanner *next; Umax_Device *device; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Int *gamma_table[4]; SANE_Int halftone_pattern[64]; SANE_Range gamma_range; unsigned int gamma_length; SANE_Range output_range; unsigned int output_bytes; SANE_Range exposure_time_range; int scanning; SANE_Parameters params; SANE_Pid reader_pid; int pipe_read_fd; int pipe_write_fd; } Umax_Scanner; /* --------------------------------------------------------------------------------------------------------- */ #endif /* umax-sane_h */ sane-backends-1.0.29/backend/umax_pp_low.c0000666000000000000000000111256413615534521015300 00000000000000/** Copyright (C) 2001-2012 Stéphane Voltz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Umax PP flatbed scanners. */ #undef BACKEND_NAME #define BACKEND_NAME umax_pp_low #include "../include/sane/config.h" #include #include #include #include #ifdef HAVE_SYS_TIME_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_IO_H #include #endif #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_FCNTL_H #include #endif #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_backend.h" #include #ifdef HAVE_DEV_PPBUS_PPI_H #include #include #endif #ifdef HAVE_MACHINE_CPUFUNC_H #include #endif #ifdef HAVE_I386_SET_IOPERM #include #endif #ifdef HAVE_LINUX_PPDEV_H #include #include #include #endif /*************************************************/ /* here we define sanei_inb/sanei_outb based on */ /* OS dependant inb/outb definitions */ /* SANE_INB is defined whenever a valid inb/outb */ /* definition has been found */ /* once all these work, it might be moved to */ /* sanei_pio.c */ /*************************************************/ #ifdef ENABLE_PARPORT_DIRECTIO #if (! defined SANE_INB ) && ( defined HAVE_SYS_HW_H ) /* OS/2 EMX case */ #define SANE_INB 1 static int sanei_ioperm (int start, int length, int enable) { if (enable) return _portaccess (port, port + length - 1); return 0; } static unsigned char sanei_inb (unsigned int port) { return _inp8 (port) & 0xFF; } static void sanei_outb (unsigned int port, unsigned char value) { _outp8 (port, value); } static void sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) { _inps8 (port, (unsigned char *) addr, count); } static void sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) { _inps32 (port, (unsigned long *) addr, count); } static void sanei_outsb (unsigned int port, const unsigned char *addr, unsigned long count) { _outps8 (port, (unsigned char *) addr, count); } static void sanei_outsl (unsigned int port, const unsigned char *addr, unsigned long count) { _outps32 (port, (unsigned long *) addr, count); } #endif /* OS/2 EMX case */ #if (! defined SANE_INB ) && ( defined HAVE_MACHINE_CPUFUNC_H ) /* FreeBSD case */ #define SANE_INB 2 static int sanei_ioperm (int start, int length, int enable) { #ifdef HAVE_I386_SET_IOPERM return i386_set_ioperm (start, length, enable); #else int fd = 0; /* makes compilers happy */ start = length + enable; fd = open ("/dev/io", O_RDONLY); if (fd > 0) return 0; return -1; #endif } static unsigned char sanei_inb (unsigned int port) { return inb (port); } static void sanei_outb (unsigned int port, unsigned char value) { outb (port, value); } static void sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) { insb (port, addr, count); } static void sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) { insl (port, addr, count); } static void sanei_outsb (unsigned int port, const unsigned char *addr, unsigned long count) { outsb (port, addr, count); } static void sanei_outsl (unsigned int port, const unsigned char *addr, unsigned long count) { outsl (port, addr, count); } #endif /* FreeBSD case */ /* linux GCC on i386 */ #if ( ! defined SANE_INB ) && ( defined HAVE_SYS_IO_H ) && ( defined __GNUC__ ) && ( defined __i386__ ) #define SANE_INB 3 static int sanei_ioperm (int start, int length, int enable) { #ifdef HAVE_IOPERM return ioperm (start, length, enable); #else /* linux without ioperm ? hum ... */ /* makes compilers happy */ start = length + enable; return 0; #endif } static unsigned char sanei_inb (unsigned int port) { return inb (port); } static void sanei_outb (unsigned int port, unsigned char value) { outb (value, port); } static void sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) { insb (port, addr, count); } static void sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) { insl (port, addr, count); } static void sanei_outsb (unsigned int port, const unsigned char *addr, unsigned long count) { outsb (port, addr, count); } static void sanei_outsl (unsigned int port, const unsigned char *addr, unsigned long count) { /* oddly, 32 bit I/O are done with outsw instead of the expected outsl */ outsw (port, addr, count); } #endif /* linux GCC on i386 */ /* linux GCC non i386 */ #if ( ! defined SANE_INB ) && ( defined HAVE_SYS_IO_H ) && ( defined __GNUC__ ) && ( ! defined __i386__ ) #define SANE_INB 4 static int sanei_ioperm (int start, int length, int enable) { #ifdef HAVE_IOPERM return ioperm (start, length, enable); #else /* linux without ioperm ? hum ... */ /* makes compilers happy */ start = length + enable; return 0; #endif } static unsigned char sanei_inb (unsigned int port) { return inb (port); } static void sanei_outb (unsigned int port, unsigned char value) { outb (value, port); } static void sanei_insb (unsigned int port, unsigned char *addr, unsigned long count) { unsigned int i; for (i = 0; i < count; i++) addr[i] = sanei_inb (port); } static void sanei_insl (unsigned int port, unsigned char *addr, unsigned long count) { unsigned int i; for (i = 0; i < count * 4; i++) addr[i] = sanei_inb (port); } static void sanei_outsb (unsigned int port, const unsigned char *addr, unsigned long count) { unsigned int i; for (i = 0; i < count; i++) sanei_outb (port, addr[i]); } static void sanei_outsl (unsigned int port, const unsigned char *addr, unsigned long count) { unsigned int i; for (i = 0; i < count * 4; i++) sanei_outb (port, addr[i]); } #endif /* linux GCC non i386 */ /* ICC on i386 */ #if ( ! defined SANE_INB ) && ( defined __INTEL_COMPILER ) && ( defined __i386__ ) #define SANE_INB 5 static int sanei_ioperm (int start, int length, int enable) { #ifdef HAVE_IOPERM return ioperm (start, length, enable); #else /* ICC without ioperm() ... */ /* makes compilers happy */ start = length + enable; return 0; #endif } static unsigned char sanei_inb (unsigned int port) { unsigned char ret; __asm__ __volatile__ ("inb %%dx,%%al":"=a" (ret):"d" ((u_int) port)); return ret; } static void sanei_outb (unsigned int port, unsigned char value) { __asm__ __volatile__ ("outb %%al,%%dx"::"a" (value), "d" ((u_int) port)); } static void sanei_insb (unsigned int port, void *addr, unsigned long count) { __asm__ __volatile__ ("rep ; insb":"=D" (addr), "=c" (count):"d" (port), "0" (addr), "1" (count)); } static void sanei_insl (unsigned int port, void *addr, unsigned long count) { __asm__ __volatile__ ("rep ; insl":"=D" (addr), "=c" (count):"d" (port), "0" (addr), "1" (count)); } static void sanei_outsb (unsigned int port, const void *addr, unsigned long count) { __asm__ __volatile__ ("rep ; outsb":"=S" (addr), "=c" (count):"d" (port), "0" (addr), "1" (count)); } static void sanei_outsl (unsigned int port, const void *addr, unsigned long count) { __asm__ __volatile__ ("rep ; outsl":"=S" (addr), "=c" (count):"d" (port), "0" (addr), "1" (count)); } #endif /* ICC on i386 */ /* direct io requested, but no valid inb/oub */ #if ( ! defined SANE_INB) && ( defined ENABLE_PARPORT_DIRECTIO ) #warning "ENABLE_PARPORT_DIRECTIO cannot be used du to lack of inb/out definition" #undef ENABLE_PARPORT_DIRECTIO #endif #endif /* ENABLE_PARPORT_DIRECTIO */ /* * no inb/outb without --enable-parport-directio * */ #ifndef ENABLE_PARPORT_DIRECTIO #define SANE_INB 0 static int sanei_ioperm (__sane_unused__ int start, __sane_unused__ int length, __sane_unused__ int enable) { /* returns failure */ return -1; } static unsigned char sanei_inb (__sane_unused__ unsigned int port) { return 255; } static void sanei_outb (__sane_unused__ unsigned int port, __sane_unused__ unsigned char value) { } static void sanei_insb (__sane_unused__ unsigned int port, __sane_unused__ unsigned char *addr, __sane_unused__ unsigned long count) { } static void sanei_insl (__sane_unused__ unsigned int port, __sane_unused__ unsigned char *addr, __sane_unused__ unsigned long count) { } static void sanei_outsb (__sane_unused__ unsigned int port, __sane_unused__ const unsigned char *addr, __sane_unused__ unsigned long count) { } static void sanei_outsl (__sane_unused__ unsigned int port, __sane_unused__ const unsigned char *addr, __sane_unused__ unsigned long count) { } #endif /* ENABLE_PARPORT_DIRECTIO is not defined */ /* we need either direct io or ppdev */ #if ! defined ENABLE_PARPORT_DIRECTIO && ! defined HAVE_LINUX_PPDEV_H && ! defined HAVE_DEV_PPBUS_PPI_H #define IO_SUPPORT_MISSING #endif #include "umax_pp_low.h" #ifdef DMALLOC #include "dmalloc.h" #endif #ifndef __IO__ #define __IO__ #define DATA gPort+0x00 #define STATUS gPort+0x01 #define CONTROL gPort+0x02 #define EPPADDR gPort+0x03 #define EPPDATA gPort+0x04 #define ECPDATA gPort+0x400 #define ECR gPort+0x402 #define FIFO_WAIT 1000 #endif static int fonc001 (void); static int foncSendWord (int *cmd); static void setEPPMode (int mode); static int getEPPMode (void); static void setModel (int model); static int getModel (void); static int ringScanner (int count, unsigned long delay); static int testVersion (int no); static int probePS2 (unsigned char *dest); static int probeEPP (unsigned char *dest); static int probeECP (unsigned char *dest); static int sendCommand (int cmd); static void SPPResetLPT (void); static int sendWord (int *cmd); static int sendData (int *cmd, int len); static int receiveData (int *cmd, int len); static int sendLength (int *cmd, int len); static int waitAck (void); static void init001 (void); static int init002 (int arg); static int init005 (int arg); /* 610p comm functions */ static int putByte610p (int data); static int EPPputByte610p (int data); static int sendLength610p (int *cmd); static int sendData610p (int *cmd, int len); static int receiveData610p (int *cmd, int len); static int connect610p (void); static int sync610p (void); static int cmdSync610p (int cmd); static int EPPcmdSync610p (int cmd); static int getStatus610p (void); static int EPPgetStatus610p (void); static int disconnect610p (void); static int EPPsendWord610p (int *cmd); static int SPPsendWord610p (int *cmd); static int cmdSet610p (int cmd, int len, int *buffer); static int cmdGet610p (int cmd, int len, int *buffer); static int EPPcmdSet610p (int cmd, int len, int *buffer); static int EPPcmdGet610p (int cmd, int len, int *buffer); static int initScanner610p (int recover); static int cmdGetBuffer610p (int cmd, int len, unsigned char *buffer); /* parport mode setting */ static void compatMode (void); static void byteMode (void); static void ECPFifoMode (void); /* block transfer init */ static void ECPSetBuffer (int size); /* mode dependant operations */ static int PS2Something (int reg); static void PS2bufferRead (int size, unsigned char *dest); static void PS2bufferWrite (int size, unsigned char *source); static int PS2registerRead (int reg); static void PS2registerWrite (int reg, int value); static int EPPconnect (void); static int EPPregisterRead (int reg); static void EPPregisterWrite (int reg, int value); static void EPPbufferRead (int size, unsigned char *dest); static void EPPbufferWrite (int size, unsigned char *source); static void EPPRead32Buffer (int size, unsigned char *dest); static void EPPWrite32Buffer (int size, unsigned char *source); static int ECPconnect (void); static void ECPdisconnect (void); static int ECPregisterRead (int reg); static void ECPregisterWrite (int reg, int value); static int ECPbufferRead (int size, unsigned char *dest); static void ECPbufferWrite (int size, unsigned char *source); static int waitFifoEmpty (void); static int waitFifoNotEmpty (void); static int waitFifoFull (void); /* generic operations */ static int connect (void); static void disconnect (void); static void bufferRead (int size, unsigned char *dest); static void bufferWrite (int size, unsigned char *source); static int pausedBufferRead (int size, unsigned char *dest); static void ClearRegister (int reg); static int connect_epat (int r08); static int prologue (int r08); static int epilogue (void); static int cmdSet (int cmd, int len, int *buffer); static int cmdGet (int cmd, int len, int *buffer); static int cmdSetGet (int cmd, int len, int *buffer); static int cmdGetBuffer (int cmd, int len, unsigned char *buffer); static int cmdGetBuffer32 (int cmd, int len, unsigned char *buffer); static int cmdGetBlockBuffer (int cmd, int len, int window, unsigned char *buffer); static void bloc2Decode (int *op); static void bloc8Decode (int *op); /* * high level operations */ static int loadDefaultTables (void); static int inquire (void); static int offsetCalibration (int color, int *offRed, int *offGreen, int *offBlue); static int coarseGainCalibration (int color, int dcRed, int dcGreen, int dcBlue, int *vgaRed, int *vgaGreen, int *vgaBlue); static int shadingCalibration (int color, int dcRed, int dcGreen, int dcBlue, int vgaRed, int vgaGreen, int vgaBlue, int *calibration); static int leftShadingCalibration610p (int color, int dcRed, int dcGreen, int dcBlue, int vgaRed, int vgaGreen, int vgaBlue, int *calibration); #define WRITESLOW(x,y) \ PS2registerWrite((x),(y)); \ DBG(16,"PS2registerWrite(0x%X,0x%X) passed... (%s:%d)\n",(x),(y),__FILE__,__LINE__); #define SLOWNIBBLEREGISTERREAD(x,y) \ tmp=PS2registerRead(x);\ if(tmp!=y)\ {\ DBG(0,"PS2registerRead: found 0x%X expected 0x%X (%s:%d)\n",tmp,y,__FILE__,__LINE__);\ /*return 0;*/ \ }\ DBG(16,"PS2registerRead(0x%X)=0x%X passed... (%s:%d)\n",x,y,__FILE__,__LINE__); #define REGISTERWRITE(x,y) \ registerWrite((x),(y)); \ DBG(16,"registerWrite(0x%X,0x%X) passed... (%s:%d)\n",(x),(y),__FILE__,__LINE__); #define REGISTERREAD(x,y) \ tmp=registerRead(x);\ if(tmp!=y)\ {\ DBG(0,"registerRead, found 0x%X expected 0x%X (%s:%d)\n",tmp,y,__FILE__,__LINE__);\ return 0;\ }\ DBG(16,"registerRead(0x%X)=0x%X passed... (%s:%d)\n",x,y,__FILE__,__LINE__); #define TRACE(level,msg) DBG(level, msg" (%s:%d)\n",__FILE__,__LINE__); #define CMDSYNC(x) if(sanei_umax_pp_cmdSync(x)!=1)\ {\ DBG(0,"cmdSync(0x%02X) failed (%s:%d)\n",x,__FILE__,__LINE__);\ return 0;\ }\ DBG(16,"cmdSync(0x%02X)=%02X passed ... (%s:%d)\n",x,sanei_umax_pp_scannerStatus(),__FILE__,__LINE__) #define CMDSETGET(cmd,len,sent) if(cmdSetGet(cmd,len,sent)!=1)\ {\ DBG(0,"cmdSetGet(0x%02X,%d,sent) failed (%s:%d)\n",cmd,len,__FILE__,__LINE__);\ return 0;\ }\ TRACE(16,"cmdSetGet() passed ...") #define YOFFSET 40 #define YOFFSET1220P 40 #define YOFFSET2000P 40 #define COMPLETIONWAIT if(completionWait()==0)\ {\ DBG(0,"completionWait() failed (%s:%d)\n",__FILE__,__LINE__);\ return 0;\ }\ TRACE(16,"completionWait() passed ...") #define MOVE(x,y,t) if(move(x,y,t)==0)\ {\ DBG(0,"move(%d,%d,buffer) failed (%s:%d)\n",x,y,__FILE__,__LINE__);\ return 0;\ }\ TRACE(16,"move() passed ...") #define CMDGETBUF(cmd,len,sent) if(cmdGetBuffer(cmd,len,sent)!=1)\ {\ DBG(0,"cmdGetBuffer(0x%02X,%ld,buffer) failed (%s:%d)\n",cmd,(long)len,__FILE__,__LINE__);\ return 0;\ }\ DBG(16,"cmdGetBuffer(%ld) passed ... (%s:%d)\n",(long)len,__FILE__,__LINE__); #define CMDGETBUF32(cmd,len,sent) if(cmdGetBuffer32(cmd,len,sent)!=1)\ {\ DBG(0,"cmdGetBuffer32(0x%02X,%ld,buffer) failed (%s:%d)\n",cmd,(long)len,__FILE__,__LINE__);\ return 0;\ }\ TRACE(16,"cmdGetBuffer32() passed ...") #define CMDSET(cmd,len,sent) if(cmdSet(cmd,len,sent)!=1)\ {\ DBG(0,"cmdSet(0x%02X,%d,sent) failed (%s:%d)\n",cmd,len,__FILE__,__LINE__);\ return 0;\ }\ TRACE(16,"cmdSet() passed ...") #define CMDGET(cmd,len,sent) if(cmdGet(cmd,len,sent)!=1)\ {\ DBG(0,"cmdGet(0x%02X,%d,read) failed (%s:%d)\n",cmd,len,__FILE__,__LINE__);\ return 0;\ }\ TRACE(16,"cmdGet() passed ...") static int gPort = 0x378; static float targetCode = 250.0; /* global control vars */ static int gControl = 0; static int gData = 0; static int g674 = 0; /* semble indiquer qu'on utilise les IRQ */ static int g67D = 0; static int g67E = 0; static int gEPAT = 0; /* signals fast mode ? */ static int g6FE = 0; static int gECP = 0; static int gLeft = 144; /* default value for 1220P */ /* default gamma translation table */ static int ggamma[256] = { 0x00, 0x06, 0x0A, 0x0D, 0x10, 0x12, 0x14, 0x17, 0x19, 0x1B, 0x1D, 0x1F, 0x21, 0x23, 0x24, 0x26, 0x28, 0x2A, 0x2B, 0x2D, 0x2E, 0x30, 0x31, 0x33, 0x34, 0x36, 0x37, 0x39, 0x3A, 0x3B, 0x3D, 0x3E, 0x40, 0x41, 0x42, 0x43, 0x45, 0x46, 0x47, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB8, 0xB9, 0xBA, 0xBB, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xBF, 0xC0, 0xC1, 0xC2, 0xC2, 0xC3, 0xC4, 0xC5, 0xC5, 0xC6, 0xC7, 0xC8, 0xC8, 0xC9, 0xCA, 0xCB, 0xCB, 0xCC, 0xCD, 0xCE, 0xCE, 0xCF, 0xD0, 0xD1, 0xD1, 0xD2, 0xD3, 0xD4, 0xD4, 0xD5, 0xD6, 0xD6, 0xD7, 0xD8, 0xD9, 0xD9, 0xDA, 0xDB, 0xDC, 0xDC, 0xDD, 0xDE, 0xDE, 0xDF, 0xE0, 0xE1, 0xE1, 0xE2, 0xE3, 0xE3, 0xE4, 0xE5, 0xE6, 0xE6, 0xE7, 0xE8, 0xE8, 0xE9, 0xEA, 0xEA, 0xEB, 0xEC, 0xEC, 0xED, 0xEE, 0xEF, 0xEF, 0xF0, 0xF1, 0xF1, 0xF2, 0xF3, 0xF3, 0xF4, 0xF5, 0xF5, 0xF6, 0xF7, 0xF7, 0xF8, 0xF9, 0xF9, 0xFA, 0xFB, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFF }; /* default gamma translation table */ static int *ggGreen = ggamma; static int *ggBlue = ggamma; static int *ggRed = ggamma; static int gParport = 0; static int gCancel = 0; static int gAutoSettings = 1; /*****************************************************************************/ /* output one byte on given port */ /*****************************************************************************/ static void Outb (int port, int value); /*****************************************************************************/ /* ouput 'size' bytes stored in 'source' on given port */ /*****************************************************************************/ static void Outsb (int port, unsigned char *source, int size); /*****************************************************************************/ /* ouput 'size' 32 bits words stored in 'source' on given port */ /*****************************************************************************/ static void Outsw (int port, unsigned char *source, int size); /*****************************************************************************/ /* input one byte from given port */ /*****************************************************************************/ static int Inb (int port); /*****************************************************************************/ /* input 'size' bytes from given port ans store them in 'dest' */ /*****************************************************************************/ static void Insb (int port, unsigned char *dest, int size); /*****************************************************************************/ /* input 'size' 32 bits word from given port ans store them in 'dest' */ /*****************************************************************************/ static void Insw (int port, unsigned char *dest, int size); char ** sanei_parport_find_port (void) { char **ports = NULL; #ifdef ENABLE_PARPORT_DIRECTIO int i, addr, ecpaddr; int found = 0; char name[80], buffer[80]; FILE *fic = NULL; /* direct I/O detection */ /* linux 2.4 + 2.6 with proc support */ for (i = 0; i < 4; i++) { /* try to ensure loading of lp module */ sprintf (name, "/dev/lp%d", i); fic = fopen (name, "wb"); if (fic != NULL) fclose (fic); sprintf (name, "/proc/sys/dev/parport/parport%d/base-addr", i); fic = fopen (name, "rb"); if (fic != NULL) { fread (buffer, 64, 1, fic); fclose (fic); if (sscanf (buffer, "%d %d", &addr, &ecpaddr) > 0) { DBG (16, "parport at 0x%X\n", addr); ports = (char **) realloc (ports, (found + 2) * sizeof (char *)); ports[found] = (char *) malloc (19); sprintf (ports[found], "0x%X", addr); found++; ports[found] = NULL; } } } #endif return ports; } char ** sanei_parport_find_device (void) { char *devices[] = { /* FreeBSD */ "/dev/ppi0", "/dev/ppi1", "/dev/ppi2", "/dev/ppi3", /* linux ppdev with devfs */ "/dev/parports/0", "/dev/parports/1", "/dev/parports/2", "/dev/parports/3", /* linux ppdev */ "/dev/parport0", "/dev/parport1", "/dev/parport2", "/dev/parport3", NULL }; int i, file; int rc = 0; int found = 0; char **ports = NULL; /* device finding */ i = 0; while (devices[i] != NULL) { DBG (16, "Controlling %s: ", devices[i]); file = open (devices[i], O_RDWR); if (file < 0) { switch (errno) { case ENOENT: #ifdef ENIO case ENXIO: #endif #ifdef ENODEV case ENODEV: #endif DBG (16, "no %s device ...\n", devices[i]); break; case EACCES: DBG (16, "current user cannot use existing %s device ...\n", devices[i]); break; default: perror (devices[i]); } } else { #ifdef HAVE_LINUX_PPDEV_H /* on kernel < 2.4.23, you have to CLAIM the device * to check it really exists * we may hang if another program already claimed it */ rc = ioctl (file, PPCLAIM); if (rc) { switch (errno) { case ENOENT: #ifdef ENXIO case ENXIO: #endif #ifdef ENODEV case ENODEV: #endif DBG (16, "no %s device ...\n", devices[i]); break; case EACCES: DBG (16, "current user cannot use existing %s device ...\n", devices[i]); break; default: DBG (16, "errno=%d\n", errno); perror (devices[i]); } } else { rc = ioctl (file, PPRELEASE); } #endif /* HAVE_LINUX_PPDEV_H */ close (file); if (!rc) { DBG (16, "adding %s to valid devices ...\n", devices[i]); ports = (char **) realloc (ports, (found + 2) * sizeof (char *)); ports[found] = strdup (devices[i]); found++; ports[found] = NULL; } } /* suite */ i++; } return ports; } /* * gain direct acces to IO port, and set parport to the 'right' mode * returns 1 on success, 0 an failure */ int sanei_umax_pp_initPort (int port, const char *name) { #ifndef IO_SUPPORT_MISSING # ifdef HAVE_LINUX_PPDEV_H int found = 0; int fd; int mode, modes, rc; # ifdef PPGETMODES char strmodes[160]; # endif # endif # ifdef HAVE_DEV_PPBUS_PP_H int found = 0; int fd; # endif # ifdef HAVE_IOPERM int ectr; # endif #endif /* since this function must be called before */ /* any other, we put debug init here */ DBG_INIT (); DBG (1, "SANE_INB level %d\n", SANE_INB); /* sets global vars */ ggGreen = ggamma; ggBlue = ggamma; ggRed = ggamma; gParport = 0; gCancel = 0; gAutoSettings = 1; gControl = 0; gData = 0; g674 = 0; g67D = 0; g67E = 0; gEPAT = 0; g6FE = 0; sanei_umax_pp_setparport (0); DBG (1, "sanei_umax_pp_InitPort(0x%X,%s)\n", port, name); #ifndef ENABLE_PARPORT_DIRECTIO if ((name == NULL) || ((name != NULL) && (strlen (name) < 4))) { DBG (0, "sanei_umax_pp_InitPort cannot use direct hardware access\n"); DBG (0, "if not compiled with --enable-parport-directio\n"); return 0; } #endif /* init global var holding port value */ gPort = port; #ifdef IO_SUPPORT_MISSING DBG (1, "*** Direct I/O or ppdev unavailable, giving up ***\n"); return 0; #else #ifdef HAVE_LINUX_PPDEV_H if (name != NULL) { if (strlen (name) > 3) { /* ppdev opening and configuration */ found = 0; fd = open (name, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd < 0) { switch (errno) { case ENOENT: DBG (1, "umax_pp: '%s' does not exist \n", name); break; case EACCES: DBG (1, "umax_pp: current user has not R/W permissions on '%s' \n", name); break; } return 0; } /* claim port */ if (ioctl (fd, PPCLAIM)) { DBG (1, "umax_pp: cannot claim port '%s'\n", name); } else { /* we check if parport does EPP or ECP */ #ifdef PPGETMODES if (ioctl (fd, PPGETMODES, &modes)) { DBG (16, "umax_pp: ppdev couldn't gave modes for port '%s'\n", name); } else { snprintf(strmodes, sizeof(strmodes), "\n%s%s%s%s%s%s", (modes & PARPORT_MODE_PCSPP)? "\t\tPARPORT_MODE_PCSPP\n": "", (modes & PARPORT_MODE_TRISTATE)? "\t\tPARPORT_MODE_TRISTATE\n": "", (modes & PARPORT_MODE_EPP)? "\t\tPARPORT_MODE_EPP\n": "", (modes & PARPORT_MODE_ECP)? "\t\tPARPORT_MODE_ECP\n": "", (modes & PARPORT_MODE_COMPAT)? "\t\tPARPORT_MODE_COMPAT\n": "", (modes & PARPORT_MODE_DMA)? "\t\tPARPORT_MODE_DMA\n": ""); if (modes & PARPORT_MODE_ECP) { gECP = 1; } DBG (32, "parport modes: %X\n", modes); DBG (32, "parport modes: %s\n", strmodes); if (!(modes & PARPORT_MODE_EPP) && !(modes & PARPORT_MODE_ECP)) { DBG (1, "port 0x%X does not have EPP or ECP, giving up ...\n", port); mode = IEEE1284_MODE_COMPAT; ioctl (fd, PPSETMODE, &mode); ioctl (fd, PPRELEASE); close (fd); return 0; } } #else DBG (16, "umax_pp: ppdev used to build SANE doesn't have PPGETMODES.\n"); /* faking result */ modes = 0xFFFFFFFF; #endif mode = 0; /* prefered mode is EPP */ if (modes & PARPORT_MODE_EPP) { mode = IEEE1284_MODE_EPP; /* negot allways fail here ... */ rc = ioctl (fd, PPNEGOT, &mode); if (rc) { DBG (16, "umax_pp: ppdev couldn't negotiate mode IEEE1284_MODE_EPP for '%s' (ignored)\n", name); } if (ioctl (fd, PPSETMODE, &mode)) { DBG (16, "umax_pp: ppdev couldn't set mode to IEEE1284_MODE_EPP for '%s'\n", name); /* signal failure for ECP test */ mode = 0; } else { DBG (16, "umax_pp: mode set to PARPORT_MODE_EPP for '%s'\n", name); } } if ((modes & PARPORT_MODE_ECP) && (mode == 0)) { mode = IEEE1284_MODE_ECP; rc = ioctl (fd, PPNEGOT, &mode); if (rc) { DBG (16, "umax_pp: ppdev couldn't negotiate mode IEEE1284_MODE_ECP for '%s' (ignored)\n", name); } if (ioctl (fd, PPSETMODE, &mode)) { DBG (16, "umax_pp: ppdev couldn't set mode to IEEE1284_MODE_ECP for '%s'\n", name); DBG (1, "port 0x%X can't be set to EPP or ECP, giving up ...\n", port); mode = IEEE1284_MODE_COMPAT; ioctl (fd, PPSETMODE, &mode); ioctl (fd, PPRELEASE); close (fd); return 0; } else { gECP = 1; DBG (16, "umax_pp: mode set to PARPORT_MODE_ECP for '%s'\n", name); } } /* allways start in compat mode (for probe) */ mode = IEEE1284_MODE_COMPAT; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = 0; /* data forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = 1; /* FW IDLE */ rc = ioctl (fd, PPSETPHASE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); found = 1; } if (!found) { DBG (1, "device %s does not fit ...\n", name); } else { DBG (1, "Using %s ...\n", name); sanei_umax_pp_setparport (fd); return 1; } } } #endif /* HAVE_LINUX_PPDEV_H */ #ifdef HAVE_DEV_PPBUS_PPI_H /* the ppi device let user access to parallel port on freebsd */ if (name != NULL) { if (strlen (name) > 3) { /* ppi opening and configuration */ found = 0; fd = open (name, O_RDONLY); if (fd < 0) { switch (errno) { case ENOENT: DBG (1, "umax_pp: '%s' does not exist \n", name); break; case EACCES: DBG (1, "umax_pp: current user has not read permissions on '%s' \n", name); break; } return 0; } else { DBG (1, "Using %s ...\n", name); sanei_umax_pp_setparport (fd); return 1; } } } #endif /* HAVE_DEV_PPBUS_PPI_H */ if (port < 0x400) { if (sanei_ioperm (port, 8, 1) != 0) { DBG (1, "sanei_ioperm() could not gain access to 0x%X\n", port); return 0; } DBG (1, "sanei_ioperm(0x%X, 8, 1) OK ...\n", port); } #ifdef HAVE_IOPERM /* ECP i/o range */ if (iopl (3) != 0) { DBG (1, "iopl could not raise IO permission to level 3\n"); DBG (1, "*NO* ECP support\n"); } else { /* any ECP out there ? */ ectr = Inb (ECR); if (ectr != 0xFF) { gECP = 1; } } #endif #endif /* IO_SUPPORT_MISSING */ return 1; } static void Outb (int port, int value) { #ifndef IO_SUPPORT_MISSING #ifdef HAVE_LINUX_PPDEV_H int fd, rc, mode, exmode; unsigned char val; fd = sanei_umax_pp_getparport (); val = (unsigned char) value; if (fd > 0) { /* there should be ECR that doesn't go through ppdev */ /* it will leave when all the I/O will be done with ppdev */ switch (port - gPort) { case 0: rc = ioctl (fd, PPWDATA, &val); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #ifdef IOLOG DBG (0, "outb DATA,%02X\n", value); #endif return; case 2: mode = val & 0x20; rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); val = val & 0xDF; rc = ioctl (fd, PPWCONTROL, &val); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #ifdef IOLOG DBG (0, "outb CONTROL,%02X\n", value); #endif return; case 4: rc = ioctl (fd, PPGETMODE, &exmode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = 0; /* data forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &val, 1); if (rc != 1) DBG (0, "ppdev short write (%s:%d)\n", __FILE__, __LINE__); rc = ioctl (fd, PPSETMODE, &exmode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #ifdef IOLOG DBG (0, "outb EPPDATA,%02X\n", value); #endif return; case 3: rc = ioctl (fd, PPGETMODE, &exmode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = 0; /* data forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &val, 1); if (rc != 1) DBG (0, "ppdev short write (%s:%d)\n", __FILE__, __LINE__); rc = ioctl (fd, PPSETMODE, &exmode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; case 0x400: case 0x402: break; default: DBG (16, "Outb(0x%03X,0x%02X) escaped ppdev\n", port, value); return; } } #endif /* HAVE_LINUX_PPDEV_H */ #ifdef HAVE_DEV_PPBUS_PPI_H int fd, rc; unsigned char val; fd = sanei_umax_pp_getparport (); val = (unsigned char) value; if (fd > 0) { switch (port - gPort) { case 0: rc = ioctl (fd, PPISDATA, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; case 1: rc = ioctl (fd, PPISSTATUS, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; case 2: rc = ioctl (fd, PPISCTRL, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; case 3: rc = ioctl (fd, PPISEPPA, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; case 4: rc = ioctl (fd, PPISEPPD, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; case 0x402: rc = ioctl (fd, PPISECR, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; default: DBG (16, "Outb(0x%03X,0x%02X) escaped ppi\n", port, value); return; } } #endif /* HAVE_DEV_PPBUS_PPI_H */ sanei_outb (port, value); #endif /* IO_SUPPORT_MISSING */ } static int Inb (int port) { int res = 0xFF; #ifndef IO_SUPPORT_MISSING #ifdef HAVE_LINUX_PPDEV_H int fd, rc, mode; unsigned char val; fd = sanei_umax_pp_getparport (); if (fd > 0) { /* there should be ECR that doesn't go through ppdev */ /* it will leave when all the I/O will be done with ppdev */ switch (port - gPort) { case 0: rc = ioctl (fd, PPRDATA, &val); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; #ifdef IOLOG DBG (0, "inb DATA,%02X\n", res); #endif return res; case 1: rc = ioctl (fd, PPRSTATUS, &val); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; #ifdef IOLOG DBG (0, "inb STATUS,%02X\n", res); #endif return res; case 2: rc = ioctl (fd, PPRCONTROL, &val); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; #ifdef IOLOG DBG (0, "inb CONTROL,%02X\n", res); #endif return res; case 4: mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = read (fd, &val, 1); if (rc != 1) DBG (0, "ppdev short read (%s:%d)\n", __FILE__, __LINE__); mode = 0; /* data_forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; #ifdef IOLOG DBG (0, "inb EPPDATA,%02X\n", res); #endif return res; case 0x400: case 0x402: default: DBG (16, "Inb(0x%03X) escaped ppdev\n", port); return 0xFF; } } #endif /* HAVE_LINUX_PPDEV_H */ #ifdef HAVE_DEV_PPBUS_PPI_H int fd, rc; unsigned char val; fd = sanei_umax_pp_getparport (); if (fd > 0) { switch (port - gPort) { case 0: rc = ioctl (fd, PPIGDATA, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; return res; case 1: rc = ioctl (fd, PPIGSTATUS, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; return res; case 2: rc = ioctl (fd, PPIGCTRL, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; return res; case 3: rc = ioctl (fd, PPIGEPPA, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; return res; case 4: rc = ioctl (fd, PPIGEPPD, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; return res; case 0x402: rc = ioctl (fd, PPIGECR, &val); if (rc) DBG (0, "ppi ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); res = val; return res; default: DBG (16, "Inb(0x%03X) escaped ppi\n", port); return 0xFF; } } #endif /* HAVE_DEV_PPBUS_PPI_H */ res = sanei_inb (port); #endif /* IO_SUPPORT_MISSING */ return res; } static void Insb (int port, unsigned char *dest, int size) { #ifndef IO_SUPPORT_MISSING #ifdef HAVE_DEV_PPBUS_PPI_H int i; if (sanei_umax_pp_getparport () > 0) { for (i = 0; i < size; i++) dest[i] = Inb (port); return; } #endif /* HAVE_DEV_PPBUS_PPI_H */ sanei_insb (port, dest, size); #endif } static void Outsb (int port, unsigned char *source, int size) { #ifndef IO_SUPPORT_MISSING #ifdef HAVE_DEV_PPBUS_PPI_H int i; if (sanei_umax_pp_getparport () > 0) { for (i = 0; i < size; i++) Outb (port, source[i]); return; } #endif /* HAVE_DEV_PPBUS_PPI_H */ sanei_outsb (port, source, size); #endif } /* size = nb words */ static void Insw (int port, unsigned char *dest, int size) { #ifndef IO_SUPPORT_MISSING #ifdef HAVE_DEV_PPBUS_PPI_H int i; if (sanei_umax_pp_getparport () > 0) { for (i = 0; i < size * 4; i++) dest[i] = Inb (port); return; } #endif /* HAVE_DEV_PPBUS_PPI_H */ sanei_insl (port, dest, size); #endif } static void Outsw (int port, unsigned char *source, int size) { #ifndef IO_SUPPORT_MISSING #ifdef HAVE_DEV_PPBUS_PPI_H int i; if (sanei_umax_pp_getparport () > 0) { for (i = 0; i < size * 4; i++) Outb (port, source[i]); return; } #endif /* HAVE_DEV_PPBUS_PPI_H */ sanei_outsl (port, source, size); #endif } /* we're trying to gather information on the scanner here, */ /* and published it through an easy interface */ /* will turn it into a struct when 610P code will be done */ static int scannerStatus = 0; static time_t gTime = 0; static time_t gDelay = 0; static int epp32 = 1; static int gMode = 0; static int gprobed = 0; static int model = 0x15; static int astra = 0; static int hasUTA = 0; /* signals that scan width matches full ccd width */ static int fullCCDWidth = 0; int sanei_umax_pp_getfull (void) { return fullCCDWidth; } void sanei_umax_pp_setfull (int mod) { fullCCDWidth = mod; } int sanei_umax_pp_UTA (void) { return hasUTA; } int sanei_umax_pp_scannerStatus (void) { struct timeval tv; /* the 610P ASIC needs some time to settle down after probe */ if ((gTime > 0) && (gDelay > 0)) { gettimeofday (&tv, NULL); /* delay elapsed ? */ if (tv.tv_sec - gTime < gDelay) /* still waiting */ return ASIC_BIT; /* wait finished */ gDelay = 0; gTime = 0; } /* 0x07 variant returns status with bit 0 or 1 allways set to 1 */ /* so we mask it out */ return scannerStatus & 0xFC; } static int getEPPMode (void) { if (epp32) return 32; return 8; } static void setEPPMode (int mode) { if (mode == 8) epp32 = 0; else epp32 = 1; } static int getModel (void) { return model; } static void setModel (int mod) { model = mod; } int sanei_umax_pp_getparport (void) { return gParport; } void sanei_umax_pp_setparport (int fd) { gParport = fd; } int sanei_umax_pp_getport (void) { return gPort; } void sanei_umax_pp_setport (int port) { gPort = port; } int sanei_umax_pp_getastra (void) { return astra; } void sanei_umax_pp_setastra (int mod) { astra = mod; } int sanei_umax_pp_getLeft (void) { switch (sanei_umax_pp_getastra ()) { case 610: return 92; default: return 144; } } void sanei_umax_pp_setLeft (int mod) { gLeft = mod; } int sanei_umax_pp_getauto (void) { return gAutoSettings; } void sanei_umax_pp_setauto (int autoset) { gAutoSettings = autoset; } #ifdef HAVE_LINUX_PPDEV_H /* set to the parallel port needed using ppdev * returns 1 if ok, 0 else */ static int ppdev_set_mode (int mode) { int fd, rc; /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { rc = ioctl (fd, PPSETMODE, &mode); if (rc) { DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return 0; } return 1; } return 0; } #endif /* set parallel port mode to 'compatible'*/ static void compatMode (void) { #ifdef HAVE_LINUX_PPDEV_H if (ppdev_set_mode (IEEE1284_MODE_COMPAT)) return; #endif if (!gECP) return; Outb (ECR, 0x15); } /* set parallel port mode to 'bidirectionel'*/ static void byteMode (void) { #ifdef HAVE_LINUX_PPDEV_H if (ppdev_set_mode (IEEE1284_MODE_BYTE)) return; #endif if (!gECP) return; Outb (ECR, 0x35); /* or 0x34 */ } /* set parallel port mode to 'fifo'*/ static void ECPFifoMode (void) { /* bits 7:5 : 000 Standard Mode 001 Byte Mode 010 Parallel Port FIFO Mode 011 ECP FIFO Mode 100 EPP Mode 101 Reserved 110 FIFO Test Mode 111 Configuration Mode */ /* logged as 74/75 */ #ifdef HAVE_LINUX_PPDEV_H if (ppdev_set_mode (IEEE1284_MODE_ECP)) return; #endif if (!gECP) return; Outb (ECR, 0x75); } /* wait for ack bit */ /* return 1 on success, 0 on error */ static int waitAck () { unsigned char breg = 0; int i = 0; Outb (CONTROL, 0x0C); /* select printer + initialize printer */ Outb (CONTROL, 0x0C); Outb (CONTROL, 0x0C); breg = Inb (STATUS) & 0xF8; while ((i < 1024) && ((breg & 0x04) == 0)) { Outb (CONTROL, 0x0E); /* autolinefeed ?.. */ Outb (CONTROL, 0x0E); Outb (CONTROL, 0x0E); breg = Inb (STATUS) & 0xF8; i++; usleep (1000); } if (i == 1024) { DBG (1, "waitAck failed, time-out waiting for Ack (%s:%d)\n", __FILE__, __LINE__); /* return 0; seems to be non-blocking ... */ } Outb (CONTROL, 0x04); /* printer reset */ Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); return 1; } static int waitFifoEmpty (void) { int i; unsigned char breg; breg = Inb (ECR); i = 0; while ((i < FIFO_WAIT) && ((breg & 0x01) == 0)) { breg = Inb (ECR); i++; } if (i == FIFO_WAIT) { DBG (0, "waitFifoEmpty failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return 0; } return 1; } static int waitFifoNotEmpty (void) { int i; unsigned char breg; breg = Inb (ECR); i = 0; while ((i < FIFO_WAIT) && ((breg & 0x01) != 0)) { breg = Inb (ECR); i++; /* usleep (2000); */ } if (i == FIFO_WAIT) { DBG (0, "waitFifoNotEmpty failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return 0; } return 1; } static int waitFifoFull (void) { int i; unsigned char breg; breg = Inb (ECR); /* two wait loop */ /* the first apply to fast data transfer (ie when no scaaning is undergoing) */ /* and we fallback to the second in case the scanner is answering slowly */ i = 0; while ((i < FIFO_WAIT) && ((breg & 0x02) == 0)) { breg = Inb (ECR); i++; } /* don't need to wait any longer */ if (i < FIFO_WAIT) return 1; i = 0; while ((i < FIFO_WAIT) && ((breg & 0x02) == 0)) { breg = Inb (ECR); i++; usleep (500); } if (i == FIFO_WAIT) { DBG (0, "waitFifoFull failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return 0; } return 1; } /* * surely some register reading in PS2 mode * only one nibble is accessed, may be * PS2RegisterLowNibbleRead(reg) */ static int PS2Something (int reg) { unsigned char breg, low, high = 0; Outb (CONTROL, 0x04); Outb (DATA, reg); /* register number ? */ Outb (CONTROL, 0x06); Outb (CONTROL, 0x06); Outb (CONTROL, 0x06); breg = Inb (STATUS) & 0xF8; low = breg; breg = breg & 0x08; /* surely means register(0x10)=0x0B */ /* since reg & 0x08 != 0, high and low nibble * differ, but we don't care, since we surely expect it * to be 0 */ if (breg != 0x08) { DBG (0, "PS2Something failed, expecting 0x08, got 0x%02X (%s:%d)\n", breg, __FILE__, __LINE__); } Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); if (breg != 0x08) high = Inb (STATUS) & 0xF0; return high + ((low & 0xF0) >> 4); } static int PS2Read (void) { int res; int tmp; res = Inb (STATUS); res = Inb (STATUS); res = res & 0xF0; Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); tmp = Inb (STATUS); tmp = Inb (STATUS); tmp = (tmp & 0xF0) >> 4; res = res | tmp; Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 5); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); return res; } /******************************************************************************/ /* PS2registerWrite: write value in register, slow method */ /******************************************************************************/ static void PS2registerWrite (int reg, int value) { /* select register */ Outb (DATA, reg | 0x60); Outb (DATA, reg | 0x60); Outb (CONTROL, 0x01); Outb (CONTROL, 0x01); Outb (CONTROL, 0x01); /* send value */ Outb (DATA, value); Outb (DATA, value); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); } /*****************************************************************************/ /* Send command returns 0 on failure, 1 on success */ /*****************************************************************************/ static int sendCommand (int cmd) { int control; int tmp; int val; int i; if (g674 != 0) { DBG (0, "No scanner attached, sendCommand(0x%X) failed\n", cmd); return 0; } control = Inb (CONTROL) & 0x3F; tmp = cmd & 0xF8; if ((g67D != 1) && (tmp != 0xE0) && (tmp != 0x20) && (tmp != 0x40) && (tmp != 0xD0) && (tmp != 0x08) && (tmp != 0x48)) { Outb (CONTROL, 4); /* reset printer */ } else { val = control & 0x1F; if (g67D != 1) val = val & 0xF; /* no IRQ */ val = val | 0x4; Outb (CONTROL, val); Outb (CONTROL, val); } /* send sequence */ Outb (DATA, 0x22); Outb (DATA, 0x22); Outb (DATA, 0xAA); Outb (DATA, 0xAA); Outb (DATA, 0x55); Outb (DATA, 0x55); Outb (DATA, 0x00); Outb (DATA, 0x00); Outb (DATA, 0xFF); Outb (DATA, 0xFF); Outb (DATA, 0x87); Outb (DATA, 0x87); Outb (DATA, 0x78); Outb (DATA, 0x78); Outb (DATA, cmd); Outb (DATA, cmd); cmd = cmd & 0xF8; if ((g67D == 1) && (cmd == 0xE0)) { val = Inb (CONTROL); val = (val & 0xC) | 0x01; Outb (CONTROL, val); Outb (CONTROL, val); val = val & 0xC; Outb (CONTROL, val); Outb (CONTROL, val); goto sendCommandEnd; } if ((cmd != 8) && (cmd != 0x48)) { tmp = Inb (CONTROL); tmp = Inb (CONTROL); tmp = tmp & 0x1E; if (g67D != 1) tmp = tmp & 0xE; Outb (CONTROL, tmp); Outb (CONTROL, tmp); } if (cmd == 0x10) { tmp = PS2Read (); tmp = tmp * 256 + PS2Read (); goto sendCommandEnd; } if (cmd == 8) { if (g67D == 1) { i = 0; while (i < g67E) { tmp = Inb (CONTROL); tmp = Inb (CONTROL); tmp = (tmp & 0x1E) | 0x1; Outb (CONTROL, tmp); Outb (CONTROL, tmp); Inb (STATUS); tmp = tmp & 0x1E; Outb (CONTROL, tmp); Outb (CONTROL, tmp); /* next read */ i++; if (i < g67E) { Outb (DATA, i | 8); Outb (DATA, i | 8); } } goto sendCommandEnd; } else { DBG (0, "UNEXPLORED BRANCH %s:%d\n", __FILE__, __LINE__); return 0; } } /* */ if (cmd == 0) { i = 0; do { tmp = Inb (CONTROL); tmp = (tmp & 0xE) | 0x1; Outb (CONTROL, tmp); Outb (CONTROL, tmp); tmp = tmp & 0xE; Outb (CONTROL, tmp); Outb (CONTROL, tmp); i++; if (i < g67E) { Outb (DATA, i); Outb (DATA, i); } } while (i < g67E); goto sendCommandEnd; } if (cmd == 0x48) { /* this case is unneeded, should fit with the rest */ tmp = Inb (CONTROL) & 0x1E; if (g67D != 1) tmp = tmp & 0xE; Outb (CONTROL, tmp | 0x1); Outb (CONTROL, tmp | 0x1); Outb (CONTROL, tmp); Outb (CONTROL, tmp); goto sendCommandEnd; } /* */ tmp = Inb (CONTROL) & 0x1E; if (g67D != 1) tmp = tmp & 0xE; Outb (CONTROL, tmp | 0x1); Outb (CONTROL, tmp | 0x1); Outb (CONTROL, tmp); Outb (CONTROL, tmp); /* success */ sendCommandEnd: if (cmd == 0x48) Outb (CONTROL, (control & 0xF) | 0x4); if (cmd == 0x30) Outb (CONTROL, (gControl & 0xF) | 0x4); /* end signature */ Outb (DATA, 0xFF); Outb (DATA, 0xFF); if (cmd == 8) { Outb (CONTROL, control); return 1; } if (cmd == 0x30) { Outb (CONTROL, gControl); return 1; } if (cmd != 0xE0) Outb (CONTROL, control); return 1; } static void ClearRegister (int reg) { /* choose register */ Outb (DATA, reg); Outb (DATA, reg); Outb (CONTROL, 1); Outb (CONTROL, 1); if ((g6FE == 0) || (g674 != 0)) { Outb (CONTROL, 1); Outb (CONTROL, 1); Outb (CONTROL, 1); Outb (CONTROL, 1); } /* clears it by not sending new value */ Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); } static void SPPResetLPT (void) { Outb (CONTROL, 0x04); } static int PS2registerRead (int reg) { int low, high; /* send register number */ Outb (DATA, reg); Outb (DATA, reg); /* get low nibble */ Outb (CONTROL, 1); Outb (CONTROL, 3); Outb (CONTROL, 3); Outb (CONTROL, 3); Outb (CONTROL, 3); low = Inb (STATUS); low = Inb (STATUS); /* get high nibble */ Outb (CONTROL, 4); Outb (CONTROL, 4); Outb (CONTROL, 4); high = Inb (STATUS); high = Inb (STATUS); /* merge nibbles and return */ high = (high & 0xF0) | ((low & 0xF0) >> 4); return high; } static void PS2bufferRead (int size, unsigned char *dest) { int high; int low; int i; int count; int bytel, byteh; /* init transfer */ Outb (DATA, 7); Outb (DATA, 7); Outb (CONTROL, 1); Outb (CONTROL, 1); Outb (CONTROL, 3); Outb (CONTROL, 3); Outb (CONTROL, 3); Outb (DATA, 0xFF); Outb (DATA, 0xFF); count = (size - 2) / 2; i = 0; bytel = 0x06; /* signals low byte of word */ byteh = 0x07; /* signals high byte of word */ /* read loop */ while (count > 0) { /* low nibble byte 0 */ Outb (CONTROL, bytel); Outb (CONTROL, bytel); Outb (CONTROL, bytel); low = Inb (STATUS); if ((low & 0x08) == 0) { /* high nibble <> low nibble */ Outb (CONTROL, bytel & 0x05); Outb (CONTROL, bytel & 0x05); Outb (CONTROL, bytel & 0x05); high = Inb (STATUS); } else { high = low; } low = low & 0xF0; high = high & 0xF0; dest[i] = (unsigned char) (high | (low >> 4)); i++; /* low nibble byte 1 */ Outb (CONTROL, byteh); Outb (CONTROL, byteh); Outb (CONTROL, byteh); low = Inb (STATUS); if ((low & 0x08) == 0) { /* high nibble <> low nibble */ Outb (CONTROL, byteh & 0x05); Outb (CONTROL, byteh & 0x05); Outb (CONTROL, byteh & 0x05); high = Inb (STATUS); } else { high = low; } low = low & 0xF0; high = high & 0xF0; dest[i] = (unsigned char) (high | (low >> 4)); i++; /* next read */ count--; } /* final read */ /* low nibble byte 0 */ Outb (CONTROL, bytel); Outb (CONTROL, bytel); Outb (CONTROL, bytel); low = Inb (STATUS); if ((low & 0x08) == 0) { /* high nibble <> low nibble */ Outb (CONTROL, bytel & 0x05); Outb (CONTROL, bytel & 0x05); Outb (CONTROL, bytel & 0x05); high = Inb (STATUS); } else { high = low; } low = low & 0xF0; high = high & 0xF0; dest[i] = (unsigned char) (high | (low >> 4)); i++; /* uneven size need an extra read */ if ((size & 0x01) == 1) { /* low nibble byte 1 */ Outb (CONTROL, byteh); Outb (CONTROL, byteh); Outb (CONTROL, byteh); low = Inb (STATUS); if ((low & 0x08) == 0) { /* high nibble <> low nibble */ Outb (CONTROL, byteh & 0x05); Outb (CONTROL, byteh & 0x05); Outb (CONTROL, byteh & 0x05); high = Inb (STATUS); } else { high = low; } low = low & 0xF0; high = high & 0xF0; dest[i] = (unsigned char) (high | (low >> 4)); i++; /* swap high/low word */ count = bytel; bytel = byteh; byteh = count; } /* final byte ... */ Outb (DATA, 0xFD); Outb (DATA, 0xFD); Outb (DATA, 0xFD); /* low nibble */ Outb (CONTROL, byteh); Outb (CONTROL, byteh); Outb (CONTROL, byteh); low = Inb (STATUS); if ((low & 0x08) == 0) { /* high nibble <> low nibble */ Outb (CONTROL, byteh & 0x05); Outb (CONTROL, byteh & 0x05); Outb (CONTROL, byteh & 0x05); high = Inb (STATUS); } else { high = low; } low = low & 0xF0; high = high & 0xF0; dest[i] = (unsigned char) (high | (low >> 4)); i++; /* reset port */ Outb (DATA, 0x00); Outb (DATA, 0x00); Outb (CONTROL, 0x04); } static void PS2bufferWrite (int size, unsigned char *source) { int i; int count; int val; /* init buffer write */ i = 0; count = size / 2; Outb (DATA, 0x67); Outb (CONTROL, 0x01); Outb (CONTROL, 0x01); Outb (CONTROL, 0x05); /* write loop */ while (count > 0) { /* low byte of word */ val = source[i]; i++; Outb (DATA, val); Outb (DATA, val); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); /* high byte of word */ val = source[i]; i++; Outb (DATA, val); Outb (DATA, val); Outb (CONTROL, 0x05); Outb (CONTROL, 0x05); Outb (CONTROL, 0x05); Outb (CONTROL, 0x05); /* next write */ count--; } /* termination sequence */ Outb (CONTROL, 0x05); Outb (CONTROL, 0x05); Outb (CONTROL, 0x05); Outb (CONTROL, 0x05); Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); } static void init001 (void) { int i; int val; int status; ClearRegister (0); Outb (CONTROL, 0x0C); if (g674 != 0) { Outb (CONTROL, 0x0C); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x0C); } Outb (DATA, 0x40); if (g674 != 0) { Outb (DATA, 0x40); Outb (DATA, 0x40); Outb (DATA, 0x40); } Outb (CONTROL, 0x06); Outb (CONTROL, 0x06); Outb (CONTROL, 0x06); if (g674 != 0) { Outb (CONTROL, 0x06); Outb (CONTROL, 0x06); Outb (CONTROL, 0x06); } /* sync loop */ i = 256; do { status = Inb (STATUS); i--; } while ((i > 0) && ((status & 0x40))); val = 0x0C; if (i > 0) { Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); if (g674 != 0) { Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); Outb (CONTROL, 0x07); } val = 0x04; Outb (CONTROL, val); Outb (CONTROL, val); Outb (CONTROL, val); if (g674 != 0) { Outb (CONTROL, val); Outb (CONTROL, val); Outb (CONTROL, val); } } val = val | 0x0C; Outb (CONTROL, val); Outb (CONTROL, val); Outb (CONTROL, val); if (g674 != 0) { Outb (CONTROL, val); Outb (CONTROL, val); Outb (CONTROL, val); } val = val & 0xF7; Outb (CONTROL, val); Outb (CONTROL, val); Outb (CONTROL, val); if (g674 != 0) { Outb (CONTROL, val); Outb (CONTROL, val); Outb (CONTROL, val); } } /* SPP register reading */ static int init002 (int arg) { int data; if (arg == 1) return 0; Outb (DATA, 0x0B); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x04); Outb (CONTROL, 0x24); Outb (CONTROL, 0x24); Outb (CONTROL, 0x26); Outb (CONTROL, 0x26); data = Inb (DATA); Outb (CONTROL, 0x04); if (data == gEPAT) { return 1; } return 0; } /* * connecct to the EPAT chip, and * prepare command sending */ static int ECPconnect (void) { int ret, control; /* these 3 lines set to 'inital mode' */ byteMode (); /*Outb (ECR, 0x20); */ Outb (DATA, 0x04); /* gData */ Outb (CONTROL, 0x0C); /* gControl */ Inb (ECR); /* 0x35 */ byteMode (); /*Outb (ECR, 0x20); */ byteMode (); /*Outb (ECR, 0x20); */ gData = Inb (DATA); gControl = Inb (CONTROL); Inb (DATA); control = Inb (CONTROL); Outb (CONTROL, control & 0x1F); control = Inb (CONTROL); Outb (CONTROL, control & 0x1F); sendCommand (0xE0); Outb (DATA, 0xFF); Outb (DATA, 0xFF); ClearRegister (0); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x04); ClearRegister (0); ret = PS2Something (0x10); if (ret != 0x0B) { DBG (16, "PS2Something returned 0x%02X, 0x0B expected (%s:%d)\n", ret, __FILE__, __LINE__); } return 1; } static void EPPdisconnect (void) { if (getModel () != 0x07) sendCommand (40); sendCommand (30); Outb (DATA, gData); Outb (CONTROL, gControl); } static void ECPdisconnect (void) { int control; if (getModel () != 0x07) /* guessed */ sendCommand (40); /* guessed */ sendCommand (0x30); control = Inb (CONTROL) | 0x01; Outb (CONTROL, control); Outb (CONTROL, control); control = control & 0x04; Outb (CONTROL, control); Outb (CONTROL, control); control = control | 0x08; Outb (CONTROL, control); Outb (DATA, 0xFF); Outb (DATA, 0xFF); Outb (CONTROL, control); } static int ECPregisterRead (int reg) { unsigned char breg, value; #ifdef HAVE_LINUX_PPDEV_H int rc, mode, fd; unsigned char bval; fd = sanei_umax_pp_getparport (); if (fd > 0) { Outb (CONTROL, 0x04); ECPFifoMode (); Outb (DATA, reg); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = read (fd, &bval, 1); if (rc != 1) DBG (0, "ppdev short read (%s:%d)\n", __FILE__, __LINE__); value = bval; breg = (Inb (CONTROL) & 0x3F); if (breg != 0x20) { DBG (0, "ECPregisterRead failed, expecting 0x20, got 0x%02X (%s:%d)\n", breg, __FILE__, __LINE__); } /* restore port state */ mode = 0; /* data_forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); Outb (CONTROL, 0x04); byteMode (); return value; } #endif Outb (CONTROL, 0x4); /* ECP FIFO mode, interrupt bit, dma disabled, service bit, fifo full=0, fifo empty=0 */ ECPFifoMode (); /*Outb (ECR, 0x60); */ if (waitFifoEmpty () == 0) { DBG (0, "ECPregisterRead failed, FIFO time-out (%s:%d)\n", __FILE__, __LINE__); } breg = Inb (ECR); Outb (DATA, reg); if (waitFifoEmpty () == 0) { DBG (0, "ECPregisterRead failed, FIFO time-out (%s:%d)\n", __FILE__, __LINE__); } breg = Inb (ECR); /* byte mode, interrupt bit, dma disabled, service bit, fifo full=0, fifo empty=0 */ byteMode (); /*Outb (ECR, 0x20); */ Outb (CONTROL, 0x20); /* data reverse */ /* ECP FIFO mode, interrupt bit, dma disabled, service bit, fifo full=0, fifo empty=0 */ ECPFifoMode (); /*Outb (ECR, 0x60); */ if (waitFifoNotEmpty () == 0) { DBG (0, "ECPregisterRead failed, FIFO time-out (%s:%d)\n", __FILE__, __LINE__); } breg = Inb (ECR); value = Inb (ECPDATA); /* according to the spec bit 7 and 6 are unused */ breg = (Inb (CONTROL) & 0x3F); if (breg != 0x20) { DBG (0, "ECPregisterRead failed, expecting 0x20, got 0x%02X (%s:%d)\n", breg, __FILE__, __LINE__); } Outb (CONTROL, 0x04); byteMode (); return value; } static int EPPregisterRead (int reg) { #ifdef HAVE_LINUX_PPDEV_H int fd, mode, rc; unsigned char breg, bval; int value; #endif int control; #ifdef HAVE_LINUX_PPDEV_H /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { breg = (unsigned char) (reg); mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &breg, 1); if (rc != 1) DBG (0, "ppdev short write (%s:%d)\n", __FILE__, __LINE__); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = read (fd, &bval, 1); if (rc != 1) DBG (0, "ppdev short read (%s:%d)\n", __FILE__, __LINE__); value = bval; mode = 0; /* forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return value; } /* if not, direct hardware access */ #endif Outb (EPPADDR, reg); control = Inb (CONTROL); control = (control & 0x1F) | 0x20; Outb (CONTROL, control); Inb (EPPDATA); control = Inb (CONTROL); control = control & 0x1F; Outb (CONTROL, control); return 0xFF; /* return value; */ } static int registerRead (int reg) { switch (gMode) { case UMAX_PP_PARPORT_ECP: return ECPregisterRead (reg); case UMAX_PP_PARPORT_BYTE: DBG (0, "STEF: gMode BYTE in registerRead !!\n"); return 0xFF; case UMAX_PP_PARPORT_EPP: return EPPregisterRead (reg); case UMAX_PP_PARPORT_PS2: DBG (0, "STEF: gMode PS2 in registerRead !!\n"); return PS2registerRead (reg); default: DBG (0, "STEF: gMode unset in registerRead !!\n"); return 0xFF; } } static void ECPregisterWrite (int reg, int value) { #ifdef HAVE_LINUX_PPDEV_H unsigned char breg; int rc, fd; fd = sanei_umax_pp_getparport (); if (fd > 0) { ECPFifoMode (); Outb (DATA, reg); breg = value; rc = write (fd, &breg, 1); if (rc != 1) DBG (0, "ppdev short write (%s:%d)\n", __FILE__, __LINE__); Outb (CONTROL, 0x04); byteMode (); return; } #endif /* standard mode, interrupt bit, dma disabled, service bit, fifo full=0, fifo empty=0 */ compatMode (); Outb (CONTROL, 0x04); /* reset ? */ /* ECP FIFO mode, interrupt bit, dma disabled, service bit, fifo full=0, fifo empty=0 */ ECPFifoMode (); /*Outb (ECR, 0x60); */ if (waitFifoEmpty () == 0) { DBG (0, "ECPregisterWrite failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (DATA, reg); if (waitFifoEmpty () == 0) { DBG (0, "ECPregisterWrite failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (ECPDATA, value); if (waitFifoEmpty () == 0) { DBG (0, "ECPregisterWrite failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (CONTROL, 0x04); byteMode (); return; } static void EPPregisterWrite (int reg, int value) { #ifdef HAVE_LINUX_PPDEV_H int fd, mode, rc; unsigned char breg, bval; #endif reg = reg | 0x40; #ifdef HAVE_LINUX_PPDEV_H /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { breg = (unsigned char) (reg); mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &breg, 1); if (rc != 1) DBG (0, "ppdev short write (%s:%d)\n", __FILE__, __LINE__); bval = (unsigned char) (value); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); return; } /* if not, direct hardware access */ #endif Outb (EPPADDR, reg); Outb (EPPDATA, value); } static void registerWrite (int reg, int value) { switch (gMode) { case UMAX_PP_PARPORT_PS2: PS2registerWrite (reg, value); DBG (0, "STEF: gMode PS2 in registerWrite !!\n"); break; case UMAX_PP_PARPORT_ECP: ECPregisterWrite (reg, value); break; case UMAX_PP_PARPORT_EPP: EPPregisterWrite (reg, value); break; case UMAX_PP_PARPORT_BYTE: DBG (0, "STEF: gMode BYTE in registerWrite !!\n"); break; default: DBG (0, "STEF: gMode unset in registerWrite !!\n"); break; } } static void EPPBlockMode (int flag) { #ifdef HAVE_LINUX_PPDEV_H int fd, mode, rc; unsigned char bval; /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { bval = (unsigned char) (flag); mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); return; } #endif Outb (EPPADDR, flag); } static void EPPbufferRead (int size, unsigned char *dest) { #ifdef HAVE_LINUX_PPDEV_H int fd, mode, rc, nb; unsigned char bval; #endif int control; #ifdef HAVE_LINUX_PPDEV_H /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { bval = 0x80; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #ifdef PPSETFLAGS mode = PP_FASTREAD; rc = ioctl (fd, PPSETFLAGS, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #endif mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); nb = 0; while (nb < size - 1) { rc = read (fd, dest + nb, size - 1 - nb); nb += rc; } mode = 0; /* forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); bval = 0xA0; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = read (fd, dest + size - 1, 1); mode = 0; /* forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; } /* if not, direct hardware access */ #endif EPPBlockMode (0x80); control = Inb (CONTROL); Outb (CONTROL, (control & 0x1F) | 0x20); /* reverse */ Insb (EPPDATA, dest, size - 1); control = Inb (CONTROL); Outb (CONTROL, (control & 0x1F)); /* forward */ EPPBlockMode (0xA0); control = Inb (CONTROL); Outb (CONTROL, (control & 0x1F) | 0x20); /* reverse */ Insb (EPPDATA, (unsigned char *) (dest + size - 1), 1); control = Inb (CONTROL); Outb (CONTROL, (control & 0x1F)); /* forward */ } /* block transfer init */ static void ECPSetBuffer (int size) { static int last = 0; /* routine XX */ compatMode (); Outb (CONTROL, 0x04); /* reset ? */ /* we set size only if it has changed */ /* from last time */ if (size == last) return; last = size; /* mode and size setting */ ECPFifoMode (); /*Outb (ECR, 0x60); */ if (waitFifoEmpty () == 0) { DBG (0, "ECPSetBuffer failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (DATA, 0x0E); if (waitFifoEmpty () == 0) { DBG (0, "ECPSetBuffer failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (ECPDATA, 0x0B); /* R0E=0x0B */ if (waitFifoEmpty () == 0) { DBG (0, "ECPSetBuffer failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (DATA, 0x0F); /* R0F=size MSB */ if (waitFifoEmpty () == 0) { DBG (0, "ECPSetBuffer failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (ECPDATA, size / 256); if (waitFifoEmpty () == 0) { DBG (0, "ECPSetBuffer failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (DATA, 0x0B); /* R0B=size LSB */ if (waitFifoEmpty () == 0) { DBG (0, "ECPSetBuffer failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); Outb (ECPDATA, size % 256); if (waitFifoEmpty () == 0) { DBG (0, "ECPSetBuffer failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } Inb (ECR); DBG (16, "ECPSetBuffer(%d) passed ...\n", size); } static int ECPbufferRead (int size, unsigned char *dest) { int n, idx, remain; idx = 0; n = size / 16; remain = size - 16 * n; /* block transfer */ Inb (ECR); /* 0x15,0x75 expected: fifo empty */ byteMode (); /*Outb (ECR, 0x20); byte mode */ Outb (CONTROL, 0x04); ECPFifoMode (); /*Outb (ECR, 0x60); */ if (waitFifoEmpty () == 0) { DBG (0, "ECPbufferRead failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return idx; } Inb (ECR); Outb (DATA, 0x80); if (waitFifoEmpty () == 0) { DBG (0, "ECPbufferRead failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return idx; } Inb (ECR); /* 0x75 expected */ byteMode (); /*Outb (ECR, 0x20); byte mode */ Outb (CONTROL, 0x20); /* data reverse */ ECPFifoMode (); /*Outb (ECR, 0x60); */ while (n > 0) { if (waitFifoFull () == 0) { DBG (0, "ECPbufferRead failed, time-out waiting for FIFO idx=%d (%s:%d)\n", idx, __FILE__, __LINE__); return idx; } Insb (ECPDATA, dest + idx, 16); idx += 16; n--; } /* reading trailing bytes */ while (remain > 0) { if (waitFifoNotEmpty () == 0) { DBG (0, "ECPbufferRead failed, FIFO time-out (%s:%d)\n", __FILE__, __LINE__); } dest[idx] = Inb (ECPDATA); idx++; remain--; } return idx; } static void EPPbufferWrite (int size, unsigned char *source) { #ifdef HAVE_LINUX_PPDEV_H int fd, mode, rc; unsigned char bval; #endif #ifdef HAVE_LINUX_PPDEV_H /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { bval = 0xC0; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, source, size); return; } /* if not, direct hardware access */ #endif EPPBlockMode (0xC0); Outsb (EPPDATA, source, size); } static void ECPbufferWrite (int size, unsigned char *source) { unsigned char breg; int n, idx; /* until we know to handle that case, fail */ if (size % 16 != 0) { DBG (0, "ECPbufferWrite failed, size %%16 !=0 (%s:%d)\n", __FILE__, __LINE__); return; } /* prepare actual transfer */ compatMode (); Outb (CONTROL, 0x04); /* reset ? */ breg = Inb (CONTROL); Outb (CONTROL, 0x04); /* data forward */ ECPFifoMode (); /*Outb (ECR, 0x60); */ if (waitFifoEmpty () == 0) { DBG (0, "ECPWriteBuffer failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } breg = Inb (ECR); breg = (Inb (STATUS)) & 0xF8; n = 0; while ((n < 1024) && (breg != 0xF8)) { breg = (Inb (STATUS)) & 0xF8; n++; } if (breg != 0xF8) { DBG (0, "ECPbufferWrite failed, expected status=0xF8, got 0x%02X (%s:%d)\n", breg, __FILE__, __LINE__); return; } /* wait for FIFO empty (bit 0) */ if (waitFifoEmpty () == 0) { DBG (0, "ECPbufferWrite failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } breg = Inb (ECR); /* block transfer direction * 0x80 means from scanner to PC, 0xC0 means PC to scanner */ Outb (DATA, 0xC0); n = size / 16; idx = 0; while (n > 0) { /* wait for FIFO empty */ if (waitFifoEmpty () == 0) { DBG (0, "ECPbufferWrite failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } breg = Inb (ECR); Outsb (ECPDATA, source + idx * 16, 16); idx++; n--; } /* final FIFO check and go to Byte mode */ if (waitFifoEmpty () == 0) { DBG (0, "ECPbufferWrite failed, time-out waiting for FIFO (%s:%d)\n", __FILE__, __LINE__); return; } breg = Inb (ECR); Outb (CONTROL, 0x04); byteMode (); } static void bufferWrite (int size, unsigned char *source) { switch (gMode) { case UMAX_PP_PARPORT_PS2: PS2bufferWrite (size, source); DBG (0, "STEF: gMode PS2 in bufferWrite !!\n"); break; case UMAX_PP_PARPORT_ECP: ECPbufferWrite (size, source); break; case UMAX_PP_PARPORT_EPP: switch (getEPPMode ()) { case 32: EPPWrite32Buffer (size, source); break; default: EPPbufferWrite (size, source); break; } break; default: DBG (0, "STEF: gMode PS2 in bufferWrite !!\n"); break; } return; } static void bufferRead (int size, unsigned char *dest) { switch (gMode) { case UMAX_PP_PARPORT_PS2: PS2bufferRead (size, dest); DBG (0, "STEF: gMode PS2 in bufferRead !!\n"); break; case UMAX_PP_PARPORT_ECP: ECPbufferRead (size, dest); break; case UMAX_PP_PARPORT_EPP: switch (getEPPMode ()) { case 32: EPPRead32Buffer (size, dest); break; default: EPPbufferRead (size, dest); break; } break; default: DBG (0, "STEF: gMode unset in bufferRead !!\n"); break; } return; } static int connect (void) { if (sanei_umax_pp_getastra () == 610) return connect610p (); switch (gMode) { case UMAX_PP_PARPORT_PS2: DBG (0, "STEF: unimplemented gMode PS2 in connect() !!\n"); return 0; break; case UMAX_PP_PARPORT_ECP: return ECPconnect (); break; case UMAX_PP_PARPORT_BYTE: DBG (0, "STEF: unimplemented gMode BYTE in connect() !!\n"); return 0; break; case UMAX_PP_PARPORT_EPP: return EPPconnect (); default: DBG (0, "STEF: gMode unset in connect() !!\n"); break; } return 0; } static void disconnect (void) { if (sanei_umax_pp_getastra () == 610) disconnect610p (); switch (gMode) { case UMAX_PP_PARPORT_PS2: DBG (0, "STEF: unimplemented gMode PS2 in disconnect() !!\n"); break; case UMAX_PP_PARPORT_ECP: ECPdisconnect (); break; case UMAX_PP_PARPORT_BYTE: DBG (0, "STEF: unimplemented gMode BYTE in disconnect() !!\n"); break; case UMAX_PP_PARPORT_EPP: EPPdisconnect (); break; default: DBG (0, "STEF: gMode unset in disconnect() !!\n"); break; } } /* returns 0 if mode OK, else -1 */ static int checkEPAT (void) { int version; version = registerRead (0x0B); if (version == 0xC7) return 0; DBG (0, "checkEPAT: expected EPAT version 0xC7, got 0x%X! (%s:%d)\n", version, __FILE__, __LINE__); return -1; } static int init005 (int arg) { int count = 5; int res; while (count > 0) { registerWrite (0x0A, arg); Outb (DATA, 0xFF); res = registerRead (0x0A); /* failed ? */ if (res != arg) return 1; /* ror arg */ res = arg & 0x01; arg = arg / 2; if (res == 1) arg = arg | 0x80; /* next loop */ count--; } return 0; } /* write 1 byte in EPP mode, returning scnner's status */ static int EPPputByte610p (int data) { int status, control; status = Inb (STATUS) & 0xF8; if ((status != 0xC8) && (status != 0xC0) && (status != 0xD0)) { DBG (0, "EPPputByte610p failed, expected 0xC8, 0xD0 or 0xC0 got 0x%02X ! (%s:%d)\n", status, __FILE__, __LINE__); return 0; } control = (Inb (CONTROL) & 0x44) | 0x44; /* data forward, bit 5 cleared (!!) */ Outb (CONTROL, control); Outb (EPPDATA, data); return status; } static int putByte610p (int data) { int status, control, j; if (gMode == UMAX_PP_PARPORT_EPP) return EPPputByte610p (data); j = 0; do { status = Inb (STATUS) & 0xF8; j++; } while ((j < 20) && (status & 0x08)); if ((status != 0xC8) && (status != 0xC0)) { DBG (0, "putByte610p failed, expected 0xC8 or 0xC0 got 0x%02X ! (%s:%d)\n", status, __FILE__, __LINE__); return 0; } control = Inb (CONTROL) & 0x1F; /* data forward */ Outb (CONTROL, control); Outb (DATA, data); Outb (CONTROL, 0x07); status = Inb (STATUS) & 0xF8; if ((status != 0x48) && (status != 0x40)) { DBG (0, "putByte610p failed, expected 0x48 or 0x40 got 0x%02X ! (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (CONTROL, 0x05); status = Inb (STATUS) & 0xF8; Outb (CONTROL, control); return status; } /* 1 OK, 0 failure */ static int sync610p (void) { int status; Outb (DATA, 0x40); Outb (CONTROL, 0x06); status = Inb (STATUS) & 0xF8; if (status != 0x38) { DBG (0, "sync610p failed (got 0x%02X expected 0x38)! (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (CONTROL, 0x07); status = Inb (STATUS) & 0xF8; if (status != 0x38) { DBG (0, "sync610p failed (got 0x%02X expected 0x38)! (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (CONTROL, 0x04); status = Inb (STATUS) & 0xF8; if (status != 0xF8) { DBG (0, "sync610p failed (got 0x%02X expected 0xF8)! (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (CONTROL, 0x05); Inb (CONTROL); /* 0x05 expected */ Outb (CONTROL, 0x04); return 1; } static int EPPcmdSync610p (int cmd) { int word[5]; int status; int i; word[0] = 0; word[1] = 0; word[2] = 0; word[3] = cmd; connect610p (); sync610p (); /* sends magic seal 55 AA */ status = EPPputByte610p (0x55); if ((status != 0xC8) && (status != 0xC0) && (status != 0xD0)) { DBG (1, "EPPcmdSync610p: Found 0x%X expected 0xC8, 0xC0 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } status = EPPputByte610p (0xAA); if ((status != 0xC8) && (status != 0xC0) && (status != 0xD0)) { DBG (1, "EPPcmdSync610p: Found 0x%X expected 0xC8, 0xC0 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } status = EPPgetStatus610p (); if (status == 0xC0) for (i = 0; i < 10; i++) status = Inb (STATUS) & 0xF8; if (status != 0xC8) { DBG (0, "EPPcmdSync610p: Found 0x%X expected 0xC8 (%s:%d)\n", status, __FILE__, __LINE__); /*return 0; */ } /* sends 4 bytes of data */ for (i = 0; i < 4; i++) { status = EPPputByte610p (word[i]); } if (status != 0xC8) { DBG (0, "EPPcmdSync610p: Found 0x%X expected 0xC8 (%s:%d)\n", status, __FILE__, __LINE__); /*return 0; */ } /* tests status */ Outb (DATA, 0xFF); if (cmd == 0xC2) { status = EPPgetStatus610p (); if (status != 0xC0) { DBG (0, "EPPcmdSync610p: Found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); /*return 0; */ } } status = EPPgetStatus610p (); if (status != 0xC0) { DBG (0, "EPPcmdSync610p: Found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); /*return 0; */ } disconnect610p (); return 1; } static int cmdSync610p (int cmd) { int word[5]; int status; if (gMode == UMAX_PP_PARPORT_EPP) return EPPcmdSync610p (cmd); word[0] = 0; word[1] = 0; word[2] = 0; word[3] = cmd; connect610p (); sync610p (); if (sendLength610p (word) == 0) { DBG (0, "sendLength610p() failed... (%s:%d)\n", __FILE__, __LINE__); return 0; } if (cmd == 0xC2) { status = getStatus610p (); if (status != 0xC0) { DBG (1, "Found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } } status = getStatus610p (); if (status != 0xC0) { DBG (1, "Found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } disconnect610p (); return 1; } static int EPPgetStatus610p (void) { int data, status, control, i; control = Inb (CONTROL) & 0xA4; control = control | 0xE0; Outb (CONTROL, control); status = Inb (STATUS) & 0xF8; if (status & 0x08) { for (i = 1; i < 10; i++) status = Inb (STATUS) & 0xF8; } else { data = Inb (EPPDATA); scannerStatus = data; } return status; } static int getStatus610p (void) { int data, status; byteMode (); status = Inb (STATUS) & 0xF8; Outb (CONTROL, 0x26); /* data reverse */ data = Inb (DATA); scannerStatus = data; Outb (CONTROL, 0x24); return status; } int sendLength610p (int *cmd) { int ret, i, wait; /* 55,AA,x,y,z,t */ byteMode (); wait = putByte610p (0x55); if ((wait != 0xC8) && (wait != 0xC0)) { DBG (0, "sendLength610p failed, expected 0xC8 or 0xC0 got 0x%02X ! (%s:%d)\n", wait, __FILE__, __LINE__); return 0; } wait = putByte610p (0xAA); if ((wait != 0xC8) && (wait != 0xC0)) { DBG (0, "sendLength610p failed, expected 0xC8 or 0xC0 got 0x%02X ! (%s:%d)\n", wait, __FILE__, __LINE__); return 0; } /* if wait=C0, we have to ... wait */ if (wait == 0xC0) { byteMode (); wait = Inb (STATUS); /* C0 expected */ Outb (CONTROL, 0x26); ret = Inb (DATA); /* 88 expected */ Outb (CONTROL, 0x24); for (i = 0; i < 10; i++) wait = Inb (STATUS); /* C8 expected */ byteMode (); } for (i = 0; i < 3; i++) { ret = putByte610p (cmd[i]); if (ret != 0xC8) { DBG (0, "sendLength610p failed, expected 0xC8 got 0x%02X ! (%s:%d)\n", ret, __FILE__, __LINE__); return 0; } } ret = putByte610p (cmd[3]); if ((ret != 0xC0) && (ret != 0xD0)) { DBG (0, "sendLength610p failed, expected 0xC0 or 0xD0 got 0x%02X ! (%s:%d)\n", ret, __FILE__, __LINE__); return 0; } return 1; } /* 1 OK, 0 failure */ static int disconnect610p (void) { int control, i; Outb (CONTROL, 0x04); for (i = 0; i < 41; i++) { control = Inb (CONTROL) & 0x3F; if (control != 0x04) { DBG (0, "disconnect610p failed (idx %d=%02X)! (%s:%d)\n", i, control, __FILE__, __LINE__); return 0; } } Outb (CONTROL, 0x0C); control = Inb (CONTROL) & 0x3F; if (control != 0x0C) { DBG (0, "disconnect610p failed expected 0x0C got %02X (%s:%d)\n", control, __FILE__, __LINE__); return 0; } /* XXX STEF XXX Outb (DATA, gData); */ Outb (DATA, 0xFF); return 1; } /* 1 OK, 0 failure */ /* 0: short connect, 1 long connect */ static int connect610p (void) { int control; gData = Inb (DATA); /* to gDATA ? */ Outb (DATA, 0xAA); Outb (CONTROL, 0x0E); control = Inb (CONTROL); /* 0x0E expected */ control = Inb (CONTROL) & 0x3F; if (control != 0x0E) { DBG (0, "connect610p control=%02X, expected 0x0E (%s:%d)\n", control, __FILE__, __LINE__); } Outb (DATA, 0x00); Outb (CONTROL, 0x0C); control = Inb (CONTROL); /* 0x0C expected */ control = Inb (CONTROL) & 0x3F; if (control != 0x0C) { DBG (0, "connect610p control=%02X, expected 0x0C (%s:%d)\n", control, __FILE__, __LINE__); } Outb (DATA, 0x55); Outb (CONTROL, 0x0E); control = Inb (CONTROL); /* 0x0E expected */ control = Inb (CONTROL) & 0x3F; if (control != 0x0E) { DBG (0, "connect610p control=%02X, expected 0x0E (%s:%d)\n", control, __FILE__, __LINE__); } Outb (DATA, 0xFF); Outb (CONTROL, 0x0C); control = Inb (CONTROL); /* 0x0C expected */ control = Inb (CONTROL) & 0x3F; if (control != 0x0C) { DBG (0, "connect610p control=%02X, expected 0x0C (%s:%d)\n", control, __FILE__, __LINE__); } Outb (CONTROL, 0x04); control = Inb (CONTROL); /* 0x04 expected */ control = Inb (CONTROL) & 0x3F; if (control != 0x04) { DBG (0, "connect610p control=%02X, expected 0x04 (%s:%d)\n", control, __FILE__, __LINE__); } return 1; } /* 1 OK, 0 failure */ static int EPPconnect (void) { int control; /* initial values, don't hardcode */ Outb (DATA, 0x04); Outb (CONTROL, 0x0C); Inb (DATA); control = Inb (CONTROL); Outb (CONTROL, control & 0x1F); control = Inb (CONTROL); Outb (CONTROL, control & 0x1F); if (sendCommand (0xE0) != 1) { DBG (0, "EPPconnect: sendCommand(0xE0) failed! (%s:%d)\n", __FILE__, __LINE__); return 0; } ClearRegister (0); init001 (); return 1; } static void EPPRead32Buffer (int size, unsigned char *dest) { #ifdef HAVE_LINUX_PPDEV_H int fd, mode, rc, nb; unsigned char bval; #endif int control; #ifdef HAVE_LINUX_PPDEV_H /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { bval = 0x80; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #ifdef PPSETFLAGS mode = PP_FASTREAD; rc = ioctl (fd, PPSETFLAGS, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #endif mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); nb = 0; while (nb < size - 4) { rc = read (fd, dest + nb, size - 4 - nb); nb += rc; } rc = read (fd, dest + size - 4, 3); mode = 0; /* forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); bval = 0xA0; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = read (fd, dest + size - 1, 1); mode = 0; /* forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return; } /* if not, direct hardware access */ #endif EPPBlockMode (0x80); control = Inb (CONTROL); Outb (CONTROL, (control & 0x1F) | 0x20); Insw (EPPDATA, dest, size / 4 - 1); Insb (EPPDATA, (unsigned char *) (dest + size - 4), 3); control = Inb (CONTROL); Outb (CONTROL, (control & 0x1F)); EPPBlockMode (0xA0); control = Inb (CONTROL); Outb (CONTROL, (control & 0x1F) | 0x20); Insb (EPPDATA, (unsigned char *) (dest + size - 1), 1); control = Inb (CONTROL); Outb (CONTROL, (control & 0x1F)); } static void EPPWrite32Buffer (int size, unsigned char *source) { #ifdef HAVE_LINUX_PPDEV_H int fd, mode, rc; unsigned char bval; #endif if ((size % 4) != 0) { DBG (0, "EPPWrite32Buffer: size %% 4 != 0!! (%s:%d)\n", __FILE__, __LINE__); } #ifdef HAVE_LINUX_PPDEV_H /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { bval = 0xC0; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); #ifdef PPSETFLAGS mode = PP_FASTWRITE; rc = ioctl (fd, PPSETFLAGS, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #endif mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, source, size); return; } /* if not, direct hardware access */ #endif EPPBlockMode (0xC0); Outsw (EPPDATA, source, size / 4); } /* returns 0 if ERROR cleared in STATUS within 1024 inb, else 1 */ static int WaitOnError (void) { int c = 0; int count = 1024; int status; do { do { status = Inb (STATUS) & 0x08; if (status != 0) { count--; if (count == 0) c = 1; } } while ((count > 0) && (status != 0)); if (status == 0) { status = Inb (STATUS) & 0x08; if (status == 0) c = 0; } } while ((status != 0) && (c == 0)); return c; } #ifdef HAVE_LINUX_PPDEV_H /* read up to size bytes, returns bytes read */ static int ParportpausedBufferRead (int size, unsigned char *dest) { unsigned char status, bval; int error; int word; int bread; int c; int fd, rc, mode; /* WIP check */ if (gMode == UMAX_PP_PARPORT_ECP) { DBG (0, "ECP access not implemented yet (WIP) ! (%s:%d)\n", __FILE__, __LINE__); } /* init */ bread = 0; error = 0; fd = sanei_umax_pp_getparport (); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #ifdef PPSETFLAGS mode = PP_FASTREAD; rc = ioctl (fd, PPSETFLAGS, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #endif mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); if ((size & 0x03) != 0) { while ((!error) && ((size & 0x03) != 0)) { rc = read (fd, dest, 1); size--; dest++; bread++; rc = ioctl (fd, PPRSTATUS, &status); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); error = status & 0x08; } if (error) { DBG (0, "Read error (%s:%d)\n", __FILE__, __LINE__); return 0; } } /* from here, we read 1 byte, then size/4-1 32 bits words, and then 3 bytes, pausing on ERROR bit of STATUS */ size -= 4; /* sanity test, seems to be wrongly handled ... */ if (size == 0) { DBG (0, "case not handled! (%s:%d)\n", __FILE__, __LINE__); return 0; } word = 0; error = 0; bread += size; do { do { rc = read (fd, dest, 1); size--; dest++; readstatus: if (size > 0) { rc = ioctl (fd, PPRSTATUS, &status); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); word = status & 0x10; error = status & 0x08; } } while ((size > 0) && (!error) && (!word)); } while ((size < 4) && (!error) && (size > 0)); /* here size=0 or error=8 or word=0x10 */ if ((word) && (!error) && (size)) { rc = read (fd, dest, 4); dest += 4; size -= 4; if (size != 0) error = 0x08; } if (!error) { c = 0; rc = ioctl (fd, PPRSTATUS, &status); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); error = status & 0x08; if (error) c = WaitOnError (); } else { /* 8282 */ c = WaitOnError (); if (c == 0) goto readstatus; } if (c == 1) { bread -= size; } else { bread += 3; size = 3; do { do { rc = read (fd, dest, 1); dest++; size--; if (size) { rc = ioctl (fd, PPRSTATUS, &status); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); error = status & 0x08; if (!error) { rc = ioctl (fd, PPRSTATUS, &status); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); error = status & 0x08; } } } while ((size > 0) && (!error)); c = 0; if (error) c = WaitOnError (); } while ((size > 0) && (c == 0)); } /* end reading */ mode = 0; /* forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); bval = 0xA0; mode = IEEE1284_MODE_EPP | IEEE1284_ADDR; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = write (fd, &bval, 1); mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); rc = read (fd, dest, 1); bread++; mode = 0; /* forward */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return bread; } #endif /* read up to size bytes, returns bytes read */ static int DirectpausedBufferRead (int size, unsigned char *dest) { int control; int status; int error; int word; int read; int c; /* init */ read = 0; error = 0; control = Inb (CONTROL) & 0x1F; Outb (CONTROL, control | 0x20); if ((size & 0x03) != 0) { /* 8174 */ while ((!error) && ((size & 0x03) != 0)) { Insb (EPPDATA, dest, 1); size--; dest++; read++; status = Inb (STATUS) & 0x1F; error = status & 0x08; } if (error) { DBG (0, "Read error (%s:%d)\n", __FILE__, __LINE__); return 0; } } /* from here, we read 1 byte, then size/4-1 32 bits words, and then 3 bytes, pausing on ERROR bit of STATUS */ size -= 4; /* sanity test, seems to be wrongly handled ... */ if (size == 0) { DBG (0, "case not handled! (%s:%d)\n", __FILE__, __LINE__); return 0; } word = 0; error = 0; read += size; do { do { Insb (EPPDATA, dest, 1); size--; dest++; readstatus: if (size > 0) { status = Inb (STATUS) & 0x1F; word = status & 0x10; error = status & 0x08; } } while ((size > 0) && (!error) && (!word)); } while ((size < 4) && (!error) && (size > 0)); /* here size=0 or error=8 or word=0x10 */ if ((word) && (!error) && (size)) { if (epp32) Insw (EPPDATA, dest, 1); else Insb (EPPDATA, dest, 4); dest += 4; size -= 4; if (size != 0) error = 0x08; } if (!error) { c = 0; error = Inb (STATUS) & 0x08; if (error) c = WaitOnError (); } else { /* 8282 */ c = WaitOnError (); if (c == 0) goto readstatus; } if (c == 1) { read -= size; } else { read += 3; size = 3; do { do { Insb (EPPDATA, dest, 1); dest++; size--; if (size) { error = Inb (STATUS) & 0x08; if (!error) error = Inb (STATUS) & 0x08; } } while ((size > 0) && (!error)); c = 0; if (error) c = WaitOnError (); } while ((size > 0) && (c == 0)); } /* end reading */ control = Inb (CONTROL) & 0x1F; Outb (CONTROL, control); EPPBlockMode (0xA0); control = Inb (CONTROL) & 0x1F; Outb (CONTROL, control | 0x20); Insb (EPPDATA, dest, 1); read++; control = Inb (CONTROL) & 0x1F; Outb (CONTROL, control); return read; } int pausedBufferRead (int size, unsigned char *dest) { EPPBlockMode (0x80); #ifdef HAVE_LINUX_PPDEV_H if (sanei_umax_pp_getparport () > 0) return ParportpausedBufferRead (size, dest); #endif /* only EPP hardware access for now */ if (gMode == UMAX_PP_PARPORT_EPP) return DirectpausedBufferRead (size, dest); return 0; } /* returns 1 on success, 0 otherwise */ static int sendWord1220P (int *cmd) { int i; int reg; int try = 0; /* send header */ reg = registerRead (0x19) & 0xF8; retry: registerWrite (0x1C, 0x55); reg = registerRead (0x19) & 0xF8; registerWrite (0x1C, 0xAA); reg = registerRead (0x19) & 0xF8; /* sync when needed */ if ((reg & 0x08) == 0x00) { reg = registerRead (0x1C); DBG (16, "UTA: reg1C=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); if (((reg & 0x10) != 0x10) && (reg != 0x6B) && (reg != 0xAB) && (reg != 0x23)) { DBG (0, "sendWord failed (reg1C=0x%02X) (%s:%d)\n", reg, __FILE__, __LINE__); return 0; } for (i = 0; i < 10; i++) { usleep (1000); reg = registerRead (0x19) & 0xF8; if (reg != 0xC8) { DBG (0, "Unexpected reg19=0x%2X (%s:%d)\n", reg, __FILE__, __LINE__); } } do { if ((reg != 0xC0) && (reg != 0xC8)) { DBG (0, "Unexpected reg19=0x%2X (%s:%d)\n", reg, __FILE__, __LINE__); } /* 0xF0 certainly means error */ if ((reg == 0xC0) || (reg == 0xD0)) { try++; goto retry; } reg = registerRead (0x19) & 0xF8; } while (reg != 0xC8); } /* send word */ i = 0; while ((reg == 0xC8) && (cmd[i] != -1)) { registerWrite (0x1C, cmd[i]); i++; reg = registerRead (0x19) & 0xF8; } TRACE (16, "sendWord() passed "); if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "sendWord failed got 0x%02X instead of 0xC0 or 0xD0 (%s:%d)\n", reg, __FILE__, __LINE__); DBG (0, "Blindly going on .....\n"); } if (((reg == 0xC0) || (reg == 0xD0)) && (cmd[i] != -1)) { DBG (0, "sendWord failed: short send (%s:%d)\n", __FILE__, __LINE__); return 0; } reg = registerRead (0x1C); DBG (16, "sendWord, reg1C=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); /* model 0x07 has always the last bit set to 1, and even bit 1 */ /* when UTA is present, we get 0x6B there */ scannerStatus = reg & 0xFC; if (scannerStatus == 0x68) hasUTA = 1; reg = reg & 0x10; if ((reg != 0x10) && (scannerStatus != 0x68) && (scannerStatus != 0xA8)) { DBG (0, "sendWord failed: acknowledge not received (%s:%d)\n", __FILE__, __LINE__); return 0; } if (try) { DBG (0, "sendWord retry success (retry %d time%s) ... (%s:%d)\n", try, (try > 1) ? "s" : "", __FILE__, __LINE__); } return 1; } /* returns 1 on success, 0 otherwise */ static int SPPsendWord610p (int *cmd) { int i, j; int tmp, status; #ifdef HAVE_LINUX_PPDEV_H int exmode, mode, rc, fd; #endif connect610p (); #ifdef HAVE_LINUX_PPDEV_H fd = sanei_umax_pp_getparport (); if (fd > 0) { rc = ioctl (fd, PPGETMODE, &exmode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); mode = IEEE1284_MODE_COMPAT; rc = ioctl (fd, PPSETMODE, &mode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); } #endif Outb (DATA, 0x55); Outb (CONTROL, 0x05); status = Inb (STATUS) & 0xF8; if (status != 0x88) { DBG (0, "SPPsendWord610p found 0x%02X expected 0x88 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (CONTROL, 0x04); Outb (DATA, 0xAA); Outb (CONTROL, 0x05); status = Inb (STATUS) & 0xF8; if (status != 0x88) { DBG (0, "SPPsendWord610p found 0x%02X expected 0x88 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (CONTROL, 0x04); for (i = 0; i < 4; i++) { Outb (DATA, cmd[i]); Outb (CONTROL, 0x05); status = Inb (STATUS) & 0xF8; if (status != 0x88) { DBG (0, "SPPsendWord610p found 0x%02X expected 0x88 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (CONTROL, 0x04); } Outb (CONTROL, 0x07); Outb (DATA, 0xFF); tmp = Inb (DATA); if (tmp != 0xFF) { DBG (0, "SPPsendWord610p found 0x%X expected 0xFF (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } status = Inb (STATUS) & 0xF8; j = 0; while ((j < 256) && (status & 0x08)) { j++; status = Inb (STATUS) & 0xF8; } if ((status != 0x80) && (status != 0xA0)) { DBG (0, "SPPsendWord610p found 0x%X expected 0x80 or 0xA0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (DATA, 0x7F); status = Inb (STATUS) & 0xF8; if (status != 0xC0) { DBG (0, "SPPsendWord610p found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (DATA, 0xFF); if (cmd[3] == 0xC2) { Outb (CONTROL, 0x07); Outb (DATA, 0xFF); tmp = Inb (DATA); if (tmp != 0xFF) { DBG (0, "SPPsendWord610p found 0x%X expected 0xFF (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } status = Inb (STATUS) & 0xF8; if ((status != 0x80) && (status != 0xA0)) { DBG (0, "SPPsendWord610p found 0x%X expected 0x80 or 0xA0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (DATA, 0x7F); status = Inb (STATUS) & 0xF8; if (status != 0xC0) { DBG (0, "SPPsendWord610p found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } Outb (DATA, 0xFF); } #ifdef HAVE_LINUX_PPDEV_H fd = sanei_umax_pp_getparport (); if (fd > 0) { rc = ioctl (fd, PPSETMODE, &exmode); if (rc) DBG (0, "ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); } #endif disconnect610p (); return 1; } /* returns 1 on success, 0 otherwise */ static int EPPsendWord610p (int *cmd) { int i; int tmp, control; /* send magic tag */ tmp = Inb (STATUS) & 0xF8; if (tmp != 0xC8) { DBG (0, "EPPsendWord610p failed, expected tmp=0xC8 , found 0x%02X (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } /* sets to EPP, and get sure that data direction is forward */ tmp = (Inb (CONTROL) & 0x44) | 0x44; /* !! */ Outb (CONTROL, tmp); Outb (EPPDATA, 0x55); /* bit0 is timeout bit in EPP mode, should we take care of it ? */ tmp = Inb (STATUS) & 0xF8; if (tmp != 0xC8) { DBG (0, "EPPsendWord610p failed, expected tmp=0xC8 , found 0x%02X (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } tmp = (Inb (CONTROL) & 0x44) | 0x44; Outb (CONTROL, tmp); Outb (EPPDATA, 0xAA); control = (Inb (CONTROL) & 0xE0) | 0xE4; Outb (CONTROL, control); /* bit 7 + data reverse + reset */ for (i = 0; i < 10; i++) { tmp = Inb (STATUS) & 0xF8; if (tmp != 0xC8) { DBG (0, "EPPsendWord610p failed, expected tmp=0xC8 , found 0x%02X (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } } i = 0; while ((tmp == 0xC8) && (cmd[i] != -1)) { tmp = Inb (STATUS) & 0xF8; control = (Inb (CONTROL) & 0x44) | 0x44; /* !! */ Outb (CONTROL, control); Outb (EPPDATA, cmd[i]); i++; } /* end */ Outb (DATA, 0xFF); control = (Inb (CONTROL) & 0x44) | 0xE4; Outb (CONTROL, control); /* data reverse + ????? */ tmp = Inb (STATUS) & 0xF8; if (tmp == 0xC8) { for (i = 0; i < 9; i++) tmp = Inb (STATUS) & 0xF8; scannerStatus = tmp; } else { scannerStatus = Inb (EPPDATA); } if ((tmp != 0xC0) && (tmp != 0xD0)) { DBG (0, "EPPsendWord610p failed got 0x%02X instead of 0xC0 or 0xD0 (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } return 1; } /* * 0: failure * 1: success */ static int sendWord (int *cmd) { switch (sanei_umax_pp_getastra ()) { case 610: return sendLength610p (cmd); case 1220: case 1600: case 2000: default: return sendWord1220P (cmd); } } /******************************************************************************/ /* ringScanner: returns 1 if scanner present, else 0 */ /******************************************************************************/ /* * in fact this function is really close to CPP macro in * /usr/src/linux/drivers/block/paride/epat.c ..... * we have almost CPP(8) */ static int ringScanner (int count, unsigned long delay) { int status; int data; int control; int ret = 1; /* save state */ data = Inb (DATA); control = Inb (CONTROL) & 0x1F; /* send -irq,+reset */ Outb (CONTROL, (control & 0xF) | 0x4); /* unhandled case */ if (g674 == 1) { DBG (1, "OUCH! %s:%d\n", __FILE__, __LINE__); return 0; } /* send ring string */ Outb (DATA, 0x22); usleep (delay); Outb (DATA, 0x22); usleep (delay); if (count == 5) { Outb (DATA, 0x22); usleep (delay); Outb (DATA, 0x22); usleep (delay); Outb (DATA, 0x22); usleep (delay); } Outb (DATA, 0xAA); usleep (delay); Outb (DATA, 0xAA); usleep (delay); if (count == 5) { Outb (DATA, 0xAA); usleep (delay); Outb (DATA, 0xAA); usleep (delay); Outb (DATA, 0xAA); usleep (delay); } Outb (DATA, 0x55); usleep (delay); Outb (DATA, 0x55); usleep (delay); if (count == 5) { Outb (DATA, 0x55); usleep (delay); Outb (DATA, 0x55); usleep (delay); Outb (DATA, 0x55); usleep (delay); } Outb (DATA, 0x00); usleep (delay); Outb (DATA, 0x00); usleep (delay); if (count == 5) { Outb (DATA, 0x00); usleep (delay); Outb (DATA, 0x00); usleep (delay); Outb (DATA, 0x00); usleep (delay); } Outb (DATA, 0xFF); usleep (delay); Outb (DATA, 0xFF); usleep (delay); if (count == 5) { Outb (DATA, 0xFF); usleep (delay); Outb (DATA, 0xFF); usleep (delay); Outb (DATA, 0xFF); usleep (delay); } /* OK ? */ status = Inb (STATUS) & 0xF8; usleep (delay); if ((status & 0xB8) != 0xB8) { DBG (1, "status %d doesn't match! %s:%d\n", status, __FILE__, __LINE__); ret = 0; } /* if OK send 0x87 */ if (ret) { Outb (DATA, 0x87); usleep (delay); Outb (DATA, 0x87); usleep (delay); if (count == 5) { Outb (DATA, 0x87); usleep (delay); Outb (DATA, 0x87); usleep (delay); Outb (DATA, 0x87); usleep (delay); } status = Inb (STATUS); /* status = 126 when scanner not connected .... */ if ((status & 0xB8) != 0x18) { DBG (1, "status %d doesn't match! %s:%d\n", status, __FILE__, __LINE__); ret = 0; } } /* if OK send 0x78 */ if (ret) { Outb (DATA, 0x78); usleep (delay); Outb (DATA, 0x78); usleep (delay); if (count == 5) { Outb (DATA, 0x78); usleep (delay); Outb (DATA, 0x78); usleep (delay); Outb (DATA, 0x78); usleep (delay); } status = Inb (STATUS); if ((status & 0x30) != 0x30) { DBG (1, "status %d doesn't match! %s:%d\n", status, __FILE__, __LINE__); ret = 0; } } /* ring OK, send termination */ if (ret) { Outb (DATA, 0x08); usleep (delay); Outb (DATA, 0x08); usleep (delay); if (count == 5) { Outb (DATA, 0x08); usleep (delay); Outb (DATA, 0x08); usleep (delay); Outb (DATA, 0x08); usleep (delay); } Outb (DATA, 0xFF); usleep (delay); Outb (DATA, 0xFF); usleep (delay); if (count == 5) { Outb (DATA, 0xFF); usleep (delay); Outb (DATA, 0xFF); usleep (delay); Outb (DATA, 0xFF); usleep (delay); } } /* restore state */ Outb (CONTROL, control); Outb (DATA, data); return ret; } /*****************************************************************************/ /* test some version : returns 1 on success, 0 otherwise */ /*****************************************************************************/ static int testVersion (int no) { int data; int status; int control; int count; int tmp; data = Inb (DATA); control = Inb (CONTROL) & 0x3F; Outb (CONTROL, (control & 0x1F) | 0x04); /* send magic sequence */ Outb (DATA, 0x22); Outb (DATA, 0x22); Outb (DATA, 0x22); Outb (DATA, 0x22); Outb (DATA, 0xAA); Outb (DATA, 0xAA); Outb (DATA, 0xAA); Outb (DATA, 0xAA); Outb (DATA, 0xAA); Outb (DATA, 0xAA); Outb (DATA, 0x55); Outb (DATA, 0x55); Outb (DATA, 0x55); Outb (DATA, 0x55); Outb (DATA, 0x55); Outb (DATA, 0x55); Outb (DATA, 0x00); Outb (DATA, 0x00); Outb (DATA, 0x00); Outb (DATA, 0x00); Outb (DATA, 0x00); Outb (DATA, 0x00); Outb (DATA, 0xFF); Outb (DATA, 0xFF); Outb (DATA, 0xFF); Outb (DATA, 0xFF); Outb (DATA, 0xFF); Outb (DATA, 0xFF); Outb (DATA, 0x87); Outb (DATA, 0x87); Outb (DATA, 0x87); Outb (DATA, 0x87); Outb (DATA, 0x87); Outb (DATA, 0x87); Outb (DATA, 0x78); Outb (DATA, 0x78); Outb (DATA, 0x78); Outb (DATA, 0x78); Outb (DATA, 0x78); Outb (DATA, 0x78); tmp = no | 0x88; Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); /* test status */ status = Inb (STATUS); status = Inb (STATUS); if ((status & 0xB8) != 0) { /* 1600P fails here */ DBG (64, "status %d doesn't match! %s:%d\n", status, __FILE__, __LINE__); Outb (CONTROL, control); Outb (DATA, data); return 0; } count = 0xF0; do { tmp = no | 0x80; Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); tmp = no | 0x88; Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); Outb (DATA, tmp); /* command received ? */ status = Inb (STATUS); status = ((status << 1) & 0x70) | (status & 0x80); if (status != count) { /* since failure is expected, we dont't alaways print */ /* this message ... */ DBG (2, "status %d doesn't match count 0x%X! %s:%d\n", status, count, __FILE__, __LINE__); Outb (CONTROL, control); Outb (DATA, data); return 0; } /* next */ count -= 0x10; } while (count > 0); /* restore port , successful exit */ Outb (CONTROL, control); Outb (DATA, data); return 1; } /* sends len bytes to scanner */ /* needs data channel to be set up */ /* returns 1 on success, 0 otherwise */ static int sendLength (int *cmd, int len) { int i; int reg, wait; int try = 0; /* send header */ retry: wait = registerRead (0x19) & 0xF8; registerWrite (0x1C, 0x55); reg = registerRead (0x19) & 0xF8; registerWrite (0x1C, 0xAA); reg = registerRead (0x19) & 0xF8; /* sync when needed */ if ((wait & 0x08) == 0x00) { reg = registerRead (0x1C); while (((reg & 0x10) != 0x10) && (reg != 0x6B) && (reg != 0xAB) && (reg != 0x23)) { DBG (0, "sendLength failed, expected reg & 0x10=0x10 , found 0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); if (try > 10) { DBG (0, "Aborting...\n"); return 0; } else { DBG (0, "Retrying ...\n"); } /* resend */ epilogue (); prologue (0x10); try++; goto retry; } for (i = 0; i < 10; i++) { reg = registerRead (0x19) & 0xF8; if (reg != 0xC8) { DBG (0, "Unexpected reg19=0x%2X (%s:%d)\n", reg, __FILE__, __LINE__); /* 0xF0 certainly means error */ if ((reg == 0xC0) || (reg == 0xD0) || (reg == 0x80)) { /* resend */ try++; if (try > 20) { DBG (0, "sendLength retry failed (%s:%d)\n", __FILE__, __LINE__); return 0; } epilogue (); sendCommand (0x00); sendCommand (0xE0); Outb (DATA, 0x00); Outb (CONTROL, 0x01); Outb (CONTROL, 0x04); sendCommand (0x30); prologue (0x10); goto retry; } } } do { if ((reg != 0xC0) && (reg != 0xD0) && (reg != 0xC8)) { /* status has changed while waiting */ /* but it's too early */ DBG (0, "Unexpected reg19=0x%2X (%s:%d)\n", reg, __FILE__, __LINE__); } /* 0xF0 certainly means error */ if ((reg == 0xC0) || (reg == 0xD0) || (reg == 0x80)) { /* resend */ try++; epilogue (); sendCommand (0x00); sendCommand (0xE0); Outb (DATA, 0x00); Outb (CONTROL, 0x01); Outb (CONTROL, 0x04); sendCommand (0x30); prologue (0x10); goto retry; } reg = registerRead (0x19) & 0xF8; } while (reg != 0xC8); } /* send bytes */ i = 0; while ((reg == 0xC8) && (i < len)) { /* write byte */ registerWrite (0x1C, cmd[i]); reg = registerRead (0x19) & 0xF8; /* 1B handling: escape it to confirm value */ if (cmd[i] == 0x1B) { registerWrite (0x1C, cmd[i]); reg = registerRead (0x19) & 0xF8; } i++; } DBG (16, "sendLength, reg19=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "sendLength failed got 0x%02X instead of 0xC0 or 0xD0 (%s:%d)\n", reg, __FILE__, __LINE__); DBG (0, "Blindly going on .....\n"); } /* check if 'finished status' received too early */ if (((reg == 0xC0) || (reg == 0xD0)) && (i != len)) { DBG (0, "sendLength failed: sent only %d bytes out of %d (%s:%d)\n", i, len, __FILE__, __LINE__); return 0; } reg = registerRead (0x1C); DBG (16, "sendLength, reg1C=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); /* model 0x07 has always the last bit set to 1 */ scannerStatus = reg & 0xFC; reg = reg & 0x10; if ((reg != 0x10) && (scannerStatus != 0x68) && (scannerStatus != 0xA8)) { DBG (0, "sendLength failed: acknowledge not received (%s:%d)\n", __FILE__, __LINE__); return 0; } if (try) { DBG (0, "sendLength retry success (retry %d time%s) ... (%s:%d)\n", try, (try > 1) ? "s" : "", __FILE__, __LINE__); } return 1; } /* sends data bytes to scanner */ /* needs data channel to be set up */ /* returns 1 on success, 0 otherwise */ static int sendData610p (int *cmd, int len) { int i, status, j; i = 0; status = 0xC8; /* while ((i < len) && ((status & 0x08) == 0x08)) XXX STEF XXX */ while (i < len) { /* escape special values */ if (cmd[i] == 0x1B) status = putByte610p (0x1B); if (i > 0) { if ((cmd[i] == 0xAA) && (cmd[i - 1] == 0x55)) status = putByte610p (0x1B); } /* regular values */ status = putByte610p (cmd[i]); i++; } j = 0; while ((status & 0x08) && (j < 256)) { status = getStatus610p (); j++; } if ((status != 0xC0) && (status != 0xD0)) { DBG (0, "sendData610p() failed, status=0x%02X, expected 0xC0 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } /* check if 'finished status' received too early */ if (i < len) { DBG (0, "sendData610p failed: sent only %d bytes out of %d (%s:%d)\n", i, len, __FILE__, __LINE__); return 0; } return 1; } /* sends data bytes to scanner */ /* needs data channel to be set up */ /* returns 1 on success, 0 otherwise */ static int sendData (int *cmd, int len) { int i; int reg; if (sanei_umax_pp_getastra () == 610) return sendData610p (cmd, len); /* send header */ reg = registerRead (0x19) & 0xF8; /* send bytes */ i = 0; while ((reg == 0xC8) && (i < len)) { /* write byte */ registerWrite (0x1C, cmd[i]); reg = registerRead (0x19) & 0xF8; /* 1B handling: escape it to confirm value */ if (cmd[i] == 0x1B) { registerWrite (0x1C, 0x1B); reg = registerRead (0x19) & 0xF8; } /* escape 55 AA pattern by adding 1B */ if ((i < len - 1) && (cmd[i] == 0x55) && (cmd[i + 1] == 0xAA)) { registerWrite (0x1C, 0x1B); reg = registerRead (0x19) & 0xF8; } /* next value */ i++; } DBG (16, "sendData, reg19=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "sendData failed got 0x%02X instead of 0xC0 or 0xD0 (%s:%d)\n", reg, __FILE__, __LINE__); DBG (0, "Blindly going on .....\n"); } /* check if 'finished status' received too early */ if (((reg == 0xC0) || (reg == 0xD0)) && (i < len)) { DBG (0, "sendData failed: sent only %d bytes out of %d (%s:%d)\n", i, len, __FILE__, __LINE__); return 0; } reg = registerRead (0x1C); DBG (16, "sendData, reg1C=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); /* model 0x07 has always the last bit set to 1 */ scannerStatus = reg & 0xFC; reg = reg & 0x10; if ((reg != 0x10) && (scannerStatus != 0x68) && (scannerStatus != 0xA8) && (scannerStatus != 0x20)) { DBG (0, "sendData failed: acknowledge not received (%s:%d)\n", __FILE__, __LINE__); return 0; } return 1; } /* receive data bytes from scanner */ /* needs data channel to be set up */ /* returns 1 on success, 0 otherwise */ /* uses pausedBufferRead */ static int pausedReadData (int size, unsigned char *dest) { int reg; int tmp; int read; REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); reg = registerRead (0x19) & 0xF8; if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "Unexpected reg19: 0x%02X instead of 0xC0 or 0xD0 (%s:%d)\n", reg, __FILE__, __LINE__); return 0; } if (gMode == UMAX_PP_PARPORT_ECP) { REGISTERWRITE (0x1A, 0x44); } REGISTERREAD (0x0C, 0x04); REGISTERWRITE (0x0C, 0x44); /* sets data direction ? */ if (gMode == UMAX_PP_PARPORT_ECP) { compatMode (); Outb (CONTROL, 0x04); /* reset ? */ ECPSetBuffer (size); read = ECPbufferRead (size, dest); DBG (16, "ECPbufferRead(%d,dest) passed (%s:%d)\n", size, __FILE__, __LINE__); REGISTERWRITE (0x1A, 0x84); } else { read = pausedBufferRead (size, dest); } if (read < size) { DBG (16, "pausedBufferRead(%d,dest) failed, only got %d bytes (%s:%d)\n", size, read, __FILE__, __LINE__); return 0; } DBG (16, "pausedBufferRead(%d,dest) passed (%s:%d)\n", size, __FILE__, __LINE__); REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); return 1; } /* receive data bytes from scanner */ /* needs data channel to be set up */ /* returns 1 on success, 0 otherwise */ static int receiveData610p (int *cmd, int len) { int i; int status; i = 0; status = 0xD0; byteMode (); while (i < len) { status = Inb (STATUS) & 0xF8; Outb (CONTROL, 0x26); /* data reverse+ 'reg' */ cmd[i] = Inb (DATA); Outb (CONTROL, 0x24); /* data reverse+ 'reg' */ i++; } if (status != 0xC0) { DBG (0, "receiveData610p failed got 0x%02X instead of 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); DBG (0, "Blindly going on .....\n"); } /* check if 'finished status' received to early */ if ((status == 0xC0) && (i != len)) { DBG (0, "receiveData610p failed: received only %d bytes out of %d (%s:%d)\n", i, len, __FILE__, __LINE__); return 0; } return 1; } /* receive data bytes from scanner */ /* needs data channel to be set up */ /* returns 1 on success, 0 otherwise */ static int receiveData (int *cmd, int len) { int i; int reg; /* send header */ reg = registerRead (0x19) & 0xF8; /* send bytes */ i = 0; while (((reg == 0xD0) || (reg == 0xC0)) && (i < len)) { /* write byte */ cmd[i] = registerRead (0x1C); reg = registerRead (0x19) & 0xF8; i++; } DBG (16, "receiveData, reg19=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "sendData failed got 0x%02X instead of 0xC0 or 0xD0 (%s:%d)\n", reg, __FILE__, __LINE__); DBG (0, "Blindly going on .....\n"); } /* check if 'finished status' received to early */ if (((reg == 0xC0) || (reg == 0xD0)) && (i != len)) { DBG (0, "receiveData failed: received only %d bytes out of %d (%s:%d)\n", i, len, __FILE__, __LINE__); return 0; } reg = registerRead (0x1C); DBG (16, "receiveData, reg1C=0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); /* model 0x07 has always the last bit set to 1 */ scannerStatus = reg & 0xF8; reg = reg & 0x10; if ((reg != 0x10) && (scannerStatus != 0x68) && (scannerStatus != 0xA8)) { DBG (0, "receiveData failed: acknowledge not received (%s:%d)\n", __FILE__, __LINE__); return 0; } return 1; } /* 1=success, 0 failed */ static int fonc001 (void) { int i; int res; int reg; res = 1; while (res == 1) { registerWrite (0x1A, 0x0C); registerWrite (0x18, 0x40); /* send 0x06 */ registerWrite (0x1A, 0x06); for (i = 0; i < 10; i++) { reg = registerRead (0x19) & 0xF8; if ((reg & 0x78) == 0x38) { res = 0; break; } } if (res == 1) { registerWrite (0x1A, 0x00); registerWrite (0x1A, 0x0C); } } /* send 0x07 */ registerWrite (0x1A, 0x07); res = 1; for (i = 0; i < 10; i++) { reg = registerRead (0x19) & 0xF8; if ((reg & 0x78) == 0x38) { res = 0; break; } } if (res != 0) return 0; /* send 0x04 */ registerWrite (0x1A, 0x04); res = 1; for (i = 0; i < 10; i++) { reg = registerRead (0x19) & 0xF8; if ((reg & 0xF8) == 0xF8) { res = 0; break; } } if (res != 0) return 0; /* send 0x05 */ registerWrite (0x1A, 0x05); res = 1; for (i = 0; i < 10; i++) { reg = registerRead (0x1A); if (reg == 0x05) { res = 0; break; } } if (res != 0) return 0; /* end */ registerWrite (0x1A, 0x84); return 1; } /* 1 OK, 0 failed */ static int foncSendWord (int *cmd) { prologue (0x10); if (sendWord (cmd) == 0) { DBG (0, "sendWord(cmd) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } epilogue (); return 1; } static int cmdSetDataBuffer (int *data) { int cmd1[] = { 0x00, 0x00, 0x22, 0x88, -1 }; /* 34 bytes write on channel 8 */ int cmd2[] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x00, 0x20, 0x02, 0x00, 0x16, 0x41, 0xE0, 0xAC, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, -1 }; int cmd3[] = { 0x00, 0x08, 0x00, 0x84, -1 }; /* 2048 bytes size write on channel 4 (data) */ int cmd4[] = { 0x00, 0x08, 0x00, 0xC4, -1 }; /* 2048 bytes size read on channel 4 (data) */ int i; unsigned char dest[2048]; /* cmdSet(8,34,cmd2), but without prologue/epilogue */ /* set block length to 34 bytes on 'channel 8' */ sendWord (cmd1); DBG (16, "sendWord(cmd1) passed (%s:%d) \n", __FILE__, __LINE__); /* sendData */ sendData (cmd2, 0x22); DBG (16, "sendData(cmd2) passed (%s:%d) \n", __FILE__, __LINE__); if (DBG_LEVEL >= 128) { bloc8Decode (cmd2); } /* set block length to 2048, write on 'channel 4' */ sendWord (cmd3); DBG (16, "sendWord(cmd3) passed (%s:%d) \n", __FILE__, __LINE__); if (sendData (data, 2048) == 0) { DBG (0, "sendData(data,%d) failed (%s:%d)\n", 2048, __FILE__, __LINE__); return 0; } TRACE (16, "sendData(data,2048) passed ..."); /* read back all data sent to 'channel 4' */ sendWord (cmd4); DBG (16, "sendWord(cmd4) passed (%s:%d) \n", __FILE__, __LINE__); if (pausedReadData (2048, dest) == 0) { DBG (16, "pausedReadData(2048,dest) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "pausedReadData(2048,dest) passed (%s:%d)\n", __FILE__, __LINE__); /* dest should hold the same data than donnees */ for (i = 0; i < 2047; i++) { if (data[i] != (int) (dest[i])) { DBG (0, "Warning data read back differs: expected %02X found dest[%d]=%02X ! (%s:%d)\n", data[i], i, dest[i], __FILE__, __LINE__); } } return 1; } /* 1: OK 0: end session failed */ int sanei_umax_pp_endSession (void) { int zero[5] = { 0, 0, 0, 0, -1 }; if (sanei_umax_pp_getastra () != 610) { prologue (0x00); sendWord (zero); epilogue (); sanei_umax_pp_cmdSync (0xC2); sanei_umax_pp_cmdSync (0x00); /* cancels any pending operation */ sanei_umax_pp_cmdSync (0x00); /* cancels any pending operation */ } else { CMDSYNC (0x00); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSYNC (0x00); } compatMode (); /* restore port state */ Outb (DATA, gData); Outb (CONTROL, gControl); /* OUF */ DBG (1, "End session done ...\n"); return 1; } /* initialize scanner with default values * and do head re-homing if needed */ int initScanner610p (int recover) { int first, rc, x; int cmd55AA[9] = { 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, -1 }; int cmd02[17] = { 0x02, 0x80, 0x00, 0x40, 0x30, 0x00, 0xC0, 0x2F, 0x2F, 0x07, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x00, -1 }; int op01[17] = { 0x01, 0x00, 0x32, 0x70, 0x00, 0x00, 0xC0, 0x2F, 0x17, 0x05, 0x00, 0x00, 0x00, 0x80, 0xA4, 0x00, -1 }; int op11[17] = { 0x01, 0x80, 0x0C, 0x70, 0x00, 0x00, 0xC0, 0x2F, 0x17, 0x01, 0x00, 0x00, 0x00, 0x80, 0xA4, 0x00, -1 }; int op21[17] = { 0x01, 0x00, 0x01, 0x40, 0x30, 0x00, 0xC0, 0x2F, 0x17, 0x05, 0x00, 0x00, 0x00, 0x80, 0xF4, 0x00, -1 }; int op31[17] = { 0x01, 0x00, 0x39, 0x73, 0x00, 0x00, 0xC0, 0x2F, 0x17, 0x05, 0x00, 0x00, 0x00, 0x80, 0xB4, 0x00, -1 }; int op02[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x20, 0x02, 0x00, 0x76, 0x00, 0x75, 0xEF, 0x06, 0x00, 0x00, 0xF6, 0x4D, 0xA0, 0x00, 0x8B, 0x4D, 0x4B, 0xD0, 0x68, 0xDF, 0x1B, -1 }; int op22[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x00, 0x20, 0x02, 0x00, 0x16, 0x80, 0x15, 0x78, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x4D, 0x4B, 0xD0, 0x68, 0xDF, 0x1B, -1 }; int op03[9] = { 0x00, 0x00, 0x00, 0xAA, 0xCC, 0xEE, 0xFF, 0xFF, -1 }; struct timeval tv; byteMode (); /* just to get sure */ first = 0; rc = inquire (); /* get time to handle settle time delay */ gettimeofday (&tv, NULL); gTime = tv.tv_sec; /* default delay */ gDelay = 5; if (rc == 0) { DBG (0, "inquire() failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } if (rc == 2) { /* same value used by windows driver */ gDelay = 45; DBG (1, "inquire() signals re-homing needed ... (%s:%d) \n", __FILE__, __LINE__); first = 1; } DBG (1, "inquire() passed ... (%s:%d) \n", __FILE__, __LINE__); rc = loadDefaultTables (); if (rc == 0) { DBG (0, "loadDefaultTables() failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (1, "loadDefaultTables() passed ... (%s:%d) \n", __FILE__, __LINE__); if (recover) first = 1; CMDSETGET (2, 0x10, cmd02); CMDSETGET (1, 0x08, cmd55AA); if (!first) { CMDSYNC (0x00); CMDSYNC (0xC2); CMDSYNC (0x00); DBG (1, "initScanner610p done ...\n"); return 1; } /* here we do re-homing * since it is first probe or recover */ /* move forward */ CMDSYNC (0xC2); if (!recover) { CMDSETGET (2, 0x10, op01); CMDSETGET (8, 0x22, op02); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, op03); CMDSYNC (0x40); CMDSYNC (0xC2); sleep (2); } /* move backward */ CMDSETGET (2, 0x10, op11); CMDSETGET (8, 0x22, op02); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSYNC (0x00); CMDSETGET (4, 0x08, op03); CMDSYNC (0x40); CMDSYNC (0xC2); sleep (2); /* means 'CONTINUE MOVE' */ CMDSYNC (0x00); while ((scannerStatus & MOTOR_BIT) == 0) { CMDSYNC (0xC2); CMDSETGET (2, 0x10, op21); CMDSETGET (8, 0x22, op22); CMDSYNC (0x40); usleep (20000); } CMDSYNC (0xC2); CMDSYNC (0x00); /* send head away */ if (!recover) { CMDSETGET (2, 0x10, op31); CMDSETGET (8, 0x22, op02); if (DBG_LEVEL > 8) { bloc2Decode (op31); bloc8Decode (op02); } CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, op03); CMDSYNC (0x40); CMDSYNC (0xC2); sleep (9); } CMDSYNC (0x00); /* this code has been added, without corresponding logs/ * it seem I just can't found 'real' parking command ... */ /* send park command */ if (sanei_umax_pp_park () == 0) { TRACE (0, "sanei_umax_pp_park failed! "); return 0; } /* and wait it to succeed */ if (sanei_umax_pp_parkWait () == 0) { TRACE (0, "sanei_umax_pp_parkWait failed! "); return 0; } /* override gamma table with 610P defaults */ for (x = 0; x < 256; x++) { ggRed[x] = x; ggGreen[x] = x; ggBlue[x] = x; } DBG (1, "initScanner610p done ...\n"); return 1; } /* 1: OK 2: homing happened 3: scanner busy 0: init failed init transport layer init scanner */ int sanei_umax_pp_initScanner (int recover) { int i; int status; int readcmd[64]; /* in umax1220u, this buffer is opc[16] */ int sentcmd[17] = { 0x02, 0x80, 0x00, 0x70, 0x00, 0x00, 0x00, 0x2F, 0x2F, 0x07, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x00, -1 }; int cmdA7[9] = { 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, -1 }; if (sanei_umax_pp_getastra () == 610) return initScanner610p (recover); if (getModel () == 0x07) sentcmd[15] = 0x00; else sentcmd[15] = 0x18; /* fails here if there is an unfinished previous scan */ CMDSETGET (0x02, 16, sentcmd); /* needs some init */ if (sentcmd[15] == 0x18) { sentcmd[15] = 0x00; /* was 0x18 */ CMDSETGET (0x02, 16, sentcmd); /* in umax1220u, this buffer does not exist */ CMDSETGET (0x01, 8, cmdA7); } /* ~ opb3: inquire status */ CMDGET (0x08, 36, readcmd); if (DBG_LEVEL >= 32) { bloc8Decode (readcmd); } DBG (16, "cmdGet(0x08,36,readcmd) passed (%s:%d)\n", __FILE__, __LINE__); /* is the scanner busy parking ? */ status = sanei_umax_pp_scannerStatus (); DBG (8, "INQUIRE SCANNER STATUS IS 0x%02X (%s:%d)\n", status, __FILE__, __LINE__); if ((!recover) && (status & MOTOR_BIT) == 0x00) { DBG (1, "Warning: scanner motor on, giving up ... (%s:%d)\n", __FILE__, __LINE__); return 3; } /* head homing needed ? */ if ((readcmd[34] != 0x1A) || (recover == 1)) { /* homing needed, readcmd[34] should be 0x48 */ int op01[17] = { 0x01, 0x00, 0x32, 0x70, 0x00, 0x00, 0x60, 0x2F, 0x17, 0x05, 0x00, 0x00, 0x00, 0x80, 0xE4, 0x00, -1 }; int op05[17] = { 0x01, 0x00, 0x01, 0x70, 0x00, 0x00, 0x60, 0x2F, 0x13, 0x05, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x00, -1 }; int op02[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x20, 0x02, 0x00, 0x16, 0x00, 0x70, 0x9F, 0x06, 0x00, 0x00, 0xF6, 0x4D, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x0B, 0x1A, 0x00, -1 }; int op04[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x00, 0x20, 0x02, 0x00, 0x16, 0x80, 0x15, 0x78, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x0B, 0x1A, 0x00, -1 }; int op03[9] = { 0x00, 0x00, 0x00, 0xAA, 0xCC, 0xEE, 0xFF, 0xFF, -1 }; CMDSYNC (0xC2); CMDSETGET (0x02, 16, op01); CMDSETGET (0x08, 36, op02); if (!recover) { CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (0x04, 8, op03); CMDSYNC (0x40); do { sleep (1); CMDSYNC (0xC2); } while ((sanei_umax_pp_scannerStatus () & 0x90) != 0x90); op01[2] = 0x1E; op01[9] = 0x01; CMDSETGET (0x02, 16, op01); CMDSETGET (0x08, 36, op02); CMDSYNC (0x00); CMDSYNC (0x00); CMDSETGET (0x04, 8, op03); CMDSYNC (0x40); do { sleep (1); CMDSYNC (0xC2); } while ((sanei_umax_pp_scannerStatus () & 0x90) != 0x90); CMDSYNC (0x00); } for (i = 0; i < 4; i++) { do { usleep (500000); CMDSYNC (0xC2); status = sanei_umax_pp_scannerStatus (); status = status & 0x10; } while (status != 0x10); /* was 0x90 */ CMDSETGET (0x02, 16, op05); CMDSETGET (0x08, 36, op04); CMDSYNC (0x40); status = sanei_umax_pp_scannerStatus (); DBG (16, "loop %d passed, status=0x%02X (%s:%d)\n", i, status, __FILE__, __LINE__); } /* get head back home ... */ do { i++; do { usleep (500000); CMDSYNC (0xC2); status = sanei_umax_pp_scannerStatus (); status = status & 0x10; } while (status != 0x10); /* was 0x90 */ CMDSETGET (0x02, 16, op05); CMDSETGET (0x08, 36, op04); CMDSYNC (0x40); status = sanei_umax_pp_scannerStatus (); DBG (16, "loop %d passed, status=0x%02X (%s:%d)\n", i, status, __FILE__, __LINE__); } while ((status & MOTOR_BIT) == 0x00); /* 0xD0 when head is back home */ do { usleep (500000); CMDSYNC (0xC2); } while ((sanei_umax_pp_scannerStatus () & 0x90) != 0x90); /* don't do automatic home sequence on recovery */ if (!recover) { CMDSYNC (0x00); op01[2] = 0x1A; op01[3] = 0x74; /* was 0x70 */ op01[9] = 0x05; /* initial value */ op01[14] = 0xF4; /* was 0xE4 */ CMDSETGET (0x02, 16, op01); CMDSETGET (0x08, 36, op02); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (0x04, 8, op03); CMDSYNC (0x40); /* wait for automatic homing sequence */ /* to complete, thus avoiding */ /* scanning too early */ do { /* the sleep is here to prevent */ /* excessive CPU usage, can be */ /* removed, if we don't care */ sleep (3); CMDSYNC (0xC2); DBG (16, "PARKING polling status is 0x%02X (%s:%d)\n", sanei_umax_pp_scannerStatus (), __FILE__, __LINE__); } while (sanei_umax_pp_scannerStatus () == 0x90); } /* signal homing */ return 2; } /* end ... */ DBG (1, "Scanner init done ...\n"); return 1; } /* 1: OK 2: failed, try again 0: init failed initialize the transport layer */ static int initTransport610p (void) { int tmp, i; int zero[5] = { 0, 0, 0, 0, -1 }; /* test EPP availability */ connect610p (); if (sync610p () == 0) { DBG (0, "sync610p failed! Scanner not present or powered off ... (%s:%d)\n", __FILE__, __LINE__); return 0; } if (EPPsendWord610p (zero) == 0) { DBG (1, "No EPP mode detected\n"); gMode = UMAX_PP_PARPORT_BYTE; } else { DBG (1, "EPP mode detected\n"); gMode = UMAX_PP_PARPORT_EPP; } disconnect610p (); /* set up to bidirectionnal */ /* in fact we could add support for EPP */ /* but let's make 610 work first */ if (gMode == UMAX_PP_PARPORT_BYTE) { byteMode (); /* reset after failure */ /* set to data reverse */ Outb (CONTROL, 0x2C); Inb (CONTROL); for (i = 0; i < 10; i++) Outb (DATA, 0xAA); tmp = Inb (DATA); tmp = Inb (DATA); if (tmp != 0xFF) { DBG (1, "Found 0x%X expected 0xFF (%s:%d)\n", tmp, __FILE__, __LINE__); } for (i = 0; i < 4; i++) { Outb (DATA, 0x00); tmp = Inb (DATA); if (tmp != 0xFF) { DBG (1, "Found 0x%X expected 0xFF (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } Outb (DATA, 0xFF); tmp = Inb (DATA); if (tmp != 0xFF) { DBG (1, "Found 0x%X expected 0xFF (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } } TRACE (16, "RESET done... "); byteMode (); if (SPPsendWord610p (zero) == 0) { DBG (0, "SPPsendWord610p(zero) failed! (%s:%d)\n", __FILE__, __LINE__); return 0; } TRACE (16, "SPPsendWord610p(zero) passed... "); } /* OK ! */ TRACE (1, "initTransport610p done... "); return 1; } /* 1: OK 2: failed, try again 0: init failed initialize the transport layer */ static int initTransport1220P (int recover) /* ECP OK !! */ { int i, j; int reg, tmp; unsigned char *dest = NULL; int zero[5] = { 0, 0, 0, 0, -1 }; int model, nb; connect (); DBG (16, "connect() passed... (%s:%d)\n", __FILE__, __LINE__); gEPAT = 0xC7; reg = registerRead (0x0B); if (reg != gEPAT) { DBG (16, "Error! expected reg0B=0x%02X, found 0x%02X! (%s:%d) \n", gEPAT, reg, __FILE__, __LINE__); DBG (16, "Scanner needs probing ... \n"); if (sanei_umax_pp_probeScanner (recover) != 1) { return 0; } else { return 2; /* signals retry initTransport() */ } } reg = registerRead (0x0D); reg = (reg & 0xE8) | 0x43; registerWrite (0x0D, reg); REGISTERWRITE (0x0C, 0x04); reg = registerRead (0x0A); if (reg != 0x00) { if (reg != 0x1C) { DBG (0, "Warning! expected reg0A=0x00, found 0x%02X! (%s:%d) \n", reg, __FILE__, __LINE__); } else { DBG (16, "Scanner in idle state .... (%s:%d)\n", __FILE__, __LINE__); } } /* model detection: redone since we might not be probing each time ... */ /* write addr in 0x0E, read value at 0x0F */ REGISTERWRITE (0x0E, 0x01); model = registerRead (0x0F); setModel (model); REGISTERWRITE (0x0A, 0x1C); if (gMode == UMAX_PP_PARPORT_ECP) { REGISTERWRITE (0x08, 0x10); } else { REGISTERWRITE (0x08, 0x21); } REGISTERWRITE (0x0E, 0x0F); REGISTERWRITE (0x0F, 0x0C); REGISTERWRITE (0x0A, 0x1C); REGISTERWRITE (0x0E, 0x10); REGISTERWRITE (0x0F, 0x1C); if (gMode == UMAX_PP_PARPORT_ECP) { REGISTERWRITE (0x0F, 0x00); } REGISTERWRITE (0x0A, 0x11); dest = (unsigned char *) (malloc (65536)); if (dest == NULL) { DBG (0, "Failed to allocate 64 Ko !\n"); return 0; } for (i = 0; i < 256; i++) { dest[i * 2] = i; dest[i * 2 + 1] = 0xFF - i; dest[512 + i * 2] = i; dest[512 + i * 2 + 1] = 0xFF - i; } nb = 150; for (i = 0; i < nb; i++) { bufferWrite (0x400, dest); DBG (16, "Loop %d: bufferWrite(0x400,dest) passed... (%s:%d)\n", i, __FILE__, __LINE__); } REGISTERWRITE (0x0A, 0x18); REGISTERWRITE (0x0A, 0x11); if (gMode == UMAX_PP_PARPORT_ECP) { ECPSetBuffer (0x400); } for (i = 0; i < nb; i++) { /* XXX Compat/Byte ??? XXX */ bufferRead (0x400, dest); for (j = 0; j < 256; j++) { if (dest[j * 2] != j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", j * 2, j, dest[j * 2]); return 0; } if (dest[j * 2 + 1] != 0xFF - j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", j * 2 + 1, 0xFF - j, dest[j * 2 + 1]); return 0; } if (dest[512 + j * 2] != j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", 512 + j * 2, j, dest[512 + j * 2]); return 0; } if (dest[512 + j * 2 + 1] != 0xFF - j) { DBG (0, "Altered buffer value at %03X, expected 0x%02X, found 0x%02X\n", 512 + j * 2 + 1, 0xFF - j, dest[512 + j * 2 + 1]); return 0; } } DBG (16, "Loop %d: bufferRead(0x400,dest) passed... (%s:%d)\n", i, __FILE__, __LINE__); } REGISTERWRITE (0x0A, 0x18); /* ECP: "HEAVY" reconnect here */ if (gMode == UMAX_PP_PARPORT_ECP) { epilogue (); /* 3 line: set to initial parport state ? */ byteMode (); /*Outb (ECR, 0x20); */ Outb (DATA, 0x04); Outb (CONTROL, 0x0C); /* the following is a variant of connect(); */ Inb (ECR); Inb (ECR); byteMode (); /*Outb (ECR, 0x20); */ byteMode (); /*Outb (ECR, 0x20); */ Inb (CONTROL); Outb (CONTROL, 0x0C); Inb (DATA); sendCommand (0xE0); Outb (DATA, 0XFF); Outb (DATA, 0XFF); ClearRegister (0); WRITESLOW (0x0E, 0x0A); SLOWNIBBLEREGISTERREAD (0x0F, 0x08); /* resend value OR'ed 0x08 ? */ WRITESLOW (0x0F, 0x08); WRITESLOW (0x08, 0x10); disconnect (); prologue (0x10); } if (fonc001 () != 1) { DBG (0, "fonc001() failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (16, "fonc001() passed ... (%s:%d) \n", __FILE__, __LINE__); /* sync */ if (sendWord (zero) == 0) { DBG (0, "sendWord(zero) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "sendWord(zero) passed (%s:%d)\n", __FILE__, __LINE__); epilogue (); /* OK ! */ free (dest); DBG (1, "initTransport1220P done ...\n"); return 1; } /* 1: OK 2: failed, try again 0: init failed initialize the transport layer */ int sanei_umax_pp_initTransport (int recover) { TRACE (16, "sanei_umax_pp_initTransport"); switch (sanei_umax_pp_getastra ()) { case 610: return initTransport610p (); case 1220: case 1600: case 2000: default: return initTransport1220P (recover); } } /* 1: OK 0: probe failed */ static int probe610p (int recover) { if (initTransport610p () == 0) { DBG (0, "initTransport610p() failed (%s:%d)\n", __FILE__, __LINE__); return 0; } /* make sure we won't try 1220/200P later * since we got here, we have a 610, and in any case * NOT a 1220P/2000P, since no EPAT present */ sanei_umax_pp_setastra (610); if (initScanner610p (recover) == 0) { DBG (0, "initScanner610p() failed (%s:%d)\n", __FILE__, __LINE__); return 0; } /* successfull end ... */ DBG (1, "UMAX Astra 610p detected\n"); DBG (1, "probe610p done ...\n"); return 1; } /* * try PS2 mode * returns 1 on success, 0 on failure */ int probePS2 (unsigned char *dest) { int i, tmp; /* write/read full buffer */ for (i = 0; i < 256; i++) { WRITESLOW (0x0A, i); SLOWNIBBLEREGISTERREAD (0x0A, i); WRITESLOW (0x0A, 0xFF - i); SLOWNIBBLEREGISTERREAD (0x0A, 0xFF - i); } /* end test for nibble byte/byte mode */ /* now we try nibble buffered mode */ WRITESLOW (0x13, 0x01); WRITESLOW (0x13, 0x00); /*reset something */ WRITESLOW (0x0A, 0x11); for (i = 0; i < 10; i++) /* 10 ~ 11 ? */ { PS2bufferRead (0x400, dest); DBG (16, "Loop %d: PS2bufferRead passed ... (%s:%d)\n", i, __FILE__, __LINE__); } /* write buffer */ for (i = 0; i < 10; i++) { PS2bufferWrite (0x400, dest); DBG (16, "Loop %d: PS2bufferWrite passed ... (%s:%d)\n", i, __FILE__, __LINE__); } SLOWNIBBLEREGISTERREAD (0x0C, 0x04); WRITESLOW (0x13, 0x01); WRITESLOW (0x13, 0x00); WRITESLOW (0x0A, 0x18); return 1; } /* * try EPP 8 then 32 bits * returns 1 on success, 0 on failure */ int probeEPP (unsigned char *dest) { int tmp, i, j; int reg; /* test EPP MODE */ setEPPMode (8); gMode = UMAX_PP_PARPORT_EPP; ClearRegister (0); DBG (16, "ClearRegister(0) passed... (%s:%d)\n", __FILE__, __LINE__); WRITESLOW (0x08, 0x22); init001 (); DBG (16, "init001() passed... (%s:%d)\n", __FILE__, __LINE__); gEPAT = 0xC7; init002 (0); DBG (16, "init002(0) passed... (%s:%d)\n", __FILE__, __LINE__); REGISTERWRITE (0x0A, 0); /* catch any failure to read back data in EPP mode */ reg = registerRead (0x0A); if (reg != 0) { DBG (0, "registerRead, found 0x%X expected 0x00 (%s:%d)\n", reg, __FILE__, __LINE__); if (reg == 0xFF) { DBG (0, "*** It appears that EPP data transfer doesn't work ***\n"); DBG (0, "*** Please read SETTING EPP section in sane-umax_pp.5 ***\n"); } return 0; } else { DBG (16, "registerRead(0x0A)=0x00 passed... (%s:%d)\n", __FILE__, __LINE__); } registerWrite (0x0A, 0xFF); DBG (16, "registerWrite(0x%X,0x%X) passed... (%s:%d)\n", 0x0A, 0xFF, __FILE__, __LINE__); REGISTERREAD (0x0A, 0xFF); for (i = 1; i < 256; i++) { REGISTERWRITE (0x0A, i); REGISTERREAD (0x0A, i); REGISTERWRITE (0x0A, 0xFF - i); REGISTERREAD (0x0A, 0xFF - i); } REGISTERWRITE (0x13, 0x01); REGISTERWRITE (0x13, 0x00); REGISTERWRITE (0x0A, 0x11); for (i = 0; i < 10; i++) { bufferRead (0x400, dest); for (j = 0; j < 512; j++) { if (dest[2 * j] != (j % 256)) { DBG (0, "Loop %d, char %d bufferRead failed! (%s:%d)\n", i, j * 2, __FILE__, __LINE__); return 0; } if (dest[2 * j + 1] != (0xFF - (j % 256))) { DBG (0, "Loop %d, char %d bufferRead failed! (%s:%d)\n", i, j * 2 + 1, __FILE__, __LINE__); return 0; } } DBG (16, "Loop %d: bufferRead(0x400,dest) passed... (%s:%d)\n", i, __FILE__, __LINE__); } for (i = 0; i < 10; i++) { bufferWrite (0x400, dest); DBG (16, "Loop %d: bufferWrite(0x400,dest) passed... (%s:%d)\n", i, __FILE__, __LINE__); } REGISTERREAD (0x0C, 4); REGISTERWRITE (0x13, 0x01); REGISTERWRITE (0x13, 0x00); REGISTERWRITE (0x0A, 0x18); Outb (DATA, 0x0); ClearRegister (0); init001 (); if (checkEPAT () != 0) return 0; DBG (16, "checkEPAT() passed... (%s:%d)\n", __FILE__, __LINE__); tmp = Inb (CONTROL) & 0x1F; Outb (CONTROL, tmp); Outb (CONTROL, tmp); WRITESLOW (0x08, 0x21); init001 (); DBG (16, "init001() passed... (%s:%d)\n", __FILE__, __LINE__); WRITESLOW (0x08, 0x21); init001 (); DBG (16, "init001() passed... (%s:%d)\n", __FILE__, __LINE__); SPPResetLPT (); if (init005 (0x80)) { DBG (0, "init005(0x80) failed... (%s:%d)\n", __FILE__, __LINE__); } DBG (16, "init005(0x80) passed... (%s:%d)\n", __FILE__, __LINE__); if (init005 (0xEC)) { DBG (0, "init005(0xEC) failed... (%s:%d)\n", __FILE__, __LINE__); } DBG (16, "init005(0xEC) passed... (%s:%d)\n", __FILE__, __LINE__); /* write/read buffer loop */ for (i = 0; i < 256; i++) { REGISTERWRITE (0x0A, i); REGISTERREAD (0x0A, i); REGISTERWRITE (0x0A, 0xFF - i); REGISTERREAD (0x0A, 0xFF - i); } DBG (16, "EPP write/read buffer loop passed... (%s:%d)\n", __FILE__, __LINE__); REGISTERWRITE (0x13, 0x01); REGISTERWRITE (0x13, 0x00); REGISTERWRITE (0x0A, 0x11); /* test EPP32 mode */ /* we set 32 bits I/O mode first, then step back to */ /* 8bits if tests fail */ setEPPMode (32); for (i = 0; (i < 10) && (getEPPMode () == 32); i++) { bufferRead (0x400, dest); /* if 32 bit I/O work, we should have a buffer */ /* filled by 00 FF 01 FE 02 FD 03 FC ..... */ for (j = 0; j < 0x200; j++) { if ((dest[j * 2] != j % 256) || (dest[j * 2 + 1] != 0xFF - (j % 256))) { DBG (1, "Setting EPP I/O to 8 bits ... (%s:%d)\n", __FILE__, __LINE__); setEPPMode (8); /* leave out current loop since an error was detected */ break; } } DBG (16, "Loop %d: bufferRead(0x400) passed... (%s:%d)\n", i, __FILE__, __LINE__); } DBG (1, "%d bits EPP data transfer\n", getEPPMode ()); for (i = 0; i < 10; i++) { bufferWrite (0x400, dest); DBG (16, "Loop %d: bufferWrite(0x400,dest) passed... (%s:%d)\n", i, __FILE__, __LINE__); } REGISTERREAD (0x0C, 0x04); REGISTERWRITE (0x13, 0x01); REGISTERWRITE (0x13, 0x00); REGISTERWRITE (0x0A, 0x18); WRITESLOW (0x08, 0x21); init001 (); DBG (16, "init001() passed... (%s:%d)\n", __FILE__, __LINE__); SPPResetLPT (); if (init005 (0x80)) { DBG (0, "init005(0x80) failed... (%s:%d)\n", __FILE__, __LINE__); } DBG (16, "init005(0x80) passed... (%s:%d)\n", __FILE__, __LINE__); if (init005 (0xEC)) { DBG (0, "init005(0xEC) failed... (%s:%d)\n", __FILE__, __LINE__); } DBG (16, "init005(0xEC) passed... (%s:%d)\n", __FILE__, __LINE__); /* write/read buffer loop */ for (i = 0; i < 256; i++) { REGISTERWRITE (0x0A, i); REGISTERREAD (0x0A, i); REGISTERWRITE (0x0A, 0xFF - i); REGISTERREAD (0x0A, 0xFF - i); } DBG (16, "EPP write/read buffer loop passed... (%s:%d)\n", __FILE__, __LINE__); REGISTERWRITE (0x13, 0x01); REGISTERWRITE (0x13, 0x00); REGISTERWRITE (0x0A, 0x11); for (i = 0; i < 10; i++) { bufferRead (0x400, dest); DBG (16, "Loop %d: bufferRead(0x400) passed... (%s:%d)\n", i, __FILE__, __LINE__); } for (i = 0; i < 10; i++) { bufferWrite (0x400, dest); DBG (16, "Loop %d: bufferWrite(0x400,dest) passed... (%s:%d)\n", i, __FILE__, __LINE__); } REGISTERREAD (0x0C, 0x04); REGISTERWRITE (0x13, 0x01); REGISTERWRITE (0x13, 0x00); REGISTERWRITE (0x0A, 0x18); gMode = UMAX_PP_PARPORT_EPP; return 1; } /* * try ECP mode * returns 1 on success, 0 on failure */ int probeECP (unsigned char *dest) { int i, j, tmp; unsigned char breg; /* if ECP not available, fail */ if (gECP != 1) { DBG (1, "Hardware can't do ECP, giving up (%s:%d) ...\n", __FILE__, __LINE__); return 0; } gMode = UMAX_PP_PARPORT_ECP; /* clean from EPP failure */ breg = Inb (CONTROL); Outb (CONTROL, breg & 0x04); /* reset sequence */ byteMode (); /*Outb (ECR, 0x20); byte mode */ Outb (CONTROL, 0x04); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x0C); for (i = 0; i < 256; i++) { breg = (Inb (STATUS)) & 0xF8; if (breg != 0x48) { DBG (0, "probeECP() failed at sync step %d, status=0x%02X, expected 0x48 (%s:%d)\n", i, breg, __FILE__, __LINE__); return 0; } } Outb (CONTROL, 0x0E); Outb (CONTROL, 0x0E); Outb (CONTROL, 0x0E); breg = (Inb (STATUS)) & 0xF8; if (breg != 0x48) { DBG (0, "probeECP() failed, status=0x%02X, expected 0x48 (%s:%d)\n", breg, __FILE__, __LINE__); return 0; } Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); breg = Inb (STATUS) & 0xF8; breg = (Inb (STATUS)) & 0xF8; if (breg != 0xC8) { DBG (0, "probeECP() failed, status=0x%02X, expected 0xC8 (%s:%d)\n", breg, __FILE__, __LINE__); return 0; } /* end of reset sequence */ Outb (DATA, 0x00); ClearRegister (0); /* utile ? semble tester le registre de configuration * inb ECR,35 * inb 77B,FF * inb ECR,35 */ /* routine A */ breg = Inb (CONTROL); /* 0x04 évidemment! */ breg = Inb (ECR); breg = Inb (ECR); breg = Inb (ECR); breg = Inb (ECR); breg = Inb (CONTROL); byteMode (); /*Outb (ECR, 0x20); byte mode */ /*byteMode (); Outb (ECR, 0x20); */ breg = Inb (CONTROL); Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); breg = Inb (ECR); /* 35 expected */ breg = Inb (ECR); /* 35 expected */ breg = Inb (ECR); /* 35 expected */ breg = Inb (ECR); /* 35 expected */ Outb (CONTROL, 0x04); Outb (CONTROL, 0x04); byteMode (); byteMode (); ClearRegister (0); /* routine C */ PS2registerWrite (0x08, 0x01); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x04); ClearRegister (0); breg = PS2Something (0x10); if (breg != 0x0B) { DBG (0, "probeECP() failed, reg10=0x%02X, expected 0x0B (%s:%d)\n", breg, __FILE__, __LINE__); /* return 0; */ } for (i = 0; i < 256; i++) { ECPregisterWrite (0x0A, i); breg = ECPregisterRead (0x0A); if (breg != i) { DBG (0, "probeECP(), loop %d failed (%s:%d)\n", i, __FILE__, __LINE__); return 0; } ECPregisterWrite (0x0A, 0xFF - i); breg = ECPregisterRead (0x0A); if (breg != 0xFF - i) { DBG (0, "probeECP(), loop %d failed (%s:%d)\n", i, __FILE__, __LINE__); return 0; } } DBG (16, "probeECP(), loop passed (%s:%d)\n", __FILE__, __LINE__); ECPregisterWrite (0x13, 0x01); ECPregisterWrite (0x13, 0x00); ECPregisterWrite (0x0A, 0x11); /* there is one buffer transfer size set up */ /* subsequent reads are done in a row */ ECPSetBuffer (0x400); for (i = 0; i < 10; i++) { /* if (i > 0) */ compatMode (); Outb (CONTROL, 0x04); /* reset ? */ ECPbufferRead (1024, dest); /* check content of the returned buffer */ for (j = 0; j < 256; j++) { if (dest[j * 2] != j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", j * 2, j, dest[j * 2]); return 0; } if (dest[j * 2 + 1] != 0xFF - j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", j * 2 + 1, 0xFF - j, dest[j * 2 + 1]); return 0; } if (dest[512 + j * 2] != j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", 512 + j * 2, j, dest[512 + j * 2]); return 0; } if (dest[512 + j * 2 + 1] != 0xFF - j) { DBG (0, "Altered buffer value at %03X, expected 0x%02X, found 0x%02X\n", 512 + j * 2 + 1, 0xFF - j, dest[512 + j * 2 + 1]); return 0; } } Outb (CONTROL, 0x04); byteMode (); } for (i = 0; i < 10; i++) ECPbufferWrite (1024, dest); breg = ECPregisterRead (0x0C); if (breg != 0x04) { DBG (0, "Warning! expected reg0C=0x04, found 0x%02X! (%s:%d) \n", breg, __FILE__, __LINE__); } ECPregisterWrite (0x13, 0x01); ECPregisterWrite (0x13, 0x00); ECPregisterWrite (0x0A, 0x18); /* reset printer ? */ Outb (DATA, 0x00); Outb (CONTROL, 0x00); Outb (CONTROL, 0x04); for (i = 0; i < 3; i++) { /* will go in a function */ ClearRegister (0); if (waitAck () != 1) { DBG (0, "probeECP failed because of waitAck() (%s:%d) \n", __FILE__, __LINE__); /* return 0; may fail without harm ... ??? */ } /* are these 2 out really needed ? */ PS2registerWrite (0x08, 0x01); Outb (CONTROL, 0x0C); /* select + reset */ Outb (CONTROL, 0x04); /* reset */ } /* prologue of the 'rotate test' */ ClearRegister (0); breg = PS2Something (0x10); if (breg != 0x0B) { DBG (0, "PS2Something returned 0x%02X, 0x0B expected (%s:%d)\n", breg, __FILE__, __LINE__); } Outb (CONTROL, 0x04); /* reset */ if (init005 (0x80)) { DBG (0, "init005(0x80) failed... (%s:%d)\n", __FILE__, __LINE__); } DBG (16, "init005(0x80) passed... (%s:%d)\n", __FILE__, __LINE__); if (init005 (0xEC)) { DBG (0, "init005(0xEC) failed... (%s:%d)\n", __FILE__, __LINE__); } DBG (16, "init005(0xEC) passed... (%s:%d)\n", __FILE__, __LINE__); for (i = 0; i < 256; i++) { REGISTERWRITE (0x0A, i); REGISTERREAD (0x0A, i); REGISTERWRITE (0x0A, 0xFF - i); REGISTERREAD (0x0A, 0xFF - i); } DBG (16, "ECPprobe(), write/read buffer loop passed (%s:%d)\n", __FILE__, __LINE__); REGISTERWRITE (0x13, 0x01); REGISTERWRITE (0x13, 0x00); REGISTERWRITE (0x0A, 0x11); /* should be a function */ /* in probeEPP(), we begin 32 bit mode test here */ for (i = 0; i < 10; i++) { compatMode (); Outb (CONTROL, 0x04); /* reset ? */ ECPbufferRead (0x400, dest); /* check content of the returned buffer */ for (j = 0; j < 256; j++) { if (dest[j * 2] != j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", j * 2, j, dest[j * 2]); return 0; } if (dest[j * 2 + 1] != 0xFF - j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", j * 2 + 1, 0xFF - j, dest[j * 2 + 1]); return 0; } if (dest[512 + j * 2] != j) { DBG (0, "Altered buffer value at %03X, expected %02X, found %02X\n", 512 + j * 2, j, dest[512 + j * 2]); return 0; } if (dest[512 + j * 2 + 1] != 0xFF - j) { DBG (0, "Altered buffer value at %03X, expected 0x%02X, found 0x%02X\n", 512 + j * 2 + 1, 0xFF - j, dest[512 + j * 2 + 1]); return 0; } } Outb (CONTROL, 0x04); byteMode (); } for (i = 0; i < 10; i++) ECPbufferWrite (1024, dest); REGISTERREAD (0x0C, 0x04); REGISTERWRITE (0x13, 0x01); REGISTERWRITE (0x13, 0x00); REGISTERWRITE (0x0A, 0x18); waitAck (); return 1; } /* 1: OK 0: probe failed */ int sanei_umax_pp_probeScanner (int recover) { int tmp, i, j; int reg, nb; unsigned char *dest = NULL; int initbuf[2049]; int voidbuf[2049]; int val; int zero[5] = { 0, 0, 0, 0, -1 }; int model; /* saves port state */ gData = Inb (DATA); gControl = Inb (CONTROL); if (sanei_umax_pp_getastra () == 610) return probe610p (recover); /* save and set CONTROL */ tmp = (Inb (CONTROL)) & 0x1F; tmp = (Inb (CONTROL)) & 0x1F; Outb (CONTROL, tmp); Outb (CONTROL, tmp); tmp = Inb (DATA); tmp = Inb (CONTROL) & 0x3F; Outb (CONTROL, tmp); tmp = Inb (CONTROL) & 0x3F; tmp = Inb (DATA); tmp = Inb (CONTROL) & 0x3F; tmp = Inb (DATA); /* any scanner ? */ /* fast detect */ tmp = ringScanner (2, 0); if (!tmp) { DBG (1, "No scanner detected by 'ringScanner(2,0)'...\n"); tmp = ringScanner (5, 0); if (!tmp) { DBG (1, "No scanner detected by 'ringScanner(5,0)'...\n"); tmp = ringScanner (5, 10000); if (!tmp) { DBG (1, "No scanner detected by 'ringScanner(5,10000)'...\n"); tmp = ringScanner (5, 10000); if (!tmp) { DBG (1, "No scanner detected by 'ringScanner(5,10000)'...\n"); } } } } if (!tmp) { DBG (1, "No 1220P/2000P scanner detected by 'ringScanner()'...\n"); } DBG (16, "ringScanner passed...\n"); gControl = Inb (CONTROL) & 0x3F; g67D = 1; if (sendCommand (0x30) == 0) { DBG (0, "sendCommand(0x30) (%s:%d) failed ...\n", __FILE__, __LINE__); return 0; } DBG (16, "sendCommand(0x30) passed ... (%s:%d)\n", __FILE__, __LINE__); g67E = 4; /* bytes to read */ if (sendCommand (0x00) == 0) { DBG (0, "sendCommand(0x00) (%s:%d) failed ...\n", __FILE__, __LINE__); return 0; } DBG (16, "sendCommand(0x00) passed... (%s:%d)\n", __FILE__, __LINE__); g67E = 0; /* bytes to read */ if (testVersion (0) == 0) { DBG (16, "testVersion(0) (%s:%d) failed ...\n", __FILE__, __LINE__); } DBG (16, "testVersion(0) passed...\n"); /* must fail for 1220P and 2000P */ if (testVersion (1) == 0) /* software doesn't do it for model 0x07 */ { /* but it works .. */ DBG (16, "testVersion(1) failed (expected) ... (%s:%d)\n", __FILE__, __LINE__); } else { DBG (16, "Unexpected success on testVersion(1) ... (%s:%d)\n", __FILE__, __LINE__); } if (testVersion (0) == 0) { DBG (16, "testVersion(0) (%s:%d) failed ...\n", __FILE__, __LINE__); } DBG (16, "testVersion(0) passed...\n"); /* must fail */ if (testVersion (1) == 0) { DBG (16, "testVersion(1) failed (expected) ... (%s:%d)\n", __FILE__, __LINE__); } else { DBG (16, "Unexpected success on testVersion(1) ... (%s:%d)\n", __FILE__, __LINE__); } Outb (DATA, 0x04); Outb (CONTROL, 0x0C); Outb (DATA, 0x04); Outb (CONTROL, 0x0C); gControl = Inb (CONTROL) & 0x3F; Outb (CONTROL, gControl & 0xEF); if (sendCommand (0x40) == 0) { DBG (0, "sendCommand(0x40) (%s:%d) failed ...\n", __FILE__, __LINE__); return 0; } DBG (16, "sendCommand(0x40) passed...\n"); if (sendCommand (0xE0) == 0) { DBG (0, "sendCommand(0xE0) (%s:%d) failed ...\n", __FILE__, __LINE__); return 0; } DBG (16, "sendCommand(0xE0) passed...\n"); ClearRegister (0); DBG (16, "ClearRegister(0) passed...\n"); SPPResetLPT (); DBG (16, "SPPResetLPT() passed...\n"); Outb (CONTROL, 4); Outb (CONTROL, 4); /* test PS2 mode */ tmp = PS2registerRead (0x0B); if (tmp == 0xC7) { /* epat C7 detected */ DBG (16, "PS2registerRead(0x0B)=0x%X passed...\n", tmp); PS2registerWrite (8, 0); DBG (16, "PS2registerWrite(8,0) passed... (%s:%d)\n", __FILE__, __LINE__); tmp = PS2registerRead (0x0A); if (tmp != 0x00) { if (tmp == 0x1C) { DBG (16, "Previous probe detected ... (%s:%d)\n", __FILE__, __LINE__); } else { DBG (0, "Found 0x%X expected 0x00 (%s:%d)\n", tmp, __FILE__, __LINE__); } } DBG (16, "PS2registerRead(0x0A)=0x%X passed ...(%s:%d)\n", tmp, __FILE__, __LINE__); } else { DBG (4, "Found 0x%X expected 0xC7 (%s:%d)\n", tmp, __FILE__, __LINE__); if ((tmp == 0xFF) && (sanei_umax_pp_getparport () < 1)) { DBG (0, "It is likely that the hardware address (0x%X) you specified is wrong\n", gPort); return 0; } /* probe for a 610p, since we can't detect an EPAT */ DBG (1, "Trying 610p (%s:%d)\n", __FILE__, __LINE__); return probe610p (recover); } /* clear register 3 */ ClearRegister (3); DBG (16, "ClearRegister(3) passed...\n"); /* wait ? */ i = 65535; while (i > 0) { tmp = Inb (DATA); tmp = Inb (DATA); i--; } DBG (16, "FFFF in loop passed...\n"); ClearRegister (0); DBG (16, "ClearRegister(0) passed... (%s:%d)\n", __FILE__, __LINE__); fflush (stdout); /* 1220/2000P branch */ WRITESLOW (0x0E, 1); /* register 0x0F used only once: model number ? Or ASIC revision ? */ /* comm mode ? */ model = PS2registerRead (0x0F); DBG (1, "UMAX Astra 1220/1600/2000 P ASIC detected (mode=%d)\n", model); setModel (model); DBG (16, "PS2registerRead(0x0F) passed... (%s:%d)\n", __FILE__, __LINE__); /* scanner powered off */ if (model == 0x1B) { DBG (0, "Register 0x0F=0x1B, scanner powered off ! (%s:%d)\n", __FILE__, __LINE__); return 0; } if ((model != 0x1F) && (model != 0x07)) { DBG (0, "Unexpected value for for register 0x0F, expected 0x07 or 0x1F, got 0x%02X ! (%s:%d)\n", model, __FILE__, __LINE__); DBG (0, "There is a new scanner revision in town, or a bug ....\n"); } WRITESLOW (0x08, 0x02); WRITESLOW (0x0E, 0x0F); WRITESLOW (0x0F, 0x0C); WRITESLOW (0x0C, 0x04); tmp = PS2registerRead (0x0D); if ((tmp != 0x00) && (tmp != 0x40)) { DBG (0, "Unexpected value for for register 0x0D, expected 0x00 or 0x40, got 0x%02X ! (%s:%d)\n", tmp, __FILE__, __LINE__); } WRITESLOW (0x0D, 0x1B); switch (model) { case 0x1F: WRITESLOW (0x12, 0x14); SLOWNIBBLEREGISTERREAD (0x12, 0x10); break; case 0x07: WRITESLOW (0x12, 0x00); SLOWNIBBLEREGISTERREAD (0x12, 0x00); /* we may get 0x20, in this case some color aberration may occur */ /* must depend on the parport */ /* model 0x07 + 0x00=>0x20=2000P */ break; default: WRITESLOW (0x12, 0x00); SLOWNIBBLEREGISTERREAD (0x12, 0x20); break; } SLOWNIBBLEREGISTERREAD (0x0D, 0x18); SLOWNIBBLEREGISTERREAD (0x0C, 0x04); SLOWNIBBLEREGISTERREAD (0x0A, 0x00); WRITESLOW (0x0E, 0x0A); WRITESLOW (0x0F, 0x00); WRITESLOW (0x0E, 0x0D); WRITESLOW (0x0F, 0x00); dest = (unsigned char *) malloc (65536); if (dest == NULL) { DBG (0, "Failed to allocate 64K (%s:%d)\n", __FILE__, __LINE__); return 0; } gMode = UMAX_PP_PARPORT_PS2; if (probePS2 (dest)) { /* PS2 mode works */ DBG (16, "probePS2 passed ... (%s:%d)\n", __FILE__, __LINE__); gprobed = UMAX_PP_PARPORT_PS2; } Outb (CONTROL, 4); SLOWNIBBLEREGISTERREAD (0x0A, 0x18); WRITESLOW (0x08, 0x40); WRITESLOW (0x08, 0x60); WRITESLOW (0x08, 0x22); gMode = UMAX_PP_PARPORT_EPP; if (probeEPP (dest)) { /* EPP mode works */ gprobed = UMAX_PP_PARPORT_EPP; gMode = UMAX_PP_PARPORT_EPP; DBG (16, "probeEPP passed ... (%s:%d)\n", __FILE__, __LINE__); } else { /* EPP fails, try ECP */ DBG (16, "probeEPP failed ... (%s:%d)\n", __FILE__, __LINE__); gMode = UMAX_PP_PARPORT_ECP; if (probeECP (dest)) { /* ECP mode works */ DBG (16, "probeECP passed ... (%s:%d)\n", __FILE__, __LINE__); gprobed = UMAX_PP_PARPORT_ECP; } else { /* ECP and EPP fail, give up */ /* PS2 could be used */ DBG (16, "probeECP failed ... (%s:%d)\n", __FILE__, __LINE__); DBG (1, "No EPP or ECP mode working, giving up ... (%s:%d)\n", __FILE__, __LINE__); free (dest); return 0; } } /* some operations here may have to go into probeEPP/probeECP */ g6FE = 1; if (gMode == UMAX_PP_PARPORT_ECP) { WRITESLOW (0x08, 0x01); Outb (CONTROL, 0x0C); Outb (CONTROL, 0x04); ClearRegister (0); tmp = PS2Something (0x10); if (tmp != 0x0B) { DBG (0, "PS2Something returned 0x%02X, 0x0B expected (%s:%d)\n", tmp, __FILE__, __LINE__); } } else { WRITESLOW (0x08, 0x21); init001 (); DBG (16, "init001() passed... (%s:%d)\n", __FILE__, __LINE__); } reg = registerRead (0x0D); reg = (reg & 0xE8) | 0x43; registerWrite (0x0D, reg); REGISTERWRITE (0x0A, 0x18); REGISTERWRITE (0x0E, 0x0F); REGISTERWRITE (0x0F, 0x0C); REGISTERWRITE (0x0A, 0x1C); REGISTERWRITE (0x0E, 0x10); REGISTERWRITE (0x0F, 0x1C); reg = registerRead (0x0D); /* 0x48 expected */ reg = registerRead (0x0D); reg = registerRead (0x0D); reg = (reg & 0xB7) | 0x03; registerWrite (0x0D, reg); DBG (16, "(%s:%d) passed \n", __FILE__, __LINE__); reg = registerRead (0x12); /* 0x10 for model 0x0F, 0x20 for model 0x07 */ /* 0x00 when in ECP mode ... */ reg = reg & 0xEF; registerWrite (0x12, reg); DBG (16, "(%s:%d) passed \n", __FILE__, __LINE__); reg = registerRead (0x0A); if (reg != 0x1C) { DBG (0, "Warning! expected reg0A=0x1C, found 0x%02X! (%s:%d) \n", reg, __FILE__, __LINE__); } DBG (16, "(%s:%d) passed \n", __FILE__, __LINE__); /*Inb(CONTROL); ECP 0x04 expected */ disconnect (); DBG (16, "disconnect() passed... (%s:%d)\n", __FILE__, __LINE__); connect (); DBG (16, "connect() passed... (%s:%d)\n", __FILE__, __LINE__); /* some sort of countdown, some warming-up ? */ /* maybe some data sent to the stepper motor */ /* if (model == 0x07) */ { /* REGISTERWRITE (0x0A, 0x00); reg = registerRead (0x0D); reg = (reg & 0xE8); registerWrite (0x0D, reg); DBG (16, "(%s:%d) passed \n", __FILE__, __LINE__); */ epilogue (); prologue (0x10); reg = registerRead (0x13); if (reg != 0x00) { DBG (0, "Warning! expected reg13=0x00, found 0x%02X! (%s:%d) \n", reg, __FILE__, __LINE__); } REGISTERWRITE (0x13, 0x81); usleep (10000); REGISTERWRITE (0x13, 0x80); /* could it be step-motor values ? */ REGISTERWRITE (0x0E, 0x04); /* FF->R04 */ REGISTERWRITE (0x0F, 0xFF); REGISTERWRITE (0x0E, 0x05); /* 03->R05 */ REGISTERWRITE (0x0F, 0x03); REGISTERWRITE (0x10, 0x66); usleep (10000); REGISTERWRITE (0x0E, 0x04); /* FF->R04 */ REGISTERWRITE (0x0F, 0xFF); REGISTERWRITE (0x0E, 0x05); /* 01 ->R05 */ REGISTERWRITE (0x0F, 0x01); REGISTERWRITE (0x10, 0x55); usleep (10000); REGISTERWRITE (0x0E, 0x04); /* FF -> R04 */ REGISTERWRITE (0x0F, 0xFF); REGISTERWRITE (0x0E, 0x05); /* 00 -> R05 */ REGISTERWRITE (0x0F, 0x00); REGISTERWRITE (0x10, 0x44); usleep (10000); REGISTERWRITE (0x0E, 0x04); /* 7F -> R04 */ REGISTERWRITE (0x0F, 0x7F); REGISTERWRITE (0x0E, 0x05); /* 00 -> R05 */ REGISTERWRITE (0x0F, 0x00); REGISTERWRITE (0x10, 0x33); usleep (10000); REGISTERWRITE (0x0E, 0x04); /* 3F -> R04 */ REGISTERWRITE (0x0F, 0x3F); REGISTERWRITE (0x0E, 0x05); REGISTERWRITE (0x0F, 0x00); /* 00 -> R05 */ REGISTERWRITE (0x10, 0x22); usleep (10000); REGISTERWRITE (0x0E, 0x04); REGISTERWRITE (0x0F, 0x00); REGISTERWRITE (0x0E, 0x05); REGISTERWRITE (0x0F, 0x00); REGISTERWRITE (0x10, 0x11); usleep (10000); REGISTERWRITE (0x13, 0x81); usleep (10000); REGISTERWRITE (0x13, 0x80); REGISTERWRITE (0x0E, 0x04); REGISTERWRITE (0x0F, 0x00); REGISTERWRITE (0x0E, 0x05); REGISTERWRITE (0x0F, 0x00); usleep (10000); reg = registerRead (0x10); DBG (1, "Count-down value is 0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); /* 2 reports of CF, was FF first (typo ?) */ /* CF seems a valid value */ /* in case of CF, we may have timeout ... */ /*if (reg != 0x00) { DBG (0, "Warning! expected reg10=0x00, found 0x%02X! (%s:%d) \n", reg, __FILE__, __LINE__); } */ REGISTERWRITE (0x13, 0x00); } /* end of countdown */ DBG (16, "(%s:%d) passed \n", __FILE__, __LINE__); /* *NOT* epilogue(); (when EPP) */ /*REGISTERWRITE (0x0A, 0x00); REGISTERREAD (0x0D, 0x40); REGISTERWRITE (0x0D, 0x00); */ epilogue (); prologue (0x10); REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); REGISTERWRITE (0x0A, 0x1C); /* real start of high level protocol ? */ if (fonc001 () != 1) { DBG (0, "fonc001() failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (16, "fonc001() passed (%s:%d) \n", __FILE__, __LINE__); reg = registerRead (0x19) & 0xC8; /* if reg=E8 or D8 , we have a 'messed' scanner */ /* 4 tranform buffers + 'void' are sent: 1 B&W, and 3 RGB ? */ memset (initbuf, 0x00, 2048 * sizeof (int)); memset (voidbuf, 0x00, 2048 * sizeof (int)); initbuf[512] = 0xFF; initbuf[513] = 0xAA; initbuf[514] = 0x55; for (j = 0; j < 4; j++) { for (i = 0; i < 256; i++) { voidbuf[512 * j + 2 * i] = i; voidbuf[512 * j + 2 * i] = 0xFF - i; } } /* one pass (B&W ?) */ if (cmdSetDataBuffer (initbuf) != 1) { DBG (0, "cmdSetDataBuffer(initbuf) failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (16, "cmdSetDataBuffer(initbuf) passed... (%s:%d)\n", __FILE__, __LINE__); if (cmdSetDataBuffer (voidbuf) != 1) { DBG (0, "cmdSetDataBuffer(voidbuf) failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (16, "cmdSetDataBuffer(voidbuf) passed... (%s:%d)\n", __FILE__, __LINE__); /* everything above the FF 55 AA tag is 'void' */ /* it seems that the buffer is reused and only the beginning is initalized */ for (i = 515; i < 2048; i++) initbuf[i] = voidbuf[i]; /* three pass (RGB ?) */ for (i = 0; i < 3; i++) { if (cmdSetDataBuffer (initbuf) != 1) { DBG (0, "cmdSetDataBuffer(initbuf) failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (16, "Loop %d: cmdSetDataBuffer(initbuf) passed... (%s:%d)\n", i, __FILE__, __LINE__); if (cmdSetDataBuffer (voidbuf) != 1) { DBG (0, "Loop %d: cmdSetDataBuffer(voidbuf) failed ! (%s:%d) \n", i, __FILE__, __LINE__); return 0; } } /* memory size testing ? */ /* load 150 Ko in scanner */ REGISTERWRITE (0x1A, 0x00); REGISTERWRITE (0x1A, 0x0C); REGISTERWRITE (0x1A, 0x00); REGISTERWRITE (0x1A, 0x0C); REGISTERWRITE (0x0A, 0x11); /* start */ nb = 150; for (i = 0; i < nb; i++) /* 300 for ECP ??? */ { bufferWrite (0x400, dest); DBG (16, "Loop %d: bufferWrite(0x400,dest) passed... (%s:%d)\n", i, __FILE__, __LINE__); } REGISTERWRITE (0x0A, 0x18); /* end */ /* read them back */ REGISTERWRITE (0x0A, 0x11); /*start transfert */ if (gMode == UMAX_PP_PARPORT_ECP) { ECPSetBuffer (0x400); } for (i = 0; i < nb; i++) /* 300 for ECP ??? */ { bufferRead (0x400, dest); DBG (16, "Loop %d: bufferRead(0x400,dest) passed... (%s:%d)\n", i, __FILE__, __LINE__); } REGISTERWRITE (0x0A, 0x18); /*end transfer */ /* fully disconnect, then reconnect */ if (gMode == UMAX_PP_PARPORT_ECP) { epilogue (); sendCommand (0xE0); Outb (DATA, 0xFF); Outb (DATA, 0xFF); ClearRegister (0); WRITESLOW (0x0E, 0x0A); SLOWNIBBLEREGISTERREAD (0x0F, 0x00); WRITESLOW (0x0F, 0x08); WRITESLOW (0x08, 0x10); /* 0x10 ?? */ prologue (0x10); } /* almost cmdSync(0x00) which halts any pending operation */ if (fonc001 () != 1) { DBG (0, "fonc001() failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (16, "Fct001() passed (%s:%d) \n", __FILE__, __LINE__); if (sendWord (zero) == 0) { DBG (0, "sendWord(zero) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } epilogue (); DBG (16, "sendWord(zero) passed (%s:%d)\n", __FILE__, __LINE__); /* end transport init */ /* now high level (connected) protocol begins */ val = sanei_umax_pp_initScanner (recover); if (val == 0) { DBG (0, "initScanner() failed (%s:%d)\n", __FILE__, __LINE__); return 0; } /* if no homing .... */ if (val == 1) { CMDSYNC (0); CMDSYNC (0xC2); CMDSYNC (0); } /* set port to its initial state */ Outb (DATA, gData); Outb (CONTROL, gControl); free (dest); DBG (1, "probe done ...\n"); return 1; } static int disconnect_epat (void) { REGISTERWRITE (0x0A, 0x00); registerRead (0x0D); REGISTERWRITE (0x0D, 0x00); disconnect (); return 1; } static int connect_epat (int r08) { int reg; if (connect () != 1) { DBG (0, "connect_epat: connect() failed! (%s:%d)\n", __FILE__, __LINE__); return 0; } reg = registerRead (0x0B); if (reg != gEPAT) { /* ASIC version is not */ /* the one expected (epat c7) */ DBG (0, "Error! expected reg0B=0x%02X, found 0x%02X! (%s:%d) \n", gEPAT, reg, __FILE__, __LINE__); /* we try to clean all */ disconnect (); return 0; } reg = registerRead (0x0D); reg = (reg | 0x43) & 0xEB; REGISTERWRITE (0x0D, reg); REGISTERWRITE (0x0C, 0x04); reg = registerRead (0x0A); if (reg != 0x00) { /* a previous unfinished command */ /* has left an uncleared value */ DBG (0, "Warning! expected reg0A=0x00, found 0x%02X! (%s:%d) \n", reg, __FILE__, __LINE__); } REGISTERWRITE (0x0A, 0x1C); if (r08 != 0) { if (gMode == UMAX_PP_PARPORT_ECP) { REGISTERWRITE (0x08, r08); /* 0x01 or 0x10 ??? */ } else { REGISTERWRITE (0x08, 0x21); } } REGISTERWRITE (0x0E, 0x0F); REGISTERWRITE (0x0F, 0x0C); REGISTERWRITE (0x0A, 0x1C); REGISTERWRITE (0x0E, 0x10); REGISTERWRITE (0x0F, 0x1C); if (gMode == UMAX_PP_PARPORT_ECP) { REGISTERWRITE (0x0F, 0x00); } return 1; } static int prologue (int r08) { switch (sanei_umax_pp_getastra ()) { case 610: connect610p (); return sync610p (); case 1220: case 1600: case 2000: default: return connect_epat (r08); } } static int epilogue (void) { switch (sanei_umax_pp_getastra ()) { case 610: return disconnect610p (); case 1220: case 1600: case 2000: default: return disconnect_epat (); } } static int EPPcmdGet610p (int cmd, int len, int *val) { int word[4]; int i, status, control; word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x3F) | 0x80 | 0x40; /* 0x40 means 'read' */ connect610p (); sync610p (); /* sends magic seal 55 AA */ status = EPPputByte610p (0x55); if (status != 0xC8) { DBG (1, "EPPcmdGet610p: Found 0x%X expected 0xC8 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } status = EPPputByte610p (0xAA); if (status != 0xC8) { DBG (1, "EPPcmdGet610p: Found 0x%02X expected 0xC8 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } /* tests status */ /* scannerStatus=0x58 */ status = EPPgetStatus610p (); if (status != 0xC8) { DBG (1, "EPPcmdGet610p: Found 0x%X expected 0xC8, status=0x%02X (%s:%d)\n", status, scannerStatus, __FILE__, __LINE__); return 0; } /* sends length of data */ for (i = 0; (i < 4) && (status == 0xC8); i++) { status = EPPputByte610p (word[i]); } if (status != 0xC8) { DBG (1, "EPPcmdGet610p: loop %d, found 0x%02X expected 0xC8 (%s:%d)\n", i, status, __FILE__, __LINE__); return 0; } Outb (DATA, 0xFF); /* tests status */ /* scannerStatus=0x58 */ status = EPPgetStatus610p (); if (status != 0xD0) { DBG (1, "EPPcmdGet610p: Found 0x%X expected 0xD0, status=0x%02X (%s:%d)\n", status, scannerStatus, __FILE__, __LINE__); return 0; } /* data reverse */ control = Inb (CONTROL) & 0xF4; control = control | 0xA0; /* receive data */ i = 0; while (i < len) { status = Inb (STATUS) & 0xF8; if (status & 0x08) { DBG (1, "EPPcmdGet610p: loop %d, found 0x%X expected 0xD0 or 0xC0 (%s:%d)\n", i, status, __FILE__, __LINE__); return 0; } val[i] = Inb (EPPDATA); i++; } if (DBG_LEVEL >= 8) { char *str = NULL; str = malloc (3 * len + 1); if (str != NULL) { for (i = 0; i < len; i++) { sprintf (str + 3 * i, "%02X ", val[i]); } str[3 * i] = 0x00; DBG (8, "String received for %02X: %s\n", cmd, str); free (str); } else { TRACE (8, "not enough memory for debugging ..."); } } /* scannerStatus=0x58 */ status = EPPgetStatus610p (); scannerStatus = status; if (status != 0xC0) { DBG (0, "EPPcmdGet610p: Found 0x%02X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } disconnect610p (); return 1; } static int cmdGet610p (int cmd, int len, int *val) { int word[5]; int i, j, status; if ((cmd == 8) && (len > 0x23)) len = 0x23; if (gMode == UMAX_PP_PARPORT_EPP) return EPPcmdGet610p (cmd, len, val); /* compute word */ word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x3F) | 0x80 | 0x40; /* 0x40 means 'read' */ word[4] = -1; connect610p (); sync610p (); if (sendLength610p (word) == 0) { DBG (0, "sendLength610p(word) failed... (%s:%d)\n", __FILE__, __LINE__); return 0; } status = getStatus610p (); scannerStatus = status; if ((status != 0xC0) && (status != 0xD0)) { DBG (0, "Found 0x%02X expected 0xC0 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } if (receiveData610p (val, len) == 0) { DBG (0, "sendData610p(val,%d) failed (%s:%d)\n", len, __FILE__, __LINE__); return 0; } status = getStatus610p (); scannerStatus = status; j = 0; while ((j < 256) && (status & 0x08)) { status = getStatus610p (); j++; } if (status != 0xC0) { DBG (0, "Found 0x%02X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } disconnect610p (); if (DBG_LEVEL >= 8) { char *str = NULL; str = malloc (3 * len + 1); if (str != NULL) { for (i = 0; i < len; i++) { sprintf (str + 3 * i, "%02X ", val[i]); } str[3 * i] = 0x00; DBG (8, "String received for %02X: %s\n", cmd, str); free (str); } else { TRACE (8, "not enough memory for debugging ..."); } } return 1; } static int EPPcmdSet610p (int cmd, int len, int *val) { int word[5]; int i, status; if ((cmd == 8) && (len > 0x23)) { /* blank useless extra bytes */ for (i = 0x22; i < len; i++) val[i] = 0x00; } word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x3F) | 0x80; connect610p (); sync610p (); /* sends magic seal 55 AA */ status = EPPputByte610p (0x55); if ((status != 0xC8) && (status!=0xC0)) { DBG (0, "EPPcmdSet610p: Found 0x%X expected 0xC0 or 0xC8 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } status = EPPputByte610p (0xAA); if ((status != 0xC8) && (status!=0xC0)) { DBG (0, "EPPcmdSet610p: Found 0x%X expected 0xC0 or 0xC8 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } /* tests status */ status = EPPgetStatus610p (); if ((status != 0xC8) && (status!=0xC0)) { DBG (0, "EPPcmdSet610p: Found 0x%02X expected 0xC0 or 0xC8 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } /* sends length of data */ for (i = 0; i < 4; i++) { status = EPPputByte610p (word[i]); } if ((status != 0xC8) && (status!=0xC0)) { DBG (0, "EPPcmdSet610p: loop %d, found 0x%02X expected 0xC0 or 0xC8 (%s:%d)\n", i, status, __FILE__, __LINE__); return 0; } Outb (DATA, 0xFF); /* tests status */ status = EPPgetStatus610p (); if (status != 0xC0) { DBG (0, "Found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } /* sends data */ status = 0xC8; for (i = 0; (i < len) && (status == 0xC8); i++) { /* escape special values with ESC (0x1B) */ if (val[i] == 0x1B) status = EPPputByte610p (0x1B); if (i > 0) { if ((val[i] == 0xAA) && (val[i - 1] == 0x55)) status = EPPputByte610p (0x1B); } /* now send data */ status = EPPputByte610p (val[i]); } if (status != 0xC8) { DBG (0, "EPPcmdSet610p: loop %d, found 0x%02X expected 0xC8 (%s:%d)\n", i, status, __FILE__, __LINE__); return 0; } Outb (DATA, 0xFF); status = EPPgetStatus610p (); if (status != 0xC0) { DBG (0, "Found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } disconnect610p (); return 1; } static int cmdSet610p (int cmd, int len, int *val) { int word[5]; int i, j, status; if (gMode == UMAX_PP_PARPORT_EPP) return EPPcmdSet610p (cmd, len, val); if ((cmd == 8) && (len > 0x23)) { /* blank useless extra bytes */ for (i = 0x22; i < len; i++) val[i] = 0x00; } /* compute word */ word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x3F) | 0x80; word[4] = -1; connect610p (); sync610p (); if (sendLength610p (word) == 0) { DBG (0, "sendLength610p(word) failed... (%s:%d)\n", __FILE__, __LINE__); return 0; } status = getStatus610p (); scannerStatus = status; if ((status != 0xC0) && (status != 0xD0)) { DBG (1, "Found 0x%X expected 0xC0 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } if (sendData610p (val, len) == 0) { DBG (1, "sendData610p(val,%d) failed (%s:%d)\n", len, __FILE__, __LINE__); return 0; } status = getStatus610p (); scannerStatus = status; j = 0; while ((j < 256) && (status & 0x08)) { status = getStatus610p (); j++; } if (status != 0xC0) { DBG (1, "Found 0x%X expected 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); /* return 0; */ } disconnect610p (); return 1; } static int cmdSet (int cmd, int len, int *val) { int word[5]; int i; if (DBG_LEVEL >= 8) { char *str = NULL; str = malloc (3 * len + 1); if (str != NULL) { for (i = 0; i < len; i++) { sprintf (str + 3 * i, "%02X ", val[i]); } str[3 * i] = 0x00; DBG (8, "String sent for %02X: %s\n", cmd, str); free (str); } else { TRACE (8, "not enough memory for debugging ..."); } } if (sanei_umax_pp_getastra () == 610) return cmdSet610p (cmd, len, val); /* cmd 08 as 2 length depending upon model */ if ((cmd == 8) && (getModel () == 0x07)) { len = 35; } /* compute word */ word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x3F) | 0x80; if (!prologue (0x10)) { DBG (0, "cmdSet: prologue failed ! (%s:%d)\n", __FILE__, __LINE__); return 0; } /* send data */ if (sendLength (word, 4) == 0) { DBG (0, "sendLength(word,4) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } TRACE (16, "sendLength(word,4) passed ..."); /* head end */ epilogue (); if (len > 0) { /* send body */ if (!prologue (0x10)) { DBG (0, "cmdSet: prologue failed ! (%s:%d)\n", __FILE__, __LINE__); } /* send data */ if (sendData (val, len) == 0) { DBG (0, "sendData(word,%d) failed (%s:%d)\n", len, __FILE__, __LINE__); epilogue (); return 0; } TRACE (16, "sendData(val,len) passed ..."); /* body end */ epilogue (); } return 1; } static int cmdGet (int cmd, int len, int *val) { int word[5]; int i; if (sanei_umax_pp_getastra () == 610) return cmdGet610p (cmd, len, val); /* cmd 08 as 2 length depending upon model */ if ((cmd == 8) && (getModel () == 0x07)) { len = 35; } /* compute word */ word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x3F) | 0x80 | 0x40; /* 0x40 means 'read' */ word[4] = -1; /* send header */ if (!prologue (0x10)) { DBG (0, "cmdGet: prologue failed ! (%s:%d)\n", __FILE__, __LINE__); return 0; } /* send data */ if (sendLength (word, 4) == 0) { DBG (0, "sendLength(word,4) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } TRACE (16, "sendLength(word,4) passed ..."); /* head end */ epilogue (); /* send header */ if (!prologue (0x10)) { DBG (0, "cmdGet: prologue failed ! (%s:%d)\n", __FILE__, __LINE__); return 0; } /* get actual data */ if (receiveData (val, len) == 0) { DBG (0, "receiveData(val,len) failed (%s:%d)\n", __FILE__, __LINE__); epilogue (); return 0; } if (DBG_LEVEL >= 8) { char *str = NULL; str = malloc (3 * len + 1); if (str != NULL) { for (i = 0; i < len; i++) { sprintf (str + 3 * i, "%02X ", val[i]); } str[3 * i] = 0x00; DBG (8, "String received for %02X: %s\n", cmd, str); free (str); } else { TRACE (8, "not enough memory for debugging ..."); } } epilogue (); return 1; } static int cmdSetGet (int cmd, int len, int *val) { int *tampon; int i; /* model revision 0x07 uses 35 bytes buffers */ /* cmd 08 as 2 length depending upon model */ if ((cmd == 8) && (getModel () == 0x07)) { len = 0x23; } /* first we send */ if (cmdSet (cmd, len, val) == 0) { DBG (0, "cmdSetGet failed ! (%s:%d)\n", __FILE__, __LINE__); return 0; } tampon = (int *) malloc (len * sizeof (int)); memset (tampon, 0x00, len * sizeof (int)); if (tampon == NULL) { DBG (0, "Failed to allocate room for %d int ! (%s:%d)\n", len, __FILE__, __LINE__); epilogue (); return 0; } /* then we receive */ if (cmdGet (cmd, len, tampon) == 0) { DBG (0, "cmdSetGet failed ! (%s:%d)\n", __FILE__, __LINE__); free (tampon); epilogue (); return 0; } /* check and copy */ for (i = 0; (i < len) && (val[i] >= 0); i++) { if (tampon[i] != val[i]) { DBG (0, "Warning data read back differs: expected %02X found tampon[%d]=%02X ! (%s:%d)\n", val[i], i, tampon[i], __FILE__, __LINE__); } val[i] = tampon[i]; } /* OK */ free (tampon); return 1; } /* 1 OK, 0 failed */ static int EPPcmdGetBuffer610p (int cmd, int len, unsigned char *buffer) { int status, i, tmp, control; int word[5]; int count, needed, max; #ifdef HAVE_LINUX_PPDEV_H int fd, mode, rc, wait; #endif int loop, remain; /* first we set length and channel */ /* compute word */ word[0] = len / 65536; word[1] = (len / 256) % 256; word[2] = len % 256; word[3] = (cmd & 0x0F) | 0xC0; word[4] = -1; connect610p (); /* start of EPPsendLength610p */ sync610p (); /* sends magic seal 55 AA */ status = EPPputByte610p (0x55); if ((status != 0xD0) && (status != 0xC8)) { DBG (0, "EPPcmdGetBuffer610p: Found 0x%X expected 0xC8 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } status = EPPputByte610p (0xAA); if ((status != 0xD0) && (status != 0xC8)) { DBG (0, "EPPcmdGetBuffer610p: Found 0x%02X expected 0xC8 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } /* tests status */ status = EPPgetStatus610p (); if ((status != 0xD0) && (status != 0xC8)) { DBG (0, "EPPcmdGetBuffer610p: Found 0x%X expected 0xC8 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } /* sends length of data */ for (i = 0; i < 4; i++) { status = EPPputByte610p (word[i]); } if ((status != 0xC0) && (status != 0xC8)) { DBG (0, "EPPcmdGetBuffer610p: loop %d, found 0x%02X expected 0xC0 or 0xC8 (%s:%d)\n", i, status, __FILE__, __LINE__); return 0; } Outb (DATA, 0xFF); /* test status */ status = EPPgetStatus610p (); if ((status != 0xC0) && (status != 0xD0)) { DBG (0, "EPPcmdGetBuffer610p: Found 0x%X expected 0xC0 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); /*return 0; */ } disconnect610p (); /* end of EPPsendLength610p */ /* max data read in one go */ if (sanei_umax_pp_getfull () == 1) max = 2550 / 3; else max = 32768; /* loop until enough data is read */ count = 0; while (count < len) { if (len - count > max) needed = max; else needed = len - count; if (needed % 4) remain = needed % 4; else remain = 4; loop = (needed - remain) / 2; DBG (32, "EPPcmdGetBuffer610p: %d loops to do \n", loop); status = 0x20; /* wait for data ready */ while ((status & 0x80) != 0x80) { /* this is SPPgetStatus */ connect610p (); Outb (CONTROL, 0x07); Outb (DATA, 0xFF); tmp = Inb (DATA); if (tmp != 0xFF) { DBG (0, "EPPcmdGetBuffer610p found 0x%02X expected 0xFF (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } status = Inb (STATUS) & 0xF8; if ((status & 0x80) != 0x80) { disconnect610p (); usleep(1000); } else { Outb (CONTROL, 0x04); sync610p (); Outb (DATA, 0xFF); control = (Inb (CONTROL) & 0x44) | 0xE4; Outb (CONTROL, control); } } /* EPP block read */ /* there is one form for full CCD width reads, and another for other reads */ #ifdef HAVE_LINUX_PPDEV_H wait = 0; /* check we have ppdev working */ fd = sanei_umax_pp_getparport (); if (fd > 0) { mode = 1; /* data_reverse */ rc = ioctl (fd, PPDATADIR, &mode); if (rc) DBG (0, "EPPcmdGetBuffer610p: ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #ifdef PPSETFLAGS mode = PP_FASTREAD; rc = ioctl (fd, PPSETFLAGS, &mode); if (rc) DBG (0, "EPPcmdGetBuffer610p: ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); #endif mode = IEEE1284_MODE_EPP | IEEE1284_DATA; rc = ioctl (fd, PPSETMODE, &mode); if (rc) { DBG (0, "EPPcmdGetBuffer610p: ppdev ioctl returned <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return 0; } if (sanei_umax_pp_getfull () == 1) { do { rc = read (fd, buffer + count, needed); } while (rc == EAGAIN); if (rc < 0) { DBG (0, "EPPcmdGetBuffer610p: ppdev read failed <%s> (%s:%d)\n", strerror (errno), __FILE__, __LINE__); return 0; } #ifdef IOLOG DBG (0, "insb *%d\n", rc); #endif needed = rc; } else { for (loop = 0; (loop < needed) && (wait==0); loop++) { status = Inb (STATUS) & 0xF8; if ((status != 0xD0) && (status != 0xC0) && (status != 0xC8)) { DBG (0, "EPPcmdGetBuffer610p found 0x%02X expected 0xD0 or 0xC0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } if (status == 0xC8) { wait = 1; needed=loop; } else { tmp = Inb (EPPDATA); buffer[count + loop] = tmp; } } } } else #endif /* HAVE_LINUX_PPDEV_H */ { Insb (EPPDATA, buffer + count, needed); } count += needed; disconnect610p (); } usleep (10000); /* ??? CMDSYNC (0x00); */ /* everything went fine */ return 1; } /* 1 OK, 0 failed */ static int cmdGetBuffer610p (int cmd, int len, unsigned char *buffer) { int status, i, tmp; int word[5]; int read, needed, max; if (gMode == UMAX_PP_PARPORT_EPP) return EPPcmdGetBuffer610p (cmd, len, buffer); /* first we set length and channel */ /* compute word */ word[0] = len / 65536; word[1] = (len / 256) % 256; word[2] = len % 256; word[3] = (cmd & 0x0F) | 0xC0; word[4] = -1; connect610p (); sync610p (); if (sendLength610p (word) == 0) { DBG (0, "sendLength610p(word) failed... (%s:%d)\n", __FILE__, __LINE__); return 0; } status = getStatus610p (); scannerStatus = status; if ((status != 0xC0) && (status != 0xD0)) { DBG (1, "Found 0x%X expected 0xC0 or 0xD0 (%s:%d)\n", status, __FILE__, __LINE__); return 0; } disconnect610p (); if (sanei_umax_pp_getfull () == 1) max = 2550 / 3; else max = 32768; read = 0; while (read < len) { if (len - read > max) needed = max; else needed = len - read; if (sanei_umax_pp_getfull () == 0) status = getStatus610p (); else status = 0x20; /* wait for data ready */ while ((status & 0x80) == 0x00) { connect610p (); Outb (CONTROL, 0x07); Outb (DATA, 0xFF); tmp = Inb (DATA); if (tmp != 0xFF) { DBG (0, "cmdGetBuffer610p found 0x%02X expected 0xFF (%s:%d)\n", tmp, __FILE__, __LINE__); return 0; } status = Inb (STATUS) & 0xF8; if ((status & 0x80) == 0x00) disconnect610p (); else { Outb (CONTROL, 0x04); sync610p (); byteMode (); } } i = 0; while (i < needed) { if (sanei_umax_pp_getfull () == 0) { status = Inb (STATUS) & 0xF8; if (status == 0xC8) { for (tmp = 0; tmp < 18; tmp++) status = Inb (STATUS) & 0xF8; break; } } Outb (CONTROL, 0x26); /* data reverse+ 'reg' */ buffer[read + i] = Inb (DATA); Outb (CONTROL, 0x24); /* data reverse+ 'reg' */ i++; } byteMode (); disconnect610p (); read += i; } return 1; } /* 1 OK, 0 failed */ static int cmdGetBuffer (int cmd, int len, unsigned char *buffer) { int reg, tmp; int word[5], read; int needed; if (sanei_umax_pp_getastra () == 610) return cmdGetBuffer610p (cmd, len, buffer); /* compute word */ word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x0F) | 0xC0; word[4] = -1; /* send word: len+addr(?) */ if (foncSendWord (word) == 0) { DBG (0, "foncSendWord(word) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "(%s:%d) passed \n", __FILE__, __LINE__); prologue (0x10); REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); reg = registerRead (0x19) & 0xF8; /* wait if busy */ while ((reg & 0x08) == 0x08) reg = registerRead (0x19) & 0xF8; if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "cmdGetBuffer failed (%s:%d)\n", __FILE__, __LINE__); return 0; } if (gMode == UMAX_PP_PARPORT_ECP) { REGISTERWRITE (0x1A, 0x44); } read = 0; reg = registerRead (0x0C); if (reg != 0x04) { DBG (0, "cmdGetBuffer failed: unexpected status 0x%02X ...(%s:%d)\n", reg, __FILE__, __LINE__); return 0; } REGISTERWRITE (0x0C, reg | 0x40); /* actual data */ read = 0; while (read < len) { needed = len - read; if (needed > 32768) needed = 32768; if (gMode == UMAX_PP_PARPORT_ECP) { compatMode (); Outb (CONTROL, 0x04); /* reset ? */ ECPSetBuffer (needed); tmp = ECPbufferRead (needed, buffer + read); DBG (16, "ECPbufferRead(%d,buffer+read) passed (%s:%d)\n", needed, __FILE__, __LINE__); REGISTERWRITE (0x1A, 0x84); } else { tmp = pausedBufferRead (needed, buffer + read); } if (tmp < needed) { DBG (64, "cmdGetBuffer only got %d bytes out of %d ...(%s:%d)\n", tmp, needed, __FILE__, __LINE__); } else { DBG (64, "cmdGetBuffer got all %d bytes out of %d , read=%d...(%s:%d)\n", tmp, 32768, read, __FILE__, __LINE__); } read += tmp; DBG (16, "Read %d bytes out of %d (last block is %d bytes) (%s:%d)\n", read, len, tmp, __FILE__, __LINE__); if (read < len) { /* wait for scanner to be ready */ reg = registerRead (0x19) & 0xF8; DBG (64, "Status after block read is 0x%02X (%s:%d)\n", reg, __FILE__, __LINE__); if ((reg & 0x08) == 0x08) { int pass = 0; do { reg = registerRead (0x19) & 0xF8; usleep (100); pass++; } while ((pass < 32768) && ((reg & 0x08) == 0x08)); DBG (64, "Status after waiting is 0x%02X (pass=%d) (%s:%d)\n", reg, pass, __FILE__, __LINE__); if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "Unexpected status 0x%02X, expected 0xC0 or 0xD0 ! (%s:%d)\n", reg, __FILE__, __LINE__); DBG (0, "Going on...\n"); } } /* signal we want next data chunk */ if (gMode == UMAX_PP_PARPORT_ECP) { REGISTERWRITE (0x1A, 0x44); } reg = registerRead (0x0C); registerWrite (0x0C, reg | 0x40); } } /* OK ! */ REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); /* epilogue */ epilogue (); return 1; } /* 1 OK, 0 failed */ static int cmdGetBuffer32 (int cmd, int len, unsigned char *buffer) { int reg, tmp; int word[5], read; /* compute word */ word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x3F) | 0x80 | 0x40; if (!prologue (0x10)) { DBG (0, "cmdSet: prologue failed ! (%s:%d)\n", __FILE__, __LINE__); return 0; } /* send data */ if (sendLength (word, 4) == 0) { DBG (0, "sendLength(word,4) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } TRACE (16, "sendLength(word,4) passed ..."); /* head end */ epilogue (); prologue (0x10); REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); reg = registerRead (0x19) & 0xF8; /* wait if busy */ while ((reg & 0x08) == 0x08) reg = registerRead (0x19) & 0xF8; if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "cmdGetBuffer32 failed: unexpected status 0x%02X ...(%s:%d)\n", reg, __FILE__, __LINE__); return 0; } reg = registerRead (0x0C); if (reg != 0x04) { DBG (0, "cmdGetBuffer32 failed: unexpected status 0x%02X ...(%s:%d)\n", reg, __FILE__, __LINE__); return 0; } REGISTERWRITE (0x0C, reg | 0x40); read = 0; while (read < len) { if (read + 1700 < len) { tmp = 1700; bufferRead (tmp, buffer + read); reg = registerRead (0x19) & 0xF8; if ((read + tmp < len) && (reg & 0x08) == 0x08) { do { reg = registerRead (0x19) & 0xF8; } while ((reg & 0x08) == 0x08); if ((reg != 0xC0) && (reg != 0xD0)) { DBG (0, "Unexpected status 0x%02X, expected 0xC0 or 0xD0 ! (%s:%d)\n", reg, __FILE__, __LINE__); DBG (0, "Going on...\n"); } } reg = registerRead (0x0C); registerWrite (0x0C, reg | 0x40); read += tmp; } else { tmp = len - read; bufferRead (tmp, buffer + read); read += tmp; if ((read < len)) { reg = registerRead (0x19) & 0xF8; while ((reg & 0x08) == 0x08) { reg = registerRead (0x19) & 0xF8; } } } } /* OK ! */ epilogue (); return 1; } int sanei_umax_pp_cmdSync (int cmd) { int word[5]; if (sanei_umax_pp_getastra () == 610) return cmdSync610p (cmd); /* compute word */ word[0] = 0x00; word[1] = 0x00; word[2] = 0x00; word[3] = cmd; if (!prologue (0x10)) { DBG (0, "cmdSync: prologue failed ! (%s:%d)\n", __FILE__, __LINE__); } /* send data */ if (sendLength (word, 4) == 0) { DBG (0, "sendLength(word,4) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } TRACE (16, "sendLength(word,4) passed ..."); /* end OK */ epilogue (); return 1; } /* numbers of bytes read, else 0 (failed) */ /* read data by chunk EXACTLY the width of the scan area in the given */ /* resolution . If a valid file descriptor is given, we write data */ /* in it according to the color mode, before polling the scanner */ /* len should not be bigger than 2 Megs */ int cmdGetBlockBuffer (int cmd, int len, int window, unsigned char *buffer) { #ifdef HAVE_SYS_TIME_H struct timeval td, tf; float elapsed; #endif int reg; int word[5], read; /* compute word */ word[0] = len / 65536; word[1] = len / 256 % 256; word[2] = len % 256; word[3] = (cmd & 0x3F) | 0x80 | 0x40; if (!prologue (0x10)) { DBG (0, "cmdGetBlockBuffer: prologue failed ! (%s:%d)\n", __FILE__, __LINE__); } /* send data */ if (sendLength (word, 4) == 0) { DBG (0, "sendLength(word,4) failed (%s:%d)\n", __FILE__, __LINE__); return 0; } TRACE (16, "sendLength(word,4) passed ..."); /* head end */ epilogue (); if (!prologue (0x10)) { DBG (0, "cmdGetBlockBuffer: prologue failed ! (%s:%d)\n", __FILE__, __LINE__); } REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); /* init counter */ read = 0; /* read scanner state */ reg = registerRead (0x19) & 0xF8; /* read loop */ while (read < len) { /* wait for the data to be ready */ #ifdef HAVE_SYS_TIME_H gettimeofday (&td, NULL); #endif while ((reg & 0x08) == 0x08) { reg = registerRead (0x19) & 0xF8; #ifdef HAVE_SYS_TIME_H gettimeofday (&tf, NULL); elapsed = ((tf.tv_sec * 1000000 + tf.tv_usec) - (td.tv_sec * 1000000 + td.tv_usec)) / 1000000; if (elapsed > 3) { DBG (0, "Time-out (%.2f s) waiting for scanner ... giving up on status 0x%02X ! (%s:%d)\n", elapsed, reg, __FILE__, __LINE__); epilogue (); return read; } #endif } if ((reg != 0xC0) && (reg != 0xD0) && (reg != 0x00)) { DBG (0, "Unexpected status 0x%02X, expected 0xC0 or 0xD0 ! (%s:%d)\n", reg, __FILE__, __LINE__); DBG (0, "Going on...\n"); } /* signals next chunk */ reg = registerRead (0x0C); if (reg != 0x04) { DBG (0, "cmdGetBlockBuffer failed: unexpected value reg0C=0x%02X ...(%s:%d)\n", reg, __FILE__, __LINE__); return 0; } REGISTERWRITE (0x0C, reg | 0x40); /* there is always a full block ready when scanner is ready */ /* 32 bits I/O read , window must match the width of scan */ bufferRead (window, buffer + read); /* add bytes read */ read += window; DBG (16, "Read %d bytes out of %d (last block is %d bytes) (%s:%d)\n", read, len, window, __FILE__, __LINE__); /* test status after read */ reg = registerRead (0x19) & 0xF8; } /* wait for the data to be ready */ #ifdef HAVE_SYS_TIME_H gettimeofday (&td, NULL); #endif while ((reg & 0x08) == 0x08) { reg = registerRead (0x19) & 0xF8; #ifdef HAVE_SYS_TIME_H gettimeofday (&tf, NULL); elapsed = ((tf.tv_sec * 1000000 + tf.tv_usec) - (td.tv_sec * 1000000 + td.tv_usec)) / 1000000; if (elapsed > 3) { DBG (0, "Time-out (%.2f s) waiting for scanner ... giving up on status 0x%02X ! (%s:%d)\n", elapsed, reg, __FILE__, __LINE__); epilogue (); return read; } #endif } if ((reg != 0xC0) && (reg != 0xD0) && (reg != 0x00)) { DBG (0, "Unexpected status 0x%02X, expected 0xC0 or 0xD0 ! (%s:%d)\n", reg, __FILE__, __LINE__); DBG (0, "Going on...\n"); } REGISTERWRITE (0x0E, 0x0D); REGISTERWRITE (0x0F, 0x00); /* OK ! */ epilogue (); return read; } /* * encodes DC offsets: must be in [0..0x0F] range */ static void encodeDC (int dcRed, int dcGreen, int dcBlue, int *motor) { motor[11] = (motor[11] & 0x0F) | dcRed << 4; motor[12] = (motor[12] & 0xC3) | dcGreen << 2; motor[13] = (motor[13] & 0xF0) | dcBlue; } static void decodeDC (int *motor) { DBG (0, "DC (R,G,B)=(%d,%d,%d)\n", (motor[11] & 0xF0) >> 4, (motor[12] & 0x3C) >> 2, motor[13] & 0x0F); } /* * encodes VGA : must be in [0..0x0F] range */ static void encodeVGA (int vgaRed, int vgaGreen, int vgaBlue, int *motor) { if (sanei_umax_pp_getastra () > 610) { motor[10] = (vgaRed << 4) | vgaGreen; motor[11] = (motor[11] & 0xF0) | vgaBlue; } else { motor[10] = (vgaGreen << 4) | vgaBlue; motor[11] = (motor[11] & 0xF0) | vgaRed; /* ancien F00: vert 0F0: bleu 00F: rouge motor[10] = (vgaRed << 4) | vgaGreen; motor[11] = (motor[11] & 0xF0) | vgaBlue; */ } } static void decodeVGA (int *motor) { if (sanei_umax_pp_getastra () > 610) { DBG (0, "VGA (R,G,B)=(%d,%d,%d)\n", (motor[10] & 0xF0) >> 4, (motor[10] & 0x0F), (motor[11] & 0x0F)); } else { DBG (0, "VGA (R,G,B)=(%d,%d,%d)\n", (motor[11] & 0x0F), (motor[10] & 0xF0) >> 4, (motor[10] & 0x0F)); } } /* * this function encodes total head movement which includes * y movement and scan area height * height is scan area height * ypos is head movement before scan * total move will be ypos+height */ static void encodeHY (int height, int ypos, int *motor) { motor[0] = height % 256; motor[1] = (height / 256) & 0x3F; motor[1] = motor[1] | (ypos & 0x03) << 6; motor[2] = (ypos >> 2) % 256; motor[3] = (motor[3] & 0xF0) | ((ypos >> 10) & 0x0F); } /* * this function encodes x start and x end on the CCD * w is width of scanning area * x is start of scanning area * dpi is x resolution * color is non zero if scanning in color * bytes is on aoverride for bpl, since it sin't clear today when * the formula has to be applied */ static void encodeWX (int width, int xstart, int dpi, int color, int *ccd, int bytes) { int xend; int bpl; int x; xend = xstart + width; x = xstart - 1; /* x start encoding */ ccd[17] = x % 256; ccd[18] = (ccd[18] & 0xF0) | ((x / 256) & 0x0F); /* models >=1220P have a 600 dpi CCD: x is bigger */ if (sanei_umax_pp_getastra () > 610) { if (x > 0x1000) ccd[33] |= 0x40; else ccd[33] &= 0xBF; } /* x end encoding */ ccd[18] = (ccd[18] & 0x0F) | ((xend % 16) << 4); ccd[19] = (xend / 16) % 256; /* models >=1220P have a 600 dpi CCD: x is bigger */ if (sanei_umax_pp_getastra () > 610) { if (xend > 0x1000) ccd[33] |= 0x80; else ccd[33] &= 0x7F; } /* now bytes per line */ /* bpl = (op[24] - 0x41) * 256 + 8192 * (op[34] & 0x01) + op[23]; */ bpl = (color == 0 ? 1 : 3) * width * dpi; if (sanei_umax_pp_getastra () > 610) { bpl /= 600; if (bpl >= 8192) ccd[34] |= 0x01; else ccd[34] &= 0xFE; } else { bpl /= 300; } if (bytes > 0) bpl = bytes; ccd[23] = bpl % 256; ccd[24] = 0x41 + ((bpl / 256) & 0x1F); } /* cropping coefficient: last 2 bytes gives the coefficient applied */ /* to data scanned to get the actual image resolution */ static void encodeCoefficient (int color, int dpi, int *calibration) { int w, idx = 0; int *coeff; /* 75, 150, 300, 600 and 1200 dpi */ int color610p[4][2] = { {0x88, 0x88}, {0xAA, 0xAA}, {0xFF, 0xFF}, {0xFF, 0xFF} }; int gray610p[4][2] = { {0x88, 0x01}, {0xAA, 0x11}, {0xFF, 0xAA}, {0xFF, 0xFF} }; /* FF means coeff=1 * AA coeff=1/2 * 88 coeff=1/4 * 80 coeff=1/8 * first coeff for CCD (x) * second coeff for motor steps (y) */ int color1220p[5][2] = { {0x80, 0xAA}, {0x88, 0xFF}, {0xAA, 0xFF}, {0xFF, 0xFF}, {0xFF, 0xFF} }; int gray1220p[5][2] = { {0x80, 0x88}, {0x88, 0xAA}, {0xAA, 0xFF}, {0xFF, 0xFF}, {0xFF, 0xFF} }; switch (dpi) { case 1200: idx = 4; break; case 600: idx = 3; break; case 300: idx = 2; break; case 150: idx = 1; break; case 75: idx = 0; break; } if (sanei_umax_pp_getastra () < 1210) { w = 2550; if (color >= RGB_MODE) coeff = color610p[idx]; else coeff = gray610p[idx]; } else { w = 5100; if (color >= RGB_MODE) coeff = color1220p[idx]; else coeff = gray1220p[idx]; } /* x coefficient */ calibration[3 * w + 768] = coeff[0]; /* y coefficient */ calibration[3 * w + 769] = coeff[1]; } static void bloc2Decode (int *op) { int i; int scanh; int skiph; int dpi = 0; int dir = 0; int color = 0; char str[64]; for (i = 0; i < 16; i++) sprintf (str + 3 * i, "%02X ", (unsigned char) op[i]); str[48] = 0x00; DBG (0, "Command bloc 2: %s\n", str); scanh = op[0] + (op[1] & 0x3F) * 256; skiph = ((op[1] & 0xC0) >> 6) + (op[2] << 2) + ((op[3] & 0x0F) << 10); if (op[3] & 0x10) dir = 1; else dir = 0; /* XXX STEF XXX seems to conflict with DC definitions */ if (op[13] & 0x40) color = 1; else color = 0; /* op[6]=0x60 at 600 and 1200 dpi */ if ((op[8] == 0x17) && (op[9] != 0x05)) dpi = 150; if ((op[8] == 0x17) && (op[9] == 0x05)) dpi = 300; if ((op[9] == 0x05) && (op[14] & 0x08)) dpi = 1200; if ((dpi == 0) && ((op[14] & 0x08) == 0)) dpi = 600; DBG (0, "\t->scan height =0x%04X (%d)\n", scanh, scanh); DBG (0, "\t->skip height =0x%04X (%d)\n", skiph, skiph); DBG (0, "\t->y dpi =0x%04X (%d)\n", dpi, dpi); decodeVGA (op); decodeDC (op); if (dir) DBG (0, "\t->forward direction\n"); else DBG (0, "\t->reverse direction\n"); if (color) DBG (0, "\t->color scan \n"); else DBG (0, "\t->no color scan \n"); /* byte 14 */ if (op[14] & 0x20) { DBG (0, "\t->lamp on \n"); } else { DBG (0, "\t->lamp off \n"); } if (op[14] & 0x04) { DBG (0, "\t->normal scan (head stops at each row) \n"); } else { DBG (0, "\t->move and scan (head doesn't stop at each row) \n"); } DBG (0, "\n"); } static void bloc8Decode (int *op) { int i, bpl; int xskip; int xend, len; char str[128]; if (sanei_umax_pp_getastra () < 1220) len = 34; else len = 36; for (i = 0; i < len; i++) sprintf (str + 3 * i, "%02X ", (unsigned char) op[i]); str[3 * i] = 0x00; DBG (0, "Command bloc 8: %s\n", str); xskip = op[17] + 256 * (op[18] & 0x0F); if (op[33] & 0x40) xskip += 0x1000; xend = (op[18] & 0xF0) / 16 + 16 * op[19]; if (op[33] & 0x80) xend += 0x1000; if (len > 34) bpl = (op[24] - 0x41) * 256 + 8192 * (op[34] & 0x01) + op[23]; else bpl = (op[24] - 0x41) * 256 + op[23]; DBG (0, "\t->xskip =0x%X (%d)\n", xskip, xskip); DBG (0, "\t->xend =0x%X (%d)\n", xend, xend); DBG (0, "\t->scan width=0x%X (%d)\n", xend - xskip - 1, xend - xskip - 1); DBG (0, "\t->bytes/line=0x%X (%d)\n", bpl, bpl); DBG (0, "\t->raw =0x%X (%d)\n", op[24] * 256 + op[23], op[24] * 256 + op[23]); DBG (0, "\n"); } static int completionWait (void) { /* for 610P, wait and sync is done while * reading data from the scanner */ CMDSYNC (0x40); usleep (100000); CMDSYNC (0xC2); if ((sanei_umax_pp_getastra () == 610) || ((sanei_umax_pp_scannerStatus () & 0x90) == 0x90)) return 1; do { usleep (100000); CMDSYNC (0xC2); } while ((sanei_umax_pp_scannerStatus () & 0x90) != 0x90); CMDSYNC (0xC2); return 1; } int sanei_umax_pp_setLamp (int on) { int buffer[17]; int state; /* reset? */ sanei_umax_pp_cmdSync (0x00); sanei_umax_pp_cmdSync (0xC2); sanei_umax_pp_cmdSync (0x00); /* get status */ cmdGet (0x02, 16, buffer); state = buffer[14] & LAMP_STATE; buffer[16] = -1; if ((state == 0) && (on == 0)) { DBG (0, "Lamp already off ... (%s:%d)\n", __FILE__, __LINE__); return 1; } if ((state) && (on)) { DBG (2, "Lamp already on ... (%s:%d)\n", __FILE__, __LINE__); return 1; } /* set lamp state */ if (on) buffer[14] = buffer[14] | LAMP_STATE; else buffer[14] = buffer[14] & ~LAMP_STATE; CMDSETGET (0x02, 16, buffer); TRACE (16, "setLamp passed ..."); return 1; } static int num = 0; static void Dump (int len, unsigned char *data, char *name) { FILE *fic; char titre[80]; if (name == NULL) { sprintf (titre, "dump%04d.bin", num); num++; } else { sprintf (titre, "%s", name); } fic = fopen (titre, "wb"); if (fic == NULL) { DBG (0, "could not open %s for writing\n", titre); return; } fwrite (data, 1, len, fic); fclose (fic); } static void DumpNB (int width, int height, unsigned char *data, char *name) { FILE *fic; char titre[80]; if (name == NULL) { sprintf (titre, "dump%04d.pnm", num); num++; } else { sprintf (titre, "%s", name); } fic = fopen (titre, "wb"); if (fic == NULL) { DBG (0, "could not open %s for writing\n", titre); return; } fprintf (fic, "P5\n%d %d\n255\n", width, height); fwrite (data, width, height, fic); fclose (fic); } /* dump data has received from scanner (red line/green line/blue line) to a color pnm file */ static void DumpRVB (int width, int height, unsigned char *data, char *name) { FILE *fic; char titre[80]; int y, x; if (name == NULL) { sprintf (titre, "dump%04d.pnm", num); num++; } else { sprintf (titre, "%s", name); } fic = fopen (titre, "wb"); if (fic == NULL) { DBG (0, "could not open %s for writing\n", titre); return; } fprintf (fic, "P6\n%d %d\n255\n", width, height); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { fputc (data[3 * y * width + 2 * width + x], fic); fputc (data[3 * y * width + width + x], fic); fputc (data[3 * y * width + x], fic); } } fclose (fic); } /* dump a color buffer in a color PNM */ static void DumpRGB (int width, int height, unsigned char *data, char *name) { FILE *fic; char titre[80]; int y, x; if (name == NULL) { sprintf (titre, "dump%04d.pnm", num); num++; } else { sprintf (titre, "%s", name); } fic = fopen (titre, "wb"); fprintf (fic, "P6\n%d %d\n255\n", width, height); if (fic == NULL) { DBG (0, "could not open %s for writing\n", titre); return; } for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { fputc (data[3 * y * width + x * 3], fic); fputc (data[3 * y * width + x * 3 + 1], fic); fputc (data[3 * y * width + x * 3 + 2], fic); } } fclose (fic); } static int evalGain (int sum, int count) { int gn; float pct; float avg; float area=50; float coeff=2.5; float cnst=0.9; /* after ~ 60 * 10 scans , it looks like 1 step is a 0.57% increase */ /* so we take the value and compute the percent increase to reach 250 */ /* (target code) not 255, because we want some room for inaccuracy */ /* pct=100-(value*100)/250 */ /* then correction is pct/0.57 */ avg = (float) (sum) / (float) (count); pct = 100.0 - (avg * 100.0) / targetCode; gn = (int) (pct / 0.57); /* give gain for dark areas a boost */ #ifdef UMAX_PP_DANGEROUS_EXPERIMENT if(getenv("AREA")!=NULL) cnst=atol(getenv("AREA")); if(getenv("COEFF")!=NULL) cnst=atol(getenv("COEFF")); if(getenv("CNST")!=NULL) cnst=atol(getenv("CNST")); #endif pct = gn; avg = exp((-pct)/area)*coeff+cnst; gn = gn * avg; /* bound checking : there are sightings of >127 values being negative */ if (gn < 0) gn = 0; else if (gn > 127) gn = 127; return gn; } static void computeCalibrationData (int color, int width, unsigned char *source, int *data) { int p, i, l; int sum; memset (data, 0, (3 * 5100 + 768 + 3) * sizeof (int)); /* 0 -> 5099 */ for (i = 0; i < width; i++) { /* red calibration data */ if (color >= RGB_MODE) { /* compute average */ sum = 0; for (l = 0; l < 66; l++) sum += source[i + l * 5100 * 3]; data[i] = evalGain (sum, l); } else data[i] = 0x00; } /* 5100 -> 10199: green data */ p = 5100; for (i = 0; i < width; i++) { /* compute average */ sum = 0; for (l = 0; l < 66; l++) sum += source[i + l * 5100 * 3 + 5100]; data[p + i] = evalGain (sum, l); } /* 10200 -> 15299: blue */ p = 10200; for (i = 0; i < width; i++) { if (color >= RGB_MODE) { /* compute average */ sum = 0; for (l = 0; l < 66; l++) sum += source[i + l * 5100 * 3 + 5100 * 2]; data[p + i] = evalGain (sum, l); } else data[p + i] = 0x00; } /* gamma tables */ for (i = 0; i < 256; i++) data[15300 + i] = ggRed[i]; for (i = 0; i < 256; i++) data[15300 + 256 + i] = ggGreen[i]; for (i = 0; i < 256; i++) data[15300 + 512 + i] = ggBlue[i]; data[16070] = -1; } /* move head by the distance given using precision or not */ /* 0: failed 1: success */ static int move (int distance, int precision, unsigned char *buffer) { int header[17] = { 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x60, 0x2F, 0x2F, 0x01, 0x00, 0x00, 0x00, 0x80, 0xA4, 0x00, -1 }; int body[37] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x6E, 0xF6, 0x79, 0xBF, 0x01, 0x00, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; int end[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, -1 }; int steps, len, cmdlen; unsigned char tmp[0x200]; unsigned char *ptr; if (distance == 0) return 0; if (buffer == NULL) ptr = tmp; else ptr = buffer; /* build commands */ if (distance < 0) { /* header */ steps = -distance - 1; header[3] = 0x20; header[9] = 0x01; /* reverse direction body by default */ /* end */ end[1] = 0xFF; end[2] = 0xFF; end[3] = -1; len = 3; } else { /* header */ steps = distance - 1; header[3] = 0x70; header[9] = 0x05; /* body */ body[2] = 0x04; body[4] = 0x02; body[7] = 0x0C; body[9] = 0x04; body[10] = 0x40; body[11] = 0x01; /* end */ len = 8; } if (steps > 0) { encodeHY (1, steps, header); } if (sanei_umax_pp_getastra () < 1220) { header[6] = 0xC0; body[16] = 0x76; /* encodeWX */ body[17] = 0x00; body[18] = 0x15; body[19] = 0x70; body[20] = 0x01; body[21] = 0x00; body[28] = 0x4D; body[29] = 0x4B; body[30] = 0xD0; cmdlen = 0x22; } else cmdlen = 0x24; /* precision: default header set to precision on */ if (precision == PRECISION_OFF) { if (sanei_umax_pp_getastra () == 1600) header[8] = 0x15; else header[8] = 0x17; if (sanei_umax_pp_getastra () > 610) header[14] = 0xAC; body[20] = 0x06; } CMDSETGET (0x02, 16, header); CMDSETGET (0x08, cmdlen, body); if (DBG_LEVEL >= 128) { bloc2Decode (header); bloc8Decode (body); } CMDSYNC (0xC2); if ((sanei_umax_pp_scannerStatus () & 0x80) || (sanei_umax_pp_getastra () < 1220)) { CMDSYNC (0x00); } CMDSETGET (4, len, end); COMPLETIONWAIT; CMDGETBUF (4, 0x200, ptr); if (DBG_LEVEL >= 128) { Dump (0x200, ptr, NULL); } DBG (16, "MOVE STATUS IS 0x%02X (%s:%d)\n", sanei_umax_pp_scannerStatus (), __FILE__, __LINE__); CMDSYNC (0x00); return 1; } /* for each column, finds the row where white/black transition occurs then returns the average */ static float edgePosition (int width, int height, unsigned char *data) { int ecnt, x, y; float epos; int d, dmax, dpos, i; unsigned char *dbuffer = NULL; if (DBG_LEVEL > 128) { dbuffer = (unsigned char *) malloc (3 * width * height); memset (dbuffer, 0x00, 3 * width * height); } epos = 0; ecnt = 0; for (x = 0; x < width; x++) { /* edge: white->black drop */ /* loop stops on black area */ dmax = 0; dpos = 0; d = 0; i = 0; for (y = 10; (y < height) && (data[i] > 10); y++) { i = x + y * width; d = data[i - width] - data[i]; if (d > dmax) { dmax = d; dpos = y; } if ((DBG_LEVEL > 128) && (dbuffer != NULL)) { dbuffer[i * 3] = data[i]; dbuffer[i * 3 + 1] = data[i]; dbuffer[i * 3 + 2] = data[i]; } } epos += dpos; ecnt++; if ((DBG_LEVEL > 128) && (dbuffer != NULL)) { dbuffer[(x + dpos * width) * 3] = 0xFF; dbuffer[(x + dpos * width) * 3 + 1] = 0x00; dbuffer[(x + dpos * width) * 3 + 2] = 0x00; } } if (ecnt == 0) epos = 70; else epos = epos / ecnt; if ((DBG_LEVEL > 128) && (dbuffer != NULL)) { i = ((int) epos) * width; for (x = 0; x < width; x++) { dbuffer[(x + i) * 3] = 0x00; dbuffer[(x + i) * 3 + 1] = 0xFF; dbuffer[(x + i) * 3 + 2] = 0xFF; } for (y = 0; y < height; y++) { dbuffer[(width / 2 + y * width) * 3] = 0x00; dbuffer[(width / 2 + y * width) * 3 + 1] = 0xFF; dbuffer[(width / 2 + y * width) * 3 + 2] = 0x00; } DumpRGB (width, height, dbuffer, NULL); free (dbuffer); } return epos; } static int moveToOrigin (void) { unsigned char buffer[54000]; float edge; int val, delta = 188; int header[17] = { 0xB4, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2F, 0x2F, 0x05, 0x00, 0x00, 0x00, 0x80, 0xA4, 0x00, -1 }; int body[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6E, 0xFB, 0xC4, 0xE5, 0x06, 0x00, 0x00, 0x60, 0x4D, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; int end[9] = { 0x06, 0xF4, 0xFF, 0x81, 0x1B, 0x00, 0x08, 0x00, -1 }; int opsc03[9] = { 0x00, 0x00, 0x00, 0xAA, 0xCC, 0xEE, 0x80, 0xFF, -1 }; int w = 300, h = 180, len = 36; switch (sanei_umax_pp_getastra ()) { case 1600: header[8] = 0x2B; body[29] = 0x1A; body[30] = 0xEE; end[0] = 0x19; end[1] = 0xD5; end[4] = 0x1B; // fall through case 1220: case 2000: w = 300; h = 180; len = 36; delta = -188; CMDSYNC (0x00); CMDSYNC (0xC2); CMDSYNC (0x00); MOVE (196, PRECISION_OFF, NULL); break; case 610: w = 512; h = 90; len = 34; delta = -81; opsc03[6] = 0xFF; /* instead of 0x80 */ encodeHY (h, 60, header); /* will add encodeDpi(dpi,cmd) */ header[6] = 0xC0; header[8] = 0x17; body[13] = 0x20; body[14] = 0x02; body[16] = 0x76; encodeWX (0x200, 0x501, 300, 0, body, 0x500); /* fixed values for all 610p commands */ body[28] = 0x4D; body[29] = 0x4B; body[30] = 0xD0; /* LM9811 command block ? */ end[0] = 0x88; end[1] = 0xE6; end[2] = 0xFD; end[3] = 0x8E; end[4] = 0x30; break; } /* scan an area where is a white and a black regions, which */ /* can be detected and gives this offset to the origin of the */ /* scanning windows */ CMDSETGET (2, 0x10, header); CMDSETGET (8, len, body); CMDSETGET (1, 0x08, end); CMDSYNC (0xC2); CMDSYNC (0x00); /* signals black & white ? */ CMDSETGET (4, 8, opsc03); COMPLETIONWAIT; CMDGETBUF (4, w * h, buffer); /* get find position data */ if (DBG_LEVEL > 128) { DumpNB (w, h, buffer, NULL); } /* detection of 1600P is a by product of origin finding */ edge = 0.0; for (val = 0; val < w * h; val++) if (buffer[val] > edge) edge = buffer[val]; DBG (32, "MAX VALUE=%f (%s:%d)\n", edge, __FILE__, __LINE__); if ((edge <= 30) && (sanei_umax_pp_getastra () != 1600)) { DBG (2, "moveToOrigin() detected a 1600P"); sanei_umax_pp_setastra (1600); } edge = edgePosition (w, h, buffer); /* rounded to lowest integer, since upping origin might lead */ /* to bump in the other side if doing a full size preview */ val = (int) (edge); delta += val; DBG (64, "Edge=%f, val=%d, delta=%d\n", edge, val, delta); /* move back to y-coordinate origin */ if (sanei_umax_pp_getastra () < 1220) { MOVE (delta, PRECISION_OFF, NULL); } else { MOVE (delta, PRECISION_ON, NULL); } /* head successfully set to the origin */ return 1; } /* park head: returns 1 on success, 0 otherwise */ int sanei_umax_pp_park (void) { int header610[17] = { 0x01, 0x00, 0x01, 0x40, 0x30, 0x00, 0xC0, 0x2F, 0x17, 0x05, 0x00, 0x00, 0x00, 0x80, 0xF4, 0x00, -1 }; int body610[35] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x00, 0x20, 0x02, 0x00, 0x16, 0x80, 0x15, 0x78, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x4D, 0x4B, 0xD0, 0x68, 0xDF, 0x1B, -1 }; int header[17] = { 0x01, 0x00, 0x01, 0x70, 0x00, 0x00, 0x60, 0x2F, 0x13, 0x05, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x00, -1 }; int body[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x00, 0x00, 0x04, 0x00, 0x16, 0x80, 0x15, 0x78, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x1B, 0x1A, 0x00, -1 }; int status = 0x90; CMDSYNC (0x00); if (sanei_umax_pp_getastra () > 610) { CMDSETGET (0x02, 0x10, header); CMDSETGET (0x08, 0x24, body); } else { CMDSETGET (0x02, 0x10, header610); CMDSETGET (0x08, 0x22, body610); } CMDSYNC (0x40); status = sanei_umax_pp_scannerStatus (); DBG (16, "PARKING STATUS is 0x%02X (%s:%d)\n", status, __FILE__, __LINE__); DBG (1, "Park command issued ...\n"); return 1; } /* calibrates CCD: returns 1 on success, 0 on failure */ static int shadingCalibration1220p (int color, int dcRed, int dcGreen, int dcBlue, int vgaRed, int vgaGreen, int vgaBlue, int *calibration) { int opsc32[17] = { 0x4A, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x00, 0x17, 0x05, 0xA5, 0x08, 0x00, 0x00, 0xAC, 0x00, -1 }; int opsc41[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6E, 0x90, 0xD0, 0x47, 0x06, 0x00, 0x00, 0xC4, 0x5C, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x93, 0x1B, 0x00, -1 }; int opscnb[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6E, 0x90, 0xD0, 0x47, 0x06, 0x00, 0x00, 0xEC, 0x54, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x93, 0x1A, 0x00, -1 }; int opsc04[9] = { 0x06, 0xF4, 0xFF, 0x81, 0x1B, 0x00, 0x00, 0x00, -1 }; int commit[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, -1 }; int size; int width = 5100; /* full usable CCD width */ unsigned char buffer[0x105798]; /* 1600P have a different CCD command block */ if (sanei_umax_pp_getastra () == 1600) { opsc04[0] = 0x19; opsc04[1] = 0xD5; opsc04[4] = 0x1B; opsc41[29] = 0x1A; opsc41[30] = 0xEE; } /* step back by 67 ticks: */ /* since we're going to scan 66 lines of data */ /* which are going to be used as calibration */ /* data */ /* we are on the white area just before */ /* the user scan area */ MOVE (-67, PRECISION_ON, NULL); CMDSYNC (0x00); /* get calibration data */ /* if (sanei_umax_pp_getauto ()) { auto settings doesn't use offset offset = 0x000; } else { manual settings gain = 0x777; offset = 0x000; } */ encodeDC (dcRed, dcGreen, dcBlue, opsc32); encodeVGA (vgaRed, vgaGreen, vgaBlue, opsc32); if (sanei_umax_pp_getastra () == 1600) { opsc32[13] = 0x03; } /* 1220P/2000P shading calibration */ if (color < RGB_MODE) { opsc32[0] -= 4; opsc32[13] = 0xC0; } CMDSETGET (2, 0x10, opsc32); if (DBG_LEVEL >= 64) { bloc2Decode (opsc32); } if (color < RGB_MODE) { CMDSETGET (8, 0x24, opscnb); if (DBG_LEVEL >= 64) { bloc8Decode (opscnb); } opsc04[6] = 0x85; } else { CMDSETGET (8, 0x24, opsc41); if (DBG_LEVEL >= 64) { bloc8Decode (opsc41); } opsc04[6] = 0x0F; if (sanei_umax_pp_getastra () == 1600) opsc04[7] = 0xC0; else opsc04[7] = 0x70; } /* BUG BW noisy here */ CMDSETGET (1, 0x08, opsc04); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); /* opsc03 hangs it */ COMPLETIONWAIT; opsc04[0] = 0x06; if (color >= RGB_MODE) size = 3 * width * 70; else size = width * 66; if (getEPPMode () == 32) { cmdGetBuffer32 (4, size, buffer); } else { CMDGETBUF (4, size, buffer); } if (DBG_LEVEL >= 128) { Dump (size, buffer, NULL); if (color >= RGB_MODE) { DumpRVB (width, 66, buffer, NULL); } else { DumpNB (width, 66, buffer, NULL); } } computeCalibrationData (color, width, buffer, calibration); DBG (1, "shadingCalibration1220p() done ...\n"); return 1; } /* returns number of bytes read or 0 on failure */ int sanei_umax_pp_readBlock (long len, int window, int dpi, int last, unsigned char *buffer) { DBG (8, "readBlock(%ld,%d,%d,%d)\n", len, window, dpi, last); /* EPP block reading is available only when dpi >=600 */ if ((dpi >= 600) && (gMode != UMAX_PP_PARPORT_ECP) && (sanei_umax_pp_getastra () > 610)) { DBG (8, "cmdGetBlockBuffer(4,%ld,%d);\n", len, window); len = cmdGetBlockBuffer (4, len, window, buffer); if (len == 0) { DBG (0, "cmdGetBlockBuffer(4,%ld,%d) failed (%s:%d)\n", len, window, __FILE__, __LINE__); gCancel = 1; } } else { if ((sanei_umax_pp_getastra () < 1210) && (len > 0xFDCE)) { len = 0xFDCE; last = 0; } DBG (8, "cmdGetBuffer(4,%ld);\n", len); if (cmdGetBuffer (4, len, buffer) != 1) { DBG (0, "cmdGetBuffer(4,%ld) failed (%s:%d)\n", len, __FILE__, __LINE__); gCancel = 1; } } if (!last) { /* sync with scanner */ if (sanei_umax_pp_cmdSync (0xC2) == 0) { DBG (0, "Warning cmdSync(0xC2) failed! (%s:%d)\n", __FILE__, __LINE__); DBG (0, "Trying again ...\n"); if (sanei_umax_pp_cmdSync (0xC2) == 0) { DBG (0, " failed again! (%s:%d)\n", __FILE__, __LINE__); DBG (0, "Aborting ...\n"); gCancel = 1; } else DBG (0, " success ...\n"); } } return len; } int sanei_umax_pp_scan (int x, int y, int width, int height, int dpi, int color, int gain, int offset) { #ifdef HAVE_SYS_TIME_H struct timeval td, tf; float elapsed; #endif unsigned char *buffer; long int somme, len, read, blocksize; FILE *fout = NULL; int *dest = NULL; int bpl, hp; int th, tw, bpp; int nb; int bx, by, delta; int reserve, rc, remain, dataoffset; if (gain != 0 || offset != 0) sanei_umax_pp_setauto (0); /* colors don't come in sync, so we must increase y */ /* to have extra lines to reorder datas */ if (sanei_umax_pp_getastra () > 610) { switch (dpi) { case 1200: delta = 8; break; case 600: delta = 4; break; case 300: delta = 2; break; case 150: delta = 1; break; default: delta = 0; break; } } else { if (color >= RGB_MODE) { switch (dpi) { case 600: delta = 16; break; case 300: delta = 8; break; case 150: delta = 4; break; default: delta = 2; break; } } else delta = 0; } /* in color mode, we need extra lines to reorder data */ if (color >= RGB_MODE) { if (sanei_umax_pp_getastra () <= 610) dataoffset = 4 * delta; else dataoffset = 2 * delta; } else dataoffset = 0; rc = sanei_umax_pp_startScan (x, y - dataoffset, width, height + dataoffset, dpi, color, gain, offset, &bpp, &tw, &th); if (rc == 1) { /* blocksize must be multiple of the number of bytes per line */ /* max is 2096100 */ /* so blocksize will hold a round number of lines, easing the */ /* write data to file operation */ bpl = bpp * tw; hp = 2096100 / bpl; blocksize = hp * bpl; nb = 0; somme = bpl * th; DBG (8, "Getting buffer %d*%d*%d=%ld=0x%lX (%s:%d) \n", bpp, tw, th, somme, somme, __FILE__, __LINE__); /* correct th to be usable scan height */ th -= dataoffset; /* we need a 2 * delta lines reserve to reorder data */ if (color >= RGB_MODE) { reserve = 2 * delta * bpl; if (sanei_umax_pp_getastra () < 1210) dataoffset = reserve; else dataoffset = 0; } else { reserve = 0; dataoffset = 0; } /* get scanned data */ /* allocate memory */ buffer = (unsigned char *) malloc (blocksize + reserve); if (buffer == NULL) { DBG (0, "Failed to allocate %ld bytes, giving up....\n", blocksize + reserve); DBG (0, "Try to scan at lower resolution, or a smaller area.\n"); gCancel = 1; } /* open output file */ fout = fopen ("out.pnm", "wb"); if (fout == NULL) { DBG (0, "Failed to open 'out.pnm', giving up....\n"); gCancel = 1; } else { /* write pnm header */ if (color >= RGB_MODE) fprintf (fout, "P6\n%d %d\n255\n", tw, th - 2 * delta); else fprintf (fout, "P5\n%d %d\n255\n", tw, th); } /* read some line first until we got clean data */ read = 0; remain = 0; while (read < dataoffset) { if (read == 0) len = dataoffset; else len = dataoffset - read; len = sanei_umax_pp_readBlock (len, tw, dpi, 0, buffer + read); if (len == 0) { DBG (0, "sanei_umax_pp_readBlock failed, cancelling scan ...\n"); gCancel = 1; } read += len; } /* in color mode we have to fill the 'reserve' area * so that we can reorder data lines */ while ((read - dataoffset < reserve) && (!gCancel)) { len = reserve - read + dataoffset; len = sanei_umax_pp_readBlock (len, tw, dpi, 0, buffer + read - dataoffset); if (len == 0) { DBG (0, "sanei_umax_pp_readBlock failed, cancelling scan ...\n"); gCancel = 1; } read += len; } /* data reading loop */ #ifdef HAVE_SYS_TIME_H gettimeofday (&td, NULL); #endif while ((read < somme) && (!gCancel)) { /* 2096100 max */ if (somme - read > blocksize - remain) len = blocksize - remain; else len = somme - read; len = sanei_umax_pp_readBlock (len, tw, dpi, (len < blocksize), buffer + reserve + remain); if (len == 0) { DBG (0, "sanei_umax_pp_readBlock failed, cancelling scan ...\n"); gCancel = 1; } read += len; nb++; DBG (8, "Read %ld bytes out of %ld ...\n", read, somme); DBG (8, "Read %d blocks ... \n", nb); /* write partial buffer to file */ if (len) { if (color >= RGB_MODE) { /* using an image format that doesn't need */ /* reordering would speed up write operation */ /* don't forget remaining bytes from previous block */ hp = (len + remain) / bpl; remain = (len + remain) - hp * bpl; switch (sanei_umax_pp_getastra ()) { case 610: /* first comes RED * then BLUE * and finally GREEN */ for (by = 0; by < hp; by++) { for (bx = 0; bx < tw; bx++) { /* scanner data: red line, blue line then green line */ /* red */ fputc (buffer [3 * (by - 2 * delta) * tw + bx + reserve], fout); /* green */ fputc (buffer [3 * by * tw + 2 * tw + bx + reserve], fout); /* blue */ fputc (buffer [3 * (by - delta) * tw + tw + bx + reserve], fout); } } /* copy tail lines for next block */ /* memcpy (buffer, * (buffer + reserve) + (hp * bpl - reserve), * reserve + remain); */ memcpy (buffer, buffer + hp * bpl, reserve + remain); break; case 1600: for (by = 0; by < hp; by++) { for (bx = 0; bx < tw; bx++) { fputc (buffer[3 * by * tw + 2 * tw + bx], fout); fputc (buffer[3 * by * tw + bx], fout); fputc (buffer[3 * by * tw + tw + bx], fout); } } break; default: for (by = 0; by < hp; by++) { for (bx = 0; bx < tw; bx++) { fputc (buffer[3 * by * tw + 2 * tw + bx], fout); fputc (buffer[3 * by * tw + tw + bx], fout); fputc (buffer[3 * by * tw + bx], fout); } } /* put remaining partial lines at start of buffer */ memcpy (buffer, buffer + hp * bpl, remain); break; } } else fwrite (buffer, len, 1, fout); } } #ifdef HAVE_SYS_TIME_H gettimeofday (&tf, NULL); /* scan time are high enough to forget about usec */ elapsed = tf.tv_sec - td.tv_sec; DBG (8, "%ld bytes transferred in %f seconds ( %.2f Kb/s)\n", somme, elapsed, (somme / elapsed) / 1024.0); #endif /* release ressources */ if (fout != NULL) fclose (fout); free (dest); free (buffer); } /* if start scan OK */ else { DBG (0, "startScan failed..... \n"); } /* terminate any pending command */ if (sanei_umax_pp_cmdSync (0x00) == 0) { DBG (0, "Warning cmdSync(0x00) failed! (%s:%d)\n", __FILE__, __LINE__); DBG (0, "Trying again ... "); if (sanei_umax_pp_cmdSync (0x00) == 0) { DBG (0, " failed again! (%s:%d)\n", __FILE__, __LINE__); DBG (0, "Blindly going on ...\n"); } else DBG (0, " success ...\n"); } /* parking */ if (sanei_umax_pp_park () == 0) DBG (0, "Park failed !!! (%s:%d)\n", __FILE__, __LINE__); /* end ... */ DBG (16, "Scan done ...\n"); return 1; } /* * returns 0 on error, 1 on success: ie head parked */ int sanei_umax_pp_parkWait (void) { int status; /* check if head is at home */ DBG (16, "entering parkWait ...\n"); do { usleep (1000); CMDSYNC (0x40); status = sanei_umax_pp_scannerStatus (); } while ((status & MOTOR_BIT) == 0x00); DBG (16, "parkWait done ...\n"); return 1; } /* starts scan: return 1 on success */ int sanei_umax_pp_startScan (int x, int y, int width, int height, int dpi, int color, int gain, int offset, int *rbpp, int *rtw, int *rth) { unsigned char *buffer; int rc = 0; int calibration[3 * 5100 + 768 + 2 + 1]; int xdpi, ydpi, h; int th, tw, bpp; int hwdpi = 600; /* CCD hardware dpi */ /* DC offsets */ int dcRed, dcGreen, dcBlue; int vgaRed, vgaGreen, vgaBlue; int len, delta; int lm9811[9] = { 0x06, 0xF4, 0xFF, 0x81, 0x1B, 0x00, 0x00, 0x00, -1 }; int motor[17] = { 0xA4, 0x80, 0x07, 0x50, 0xEC, 0x03, 0x00, 0x2F, 0x17, 0x07, 0x84, 0x08, 0x90, 0x00, 0xAC, 0x00, -1 }; int ccd[37] = { 0x00, 0x00, 0xB0, 0x4F, 0xD8, 0xE7, 0xFA, 0x10, 0xEF, 0xC4, 0x3C, 0x71, 0x0F, 0x00, 0x04, 0x00, 0x6E, 0x61, 0xA1, 0x24, 0xC4, 0x7E, 0x00, 0xAE, 0x41, 0xA0, 0x0A, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x33, 0x1A, 0x00, -1 }; #ifdef UMAX_PP_DANGEROUS_EXPERIMENT FILE *f = NULL; char line[1024], *ptr; int *base = NULL; int channel; int max = 0; #endif if (sanei_umax_pp_getastra () == 610) { hwdpi = 300; len = 0x22; lm9811[0] = 0x88; lm9811[1] = 0xE6; lm9811[2] = 0xFD; lm9811[3] = 0x8E; lm9811[4] = 0x30; lm9811[5] = 0x00; lm9811[6] = 0x8F; lm9811[7] = 0x80; motor[3] = 0x30; motor[4] = 0x0E; motor[5] = 0x02; motor[12] = 0xAA; ccd[0] = 0x00; ccd[1] = 0x00; ccd[2] = 0xD8; ccd[3] = 0x27; ccd[4] = 0xEC; ccd[5] = 0x53; ccd[6] = 0x7D; ccd[7] = 0x8A; ccd[8] = 0x77; ccd[9] = 0xE2; ccd[10] = 0x9E; ccd[11] = 0xF8; ccd[12] = 0x07; ccd[13] = 0x20; ccd[14] = 0x02; ccd[15] = 0x00; ccd[16] = 0x76; ccd[17] = 0x5D; ccd[18] = 0xE0; ccd[19] = 0x13; ccd[20] = 0xE2; ccd[21] = 0x20; ccd[22] = 0x00; ccd[23] = 0xA8; ccd[24] = 0x41; ccd[25] = 0xA0; ccd[26] = 0x0A; ccd[27] = 0x8B; ccd[28] = 0x4D; ccd[29] = 0x4B; ccd[30] = 0xD0; ccd[31] = 0x68; ccd[32] = 0xDF; ccd[33] = 0x13; } else { len = 0x24; hwdpi = 600; } DBG (8, "startScan(%d,%d,%d,%d,%d,%d,%X);\n", x, y, width, height, dpi, color, gain); buffer = (unsigned char *) malloc (2096100); if (buffer == NULL) { DBG (0, "Failed to allocate 2096100 bytes... (%s:%d)\n", __FILE__, __LINE__); return 0; } /* 1600P have a different CCD command block */ if (sanei_umax_pp_getastra () == 1600) { lm9811[0] = 0x19; lm9811[1] = 0xD5; lm9811[4] = 0x1B; lm9811[7] = 0x70; ccd[29] = 0x1A; ccd[30] = 0xEE; motor[13] = 0x03; /* may be blur filter */ } /* matches intTransport610P */ /* get scanner status */ rc = inquire (); if (rc == 0) { DBG (0, "inquire() failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (16, "inquire() passed ... (%s:%d)\n", __FILE__, __LINE__); rc = loadDefaultTables (); if (rc == 0) { DBG (0, "loadDefaultTables() failed ! (%s:%d) \n", __FILE__, __LINE__); return 0; } DBG (16, "loadDefaultTables() passed ... (%s:%d)\n", __FILE__, __LINE__); /* find and move to zero */ if (moveToOrigin () == 0) { DBG (0, "moveToOrigin() failed ... (%s:%d)\n", __FILE__, __LINE__); } else { DBG (16, "moveToOrigin() passed ... (%s:%d)\n", __FILE__, __LINE__); } /* 1600P have a different CCD command block */ if (sanei_umax_pp_getastra () == 1600) { lm9811[0] = 0x19; lm9811[1] = 0xD5; lm9811[4] = 0x1B; lm9811[7] = 0x70; ccd[29] = 0x1A; ccd[30] = 0xEE; motor[13] = 0x03; /* may be blur filter */ } /* XXX STEF XXX : done even is manual settings, some day skip it * and move head the right amount */ if (offsetCalibration (color, &dcRed, &dcGreen, &dcBlue) == 0) { DBG (0, "offsetCalibration failed !!! (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "offsetCalibration(%d=>%d,%d,%d) passed ... (%s:%d)\n", color, dcRed, dcGreen, dcBlue, __FILE__, __LINE__); if (coarseGainCalibration (color, dcRed, dcGreen, dcBlue, &vgaRed, &vgaGreen, &vgaBlue) == 0) { DBG (0, "coarseGainCalibration failed !!! (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "coarseGainCalibration(%d,%d,%d,%d=>%d,%d,%d) passed ... (%s:%d)\n", color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue, __FILE__, __LINE__); /* manual setting overrides evaluated values */ if (!sanei_umax_pp_getauto ()) { dcRed = (offset & 0xF00) >> 8; dcGreen = (offset & 0x0F0) >> 4; dcBlue = offset & 0x00F; vgaRed = (gain & 0xF00) >> 8; vgaGreen = (gain & 0x0F0) >> 4; vgaBlue = gain & 0x00F; } /* ccd calibration is allways done */ /* with final dc and vga */ if (shadingCalibration (color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue, calibration) == 0) { DBG (0, "shadingCalibration failed !!! (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "shadingCalibration(%d,%d,%d,%d,%d,%d,%d) passed ... (%s:%d)\n", color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue, __FILE__, __LINE__); /* gamma or left shading calibration ? */ if (sanei_umax_pp_getastra () <= 610) { if (leftShadingCalibration610p (color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue, calibration) == 0) { DBG (0, "leftShadingCalibration610p failed !!! (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "leftShadingCalibration610p(%d,%d,%d,%d,%d,%d,%d) passed ... (%s:%d)\n", color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue, __FILE__, __LINE__); } /* 1220P: x dpi is from 75 to 600 max, any modes */ /* 610P: x dpi is from 75 to 300 max, any modes */ if (dpi > hwdpi) xdpi = hwdpi; else xdpi = dpi; /* EPPRead32Buffer does not work */ /* with length not multiple of four bytes, so we enlarge */ /* width to meet this criteria ... */ if ((getEPPMode () == 32) && (xdpi >= 600) && (width & 0x03) && (sanei_umax_pp_getastra () > 610)) { width += (4 - (width & 0x03)); /* in case we go too far on the right */ if (x + width > 5100) { x = 5100 - width; } } /* compute target size */ th = (height * dpi) / hwdpi; tw = (width * xdpi) / hwdpi; /* corrects y to match exact scan area start * and lets room for a leading zone so that * we can reorder data */ switch (sanei_umax_pp_getastra ()) { case 610: if (color >= RGB_MODE) switch (dpi) { case 600: y += 64; break; case 300: y += 32; break; case 150: y += 16; break; case 75: y += 8; break; } else y += 80; // fall through default: y += 8; break; } /* for 1220P/2000P move fast to scan target if possible */ /* it is faster to move at low resolution, then scan */ /* than scan & move at high resolution */ if ((sanei_umax_pp_getastra () > 610 && (dpi > 300)) && (y > 100)) { /* move at 150 dpi resolution */ move (y / 2, PRECISION_OFF, NULL); /* keep the remainder for scan */ y = y % 4; } /* build final scan command */ /* round width and height */ width = (tw * hwdpi) / xdpi; height = (th * hwdpi) / dpi; ydpi = dpi; if (ydpi < 300) { if ((color >= RGB_MODE) && (sanei_umax_pp_getastra () > 610)) { if (dpi < 150) ydpi = 150; } else ydpi = 300; } if ((color < RGB_MODE) && (sanei_umax_pp_getastra () <= 610)) ydpi = 600; /* at maximum resolution */ if (color >= RGB_MODE) { h = ((height * ydpi) / hwdpi) + 8; bpp = 3; } else { h = ((height * ydpi) / hwdpi) + 4; if (sanei_umax_pp_getastra () <= 610) h += 16; bpp = 1; } /* sets y resolution */ switch (ydpi) { case 1200: motor[6] = 0x60; motor[8] = 0x5E; /* *WORKING* value */ motor[8] = 0x5F; /* 5F gives wrong colors ? */ motor[8] = 0x58; motor[9] = 0x05; /* XXX test value XXX motor[14] = motor[14] & 0xF0; ~ 0x08 -> scan AND move */ /* XXX test value XXX motor[14] = (motor[14] & 0xF0) | 0x04; -> 600 dpi ? */ /* XXX test value XXX motor[14] = (motor[14] & 0xF0) | 0x0C; */ motor[14] = motor[14] & 0xF0; /* *WORKING* 1200 dpi */ break; case 600: if (sanei_umax_pp_getastra () <= 610) { motor[6] = 0xC0; motor[7] = 0x2F; motor[14] = motor[14] & 0xF0; /* if (color >= RGB_MODE) motor[14] |= 0x04; XXX STEF XXX */ } else { motor[6] = 0x60; motor[14] = (motor[14] & 0xF0) | 0x04; } motor[8] = 0x2F; motor[9] = 0x05; break; case 300: if (sanei_umax_pp_getastra () <= 610) { motor[6] = 0xC0; motor[14] = motor[14] & 0xF0; if (color >= RGB_MODE) motor[14] |= 0x04; } else { motor[6] = 0x00; motor[14] = (motor[14] & 0xF0) | 0x0C; } motor[8] = 0x17; motor[9] = 0x05; /* si | 0C h=2*w, si | 04 h=w ? */ break; case 150: if (sanei_umax_pp_getastra () <= 610) { motor[6] = 0xC0; motor[9] = 0x05; motor[14] = motor[14] & 0xF0; if (color >= RGB_MODE) motor[14] |= 0x04; } else { motor[6] = 0x00; motor[9] = 0x07; motor[14] = (motor[14] & 0xF0) | 0x0C; } motor[8] = 0x17; break; } /* different values for 610P in B&W */ if ((sanei_umax_pp_getastra () <= 610) && (color < RGB_MODE)) { motor[7] = 0xC8; motor[8] = 0x2F; motor[9] = 0x05; } /* y start -1 */ y = (y * ydpi) / hwdpi; if (color >= RGB_MODE) { /* 00 seems to give better results ? */ /* 80 some more gain, lamp power level ? */ /* 8x does not make much difference */ lm9811[6] = 0x8F; switch (sanei_umax_pp_getastra ()) { case 610: lm9811[7] = 0x80; motor[13] = 0x20; break; case 1600: lm9811[7] = 0x70; motor[13] = 0x03; break; default: lm9811[7] = 0xF0; motor[13] = 0x09; } } else { motor[13] = 0xC0; lm9811[6] = 0x80 | vgaGreen; switch (sanei_umax_pp_getastra ()) { case 610: lm9811[7] = 0xA0; lm9811[6] = lm9811[6] | 0x40; motor[13] = 0x6F; break; case 1600: lm9811[7] = 0x20; motor[13] = 0xC3; break; default: lm9811[7] = 0xA0; motor[13] = 0xC9; } } encodeCoefficient (color, dpi, calibration); encodeWX (width, x, dpi, color, ccd, 0); encodeHY (h, y, motor); encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (vgaRed, vgaGreen, vgaBlue, motor); #ifdef UMAX_PP_DANGEROUS_EXPERIMENT /*motor[13] = 0x80; B&W bit */ /*motor[13] = 0x40; green bit */ /*motor[13] = 0x20; red bit */ /*motor[13] = 0x10; blue bit */ /* with cmd 01, may be use to do 3 pass scanning ? */ /* bits 0 to 3 seem related to sharpness */ f = fopen ("/tmp/dangerous.params", "rb"); if (f != NULL) { fgets (line, 1024, f); while (!feof (f)) { channel = 0; if (sscanf (line, "CMD%1d", &channel) != 1) channel = 0; switch (channel) { case 0: break; case 1: base = lm9811; max = 8; break; case 2: base = motor; max = 16; break; case 8: base = ccd; max = 36; break; default: channel = 0; } printf ("CMD%d BEFORE: ", channel); for (i = 0; i < max; i++) printf ("%02X ", base[i]); printf ("\n"); if (channel > 0) { ptr = line + 6; for (i = 0; (i < max) && ((ptr - line) < strlen (line)); i++) { if (ptr[0] != '-') { sscanf (ptr, "%X", base + i); } ptr += 3; } } printf ("CMD%d AFTER : ", channel); for (i = 0; i < max; i++) printf ("%02X ", base[i]); printf ("\n"); fgets (line, 1024, f); } fclose (f); } #endif if (DBG_LEVEL >= 64) { bloc2Decode (motor); bloc8Decode (ccd); } CMDSYNC (0x00); CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); /* 3 ccd lines + 3 gamma tables + end tag */ if (sanei_umax_pp_getastra () <= 610) { /* XXX STEF XXX : there is a 4 pixels shift to the right * the first shading correction value applies to the forth * pixel of scan (at 300 dpi), we allready shift to the left * when doing shadingCalibration, but now we have to move coeffs * to match x coordinate */ delta = x - sanei_umax_pp_getLeft (); if (delta) { memcpy (calibration, calibration + delta, (7650 - delta) * sizeof (int)); } CMDSET (4, 0x20E4, calibration); } else { CMDSET (4, 0x3EC6, calibration); } COMPLETIONWAIT; *rbpp = bpp; *rtw = tw; *rth = th; free (buffer); return 1; } /* * check the scanner model. Return 1220 for * a 1220P, or 2000 for a 2000P. * and 610 for a 610p * values less than 610 are errors */ int sanei_umax_pp_checkModel (void) { int *dest = NULL; int state[16]; int err = 0; int i; int opsc35[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x00, 0x00, 0x04, 0x00, 0x16, 0x41, 0xE0, 0xAC, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; /* if we have already detected a scanner different from */ /* default type, no need to check again */ if (sanei_umax_pp_getastra ()) return sanei_umax_pp_getastra (); /* get scanner status */ CMDGET (0x02, 16, state); CMDSETGET (0x08, 36, opsc35); CMDSYNC (0xC2); dest = (int *) malloc (65536 * sizeof (int)); if (dest == NULL) { DBG (0, "%s:%d failed to allocate 256 Ko !\n", __FILE__, __LINE__); return 0; } /* init some buffer : default calibration data ? */ dest[0] = 0x00; dest[1] = 0x00; dest[2] = 0x00; for (i = 0; i < 768; i++) dest[i + 3] = i % 256; dest[768 + 3] = 0xAA; dest[768 + 4] = 0xAA; dest[768 + 5] = -1; CMDSETGET (0x04, 768 + 5, dest); /* check buffer returned */ for (i = 0; i < 768; i++) { if (dest[i + 3] != (i % 256)) { DBG (0, "Error data altered: byte %d=0x%02X, should be 0x%02X ! (%s:%d)\n", i, dest[i + 3], i % 256, __FILE__, __LINE__); err = 1; } } if (err) return 0; /* new part of buffer ... */ for (i = 0; i < 256; i++) { dest[i * 2] = i; dest[i * 2 + 1] = 0x00; } CMDSETGET (0x08, 36, opsc35); CMDSYNC (0xC2); CMDSET (0x04, 512, dest); /* another new part ... */ for (i = 0; i < 256; i++) { dest[i * 2] = i; dest[i * 2 + 1] = 0x04; /* instead of 0x00 */ } opsc35[2] = 0x06; /* instead of 0x04, write flag ? */ CMDSETGET (0x08, 36, opsc35); CMDSYNC (0xC2); CMDSET (0x04, 512, dest); opsc35[2] = 0x04; /* return to initial value, read flag? */ CMDSETGET (0x08, 36, opsc35); CMDGET (0x04, 512, dest); /* check buffer returned */ /* if 0x4 are still 0x04, we got a 1220P, else it is a 2000P */ for (i = 0; i < 256; i++) { if ((dest[2 * i] != i) || ((dest[2 * i + 1] != 0x04) && (dest[2 * i + 1] != 0x00))) { DBG (0, "Error data altered: expected %d=(0x%02X,0x04), found (0x%02X,0x%02X) ! (%s:%d)\n", i, i, dest[i * 2], dest[i * 2 + 1], __FILE__, __LINE__); err = 0; } } /* if buffer unchanged, we have a 1600P, or a 1220P */ /* if data has turned into 0, we have a 2000P */ if (dest[1] == 0x00) { sanei_umax_pp_setastra (2000); err = 2000; } else { /* detects 1600 by finding black scans */ /* we defaults to 1220 */ sanei_umax_pp_setastra (1220); moveToOrigin (); err = sanei_umax_pp_getastra (); /* parking */ CMDSYNC (0xC2); CMDSYNC (0x00); if (sanei_umax_pp_park () == 0) DBG (0, "Park failed !!! (%s:%d)\n", __FILE__, __LINE__); /* poll parking */ do { sleep (1); CMDSYNC (0x40); } while ((sanei_umax_pp_scannerStatus () & MOTOR_BIT) == 0x00); } /* return guessed model number */ CMDSYNC (0x00); return err; } /* sets, resets gamma tables */ void sanei_umax_pp_gamma (int *red, int *green, int *blue) { if (red != NULL) { ggRed = red; } else { ggRed = ggamma; } if (green != NULL) { ggGreen = green; } else { ggGreen = ggamma; } if (blue != NULL) { ggBlue = blue; } else { ggBlue = ggamma; } } /* initialize scanner by loading default transformation table */ /* O: failure * 1: OK */ int loadDefaultTables (void) { int cmd01[36] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x60, 0x20, 0x00, 0x00, 0x16, 0x41, 0xE0, 0xAC, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x13, -1 }; int opsc35[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x00, 0x00, 0x04, 0x00, 0x16, 0x41, 0xE0, 0xAC, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; int i, len, *cmd, err; int buffer[774]; int rc = 1; /* 1600P have a different CCD command block */ if (sanei_umax_pp_getastra () == 1600) { opsc35[29] = 0x1A; opsc35[30] = 0xEE; } if (sanei_umax_pp_getastra () <= 610) { len = 0x22; cmd = cmd01; /* XXX STEF XXX if we send F0, we get 0x10 back */ cmd[0x21] = 0x10; } else { len = 0x24; cmd = opsc35; } /* set and reread first table */ /* since 1660P seems to have another type of CCD * this table is not sent/needed */ err = 0; if (sanei_umax_pp_getastra () != 1600) { CMDSETGET (8, len, cmd); CMDSYNC (0xC2); buffer[0] = 0x00; buffer[1] = 0x00; buffer[2] = 0x00; for (i = 0; i < 768; i++) buffer[i + 3] = i % 256; if (sanei_umax_pp_getastra () <= 610) { buffer[768 + 3] = 0xFF; buffer[768 + 4] = 0xFF; } else { buffer[768 + 3] = 0xAA; buffer[768 + 4] = 0xAA; } buffer[768 + 5] = -1; CMDSETGET (4, 0x305, buffer); /* check buffer returned */ for (i = 0; i < 768; i++) { if (buffer[i + 3] != (i % 256)) { DBG (0, "Error data altered: byte %d=0x%02X, should be 0x%02X ! (%s:%d)\n", i, buffer[i + 3], i % 256, __FILE__, __LINE__); err = 1; } } if (err) return 0; } /* second table ... */ for (i = 0; i < 256; i++) { buffer[i * 2] = i; buffer[i * 2 + 1] = 0; } CMDSETGET (8, len, cmd); CMDSYNC (0xC2); CMDSET (4, 0x200, buffer); /* third table ... */ if (sanei_umax_pp_getastra () <= 610) { for (i = 0; i < 256; i++) { buffer[i * 2] = i; buffer[i * 2 + 1] = 0x01; /* instead of 0x00 */ } } else { for (i = 0; i < 256; i++) { buffer[i * 2] = i; buffer[i * 2 + 1] = 0x04; /* instead of 0x00 */ } } opsc35[2] = 0x06; cmd01[1] = 0x80; CMDSETGET (8, len, cmd); CMDSYNC (0xC2); CMDSET (4, 0x200, buffer); opsc35[2] = 0x04; cmd01[1] = 0x00; CMDSETGET (8, len, cmd); CMDGET (4, 0x200, buffer); /* check buffer returned */ /* if 0x4 are still 0x0 (hum..), we got a 1220P, else it is a 2000P */ for (i = 0; i < 256; i++) { if ((buffer[2 * i] != i) || ((buffer[2 * i + 1] != 0x04) && (buffer[2 * i + 1] != 0x01) && (buffer[2 * i + 1] != 0x00))) { DBG (0, "Error data altered: expected %d=(0x%02X,0x04), found (0x%02X,0x%02X) ! (%s:%d)\n", i, i, buffer[i * 2], buffer[i * 2 + 1], __FILE__, __LINE__); err = 1; } } if (err) return 0; return rc; } /* inquire scanner status * O: failure * 1: OK * 2: first scanner init, needs re-homing */ int inquire (void) { int cmd01[36] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x03, 0xC1, 0x80, 0x60, 0x20, 0x00, 0x00, 0x16, 0x41, 0xE0, 0xAC, 0x03, 0x03, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x1B, -1 }; int buffer[37]; int rc = 1, first, i; char str[106]; /* inquiry: ask for RAM, CCD, ... */ CMDSET (8, 0x23, cmd01); CMDGET (8, 0x23, buffer); if (DBG_LEVEL > 8) { for (i = 0; i < 35; i++) sprintf (str + 3 * i, "%02X ", buffer[i]); str[105] = 0x00; DBG (8, "SCANNER INFORMATION=%s\n", str); } /* get state */ CMDGET (2, 0x10, buffer); first = 1; for (i = 0; i < 14; i++) { if (buffer[i] != 0) first = 0; } if (buffer[15] != 0) first = 0; if (first) rc = 2; if (DBG_LEVEL > 8) { for (i = 0; i < 16; i++) sprintf (str + 3 * i, "%02X ", buffer[i]); str[48] = 0x00; DBG (8, "SCANNER STATE=%s\n", str); } return rc; } /* * computes DC offset to have black pixel really black out of * CCD ie black gives 0 * 1220P implements the method described in LM9811 datasheet * returns 1 and DC offsets in the corresponding vars on success . * On failure, returns 0. */ static int offsetCalibration1220p (int color, int *offRed, int *offGreen, int *offBlue) { unsigned char buffer[5300]; 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 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, 0x46, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; int opsc48[17] = { 0x09, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2F, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x40, 0xA4, 0x00, -1 }; float low, high; DBG (16, "entering offsetCalibration1220p() ... (%s:%d)\n", __FILE__, __LINE__); /* really dirty hack: somethig is buggy in BW mode */ /* we override mode with color until the bug is found */ /* color = RGB_MODE; */ /* 1600P have a different CCD command block */ if (sanei_umax_pp_getastra () == 1600) { opsc04[0] = 0x19; opsc04[1] = 0xD5; opsc04[4] = 0x1B; opsc04[7] = 0x20; opsc48[8] = 0x2B; opsc48[11] = 0x20; opsc48[12] = 0x08; opsc48[13] = 0x42; } /* offset calibration, scan 24 bytes of black in each color */ /* component see section 5.1 of LM9811 datasheet */ if (color >= RGB_MODE) { CMDSETGET (2, 0x10, opsc48); CMDSETGET (8, 0x24, opsc38); CMDSETGET (1, 0x08, opsc04); /* scan std, no 'enhancing' */ CMDSYNC (0xC2); if (sanei_umax_pp_scannerStatus () & 0x80) { CMDSYNC (0x00); } CMDSETGET (4, 0x08, commit); /* commit ? */ COMPLETIONWAIT; CMDGETBUF (4, 0x18, buffer); if (DBG_LEVEL >= 128) Dump (0x18, buffer, NULL); val = 0; for (i = 0; i < 24; i++) val += buffer[i]; low = (float) val / i; /* Vadc1 */ CMDSYNC (0x00); opsc04[7] = opsc04[7] | 0x10; /* enhanced ? */ CMDSETGET (1, 0x08, opsc04); COMPLETIONWAIT; CMDGETBUF (4, 0x18, buffer); val = 0; for (i = 0; i < 24; i++) val += buffer[i]; high = (float) val / i; /* Vadc2 */ if (DBG_LEVEL >= 128) Dump (0x18, buffer, NULL); *offRed = 15.0 - ((high - low) * 2); /* block that repeats */ /* must be monochrome since hscan=1 */ opsc48[0] = 0x01; if (sanei_umax_pp_getastra () == 1600) { opsc48[12] = 0x0C; opsc48[13] = 0x82; } else { opsc48[12] = 0x04; opsc48[13] = 0x80; } CMDSETGET (2, 0x10, opsc48); CMDSETGET (8, 0x24, opsc38); opsc04[7] = opsc04[7] & 0x20; CMDSETGET (1, 0x08, opsc04); CMDSYNC (0xC2); if (sanei_umax_pp_scannerStatus () & 0x80) { CMDSYNC (0x00); } CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, 0x18, buffer); if (DBG_LEVEL >= 128) Dump (0x18, buffer, NULL); val = 0; for (i = 0; i < 24; i++) val += buffer[i]; low = (float) val / i; CMDSYNC (0x00); opsc04[7] = opsc04[7] | 0x10; /* gain ? */ CMDSETGET (1, 0x08, opsc04); COMPLETIONWAIT; CMDGETBUF (4, 0x18, buffer); if (DBG_LEVEL >= 128) Dump (0x18, buffer, NULL); val = 0; for (i = 0; i < 24; i++) val += buffer[i]; high = (float) val / i; *offBlue = 15.0 - ((high - low) * 2); } /* block that repeats */ if (color < RGB_MODE) { opsc48[0] = 0x05; /* B&H height is 5 */ opsc48[13] = 0xC0; /* B&W mode */ } else { opsc48[0] = 0x05; /* color height is 5 (+4 ?) */ opsc48[13] = 0xC1; /* some strange mode ? */ } if (sanei_umax_pp_getastra () == 1600) opsc48[13] = opsc48[13] | 0x02; CMDSETGET (2, 0x10, opsc48); CMDSETGET (8, 0x24, opsc38); opsc04[7] = opsc04[7] & 0x20; CMDSETGET (1, 0x08, opsc04); CMDSYNC (0xC2); if (sanei_umax_pp_scannerStatus () & 0x80) { CMDSYNC (0x00); } CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, 0x18, buffer); if (DBG_LEVEL >= 128) Dump (0x18, buffer, NULL); val = 0; for (i = 0; i < 24; i++) val += buffer[i]; low = (float) val / i; CMDSYNC (0x00); opsc04[7] = opsc04[7] | 0x10; CMDSETGET (1, 0x08, opsc04); COMPLETIONWAIT; CMDGETBUF (4, 0x18, buffer); if (DBG_LEVEL >= 128) Dump (0x18, buffer, NULL); val = 0; for (i = 0; i < 24; i++) val += buffer[i]; high = (float) val / i; *offGreen = 15.0 - ((high - low) * 2); /*DBG (1, "STEF: offsets(RED,GREEN,BLUE=(%d,%d,%d)\n", *offRed, *offGreen, *offBlue);*/ DBG (16, "offsetCalibration1220p() done ...\n"); return 1; } /* * computes DC offset to have black pixel really black out of * CCD ie black gives 0 * 610P doesn't implement method described in LM9811 datasheet * but scan a black line with decreasing offsets until the * scanned data reach a 'good black level'. * returns 1 and DC offsets in the corresponding vars on success . * On failure, returns 0. */ static int offsetCalibration610p (int color, int *offRed, int *offGreen, int *offBlue) { int motor[17] = { 0x11, 0x00, 0x00, 0x70, 0x00, 0x00, 0xC0, 0x2F, 0x17, 0x00, 0x00, 0xF0, 0x7D, 0x5F, 0xA4, 0x00, -1 }; int ccd[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x20, 0x02, 0x00, 0x76, 0x12, 0xB0, 0x03, 0x06, 0x00, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x4D, 0x4B, 0xD0, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; int lm9811[9] = { 0x88, 0xE6, 0xFD, 0x8E, 0x30, 0x00, 0x40, 0xF0, -1 }; int commit[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, -1 }; int offset; int level; unsigned char data[40]; int i; int len; int w; DBG (16, "entering offsetCalibration610P() ... (%s:%d)\n", __FILE__, __LINE__); if (sanei_umax_pp_getastra () < 1220) { len = 0x22; w = 40; } else { len = 0x24; w = 40; } *offRed = 0; *offGreen = 0; *offBlue = 0; /* first color channel: used both in color and b&w modes */ /* offset to the max */ /* supposed to be green componant */ offset = 0x10; do { offset--; /* 7D: 0111 1101 */ /* sets for the current offset */ motor[12] = (offset << 2) | 0x40 | 0x01; lm9811[7] = offset << 4; /* sends commands */ CMDSYNC (0x00); CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, w, data); if (DBG_LEVEL > 128) { DumpNB (w, 1, data, NULL); } level = 0; for (i = 0; i < w; i++) level += data[i]; } /* loop while average >0.5 */ while ((offset > 0) && ((level * 2) / w > 1)); *offGreen = offset; /* offset calibration for the two other channels when in color */ if (color >= RGB_MODE) { motor[0] = 0x01; offset = 0x10; do { offset--; /* sets for the current offset */ motor[13] = 0x90 | offset; lm9811[7] = offset << 4; /* sends commands */ CMDSYNC (0x00); CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, w, data); if (DBG_LEVEL > 128) { DumpNB (w, 1, data, NULL); } level = 0; for (i = 0; i < w; i++) level += data[i]; } /* loop while average >0.5 */ while ((offset > 0) && ((level * 2) / w > 1)); *offBlue = offset; /* last color component */ motor[0] = 0x09; ccd[13] = 0xD0 | (ccd[13] & 0x0F); offset = 0x10; do { offset--; /* sets for the current offset */ motor[11] = offset << 4; lm9811[7] = offset << 4; /* sends commands */ CMDSYNC (0x00); CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, w, data); if (gMode == UMAX_PP_PARPORT_EPP) { CMDSYNC (0x00); } if (DBG_LEVEL > 128) { DumpNB (w, 1, data, NULL); } level = 0; for (i = 0; i < w; i++) level += data[i]; } /* loop while average >0.5 */ while ((offset > 0) && ((level * 2) / w > 1)); *offRed = offset; } else { *offRed = 0x0F; *offBlue = 0x0F; } return 1; } /* * generic offset calibration function */ static int offsetCalibration (int color, int *dcRed, int *dcGreen, int *dcBlue) { if (sanei_umax_pp_getastra () <= 610) { if (offsetCalibration610p (color, dcRed, dcGreen, dcBlue) == 0) { DBG (0, "offsetCalibration610p failed !!! (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "offsetCalibration610p(%d=>%d,%d,%d) passed ... (%s:%d)\n", color, *dcRed, *dcGreen, *dcBlue, __FILE__, __LINE__); } else { if (offsetCalibration1220p (color, dcRed, dcGreen, dcBlue) == 0) { DBG (0, "offsetCalibration1220p failed !!! (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "offsetCalibration1220p(%d=>%d,%d,%d) passed ... (%s:%d)\n", color, *dcRed, *dcGreen, *dcBlue, __FILE__, __LINE__); } return 1; } /* * computes Video Gain Amplifier : LM9811 can corrects up to 3dB of * light variation. So we must adjust VGA so that dynamic range is * within 3db. It is achieved when min white pixel >= max white pixel / 2.8 * So we scan a white area and decrease gain until this condition is met. * returns 1 and VGA values in the corresponding vars on success . * On failure, returns 0. */ static int coarseGainCalibration610p (int color, int dcRed, int dcGreen, int dcBlue, int *vgaRed, int *vgaGreen, int *vgaBlue) { int motor[17] = { 0x11, 0x00, 0x00, 0x70, 0x00, 0x00, 0xC0, 0x2F, 0x17, 0x00, 0xFF, 0xAF, 0xAA, 0x6A, 0xA4, 0x00, -1 }; int ccd[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x20, 0x02, 0x00, 0x76, 0x41, 0xE0, 0xAC, 0x06, 0x00, 0x00, 0x9C, 0x4A, 0xA0, 0x00, 0x8B, 0x4D, 0x4B, 0xD0, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; /* * lm9811[7]= VGA << 4 * lm9811[6]= 0x40 | DC offset */ int lm9811[9] = { 0x88, 0xE6, 0xFD, 0x8E, 0x30, 0x00, 0x40, 0xF0, -1 }; int commit[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, -1 }; unsigned char data[5400]; int i, len; int w, xstart, xend; int min, max; TRACE (16, "entering coarseGainCalibration610p ...\n"); if (sanei_umax_pp_getastra () < 1220) { w = 2700; len = 0x22; } else { w = 5400; len = 0x24; } /* move back to desired area */ MOVE (-69, PRECISION_OFF, NULL); /* first scan : taking a reference full width scan to * find usable full width of the CCD */ *vgaRed = 0x08; *vgaGreen = 0x00; *vgaBlue = 0x00; /* scanning red component -> h=1 */ motor[0] = 0x01; motor[13] = 0xAA; /* will be 6A below */ encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (*vgaRed, *vgaGreen, *vgaBlue, motor); lm9811[7] = dcRed << 4; lm9811[6] = 0x40 | *vgaRed; CMDSYNC (0x00); CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, w, data); if (gMode == UMAX_PP_PARPORT_EPP) { CMDSYNC (0x00); } if (DBG_LEVEL > 128) { DumpNB (w, 1, data, NULL); } /* find usable CCD area */ i = 0; while ((i < w) && (data[i] <= (targetCode * 2) / 5)) i++; xstart = i; i = w - 1; while ((i > 0) && (data[i] <= (targetCode * 2) / 5)) i--; xend = i; DBG (32, "coarseGainCalibration610p: xstart=%d, xend=%d ->left=%d\n", xstart, xend, ((xend + xstart - w) / 2)); /* choose best 'left' position */ sanei_umax_pp_setLeft ((xend + xstart - w) / 2); /* now do VGA calibration for green (=B&W channel) */ motor[0] = 0x11; motor[13] = 0x60 | (motor[13] & 0x0F); *vgaRed = 0x0F; *vgaGreen = 0x0F; *vgaBlue = 0x0F; for (*vgaGreen = 0x0F; *vgaGreen > 0; (*vgaGreen)--) { encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (*vgaRed, *vgaGreen, *vgaBlue, motor); lm9811[7] = dcGreen << 4; lm9811[6] = 0x40 | *vgaGreen; CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, w, data); if (gMode == UMAX_PP_PARPORT_EPP) { CMDSYNC (0x00); } if (DBG_LEVEL > 128) { DumpNB (w, 1, data, NULL); } min = 0xFF; max = 0x00; for (i = xstart; i <= xend; i++) { if (data[i] < min) min = data[i]; if (data[i] > max) max = data[i]; } if ((max <= targetCode) && (min > (((float) targetCode) / 2.8))) break; DBG (32, "coarseGainCalibration610p, target/2.8=%f\n", (((float) targetCode) / 2.8)); DBG (32, "coarseGainCalibration610p, green: min=%d, max=%d\n", min, max); } if (color >= RGB_MODE) { motor[0] = 0x01; motor[13] = 0xA0 | (motor[13] & 0x0F); for (*vgaBlue = 0x0F; *vgaBlue > 0; (*vgaBlue)--) { encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (*vgaRed, *vgaGreen, *vgaBlue, motor); lm9811[7] = dcBlue << 4; lm9811[6] = 0x40 | *vgaBlue; CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, w, data); if (gMode == UMAX_PP_PARPORT_EPP) { CMDSYNC (0x00); } if (DBG_LEVEL > 128) { DumpNB (w, 1, data, NULL); } min = 0xFF; max = 0x00; for (i = xstart; i <= xend; i++) { if (data[i] < min) min = data[i]; if (data[i] > max) max = data[i]; } if ((max <= targetCode) && (min > (((float) targetCode) / 2.8))) break; DBG (32, "coarseGainCalibration610p, blue: min=%d, max=%d\n", min, max); } motor[0] = 0x09; motor[13] = 0xE0 | (motor[13] & 0x0F); for (*vgaRed = 0x0F; *vgaRed > 0; (*vgaRed)--) { encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (*vgaRed, *vgaGreen, *vgaBlue, motor); lm9811[7] = dcRed << 4; lm9811[6] = 0x40 | *vgaRed; CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, w, data); if (gMode == UMAX_PP_PARPORT_EPP) { CMDSYNC (0x00); } if (DBG_LEVEL > 128) { DumpNB (w, 1, data, NULL); } min = 0xFF; max = 0x00; for (i = xstart; i <= xend; i++) { if (data[i] < min) min = data[i]; if (data[i] > max) max = data[i]; } if ((max <= targetCode) && (min > (((float) targetCode) / 2.8))) break; DBG (32, "coarseGainCalibration610p, red: min=%d, max=%d\n", min, max); } } else { *vgaRed = 0x0F; *vgaBlue = 0x0F; } TRACE (16, "coarseGainCalibration610p end ...\n"); return 1; } /* same as above, but for 1220P/1600P/200P */ static int coarseGainCalibration1220p (int color, int dcRed, int dcGreen, int dcBlue, int *vgaRed, int *vgaGreen, int *vgaBlue) { unsigned char buffer[5300]; int i; double sum; int xstart = 540; int xend = 5100; 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 opsc18[17] = { 0x01, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2F, 0x2F, 0x00, 0x88, 0x08, 0x00, 0x80, 0xA4, 0x00, -1 }; int opsc39[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6E, 0x41, 0x20, 0x24, 0x06, 0x00, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; int opsc40[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x6E, 0x41, 0x60, 0x4F, 0x06, 0x00, 0x00, 0x00, 0x46, 0xA0, 0x00, 0x8B, 0x49, 0x2A, 0xE9, 0x68, 0xDF, 0x93, 0x1A, 0x00, -1 }; int motor[17] = { 0x09, 0x00, 0x00, 0x70, 0x00, 0x00, 0x60, 0x2F, 0x2F, 0x00, 0xA5, 0x09, 0x00, 0x40, 0xA4, 0x00, -1 }; DBG (16, "entering coarseGainCalibration1220p() ... (%s:%d) \n", __FILE__, __LINE__); /* temporay workaround */ color = RGB_MODE; /* initialize VGA components */ *vgaGreen = 0; *vgaRed = 2; *vgaBlue = 2; CMDSETGET (2, 0x10, opsc18); CMDSETGET (8, 0x24, opsc39); opsc04[7] = opsc04[7] & 0x20; opsc04[6] = 0x06; /* one channel gain value */ CMDSETGET (1, 0x08, opsc10); /* was opsc04, extraneaous string */ /* that prevents using move .... */ CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, 0x200, buffer); if (DBG_LEVEL >= 128) Dump (0x200, buffer, NULL); /* auto correction of gain levels */ /* first color component X */ if (color >= RGB_MODE) { if (sanei_umax_pp_getastra () == 1600) { motor[11] |= 0x20; motor[12] = 0x08; motor[13] |= 0x02; opsc04[7] |= 0x20; } encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (*vgaRed, 0, 0, motor); CMDSETGET (2, 0x10, motor); CMDSETGET (8, 0x24, opsc40); if (DBG_LEVEL >= 128) { bloc2Decode (motor); bloc8Decode (opsc40); } opsc04[6] = *vgaRed; CMDSETGET (1, 0x08, opsc04); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, 0x14B4, buffer); if (DBG_LEVEL >= 128) Dump (0x14B4, buffer, NULL); sum = 0; for (i = xstart; i < xend; i++) sum += buffer[i]; sum = sum / (xend - xstart); while ((opsc04[6] < 0x0F) && (sum < 140)) { CMDSYNC (0x00); opsc04[6]++; CMDSETGET (1, 0x000008, opsc04); COMPLETIONWAIT; CMDGETBUF (4, 0x0014B4, buffer); if (DBG_LEVEL >= 128) Dump (0x14B4, buffer, NULL); sum = 0; for (i = xstart; i < xend; i++) sum += buffer[i]; sum = sum / (xend - xstart); } *vgaRed = opsc04[6]; /* blue */ encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (0, 0, *vgaBlue, motor); if (sanei_umax_pp_getastra () == 1600) { motor[11] |= 0x20; motor[12] = 0x08; motor[13] |= 0x02; opsc04[7] |= 0x20; } CMDSETGET (2, 0x10, motor); CMDSETGET (8, 0x24, opsc40); opsc04[6] = *vgaBlue; CMDSETGET (1, 0x08, opsc04); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; CMDGETBUF (4, 0x14B4, buffer); if (DBG_LEVEL >= 128) Dump (0x14B4, buffer, NULL); sum = 0; for (i = xstart; i < xend; i++) sum += buffer[i]; sum = sum / (xend - xstart); while ((opsc04[6] < 0x0F) && (sum < 140)) { CMDSYNC (0x00); opsc04[6]++; CMDSETGET (1, 0x08, opsc04); COMPLETIONWAIT; CMDGETBUF (4, 0x14B4, buffer); if (DBG_LEVEL >= 128) Dump (0x14B4, buffer, NULL); sum = 0; for (i = xstart; i < xend; i++) sum += buffer[i]; sum = sum / (xend - xstart); } *vgaBlue = opsc04[6]; } /* component Z: B&W component (green ...) */ encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (0, *vgaGreen, 0, motor); if (color < RGB_MODE) motor[0] = 0x01; /* in BW, scan zone doesn't have an extra 4 points */ else motor[0] = 0x05; /* extra 4 points */ motor[13] = 0xC0; /* B&W */ if (sanei_umax_pp_getastra () == 1600) { motor[11] |= 0x20; motor[12] = 0x08; motor[13] |= 0x02; opsc04[7] |= 0x20; } CMDSETGET (2, 0x10, motor); if (DBG_LEVEL >= 128) { bloc2Decode (motor); } CMDSETGET (8, 0x24, opsc40); opsc04[6] = *vgaGreen; CMDSETGET (1, 0x08, opsc04); CMDSYNC (0xC2); CMDSYNC (0x00); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; /* B&W hangs here XXX STEF XXX */ CMDGETBUF (4, 0x14B4, buffer); if (DBG_LEVEL >= 128) Dump (0x14B4, buffer, NULL); sum = 0; for (i = xstart; i < xend; i++) sum += buffer[i]; sum = sum / (xend - xstart); while ((opsc04[6] < 0x07) && (sum < 110)) { CMDSYNC (0x00); opsc04[6]++; CMDSETGET (1, 0x08, opsc04); COMPLETIONWAIT; CMDGETBUF (4, 0x0014B4, buffer); if (DBG_LEVEL >= 128) Dump (0x14B4, buffer, NULL); sum = 0; for (i = xstart; i < xend; i++) sum += buffer[i]; sum = sum / (xend - xstart); } *vgaGreen = opsc04[6]; DBG (1, "coarseGainCalibration1220p()=%d,%d,%d done ...\n", *vgaRed, *vgaGreen, *vgaBlue); return 1; } /* * generic function */ static int coarseGainCalibration (int color, int dcRed, int dcGreen, int dcBlue, int *vgaRed, int *vgaGreen, int *vgaBlue) { if (sanei_umax_pp_getastra () <= 610) { if (coarseGainCalibration610p (color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue) == 0) { DBG (0, "coarseGainCalibration610p failed !!! (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "coarseGainCalibration610p passed ... (%s:%d)\n", __FILE__, __LINE__); } else { if (coarseGainCalibration1220p (color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue) == 0) { DBG (0, "coarseGainCalibration1220p failed !!! (%s:%d)\n", __FILE__, __LINE__); return 0; } DBG (16, "coarseGainCalibration1220p passed ... (%s:%d)\n", __FILE__, __LINE__); } return 1; } /* * computes PGA offset for each pixel of the ccd. * We scan a white area with PGA=0 and computes the * offset to push the result in the correctable range * returns 1 and PGA values in 'calibration' var on success . * On failure, returns 0. */ static int shadingCalibration610p (int color, int dcRed, int dcGreen, int dcBlue, int vgaRed, int vgaGreen, int vgaBlue, int *calibration) { int motor[17] = { 0x5A, 0x80, 0x02, 0x70, 0x00, 0x00, 0xC0, 0x00, 0x17, 0x05, 0x6C, 0xAB, 0xAA, 0x2A, 0xA4, 0x00, -1 }; int ccd[37] = { 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, 0x0C, 0x00, 0x04, 0x40, 0x01, 0x00, 0x20, 0x02, 0x00, 0x76, 0x5D, 0x40, 0xA5, 0x06, 0x00, 0x00, 0xE2, 0x5E, 0xA0, 0x00, 0x8B, 0x4D, 0x4B, 0xD0, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; /* * lm9811[7]= VGA << 4 * lm9811[6]= 0x40 | DC offset */ int lm9811[9] = { 0x88, 0xE6, 0xFD, 0x8E, 0x30, 0x00, 0x0F, 0x80, -1 }; int commit[9] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, -1 }; int len, dpi, size; int bpp = 3; /* defaults to color scan value */ int w, h, x, y; int sum, i; float avg, pct, coeff = 0; unsigned char *data = NULL; int top, bottom; TRACE (16, "entering shadingCalibration610p ...\n"); len = 0x22; w = 2550; y = 10; dpi = 300; h = 90; top = 8; bottom = 8; /* move back first */ MOVE (-31, PRECISION_OFF, NULL); /* gray scanning handling */ if (color < RGB_MODE) { lm9811[7] = dcGreen << 4; lm9811[6] = 0x40 | vgaGreen; bpp = 1; motor[13] = 0x6F; } data = (unsigned char *) malloc (w * h * bpp); if (data == NULL) { DBG (0, "shadingCalibration610p: failed to allocate memory (%s:%d)\n", __FILE__, __LINE__); return 0; } memset (data, 0x00, w * h * bpp); /* prepare scan command */ x = sanei_umax_pp_getLeft (); encodeWX (w, x, dpi, color, ccd, bpp * w); encodeHY (h, y, motor); encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (vgaRed, vgaGreen, vgaBlue, motor); if (DBG_LEVEL > 128) { bloc2Decode (motor); bloc8Decode (ccd); } CMDSYNC (0x00); CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSETGET (4, 0x08, commit); COMPLETIONWAIT; /* picture height is scan area height minus y */ /* then we substract 14 or 6 lines that aren't scanned */ if (color < RGB_MODE) h = h - y - 14; else h = h - y - 6; size = w * bpp * h; DBG (128, "shadingCalibration610p: trying to read 0x%06X bytes ... (%s:%d)\n", size, __FILE__, __LINE__); /* since we know that each scan line matches CCD width, we signals * that data reading doens't need to sync on each byte, but at each * row end */ sanei_umax_pp_setfull (1); CMDGETBUF (4, size, data); sanei_umax_pp_setfull (0); /* computes correction here ... */ /* debug image files */ /* data is in R B G order */ if (DBG_LEVEL > 128) DumpNB (w * bpp, h, data, NULL); /* zeroes all shading coefficients first */ memset (calibration, 0x00, 3 * w * sizeof (int)); /* in gray scans, we have only green component (i=3) */ if (color < RGB_MODE) { /* build green only coefficients */ for (x = 4; x < w; x++) { sum = 0; for (y = top; y < h - bottom; y++) sum += data[(y * bpp) * w + x]; avg = ((float) (sum)) / ((float) (h - (top + bottom))); /* XXX ICI XXX avg=128==>2 */ /*coeff = (256.0 * (targetCode / avg - 1.0)) / 2.00;*/ coeff = (256.0 * (targetCode / avg - 1.0)) / ((avg*3.5)/targetCode); if (coeff < 0) coeff = 0; if (coeff > 255) coeff = 255; calibration[x + 2 * w - 4] = (int) (coeff + 0.5); } } else { for (i = 0; i < 3; i++) { for (x = 4; x < w; x++) { sum = 0; for (y = top; y < h - bottom; y++) sum += data[(y * bpp + i) * w + x]; avg = ((float) (sum)) / ((float) (h - (top + bottom))); /* one step increase means a 0.71% increase of the final pixel */ pct = 100.0 - (avg * 100.0) / targetCode; switch (i) { case 0: /* RED 1.80 */ case 1: /* BLUE : 2.10 */ coeff = (int) (pct / 0.57 + 0.5); break; case 2: /* GREEN 1.50 */ coeff = (int) (pct / 0.45 + 0.5); break; } if (coeff < 0) coeff = 0; if (coeff > 255) coeff = 255; calibration[x + i * w - 4] = (int) (coeff + 0.5); } /* 100 in coeffs -> +104 on picture */ } } /* use default color tables */ for (x = 0; x < 256; x++) { calibration[3 * w + x] = ggRed[x]; calibration[3 * w + x + 256] = ggGreen[x]; calibration[3 * w + x + 512] = ggBlue[x]; } if (DBG_LEVEL > 128) { DumpNB (w * bpp, h, data, NULL); DumpNB (w, h * bpp, data, NULL); } free (data); TRACE (16, "shadingCalibration610p end ...\n"); return 1; } /* * build CCD correction: a white area below the top is scanned without * correction, and the data are used to compute the coefficents needed * to correct the light/CCD variations */ static int shadingCalibration (int color, int dcRed, int dcGreen, int dcBlue, int vgaRed, int vgaGreen, int vgaBlue, int *calibration) { if (sanei_umax_pp_getastra () < 1220) return shadingCalibration610p (color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue, calibration); return shadingCalibration1220p (color, dcRed, dcGreen, dcBlue, vgaRed, vgaGreen, vgaBlue, calibration); } /* * this is certainly gamma calibration * We scan a white area with PGA=0 and computes the * offset to push the result in the correctable range * returns 1 and PGA values in 'calibration' var on success . * On failure, returns 0. */ static int leftShadingCalibration610p (int color, int dcRed, int dcGreen, int dcBlue, int vgaRed, int vgaGreen, int vgaBlue, int *calibration) { int motor[17] = { 0x14, 0x80, 0x02, 0x60, 0xDE, 0x01, 0xC0, 0x2F, 0x17, 0x00, 0x6C, 0xAB, 0xAA, 0x2A, 0xA4, 0x00, -1 }; int ccd[37] = { 0x00, 0x00, 0xD8, 0x27, 0xEC, 0x53, 0x7D, 0x8A, 0x77, 0xE3, 0x1D, 0x79, 0x07, 0x20, 0x02, 0x00, 0x76, 0x41, 0x80, 0xA3, 0xE5, 0x1D, 0x00, 0xF2, 0x5D, 0xA0, 0x00, 0x8B, 0x4D, 0x4B, 0xD0, 0x68, 0xDF, 0x13, 0x1A, 0x00, -1 }; /* * lm9811[7]= VGA << 4 * lm9811[6]= 0x40 | DC offset * lm9811[6].bit7 = use shading data */ int lm9811[9] = { 0x88, 0xE6, 0xFD, 0x8E, 0x30, 0x00, 0x8F, 0x80, -1 }; int *commit = NULL; int len, dpi, size; int w, h, x, y; int ofst; unsigned char *data = NULL; TRACE (16, "entering leftShadingCalibration610p ...\n"); if (sanei_umax_pp_getastra () < 1220) { len = 0x22; ofst = 28; w = 2550; x = 94 - ofst; /* left shift compared to shading calibration */ y = 10; dpi = 75; h = 20; } else { len = 0x24; ofst = 28; w = 5100; x = 180; y = 10; dpi = 600; h = 67; } commit = (int *) malloc ((w * 3 + 5) * sizeof (int)); if (commit == NULL) { DBG (0, "leftShadingCalibration610p: failed to allocate memory (%s:%d)\n", __FILE__, __LINE__); return 0; } data = (unsigned char *) malloc (w * h * 3); if (data == NULL) { DBG (0, "leftShadingCalibration610p: failed to allocate memory (%s:%d)\n", __FILE__, __LINE__); free (commit); return 0; } /* prepare scan command */ encodeWX (w, x, dpi, color, ccd, 7410); encodeHY (h, y, motor); encodeDC (dcRed, dcGreen, dcBlue, motor); encodeVGA (vgaRed, vgaGreen, vgaBlue, motor); if (DBG_LEVEL > 128) { bloc2Decode (motor); bloc8Decode (ccd); } /* build shading calibration data */ memset (commit, 0x00, (3 * w + 5) * sizeof (int)); for (x = ofst; x < w; x++) { commit[x] = calibration[x - ofst]; commit[x + w] = calibration[x - ofst + w]; commit[x + 2 * w] = calibration[x - ofst + 2 * w]; } /* image data cropping coefficient */ commit[3 * w + 3] = 0xFF; commit[3 * w + 4] = 0xFF; CMDSYNC (0x00); CMDSETGET (2, 0x10, motor); CMDSETGET (8, len, ccd); CMDSETGET (1, 0x08, lm9811); CMDSYNC (0xC2); CMDSETGET (4, 3 * w + 5, commit); free (commit); COMPLETIONWAIT; if (color >= RGB_MODE) { /* picture height is scan area height minus y */ h = h - y; size = w * 3 * h; } else { h = h - y - 1; size = w * h; } DBG (128, "leftShadingCalibration610p: trying to read 0x%06X bytes ... (%s:%d)\n", size, __FILE__, __LINE__); CMDGETBUF (4, size, data); if (DBG_LEVEL > 128) DumpNB (3 * w, h, data, NULL); /* XXX STEF XXX */ /* build coefficients for the 25 left pixels */ /* and compute gamma correction ? */ free (data); TRACE (16, "leftShadingCalibration610p end ...\n"); return 1; } sane-backends-1.0.29/backend/epson2-cct.c0000666000000000000000000010654213615534521014721 00000000000000/* epson2 hardware colour correction coefficients * Copyright (C) 2001-2009 SEIKO EPSON Corporation * Copyright (C) 2009 Tower Technologies * * License: GPLv2 * * This file is part of the SANE epson2 backend and has been derived * from the epkowa backend distributed with Image Scan! * */ /*! Hardware colour correction coefficients (CCC). Each entry starts with a unique identifier, followed by four CCC profiles; the first is for reflective materials, the second for colour negatives, the third for monochrome negatives, and the fourth and last one is for colour positives. */ #define DEBUG_DECLARE_ONLY #include "epson2.h" const struct epson_profile epson_cct_profiles[] = { {0x00, /* default */ {{1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x05, /* ES-6000H */ {{1.1419,-0.0596,-0.0825,-0.1234, 1.2812,-0.1413, 0.0703,-0.5720, 1.5016}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1419,-0.0596,-0.0825,-0.1234, 1.2812,-0.1413, 0.0703,-0.5720, 1.5016}}}, {0x06, /* GT-6600 */ {{1.1442,-0.0705,-0.0737,-0.0702, 1.1013,-0.0311,-0.0080,-0.3588, 1.3668}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x07, /* GT-7600 */ {{1.1967,-0.1379,-0.0588,-0.0538, 1.0385, 0.0153, 0.0348,-0.4070, 1.3721}, {1.0010,-0.0010, 0.0000,-0.1120, 1.1710,-0.0590, 0.0000,-0.0910, 1.0920}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1967,-0.1379,-0.0588,-0.0538, 1.0385, 0.0153, 0.0348,-0.4070, 1.3721}}}, {0x0D, /* ES-2000 */ {{1.1980,-0.1365,-0.0616,-0.1530, 1.1729,-0.0198,-0.0025,-0.2776, 1.2801}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1980,-0.1365,-0.0616,-0.1530, 1.1729,-0.0198,-0.0025,-0.2776, 1.2801}}}, {0x0F, /* ES-8500 */ {{1.0961,-0.0181,-0.0779,-0.1279, 1.1957,-0.0678, 0.0315,-0.3891, 1.3576}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0961,-0.0181,-0.0779,-0.1279, 1.1957,-0.0678, 0.0315,-0.3891, 1.3576}}}, {0x15, /* GT-6700 */ {{1.0999,-0.0425,-0.0574,-0.0806, 1.0835,-0.0028, 0.0057,-0.2924, 1.2866}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x16, /* GT-8700 */ {{1.2020,-0.1518,-0.0502,-0.0847, 1.1385,-0.0538, 0.0059,-0.3255, 1.3196}, {1.0030,-0.0030, 0.0000,-0.0980, 1.1500,-0.0520,-0.0030,-0.0840, 1.0880}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2456,-0.1617,-0.0839,-0.1160, 1.1862,-0.0702,-0.0036,-0.3438, 1.3473}}}, {0x18, /* GT-7700 */ {{1.1339,-0.0526,-0.0813,-0.1177, 1.1661,-0.0485,-0.0030,-0.3298, 1.3328}, {1.0010,-0.0010, 0.0000,-0.1120, 1.1710,-0.0590, 0.0000,-0.0910, 1.0920}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2066,-0.0360,-0.1706,-0.1313, 1.2523,-0.1210,-0.0299,-0.3377, 1.3676}}}, {0x1A, /* ES-9000H */ {{1.0986, 0.0235,-0.1221,-0.1294, 1.0896, 0.0399, 0.0928,-0.6043, 1.5115}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x1B, /* ES-2200 */ {{1.1855,-0.1372,-0.0483,-0.2060, 1.2468,-0.0407, 0.0358,-0.3059, 1.2701}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1976,-0.1182,-0.0794,-0.1578, 1.2720,-0.1142, 0.0122,-0.3467, 1.3345}}}, {0x1D, /* GT-7200 */ {{1.0675,-0.0586,-0.0088,-0.0332, 0.9716, 0.0616, 0.0175,-0.4054, 1.3879}, {1.0090,-0.0090, 0.0000,-0.0390, 1.0750,-0.0360,-0.0070,-0.1060, 1.1130}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1394,-0.0829,-0.0564,-0.0003, 1.0008,-0.0004,-0.0059,-0.3674, 1.3733}}}, {0x1F, /* GT-8200 */ {{1.0800,-0.0607,-0.0193,-0.0787, 1.0846,-0.0059, 0.0135,-0.3334, 1.3199}, {1.0040,-0.0040, 0.0000,-0.0780, 1.1360,-0.0570,-0.0020,-0.0810, 1.0830}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1334,-0.0929,-0.0405,-0.0418, 1.0689,-0.0271,-0.0521,-0.3262, 1.3783}}}, {0x21, /* GT-9700 */ {{1.0919,-0.0739,-0.0180,-0.0941, 1.1150,-0.0209, 0.0220,-0.3744, 1.3524}, {1.0090,-0.0100, 0.0010,-0.0720, 1.1310,-0.0600, 0.0000,-0.1000, 1.1000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1374,-0.1396, 0.0021,-0.0489, 1.0655,-0.0166, 0.0081,-0.3492, 1.3411}}}, {0x23, /* GT-7300 */ {{1.0339,-0.0166,-0.0173,-0.0117, 0.9797, 0.0319, 0.0010,-0.3609, 1.3599}, {1.0090,-0.0090, 0.0000,-0.0390, 1.0750,-0.0360,-0.0070,-0.1060, 1.1130}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1666,-0.0898,-0.0768,-0.0076, 1.0157,-0.0081, 0.0012,-0.3048, 1.3036}}}, {0x25, /* GT-8300 */ {{1.0800,-0.0607,-0.0193,-0.0787, 1.0846,-0.0059, 0.0135,-0.3334, 1.3199}, {1.0040,-0.0040, 0.0000,-0.0780, 1.1360,-0.0570,-0.0020,-0.0810, 1.0830}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1334,-0.0929,-0.0405,-0.0418, 1.0689,-0.0271,-0.0521,-0.3262, 1.3783}}}, {0x27, /* GT-9300 */ {{1.0919,-0.0739,-0.0180,-0.0941, 1.1150,-0.0209, 0.0220,-0.3744, 1.3524}, {1.0083,-0.0094, 0.0011,-0.0760, 1.1379,-0.0619,-0.0002,-0.0945, 1.0947}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1952,-0.1519,-0.0433,-0.0932, 1.1613,-0.0681,-0.0418,-0.3140, 1.3558}}}, {0x29, /* GT-9800F */ {{1.0369,-0.0210,-0.0160,-0.0820, 1.1160,-0.0341, 0.0150,-0.5035, 1.4885}, {1.0122,-0.0151, 0.0029,-0.0861, 1.1402,-0.0542,-0.0061,-0.1607, 1.1669}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1764,-0.1749,-0.0014,-0.0590, 1.0983,-0.0393, 0.0208,-0.5194, 1.4986}}}, {0x2B, /* ES-7000H */ {{1.0305,-0.0116,-0.0189,-0.0936, 1.1245,-0.0309,-0.0072,-0.1413, 1.1485}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x32, /* GT-9400 */ {{1.0932,-0.0529,-0.0403,-0.1077, 1.1416,-0.0338, 0.0079,-0.5525, 1.5446}, {1.0259,-0.0356, 0.0097,-0.1085, 1.2225,-0.1140,-0.0046,-0.1848, 1.1894}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2720,-0.2665,-0.0054,-0.0672, 1.1301,-0.0629,-0.0048,-0.3917, 1.3965}}}, {0x2D, /* CC-600PX */ {{1.0436,-0.0078,-0.0359,-0.0169, 1.0114, 0.0056, 0.0308,-0.4425, 1.4117}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x3A, /* PM-A850 */ {{1.1150,-0.0677,-0.0473,-0.1179, 1.1681,-0.0502, 0.0052,-0.4858, 1.4806}, {1.0133,-0.0151, 0.0017,-0.1216, 1.2207,-0.0991,-0.0003,-0.1512, 1.1515}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2105,-0.1644,-0.0461,-0.1124, 1.1945,-0.0820,-0.0450,-0.3367, 1.3817}}}, {0x36, /* CX5300/CX5400 */ {{1.0848,-0.0153,-0.0695,-0.0902, 1.0611, 0.0291, 0.0344,-0.5002, 1.4658}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x34, /* GT-X700 */ {{1.1032,-0.0590,-0.0442,-0.1915, 1.3371,-0.1456, 0.0387,-0.5804, 1.5417}, {1.0232,-0.0258, 0.0026,-0.1296, 1.2882,-0.1587,-0.0011,-0.1928, 1.1940}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2662,-0.2664, 0.0002,-0.1050, 1.3168,-0.2118,-0.0058,-0.4370, 1.4428}}}, {0x38, /* RX500/RX510 */ {{1.1150,-0.0677,-0.0473,-0.1179, 1.1681,-0.0502, 0.0052,-0.4858, 1.4806}, {1.0133,-0.0151, 0.0017,-0.1216, 1.2207,-0.0991,-0.0003,-0.1512, 1.1515}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2105,-0.1644,-0.0461,-0.1124, 1.1945,-0.0820,-0.0450,-0.3367, 1.3817}}}, {0x37, /* CX6300/CX6400 */ {{0.9640, 0.1455,-0.1095, 0.0108, 1.1933,-0.2041, 0.0071,-0.3487, 1.3416}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x3F, /* ES-10000G */ {{1.1223,-0.0985,-0.0238,-0.0847, 1.1502,-0.0655, 0.0118,-0.5022, 1.4904}, {1.0077,-0.0129, 0.0052,-0.0904, 1.1785,-0.0881, 0.0000,-0.1528, 1.1528}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1927,-0.1646,-0.0280,-0.0655, 1.1033,-0.0378, 0.0034,-0.4173, 1.4139}}}, {0x41, /* GT-F500/F550 */ {{1.0732,-0.0581,-0.0150,-0.0897, 1.1553,-0.0657,-0.0179,-0.6500, 1.6679}, {1.0163,-0.0203, 0.0040,-0.1125, 1.1797,-0.0672,-0.0091,-0.2343, 1.2434}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2437,-0.2022,-0.0415,-0.0352, 1.0735,-0.0383,-0.0188,-0.5020, 1.5209}}}, {0x43, /* GT-F600 */ {{1.0782,-0.0697,-0.0085,-0.1605, 1.2862,-0.1257, 0.0148,-0.5854, 1.5706}, {1.0136,-0.0151, 0.0016,-0.1836, 1.3422,-0.1586,-0.0014,-0.1851, 1.1865}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1491,-0.1456,-0.0035,-0.0990, 1.2657,-0.1666, 0.0015,-0.3868, 1.3853}}}, {0x46, /* CX3500/CX3600/CX4500/CX4600 */ {{0.9828, 0.0924,-0.0752, 0.0255, 1.1510,-0.1765, 0.0049,-0.3250, 1.3201}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x48, /* PM-A700/RX420/RX430 */ {{0.9716, 0.0927,-0.0643, 0.0010, 1.1068,-0.1078, 0.0101,-0.3046, 1.2945}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x49, /* CX6500/CX6600 */ {{0.9640, 0.1455,-0.1095, 0.0108, 1.1933,-0.2041, 0.0071,-0.3487, 1.3416}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x4B, /* PM-A870 */ {{1.1150,-0.0677,-0.0473,-0.1179, 1.1681,-0.0502, 0.0052,-0.4858, 1.4806}, {1.0133,-0.0151, 0.0017,-0.1216, 1.2207,-0.0991,-0.0003,-0.1512, 1.1515}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2105,-0.1644,-0.0461,-0.1124, 1.1945,-0.0820,-0.0450,-0.3367, 1.3817}}}, {0x4D, /* PM-A900 */ {{1.1011,-0.0824,-0.0186,-0.0970, 1.1991,-0.1021,-0.0161,-0.6247, 1.6408}, {1.0259,-0.0356, 0.0097,-0.1085, 1.2225,-0.1140,-0.0046,-0.1848, 1.1894}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2150,-0.2074,-0.0076,-0.0521, 1.1430,-0.0909,-0.0204,-0.4156, 1.4360}}}, {0x4F, /* GT-X800 */ {{1.1052,-0.0850,-0.0202,-0.1050, 1.2294,-0.1245,-0.0486,-0.4160, 1.4646}, {1.0255,-0.0272, 0.0017,-0.0919, 1.2098,-0.1180,-0.0021,-0.1296, 1.1317}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2950,-0.2619,-0.0332,-0.0562, 1.1587,-0.1025,-0.0397,-0.3100, 1.3497}}}, {0x51, /* LP-A500 */ {{1.0614,-0.0361,-0.0253,-0.1081, 1.1320,-0.0240,-0.0536,-0.2045, 1.2580}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x52, /* GT-F520/F570 */ {{1.0978,-0.0806,-0.0173,-0.0802, 1.1515,-0.0713,-0.0476,-0.4656, 1.5132}, {1.0192,-0.0192, 0.0000,-0.0974, 1.1846,-0.0872,-0.0031,-0.1797, 1.1828}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2490,-0.2030,-0.0460,-0.0469, 1.1046,-0.0577,-0.0361,-0.3857, 1.4217}}}, {0x54, /* GT-X750 */ {{1.0905,-0.0654,-0.0251,-0.1030, 1.1801,-0.0771,-0.0685,-0.4238, 1.4923}, {1.0206,-0.0207, 0.0000,-0.0890, 1.1770,-0.0880,-0.0014,-0.1450, 1.1464}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.3041,-0.2907,-0.0134,-0.0383, 1.0908,-0.0525,-0.0327,-0.2947, 1.3275}}}, {0x56, /* LP-M5500 */ {{1.0784,-0.0560,-0.0224,-0.1793, 1.2234,-0.0441,-0.0041,-0.2636, 1.2677}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x57, /* Stylus CX3700/CX3800/DX3800 */ {{0.9828, 0.0924,-0.0752, 0.0255, 1.1510,-0.1765, 0.0049,-0.3250, 1.3201}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x58, /* PX-A650/Stylus CX4700/CX4800/DX4800 */ {{0.9716, 0.0927,-0.0643, 0.0010, 1.1068,-0.1078, 0.0101,-0.3046, 1.2945}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x59, /* Stylus CX4100/CX4200/DX4200 */ {{0.9716, 0.0927,-0.0643, 0.0010, 1.1068,-0.1078, 0.0101,-0.3046, 1.2945}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x5B, /* Stylus CX7700/CX7800 */ {{0.9764, 0.1095,-0.0859, 0.0149, 1.1154,-0.1303, 0.0051,-0.2851, 1.2800}, {1.0024,-0.0149, 0.0124,-0.2569, 1.3432,-0.0864,-0.0043,-0.1306, 1.1349}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1003,-0.0493,-0.0510,-0.1607, 1.2748,-0.1142,-0.0059,-0.3161, 1.3220}}}, {0x5D, /* Stylus Photo RX520/RX530 */ {{0.9764, 0.1095,-0.0859, 0.0149, 1.1154,-0.1303, 0.0051,-0.2851, 1.2800}, {1.0024,-0.0149, 0.0124,-0.2569, 1.3432,-0.0864,-0.0043,-0.1306, 1.1349}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.1003,-0.0493,-0.0510,-0.1607, 1.2748,-0.1142,-0.0059,-0.3161, 1.3220}}}, {0x5F, /* Stylus Photo RX640/RX650 */ {{1.0697,-0.0561,-0.0137,-0.0824, 1.1291,-0.0467,-0.0390,-0.5218, 1.5608}, {1.0208,-0.0209, 0.0000,-0.0923, 1.2017,-0.1093,-0.0020,-0.1290, 1.1310}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2606,-0.2125,-0.0482,-0.0567, 1.1441,-0.0874,-0.0431,-0.3490, 1.3921}}}, {0x61, /* PM-A950 */ {{1.0921,-0.0722,-0.0199,-0.0831, 1.1550,-0.0718,-0.0452,-0.3721, 1.4173}, {1.0168,-0.0168, 0.0000,-0.0953, 1.1928,-0.0975,-0.0012,-0.1235, 1.1247}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2603,-0.2763, 0.0155,-0.0398, 1.1033,-0.0635,-0.0249,-0.2675, 1.2924}}}, {0x63, /* GT-X900 */ {{1.0976,-0.0789,-0.0187,-0.0958, 1.1821,-0.0863,-0.0565,-0.4179, 1.4744}, {1.0250,-0.0267, 0.0016,-0.0930, 1.2108,-0.1178,-0.0022,-0.1296, 1.1317}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.3111,-0.2979,-0.0132,-0.0441, 1.1148,-0.0707,-0.0348,-0.2971, 1.3319}}}, {0x65, /* ES-H300 */ {{1.0359,-0.0146,-0.0213,-0.0752, 1.0963,-0.0211,-0.0456,-0.3238, 1.3693}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x66, /* GT-S600/F650, Perfection V10/V100 */ {{1.0878,-0.0667,-0.0211,-0.0892, 1.1513,-0.0622,-0.0654,-0.5175, 1.5829}, {1.0208,-0.0209, 0.0000,-0.0923, 1.2017,-0.1093,-0.0020,-0.1290, 1.1310}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2688,-0.2522,-0.0166,-0.0559, 1.1291,-0.0733,-0.0377,-0.3519, 1.3896}}}, {0x68, /* GT-F700, Perfection V350 */ {{1.0950,-0.0646,-0.0305,-0.0792, 1.1398,-0.0606,-0.0123,-0.5175, 1.5298}, {1.0258,-0.0306, 0.0048,-0.0995, 1.2173,-0.1178,-0.0054,-0.1242, 1.1296}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2697,-0.2501,-0.0195,-0.0351, 1.1236,-0.0885,-0.0131,-0.3268, 1.3400}}}, {0x6A, /* Stylus CX2800/CX2900/ME200 */ {{0.9828, 0.0924,-0.0752, 0.0255, 1.1510,-0.1765, 0.0049,-0.3250, 1.3201}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x6B, /* Stylus PX-A620, CX3900/DX4000 */ {{0.9828, 0.0924,-0.0752, 0.0255, 1.1510,-0.1765, 0.0049,-0.3250, 1.3201}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x6C, /* Stylus CX5900/CX6000/DX6000 */ {{0.9716, 0.0927,-0.0643, 0.0010, 1.1068,-0.1078, 0.0101,-0.3046, 1.2945}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x70, /* Stylus Photo RX560/RX580/RX590 */ {{0.9533, 0.0885,-0.0418, 0.0033, 1.0627,-0.0660,-0.0137,-0.1904, 1.2041}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x71, /* PM-A920 */ {{1.0697,-0.0561,-0.0137,-0.0824, 1.1291,-0.0467,-0.0390,-0.5218, 1.5608}, {1.0208,-0.0209, 0.0000,-0.0923, 1.2017,-0.1093,-0.0020,-0.1290, 1.1310}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2606,-0.2125,-0.0482,-0.0567, 1.1441,-0.0874,-0.0431,-0.3490, 1.3921}}}, {0x73, /* PM-A970 */ {{1.0828,-0.0739,-0.0089,-0.0895, 1.1597,-0.0702,-0.0531,-0.4291, 1.4822}, {1.0258,-0.0306, 0.0048,-0.0995, 1.2173,-0.1178,-0.0054,-0.1242, 1.1296}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2579,-0.2384,-0.0195,-0.0569, 1.1454,-0.0884,-0.0411,-0.3072, 1.3483}}}, {0x75, /* PM-T990 */ {{1.0828,-0.0739,-0.0089,-0.0895, 1.1597,-0.0702,-0.0531,-0.4291, 1.4822}, {1.0258,-0.0306, 0.0048,-0.0995, 1.2173,-0.1178,-0.0054,-0.1242, 1.1296}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.2579,-0.2384,-0.0195,-0.0569, 1.1454,-0.0884,-0.0411,-0.3072, 1.3483}}}, {0x77, /* Stylus CX4900/CX5000/DX5000 */ {{0.9716, 0.0927,-0.0643, 0.0010, 1.1068,-0.1078, 0.0101,-0.3046, 1.2945}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x78, /* LP-M5600 */ {{1.0784,-0.0560,-0.0224,-0.1793, 1.2234,-0.0441,-0.0041,-0.2636, 1.2677}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x79, /* AcuLaser CX21 */ {{1.0614,-0.0361,-0.0253,-0.1081, 1.1320,-0.0240,-0.0536,-0.2045, 1.2580}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x7A, /* GT-F670, Perfection V200 */ {{1.1754,-0.1173,-0.0580,-0.0687, 1.1307,-0.0620,-0.0255,-0.4699, 1.4954}, {1.0150,-0.0173, 0.0022,-0.0853, 1.2238,-0.1384,-0.0073,-0.1490, 1.1562}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.4283,-0.4335, 0.0052,-0.0170, 1.1308,-0.1138,-0.0147,-0.2230, 1.2377}}}, {0x7C, /* GT-X770, Perfection V500 */ {{1.2470,-0.2041,-0.0429,-0.1920, 1.2918,-0.0998,-0.0100,-0.2503, 1.2603}, {1.0050,-0.0076, 0.0026,-0.2532, 1.1289, 0.1243,-0.0733,-0.0960, 1.1693}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.4724,-0.4599,-0.0125,-0.0876, 1.1562,-0.0686,-0.0097,-0.2278, 1.2375}}}, {0x7E, /* Stylus CX4300/CX4400/CX5500/CX5600/DX4400 */ {{0.9828, 0.0924,-0.0752, 0.0255, 1.1510,-0.1765, 0.0049,-0.3250, 1.3201}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x7F, /* PX-A640, Stylus CX7300/CX7400/DX7400 */ {{1.0936,-0.0142,-0.0795,-0.0001, 1.0951,-0.0949, 0.0308,-0.2967, 1.2659}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x80, /* PX-A740, Stylus CX8300/CX8400/DX8400 */ {{1.0936,-0.0142,-0.0795,-0.0001, 1.0951,-0.0949, 0.0308,-0.2967, 1.2659}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x81, /* PX-FA700, Stylus CX9300F/CX9400Fax/DX9400F */ {{1.1090,-0.0304,-0.0786, 0.0194, 1.1078,-0.1272,-0.0077,-0.1293, 1.1370}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x82, /* PM-T960 */ {{1.1622,-0.1102,-0.0519,-0.0717, 1.1060,-0.0343,-0.0248,-0.4138, 1.4385}, {0.9913, 0.0082, 0.0005,-0.1259, 1.0452, 0.0807,-0.0072,-0.0767, 1.0839}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.3900,-0.3008,-0.0892,-0.0254, 1.0890,-0.0636,-0.0300,-0.2501, 1.2801}}}, {0x84, /* PM-A940, Stylus Photo RX680/RX685/RX690 */ {{1.0934,-0.0042,-0.0892, 0.0052, 1.1019,-0.1071, 0.0259,-0.2651, 1.2392}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x85, /* PM-A840/A840S, Stylus Photo RX585/RX595/RX610 */ {{1.0534, 0.0399,-0.0934, 0.0098, 1.0589,-0.0687, 0.0016,-0.1131, 1.1115}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x86, /* GT-D1000, GT-1500 */ {{1.1945,-0.1413,-0.0532,-0.1929, 1.2525,-0.0596,-0.0235,-0.2761, 1.2996}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x87, /* GT-X970 */ {{1.1978,-0.1417,-0.0561,-0.0852, 1.1610,-0.0758,-0.0395,-0.3212, 1.3607}, {1.0000, 0.0009,-0.0009,-0.1268, 1.0523, 0.0745,-0.0075,-0.0873, 1.0948}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.4475,-0.3957,-0.0518,-0.0138, 1.0644,-0.0506,-0.0199,-0.2050, 1.2249}}}, {0x97, /* LP-M5000 */ {{1.1115,-0.0377,-0.0738,-0.0658, 1.0624, 0.0034, 0.0042,-0.2883, 1.2841}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x89, /* LP-M6000 */ {{1.1115,-0.0377,-0.0738,-0.0658, 1.0624, 0.0034, 0.0042,-0.2883, 1.2841}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x8A, /* ES-H7200, GT-20000 */ {{1.1221,-0.0396,-0.0825,-0.0718, 1.0822,-0.0104, 0.0112,-0.2995, 1.2883}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x8B, /* GT-F720/S620, Perfection V30/V300 */ {{1.2402,-0.1891,-0.0511,-0.1535, 1.2008,-0.0473,-0.0316,-0.3293, 1.3609}, {1.0027,-0.0048, 0.0021,-0.2067, 1.0878, 0.1189,-0.0408,-0.0767, 1.1175}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.4524,-0.4346,-0.0178,-0.0601, 1.1273,-0.0672,-0.0173,-0.1823, 1.1996}}}, {0x8D, /* Stylus NX200/SX200/TX200 */ {{1.0936,-0.0142,-0.0795,-0.0001, 1.0951,-0.0949, 0.0308,-0.2967, 1.2659}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x8E, /* PX-501A, Stylus NX400/SX400/TX400 */ {{1.0936,-0.0142,-0.0795,-0.0001, 1.0951,-0.0949, 0.0308,-0.2967, 1.2659}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x8F, /* Stylus NX300 / Stylus Office BX300F/TX300F / ME Office 600F */ {{1.1090,-0.0304,-0.0786, 0.0194, 1.1078,-0.1272,-0.0077,-0.1293, 1.1370}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x90, /* PX-601F, Stylus SX600FW/TX600FW / Stylus Office BX600FW / WorkForce 600 */ {{1.0316, 0.0864,-0.1180, 0.0268, 1.1111,-0.1379, 0.0213,-0.2235, 1.2022}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x91, /* EP-901A/901F, Artisan 800 / Stylus Photo PX800FW/FX800FW */ {{1.0777, 0.0152,-0.0929, 0.0244, 1.1221,-0.1465, 0.0103,-0.1544, 1.1441}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x92, /* EP-801A, Artisan 700 / Stylus Photo PX700W/TX700W */ {{1.0777, 0.0152,-0.0929, 0.0244, 1.1221,-0.1465, 0.0103,-0.1544, 1.1441}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x93, /* PX-401A, Stylus NX100/SX100/TX100 / ME 300 */ {{1.0934,-0.0042,-0.0892, 0.0052, 1.1019,-0.1071, 0.0259,-0.2651, 1.2392}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x96, /* WorkForce 500 */ {{1.1090,-0.0304,-0.0786, 0.0194, 1.1078,-0.1272,-0.0077,-0.1293, 1.1370}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x98, {{1.0936,-0.0142,-0.0795,-0.0001, 1.0951,-0.0949, 0.0308,-0.2967, 1.2659}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x99, {{1.1090,-0.0304,-0.0786, 0.0194, 1.1078,-0.1272,-0.0077,-0.1293, 1.1370}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x9A, {{1.0779, 0.0132,-0.0911, 0.0214, 1.1003,-0.1217, 0.0109,-0.1487, 1.1378}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x9B, {{1.0779, 0.0132,-0.0911, 0.0214, 1.1003,-0.1217, 0.0109,-0.1487, 1.1378}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x9C, {{1.0316, 0.0864,-0.1180, 0.0268, 1.1111,-0.1379, 0.0213,-0.2235, 1.2022}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x9D, {{1.0316, 0.0864,-0.1180, 0.0268, 1.1111,-0.1379, 0.0213,-0.2235, 1.2022}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x9E, {{1.0534, 0.0399,-0.0934, 0.0098, 1.0589,-0.0687, 0.0016,-0.1131, 1.1115}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0x9F, {{1.0777, 0.0152,-0.0929, 0.0244, 1.1221,-0.1465, 0.0103,-0.1544, 1.1441}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0xA0, {{1.0777, 0.0152,-0.0929, 0.0244, 1.1221,-0.1465, 0.0103,-0.1544, 1.1441}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}}}, {0xA1, {{1.2578,-0.2140,-0.0438,-0.1939, 1.2856,-0.0917,-0.0258,-0.2642, 1.2900}, {0.9989,-0.0018, 0.0029,-0.2608, 1.1305, 0.1303,-0.0802,-0.0807, 1.1609}, {1.0000, 0.0000, 0.0000, 0.0000, 1.0000, 0.0000, 0.0000, 0.0000, 1.0000}, {1.4431,-0.4193,-0.0238,-0.0915, 1.1507,-0.0592,-0.0226,-0.1978, 1.2204}}}, {0xFF, /* terminator */ {{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}}} }; /* cat hw-data.c | grep '{"' | cut -d ',' -f1,2 | awk '{ print $0 " },"}' */ const struct epson_profile_map epson_cct_models[] = { {"GT-10000", 0x05 }, {"ES-6000", 0x05 }, {"Perfection610", 0x06 }, {"GT-6600", 0x06 }, {"Perfection1200", 0x07 }, {"GT-7600", 0x07 }, {"Expression1600", 0x0D }, {"ES-2000", 0x0D }, {"Expression1640XL", 0x0F }, {"ES-8500", 0x0F }, {"Perfection640", 0x15 }, {"GT-6700", 0x15 }, {"Perfection1640", 0x16 }, {"GT-8700", 0x16 }, {"Perfection1240", 0x18 }, {"GT-7700", 0x18 }, {"GT-30000", 0x1A }, {"ES-9000H", 0x1A }, {"Expression1680", 0x1B }, {"ES-2200", 0x1B }, {"GT-7200", 0x1D }, {"GT-8200", 0x1F }, {"GT-9700", 0x21 }, {"GT-7300", 0x23 }, {"GT-8300", 0x25 }, {"GT-9300", 0x27 }, {"GT-9800", 0x29 }, {"ES-7000H", 0x2B }, {"LP-A500", 0x51 }, {"AL-CX11", 0x51 }, {"GT-9400", 0x32 }, {"CC-600PX", 0x2D }, {"PM-A850", 0x3A }, {"CX5400", 0x36 }, {"GT-X700", 0x34 }, {"RX500", 0x38 }, {"PX-A650", 0x37 }, {"ES-10000G", 0x3F }, {"Expression10000", 0x3F }, {"CX4600", 0x46 }, {"CX6600", 0x49 }, {"CX3600", 0x46 }, {"RX420", 0x48 }, {"PM-A700", 0x48 }, {"PM-A870", 0x4B }, {"GT-F500", 0x41 }, {"GT-F600", 0x43 }, {"PM-A900", 0x4D }, {"GT-X800", 0x4F }, {"GT-X750", 0x54 }, {"LP-M5500", 0x56 }, {"LP-M5600", 0x78 }, {"GT-F520", 0x52 }, {"CX3800", 0x57 }, {"CX7800", 0x5B }, {"PM-A750", 0x5D }, {"CX4800", 0x58 }, {"CX4200", 0x59 }, {"PM-A950", 0x61 }, {"PM-A890", 0x5F }, {"GT-X900", 0x63 }, {"CX4000", 0x6B }, {"CX3000v", 0x6A }, {"ES-H300", 0x65 }, {"CX6000", 0x6C }, {"PM-A820", 0x70 }, {"PM-A920", 0x71 }, {"PM-A970", 0x73 }, {"PM-T990", 0x75 }, {"CX5000", 0x77 }, {"GT-S600", 0x66 }, {"GT-F700", 0x68 }, {"AL-CX21", 0x79 }, {"GT-F670", 0x7A }, {"GT-X770", 0x7C }, {"CX4400", 0x7E }, {"CX7400", 0x7F }, {"CX8400", 0x80 }, {"CX9400Fax", 0x81 }, {"PM-T960", 0x82 }, {"PM-A940", 0x84 }, {"PM-A840", 0x85 }, {"GT-D1000", 0x86 }, {"GT-X970", 0x87 }, {"LP-M5000", 0x97 }, {"LP-M6000", 0x89 }, {"ES-H7200", 0x8A }, {"GT-20000", 0x8A }, {"NX200", 0x8D }, {"NX400", 0x8E }, {"NX100", 0x93 }, {"NX300", 0x8F }, {"WorkForce 600", 0x90 }, {"Artisan 800", 0x91 }, {"Artisan 700", 0x92 }, {"WorkForce 500", 0x96 }, {"GT-F720", 0x8B }, {"GT-S620", 0x8B }, {"GT-S50", 0x00 }, {"GT-S80", 0x00 }, {"PID 0851", 0x98 }, {"PID 084D", 0x99 }, {"PID 084F", 0x9A }, {"PID 0854", 0x9B }, {"PID 0856", 0x9C }, {"PID 0855", 0x9D }, {"PID 0850", 0x9E }, {"PID 0852", 0xA0 }, {"PID 0853", 0x9F }, {"GT-X820", 0xA1 }, {NULL, 0x00 } /* terminator */ }; sane-backends-1.0.29/backend/hp.TODO0000666000000000000000000000265413615534521013675 00000000000000These are Geoffreys TODOs: Fix ifdef ENABLE_'s Add emulation for color separation matrixes? Gamma plot initialization? Dither pattern option not working right. More use of FAILED macro , maybe SUCCESS macro ? Convert to single .h file? /** FIXME: ToDo * * Split up hp_scsi_open -- don't need full probe every time? * or if probing at least make sure answer is constant. * * Stale flage so don't download unchanged parameters? * * Fix or disable dither stuff. * * Add controls * * Preview mode: fast, grayscale instead of halftone. * Separate X and Y resolutions + bind button. * 10x8 tone maps? * Sharpening? * Matrixes - fix color separtion? * Dither pattern? COlor dither pattern? * * check return values (of maybe others)? * get rid of overly verbose DBG's * add som DBG's */ New TODOs: Find a way to set matrices in the frontend (gtk-table with sliders ?) Find a way to set dither matrices in the frontend (See the ENABLE_...-macros in hp.h to enable these features) Fix problem with performance of reader-process. Communication through the pipe might be too slow and make the scanner repeating several strips. Fix various problems with PhotoScanner: - rubbish on bottom of scanned image - too few data that is received on bottom of scanned image for PhotoScanner - scan time for slides at 2400 dpi is twice as long as under M$-Windows Support 10/12-bits for greyscale sane-backends-1.0.29/backend/hp.README0000666000000000000000000000467313615534521014070 00000000000000Fri Dec 5 18:10:52 PST 1997 Geoffrey T. Dairiki Here is a new HP backend. It's name is, appropriately, ``newhp''. It is still in the pre-alpha stages but mostly works on my ScanJet 5P. It is completely untested on other scanners, but might hopefully work on ScanJet models IIp, IIc, IIcx, 3p, 3c, 4c, 4p, and 5p. I've only really tested this with xscanimage. Some features included in this backend which aren't in the old HP driver are: Support for custom tonemaps (gamma-maps). For some reason I can't get the 10-bit tonemaps working with my 5p, so for you only get a single tonemap (it still works in color mode, but you don't get individual control over each R/G/B channel.) You can enable the scanjets "Auto Threshold" mode when scanning line-art. I can't notice that it does much though.... Added an option to control the scan speed. Added an option to select the dither pattern used in half-tone mode. I don't think that custom dither patterns are working correctly, and in any case, with the current front-ends, there is no convenient way to set a custom dither pattern.... Added an option to select the color correction matrixes. This also seems to be flaky. Again the current front-ends do not provide a decent way to adjust the custom color matrix. Tue Feb 24 20:00:00 UT+1 1998 Peter Kirchgessner Picked up the sources because they did not find their way to the SANE-package up to now. And because I want to have a better support for the HP Photosmart Photoscanner. Renamed the backend from newhp to xhp just to get a better acceptance. Added an option to perform calibration. Upload and download calibration data Added options for horizontal/vertical mirroring. Vertical mirroring is performed by loading image completely into memory before sending to frontend. Uses SCSI-flushing more often because otherwise the scanner did not accept all of the commands. Test support of commands to be independant from inquired model number. Wed Mar 28 10:00:00 UT+1 1998 Bring it on its way to the SANE-project. Geoffrey accepted to add licence informations to the files as long as noone has to pay for the code. Sun Jun 07 15:00:00 UT+1 1998 Added unload button Fixed problem with custom gamma table Sat Nov 14 14:00:00 UT+1 1998 Show calibrate button on Photosmart only for print media Add HP 6200 C Suppress halftone mode on photosmart (it is not supported) sane-backends-1.0.29/backend/mustek_pp_null.c0000666000000000000000000001000413615534521015770 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000-2003 Jochen Eisinger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Mustek PP flatbed scanners. */ #include "../include/sane/config.h" #if defined(HAVE_STDLIB_H) # include #endif #include #include #if defined(HAVE_STRING_H) # include #elif defined(HAVE_STRINGS_H) # include #endif #define DEBUG_DECLARE_ONLY #include "mustek_pp.h" #include "mustek_pp_decl.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #define MUSTEK_PP_NULL_DRIVER 0 static SANE_Status debug_drv_init(SANE_Int options, SANE_String_Const port, SANE_String_Const name, SANE_Attach_Callback attach) { if (options != CAP_NOTHING) return SANE_STATUS_INVAL; return attach(port, name, MUSTEK_PP_NULL_DRIVER, 0); } /*ARGSUSED*/ static void debug_drv_capabilities(SANE_Int info __UNUSED__, SANE_String *model, SANE_String *vendor, SANE_String *type, SANE_Int *maxres, SANE_Int *minres, SANE_Int *maxhsize, SANE_Int *maxvsize, SANE_Int *caps) { *model = strdup("debugger"); *vendor = strdup("mustek_pp"); *type = strdup("software emulated"); *maxres = 300; *minres = 50; *maxhsize = 1000; *maxvsize = 3000; *caps = CAP_NOTHING; } /*ARGSUSED*/ static SANE_Status debug_drv_open (SANE_String port __UNUSED__, SANE_Int caps __UNUSED__, SANE_Int *fd) { *fd = 1; return SANE_STATUS_GOOD; } static void debug_drv_setup (SANE_Handle hndl) { Mustek_pp_Handle *dev = hndl; dev->lamp_on = 0; dev->priv = NULL; } /*ARGSUSED*/ static SANE_Status debug_drv_config(SANE_Handle hndl __UNUSED__, SANE_String_Const optname, SANE_String_Const optval) { DBG (3, "debug_drv cfg option: %s=%s\n", optname, optval ? optval : ""); return SANE_STATUS_GOOD; } /*ARGSUSED*/ static void debug_drv_close (SANE_Handle hndl __UNUSED__) { } /*ARGSUSED*/ static SANE_Status debug_drv_start (SANE_Handle hndl __UNUSED__) { return SANE_STATUS_GOOD; } static void debug_drv_read (SANE_Handle hndl, SANE_Byte *buffer) { Mustek_pp_Handle *dev = hndl; memset (buffer, 0, dev->params.bytes_per_line); } /*ARGSUSED*/ static void debug_drv_stop (SANE_Handle hndl __UNUSED__) { } sane-backends-1.0.29/backend/sm3600-scanutil.c0000666000000000000000000003121013615534521015501 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) Marian Eichholz 2001 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* ====================================================================== Userspace scan tool for the Microtek 3600 scanner $Id$ ====================================================================== */ #include #include "sm3600-scantool.h" /* ********************************************************************** dprintf(DEBUG_XXXX, format, ...) Put a debug message on STDERR (or whatever). The message is prefixed with a "debug:" and given, if the current debugging flags contain the given flag "ulType". ********************************************************************** */ #ifdef INSANE_VERSION void DBG(int nLevel, const char *szFormat, ...) { szFormat++; } #endif __SM3600EXPORT__ void debug_printf(unsigned long ulType, const char *szFormat, ...) { va_list ap; if ((ulDebugMask & ulType)!=ulType) return; if (*szFormat=='~') szFormat++; else fprintf(stderr,"debug:"); va_start(ap,szFormat); vfprintf(stderr,szFormat,ap); va_end(ap); } /* ********************************************************************** SetError(error, format, ...) The program is aborted, all handles and ressources are freed (this being global) and the user gets a nice panic screen :-) ********************************************************************** */ __SM3600EXPORT__ int SetError(TInstance *this, int nError, const char *szFormat, ...) { va_list ap; if (this->nErrorState) return 0; /* do not overwrite error state */ this->nErrorState=nError; this->szErrorReason=malloc(500); if (szFormat!=NULL && this->szErrorReason) { va_start(ap,szFormat); vsnprintf(this->szErrorReason,499,szFormat,ap); va_end(ap); this->szErrorReason[499]='\0'; } return nError; } #ifdef INSANE_VERSION /* ********************************************************************** DumpBuffer(fh,pch,cch) ********************************************************************** */ __SM3600EXPORT__ void DumpBuffer(FILE *fh, const char *pch, int cch) { int i=0; while (istate.ppchLines) { int i; for (i=0; istate.cBacklog; i++) { if (this->state.ppchLines[i]) free(this->state.ppchLines[i]); } free(this->state.ppchLines); } if (this->state.pchLineOut) free(this->state.pchLineOut); if (this->state.pchBuf) free(this->state.pchBuf); this->state.pchBuf =NULL; this->state.pchLineOut=NULL; this->state.ppchLines =NULL; return nReturn; } /* ====================================================================== EndScan() ====================================================================== */ __SM3600EXPORT__ TState EndScan(TInstance *this) { if (!this->state.bScanning) return SANE_STATUS_GOOD; /* move slider back to start */ this->state.bScanning=false; FreeState(this,0); INST_ASSERT(); return DoJog(this,-this->state.cyTotalPath); } /* ====================================================================== TState CancelScan(TInstance *this) ====================================================================== */ __SM3600EXPORT__ TState CancelScan(TInstance *this) { TBool bCanceled; DBG(DEBUG_INFO,"CancelScan() called\n"); this->state.cyTotalPath-=RegRead(this,R_POS,2); DBG(DEBUG_JUNK,"stepping back %d steps\n",this->state.cyTotalPath); /* this->state.cyTotalPath=0; */ usleep(200); DoReset(this); EndScan(this); /* and step back! */ DBG(DEBUG_JUNK,"cs4: %d\n",(int)this->nErrorState); bCanceled=this->state.bCanceled; this->state.bCanceled=false; /* re-enable Origination! */ if (!this->bOptSkipOriginate) DoOriginate(this,false); /* have an error here... */ this->state.bCanceled=bCanceled; DBG(DEBUG_JUNK,"cs5: %d\n",(int)this->nErrorState); INST_ASSERT(); DBG(DEBUG_INFO,"cs6: ok.\n"); return SANE_STATUS_CANCELLED; /* or shall be say GOOD? */ } /* ====================================================================== ReadChunk() ====================================================================== */ __SM3600EXPORT__ TState ReadChunk(TInstance *this, unsigned char *achOut, int cchMax, int *pcchRead) { /* have we to copy more than we have? */ /* can the current line fill the buffer ? */ int rc; *pcchRead=0; INST_ASSERT(); if (!this->state.bScanning) return SANE_STATUS_CANCELLED; /* deferred cancel? */ if (this->state.bCanceled) /* deferred cancellation? */ return CancelScan(this); INST_ASSERT(); /* 22.4.2001: This took me hard, harder, hardest:*/ /* We need to fill the line buffer with at least a *rest* of a line. A single line will do. */ /* Thus, "iLine>0" is a suitable condition. */ /* Without the preread, there will a dummy line be read, if the target buffer is large enough.*/ if (this->state.iLine) rc=SANE_STATUS_GOOD; else rc=(*(this->state.ReadProc))(this); /* preread one line */ if (rc!=SANE_STATUS_GOOD) return rc; dprintf(DEBUG_BUFFER,"Chunk-Init: cchMax = %d\n",cchMax); while (this->state.iReadPos + cchMax > this->state.cchLineOut) { int cch; /* copy rest of the line into target */ cch = this->state.cchLineOut - this->state.iReadPos; memcpy(achOut, this->state.pchLineOut+this->state.iReadPos, cch); cchMax-=cch; /* advance parameters */ achOut+=cch; (*pcchRead)+=cch; this->state.iReadPos=0; rc=(*(this->state.ReadProc))(this); dprintf(DEBUG_BUFFER,"Chunk-Read: cchMax = %d\n",cchMax); if (rc!=SANE_STATUS_GOOD) return rc; /* should be NOT(!) EOF, but then: good and away! */ } dprintf(DEBUG_BUFFER,"Chunk-Exit: cchMax = %d\n",cchMax); if (!cchMax) return SANE_STATUS_GOOD; /* now everything fits! */ (*pcchRead) += cchMax; memcpy(achOut, this->state.pchLineOut+this->state.iReadPos, cchMax); this->state.iReadPos += cchMax; return SANE_STATUS_GOOD; } /* ====================================================================== GetAreaSize() ====================================================================== */ __SM3600EXPORT__ void GetAreaSize(TInstance *this) { /* this->state.cxPixel : pixels, we *want* (after interpolation) this->state.cxMax : pixels, we *need* (before interpolation) */ int nRefResX,nRefResY; nRefResX=nRefResY=this->param.res; switch (this->param.res) { case 75: nRefResX=100; this->state.nFixAspect=75; break; default: this->state.nFixAspect=100; break; } this->state.cxPixel =this->param.cx*this->param.res/1200; this->state.cyPixel =this->param.cy*this->param.res/1200; this->state.cxMax =this->state.cxPixel*100/this->state.nFixAspect; this->state.cxWindow =this->state.cxMax*600/nRefResX; this->state.cyWindow =this->state.cyPixel*600/nRefResY; dprintf(DEBUG_SCAN,"requesting %d[600] %d[real] %d[raw]\n", this->state.cxWindow,this->state.cxPixel,this->state.cxMax); } /* ====================================================================== ResetCalibration() Free calibration data. The Instance can be safely released afterwards. ====================================================================== */ __SM3600EXPORT__ void ResetCalibration(TInstance *this) { if (this->calibration.achStripeY) free(this->calibration.achStripeY); if (this->calibration.achStripeR) free(this->calibration.achStripeR); if (this->calibration.achStripeG) free(this->calibration.achStripeG); if (this->calibration.achStripeB) free(this->calibration.achStripeB); /* reset all handles, pointers, flags */ memset(&(this->calibration),0,sizeof(this->calibration)); /* TODO: type specific margins */ this->calibration.xMargin=200; this->calibration.yMargin=0x019D; this->calibration.nHoleGray=10; this->calibration.rgbBias=0x888884; this->calibration.nBarGray=0xC0; } /* ====================================================================== InitGammaTables() Init gammy tables and gain tables within controller memory. ====================================================================== */ __SM3600EXPORT__ TState InitGammaTables(TInstance *this, int nBrightness, int nContrast) { long i; long lOffset; long lScale; /* the rescaling is done with temporary zero translation to 2048 */ lOffset=(nBrightness-128)*16; /* signed! */ lScale=(nContrast+128)*100; /* in percent */ for (i=0; i<4096; i++) { int n=(int)((i+lOffset)*lScale/12800L+2048L); if (n<0) n=0; else if (n>4095) n=4095; this->agammaY[i]=n; this->agammaR[i]=n; this->agammaG[i]=n; this->agammaB[i]=n; } return SANE_STATUS_GOOD; } #ifdef INSANE_VERSION /* ====================================================================== DoScanFile() Top level caller for scantool. ====================================================================== */ #define APP_CHUNK_SIZE 0x8000 __SM3600EXPORT__ TState DoScanFile(TInstance *this) { int cx,cy; long lcchRead; TState rc; char *achBuf; achBuf=malloc(APP_CHUNK_SIZE); rc=SANE_STATUS_GOOD; /* make compiler happy */ rc=InitGammaTables(this, this->param.nBrightness, this->param.nContrast); if (rc!=SANE_STATUS_GOOD) return rc; if (this->mode==color) rc=StartScanColor(this); else rc=StartScanGray(this); cx=this->state.cxPixel; cy=this->state.cyPixel; if (this->bVerbose) fprintf(stderr,"scanning %d by %d\n",cx,cy); if (this->fhScan && !this->bWriteRaw && !this->pchPageBuffer) { switch (this->mode) { case color: fprintf(this->fhScan,"P6\n%d %d\n255\n",cx,cy); break; case gray: fprintf(this->fhScan,"P5\n%d %d\n255\n",cx,cy); break; default: fprintf(this->fhScan,"P4\n%d %d\n",cx,cy); break; } } lcchRead=0L; while (!rc) { int cch; cch=0; rc=ReadChunk(this,achBuf,APP_CHUNK_SIZE,&cch); if (cch>0 && this->fhScan && cch<=APP_CHUNK_SIZE) { if (this->pchPageBuffer) { #ifdef SM3600_DEBUGPAGEBUFFER if (this->bVerbose) fprintf(stderr,"ichPageBuffer:%d, cch:%d, cchPageBuffer:%d\n", this->ichPageBuffer,cch,this->cchPageBuffer); #endif CHECK_ASSERTION(this->ichPageBuffer+cch<=this->cchPageBuffer); memcpy(this->pchPageBuffer+this->ichPageBuffer, achBuf,cch); this->ichPageBuffer+=cch; } else if (!this->bWriteRaw) fwrite(achBuf,1,cch,this->fhScan); lcchRead+=cch; } } free(achBuf); if (this->bVerbose) fprintf(stderr,"read %ld image byte(s)\n",lcchRead); EndScan(this); INST_ASSERT(); return SANE_STATUS_GOOD; } #endif sane-backends-1.0.29/backend/stv680.h0000666000000000000000000002370213615534521014017 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2004 -2006 Gerard Klaver (gerard at gkall dot hobby dot nl) The teco2 and gl646 backend (Frank Zago) are used as a template for this backend. For the usb commands and bayer decoding parts of the following program are used: The pencam2 program (GNU GPL license 2) For the usb commands parts of the following programs are used: The libgphoto2 (camlib stv0680) (GNU GPL license 2) The stv680.c/.h kernel module (GNU GPL license 2) For the stv680_add_text routine the add_text routine and font_6x11.h file are taken from the webcam.c file, part of xawtv program, (c) 1998-2002 Gerd Knorr (GNU GPL license 2). 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --------------------------------------------------------------------- */ /* $Id$ update 20-04-2006*/ /* Commands supported by the vidcam. */ /*--------------------------------------------------------------------------*/ static inline int getbitfield (unsigned char *pageaddr, int mask, int shift) { return ((*pageaddr >> shift) & mask); } /*--------------------------------------------------------------------------*/ #include #define LIBUSB_TIMEOUT 1000 /* ms */ typedef unsigned char byte; /*--------------------------------------------------------------------------*/ /* Black magic for color adjustment. */ struct dpi_color_adjust { int resolution_x; /* x-resolution */ int resolution_y; /* y-resolution */ int z1_color_0; /* 0, 1 or 2 */ int z1_color_1; /* idem */ int z1_color_2; /* idem */ }; /*--------------------------------------------------------------------------*/ enum Stv680_Option { /* Must come first */ OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, /* vidcam modes */ OPT_RESOLUTION, /* X and Y resolution */ OPT_BRIGHTNESS, /* brightness */ OPT_ENHANCEMENT_GROUP, OPT_WHITE_LEVEL_R, /*white level red correction */ OPT_WHITE_LEVEL_G, /*white level green correction */ OPT_WHITE_LEVEL_B, /*white level blue correction */ /* must come last: */ OPT_NUM_OPTIONS }; /*--------------------------------------------------------------------------*/ /* * Video Camera supported by this backend. */ struct vidcam_hardware { /* USB stuff */ SANE_Word vendor; SANE_Word product; SANE_Word class; /* Readable names */ const char *vendor_name; /* brand on the box */ const char *product_name; /* name on the box */ /* Resolutions supported in color mode. */ const struct dpi_color_adjust *color_adjust; }; #define COLOR_RAW_STR SANE_I18N("Color RAW") #define COLOR_RGB_STR SANE_I18N("Color RGB") #define COLOR_RGB_TEXT_STR SANE_I18N("Color RGB TEXT") /*--------------------------------------------------------------------------*/ /* Define a vidcam occurence. */ typedef struct Stv680_Vidcam { struct Stv680_Vidcam *next; SANE_Device sane; char *devicename; SANE_Int fd; /* device handle */ /* USB handling */ size_t buffer_size; /* size of the buffer */ SANE_Byte *buffer; /* for USB transfer. */ /* Bayer handling */ size_t output_size; /* size of the output */ SANE_Byte *output; /* for bayer conversion */ size_t image_size; /* allocated size of image */ size_t image_begin; /* first significant byte in image */ size_t image_end; /* first free byte in image */ SANE_Byte *image; /* keep the raw image here */ /* USB control messages handling */ size_t windoww_size; /* size of window write */ size_t windowr_size; /* size of window read */ SANE_Byte *windoww; /* for window write */ SANE_Byte *windowr; /* for window read */ /* Scanner infos. */ const struct vidcam_hardware *hw; /* default options for that vidcam */ SANE_Word *resolutions_list; SANE_Word *color_sequence_list; /* Scanning handling. */ SANE_Bool scanning; /* TRUE if a scan is running. */ SANE_Bool deliver_eof; int x_resolution; /* X resolution */ int y_resolution; /* Y resolution */ int depth; /* depth per color */ unsigned int colour; int red_s; int green_s; int blue_s; SANE_Parameters s_params; enum { STV680_COLOR_RGB, STV680_COLOR_RGB_TEXT, STV680_COLOR, STV680_COLOR_RAW } scan_mode; size_t bytes_left; /* number of bytes left to give to the backend */ size_t real_bytes_left; /* number of bytes left the vidcam will return. */ int bytes_pixel; const struct dpi_color_adjust *color_adjust; SANE_Parameters params; /* Options */ SANE_Option_Descriptor opt[OPT_NUM_OPTIONS]; Option_Value val[OPT_NUM_OPTIONS]; unsigned int video_mode; /* 0x0100 = VGA, 0x0000 = CIF, * 0x0300 = QVGA, 0x0200 = QCIF*/ unsigned int video_status; /* 0x01=start, 0x02=video, 0x04=busy, 0x08=idle */ int SupportedModes; int HardwareConfig; int QSIF; int CIF; int VGA; int QVGA; int QCIF; int cwidth; /* camera width */ int cheight; int subsample; int framecount; char picmsg_ps[50]; } Stv680_Vidcam; /*--------------------------------------------------------------------------*/ /* Debug levels. * Should be common to all backends. */ #define DBG_error0 0 #define DBG_error 1 #define DBG_sense 2 #define DBG_warning 3 #define DBG_inquiry 4 #define DBG_info 5 #define DBG_info2 6 #define DBG_proc 7 #define DBG_read 8 #define DBG_sane_init 10 #define DBG_sane_proc 11 #define DBG_sane_info 12 #define DBG_sane_option 13 /*--------------------------------------------------------*/ static SANE_Byte red_g[256] = { 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42, 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69, 71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87, 88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134, 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143, 143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151, 152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159, 159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166, 167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173, 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179, 180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186, 187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192, 192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197, 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204, 204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209, 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215, 215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219, 220, 220, 221, 221 }; static SANE_Byte green_g[256] = { 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47, 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77, 79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97, 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113, 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149, 150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159, 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168, 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177, 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185, 186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193, 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207, 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239, 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244, 245, 245, 246, 246 }; static SANE_Byte blue_g[256] = { 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51, 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84, 86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106, 107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163, 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184, 185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194, 194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203, 204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212, 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220, 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235, 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242, 243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249, 249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 }; sane-backends-1.0.29/backend/pint.c0000666000000000000000000006222713615534521013717 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Gordon Matzigkeit Copyright (C) 1997 David Mosberger-Tang 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "../include/sane/config.h" #include #include #include extern int errno; #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include #include #include "../include/sane/sanei_backend.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #include "../include/sane/sanei_config.h" #define PINT_CONFIG_FILE "pint.conf" #include "pint.h" #define DECIPOINTS_PER_MM (720.0 / MM_PER_INCH) #define TWELVEHUNDS_PER_MM (1200.0 / MM_PER_INCH) static int num_devices; static PINT_Device *first_dev; static PINT_Scanner *first_handle; /* A zero-terminated list of valid scanner modes. */ static SANE_String_Const mode_list[8]; static const SANE_Range s7_range = { -127, /* minimum */ 127, /* maximum */ 1 /* quantization */ }; static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } static SANE_Status attach (const char *devname, PINT_Device **devp) { int fd; long lastguess, inc; PINT_Device *dev; struct scan_io scanio; for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devname) == 0) { if (devp) *devp = dev; return SANE_STATUS_GOOD; } DBG(3, "attach: opening %s\n", devname); fd = open (devname, O_RDONLY, 0); if (fd < 0) { DBG(1, "attach: open failed (%s)\n", strerror (errno)); return SANE_STATUS_INVAL; } DBG(3, "attach: sending SCIOCGET\n"); if (ioctl (fd, SCIOCGET, &scanio) < 0) { DBG(1, "attach: get status failed (%s)\n", strerror (errno)); close (fd); return SANE_STATUS_INVAL; } dev = malloc (sizeof (*dev)); if (!dev) return SANE_STATUS_NO_MEM; memset(dev, 0, sizeof (*dev)); /* Copy the original scanner state to the device structure. */ memcpy (&dev->scanio, &scanio, sizeof (dev->scanio)); /* FIXME: PINT currently has no good way to determine maxima and minima. So, do binary searches to find out what limits the driver has. */ /* Assume that minimum range of x and y is 0. */ dev->x_range.min = SANE_FIX (0); dev->y_range.min = SANE_FIX (0); dev->x_range.quant = 0; dev->y_range.quant = 0; /* x range */ inc = 8.5 * 1200; /* Converge on the maximum scan width. */ while ((inc /= 2) != 0) { /* Move towards the extremum until we overflow. */ do { lastguess = scanio.scan_width; scanio.scan_width += inc; } while (ioctl (fd, SCIOCSET, &scanio) >= 0); /* Pick the last valid guess, divide by two, and try again. */ scanio.scan_width = lastguess; } dev->x_range.max = SANE_FIX (scanio.scan_width / TWELVEHUNDS_PER_MM); /* y range */ inc = 11 * 1200; while ((inc /= 2) != 0) { do { lastguess = scanio.scan_height; scanio.scan_height += inc; } while (ioctl (fd, SCIOCSET, &scanio) >= 0); scanio.scan_height = lastguess; } dev->y_range.max = SANE_FIX (scanio.scan_height / TWELVEHUNDS_PER_MM); /* Converge on the minimum scan resolution. */ dev->dpi_range.quant = 1; if (scanio.scan_x_resolution > scanio.scan_y_resolution) scanio.scan_x_resolution = scanio.scan_y_resolution; else scanio.scan_y_resolution = scanio.scan_x_resolution; inc = -scanio.scan_x_resolution; while ((inc /= 2) != 0) { do { lastguess = scanio.scan_x_resolution; scanio.scan_x_resolution = scanio.scan_y_resolution += inc; } while (ioctl (fd, SCIOCSET, &scanio) >= 0); scanio.scan_x_resolution = scanio.scan_y_resolution = lastguess; } dev->dpi_range.min = scanio.scan_x_resolution; /* Converge on the maximum scan resolution. */ inc = 600; while ((inc /= 2) != 0) { do { lastguess = scanio.scan_x_resolution; scanio.scan_x_resolution = scanio.scan_y_resolution += inc; } while (ioctl (fd, SCIOCSET, &scanio) >= 0); scanio.scan_x_resolution = scanio.scan_y_resolution = lastguess; } dev->dpi_range.max = scanio.scan_x_resolution; /* Determine the valid scan modes for mode_list. */ lastguess = 0; #define CHECK_MODE(flag,modename) \ scanio.scan_image_mode = flag; \ if (ioctl (fd, SCIOCSET, &scanio) >= 0) \ mode_list[lastguess ++] = modename CHECK_MODE(SIM_BINARY_MONOCHROME, SANE_VALUE_SCAN_MODE_LINEART); CHECK_MODE(SIM_DITHERED_MONOCHROME, SANE_VALUE_SCAN_MODE_HALFTONE); CHECK_MODE(SIM_GRAYSCALE, SANE_VALUE_SCAN_MODE_GRAY); CHECK_MODE(SIM_COLOR, SANE_VALUE_SCAN_MODE_COLOR); CHECK_MODE(SIM_RED, "Red"); CHECK_MODE(SIM_GREEN, "Green"); CHECK_MODE(SIM_BLUE, "Blue"); #undef CHECK_MODE /* Zero-terminate the list of modes. */ mode_list[lastguess] = 0; /* Restore the scanner state. */ if (ioctl (fd, SCIOCSET, &dev->scanio)) DBG (2, "cannot reset original scanner state: %s\n", strerror (errno)); close (fd); dev->sane.name = strdup (devname); /* Determine vendor. */ switch (scanio.scan_scanner_type) { case EPSON_ES300C: dev->sane.vendor = "Epson"; break; case FUJITSU_M3096G: dev->sane.vendor = "Fujitsu"; break; case HP_SCANJET_IIC: dev->sane.vendor = "HP"; break; case IBM_2456: dev->sane.vendor = "IBM"; break; case MUSTEK_06000CX: case MUSTEK_12000CX: dev->sane.vendor = "Mustek"; break; case RICOH_FS1: case RICOH_IS410: case RICOH_IS50: dev->sane.vendor = "Ricoh"; break; case SHARP_JX600: dev->sane.vendor = "Sharp"; break; case UMAX_UC630: case UMAX_UG630: dev->sane.vendor = "UMAX"; break; default: dev->sane.vendor = "PINT"; } /* Determine model. */ switch (scanio.scan_scanner_type) { case EPSON_ES300C: dev->sane.vendor = "Epson"; break; case FUJITSU_M3096G: dev->sane.model = "M3096G"; break; case HP_SCANJET_IIC: dev->sane.model = "ScanJet IIc"; break; case IBM_2456: dev->sane.vendor = "IBM"; break; case MUSTEK_06000CX: case MUSTEK_12000CX: dev->sane.vendor = "Mustek"; break; case RICOH_FS1: dev->sane.model = "FS1"; break; case RICOH_IS410: dev->sane.model = "IS-410"; break; case RICOH_IS50: dev->sane.vendor = "Ricoh"; break; case SHARP_JX600: dev->sane.vendor = "Sharp"; break; case UMAX_UC630: case UMAX_UG630: dev->sane.vendor = "UMAX"; break; default: dev->sane.model = "unknown"; } /* Determine the scanner type. */ switch (scanio.scan_scanner_type) { case HP_SCANJET_IIC: dev->sane.type = "flatbed scanner"; /* FIXME: which of these are flatbed or handhelds? */ case EPSON_ES300C: case FUJITSU_M3096G: case IBM_2456: case MUSTEK_06000CX: case MUSTEK_12000CX: case RICOH_FS1: case RICOH_IS410: case RICOH_IS50: case SHARP_JX600: case UMAX_UC630: case UMAX_UG630: default: dev->sane.type = "generic scanner"; } DBG(1, "attach: found %s %s, x=%g-%gmm, y=%g-%gmm, " "resolution=%d-%ddpi\n", dev->sane.vendor, dev->sane.model, SANE_UNFIX (dev->x_range.min), SANE_UNFIX (dev->x_range.max), SANE_UNFIX (dev->y_range.min), SANE_UNFIX (dev->y_range.max), dev->dpi_range.min, dev->dpi_range.max); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; return SANE_STATUS_GOOD; } static SANE_Status init_options (PINT_Scanner *s) { int i; int x0, x1, y0, y1; memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = "Scan Mode"; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; /* Translate the current PINT mode into a string. */ switch (s->hw->scanio.scan_image_mode) { case SIM_BINARY_MONOCHROME: s->val[OPT_MODE].s = strdup (mode_list[0]); break; case SIM_DITHERED_MONOCHROME: s->val[OPT_MODE].s = strdup (mode_list[1]); break; case SIM_COLOR: s->val[OPT_MODE].s = strdup (mode_list[3]); break; case SIM_RED: s->val[OPT_MODE].s = strdup (mode_list[4]); break; case SIM_GREEN: s->val[OPT_MODE].s = strdup (mode_list[5]); break; case SIM_BLUE: s->val[OPT_MODE].s = strdup (mode_list[6]); break; case SIM_GRAYSCALE: default: s->val[OPT_MODE].s = strdup (mode_list[2]); } /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_RESOLUTION].constraint.range = &s->hw->dpi_range; s->val[OPT_RESOLUTION].w = (s->hw->scanio.scan_x_resolution > s->hw->scanio.scan_y_resolution) ? s->hw->scanio.scan_x_resolution : s->hw->scanio.scan_y_resolution; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Calculate the x and y millimetre coordinates from the scanio. */ x0 = SANE_FIX (s->hw->scanio.scan_x_origin / TWELVEHUNDS_PER_MM); y0 = SANE_FIX (s->hw->scanio.scan_y_origin / TWELVEHUNDS_PER_MM); x1 = SANE_FIX ((s->hw->scanio.scan_x_origin + s->hw->scanio.scan_width) / TWELVEHUNDS_PER_MM); y1 = SANE_FIX ((s->hw->scanio.scan_y_origin + s->hw->scanio.scan_height) / TWELVEHUNDS_PER_MM); /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->val[OPT_TL_X].w = x0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->val[OPT_TL_Y].w = y0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->val[OPT_BR_X].w = x1; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; s->val[OPT_BR_Y].w = y1; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &s7_range; s->val[OPT_BRIGHTNESS].w = s->hw->scanio.scan_brightness - 128; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_INT; s->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &s7_range; s->val[OPT_CONTRAST].w = s->hw->scanio.scan_contrast - 128; return SANE_STATUS_GOOD; } static SANE_Status do_cancel (PINT_Scanner *s) { /* FIXME: PINT doesn't have any good way to cancel ScanJets right now. */ #define gobble_up_buf_len 1024 char buf[gobble_up_buf_len]; /* Send the restart code. */ buf[0] = ioctl (s->fd, SCIOCRESTART, 0); if (!s->scanning) return SANE_STATUS_CANCELLED; s->scanning = SANE_FALSE; /* Read to the end of the file. */ while (read (s->fd, buf, gobble_up_buf_len) > 0) ; #undef gobble_up_buf_len /* Finally, close the file descriptor. */ if (s->fd >= 0) { close (s->fd); s->fd = -1; } return SANE_STATUS_CANCELLED; } SANE_Status sane_init (SANE_Int *version_code, SANE_Auth_Callback authorize) { char dev_name[PATH_MAX]; size_t len; FILE *fp; DBG_INIT(); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (PINT_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ attach ("/dev/scanner", 0); return SANE_STATUS_GOOD; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ attach (dev_name, 0); } fclose (fp); return SANE_STATUS_GOOD; } void sane_exit (void) { PINT_Device *dev, *next; for (dev = first_dev; dev; dev = next) { next = dev->next; free ((void *) dev->sane.name); free (dev); } } SANE_Status sane_get_devices (const SANE_Device ***device_list, SANE_Bool local_only) { static const SANE_Device **devlist = 0; PINT_Device *dev; int i; if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle *handle) { SANE_Status status; PINT_Device *dev; PINT_Scanner *s; if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; if (!dev) { status = attach (devicename, &dev); if (status != SANE_STATUS_GOOD) return status; } } else /* empty devicename -> use first device */ dev = first_dev; if (!dev) return SANE_STATUS_INVAL; s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->hw = dev; s->fd = -1; init_options (s); /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { PINT_Scanner *prev, *s; /* 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) { DBG(1, "close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (s->scanning) do_cancel (handle); if (prev) prev->next = s->next; else first_handle = s->next; free (handle); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { PINT_Scanner *s = handle; if ((unsigned) option >= NUM_OPTIONS) return 0; return s->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int *info) { PINT_Scanner *s = handle; SANE_Status status; SANE_Word cap; if (info) *info = 0; if (s->scanning) return SANE_STATUS_DEVICE_BUSY; if (option >= NUM_OPTIONS) return SANE_STATUS_INVAL; cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) return SANE_STATUS_INVAL; if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_BRIGHTNESS: case OPT_CONTRAST: *(SANE_Word *) val = s->val[option].w; return SANE_STATUS_GOOD; /* string options: */ case OPT_MODE: strcpy (val, s->val[option].s); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) return SANE_STATUS_INVAL; status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { /* (mostly) side-effect-free word options: */ case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: if (info) *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_NUM_OPTS: case OPT_BRIGHTNESS: case OPT_CONTRAST: s->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; case OPT_MODE: if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return SANE_STATUS_GOOD; } } return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters *params) { PINT_Scanner *s = handle; struct scan_io scanio; if (!s->scanning) { u_long x0, y0, width, height; const char *mode; /* Grab the scanio for this device. */ if (s->fd < 0) { s->fd = open (s->hw->sane.name, O_RDONLY, 0); if (s->fd < 0) { DBG(1, "open of %s failed: %s\n", s->hw->sane.name, strerror (errno)); return SANE_STATUS_INVAL; } } if (ioctl (s->fd, SCIOCGET, &scanio) < 0) { DBG(1, "getting scanner state failed: %s", strerror (errno)); return SANE_STATUS_INVAL; } memset (&s->params, 0, sizeof (s->params)); /* FIXME: there is some lossage here: the parameters change due to roundoff errors between converting to fixed point millimetres and back. */ x0 = SANE_UNFIX (s->val[OPT_TL_X].w * TWELVEHUNDS_PER_MM); y0 = SANE_UNFIX (s->val[OPT_TL_Y].w * TWELVEHUNDS_PER_MM); width = SANE_UNFIX ((s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) * TWELVEHUNDS_PER_MM); height = SANE_UNFIX ((s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) * TWELVEHUNDS_PER_MM); /* x and y dpi: */ scanio.scan_x_resolution = s->val[OPT_RESOLUTION].w; scanio.scan_y_resolution = s->val[OPT_RESOLUTION].w; /* set scan extents, in 1/1200'ths of an inch */ scanio.scan_x_origin = x0; scanio.scan_y_origin = y0; scanio.scan_width = width; scanio.scan_height = height; /* brightness and contrast */ scanio.scan_brightness = s->val[OPT_BRIGHTNESS].w + 128; scanio.scan_contrast = s->val[OPT_CONTRAST].w + 128; /* set the scan image mode */ mode = s->val[OPT_MODE].s; if (!strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART)) { s->params.format = SANE_FRAME_GRAY; scanio.scan_image_mode = SIM_BINARY_MONOCHROME; } else if (!strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE)) { s->params.format = SANE_FRAME_GRAY; scanio.scan_image_mode = SIM_DITHERED_MONOCHROME; } else if (!strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY)) { s->params.format = SANE_FRAME_GRAY; scanio.scan_image_mode = SIM_GRAYSCALE; } else if (!strcmp (mode, "Red")) { s->params.format = SANE_FRAME_RED; scanio.scan_image_mode = SIM_RED; } else if (!strcmp (mode, "Green")) { s->params.format = SANE_FRAME_GREEN; scanio.scan_image_mode = SIM_GREEN; } else if (!strcmp (mode, "Blue")) { s->params.format = SANE_FRAME_BLUE; scanio.scan_image_mode = SIM_BLUE; } else { s->params.format = SANE_FRAME_RGB; scanio.scan_image_mode = SIM_COLOR; } /* inquire resulting size of image after setting it up */ if (ioctl (s->fd, SCIOCSET, &scanio) < 0) { DBG(1, "setting scan parameters failed: %s", strerror (errno)); return SANE_STATUS_INVAL; } if (ioctl (s->fd, SCIOCGET, &scanio) < 0) { DBG(1, "getting scan parameters failed: %s", strerror (errno)); return SANE_STATUS_INVAL; } /* Save all the PINT-computed values. */ s->params.pixels_per_line = scanio.scan_pixels_per_line; s->params.bytes_per_line = (scanio.scan_bits_per_pixel * scanio.scan_pixels_per_line + 7) / 8; s->params.lines = scanio.scan_lines; s->params.depth = (scanio.scan_image_mode == SIM_COLOR) ? scanio.scan_bits_per_pixel / 3 : scanio.scan_bits_per_pixel; /* FIXME: this will need to be different for hand scanners. */ s->params.last_frame = SANE_TRUE; } if (params) *params = s->params; return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { PINT_Scanner *s = handle; SANE_Status status; /* First make sure we have a current parameter set. This call actually uses the PINT driver to do the calculations, so we trust its results. */ status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; DBG(1, "%d pixels per line, %d bytes, %d lines high, dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line, s->params.lines, s->val[OPT_RESOLUTION].w); /* The scan is triggered in sane_read. */ s->scanning = SANE_TRUE; return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { PINT_Scanner *s = handle; ssize_t nread; *len = 0; if (!s->scanning) return do_cancel (s); /* Verrry simple. Just suck up all the data PINT passes to us. */ nread = read (s->fd, buf, max_len); if (nread <= 0) { do_cancel (s); return (nread == 0) ? SANE_STATUS_EOF : SANE_STATUS_IO_ERROR; } *len = nread; return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { PINT_Scanner *s = handle; do_cancel (s); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int *fd) { return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/plustek-usbmap.c0000666000000000000000000001431613615534521015715 00000000000000/*............................................................................. * Project : SANE library for Plustek flatbed scanners. *............................................................................. */ /** @file plustek-usbmap.c * @brief Creating and manipulating lookup tables. * * Based on sources acquired from Plustek Inc.
* Copyright (C) 2001-2007 Gerhard Jaeger * * History: * - 0.40 - starting version of the USB support * - 0.41 - fixed brightness problem for lineart mode * - 0.42 - removed preset of linear gamma tables * - 0.43 - no changes * - 0.44 - map inversion for negatatives now only upon user request * - 0.45 - no changes * - 0.46 - no changes * - 0.47 - cleanup work * - 0.48 - added support for binary from color scans * - 0.49 - changed usb_MapDownload * - 0.50 - cleanup * - 0.51 - no changes * - 0.52 - no changes * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #define _MAP_SIZE 4096 static SANE_Byte a_bMap[_MAP_SIZE * 3]; /** adjust acording to brightness and contrast */ static void usb_MapAdjust( Plustek_Device *dev ) { int i, tabLen; double b, c, tmp; tabLen = _MAP_SIZE; /* adjust brightness (b) and contrast (c) using the function: * * s(x,y) = (s(x,y) + b) * c * b = [-127, 127] * c = [0,2] */ b = ((double)dev->scanning.sParam.brightness * 192.0)/100.0; c = ((double)dev->scanning.sParam.contrast + 100.0)/100.0; DBG( _DBG_INFO, "* brightness = %i -> %i\n", dev->scanning.sParam.brightness, (u_char)b); DBG( _DBG_INFO, "* contrast = %i -> %.3f\n", dev->scanning.sParam.contrast, c); if( dev->scanning.sParam.brightness == 0 && dev->scanning.sParam.contrast ) return; for( i = 0; i < tabLen; i++ ) { tmp = ((double)(a_bMap[i] + b)) * c; if( tmp < 0 ) tmp = 0; if( tmp > 255 ) tmp = 255; a_bMap[i] = (u_char)tmp; tmp = ((double)(a_bMap[tabLen+i] + b)) * c; if( tmp < 0 ) tmp = 0; if( tmp > 255 ) tmp = 255; a_bMap[tabLen+i] = (u_char)tmp; tmp = ((double)(a_bMap[tabLen*2+i] + b)) * c; if( tmp < 0 ) tmp = 0; if( tmp > 255 ) tmp = 255; a_bMap[tabLen*2+i] = (u_char)tmp; } } /** */ static SANE_Bool usb_MapDownload( Plustek_Device *dev ) { ScanDef *scanning = &dev->scanning; DCapsDef *sc = &dev->usbDev.Caps; int color; int i, threshold; SANE_Byte value; SANE_Bool fInverse = 0; DBG( _DBG_INFO, "usb_MapDownload()\n" ); /* the maps are have been already set */ /* do the brightness and contrast adjustment ... */ if( scanning->sParam.bDataType != SCANDATATYPE_BW ) usb_MapAdjust( dev ); if( !usbio_WriteReg( dev->fd, 7, 0)) return SANE_FALSE; /* we download all the time all three color maps, as we run * into trouble elsewhere on CanoScan models using gray mode */ for( color = 0; color < 3; color++) { /* select color */ value = (color << 2)+2; /* set gamma color selector */ usbio_WriteReg( dev->fd, 0x03, value ); usbio_WriteReg( dev->fd, 0x04, 0 ); usbio_WriteReg( dev->fd, 0x05, 0 ); /* write the gamma table entry to merlin */ if((scanning->sParam.bDataType == SCANDATATYPE_BW) || (scanning->fGrayFromColor > 7 )) { threshold = (int)((double)scanning->sParam.brightness * (_MAP_SIZE/200.0)) + (_MAP_SIZE/2); threshold = _MAP_SIZE - threshold; if(threshold < 0) threshold = 0; if(threshold > (int)_MAP_SIZE) threshold = _MAP_SIZE; DBG(_DBG_INFO, "* Threshold is at %u brightness=%i\n", threshold, scanning->sParam.brightness ); for(i = 0; i < threshold; i++) a_bMap[color*_MAP_SIZE + i] = 0; for(i = threshold; i < _MAP_SIZE; i++) a_bMap[color*_MAP_SIZE + i] = 255; fInverse = 1; } else { fInverse = 0; } if( /*scanning->dwFlag & SCANFLAG_Pseudo48 && */ (scanning->sParam.bSource == SOURCE_Negative) && (sc->workaroundFlag &_WAF_INV_NEGATIVE_MAP)) { fInverse ^= 1; } if( fInverse ) { u_char map[_MAP_SIZE]; u_char *pMap = a_bMap+color*_MAP_SIZE; DBG( _DBG_INFO, "* Inverting Map\n" ); for( i = 0; i < _MAP_SIZE; i++, pMap++ ) map[i] = ~*pMap; sanei_lm983x_write( dev->fd, 0x06, map, _MAP_SIZE, SANE_FALSE ); } else { DBG( _DBG_INFO, "* downloading map %u...\n", color ); sanei_lm983x_write( dev->fd, 0x06, a_bMap+color*_MAP_SIZE, _MAP_SIZE, SANE_FALSE ); } } /* for each color */ DBG( _DBG_INFO, "usb_MapDownload() done.\n" ); return SANE_TRUE; } /* END PLUSTEK-USBMAP.C .....................................................*/ sane-backends-1.0.29/backend/test.c0000666000000000000000000026353613615534521013732 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002-2006 Henning Meier-Geinitz Changes according to the sanei_thread usage by Gerhard Jaeger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This backend is for testing frontends. */ #define BUILD 28 #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include "../include/_stdint.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_thread.h" #define BACKEND_NAME test #include "../include/sane/sanei_backend.h" #include "test.h" #include "test-picture.c" #define TEST_CONFIG_FILE "test.conf" static SANE_Bool inited = SANE_FALSE; static SANE_Device **sane_device_list = 0; static Test_Device *first_test_device = 0; static SANE_Range geometry_range = { SANE_FIX (0.0), SANE_FIX (200.0), SANE_FIX (1.0) }; static SANE_Range resolution_range = { SANE_FIX (1.0), SANE_FIX (1200.0), SANE_FIX (1.0) }; static SANE_Range ppl_loss_range = { 0, 128, 1 }; static SANE_Range read_limit_size_range = { 1, 64 * 1024, /* 64 KB ought to be enough for everyone :-) */ 1 }; static SANE_Range read_delay_duration_range = { 1000, 200 * 1000, /* 200 msec */ 1000 }; static SANE_Range int_constraint_range = { 4, 192, 2 }; static SANE_Range fixed_constraint_range = { SANE_FIX (-42.17), SANE_FIX (32767.9999), SANE_FIX (2.0) }; static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, 0 }; static SANE_String_Const order_list[] = { "RGB", "RBG", "GBR", "GRB", "BRG", "BGR", 0 }; static SANE_String_Const test_picture_list[] = { SANE_I18N ("Solid black"), SANE_I18N ("Solid white"), SANE_I18N ("Color pattern"), SANE_I18N ("Grid"), 0 }; static SANE_String_Const read_status_code_list[] = { SANE_I18N ("Default"), "SANE_STATUS_UNSUPPORTED", "SANE_STATUS_CANCELLED", "SANE_STATUS_DEVICE_BUSY", "SANE_STATUS_INVAL", "SANE_STATUS_EOF", "SANE_STATUS_JAMMED", "SANE_STATUS_NO_DOCS", "SANE_STATUS_COVER_OPEN", "SANE_STATUS_IO_ERROR", "SANE_STATUS_NO_MEM", "SANE_STATUS_ACCESS_DENIED", 0 }; static SANE_Int depth_list[] = { 3, 1, 8, 16 }; static SANE_Int int_constraint_word_list[] = { 9, -42, -8, 0, 17, 42, 256, 65536, 256 * 256 * 256, 256 * 256 * 256 * 64 }; static SANE_Int fixed_constraint_word_list[] = { 4, SANE_FIX (-32.7), SANE_FIX (12.1), SANE_FIX (42.0), SANE_FIX (129.5) }; static SANE_String_Const string_constraint_string_list[] = { SANE_I18N ("First entry"), SANE_I18N ("Second entry"), SANE_I18N ("This is the very long third entry. Maybe the frontend has an idea how to " "display it"), 0 }; static SANE_String_Const string_constraint_long_string_list[] = { SANE_I18N ("First entry"), SANE_I18N ("Second entry"), "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", 0 }; static SANE_Int int_array[] = { -17, 0, -5, 42, 91, 256 * 256 * 256 * 64 }; static SANE_Int int_array_constraint_range[] = { 48, 6, 4, 92, 190, 16 }; static SANE_Int int_array_constraint_word_list[] = { -42, 0, -8, 17, 42, 42 }; static SANE_String_Const source_list[] = { SANE_I18N ("Flatbed"), SANE_I18N ("Automatic Document Feeder"), 0 }; static double random_factor; /* use for fuzzyness of parameters */ /* initial values */ static SANE_Word init_number_of_devices = 2; static SANE_Fixed init_tl_x = SANE_FIX (0.0); static SANE_Fixed init_tl_y = SANE_FIX (0.0); static SANE_Fixed init_br_x = SANE_FIX (80.0); static SANE_Fixed init_br_y = SANE_FIX (100.0); static SANE_Word init_resolution = 50; static SANE_String init_mode =SANE_VALUE_SCAN_MODE_GRAY; static SANE_Word init_depth = 8; static SANE_Bool init_hand_scanner = SANE_FALSE; static SANE_Bool init_three_pass = SANE_FALSE; static SANE_String init_three_pass_order = "RGB"; static SANE_String init_scan_source = "Flatbed"; static SANE_String init_test_picture = "Solid black"; static SANE_Bool init_invert_endianess = SANE_FALSE; static SANE_Bool init_read_limit = SANE_FALSE; static SANE_Word init_read_limit_size = 1; static SANE_Bool init_read_delay = SANE_FALSE; static SANE_Word init_read_delay_duration = 1000; static SANE_String init_read_status_code = "Default"; static SANE_Bool init_fuzzy_parameters = SANE_FALSE; static SANE_Word init_ppl_loss = 0; static SANE_Bool init_non_blocking = SANE_FALSE; static SANE_Bool init_select_fd = SANE_FALSE; static SANE_Bool init_enable_test_options = SANE_FALSE; static SANE_String init_string = "This is the contents of the string option. " "Fill some more words to see how the frontend behaves."; static SANE_String init_string_constraint_string_list = "First entry"; static SANE_String init_string_constraint_long_string_list = "First entry"; /* Test if this machine is little endian (from coolscan.c) */ static SANE_Bool little_endian (void) { SANE_Int testvalue = 255; uint8_t *firstbyte = (uint8_t *) & testvalue; if (*firstbyte == 255) return SANE_TRUE; return SANE_FALSE; } static void swap_double (double *a, double *b) { double c; c = *a; *a = *b; *b = c; return; } static size_t max_string_size (const SANE_String_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; } static SANE_Bool check_handle (SANE_Handle handle) { Test_Device *test_device = first_test_device; while (test_device) { if (test_device == (Test_Device *) handle) return SANE_TRUE; test_device = test_device->next; } return SANE_FALSE; } static SANE_Status init_options (Test_Device * test_device) { SANE_Option_Descriptor *od; DBG (2, "init_options: test_device=%p\n", (void *) test_device); /* opt_num_opts */ od = &test_device->opt[opt_num_opts]; od->name = ""; od->title = SANE_TITLE_NUM_OPTIONS; od->desc = SANE_DESC_NUM_OPTIONS; od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_num_opts].w = num_options; test_device->loaded[opt_num_opts] = 1; /* opt_mode_group */ od = &test_device->opt[opt_mode_group]; od->name = ""; od->title = SANE_I18N ("Scan Mode"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = 0; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_mode_group].w = 0; /* opt_mode */ od = &test_device->opt[opt_mode]; od->name = SANE_NAME_SCAN_MODE; od->title = SANE_TITLE_SCAN_MODE; od->desc = SANE_DESC_SCAN_MODE; od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = max_string_size (mode_list); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = mode_list; test_device->val[opt_mode].s = malloc (od->size); if (!test_device->val[opt_mode].s) return SANE_STATUS_NO_MEM; strcpy (test_device->val[opt_mode].s, init_mode); /* opt_depth */ od = &test_device->opt[opt_depth]; od->name = SANE_NAME_BIT_DEPTH; od->title = SANE_TITLE_BIT_DEPTH; od->desc = SANE_DESC_BIT_DEPTH; od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_WORD_LIST; od->constraint.word_list = depth_list; test_device->val[opt_depth].w = init_depth; /* opt_hand_scanner */ od = &test_device->opt[opt_hand_scanner]; od->name = "hand-scanner"; od->title = SANE_I18N ("Hand-scanner simulation"); od->desc = SANE_I18N ("Simulate a hand-scanner. Hand-scanners do not " "know the image height a priori. Instead, they " "return a height of -1. Setting this option allows one " "to test whether a frontend can handle this " "correctly. This option also enables a fixed width " "of 11 cm."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_hand_scanner].w = init_hand_scanner; /* opt_three_pass */ od = &test_device->opt[opt_three_pass]; od->name = "three-pass"; od->title = SANE_I18N ("Three-pass simulation"); od->desc = SANE_I18N ("Simulate a three-pass scanner. In color mode, three " "frames are transmitted."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; if (strcmp (init_mode, SANE_VALUE_SCAN_MODE_COLOR) != 0) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_three_pass].w = init_three_pass; /* opt_three_pass_order */ od = &test_device->opt[opt_three_pass_order]; od->name = "three-pass-order"; od->title = SANE_I18N ("Set the order of frames"); od->desc = SANE_I18N ("Set the order of frames in three-pass color mode."); od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = max_string_size (order_list); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; if (strcmp (init_mode, SANE_VALUE_SCAN_MODE_COLOR) != 0) od->cap |= SANE_CAP_INACTIVE; if (!init_three_pass) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = order_list; test_device->val[opt_three_pass_order].s = malloc (od->size); if (!test_device->val[opt_three_pass_order].s) return SANE_STATUS_NO_MEM; strcpy (test_device->val[opt_three_pass_order].s, init_three_pass_order); /* opt_resolution */ od = &test_device->opt[opt_resolution]; od->name = SANE_NAME_SCAN_RESOLUTION; od->title = SANE_TITLE_SCAN_RESOLUTION; od->desc = SANE_DESC_SCAN_RESOLUTION; od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_DPI; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &resolution_range; test_device->val[opt_resolution].w = init_resolution; /* opt_scan_source */ od = &test_device->opt[opt_scan_source]; od->name = SANE_NAME_SCAN_SOURCE; od->title = SANE_TITLE_SCAN_SOURCE; od->desc = SANE_I18N("If Automatic Document Feeder is selected, the feeder will be 'empty' after 10 scans."); od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = max_string_size (source_list); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = source_list; test_device->val[opt_scan_source].s = malloc (od->size); if (!test_device->val[opt_scan_source].s) return SANE_STATUS_NO_MEM; strcpy (test_device->val[opt_scan_source].s, init_scan_source); /* opt_special_group */ od = &test_device->opt[opt_special_group]; od->name = ""; od->title = SANE_I18N ("Special Options"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = 0; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_special_group].w = 0; /* opt_test_picture */ od = &test_device->opt[opt_test_picture]; od->name = "test-picture"; od->title = SANE_I18N ("Select the test picture"); od->desc = SANE_I18N ("Select the kind of test picture. Available options:\n" "Solid black: fills the whole scan with black.\n" "Solid white: fills the whole scan with white.\n" "Color pattern: draws various color test patterns " "depending on the mode.\n" "Grid: draws a black/white grid with a width and " "height of 10 mm per square."); od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = max_string_size (test_picture_list); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = test_picture_list; test_device->val[opt_test_picture].s = malloc (od->size); if (!test_device->val[opt_test_picture].s) return SANE_STATUS_NO_MEM; strcpy (test_device->val[opt_test_picture].s, init_test_picture); /* opt_invert_endianness */ od = &test_device->opt[opt_invert_endianess]; od->name = "invert-endianess"; od->title = SANE_I18N ("Invert endianness"); od->desc = SANE_I18N ("Exchange upper and lower byte of image data in 16 " "bit modes. This option can be used to test the 16 " "bit modes of frontends, e.g. if the frontend uses " "the correct endianness."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_invert_endianess].w = init_invert_endianess; /* opt_read_limit */ od = &test_device->opt[opt_read_limit]; od->name = "read-limit"; od->title = SANE_I18N ("Read limit"); od->desc = SANE_I18N ("Limit the amount of data transferred with each " "call to sane_read()."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_read_limit].w = init_read_limit; /* opt_read_limit_size */ od = &test_device->opt[opt_read_limit_size]; od->name = "read-limit-size"; od->title = SANE_I18N ("Size of read-limit"); od->desc = SANE_I18N ("The (maximum) amount of data transferred with each " "call to sane_read()."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; if (!init_read_limit) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &read_limit_size_range; test_device->val[opt_read_limit_size].w = init_read_limit_size; /* opt_read_delay */ od = &test_device->opt[opt_read_delay]; od->name = "read-delay"; od->title = SANE_I18N ("Read delay"); od->desc = SANE_I18N ("Delay the transfer of data to the pipe."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_read_delay].w = init_read_delay; /* opt_read_delay_duration */ od = &test_device->opt[opt_read_delay_duration]; od->name = "read-delay-duration"; od->title = SANE_I18N ("Duration of read-delay"); od->desc = SANE_I18N ("How long to wait after transferring each buffer of " "data through the pipe."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_MICROSECOND; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; if (!init_read_delay) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &read_delay_duration_range; test_device->val[opt_read_delay_duration].w = init_read_delay_duration; /* opt_read_status_code */ od = &test_device->opt[opt_read_status_code]; od->name = "read-return-value"; od->title = SANE_I18N ("Return-value of sane_read"); od->desc = SANE_I18N ("Select the return-value of sane_read(). \"Default\" " "is the normal handling for scanning. All other status " "codes are for testing how the frontend handles them."); od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = max_string_size (read_status_code_list); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = read_status_code_list; test_device->val[opt_read_status_code].s = malloc (od->size); if (!test_device->val[opt_read_status_code].s) return SANE_STATUS_NO_MEM; strcpy (test_device->val[opt_read_status_code].s, init_read_status_code); /* opt_ppl_loss */ od = &test_device->opt[opt_ppl_loss]; od->name = "ppl-loss"; od->title = SANE_I18N ("Loss of pixels per line"); od->desc = SANE_I18N ("The number of pixels that are wasted at the end of each " "line."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_PIXEL; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &ppl_loss_range; test_device->val[opt_ppl_loss].w = init_ppl_loss; /* opt_fuzzy_parameters */ od = &test_device->opt[opt_fuzzy_parameters]; od->name = "fuzzy-parameters"; od->title = SANE_I18N ("Fuzzy parameters"); od->desc = SANE_I18N ("Return fuzzy lines and bytes per line when " "sane_parameters() is called before sane_start()."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_fuzzy_parameters].w = init_fuzzy_parameters; /* opt_non_blocking */ od = &test_device->opt[opt_non_blocking]; od->name = "non-blocking"; od->title = SANE_I18N ("Use non-blocking IO"); od->desc = SANE_I18N ("Use non-blocking IO for sane_read() if supported " "by the frontend."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_non_blocking].w = init_non_blocking; /* opt_select_fd */ od = &test_device->opt[opt_select_fd]; od->name = "select-fd"; od->title = SANE_I18N ("Offer select file descriptor"); od->desc = SANE_I18N ("Offer a select filedescriptor for detecting if " "sane_read() will return data."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_select_fd].w = init_select_fd; /* opt_enable_test_options */ od = &test_device->opt[opt_enable_test_options]; od->name = "enable-test-options"; od->title = SANE_I18N ("Enable test options"); od->desc = SANE_I18N ("Enable various test options. This is for testing " "the ability of frontends to view and modify all the " "different SANE option types."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_enable_test_options].w = init_enable_test_options; /* opt_print_options */ od = &test_device->opt[opt_print_options]; od->name = "print-options"; od->title = SANE_I18N ("Print options"); od->desc = SANE_I18N ("Print a list of all options."); od->type = SANE_TYPE_BUTTON; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.string_list = 0; test_device->val[opt_print_options].w = 0; /* opt_geometry_group */ od = &test_device->opt[opt_geometry_group]; od->name = ""; od->title = SANE_I18N ("Geometry"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = 0; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_geometry_group].w = 0; /* opt_tl_x */ od = &test_device->opt[opt_tl_x]; od->name = SANE_NAME_SCAN_TL_X; od->title = SANE_TITLE_SCAN_TL_X; od->desc = SANE_DESC_SCAN_TL_X; od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_MM; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &geometry_range; test_device->val[opt_tl_x].w = init_tl_x; /* opt_tl_y */ od = &test_device->opt[opt_tl_y]; od->name = SANE_NAME_SCAN_TL_Y; od->title = SANE_TITLE_SCAN_TL_Y; od->desc = SANE_DESC_SCAN_TL_Y; od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_MM; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &geometry_range; test_device->val[opt_tl_y].w = init_tl_y; /* opt_br_x */ od = &test_device->opt[opt_br_x]; od->name = SANE_NAME_SCAN_BR_X; od->title = SANE_TITLE_SCAN_BR_X; od->desc = SANE_DESC_SCAN_BR_X; od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_MM; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &geometry_range; test_device->val[opt_br_x].w = init_br_x; /* opt_br_y */ od = &test_device->opt[opt_br_y]; od->name = SANE_NAME_SCAN_BR_Y; od->title = SANE_TITLE_SCAN_BR_Y; od->desc = SANE_DESC_SCAN_BR_Y; od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_MM; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &geometry_range; test_device->val[opt_br_y].w = init_br_y; /* opt_bool_group */ od = &test_device->opt[opt_bool_group]; od->name = ""; od->title = SANE_I18N ("Bool test options"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = SANE_CAP_ADVANCED; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_bool_group].w = 0; /* opt_bool_soft_select_soft_detect */ od = &test_device->opt[opt_bool_soft_select_soft_detect]; od->name = "bool-soft-select-soft-detect"; od->title = SANE_I18N ("(1/6) Bool soft select soft detect"); od->desc = SANE_I18N ("(1/6) Bool test option that has soft select and soft " "detect (and advanced) capabilities. That's just a " "normal bool option."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_bool_soft_select_soft_detect].w = SANE_FALSE; /* opt_bool_hard_select_soft_detect */ od = &test_device->opt[opt_bool_hard_select_soft_detect]; od->name = "bool-hard-select-soft-detect"; od->title = SANE_I18N ("(2/6) Bool hard select soft detect"); od->desc = SANE_I18N ("(2/6) Bool test option that has hard select and soft " "detect (and advanced) capabilities. That means the " "option can't be set by the frontend but by the user " "(e.g. by pressing a button at the device)."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_bool_hard_select_soft_detect].w = SANE_FALSE; /* opt_bool_hard_select */ od = &test_device->opt[opt_bool_hard_select]; od->name = "bool-hard-select"; od->title = SANE_I18N ("(3/6) Bool hard select"); od->desc = SANE_I18N ("(3/6) Bool test option that has hard select " "(and advanced) capabilities. That means the option " "can't be set by the frontend but by the user " "(e.g. by pressing a button at the device) and can't " "be read by the frontend."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_bool_hard_select].w = SANE_FALSE; /* opt_bool_soft_detect */ od = &test_device->opt[opt_bool_soft_detect]; od->name = "bool-soft-detect"; od->title = SANE_I18N ("(4/6) Bool soft detect"); od->desc = SANE_I18N ("(4/6) Bool test option that has soft detect " "(and advanced) capabilities. That means the option " "is read-only."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_bool_soft_detect].w = SANE_FALSE; /* opt_bool_soft_select_soft_detect_emulated */ od = &test_device->opt[opt_bool_soft_select_soft_detect_emulated]; od->name = "bool-soft-select-soft-detect-emulated"; od->title = SANE_I18N ("(5/6) Bool soft select soft detect emulated"); od->desc = SANE_I18N ("(5/6) Bool test option that has soft select, soft " "detect, and emulated (and advanced) capabilities."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED | SANE_CAP_EMULATED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_bool_soft_select_soft_detect_emulated].w = SANE_FALSE; /* opt_bool_soft_select_soft_detect_auto */ od = &test_device->opt[opt_bool_soft_select_soft_detect_auto]; od->name = "bool-soft-select-soft-detect-auto"; od->title = SANE_I18N ("(6/6) Bool soft select soft detect auto"); od->desc = SANE_I18N ("(6/6) Bool test option that has soft select, soft " "detect, and automatic (and advanced) capabilities. " "This option can be automatically set by the backend."); od->type = SANE_TYPE_BOOL; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED | SANE_CAP_AUTOMATIC; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_bool_soft_select_soft_detect_auto].w = SANE_FALSE; /* opt_int_group */ od = &test_device->opt[opt_int_group]; od->name = ""; od->title = SANE_I18N ("Int test options"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = SANE_CAP_ADVANCED; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_int_group].w = 0; /* opt_int */ od = &test_device->opt[opt_int]; od->name = "int"; od->title = SANE_I18N ("(1/6) Int"); od->desc = SANE_I18N ("(1/6) Int test option with no unit and no " "constraint set."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_int].w = 42; /* opt_int_constraint_range */ od = &test_device->opt[opt_int_constraint_range]; od->name = "int-constraint-range"; od->title = SANE_I18N ("(2/6) Int constraint range"); od->desc = SANE_I18N ("(2/6) Int test option with unit pixel and " "constraint range set. Minimum is 4, maximum 192, and " "quant is 2."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_PIXEL; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &int_constraint_range; test_device->val[opt_int_constraint_range].w = 26; /* opt_int_constraint_word_list */ od = &test_device->opt[opt_int_constraint_word_list]; od->name = "int-constraint-word-list"; od->title = SANE_I18N ("(3/6) Int constraint word list"); od->desc = SANE_I18N ("(3/6) Int test option with unit bits and " "constraint word list set."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_BIT; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_WORD_LIST; od->constraint.word_list = int_constraint_word_list; test_device->val[opt_int_constraint_word_list].w = 42; /* opt_int_array */ od = &test_device->opt[opt_int_array]; od->name = "int-constraint-array"; od->title = SANE_I18N ("(4/6) Int array"); od->desc = SANE_I18N ("(4/6) Int test option with unit mm and using " "an array without constraints."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_MM; od->size = 6 * sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_int_array].wa = &int_array[0]; /* opt_int_array_constraint_range */ od = &test_device->opt[opt_int_array_constraint_range]; od->name = "int-constraint-array-constraint-range"; od->title = SANE_I18N ("(5/6) Int array constraint range"); od->desc = SANE_I18N ("(5/6) Int test option with unit dpi and using " "an array with a range constraint. Minimum is 4, " "maximum 192, and quant is 2."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_DPI; od->size = 6 * sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &int_constraint_range; test_device->val[opt_int_array_constraint_range].wa = &int_array_constraint_range[0]; /* opt_int_array_constraint_word_list */ od = &test_device->opt[opt_int_array_constraint_word_list]; od->name = "int-constraint-array-constraint-word-list"; od->title = SANE_I18N ("(6/6) Int array constraint word list"); od->desc = SANE_I18N ("(6/6) Int test option with unit percent and using " "an array with a word list constraint."); od->type = SANE_TYPE_INT; od->unit = SANE_UNIT_PERCENT; od->size = 6 * sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_WORD_LIST; od->constraint.word_list = int_constraint_word_list; test_device->val[opt_int_array_constraint_word_list].wa = &int_array_constraint_word_list[0]; /* opt_fixed_group */ od = &test_device->opt[opt_fixed_group]; od->name = ""; od->title = SANE_I18N ("Fixed test options"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = SANE_CAP_ADVANCED; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_fixed_group].w = 0; /* opt_fixed */ od = &test_device->opt[opt_fixed]; od->name = "fixed"; od->title = SANE_I18N ("(1/3) Fixed"); od->desc = SANE_I18N ("(1/3) Fixed test option with no unit and no " "constraint set."); od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_fixed].w = SANE_FIX (42.0); /* opt_fixed_constraint_range */ od = &test_device->opt[opt_fixed_constraint_range]; od->name = "fixed-constraint-range"; od->title = SANE_I18N ("(2/3) Fixed constraint range"); od->desc = SANE_I18N ("(2/3) Fixed test option with unit microsecond and " "constraint range set. Minimum is -42.17, maximum " "32767.9999, and quant is 2.0."); od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_MICROSECOND; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_RANGE; od->constraint.range = &fixed_constraint_range; test_device->val[opt_fixed_constraint_range].w = SANE_FIX (41.83); /* opt_fixed_constraint_word_list */ od = &test_device->opt[opt_fixed_constraint_word_list]; od->name = "fixed-constraint-word-list"; od->title = SANE_I18N ("(3/3) Fixed constraint word list"); od->desc = SANE_I18N ("(3/3) Fixed test option with no unit and " "constraint word list set."); od->type = SANE_TYPE_FIXED; od->unit = SANE_UNIT_NONE; od->size = sizeof (SANE_Word); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT | SANE_CAP_ADVANCED; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_WORD_LIST; od->constraint.word_list = fixed_constraint_word_list; test_device->val[opt_fixed_constraint_word_list].w = SANE_FIX (42.0); /* opt_string_group */ od = &test_device->opt[opt_string_group]; od->name = ""; od->title = SANE_I18N ("String test options"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = 0; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_string_group].w = 0; /* opt_string */ od = &test_device->opt[opt_string]; od->name = "string"; od->title = SANE_I18N ("(1/3) String"); od->desc = SANE_I18N ("(1/3) String test option without constraint."); od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = strlen (init_string) + 1; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.string_list = 0; test_device->val[opt_string].s = malloc (od->size); if (!test_device->val[opt_string].s) return SANE_STATUS_NO_MEM; strcpy (test_device->val[opt_string].s, init_string); /* opt_string_constraint_string_list */ od = &test_device->opt[opt_string_constraint_string_list]; od->name = "string-constraint-string-list"; od->title = SANE_I18N ("(2/3) String constraint string list"); od->desc = SANE_I18N ("(2/3) String test option with string list " "constraint."); od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = max_string_size (string_constraint_string_list); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = string_constraint_string_list; test_device->val[opt_string_constraint_string_list].s = malloc (od->size); if (!test_device->val[opt_string_constraint_string_list].s) return SANE_STATUS_NO_MEM; strcpy (test_device->val[opt_string_constraint_string_list].s, init_string_constraint_string_list); /* opt_string_constraint_long_string_list */ od = &test_device->opt[opt_string_constraint_long_string_list]; od->name = "string-constraint-long-string-list"; od->title = SANE_I18N ("(3/3) String constraint long string list"); od->desc = SANE_I18N ("(3/3) String test option with string list " "constraint. Contains some more entries..."); od->type = SANE_TYPE_STRING; od->unit = SANE_UNIT_NONE; od->size = max_string_size (string_constraint_long_string_list); od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_STRING_LIST; od->constraint.string_list = string_constraint_long_string_list; test_device->val[opt_string_constraint_long_string_list].s = malloc (od->size); if (!test_device->val[opt_string_constraint_long_string_list].s) return SANE_STATUS_NO_MEM; strcpy (test_device->val[opt_string_constraint_long_string_list].s, init_string_constraint_long_string_list); /* opt_button_group */ od = &test_device->opt[opt_button_group]; od->name = ""; od->title = SANE_I18N ("Button test options"); od->desc = ""; od->type = SANE_TYPE_GROUP; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = 0; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.range = 0; test_device->val[opt_button_group].w = 0; /* opt_button */ od = &test_device->opt[opt_button]; od->name = "button"; od->title = SANE_I18N ("(1/1) Button"); od->desc = SANE_I18N ("(1/1) Button test option. Prints some text..."); od->type = SANE_TYPE_BUTTON; od->unit = SANE_UNIT_NONE; od->size = 0; od->cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; if (init_enable_test_options == SANE_FALSE) od->cap |= SANE_CAP_INACTIVE; od->constraint_type = SANE_CONSTRAINT_NONE; od->constraint.string_list = 0; test_device->val[opt_button].w = 0; return SANE_STATUS_GOOD; } static SANE_Status read_option (SANE_String line, SANE_String option_string, parameter_type p_type, void *value) { SANE_String_Const cp; SANE_Char *word, *end; word = 0; cp = sanei_config_get_string (line, &word); if (!word) return SANE_STATUS_INVAL; if (strcmp (word, option_string) != 0) { free(word); return SANE_STATUS_INVAL; } free (word); word = 0; switch (p_type) { case param_none: return SANE_STATUS_GOOD; case param_bool: { cp = sanei_config_get_string (cp, &word); if (!word) return SANE_STATUS_INVAL; if (strlen (word) == 0) { DBG (3, "read_option: option `%s' requires parameter\n", option_string); return SANE_STATUS_INVAL; } if (strcmp (word, "true") != 0 && strcmp (word, "false") != 0) { DBG (3, "read_option: option `%s' requires parameter " "`true' or `false'\n", option_string); return SANE_STATUS_INVAL; } else if (strcmp (word, "true") == 0) *(SANE_Bool *) value = SANE_TRUE; else *(SANE_Bool *) value = SANE_FALSE; DBG (3, "read_option: set option `%s' to %s\n", option_string, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; } case param_int: { SANE_Int int_value; cp = sanei_config_get_string (cp, &word); if (!word) return SANE_STATUS_INVAL; errno = 0; int_value = (SANE_Int) strtol (word, &end, 0); if (end == word) { DBG (3, "read_option: option `%s' requires parameter\n", option_string); return SANE_STATUS_INVAL; } else if (errno) { DBG (3, "read_option: option `%s': can't parse parameter `%s' " "(%s)\n", option_string, word, strerror (errno)); return SANE_STATUS_INVAL; } else { DBG (3, "read_option: set option `%s' to %d\n", option_string, int_value); *(SANE_Int *) value = int_value; } break; } case param_fixed: { double double_value; SANE_Fixed fixed_value; cp = sanei_config_get_string (cp, &word); if (!word) return SANE_STATUS_INVAL; errno = 0; double_value = strtod (word, &end); if (end == word) { DBG (3, "read_option: option `%s' requires parameter\n", option_string); return SANE_STATUS_INVAL; } else if (errno) { DBG (3, "read_option: option `%s': can't parse parameter `%s' " "(%s)\n", option_string, word, strerror (errno)); return SANE_STATUS_INVAL; } else { DBG (3, "read_option: set option `%s' to %.0f\n", option_string, double_value); fixed_value = SANE_FIX (double_value); *(SANE_Fixed *) value = fixed_value; } break; } case param_string: { cp = sanei_config_get_string (cp, &word); if (!word) return SANE_STATUS_INVAL; if (strlen (word) == 0) { DBG (3, "read_option: option `%s' requires parameter\n", option_string); return SANE_STATUS_INVAL; } else { DBG (3, "read_option: set option `%s' to `%s'\n", option_string, word); *(SANE_String *) value = strdup (word); } break; } default: DBG (1, "read_option: unknown param_type %d\n", p_type); return SANE_STATUS_INVAL; } /* switch */ if (word) free (word); return SANE_STATUS_GOOD; } static SANE_Status reader_process (Test_Device * test_device, SANE_Int fd) { SANE_Status status; SANE_Word byte_count = 0, bytes_total; SANE_Byte *buffer = 0; ssize_t bytes_written = 0; size_t buffer_size = 0, write_count = 0; DBG (2, "(child) reader_process: test_device=%p, fd=%d\n", (void *) test_device, fd); bytes_total = test_device->lines * test_device->bytes_per_line; status = init_picture_buffer (test_device, &buffer, &buffer_size); if (status != SANE_STATUS_GOOD) return status; DBG (2, "(child) reader_process: buffer=%p, buffersize=%lu\n", buffer, (u_long) buffer_size); while (byte_count < bytes_total) { if (write_count == 0) { write_count = buffer_size; if (byte_count + (SANE_Word) write_count > bytes_total) write_count = bytes_total - byte_count; if (test_device->val[opt_read_delay].w == SANE_TRUE) usleep (test_device->val[opt_read_delay_duration].w); } bytes_written = write (fd, buffer, write_count); if (bytes_written < 0) { DBG (1, "(child) reader_process: write returned %s\n", strerror (errno)); return SANE_STATUS_IO_ERROR; } byte_count += bytes_written; DBG (4, "(child) reader_process: wrote %ld bytes of %lu (%d total)\n", (long) bytes_written, (u_long) write_count, byte_count); write_count -= bytes_written; } free (buffer); if (sanei_thread_is_forked ()) { DBG (4, "(child) reader_process: finished, wrote %d bytes, expected %d " "bytes, now waiting\n", byte_count, bytes_total); while (SANE_TRUE) sleep (10); DBG (4, "(child) reader_process: this should have never happened..."); close (fd); } else { DBG (4, "(child) reader_process: finished, wrote %d bytes, expected %d " "bytes\n", byte_count, bytes_total); } return SANE_STATUS_GOOD; } /* * this code either runs in child or thread context... */ static int reader_task (void *data) { SANE_Status status; struct SIGACTION act; struct Test_Device *test_device = (struct Test_Device *) data; DBG (2, "reader_task started\n"); if (sanei_thread_is_forked ()) { DBG (3, "reader_task started (forked)\n"); close (test_device->pipe); test_device->pipe = -1; } else { DBG (3, "reader_task started (as thread)\n"); } memset (&act, 0, sizeof (act)); sigaction (SIGTERM, &act, 0); status = reader_process (test_device, test_device->reader_fds); DBG (2, "(child) reader_task: reader_process finished (%s)\n", sane_strstatus (status)); return (int) status; } static SANE_Status finish_pass (Test_Device * test_device) { SANE_Status return_status = SANE_STATUS_GOOD; DBG (2, "finish_pass: test_device=%p\n", (void *) test_device); test_device->scanning = SANE_FALSE; if (test_device->pipe >= 0) { DBG (2, "finish_pass: closing pipe\n"); close (test_device->pipe); DBG (2, "finish_pass: pipe closed\n"); test_device->pipe = -1; } if (sanei_thread_is_valid (test_device->reader_pid)) { int status; SANE_Pid pid; DBG (2, "finish_pass: terminating reader process %ld\n", (long) test_device->reader_pid); sanei_thread_kill (test_device->reader_pid); pid = sanei_thread_waitpid (test_device->reader_pid, &status); if (!sanei_thread_is_valid (pid)) { DBG (1, "finish_pass: sanei_thread_waitpid failed, already terminated? (%s)\n", strerror (errno)); } else { DBG (2, "finish_pass: reader process terminated with status: %s\n", sane_strstatus (status)); } sanei_thread_invalidate (test_device->reader_pid); } /* this happens when running in thread context... */ if (test_device->reader_fds >= 0) { DBG (2, "finish_pass: closing reader pipe\n"); close (test_device->reader_fds); DBG (2, "finish_pass: reader pipe closed\n"); test_device->reader_fds = -1; } return return_status; } static void print_options (Test_Device * test_device) { SANE_Option_Descriptor *od; SANE_Word option_number; SANE_Char caps[1024]; for (option_number = 0; option_number < num_options; option_number++) { od = &test_device->opt[option_number]; DBG (0, "-----> number: %d\n", option_number); DBG (0, " name: `%s'\n", od->name); DBG (0, " title: `%s'\n", od->title); DBG (0, " description: `%s'\n", od->desc); DBG (0, " type: %s\n", od->type == SANE_TYPE_BOOL ? "SANE_TYPE_BOOL" : od->type == SANE_TYPE_INT ? "SANE_TYPE_INT" : od->type == SANE_TYPE_FIXED ? "SANE_TYPE_FIXED" : od->type == SANE_TYPE_STRING ? "SANE_TYPE_STRING" : od->type == SANE_TYPE_BUTTON ? "SANE_TYPE_BUTTON" : od->type == SANE_TYPE_GROUP ? "SANE_TYPE_GROUP" : "unknown"); DBG (0, " unit: %s\n", od->unit == SANE_UNIT_NONE ? "SANE_UNIT_NONE" : od->unit == SANE_UNIT_PIXEL ? "SANE_UNIT_PIXEL" : od->unit == SANE_UNIT_BIT ? "SANE_UNIT_BIT" : od->unit == SANE_UNIT_MM ? "SANE_UNIT_MM" : od->unit == SANE_UNIT_DPI ? "SANE_UNIT_DPI" : od->unit == SANE_UNIT_PERCENT ? "SANE_UNIT_PERCENT" : od->unit == SANE_UNIT_MICROSECOND ? "SANE_UNIT_MICROSECOND" : "unknown"); DBG (0, " size: %d\n", od->size); caps[0] = '\0'; if (od->cap & SANE_CAP_SOFT_SELECT) strcat (caps, "SANE_CAP_SOFT_SELECT "); if (od->cap & SANE_CAP_HARD_SELECT) strcat (caps, "SANE_CAP_HARD_SELECT "); if (od->cap & SANE_CAP_SOFT_DETECT) strcat (caps, "SANE_CAP_SOFT_DETECT "); if (od->cap & SANE_CAP_EMULATED) strcat (caps, "SANE_CAP_EMULATED "); if (od->cap & SANE_CAP_AUTOMATIC) strcat (caps, "SANE_CAP_AUTOMATIC "); if (od->cap & SANE_CAP_INACTIVE) strcat (caps, "SANE_CAP_INACTIVE "); if (od->cap & SANE_CAP_ADVANCED) strcat (caps, "SANE_CAP_ADVANCED "); DBG (0, " capabilities: %s\n", caps); DBG (0, "constraint type: %s\n", od->constraint_type == SANE_CONSTRAINT_NONE ? "SANE_CONSTRAINT_NONE" : od->constraint_type == SANE_CONSTRAINT_RANGE ? "SANE_CONSTRAINT_RANGE" : od->constraint_type == SANE_CONSTRAINT_WORD_LIST ? "SANE_CONSTRAINT_WORD_LIST" : od->constraint_type == SANE_CONSTRAINT_STRING_LIST ? "SANE_CONSTRAINT_STRING_LIST" : "unknown"); } } /***************************** SANE API ****************************/ SANE_Status sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_unused__ authorize) { FILE *fp; SANE_Int linenumber; SANE_Char line[PATH_MAX], *word = NULL; SANE_String_Const cp; SANE_Device *sane_device; Test_Device *test_device, *previous_device; SANE_Int num; DBG_INIT (); sanei_thread_init (); test_device = 0; previous_device = 0; DBG (1, "sane_init: SANE test backend version %d.%d.%d from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); if (inited) DBG (3, "sane_init: warning: already inited\n"); fp = sanei_config_open (TEST_CONFIG_FILE); if (fp) { linenumber = 0; DBG (4, "sane_init: reading config file `%s'\n", TEST_CONFIG_FILE); while (sanei_config_read (line, sizeof (line), fp)) { if (word) free (word); word = NULL; linenumber++; cp = sanei_config_get_string (line, &word); if (!word || cp == line) { DBG (5, "sane_init: config file line %3d: ignoring empty line\n", linenumber); continue; } if (word[0] == '#') { DBG (5, "sane_init: config file line %3d: ignoring comment line\n", linenumber); continue; } DBG (5, "sane_init: config file line %3d: `%s'\n", linenumber, line); if (read_option (line, "number_of_devices", param_int, &init_number_of_devices) == SANE_STATUS_GOOD) continue; if (read_option (line, "mode", param_string, &init_mode) == SANE_STATUS_GOOD) continue; if (read_option (line, "hand-scanner", param_bool, &init_hand_scanner) == SANE_STATUS_GOOD) continue; if (read_option (line, "three-pass", param_bool, &init_three_pass) == SANE_STATUS_GOOD) continue; if (read_option (line, "three-pass-order", param_string, &init_three_pass_order) == SANE_STATUS_GOOD) continue; if (read_option (line, "resolution_min", param_fixed, &resolution_range.min) == SANE_STATUS_GOOD) continue; if (read_option (line, "resolution_max", param_fixed, &resolution_range.max) == SANE_STATUS_GOOD) continue; if (read_option (line, "resolution_quant", param_fixed, &resolution_range.quant) == SANE_STATUS_GOOD) continue; if (read_option (line, "resolution", param_fixed, &init_resolution) == SANE_STATUS_GOOD) continue; if (read_option (line, "depth", param_int, &init_depth) == SANE_STATUS_GOOD) continue; if (read_option (line, "scan-source", param_string, &init_scan_source) == SANE_STATUS_GOOD) continue; if (read_option (line, "test-picture", param_string, &init_test_picture) == SANE_STATUS_GOOD) continue; if (read_option (line, "invert-endianess", param_bool, &init_invert_endianess) == SANE_STATUS_GOOD) continue; if (read_option (line, "read-limit", param_bool, &init_read_limit) == SANE_STATUS_GOOD) continue; if (read_option (line, "read-limit-size", param_int, &init_read_limit_size) == SANE_STATUS_GOOD) continue; if (read_option (line, "read-delay", param_bool, &init_read_delay) == SANE_STATUS_GOOD) continue; if (read_option (line, "read-delay-duration", param_int, &init_read_delay_duration) == SANE_STATUS_GOOD) continue; if (read_option (line, "read-status-code", param_string, &init_read_status_code) == SANE_STATUS_GOOD) continue; if (read_option (line, "ppl-loss", param_int, &init_ppl_loss) == SANE_STATUS_GOOD) continue; if (read_option (line, "fuzzy-parameters", param_bool, &init_fuzzy_parameters) == SANE_STATUS_GOOD) continue; if (read_option (line, "non-blocking", param_bool, &init_non_blocking) == SANE_STATUS_GOOD) continue; if (read_option (line, "select-fd", param_bool, &init_select_fd) == SANE_STATUS_GOOD) continue; if (read_option (line, "enable-test-options", param_bool, &init_enable_test_options) == SANE_STATUS_GOOD) continue; if (read_option (line, "geometry_min", param_fixed, &geometry_range.min) == SANE_STATUS_GOOD) continue; if (read_option (line, "geometry_max", param_fixed, &geometry_range.max) == SANE_STATUS_GOOD) continue; if (read_option (line, "geometry_quant", param_fixed, &geometry_range.quant) == SANE_STATUS_GOOD) continue; if (read_option (line, "tl_x", param_fixed, &init_tl_x) == SANE_STATUS_GOOD) continue; if (read_option (line, "tl_y", param_fixed, &init_tl_y) == SANE_STATUS_GOOD) continue; if (read_option (line, "br_x", param_fixed, &init_br_x) == SANE_STATUS_GOOD) continue; if (read_option (line, "br_y", param_fixed, &init_br_y) == SANE_STATUS_GOOD) continue; DBG (3, "sane-init: I don't know how to handle option `%s'\n", word); } /* while */ if (word) free (word); fclose (fp); } /* if */ else { DBG (3, "sane_init: couldn't find config file (%s), using default " "settings\n", TEST_CONFIG_FILE); } /* create devices */ sane_device_list = malloc ((init_number_of_devices + 1) * sizeof (sane_device)); if (!sane_device_list) return SANE_STATUS_NO_MEM; for (num = 0; num < init_number_of_devices; num++) { SANE_Char number_string[PATH_MAX]; test_device = malloc (sizeof (*test_device)); if (!test_device) return SANE_STATUS_NO_MEM; test_device->sane.vendor = "Noname"; test_device->sane.type = "virtual device"; test_device->sane.model = "frontend-tester"; snprintf (number_string, sizeof (number_string), "%d", num); number_string[sizeof (number_string) - 1] = '\0'; test_device->name = strdup (number_string); if (!test_device->name) return SANE_STATUS_NO_MEM; test_device->sane.name = test_device->name; if (previous_device) previous_device->next = test_device; previous_device = test_device; if (num == 0) first_test_device = test_device; sane_device_list[num] = &test_device->sane; test_device->open = SANE_FALSE; test_device->eof = SANE_FALSE; test_device->scanning = SANE_FALSE; test_device->cancelled = SANE_FALSE; sanei_thread_initialize (test_device->reader_pid); test_device->pipe = -1; DBG (4, "sane_init: new device: `%s' is a %s %s %s\n", test_device->sane.name, test_device->sane.vendor, test_device->sane.model, test_device->sane.type); } test_device->next = 0; sane_device_list[num] = 0; srand (time (NULL)); random_factor = ((double) rand ()) / RAND_MAX + 0.5; inited = SANE_TRUE; return SANE_STATUS_GOOD; } void sane_exit (void) { Test_Device *test_device, *previous_device; DBG (2, "sane_exit\n"); if (!inited) { DBG (1, "sane_exit: not inited, call sane_init() first\n"); return; } test_device = first_test_device; while (test_device) { DBG (4, "sane_exit: freeing device %s\n", test_device->name); previous_device = test_device; test_device = test_device->next; if (previous_device->name) free (previous_device->name); free (previous_device); } DBG (4, "sane_exit: freeing device list\n"); if (sane_device_list) free (sane_device_list); sane_device_list = NULL; first_test_device = NULL; inited = SANE_FALSE; return; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { DBG (2, "sane_get_devices: device_list=%p, local_only=%d\n", (void *) device_list, local_only); if (!inited) { DBG (1, "sane_get_devices: not inited, call sane_init() first\n"); return SANE_STATUS_INVAL; } if (!device_list) { DBG (1, "sane_get_devices: device_list == 0\n"); return SANE_STATUS_INVAL; } *device_list = (const SANE_Device **) sane_device_list; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Test_Device *test_device = first_test_device; SANE_Status status; DBG (2, "sane_open: devicename = \"%s\", handle=%p\n", devicename, (void *) handle); if (!inited) { DBG (1, "sane_open: not inited, call sane_init() first\n"); return SANE_STATUS_INVAL; } if (!handle) { DBG (1, "sane_open: handle == 0\n"); return SANE_STATUS_INVAL; } if (!devicename || strlen (devicename) == 0) { DBG (2, "sane_open: device name NULL or empty\n"); } else { for (test_device = first_test_device; test_device; test_device = test_device->next) { if (strcmp (devicename, test_device->name) == 0) break; } } if (!test_device) { DBG (1, "sane_open: device `%s' not found\n", devicename); return SANE_STATUS_INVAL; } if (test_device->open) { DBG (1, "sane_open: device `%s' already open\n", devicename); return SANE_STATUS_DEVICE_BUSY; } DBG (2, "sane_open: opening device `%s', handle = %p\n", test_device->name, (void *) test_device); test_device->open = SANE_TRUE; *handle = test_device; status = init_options (test_device); if (status != SANE_STATUS_GOOD) return status; test_device->open = SANE_TRUE; test_device->scanning = SANE_FALSE; test_device->cancelled = SANE_FALSE; test_device->eof = SANE_FALSE; test_device->bytes_total = 0; test_device->pass = 0; test_device->number_of_scans = 0; return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Test_Device *test_device = handle; DBG (2, "sane_close: handle=%p\n", (void *) handle); if (!inited) { DBG (1, "sane_close: not inited, call sane_init() first\n"); return; } if (!check_handle (handle)) { DBG (1, "sane_close: handle %p unknown\n", (void *) handle); return; } if (!test_device->open) { DBG (1, "sane_close: handle %p not open\n", (void *) handle); return; } test_device->open = SANE_FALSE; return; } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Test_Device *test_device = handle; DBG (4, "sane_get_option_descriptor: handle=%p, option = %d\n", (void *) handle, option); if (!inited) { DBG (1, "sane_get_option_descriptor: not inited, call sane_init() " "first\n"); return 0; } if (!check_handle (handle)) { DBG (1, "sane_get_option_descriptor: handle %p unknown\n", (void *) handle); return 0; } if (!test_device->open) { DBG (1, "sane_get_option_descriptor: not open\n"); return 0; } if (option < 0 || option >= num_options) { DBG (3, "sane_get_option_descriptor: option < 0 || " "option > num_options\n"); return 0; } test_device->loaded[option] = 1; return &test_device->opt[option]; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { Test_Device *test_device = handle; SANE_Int myinfo = 0; SANE_Status status; DBG (4, "sane_control_option: handle=%p, opt=%d, act=%d, val=%p, info=%p\n", (void *) handle, option, action, (void *) value, (void *) info); if (!inited) { DBG (1, "sane_control_option: not inited, call sane_init() first\n"); return SANE_STATUS_INVAL; } if (!check_handle (handle)) { DBG (1, "sane_control_option: handle %p unknown\n", (void *) handle); return SANE_STATUS_INVAL; } if (!test_device->open) { DBG (1, "sane_control_option: not open\n"); return SANE_STATUS_INVAL; } if (test_device->scanning) { DBG (1, "sane_control_option: is scanning\n"); return SANE_STATUS_INVAL; } if (option < 0 || option >= num_options) { DBG (1, "sane_control_option: option < 0 || option > num_options\n"); return SANE_STATUS_INVAL; } if (!test_device->loaded[option]) { DBG (1, "sane_control_option: option not loaded\n"); return SANE_STATUS_INVAL; } if (!SANE_OPTION_IS_ACTIVE (test_device->opt[option].cap)) { DBG (1, "sane_control_option: option is inactive\n"); return SANE_STATUS_INVAL; } if (test_device->opt[option].type == SANE_TYPE_GROUP) { DBG (1, "sane_control_option: option is a group\n"); return SANE_STATUS_INVAL; } switch (action) { case SANE_ACTION_SET_AUTO: if (!SANE_OPTION_IS_SETTABLE (test_device->opt[option].cap)) { DBG (1, "sane_control_option: option is not setable\n"); return SANE_STATUS_INVAL; } if (!(test_device->opt[option].cap & SANE_CAP_AUTOMATIC)) { DBG (1, "sane_control_option: option is not automatically " "setable\n"); return SANE_STATUS_INVAL; } switch (option) { case opt_bool_soft_select_soft_detect_auto: test_device->val[option].w = SANE_TRUE; DBG (4, "sane_control_option: set option %d (%s) automatically " "to %s\n", option, test_device->opt[option].name, test_device->val[option].w == SANE_TRUE ? "true" : "false"); break; default: DBG (1, "sane_control_option: trying to automatically set " "unexpected option\n"); return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_VALUE: if (!SANE_OPTION_IS_SETTABLE (test_device->opt[option].cap)) { DBG (1, "sane_control_option: option is not setable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (&test_device->opt[option], value, &myinfo); if (status != SANE_STATUS_GOOD) { DBG (3, "sane_control_option: sanei_constrain_value returned %s\n", sane_strstatus (status)); return status; } switch (option) { case opt_tl_x: /* Fixed with parameter reloading */ case opt_tl_y: case opt_br_x: case opt_br_y: case opt_resolution: if (test_device->val[option].w == *(SANE_Fixed *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Fixed *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; DBG (4, "sane_control_option: set option %d (%s) to %.0f %s\n", option, test_device->opt[option].name, SANE_UNFIX (*(SANE_Fixed *) value), test_device->opt[option].unit == SANE_UNIT_MM ? "mm" : "dpi"); break; case opt_fixed: /* Fixed */ case opt_fixed_constraint_range: if (test_device->val[option].w == *(SANE_Fixed *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Fixed *) value; DBG (4, "sane_control_option: set option %d (%s) to %.0f\n", option, test_device->opt[option].name, SANE_UNFIX (*(SANE_Fixed *) value)); break; case opt_read_limit_size: /* Int */ case opt_ppl_loss: case opt_read_delay_duration: case opt_int: case opt_int_constraint_range: if (test_device->val[option].w == *(SANE_Int *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Int *) value; DBG (4, "sane_control_option: set option %d (%s) to %d\n", option, test_device->opt[option].name, *(SANE_Int *) value); break; case opt_fuzzy_parameters: /* Bool with parameter reloading */ if (test_device->val[option].w == *(SANE_Bool *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Bool *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; case opt_invert_endianess: /* Bool */ case opt_non_blocking: case opt_select_fd: case opt_bool_soft_select_soft_detect: case opt_bool_soft_select_soft_detect_auto: case opt_bool_soft_select_soft_detect_emulated: if (test_device->val[option].w == *(SANE_Bool *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Bool *) value; DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; case opt_depth: /* Word list with parameter and options reloading */ if (test_device->val[option].w == *(SANE_Int *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Int *) value; if (test_device->val[option].w == 16) test_device->opt[opt_invert_endianess].cap &= ~SANE_CAP_INACTIVE; else test_device->opt[opt_invert_endianess].cap |= SANE_CAP_INACTIVE; myinfo |= SANE_INFO_RELOAD_PARAMS; myinfo |= SANE_INFO_RELOAD_OPTIONS; DBG (4, "sane_control_option: set option %d (%s) to %d\n", option, test_device->opt[option].name, *(SANE_Int *) value); break; case opt_three_pass_order: /* String list with parameter reload */ if (strcmp (test_device->val[option].s, value) == 0) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } strcpy (test_device->val[option].s, (SANE_String) value); myinfo |= SANE_INFO_RELOAD_PARAMS; DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, (SANE_String) value); break; case opt_int_constraint_word_list: /* Word list */ case opt_fixed_constraint_word_list: if (test_device->val[option].w == *(SANE_Int *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Int *) value; DBG (4, "sane_control_option: set option %d (%s) to %d\n", option, test_device->opt[option].name, *(SANE_Int *) value); break; case opt_read_status_code: /* String (list) */ case opt_test_picture: case opt_string: case opt_string_constraint_string_list: case opt_string_constraint_long_string_list: case opt_scan_source: if (strcmp (test_device->val[option].s, value) == 0) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } strcpy (test_device->val[option].s, (SANE_String) value); DBG (4, "sane_control_option: set option %d (%s) to `%s'\n", option, test_device->opt[option].name, (SANE_String) value); break; case opt_int_array: /* Word array */ case opt_int_array_constraint_range: case opt_int_array_constraint_word_list: memcpy (test_device->val[option].wa, value, test_device->opt[option].size); DBG (4, "sane_control_option: set option %d (%s) to %p\n", option, test_device->opt[option].name, (void *) value); break; /* options with side-effects */ case opt_print_options: DBG (4, "sane_control_option: set option %d (%s)\n", option, test_device->opt[option].name); print_options (test_device); break; case opt_button: DBG (0, "Yes! You pressed me!\n"); DBG (4, "sane_control_option: set option %d (%s)\n", option, test_device->opt[option].name); break; case opt_mode: if (strcmp (test_device->val[option].s, value) == 0) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } strcpy (test_device->val[option].s, (SANE_String) value); myinfo |= SANE_INFO_RELOAD_PARAMS; myinfo |= SANE_INFO_RELOAD_OPTIONS; if (strcmp (test_device->val[option].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) { test_device->opt[opt_three_pass].cap &= ~SANE_CAP_INACTIVE; if (test_device->val[opt_three_pass].w == SANE_TRUE) test_device->opt[opt_three_pass_order].cap &= ~SANE_CAP_INACTIVE; } else { test_device->opt[opt_three_pass].cap |= SANE_CAP_INACTIVE; test_device->opt[opt_three_pass_order].cap |= SANE_CAP_INACTIVE; } DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, (SANE_String) value); break; case opt_three_pass: if (test_device->val[option].w == *(SANE_Bool *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Bool *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; myinfo |= SANE_INFO_RELOAD_OPTIONS; if (test_device->val[option].w == SANE_TRUE) test_device->opt[opt_three_pass_order].cap &= ~SANE_CAP_INACTIVE; else test_device->opt[opt_three_pass_order].cap |= SANE_CAP_INACTIVE; DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; case opt_hand_scanner: if (test_device->val[option].w == *(SANE_Bool *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Bool *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; myinfo |= SANE_INFO_RELOAD_OPTIONS; if (test_device->val[option].w == SANE_TRUE) { test_device->opt[opt_tl_x].cap |= SANE_CAP_INACTIVE; test_device->opt[opt_tl_y].cap |= SANE_CAP_INACTIVE; test_device->opt[opt_br_x].cap |= SANE_CAP_INACTIVE; test_device->opt[opt_br_y].cap |= SANE_CAP_INACTIVE; } else { test_device->opt[opt_tl_x].cap &= ~SANE_CAP_INACTIVE; test_device->opt[opt_tl_y].cap &= ~SANE_CAP_INACTIVE; test_device->opt[opt_br_x].cap &= ~SANE_CAP_INACTIVE; test_device->opt[opt_br_y].cap &= ~SANE_CAP_INACTIVE; } DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; case opt_read_limit: if (test_device->val[option].w == *(SANE_Bool *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Bool *) value; myinfo |= SANE_INFO_RELOAD_OPTIONS; if (test_device->val[option].w == SANE_TRUE) test_device->opt[opt_read_limit_size].cap &= ~SANE_CAP_INACTIVE; else test_device->opt[opt_read_limit_size].cap |= SANE_CAP_INACTIVE; DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; case opt_read_delay: if (test_device->val[option].w == *(SANE_Bool *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Bool *) value; myinfo |= SANE_INFO_RELOAD_OPTIONS; if (test_device->val[option].w == SANE_TRUE) test_device->opt[opt_read_delay_duration].cap &= ~SANE_CAP_INACTIVE; else test_device->opt[opt_read_delay_duration].cap |= SANE_CAP_INACTIVE; DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; case opt_enable_test_options: { int option_number; if (test_device->val[option].w == *(SANE_Bool *) value) { DBG (4, "sane_control_option: option %d (%s) not changed\n", option, test_device->opt[option].name); break; } test_device->val[option].w = *(SANE_Bool *) value; myinfo |= SANE_INFO_RELOAD_OPTIONS; for (option_number = opt_bool_soft_select_soft_detect; option_number < num_options; option_number++) { if (test_device->opt[option_number].type == SANE_TYPE_GROUP) continue; if (test_device->val[option].w == SANE_TRUE) test_device->opt[option_number].cap &= ~SANE_CAP_INACTIVE; else test_device->opt[option_number].cap |= SANE_CAP_INACTIVE; } DBG (4, "sane_control_option: set option %d (%s) to %s\n", option, test_device->opt[option].name, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; } default: DBG (1, "sane_control_option: trying to set unexpected option\n"); return SANE_STATUS_INVAL; } break; case SANE_ACTION_GET_VALUE: switch (option) { case opt_num_opts: *(SANE_Word *) value = num_options; DBG (4, "sane_control_option: get option 0, value = %d\n", num_options); break; case opt_tl_x: /* Fixed options */ case opt_tl_y: case opt_br_x: case opt_br_y: case opt_resolution: case opt_fixed: case opt_fixed_constraint_range: case opt_fixed_constraint_word_list: { *(SANE_Fixed *) value = test_device->val[option].w; DBG (4, "sane_control_option: get option %d (%s), value=%.1f %s\n", option, test_device->opt[option].name, SANE_UNFIX (*(SANE_Fixed *) value), test_device->opt[option].unit == SANE_UNIT_MM ? "mm" : SANE_UNIT_DPI ? "dpi" : ""); break; } case opt_hand_scanner: /* Bool options */ case opt_three_pass: case opt_invert_endianess: case opt_read_limit: case opt_read_delay: case opt_fuzzy_parameters: case opt_non_blocking: case opt_select_fd: case opt_bool_soft_select_soft_detect: case opt_bool_hard_select_soft_detect: case opt_bool_soft_detect: case opt_enable_test_options: case opt_bool_soft_select_soft_detect_emulated: case opt_bool_soft_select_soft_detect_auto: *(SANE_Bool *) value = test_device->val[option].w; DBG (4, "sane_control_option: get option %d (%s), value=%s\n", option, test_device->opt[option].name, *(SANE_Bool *) value == SANE_TRUE ? "true" : "false"); break; case opt_mode: /* String (list) options */ case opt_three_pass_order: case opt_read_status_code: case opt_test_picture: case opt_string: case opt_string_constraint_string_list: case opt_string_constraint_long_string_list: case opt_scan_source: strcpy (value, test_device->val[option].s); DBG (4, "sane_control_option: get option %d (%s), value=`%s'\n", option, test_device->opt[option].name, (SANE_String) value); break; case opt_depth: /* Int + word list options */ case opt_read_limit_size: case opt_ppl_loss: case opt_read_delay_duration: case opt_int: case opt_int_constraint_range: case opt_int_constraint_word_list: *(SANE_Int *) value = test_device->val[option].w; DBG (4, "sane_control_option: get option %d (%s), value=%d\n", option, test_device->opt[option].name, *(SANE_Int *) value); break; case opt_int_array: /* Int array */ case opt_int_array_constraint_range: case opt_int_array_constraint_word_list: memcpy (value, test_device->val[option].wa, test_device->opt[option].size); DBG (4, "sane_control_option: get option %d (%s), value=%p\n", option, test_device->opt[option].name, (void *) value); break; default: DBG (1, "sane_control_option: trying to get unexpected option\n"); return SANE_STATUS_INVAL; } break; default: DBG (1, "sane_control_option: trying unexpected action %d\n", action); return SANE_STATUS_INVAL; } if (info) *info = myinfo; if(myinfo & SANE_INFO_RELOAD_OPTIONS){ SANE_Int i = 0; for(i=1;iloaded[i] = 0; } } DBG (4, "sane_control_option: finished, info=%s %s %s \n", myinfo & SANE_INFO_INEXACT ? "inexact" : "", myinfo & SANE_INFO_RELOAD_PARAMS ? "reload_parameters" : "", myinfo & SANE_INFO_RELOAD_OPTIONS ? "reload_options" : ""); return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Test_Device *test_device = handle; SANE_Parameters *p; double res, tl_x = 0, tl_y = 0, br_x = 0, br_y = 0; SANE_String text_format, mode; SANE_Int channels = 1; DBG (2, "sane_get_parameters: handle=%p, params=%p\n", (void *) handle, (void *) params); if (!inited) { DBG (1, "sane_get_parameters: not inited, call sane_init() first\n"); return SANE_STATUS_INVAL; } if (!check_handle (handle)) { DBG (1, "sane_get_parameters: handle %p unknown\n", (void *) handle); return SANE_STATUS_INVAL; } if (!test_device->open) { DBG (1, "sane_get_parameters: handle %p not open\n", (void *) handle); return SANE_STATUS_INVAL; } res = SANE_UNFIX (test_device->val[opt_resolution].w); mode = test_device->val[opt_mode].s; p = &test_device->params; p->depth = test_device->val[opt_depth].w; if (test_device->val[opt_hand_scanner].w == SANE_TRUE) { tl_x = 0.0; br_x = 110.0; tl_y = 0.0; br_y = 170.0; p->lines = -1; test_device->lines = (SANE_Word) (res * (br_y - tl_y) / MM_PER_INCH); } else { tl_x = SANE_UNFIX (test_device->val[opt_tl_x].w); tl_y = SANE_UNFIX (test_device->val[opt_tl_y].w); br_x = SANE_UNFIX (test_device->val[opt_br_x].w); br_y = SANE_UNFIX (test_device->val[opt_br_y].w); if (tl_x > br_x) swap_double (&tl_x, &br_x); if (tl_y > br_y) swap_double (&tl_y, &br_y); test_device->lines = (SANE_Word) (res * (br_y - tl_y) / MM_PER_INCH); if (test_device->lines < 1) test_device->lines = 1; p->lines = test_device->lines; if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE && test_device->scanning == SANE_FALSE) p->lines *= random_factor; } if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) { p->format = SANE_FRAME_GRAY; p->last_frame = SANE_TRUE; } else /* Color */ { if (test_device->val[opt_three_pass].w == SANE_TRUE) { if (test_device->val[opt_three_pass_order].s[test_device->pass] == 'R') p->format = SANE_FRAME_RED; else if (test_device->val[opt_three_pass_order].s[test_device->pass] == 'G') p->format = SANE_FRAME_GREEN; else p->format = SANE_FRAME_BLUE; if (test_device->pass > 1) p->last_frame = SANE_TRUE; else p->last_frame = SANE_FALSE; } else { p->format = SANE_FRAME_RGB; p->last_frame = SANE_TRUE; } } p->pixels_per_line = (SANE_Int) (res * (br_x - tl_x) / MM_PER_INCH); if (test_device->val[opt_fuzzy_parameters].w == SANE_TRUE && test_device->scanning == SANE_FALSE) p->pixels_per_line *= random_factor; if (p->pixels_per_line < 1) p->pixels_per_line = 1; if (p->format == SANE_FRAME_RGB) channels = 3; if (p->depth == 1) p->bytes_per_line = channels * (int) ((p->pixels_per_line + 7) / 8); else /* depth == 8 || depth == 16 */ p->bytes_per_line = channels * p->pixels_per_line * ((p->depth + 7) / 8); test_device->bytes_per_line = p->bytes_per_line; p->pixels_per_line -= test_device->val[opt_ppl_loss].w; if (p->pixels_per_line < 1) p->pixels_per_line = 1; test_device->pixels_per_line = p->pixels_per_line; switch (p->format) { case SANE_FRAME_GRAY: text_format = "gray"; break; case SANE_FRAME_RGB: text_format = "rgb"; break; case SANE_FRAME_RED: text_format = "red"; break; case SANE_FRAME_GREEN: text_format = "green"; break; case SANE_FRAME_BLUE: text_format = "blue"; break; default: text_format = "unknown"; break; } DBG (3, "sane_get_parameters: format=%s\n", text_format); DBG (3, "sane_get_parameters: last_frame=%s\n", p->last_frame ? "true" : "false"); DBG (3, "sane_get_parameters: lines=%d\n", p->lines); DBG (3, "sane_get_parameters: depth=%d\n", p->depth); DBG (3, "sane_get_parameters: pixels_per_line=%d\n", p->pixels_per_line); DBG (3, "sane_get_parameters: bytes_per_line=%d\n", p->bytes_per_line); if (params) *params = *p; return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Test_Device *test_device = handle; int pipe_descriptor[2]; DBG (2, "sane_start: handle=%p\n", handle); if (!inited) { DBG (1, "sane_start: not inited, call sane_init() first\n"); return SANE_STATUS_INVAL; } if (!check_handle (handle)) { DBG (1, "sane_start: handle %p unknown\n", handle); return SANE_STATUS_INVAL; } if (!test_device->open) { DBG (1, "sane_start: not open\n"); return SANE_STATUS_INVAL; } if (test_device->scanning && (test_device->val[opt_three_pass].w == SANE_FALSE && strcmp (test_device->val[opt_mode].s, SANE_VALUE_SCAN_MODE_COLOR) == 0)) { DBG (1, "sane_start: already scanning\n"); return SANE_STATUS_INVAL; } if (strcmp (test_device->val[opt_mode].s, SANE_VALUE_SCAN_MODE_COLOR) == 0 && test_device->val[opt_three_pass].w == SANE_TRUE && test_device->pass > 2) { DBG (1, "sane_start: already in last pass of three\n"); return SANE_STATUS_INVAL; } if (test_device->pass == 0) { test_device->number_of_scans++; DBG (3, "sane_start: scanning page %d\n", test_device->number_of_scans); if ((strcmp (test_device->val[opt_scan_source].s, "Automatic Document Feeder") == 0) && (((test_device->number_of_scans) % 11) == 0)) { DBG (1, "sane_start: Document feeder is out of documents!\n"); return SANE_STATUS_NO_DOCS; } } test_device->scanning = SANE_TRUE; test_device->cancelled = SANE_FALSE; test_device->eof = SANE_FALSE; test_device->bytes_total = 0; sane_get_parameters (handle, 0); if (test_device->params.lines == 0) { DBG (1, "sane_start: lines == 0\n"); test_device->scanning = SANE_FALSE; return SANE_STATUS_INVAL; } if (test_device->params.pixels_per_line == 0) { DBG (1, "sane_start: pixels_per_line == 0\n"); test_device->scanning = SANE_FALSE; return SANE_STATUS_INVAL; } if (test_device->params.bytes_per_line == 0) { DBG (1, "sane_start: bytes_per_line == 0\n"); test_device->scanning = SANE_FALSE; return SANE_STATUS_INVAL; } if (pipe (pipe_descriptor) < 0) { DBG (1, "sane_start: pipe failed (%s)\n", strerror (errno)); return SANE_STATUS_IO_ERROR; } /* create reader routine as new process or thread */ test_device->pipe = pipe_descriptor[0]; test_device->reader_fds = pipe_descriptor[1]; test_device->reader_pid = sanei_thread_begin (reader_task, (void *) test_device); if (!sanei_thread_is_valid (test_device->reader_pid)) { DBG (1, "sane_start: sanei_thread_begin failed (%s)\n", strerror (errno)); return SANE_STATUS_NO_MEM; } if (sanei_thread_is_forked ()) { close (test_device->reader_fds); test_device->reader_fds = -1; } return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { Test_Device *test_device = handle; SANE_Int max_scan_length; ssize_t bytes_read; size_t read_count; SANE_Int bytes_total = test_device->lines * test_device->bytes_per_line; DBG (4, "sane_read: handle=%p, data=%p, max_length = %d, length=%p\n", handle, data, max_length, (void *) length); if (!inited) { DBG (1, "sane_read: not inited, call sane_init() first\n"); return SANE_STATUS_INVAL; } if (!check_handle (handle)) { DBG (1, "sane_read: handle %p unknown\n", handle); return SANE_STATUS_INVAL; } if (!length) { DBG (1, "sane_read: length == NULL\n"); return SANE_STATUS_INVAL; } if (strcmp (test_device->val[opt_read_status_code].s, "Default") != 0) { SANE_String_Const sc = test_device->val[opt_read_status_code].s; DBG (3, "sane_read: setting return status to %s\n", sc); if (strcmp (sc, "SANE_STATUS_UNSUPPORTED") == 0) return SANE_STATUS_UNSUPPORTED; if (strcmp (sc, "SANE_STATUS_CANCELLED") == 0) return SANE_STATUS_CANCELLED; if (strcmp (sc, "SANE_STATUS_DEVICE_BUSY") == 0) return SANE_STATUS_DEVICE_BUSY; if (strcmp (sc, "SANE_STATUS_INVAL") == 0) return SANE_STATUS_INVAL; if (strcmp (sc, "SANE_STATUS_EOF") == 0) return SANE_STATUS_EOF; if (strcmp (sc, "SANE_STATUS_JAMMED") == 0) return SANE_STATUS_JAMMED; if (strcmp (sc, "SANE_STATUS_NO_DOCS") == 0) return SANE_STATUS_NO_DOCS; if (strcmp (sc, "SANE_STATUS_COVER_OPEN") == 0) return SANE_STATUS_COVER_OPEN; if (strcmp (sc, "SANE_STATUS_IO_ERROR") == 0) return SANE_STATUS_IO_ERROR; if (strcmp (sc, "SANE_STATUS_NO_MEM") == 0) return SANE_STATUS_NO_MEM; if (strcmp (sc, "SANE_STATUS_ACCESS_DENIED") == 0) return SANE_STATUS_ACCESS_DENIED; } max_scan_length = max_length; if (test_device->val[opt_read_limit].w == SANE_TRUE && test_device->val[opt_read_limit_size].w < max_scan_length) { max_scan_length = test_device->val[opt_read_limit_size].w; DBG (3, "sane_read: limiting max_scan_length to %d bytes\n", max_scan_length); } *length = 0; if (!data) { DBG (1, "sane_read: data == NULL\n"); return SANE_STATUS_INVAL; } if (!test_device->open) { DBG (1, "sane_read: not open\n"); return SANE_STATUS_INVAL; } if (test_device->cancelled) { DBG (1, "sane_read: scan was cancelled\n"); return SANE_STATUS_CANCELLED; } if (test_device->eof) { DBG (2, "sane_read: No more data available, sending EOF\n"); return SANE_STATUS_EOF; } if (!test_device->scanning) { DBG (1, "sane_read: not scanning (call sane_start first)\n"); return SANE_STATUS_INVAL; } read_count = max_scan_length; bytes_read = read (test_device->pipe, data, read_count); if (bytes_read == 0 || (bytes_read + test_device->bytes_total >= bytes_total)) { SANE_Status status; DBG (2, "sane_read: EOF reached\n"); status = finish_pass (test_device); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_read: finish_pass returned `%s'\n", sane_strstatus (status)); return status; } test_device->eof = SANE_TRUE; if (strcmp (test_device->val[opt_mode].s, SANE_VALUE_SCAN_MODE_COLOR) == 0 && test_device->val[opt_three_pass].w == SANE_TRUE) { test_device->pass++; if (test_device->pass > 2) test_device->pass = 0; } if (bytes_read == 0) return SANE_STATUS_EOF; } else if (bytes_read < 0) { if (errno == EAGAIN) { DBG (2, "sane_read: no data available, try again\n"); return SANE_STATUS_GOOD; } else { DBG (1, "sane_read: read returned error: %s\n", strerror (errno)); return SANE_STATUS_IO_ERROR; } } *length = bytes_read; test_device->bytes_total += bytes_read; DBG (2, "sane_read: read %ld bytes of %d, total %d\n", (long) bytes_read, max_scan_length, test_device->bytes_total); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Test_Device *test_device = handle; DBG (2, "sane_cancel: handle = %p\n", handle); if (!inited) { DBG (1, "sane_cancel: not inited, call sane_init() first\n"); return; } if (!check_handle (handle)) { DBG (1, "sane_cancel: handle %p unknown\n", handle); return; } if (!test_device->open) { DBG (1, "sane_cancel: not open\n"); return; } if (test_device->cancelled) { DBG (1, "sane_cancel: scan already cancelled\n"); return; } if (!test_device->scanning) { DBG (2, "sane_cancel: scan is already finished\n"); return; } finish_pass (test_device); test_device->cancelled = SANE_TRUE; test_device->scanning = SANE_FALSE; test_device->eof = SANE_FALSE; test_device->pass = 0; return; } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Test_Device *test_device = handle; DBG (2, "sane_set_io_mode: handle = %p, non_blocking = %d\n", handle, non_blocking); if (!inited) { DBG (1, "sane_set_io_mode: not inited, call sane_init() first\n"); return SANE_STATUS_INVAL; } if (!check_handle (handle)) { DBG (1, "sane_set_io_mode: handle %p unknown\n", handle); return SANE_STATUS_INVAL; } if (!test_device->open) { DBG (1, "sane_set_io_mode: not open\n"); return SANE_STATUS_INVAL; } if (!test_device->scanning) { DBG (1, "sane_set_io_mode: not scanning\n"); return SANE_STATUS_INVAL; } if (test_device->val[opt_non_blocking].w == SANE_TRUE) { if (fcntl (test_device->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) { DBG (1, "sane_set_io_mode: can't set io mode"); return SANE_STATUS_INVAL; } } else { if (non_blocking) return SANE_STATUS_UNSUPPORTED; } return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Test_Device *test_device = handle; DBG (2, "sane_get_select_fd: handle = %p, fd %s 0\n", handle, fd ? "!=" : "="); if (!inited) { DBG (1, "sane_get_select_fd: not inited, call sane_init() first\n"); return SANE_STATUS_INVAL; } if (!check_handle (handle)) { DBG (1, "sane_get_select_fd: handle %p unknown\n", handle); return SANE_STATUS_INVAL; } if (!test_device->open) { DBG (1, "sane_get_select_fd: not open\n"); return SANE_STATUS_INVAL; } if (!test_device->scanning) { DBG (1, "sane_get_select_fd: not scanning\n"); return SANE_STATUS_INVAL; } if (test_device->val[opt_select_fd].w == SANE_TRUE) { *fd = test_device->pipe; return SANE_STATUS_GOOD; } return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/lexmark.conf.in0000666000000000000000000000016713615534521015513 00000000000000# X11xx series usb 0x043d 0x007c # X12xx series usb 0x043d 0x007d # Dell A920 usb 0x413c 0x5105 # X74 usb 0x43d 0x0060 sane-backends-1.0.29/backend/net.conf.in0000666000000000000000000000107513615534521014635 00000000000000# This is the net backend config file. ## net backend options # Timeout for the initial connection to saned. This will prevent the backend # from blocking for several minutes trying to connect to an unresponsive # saned host (network outage, host down, ...). Value in seconds. # connect_timeout = 60 ## saned hosts # Each line names a host to attach to. # If you list "localhost" then your backends can be accessed either # directly or through the net backend. Going through the net backend # may be necessary to access devices that need special privileges. # localhost sane-backends-1.0.29/backend/s9036.conf.in0000666000000000000000000000001513615534521014624 00000000000000/dev/scanner sane-backends-1.0.29/backend/hp3900.conf.in0000666000000000000000000000061313615534521014767 00000000000000# # Configuration file for the hp3900 backend # # HP Scanjet 3800 usb 0x03f0 0x2605 # HP Scanjet 3970c usb 0x03f0 0x2305 # HP Scanjet 4070 Photosmart usb 0x03f0 0x2405 # HP Scanjet 4370 usb 0x03f0 0x4105 # HP Scanjet G2710 usb 0x03f0 0x2805 # HP Scanjet G3010 usb 0x03f0 0x4205 # HP Scanjet G3110 usb 0x03f0 0x4305 # UMAX Astra 4900/4950 usb 0x06dc 0x0020 # BenQ 5550 usb 0x04a5 0x2211 sane-backends-1.0.29/backend/niash.c0000666000000000000000000011555213615534521014047 00000000000000/* Copyright (C) 2001 Bertrik Sikken (bertrik@zonnet.nl) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $Id$ */ /* Concept for a backend for scanners based on the NIASH chipset, such as HP3300C, HP3400C, HP4300C, Agfa Touch. Parts of this source were inspired by other backends. */ #include "../include/sane/config.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/sane/saneopts.h" #include /* malloc, free */ #include /* memcpy */ #include #include #include /* definitions for debug */ #define BACKEND_NAME niash #define BUILD 1 #define DBG_ASSERT 1 #define DBG_ERR 16 #define DBG_MSG 32 /* Just to avoid conflicts between niash backend and testtool */ #define WITH_NIASH 1 /* (source) includes for data transfer methods */ #define STATIC static #include "niash_core.c" #include "niash_xfer.c" #define ASSERT(cond) (!(cond) ? DBG(DBG_ASSERT, "!!! ASSERT(%S) FAILED!!!\n",STRINGIFY(cond));) #define MM_TO_PIXEL(_mm_, _dpi_) ((_mm_) * (_dpi_) / 25.4 ) #define PIXEL_TO_MM(_pixel_, _dpi_) ((_pixel_) * 25.4 / (_dpi_) ) /* options enumerator */ typedef enum { optCount = 0, optGroupGeometry, optTLX, optTLY, optBRX, optBRY, optDPI, optGroupImage, optGammaTable, /* gamma table */ optGroupMode, optMode, optGroupEnhancement, optThreshold, #ifdef EXPERIMENTAL optGroupMisc, optLamp, optCalibrate, optGamma, /* analog gamma = single number */ #endif optLast } EOptionIndex; typedef union { SANE_Word w; SANE_Word *wa; /* word array */ SANE_String s; } TOptionValue; #define HW_GAMMA_SIZE 4096 #define SANE_GAMMA_SIZE 4096 typedef struct { SANE_Option_Descriptor aOptions[optLast]; TOptionValue aValues[optLast]; TScanParams ScanParams; THWParams HWParams; TDataPipe DataPipe; int iLinesLeft; /* lines to scan */ int iBytesLeft; /* bytes to read */ int iPixelsPerLine; /* pixels in one scan line */ SANE_Int aGammaTable[SANE_GAMMA_SIZE]; /* a 12-to-8 bit color lookup table */ /* fCancelled needed to let sane issue the cancel message instead of an error message */ SANE_Bool fCancelled; /* SANE_TRUE if scanning cancelled */ SANE_Bool fScanning; /* SANE_TRUE if actively scanning */ int WarmUpTime; /* time to wait before a calibration starts */ unsigned char CalWhite[3]; /* values for the last calibration of white */ struct timeval WarmUpStarted; /* system type to trace the time elapsed */ } TScanner; /* linked list of SANE_Device structures */ typedef struct TDevListEntry { struct TDevListEntry *pNext; SANE_Device dev; } TDevListEntry; static TDevListEntry *_pFirstSaneDev = 0; static int iNumSaneDev = 0; static const SANE_Device **_pSaneDevList = 0; /* option constraints */ static const SANE_Range rangeGammaTable = { 0, 255, 1 }; /* available scanner resolutions */ static const SANE_Int setResolutions[] = { 4, 75, 150, 300, 600 }; #ifdef EXPERIMENTAL /* range of an analog gamma */ static const SANE_Range rangeGamma = { SANE_FIX (0.25), SANE_FIX (4.0), SANE_FIX (0.0) }; #endif /* interpolate a sane gamma table to a hardware appropriate one just in case the sane gamma table would be smaller */ static void _ConvertGammaTable (SANE_Word * saneGamma, unsigned char *hwGamma) { int i; int current = 0; for (i = 0; i < SANE_GAMMA_SIZE; ++i) { int j; int next; /* highest range of copy indices */ next = ((i + 1) * HW_GAMMA_SIZE) / SANE_GAMMA_SIZE; /* always copy the first */ hwGamma[current] = saneGamma[i]; /* the interpolation of the rest depends on the gap */ for (j = current + 1; j < HW_GAMMA_SIZE && j < next; ++j) { hwGamma[j] = (saneGamma[i] * (next - j) + saneGamma[i + 1] * (j - current)) / (next - current); } current = next; } } /* create a unity gamma table */ static void _UnityGammaTable (unsigned char *hwGamma) { int i; for (i = 0; i < HW_GAMMA_SIZE; ++i) { hwGamma[i] = (i * 256) / HW_GAMMA_SIZE; } } static const SANE_Range rangeXmm = { 0, 220, 1 }; static const SANE_Range rangeYmm = { 0, 296, 1 }; static const SANE_Int startUpGamma = SANE_FIX (1.6); static const char colorStr[] = { SANE_VALUE_SCAN_MODE_COLOR }; static const char grayStr[] = { SANE_VALUE_SCAN_MODE_GRAY }; static const char lineartStr[] = { SANE_VALUE_SCAN_MODE_LINEART }; #define DEPTH_LINEART 1 #define DEPTH_GRAY 8 #define DEPTH_COLOR 8 #define BYTES_PER_PIXEL_GRAY 1 #define BYTES_PER_PIXEL_COLOR 3 #define BITS_PER_PIXEL_LINEART 1 #define BITS_PER_PIXEL_GRAY DEPTH_GRAY #define BITS_PER_PIXEL_COLOR (DEPTH_COLOR*3) #define BITS_PER_BYTE 8 #define BITS_PADDING (BITS_PER_BYTE-1) #define MODE_COLOR 0 #define MODE_GRAY 1 #define MODE_LINEART 2 /* lineart treshold range */ static const SANE_Range rangeThreshold = { 0, 100, 1 }; /* scanning modes */ static SANE_String_Const modeList[] = { colorStr, grayStr, lineartStr, NULL }; static int _bytesPerLineLineart (int pixelsPerLine) { return (pixelsPerLine * BITS_PER_PIXEL_LINEART + BITS_PADDING) / BITS_PER_BYTE; } static int _bytesPerLineGray (int pixelsPerLine) { return (pixelsPerLine * BITS_PER_PIXEL_GRAY + BITS_PADDING) / BITS_PER_BYTE; } static int _bytesPerLineColor (int pixelsPerLine) { return (pixelsPerLine * BITS_PER_PIXEL_COLOR + BITS_PADDING) / BITS_PER_BYTE; } /* dummy*/ static void _rgb2rgb (unsigned char __sane_unused__ *buffer, int __sane_unused__ pixels, int __sane_unused__ threshold) { /* make the compiler content */ } /* convert 24bit RGB to 8bit GRAY */ static void _rgb2gray (unsigned char *buffer, int pixels, int __sane_unused__ threshold) { #define WEIGHT_R 27 #define WEIGHT_G 54 #define WEIGHT_B 19 #define WEIGHT_W (WEIGHT_R + WEIGHT_G + WEIGHT_B) static int aWeight[BYTES_PER_PIXEL_COLOR] = { WEIGHT_R, WEIGHT_G, WEIGHT_B }; int nbyte = pixels * BYTES_PER_PIXEL_COLOR; int acc = 0; int x; for (x = 0; x < nbyte; ++x) { acc += aWeight[x % BYTES_PER_PIXEL_COLOR] * buffer[x]; if ((x + 1) % BYTES_PER_PIXEL_COLOR == 0) { buffer[x / BYTES_PER_PIXEL_COLOR] = (unsigned char) (acc / WEIGHT_W); acc = 0; } } #undef WEIGHT_R #undef WEIGHT_G #undef WEIGHT_B #undef WEIGHT_W } /* convert 24bit RGB to 1bit B/W */ static void _rgb2lineart (unsigned char *buffer, int pixels, int threshold) { static const int aMask[BITS_PER_BYTE] = { 128, 64, 32, 16, 8, 4, 2, 1 }; int acc = 0; int nx; int x; int thresh; _rgb2gray (buffer, pixels, 0); nx = ((pixels + BITS_PADDING) / BITS_PER_BYTE) * BITS_PER_BYTE; thresh = 255 * threshold / rangeThreshold.max; for (x = 0; x < nx; ++x) { if (x < pixels && buffer[x] < thresh) { acc |= aMask[x % BITS_PER_BYTE]; } if ((x + 1) % BITS_PER_BYTE == 0) { buffer[x / BITS_PER_BYTE] = (unsigned char) (acc); acc = 0; } } } typedef struct tgModeParam { SANE_Int depth; SANE_Frame format; int (*bytesPerLine) (int pixelsPerLine); void (*adaptFormat) (unsigned char *rgbBuffer, int pixels, int threshold); } TModeParam; static const TModeParam modeParam[] = { {DEPTH_COLOR, SANE_FRAME_RGB, _bytesPerLineColor, _rgb2rgb}, {DEPTH_GRAY, SANE_FRAME_GRAY, _bytesPerLineGray, _rgb2gray}, {DEPTH_LINEART, SANE_FRAME_GRAY, _bytesPerLineLineart, _rgb2lineart} }; #define WARMUP_AFTERSTART 1 /* flag for 1st warm up */ #define WARMUP_INSESSION 0 #define WARMUP_TESTINTERVAL 15 /* test every 15sec */ #define WARMUP_TIME 30 /* first wait is 30sec minimum */ #define WARMUP_MAXTIME 90 /* after one and a half minute start latest */ #define CAL_DEV_MAX 15 /* maximum deviation of cal values in percent between 2 tests */ /* different warm up after start and after automatic off */ static const int aiWarmUpTime[] = { WARMUP_TESTINTERVAL, WARMUP_TIME }; /* returns 1, when the warm up time "iTime" has elasped */ static int _TimeElapsed (struct timeval *start, struct timeval *now, int iTime) { /* this is a bit strange, but can deal with overflows */ if (start->tv_sec > now->tv_sec) return (start->tv_sec / 2 - now->tv_sec / 2 > iTime / 2); else return (now->tv_sec - start->tv_sec >= iTime); } static void _WarmUpLamp (TScanner * s, int iMode) { SANE_Bool fLampOn; /* on startup don't care what was before assume lamp was off, and the previous cal values can never be reached */ if (iMode == WARMUP_AFTERSTART) { fLampOn = SANE_FALSE; s->CalWhite[0] = s->CalWhite[1] = s->CalWhite[2] = (unsigned char) (-1); } else GetLamp (&s->HWParams, &fLampOn); if (!fLampOn) { /* get the current system time */ gettimeofday (&s->WarmUpStarted, 0); /* determine the time to wait at least */ s->WarmUpTime = aiWarmUpTime[iMode]; /* switch on the lamp */ SetLamp (&s->HWParams, SANE_TRUE); } } static void _WaitForLamp (TScanner * s, unsigned char *pabCalibTable) { struct timeval now[2]; /* toggling time holder */ int i; /* rgb loop */ int iCal = 0; /* counter */ int iCurrent = 0; /* buffer and time-holder swap flag */ SANE_Bool fHasCal; unsigned char CalWhite[2][3]; /* toggling buffer */ int iDelay = 0; /* delay loop counter */ _WarmUpLamp (s, SANE_FALSE); /* get the time stamp for the wait loops */ if (s->WarmUpTime) gettimeofday (&now[iCurrent], 0); SimpleCalibExt (&s->HWParams, pabCalibTable, CalWhite[iCurrent]); fHasCal = SANE_TRUE; DBG (DBG_MSG, "_WaitForLamp: first calibration\n"); /* wait until time has elapsed or for values to stabilze */ while (s->WarmUpTime) { /* check if the last scan has lower calibration values than the current one would have */ if (s->WarmUpTime && fHasCal) { SANE_Bool fOver = SANE_TRUE; for (i = 0; fOver && i < 3; ++i) { if (!s->CalWhite[i]) fOver = SANE_FALSE; else if (CalWhite[iCurrent][i] < s->CalWhite[i]) fOver = SANE_FALSE; } /* warm up is not needed, when calibration data is above the calibration data of the last scan */ if (fOver) { s->WarmUpTime = 0; DBG (DBG_MSG, "_WaitForLamp: Values seem stable, skipping next calibration cycle\n"); } } /* break the loop, when the longest wait time has expired to prevent a hanging application, even if the values might not be good, yet */ if (s->WarmUpTime && fHasCal && iCal) { /* abort, when we have waited long enough */ if (_TimeElapsed (&s->WarmUpStarted, &now[iCurrent], WARMUP_MAXTIME)) { /* stop idling */ s->WarmUpTime = 0; DBG (DBG_MSG, "_WaitForLamp: WARMUP_MAXTIME=%ds elapsed!\n", WARMUP_MAXTIME); } } /* enter a delay loop, when there is still time to wait */ if (s->WarmUpTime) { /* if the (too low) calibration values have just been acquired we start waiting */ if (fHasCal) DBG (DBG_MSG, "_WaitForLamp: entering delay loop\r"); else DBG (DBG_MSG, "_WaitForLamp: delay loop %d \r", ++iDelay); sleep (1); fHasCal = SANE_FALSE; gettimeofday (&now[!iCurrent], 0); } /* look if we should check again */ if (s->WarmUpTime /* did we have to wait at all */ /* is the minimum time elapsed */ && _TimeElapsed (&s->WarmUpStarted, &now[!iCurrent], s->WarmUpTime) /* has the minimum time elapsed since the last calibration */ && _TimeElapsed (&now[iCurrent], &now[!iCurrent], WARMUP_TESTINTERVAL)) { int dev = 0; /* 0 percent deviation in cal value as default */ iDelay = 0; /* all delays processed */ /* new calibration */ ++iCal; iCurrent = !iCurrent; /* swap the test-buffer, and time-holder */ SimpleCalibExt (&s->HWParams, pabCalibTable, CalWhite[iCurrent]); fHasCal = SANE_TRUE; for (i = 0; i < 3; ++i) { /* copy for faster and clearer access */ int cwa; int cwb; int ldev; cwa = CalWhite[!iCurrent][i]; cwb = CalWhite[iCurrent][i]; /* find the biggest deviation of one color */ if (cwa > cwb) ldev = 0; else if (cwa && cwb) ldev = ((cwb - cwa) * 100) / cwb; else ldev = 100; dev = MAX (dev, ldev); } /* show the biggest deviation of the calibration values */ DBG (DBG_MSG, "_WaitForLamp: recalibration #%d, deviation = %d%%\n", iCal, dev); /* the deviation to the previous calibration is tolerable */ if (dev <= CAL_DEV_MAX) s->WarmUpTime = 0; } } /* remember the values of this calibration for the next time */ for (i = 0; i < 3; ++i) { s->CalWhite[i] = CalWhite[iCurrent][i]; } } /* used, when setting gamma as 1 value */ static void _SetScalarGamma (SANE_Int * aiGamma, SANE_Int sfGamma) { int j; double fGamma; fGamma = SANE_UNFIX (sfGamma); for (j = 0; j < SANE_GAMMA_SIZE; j++) { int iData; iData = floor (256.0 * pow (((double) j / (double) SANE_GAMMA_SIZE), 1.0 / fGamma)); if (iData > 255) iData = 255; aiGamma[j] = iData; } } /* return size of longest string in a string list */ static size_t _MaxStringSize (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } /* change a sane cap and return true, when a change took place */ static int _ChangeCap (SANE_Word * pCap, SANE_Word cap, int isSet) { SANE_Word prevCap = *pCap; if (isSet) { *pCap |= cap; } else { *pCap &= ~cap; } return *pCap != prevCap; } static void _InitOptions (TScanner * s) { int i; SANE_Option_Descriptor *pDesc; TOptionValue *pVal; _SetScalarGamma (s->aGammaTable, startUpGamma); for (i = optCount; i < optLast; i++) { pDesc = &s->aOptions[i]; pVal = &s->aValues[i]; /* defaults */ pDesc->name = ""; pDesc->title = ""; pDesc->desc = ""; pDesc->type = SANE_TYPE_INT; pDesc->unit = SANE_UNIT_NONE; pDesc->size = sizeof (SANE_Word); pDesc->constraint_type = SANE_CONSTRAINT_NONE; pDesc->cap = 0; switch (i) { case optCount: pDesc->title = SANE_TITLE_NUM_OPTIONS; pDesc->desc = SANE_DESC_NUM_OPTIONS; pDesc->cap = SANE_CAP_SOFT_DETECT; pVal->w = (SANE_Word) optLast; break; case optGroupGeometry: pDesc->title = "Geometry"; pDesc->type = SANE_TYPE_GROUP; pDesc->size = 0; break; case optTLX: pDesc->name = SANE_NAME_SCAN_TL_X; pDesc->title = SANE_TITLE_SCAN_TL_X; pDesc->desc = SANE_DESC_SCAN_TL_X; pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeXmm; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = rangeXmm.min; break; case optTLY: pDesc->name = SANE_NAME_SCAN_TL_Y; pDesc->title = SANE_TITLE_SCAN_TL_Y; pDesc->desc = SANE_DESC_SCAN_TL_Y; pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeYmm; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = rangeYmm.min; break; case optBRX: pDesc->name = SANE_NAME_SCAN_BR_X; pDesc->title = SANE_TITLE_SCAN_BR_X; pDesc->desc = SANE_DESC_SCAN_BR_X; pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeXmm; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = 210 /* A4 width instead of rangeXmm.max */ ; break; case optBRY: pDesc->name = SANE_NAME_SCAN_BR_Y; pDesc->title = SANE_TITLE_SCAN_BR_Y; pDesc->desc = SANE_DESC_SCAN_BR_Y; pDesc->unit = SANE_UNIT_MM; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeYmm; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = 290 /* have a bit reserve instaed of rangeYmm.max */ ; break; case optDPI: pDesc->name = SANE_NAME_SCAN_RESOLUTION; pDesc->title = SANE_TITLE_SCAN_RESOLUTION; pDesc->desc = SANE_DESC_SCAN_RESOLUTION; pDesc->unit = SANE_UNIT_DPI; pDesc->constraint_type = SANE_CONSTRAINT_WORD_LIST; pDesc->constraint.word_list = setResolutions; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = setResolutions[2]; /* default to 150dpi */ break; case optGroupImage: pDesc->title = SANE_I18N ("Image"); pDesc->type = SANE_TYPE_GROUP; pDesc->size = 0; break; #ifdef EXPERIMENTAL case optGamma: pDesc->name = SANE_NAME_ANALOG_GAMMA; pDesc->title = SANE_TITLE_ANALOG_GAMMA; pDesc->desc = SANE_DESC_ANALOG_GAMMA; pDesc->type = SANE_TYPE_FIXED; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeGamma; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->w = startUpGamma; break; #endif case optGammaTable: pDesc->name = SANE_NAME_GAMMA_VECTOR; pDesc->title = SANE_TITLE_GAMMA_VECTOR; pDesc->desc = SANE_DESC_GAMMA_VECTOR; pDesc->size = sizeof (s->aGammaTable); pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeGammaTable; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; pVal->wa = s->aGammaTable; break; #ifdef EXPERIMENTAL case optGroupMisc: pDesc->title = SANE_I18N ("Miscellaneous"); pDesc->type = SANE_TYPE_GROUP; pDesc->size = 0; break; case optLamp: pDesc->name = "lamp"; pDesc->title = SANE_I18N ("Lamp status"); pDesc->desc = SANE_I18N ("Switches the lamp on or off."); pDesc->type = SANE_TYPE_BOOL; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; /* switch the lamp on when starting for first the time */ pVal->w = SANE_TRUE; break; case optCalibrate: pDesc->name = "calibrate"; pDesc->title = SANE_I18N ("Calibrate"); pDesc->desc = SANE_I18N ("Calibrates for black and white level."); pDesc->type = SANE_TYPE_BUTTON; pDesc->cap = SANE_CAP_SOFT_SELECT; pDesc->size = 0; break; #endif case optGroupMode: pDesc->title = SANE_I18N ("Scan Mode"); pDesc->desc = ""; pDesc->type = SANE_TYPE_GROUP; break; case optMode: /* scan mode */ pDesc->name = SANE_NAME_SCAN_MODE; pDesc->title = SANE_TITLE_SCAN_MODE; pDesc->desc = SANE_DESC_SCAN_MODE; pDesc->type = SANE_TYPE_STRING; pDesc->size = _MaxStringSize (modeList); pDesc->constraint_type = SANE_CONSTRAINT_STRING_LIST; pDesc->constraint.string_list = modeList; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_EMULATED; pVal->w = MODE_COLOR; break; case optGroupEnhancement: pDesc->title = SANE_I18N ("Enhancement"); pDesc->desc = ""; pDesc->type = SANE_TYPE_GROUP; break; case optThreshold: pDesc->name = SANE_NAME_THRESHOLD; pDesc->title = SANE_TITLE_THRESHOLD; pDesc->desc = SANE_DESC_THRESHOLD; pDesc->type = SANE_TYPE_INT; pDesc->unit = SANE_UNIT_PERCENT; pDesc->constraint_type = SANE_CONSTRAINT_RANGE; pDesc->constraint.range = &rangeThreshold; pDesc->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE | SANE_CAP_EMULATED; pVal->w = 50; break; default: DBG (DBG_ERR, "Uninitialised option %d\n", i); break; } } } static int _ReportDevice (TScannerModel * pModel, const char *pszDeviceName) { TDevListEntry *pNew, *pDev; DBG (DBG_MSG, "niash: _ReportDevice '%s'\n", pszDeviceName); pNew = malloc (sizeof (TDevListEntry)); if (!pNew) { DBG (DBG_ERR, "no mem\n"); return -1; } /* add new element to the end of the list */ if (_pFirstSaneDev == 0) { _pFirstSaneDev = pNew; } else { for (pDev = _pFirstSaneDev; pDev->pNext; pDev = pDev->pNext) { ; } pDev->pNext = pNew; } /* fill in new element */ pNew->pNext = 0; pNew->dev.name = strdup (pszDeviceName); pNew->dev.vendor = pModel->pszVendor; pNew->dev.model = pModel->pszName; pNew->dev.type = "flatbed scanner"; iNumSaneDev++; return 0; } /*****************************************************************************/ SANE_Status sane_init (SANE_Int * piVersion, SANE_Auth_Callback __sane_unused__ pfnAuth) { DBG_INIT (); DBG (DBG_MSG, "sane_init\n"); if (piVersion != NULL) { *piVersion = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); } /* initialise transfer methods */ iNumSaneDev = 0; NiashXferInit (_ReportDevice); return SANE_STATUS_GOOD; } void sane_exit (void) { TDevListEntry *pDev, *pNext; DBG (DBG_MSG, "sane_exit\n"); /* free device list memory */ if (_pSaneDevList) { for (pDev = _pFirstSaneDev; pDev; pDev = pNext) { pNext = pDev->pNext; free ((void *) pDev->dev.name); free (pDev); } _pFirstSaneDev = 0; free (_pSaneDevList); _pSaneDevList = 0; } } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { TDevListEntry *pDev; int i; DBG (DBG_MSG, "sane_get_devices\n"); if (_pSaneDevList) { free (_pSaneDevList); } _pSaneDevList = malloc (sizeof (*_pSaneDevList) * (iNumSaneDev + 1)); if (!_pSaneDevList) { DBG (DBG_MSG, "no mem\n"); return SANE_STATUS_NO_MEM; } i = 0; for (pDev = _pFirstSaneDev; pDev; pDev = pDev->pNext) { _pSaneDevList[i++] = &pDev->dev; } _pSaneDevList[i++] = 0; /* last entry is 0 */ *device_list = _pSaneDevList; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h) { TScanner *s; DBG (DBG_MSG, "sane_open: %s\n", name); /* check the name */ if (strlen (name) == 0) { /* default to first available device */ name = _pFirstSaneDev->dev.name; } s = malloc (sizeof (TScanner)); if (!s) { DBG (DBG_MSG, "malloc failed\n"); return SANE_STATUS_NO_MEM; } if (NiashOpen (&s->HWParams, name) < 0) { /* is this OK ? */ DBG (DBG_ERR, "NiashOpen failed\n"); free ((void *) s); return SANE_STATUS_DEVICE_BUSY; } _InitOptions (s); s->fScanning = SANE_FALSE; s->fCancelled = SANE_FALSE; *h = s; /* Turn on lamp by default at startup */ _WarmUpLamp (s, WARMUP_AFTERSTART); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle h) { TScanner *s; DBG (DBG_MSG, "sane_close\n"); s = (TScanner *) h; /* turn off scanner lamp */ SetLamp (&s->HWParams, SANE_FALSE); /* close scanner */ NiashClose (&s->HWParams); /* free scanner object memory */ free ((void *) s); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle h, SANE_Int n) { TScanner *s; DBG (DBG_MSG, "sane_get_option_descriptor %d\n", n); if ((n < optCount) || (n >= optLast)) { return NULL; } s = (TScanner *) h; return &s->aOptions[n]; } SANE_Status sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action Action, void *pVal, SANE_Int * pInfo) { TScanner *s; static char szTable[100]; int *pi; int i; SANE_Int info; SANE_Status status; #ifdef EXPERIMENTAL SANE_Bool fLampIsOn; SANE_Bool fVal; SANE_Bool fSame; #endif DBG (DBG_MSG, "sane_control_option: option %d, action %d\n", n, Action); if ((n < optCount) || (n >= optLast)) { return SANE_STATUS_UNSUPPORTED; } if (Action == SANE_ACTION_GET_VALUE || Action == SANE_ACTION_SET_VALUE) { if (pVal == NULL) { return SANE_STATUS_INVAL; } } s = (TScanner *) h; info = 0; switch (Action) { case SANE_ACTION_GET_VALUE: switch (n) { /* Get options of type SANE_Word */ case optCount: case optDPI: #ifdef EXPERIMENTAL case optGamma: #endif case optTLX: case optTLY: case optBRX: case optBRY: case optThreshold: DBG (DBG_MSG, "sane_control_option: SANE_ACTION_GET_VALUE %d = %d\n", n, (int) s->aValues[n].w); *(SANE_Word *) pVal = s->aValues[n].w; break; /* Get options of type SANE_Word array */ case optGammaTable: DBG (DBG_MSG, "Reading gamma table\n"); memcpy (pVal, s->aValues[n].wa, s->aOptions[n].size); break; case optMode: DBG (DBG_MSG, "Reading scan mode %s\n", modeList[s->aValues[optMode].w]); strcpy ((char *) pVal, modeList[s->aValues[optMode].w]); break; #ifdef EXPERIMENTAL /* Get options of type SANE_Bool */ case optLamp: GetLamp (&s->HWParams, &fLampIsOn); *(SANE_Bool *) pVal = fLampIsOn; break; case optCalibrate: /* although this option has nothing to read, it's added here to avoid a warning when running scanimage --help */ break; #endif default: DBG (DBG_MSG, "SANE_ACTION_GET_VALUE: Invalid option (%d)\n", n); } break; case SANE_ACTION_SET_VALUE: if (s->fScanning) { DBG (DBG_ERR, "sane_control_option: SANE_ACTION_SET_VALUE not allowed during scan\n"); return SANE_STATUS_INVAL; } switch (n) { case optCount: return SANE_STATUS_INVAL; #ifdef EXPERIMENTAL case optGamma: #endif case optThreshold: case optDPI: info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case optTLX: case optTLY: case optBRX: case optBRY: status = sanei_constrain_value (&s->aOptions[n], pVal, &info); if (status != SANE_STATUS_GOOD) { DBG (DBG_ERR, "Failed to constrain option %d (%s)\n", n, s->aOptions[n].title); return status; } #ifdef EXPERIMENTAL /* check values if they are equal */ fSame = s->aValues[n].w == *(SANE_Word *) pVal; #endif /* set the values */ s->aValues[n].w = *(SANE_Word *) pVal; DBG (DBG_MSG, "sane_control_option: SANE_ACTION_SET_VALUE %d = %d\n", n, (int) s->aValues[n].w); #ifdef EXPERIMENTAL if (n == optGamma) { if (!fSame && optLast > optGammaTable) { info |= SANE_INFO_RELOAD_OPTIONS; } _SetScalarGamma (s->aGammaTable, s->aValues[n].w); } #endif break; case optGammaTable: DBG (DBG_MSG, "Writing gamma table\n"); pi = (SANE_Int *) pVal; memcpy (s->aValues[n].wa, pVal, s->aOptions[n].size); /* prepare table for debug */ strcpy (szTable, "Gamma table summary:"); for (i = 0; i < SANE_GAMMA_SIZE; i++) { if ((SANE_GAMMA_SIZE / 16) && (i % (SANE_GAMMA_SIZE / 16)) == 0) { DBG (DBG_MSG, "%s\n", szTable); szTable[0] = '\0'; } /* test for number print */ if ((SANE_GAMMA_SIZE / 64) && (i % (SANE_GAMMA_SIZE / 64)) == 0) { sprintf (szTable + strlen(szTable), " %04X", pi[i]); } } if (strlen (szTable)) { DBG (DBG_MSG, "%s\n", szTable); } break; case optMode: { SANE_Word *pCap; int fCapChanged = 0; pCap = &s->aOptions[optThreshold].cap; if (strcmp ((char const *) pVal, colorStr) == 0) { s->aValues[optMode].w = MODE_COLOR; fCapChanged = _ChangeCap (pCap, SANE_CAP_INACTIVE, 1); } if (strcmp ((char const *) pVal, grayStr) == 0) { s->aValues[optMode].w = MODE_GRAY; fCapChanged = _ChangeCap (pCap, SANE_CAP_INACTIVE, 1); } if (strcmp ((char const *) pVal, lineartStr) == 0) { s->aValues[optMode].w = MODE_LINEART; fCapChanged = _ChangeCap (pCap, SANE_CAP_INACTIVE, 0); } info |= SANE_INFO_RELOAD_PARAMS; if (fCapChanged) { info |= SANE_INFO_RELOAD_OPTIONS; } DBG (DBG_MSG, "setting scan mode: %s\n", (char const *) pVal); } break; #ifdef EXPERIMENTAL case optLamp: fVal = *(SANE_Bool *) pVal; DBG (DBG_MSG, "lamp %s\n", fVal ? "on" : "off"); if (fVal) _WarmUpLamp (s, WARMUP_INSESSION); else SetLamp (&s->HWParams, SANE_FALSE); break; case optCalibrate: /* SimpleCalib(&s->HWParams); */ break; #endif default: DBG (DBG_ERR, "SANE_ACTION_SET_VALUE: Invalid option (%d)\n", n); } if (pInfo != NULL) { *pInfo |= info; } break; case SANE_ACTION_SET_AUTO: return SANE_STATUS_UNSUPPORTED; default: DBG (DBG_ERR, "Invalid action (%d)\n", Action); return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle h, SANE_Parameters * p) { TScanner *s; TModeParam const *pMode; DBG (DBG_MSG, "sane_get_parameters\n"); s = (TScanner *) h; /* first do some checks */ if (s->aValues[optTLX].w >= s->aValues[optBRX].w) { DBG (DBG_ERR, "TLX should be smaller than BRX\n"); return SANE_STATUS_INVAL; /* proper error code? */ } if (s->aValues[optTLY].w >= s->aValues[optBRY].w) { DBG (DBG_ERR, "TLY should be smaller than BRY\n"); return SANE_STATUS_INVAL; /* proper error code? */ } pMode = &modeParam[s->aValues[optMode].w]; /* return the data */ p->format = pMode->format; p->last_frame = SANE_TRUE; p->lines = MM_TO_PIXEL (s->aValues[optBRY].w - s->aValues[optTLY].w, s->aValues[optDPI].w); p->depth = pMode->depth; p->pixels_per_line = MM_TO_PIXEL (s->aValues[optBRX].w - s->aValues[optTLX].w, s->aValues[optDPI].w); p->bytes_per_line = pMode->bytesPerLine (p->pixels_per_line); return SANE_STATUS_GOOD; } /* get the scale down factor for a resolution that is not supported by hardware */ static int _SaneEmulateScaling (int iDpi) { if (iDpi == 75) return 2; else return 1; } SANE_Status sane_start (SANE_Handle h) { TScanner *s; SANE_Parameters par; int iLineCorr; int iScaleDown; static unsigned char abGamma[HW_GAMMA_SIZE]; static unsigned char abCalibTable[HW_PIXELS * 6]; DBG (DBG_MSG, "sane_start\n"); s = (TScanner *) h; if (sane_get_parameters (h, &par) != SANE_STATUS_GOOD) { DBG (DBG_MSG, "Invalid scan parameters\n"); return SANE_STATUS_INVAL; } iScaleDown = _SaneEmulateScaling (s->aValues[optDPI].w); s->iLinesLeft = par.lines; /* fill in the scanparams using the option values */ s->ScanParams.iDpi = s->aValues[optDPI].w * iScaleDown; s->ScanParams.iLpi = s->aValues[optDPI].w * iScaleDown; /* calculate correction for filling of circular buffer */ iLineCorr = 3 * s->HWParams.iSensorSkew; /* usually 16 motor steps */ /* calculate correction for garbage lines */ iLineCorr += s->HWParams.iSkipLines * (HW_LPI / s->ScanParams.iLpi); s->ScanParams.iTop = MM_TO_PIXEL (s->aValues[optTLY].w + s->HWParams.iTopLeftY, HW_LPI) - iLineCorr; s->ScanParams.iLeft = MM_TO_PIXEL (s->aValues[optTLX].w + s->HWParams.iTopLeftX, HW_DPI); s->ScanParams.iWidth = par.pixels_per_line * iScaleDown; s->ScanParams.iHeight = par.lines * iScaleDown; s->ScanParams.iBottom = HP3300C_BOTTOM; s->ScanParams.fCalib = SANE_FALSE; /* perform a simple calibration just before scanning */ _WaitForLamp (s, abCalibTable); if (s->aValues[optMode].w == MODE_LINEART) { /* use a unity gamma table for lineart to be independent from Gamma settings */ _UnityGammaTable (abGamma); } else { /* copy gamma table */ _ConvertGammaTable (s->aGammaTable, abGamma); } WriteGammaCalibTable (abGamma, abGamma, abGamma, abCalibTable, 0, 0, &s->HWParams); /* prepare the actual scan */ if (!InitScan (&s->ScanParams, &s->HWParams)) { DBG (DBG_MSG, "Invalid scan parameters\n"); return SANE_STATUS_INVAL; } /* init data pipe */ s->DataPipe.iSkipLines = s->HWParams.iSkipLines; /* on the hp3400 and hp4300 we cannot set the top of the scan area (yet), so instead we just scan and throw away the data until the top */ if (s->HWParams.fReg07) { s->DataPipe.iSkipLines += MM_TO_PIXEL (s->aValues[optTLY].w + s->HWParams.iTopLeftY, s->aValues[optDPI].w * iScaleDown); } s->iBytesLeft = 0; s->iPixelsPerLine = par.pixels_per_line; /* hack */ s->DataPipe.pabLineBuf = (unsigned char *) malloc (HW_PIXELS * 3); CircBufferInit (s->HWParams.iXferHandle, &s->DataPipe, par.pixels_per_line, s->ScanParams.iHeight, s->ScanParams.iLpi * s->HWParams.iSensorSkew / HW_LPI, s->HWParams.iReversedHead, iScaleDown, iScaleDown); s->fScanning = SANE_TRUE; s->fCancelled = SANE_FALSE; return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle h, SANE_Byte * buf, SANE_Int maxlen, SANE_Int * len) { TScanner *s; TDataPipe *p; TModeParam const *pMode; DBG (DBG_MSG, "sane_read: buf=%p, maxlen=%d, ", buf, maxlen); s = (TScanner *) h; pMode = &modeParam[s->aValues[optMode].w]; /* sane_read only allowed after sane_start */ if (!s->fScanning) { if (s->fCancelled) { DBG (DBG_MSG, "\n"); DBG (DBG_MSG, "sane_read: sane_read cancelled\n"); s->fCancelled = SANE_FALSE; return SANE_STATUS_CANCELLED; } else { DBG (DBG_ERR, "sane_read: sane_read only allowed after sane_start\n"); return SANE_STATUS_INVAL; } } p = &s->DataPipe; /* anything left to read? */ if ((s->iLinesLeft == 0) && (s->iBytesLeft == 0)) { CircBufferExit (p); free (p->pabLineBuf); p->pabLineBuf = NULL; FinishScan (&s->HWParams); *len = 0; DBG (DBG_MSG, "\n"); DBG (DBG_MSG, "sane_read: end of scan\n"); s->fCancelled = SANE_FALSE; s->fScanning = SANE_FALSE; return SANE_STATUS_EOF; } /* time to read the next line? */ if (s->iBytesLeft == 0) { /* read a line from the transfer buffer */ if (CircBufferGetLineEx (s->HWParams.iXferHandle, p, p->pabLineBuf, s->HWParams.iReversedHead, SANE_TRUE)) { pMode->adaptFormat (p->pabLineBuf, s->iPixelsPerLine, s->aValues[optThreshold].w); s->iBytesLeft = pMode->bytesPerLine (s->iPixelsPerLine); s->iLinesLeft--; } /* stop scanning further, when the read action fails because we try read after the end of the buffer */ else { FinishScan (&s->HWParams); CircBufferExit (p); free (p->pabLineBuf); p->pabLineBuf = NULL; *len = 0; DBG (DBG_MSG, "\n"); DBG (DBG_MSG, "sane_read: read after end of buffer\n"); s->fCancelled = SANE_FALSE; s->fScanning = SANE_FALSE; return SANE_STATUS_EOF; } } /* copy (part of) a line */ *len = MIN (maxlen, s->iBytesLeft); memcpy (buf, &p->pabLineBuf[pMode->bytesPerLine (s->iPixelsPerLine) - s->iBytesLeft], *len); s->iBytesLeft -= *len; DBG (DBG_MSG, " read=%d \n", *len); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle h) { TScanner *s; DBG (DBG_MSG, "sane_cancel\n"); s = (TScanner *) h; /* Make sure the scanner head returns home */ FinishScan (&s->HWParams); /* delete allocated data */ if (s->fScanning) { CircBufferExit (&s->DataPipe); free (s->DataPipe.pabLineBuf); s->DataPipe.pabLineBuf = NULL; DBG (DBG_MSG, "sane_cancel: freeing buffers\n"); } s->fCancelled = SANE_TRUE; s->fScanning = SANE_FALSE; } SANE_Status sane_set_io_mode (SANE_Handle __sane_unused__ h, SANE_Bool m) { DBG (DBG_MSG, "sane_set_io_mode %s\n", m ? "non-blocking" : "blocking"); if (m) { return SANE_STATUS_UNSUPPORTED; } return SANE_STATUS_GOOD; } SANE_Status 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; } sane-backends-1.0.29/backend/hp3900_usb.c0000666000000000000000000003240713615534521014536 00000000000000/* HP Scanjet 3900 series - USB layer Copyright (C) 2005-2008 Jonathan Bravo Lopez 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef USBLAYER #define USBLAYER #define TIMEOUT 1000 #define BLK_READ_EP 0x81 #define BLK_WRITE_EP 0x02 SANE_Int dataline_count = 0; /* USB layer commands */ static SANE_Int usb_ctl_write (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size, SANE_Int index); static SANE_Int usb_ctl_read (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size, SANE_Int index); /* Higher level commands*/ static SANE_Int IRead_Byte (USB_Handle usb_handle, SANE_Int address, SANE_Byte * data, SANE_Int index); static SANE_Int IRead_Word (USB_Handle usb_handle, SANE_Int address, SANE_Int * data, SANE_Int index); static SANE_Int IRead_Integer (USB_Handle usb_handle, SANE_Int address, SANE_Int * data, SANE_Int index); static SANE_Int IRead_Buffer (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size, SANE_Int index); static SANE_Int IWrite_Byte (USB_Handle usb_handle, SANE_Int address, SANE_Byte data, SANE_Int index1, SANE_Int index2); static SANE_Int IWrite_Word (USB_Handle usb_handle, SANE_Int address, SANE_Int data, SANE_Int index); static SANE_Int IWrite_Integer (USB_Handle usb_handle, SANE_Int address, SANE_Int data, SANE_Int index); static SANE_Int IWrite_Buffer (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size, SANE_Int index); static SANE_Int Read_Byte (USB_Handle usb_handle, SANE_Int address, SANE_Byte * data); static SANE_Int Read_Word (USB_Handle usb_handle, SANE_Int address, SANE_Int * data); static SANE_Int Read_Integer (USB_Handle usb_handle, SANE_Int address, SANE_Int * data); static SANE_Int Read_Buffer (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size); static SANE_Int Read_Bulk (USB_Handle usb_handle, SANE_Byte * buffer, size_t size); static SANE_Int Write_Byte (USB_Handle usb_handle, SANE_Int address, SANE_Byte data); static SANE_Int Write_Word (USB_Handle usb_handle, SANE_Int address, SANE_Int data); /*static SANE_Int Write_Integer (USB_Handle usb_handle, SANE_Int address, SANE_Int data);*/ static SANE_Int Write_Buffer (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size); static SANE_Int Write_Bulk (USB_Handle usb_handle, SANE_Byte * buffer, SANE_Int size); static SANE_Int show_buffer (SANE_Int level, SANE_Byte * buffer, SANE_Int size); /* Implementation */ static SANE_Int IWrite_Byte (USB_Handle usb_handle, SANE_Int address, SANE_Byte data, SANE_Int index1, SANE_Int index2) { SANE_Int rst = ERROR; SANE_Byte buffer[2] = { 0x00, 0x00 }; if (usb_ctl_read (usb_handle, address + 1, buffer, 0x02, index1) == 2) { buffer[1] = (buffer[0] & 0xff); buffer[0] = (data & 0xff); if (usb_ctl_write (usb_handle, address, buffer, 0x02, index2) == 2) rst = OK; } return rst; } static SANE_Int IWrite_Word (USB_Handle usb_handle, SANE_Int address, SANE_Int data, SANE_Int index) { SANE_Int rst = ERROR; SANE_Byte buffer[2]; buffer[0] = (data & 0xff); buffer[1] = ((data >> 8) & 0xff); if (usb_ctl_write (usb_handle, address, buffer, 0x02, index) == 2) rst = OK; return rst; } static SANE_Int IWrite_Integer (USB_Handle usb_handle, SANE_Int address, SANE_Int data, SANE_Int index) { SANE_Int rst = ERROR; SANE_Byte buffer[4]; buffer[0] = (data & 0xff); buffer[1] = ((data >> 8) & 0xff); buffer[2] = ((data >> 16) & 0xff); buffer[3] = ((data >> 24) & 0xff); if (usb_ctl_write (usb_handle, address, buffer, 0x04, index) == 4) rst = OK; return rst; } static SANE_Int IWrite_Buffer (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size, SANE_Int index) { SANE_Int ret = ERROR; if (!((buffer == NULL) && (size > 0))) if (usb_ctl_write (usb_handle, address, buffer, size, index) == size) ret = OK; return ret; } static SANE_Int IRead_Byte (USB_Handle usb_handle, SANE_Int address, SANE_Byte * data, SANE_Int index) { SANE_Byte buffer[2] = { 0x00, 0x00 }; SANE_Int ret = ERROR; if (data != NULL) if (usb_ctl_read (usb_handle, address, buffer, 0x02, index) == 2) { *data = (SANE_Byte) (buffer[0] & 0xff); ret = OK; } return ret; } static SANE_Int IRead_Word (USB_Handle usb_handle, SANE_Int address, SANE_Int * data, SANE_Int index) { SANE_Byte buffer[2] = { 0x00, 0x00 }; SANE_Int ret = ERROR; if (data != NULL) if (usb_ctl_read (usb_handle, address, buffer, 0x02, index) == 2) { *data = ((buffer[1] << 8) & 0xffff) + (buffer[0] & 0xff); ret = OK; } return ret; } static SANE_Int IRead_Integer (USB_Handle usb_handle, SANE_Int address, SANE_Int * data, SANE_Int index) { SANE_Byte buffer[4] = { 0x00, 0x00, 0x00, 0x00 }; SANE_Int ret = ERROR; if (data != NULL) { *data = 0; if (usb_ctl_read (usb_handle, address, buffer, 0x04, index) == 4) { SANE_Int C; for (C = 3; C >= 0; C--) *data = ((*data << 8) + (buffer[C] & 0xff)) & 0xffffffff; ret = OK; } } return ret; } static SANE_Int IRead_Buffer (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size, SANE_Int index) { SANE_Int ret = ERROR; if (buffer != NULL) if (usb_ctl_read (usb_handle, address, buffer, size, index) == size) ret = OK; return ret; } static SANE_Int Write_Byte (USB_Handle usb_handle, SANE_Int address, SANE_Byte data) { return IWrite_Byte (usb_handle, address, data, 0x100, 0); } static SANE_Int Write_Word (USB_Handle usb_handle, SANE_Int address, SANE_Int data) { return IWrite_Word (usb_handle, address, data, 0); } /*static SANE_Int Write_Integer(USB_Handle usb_handle, SANE_Int address, SANE_Int data) { return IWrite_Integer(usb_handle, address, data, 0); }*/ static SANE_Int Write_Buffer (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size) { return IWrite_Buffer (usb_handle, address, buffer, size, 0); } static SANE_Int Read_Byte (USB_Handle usb_handle, SANE_Int address, SANE_Byte * data) { return IRead_Byte (usb_handle, address, data, 0x100); } static SANE_Int Read_Word (USB_Handle usb_handle, SANE_Int address, SANE_Int * data) { return IRead_Word (usb_handle, address, data, 0x100); } static SANE_Int Read_Integer (USB_Handle usb_handle, SANE_Int address, SANE_Int * data) { return IRead_Integer (usb_handle, address, data, 0x100); } static SANE_Int Read_Buffer (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size) { return IRead_Buffer (usb_handle, address, buffer, size, 0x100); } static SANE_Int Write_Bulk (USB_Handle usb_handle, SANE_Byte * buffer, SANE_Int size) { SANE_Int rst = ERROR; if (buffer != NULL) { dataline_count++; DBG (DBG_CTL, "%06i BLK DO: %i. bytes\n", dataline_count, size); show_buffer (4, buffer, size); #ifdef STANDALONE if (usb_handle != NULL) if (usb_bulk_write (usb_handle, BLK_WRITE_EP, (char *) buffer, size, TIMEOUT) == size) rst = OK; #else if (usb_handle != -1) { size_t mysize = size; if (sanei_usb_write_bulk (usb_handle, buffer, &mysize) == SANE_STATUS_GOOD) rst = OK; } #endif } if (rst != OK) DBG (DBG_CTL, " : Write_Bulk error\n"); return rst; } static SANE_Int Read_Bulk (USB_Handle usb_handle, SANE_Byte * buffer, size_t size) { SANE_Int rst = ERROR; if (buffer != NULL) { dataline_count++; DBG (DBG_CTL, "%06i BLK DI: Buffer length = %lu. bytes\n", dataline_count, (u_long) size); #ifdef STANDALONE if (usb_handle != NULL) rst = usb_bulk_read (usb_handle, BLK_READ_EP, (char *) buffer, size, TIMEOUT); #else if (usb_handle != -1) if (sanei_usb_read_bulk (usb_handle, buffer, &size) == SANE_STATUS_GOOD) rst = size; #endif } if (rst < 0) DBG (DBG_CTL, " : Read_Bulk error\n"); else show_buffer (4, buffer, rst); return rst; } static SANE_Int usb_ctl_write (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size, SANE_Int index) { SANE_Int rst = ERROR; dataline_count++; DBG (DBG_CTL, "%06i CTL DO: 40 04 %04x %04x %04x\n", dataline_count, address & 0xffff, index, size); show_buffer (DBG_CTL, buffer, size); #ifdef STANDALONE if (usb_handle != NULL) rst = usb_control_msg (usb_handle, 0x40, /* Request type */ 0x04, /* Request */ address, /* Value */ index, /* Index */ (char *) buffer, /* Buffer */ size, /* Size */ TIMEOUT); #else if (usb_handle != -1) { if (sanei_usb_control_msg (usb_handle, 0x40, /* Request type */ 0x04, /* Request */ address, /* Value */ index, /* Index */ size, /* Size */ buffer) /* Buffer */ == SANE_STATUS_GOOD) rst = size; else rst = -1; } #endif if (rst < 0) DBG (DBG_CTL, " : Error, returned %i\n", rst); return rst; } static SANE_Int usb_ctl_read (USB_Handle usb_handle, SANE_Int address, SANE_Byte * buffer, SANE_Int size, SANE_Int index) { SANE_Int rst; rst = ERROR; dataline_count++; DBG (DBG_CTL, "%06i CTL DI: c0 04 %04x %04x %04x\n", dataline_count, address & 0xffff, index, size); #ifdef STANDALONE if (usb_handle != NULL) rst = usb_control_msg (usb_handle, 0xc0, /* Request type */ 0x04, /* Request */ address, /* Value */ index, /* Index */ (char *) buffer, /* Buffer */ size, /* Size */ TIMEOUT); #else if (usb_handle != -1) { if (sanei_usb_control_msg (usb_handle, 0xc0, /* Request type */ 0x04, /* Request */ address, /* Value */ index, /* Index */ size, /* Size */ buffer) /* Buffer */ == SANE_STATUS_GOOD) rst = size; else rst = -1; } #endif if (rst < 0) DBG (DBG_CTL, " : Error, returned %i\n", rst); else show_buffer (DBG_CTL, buffer, rst); return rst; } static SANE_Int show_buffer (SANE_Int level, SANE_Byte * buffer, SANE_Int size) { if (DBG_LEVEL >= level) { char *sline = NULL; char *sdata = NULL; SANE_Int cont, data, offset = 0, col = 0; if ((size > 0) && (buffer != NULL)) { sline = (char *) malloc (256); if (sline != NULL) { sdata = (char *) malloc (256); if (sdata != NULL) { memset (sline, 0, 256); for (cont = 0; cont < size; cont++) { if (col == 0) { if (cont == 0) snprintf (sline, 255, " BF: "); else snprintf (sline, 255, " "); } data = (buffer[cont] & 0xff); snprintf (sdata, 255, "%02x ", data); sline = strcat (sline, sdata); col++; offset++; if (col == 8) { col = 0; snprintf (sdata, 255, " : %i\n", offset - 8); sline = strcat (sline, sdata); DBG (level, "%s", sline); memset (sline, 0, 256); } } if (col > 0) { for (cont = col; cont < 8; cont++) { snprintf (sdata, 255, "-- "); sline = strcat (sline, sdata); offset++; } snprintf (sdata, 255, " : %i\n", offset - 8); sline = strcat (sline, sdata); DBG (level, "%s", sline); memset (sline, 0, 256); } free (sdata); } free (sline); } } else DBG (level, " BF: Empty buffer\n"); } return OK; } #endif /*USBLAYER*/ sane-backends-1.0.29/backend/epsonds-ops.c0000666000000000000000000002556413615534521015222 00000000000000/* * epsonds-ops.c - Epson ESC/I-2 driver, support routines. * * Copyright (C) 2015 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" #include /* sleep */ #ifdef HAVE_SYS_SELECT_H #include #endif #include "epsonds.h" #include "epsonds-io.h" #include "epsonds-ops.h" #include "epsonds-cmd.h" extern struct mode_param mode_params[]; /* Define the different scan sources */ #define FBF_STR SANE_I18N("Flatbed") #define TPU_STR SANE_I18N("Transparency Unit") #define ADF_STR SANE_I18N("Automatic Document Feeder") extern SANE_String_Const source_list[]; void eds_dev_init(epsonds_device *dev) { dev->res_list = malloc(sizeof(SANE_Word)); dev->res_list[0] = 0; dev->depth_list = malloc(sizeof(SANE_Word)); dev->depth_list[0] = 0; } SANE_Status eds_dev_post_init(struct epsonds_device *dev) { SANE_String_Const *source_list_add = source_list; DBG(10, "%s\n", __func__); if (dev->has_fb) *source_list_add++ = FBF_STR; if (dev->has_adf) *source_list_add++ = ADF_STR; if (source_list[0] == 0 || (dev->res_list[0] == 0 && dev->dpi_range.min == 0) || dev->depth_list[0] == 0) { DBG(1, "something is wrong in the discovery process, aborting.\n"); DBG(1, "sources: %ld, res: %d, depths: %d.\n", source_list_add - source_list, dev->res_list[0], dev->depth_list[0]); return SANE_STATUS_INVAL; } 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) { DBG(10, "%s: add (dpi): %d\n", __func__, r); /* first element is the list size */ dev->res_list[0]++; dev->res_list = realloc(dev->res_list, (dev->res_list[0] + 1) * sizeof(SANE_Word)); if (dev->res_list == NULL) return SANE_STATUS_NO_MEM; dev->res_list[dev->res_list[0]] = r; return SANE_STATUS_GOOD; } SANE_Status eds_set_resolution_range(epsonds_device *dev, int min, int max) { DBG(10, "%s: set min/max (dpi): %d/%d\n", __func__, min, max); dev->dpi_range.min = min; dev->dpi_range.max = max; dev->dpi_range.quant = 1; return SANE_STATUS_GOOD; } void eds_set_fbf_area(epsonds_device *dev, int x, int y, int unit) { if (x == 0 || y == 0) return; dev->fbf_x_range.min = 0; dev->fbf_x_range.max = SANE_FIX(x * MM_PER_INCH / unit); dev->fbf_x_range.quant = 0; dev->fbf_y_range.min = 0; dev->fbf_y_range.max = SANE_FIX(y * MM_PER_INCH / unit); dev->fbf_y_range.quant = 0; DBG(5, "%s: %f,%f %f,%f %d [mm]\n", __func__, SANE_UNFIX(dev->fbf_x_range.min), SANE_UNFIX(dev->fbf_y_range.min), SANE_UNFIX(dev->fbf_x_range.max), SANE_UNFIX(dev->fbf_y_range.max), unit); } void eds_set_adf_area(struct epsonds_device *dev, int x, int y, int unit) { dev->adf_x_range.min = 0; dev->adf_x_range.max = SANE_FIX(x * MM_PER_INCH / unit); dev->adf_x_range.quant = 0; dev->adf_y_range.min = 0; dev->adf_y_range.max = SANE_FIX(y * MM_PER_INCH / unit); dev->adf_y_range.quant = 0; DBG(5, "%s: %f,%f %f,%f %d [mm]\n", __func__, SANE_UNFIX(dev->adf_x_range.min), SANE_UNFIX(dev->adf_y_range.min), SANE_UNFIX(dev->adf_x_range.max), SANE_UNFIX(dev->adf_y_range.max), unit); } void eds_set_tpu_area(struct epsonds_device *dev, int x, int y, int unit) { dev->tpu_x_range.min = 0; dev->tpu_x_range.max = SANE_FIX(x * MM_PER_INCH / unit); dev->tpu_x_range.quant = 0; dev->tpu_y_range.min = 0; dev->tpu_y_range.max = SANE_FIX(y * MM_PER_INCH / unit); dev->tpu_y_range.quant = 0; DBG(5, "%s: %f,%f %f,%f %d [mm]\n", __func__, SANE_UNFIX(dev->tpu_x_range.min), SANE_UNFIX(dev->tpu_y_range.min), SANE_UNFIX(dev->tpu_x_range.max), SANE_UNFIX(dev->tpu_y_range.max), unit); } SANE_Status eds_add_depth(epsonds_device *dev, SANE_Word depth) { DBG(5, "%s: add (bpp): %d\n", __func__, depth); /* > 8bpp not implemented yet */ if (depth > 8) { DBG(1, " not supported"); return SANE_STATUS_GOOD; } if (depth > dev->max_depth) dev->max_depth = depth; /* first element is the list size */ dev->depth_list[0]++; dev->depth_list = realloc(dev->depth_list, (dev->depth_list[0] + 1) * sizeof(SANE_Word)); if (dev->depth_list == NULL) return SANE_STATUS_NO_MEM; dev->depth_list[dev->depth_list[0]] = depth; return SANE_STATUS_GOOD; } SANE_Status eds_init_parameters(epsonds_scanner *s) { int dpi, bytes_per_pixel; memset(&s->params, 0, sizeof(SANE_Parameters)); 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 || SANE_UNFIX(s->val[OPT_BR_X].w) == 0) return SANE_STATUS_INVAL; s->left = ((SANE_UNFIX(s->val[OPT_TL_X].w) / MM_PER_INCH) * s->val[OPT_RESOLUTION].w) + 0.5; s->top = ((SANE_UNFIX(s->val[OPT_TL_Y].w) / MM_PER_INCH) * s->val[OPT_RESOLUTION].w) + 0.5; s->params.pixels_per_line = ((SANE_UNFIX(s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) / MM_PER_INCH) * dpi) + 0.5; s->params.lines = ((SANE_UNFIX(s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) / MM_PER_INCH) * dpi) + 0.5; DBG(5, "%s: tlx %f tly %f brx %f bry %f [mm]\n", __func__, SANE_UNFIX(s->val[OPT_TL_X].w), SANE_UNFIX(s->val[OPT_TL_Y].w), SANE_UNFIX(s->val[OPT_BR_X].w), SANE_UNFIX(s->val[OPT_BR_Y].w)); DBG(5, "%s: tlx %d tly %d brx %d bry %d [dots @ %d dpi]\n", __func__, s->left, s->top, s->params.pixels_per_line, s->params.lines, dpi); /* center aligned? */ if (s->hw->alignment == 1) { SANE_Int offset = ((SANE_UNFIX(s->hw->x_range->max) / MM_PER_INCH) * dpi) + 0.5; s->left += ((offset - s->params.pixels_per_line) / 2); DBG(5, "%s: centered to tlx %d tly %d brx %d bry %d [dots @ %d dpi]\n", __func__, s->left, s->top, s->params.pixels_per_line, s->params.lines, dpi); } /* * Calculate bytes_per_pixel and bytes_per_line for * any color depths. * * The default color depth is stored in mode_params.depth: */ /* 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 ... */ bytes_per_pixel++; } /* pixels_per_line is rounded to the next 8bit boundary */ s->params.pixels_per_line = s->params.pixels_per_line & ~7; s->params.last_frame = SANE_TRUE; switch (s->val[OPT_MODE].w) { case MODE_BINARY: case MODE_GRAY: s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8; break; case MODE_COLOR: s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line = 3 * s->params.pixels_per_line * bytes_per_pixel; break; } if (s->params.bytes_per_line == 0) { DBG(1, "bytes_per_line is ZERO\n"); return SANE_STATUS_INVAL; } /* * If (s->top + s->params.lines) is larger than the max scan area, reset * the number of scan lines: * XXX: precalculate the maximum scanning area elsewhere (use dev max_y) */ if (SANE_UNFIX(s->val[OPT_BR_Y].w) / MM_PER_INCH * dpi < (s->params.lines + s->top)) { s->params.lines = ((int) SANE_UNFIX(s->val[OPT_BR_Y].w) / MM_PER_INCH * dpi + 0.5) - s->top; } if (s->params.lines <= 0) { DBG(1, "wrong number of lines: %d\n", s->params.lines); return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } void eds_copy_image_from_ring(epsonds_scanner *s, SANE_Byte *data, SANE_Int max_length, SANE_Int *length) { int lines, available; int hw_line_size = (s->params.bytes_per_line + s->dummy); /* trim max_length to a multiple of hw_line_size */ max_length -= (max_length % hw_line_size); /* check available data */ available = eds_ring_avail(s->current); if (max_length > available) max_length = available; lines = max_length / hw_line_size; DBG(18, "copying %d lines (%d, %d)\n", lines, s->params.bytes_per_line, s->dummy); /* need more data? */ if (lines == 0) { *length = 0; return; } *length = (lines * s->params.bytes_per_line); /* we need to copy one line at time, skipping * dummy bytes at the end of each line */ /* lineart */ if (s->params.depth == 1) { while (lines--) { int i; SANE_Byte *p; eds_ring_read(s->current, s->line_buffer, s->params.bytes_per_line); eds_ring_skip(s->current, s->dummy); p = s->line_buffer; for (i = 0; i < s->params.bytes_per_line; i++) { *data++ = ~*p++; } } } else { /* gray and color */ while (lines--) { eds_ring_read(s->current, data, s->params.bytes_per_line); eds_ring_skip(s->current, s->dummy); data += s->params.bytes_per_line; } } } SANE_Status eds_ring_init(ring_buffer *ring, SANE_Int size) { ring->ring = realloc(ring->ring, size); if (!ring->ring) { return SANE_STATUS_NO_MEM; } ring->size = size; ring->fill = 0; ring->end = ring->ring + size; ring->wp = ring->rp = ring->ring; return SANE_STATUS_GOOD; } SANE_Status eds_ring_write(ring_buffer *ring, SANE_Byte *buf, SANE_Int size) { SANE_Int tail; if (size > (ring->size - ring->fill)) { DBG(1, "ring buffer full, requested: %d, available: %d\n", size, ring->size - ring->fill); return SANE_STATUS_NO_MEM; } tail = ring->end - ring->wp; if (size < tail) { memcpy(ring->wp, buf, size); ring->wp += size; ring->fill += size; } else { memcpy(ring->wp, buf, tail); size -= tail; ring->wp = ring->ring; memcpy(ring->wp, buf + tail, size); ring->wp += size; ring->fill += (tail + size); } return SANE_STATUS_GOOD; } SANE_Int eds_ring_read(ring_buffer *ring, SANE_Byte *buf, SANE_Int size) { SANE_Int tail; DBG(18, "reading from ring, %d bytes available\n", (int)ring->fill); /* limit read to available */ if (size > ring->fill) { DBG(1, "not enough data in the ring, shouldn't happen\n"); size = ring->fill; } tail = ring->end - ring->rp; if (size < tail) { memcpy(buf, ring->rp, size); ring->rp += size; ring->fill -= size; return size; } else { memcpy(buf, ring->rp, tail); size -= tail; ring->rp = ring->ring; memcpy(buf + tail, ring->rp, size); ring->rp += size; ring->fill -= (size + tail); return size + tail; } } SANE_Int eds_ring_skip(ring_buffer *ring, SANE_Int size) { SANE_Int tail; /* limit skip to available */ if (size > ring->fill) size = ring->fill; tail = ring->end - ring->rp; if (size < tail) { ring->rp += size; } else { ring->rp = ring->ring + (size - tail); } ring->fill -= size; return size; } SANE_Int eds_ring_avail(ring_buffer *ring) { return ring->fill; } void eds_ring_flush(ring_buffer *ring) { eds_ring_skip(ring, ring->fill); } sane-backends-1.0.29/backend/dmc.h0000666000000000000000000000764113615534521013514 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1998 David F. Skoll 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* $Id$ */ #ifndef polaroid_dmc_h #define polaroid_dmc_h #include #define BYTES_PER_RAW_LINE 1599 typedef enum { OPT_NUM_OPTS = 0, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_MODE_GROUP, /* Image acquisition mode */ OPT_IMAGE_MODE, /* Thumbnail, center cut or MFI'd image */ OPT_ASA, /* ASA Settings */ OPT_SHUTTER_SPEED, /* Shutter speed */ OPT_WHITE_BALANCE, /* White balance */ /* must come last: */ NUM_OPTIONS } DMC_Option; typedef struct DMC_Device { struct DMC_Device *next; SANE_Device sane; SANE_Range shutterSpeedRange; unsigned int shutterSpeed; int asa; int whiteBalance; } DMC_Device; typedef struct DMC_Camera { /* all the state needed to define a scan request: */ struct DMC_Camera *next; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Parameters params; size_t bytes_to_read; SANE_Range tl_x_range; SANE_Range tl_y_range; SANE_Range br_x_range; SANE_Range br_y_range; int imageMode; /* The DMC needs certain reads to be done in one chunk, meaning we might have to buffer them. */ char *readBuffer; char *readPtr; int inViewfinderMode; int fd; /* SCSI filedescriptor */ SANE_Byte currentRawLine[BYTES_PER_RAW_LINE]; SANE_Byte nextRawLine[BYTES_PER_RAW_LINE]; int nextRawLineValid; /* scanner dependent/low-level state: */ DMC_Device *hw; } DMC_Camera; /* We only support the following four imaging modes */ #define IMAGE_MFI 0x0000 /* 801x600 filtered image */ #define IMAGE_VIEWFINDER 0x0001 /* 270x201 viewfinder image */ #define IMAGE_RAW 0x0002 /* 1599x600 raw image */ #define IMAGE_THUMB 0x0003 /* 80x60 thumbnail image */ #define IMAGE_SUPER_RES 0x0004 #define NUM_IMAGE_MODES 5 #define ASA_25 0 #define ASA_50 1 #define ASA_100 2 #define WHITE_BALANCE_DAYLIGHT 0 #define WHITE_BALANCE_INCANDESCENT 1 #define WHITE_BALANCE_FLUORESCENT 2 #endif /* polaroid_dmc_h */ sane-backends-1.0.29/backend/sm3840_lib.c0000666000000000000000000006136013615534521014526 00000000000000/* sane - Scanner Access Now Easy. ScanMaker 3840 Backend Copyright (C) 2005-7 Earle F. Philhower, III earle@ziplabel.com - http://www.ziplabel.com 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include #include #include #include "sm3840_lib.h" #ifndef BACKENDNAME /* For standalone compilation */ static void DBG (int ignored, const char *fmt, ...) { va_list a; va_start (a, fmt); vfprintf (stderr, fmt, a); va_end (a); } #else /* For SANE compilation, convert libusb to sanei_usb */ static int my_usb_bulk_write (p_usb_dev_handle dev, int ep, unsigned char *bytes, int size, int timeout) { SANE_Status status; size_t my_size; timeout = timeout; ep = ep; my_size = size; status = sanei_usb_write_bulk ((SANE_Int) dev, (SANE_Byte *) bytes, &my_size); if (status != SANE_STATUS_GOOD) my_size = -1; return my_size; } static int my_usb_bulk_read (p_usb_dev_handle dev, int ep, unsigned char *bytes, int size, int timeout) { SANE_Status status; size_t my_size; timeout = timeout; ep = ep; my_size = size; status = sanei_usb_read_bulk ((SANE_Int) dev, (SANE_Byte *) bytes, &my_size); if (status != SANE_STATUS_GOOD) my_size = -1; return my_size; } static int my_usb_control_msg (p_usb_dev_handle dev, int requesttype, int request, int value, int index, unsigned char *bytes, int size, int timeout) { SANE_Status status; timeout = timeout; status = sanei_usb_control_msg ((SANE_Int) dev, (SANE_Int) requesttype, (SANE_Int) request, (SANE_Int) value, (SANE_Int) index, (SANE_Int) size, (SANE_Byte *) bytes); return status; } #endif /* Sanitize and convert scan parameters from inches to pixels */ static void prepare_params (SM3840_Params * params) { if (params->gray) params->gray = 1; if (params->lineart) { params->gray = 1; params->lineart = 1; } if (params->halftone) { params->gray = 1; params->halftone = 1; } if (params->dpi != 1200 && params->dpi != 600 && params->dpi != 300 && params->dpi != 150) params->dpi = 150; if (params->bpp != 8 && params->bpp != 16) params->bpp = 8; /* Sanity check input sizes */ if (params->top < 0) params->top = 0; if (params->left < 0) params->left = 0; if (params->width < 0) params->width = 0; if (params->height < 0) params->height = 0; if ((params->top + params->height) > 11.7) params->height = 11.7 - params->top; if ((params->left + params->width) > 8.5) params->width = 8.5 - params->left; params->topline = params->top * params->dpi; params->scanlines = params->height * params->dpi; params->leftpix = params->left * params->dpi; params->leftpix &= ~1; /* Always start on even pixel boundary for remap */ /* Scanpix always a multiple of 128 */ params->scanpix = params->width * params->dpi; params->scanpix = (params->scanpix + 127) & ~127; /* Sanity check outputs... */ if (params->topline < 0) params->topline = 0; if (params->scanlines < 1) params->scanlines = 1; if (params->leftpix < 0) params->leftpix = 0; if (params->scanpix < 128) params->scanpix = 128; /* Some handy calculations */ params->linelen = params->scanpix * (params->bpp / 8) * (params->gray ? 1 : 3); } #ifndef BACKENDNAME usb_dev_handle * find_device (unsigned int idVendor, unsigned int idProduct) { struct usb_bus *bus; struct usb_device *dev; usb_init (); usb_find_busses (); usb_find_devices (); for (bus = usb_get_busses (); bus; bus = bus->next) for (dev = bus->devices; dev; dev = dev->next) if (dev->descriptor.idVendor == idVendor && dev->descriptor.idProduct == idProduct) return usb_open (dev); return NULL; } #endif static void idle_ab (p_usb_dev_handle udev) { int i; unsigned char buff[8] = { 0x64, 0x65, 0x16, 0x17, 0x64, 0x65, 0x44, 0x45 }; for (i = 0; i < 8; i++) { usb_control_msg (udev, 0x40, 0x0c, 0x0090, 0x0000, buff + i, 0x0001, wr_timeout); } } /* CW: 40 04 00b0 0000 : ... */ static void write_regs (p_usb_dev_handle udev, int regs, unsigned char reg1, unsigned char val1, ... /*unsigned char reg, unsigned char val, ... */ ) { unsigned char buff[512]; va_list marker; int i; va_start (marker, val1); buff[0] = reg1; buff[1] = val1; for (i = 1; i < regs; i++) { buff[i * 2] = va_arg (marker, int); buff[i * 2 + 1] = va_arg (marker, int); } va_end (marker); usb_control_msg (udev, 0x40, 0x04, 0x00b0, 0x0000, buff, regs * 2, wr_timeout); } static int write_vctl (p_usb_dev_handle udev, int request, int value, int index, unsigned char byte) { return usb_control_msg (udev, 0x40, request, value, index, &byte, 1, wr_timeout); } static int read_vctl (p_usb_dev_handle udev, int request, int value, int index, unsigned char *byte) { return usb_control_msg (udev, 0xc0, request, value, index, byte, 1, wr_timeout); } #ifndef BACKENDNAME /* Copy from a USB data pipe to a file with optional header */ static void record_head (p_usb_dev_handle udev, char *fname, int bytes, char *header) { FILE *fp; unsigned char buff[65536]; int len; int toread; fp = fopen (fname, "wb"); if (header) fprintf (fp, "%s", header); do { toread = (bytes > 65536) ? 65536 : bytes; len = usb_bulk_read (udev, 1, buff, toread, rd_timeout); if (len > 0) { fwrite (buff, len, 1, fp); bytes -= len; } else { DBG (2, "TIMEOUT\n"); } } while (bytes); fclose (fp); } /* Copy from a USB data pipe to a file without header */ static void record (p_usb_dev_handle udev, char *fname, int bytes) { record_head (udev, fname, bytes, ""); } #endif static int max (int a, int b) { return (a > b) ? a : b; } #define DPI1200SHUFFLE 6 static void record_line (int reset, p_usb_dev_handle udev, unsigned char *storeline, int dpi, int scanpix, int gray, int bpp16, int *save_i, unsigned char **save_scan_line, unsigned char **save_dpi1200_remap, unsigned char **save_color_remap) { unsigned char *scan_line, *dpi1200_remap; unsigned char *color_remap; int i; int red_delay, blue_delay, green_delay; int j; int linelen; int pixsize; unsigned char *ptrcur, *ptrprev; unsigned char *savestoreline; int lineptr, outline, bufflines; i = *save_i; scan_line = *save_scan_line; dpi1200_remap = *save_dpi1200_remap; color_remap = *save_color_remap; pixsize = (gray ? 1 : 3) * (bpp16 ? 2 : 1); linelen = scanpix * pixsize; if (gray) { red_delay = 0; blue_delay = 0; green_delay = 0; } else if (dpi == 150) { red_delay = 0; blue_delay = 6; green_delay = 3; } else if (dpi == 300) { red_delay = 0; blue_delay = 12; green_delay = 6; } else if (dpi == 600) { red_delay = 0; blue_delay = 24; green_delay = 12; } else /*(dpi==1200) */ { red_delay = 0; blue_delay = 48; green_delay = 24; } bufflines = max (max (red_delay, blue_delay), green_delay) + 1; if (reset) { if (dpi1200_remap) free (dpi1200_remap); if (scan_line) free (scan_line); if (color_remap) free (color_remap); *save_color_remap = color_remap = (unsigned char *) malloc (bufflines * linelen); *save_scan_line = scan_line = (unsigned char *) calloc (linelen, 1); if (dpi == 1200) *save_dpi1200_remap = dpi1200_remap = (unsigned char *) calloc (linelen, DPI1200SHUFFLE); else *save_dpi1200_remap = dpi1200_remap = NULL; *save_i = i = 0; /* i is our linenumber */ } while (1) { /* We'll exit inside the loop... */ usb_bulk_read (udev, 1, scan_line, linelen, rd_timeout); if (dpi == 1200) { ptrcur = dpi1200_remap + (linelen * (i % DPI1200SHUFFLE)); ptrprev = dpi1200_remap + (linelen * ((i - (DPI1200SHUFFLE - 2)) % DPI1200SHUFFLE)); } else { ptrcur = scan_line; ptrprev = NULL; } if (gray) { memcpy (ptrcur, scan_line, linelen); } else { int pixsize = bpp16 ? 2 : 1; int pix = linelen / (3 * pixsize); unsigned char *outbuff = ptrcur; outline = i; lineptr = i % bufflines; memcpy (color_remap + linelen * lineptr, scan_line, linelen); outline++; if (outline > bufflines) { int redline = (outline + red_delay) % bufflines; int greenline = (outline + green_delay) % bufflines; int blueline = (outline + blue_delay) % bufflines; unsigned char *rp, *gp, *bp; rp = color_remap + linelen * redline; gp = color_remap + linelen * greenline + 1 * pixsize; bp = color_remap + linelen * blueline + 2 * pixsize; for (j = 0; j < pix; j++) { if (outbuff) { *(outbuff++) = *rp; if (pixsize == 2) *(outbuff++) = *(rp + 1); *(outbuff++) = *gp; if (pixsize == 2) *(outbuff++) = *(gp + 1); *(outbuff++) = *bp; if (pixsize == 2) *(outbuff++) = *(bp + 1); } rp += 3 * pixsize; gp += 3 * pixsize; bp += 3 * pixsize; } } lineptr = (lineptr + 1) % bufflines; } if (dpi != 1200) { if (i > blue_delay) { savestoreline = storeline; for (j = 0; j < scanpix; j++) { memcpy (storeline, ptrcur + linelen - (j + 1) * pixsize, pixsize); storeline += pixsize; } if (dpi == 150) { /* 150 DPI skips every 4th returned line */ if (i % 4) { i++; *save_i = i; if (bpp16) fix_endian_short ((unsigned short *) storeline, scanpix); return; } storeline = savestoreline; } else { i++; *save_i = i; if (bpp16) fix_endian_short ((unsigned short *) storeline, scanpix); return; } } } else /* dpi==1200 */ { if (i > (DPI1200SHUFFLE + blue_delay)) { for (j = 0; j < scanpix; j++) { if (1 == (j & 1)) memcpy (storeline, ptrcur + linelen - (j + 1) * pixsize, pixsize); else memcpy (storeline, ptrprev + linelen - (j + 1) * pixsize, pixsize); storeline += pixsize; } /* end for */ i++; *save_i = i; if (bpp16) fix_endian_short ((unsigned short *) storeline, scanpix); return; } /* end if >dpi1200shuffle */ } /* end if dpi1200 */ i++; } /* end for */ } #ifndef BACKENDNAME /* Record an image to a file with remapping/reordering/etc. */ void record_image (p_usb_dev_handle udev, char *fname, int dpi, int scanpix, int scanlines, int gray, char *head, int bpp16) { FILE *fp; int i; int save_i; unsigned char *save_scan_line; unsigned char *save_dpi1200_remap; unsigned char *save_color_remap; unsigned char *storeline; save_i = 0; save_scan_line = save_dpi1200_remap = save_color_remap = NULL; storeline = (unsigned char *) malloc (scanpix * (gray ? 1 : 3) * (bpp16 ? 2 : 1)); fp = fopen (fname, "wb"); if (head) fprintf (fp, "%s", head); for (i = 0; i < scanlines; i++) { record_line ((i == 0) ? 1 : 0, udev, storeline, dpi, scanpix, gray, bpp16, &save_i, &save_scan_line, &save_dpi1200_remap, &save_color_remap); fwrite (storeline, scanpix * (gray ? 1 : 3) * (bpp16 ? 2 : 1), 1, fp); } fclose (fp); if (save_scan_line) free (save_scan_line); if (save_dpi1200_remap) free (save_dpi1200_remap); if (save_color_remap) free (save_color_remap); free (storeline); } #endif static void record_mem (p_usb_dev_handle udev, unsigned char **dest, int bytes) { unsigned char *mem; unsigned char buff[65536]; int len; mem = (unsigned char *) malloc (bytes); *dest = mem; do { len = usb_bulk_read (udev, 1, buff, bytes > 65536 ? 65536 : bytes, rd_timeout); if (len > 0) { memcpy (mem, buff, len); bytes -= len; mem += len; } } while (bytes); } static void reset_scanner (p_usb_dev_handle udev) { unsigned char rd_byte; DBG (2, "+reset_scanner\n"); write_regs (udev, 5, 0x83, 0x00, 0xa3, 0xff, 0xa4, 0xff, 0xa1, 0xff, 0xa2, 0xff); write_vctl (udev, 0x0c, 0x0001, 0x0000, 0x00); write_regs (udev, 2, 0xbe, 0x00, 0x84, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x8406, 0x00); write_vctl (udev, 0x0c, 0x00c0, 0x0406, 0x00); write_regs (udev, 16, 0xbe, 0x18, 0x80, 0x00, 0x84, 0x00, 0x89, 0x00, 0x88, 0x00, 0x86, 0x00, 0x90, 0x00, 0xc1, 0x00, 0xc2, 0x00, 0xc3, 0x00, 0xc4, 0x00, 0xc5, 0x00, 0xc6, 0x00, 0xc7, 0x00, 0xc8, 0x00, 0xc0, 0x00); write_regs (udev, 16, 0x84, 0x94, 0x80, 0xd1, 0x80, 0xc1, 0x82, 0x7f, 0xcf, 0x04, 0xc1, 0x02, 0xc2, 0x00, 0xc3, 0x06, 0xc4, 0xff, 0xc5, 0x40, 0xc6, 0x8c, 0xc7, 0xdc, 0xc8, 0x20, 0xc0, 0x72, 0x89, 0xff, 0x86, 0xff); write_regs (udev, 7, 0xa8, 0x80, 0x83, 0xa2, 0x85, 0xc8, 0x83, 0x82, 0x85, 0xaf, 0x83, 0x00, 0x93, 0x00); write_regs (udev, 3, 0xa8, 0x0a, 0x8c, 0x08, 0x94, 0x00); 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); write_regs (udev, 1, 0x97, 0x0b); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x0f); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); write_regs (udev, 1, 0x97, 0x05); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); DBG (2, "-reset_scanner\n"); } static void poll1 (p_usb_dev_handle udev) { unsigned char rd_byte; DBG (2, "+poll1\n"); do { write_regs (udev, 1, 0x97, 0x00); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); } while (0 == (rd_byte & 0x40)); DBG (2, "-poll1\n"); } static void poll2 (p_usb_dev_handle udev) { unsigned char rd_byte; DBG (2, "+poll2\n"); do { write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); } while (0 == (rd_byte & 0x02)); DBG (2, "-poll2\n"); } #ifndef BACKENDNAME static void check_buttons (p_usb_dev_handle udev, int *scan, int *print, int *mail) { unsigned char rd_byte; 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); if (scan) { if (0 == (rd_byte & 1)) *scan = 1; else *scan = 0; } if (print) { if (0 == (rd_byte & 2)) *print = 1; else *print = 0; } if (mail) { if (0 == (rd_byte & 4)) *mail = 1; else *mail = 0; } write_regs (udev, 1, 0x97, 0x0b); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); idle_ab (udev); write_regs (udev, 1, 0x97, 0x0f); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); idle_ab (udev); write_regs (udev, 1, 0x97, 0x05); write_vctl (udev, 0x0c, 0x0004, 0x008b, 0x00); read_vctl (udev, 0x0c, 0x0007, 0x0000, &rd_byte); idle_ab (udev); } #endif static int lut (int val, double gain, int offset) { /* int offset = 1800; */ /* double exponent = 3.5; */ return (offset + 8192.0 * (pow ((8192.0 - val) / 8192.0, gain))); } static void calc_lightmap (unsigned short *buff, unsigned short *storage, int index, int dpi, double gain, int offset) { int val, line; int px = 5632; int i; line = px * 3; for (i = 0; i < px; i++) { if ((i >= 2) && (i <= (px - 2))) { val = 0; val += 1 * buff[i * 3 + index - 3 * 2]; val += 3 * buff[i * 3 + index - 3 * 1]; val += 5 * buff[i * 3 + index + 3 * 0]; val += 3 * buff[i * 3 + index + 3 * 1]; val += 1 * buff[i * 3 + index + 3 * 2]; val += 2 * buff[i * 3 + index - 3 * 1 + line]; val += 3 * buff[i * 3 + index + 3 * 0 + line]; val += 2 * buff[i * 3 + index + 3 * 1 + line]; val += 1 * buff[i * 3 + index + 3 * 0 + 2 * line]; val /= 21; } else { val = 1 * buff[i * 3 + index]; } val = val >> 3; if (val > 8191) val = 8191; val = lut (val, gain, offset); if (val > 8191) val = 8191; if (val < 0) val = 0; storage[i * (dpi == 1200 ? 2 : 1)] = val; if (dpi == 1200) storage[i * 2 + 1] = val; } fix_endian_short (storage, (dpi == 1200) ? i * 2 : i); } /*#define VALMAP 0x1fff */ /*#define SCANMAP 0x2000*/ #define RAWPIXELS600 7320 #define RAWPIXELS1200 14640 static void select_pixels (unsigned short *map, int dpi, int start, int end) { int i; int skip, offset; unsigned short VALMAP = 0x1fff; unsigned short SCANMAP = 0x2000; fix_endian_short (&VALMAP, 1); fix_endian_short (&SCANMAP, 1); /* Clear the pixel-on flags for all bits */ for (i = 0; i < ((dpi == 1200) ? RAWPIXELS1200 : RAWPIXELS600); i++) map[i] &= VALMAP; /* 300 and 150 have subsampling */ if (dpi == 300) skip = -2; else if (dpi == 150) skip = -4; else skip = -1; /* 1200 has 2x pixels so start at 2x the offset */ if (dpi == 1200) offset = 234 + (8.5 * 1200); else offset = 117 + (8.5 * 600); if (0 == (offset & 1)) offset++; DBG (2, "offset=%d start=%d skip=%d\n", offset, start, skip); for (i = 0; i < end; i++) { int x; x = offset + (start * skip) + (i * skip); if (x < 0 || x > ((dpi == 1200) ? RAWPIXELS1200 : RAWPIXELS600)) DBG (2, "ERR %d\n", x); else map[x] |= SCANMAP; } } static void set_lightmap_white (unsigned short *map, int dpi, int color) { int i; unsigned short VALMAP = 0x1fff; unsigned short SCANMAP = 0x2000; fix_endian_short (&VALMAP, 1); fix_endian_short (&SCANMAP, 1); if (dpi != 1200) { memset (map, 0, RAWPIXELS600 * 2); if (color != 0) return; /* Only 1st has enables... */ for (i = 0; i < 22; i++) map[7 + i] = SCANMAP; /* Get some black... */ for (i = 0; i < 1024; i++) map[2048 + i] = SCANMAP; /* And some white... */ } else { memset (map, 0, RAWPIXELS1200 * 2); if (color != 0) return; for (i = 16; i < 61; i++) map[i] = SCANMAP; for (i = 4076; i < 6145; i++) map[i] = SCANMAP; /* 3rd is all clear */ } } static void set_lamp_timer (p_usb_dev_handle udev, int timeout_in_mins) { write_regs (udev, 7, 0xa8, 0x80, 0x83, 0xa2, 0x85, 0xc8, 0x83, 0x82, 0x85, 0xaf, 0x83, 0x00, 0x93, 0x00); write_regs (udev, 3, 0xa8, timeout_in_mins * 2, 0x8c, 0x08, 0x94, 0x00); idle_ab (udev); write_regs (udev, 4, 0x83, 0x20, 0x8d, 0x26, 0x83, 0x00, 0x8d, 0xff); } static void calculate_lut8 (double *poly, int skip, unsigned char *dest) { int i; double sum, x; if (!poly || !dest) return; for (i = 0; i < 8192; i += skip) { sum = poly[0]; x = (double) i; sum += poly[1] * x; x = x * i; sum += poly[2] * x; x = x * i; sum += poly[3] * x; x = x * i; sum += poly[4] * x; x = x * i; sum += poly[5] * x; x = x * i; sum += poly[6] * x; x = x * i; sum += poly[7] * x; x = x * i; sum += poly[8] * x; x = x * i; sum += poly[9] * x; x = x * i; if (sum < 0) sum = 0; if (sum > 255) sum = 255; *dest = (unsigned char) sum; dest++; } } static void download_lut8 (p_usb_dev_handle udev, int dpi, int incolor) { double color[10] = { 0.0, 1.84615261590892E-01, -2.19613868292657E-04, 1.79549523214101E-07, -8.69378513113239E-11, 2.56694911984996E-14, -4.67288886157239E-18, 5.11622894146250E-22, -3.08729724411991E-26, 7.88581670873938E-31 }; double gray[10] = { 0.0, 1.73089945056694E-01, -1.39794924306080E-04, 9.70266873814926E-08, -4.57503008236968E-11, 1.37092321631794E-14, -2.54395068387198E-18, 2.82432084125966E-22, -1.71787408822688E-26, 4.40306800664567E-31 }; unsigned char *lut; DBG (2, "+download_lut8\n"); switch (dpi) { case 150: case 300: case 600: lut = (unsigned char *) malloc (4096); if (!lut) return; if (!incolor) { calculate_lut8 (gray, 2, lut); write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x20, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x2f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, 0x1000, 0x00); usb_bulk_write (udev, 2, lut, 4096, wr_timeout); } else { calculate_lut8 (color, 2, lut); write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x10, 0xb2, 0x07, 0xb3, 0xff, 0xb4, 0x1f, 0xb5, 0x07); write_vctl (udev, 0x0c, 0x0002, 0x1000, 0x00); 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); 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); usb_bulk_write (udev, 2, lut, 4096, wr_timeout); } break; case 1200: default: lut = (unsigned char *) malloc (8192); if (!lut) return; if (!incolor) { calculate_lut8 (gray, 1, lut); write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x40, 0xb2, 0x06, 0xb3, 0xff, 0xb4, 0x5f, 0xb5, 0x06); write_vctl (udev, 0x0c, 0x0002, 0x2000, 0x00); usb_bulk_write (udev, 2, lut, 8192, wr_timeout); } else { calculate_lut8 (color, 1, lut); write_regs (udev, 6, 0xb0, 0x00, 0xb1, 0x20, 0xb2, 0x06, 0xb3, 0xff, 0xb4, 0x3f, 0xb5, 0x06); write_vctl (udev, 0x0c, 0x0002, 0x2000, 0x00); 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); 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); usb_bulk_write (udev, 2, lut, 8192, wr_timeout); } break; } free (lut); DBG (2, "-download_lut8\n"); } static void set_gain_black (p_usb_dev_handle udev, int r_gain, int g_gain, int b_gain, int r_black, int g_black, int b_black) { write_regs (udev, 1, 0x80, 0x00); write_regs (udev, 1, 0x80, 0x01); write_regs (udev, 1, 0x04, 0x80); write_regs (udev, 1, 0x04, 0x00); write_regs (udev, 1, 0x00, 0x00); write_regs (udev, 1, 0x01, 0x03); write_regs (udev, 1, 0x02, 0x04); write_regs (udev, 1, 0x03, 0x11); write_regs (udev, 1, 0x05, 0x00); write_regs (udev, 1, 0x28, r_gain); write_regs (udev, 1, 0x29, g_gain); write_regs (udev, 1, 0x2a, b_gain); write_regs (udev, 1, 0x20, r_black); write_regs (udev, 1, 0x21, g_black); write_regs (udev, 1, 0x22, b_black); write_regs (udev, 1, 0x24, 0x00); write_regs (udev, 1, 0x25, 0x00); write_regs (udev, 1, 0x26, 0x00); } /* Handle short endianness issues */ static void fix_endian_short (unsigned short *data, int count) { unsigned short testvalue = 255; unsigned char *firstbyte = (unsigned char *) &testvalue; int i; if (*firstbyte == 255) return; /* INTC endianness */ DBG (2, "swapping endiannes...\n"); for (i = 0; i < count; i++) data[i] = ((data[i] >> 8) & 0x00ff) | ((data[i] << 8) & 0xff00); } sane-backends-1.0.29/backend/sm3840_params.h0000666000000000000000000000475013615534521015250 00000000000000/* sane - Scanner Access Now Easy. ScanMaker 3840 Backend Copyright (C) 2005-7 Earle F. Philhower, III earle@ziplabel.com - http://www.ziplabel.com 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef _SM3840_Params #define _SM3840_Params typedef struct SM3840_Params { int gray; /* 0, 1 */ int halftone; /* 0, 1 (also set gray=1) */ int lineart; /* 0, 1 (also set gray=1) */ int dpi; /* 150, 300, 600, 1200 */ int bpp; /* 8, 16 */ double gain; /* 0.01...9.9 */ int offset; /* 0..4095 */ int lamp; /* 1..15 mins */ int threshold; /* 0...255 luminosity */ /* Input to configure(), in inches */ double top, left; double width, height; /* Output from configure(), in pixels */ int topline; int scanlines; int leftpix; int scanpix; int linelen; /* bytes per line */ } SM3840_Params; #endif sane-backends-1.0.29/backend/canon_pp.conf.in0000666000000000000000000000220613615534521015641 00000000000000# Define which port to use if one isn't specified - you should only have # one of these lines! # This is the default port to be used - others will be detected ieee1284 parport0 # Define the location of our pixel weight file, can begin with ~/ if needed. # You can have as many of these as you like - lines with ports that don't exist # will be ignored. # # Parameters are: # calibrate /path/to/calibration-file port-name # # The format of port-name is dependant on your OS version. # # If a file isn't speficied, the default name will be # ~/.sane/canon_pp-calibration-[port-name] calibrate ~/.sane/canon_pp-calibration-pp0 parport0 # calibrate /etc/sane/my_calibration parport1 # Enable the next line if you're having trouble with ECP mode such as I/O # errors. Nibble mode is slower, but more reliable. #force_nibble # Set a default initialisation mode for each port. Valid modes are: # AUTO (attempts to automatically detect by trying both methods) # FB620P (10101010 style.. also works for FB320P) # FB630P (11001100 style.. also works for FB330P, N340P, N640P) init_mode AUTO parport0 # init_mode FB620P parport0 # init_mode FB630P parport0 sane-backends-1.0.29/backend/plustek-pp_p48xx.c0000666000000000000000000006115513615534521016123 00000000000000/* @file plustek-pp_p48xx.c * @brief here we have all functionality according to the ASIC96001/3 based * models. * * based on sources acquired from Plustek Inc. * Copyright (C) 1998 Plustek Inc. * Copyright (C) 2000-2013 Gerhard Jaeger * also based on the work done by Rick Bronson * * History: * - 0.30 - initial version * - 0.31 - fixed a bug for the return value in p48xxDoTest * - added additional debug messages * - added function p48xxCheck4800Memory * - 0.32 - added debug messages * - fixed a bug in p48xxDoTest * - disabled RD_WatchDogControl, lamp will be controlled by driver * - 0.33 - added function p48xxSetAsicRegisters() * - fixed a bug in p48xxDoTest (reset the ASIC registers) * - removed p48xxPositionLamp * - 0.34 - added some comments * - 0.35 - added some comments * - 0.36 - added function p48xxInitAllModules() to allow reinit of the modules * - switching from Full- to Halfstep at ps->PhysicalDpi now in * - p48xxSetGeneralRegister * - fixed the color-inverse problem for model OP4800 * - 0.37 - move p48xxOpenScanPath, p48xxCloseScanPath * and p48xxRegisterToScanner to io.c * - removed // comments * - added override for A3I scanner * - 0.38 - added function p48xxPutToIdleMode() * - added function p48xxCalibration * - 0.39 - added A3I stuff * - 0.40 - disabled A3I stuff * - 0.41 - no changes * - 0.42 - changed include names * - 0.43 - no changes * - 0.44 - fix format string issues, as Long types default to int32_t * now * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #include "plustek-pp_scan.h" /*************************** some definitions ********************************/ #define _TEST_SZ 2048 /* always use 2048 for mem size (= one bank) */ #define _START_VAL 0x12345678 /* pick a non-zero starting value for our long */ #define _BankAndSizeForTest _MemBankSize2k /* always use 2k for mem test */ /*************************** local functions *********************************/ /*............................................................................. * 1) Set asic to PROGRAM mode * 2) Select the memory bank and size * 3) Initiate data fifo */ static void p48xxSetMemoryBankForProgram( pScanData ps , Byte bBankAndSize ) { /* enter program mode */ IODataToRegister( ps, ps->RegModeControl, _ModeProgram ); /* bank and size */ IODataToRegister( ps, ps->RegMemAccessControl, bBankAndSize ); /* initiate data fifo */ IORegisterToScanner( ps, ps->RegInitDataFifo ); } /*............................................................................. * use the internal memory of a scanner to find the model */ static int p48xxDoTest( pScanData ps ) { UChar tmpByte; int retval; ULong adder, ul, cntr; pULong buffer; DBG( DBG_LOW, "p48xxDoTest()\n" ); buffer = _KALLOC( sizeof(UChar) * _TEST_SZ, GFP_KERNEL ); if( NULL == buffer ) return _E_ALLOC; retval = _E_NO_DEV; /* * do a memory test to determine how much memory this unit has, in the * process we can figure out if it's a 4830 or a 9630. NOTE: the ram * seems to be mirrored such that if you have a unit with only 32k it's * mirrored 4 times to fill the 128k (2k * (_MemBankMask + 1)) space, * so we will run a 32 bit incrementing pattern over the entire 128k and * look for the 1st page (2k) to fail */ adder = 0; for (cntr = _BankAndSizeForTest; cntr < _BankAndSizeForTest + _MemBanks; cntr++) { ps->OpenScanPath( ps ); p48xxSetMemoryBankForProgram( ps, cntr ); /* prepare content, incrementing 32 val */ for (ul = 0; ul < _TEST_SZ / sizeof(ULong); ul++) buffer[ul] = ul + adder + _START_VAL; /* fill to buffer */ IOMoveDataToScanner( ps, (pUChar)buffer, _TEST_SZ ); /* * now check bank 0 to see if it got overwritten * bank 0, size 2k */ p48xxSetMemoryBankForProgram( ps, _BankAndSizeForTest ); ps->CloseScanPath( ps ); /* read data back */ IOReadScannerImageData( ps, (pUChar)buffer, _TEST_SZ ); /* check */ for (ul = 0; ul < _TEST_SZ / sizeof(ULong); ul++) { if (buffer[ul] != ul + _START_VAL) { break; } } /* if fail */ if (ul != _TEST_SZ / sizeof (ULong)) { DBG( DBG_LOW, "Bank 0 overwritten\n" ); break; } /* now check current bank */ ps->OpenScanPath( ps ); p48xxSetMemoryBankForProgram( ps, cntr ); ps->CloseScanPath( ps ); /* read data back */ IOReadScannerImageData( ps, (pUChar)buffer, _TEST_SZ); /* check if fail */ for( ul = 0; ul < _TEST_SZ / sizeof(ULong); ul++ ) { if( buffer[ul] != ul + adder + _START_VAL ) break; } /* check if fail */ if (ul != _TEST_SZ / sizeof(ULong)) { DBG( DBG_LOW, "Bank not present, error at pos %u (%u)\n", ul, (ULong)(_TEST_SZ / sizeof(ULong))); break; } adder += _TEST_SZ / sizeof(ULong); } _KFREE( buffer ); DBG( DBG_LOW, "found %d bytes of memory\n", _TEST_SZ * (cntr - _BankAndSizeForTest)); if( cntr == _BankAndSizeForTest ) { DBG( DBG_LOW, "No memory ! No scanner...\n" ); return retval; } #ifdef DEBUG tmpByte = IODataRegisterFromScanner( ps, 0x18 ); DBG( DBG_LOW, "tmpByte[0x18] = 0x%02x\n",tmpByte ); #endif tmpByte = IODataRegisterFromScanner( ps, 0x0e ); DBG( DBG_LOW, "tmpByte = 0x%02x, cntr = %u, AsicId = 0x%02x\n", tmpByte, cntr, ps->sCaps.AsicID ); /* 128k */ if ((_TEST_SZ * (cntr - _BankAndSizeForTest) == 1 << 17) && (ps->sCaps.AsicID == _ASIC_IS_96003)) { /* * if 128k then must be a 9630 or above * hack, test for 12000P, The 9630 returns an 0x08 */ if ( tmpByte == 0x02 ) { /* * as we currently can't automagically detect an A3I we have to * use the override switch */ if( _OVR_PLUSTEK_A3I == ps->ModelOverride ) { DBG( DBG_LOW, "Model Override --> A3I\n" ); ModelSetA3I( ps ); } else { ModelSet12000( ps ); DBG( DBG_LOW, "It seems we have a 12000P/96000P\n" ); } } else { ModelSet9630( ps ); DBG( DBG_LOW, "It seems we have a 9630\n" ); } retval = _OK; } else { DBG( DBG_LOW, "Scanner is not a 9630 or above\n"); if ( tmpByte != 0x0f ) { DBG( DBG_LOW, "Looks like a 600!\n" ); if (( 0x08 == tmpByte ) && ((_TEST_SZ * (cntr - _BankAndSizeForTest)) == 32768 )) { DBG( DBG_LOW, "But it is a 4830P!!! " "(by mkochano@ee.pw.edu.pl)\n" ); ModelSet4830( ps ); } else { ModelSet600( ps ); } } #ifdef DEBUG else DBG( DBG_LOW, "It seems we have a 4830\n" ); #endif retval = _OK; } return retval; } /*............................................................................. * setup ASIC registers and clear all scan states (no stepping) */ static void p48xxSetAsicRegisters( pScanData ps ) { memset( &ps->AsicReg, 0, sizeof(ps->AsicReg)); memset( &ps->Asic96Reg, 0, sizeof(ps->Asic96Reg)); memset( ps->a_nbNewAdrPointer, 0, _SCANSTATE_BYTES ); ps->AsicReg.RD_LineControl = ps->TimePerLine; ps->AsicReg.RD_ScanControl = _SCAN_LAMP_ON; ps->AsicReg.RD_ModelControl = ps->Device.ModelCtrl | _ModelWhiteIs0; ps->AsicReg.RD_Origin = 0; ps->AsicReg.RD_Pixels = 5110; /*ps->RdPix;*/ ps->Asic96Reg.RD_MotorControl = 0; ps->Asic96Reg.RD_WatchDogControl = 0; /* org. val = 0x8f; */ IOPutOnAllRegisters( ps ); } /*............................................................................. * use the internal memory of a scanner to find the model */ static int p48xxCheck4800Memory( pScanData ps ) { int retval; ULong ul; pUChar buffer; DBG( DBG_LOW, "p48xxCheck4800Memory()\n" ); buffer = _KALLOC( 2560, GFP_KERNEL ); /* 1280: Read,1280:Write */ if( NULL == buffer ) return _E_ALLOC; retval = _OK; /* bank 0, size 2k */ ps->OpenScanPath( ps ); p48xxSetMemoryBankForProgram( ps, _BankAndSizeForTest ); for (ul = 0; ul < 1280; ul++) buffer[ul] = (UChar)ul; /* prepare content */ IOMoveDataToScanner( ps, buffer, 1280 ); /* fill to buffer */ p48xxSetMemoryBankForProgram( ps, _BankAndSizeForTest ); ps->CloseScanPath( ps ); /* read data back */ IOReadScannerImageData( ps, buffer + 1280, 1280 ); for( ul = 0; ul < 1280; ul++ ) { if( buffer[ul] != buffer[ul+1280] ) { DBG( DBG_HIGH, "Error in memory test at pos %u (%u != %u)\n", ul, buffer[ul], buffer[ul+1280] ); retval = _E_NO_DEV; break; } } _KFREE(buffer); return retval; } /*............................................................................. * call all other modules, to initialize themselves */ static int p48xxInitAllModules( pScanData ps ) { int result; result = DacInitialize( ps ); if( _OK != result ) return result; result = ImageInitialize( ps ); if( _OK != result ) return result; result = IOFuncInitialize( ps ); if( _OK != result ) return result; result = IOInitialize( ps ); if( _OK != result ) return result; result = MotorInitialize( ps ); if( _OK != result ) return result; /* * in debug version, check all function pointers */ #ifdef DEBUG if( _FALSE == MiscAllPointersSet( ps )) return _E_INTERNAL; #endif return _OK; } /*............................................................................. * */ static int p48xxReadWriteTest( pScanData ps ) { int retval; DBG( DBG_LOW, "p48xxReadWriteTest()\n" ); /* * determine the model by the ASIC type (except for 4830/9630) * might want to make a SetModelCommon() someday for this... */ ps->RedDataReady = 0x01; /* normal for Red and Green */ ps->GreenDataReady = 0x02; ps->AsicRedColor = 0x01; ps->AsicGreenColor = 0x03; /* * if not already set, try to find ASIC type (96001 or 96003) */ if ( _NO_BASE == ps->sCaps.wIOBase ) { /* get copy of asic id */ ps->sCaps.AsicID = IODataRegisterFromScanner( ps, ps->RegAsicID ); if ( _ASIC_IS_96003 == ps->sCaps.AsicID ) { /* actually either a 4830, 9630, 12000, find out later */ DBG( DBG_LOW, "Found a 96003 ASIC at Reg 0x%x\n", ps->RegAsicID ); ModelSet4830( ps ); } else { if ( _ASIC_IS_96001 == ps->sCaps.AsicID ) { DBG( DBG_LOW, "Found a 96001 ASIC at Reg 0x%x\n", ps->RegAsicID ); ModelSet4800( ps ); } else { DBG( DBG_LOW, "Can't find your model, asic = 0x%x\n", ps->sCaps.AsicID ); return _E_NO_ASIC; } } } /* * set the registers according to the assumptions above */ p48xxSetAsicRegisters( ps ); if ( _ASIC_IS_96003 == ps->sCaps.AsicID ) { retval = p48xxDoTest( ps ); /* * as we may now have detected another model, we have to set * the registers to their new values... * and maybe the modules have to be reset as well */ if( _OK == retval ) { p48xxSetAsicRegisters( ps ); retval = p48xxInitAllModules( ps ); } return retval; } /* * this part will be reached only for the 4800 - ASIC 96001 * we check only the memory as the original driver does */ return p48xxCheck4800Memory( ps ); } /*............................................................................. * 1) Setup the registers of asic. * 2) Determine which type of CCD we are using * 3) According to the CCD, prepare the CCD dependent veriables * SONY CCD: * The color exposure sequence: Red, Green (after 11 red lines), * Blue (after 8 green lines) * TOSHIBA CCD: * The color exposure sequence: Red, Blue (after 11 red lines), * Green (after 8 blue lines) */ static void p48xxSetupScannerVariables( pScanData ps ) { UChar tmp; TimerDef timer; DBG( DBG_LOW, "p48xxSetupScannerVariables()\n" ); ps->OpenScanPath( ps ); IODataToRegister( ps, ps->RegModelControl2, _Model2ChannelMult ); if( 2 == IODataFromRegister( ps, ps->RegWriteIOBusDecode1 )) { DBG( DBG_LOW, "Scanner has 97003 ASIC too.\n" ); ps->f97003 = _TRUE; ps->b97003DarkR = 8; ps->b97003DarkG = 8; ps->b97003DarkB = 8; ps->Asic96Reg.u26.RD_ModelControl2 = _Model2ChannelMult; } else { DBG( DBG_LOW, "No ASIC 97003 found.\n" ); ps->f97003 = _FALSE; ps->Asic96Reg.u26.RD_ModelControl2 = _Model2DirectOutPort; } IODataToRegister( ps, ps->RegModelControl2, ps->Asic96Reg.u26.RD_ModelControl2 ); tmp = IODataFromRegister( ps, ps->RegStatus ); DBG( DBG_LOW, "Status-Register = 0x%02X\n", tmp ); #ifdef DEBUG if( tmp & _FLAG_P96_MOTORTYPE ) { DBG( DBG_LOW, "Scanner has Full/Half Stepping drive\n" ); } else { DBG( DBG_LOW, "Scanner has Micro Stepping drive\n" ); } #endif if( tmp & _FLAG_P96_CCDTYPE) { ps->fSonyCCD = _FALSE; DBG( DBG_LOW, "CCD is NEC/TOSHIBA Type\n" ); } else { ps->fSonyCCD = _TRUE; DBG( DBG_LOW, "CCD is SONY Type\n" ); } ps->CloseScanPath( ps ); ps->b1stColorByte = ps->AsicRedColor; ps->b1stColor = ps->RedDataReady; if (ps->fSonyCCD) { ps->b2ndColorByte = ps->AsicGreenColor; ps->b2ndColor = ps->GreenDataReady; ps->b3rdColorByte = _ASIC_BLUECOLOR; ps->b3rdColor = _BLUE_DATA_READY; } else { /* NEC/Toshiba CCD */ ps->b2ndColorByte = _ASIC_BLUECOLOR; ps->b2ndColor = _BLUE_DATA_READY; ps->b3rdColorByte = ps->AsicGreenColor; ps->b3rdColor = ps->GreenDataReady; } ps->b1stMask = (Byte)~ps->b1stColor; ps->b2ndMask = (Byte)~ps->b2ndColor; ps->b3rdMask = (Byte)~ps->b3rdColor; ps->b1stLinesOffset = 17; ps->b2ndLinesOffset = 9; /* * calculate I/O Timer * if we cannot read 200 lines within 1 second, the I/O time has to add 2 * CalculateIOTime () */ if( _PORT_SPP != ps->IO.portMode ) { UShort wLines = 200; pUChar pBuf; pBuf = _KALLOC((_BUF_SIZE_BASE_CONST * 2), GFP_KERNEL ); if ( NULL != pBuf ) { MiscStartTimer( &timer, _SECOND ); do { IOReadScannerImageData( ps, pBuf, (_BUF_SIZE_BASE_CONST * 2)); wLines--; } while (!MiscCheckTimer( &timer) && wLines); if( !wLines ) ps->bExtraAdd = 0; else ps->bExtraAdd = 2; _KFREE( pBuf ); } else { ps->bExtraAdd = 2; /* poor resource */ } } else { ps->bExtraAdd = 0; } } /*............................................................................. * */ static void p48xxSetGeneralRegister( pScanData ps ) { if( MODEL_OP_A3I == ps->sCaps.Model ) { ps->AsicReg.RD_ModelControl = _ModelDpi400 | _ModelWhiteIs0 | _ModelMemSize128k4; } ps->AsicReg.RD_ModeControl = _ModeScan; /* WORK: ps->PhysicalDpi should be correct, but the we have to work * on motor.c again to use other running-tables * if ( ps->DataInf.xyAppDpi.y <= ps->PhysicalDpi ) { */ if ( ps->DataInf.xyAppDpi.y <= 300 ) { /* HEINER:A3I if ( ps->DataInf.xyAppDpi.y <= ps->PhysicalDpi ) { */ ps->Asic96Reg.RD_MotorControl = (ps->FullStep | ps->IgnorePF | ps->MotorOn | _MotorDirForward); } else { ps->Asic96Reg.RD_MotorControl = (ps->IgnorePF | ps->MotorOn | _MotorDirForward); } if ( ps->DataInf.wPhyDataType == COLOR_BW ) { ps->AsicReg.RD_ScanControl = ps->bLampOn; if (!(ps->DataInf.dwScanFlag & SCANDEF_Inverse)) ps->AsicReg.RD_ScanControl |= _P96_SCANDATA_INVERT; } else { ps->AsicReg.RD_ScanControl = ps->bLampOn | _SCAN_BYTEMODE; if (ps->DataInf.dwScanFlag & SCANDEF_Inverse) ps->AsicReg.RD_ScanControl |= _P96_SCANDATA_INVERT; } if (ps->DataInf.xyPhyDpi.x <= 200) ps->AsicReg.RD_ScanControl |= _SCAN_1ST_AVERAGE; DBG( DBG_LOW, "RD_ModeControl = 0x%02x\n", ps->AsicReg.RD_ModeControl ); DBG( DBG_LOW, "RD_MotorControl = 0x%02x\n", ps->Asic96Reg.RD_MotorControl ); DBG( DBG_LOW, "RD_ScanControl = 0x%02x\n", ps->AsicReg.RD_ScanControl ); } /*............................................................................. * */ static void p48xxSetupScanningCondition( pScanData ps ) { DBG( DBG_LOW, "p48xxSetupScanningCondition()\n" ); IORegisterDirectToScanner( ps, ps->RegInitDataFifo ); /* Cal64kTime (); */ if( MODEL_OP_A3I == ps->sCaps.Model ) ps->wLinesPer64kTime = (UShort)(65555UL / ps->DataInf.dwAsicBytesPerPlane * 5UL); else ps->wLinesPer64kTime = (UShort)(65555UL / ps->DataInf.dwAsicBytesPerPlane * 10UL / 3UL); DBG( DBG_LOW, "wLinesPer64kTime = %u\n", ps->wLinesPer64kTime ); ps->InitialSetCurrentSpeed( ps ); DBG( DBG_LOW, "Current Speed = %u\n", ps->bCurrentSpeed ); ps->bMinReadFifo = (Byte)((ps->DataInf.dwAsicBytesPerPlane + 511) / 512); DBG( DBG_LOW, "MinReadFifo = %u\n", ps->bMinReadFifo ); p48xxSetGeneralRegister( ps ); /* * if speed is not the fastest and DPI is less than 400, do half steps */ if( ps->DataInf.wPhyDataType >= COLOR_256GRAY && !(ps->bCurrentSpeed & 1) && (ps->DataInf.xyAppDpi.y <= 300)) { /* HEINER:A3I if( !(ps->bCurrentSpeed & 1) && (ps->DataInf.xyAppDpi.y <= ps->PhysicalDpi)) { */ ps->fHalfStepTableFlag = _TRUE; ps->Asic96Reg.RD_MotorControl &= ps->StepMask; } ps->AsicReg.RD_Dpi = ps->DataInf.xyPhyDpi.x; DBG( DBG_LOW, "RD_Dpi = %u\n", ps->AsicReg.RD_Dpi ); /* SetStartStopRegister (ps) */ ps->AsicReg.RD_Origin = (UShort)(ps->Offset70 + ps->Device.DataOriginX + ps->DataInf.crImage.x); if (ps->DataInf.wPhyDataType < COLOR_256GRAY) { ps->AsicReg.RD_Pixels = (UShort)(ps->DataInf.dwAsicPixelsPerPlane + 7) & 0xfff8; } else { ps->AsicReg.RD_Pixels = (UShort)ps->DataInf.dwAsicPixelsPerPlane; } DBG( DBG_LOW, "RD_Pixels = %u\n", ps->AsicReg.RD_Pixels ); /* SetupMotorStart () */ IORegisterDirectToScanner( ps, ps->RegInitDataFifo); ps->SetupMotorRunTable( ps ); IOSetToMotorRegister( ps ); ps->pCurrentColorRunTable = ps->pColorRunTable; ps->bCurrentLineCount = 0; IOPutOnAllRegisters( ps ); ps->OpenScanPath( ps ); /* * when using the full-step speed on 600 dpi models, then set * the motor into half-step mode, to avoid that the scanner hits * the back of its cover */ if((600 == ps->PhysicalDpi) && (1 == ps->bCurrentSpeed)) { ps->Asic96Reg.RD_MotorControl &= ~ps->FullStep; } IODataToRegister( ps, ps->RegMotorControl, (Byte)(ps->Asic96Reg.RD_MotorControl & ~ps->MotorOn)); IODataToRegister( ps, ps->RegMotorControl, ps->Asic96Reg.RD_MotorControl); IORegisterToScanner( ps, ps->RegInitDataFifo ); ps->CloseScanPath( ps ); } /*............................................................................. * switch the motor off and put the scanner into idle mode */ static void p48xxPutToIdleMode( pScanData ps ) { DBG( DBG_LOW, "Putting Scanner (ASIC 96001/3) into Idle-Mode\n" ); /* * turn off motor */ ps->Asic96Reg.RD_MotorControl = 0; IOCmdRegisterToScanner( ps, ps->RegMotorControl, 0 ); } /*............................................................................. * for P96001/3 ASIC * do all the preliminary stuff here (calibrate the scanner and move the * sensor to it´s start position, also setup the driver for the * current run) */ static int p48xxCalibration( pScanData ps ) { DBG( DBG_LOW, "p48xxCalibration()\n" ); ps->Scan.bFifoSelect = ps->RegGFifoOffset; while (_TRUE) { _ASSERT(ps->WaitForShading); if (ps->WaitForShading( ps )) { if(!(ps->DataInf.dwScanFlag & SCANDEF_TPA)) { /* HEINER:A3I disable !! */ MotorP96AheadToDarkArea( ps ); if( ps->Scan.fRefreshState ) { ps->Scan.fRefreshState = _FALSE; if (!ps->fReshaded) { ps->fReshaded = _TRUE; if (ps->fColorMoreRedFlag || ps->fColorMoreBlueFlag) { continue; } } } } break; } else { ps->fScanningStatus = _FALSE; ps->DataInf.dwAppLinesPerArea = 0; return _E_TIMEOUT; } } if((ps->sCaps.AsicID != _ASIC_IS_96001) && (ps->DataInf.wPhyDataType != COLOR_BW)) { DacP96WriteBackToGammaShadingRAM(ps); } if( ps->DataInf.dwScanFlag & SCANDEF_TPA ) { ps->bExtraMotorCtrl = 0; ps->Scan.fMotorBackward = _TRUE; MotorP96ConstantMoveProc( ps, 4000 ); } /* * move sensor and setup scanner for grabbing the picture */ _ASSERT(ps->WaitForPositionY); ps->WaitForPositionY(ps); return _OK; } /************************ exported functions *********************************/ /*............................................................................. * initialize the register values and function calls for the 96001/3 asic */ _LOC int P48xxInitAsic( pScanData ps ) { DBG( DBG_LOW, "P48xxInitAsic()\n" ); ps->IO.bOpenCount = 0; ps->RegSwitchBus = 0; ps->RegReadDataMode = 1; ps->RegWriteDataMode = 2; ps->RegEPPEnable = 3; ps->RegInitDataFifo = 4; ps->RegForceStep = 5; ps->RegInitScanState = 6; ps->RegRefreshScanState = 7; ps->RegStatus = 0x10; ps->RegFifoOffset = 0x11; ps->RegGetScanState = 0x12; ps->RegAsicID = 0x13; /* Determine the asic */ ps->RegReadIOBufBus = 0x17; ps->RegModeControl = 0x18; ps->RegLineControl = 0x19; ps->RegScanControl = 0x1a; ps->RegMotorControl = 0x1b; ps->RegModelControl = 0x1c; ps->RegMemAccessControl = 0x1d; ps->RegDpiLow = 0x1e; ps->RegDpiHigh = 0x1f; ps->RegScanPosLow = 0x20; ps->RegScanPosHigh = 0x21; ps->RegWidthPixelsLow = 0x22; ps->RegWidthPixelsHigh = 0x23; ps->RegThresholdControl = 0x24; ps->RegWatchDogControl = 0x25; ps->RegModelControl2 = 0x26; ps->RegThresholdGapControl = 0x27; ps->RegRedChShadingOffset = 0x28; ps->RegGreenChShadingOffset = 0x29; ps->RegRedDCAdjust = 0x27; /* not sure why these are dup's */ ps->RegGreenDCAdjust = 0x28; ps->RegBlueDCAdjust = 0x29; ps->RegBlueChShadingOffset = 0x2a; ps->RegRedChDarkOffset = 0x2b; ps->RegGreenChDarkOffset = 0x2c; ps->RegBlueChDarkOffset = 0x2d; ps->RegWriteIOBusDecode1 = 0x2e; ps->RegWriteIOBusDecode2 = 0x2f; ps->RegScanStateControl = 0x30; ps->RegRedChEvenOffset = 0x31; ps->RegGreenChEvenOffset = 0x32; ps->RegBlueChEvenOffset = 0x33; ps->RegRedChOddOffset = 0x34; ps->RegGreenChOddOffset = 0x35; ps->RegBlueChOddOffset = 0x36; ps->RegRedGainOutDirect = 0x37; ps->RegGreenGainOutDirect = 0x38; ps->RegBlueGainOutDirect = 0x39; ps->RegLedControl = 0x3a; ps->RegShadingCorrectCtrl = 0x3b; ps->RegScanStateBegin = 0x40; /* (0, 1) */ ps->RegScanStateEnd = 0x5f; /* (62, 63) */ /* * setup function calls */ ps->ReadWriteTest = p48xxReadWriteTest; ps->SetupScannerVariables = p48xxSetupScannerVariables; ps->SetupScanningCondition = p48xxSetupScanningCondition; ps->PutToIdleMode = p48xxPutToIdleMode; ps->Calibration = p48xxCalibration; /* * setup misc */ ps->CtrlReadHighNibble = _CTRL_GENSIGNAL + _CTRL_AUTOLF; ps->CtrlReadLowNibble = _CTRL_GENSIGNAL + _CTRL_AUTOLF + _CTRL_STROBE; ps->MotorFreeRun = 0x80; ps->bLampOn = _SCAN_LAMP_ON; ps->f97003 = _FALSE; /* * initialize the other modules */ return p48xxInitAllModules( ps ); } /* END PLUSTEK-PP_P48xx.C ...................................................*/ sane-backends-1.0.29/backend/dc25.c0000666000000000000000000017504313615534521013503 00000000000000/*************************************************************************** * SANE - Scanner Access Now Easy. dc25.c $Id$ This file (C) 1998 Peter Fales 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. *************************************************************************** This file implements a SANE backend for the Kodak DC-25 (and probably the DC-20) digital cameras. THIS IS EXTREMELY ALPHA CODE! USE AT YOUR OWN RISK!! (feedback to: dc25-devel@fales-lorenz.net) This backend is based heavily on the dc20ctrl package by Ugo Paternostro . I've attached his header below: *************************************************************************** * Copyright (C) 1998 Ugo Paternostro * * This file is part of the dc20ctrl package. The complete package can be * downloaded from: * http://aguirre.dsi.unifi.it/~paterno/binaries/dc20ctrl.tar.gz * * This package is derived from the dc20 package, built by Karl Hakimian * that you can find it at ftp.eecs.wsu.edu in the * /pub/hakimian directory. The complete URL is: * ftp://ftp.eecs.wsu.edu/pub/hakimian/dc20.tar.gz * * This package also includes a sligthly modified version of the Comet to ppm * conversion routine written by YOSHIDA Hideki * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * ***************************************************************************/ #include "../include/sane/config.h" #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #define BACKEND_NAME dc25 #include "../include/sane/sanei_backend.h" #include "dc25.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #define MAGIC (void *)0xab730324 #define DC25_CONFIG_FILE "dc25.conf" #define THUMBSIZE ( (CameraInfo.model == 0x25 ) ? 14400 : 5120 ) static SANE_Bool is_open = 0; static SANE_Byte dc25_opt_image_number = 1; /* Image to load */ static SANE_Bool dc25_opt_thumbnails; /* Load thumbnails */ static SANE_Bool dc25_opt_snap; /* Take new picture */ static SANE_Bool dc25_opt_lowres; /* Use low resoluiton */ #define DC25_OPT_CONTRAST_DEFAULT 1.6 /* Contrast enhancement */ static SANE_Fixed dc25_opt_contrast = SANE_FIX (DC25_OPT_CONTRAST_DEFAULT); #define DC25_OPT_GAMMA_DEFAULT 4.5 /* Gamma correction (10x) */ static SANE_Fixed dc25_opt_gamma = SANE_FIX (DC25_OPT_GAMMA_DEFAULT); static SANE_Bool dc25_opt_erase; /* Erase all after download */ static SANE_Bool dc25_opt_erase_one; /* Erase one after download */ static SANE_Bool dumpinquiry; static SANE_Int info_flags; static int tfd; /* Camera File Descriptor */ static char tty_name[PATH_MAX]; #define DEF_TTY_NAME "/dev/ttyS0" static speed_t tty_baud = DEFAULT_TTY_BAUD; static char *tmpname; static char tmpnamebuf[] = "/tmp/dc25XXXXXX"; static Dc20Info *dc20_info; static Dc20Info CameraInfo; static SANE_Byte contrast_table[256]; static struct pixmap *pp; static const SANE_Range contrast_range = { 0 << SANE_FIXED_SCALE_SHIFT, /* minimum */ 3 << SANE_FIXED_SCALE_SHIFT, /* maximum */ 16384 /* quantization ~ 0.025 */ }; static const SANE_Range gamma_range = { 0 << SANE_FIXED_SCALE_SHIFT, /* minimum */ 10 << SANE_FIXED_SCALE_SHIFT, /* maximum */ 16384 /* quantization ~ 0.025 */ }; static SANE_Range image_range = { 0, 14, 0 }; static SANE_Option_Descriptor sod[] = { { SANE_NAME_NUM_OPTIONS, SANE_TITLE_NUM_OPTIONS, SANE_DESC_NUM_OPTIONS, SANE_TYPE_INT, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define D25_OPT_IMAGE_SELECTION 1 { "", "Image Selection", "Selection of the image to load.", SANE_TYPE_GROUP, SANE_UNIT_NONE, 0, 0, SANE_CONSTRAINT_NONE, {NULL} } , #define DC25_OPT_IMAGE_NUMBER 2 { "image", "Image Number", "Select Image Number to load from camera", SANE_TYPE_INT, SANE_UNIT_NONE, 4, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(SANE_String_Const *) & image_range} /* this is ANSI conformant! */ } , #define DC25_OPT_THUMBS 3 { "thumbs", "Load Thumbnail", "Load the image as thumbnail.", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define DC25_OPT_SNAP 4 { "snap", "Snap new picture", "Take new picture and download it", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED, SANE_CONSTRAINT_NONE, {NULL} } , #define DC25_OPT_LOWRES 5 { "lowres", "Low Resolution", "New pictures taken in low resolution", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE | SANE_CAP_ADVANCED, SANE_CONSTRAINT_NONE, {NULL} } , #define DC25_OPT_ERASE 6 { "erase", "Erase", "Erase all pictures after downloading", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define DC25_OPT_ERASE_ONE 7 { "erase-one", "Erase One", "Erase downloaded picture after downloading", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define DC25_OPT_ENHANCE 8 { "", "Image Parameters", "Modifications to image parameters", SANE_TYPE_GROUP, SANE_UNIT_NONE, 0, 0, SANE_CONSTRAINT_NONE, {NULL} } , #define DC25_OPT_CONTRAST 9 { "contrast", "Contrast Adjustment", "Values > 1 enhance contrast", SANE_TYPE_FIXED, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(const SANE_String_Const *) &contrast_range} /* this is ANSI conformant! */ }, #define DC25_OPT_GAMMA 10 { "gamma", "Gamma Adjustment", "Larger values make image darker", SANE_TYPE_FIXED, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(const SANE_String_Const *) &gamma_range} /* this is ANSI conformant! */ }, #define DC25_OPT_DEFAULT 11 { "default-enhancements", "Defaults", "Set default values for enhancement controls (i.e. contrast).", SANE_TYPE_BUTTON, SANE_UNIT_NONE, 0, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } }; static SANE_Parameters parms = { SANE_FRAME_RGB, 1, 500, /* Number of bytes returned per scan line: */ 500, /* Number of pixels per scan line. */ 373, /* Number of lines for the current scan. */ 8, /* Number of bits per sample. */ }; static unsigned char init_pck[] = INIT_PCK; /* * List of speeds to try to establish connection with the camera. * Check 9600 first, as it's the speed the camera comes up in, then * 115200, as that is the one most likely to be configured from a * previous run */ static struct pkt_speed speeds[] = { {B9600, {0x96, 0x00}}, #ifdef B115200 {B115200, {0x11, 0x52}}, #endif #ifdef B57600 {B57600, {0x57, 0x60}}, #endif {B38400, {0x38, 0x40}}, {B19200, {0x19, 0x20}}, }; #define NUM_OF_SPEEDS ((int)(sizeof(speeds) / sizeof(struct pkt_speed))) static struct termios tty_orig; static int send_pck (int fd, unsigned char *pck) { int n; unsigned char r; /* * Not quite sure why we need this, but the program works a whole * lot better (at least on the DC25) with this short delay. */ #ifdef HAVE_USLEEP usleep (10); #else sleep (1); #endif if (write (fd, (char *) pck, 8) != 8) { DBG (2, "send_pck: error: write returned -1\n"); return -1; } if ((n = read (fd, (char *) &r, 1)) != 1) { DBG (2, "send_pck: error: read returned -1\n"); return -1; } return (r == 0xd1) ? 0 : -1; } static int init_dc20 (char *device, speed_t speed) { struct termios tty_new; int speed_index; DBG (1, "DC-20/25 Backend 05/07/01\n"); for (speed_index = 0; speed_index < NUM_OF_SPEEDS; speed_index++) { if (speeds[speed_index].baud == speed) { init_pck[2] = speeds[speed_index].pkt_code[0]; init_pck[3] = speeds[speed_index].pkt_code[1]; break; } } if (init_pck[2] == 0) { DBG (2, "unsupported baud rate.\n"); return -1; } /* Open device file. */ if ((tfd = open (device, O_RDWR)) == -1) { DBG (2, "init_dc20: error: could not open %s for read/write\n", device); return -1; } /* Save old device information to restore when we are done. */ if (tcgetattr (tfd, &tty_orig) == -1) { DBG (2, "init_dc20: error: could not get attributes\n"); return -1; } memcpy ((char *) &tty_new, (char *) &tty_orig, sizeof (struct termios)); /* We need the device to be raw. 8 bits even parity on 9600 baud to start. */ #ifdef HAVE_CFMAKERAW cfmakeraw (&tty_new); #else tty_new.c_lflag &= ~(ICANON | ECHO | ISIG); #endif tty_new.c_oflag &= ~CSTOPB; tty_new.c_cflag |= PARENB; tty_new.c_cflag &= ~PARODD; tty_new.c_cc[VMIN] = 0; tty_new.c_cc[VTIME] = 50; cfsetospeed (&tty_new, B9600); cfsetispeed (&tty_new, B9600); if (tcsetattr (tfd, TCSANOW, &tty_new) == -1) { DBG (2, "init_dc20: error: could not set attributes\n"); return -1; } if (send_pck (tfd, init_pck) == -1) { /* * The camera always powers up at 9600, so we try * that first. However, it may be already set to * a different speed. Try the entries in the table: */ for (speed_index = NUM_OF_SPEEDS - 1; speed_index > 0; speed_index--) { DBG (3, "init_dc20: changing speed to %d\n", (int) speeds[speed_index].baud); cfsetospeed (&tty_new, speeds[speed_index].baud); cfsetispeed (&tty_new, speeds[speed_index].baud); if (tcsetattr (tfd, TCSANOW, &tty_new) == -1) { DBG (2, "init_dc20: error: could not set attributes\n"); return -1; } if (send_pck (tfd, init_pck) != -1) break; } if (speed_index == 0) { tcsetattr (tfd, TCSANOW, &tty_orig); DBG (2, "init_dc20: error: no suitable baud rate\n"); return -1; } } /* Set speed to requested speed. Also, make a long timeout (we need this for erase and shoot operations) */ tty_new.c_cc[VTIME] = 150; cfsetospeed (&tty_new, speed); cfsetispeed (&tty_new, speed); if (tcsetattr (tfd, TCSANOW, &tty_new) == -1) { DBG (2, "init_dc20: error: could not set attributes\n"); return -1; } return tfd; } static void close_dc20 (int fd) { DBG (127, "close_dc20() called\n"); /* * Put the camera back to 9600 baud */ init_pck[2] = speeds[0].pkt_code[0]; init_pck[3] = speeds[0].pkt_code[1]; if (send_pck (fd, init_pck) == -1) { DBG (4, "close_dc20: error: could not set attributes\n"); } /* Restore original device settings. */ if (tcsetattr (fd, TCSANOW, &tty_orig) == -1) { DBG (4, "close_dc20: error: could not set attributes\n"); } if (close (fd) == -1) { DBG (4, "close_dc20: error: could not close device\n"); } } static unsigned char info_pck[] = INFO_PCK; static Dc20Info * get_info (int fd) { unsigned char buf[256]; if (send_pck (fd, info_pck) == -1) { DBG (2, "get_info: error: send_pck returned -1\n"); return NULL; } DBG (9, "get_info: read info packet\n"); if (read_data (fd, buf, 256) == -1) { DBG (2, "get_info: error: read_data returned -1\n"); return NULL; } if (end_of_data (fd) == -1) { DBG (2, "get_info: error: end_of_data returned -1\n"); return NULL; } CameraInfo.model = buf[1]; CameraInfo.ver_major = buf[2]; CameraInfo.ver_minor = buf[3]; CameraInfo.pic_taken = buf[8] << 8 | buf[9]; if (CameraInfo.model == 0x25) { /* Not sure where the previous line came from. All the * information I have says that even on the DC20 the number of * standard res pics is in byte 17 and the number of high res pics * is in byte 19. This is definitely true on my DC25. */ CameraInfo.pic_taken = buf[17] + buf[19]; } image_range.max = CameraInfo.pic_taken; image_range.min = CameraInfo.pic_taken ? 1 : 0; CameraInfo.pic_left = buf[10] << 8 | buf[11]; if (CameraInfo.model == 0x25) { /* Not sure where the previous line came from. All the * information I have says that even on the DC20 the number of * standard res pics left is in byte 23 and the number of high res * pics left is in byte 21. It seems to me that the conservative * approach is to report the number of high res pics left. */ CameraInfo.pic_left = buf[21]; } CameraInfo.flags.low_res = buf[23]; if (CameraInfo.model == 0x25) { /* Not sure where the previous line came from. All the * information I have says that even on the DC20 the low_res * byte is 11. */ CameraInfo.flags.low_res = buf[11]; } CameraInfo.flags.low_batt = buf[29]; return &CameraInfo; } static int read_data (int fd, unsigned char *buf, int sz) { unsigned char ccsum; unsigned char rcsum; unsigned char c; int retries = 0; int n; int r = 0; int i; while (retries++ < 5) { /* * If this is not the first time through, then it must be * a retry - signal the camera that we didn't like what * we got. In either case, start filling the packet */ if (retries != 1) { DBG (2, "Attempt retry %d\n", retries); c = 0xe3; if (write (fd, (char *) &c, 1) != 1) { DBG (2, "read_data: error: write ack\n"); return -1; } } for (n = 0; n < sz && (r = read (fd, (char *) &buf[n], sz - n)) > 0; n += r) ; if (r <= 0) { DBG (2, "read_data: error: read returned -1\n"); continue; } if (n < sz || read (fd, &rcsum, 1) != 1) { DBG (2, "read_data: error: buffer underrun or no checksum\n"); continue; } for (i = 0, ccsum = 0; i < n; i++) ccsum ^= buf[i]; if (ccsum != rcsum) { DBG (2, "read_data: error: bad checksum (%02x != %02x)\n", rcsum, ccsum); continue; } /* If we got this far, then the packet is OK */ break; } c = 0xd2; if (write (fd, (char *) &c, 1) != 1) { DBG (2, "read_data: error: write ack\n"); return -1; } return 0; } static int end_of_data (int fd) { char c; if (read (fd, &c, 1) != 1) { DBG (2, "end_of_data: error: read returned -1\n"); return -1; } if (c != 0) { DBG (2, "end_of_data: error: bad EOD from camera (%02x)\n", (unsigned) c); return -1; } return 0; } #include #define BIDIM_ARRAY(name, x, y, width) (name[((x) + ((y) * (width)))]) /* * These definitions depend on the resolution of the image */ #define MY_LOW_RIGHT_MARGIN 6 /* * These definitions are constant with resolution */ #define MY_LEFT_MARGIN 2 #define NET_COLUMNS (columns - MY_LEFT_MARGIN - right_margin) #define NET_LINES (HEIGHT - TOP_MARGIN - BOTTOM_MARGIN) #define NET_PIXELS (NET_COLUMNS * NET_LINES) #define SCALE 64 #define SMAX (256 * SCALE - 1) #define HORIZONTAL_INTERPOLATIONS 3 #define HISTOGRAM_STEPS 4096 #define RFACTOR 0.64 #define GFACTOR 0.58 #define BFACTOR 1.00 #define RINTENSITY 0.476 #define GINTENSITY 0.299 #define BINTENSITY 0.175 #define SATURATION 1.0 #define NORM_PERCENTAGE 3 static int columns = HIGH_WIDTH, right_margin = HIGH_RIGHT_MARGIN, camera_header_size = HIGH_CAMERA_HEADER; static int low_i = -1, high_i = -1, norm_percentage = NORM_PERCENTAGE; static float saturation = SATURATION, rfactor = RFACTOR, gfactor = GFACTOR, bfactor = BFACTOR; static void set_initial_interpolation (const unsigned char ccd[], short horizontal_interpolation[]) { int column, line; for (line = 0; line < HEIGHT; line++) { BIDIM_ARRAY (horizontal_interpolation, MY_LEFT_MARGIN, line, columns) = BIDIM_ARRAY (ccd, MY_LEFT_MARGIN + 1, line, columns) * SCALE; BIDIM_ARRAY (horizontal_interpolation, columns - right_margin - 1, line, columns) = BIDIM_ARRAY (ccd, columns - right_margin - 2, line, columns) * SCALE; for (column = MY_LEFT_MARGIN + 1; column < columns - right_margin - 1; column++) { BIDIM_ARRAY (horizontal_interpolation, column, line, columns) = (BIDIM_ARRAY (ccd, column - 1, line, columns) + BIDIM_ARRAY (ccd, column + 1, line, columns)) * (SCALE / 2); } } } static void interpolate_horizontally (const unsigned char ccd[], short horizontal_interpolation[]) { int column, line, i, initial_column; for (line = TOP_MARGIN - 1; line < HEIGHT - BOTTOM_MARGIN + 1; line++) { for (i = 0; i < HORIZONTAL_INTERPOLATIONS; i++) { for (initial_column = MY_LEFT_MARGIN + 1; initial_column <= MY_LEFT_MARGIN + 2; initial_column++) { for (column = initial_column; column < columns - right_margin - 1; column += 2) { BIDIM_ARRAY (horizontal_interpolation, column, line, columns) = ((float) BIDIM_ARRAY (ccd, column - 1, line, columns) / BIDIM_ARRAY (horizontal_interpolation, column - 1, line, columns) + (float) BIDIM_ARRAY (ccd, column + 1, line, columns) / BIDIM_ARRAY (horizontal_interpolation, column + 1, line, columns)) * BIDIM_ARRAY (ccd, column, line, columns) * (SCALE * SCALE / 2) + 0.5; } } } } } static void interpolate_vertically (const unsigned char ccd[], const short horizontal_interpolation[], short red[], short green[], short blue[]) { int column, line; for (line = TOP_MARGIN; line < HEIGHT - BOTTOM_MARGIN; line++) { for (column = MY_LEFT_MARGIN; column < columns - right_margin; column++) { int r2gb, g2b, rg2, rgb2, r, g, b; int this_ccd = BIDIM_ARRAY (ccd, column, line, columns) * SCALE; int up_ccd = BIDIM_ARRAY (ccd, column, line - 1, columns) * SCALE; int down_ccd = BIDIM_ARRAY (ccd, column, line + 1, columns) * SCALE; int this_horizontal_interpolation = BIDIM_ARRAY (horizontal_interpolation, column, line, columns); int this_intensity = this_ccd + this_horizontal_interpolation; int up_intensity = BIDIM_ARRAY (horizontal_interpolation, column, line - 1, columns) + up_ccd; int down_intensity = BIDIM_ARRAY (horizontal_interpolation, column, line + 1, columns) + down_ccd; int this_vertical_interpolation; /* * PSF: I don't understand all this code, but I've found pictures * where up_intensity or down_intensity are zero, resulting in a * divide by zero error. It looks like this only happens when * up_ccd or down_ccd are also zero, so we just set the intensity * value to non-zero to prevent the error. */ if (down_ccd == 0) DBG (10, "down_ccd==0 at %d,%d\n", line, column); if (up_ccd == 0) DBG (10, "up_ccd==0 at %d,%d\n", line, column); if (down_intensity == 0) { DBG (9, "Found down_intensity==0 at %d,%d down_ccd=%d\n", line, column, down_ccd); down_intensity = 1; } if (up_intensity == 0) { DBG (9, "Found up_intensity==0 at %d,%d up_ccd=%d\n", line, column, up_ccd); up_intensity = 1; } if (line == TOP_MARGIN) { this_vertical_interpolation = (float) down_ccd / down_intensity * this_intensity + 0.5; } else if (line == HEIGHT - BOTTOM_MARGIN - 1) { this_vertical_interpolation = (float) up_ccd / up_intensity * this_intensity + 0.5; } else { this_vertical_interpolation = ((float) up_ccd / up_intensity + (float) down_ccd / down_intensity) * this_intensity / 2.0 + 0.5; } if (line & 1) { if (column & 1) { r2gb = this_ccd; g2b = this_horizontal_interpolation; rg2 = this_vertical_interpolation; r = (2 * (r2gb - g2b) + rg2) / 5; g = (rg2 - r) / 2; b = g2b - 2 * g; } else { g2b = this_ccd; r2gb = this_horizontal_interpolation; rgb2 = this_vertical_interpolation; r = (3 * r2gb - g2b - rgb2) / 5; g = 2 * r - r2gb + g2b; b = g2b - 2 * g; } } else { if (column & 1) { rg2 = this_ccd; rgb2 = this_horizontal_interpolation; r2gb = this_vertical_interpolation; b = (3 * rgb2 - r2gb - rg2) / 5; g = (rgb2 - r2gb + rg2 - b) / 2; r = rg2 - 2 * g; } else { rgb2 = this_ccd; rg2 = this_horizontal_interpolation; g2b = this_vertical_interpolation; b = (g2b - 2 * (rg2 - rgb2)) / 5; g = (g2b - b) / 2; r = rg2 - 2 * g; } } if (r < 0) r = 0; if (g < 0) g = 0; if (b < 0) b = 0; BIDIM_ARRAY (red, column, line, columns) = r; BIDIM_ARRAY (green, column, line, columns) = g; BIDIM_ARRAY (blue, column, line, columns) = b; } } } static void adjust_color_and_saturation (short red[], short green[], short blue[]) { int line, column; int r_min = SMAX, g_min = SMAX, b_min = SMAX; int r_max = 0, g_max = 0, b_max = 0; int r_sum = 0, g_sum = 0, b_sum = 0; float sqr_saturation = sqrt (saturation); for (line = TOP_MARGIN; line < HEIGHT - BOTTOM_MARGIN; line++) { for (column = MY_LEFT_MARGIN; column < columns - right_margin; column++) { float r = BIDIM_ARRAY (red, column, line, columns) * rfactor; float g = BIDIM_ARRAY (green, column, line, columns) * gfactor; float b = BIDIM_ARRAY (blue, column, line, columns) * bfactor; if (saturation != 1.0) { float *min, *mid, *max, new_intensity; float intensity = r * RINTENSITY + g * GINTENSITY + b * BINTENSITY; if (r > g) { if (r > b) { max = &r; if (g > b) { min = &b; mid = &g; } else { min = &g; mid = &b; } } else { min = &g; mid = &r; max = &b; } } else { if (g > b) { max = &g; if (r > b) { min = &b; mid = &r; } else { min = &r; mid = &b; } } else { min = &r; mid = &g; max = &b; } } *mid = *min + sqr_saturation * (*mid - *min); *max = *min + saturation * (*max - *min); new_intensity = r * RINTENSITY + g * GINTENSITY + b * BINTENSITY; r *= intensity / new_intensity; g *= intensity / new_intensity; b *= intensity / new_intensity; } r += 0.5; g += 0.5; b += 0.5; if (r_min > r) r_min = r; if (g_min > g) g_min = g; if (b_min > b) b_min = b; if (r_max < r) r_max = r; if (g_max < g) g_max = g; if (b_max < b) b_max = b; r_sum += r; g_sum += g; b_sum += b; BIDIM_ARRAY (red, column, line, columns) = r; BIDIM_ARRAY (green, column, line, columns) = g; BIDIM_ARRAY (blue, column, line, columns) = b; } } } static int min3 (int x, int y, int z) { return (x < y ? (x < z ? x : z) : (y < z ? y : z)); } static int max3 (int x, int y, int z) { return (x > y ? (x > z ? x : z) : (y > z ? y : z)); } static void determine_limits (const short red[], const short green[], const short blue[], int *low_i_ptr, int *high_i_ptr) { unsigned int histogram[HISTOGRAM_STEPS + 1]; int column, line, i, s; int low_i = *low_i_ptr, high_i = *high_i_ptr; int max_i = 0; for (line = TOP_MARGIN; line < HEIGHT - BOTTOM_MARGIN; line++) { for (column = MY_LEFT_MARGIN; column < columns - right_margin; column++) { i = max3 (BIDIM_ARRAY (red, column, line, columns), BIDIM_ARRAY (green, column, line, columns), BIDIM_ARRAY (blue, column, line, columns)); if (i > max_i) max_i = i; } } if (low_i == -1) { for (i = 0; i <= HISTOGRAM_STEPS; i++) histogram[i] = 0; for (line = TOP_MARGIN; line < HEIGHT - BOTTOM_MARGIN; line++) { for (column = MY_LEFT_MARGIN; column < columns - right_margin; column++) { i = min3 (BIDIM_ARRAY (red, column, line, columns), BIDIM_ARRAY (green, column, line, columns), BIDIM_ARRAY (blue, column, line, columns)); histogram[i * HISTOGRAM_STEPS / max_i]++; } } for (low_i = 0, s = 0; low_i <= HISTOGRAM_STEPS && s < NET_PIXELS * norm_percentage / 100; low_i++) { s += histogram[low_i]; } low_i = (low_i * max_i + HISTOGRAM_STEPS / 2) / HISTOGRAM_STEPS; *low_i_ptr = low_i; } if (high_i == -1) { for (i = 0; i <= HISTOGRAM_STEPS; i++) histogram[i] = 0; for (line = TOP_MARGIN; line < HEIGHT - BOTTOM_MARGIN; line++) { for (column = MY_LEFT_MARGIN; column < columns - right_margin; column++) { i = max3 (BIDIM_ARRAY (red, column, line, columns), BIDIM_ARRAY (green, column, line, columns), BIDIM_ARRAY (blue, column, line, columns)); histogram[i * HISTOGRAM_STEPS / max_i]++; } } for (high_i = HISTOGRAM_STEPS, s = 0; high_i >= 0 && s < NET_PIXELS * norm_percentage / 100; high_i--) { s += histogram[high_i]; } high_i = (high_i * max_i + HISTOGRAM_STEPS / 2) / HISTOGRAM_STEPS; *high_i_ptr = high_i; } /* if (verbose) printf ("%s: determine_limits: low_i = %d, high_i = %d\n", __progname, low_i, high_i); */ } /* * The original dc20ctrl program used a default gamma of 0.35, but I thougt * 0.45 looks better. In addition, since xscanimage seems to always force * a resolution of 0.1, I multiply everything by 10 and make the default * 4.5. */ static unsigned char * make_gamma_table (int range) { int i; double factor = pow (256.0, 1.0 / (SANE_UNFIX (dc25_opt_gamma) / 10.0)) / range; unsigned char *gamma_table; if ((gamma_table = malloc (range * sizeof (unsigned char))) == NULL) { DBG (1, "make_gamma_table: can't allocate memory for gamma table\n"); return NULL; } for (i = 0; i < range; i++) { int g = pow ((double) i * factor, (SANE_UNFIX (dc25_opt_gamma) / 10.0)) + 0.5; /* if (verbose) fprintf (stderr, "%s: make_gamma_table: gamma[%4d] = %3d\n", __progname, i, g); */ if (g > 255) g = 255; gamma_table[i] = g; } return gamma_table; } static int lookup_gamma_table (int i, int low_i, int high_i, const unsigned char gamma_table[]) { if (i <= low_i) return 0; if (i >= high_i) return 255; return gamma_table[i - low_i]; } static int output_rgb (const short red[], const short green[], const short blue[], int low_i, int high_i, struct pixmap *pp) { int r_min = 255, g_min = 255, b_min = 255; int r_max = 0, g_max = 0, b_max = 0; int r_sum = 0, g_sum = 0, b_sum = 0; int column, line; unsigned char *gamma_table = make_gamma_table (high_i - low_i); if (gamma_table == NULL) { DBG (10, "output_rgb: error: cannot make gamma table\n"); return -1; } for (line = TOP_MARGIN; line < HEIGHT - BOTTOM_MARGIN; line++) { for (column = MY_LEFT_MARGIN; column < columns - right_margin; column++) { int r = lookup_gamma_table (BIDIM_ARRAY (red, column, line, columns), low_i, high_i, gamma_table); int g = lookup_gamma_table (BIDIM_ARRAY (green, column, line, columns), low_i, high_i, gamma_table); int b = lookup_gamma_table (BIDIM_ARRAY (blue, column, line, columns), low_i, high_i, gamma_table); if (r > 255) r = 255; else if (r < 0) r = 0; if (g > 255) g = 255; else if (g < 0) g = 0; if (b > 255) b = 255; else if (b < 0) b = 0; set_pixel_rgb (pp, column - MY_LEFT_MARGIN, line - TOP_MARGIN, r, g, b); if (r_min > r) r_min = r; if (g_min > g) g_min = g; if (b_min > b) b_min = b; if (r_max < r) r_max = r; if (g_max < g) g_max = g; if (b_max < b) b_max = b; r_sum += r; g_sum += g; b_sum += b; } } free (gamma_table); /* { fprintf (stderr, "%s: output_rgb: r: min = %d, max = %d, ave = %d\n", __progname, r_min, r_max, r_sum / NET_PIXELS); fprintf (stderr, "%s: output_rgb: g: min = %d, max = %d, ave = %d\n", __progname, g_min, g_max, g_sum / NET_PIXELS); fprintf (stderr, "%s: output_rgb: b: min = %d, max = %d, ave = %d\n", __progname, b_min, b_max, b_sum / NET_PIXELS); } */ return 0; } static int comet_to_pixmap (unsigned char *pic, struct pixmap *pp) { unsigned char *ccd; short *horizontal_interpolation, *red, *green, *blue; int retval = 0; if (pic == NULL) { DBG (1, "cmttoppm: error: no input image\n"); return -1; } if (pic[4] == 0x01) { /* Low resolution mode */ columns = LOW_WIDTH; right_margin = MY_LOW_RIGHT_MARGIN; camera_header_size = LOW_CAMERA_HEADER; } else { /* High resolution mode */ columns = HIGH_WIDTH; right_margin = HIGH_RIGHT_MARGIN; camera_header_size = HIGH_CAMERA_HEADER; } ccd = pic + camera_header_size; if ((horizontal_interpolation = malloc (sizeof (short) * HEIGHT * columns)) == NULL) { DBG (1, "cmttoppm: error: not enough memory for horizontal_interpolation\n"); return -1; } if ((red = malloc (sizeof (short) * HEIGHT * columns)) == NULL) { DBG (1, "error: not enough memory for red\n"); return -1; } if ((green = malloc (sizeof (short) * HEIGHT * columns)) == NULL) { DBG (1, "error: not enough memory for green\n"); return -1; } if ((blue = malloc (sizeof (short) * HEIGHT * columns)) == NULL) { DBG (1, "error: not enough memory for blue\n"); return -1; } /* Decode raw CCD data to RGB */ set_initial_interpolation (ccd, horizontal_interpolation); interpolate_horizontally (ccd, horizontal_interpolation); interpolate_vertically (ccd, horizontal_interpolation, red, green, blue); adjust_color_and_saturation (red, green, blue); /* Determine lower and upper limit using histogram */ if (low_i == -1 || high_i == -1) { determine_limits (red, green, blue, &low_i, &high_i); } /* Output pixmap structure */ retval = output_rgb (red, green, blue, low_i, high_i, pp); return retval; } static int convert_pic (char *base_name, int format) { FILE *ifp; unsigned char pic[MAX_IMAGE_SIZE]; int res, image_width, net_width, components; struct pixmap *pp2; DBG (127, "convert_pic() called\n"); /* * Read the image in memory */ if ((ifp = fopen (base_name, "rb")) == NULL) { DBG (10, "convert_pic: error: cannot open %s for reading\n", base_name); return -1; } if (fread (pic, COMET_HEADER_SIZE, 1, ifp) != 1) { DBG (10, "convert_pic: error: cannot read COMET header\n"); fclose (ifp); return -1; } if (strncmp ((char *) pic, COMET_MAGIC, sizeof (COMET_MAGIC)) != 0) { DBG (10, "convert_pic: error: file %s is not in COMET format\n", base_name); fclose (ifp); return -1; } if (fread (pic, LOW_CAMERA_HEADER, 1, ifp) != 1) { DBG (10, "convert_pic: error: cannot read camera header\n"); fclose (ifp); return -1; } res = pic[4]; if (res == 0) { /* * We just read a LOW_CAMERA_HEADER block, so resync with the * HIGH_CAMERA_HEADER length by reading once more one of this. */ if (fread (pic + LOW_CAMERA_HEADER, LOW_CAMERA_HEADER, 1, ifp) != 1) { DBG (10, "convert_pic: error: cannot resync with high resolution header\n"); fclose (ifp); return -1; } } if (fread (pic + CAMERA_HEADER (res), WIDTH (res), HEIGHT, ifp) != HEIGHT) { DBG (9, "convert_pic: error: cannot read picture\n"); fclose (ifp); return -1; } fclose (ifp); /* * Setup image size with resolution */ image_width = WIDTH (res); net_width = image_width - LEFT_MARGIN - RIGHT_MARGIN (res); components = (format & SAVE_24BITS) ? 3 : 1; /* * Convert the image to 24 bits */ if ((pp = alloc_pixmap (net_width - 1, HEIGHT - BOTTOM_MARGIN - 1, components)) == NULL) { DBG (1, "convert_pic: error: alloc_pixmap\n"); return -1; } comet_to_pixmap (pic, pp); if (format & SAVE_ADJASPECT) { /* * Strech image */ if (res) pp2 = alloc_pixmap (320, HEIGHT - BOTTOM_MARGIN - 1, components); else pp2 = alloc_pixmap (net_width - 1, 373, components); if (pp2 == NULL) { DBG (2, "convert_pic: error: alloc_pixmap\n"); free_pixmap (pp); return -1; } if (res) zoom_x (pp, pp2); else zoom_y (pp, pp2); free_pixmap (pp); pp = pp2; pp2 = NULL; } return 0; } #define PGM_EXT "pgm" #define PPM_EXT "ppm" #define RED 0.30 #define GREEN 0.59 #define BLUE 0.11 #define RED_OFFSET 0 #define GREEN_OFFSET 1 #define BLUE_OFFSET 2 #define GET_COMP(pp, x, y, c) (pp->planes[((x) + (y)*pp->width)*pp->components + (c)]) #define GET_R(pp, x, y) (GET_COMP(pp, x, y, RED_OFFSET)) #define GET_G(pp, x, y) (GET_COMP(pp, x, y, GREEN_OFFSET)) #define GET_B(pp, x, y) (GET_COMP(pp, x, y, BLUE_OFFSET)) static struct pixmap * alloc_pixmap (int x, int y, int d) { struct pixmap *result = NULL; if (d == 1 || d == 3) { if (x > 0) { if (y > 0) { if ((result = malloc (sizeof (struct pixmap))) != NULL) { result->width = x; result->height = y; result->components = d; if (!(result->planes = malloc (x * y * d))) { DBG (10, "alloc_pixmap: error: not enough memory for bitplanes\n"); free (result); result = NULL; } } else DBG (10, "alloc_pixmap: error: not enough memory for pixmap\n"); } else DBG (10, "alloc_pixmap: error: y is out of range\n"); } else DBG (10, "alloc_pixmap: error: x is out of range\n"); } else DBG (10, "alloc_pixmap: error: cannot handle %d components\n", d); return result; } static void free_pixmap (struct pixmap *p) { if (p) { free (p->planes); free (p); } } static int set_pixel_rgb (struct pixmap *p, int x, int y, unsigned char r, unsigned char g, unsigned char b) { int result = 0; if (p) { if (x >= 0 && x < p->width) { if (y >= 0 && y < p->height) { if (p->components == 1) { GET_R (p, x, y) = RED * r + GREEN * g + BLUE * b; } else { GET_R (p, x, y) = r; GET_G (p, x, y) = g; GET_B (p, x, y) = b; } } else { DBG (10, "set_pixel_rgb: error: y out of range\n"); result = -1; } } else { DBG (10, "set_pixel_rgb: error: x out of range\n"); result = -1; } } return result; } static int zoom_x (struct pixmap *source, struct pixmap *dest) { int result = 0, dest_col, row, component, src_index; float ratio, src_ptr, delta; unsigned char src_component; if (source && dest) { /* * We could think of resizing a pixmap and changing the number of * components at the same time. Maybe this will be implemented later. */ if (source->height == dest->height && source->components == dest->components) { if (source->width < dest->width) { ratio = ((float) source->width / (float) dest->width); for (src_ptr = 0, dest_col = 0; dest_col < dest->width; src_ptr += ratio, dest_col++) { /* * dest[dest_col] = source[(int)src_ptr] + * (source[((int)src_ptr) + 1] - source[(int)src_ptr]) * * (src_ptr - (int)src_ptr); */ src_index = (int) src_ptr; delta = src_ptr - src_index; for (row = 0; row < source->height; row++) { for (component = 0; component < source->components; component++) { src_component = GET_COMP (source, src_index, row, component); GET_COMP (dest, dest_col, row, component) = src_component + (GET_COMP (source, src_index + 1, row, component) - src_component) * delta; } } } } else { DBG (10, "zoom_x: error: can only zoom out\n"); result = -1; } } else { DBG (10, "zoom_x: error: incompatible pixmaps\n"); result = -1; } } return result; } static int zoom_y (struct pixmap *source, struct pixmap *dest) { int result = 0, dest_row, column, component, src_index; float ratio, src_ptr, delta; unsigned char src_component; if (source && dest) { /* * We could think of resizing a pixmap and changing the number of * components at the same time. Maybe this will be implemented later. */ if (source->width == dest->width && source->components == dest->components) { if (source->height < dest->height) { ratio = ((float) source->height / (float) dest->height); for (src_ptr = 0, dest_row = 0; dest_row < dest->height; src_ptr += ratio, dest_row++) { /* * dest[dest_row] = source[(int)src_ptr] + * (source[((int)src_ptr) + 1] - source[(int)src_ptr]) * * (src_ptr - (int)src_ptr); */ src_index = (int) src_ptr; delta = src_ptr - src_index; for (column = 0; column < source->width; column++) { for (component = 0; component < source->components; component++) { src_component = GET_COMP (source, column, src_index, component); GET_COMP (dest, column, dest_row, component) = src_component + (GET_COMP (source, column, src_index + 1, component) - src_component) * delta; } } } } else { DBG (10, "zoom_y: error: can only zoom out\n"); result = -1; } } else { DBG (10, "zoom_y: error: incompatible pixmaps\n"); result = -1; } } return result; } static unsigned char shoot_pck[] = SHOOT_PCK; static int shoot (int fd) { struct termios tty_temp, tty_old; int result = 0; DBG (127, "shoot() called\n"); if (write (fd, (char *) shoot_pck, 8) != 8) { DBG (3, "shoot: error: write error\n"); return -1; } if (CameraInfo.model != 0x25) { /* * WARNING: now we set the serial port to 9600 baud! */ if (tcgetattr (fd, &tty_old) == -1) { DBG (3, "shoot: error: could not get attributes\n"); return -1; } memcpy ((char *) &tty_temp, (char *) &tty_old, sizeof (struct termios)); cfsetispeed (&tty_temp, B9600); cfsetospeed (&tty_temp, B9600); /* * Apparently there is a bug in the DC20 where the response to * the shoot request is always at 9600. The DC25 does not have * this bug, so we skip this block. */ if (tcsetattr (fd, TCSANOW, &tty_temp) == -1) { DBG (3, "shoot: error: could not set attributes\n"); return -1; } } if (read (fd, (char *) &result, 1) != 1) { DBG (3, "shoot: error: read returned -1\n"); result = -1; } else { result = (result == 0xD1) ? 0 : -1; } if (CameraInfo.model != 0x25) { /* * We reset the serial to its original speed. * We can skip this on the DC25 also. */ if (tcsetattr (fd, TCSANOW, &tty_old) == -1) { DBG (3, "shoot: error: could not reset attributes\n"); result = -1; } } if (result == 0) { if (CameraInfo.model == 0x25) { /* * If we don't put this in, the next read will time out * and return failure. Does the DC-20 need it too? */ sleep (3); } if (end_of_data (fd) == -1) { DBG (3, "shoot: error: end_of_data returned -1\n"); result = -1; } } return result; } static unsigned char erase_pck[] = ERASE_PCK; static int erase (int fd) { int count = 0; DBG (127, "erase() called for image %d\n", dc25_opt_image_number); erase_pck[3] = dc25_opt_image_number; if (dc25_opt_erase) { erase_pck[3] = 0; } if (send_pck (fd, erase_pck) == -1) { DBG (3, "erase: error: send_pck returned -1\n"); return -1; } if (CameraInfo.model == 0x25) { /* * This block may really apply to the DC20 also, but since I * don't have one, it's hard to say for sure. On the DC25, erase * takes long enought that the read may timeout without returning * any data before the erase is complete. We let this happen * up to 4 times, then give up. */ while (count < 4) { if (end_of_data (fd) == -1) { count++; } else { break; } } if (count == 4) { DBG (3, "erase: error: end_of_data returned -1\n"); return -1; } } else { /* Assume DC-20 */ if (end_of_data (fd) == -1) { DBG (3, "erase: error: end_of_data returned -1\n"); return -1; } } return 0; } static unsigned char res_pck[] = RES_PCK; static int change_res (int fd, unsigned char res) { DBG (127, "change_res called\n"); if (res != 0 && res != 1) { DBG (3, "change_res: error: unsupported resolution\n"); return -1; } res_pck[2] = res; if (send_pck (fd, res_pck) == -1) { DBG (4, "change_res: error: send_pck returned -1\n"); } if (end_of_data (fd) == -1) { DBG (4, "change_res: error: end_of_data returned -1\n"); } return 0; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { char dev_name[PATH_MAX], *p; size_t len; FILE *fp; int baud; strcpy (tty_name, DEF_TTY_NAME); DBG_INIT (); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (DC25_CONFIG_FILE); DBG (127, "sane_init() $Id$\n"); if (!fp) { /* default to /dev/ttyS0 instead of insisting on config file */ DBG (1, "sane_init: missing config file '%s'\n", DC25_CONFIG_FILE); } else { while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { dev_name[sizeof (dev_name) - 1] = '\0'; DBG (20, "sane_init: config- %s", dev_name); if (dev_name[0] == '#') continue; /* ignore line comments */ len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ if (strncmp (dev_name, "port=", 5) == 0) { p = strchr (dev_name, '/'); if (p) { strcpy (tty_name, p); } DBG (20, "Config file port=%s\n", tty_name); } else if (strncmp (dev_name, "baud=", 5) == 0) { baud = atoi (&dev_name[5]); switch (baud) { case 9600: tty_baud = B9600; break; case 19200: tty_baud = B19200; break; case 38400: tty_baud = B38400; break; #ifdef B57600 case 57600: tty_baud = B57600; break; #endif #ifdef B115200 case 115200: tty_baud = B115200; break; #endif default: DBG (20, "Unknown baud=%d\n", baud); tty_baud = DEFAULT_TTY_BAUD; break; } DBG (20, "Config file baud=%lu\n", (u_long) tty_baud); } else if (strcmp (dev_name, "dumpinquiry") == 0) { dumpinquiry = SANE_TRUE; } } fclose (fp); } if ((tfd = init_dc20 (tty_name, tty_baud)) == -1) { return SANE_STATUS_INVAL; } if ((dc20_info = get_info (tfd)) == NULL) { DBG (2, "error: could not get info\n"); close_dc20 (tfd); return SANE_STATUS_INVAL; } if (dumpinquiry) { DBG (0, "\nCamera information:\n~~~~~~~~~~~~~~~~~\n\n"); DBG (0, "Model...........: DC%x\n", dc20_info->model); DBG (0, "Firmware version: %d.%d\n", dc20_info->ver_major, dc20_info->ver_minor); DBG (0, "Pictures........: %d/%d\n", dc20_info->pic_taken, dc20_info->pic_taken + dc20_info->pic_left); DBG (0, "Resolution......: %s\n", dc20_info->flags.low_res ? "low" : "high"); DBG (0, "Battery state...: %s\n", dc20_info->flags.low_batt ? "low" : "good"); } if (CameraInfo.pic_taken == 0) { /* sod[DC25_OPT_IMAGE_NUMBER].cap |= SANE_CAP_INACTIVE; */ image_range.min = 0; dc25_opt_image_number = 0; } else { /* sod[DC25_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; */ image_range.min = 1; } return SANE_STATUS_GOOD; } void sane_exit (void) { } /* Device select/open/close */ static const SANE_Device dev[] = { { "0", "Kodak", "DC-25", "still camera"}, }; SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { static const SANE_Device *devlist[] = { dev + 0, 0 }; DBG (127, "sane_get_devices called\n"); if (dc20_info == NULL) { return SANE_STATUS_INVAL; } *device_list = devlist; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { int i; DBG (127, "sane_open for device %s\n", devicename); if (!devicename[0]) { i = 0; } else { for (i = 0; i < NELEMS (dev); ++i) { if (strcmp (devicename, dev[i].name) == 0) { break; } } } if (i >= NELEMS (dev)) { return SANE_STATUS_INVAL; } if (is_open) { return SANE_STATUS_DEVICE_BUSY; } is_open = 1; *handle = MAGIC; if (dc20_info == NULL) { DBG (1, "No device info\n"); } if (tmpname == NULL) { tmpname = tmpnamebuf; if (!mkstemp (tmpname)) { DBG (1, "Unable to make temp file %s\n", tmpname); return SANE_STATUS_INVAL; } } DBG (3, "sane_open: pictures taken=%d\n", dc20_info->pic_taken); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { DBG (127, "sane_close called\n"); if (handle == MAGIC) is_open = 0; if (pp) { free_pixmap (pp); pp = NULL; } close_dc20 (tfd); DBG (127, "sane_close returning\n"); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { if (handle != MAGIC || !is_open) return NULL; /* wrong device */ if (option < 0 || option >= NELEMS (sod)) return NULL; return &sod[option]; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { SANE_Int myinfo = info_flags; SANE_Status status; info_flags = 0; DBG (127, "control_option(handle=%p,opt=%s,act=%s,val=%p,info=%p)\n", handle, sod[option].title, (action == SANE_ACTION_SET_VALUE ? "SET" : (action == SANE_ACTION_GET_VALUE ? "GET" : "SETAUTO")), value, (void *)info); if (handle != MAGIC || !is_open) return SANE_STATUS_INVAL; /* Unknown handle ... */ if (option < 0 || option >= NELEMS (sod)) return SANE_STATUS_INVAL; /* Unknown option ... */ switch (action) { case SANE_ACTION_SET_VALUE: status = sanei_constrain_value (sod + option, value, &myinfo); if (status != SANE_STATUS_GOOD) { DBG (1, "Constraint error in control_option\n"); return status; } switch (option) { case DC25_OPT_IMAGE_NUMBER: dc25_opt_image_number = *(SANE_Word *) value; /* myinfo |= SANE_INFO_RELOAD_OPTIONS; */ break; case DC25_OPT_THUMBS: dc25_opt_thumbnails = !!*(SANE_Word *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; if (dc25_opt_thumbnails) { /* * DC20 thumbnail are 80x60 grayscale, DC25 * thumbnails are color. */ parms.format = (CameraInfo.model == 0x25) ? SANE_FRAME_RGB : SANE_FRAME_GRAY; parms.bytes_per_line = 80 * 3; parms.pixels_per_line = 80; parms.lines = 60; } else { parms.format = SANE_FRAME_RGB; if (dc20_info->flags.low_res) { parms.bytes_per_line = 320 * 3; parms.pixels_per_line = 320; parms.lines = 243; } else { parms.bytes_per_line = 500 * 3; parms.pixels_per_line = 500; parms.lines = 373; } } break; case DC25_OPT_SNAP: dc25_opt_snap = !!*(SANE_Word *) value; myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; if (dc25_opt_snap) { sod[DC25_OPT_LOWRES].cap &= ~SANE_CAP_INACTIVE; } else { sod[DC25_OPT_LOWRES].cap |= SANE_CAP_INACTIVE; } break; case DC25_OPT_LOWRES: dc25_opt_lowres = !!*(SANE_Word *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; if (!dc25_opt_thumbnails) { parms.format = SANE_FRAME_RGB; if (dc20_info->flags.low_res) { parms.bytes_per_line = 320 * 3; parms.pixels_per_line = 320; parms.lines = 243; } else { parms.bytes_per_line = 500 * 3; parms.pixels_per_line = 500; parms.lines = 373; } } break; case DC25_OPT_CONTRAST: dc25_opt_contrast = *(SANE_Word *) value; break; case DC25_OPT_GAMMA: dc25_opt_gamma = *(SANE_Word *) value; break; case DC25_OPT_ERASE: dc25_opt_erase = !!*(SANE_Word *) value; /* * erase and erase_one are mutually exclusive. If * this one is turned on, the other must be off */ if (dc25_opt_erase && dc25_opt_erase_one) { dc25_opt_erase_one = SANE_FALSE; myinfo |= SANE_INFO_RELOAD_OPTIONS; } break; case DC25_OPT_ERASE_ONE: dc25_opt_erase_one = !!*(SANE_Word *) value; /* * erase and erase_one are mutually exclusive. If * this one is turned on, the other must be off */ if (dc25_opt_erase_one && dc25_opt_erase) { dc25_opt_erase = SANE_FALSE; myinfo |= SANE_INFO_RELOAD_OPTIONS; } break; case DC25_OPT_DEFAULT: dc25_opt_contrast = SANE_FIX (DC25_OPT_CONTRAST_DEFAULT); dc25_opt_gamma = SANE_FIX (DC25_OPT_GAMMA_DEFAULT); myinfo |= SANE_INFO_RELOAD_OPTIONS; break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_GET_VALUE: switch (option) { case 0: *(SANE_Word *) value = NELEMS (sod); break; case DC25_OPT_IMAGE_NUMBER: *(SANE_Word *) value = dc25_opt_image_number; break; case DC25_OPT_THUMBS: *(SANE_Word *) value = dc25_opt_thumbnails; break; case DC25_OPT_SNAP: *(SANE_Word *) value = dc25_opt_snap; break; case DC25_OPT_LOWRES: *(SANE_Word *) value = dc25_opt_lowres; break; case DC25_OPT_CONTRAST: *(SANE_Word *) value = dc25_opt_contrast; break; case DC25_OPT_GAMMA: *(SANE_Word *) value = dc25_opt_gamma; break; case DC25_OPT_ERASE: *(SANE_Word *) value = dc25_opt_erase; break; case DC25_OPT_ERASE_ONE: *(SANE_Word *) value = dc25_opt_erase_one; break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_AUTO: switch (option) { #if 0 case DC25_OPT_CONTRAST: dc25_opt_contrast = SANE_FIX (DC25_OPT_CONTRAST_DEFAULT); break; case DC25_OPT_GAMMA: dc25_opt_gamma = SANE_FIX (DC25_OPT_GAMMA_DEFAULT); break; #endif default: return SANE_STATUS_UNSUPPORTED; /* We are DUMB */ } } if (info) *info = myinfo; return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { int rc = SANE_STATUS_GOOD; DBG (127, "sane_get_params called\n"); if (handle != MAGIC || !is_open) rc = SANE_STATUS_INVAL; /* Unknown handle ... */ *params = parms; return rc; } static unsigned char thumb_pck[] = THUMBS_PCK; static unsigned char pic_pck[] = PICS_PCK; static int bytes_in_buffer; static int bytes_read_from_buffer; static SANE_Byte buffer[1024]; static int total_bytes_read; static SANE_Bool started = SANE_FALSE; static int outbytes; SANE_Status sane_start (SANE_Handle handle) { int n, i; FILE *f; DBG (127, "sane_start called, handle=%lx\n", (u_long) handle); if (handle != MAGIC || !is_open || (dc25_opt_image_number == 0 && dc25_opt_snap == SANE_FALSE)) return SANE_STATUS_INVAL; /* Unknown handle ... */ if (started) { return SANE_STATUS_EOF; } if (dc25_opt_snap) { /* * Don't allow picture unless there is room in the * camera. */ if (CameraInfo.pic_left == 0) { DBG (3, "No room to store new picture\n"); return SANE_STATUS_INVAL; } /* * DC-20 can only change resolution when camer is empty. * DC-25 can do it any time. */ if (CameraInfo.model != 0x20 || CameraInfo.pic_taken == 0) { if (change_res (tfd, dc25_opt_lowres) == -1) { DBG (1, "Failed to set resolution\n"); return SANE_STATUS_INVAL; } } /* * Not sure why this delay is needed, but it seems to help: */ #ifdef HAVE_USLEEP usleep (10); #else sleep (1); #endif if (shoot (tfd) == -1) { DBG (1, "Failed to snap new picture\n"); return SANE_STATUS_INVAL; } else { info_flags |= SANE_INFO_RELOAD_OPTIONS; CameraInfo.pic_taken++; CameraInfo.pic_left--; dc25_opt_image_number = CameraInfo.pic_taken; if (image_range.min == 0) image_range.min = 1; image_range.max++; sod[DC25_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; } } if (dc25_opt_thumbnails) { /* * For thumbnails, we can do things right where we * start the download, and grab the first block * from the camera. The reamining blocks will be * fetched as necessary by sane_read(). */ thumb_pck[3] = (unsigned char) dc25_opt_image_number; if (send_pck (tfd, thumb_pck) == -1) { DBG (4, "sane_start: error: send_pck returned -1\n"); return SANE_STATUS_INVAL; } if (read_data (tfd, buffer, 1024) == -1) { DBG (4, "sane_start: read_data failed\n"); return SANE_STATUS_INVAL; } /* * DC20 thumbnail are 80x60 grayscale, DC25 * thumbnails are color. */ parms.format = (CameraInfo.model == 0x25) ? SANE_FRAME_RGB : SANE_FRAME_GRAY; parms.bytes_per_line = 80 * 3; /* 80 pixels, 3 colors */ parms.pixels_per_line = 80; parms.lines = 60; bytes_in_buffer = 1024; bytes_read_from_buffer = 0; } else { /* * We do something a little messy, and violates the SANE * philosophy. However, since it is fairly tricky to * convert the DC2x "comet" files on the fly, we read in * the entire data stream in sane_open(), and use convert_pic * to convert it to an in-memory pixpmap. Then when * sane_read() is called, we fill the requests from * memory. A good project for me (or some kind volunteer) * would be to rewrite this and move the actual download * to sane_read(). However, one argument for keeping it * this way is that the data comes down pretty fast, and * it helps to dedicate the processor to this task. We * might get serial port overruns if we try to do other * things at the same time. * * Also, as a side note, I was constantly getting serial * port overruns on a 90MHz pentium until I used hdparm * to set the "-u1" flag on the system drives. */ int fd; fd = open (tmpname, O_CREAT | O_EXCL | O_WRONLY, 0600); if (fd == -1) { DBG (0, "Unable to open tmp file\n"); return SANE_STATUS_INVAL; } f = fdopen (fd, "wb"); if (f == NULL) { DBG (0, "Unable to fdopen tmp file\n"); return SANE_STATUS_INVAL; } strcpy ((char *) buffer, COMET_MAGIC); fwrite (buffer, 1, COMET_HEADER_SIZE, f); pic_pck[3] = (unsigned char) dc25_opt_image_number; if (send_pck (tfd, pic_pck) == -1) { DBG (4, "sane_start: error: send_pck returned -1\n"); return SANE_STATUS_INVAL; } if (read_data (tfd, buffer, 1024) == -1) { DBG (5, "sane_start: read_data failed\n"); return SANE_STATUS_INVAL; } if (buffer[4] == 0) { /* hi-res image */ DBG (5, "sane_start: hi-res image\n"); n = 122; parms.bytes_per_line = 500 * 3; /* 3 colors */ parms.pixels_per_line = 500; parms.lines = 373; bytes_in_buffer = 1024; bytes_read_from_buffer = 0; } else { n = 61; DBG (5, "sane_start: low-res image\n"); parms.bytes_per_line = 320 * 3; /* 3 Colors */ parms.pixels_per_line = 320; parms.lines = 243; bytes_in_buffer = 1024; bytes_read_from_buffer = 0; } fwrite (buffer, 1, 1024, f); for (i = 1; i < n; i++) { if (read_data (tfd, buffer, 1024) == -1) { DBG (5, "sane_start: read_data failed\n"); return SANE_STATUS_INVAL; } fwrite (buffer, 1, 1024, f); } if (end_of_data (tfd) == -1) { fclose (f); DBG (4, "sane_open: end_of_data error\n"); return SANE_STATUS_INVAL; } else { fclose (f); if (convert_pic (tmpname, SAVE_ADJASPECT | SAVE_24BITS) == -1) { DBG (3, "sane_open: unable to convert\n"); return SANE_STATUS_INVAL; } unlink (tmpname); outbytes = 0; } } started = SANE_TRUE; total_bytes_read = 0; return SANE_STATUS_GOOD; } SANE_Status 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); if ( ! started ) { return SANE_STATUS_INVAL; } if (dc25_opt_thumbnails) { if (total_bytes_read == THUMBSIZE) { if (dc25_opt_erase || dc25_opt_erase_one) { if (erase (tfd) == -1) { DBG (1, "Failed to erase memory\n"); return SANE_STATUS_INVAL; } dc25_opt_erase = SANE_FALSE; dc25_opt_erase_one = SANE_FALSE; info_flags |= SANE_INFO_RELOAD_OPTIONS; if (get_info (tfd) == NULL) { DBG (2, "error: could not get info\n"); close_dc20 (tfd); return SANE_STATUS_INVAL; } DBG (10, "Call get_info!, image range=%d,%d\n", image_range.min, image_range.max); } return SANE_STATUS_EOF; } *length = 0; if (!(bytes_in_buffer - bytes_read_from_buffer)) { if (read_data (tfd, buffer, 1024) == -1) { DBG (5, "sane_read: read_data failed\n"); return SANE_STATUS_INVAL; } bytes_in_buffer = 1024; bytes_read_from_buffer = 0; } while (bytes_read_from_buffer < bytes_in_buffer && max_length && total_bytes_read < THUMBSIZE) { *data++ = buffer[bytes_read_from_buffer++]; (*length)++; max_length--; total_bytes_read++; } if (total_bytes_read == THUMBSIZE) { if (end_of_data (tfd) == -1) { DBG (4, "sane_read: end_of_data error\n"); return SANE_STATUS_INVAL; } else { return SANE_STATUS_GOOD; } } else { return SANE_STATUS_GOOD; } } else { int i; int filesize = parms.bytes_per_line * parms.lines; /* * If outbytes is zero, then this is the first time * we've been called, so update the contrast table. * The formula is something I came up with that has the * following prooperties: * 1) It's a smooth curve that provides the effect I wanted * (bright pixels are made brighter, dim pixels are made * dimmer) * 2) The contrast parameter can be adjusted to provide * different amounts of contrast. * 3) A parameter of 1.0 can be used to pass the data * through unchanged (but values around 1.75 look * a lot better */ if (outbytes == 0) { double d; double cont = SANE_UNFIX (dc25_opt_contrast); for (i = 0; i < 256; i++) { d = (i * 2.0) / 255 - 1.0; d = ((-pow (1 - d, cont)) + 1) * (d >= 0) + (((pow (d + 1, cont)) - 1)) * (d < 0); contrast_table[i] = (d * 127.5) + 127.5; /* fprintf (stderr,"%03d %03d\n",i,contrast_table[i]); */ } } /* We're done, so return EOF */ if (outbytes >= filesize) { free_pixmap (pp); pp = NULL; if (dc25_opt_erase || dc25_opt_erase_one) { if (erase (tfd) == -1) { DBG (1, "Failed to erase memory\n"); return SANE_STATUS_INVAL; } } if (get_info (tfd) == NULL) { DBG (2, "error: could not get info\n"); close_dc20 (tfd); return SANE_STATUS_INVAL; } DBG (10, "Call get_info!, image range=%d,%d\n", image_range.min, image_range.max); get_info (tfd); *length=0; return SANE_STATUS_EOF; } if (max_length > filesize - outbytes) { *length = filesize - outbytes; } else { *length = max_length; } memcpy (data, pp->planes + outbytes, *length); outbytes += *length; for (i = 0; i < *length; i++) { data[i] = contrast_table[data[i]]; } return SANE_STATUS_GOOD; } } void sane_cancel (SANE_Handle __sane_unused__ handle) { DBG (127, "sane_cancel() called\n"); started = SANE_FALSE; } SANE_Status 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) { if (non_blocking == SANE_FALSE) { return SANE_STATUS_GOOD; } else { return SANE_STATUS_UNSUPPORTED; } } else { /* We aren't currently scanning */ return SANE_STATUS_INVAL; } } SANE_Status sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/umax-uc840.c0000666000000000000000000001026513615534521014553 00000000000000/* ------------------------------------------------------------------------- */ /* umax-uc840.c: inquiry for UMAX scanner uc840 (C) 1997-2002 Oliver Rauch 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* ------------------------------------------------------------------------- */ #include "umax-scanner.h" /* ------------------------------------------------------------------------- */ static unsigned char UC840_INQUIRY[] = { #define UC840_INQUIRY_LEN 0x94 /* 24 F/W support function */ 0x00, /* ? */ /* 25 -27 exposure-times */ 0x00, 0x00, 0x00, /* 28 - 29 reserved */ 0x00, 0x00, /* 2a - 35 exposure times */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 36 - 37 reserved */ 0x00, 0x00, /* 38 - 5f scsi reserved */ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, /* 60 -62 scanner capability*/ 0xfd, 0x8c, /* 0xbc ? */ 0x03, /* 63 reserved */ 0x00, /* 64 gamma */ 0xa1, /* 65 reserved */ 0x00, /* 66 GIB */ 0x01, /* 67 reserved */ 0x00, /* 68 GOB */ 0x01, /* 69 - 6a halftone */ 0x88, 0x2f, /* 6b - 6c reserved */ 0x00, 0x00, /* 6d color sequence */ 0xe5, /* 6e - 71 video memory */ 0x00, 0x20, 0x00, 0x00, /* 72 reserved */ 0x00, /* 73 max optical res in 100 dpi */ 0x04, /* 74 max x_res in 100 dpi */ 0x04, /* 75 max y_res in 100 dpi */ 0x08, /* 76-77 fb max scan width in 0.01 inch */ 0x03, 0x52, /* 78-79 fb max scan length in 0.01 inch */ 0x05, 0x78, /* 7a-7b uta x original point, may be 0x05, 0x89 */ 0x00, 0x76, /* 7c-7d uta y original point, may be 0x06, 0x75 */ 0x00, 0x89, /* 7e-7f uta max scan width in 0.01 inch */ 0x02, 0x4e, /* 80-81 uta max scan length in 0.01 inch */ 0x03, 0x65, /* 82-85 reserved */ 00, 00, 00, 00, /* 86-87 dor x original point */ 0x00, 0x00, /* 88-89 dor x original point */ 0x00, 0x00, /* 8a-8b dor max scan width in 0.01 inch */ 0x00, 0x00, /* 8c-8d dor max scan length in 0.01 inch */ 0x00, 0x00, /* 8e reserved */ 0x00, /* 8f last calibration lamp density */ 0x00, /* 90 reserved */ 0x00, /* 91 lamp warmup max time */ 0x00, /* 92-93 window descriptor block length */ 0x00, 0x30, /* 94 optical resolution residue (1dpi) */ 0x00, /* 95 x_resolution residue (1dpi) */ 0x00, /* 96 y_resolution residue (1dpi) */ 0x00, /* 97 analog gamma table */ 0x00, /* 98-99 reserved */ 0x00, 0x00, /* 9a max calibration data lines */ 0x00 }; static inquiry_blk inquiry_uc840 = { "UC840 ", UC840_INQUIRY, UC840_INQUIRY_LEN }; sane-backends-1.0.29/backend/cardscan.conf.in0000666000000000000000000000105013615534521015616 00000000000000# For scanners connected via USB on a known device (kernel driver): #usb /dev/usb/scanner0 # For scanners connected via USB using vendor and device ids (libusb): #usb VENDORID PRODUCTID # NOTE: if you have to add your device here- please send the id and model # to the author via email, so it can be included in next version. kitno455 at # gmail dot com - with cardscan in the subject line # Corex Cardscan 800c usb 0x08f0 0x0005 # Sanford Cardscan 800c usb 0x0451 0x6250 # Corex Cardscan 600c has_cal_buffer 0 lines_per_block 1 usb 0x08f0 0x0002 sane-backends-1.0.29/backend/niash_core.c0000666000000000000000000010413513615534521015052 00000000000000/* Copyright (C) 2001 Bertrik Sikken (bertrik@zonnet.nl) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $Id$ */ /* Core NIASH chip functions. */ #include /* fopen, fread, fwrite, fclose etc */ #include /* va_list for vfprintf */ #include /* memcpy, memset */ #include /* unlink */ #include /* malloc, free */ #include /* exp, pow */ #include "niash_xfer.h" #include "niash_core.h" #ifndef MIN #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif #ifndef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif #define XFER_BUF_SIZE 0xF000 /* HP3400 firmware data */ static unsigned char abData0000[] = { 0xfe, 0x9f, 0x58, 0x1b, 0x00, 0x03, 0xa4, 0x02, 0x63, 0x02, 0x33, 0x02, 0x0d, 0x02, 0xf0, 0x01, 0xd8, 0x01, 0xc5, 0x01, 0xb5, 0x01, 0xa8, 0x01, 0x9d, 0x01, 0x93, 0x01, 0x8b, 0x01, 0x84, 0x01, 0x7e, 0x01, 0x79, 0x01, 0x74, 0x01, 0x70, 0x01, 0x6d, 0x01, 0x69, 0x01, 0x67, 0x01, 0x64, 0x01, 0x62, 0x01, 0x60, 0x01, 0x5f, 0x01, 0x5d, 0x01, 0x5c, 0x01, 0x5b, 0x01, 0x5a, 0x01, 0x59, 0x01, 0x58, 0x01, 0x57, 0x01, 0x57, 0x01, 0x56, 0x01, 0x56, 0x01, 0x55, 0x01, 0x55, 0x01, 0x54, 0x01, 0x54, 0x01, 0x54, 0x01, 0x54, 0x01, 0x53, 0x01, 0x53, 0x01, 0x53, 0x01, 0x53, 0x01, 0x52, 0x81 }; /* 1st word : 0x9ffe = 40958, strip 15th bit: 0x1ffe = 8190 2nd word : 0x1b58 = 7000 -> coincidence ? other words: formula: y = 676 / (2 - exp(0.113 * (1-x)) ), where x = 0 for first entry */ /* more HP3400 firmware data */ static unsigned char abData0400[] = { 0xa4, 0x82, 0x00, 0x80, 0xa4, 0x82, 0xaa, 0x02, 0xc0, 0x02, 0xe8, 0x02, 0x3e, 0x03, 0xc8, 0x03, 0x58, 0x1b, 0xfe, 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static void _ConvertMotorTable (unsigned char *pabOld, unsigned char *pabNew, int iSize, int iLpi) { int iData, i, iBit15; for (i = 0; i < (iSize / 2); i++) { iData = pabOld[2 * i + 0] + (pabOld[2 * i + 1] << 8); iBit15 = (iData & 0x8000); iData = (iData & 0x7FFF); if (iData <= 0x400) { iData = iData * iLpi / 300; } if (iBit15 != 0) { iData |= 0x8000; } pabNew[2 * i + 0] = iData & 255; pabNew[2 * i + 1] = (iData >> 8) & 255; } } /************************************************************************* _ProbeRegisters =============== Tries to determine certain hardware properties. This is done by checking the writeability of some scanner registers. We cannot rely simply on the scanner model to contain a specific chip. The HP3300c for example uses one of at least three slightly different scanner ASICs (NIASH00012, NIASH00013 and NIASH00014). OUT pHWParams Hardware parameters, updated fields: fGamma16 TRUE if 16 bit gamma tables can be used fReg07 TRUE if reg07 is writeable iBufferSize Size of scanner's internal buffer Returns TRUE if a NIASH chipset was found. *************************************************************************/ static SANE_Bool _ProbeRegisters (THWParams * pHWParams) { unsigned char bData1, bData2; int iHandle; iHandle = pHWParams->iXferHandle; DBG (DBG_MSG, "Probing scanner...\n"); /* check register 0x04 */ NiashWriteReg (iHandle, 0x04, 0x55); NiashReadReg (iHandle, 0x04, &bData1); NiashWriteReg (iHandle, 0x04, 0xAA); NiashReadReg (iHandle, 0x04, &bData2); NiashWriteReg (iHandle, 0x04, 0x07); if ((bData1 != 0x55) || (bData2 != 0xAA)) { DBG (DBG_ERR, " No NIASH chipset found!\n"); return SANE_FALSE; } /* check writeability of register 3 bit 1 */ NiashReadReg (iHandle, 0x03, &bData1); NiashWriteReg (iHandle, 0x03, bData1 | 0x02); NiashReadReg (iHandle, 0x03, &bData2); NiashWriteReg (iHandle, 0x03, bData1); pHWParams->fGamma16 = ((bData2 & 0x02) != 0); DBG (DBG_MSG, " Gamma table entries are %d bit\n", pHWParams->fGamma16 ? 16 : 8); /* check register 0x07 */ NiashReadReg (iHandle, 0x07, &bData1); NiashWriteReg (iHandle, 0x07, 0x1C); NiashReadReg (iHandle, 0x07, &bData2); NiashWriteReg (iHandle, 0x07, bData1); pHWParams->fReg07 = (bData2 == 0x1C); if (!pHWParams->fGamma16) { /* internal scan buffer size is an educated guess, but seems to correlate well with the size calculated from several windows driver log files size = 128kB - 44088 unsigned chars (space required for gamma/calibration table) */ pHWParams->iBufferSize = 86984L; DBG (DBG_MSG, " NIASH version < 00014\n"); } else { pHWParams->iBufferSize = 0x60000L; if (!pHWParams->fReg07) { DBG (DBG_MSG, " NIASH version = 00014\n"); } else { DBG (DBG_MSG, " NIASH version > 00014\n"); } } return SANE_TRUE; } /* returns 0 on success, < 0 otherwise */ STATIC int NiashOpen (THWParams * pHWParams, const char *pszName) { int iXferHandle; iXferHandle = NiashXferOpen (pszName, &pHWParams->eModel); if (iXferHandle < 0) { DBG (DBG_ERR, "NiashXferOpen failed for '%s'\n", pszName); return -1; } pHWParams->iXferHandle = iXferHandle; NiashWakeup (pHWParams->iXferHandle); /* default HW params */ pHWParams->iSensorSkew = 8; pHWParams->iTopLeftX = 0; pHWParams->iTopLeftY = 3; pHWParams->fReg07 = SANE_FALSE; pHWParams->iSkipLines = 0; pHWParams->iExpTime = 5408; pHWParams->iReversedHead = SANE_TRUE; switch (pHWParams->eModel) { case eHp3300c: DBG (DBG_MSG, "Setting params for Hp3300\n"); pHWParams->iTopLeftX = 4; pHWParams->iTopLeftY = 11; pHWParams->iSkipLines = 14; break; case eHp3400c: case eHp4300c: DBG (DBG_MSG, "Setting params for Hp3400c/Hp4300c\n"); pHWParams->iTopLeftX = 3; pHWParams->iTopLeftY = 14; pHWParams->fReg07 = SANE_TRUE; break; case eAgfaTouch: DBG (DBG_MSG, "Setting params for AgfaTouch\n"); pHWParams->iReversedHead = SANE_FALSE; /* head not reversed on Agfa Touch */ pHWParams->iTopLeftX = 3; pHWParams->iTopLeftY = 10; pHWParams->iSkipLines = 7; break; case eUnknownModel: DBG (DBG_MSG, "Setting params for UnknownModel\n"); break; default: DBG (DBG_ERR, "ERROR: internal error! (%d)\n", (int) pHWParams->eModel); return -1; } /* autodetect some hardware properties */ if (!_ProbeRegisters (pHWParams)) { DBG (DBG_ERR, "_ProbeRegisters failed!\n"); return -1; } return 0; } STATIC void NiashClose (THWParams * pHWPar) { NiashXferClose (pHWPar->iXferHandle); pHWPar->iXferHandle = 0; } static void WriteRegWord (int iHandle, unsigned char bReg, SANE_Word wData) { NiashWriteReg (iHandle, bReg, wData & 0xFF); NiashWriteReg (iHandle, bReg + 1, (wData >> 8) & 0xFF); } /* calculate a 4096 unsigned char gamma table */ STATIC void CalcGamma (unsigned char *pabTable, double Gamma) { int i, iData; /* fill gamma table */ for (i = 0; i < 4096; i++) { iData = floor (256.0 * pow (((double) i / 4096.0), 1.0 / Gamma)); pabTable[i] = iData; } } /* Hp3400WriteFw ============= Writes data to scanners with a NIASH00019 chipset, e.g. gamma, calibration and motor control data. IN pabData pointer to firmware data iLen Size of firmware date (unsigned chars) iAddr Scanner address to write to */ static void Hp3400cWriteFW (int iXferHandle, unsigned char *pabData, int iLen, int iAddr) { iAddr--; NiashWriteReg (iXferHandle, 0x21, iAddr & 0xFF); NiashWriteReg (iXferHandle, 0x22, (iAddr >> 8) & 0xFF); NiashWriteReg (iXferHandle, 0x23, (iAddr >> 16) & 0xFF); NiashWriteBulk (iXferHandle, pabData, iLen); } /* Writes the gamma and offset/gain tables to the scanner. In case a calibration file exist, it will be used for offset/gain */ STATIC void WriteGammaCalibTable (unsigned char *pabGammaR, unsigned char *pabGammaG, unsigned char *pabGammaB, unsigned char *pabCalibTable, int iGain, int iOffset, THWParams * pHWPar) { int i, j, k; static unsigned char abGamma[60000]; int iData; int iHandle; iHandle = pHWPar->iXferHandle; j = 0; /* fill gamma table for red component */ /* pad entries with 0 for 16-bit gamma table */ for (i = 0; i < 4096; i++) { if (pHWPar->fGamma16) { abGamma[j++] = 0; } abGamma[j++] = pabGammaR[i]; } /* fill gamma table for green component */ for (i = 0; i < 4096; i++) { if (pHWPar->fGamma16) { abGamma[j++] = 0; } abGamma[j++] = pabGammaG[i]; } /* fill gamma table for blue component */ for (i = 0; i < 4096; i++) { if (pHWPar->fGamma16) { abGamma[j++] = 0; } abGamma[j++] = pabGammaB[i]; } if (pabCalibTable == NULL) { iData = (iGain << 6) + iOffset; for (i = 0; i < HW_PIXELS; i++) { for (k = 0; k < 3; k++) { abGamma[j++] = (iData) & 255; abGamma[j++] = (iData >> 8) & 255; } } } else { memcpy (&abGamma[j], pabCalibTable, HW_PIXELS * 6); j += HW_PIXELS * 6; } NiashWriteReg (iHandle, 0x02, 0x80); NiashWriteReg (iHandle, 0x03, 0x01); NiashWriteReg (iHandle, 0x03, 0x11); NiashWriteReg (iHandle, 0x02, 0x84); if (pHWPar->fReg07) { Hp3400cWriteFW (iHandle, abGamma, j, 0x2000); } else { NiashWriteBulk (iHandle, abGamma, j); } NiashWriteReg (iHandle, 0x02, 0x80); } static void WriteAFEReg (int iHandle, int iReg, int iData) { NiashWriteReg (iHandle, 0x25, iReg); NiashWriteReg (iHandle, 0x26, iData); } /* setup the analog front-end -> coarse calibration */ static void WriteAFE (int iHandle) { /* see WM8143 datasheet */ WriteAFEReg (iHandle, 0x04, 0x00); WriteAFEReg (iHandle, 0x03, 0x12); WriteAFEReg (iHandle, 0x02, 0x04); WriteAFEReg (iHandle, 0x05, 0x10); WriteAFEReg (iHandle, 0x01, 0x03); WriteAFEReg (iHandle, 0x20, 0xc0); /*c8 *//* red offset */ WriteAFEReg (iHandle, 0x21, 0xc0); /*c8 *//* green offset */ WriteAFEReg (iHandle, 0x22, 0xc0); /*d0 *//* blue offset */ WriteAFEReg (iHandle, 0x28, 0x05); /*5 *//* red gain */ WriteAFEReg (iHandle, 0x29, 0x03); /*3 *//* green gain */ WriteAFEReg (iHandle, 0x2A, 0x04); /*4 *//* blue gain */ } /* wait for the carriage to return */ static void WaitReadyBit (int iHandle) { unsigned char bData; do { NiashReadReg (iHandle, 0x03, &bData); } while ((bData & 8) == 0); } /* Initialisation specific for NIASH00014 and lower chips */ static void InitNiash00014 (TScanParams * pParams, THWParams * pHWParams) { int iHandle, iLpiCode; iHandle = pHWParams->iXferHandle; /* exposure time (in units 24/Fcrystal)? */ WriteRegWord (iHandle, 0x08, pHWParams->iExpTime - 1); /* width in pixels */ WriteRegWord (iHandle, 0x12, pParams->iWidth - 1); /* top */ WriteRegWord (iHandle, 0x17, pParams->iTop); WriteRegWord (iHandle, 0x19, pParams->iTop); /* time between stepper motor steps (in units of 24/Fcrystal)? */ iLpiCode = pParams->iLpi * pHWParams->iExpTime / 1200L; if (!pHWParams->fGamma16) { /* NIASH 00012 / 00013 init */ /* LPI specific settings */ if (pParams->iLpi < 600) { /* set halfres bit */ NiashWriteReg (iHandle, 0x06, 0x01); /* double lpi code because of halfres bit */ iLpiCode *= 2; } else { /* clear halfres bit */ NiashWriteReg (iHandle, 0x06, 0x00); /* add exptime to make it scan slower */ iLpiCode += pHWParams->iExpTime; } /* unknown setting */ WriteRegWord (iHandle, 0x27, 0x7FD2); WriteRegWord (iHandle, 0x29, 0x6421); } else { /* NIASH 00014 init */ /* halfres bit always cleared */ NiashWriteReg (iHandle, 0x06, 0x00); /* LPI specific settings */ if (pParams->iLpi >= 600) { /* add exptime to make it scan slower */ iLpiCode += pHWParams->iExpTime; } /* unknown setting */ WriteRegWord (iHandle, 0x27, 0xc862); /*c862 */ WriteRegWord (iHandle, 0x29, 0xb853); /*b853 */ } /* LPI code */ WriteRegWord (iHandle, 0x0A, iLpiCode - 1); /* backtrack reversing speed */ NiashWriteReg (iHandle, 0x1E, (iLpiCode - 1) / 32); } /* Initialisation specific for NIASH00019 chips */ static void InitNiash00019 (TScanParams * pParams, THWParams * pHWParams) { int iHandle, iLpiCode; static unsigned char abMotor[512]; iHandle = pHWParams->iXferHandle; /* exposure time (in units 24/Fcrystal)? */ WriteRegWord (iHandle, 0x08, pHWParams->iExpTime); /* width in pixels */ WriteRegWord (iHandle, 0x12, pParams->iWidth); /* ? */ WriteRegWord (iHandle, 0x27, 0xc862); /*c862 */ WriteRegWord (iHandle, 0x29, 0xb853); /*b853 */ /* specific handling of 150 dpi resolution */ if (pParams->iLpi == 150) { /* use 300 LPI but skip every other line */ pParams->iLpi = 300; NiashWriteReg (iHandle, 0x06, 0x01); } else { NiashWriteReg (iHandle, 0x06, 0x00); } /* DPI and position table */ NiashWriteReg (iHandle, 0x07, 0x02); _ConvertMotorTable (abData0000, abMotor, sizeof (abData0000), pParams->iLpi); Hp3400cWriteFW (iHandle, abMotor, sizeof (abData0000), 0x000); _ConvertMotorTable (abData0400, abMotor, sizeof (abData0400), pParams->iLpi); Hp3400cWriteFW (iHandle, abMotor, sizeof (abData0400), 0x400); /* backtrack reversing speed */ iLpiCode = pParams->iLpi * pHWParams->iExpTime / 1200L; NiashWriteReg (iHandle, 0x1E, (iLpiCode - 1) / 32); } /* Scanner initialisation common to all NIASH chips */ static void InitNiashCommon (TScanParams * pParams, THWParams * pHWParams) { int iWidthHW, iHandle, iMaxLevel; iHandle = pHWParams->iXferHandle; NiashWriteReg (iHandle, 0x02, 0x80); NiashWriteReg (iHandle, 0x03, 0x11); NiashWriteReg (iHandle, 0x01, 0x8B); NiashWriteReg (iHandle, 0x05, 0x01); /* dpi */ WriteRegWord (iHandle, 0x0C, pParams->iDpi); /* calculate width in units of HW resolution */ iWidthHW = pParams->iWidth * (HW_DPI / pParams->iDpi); /* set left and right limits */ if (pHWParams->iReversedHead) { /* head is reversed */ /* right */ WriteRegWord (iHandle, 0x0E, 3 * (HW_PIXELS - (pParams->iLeft + iWidthHW))); /* left */ WriteRegWord (iHandle, 0x10, 3 * (HW_PIXELS - pParams->iLeft) - 1); } else { /* head is not reversed */ /*left */ WriteRegWord (iHandle, 0x0E, 3 * pParams->iLeft); /* right */ WriteRegWord (iHandle, 0x10, 3 * (pParams->iLeft + iWidthHW) - 1); } /* bottom */ WriteRegWord (iHandle, 0x1B, pParams->iBottom); /* 0x393C); */ /* forward jogging speed */ NiashWriteReg (iHandle, 0x1D, 0x60); /* backtrack reversing speed? */ NiashWriteReg (iHandle, 0x2B, 0x15); /* backtrack distance */ if (pParams->iLpi < 600) { NiashWriteReg (iHandle, 0x1F, 0x30); } else { NiashWriteReg (iHandle, 0x1F, 0x18); } /* max buffer level before backtrace */ iMaxLevel = MIN (pHWParams->iBufferSize / pParams->iWidth, 250); NiashWriteReg (iHandle, 0x14, iMaxLevel - 1); /* lamp PWM, max = 0x1ff? */ WriteRegWord (iHandle, 0x2C, 0x01FF); /* not needed? */ NiashWriteReg (iHandle, 0x15, 0x90); /* 90 */ NiashWriteReg (iHandle, 0x16, 0x70); /* 70 */ WriteAFE (iHandle); WaitReadyBit (iHandle); NiashWriteReg (iHandle, 0x03, 0x05); NiashWriteReg (iHandle, 0x02, pParams->fCalib ? 0x88 : 0xA8); } /* write registers */ STATIC SANE_Bool InitScan (TScanParams * pParams, THWParams * pHWParams) { int iHeight; int iExpTime; TScanParams Params; /* check validity of scanparameters */ switch (pParams->iDpi) { case 150: case 300: case 600: break; default: DBG (DBG_ERR, "Invalid dpi (%d)\n", pParams->iDpi); return SANE_FALSE; } iHeight = (pParams->iBottom - pParams->iTop + 1); if (iHeight <= 0) { DBG (DBG_ERR, "Invalid height (%d)\n", iHeight); return SANE_FALSE; } if (pParams->iWidth <= 0) { DBG (DBG_ERR, "Invalid width (%d)\n", pParams->iWidth); return SANE_FALSE; } switch (pParams->iLpi) { case 150: case 300: case 600: break; default: DBG (DBG_ERR, "Invalid lpi (%d)\n", pParams->iLpi); return SANE_FALSE; } /* exposure time (in units of 24/Fcrystal?), must be divisible by 8 !!! */ iExpTime = 5408; if ((iExpTime % 8) != 0) { DBG (DBG_ERR, "Invalid exposure time (%d)\n", iExpTime); return SANE_FALSE; } /* *** Done checking scan parameters validity *** */ /* copy the parameters locally and make pParams point to the local copy */ memcpy (&Params, pParams, sizeof (Params)); pParams = &Params; if (!pHWParams->fReg07) { /* init NIASH00014 and lower */ InitNiash00014 (pParams, pHWParams); } else { /* init NIASH00019 */ InitNiash00019 (pParams, pHWParams); } /* common NIASH init */ InitNiashCommon (pParams, pHWParams); return SANE_TRUE; } /************************************************************************/ static SANE_Bool XferBufferGetLine (int iHandle, TDataPipe * p, unsigned char *pabLine, SANE_Bool fReturn) { unsigned char bData, bData2; SANE_Bool fJustDone = SANE_FALSE; /* all calculated transfers done ? */ if (p->iLinesLeft == 0) return SANE_FALSE; /* time for a fresh read? */ if (p->iCurLine == 0) { int iLines; iLines = p->iLinesPerXferBuf; /* read only as many lines as needed */ if (p->iLinesLeft > 0 && p->iLinesLeft <= iLines) { iLines = p->iLinesLeft; DBG (DBG_MSG, "\n"); DBG (DBG_MSG, "last bulk read\n"); if (iLines < p->iLinesPerXferBuf) { DBG (DBG_MSG, "reading reduced number of lines: %d instead of %d\n", iLines, p->iLinesPerXferBuf); } fJustDone = SANE_TRUE; } /* reading old buffer level */ NiashReadReg (iHandle, 0x20, &bData); NiashReadBulk (iHandle, p->pabXferBuf, iLines * p->iBytesPerLine); /* reding new buffer level */ NiashReadReg (iHandle, 0x20, &bData2); if (fJustDone && fReturn) { NiashWriteReg (iHandle, 0x02, 0x80); DBG (DBG_MSG, "returning scanner head\n"); } DBG (DBG_MSG, "buffer level = %3d, , buffer level = %3d\r", (int) bData, iLines * p->iBytesPerLine, (int) bData2); fflush (stdout); } /* copy one line */ if (pabLine != NULL) { memcpy (pabLine, &p->pabXferBuf[p->iCurLine * p->iBytesPerLine], p->iBytesPerLine); } /* advance pointer */ p->iCurLine = (p->iCurLine + 1) % p->iLinesPerXferBuf; /* one transfer line less to the XFerBuffer */ if (p->iLinesLeft > 0) --(p->iLinesLeft); return SANE_TRUE; } static void XferBufferInit (int iHandle, TDataPipe * p) { int i; p->pabXferBuf = (unsigned char *) malloc (XFER_BUF_SIZE); p->iCurLine = 0; /* skip garbage lines */ for (i = 0; i < p->iSkipLines; i++) { XferBufferGetLine (iHandle, p, NULL, SANE_FALSE); } } /* static procedure that fills the circular buffer in advance to any circular buffer data retrieval */ static void CircBufferFill (int iHandle, TDataPipe * p, SANE_Bool iReversedHead) { int i; for (i = 0; i < p->iLinesPerCircBuf; i++) { if (iReversedHead) { XferBufferGetLine (iHandle, p, &p->pabCircBuf[p->iRedLine * p->iBytesPerLine], SANE_FALSE); } else { XferBufferGetLine (iHandle, p, &p->pabCircBuf[p->iBluLine * p->iBytesPerLine], SANE_FALSE); } /* advance pointers */ p->iRedLine = (p->iRedLine + 1) % p->iLinesPerCircBuf; p->iGrnLine = (p->iGrnLine + 1) % p->iLinesPerCircBuf; p->iBluLine = (p->iBluLine + 1) % p->iLinesPerCircBuf; } } static void XferBufferExit (TDataPipe * p) { if (p->pabXferBuf != NULL) { free (p->pabXferBuf); p->pabXferBuf = NULL; } else { DBG (DBG_ERR, "XferBufExit: Xfer buffer not initialised!\n"); } } /* unscrambles a line: - combining the proper R, G and B lines and converting them to interpixel RGB - mirroring left to right */ static void _UnscrambleLine (unsigned char *pabLine, unsigned char *pabRed, unsigned char *pabGrn, unsigned char *pabBlu, int iWidth, SANE_Bool iReversedHead, int iScaleDownDpi, int iBufWeight) { /* never change an approved algorithm ... so take Bertriks original source for this special case */ if (iScaleDownDpi == 1 && iBufWeight == 0) { int i, j; if (iReversedHead) { /* reversed */ for (i = 0; i < iWidth; i++) { j = (iWidth - i) * 3; pabLine[j - 3] = pabRed[i]; pabLine[j - 2] = pabGrn[i + iWidth]; pabLine[j - 1] = pabBlu[i + iWidth * 2]; } } else { /* not reversed */ for (i = 0; i < iWidth; i++) { pabLine[3 * i] = pabRed[i]; pabLine[3 * i + 1] = pabGrn[i + iWidth]; pabLine[3 * i + 2] = pabBlu[i + iWidth * 2]; } } } else { int i, j; /* loop variables */ int c; /* color buffer accumulator for horizontal avarage */ /* initialize for incremental color buffer access */ int iInc = 1; int iStart = 0; /* set for "from the end to the front" of the circular color buffers */ if (iReversedHead) { iStart = iWidth - iScaleDownDpi; iInc = -1; } /* each pixel is the mean of iScaleDownDpi so set the skip width accordingly */ iInc *= iScaleDownDpi; for (i = iStart; i >= 0 && i < iWidth; i += iInc) { /* collect the red pixels */ for (c = j = 0; j < iScaleDownDpi; ++j) c += pabRed[i + j]; *pabLine = (*pabLine * iBufWeight + c / iScaleDownDpi) / (iBufWeight + 1); pabLine++; /* collect the green pixels */ for (c = j = 0; j < iScaleDownDpi; ++j) c += pabGrn[i + iWidth + j]; *pabLine = (*pabLine * iBufWeight + c / iScaleDownDpi) / (iBufWeight + 1); pabLine++; /* collect the blue pixels */ for (c = j = 0; j < iScaleDownDpi; ++j) c += pabBlu[i + 2 * iWidth + j]; *pabLine = (*pabLine * iBufWeight + c / iScaleDownDpi) / (iBufWeight + 1); pabLine++; } } } /* gets an unscrambled line from the circular buffer. the first couple of lines contain garbage, if fReturn==SANE_TRUE, the head will return automatically on an end of scan */ STATIC SANE_Bool CircBufferGetLineEx (int iHandle, TDataPipe * p, unsigned char *pabLine, SANE_Bool iReversedHead, SANE_Bool fReturn) { int iLineCount; for (iLineCount = 0; iLineCount < p->iScaleDownLpi; ++iLineCount) { if (iReversedHead) { if (!XferBufferGetLine (iHandle, p, &p->pabCircBuf[p->iRedLine * p->iBytesPerLine], fReturn)) return SANE_FALSE; } else { if (!XferBufferGetLine (iHandle, p, &p->pabCircBuf[p->iBluLine * p->iBytesPerLine], fReturn)) return SANE_FALSE; } if (pabLine != NULL) { _UnscrambleLine (pabLine, &p->pabCircBuf[p->iRedLine * p->iBytesPerLine], &p->pabCircBuf[p->iGrnLine * p->iBytesPerLine], &p->pabCircBuf[p->iBluLine * p->iBytesPerLine], p->iWidth * p->iScaleDownDpi, iReversedHead, p->iScaleDownDpi, iLineCount); } /* advance pointers */ p->iRedLine = (p->iRedLine + 1) % p->iLinesPerCircBuf; p->iGrnLine = (p->iGrnLine + 1) % p->iLinesPerCircBuf; p->iBluLine = (p->iBluLine + 1) % p->iLinesPerCircBuf; } return SANE_TRUE; } /* gets an unscrambled line from the circular buffer. the first couple of lines contain garbage */ STATIC SANE_Bool CircBufferGetLine (int iHandle, TDataPipe * p, unsigned char *pabLine, SANE_Bool iReversedHead) { return CircBufferGetLineEx (iHandle, p, pabLine, iReversedHead, SANE_FALSE); } /* try to keep the number of transfers the same, but make them all as good as possible the same size to avoid cranking in critical situations */ static int _OptimizeXferSize (int iLines, int iLinesPerXfer) { int iXfers; iXfers = (iLines + iLinesPerXfer - 1) / iLinesPerXfer; while (--iLinesPerXfer > 0 && (iLines + iLinesPerXfer - 1) / iLinesPerXfer == iXfers); return iLinesPerXfer + 1; } STATIC void CircBufferInit (int iHandle, TDataPipe * p, int iWidth, int iHeight, int iMisAlignment, SANE_Bool iReversedHead, int iScaleDownDpi, int iScaleDownLpi) { /* relevant for internal read and write functions */ p->iScaleDownLpi = iScaleDownLpi; p->iScaleDownDpi = iScaleDownDpi; p->iWidth = iWidth; p->iBytesPerLine = iWidth * iScaleDownDpi * BYTES_PER_PIXEL; p->iSaneBytesPerLine = iWidth * BYTES_PER_PIXEL; if (iMisAlignment == 0) { p->iLinesPerCircBuf = 1; } else { p->iLinesPerCircBuf = 3 * iMisAlignment; } DBG (DBG_MSG, "_iScaleDown (Dpi,Lpi) = (%d,%d)\n", p->iScaleDownDpi, p->iScaleDownLpi); DBG (DBG_MSG, "_iBytesPerLine = %d\n", p->iBytesPerLine); DBG (DBG_MSG, "_iLinesPerCircBuf = %d\n", p->iLinesPerCircBuf); p->pabCircBuf = (unsigned char *) malloc (p->iBytesPerLine * p->iLinesPerCircBuf); if (p->pabCircBuf == NULL) { DBG (DBG_ERR, "Unable to allocate %d unsigned chars for circular buffer\n", (int) (p->iBytesPerLine * p->iLinesPerCircBuf)); return; } DBG (DBG_MSG, "Allocated %d unsigned chars for circular buffer\n", p->iBytesPerLine * p->iLinesPerCircBuf); if (iReversedHead) { p->iBluLine = 0; p->iGrnLine = iMisAlignment; p->iRedLine = iMisAlignment * 2; } else { p->iRedLine = 0; p->iGrnLine = iMisAlignment; p->iBluLine = iMisAlignment * 2; } /* negative height is an indication for "no Check" */ if (iHeight < 0) { p->iLinesLeft = -1; p->iLinesPerXferBuf = XFER_BUF_SIZE / p->iBytesPerLine; DBG (DBG_MSG, "using unchecked XFER_BUF_SIZE\n"); DBG (DBG_MSG, "_iXFerSize = %d\n", p->iBytesPerLine * p->iLinesPerXferBuf); } else { #define SAFETY_LINES 0 #define MAX_LINES_PER_XFERBUF 800 /* estimate of number of unsigned chars to transfer at all via the USB */ /* add some lines for securtiy */ p->iLinesLeft = iHeight + p->iSkipLines + p->iLinesPerCircBuf + SAFETY_LINES; p->iLinesPerXferBuf = XFER_BUF_SIZE / p->iBytesPerLine; /* with more than 800 lines the timing is spoiled */ if (p->iLinesPerXferBuf > MAX_LINES_PER_XFERBUF) { p->iLinesPerXferBuf = MAX_LINES_PER_XFERBUF; } /* final optimization to keep critical scans smooth */ p->iLinesPerXferBuf = _OptimizeXferSize (p->iLinesLeft, p->iLinesPerXferBuf); DBG (DBG_MSG, "_iXFerSize = %d for %d transfer(s)\n", (int) p->iLinesPerXferBuf * p->iBytesPerLine, (p->iLinesLeft + p->iLinesPerXferBuf - 1) / p->iLinesPerXferBuf); } DBG (DBG_MSG, "_iLinesPerXferBuf = %d\n", p->iLinesPerXferBuf); /* init transfer buffer */ XferBufferInit (iHandle, p); /* fill circular buffer */ CircBufferFill (iHandle, p, iReversedHead); } STATIC void CircBufferExit (TDataPipe * p) { XferBufferExit (p); if (p->pabCircBuf != NULL) { DBG (DBG_MSG, "\n"); free (p->pabCircBuf); p->pabCircBuf = NULL; } else { DBG (DBG_ERR, "CircBufferExit: Circular buffer not initialised!\n"); } } /************************************************************************/ static int _CalcAvg (unsigned char *pabBuf, int n, int iStep) { int i, j, x; for (i = j = x = 0; i < n; i++) { x += pabBuf[j]; j += iStep; } return (x / n); } /* converts white line data and black point data into a calibration table */ static void CreateCalibTable (unsigned char *abWhite, unsigned char bBlackR, unsigned char bBlackG, unsigned char bBlackB, int iReversedHead, unsigned char *pabCalibTable) { int i, j, iGain, iOffset, iData; unsigned char *pabPixel; j = 0; for (i = 0; i < HW_PIXELS; i++) { if (iReversedHead) { pabPixel = &abWhite[(HW_PIXELS - i - 1) * 3]; } else { pabPixel = &abWhite[i * 3]; } /* red */ if (bBlackR > 16) bBlackR = 16; iGain = 65536 / MAX (1, pabPixel[0] - bBlackR); iOffset = bBlackR * 4; if (iOffset > 63) iOffset = 63; iData = (iGain << 6) + iOffset; pabCalibTable[j++] = (iData) & 255; pabCalibTable[j++] = (iData >> 8) & 255; /* green */ if (bBlackG > 16) bBlackG = 16; iGain = 65536 / MAX (1, pabPixel[1] - bBlackG); iOffset = bBlackG * 4; if (iOffset > 63) iOffset = 63; iData = (iGain << 6) + iOffset; pabCalibTable[j++] = (iData) & 255; pabCalibTable[j++] = (iData >> 8) & 255; /* blue */ if (bBlackB > 16) bBlackB = 16; iGain = 65536 / MAX (1, pabPixel[2] - bBlackB); iOffset = bBlackB * 4; if (iOffset > 63) iOffset = 63; iData = (iGain << 6) + iOffset; pabCalibTable[j++] = (iData) & 255; pabCalibTable[j++] = (iData >> 8) & 255; } } /************************************************************************* Lamp control functions *************************************************************************/ STATIC SANE_Bool GetLamp (THWParams * pHWParams, SANE_Bool * pfLampIsOn) { unsigned char bData; NiashReadReg (pHWParams->iXferHandle, 0x03, &bData); *pfLampIsOn = ((bData & 0x01) != 0); return SANE_TRUE; } STATIC SANE_Bool SetLamp (THWParams * pHWParams, SANE_Bool fLampOn) { unsigned char bData; int iHandle; iHandle = pHWParams->iXferHandle; NiashReadReg (iHandle, 0x03, &bData); if (fLampOn) { NiashWriteReg (iHandle, 0x03, bData | 0x01); } else { NiashWriteReg (iHandle, 0x03, bData & ~0x01); } return SANE_TRUE; } /************************************************************************* Experimental simple calibration, but also returning the white levels *************************************************************************/ STATIC SANE_Bool SimpleCalibExt (THWParams * pHWPar, unsigned char *pabCalibTable, unsigned char *pabCalWhite) { unsigned char bMinR, bMinG, bMinB; TDataPipe DataPipe; TScanParams Params; unsigned char abGamma[4096]; int i, j; static unsigned char abBuf[HW_PIXELS * 3 * 71]; /* Carefull : see startWhite and endWhite below */ static unsigned char abLine[HW_PIXELS * 3]; static unsigned char abWhite[HW_PIXELS * 3]; unsigned char *pabWhite; int iWhiteR, iWhiteG, iWhiteB; int iHandle; SANE_Bool iReversedHead; int startWhiteY, endWhiteY; int startBlackY, endBlackY; int endBlackX; iHandle = pHWPar->iXferHandle; iReversedHead = pHWPar->iReversedHead; DataPipe.iSkipLines = pHWPar->iSkipLines; Params.iDpi = HW_DPI; Params.iLpi = HW_DPI; if (iReversedHead) /* hp scanners */ Params.iTop = 60; else /* agfa scanners */ Params.iTop = 30; Params.iBottom = HP3300C_BOTTOM; Params.iLeft = 0; Params.iWidth = HW_PIXELS; Params.iHeight = 54; Params.fCalib = SANE_TRUE; /* write gamma table with neutral gain / offset */ CalcGamma (abGamma, 1.0); WriteGammaCalibTable (abGamma, abGamma, abGamma, NULL, 256, 0, pHWPar); if (!InitScan (&Params, pHWPar)) { if (pabCalWhite) pabCalWhite[0] = pabCalWhite[1] = pabCalWhite[2] = 0; return SANE_FALSE; } /* Definition of white and black areas */ if (iReversedHead) { /* hp scanners */ startWhiteY = 0; endWhiteY = 15; startBlackY = 16; endBlackY = 135; endBlackX = HW_PIXELS; } else { /* agfa scanners */ startWhiteY = 0; endWhiteY = 70; startBlackY = 86; endBlackY = 135; endBlackX = 3374; } CircBufferInit (iHandle, &DataPipe, HW_PIXELS, -1, Params.iLpi / 150, iReversedHead, 1, 1); /* white level */ /* skip some lines */ for (i = 0; i < startWhiteY; i++) { CircBufferGetLine (iHandle, &DataPipe, abLine, iReversedHead); } /* Get white lines */ for (i = 0; i < endWhiteY - startWhiteY + 1; i++) { CircBufferGetLine (iHandle, &DataPipe, &abBuf[i * HW_PIXELS * 3], iReversedHead); } /* black level */ bMinR = 255; bMinG = 255; bMinB = 255; /* Skip some lines */ for (i = 0; i < startBlackY; i++) { CircBufferGetLine (iHandle, &DataPipe, abLine, iReversedHead); } for (i = 0; i < endBlackY - startBlackY + 1; i++) { CircBufferGetLine (iHandle, &DataPipe, abLine, iReversedHead); for (j = 0; j < endBlackX; j++) { bMinR = MIN (abLine[j * 3 + 0], bMinR); bMinG = MIN (abLine[j * 3 + 1], bMinG); bMinB = MIN (abLine[j * 3 + 2], bMinB); } } CircBufferExit (&DataPipe); FinishScan (pHWPar); /* calc average white level */ pabWhite = abBuf; for (i = 0; i < HW_PIXELS; i++) { abWhite[i * 3 + 0] = _CalcAvg (&pabWhite[i * 3 + 0], endWhiteY - startWhiteY + 1, HW_PIXELS * 3); abWhite[i * 3 + 1] = _CalcAvg (&pabWhite[i * 3 + 1], endWhiteY - startWhiteY + 1, HW_PIXELS * 3); abWhite[i * 3 + 2] = _CalcAvg (&pabWhite[i * 3 + 2], endWhiteY - startWhiteY + 1, HW_PIXELS * 3); } iWhiteR = _CalcAvg (&abWhite[0], HW_PIXELS, 3); iWhiteG = _CalcAvg (&abWhite[1], HW_PIXELS, 3); iWhiteB = _CalcAvg (&abWhite[2], HW_PIXELS, 3); DBG (DBG_MSG, "Black level (%d,%d,%d), White level (%d,%d,%d)\n", (int) bMinR, (int) bMinG, (int) bMinB, iWhiteR, iWhiteG, iWhiteB); /* convert the white line and black point into a calibration table */ CreateCalibTable (abWhite, bMinR, bMinG, bMinB, iReversedHead, pabCalibTable); /* assign the White Levels */ if (pabCalWhite) { pabCalWhite[0] = iWhiteR; pabCalWhite[1] = iWhiteG; pabCalWhite[2] = iWhiteB; } return SANE_TRUE; } /************************************************************************* FinishScan ========== Finishes the scan. Makes the scanner head move back to the home position. *************************************************************************/ STATIC void FinishScan (THWParams * pHWParams) { NiashWriteReg (pHWParams->iXferHandle, 0x02, 0x80); } sane-backends-1.0.29/backend/hp5400.c0000666000000000000000000000553513615534521013664 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2003 Martijn van Oosterhout Copyright (C) 2003 Thomas Soumarmon This file was initially copied from the hp3300 testools and adjusted to suit. Original copyright notice follows: Copyright (C) 2001 Bertrik Sikken (bertrik@zonnet.nl) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* SANE interface for hp54xx scanners. Prototype. Parts of this source were inspired by other backends. */ #include "../include/sane/config.h" #include "hp5400_debug.h" #include "hp5400.h" #include "../include/sane/config.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/sane/saneopts.h" #include /* malloc, free */ #include /* memcpy */ #include #ifdef HAVE_SYS_TYPES_H #include #endif #define HP5400_CONFIG_FILE "hp5400.conf" #define BUILD 3 /* (source) includes for data transfer methods */ #include "hp5400_debug.c" #include "hp5400_internal.c" #include "hp5400_sane.c" #include "hp5400_sanei.c" sane-backends-1.0.29/backend/artec.c0000666000000000000000000031051713615534521014041 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 David Mosberger-Tang 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for the Artec/Ultima scanners. Copyright (C) 1998-2000 Chris Pinkham Released under the terms of the GPL. *NO WARRANTY* Portions contributed by: David Leadbetter - A6000C (3-pass) Dick Bruijn - AT12 ********************************************************************* For feedback/information: cpinkham@corp.infi.net http://www4.infi.net/~cpinkham/sane/sane-artec-doc.html ********************************************************************* */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include "../include/_stdint.h" #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include #define BACKEND_NAME artec #define ARTEC_MAJOR 0 #define ARTEC_MINOR 5 #define ARTEC_SUB 16 #define ARTEC_LAST_MOD "05/26/2001 17:28 EST" #ifndef PATH_MAX #define PATH_MAX 1024 #endif #define ARTEC_CONFIG_FILE "artec.conf" #define ARTEC_MAX_READ_SIZE 32768 static int num_devices; static const SANE_Device **devlist = 0; static ARTEC_Device *first_dev; static ARTEC_Scanner *first_handle; static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_HALFTONE, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, 0 }; static const SANE_String_Const filter_type_list[] = { "Mono", "Red", "Green", "Blue", 0 }; static const SANE_String_Const halftone_pattern_list[] = { "User defined (unsupported)", "4x4 Spiral", "4x4 Bayer", "8x8 Spiral", "8x8 Bayer", 0 }; static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; #define INQ_LEN 0x60 static const uint8_t inquiry[] = { 0x12, 0x00, 0x00, 0x00, INQ_LEN, 0x00 }; static const uint8_t test_unit_ready[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static struct { SANE_String model; /* product model */ SANE_String type; /* type of scanner */ double width; /* width in inches */ double height; /* height in inches */ SANE_Word adc_bits; /* Analog-to-Digital Converter Bits */ SANE_Word setwindow_cmd_size; /* Set-Window command size */ SANE_Word max_read_size; /* Max Read size in bytes */ long flags; /* flags */ SANE_String horz_resolution_str; /* Horizontal resolution list */ SANE_String vert_resolution_str; /* Vertical resolution list */ } cap_data[] = { { "AT3", "flatbed", 8.3, 11, 8, 55, 32768, ARTEC_FLAG_CALIBRATE_RGB | ARTEC_FLAG_RGB_LINE_OFFSET | ARTEC_FLAG_RGB_CHAR_SHIFT | ARTEC_FLAG_OPT_CONTRAST | ARTEC_FLAG_GAMMA_SINGLE | ARTEC_FLAG_SEPARATE_RES | ARTEC_FLAG_SENSE_HANDLER | ARTEC_FLAG_SENSE_BYTE_19 | ARTEC_FLAG_ADF | ARTEC_FLAG_HALFTONE_PATTERN | ARTEC_FLAG_MBPP_NEGATIVE | ARTEC_FLAG_ONE_PASS_SCANNER, "50,100,200,300", "50,100,200,300,600" } , { "A6000C", "flatbed", 8.3, 14, 8, 55, 8192, /* some have reported that Calibration does not work the same as AT3 & A6000C+ ARTEC_FLAG_CALIBRATE_RGB | */ ARTEC_FLAG_OPT_CONTRAST | ARTEC_FLAG_OPT_BRIGHTNESS | ARTEC_FLAG_SEPARATE_RES | ARTEC_FLAG_SENSE_HANDLER | ARTEC_FLAG_ADF | ARTEC_FLAG_HALFTONE_PATTERN, "50,100,200,300", "50,100,200,300,600" } , { "A6000C PLUS", "flatbed", 8.3, 14, 8, 55, 8192, ARTEC_FLAG_CALIBRATE_RGB | ARTEC_FLAG_RGB_LINE_OFFSET | ARTEC_FLAG_RGB_CHAR_SHIFT | ARTEC_FLAG_OPT_CONTRAST | ARTEC_FLAG_GAMMA_SINGLE | ARTEC_FLAG_SEPARATE_RES | ARTEC_FLAG_SENSE_HANDLER | ARTEC_FLAG_SENSE_BYTE_19 | ARTEC_FLAG_ADF | ARTEC_FLAG_HALFTONE_PATTERN | ARTEC_FLAG_MBPP_NEGATIVE | ARTEC_FLAG_ONE_PASS_SCANNER, "50,100,200,300", "50,100,200,300,600" } , { "AT6", "flatbed", 8.3, 11, 10, 55, 32768, ARTEC_FLAG_CALIBRATE_RGB | ARTEC_FLAG_RGB_LINE_OFFSET | ARTEC_FLAG_RGB_CHAR_SHIFT | ARTEC_FLAG_OPT_CONTRAST | /* gamma not working totally correct yet. ARTEC_FLAG_GAMMA_SINGLE | */ ARTEC_FLAG_SEPARATE_RES | ARTEC_FLAG_SENSE_HANDLER | ARTEC_FLAG_ADF | ARTEC_FLAG_HALFTONE_PATTERN | ARTEC_FLAG_MBPP_NEGATIVE | ARTEC_FLAG_ONE_PASS_SCANNER, "50,100,200,300", "50,100,200,300,600" } , { "AT12", "flatbed", 8.5, 11, 12, 67, 32768, /* calibration works slower so disabled ARTEC_CALIBRATE_DARK_WHITE | */ /* gamma not working totally correct yet. ARTEC_FLAG_GAMMA | */ ARTEC_FLAG_OPT_CONTRAST | ARTEC_FLAG_SEPARATE_RES | ARTEC_FLAG_SENSE_HANDLER | ARTEC_FLAG_SENSE_ENH_18 | ARTEC_FLAG_SENSE_BYTE_22 | ARTEC_FLAG_SC_BUFFERS_LINES | ARTEC_FLAG_SC_HANDLES_OFFSET | ARTEC_FLAG_PIXEL_AVERAGING | ARTEC_FLAG_ENHANCE_LINE_EDGE | ARTEC_FLAG_ADF | ARTEC_FLAG_HALFTONE_PATTERN | ARTEC_FLAG_MBPP_NEGATIVE | ARTEC_FLAG_ONE_PASS_SCANNER, "25,50,100,200,300,400,500,600", "25,50,100,200,300,400,500,600,700,800,900,1000,1100,1200" } , { "AM12S", "flatbed", 8.26, 11.7, 12, 67, ARTEC_MAX_READ_SIZE, /* calibration works slower so disabled ARTEC_CALIBRATE_DARK_WHITE | */ /* gamma not working totally correct yet. ARTEC_FLAG_GAMMA | */ ARTEC_FLAG_RGB_LINE_OFFSET | ARTEC_FLAG_SEPARATE_RES | ARTEC_FLAG_IMAGE_REV_LR | ARTEC_FLAG_REVERSE_WINDOW | ARTEC_FLAG_SENSE_HANDLER | ARTEC_FLAG_SENSE_ENH_18 | ARTEC_FLAG_MBPP_NEGATIVE | ARTEC_FLAG_ONE_PASS_SCANNER, "50,100,300,600", "50,100,300,600,1200" } , }; /* store vendor and model if hardcoded in artec.conf */ static char artec_vendor[9] = ""; static char artec_model[17] = ""; /* file descriptor for debug data output */ static int debug_fd = -1; static char *artec_skip_whitespace (char *str) { while (isspace (*str)) ++str; return str; } static SANE_Status artec_str_list_to_word_list (SANE_Word ** word_list_ptr, SANE_String str) { SANE_Word *word_list; char *start; char *end; char temp_str[1024]; int comma_count = 1; if ((str == NULL) || (strlen (str) == 0)) { /* alloc space for word which stores length (0 in this case) */ word_list = (SANE_Word *) malloc (sizeof (SANE_Word)); if (word_list == NULL) return (SANE_STATUS_NO_MEM); word_list[0] = 0; *word_list_ptr = word_list; return (SANE_STATUS_GOOD); } /* make temp copy of input string (only hold 1024 for now) */ strncpy (temp_str, str, 1023); temp_str[1023] = '\0'; end = strchr (temp_str, ','); while (end != NULL) { comma_count++; start = end + 1; end = strchr (start, ','); } word_list = (SANE_Word *) calloc (comma_count + 1, sizeof (SANE_Word)); if (word_list == NULL) return (SANE_STATUS_NO_MEM); word_list[0] = comma_count; comma_count = 1; start = temp_str; end = strchr (temp_str, ','); while (end != NULL) { *end = '\0'; word_list[comma_count] = atol (start); start = end + 1; comma_count++; end = strchr (start, ','); } word_list[comma_count] = atol (start); *word_list_ptr = word_list; return (SANE_STATUS_GOOD); } static size_t artec_get_str_index (const SANE_String_Const strings[], char *str) { size_t index; index = 0; while ((strings[index]) && strcmp (strings[index], str)) { index++; } if (!strings[index]) { index = 0; } return (index); } static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return (max_size); } /* DB added a sense handler */ /* last argument is expected to be a pointer to a Artec_Scanner structure */ static SANE_Status sense_handler (int fd, u_char * sense, void *arg) { ARTEC_Scanner *s = (ARTEC_Scanner *)arg; int err; err = 0; DBG(2, "sense fd: %d, data: %02x %02x %02x %02x %02x %02x %02x %02x " "%02x %02x %02x %02x %02x %02x %02x %02x\n", fd, sense[0], sense[1], sense[2], sense[3], sense[4], sense[5], sense[6], sense[7], sense[8], sense[9], sense[10], sense[11], sense[12], sense[13], sense[14], sense[15]); /* byte 18 info pertaining to ADF */ if ((s) && (s->hw->flags & ARTEC_FLAG_ADF)) { if (sense[18] & 0x01) { DBG (2, "sense: ADF PAPER JAM\n"); err++; } if (sense[18] & 0x02) { DBG (2, "sense: ADF NO DOCUMENT IN BIN\n"); err++; } if (sense[18] & 0x04) { DBG (2, "sense: ADF SWITCH COVER OPEN\n"); err++; } /* DB : next is, i think no failure, so no incrementing s */ if (sense[18] & 0x08) { DBG (2, "sense: ADF SET CORRECTLY ON TARGET\n"); } /* The following only for AT12, its reserved (zero?) on other models, */ if (sense[18] & 0x10) { DBG (2, "sense: ADF LENGTH TOO SHORT\n"); err++; } } /* enhanced byte 18 sense data */ if ((s) && (s->hw->flags & ARTEC_FLAG_SENSE_ENH_18)) { if (sense[18] & 0x20) { DBG (2, "sense: LAMP FAIL : NOT WARM \n"); err++; } if (sense[18] & 0x40) { DBG (2, "sense: NOT READY STATE\n"); err++; } } if ((s) && (s->hw->flags & ARTEC_FLAG_SENSE_BYTE_19)) { if (sense[19] & 0x01) { DBG (2, "sense: 8031 program ROM checksum Error\n"); err++; } if (sense[19] & 0x02) { DBG (2, "sense: 8031 data RAM R/W Error\n"); err++; } if (sense[19] & 0x04) { DBG (2, "sense: Shadow Correction RAM R/W Error\n"); err++; } if (sense[19] & 0x08) { DBG (2, "sense: Line RAM R/W Error\n"); err++; } if (sense[19] & 0x10) { /* docs say "reserved to '0'" */ DBG (2, "sense: CCD control circuit Error\n"); err++; } if (sense[19] & 0x20) { DBG (2, "sense: Motor End Switch Error\n"); err++; } if (sense[19] & 0x40) { /* docs say "reserved to '0'" */ DBG (2, "sense: Lamp Error\n"); err++; } if (sense[19] & 0x80) { DBG (2, "sense: Optical Calibration/Shading Error\n"); err++; } } /* These are the self test results for tests 0-15 */ if ((s) && (s->hw->flags & ARTEC_FLAG_SENSE_BYTE_22)) { if (sense[22] & 0x01) { DBG (2, "sense: 8031 Internal Memory R/W Error\n"); err++; } if (sense[22] & 0x02) { DBG (2, "sense: EEPROM test pattern R/W Error\n"); err++; } if (sense[22] & 0x04) { DBG (2, "sense: ASIC Test Error\n"); err++; } if (sense[22] & 0x08) { DBG (2, "sense: Line RAM R/W Error\n"); err++; } if (sense[22] & 0x10) { DBG (2, "sense: PSRAM R/W Test Error\n"); err++; } if (sense[22] & 0x20) { DBG (2, "sense: Positioning Error\n"); err++; } if (sense[22] & 0x40) { DBG (2, "sense: Test 6 Error\n"); err++; } if (sense[22] & 0x80) { DBG (2, "sense: Test 7 Error\n"); err++; } if (sense[23] & 0x01) { DBG (2, "sense: Test 8 Error\n"); err++; } if (sense[23] & 0x02) { DBG (2, "sense: Test 9 Error\n"); err++; } if (sense[23] & 0x04) { DBG (2, "sense: Test 10 Error\n"); err++; } if (sense[23] & 0x08) { DBG (2, "sense: Test 11 Error\n"); err++; } if (sense[23] & 0x10) { DBG (2, "sense: Test 12 Error\n"); err++; } if (sense[23] & 0x20) { DBG (2, "sense: Test 13 Error\n"); err++; } if (sense[23] & 0x40) { DBG (2, "sense: Test 14 Error\n"); err++; } if (sense[23] & 0x80) { DBG (2, "sense: Test 15 Error\n"); err++; } } if (err) return SANE_STATUS_IO_ERROR; switch (sense[0]) { case 0x70: /* ALWAYS */ switch (sense[2]) { case 0x00: DBG (2, "sense: Successful command\n"); return SANE_STATUS_GOOD; case 0x02: DBG (2, "sense: Not Ready, target can not be accessed\n"); return SANE_STATUS_IO_ERROR; case 0x03: DBG (2, "sense: Medium Error, paper jam or misfeed during ADF\n"); return SANE_STATUS_IO_ERROR; case 0x04: DBG (2, "sense: Hardware Error, non-recoverable\n"); return SANE_STATUS_IO_ERROR; case 0x05: DBG (2, "sense: Illegal Request, bad parameter in command block\n"); return SANE_STATUS_IO_ERROR; case 0x06: DBG (2, "sense: Unit Attention\n"); return SANE_STATUS_GOOD; default: DBG (2, "sense: SENSE KEY UNKNOWN (%02x)\n", sense[2]); return SANE_STATUS_IO_ERROR; } default: DBG (2, "sense: Unknown Error Code Qualifier (%02x)\n", sense[0]); return SANE_STATUS_IO_ERROR; } DBG (2, "sense: Should not come here!\n"); return SANE_STATUS_IO_ERROR; } /* DB added a wait routine for the scanner to come ready */ static SANE_Status wait_ready (int fd) { SANE_Status status; int retry = 30; /* make this tuneable? */ DBG (7, "wait_ready()\n"); while (retry-- > 0) { status = sanei_scsi_cmd (fd, test_unit_ready, sizeof (test_unit_ready), 0, 0); if (status == SANE_STATUS_GOOD) return status; if (status == SANE_STATUS_DEVICE_BUSY) { sleep (1); continue; } /* status != GOOD && != BUSY */ DBG (9, "wait_ready: '%s'\n", sane_strstatus (status)); return status; } /* BUSY after n retries */ DBG (9, "wait_ready: '%s'\n", sane_strstatus (status)); return status; } /* DB added a abort routine, executed via mode select */ static SANE_Status abort_scan (SANE_Handle handle) { ARTEC_Scanner *s = handle; uint8_t *data, comm[22]; DBG (7, "abort_scan()\n"); memset (comm, 0, sizeof (comm)); comm[0] = 0x15; comm[1] = 0x10; comm[2] = 0x00; comm[3] = 0x00; comm[4] = 0x10; comm[5] = 0x00; data = comm + 6; data[0] = 0x00; /* mode data length */ data[1] = 0x00; /* medium type */ data[2] = 0x00; /* device specific parameter */ data[3] = 0x00; /* block descriptor length */ data = comm + 10; data[0] = 0x00; /* control page parameters */ data[1] = 0x0a; /* parameter length */ data[2] = 0x02 | ((s->val[OPT_TRANSPARENCY].w == SANE_TRUE) ? 0x04 : 0x00) | ((s->val[OPT_ADF].w == SANE_TRUE) ? 0x00 : 0x01); data[3] = 0x00; /* reserved */ data[4] = 0x00; /* reserved */ DBG (9, "abort: sending abort command\n"); sanei_scsi_cmd (s->fd, comm, 6 + comm[4], 0, 0); DBG (9, "abort: wait for scanner to come ready...\n"); wait_ready (s->fd); DBG (9, "abort: resetting abort status\n"); data[2] = ((s->val[OPT_TRANSPARENCY].w == SANE_TRUE) ? 0x04 : 0x00) | ((s->val[OPT_ADF].w == SANE_TRUE) ? 0x00 : 0x01); sanei_scsi_cmd (s->fd, comm, 6 + comm[4], 0, 0); DBG (9, "abort: wait for scanner to come ready...\n"); return wait_ready (s->fd); } /* DAL - mode_select: used for transparency and ADF scanning */ /* Based on abort_scan */ static SANE_Status artec_mode_select (SANE_Handle handle) { ARTEC_Scanner *s = handle; uint8_t *data, comm[22]; DBG (7, "artec_mode_select()\n"); memset (comm, 0, sizeof (comm)); comm[0] = 0x15; comm[1] = 0x10; comm[2] = 0x00; comm[3] = 0x00; comm[4] = 0x10; comm[5] = 0x00; data = comm + 6; data[0] = 0x00; /* mode data length */ data[1] = 0x00; /* medium type */ data[2] = 0x00; /* device specific parameter */ data[3] = 0x00; /* block descriptor length */ data = comm + 10; data[0] = 0x00; /* control page parameters */ data[1] = 0x0a; /* parameter length */ data[2] = ((s->val[OPT_TRANSPARENCY].w == SANE_TRUE) ? 0x04 : 0x00) | ((s->val[OPT_ADF].w == SANE_TRUE) ? 0x00 : 0x01); data[3] = 0x00; /* reserved */ data[4] = 0x00; /* reserved */ DBG (9, "artec_mode_select: mode %d\n", data[2]); DBG (9, "artec_mode_select: sending mode command\n"); sanei_scsi_cmd (s->fd, comm, 6 + comm[4], 0, 0); DBG (9, "artec_mode_select: wait for scanner to come ready...\n"); return wait_ready (s->fd); } static SANE_Status read_data (int fd, int data_type_code, u_char * dest, size_t * len) { static u_char read_6[10]; DBG (7, "read_data()\n"); memset (read_6, 0, sizeof (read_6)); read_6[0] = 0x28; read_6[2] = data_type_code; read_6[6] = *len >> 16; read_6[7] = *len >> 8; read_6[8] = *len; return (sanei_scsi_cmd (fd, read_6, sizeof (read_6), dest, len)); } static int artec_get_status (int fd) { u_char write_10[10]; u_char read_12[12]; size_t nread; DBG (7, "artec_get_status()\n"); nread = 12; memset (write_10, 0, 10); write_10[0] = 0x34; write_10[8] = 0x0c; sanei_scsi_cmd (fd, write_10, 10, read_12, &nread); nread = (read_12[9] << 16) + (read_12[10] << 8) + read_12[11]; DBG (9, "artec_status: %lu\n", (u_long) nread); return (nread); } static SANE_Status artec_reverse_line (SANE_Handle handle, SANE_Byte * data) { ARTEC_Scanner *s = handle; SANE_Byte tmp_buf[32768]; /* max dpi 1200 * 8.5 inches * 3 = 30600 */ SANE_Byte *to, *from; int len; DBG (8, "artec_reverse_line()\n"); len = s->params.bytes_per_line; memcpy (tmp_buf, data, len); if (s->params.format == SANE_FRAME_RGB) /* RGB format */ { for (from = tmp_buf, to = data + len - 3; to >= data; to -= 3, from += 3) { *(to + 0) = *(from + 0); /* copy the R byte */ *(to + 1) = *(from + 1); /* copy the G byte */ *(to + 2) = *(from + 2); /* copy the B byte */ } } else if (s->params.format == SANE_FRAME_GRAY) { if (s->params.depth == 8) /* 256 color gray-scale */ { for (from = tmp_buf, to = data + len; to >= data; to--, from++) { *to = *from; } } else if (s->params.depth == 1) /* line art or halftone */ { for (from = tmp_buf, to = data + len; to >= data; to--, from++) { *to = (((*from & 0x01) << 7) | ((*from & 0x02) << 5) | ((*from & 0x04) << 3) | ((*from & 0x08) << 1) | ((*from & 0x10) >> 1) | ((*from & 0x20) >> 3) | ((*from & 0x40) >> 5) | ((*from & 0x80) >> 7)); } } } return (SANE_STATUS_GOOD); } #if 0 static SANE_Status artec_byte_rgb_to_line_rgb (SANE_Byte * data, SANE_Int len) { SANE_Byte tmp_buf[32768]; /* max dpi 1200 * 8.5 inches * 3 = 30600 */ int count, from; DBG (8, "artec_byte_rgb_to_line_rgb()\n"); /* copy the RGBRGBRGBRGBRGB... formated data to our temp buffer */ memcpy (tmp_buf, data, len * 3); /* now copy back to *data in RRRRRRRGGGGGGGBBBBBBB format */ for (count = 0, from = 0; count < len; count++, from += 3) { data[count] = tmp_buf[from]; /* R byte */ data[count + len] = tmp_buf[from + 1]; /* G byte */ data[count + (len * 2)] = tmp_buf[from + 2]; /* B byte */ } return (SANE_STATUS_GOOD); } #endif static SANE_Status artec_line_rgb_to_byte_rgb (SANE_Byte * data, SANE_Int len) { SANE_Byte tmp_buf[32768]; /* max dpi 1200 * 8.5 inches * 3 = 30600 */ int count, to; DBG (8, "artec_line_rgb_to_byte_rgb()\n"); /* copy the rgb data to our temp buffer */ memcpy (tmp_buf, data, len * 3); /* now copy back to *data in RGB format */ for (count = 0, to = 0; count < len; count++, to += 3) { data[to] = tmp_buf[count]; /* R byte */ data[to + 1] = tmp_buf[count + len]; /* G byte */ data[to + 2] = tmp_buf[count + (len * 2)]; /* B byte */ } return (SANE_STATUS_GOOD); } static SANE_Byte **line_buffer = NULL; static SANE_Byte *tmp_line_buf = NULL; static SANE_Int r_buf_lines; static SANE_Int g_buf_lines; static SANE_Status artec_buffer_line_offset (SANE_Handle handle, SANE_Int line_offset, SANE_Byte * data, size_t * len) { ARTEC_Scanner *s = handle; static SANE_Int width; static SANE_Int cur_line; SANE_Byte *tmp_buf_ptr; SANE_Byte *grn_ptr; SANE_Byte *blu_ptr; SANE_Byte *out_ptr; int count; DBG (8, "artec_buffer_line_offset()\n"); if (*len == 0) return (SANE_STATUS_GOOD); if (tmp_line_buf == NULL) { width = *len / 3; cur_line = 0; DBG (9, "buffer_line_offset: offset = %d, len = %lu\n", line_offset, (u_long) * len); tmp_line_buf = malloc (*len); if (tmp_line_buf == NULL) { DBG (1, "couldn't allocate memory for temp line buffer\n"); return (SANE_STATUS_NO_MEM); } r_buf_lines = line_offset * 2; g_buf_lines = line_offset; line_buffer = malloc (r_buf_lines * sizeof (SANE_Byte *)); if (line_buffer == NULL) { DBG (1, "couldn't allocate memory for line buffer pointers\n"); return (SANE_STATUS_NO_MEM); } for (count = 0; count < r_buf_lines; count++) { line_buffer[count] = malloc ((*len) * sizeof (SANE_Byte)); if (line_buffer[count] == NULL) { DBG (1, "couldn't allocate memory for line buffer %d\n", count); return (SANE_STATUS_NO_MEM); } } DBG (9, "buffer_line_offset: r lines = %d, g lines = %d\n", r_buf_lines, g_buf_lines); } cur_line++; if (r_buf_lines > 0) { if (cur_line > r_buf_lines) { /* copy the Red and Green portions out of the buffer */ /* if scanner returns RRRRRRRRGGGGGGGGGBBBBBBBB format it's easier */ if (s->hw->flags & ARTEC_FLAG_RGB_CHAR_SHIFT) { /* get the red line info from r_buf_lines ago */ memcpy (tmp_line_buf, line_buffer[0], width); /* get the green line info from g_buf_lines ago */ memcpy (tmp_line_buf + width, &line_buffer[line_offset][width], width); } else { /* get the red line info from r_buf_lines ago as a whole line */ memcpy (tmp_line_buf, line_buffer[0], *len); /* scanner returns RGBRGBRGB format so we do a loop for green */ grn_ptr = &line_buffer[line_offset][1]; out_ptr = tmp_line_buf + 1; for (count = 0; count < width; count++) { *out_ptr = *grn_ptr; /* copy green pixel */ grn_ptr += 3; out_ptr += 3; } } } /* move all the buffered lines down (just move the ptrs for speed) */ tmp_buf_ptr = line_buffer[0]; for (count = 0; count < (r_buf_lines - 1); count++) { line_buffer[count] = line_buffer[count + 1]; } line_buffer[r_buf_lines - 1] = tmp_buf_ptr; /* insert the new line data at the end of our FIFO */ memcpy (line_buffer[r_buf_lines - 1], data, *len); if (cur_line > r_buf_lines) { /* copy the Red and Green portions out of the buffer */ /* if scanner returns RRRRRRRRGGGGGGGGGBBBBBBBB format it's easier */ if (s->hw->flags & ARTEC_FLAG_RGB_CHAR_SHIFT) { /* copy the red and green data in with the original blue */ memcpy (data, tmp_line_buf, width * 2); } else { /* scanner returns RGBRGBRGB format so we have to do a loop */ /* copy the blue data into our temp buffer then copy full */ /* temp buffer overtop of input data */ if (s->hw->flags & ARTEC_FLAG_IMAGE_REV_LR) { blu_ptr = data; out_ptr = tmp_line_buf; } else { blu_ptr = data + 2; out_ptr = tmp_line_buf + 2; } for (count = 0; count < width; count++) { *out_ptr = *blu_ptr; /* copy blue pixel */ blu_ptr += 3; out_ptr += 3; } /* now just copy tmp_line_buf back over original data */ memcpy (data, tmp_line_buf, *len); } } else { /* if in the first r_buf_lines, then don't return anything */ *len = 0; } } return (SANE_STATUS_GOOD); } static SANE_Status artec_buffer_line_offset_free (void) { int count; DBG (7, "artec_buffer_line_offset_free()\n"); free (tmp_line_buf); tmp_line_buf = NULL; for (count = 0; count < r_buf_lines; count++) { free (line_buffer[count]); } free (line_buffer); line_buffer = NULL; return (SANE_STATUS_GOOD); } #if 0 static SANE_Status artec_read_gamma_table (SANE_Handle handle) { ARTEC_Scanner *s = handle; char write_6[4096 + 20]; /* max gamma table is 4096 + 20 for command data */ char *data; char prt_buf[128]; char tmp_buf[128]; int i; DBG (7, "artec_read_gamma_table()\n"); memset (write_6, 0, sizeof (*write_6)); write_6[0] = 0x28; /* read data code */ /* FIXME: AT12 and AM12S use 0x0E for reading all channels of data */ write_6[2] = 0x03; /* data type code "gamma data" */ write_6[6] = (s->gamma_length + 9) >> 16; write_6[7] = (s->gamma_length + 9) >> 8; write_6[8] = (s->gamma_length + 9); /* FIXME: AT12 and AM12S have one less byte so use 18 */ if ((!strcmp (s->hw->sane.model, "AT12")) || (!strcmp (s->hw->sane.model, "AM12S"))) { data = write_6 + 18; } else { data = write_6 + 19; } /* FIXME: AT12 & AM12S ignore this, it's a reserved field */ write_6[10] = 0x08; /* bitmask, bit 3 means mono type */ if (!s->val[OPT_CUSTOM_GAMMA].w) { write_6[11] = 1; /* internal gamma table #1 (hope this is default) */ } DBG( 9, "Gamma Table\n" ); DBG( 9, "==================================\n" ); prt_buf[0] = '\0'; for (i = 0; i < s->gamma_length; i++) { if (DBG_LEVEL >= 9) { if (!(i % 16)) { if ( prt_buf[0] ) { strcat( prt_buf, "\n" ); DBG( 9, "%s", prt_buf ); } sprintf (prt_buf, "%02x: ", i); } sprintf (tmp_buf, "%02x ", (int) s->gamma_table[0][i]); strcat (prt_buf, tmp_buf ); } data[i] = s->gamma_table[0][i]; } if ( prt_buf[0] ) { strcat( prt_buf, "\n" ); DBG( 9, "%s", prt_buf ); } if ((!strcmp (s->hw->sane.model, "AT12")) || (!strcmp (s->hw->sane.model, "AM12S"))) { return (sanei_scsi_cmd (s->fd, write_6, 10 + 8 + s->gamma_length, 0, 0)); } else { return (sanei_scsi_cmd (s->fd, write_6, 10 + 9 + s->gamma_length, 0, 0)); } } #endif static SANE_Status artec_send_gamma_table (SANE_Handle handle) { ARTEC_Scanner *s = handle; char write_6[4096 + 20]; /* max gamma table is 4096 + 20 for command data */ char *data; char prt_buf[128]; char tmp_buf[128]; int i; DBG (7, "artec_send_gamma_table()\n"); memset (write_6, 0, sizeof (*write_6)); write_6[0] = 0x2a; /* send data code */ if (s->hw->setwindow_cmd_size > 55) { /* newer scanners support sending 3 channels of gamma, or populating all */ /* 3 channels with same data by using code 0x0e */ write_6[2] = 0x0e; } else { /* older scanners only support 1 channel of gamma data using code 0x3 */ write_6[2] = 0x03; } /* FIXME: AT12 & AM!2S ignore this, it's a reserved field */ write_6[10] = 0x08; /* bitmask, bit 3 means mono type */ if (!s->val[OPT_CUSTOM_GAMMA].w) { write_6[6] = 9 >> 16; write_6[7] = 9 >> 8; write_6[8] = 9; write_6[11] = 1; /* internal gamma table #1 (hope this is default) */ return (sanei_scsi_cmd (s->fd, write_6, 10 + 9, 0, 0)); } else { write_6[6] = (s->gamma_length + 9) >> 16; write_6[7] = (s->gamma_length + 9) >> 8; write_6[8] = (s->gamma_length + 9); DBG( 9, "Gamma Table\n" ); DBG( 9, "==================================\n" ); /* FIXME: AT12 and AM12S have one less byte so use 18 */ if ((!strcmp (s->hw->sane.model, "AT12")) || (!strcmp (s->hw->sane.model, "AM12S"))) { data = write_6 + 18; } else { data = write_6 + 19; } prt_buf[0] = '\0'; for (i = 0; i < s->gamma_length; i++) { if (DBG_LEVEL >= 9) { if (!(i % 16)) { if ( prt_buf[0] ) { strcat( prt_buf, "\n" ); DBG( 9, "%s", prt_buf ); } sprintf (prt_buf, "%02x: ", i); } sprintf (tmp_buf, "%02x ", (int) s->gamma_table[0][i]); strcat (prt_buf, tmp_buf ); } data[i] = s->gamma_table[0][i]; } data[s->gamma_length - 1] = 0; if ( prt_buf[0] ) { strcat( prt_buf, "\n" ); DBG( 9, "%s", prt_buf ); } /* FIXME: AT12 and AM12S have one less byte so use 18 */ if ((!strcmp (s->hw->sane.model, "AT12")) || (!strcmp (s->hw->sane.model, "AM12S"))) { return (sanei_scsi_cmd (s->fd, write_6, 10 + 8 + s->gamma_length, 0, 0)); } else { return (sanei_scsi_cmd (s->fd, write_6, 10 + 9 + s->gamma_length, 0, 0)); } } } static SANE_Status artec_set_scan_window (SANE_Handle handle) { ARTEC_Scanner *s = handle; char write_6[4096]; unsigned char *data; int counter; int reversed_x; int max_x; DBG (7, "artec_set_scan_window()\n"); /* * if we can, start before the desired window since we have to throw away * s->line_offset number of rows because of the RGB fixup. */ if ((s->line_offset) && (s->tl_y) && (s->tl_y >= (s->line_offset * 2))) { s->tl_y -= (s->line_offset * 2); } data = (unsigned char *)write_6 + 10; DBG (5, "Scan window info:\n"); DBG (5, " X resolution: %5d (%d-%d)\n", s->x_resolution, ARTEC_MIN_X (s->hw), ARTEC_MAX_X (s->hw)); DBG (5, " Y resolution: %5d (%d-%d)\n", s->y_resolution, ARTEC_MIN_Y (s->hw), ARTEC_MAX_Y (s->hw)); DBG (5, " TL_X (pixel): %5d\n", s->tl_x); DBG (5, " TL_Y (pixel): %5d\n", s->tl_y); DBG (5, " Width : %5d (%d-%d)\n", s->params.pixels_per_line, s->hw->x_range.min, (int) ((SANE_UNFIX (s->hw->x_range.max) / MM_PER_INCH) * s->x_resolution)); DBG (5, " Height : %5d (%d-%d)\n", s->params.lines, s->hw->y_range.min, (int) ((SANE_UNFIX (s->hw->y_range.max) / MM_PER_INCH) * s->y_resolution)); DBG (5, " Image Comp. : %s\n", s->mode); DBG (5, " Line Offset : %lu\n", (u_long) s->line_offset); memset (write_6, 0, 4096); write_6[0] = 0x24; write_6[8] = s->hw->setwindow_cmd_size; /* total size of command */ /* beginning of set window data header */ /* actual SCSI command data byte count */ data[7] = s->hw->setwindow_cmd_size - 8; /* x resolution */ data[10] = s->x_resolution >> 8; data[11] = s->x_resolution; /* y resolution */ data[12] = s->y_resolution >> 8; data[13] = s->y_resolution; if ( s->hw->flags & ARTEC_FLAG_REVERSE_WINDOW ) { /* top left X value */ /* the select area is flipped across the page, so we have to do some */ /* calculation here to get the real starting X value */ max_x = (int) ((SANE_UNFIX (s->hw->x_range.max) / MM_PER_INCH) * s->x_resolution); reversed_x = max_x - s->tl_x - s->params.pixels_per_line; data[14] = reversed_x >> 24; data[15] = reversed_x >> 16; data[16] = reversed_x >> 8; data[17] = reversed_x; } else { /* top left X value */ data[14] = s->tl_x >> 24; data[15] = s->tl_x >> 16; data[16] = s->tl_x >> 8; data[17] = s->tl_x; } /* top left Y value */ data[18] = s->tl_y >> 24; data[19] = s->tl_y >> 16; data[20] = s->tl_y >> 8; data[21] = s->tl_y; /* width */ data[22] = s->params.pixels_per_line >> 24; data[23] = s->params.pixels_per_line >> 16; data[24] = s->params.pixels_per_line >> 8; data[25] = s->params.pixels_per_line; /* height */ data[26] = (s->params.lines + (s->line_offset * 2)) >> 24; data[27] = (s->params.lines + (s->line_offset * 2)) >> 16; data[28] = (s->params.lines + (s->line_offset * 2)) >> 8; data[29] = (s->params.lines + (s->line_offset * 2)); /* misc. single-byte settings */ /* brightness */ if (s->hw->flags & ARTEC_FLAG_OPT_BRIGHTNESS) data[30] = s->val[OPT_BRIGHTNESS].w; data[31] = s->val[OPT_THRESHOLD].w; /* threshold */ /* contrast */ if (s->hw->flags & ARTEC_FLAG_OPT_CONTRAST) data[32] = s->val[OPT_CONTRAST].w; /* * byte 33 is mode * byte 37 bit 7 is "negative" setting */ if (strcmp (s->mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) { data[33] = ARTEC_COMP_LINEART; data[37] = (s->val[OPT_NEGATIVE].w == SANE_TRUE) ? 0x0 : 0x80; } else if (strcmp (s->mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) { data[33] = ARTEC_COMP_HALFTONE; data[37] = (s->val[OPT_NEGATIVE].w == SANE_TRUE) ? 0x0 : 0x80; } else if (strcmp (s->mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) { data[33] = ARTEC_COMP_GRAY; data[37] = (s->val[OPT_NEGATIVE].w == SANE_TRUE) ? 0x80 : 0x0; } else if (strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) { data[33] = ARTEC_COMP_COLOR; data[37] = (s->val[OPT_NEGATIVE].w == SANE_TRUE) ? 0x80 : 0x0; } data[34] = s->params.depth; /* bits per pixel */ if (s->hw->flags & ARTEC_FLAG_HALFTONE_PATTERN) { data[35] = artec_get_str_index (halftone_pattern_list, s->val[OPT_HALFTONE_PATTERN].s); /* halftone pattern */ } /* user supplied halftone pattern not supported for now so override with */ /* 8x8 Bayer */ if (data[35] == 0) { data[35] = 4; } /* NOTE: AT12 doesn't support mono according to docs. */ data[48] = artec_get_str_index (filter_type_list, s->val[OPT_FILTER_TYPE].s); /* filter mode */ if (s->hw->setwindow_cmd_size > 55) { data[48] = 0x2; /* DB filter type green for AT12,see above */ if (s->hw->flags & ARTEC_FLAG_SC_BUFFERS_LINES) { /* FIXME: guessing at this value, use formula instead */ data[55] = 0x00; /* buffer full line count */ data[56] = 0x00; /* buffer full line count */ data[57] = 0x00; /* buffer full line count */ data[58] = 0x0a; /* buffer full line count */ /* FIXME: guessing at this value, use formula instead */ data[59] = 0x00; /* access line count */ data[60] = 0x00; /* access line count */ data[61] = 0x00; /* access line count */ data[62] = 0x0a; /* access line count */ } if (s->hw->flags & ARTEC_FLAG_SC_HANDLES_OFFSET) { /* DB : following fields : high order bit (0x80) is enable */ /* scanner handles line offset fixup, 0 = driver handles */ data[63] = 0x80; } if ((s->hw->flags & ARTEC_FLAG_PIXEL_AVERAGING) && (s->val[OPT_PIXEL_AVG].w)) { /* enable pixel average function */ data[64] = 0x80; } else { /* disable pixel average function */ data[64] = 0; } if ((s->hw->flags & ARTEC_FLAG_ENHANCE_LINE_EDGE) && (s->val[OPT_EDGE_ENH].w)) { /* enable lineart edge enhancement function */ data[65] = 0x80; } else { /* disable lineart edge enhancement function */ data[65] = 0; } /* data is R-G-B format, 0x80 = G-B-R format (reversed) */ data[66] = 0; } DBG (50, "Set Window data : \n"); for (counter = 0; counter < s->hw->setwindow_cmd_size; counter++) { DBG (50, " byte %2d = %02x \n", counter, data[counter] & 0xff); /* DB */ } DBG (50, "\n"); /* set the scan window */ return (sanei_scsi_cmd (s->fd, write_6, 10 + s->hw->setwindow_cmd_size, 0, 0)); } static SANE_Status artec_start_scan (SANE_Handle handle) { ARTEC_Scanner *s = handle; char write_7[7]; DBG (7, "artec_start_scan()\n"); /* setup cmd to start scanning */ memset (write_7, 0, 7); write_7[0] = 0x1b; /* code to start scan */ /* FIXME: need to make this a flag */ if (!strcmp (s->hw->sane.model, "AM12S")) { /* start the scan */ return (sanei_scsi_cmd (s->fd, write_7, 6, 0, 0)); } else { write_7[4] = 0x01; /* need to send 1 data byte */ /* start the scan */ return (sanei_scsi_cmd (s->fd, write_7, 7, 0, 0)); } } static SANE_Status artec_software_rgb_calibrate (SANE_Handle handle, SANE_Byte * buf, int lines) { ARTEC_Scanner *s = handle; int line, i, loop, offset; DBG (7, "artec_software_rgb_calibrate()\n"); for (line = 0; line < lines; line++) { i = 0; offset = 0; if (s->x_resolution == 200) { /* skip ever 3rd byte, -= causes us to go down in count */ if ((s->tl_x % 3) == 0) offset -= 1; } else { /* round down to the previous pixel */ offset += ((s->tl_x / (300 / s->x_resolution)) * (300 / s->x_resolution)); } for (loop = 0; loop < s->params.pixels_per_line; loop++) { if ((DBG_LEVEL == 100) && (loop < 100)) { DBG (100, " %2d-%4d R (%4d,%4d): %d * %5.2f = %d\n", line, loop, i, offset, buf[i], s->soft_calibrate_data[ARTEC_SOFT_CALIB_RED][offset], (int) (buf[i] * s->soft_calibrate_data[ARTEC_SOFT_CALIB_RED][offset])); } buf[i] = buf[i] * s->soft_calibrate_data[ARTEC_SOFT_CALIB_RED][offset]; i++; if ((DBG_LEVEL == 100) && (loop < 100)) { DBG (100, " G (%4d,%4d): %d * %5.2f = %d\n", i, offset, buf[i], s->soft_calibrate_data[ARTEC_SOFT_CALIB_GREEN][offset], (int) (buf[i] * s->soft_calibrate_data[ARTEC_SOFT_CALIB_GREEN][offset])); } buf[i] = buf[i] * s->soft_calibrate_data[ARTEC_SOFT_CALIB_GREEN][offset]; i++; if ((DBG_LEVEL == 100) && (loop < 100)) { DBG (100, " B (%4d,%4d): %d * %5.2f = %d\n", i, offset, buf[i], s->soft_calibrate_data[ARTEC_SOFT_CALIB_BLUE][offset], (int) (buf[i] * s->soft_calibrate_data[ARTEC_SOFT_CALIB_BLUE][offset])); } buf[i] = buf[i] * s->soft_calibrate_data[ARTEC_SOFT_CALIB_BLUE][offset]; i++; if (s->x_resolution == 200) { offset += 1; /* skip every 3rd byte */ if (((offset + 1) % 3) == 0) offset += 1; } else { offset += (300 / s->x_resolution); } } } return (SANE_STATUS_GOOD); } static SANE_Status artec_calibrate_shading (SANE_Handle handle) { ARTEC_Scanner *s = handle; SANE_Status status; /* DB added */ u_char buf[76800]; /* should be big enough */ size_t len; SANE_Word save_x_resolution; SANE_Word save_pixels_per_line; int i; DBG (7, "artec_calibrate_shading()\n"); if (s->hw->flags & ARTEC_FLAG_CALIBRATE_RGB) { /* this method scans in 4 lines each of Red, Green, and Blue */ /* after reading line of shading data, generate data for software */ /* calibration so we have it if user requests */ len = 4 * 2592; /* 4 lines of data, 2592 pixels wide */ if ( DBG_LEVEL == 100 ) DBG (100, "RED Software Calibration data\n"); read_data (s->fd, ARTEC_DATA_RED_SHADING, buf, &len); for (i = 0; i < 2592; i++) { s->soft_calibrate_data[ARTEC_SOFT_CALIB_RED][i] = 255.0 / ((buf[i] + buf[i + 2592] + buf[i + 5184] + buf[i + 7776]) / 4); if (DBG_LEVEL == 100) { DBG (100, " %4d: 255.0 / (( %3d + %3d + %3d + %3d ) / 4 ) = %5.2f\n", i, buf[i], buf[i + 2592], buf[i + 5184], buf[i + 7776], s->soft_calibrate_data[ARTEC_SOFT_CALIB_RED][i]); } } if (DBG_LEVEL == 100) { DBG (100, "GREEN Software Calibration data\n"); } read_data (s->fd, ARTEC_DATA_GREEN_SHADING, buf, &len); for (i = 0; i < 2592; i++) { s->soft_calibrate_data[ARTEC_SOFT_CALIB_GREEN][i] = 255.0 / ((buf[i] + buf[i + 2592] + buf[i + 5184] + buf[i + 7776]) / 4); if (DBG_LEVEL == 100) { DBG (100, " %4d: 255.0 / (( %3d + %3d + %3d + %3d ) / 4 ) = %5.2f\n", i, buf[i], buf[i + 2592], buf[i + 5184], buf[i + 7776], s->soft_calibrate_data[ARTEC_SOFT_CALIB_GREEN][i]); } } if (DBG_LEVEL == 100) { DBG (100, "BLUE Software Calibration data\n"); } read_data (s->fd, ARTEC_DATA_BLUE_SHADING, buf, &len); for (i = 0; i < 2592; i++) { s->soft_calibrate_data[ARTEC_SOFT_CALIB_BLUE][i] = 255.0 / ((buf[i] + buf[i + 2592] + buf[i + 5184] + buf[i + 7776]) / 4); if (DBG_LEVEL == 100) { DBG (100, " %4d: 255.0 / (( %3d + %3d + %3d + %3d ) / 4 ) = %5.2f\n", i, buf[i], buf[i + 2592], buf[i + 5184], buf[i + 7776], s->soft_calibrate_data[ARTEC_SOFT_CALIB_BLUE][i]); } } } else if (s->hw->flags & ARTEC_FLAG_CALIBRATE_DARK_WHITE) { /* this method scans black, then white data */ len = 3 * 5100; /* 1 line of data, 5100 pixels wide, RGB data */ read_data (s->fd, ARTEC_DATA_DARK_SHADING, buf, &len); save_x_resolution = s->x_resolution; s->x_resolution = 600; save_pixels_per_line = s->params.pixels_per_line; s->params.pixels_per_line = ARTEC_MAX_X (s->hw); s->params.pixels_per_line = 600 * 8.5; /* ?this? or ?above line? */ /* DB added wait_ready */ status = wait_ready (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "wait for scanner ready failed: %s\n", sane_strstatus (status)); return status; } /* next line should use ARTEC_DATA_WHITE_SHADING_TRANS if using ADF */ read_data (s->fd, ARTEC_DATA_WHITE_SHADING_OPT, buf, &len); s->x_resolution = save_x_resolution; s->params.pixels_per_line = save_pixels_per_line; } return (SANE_STATUS_GOOD); } static SANE_Status end_scan (SANE_Handle handle) { ARTEC_Scanner *s = handle; /* DB uint8_t write_6[6] = {0x1B, 0, 0, 0, 0, 0}; */ DBG (7, "end_scan()\n"); s->scanning = SANE_FALSE; /* if (s->this_pass == 3) */ s->this_pass = 0; if ((s->hw->flags & ARTEC_FLAG_RGB_LINE_OFFSET) && (tmp_line_buf != NULL)) { artec_buffer_line_offset_free (); } /* DB return (sanei_scsi_cmd (s->fd, write_6, 6, 0, 0)); */ return abort_scan (s); } static SANE_Status artec_get_cap_data (ARTEC_Device * dev, int fd) { int cap_model, loop; u_char cap_buf[256]; /* buffer for cap data */ DBG (7, "artec_get_cap_data()\n"); /* DB always use the hard-coded capability info first * if we get cap data from the scanner, we override */ cap_model = -1; for (loop = 0; loop < NELEMS (cap_data); loop++) { if (strcmp (cap_data[loop].model, dev->sane.model) == 0) { cap_model = loop; } } if (cap_model == -1) { DBG (1, "unable to identify Artec model '%s', check artec.c\n", dev->sane.model); return (SANE_STATUS_UNSUPPORTED); } dev->x_range.min = 0; dev->x_range.max = SANE_FIX (cap_data[cap_model].width) * MM_PER_INCH; dev->x_range.quant = 1; dev->width = cap_data[cap_model].width; dev->y_range.min = 0; dev->y_range.max = SANE_FIX (cap_data[cap_model].height) * MM_PER_INCH; dev->y_range.quant = 1; dev->height = cap_data[cap_model].height; artec_str_list_to_word_list (&dev->horz_resolution_list, cap_data[cap_model].horz_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; dev->contrast_range.quant = 1; dev->brightness_range.min = 0; dev->brightness_range.max = 255; dev->brightness_range.quant = 1; dev->threshold_range.min = 0; dev->threshold_range.max = 255; dev->threshold_range.quant = 1; dev->sane.type = cap_data[cap_model].type; dev->max_read_size = cap_data[cap_model].max_read_size; dev->flags = cap_data[cap_model].flags; switch (cap_data[cap_model].adc_bits) { case 8: dev->gamma_length = 256; break; case 10: dev->gamma_length = 1024; break; case 12: dev->gamma_length = 4096; break; } dev->setwindow_cmd_size = cap_data[cap_model].setwindow_cmd_size; if (dev->support_cap_data_retrieve) /* DB */ { /* DB added reading capability data from scanner */ char info[80]; /* for printing debugging info */ size_t len = sizeof (cap_buf); /* read the capability data from the scanner */ DBG (9, "reading capability data from scanner...\n"); wait_ready (fd); read_data (fd, ARTEC_DATA_CAPABILITY_DATA, cap_buf, &len); DBG (50, "scanner capability data : \n"); strncpy (info, (const char *) &cap_buf[0], 8); info[8] = '\0'; DBG (50, " Vendor : %s\n", info); strncpy (info, (const char *) &cap_buf[8], 16); info[16] = '\0'; DBG (50, " Device Name : %s\n", info); strncpy (info, (const char *) &cap_buf[24], 4); info[4] = '\0'; DBG (50, " Version Number : %s\n", info); sprintf (info, "%d ", cap_buf[29]); DBG (50, " CCD Type : %s\n", info); sprintf (info, "%d ", cap_buf[30]); DBG (50, " AD Converter Type : %s\n", info); sprintf (info, "%d ", (cap_buf[31] << 8) | cap_buf[32]); DBG (50, " Buffer size : %s\n", info); sprintf (info, "%d ", cap_buf[33]); DBG (50, " Channels of RGB Gamma : %s\n", info); sprintf (info, "%d ", (cap_buf[34] << 8) | cap_buf[35]); DBG (50, " Opt. res. of R channel : %s\n", info); sprintf (info, "%d ", (cap_buf[36] << 8) | cap_buf[37]); DBG (50, " Opt. res. of G channel : %s\n", info); sprintf (info, "%d ", (cap_buf[38] << 8) | cap_buf[39]); DBG (50, " Opt. res. of B channel : %s\n", info); sprintf (info, "%d ", (cap_buf[40] << 8) | cap_buf[41]); DBG (50, " Min. Hor. Resolution : %s\n", info); sprintf (info, "%d ", (cap_buf[42] << 8) | cap_buf[43]); DBG (50, " Max. Vert. Resolution : %s\n", info); sprintf (info, "%d ", (cap_buf[44] << 8) | cap_buf[45]); DBG (50, " Min. Vert. Resolution : %s\n", info); sprintf (info, "%s ", cap_buf[46] == 0x80 ? "yes" : "no"); DBG (50, " Chunky Data Format : %s\n", info); sprintf (info, "%s ", cap_buf[47] == 0x80 ? "yes" : "no"); DBG (50, " RGB Data Format : %s\n", info); sprintf (info, "%s ", cap_buf[48] == 0x80 ? "yes" : "no"); DBG (50, " BGR Data Format : %s\n", info); sprintf (info, "%d ", cap_buf[49]); DBG (50, " Line Offset : %s\n", info); sprintf (info, "%s ", cap_buf[50] == 0x80 ? "yes" : "no"); DBG (50, " Channel Valid Sequence : %s\n", info); sprintf (info, "%s ", cap_buf[51] == 0x80 ? "yes" : "no"); DBG (50, " True Gray : %s\n", info); sprintf (info, "%s ", cap_buf[52] == 0x80 ? "yes" : "no"); DBG (50, " Force Host Not Do Shading : %s\n", info); sprintf (info, "%s ", cap_buf[53] == 0x00 ? "AT006" : "AT010"); DBG (50, " ASIC : %s\n", info); sprintf (info, "%s ", cap_buf[54] == 0x82 ? "SCSI2" : cap_buf[54] == 0x81 ? "SCSI1" : "Parallel"); DBG (50, " Interface : %s\n", info); sprintf (info, "%d ", (cap_buf[55] << 8) | cap_buf[56]); DBG (50, " Phys. Area Width : %s\n", info); sprintf (info, "%d ", (cap_buf[57] << 8) | cap_buf[58]); DBG (50, " Phys. Area Length : %s\n", info); /* fill in the information we've got from the scanner */ dev->width = ((float) ((cap_buf[55] << 8) | cap_buf[56])) / 1000; dev->height = ((float) ((cap_buf[57] << 8) | cap_buf[58])) / 1000; /* DB ----- */ } DBG (9, "Scanner capability info.\n"); DBG (9, " Vendor : %s\n", dev->sane.vendor); DBG (9, " Model : %s\n", dev->sane.model); DBG (9, " Type : %s\n", dev->sane.type); DBG (5, " Width : %.2f inches\n", dev->width); DBG (9, " Height : %.2f inches\n", dev->height); DBG (9, " X Range(mm) : %d-%d\n", dev->x_range.min, (int) (SANE_UNFIX (dev->x_range.max))); DBG (9, " Y Range(mm) : %d-%d\n", dev->y_range.min, (int) (SANE_UNFIX (dev->y_range.max))); DBG (9, " Horz. DPI : %d-%d\n", ARTEC_MIN_X (dev), ARTEC_MAX_X (dev)); DBG (9, " Vert. DPI : %d-%d\n", ARTEC_MIN_Y (dev), ARTEC_MAX_Y (dev)); DBG (9, " Contrast : %d-%d\n", dev->contrast_range.min, dev->contrast_range.max); DBG (9, " REQ Sh. Cal.: %d\n", dev->flags & ARTEC_FLAG_CALIBRATE ? 1 : 0); DBG (9, " REQ Ln. Offs: %d\n", dev->flags & ARTEC_FLAG_RGB_LINE_OFFSET ? 1 : 0); DBG (9, " REQ Ch. Shft: %d\n", dev->flags & ARTEC_FLAG_RGB_CHAR_SHIFT ? 1 : 0); DBG (9, " SetWind Size: %d\n", dev->setwindow_cmd_size); DBG (9, " Calib Method: %s\n", dev->flags & ARTEC_FLAG_CALIBRATE_RGB ? "RGB" : dev->flags & ARTEC_FLAG_CALIBRATE_DARK_WHITE ? "white/black" : "N/A"); return (SANE_STATUS_GOOD); } static SANE_Status dump_inquiry (unsigned char *result) { int i; int j; char prt_buf[129] = ""; char tmp_buf[129]; DBG (4, "dump_inquiry()\n"); DBG (4, " === SANE/Artec backend v%d.%d.%d ===\n", ARTEC_MAJOR, ARTEC_MINOR, ARTEC_SUB); DBG (4, " ===== Scanner Inquiry Block =====\n"); for (i = 0; i < 96; i += 16) { sprintf (prt_buf, "0x%02x: ", i); for (j = 0; j < 16; j++) { sprintf (tmp_buf, "%02x ", (int) result[i + j]); strcat( prt_buf, tmp_buf ); } strcat( prt_buf, " "); for (j = 0; j < 16; j++) { sprintf (tmp_buf, "%c", isprint (result[i + j]) ? result[i + j] : '.'); strcat( prt_buf, tmp_buf ); } strcat( prt_buf, "\n" ); DBG(4, "%s", prt_buf ); } return (SANE_STATUS_GOOD); } static SANE_Status attach (const char *devname, ARTEC_Device ** devp) { char result[INQ_LEN]; char product_revision[5]; char temp_result[33]; char *str, *t; int fd; SANE_Status status; ARTEC_Device *dev; size_t size; DBG (7, "attach()\n"); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devname) == 0) { if (devp) *devp = dev; return (SANE_STATUS_GOOD); } } DBG (6, "attach: opening %s\n", devname); status = sanei_scsi_open (devname, &fd, sense_handler, NULL); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: open failed (%s)\n", sane_strstatus (status)); return (SANE_STATUS_INVAL); } DBG (6, "attach: sending INQUIRY\n"); size = sizeof (result); status = sanei_scsi_cmd (fd, inquiry, sizeof (inquiry), result, &size); if (status != SANE_STATUS_GOOD || size < 16) { DBG (1, "attach: inquiry failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (fd); return (status); } /* * Check to see if this device is a scanner. */ if (result[0] != 0x6) { DBG (1, "attach: device doesn't look like a scanner at all.\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } /* * The BlackWidow BW4800SP is actually a rebadged AT3, with the vendor * string set to 8 spaces and the product to "Flatbed Scanner ". So, * if we have one of these, we'll make it look like an AT3. * * For now, to be on the safe side, we'll also check the version number * since BlackWidow seems to have left that intact as "1.90". * * Check that result[36] == 0x00 so we don't mistake a microtek scanner. */ if ((result[36] == 0x00) && (strncmp (result + 32, "1.90", 4) == 0) && (strncmp (result + 8, " ", 8) == 0) && (strncmp (result + 16, "Flatbed Scanner ", 16) == 0)) { DBG (6, "Found BlackWidow BW4800SP scanner, setting up like AT3\n"); /* setup the vendor and product to mimic the Artec/Ultima AT3 */ memcpy (result + 8, "ULTIMA", 6); memcpy (result + 16, "AT3 ", 16); } /* * The Plustek 19200S is actually a rebadged AM12S, with the vendor string * set to 8 spaces. */ if ((strncmp (result + 8, " ", 8) == 0) && (strncmp (result + 16, "SCAN19200 ", 16) == 0)) { DBG (6, "Found Plustek 19200S scanner, setting up like AM12S\n"); /* setup the vendor and product to mimic the Artec/Ultima AM12S */ memcpy (result + 8, "ULTIMA", 6); memcpy (result + 16, "AM12S ", 16); } /* * Check to see if they have forced a vendor and/or model string and * if so, fudge the inquiry results with that info. We do this right * before we check the inquiry results, otherwise we might not be forcing * anything. */ if (artec_vendor[0] != 0x0) { /* * 1) copy the vendor string to our temp variable * 2) append 8 spaces to make sure we have at least 8 characters * 3) copy our fudged vendor string into the inquiry result. */ strcpy (temp_result, artec_vendor); strcat (temp_result, " "); strncpy (result + 8, temp_result, 8); } if (artec_model[0] != 0x0) { /* * 1) copy the model string to our temp variable * 2) append 16 spaces to make sure we have at least 16 characters * 3) copy our fudged model string into the inquiry result. */ strcpy (temp_result, artec_model); strcat (temp_result, " "); strncpy (result + 16, temp_result, 16); } /* are we really dealing with a scanner by ULTIMA/ARTEC? */ if ((strncmp (result + 8, "ULTIMA", 6) != 0) && (strncmp (result + 8, "ARTEC", 5) != 0)) { DBG (1, "attach: device doesn't look like a Artec/ULTIMA scanner\n"); strncpy (temp_result, result + 8, 8); temp_result[8] = 0x0; DBG (1, "attach: FOUND vendor = '%s'\n", temp_result); strncpy (temp_result, result + 16, 16); temp_result[16] = 0x0; DBG (1, "attach: FOUND model = '%s'\n", temp_result); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } /* turn this wait OFF for now since it appears to cause problems with */ /* AT12 models */ /* turned off by creating an "if" that can never be true */ if ( 1 == 2 ) { DBG (6, "attach: wait for scanner to come ready\n"); status = wait_ready (fd); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: test unit ready failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (fd); return (status); } /* This is the end of the "if" that can never be true that in effect */ /* comments out this wait_ready() call */ } /* end of "if( 1 == 2 )" */ dev = malloc (sizeof (*dev)); if (!dev) return (SANE_STATUS_NO_MEM); memset (dev, 0, sizeof (*dev)); if (DBG_LEVEL >= 4) dump_inquiry ((unsigned char *) result); dev->sane.name = strdup (devname); /* get the model info */ str = malloc (17); memcpy (str, result + 16, 16); str[16] = ' '; t = str + 16; while ((*t == ' ') && (t > str)) { *t = '\0'; t--; } dev->sane.model = str; /* for some reason, the firmware revision is in the model info string on */ /* the A6000C PLUS scanners instead of in it's proper place */ if (strstr (str, "A6000C PLUS") == str) { str[11] = '\0'; strncpy (product_revision, str + 12, 4); } else if (strstr (str, "AT3") == str) { str[3] = '\0'; strncpy (product_revision, str + 8, 4); } else { /* get the product revision from it's normal place */ strncpy (product_revision, result + 32, 4); } product_revision[4] = ' '; t = strchr (product_revision, ' '); if (t) *t = '\0'; else t = "unknown revision"; /* get the vendor info */ str = malloc (9); memcpy (str, result + 8, 8); str[8] = ' '; t = strchr (str, ' '); *t = '\0'; dev->sane.vendor = str; DBG (5, "scanner vendor: '%s', model: '%s', revision: '%s'\n", dev->sane.vendor, dev->sane.model, product_revision); /* Artec docs say if bytes 36-43 = "ULTIMA ", then supports read cap. data */ if (strncmp (result + 36, "ULTIMA ", 8) == 0) { DBG (5, "scanner supports read capability data function\n"); dev->support_cap_data_retrieve = SANE_TRUE; } else { DBG (5, "scanner does NOT support read capability data function\n"); dev->support_cap_data_retrieve = SANE_FALSE; } DBG (6, "attach: getting scanner capability data\n"); status = artec_get_cap_data (dev, fd); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: artec_get_cap_data failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (fd); return (status); } sanei_scsi_close (fd); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; return (SANE_STATUS_GOOD); } static SANE_Status init_options (ARTEC_Scanner * s) { int i; DBG (7, "init_options()\n"); memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = "Scan Mode"; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].s = strdup (mode_list[3]); /* horizontal resolution */ s->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_X_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_X_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_X_RESOLUTION].constraint.word_list = s->hw->horz_resolution_list; s->val[OPT_X_RESOLUTION].w = 100; /* vertical resolution */ s->opt[OPT_Y_RESOLUTION].name = SANE_NAME_SCAN_Y_RESOLUTION; s->opt[OPT_Y_RESOLUTION].title = SANE_TITLE_SCAN_Y_RESOLUTION; s->opt[OPT_Y_RESOLUTION].desc = SANE_DESC_SCAN_Y_RESOLUTION; s->opt[OPT_Y_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_Y_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_Y_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_Y_RESOLUTION].constraint.word_list = s->hw->vert_resolution_list; s->opt[OPT_Y_RESOLUTION].cap |= SANE_CAP_INACTIVE; s->val[OPT_Y_RESOLUTION].w = 100; /* bind resolution */ s->opt[OPT_RESOLUTION_BIND].name = SANE_NAME_RESOLUTION_BIND; s->opt[OPT_RESOLUTION_BIND].title = SANE_TITLE_RESOLUTION_BIND; s->opt[OPT_RESOLUTION_BIND].desc = SANE_DESC_RESOLUTION_BIND; s->opt[OPT_RESOLUTION_BIND].type = SANE_TYPE_BOOL; s->val[OPT_RESOLUTION_BIND].w = SANE_TRUE; if (!(s->hw->flags & ARTEC_FLAG_SEPARATE_RES)) s->opt[OPT_RESOLUTION_BIND].cap |= SANE_CAP_INACTIVE; /* Preview Mode */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->opt[OPT_PREVIEW].unit = SANE_UNIT_NONE; s->opt[OPT_PREVIEW].size = sizeof (SANE_Word); s->val[OPT_PREVIEW].w = SANE_FALSE; /* Grayscale Preview Mode */ s->opt[OPT_GRAY_PREVIEW].name = SANE_NAME_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].title = SANE_TITLE_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].desc = SANE_DESC_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].type = SANE_TYPE_BOOL; s->opt[OPT_GRAY_PREVIEW].unit = SANE_UNIT_NONE; s->opt[OPT_GRAY_PREVIEW].size = sizeof (SANE_Word); s->val[OPT_GRAY_PREVIEW].w = SANE_FALSE; /* negative */ s->opt[OPT_NEGATIVE].name = SANE_NAME_NEGATIVE; s->opt[OPT_NEGATIVE].title = SANE_TITLE_NEGATIVE; s->opt[OPT_NEGATIVE].desc = "Negative Image"; s->opt[OPT_NEGATIVE].type = SANE_TYPE_BOOL; s->val[OPT_NEGATIVE].w = SANE_FALSE; if (!(s->hw->flags & ARTEC_FLAG_MBPP_NEGATIVE)) { s->opt[OPT_NEGATIVE].cap |= SANE_CAP_INACTIVE; } /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->val[OPT_TL_X].w = s->hw->x_range.min; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->val[OPT_TL_Y].w = s->hw->y_range.min; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->val[OPT_BR_X].w = s->hw->x_range.max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; s->val[OPT_BR_Y].w = s->hw->y_range.max; /* Enhancement group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* filter mode */ s->opt[OPT_FILTER_TYPE].name = "filter-type"; s->opt[OPT_FILTER_TYPE].title = "Filter Type"; s->opt[OPT_FILTER_TYPE].desc = "Filter Type for mono scans"; s->opt[OPT_FILTER_TYPE].type = SANE_TYPE_STRING; s->opt[OPT_FILTER_TYPE].size = max_string_size (filter_type_list); s->opt[OPT_FILTER_TYPE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_FILTER_TYPE].constraint.string_list = filter_type_list; s->val[OPT_FILTER_TYPE].s = strdup (filter_type_list[0]); s->opt[OPT_FILTER_TYPE].cap |= SANE_CAP_INACTIVE; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_INT; s->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &s->hw->brightness_range; s->val[OPT_CONTRAST].w = 0x80; if (!(s->hw->flags & ARTEC_FLAG_OPT_CONTRAST)) { s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; } /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &s->hw->contrast_range; s->val[OPT_BRIGHTNESS].w = 0x80; if (!(s->hw->flags & ARTEC_FLAG_OPT_BRIGHTNESS)) { s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_INACTIVE; } /* threshold */ s->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; s->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; s->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; s->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &s->hw->threshold_range; s->val[OPT_THRESHOLD].w = 0x80; s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; /* halftone pattern */ s->opt[OPT_HALFTONE_PATTERN].name = SANE_NAME_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].title = SANE_TITLE_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].desc = SANE_DESC_HALFTONE_PATTERN; s->opt[OPT_HALFTONE_PATTERN].type = SANE_TYPE_STRING; s->opt[OPT_HALFTONE_PATTERN].size = max_string_size (halftone_pattern_list); s->opt[OPT_HALFTONE_PATTERN].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_HALFTONE_PATTERN].constraint.string_list = halftone_pattern_list; s->val[OPT_HALFTONE_PATTERN].s = strdup (halftone_pattern_list[1]); s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; /* pixel averaging */ s->opt[OPT_PIXEL_AVG].name = "pixel-avg"; s->opt[OPT_PIXEL_AVG].title = "Pixel Averaging"; s->opt[OPT_PIXEL_AVG].desc = "Enable HardWare Pixel Averaging function"; s->opt[OPT_PIXEL_AVG].type = SANE_TYPE_BOOL; s->val[OPT_PIXEL_AVG].w = SANE_FALSE; if (!(s->hw->flags & ARTEC_FLAG_PIXEL_AVERAGING)) { s->opt[OPT_PIXEL_AVG].cap |= SANE_CAP_INACTIVE; } /* lineart line edge enhancement */ s->opt[OPT_EDGE_ENH].name = "edge-enh"; s->opt[OPT_EDGE_ENH].title = "Line Edge Enhancement"; s->opt[OPT_EDGE_ENH].desc = "Enable HardWare Lineart Line Edge Enhancement"; s->opt[OPT_EDGE_ENH].type = SANE_TYPE_BOOL; s->val[OPT_EDGE_ENH].w = SANE_FALSE; s->opt[OPT_EDGE_ENH].cap |= SANE_CAP_INACTIVE; /* custom-gamma table */ s->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; s->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* grayscale gamma vector */ s->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR].wa = &(s->gamma_table[0][0]); s->opt[OPT_GAMMA_VECTOR].constraint.range = &u8_range; s->opt[OPT_GAMMA_VECTOR].size = s->gamma_length * sizeof (SANE_Word); /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_R].wa = &(s->gamma_table[1][0]); s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &(s->gamma_range); s->opt[OPT_GAMMA_VECTOR_R].size = s->gamma_length * sizeof (SANE_Word); /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_G].wa = &(s->gamma_table[2][0]); s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &(s->gamma_range); s->opt[OPT_GAMMA_VECTOR_G].size = s->gamma_length * sizeof (SANE_Word); /* blue gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_GAMMA_VECTOR_B].wa = &(s->gamma_table[3][0]); s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &(s->gamma_range); s->opt[OPT_GAMMA_VECTOR_B].size = s->gamma_length * sizeof (SANE_Word); if (s->hw->flags & ARTEC_FLAG_GAMMA_SINGLE) { s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } if (!(s->hw->flags & ARTEC_FLAG_GAMMA)) { s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; } /* transparency */ s->opt[OPT_TRANSPARENCY].name = "transparency"; s->opt[OPT_TRANSPARENCY].title = "Transparency"; s->opt[OPT_TRANSPARENCY].desc = "Use transparency adaptor"; s->opt[OPT_TRANSPARENCY].type = SANE_TYPE_BOOL; s->val[OPT_TRANSPARENCY].w = SANE_FALSE; /* ADF */ s->opt[OPT_ADF].name = "adf"; s->opt[OPT_ADF].title = "ADF"; s->opt[OPT_ADF].desc = "Use ADF"; s->opt[OPT_ADF].type = SANE_TYPE_BOOL; s->val[OPT_ADF].w = SANE_FALSE; /* Calibration group: */ s->opt[OPT_CALIBRATION_GROUP].title = "Calibration"; s->opt[OPT_CALIBRATION_GROUP].desc = ""; s->opt[OPT_CALIBRATION_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_CALIBRATION_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_CALIBRATION_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* Calibrate Every Scan? */ s->opt[OPT_QUALITY_CAL].name = SANE_NAME_QUALITY_CAL; s->opt[OPT_QUALITY_CAL].title = "Hardware Calibrate Every Scan"; s->opt[OPT_QUALITY_CAL].desc = "Perform hardware calibration on every scan"; s->opt[OPT_QUALITY_CAL].type = SANE_TYPE_BOOL; s->val[OPT_QUALITY_CAL].w = SANE_FALSE; if (!(s->hw->flags & ARTEC_FLAG_CALIBRATE)) { s->opt[OPT_QUALITY_CAL].cap |= SANE_CAP_INACTIVE; } /* Perform Software Quality Calibration */ s->opt[OPT_SOFTWARE_CAL].name = "software-cal"; s->opt[OPT_SOFTWARE_CAL].title = "Software Color Calibration"; s->opt[OPT_SOFTWARE_CAL].desc = "Perform software quality calibration in " "addition to hardware calibration"; s->opt[OPT_SOFTWARE_CAL].type = SANE_TYPE_BOOL; s->val[OPT_SOFTWARE_CAL].w = SANE_FALSE; /* check for RGB calibration now because we have only implemented software */ /* calibration in conjunction with hardware RGB calibration */ if ((!(s->hw->flags & ARTEC_FLAG_CALIBRATE)) || (!(s->hw->flags & ARTEC_FLAG_CALIBRATE_RGB))) { s->opt[OPT_SOFTWARE_CAL].cap |= SANE_CAP_INACTIVE; } return (SANE_STATUS_GOOD); } static SANE_Status do_cancel (ARTEC_Scanner * s) { DBG (7, "do_cancel()\n"); s->scanning = SANE_FALSE; /* DAL: Terminate a three pass scan properly */ /* if (s->this_pass == 3) */ s->this_pass = 0; if ((s->hw->flags & ARTEC_FLAG_RGB_LINE_OFFSET) && (tmp_line_buf != NULL)) { artec_buffer_line_offset_free (); } if (s->fd >= 0) { sanei_scsi_close (s->fd); s->fd = -1; } return (SANE_STATUS_CANCELLED); } static SANE_Status attach_one (const char *dev) { DBG (7, "attach_one()\n"); attach (dev, 0); return (SANE_STATUS_GOOD); } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char dev_name[PATH_MAX], *cp; size_t len; FILE *fp; DBG_INIT (); DBG (1, "Artec/Ultima backend version %d.%d.%d, last mod: %s\n", ARTEC_MAJOR, ARTEC_MINOR, ARTEC_SUB, ARTEC_LAST_MOD); DBG (1, "http://www4.infi.net/~cpinkham/sane-artec-doc.html\n"); DBG (7, "sane_init()\n" ); devlist = 0; /* make sure these 2 are empty */ strcpy (artec_vendor, ""); strcpy (artec_model, ""); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); if (authorize) DBG (7, "sane_init(), authorize %s null\n", (authorize) ? "!=" : "=="); fp = sanei_config_open (ARTEC_CONFIG_FILE); if (!fp) { /* default to /dev/scanner instead of insisting on config file */ attach ("/dev/scanner", 0); return (SANE_STATUS_GOOD); } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { cp = artec_skip_whitespace (dev_name); /* ignore line comments and blank lines */ if ((!*cp) || (*cp == '#')) continue; len = strlen (cp); /* ignore empty lines */ if (!len) continue; DBG (50, "%s line: '%s', len = %lu\n", ARTEC_CONFIG_FILE, cp, (u_long) len); /* check to see if they forced a vendor string in artec.conf */ if ((strncmp (cp, "vendor", 6) == 0) && isspace (cp[6])) { cp += 7; cp = artec_skip_whitespace (cp); strcpy (artec_vendor, cp); DBG (5, "sane_init: Forced vendor string '%s' in %s.\n", cp, ARTEC_CONFIG_FILE); } /* OK, maybe they forced the model string in artec.conf */ else if ((strncmp (cp, "model", 5) == 0) && isspace (cp[5])) { cp += 6; cp = artec_skip_whitespace (cp); strcpy (artec_model, cp); DBG (5, "sane_init: Forced model string '%s' in %s.\n", cp, ARTEC_CONFIG_FILE); } /* well, nothing else to do but attempt the attach */ else { sanei_config_attach_matching_devices (dev_name, attach_one); strcpy (artec_vendor, ""); strcpy (artec_model, ""); } } fclose (fp); return (SANE_STATUS_GOOD); } void sane_exit (void) { ARTEC_Device *dev, *next; DBG (7, "sane_exit()\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free ((void *) dev->sane.name); free ((void *) dev->sane.model); free (dev); } if (devlist) free (devlist); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { ARTEC_Device *dev; int i; DBG (7, "sane_get_devices( device_list, local_only = %d )\n", local_only ); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return (SANE_STATUS_GOOD); } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { SANE_Status status; ARTEC_Device *dev; ARTEC_Scanner *s; int i, j; DBG (7, "sane_open()\n"); if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; if (!dev) { status = attach (devicename, &dev); if (status != SANE_STATUS_GOOD) return (status); } } else { /* empty devicname -> use first device */ dev = first_dev; } if (!dev) return SANE_STATUS_INVAL; s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->fd = -1; s->hw = dev; s->this_pass = 0; s->gamma_length = s->hw->gamma_length; s->gamma_range.min = 0; s->gamma_range.max = s->gamma_length - 1; s->gamma_range.quant = 0; /* not sure if I need this or not, it was in the umax backend though. :-) */ for (j = 0; j < s->gamma_length; ++j) { s->gamma_table[0][j] = j * (s->gamma_length - 1) / s->gamma_length; } for (i = 1; i < 4; i++) { for (j = 0; j < s->gamma_length; ++j) { s->gamma_table[i][j] = j; } } init_options (s); /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; if (s->hw->flags & ARTEC_FLAG_CALIBRATE) { status = sanei_scsi_open (s->hw->sane.name, &s->fd, 0, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "error opening scanner for initial calibration: %s\n", sane_strstatus (status)); s->fd = -1; return status; } status = artec_calibrate_shading (s); if (status != SANE_STATUS_GOOD) { DBG (1, "initial shading calibration failed: %s\n", sane_strstatus (status)); sanei_scsi_close (s->fd); s->fd = -1; return status; } sanei_scsi_close (s->fd); } return (SANE_STATUS_GOOD); } void sane_close (SANE_Handle handle) { ARTEC_Scanner *prev, *s; DBG (7, "sane_close()\n"); if ((DBG_LEVEL == 101) && (debug_fd > -1)) { close (debug_fd); DBG (101, "closed artec.data.raw output file\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) { DBG (1, "close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (s->scanning) do_cancel (handle); if (prev) prev->next = s->next; else first_handle = s->next; free (handle); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { ARTEC_Scanner *s = handle; DBG (7, "sane_get_option_descriptor()\n"); if (((unsigned) option >= NUM_OPTIONS) || (option < 0 )) return (0); return (s->opt + option); } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { ARTEC_Scanner *s = handle; SANE_Status status; SANE_Word w, cap; DBG (7, "sane_control_option()\n"); if (info) *info = 0; if (s->scanning) return SANE_STATUS_DEVICE_BUSY; if (s->this_pass) return SANE_STATUS_DEVICE_BUSY; if (option >= NUM_OPTIONS) return SANE_STATUS_INVAL; cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) return SANE_STATUS_INVAL; if (action == SANE_ACTION_GET_VALUE) { DBG (13, "sane_control_option %d, get value\n", option); switch (option) { /* word options: */ case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_PREVIEW: case OPT_GRAY_PREVIEW: case OPT_RESOLUTION_BIND: case OPT_NEGATIVE: case OPT_TRANSPARENCY: case OPT_ADF: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_QUALITY_CAL: case OPT_SOFTWARE_CAL: case OPT_CONTRAST: case OPT_BRIGHTNESS: case OPT_THRESHOLD: case OPT_CUSTOM_GAMMA: case OPT_PIXEL_AVG: case OPT_EDGE_ENH: *(SANE_Word *) val = s->val[option].w; return (SANE_STATUS_GOOD); /* string options: */ case OPT_MODE: case OPT_FILTER_TYPE: case OPT_HALFTONE_PATTERN: strcpy (val, s->val[option].s); return (SANE_STATUS_GOOD); /* word array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (val, s->val[option].wa, s->opt[option].size); return (SANE_STATUS_GOOD); } } else if (action == SANE_ACTION_SET_VALUE) { DBG (13, "sane_control_option %d, set value\n", option); if (!SANE_OPTION_IS_SETTABLE (cap)) return (SANE_STATUS_INVAL); status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) return (status); switch (option) { /* (mostly) side-effect-free word options: */ case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_BR_X: case OPT_BR_Y: case OPT_TL_X: case OPT_TL_Y: if (info && s->val[option].w != *(SANE_Word *) val) *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_PREVIEW: case OPT_GRAY_PREVIEW: case OPT_QUALITY_CAL: case OPT_SOFTWARE_CAL: case OPT_NUM_OPTS: case OPT_NEGATIVE: case OPT_TRANSPARENCY: case OPT_ADF: case OPT_CONTRAST: case OPT_BRIGHTNESS: case OPT_THRESHOLD: case OPT_PIXEL_AVG: case OPT_EDGE_ENH: s->val[option].w = *(SANE_Word *) val; return (SANE_STATUS_GOOD); case OPT_MODE: { if (s->val[option].s) free (s->val[option].s); s->val[option].s = (SANE_Char *) strdup (val); if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; s->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* options INvisible by default */ s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HALFTONE_PATTERN].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SOFTWARE_CAL].cap |= SANE_CAP_INACTIVE; s->opt[OPT_EDGE_ENH].cap |= SANE_CAP_INACTIVE; /* options VISIBLE by default */ s->opt[OPT_CONTRAST].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_FILTER_TYPE].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_NEGATIVE].cap &= ~SANE_CAP_INACTIVE; if (strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) == 0) { /* Lineart mode */ s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; /* OFF */ s->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; if (s->hw->flags & ARTEC_FLAG_ENHANCE_LINE_EDGE) s->opt[OPT_EDGE_ENH].cap &= ~SANE_CAP_INACTIVE; } else if (strcmp (val, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) { /* Halftone mode */ if (s->hw->flags & ARTEC_FLAG_HALFTONE_PATTERN) s->opt[OPT_HALFTONE_PATTERN].cap &= ~SANE_CAP_INACTIVE; } else if (strcmp (val, SANE_VALUE_SCAN_MODE_GRAY) == 0) { /* Grayscale mode */ if (!(s->hw->flags & ARTEC_FLAG_MBPP_NEGATIVE)) { s->opt[OPT_NEGATIVE].cap |= SANE_CAP_INACTIVE; } } else if (strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) == 0) { /* Color mode */ s->opt[OPT_FILTER_TYPE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SOFTWARE_CAL].cap &= ~SANE_CAP_INACTIVE; if (!(s->hw->flags & ARTEC_FLAG_MBPP_NEGATIVE)) { s->opt[OPT_NEGATIVE].cap |= SANE_CAP_INACTIVE; } } } return (SANE_STATUS_GOOD); case OPT_FILTER_TYPE: case OPT_HALFTONE_PATTERN: if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); return (SANE_STATUS_GOOD); case OPT_RESOLUTION_BIND: if (s->val[option].w != *(SANE_Word *) val) { s->val[option].w = *(SANE_Word *) val; if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; } if (s->val[option].w == SANE_FALSE) { /* don't bind */ s->opt[OPT_Y_RESOLUTION].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_X_RESOLUTION; s->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_X_RESOLUTION; } else { /* bind */ s->opt[OPT_Y_RESOLUTION].cap |= SANE_CAP_INACTIVE; s->opt[OPT_X_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; } } return (SANE_STATUS_GOOD); /* side-effect-free word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (s->val[option].wa, val, s->opt[option].size); return (SANE_STATUS_GOOD); /* options with side effects: */ case OPT_CUSTOM_GAMMA: w = *(SANE_Word *) val; if (w == s->val[OPT_CUSTOM_GAMMA].w) return (SANE_STATUS_GOOD); s->val[OPT_CUSTOM_GAMMA].w = w; if (w) /* use custom_gamma_table */ { const char *mode = s->val[OPT_MODE].s; if ((strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) || (strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) || (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0)) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; } else if (strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; if (!(s->hw->flags & ARTEC_FLAG_GAMMA_SINGLE)) { s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } } else /* don't use custom_gamma_table */ { s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } if (info) *info |= SANE_INFO_RELOAD_OPTIONS; return (SANE_STATUS_GOOD); } } return (SANE_STATUS_INVAL); } static void set_pass_parameters (SANE_Handle handle) { ARTEC_Scanner *s = handle; DBG (7, "set_pass_parameters()\n"); if (s->threepasscolor) { s->this_pass += 1; DBG (9, "set_pass_parameters: three-pass, on %d\n", s->this_pass); switch (s->this_pass) { case 1: s->params.format = SANE_FRAME_RED; s->params.last_frame = SANE_FALSE; break; case 2: s->params.format = SANE_FRAME_GREEN; s->params.last_frame = SANE_FALSE; break; case 3: s->params.format = SANE_FRAME_BLUE; s->params.last_frame = SANE_TRUE; break; default: DBG (9, "set_pass_parameters: What?!? pass %d = filter?\n", s->this_pass); break; } } else s->this_pass = 0; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { ARTEC_Scanner *s = handle; DBG (7, "sane_get_parameters()\n"); if (!s->scanning) { double width, height; memset (&s->params, 0, sizeof (s->params)); s->x_resolution = s->val[OPT_X_RESOLUTION].w; s->y_resolution = s->val[OPT_Y_RESOLUTION].w; if ((s->val[OPT_RESOLUTION_BIND].w == SANE_TRUE) || (s->val[OPT_PREVIEW].w == SANE_TRUE)) { s->y_resolution = s->x_resolution; } s->tl_x = SANE_UNFIX (s->val[OPT_TL_X].w) / MM_PER_INCH * s->x_resolution; s->tl_y = SANE_UNFIX (s->val[OPT_TL_Y].w) / MM_PER_INCH * s->y_resolution; width = SANE_UNFIX (s->val[OPT_BR_X].w - s->val[OPT_TL_X].w); height = SANE_UNFIX (s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w); if ((s->x_resolution > 0.0) && (s->y_resolution > 0.0) && (width > 0.0) && (height > 0.0)) { s->params.pixels_per_line = width * s->x_resolution / MM_PER_INCH + 1; s->params.lines = height * s->y_resolution / MM_PER_INCH + 1; } s->onepasscolor = SANE_FALSE; s->threepasscolor = SANE_FALSE; s->params.last_frame = SANE_TRUE; if ((s->val[OPT_PREVIEW].w == SANE_TRUE) && (s->val[OPT_GRAY_PREVIEW].w == SANE_TRUE)) { s->mode = SANE_VALUE_SCAN_MODE_GRAY; } else { s->mode = s->val[OPT_MODE].s; } if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) || (strcmp (s->mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0)) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = (s->params.pixels_per_line + 7) / 8; s->params.depth = 1; s->line_offset = 0; /* round pixels_per_line up to the next full byte of pixels */ /* this way we don't have to do bit buffering, pixels_per_line is */ /* what is used in the set window command. */ /* SANE expects the last byte in a line to be padded if it's not */ /* full, so this should not affect scans in a negative way */ s->params.pixels_per_line = s->params.bytes_per_line * 8; } else if (strcmp (s->mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; s->line_offset = 0; } else { s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; if (s->hw->flags & ARTEC_FLAG_ONE_PASS_SCANNER) { s->onepasscolor = SANE_TRUE; s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line *= 3; /* * line offsets from documentation. * (I don't yet see a common formula I can easily use) */ /* FIXME: figure out a cleaner way to do this... */ s->line_offset = 0; /* default */ if ((!strcmp (s->hw->sane.model, "AT3")) || (!strcmp (s->hw->sane.model, "A6000C")) || (!strcmp (s->hw->sane.model, "A6000C PLUS")) || (!strcmp (s->hw->sane.model, "AT6"))) { /* formula #1 */ /* ranges from 1 at 50dpi to 16 at 600dpi */ s->line_offset = 8 * (s->y_resolution / 300.0); } else if (!strcmp (s->hw->sane.model, "AT12")) { /* formula #2 */ /* ranges from 0 at 25dpi to 16 at 1200dpi */ /***********************************************************/ /* this should be handled in hardware for now, so leave it */ /* sitting at zero for now. */ /***********************************************************/ /* s->line_offset = 16 * ( s->y_resolution / 1200.0 ); */ } else if (!strcmp (s->hw->sane.model, "AM12S")) { /* formula #3 */ /* ranges from 0 at 50dpi to 8 at 1200dpi */ s->line_offset = 8 * (s->y_resolution / 1200.0); } } else { s->params.last_frame = SANE_FALSE; s->threepasscolor = SANE_TRUE; s->line_offset = 0; } } } if (params) *params = s->params; return (SANE_STATUS_GOOD); } SANE_Status sane_start (SANE_Handle handle) { ARTEC_Scanner *s = handle; SANE_Status status; DBG (7, "sane_start()\n"); if (debug_fd != -1) { close (debug_fd); debug_fd = -1; } if (DBG_LEVEL == 101) { debug_fd = open ("artec.data.raw", O_WRONLY | O_CREAT | O_TRUNC, 0666); if (debug_fd > -1) DBG (101, "opened artec.data.raw output file\n"); } /* First make sure we have a current parameter set. Some of the */ /* parameters will be overwritten below, but that's OK. */ status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; /* DAL: For 3 pass colour set the current pass parameters */ if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) && s->threepasscolor) set_pass_parameters (s); /* DAL: For single pass scans and the first pass of a 3 pass scan */ if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) != 0) || (!s->threepasscolor) || ((s->threepasscolor) && (s->this_pass == 1))) { if (s->hw->flags & ARTEC_FLAG_SENSE_HANDLER) { status = sanei_scsi_open (s->hw->sane.name, &s->fd, sense_handler, (void *)s); } else { status = sanei_scsi_open (s->hw->sane.name, &s->fd, 0, 0); } if (status != SANE_STATUS_GOOD) { DBG (1, "open of %s failed: %s\n", s->hw->sane.name, sane_strstatus (status)); return status; } /* DB added wait_ready */ status = wait_ready (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "wait for scanner ready failed: %s\n", sane_strstatus (status)); return status; } } s->bytes_to_read = s->params.bytes_per_line * s->params.lines; DBG (9, "%d pixels per line, %d bytes, %d lines high, xdpi = %d, " "ydpi = %d, btr = %lu\n", s->params.pixels_per_line, s->params.bytes_per_line, s->params.lines, s->x_resolution, s->y_resolution, (u_long) s->bytes_to_read); /* DAL: For single pass scans and the first pass of a 3 pass scan */ if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) != 0) || !s->threepasscolor || (s->threepasscolor && s->this_pass == 1)) { /* do a calibrate if scanner requires/recommends it */ if ((s->hw->flags & ARTEC_FLAG_CALIBRATE) && (s->val[OPT_QUALITY_CAL].w == SANE_TRUE)) { status = artec_calibrate_shading (s); if (status != SANE_STATUS_GOOD) { DBG (1, "shading calibration failed: %s\n", sane_strstatus (status)); return status; } } /* DB added wait_ready */ status = wait_ready (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "wait for scanner ready failed: %s\n", sane_strstatus (status)); return status; } /* send the custom gamma table if we have one */ if (s->hw->flags & ARTEC_FLAG_GAMMA) artec_send_gamma_table (s); /* now set our scan window */ status = artec_set_scan_window (s); if (status != SANE_STATUS_GOOD) { DBG (1, "set scan window failed: %s\n", sane_strstatus (status)); return status; } /* DB added wait_ready */ status = wait_ready (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "wait for scanner ready failed: %s\n", sane_strstatus (status)); return status; } } /* now we can start the actual scan */ /* DAL: For single pass scans and the first pass of a 3 pass scan */ if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) != 0) || (!s->threepasscolor) || (s->this_pass == 1)) { /* DAL - do mode select before each scan */ /* The mode is NOT turned off at the end of the scan */ artec_mode_select (s); status = artec_start_scan (s); if (status != SANE_STATUS_GOOD) { DBG (1, "start scan: %s\n", sane_strstatus (status)); return status; } } s->scanning = SANE_TRUE; return (SANE_STATUS_GOOD); } #if 0 static void binout (SANE_Byte byte) { SANE_Byte b = byte; int bit; for (bit = 0; bit < 8; bit++) { DBG (9, "%d", b & 128 ? 1 : 0); b = b << 1; } } #endif static SANE_Status artec_sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { ARTEC_Scanner *s = handle; SANE_Status status; size_t nread; size_t lread; size_t bytes_read; size_t rows_read; size_t max_read_rows; size_t max_ret_rows; size_t remaining_rows; size_t rows_available; size_t line; SANE_Byte temp_buf[ARTEC_MAX_READ_SIZE]; SANE_Byte line_buf[ARTEC_MAX_READ_SIZE]; DBG (7, "artec_sane_read( %p, %p, %d, %d )\n", handle, buf, max_len, *len); *len = 0; if (s->bytes_to_read == 0) { if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) != 0) || !s->threepasscolor || (s->threepasscolor && s->this_pass == 3)) { do_cancel (s); /* without this a 4th pass is attempted, yet do_cancel does this */ s->scanning = SANE_FALSE; } return (SANE_STATUS_EOF); } if (!s->scanning) return do_cancel (s); remaining_rows = (s->bytes_to_read + s->params.bytes_per_line - 1) / s->params.bytes_per_line; max_read_rows = s->hw->max_read_size / s->params.bytes_per_line; max_ret_rows = max_len / s->params.bytes_per_line; while (artec_get_status (s->fd) == 0) { DBG (120, "hokey loop till data available\n"); usleep (50000); /* sleep for .05 second */ } rows_read = 0; bytes_read = 0; while ((rows_read < max_ret_rows) && (rows_read < remaining_rows)) { DBG (50, "top of while loop, rr = %lu, mrr = %lu, rem = %lu\n", (u_long) rows_read, (u_long) max_ret_rows, (u_long) remaining_rows); if (s->bytes_to_read - bytes_read <= s->params.bytes_per_line * max_read_rows) { nread = s->bytes_to_read - bytes_read; } else { nread = s->params.bytes_per_line * max_read_rows; } lread = nread / s->params.bytes_per_line; if ((max_read_rows - rows_read) < lread) { lread = max_read_rows - rows_read; nread = lread * s->params.bytes_per_line; } if ((max_ret_rows - rows_read) < lread) { lread = max_ret_rows - rows_read; nread = lread * s->params.bytes_per_line; } while ((rows_available = artec_get_status (s->fd)) == 0) { DBG (120, "hokey loop till data available\n"); usleep (50000); /* sleep for .05 second */ } if (rows_available < lread) { lread = rows_available; nread = lread * s->params.bytes_per_line; } /* This should never happen, but just in case... */ if (nread > (s->bytes_to_read - bytes_read)) { nread = s->bytes_to_read - bytes_read; lread = 1; } DBG (50, "rows_available = %lu, params.lines = %d, bytes_per_line = %d\n", (u_long) rows_available, s->params.lines, s->params.bytes_per_line); DBG (50, "bytes_to_read = %lu, max_len = %d, max_rows = %lu\n", (u_long) s->bytes_to_read, max_len, (u_long) max_ret_rows); DBG (50, "nread = %lu, lread = %lu, bytes_read = %lu, rows_read = %lu\n", (u_long) nread, (u_long) lread, (u_long) bytes_read, (u_long) rows_read); status = read_data (s->fd, ARTEC_DATA_IMAGE, temp_buf, &nread); if (status != SANE_STATUS_GOOD) { end_scan (s); do_cancel (s); return (SANE_STATUS_IO_ERROR); } if ((DBG_LEVEL == 101) && (debug_fd > -1)) { write (debug_fd, temp_buf, nread); } if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) && (s->hw->flags & ARTEC_FLAG_RGB_LINE_OFFSET)) { for (line = 0; line < lread; line++) { memcpy (line_buf, temp_buf + (line * s->params.bytes_per_line), s->params.bytes_per_line); nread = s->params.bytes_per_line; artec_buffer_line_offset (s, s->line_offset, line_buf, &nread); if (nread > 0) { if (s->hw->flags & ARTEC_FLAG_RGB_CHAR_SHIFT) { artec_line_rgb_to_byte_rgb (line_buf, s->params.pixels_per_line); } if (s->hw->flags & ARTEC_FLAG_IMAGE_REV_LR) { artec_reverse_line (s, line_buf); } /* do software calibration if necessary */ if (s->val[OPT_SOFTWARE_CAL].w) { artec_software_rgb_calibrate (s, line_buf, 1); } memcpy (buf + bytes_read, line_buf, s->params.bytes_per_line); bytes_read += nread; rows_read++; } } } else { if ((s->hw->flags & ARTEC_FLAG_IMAGE_REV_LR) || ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) && (s->hw->flags & ARTEC_FLAG_RGB_CHAR_SHIFT))) { for (line = 0; line < lread; line++) { if ((strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) && (s->hw->flags & ARTEC_FLAG_RGB_CHAR_SHIFT)) { artec_line_rgb_to_byte_rgb (temp_buf + (line * s->params.bytes_per_line), s->params.pixels_per_line); } if (s->hw->flags & ARTEC_FLAG_IMAGE_REV_LR) { artec_reverse_line (s, temp_buf + (line * s->params.bytes_per_line)); } } } /* do software calibration if necessary */ if ((s->val[OPT_SOFTWARE_CAL].w) && (strcmp (s->mode, SANE_VALUE_SCAN_MODE_COLOR) == 0)) { artec_software_rgb_calibrate (s, temp_buf, lread); } memcpy (buf + bytes_read, temp_buf, nread); bytes_read += nread; rows_read += lread; } } *len = bytes_read; s->bytes_to_read -= bytes_read; DBG (9, "artec_sane_read() returning, we read %lu bytes, %lu left\n", (u_long) * len, (u_long) s->bytes_to_read); if ((s->bytes_to_read == 0) && (s->hw->flags & ARTEC_FLAG_RGB_LINE_OFFSET) && (tmp_line_buf != NULL)) { artec_buffer_line_offset_free (); } return (SANE_STATUS_GOOD); } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { ARTEC_Scanner *s = handle; SANE_Status status; int bytes_to_copy; int loop; static SANE_Byte temp_buf[ARTEC_MAX_READ_SIZE]; static int bytes_in_buf = 0; DBG (7, "sane_read( %p, %p, %d, %d )\n", handle, buf, max_len, *len); DBG (9, "sane_read: bib = %d, ml = %d\n", bytes_in_buf, max_len); if (bytes_in_buf != 0) { bytes_to_copy = max_len < bytes_in_buf ? max_len : bytes_in_buf; } else { status = artec_sane_read (s, temp_buf, s->hw->max_read_size, len); if (status != SANE_STATUS_GOOD) { return (status); } bytes_in_buf = *len; if (*len == 0) { return (SANE_STATUS_GOOD); } bytes_to_copy = max_len < s->hw->max_read_size ? max_len : s->hw->max_read_size; bytes_to_copy = *len < bytes_to_copy ? *len : bytes_to_copy; } memcpy (buf, temp_buf, bytes_to_copy); bytes_in_buf -= bytes_to_copy; *len = bytes_to_copy; DBG (9, "sane_read: btc = %d, bib now = %d\n", bytes_to_copy, bytes_in_buf); for (loop = 0; loop < bytes_in_buf; loop++) { temp_buf[loop] = temp_buf[loop + bytes_to_copy]; } return (SANE_STATUS_GOOD); } void sane_cancel (SANE_Handle handle) { ARTEC_Scanner *s = handle; DBG (7, "sane_cancel()\n"); if (s->scanning) { s->scanning = SANE_FALSE; abort_scan (s); do_cancel (s); } } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { DBG (7, "sane_set_io_mode( %p, %d )\n", handle, non_blocking); return (SANE_STATUS_UNSUPPORTED); } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { DBG (7, "sane_get_select_fd( %p, %d )\n", handle, *fd ); return (SANE_STATUS_UNSUPPORTED); } sane-backends-1.0.29/backend/pie-scsidef.h0000666000000000000000000003640713615534521015146 00000000000000/* ----------------------------------------------------------------------------- */ /* sane - Scanner Access Now Easy. pie-scsidef.h: scsi-definiton header file for PIE scanner driver. Copyright (C) 2000 Simon Munton, based on the umax-scsidef.h by Oliver Rauch & Michael Johnson 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* --------------------------------------------------------------------------------------------------------- */ #ifndef PIE_SCSIDEF_H #define PIE_SCSIDEF_H /* --------------------------------------------------------------------------------------------------------- */ /* I'm using functions derived from Eric Youngdale's scsiinfo * program here for dealing with parts of SCSI commands. */ static inline void setbitfield(unsigned char * pageaddr, int mask, int shift, int val) { *pageaddr = (*pageaddr & ~(mask << shift)) | ((val & mask) << shift); } static inline void resetbitfield(unsigned char * pageaddr, int mask, int shift, int val) { *pageaddr = (*pageaddr & ~(mask << shift)) | (((!val) & mask) << shift); } static inline int getbitfield(unsigned char * pageaddr, int mask, int shift) { return ((*pageaddr >> shift) & mask); } /* ------------------------------------------------------------------------- */ static inline int getnbyte(unsigned char * pnt, int nbytes) { unsigned int result = 0; int i; for(i=0; i= 0; i--) result = (result << 8) | (pnt[i] & 0xff); return result; } /* ------------------------------------------------------------------------- */ static inline void putnbyte(unsigned char * pnt, unsigned int value, unsigned int nbytes) { int i; for(i=nbytes-1; i>= 0; i--) { pnt[i] = value & 0xff; value = value >> 8; } } /* ------------------------------------------------------------------------- */ static inline void putnbyte1(unsigned char * pnt, unsigned int value, unsigned int nbytes) { unsigned int i; for(i=0; i< nbytes; i++) { pnt[i] = value & 0xff; value = value >> 8; } } /* --------------------------------------------------------------------------------------------------------- */ /* Not all of these are defined in scsi.h, so we'll make sure * we agree about them here... */ #define TEST_UNIT_READY 0x00 #define REQUEST_SENSE 0x03 #define INQUIRY 0x12 #define RESERVE_UNIT 0x16 #define RELEASE_UNIT 0x17 #define SCAN 0x1B #define READ 0x08 #define WRITE 0x0A #define PARAM 0x0F #define MODE 0x15 /* --------------------------------------------------------------------------------------------------------- */ #define STD_WDB_LEN 0x28 /* wdb_len if nothing is set by inquiry */ /* --------------------------------------------------------------------------------------------------------- */ /* SCSI commands */ typedef struct { unsigned char *cmd; size_t size; } scsiblk; /* --------------------------------------------------------------------------------------------------------- */ #define set_inquiry_return_size(icb,val) icb[0x04]=val static unsigned char inquiryC[] = { INQUIRY, 0x00, 0x00, 0x00, 0x7c, 0x00 }; static scsiblk inquiry = { inquiryC, sizeof(inquiryC) }; /* --------------------------------------------------------------------------------------------------------- */ #define get_inquiry_periph_qual(in) getbitfield(in, 0x07, 5) # define IN_periph_qual_lun 0x00 # define IN_periph_qual_nolun 0x03 #define get_inquiry_periph_devtype(in) getbitfield(in, 0x1f, 0) # define IN_periph_devtype_scanner 0x06 # define IN_periph_devtype_unknown 0x1f #define get_inquiry_rmb(in) getbitfield(in + 0x01, 0x01, 7) #define get_inquiry_0x01_bit6(in) getbitfield(in + 0x01, 0x01, 6) #define get_inquiry_0x01_bit5(in) getbitfield(in + 0x01, 0x01, 5) #define get_inquiry_iso_version(in) getbitfield(in + 0x02, 0x03, 6) #define get_inquiry_ecma_version(in) getbitfield(in + 0x02, 0x07, 3) #define get_inquiry_ansi_version(in) getbitfield(in + 0x02, 0x07, 0) #define get_inquiry_aenc(in) getbitfield(in + 0x03, 0x01, 7) #define get_inquiry_tmiop(in) getbitfield(in + 0x03, 0x01, 6) #define get_inquiry_0x03_bit5(in) getbitfield(in + 0x03, 0x01, 5) #define get_inquiry_0x03_bit4(in) getbitfield(in + 0x03, 0x01, 4) #define get_inquiry_response_format(in) getbitfield(in + 0x03, 0x0f, 0) # define IN_recognized 0x02 #define get_inquiry_additional_length(in) in[0x04] #define set_inquiry_length(out,n) out[0x04]=n-5 #define get_inquiry_vendor(in, buf) strncpy(buf, in + 0x08, 0x08) #define get_inquiry_product(in, buf) strncpy(buf, in + 0x10, 0x010) #define get_inquiry_version(in, buf) strncpy(buf, in + 0x20, 0x04) #define get_inquiry_max_x_res(in) getnbyte1(in + 0x24, 2) #define get_inquiry_max_y_res(in) getnbyte1(in + 0x26, 2) #define get_inquiry_fb_max_scan_width(in) getnbyte1(in + 0x28, 2) #define get_inquiry_fb_max_scan_length(in) getnbyte1(in + 0x2a, 2) #define get_inquiry_filters(in) in[0x2c] #define get_inquiry_color_depths(in) in[0x2d] #define get_inquiry_color_format(in) in[0x2e] #define get_inquiry_image_format(in) in[0x30] #define get_inquiry_scan_capability(in) in[0x31] #define get_inquiry_optional_devices(in) in[0x32] #define get_inquiry_enhancements(in) in[0x33] #define get_inquiry_gamma_bits(in) in[0x34] #define get_inquiry_last_filter(in) in[0x35] #define get_inquiry_fast_preview_res(in) getnbyte1(in + 0x36, 2) #define get_inquiry_halftones(in) in[0x60] #define get_inquiry_halftone_max_width(in) in[0x61] #define get_inquiry_halftone_max_heighgt(in) in[0x62] #define get_inquiry_max_windows(in) in[0x63] #define get_inquiry_min_highlight(in) in[0x65] #define get_inquiry_max_shadow(in) in[0x66] #define get_inquiry_cal_eqn(in) in[0x67] #define get_inquiry_max_exp(in) getnbyte1(in + 0x68, 2) #define get_inquiry_min_exp(in) getnbyte1(in + 0x6a, 2) #define get_inquiry_trans_x1(in) getnbyte1(in + 0x6c, 2) #define get_inquiry_trans_y1(in) getnbyte1(in + 0x6e, 2) #define get_inquiry_trans_x2(in) getnbyte1(in + 0x70, 2) #define get_inquiry_trans_y2(in) getnbyte1(in + 0x72, 2) #define INQ_ONE_PASS_COLOR 0x80 #define INQ_FILTER_BLUE 0x08 #define INQ_FILTER_GREEN 0x04 #define INQ_FILTER_RED 0x02 #define INQ_FILTER_NEUTRAL 0x01 #define INQ_COLOR_DEPTH_16 0x20 #define INQ_COLOR_DEPTH_12 0x10 #define INQ_COLOR_DEPTH_10 0x08 #define INQ_COLOR_DEPTH_8 0x04 #define INQ_COLOR_DEPTH_4 0x02 #define INQ_COLOR_DEPTH_1 0x01 #define INQ_COLOR_FORMAT_INDEX 0x04 #define INQ_COLOR_FORMAT_LINE 0x02 #define INQ_COLOR_FORMAT_PIXEL 0x01 #define INQ_IMG_FMT_OKLINE 0x08 #define INQ_IMG_FMT_BLK_ONE 0x04 #define INQ_IMG_FMT_MOTOROLA 0x02 #define INQ_IMG_FMT_INTEL 0x01 #define INQ_CAP_PWRSAV 0x80 #define INQ_CAP_EXT_CAL 0x40 #define INQ_CAP_FAST_PREVIEW 0x10 #define INQ_CAP_DISABLE_CAL 0x08 #define INQ_CAP_SPEEDS 0x07 #define INQ_OPT_DEV_MPCL 0x80 #define INQ_OPT_DEV_TP1 0x04 #define INQ_OPT_DEV_TP 0x02 #define INQ_OPT_DEV_ADF 0x01 #define INQ_ENHANCE_EDGE 0x02 #define INQ_LAST_FILTER_BLUE 0x08 #define INQ_LAST_FILTER_GREEN 0x04 #define INQ_LAST_FILTER_RED 0x02 #define INQ_LAST_FILTER_NEUTRAL 0x01 #define INQ_DWNLD_HALFTONE 0x80 #define INQ_NUM_HALFTONES 0x7f /* --------------------------------------------------------------------------------------------------------- */ static unsigned char test_unit_readyC[] = { TEST_UNIT_READY, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk test_unit_ready = { test_unit_readyC,sizeof(test_unit_readyC) }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char reserve_unitC[] = { RESERVE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk reserve_unit = { reserve_unitC, sizeof(reserve_unitC) }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char release_unitC[] = { RELEASE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk release_unit = { release_unitC, sizeof(release_unitC) }; /* --------------------------------------------------------------------------------------------------------- */ static unsigned char paramC[] = { PARAM, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk param = { paramC, sizeof(paramC) }; #define set_param_length(in, l) putnbyte(in + 3, (l), 2) #define get_param_scan_width(b) getnbyte1(b, 2) #define get_param_scan_lines(b) getnbyte1(b + 2, 2) #define get_param_scan_bytes(b) getnbyte1(b + 4, 2) #define get_param_scan_filter_offset1(b) b[6] #define get_param_scan_filter_offset2(b) b[7] #define get_param_scan_period(b) getnbyte1(b + 8, 4) #define get_param_scsi_xfer_rate(b) getnbyte1(b + 12, 2) #define get_param_scan_available_lines(b) getnbyte1(b + 14, 2) /* --------------------------------------------------------------------------------------------------------- */ static unsigned char writeC[] = { WRITE, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk swrite = { writeC, sizeof(writeC) }; #define set_write_length(in, l) putnbyte(in + 2, (l), 3) /* --------------------------------------------------------------------------------------------------------- */ static unsigned char modeC[] = { MODE, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk smode = { modeC, sizeof(modeC) }; #define set_mode_length(in, l) putnbyte(in + 3, (l), 2) /* --------------------------------------------------------------------------------------------------------- */ static unsigned char scanC[] = { SCAN, 0x00, 0x00, 0x00, 0x01, 0x00 }; static scsiblk scan = { scanC, sizeof(scanC) }; #define set_scan_cmd(in, l) in[4] = l /* --------------------------------------------------------------------------------------------------------- */ /* sread instead of read because read is a libc primitive */ static unsigned char sreadC[] = { READ, 0x00, 0x00, 0x00, 0x00, 0x00 }; static scsiblk sread = { sreadC, sizeof(sreadC) }; #define set_read_length(in, l) putnbyte(in + 2, (l), 3) /* --------------------------------------------------------------------------------------------------------- */ #if 0 static unsigned char request_senseC[] = { REQUEST_SENSE, 0x00, 0x00, 0x00, 0x00, 0x00 }; #define set_RS_allocation_length(sb,val) sb[0x04]=val #define set_RS_LUN(sb,val) setbitfield(sb + 0x01, 7, 5) /* ??? */ static scsiblk request_sense = { request_senseC, sizeof(request_senseC) }; #endif /* defines for request sense return block */ #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7) #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0) #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7) #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6) #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5) #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0) #define get_RS_information(b) getnbyte(b+0x03, 4) #define get_RS_additional_length(b) b[0x07] #define get_RS_ASC(b) b[0x0c] #define get_RS_ASCQ(b) b[0x0d] #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /* valid */ #define get_RS_CD(b) getbitfield(b+0x0f,1,6) /* 1=CDB */ #define get_RS_field_pointer(b) getnbyte(b+0x10, 2) #define get_RS_additional_sense(b) getnbyte(b+0x12, 2) #define rs_return_block_size 0x1f /* --------------------------------------------------------------------------------------------------------- */ static char *sense_str[] = {"NO SENSE", "RECOVERED ERROR", "NOT READY", "MEDIUM ERROR", "HARDWARE ERROR", "ILLEGAL REQUEST", "UNIT ATTENTION", "DATA PROTECT", "BLANK CHECK", "VENDOR SPECIFIC", "COPY ABORTED", "ABORTED COMMAND", "EQUAL", "VOLUME OVERFLOW", "MISCOMPARE", "??? - SENSE 0FH" }; /* --------------------------------------------------------------------------------------------------------- */ /* command codes used in the data part of a SCSI write command */ #define SET_POWER_SAVE_CONTROL 0x01 #define DWNLD_GAMMA_TABLE 0x10 #define DWNLD_HALFTONE 0x11 #define SET_SCAN_FRAME 0x12 #define SET_EXP_TIME 0x13 #define SET_HIGHLIGHT_SHADOW 0x14 #define SEND_CAL_DATA 0x16 #define READ_POWER_SAVE_CONTROL 0x81 #define READ_GAMMA_TABLE 0x90 #define READ_HALFTONE 0x91 #define READ_SCAN_FRAME 0x92 #define READ_EXP_TIME 0x93 #define READ_HIGHLIGHT_SHADOW 0x94 #define READ_CAL_INFO 0x95 #define set_command(in, cmd) putnbyte1(in, cmd, 2) #define set_data_length(in, len) putnbyte1(in + 2, len, 2) #define set_data(in, ofs, val, num) putnbyte1(in + ofs, val, num) #define FILTER_BLUE 0x08 #define FILTER_GREEN 0x04 #define FILTER_RED 0x02 #define FILTER_NEUTRAL 0x01 #endif sane-backends-1.0.29/backend/mustek_pp_cis.c0000666000000000000000000025555613615534521015623 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001-2003 Eddy De Greef 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Mustek PP flatbed _CIS_ scanners. */ /* Global picture Mustek_PP_handle -> Mustek_PP_dev -> priv = Mustek_PP_CIS_dev -> CIS */ /* * This flag determines whether the scanner uses fast skipping at high * resolutions. It is possible that this fast skipping introduces * inaccuracies. It if turns out to be a problem, fast skipping can * be disabled by setting this flag to 0. */ #define MUSTEK_PP_CIS_FAST_SKIP 1 #define MUSTEK_PP_CIS_WAIT_BANK 200 /* * These parameters determine where the scanable area starts at the top. * If there is a consistent offset error, you can tune it through these * parameters. Note that an inaccuracy in the order of 1 mm seems to be * normal for the Mustek 600/1200 CP series. */ #define MUSTEK_PP_CIS_600CP_DEFAULT_SKIP 250 #define MUSTEK_PP_CIS_1200CP_DEFAULT_SKIP 330 /* * Number of scan lines on which the average is taken to determine the * maximum number of color levels. */ #define MUSTEK_PP_CIS_AVERAGE_COUNT 32 #define MUSTEK_PP_CIS600 1 #define MUSTEK_PP_CIS1200 2 #define MUSTEK_PP_CIS1200PLUS 3 #define MUSTEK_PP_CIS_CHANNEL_RED 0 #define MUSTEK_PP_CIS_CHANNEL_GREEN 1 #define MUSTEK_PP_CIS_CHANNEL_BLUE 2 #define MUSTEK_PP_CIS_CHANNEL_GRAY 1 #define MUSTEK_PP_CIS_MAX_H_PIXEL 5118 #define MUSTEK_PP_CIS_MAX_V_PIXEL 7000 #define MUSTEK_PP_CIS_MOTOR_REVERSE 0 #include "../include/sane/config.h" #include #include #include #include #include #include #ifdef HAVE_SYS_SELECT_H # include #endif #include "../include/sane/sane.h" #include "../include/sane/sanei_pa4s2.h" #define DEBUG_DECLARE_ONLY #include "mustek_pp.h" #include "mustek_pp_decl.h" #include "mustek_pp_cis.h" /****************************************************************************** ****************************************************************************** *** MA1015 chipset related functionality *** ****************************************************************************** *****************************************************************************/ /* These defines control some debugging functionality #define M1015_TRACE_REGS -> trace the status of the internal registers #define M1015_LOG_HL -> create a high-level log file (register-level) #define M1015_LOG_LL -> create a low-level log file (byte-level) By default, all logging/tracing is turned off. */ /****************************************************************************** * Low level logging: logs read and writes at the byte level, similar to * the sequences produced by tool of Jochen Eisinger * for analysing the TWAIN driver communication. * This simplifies comparison of the sequences. *****************************************************************************/ #ifdef M1015_LOG_LL static FILE* M1015_LOG_1; #define M1015_START_LL\ M1015_LOG_1 = fopen("cis_ll.log", "w"); #define M1015_STOP_LL\ fclose(M1015_LOG_1); #define SANEI_PA4S2_WRITEBYTE(fd, reg, val)\ do\ {\ sanei_pa4s2_writebyte (fd, reg, val);\ fprintf(M1015_LOG_1, "\tsanei_pa4s2_writebyte(fd, %d, 0x%02X);\n", \ reg, val);\ } while (0) static const char* cis_last_rreg_name; static int cis_read_count; #define SANEI_PA4S2_READBEGIN(fd, reg)\ do\ {\ cis_last_rreg_name = Mustek_PP_1015_reg_r_name(reg);\ cis_read_count = 0;\ sanei_pa4s2_readbegin(fd, reg);\ } while (0) #define SANEI_PA4S2_READBYTE(fd, val)\ do\ {\ sanei_pa4s2_readbyte(fd, val);\ ++cis_read_count;\ } while (0) #define SANEI_PA4S2_READEND(fd)\ do\ {\ sanei_pa4s2_readend(fd);\ fprintf(M1015_LOG_1, "\tread_reg(%s, %d);\n", \ cis_last_rreg_name, cis_read_count);\ } while (0) #define M1015_MARK_LL(info)\ fprintf(M1015_LOG_1, "* %s\n", info); #else /* M1015_LOG_LL */ #define M1015_START_LL #define M1015_STOP_LL #define SANEI_PA4S2_WRITEBYTE(fd, reg, val)\ sanei_pa4s2_writebyte (fd, reg, val) #define SANEI_PA4S2_READBEGIN(fd, reg)\ sanei_pa4s2_readbegin(fd, reg) #define SANEI_PA4S2_READBYTE(fd, val)\ sanei_pa4s2_readbyte(fd, val) #define SANEI_PA4S2_READEND(fd)\ sanei_pa4s2_readend(fd) #define M1015_MARK_LL(info) #endif /* M1015_LOG_LL */ /****************************************************************************** * High-level logging: traces the flow of the driver in a hierarchical way * up to the level of register acccesses. *****************************************************************************/ #ifdef M1015_LOG_HL static FILE* M1015_LOG_2; static char hl_prev_line[4096], hl_next_line[4096], hl_repeat_count; /* * A few variables for hierarchical log message indentation. */ static const char* cis_indent_start = " "; static const char* cis_indent; static const char* cis_indent_end; #define M1015_START_HL\ M1015_LOG_2 = fopen("cis_hl.log", "w");\ cis_indent = cis_indent_start + strlen(cis_indent_start);\ cis_indent_end = cis_indent;\ hl_prev_line[0] = 0;\ hl_next_line[0] = 0;\ hl_repeat_count = 0; #define M1015_FLUSH_HL\ if (strcmp(hl_prev_line, hl_next_line))\ {\ fprintf(M1015_LOG_2, &hl_prev_line[0]);\ strcpy(&hl_prev_line[0], &hl_next_line[0]);\ if (hl_repeat_count != 0)\ {\ fprintf(M1015_LOG_2, "%s [last message repeated %d times]\n",\ cis_indent, hl_repeat_count+1); \ }\ hl_repeat_count = 0;\ }\ else\ {\ hl_repeat_count += 1;\ } #define M1015_MARK(info)\ sprintf(&hl_next_line[0], "%s+ %s\n", cis_indent, info);\ M1015_FLUSH_HL #define M1015_STOP_HL\ hl_next_line[0] = 0;\ M1015_FLUSH_HL\ fclose(M1015_LOG_2); #else /* M1015_LOG_HL */ #define M1015_START_HL #define M1015_STOP_HL #define M1015_MARK(info) #define M1015_FLUSH_HL #endif /* M1015_LOG_HL */ #ifdef M1015_TRACE_REGS #define M1015_DISPLAY_REGS(dev, msg) Mustek_PP_1015_display_regs(dev, msg) #define M1015_DISPLAY_REG(msg, val) Mustek_PP_1015_display_reg(msg, val) #else #define M1015_DISPLAY_REGS(dev, msg) #define M1015_DISPLAY_REG(msg, val) #endif #if defined (M1015_LOG_HL) || defined (M1015_LOG_LL) static const char* Mustek_PP_1015_reg_r_name(Mustek_PP_1015R_reg id) { static const char* names[4] = { "ASIC", "SCAN_VAL", "MOTOR", "BANK_COUNT" }; return names[id & 0x03]; } static const char* Mustek_PP_1015_bit_name(Mustek_PP_1015R_bit id) { static const char* names[4] = { "????", "MOTOR_HOME", "????", "MOTOR_BUSY" }; return names[id & 0x03]; } static const char* Mustek_PP_1015_reg_w_name(Mustek_PP_1015R_reg id) { static const char* names[4][4] = { { "RED_REF", "GREEN_REF", "BLUE_REF", "DPI_CONTROL" }, { "BYTE_COUNT_HB", "BYTE_COUNT_LB", "SKIP_COUNT", "EXPOSE_TIME" }, { "SRAM_SOURCE_PC", "MOTOR_CONTROL", "UNKNOWN_42", "UNKNOWN_82" }, { "POWER_ON_DELAY", "CCD_TIMING", "CCD_TIMING_ADJ", "RIGHT_BOUND" } }; return names[(id & 0x30) >> 4][id & 0x03]; } #endif /****************************************************************************** * Converts a register value to a hex/dec/bin representation. *****************************************************************************/ static const char* Mustek_PP_1015_show_val(int val) { /* Since we use a static temporary buffer, we must make sure that the buffer isn't altered while it is still in use (typically because more than one value is converted in a printf statement). Therefore the buffer is organized as a ring buffer. If should contain at least 21 elements in order to be able to display all registers with one printf statement. */ #define Mustek_PP_1015_RING_BUFFER_SIZE 50 static char buf[Mustek_PP_1015_RING_BUFFER_SIZE][64]; static int index = 0; int i; char* current = (char*)buf[index++]; if (index >= Mustek_PP_1015_RING_BUFFER_SIZE) index = 0; if (val < 0) { /* The register has not been initialized yet. */ sprintf(current, "---- (---) --------"); } else { sprintf(current, "0x%02X (%3d) ", val & 0xFF, val & 0xFF); for (i=0; i<8; ++i) { sprintf(current+11+i, "%d", (val >> (7-i)) & 1); } } return current; } #ifdef M1015_TRACE_REGS /****************************************************************************** * Displays the contents of all registers of the scanner on stderr. *****************************************************************************/ static void Mustek_PP_1015_display_regs(Mustek_PP_CIS_dev * dev, const char* info) { /* * Register naming convention: * Rx : read-only register no. x * ByWx : write-only register no. x of bank no. y */ fprintf(stderr, "\n" "Register status: %s\n" "\n" " R0: %s : ASIC info\n" " R1: %s : scan value\n" " R2: %s : CCD/motor info\n" " R3: %s : bank count\n" "\n" " B0W0: %s : red reference\n" " B0W1: %s : green reference\n" " B0W2: %s : blue reference\n" " B0W3: %s : DPI control\n" "\n" " B1W0: %s : byte count, high byte\n" " B1W1: %s : byte count, low byte\n" " B1W2: %s : skip x32 pixels\n" " B1W3: %s : expose time (CCDWIDTH)\n" "\n" " B2W0: %s : SRAM source PC\n" " B2W1: %s : motor control\n" " B2W2: %s : -\n" " B2W3: %s : -\n" "\n" " B3W0: %s : power on delay\n" " B3W1: %s : CCD timing - always 0x05\n" " B3W2: %s : CCD timing adjust - always 0x00\n" " B3W3: %s : right bound (not used)\n" "\n" " CHAN: %s : channel [%s]\n" "\n", info, Mustek_PP_1015_show_val (dev->CIS.regs.in_regs[0]), Mustek_PP_1015_show_val (dev->CIS.regs.in_regs[1]), Mustek_PP_1015_show_val (dev->CIS.regs.in_regs[2]), Mustek_PP_1015_show_val (dev->CIS.regs.in_regs[3]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[0][0]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[0][1]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[0][2]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[0][3]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[1][0]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[1][1]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[1][2]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[1][3]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[2][0]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[2][1]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[2][2]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[2][3]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[3][0]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[3][1]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[3][2]), Mustek_PP_1015_show_val (dev->CIS.regs.out_regs[3][3]), Mustek_PP_1015_show_val (dev->CIS.regs.channel), (dev->CIS.regs.channel == 0x80 ? "RED" : (dev->CIS.regs.channel == 0x40 ? "GREEN" : (dev->CIS.regs.channel == 0xC0 ? "BLUE" : "unknown"))) ); } /****************************************************************************** * Displays a single register value *****************************************************************************/ static void Mustek_PP_1015_display_reg(const char* info, int val) { fprintf (stderr, "%s: %s\n", info, Mustek_PP_1015_show_val(val)); } #endif /* M1015_TRACE_REGS */ /****************************************************************************** * * Reads one of the 4 internal registers of the scanner * * 0: ASIC identification * 1: scan values * 2: CCD info / motor info * 3: bank count info * *****************************************************************************/ static SANE_Byte Mustek_PP_1015_read_reg(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg) { SANE_Byte tmp; assert(reg <= 3); SANEI_PA4S2_READBEGIN (dev->desc->fd, reg & 0x03); SANEI_PA4S2_READBYTE (dev->desc->fd, &tmp); SANEI_PA4S2_READEND (dev->desc->fd); #ifdef M1015_LOG_HL sprintf(&hl_next_line[0], "%s read_reg(%s); [%s]\n", cis_indent, Mustek_PP_1015_reg_r_name(reg), Mustek_PP_1015_show_val(tmp)); M1015_FLUSH_HL; #endif #ifdef M1015_TRACE_REGS dev->CIS.regs.in_regs[reg & 0x03] = tmp; #endif return tmp; } /****************************************************************************** * * Waits for a bit of register to become 1 or 0. The period of checking can be * controlled through the sleep parameter (microseconds). * *****************************************************************************/ static SANE_Bool Mustek_PP_1015_wait_bit(Mustek_PP_CIS_dev * dev, Mustek_PP_1015R_reg reg, Mustek_PP_1015R_bit bit, SANE_Bool on, unsigned period) { SANE_Byte tmp; SANE_Byte mask, val; int tries = 0; assert(reg <= 3); assert(bit <= 3); mask = 1 << bit; /* We don't want to wait forever */ while (dev->desc->state != STATE_CANCELLED) { #if defined (M1015_LOG_LL) || defined (M1015_LOG_HL) ++tries; #endif sanei_pa4s2_readbegin (dev->desc->fd, reg & 0x03); sanei_pa4s2_readbyte (dev->desc->fd, &tmp); sanei_pa4s2_readend (dev->desc->fd); #ifdef M1015_LOG_HL sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d): %s %s;\n", cis_indent, Mustek_PP_1015_reg_r_name(reg), Mustek_PP_1015_bit_name(bit), on?1:0, Mustek_PP_1015_show_val(mask), Mustek_PP_1015_show_val(tmp)); M1015_FLUSH_HL; #endif val = ((on == SANE_TRUE) ? tmp : ~tmp ) & mask; if (val != 0) break; if (period) usleep(period); if (tries > 50000) { #ifdef M1015_LOG_HL sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d): failed;\n", cis_indent, Mustek_PP_1015_reg_r_name(reg), Mustek_PP_1015_bit_name(bit), on?1:0); M1015_FLUSH_HL; #endif DBG(2, "Mustek_PP_1015_wait_bit: failed (reg %d, bit %d, on: %d)\n", reg, bit, on?1:0); return SANE_FALSE; } } #ifdef M1015_LOG_HL sprintf(&hl_next_line[0], "%s wait_bit(%s, %s, %d);\n", cis_indent, Mustek_PP_1015_reg_r_name(reg), Mustek_PP_1015_bit_name(bit), on?1:0); M1015_FLUSH_HL; #endif #ifdef M1015_LOG_LL fprintf(M1015_LOG_1, "\tread_reg(%s, %d);\n", Mustek_PP_1015_reg_r_name(reg), tries); #endif #ifdef M1015_TRACE_REGS dev->CIS.regs.in_regs[reg & 0x03] = tmp; #endif return dev->desc->state != STATE_CANCELLED ? SANE_TRUE : SANE_FALSE; } /****************************************************************************** * * Writes one out of 4 registers of one of the 4 register banks (I guess) * * Bank 0 * 0: voltage red --+ * 1: voltage green +-> always set to 0x96 * 2: voltage blue --+ * 3: DPI control * * Bank 1 * 0: line adjust (?) - high byte * 1: line adjust (?) - low byte * 2: unknown (values seen: 0x00, 0x02, 0x03, 0x1D) * 3: expose time (?) (values seen: 0xAA, 0xFD, 0xFE, 0xFF) * * Bank 2 * 0: unknown, used to start linear sequence during calibration * 1: motor control code (forward, return home, ...) * 2: never used * 3: never used * * Bank 3 * 0: reduction factor (16bit internal -> 8bit) -> target for calibration * 1: unknown -> always set to 0x05 * 2: unknown -> always set to 0x00 * 3: never used * *****************************************************************************/ static void Mustek_PP_1015_write_reg(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg, SANE_Byte val) { SANE_Byte regBank = (reg & 0xF0) >> 4; SANE_Byte regNo = (reg & 0x0F); assert (regNo <= 3); assert (regBank <= 3); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (4+regNo))+ regBank); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, regBank); #ifdef M1015_TRACE_REGS dev->CIS.regs.out_regs[regBank][regNo] = val; #endif #ifdef M1015_LOG_HL sprintf(&hl_next_line[0], "%s write_reg(%s, 0x%02X);\n", cis_indent, Mustek_PP_1015_reg_w_name(reg), val); M1015_FLUSH_HL; #endif } /****************************************************************************** * * Writes 2 values to 2 adjecent registers. * It is probably equivalent to 2 simple write operations (but I'm not sure). * * val1 is written to register[regNo] * val2 is written to register[regNo+1] * *****************************************************************************/ static void Mustek_PP_1015_write_reg2(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg, SANE_Byte val1, SANE_Byte val2) { SANE_Byte regBank = (reg & 0xF0) >> 4; SANE_Byte regNo = (reg & 0x0F); assert (regNo <= 2); assert (regBank <= 3); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (4+regNo))+ regBank); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val1); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (5+regNo))+ regBank); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val2); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, regBank); #ifdef M1015_TRACE_REGS dev->CIS.regs.out_regs[regBank][regNo] = val1; dev->CIS.regs.out_regs[regBank][regNo+1] = val2; #endif #ifdef M1015_LOG_HL sprintf(&hl_next_line[0], "%s write_reg2(%s, 0x%02X, 0x%02X);\n", cis_indent, Mustek_PP_1015_reg_w_name(reg), val1, val2); M1015_FLUSH_HL; #endif } /****************************************************************************** * * Writes 3 values to 3 adjecent registers. * It is probably equivalent to 3 simple write operations (but I'm not sure). * * val1 is written to register[regNo] * val2 is written to register[regNo+1] * val3 is written to register[regNo+2] * *****************************************************************************/ static void Mustek_PP_1015_write_reg3(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg, SANE_Byte val1, SANE_Byte val2, SANE_Byte val3) { SANE_Byte regBank = (reg & 0xF0) >> 4; SANE_Byte regNo = (reg & 0x0F); assert (regNo <= 1); assert (regBank <= 3); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (4+regNo))+ regBank); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val1); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (5+regNo))+ regBank); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val2); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (6+regNo))+ regBank); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val3); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, regBank); #ifdef M1015_TRACE_REGS dev->CIS.regs.out_regs[regBank][regNo ] = val1; dev->CIS.regs.out_regs[regBank][regNo+1] = val2; dev->CIS.regs.out_regs[regBank][regNo+2] = val3; #endif #ifdef M1015_LOG_HL sprintf(&hl_next_line[0], "%s write_reg3(%s, 0x%02X, 0x%02X, 0x%02X);\n", cis_indent, Mustek_PP_1015_reg_w_name(reg), val1, val2, val3); M1015_FLUSH_HL; #endif } /****************************************************************************** * Opens a register for a (series of) write operation(s). *****************************************************************************/ static void Mustek_PP_1015_write_reg_start(Mustek_PP_CIS_dev * dev, Mustek_PP_1015W_reg reg) { SANE_Byte regBank = (reg & 0xF0) >> 4; SANE_Byte regNo = (reg & 0x0F); assert (regNo <= 3); assert (regBank <= 3); dev->CIS.regs.current_write_reg = reg; #ifdef M1015_LOG_HL dev->CIS.regs.write_count = 0; #endif SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, (1 << (4+regNo))+ regBank); } /****************************************************************************** * Writes a value to the currently open register. *****************************************************************************/ static void Mustek_PP_1015_write_reg_val(Mustek_PP_CIS_dev * dev, SANE_Byte val) { #ifdef M1015_TRACE_REGS SANE_Byte regBank = (dev->CIS.regs.current_write_reg & 0xF0) >> 4; SANE_Byte regNo = (dev->CIS.regs.current_write_reg & 0x0F); assert (regNo <= 3); assert (regBank <= 3); dev->CIS.regs.out_regs[regBank][regNo] = val; #endif SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 5, val); #ifdef M1015_LOG_HL ++dev->CIS.regs.write_count; #endif } /****************************************************************************** * Closes a register after a (series of) write operation(s). *****************************************************************************/ static void Mustek_PP_1015_write_reg_stop(Mustek_PP_CIS_dev * dev) { SANE_Byte regBank = (dev->CIS.regs.current_write_reg & 0xF0) >> 4; #ifdef M1015_LOG_HL SANE_Byte regNo = (dev->CIS.regs.current_write_reg & 0x0F); assert (regNo <= 3); sprintf(&hl_next_line[0], "%s write_reg_multi(%s, *%d);\n", cis_indent, Mustek_PP_1015_reg_w_name(dev->CIS.regs.current_write_reg), dev->CIS.regs.write_count); M1015_FLUSH_HL; #endif assert (regBank <= 3); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, regBank); } /****************************************************************************** * * Sends a command to the scanner. The command should not access one of the * internal registers, ie., the 3rd bit should not be zero. * *****************************************************************************/ static void Mustek_PP_1015_send_command(Mustek_PP_CIS_dev * dev, SANE_Byte command) { assert (command & 0x04); SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, command); #ifdef M1015_LOG_HL sprintf(&hl_next_line[0], "%s send_command(0x%02X);\n", cis_indent, command); M1015_FLUSH_HL; #endif } /****************************************************************************** ############################################################################## ## CIS driver ## ############################################################################## *****************************************************************************/ /****************************************************************************** * Resolution conversion functions *****************************************************************************/ static int max2hw_hres(Mustek_PP_CIS_dev *dev, int dist) { return (int)((dist * dev->CIS.hw_hres) / dev->desc->dev->maxres + 0.5); } #ifdef NOT_USED static int max2hw_vres(Mustek_PP_CIS_dev *dev, int dist) { return (int)((dist * dev->CIS.hw_vres) / dev->desc->dev->maxres + 0.5); } #endif static int max2cis_hres(Mustek_PP_CIS_dev *dev, int dist) { return (int)((dist * dev->CIS.cisRes) / dev->desc->dev->maxres + 0.5); } static int cis2max_res(Mustek_PP_CIS_dev *dev, int dist) { return (int)((dist * dev->desc->dev->maxres) / dev->CIS.cisRes + 0.5); } #ifdef NOT_USED static int hw2max_vres(Mustek_PP_CIS_dev *dev, int dist) { return (int)((dist * dev->desc->dev->maxres) / dev->CIS.hw_vres + 0.5); } #endif /****************************************************************************** * Attempts to extract the current bank no. *****************************************************************************/ static void cis_get_bank_count(Mustek_PP_CIS_dev *dev) { dev->bank_count = (Mustek_PP_1015_read_reg(dev, MA1015R_BANK_COUNT) & 0x7); if (dev->CIS.use8KBank) dev->bank_count >>= 1; } /****************************************************************************** * Triggers a bank switch (I assume). *****************************************************************************/ static void cis_set_sti(Mustek_PP_CIS_dev *dev) { SANEI_PA4S2_WRITEBYTE(dev->desc->fd, 3, 0xFF); dev->bank_count++; dev->bank_count &= (dev->CIS.use8KBank == SANE_TRUE) ? 3 : 7; } /****************************************************************************** * Wait till the bank with a given number becomes available. *****************************************************************************/ static SANE_Bool cis_wait_bank_change (Mustek_PP_CIS_dev * dev, int bankcount) { struct timeval start, end; unsigned long diff; int firsttime = 1; gettimeofday (&start, NULL); do { if (1 /*niceload*/) { if (firsttime) firsttime = 0; else usleep (10); /* for a little nicer load */ } cis_get_bank_count (dev); gettimeofday (&end, NULL); diff = (end.tv_sec * 1000 + end.tv_usec / 1000) - (start.tv_sec * 1000 + start.tv_usec / 1000); } while ((dev->bank_count != bankcount) && (diff < MUSTEK_PP_CIS_WAIT_BANK)); if (dev->bank_count != bankcount && dev->desc->state != STATE_CANCELLED) { u_char tmp; tmp = Mustek_PP_1015_read_reg(dev, 3); DBG(2, "cis_wait_bank_change: Missed a bank: got %d [%s], " "wanted %d, waited %d msec\n", dev->bank_count, Mustek_PP_1015_show_val(tmp), bankcount, MUSTEK_PP_CIS_WAIT_BANK); } return dev->bank_count == bankcount ? SANE_TRUE : SANE_FALSE; } /****************************************************************************** * Configure the CIS for a given resolution. * * CIS scanners seem to have 2 modes: * * low resolution (50-300 DPI) and * high resolution (300-600 DPI). * * Depending on the resolution requested by the user, the scanner is used * in high or low resolution mode. In high resolution mode, the motor step * sizes are also reduced by a factor of two. * *****************************************************************************/ static void cis_set_dpi_value (Mustek_PP_CIS_dev * dev) { u_char val = 0; if (dev->model == MUSTEK_PP_CIS1200PLUS) { /* Toshiba CIS: only 600 DPI + decimation */ switch (dev->CIS.hw_hres) { case 75: val = 0x48; /* 1/8 */ break; case 100: val = 0x08; /* 1/6 */ break; case 200: val = 0x00; /* 1/3 */ break; case 300: val = 0x50; /* 2/4 */ break; case 400: val = 0x10; /* 2/3 */ break; case 600: val = 0x20; /* 3/3 */ break; default: assert (0); } } else { /* Canon CIS: sensor can use 300 or 600 DPI */ switch (dev->CIS.hw_hres) { case 50: val = 0x08; /* 1/6 */ break; case 100: val = 0x00; /* 1/3 */ break; case 200: val = 0x10; /* 2/3 */ break; case 300: val = 0x20; /* 3/3 */ break; case 400: val = 0x10; /* 2/3 */ break; case 600: val = 0x20; /* 3/3 */ break; default: assert (0); } } Mustek_PP_1015_write_reg(dev, MA1015W_DPI_CONTROL, val | 0x04); DBG (4, "cis_set_dpi_value: dpi: %d -> value 0x%02x\n", dev->CIS.hw_hres, val); } static void cis_set_ccd_channel (Mustek_PP_CIS_dev * dev) { SANE_Byte codes[] = { 0x84, 0x44, 0xC4 }; SANE_Byte chancode; assert (dev->CIS.channel < 3); chancode = codes[dev->CIS.channel]; /* The TWAIN driver sets an extra bit in lineart mode. When I do this too, I don't see any effect on the image. Moreover, for 1 resolution, namely 400 dpi, the bank counter seems to behave strangely, and the synchronization get completely lost. I guess the software conversion from gray to lineart is good enough, so I'll leave it like that. if (dev->CIS.setParameters) { chancode |= (dev->desc->mode == MODE_BW) ? 0x20: 0; } */ SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, chancode); #ifdef M1015_TRACE_REGS dev->CIS.regs.channel = chancode; #endif } static void cis_config_ccd (Mustek_PP_CIS_dev * dev) { SANE_Int skipCount, byteCount; if (dev->CIS.res != 0) dev->CIS.hres_step = SANE_FIX ((float) dev->CIS.hw_hres / (float) dev->CIS.res); /* CIS: <= 300 dpi -> 0x86 > 300 dpi -> 0x96 */ if (dev->CIS.cisRes == 600) SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, 0x96); else SANEI_PA4S2_WRITEBYTE (dev->desc->fd, 6, 0x86); cis_set_dpi_value(dev); if (dev->CIS.setParameters) { dev->CIS.channel = dev->desc->mode == MODE_COLOR ? MUSTEK_PP_CIS_CHANNEL_RED : MUSTEK_PP_CIS_CHANNEL_GRAY; } else { dev->CIS.channel = MUSTEK_PP_CIS_CHANNEL_GRAY; } cis_set_ccd_channel (dev); Mustek_PP_1015_write_reg (dev, MA1015W_POWER_ON_DELAY, 0xAA); Mustek_PP_1015_write_reg (dev, MA1015W_CCD_TIMING, 0x05); Mustek_PP_1015_write_reg (dev, MA1015W_CCD_TIMING_ADJ, 0x00); Mustek_PP_1015_send_command (dev, 0x45); /* or 0x05 for no 8kbank */ /* * Unknown sequence. * Seems to be always the same during configuration, independent of the * mode and the resolution. */ CIS_CLEAR_FULLFLAG(dev); CIS_INC_READ(dev); CIS_CLEAR_READ_BANK(dev); CIS_CLEAR_WRITE_ADDR(dev); CIS_CLEAR_WRITE_BANK(dev); CIS_CLEAR_TOGGLE(dev); /* # SkipImage = expressed in max resolution (600 DPI) # # Formulas # # <= 300 DPI: # # Skip = 67 + skipimage/2 # # Skip1 = Skip / 32 # Skip2 = Skip % 32 # # Bytes = Skip2 * hw_hres/300 + (imagebytes * hw_hres/res) + 2 # # > 300 DPI # # Skip = 67 + skipimage # # Skip1 = Skip / 32 # Skip2 = Skip % 32 # # Bytes = Skip2*hw_hres/600 + (imagebytes * hw_hres/res) + 2 # */ skipCount = 67; /* Hardware parameter - fixed */ if (dev->CIS.setParameters == SANE_TRUE) { /* * It seems that the TWAIN driver always adds 2 mm extra. When I do the * inverse calculation from the parameters that driver sends, I always * get a difference of exactly 2mm, at every resolution and for * different positions of the scan area. Moreover, when I don't add this * offset, the resulting scan seems to start 2mm to soon. * I can't find this back in the backend of the TWAIN driver, but I * assume that this 2mm offset is taken care off at the higher levels. */ DBG(4, "cis_config_ccd: Skip count: %d\n", skipCount); skipCount += max2cis_hres(dev, dev->CIS.skipimagebytes); DBG(4, "cis_config_ccd: Skip count: %d (cis res: %d)\n", skipCount, dev->CIS.cisRes); skipCount += (int)(2.0/25.4*dev->CIS.cisRes); DBG(4, "cis_config_ccd: Skip count: %d\n", skipCount); Mustek_PP_1015_write_reg (dev, MA1015W_SKIP_COUNT, skipCount / 32); DBG(4, "cis_config_ccd: Skip count: %d (x32)\n", skipCount / 32); } else { Mustek_PP_1015_write_reg (dev, MA1015W_SKIP_COUNT, 0); DBG(4, "cis_config_ccd: Skip count: 67 (x32)\n"); } skipCount %= 32; skipCount = cis2max_res(dev, skipCount); /* Back to max res */ Mustek_PP_1015_write_reg(dev, MA1015W_EXPOSE_TIME, dev->CIS.exposeTime); DBG(4, "cis_config_ccd: skipcount: %d imagebytes: %d\n", skipCount, dev->CIS.imagebytes); /* set_initial_skip_1015 (dev); */ if (dev->CIS.setParameters == SANE_TRUE) { Mustek_PP_1015_write_reg(dev, MA1015W_EXPOSE_TIME, dev->CIS.exposeTime); Mustek_PP_1015_write_reg(dev, MA1015W_POWER_ON_DELAY, 0xAA); /* The TWAIN drivers always sends the same value: 0x96 */ Mustek_PP_1015_write_reg3(dev, MA1015W_RED_REF, 0x96, 0x96, 0x96); dev->CIS.adjustskip = max2hw_hres(dev, skipCount); byteCount = max2hw_hres(dev, skipCount + dev->CIS.imagebytes) + 2; dev->CIS.setParameters = SANE_FALSE; } else { dev->CIS.adjustskip = 0; byteCount = max2hw_hres(dev, skipCount); } DBG(4, "cis_config_ccd: adjust skip: %d bytecount: %d\n", dev->CIS.adjustskip, byteCount); Mustek_PP_1015_write_reg2(dev, MA1015W_BYTE_COUNT_HB, byteCount >> 8, byteCount & 0xFF); cis_get_bank_count (dev); DBG(5, "cis_config_ccd: done\n"); } static SANE_Bool cis_wait_motor_stable (Mustek_PP_CIS_dev * dev) { static struct timeval timeoutVal; SANE_Bool ret = Mustek_PP_1015_wait_bit (dev, MA1015R_MOTOR, MA1015B_MOTOR_STABLE, SANE_FALSE, 0); #ifdef HAVE_SYS_SELECT_H if (dev->engine_delay > 0) { timeoutVal.tv_sec = 0; timeoutVal.tv_usec = dev->engine_delay*1000; select(0, NULL, NULL, NULL, &timeoutVal); } #endif return ret; } static void cis_motor_forward (Mustek_PP_CIS_dev * dev) { SANE_Byte control; if (dev->model == MUSTEK_PP_CIS600) { switch (dev->CIS.hw_vres) { case 150: control = 0x7B; break; case 300: control = 0x73; break; case 600: control = 0x13; break; default: exit(1); } } else { switch (dev->CIS.hw_vres) { case 300: control = 0x7B; break; case 600: control = 0x73; break; case 1200: control = 0x13; break; default: exit(1); } } #if MUSTEK_PP_CIS_MOTOR_REVERSE == 1 control ^= 0x10; #endif DBG(4, "cis_motor_forward: @%d dpi: 0x%02X.\n", dev->CIS.hw_vres, control); if (!cis_wait_motor_stable (dev)) return; Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, control); } static void cis_move_motor (Mustek_PP_CIS_dev * dev, SANE_Int steps) /* steps @ maxres */ { /* Note: steps is expressed at maximum resolution */ SANE_Byte fullStep = 0x13, biStep = 0x73, quadStep = 0x7B; SANE_Int fullSteps, biSteps, quadSteps; /* * During a multi-step feed, the expose time is fixed. The value depends * on the type of the motor (600/1200 CP) */ SANE_Byte savedExposeTime = dev->CIS.exposeTime; dev->CIS.exposeTime = 85; DBG(4, "cis_move_motor: Moving motor %d steps.\n", steps); /* Just in case ... */ if (steps < 0) { DBG(1, "cis_move_motor: trying to move negative steps: %d\n", steps); steps = 0; /* We must go through the configuration procedure */ } /* * Using the parameter settings for the 600 CP on a 1200 CP scanner * doesn't work: the engine doesn't move and makes a sharp noise, which * doesn't sound too healthy. It could be harmful to the motor ! * Apparently, the same happens on a real 600 CP (reported by Disma * Goggia), so it's probably better to always use the 1200 CP settings. */ dev->CIS.exposeTime <<= 1; cis_config_ccd(dev); dev->CIS.exposeTime = savedExposeTime; /* * This is a minor speed optimization: when we are using the high * resolution mode, long feeds (eg, to move to a scan area at the bottom * of the page) can be made almost twice as fast by using double motor * steps as much as possible. * It is possible, though, that fast skipping (which is the default) is * not very accurate on some scanners. Therefore, the user can disable * this through the configuration file. */ fullSteps = steps & 1; biSteps = steps >> 1; if (dev->fast_skip) { quadSteps = biSteps >> 1; biSteps &= 1; } else { quadSteps = 0; } M1015_DISPLAY_REGS(dev, "Before move"); #if MUSTEK_PP_CIS_MOTOR_REVERSE == 1 fullStep ^= 0x10; biStep ^= 0x10; quadStep ^= 0x10; #endif DBG(4, "cis_move_motor: 4x%d 2x%d 1x%d\n", quadSteps, biSteps, fullSteps); /* Note: the TWAIN driver opens the motor control register only once before the loop, and closes it after the loop. I've tried this too, but it resulted in inaccurate skip distances; therefore, the motor control register is now opened and closed for each step. */ while (quadSteps-- > 0 && dev->desc->state != STATE_CANCELLED) { cis_wait_motor_stable (dev); Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, quadStep); } while (biSteps-- > 0 && dev->desc->state != STATE_CANCELLED) { cis_wait_motor_stable (dev); Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, biStep); } while (fullSteps-- > 0 && dev->desc->state != STATE_CANCELLED) { cis_wait_motor_stable (dev); Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, fullStep); } } static void cis_set_et_pd_sti (Mustek_PP_CIS_dev * dev) { Mustek_PP_1015_write_reg(dev, MA1015W_EXPOSE_TIME, dev->CIS.exposeTime); Mustek_PP_1015_write_reg(dev, MA1015W_POWER_ON_DELAY, dev->CIS.powerOnDelay[dev->CIS.channel]); cis_set_ccd_channel (dev); cis_set_sti (dev); } /* * Prepare the scanner for catching the next channel and, if necessary, * move the head one step further. */ static SANE_Bool cis_wait_next_channel (Mustek_PP_CIS_dev * dev) { int moveAtChannel = dev->desc->mode == MODE_COLOR ? MUSTEK_PP_CIS_CHANNEL_BLUE : MUSTEK_PP_CIS_CHANNEL_GRAY; if (!cis_wait_bank_change (dev, dev->bank_count)) { DBG(2, "cis_wait_next_channel: Could not get next bank.\n"); return SANE_FALSE; } moveAtChannel = (dev->desc->mode == MODE_COLOR) ? MUSTEK_PP_CIS_CHANNEL_BLUE : MUSTEK_PP_CIS_CHANNEL_GRAY; if (dev->CIS.channel == moveAtChannel && !dev->CIS.dontMove) { cis_motor_forward (dev); } cis_set_et_pd_sti (dev); if (dev->desc->mode == MODE_COLOR) { ++dev->CIS.channel; dev->CIS.channel %= 3; } return SANE_TRUE; } /* * Wait for the device to be ready for scanning. Cycles through the different * channels and sets the parameters (only green channel in gray/lineart). */ static SANE_Bool cis_wait_read_ready (Mustek_PP_CIS_dev * dev) { int channel; dev->CIS.dontIncRead = SANE_TRUE; dev->CIS.channel = dev->desc->mode == MODE_COLOR ? MUSTEK_PP_CIS_CHANNEL_RED : MUSTEK_PP_CIS_CHANNEL_GRAY; for (channel = 0; channel < 3; ++channel) { if (!cis_wait_next_channel(dev)) return SANE_FALSE; } return SANE_TRUE; } static int delay_read (int delay) { /* * A (very) smart compiler may complete optimize the delay loop away. By * adding some difficult data dependencies, we can try to prevent this. */ static int prevent_removal, i; for (i = 0; iCIS.adjustskip, cval; int bpos = 0; SANE_Byte low_val = 0, hi_val = 255; if (pixel <= 0) return; SANEI_PA4S2_READBEGIN (dev->desc->fd, 1); while(skips-- >= 0) { if (dev->CIS.delay) delay_read(dev->CIS.delay); SANEI_PA4S2_READBYTE (dev->desc->fd, &color); } if (dev->CIS.hw_hres == dev->CIS.res) { /* One-to one mapping */ DBG (6, "cis_read_line_low_level: one-to-one\n"); for (ctr = 0; ctr < pixel; ctr++) { if (dev->CIS.delay) delay_read(dev->CIS.delay); SANEI_PA4S2_READBYTE (dev->desc->fd, &color); cval = color; if (calib_low) { low_val = calib_low[ctr] ; } if (calib_hi) { hi_val = calib_hi[ctr] ; } cval -= low_val ; cval <<= 8 ; cval /= hi_val-low_val ; if (cval < 0) cval = 0; else if (cval > 255) cval = 255; if (gamma) cval = gamma[cval]; buf[ctr] = cval; } } else if (dev->CIS.hw_hres > dev->CIS.res) { /* Sub-sampling */ int pos = 0; DBG (6, "cis_read_line_low_level: sub-sampling\n"); ctr = 0; do { if (dev->CIS.delay) delay_read(dev->CIS.delay); SANEI_PA4S2_READBYTE (dev->desc->fd, &color); cval = color; if (ctr < (pos >> SANE_FIXED_SCALE_SHIFT)) { ctr++; continue; } ctr++; pos += dev->CIS.hres_step; if (calib_low) { low_val = calib_low[bpos] ; } if (calib_hi) { hi_val = calib_hi[bpos] ; } cval -= low_val ; cval <<= 8 ; cval /= hi_val-low_val ; if (cval < 0) cval = 0 ; else if (cval > 255) cval = 255 ; if (gamma) cval = gamma[cval]; buf[bpos++] = cval; } while (bpos < pixel); } else { int calctr = 0; SANE_Int pos = 0, nextPos = 1; /* Step: eg: 600 DPI -> 700 DPI -> hres_step = 6/7 -> step = 1/7 */ SANE_Int step = SANE_FIX(1) - dev->CIS.hres_step; /* Super-sampling */ DBG (6, "cis_read_line_low_level: super-sampling\n"); do { if (dev->CIS.delay) delay_read(dev->CIS.delay); SANEI_PA4S2_READBYTE (dev->desc->fd, &color); cval = color; if (calib_low) { low_val = calib_low[calctr] ; } if (calib_hi) { hi_val = calib_hi[calctr] ; } if (++calctr >= dev->calib_pixels) { /* Avoid array boundary violations due to rounding errors (due to the incremental calculation, the current position may be inaccurate to up to two pixels, so we may need to read a few extra bytes -> use the last calibration value) */ calctr = dev->calib_pixels - 1; DBG (3, "cis_read_line_low_level: calibration overshoot\n"); } cval -= low_val ; cval <<= 8 ; cval /= hi_val-low_val ; if (cval < 0) cval = 0 ; else if (cval > 255) cval = 255 ; if (gamma) cval = gamma[cval]; pos += step; if ((pos >> SANE_FIXED_SCALE_SHIFT) >= nextPos) { nextPos++; /* Insert an interpolated value */ buf[bpos] = (buf[bpos-1] + cval)/2; /* Interpolate */ ++bpos; /* Store the plain value, but only if we still need pixels */ if (bpos < pixel) buf[bpos++] = cval; pos += step; /* Take interpolated value into account for pos */ } else { buf[bpos++] = cval; } } while (bpos < pixel); } SANEI_PA4S2_READEND (dev->desc->fd); DBG (6, "cis_read_line_low_level: done\n"); } static SANE_Bool cis_read_line (Mustek_PP_CIS_dev * dev, SANE_Byte* buf, SANE_Int pixel, SANE_Bool raw) { if (!dev->CIS.dontIncRead) CIS_INC_READ(dev); else dev->CIS.dontIncRead = SANE_FALSE; if (raw) { /* No color correction; raw data */ cis_read_line_low_level (dev, buf, pixel, NULL, NULL, NULL); } else { /* Color correction */ cis_read_line_low_level (dev, buf, pixel, dev->calib_low[dev->CIS.channel], dev->calib_hi[dev->CIS.channel], (dev->desc->val[OPT_CUSTOM_GAMMA].w ? dev->desc->gamma_table[dev->CIS.channel] : NULL)); } return cis_wait_next_channel(dev); } 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, step = dev->CIS.line_step; SANE_Byte gotline; if (dev->desc->mode == MODE_COLOR) { first = MUSTEK_PP_CIS_CHANNEL_RED; last = MUSTEK_PP_CIS_CHANNEL_BLUE; stride = 3; } else { first = MUSTEK_PP_CIS_CHANNEL_GRAY; last = MUSTEK_PP_CIS_CHANNEL_GRAY; stride = 1; } gotline = SANE_FALSE; do { dev->ccd_line++; if ((dev->line_diff >> SANE_FIXED_SCALE_SHIFT) != dev->ccd_line) { cis_motor_forward (dev); continue; } dev->line_diff += step; for (channel = first; channel <= last; ++channel) { if (!cis_read_line(dev, tmpbuf, dev->desc->params.pixels_per_line, SANE_FALSE)) return; dest = buf + channel - first; for (ctr = 0; ctr < dev->desc->params.pixels_per_line; ctr++) { *dest = tmpbuf[ctr]; dest += stride; } } gotline = SANE_TRUE; } while (!gotline && dev->desc->state != STATE_CANCELLED); } static void cis_get_grayscale_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf) { cis_get_next_line(dev, buf); } static void cis_get_lineart_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf) { int ctr; SANE_Byte gbuf[MUSTEK_PP_CIS_MAX_H_PIXEL * 2]; cis_get_grayscale_line (dev, gbuf); memset (buf, 0xFF, dev->desc->params.bytes_per_line); for (ctr = 0; ctr < dev->desc->params.pixels_per_line; ctr++) buf[ctr >> 3] ^= ((gbuf[ctr] > dev->bw_limit) ? (1 << (7 - ctr % 8)) : 0); } static void cis_get_color_line (Mustek_PP_CIS_dev * dev, SANE_Byte * buf) { cis_get_next_line(dev, buf); } /****************************************************************************** * Saves the state of the device during reset and calibration. *****************************************************************************/ static void cis_save_state (Mustek_PP_CIS_dev * dev) { dev->Saved_CIS = dev->CIS; } /****************************************************************************** * Restores the state of the device after reset and calibration. *****************************************************************************/ static void cis_restore_state (Mustek_PP_CIS_dev * dev) { dev->CIS = dev->Saved_CIS; } #define CIS_TOO_BRIGHT 1 #define CIS_OK 0 #define CIS_TOO_DARK -1 static int cis_check_result(SANE_Byte* buffer, int pixel) { int i, maxVal = 0; for (i=0;i maxVal) maxVal = buffer[i]; if (maxVal > 250) return CIS_TOO_BRIGHT; if (maxVal < 240) return CIS_TOO_DARK; return CIS_OK; } static SANE_Bool cis_maximize_dynamic_range(Mustek_PP_CIS_dev * dev) { /* The device is in its final configuration already. */ int i, j, pixel, channel, minExposeTime, first, last; SANE_Byte powerOnDelayLower[3], powerOnDelayUpper[3], exposeTime[3]; SANE_Byte buf[3][MUSTEK_PP_CIS_MAX_H_PIXEL]; SANE_Int pixels = dev->calib_pixels; DBG(3, "cis_maximize_dynamic_range: starting\n"); for (channel = 0; channel < 3; ++channel) { exposeTime[channel] = 254; dev->CIS.powerOnDelay[channel] = 170; powerOnDelayLower[channel] = 1; powerOnDelayUpper[channel] = 254; } dev->CIS.setParameters = SANE_TRUE; dev->CIS.exposeTime = exposeTime[MUSTEK_PP_CIS_CHANNEL_GREEN]; cis_config_ccd(dev); M1015_DISPLAY_REGS(dev, "before maximizing dynamic range"); dev->CIS.dontMove = SANE_TRUE; /* Don't move while calibrating */ if (!cis_wait_read_ready(dev) && dev->desc->state != STATE_CANCELLED) { DBG(2, "cis_maximize_dynamic_range: DEVICE NOT READY!\n"); return SANE_FALSE; } if (dev->desc->mode == MODE_COLOR) { first = MUSTEK_PP_CIS_CHANNEL_RED; last = MUSTEK_PP_CIS_CHANNEL_BLUE; } else { first = MUSTEK_PP_CIS_CHANNEL_GRAY; last = MUSTEK_PP_CIS_CHANNEL_GRAY; } dev->CIS.channel = first; /* Perform a kind of binary search. In the worst case, we should find the optimal power delay values after 8 iterations */ for( i=0; i<8; i++) { for (channel = first; channel <= last; ++channel) { dev->CIS.powerOnDelay[channel] = (powerOnDelayLower[channel] + powerOnDelayUpper[channel]) / 2; } Mustek_PP_1015_write_reg(dev, MA1015W_POWER_ON_DELAY, dev->CIS.powerOnDelay[1]); /* Green */ for (pixel = 0; pixel < pixels; ++pixel) { buf[0][pixel] = buf[1][pixel] = buf[2][pixel] = 255; } /* Scan 4 lines, but ignore the first 3 ones. */ for (j = 0; j < 4; ++j) { for (channel = first; channel <= last; ++channel) { if (!cis_read_line(dev, &buf[channel][0], pixels, /* raw = */ SANE_TRUE)) return SANE_FALSE; } } for (channel = first; channel <= last; ++channel) { switch (cis_check_result(buf[channel], pixels)) { case CIS_TOO_BRIGHT: powerOnDelayLower[channel] = dev->CIS.powerOnDelay[channel]; break; case CIS_TOO_DARK: powerOnDelayUpper[channel] = dev->CIS.powerOnDelay[channel]; break; default: break; } } DBG (4, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n", dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1], dev->CIS.powerOnDelay[2]); } dev->CIS.dontMove = SANE_FALSE; DBG (3, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n", dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1], dev->CIS.powerOnDelay[2]); minExposeTime = (dev->CIS.hw_hres <= 300) ? 170 : 253; for (channel = first; channel <= last; ++channel) { dev->CIS.powerOnDelay[channel] = (powerOnDelayLower[channel] + powerOnDelayUpper[channel]) / 2; exposeTime[channel] -= dev->CIS.powerOnDelay[channel] - 1; dev->CIS.powerOnDelay[channel] = 1; if (exposeTime[channel] < minExposeTime) { dev->CIS.powerOnDelay[channel] += minExposeTime - exposeTime[channel]; exposeTime[channel] = minExposeTime; } } dev->CIS.exposeTime = exposeTime[MUSTEK_PP_CIS_CHANNEL_GREEN]; DBG (3, "cis_maximize_dynamic_range: expose time: %3d\n", exposeTime[1]); DBG (3, "cis_maximize_dynamic_range: power on delay %3d %3d %3d\n", dev->CIS.powerOnDelay[0], dev->CIS.powerOnDelay[1], dev->CIS.powerOnDelay[2]); /* * Short the calibration. Temporary, to find out what is wrong with * the calibration on a 600 CP. * dev->CIS.exposeTime = 170; dev->CIS.powerOnDelay[0] = 120; dev->CIS.powerOnDelay[1] = 120; dev->CIS.powerOnDelay[2] = 120; */ return SANE_TRUE; } static SANE_Bool cis_measure_extremes(Mustek_PP_CIS_dev * dev, SANE_Byte* calib[3], SANE_Int pixels, SANE_Int first, SANE_Int last) { SANE_Byte buf[3][MUSTEK_PP_CIS_MAX_H_PIXEL]; SANE_Byte min[3][MUSTEK_PP_CIS_MAX_H_PIXEL]; SANE_Byte max[3][MUSTEK_PP_CIS_MAX_H_PIXEL]; SANE_Int sum[3][MUSTEK_PP_CIS_MAX_H_PIXEL]; int channel, cnt, p; memset((void*)&min, 255, 3*MUSTEK_PP_CIS_MAX_H_PIXEL*sizeof(SANE_Byte)); memset((void*)&max, 0, 3*MUSTEK_PP_CIS_MAX_H_PIXEL*sizeof(SANE_Byte)); memset((void*)&sum, 0, 3*MUSTEK_PP_CIS_MAX_H_PIXEL*sizeof(SANE_Int)); dev->CIS.channel = first; /* Purge the banks first (there's always a 3-cycle delay) */ for (channel = first; channel <= last; ++channel) { if (!cis_read_line(dev, &buf[channel%3][0], pixels, /* raw = */ SANE_TRUE)) return SANE_FALSE; } --dev->CIS.skipsToOrigin; for (cnt = 0; cnt < MUSTEK_PP_CIS_AVERAGE_COUNT + 2; ++cnt) { for (channel = first; channel <= last; ++channel) { DBG(4, "cis_measure_extremes: Reading line %d - channel %d\n", cnt, channel); if (!cis_read_line(dev, &buf[channel][0], pixels, /* raw = */ SANE_TRUE)) return SANE_FALSE; for (p = 0; p < pixels; ++p) { SANE_Byte val = buf[channel][p]; if (val < min[channel][p]) min[channel][p] = val; if (val > max[channel][p]) max[channel][p] = val; sum[channel][p] += val; } } --dev->CIS.skipsToOrigin; } DBG(4, "cis_measure_extremes: Averaging\n"); for (channel = first; channel <= last; ++channel) { /* Ignore the extreme values and take the average of the others. */ for (p = 0; p < pixels; ++p) { sum[channel][p] -= min[channel][p] + max[channel][p]; sum[channel][p] /= MUSTEK_PP_CIS_AVERAGE_COUNT; if (calib[channel]) calib[channel][p] = sum[channel][p]; } } DBG(4, "cis_measure_extremes: Done\n"); return SANE_TRUE; } static SANE_Bool cis_normalize_ranges(Mustek_PP_CIS_dev * dev) { SANE_Byte cal_low, cal_hi ; SANE_Byte powerOnDelay[3] ; SANE_Int pixels = dev->calib_pixels; SANE_Int channel, p, first, last; if (dev->desc->mode == MODE_COLOR) { first = MUSTEK_PP_CIS_CHANNEL_RED; last = MUSTEK_PP_CIS_CHANNEL_BLUE; } else { first = MUSTEK_PP_CIS_CHANNEL_GRAY; last = MUSTEK_PP_CIS_CHANNEL_GRAY; } DBG(3, "cis_normalize_ranges: Measuring high extremes\n"); /* Measure extremes with normal lighting */ if (!cis_measure_extremes(dev, dev->calib_hi, pixels, first, last)) { return SANE_FALSE; } /* Measure extremes without lighting */ for (channel=first; channel<=last; ++channel) { powerOnDelay[channel] = dev->CIS.powerOnDelay[channel]; dev->CIS.powerOnDelay[channel] = dev->CIS.exposeTime; } DBG(3, "cis_normalize_ranges: Measuring low extremes\n"); if (!cis_measure_extremes(dev, dev->calib_low, pixels, first, last)) { return SANE_FALSE; } /* Restore settings */ for (channel=first; channel<=last; ++channel) { dev->CIS.powerOnDelay[channel] = powerOnDelay[channel]; } /* Make sure calib_hi is greater than calib_low */ for (channel = first; channel <= last; ++channel) { for (p = 0; pcalib_low[channel]) { cal_low = dev->calib_low[channel][p]; } else { cal_low = 0; } if (dev->calib_hi[channel]) { cal_hi = dev->calib_hi[channel][p]; } else { cal_hi = 255; } if (cal_hi <= cal_low) { if(cal_hi<255) { /* calib_hi exists, else cal_hi would be 255 */ dev->calib_hi[channel][p] = cal_low+1; } else { /* calib_low exists, else cal_low would be 0, < 255 */ dev->calib_low[channel][p] = cal_hi-1; } } } } DBG(3, "cis_normalize_ranges: calibration done\n"); return SANE_TRUE; } /* * This routine measures the time that we have to wait between reading * to pixels from the scanner. Especially at low resolutions, but also * for narrow-width scans at high resolutions, reading too fast cause * color stability problems. * This routine sends a test pattern to the scanner memory banks and tries * to measure how fast it can be retrieved without errors. * The same is done by the TWAIN driver (TESTIO.CPP:TestDelay). */ static SANE_Bool cis_measure_delay(Mustek_PP_CIS_dev * dev) { SANE_Byte buf[2][2048]; unsigned i, j, d; int saved_res; SANE_Bool error = SANE_FALSE; CIS_CLEAR_FULLFLAG(dev); CIS_CLEAR_WRITE_ADDR(dev); CIS_CLEAR_WRITE_BANK(dev); CIS_INC_READ(dev); CIS_CLEAR_READ_BANK(dev); M1015_DISPLAY_REGS(dev, "Before delay measurement"); assert(dev->CIS.adjustskip == 0); /* Sawtooth */ for (i=0; i<2048; ++i) { buf[0][i] = i % 255; /* Why 255 ? Seems to have no real importance */ } Mustek_PP_1015_write_reg_start(dev, MA1015W_SRAM_SOURCE_PC); for (i=0; i<2048; ++i) { Mustek_PP_1015_write_reg_val(dev, buf[0][i]); } Mustek_PP_1015_write_reg_stop(dev); /* Bank offset measurement */ dev->CIS.delay = 0; /* Initialize to zero, measure next */ saved_res = dev->CIS.res; dev->CIS.res = dev->CIS.hw_hres; /* * Note: the TWAIN driver seems to have a fast EPP mode too. That one is * tried first, and then they try the normal mode. I haven't figured out * yet how the fast mode works, so I'll only check the normal mode for now. * Moreover, from the behaviour that I've witnessed from the TWAIN driver, * I must conclude that the fast mode probably doesn't work on my computer, * so I can't test it anyhow. */ /* Gradually increase the delay till we have no more errors */ for (d = 0; d < 75 /* 255 */ && dev->desc->state != STATE_CANCELLED; d += 5) { dev->CIS.delay = d; /* * We read the line 5 times to make sure that all garbage is flushed. */ for (i=0; i<5; ++i) { CIS_INC_READ(dev); CIS_CLEAR_READ_BANK(dev); cis_read_line_low_level (dev, &buf[1][0], 2048, NULL, NULL, NULL); if (dev->desc->state == STATE_CANCELLED) return SANE_FALSE; } error = SANE_FALSE; /* Check 100 times whether we can read without errors. */ for (i=0; i<100 && !error; ++i) { CIS_INC_READ(dev); CIS_CLEAR_READ_BANK(dev); cis_read_line_low_level (dev, &buf[1][0], 2048, NULL, NULL, NULL); if (dev->desc->state == STATE_CANCELLED) return SANE_FALSE; for (j=0; j<2048; ++j) { if (buf[0][j] != buf[1][j]) { error = SANE_TRUE; break; } } } DBG (3, "cis_measure_delay: delay %d\n", dev->CIS.delay); if (!error) break; } dev->CIS.res = saved_res; if (error) { fprintf(stderr, "mustek_pp_cis: failed to measure delay.\n"); fprintf(stderr, "Buffer contents:\n"); for (j = 0; j < 20; ++j) { fprintf(stderr, "%d ", buf[1][j]); } fprintf(stderr, "\n"); dev->CIS.delay = 0; } DBG (3, "cis_measure_delay: delay %d\n", dev->CIS.delay); return SANE_TRUE; } static void cis_motor_control (Mustek_PP_CIS_dev * dev, u_char control) { cis_wait_motor_stable (dev); Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, control); } static void cis_return_home (Mustek_PP_CIS_dev * dev, SANE_Bool nowait) { SANE_Byte savedExposeTime = dev->CIS.exposeTime; DBG(4, "cis_return_home: returning home; nowait: %d\n", nowait); /* During a return-home, the expose time is fixed. */ dev->CIS.exposeTime = 170; cis_config_ccd(dev); dev->CIS.exposeTime = savedExposeTime; cis_motor_control (dev, 0xEB); if (nowait == SANE_FALSE) Mustek_PP_1015_wait_bit(dev, MA1015R_MOTOR, MA1015B_MOTOR_HOME, SANE_TRUE, 1000); } /****************************************************************************** * Does a full reset of the device, ie. configures the CIS to a default * resolution of 300 DPI (in high or low resolution mode, depending on the * resolution requested by the user). *****************************************************************************/ static void cis_reset_device (Mustek_PP_CIS_dev * dev) { DBG(4, "cis_reset_device: resetting device\n"); dev->CIS.adjustskip = 0; dev->CIS.dontIncRead = SANE_TRUE; dev->CIS.dontMove = SANE_FALSE; cis_save_state(dev); dev->CIS.hw_hres = 300; dev->CIS.channel = MUSTEK_PP_CIS_CHANNEL_GREEN; dev->CIS.setParameters = SANE_FALSE; dev->CIS.exposeTime = 0xAA; cis_config_ccd (dev); cis_restore_state(dev); } static SANE_Bool cis_calibrate (Mustek_PP_CIS_dev * dev) { int i, saved_res = dev->CIS.res, saved_vres = dev->CIS.hw_vres; /* * Flow of operation observed from the twain driver * (it is assumed that the lamp is at the origin, and that the CIS is * configured for 300 DPI, ie. cis_reset_device has been called.) * * - Reset the device and return the lamp to its home position * * - Unknown short sequence * * - Send a sawtooth-like pattern to one of the memory banks. * * - Repetitive read_line of 2048 bytes, interleaved with an unknown * command. The number varies between 102 and 170 times, but there * doesn't seem to be any correlation with the current mode of the * scanner, so I assume that the exact number isn't really relevant. * The values that are read are the one that were sent to the bank, * rotated by 1 byte in my case. * * * It seems that the width of the black border is being measured at * this stage, possibly multiple times till it stabilizes. * I assume that the buffer is read 100 times to allow the lamp to * warm up and that the width of the black border is then being * measured till it stabilizes. That would explain the minimum number * of 102 iterations that I've seen. * * - reset the device * * - move the motor 110 steps forward. The TWAIN driver moves 90 steps, * and I've used 90 steps for a long time too, but occasionally, * 90 steps is a fraction to short to reach the start of the * calibration strip (the motor movements are not very accurate; * an offset of 1 mm is not unusual). Therefore, I've increased it to * 110 steps. This gives us an additional 1.6 mm slack, which should * prevent calibration errors. * (Note that the MUSTEK_PP_CIS_????CP_DEFAULT_SKIP constants have to * be adjusted if the number of steps is altered.) * * - configure the CIS : actual resolution + set parameters * */ /* * We must make sure that we are in the scanning state; otherwise we may * still be in the canceled state from a previous scan (even if terminated * normally), and the whole calibration would go wrong. */ dev->desc->state = STATE_SCANNING; cis_reset_device (dev); cis_return_home (dev, SANE_FALSE); /* Wait till it's home */ /* Use maximum resolution during calibration; otherwise we may calibrate past the calibration strip. */ dev->CIS.hw_vres = dev->desc->dev->maxres; /* This field remembers how many steps we still have to go @ max res */ dev->CIS.skipsToOrigin = dev->top_skip; /*max2hw_vres(dev, dev->top_skip); */ if (!cis_measure_delay(dev)) return SANE_FALSE; cis_reset_device (dev); /* Move motor 110 steps @ 300 DPI */ Mustek_PP_1015_write_reg_start(dev, MA1015W_MOTOR_CONTROL); for (i=0; i<110; ++i) { if (dev->model == MUSTEK_PP_CIS600) { Mustek_PP_1015_write_reg_val (dev, 0x73); } else { Mustek_PP_1015_write_reg_val (dev, 0x7B); } cis_wait_motor_stable (dev); } Mustek_PP_1015_write_reg_stop(dev); /* Next, we maximize the dynamic range of the scanner. During calibration we don't want to extrapolate, so we limit the resolution if necessary */ if (dev->CIS.hw_hres < dev->CIS.res) dev->CIS.res = dev->CIS.hw_hres; if (!cis_maximize_dynamic_range(dev)) return SANE_FALSE; if (!cis_normalize_ranges(dev)) return SANE_FALSE; dev->CIS.res = saved_res; dev->CIS.hw_vres = saved_vres; /* Convert steps back to max res size, which are used during skipping */ /* dev->CIS.skipsToOrigin = hw2max_vres(dev, dev->CIS.skipsToOrigin); */ /* Move to the origin */ DBG(3, "cis_calibrate: remaining skips to origin @maxres: %d\n", dev->CIS.skipsToOrigin); cis_move_motor(dev, dev->CIS.skipsToOrigin); if (dev->calib_mode) { /* In calibration mode, we scan the interior of the scanner before the glass plate in order to find the position of the calibration strip and the start of the glass plate. */ DBG(3, "cis_calibrate: running in calibration mode. Returning home.\n"); cis_return_home (dev, SANE_FALSE); /* Wait till it's home */ } return dev->desc->state != STATE_CANCELLED ? SANE_TRUE : SANE_FALSE; } /****************************************************************************** ****************************************************************************** *** Mustek PP interface *** ****************************************************************************** *****************************************************************************/ /****************************************************************************** * Init * ******************************************************************************/ /* Shared initialization routine */ static SANE_Status cis_attach(SANE_String_Const port, SANE_String_Const name, SANE_Attach_Callback attach, SANE_Int driverNo, SANE_Int info) { int fd; SANE_Status status; u_char asic; status = sanei_pa4s2_open (port, &fd); if (status != SANE_STATUS_GOOD) { SANE_Status altStatus; SANE_String_Const altPort; DBG (2, "cis_attach: couldn't attach to `%s' (%s)\n", port, sane_strstatus (status)); /* Make migration to libieee1284 painless for users that used direct io in the past */ if (strcmp(port, "0x378") == 0) altPort = "parport0"; else if (strcmp(port, "0x278") == 0) altPort = "parport1"; else if (strcmp(port, "0x3BC") == 0) altPort = "parport2"; else return status; DBG (2, "cis_attach: trying alternative port name: %s\n", altPort); altStatus = sanei_pa4s2_open (altPort, &fd); if (altStatus != SANE_STATUS_GOOD) { DBG (2, "cis_attach: couldn't attach to alternative port `%s' " "(%s)\n", altPort, sane_strstatus (altStatus)); return status; /* Return original status, not alternative status */ } } M1015_START_LL; M1015_START_HL; sanei_pa4s2_enable (fd, SANE_TRUE); SANEI_PA4S2_READBEGIN (fd, 0); SANEI_PA4S2_READBYTE (fd, &asic); SANEI_PA4S2_READEND (fd); sanei_pa4s2_enable (fd, SANE_FALSE); sanei_pa4s2_close (fd); if (asic != 0xA5) /* Identifies the MA1015 chipset */ { /* CIS driver only works for MA1015 chipset */ DBG (2, "cis_attach: asic id (0x%02x) not recognized\n", asic); return SANE_STATUS_INVAL; } DBG (3, "cis_attach: device %s attached\n", name); DBG (3, "cis_attach: asic 0x%02x\n", asic); return attach(port, name, driverNo, info); } SANE_Status cis600_drv_init(SANE_Int options, SANE_String_Const port, SANE_String_Const name, SANE_Attach_Callback attach) { if (options != CAP_NOTHING) return SANE_STATUS_INVAL; return cis_attach(port, name, attach, MUSTEK_PP_CIS600, MUSTEK_PP_CIS600); } SANE_Status cis1200_drv_init(SANE_Int options, SANE_String_Const port, SANE_String_Const name, SANE_Attach_Callback attach) { if (options != CAP_NOTHING) return SANE_STATUS_INVAL; return cis_attach(port, name, attach, MUSTEK_PP_CIS1200, MUSTEK_PP_CIS1200); } SANE_Status cis1200p_drv_init(SANE_Int options, SANE_String_Const port, SANE_String_Const name, SANE_Attach_Callback attach) { if (options != CAP_NOTHING) return SANE_STATUS_INVAL; return cis_attach(port, name, attach, MUSTEK_PP_CIS1200PLUS, MUSTEK_PP_CIS1200PLUS); } /****************************************************************************** * Capabilities * ******************************************************************************/ void cis_drv_capabilities(SANE_Int info, SANE_String *model, SANE_String *vendor, SANE_String *type, SANE_Int *maxres, SANE_Int *minres, SANE_Int *maxhsize, SANE_Int *maxvsize, SANE_Int *caps) { *vendor = strdup("Mustek"); *type = strdup("flatbed scanner"); *caps = CAP_NOTHING; switch(info) { case MUSTEK_PP_CIS600: *model = strdup("600CP"); *maxres = 600; *minres = 50; *maxhsize = MUSTEK_PP_CIS_MAX_H_PIXEL; *maxvsize = MUSTEK_PP_CIS_MAX_V_PIXEL; break; case MUSTEK_PP_CIS1200: *model = strdup("1200CP"); *maxres = 1200; *minres = 50; *maxhsize = MUSTEK_PP_CIS_MAX_H_PIXEL*2; *maxvsize = MUSTEK_PP_CIS_MAX_V_PIXEL*2; break; case MUSTEK_PP_CIS1200PLUS: *model = strdup("1200CP+"); *maxres = 1200; *minres = 50; *maxhsize = MUSTEK_PP_CIS_MAX_H_PIXEL*2; *maxvsize = MUSTEK_PP_CIS_MAX_V_PIXEL*2; break; } } /****************************************************************************** * Open * ******************************************************************************/ SANE_Status cis_drv_open (SANE_String port, SANE_Int caps, SANE_Int *fd) { SANE_Status status; if (caps != CAP_NOTHING) { DBG (1, "cis_drv_open: called with unknown capabilities (0x%02X)\n", caps); return SANE_STATUS_INVAL; } DBG (3, "cis_drv_open: called for port %s\n", port); status = sanei_pa4s2_open (port, fd); if (status != SANE_STATUS_GOOD) { SANE_Status altStatus; SANE_String_Const altPort; DBG (2, "cis_attach: couldn't attach to `%s' (%s)\n", port, sane_strstatus (status)); /* Make migration to libieee1284 painless for users that used direct io in the past */ if (strcmp(port, "0x378") == 0) altPort = "parport0"; else if (strcmp(port, "0x278") == 0) altPort = "parport1"; else if (strcmp(port, "0x3BC") == 0) altPort = "parport2"; else return status; DBG (2, "cis_attach: trying alternative port name: %s\n", altPort); altStatus = sanei_pa4s2_open (altPort, fd); if (altStatus != SANE_STATUS_GOOD) { DBG (2, "cis_attach: couldn't attach to alternative port `%s' " "(%s)\n", altPort, sane_strstatus (altStatus)); return status; /* Return original status, not alternative status */ } } return SANE_STATUS_GOOD; } /****************************************************************************** * Setup * ******************************************************************************/ void cis_drv_setup (SANE_Handle hndl) { Mustek_pp_Handle *dev = hndl; Mustek_PP_CIS_dev *cisdev; cisdev = (Mustek_PP_CIS_dev*)malloc(sizeof(Mustek_PP_CIS_dev)); if (cisdev == NULL) { DBG (2, "cis_drv_setup: not enough memory for device descriptor\n"); sanei_pa4s2_close (dev->fd); return; } memset(cisdev, 0, sizeof(Mustek_PP_CIS_dev)); DBG(3, "cis_drv_setup: cis device allocated\n"); dev->lamp_on = 0; dev->priv = cisdev; cisdev->desc = dev; cisdev->model = dev->dev->info; cisdev->CIS.hw_hres = 300; cisdev->CIS.cisRes = 300; cisdev->CIS.hw_vres = 300; /* Default values for configurable parameters; configuration file may override them. */ cisdev->fast_skip = SANE_TRUE; cisdev->bw_limit = 127; cisdev->calib_mode = SANE_FALSE; cisdev->engine_delay = 0; if (cisdev->model == MUSTEK_PP_CIS600) { cisdev->top_skip = MUSTEK_PP_CIS_600CP_DEFAULT_SKIP; } else { cisdev->top_skip = MUSTEK_PP_CIS_1200CP_DEFAULT_SKIP; } } /****************************************************************************** * Config * ******************************************************************************/ SANE_Status cis_drv_config(SANE_Handle hndl, SANE_String_Const optname, SANE_String_Const optval) { Mustek_pp_Handle *dev = hndl; Mustek_PP_CIS_dev *cisdev = dev->priv; int value = 0; double dvalue = 0; DBG (3, "cis_drv_cfg option: %s=%s\n", optname, optval ? optval : ""); if (!strcmp(optname, "top_adjust")) { if (!optval) { DBG (1, "cis_drv_config: missing value for option top_adjust\n"); return SANE_STATUS_INVAL; } dvalue = atof(optval); /* An adjustment of +/- 5 mm should be sufficient and safe */ if (dvalue < -5.0) { DBG (1, "cis_drv_config: value for option top_adjust too small: " "%.2f < -5; limiting to -5 mm\n", dvalue); dvalue = -5.0; } if (dvalue > 5.0) { DBG (1, "cis_drv_config: value for option top_adjust too large: " "%.2f > 5; limiting to 5 mm\n", dvalue); dvalue = 5.0; } /* In practice, there is a lower bound on the value that can be used, but if the top_skip value is smaller than that value, the only result will be that the driver tries to move the head a negative number of steps after calibration. The move routine just ignores negative steps, so no harm can be done. */ cisdev->top_skip += MM_TO_PIXEL(dvalue, dev->dev->maxres); DBG (3, "cis_drv_config: setting top skip value to %d\n", cisdev->top_skip); /* Just to be cautious; we don't want the head to hit the bottom */ if (cisdev->top_skip > 600) cisdev->top_skip = 600; if (cisdev->top_skip < -600) cisdev->top_skip = -600; } else if (!strcmp(optname, "slow_skip")) { if (optval) { DBG (1, "cis_drv_config: unexpected value for option slow_skip\n"); return SANE_STATUS_INVAL; } DBG (3, "cis_drv_config: disabling fast skipping\n"); cisdev->fast_skip = SANE_FALSE; } else if (!strcmp(optname, "bw")) { if (!optval) { DBG (1, "cis_drv_config: missing value for option bw\n"); return SANE_STATUS_INVAL; } value = atoi(optval); if (value < 0 || value > 255) { DBG (1, "cis_drv_config: value for option bw out of range: " "%d < 0 or %d > 255\n", value, value); return SANE_STATUS_INVAL; } cisdev->bw_limit = value; } else if (!strcmp(optname, "calibration_mode")) { if (optval) { DBG (1, "cis_drv_config: unexpected value for option calibration_mode\n"); return SANE_STATUS_INVAL; } DBG (3, "cis_drv_config: using calibration mode\n"); cisdev->calib_mode = SANE_TRUE; } else if (!strcmp(optname, "engine_delay")) { if (!optval) { DBG (1, "cis_drv_config: missing value for option engine_delay\n"); return SANE_STATUS_INVAL; } value = atoi(optval); if (value < 0 || value > 100) /* 100 ms is already pretty slow */ { DBG (1, "cis_drv_config: value for option engine_delay out of range: " "%d < 0 or %d > 100\n", value, value); return SANE_STATUS_INVAL; } cisdev->engine_delay = value; } else { DBG (1, "cis_drv_config: unknown options %s\n", optname); return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /****************************************************************************** * Close * ******************************************************************************/ void cis_drv_close (SANE_Handle hndl) { Mustek_pp_Handle *dev = hndl; Mustek_PP_CIS_dev *cisdev = dev->priv; DBG (3, "cis_close: resetting device.\n"); sanei_pa4s2_enable (dev->fd, SANE_TRUE); cis_reset_device (cisdev); DBG (3, "cis_close: returning home.\n"); cis_return_home (cisdev, SANE_TRUE); /* Don't wait */ DBG (3, "cis_close: disabling fd.\n"); sanei_pa4s2_enable (dev->fd, SANE_FALSE); DBG (3, "cis_close: closing fd.\n"); sanei_pa4s2_close (dev->fd); DBG (3, "cis_close: done.\n"); DBG (6, "cis_close: lamp_on: %d\n", (int)dev->lamp_on); M1015_STOP_LL; M1015_STOP_HL; } /****************************************************************************** * Start * ******************************************************************************/ SANE_Status cis_drv_start (SANE_Handle hndl) { Mustek_pp_Handle *dev = hndl; Mustek_PP_CIS_dev *cisdev = dev->priv; SANE_Int pixels = dev->params.pixels_per_line; if (!cisdev) { DBG (2, "cis_drv_start: not enough memory for device\n"); return SANE_STATUS_NO_MEM; } cisdev->CIS.exposeTime = 0xAA; cisdev->CIS.setParameters = SANE_FALSE; cisdev->CIS.use8KBank = SANE_TRUE; cisdev->CIS.imagebytes = dev->bottomX - dev->topX; cisdev->CIS.skipimagebytes = dev->topX; cisdev->CIS.res = dev->res; DBG (3, "cis_drv_start: %d dpi\n", dev->res); if (dev->res <= 50 && cisdev->model != MUSTEK_PP_CIS1200PLUS) { cisdev->CIS.hw_hres = 50; } else if (dev->res <= 75 && cisdev->model == MUSTEK_PP_CIS1200PLUS) { cisdev->CIS.hw_hres = 75; } else if (dev->res <= 100) { cisdev->CIS.hw_hres = 100; } else if (dev->res <= 200) { cisdev->CIS.hw_hres = 200; } else if (dev->res <= 300) { cisdev->CIS.hw_hres = 300; } else { if (cisdev->model == MUSTEK_PP_CIS600) { cisdev->CIS.hw_hres = 300; /* Limit for 600 CP */ } else if (dev->res <= 400) { cisdev->CIS.hw_hres = 400; } else { cisdev->CIS.hw_hres = 600; /* Limit for 1200 CP/CP+ */ } } if (cisdev->model == MUSTEK_PP_CIS600) { if (dev->res <= 150) { cisdev->CIS.hw_vres = 150; } else if (dev->res <= 300) { cisdev->CIS.hw_vres = 300; } else { cisdev->CIS.hw_vres = 600; } } else { if (dev->res <= 300) { cisdev->CIS.hw_vres = 300; } else if (dev->res <= 600) { cisdev->CIS.hw_vres = 600; } else { cisdev->CIS.hw_vres = 1200; } } if (cisdev->model == MUSTEK_PP_CIS600 || (cisdev->model == MUSTEK_PP_CIS1200 && dev->res <= 300)) cisdev->CIS.cisRes = 300; else cisdev->CIS.cisRes = 600; /* Calibration only makes sense for hardware pixels, not for interpolated pixels, so we limit the number of calibration pixels to the maximum number of hardware pixels corresponding to the selected area */ if (dev->res > cisdev->CIS.hw_hres) cisdev->calib_pixels = (pixels * cisdev->CIS.hw_hres) / dev->res; else cisdev->calib_pixels = pixels; DBG (3, "cis_drv_start: hres: %d vres: %d cisres: %d\n", cisdev->CIS.hw_hres, cisdev->CIS.hw_vres, cisdev->CIS.cisRes); sanei_pa4s2_enable (dev->fd, SANE_TRUE); cis_reset_device (cisdev); cis_return_home (cisdev, SANE_TRUE); /* Don't wait here */ #ifdef M1015_TRACE_REGS { int i, j; /* * Set all registers to -1 (uninitialized) */ for (i=0; i<4; ++i) { cisdev->CIS.regs.in_regs[i] = -1; for (j=0; j<4; ++j) { cisdev->CIS.regs.out_regs[i][j] = -1; } } cisdev->CIS.regs.channel = -1; /* These values have been read earlier. */ cisdev->CIS.regs.in_regs[0] = 0xA5; } #endif cis_reset_device (cisdev); cis_return_home (cisdev, SANE_TRUE); /* no wait */ /* Allocate memory for temporary color buffer */ cisdev->tmpbuf = malloc (pixels); if (cisdev->tmpbuf == NULL) { sanei_pa4s2_enable (dev->fd, SANE_FALSE); DBG (2, "cis_drv_start: not enough memory for temporary buffer\n"); free(cisdev); dev->priv = NULL; return SANE_STATUS_NO_MEM; } /* Allocate memory for calibration; calibrating interpolated pixels makes no sense */ if (pixels > (dev->dev->maxhsize >> 1)) pixels = (dev->dev->maxhsize >> 1); cisdev->calib_low[1] = malloc (pixels); cisdev->calib_hi[1] = malloc (pixels); if (cisdev->calib_low[1] == NULL || cisdev->calib_hi[1] == NULL) { free (cisdev->calib_low[1]); cisdev->calib_low[1] = NULL; free (cisdev->calib_hi[1]); cisdev->calib_hi[1] = NULL; sanei_pa4s2_enable (dev->fd, SANE_FALSE); DBG (2, "cis_drv_start: not enough memory for calibration buffer\n"); free(cisdev->tmpbuf); cisdev->tmpbuf = NULL; free(cisdev); dev->priv = NULL; return SANE_STATUS_NO_MEM; } cisdev->calib_low[0] = NULL; cisdev->calib_low[2] = NULL; cisdev->calib_hi[0] = NULL; cisdev->calib_hi[2] = NULL; if (dev->mode == MODE_COLOR) { cisdev->calib_low[0] = malloc (pixels); cisdev->calib_low[2] = malloc (pixels); cisdev->calib_hi[0] = malloc (pixels); cisdev->calib_hi[2] = malloc (pixels); if ((cisdev->calib_low[0] == NULL) || (cisdev->calib_low[2] == NULL) || (cisdev->calib_hi[0] == NULL) || (cisdev->calib_hi[2] == NULL)) { free (cisdev->calib_low[0]); cisdev->calib_low[0] = NULL; free (cisdev->calib_low[1]); cisdev->calib_low[1] = NULL; free (cisdev->calib_low[2]); cisdev->calib_low[2] = NULL; free (cisdev->calib_hi[0]); cisdev->calib_hi[0] = NULL; free (cisdev->calib_hi[1]); cisdev->calib_hi[1] = NULL; free (cisdev->calib_hi[2]); cisdev->calib_hi[2] = NULL; free(cisdev->tmpbuf); cisdev->tmpbuf = NULL; free(cisdev); dev->priv = NULL; sanei_pa4s2_enable (dev->fd, SANE_FALSE); DBG (2, "cis_drv_start: not enough memory for color calib buffer\n"); return SANE_STATUS_NO_MEM; } } DBG (3, "cis_drv_start: executing calibration\n"); if (!cis_calibrate (cisdev)) { free (cisdev->calib_low[0]); cisdev->calib_low[0] = NULL; free (cisdev->calib_low[1]); cisdev->calib_low[1] = NULL; free (cisdev->calib_low[2]); cisdev->calib_low[2] = NULL; free (cisdev->calib_hi[0]); cisdev->calib_hi[0] = NULL; free (cisdev->calib_hi[1]); cisdev->calib_hi[1] = NULL; free (cisdev->calib_hi[2]); cisdev->calib_hi[2] = NULL; free(cisdev->tmpbuf); cisdev->tmpbuf = NULL; free(cisdev); dev->priv = NULL; return SANE_STATUS_CANCELLED; /* Most likely cause */ } /* M1015_DISPLAY_REGS(dev, "after calibration"); */ cis_get_bank_count(cisdev); cis_move_motor (cisdev, dev->topY); /* Measured in max resolution */ /* It is vital to reinitialize the scanner right before we start the real scanning. Otherwise the bank synchronization may have gotten lost by the time we reach the top of the scan area */ cisdev->CIS.setParameters = SANE_TRUE; cis_config_ccd(cisdev); cis_wait_read_ready(cisdev); sanei_pa4s2_enable (dev->fd, SANE_FALSE); cisdev->CIS.line_step = SANE_FIX ((float) cisdev->CIS.hw_vres / (float) cisdev->CIS.res); /* * It is very important that line_diff is not initialized at zero ! * If it is set to zero, the motor will keep on moving forever (or better, * till the scanner breaks). */ cisdev->line_diff = cisdev->CIS.line_step; cisdev->ccd_line = 0; cisdev->line = 0; cisdev->lines_left = dev->params.lines; dev->state = STATE_SCANNING; DBG (3, "cis_drv_start: device ready for scanning\n"); return SANE_STATUS_GOOD; } /****************************************************************************** * Read * ******************************************************************************/ void cis_drv_read (SANE_Handle hndl, SANE_Byte *buffer) { Mustek_pp_Handle *dev = hndl; Mustek_PP_CIS_dev *cisdev = dev->priv; DBG(6, "cis_drv_read: Reading line\n"); sanei_pa4s2_enable (dev->fd, SANE_TRUE); switch (dev->mode) { case MODE_BW: cis_get_lineart_line(cisdev, buffer); break; case MODE_GRAYSCALE: cis_get_grayscale_line(cisdev, buffer); break; case MODE_COLOR: cis_get_color_line(cisdev, buffer); break; } sanei_pa4s2_enable (dev->fd, SANE_FALSE); } /****************************************************************************** * Stop * ******************************************************************************/ void cis_drv_stop (SANE_Handle hndl) { Mustek_pp_Handle *dev = hndl; Mustek_PP_CIS_dev *cisdev = dev->priv; /* device is scanning: return lamp and free buffers */ DBG (3, "cis_drv_stop: stopping current scan\n"); dev->state = STATE_CANCELLED; DBG (9, "cis_drv_stop: enabling fd\n"); sanei_pa4s2_enable (dev->fd, SANE_TRUE); Mustek_PP_1015_write_reg(cisdev, MA1015W_MOTOR_CONTROL, 0); /* stop */ DBG (9, "cis_drv_stop: resetting device (1)\n"); cis_reset_device (cisdev); DBG (9, "cis_drv_stop: returning home\n"); cis_return_home (cisdev, SANE_TRUE); /* don't wait */ DBG (9, "cis_drv_stop: resetting device (2)\n"); cis_reset_device (cisdev); DBG (9, "cis_drv_stop: disabling fd\n"); sanei_pa4s2_enable (dev->fd, SANE_FALSE); DBG (9, "cis_drv_stop: freeing buffers\n"); /* This is no good: canceling while the device is scanning and freeing the data buffers can result in illegal memory accesses if the device is still scanning in another thread. */ free (cisdev->calib_low[1]); cisdev->calib_low[1] = NULL; free (cisdev->calib_hi[1]); cisdev->calib_hi[1] = NULL; free (cisdev->tmpbuf); cisdev->tmpbuf = NULL; DBG (3, "cis_drv_stop: freed green and temporary buffers\n"); if (cisdev->CIS.mode == MODE_COLOR) { free (cisdev->calib_low[0]); cisdev->calib_low[0] = NULL; free (cisdev->calib_low[2]); cisdev->calib_low[2] = NULL; free (cisdev->calib_hi[0]); cisdev->calib_hi[0] = NULL; free (cisdev->calib_hi[2]); cisdev->calib_hi[2] = NULL; } DBG (3, "cis_drv_stop: freed buffers\n"); DBG (6, "cis_drv_stop: lamp_on: %d\n", (int)dev->lamp_on); } sane-backends-1.0.29/backend/hp.h0000666000000000000000000001511413615534521013352 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Geoffrey T. Dairiki 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP Scanners supporting HP Scanner Control Language (SCL). */ #ifndef HP_H_INCLUDED #define HP_H_INCLUDED #include #include #include "../include/sane/sane.h" #undef BACKEND_NAME #define BACKEND_NAME hp #define DEBUG_NOT_STATIC #include "../include/sane/sanei_debug.h" /* FIXME: these should be options? */ #undef ENABLE_7x12_TONEMAPS #define ENABLE_16x16_DITHERS #define ENABLE_10BIT_MATRIXES #define FAKE_COLORSEP_MATRIXES #undef ENABLE_CUSTOM_MATRIX #define HP_CONFIG_FILE STRINGIFY(BACKEND_NAME) ".conf" #define DEVPIX_PER_INCH 300.0 #define MM_PER_DEVPIX (MM_PER_INCH / DEVPIX_PER_INCH) /* * Macros for testing return values of functions which * return SANE_Status types. */ #define FAILED(status) (status != SANE_STATUS_GOOD) #define UNSUPPORTED(status) (status == SANE_STATUS_UNSUPPORTED) #define RETURN_IF_FAIL(try) do { \ SANE_Status status = (try); \ if (FAILED(status)) \ return status; \ } while (0) #define CATCH_RET_FAIL(try, catch) do { \ SANE_Status status = (try); \ if (FAILED(status)) { (catch); return status; } \ } while (0) #ifndef DBG_LEVEL #define DBG_LEVEL PASTE(sanei_debug_, BACKEND_NAME) #endif #ifndef NDEBUG # define DBGDUMP(level, buf, size) \ do { if (DBG_LEVEL >= (level)) sanei_hp_dbgdump(buf, size); } while (0) #else # define DBGDUMP(level, buf, size) #endif /* * */ typedef unsigned int hp_bool_t; typedef unsigned char hp_byte_t; typedef enum { HP_CONNECT_SCSI, HP_CONNECT_DEVICE, HP_CONNECT_PIO, HP_CONNECT_USB, HP_CONNECT_RESERVE } HpConnect; typedef struct { HpConnect connect; hp_bool_t got_connect_type; hp_bool_t use_scsi_request; hp_bool_t use_image_buffering; hp_bool_t dumb_read; } HpDeviceConfig; #define HP_SCL_INQID_MIN 10306 #define HP_SCL_INQID_MAX 10971 typedef struct { hp_bool_t checked, is_supported; int minval, maxval; } HpSclSupport; typedef struct { /* Flags for simulated commands */ hp_bool_t sclsimulate[HP_SCL_INQID_MAX - HP_SCL_INQID_MIN + 1]; hp_bool_t gamma_simulate; unsigned char brightness_map[256]; /* Map to simulate brightness level */ unsigned char contrast_map[256]; /* Map to simulate contrast level */ unsigned char gamma_map[256]; /* Map to simulate custom gamma table */ } HpSimulate; /* Information about a connected device */ typedef struct { char devname[64]; /* unique device name */ hp_bool_t config_is_up; /* flag if config-struct is valid */ HpDeviceConfig config; /* device configuration*/ /* List of command support */ HpSclSupport sclsupport[HP_SCL_INQID_MAX - HP_SCL_INQID_MIN + 1]; HpSimulate simulate; /* Info about simulations */ hp_bool_t unload_after_scan; int active_xpa; int max_model; } HpDeviceInfo; HpDeviceInfo *sanei_hp_device_info_get (const char *dev_name); /* hp-scl.c */ #if INT_MAX > 30000 typedef int HpScl; #else typedef long int HpScl; #endif void sanei_hp_init_openfd (void); typedef struct { int lines; int bytes_per_line; /* as received from scanner */ int bits_per_channel; hp_bool_t out8; /* This flag is set and only set, when data with */ /* depths > 8 is to be mapped to 8 bit output. */ hp_bool_t mirror_vertical; hp_bool_t invert; HpScl startscan; } HpProcessData; /* hp-option.c */ typedef SANE_Option_Descriptor * HpSaneOption; typedef const struct hp_choice_s * HpChoice; typedef struct hp_option_s * HpOption; typedef const struct hp_option_descriptor_s * HpOptionDescriptor; typedef struct hp_optset_s * HpOptSet; /* hp-accessor.c */ typedef struct hp_data_s * HpData; typedef struct hp_accessor_s * HpAccessor; typedef struct hp_accessor_vector_s * HpAccessorVector; typedef struct hp_accessor_choice_s * HpAccessorChoice; /* hp-device.c */ typedef struct hp_device_s * HpDevice; hp_bool_t sanei_hp_device_simulate_get (const char *devname, HpScl scl); HpDevice sanei_hp_device_get (const char *dev_name); /* hp-handle.c */ typedef struct hp_handle_s * HpHandle; /* hp-scsi.c */ typedef struct hp_scsi_s * HpScsi; /* hp-scl.c */ hp_bool_t sanei_hp_is_active_xpa (HpScsi scsi); int sanei_hp_get_max_model (HpScsi scsi); int sanei_hp_is_flatbed_adf (HpScsi scsi); HpConnect sanei_hp_get_connect (const char *devname); HpConnect sanei_hp_scsi_get_connect (HpScsi this); /* hp.c */ #ifndef NDEBUG void sanei_hp_dbgdump (const void * bufp, size_t len); #endif /* hp-hpmem.c */ void * sanei_hp_alloc(size_t sz); void * sanei_hp_allocz(size_t sz); void * sanei_hp_memdup(const void * src, size_t sz); char * sanei_hp_strdup(const char * str); void * sanei_hp_realloc(void * ptr, size_t sz); void sanei_hp_free(void * ptr); void sanei_hp_free_all(void); #endif /* HP_H_INCLUDED */ sane-backends-1.0.29/backend/dc210.c0000666000000000000000000010446413615534521013556 00000000000000/*************************************************************************** * SANE - Scanner Access Now Easy. dc210.c 11/11/98 This file (C) 1998 Brian J. Murrell 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. *************************************************************************** This file implements a SANE backend for the Kodak DC-210 digital camera. THIS IS EXTREMELY ALPHA CODE! USE AT YOUR OWN RISK!! (feedback to: sane-dc210@interlinx.bc.ca This backend is based somewhat on the dc25 backend included in this package by Peter Fales ***************************************************************************/ #include "../include/sane/config.h" #include #include #include #include #include #include #include "../include/sane/sanei_jpeg.h" #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #define BACKEND_NAME dc210 #include "../include/sane/sanei_backend.h" #include "dc210.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #define MAGIC (void *)0xab730324 #define DC210_CONFIG_FILE "dc210.conf" #define THUMBSIZE 20736 #ifdef B115200 # define DEFAULT_BAUD_RATE B115200 #else # define DEFAULT_BAUD_RATE B38400 #endif #if defined (__sgi) # define DEFAULT_TTY "/dev/ttyd1" /* Irix */ #elif defined (__sun) # define DEFAULT_TTY "/dev/term/a" /* Solaris */ #elif defined (hpux) # define DEFAULT_TTY "/dev/tty1d0" /* HP-UX */ #elif defined (__osf__) # define DEFAULT_TTY "/dev/tty00" /* Digital UNIX */ #else # define DEFAULT_TTY "/dev/ttyS0" /* Linux */ #endif static SANE_Bool is_open = 0; static SANE_Bool dc210_opt_thumbnails; static SANE_Bool dc210_opt_snap; static SANE_Bool dc210_opt_lowres; static SANE_Bool dc210_opt_erase; static SANE_Bool dumpinquiry; static struct jpeg_decompress_struct cinfo; static djpeg_dest_ptr dest_mgr = NULL; static unsigned long cmdrespause = 250000UL; /* pause after sending cmd */ static unsigned long breakpause = 1000000UL; /* pause after sending break */ static int bytes_in_buffer; static int bytes_read_from_buffer; static int total_bytes_read; static DC210 Camera; static SANE_Range image_range = { 0, 14, 0 }; static SANE_Option_Descriptor sod[] = { { SANE_NAME_NUM_OPTIONS, SANE_TITLE_NUM_OPTIONS, SANE_DESC_NUM_OPTIONS, SANE_TYPE_INT, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define D25_OPT_IMAGE_SELECTION 1 { "", "Image Selection", "Selection of the image to load.", SANE_TYPE_GROUP, SANE_UNIT_NONE, 0, 0, SANE_CONSTRAINT_NONE, {NULL} } , #define DC210_OPT_IMAGE_NUMBER 2 { "image", "Image Number", "Select Image Number to load from camera", SANE_TYPE_INT, SANE_UNIT_NONE, 4, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(void *) & image_range} } , #define DC210_OPT_THUMBS 3 { "thumbs", "Load Thumbnail", "Load the image as thumbnail.", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define DC210_OPT_SNAP 4 { "snap", "Snap new picture", "Take new picture and download it", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT /* | SANE_CAP_ADVANCED */ , SANE_CONSTRAINT_NONE, {NULL} } , #define DC210_OPT_LOWRES 5 { "lowres", "Low Resolution", "Resolution of new pictures", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE /* | SANE_CAP_ADVANCED */ , SANE_CONSTRAINT_NONE, {NULL} } , #define DC210_OPT_ERASE 6 { "erase", "Erase", "Erase the picture after downloading", SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define DC210_OPT_DEFAULT 7 { "default-enhancements", "Defaults", "Set default values for enhancement controls.", SANE_TYPE_BUTTON, SANE_UNIT_NONE, 0, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } , #define DC210_OPT_INIT_DC210 8 { "camera-init", "Re-establish Communications", "Re-establish communications with camera (in case of timeout, etc.)", SANE_TYPE_BUTTON, SANE_UNIT_NONE, 0, SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} } }; static SANE_Parameters parms = { SANE_FRAME_RGB, 0, 0, /* Number of bytes returned per scan line: */ 0, /* Number of pixels per scan line. */ 0, /* Number of lines for the current scan. */ 8, /* Number of bits per sample. */ }; static unsigned char shoot_pck[] = SHOOT_PCK; static unsigned char init_pck[] = INIT_PCK; static unsigned char thumb_pck[] = THUMBS_PCK; static unsigned char pic_pck[] = PICS_PCK; static unsigned char pic_info_pck[] = PICS_INFO_PCK; static unsigned char info_pck[] = INFO_PCK; static unsigned char erase_pck[] = ERASE_PCK; static unsigned char res_pck[] = RES_PCK; static struct pkt_speed speeds[] = SPEEDS; static struct termios tty_orig; #include #include static int send_pck (int fd, unsigned char *pck) { int n; unsigned char r = 0xf0; /* prime the loop with a "camera busy" */ /* keep trying if camera says it's busy */ while (r == 0xf0) { /* * Not quite sure why we need this, but the program works a whole * lot better (at least on the DC210) with this short delay. */ if (write (fd, (char *) pck, 8) != 8) { DBG (2, "send_pck: error: write returned -1\n"); return -1; } /* need to wait before we read command result */ usleep (cmdrespause); if ((n = read (fd, (char *) &r, 1)) != 1) { DBG (2, "send_pck: error: read returned -1\n"); return -1; } } return (r == 0xd1) ? 0 : -1; } static int init_dc210 (DC210 * camera) { struct termios tty_new; int speed_index; for (speed_index = 0; speed_index < NELEMS (speeds); speed_index++) { if (speeds[speed_index].baud == camera->baud) { init_pck[2] = speeds[speed_index].pkt_code[0]; init_pck[3] = speeds[speed_index].pkt_code[1]; break; } } if (init_pck[2] == 0) { DBG (2, "unsupported baud rate.\n"); return -1; } /* Open device file. */ if ((camera->fd = open (camera->tty_name, O_RDWR)) == -1) { DBG (2, "init_dc210: error: could not open %s for read/write\n", camera->tty_name); return -1; } /* Save old device information to restore when we are done. */ if (tcgetattr (camera->fd, &tty_orig) == -1) { DBG (2, "init_dc210: error: could not get attributes\n"); return -1; } memcpy ((char *) &tty_new, (char *) &tty_orig, sizeof (struct termios)); /* We need the device to be raw. 8 bits even parity on 9600 baud to start. */ #ifdef HAVE_CFMAKERAW cfmakeraw (&tty_new); #else /* Modified to set the port REALLY as required. Code inspired by the gPhoto2 serial port setup */ /* input control settings */ tty_new.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | IUCLC | IXANY | IXON | IXOFF | INPCK | ISTRIP); tty_new.c_iflag |= (BRKINT | IGNPAR); /* output control settings */ tty_new.c_oflag &= ~OPOST; /* hardware control settings */ tty_new.c_cflag = (tty_new.c_cflag & ~CSIZE) | CS8; tty_new.c_cflag &= ~(PARENB | PARODD | CSTOPB); # if defined(__sgi) tty_new.c_cflag &= ~CNEW_RTSCTS; # else /* OS/2 doesn't have CRTSCTS - will this work for them? */ # ifdef CRTSCTS tty_new.c_cflag &= ~CRTSCTS; # endif # endif tty_new.c_cflag |= CLOCAL | CREAD; #endif /* line discipline settings */ tty_new.c_lflag &= ~(ICANON | ISIG | ECHO | ECHONL | ECHOE | ECHOK | IEXTEN); tty_new.c_cc[VMIN] = 0; tty_new.c_cc[VTIME] = 5; cfsetospeed (&tty_new, B9600); cfsetispeed (&tty_new, B9600); if (tcsetattr (camera->fd, TCSANOW, &tty_new) == -1) { DBG (2, "init_dc210: error: could not set attributes\n"); return -1; } /* send a break to get it back to a known state */ /* Used to supply a non-zero argument to tcsendbreak(), TCSBRK, * and TCSBRKP, but that is system dependent. e.g. on irix a non-zero * value does a drain instead of a break. A zero value is universally * used to send a break. */ #ifdef HAVE_TCSENDBREAK tcsendbreak (camera->fd, 0); # if defined(__sgi) tcdrain (camera->fd); # endif # elif defined(TCSBRKP) ioctl (camera->fd, TCSBRKP, 0); # elif defined(TCSBRK) ioctl (camera->fd, TCSBRK, 0); #endif /* and wait for it to recover from the break */ #ifdef HAVE_USLEEP usleep (breakpause); #else sleep (1); #endif if (send_pck (camera->fd, init_pck) == -1) { /* * The camera always powers up at 9600, so we try * that first. However, it may be already set to * a different speed. Try the entries in the table: */ for (speed_index = NELEMS (speeds) - 1; speed_index > 0; speed_index--) { int x; DBG (3, "init_dc210: changing speed to %d\n", (int) speeds[speed_index].baud); cfsetospeed (&tty_new, speeds[speed_index].baud); cfsetispeed (&tty_new, speeds[speed_index].baud); if (tcsetattr (camera->fd, TCSANOW, &tty_new) == -1) { DBG (2, "init_dc210: error: could not set attributes\n"); return -1; } for (x = 0; x < 3; x++) if (send_pck (camera->fd, init_pck) != -1) break; } if (speed_index == 0) { tcsetattr (camera->fd, TCSANOW, &tty_orig); DBG (2, "init_dc210: error: no suitable baud rate\n"); return -1; } } /* Set speed to requested speed. */ cfsetospeed (&tty_new, Camera.baud); cfsetispeed (&tty_new, Camera.baud); if (tcsetattr (camera->fd, TCSANOW, &tty_new) == -1) { DBG (2, "init_dc210: error: could not set attributes\n"); return -1; } return camera->fd; } static void close_dc210 (int fd) { /* * Put the camera back to 9600 baud */ if (close (fd) == -1) { DBG (4, "close_dc210: error: could not close device\n"); } } int get_info (DC210 * camera) { char f[] = "get_info"; unsigned char buf[256]; if (send_pck (camera->fd, info_pck) == -1) { DBG (2, "%s: error: send_pck returned -1\n", f); return -1; } DBG (9, "%s: read info packet\n", f); if (read_data (camera->fd, buf, 256) == -1) { DBG (2, "%s: error: read_data returned -1\n", f); return -1; } if (end_of_data (camera->fd) == -1) { DBG (2, "%s: error: end_of_data returned -1\n", f); return -1; } camera->model = buf[1]; camera->ver_major = buf[2]; camera->ver_minor = buf[3]; camera->pic_taken = buf[56] << 8 | buf[57]; camera->pic_left = buf[72] << 8 | buf[73]; camera->flags.low_res = buf[22]; camera->flags.low_batt = buf[8]; return 0; } static int read_data (int fd, unsigned char *buf, int sz) { unsigned char ccsum; unsigned char rcsum; unsigned char c; int n; int r = 0; int i; /* read the control byte */ if (read (fd, &c, 1) != 1) { DBG (2, "read_data: error: read for packet control byte returned bad status\n"); return -1; } if (c != 1) { DBG (2, "read_data: error: incorrect packet control byte: %02x\n", c); return -1; } for (n = 0; n < sz && (r = read (fd, (char *) &buf[n], sz - n)) > 0; n += r) ; if (r <= 0) { DBG (2, "read_data: error: read returned -1\n"); return -1; } if (n < sz || read (fd, &rcsum, 1) != 1) { DBG (2, "read_data: error: buffer underrun or no checksum\n"); return -1; } for (i = 0, ccsum = 0; i < n; i++) ccsum ^= buf[i]; if (ccsum != rcsum) { DBG (2, "read_data: error: bad checksum (%02x !=%02x)\n", rcsum, ccsum); return -1; } c = 0xd2; if (write (fd, (char *) &c, 1) != 1) { DBG (2, "read_data: error: write ack\n"); return -1; } return 0; } static int end_of_data (int fd) { unsigned char c; do { /* loop until the camera isn't busy */ if (read (fd, &c, 1) != 1) { DBG (2, "end_of_data: error: read returned -1\n"); return -1; } if (c == 0) /* got successful end of data */ return 0; /* return success */ sleep (1); /* not too fast */ } while (c == 0xf0); /* Accck! Not busy, but not a good end of data either */ if (c != 0) { DBG (2, "end_of_data: error: bad EOD from camera (%02x)\n", (unsigned) c); return -1; } return 0; /* should never get here but shut gcc -Wall up */ } static int erase (int fd) { if (send_pck (fd, erase_pck) == -1) { DBG (3, "erase: error: send_pck returned -1\n"); return -1; } if (end_of_data (fd) == -1) { DBG (3, "erase: error: end_of_data returned -1\n"); return -1; } return 0; } static int change_res (int fd, unsigned char res) { char f[] = "change_res"; DBG (127, "%s called\n", f); if (res != 0 && res != 1) { DBG (3, "%s: error: unsupported resolution\n", f); return -1; } /* cameras resolution semantics are opposite of ours */ res = !res; DBG (127, "%s: setting res to %d\n", f, res); res_pck[2] = res; if (send_pck (fd, res_pck) == -1) { DBG (4, "%s: error: send_pck returned -1\n", f); } if (end_of_data (fd) == -1) { DBG (4, "%s: error: end_of_data returned -1\n", f); } return 0; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { char f[] = "sane_init"; char dev_name[PATH_MAX], *p; size_t len; FILE *fp; int baud; DBG_INIT (); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (DC210_CONFIG_FILE); /* defaults */ Camera.baud = DEFAULT_BAUD_RATE; Camera.tty_name = DEFAULT_TTY; if (!fp) { /* default to /dev/whatever instead of insisting on config file */ DBG (1, "%s: missing config file '%s'\n", f, DC210_CONFIG_FILE); } else { while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { dev_name[sizeof (dev_name) - 1] = '\0'; DBG (20, "%s: config- %s\n", f, dev_name); if (dev_name[0] == '#') continue; /* ignore line comments */ len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ if (strncmp (dev_name, "port=", 5) == 0) { p = strchr (dev_name, '/'); if (p) Camera.tty_name = strdup (p); DBG (20, "Config file port=%s\n", Camera.tty_name); } else if (strncmp (dev_name, "baud=", 5) == 0) { baud = atoi (&dev_name[5]); switch (baud) { case 9600: Camera.baud = B9600; break; case 19200: Camera.baud = B19200; break; case 38400: Camera.baud = B38400; break; #ifdef B57600 case 57600: Camera.baud = B57600; break; #endif #ifdef B115200 case 115200: Camera.baud = B115200; break; #endif } DBG (20, "Config file baud=%d\n", Camera.baud); } else if (strcmp (dev_name, "dumpinquiry") == 0) { dumpinquiry = SANE_TRUE; } else if (strncmp (dev_name, "cmdrespause=", 12) == 0) { cmdrespause = atoi (&dev_name[12]); DBG (20, "Config file cmdrespause=%lu\n", cmdrespause); } else if (strncmp (dev_name, "breakpause=", 11) == 0) { breakpause = atoi (&dev_name[11]); DBG (20, "Config file breakpause=%lu\n", breakpause); } } fclose (fp); } if (init_dc210 (&Camera) == -1) return SANE_STATUS_INVAL; if (get_info (&Camera) == -1) { DBG (2, "error: could not get info\n"); close_dc210 (Camera.fd); return SANE_STATUS_INVAL; } if (Camera.pic_taken == 0) { sod[DC210_OPT_IMAGE_NUMBER].cap |= SANE_CAP_INACTIVE; image_range.min = 0; image_range.max = 0; } else { sod[DC210_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; image_range.min = 1; image_range.max = Camera.pic_taken; } /* load the current images array */ Camera.Pictures = get_pictures_info (); if (Camera.pic_taken == 0) { Camera.current_picture_number = 0; parms.bytes_per_line = 0; parms.pixels_per_line = 0; parms.lines = 0; } else { Camera.current_picture_number = 1; if (Camera.Pictures[Camera.current_picture_number - 1].low_res) { parms.bytes_per_line = 640 * 3; parms.pixels_per_line = 640; parms.lines = 480; } else { parms.bytes_per_line = 1152 * 3; parms.pixels_per_line = 1152; parms.lines = 864; } } if (dumpinquiry) { DBG (0, "\nCamera information:\n~~~~~~~~~~~~~~~~~\n\n"); DBG (0, "Model...........: DC%x\n", Camera.model); DBG (0, "Firmware version: %d.%d\n", Camera.ver_major, Camera.ver_minor); DBG (0, "Pictures........: %d/%d\n", Camera.pic_taken, Camera.pic_taken + Camera.pic_left); DBG (0, "Resolution......: %s\n", Camera.flags.low_res ? "low" : "high"); DBG (0, "Battery state...: %s\n", Camera.flags.low_batt ? "low" : "good"); } return SANE_STATUS_GOOD; } void sane_exit (void) { } /* Device select/open/close */ static const SANE_Device dev[] = { { "0", "Kodak", "DC-210", "still camera"}, }; SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool __sane_unused__ local_only) { static const SANE_Device *devlist[] = { dev + 0, 0 }; DBG (127, "sane_get_devices called\n"); *device_list = devlist; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { int i; DBG (127, "sane_open for device %s\n", devicename); if (!devicename[0]) { i = 0; } else { for (i = 0; i < NELEMS (dev); ++i) { if (strcmp (devicename, dev[i].name) == 0) { break; } } } if (i >= NELEMS (dev)) { return SANE_STATUS_INVAL; } if (is_open) { return SANE_STATUS_DEVICE_BUSY; } is_open = 1; *handle = MAGIC; DBG (3, "sane_open: pictures taken=%d\n", Camera.pic_taken); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { DBG (127, "sane_close called\n"); if (handle == MAGIC) is_open = 0; DBG (127, "sane_close returning\n"); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { if (handle != MAGIC || !is_open) return NULL; /* wrong device */ if (option < 0 || option >= NELEMS (sod)) return NULL; return &sod[option]; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { SANE_Int myinfo = 0; SANE_Status status; DBG (127, "control_option(handle=%p,opt=%s,act=%s,val=%p,info=%p)\n", handle, sod[option].title, (action == SANE_ACTION_SET_VALUE ? "SET" : (action == SANE_ACTION_GET_VALUE ? "GET" : "SETAUTO")), value, (void *)info); if (handle != MAGIC || !is_open) return SANE_STATUS_INVAL; /* Unknown handle ... */ if (option < 0 || option >= NELEMS (sod)) return SANE_STATUS_INVAL; /* Unknown option ... */ switch (action) { case SANE_ACTION_SET_VALUE: status = sanei_constrain_value (sod + option, value, &myinfo); if (status != SANE_STATUS_GOOD) { DBG (1, "Constraint error in control_option\n"); return status; } switch (option) { case DC210_OPT_IMAGE_NUMBER: Camera.current_picture_number = *(SANE_Word *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; /* get the image's resolution */ if (Camera.Pictures[Camera.current_picture_number - 1].low_res) { parms.bytes_per_line = 640 * 3; parms.pixels_per_line = 640; parms.lines = 480; } else { parms.bytes_per_line = 1152 * 3; parms.pixels_per_line = 1152; parms.lines = 864; } break; case DC210_OPT_THUMBS: dc210_opt_thumbnails = !!*(SANE_Word *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; if (dc210_opt_thumbnails) { /* * DC210 thumbnail are 96x72x8x3 */ parms.bytes_per_line = 96 * 3; parms.pixels_per_line = 96; parms.lines = 72; } else { if (Camera.Pictures[Camera.current_picture_number - 1].low_res) { parms.bytes_per_line = 640 * 3; parms.pixels_per_line = 640; parms.lines = 480; } else { parms.bytes_per_line = 1152 * 3; parms.pixels_per_line = 1152; parms.lines = 864; } } break; case DC210_OPT_SNAP: dc210_opt_snap = !!*(SANE_Word *) value; myinfo |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; /* if we are snapping a new one */ if (dc210_opt_snap) { /* activate the resolution setting */ sod[DC210_OPT_LOWRES].cap &= ~SANE_CAP_INACTIVE; /* and de-activate the image number selector */ sod[DC210_OPT_IMAGE_NUMBER].cap |= SANE_CAP_INACTIVE; } else { /* deactivate the resolution setting */ sod[DC210_OPT_LOWRES].cap |= SANE_CAP_INACTIVE; /* and activate the image number selector */ sod[DC210_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; } /* set params according to resolution settings */ if (dc210_opt_lowres) { parms.bytes_per_line = 640 * 3; parms.pixels_per_line = 640; parms.lines = 480; } else { parms.bytes_per_line = 1152 * 3; parms.pixels_per_line = 1152; parms.lines = 864; } break; case DC210_OPT_LOWRES: dc210_opt_lowres = !!*(SANE_Word *) value; myinfo |= SANE_INFO_RELOAD_PARAMS; if (!dc210_opt_thumbnails) { /* XXX - change the number of pictures left depending on resolution perhaps just call get_info again? */ if (dc210_opt_lowres) { parms.bytes_per_line = 640 * 3; parms.pixels_per_line = 640; parms.lines = 480; } else { parms.bytes_per_line = 1152 * 3; parms.pixels_per_line = 1152; parms.lines = 864; } } break; case DC210_OPT_ERASE: dc210_opt_erase = !!*(SANE_Word *) value; break; case DC210_OPT_DEFAULT: DBG (1, "Fixme: Set all defaults here!\n"); break; case DC210_OPT_INIT_DC210: if ((Camera.fd = init_dc210 (&Camera)) == -1) { return SANE_STATUS_INVAL; } break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_GET_VALUE: switch (option) { case 0: *(SANE_Word *) value = NELEMS (sod); break; case DC210_OPT_IMAGE_NUMBER: *(SANE_Word *) value = Camera.current_picture_number; break; case DC210_OPT_THUMBS: *(SANE_Word *) value = dc210_opt_thumbnails; break; case DC210_OPT_SNAP: *(SANE_Word *) value = dc210_opt_snap; break; case DC210_OPT_LOWRES: *(SANE_Word *) value = dc210_opt_lowres; break; case DC210_OPT_ERASE: *(SANE_Word *) value = dc210_opt_erase; break; default: return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_AUTO: switch (option) { default: return SANE_STATUS_UNSUPPORTED; /* We are DUMB */ } } if (info) *info = myinfo; return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { int rc = SANE_STATUS_GOOD; DBG (127, "sane_get_params called\n"); if (handle != MAGIC || !is_open) rc = SANE_STATUS_INVAL; /* Unknown handle ... */ parms.last_frame = SANE_TRUE; /* Have no idea what this does */ *params = parms; DBG (127, "sane_get_params return %d\n", rc); return rc; } typedef struct { struct jpeg_source_mgr pub; JOCTET *buffer; } my_source_mgr; typedef my_source_mgr *my_src_ptr; METHODDEF (void) sanei_jpeg_init_source (j_decompress_ptr __sane_unused__ cinfo) { /* nothing to do */ } METHODDEF (boolean) sanei_jpeg_fill_input_buffer (j_decompress_ptr cinfo) { my_src_ptr src = (my_src_ptr) cinfo->src; if (read_data (Camera.fd, src->buffer, 1024) == -1) { DBG (5, "sane_start: read_data failed\n"); src->buffer[0] = (JOCTET) 0xFF; src->buffer[1] = (JOCTET) JPEG_EOI; return FALSE; } src->pub.next_input_byte = src->buffer; src->pub.bytes_in_buffer = 1024; return TRUE; } METHODDEF (void) sanei_jpeg_skip_input_data (j_decompress_ptr cinfo, long num_bytes) { my_src_ptr src = (my_src_ptr) cinfo->src; if (num_bytes > 0) { while (num_bytes > (long) src->pub.bytes_in_buffer) { num_bytes -= (long) src->pub.bytes_in_buffer; (void) sanei_jpeg_fill_input_buffer (cinfo); } } src->pub.next_input_byte += (size_t) num_bytes; src->pub.bytes_in_buffer -= (size_t) num_bytes; } METHODDEF (void) sanei_jpeg_term_source (j_decompress_ptr __sane_unused__ cinfo) { /* no work necessary here */ } SANE_Status sane_start (SANE_Handle handle) { DBG (127, "sane_start called\n"); if (handle != MAGIC || !is_open || (Camera.current_picture_number == 0 && dc210_opt_snap == SANE_FALSE)) return SANE_STATUS_INVAL; /* Unknown handle ... */ if (Camera.scanning) return SANE_STATUS_EOF; if (dc210_opt_snap) { /* * Don't allow picture unless there is room in the * camera. */ if (Camera.pic_left == 0) { DBG (3, "No room to store new picture\n"); return SANE_STATUS_INVAL; } if (snap_pic (Camera.fd) != SANE_STATUS_GOOD) { DBG (1, "Failed to snap new picture\n"); return SANE_STATUS_INVAL; } } if (dc210_opt_thumbnails) { thumb_pck[3] = (unsigned char) Camera.current_picture_number - 1; thumb_pck[4] = 1; if (send_pck (Camera.fd, thumb_pck) == -1) { DBG (4, "sane_start: error: send_pck returned -1\n"); return SANE_STATUS_INVAL; } parms.bytes_per_line = 96 * 3; parms.pixels_per_line = 96; parms.lines = 72; bytes_in_buffer = 0; bytes_read_from_buffer = 0; } else { my_src_ptr src; struct jpeg_error_mgr jerr; pic_pck[3] = (unsigned char) Camera.current_picture_number - 1; if (send_pck (Camera.fd, pic_pck) == -1) { DBG (4, "sane_start: error: send_pck returned -1\n"); return SANE_STATUS_INVAL; } cinfo.err = jpeg_std_error (&jerr); jpeg_create_decompress (&cinfo); cinfo.src = (struct jpeg_source_mgr *) (*cinfo.mem->alloc_small) ((j_common_ptr) & cinfo, JPOOL_PERMANENT, sizeof (my_source_mgr)); src = (my_src_ptr) cinfo.src; src->buffer = (JOCTET *) (*cinfo.mem->alloc_small) ((j_common_ptr) & cinfo, JPOOL_PERMANENT, 1024 * sizeof (JOCTET)); src->pub.init_source = sanei_jpeg_init_source; src->pub.fill_input_buffer = sanei_jpeg_fill_input_buffer; src->pub.skip_input_data = sanei_jpeg_skip_input_data; src->pub.resync_to_restart = jpeg_resync_to_restart; /* default */ src->pub.term_source = sanei_jpeg_term_source; src->pub.bytes_in_buffer = 0; src->pub.next_input_byte = NULL; (void) jpeg_read_header (&cinfo, TRUE); dest_mgr = sanei_jpeg_jinit_write_ppm (&cinfo); (void) jpeg_start_decompress (&cinfo); } Camera.scanning = SANE_TRUE; /* don't overlap scan requests */ total_bytes_read = 0; return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle __sane_unused__ handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { static char buffer[1024]; if (dc210_opt_thumbnails) { if (total_bytes_read == THUMBSIZE) { if (dc210_opt_erase) { if (erase (Camera.fd) == -1) { DBG (1, "Failed to erase memory\n"); return SANE_STATUS_INVAL; } Camera.pic_taken--; Camera.pic_left++; Camera.current_picture_number = Camera.pic_taken; image_range.max--; } return SANE_STATUS_EOF; } *length = 0; if (!(bytes_in_buffer - bytes_read_from_buffer)) { if (read_data (Camera.fd, (unsigned char *) buffer, 1024) == -1) { DBG (5, "sane_read: read_data failed\n"); return SANE_STATUS_INVAL; } bytes_in_buffer = 1024; bytes_read_from_buffer = 0; } while (bytes_read_from_buffer < bytes_in_buffer && max_length && total_bytes_read < THUMBSIZE) { *data++ = buffer[bytes_read_from_buffer++]; (*length)++; max_length--; total_bytes_read++; } if (total_bytes_read == THUMBSIZE) { if (end_of_data (Camera.fd) == -1) { DBG (4, "sane_read: end_of_data error\n"); return SANE_STATUS_INVAL; } else { return SANE_STATUS_GOOD; } } else { return SANE_STATUS_GOOD; } } else { int lines = 0; if (cinfo.output_scanline >= cinfo.output_height) { /* clean up comms with the camera */ if (end_of_data (Camera.fd) == -1) { DBG (2, "sane_read: error: end_of_data returned -1\n"); return SANE_STATUS_INVAL; } if (dc210_opt_erase) { DBG (127, "sane_read bp%d, erase image\n", __LINE__); if (erase (Camera.fd) == -1) { DBG (1, "Failed to erase memory\n"); return SANE_STATUS_INVAL; } Camera.pic_taken--; Camera.pic_left++; Camera.current_picture_number = Camera.pic_taken; image_range.max--; } return SANE_STATUS_EOF; } /* XXX - we should read more than 1 line at a time here */ lines = 1; (void) jpeg_read_scanlines (&cinfo, dest_mgr->buffer, lines); (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, lines, (char *) data); *length = cinfo.output_width * cinfo.output_components * lines; return SANE_STATUS_GOOD; } } void sane_cancel (SANE_Handle __sane_unused__ handle) { DBG (127, "sane_cancel() called\n"); if (Camera.scanning) Camera.scanning = SANE_FALSE; /* done with scan */ else DBG (127, "sane_cancel() aborted, scanner not scanning\n"); } SANE_Status sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { return SANE_STATUS_UNSUPPORTED; } static PictureInfo * get_pictures_info (void) { char f[] = "get_pictures_info"; unsigned int p; PictureInfo *pics; if ((pics = (PictureInfo *) malloc (Camera.pic_taken * sizeof (PictureInfo))) == NULL) { DBG (4, "%s: error: allocate memory for pictures array\n", f); return NULL; } for (p = 0; p < (unsigned int) Camera.pic_taken; p++) { if (get_picture_info (pics + p, p) == -1) { free (pics); return NULL; } } return pics; } static int get_picture_info (PictureInfo * pic, int p) { char f[] = "get_picture_info"; static char buffer[256]; DBG (4, "%s: info for pic #%d\n", f, p); pic_info_pck[3] = (unsigned char) p; if (send_pck (Camera.fd, pic_info_pck) == -1) { DBG (4, "%s: error: send_pck returned -1\n", f); return -1; } if (read_data (Camera.fd, (unsigned char *) buffer, 256) == -1) { DBG (2, "%s: error: read_data returned -1\n", f); return -1; } if (end_of_data (Camera.fd) == -1) { DBG (2, "%s: error: end_of_data returned -1\n", f); return -1; } if (buffer[3] == 0) { pic->low_res = SANE_TRUE; } else if (buffer[3] == 1) { pic->low_res = SANE_FALSE; } else { DBG (2, "%s: error: unknown resolution code %u\n", f, buffer[3]); return -1; } pic->size = (buffer[8] & 0xFF) << 24; pic->size |= (buffer[9] & 0xFF) << 16; pic->size |= (buffer[10] & 0xFF) << 8; pic->size |= (buffer[11] & 0xFF); return 0; } static SANE_Status snap_pic (int fd) { char f[] = "snap_pic"; /* make sure camera is set to our settings state */ if (change_res (Camera.fd, dc210_opt_lowres) == -1) { DBG (1, "%s: Failed to set resolution\n", f); return SANE_STATUS_INVAL; } /* take the picture */ if (send_pck (fd, shoot_pck) == -1) { DBG (4, "%s: error: send_pck returned -1\n", f); return SANE_STATUS_INVAL; } else { if (end_of_data (Camera.fd) == -1) { DBG (2, "%s: error: end_of_data returned -1\n", f); return SANE_STATUS_INVAL; } } Camera.pic_taken++; Camera.pic_left--; Camera.current_picture_number = Camera.pic_taken; image_range.max++; sod[DC210_OPT_IMAGE_NUMBER].cap &= ~SANE_CAP_INACTIVE; /* add this one to the Pictures array */ if ((Camera.Pictures = (PictureInfo *) realloc (Camera.Pictures, Camera.pic_taken * sizeof (PictureInfo))) == NULL) { DBG (4, "%s: error: allocate memory for pictures array\n", f); return SANE_STATUS_INVAL; } if (get_picture_info (Camera.Pictures + Camera.pic_taken, Camera.pic_taken) == -1) { DBG (1, "%s: Failed to get new picture info\n", f); /* XXX - I guess we should try to erase the image here */ return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/hp4200_lm9830.c0000666000000000000000000001307213615534521014670 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000 Adrian Perez Jorge 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a backend for the HP4200C flatbed scanner */ #include "hp4200_lm9830.h" static SANE_Status lm9830_read_register (int fd, unsigned char reg, unsigned char *data) { SANE_Status retval; if (!data) return -SANE_STATUS_INVAL; retval = sanei_pv8630_write_byte (fd, PV8630_REPPADDRESS, reg); if (retval != SANE_STATUS_GOOD) return retval; return sanei_pv8630_read_byte (fd, PV8630_RDATA, data); } static SANE_Status lm9830_write_register (int fd, unsigned char reg, unsigned char value) { SANE_Status retval; retval = sanei_pv8630_write_byte (fd, PV8630_REPPADDRESS, reg); if (retval != SANE_STATUS_GOOD) return retval; return sanei_pv8630_write_byte (fd, PV8630_RDATA, value); } #ifdef DEBUG static int lm9830_dump_registers (int fd) { int i; unsigned char value = 0; for (i = 0; i < 0x80; i++) { lm9830_read_register (fd, i, &value); printf ("%.2x:0x%.2x", i, value); if ((i + 1) % 8) printf (", "); else printf ("\n"); } puts (""); return 0; } #endif #if 0 static int pv8630_reset_buttons (int fd) { lm9830_write_register (fd, 0x59, 0x10); lm9830_write_register (fd, 0x59, 0x90); return 0; } #endif #if 0 static int lm9830_lamp_off (int fd) { lm9830_write_register (fd, 0x07, 0x00); lm9830_write_register (fd, 0x2c, 0x00); lm9830_write_register (fd, 0x2d, 0x01); lm9830_write_register (fd, 0x2e, 0x3f); lm9830_write_register (fd, 0x2f, 0xff); return 0; } static int lm9830_lamp_on (int fd) { lm9830_write_register (fd, 0x07, 0x00); lm9830_write_register (fd, 0x2c, 0x3f); lm9830_write_register (fd, 0x2d, 0xff); lm9830_write_register (fd, 0x2e, 0x00); lm9830_write_register (fd, 0x2f, 0x01); return 0; } #endif #if 0 /* * This function prints what button was pressed (the time before this * code was executed). */ static int hp4200c_what_button (int fd) { unsigned char button; pv8630_read_buttons (fd, &button); if (button & 0x08) puts ("Scan"); if (button & 0x10) puts ("Copy"); if (button & 0x20) puts ("E-mail"); if ((button & 0x38) == 0) puts ("None"); pv8630_reset_buttons (fd); return 0; } #endif static int lm9830_ini_scanner (int fd, unsigned char *regs) { #ifdef unused unsigned char inittable[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1A, 0x00, 0x0A, 0x60, 0x2F, 0x13, 0x06, 0x17, 0x01, 0x03, 0x03, 0x05, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x21, 0x00, 0x40, 0x15, 0x18, 0x00, 0x40, 0x02, 0x98, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x3F, 0xFF, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x30, 0x25, 0x25, 0x24, 0x28, 0x24, 0x28, 0x00, 0x00, 0x00, 0x00, 0x06, 0x1D, 0x00, 0x13, 0x05, 0x48, 0x01, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x5E, 0x02, 0x00, 0x15, 0x00, 0x45, 0x00, 0x10, 0x08, 0x17, 0x2B, 0x90, 0x00, 0x00, 0x01, 0x00, 0x80, 0x00 }; #endif unsigned char daisy[] = { 0x99, 0x66, 0xcc, 0x33 }; unsigned char *regdata; unsigned int i; sanei_pv8630_write_byte (fd, PV8630_RMODE, 0x02); for (i = 0; i < sizeof (daisy); i++) { sanei_pv8630_write_byte (fd, PV8630_RDATA, daisy[i]); } sanei_pv8630_write_byte (fd, PV8630_RMODE, 0x16); lm9830_write_register (fd, 0x42, 0x06); if (!regs) return 0; /* regdata = inittable; */ else regdata = regs; for (i = 8; i < 0x60; i++) { lm9830_write_register (fd, i, regdata[i]); } for (i = 0x60; i < 0x70; i++) { lm9830_write_register (fd, i, 0); } lm9830_write_register (fd, 0x70, 0x70); for (i = 0x71; i < 0x80; i++) { lm9830_write_register (fd, i, 0); } return 0; } static int lm9830_reset (int fd) { lm9830_write_register (fd, 0x07, 0x08); usleep (100); lm9830_write_register (fd, 0x07, 0x00); usleep (100); return 0; } sane-backends-1.0.29/backend/plustek-usbscan.c0000666000000000000000000013316513615534521016070 00000000000000/*............................................................................. * Project : SANE library for Plustek flatbed scanners. *............................................................................. */ /** @file plustek-usbscan.c * @brief Scanning... * * Based on sources acquired from Plustek Inc.
* Copyright (C) 2001-2013 Gerhard Jaeger * * History: * - 0.40 - starting version of the USB support * - 0.41 - minor fixes * - 0.42 - added some stuff for CIS devices * - 0.43 - no changes * - 0.44 - added CIS specific settings and calculations * - removed usb_IsEscPressed * - 0.45 - fixed the special setting stuff for CanoScan * - fixed pixel calculation for binary modes * - fixed cancel hang problem * - fixed CIS PhyBytes adjustment * - removed CanoScan specific setting stuff * - 0.46 - fixed problem in usb_SetScanParameters() * - 0.47 - no changes * - 0.48 - minor fixes * - 0.49 - a_bRegs is now part of the device structure * - using now PhyDpi.y as selector for the motor MCLK range * - changed usb_MapDownload prototype * - 0.50 - cleanup * - 0.51 - added usb_get_res() and usb_GetPhyPixels() * - 0.52 - removed stuff, that will most probably never be used * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #define DIVIDER 8 /** array used to get motor-settings and mclk-settings */ static int dpi_ranges[] = { 75,100,150,200,300,400,600,800,1200,2400 }; static u_char bMaxITA; static SANE_Bool m_fAutoPark; static SANE_Bool m_fFirst; static double m_dHDPIDivider; static double m_dMCLKDivider; static ScanParam *m_pParam; static u_char m_bLineRateColor; static u_char m_bCM; static u_char m_bIntTimeAdjust; static u_char m_bOldScanData; static u_short m_wFastFeedStepSize; static u_short m_wLineLength; static u_short m_wStepSize; static u_long m_dwPauseLimit; static SANE_Bool m_fStart = SANE_FALSE; /* Prototype... */ static SANE_Bool usb_DownloadShadingData( Plustek_Device*, u_char ); /** returns the min of the two values val1 and val2 * @param val1 - first parameter * @param val2 - second parameter * @return val1 if val1 < val2, else val1 */ static u_long usb_min( u_long val1, u_long val2 ) { if( val1 > val2 ) return val2; return val1; } /** returns the max of the two values val1 and val2 * @param val1 - first parameter * @param val2 - second parameter * @return val1 if val1 > val2, else val2 */ static u_long usb_max( u_long val1, u_long val2 ) { if( val1 > val2 ) return val1; return val2; } /** function to get the possible resolution for a specific base resolution, * according to the dividers a LM983x offers. * @param base - scanners optical resolution * @param idx - which divider to use */ static u_short usb_get_res( u_short base, u_short idx ) { double div_list[DIVIDER] = { 12.0, 8.0, 6.0, 4.0, 3.0, 2.0, 1.5, 1.0 }; if( idx == 0 || idx > DIVIDER ) return 0; return (u_short)((double)base/div_list[idx-1]); } /** Set the horizontal DPI divider. * Affected registers:
* 0x09 - Horizontal DPI divider HDPI_DIV
* * @param dev - pointer to our device structure, * it should contain all we need * @param xdpi - user specified horizontal resolution * @return - the function returns the "normalized" horizontal resolution. */ static u_short usb_SetAsicDpiX( Plustek_Device *dev, u_short xdpi ) { u_short res; ScanDef *scanning = &dev->scanning; DCapsDef *scaps = &dev->usbDev.Caps; u_char *regs = dev->usbDev.a_bRegs; /* limit xdpi to lower value for certain devices... */ if( scaps->OpticDpi.x == 1200 && scanning->sParam.bDataType != SCANDATATYPE_Color && xdpi < 150 && scanning->sParam.bDataType == SCANDATATYPE_BW ) { xdpi = 150; DBG( _DBG_INFO2, "* LIMIT XDPI to %udpi\n", xdpi ); } m_dHDPIDivider = (double)scaps->OpticDpi.x / xdpi; if (m_dHDPIDivider < 1.5) { m_dHDPIDivider = 1.0; regs[0x09] = 0; } else if (m_dHDPIDivider < 2.0) { m_dHDPIDivider = 1.5; regs[0x09] = 1; } else if (m_dHDPIDivider < 3.0) { m_dHDPIDivider = 2.0; regs[0x09] = 2; } else if (m_dHDPIDivider < 4.0) { m_dHDPIDivider = 3.0; regs[0x09] = 3; } else if (m_dHDPIDivider < 6.0) { m_dHDPIDivider = 4.0; regs[0x09] = 4; } else if (m_dHDPIDivider < 8.0) { m_dHDPIDivider = 6.0; regs[0x09] = 5; } else if (m_dHDPIDivider < 12.0) { m_dHDPIDivider = 8.0; regs[0x09] = 6; } else { m_dHDPIDivider = 12.0; regs[0x09] = 7; } /* adjust, if any turbo/preview mode is set, should be 0 here... */ if( regs[0x0a] ) regs[0x09] -= ((regs[0x0a] >> 2) + 2); DBG( _DBG_INFO2, "* HDPI: %.3f\n", m_dHDPIDivider ); res = (u_short)((double)scaps->OpticDpi.x / m_dHDPIDivider); DBG( _DBG_INFO2, "* XDPI=%u, HDPI=%.3f\n", res, m_dHDPIDivider ); return res; } /** * @param dev - pointer to our device structure, * it should contain all we need * @param ydpi - user specified vertical resolution * @return - */ static u_short usb_SetAsicDpiY( Plustek_Device *dev, u_short ydpi ) { ScanDef *scanning = &dev->scanning; DCapsDef *sCaps = &dev->usbDev.Caps; HWDef *hw = &dev->usbDev.HwSetting; u_short wMinDpi, wDpi; if(0 != sCaps->bSensorDistance ) wMinDpi = sCaps->OpticDpi.y / sCaps->bSensorDistance; else wMinDpi = 75; /* Here we might have to check against the MinDpi value ! */ wDpi = (ydpi + wMinDpi - 1) / wMinDpi * wMinDpi; /* * HEINER: added '*2' */ if( wDpi > sCaps->OpticDpi.y * 2 ) wDpi = sCaps->OpticDpi.y * 2; if( (hw->motorModel == MODEL_Tokyo600) || !_IS_PLUSTEKMOTOR(hw->motorModel)) { /* return wDpi; */ } else if( sCaps->wFlags & DEVCAPSFLAG_Adf && sCaps->OpticDpi.x == 600 ) { /* for ADF scanner color mode 300 dpi big noise */ if( scanning->sParam.bDataType == SCANDATATYPE_Color && scanning->sParam.bBitDepth > 8 && wDpi < 300 ) { wDpi = 300; } } else if( sCaps->OpticDpi.x == 1200 ) { if( scanning->sParam.bDataType != SCANDATATYPE_Color && wDpi < 200) { wDpi = 200; } } DBG( _DBG_INFO2, "* YDPI=%u, MinDPIY=%u\n", wDpi, wMinDpi ); return wDpi; } /** set color mode and sensor configuration stuff, according to the data mode * Affected registers:
* 0x26 - 0x27 - Color Mode settings
* 0x0f - 0x18 - Sensor Configuration - directly from the HwDefs
* 0x09 - add Data Mode and Pixel Packing
* * @param dev - pointer to our device structure, * it should contain all we need * @param pParam - pointer to the current scan parameters * @return - Nothing */ static void usb_SetColorAndBits( Plustek_Device *dev, ScanParam *pParam ) { HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; /* Set pixel packing, data mode and AFE operation */ switch( pParam->bDataType ) { case SCANDATATYPE_Color: m_bCM = 3; regs[0x26] = hw->bReg_0x26 & 0x7; /* if set to one channel color, we select the blue channel * as input source, this is the default, but I don't know * what happens, if we deselect this */ if( regs[0x26] & _ONE_CH_COLOR ) regs[0x26] |= (_BLUE_CH | 0x01); memcpy( ®s[0x0f], hw->bReg_0x0f_Color, 10 ); break; case SCANDATATYPE_Gray: m_bCM = 1; regs[0x26] = (hw->bReg_0x26 & 0x18) | 0x04; memcpy( ®s[0x0f], hw->bReg_0x0f_Mono, 10 ); break; case SCANDATATYPE_BW: m_bCM = 1; regs[0x26] = (hw->bReg_0x26 & 0x18) | 0x04; memcpy( ®s[0x0f], hw->bReg_0x0f_Mono, 10 ); break; } regs[0x27] = hw->bReg_0x27; if( pParam->bBitDepth > 8 ) { regs[0x09] |= 0x20; /* 14/16bit image data */ } else if( pParam->bBitDepth == 8 ) { regs[0x09] |= 0x18; /* 8bits/per pixel */ } } /** * Data output from NS983X should be times of 2-byte and every line * will append 2 status bytes */ static void usb_GetPhyPixels( Plustek_Device *dev, ScanParam *sp ) { sp->Size.dwValidPixels = sp->Size.dwPixels * sp->PhyDpi.x / sp->UserDpi.x; if (sp->bBitDepth == 1) { /* Pixels should be times of 16 */ sp->Size.dwPhyPixels = (sp->Size.dwValidPixels + 15UL) & 0xfffffff0UL; sp->Size.dwPhyBytes = sp->Size.dwPhyPixels / 8UL + 2UL; } else if (sp->bBitDepth == 8) { /* Pixels should be times of 2 */ sp->Size.dwPhyPixels = (sp->Size.dwValidPixels + 1UL) & 0xfffffffeUL; sp->Size.dwPhyBytes = sp->Size.dwPhyPixels * sp->bChannels + 2UL; /* need to be adjusted fo CIS devices in color mode */ if(usb_IsCISDevice( dev ) && (sp->bDataType == SCANDATATYPE_Color)) { sp->Size.dwPhyBytes *= 3; } } else /* sp->bBitDepth == 16 */ { sp->Size.dwPhyPixels = sp->Size.dwValidPixels; sp->Size.dwPhyBytes = sp->Size.dwPhyPixels * 2 * sp->bChannels + 2UL; /* need to be adjusted fo CIS devices in color mode */ if(usb_IsCISDevice( dev ) && (sp->bDataType == SCANDATATYPE_Color)) { sp->Size.dwPhyBytes *= 3; } } } /** Calculate basic image settings like the number of physical bytes per line * etc... * Affected registers:
* 0x22/0x23 - Data Pixels Start
* 0x24/0x25 - Data Pixels End
* 0x4a/0x4b - Full Steps to Skip at Start of Scan * * @param dev - pointer to our device structure, * it should contain all we need * @param pParam - pointer to the current scan parameters * @return - Nothing */ static void usb_GetScanRect( Plustek_Device *dev, ScanParam *sp ) { u_short wDataPixelStart, wLineEnd; DCapsDef *sCaps = &dev->usbDev.Caps; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; /* Convert pixels to physical dpi based */ usb_GetPhyPixels( dev, sp ); /* Compute data start pixel */ #if 0 /* HEINER: check ADF stuff... */ if(sp->bCalibration != PARAM_Gain && sp->bCalibration != PARAM_Offset && ScanInf.m_fADF) wDataPixelStart = 2550 * sCaps->OpticDpi.x / 300UL - (u_short)(m_dHDPIDivider * sp->Size.dwValidPixels + 0.5); else #endif wDataPixelStart = (u_short)((u_long)sp->Origin.x * sCaps->OpticDpi.x / 300UL); /* during the calibration steps, we read the entire CCD data */ if((sp->bCalibration != PARAM_Gain)&&(sp->bCalibration != PARAM_Offset)) { /* HEINER: check ADF stuff... */ #if 0 if(ScanInf.m_fADF) { wDataPixelStart = 2550 * sCaps->OpticDpi.x / 300UL - (u_short)(m_dHDPIDivider * sp->Size.dwValidPixels + 0.5); } #endif wDataPixelStart += hw->wActivePixelsStart; } wLineEnd = wDataPixelStart + (u_short)(m_dHDPIDivider * sp->Size.dwPhyPixels + 0.5); DBG( _DBG_INFO2, "* DataPixelStart=%u, LineEnd=%u\n", wDataPixelStart, wLineEnd ); if( wDataPixelStart & 1 ) { wDataPixelStart++; wLineEnd++; DBG( _DBG_INFO2, "* DataPixelStart=%u, LineEnd=%u (ADJ)\n", wDataPixelStart, wLineEnd ); } regs[0x22] = _HIBYTE( wDataPixelStart ); regs[0x23] = _LOBYTE( wDataPixelStart ); /* should match: wLineEnd-wDataPixelStart%(m_dHDPIDivider*2) = 0!! */ regs[0x24] = _HIBYTE( wLineEnd ); regs[0x25] = _LOBYTE( wLineEnd ); DBG( _DBG_INFO2, ">> End-Start=%u, HDPI=%.2f\n", wLineEnd-wDataPixelStart, m_dHDPIDivider); /* Y origin */ if( sp->bCalibration == PARAM_Scan ) { if( hw->motorModel == MODEL_Tokyo600 ) { if(sp->PhyDpi.x <= 75) sp->Origin.y += 20; else if(sp->PhyDpi.x <= 100) { if (sp->bDataType == SCANDATATYPE_Color) sp->Origin.y += 0; else sp->Origin.y -= 6; } else if(sp->PhyDpi.x <= 150) { if (sp->bDataType == SCANDATATYPE_Color) sp->Origin.y -= 0; } else if(sp->PhyDpi.x <= 200) { if (sp->bDataType == SCANDATATYPE_Color) sp->Origin.y -= 10; else sp->Origin.y -= 4; } else if(sp->PhyDpi.x <= 300) { if (sp->bDataType == SCANDATATYPE_Color) sp->Origin.y += 16; else sp->Origin.y -= 18; } else if(sp->PhyDpi.x <= 400) { if (sp->bDataType == SCANDATATYPE_Color) sp->Origin.y += 15; else if(sp->bDataType == SCANDATATYPE_BW) sp->Origin.y += 4; } else /* if(sp->PhyDpi.x <= 600) */ { if (sp->bDataType == SCANDATATYPE_Gray) sp->Origin.y += 4; } } /* Add gray mode offset (Green offset, we assume the CCD are * always be RGB or BGR order). */ if (sp->bDataType != SCANDATATYPE_Color) sp->Origin.y += (u_long)(300UL * sCaps->bSensorDistance / sCaps->OpticDpi.y); } sp->Origin.y=(u_short)((u_long)sp->Origin.y * hw->wMotorDpi/300UL); /* Something wrong, but I can not find it. */ if( hw->motorModel == MODEL_HuaLien && sCaps->OpticDpi.x == 600) sp->Origin.y = sp->Origin.y * 297 / 298; DBG(_DBG_INFO2,"* Full Steps to Skip at Start = 0x%04x\n", sp->Origin.y); regs[0x4a] = _HIBYTE( sp->Origin.y ); regs[0x4b] = _LOBYTE( sp->Origin.y ); } /** preset scan stepsize and fastfeed stepsize */ static void usb_PresetStepSize( Plustek_Device *dev, ScanParam *pParam ) { u_short ssize; double mclkdiv = pParam->dMCLK; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; ssize = (u_short)((double)CRYSTAL_FREQ / ( mclkdiv * 8.0 * (double)m_bCM * hw->dMaxMotorSpeed * 4.0 * (double)hw->wMotorDpi)); regs[0x46] = _HIBYTE( ssize ); regs[0x47] = _LOBYTE( ssize ); regs[0x48] = _HIBYTE( ssize ); regs[0x49] = _LOBYTE( ssize ); DBG( _DBG_INFO2, "* StepSize(Preset) = %u (0x%04x)\n", ssize, ssize ); } /** calculate default phase difference DPD */ static void usb_GetDPD( Plustek_Device *dev ) { int qtcnt; /* quarter speed count count reg 51 b2..3 */ int hfcnt; /* half speed count reg 51 b0..1 */ int strev; /* steps to reverse reg 50 */ int dpd; /* calculated dpd reg 52:53 */ int st; /* step size reg 46:47 */ HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; qtcnt = (regs[0x51] & 0x30) >> 4; /* quarter speed count */ hfcnt = (regs[0x51] & 0xc0) >> 6; /* half speed count */ if( _LM9831 == hw->chip ) strev = regs[0x50] & 0x3f; /* steps to reverse */ else /* LM9832/3 */ { if (qtcnt == 3) qtcnt = 8; if (hfcnt == 3) hfcnt = 8; strev = regs[0x50]; /* steps to reverse */ } st = regs[0x46] * 256 + regs[0x47]; /* scan step size */ if (m_wLineLength == 0) dpd = 0; else { dpd = (((qtcnt * 4) + (hfcnt * 2) + strev) * 4 * st) % (m_wLineLength * m_bLineRateColor); DBG( _DBG_INFO2, "* DPD =%u (0x%04x)\n", dpd, dpd ); dpd = m_wLineLength * m_bLineRateColor - dpd; } DBG( _DBG_INFO2, "* DPD =%u (0x%04x), step size=%u, steps2rev=%u\n", dpd, dpd, st, strev); DBG( _DBG_INFO2, "* llen=%u, lineRateColor=%u, qtcnt=%u, hfcnt=%u\n", m_wLineLength, m_bLineRateColor, qtcnt, hfcnt ); regs[0x51] |= (u_char)((dpd >> 16) & 0x03); regs[0x52] = (u_char)(dpd >> 8); regs[0x53] = (u_char)(dpd & 0xFF); } #define MCLKDIV_SCALING 2 #define _MIN(a,b) ((a) < (b) ? (a) : (b)) #define _MAX(a,b) ((a) > (b) ? (a) : (b)) /** */ static int usb_GetMCLKDiv( Plustek_Device *dev ) { int j, pixelbits, pixelsperline, r; int minmclk, maxmclk, mclkdiv; double hdpi, min_int_time; u_char *regs = dev->usbDev.a_bRegs; HWDef *hw = &dev->usbDev.HwSetting; DBG( _DBG_INFO, "usb_GetMCLKDiv()\n" ); r = 8; /* line rate */ if ((regs[0x26] & 7) == 0) r = 24; /* pixel rate */ /* use high or low res min integration time */ min_int_time = ((regs[0x9]&7) > 2 ? hw->dMinIntegrationTimeLowres: hw->dMinIntegrationTimeHighres); minmclk = (int)ceil((double) MCLKDIV_SCALING * CRYSTAL_FREQ * min_int_time /((double)1000. * r * m_wLineLength)); minmclk = _MAX(minmclk,MCLKDIV_SCALING); maxmclk = (int)(32.5*MCLKDIV_SCALING + .5); DBG(_DBG_INFO2,"- lower mclkdiv limit=%f\n",(double)minmclk/MCLKDIV_SCALING); DBG(_DBG_INFO2,"- upper mclkdiv limit=%f\n",(double)maxmclk/MCLKDIV_SCALING); /* get the bits per pixel */ switch (regs[0x9] & 0x38) { case 0: pixelbits=1; break; case 0x8: pixelbits=2; break; case 0x10: pixelbits=4; break; case 0x18: pixelbits=8; break; default: pixelbits=16;break; } /* compute the horizontal dpi (pixels per inch) */ j = regs[0x9] & 0x7; hdpi = ((j&1)*.5+1)*(j&2?2:1)*(j&4?4:1); pixelsperline = (int)((256*regs[0x24]+regs[0x25]-256*regs[0x22]-regs[0x23]) *pixelbits/(hdpi * 8)); mclkdiv = (int)ceil((double)MCLKDIV_SCALING * pixelsperline * CRYSTAL_FREQ /((double) 8. * m_wLineLength * dev->transferRate)); DBG( _DBG_INFO2, "- hdpi = %.3f\n", hdpi ); DBG( _DBG_INFO2, "- pixelbits = %u\n", pixelbits ); DBG( _DBG_INFO2, "- pixelsperline = %u\n", pixelsperline ); DBG( _DBG_INFO2, "- linelen = %u\n", m_wLineLength ); DBG( _DBG_INFO2, "- transferrate = %lu\n", dev->transferRate ); DBG( _DBG_INFO2, "- MCLK Divider = %u\n", mclkdiv/MCLKDIV_SCALING ); mclkdiv = _MAX(mclkdiv,minmclk); mclkdiv = _MIN(mclkdiv,maxmclk); DBG( _DBG_INFO2, "- Current MCLK Divider = %u\n", mclkdiv/MCLKDIV_SCALING ); if( dev->transferRate == 2000000 ) { while (mclkdiv * hdpi < 6.*MCLKDIV_SCALING) { mclkdiv++; } DBG( _DBG_INFO2, "- HIGHSPEED MCLK Divider = %u\n", mclkdiv/MCLKDIV_SCALING ); } return mclkdiv; } /** Plusteks' poor-man MCLK calculation... * at least we give the master clock divider and adjust the step size * and integration time (for 14/16 bit modes) */ static double usb_GetMCLKDivider( Plustek_Device *dev, ScanParam *pParam ) { double dMaxIntegrationTime; double dMaxMCLKDivider; DCapsDef *sCaps = &dev->usbDev.Caps; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; DBG( _DBG_INFO, "usb_GetMCLKDivider()\n" ); if( dev->transferRate == 2000000 ) { int mclkdiv = usb_GetMCLKDiv(dev); pParam->dMCLK = (double)mclkdiv/MCLKDIV_SCALING; } m_dMCLKDivider = pParam->dMCLK; if (m_dHDPIDivider*m_dMCLKDivider >= 5.3/*6*/) m_bIntTimeAdjust = 0; else m_bIntTimeAdjust = ceil( 5.3/*6.0*/ / (m_dHDPIDivider*m_dMCLKDivider)); if( pParam->bCalibration == PARAM_Scan ) { usb_GetMCLKDiv(dev); /* Compare Integration with USB speed to find the best ITA value */ if( pParam->bBitDepth > 8 ) { while( pParam->Size.dwPhyBytes > (m_dMCLKDivider * m_bCM * m_wLineLength / 6 * 9 / 10) * (1 + m_bIntTimeAdjust)) { m_bIntTimeAdjust++; } if( hw->motorModel == MODEL_HuaLien && sCaps->bCCD == kNEC3799 && m_bIntTimeAdjust > bMaxITA) { m_bIntTimeAdjust = bMaxITA; } if(((hw->motorModel == MODEL_HP) && (sCaps->bCCD == kNECSLIM))/* || ( regs[0x26] & _ONE_CH_COLOR )*/) { bMaxITA = (u_char)floor((m_dMCLKDivider + 1) / 2.0); DBG( _DBG_INFO2, "* MaxITA (HP) = %u\n", bMaxITA ); if( m_bIntTimeAdjust > bMaxITA ) { DBG( _DBG_INFO, "* ITA (%u) limited\n", m_bIntTimeAdjust ); m_bIntTimeAdjust = bMaxITA; } } } } DBG( _DBG_INFO2, "* Integration Time Adjust = %u (HDPI=%.3f,MCLKD=%.3f)\n", m_bIntTimeAdjust, m_dHDPIDivider, m_dMCLKDivider ); regs[0x08] = (u_char)((m_dMCLKDivider - 1) * 2); regs[0x19] = m_bIntTimeAdjust; if( m_bIntTimeAdjust != 0 ) { m_wStepSize = (u_short)((u_long) m_wStepSize * (m_bIntTimeAdjust + 1) / m_bIntTimeAdjust); if( m_wStepSize < 2 ) m_wStepSize = 2; regs[0x46] = _HIBYTE(m_wStepSize); regs[0x47] = _LOBYTE(m_wStepSize); DBG( _DBG_INFO2, "* Stepsize = %u, 0x46=0x%02x 0x47=0x%02x\n", m_wStepSize, regs[0x46], regs[0x47] ); usb_GetDPD( dev ); } /* Compute maximum MCLK divider base on maximum integration time for * high lamp PWM, use equation 4 */ dMaxIntegrationTime = hw->dIntegrationTimeHighLamp; dMaxMCLKDivider = (double)CRYSTAL_FREQ * dMaxIntegrationTime / (1000 * 8 * m_bCM * m_wLineLength); /* Determine lamp PWM setting */ if( m_dMCLKDivider > dMaxMCLKDivider ) { DBG( _DBG_INFO2, "* Setting GreenPWMDutyCycleLow\n" ); regs[0x2a] = _HIBYTE( hw->wGreenPWMDutyCycleLow ); regs[0x2b] = _LOBYTE( hw->wGreenPWMDutyCycleLow ); } else { DBG( _DBG_INFO2, "* Setting GreenPWMDutyCycleHigh\n" ); regs[0x2a] = _HIBYTE( hw->wGreenPWMDutyCycleHigh ); regs[0x2b] = _LOBYTE( hw->wGreenPWMDutyCycleHigh ); } DBG( _DBG_INFO2, "* Current MCLK Divider = %f\n", m_dMCLKDivider ); return m_dMCLKDivider; } /** calculate the step size of each scan step */ static void usb_GetStepSize( Plustek_Device *dev, ScanParam *pParam ) { HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; /* Compute step size using equation 1 */ if (m_bIntTimeAdjust != 0) { m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength * m_bLineRateColor * (m_bIntTimeAdjust + 1)) / (4 * hw->wMotorDpi * m_bIntTimeAdjust)); } else { m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength * m_bLineRateColor) / (4 * hw->wMotorDpi)); } if (m_wStepSize < 2) m_wStepSize = 2; m_wStepSize = m_wStepSize * 298 / 297; regs[0x46] = _HIBYTE( m_wStepSize ); regs[0x47] = _LOBYTE( m_wStepSize ); DBG( _DBG_INFO2, "* Stepsize = %u, 0x46=0x%02x 0x47=0x%02x\n", m_wStepSize, regs[0x46], regs[0x47] ); } /** */ static void usb_GetLineLength( Plustek_Device *dev, ScanParam *param ) { /* [note] * The ITA in this moment is always 0, it will be changed later when we * calculate MCLK. This is very strange why this routine will not call * again to get all new value after ITA was changed? If this routine * never call again, maybe we remove all factor with ITA here. */ int tr; int tpspd; /* turbo/preview mode speed reg 0a b2..3 */ int tpsel; /* turbo/preview mode select reg 0a b0..1 */ int gbnd; /* guardband duration reg 0e b4..7 */ int dur; /* pulse duration reg 0e b0..3 */ int ntr; /* number of tr pulses reg 0d b7 */ int afeop; /* scan mode, 0=pixel rate, 1=line rate, */ /* 4=1 channel mode a, 5=1 channel mode b, reg 26 b0..2 */ int ctmode; /* CIS tr timing mode reg 19 b0..1 */ int tp; /* tpspd or 1 if tpsel=0 */ int b; /* if ctmode=0, (ntr+1)*((2*gbnd)+dur+1), otherwise 1 */ int tradj; /* ITA */ int en_tradj; u_short le; HWDef *hw = &dev->usbDev.HwSetting; ClkMotorDef *motor = usb_GetMotorSet( hw->motorModel ); u_char *regs = dev->usbDev.a_bRegs; tpspd = (regs[0x0a] & 0x0c) >> 2; /* turbo/preview mode speed */ tpsel = regs[0x0a] & 3; /* turbo/preview mode select */ gbnd = (regs[0x0e] & 0xf0) >> 4; /* TR fi1 guardband duration */ dur = (regs[0x0e] & 0xf); /* TR pulse duration */ ntr = regs[0x0d] / 128; /* number of tr pulses */ afeop = regs[0x26] & 7; /* afe op - 3 channel or 1 channel */ tradj = regs[0x19] & 0x7f; /* integration time adjust */ en_tradj = (tradj) ? 1 : 0; ctmode = (regs[0x0b] >> 3) & 3; /* cis tr timing mode */ m_bLineRateColor = 1; if (afeop == 1 || afeop == 5) /* if 3 channel line or 1 channel mode b */ m_bLineRateColor = 3; /* according to turbo/preview mode to set value */ if( tpsel == 0 ) { tp = 1; } else { tp = tpspd + 2; if( tp == 5 ) tp++; } b = 1; if( ctmode == 0 ) { /* CCD mode scanner*/ b = (ntr + 1) * ((2 * gbnd) + dur + 1); b += (1 - ntr) * en_tradj; } if( ctmode == 2 ) /* CIS mode scanner */ b = 3; /* it might be necessary to tweak this value, to keep the * MCLK constant - see some sheet-fed devices */ le = hw->wLineEnd; if (motor->dpi_thresh != 0) { if( param->PhyDpi.y <= motor->dpi_thresh) { le = motor->lineend; DBG( _DBG_INFO2, "* Adjusting lineend: %u\n", le); } regs[0x20] = _HIBYTE( le ); regs[0x21] = _LOBYTE( le ); } tr = m_bLineRateColor * (le + tp * (b + 3 - ntr)); if( tradj == 0 ) { if( ctmode == 0 ) tr += m_bLineRateColor; } else { int le_phi, num_byteclk, num_mclkf, tr_fast_pix, extra_pix; /* Line color or gray mode */ if( afeop != 0 ) { le_phi = (tradj + 1) / 2 + 1 + 6; num_byteclk = ((le_phi + 8 * le + 8 * b + 4) / (8 * tradj)) + 1; num_mclkf = 8 * tradj * num_byteclk; tr_fast_pix = num_byteclk; extra_pix = (num_mclkf - le_phi) % 8; } else /* 3 channel pixel rate color */ { le_phi = (tradj + 1) / 2 + 1 + 10 + 12; num_byteclk = ((le_phi + 3 * 8 * le + 3 * 8 * b + 3 * 4) / (3 * 8 * tradj)) + 1; num_mclkf = 3 * 8 * tradj * num_byteclk; tr_fast_pix = num_byteclk; extra_pix = (num_mclkf - le_phi) % (3 * 8); } tr = b + le + 4 + tr_fast_pix; if (extra_pix == 0) tr++; tr *= m_bLineRateColor; } m_wLineLength = tr / m_bLineRateColor; DBG( _DBG_INFO2, "* LineLength=%d, LineRateColor=%u\n", m_wLineLength, m_bLineRateColor ); } /** usb_GetMotorParam * registers 0x56, 0x57 */ static void usb_GetMotorParam( Plustek_Device *dev, ScanParam *pParam ) { int idx, i; ClkMotorDef *clk; MDef *md; DCapsDef *sCaps = &dev->usbDev.Caps; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; if (!_IS_PLUSTEKMOTOR(hw->motorModel)) { clk = usb_GetMotorSet( hw->motorModel ); md = clk->motor_sets; idx = 0; for( i = 0; i < _MAX_CLK; i++ ) { if( pParam->PhyDpi.y <= dpi_ranges[i] ) break; idx++; } if( idx >= _MAX_CLK ) idx = _MAX_CLK - 1; regs[0x56] = md[idx].pwm; regs[0x57] = md[idx].pwm_duty; regs[0x43] = 0; regs[0x44] = 0; if( md[idx].scan_lines_per_line > 1 ) { if((pParam->bBitDepth > 8) && (pParam->bDataType == SCANDATATYPE_Color)) { regs[0x43] = 0xff; regs[0x44] = md[idx].scan_lines_per_line; DBG( _DBG_INFO2, "* Line Skipping : 0x43=0x%02x, 0x44=0x%02x\n", regs[0x43], regs[0x44] ); } } } else { if( sCaps->OpticDpi.x == 1200 ) { switch( hw->motorModel ) { case MODEL_HuaLien: case MODEL_KaoHsiung: default: if(pParam->PhyDpi.x <= 200) { regs[0x56] = 1; regs[0x57] = 48; /* 63; */ } else if(pParam->PhyDpi.x <= 300) { regs[0x56] = 2; /* 8; */ regs[0x57] = 48; /* 56; */ } else if(pParam->PhyDpi.x <= 400) { regs[0x56] = 8; regs[0x57] = 48; } else if(pParam->PhyDpi.x <= 600) { regs[0x56] = 2; /* 10; */ regs[0x57] = 48; /* 56; */ } else /* pParam->PhyDpi.x == 1200) */ { regs[0x56] = 1; /* 8; */ regs[0x57] = 48; /* 56; */ } break; } } else { switch ( hw->motorModel ) { case MODEL_Tokyo600: regs[0x56] = 16; regs[0x57] = 4; /* 2; */ break; case MODEL_HuaLien: { if(pParam->PhyDpi.x <= 200) { regs[0x56] = 64; /* 24; */ regs[0x57] = 4; /* 16; */ } else if(pParam->PhyDpi.x <= 300) { regs[0x56] = 64; /* 16; */ regs[0x57] = 4; /* 16; */ } else if(pParam->PhyDpi.x <= 400) { regs[0x56] = 64; /* 16; */ regs[0x57] = 4; /* 16; */ } else /* if(pParam->PhyDpi.x <= 600) */ { /* HEINER: check ADF stuff... */ #if 0 if(ScanInf.m_fADF) { regs[0x56] = 8; regs[0x57] = 48; } else #endif { regs[0x56] = 64; /* 2; */ regs[0x57] = 4; /* 48; */ } } } break; case MODEL_KaoHsiung: default: if(pParam->PhyDpi.x <= 200) { regs[0x56] = 24; regs[0x57] = 16; } else if(pParam->PhyDpi.x <= 300) { regs[0x56] = 16; regs[0x57] = 16; } else if(pParam->PhyDpi.x <= 400) { regs[0x56] = 16; regs[0x57] = 16; } else /* if(pParam->PhyDpi.x <= 600) */ { regs[0x56] = 2; regs[0x57] = 48; } break; } } } DBG( _DBG_INFO2, "* MOTOR-Settings: PWM=0x%02x, PWM_DUTY=0x%02x\n", regs[0x56], regs[0x57] ); } /** */ static void usb_GetPauseLimit( Plustek_Device *dev, ScanParam *pParam ) { int coeffsize, scaler; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; scaler = 1; if( hw->bReg_0x26 & _ONE_CH_COLOR ) { if( pParam->bDataType == SCANDATATYPE_Color ) { scaler = 3; } } /* compute size of coefficient ram */ coeffsize = 4 + 16 + 16; /* gamma and shading and offset */ /* if 16 bit, then not all is used */ if( regs[0x09] & 0x20 ) { coeffsize = 16 + 16; /* no gamma */ } coeffsize *= (2*3); /* 3 colors and 2 bytes/word */ /* Get available buffer size in KB * for 512kb this will be 296 * for 2Mb this will be 1832 */ m_dwPauseLimit = (u_long)(hw->wDRAMSize - (u_long)(coeffsize)); m_dwPauseLimit -= ((pParam->Size.dwPhyBytes*scaler) / 1024 + 1); /* If not reversing, take into account the steps to reverse */ if( regs[0x50] == 0 ) m_dwPauseLimit -= ((regs[0x54] & 7) * (pParam->Size.dwPhyBytes * scaler) + 1023) / 1024; DBG( _DBG_INFO2, "* PL=%lu, coeffsize=%u, scaler=%u\n", m_dwPauseLimit, coeffsize, scaler ); m_dwPauseLimit = usb_max( usb_min(m_dwPauseLimit, (u_long)ceil(pParam->Size.dwTotalBytes / 1024.0)), 2); regs[0x4e] = (u_char)floor((m_dwPauseLimit*512.0)/(2.0*hw->wDRAMSize)); if( regs[0x4e] > 1 ) { regs[0x4e]--; if(regs[0x4e] > 1) regs[0x4e]--; } else regs[0x4e] = 1; /* resume, when buffer is 2/8 kbytes full (512k/2M memory) */ regs[0x4f] = 1; DBG( _DBG_INFO2, "* PauseLimit = %lu, [0x4e] = 0x%02x, [0x4f] = 0x%02x\n", m_dwPauseLimit, regs[0x4e], regs[0x4f] ); } /** usb_GetScanLinesAndSize */ static void usb_GetScanLinesAndSize( Plustek_Device *dev, ScanParam *pParam ) { DCapsDef *sCaps = &dev->usbDev.Caps; pParam->Size.dwPhyLines = (u_long)ceil((double) pParam->Size.dwLines * pParam->PhyDpi.y / pParam->UserDpi.y); /* Calculate color offset */ if (pParam->bCalibration == PARAM_Scan && pParam->bChannels == 3) { dev->scanning.bLineDistance = sCaps->bSensorDistance * pParam->PhyDpi.y / sCaps->OpticDpi.x; pParam->Size.dwPhyLines += (dev->scanning.bLineDistance << 1); } else dev->scanning.bLineDistance = 0; pParam->Size.dwTotalBytes = pParam->Size.dwPhyBytes * pParam->Size.dwPhyLines; DBG( _DBG_INFO, "* PhyBytes = %lu\n", pParam->Size.dwPhyBytes ); DBG( _DBG_INFO, "* PhyLines = %lu\n", pParam->Size.dwPhyLines ); DBG( _DBG_INFO, "* TotalBytes = %lu\n", pParam->Size.dwTotalBytes ); } /** function to preset/reset the merlin registers */ static SANE_Bool usb_SetScanParameters( Plustek_Device *dev, ScanParam *pParam ) { static u_char reg8, reg38[6], reg48[2]; ScanDef *scan = &dev->scanning; ScanParam *pdParam = &dev->scanning.sParam; HWDef *hw = &dev->usbDev.HwSetting; u_char *regs = dev->usbDev.a_bRegs; m_pParam = pParam; DBG( _DBG_INFO, "usb_SetScanParameters()\n" ); if( !usb_IsScannerReady(dev)) return SANE_FALSE; if(pParam->bCalibration == PARAM_Scan && pParam->bSource == SOURCE_ADF) { /* HEINER: dSaveMoveSpeed is only used in func EjectPaper!!! dSaveMoveSpeed = hw->dMaxMoveSpeed; */ hw->dMaxMoveSpeed = 1.0; usb_MotorSelect( dev, SANE_TRUE ); usb_MotorOn( dev, SANE_TRUE ); } /* * calculate the basic settings... */ pParam->PhyDpi.x = usb_SetAsicDpiX( dev, pParam->UserDpi.x ); pParam->PhyDpi.y = usb_SetAsicDpiY( dev, pParam->UserDpi.y ); usb_SetColorAndBits( dev, pParam ); usb_GetScanRect ( dev, pParam ); usb_PresetStepSize( dev, pParam ); if( dev->caps.dwFlag & SFLAG_ADF ) { if( pParam->bCalibration == PARAM_Scan ) { if( pdParam->bSource == SOURCE_ADF ) { regs[0x50] = 0; regs[0x51] = 0x40; if( pParam->PhyDpi.x <= 300) regs[0x54] = (regs[0x54] & ~7) | 4; /* 3; */ else regs[0x54] = (regs[0x54] & ~7) | 5; /* 4; */ } else { regs[0x50] = hw->bStepsToReverse; regs[0x51] = hw->bReg_0x51; regs[0x54] &= ~7; } } else regs[0x50] = 0; } else { if( pParam->bCalibration == PARAM_Scan ) regs[0x50] = hw->bStepsToReverse; else regs[0x50] = 0; } /* Assume we will not use ITA */ regs[0x19] = m_bIntTimeAdjust = 0; /* Get variables from calculation algorithms */ if(!(pParam->bCalibration == PARAM_Scan && pParam->bSource == SOURCE_ADF && dev->usbDev.fLastScanIsAdf )) { DBG( _DBG_INFO2, "* Scan calculations...\n" ); usb_GetLineLength ( dev, pParam ); usb_GetStepSize ( dev, pParam ); usb_GetDPD ( dev ); usb_GetMCLKDivider( dev, pParam ); usb_GetMotorParam ( dev, pParam ); } /* Compute fast feed step size, use equation 3 and equation 8 */ if( m_dMCLKDivider < 1.0) m_dMCLKDivider = 1.0; m_wFastFeedStepSize = (u_short)(CRYSTAL_FREQ / (m_dMCLKDivider * 8 * m_bCM * hw->dMaxMoveSpeed * 4 * hw->wMotorDpi)); /* CIS special ;-) */ if((hw->bReg_0x26 & _ONE_CH_COLOR) && (m_bCM == 1)) { DBG( _DBG_INFO2, "* CIS FFStep-Speedup\n" ); m_wFastFeedStepSize /= 3; } if( m_bIntTimeAdjust != 0 ) m_wFastFeedStepSize /= m_bIntTimeAdjust; if(regs[0x0a]) m_wFastFeedStepSize *= ((regs[0x0a] >> 2) + 2); regs[0x48] = _HIBYTE( m_wFastFeedStepSize ); regs[0x49] = _LOBYTE( m_wFastFeedStepSize ); DBG( _DBG_INFO2, "* FFStepSize = %u, [0x48] = 0x%02x, [0x49] = 0x%02x\n", m_wFastFeedStepSize, regs[0x48], regs[0x49] ); /* Compute the number of lines to scan using actual Y resolution */ usb_GetScanLinesAndSize( dev, pParam ); /* Pause limit should be bounded by total bytes to read * so that the chassis will not move too far. */ usb_GetPauseLimit( dev, pParam ); /* For ADF .... */ if(pParam->bCalibration == PARAM_Scan && pParam->bSource == SOURCE_ADF) { if( dev->usbDev.fLastScanIsAdf ) { regs[0x08] = reg8; memcpy( ®s[0x38], reg38, sizeof(reg38)); memcpy( ®s[0x48], reg48, sizeof(reg48)); } else { reg8 = regs[0x08]; memcpy( reg38, ®s[0x38], sizeof(reg38)); memcpy( reg48, ®s[0x48], sizeof(reg48)); } usb_MotorSelect( dev, SANE_TRUE ); } /* Reset LM983x's state machine before setting register values */ if( !usbio_WriteReg( dev->fd, 0x18, 0x18 )) return SANE_FALSE; usleep(200 * 1000); /* Need to delay at least xxx microseconds */ if( !usbio_WriteReg( dev->fd, 0x07, 0x20 )) return SANE_FALSE; if( !usbio_WriteReg( dev->fd, 0x19, 6 )) return SANE_FALSE; regs[0x07] = 0; regs[0x28] = 0; /* set unused registers to 0 */ memset( ®s[0x03], 0, 3 ); memset( ®s[0x5f], 0, 0x7f-0x5f+1 ); if( !usb_IsSheetFedDevice(dev)) { /* we limit the possible scansteps to avoid, that the sensors bumps * against the scanbed - not necessary for sheet-fed devices */ if(pParam->bCalibration==PARAM_Scan && pParam->bSource!=SOURCE_ADF) { u_long lines = pParam->Size.dwPhyLines + scan->bLinesToSkip + scan->dwLinesDiscard + 5; u_short scansteps = (u_short)ceil((double)lines* hw->wMotorDpi / pParam->PhyDpi.y); DBG( _DBG_INFO, "* Scansteps=%u (%lu*%u/%u)\n", scansteps, lines, hw->wMotorDpi, pParam->PhyDpi.y ); regs[0x4c] = _HIBYTE(scansteps); regs[0x4d] = _LOBYTE(scansteps); } } /* set the merlin registers */ _UIO(sanei_lm983x_write( dev->fd, 0x03, ®s[0x03], 3, SANE_TRUE)); _UIO(sanei_lm983x_write( dev->fd, 0x08, ®s[0x08], 0x7f - 0x08+1, SANE_TRUE)); usleep(100); if( !usbio_WriteReg( dev->fd, 0x07, 0 )) return SANE_FALSE; DBG( _DBG_INFO, "usb_SetScanParameters() done.\n" ); return SANE_TRUE; } /** */ static SANE_Bool usb_ScanBegin( Plustek_Device *dev, SANE_Bool auto_park ) { u_char value; u_short inches; HWDef *hw = &dev->usbDev.HwSetting; DCapsDef *sc = &dev->usbDev.Caps; u_char *regs = dev->usbDev.a_bRegs; DBG( _DBG_INFO, "usb_ScanBegin()\n" ); if( !usb_Wait4ScanSample( dev )) return SANE_FALSE; /* save the request for usb_ScanEnd () */ m_fAutoPark = auto_park; /* Disable home sensor during scan, or the chassis cannot move */ value = ((m_pParam->bCalibration == PARAM_Scan && m_pParam->bSource == SOURCE_ADF)? (regs[0x58] & ~7): 0); if(!usbio_WriteReg( dev->fd, 0x58, value )) return SANE_FALSE; /* Check if scanner is ready for receiving command */ if( !usb_IsScannerReady(dev)) return SANE_FALSE; /* Flush cache - only LM9831 (Source: National Semiconductors) */ if( _LM9831 == hw->chip ) { for(;;) { if( SANE_TRUE == cancelRead ) { DBG( _DBG_INFO, "ScanBegin() - Cancel detected...\n" ); return SANE_FALSE; } _UIO(usbio_ReadReg( dev->fd, 0x01, &m_bOldScanData )); if( m_bOldScanData ) { u_long dwBytesToRead = m_bOldScanData * hw->wDRAMSize * 4; u_char *pBuffer = malloc( sizeof(u_char) * dwBytesToRead ); DBG(_DBG_INFO,"Flushing cache - %lu bytes (bOldScanData=%u)\n", dwBytesToRead, m_bOldScanData ); _UIO(sanei_lm983x_read( dev->fd, 0x00, pBuffer, dwBytesToRead, SANE_FALSE )); free( pBuffer ); } else break; } } /* Download map & Shading data */ if(( m_pParam->bCalibration == PARAM_Scan && !usb_MapDownload( dev )) || !usb_DownloadShadingData( dev, m_pParam->bCalibration )) { return SANE_FALSE; } /* Move chassis and start to read image data */ if (!usbio_WriteReg( dev->fd, 0x07, 3 )) return SANE_FALSE; usbio_ReadReg( dev->fd, 0x01, &m_bOldScanData ); m_bOldScanData = 0; /* No data at all */ m_fStart = m_fFirst = SANE_TRUE; /* Prepare to read */ DBG( _DBG_DREGS, "Register Dump before reading data:\n" ); dumpregs( dev->fd, NULL ); inches = (u_short)((m_pParam->Origin.y *300UL)/hw->wMotorDpi); DBG( _DBG_INFO2, ">>> INCH=%u, DOY=%u\n", inches, sc->Normal.DataOrigin.y ); if( inches > sc->Normal.DataOrigin.y ) usb_WaitPos( dev, 150, SANE_FALSE ); DBG( _DBG_INFO, "usb_ScanBegin() done.\n" ); return SANE_TRUE; } /** usb_ScanEnd * stop all the processing stuff and reposition sensor back home */ static SANE_Bool usb_ScanEnd( Plustek_Device *dev ) { u_char value; DBG( _DBG_INFO, "usbDev_ScanEnd(), start=%u, park=%u\n", m_fStart, m_fAutoPark ); usbio_ReadReg( dev->fd, 0x07, &value ); if( value == 3 || value != 2 ) usbio_WriteReg( dev->fd, 0x07, 0 ); if( m_fStart ) { m_fStart = SANE_FALSE; if( m_fAutoPark ) usb_ModuleToHome( dev, SANE_FALSE ); } else if( SANE_TRUE == cancelRead ) { usb_ModuleToHome( dev, SANE_FALSE ); } return SANE_TRUE; } /** */ static SANE_Bool usb_IsDataAvailableInDRAM( Plustek_Device *dev ) { /* Compute polling timeout * Height (Inches) / MaxScanSpeed (Inches/Second) = Seconds to move the * module from top to bottom. Then convert the seconds to miliseconds * by multiply 1000. We add extra 2 seconds to get some tolerance. */ u_char a_bBand[3]; long dwTicks; struct timeval t; u_char *regs = dev->usbDev.a_bRegs; DBG( _DBG_INFO, "usb_IsDataAvailableInDRAM()\n" ); gettimeofday( &t, NULL); dwTicks = t.tv_sec + 30; for(;;) { _UIO( sanei_lm983x_read( dev->fd, 0x01, a_bBand, 3, SANE_FALSE )); gettimeofday( &t, NULL); if( t.tv_sec > dwTicks ) break; if( usb_IsEscPressed()) { DBG(_DBG_INFO,"usb_IsDataAvailableInDRAM() - Cancel detected...\n"); return SANE_FALSE; } /* It is not stable for read */ if((a_bBand[0] != a_bBand[1]) && (a_bBand[1] != a_bBand[2])) continue; if( a_bBand[0] > m_bOldScanData ) { if( m_pParam->bSource != SOURCE_Reflection ) usleep(1000*(30 * regs[0x08] * dev->usbDev.Caps.OpticDpi.x / 600)); else usleep(1000*(20 * regs[0x08] * dev->usbDev.Caps.OpticDpi.x / 600)); DBG( _DBG_INFO, "Data is available\n" ); return SANE_TRUE; } } DBG( _DBG_INFO, "NO Data available\n" ); return SANE_FALSE; } /** */ static SANE_Bool usb_ScanReadImage( Plustek_Device *dev, void *pBuf, u_long dwSize ) { u_char *regs = dev->usbDev.a_bRegs; SANE_Status res; DBG( _DBG_READ, "usb_ScanReadImage(%lu)\n", dwSize ); if( m_fFirst ) { m_fFirst = SANE_FALSE; /* Wait for data band ready */ if (!usb_IsDataAvailableInDRAM( dev )) { DBG( _DBG_ERROR, "Nothing to read...\n" ); return SANE_FALSE; } /* restore the fast forward stepsize...*/ sanei_lm983x_write(dev->fd, 0x48, ®s[0x48], 2, SANE_TRUE); } res = sanei_lm983x_read(dev->fd, 0x00, (u_char *)pBuf, dwSize, SANE_FALSE); /* check for pressed ESC button, as sanei_lm983x_read() may take some time */ if( usb_IsEscPressed()) { DBG(_DBG_INFO,"usb_ScanReadImage() - Cancel detected...\n"); return SANE_FALSE; } DBG( _DBG_READ, "usb_ScanReadImage() done, result: %d\n", res ); if( SANE_STATUS_GOOD == res ) { return SANE_TRUE; } DBG( _DBG_ERROR, "usb_ScanReadImage() failed\n" ); return SANE_FALSE; } /** calculate the number of pixels per line and lines out of a given * crop-area. The size of the area is given on a 300dpi base! */ static void usb_GetImageInfo( Plustek_Device *dev, ImgDef *pInfo, WinInfo *pSize ) { DBG( _DBG_INFO, "usb_GetImageInfo()\n" ); pSize->dwPixels = (u_long)pInfo->crArea.cx * pInfo->xyDpi.x / 300UL; pSize->dwLines = (u_long)pInfo->crArea.cy * pInfo->xyDpi.y / 300UL; DBG( _DBG_INFO2,"Area: cx=%u, cy=%u\n",pInfo->crArea.cx,pInfo->crArea.cy); switch( pInfo->wDataType ) { case COLOR_TRUE48: pSize->dwBytes = pSize->dwPixels * 6UL; break; case COLOR_TRUE24: if( dev->scanning.fGrayFromColor > 7 ){ pSize->dwBytes = (pSize->dwPixels + 7UL) >> 3; pSize->dwPixels = pSize->dwBytes * 8; } else { pSize->dwBytes = pSize->dwPixels * 3UL; } break; case COLOR_GRAY16: pSize->dwBytes = pSize->dwPixels << 1; break; case COLOR_256GRAY: pSize->dwBytes = pSize->dwPixels; break; default: pSize->dwBytes = (pSize->dwPixels + 7UL) >> 3; pSize->dwPixels = pSize->dwBytes * 8; break; } } /** */ static void usb_SaveImageInfo( Plustek_Device *dev, ImgDef *pInfo ) { HWDef *hw = &dev->usbDev.HwSetting; ScanParam *pParam = &dev->scanning.sParam; DBG( _DBG_INFO, "usb_SaveImageInfo()\n" ); /* Dpi & Origins */ pParam->UserDpi = pInfo->xyDpi; pParam->Origin.x = pInfo->crArea.x; pParam->Origin.y = pInfo->crArea.y; /* Source & Bits */ pParam->bBitDepth = 8; switch( pInfo->wDataType ) { case COLOR_TRUE48: pParam->bBitDepth = 16; /* fall through... */ case COLOR_TRUE24: pParam->bDataType = SCANDATATYPE_Color; /* AFE operation: one or 3 channels ! */ if( hw->bReg_0x26 & _ONE_CH_COLOR ) pParam->bChannels = 1; else pParam->bChannels = 3; break; case COLOR_GRAY16: pParam->bBitDepth = 16; /* fall through... */ case COLOR_256GRAY: pParam->bDataType = SCANDATATYPE_Gray; pParam->bChannels = 1; break; default: pParam->bBitDepth = 1; pParam->bDataType = SCANDATATYPE_BW; pParam->bChannels = 1; } DBG( _DBG_INFO, "* dwFlag = 0x%08lx\n", pInfo->dwFlag ); if( pInfo->dwFlag & SCANDEF_Transparency ) pParam->bSource = SOURCE_Transparency; else if( pInfo->dwFlag & SCANDEF_Negative ) pParam->bSource = SOURCE_Negative; else if( pInfo->dwFlag & SCANDEF_Adf ) pParam->bSource = SOURCE_ADF; else pParam->bSource = SOURCE_Reflection; /* it seems, that we need to adjust the Origin.x when we have a * sheetfed device to avoid stripes in the resulting pictures */ if( usb_IsSheetFedDevice(dev)) { int step, div, org, xdpi; xdpi = usb_SetAsicDpiX( dev, pParam->UserDpi.x ); if ((xdpi * 2) <= 300) div = 300; else if ((xdpi * 2) <= 600) div = 600; else if ((xdpi * 2) <= 1200) div = 1200; else div = 2400; step = div / xdpi; org = pParam->Origin.x; pParam->Origin.x = (pParam->Origin.x / step) * step; if (org != pParam->Origin.x) DBG(_DBG_INFO, "* Origin.x adjusted: %i -> %i\n", org, pParam->Origin.x); } } /* END PLUSTEK-USBSCAN.C ....................................................*/ sane-backends-1.0.29/backend/hp-handle.c0000666000000000000000000005271713615534521014610 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Geoffrey T. Dairiki 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP Scanners supporting HP Scanner Control Language (SCL). */ /* #define STUBS extern int sanei_debug_hp; */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #ifdef HAVE_UNISTD_H # include #endif #include #include #include "../include/lassert.h" #include #include #include #include "hp-handle.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_thread.h" #include "hp-device.h" #include "hp-option.h" #include "hp-accessor.h" #include "hp-scsi.h" #include "hp-scl.h" struct hp_handle_s { HpData data; HpDevice dev; SANE_Parameters scan_params; SANE_Pid reader_pid; int child_forked; /* Flag if we used fork() or not */ size_t bytes_left; int pipe_read_fd; sigset_t sig_set; sig_atomic_t cancelled; /* These data are used by the child */ HpScsi scsi; HpProcessData procdata; int pipe_write_fd; }; static hp_bool_t hp_handle_isScanning (HpHandle this) { return this->reader_pid != 0; } /* * reader thread. Used when threads are used */ static int reader_thread (void *data) { struct hp_handle_s *this = (struct hp_handle_s *) data; struct SIGACTION act; SANE_Status status; DBG (1, "reader_thread: thread started\n" " parameters: scsi = 0x%08lx, pipe_write_fd = %d\n", (long) this->scsi, this->pipe_write_fd); memset(&act, 0, sizeof(act)); sigaction(SIGTERM, &act, 0); DBG (1, "Starting sanei_hp_scsi_pipeout()\n"); status = sanei_hp_scsi_pipeout (this->scsi, this->pipe_write_fd, &(this->procdata)); DBG (1, "sanei_hp_scsi_pipeout finished with %s\n", sane_strstatus (status)); close (this->pipe_write_fd); this->pipe_write_fd = -1; sanei_hp_scsi_destroy (this->scsi, 0); return status; } /* * reader process. Used when forking child. */ static int reader_process (void *data) { struct hp_handle_s *this = (struct hp_handle_s *) data; struct SIGACTION sa; SANE_Status status; /* Here we are in a forked child. The thread will not come up to here. */ /* Forked child must close read end of pipe */ close (this->pipe_read_fd); this->pipe_read_fd = -1; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_DFL; sigaction(SIGTERM, &sa, 0); sigdelset(&(this->sig_set), SIGTERM); sigprocmask(SIG_SETMASK, &(this->sig_set), 0); /* not closing writing end of pipe gives an infinite loop on Digital UNIX */ status = sanei_hp_scsi_pipeout (this->scsi, this->pipe_write_fd, &(this->procdata)); close (this->pipe_write_fd); this->pipe_write_fd = -1; DBG(3,"reader_process: Exiting child (%s)\n",sane_strstatus(status)); return (status); } static SANE_Status hp_handle_startReader (HpHandle this, HpScsi scsi) { int fds[2]; sigset_t old_set; assert(this->reader_pid == 0); this->cancelled = 0; this->pipe_write_fd = this->pipe_read_fd = -1; if (pipe(fds)) return SANE_STATUS_IO_ERROR; sigfillset(&(this->sig_set)); sigprocmask(SIG_BLOCK, &(this->sig_set), &old_set); this->scsi = scsi; this->pipe_write_fd = fds[1]; this->pipe_read_fd = fds[0]; /* Will childs be forked ? */ this->child_forked = sanei_thread_is_forked (); /* Start a thread or fork a child. None of them will return here. */ /* Returning means to be in the parent or thread/fork failed */ this->reader_pid = sanei_thread_begin (this->child_forked ? reader_process : reader_thread, (void *) this); if (this->reader_pid != 0) { /* Here we are in the parent */ sigprocmask(SIG_SETMASK, &old_set, 0); if ( this->child_forked ) { /* After fork(), parent must close writing end of pipe */ DBG(3, "hp_handle_startReader: parent closes write end of pipe\n"); close (this->pipe_write_fd); this->pipe_write_fd = -1; } if (!sanei_thread_is_valid (this->reader_pid)) { if ( !this->child_forked ) { close (this->pipe_write_fd); this->pipe_write_fd = -1; } close (this->pipe_read_fd); this->pipe_read_fd = -1; DBG(1, "hp_handle_startReader: fork() failed\n"); return SANE_STATUS_IO_ERROR; } DBG(1, "start_reader: reader process %ld started\n", (long) this->reader_pid); return SANE_STATUS_GOOD; } DBG(3, "Unexpected return from sanei_thread_begin()\n"); return SANE_STATUS_INVAL; } static SANE_Status hp_handle_stopScan (HpHandle this) { HpScsi scsi; this->cancelled = 0; this->bytes_left = 0; if (this->reader_pid) { int info; DBG(3, "hp_handle_stopScan: killing child (%ld)\n", (long) this->reader_pid); sanei_thread_kill (this->reader_pid); sanei_thread_waitpid(this->reader_pid, &info); DBG(1, "hp_handle_stopScan: child %s = %d\n", WIFEXITED(info) ? "exited, status" : "signalled, signal", WIFEXITED(info) ? WEXITSTATUS(info) : WTERMSIG(info)); close(this->pipe_read_fd); this->reader_pid = 0; if ( !FAILED( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name)) ) { if (WIFSIGNALED(info)) { /* sanei_hp_scl_set(scsi, SCL_CLEAR_ERRORS, 0); sanei_hp_scl_errcheck(scsi); */ sanei_hp_scl_reset(scsi); } sanei_hp_scsi_destroy(scsi,0); } } else { DBG(3, "hp_handle_stopScan: no pid for child\n"); } return SANE_STATUS_GOOD; } static SANE_Status hp_handle_uploadParameters (HpHandle this, HpScsi scsi, int *scan_depth, hp_bool_t *soft_invert, hp_bool_t *out8) { SANE_Parameters * p = &this->scan_params; int data_width; enum hp_device_compat_e compat; assert(scsi); *soft_invert = 0; *out8 = 0; p->last_frame = SANE_TRUE; /* inquire resulting size of image after setting it up */ RETURN_IF_FAIL( sanei_hp_scl_inquire(scsi, SCL_PIXELS_PER_LINE, &p->pixels_per_line,0,0) ); RETURN_IF_FAIL( sanei_hp_scl_inquire(scsi, SCL_BYTES_PER_LINE, &p->bytes_per_line,0,0) ); RETURN_IF_FAIL( sanei_hp_scl_inquire(scsi, SCL_NUMBER_OF_LINES, &p->lines,0,0)); RETURN_IF_FAIL( sanei_hp_scl_inquire(scsi, SCL_DATA_WIDTH, &data_width,0,0)); switch (sanei_hp_optset_scanmode(this->dev->options, this->data)) { case HP_SCANMODE_LINEART: /* Lineart */ case HP_SCANMODE_HALFTONE: /* Halftone */ p->format = SANE_FRAME_GRAY; p->depth = 1; *scan_depth = 1; /* The OfficeJets don't seem to handle SCL_INVERSE_IMAGE, so we'll * have to invert in software. */ if ((sanei_hp_device_probe (&compat, scsi) == SANE_STATUS_GOOD) && (compat & HP_COMPAT_OJ_1150C)) { *soft_invert=1; } break; case HP_SCANMODE_GRAYSCALE: /* Grayscale */ p->format = SANE_FRAME_GRAY; p->depth = (data_width > 8) ? 16 : 8; *scan_depth = data_width; /* 8 bit output forced ? */ if ( *scan_depth > 8 ) { *out8 = sanei_hp_optset_output_8bit (this->dev->options, this->data); DBG(1,"hp_handle_uploadParameters: out8=%d\n", (int)*out8); if (*out8) { p->depth = 8; p->bytes_per_line /= 2; } } break; case HP_SCANMODE_COLOR: /* RGB */ p->format = SANE_FRAME_RGB; p->depth = (data_width > 24) ? 16 : 8; *scan_depth = data_width / 3; /* 8 bit output forced ? */ if ( *scan_depth > 8 ) { *out8 = sanei_hp_optset_output_8bit (this->dev->options, this->data); DBG(1,"hp_handle_uploadParameters: out8=%d\n", (int)*out8); if (*out8) { p->depth = 8; p->bytes_per_line /= 2; } } /* HP PhotoSmart does not invert when depth > 8. Lets do it by software */ if ( (*scan_depth > 8) && (sanei_hp_device_probe (&compat, scsi) == SANE_STATUS_GOOD) && (compat & HP_COMPAT_PS) ) *soft_invert = 1; DBG(1, "hp_handle_uploadParameters: data width %d\n", data_width); break; default: assert(!"Aack"); return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } HpHandle sanei_hp_handle_new (HpDevice dev) { HpHandle new = sanei_hp_allocz(sizeof(*new)); if (!new) return 0; if (!(new->data = sanei_hp_data_dup(dev->data))) { sanei_hp_free(new); return 0; } new->dev = dev; return new; } void sanei_hp_handle_destroy (HpHandle this) { HpScsi scsi=0; DBG(3,"sanei_hp_handle_destroy: stop scan\n"); hp_handle_stopScan(this); if (sanei_hp_scsi_new(&scsi,this->dev->sanedev.name)==SANE_STATUS_GOOD && scsi) { sanei_hp_scsi_destroy(scsi,1); } sanei_hp_data_destroy(this->data); sanei_hp_free(this); } const SANE_Option_Descriptor * sanei_hp_handle_saneoption (HpHandle this, SANE_Int optnum) { if (this->cancelled) { DBG(1, "sanei_hp_handle_saneoption: cancelled. Stop scan\n"); hp_handle_stopScan(this); } return sanei_hp_optset_saneoption(this->dev->options, this->data, optnum); } SANE_Status sanei_hp_handle_control(HpHandle this, SANE_Int optnum, SANE_Action action, void *valp, SANE_Int *info) { SANE_Status status; HpScsi scsi; hp_bool_t immediate; if (this->cancelled) { DBG(1, "sanei_hp_handle_control: cancelled. Stop scan\n"); RETURN_IF_FAIL( hp_handle_stopScan(this) ); } if (hp_handle_isScanning(this)) return SANE_STATUS_DEVICE_BUSY; RETURN_IF_FAIL( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name) ); immediate = sanei_hp_optset_isImmediate(this->dev->options, optnum); status = sanei_hp_optset_control(this->dev->options, this->data, optnum, action, valp, info, scsi, immediate); sanei_hp_scsi_destroy ( scsi,0 ); return status; } SANE_Status sanei_hp_handle_getParameters (HpHandle this, SANE_Parameters *params) { SANE_Status status; if (!params) return SANE_STATUS_GOOD; if (this->cancelled) { DBG(1, "sanei_hp_handle_getParameters: cancelled. Stop scan\n"); RETURN_IF_FAIL( hp_handle_stopScan(this) ); } if (hp_handle_isScanning(this)) { *params = this->scan_params; return SANE_STATUS_GOOD; } status = sanei_hp_optset_guessParameters(this->dev->options, this->data, params); #ifdef INQUIRE_AFTER_SCAN /* Photosmart: this gives the correct number of lines when doing an update of the SANE parameters right after a preview */ if (!strcmp("C5100A", this->dev->sanedev.model)) { HpScsi scsi; SANE_Parameters * p = &this->scan_params; if (!FAILED( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name) )) { RETURN_IF_FAIL( sanei_hp_scl_inquire(scsi, SCL_NUMBER_OF_LINES, &p->lines,0,0)); sanei_hp_scsi_destroy(scsi,0); *params = this->scan_params; } } #endif return status; } SANE_Status sanei_hp_handle_startScan (HpHandle this) { SANE_Status status; HpScsi scsi; HpScl scl; HpProcessData *procdata = &(this->procdata); int adfscan; /* FIXME: setup preview mode stuff? */ if (hp_handle_isScanning(this)) { DBG(3,"sanei_hp_handle_startScan: Stop current scan\n"); RETURN_IF_FAIL( hp_handle_stopScan(this) ); } RETURN_IF_FAIL( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name) ); status = sanei_hp_optset_download(this->dev->options, this->data, scsi); if (!FAILED(status)) status = hp_handle_uploadParameters(this, scsi, &(procdata->bits_per_channel), &(procdata->invert), &(procdata->out8)); if (FAILED(status)) { sanei_hp_scsi_destroy(scsi,0); return status; } procdata->mirror_vertical = sanei_hp_optset_mirror_vert (this->dev->options, this->data, scsi); DBG(1, "start: %s to mirror image vertically\n", procdata->mirror_vertical ? "Request" : "No request" ); scl = sanei_hp_optset_scan_type (this->dev->options, this->data); adfscan = (scl == SCL_ADF_SCAN); /* For ADF scan we should check if there is paper available */ if ( adfscan ) {int adfstat = 0; int can_check_paper = 0; int is_flatbed = 0; int minval, maxval; /* For ADF-support, we have three different types of scanners: * ScanJet, ScanJet+, IIp, 3p: * scroll feed, no support for inquire paper in ADF, unload document * and preload document * IIc, IIcx, 3c, 4c, 6100C, 4p: * flatbed, no support for preload document * 5100C, 5200C, 6200C, 6300C: * scroll feed. * For all scroll feed types, we use the usual scan window command. * For flatbed types, use a sequence of special commands. */ /* Check the IIp group */ if ( (sanei_hp_device_support_get (this->dev->sanedev.name, SCL_UNLOAD, &minval, &maxval) != SANE_STATUS_GOOD ) && (sanei_hp_device_support_get (this->dev->sanedev.name, SCL_CHANGE_DOC, &minval, &maxval) != SANE_STATUS_GOOD ) ) { DBG(3, "start: Request for ADF scan without support of unload doc\n"); DBG(3, " and change doc. Seems to be something like a IIp.\n"); DBG(3, " Use standard scan window command.\n"); scl = SCL_START_SCAN; can_check_paper = 0; is_flatbed = 0; } /* else if ( sanei_hp_device_support_get (this->dev->sanedev.name, SCL_PRELOAD_ADF, &minval, &maxval) != SANE_STATUS_GOOD ) */ else if ( sanei_hp_is_flatbed_adf (scsi) ) { DBG(3, "start: Request for ADF scan without support of preload doc.\n"); DBG(3, " Seems to be a flatbed ADF.\n"); DBG(3, " Use ADF scan window command.\n"); can_check_paper = 1; is_flatbed = 1; } else { DBG(3, "start: Request for ADF scan with support of preload doc.\n"); DBG(3, " Seems to be a scroll feed ADF.\n"); DBG(3, " Use standard scan window command.\n"); scl = SCL_START_SCAN; can_check_paper = 1; is_flatbed = 0; } /* Check if the ADF is ready */ if ( sanei_hp_scl_inquire(scsi, SCL_ADF_READY, &adfstat, 0, 0) != SANE_STATUS_GOOD ) { DBG(1, "start: Error checking if ADF is ready\n"); sanei_hp_scsi_destroy(scsi,0); return SANE_STATUS_UNSUPPORTED; } if ( adfstat != 1 ) { DBG(1, "start: ADF is not ready. Finished.\n"); sanei_hp_scsi_destroy(scsi,0); return SANE_STATUS_NO_DOCS; } /* Check paper in ADF */ if ( can_check_paper ) { if ( sanei_hp_scl_inquire(scsi, SCL_ADF_BIN, &adfstat, 0, 0) != SANE_STATUS_GOOD ) { DBG(1, "start: Error checking if paper in ADF\n"); sanei_hp_scsi_destroy(scsi,0); return SANE_STATUS_UNSUPPORTED; } if ( adfstat != 1 ) { DBG(1, "start: No paper in ADF bin. Finished.\n"); sanei_hp_scsi_destroy(scsi,0); return SANE_STATUS_NO_DOCS; } if ( is_flatbed ) { if ( sanei_hp_scl_set(scsi, SCL_CHANGE_DOC, 0) != SANE_STATUS_GOOD ) { DBG(1, "start: Error changing document\n"); sanei_hp_scsi_destroy(scsi,0); return SANE_STATUS_UNSUPPORTED; } } } } DBG(1, "start: %s to mirror image vertically\n", procdata->mirror_vertical ? "Request" : "No request" ); this->bytes_left = ( this->scan_params.bytes_per_line * this->scan_params.lines ); DBG(1, "start: %d pixels per line, %d bytes per line, %d lines high\n", this->scan_params.pixels_per_line, this->scan_params.bytes_per_line, this->scan_params.lines); procdata->bytes_per_line = (int)this->scan_params.bytes_per_line; if (procdata->out8) { procdata->bytes_per_line *= 2; DBG(1,"(scanner will send %d bytes per line, 8 bit output forced)\n", procdata->bytes_per_line); } procdata->lines = this->scan_params.lines; /* Wait for front-panel button push ? */ status = sanei_hp_optset_start_wait(this->dev->options, this->data); if (status) /* Wait for front button push ? Start scan in reader process */ { procdata->startscan = scl; status = SANE_STATUS_GOOD; } else { procdata->startscan = 0; status = sanei_hp_scl_startScan(scsi, scl); } if (!FAILED( status )) { status = hp_handle_startReader(this, scsi); } /* Close SCSI-connection in forked environment */ if (this->child_forked) sanei_hp_scsi_destroy(scsi,0); return status; } SANE_Status sanei_hp_handle_read (HpHandle this, void * buf, size_t *lengthp) { ssize_t nread; SANE_Status status; DBG(3, "sanei_hp_handle_read: trying to read %lu bytes\n", (unsigned long) *lengthp); if (!hp_handle_isScanning(this)) { DBG(1, "sanei_hp_handle_read: not scanning\n"); return SANE_STATUS_INVAL; } if (this->cancelled) { DBG(1, "sanei_hp_handle_read: cancelled. Stop scan\n"); RETURN_IF_FAIL( hp_handle_stopScan(this) ); return SANE_STATUS_CANCELLED; } if (*lengthp == 0) return SANE_STATUS_GOOD; if (*lengthp > this->bytes_left) *lengthp = this->bytes_left; if ((nread = read(this->pipe_read_fd, buf, *lengthp)) < 0) { *lengthp = 0; if (errno == EAGAIN) return SANE_STATUS_GOOD; DBG(1, "sanei_hp_handle_read: read from pipe: %s. Stop scan\n", strerror(errno)); hp_handle_stopScan(this); return SANE_STATUS_IO_ERROR; } this->bytes_left -= (*lengthp = nread); if (nread > 0) { DBG(3, "sanei_hp_handle_read: read %lu bytes\n", (unsigned long) nread); return SANE_STATUS_GOOD; } DBG(1, "sanei_hp_handle_read: EOF from pipe. Stop scan\n"); status = this->bytes_left ? SANE_STATUS_IO_ERROR : SANE_STATUS_EOF; RETURN_IF_FAIL( hp_handle_stopScan(this) ); /* Switch off lamp and check unload after scan */ if (status == SANE_STATUS_EOF) { const HpDeviceInfo *hpinfo; HpScsi scsi; if ( sanei_hp_scsi_new(&scsi, this->dev->sanedev.name) == SANE_STATUS_GOOD ) { hpinfo = sanei_hp_device_info_get ( this->dev->sanedev.name ); if ( hpinfo ) { if ( hpinfo->unload_after_scan ) sanei_hp_scl_set(scsi, SCL_UNLOAD, 0); } sanei_hp_scsi_destroy(scsi,0); } } return status; } void sanei_hp_handle_cancel (HpHandle this) { this->cancelled = 1; /* The OfficeJet K series may not deliver enough data. */ /* Therefore the read might not return until it is interrupted. */ DBG(3,"sanei_hp_handle_cancel: compat flags: 0x%04x\n", (int)this->dev->compat); if ( (this->reader_pid) && (this->dev->compat & HP_COMPAT_OJ_1150C) ) { DBG(3,"sanei_hp_handle_cancel: send SIGTERM to child (%ld)\n", (long) this->reader_pid); sanei_thread_kill(this->reader_pid); } } SANE_Status sanei_hp_handle_setNonblocking (HpHandle this, hp_bool_t non_blocking) { if (!hp_handle_isScanning(this)) return SANE_STATUS_INVAL; if (this->cancelled) { DBG(3,"sanei_hp_handle_setNonblocking: cancelled. Stop scan\n"); RETURN_IF_FAIL( hp_handle_stopScan(this) ); return SANE_STATUS_CANCELLED; } if (fcntl(this->pipe_read_fd, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) return SANE_STATUS_IO_ERROR; return SANE_STATUS_GOOD; } SANE_Status sanei_hp_handle_getPipefd (HpHandle this, SANE_Int *fd) { if (! hp_handle_isScanning(this)) return SANE_STATUS_INVAL; if (this->cancelled) { DBG(3,"sanei_hp_handle_getPipefd: cancelled. Stop scan\n"); RETURN_IF_FAIL( hp_handle_stopScan(this) ); return SANE_STATUS_CANCELLED; } *fd = this->pipe_read_fd; return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/coolscan.h0000666000000000000000000002401713615534521014546 00000000000000/* --------------------------------------------------------------------- */ /* coolscan.h - headerfile for SANE-backend for coolscan scanners 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* --------------------------------------------------------------------- */ #ifndef coolscan_h #define coolscan_h #include "sys/types.h" enum Coolscan_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_SOURCE, OPT_RESOLUTION, OPT_PREVIEW_RESOLUTION, OPT_TYPE, OPT_BIT_DEPTH, OPT_PRESCAN, OPT_PRESCAN_NOW, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_GAMMA_BIND, OPT_ANALOG_GAMMA, OPT_AVERAGING, OPT_RGB_CONTROL, OPT_BRIGHTNESS, OPT_R_BRIGHTNESS, OPT_G_BRIGHTNESS, OPT_B_BRIGHTNESS, OPT_CONTRAST, OPT_R_CONTRAST, OPT_G_CONTRAST, OPT_B_CONTRAST, OPT_EXPOSURE, OPT_R_EXPOSURE, OPT_G_EXPOSURE, OPT_B_EXPOSURE, OPT_R_SHIFT, OPT_G_SHIFT, OPT_B_SHIFT, OPT_ADVANCED_GROUP, OPT_PREVIEW, /* preview */ OPT_AUTOFOCUS, /* autofocus */ OPT_IRED_RED, OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, /* must come last: */ NUM_OPTIONS }; typedef struct Image_Pos { int start; /* start position of image on film strip */ int end; /* end position of image on film strip */ int offset /* always 0 */; int height; /* image height always 2591 */ } Image_Pos_t; typedef struct Coolscan { struct Coolscan *next; SANE_Option_Descriptor opt[NUM_OPTIONS]; SANE_Pid reader_pid; int reader_fds; int pipe; int scanning; /*--------------------------*/ SANE_Device sane; SANE_Range dpi_range; SANE_Range x_range; SANE_Range y_range; /*--------------------------*/ /* buffer used for scsi-transfer and writing*/ unsigned char *buffer; unsigned char *obuffer; unsigned int row_bufsize; char *devicename; /* name of the scanner device */ int sfd; /* output file descriptor, scanner device */ char vendor[9]; /* will be Nikon */ char product[17]; /* e.g. "LS-1000 " or so */ char version[5]; /* e.g. V1.6 */ int LS; /* index in scanner_str */ int cont; /* continue although scanner is unknown */ int verbose; /* 1,2=output informations */ int asf; /* Automatic Slide Feeder enabled? */ int MUD; /* Measurement Unit Divisor (1200 or 2700) */ int inquiry_len; /* length of inquiry return block [36] */ int inquiry_wdb_len; /* length of window descriptor block [117] */ int wdb_len; /* use this length of WDB */ double width; /* use this width of scan-area */ double length; /* use this length of scan-area */ int x_nres; int y_nres; int x_p_nres; /* same as above, but apply to preview */ int y_p_nres; int tlx; /* Left edge in 'Internal Length Units'. */ int tly; /* Top edge in ILU */ int brx; /* Right edge in ILU. */ int bry; /* Bottom edge in ILU. */ int bits_per_color; /* bits per color (8/10/12) */ int bits_per_pixel; /* bits per pixel (24/30/40) */ int negative; /* Negative/positive object */ int dropoutcolor; /* Which color to scan when gray */ int transfermode; /**/ int gammaselection; /* Linear/Monitor*/ int shading; int averaging; int brightness_R; int brightness_G; int brightness_B; int contrast_R; int contrast_G; int contrast_B; int exposure_R; int exposure_G; int exposure_B; int shift_R; int shift_G; int shift_B; int set_auto; /* 0 or 1, don't know what it is */ int preview; /* 1 if preview */ int autofocus; /* when to do autofocus */ #define AF_NEVER 0x00 #define AF_PREVIEW 0x01 #define AF_SCAN 0x02 #define AF_PREANDSCAN 0x03 int colormode; /* GREYSCALE or RGB */ int colormode_p; /* GREYSCALE or RGB for preview */ #define GREYSCALE 0x01 #define RGB 0x07 #define IRED 0x08 #define RGBI 0x0f int low_byte_first; /* 1 if little-endian - 0 if big-endian */ /* Internal information */ int adbits; /* Number of A/D bits [8 or 12] */ int outputbits; /* Number of output image data bits [8] */ int maxres; /* Maximum resolution [2700] (dpi) */ int xmax; /* X-axis coordinate maximum value (basic measurement unit when measurement unit divisor = 1200) [1151] */ int ymax; /* Y-axis coordinate maximum value (basic measurement unit when measurement unit divisor = 1200) [1727] */ int xmaxpix; /* X-axis coordinate maximum value (pixel address value) [2591] */ int ymaxpix; /* Y-axis coordinate maximum value (pixel address value) [3887] */ int ycurrent; /* Current stage position (Y-axis direction pixel address) [0-7652] */ int currentfocus; /* Current focus position (focus direction address) [0-200] */ int currentscanpitch; /* Current scan pitch [1-25] */ int autofeeder; /* Provision of auto feeder [Yes: 1, No: 0] */ int analoggamma; /* Analog gamma support [Yes: 1, No: 0] */ int derr[8]; /* Device error code (0 is latest, 7 oldest) */ int wbetr_r; /* White balance exposure time variable (R) */ int webtr_g; /* White balance exposure time variable (G) */ int webtr_b; /* White balance exposure time variable (B) */ int pretv_r; /* Prescan result exposure time variable (R) */ int pretv_g; /* Prescan result exposure time variable (G) */ int pretv_b; /* Prescan result exposure time variable (B) */ int cetv_r; /* Current exposure time variable (R) */ int cetv_g; /* Current exposure time variable (G) */ int cetv_b; /* Current exposure time variable (B) */ int ietu_r; /* Internal exposure time unit (R) */ int ietu_g; /* Internal exposure time unit (G) */ int ietu_b; /* Internal exposure time unit (B) */ int limitcondition; /* Condition of each limit SW, DIP SW, etc. */ int offsetdata_r; /* Offset data (R) */ int offsetdata_g; /* Offset data (G) */ int offsetdata_b; /* Offset data (B) */ char power_on_errors[8]; /* Records of error code at power on */ /* End of internal information */ int brightness; /* (128) cbhs_range 0-255, halftone mode */ int contrast; /* (128) cbhs_range 0-255, halftone-mode */ int prescan; /* */ int rgb_control; /* */ int gamma_bind; /* TRUE -> RGB */ int lutlength; /* length of gamma table */ int max_lut_val; /* maximum value in lut */ SANE_Word gamma[4096]; /* gamma value for RGB */ SANE_Word gamma_r[4096]; /* gamma value for red */ SANE_Word gamma_g[4096]; /* gamma value for green */ SANE_Word gamma_b[4096]; /* gamma value for blue */ int luti[4096]; /* lut value for infrared */ int lutr[4096]; /* lut value for red */ int lutg[4096]; /* lut value for green */ int lutb[4096]; /* lut value for blue */ char *gamma_file_r; /* file for gamma download */ char *gamma_file_g; /* file for gamma download */ char *gamma_file_b; /* file for gamma download */ int analog_gamma_r; /* analog gamma red and grey */ int analog_gamma_g; /* analog gamma green */ int analog_gamma_b; /* analog gamma blue */ /* Infrared correction values */ int ired_red; int ired_green; int ired_blue; int feeder; /* type of feeder used */ int numima; /* number of images on film strip */ int posima; /* current image */ Image_Pos_t ipos[6]; /* positions for 6 images */ #define STRIP_FEEDER 1 #define MOUNT_FEEDER 2 } Coolscan_t; typedef struct { char *scanner; char *inquiry; int inquiry_len; } inquiry_blk; /* ==================================================================== */ /* names of scanners that are supported because */ /* the inquiry_return_block is ok and driver is tested */ static char *scanner_str[] = { "COOLSCAN II ", "LS-1000 ", "COOLSCANIII ", "LS-2000 ", }; #define known_scanners 4 /* Comment this line if you havn't patched sane.h to include SANE_FRAME_RGBA */ /* #define HAS_IRED 1 */ #endif /* coolscan-sane_h */ sane-backends-1.0.29/backend/ricoh.c0000666000000000000000000007160413615534521014050 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1998, Feico W. Dillema 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* $Id$ This file implements a SANE backend for Ricoh flatbed scanners. */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #define BACKEND_NAME ricoh #include "../include/sane/sanei_backend.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #include "../include/sane/sanei_config.h" #define RICOH_CONFIG_FILE "ricoh.conf" #include "ricoh.h" #define MAX(a,b) ((a) > (b) ? (a) : (b)) static const SANE_Device **devlist = NULL; static int num_devices = 0; static Ricoh_Device *first_dev = NULL; static Ricoh_Scanner *first_handle = NULL; static int is50 = 0; #include "ricoh-scsi.c" static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; DBG (11, ">> max_string_size\n"); for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } DBG (11, "<< max_string_size\n"); return max_size; } static SANE_Status attach (const char *devnam, Ricoh_Device ** devp) { SANE_Status status; Ricoh_Device *dev; int fd; struct inquiry_data ibuf; struct measurements_units_page mup; struct ricoh_window_data wbuf; size_t buf_size; char *str; DBG (11, ">> attach\n"); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devnam) == 0) { if (devp) *devp = dev; return (SANE_STATUS_GOOD); } } DBG (3, "attach: opening %s\n", devnam); status = sanei_scsi_open (devnam, &fd, NULL, NULL); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: open failed: %s\n", sane_strstatus (status)); return (status); } DBG (3, "attach: sending INQUIRY\n"); memset (&ibuf, 0, sizeof (ibuf)); buf_size = sizeof(ibuf); status = inquiry (fd, &ibuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: inquiry failed: %s\n", sane_strstatus (status)); sanei_scsi_close (fd); return (status); } if (ibuf.devtype != 6 || strncmp ((char *)ibuf.vendor, "RICOH", 5) != 0 || (strncmp ((char *)ibuf.product, "IS50", 4) != 0 && strncmp ((char *)ibuf.product, "IS60", 4) != 0)) { DBG (1, "attach: device doesn't look like the Ricoh scanner I know\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } is50 = (strncmp ((char *)ibuf.product, "IS50", 4) == 0); DBG (3, "attach: sending TEST_UNIT_READY\n"); status = test_unit_ready (fd); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: test unit ready failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (fd); return (status); } DBG (3, "attach: sending OBJECT POSITION\n"); status = object_position (fd); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: OBJECT POSTITION failed\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } memset (&mup, 0, sizeof (mup)); mup.page_code = MEASUREMENTS_PAGE; mup.parameter_length = 0x06; mup.bmu = INCHES; mup.mud[0] = (DEFAULT_MUD >> 8) & 0xff; mup.mud[1] = (DEFAULT_MUD & 0xff); #if 0 DBG (3, "attach: sending MODE SELECT\n"); status = mode_select (fd, (struct mode_pages *) &mup); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: MODE_SELECT failed\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } #endif #if 0 DBG (3, "attach: sending MODE SENSE\n"); memset (&mup, 0, sizeof (mup)); status = mode_sense (fd, (struct mode_pages *) &mup, PC_CURRENT | MEASUREMENTS_PAGE); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: MODE_SENSE failed\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } #endif DBG (3, "attach: sending GET WINDOW\n"); memset (&wbuf, 0, sizeof (wbuf)); status = get_window (fd, &wbuf); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: GET_WINDOW failed %d\n", status); sanei_scsi_close (fd); DBG (11, "<< attach\n"); return (SANE_STATUS_INVAL); } sanei_scsi_close (fd); dev = malloc (sizeof (*dev)); if (!dev) return (SANE_STATUS_NO_MEM); memset (dev, 0, sizeof (*dev)); dev->sane.name = strdup (devnam); dev->sane.vendor = "RICOH"; size_t prod_rev_size = sizeof(ibuf.product) + sizeof(ibuf.revision) + 1; str = malloc (prod_rev_size); if (str) { snprintf (str, prod_rev_size, "%.*s%.*s", (int) sizeof(ibuf.product), (const char *) ibuf.product, (int) sizeof(ibuf.revision), (const char *) ibuf.revision); } dev->sane.model = str; dev->sane.type = "flatbed scanner"; DBG (5, "dev->sane.name = %s\n", dev->sane.name); DBG (5, "dev->sane.vendor = %s\n", dev->sane.vendor); DBG (5, "dev->sane.model = %s\n", dev->sane.model); DBG (5, "dev->sane.type = %s\n", dev->sane.type); dev->info.xres_default = _2btol(wbuf.x_res); dev->info.yres_default = _2btol(wbuf.y_res); dev->info.image_mode_default = wbuf.image_comp; /* if you throw the MRIF bit the brighness control reverses too */ /* so I reverse the reversal in software for symmetry's sake */ /* I should make this into an option */ if (wbuf.image_comp == RICOH_GRAYSCALE || wbuf.image_comp == RICOH_DITHERED_MONOCHROME) { dev->info.brightness_default = 256 - wbuf.brightness; if (is50) dev->info.contrast_default = wbuf.contrast; else dev->info.contrast_default = 256 - wbuf.contrast; } else /* wbuf.image_comp == RICOH_BINARY_MONOCHROME */ { dev->info.brightness_default = wbuf.brightness; dev->info.contrast_default = wbuf.contrast; } #if 1 dev->info.bmu = mup.bmu; dev->info.mud = _2btol(mup.mud); if (dev->info.mud == 0) { /* The RICOH says it uses points as default Basic Measurement Unit */ /* but gives a Measurement Unit Divisor of zero */ /* So, we set it to the default (SCSI-standard) of 1200 */ /* with BMU in inches, i.e. 1200 points equal 1 inch */ dev->info.bmu = INCHES; dev->info.mud = DEFAULT_MUD; } #else dev->info.bmu = INCHES; dev->info.mud = DEFAULT_MUD; #endif DBG (5, "xres_default=%d\n", dev->info.xres_default); DBG (5, "xres_range.max=%d\n", dev->info.xres_range.max); DBG (5, "xres_range.min=%d\n", dev->info.xres_range.min); DBG (5, "yres_default=%d\n", dev->info.yres_default); DBG (5, "yres_range.max=%d\n", dev->info.yres_range.max); DBG (5, "yres_range.min=%d\n", dev->info.yres_range.min); DBG (5, "x_range.max=%d\n", dev->info.x_range.max); DBG (5, "y_range.max=%d\n", dev->info.y_range.max); DBG (5, "image_mode=%d\n", dev->info.image_mode_default); DBG (5, "brightness=%d\n", dev->info.brightness_default); DBG (5, "contrast=%d\n", dev->info.contrast_default); DBG (5, "bmu=%d\n", dev->info.bmu); DBG (5, "mud=%d\n", dev->info.mud); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; DBG (11, "<< attach\n"); return (SANE_STATUS_GOOD); } static SANE_Status attach_one(const char *devnam) { attach (devnam, NULL); return SANE_STATUS_GOOD; } static SANE_Status init_options (Ricoh_Scanner * s) { int i; DBG (11, ">> init_options\n"); memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = "Scan Mode"; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].s = strdup (mode_list[s->hw->info.image_mode_default]); /* x resolution */ s->opt[OPT_X_RESOLUTION].name = "X" SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].title = "X " SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_X_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_X_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_X_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_X_RESOLUTION].constraint.range = &is60_res_range; s->val[OPT_X_RESOLUTION].w = s->hw->info.xres_default; if (is50) s->opt[OPT_X_RESOLUTION].constraint.range = &is50_res_range; else s->opt[OPT_X_RESOLUTION].constraint.range = &is60_res_range; /* y resolution */ s->opt[OPT_Y_RESOLUTION].name = "Y" SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_Y_RESOLUTION].title = "Y " SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_Y_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_Y_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_Y_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_Y_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->val[OPT_Y_RESOLUTION].w = s->hw->info.yres_default; if (is50) s->opt[OPT_Y_RESOLUTION].constraint.range = &is50_res_range; else s->opt[OPT_Y_RESOLUTION].constraint.range = &is60_res_range; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_INT; s->opt[OPT_TL_X].unit = SANE_UNIT_PIXEL; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &default_x_range; s->val[OPT_TL_X].w = 0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_INT; s->opt[OPT_TL_Y].unit = SANE_UNIT_PIXEL; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &default_y_range; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_INT; s->opt[OPT_BR_X].unit = SANE_UNIT_PIXEL; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &default_x_range; s->val[OPT_BR_X].w = default_x_range.max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_INT; s->opt[OPT_BR_Y].unit = SANE_UNIT_PIXEL; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &default_y_range; s->val[OPT_BR_Y].w = default_y_range.max; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &u8_range; s->val[OPT_BRIGHTNESS].w = s->hw->info.brightness_default; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_INT; s->opt[OPT_CONTRAST].unit = SANE_UNIT_NONE; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &u8_range; s->val[OPT_CONTRAST].w = s->hw->info.contrast_default; DBG (11, "<< init_options\n"); return SANE_STATUS_GOOD; } static SANE_Status do_cancel (Ricoh_Scanner * s) { SANE_Status status; DBG (11, ">> do_cancel\n"); DBG (3, "cancel: sending OBJECT POSITION\n"); status = object_position (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "cancel: OBJECT POSTITION failed\n"); } s->scanning = SANE_FALSE; if (s->fd >= 0) { sanei_scsi_close (s->fd); s->fd = -1; } DBG (11, "<< do_cancel\n"); return (SANE_STATUS_CANCELLED); } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char devnam[PATH_MAX] = "/dev/scanner"; FILE *fp; authorize = authorize; /* silence gcc */ DBG_INIT (); DBG (11, ">> sane_init\n"); #if defined PACKAGE && defined VERSION DBG (2, "sane_init: " PACKAGE " " VERSION "\n"); #endif if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open(RICOH_CONFIG_FILE); if (fp) { char line[PATH_MAX], *lp; size_t len; /* read config file */ while (sanei_config_read (line, sizeof (line), fp)) { if (line[0] == '#') /* ignore line comments */ continue; len = strlen (line); if (!len) continue; /* ignore empty lines */ /* skip white space: */ for (lp = line; isspace(*lp); ++lp); strcpy (devnam, lp); } fclose (fp); } sanei_config_attach_matching_devices (devnam, attach_one); DBG (11, "<< sane_init\n"); return SANE_STATUS_GOOD; } void sane_exit (void) { Ricoh_Device *dev, *next; DBG (11, ">> sane_exit\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free ((void *) dev->sane.name); free ((void *) dev->sane.model); free (dev); } if (devlist) free (devlist); DBG (11, "<< sane_exit\n"); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Ricoh_Device *dev; int i; local_only = local_only; /* silence gcc */ DBG (11, ">> sane_get_devices\n"); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return (SANE_STATUS_NO_MEM); i = 0; for (dev = first_dev; dev; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (11, "<< sane_get_devices\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devnam, SANE_Handle * handle) { SANE_Status status; Ricoh_Device *dev; Ricoh_Scanner *s; DBG (11, ">> sane_open\n"); if (devnam[0] == '\0') { for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devnam) == 0) break; } if (!dev) { status = attach (devnam, &dev); if (status != SANE_STATUS_GOOD) return (status); } } else { dev = first_dev; } if (!dev) return (SANE_STATUS_INVAL); s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->fd = -1; s->hw = dev; init_options (s); s->next = first_handle; first_handle = s; *handle = s; DBG (11, "<< sane_open\n"); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Ricoh_Scanner *s = (Ricoh_Scanner *) handle; DBG (11, ">> sane_close\n"); if (s->fd != -1) sanei_scsi_close (s->fd); free (s); DBG (11, ">> sane_close\n"); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Ricoh_Scanner *s = handle; DBG (11, ">> sane_get_option_descriptor\n"); if ((unsigned) option >= NUM_OPTIONS) return (0); DBG (11, "<< sane_get_option_descriptor\n"); return (s->opt + option); } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Ricoh_Scanner *s = handle; SANE_Status status; SANE_Word cap; DBG (11, ">> sane_control_option\n"); if (info) *info = 0; if (s->scanning) return (SANE_STATUS_DEVICE_BUSY); if (option >= NUM_OPTIONS) return (SANE_STATUS_INVAL); cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) return (SANE_STATUS_INVAL); if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_BRIGHTNESS: case OPT_CONTRAST: *(SANE_Word *) val = s->val[option].w; return (SANE_STATUS_GOOD); /* string options: */ case OPT_MODE: strcpy (val, s->val[option].s); return (SANE_STATUS_GOOD); } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) return (SANE_STATUS_INVAL); status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) return status; switch (option) { /* (mostly) side-effect-free word options: */ case OPT_X_RESOLUTION: case OPT_Y_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: if (info && s->val[option].w != *(SANE_Word *) val) *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_NUM_OPTS: case OPT_BRIGHTNESS: case OPT_CONTRAST: s->val[option].w = *(SANE_Word *) val; return (SANE_STATUS_GOOD); case OPT_MODE: if (info && strcmp (s->val[option].s, (SANE_String) val)) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); return (SANE_STATUS_GOOD); } } DBG (11, "<< sane_control_option\n"); return (SANE_STATUS_INVAL); } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Ricoh_Scanner *s = handle; DBG (11, ">> sane_get_parameters\n"); if (!s->scanning) { int width, length, xres, yres; const char *mode; memset (&s->params, 0, sizeof (s->params)); width = s->val[OPT_BR_X].w - s->val[OPT_TL_X].w; length = s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w; xres = s->val[OPT_X_RESOLUTION].w; yres = s->val[OPT_Y_RESOLUTION].w; /* make best-effort guess at what parameters will look like once scanning starts. */ if (xres > 0 && yres > 0 && width > 0 && length > 0) { s->params.pixels_per_line = width * xres / s->hw->info.mud; s->params.lines = length * yres / s->hw->info.mud; } mode = s->val[OPT_MODE].s; if (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0 || strcmp (mode, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line / 8; /* the Ricoh truncates to the byte boundary, so: chop! */ s->params.pixels_per_line = s->params.bytes_per_line * 8; s->params.depth = 1; } else /* if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) */ { s->params.format = SANE_FRAME_GRAY; s->params.bytes_per_line = s->params.pixels_per_line; s->params.depth = 8; } s->params.last_frame = SANE_TRUE; } if (params) *params = s->params; DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, " "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line, s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w); DBG (11, "<< sane_get_parameters\n"); return (SANE_STATUS_GOOD); } SANE_Status sane_start (SANE_Handle handle) { char *mode_str; Ricoh_Scanner *s = handle; SANE_Status status; struct ricoh_window_data wbuf; struct measurements_units_page mup; DBG (11, ">> sane_start\n"); /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; status = sanei_scsi_open (s->hw->sane.name, &s->fd, 0, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "open of %s failed: %s\n", s->hw->sane.name, sane_strstatus (status)); return (status); } mode_str = s->val[OPT_MODE].s; s->xres = s->val[OPT_X_RESOLUTION].w; s->yres = s->val[OPT_Y_RESOLUTION].w; s->ulx = s->val[OPT_TL_X].w; s->uly = s->val[OPT_TL_Y].w; s->width = s->val[OPT_BR_X].w - s->val[OPT_TL_X].w; s->length = s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w; s->brightness = s->val[OPT_BRIGHTNESS].w; s->contrast = s->val[OPT_CONTRAST].w; s->bpp = s->params.depth; if (strcmp (mode_str, SANE_VALUE_SCAN_MODE_LINEART) == 0) { s->image_composition = RICOH_BINARY_MONOCHROME; } else if (strcmp (mode_str, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) { s->image_composition = RICOH_DITHERED_MONOCHROME; } else if (strcmp (mode_str, SANE_VALUE_SCAN_MODE_GRAY) == 0) { s->image_composition = RICOH_GRAYSCALE; } memset (&wbuf, 0, sizeof (wbuf)); _lto2b(sizeof(wbuf) - 8, wbuf.len); _lto2b(s->xres, wbuf.x_res); _lto2b(s->yres, wbuf.y_res); _lto4b(s->ulx, wbuf.x_org); _lto4b(s->uly, wbuf.y_org); _lto4b(s->width, wbuf.width); _lto4b(s->length, wbuf.length); wbuf.image_comp = s->image_composition; /* if you throw the MRIF bit the brighness control reverses too */ /* so I reverse the reversal in software for symmetry's sake */ if (wbuf.image_comp == RICOH_GRAYSCALE || wbuf.image_comp == RICOH_DITHERED_MONOCHROME) { if (wbuf.image_comp == RICOH_GRAYSCALE) wbuf.mrif_filtering_gamma_id = (SANE_Byte) 0x90; if (wbuf.image_comp == RICOH_DITHERED_MONOCHROME) wbuf.mrif_filtering_gamma_id = (SANE_Byte) 0x10; wbuf.brightness = 256 - (SANE_Byte) s->brightness; if (is50) wbuf.contrast = (SANE_Byte) s->contrast; else wbuf.contrast = 256 - (SANE_Byte) s->contrast; } else /* wbuf.image_comp == RICOH_BINARY_MONOCHROME */ { wbuf.mrif_filtering_gamma_id = (SANE_Byte) 0x00; wbuf.brightness = (SANE_Byte) s->brightness; wbuf.contrast = (SANE_Byte) s->contrast; } wbuf.threshold = 0; wbuf.bits_per_pixel = s->bpp; wbuf.halftone_pattern[0] = 2; wbuf.halftone_pattern[1] = 0; wbuf.pad_type = 3; wbuf.bit_ordering[0] = 0; wbuf.bit_ordering[1] = 3; DBG (5, "xres=%d\n", _2btol(wbuf.x_res)); DBG (5, "yres=%d\n", _2btol(wbuf.y_res)); DBG (5, "ulx=%d\n", _4btol(wbuf.x_org)); DBG (5, "uly=%d\n", _4btol(wbuf.y_org)); DBG (5, "width=%d\n", _4btol(wbuf.width)); DBG (5, "length=%d\n", _4btol(wbuf.length)); DBG (5, "image_comp=%d\n", wbuf.image_comp); DBG (11, "sane_start: sending SET WINDOW\n"); status = set_window (s->fd, &wbuf); if (status != SANE_STATUS_GOOD) { DBG (1, "SET WINDOW failed: %s\n", sane_strstatus (status)); return (status); } DBG (11, "sane_start: sending GET WINDOW\n"); memset (&wbuf, 0, sizeof (wbuf)); status = get_window (s->fd, &wbuf); if (status != SANE_STATUS_GOOD) { DBG (1, "GET WINDOW failed: %s\n", sane_strstatus (status)); return (status); } DBG (5, "xres=%d\n", _2btol(wbuf.x_res)); DBG (5, "yres=%d\n", _2btol(wbuf.y_res)); DBG (5, "ulx=%d\n", _4btol(wbuf.x_org)); DBG (5, "uly=%d\n", _4btol(wbuf.y_org)); DBG (5, "width=%d\n", _4btol(wbuf.width)); DBG (5, "length=%d\n", _4btol(wbuf.length)); DBG (5, "image_comp=%d\n", wbuf.image_comp); DBG (11, "sane_start: sending MODE SELECT\n"); memset (&mup, 0, sizeof (mup)); mup.page_code = MEASUREMENTS_PAGE; mup.parameter_length = 0x06; mup.bmu = INCHES; mup.mud[0] = (DEFAULT_MUD >> 8) & 0xff; mup.mud[1] = (DEFAULT_MUD & 0xff); status = mode_select (s->fd, (struct mode_pages *) &mup); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: MODE_SELECT failed\n"); return (SANE_STATUS_INVAL); } status = trigger_scan (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "start of scan failed: %s\n", sane_strstatus (status)); return (status); } /* Wait for scanner to become ready to transmit data */ status = ricoh_wait_ready (s); if (status != SANE_STATUS_GOOD) { DBG (1, "GET DATA STATUS failed: %s\n", sane_strstatus (status)); return (status); } s->bytes_to_read = s->params.bytes_per_line * s->params.lines; DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, " "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line, s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w); s->scanning = SANE_TRUE; DBG (11, "<< sane_start\n"); return (SANE_STATUS_GOOD); } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { Ricoh_Scanner *s = handle; SANE_Status status; size_t nread; DBG (11, ">> sane_read\n"); *len = 0; DBG (11, "sane_read: bytes left to read: %ld\n", (u_long) s->bytes_to_read); if (s->bytes_to_read == 0) { do_cancel (s); return (SANE_STATUS_EOF); } if (!s->scanning) { DBG (11, "sane_read: scanning is false!\n"); return (do_cancel (s)); } nread = max_len; if (nread > s->bytes_to_read) nread = s->bytes_to_read; DBG (11, "sane_read: read %ld bytes\n", (u_long) nread); status = read_data (s->fd, buf, &nread); if (status != SANE_STATUS_GOOD) { DBG (11, "sane_read: read error\n"); do_cancel (s); return (SANE_STATUS_IO_ERROR); } *len = nread; s->bytes_to_read -= nread; DBG (11, "<< sane_read\n"); return (SANE_STATUS_GOOD); } void sane_cancel (SANE_Handle handle) { Ricoh_Scanner *s = handle; DBG (11, ">> sane_cancel\n"); s->scanning = SANE_FALSE; DBG (11, "<< sane_cancel\n"); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { handle = handle; /* silence gcc */ non_blocking = non_blocking; /* silence gcc */ DBG (5, ">> sane_set_io_mode\n"); DBG (5, "<< sane_set_io_mode\n"); return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { handle = handle; /* silence gcc */ fd = fd; /* silence gcc */ DBG (5, ">> sane_get_select_fd\n"); DBG (5, "<< sane_get_select_fd\n"); return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/epson2-ops.h0000666000000000000000000000470713615534521014756 00000000000000/* * epson2.c - SANE library for Epson scanners. * * Based on Kazuhiro Sasayama previous * Work on epson.[ch] file from the SANE package. * Please see those files for additional copyrights. * * Copyright (C) 2006-07 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. */ /* some defines to make handling the TPU easier */ #define FILM_TYPE_NEGATIVE (1L << 0) #define FILM_TYPE_SLIDE (1L << 1) #define e2_model(s,m) e2_dev_model((s)->hw,(m)) extern int sanei_scsi_max_request_size; extern int *gamma_params; extern void e2_dev_init(Epson_Device *dev, const char *devname, int conntype); extern SANE_Status e2_dev_post_init(struct Epson_Device *dev); extern SANE_Bool e2_dev_model(Epson_Device *dev, const char *model); extern void e2_set_cmd_level(SANE_Handle handle, unsigned char *level); extern SANE_Status e2_set_model(Epson_Scanner *s, unsigned char *model, size_t len); extern SANE_Status e2_add_resolution(Epson_Device *dev, int r); extern void e2_set_fbf_area(Epson_Scanner *s, int x, int y, int unit); extern void e2_set_adf_area(struct Epson_Scanner *s, int x, int y, int unit); extern void e2_set_tpu_area(struct Epson_Scanner *s, int x, int y, int unit); extern void e2_set_tpu2_area(struct Epson_Scanner *s, int x, int y, int unit); extern void e2_add_depth(Epson_Device *dev, SANE_Word depth); extern SANE_Status e2_discover_capabilities(Epson_Scanner *s); extern SANE_Status e2_set_extended_scanning_parameters(Epson_Scanner *s); extern SANE_Status e2_set_scanning_parameters(Epson_Scanner *s); extern void e2_setup_block_mode(Epson_Scanner *s); extern SANE_Status e2_init_parameters(Epson_Scanner *s); extern void e2_wait_button(Epson_Scanner *s); extern SANE_Status e2_check_warm_up(Epson_Scanner *s, SANE_Bool *wup); extern SANE_Status e2_wait_warm_up(Epson_Scanner *s); extern SANE_Status e2_check_adf(Epson_Scanner *s); extern SANE_Status e2_start_std_scan(Epson_Scanner *s); extern SANE_Status e2_start_ext_scan(Epson_Scanner *s); extern void e2_scan_finish(Epson_Scanner *s); extern void e2_copy_image_data(Epson_Scanner *s, SANE_Byte *data, SANE_Int max_length, SANE_Int *length); extern SANE_Status e2_ext_read(struct Epson_Scanner *s); extern SANE_Status e2_block_read(struct Epson_Scanner *s); sane-backends-1.0.29/backend/agfafocus.h0000666000000000000000000000607613615534521014710 00000000000000/* sane - Scanner Access Now Easy. This file (C) 1997 Ingo Schneider (C) 1998 Karl Anders Øygard This file is part of the SANE package. SANE 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; either version 2 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef agfafocus_h #define agfafocus_h enum AgfaFocus_Scanner_Type { AGFAGRAY64, AGFALINEART, AGFAGRAY256, AGFACOLOR }; typedef enum { LINEART, GRAY6BIT, GRAY8BIT, COLOR18BIT, COLOR24BIT } AgfaFocus_Scanner_Mode; enum AgfaFocus_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_HALFTONE_PATTERN, /* halftone matrix */ OPT_RESOLUTION, OPT_SOURCE, OPT_QUALITY, /* quality calibration */ OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_EXPOSURE, OPT_BRIGHTNESS, OPT_CONTRAST, OPT_AUTO_BRIGHTNESS, OPT_AUTO_CONTRAST, OPT_ATTENUATION_RED, OPT_ATTENUATION_BLUE, OPT_ATTENUATION_GREEN, OPT_SHARPEN, /* sharpening */ /* must come last: */ NUM_OPTIONS }; typedef struct AgfaFocus_Device { struct AgfaFocus_Device *next; SANE_Device sane; SANE_Handle handle; SANE_Word type; SANE_Bool transparent; SANE_Bool analoglog; SANE_Bool tos5; SANE_Bool quality; SANE_Bool disconnect; SANE_Bool upload_user_defines; } AgfaFocus_Device; typedef struct AgfaFocus_Scanner { /* all the state needed to define a scan request: */ SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; /* Parsed option values and variables that are valid only during actual scanning: */ SANE_Bool scanning; SANE_Int pass; SANE_Parameters params; AgfaFocus_Scanner_Mode mode; SANE_Int image_composition; SANE_Int bpp; SANE_Int halftone; SANE_Int original; SANE_Int exposure; SANE_Int r_att; SANE_Int g_att; SANE_Int b_att; SANE_Int tonecurve; SANE_Int quality; SANE_Bool edge; SANE_Bool lin_log; int lines_available; /* Lines in scanner memory */ int fd; /* SCSI filedescriptor */ SANE_Pid reader_pid; /* process id of reader */ int pipe; /* pipe to reader process */ int reader_pipe; /* pipe from reader process */ /* scanner dependent/low-level state: */ AgfaFocus_Device *hw; } AgfaFocus_Scanner; #endif /* agfafocus_h */ sane-backends-1.0.29/backend/dc240.h0000666000000000000000000001620713615534521013563 00000000000000/*************************************************************************** * SANE - Scanner Access Now Easy. dc240.h 03/12/01 - Peter Fales Based on the dc210 driver, (C) 1998 Brian J. Murrell (which is based on dc25 driver (C) 1998 by Peter Fales) This file (C) 2001 by Peter Fales 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. *************************************************************************** This file implements a SANE backend for the Kodak DC-240 digital camera. THIS IS EXTREMELY ALPHA CODE! USE AT YOUR OWN RISK!! (feedback to: dc240-devel@fales-lorenz.net) This backend is based somewhat on the dc25 backend included in this package by Peter Fales, and the dc210 backend by Brian J. Murrell ***************************************************************************/ #include #include #include #include #include #include #ifndef TRUE #define TRUE (1==1) #endif #ifndef FALSE #define FALSE (!TRUE) #endif #ifndef NULL #define NULL 0L #endif typedef struct picture_info { int low_res; int size; } PictureInfo; typedef struct DC240_s { SANE_Int fd; /* file descriptor to talk to it */ char *tty_name; /* the tty port name it's on */ speed_t baud; /* current tty speed */ SANE_Bool scanning; /* currently scanning an image? */ SANE_Byte model; SANE_Byte ver_major; SANE_Byte ver_minor; SANE_Int pic_taken; SANE_Int pic_left; struct { unsigned int low_res:1; unsigned int low_batt:1; } flags; PictureInfo *Pictures; /* array of pictures */ SANE_Int current_picture_number; /* picture being operated on */ } DC240; typedef struct dc240_info_s { SANE_Byte model; SANE_Byte ver_major; SANE_Byte ver_minor; SANE_Int pic_taken; SANE_Int pic_left; struct { SANE_Int low_res:1; SANE_Int low_batt:1; } flags; } Dc240Info, *Dc240InfoPtr; static SANE_Int get_info (DC240 *); #define INIT_PCK {0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} /* ^^^^^^^^^^ * Baud rate: (see pkt_speed structure) * 0x96 0x00 -> 9600 baud * 0x19 0x20 -> 19200 baud * 0x38 0x40 -> 38400 baud * 0x57 0x60 -> 57600 baud * 0x11 0x52 -> 115200 baud */ #define INFO_PCK {0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} #define SHOOT_PCK {0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} #define ERASE_PCK {0x9D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} #define RES_PCK {0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} /* ^^^^ * Resolution: 0x00 = low, 0x01 = high */ #define THUMBS_PCK {0x93, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x1A} /* * */ #define PICS_PCK {0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} /* * */ #define PICS_INFO_PCK {0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} /* * */ #define OPEN_CARD_PCK {0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} #define READ_DIR_PCK {0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A} /* ^^^^ * 1=Report number of entries only */ struct pkt_speed { speed_t baud; SANE_Byte pkt_code[2]; }; #if defined (B57600) && defined (B115200) # define SPEEDS { { B9600, { 0x96, 0x00 } }, \ { B19200, { 0x19, 0x20 } }, \ { B38400, { 0x38, 0x40 } }, \ { B57600, { 0x57, 0x60 } }, \ { B115200, { 0x11, 0x52 } } } #else # define SPEEDS { { B9600, { 0x96, 0x00 } }, \ { B19200, { 0x19, 0x20 } }, \ { B38400, { 0x38, 0x40 } } } #endif #define HIGH_RES 0 #define LOW_RES 1 #define HIGHRES_WIDTH 1280 #define HIGHRES_HEIGHT 960 #define LOWRES_WIDTH 640 #define LOWRES_HEIGHT 480 /* * External definitions */ extern char *__progname; /* Defined in /usr/lib/crt0.o */ struct cam_dirent { SANE_Char name[11]; SANE_Byte attr; SANE_Byte create_time[2]; SANE_Byte creat_date[2]; long size; }; #ifdef OLD /* This is the layout of the directory in the camera - Unfortunately, * this only works in gcc. */ struct dir_buf { SANE_Byte entries_msb PACKED; SANE_Byte entries_lsb PACKED; struct cam_dirent entry[1000] PACKED; }; #else /* So, we have to do it the hard way... */ #define CAMDIRENTRYSIZE 20 #define DIRENTRIES 1000 #define get_name(entry) (SANE_Char*) &dir_buf2[2+CAMDIRENTRYSIZE*(entry)] #define get_attr(entry) dir_buf2[2+11+CAMDIRENTRYSIZE*(entry)] #define get_create_time(entry) \ ( dir_buf2[2+12+CAMDIRENTRYSIZE*(entry)] << 8 \ + dir_buf2[2+13+CAMDIRENTRYSIZE*(entry)]) #endif struct cam_dirlist { SANE_Char name[48]; struct cam_dirlist *next; }; #include FILE *sanei_config_open (const char *filename); static SANE_Int init_dc240 (DC240 *); static void close_dc240 (SANE_Int); static SANE_Int read_data (SANE_Int fd, SANE_Byte * buf, SANE_Int sz); static SANE_Int end_of_data (SANE_Int fd); static PictureInfo *get_pictures_info (void); static SANE_Int get_picture_info (PictureInfo * pic, SANE_Int p); static SANE_Status snap_pic (SANE_Int fd); char *sanei_config_read (char *str, int n, FILE * stream); static SANE_Int read_dir (SANE_String dir); static SANE_Int read_info (SANE_String fname); static SANE_Int dir_insert (struct cam_dirent *entry); static SANE_Int dir_delete (SANE_String name); static SANE_Int send_data (SANE_Byte * buf); static void set_res (SANE_Int lowres); sane-backends-1.0.29/backend/escl/0000755000000000000000000000000013615535551013576 500000000000000sane-backends-1.0.29/backend/escl/escl_reset.c0000666000000000000000000000476713615534521016030 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include #include #include /** * \fn void escl_scanner(SANE_String_Const name, char *result) * \brief Function that resets the scanner after each scan, using curl. * This function is called in the 'sane_cancel' function. */ void escl_scanner(SANE_String_Const name, char *result) { CURL *curl_handle = NULL; const char *scan_jobs = "/eSCL/ScanJobs"; const char *scanner_start = "/NextDocument"; char scan_cmd[PATH_MAX] = { 0 }; int i = 0; long answer = 0; if (name == NULL || result == NULL) return; CURL_CALL: curl_handle = curl_easy_init(); if (curl_handle != NULL) { strcpy(scan_cmd, name); strcat(scan_cmd, scan_jobs); strcat(scan_cmd, result); strcat(scan_cmd, scanner_start); curl_easy_setopt(curl_handle, CURLOPT_URL, scan_cmd); DBG( 1, "Reset Job : %s.\n", scan_cmd); if (strncmp(name, "https", 5) == 0) { DBG( 1, "Ignoring safety certificates, use https\n"); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); } if (curl_easy_perform(curl_handle) == CURLE_OK) { curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &answer); if (i < 3 && answer == 503) { curl_easy_cleanup(curl_handle); i++; goto CURL_CALL; } } curl_easy_cleanup(curl_handle); } } sane-backends-1.0.29/backend/escl/escl_devices.c0000666000000000000000000001603613615534521016320 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include #include #include #include #include #include #include #include "../include/sane/sanei.h" static AvahiSimplePoll *simple_poll = NULL; /** * \fn static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED * AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol, * AvahiResolverEvent event, const char *name, * const char *type, const char *domain, const char *host_name, * const AvahiAddress *address, uint16_t port, * AvahiStringList *txt, AvahiLookupResultFlags flags, * void *userdata) * \brief Callback function that will check if the selected scanner follows the escl * protocol or not. */ static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIndex interface, AVAHI_GCC_UNUSED AvahiProtocol protocol, AvahiResolverEvent event, const char *name, const char __sane_unused__ *type, const char __sane_unused__ *domain, const char __sane_unused__ *host_name, const AvahiAddress *address, uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags __sane_unused__ flags, void __sane_unused__ *userdata) { char a[AVAHI_ADDRESS_STR_MAX], *t; assert(r); switch (event) { case AVAHI_RESOLVER_FAILURE: break; case AVAHI_RESOLVER_FOUND: avahi_address_snprint(a, sizeof(a), address); t = avahi_string_list_to_string(txt); if (strstr(t, "\"rs=eSCL\"") || strstr(t, "\"rs=/eSCL\"")) escl_device_add(port, name, a, (char*)type); } } /** * \fn static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, * AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, * const char *type, const char *domain, * AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) * \brief Callback function that will browse tanks to 'avahi' the scanners * connected in network. */ static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AVAHI_GCC_UNUSED AvahiLookupResultFlags flags, void* userdata) { AvahiClient *c = userdata; assert(b); switch (event) { case AVAHI_BROWSER_FAILURE: avahi_simple_poll_quit(simple_poll); return; case AVAHI_BROWSER_NEW: if (!(avahi_service_resolver_new(c, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, c))) break; case AVAHI_BROWSER_REMOVE: break; case AVAHI_BROWSER_ALL_FOR_NOW: case AVAHI_BROWSER_CACHE_EXHAUSTED: if (event != AVAHI_BROWSER_CACHE_EXHAUSTED) avahi_simple_poll_quit(simple_poll); break; } } /** * \fn static void client_callback(AvahiClient *c, AvahiClientState state, * AVAHI_GCC_UNUSED void *userdata) * \brief Callback Function that quit if it doesn't find a connected scanner, * possible thanks the "Hello Protocol". * --> Waiting for a answer by the scanner to continue the avahi process. */ static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void *userdata) { assert(c); if (state == AVAHI_CLIENT_FAILURE) avahi_simple_poll_quit(simple_poll); } /** * \fn ESCL_Device *escl_devices(SANE_Status *status) * \brief Function that calls all the avahi functions and then, recovers the * connected eSCL devices. * This function is called in the 'sane_get_devices' function. * * \return NULL (the eSCL devices found) */ ESCL_Device * escl_devices(SANE_Status *status) { AvahiClient *client = NULL; AvahiServiceBrowser *sb = NULL; int error; *status = SANE_STATUS_GOOD; if (!(simple_poll = avahi_simple_poll_new())) { DBG( 1, "Failed to create simple poll object.\n"); *status = SANE_STATUS_INVAL; goto fail; } client = avahi_client_new(avahi_simple_poll_get(simple_poll), 0, client_callback, NULL, &error); if (!client) { DBG( 1, "Failed to create client: %s\n", avahi_strerror(error)); *status = SANE_STATUS_INVAL; goto fail; } if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_uscan._tcp", NULL, 0, browse_callback, client))) { DBG( 1, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client))); *status = SANE_STATUS_INVAL; goto fail; } if (!(sb = avahi_service_browser_new(client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_uscans._tcp", NULL, 0, browse_callback, client))) { DBG( 1, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client))); *status = SANE_STATUS_INVAL; goto fail; } avahi_simple_poll_loop(simple_poll); fail: if (sb) avahi_service_browser_free(sb); if (client) avahi_client_free(client); if (simple_poll) avahi_simple_poll_free(simple_poll); return (NULL); } sane-backends-1.0.29/backend/escl/escl_status.c0000666000000000000000000001267413615534521016225 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include #include #include #include #include struct idle { char *memory; size_t size; }; /** * \fn static size_t memory_callback_s(void *contents, size_t size, size_t nmemb, void *userp) * \brief Callback function that stocks in memory the content of the scanner status. * * \return realsize (size of the content needed -> the scanner status) */ static size_t memory_callback_s(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct idle *mem = (struct idle *)userp; char *str = realloc(mem->memory, mem->size + realsize + 1); if (str == NULL) { DBG(1, "not enough memory (realloc returned NULL)\n"); return (0); } mem->memory = str; memcpy(&(mem->memory[mem->size]), contents, realsize); mem->size = mem->size + realsize; mem->memory[mem->size] = 0; return (realsize); } /** * \fn static int find_nodes_s(xmlNode *node) * \brief Function that browses the xml file and parses it, to find the xml children node. * --> to recover the scanner status. * * \return 0 if a xml child node is found, 1 otherwise */ static int find_nodes_s(xmlNode *node) { xmlNode *child = node->children; while (child) { if (child->type == XML_ELEMENT_NODE) return (0); child = child->next; } return (1); } /** * \fn static void print_xml_s(xmlNode *node, SANE_Status *status) * \brief Function that browses the xml file, node by node. * If the node 'State' is found, we are expecting to found in this node the 'Idle' * content (if the scanner is ready to use) and then 'status' = SANE_STATUS_GOOD. * Otherwise, this means that the scanner isn't ready to use. */ static void print_xml_s(xmlNode *node, SANE_Status *status) { int x = 0; while (node) { if (node->type == XML_ELEMENT_NODE) { if (find_nodes_s(node)) { if (strcmp((const char *)node->name, "State") == 0) x = 1; } if (x == 1 && strcmp((const char *)xmlNodeGetContent(node), "Idle") == 0) *status = SANE_STATUS_GOOD; } print_xml_s(node->children, status); node = node->next; } } /** * \fn SANE_Status escl_status(SANE_String_Const name) * \brief Function that finally recovers the scanner status ('Idle', or not), using curl. * This function is called in the 'sane_open' function and it's the equivalent of * the following curl command : "curl http(s)://'ip':'port'/eSCL/ScannerStatus". * * \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status escl_status(SANE_String_Const name) { SANE_Status status; CURL *curl_handle = NULL; struct idle *var = NULL; xmlDoc *data = NULL; xmlNode *node = NULL; const char *scanner_status = "/eSCL/ScannerStatus"; char tmp[PATH_MAX] = { 0 }; if (name == NULL) return (SANE_STATUS_NO_MEM); var = (struct idle*)calloc(1, sizeof(struct idle)); if (var == NULL) return (SANE_STATUS_NO_MEM); var->memory = malloc(1); var->size = 0; curl_handle = curl_easy_init(); strcpy(tmp, name); strcat(tmp, scanner_status); curl_easy_setopt(curl_handle, CURLOPT_URL, tmp); DBG( 1, "Get Status : %s.\n", tmp); if (strncmp(name, "https", 5) == 0) { DBG( 1, "Ignoring safety certificates, use https\n"); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); } curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, memory_callback_s); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)var); if (curl_easy_perform(curl_handle) != CURLE_OK) { DBG( 1, "The scanner didn't respond.\n"); status = SANE_STATUS_INVAL; goto clean_data; } data = xmlReadMemory(var->memory, var->size, "file.xml", NULL, 0); if (data == NULL) { status = SANE_STATUS_NO_MEM; goto clean_data; } node = xmlDocGetRootElement(data); if (node == NULL) { status = SANE_STATUS_NO_MEM; goto clean; } status = SANE_STATUS_DEVICE_BUSY; print_xml_s(node, &status); clean: xmlFreeDoc(data); clean_data: xmlCleanupParser(); xmlMemoryDump(); curl_easy_cleanup(curl_handle); free(var->memory); free(var); return (status); } sane-backends-1.0.29/backend/escl/escl_png.c0000666000000000000000000001362213615534521015460 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include "../include/sane/sanei.h" #include #include #include #if(defined HAVE_LIBPNG) #include #endif #include #if(defined HAVE_LIBPNG) /** * \fn SANE_Status escl_sane_decompressor(escl_sane_t *handler) * \brief Function that aims to decompress the png image to SANE be able to read the image. * This function is called in the "sane_read" function. * * \return SANE_STATUS_GOOD (if everything is OK, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status get_PNG_data(capabilities_t *scanner, int *w, int *h, int *components) { unsigned int width = 0; /* largeur */ unsigned int height = 0; /* hauteur */ int bps = 3; /* composantes d'un texel */ unsigned char *texels = NULL; /* données de l'image */ unsigned int i = 0; png_byte magic[8]; // read magic number fread (magic, 1, sizeof (magic), scanner->tmp); // check for valid magic number if (!png_check_sig (magic, sizeof (magic))) { DBG( 1, "Escl Png : PNG error is not a valid PNG image!\n"); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_INVAL); } // create a png read struct png_structp png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { DBG( 1, "Escl Png : PNG error create a png read struct\n"); if (scanner->tmp) if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_INVAL); } // create a png info struct png_infop info_ptr = png_create_info_struct (png_ptr); if (!info_ptr) { DBG( 1, "Escl Png : PNG error create a png info struct\n"); png_destroy_read_struct (&png_ptr, NULL, NULL); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_INVAL); } // initialize the setjmp for returning properly after a libpng // error occured if (setjmp (png_jmpbuf (png_ptr))) { png_destroy_read_struct (&png_ptr, &info_ptr, NULL); if (texels) free (texels); fprintf(stderr,"PNG read error.\n"); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } DBG( 1, "Escl Png : PNG read error.\n"); return (SANE_STATUS_INVAL); } // setup libpng for using standard C fread() function // with our FILE pointer png_init_io (png_ptr, scanner->tmp); // tell libpng that we have already read the magic number png_set_sig_bytes (png_ptr, sizeof (magic)); // read png info png_read_info (png_ptr, info_ptr); int bit_depth, color_type; // get some usefull information from header bit_depth = png_get_bit_depth (png_ptr, info_ptr); color_type = png_get_color_type (png_ptr, info_ptr); // convert index color images to RGB images if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb (png_ptr); else if (color_type != PNG_COLOR_TYPE_RGB && color_type != PNG_COLOR_TYPE_RGB_ALPHA) { fprintf(stderr,"PNG format not supported.\n"); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_INVAL); } if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) bps = 4; else bps = 3; if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha (png_ptr); if (bit_depth == 16) png_set_strip_16 (png_ptr); else if (bit_depth < 8) png_set_packing (png_ptr); // update info structure to apply transformations png_read_update_info (png_ptr, info_ptr); // retrieve updated information png_get_IHDR (png_ptr, info_ptr, (png_uint_32*)(&width), (png_uint_32*)(&height), &bit_depth, &color_type, NULL, NULL, NULL); *w = (int)width; *h = (int)height; *components = bps; // we can now allocate memory for storing pixel data texels = (unsigned char *)malloc (sizeof (unsigned char) * width * height * bps); png_bytep *row_pointers; // setup a pointer array. Each one points at the begening of a row. row_pointers = (png_bytep *)malloc (sizeof (png_bytep) * height); for (i = 0; i < height; ++i) { row_pointers[i] = (png_bytep)(texels + ((height - (i + 1)) * width * bps)); } // read pixel data using row pointers png_read_image (png_ptr, row_pointers); // we don't need row pointers anymore scanner->img_data = texels; scanner->img_size = (int)(width * height * bps); scanner->img_read = 0; free (row_pointers); fclose(scanner->tmp); scanner->tmp = NULL; return (SANE_STATUS_GOOD); } #else SANE_Status get_PNG_data(capabilities_t __sane_unused__ *scanner, int __sane_unused__ *w, int __sane_unused__ *h, int __sane_unused__ *bps) { return (SANE_STATUS_INVAL); } #endif sane-backends-1.0.29/backend/escl/escl_tiff.c0000666000000000000000000000664213615534521015630 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include "../include/sane/sanei.h" #include #include #include #include #if(defined HAVE_TIFFIO_H) #include #endif #include #if(defined HAVE_TIFFIO_H) /** * \fn SANE_Status escl_sane_decompressor(escl_sane_t *handler) * \brief Function that aims to decompress the png image to SANE be able to read the image. * This function is called in the "sane_read" function. * * \return SANE_STATUS_GOOD (if everything is OK, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status get_TIFF_data(capabilities_t *scanner, int *w, int *h, int *components) { TIFF* tif = NULL; uint32 width = 0; /* largeur */ uint32 height = 0; /* hauteur */ unsigned char *raster = NULL; /* données de l'image */ int bps = 4; uint32 npixels = 0; lseek(fileno(scanner->tmp), 0, SEEK_SET); tif = TIFFFdOpen(fileno(scanner->tmp), "temp", "r"); if (!tif) { DBG( 1, "Escl Tiff : Can not open, or not a TIFF file.\n"); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_INVAL); } TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); npixels = width * height; raster = (unsigned char*) malloc(npixels * sizeof (uint32)); if (raster != NULL) { DBG( 1, "Escl Tiff : Memory allocation problem.\n"); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_INVAL); } if (!TIFFReadRGBAImage(tif, width, height, (uint32 *)raster, 0)) { DBG( 1, "Escl Tiff : Problem reading image data.\n"); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_INVAL); } *w = (int)width; *h = (int)height; *components = bps; // we don't need row pointers anymore scanner->img_data = raster; scanner->img_size = (int)(width * height * bps); scanner->img_read = 0; TIFFClose(tif); fclose(scanner->tmp); scanner->tmp = NULL; return (SANE_STATUS_GOOD); } #else SANE_Status get_TIFF_data(capabilities_t __sane_unused__ *scanner, int __sane_unused__ *w, int __sane_unused__ *h, int __sane_unused__ *bps) { return (SANE_STATUS_INVAL); } #endif sane-backends-1.0.29/backend/escl/escl.c0000666000000000000000000006762713615534521014632 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #include "escl.h" #include #include #include #include #include #include "../include/sane/saneopts.h" #include "../include/sane/sanei.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #define min(A,B) (((A)<(B)) ? (A) : (B)) #define max(A,B) (((A)>(B)) ? (A) : (B)) #define INPUT_BUFFER_SIZE 4096 static const SANE_Device **devlist = NULL; static ESCL_Device *list_devices_primary = NULL; static int num_devices = 0; typedef struct Handled { struct Handled *next; SANE_String_Const name; char *result; ESCL_ScanParam param; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; capabilities_t *scanner; SANE_Range x_range; SANE_Range y_range; SANE_Bool cancel; SANE_Bool write_scan_data; SANE_Bool decompress_scan_data; SANE_Bool end_read; SANE_Parameters ps; } escl_sane_t; /** * \fn static SANE_Status escl_add_in_list(ESCL_Device *current) * \brief Function that adds all the element needed to my list : * the port number, the model name, the ip address, and the type of url (http/https). * Moreover, this function counts the number of devices found. * * \return SANE_STATUS_GOOD if everything is OK. */ static SANE_Status escl_add_in_list(ESCL_Device *current) { ++num_devices; current->next = list_devices_primary; list_devices_primary = current; return (SANE_STATUS_GOOD); } /** * \fn SANE_Status escl_device_add(int port_nb, const char *model_name, char *ip_address, char *type) * \brief Function that browses my list ('for' loop) and returns the "escl_add_in_list" function to * adds all the element needed to my list : * the port number, the model name, the ip address and the type of the url (http / https). * * \return escl_add_in_list(current) */ SANE_Status escl_device_add(int port_nb, const char *model_name, char *ip_address, char *type) { ESCL_Device *current = NULL; DBG (10, "escl_device_add\n"); for (current = list_devices_primary; current; current = current->next) { if (strcmp(current->ip_address, ip_address) == 0 && current->port_nb == port_nb && strcmp(current->type, type) == 0) return (SANE_STATUS_GOOD); } current = malloc(sizeof(*current)); if (current == NULL) return (SANE_STATUS_NO_MEM); memset(current, 0, sizeof(*current)); current->port_nb = port_nb; current->model_name = strdup(model_name); current->ip_address = strdup(ip_address); current->type = strdup(type); return escl_add_in_list(current); } /** * \fn static inline size_t max_string_size(const SANE_String_Const strings[]) * \brief Function that browses the string ('for' loop) and counts the number of character in the string. * --> this allows to know the maximum size of the string. * * \return max_size + 1 (the size max) */ static inline size_t max_string_size(const SANE_String_Const strings[]) { size_t max_size = 0; int i = 0; for (i = 0; strings[i]; ++i) { size_t size = strlen (strings[i]); if (size > max_size) max_size = size; } return (max_size + 1); } /** * \fn static SANE_Device *convertFromESCLDev(ESCL_Device *cdev) * \brief Function that checks if the url of the received scanner is secured or not (http / https). * --> if the url is not secured, our own url will be composed like "http://'ip':'port'". * --> else, our own url will be composed like "https://'ip':'port'". * AND, it's in this function that we gather all the informations of the url (that were in our list) : * the model_name, the port, the ip, and the type of url. * SO, leaving this function, we have in memory the complete url. * * \return sdev (structure that contains the elements of the url) */ static SANE_Device * convertFromESCLDev(ESCL_Device *cdev) { SANE_Device *sdev = (SANE_Device*) calloc(1, sizeof(SANE_Device)); char tmp[PATH_MAX] = { 0 }; if (strcmp(cdev->type, "_uscan._tcp") == 0 || strcmp(cdev->type, "http") == 0) snprintf(tmp, sizeof(tmp), "http://%s:%d", cdev->ip_address, cdev->port_nb); else snprintf(tmp, sizeof(tmp), "https://%s:%d", cdev->ip_address, cdev->port_nb); DBG( 1, "Escl add device : %s\n", tmp); sdev->name = strdup(tmp); sdev->model = strdup(cdev->model_name); sdev->vendor = strdup("ESCL"); sdev->type = strdup("flatbed scanner"); return (sdev); } /** * \fn SANE_Status sane_init(SANE_Int *version_code, SANE_Auth_Callback authorize) * \brief Function that's called before any other SANE function ; it's the first SANE function called. * --> this function checks the SANE config. and can check the authentication of the user if * 'authorize' value is more than SANE_TRUE. * In this case, it will be necessary to define an authentication method. * * \return SANE_STATUS_GOOD (everything is OK) */ SANE_Status sane_init(SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize) { DBG_INIT(); DBG (10, "escl sane_init\n"); SANE_Status status = SANE_STATUS_GOOD; curl_global_init(CURL_GLOBAL_ALL); if (version_code != NULL) *version_code = SANE_VERSION_CODE(1, 0, 0); if (status != SANE_STATUS_GOOD) return (status); return (SANE_STATUS_GOOD); } /** * \fn void sane_exit(void) * \brief Function that must be called to terminate use of a backend. * This function will first close all device handles that still might be open. * --> by freeing all the elements of my list. * After this function, no function other than 'sane_init' may be called. */ void sane_exit(void) { DBG (10, "escl sane_exit\n"); ESCL_Device *next = NULL; while (list_devices_primary != NULL) { next = list_devices_primary->next; free(list_devices_primary); list_devices_primary = next; } if (devlist) free (devlist); list_devices_primary = NULL; devlist = NULL; curl_global_cleanup(); } /** * \fn static SANE_Status attach_one_config(SANEI_Config *config, const char *line) * \brief Function that implements a configuration file to the user : * if the user can't detect some devices, he will be able to force their detection with this config' file to use them. * Thus, this function parses the config' file to use the device of the user with the information below : * the type of protocol (http/https), the ip, the port number, and the model name. * * \return escl_add_in_list(escl_device) if the parsing worked, SANE_STATUS_GOOD otherwise. */ static SANE_Status attach_one_config(SANEI_Config __sane_unused__ *config, const char *line) { int port = 0; static int count = 0; static ESCL_Device *escl_device = NULL; if (strncmp(line, "[device]", 8) == 0) { count = 0; escl_device = (ESCL_Device*)calloc(1, sizeof(ESCL_Device)); } if (strncmp(line, "ip", 2) == 0) { const char *ip_space = sanei_config_skip_whitespace(line + 2); if (escl_device != NULL && ip_space != NULL) { count++; escl_device->ip_address = strdup(ip_space); } } if (sscanf(line, "port %i", &port) == 1 && port != 0) { const char *port_space = sanei_config_skip_whitespace(line + 4); if (escl_device != NULL && port_space != NULL) { count++; escl_device->port_nb = port; } } if (strncmp(line, "model", 5) == 0) { const char *model_space = sanei_config_skip_whitespace(line + 5); if (escl_device != NULL && model_space != NULL) { count++; escl_device->model_name = strdup(model_space); } } if (strncmp(line, "type", 4) == 0) { const char *type_space = sanei_config_skip_whitespace(line + 4); if (escl_device != NULL && type_space != NULL) { count++; escl_device->type = strdup(type_space); } } if (count == 4) return (escl_add_in_list(escl_device)); return (SANE_STATUS_GOOD); } /** * \fn SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only) * \brief Function that searches for connected devices and places them in our 'device_list'. ('for' loop) * If the attribute 'local_only' is worth SANE_FALSE, we only returns the connected devices locally. * * \return SANE_STATUS_GOOD if devlist != NULL ; SANE_STATUS_NO_MEM otherwise. */ SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool local_only) { if (local_only) /* eSCL is a network-only protocol */ return (device_list ? SANE_STATUS_GOOD : SANE_STATUS_INVAL); DBG (10, "escl sane_get_devices\n"); ESCL_Device *dev = NULL; static const SANE_Device **devlist = 0; SANE_Status status; if (device_list == NULL) return (SANE_STATUS_INVAL); status = sanei_configure_attach(ESCL_CONFIG_FILE, NULL, attach_one_config); if (status != SANE_STATUS_GOOD) return (status); escl_devices(&status); if (status != SANE_STATUS_GOOD) return (status); if (devlist) free(devlist); devlist = (const SANE_Device **) calloc (num_devices + 1, sizeof (devlist[0])); if (devlist == NULL) return (SANE_STATUS_NO_MEM); int i = 0; for (dev = list_devices_primary; i < num_devices; dev = dev->next) { SANE_Device *s_dev = convertFromESCLDev(dev); devlist[i] = s_dev; i++; } devlist[i] = 0; *device_list = devlist; return (devlist) ? SANE_STATUS_GOOD : SANE_STATUS_NO_MEM; } /** * \fn static SANE_Status init_options(SANE_String_Const name, escl_sane_t *s) * \brief Function thzt initializes all the needed options of the received scanner * (the resolution / the color / the margins) thanks to the informations received with * the 'escl_capabilities' function, called just before. * * \return status (if everything is OK, status = SANE_STATUS_GOOD) */ static SANE_Status init_options(SANE_String_Const name, escl_sane_t *s) { DBG (10, "escl init_options\n"); SANE_Status status = SANE_STATUS_GOOD; int i = 0; if (name == NULL) return (SANE_STATUS_INVAL); memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->x_range.min = 0; s->x_range.max = s->scanner->MaxWidth - s->scanner->MinWidth; s->x_range.quant = 1; s->y_range.min = 0; s->y_range.max = s->scanner->MaxHeight - s->scanner->MinHeight; s->y_range.quant = 1; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; s->opt[OPT_MODE_GROUP].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].unit = SANE_UNIT_NONE; s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = s->scanner->ColorModes; s->val[OPT_MODE].s = (char *)strdup(s->scanner->ColorModes[0]); s->opt[OPT_MODE].size = max_string_size(s->scanner->ColorModes); s->scanner->default_color = (char *)strdup(s->scanner->ColorModes[0]); s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_RESOLUTION].constraint.word_list = s->scanner->SupportedResolutions; s->val[OPT_RESOLUTION].w = s->scanner->SupportedResolutions[1]; s->scanner->default_resolution = s->scanner->SupportedResolutions[1]; s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_PREVIEW].w = SANE_FALSE; s->opt[OPT_GRAY_PREVIEW].name = SANE_NAME_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].title = SANE_TITLE_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].desc = SANE_DESC_GRAY_PREVIEW; s->opt[OPT_GRAY_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_GRAY_PREVIEW].w = SANE_FALSE; s->opt[OPT_GEOMETRY_GROUP].title = SANE_TITLE_GEOMETRY; s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_PIXEL; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->x_range; s->val[OPT_TL_X].w = s->scanner->RiskyLeftMargin; s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_PIXEL; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->y_range; s->val[OPT_TL_Y].w = s->scanner->RiskyTopMargin; s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_PIXEL; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->x_range; s->val[OPT_BR_X].w = s->scanner->MaxWidth; s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_PIXEL; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->y_range; s->val[OPT_BR_Y].w = s->scanner->MaxHeight; return (status); } /** * \fn SANE_Status sane_open(SANE_String_Const name, SANE_Handle *h) * \brief Function that establishes a connection with the device named by 'name', * and returns a 'handler' using 'SANE_Handle *h', representing it. * Thus, it's this function that calls the 'escl_status' function firstly, * then the 'escl_capabilities' function, and, after, the 'init_options' function. * * \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status sane_open(SANE_String_Const name, SANE_Handle *h) { DBG (10, "escl sane_open\n"); SANE_Status status; escl_sane_t *handler = NULL; if (name == NULL) return (SANE_STATUS_INVAL); status = escl_status(name); if (status != SANE_STATUS_GOOD) return (status); handler = (escl_sane_t *)calloc(1, sizeof(escl_sane_t)); if (handler == NULL) return (SANE_STATUS_NO_MEM); handler->name = strdup(name); handler->scanner = escl_capabilities(name, &status); if (status != SANE_STATUS_GOOD) return (status); status = init_options(name, handler); if (status != SANE_STATUS_GOOD) return (status); handler->ps.depth = 8; handler->ps.last_frame = SANE_TRUE; handler->ps.format = SANE_FRAME_RGB; handler->ps.pixels_per_line = handler->val[OPT_BR_X].w; handler->ps.lines = handler->val[OPT_BR_Y].w; handler->ps.bytes_per_line = handler->ps.pixels_per_line * 3; status = sane_get_parameters(handler, 0); if (status != SANE_STATUS_GOOD) return (status); handler->cancel = SANE_FALSE; handler->write_scan_data = SANE_FALSE; handler->decompress_scan_data = SANE_FALSE; handler->end_read = SANE_FALSE; *h = handler; return (status); } /** * \fn void sane_cancel(SANE_Handle h) * \brief Function that's used to, immediately or as quickly as possible, cancel the currently * pending operation of the device represented by 'SANE_Handle h'. * This functions calls the 'escl_scanner' functions, that resets the scan operations. */ void sane_cancel(SANE_Handle h) { DBG (10, "escl sane_cancel\n"); escl_sane_t *handler = h; if (handler->scanner->tmp) { fclose(handler->scanner->tmp); handler->scanner->tmp = NULL; } handler->cancel = SANE_TRUE; escl_scanner(handler->name, handler->result); } /** * \fn void sane_close(SANE_Handle h) * \brief Function that closes the communication with the device represented by 'SANE_Handle h'. * This function must release the resources that were allocated to the opening of 'h'. */ void sane_close(SANE_Handle h) { DBG (10, "escl sane_close\n"); if (h != NULL) { free(h); h = NULL; } } /** * \fn const SANE_Option_Descriptor *sane_get_option_descriptor(SANE_Handle h, SANE_Int n) * \brief Function that retrieves a descriptor from the n number option of the scanner * represented by 'h'. * The descriptor remains valid until the machine is closed. * * \return s->opt + n */ const SANE_Option_Descriptor * sane_get_option_descriptor(SANE_Handle h, SANE_Int n) { DBG (10, "escl sane_get_option_descriptor\n"); escl_sane_t *s = h; if ((unsigned) n >= NUM_OPTIONS || n < 0) return (0); return (s->opt + n); } /** * \fn SANE_Status sane_control_option(SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int *i) * \brief Function that defines the actions to perform for the 'n' option of the machine, * represented by 'h', if the action is 'a'. * There are 3 types of possible actions : * --> SANE_ACTION_GET_VALUE: 'v' must be used to provide the value of the option. * --> SANE_ACTION_SET_VALUE: The option must take the 'v' value. * --> SANE_ACTION_SET_AUTO: The backend or machine must affect the option with an appropriate value. * Moreover, the parameter 'i' is used to provide additional information about the state of * 'n' option if SANE_ACTION_SET_VALUE has been performed. * * \return SANE_STATUS_GOOD if everything is OK, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL */ SANE_Status sane_control_option(SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int *i) { DBG (10, "escl sane_control_option\n"); escl_sane_t *handler = h; if (i) *i = 0; if (n >= NUM_OPTIONS || n < 0) return (SANE_STATUS_INVAL); if (a == SANE_ACTION_GET_VALUE) { switch (n) { case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_PREVIEW: case OPT_GRAY_PREVIEW: *(SANE_Word *) v = handler->val[n].w; break; case OPT_MODE: strcpy (v, handler->val[n].s); break; case OPT_MODE_GROUP: default: break; } return (SANE_STATUS_GOOD); } if (a == SANE_ACTION_SET_VALUE) { switch (n) { case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_PREVIEW: case OPT_GRAY_PREVIEW: handler->val[n].w = *(SANE_Word *) v; if (i && handler->val[n].w != *(SANE_Word *) v) *i |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS | SANE_INFO_INEXACT; handler->val[n].w = *(SANE_Word *) v; break; case OPT_RESOLUTION: handler->val[n].w = *(SANE_Word *) v; if (i) *i |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS | SANE_INFO_INEXACT; break; case OPT_MODE: if (handler->val[n].s) free (handler->val[n].s); handler->val[n].s = strdup (v); if (i) *i |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS | SANE_INFO_INEXACT; break; default: break; } } return (SANE_STATUS_GOOD); } /** * \fn SANE_Status sane_start(SANE_Handle h) * \brief Function that initiates aquisition of an image from the device represented by handle 'h'. * This function calls the "escl_newjob" function and the "escl_scan" function. * * \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status sane_start(SANE_Handle h) { DBG (10, "escl sane_start\n"); SANE_Status status = SANE_STATUS_GOOD; escl_sane_t *handler = h; int w = 0; int he = 0; int bps = 0; if (handler->name == NULL) return (SANE_STATUS_INVAL); handler->cancel = SANE_FALSE; handler->write_scan_data = SANE_FALSE; handler->decompress_scan_data = SANE_FALSE; handler->end_read = SANE_FALSE; handler->scanner->height = handler->val[OPT_BR_Y].w; handler->scanner->width = handler->val[OPT_BR_X].w; handler->scanner->pos_x = handler->val[OPT_TL_X].w; handler->scanner->pos_y = handler->val[OPT_TL_Y].w; if(handler->scanner->default_color) free(handler->scanner->default_color); if (handler->val[OPT_PREVIEW].w == SANE_TRUE) { int i = 0, val = 9999;; if (handler->val[OPT_GRAY_PREVIEW].w == SANE_TRUE || !strncasecmp(handler->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY, 3)) handler->scanner->default_color = strdup("Grayscale8"); else handler->scanner->default_color = strdup("RGB24"); for (i = 1; i < handler->scanner->SupportedResolutionsSize; i++) { if (val > handler->scanner->SupportedResolutions[i]) val = handler->scanner->SupportedResolutions[i]; } handler->scanner->default_resolution = val; } else { handler->scanner->default_resolution = handler->val[OPT_RESOLUTION].w; if (!strncasecmp(handler->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY, 3)) handler->scanner->default_color = strdup("Grayscale8"); else handler->scanner->default_color = strdup("RGB24"); } handler->result = escl_newjob(handler->scanner, handler->name, &status); if (status != SANE_STATUS_GOOD) return (status); status = escl_scan(handler->scanner, handler->name, handler->result); if (status != SANE_STATUS_GOOD) return (status); if (!strcmp(handler->scanner->default_format, "image/jpeg")) { status = get_JPEG_data(handler->scanner, &w, &he, &bps); } else if (!strcmp(handler->scanner->default_format, "image/png")) { status = get_PNG_data(handler->scanner, &w, &he, &bps); } else if (!strcmp(handler->scanner->default_format, "image/tiff")) { status = get_TIFF_data(handler->scanner, &w, &he, &bps); } else return SANE_STATUS_INVAL; if (status != SANE_STATUS_GOOD) return (status); handler->ps.depth = 8; handler->ps.pixels_per_line = w; handler->ps.lines = he; handler->ps.bytes_per_line = w * bps; handler->ps.last_frame = SANE_TRUE; handler->ps.format = SANE_FRAME_RGB; return (status); } /** * \fn SANE_Status sane_get_parameters(SANE_Handle h, SANE_Parameters *p) * \brief Function that retrieves the device parameters represented by 'h' and stores them in 'p'. * This function is normally used after "sane_start". * It's in this function that we choose to assign the default color. (Color or Monochrome) * * \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status sane_get_parameters(SANE_Handle h, SANE_Parameters *p) { DBG (10, "escl sane_get_parameters\n"); SANE_Status status = SANE_STATUS_GOOD; escl_sane_t *handler = h; if (status != SANE_STATUS_GOOD) return (status); if (p != NULL) { p->depth = 8; p->last_frame = SANE_TRUE; p->format = SANE_FRAME_RGB; p->pixels_per_line = handler->ps.pixels_per_line; p->lines = handler->ps.lines; p->bytes_per_line = handler->ps.bytes_per_line; } return (status); } /** * \fn SANE_Status sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *len) * \brief Function that's used to read image data from the device represented by handle 'h'. * The argument 'buf' is a pointer to a memory area that is at least 'maxlen' bytes long. * The number of bytes returned is stored in '*len'. * --> When the call succeeds, the number of bytes returned can be anywhere in the range from 0 to 'maxlen' bytes. * * \return SANE_STATUS_GOOD (if everything is OK, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *len) { DBG (10, "escl sane_read\n"); escl_sane_t *handler = h; SANE_Status status = SANE_STATUS_GOOD; long readbyte; if (!handler | !buf | !len) return (SANE_STATUS_INVAL); if (handler->cancel) return (SANE_STATUS_CANCELLED); if (!handler->write_scan_data) handler->write_scan_data = SANE_TRUE; if (!handler->decompress_scan_data) { if (status != SANE_STATUS_GOOD) return (status); handler->decompress_scan_data = SANE_TRUE; } if (handler->scanner->img_data == NULL) return (SANE_STATUS_INVAL); if (!handler->end_read) { readbyte = min((handler->scanner->img_size - handler->scanner->img_read), maxlen); memcpy(buf, handler->scanner->img_data + handler->scanner->img_read, readbyte); handler->scanner->img_read = handler->scanner->img_read + readbyte; *len = readbyte; if (handler->scanner->img_read == handler->scanner->img_size) handler->end_read = SANE_TRUE; else if (handler->scanner->img_read > handler->scanner->img_size) { *len = 0; handler->end_read = SANE_TRUE; free(handler->scanner->img_data); handler->scanner->img_data = NULL; return (SANE_STATUS_INVAL); } } else { *len = 0; free(handler->scanner->img_data); handler->scanner->img_data = NULL; return (SANE_STATUS_EOF); } return (SANE_STATUS_GOOD); } SANE_Status sane_get_select_fd(SANE_Handle __sane_unused__ h, SANE_Int __sane_unused__ *fd) { return (SANE_STATUS_UNSUPPORTED); } SANE_Status sane_set_io_mode(SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { return (SANE_STATUS_UNSUPPORTED); } sane-backends-1.0.29/backend/escl/escl_capabilities.c0000666000000000000000000003262113615534521017325 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include #include #include #include #include #include "../include/sane/saneopts.h" struct cap { char *memory; size_t size; }; /** * \fn static SANE_String_Const convert_elements(SANE_String_Const str) * \brief Function that converts the 'color modes' of the scanner (color/gray) to be understood by SANE. * * \return SANE_VALUE_SCAN_MODE_GRAY / SANE_VALUE_SCAN_MODE_COLOR ; NULL otherwise */ static SANE_String_Const convert_elements(SANE_String_Const str) { if (strcmp(str, "Grayscale8") == 0) return (SANE_VALUE_SCAN_MODE_GRAY); else if (strcmp(str, "RGB24") == 0) return (SANE_VALUE_SCAN_MODE_COLOR); return (NULL); } /** * \fn static SANE_String_Const *char_to_array(SANE_String_Const *tab, int *tabsize, SANE_String_Const mode, int good_array) * \brief Function that creates the character arrays to put inside : * the 'color modes', the 'content types', the 'document formats' and the 'supported intents'. * * \return board (the allocated array) */ static SANE_String_Const * char_to_array(SANE_String_Const *tab, int *tabsize, SANE_String_Const mode, int good_array) { SANE_String_Const *board = NULL; int i = 0; SANE_String_Const convert = NULL; if (mode == NULL) return (tab); if (good_array != 0) { convert = convert_elements(mode); if (convert == NULL) return (tab); } else convert = mode; for (i = 0; i < (*tabsize); i++) { if (strcmp(tab[i], convert) == 0) return (tab); } (*tabsize)++; if (*tabsize == 1) board = (SANE_String_Const *)malloc(sizeof(SANE_String_Const) * (*tabsize) + 1); else board = (SANE_String_Const *)realloc(tab, sizeof(SANE_String_Const) * (*tabsize) + 1); board[*tabsize - 1] = (SANE_String_Const)strdup(convert); board[*tabsize] = NULL; return (board); } /** * \fn static SANE_Int *int_to_array(SANE_Int *tab, int *tabsize, int cont) * \brief Function that creates the integer array to put inside the 'supported resolutions'. * * \return board (the allocated array) */ static SANE_Int * int_to_array(SANE_Int *tab, int *tabsize, int cont) { SANE_Int *board = NULL; int i = 0; for (i = 0; i < (*tabsize); i++) { if (tab[i] == cont) return (tab); } (*tabsize)++; if (*tabsize == 1) { (*tabsize)++; board = malloc(sizeof(SANE_Int *) * (*tabsize) + 1); } else board = realloc(tab, sizeof(SANE_Int *) * (*tabsize) + 1); board[0] = *tabsize - 1; board[*tabsize - 1] = cont; board[*tabsize] = -1; return (board); } /** * \fn static size_t memory_callback_c(void *contents, size_t size, size_t nmemb, void *userp) * \brief Callback function that stocks in memory the content of the scanner capabilities. * * \return realsize (size of the content needed -> the scanner capabilities) */ static size_t memory_callback_c(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct cap *mem = (struct cap *)userp; char *str = realloc(mem->memory, mem->size + realsize + 1); if (str == NULL) { fprintf(stderr, "not enough memory (realloc returned NULL)\n"); return (0); } mem->memory = str; memcpy(&(mem->memory[mem->size]), contents, realsize); mem->size = mem->size + realsize; mem->memory[mem->size] = 0; return (realsize); } /** * \fn static int find_nodes_c(xmlNode *node) * \brief Function that browses the xml file and parses it, to find the xml children node. * --> to recover the scanner capabilities. * * \return 0 if a xml child node is found, 1 otherwise */ static int find_nodes_c(xmlNode *node) { xmlNode *child = node->children; while (child) { if (child->type == XML_ELEMENT_NODE) return (0); child = child->next; } return (1); } /** * \fn static int find_valor_of_array_variables(xmlNode *node, capabilities_t *scanner) * \brief Function that searchs in the xml file if a scanner capabilitie stocked * in one of the created array (character/integer array) is found. * * \return 0 */ static int find_valor_of_array_variables(xmlNode *node, capabilities_t *scanner) { const char *name = (const char *)node->name; if (strcmp(name, "ColorMode") == 0) scanner->ColorModes = char_to_array(scanner->ColorModes, &scanner->ColorModesSize, (SANE_String_Const)xmlNodeGetContent(node), 1); else if (strcmp(name, "ContentType") == 0) scanner->ContentTypes = char_to_array(scanner->ContentTypes, &scanner->ContentTypesSize, (SANE_String_Const)xmlNodeGetContent(node), 0); else if (strcmp(name, "DocumentFormat") == 0) { int i = 0; scanner->DocumentFormats = char_to_array(scanner->DocumentFormats, &scanner->DocumentFormatsSize, (SANE_String_Const)xmlNodeGetContent(node), 0); for(; i < scanner->DocumentFormatsSize; i++) { if (scanner->default_format == NULL && !strcmp(scanner->DocumentFormats[i], "image/jpeg")) { scanner->default_format = strdup("image/jpeg"); } #if(defined HAVE_LIBPNG) else if(!strcmp(scanner->DocumentFormats[i], "image/png") && (scanner->default_format == NULL || strcmp(scanner->default_format, "image/tiff"))) { if (scanner->default_format) free(scanner->default_format); scanner->default_format = strdup("image/png"); } #endif #if(defined HAVE_TIFFIO_H) else if(!strcmp(scanner->DocumentFormats[i], "image/tiff")) { if (scanner->default_format) free(scanner->default_format); scanner->default_format = strdup("image/tiff"); } #endif } fprintf(stderr, "Capability : [%s]\n", scanner->default_format); } else if (strcmp(name, "DocumentFormatExt") == 0) scanner->format_ext = 1; else if (strcmp(name, "Intent") == 0) scanner->SupportedIntents = char_to_array(scanner->SupportedIntents, &scanner->SupportedIntentsSize, (SANE_String_Const)xmlNodeGetContent(node), 0); else if (strcmp(name, "XResolution") == 0) scanner->SupportedResolutions = int_to_array(scanner->SupportedResolutions, &scanner->SupportedResolutionsSize, atoi((const char *)xmlNodeGetContent(node))); return (0); } /** * \fn static int find_value_of_int_variables(xmlNode *node, capabilities_t *scanner) * \brief Function that searchs in the xml file if a integer scanner capabilitie is found. * The integer scanner capabilities that are interesting are : * MinWidth, MaxWidth, MaxHeight, MinHeight, MaxScanRegions, MaxOpticalXResolution, * RiskyLeftMargin, RiskyRightMargin, RiskyTopMargin, RiskyBottomMargin. * * \return 0 */ static int find_value_of_int_variables(xmlNode *node, capabilities_t *scanner) { int MaxWidth = 0; int MaxHeight = 0; const char *name = (const char *)node->name; if (strcmp(name, "MinWidth") == 0) scanner->MinWidth = atoi((const char*)xmlNodeGetContent(node)); else if (strcmp(name, "MaxWidth") == 0) { MaxWidth = atoi((const char*)xmlNodeGetContent(node)); if (scanner->MaxWidth == 0 || MaxWidth < scanner->MaxWidth) scanner->MaxWidth = atoi((const char *)xmlNodeGetContent(node)); } else if (strcmp(name, "MinHeight") == 0) scanner->MinHeight = atoi((const char*)xmlNodeGetContent(node)); else if (strcmp(name, "MaxHeight") == 0) { MaxHeight = atoi((const char*)xmlNodeGetContent(node)); if (scanner->MaxHeight == 0 || MaxHeight < scanner->MaxHeight) scanner->MaxHeight = atoi((const char *)xmlNodeGetContent(node)); } else if (strcmp(name, "MaxScanRegions") == 0) scanner->MaxScanRegions = atoi((const char *)xmlNodeGetContent(node)); else if (strcmp(name, "MaxOpticalXResolution") == 0) scanner->MaxOpticalXResolution = atoi((const char *)xmlNodeGetContent(node)); else if (strcmp(name, "RiskyLeftMargin") == 0) scanner->RiskyLeftMargin = atoi((const char *)xmlNodeGetContent(node)); else if (strcmp(name, "RiskyRightMargin") == 0) scanner->RiskyRightMargin = atoi((const char *)xmlNodeGetContent(node)); else if (strcmp(name, "RiskyTopMargin") == 0) scanner->RiskyTopMargin = atoi((const char *)xmlNodeGetContent(node)); else if (strcmp(name, "RiskyBottomMargin") == 0) scanner->RiskyBottomMargin = atoi((const char *)xmlNodeGetContent(node)); find_valor_of_array_variables(node, scanner); return (0); } /** * \fn static int find_true_variables(xmlNode *node, capabilities_t *scanner) * \brief Function that searchs in the xml file if we find a scanner capabilitie stocked * in one of the created array (character/integer array), * or, if we find a integer scanner capabilitie. * * \return 0 */ static int find_true_variables(xmlNode *node, capabilities_t *scanner) { const char *name = (const char *)node->name; if (strcmp(name, "MinWidth") == 0 || strcmp(name, "MaxWidth") == 0 || strcmp(name, "MinHeight") == 0 || strcmp(name, "MaxHeight") == 0 || strcmp(name, "MaxScanRegions") == 0 || strcmp(name, "ColorMode") == 0 || strcmp(name, "ContentType") == 0 || strcmp(name, "DocumentFormat") == 0 || strcmp(name, "XResolution") == 0 || strcmp(name, "Intent") == 0 || strcmp(name, "MaxOpticalXResolution") == 0 || strcmp(name, "RiskyLeftMargin") == 0 || strcmp(name, "RiskyRightMargin") == 0 || strcmp(name, "RiskyTopMargin") == 0 || strcmp(name, "RiskyBottomMargin") == 0 || strcmp(name, "DocumentFormatExt") == 0) find_value_of_int_variables(node, scanner); return (0); } /** * \fn static int print_xml_c(xmlNode *node, capabilities_t *scanner) * \brief Function that browses the xml file, node by node. * * \return 0 */ static int print_xml_c(xmlNode *node, capabilities_t *scanner) { while (node) { if (node->type == XML_ELEMENT_NODE) { if (find_nodes_c(node)) find_true_variables(node, scanner); } print_xml_c(node->children, scanner); node = node->next; } return (0); } /** * \fn capabilities_t *escl_capabilities(SANE_String_Const name, SANE_Status *status) * \brief Function that finally recovers all the capabilities of the scanner, using curl. * This function is called in the 'sane_open' function and it's the equivalent of * the following curl command : "curl http(s)://'ip':'port'/eSCL/ScannerCapabilities". * * \return scanner (the structure that stocks all the capabilities elements) */ capabilities_t * escl_capabilities(SANE_String_Const name, SANE_Status *status) { capabilities_t *scanner = (capabilities_t*)calloc(1, sizeof(capabilities_t)); CURL *curl_handle = NULL; struct cap *var = NULL; xmlDoc *data = NULL; xmlNode *node = NULL; const char *scanner_capabilities = "/eSCL/ScannerCapabilities"; char tmp[PATH_MAX] = { 0 }; *status = SANE_STATUS_GOOD; if (name == NULL) *status = SANE_STATUS_NO_MEM; var = (struct cap *)calloc(1, sizeof(struct cap)); if (var == NULL) *status = SANE_STATUS_NO_MEM; var->memory = malloc(1); var->size = 0; curl_handle = curl_easy_init(); strcpy(tmp, name); strcat(tmp, scanner_capabilities); DBG( 1, "Get Capabilities : %s\n", tmp); curl_easy_setopt(curl_handle, CURLOPT_URL, tmp); if (strncmp(name, "https", 5) == 0) { DBG( 1, "Ignoring safety certificates, use https\n"); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); } curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, memory_callback_c); curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)var); if (curl_easy_perform(curl_handle) != CURLE_OK) { DBG( 1, "The scanner didn't respond.\n"); *status = SANE_STATUS_INVAL; } data = xmlReadMemory(var->memory, var->size, "file.xml", NULL, 0); if (data == NULL) *status = SANE_STATUS_NO_MEM; node = xmlDocGetRootElement(data); if (node == NULL) *status = SANE_STATUS_NO_MEM; print_xml_c(node, scanner); xmlFreeDoc(data); xmlCleanupParser(); xmlMemoryDump(); curl_easy_cleanup(curl_handle); free(var->memory); return (scanner); } sane-backends-1.0.29/backend/escl/escl_jpeg.c0000666000000000000000000001466313615534521015627 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include "../include/sane/sanei.h" #include #include #include #if(defined HAVE_LIBJPEG) # include #endif #include #define INPUT_BUFFER_SIZE 4096 #if(defined HAVE_LIBJPEG) struct my_error_mgr { struct jpeg_error_mgr errmgr; jmp_buf escape; }; typedef struct { struct jpeg_source_mgr pub; FILE *ctx; unsigned char buffer[INPUT_BUFFER_SIZE]; } my_source_mgr; /** * \fn static boolean fill_input_buffer(j_decompress_ptr cinfo) * \brief Called in the "skip_input_data" function. * * \return TRUE (everything is OK) */ static boolean fill_input_buffer(j_decompress_ptr cinfo) { my_source_mgr *src = (my_source_mgr *) cinfo->src; int nbytes = 0; nbytes = fread(src->buffer, 1, INPUT_BUFFER_SIZE, src->ctx); if (nbytes <= 0) { src->buffer[0] = (unsigned char) 0xFF; src->buffer[1] = (unsigned char) JPEG_EOI; nbytes = 2; } src->pub.next_input_byte = src->buffer; src->pub.bytes_in_buffer = nbytes; return (TRUE); } /** * \fn static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) * \brief Called in the "jpeg_RW_src" function. */ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) { my_source_mgr *src = (my_source_mgr *) cinfo->src; if (num_bytes > 0) { while (num_bytes > (long) src->pub.bytes_in_buffer) { num_bytes -= (long) src->pub.bytes_in_buffer; (void) src->pub.fill_input_buffer(cinfo); } src->pub.next_input_byte += (size_t) num_bytes; src->pub.bytes_in_buffer -= (size_t) num_bytes; } } static void term_source(j_decompress_ptr __sane_unused__ cinfo) { return; } static void init_source(j_decompress_ptr __sane_unused__ cinfo) { return; } /** * \fn static void jpeg_RW_src(j_decompress_ptr cinfo, FILE *ctx) * \brief Called in the "escl_sane_decompressor" function. */ static void jpeg_RW_src(j_decompress_ptr cinfo, FILE *ctx) { my_source_mgr *src; if (cinfo->src == NULL) { cinfo->src = (struct jpeg_source_mgr *)(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(my_source_mgr)); src = (my_source_mgr *) cinfo->src; } src = (my_source_mgr *) cinfo->src; src->pub.init_source = init_source; src->pub.fill_input_buffer = fill_input_buffer; src->pub.skip_input_data = skip_input_data; src->pub.resync_to_restart = jpeg_resync_to_restart; src->pub.term_source = term_source; src->ctx = ctx; src->pub.bytes_in_buffer = 0; src->pub.next_input_byte = NULL; } static void my_error_exit(j_common_ptr cinfo) { struct my_error_mgr *err = (struct my_error_mgr *)cinfo->err; longjmp(err->escape, 1); } static void output_no_message(j_common_ptr __sane_unused__ cinfo) { } /** * \fn SANE_Status escl_sane_decompressor(escl_sane_t *handler) * \brief Function that aims to decompress the jpeg image to SANE be able to read the image. * This function is called in the "sane_read" function. * * \return SANE_STATUS_GOOD (if everything is OK, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status get_JPEG_data(capabilities_t *scanner, int *w, int *h, int *bps) { int start = 0; struct jpeg_decompress_struct cinfo; JSAMPROW rowptr[1]; unsigned char *surface = NULL; struct my_error_mgr jerr; int lineSize = 0; if (scanner->tmp == NULL) return (SANE_STATUS_INVAL); fseek(scanner->tmp, SEEK_SET, 0); start = ftell(scanner->tmp); cinfo.err = jpeg_std_error(&jerr.errmgr); jerr.errmgr.error_exit = my_error_exit; jerr.errmgr.output_message = output_no_message; if (setjmp(jerr.escape)) { jpeg_destroy_decompress(&cinfo); if (surface != NULL) free(surface); DBG( 1, "Escl Jpeg : Error reading jpeg\n"); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_INVAL); } jpeg_create_decompress(&cinfo); jpeg_RW_src(&cinfo, scanner->tmp); jpeg_read_header(&cinfo, TRUE); cinfo.out_color_space = JCS_RGB; cinfo.quantize_colors = FALSE; jpeg_calc_output_dimensions(&cinfo); surface = malloc(cinfo.output_width * cinfo.output_height * cinfo.output_components); if (surface == NULL) { jpeg_destroy_decompress(&cinfo); fseek(scanner->tmp, start, SEEK_SET); DBG( 1, "Escl Jpeg : Memory allocation problem\n"); if (scanner->tmp) { fclose(scanner->tmp); scanner->tmp = NULL; } return (SANE_STATUS_NO_MEM); } lineSize = cinfo.output_width * cinfo.output_components; jpeg_start_decompress(&cinfo); while (cinfo.output_scanline < cinfo.output_height) { rowptr[0] = (JSAMPROW)surface + (lineSize * cinfo.output_scanline); jpeg_read_scanlines(&cinfo, rowptr, (JDIMENSION) 1); } scanner->img_data = surface; scanner->img_size = lineSize * cinfo.output_height; scanner->img_read = 0; *w = cinfo.output_width; *h = cinfo.output_height; *bps = cinfo.output_components; jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); fclose(scanner->tmp); scanner->tmp = NULL; return (SANE_STATUS_GOOD); } #else SANE_Status get_JPEG_data(capabilities_t __sane_unused__ *scanner, int __sane_unused__ *w, int __sane_unused__ *h, int __sane_unused__ *bps) { return (SANE_STATUS_INVAL); } #endif sane-backends-1.0.29/backend/escl/escl.h0000666000000000000000000001107013615534521014614 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #ifndef __ESCL_H__ #define __ESCL_H__ #include "../include/sane/config.h" #if !(HAVE_LIBCURL && defined(WITH_AVAHI) && defined(HAVE_LIBXML2)) #error "The escl backend requires libcurl, libavahi and libxml2" #endif #ifndef HAVE_LIBJPEG /* FIXME: Make JPEG support optional. Support for PNG and PDF is to be added later but currently only JPEG is supported. Absence of JPEG support makes the backend a no-op at present. */ #error "The escl backend currently requires libjpeg" #endif #include "../include/sane/sane.h" #include #ifndef BACKEND_NAME #define BACKEND_NAME escl #endif #define DEBUG_NOT_STATIC #include "../include/sane/sanei_debug.h" #ifndef DBG_LEVEL #define DBG_LEVEL PASTE(sanei_debug_, BACKEND_NAME) #endif #ifndef NDEBUG # define DBGDUMP(level, buf, size) \ do { if (DBG_LEVEL >= (level)) sanei_escl_dbgdump(buf, size); } while (0) #else # define DBGDUMP(level, buf, size) #endif #define ESCL_CONFIG_FILE "escl.conf" typedef struct { int p1_0; int p2_0; int p3_3; int DocumentType; int p4_0; int p5_0; int p6_1; int reserve[11]; } ESCL_SCANOPTS; typedef struct ESCL_Device { struct ESCL_Device *next; char *model_name; int port_nb; char *ip_address; char *type; } ESCL_Device; typedef struct capabilities { int height; int width; int pos_x; int pos_y; SANE_String default_color; SANE_String default_format; SANE_Int default_resolution; int MinWidth; int MaxWidth; int MinHeight; int MaxHeight; int MaxScanRegions; SANE_String_Const *ColorModes; int ColorModesSize; SANE_String_Const *ContentTypes; int ContentTypesSize; SANE_String_Const *DocumentFormats; int DocumentFormatsSize; SANE_Int *SupportedResolutions; int SupportedResolutionsSize; SANE_String_Const *SupportedIntents; int SupportedIntentsSize; SANE_String_Const SupportedIntentDefault; int MaxOpticalXResolution; int RiskyLeftMargin; int RiskyRightMargin; int RiskyTopMargin; int RiskyBottomMargin; FILE *tmp; unsigned char *img_data; long img_size; long img_read; int format_ext; } capabilities_t; typedef struct { int XRes; int YRes; int Left; int Top; int Right; int Bottom; int ScanMode; int ScanMethod; ESCL_SCANOPTS opts; } ESCL_ScanParam; enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_RESOLUTION, OPT_PREVIEW, OPT_GRAY_PREVIEW, OPT_GEOMETRY_GROUP, OPT_TL_X, OPT_TL_Y, OPT_BR_X, OPT_BR_Y, NUM_OPTIONS }; ESCL_Device *escl_devices(SANE_Status *status); SANE_Status escl_device_add(int port_nb, const char *model_name, char *ip_address, char *type); SANE_Status escl_status(SANE_String_Const name); capabilities_t *escl_capabilities(SANE_String_Const name, SANE_Status *status); char *escl_newjob(capabilities_t *scanner, SANE_String_Const name, SANE_Status *status); SANE_Status escl_scan(capabilities_t *scanner, SANE_String_Const name, char *result); void escl_scanner(SANE_String_Const name, char *result); // JPEG SANE_Status get_JPEG_data(capabilities_t *scanner, int *w, int *h, int *bps); // PNG SANE_Status get_PNG_data(capabilities_t *scanner, int *w, int *h, int *bps); // TIFF SANE_Status get_TIFF_data(capabilities_t *scanner, int *w, int *h, int *bps); #endif sane-backends-1.0.29/backend/escl/escl_scan.c0000666000000000000000000000700713615534521015620 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include #include #include #include #include "../include/sane/sanei.h" /** * \fn static size_t write_callback(void *str, size_t size, size_t nmemb, void *userp) * \brief Callback function that writes the image scanned into the temporary file. * * \return to_write (the result of the fwrite fonction) */ static size_t write_callback(void *str, size_t size, size_t nmemb, void *userp) { size_t to_write = fwrite(str, size, nmemb, (FILE *)userp); return (to_write); } /** * \fn SANE_Status escl_scan(capabilities_t *scanner, SANE_String_Const name, char *result) * \brief Function that, after recovering the 'new job', scans the image writed in the * temporary file, using curl. * This function is called in the 'sane_start' function and it's the equivalent of * the following curl command : "curl -s http(s)://'ip:'port'/eSCL/ScanJobs/'new job'/NextDocument > image.jpg". * * \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL) */ SANE_Status escl_scan(capabilities_t __sane_unused__ *scanner, SANE_String_Const name, char *result) { CURL *curl_handle = NULL; const char *scan_jobs = "/eSCL/ScanJobs"; const char *scanner_start = "/NextDocument"; char scan_cmd[PATH_MAX] = { 0 }; SANE_Status status = SANE_STATUS_GOOD; if (name == NULL) return (SANE_STATUS_NO_MEM); curl_handle = curl_easy_init(); if (curl_handle != NULL) { strcpy(scan_cmd, name); strcat(scan_cmd, scan_jobs); strcat(scan_cmd, result); strcat(scan_cmd, scanner_start); curl_easy_setopt(curl_handle, CURLOPT_URL, scan_cmd); DBG( 1, "Scan : %s.\n", scan_cmd); if (strncmp(name, "https", 5) == 0) { DBG( 1, "Ignoring safety certificates, use https\n"); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); } curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback); scanner->tmp = tmpfile(); if (scanner->tmp != NULL) { curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, scanner->tmp); if (curl_easy_perform(curl_handle) != CURLE_OK) { status = SANE_STATUS_INVAL; } else curl_easy_cleanup(curl_handle); fseek(scanner->tmp, 0, SEEK_SET); } else status = SANE_STATUS_NO_MEM; } return (status); } sane-backends-1.0.29/backend/escl/escl_newjob.c0000666000000000000000000002135613615534521016163 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2019 Touboul Nathane Copyright (C) 2019 Thierry HUCHARD This file is part of the SANE package. SANE 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; either version 3 of the License, or (at your option) any later version. SANE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with sane; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. This file implements a SANE backend for eSCL scanners. */ #define DEBUG_DECLARE_ONLY #include "../include/sane/config.h" #include "escl.h" #include #include #include #include #ifdef PATH_MAX # undef PATH_MAX #endif #define PATH_MAX 4096 struct uploading { const char *read_data; size_t size; }; struct downloading { char *memory; size_t size; }; static const char settings[] = "" \ "" \ " 2.0" \ " " \ " " \ " escl:ThreeHundredthsOfInches" \ " %d" \ " %d" \ " %d" \ " %d" \ " " \ " " \ " %s" \ "%s" \ " %s" \ " %d" \ " %d" \ " Platen" \ ""; static char formatExtJPEG[] = " image/jpeg"; static char formatExtPNG[] = " image/png"; static char formatExtTIFF[] = " image/tiff"; /** * \fn static size_t download_callback(void *str, size_t size, size_t nmemb, void *userp) * \brief Callback function that stocks in memory the content of the 'job'. Example below : * "Trying 192.168.14.150... * TCP_NODELAY set * Connected to 192.168.14.150 (192.168.14.150) port 80 * POST /eSCL/ScanJobs HTTP/1.1 * Host: 192.168.14.150 * User-Agent: curl/7.55.1 * Accept: / * Content-Length: 605 * Content-Type: application/x-www-form-urlencoded * upload completely sent off: 605 out of 605 bytes * < HTTP/1.1 201 Created * < MIME-Version: 1.0 * < Location: http://192.168.14.150/eSCL/ScanJobs/22b54fd0-027b-1000-9bd0-f4a99726e2fa * < Content-Length: 0 * < Connection: close * < * Closing connection 0" * * \return realsize (size of the content needed -> the 'job') */ static size_t download_callback(void *str, size_t size, size_t nmemb, void *userp) { struct downloading *download = (struct downloading *)userp; size_t realsize = size * nmemb; char *content = realloc(download->memory, download->size + realsize + 1); if (content == NULL) { DBG( 1, "Not enough memory (realloc returned NULL)\n"); return (0); } download->memory = content; memcpy(&(download->memory[download->size]), str, realsize); download->size = download->size + realsize; download->memory[download->size] = 0; return (realsize); } /** * \fn char *escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *status) * \brief Function that, using curl, uploads the data (composed by the scanner capabilities) to the * server to download the 'job' and recover the 'new job' (char *result), in LOCATION. * This function is called in the 'sane_start' function and it's the equivalent of the * following curl command : "curl -v POST -d cap.xml http(s)://'ip':'port'/eSCL/ScanJobs". * * \return result (the 'new job', situated in LOCATION) */ char * escl_newjob (capabilities_t *scanner, SANE_String_Const name, SANE_Status *status) { CURL *curl_handle = NULL; struct uploading *upload = NULL; struct downloading *download = NULL; const char *scan_jobs = "/eSCL/ScanJobs"; char cap_data[PATH_MAX] = { 0 }; char job_cmd[PATH_MAX] = { 0 }; char *location = NULL; char *result = NULL; char *temporary = NULL; char *f_ext = ""; char *format_ext = NULL; *status = SANE_STATUS_GOOD; if (name == NULL || scanner == NULL) { *status = SANE_STATUS_NO_MEM; DBG( 1, "Create NewJob : the name or the scan are invalid.\n"); return (NULL); } upload = (struct uploading *)calloc(1, sizeof(struct uploading)); if (upload == NULL) { *status = SANE_STATUS_NO_MEM; DBG( 1, "Create NewJob : memory allocation failure\n"); return (NULL); } download = (struct downloading *)calloc(1, sizeof(struct downloading)); if (download == NULL) { free(upload); DBG( 1, "Create NewJob : memory allocation failure\n"); *status = SANE_STATUS_NO_MEM; return (NULL); } curl_handle = curl_easy_init(); if (scanner->format_ext == 1) { if (!strcmp(scanner->default_format, "image/jpeg")) format_ext = formatExtJPEG; else if (!strcmp(scanner->default_format, "image/png")) format_ext = formatExtPNG; else if (!strcmp(scanner->default_format, "image/tiff")) format_ext = formatExtTIFF; else format_ext = f_ext; } else format_ext = f_ext; DBG( 1, "Create NewJob : %s\n", scanner->default_format); if (curl_handle != NULL) { snprintf(cap_data, sizeof(cap_data), settings, scanner->height, scanner->width, 0, 0, scanner->default_format, format_ext, scanner->default_color, scanner->default_resolution, scanner->default_resolution); DBG( 1, "Create NewJob : %s\n", cap_data); upload->read_data = strdup(cap_data); upload->size = strlen(cap_data); download->memory = malloc(1); download->size = 0; strcpy(job_cmd, name); strcat(job_cmd, scan_jobs); curl_easy_setopt(curl_handle, CURLOPT_URL, job_cmd); if (strncmp(name, "https", 5) == 0) { curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); } curl_easy_setopt(curl_handle, CURLOPT_POST, 1L); curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, upload->read_data); curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, upload->size); curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, download_callback); curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, (void *)download); if (curl_easy_perform(curl_handle) != CURLE_OK) { DBG( 1, "Create NewJob : the scanner responded incorrectly.\n"); *status = SANE_STATUS_INVAL; } else { if (download->memory != NULL) { if (strstr(download->memory, "Location:")) { temporary = strrchr(download->memory, '/'); if (temporary != NULL) { location = strchr(temporary, '\r'); if (location == NULL) location = strchr(temporary, '\n'); else { *location = '\0'; result = strdup(temporary); } DBG( 1, "Create NewJob : %s\n", result); } free(download->memory); } else { DBG( 1, "Create NewJob : The creation of the failed job\n"); *status = SANE_STATUS_INVAL; } } else { *status = SANE_STATUS_NO_MEM; DBG( 1, "Create NewJob : The creation of the failed job\n"); return (NULL); } } curl_easy_cleanup(curl_handle); } if (upload != NULL) free(upload); if (download != NULL) free(download); return (result); } sane-backends-1.0.29/backend/canon630u.c0000666000000000000000000006252613615534521014463 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002, Nathan Rutman Copyright (C) 2001, Marcio Luis Teixeira Parts copyright (C) 1996, 1997 Andreas Beck Parts copyright (C) 2000, 2001 Michael Herder Parts copyright (C) 2001 Henning Meier-Geinitz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #define BUILD 1 #define MM_IN_INCH 25.4 #include "../include/sane/config.h" #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_usb.h" #define BACKEND_NAME canon630u #define CANONUSB_CONFIG_FILE "canon630u.conf" #include "../include/sane/sanei_backend.h" #include "canon630u-common.c" typedef struct Canon_Device { struct Canon_Device *next; SANE_String name; SANE_Device sane; } Canon_Device; typedef struct Canon_Scanner { struct Canon_Scanner *next; Canon_Device *device; CANON_Handle scan; } Canon_Scanner; static int num_devices = 0; static const SANE_Device **devlist = NULL; static Canon_Device *first_dev = NULL; static Canon_Scanner *first_handle = NULL; static SANE_Parameters parms = { SANE_FRAME_RGB, 0, 0, /* Number of bytes returned per scan line: */ 0, /* Number of pixels per scan line. */ 0, /* Number of lines for the current scan. */ 8 /* Number of bits per sample. */ }; struct _SANE_Option { SANE_Option_Descriptor *descriptor; SANE_Status (*callback) (struct _SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info); }; typedef struct _SANE_Option SANE_Option; /*-----------------------------------------------------------------*/ static SANE_Word getNumberOfOptions (void); /* Forward declaration */ /* This read-only option returns the number of options available for the device. It should be the first option in the options array declared below. */ static SANE_Option_Descriptor optionNumOptionsDescriptor = { SANE_NAME_NUM_OPTIONS, SANE_TITLE_NUM_OPTIONS, SANE_DESC_NUM_OPTIONS, SANE_TYPE_INT, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} }; static SANE_Status optionNumOptionsCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { option = option; handle = handle; info = info; /* Eliminate warning about unused parameters */ if (action != SANE_ACTION_GET_VALUE) return SANE_STATUS_INVAL; *(SANE_Word *) value = getNumberOfOptions (); return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ /* This option lets the user force scanner calibration. Normally, this is done only once, at first scan after powerup. */ static SANE_Word optionCalibrateValue = SANE_FALSE; static SANE_Option_Descriptor optionCalibrateDescriptor = { "cal", SANE_I18N ("Calibrate Scanner"), SANE_I18N ("Force scanner calibration before scan"), SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} }; static SANE_Status optionCalibrateCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { handle = handle; option = option; /* Eliminate warning about unused parameters */ switch (action) { case SANE_ACTION_SET_AUTO: return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: *info |= SANE_INFO_RELOAD_PARAMS; optionCalibrateValue = *(SANE_Bool *) value; break; case SANE_ACTION_GET_VALUE: *(SANE_Word *) value = optionCalibrateValue; break; } return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ /* This option lets the user select the scan resolution. The Canon fb630u scanner supports the following resolutions: 75, 150, 300, 600, 1200 */ static const SANE_Word optionResolutionList[] = { 4, /* Number of elements */ 75, 150, 300, 600 /* Resolution list */ /* also 600x1200, but ignore that for now. */ }; static SANE_Option_Descriptor optionResolutionDescriptor = { SANE_NAME_SCAN_RESOLUTION, SANE_TITLE_SCAN_RESOLUTION, SANE_DESC_SCAN_RESOLUTION, SANE_TYPE_INT, SANE_UNIT_DPI, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_AUTOMATIC, SANE_CONSTRAINT_WORD_LIST, {(const SANE_String_Const *) optionResolutionList} }; static SANE_Word optionResolutionValue = 75; static SANE_Status optionResolutionCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { SANE_Status status; SANE_Word autoValue = 75; handle = handle; /* Eliminate warning about unused parameters */ switch (action) { case SANE_ACTION_SET_AUTO: status = sanei_constrain_value (option->descriptor, (void *) &autoValue, info); if (status != SANE_STATUS_GOOD) return status; optionResolutionValue = autoValue; *info |= SANE_INFO_RELOAD_PARAMS; break; case SANE_ACTION_SET_VALUE: *info |= SANE_INFO_RELOAD_PARAMS; optionResolutionValue = *(SANE_Word *) value; break; case SANE_ACTION_GET_VALUE: *(SANE_Word *) value = optionResolutionValue; break; } return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ #ifdef GRAY /* This option lets the user select a gray scale scan */ static SANE_Word optionGrayscaleValue = SANE_FALSE; static SANE_Option_Descriptor optionGrayscaleDescriptor = { "gray", SANE_I18N ("Grayscale scan"), SANE_I18N ("Do a grayscale rather than color scan"), SANE_TYPE_BOOL, SANE_UNIT_NONE, sizeof (SANE_Word), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_NONE, {NULL} }; static SANE_Status optionGrayscaleCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { handle = handle; option = option; /* Eliminate warning about unused parameters */ switch (action) { case SANE_ACTION_SET_AUTO: return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: *info |= SANE_INFO_RELOAD_PARAMS; optionGrayscaleValue = *(SANE_Bool *) value; break; case SANE_ACTION_GET_VALUE: *(SANE_Word *) value = optionGrayscaleValue; break; } return SANE_STATUS_GOOD; } #endif /* GRAY */ /*-----------------------------------------------------------------*/ /* Analog Gain setting */ static const SANE_Range aGainRange = { 0, /* minimum */ 64, /* maximum */ 1 /* quantization */ }; static SANE_Int optionAGainValue = 1; static SANE_Option_Descriptor optionAGainDescriptor = { "gain", SANE_I18N ("Analog Gain"), SANE_I18N ("Increase or decrease the analog gain of the CCD array"), SANE_TYPE_INT, SANE_UNIT_NONE, sizeof (SANE_Int), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED, SANE_CONSTRAINT_RANGE, {(const SANE_String_Const *) &aGainRange} }; static SANE_Status optionAGainCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { option = option; handle = handle; info = info; /* Eliminate warning about unused parameters */ switch (action) { case SANE_ACTION_SET_AUTO: return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: optionAGainValue = *(SANE_Int *) value; *info |= SANE_INFO_RELOAD_PARAMS; break; case SANE_ACTION_GET_VALUE: *(SANE_Int *) value = optionAGainValue; break; } return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ /* Scanner gamma setting */ static SANE_Fixed optionGammaValue = SANE_FIX (1.6); static SANE_Option_Descriptor optionGammaDescriptor = { "gamma", SANE_I18N ("Gamma Correction"), SANE_I18N ("Selects the gamma corrected transfer curve"), SANE_TYPE_FIXED, SANE_UNIT_NONE, sizeof (SANE_Int), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED, SANE_CONSTRAINT_NONE, {NULL} }; static SANE_Status optionGammaCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { option = option; handle = handle; info = info; /* Eliminate warning about unused parameters */ switch (action) { case SANE_ACTION_SET_AUTO: return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: optionGammaValue = *(SANE_Fixed *) value; *info |= SANE_INFO_RELOAD_PARAMS; break; case SANE_ACTION_GET_VALUE: *(SANE_Fixed *) value = optionGammaValue; break; } return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ /* Scan range */ static const SANE_Range widthRange = { 0, /* minimum */ SANE_FIX (CANON_MAX_WIDTH * MM_IN_INCH / 600), /* maximum */ 0 /* quantization */ }; static const SANE_Range heightRange = { 0, /* minimum */ SANE_FIX (CANON_MAX_HEIGHT * MM_IN_INCH / 600), /* maximum */ 0 /* quantization */ }; /*-----------------------------------------------------------------*/ /* This option controls the top-left-x corner of the scan */ static SANE_Fixed optionTopLeftXValue = 0; static SANE_Option_Descriptor optionTopLeftXDescriptor = { SANE_NAME_SCAN_TL_X, SANE_TITLE_SCAN_TL_X, SANE_DESC_SCAN_TL_X, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Fixed), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(const SANE_String_Const *) &widthRange} }; static SANE_Status optionTopLeftXCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { option = option; handle = handle; value = value; /* Eliminate warning about unused parameters */ switch (action) { case SANE_ACTION_SET_AUTO: return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: optionTopLeftXValue = *(SANE_Fixed *) value; *info |= SANE_INFO_RELOAD_PARAMS; break; case SANE_ACTION_GET_VALUE: *(SANE_Fixed *) value = optionTopLeftXValue; break; } return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ /* This option controls the top-left-y corner of the scan */ static SANE_Fixed optionTopLeftYValue = 0; static SANE_Option_Descriptor optionTopLeftYDescriptor = { SANE_NAME_SCAN_TL_Y, SANE_TITLE_SCAN_TL_Y, SANE_DESC_SCAN_TL_Y, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Fixed), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(const SANE_String_Const *) &heightRange} }; static SANE_Status optionTopLeftYCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { /* Eliminate warnings about unused parameters */ option = option; handle = handle; switch (action) { case SANE_ACTION_SET_AUTO: return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: optionTopLeftYValue = *(SANE_Fixed *) value; *info |= SANE_INFO_RELOAD_PARAMS; break; case SANE_ACTION_GET_VALUE: *(SANE_Fixed *) value = optionTopLeftYValue; break; } return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ /* This option controls the bot-right-x corner of the scan Default to 215.9mm, max. */ static SANE_Fixed optionBotRightXValue = SANE_FIX (215.9); static SANE_Option_Descriptor optionBotRightXDescriptor = { SANE_NAME_SCAN_BR_X, SANE_TITLE_SCAN_BR_X, SANE_DESC_SCAN_BR_X, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Fixed), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(const SANE_String_Const *) &widthRange} }; static SANE_Status optionBotRightXCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { /* Eliminate warnings about unused parameters */ option = option; handle = handle; switch (action) { case SANE_ACTION_SET_AUTO: return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: optionBotRightXValue = *(SANE_Fixed *) value; *info |= SANE_INFO_RELOAD_PARAMS; break; case SANE_ACTION_GET_VALUE: *(SANE_Fixed *) value = optionBotRightXValue; break; } return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ /* This option controls the bot-right-y corner of the scan Default to 296.3mm, max */ static SANE_Fixed optionBotRightYValue = SANE_FIX (296.3); static SANE_Option_Descriptor optionBotRightYDescriptor = { SANE_NAME_SCAN_BR_Y, SANE_TITLE_SCAN_BR_Y, SANE_DESC_SCAN_BR_Y, SANE_TYPE_FIXED, SANE_UNIT_MM, sizeof (SANE_Fixed), SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT, SANE_CONSTRAINT_RANGE, {(const SANE_String_Const *) &heightRange} }; static SANE_Status optionBotRightYCallback (SANE_Option * option, SANE_Handle handle, SANE_Action action, void *value, SANE_Int * info) { /* Eliminate warnings about unused parameters */ option = option; handle = handle; switch (action) { case SANE_ACTION_SET_AUTO: return SANE_STATUS_INVAL; break; case SANE_ACTION_SET_VALUE: optionBotRightYValue = *(SANE_Fixed *) value; *info |= SANE_INFO_RELOAD_PARAMS; break; case SANE_ACTION_GET_VALUE: *(SANE_Fixed *) value = optionBotRightYValue; break; } return SANE_STATUS_GOOD; } /*-----------------------------------------------------------------*/ /* The following array binds the option descriptors to their respective callback routines */ static SANE_Option so[] = { {&optionNumOptionsDescriptor, optionNumOptionsCallback}, {&optionResolutionDescriptor, optionResolutionCallback}, {&optionCalibrateDescriptor, optionCalibrateCallback}, #ifdef GRAY {&optionGrayscaleDescriptor, optionGrayscaleCallback}, #endif {&optionAGainDescriptor, optionAGainCallback}, {&optionGammaDescriptor, optionGammaCallback}, {&optionTopLeftXDescriptor, optionTopLeftXCallback}, {&optionTopLeftYDescriptor, optionTopLeftYCallback}, {&optionBotRightXDescriptor, optionBotRightXCallback}, {&optionBotRightYDescriptor, optionBotRightYCallback} }; static SANE_Word getNumberOfOptions (void) { return NELEMS (so); } /* This routine dispatches the control message to the appropriate callback routine, it outght to be called by sane_control_option after any driver specific validation. */ static SANE_Status dispatch_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { SANE_Option *op = so + option; SANE_Int myinfo = 0; SANE_Status status = SANE_STATUS_GOOD; if (option < 0 || option >= NELEMS (so)) return SANE_STATUS_INVAL; /* Unknown option ... */ if ((action == SANE_ACTION_SET_VALUE) && ((op->descriptor->cap & SANE_CAP_SOFT_SELECT) == 0)) return SANE_STATUS_INVAL; if ((action == SANE_ACTION_GET_VALUE) && ((op->descriptor->cap & SANE_CAP_SOFT_DETECT) == 0)) return SANE_STATUS_INVAL; if ((action == SANE_ACTION_SET_AUTO) && ((op->descriptor->cap & SANE_CAP_AUTOMATIC) == 0)) return SANE_STATUS_INVAL; if (action == SANE_ACTION_SET_VALUE) { status = sanei_constrain_value (op->descriptor, value, &myinfo); if (status != SANE_STATUS_GOOD) return status; } status = (op->callback) (op, handle, action, value, &myinfo); if (info) *info = myinfo; return status; } static SANE_Status attach_scanner (const char *devicename, Canon_Device ** devp) { CANON_Handle scan; Canon_Device *dev; SANE_Status status; DBG (3, "attach_scanner: %s\n", devicename); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devicename) == 0) { if (devp) *devp = dev; return SANE_STATUS_GOOD; } } dev = malloc (sizeof (*dev)); if (!dev) return SANE_STATUS_NO_MEM; memset (dev, '\0', sizeof (Canon_Device)); /* clear structure */ DBG (4, "attach_scanner: opening %s\n", devicename); status = CANON_open_device (&scan, devicename); if (status != SANE_STATUS_GOOD) { DBG (1, "ERROR: attach_scanner: opening %s failed\n", devicename); free (dev); return status; } dev->name = strdup (devicename); dev->sane.name = dev->name; dev->sane.vendor = "CANON"; dev->sane.model = CANON_get_device_name (&scan); dev->sane.type = "flatbed scanner"; CANON_close_device (&scan); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; return SANE_STATUS_GOOD; } /* callback function for sanei_usb_attach_matching_devices */ static SANE_Status attach_one (const char *name) { attach_scanner (name, 0); return SANE_STATUS_GOOD; } /* Find our devices */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char config_line[PATH_MAX]; size_t len; FILE *fp; DBG_INIT (); #if 0 DBG_LEVEL = 10; #endif DBG (2, "sane_init: version_code %s 0, authorize %s 0\n", version_code == 0 ? "=" : "!=", authorize == 0 ? "=" : "!="); DBG (1, "sane_init: SANE Canon630u backend version %d.%d.%d from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); sanei_usb_init (); fp = sanei_config_open (CANONUSB_CONFIG_FILE); if (!fp) { /* no config-file: try these */ attach_scanner ("/dev/scanner", 0); attach_scanner ("/dev/usbscanner", 0); attach_scanner ("/dev/usb/scanner", 0); return SANE_STATUS_GOOD; } DBG (3, "reading configure file %s\n", CANONUSB_CONFIG_FILE); while (sanei_config_read (config_line, sizeof (config_line), fp)) { if (config_line[0] == '#') continue; /* ignore line comments */ len = strlen (config_line); if (!len) continue; /* ignore empty lines */ DBG (4, "attach_matching_devices(%s)\n", config_line); sanei_usb_attach_matching_devices (config_line, attach_one); } DBG (4, "finished reading configure file\n"); fclose (fp); return SANE_STATUS_GOOD; } void sane_exit (void) { Canon_Device *dev, *next; DBG (3, "sane_exit\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free (dev->name); free (dev); } if (devlist) free (devlist); return; } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Canon_Device *dev; int i; DBG (3, "sane_get_devices(local_only = %d)\n", local_only); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Canon_Device *dev; SANE_Status status; Canon_Scanner *scanner; DBG (3, "sane_open\n"); if (devicename[0]) /* search for devicename */ { DBG (4, "sane_open: devicename=%s\n", devicename); for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; if (!dev) { status = attach_scanner (devicename, &dev); if (status != SANE_STATUS_GOOD) return status; } } else { DBG (2, "sane_open: no devicename, opening first device\n"); dev = first_dev; } if (!dev) return SANE_STATUS_INVAL; scanner = malloc (sizeof (*scanner)); if (!scanner) return SANE_STATUS_NO_MEM; memset (scanner, 0, sizeof (*scanner)); scanner->device = dev; status = CANON_open_device (&scanner->scan, dev->sane.name); if (status != SANE_STATUS_GOOD) { free (scanner); return status; } *handle = scanner; /* insert newly opened handle into list of open handles: */ scanner->next = first_handle; first_handle = scanner; return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Canon_Scanner *prev, *scanner; DBG (3, "sane_close\n"); if (!first_handle) { DBG (1, "ERROR: sane_close: no handles opened\n"); return; } /* remove handle from list of open handles: */ prev = NULL; for (scanner = first_handle; scanner; scanner = scanner->next) { if (scanner == handle) break; prev = scanner; } if (!scanner) { DBG (1, "ERROR: sane_close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (prev) prev->next = scanner->next; else first_handle = scanner->next; CANON_close_device (&scanner->scan); free (scanner); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { handle = handle; /* Eliminate compiler warning */ DBG (3, "sane_get_option_descriptor: option = %d\n", option); if (option < 0 || option >= NELEMS (so)) return NULL; return so[option].descriptor; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { handle = handle; /* Eliminate compiler warning */ DBG (3, "sane_control_option: handle=%p, opt=%d, act=%d, val=%p, info=%p\n", handle, option, action, value, (void *)info); return dispatch_control_option (handle, option, action, value, info); } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { int rc = SANE_STATUS_GOOD; int w = SANE_UNFIX (optionBotRightXValue - optionTopLeftXValue) / MM_IN_INCH * optionResolutionValue; int h = SANE_UNFIX (optionBotRightYValue - optionTopLeftYValue) / MM_IN_INCH * optionResolutionValue; handle = handle; /* Eliminate compiler warning */ DBG (3, "sane_get_parameters\n"); parms.depth = 8; parms.last_frame = SANE_TRUE; parms.pixels_per_line = w; parms.lines = h; #ifdef GRAY if (optionGrayscaleValue == SANE_TRUE) { parms.format = SANE_FRAME_GRAY; parms.bytes_per_line = w; } else #endif { parms.format = SANE_FRAME_RGB; parms.bytes_per_line = w * 3; } *params = parms; return rc; } SANE_Status sane_start (SANE_Handle handle) { Canon_Scanner *scanner = handle; SANE_Status res; DBG (3, "sane_start\n"); res = CANON_set_scan_parameters (&scanner->scan, optionCalibrateValue, #ifdef GRAY optionGrayscaleValue, #else SANE_FALSE, #endif SANE_UNFIX (optionTopLeftXValue) / MM_IN_INCH * 600, SANE_UNFIX (optionTopLeftYValue) / MM_IN_INCH * 600, SANE_UNFIX (optionBotRightXValue) / MM_IN_INCH * 600, SANE_UNFIX (optionBotRightYValue) / MM_IN_INCH * 600, optionResolutionValue, optionAGainValue, SANE_UNFIX (optionGammaValue)); if (res != SANE_STATUS_GOOD) return res; return CANON_start_scan (&scanner->scan); } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { Canon_Scanner *scanner = handle; return CANON_read (&scanner->scan, data, max_length, length); } void sane_cancel (SANE_Handle handle) { DBG (3, "sane_cancel: handle = %p\n", handle); DBG (3, "sane_cancel: cancelling is unsupported in this backend\n"); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { DBG (3, "sane_set_io_mode: handle = %p, non_blocking = %d\n", handle, non_blocking); if (non_blocking != SANE_FALSE) return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { handle = handle; /* silence gcc */ fd = fd; /* silence gcc */ return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/epsonds-cmd.h0000666000000000000000000000164613615534521015164 00000000000000/* * epsonds-cmd.h - Epson ESC/I-2 routines. * * Copyright (C) 2015 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. */ #ifndef epsonds_cmd_h #define epsonds_cmd_h SANE_Status esci2_info(epsonds_scanner *s); SANE_Status esci2_fin(epsonds_scanner *s); SANE_Status esci2_can(epsonds_scanner *s); SANE_Status esci2_capa(epsonds_scanner *s); SANE_Status esci2_resa(epsonds_scanner *s); SANE_Status esci2_stat(epsonds_scanner *s); SANE_Status esci2_para(epsonds_scanner *s, char *parameters); SANE_Status esci2_mech(epsonds_scanner *s, char *parameters); SANE_Status esci2_trdt(epsonds_scanner *s); SANE_Status esci2_img(struct epsonds_scanner *s, SANE_Int *length) ; #endif sane-backends-1.0.29/backend/sharp.h0000666000000000000000000002752213615534521014066 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1998, 1999 Kazuya Fukuda, Abel Deuring 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef sharp_h #define sharp_h 1 #include /* default values for configurable options. Though these options are only meaningful if USE_FORK is defined, they are DEFAULT_BUFFERS: number of buffers allocated as shared memory for the data transfer from reader_process to read_data. The minimum value is 2 DEFAULT_BUFSIZE: default size of one buffer. Must be greater than zero. DEFAULT_QUEUED_READS: number of read requests queued by sanei_scsi_req_enter. Since queued read requests are currently only supported for Linux and DomainOS, this value should automatically be set dependent on the target OS... For Linux, 2 is the optimum; for DomainOS, I don't have any recommendation; other OS should use the value zero. The value for DEFAULT_BUFSIZE is probably too Linux-oriented... */ #define DEFAULT_BUFFERS 12 #define DEFAULT_BUFSIZE 128 * 1024 #define DEFAULT_QUEUED_READS 2 typedef enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_HALFTONE, OPT_PAPER, OPT_SCANSOURCE, OPT_GAMMA, #ifdef USE_CUSTOM_GAMMA OPT_CUSTOM_GAMMA, #endif OPT_SPEED, OPT_RESOLUTION_GROUP, #ifdef USE_RESOLUTION_LIST OPT_RESOLUTION_LIST, #endif OPT_X_RESOLUTION, #ifdef USE_SEPARATE_Y_RESOLUTION OPT_Y_RESOLUTION, #endif OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_EDGE_EMPHASIS, OPT_THRESHOLD, #ifdef USE_COLOR_THRESHOLD OPT_THRESHOLD_R, OPT_THRESHOLD_G, OPT_THRESHOLD_B, #endif OPT_LIGHTCOLOR, OPT_PREVIEW, #ifdef USE_CUSTOM_GAMMA OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, #endif /* must come last: */ NUM_OPTIONS } SHARP_Option; #ifdef USE_FORK /* status defines for a buffer: buffer not used / read request queued / buffer contains data */ #define SHM_EMPTY 0 #define SHM_BUSY 1 #define SHM_FULL 2 typedef struct SHARP_shmem_ctl { int shm_status; /* can be SHM_EMPTY, SHM_BUSY, SHM_FULL */ size_t used; /* number of bytes successfully read from scanner */ size_t nreq; /* number of bytes requested from scanner */ size_t start; /* index of the begin of used area of the buffer */ void *qid; SANE_Byte *buffer; } SHARP_shmem_ctl; typedef struct SHARP_rdr_ctl { int cancel; /* 1 = flag for the reader process to cancel */ int running; /* 1 indicates that the reader process is alive */ SANE_Status status; /* return status of the reader process */ SHARP_shmem_ctl *buf_ctl; } SHARP_rdr_ctl; #endif /* USE_FORK */ typedef enum { /* JX250, JX330, JX350, JX610 are used as array indices, so the corresponding numbers should start at 0 */ unknown = -1, JX250, JX320, JX330, JX350, JX610 } SHARP_Model; typedef struct SHARP_Info { SANE_Range xres_range; SANE_Range yres_range; SANE_Range tl_x_ranges[3]; /* normal / FSU / ADF */ SANE_Range br_x_ranges[3]; /* normal / FSU / ADF */ SANE_Range tl_y_ranges[3]; /* normal / FSU / ADF */ SANE_Range br_y_ranges[3]; /* normal / FSU / ADF */ SANE_Range threshold_range; SANE_Int xres_default; SANE_Int yres_default; SANE_Int x_default; SANE_Int y_default; SANE_Int bmu; SANE_Int mud; SANE_Int adf_fsu_installed; SANE_String_Const scansources[5]; size_t buffers; size_t bufsize; int wanted_bufsize; size_t queued_reads; int complain_on_errors; /* default scan mode: -1 -> "automatic": Use the ADF, if installed, else use the FSU, if installed. or: SCAN_ADF, SCAN_FSU, SCAN_SIMPLE */ int default_scan_mode; } SHARP_Info; #define COMPLAIN_ON_FSU_ERROR 2 #define COMPLAIN_ON_ADF_ERROR 1 typedef struct SHARP_Sense_Data { SHARP_Model model; /* flag, if conditions like "paper jam" or "cover open" are considered as an error. Should be 0 for attach, else a frontend might refuse to start, if the scanner returns these errors. */ int complain_on_errors; /* Linux returns only 16 bytes of sense data... */ u_char sb[16]; } SHARP_Sense_Data; typedef struct SHARP_Device { struct SHARP_Device *next; SANE_Device sane; SHARP_Info info; /* xxx now part of sense data SHARP_Model model; */ SHARP_Sense_Data sensedat; } SHARP_Device; typedef struct SHARP_New_Device { struct SHARP_Device *dev; struct SHARP_New_Device *next; } SHARP_New_Device; typedef struct SHARP_Scanner { struct SHARP_Scanner *next; int fd; SHARP_Device *dev; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Parameters params; int get_params_called; SANE_Byte *buffer; /* for color data re-ordering, required for JX 250 */ SANE_Int buf_used; SANE_Int buf_pos; SANE_Int modes; SANE_Int xres; SANE_Int yres; SANE_Int ulx; SANE_Int uly; SANE_Int width; SANE_Int length; SANE_Int threshold; SANE_Int image_composition; SANE_Int bpp; SANE_Int halftone; SANE_Bool reverse; SANE_Bool speed; SANE_Int gamma; SANE_Int edge; SANE_Int lightcolor; SANE_Int adf_fsu_mode; /* mode selected by user */ SANE_Int adf_scan; /* flag, if the actual scan is an ADF scan */ size_t bytes_to_read; size_t max_lines_to_read; size_t unscanned_lines; SANE_Bool scanning; SANE_Bool busy; SANE_Bool cancel; #ifdef USE_CUSTOM_GAMMA SANE_Int gamma_table[4][256]; #endif #ifdef USE_FORK pid_t reader_pid; SHARP_rdr_ctl *rdr_ctl; int shmid; size_t read_buff; /* index of the buffer actually used by read_data */ #endif /* USE_FORK */ } SHARP_Scanner; typedef struct SHARP_Send { SANE_Int dtc; SANE_Int dtq; SANE_Int length; SANE_Byte *data; } SHARP_Send; typedef struct WPDH { u_char wpdh[6]; u_char wdl[2]; } WPDH; typedef struct WDB { SANE_Byte wid; SANE_Byte autobit; SANE_Byte x_res[2]; SANE_Byte y_res[2]; SANE_Byte x_ul[4]; SANE_Byte y_ul[4]; SANE_Byte width[4]; SANE_Byte length[4]; SANE_Byte brightness; SANE_Byte threshold; SANE_Byte null_1; SANE_Byte image_composition; SANE_Byte bpp; SANE_Byte ht_pattern[2]; SANE_Byte rif_padding; SANE_Byte null_2[4]; SANE_Byte null_3[6]; SANE_Byte eletu; SANE_Byte zooming_x[2]; SANE_Byte zooming_y[2]; SANE_Byte lightness_r[2]; SANE_Byte lightness_g[2]; SANE_Byte lightness_b[2]; SANE_Byte lightness_bw[2]; } WDB; /* "extension" of the window descriptor block for the JX 330 */ typedef struct WDBX330 { SANE_Byte moire_reduction[2]; } WDBX330; /* "extension" of the window descriptor block for the JX 250 */ typedef struct XWDBX250 { SANE_Byte threshold_red; SANE_Byte threshold_green; SANE_Byte threshold_blue; SANE_Byte draft; SANE_Byte scanning_time[4]; SANE_Byte fixed_gamma; SANE_Byte x_axis_res_qualifier[2]; SANE_Byte y_axis_res_qualifier[2]; } WDBX250; typedef struct window_param { WPDH wpdh; WDB wdb; WDBX330 wdbx330; WDBX250 wdbx250; } window_param; typedef struct mode_sense_param { SANE_Byte mode_data_length; SANE_Byte mode_param_header2; SANE_Byte mode_param_header3; SANE_Byte mode_desciptor_length; SANE_Byte resereved[5]; SANE_Byte blocklength[3]; SANE_Byte page_code; SANE_Byte page_length; /* 6 */ SANE_Byte bmu; SANE_Byte res2; SANE_Byte mud[2]; SANE_Byte res3; SANE_Byte res4; } mode_sense_param; typedef struct mode_sense_subdevice { /* This definition reflects the JX250. The JX330 would need a slightly different definition, but the bytes used right now (for ADF and FSU) are identical. */ SANE_Byte mode_data_length; SANE_Byte mode_param_header2; SANE_Byte mode_param_header3; SANE_Byte mode_desciptor_length; SANE_Byte res1[5]; SANE_Byte blocklength[3]; SANE_Byte page_code; SANE_Byte page_length; /* 0x1a */ SANE_Byte a_mode_type; SANE_Byte f_mode_type; SANE_Byte res2; SANE_Byte max_x[4]; SANE_Byte max_y[4]; SANE_Byte res3[2]; SANE_Byte x_basic_resolution[2]; SANE_Byte y_basic_resolution[2]; SANE_Byte x_max_resolution[2]; SANE_Byte y_max_resolution[2]; SANE_Byte x_min_resolution[2]; SANE_Byte y_min_resolution[2]; SANE_Byte res4; } mode_sense_subdevice; typedef struct mode_select_param { SANE_Byte mode_param_header1; SANE_Byte mode_param_header2; SANE_Byte mode_param_header3; SANE_Byte mode_param_header4; SANE_Byte page_code; SANE_Byte page_length; /* 6 */ SANE_Byte res1; SANE_Byte res2; SANE_Byte mud[2]; SANE_Byte res3; SANE_Byte res4; } mode_select_param; typedef struct mode_select_subdevice { SANE_Byte mode_param_header1; SANE_Byte mode_param_header2; SANE_Byte mode_param_header3; SANE_Byte mode_param_header4; SANE_Byte page_code; SANE_Byte page_length; /* 0x1A */ SANE_Byte a_mode; SANE_Byte f_mode; SANE_Byte res[24]; } mode_select_subdevice; /* SCSI commands */ #define TEST_UNIT_READY 0x00 #define REQUEST_SENSE 0x03 #define INQUIRY 0x12 #define MODE_SELECT6 0x15 #define RESERVE_UNIT 0x16 #define RELEASE_UNIT 0x17 #define MODE_SENSE6 0x1a #define SCAN 0x1b #define SEND_DIAGNOSTIC 0x1d #define SET_WINDOW 0x24 #define GET_WINDOW 0x25 #define READ 0x28 #define SEND 0x2a #define OBJECT_POSITION 0x31 #define SENSE_LEN 18 #define INQUIRY_LEN 36 #define MODEPARAM_LEN 12 #define MODE_SUBDEV_LEN 32 #define WINDOW_LEN 76 #endif /* not sharp_h */ sane-backends-1.0.29/backend/lexmark_low.c0000666000000000000000000053117713615534521015276 00000000000000/* lexmark-low.c: scanner-interface file for low Lexmark scanners. (C) 2005 Fred Odendaal (C) 2006-2013 Stéphane Voltz (C) 2010 "Torsten Houwaart" X74 support 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. **************************************************************************/ #undef BACKEND_NAME #define BACKEND_NAME lexmark_low #include "lexmark.h" #include "lexmark_sensors.c" #include "lexmark_models.c" /* numbre of ranges for offset */ #define OFFSET_RANGES 5 typedef enum { black = 0, white } region_type; #define HomeTolerance 32 #define LOBYTE(x) ((uint8_t)((x) & 0xFF)) #define HIBYTE(x) ((uint8_t)((x) >> 8)) /* Static low function proto-types */ static SANE_Status low_usb_bulk_write (SANE_Int devnum, SANE_Byte * cmd, size_t * size); static SANE_Status low_usb_bulk_read (SANE_Int devnum, SANE_Byte * buf, size_t * size); static SANE_Status low_write_all_regs (SANE_Int devnum, SANE_Byte * regs); static SANE_Bool low_is_home_line (Lexmark_Device * dev, unsigned char *buffer); static SANE_Status low_get_start_loc (SANE_Int resolution, SANE_Int * vert_start, SANE_Int * hor_start, SANE_Int offset, Lexmark_Device * dev); static void low_rewind (Lexmark_Device * dev, SANE_Byte * regs); static SANE_Status low_start_mvmt (SANE_Int devnum); static SANE_Status low_stop_mvmt (SANE_Int devnum); static SANE_Status low_clr_c6 (SANE_Int devnum); static SANE_Status low_simple_scan (Lexmark_Device * dev, SANE_Byte * regs, int xoffset, int pixels, int yoffset, int lines, SANE_Byte ** data); static void low_set_scan_area (SANE_Int res, SANE_Int tlx, SANE_Int tly, SANE_Int brx, SANE_Int bry, SANE_Int offset, SANE_Bool half_step, SANE_Byte * regs, Lexmark_Device * dev); /* Static Read Buffer Proto-types */ static SANE_Status read_buffer_init (Lexmark_Device * dev, int bytesperline); static SANE_Status read_buffer_free (Read_Buffer * rb); static size_t read_buffer_bytes_available (Read_Buffer * rb); static SANE_Status read_buffer_add_byte (Read_Buffer * rb, SANE_Byte * byte_pointer); static SANE_Status read_buffer_add_byte_gray (Read_Buffer * rb, SANE_Byte * byte_pointer); static SANE_Status read_buffer_add_bit_lineart (Read_Buffer * rb, SANE_Byte * byte_pointer, SANE_Byte threshold); static size_t read_buffer_get_bytes (Read_Buffer * rb, SANE_Byte * buffer, size_t rqst_size); static SANE_Bool read_buffer_is_empty (Read_Buffer * rb); /* * RTS88XX START * * these rts88xx functions will be spin off in a separate lib * so that they can be reused. */ /* * registers helpers to avoid direct access */ static SANE_Bool rts88xx_is_color (SANE_Byte * regs) { if ((regs[0x2f] & 0x11) == 0x11) return SANE_TRUE; return SANE_FALSE; } static void rts88xx_set_gray_scan (SANE_Byte * regs) { regs[0x2f] = (regs[0x2f] & 0x0f) | 0x20; } #if 0 static void rts88xx_set_color_scan (SANE_Byte * regs) { regs[0x2f] = (regs[0x2f] & 0x0f) | 0x10; } #endif static void rts88xx_set_offset (SANE_Byte * regs, SANE_Byte red, SANE_Byte green, SANE_Byte blue) { /* offset for odd pixels */ regs[0x02] = red; regs[0x03] = green; regs[0x04] = blue; /* offset for even pixels */ regs[0x05] = red; regs[0x06] = green; regs[0x07] = blue; } static void rts88xx_set_gain (SANE_Byte * regs, SANE_Byte red, SANE_Byte green, SANE_Byte blue) { regs[0x08] = red; regs[0x09] = green; regs[0x0a] = blue; } /* set # of head moves per CIS read */ static int rts88xx_set_scan_frequency (SANE_Byte * regs, int frequency) { regs[0x64] = (regs[0x64] & 0xf0) | (frequency & 0x0f); return 0; } /* * read one register at given index */ static SANE_Status rts88xx_read_reg (SANE_Int devnum, SANE_Int index, SANE_Byte * reg) { SANE_Status status = SANE_STATUS_GOOD; unsigned char cmd[] = { 0x80, 0x00, 0x00, 0x01 }; size_t size; cmd[1] = index; size = 4; #ifdef FAKE_USB status = SANE_STATUS_GOOD; #else status = sanei_usb_write_bulk (devnum, cmd, &size); #endif if (status != SANE_STATUS_GOOD) { DBG (5, "rts88xx_read_reg: bulk write failed\n"); return status; } size = 1; #ifdef FAKE_USB status = SANE_STATUS_GOOD; #else status = sanei_usb_read_bulk (devnum, reg, &size); #endif if (status != SANE_STATUS_GOOD) { DBG (5, "rts88xx_read_reg: bulk read failed\n"); return status; } DBG (15, "rts88xx_read_reg: reg[0x%02x]=0x%02x\n", index, *reg); return status; } /* * write one register at given index */ static SANE_Status rts88xx_write_reg (SANE_Int devnum, SANE_Int index, SANE_Byte * reg) { SANE_Status status = SANE_STATUS_GOOD; unsigned char cmd[] = { 0x88, 0x00, 0x00, 0x01 }; size_t size; cmd[1] = index; size = 4; #ifdef FAKE_USB status = SANE_STATUS_GOOD; #else status = sanei_usb_write_bulk (devnum, cmd, &size); #endif if (status != SANE_STATUS_GOOD) { DBG (5, "rts88xx_write_reg: bulk write failed\n"); return status; } size = 1; #ifdef FAKE_USB status = SANE_STATUS_GOOD; #else status = sanei_usb_write_bulk (devnum, reg, &size); #endif if (status != SANE_STATUS_GOOD) { DBG (5, "rts88xx_write_reg: bulk write failed\n"); return status; } DBG (15, "rts88xx_write_reg: reg[0x%02x]=0x%02x\n", index, *reg); return status; } /* * write length consecutive registers, starting at index * register 0xb3 is never wrote in bulk register write, so we split * write if it belongs to the register set sent */ static SANE_Status rts88xx_write_regs (SANE_Int devnum, SANE_Int start, SANE_Byte * source, SANE_Int length) { size_t size = 0; /* when writing several registers at a time, we avoid writing 0xb3 register */ if ((start + length > 0xb3) && (length > 1)) { size = 0xb3 - start; if (low_usb_bulk_write (devnum, source, &size) != SANE_STATUS_GOOD) { DBG (5, "rts88xx_write_regs : write registers part 1 failed ...\n"); return SANE_STATUS_IO_ERROR; } /* skip 0xB3 register */ size++; start = 0xb4; source = source + size; } size = length - size; if (low_usb_bulk_write (devnum, source, &size) != SANE_STATUS_GOOD) { DBG (5, "rts88xx_write_regs : write registers part 2 failed ...\n"); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /* * reads 'needed' bytes of scanned data into 'data'. Actual number of bytes get * is retruned in 'size' */ static SANE_Status rts88xx_read_data (SANE_Int devnum, size_t needed, SANE_Byte * data, size_t * size) { SANE_Byte read_cmd[] = { 0x91, 0x00, 0x00, 0x00 }; size_t cmd_size; SANE_Status status = SANE_STATUS_GOOD; /* this block would deserve to be a function */ if (needed > MAX_XFER_SIZE) *size = MAX_XFER_SIZE; else *size = needed; read_cmd[3] = (*size) & 0xff; read_cmd[2] = (*size >> 8) & 0xff; read_cmd[1] = (*size >> 16) & 0xff; /* send header for 'get scanned data' */ cmd_size = 4; status = low_usb_bulk_write (devnum, read_cmd, &cmd_size); if (status != SANE_STATUS_GOOD) { *size = 0; DBG (5, "rts88xx_read_data : header sending failed ...\n"); return status; } /* get actual scanned data */ status = low_usb_bulk_read (devnum, data, size); if (status != SANE_STATUS_GOOD) { *size = 0; DBG (5, "rts88xx_read_data : data reading failed ...\n"); } return status; } /* starts scan by sending color depth, stopping head, the starting it */ static SANE_Status rts88xx_commit (SANE_Int devnum, SANE_Byte depth) { SANE_Status status; SANE_Byte reg; DBG (2, "rts88xx_commit: start\n"); /* send color depth depth ?? * X1100 -> 0x0f * X1100/B2 -> 0x0d * X1200 -> 0x01 */ reg = depth; rts88xx_write_reg (devnum, 0x2c, ®); /* stop before starting */ low_stop_mvmt (devnum); /* effective start */ status = low_start_mvmt (devnum); DBG (2, "rts88xx_commit: end\n"); return status; } /* * RTS88XX END */ /* * sets the scanner idle */ static SANE_Status lexmark_low_set_idle (SANE_Int devnum) { SANE_Byte regs[14] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60 }; if (rts88xx_write_regs (devnum, 16, regs, 14) != SANE_STATUS_GOOD) { DBG (5, "lexmark_low_set_idle : register write failed ...\n"); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /* wake up scanner */ #if 0 static SANE_Status lexmark_low_wake_up (Lexmark_Device * dev) { SANE_Byte regs[5] = { 0x12, 0x14, 0x16, 0x18, 0x1a }; SANE_Byte values[5] = { 0x0f, 0x00, 0x07, 0x00, 0x00 }; int i; /* send the wake-up sequence, one reg at at time */ for (i = 0; i < 10; i++) { if (rts88xx_write_reg (dev->devnum, regs[i], values + i) != SANE_STATUS_GOOD) { DBG (5, "lexmark_low_wake_up : register write pass %d failed ...\n", i); return SANE_STATUS_IO_ERROR; } } return SANE_STATUS_GOOD; } #endif /** * */ #ifdef DEEP_DEBUG static void write_pnm_file (char *title, int pixels, int lines, int color, unsigned char *data) { FILE *fdbg; int x, y; fdbg = fopen (title, "wb"); if (fdbg == NULL) return; if (color) { fprintf (fdbg, "P6\n%d %d\n255\n", pixels, lines); for (y = 0; y < lines; y++) { for (x = 0; x < pixels; x += 2) { fputc (data[y * pixels * 3 + x + 1], fdbg); fputc (data[y * pixels * 3 + x + 1 + pixels], fdbg); fputc (data[y * pixels * 3 + x + 1 + pixels * 2], fdbg); fputc (data[y * pixels * 3 + x], fdbg); fputc (data[y * pixels * 3 + x + pixels], fdbg); fputc (data[y * pixels * 3 + x + pixels * 2], fdbg); } } } else { fprintf (fdbg, "P5\n%d %d\n255\n", pixels, lines); fwrite (data, pixels, lines, fdbg); } fclose (fdbg); } #endif /* * mid level hardware functions */ /* * model init */ SANE_Status sanei_lexmark_low_init (Lexmark_Device * dev) { int i; SANE_Status status; DBG_INIT (); status = SANE_STATUS_UNSUPPORTED; DBG (2, "low_init: start\n"); /* clear all registers first */ for (i = 0; i < 255; i++) { dev->shadow_regs[i] = 0; } /* set up per model constant values */ dev->shadow_regs[0xf3] = 0xf8; dev->shadow_regs[0xf4] = 0x7f; switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x00] = 0x04; dev->shadow_regs[0x01] = 0x43; dev->shadow_regs[0x0b] = 0x70; dev->shadow_regs[0x12] = 0x0f; dev->shadow_regs[0x16] = 0x07; dev->shadow_regs[0x1d] = 0x20; dev->shadow_regs[0x28] = 0xe0; dev->shadow_regs[0x29] = 0xe3; dev->shadow_regs[0x2a] = 0xeb; dev->shadow_regs[0x2b] = 0x0d; dev->shadow_regs[0x2e] = 0x40; dev->shadow_regs[0x2e] = 0x86; dev->shadow_regs[0x2f] = 0x01; dev->shadow_regs[0x30] = 0x48; dev->shadow_regs[0x31] = 0x06; dev->shadow_regs[0x33] = 0x01; dev->shadow_regs[0x34] = 0x50; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x50; dev->shadow_regs[0x37] = 0x01; dev->shadow_regs[0x38] = 0x50; dev->shadow_regs[0x3a] = 0x20; dev->shadow_regs[0x3c] = 0x88; dev->shadow_regs[0x3d] = 0x08; dev->shadow_regs[0x65] = 0x80; dev->shadow_regs[0x66] = 0x64; dev->shadow_regs[0x6c] = 0xc8; dev->shadow_regs[0x72] = 0x1a; dev->shadow_regs[0x74] = 0x23; dev->shadow_regs[0x75] = 0x03; dev->shadow_regs[0x79] = 0x40; dev->shadow_regs[0x7A] = 0x01; dev->shadow_regs[0x8d] = 0x01; dev->shadow_regs[0x8e] = 0x60; dev->shadow_regs[0x8f] = 0x80; dev->shadow_regs[0x93] = 0x02; dev->shadow_regs[0x94] = 0x0e; dev->shadow_regs[0xa3] = 0xcc; dev->shadow_regs[0xa4] = 0x27; dev->shadow_regs[0xa5] = 0x24; dev->shadow_regs[0xc2] = 0x80; dev->shadow_regs[0xc3] = 0x01; dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x0a; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x0a; dev->shadow_regs[0xe2] = 0x70; dev->shadow_regs[0xe3] = 0x17; dev->shadow_regs[0xf3] = 0xe0; dev->shadow_regs[0xf4] = 0xff; dev->shadow_regs[0xf5] = 0x01; status = SANE_STATUS_GOOD; break; case X1100_B2_SENSOR: dev->shadow_regs[0x01] = 0x43; dev->shadow_regs[0x0b] = 0x70; dev->shadow_regs[0x11] = 0x01; dev->shadow_regs[0x12] = 0x0f; dev->shadow_regs[0x13] = 0x01; dev->shadow_regs[0x15] = 0x01; dev->shadow_regs[0x16] = 0x0f; dev->shadow_regs[0x1d] = 0x20; dev->shadow_regs[0x28] = 0xeb; dev->shadow_regs[0x29] = 0xee; dev->shadow_regs[0x2a] = 0xf7; dev->shadow_regs[0x2b] = 0x01; dev->shadow_regs[0x2e] = 0x86; dev->shadow_regs[0x30] = 0x48; dev->shadow_regs[0x33] = 0x01; dev->shadow_regs[0x3a] = 0x20; dev->shadow_regs[0x3b] = 0x37; dev->shadow_regs[0x3c] = 0x88; dev->shadow_regs[0x3d] = 0x08; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x72] = 0x05; dev->shadow_regs[0x74] = 0x0e; dev->shadow_regs[0x8b] = 0xff; dev->shadow_regs[0x8c] = 0x02; dev->shadow_regs[0x8d] = 0x01; dev->shadow_regs[0x8e] = 0x60; dev->shadow_regs[0x8f] = 0x80; dev->shadow_regs[0x94] = 0x0e; dev->shadow_regs[0xa3] = 0xcc; dev->shadow_regs[0xa4] = 0x27; dev->shadow_regs[0xa5] = 0x24; dev->shadow_regs[0xb0] = 0xb2; dev->shadow_regs[0xb2] = 0x04; dev->shadow_regs[0xc2] = 0x80; dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x3b; dev->shadow_regs[0xed] = 0xc2; dev->shadow_regs[0xee] = 0x02; status = SANE_STATUS_GOOD; break; case X1100_2C_SENSOR: dev->shadow_regs[0x00] = 0x00; dev->shadow_regs[0x01] = 0x43; dev->shadow_regs[0x0b] = 0x70; dev->shadow_regs[0x0c] = 0x28; dev->shadow_regs[0x0d] = 0xa4; dev->shadow_regs[0x11] = 0x01; dev->shadow_regs[0x12] = 0x0f; dev->shadow_regs[0x13] = 0x01; dev->shadow_regs[0x15] = 0x01; dev->shadow_regs[0x16] = 0x0f; dev->shadow_regs[0x17] = 0x00; dev->shadow_regs[0x1d] = 0x20; dev->shadow_regs[0x28] = 0xf5; dev->shadow_regs[0x29] = 0xf7; dev->shadow_regs[0x2a] = 0xf5; dev->shadow_regs[0x2b] = 0x17; dev->shadow_regs[0x2d] = 0x41; dev->shadow_regs[0x2e] = 0x86; dev->shadow_regs[0x2f] = 0x11; dev->shadow_regs[0x30] = 0x48; dev->shadow_regs[0x31] = 0x01; dev->shadow_regs[0x33] = 0x01; dev->shadow_regs[0x34] = 0x50; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x50; dev->shadow_regs[0x37] = 0x01; dev->shadow_regs[0x38] = 0x50; dev->shadow_regs[0x3a] = 0x20; dev->shadow_regs[0x3b] = 0x37; dev->shadow_regs[0x3c] = 0x88; dev->shadow_regs[0x3d] = 0x08; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x47] = 0x01; dev->shadow_regs[0x48] = 0x1a; dev->shadow_regs[0x49] = 0x5b; dev->shadow_regs[0x4a] = 0x1b; dev->shadow_regs[0x4b] = 0x5b; dev->shadow_regs[0x4c] = 0x05; dev->shadow_regs[0x4d] = 0x3f; dev->shadow_regs[0x60] = 0x2f; dev->shadow_regs[0x61] = 0x36; dev->shadow_regs[0x62] = 0x30; dev->shadow_regs[0x63] = 0x36; dev->shadow_regs[0x65] = 0x80; dev->shadow_regs[0x66] = 0x64; dev->shadow_regs[0x6c] = 0xc8; dev->shadow_regs[0x6d] = 0x00; dev->shadow_regs[0x72] = 0x35; dev->shadow_regs[0x74] = 0x4e; dev->shadow_regs[0x75] = 0x03; dev->shadow_regs[0x79] = 0x40; dev->shadow_regs[0x7a] = 0x01; dev->shadow_regs[0x85] = 0x02; dev->shadow_regs[0x86] = 0x33; dev->shadow_regs[0x87] = 0x0f; dev->shadow_regs[0x88] = 0x24; dev->shadow_regs[0x8b] = 0xff; dev->shadow_regs[0x8c] = 0x02; dev->shadow_regs[0x8d] = 0x01; dev->shadow_regs[0x8e] = 0x60; dev->shadow_regs[0x8f] = 0x80; dev->shadow_regs[0x91] = 0x19; dev->shadow_regs[0x92] = 0x20; dev->shadow_regs[0x93] = 0x02; dev->shadow_regs[0x94] = 0x0e; dev->shadow_regs[0xa3] = 0x0d; dev->shadow_regs[0xa4] = 0x5e; dev->shadow_regs[0xa5] = 0x23; dev->shadow_regs[0xb0] = 0x2c; dev->shadow_regs[0xb1] = 0x07; dev->shadow_regs[0xb2] = 0x04; dev->shadow_regs[0xc2] = 0x80; dev->shadow_regs[0xc3] = 0x01; dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x0a; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x3b; dev->shadow_regs[0xca] = 0x0a; dev->shadow_regs[0xe2] = 0xf8; dev->shadow_regs[0xe3] = 0x2a; status = SANE_STATUS_GOOD; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x01] = 0x43; dev->shadow_regs[0x11] = 0x01; dev->shadow_regs[0x12] = 0x0f; dev->shadow_regs[0x13] = 0x01; dev->shadow_regs[0x15] = 0x01; dev->shadow_regs[0x16] = 0x0f; dev->shadow_regs[0x17] = 0x00; dev->shadow_regs[0x1d] = 0x20; dev->shadow_regs[0x28] = 0xf5; dev->shadow_regs[0x29] = 0xf7; dev->shadow_regs[0x2a] = 0xf5; dev->shadow_regs[0x2b] = 0x17; dev->shadow_regs[0x2d] = 0x41; dev->shadow_regs[0x2e] = 0x86; dev->shadow_regs[0x30] = 0x48; dev->shadow_regs[0x31] = 0x01; dev->shadow_regs[0x33] = 0x01; dev->shadow_regs[0x34] = 0x50; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x50; dev->shadow_regs[0x37] = 0x01; dev->shadow_regs[0x38] = 0x50; dev->shadow_regs[0x3c] = 0x88; dev->shadow_regs[0x3d] = 0x08; dev->shadow_regs[0x66] = 0x64; dev->shadow_regs[0x67] = 0x00; dev->shadow_regs[0x6c] = 0xc8; dev->shadow_regs[0x6d] = 0x00; dev->shadow_regs[0x72] = 0x35; dev->shadow_regs[0x74] = 0x4e; dev->shadow_regs[0x75] = 0x03; dev->shadow_regs[0x7a] = 0x01; dev->shadow_regs[0x93] = 0x0a; dev->shadow_regs[0x94] = 0x0e; dev->shadow_regs[0xc3] = 0x01; dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x0a; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x3b; dev->shadow_regs[0xca] = 0x0a; dev->shadow_regs[0xe2] = 0xf8; dev->shadow_regs[0xe3] = 0x2a; status = SANE_STATUS_GOOD; break; case A920_SENSOR: dev->shadow_regs[0x01] = 0x43; dev->shadow_regs[0x0b] = 0x70; dev->shadow_regs[0x0c] = 0x28; dev->shadow_regs[0x0d] = 0xa4; dev->shadow_regs[0x11] = 0x01; dev->shadow_regs[0x12] = 0x0f; dev->shadow_regs[0x13] = 0x01; dev->shadow_regs[0x15] = 0x01; dev->shadow_regs[0x16] = 0x07; dev->shadow_regs[0x1d] = 0x20; dev->shadow_regs[0x28] = 0xf5; dev->shadow_regs[0x29] = 0xf7; dev->shadow_regs[0x2a] = 0xf5; dev->shadow_regs[0x2b] = 0x17; dev->shadow_regs[0x2e] = 0x86; dev->shadow_regs[0x30] = 0x48; dev->shadow_regs[0x31] = 0x01; dev->shadow_regs[0x33] = 0x01; dev->shadow_regs[0x3a] = 0x20; dev->shadow_regs[0x3b] = 0x37; dev->shadow_regs[0x3c] = 0x88; dev->shadow_regs[0x3d] = 0x08; dev->shadow_regs[0x47] = 0x21; dev->shadow_regs[0x48] = 0x1a; dev->shadow_regs[0x49] = 0x5b; dev->shadow_regs[0x4a] = 0x1b; dev->shadow_regs[0x4b] = 0x5b; dev->shadow_regs[0x4c] = 0x05; dev->shadow_regs[0x4d] = 0x3f; dev->shadow_regs[0x65] = 0x80; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x89] = 0xf5; dev->shadow_regs[0x8d] = 0x01; dev->shadow_regs[0x8e] = 0x60; dev->shadow_regs[0x8f] = 0x80; dev->shadow_regs[0x94] = 0x0e; dev->shadow_regs[0xa3] = 0x0d; dev->shadow_regs[0xa4] = 0x5e; dev->shadow_regs[0xa5] = 0x23; dev->shadow_regs[0xb0] = 0x2c; dev->shadow_regs[0xb1] = 0x0f; dev->shadow_regs[0xc2] = 0x80; dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc8] = 0x04; status = SANE_STATUS_GOOD; break; case X1200_SENSOR: dev->shadow_regs[0x01] = 0x43; dev->shadow_regs[0x0b] = 0x70; dev->shadow_regs[0x0c] = 0x28; dev->shadow_regs[0x0d] = 0xa4; dev->shadow_regs[0x11] = 0x01; dev->shadow_regs[0x12] = 0x0f; dev->shadow_regs[0x13] = 0x01; dev->shadow_regs[0x15] = 0x01; dev->shadow_regs[0x16] = 0x0f; dev->shadow_regs[0x1d] = 0x20; dev->shadow_regs[0x28] = 0xe9; dev->shadow_regs[0x29] = 0xeb; dev->shadow_regs[0x2a] = 0xe9; dev->shadow_regs[0x2b] = 0x0b; dev->shadow_regs[0x2d] = 0x01; dev->shadow_regs[0x2e] = 0x86; dev->shadow_regs[0x2f] = 0x11; dev->shadow_regs[0x30] = 0x48; dev->shadow_regs[0x33] = 0x01; dev->shadow_regs[0x34] = 0x50; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x50; dev->shadow_regs[0x37] = 0x01; dev->shadow_regs[0x38] = 0x50; dev->shadow_regs[0x3a] = 0x20; dev->shadow_regs[0x3b] = 0x37; dev->shadow_regs[0x3c] = 0x88; dev->shadow_regs[0x3d] = 0x08; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x47] = 0x01; dev->shadow_regs[0x48] = 0x1a; dev->shadow_regs[0x49] = 0x5b; dev->shadow_regs[0x4a] = 0x1b; dev->shadow_regs[0x4b] = 0x5b; dev->shadow_regs[0x4c] = 0x05; dev->shadow_regs[0x4d] = 0x3f; dev->shadow_regs[0x60] = 0x12; dev->shadow_regs[0x62] = 0x81; dev->shadow_regs[0x63] = 0x03; dev->shadow_regs[0x65] = 0x80; dev->shadow_regs[0x66] = 0x64; dev->shadow_regs[0x6c] = 0xc8; dev->shadow_regs[0x72] = 0x1e; dev->shadow_regs[0x74] = 0x3c; dev->shadow_regs[0x75] = 0x03; dev->shadow_regs[0x79] = 0x40; dev->shadow_regs[0x7a] = 0x01; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x1e; dev->shadow_regs[0x87] = 0x39; dev->shadow_regs[0x8b] = 0xff; dev->shadow_regs[0x8c] = 0x02; dev->shadow_regs[0x8d] = 0x01; dev->shadow_regs[0x8e] = 0x60; dev->shadow_regs[0x8f] = 0x80; dev->shadow_regs[0x92] = 0x92; dev->shadow_regs[0x93] = 0x02; dev->shadow_regs[0x94] = 0x0e; dev->shadow_regs[0xa3] = 0x0d; dev->shadow_regs[0xa4] = 0x5e; dev->shadow_regs[0xa5] = 0x23; dev->shadow_regs[0xb0] = 0x2c; dev->shadow_regs[0xb1] = 0x07; dev->shadow_regs[0xb2] = 0x04; dev->shadow_regs[0xc2] = 0x80; dev->shadow_regs[0xc3] = 0x01; dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x0a; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x3b; dev->shadow_regs[0xca] = 0x0a; dev->shadow_regs[0xe2] = 0xf8; dev->shadow_regs[0xe3] = 0x2a; dev->shadow_regs[0xf3] = 0xff; dev->shadow_regs[0xf4] = 0x0f; break; } DBG (5, "sanei_lexmark_low_init: init done for model %s/%s\n", dev->model.model, dev->model.name); DBG (2, "low_init: done\n"); return status; } void sanei_lexmark_low_destroy (Lexmark_Device * dev) { /* free the read buffer */ if (dev->read_buffer != NULL) read_buffer_free (dev->read_buffer); } SANE_Status low_usb_bulk_write (SANE_Int devnum, SANE_Byte * cmd, size_t * size) { SANE_Status status; size_t cmd_size; cmd_size = *size; #ifdef FAKE_USB status = SANE_STATUS_GOOD; #else status = sanei_usb_write_bulk (devnum, cmd, size); #endif if (status != SANE_STATUS_GOOD) { DBG (5, "low_usb_bulk_write: returned %s (size = %lu, expected %lu)\n", sane_strstatus (status), (u_long) * size, (u_long) cmd_size); /* F.O. should reset the pipe here... */ } return status; } SANE_Status low_usb_bulk_read (SANE_Int devnum, SANE_Byte * buf, size_t * size) { SANE_Status status; size_t exp_size; exp_size = *size; #ifdef FAKE_USB status = SANE_STATUS_GOOD; #else status = sanei_usb_read_bulk (devnum, buf, size); #endif if (status != SANE_STATUS_GOOD) { DBG (5, "low_usb_bulk_read: returned %s (size = %lu, expected %lu)\n", sane_strstatus (status), (u_long) * size, (u_long) exp_size); /* F.O. should reset the pipe here... */ } DBG (7, "low_usb_bulk_read: returned size = %lu (required %lu)\n", (u_long) * size, (u_long) exp_size); return status; } SANE_Status low_start_mvmt (SANE_Int devnum) { SANE_Status status; SANE_Byte reg; reg = 0x68; rts88xx_write_reg (devnum, 0xb3, ®); status = rts88xx_write_reg (devnum, 0xb3, ®); return status; } SANE_Status low_stop_mvmt (SANE_Int devnum) { SANE_Status status; SANE_Byte reg; /* Stop scanner - clear reg 0xb3: */ reg = 0x02; rts88xx_write_reg (devnum, 0xb3, ®); rts88xx_write_reg (devnum, 0xb3, ®); reg = 0x00; rts88xx_write_reg (devnum, 0xb3, ®); status = rts88xx_write_reg (devnum, 0xb3, ®); return status; } SANE_Status low_clr_c6 (SANE_Int devnum) { SANE_Status status; SANE_Byte reg; /* Clear register 0xC6 */ /* cmd_size = 0x05; return low_usb_bulk_write (devnum, clearC6_command_block, &cmd_size); */ reg = 0x00; status = rts88xx_write_reg (devnum, 0xc6, ®); return status; } /* stops current scan */ static SANE_Status low_cancel (SANE_Int devnum) { SANE_Status status; DBG (2, "low_cancel: start\n"); status = low_stop_mvmt (devnum); if (status != SANE_STATUS_GOOD) return status; status = low_clr_c6 (devnum); if (status != SANE_STATUS_GOOD) return status; DBG (2, "low_cancel: end.\n"); return status; } static SANE_Status low_start_scan (SANE_Int devnum, SANE_Byte * regs) { SANE_Status status; DBG (2, "low_start_scan: start\n"); /* writes registers to scanner */ regs[0x32] = 0x00; status = low_write_all_regs (devnum, regs); if (status != SANE_STATUS_GOOD) return status; regs[0x32] = 0x40; status = low_write_all_regs (devnum, regs); if (status != SANE_STATUS_GOOD) return status; /* Stop scanner - clear reg 0xb3: */ /* status = low_stop_mvmt (devnum); if (status != SANE_STATUS_GOOD) return status; */ /* then start */ status = rts88xx_commit (devnum, regs[0x2c]); DBG (2, "low_start_scan: end.\n"); return status; } /* wait for scan data being available */ static SANE_Status low_poll_data (SANE_Int devnum) { SANE_Status status; int loops = 0; size_t size; static SANE_Byte command4_block[] = { 0x90, 0x00, 0x00, 0x03 }; SANE_Byte result[3]; SANE_Word count; /* Poll the available byte count until not 0 */ while (loops < 1000) { /* 10 ms sleep */ usleep (10000); /* as stated in sanei_lexmark_low_search_home_bwd, we read * available data count twice */ size = 4; status = low_usb_bulk_write (devnum, command4_block, &size); if (status != SANE_STATUS_GOOD) return status; size = 0x3; status = low_usb_bulk_read (devnum, result, &size); if (status != SANE_STATUS_GOOD) return status; size = 4; /* read availbale data size again */ status = low_usb_bulk_write (devnum, command4_block, &size); if (status != SANE_STATUS_GOOD) return status; size = 0x3; status = low_usb_bulk_read (devnum, result, &size); if (status != SANE_STATUS_GOOD) return status; count = result[0] + (result[1] << 8) + (result[2] << 16); if (count != 0) { DBG (15, "low_poll_data: %d bytes available\n", count); return SANE_STATUS_GOOD; } loops++; } return SANE_STATUS_IO_ERROR; } /** * do a simple scan with the given registers. data buffer is allocated within * the function */ static SANE_Status low_simple_scan (Lexmark_Device * dev, SANE_Byte * regs, int xoffset, int pixels, int yoffset, int lines, SANE_Byte ** data) { SANE_Status status = SANE_STATUS_GOOD; static SANE_Byte reg; size_t size, read, needed; int i, bpl, yend; DBG (2, "low_simple_scan: start\n"); DBG (15, "low_simple_scan: x=%d, pixels=%d (ex=%d), y=%d, lines=%d\n", xoffset, pixels, xoffset + pixels * regs[0x7a], yoffset, lines); /* set up registers */ regs[0x60] = LOBYTE (yoffset); regs[0x61] = HIBYTE (yoffset); yend = yoffset + lines; if ((dev->model.motor_type == A920_MOTOR || dev->model.motor_type == X74_MOTOR) && rts88xx_is_color (regs) && dev->val[OPT_RESOLUTION].w == 600) yend *= 2; regs[0x62] = LOBYTE (yend); regs[0x63] = HIBYTE (yend); regs[0x66] = LOBYTE (xoffset); regs[0x67] = HIBYTE (xoffset); regs[0x6c] = LOBYTE (xoffset + pixels * regs[0x7a]); regs[0x6d] = HIBYTE (xoffset + pixels * regs[0x7a]); /* allocate memory */ if (rts88xx_is_color (regs)) bpl = 3 * pixels; else bpl = pixels; *data = (SANE_Byte *) malloc (bpl * lines); if (*data == NULL) { DBG (2, "low_simple_scan: failed to allocate %d bytes !\n", bpl * lines); return SANE_STATUS_NO_MEM; } /* start scan */ status = low_cancel (dev->devnum); if (status != SANE_STATUS_GOOD) return status; status = low_start_scan (dev->devnum, regs); if (status != SANE_STATUS_GOOD) return status; /* wait for data */ status = low_poll_data (dev->devnum); if (status != SANE_STATUS_GOOD) { DBG (1, "low_simple_scan: time-out while waiting for data.\n"); return status; } /* data reading loop */ needed = bpl * lines; DBG (1, "low_simple_scan: bpl=%d, lines=%d, needed=%lu.\n", bpl, lines, (u_long) needed); read = 0; do { /* this block would deserve to be a function */ status = rts88xx_read_data (dev->devnum, needed - read, (*data) + read, &size); if (status != SANE_STATUS_GOOD) return status; read += size; } while (read < needed); /* if needed, wait for motor to stop */ if (regs[0xc3] & 0x80) { i = 0; do { if (rts88xx_read_reg (dev->devnum, 0xb3, ®) != SANE_STATUS_GOOD) { DBG (5, "low_simple_scan: register read failed ...\n"); return SANE_STATUS_IO_ERROR; } usleep (100000); i++; } while ((reg & 0x08) && (i < 100)); if (reg & 0x08) { DBG (5, "low_simple_scan : timeout waiting for motor to stop ...\n"); return SANE_STATUS_IO_ERROR; } } /* stop scan */ status = low_cancel (dev->devnum); if (status != SANE_STATUS_GOOD) { DBG (1, "low_simple_scan: cancel failed.\n"); return status; } DBG (2, "low_simple_scan: end.\n"); return status; } /* * open USB device ,read initial registers values and probe sensor */ SANE_Status sanei_lexmark_low_open_device (Lexmark_Device * dev) { /* This function calls the Sane Interface to open this usb device. It also needlessly does what the Windows driver does and reads the entire register set - this may be removed. */ SANE_Status result; static SANE_Byte command_block[] = { 0x80, 0, 0x00, 0xFF }; size_t size; SANE_Byte variant = 0; SANE_Byte shadow_regs[255]; int sx, ex; int sy, ey; int i; char msg[2048]; #ifdef FAKE_USB result = SANE_STATUS_GOOD; shadow_regs[0x00] = 0x91; shadow_regs[0xb0] = 0x2c; shadow_regs[0x10] = 0x97; shadow_regs[0x10] = 0x87; shadow_regs[0xf3] = 0xf8; shadow_regs[0xf4] = 0x7f; #else result = sanei_usb_open (dev->sane.name, &(dev->devnum)); #endif DBG (2, "sanei_lexmark_low_open_device: devnum=%d\n", dev->devnum); size = 4; low_usb_bulk_write (dev->devnum, command_block, &size); size = 0xFF; memset (shadow_regs, 0, sizeof (shadow_regs)); low_usb_bulk_read (dev->devnum, shadow_regs, &size); if (DBG_LEVEL > 2) { DBG (2, "sanei_lexmark_low_open_device: initial registers values\n"); for (i = 0; i < 255; i++) { sprintf (msg + i * 5, "0x%02x ", shadow_regs[i]); } DBG (3, "%s\n", msg); } /* it seems that at first read after reset, registers hold information * about the scanner. Register 0x00 is overwritten with 0, so only first read * after USB plug-in gives this value */ if (shadow_regs[0] == 0x91) { sx = shadow_regs[0x67] * 256 + shadow_regs[0x66]; ex = shadow_regs[0x6d] * 256 + shadow_regs[0x6c]; DBG (7, "startx=%d, endx=%d, pixels=%d, coef=%d, r2f=0x%02x\n", sx, ex, ex - sx, dev->shadow_regs[0x7a], shadow_regs[0x2f]); sy = shadow_regs[0x61] * 256 + shadow_regs[0x60]; ey = shadow_regs[0x63] * 256 + shadow_regs[0x62]; DBG (7, "starty=%d, endy=%d, lines=%d\n", sy, ey, ey - sy); } /* we use register 0xb0 to identify details about models */ /* this register isn't overwritten during normal operation */ if (shadow_regs[0xb0] == 0x2c && dev->model.sensor_type == X1100_B2_SENSOR) { variant = shadow_regs[0xb0]; } /* now the same with register 0x10 */ /* which most likely signals USB2.0/USB1.1 */ if ((dev->model.sensor_type == X1200_SENSOR) && (shadow_regs[0x10] == 0x97)) { variant = shadow_regs[0x10]; } /* if find a case where default model given is inappropriate, reassign it * since we have now the informations to get the real one. * We could avoid this if attach() did open and read registers, not init */ if (variant != 0) { DBG (3, "sanei_lexmark_low_open_device: reassign model/sensor for variant 0x%02x\n", variant); sanei_lexmark_low_assign_model (dev, dev->sane.name, dev->model.vendor_id, dev->model.product_id, variant); /* since model has changed, run init again */ sanei_lexmark_low_init (dev); } DBG (2, "sanei_lexmark_low_open_device: end\n"); return result; } void sanei_lexmark_low_close_device (Lexmark_Device * dev) { /* put scanner in idle state */ lexmark_low_set_idle (dev->devnum); /* This function calls the Sane USB library to close this usb device */ #ifndef FAKE_USB sanei_usb_close (dev->devnum); #endif return; } /* This function writes the contents of the given registers to the scanner. */ SANE_Status low_write_all_regs (SANE_Int devnum, SANE_Byte * regs) { int i; SANE_Status status; size_t size; static SANE_Byte command_block1[0xb7]; static SANE_Byte command_block2[0x4f]; command_block1[0] = 0x88; command_block1[1] = 0x00; command_block1[2] = 0x00; command_block1[3] = 0xb3; for (i = 0; i < 0xb3; i++) { command_block1[i + 4] = regs[i]; } command_block2[0] = 0x88; command_block2[1] = 0xb4; command_block2[2] = 0x00; command_block2[3] = 0x4b; for (i = 0; i < 0x4b; i++) { command_block2[i + 4] = regs[i + 0xb4]; } size = 0xb7; #ifdef DEEP_DEBUG fprintf (stderr, "write_all(0x00,255)="); for (i = 0; i < 255; i++) { fprintf (stderr, "0x%02x ", regs[i]); } fprintf (stderr, "\n"); #endif status = low_usb_bulk_write (devnum, command_block1, &size); if (status != SANE_STATUS_GOOD) return status; size = 0x4f; status = low_usb_bulk_write (devnum, command_block2, &size); if (status != SANE_STATUS_GOOD) return status; return SANE_STATUS_GOOD; } SANE_Bool low_is_home_line (Lexmark_Device * dev, unsigned char *buffer) { /* This function assumes the buffer has a size of 2500 bytes.It is destructive to the buffer. Here is what it does: Go through the buffer finding low and high values, which are computed by comparing to the average: average = (lowest value + highest value)/2 High bytes are changed to 0xFF (white), lower or equal bytes are changed to 0x00 (black),so that the buffer only contains white (0xFF) or black (0x00) values. Next, we go through the buffer. We use a tolerance of 5 bytes on each end of the buffer and check a region from bytes 5 to 2495. We start assuming we are in a white region and look for the start of a black region. We save this index as the transition from white to black. We also save where we change from black back to white. We continue checking for transitions until the end of the check region. If we don't have exactly two transitions when we reach the end we return SANE_FALSE. The final check compares the transition indices to the nominal values plus or minus the tolerence. For the first transition (white to black index) the value must lie in the range 1235-30 (1205) to 1235+30 (1265). For the second transition (black to white) the value must lie in the range 1258-30 (1228) to 1258+30 (1288). If the indices are out of range we return SANE_FALSE. Otherwise, we return SANE_TRUE. */ unsigned char max_byte = 0; unsigned char min_byte = 0xFF; unsigned char average; int i; int home_point1; int home_point2; region_type region; int transition_counter; int index1 = 0; int index2 = 0; int low_range, high_range; #ifdef DEEP_DEBUG static int numero = 0; char titre[80]; FILE *trace = NULL; sprintf (titre, "lgn%03d.pnm", numero); trace = fopen (titre, "wb"); if (trace) { fprintf (trace, "P5\n2500 1\n255\n"); fwrite (buffer, 2500, 1, trace); fclose (trace); } numero++; #endif DBG (15, "low_is_home_line: start\n"); /* Find the max and the min */ for (i = 0; i < 2500; i++) { if (*(buffer + i) > max_byte) max_byte = *(buffer + i); if (*(buffer + i) < min_byte) min_byte = *(buffer + i); } /* The average */ average = ((max_byte + min_byte) / 2); /* Set bytes as white (0xFF) or black (0x00) */ for (i = 0; i < 2500; i++) { if (*(buffer + i) > average) *(buffer + i) = 0xFF; else *(buffer + i) = 0x00; } region = white; transition_counter = 0; /* Go through the check region - bytes 5 to 2495 */ /* XXX STEF XXX shrink the area to where the dot should be * +-100 around the 1250 expected location */ for (i = 1150; i <= 1350; i++) { /* Check for transition to black */ if ((region == white) && (*(buffer + i) == 0)) { if (transition_counter < 2) { region = black; index1 = i; transition_counter++; } else { DBG (15, "low_is_home_line: no transition to black \n"); return SANE_FALSE; } } /* Check for transition to white */ else if ((region == black) && (*(buffer + i) == 0xFF)) { if (transition_counter < 2) { region = white; index2 = i; transition_counter++; } else { DBG (15, "low_is_home_line: no transition to white \n"); return SANE_FALSE; } } } /* Check that the number of transitions is 2 */ if (transition_counter != 2) { DBG (15, "low_is_home_line: transitions!=2 (%d)\n", transition_counter); return SANE_FALSE; } /* Check that the 1st index is in range */ home_point1 = dev->model.HomeEdgePoint1; low_range = home_point1 - HomeTolerance; high_range = home_point1 + HomeTolerance; if ((index1 < low_range) || (index1 > high_range)) { DBG (15, "low_is_home_line: index1=%d out of range\n", index1); return SANE_FALSE; } /* Check that the 2nd index is in range */ home_point2 = dev->model.HomeEdgePoint2; low_range = home_point2 - HomeTolerance; high_range = home_point2 + HomeTolerance; if ((index2 < low_range) || (index2 > high_range)) { DBG (15, "low_is_home_line: index2=%d out of range.\n", index2); return SANE_FALSE; } /* We made it this far, so its a good home line. Return True */ DBG (15, "low_is_home_line: success\n"); return SANE_TRUE; } void sanei_lexmark_low_move_fwd (SANE_Int distance, Lexmark_Device * dev, SANE_Byte * regs) { /* This function moves the scan head forward with the highest vertical resolution of 1200dpi. The distance moved is given by the distance parameter. As an example, given a distance parameter of 600, the scan head will move 600/1200", or 1/2" forward. */ static SANE_Byte pollstopmoving_command_block[] = { 0x80, 0xb3, 0x00, 0x01 }; size_t cmd_size; SANE_Int devnum; SANE_Bool scan_head_moving; SANE_Byte read_result; DBG (2, "sanei_lexmark_low_move_fwd: \n"); devnum = dev->devnum; /* registers set-up */ regs[0x2c] = 0x00; regs[0x2d] = 0x41; regs[0x65] = 0x80; switch (dev->model.sensor_type) { case X74_SENSOR: rts88xx_set_scan_frequency (regs, 0); regs[0x93] = 0x06; break; case X1100_B2_SENSOR: regs[0x8b] = 0x00; regs[0x8c] = 0x00; regs[0x93] = 0x06; break; case X1100_2C_SENSOR: rts88xx_set_scan_frequency (regs, 0); regs[0x93] = 0x06; break; case A920_SENSOR: rts88xx_set_scan_frequency (regs, 0); regs[0x8b] = 0xff; regs[0x8c] = 0x02; regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x2d] = 0x01; rts88xx_set_scan_frequency (regs, 0); break; case X1200_USB2_SENSOR: dev->shadow_regs[0x2d] = 0x4f; rts88xx_set_scan_frequency (regs, 0); break; } /* set grayscale scan + nodata/nochannel? */ regs[0x2f] = 0xa1; /* set ? */ regs[0x34] = 0x50; regs[0x35] = 0x01; regs[0x36] = 0x50; regs[0x37] = 0x01; regs[0x38] = 0x50; /* set motor resolution divisor */ regs[0x39] = 0x00; /* set vertical start/end positions */ regs[0x60] = LOBYTE (distance - 1); regs[0x61] = HIBYTE (distance - 1); regs[0x62] = LOBYTE (distance); regs[0x63] = HIBYTE (distance); /* set horizontal start position */ regs[0x66] = 0x64; regs[0x67] = 0x00; /* set horizontal end position */ regs[0x6c] = 0xc8; regs[0x6d] = 0x00; /* set horizontal resolution */ regs[0x79] = 0x40; regs[0x7a] = 0x01; /* don't buffer data for this scan */ regs[0xb2] = 0x04; /* Motor enable & Coordinate space denominator */ regs[0xc3] = 0x81; /* Movement direction & step size */ regs[0xc6] = 0x09; /* ? */ regs[0x80] = 0x00; regs[0x81] = 0x00; regs[0x82] = 0x00; regs[0xc5] = 0x0a; switch (dev->model.motor_type) { case X1100_MOTOR: case A920_MOTOR: /* step size range2 */ regs[0xc9] = 0x3b; /* ? */ regs[0xca] = 0x0a; /* motor curve stuff */ regs[0xe0] = 0x00; regs[0xe1] = 0x00; regs[0xe4] = 0x00; regs[0xe5] = 0x00; regs[0xe7] = 0x00; regs[0xe8] = 0x00; regs[0xe2] = 0x09; regs[0xe3] = 0x1a; regs[0xe6] = 0xdc; regs[0xe9] = 0x1b; regs[0xec] = 0x07; regs[0xef] = 0x03; break; case X74_MOTOR: regs[0xc5] = 0x41; /* step size range2 */ regs[0xc9] = 0x39; /* ? */ regs[0xca] = 0x40; /* motor curve stuff */ regs[0xe0] = 0x00; regs[0xe1] = 0x00; regs[0xe2] = 0x09; regs[0xe3] = 0x1a; regs[0xe4] = 0x00; regs[0xe5] = 0x00; regs[0xe6] = 0x64; regs[0xe7] = 0x00; regs[0xe8] = 0x00; regs[0xe9] = 0x32; regs[0xec] = 0x0c; regs[0xef] = 0x08; break; } /* prepare for register write */ low_clr_c6 (devnum); low_stop_mvmt (devnum); /* Move Forward without scanning: */ regs[0x32] = 0x00; low_write_all_regs (devnum, regs); regs[0x32] = 0x40; low_write_all_regs (devnum, regs); /* Stop scanner - clear reg 0xb3: */ /* low_stop_mvmt (devnum); */ rts88xx_commit (devnum, regs[0x2c]); /* Poll for scanner stopped - return value(3:0) = 0: */ scan_head_moving = SANE_TRUE; while (scan_head_moving) { #ifdef FAKE_USB scan_head_moving = SANE_FALSE; #else cmd_size = 0x04; low_usb_bulk_write (devnum, pollstopmoving_command_block, &cmd_size); cmd_size = 0x1; low_usb_bulk_read (devnum, &read_result, &cmd_size); if ((read_result & 0xF) == 0x0) { scan_head_moving = SANE_FALSE; } #endif } /* this is needed to find the start line properly */ if (dev->model.sensor_type == X74_SENSOR) low_stop_mvmt (devnum); DBG (2, "sanei_lexmark_low_move_fwd: end.\n"); } SANE_Bool sanei_lexmark_low_search_home_fwd (Lexmark_Device * dev) { /* This function actually searches backwards one line looking for home */ SANE_Int devnum; int i; SANE_Byte poll_result[3]; SANE_Byte *buffer; SANE_Byte temp_byte; static SANE_Byte command4_block[] = { 0x90, 0x00, 0x00, 0x03 }; static SANE_Byte command5_block[] = { 0x91, 0x00, 0x09, 0xc4 }; size_t cmd_size; SANE_Bool got_line; SANE_Bool ret_val; devnum = dev->devnum; DBG (2, "sanei_lexmark_low_search_home_fwd:\n"); /* set up registers according to the sensor type */ switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x2c] = 0x03; dev->shadow_regs[0x2d] = 0x45; dev->shadow_regs[0x2f] = 0x21; dev->shadow_regs[0x30] = 0x48; dev->shadow_regs[0x31] = 0x06; dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x35] = 0x05; dev->shadow_regs[0x36] = 0x09; dev->shadow_regs[0x37] = 0x09; dev->shadow_regs[0x38] = 0x0d; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x75] = 0x00; dev->shadow_regs[0x8b] = 0xff; dev->shadow_regs[0x93] = 0x06; break; case X1100_B2_SENSOR: dev->shadow_regs[0x2c] = 0x0f; dev->shadow_regs[0x2d] = 0x51; dev->shadow_regs[0x2f] = 0x21; dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x35] = 0x04; dev->shadow_regs[0x36] = 0x08; dev->shadow_regs[0x37] = 0x08; dev->shadow_regs[0x38] = 0x0b; dev->shadow_regs[0x93] = 0x06; break; case X1100_2C_SENSOR: dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x35] = 0x05; dev->shadow_regs[0x36] = 0x09; dev->shadow_regs[0x37] = 0x09; dev->shadow_regs[0x38] = 0x0d; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x72] = 0x35; dev->shadow_regs[0x74] = 0x4e; dev->shadow_regs[0x85] = 0x20; /* 05 */ dev->shadow_regs[0x86] = 0x00; /* 05 */ dev->shadow_regs[0x87] = 0x00; /* 05 */ dev->shadow_regs[0x88] = 0x00; /* 45 */ dev->shadow_regs[0x89] = 0x00; dev->shadow_regs[0x8b] = 0xff; dev->shadow_regs[0x93] = 0x06; /* 0e */ dev->shadow_regs[0x75] = 0x00; /* */ dev->shadow_regs[0x91] = 0x00; /* 60 */ dev->shadow_regs[0x92] = 0x00; /* 8d */ dev->shadow_regs[0xb1] = 0x00; /* */ dev->shadow_regs[0xc5] = 0x00; /* */ dev->shadow_regs[0xca] = 0x00; /* */ dev->shadow_regs[0xc3] = 0x01; /* */ break; case A920_SENSOR: dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x35] = 0x05; dev->shadow_regs[0x36] = 0x09; dev->shadow_regs[0x37] = 0x09; dev->shadow_regs[0x38] = 0x0d; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x72] = 0x35; dev->shadow_regs[0x74] = 0x4e; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x88] = 0x45; dev->shadow_regs[0x89] = 0x00; dev->shadow_regs[0x8b] = 0xff; dev->shadow_regs[0x91] = 0x60; dev->shadow_regs[0x92] = 0x8d; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x2c] = 0x01; dev->shadow_regs[0x2d] = 0x03; dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x35] = 0x04; dev->shadow_regs[0x36] = 0x08; dev->shadow_regs[0x37] = 0x08; dev->shadow_regs[0x38] = 0x0b; dev->shadow_regs[0x66] = 0x88; dev->shadow_regs[0x6c] = 0x10; dev->shadow_regs[0x6d] = 0x14; dev->shadow_regs[0x75] = 0x00; dev->shadow_regs[0x93] = 0x06; dev->shadow_regs[0xc5] = 0x00; dev->shadow_regs[0xca] = 0x00; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x0b] = 0x70; dev->shadow_regs[0x0c] = 0x28; dev->shadow_regs[0x0d] = 0xa4; dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; dev->shadow_regs[0x2f] = 0x21; dev->shadow_regs[0x32] = 0x40; dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x35] = 0x05; dev->shadow_regs[0x36] = 0x09; dev->shadow_regs[0x37] = 0x09; dev->shadow_regs[0x38] = 0x0d; dev->shadow_regs[0x3a] = 0x20; dev->shadow_regs[0x3b] = 0x37; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x47] = 0x01; dev->shadow_regs[0x48] = 0x1a; dev->shadow_regs[0x49] = 0x5b; dev->shadow_regs[0x4a] = 0x1b; dev->shadow_regs[0x4b] = 0x5b; dev->shadow_regs[0x4c] = 0x05; dev->shadow_regs[0x4d] = 0x3f; dev->shadow_regs[0x75] = 0x00; dev->shadow_regs[0x85] = 0x03; dev->shadow_regs[0x86] = 0x33; dev->shadow_regs[0x87] = 0x8f; dev->shadow_regs[0x88] = 0x34; dev->shadow_regs[0x8b] = 0xff; dev->shadow_regs[0x8e] = 0x60; dev->shadow_regs[0x8f] = 0x80; dev->shadow_regs[0x91] = 0x59; dev->shadow_regs[0x92] = 0x10; dev->shadow_regs[0x93] = 0x06; dev->shadow_regs[0xa3] = 0x0d; dev->shadow_regs[0xa4] = 0x5e; dev->shadow_regs[0xa5] = 0x23; dev->shadow_regs[0xb1] = 0x07; dev->shadow_regs[0xc2] = 0x80; dev->shadow_regs[0xc5] = 0x00; dev->shadow_regs[0xca] = 0x00; break; } dev->shadow_regs[0x65] = 0x80; dev->shadow_regs[0x8c] = 0x02; dev->shadow_regs[0x8d] = 0x01; dev->shadow_regs[0xb2] = 0x00; dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; rts88xx_set_gain (dev->shadow_regs, dev->sensor->default_gain, dev->sensor->default_gain, dev->sensor->default_gain); rts88xx_set_offset (dev->shadow_regs, 0x80, 0x80, 0x80); /* set grayscale scan */ rts88xx_set_gray_scan (dev->shadow_regs); /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x07; /* set vertical start/end positions */ dev->shadow_regs[0x60] = 0x01; dev->shadow_regs[0x61] = 0x00; dev->shadow_regs[0x62] = 0x02; dev->shadow_regs[0x63] = 0x00; /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 1); /* set horizontal start position */ dev->shadow_regs[0x66] = 0x6a; /* 0x88 for X1200 */ dev->shadow_regs[0x67] = 0x00; /* set horizontal end position */ dev->shadow_regs[0x6c] = 0xf2; /* 0x1410 for X1200 */ dev->shadow_regs[0x6d] = 0x13; /* set horizontal resolution */ dev->shadow_regs[0x79] = 0x40; dev->shadow_regs[0x7a] = 0x02; /* Motor disable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x01; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x01; switch (dev->model.motor_type) { case A920_MOTOR: case X1100_MOTOR: /* step size range2 */ dev->shadow_regs[0xc9] = 0x3b; /* step size range0 */ dev->shadow_regs[0xe2] = 0x01; /* ? */ dev->shadow_regs[0xe3] = 0x03; break; case X74_MOTOR: dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x00; dev->shadow_regs[0xc8] = 0x04; /* step size range2 */ dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x00; /* motor curve stuff */ dev->shadow_regs[0xe0] = 0x29; dev->shadow_regs[0xe1] = 0x17; dev->shadow_regs[0xe2] = 0x8f; dev->shadow_regs[0xe3] = 0x06; dev->shadow_regs[0xe4] = 0x61; dev->shadow_regs[0xe5] = 0x16; dev->shadow_regs[0xe6] = 0x64; dev->shadow_regs[0xe7] = 0xb5; dev->shadow_regs[0xe8] = 0x08; dev->shadow_regs[0xe9] = 0x32; dev->shadow_regs[0xec] = 0x0c; dev->shadow_regs[0xef] = 0x08; break; } /* Stop the scanner */ low_stop_mvmt (devnum); /* write regs out twice */ dev->shadow_regs[0x32] = 0x00; low_write_all_regs (devnum, dev->shadow_regs); dev->shadow_regs[0x32] = 0x40; low_write_all_regs (devnum, dev->shadow_regs); /* Start Scan */ rts88xx_commit (devnum, dev->shadow_regs[0x2c]); /* Poll the available byte count until not 0 */ got_line = SANE_FALSE; while (!got_line) { cmd_size = 4; low_usb_bulk_write (devnum, command4_block, &cmd_size); cmd_size = 0x3; low_usb_bulk_read (devnum, poll_result, &cmd_size); if (! (poll_result[0] == 0 && poll_result[1] == 0 && poll_result[2] == 0)) { /* if result != 00 00 00 we got data */ got_line = SANE_TRUE; } } /* create buffer for scan data */ buffer = calloc (2500, sizeof (char)); if (buffer == NULL) { return SANE_FALSE; } /* Tell the scanner to send the data */ /* Write: 91 00 09 c4 */ cmd_size = 4; low_usb_bulk_write (devnum, command5_block, &cmd_size); /* Read it */ cmd_size = 0x09c4; low_usb_bulk_read (devnum, buffer, &cmd_size); /* Reverse order of bytes in words of buffer */ for (i = 0; i < 2500; i = i + 2) { temp_byte = *(buffer + i); *(buffer + i) = *(buffer + i + 1); *(buffer + i + 1) = temp_byte; } /* check for home position */ ret_val = low_is_home_line (dev, buffer); if (ret_val) DBG (2, "sanei_lexmark_low_search_home_fwd: !!!HOME POSITION!!!\n"); /* free the buffer */ free (buffer); DBG (2, "sanei_lexmark_low_search_home_fwd: end.\n"); return ret_val; } SANE_Bool sanei_lexmark_low_search_home_bwd (Lexmark_Device * dev) { /* This function must only be called if the scan head is past the home dot. It could damage the scanner if not. This function tells the scanner to do a grayscale scan backwards with a 300dpi resolution. It reads 2500 bytes of data between horizontal co-ordinates 0x6a and 0x13f2. The scan is set to read between vertical co-ordinates from 0x0a to 0x0f46, or 3900 lines. This equates to 13" at 300dpi, so we must stop the scan before it bangs against the end. A line limit is set so that a maximum of 0x0F3C (13"*300dpi) lines can be read. To read the scan data we create a buffer space large enough to hold 10 lines of data. For each read we poll twice, ignoring the first poll. This is required for timing. We repeat the double poll until there is data available. The number of lines (or number of buffers in our buffer space) is calculated from the size of the data available from the scanner. The number of buffers is calculated as the space required to hold 1.5 times the size of the data available from the scanner. After data is read from the scanner each line is checked if it is on the home dot. Lines are continued to be read until we are no longer on the home dot. */ SANE_Int devnum; SANE_Status status; int i, j; SANE_Byte poll_result[3]; SANE_Byte *buffer; SANE_Byte *buffer_start; SANE_Byte temp_byte; SANE_Int buffer_count = 0; SANE_Int size_requested; SANE_Int size_returned; SANE_Int no_of_buffers; SANE_Int buffer_limit = 0xF3C; SANE_Int high_byte, mid_byte, low_byte; SANE_Int home_line_count; SANE_Bool in_home_region; static SANE_Byte command4_block[] = { 0x90, 0x00, 0x00, 0x03 }; static SANE_Byte command5_block[] = { 0x91, 0x00, 0xff, 0xc0 }; #ifdef DEEP_DEBUG FILE *img = NULL; #endif size_t cmd_size; SANE_Bool got_line; devnum = dev->devnum; DBG (2, "sanei_lexmark_low_search_home_bwd:\n"); /* set up registers */ switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x2c] = 0x03; dev->shadow_regs[0x2d] = 0x45; dev->shadow_regs[0x34] = 0x09; dev->shadow_regs[0x35] = 0x09; dev->shadow_regs[0x36] = 0x11; dev->shadow_regs[0x37] = 0x11; dev->shadow_regs[0x38] = 0x19; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x93] = 0x06; dev->shadow_regs[0x40] = 0x80; /* important for detection of b/w transitions */ dev->shadow_regs[0x75] = 0x00; dev->shadow_regs[0x8b] = 0xff; break; case X1100_B2_SENSOR: dev->shadow_regs[0x2c] = 0x0f; dev->shadow_regs[0x2d] = 0x51; dev->shadow_regs[0x34] = 0x07; dev->shadow_regs[0x35] = 0x07; dev->shadow_regs[0x36] = 0x0f; dev->shadow_regs[0x37] = 0x0f; dev->shadow_regs[0x38] = 0x15; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x93] = 0x06; break; case X1100_2C_SENSOR: dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; dev->shadow_regs[0x34] = 0x09; dev->shadow_regs[0x35] = 0x09; dev->shadow_regs[0x36] = 0x11; dev->shadow_regs[0x37] = 0x11; dev->shadow_regs[0x38] = 0x19; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; dev->shadow_regs[0x34] = 0x09; dev->shadow_regs[0x35] = 0x09; dev->shadow_regs[0x36] = 0x11; dev->shadow_regs[0x37] = 0x11; dev->shadow_regs[0x38] = 0x19; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x2c] = 0x01; dev->shadow_regs[0x2d] = 0x03; dev->shadow_regs[0x34] = 0x07; dev->shadow_regs[0x35] = 0x07; dev->shadow_regs[0x36] = 0x0f; dev->shadow_regs[0x37] = 0x0f; dev->shadow_regs[0x38] = 0x15; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; dev->shadow_regs[0x34] = 0x09; dev->shadow_regs[0x35] = 0x09; dev->shadow_regs[0x36] = 0x11; dev->shadow_regs[0x37] = 0x11; dev->shadow_regs[0x38] = 0x19; dev->shadow_regs[0x85] = 0x03; dev->shadow_regs[0x93] = 0x06; break; } rts88xx_set_gain (dev->shadow_regs, dev->sensor->default_gain, dev->sensor->default_gain, dev->sensor->default_gain); dev->shadow_regs[0x65] = 0x80; dev->shadow_regs[0x8b] = 0xff; dev->shadow_regs[0x8c] = 0x02; dev->shadow_regs[0xb2] = 0x00; /* set calibration */ rts88xx_set_offset (dev->shadow_regs, 0x80, 0x80, 0x80); /* set grayscale scan */ dev->shadow_regs[0x2f] = 0x21; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x03; /* set vertical start/end positions */ dev->shadow_regs[0x60] = 0x0a; dev->shadow_regs[0x61] = 0x00; dev->shadow_regs[0x62] = 0x46; dev->shadow_regs[0x63] = 0x0f; /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 2); /* set horizontal start position */ dev->shadow_regs[0x66] = 0x6a; /* 0x88 for X1200 */ dev->shadow_regs[0x67] = 0x00; /* set horizontal end position */ dev->shadow_regs[0x6c] = 0xf2; /* 0x1410 for X1200, 13f2 for X1200/rev. 97 */ dev->shadow_regs[0x6d] = 0x13; /* set horizontal resolution */ dev->shadow_regs[0x79] = 0x40; dev->shadow_regs[0x7a] = 0x02; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x01; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x81; switch (dev->model.motor_type) { case X74_MOTOR: dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x00; dev->shadow_regs[0xc8] = 0x04; /* step size range2 */ dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x00; /* motor curve stuff */ dev->shadow_regs[0xe0] = 0x29; dev->shadow_regs[0xe1] = 0x17; dev->shadow_regs[0xe2] = 0x8f; dev->shadow_regs[0xe3] = 0x06; dev->shadow_regs[0xe4] = 0x61; dev->shadow_regs[0xe5] = 0x16; dev->shadow_regs[0xe6] = 0x64; dev->shadow_regs[0xe7] = 0xb5; dev->shadow_regs[0xe8] = 0x08; dev->shadow_regs[0xe9] = 0x32; dev->shadow_regs[0xec] = 0x0c; dev->shadow_regs[0xef] = 0x08; break; case A920_MOTOR: case X1100_MOTOR: /* ? */ dev->shadow_regs[0xc5] = 0x19; /* step size range2 */ dev->shadow_regs[0xc9] = 0x3a; /* ? */ dev->shadow_regs[0xca] = 0x08; /* motor curve stuff */ dev->shadow_regs[0xe0] = 0xe3; dev->shadow_regs[0xe1] = 0x18; dev->shadow_regs[0xe2] = 0x03; dev->shadow_regs[0xe3] = 0x06; dev->shadow_regs[0xe4] = 0x2b; dev->shadow_regs[0xe5] = 0x17; dev->shadow_regs[0xe6] = 0xdc; dev->shadow_regs[0xe7] = 0xb3; dev->shadow_regs[0xe8] = 0x07; dev->shadow_regs[0xe9] = 0x1b; dev->shadow_regs[0xec] = 0x07; dev->shadow_regs[0xef] = 0x03; break; } /* Stop the scanner */ low_stop_mvmt (devnum); /* write regs out twice */ dev->shadow_regs[0x32] = 0x00; low_write_all_regs (devnum, dev->shadow_regs); dev->shadow_regs[0x32] = 0x40; low_write_all_regs (devnum, dev->shadow_regs); /* Start Scan */ status = rts88xx_commit (devnum, dev->shadow_regs[0x2c]); /* create buffer to hold up to 10 lines of scan data */ buffer = calloc (10 * 2500, sizeof (char)); if (buffer == NULL) { return SANE_FALSE; } home_line_count = 0; in_home_region = SANE_FALSE; #ifdef DEEP_DEBUG img = fopen ("find_bwd.pnm", "wb"); fprintf (img, "P5\n2500 100\n255\n"); #endif while (buffer_count < buffer_limit) { size_returned = 0; got_line = SANE_FALSE; while (!got_line) { /* always poll twice (needed for timing) - disregard 1st poll */ cmd_size = 4; status = low_usb_bulk_write (devnum, command4_block, &cmd_size); if (status != SANE_STATUS_GOOD) return SANE_FALSE; cmd_size = 0x3; status = low_usb_bulk_read (devnum, poll_result, &cmd_size); if (status != SANE_STATUS_GOOD) return SANE_FALSE; cmd_size = 4; status = low_usb_bulk_write (devnum, command4_block, &cmd_size); if (status != SANE_STATUS_GOOD) return SANE_FALSE; cmd_size = 0x3; status = low_usb_bulk_read (devnum, poll_result, &cmd_size); if (status != SANE_STATUS_GOOD) return SANE_FALSE; if (! (poll_result[0] == 0 && poll_result[1] == 0 && poll_result[2] == 0)) { /* if result != 00 00 00 we got data */ got_line = SANE_TRUE; high_byte = poll_result[2] << 16; mid_byte = poll_result[1] << 8; low_byte = poll_result[0]; size_returned = high_byte + mid_byte + low_byte; } } /*size_requested = size_returned;*/ size_requested = 2500; no_of_buffers = size_returned * 3; no_of_buffers = no_of_buffers / 2500; no_of_buffers = no_of_buffers >> 1; /* force 1 buffer at a time to improve accuray, which slow downs search */ no_of_buffers = 1; if (no_of_buffers < 1) no_of_buffers = 1; else if (no_of_buffers > 10) no_of_buffers = 10; buffer_count = buffer_count + no_of_buffers; size_requested = no_of_buffers * 2500; /* Tell the scanner to send the data */ /* Write: 91 */ command5_block[1] = (SANE_Byte) (size_requested >> 16); command5_block[2] = (SANE_Byte) (size_requested >> 8); command5_block[3] = (SANE_Byte) (size_requested & 0xFF); cmd_size = 4; status = low_usb_bulk_write (devnum, command5_block, &cmd_size); if (status != SANE_STATUS_GOOD) return SANE_FALSE; /* Read it */ cmd_size = size_requested; status = low_usb_bulk_read (devnum, buffer, &cmd_size); if (status != SANE_STATUS_GOOD) return SANE_FALSE; for (i = 0; i < no_of_buffers; i++) { buffer_start = buffer + (i * 2500); /* Reverse order of bytes in words of buffer */ for (j = 0; j < 2500; j = j + 2) { temp_byte = *(buffer_start + j); *(buffer_start + j) = *(buffer_start + j + 1); *(buffer_start + j + 1) = temp_byte; } #ifdef DEEP_DEBUG fwrite (buffer + (i * 2500), 2500, 1, img); #endif if (low_is_home_line (dev, buffer_start)) { home_line_count++; if (home_line_count > 7) in_home_region = SANE_TRUE; } if (in_home_region) { /* slow down scanning : on purpose backtracking */ if (home_line_count) sleep (1); free (buffer); #ifdef DEEP_DEBUG fflush (img); i = ftell (img) / 2500; rewind (img); DBG (2, "sanei_lexmark_low_search_home_bwd: offset=%d\n", i); fprintf (img, "P5\n2500 %03d\n", i); fclose (img); #endif low_stop_mvmt (devnum); DBG (2, "sanei_lexmark_low_search_home_bwd: in home region, end.\n"); return SANE_TRUE; } } } /* end while (buffer_count > buffer_limit); */ free (buffer); #ifdef DEEP_DEBUG fflush (img); i = ftell (img) / 2500; rewind (img); fprintf (img, "P5\n2500 %03d\n", i); fclose (img); #endif low_stop_mvmt (devnum); DBG (2, "sanei_lexmark_low_search_home_bwd: end.\n"); return SANE_FALSE; } SANE_Status low_get_start_loc (SANE_Int resolution, SANE_Int * vert_start, SANE_Int * hor_start, SANE_Int offset, Lexmark_Device * dev) { SANE_Int start_600; switch (dev->model.sensor_type) { case X1100_2C_SENSOR: case X1200_USB2_SENSOR: case A920_SENSOR: case X1200_SENSOR: start_600 = 195 - offset; *hor_start = 0x68; break; case X1100_B2_SENSOR: start_600 = 195 - offset; switch (resolution) { case 75: *hor_start = 0x68; break; case 150: *hor_start = 0x68; break; case 300: *hor_start = 0x6a; break; case 600: *hor_start = 0x6b; break; case 1200: *hor_start = 0x6b; break; default: /* If we're here we have an invalid resolution */ return SANE_STATUS_INVAL; } break; case X74_SENSOR: start_600 = 268 - offset; switch (resolution) { case 75: *hor_start = 0x48; break; case 150: *hor_start = 0x48; break; case 300: *hor_start = 0x4a; break; case 600: *hor_start = 0x4b; break; default: /* If we're here we have an invalid resolution */ 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) { case 75: *vert_start = start_600 / 8; break; case 150: *vert_start = start_600 / 4; break; case 300: *vert_start = start_600 / 2; break; case 600: *vert_start = start_600; break; case 1200: *vert_start = start_600 * 2; break; default: /* If we're here we have an invalid resolution */ return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } void low_set_scan_area (SANE_Int res, SANE_Int tlx, SANE_Int tly, SANE_Int brx, SANE_Int bry, SANE_Int offset, SANE_Bool half_step, SANE_Byte * regs, Lexmark_Device * dev) { SANE_Int vert_start = 0; SANE_Int hor_start = 0; SANE_Int vert_end; SANE_Int hor_end; low_get_start_loc (res, &vert_start, &hor_start, offset, dev); /* convert pixel height to vertical location coordinates */ vert_end = vert_start + (bry * res) / 600; vert_start += (tly * res) / 600; /* scan area size : for A920, 600 color scans are done at 1200 y dpi */ /* this follow what was found in usb logs */ if (half_step) { vert_end = vert_end * 2; vert_start = vert_start * 2; } /* set vertical start position registers */ regs[0x60] = LOBYTE (vert_start); regs[0x61] = HIBYTE (vert_start); /* set vertical end position registers */ regs[0x62] = LOBYTE (vert_end); regs[0x63] = HIBYTE (vert_end); /* convert pixel width to horizontal location coordinates */ hor_end = hor_start + brx; hor_start += tlx; regs[0x66] = LOBYTE (hor_start); regs[0x67] = HIBYTE (hor_start); /* set horizontal end position registers */ regs[0x6c] = LOBYTE (hor_end); regs[0x6d] = HIBYTE (hor_end); /* Debug */ DBG (2, "low_set_scan_area: vert_start: %d (tly=%d)\n", vert_start, tly); DBG (2, "low_set_scan_area: vert_end: %d\n", vert_end); DBG (2, "low_set_scan_area: hor_start: %d\n", hor_start); DBG (2, "low_set_scan_area: hor_end: %d\n", hor_end); } SANE_Int sanei_lexmark_low_find_start_line (Lexmark_Device * dev) { /* This function scans forward 59 lines, reading 88 bytes per line from the middle of the horizontal line: pixel 0xa84 to pixel 0x9d4. It scans with the following parameters: dir=fwd mode=grayscale h.res=300 dpi v.res=600 dpi hor. pixels = (0xa84 - 0x9d4)/2 = 0x58 = 88 vert. pixels = 0x3e - 0x03 = 0x3b = 59 data = 88x59=5192=0x1448 It assumes we are in the start dot, or just before it. We are reading enough lines at 600dpi to read past the dot. We return the number of entirely white lines read consecutively, so we know how far past the dot we are. To find the number of consecutive white lines we do the following: Byte swap the order of the bytes in the buffer. Go through the buffer finding low and high values, which are computed by comparing to the weighted average: weighted_average = (lowest value + (highest value - lowest value)/4) Low bytes are changed to 0xFF (white), higher of equal bytes are changed to 0x00 (black),so that the buffer only contains white (0xFF) or black (0x00) values. Next, we go through the buffer a line (88 bytes) at a time for 59 lines to read the entire buffer. For each byte in a line we check if the byte is black. If it is we increment the black byte counter. After each line we check the black byte counter. If it is greater than 0 we increment the black line count and set the white line count to 0. If there were no black bytes in the line we set the black line count to 0 and increment the white line count. When all lines have been processed we return the white line count. */ int blackLineCount = 0; int whiteLineCount = 0; int blackByteCounter = 0; unsigned char max_byte = 0; unsigned char min_byte = 0xFF; unsigned char weighted_average; int i, j; #ifdef DEEP_DEBUG FILE *fdbg = NULL; #endif SANE_Byte poll_result[3]; SANE_Byte *buffer; SANE_Byte temp_byte; static SANE_Byte command4_block[] = { 0x90, 0x00, 0x00, 0x03 }; static SANE_Byte command5_block[] = { 0x91, 0x00, 0x14, 0x48 }; size_t cmd_size; SANE_Bool got_line; DBG (2, "sanei_lexmark_low_find_start_line:\n"); /* set up registers */ switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x2c] = 0x04; dev->shadow_regs[0x2d] = 0x46; dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x35] = 0x05; dev->shadow_regs[0x36] = 0x0b; dev->shadow_regs[0x37] = 0x0b; dev->shadow_regs[0x38] = 0x11; dev->shadow_regs[0x40] = 0x40; rts88xx_set_gain (dev->shadow_regs, 6, 6, 6); break; case X1100_B2_SENSOR: dev->shadow_regs[0x2c] = 0x0f; dev->shadow_regs[0x2d] = 0x51; dev->shadow_regs[0x34] = 0x0d; dev->shadow_regs[0x35] = 0x0d; dev->shadow_regs[0x36] = 0x1d; dev->shadow_regs[0x37] = 0x1d; dev->shadow_regs[0x38] = 0x29; dev->shadow_regs[0x65] = 0x80; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x93] = 0x06; rts88xx_set_gain (dev->shadow_regs, 6, 6, 6); break; case X1100_2C_SENSOR: rts88xx_set_gain (dev->shadow_regs, 10, 10, 10); dev->shadow_regs[0x28] = 0xf5; dev->shadow_regs[0x29] = 0xf7; dev->shadow_regs[0x2a] = 0xf5; dev->shadow_regs[0x2b] = 0x17; dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; dev->shadow_regs[0x31] = 0x01; dev->shadow_regs[0x34] = 0x11; dev->shadow_regs[0x35] = 0x11; dev->shadow_regs[0x36] = 0x21; dev->shadow_regs[0x37] = 0x21; dev->shadow_regs[0x38] = 0x31; dev->shadow_regs[0x72] = 0x35; dev->shadow_regs[0x74] = 0x4e; dev->shadow_regs[0x85] = 0x02; dev->shadow_regs[0x86] = 0x33; dev->shadow_regs[0x87] = 0x0f; dev->shadow_regs[0x88] = 0x24; dev->shadow_regs[0x91] = 0x19; dev->shadow_regs[0x92] = 0x20; dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; break; case A920_SENSOR: dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; dev->shadow_regs[0x34] = 0x11; dev->shadow_regs[0x35] = 0x11; dev->shadow_regs[0x36] = 0x21; dev->shadow_regs[0x37] = 0x21; dev->shadow_regs[0x38] = 0x31; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x88] = 0x44; dev->shadow_regs[0x92] = 0x85; dev->shadow_regs[0x93] = 0x0e; rts88xx_set_gain (dev->shadow_regs, 6, 6, 6); break; case X1200_SENSOR: dev->shadow_regs[0x2c] = 0x01; dev->shadow_regs[0x2d] = 0x03; dev->shadow_regs[0x34] = 0x0d; dev->shadow_regs[0x35] = 0x0d; dev->shadow_regs[0x36] = 0x1d; dev->shadow_regs[0x37] = 0x1d; dev->shadow_regs[0x38] = 0x29; dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x81] = 0x00; dev->shadow_regs[0x82] = 0x00; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0xff; dev->shadow_regs[0x88] = 0x02; dev->shadow_regs[0x92] = 0x00; rts88xx_set_gain (dev->shadow_regs, 10, 10, 10); break; case X1200_USB2_SENSOR: dev->shadow_regs[0x2c] = 0x01; dev->shadow_regs[0x2d] = 0x03; dev->shadow_regs[0x34] = 0x0d; dev->shadow_regs[0x35] = 0x0d; dev->shadow_regs[0x36] = 0x1d; dev->shadow_regs[0x37] = 0x1d; dev->shadow_regs[0x38] = 0x29; dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; rts88xx_set_gain (dev->shadow_regs, 10, 10, 10); break; } /* set offset to a safe value */ rts88xx_set_offset (dev->shadow_regs, 0x80, 0x80, 0x80); /* set grayscale scan */ dev->shadow_regs[0x2f] = 0x21; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x01; /* set vertical start/end positions */ dev->shadow_regs[0x60] = 0x03; dev->shadow_regs[0x61] = 0x00; dev->shadow_regs[0x62] = 0x3e; dev->shadow_regs[0x63] = 0x00; /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 1); /* set horizontal start position */ dev->shadow_regs[0x66] = 0xd4; /* 0xf2 for X1200 */ dev->shadow_regs[0x67] = 0x09; /* set horizontal end position */ dev->shadow_regs[0x6c] = 0x84; /* 0xa2 for X1200 */ dev->shadow_regs[0x6d] = 0x0a; /* set horizontal resolution */ dev->shadow_regs[0x79] = 0x40; dev->shadow_regs[0x7a] = 0x02; /* set for ? */ /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x81; switch (dev->model.motor_type) { case X1100_MOTOR: case A920_MOTOR: /* set for ? */ dev->shadow_regs[0xc5] = 0x22; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; /* step size range2 */ dev->shadow_regs[0xc9] = 0x3b; /* set for ? */ dev->shadow_regs[0xca] = 0x1f; dev->shadow_regs[0xe0] = 0xf7; dev->shadow_regs[0xe1] = 0x16; /* step size range0 */ dev->shadow_regs[0xe2] = 0x87; /* ? */ dev->shadow_regs[0xe3] = 0x13; dev->shadow_regs[0xe4] = 0x1b; dev->shadow_regs[0xe5] = 0x16; dev->shadow_regs[0xe6] = 0xdc; dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; dev->shadow_regs[0xe9] = 0x1b; dev->shadow_regs[0xec] = 0x07; dev->shadow_regs[0xef] = 0x03; break; case X74_MOTOR: dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x22; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x0b; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x1f; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x2f; dev->shadow_regs[0xe1] = 0x11; /* step size range0 */ dev->shadow_regs[0xe2] = 0x9f; /* ? */ dev->shadow_regs[0xe3] = 0x0f; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0xcb; dev->shadow_regs[0xe5] = 0x10; /* step size range1 */ dev->shadow_regs[0xe6] = 0x64; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x32; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x0c; /* bounds of movement range4 -only for 75dpi grayscale */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x08; break; } /* Stop the scanner */ low_stop_mvmt (dev->devnum); /* write regs out twice */ dev->shadow_regs[0x32] = 0x00; low_write_all_regs (dev->devnum, dev->shadow_regs); dev->shadow_regs[0x32] = 0x40; low_write_all_regs (dev->devnum, dev->shadow_regs); /* Start Scan */ rts88xx_commit (dev->devnum, dev->shadow_regs[0x2c]); /* Poll the available byte count until not 0 */ got_line = SANE_FALSE; while (!got_line) { cmd_size = 4; low_usb_bulk_write (dev->devnum, command4_block, &cmd_size); cmd_size = 0x3; low_usb_bulk_read (dev->devnum, poll_result, &cmd_size); if (! (poll_result[0] == 0 && poll_result[1] == 0 && poll_result[2] == 0)) { /* if result != 00 00 00 we got data */ got_line = SANE_TRUE; } #ifdef FAKE_USB got_line = SANE_TRUE; #endif } /* create buffer for scan data */ buffer = calloc (5192, sizeof (char)); if (buffer == NULL) { return -1; } /* Tell the scanner to send the data */ /* Write: 91 00 14 48 */ cmd_size = 4; low_usb_bulk_write (dev->devnum, command5_block, &cmd_size); /* Read it */ cmd_size = 0x1448; low_usb_bulk_read (dev->devnum, buffer, &cmd_size); /* Stop the scanner */ low_stop_mvmt (dev->devnum); /* Reverse order of bytes in words of buffer */ for (i = 0; i < 5192; i = i + 2) { temp_byte = *(buffer + i); *(buffer + i) = *(buffer + i + 1); *(buffer + i + 1) = temp_byte; } #ifdef DEEP_DEBUG fdbg = fopen ("find_start.pnm", "wb"); if (fdbg != NULL) { fprintf (fdbg, "P5\n%d %d\n255\n", 88, 59); fwrite (buffer, 5192, 1, fdbg); fclose (fdbg); } #endif /* Find the max and the min */ for (i = 0; i < 5192; i++) { if (*(buffer + i) > max_byte) max_byte = *(buffer + i); if (*(buffer + i) < min_byte) min_byte = *(buffer + i); } weighted_average = min_byte + ((max_byte - min_byte) / 4); /* Set bytes as black (0x00) or white (0xFF) */ for (i = 0; i < 5192; i++) { if (*(buffer + i) > weighted_average) *(buffer + i) = 0xFF; else *(buffer + i) = 0x00; } #ifdef DEEP_DEBUG fdbg = fopen ("find_start_after.pnm", "wb"); if (fdbg != NULL) { fprintf (fdbg, "P5\n%d %d\n255\n", 88, 59); fwrite (buffer, 5192, 1, fdbg); fclose (fdbg); } #endif /* Go through 59 lines */ for (j = 0; j < 59; j++) { blackByteCounter = 0; /* Go through 88 bytes per line */ for (i = 0; i < 88; i++) { /* Is byte black? */ if (*(buffer + (j * 88) + i) == 0) { blackByteCounter++; } } /* end for line */ if (blackByteCounter > 0) { /* This was a black line */ blackLineCount++; whiteLineCount = 0; } else { /* This is a white line */ whiteLineCount++; blackLineCount = 0; } } /* end for buffer */ free (buffer); /* Stop the scanner. This is needed to get the right distance to the scanning area */ if (dev->model.sensor_type == X74_SENSOR) low_stop_mvmt (dev->devnum); DBG (2, "sanei_lexmark_low_find_start_line: end.\n"); return whiteLineCount; } SANE_Status sanei_lexmark_low_set_scan_regs (Lexmark_Device * dev, SANE_Int resolution, SANE_Int offset, SANE_Bool calibrated) { SANE_Bool isColourScan; DBG (2, "sanei_lexmark_low_set_scan_regs:\n"); DBG (7, "sanei_lexmark_low_set_scan_regs: resolution=%d DPI\n", resolution); /* colour mode */ if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) isColourScan = SANE_TRUE; else isColourScan = SANE_FALSE; /* set up registers */ switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x2c] = 0x03; dev->shadow_regs[0x2d] = 0x45; break; case X1100_B2_SENSOR: dev->shadow_regs[0x2c] = 0x0f; dev->shadow_regs[0x2d] = 0x51; break; case X1100_2C_SENSOR: dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; break; case A920_SENSOR: dev->shadow_regs[0x2c] = 0x0d; dev->shadow_regs[0x2d] = 0x4f; break; case X1200_SENSOR: dev->shadow_regs[0x2c] = 0x01; dev->shadow_regs[0x2d] = 0x03; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x2c] = 0x01; dev->shadow_regs[0x2d] = 0x03; break; } low_set_scan_area (resolution, dev->val[OPT_TL_X].w, dev->val[OPT_TL_Y].w, dev->val[OPT_BR_X].w, dev->val[OPT_BR_Y].w, offset, (dev->model.motor_type == A920_MOTOR || dev->model.motor_type == X74_MOTOR) && isColourScan && (resolution == 600), dev->shadow_regs, dev); /* may be we could use a sensor descriptor that would held the max horiz dpi */ if (dev->val[OPT_RESOLUTION].w < 600) dev->shadow_regs[0x7a] = 600 / dev->val[OPT_RESOLUTION].w; else dev->shadow_regs[0x7a] = 1; /* 75dpi x 75dpi */ if (resolution == 75) { DBG (5, "sanei_lexmark_low_set_scan_regs(): 75 DPI resolution\n"); if (isColourScan) { switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x36] = 0x03; dev->shadow_regs[0x38] = 0x03; dev->shadow_regs[0x79] = 0x08; dev->shadow_regs[0x80] = 0x0d; dev->shadow_regs[0x81] = 0x0e; dev->shadow_regs[0x82] = 0x02; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06;; break; case X1100_B2_SENSOR: dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x36] = 0x05; dev->shadow_regs[0x38] = 0x05; dev->shadow_regs[0x80] = 0x0c; dev->shadow_regs[0x81] = 0x0c; dev->shadow_regs[0x82] = 0x09; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x8c; dev->shadow_regs[0x92] = 0x40; dev->shadow_regs[0x93] = 0x06; break; case X1100_2C_SENSOR: dev->shadow_regs[0x34] = 0x03; dev->shadow_regs[0x36] = 0x04; dev->shadow_regs[0x38] = 0x03; dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x02; dev->shadow_regs[0x82] = 0x03; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x34] = 0x02; dev->shadow_regs[0x36] = 0x04; dev->shadow_regs[0x38] = 0x03; dev->shadow_regs[0x80] = 0x07; dev->shadow_regs[0x81] = 0x0f; dev->shadow_regs[0x82] = 0x03; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x44; dev->shadow_regs[0x91] = 0x60; dev->shadow_regs[0x92] = 0x85; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x34] = 0x02; dev->shadow_regs[0x36] = 0x03; dev->shadow_regs[0x38] = 0x01; dev->shadow_regs[0x79] = 0x20; dev->shadow_regs[0x80] = 0x08; dev->shadow_regs[0x81] = 0x02; dev->shadow_regs[0x82] = 0x0d; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x1e; dev->shadow_regs[0x87] = 0x39; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; /* dev->shadow_regs[0x92] = 0x92; */ dev->shadow_regs[0x93] = 0x06; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x36] = 0x05; dev->shadow_regs[0x38] = 0x04; dev->shadow_regs[0x80] = 0x01; dev->shadow_regs[0x81] = 0x0a; dev->shadow_regs[0x82] = 0x0b; break; } switch (dev->model.motor_type) { case X74_MOTOR: dev->shadow_regs[0xc2] = 0x80; /* ? */ dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x0c; dev->shadow_regs[0xc6] = 0x0b; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x01; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x1b; dev->shadow_regs[0xe1] = 0x0a; /* step size range0 */ dev->shadow_regs[0xe2] = 0x4f; /* ? */ dev->shadow_regs[0xe3] = 0x01; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0xb3; dev->shadow_regs[0xe5] = 0x09; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0d; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0xe5; dev->shadow_regs[0xe8] = 0x02; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0xa0; dev->shadow_regs[0xeb] = 0x01; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* bounds of movement range4 */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; break; case A920_MOTOR: case X1100_MOTOR: /* ? */ dev->shadow_regs[0xc5] = 0x0a; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x2b; dev->shadow_regs[0xe1] = 0x0a; /* step size range0 */ dev->shadow_regs[0xe2] = 0x7f; /* ? */ dev->shadow_regs[0xe3] = 0x01; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0xbb; dev->shadow_regs[0xe5] = 0x09; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0e; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x2b; dev->shadow_regs[0xe8] = 0x03; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0xa0; dev->shadow_regs[0xeb] = 0x01; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; break; } /* set colour scan */ dev->shadow_regs[0x2f] = 0x11; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x37] = 0x01; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x83; } else /* 75 dpi gray */ { switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x34] = 0x01; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x02; dev->shadow_regs[0x37] = 0x02; dev->shadow_regs[0x38] = 0x03; dev->shadow_regs[0x39] = 0x0f; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x79] = 0x08; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x8c] = 0x02; dev->shadow_regs[0x8d] = 0x01; dev->shadow_regs[0x8e] = 0x60; dev->shadow_regs[0x8f] = 0x80; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_B2_SENSOR: dev->shadow_regs[0x34] = 0x02; dev->shadow_regs[0x35] = 0x02; dev->shadow_regs[0x36] = 0x04; dev->shadow_regs[0x37] = 0x04; dev->shadow_regs[0x38] = 0x06; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_2C_SENSOR: dev->shadow_regs[0x34] = 0x01; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x02; dev->shadow_regs[0x37] = 0x02; dev->shadow_regs[0x38] = 0x03; /* these are half of B2 sensor */ dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x34] = 0x01; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x02; dev->shadow_regs[0x37] = 0x02; dev->shadow_regs[0x38] = 0x03; dev->shadow_regs[0x85] = 0x0d; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x45; dev->shadow_regs[0x91] = 0x60; dev->shadow_regs[0x92] = 0x8d; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x34] = 0x01; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x02; dev->shadow_regs[0x37] = 0x02; dev->shadow_regs[0x38] = 0x02; dev->shadow_regs[0x79] = 0x20; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0xff; dev->shadow_regs[0x88] = 0x02; dev->shadow_regs[0x92] = 0x00; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x34] = 0x01; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x02; dev->shadow_regs[0x37] = 0x02; dev->shadow_regs[0x38] = 0x02; dev->shadow_regs[0x79] = 0x20; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0xff; dev->shadow_regs[0x88] = 0x02; dev->shadow_regs[0x92] = 0x00; break; } switch (dev->model.motor_type) { case X74_MOTOR: /* ? */ dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x0a; dev->shadow_regs[0xc6] = 0x0b; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x01; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x07; dev->shadow_regs[0xe1] = 0x18; /* step size range0 */ dev->shadow_regs[0xe2] = 0xe7; /* ? */ dev->shadow_regs[0xe3] = 0x03; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0xe7; dev->shadow_regs[0xe5] = 0x14; /* step size range1 */ dev->shadow_regs[0xe6] = 0x64; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0xcb; dev->shadow_regs[0xe8] = 0x08; /* step size range2 */ dev->shadow_regs[0xe9] = 0x32; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0xe3; dev->shadow_regs[0xeb] = 0x04; /* step size range3 */ dev->shadow_regs[0xec] = 0x0c; /* bounds of movement range4 */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x08; break; case A920_MOTOR: case X1100_MOTOR: /* ? */ dev->shadow_regs[0xc5] = 0x10; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; dev->shadow_regs[0xc9] = 0x3b; dev->shadow_regs[0xca] = 0x01; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x4d; dev->shadow_regs[0xe1] = 0x1c; /* step size range0 */ dev->shadow_regs[0xe2] = 0x71; /* ? */ dev->shadow_regs[0xe3] = 0x02; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x6d; dev->shadow_regs[0xe5] = 0x15; /* step size range1 */ dev->shadow_regs[0xe6] = 0xdc; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0xad; dev->shadow_regs[0xe8] = 0x07; /* step size range2 */ dev->shadow_regs[0xe9] = 0x1b; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0xe1; dev->shadow_regs[0xeb] = 0x03; /* step size range3 */ dev->shadow_regs[0xec] = 0x07; /* bounds of movement range4 -only for 75dpi grayscale */ dev->shadow_regs[0xed] = 0xc2; dev->shadow_regs[0xee] = 0x02; /* step size range4 */ dev->shadow_regs[0xef] = 0x03; break; } /* set grayscale scan */ dev->shadow_regs[0x2f] = 0x21; /* set ? only for colour? */ dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x00; dev->shadow_regs[0x82] = 0x00; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x81; } /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x0f; /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 1); /* set horizontal resolution */ if (dev->model.sensor_type != X1200_SENSOR) dev->shadow_regs[0x79] = 0x08; } /* 150dpi x 150dpi */ if (resolution == 150) { DBG (5, "sanei_lexmark_low_set_scan_regs(): 150 DPI resolution\n"); if (isColourScan) { switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x34] = 0x08; dev->shadow_regs[0x36] = 0x06; dev->shadow_regs[0x38] = 0x05; dev->shadow_regs[0x39] = 0x07; /* resolution divisor */ dev->shadow_regs[0x79] = 0x08; dev->shadow_regs[0x80] = 0x0a; dev->shadow_regs[0x81] = 0x0c; dev->shadow_regs[0x82] = 0x04; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_B2_SENSOR: dev->shadow_regs[0x34] = 0x0b; dev->shadow_regs[0x36] = 0x0b; dev->shadow_regs[0x38] = 0x0a; dev->shadow_regs[0x80] = 0x05; dev->shadow_regs[0x81] = 0x05; dev->shadow_regs[0x82] = 0x0a; dev->shadow_regs[0x85] = 0x83; dev->shadow_regs[0x86] = 0x7e; dev->shadow_regs[0x87] = 0xad; dev->shadow_regs[0x88] = 0x35; dev->shadow_regs[0x91] = 0xfe; dev->shadow_regs[0x92] = 0xdf; dev->shadow_regs[0x93] = 0x0e; break; case X1100_2C_SENSOR: dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x36] = 0x07; dev->shadow_regs[0x38] = 0x05; dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x02; dev->shadow_regs[0x82] = 0x06; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x34] = 0x03; dev->shadow_regs[0x36] = 0x08; dev->shadow_regs[0x38] = 0x05; dev->shadow_regs[0x80] = 0x0e; dev->shadow_regs[0x81] = 0x07; dev->shadow_regs[0x82] = 0x02; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x04; dev->shadow_regs[0x91] = 0xe0; dev->shadow_regs[0x92] = 0x85; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x36] = 0x05; dev->shadow_regs[0x38] = 0x02; /* data compression dev->shadow_regs[0x40] = 0x90; dev->shadow_regs[0x50] = 0x20; */ /* no data compression */ dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x79] = 0x20; dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x07; dev->shadow_regs[0x82] = 0x0b; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x1e; dev->shadow_regs[0x87] = 0x39; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x92] = 0x92; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x36] = 0x05; dev->shadow_regs[0x38] = 0x02; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x79] = 0x20; dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x07; dev->shadow_regs[0x82] = 0x0b; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x1e; dev->shadow_regs[0x87] = 0x39; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x92] = 0x92; break; } /* switch */ switch (dev->model.motor_type) { case X74_MOTOR: dev->shadow_regs[0xc2] = 0x80; /* ? */ dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x0e; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x0b; dev->shadow_regs[0xc7] = 0x00; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x03; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x41; dev->shadow_regs[0xe1] = 0x09; /* step size range0 */ dev->shadow_regs[0xe2] = 0x89; /* ? */ dev->shadow_regs[0xe3] = 0x02; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x0d; dev->shadow_regs[0xe5] = 0x09; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0d; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0xe8; dev->shadow_regs[0xe8] = 0x02; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* bounds of movement range4 */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; break; case X1100_MOTOR: case A920_MOTOR: /* ? */ dev->shadow_regs[0xc5] = 0x0e; /* ? */ dev->shadow_regs[0xc9] = 0x3a; dev->shadow_regs[0xca] = 0x03; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x61; dev->shadow_regs[0xe1] = 0x0a; /* step size range0 */ dev->shadow_regs[0xe2] = 0xed; /* ? */ dev->shadow_regs[0xe3] = 0x02; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x29; dev->shadow_regs[0xe5] = 0x0a; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0e; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x29; dev->shadow_regs[0xe8] = 0x03; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; break; } /* set colour scan */ dev->shadow_regs[0x2f] = 0x11; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x37] = 0x01; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x83; } /* if (isColourScan) */ else { switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x34] = 0x02; dev->shadow_regs[0x35] = 0x02; dev->shadow_regs[0x36] = 0x04; dev->shadow_regs[0x37] = 0x04; dev->shadow_regs[0x38] = 0x06; dev->shadow_regs[0x39] = 0x07; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0x40] = 0x40; /* resolution divisor */ dev->shadow_regs[0x79] = 0x08; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_B2_SENSOR: dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x35] = 0x04; dev->shadow_regs[0x36] = 0x07; dev->shadow_regs[0x37] = 0x07; dev->shadow_regs[0x38] = 0x0a; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_2C_SENSOR: dev->shadow_regs[0x34] = 0x02; dev->shadow_regs[0x35] = 0x02; dev->shadow_regs[0x36] = 0x04; dev->shadow_regs[0x37] = 0x04; dev->shadow_regs[0x38] = 0x05; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x34] = 0x02; dev->shadow_regs[0x35] = 0x02; dev->shadow_regs[0x36] = 0x04; dev->shadow_regs[0x37] = 0x04; dev->shadow_regs[0x38] = 0x05; dev->shadow_regs[0x85] = 0x0d; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x45; dev->shadow_regs[0x91] = 0x60; dev->shadow_regs[0x92] = 0x8d; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x34] = 0x01; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x02; dev->shadow_regs[0x37] = 0x02; dev->shadow_regs[0x38] = 0x03; /* dev->shadow_regs[0x40] = 0x90; dev->shadow_regs[0x50] = 0x20; */ /* no data compression */ dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x79] = 0x20; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0xff; dev->shadow_regs[0x88] = 0x02; dev->shadow_regs[0x92] = 0x92; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x34] = 0x01; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x02; dev->shadow_regs[0x37] = 0x02; dev->shadow_regs[0x38] = 0x03; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x79] = 0x20; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0xff; dev->shadow_regs[0x88] = 0x02; dev->shadow_regs[0x92] = 0x92; break; } /* switch */ switch (dev->model.motor_type) { case X74_MOTOR: /* ? */ dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x14; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x0b; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x01; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x09; dev->shadow_regs[0xe1] = 0x18; /* step size range0 */ dev->shadow_regs[0xe2] = 0xe9; /* ? */ dev->shadow_regs[0xe3] = 0x03; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x79; dev->shadow_regs[0xe5] = 0x16; /* step size range1 */ dev->shadow_regs[0xe6] = 0x64; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0xcd; dev->shadow_regs[0xe8] = 0x08; /* step size range2 */ dev->shadow_regs[0xe9] = 0x32; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0xe5; dev->shadow_regs[0xeb] = 0x04; /* step size range3 */ dev->shadow_regs[0xec] = 0x0c; /* bounds of movement range4 */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x08; break; case X1100_MOTOR: case A920_MOTOR: /* ? */ dev->shadow_regs[0xc5] = 0x16; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; /* ? */ dev->shadow_regs[0xc9] = 0x3b; dev->shadow_regs[0xca] = 0x01; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0xdd; dev->shadow_regs[0xe1] = 0x18; /* step size range0 */ dev->shadow_regs[0xe2] = 0x01; /* ? */ dev->shadow_regs[0xe3] = 0x03; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x6d; dev->shadow_regs[0xe5] = 0x15; /* step size range1 */ dev->shadow_regs[0xe6] = 0xdc; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0xad; dev->shadow_regs[0xe8] = 0x07; /* step size range2 */ dev->shadow_regs[0xe9] = 0x1b; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0xe1; dev->shadow_regs[0xeb] = 0x03; /* step size range3 */ dev->shadow_regs[0xec] = 0x07; /* step size range4 */ dev->shadow_regs[0xef] = 0x03; break; } /* set grayscale scan */ dev->shadow_regs[0x2f] = 0x21; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x07; /* set ? only for colour? */ dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x00; dev->shadow_regs[0x82] = 0x00; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x81; } /* else (greyscale) */ /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 1); /* hum, horizontal resolution different for X1200 ? */ /* if (dev->model.sensor_type != X1200_SENSOR) dev->shadow_regs[0x79] = 0x20; */ } /*300dpi x 300dpi */ if (resolution == 300) { DBG (5, "sanei_lexmark_low_set_scan_regs(): 300 DPI resolution\n"); if (isColourScan) { switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x34] = 0x08; dev->shadow_regs[0x36] = 0x06; dev->shadow_regs[0x38] = 0x05; dev->shadow_regs[0x39] = 0x07; dev->shadow_regs[0x80] = 0x08; dev->shadow_regs[0x81] = 0x0a; dev->shadow_regs[0x82] = 0x03; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_B2_SENSOR: dev->shadow_regs[0x34] = 0x15; dev->shadow_regs[0x36] = 0x15; dev->shadow_regs[0x38] = 0x14; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x03; dev->shadow_regs[0x80] = 0x0a; dev->shadow_regs[0x81] = 0x0a; dev->shadow_regs[0x82] = 0x06; dev->shadow_regs[0x85] = 0x83; dev->shadow_regs[0x86] = 0x7e; dev->shadow_regs[0x87] = 0xad; dev->shadow_regs[0x88] = 0x35; dev->shadow_regs[0x91] = 0xfe; dev->shadow_regs[0x92] = 0xdf; dev->shadow_regs[0x93] = 0x0e; break; case X1100_2C_SENSOR: dev->shadow_regs[0x34] = 0x08; dev->shadow_regs[0x36] = 0x0d; dev->shadow_regs[0x38] = 0x09; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x03; dev->shadow_regs[0x80] = 0x0e; dev->shadow_regs[0x81] = 0x04; dev->shadow_regs[0x82] = 0x0a; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x34] = 0x06; dev->shadow_regs[0x36] = 0x10; dev->shadow_regs[0x38] = 0x09; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x03; dev->shadow_regs[0x80] = 0x0c; dev->shadow_regs[0x81] = 0x02; dev->shadow_regs[0x82] = 0x04; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x04; dev->shadow_regs[0x91] = 0xe0; dev->shadow_regs[0x92] = 0x85; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x34] = 0x07; dev->shadow_regs[0x36] = 0x09; dev->shadow_regs[0x38] = 0x04; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x03; /* data compression dev->shadow_regs[0x40] = 0x90; dev->shadow_regs[0x50] = 0x20; */ /* no data compression */ dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x0e; dev->shadow_regs[0x82] = 0x06; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x34] = 0x07; dev->shadow_regs[0x36] = 0x09; dev->shadow_regs[0x38] = 0x04; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x03; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x0e; dev->shadow_regs[0x82] = 0x06; break; } switch (dev->model.motor_type) { case X74_MOTOR: /* ? */ dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x12; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x0f; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x5d; dev->shadow_regs[0xe1] = 0x05; /* step size range0 */ dev->shadow_regs[0xe2] = 0xed; /* ? */ dev->shadow_regs[0xe3] = 0x02; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x29; dev->shadow_regs[0xe5] = 0x05; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0d; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* bounds of movement range4 -only for 75dpi grayscale */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; break; case A920_MOTOR: case X1100_MOTOR: /* ? */ dev->shadow_regs[0xc5] = 0x17; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; /* ? */ dev->shadow_regs[0xc9] = 0x3a; dev->shadow_regs[0xca] = 0x0a; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x75; dev->shadow_regs[0xe1] = 0x0a; /* step size range0 */ dev->shadow_regs[0xe2] = 0xdd; /* ? */ dev->shadow_regs[0xe3] = 0x05; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x59; dev->shadow_regs[0xe5] = 0x0a; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0e; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; break; } dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x37] = 0x01; /* set colour scan */ dev->shadow_regs[0x2f] = 0x11; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x83; } else /* greyscale */ { switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x35] = 0x04; dev->shadow_regs[0x36] = 0x08; dev->shadow_regs[0x37] = 0x08; dev->shadow_regs[0x38] = 0x0c; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_B2_SENSOR: dev->shadow_regs[0x34] = 0x08; dev->shadow_regs[0x35] = 0x08; dev->shadow_regs[0x36] = 0x0f; dev->shadow_regs[0x37] = 0x0f; dev->shadow_regs[0x38] = 0x16; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_2C_SENSOR: dev->shadow_regs[0x34] = 0x04; dev->shadow_regs[0x35] = 0x04; dev->shadow_regs[0x36] = 0x07; dev->shadow_regs[0x37] = 0x07; dev->shadow_regs[0x38] = 0x0a; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x34] = 0x03; dev->shadow_regs[0x35] = 0x03; dev->shadow_regs[0x36] = 0x06; dev->shadow_regs[0x37] = 0x06; dev->shadow_regs[0x38] = 0x09; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x04; dev->shadow_regs[0x91] = 0xe0; dev->shadow_regs[0x92] = 0x85; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x34] = 0x02; dev->shadow_regs[0x35] = 0x02; dev->shadow_regs[0x36] = 0x04; dev->shadow_regs[0x37] = 0x04; dev->shadow_regs[0x38] = 0x06; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x34] = 0x02; dev->shadow_regs[0x35] = 0x02; dev->shadow_regs[0x36] = 0x04; dev->shadow_regs[0x37] = 0x04; dev->shadow_regs[0x38] = 0x06; break; } switch (dev->model.motor_type) { case X74_MOTOR: /* ? */ dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x1c; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x0b; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x05; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x29; dev->shadow_regs[0xe1] = 0x17; /* step size range0 */ dev->shadow_regs[0xe2] = 0x8f; /* ? */ dev->shadow_regs[0xe3] = 0x06; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x61; dev->shadow_regs[0xe5] = 0x16; /* step size range1 */ dev->shadow_regs[0xe6] = 0x64; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0xb5; dev->shadow_regs[0xe8] = 0x08; /* step size range2 */ dev->shadow_regs[0xe9] = 0x32; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x0c; /* bounds of movement range4 -only for 75dpi grayscale */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x08; break; case A920_MOTOR: case X1100_MOTOR: /* ? */ dev->shadow_regs[0xc5] = 0x19; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; /* ? */ dev->shadow_regs[0xc9] = 0x3a; dev->shadow_regs[0xca] = 0x08; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0xe3; dev->shadow_regs[0xe1] = 0x18; /* step size range0 */ dev->shadow_regs[0xe2] = 0x03; /* ? */ dev->shadow_regs[0xe3] = 0x06; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x2b; dev->shadow_regs[0xe5] = 0x17; /* step size range1 */ dev->shadow_regs[0xe6] = 0xdc; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0xb3; dev->shadow_regs[0xe8] = 0x07; /* step size range2 */ dev->shadow_regs[0xe9] = 0x1b; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x07; /* step size range4 */ dev->shadow_regs[0xef] = 0x03; break; } /* switch motortype */ /* set grayscale scan */ dev->shadow_regs[0x2f] = 0x21; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x03; /* set ? only for colour? */ dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x00; dev->shadow_regs[0x82] = 0x00; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x81; } /* else (gray) */ /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 1); /* set horizontal resolution */ dev->shadow_regs[0x79] = 0x20; } /* 600dpi x 600dpi */ if (resolution == 600) { DBG (5, "sanei_lexmark_low_set_scan_regs(): 600 DPI resolution\n"); if (isColourScan) { /* 600 dpi color doesn't work for X74 yet */ if (dev->model.sensor_type == X74_SENSOR) return SANE_STATUS_INVAL; switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x34] = 0x10; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x0c; dev->shadow_regs[0x37] = 0x01; dev->shadow_regs[0x38] = 0x09; dev->shadow_regs[0x80] = 0x02; dev->shadow_regs[0x81] = 0x08; dev->shadow_regs[0x82] = 0x08; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; /*dev->shadow_regs[0x34] = 0x08; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x36] = 0x06; dev->shadow_regs[0x37] = 0x01; dev->shadow_regs[0x38] = 0x05; dev->shadow_regs[0x80] = 0x09; dev->shadow_regs[0x81] = 0x0c; dev->shadow_regs[0x82] = 0x04; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; */ case X1100_B2_SENSOR: dev->shadow_regs[0x34] = 0x15; dev->shadow_regs[0x36] = 0x15; dev->shadow_regs[0x38] = 0x14; dev->shadow_regs[0x80] = 0x02; dev->shadow_regs[0x81] = 0x02; dev->shadow_regs[0x82] = 0x08; dev->shadow_regs[0x85] = 0x83; dev->shadow_regs[0x86] = 0x7e; dev->shadow_regs[0x87] = 0xad; dev->shadow_regs[0x88] = 0x35; dev->shadow_regs[0x91] = 0xfe; dev->shadow_regs[0x92] = 0xdf; dev->shadow_regs[0x93] = 0x0e; break; case X1100_2C_SENSOR: dev->shadow_regs[0x34] = 0x08; dev->shadow_regs[0x36] = 0x0d; dev->shadow_regs[0x38] = 0x09; dev->shadow_regs[0x80] = 0x0e; dev->shadow_regs[0x81] = 0x02; dev->shadow_regs[0x82] = 0x0a; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x34] = 0x06; dev->shadow_regs[0x36] = 0x0f; dev->shadow_regs[0x38] = 0x09; dev->shadow_regs[0x79] = 0x40; dev->shadow_regs[0x80] = 0x0e; dev->shadow_regs[0x81] = 0x0e; dev->shadow_regs[0x82] = 0x00; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x04; dev->shadow_regs[0x91] = 0x60; dev->shadow_regs[0x92] = 0x85; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x34] = 0x07; dev->shadow_regs[0x36] = 0x0a; dev->shadow_regs[0x38] = 0x04; /* data compression dev->shadow_regs[0x40] = 0x90; dev->shadow_regs[0x50] = 0x20; */ /* no data compression */ dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x80] = 0x02; dev->shadow_regs[0x81] = 0x00; dev->shadow_regs[0x82] = 0x06; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x34] = 0x0d; dev->shadow_regs[0x36] = 0x13; dev->shadow_regs[0x38] = 0x10; dev->shadow_regs[0x80] = 0x04; dev->shadow_regs[0x81] = 0x0e; dev->shadow_regs[0x82] = 0x08; dev->shadow_regs[0x85] = 0x02; dev->shadow_regs[0x86] = 0x3b; dev->shadow_regs[0x87] = 0x0f; dev->shadow_regs[0x88] = 0x24; dev->shadow_regs[0x91] = 0x19; dev->shadow_regs[0x92] = 0x30; dev->shadow_regs[0x93] = 0x0e; dev->shadow_regs[0xc5] = 0x17; dev->shadow_regs[0xc6] = 0x09; dev->shadow_regs[0xca] = 0x0a; break; } switch (dev->model.motor_type) { case X74_MOTOR: /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x81; /* ? */ dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x21; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x20; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x00; dev->shadow_regs[0xe1] = 0x00; /* step size range0 */ dev->shadow_regs[0xe2] = 0xbf; /* ? */ dev->shadow_regs[0xe3] = 0x05; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x00; dev->shadow_regs[0xe5] = 0x00; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0d; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* bounds of movement range4 -only for 75dpi grayscale */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; break; case A920_MOTOR: case X1100_MOTOR: /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x86; /* ? */ dev->shadow_regs[0xc5] = 0x27; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x0c; /* ? */ dev->shadow_regs[0xc9] = 0x3a; dev->shadow_regs[0xca] = 0x1a; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x57; dev->shadow_regs[0xe1] = 0x0a; /* step size range0 */ dev->shadow_regs[0xe2] = 0xbf; /* ? */ dev->shadow_regs[0xe3] = 0x05; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x3b; dev->shadow_regs[0xe5] = 0x0a; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0e; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; break; } /* set colour scan */ dev->shadow_regs[0x2f] = 0x11; dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x37] = 0x01; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x03; /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 2); } else { switch (dev->model.sensor_type) { case X74_SENSOR: dev->shadow_regs[0x2c] = 0x04; dev->shadow_regs[0x2d] = 0x46; dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x35] = 0x05; dev->shadow_regs[0x36] = 0x0b; dev->shadow_regs[0x37] = 0x0b; dev->shadow_regs[0x38] = 0x11; dev->shadow_regs[0x40] = 0x40; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_B2_SENSOR: dev->shadow_regs[0x34] = 0x11; dev->shadow_regs[0x35] = 0x11; dev->shadow_regs[0x36] = 0x21; dev->shadow_regs[0x37] = 0x21; dev->shadow_regs[0x38] = 0x31; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case X1100_2C_SENSOR: dev->shadow_regs[0x34] = 0x07; dev->shadow_regs[0x35] = 0x07; dev->shadow_regs[0x36] = 0x0d; dev->shadow_regs[0x37] = 0x0d; dev->shadow_regs[0x38] = 0x13; dev->shadow_regs[0x85] = 0x20; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; break; case A920_SENSOR: dev->shadow_regs[0x34] = 0x05; dev->shadow_regs[0x35] = 0x05; dev->shadow_regs[0x36] = 0x0b; dev->shadow_regs[0x37] = 0x0b; dev->shadow_regs[0x38] = 0x11; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x04; dev->shadow_regs[0x91] = 0xe0; dev->shadow_regs[0x92] = 0x85; dev->shadow_regs[0x93] = 0x0e; break; case X1200_SENSOR: dev->shadow_regs[0x34] = 0x03; dev->shadow_regs[0x35] = 0x03; dev->shadow_regs[0x36] = 0x07; dev->shadow_regs[0x37] = 0x07; dev->shadow_regs[0x38] = 0x0b; /* data compression dev->shadow_regs[0x40] = 0x90; dev->shadow_regs[0x50] = 0x20; */ /* no data compression */ dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0xff; dev->shadow_regs[0x88] = 0x02; dev->shadow_regs[0x92] = 0x00; break; case X1200_USB2_SENSOR: dev->shadow_regs[0x34] = 0x03; dev->shadow_regs[0x35] = 0x03; dev->shadow_regs[0x36] = 0x07; dev->shadow_regs[0x37] = 0x07; dev->shadow_regs[0x38] = 0x0b; dev->shadow_regs[0x40] = 0x80; dev->shadow_regs[0x50] = 0x00; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0xff; dev->shadow_regs[0x88] = 0x02; dev->shadow_regs[0x92] = 0x00; break; } switch (dev->model.motor_type) { case X74_MOTOR: /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 1); /* ? */ dev->shadow_regs[0xc4] = 0x20; dev->shadow_regs[0xc5] = 0x22; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x0b; dev->shadow_regs[0xc8] = 0x04; dev->shadow_regs[0xc9] = 0x39; dev->shadow_regs[0xca] = 0x1f; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x2f; dev->shadow_regs[0xe1] = 0x11; /* step size range0 */ dev->shadow_regs[0xe2] = 0x9f; /* ? */ dev->shadow_regs[0xe3] = 0x0f; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0xcb; dev->shadow_regs[0xe5] = 0x10; /* step size range1 */ dev->shadow_regs[0xe6] = 0x64; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x32; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x0c; /* bounds of movement range4 -only for 75dpi grayscale */ dev->shadow_regs[0xed] = 0x00; dev->shadow_regs[0xee] = 0x00; /* step size range4 */ dev->shadow_regs[0xef] = 0x08; break; case X1100_MOTOR: case A920_MOTOR: /* set ? only for colour? */ dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x00; dev->shadow_regs[0x82] = 0x00; /* ? */ dev->shadow_regs[0xc5] = 0x22; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; /* ? */ dev->shadow_regs[0xc9] = 0x3b; dev->shadow_regs[0xca] = 0x1f; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0xf7; dev->shadow_regs[0xe1] = 0x16; /* step size range0 */ dev->shadow_regs[0xe2] = 0x87; /* ? */ dev->shadow_regs[0xe3] = 0x13; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x1b; dev->shadow_regs[0xe5] = 0x16; /* step size range1 */ dev->shadow_regs[0xe6] = 0xdc; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x1b; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x07; /* step size range4 */ dev->shadow_regs[0xef] = 0x03; break; } /* set grayscale scan */ dev->shadow_regs[0x2f] = 0x21; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x01; /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 1); /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x81; } /* else (grayscale) */ /* set horizontal resolution */ dev->shadow_regs[0x79] = 0x40; } /*600dpi x 1200dpi */ if (resolution == 1200) { DBG (5, "sanei_lexmark_low_set_scan_regs(): 1200 DPI resolution\n"); /* 1200 dpi doesn't work for X74 yet */ if (dev->model.sensor_type == X74_SENSOR) return SANE_STATUS_INVAL; if (isColourScan) { /* set colour scan */ dev->shadow_regs[0x2f] = 0x11; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x01; /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 2); if (dev->model.sensor_type == X1100_B2_SENSOR) { /* set ? */ dev->shadow_regs[0x34] = 0x29; dev->shadow_regs[0x36] = 0x29; dev->shadow_regs[0x38] = 0x28; /* set ? */ dev->shadow_regs[0x80] = 0x04; dev->shadow_regs[0x81] = 0x04; dev->shadow_regs[0x82] = 0x08; dev->shadow_regs[0x85] = 0x83; dev->shadow_regs[0x86] = 0x7e; dev->shadow_regs[0x87] = 0xad; dev->shadow_regs[0x88] = 0x35; dev->shadow_regs[0x91] = 0xfe; dev->shadow_regs[0x92] = 0xdf; } else { /* A920 case */ dev->shadow_regs[0x34] = 0x0c; dev->shadow_regs[0x36] = 0x1e; dev->shadow_regs[0x38] = 0x10; dev->shadow_regs[0x80] = 0x0c; dev->shadow_regs[0x81] = 0x08; dev->shadow_regs[0x82] = 0x0c; dev->shadow_regs[0x85] = 0x05; dev->shadow_regs[0x86] = 0x14; dev->shadow_regs[0x87] = 0x06; dev->shadow_regs[0x88] = 0x04; dev->shadow_regs[0x91] = 0x60; dev->shadow_regs[0x92] = 0x85; } dev->shadow_regs[0x35] = 0x01; dev->shadow_regs[0x37] = 0x01; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x01; dev->shadow_regs[0x93] = 0x0e; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x86; /* ? */ dev->shadow_regs[0xc5] = 0x41; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x0c; /* ? */ dev->shadow_regs[0xc9] = 0x3a; dev->shadow_regs[0xca] = 0x40; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x00; dev->shadow_regs[0xe1] = 0x00; /* step size range0 */ dev->shadow_regs[0xe2] = 0x85; /* ? */ dev->shadow_regs[0xe3] = 0x0b; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x00; dev->shadow_regs[0xe5] = 0x00; /* step size range1 */ dev->shadow_regs[0xe6] = 0x0e; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x05; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x01; /* step size range4 */ dev->shadow_regs[0xef] = 0x01; } else { /* set grayscale scan */ dev->shadow_regs[0x2f] = 0x21; /* set ? */ dev->shadow_regs[0x34] = 0x22; dev->shadow_regs[0x35] = 0x22; dev->shadow_regs[0x36] = 0x42; dev->shadow_regs[0x37] = 0x42; dev->shadow_regs[0x38] = 0x62; /* set motor resolution divisor */ dev->shadow_regs[0x39] = 0x01; /* set # of head moves per CIS read */ rts88xx_set_scan_frequency (dev->shadow_regs, 0); /* set ? only for colour? */ dev->shadow_regs[0x80] = 0x00; dev->shadow_regs[0x81] = 0x00; dev->shadow_regs[0x82] = 0x00; dev->shadow_regs[0x85] = 0x00; dev->shadow_regs[0x86] = 0x00; dev->shadow_regs[0x87] = 0x00; dev->shadow_regs[0x88] = 0x00; dev->shadow_regs[0x91] = 0x00; dev->shadow_regs[0x92] = 0x00; dev->shadow_regs[0x93] = 0x06; /* Motor enable & Coordinate space denominator */ dev->shadow_regs[0xc3] = 0x81; /* ? */ dev->shadow_regs[0xc5] = 0x41; /* Movement direction & step size */ dev->shadow_regs[0xc6] = 0x09; /* ? */ dev->shadow_regs[0xc9] = 0x3a; dev->shadow_regs[0xca] = 0x40; /* bounds of movement range0 */ dev->shadow_regs[0xe0] = 0x00; dev->shadow_regs[0xe1] = 0x00; /* step size range0 */ dev->shadow_regs[0xe2] = 0xc7; /* ? */ dev->shadow_regs[0xe3] = 0x29; /* bounds of movement range1 */ dev->shadow_regs[0xe4] = 0x00; dev->shadow_regs[0xe5] = 0x00; /* step size range1 */ dev->shadow_regs[0xe6] = 0xdc; /* bounds of movement range2 */ dev->shadow_regs[0xe7] = 0x00; dev->shadow_regs[0xe8] = 0x00; /* step size range2 */ dev->shadow_regs[0xe9] = 0x1b; /* bounds of movement range3 */ dev->shadow_regs[0xea] = 0x00; dev->shadow_regs[0xeb] = 0x00; /* step size range3 */ dev->shadow_regs[0xec] = 0x07; /* step size range4 */ dev->shadow_regs[0xef] = 0x03; } /* set horizontal resolution */ dev->shadow_regs[0x79] = 0x40; } /* is calibration has been done, we override fixed settings with detected ones */ if (calibrated) { /* override fixed values with ones from calibration */ if (rts88xx_is_color (dev->shadow_regs)) { rts88xx_set_offset (dev->shadow_regs, dev->offset.red, dev->offset.green, dev->offset.blue); rts88xx_set_gain (dev->shadow_regs, dev->gain.red, dev->gain.green, dev->gain.blue); } else { rts88xx_set_offset (dev->shadow_regs, dev->offset.gray, dev->offset.gray, dev->offset.gray); rts88xx_set_gain (dev->shadow_regs, dev->gain.gray, dev->gain.gray, dev->gain.gray); } } DBG (2, "sanei_lexmark_low_set_scan_regs: end.\n"); return SANE_STATUS_GOOD; } SANE_Status sanei_lexmark_low_start_scan (Lexmark_Device * dev) { SANE_Int devnum; static SANE_Byte command4_block[] = { 0x90, 0x00, 0x00, 0x03 }; static SANE_Byte command5_block[] = { 0x80, 0xb3, 0x00, 0x01 }; SANE_Byte poll_result[3]; SANE_Byte read_result; SANE_Bool scan_head_moving; size_t size; devnum = dev->devnum; dev->transfer_buffer = NULL; /* No data xferred yet */ DBG (2, "sanei_lexmark_low_start_scan:\n"); /* 80 b3 00 01 - poll for scanner not moving */ scan_head_moving = SANE_TRUE; while (scan_head_moving) { size = 4; low_usb_bulk_write (devnum, command5_block, &size); size = 0x1; low_usb_bulk_read (devnum, &read_result, &size); if ((read_result & 0xF) == 0x0) { scan_head_moving = SANE_FALSE; } /* F.O. Should be a timeout here so we don't hang if something breaks */ #ifdef FAKE_USB scan_head_moving = SANE_FALSE; #endif } /* Clear C6 */ low_clr_c6 (devnum); /* Stop the scanner */ low_stop_mvmt (devnum); /*Set regs x2 */ dev->shadow_regs[0x32] = 0x00; low_write_all_regs (devnum, dev->shadow_regs); dev->shadow_regs[0x32] = 0x40; low_write_all_regs (devnum, dev->shadow_regs); /* Start Scan */ rts88xx_commit (devnum, dev->shadow_regs[0x2c]); /* We start with 0 bytes remaining to be read */ dev->bytes_remaining = 0; /* and 0 bytes in the transfer buffer */ dev->bytes_in_buffer = 0; dev->bytes_read = 0; /* Poll the available byte count until not 0 */ while (1) { size = 4; low_usb_bulk_write (devnum, command4_block, &size); size = 0x3; low_usb_bulk_read (devnum, poll_result, &size); if (! (poll_result[0] == 0 && poll_result[1] == 0 && poll_result[2] == 0)) { /* if result != 00 00 00 we got data */ /* data_size should be used to set bytes_remaining */ /* data_size is set from sane_get_parameters () */ dev->bytes_remaining = dev->data_size; /* Initialize the read buffer */ read_buffer_init (dev, dev->params.bytes_per_line); return SANE_STATUS_GOOD; } size = 4; /* I'm not sure why the Windows driver does this - probably a timeout? */ low_usb_bulk_write (devnum, command5_block, &size); size = 0x1; low_usb_bulk_read (devnum, &read_result, &size); if (read_result != 0x68) { dev->bytes_remaining = 0; return SANE_STATUS_IO_ERROR; } } DBG (2, "sanei_lexmark_low_start_scan: end.\n"); return SANE_STATUS_GOOD; } long sanei_lexmark_low_read_scan_data (SANE_Byte * data, SANE_Int size, Lexmark_Device * dev) { SANE_Bool isColourScan, isGrayScan; static SANE_Byte command1_block[] = { 0x91, 0x00, 0xff, 0xc0 }; size_t cmd_size, xfer_request; long bytes_read; SANE_Bool even_byte; SANE_Status status; int i, k, val; DBG (2, "sanei_lexmark_low_read_scan_data:\n"); /* colour mode */ isGrayScan = SANE_FALSE; if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) isColourScan = SANE_TRUE; else { isColourScan = SANE_FALSE; /* grayscale mode */ if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY) == 0) isGrayScan = SANE_TRUE; } /* Check if we have a transfer buffer. Create one and fill it if we don't */ if (dev->transfer_buffer == NULL) { if (dev->bytes_remaining > 0) { if (dev->bytes_remaining > MAX_XFER_SIZE) xfer_request = MAX_XFER_SIZE; else xfer_request = dev->bytes_remaining; command1_block[2] = (SANE_Byte) (xfer_request >> 8); command1_block[3] = (SANE_Byte) (xfer_request & 0xFF); /* wait for data */ status = low_poll_data (dev->devnum); if (status != SANE_STATUS_GOOD) { DBG (1, "sanei_lexmark_low_read_scan_data: time-out while waiting for data.\n"); return status; } /* Create buffer to hold the amount we will request */ dev->transfer_buffer = (SANE_Byte *) malloc (MAX_XFER_SIZE); if (dev->transfer_buffer == NULL) return SANE_STATUS_NO_MEM; /* Fill it */ /* Write: 91 00 (xfer_size) */ cmd_size = 4; low_usb_bulk_write (dev->devnum, command1_block, &cmd_size); /* Read: xfer_size bytes */ cmd_size = xfer_request; low_usb_bulk_read (dev->devnum, dev->transfer_buffer, &cmd_size); /* apply shading coefficients */ k = dev->bytes_read % dev->read_buffer->linesize; for (i = 0; i < (int) cmd_size; i++) { val = dev->transfer_buffer[i]; val = (int) ((float) val * dev->shading_coeff[k] + 0.5); if (val > 255) val = 255; dev->transfer_buffer[i] = val; k++; if ((size_t) k == dev->read_buffer->linesize) k = 0; } /* advance by the amount actually read from device */ dev->bytes_read += cmd_size; dev->bytes_remaining -= cmd_size; dev->bytes_in_buffer = cmd_size; dev->read_pointer = dev->transfer_buffer; DBG (2, "sanei_lexmark_low_read_scan_data:\n"); DBG (2, " Filled a buffer from the scanner\n"); DBG (2, " bytes_remaining: %lu\n", (u_long) dev->bytes_remaining); DBG (2, " bytes_in_buffer: %lu\n", (u_long) dev->bytes_in_buffer); DBG (2, " read_pointer: %p\n", dev->read_pointer); } } DBG (5, "READ BUFFER INFO: \n"); DBG (5, " write ptr: %p\n", dev->read_buffer->writeptr); DBG (5, " read ptr: %p\n", dev->read_buffer->readptr); DBG (5, " max write ptr: %p\n", dev->read_buffer->max_writeptr); DBG (5, " buffer size: %lu\n", (u_long) dev->read_buffer->size); DBG (5, " line size: %lu\n", (u_long) dev->read_buffer->linesize); DBG (5, " empty: %d\n", dev->read_buffer->empty); DBG (5, " line no: %d\n", dev->read_buffer->image_line_no); /* If there is space in the read buffer, copy the transfer buffer over */ if (read_buffer_bytes_available (dev->read_buffer) >= dev->bytes_in_buffer) { even_byte = SANE_TRUE; while (dev->bytes_in_buffer) { /* Colour Scan */ if (isColourScan) { if (even_byte) read_buffer_add_byte (dev->read_buffer, dev->read_pointer + 1); else read_buffer_add_byte (dev->read_buffer, dev->read_pointer - 1); even_byte = !even_byte; } /* Gray Scan */ else if (isGrayScan) { if (even_byte) read_buffer_add_byte_gray (dev->read_buffer, dev->read_pointer + 1); else read_buffer_add_byte_gray (dev->read_buffer, dev->read_pointer - 1); even_byte = !even_byte; } /* Lineart Scan */ else { if (even_byte) read_buffer_add_bit_lineart (dev->read_buffer, dev->read_pointer + 1, dev->threshold); else read_buffer_add_bit_lineart (dev->read_buffer, dev->read_pointer - 1, dev->threshold); even_byte = !even_byte; } dev->read_pointer = dev->read_pointer + sizeof (SANE_Byte); dev->bytes_in_buffer--; } /* free the transfer buffer */ free (dev->transfer_buffer); dev->transfer_buffer = NULL; } DBG (5, "READ BUFFER INFO: \n"); DBG (5, " write ptr: %p\n", dev->read_buffer->writeptr); DBG (5, " read ptr: %p\n", dev->read_buffer->readptr); DBG (5, " max write ptr: %p\n", dev->read_buffer->max_writeptr); DBG (5, " buffer size: %lu\n", (u_long) dev->read_buffer->size); DBG (5, " line size: %lu\n", (u_long) dev->read_buffer->linesize); DBG (5, " empty: %d\n", dev->read_buffer->empty); DBG (5, " line no: %d\n", dev->read_buffer->image_line_no); /* Read blocks out of read buffer */ bytes_read = read_buffer_get_bytes (dev->read_buffer, data, size); DBG (2, "sanei_lexmark_low_read_scan_data:\n"); DBG (2, " Copying lines from buffer to data\n"); DBG (2, " bytes_remaining: %lu\n", (u_long) dev->bytes_remaining); DBG (2, " bytes_in_buffer: %lu\n", (u_long) dev->bytes_in_buffer); DBG (2, " read_pointer: %p\n", dev->read_buffer->readptr); DBG (2, " bytes_read %lu\n", (u_long) bytes_read); /* if no more bytes to xfer and read buffer empty we're at the end */ if ((dev->bytes_remaining == 0) && read_buffer_is_empty (dev->read_buffer)) { if (!dev->eof) { DBG (2, "sanei_lexmark_low_read_scan_data: EOF- parking the scanner\n"); dev->eof = SANE_TRUE; low_rewind (dev, dev->shadow_regs); } else { DBG (2, "ERROR: Why are we trying to set eof more than once?\n"); } } DBG (2, "sanei_lexmark_low_read_scan_data: end.\n"); return bytes_read; } void low_rewind (Lexmark_Device * dev, SANE_Byte * regs) { SANE_Int new_location; SANE_Int location; SANE_Int scale; DBG (2, "low_rewind: \n"); /* We rewind at 1200dpi resolution. We rely on content of shadow registers to compute the number of lines at 1200 dpi to go back */ /* first move to start of scanning area */ scale = 600 / dev->val[OPT_RESOLUTION].w; new_location = ((dev->val[OPT_BR_Y].w / scale) * scale) * 2; /* then add distance to go to the "origin dot" */ if (rts88xx_is_color (regs)) new_location += 400; else new_location += 420; if (dev->model.sensor_type == X74_SENSOR) new_location += 150; location = new_location - 1; DBG (2, "low_rewind: %d=>new_location=%d\n", dev->val[OPT_BR_Y].w, new_location); /* stops any pending scan */ low_clr_c6 (dev->devnum); low_cancel (dev->devnum); /* set regs for rewind */ regs[0x2f] = 0xa1; regs[0x32] = 0x00; regs[0x39] = 0x00; /* all other regs are always the same. these ones change with parameters */ /* the following 4 regs are the location 61,60 and the location+1 63,62 */ regs[0x60] = LOBYTE (location); regs[0x61] = HIBYTE (location); regs[0x62] = LOBYTE (new_location); regs[0x63] = HIBYTE (new_location); switch (dev->model.motor_type) { case X74_MOTOR: regs[0xc3] = 0x81; regs[0xc6] = 0x03; regs[0xc9] = 0x39; regs[0xe0] = 0x81; regs[0xe1] = 0x16; regs[0xe2] = 0xe1; regs[0xe3] = 0x04; regs[0xe4] = 0xe7; regs[0xe5] = 0x14; regs[0xe6] = 0x64; regs[0xe7] = 0xd5; regs[0xe8] = 0x08; regs[0xe9] = 0x32; regs[0xea] = 0xed; regs[0xeb] = 0x04; regs[0xec] = 0x0c; regs[0xef] = 0x08; break; case X1100_MOTOR: case A920_MOTOR: /* set regs for rewind */ regs[0x79] = 0x40; regs[0xb2] = 0x04; regs[0xc3] = 0x81; regs[0xc6] = 0x01; regs[0xc9] = 0x3b; regs[0xe0] = 0x2b; regs[0xe1] = 0x17; regs[0xe2] = 0xe7; regs[0xe3] = 0x03; regs[0xe6] = 0xdc; regs[0xe7] = 0xb3; regs[0xe8] = 0x07; regs[0xe9] = 0x1b; regs[0xea] = 0x00; regs[0xeb] = 0x00; regs[0xec] = 0x07; regs[0xef] = 0x03; break; } /* starts scan */ low_start_scan (dev->devnum, regs); DBG (2, "low_rewind: end.\n"); } SANE_Status read_buffer_init (Lexmark_Device * dev, int bytesperline) { size_t no_lines_in_buffer; DBG (2, "read_buffer_init: Start\n"); dev->read_buffer = (Read_Buffer *) malloc (sizeof (Read_Buffer)); if (dev->read_buffer == NULL) return SANE_STATUS_NO_MEM; dev->read_buffer->linesize = bytesperline; dev->read_buffer->gray_offset = 0; dev->read_buffer->max_gray_offset = bytesperline - 1; dev->read_buffer->region = RED; dev->read_buffer->red_offset = 0; dev->read_buffer->green_offset = 1; dev->read_buffer->blue_offset = 2; dev->read_buffer->max_red_offset = bytesperline - 3; dev->read_buffer->max_green_offset = bytesperline - 2; dev->read_buffer->max_blue_offset = bytesperline - 1; no_lines_in_buffer = 3 * MAX_XFER_SIZE / bytesperline; dev->read_buffer->size = bytesperline * no_lines_in_buffer; dev->read_buffer->data = (SANE_Byte *) malloc (dev->read_buffer->size); if (dev->read_buffer->data == NULL) return SANE_STATUS_NO_MEM; dev->read_buffer->readptr = dev->read_buffer->data; dev->read_buffer->writeptr = dev->read_buffer->data; dev->read_buffer->max_writeptr = dev->read_buffer->data + (no_lines_in_buffer - 1) * bytesperline; dev->read_buffer->empty = SANE_TRUE; dev->read_buffer->image_line_no = 0; dev->read_buffer->bit_counter = 0; dev->read_buffer->max_lineart_offset = dev->params.pixels_per_line - 1; return SANE_STATUS_GOOD; } SANE_Status read_buffer_free (Read_Buffer * read_buffer) { DBG (2, "read_buffer_free:\n"); if (read_buffer) { free (read_buffer->data); free (read_buffer); read_buffer = NULL; } return SANE_STATUS_GOOD; } size_t read_buffer_bytes_available (Read_Buffer * rb) { DBG (2, "read_buffer_bytes_available:\n"); if (rb->empty) return rb->size; else if ((size_t) abs (rb->writeptr - rb->readptr) < rb->linesize) return 0; /* ptrs are less than one line apart */ else if (rb->writeptr < rb->readptr) return (rb->readptr - rb->writeptr - rb->linesize); else return (rb->size + rb->readptr - rb->writeptr - rb->linesize); } SANE_Status read_buffer_add_byte (Read_Buffer * rb, SANE_Byte * byte_pointer) { /* DBG(2, "read_buffer_add_byte:\n"); */ /* F.O. Need to fix the endian byte ordering here */ switch (rb->region) { case RED: *(rb->writeptr + rb->red_offset) = *byte_pointer; if (rb->red_offset == rb->max_red_offset) { rb->red_offset = 0; rb->region = GREEN; } else rb->red_offset = rb->red_offset + (3 * sizeof (SANE_Byte)); return SANE_STATUS_GOOD; case GREEN: *(rb->writeptr + rb->green_offset) = *byte_pointer; if (rb->green_offset == rb->max_green_offset) { rb->green_offset = 1; rb->region = BLUE; } else rb->green_offset = rb->green_offset + (3 * sizeof (SANE_Byte)); return SANE_STATUS_GOOD; case BLUE: *(rb->writeptr + rb->blue_offset) = *byte_pointer; if (rb->blue_offset == rb->max_blue_offset) { rb->image_line_no++; /* finished a line. read_buffer no longer empty */ rb->empty = SANE_FALSE; rb->blue_offset = 2; rb->region = RED; if (rb->writeptr == rb->max_writeptr) rb->writeptr = rb->data; /* back to beginning of buffer */ else rb->writeptr = rb->writeptr + rb->linesize; /* next line */ } else rb->blue_offset = rb->blue_offset + (3 * sizeof (SANE_Byte)); return SANE_STATUS_GOOD; } return SANE_STATUS_GOOD; } SANE_Status read_buffer_add_byte_gray (Read_Buffer * rb, SANE_Byte * byte_pointer) { /* DBG(2, "read_buffer_add_byte_gray:\n"); */ *(rb->writeptr + rb->gray_offset) = *byte_pointer; if (rb->gray_offset == rb->max_gray_offset) { rb->image_line_no++; /* finished a line. read_buffer no longer empty */ rb->empty = SANE_FALSE; rb->gray_offset = 0; if (rb->writeptr == rb->max_writeptr) rb->writeptr = rb->data; /* back to beginning of buffer */ else rb->writeptr = rb->writeptr + rb->linesize; /* next line */ } else rb->gray_offset = rb->gray_offset + (1 * sizeof (SANE_Byte)); return SANE_STATUS_GOOD; } SANE_Status read_buffer_add_bit_lineart (Read_Buffer * rb, SANE_Byte * byte_pointer, SANE_Byte threshold) { SANE_Byte tmpByte; SANE_Byte *currentBytePtr; SANE_Int bitIndex; /* DBG(2, "read_buffer_add_bit_lineart:\n"); */ /* threshold = 0x80; */ tmpByte = 0; /* Create a bit by comparing incoming byte to threshold */ if (*byte_pointer <= threshold) { tmpByte = 128; } /* Calculate the bit index in the current byte */ bitIndex = rb->bit_counter % 8; /* Move the bit to its correct position in the temporary byte */ tmpByte = tmpByte >> bitIndex; /* Get the pointer to the current byte */ currentBytePtr = rb->writeptr + rb->gray_offset; /* If this is the first write to this byte, clear the byte */ if (bitIndex == 0) *currentBytePtr = 0; /* Set the value of the bit in the current byte */ *currentBytePtr = *currentBytePtr | tmpByte; /* last bit in the line? */ if (rb->bit_counter == rb->max_lineart_offset) { /* Check if we're at the last byte of the line - error if not */ if (rb->gray_offset != rb->max_gray_offset) { DBG (5, "read_buffer_add_bit_lineart:\n"); DBG (5, " Last bit of line is not last byte.\n"); DBG (5, " Bit Index: %d, Byte Index: %d. \n", rb->bit_counter, rb->max_gray_offset); return SANE_STATUS_INVAL; } rb->image_line_no++; /* line finished read_buffer no longer empty */ rb->empty = SANE_FALSE; rb->gray_offset = 0; /* are we at the last line in the read buffer ? */ if (rb->writeptr == rb->max_writeptr) rb->writeptr = rb->data; /* back to beginning of buffer */ else rb->writeptr = rb->writeptr + rb->linesize; /* next line */ /* clear the bit counter */ rb->bit_counter = 0; } /* last bit in the byte? */ else if (bitIndex == 7) { /* Not at the end of the line, but byte done. Increment byte offset */ rb->gray_offset = rb->gray_offset + (1 * sizeof (SANE_Byte)); /* increment bit counter */ rb->bit_counter++; } else { /* else increment bit counter */ rb->bit_counter++; } return SANE_STATUS_GOOD; } size_t read_buffer_get_bytes (Read_Buffer * rb, SANE_Byte * buffer, size_t rqst_size) { /* Read_Buffer *rb; */ size_t available_bytes; /* rb = read_buffer; */ if (rb->empty) return 0; else if (rb->writeptr > rb->readptr) { available_bytes = rb->writeptr - rb->readptr; if (available_bytes <= rqst_size) { /* We can read from the read pointer up to the write pointer */ memcpy (buffer, rb->readptr, available_bytes); rb->readptr = rb->writeptr; rb->empty = SANE_TRUE; return available_bytes; } else { /* We can read from the full request size */ memcpy (buffer, rb->readptr, rqst_size); rb->readptr = rb->readptr + rqst_size; return rqst_size; } } else { /* The read pointer is ahead of the write pointer. Its wrapped around. */ /* We can read to the end of the buffer and make a recursive call to */ /* read any available lines at the beginning of the buffer */ available_bytes = rb->data + rb->size - rb->readptr; if (available_bytes <= rqst_size) { /* We can read from the read pointer up to the end of the buffer */ memcpy (buffer, rb->readptr, available_bytes); rb->readptr = rb->data; if (rb->writeptr == rb->readptr) rb->empty = SANE_TRUE; return available_bytes + read_buffer_get_bytes (rb, buffer + available_bytes, rqst_size - available_bytes); } else { /* We can read from the full request size */ memcpy (buffer, rb->readptr, rqst_size); rb->readptr = rb->readptr + rqst_size; return rqst_size; } } } SANE_Bool read_buffer_is_empty (Read_Buffer * read_buffer) { return read_buffer->empty; } /* * average a width*height rgb/monochrome area * return values in given pointers */ static int average_area (SANE_Byte * regs, SANE_Byte * data, int width, int height, int *ra, int *ga, int *ba) { int x, y; int global = 0; int rc, gc, bc; *ra = 0; *ga = 0; *ba = 0; rc = 0; gc = 0; bc = 0; if (rts88xx_is_color (regs)) { for (x = 0; x < width; x++) for (y = 0; y < height; y++) { rc += data[3 * width * y + x]; gc += data[3 * width * y + width + x]; bc += data[3 * width * y + 2 * width + x]; } global = (rc + gc + bc) / (3 * width * height); *ra = rc / (width * height); *ga = gc / (width * height); *ba = bc / (width * height); } else { for (x = 0; x < width; x++) for (y = 0; y < height; y++) { gc += data[width * y + x]; } global = gc / (width * height); *ga = gc / (width * height); } DBG (7, "average_area: global=%d, red=%d, green=%d, blue=%d\n", global, *ra, *ga, *ba); return global; } /** * we scan a dark area with gain minimum to detect offset */ SANE_Status sanei_lexmark_low_offset_calibration (Lexmark_Device * dev) { SANE_Byte regs[255]; /* we have our own copy of shadow registers */ SANE_Status status = SANE_STATUS_GOOD; int i, lines = 8, yoffset = 2; int pixels; int failed = 0; /* offsets */ int ro = 0, go = 0, bo = 0; /* averages */ int ra, ga, ba, average; SANE_Byte *data = NULL; SANE_Byte top[OFFSET_RANGES] = { 0, 0x7f, 0x9f, 0xbf, 0xff }; #ifdef DEEP_DEBUG char title[20]; #endif DBG (2, "sanei_lexmark_low_offset_calibration: start\n"); /* copy registers */ for (i = 0; i < 255; i++) regs[i] = dev->shadow_regs[i]; /* we clear movement bit */ regs[0xc3] = regs[0xc3] & 0x7f; pixels = (dev->sensor->offset_endx - dev->sensor->offset_startx) / regs[0x7a]; /* there are 4 ranges of offset: 00-7F : almost no offset 80-9F : high noise A0-BF : high noise C0-FF : high noise we start with the highest one and decrease until overall offset is ok First loop may have such an high offset that scanned data overflow and gives a low average. So we allways skip its results */ /* minimal gains */ DBG (3, "sanei_lexmark_low_offset_calibration: setting gains to (1,1,1).\n"); rts88xx_set_gain (regs, 1, 1, 1); i = OFFSET_RANGES; average = 255; /* loop on ranges until one fits. Then adjust offset, first loop is * always done. TODO detect overflow by 'noise looking' data pattern */ while (((i > 0) && (average > dev->sensor->offset_threshold)) || (i == OFFSET_RANGES)) { /* next range */ i--; /* sets to top of range */ ro = top[i]; go = top[i]; bo = top[i]; rts88xx_set_offset (regs, ro, ro, ro); DBG (3, "sanei_lexmark_low_offset_calibration: setting offsets to (%d,%d,%d).\n", ro, ro, ro); status = low_simple_scan (dev, regs, dev->sensor->offset_startx, pixels, yoffset, lines, &data); if (status != SANE_STATUS_GOOD) { DBG (1, "sanei_lexmark_low_offset_calibration: low_simple_scan failed!\n"); if (data != NULL) free (data); return status; } #ifdef DEEP_DEBUG sprintf (title, "offset%02x.pnm", ro); write_pnm_file (title, pixels, lines, rts88xx_is_color (regs), data); #endif average = average_area (regs, data, pixels, lines, &ra, &ga, &ba); free (data); } if (i == 0) { DBG (2, "sanei_lexmark_low_offset_calibration: failed !\n"); failed = 1; } /* increase gain and scan again */ /* increase gain for fine offset tuning */ rts88xx_set_gain (regs, 6, 6, 6); status = low_simple_scan (dev, regs, dev->sensor->offset_startx, pixels, yoffset, lines, &data); if (status != SANE_STATUS_GOOD) { DBG (1, "sanei_lexmark_low_offset_calibration: low_simple_scan failed!\n"); if (data != NULL) free (data); return status; } average_area (regs, data, pixels, lines, &ra, &ga, &ba); #ifdef DEEP_DEBUG write_pnm_file ("offset-final.pnm", pixels, lines, rts88xx_is_color (regs), data); #endif /* this "law" is a guess, may (should?) be changed ... */ if (!failed) { if (ro > ra) dev->offset.red = ro - ra; if (go > ga) { dev->offset.green = go - ga; dev->offset.gray = go - ga; } if (bo > ba) dev->offset.blue = bo - ba; } else { dev->offset.red = dev->sensor->offset_fallback; dev->offset.green = dev->sensor->offset_fallback; dev->offset.blue = dev->sensor->offset_fallback; } DBG (7, "sanei_lexmark_low_offset_calibration: offset=(0x%02x,0x%02x,0x%02x).\n", dev->offset.red, dev->offset.green, dev->offset.blue); DBG (2, "sanei_lexmark_low_offset_calibration: end.\n"); free (data); return status; } /* * we scan a white area until average is good enough * level is good enough when it maximize the range value of output: * ie max-min is maximum */ SANE_Status sanei_lexmark_low_gain_calibration (Lexmark_Device * dev) { SANE_Byte regs[255]; /* we have our own copy of shadow registers */ SANE_Status status = SANE_STATUS_GOOD; int i, lines = 4, yoffset = 1; int sx, ex; int pixels; /* averages */ int ra, ga, ba; SANE_Byte *data = NULL; int red, green, blue; #ifdef DEEP_DEBUG char title[20]; #endif DBG (2, "sanei_lexmark_low_gain_calibration: start\n"); /* copy registers */ for (i = 0; i < 255; i++) regs[i] = dev->shadow_regs[i]; /* we clear movement bit */ regs[0xc3] = regs[0xc3] & 0x7f; sx = regs[0x67] * 256 + regs[0x66]; ex = regs[0x6d] * 256 + regs[0x6c]; pixels = (ex - sx) / regs[0x7a]; /* set up inital gains */ red = 6; green = 6; blue = 6; rts88xx_set_gain (regs, red, green, blue); /* init loop */ i = 0; ra = 0; ba = 0; ga = 0; status = low_cancel (dev->devnum); if (status != SANE_STATUS_GOOD) return status; /* we do a simple scan all 3 averages give the choosen level */ while (((rts88xx_is_color (regs) && ((ra < dev->sensor->red_gain_target) || (ga < dev->sensor->green_gain_target) || (ba < dev->sensor->blue_gain_target))) || (!rts88xx_is_color (regs) && (ga < dev->sensor->gray_gain_target))) && (i < 25)) { status = low_simple_scan (dev, regs, sx, pixels, yoffset, lines, &data); if (status != SANE_STATUS_GOOD) { DBG (1, "sanei_lexmark_low_gain_calibration: low_simple_scan failed!\n"); if (data != NULL) free (data); return status; } #ifdef DEEP_DEBUG sprintf (title, "gain%02d.pnm", i); write_pnm_file (title, pixels, lines, rts88xx_is_color (regs), data); #endif average_area (regs, data, pixels, lines, &ra, &ga, &ba); free (data); if (ra < dev->sensor->red_gain_target) red++; if (ga < dev->sensor->green_gain_target || (dev->sensor->gray_gain_target && !rts88xx_is_color (regs))) green++; if (ba < dev->sensor->blue_gain_target) blue++; rts88xx_set_gain (regs, red, green, blue); i++; } dev->gain.red = red; dev->gain.green = green; dev->gain.blue = blue; dev->gain.gray = green; DBG (7, "sanei_lexmark_low_gain_calibration: gain=(0x%02x,0x%02x,0x%02x).\n", dev->gain.red, dev->gain.green, dev->gain.blue); DBG (2, "sanei_lexmark_low_gain_calibration: end.\n"); return status; } /** * there is no hardware shading correction. So we have to do it in software. * We do it by scanning a pure white area which is before scanning area. Then * we compute per pixel coefficient to move the scanned value to the target * value. These coefficients are used later to correct scanned data. * The scan is done with all the final scan settings but the heigth and vertical * start position. */ SANE_Status sanei_lexmark_low_shading_calibration (Lexmark_Device * dev) { SANE_Byte regs[255]; /* we have our own copy of shadow registers */ int i, j, pixels, bpl; int sx, ex; SANE_Byte *data = NULL; SANE_Status status; /* enough 75 dpi lines to "go off" home position dot, and include shading area */ int lines = 4 + 4; int lineoffset = 1; int linetotal = lines + lineoffset; int yoffset; int x, y; float rtarget, btarget, gtarget; DBG (2, "sanei_lexmark_low_shading_calibration: start\n"); /* copy registers */ for (i = 0; i < 255; i++) regs[i] = dev->shadow_regs[i]; /* allocate memory for scan */ sx = regs[0x67] * 256 + regs[0x66]; ex = regs[0x6d] * 256 + regs[0x6c]; DBG (7, "startx=%d, endx=%d, coef=%d, r2f=0x%02x\n", sx, ex, regs[0x7a], regs[0x2f]); pixels = (ex - sx) / regs[0x7a]; if (rts88xx_is_color (regs)) bpl = 3 * pixels; else bpl = pixels; /* adjust the target area to the scanning resolution */ lines = (8 * lines) / regs[0x7a]; lineoffset = (8 * lineoffset) / regs[0x7a]; linetotal = (8 * linetotal) / regs[0x7a]; data = (SANE_Byte *) malloc (bpl * lines); DBG (7, "pixels=%d, lines=%d, size=%d\n", pixels, lines, bpl * lines); if (data == NULL) { DBG (2, "sanei_lexmark_low_shading_calibration: failed to allocate %d bytes !\n", bpl * lines); return SANE_STATUS_NO_MEM; } if (dev->shading_coeff != NULL) free (dev->shading_coeff); dev->shading_coeff = (float *) malloc (bpl * sizeof (float)); if (dev->shading_coeff == NULL) { DBG (2, "sanei_lexmark_low_shading_calibration: failed to allocate %d floats !\n", bpl); free (data); return SANE_STATUS_NO_MEM; } /* we set movement bit this time */ regs[0xc3] = regs[0xc3] | 0x80; /* execute scan */ status = low_simple_scan (dev, regs, sx, pixels, lineoffset, lines, &data); if (status != SANE_STATUS_GOOD) { DBG (1, "sanei_lexmark_low_shading_calibration: low_simple_scan failed!\n"); if (data != NULL) free (data); return status; } yoffset = -1; /* the very first lines of the scan may include the dark dot used * locate park position. We find the first line free of it in the scan. * We can't use is_home_line since it modifies data. */ for (y = 0; (y < lines) && (yoffset == y - 1); y++) { if (rts88xx_is_color (regs)) { for (x = 0; x < 3 * pixels; x++) { if (data[x + y * 3 * pixels] < 30) yoffset = y; } } else { for (x = 0; x < pixels; x++) { if (data[x + y * pixels] < 30) yoffset = y; } } } /* make sure we are really out of the dot */ yoffset++; /* yoffset is index of last dot line, go to first white line */ if (yoffset >= lines - 1) { DBG (7, "sanei_lexmark_low_shading_calibration: failed to detect yoffset.\n"); /* fail safe fallback, picture will be altered at dot position, but scanner is safe */ yoffset = lines - 2; } else yoffset++; DBG (7, "sanei_lexmark_low_shading_calibration: yoffset=%d.\n", yoffset); #ifdef DEEP_DEBUG write_pnm_file ("shading.pnm", pixels, lines, rts88xx_is_color (regs), data); #endif /* computes coefficients */ /* there are 8 lines usable for shading calibration at 150 dpi, between bottom of "home position" dot and the start of the scanner's window assembly, we only use 7 of them */ if (yoffset + (8 * 4) / regs[0x7a] < lines) lines = yoffset + (8 * 4) / regs[0x7a]; rtarget = dev->sensor->red_shading_target; gtarget = dev->sensor->green_shading_target; btarget = dev->sensor->blue_shading_target; for (i = 0; i < pixels; i++) { /* we computes the coefficient needed to move the scanned value to the target value */ if (rts88xx_is_color (dev->shadow_regs)) { /* RED */ dev->shading_coeff[i] = 0; for (j = yoffset; j < lines; j++) dev->shading_coeff[i] += data[i + j * bpl]; dev->shading_coeff[i] = (rtarget / (dev->shading_coeff[i] / (lines - yoffset))); /* GREEN */ dev->shading_coeff[i + pixels] = 0; for (j = yoffset; j < lines; j++) dev->shading_coeff[i + pixels] += data[i + j * bpl + pixels]; dev->shading_coeff[i + pixels] = ((gtarget / dev->shading_coeff[i + pixels]) * (lines - yoffset)); /* BLUE */ dev->shading_coeff[i + 2 * pixels] = 0; for (j = yoffset; j < lines; j++) dev->shading_coeff[i + 2 * pixels] += data[i + j * bpl + 2 * pixels]; dev->shading_coeff[i + 2 * pixels] = ((btarget / dev->shading_coeff[i + 2 * pixels]) * (lines - yoffset)); } else { dev->shading_coeff[i] = 0; for (j = yoffset; j < lines; j++) { dev->shading_coeff[i] += data[i + j * bpl]; } dev->shading_coeff[i] = (rtarget / dev->shading_coeff[i]) * (lines - yoffset); } } free(data); /* do the scan backward to go back to start position */ regs[0xc6] &= 0xF7; lines = (8 * 8) / regs[0x7a]; /* it shoud use linetotal to account for the lineoffset */ if (dev->model.sensor_type == X74_SENSOR) lines = linetotal; /* execute scan */ status = low_simple_scan (dev, regs, sx, pixels, 1, lines, &data); if (status != SANE_STATUS_GOOD) { DBG (1, "sanei_lexmark_low_shading_calibration: low_simple_scan failed!\n"); if(data!=NULL) free(data); return status; } #ifdef DEEP_DEBUG write_pnm_file ("shading_bwd.pnm", pixels, lines, rts88xx_is_color (regs), data); #endif free (data); DBG (2, "sanei_lexmark_low_shading_calibration: end.\n"); return status; } SANE_Status sanei_lexmark_low_calibration (Lexmark_Device * dev) { SANE_Status status; DBG (2, "sanei_lexmark_low_calibration: start.\n"); status = sanei_lexmark_low_offset_calibration (dev); if (status != SANE_STATUS_GOOD) return status; /* we put the offset just computed in scanning regs */ if (rts88xx_is_color (dev->shadow_regs)) { rts88xx_set_offset (dev->shadow_regs, dev->offset.red, dev->offset.green, dev->offset.blue); } else { rts88xx_set_offset (dev->shadow_regs, dev->offset.gray, dev->offset.gray, dev->offset.gray); } /* if manual gain settings, no gain calibration */ if (dev->val[OPT_MANUAL_GAIN].w == SANE_TRUE) { if (rts88xx_is_color (dev->shadow_regs)) { dev->gain.red = dev->val[OPT_RED_GAIN].w; dev->gain.green = dev->val[OPT_GREEN_GAIN].w; dev->gain.blue = dev->val[OPT_BLUE_GAIN].w; } else dev->gain.gray = dev->val[OPT_GRAY_GAIN].w; } else { status = sanei_lexmark_low_gain_calibration (dev); if (status != SANE_STATUS_GOOD) return status; } /* put the calibrated or manual settings before shading calibration which must be done with final setting values */ if (rts88xx_is_color (dev->shadow_regs)) { rts88xx_set_gain (dev->shadow_regs, dev->gain.red, dev->gain.green, dev->gain.blue); } else { rts88xx_set_gain (dev->shadow_regs, dev->gain.gray, dev->gain.gray, dev->gain.gray); } status = sanei_lexmark_low_shading_calibration (dev); if (status != SANE_STATUS_GOOD) return status; DBG (2, "sanei_lexmark_low_calibration: end.\n"); return SANE_STATUS_GOOD; } /* assign sensor data */ static SANE_Status sanei_lexmark_low_assign_sensor (Lexmark_Device * dev) { int dn; /* init sensor data */ dn = 0; while (sensor_list[dn].id != 0 && sensor_list[dn].id != dev->model.sensor_type) dn++; if (sensor_list[dn].id == 0) { DBG (1, "sanei_lexmark_low_assign_sensor: unknown sensor %d\n", dev->model.sensor_type); return SANE_STATUS_UNSUPPORTED; } dev->sensor = &(sensor_list[dn]); DBG (1, "sanei_lexmark_low_assign_sensor: assigned sensor number %d\n", dev->model.sensor_type); return SANE_STATUS_GOOD; } /* assign model description, based on USB id, and register content when * available */ SANE_Status sanei_lexmark_low_assign_model (Lexmark_Device * dev, SANE_String_Const devname, SANE_Int vendor, SANE_Int product, SANE_Byte mainboard) { int dn; SANE_Bool found = SANE_FALSE; DBG_INIT (); DBG (2, "sanei_lexmark_low_assign_model: start\n"); DBG (3, "sanei_lexmark_low_assign_model: assigning %04x:%04x, variant %d\n", vendor, product, mainboard); dn = 0; /* walk the list of known devices */ while (!found && model_list[dn].vendor_id != 0) { /* no mainboard id given (at attach time) */ if (mainboard == 0 && vendor == model_list[dn].vendor_id && product == model_list[dn].product_id) found = SANE_TRUE; /* mainboard given (init time) */ if (mainboard != 0 && mainboard == model_list[dn].mainboard_id && vendor == model_list[dn].vendor_id && product == model_list[dn].product_id) found = SANE_TRUE; if (!found) dn++; } /* we hit the end of list, so we don't know about the current model */ if (!found) { DBG (1, "sanei_lexmark_low_assign_model: unknown device 0x%04x:0x%04x\n", vendor, product); return SANE_STATUS_UNSUPPORTED; } dev->sane.name = strdup (devname); dev->sane.vendor = model_list[dn].vendor; dev->sane.model = model_list[dn].model; dev->model = model_list[dn]; dev->sane.type = "flatbed scanner"; DBG (3, "sanei_lexmark_low_assign_model: assigned %s\n", dev->model.model); /* init sensor data */ DBG (2, "sanei_lexmark_low_assign_model: end.\n"); return sanei_lexmark_low_assign_sensor (dev); } sane-backends-1.0.29/backend/epsonds-cmd.c0000666000000000000000000004431113615534521015153 00000000000000/* * epsonds-cmd.c - Epson ESC/I-2 routines. * * Copyright (C) 2015 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" #include #include /* sleep */ #include "epsonds.h" #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)) { SANE_Status status = SANE_STATUS_GOOD; SANE_Status delayed_status = SANE_STATUS_GOOD; char *start = buf; char *end = (buf + len) - 1; /* 0 : # * 1-3: param * 4- : data */ while (1) { char param[4]; while (*start != '#' && start < end) start++; if (*start != '#') break; param[0] = *++start; param[1] = *++start; param[2] = *++start; param[3] = '\0'; if (strncmp("---", param, 3) == 0) break; /* ugly hack to skip over GMT in RESA */ if (strncmp("GMT", param, 3) == 0 && *(start + 5) == 'h') { start = start + 4 + 0x100; continue; } /* find the end of the token */ { int tlen; char *next = start; while (*next != '#' && *next != 0x00 && next < end) next++; tlen = next - start - 1; if (cb) { status = cb(userdata, start - 2, tlen); if (status != SANE_STATUS_GOOD) { delayed_status = status; } } start = next; } } if (delayed_status != SANE_STATUS_GOOD) return delayed_status; return status; } static SANE_Bool esci2_check_header(const char *cmd, const char *buf, unsigned int *more) { int err; *more = 0; if (strncmp(cmd, buf, 4) != 0) { if (strncmp("UNKN", buf, 4) == 0) { DBG(1, "UNKN reply code received\n"); } else if (strncmp("INVD", buf, 4) == 0) { DBG(1, "INVD reply code received\n"); } else { DBG(1, "%c%c%c%c, unexpected reply code\n", buf[0], buf[1], buf[2], buf[3]); } return 0; } /* INFOx0000100#.... */ /* read the answer len */ if (buf[4] != 'x') { DBG(1, "unknown type in header: %c\n", buf[4]); return 0; } err = sscanf(&buf[5], "%x#", more); if (err != 1) { DBG(1, "cannot decode length from header\n"); return 0; } return 1; } static SANE_Status esci2_cmd(epsonds_scanner* s, char *cmd, size_t len, char *payload, size_t plen, void *userdata, SANE_Status (*cb)(void *userdata, char *token, int len)) { SANE_Status status; unsigned int more; 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); 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 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, request response */ if (plen) { DBG(8, " %12.12s (%lu)\n", header, plen); status = eds_txrx(s, payload, plen, rbuf, 64); if (status != SANE_STATUS_GOOD) { return status; } } /* rxbuf holds the DataHeaderBlock, which should be * parsed to know if we need to read more data */ if (!esci2_check_header(cmd, rbuf, &more)) { return SANE_STATUS_IO_ERROR; } /* parse the received header block */ if (cb) { status = esci2_parse_block(rbuf + 12, 64 - 12, userdata, cb); if (status != SANE_STATUS_GOOD && status != SANE_STATUS_DEVICE_BUSY) { DBG(1, "%s: %4s error while parsing received header\n", __func__, cmd); } } /* header valid, get the data block if present */ if (more) { 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) { } /* parse the received data block */ if (cb) { status = esci2_parse_block(pbuf, more, userdata, cb); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: %4s error while parsing received data block\n", __func__, cmd); } } free(pbuf); } else { return SANE_STATUS_NO_MEM; } } return status; } static SANE_Status esci2_cmd_simple(epsonds_scanner* s, char *cmd, SANE_Status (*cb)(void *userdata, char *token, int len)) { return esci2_cmd(s, cmd, 12, NULL, 0, s, cb); } SANE_Status esci2_fin(epsonds_scanner *s) { SANE_Status status; DBG(5, "%s\n", __func__); status = esci2_cmd_simple(s, "FIN x0000000", NULL); s->locked = 0; return status; } SANE_Status esci2_can(epsonds_scanner *s) { return esci2_cmd_simple(s, "CAN x0000000", NULL); } static int decode_value(char *buf, int len) { char tmp[10]; memcpy(tmp, buf, len); tmp[len] = '\0'; if (buf[0] == 'd' && len == 4) { return strtol(buf + 1, NULL, 10); } else if (buf[0] == 'i' && len == 8) { return strtol(buf + 1, NULL, 10); } else if (buf[0] == 'x' && len == 8) { return strtol(buf + 1, NULL, 16); } else if (buf[0] == 'h' && len == 4) { return strtol(buf + 1, NULL, 16); } return -1; } /* h000 */ static char *decode_binary(char *buf) { char tmp[6]; int hl; memcpy(tmp, buf, 4); tmp[4] = '\0'; if (buf[0] != 'h') return NULL; hl = strtol(tmp + 1, NULL, 16); if (hl) { char *v = malloc(hl + 1); memcpy(v, buf + 4, hl); v[hl] = '\0'; return v; } return NULL; } static char *decode_string(char *buf) { char *p, *s = decode_binary(buf); if (s == NULL) return NULL; /* trim white space at the end */ p = s + strlen(s); while (*--p == ' ') *p = '\0'; return s; } static void debug_token(int level, const char *func, char *token, int len) { char *tdata = malloc(len + 1); memcpy(tdata, token + 3, len); tdata[len] = '\0'; DBG(level, "%s: %3.3s / %s / %d\n", func, token, tdata, len); free(tdata); } static SANE_Status info_cb(void *userdata, char *token, int len) { epsonds_scanner *s = (epsonds_scanner *)userdata; char *value; if (DBG_LEVEL >= 11) { debug_token(DBG_LEVEL, __func__, token, len); } /* pointer to the token's value */ value = token + 3; /* nrd / nrdBUSY */ if (strncmp("nrd", token, 3) == 0) { if (strncmp("BUSY", value, 4) == 0) { return SANE_STATUS_DEVICE_BUSY; } } if (strncmp("PRD", token, 3) == 0) { free(s->hw->model); s->hw->model = decode_string(value); s->hw->sane.model = s->hw->model; DBG(1, " product: %s\n", s->hw->model); /* we will free the string later */ } if (strncmp("VER", token, 3) == 0) { char *v = decode_string(value); DBG(1, " version: %s\n", v); free(v); } if (strncmp("S/N", token, 3) == 0) { char *v = decode_string(value); DBG(1, " serial: %s\n", v); free(v); } if (strncmp("ADF", token, 3) == 0) { s->hw->has_adf = 1; if (len == 8) { if (strncmp("TYPEPAGE", value, len) == 0) { DBG(1, " ADF: page type\n"); } if (strncmp("TYPEFEED", value, len) == 0) { DBG(1, " ADF: sheet feed type\n"); } if (strncmp("DPLX1SCN", value, len) == 0) { DBG(1, " ADF: duplex single pass\n"); s->hw->adf_singlepass = 1; } if (strncmp("DPLX2SCN", value, len) == 0) { DBG(1, " ADF: duplex double pass\n"); s->hw->adf_singlepass = 0; } if (strncmp("FORDPF1N", value, len) == 0) { DBG(1, " ADF: order is 1 to N\n"); } if (strncmp("FORDPFN1", value, len) == 0) { DBG(1, " ADF: order is N to 1\n"); } if (strncmp("ALGNLEFT", value, len) == 0) { DBG(1, " ADF: left aligned\n"); s->hw->adf_alignment = 0; } if (strncmp("ALGNCNTR", value, len) == 0) { DBG(1, " ADF: center aligned\n"); s->hw->adf_alignment = 1; } if (strncmp("ALGNRIGT", value, len) == 0) { DBG(1, " ADF: right aligned (not supported!)\n"); s->hw->adf_alignment = 2; } } if (len == 4) { if (strncmp("PREF", value, len) == 0) { DBG(1, " ADF: auto pre-feed\n"); } if (strncmp("ASCN", value, len) == 0) { DBG(1, " ADF: auto scan\n"); } if (strncmp("RCVR", value, len) == 0) { DBG(1, " ADF: auto recovery\n"); } } if (len == 20) { /* ADFAREAi0000850i0001400 */ if (strncmp("AREA", value, 4) == 0) { int min = decode_value(value + 4, 8); int max = decode_value(value + 4 + 8, 8); DBG(1, " ADF: area %dx%d @ 100dpi\n", min, max); } if (strncmp("AMIN", value, 4) == 0) { int min = decode_value(value + 4, 8); int max = decode_value(value + 4 + 8, 8); DBG(1, " ADF: min %dx%d @ 100dpi\n", min, max); } if (strncmp("AMAX", value, 4) == 0) { int min = decode_value(value + 4, 8); int max = decode_value(value + 4 + 8, 8); DBG(1, " ADF: max %dx%d @ 100dpi\n", min, max); eds_set_adf_area(s->hw, min, max, 100); } } if (len == 12) { /* RESOi0000600 */ if (strncmp("RESO", value, 4) == 0) { int res = decode_value(value + 4, 8); DBG(1, " ADF: basic resolution is %d dpi\n", res); } /* OVSNd025d035 */ if (strncmp("OVSN", value, 4) == 0) { int x = decode_value(value + 4, 4); int y = decode_value(value + 4 + 4, 4); DBG(1, " ADF: overscan %dx%d @ 100dpi\n", x, y); } } } if (strncmp("FB ", token, 3) == 0) { s->hw->has_fb = 1; if (len == 20) { /* AREAi0000850i0001400 */ if (strncmp("AREA", value, 4) == 0) { int min = decode_value(value + 4, 8); int max = decode_value(value + 4 + 8, 8); DBG(1, " FB: area %dx%d @ 100dpi\n", min, max); eds_set_fbf_area(s->hw, min, max, 100); } } if (len == 8) { if (strncmp("ALGNLEFT", value, len) == 0) { DBG(1, " FB: left aligned\n"); s->hw->fbf_alignment = 0; } if (strncmp("ALGNCNTR", value, len) == 0) { DBG(1, " FB: center aligned\n"); s->hw->fbf_alignment = 1; } if (strncmp("ALGNRIGT", value, len) == 0) { DBG(1, " FB: right aligned (not supported!)\n"); s->hw->fbf_alignment = 2; } } if (len == 12) { /* RESOi0000600 */ if (strncmp("RESO", value, 4) == 0) { int res = decode_value(value + 4, 8); DBG(1, " FB: basic resolution is %d dpi\n", res); } /* OVSNd025d035 */ if (strncmp("OVSN", value, 4) == 0) { int x = decode_value(value + 4, 4); int y = decode_value(value + 4 + 4, 4); DBG(1, " FB: overscan %dx%d @ 100dpi\n", x, y); } } if (len == 4) { if (strncmp("DETX", value, len) == 0) { DBG(1, " FB: paper width detection\n"); } if (strncmp("DETY", value, len) == 0) { DBG(1, " FB: paper height detection\n"); } } } return SANE_STATUS_GOOD; } SANE_Status esci2_info(epsonds_scanner *s) { SANE_Status status; int i = 4; DBG(1, "= gathering device information\n"); do { status = esci2_cmd_simple(s, "INFOx0000000", &info_cb); if (status == SANE_STATUS_DEVICE_BUSY) { sleep(2); } i--; } while (status == SANE_STATUS_DEVICE_BUSY && i); return status; } /* CAPA */ static SANE_Status capa_cb(void *userdata, char *token, int len) { epsonds_scanner *s = (epsonds_scanner *)userdata; char *value = token + 3; if (DBG_LEVEL >= 11) { debug_token(DBG_LEVEL, __func__, token, len); } if (len == 4) { if (strncmp("ADFDPLX", token, 3 + 4) == 0) { DBG(1, " ADF: duplex\n"); s->hw->adf_is_duplex = 1; } if (strncmp("ADFSKEW", token, 3 + 4) == 0) { DBG(1, " ADF: skew correction\n"); s->hw->adf_has_skew = 1; } if (strncmp("ADFOVSN", token, 3 + 4) == 0) { DBG(1, " ADF: overscan\n"); } if (strncmp("ADFPEDT", token, 3 + 4) == 0) { DBG(1, " ADF: paper end detection\n"); } if (strncmp("ADFLOAD", token, 3 + 4) == 0) { DBG(1, " ADF: paper load\n"); s->hw->adf_has_load = 1; } if (strncmp("ADFEJCT", token, 3 + 4) == 0) { DBG(1, " ADF: paper eject\n"); s->hw->adf_has_eject = 1; } if (strncmp("ADFCRP ", token, 3 + 4) == 0) { DBG(1, " ADF: image cropping\n"); } if (strncmp("ADFFAST", token, 3 + 4) == 0) { DBG(1, " ADF: fast mode available\n"); } if (strncmp("ADFDFL1", token, 3 + 4) == 0) { DBG(1, " ADF: double feed detection\n"); s->hw->adf_has_dfd = 1; } } if (len == 8 && strncmp("ADFDFL1DFL2", token, 3 + 4) == 0) { DBG(1, " ADF: double feed detection (high sensitivity)\n"); s->hw->adf_has_dfd = 2; } if (strncmp("FMT", token, 3) == 0) { /* a bit ugly... */ if (len >= 8) { if (strncmp("RAW ", value + 4, 4) == 0) { s->hw->has_raw = 1; } } if (len >= 12) { if (strncmp("RAW ", value + 8, 4) == 0) { s->hw->has_raw = 1; } } } /* RSMRANGi0000050i0000600 */ if (strncmp("RSMRANG", token, 3 + 4) == 0) { char *p = token + 3 + 4; if (p[0] == 'i') { int min = decode_value(p, 8); int max = decode_value(p + 8, 8); eds_set_resolution_range(s->hw, min, max); DBG(1, "resolution min/max %d/%d\n", min, max); } } /* RSMLISTi0000300i0000600 */ if (strncmp("RSMLIST", token, 3 + 4) == 0) { char *p = token + 3 + 4; if (p[0] == 'i') { int i; int count = (len - 4) / 8; for (i = 0; i < count; i++) { eds_add_resolution(s->hw, decode_value(p, 8)); p += 8; } } } return SANE_STATUS_GOOD; } SANE_Status esci2_capa(epsonds_scanner *s) { return esci2_cmd_simple(s, "CAPAx0000000", &capa_cb); } /* STAT */ static SANE_Status stat_cb(void *userdata, char *token, int len) { /* epsonds_scanner *s = (epsonds_scanner *)userdata; char *value = token + 3; */ userdata = userdata; if (DBG_LEVEL >= 11) { debug_token(DBG_LEVEL, __func__, token, len); } return SANE_STATUS_GOOD; } SANE_Status esci2_stat(epsonds_scanner *s) { return esci2_cmd_simple(s, "STATx0000000", &stat_cb); } /* RESA */ static SANE_Status resa_cb(void *userdata, char *token, int len) { /* epsonds_scanner *s = (epsonds_scanner *)userdata; */ userdata = userdata; if (DBG_LEVEL >= 11) { debug_token(DBG_LEVEL, __func__, token, len); } return SANE_STATUS_GOOD; } SANE_Status esci2_resa(epsonds_scanner *s) { return esci2_cmd_simple(s, "RESAx0000000", &resa_cb); } /* PARA */ static SANE_Status para_cb(void *userdata, char *token, int len) { if (DBG_LEVEL >= 11) { debug_token(DBG_LEVEL, __func__, token, len); } userdata = userdata; if (strncmp("par", token, 3) == 0) { if (strncmp("FAIL", token + 3, 4) == 0) { DBG(1, "%s: parameter setting failed\n", __func__); return SANE_STATUS_INVAL; } } return SANE_STATUS_GOOD; } SANE_Status esci2_para(epsonds_scanner *s, char *parameters) { DBG(8, "%s: %s\n", __func__, parameters); return esci2_cmd(s, "PARAx0000000", 12, parameters, strlen(parameters), NULL, ¶_cb); } SANE_Status esci2_mech(epsonds_scanner *s, char *parameters) { DBG(8, "%s: %s\n", __func__, parameters); return esci2_cmd(s, "MECHx0000000", 12, parameters, strlen(parameters), NULL, ¶_cb); } SANE_Status esci2_trdt(epsonds_scanner *s) { return esci2_cmd_simple(s, "TRDTx0000000", NULL); } static SANE_Status img_cb(void *userdata, char *token, int len) { struct epsonds_scanner *s = userdata; if (DBG_LEVEL >= 11) { debug_token(DBG_LEVEL, __func__, token, len); } /* psti0000256i0000000i0000945 / 24 */ /* integer comparison first so it's faster */ if (len == 24 && strncmp("pst", token, 3) == 0) { s->dummy = decode_value(token + 3 + 8, 8); DBG(10, "%s: pst width: %d, height: %d, dummy: %d\n", __func__, decode_value(token + 3, 8), decode_value(token + 3 + 8 + 8, 8), s->dummy); return SANE_STATUS_GOOD; } if (len == 16 && strncmp("pen", token, 3) == 0) { DBG(10, "%s: page end\n", __func__); s->eof = 1; return SANE_STATUS_EOF; } /* typIMGA or typIMGB */ if (len == 4 && strncmp("typ", token, 3) == 0) { if (token[6] == 'B') s->backside = 1; else s->backside = 0; return SANE_STATUS_GOOD; } if (strncmp("err", token, 3) == 0) { char *option = token + 3; /* ADF, TPU, FB */ char *cause = token + 3 + 4; /* OPN, PJ, PE, ERR, LTF, LOCK, DFED, DTCL, AUT, PERM */ s->scanning = 0; DBG(1, "%s: error on option %3.3s, cause %4.4s\n", __func__, option, cause); if (cause[0] == 'P' && cause[1] == 'J') return SANE_STATUS_JAMMED; if (cause[0] == 'P' && cause[1] == 'E') return SANE_STATUS_NO_DOCS; if (cause[0] == 'O' && cause[1] == 'P' && cause[2] == 'N') return SANE_STATUS_COVER_OPEN; return SANE_STATUS_IO_ERROR; } if (len == 4 && strncmp("atnCAN ", token, 3 + 4) == 0) { DBG(1, "%s: cancel request\n", __func__); s->canceling = 1; s->scanning = 0; return SANE_STATUS_CANCELLED; } if (len == 4 && strncmp("lftd000", token, 3 + 4) == 0) { s->scanning = 0; } return SANE_STATUS_GOOD; } SANE_Status esci2_img(struct epsonds_scanner *s, SANE_Int *length) { SANE_Status status = SANE_STATUS_GOOD; SANE_Status parse_status; unsigned int more; ssize_t read; *length = 0; if (s->canceling) return SANE_STATUS_CANCELLED; /* request image data */ eds_send(s, "IMG x0000000", 12, &status, 64); if (status != SANE_STATUS_GOOD) { return status; } /* receive DataHeaderBlock */ memset(s->buf, 0x00, 64); eds_recv(s, s->buf, 64, &status); if (status != SANE_STATUS_GOOD) { return status; } /* check if we need to read any image data */ more = 0; if (!esci2_check_header("IMG ", (char *)s->buf, &more)) { return SANE_STATUS_IO_ERROR; } /* this handles eof and errors */ parse_status = esci2_parse_block((char *)s->buf + 12, 64 - 12, s, &img_cb); /* no more data? return using the status of the esci2_parse_block * call, which might hold other error conditions. */ if (!more) { return parse_status; } /* 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; } if (read != more) { return SANE_STATUS_IO_ERROR; } /* handle esci2_parse_block errors */ if (parse_status != SANE_STATUS_GOOD) { return parse_status; } DBG(15, "%s: read %lu bytes, status: %d\n", __func__, (unsigned long) read, status); *length = read; if (s->canceling) { return SANE_STATUS_CANCELLED; } return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/leo.h0000666000000000000000000004612513615534521013530 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002 Frank Zago (sane at zago dot net) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* $Id$ */ /* Commands supported by the scanner. */ #define SCSI_TEST_UNIT_READY 0x00 #define SCSI_INQUIRY 0x12 #define SCSI_SCAN 0x1b #define SCSI_SET_WINDOW 0x24 #define SCSI_READ_10 0x28 #define SCSI_SEND_10 0x2a #define SCSI_REQUEST_SENSE 0x03 #define SCSI_GET_DATA_BUFFER_STATUS 0x34 typedef struct { unsigned char data[16]; int len; } CDB; /* Set a specific bit depending on a boolean. * MKSCSI_BIT(TRUE, 3) will generate 0x08. */ #define MKSCSI_BIT(bit, pos) ((bit)? 1<<(pos): 0) /* Set a value in a range of bits. * MKSCSI_I2B(5, 3, 5) will generate 0x28 */ #define MKSCSI_I2B(bits, pos_b, pos_e) ((bits) << (pos_b) & ((1<<((pos_e)-(pos_b)+1))-1)) /* Store an integer in 2, 3 or 4 byte in an array. */ #define Ito16(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 0) & 0xff; \ } #define Ito24(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 16) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[2] = ((val) >> 0) & 0xff; \ } #define Ito32(val, buf) { \ ((unsigned char *)buf)[0] = ((val) >> 24) & 0xff; \ ((unsigned char *)buf)[1] = ((val) >> 16) & 0xff; \ ((unsigned char *)buf)[2] = ((val) >> 8) & 0xff; \ ((unsigned char *)buf)[3] = ((val) >> 0) & 0xff; \ } #define MKSCSI_GET_DATA_BUFFER_STATUS(cdb, wait, buflen) \ cdb.data[0] = SCSI_GET_DATA_BUFFER_STATUS; \ cdb.data[1] = MKSCSI_BIT(wait, 0); \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.data[6] = 0; \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_INQUIRY(cdb, buflen) \ cdb.data[0] = SCSI_INQUIRY; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = buflen; \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_SCAN(cdb) \ cdb.data[0] = SCSI_SCAN; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_SEND_10(cdb, dtc, dtq, buflen) \ cdb.data[0] = SCSI_SEND_10; \ cdb.data[1] = 0; \ cdb.data[2] = (dtc); \ cdb.data[3] = 0; \ cdb.data[4] = (((dtq) >> 8) & 0xff); \ cdb.data[5] = (((dtq) >> 0) & 0xff); \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_SET_WINDOW(cdb, buflen) \ cdb.data[0] = SCSI_SET_WINDOW; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_READ_10(cdb, dtc, dtq, buflen) \ cdb.data[0] = SCSI_READ_10; \ cdb.data[1] = 0; \ cdb.data[2] = (dtc); \ cdb.data[3] = 0; \ cdb.data[4] = (((dtq) >> 8) & 0xff); \ cdb.data[5] = (((dtq) >> 0) & 0xff); \ cdb.data[6] = (((buflen) >> 16) & 0xff); \ cdb.data[7] = (((buflen) >> 8) & 0xff); \ cdb.data[8] = (((buflen) >> 0) & 0xff); \ cdb.data[9] = 0; \ cdb.len = 10; #define MKSCSI_REQUEST_SENSE(cdb, buflen) \ cdb.data[0] = SCSI_REQUEST_SENSE; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = (buflen); \ cdb.data[5] = 0; \ cdb.len = 6; #define MKSCSI_TEST_UNIT_READY(cdb) \ cdb.data[0] = SCSI_TEST_UNIT_READY; \ cdb.data[1] = 0; \ cdb.data[2] = 0; \ cdb.data[3] = 0; \ cdb.data[4] = 0; \ cdb.data[5] = 0; \ cdb.len = 6; /*--------------------------------------------------------------------------*/ static int getbitfield (unsigned char *pageaddr, int mask, int shift) { return ((*pageaddr >> shift) & mask); } /* defines for request sense return block */ #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7) #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0) #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7) #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6) #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5) #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0) #define get_RS_information(b) getnbyte(b+0x03, 4) #define get_RS_additional_length(b) b[0x07] #define get_RS_ASC(b) b[0x0c] #define get_RS_ASCQ(b) b[0x0d] #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /*--------------------------------------------------------------------------*/ #define mmToIlu(mm) (((mm) * dev->x_resolution) / MM_PER_INCH) #define iluToMm(ilu) (((ilu) * MM_PER_INCH) / dev->x_resolution) /*--------------------------------------------------------------------------*/ #define GAMMA_LENGTH 0x100 /* number of value per color */ /*--------------------------------------------------------------------------*/ enum Leo_Option { /* Must come first */ OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, /* scanner modes */ OPT_RESOLUTION, /* X and Y resolution */ OPT_GEOMETRY_GROUP, OPT_TL_X, /* upper left X */ OPT_TL_Y, /* upper left Y */ OPT_BR_X, /* bottom right X */ OPT_BR_Y, /* bottom right Y */ OPT_ENHANCEMENT_GROUP, OPT_CUSTOM_GAMMA, /* Use the custom gamma tables */ OPT_GAMMA_VECTOR_R, /* Custom Red gamma table */ OPT_GAMMA_VECTOR_G, /* Custom Green Gamma table */ OPT_GAMMA_VECTOR_B, /* Custom Blue Gamma table */ OPT_GAMMA_VECTOR_GRAY, /* Custom Gray Gamma table */ OPT_HALFTONE_PATTERN, /* Halftone pattern */ OPT_PREVIEW, /* preview mode */ /* must come last: */ OPT_NUM_OPTIONS }; /*--------------------------------------------------------------------------*/ /* * Scanner supported by this backend. */ struct scanners_supported { int scsi_type; char scsi_vendor[9]; char scsi_product[17]; const char *real_vendor; const char *real_product; }; /*--------------------------------------------------------------------------*/ #define BLACK_WHITE_STR SANE_VALUE_SCAN_MODE_LINEART #define GRAY_STR SANE_VALUE_SCAN_MODE_GRAY #define COLOR_STR SANE_VALUE_SCAN_MODE_COLOR /*--------------------------------------------------------------------------*/ /* Define a scanner occurence. */ typedef struct Leo_Scanner { struct Leo_Scanner *next; SANE_Device sane; char *devicename; int sfd; /* device handle */ /* Infos from inquiry. */ char scsi_type; char scsi_vendor[9]; char scsi_product[17]; char scsi_version[5]; SANE_Range res_range; int x_resolution_max; /* maximum X dpi */ int y_resolution_max; /* maximum Y dpi */ /* SCSI handling */ size_t buffer_size; /* size of the buffer */ SANE_Byte *buffer; /* for SCSI transfer. */ /* Scanner infos. */ const struct scanners_supported *def; /* default options for that scanner */ /* Scanning handling. */ int scanning; /* TRUE if a scan is running. */ int x_resolution; /* X resolution in DPI */ int y_resolution; /* Y resolution in DPI */ int x_tl; /* X top left */ int y_tl; /* Y top left */ int x_br; /* X bottom right */ int y_br; /* Y bottom right */ int width; /* width of the scan area in mm */ int length; /* length of the scan area in mm */ int pass; /* current pass number */ enum { LEO_BW, LEO_HALFTONE, LEO_GRAYSCALE, LEO_COLOR } scan_mode; int depth; /* depth per color */ size_t bytes_left; /* number of bytes left to give to the backend */ size_t real_bytes_left; /* number of bytes left the scanner will return. */ SANE_Byte *image; /* keep the raw image here */ size_t image_size; /* allocated size of image */ size_t image_begin; /* first significant byte in image */ size_t image_end; /* first free byte in image */ SANE_Parameters params; /* Options */ SANE_Option_Descriptor opt[OPT_NUM_OPTIONS]; Option_Value val[OPT_NUM_OPTIONS]; /* Gamma table. 1 array per colour. */ SANE_Word gamma_R[GAMMA_LENGTH]; SANE_Word gamma_G[GAMMA_LENGTH]; SANE_Word gamma_B[GAMMA_LENGTH]; SANE_Word gamma_GRAY[GAMMA_LENGTH]; } Leo_Scanner; /*--------------------------------------------------------------------------*/ /* Debug levels. * Should be common to all backends. */ #define DBG_error0 0 #define DBG_error 1 #define DBG_sense 2 #define DBG_warning 3 #define DBG_inquiry 4 #define DBG_info 5 #define DBG_info2 6 #define DBG_proc 7 #define DBG_read 8 #define DBG_sane_init 10 #define DBG_sane_proc 11 #define DBG_sane_info 12 #define DBG_sane_option 13 /*--------------------------------------------------------------------------*/ /* 32 bits from an array to an integer (eg ntohl). */ #define B32TOI(buf) \ ((((unsigned char *)buf)[0] << 24) | \ (((unsigned char *)buf)[1] << 16) | \ (((unsigned char *)buf)[2] << 8) | \ (((unsigned char *)buf)[3] << 0)) #define B24TOI(buf) \ ((((unsigned char *)buf)[0] << 16) | \ (((unsigned char *)buf)[1] << 8) | \ (((unsigned char *)buf)[2] << 0)) #define B16TOI(buf) \ ((((unsigned char *)buf)[0] << 8) | \ (((unsigned char *)buf)[1] << 0)) /*--------------------------------------------------------------------------*/ /* Downloadable halftone patterns */ typedef unsigned char halftone_pattern_t[256]; static const halftone_pattern_t haltfone_pattern_diamond = { 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0 }; static const halftone_pattern_t haltfone_pattern_8x8_Coarse_Fatting = { 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xC6, 0x96, 0x76, 0x4E, 0x46, 0x6E, 0x9E, 0xCE, 0xC6, 0x96, 0x76, 0x4E, 0x46, 0x6E, 0x9E, 0xCE, 0x2A, 0x62, 0x82, 0xA2, 0xAA, 0x8A, 0x7A, 0x22, 0x2A, 0x62, 0x82, 0xA2, 0xAA, 0x8A, 0x7A, 0x22, 0x0A, 0x32, 0xDA, 0xF2, 0xFE, 0xB2, 0x5A, 0x02, 0x0A, 0x32, 0xDA, 0xF2, 0xFE, 0xB2, 0x5A, 0x02, 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xC6, 0x96, 0x76, 0x4E, 0x46, 0x6E, 0x9E, 0xCE, 0xC6, 0x96, 0x76, 0x4E, 0x46, 0x6E, 0x9E, 0xCE, 0x2A, 0x62, 0x82, 0xA2, 0xAA, 0x8A, 0x7A, 0x22, 0x2A, 0x62, 0x82, 0xA2, 0xAA, 0x8A, 0x7A, 0x22, 0x0A, 0x32, 0xDA, 0xF2, 0xFE, 0xB2, 0x5A, 0x02, 0x0A, 0x32, 0xDA, 0xF2, 0xFE, 0xB2, 0x5A, 0x02 }; static const halftone_pattern_t haltfone_pattern_8x8_Fine_Fatting = { 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76, 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76, 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76, 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76 }; static const halftone_pattern_t haltfone_pattern_8x8_Bayer = { 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0x46, 0xD6, 0xC6, 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0x46, 0xD6, 0xC6, 0xBE, 0x0E, 0x1E, 0x5E, 0xB6, 0x06, 0x16, 0x56, 0xBE, 0x0E, 0x1E, 0x5E, 0xB6, 0x06, 0x16, 0x56, 0x7E, 0x3E, 0x2E, 0x9E, 0x76, 0x36, 0x26, 0x96, 0x7E, 0x3E, 0x2E, 0x9E, 0x76, 0x36, 0x26, 0x96, 0xEE, 0xAE, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6, 0xEE, 0xAE, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6, 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0x46, 0xD6, 0xC6, 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0x46, 0xD6, 0xC6, 0xBE, 0x0E, 0x1E, 0x5E, 0xB6, 0x06, 0x16, 0x56, 0xBE, 0x0E, 0x1E, 0x5E, 0xB6, 0x06, 0x16, 0x56, 0x7E, 0x3E, 0x2E, 0x9E, 0x76, 0x36, 0x26, 0x96, 0x7E, 0x3E, 0x2E, 0x9E, 0x76, 0x36, 0x26, 0x96, 0xEE, 0xAE, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6, 0xEE, 0xAE, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6 }; static const halftone_pattern_t haltfone_pattern_8x8_Vertical_Line = { 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6, 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6, 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6, 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6 }; sane-backends-1.0.29/backend/rts8891_low.c0000666000000000000000000005572213615534521014772 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2007-2013 stef.dev@free.fr 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* this file contains all the low level functions needed for the higher level * functions of the sane standard. They are put there to keep files smaller * and separate functions with different goals. */ #include "../include/sane/config.h" #include "../include/sane/sane.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_usb.h" #include #ifdef HAVE_SYS_TIME_H #include #endif #include "rts8891_low.h" #define RTS8891_BUILD 30 #define RTS8891_MAX_REGISTERS 244 /* init rts8891 library */ static void rts8891_low_init (void) { DBG_INIT (); DBG (DBG_info, "RTS8891 low-level functions, version %d.%d-%d\n", SANE_CURRENT_MAJOR, V_MINOR, RTS8891_BUILD); } /****************************************************************/ /* ASIC specific functions */ /****************************************************************/ /* write all registers, taking care of the special 0xaa value which * must be escaped with a zero */ static SANE_Status rts8891_write_all (SANE_Int devnum, SANE_Byte * regs, SANE_Int count) { SANE_Status status = SANE_STATUS_GOOD; SANE_Byte local_regs[RTS8891_MAX_REGISTERS]; size_t size = 0; SANE_Byte buffer[260]; unsigned int i, j; char message[256 * 5]; if (DBG_LEVEL > DBG_io) { for (i = 0; i < (unsigned int) count; i++) { if (i != 0xb3) sprintf (message + 5 * i, "0x%02x ", regs[i]); else sprintf (message + 5 * i, "---- "); } DBG (DBG_io, "rts8891_write_all : write_all(0x00,%d)=%s\n", count, message); } /* copy register set and escaping 0xaa values */ /* b0, b1 abd b3 values may be scribled, but that isn't important */ /* since they are read-only registers */ j = 0; for (i = 0; i < 0xb3; i++) { local_regs[j] = regs[i]; if (local_regs[j] == 0xaa && i < 0xb3) { j++; local_regs[j] = 0x00; } j++; } buffer[0] = 0x88; buffer[1] = 0; buffer[2] = 0x00; buffer[3] = 0xb3; for (i = 0; i < j; i++) buffer[i + 4] = local_regs[i]; /* the USB block is size + 4 bytes of header long */ size = j + 4; if (sanei_usb_write_bulk (devnum, buffer, &size) != SANE_STATUS_GOOD) { DBG (DBG_error, "rts88xx_write_all : write registers part 1 failed ...\n"); return SANE_STATUS_IO_ERROR; } size = count - 0xb4; /* we need to substract one reg since b3 won't be written */ buffer[0] = 0x88; buffer[1] = 0xb4; buffer[2] = 0x00; buffer[3] = size; for (i = 0; i < size; i++) buffer[i + 4] = regs[0xb4 + i]; /* the USB block is size + 4 bytes of header long */ size += 4; if (sanei_usb_write_bulk (devnum, buffer, &size) != SANE_STATUS_GOOD) { DBG (DBG_error, "rts88xx_write_all : write registers part 2 failed ...\n"); return SANE_STATUS_IO_ERROR; } return status; } /* this functions "commits" pending scan command */ static SANE_Status rts8891_commit (SANE_Int devnum, SANE_Byte value) { SANE_Status status; SANE_Byte reg; reg = value; sanei_rts88xx_write_reg (devnum, 0xd3, ®); sanei_rts88xx_cancel (devnum); sanei_rts88xx_write_control (devnum, 0x08); status = sanei_rts88xx_write_control (devnum, 0x08); return status; } /* this functions reads button status */ static SANE_Status rts8891_read_buttons (SANE_Int devnum, SANE_Int * mask) { SANE_Status status = SANE_STATUS_GOOD; SANE_Byte reg; /* check CONTROL_REG */ sanei_rts88xx_read_reg (devnum, CONTROL_REG, ®); /* read 'base' button status */ sanei_rts88xx_read_reg (devnum, 0x25, ®); DBG (DBG_io, "rts8891_read_buttons: r25=0x%02x\n", reg); *mask |= reg; /* read 'extended' button status */ sanei_rts88xx_read_reg (devnum, 0x1a, ®); DBG (DBG_io, "rts8891_read_buttons: r1a=0x%02x\n", reg); *mask |= reg << 8; /* clear register r25 */ reg = 0x00; sanei_rts88xx_write_reg (devnum, 0x25, ®); /* clear register r1a */ sanei_rts88xx_read_reg (devnum, 0x1a, ®); reg = 0x00; status = sanei_rts88xx_write_reg (devnum, 0x1a, ®); DBG (DBG_info, "rts8891_read_buttons: mask=0x%04x\n", *mask); return status; } /* * Does a simple scan based on the given register set, returning data in a * preallocated buffer of the claimed size. * sanei_rts88xx_data_count cannot be made reliable, when the announced data * amount is read, it may no be ready, leading to errors. To work around * it, we read data count one more time before reading. */ static SANE_Status rts8891_simple_scan (SANE_Int devnum, SANE_Byte * regs, int regcount, SANE_Int format, SANE_Word total, unsigned char *image) { SANE_Word count, read, len, dummy; SANE_Status status = SANE_STATUS_GOOD; SANE_Byte control; rts8891_write_all (devnum, regs, regcount); rts8891_commit (devnum, format); read = 0; count = 0; while (count == 0) { status = sanei_rts88xx_data_count (devnum, &count); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "simple_scan: failed to wait for data\n"); return status; } if (count == 0) { status = sanei_rts88xx_read_reg (devnum, CONTROL_REG, &control); if (((control & 0x08) == 0) || (status != SANE_STATUS_GOOD)) { DBG (DBG_error, "simple_scan: failed to wait for data\n"); return SANE_STATUS_IO_ERROR; } } } /* data reading */ read = 0; while ((read < total) && (count != 0 || (control & 0x08) == 0x08)) { /* sync ? */ status = sanei_rts88xx_data_count (devnum, &dummy); /* read */ if (count > 0) { len = count; /* read even size unless last chunk */ if ((len & 1) && (read + len < total)) { len++; } if (len > RTS88XX_MAX_XFER_SIZE) { len = RTS88XX_MAX_XFER_SIZE; } if (len > 0) { status = sanei_rts88xx_read_data (devnum, &len, image + read); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "simple_scan: failed to read from scanner\n"); return status; } read += len; } } /* don't try to read data count if we have enough data */ if (read < total) { status = sanei_rts88xx_data_count (devnum, &count); } else { count = 0; } if (count == 0) { sanei_rts88xx_read_reg (devnum, CONTROL_REG, &control); } } /* sanity check */ if (read < total) { DBG (DBG_io2, "simple_scan: ERROR, %d bytes missing ... \n", total - read); } /* wait for the motor to stop */ do { sanei_rts88xx_read_reg (devnum, CONTROL_REG, &control); } while ((control & 0x08) == 0x08); return status; } /** * set the data format. Is part of the commit sequence. Then returned * value is the value used in d3 register for a scan. */ static SANE_Int rts8891_data_format (SANE_Int dpi, int sensor) { SANE_Byte reg = 0x00; /* it seems that lower nibble is a divisor */ if (sensor == SENSOR_TYPE_BARE || sensor == SENSOR_TYPE_XPA) { switch (dpi) { case 75: reg = 0x02; break; case 150: if (sensor == SENSOR_TYPE_BARE) reg = 0x0e; else reg = 0x0b; break; case 300: reg = 0x17; break; case 600: if (sensor == SENSOR_TYPE_BARE) reg = 0x02; else reg = 0x0e; break; case 1200: if (sensor == SENSOR_TYPE_BARE) reg = 0x17; else reg = 0x05; break; } } if (sensor == SENSOR_TYPE_4400 || sensor == SENSOR_TYPE_4400_BARE) { switch (dpi) { case 75: reg = 0x02; break; case 150: if (sensor == SENSOR_TYPE_4400) reg = 0x0b; else reg = 0x17; break; case 300: reg = 0x17; break; case 600: if (sensor == SENSOR_TYPE_4400) reg = 0x0e; else reg = 0x02; break; case 1200: if (sensor == SENSOR_TYPE_4400) reg = 0x05; else reg = 0x17; break; } } return reg; } /** * set up default values for a 75xdpi, 150 ydpi scan */ static void rts8891_set_default_regs (SANE_Byte * scanner_regs) { SANE_Byte default_75[RTS8891_MAX_REGISTERS] = { 0xe5, 0x41, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0a, 0x0a, 0x0a, 0x70, 0x00, 0x00, 0x00, 0x00, 0x28, 0x3f, 0xff, 0x20, 0xf8, 0x28, 0x07, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x3a, 0xf2, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x8c, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x14, 0x18, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f, 0x80, 0x68, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x27, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0e, 0x00, 0x00, 0xf0, 0xff, 0xf5, 0xf7, 0xea, 0x0b, 0x03, 0x05, 0x86, 0x1b, 0x30, 0xf6, 0xa2, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; unsigned int i; for (i = 0; i < RTS8891_MAX_REGISTERS; i++) scanner_regs[i] = default_75[i]; } static SANE_Status rts8891_move (struct Rts8891_Device *device, SANE_Byte * regs, SANE_Int distance, SANE_Bool forward) { SANE_Status status = SANE_STATUS_GOOD; SANE_Byte regs10, regs11; DBG (DBG_proc, "rts8891_move: start\n"); DBG (DBG_io, "rts8891_move: %d lines %s, sensor=%d\n", distance, forward == SANE_TRUE ? "forward" : "backward", device->sensor); /* prepare scan */ rts8891_set_default_regs (regs); if (device->sensor != SENSOR_TYPE_4400 && device->sensor != SENSOR_TYPE_4400_BARE) { regs10 = 0x20; regs11 = 0x28; } else { regs10 = 0x10; regs11 = 0x2a; } regs[0x32] = 0x80; regs[0x33] = 0x81; regs[0x35] = 0x10; regs[0x36] = 0x24; regs[0x39] = 0x02; regs[0x3a] = 0x0e; regs[0x64] = 0x01; regs[0x65] = 0x20; regs[0x79] = 0x20; regs[0x7a] = 0x01; regs[0x80] = 0x32; regs[0x82] = 0x33; regs[0x85] = 0x46; regs[0x86] = 0x0b; regs[0x87] = 0x8c; regs[0x88] = 0x10; regs[0x89] = 0xb2; regs[0x8d] = 0x3b; regs[0x8e] = 0x60; regs[0x90] = 0x1c; regs[0xb2] = 0x16; /* 0x10 : stop when at home, 0x04: no data */ regs[0xc0] = 0x00; regs[0xc1] = 0x00; regs[0xc3] = 0x00; regs[0xc4] = 0x00; regs[0xc5] = 0x00; regs[0xc6] = 0x00; regs[0xc7] = 0x00; regs[0xc8] = 0x00; regs[0xca] = 0x00; regs[0xcd] = 0x00; regs[0xce] = 0x00; regs[0xcf] = 0x00; regs[0xd0] = 0x00; regs[0xd1] = 0x00; regs[0xd2] = 0x00; regs[0xd3] = 0x00; regs[0xd4] = 0x00; regs[0xd6] = 0x6b; regs[0xd7] = 0x00; regs[0xd8] = 0x00; regs[0xd9] = 0xad; regs[0xda] = 0xa7; regs[0xe2] = 0x17; regs[0xe3] = 0x0d; regs[0xe4] = 0x06; regs[0xe5] = 0xf9; regs[0xe7] = 0x53; regs[0xe8] = 0x02; regs[0xe9] = 0x02; /* hp4400 sensors */ if (device->sensor == SENSOR_TYPE_4400 || device->sensor == SENSOR_TYPE_4400_BARE) { regs[0x13] = 0x39; /* 0x20 */ regs[0x14] = 0xf0; /* 0xf8 */ regs[0x15] = 0x29; /* 0x28 */ regs[0x16] = 0x0f; /* 0x07 */ regs[0x17] = 0x10; /* 0x00 */ regs[0x23] = 0x00; /* 0xff */ regs[0x35] = 0x29; /* 0x10 */ regs[0x36] = 0x21; /* 0x24 */ regs[0x39] = 0x00; /* 0x02 */ regs[0x80] = 0xb0; /* 0x32 */ regs[0x82] = 0xb1; /* 0x33 */ regs[0xe2] = 0x0b; /* 0x17 */ regs[0xe5] = 0xf3; /* 0xf9 */ regs[0xe6] = 0x01; /* 0x00 */ } /* disable CCD */ regs[0] = 0xf5; sanei_rts88xx_set_status (device->devnum, regs, regs10, regs11); sanei_rts88xx_set_scan_area (regs, distance, distance + 1, 100, 200); sanei_rts88xx_set_gain (regs, 16, 16, 16); sanei_rts88xx_set_offset (regs, 127, 127, 127); /* forward/backward */ /* 0x2c is forward, 0x24 backward */ if (forward == SANE_TRUE) { /* forward */ regs[0x36] = regs[0x36] | 0x08; } else { /* backward */ regs[0x36] = regs[0x36] & 0xf7; } /* write regiters values */ status = rts8891_write_all (device->devnum, regs, RTS8891_MAX_REGISTERS); /* commit it */ rts8891_commit (device->devnum, 0x00); return status; } /** * wait for the scanning head to reach home position */ static SANE_Status rts8891_wait_for_home (struct Rts8891_Device *device, SANE_Byte * regs) { SANE_Status status = SANE_STATUS_GOOD; SANE_Byte motor, sensor, reg; DBG (DBG_proc, "rts8891_wait_for_home: start\n"); /* wait for controller home bit to raise, no timeout */ /* at each loop we check that motor is on, then that the sensor bit it cleared */ do { sanei_rts88xx_read_reg (device->devnum, CONTROL_REG, &motor); sanei_rts88xx_read_reg (device->devnum, CONTROLER_REG, &sensor); } while ((motor & 0x08) && ((sensor & 0x02) == 0)); /* flag that device has finished parking */ device->parking=SANE_FALSE; /* check for error */ if (((motor & 0x08) == 0x00) && ((sensor & 0x02) == 0)) { DBG (DBG_error, "rts8891_wait_for_home: error, motor stopped before head parked\n"); status = SANE_STATUS_INVAL; } /* re-enable CCD */ regs[0] = regs[0] & 0xef; sanei_rts88xx_cancel (device->devnum); /* reset ? so we don't need to read data */ reg = 0; /* b7: movement on/off, b3-b0 : movement divisor */ sanei_rts88xx_write_reg (device->devnum, 0x33, ®); sanei_rts88xx_write_reg (device->devnum, 0x33, ®); /* movement direction */ sanei_rts88xx_write_reg (device->devnum, 0x36, ®); sanei_rts88xx_cancel (device->devnum); DBG (DBG_proc, "rts8891_wait_for_home: end\n"); return status; } /** * move the head backward by a huge line number then poll home sensor until * head has get back home. We have our own copy of the registers to avoid * messing scanner status */ static SANE_Status rts8891_park (struct Rts8891_Device *device, SANE_Byte *regs, SANE_Bool wait) { SANE_Status status = SANE_STATUS_GOOD; DBG (DBG_proc, "rts8891_park: start\n"); device->parking=SANE_TRUE; rts8891_move (device, regs, 8000, SANE_FALSE); if(wait==SANE_TRUE) { status = rts8891_wait_for_home (device,regs); } DBG (DBG_proc, "rts8891_park: end\n"); return status; } /* reads data from scanner. * First we wait for some data to be available and then loop reading * from scanner until the required amount is reached. * We handle non blocking I/O by returning immediatly (with SANE_STATUS_BUSY) * if there is no data available from scanner. But once read is started, * all the required amount is read. Once wait for data succeeded, we still poll * for data in order no to read it too fast, but we don' take care of non blocking * mode since we cope with it on first data wait. */ static SANE_Status read_data (struct Rts8891_Session *session, SANE_Byte * dest, SANE_Int length) { SANE_Status status = SANE_STATUS_GOOD; SANE_Int count, read, len, dummy; struct Rts8891_Device *dev = session->dev; static FILE *raw = NULL; /* for debugging purpose we need it static */ SANE_Byte control = 0x08; unsigned char buffer[RTS88XX_MAX_XFER_SIZE]; DBG (DBG_proc, "read_data: start\n"); DBG (DBG_proc, "read_data: requiring %d bytes\n", length); /* wait for data being available and handle non blocking mode */ /* only when data reading hasn't produce any data yet */ if (dev->read == 0) { do { status = sanei_rts88xx_data_count (dev->devnum, &count); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "read_data: failed to wait for data\n"); return status; } if (count == 0) { sanei_rts88xx_read_reg (dev->devnum, CONTROL_REG, &control); if ((control & 0x08) == 0 && (count == 0)) { DBG (DBG_error, "read_data: scanner stopped being busy before data are available\n"); return SANE_STATUS_IO_ERROR; } } /* in case there is no data, we return BUSY since this mean */ /* that scanning head hasn't reach is position and data hasn't */ /* come yet */ if (session->non_blocking && count == 0) { dev->regs[LAMP_REG] = 0x8d; sanei_rts88xx_write_reg (dev->devnum, LAMP_REG, &(dev->regs[LAMP_REG])); DBG (DBG_io, "read_data: no data vailable\n"); DBG (DBG_proc, "read_data: end\n"); return SANE_STATUS_DEVICE_BUSY; } } while (count == 0); } else { /* start of read for a new block */ status = sanei_rts88xx_data_count (dev->devnum, &count); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "read_data: failed to wait for data\n"); return status; } if (count == 0) { sanei_rts88xx_read_reg (dev->devnum, CONTROL_REG, &control); if ((control & 0x08) == 0 && (count == 0)) { DBG (DBG_error, "read_data: scanner stopped being busy before data are available\n"); return SANE_STATUS_IO_ERROR; } } } /* fill scanned data buffer */ read = 0; /* now loop reading data until we have the amount requested */ /* we also take care of not reading too much data */ while (read < length && dev->read < dev->to_read && ((control & 0x08) == 0x08)) { /* used to sync */ if (dev->read == 0) { status = sanei_rts88xx_data_count (dev->devnum, &dummy); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "read_data: failed to read data count\n"); return status; } } /* if there is data to read, read it */ if (count > 0) { len = count; if (len > RTS88XX_MAX_XFER_SIZE) { len = RTS88XX_MAX_XFER_SIZE; } /* we only read even size blocks of data */ if (len & 1) { DBG (DBG_io, "read_data: round to next even number\n"); len++; } if (len > length - read) { len = length - read; } status = sanei_rts88xx_read_data (dev->devnum, &len, dest + read); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "read_data: failed to read from scanner\n"); return status; } /* raw data tracing */ if (DBG_LEVEL >= DBG_io2) { /* open a new file only when no data scanned */ if (dev->read == 0) { raw = fopen ("raw_data.pnm", "wb"); if (raw != NULL) { /* PNM header */ fprintf (raw, "P%c\n%d %d\n255\n", session->params.format == SANE_FRAME_RGB || session->emulated_gray == SANE_TRUE ? '6' : '5', dev->pixels, dev->lines); } } if (raw != NULL) { fwrite (dest + read, 1, len, raw); } } /* move pointer and counter */ read += len; dev->read += len; DBG (DBG_io2, "read_data: %d/%d\n", dev->read, dev->to_read); } /* in fast scan mode, read data count * in slow scan, head moves by the amount of data read */ status = sanei_rts88xx_data_count (dev->devnum, &count); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "read_data: failed to read data count\n"); return status; } /* if no data, check if still scanning */ if (count == 0 && dev->read < dev->to_read) { sanei_rts88xx_read_reg (dev->devnum, CONTROL_REG, &control); if ((control & 0x08) == 0x00) { DBG (DBG_error, "read_data: scanner stopped being busy before data are available\n"); return SANE_STATUS_IO_ERROR; } } } /* end of physical reads */ if (dev->read >= dev->to_read) { /* check there is no more data in case of a bug */ sanei_rts88xx_data_count (dev->devnum, &count); if (count > 0) { DBG (DBG_warn, "read_data: %d bytes are still available from scanner\n", count); /* flush left-over data */ while (count > 0) { len = count; if (len > RTS88XX_MAX_XFER_SIZE) { len = RTS88XX_MAX_XFER_SIZE; } /* we only read even size blocks of data */ if (len & 1) { len++; } sanei_rts88xx_read_data (dev->devnum, &len, buffer); sanei_rts88xx_data_count (dev->devnum, &count); } } /* wait for motor to stop at the end of the scan */ do { sanei_rts88xx_read_reg (dev->devnum, CONTROL_REG, &control); } while ((control & 0x08) != 0); /* close log file if needed */ if (DBG_LEVEL >= DBG_io2) { if (raw != NULL) { fclose (raw); raw = NULL; } } } DBG (DBG_io, "read_data: read %d bytes from scanner\n", length); DBG (DBG_proc, "read_data: end\n"); return status; } /** * set scanner idle before leaving xxx_quiet() write_reg(0x33,1)=0x00 write_reg(0x33,1)=0x00 write_reg(0x36,1)=0x00 prepare(); ------ write_reg(LAMP_REG,1)=0x80 write_reg(LAMP_REG,1)=0xad read_reg(0x14,2)=0xf8 0x28 write_reg(0x14,2)=0x78 0x28 get_status()=0x20 0x3f read_reg(0xb1,1)=0x00 read_control()=0x00 reset_lamp()=(0x20,0x3f) write_reg(LAMP_REG,1)=0x8d write_reg(LAMP_REG,1)=0xad */ /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ sane-backends-1.0.29/backend/qcam.h0000666000000000000000000001264313615534521013670 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 David Mosberger-Tang This file is part of the SANE package. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. Portions of this code are derived from Scott Laird's qcam driver. It's copyright notice is reproduced here: Copyright (C) 1996 by Scott Laird Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SCOTT LAIRD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef qcam_h #define qcam_h #include "../include/sane/sane.h" typedef enum { QC_MONO = 0x01, QC_COLOR = 0x10 } QC_Model; typedef enum { QC_RES_LOW = 0, QC_RES_HIGH } QC_Resolution; /* commands common to all quick-cameras: */ typedef enum { QC_SEND_VIDEO_FRAME = 7, QC_SET_BRIGHTNESS = 11, QC_SET_TOP = 13, QC_SET_LEFT = 15, QC_SET_NUM_V = 17, QC_SET_NUM_H = 19, QC_SEND_VERSION = 23, QC_SET_BLACK = 29, QC_SET_WHITE = 31, QC_SET_SATURATION = 35, QC_SEND_STATUS = 41, QC_SET_SPEED = 45 } QC_Command; /* commands for grayscale camera: */ typedef enum { QC_MONO_SET_CONTRAST = 25, QC_MONO_AUTO_ADJUST_OFFSET = 27, QC_MONO_GET_OFFSET = 33 } QC_Mono_Command; /* commands for color camera: */ typedef enum { QC_COL_LOAD_RAM = 27, QC_COL_SET_HUE = 33, QC_COL_SET_CONTRAST = 37 } QC_Col_Command; typedef enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_DEPTH, /* 4 or 6 (b&w) or 24 (color) */ OPT_RESOLUTION, /* resolution in pixels */ OPT_XFER_SCALE, /* transfer-scale */ OPT_DESPECKLE, /* turn on despeckling? */ OPT_TEST, /* test image */ OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_BRIGHTNESS, OPT_CONTRAST, OPT_BLACK_LEVEL, OPT_WHITE_LEVEL, OPT_HUE, OPT_SATURATION, /* must come last: */ NUM_OPTIONS } QC_Option; typedef enum { QC_UNIDIR, QC_BIDIR } QC_Port_Mode; typedef struct { size_t num_bytes; /* # of bytes to read */ QC_Resolution resolution; /* high-resolution? */ SANE_Parameters params; /* other parameters */ u_int mode; /* qcam scan code (get video data command) */ int despeckle; /* apply despeckling filter? */ } QC_Scan_Request; typedef struct QC_Device { struct QC_Device * next; SANE_Device sane; QC_Port_Mode port_mode; int port; /* i/o port address */ int version; /* camera version */ int lock_fd; /* used for locking protocol */ } QC_Device; typedef struct QC_Scanner { struct QC_Scanner *next; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; QC_Resolution resolution; SANE_Parameters params; QC_Device *hw; SANE_Int user_corner; /* bitmask of user-selected coordinates */ SANE_Int value_changed; /* bitmask of options that were set */ SANE_Bool scanning; SANE_Bool deliver_eof; SANE_Bool holding_lock; /* are we holding the lock? */ /* state for reading a frame: */ size_t num_bytes; /* # of bytes read so far */ size_t bytes_per_frame; /* total number of bytes in frame */ /* state relating to the reader-process */ int reader_pid; /* -1 if there is no reader process (yet) */ int from_child; /* fd to read from child process*/ int to_child; /* fd to write to child */ int read_fd; /* used to read data */ /* internal state for qc_readbytes(): */ int readbytes_state; unsigned int saved_bits; } QC_Scanner; #endif /* qcam_h */ sane-backends-1.0.29/backend/v4l.h0000666000000000000000000002063313615534521013452 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 David Mosberger-Tang Updates and bugfixes (C) 2002. 2003 Henning Meier-Geinitz This file is part of the SANE package. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef v4l_h #define v4l_h #ifndef __LINUX_VIDEODEV_H /* Kernel interface */ /* Only the stuff we need. For more features, more defines are needed */ #define VID_TYPE_CAPTURE 1 /* Can capture */ #define VID_TYPE_TUNER 2 /* Can tune */ #define VID_TYPE_TELETEXT 4 /* Does teletext */ #define VID_TYPE_OVERLAY 8 /* Overlay onto frame buffer */ #define VID_TYPE_CHROMAKEY 16 /* Overlay by chromakey */ #define VID_TYPE_CLIPPING 32 /* Can clip */ #define VID_TYPE_FRAMERAM 64 /* Uses the frame buffer memory */ #define VID_TYPE_SCALES 128 /* Scalable */ #define VID_TYPE_MONOCHROME 256 /* Monochrome only */ #define VID_TYPE_SUBCAPTURE 512 /* Can capture subareas of the image */ #define VID_TYPE_MPEG_DECODER 1024 /* Can decode MPEG streams */ #define VID_TYPE_MPEG_ENCODER 2048 /* Can encode MPEG streams */ #define VID_TYPE_MJPEG_DECODER 4096 /* Can decode MJPEG streams */ #define VID_TYPE_MJPEG_ENCODER 8192 /* Can encode MJPEG streams */ struct video_capability { char name[32]; int type; int channels; /* Num channels */ int audios; /* Num audio devices */ int maxwidth; /* Supported width */ int maxheight; /* And height */ int minwidth; /* Supported width */ int minheight; /* And height */ }; struct video_picture { __u16 brightness; __u16 hue; __u16 colour; __u16 contrast; __u16 whiteness; /* Black and white only */ __u16 depth; /* Capture depth */ __u16 palette; /* Palette in use */ #define VIDEO_PALETTE_GREY 1 /* Linear greyscale */ #define VIDEO_PALETTE_HI240 2 /* High 240 cube (BT848) */ #define VIDEO_PALETTE_RGB565 3 /* 565 16 bit RGB */ #define VIDEO_PALETTE_RGB24 4 /* 24bit RGB */ #define VIDEO_PALETTE_RGB32 5 /* 32bit RGB */ #define VIDEO_PALETTE_RGB555 6 /* 555 15bit RGB */ #define VIDEO_PALETTE_YUV422 7 /* YUV422 capture */ #define VIDEO_PALETTE_YUYV 8 #define VIDEO_PALETTE_UYVY 9 /* The great thing about standards is ... */ #define VIDEO_PALETTE_YUV420 10 #define VIDEO_PALETTE_YUV411 11 /* YUV411 capture */ #define VIDEO_PALETTE_RAW 12 /* RAW capture (BT848) */ #define VIDEO_PALETTE_YUV422P 13 /* YUV 4:2:2 Planar */ #define VIDEO_PALETTE_YUV411P 14 /* YUV 4:1:1 Planar */ #define VIDEO_PALETTE_YUV420P 15 /* YUV 4:2:0 Planar */ #define VIDEO_PALETTE_YUV410P 16 /* YUV 4:1:0 Planar */ #define VIDEO_PALETTE_PLANAR 13 /* start of planar entries */ #define VIDEO_PALETTE_COMPONENT 7 /* start of component entries */ }; struct video_window { __u32 x,y; /* Position of window */ __u32 width,height; /* Its size */ __u32 chromakey; __u32 flags; struct video_clip *clips; /* Set only */ int clipcount; #define VIDEO_WINDOW_INTERLACE 1 #define VIDEO_WINDOW_CHROMAKEY 16 /* Overlay by chromakey */ #define VIDEO_CLIP_BITMAP -1 /* bitmap is 1024x625, a '1' bit represents a clipped pixel */ #define VIDEO_CLIPMAP_SIZE (128 * 625) }; #define VIDEO_MAX_FRAME 32 struct video_mbuf { int size; /* Total memory to map */ int frames; /* Frames */ int offsets[VIDEO_MAX_FRAME]; }; struct video_mmap { unsigned int frame; /* Frame (0 - n) for double buffer */ int height,width; unsigned int format; /* should be VIDEO_PALETTE_* */ }; struct video_channel { int channel; char name[32]; int tuners; __u32 flags; #define VIDEO_VC_TUNER 1 /* Channel has a tuner */ #define VIDEO_VC_AUDIO 2 /* Channel has audio */ __u16 type; #define VIDEO_TYPE_TV 1 #define VIDEO_TYPE_CAMERA 2 __u16 norm; /* Norm set by channel */ }; #define VIDIOCGCAP _IOR('v',1,struct video_capability) /* Get capabilities */ #define VIDIOCGCHAN _IOWR('v',2,struct video_channel) /* Get channel info (sources) */ #define VIDIOCSCHAN _IOW('v',3,struct video_channel) /* Set channel */ #define VIDIOCGTUNER _IOWR('v',4,struct video_tuner) /* Get tuner abilities */ #define VIDIOCSTUNER _IOW('v',5,struct video_tuner) /* Tune the tuner for the current channel */ #define VIDIOCGPICT _IOR('v',6,struct video_picture) /* Get picture properties */ #define VIDIOCSPICT _IOW('v',7,struct video_picture) /* Set picture properties */ #define VIDIOCCAPTURE _IOW('v',8,int) /* Start, end capture */ #define VIDIOCGWIN _IOR('v',9, struct video_window) /* Get the video overlay window */ #define VIDIOCSWIN _IOW('v',10, struct video_window) /* Set the video overlay window - passes clip list for hardware smarts , chromakey etc */ #define VIDIOCGFBUF _IOR('v',11, struct video_buffer) /* Get frame buffer */ #define VIDIOCSFBUF _IOW('v',12, struct video_buffer) /* Set frame buffer - root only */ #define VIDIOCKEY _IOR('v',13, struct video_key) /* Video key event - to dev 255 is to all - cuts capture on all DMA windows with this key (0xFFFFFFFF == all) */ #define VIDIOCGFREQ _IOR('v',14, unsigned long) /* Set tuner */ #define VIDIOCSFREQ _IOW('v',15, unsigned long) /* Set tuner */ #define VIDIOCGAUDIO _IOR('v',16, struct video_audio) /* Get audio info */ #define VIDIOCSAUDIO _IOW('v',17, struct video_audio) /* Audio source, mute etc */ #define VIDIOCSYNC _IOW('v',18, int) /* Sync with mmap grabbing */ #define VIDIOCMCAPTURE _IOW('v',19, struct video_mmap) /* Grab frames */ #define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map buffer info */ #define VIDIOCGUNIT _IOR('v',21, struct video_unit) /* Get attached units */ #define VIDIOCGCAPTURE _IOR('v',22, struct video_capture) /* Get subcapture */ #define VIDIOCSCAPTURE _IOW('v',23, struct video_capture) /* Set subcapture */ #define VIDIOCSPLAYMODE _IOW('v',24, struct video_play_mode) /* Set output video mode/feature */ #define VIDIOCSWRITEMODE _IOW('v',25, int) /* Set write mode */ #define VIDIOCGPLAYINFO _IOR('v',26, struct video_info) /* Get current playback info from hardware */ #define VIDIOCSMICROCODE _IOW('v',27, struct video_code) /* Load microcode into hardware */ #define VIDIOCGVBIFMT _IOR('v',28, struct vbi_format) /* Get VBI information */ #define VIDIOCSVBIFMT _IOW('v',29, struct vbi_format) /* Set VBI information */ /* end of kernel interface */ #endif /* !__LINUX_VIDEODEV_H */ #include <../include/sane/sane.h> #define MAX_CHANNELS 32 typedef enum { V4L_RES_LOW = 0, V4L_RES_HIGH } V4L_Resolution; typedef enum { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_CHANNEL, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_BRIGHTNESS, OPT_HUE, OPT_COLOR, OPT_CONTRAST, OPT_WHITE_LEVEL, /* must come last: */ NUM_OPTIONS } V4L_Option; typedef struct V4L_Device { struct V4L_Device *next; SANE_Device sane; } V4L_Device; typedef struct V4L_Scanner { struct V4L_Scanner *next; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; V4L_Resolution resolution; SANE_Parameters params; SANE_String_Const devicename; /* Name of the Device */ int fd; /* Filedescriptor */ SANE_Int user_corner; /* bitmask of user-selected coordinates */ SANE_Bool scanning; SANE_Bool deliver_eof; SANE_Bool is_mmap; /* Do we use mmap ? */ /* state for reading a frame: */ size_t num_bytes; /* # of bytes read so far */ size_t bytes_per_frame; /* total number of bytes in frame */ struct video_capability capability; struct video_picture pict; struct video_window window; struct video_mbuf mbuf; struct video_mmap mmap; SANE_String_Const channel[MAX_CHANNELS]; SANE_Int buffercount; } V4L_Scanner; #endif /* v4l_h */ sane-backends-1.0.29/backend/hp5400_debug.h0000666000000000000000000000501213615534521015025 00000000000000#ifndef __HP5400_DEBUG_H_ #define __HP5400_DEBUG_H_ /* sane - Scanner Access Now Easy. Copyright (C) 2003 Martijn van Oosterhout Copyright (C) 2003 Thomas Soumarmon Originally copied from HP3300 testtools. Original notice follows: Copyright (C) 2001 Bertrik Sikken (bertrik@zonnet.nl) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef STANDALONE #define DEBUG_NOT_STATIC #define DEBUG_DECLARE_ONLY #include "../include/sane/sanei_debug.h" #define DBG_ASSERT 1 #define DBG_ERR 16 #define DBG_MSG 32 #define HP5400_DBG DBG #define HP5400_SANE_STATIC static #else #include #define LOCAL_DBG #define HP5400_DBG fprintf extern FILE *DBG_ASSERT; extern FILE *DBG_ERR; extern FILE *DBG_MSG; void hp5400_dbg_start(); #define HP5400_SANE_STATIC #endif #endif sane-backends-1.0.29/backend/dmc.conf.in0000666000000000000000000000001413615534521014602 00000000000000/dev/camera sane-backends-1.0.29/backend/plustek-pp_sysdep.h0000666000000000000000000002660713615534521016447 00000000000000/* @file plustek-pp_sysdep.h * @brief a trial to centralize changes between the different * kernel-versions some stuff is maybe not relevant, but anyway... * * Copyright (C) 2000-2013 Gerhard Jaeger * * History: * 0.30 - initial version * 0.38 - added this header * 0.39 - added kernel 2.4 stuff * 0.40 - added slab.h/malloc.h stuff for kernel >= 2.4.17 * 0.41 - no changes * 0.42 - added _GET_TIME * - added LINUX_26 for new kernel * - added _MINOR * 0.43 - added class functions * 0.44 - added support for kernel >= 2.6.35 and 3.x * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #ifndef _SYSDEP_H_ #define _SYSDEP_H_ #ifndef LINUX_VERSION_CODE # include #endif #ifndef VERSION_CODE # define VERSION_CODE(vers,rel,seq) ( ((vers)<<16) | ((rel)<<8) | (seq) ) #endif /* only allow > 2.0.x */ #if LINUX_VERSION_CODE < VERSION_CODE(2,0,0) # error "This kernel is too old: not supported by this file" #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,1,0) # define LINUX_20 #elif LINUX_VERSION_CODE < VERSION_CODE(2,4,0) # define LINUX_21 #elif LINUX_VERSION_CODE < VERSION_CODE(2,6,0) # define LINUX_24 #else # define LINUX_24 # define LINUX_26 # include # if LINUX_VERSION_CODE > VERSION_CODE(2,6,35) # define NOLOCK_IOCTL # define IOCTL unlocked_ioctl # else # define IOCTL ioctl # endif # if LINUX_VERSION_CODE > VERSION_CODE(3,0,0) # include # endif #endif #include /* used later in this header */ /* Modularization issues */ #if LINUX_VERSION_CODE < VERSION_CODE(2,1,18) # define __USE_OLD_SYMTAB__ # define EXPORT_NO_SYMBOLS register_symtab(NULL); # define REGISTER_SYMTAB(tab) register_symtab(tab) #else # define REGISTER_SYMTAB(tab) /* nothing */ #endif #ifdef __USE_OLD_SYMTAB__ # define __MODULE_STRING(s) /* nothing */ # define MODULE_PARM(v,t) /* nothing */ # define MODULE_PARM_DESC(v,t) /* nothing */ # define MODULE_AUTHOR(n) /* nothing */ # define MODULE_DESCRIPTION(d) /* nothing */ # define MODULE_SUPPORTED_DEVICE(n) /* nothing */ #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,1,31) # define CLOSETYPE void # define CLOSERETURN(arg) #else # define CLOSETYPE int # define CLOSERETURN(arg) return arg #endif /* * "select" changed in 2.1.23. The implementation is twin, but this * header is new */ #if LINUX_VERSION_CODE > VERSION_CODE(2,1,22) # include #else # define __USE_OLD_SELECT__ #endif /* Other change in the fops are solved using pseudo-types */ #if defined(LINUX_21) || defined(LINUX_24) || defined(LINUX_26) # define lseek_t long long # define lseek_off_t long long #else # define lseek_t int # define lseek_off_t off_t #endif /* changed the prototype of read/write */ #if defined(LINUX_21) || defined (LINUX_24) || defined(LINUX_26) || defined(__alpha__) # define count_t unsigned long # define read_write_t long #else # define count_t int # define read_write_t int #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,1,31) # define release_t void # define release_return(x) return #else # define release_t int # define release_return(x) return (x) #endif /* * access to user space: use the 2.1 functions, * and implement them as macros for 2.0 */ #ifdef LINUX_20 # include # define access_ok(t,a,sz) (verify_area((t),(a),(sz)) ? 0 : 1) # define verify_area_20 verify_area # define copy_to_user(t,f,n) (memcpy_tofs(t,f,n), 0) # define __copy_to_user(t,f,n) copy_to_user((t),(f),(n)) # define copy_to_user_ret(t,f,n,r) copy_to_user((t),(f),(n)) # define copy_from_user(t,f,n) (memcpy_fromfs((t),(f),(n)), 0) # define __copy_from_user(t,f,n) copy_from_user((t),(f),(n)) # define copy_from_user_ret(t,f,n,r) copy_from_user((t),(f),(n)) # define PUT_USER(val,add) (put_user((val),(add)), 0) # define __PUT_USER(val,add) PUT_USER((val),(add)) # define PUT_USER_RET(val,add,ret) PUT_USER((val),(add)) # define GET_USER(dest,add) ((dest)=get_user((add)), 0) # define __GET_USER(dest,add) GET_USER((dest),(add)) # define GET_USER_RET(dest,add,ret) GET_USER((dest),(add)) #else # include # include # define verify_area_20(t,a,sz) (0) /* == success */ # define PUT_USER put_user # define __PUT_USER __put_user # define PUT_USER_RET put_user_ret # define GET_USER get_user # define __GET_USER __get_user # define GET_USER_RET get_user_ret /* starting with 2.4.0-test8, they removed the put_user_ret and get_user_ret * macros, so we recode'em */ #if defined(LINUX_24) || defined(LINUX_26) #ifndef put_user_ret # define put_user_ret(x,ptr,ret) ({ if (put_user(x,ptr)) return ret; }) #endif #ifndef get_user_ret # define get_user_ret(x,ptr,ret) ({ if (get_user(x,ptr)) return ret; }) #endif #endif #endif /* ioremap */ #ifdef LINUX_20 # define ioremap vremap # define iounmap vfree #endif /* The use_count of exec_domain and binfmt changed in 2.1.23 */ #ifdef LINUX_20 # define INCRCOUNT(p) ((p)->module ? __MOD_INC_USE_COUNT((p)->module) : 0) # define CURRCOUNT(p) ((p)->module && (p)->module->usecount) # define DECRCOUNT(p) ((p)->module ? __MOD_DEC_USE_COUNT((p)->module) : 0) #else # define INCRCOUNT(p) ((p)->use_count++) # define CURRCOUNT(p) ((p)->use_count) # define DECRCOUNT(p) ((p)->use_count--) #endif /* register_dynamic no more existent -- just have 0 as inum */ #if LINUX_VERSION_CODE >= VERSION_CODE(2,1,29) # define proc_register_dynamic proc_register #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,1,37) # define test_and_set_bit(nr,addr) test_bit((nr),(addr)) # define test_and_clear_bit(nr,addr) clear_bit((nr),(addr)) # define test_and_change_bit(nr,addr) change_bit((nr),(addr)) #endif /* 2.1.30 removed these functions. Let's define them, just in case */ #if LINUX_VERSION_CODE > VERSION_CODE(2,1,29) # define queue_task_irq queue_task # define queue_task_irq_off queue_task #endif /* 2.1.10 and 2.1.43 introduced new functions. They are worth using */ #if LINUX_VERSION_CODE < VERSION_CODE(2,1,10) # include # ifdef __LITTLE_ENDIAN # define cpu_to_le16(x) (x) # define cpu_to_le32(x) (x) # define cpu_to_be16(x) htons((x)) # define cpu_to_be32(x) htonl((x)) # else # define cpu_to_be16(x) (x) # define cpu_to_be32(x) (x) extern inline __u16 cpu_to_le16(__u16 x) { return (x<<8) | (x>>8);} extern inline __u32 cpu_to_le32(__u32 x) { return((x>>24) | ((x>>8)&0xff00) | ((x<<8)&0xff0000) | (x<<24));} # endif # define le16_to_cpu(x) cpu_to_le16(x) # define le32_to_cpu(x) cpu_to_le32(x) # define be16_to_cpu(x) cpu_to_be16(x) # define be32_to_cpu(x) cpu_to_be32(x) #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,1,43) # define cpu_to_le16p(addr) (cpu_to_le16(*(addr))) # define cpu_to_le32p(addr) (cpu_to_le32(*(addr))) # define cpu_to_be16p(addr) (cpu_to_be16(*(addr))) # define cpu_to_be32p(addr) (cpu_to_be32(*(addr))) extern inline void cpu_to_le16s(__u16 *a) {*a = cpu_to_le16(*a);} extern inline void cpu_to_le32s(__u16 *a) {*a = cpu_to_le32(*a);} extern inline void cpu_to_be16s(__u16 *a) {*a = cpu_to_be16(*a);} extern inline void cpu_to_be32s(__u16 *a) {*a = cpu_to_be32(*a);} # define le16_to_cpup(x) cpu_to_le16p(x) # define le32_to_cpup(x) cpu_to_le32p(x) # define be16_to_cpup(x) cpu_to_be16p(x) # define be32_to_cpup(x) cpu_to_be32p(x) # define le16_to_cpus(x) cpu_to_le16s(x) # define le32_to_cpus(x) cpu_to_le32s(x) # define be16_to_cpus(x) cpu_to_be16s(x) # define be32_to_cpus(x) cpu_to_be32s(x) #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,1,15) # define __USE_OLD_REBUILD_HEADER__ #endif #if LINUX_VERSION_CODE < VERSION_CODE(2,1,30) # define in_interrupt() (intr_count!=0) #endif /* * from 2.4.17 on, they decided to use slab.h instead of malloc.h... so what... * somewhere from 2.4.18-pre9 they skipped get_fast_time... */ #if LINUX_VERSION_CODE < VERSION_CODE(2,4,17) # include "linux/malloc.h" # define _GET_TIME get_fast_time #else # include "linux/slab.h" # define _GET_TIME do_gettimeofday #endif #ifdef LINUX_26 # define _MINOR(p) iminor(p) #else # define _MINOR(p) minor(p->i_rdev) #endif /* Basic class macros */ #ifdef LINUX_26 #if LINUX_VERSION_CODE >= VERSION_CODE(2,6,15) typedef struct class class_t; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) #define CLASS_DEV_CREATE(class, devt, device, name) \ device_create(class, device, devt, NULL, "%s", name) #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) #define CLASS_DEV_CREATE(class, devt, device, name) \ device_create(class, device, devt, name) #else #define CLASS_DEV_CREATE(class, devt, device, name) \ class_device_create(class, NULL, devt, device, name) #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) #define CLASS_DEV_DESTROY device_destroy #else #define CLASS_DEV_DESTROY class_device_destroy #endif #else /* LINUX 2.6.0 - 2.6.14 */ #if LINUX_VERSION_CODE >= VERSION_CODE(2,6,13) /* LINUX 2.6.13 - 2.6.14 */ typedef struct class class_t; #define CLASS_DEVICE_CREATE class_device_create #define CLASS_DEV_DESTROY(class, devt) class_device_destroy(class, devt) #else /* LINUX 2.6.0 - 2.6.12, class_simple */ typedef struct class_simple class_t; #define CLASS_DEVICE_CREATE class_simple_device_add #define CLASS_DEV_DESTROY(class, devt) class_simple_device_remove(class, devt) #define class_create class_simple_create #define class_destroy class_simple_destroy #define class_device_destroy(a, b) class_simple_device_remove(b) #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) */ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) */ #endif #endif /* _SYSDEP_H_ */ /* END PLUSTEK-PP_SYSDEP.H ..................................................*/ sane-backends-1.0.29/backend/mustek_pp.c0000666000000000000000000014531013615534521014747 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000-2003 Jochen Eisinger 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Mustek PP flatbed scanners. */ #include "../include/sane/config.h" #if defined(HAVE_STDLIB_H) # include #endif #include #include #include #include #include #if defined(HAVE_STRING_H) # include #elif defined(HAVE_STRINGS_H) # include #endif #if defined(HAVE_UNISTD_H) # include #endif #include #include #include #if defined(HAVE_SYS_TIME_H) # include #endif #if defined(HAVE_SYS_TYPES_H) # include #endif #include #define BACKEND_NAME mustek_pp #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #define MUSTEK_PP_CONFIG_FILE "mustek_pp.conf" #include "../include/sane/sanei_pa4s2.h" #include "mustek_pp.h" #include "mustek_pp_drivers.h" #define MIN(a,b) ((a) < (b) ? (a) : (b)) /* converts millimeter to pixels at a given resolution */ #define MM_TO_PIXEL(mm, dpi) (((float )mm * 5.0 / 127.0) * (float)dpi) /* and back */ #define PIXEL_TO_MM(pixel, dpi) (((float )pixel / (float )dpi) * 127.0 / 5.0) /* if you change the source, please set MUSTEK_PP_STATE to "devel". Do *not* * change the MUSTEK_PP_BUILD. */ #define MUSTEK_PP_BUILD 13 #define MUSTEK_PP_STATE "beta" /* auth callback... since basic user authentication is done by saned, this * callback mechanism isn't used */ SANE_Auth_Callback sane_auth; /* count of present devices */ static int num_devices = 0; /* list of present devices */ static Mustek_pp_Device *devlist = NULL; /* temporary array of configuration options used during device attachment */ static Mustek_pp_config_option *cfgoptions = NULL; static int numcfgoptions = 0; /* list of pointers to the SANE_Device structures of the Mustek_pp_Devices */ static SANE_Device **devarray = NULL; /* currently active Handles */ static Mustek_pp_Handle *first_hndl = NULL; static SANE_String_Const mustek_pp_modes[4] = {SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, NULL}; static SANE_Word mustek_pp_modes_size = 10; static SANE_String_Const mustek_pp_speeds[6] = {"Slowest", "Slower", "Normal", "Faster", "Fastest", NULL}; static SANE_Word mustek_pp_speeds_size = 8; static SANE_Word mustek_pp_depths[5] = {4, 8, 10, 12, 16}; /* prototypes */ static void free_cfg_options(int *numoptions, Mustek_pp_config_option** options); static SANE_Status do_eof(Mustek_pp_Handle *hndl); static SANE_Status do_stop(Mustek_pp_Handle *hndl); static int reader_process (Mustek_pp_Handle * hndl, int pipe); static SANE_Status sane_attach(SANE_String_Const port, SANE_String_Const name, SANE_Int driver, SANE_Int info); static void init_options(Mustek_pp_Handle *hndl); static void attach_device(SANE_String *driver, SANE_String *name, SANE_String *port, SANE_String *option_ta); /* * Auxiliary function for freeing arrays of configuration options, */ static void free_cfg_options(int *numoptions, Mustek_pp_config_option** options) { int i; if (*numoptions) { for (i=0; i<*numoptions; ++i) { free ((*options)[i].name); free ((*options)[i].value); } free (*options); } *options = NULL; *numoptions = 0; } /* do_eof: * closes the pipeline * * Description: * closes the pipe (read-only end) */ static SANE_Status do_eof (Mustek_pp_Handle *hndl) { if (hndl->pipe >= 0) { close (hndl->pipe); hndl->pipe = -1; } return SANE_STATUS_EOF; } /* do_stop: * ends the reader_process and stops the scanner * * Description: * kills the reader process with a SIGTERM and cancels the scanner */ static SANE_Status do_stop(Mustek_pp_Handle *hndl) { int exit_status; do_eof (hndl); if (hndl->reader > 0) { DBG (3, "do_stop: terminating reader process\n"); kill (hndl->reader, SIGTERM); while (wait (&exit_status) != hndl->reader); DBG ((exit_status == SANE_STATUS_GOOD ? 3 : 1), "do_stop: reader_process terminated with status ``%s''\n", sane_strstatus(exit_status)); hndl->reader = 0; hndl->dev->func->stop (hndl); return exit_status; } hndl->dev->func->stop (hndl); return SANE_STATUS_GOOD; } /* sigterm_handler: * cancel scanner when receiving a SIGTERM * * Description: * just exit... reader_process takes care that nothing bad will happen * * EDG - Jan 14, 2004: * Make sure that the parport is released again by the child process * under all circumstances, because otherwise the parent process may no * longer be able to claim it (they share the same file descriptor, and * the kernel doesn't release the child's claim because the file * descriptor isn't cleaned up). If that would happen, the lamp may stay * on and may not return to its home position, unless the scanner * frontend is restarted. * (This happens only when sanei_pa4s2 uses libieee1284 AND * libieee1284 goes via /dev/parportX). * */ static int fd_to_release = 0; /*ARGSUSED*/ static void sigterm_handler (int signal __UNUSED__) { sanei_pa4s2_enable(fd_to_release, SANE_FALSE); _exit (SANE_STATUS_GOOD); } /* reader_process: * receives data from the scanner and stuff it into the pipeline * * Description: * The signal handle for SIGTERM is initialized. * */ static int reader_process (Mustek_pp_Handle * hndl, int pipe) { sigset_t sigterm_set; struct SIGACTION act; FILE *fp; SANE_Status status; int line; int size, elem; SANE_Byte *buffer; sigemptyset (&sigterm_set); sigaddset (&sigterm_set, SIGTERM); if (!(buffer = malloc (hndl->params.bytes_per_line))) return SANE_STATUS_NO_MEM; if (!(fp = fdopen(pipe, "w"))) return SANE_STATUS_IO_ERROR; fd_to_release = hndl->fd; memset (&act, 0, sizeof(act)); act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, NULL); if ((status = hndl->dev->func->start (hndl)) != SANE_STATUS_GOOD) return status; size = hndl->params.bytes_per_line; elem = 1; for (line=0; lineparams.lines ; line++) { sigprocmask (SIG_BLOCK, &sigterm_set, NULL); hndl->dev->func->read (hndl, buffer); if (getppid() == 1) { /* The parent process has died. Stop the scan (to make sure that the lamp is off and returns home). This is a safety measure to make sure that we don't break the scanner in case the frontend crashes. */ DBG (1, "reader_process: front-end died; aborting.\n"); hndl->dev->func->stop (hndl); return SANE_STATUS_CANCELLED; } sigprocmask (SIG_UNBLOCK, &sigterm_set, NULL); fwrite (buffer, size, elem, fp); } fclose (fp); free (buffer); return SANE_STATUS_GOOD; } /* sane_attach: * adds a new entry to the Mustek_pp_Device *devlist list * * Description: * After memory for a new device entry is allocated, the * parameters for the device are determined by a call to * capabilities(). * * Afterwards the new device entry is inserted into the * devlist * */ static SANE_Status sane_attach (SANE_String_Const port, SANE_String_Const name, SANE_Int driver, SANE_Int info) { Mustek_pp_Device *dev; DBG (3, "sane_attach: attaching device ``%s'' to port %s (driver %s v%s by %s)\n", name, port, Mustek_pp_Drivers[driver].driver, Mustek_pp_Drivers[driver].version, Mustek_pp_Drivers[driver].author); if ((dev = malloc (sizeof (Mustek_pp_Device))) == NULL) { DBG (1, "sane_attach: not enough free memory\n"); return SANE_STATUS_NO_MEM; } memset (dev, 0, sizeof (Mustek_pp_Device)); memset (&dev->sane, 0, sizeof (SANE_Device)); dev->func = &Mustek_pp_Drivers[driver]; dev->sane.name = dev->name = strdup (name); dev->port = strdup (port); dev->info = info; /* Modified by EDG */ /* Transfer the options parsed from the configuration file */ dev->numcfgoptions = numcfgoptions; dev->cfgoptions = cfgoptions; numcfgoptions = 0; cfgoptions = NULL; dev->func->capabilities (info, &dev->model, &dev->vendor, &dev->type, &dev->maxres, &dev->minres, &dev->maxhsize, &dev->maxvsize, &dev->caps); dev->sane.model = dev->model; dev->sane.vendor = dev->vendor; dev->sane.type = dev->type; dev->next = devlist; devlist = dev; num_devices++; return SANE_STATUS_GOOD; } /* init_options: * Sets up the option descriptors for a device * * Description: */ static void init_options(Mustek_pp_Handle *hndl) { int i; memset (hndl->opt, 0, sizeof (hndl->opt)); memset (hndl->val, 0, sizeof (hndl->val)); for (i = 0; i < NUM_OPTIONS; ++i) { hndl->opt[i].size = sizeof (SANE_Word); hndl->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } hndl->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; hndl->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; hndl->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; hndl->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; hndl->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; hndl->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ hndl->opt[OPT_MODE_GROUP].title = "Scan Mode"; hndl->opt[OPT_MODE_GROUP].desc = ""; hndl->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; hndl->opt[OPT_MODE_GROUP].cap = 0; hndl->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; hndl->opt[OPT_MODE_GROUP].size = 0; /* scan mode */ hndl->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; hndl->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; hndl->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; hndl->opt[OPT_MODE].type = SANE_TYPE_STRING; hndl->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; hndl->opt[OPT_MODE].size = mustek_pp_modes_size; hndl->opt[OPT_MODE].constraint.string_list = mustek_pp_modes; hndl->val[OPT_MODE].s = strdup (mustek_pp_modes[2]); /* resolution */ hndl->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; hndl->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; hndl->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; hndl->opt[OPT_RESOLUTION].type = SANE_TYPE_FIXED; hndl->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; hndl->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_RESOLUTION].constraint.range = &hndl->dpi_range; hndl->val[OPT_RESOLUTION].w = SANE_FIX (hndl->dev->minres); hndl->dpi_range.min = SANE_FIX (hndl->dev->minres); hndl->dpi_range.max = SANE_FIX (hndl->dev->maxres); hndl->dpi_range.quant = SANE_FIX (1); /* speed */ hndl->opt[OPT_SPEED].name = SANE_NAME_SCAN_SPEED; hndl->opt[OPT_SPEED].title = SANE_TITLE_SCAN_SPEED; hndl->opt[OPT_SPEED].desc = SANE_DESC_SCAN_SPEED; hndl->opt[OPT_SPEED].type = SANE_TYPE_STRING; hndl->opt[OPT_SPEED].size = mustek_pp_speeds_size; hndl->opt[OPT_SPEED].constraint_type = SANE_CONSTRAINT_STRING_LIST; hndl->opt[OPT_SPEED].constraint.string_list = mustek_pp_speeds; hndl->val[OPT_SPEED].s = strdup (mustek_pp_speeds[2]); if (! (hndl->dev->caps & CAP_SPEED_SELECT)) hndl->opt[OPT_SPEED].cap |= SANE_CAP_INACTIVE; /* preview */ hndl->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; hndl->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; hndl->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; hndl->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; hndl->val[OPT_PREVIEW].w = SANE_FALSE; /* gray preview */ hndl->opt[OPT_GRAY_PREVIEW].name = SANE_NAME_GRAY_PREVIEW; hndl->opt[OPT_GRAY_PREVIEW].title = SANE_TITLE_GRAY_PREVIEW; hndl->opt[OPT_GRAY_PREVIEW].desc = SANE_DESC_GRAY_PREVIEW; hndl->opt[OPT_GRAY_PREVIEW].type = SANE_TYPE_BOOL; hndl->val[OPT_GRAY_PREVIEW].w = SANE_FALSE; /* color dept */ hndl->opt[OPT_DEPTH].name = SANE_NAME_BIT_DEPTH; hndl->opt[OPT_DEPTH].title = SANE_TITLE_BIT_DEPTH; hndl->opt[OPT_DEPTH].desc = "Number of bits per sample for color scans, typical values are 8 for truecolor (24bpp)" "up to 16 for far-to-many-color (48bpp)."; hndl->opt[OPT_DEPTH].type = SANE_TYPE_INT; hndl->opt[OPT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; hndl->opt[OPT_DEPTH].constraint.word_list = mustek_pp_depths; hndl->opt[OPT_DEPTH].unit = SANE_UNIT_BIT; hndl->opt[OPT_DEPTH].size = sizeof(SANE_Word); hndl->val[OPT_DEPTH].w = 8; if ( !(hndl->dev->caps & CAP_DEPTH)) hndl->opt[OPT_DEPTH].cap |= SANE_CAP_INACTIVE; /* "Geometry" group: */ hndl->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; hndl->opt[OPT_GEOMETRY_GROUP].desc = ""; hndl->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; hndl->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; hndl->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; hndl->opt[OPT_GEOMETRY_GROUP].size = 0; /* top-left x */ hndl->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; hndl->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; hndl->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; hndl->opt[OPT_TL_X].type = SANE_TYPE_FIXED; hndl->opt[OPT_TL_X].unit = SANE_UNIT_MM; hndl->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_TL_X].constraint.range = &hndl->x_range; hndl->x_range.min = SANE_FIX (0); hndl->x_range.max = SANE_FIX (PIXEL_TO_MM(hndl->dev->maxhsize,hndl->dev->maxres)); hndl->x_range.quant = 0; hndl->val[OPT_TL_X].w = hndl->x_range.min; /* top-left y */ hndl->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; hndl->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; hndl->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; hndl->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; hndl->opt[OPT_TL_Y].unit = SANE_UNIT_MM; hndl->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_TL_Y].constraint.range = &hndl->y_range; hndl->y_range.min = SANE_FIX(0); hndl->y_range.max = SANE_FIX(PIXEL_TO_MM(hndl->dev->maxvsize,hndl->dev->maxres)); hndl->y_range.quant = 0; hndl->val[OPT_TL_Y].w = hndl->y_range.min; /* bottom-right x */ hndl->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; hndl->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; hndl->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; hndl->opt[OPT_BR_X].type = SANE_TYPE_FIXED; hndl->opt[OPT_BR_X].unit = SANE_UNIT_MM; hndl->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_BR_X].constraint.range = &hndl->x_range; hndl->val[OPT_BR_X].w = hndl->x_range.max; /* bottom-right y */ hndl->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; hndl->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; hndl->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; hndl->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; hndl->opt[OPT_BR_Y].unit = SANE_UNIT_MM; hndl->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_BR_Y].constraint.range = &hndl->y_range; hndl->val[OPT_BR_Y].w = hndl->y_range.max; /* "Enhancement" group: */ hndl->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; hndl->opt[OPT_ENHANCEMENT_GROUP].desc = ""; hndl->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; hndl->opt[OPT_ENHANCEMENT_GROUP].cap = 0; hndl->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; hndl->opt[OPT_ENHANCEMENT_GROUP].size = 0; /* custom-gamma table */ hndl->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; hndl->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; hndl->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; hndl->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; hndl->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; if ( !(hndl->dev->caps & CAP_GAMMA_CORRECT)) hndl->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; /* grayscale gamma vector */ hndl->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; hndl->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; hndl->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; hndl->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; hndl->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; hndl->opt[OPT_GAMMA_VECTOR].size = 256 * sizeof (SANE_Word); hndl->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_GAMMA_VECTOR].constraint.range = &hndl->gamma_range; hndl->val[OPT_GAMMA_VECTOR].wa = &hndl->gamma_table[0][0]; /* red gamma vector */ hndl->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; hndl->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; hndl->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; hndl->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; hndl->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; hndl->opt[OPT_GAMMA_VECTOR_R].size = 256 * sizeof (SANE_Word); hndl->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_GAMMA_VECTOR_R].constraint.range = &hndl->gamma_range; hndl->val[OPT_GAMMA_VECTOR_R].wa = &hndl->gamma_table[1][0]; /* green gamma vector */ hndl->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; hndl->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; hndl->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; hndl->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; hndl->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; hndl->opt[OPT_GAMMA_VECTOR_G].size = 256 * sizeof (SANE_Word); hndl->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_GAMMA_VECTOR_G].constraint.range = &hndl->gamma_range; hndl->val[OPT_GAMMA_VECTOR_G].wa = &hndl->gamma_table[2][0]; /* blue gamma vector */ hndl->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; hndl->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; hndl->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; hndl->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; hndl->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; hndl->opt[OPT_GAMMA_VECTOR_B].size = 256 * sizeof (SANE_Word); hndl->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; hndl->opt[OPT_GAMMA_VECTOR_B].constraint.range = &hndl->gamma_range; hndl->val[OPT_GAMMA_VECTOR_B].wa = &hndl->gamma_table[3][0]; hndl->gamma_range.min = 0; hndl->gamma_range.max = 255; hndl->gamma_range.quant = 1; hndl->opt[OPT_INVERT].name = SANE_NAME_NEGATIVE; hndl->opt[OPT_INVERT].title = SANE_TITLE_NEGATIVE; hndl->opt[OPT_INVERT].desc = SANE_DESC_NEGATIVE; hndl->opt[OPT_INVERT].type = SANE_TYPE_BOOL; hndl->val[OPT_INVERT].w = SANE_FALSE; if (! (hndl->dev->caps & CAP_INVERT)) hndl->opt[OPT_INVERT].cap |= SANE_CAP_INACTIVE; } /* attach_device: * Attempts to attach a device to the list after parsing of a section * of the configuration file. * * Description: * After parsing a scanner section of the config file, this function * is called to look for a driver with a matching name. When found, * this driver is called to initialize the device. */ static void attach_device(SANE_String *driver, SANE_String *name, SANE_String *port, SANE_String *option_ta) { int found = 0, driver_no, port_no; const char **ports; if (!strcmp (*port, "*")) { ports = sanei_pa4s2_devices(); DBG (3, "sanei_init: auto probing port\n"); } else { ports = malloc (sizeof(char *) * 2); ports[0] = *port; ports[1] = NULL; } for (port_no=0; ports[port_no] != NULL; port_no++) { for (driver_no=0 ; driver_no [] * * where is a arbitrary name to identify this entry * is the port where the scanner is attached to * is the name of the driver to use * * if the optional argument "option_ta" is present the driver uses special * parameters fitting for a trasparency adapter. */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { FILE *fp; char config_line[1024]; const char *config_line_ptr; int line=0, driver_no; char *driver = 0, *port = 0, *name = 0, *option_ta = 0; DBG_INIT (); DBG (3, "sane-mustek_pp, version 0.%d-%s. build for SANE %s\n", MUSTEK_PP_BUILD, MUSTEK_PP_STATE, VERSION); DBG (3, "backend by Jochen Eisinger \n"); if (version_code != NULL) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, MUSTEK_PP_BUILD); sane_auth = authorize; fp = sanei_config_open (MUSTEK_PP_CONFIG_FILE); if (fp == NULL) { char driver_name[64]; const char **devices = sanei_pa4s2_devices(); int device_no; DBG (2, "sane_init: could not open configuration file\n"); for (device_no = 0; devices[device_no] != NULL; device_no++) { DBG (3, "sane_init: trying ``%s''\n", devices[device_no]); for (driver_no=0 ; driver_no [] Note that the value is optional. */ char *optname, *optval = 0; Mustek_pp_config_option *tmpoptions; config_line_ptr += 6; config_line_ptr = sanei_config_skip_whitespace (config_line_ptr); if (!*config_line_ptr) { DBG (1, "sane_init: parse error in line %d after ``option''\n", line); continue; } config_line_ptr = sanei_config_get_string (config_line_ptr, &optname); if ((optname == NULL) || (!*optname)) { DBG (1, "sane_init: parse error in line %d after ``option''\n", line); if (optname != NULL) free (optname); continue; } config_line_ptr = sanei_config_skip_whitespace (config_line_ptr); if (*config_line_ptr) { /* The option has a value. No need to check the value; that's up to the backend */ config_line_ptr = sanei_config_get_string (config_line_ptr, &optval); config_line_ptr = sanei_config_skip_whitespace (config_line_ptr); } if (*config_line_ptr) { DBG (1, "sane_init: parse error in line %d after " "``option %s %s''\n", line, optname, (optval == 0 ? "" : optval)); free (optname); if (optval) free (optval); continue; } if (!strcmp (optname, "no_epp")) { u_int pa4s2_options; if (name) DBG (2, "sane_init: global option found in local scope, " "executing anyway\n"); free (optname); if (optval) { DBG (1, "sane_init: unexpected value for option no_epp\n"); free (optval); continue; } DBG (3, "sane_init: disabling mode EPP\n"); sanei_pa4s2_options (&pa4s2_options, SANE_FALSE); pa4s2_options |= SANEI_PA4S2_OPT_NO_EPP; sanei_pa4s2_options (&pa4s2_options, SANE_TRUE); continue; } else if (!name) { DBG (1, "sane_init: parse error in line %d: unexpected " " ``option''\n", line); free (optname); if (optval) free (optval); continue; } /* Extend the (global) array of options */ tmpoptions = realloc(cfgoptions, (numcfgoptions+1)*sizeof(cfgoptions[0])); if (!tmpoptions) { DBG (1, "sane_init: not enough memory for device options\n"); free_cfg_options(&numcfgoptions, &cfgoptions); return SANE_STATUS_NO_MEM; } cfgoptions = tmpoptions; cfgoptions[numcfgoptions].name = optname; cfgoptions[numcfgoptions].value = optval; ++numcfgoptions; } else { DBG (1, "sane_init: parse error at beginning of line %d\n", line); continue; } } /* If we hit the end of the file, we still may have to process the last driver */ if (name) attach_device(&driver, &name, &port, &option_ta); fclose(fp); return SANE_STATUS_GOOD; } /* sane_exit: * Unloads all drivers and frees allocated memory * * Description: * All open devices are closed first. Then all registered devices * are removed. * */ void sane_exit (void) { Mustek_pp_Handle *hndl; Mustek_pp_Device *dev; if (first_hndl) DBG (3, "sane_exit: closing open devices\n"); while (first_hndl) { hndl = first_hndl; sane_close (hndl); } dev = devlist; num_devices = 0; devlist = NULL; while (dev) { free (dev->port); free (dev->name); free (dev->vendor); free (dev->model); free (dev->type); free_cfg_options (&dev->numcfgoptions, &dev->cfgoptions); dev = dev->next; } if (devarray != NULL) free (devarray); devarray = NULL; DBG (3, "sane_exit: all drivers unloaded\n"); } /* sane_get_devices: * Returns a list of registered devices * * Description: * A possible present old device_list is removed first. A new * devarray is allocated and filled with pointers to the * SANE_Device structures of the Mustek_pp_Devices */ /*ARGSUSED*/ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only __UNUSED__) { int ctr; Mustek_pp_Device *dev; if (devarray != NULL) free (devarray); devarray = malloc ((num_devices + 1) * sizeof (devarray[0])); if (devarray == NULL) { DBG (1, "sane_get_devices: not enough memory for device list\n"); return SANE_STATUS_NO_MEM; } dev = devlist; for (ctr=0 ; ctrsane; dev = dev->next; } devarray[num_devices] = NULL; *device_list = (const SANE_Device **)devarray; return SANE_STATUS_GOOD; } /* sane_open: * opens a device and prepares it for operation * * Description: * The device identified by ``devicename'' is looked * up in the list, or if devicename is zero, the * first device from the list is taken. * * open is called for the selected device. * * The handel is set up with default values, and the * option descriptors are initialized */ SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Mustek_pp_Handle *hndl; Mustek_pp_Device *dev; SANE_Status status; int fd, i; if (devicename[0]) { dev = devlist; while (dev) { if (strcmp (dev->name, devicename) == 0) break; dev = dev->next; } if (!dev) { DBG (1, "sane_open: unknown devicename ``%s''\n", devicename); return SANE_STATUS_INVAL; } } else dev = devlist; if (!dev) { DBG (1, "sane_open: no devices present...\n"); return SANE_STATUS_INVAL; } DBG (3, "sane_open: Using device ``%s'' (driver %s v%s by %s)\n", dev->name, dev->func->driver, dev->func->version, dev->func->author); if ((hndl = malloc (sizeof (Mustek_pp_Handle))) == NULL) { DBG (1, "sane_open: not enough free memory for the handle\n"); return SANE_STATUS_NO_MEM; } if ((status = dev->func->open (dev->port, dev->caps, &fd)) != SANE_STATUS_GOOD) { DBG (1, "sane_open: could not open device (%s)\n", sane_strstatus (status)); return status; } hndl->next = first_hndl; hndl->dev = dev; hndl->fd = fd; hndl->state = STATE_IDLE; hndl->pipe = -1; init_options (hndl); dev->func->setup (hndl); /* Initialize driver-specific configuration options. This must be done after calling the setup() function because only then the driver is guaranteed to be fully initialized */ for (i = 0; inumcfgoptions; ++i) { status = dev->func->config (hndl, dev->cfgoptions[i].name, dev->cfgoptions[i].value); if (status != SANE_STATUS_GOOD) { DBG (1, "sane_open: could not set option %s for device (%s)\n", dev->cfgoptions[i].name, sane_strstatus (status)); /* Question: should the initialization be aborted when an option cannot be handled ? The driver should have reasonable built-in defaults, so an illegal option value or an unknown option should not be fatal. Therefore, it's probably ok to ignore the error. */ } } first_hndl = hndl; *handle = hndl; return SANE_STATUS_GOOD; } /* sane_close: * closes a given device and frees all resources * * Description: * The handle is searched in the list of active handles. * If it's found, the handle is removed. * * If the associated device is still scanning, the process * is cancelled. * * Then the backend makes sure, the lamp was at least * 2 seconds on. * * Afterwards the selected handel is closed */ void sane_close (SANE_Handle handle) { Mustek_pp_Handle *prev, *hndl; prev = NULL; for (hndl = first_hndl; hndl; hndl = hndl->next) { if (hndl == handle) break; prev = hndl; } if (hndl == NULL) { DBG (2, "sane_close: unknown device handle\n"); return; } if (hndl->state == STATE_SCANNING) { sane_cancel (handle); do_eof (handle); } if (prev != NULL) prev->next = hndl->next; else first_hndl = hndl->next; DBG (3, "sane_close: maybe waiting for lamp...\n"); if (hndl->lamp_on) while (time (NULL) - hndl->lamp_on < 2) sleep (1); hndl->dev->func->close (hndl); DBG (3, "sane_close: device closed\n"); free (handle); } /* sane_get_option_descriptor: * does what it says * * Description: * */ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Mustek_pp_Handle *hndl = handle; if ((unsigned) option >= NUM_OPTIONS) { DBG (2, "sane_get_option_descriptor: option %d doesn't exist\n", option); return NULL; } return hndl->opt + option; } /* sane_control_option: * Reads or writes an option * * Desription: * If a pointer to info is given, the value is initialized to zero * while scanning options cannot be read or written. next a basic * check whether the request is valid is done. * * Depending on ``action'' the value of the option is either read * (in the first block) or written (in the second block). auto * values aren't supported. * * before a value is written, some checks are performed. Depending * on the option, that is written, other options also change * */ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Mustek_pp_Handle *hndl = handle; SANE_Status status; SANE_Word w, cap; if (info) *info = 0; if (hndl->state == STATE_SCANNING) { DBG (2, "sane_control_option: device is scanning\n"); return SANE_STATUS_DEVICE_BUSY; } if ((unsigned int) option >= NUM_OPTIONS) { DBG (2, "sane_control_option: option %d doesn't exist\n", option); return SANE_STATUS_INVAL; } cap = hndl->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { DBG (2, "sane_control_option: option %d isn't active\n", option); return SANE_STATUS_INVAL; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_PREVIEW: case OPT_GRAY_PREVIEW: case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_CUSTOM_GAMMA: case OPT_INVERT: case OPT_DEPTH: *(SANE_Word *) val = hndl->val[option].w; return SANE_STATUS_GOOD; /* word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (val, hndl->val[option].wa, hndl->opt[option].size); return SANE_STATUS_GOOD; /* string options: */ case OPT_MODE: case OPT_SPEED: strcpy (val, hndl->val[option].s); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (2, "sane_control_option: option can't be set (%s)\n", hndl->opt[option].name); return SANE_STATUS_INVAL; } status = sanei_constrain_value (hndl->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (2, "sane_control_option: constrain_value failed (%s)\n", sane_strstatus (status)); return status; } switch (option) { /* (mostly) side-effect-free word options: */ case OPT_RESOLUTION: case OPT_TL_X: case OPT_BR_X: case OPT_TL_Y: case OPT_BR_Y: case OPT_PREVIEW: case OPT_GRAY_PREVIEW: case OPT_INVERT: case OPT_DEPTH: if (info) *info |= SANE_INFO_RELOAD_PARAMS; hndl->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* side-effect-free word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (hndl->val[option].wa, val, hndl->opt[option].size); return SANE_STATUS_GOOD; /* side-effect-free string options: */ case OPT_SPEED: if (hndl->val[option].s) free (hndl->val[option].s); hndl->val[option].s = strdup (val); return SANE_STATUS_GOOD; /* options with side-effects: */ case OPT_CUSTOM_GAMMA: w = *(SANE_Word *) val; if (w == hndl->val[OPT_CUSTOM_GAMMA].w) return SANE_STATUS_GOOD; /* no change */ if (info) *info |= SANE_INFO_RELOAD_OPTIONS; hndl->val[OPT_CUSTOM_GAMMA].w = w; if (w == SANE_TRUE) { const char *mode = hndl->val[OPT_MODE].s; if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) hndl->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_COLOR) == 0) { hndl->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } else { hndl->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } return SANE_STATUS_GOOD; case OPT_MODE: { char *old_val = hndl->val[option].s; if (old_val) { if (strcmp (old_val, val) == 0) return SANE_STATUS_GOOD; /* no change */ free (old_val); } if (info) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; hndl->val[option].s = strdup (val); hndl->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; hndl->opt[OPT_DEPTH].cap |= SANE_CAP_INACTIVE; if ((hndl->dev->caps & CAP_DEPTH) && (strcmp(val, SANE_VALUE_SCAN_MODE_COLOR) == 0)) hndl->opt[OPT_DEPTH].cap &= ~SANE_CAP_INACTIVE; if (!(hndl->dev->caps & CAP_GAMMA_CORRECT)) return SANE_STATUS_GOOD; if (strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) != 0) hndl->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (hndl->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE) { if (strcmp (val, SANE_VALUE_SCAN_MODE_GRAY) == 0) hndl->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (val, SANE_VALUE_SCAN_MODE_COLOR) == 0) { hndl->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; hndl->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } return SANE_STATUS_GOOD; } } } DBG (2, "sane_control_option: unknown action\n"); return SANE_STATUS_INVAL; } /* sane_get_parameters: * returns the set of parameters, that is used for the next scan * * Description: * * First of all it is impossible to change the parameter set * while scanning. * * sane_get_parameters not only returns the parameters for * the next scan, it also sets them, i.e. converts the * options in actuall parameters. * * The following parameters are set: * * scanmode: according to the option SCANMODE, but * 24bit color, if PREVIEW is selected and * grayscale if GRAY_PREVIEW is selected * depth: the bit depth for color modes (if * supported) or 24bit by default * (ignored in bw/grayscale or if not * supported) * dpi: resolution * invert: if supported else defaults to false * gamma: if supported and selected * ta: if supported by the device * speed: selected speed (or fastest if not * supported) * scanarea: the scanarea is calculated from the * selections the user has mode. note * that the area may slightly differ from * the scanarea selected due to rounding * note also, that a scanarea of * (0,0)-(100,100) will include all pixels * where 0 <= x < 100 and 0 <= y < 100 * afterwards, all values are copied into the SANE_Parameters * structure. */ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Mustek_pp_Handle *hndl = handle; char *mode; int dpi, ctr; if (hndl->state != STATE_SCANNING) { memset (&hndl->params, 0, sizeof (hndl->params)); if ((hndl->dev->caps & CAP_DEPTH) && (hndl->mode == MODE_COLOR)) hndl->depth = hndl->val[OPT_DEPTH].w; else hndl->depth = 8; dpi = (int) (SANE_UNFIX (hndl->val[OPT_RESOLUTION].w) + 0.5); hndl->res = dpi; if (hndl->dev->caps & CAP_INVERT) hndl->invert = hndl->val[OPT_INVERT].w; else hndl->invert = SANE_FALSE; if (hndl->dev->caps & CAP_TA) hndl->use_ta = SANE_TRUE; else hndl->use_ta = SANE_FALSE; if ((hndl->dev->caps & CAP_GAMMA_CORRECT) && (hndl->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE)) hndl->do_gamma = SANE_TRUE; else hndl->do_gamma = SANE_FALSE; if (hndl->dev->caps & CAP_SPEED_SELECT) { for (ctr=SPEED_SLOWEST; ctr<=SPEED_FASTEST; ctr++) if (strcmp(mustek_pp_speeds[ctr], hndl->val[OPT_SPEED].s) == 0) hndl->speed = ctr; } else hndl->speed = SPEED_NORMAL; mode = hndl->val[OPT_MODE].s; if (strcmp (mode, SANE_VALUE_SCAN_MODE_LINEART) == 0) hndl->mode = MODE_BW; else if (strcmp (mode, SANE_VALUE_SCAN_MODE_GRAY) == 0) hndl->mode = MODE_GRAYSCALE; else hndl->mode = MODE_COLOR; if (hndl->val[OPT_PREVIEW].w == SANE_TRUE) { hndl->speed = SPEED_FASTEST; hndl->depth = 8; if (! hndl->use_ta) hndl->invert = SANE_FALSE; hndl->do_gamma = SANE_FALSE; if (hndl->val[OPT_GRAY_PREVIEW].w == SANE_TRUE) hndl->mode = MODE_GRAYSCALE; else { hndl->mode = MODE_COLOR; } } hndl->topX = MIN ((int) (MM_TO_PIXEL (SANE_UNFIX(hndl->val[OPT_TL_X].w), hndl->dev->maxres) + 0.5), hndl->dev->maxhsize); hndl->topY = MIN ((int) (MM_TO_PIXEL (SANE_UNFIX(hndl->val[OPT_TL_Y].w), hndl->dev->maxres) + 0.5), hndl->dev->maxvsize); hndl->bottomX = MIN ((int) (MM_TO_PIXEL (SANE_UNFIX(hndl->val[OPT_BR_X].w), hndl->dev->maxres) + 0.5), hndl->dev->maxhsize); hndl->bottomY = MIN ((int) (MM_TO_PIXEL (SANE_UNFIX(hndl->val[OPT_BR_Y].w), hndl->dev->maxres) + 0.5), hndl->dev->maxvsize); /* If necessary, swap the upper and lower boundaries to avoid negative distances. */ if (hndl->topX > hndl->bottomX) { SANE_Int tmp = hndl->topX; hndl->topX = hndl->bottomX; hndl->bottomX = tmp; } if (hndl->topY > hndl->bottomY) { SANE_Int tmp = hndl->topY; hndl->topY = hndl->bottomY; hndl->bottomY = tmp; } hndl->params.pixels_per_line = (hndl->bottomX - hndl->topX) * hndl->res / hndl->dev->maxres; hndl->params.bytes_per_line = hndl->params.pixels_per_line; switch (hndl->mode) { case MODE_BW: hndl->params.bytes_per_line /= 8; if ((hndl->params.pixels_per_line % 8) != 0) hndl->params.bytes_per_line++; hndl->params.depth = 1; break; case MODE_GRAYSCALE: hndl->params.depth = 8; hndl->params.format = SANE_FRAME_GRAY; break; case MODE_COLOR: hndl->params.depth = hndl->depth; hndl->params.bytes_per_line *= 3; if (hndl->depth > 8) hndl->params.bytes_per_line *= 2; hndl->params.format = SANE_FRAME_RGB; break; } hndl->params.last_frame = SANE_TRUE; hndl->params.lines = (hndl->bottomY - hndl->topY) * hndl->res / hndl->dev->maxres; } else DBG (2, "sane_get_parameters: can't set parameters while scanning\n"); if (params != NULL) *params = hndl->params; return SANE_STATUS_GOOD; } /* sane_start: * starts the scan. data aquisition will start immedially * * Description: * */ SANE_Status sane_start (SANE_Handle handle) { Mustek_pp_Handle *hndl = handle; int pipeline[2]; if (hndl->state == STATE_SCANNING) { DBG (2, "sane_start: device is already scanning\n"); return SANE_STATUS_DEVICE_BUSY; } sane_get_parameters (hndl, NULL); if (pipe(pipeline) < 0) { DBG (1, "sane_start: could not initialize pipe (%s)\n", strerror(errno)); return SANE_STATUS_IO_ERROR; } hndl->reader = fork(); if (hndl->reader == 0) { sigset_t ignore_set; struct SIGACTION act; close (pipeline[0]); sigfillset (&ignore_set); sigdelset (&ignore_set, SIGTERM); sigprocmask (SIG_SETMASK, &ignore_set, NULL); memset (&act, 0, sizeof(act)); sigaction (SIGTERM, &act, NULL); _exit (reader_process (hndl, pipeline[1])); } close (pipeline[1]); hndl->pipe = pipeline[0]; hndl->state = STATE_SCANNING; return SANE_STATUS_GOOD; } /* sane_read: * receives data from pipeline and passes it to the caller * * Description: * ditto */ SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { Mustek_pp_Handle *hndl = handle; SANE_Int nread; if (hndl->state == STATE_CANCELLED) { DBG (2, "sane_read: device already cancelled\n"); do_eof (hndl); hndl->state = STATE_IDLE; return SANE_STATUS_CANCELLED; } if (hndl->state != STATE_SCANNING) { DBG (1, "sane_read: device isn't scanning\n"); return SANE_STATUS_INVAL; } *len = nread = 0; while (*len < max_len) { nread = read(hndl->pipe, buf + *len, max_len - *len); if (hndl->state == STATE_CANCELLED) { *len = 0; DBG(3, "sane_read: scan was cancelled\n"); do_eof (hndl); hndl->state = STATE_IDLE; return SANE_STATUS_CANCELLED; } if (nread < 0) { if (errno == EAGAIN) { if (*len == 0) DBG(3, "sane_read: no data at the moment\n"); else DBG(3, "sane_read: %d bytes read\n", *len); return SANE_STATUS_GOOD; } else { DBG(1, "sane_read: IO error (%s)\n", strerror(errno)); hndl->state = STATE_IDLE; do_stop(hndl); do_eof (hndl); *len = 0; return SANE_STATUS_IO_ERROR; } } *len += nread; if (nread == 0) { if (*len == 0) { DBG (3, "sane_read: read finished\n"); do_stop(hndl); hndl->state = STATE_IDLE; return do_eof(hndl); } DBG(3, "sane_read: read last buffer of %d bytes\n", *len); return SANE_STATUS_GOOD; } } DBG(3, "sane_read: read full buffer of %d bytes\n", *len); return SANE_STATUS_GOOD; } /* sane_cancel: * stops a scan and ends the reader process * * Description: * */ void sane_cancel (SANE_Handle handle) { Mustek_pp_Handle *hndl = handle; if (hndl->state != STATE_SCANNING) return; hndl->state = STATE_CANCELLED; do_stop (hndl); } /* sane_set_io_mode: * toggles between blocking and non-blocking reading * * Description: * */ SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Mustek_pp_Handle *hndl=handle; if (hndl->state != STATE_SCANNING) return SANE_STATUS_INVAL; if (fcntl (hndl->pipe, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) { DBG(1, "sane_set_io_mode: can't set io mode\n"); return SANE_STATUS_IO_ERROR; } return SANE_STATUS_GOOD; } /* sane_get_select_fd: * returns the pipeline fd for direct reading * * Description: * to allow the frontend to receive the data directly it * can read from the pipeline itself */ SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Mustek_pp_Handle *hndl=handle; if (hndl->state != STATE_SCANNING) return SANE_STATUS_INVAL; *fd = hndl->pipe; return SANE_STATUS_GOOD; } /* include drivers */ #include "mustek_pp_decl.h" #include "mustek_pp_null.c" #include "mustek_pp_cis.h" #include "mustek_pp_cis.c" #include "mustek_pp_ccd300.h" #include "mustek_pp_ccd300.c" sane-backends-1.0.29/backend/hp-device.h0000666000000000000000000000735013615534521014612 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Geoffrey T. Dairiki 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP Scanners supporting HP Scanner Control Language (SCL). */ #ifndef HP_DEVICE_INCLUDED #define HP_DEVICE_INCLUDED #include "hp.h" enum hp_device_compat_e { HP_COMPAT_PLUS = 1 << 0, /* HP ScanJet Plus */ HP_COMPAT_2C = 1 << 1, HP_COMPAT_2P = 1 << 2, HP_COMPAT_2CX = 1 << 3, HP_COMPAT_4C = 1 << 4, /* also 3c, 6100C */ HP_COMPAT_3P = 1 << 5, HP_COMPAT_4P = 1 << 6, HP_COMPAT_5P = 1 << 7, /* also 4100C, 5100C */ HP_COMPAT_5100C = 1 << 8, /* redundant with 5p */ HP_COMPAT_PS = 1 << 9, /* HP PhotoSmart Photo Scanner */ HP_COMPAT_OJ_1150C = 1 << 10, HP_COMPAT_OJ_1170C = 1 << 11, /* also later OfficeJets */ HP_COMPAT_6200C = 1 << 12, HP_COMPAT_5200C = 1 << 13, HP_COMPAT_6300C = 1 << 14 }; struct hp_device_s { HpData data; HpOptSet options; SANE_Device sanedev; enum hp_device_compat_e compat; }; SANE_Status sanei_hp_device_new (HpDevice * new, const char * devname); const SANE_Device * sanei_hp_device_sanedevice (HpDevice this); void sanei_hp_device_simulate_clear (const char *devname); SANE_Status sanei_hp_device_simulate_set (const char *devname, HpScl scl, int flag); SANE_Status sanei_hp_device_support_get (const char *devname, HpScl scl, int *minval, int *maxval); SANE_Status sanei_hp_device_support_probe (HpScsi scsi); SANE_Status sanei_hp_device_probe_model (enum hp_device_compat_e *compat, HpScsi scsi, int *model_num, const char **model_name); SANE_Status sanei_hp_device_probe (enum hp_device_compat_e *compat, HpScsi scsi); hp_bool_t sanei_hp_device_compat (HpDevice this, enum hp_device_compat_e c); #endif /* HP_DEVICE_INCLUDED */ sane-backends-1.0.29/backend/hp-option.h0000666000000000000000000002323513615534521014663 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Geoffrey T. Dairiki 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP Scanners supporting HP Scanner Control Language (SCL). */ /* $Id$ */ #ifndef HP_OPTION_H_INCLUDED #define HP_OPTION_H_INCLUDED #include "hp.h" /* * Non-standard SANE options * * FIXME: this should become standard */ #ifndef SANE_NAME_SHARPENING # define SANE_NAME_SHARPENING "sharpening" # define SANE_TITLE_SHARPENING SANE_I18N("Sharpening") # define SANE_DESC_SHARPENING SANE_I18N("Set sharpening value.") #endif #ifndef SANE_NAME_AUTO_THRESHOLD # define SANE_NAME_AUTO_THRESHOLD "auto-threshold" # define SANE_TITLE_AUTO_THRESHOLD SANE_I18N("Auto Threshold") # define SANE_DESC_AUTO_THRESHOLD \ SANE_I18N("Enable automatic determination of threshold for line-art scans.") #endif #ifndef SANE_NAME_SMOOTHING # define SANE_NAME_SMOOTHING "smoothing" # define SANE_TITLE_SMOOTHING SANE_I18N("Smoothing") # define SANE_DESC_SMOOTHING SANE_I18N("Select smoothing filter.") #endif #ifndef SANE_NAME_UNLOAD_AFTER_SCAN # define SANE_NAME_UNLOAD_AFTER_SCAN "unload-after-scan" # define SANE_TITLE_UNLOAD_AFTER_SCAN SANE_I18N("Unload media after scan") # define SANE_DESC_UNLOAD_AFTER_SCAN SANE_I18N("Unloads the media after a scan.") #endif #ifndef SANE_NAME_CHANGE_DOC # define SANE_NAME_CHANGE_DOC "change-document" # define SANE_TITLE_CHANGE_DOC SANE_I18N("Change document") # define SANE_DESC_CHANGE_DOC SANE_I18N("Change Document.") #endif #ifndef SANE_NAME_UNLOAD # define SANE_NAME_UNLOAD "unload" # define SANE_TITLE_UNLOAD SANE_I18N("Unload") # define SANE_DESC_UNLOAD SANE_I18N("Unload Document.") #endif #ifndef SANE_NAME_CALIBRATE # define SANE_NAME_CALIBRATE "calibrate" # define SANE_TITLE_CALIBRATE SANE_I18N("Calibrate") # define SANE_DESC_CALIBRATE SANE_I18N("Start calibration process.") #endif #ifndef SANE_NAME_MEDIA # define SANE_NAME_MEDIA "media-type" # define SANE_TITLE_MEDIA SANE_I18N("Media") # define SANE_DESC_MEDIA SANE_I18N("Set type of media.") #endif #ifndef SANE_NAME_PS_EXPOSURE_TIME # define SANE_NAME_PS_EXPOSURE_TIME "ps-exposure-time" # define SANE_TITLE_PS_EXPOSURE_TIME SANE_I18N("Exposure time") # define SANE_DESC_PS_EXPOSURE_TIME \ SANE_I18N("A longer exposure time lets the scanner\ collect more light. Suggested use is 175% for prints,\ 150% for normal slides and \"Negative\" for\ negative film. For dark (underexposed) images you can increase this value.") #endif #ifndef SANE_NAME_MATRIX_TYPE # define SANE_NAME_MATRIX_TYPE "matrix-type" # define SANE_TITLE_MATRIX_TYPE SANE_I18N("Color Matrix") /* FIXME: better description */ # define SANE_DESC_MATRIX_TYPE SANE_I18N("Set the scanner's color matrix.") #endif #ifndef SANE_NAME_MATRIX_RGB # define SANE_NAME_MATRIX_RGB "matrix-rgb" # define SANE_TITLE_MATRIX_RGB SANE_I18N("Color Matrix") # define SANE_DESC_MATRIX_RGB SANE_I18N("Custom color matrix.") #endif #ifndef SANE_NAME_MATRIX_GRAY # define SANE_NAME_MATRIX_GRAY "matrix-gray" # define SANE_TITLE_MATRIX_GRAY SANE_I18N("Mono Color Matrix") # define SANE_DESC_MATRIX_GRAY SANE_I18N("Custom color matrix for grayscale scans.") #endif #ifndef SANE_NAME_MIRROR_HORIZ # define SANE_NAME_MIRROR_HORIZ "mirror-horizontal" # define SANE_TITLE_MIRROR_HORIZ SANE_I18N("Mirror horizontal") # define SANE_DESC_MIRROR_HORIZ SANE_I18N("Mirror image horizontally.") #endif #ifndef SANE_NAME_MIRROR_VERT # define SANE_NAME_MIRROR_VERT "mirror-vertical" # define SANE_TITLE_MIRROR_VERT SANE_I18N("Mirror vertical") # define SANE_DESC_MIRROR_VERT SANE_I18N("Mirror image vertically.") #endif #ifndef SANE_NAME_UPDATE # define SANE_NAME_UPDATE "update-options" # define SANE_TITLE_UPDATE SANE_I18N("Update options") # define SANE_DESC_UPDATE SANE_I18N("Update options.") #endif #ifndef SANE_NAME_OUTPUT_8BIT # define SANE_NAME_OUTPUT_8BIT "output-8bit" # define SANE_TITLE_OUTPUT_8BIT SANE_I18N("8 bit output") # define SANE_DESC_OUTPUT_8BIT \ SANE_I18N("Use bit depth greater eight internally,\ but output only eight bits.") #endif #ifndef SANE_NAME_BUTTON_WAIT # define SANE_NAME_BUTTON_WAIT "button-wait" # define SANE_TITLE_BUTTON_WAIT SANE_I18N("Front button wait") # define SANE_DESC_BUTTON_WAIT SANE_I18N("Wait to scan for front-panel button push.") # define HP_BUTTON_WAIT_NO 0 # define HP_BUTTON_WAIT_YES 1 #endif #ifndef SANE_NAME_LAMP_OFF # define SANE_NAME_LAMP_OFF "lamp-off" # define SANE_TITLE_LAMP_OFF SANE_I18N("Shut off lamp") # define SANE_DESC_LAMP_OFF SANE_I18N("Shut off scanner lamp.") # define HP_LAMP_OFF_NO 0 # define HP_LAMP_OFF_YES 1 #endif /* Some test stuff to see what undocumented SCL-commands do */ # define SANE_NAME_10470 "10470" # define SANE_TITLE_10470 "10470" # define SANE_DESC_10470 "10470." # define SANE_NAME_10485 "10485" # define SANE_TITLE_10485 "10485" # define SANE_DESC_10485 "10485." # define SANE_NAME_10952 "10952" # define SANE_TITLE_10952 "10952" # define SANE_DESC_10952 "10952." # define SANE_NAME_10967 "10967" # define SANE_TITLE_10967 "10967" # define SANE_DESC_10967 "10967." /* * Internal option names which are not presented to the SANE frontend. */ #define HP_NAME_HORIZONTAL_DITHER "__hdither__" #define HP_NAME_DEVPIX_RESOLUTION "__devpix_resolution__" #ifdef ENABLE_7x12_TONEMAPS # define HP_NAME_RGB_TONEMAP "__rgb_tonemap__" #endif #ifdef FAKE_COLORSEP_MATRIXES # define HP_NAME_SEPMATRIX "__sepmatrix__" #endif struct hp_choice_s { int val; const char *name; hp_bool_t (*enable)(HpChoice this, HpOptSet optset, HpData data, const HpDeviceInfo *info); hp_bool_t is_emulated:1; HpChoice next; }; enum hp_scanmode_e { HP_SCANMODE_LINEART = 0, HP_SCANMODE_HALFTONE = 3, HP_SCANMODE_GRAYSCALE = 4, HP_SCANMODE_COLOR = 5 }; enum hp_scantype_e { HP_SCANTYPE_NORMAL = 0, HP_SCANTYPE_ADF = 1, HP_SCANTYPE_XPA = 2 }; enum hp_dither_type_e { HP_DITHER_CUSTOM = -1, HP_DITHER_COARSE = 0, HP_DITHER_FINE = 1, HP_DITHER_BAYER = 2, HP_DITHER_VERTICAL = 3, HP_DITHER_HORIZONTAL }; enum hp_matrix_type_e { HP_MATRIX_AUTO = -256, HP_MATRIX_GREEN = -257, HP_MATRIX_CUSTOM_BW = -2, HP_MATRIX_CUSTOM = -1, HP_MATRIX_RGB = 0, HP_MATRIX_BW = 1, HP_MATRIX_PASS = 2, HP_MATRIX_RED = 3, HP_MATRIX_BLUE = 4, HP_MATRIX_XPA_RGB = 5, HP_MATRIX_XPA_BW = 6 }; enum hp_mirror_horiz_e { HP_MIRROR_HORIZ_CONDITIONAL = -256, HP_MIRROR_HORIZ_OFF = 0, HP_MIRROR_HORIZ_ON = 1 }; enum hp_mirror_vert_e { HP_MIRROR_VERT_OFF = -258, HP_MIRROR_VERT_ON = -257, HP_MIRROR_VERT_CONDITIONAL = -256 }; enum hp_media_e { HP_MEDIA_NEGATIVE = 1, HP_MEDIA_SLIDE = 2, HP_MEDIA_PRINT = 3 }; hp_bool_t sanei_hp_choice_isEnabled (HpChoice this, HpOptSet optset, HpData data, const HpDeviceInfo *info); SANE_Status sanei_hp_optset_new(HpOptSet * newp, HpScsi scsi, HpDevice dev); SANE_Status sanei_hp_optset_download (HpOptSet this, HpData data, HpScsi scsi); SANE_Status sanei_hp_optset_control (HpOptSet this, HpData data, int optnum, SANE_Action action, void * valp, SANE_Int *infop, HpScsi scsi, hp_bool_t immediate); SANE_Status sanei_hp_optset_guessParameters (HpOptSet this, HpData data, SANE_Parameters * p); enum hp_scanmode_e sanei_hp_optset_scanmode (HpOptSet this, HpData data); hp_bool_t sanei_hp_optset_output_8bit (HpOptSet this, HpData data); int sanei_hp_optset_data_width (HpOptSet this, HpData data); hp_bool_t sanei_hp_optset_isImmediate (HpOptSet this, int optnum); hp_bool_t sanei_hp_optset_mirror_vert (HpOptSet this, HpData data, HpScsi scsi); hp_bool_t sanei_hp_optset_start_wait(HpOptSet this, HpData data); HpScl sanei_hp_optset_scan_type (HpOptSet this, HpData data); const SANE_Option_Descriptor * sanei_hp_optset_saneoption (HpOptSet this, HpData data, int optnum); #endif /* HP_OPTION_H_INCLUDED */ sane-backends-1.0.29/backend/gt68xx_devices.c0000666000000000000000000024130013615534521015606 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2002 Sergey Vlasov Copyright (C) 2002 - 2007 Henning Geinitz 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* Scanner-specific data */ #include "gt68xx_low.h" #include "gt68xx_generic.c" #include "gt68xx_gt6801.c" #include "gt68xx_gt6816.c" static GT68xx_Command_Set mustek_gt6816_command_set = { "mustek-gt6816", /* Name of this command set */ 0x40, /* Request type */ 0x01, /* Request */ 0x200c, /* Memory read - wValue */ 0x200b, /* Memory write - wValue */ 0x2010, /* Send normal command - wValue */ 0x3f40, /* Send normal command - wIndex */ 0x2011, /* Receive normal result - wValue */ 0x3f00, /* Receive normal result - wIndex */ 0x2012, /* Send small command - wValue */ 0x3f40, /* Send small command - wIndex */ 0x2013, /* Receive small result - wValue */ 0x3f00, /* Receive small result - wIndex */ /* activate */ NULL, /* deactivate */ NULL, gt6816_check_firmware, gt6816_download_firmware, gt6816_get_power_status, gt6816_get_ta_status, gt6816_lamp_control, gt6816_is_moving, gt68xx_generic_move_relative, gt6816_carriage_home, /* gt68xx_generic_paperfeed */ NULL, gt68xx_generic_start_scan, gt68xx_generic_read_scanned_data, gt6816_stop_scan, gt68xx_generic_setup_scan, gt68xx_generic_set_afe, gt68xx_generic_set_exposure_time, gt68xx_generic_get_id, /* gt68xx_generic_move_paper */ NULL, /* gt6816_document_present */ NULL }; static GT68xx_Command_Set mustek_gt6816_sheetfed_command_set = { "mustek-gt6816", /* Name of this command set */ 0x40, /* Request type */ 0x01, /* Request */ 0x200c, /* Memory read - wValue */ 0x200b, /* Memory write - wValue */ 0x2010, /* Send normal command - wValue */ 0x3f40, /* Send normal command - wIndex */ 0x2011, /* Receive normal result - wValue */ 0x3f00, /* Receive normal result - wIndex */ 0x2012, /* Send small command - wValue */ 0x3f40, /* Send small command - wIndex */ 0x2013, /* Receive small result - wValue */ 0x3f00, /* Receive small result - wIndex */ /* activate */ NULL, /* deactivate */ NULL, gt6816_check_firmware, gt6816_download_firmware, gt6816_get_power_status, gt6816_get_ta_status, gt6816_lamp_control, gt6816_is_moving, gt68xx_generic_move_relative, /* gt6816_carriage_home */ NULL, gt68xx_generic_paperfeed, gt68xx_generic_start_scan, gt68xx_generic_read_scanned_data, gt6801_stop_scan, gt68xx_generic_setup_scan, gt68xx_generic_set_afe, gt68xx_generic_set_exposure_time, gt68xx_generic_get_id, gt68xx_generic_move_paper, gt6816_document_present }; static GT68xx_Command_Set mustek_gt6801_command_set = { "mustek-gt6801", 0x40, /* Request type */ 0x01, /* Request */ 0x200a, /* Memory read - wValue */ 0x2009, /* Memory write - wValue */ 0x2010, /* Send normal command - wValue */ 0x3f40, /* Send normal command - wIndex */ 0x2011, /* Receive normal result - wValue */ 0x3f00, /* Receive normal result - wIndex */ 0x2012, /* Send small command - wValue */ 0x3f40, /* Send small command - wIndex */ 0x2013, /* Receive small result - wValue */ 0x3f00, /* Receive small result - wIndex */ /* activate */ NULL, /* deactivate */ NULL, gt6801_check_firmware, gt6801_download_firmware, gt6801_get_power_status, /* get_ta_status (FIXME: implement this) */ NULL, gt6801_lamp_control, gt6801_is_moving, /* gt68xx_generic_move_relative *** to be tested */ NULL, gt6801_carriage_home, /* gt68xx_generic_paperfeed */ NULL, gt68xx_generic_start_scan, gt68xx_generic_read_scanned_data, gt6801_stop_scan, gt68xx_generic_setup_scan, gt68xx_generic_set_afe, gt68xx_generic_set_exposure_time, gt68xx_generic_get_id, /* gt68xx_generic_move_paper */ NULL, /* gt6816_document_present */ NULL }; static GT68xx_Command_Set plustek_gt6801_command_set = { "plustek-gt6801", 0x40, /* Request type */ 0x04, /* Request */ 0x200a, /* Memory read - wValue */ 0x2009, /* Memory write - wValue */ 0x2010, /* Send normal command - wValue */ 0x3f40, /* Send normal command - wIndex */ 0x2011, /* Receive normal result - wValue */ 0x3f00, /* Receive normal result - wIndex */ 0x2012, /* Send small command - wValue */ 0x3f40, /* Send small command - wIndex */ 0x2013, /* Receive small result - wValue */ 0x3f00, /* Receive small result - wIndex */ /* activate */ NULL, /* deactivate */ NULL, gt6801_check_plustek_firmware, gt6801_download_firmware, gt6801_get_power_status, /* get_ta_status (FIXME: implement this) */ NULL, gt6801_lamp_control, gt6801_is_moving, /* gt68xx_generic_move_relative *** to be tested */ NULL, gt6801_carriage_home, /* gt68xx_generic_paperfeed */ NULL, gt68xx_generic_start_scan, gt68xx_generic_read_scanned_data, gt6801_stop_scan, gt68xx_generic_setup_scan, gt68xx_generic_set_afe, /* set_exposure_time */ NULL, gt68xx_generic_get_id, /* gt68xx_generic_move_paper */ NULL, /* gt6816_document_present */ NULL }; static GT68xx_Model unknown_model = { "unknown-scanner", /* Name */ "unknown manufacturer", /* Device vendor string */ "unknown device -- use override to select", /* Device model name */ "unknown", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {8, 0}, /* possible depths in gray mode */ {8, 0}, /* possible depths in color mode */ SANE_FIX (0.0), /* Start of scan area in mm (x) */ SANE_FIX (13.0), /* Start of scan area in mm (y) */ SANE_FIX (200.0), /* Size of scan area in mm (x) */ SANE_FIX (280.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 (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) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x14, 0x07, 0x14, 0x07, 0x14, 0x07}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_STOP /* Which flags are needed for this scanner? */ /* Standard values for unknown scanner */ }; static GT68xx_Model mustek_2400ta_model = { "mustek-bearpaw-2400-ta", /* Name */ "Mustek", /* Device vendor string */ "BearPaw 2400 TA", /* Device model name */ "A2fw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 2400, /* maximum motor resolution */ 1200, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {1200, 600, 300, 200, 100, 50, 0}, /* possible x-resolutions */ {2400, 1200, 600, 300, 200, 100, 50, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (3.67), /* Start of scan area in mm (x) */ SANE_FIX (7.4), /* Start of scan area in mm (y) */ SANE_FIX (219.0), /* Size of scan area in mm (x) */ SANE_FIX (298.0), /* Size of scan area in mm (y) */ SANE_FIX (0.0), /* Start of white strip in mm (y) */ SANE_FIX (0.635), /* Start of black mark in mm (x) */ SANE_FIX (94.0), /* Start of scan area in TA mode in mm (x) */ SANE_FIX (107.0), /* Start of scan area in TA mode in mm (y) */ SANE_FIX (37.0), /* Size of scan area in TA mode in mm (x) */ SANE_FIX (165.0), /* Size of scan area in TA mode in mm (y) */ SANE_FIX (95.0), /* Start of white strip in TA mode in mm (y) */ 0, 24, 48, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_SCAN_FROM_HOME /* Which flags are needed for this scanner? */ /* flatbed values tested */ }; static GT68xx_Model mustek_2400taplus_model = { "mustek-bearpaw-2400-ta-plus", /* Name */ "Mustek", /* Device vendor string */ "BearPaw 2400 TA Plus", /* Device model name */ "A2Dfw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 2400, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {1200, 600, 300, 100, 50, 0}, /* possible x-resolutions */ {2400, 1200, 600, 300, 100, 50, 0}, /* possible y-resolutions */ {8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (7.41), /* Start of scan area in mm (x) */ SANE_FIX (7.4), /* Start of scan area in mm (y) */ SANE_FIX (217.5), /* Size of scan area in mm (x) */ SANE_FIX (298.0), /* Size of scan area in mm (y) */ SANE_FIX (0.0), /* Start of white strip in mm (y) */ SANE_FIX (5.0), /* Start of black mark in mm (x) */ SANE_FIX (94.0), /* Start of scan area in TA mode in mm (x) */ SANE_FIX (107.0) /* Start of scan area in TA mode in mm (y) */ , SANE_FIX (37.0), /* Size of scan area in TA mode in mm (x) */ SANE_FIX (165.0), /* Size of scan area in TA mode in mm (y) */ SANE_FIX (95.0), /* Start of white strip in TA mode in mm (y) */ 0, 48, 96, /* RGB CCD Line-distance correction in pixel */ 8, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_USE_OPTICAL_X | GT68XX_FLAG_SCAN_FROM_HOME /* Which flags are needed for this scanner? */ /* Setup and tested */ }; static GT68xx_Model mustek_2448taplus_model = { "mustek-bearpaw-2448-ta-plus", /* Name */ "Mustek", /* Device vendor string */ "BearPaw 2448 TA Plus", /* Device model name */ "A2Nfw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 2400, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {1200, 600, 300, 200, 100, 0}, /* possible x-resolutions */ {2400, 1200, 600, 300, 200, 100, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (7.41), /* Start of scan area in mm (x) */ SANE_FIX (7.4), /* Start of scan area in mm (y) */ SANE_FIX (216.3), /* 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 (4.0), /* Start of black mark in mm (x) */ SANE_FIX (94.0), /* Start of scan area in TA mode in mm (x) */ SANE_FIX (105.0), /* Start of scan area in TA mode in mm (y) */ SANE_FIX (36.0), /* Size of scan area in TA mode in mm (x) */ SANE_FIX (165.0), /* Size of scan area in TA mode in mm (y) */ SANE_FIX (95.0), /* Start of white strip in TA mode in mm (y) */ 0, 48, 96, /* RGB CCD Line-distance correction in pixel */ 8, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_STOP /* Which flags are needed for this scanner? */ /* Based on data from Jakub Dvořák . */ }; static GT68xx_Model mustek_1200ta_model = { "mustek-bearpaw-1200-ta", /* Name */ "Mustek", /* Device vendor string */ "BearPaw 1200 TA", /* Device model name */ "A1fw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (8.4), /* Start of scan area in mm (x) */ SANE_FIX (7.5), /* Start of scan area in mm (y) */ SANE_FIX (220.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 (6.9), /* Start of black mark in mm (x) */ SANE_FIX (98.0), /* Start of scan area in TA mode in mm (x) */ SANE_FIX (108.0), /* Start of scan area in TA mode in mm (y) */ SANE_FIX (37.0), /* Size of scan area in TA mode in mm (x) */ SANE_FIX (163.0), /* Size of scan area in TA mode in mm (y) */ SANE_FIX (95.0), /* Start of white strip in TA mode in mm (y) */ 32, 16, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x2a, 0x0c, 0x2e, 0x06, 0x2d, 0x07}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ 0 /* Which flags are needed for this scanner? */ /* Setup for 1200 TA */ }; static GT68xx_Model mustek_1200cuplus_model = { "mustek-bearpaw-1200-cu-plus", /* Name */ "Mustek", /* Device vendor string */ "Bearpaw 1200 CU Plus", /* Device model name */ "PS1Dfw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (0.0), /* Start of scan area in mm (x) */ SANE_FIX (13.0), /* Start of scan area in mm (y) */ SANE_FIX (217.0), /* Size of scan area in mm (x) */ SANE_FIX (299.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 (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) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x14, 0x07, 0x14, 0x07, 0x14, 0x07}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_STOP /* Which flags are needed for this scanner? */ /* Tested by Hamersky Robert r.hamersky at utanet.at */ }; static GT68xx_Model mustek_1200cuplus2_model = { "mustek-bearpaw-1200-cu-plus-2", /* Name */ "Mustek", /* Device vendor string */ "Bearpaw 1200 CU Plus", /* Device model name */ "PS1Gfw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (4.0), /* Start of scan area in mm (x) */ SANE_FIX (13.0), /* Start of scan area in mm (y) */ SANE_FIX (217.0), /* Size of scan area in mm (x) */ SANE_FIX (299.0), /* Size of scan area in mm (y) */ SANE_FIX (5.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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x19, 0x03, 0x1b, 0x05, 0x19, 0x03}, /* Default offset/gain */ {0xb0, 0xb0, 0xb0}, /* Default exposure parameters */ SANE_FIX (1.5), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_STOP /* Which flags are needed for this scanner? */ /* Tested by hmg */ }; static GT68xx_Model mustek_2400cuplus_model = { "mustek-bearpaw-2400-cu-plus", /* Name */ "Mustek", /* Device vendor string */ "BearPaw 2400 CU Plus", /* Device model name */ "PS2Dfw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 2400, /* maximum motor resolution */ 1200, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {1200, 600, 300, 200, 150, 100, 50, 0}, /* possible x-resolutions */ {2400, 1200, 600, 300, 200, 150, 100, 50, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (2.0), /* Start of scan area in mm (x) */ SANE_FIX (13.0), /* Start of scan area in mm (y) */ SANE_FIX (217.0), /* Size of scan area in mm (x) */ SANE_FIX (300.0), /* Size of scan area in mm (y) */ SANE_FIX (4.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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x15, 0x08, 0x12, 0x05, 0x12, 0x05}, /* Default offset/gain */ {0x2a0, 0x1ab, 0x10d}, /* Default exposure parameters */ SANE_FIX (1.5), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_STOP /* Which flags are needed for this scanner? */ /* Setup and tested */ }; /* Seems that Mustek ScanExpress 1200 UB Plus, the Mustek BearPaw 1200 CU * and lots of other scanners have the same USB identifier. */ static GT68xx_Model mustek_1200cu_model = { "mustek-bearpaw-1200-cu", /* Name */ "Mustek", /* Device vendor string */ "BearPaw 1200 CU", /* Device model name */ "PS1fw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6801_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 600, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (0.0), /* Start of scan area in mm (x) */ SANE_FIX (13.0), /* Start of scan area in mm (y) */ SANE_FIX (217.0), /* Size of scan area in mm (x) */ SANE_FIX (299.0), /* Size of scan area in mm (y) */ SANE_FIX (4.2), /* 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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x13, 0x04, 0x15, 0x06, 0x0f, 0x02}, /* Default offset/gain */ {0x150, 0x150, 0x150}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ 0 /* Which flags are needed for this scanner? */ /* Setup and tested */ }; static GT68xx_Model mustek_scanexpress1200ubplus_model = { "mustek-scanexpress-1200-ub-plus", /* Name */ "Mustek", /* Device vendor string */ "ScanExpress 1200 UB Plus", /* Device model name */ "SBfw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6801_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (0.0), /* Start of scan area in mm (x) */ SANE_FIX (15.5), /* Start of scan area in mm (y) */ SANE_FIX (217.0), /* Size of scan area in mm (x) */ SANE_FIX (299.0), /* Size of scan area in mm (y) */ SANE_FIX (6.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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x0f, 0x01, 0x15, 0x06, 0x13, 0x04}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ 0 /* Which flags are needed for this scanner? */ /* Setup and tested */ }; static GT68xx_Model mustek_scanexpress1248ub_model = { "mustek-scanexpress-1248-ub", /* Name */ "Mustek", /* Device vendor string */ "ScanExpress 1248 UB", /* Device model name */ "SBSfw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (4.0), /* Start of scan area in mm (x) */ SANE_FIX (14.5), /* Start of scan area in mm (y) */ SANE_FIX (217.0), /* Size of scan area in mm (x) */ SANE_FIX (299.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 (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) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x1e, 0x08, 0x21, 0x0d, 0x1b, 0x05}, /* Default offset/gain */ {0x50, 0x50, 0x50}, /* Default exposure parameters */ SANE_FIX (1.5), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_STOP /* Which flags are needed for this scanner? */ /* tested by hmg */ }; static GT68xx_Model artec_ultima2000_model = { "artec-ultima-2000", /* Name */ "Artec", /* Device vendor string */ "Ultima 2000", /* Device model name */ "Gt680xfw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6801_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 200, 150, 100, 75, 50, 0}, /* possible x-resolutions */ {600, 300, 200, 150, 100, 75, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (2.0), /* Start of scan area in mm (x) */ SANE_FIX (7.0), /* 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 (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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x0f, 0x01, 0x15, 0x06, 0x13, 0x04}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_MIRROR_X | GT68XX_FLAG_MOTOR_HOME | GT68XX_FLAG_OFFSET_INV /* Which flags are needed for this scanner? */ /* Setup for Cytron TCM MD 9385 */ }; static GT68xx_Model plustek_opticslim500plus_model = { "plustek-opticslim-500plus", /* Name */ "Plustek", /* Device vendor string */ "OpticSlim 500 Plus", /* Device model name */ "cis3R5B1.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0},/* possible y-resolutions */ {16, 8, 0}, /* possible depths in gray mode */ {16, 8, 0}, /* possible depths in color mode */ SANE_FIX (1.0), /* Start of scan area in mm (x) */ SANE_FIX (9.5), /* Start of scan area in mm (y) */ SANE_FIX (218.0), /* Size of scan area in mm (x) */ SANE_FIX (142.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 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) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x32, 0x02, 0x26, 0x07, 0x26, 0x09}, /* Default offset/gain */ {0x127, 0x127, 0x127}, /* Default exposure parameters */ SANE_FIX (1.5), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_CALIBRATE /* Which flags are needed for this scanner? */ }; static GT68xx_Model mustek_2400cu_model = { "mustek-bearpaw-2400-cu", /* Name */ "Mustek", /* Device vendor string */ "BearPaw 2400 CU", /* Device model name */ "PS2fw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6801_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 2400, /* maximum motor resolution */ 1200, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {1200, 600, 300, 150, 100, 50, 0}, /* possible x-resolutions */ {2400, 1200, 600, 300, 150, 100, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (0.0), /* Start of scan area in mm (x) */ SANE_FIX (13.5), /* Start of scan area in mm (y) */ SANE_FIX (215.0), /* Size of scan area in mm (x) */ SANE_FIX (296.9), /* Size of scan area in mm (y) */ SANE_FIX (5.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.9), /* 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) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x0f, 0x01, 0x15, 0x06, 0x13, 0x04}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ 0 /* Which flags are needed for this scanner? */ /* basically tested, details may need tweaking */ }; static GT68xx_Model mustek_scanexpress2400usb_model = { "mustek-scanexpress-2400-usb", /* Name */ "Mustek", /* Device vendor string */ "ScanExpress 2400 USB", /* Device model name */ "P9fw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6801_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 1200, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 100, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 100, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (5.0), /* Start of scan area in mm (x) */ SANE_FIX (12.0), /* Start of scan area in mm (y) */ SANE_FIX (224.0), /* 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 (7.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 white strip in TA mode in mm (y) */ 24, 12, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x12, 0x06, 0x0e, 0x03, 0x19, 0x25}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_UNTESTED | GT68XX_FLAG_SE_2400 /* Which flags are needed for this scanner? */ /* only partly tested, from "Fan Dan" */ }; static GT68xx_Model mustek_a3usb_model = { "mustek-scanexpress-a3-usb", /* Name */ "Mustek", /* Device vendor string */ "ScanExpress A3 USB", /* Device model name */ "A32fw.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 300, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 300, /* base x-res used to calculate geometry */ 300, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {300, 150, 75, 50, 0}, /* possible x-resolutions */ {600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (7.0), /* Start of scan area in mm (x) */ SANE_FIX (11.5), /* Start of scan area in mm (y) */ SANE_FIX (297.0), /* Size of scan area in mm (x) */ SANE_FIX (433.0), /* Size of scan area in mm (y) */ SANE_FIX (2.4), /* Start of white strip in mm (y) */ SANE_FIX (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 white strip in TA mode in mm (y) */ 0, 5, 5, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x14, 0x05, 0x12, 0x05, 0x17, 0x0c}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (1.5), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_CIS_LAMP /* Which flags are needed for this scanner? */ /* Tested by hmg. This scanner is a bit strange as it uses a CIS sensor but it also has a lamp. So the lamp needs to be heated but CIS mode must be used for scanning and calibration. There is no TA for that scanner */ }; static GT68xx_Model lexmark_x73_model = { "lexmark-x73", /* Name */ "Lexmark", /* Device vendor string */ "X73", /* Device model name */ "OSLO3071b2.usb", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 0}, /* possible x-resolutions */ {600, 300, 150, 75, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (6.519), /* Start of scan area in mm (x) */ SANE_FIX (12.615), /* Start of scan area in mm (y) */ SANE_FIX (220.0), /* 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 (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) */ 32, 16, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x14, 0x07, 0x14, 0x07, 0x14, 0x07}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ 0 /* Which flags are needed for this scanner? */ /* When using automatic gain pictures are too dark. Only some ad hoc tests for lexmark x70 were done so far. WARNING: Don't use the Full scan option with the above settings, otherwise the sensor may bump at the end of the sledge and the scanner may be damaged! */ }; static GT68xx_Model plustek_op1248u_model = { "plustek-op1248u", /* Name */ "Plustek", /* Device vendor string */ "OpticPro 1248U", /* Device model name */ "ccd548.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &plustek_gt6801_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 0}, /* possible x-resolutions */ {600, 300, 150, 75, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 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 (216.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 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) */ 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x1e, 0x24, 0x1d, 0x1f, 0x1d, 0x20}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* tested */ }; static GT68xx_Model plustek_u16b_model = { "plustek-u16b", /* Name */ "Plustek", /* Device vendor string */ "OpticPro U16B", /* Device model name */ "ccd68861.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {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, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (5.5), /* Start of scan area in mm (x) */ SANE_FIX (8.5), /* Start of scan area in mm (y) */ SANE_FIX (216.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 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) */ 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x18, 0x16, 0x16, 0x0f, 0x17, 0x11}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_NO_POWER_STATUS | GT68XX_FLAG_NO_LINEMODE /* Which flags are needed for this scanner? */ /* Tested with a U16B by Henning Meier-Geinitz. 600 dpi is maximum vertically. Line mode does not work. That's a hardware/firmware issue. */ }; static GT68xx_Model plustek_ops12_model = { "plustek-opticpro-s12", /* Name */ "Plustek", /* Device vendor string */ "OpticPro S12", /* Device model name */ "ccd548.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 0}, /* possible x-resolutions */ {600, 300, 150, 75, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 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 (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 white strip in TA mode in mm (y) */ 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x1c, 0x29, 0x1c, 0x2c, 0x1c, 0x2b}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* Seems to work */ }; static GT68xx_Model plustek_ops24_model = { "plustek-opticpro-s24", /* Name */ "Plustek", /* Device vendor string */ "OpticPro S24", /* Device model name */ "ccd569.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 200, 100, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 200, 100, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (4.5), /* Start of scan area in mm (x) */ SANE_FIX (8.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 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) */ 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x18, 0x1c, 0x16, 0x12, 0x18, 0x1c}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* Works (tested by Filip Kaluza). Based on genius Colorpage Vivid 1200 X. */ }; static GT68xx_Model genius_vivid4_model = { "genius-colorpage-vivid4", /* Name */ "Genius", /* Device vendor string */ "ColorPage Vivid 4", /* Device model name */ "ccd68861.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {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, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (5.5), /* Start of scan area in mm (x) */ SANE_FIX (8.5), /* Start of scan area in mm (y) */ SANE_FIX (216.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 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) */ 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x18, 0x16, 0x16, 0x0f, 0x17, 0x11}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_NO_POWER_STATUS | GT68XX_FLAG_NO_LINEMODE /* Which flags are needed for this scanner? */ /* This scanner seems to be very similar to Plustelk U16B and is reported to work. */ }; static GT68xx_Model genius_vivid3x_model = { "genius-colorpage-vivid3x", /* Name */ "Genius", /* Device vendor string */ "Colorpage Vivid3x", /* Device model name */ "ccd548.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &plustek_gt6801_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 0}, /* possible x-resolutions */ {600, 300, 150, 75, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 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 (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 white strip in TA mode in mm (y) */ 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x1c, 0x29, 0x1c, 0x2c, 0x1c, 0x2b}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* Tested to some degree, based on the Plustek OpticPro 1248U */ }; static GT68xx_Model genius_vivid4x_model = { "genius-colorpage-vivid4x", /* Name */ "Genius", /* Device vendor string */ "Colorpage Vivid4x", /* Device model name */ "ccd548.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 0}, /* possible x-resolutions */ {600, 300, 150, 75, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 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 (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 white strip in TA mode in mm (y) */ 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x1c, 0x29, 0x1c, 0x2c, 0x1c, 0x2b}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* Is reported to work, copied from 3x, some values from Claudio Filho */ }; static GT68xx_Model genius_vivid4xe_model = { "genius-colorpage-vivid4xe", /* Name */ "Genius", /* Device vendor string */ "Colorpage Vivid4xe", /* Device model name */ "ccd548.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 0}, /* possible x-resolutions */ {600, 300, 150, 75, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 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 (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 white strip in TA mode in mm (y) */ 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x1c, 0x29, 0x1c, 0x2c, 0x1c, 0x2b}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* tested a bit */ }; static GT68xx_Model genius_vivid3xe_model = { "genius-colorpage-vivid3xe", /* Name */ "Genius", /* Device vendor string */ "Colorpage Vivid3xe", /* Device model name */ "ccd548.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &plustek_gt6801_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 600, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 0}, /* possible x-resolutions */ {600, 300, 150, 75, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 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 (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 white strip in TA mode in mm (y) */ 0, 8, 16, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x1c, 0x29, 0x1c, 0x2c, 0x1c, 0x2b}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* mostly untested, based on the Genius Vivid3x */ }; static GT68xx_Model genius_vivid1200x_model = { "genius-colorpage-vivid-1200-x", /* Name */ "Genius", /* Device vendor string */ "Colorpage Vivid 1200 X", /* Device model name */ "ccd569.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 200, 100, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 200, 100, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (4.5), /* Start of scan area in mm (x) */ SANE_FIX (8.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 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) */ 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x18, 0x1c, 0x16, 0x12, 0x18, 0x1c}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* Tested. */ }; static GT68xx_Model genius_vivid1200xe_model = { "genius-colorpage-vivid-1200-xe", /* Name */ "Genius", /* Device vendor string */ "Colorpage Vivid 1200 XE", /* Device model name */ "ccd569.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_TRUE, /* Use base_ydpi for all resolutions */ {600, 300, 200, 100, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 200, 100, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (4.5), /* Start of scan area in mm (x) */ SANE_FIX (8.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 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) */ 48, 24, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x18, 0x1c, 0x16, 0x12, 0x18, 0x1c}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_FALSE, /* Is this a CIS scanner? */ GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_ALWAYS_LINEMODE /* Which flags are needed for this scanner? */ /* Tested by hmg */ }; static GT68xx_Model iriscan_express_2_model = { "iriscan-express-2", /* Name */ "Iris", /* Device vendor string */ "Iriscan Express 2", /* Device model name */ "cism216.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_sheetfed_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ /* values based on analyze of the firmware */ {600, 400, 300, 200, 150, 100, 50, 0}, /* possible x-resolutions */ {1200, 600, 400, 300, 200, 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 (0.0), /* Start of scan area in mm (x) */ SANE_FIX (1.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 (18.0), /* Start of white strip in mm (y) */ SANE_FIX (21.72), /* 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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x22, 0x0c, 0x22, 0x0a, 0x24, 0x09}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_POWER_STATUS | GT68XX_FLAG_SHEET_FED | GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_HAS_CALIBRATE }; static GT68xx_Model plustek_opticslim_m12_model = { "plustek-opticslim-m12", /* Name */ "Plustek", /* Device vendor string */ "OpticSlim M12", /* Device model name */ "cism216.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_sheetfed_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {600, 400, 300, 200, 150, 100, 50, 0}, /* possible x-resolutions */ {1200, 600, 400, 300, 200, 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 (0.0), /* Start of scan area in mm (x) */ SANE_FIX (1.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 (18.0), /* Start of white strip in mm (y) */ SANE_FIX (21.72), /* 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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x24, 0x0a, 0x23, 0x0f, 0x23, 0x0b}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_POWER_STATUS | GT68XX_FLAG_SHEET_FED | GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_HAS_CALIBRATE }; static GT68xx_Model genius_sf600_model = { "genius-SF600", /* Name */ "Genius", /* Device vendor string */ "ColorPage SF600", /* Device model name */ "cism216.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_sheetfed_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {600, 300, 200, 150, 100, 0}, /* possible x-resolutions */ {600, 300, 200, 150, 100, 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.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 (18.0), /* Start of white strip in mm (y) */ SANE_FIX (21.72), /* 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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_BGR, /* Order of the CCD/CIS colors */ {0x24, 0x0a, 0x23, 0x0f, 0x23, 0x0b}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_NO_POWER_STATUS | GT68XX_FLAG_UNTESTED | GT68XX_FLAG_SHEET_FED | GT68XX_FLAG_OFFSET_INV | GT68XX_FLAG_HAS_CALIBRATE | GT68XX_FLAG_NO_STOP }; /* Untested but should work according to Ryan Reading . Based on Plustek M12 */ static GT68xx_Model plustek_opticslim1200_model = { "plustek-opticslim-1200", /* Name */ "Plustek", /* Device vendor string */ "OpticSlim 1200", /* Device model name */ "cism216.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 600, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 600, /* base x-res used to calculate geometry */ 600, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {600, 300, 150, 75, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 75, 50, 0}, /* possible y-resolutions */ {16, 8, 0}, /* possible depths in gray mode */ {16, 8, 0}, /* possible depths in color mode */ SANE_FIX (1.0), /* Start of scan area in mm (x) */ SANE_FIX (9.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 (140.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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x15, 0x09, 0x18, 0x11, 0x16, 0x0c}, /* Default offset/gain */ {0x157, 0x157, 0x157}, /* Default exposure parameters */ SANE_FIX (2.0), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ 0 }; static GT68xx_Model plustek_opticslim2400_model = { "plustek-opticslim-2400", /* Name */ "Plustek", /* Device vendor string */ "OpticSlim 2400", /* Device model name */ "cis3R5B1.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 2400, /* maximum motor resolution */ 1200, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {1200, 600, 300, 150, 100, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 100, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (1.0), /* Start of scan area in mm (x) */ SANE_FIX (9.5), /* Start of scan area in mm (y) */ SANE_FIX (217.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 (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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x15, 0x09, 0x18, 0x11, 0x16, 0x0c}, /* Default offset/gain */ {0x300, 0x300, 0x300}, /* Default exposure parameters */ SANE_FIX (1.5), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ 0 /* By Detlef Gausepohl . Fixed and tested by hmg. */ }; static GT68xx_Model visioneer_onetouch_7300_model = { "visioneer-onetouch-7300", /* Name */ "Visioneer", /* Device vendor string */ "OneTouch 7300", /* Device model name */ "Cis3r5b1.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 1200, /* maximum motor resolution */ 1200, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {1200, 600, 300, 150, 100, 50, 0}, /* possible x-resolutions */ {1200, 600, 300, 150, 100, 50, 0}, /* possible y-resolutions */ {12, 8, 0}, /* possible depths in gray mode */ {12, 8, 0}, /* possible depths in color mode */ SANE_FIX (1.0), /* Start of scan area in mm (x) */ SANE_FIX (9.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 (140.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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x15, 0x09, 0x18, 0x11, 0x16, 0x0c}, /* Default offset/gain */ {0x80, 0x80, 0x80}, /* Default exposure parameters */ SANE_FIX (1.5), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ 0 }; /* Tested by Jason Novek. Based on Plustek OpticSlim 2400. */ static GT68xx_Model genius_colorpageslim_1200_model = { "genius-colorpageslim-1200", /* Name */ "Genius", /* Device vendor string */ "ColorPage Slim 1200", /* Device model name */ "Cis3r5b1.fw", /* Name of the firmware file */ SANE_FALSE, /* Dynamic allocation flag */ &mustek_gt6816_command_set, /* Command set used by this scanner */ 1200, /* maximum optical sensor resolution */ 2400, /* maximum motor resolution */ 1200, /* base x-res used to calculate geometry */ 1200, /* base y-res used to calculate geometry */ 1200, /* if ydpi is equal or higher, disable backtracking */ SANE_FALSE, /* Use base_ydpi for all resolutions */ {1200, 600, 300, 150, 100, 50, 0}, /* possible x-resolutions */ {2400,1200, 600, 300, 150, 100, 50, 0}, /* possible y-resolutions */ {16, 12, 8, 0}, /* possible depths in gray mode */ {16, 12, 8, 0}, /* possible depths in color mode */ SANE_FIX (0.5), /* Start of scan area in mm (x) */ SANE_FIX (8.0), /* 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 (9.5), /* 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 white strip in TA mode in mm (y) */ 0, 0, 0, /* RGB CCD Line-distance correction in pixel */ 0, /* CCD distcance for CCD with 6 lines) */ COLOR_ORDER_RGB, /* Order of the CCD/CIS colors */ {0x19, 0x1a, 0x18, 0x14, 0x18, 0x12}, /* Default offset/gain */ {0x548, 0x513, 0x48d}, /* Default exposure parameters */ SANE_FIX (1.5), /* Default gamma value */ SANE_TRUE, /* Is this a CIS scanner? */ GT68XX_FLAG_ALWAYS_LINEMODE | GT68XX_FLAG_SE_2400 }; /* tested by Aleksey Nedorezov */ static GT68xx_USB_Device_Entry gt68xx_usb_device_list[] = { {0x10000, 0x10000, &unknown_model}, /* used for yet unknown scanners */ {0x055f, 0x0218, &mustek_2400ta_model}, {0x055f, 0x0219, &mustek_2400taplus_model}, {0x055f, 0x021c, &mustek_1200cuplus_model}, {0x055f, 0x021b, &mustek_1200cuplus2_model}, {0x055f, 0x021d, &mustek_2400cuplus_model}, {0x055f, 0x021e, &mustek_1200ta_model}, {0x055f, 0x021f, &mustek_scanexpress1248ub_model}, {0x05d8, 0x4002, &mustek_1200cu_model}, {0x05d8, 0x4002, &mustek_scanexpress1200ubplus_model}, /* manual override */ {0x05d8, 0x4002, &artec_ultima2000_model}, /* manual override */ {0x05d8, 0x4002, &mustek_2400cu_model}, /* manual override */ {0x05d8, 0x4002, &mustek_scanexpress2400usb_model}, /* manual override */ {0x055f, 0x0210, &mustek_a3usb_model}, {0x055f, 0x021a, &mustek_2448taplus_model}, {0x043d, 0x002d, &lexmark_x73_model}, {0x07b3, 0x0400, &plustek_op1248u_model}, {0x07b3, 0x0401, &plustek_op1248u_model}, /* Same scanner, different id? */ {0x07b3, 0x0402, &plustek_u16b_model}, {0x07b3, 0x0403, &plustek_u16b_model}, /* two ids? 403 seems to be more common */ {0x07b3, 0x040b, &plustek_ops12_model}, {0x07b3, 0x040e, &plustek_ops24_model}, {0x07b3, 0x0412, &plustek_opticslim_m12_model}, {0x07b3, 0x046e, &plustek_opticslim500plus_model}, {0x07b3, 0x0413, &plustek_opticslim1200_model}, {0x07b3, 0x0422, &plustek_opticslim2400_model}, {0x07b3, 0x045f, &iriscan_express_2_model}, {0x0458, 0x2011, &genius_vivid3x_model}, {0x0458, 0x2014, &genius_vivid4_model}, {0x0458, 0x2017, &genius_vivid3xe_model}, {0x0458, 0x201a, &genius_vivid4xe_model}, {0x0458, 0x201b, &genius_vivid4x_model}, {0x0458, 0x201d, &genius_vivid1200x_model}, {0x0458, 0x201f, &genius_vivid1200xe_model}, {0x0458, 0x2021, &genius_sf600_model}, {0x04a7, 0x0444, &visioneer_onetouch_7300_model}, {0x0458, 0x201E, &genius_colorpageslim_1200_model}, {0, 0, NULL} }; sane-backends-1.0.29/backend/coolscan3.c0000666000000000000000000022703713615534521014633 00000000000000/* * SANE - Scanner Access Now Easy. * coolscan3.c * * This file implements a SANE backend for Nikon Coolscan film scanners. * * coolscan3.c is based on coolscan2.c, a work of András Major, Ariel Garcia * and Giuseppe Sacco. * * Copyright (C) 2007-08 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. * */ /* ========================================================================= */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include "../include/_stdint.h" #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_debug.h" #include "../include/sane/sanei_config.h" #define BACKEND_NAME coolscan3 #include "../include/sane/sanei_backend.h" /* must be last */ #define CS3_VERSION_MAJOR 1 #define CS3_VERSION_MINOR 0 #define CS3_REVISION 0 #define CS3_CONFIG_FILE "coolscan3.conf" #define WSIZE (sizeof (SANE_Word)) /* ========================================================================= */ /* typedefs */ typedef enum { CS3_TYPE_UNKOWN, CS3_TYPE_LS30, CS3_TYPE_LS40, CS3_TYPE_LS50, CS3_TYPE_LS2000, CS3_TYPE_LS4000, CS3_TYPE_LS5000, CS3_TYPE_LS8000 } cs3_type_t; typedef enum { CS3_INTERFACE_UNKNOWN, CS3_INTERFACE_SCSI, /* includes IEEE1394 via SBP2 */ CS3_INTERFACE_USB } cs3_interface_t; typedef enum { CS3_PHASE_NONE = 0x00, CS3_PHASE_STATUS = 0x01, CS3_PHASE_OUT = 0x02, CS3_PHASE_IN = 0x03, CS3_PHASE_BUSY = 0x04 } cs3_phase_t; typedef enum { CS3_SCAN_NORMAL, CS3_SCAN_AE, CS3_SCAN_AE_WB } cs3_scan_t; typedef enum { CS3_STATUS_READY = 0, CS3_STATUS_BUSY = 1, CS3_STATUS_NO_DOCS = 2, CS3_STATUS_PROCESSING = 4, CS3_STATUS_ERROR = 8, CS3_STATUS_REISSUE = 16, CS3_STATUS_ALL = 31 /* sum of all others */ } cs3_status_t; typedef enum { CS3_OPTION_NUM = 0, CS3_OPTION_PREVIEW, CS3_OPTION_NEGATIVE, CS3_OPTION_INFRARED, CS3_OPTION_SAMPLES_PER_SCAN, CS3_OPTION_DEPTH, CS3_OPTION_EXPOSURE, CS3_OPTION_EXPOSURE_R, CS3_OPTION_EXPOSURE_G, CS3_OPTION_EXPOSURE_B, CS3_OPTION_SCAN_AE, CS3_OPTION_SCAN_AE_WB, CS3_OPTION_LUT_R, CS3_OPTION_LUT_G, CS3_OPTION_LUT_B, CS3_OPTION_RES, CS3_OPTION_RESX, CS3_OPTION_RESY, CS3_OPTION_RES_INDEPENDENT, CS3_OPTION_PREVIEW_RESOLUTION, CS3_OPTION_FRAME, CS3_OPTION_FRAME_COUNT, CS3_OPTION_SUBFRAME, CS3_OPTION_XMIN, CS3_OPTION_XMAX, CS3_OPTION_YMIN, CS3_OPTION_YMAX, CS3_OPTION_LOAD, CS3_OPTION_AUTOLOAD, CS3_OPTION_EJECT, CS3_OPTION_RESET, CS3_OPTION_FOCUS_ON_CENTRE, CS3_OPTION_FOCUS, CS3_OPTION_AUTOFOCUS, CS3_OPTION_FOCUSX, CS3_OPTION_FOCUSY, CS3_N_OPTIONS /* must be last -- counts number of enum items */ } cs3_option_t; typedef unsigned int cs3_pixel_t; #define CS3_COLOR_MAX 10 /* 9 + 1, see cs3_colors */ /* Given that there is no way to give scanner vendor * and model to the calling software, I have to use * an ugly hack here. :( That's very sad. Suggestions * that can provide the same features are appreciated. */ #ifndef SANE_COOKIE #define SANE_COOKIE 0x0BADCAFE struct SANE_Cookie { uint16_t version; const char *vendor; const char *model; const char *revision; }; #endif typedef struct { /* magic bits :( */ uint32_t magic; struct SANE_Cookie *cookie_ptr; struct SANE_Cookie cookie; /* interface */ cs3_interface_t interface; int fd; SANE_Byte *send_buf, *recv_buf; size_t send_buf_size, recv_buf_size; size_t n_cmd, n_send, n_recv; /* device characteristics */ char vendor_string[9], product_string[17], revision_string[5]; cs3_type_t type; int maxbits; unsigned int resx_optical, resx_min, resx_max, *resx_list, resx_n_list; unsigned int resy_optical, resy_min, resy_max, *resy_list, resy_n_list; unsigned long boundaryx, boundaryy; unsigned long frame_offset; unsigned int unit_dpi; double unit_mm; int n_frames; int focus_min, focus_max; /* settings */ SANE_Bool preview, negative, infrared, autoload, autofocus, ae, aewb; int samples_per_scan, depth, real_depth, bytes_per_pixel, shift_bits, n_colors; cs3_pixel_t n_lut; cs3_pixel_t *lut_r, *lut_g, *lut_b, *lut_neutral; unsigned long resx, resy, res, res_independent, res_preview; unsigned long xmin, xmax, ymin, ymax; int i_frame, frame_count; double subframe; unsigned int real_resx, real_resy, real_pitchx, real_pitchy; unsigned long real_xoffset, real_yoffset, real_width, real_height, logical_width, logical_height; int odd_padding; int block_padding; double exposure, exposure_r, exposure_g, exposure_b; unsigned long real_exposure[CS3_COLOR_MAX]; SANE_Bool focus_on_centre; unsigned long focusx, focusy, real_focusx, real_focusy; int focus; /* status */ SANE_Bool scanning; SANE_Byte *line_buf; ssize_t n_line_buf, i_line_buf; unsigned long sense_key, sense_asc, sense_ascq, sense_info; unsigned long sense_code; cs3_status_t status; size_t xfer_position, xfer_bytes_total; /* SANE stuff */ SANE_Option_Descriptor option_list[CS3_N_OPTIONS]; } cs3_t; /* ========================================================================= */ /* prototypes */ static SANE_Status cs3_open(const char *device, cs3_interface_t interface, cs3_t ** sp); static void cs3_close(cs3_t * s); static SANE_Status cs3_attach(const char *dev); static SANE_Status cs3_scsi_sense_handler(int fd, u_char * sense_buffer, void *arg); static SANE_Status cs3_parse_sense_data(cs3_t * s); static void cs3_init_buffer(cs3_t * s); static SANE_Status cs3_pack_byte(cs3_t * s, SANE_Byte byte); static void cs3_pack_long(cs3_t * s, unsigned long val); static void cs3_pack_word(cs3_t * s, unsigned long val); static SANE_Status cs3_parse_cmd(cs3_t * s, char *text); static SANE_Status cs3_grow_send_buffer(cs3_t * s); static SANE_Status cs3_issue_cmd(cs3_t * s); static cs3_phase_t cs3_phase_check(cs3_t * s); static SANE_Status cs3_set_boundary(cs3_t * s); static SANE_Status cs3_scanner_ready(cs3_t * s, int flags); static SANE_Status cs3_page_inquiry(cs3_t * s, int page); static SANE_Status cs3_full_inquiry(cs3_t * s); static SANE_Status cs3_mode_select(cs3_t * s); static SANE_Status cs3_reserve_unit(cs3_t * s); static SANE_Status cs3_release_unit(cs3_t * s); static SANE_Status cs3_execute(cs3_t * s); static SANE_Status cs3_load(cs3_t * s); static SANE_Status cs3_eject(cs3_t * s); static SANE_Status cs3_reset(cs3_t * s); static SANE_Status cs3_set_focus(cs3_t * s); static SANE_Status cs3_autofocus(cs3_t * s); static SANE_Status cs3_autoexposure(cs3_t * s, int wb); static SANE_Status cs3_get_exposure(cs3_t * s); static SANE_Status cs3_set_window(cs3_t * s, cs3_scan_t type); 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(void *p); /* ========================================================================= */ /* global variables */ static int cs3_colors[] = { 1, 2, 3, 9 }; static SANE_Device **device_list = NULL; static int n_device_list = 0; static cs3_interface_t try_interface = CS3_INTERFACE_UNKNOWN; static int open_devices = 0; /* ========================================================================= */ /* SANE entry points */ SANE_Status sane_init(SANE_Int * version_code, SANE_Auth_Callback authorize) { DBG_INIT(); DBG(1, "coolscan3 backend, version %i.%i.%i initializing.\n", CS3_VERSION_MAJOR, CS3_VERSION_MINOR, CS3_REVISION); authorize = authorize; /* to shut up compiler */ if (version_code) *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, 0); sanei_usb_init(); return SANE_STATUS_GOOD; } void sane_exit(void) { int i; DBG(10, "%s\n", __func__); for (i = 0; i < n_device_list; i++) { 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); } SANE_Status sane_get_devices(const SANE_Device *** list, SANE_Bool local_only) { char line[PATH_MAX], *p; FILE *config; local_only = local_only; /* to shut up compiler */ DBG(10, "%s\n", __func__); if (device_list) DBG(6, "sane_get_devices(): Device list already populated, not probing again.\n"); else { if (open_devices) { DBG(4, "sane_get_devices(): Devices open, not scanning for scanners.\n"); return SANE_STATUS_IO_ERROR; } config = sanei_config_open(CS3_CONFIG_FILE); if (config) { DBG(4, "sane_get_devices(): Reading config file.\n"); while (sanei_config_read(line, sizeof(line), config)) { p = line; p += strspn(line, " \t"); if (strlen(p) && (p[0] != '\n') && (p[0] != '#')) cs3_open(line, CS3_INTERFACE_UNKNOWN, NULL); } fclose(config); } else { DBG(4, "sane_get_devices(): No config file found.\n"); cs3_open("auto", CS3_INTERFACE_UNKNOWN, NULL); } DBG(6, "%s: %i device(s) detected.\n", __func__, n_device_list); } *list = (const SANE_Device **) device_list; return SANE_STATUS_GOOD; } SANE_Status sane_open(SANE_String_Const name, SANE_Handle * h) { SANE_Status status; cs3_t *s; int i_option; unsigned int i_list; SANE_Option_Descriptor o; SANE_Word *word_list; SANE_Range *range = NULL; int alloc_failed = 0; DBG(10, "%s\n", __func__); status = cs3_open(name, CS3_INTERFACE_UNKNOWN, &s); if (status != SANE_STATUS_GOOD) return status; *h = (SANE_Handle) s; /* get device properties */ s->lut_r = s->lut_g = s->lut_b = s->lut_neutral = NULL; s->resx_list = s->resy_list = NULL; s->resx_n_list = s->resy_n_list = 0; status = cs3_full_inquiry(s); if (status != SANE_STATUS_GOOD) return status; status = cs3_mode_select(s); if (status != SANE_STATUS_GOOD) return status; /* option descriptors */ for (i_option = 0; i_option < CS3_N_OPTIONS; i_option++) { o.name = o.title = o.desc = NULL; o.type = o.unit = o.cap = o.constraint_type = o.size = 0; o.constraint.range = NULL; /* only one union member needs to be NULLed */ switch (i_option) { case CS3_OPTION_NUM: o.name = ""; o.title = SANE_TITLE_NUM_OPTIONS; o.desc = SANE_DESC_NUM_OPTIONS; o.type = SANE_TYPE_INT; o.size = WSIZE; o.cap = SANE_CAP_SOFT_DETECT; break; case CS3_OPTION_PREVIEW: o.name = "preview"; o.title = "Preview mode"; o.desc = "Preview mode"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; break; case CS3_OPTION_NEGATIVE: o.name = "negative"; o.title = "Negative"; o.desc = "Negative film: make scanner invert colors"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; /*o.cap |= SANE_CAP_INACTIVE; */ break; case CS3_OPTION_INFRARED: o.name = "infrared"; o.title = "Read infrared channel"; o.desc = "Read infrared channel in addition to scan colors"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; #ifndef SANE_FRAME_RGBI o.cap |= SANE_CAP_INACTIVE; #endif break; case CS3_OPTION_SAMPLES_PER_SCAN: o.name = "samples-per-scan"; o.title = "Samples per Scan"; o.desc = "Number of samples per scan"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_NONE; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if (s->type != CS3_TYPE_LS2000 && s->type != CS3_TYPE_LS4000 && s->type != CS3_TYPE_LS5000 && s->type != CS3_TYPE_LS8000) o.cap |= SANE_CAP_INACTIVE; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc (sizeof (SANE_Range)); if (! range) alloc_failed = 1; else { range->min = 1; range->max = 16; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_DEPTH: o.name = "depth"; o.title = "Bit depth per channel"; o.desc = "Number of bits output by scanner for each channel"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_NONE; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_WORD_LIST; word_list = (SANE_Word *) cs3_xmalloc(2 * sizeof(SANE_Word)); if (!word_list) alloc_failed = 1; else { word_list[1] = 8; word_list[2] = s->maxbits; word_list[0] = 2; o.constraint.word_list = word_list; } break; case CS3_OPTION_EXPOSURE: o.name = "exposure"; o.title = "Exposure multiplier"; o.desc = "Exposure multiplier for all channels"; o.type = SANE_TYPE_FIXED; o.unit = SANE_UNIT_NONE; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = SANE_FIX(0.); range->max = SANE_FIX(10.); range->quant = SANE_FIX(0.1); o.constraint.range = range; } break; case CS3_OPTION_EXPOSURE_R: o.name = "red-exposure"; o.title = "Red exposure time"; o.desc = "Exposure time for red channel"; o.type = SANE_TYPE_FIXED; o.unit = SANE_UNIT_MICROSECOND; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = SANE_FIX(50.); range->max = SANE_FIX(20000.); range->quant = SANE_FIX(10.); o.constraint.range = range; } break; case CS3_OPTION_EXPOSURE_G: o.name = "green-exposure"; o.title = "Green exposure time"; o.desc = "Exposure time for green channel"; o.type = SANE_TYPE_FIXED; o.unit = SANE_UNIT_MICROSECOND; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = SANE_FIX(50.); range->max = SANE_FIX(20000.); range->quant = SANE_FIX(10.); o.constraint.range = range; } break; case CS3_OPTION_EXPOSURE_B: o.name = "blue-exposure"; o.title = "Blue exposure time"; o.desc = "Exposure time for blue channel"; o.type = SANE_TYPE_FIXED; o.unit = SANE_UNIT_MICROSECOND; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = SANE_FIX(50.); range->max = SANE_FIX(20000.); range->quant = SANE_FIX(10.); o.constraint.range = range; } break; case CS3_OPTION_LUT_R: o.name = "red-gamma-table"; o.title = "LUT for red channel"; o.desc = "LUT for red channel"; o.type = SANE_TYPE_INT; o.size = s->n_lut * WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 0; range->max = s->n_lut - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_LUT_G: o.name = "green-gamma-table"; o.title = "LUT for green channel"; o.desc = "LUT for green channel"; o.type = SANE_TYPE_INT; o.size = s->n_lut * WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 0; range->max = s->n_lut - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_LUT_B: o.name = "blue-gamma-table"; o.title = "LUT for blue channel"; o.desc = "LUT for blue channel"; o.type = SANE_TYPE_INT; o.size = s->n_lut * WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 0; range->max = s->n_lut - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_LOAD: o.name = "load"; o.title = "Load"; o.desc = "Load next slide"; o.type = SANE_TYPE_BUTTON; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if (s->n_frames > 1) o.cap |= SANE_CAP_INACTIVE; break; case CS3_OPTION_AUTOLOAD: o.name = "autoload"; o.title = "Autoload"; o.desc = "Autoload slide before each scan"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if (s->n_frames > 1) o.cap |= SANE_CAP_INACTIVE; break; case CS3_OPTION_EJECT: o.name = "eject"; o.title = "Eject"; o.desc = "Eject loaded medium"; o.type = SANE_TYPE_BUTTON; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; break; case CS3_OPTION_RESET: o.name = "reset"; o.title = "Reset scanner"; o.desc = "Initialize scanner"; o.type = SANE_TYPE_BUTTON; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; break; case CS3_OPTION_RESX: case CS3_OPTION_RES: case CS3_OPTION_PREVIEW_RESOLUTION: if (i_option == CS3_OPTION_PREVIEW_RESOLUTION) { o.name = "preview-resolution"; o.title = "Preview resolution"; o.desc = "Scanning resolution for preview mode in dpi, affecting both x and y directions"; } else if (i_option == CS3_OPTION_RES) { o.name = "resolution"; o.title = "Resolution"; o.desc = "Scanning resolution in dpi, affecting both x and y directions"; } else { o.name = "x-resolution"; o.title = "X resolution"; o.desc = "Scanning resolution in dpi, affecting x direction only"; } o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_DPI; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if (i_option == CS3_OPTION_RESX) o.cap |= SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; if (i_option == CS3_OPTION_PREVIEW_RESOLUTION) o.cap |= SANE_CAP_ADVANCED; o.constraint_type = SANE_CONSTRAINT_WORD_LIST; word_list = (SANE_Word *) cs3_xmalloc((s->resx_n_list + 1) * sizeof(SANE_Word)); if (!word_list) alloc_failed = 1; else { for (i_list = 0; i_list < s->resx_n_list; i_list++) word_list[i_list + 1] = s->resx_list[i_list]; word_list[0] = s->resx_n_list; o.constraint.word_list = word_list; } break; case CS3_OPTION_RESY: o.name = "y-resolution"; o.title = "Y resolution"; o.desc = "Scanning resolution in dpi, affecting y direction only"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_DPI; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; o.constraint_type = SANE_CONSTRAINT_WORD_LIST; word_list = (SANE_Word *) cs3_xmalloc((s->resy_n_list + 1) * sizeof(SANE_Word)); if (!word_list) alloc_failed = 1; else { for (i_list = 0; i_list < s->resy_n_list; i_list++) word_list[i_list + 1] = s->resy_list[i_list]; word_list[0] = s->resy_n_list; o.constraint.word_list = word_list; } break; case CS3_OPTION_RES_INDEPENDENT: o.name = "independent-res"; o.title = "Independent x/y resolutions"; o.desc = "Enable independent controls for scanning resolution in x and y direction"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE | SANE_CAP_ADVANCED; break; case CS3_OPTION_FRAME: o.name = "frame"; o.title = "Frame number"; o.desc = "Number of frame to be scanned, starting with 1"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_NONE; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if (s->n_frames <= 1) o.cap |= SANE_CAP_INACTIVE; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 1; range->max = s->n_frames; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_FRAME_COUNT: o.name = "frame-count"; o.title = "Frame count"; o.desc = "Amount of frames to scan"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_NONE; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; if (s->n_frames <= 1) o.cap |= SANE_CAP_INACTIVE; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 1; range->max = s->n_frames - s->i_frame + 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_SUBFRAME: o.name = "subframe"; o.title = "Frame shift"; o.desc = "Fine position within the selected frame"; o.type = SANE_TYPE_FIXED; o.unit = SANE_UNIT_MM; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = SANE_FIX(0.); range->max = SANE_FIX((s->boundaryy - 1) * s->unit_mm); range->quant = SANE_FIX(0.); o.constraint.range = range; } break; case CS3_OPTION_XMIN: o.name = "tl-x"; o.title = "Left x value of scan area"; o.desc = "Left x value of scan area"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_PIXEL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; if (!range) alloc_failed = 1; else { range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); range->min = 0; range->max = s->boundaryx - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_XMAX: o.name = "br-x"; o.title = "Right x value of scan area"; o.desc = "Right x value of scan area"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_PIXEL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 0; range->max = s->boundaryx - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_YMIN: o.name = "tl-y"; o.title = "Top y value of scan area"; o.desc = "Top y value of scan area"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_PIXEL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 0; range->max = s->boundaryy - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_YMAX: o.name = "br-y"; o.title = "Bottom y value of scan area"; o.desc = "Bottom y value of scan area"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_PIXEL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 0; range->max = s->boundaryy - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_FOCUS_ON_CENTRE: o.name = "focus-on-centre"; o.title = "Use centre of scan area as AF point"; o.desc = "Use centre of scan area as AF point instead of manual AF point selection"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; break; case CS3_OPTION_FOCUS: o.name = "focus"; o.title = "Focus position"; o.desc = "Focus position for manual focus"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_NONE; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = s->focus_min; range->max = s->focus_max; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_AUTOFOCUS: o.name = "autofocus"; o.title = "Autofocus"; o.desc = "Perform autofocus before scan"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; break; case CS3_OPTION_FOCUSX: o.name = "focusx"; o.title = "X coordinate of AF point"; o.desc = "X coordinate of AF point"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_PIXEL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 0; range->max = s->boundaryx - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_FOCUSY: o.name = "focusy"; o.title = "Y coordinate of AF point"; o.desc = "Y coordinate of AF point"; o.type = SANE_TYPE_INT; o.unit = SANE_UNIT_PIXEL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_INACTIVE; o.constraint_type = SANE_CONSTRAINT_RANGE; range = (SANE_Range *) cs3_xmalloc(sizeof(SANE_Range)); if (!range) alloc_failed = 1; else { range->min = 0; range->max = s->boundaryy - 1; range->quant = 1; o.constraint.range = range; } break; case CS3_OPTION_SCAN_AE: o.name = "ae"; o.title = "Auto-exposure"; o.desc = "Perform auto-exposure before scan"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; break; case CS3_OPTION_SCAN_AE_WB: o.name = "ae-wb"; o.title = "Auto-exposure with white balance"; o.desc = "Perform auto-exposure with white balance before scan"; o.type = SANE_TYPE_BOOL; o.size = WSIZE; o.cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; break; default: DBG(1, "BUG: sane_open(): Unknown option number: %d\n", i_option); break; } s->option_list[i_option] = o; } s->scanning = SANE_FALSE; s->preview = SANE_FALSE; s->negative = SANE_FALSE; s->autoload = SANE_FALSE; s->infrared = SANE_FALSE; s->ae = SANE_FALSE; s->aewb = SANE_FALSE; s->samples_per_scan = 1; s->depth = 8; s->i_frame = 1; s->frame_count = 1; s->subframe = 0.; s->res = s->resx = s->resx_max; s->resy = s->resy_max; s->res_independent = SANE_FALSE; s->res_preview = s->resx_max / 10; if (s->res_preview < s->resx_min) s->res_preview = s->resx_min; s->xmin = 0; s->xmax = s->boundaryx - 1; s->ymin = 0; s->ymax = s->boundaryy - 1; s->focus_on_centre = SANE_TRUE; s->focus = 0; s->focusx = 0; s->focusy = 0; s->exposure = 1.; s->exposure_r = 1200.; s->exposure_g = 1200.; s->exposure_b = 1000.; s->line_buf = NULL; s->n_line_buf = 0; if (alloc_failed) { cs3_close(s); return SANE_STATUS_NO_MEM; } return cs3_reserve_unit(s); } void sane_close(SANE_Handle h) { cs3_t *s = (cs3_t *) h; DBG(10, "%s\n", __func__); cs3_release_unit(s); cs3_close(s); } const SANE_Option_Descriptor * sane_get_option_descriptor(SANE_Handle h, SANE_Int n) { cs3_t *s = (cs3_t *) h; DBG(24, "%s, option %i\n", __func__, n); if ((n >= 0) && (n < CS3_N_OPTIONS)) return &s->option_list[n]; else return NULL; } SANE_Status sane_control_option(SANE_Handle h, SANE_Int n, SANE_Action a, void *v, SANE_Int * i) { cs3_t *s = (cs3_t *) h; SANE_Int flags = 0; cs3_pixel_t pixel; SANE_Option_Descriptor o = s->option_list[n]; DBG(24, "%s, option %i, action %i.\n", __func__, n, a); switch (a) { case SANE_ACTION_GET_VALUE: switch (n) { case CS3_OPTION_NUM: *(SANE_Word *) v = CS3_N_OPTIONS; break; case CS3_OPTION_NEGATIVE: *(SANE_Word *) v = s->negative; break; case CS3_OPTION_INFRARED: *(SANE_Word *) v = s->infrared; break; case CS3_OPTION_SAMPLES_PER_SCAN: *(SANE_Word *) v = s->samples_per_scan; break; case CS3_OPTION_DEPTH: *(SANE_Word *) v = s->depth; break; case CS3_OPTION_PREVIEW: *(SANE_Word *) v = s->preview; break; case CS3_OPTION_AUTOLOAD: *(SANE_Word *) v = s->autoload; break; case CS3_OPTION_EXPOSURE: *(SANE_Word *) v = SANE_FIX(s->exposure); break; case CS3_OPTION_EXPOSURE_R: *(SANE_Word *) v = SANE_FIX(s->exposure_r); break; case CS3_OPTION_EXPOSURE_G: *(SANE_Word *) v = SANE_FIX(s->exposure_g); break; case CS3_OPTION_EXPOSURE_B: *(SANE_Word *) v = SANE_FIX(s->exposure_b); break; case CS3_OPTION_LUT_R: if (!(s->lut_r)) return SANE_STATUS_INVAL; for (pixel = 0; pixel < s->n_lut; pixel++) ((SANE_Word *) v)[pixel] = s->lut_r[pixel]; break; case CS3_OPTION_LUT_G: if (!(s->lut_g)) return SANE_STATUS_INVAL; for (pixel = 0; pixel < s->n_lut; pixel++) ((SANE_Word *) v)[pixel] = s->lut_g[pixel]; break; case CS3_OPTION_LUT_B: if (!(s->lut_b)) return SANE_STATUS_INVAL; for (pixel = 0; pixel < s->n_lut; pixel++) ((SANE_Word *) v)[pixel] = s->lut_b[pixel]; break; case CS3_OPTION_EJECT: break; case CS3_OPTION_LOAD: break; case CS3_OPTION_RESET: break; case CS3_OPTION_FRAME: *(SANE_Word *) v = s->i_frame; break; case CS3_OPTION_FRAME_COUNT: *(SANE_Word *) v = s->frame_count; break; case CS3_OPTION_SUBFRAME: *(SANE_Word *) v = SANE_FIX(s->subframe); break; case CS3_OPTION_RES: *(SANE_Word *) v = s->res; break; case CS3_OPTION_RESX: *(SANE_Word *) v = s->resx; break; case CS3_OPTION_RESY: *(SANE_Word *) v = s->resy; break; case CS3_OPTION_RES_INDEPENDENT: *(SANE_Word *) v = s->res_independent; break; case CS3_OPTION_PREVIEW_RESOLUTION: *(SANE_Word *) v = s->res_preview; break; case CS3_OPTION_XMIN: *(SANE_Word *) v = s->xmin; break; case CS3_OPTION_XMAX: *(SANE_Word *) v = s->xmax; break; case CS3_OPTION_YMIN: *(SANE_Word *) v = s->ymin; break; case CS3_OPTION_YMAX: *(SANE_Word *) v = s->ymax; break; case CS3_OPTION_FOCUS_ON_CENTRE: *(SANE_Word *) v = s->focus_on_centre; break; case CS3_OPTION_FOCUS: *(SANE_Word *) v = s->focus; break; case CS3_OPTION_AUTOFOCUS: *(SANE_Word *) v = s->autofocus; break; case CS3_OPTION_FOCUSX: *(SANE_Word *) v = s->focusx; break; case CS3_OPTION_FOCUSY: *(SANE_Word *) v = s->focusy; break; case CS3_OPTION_SCAN_AE: *(SANE_Word *) v = s->ae; break; case CS3_OPTION_SCAN_AE_WB: *(SANE_Word *) v = s->aewb; break; default: DBG(4, "%s: Unknown option (bug?).\n", __func__); return SANE_STATUS_INVAL; } break; case SANE_ACTION_SET_VALUE: if (s->scanning) return SANE_STATUS_INVAL; /* XXX do this for all elements of arrays */ switch (o.type) { case SANE_TYPE_BOOL: if ((*(SANE_Word *) v != SANE_TRUE) && (*(SANE_Word *) v != SANE_FALSE)) return SANE_STATUS_INVAL; break; case SANE_TYPE_INT: case SANE_TYPE_FIXED: switch (o.constraint_type) { case SANE_CONSTRAINT_RANGE: if (*(SANE_Word *) v < o.constraint.range->min) { *(SANE_Word *) v = o.constraint.range->min; flags |= SANE_INFO_INEXACT; } else if (*(SANE_Word *) v > o.constraint.range->max) { *(SANE_Word *) v = o.constraint.range->max; flags |= SANE_INFO_INEXACT; } break; case SANE_CONSTRAINT_WORD_LIST: break; default: break; } break; case SANE_TYPE_STRING: break; case SANE_TYPE_BUTTON: break; case SANE_TYPE_GROUP: break; } switch (n) { case CS3_OPTION_NUM: return SANE_STATUS_INVAL; break; case CS3_OPTION_NEGATIVE: s->negative = *(SANE_Word *) v; break; case CS3_OPTION_INFRARED: s->infrared = *(SANE_Word *) v; /* flags |= SANE_INFO_RELOAD_PARAMS; XXX */ break; case CS3_OPTION_SAMPLES_PER_SCAN: s->samples_per_scan = *(SANE_Word *) v; break; case CS3_OPTION_DEPTH: if (*(SANE_Word *) v > s->maxbits) return SANE_STATUS_INVAL; s->depth = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_PREVIEW: s->preview = *(SANE_Word *) v; break; case CS3_OPTION_AUTOLOAD: s->autoload = *(SANE_Word *) v; break; case CS3_OPTION_EXPOSURE: s->exposure = SANE_UNFIX(*(SANE_Word *) v); break; case CS3_OPTION_EXPOSURE_R: s->exposure_r = SANE_UNFIX(*(SANE_Word *) v); break; case CS3_OPTION_EXPOSURE_G: s->exposure_g = SANE_UNFIX(*(SANE_Word *) v); break; case CS3_OPTION_EXPOSURE_B: s->exposure_b = SANE_UNFIX(*(SANE_Word *) v); break; case CS3_OPTION_LUT_R: if (!(s->lut_r)) return SANE_STATUS_INVAL; for (pixel = 0; pixel < s->n_lut; pixel++) s->lut_r[pixel] = ((SANE_Word *) v)[pixel]; break; case CS3_OPTION_LUT_G: if (!(s->lut_g)) return SANE_STATUS_INVAL; for (pixel = 0; pixel < s->n_lut; pixel++) s->lut_g[pixel] = ((SANE_Word *) v)[pixel]; break; case CS3_OPTION_LUT_B: if (!(s->lut_b)) return SANE_STATUS_INVAL; for (pixel = 0; pixel < s->n_lut; pixel++) s->lut_b[pixel] = ((SANE_Word *) v)[pixel]; break; case CS3_OPTION_LOAD: cs3_load(s); break; case CS3_OPTION_EJECT: cs3_eject(s); break; case CS3_OPTION_RESET: cs3_reset(s); break; case CS3_OPTION_FRAME: s->i_frame = *(SANE_Word *) v; break; case CS3_OPTION_FRAME_COUNT: if (*(SANE_Word *) v > (s->n_frames - s->i_frame + 1)) return SANE_STATUS_INVAL; s->frame_count = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_SUBFRAME: s->subframe = SANE_UNFIX(*(SANE_Word *) v); break; case CS3_OPTION_RES: s->res = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_RESX: s->resx = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_RESY: s->resy = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_RES_INDEPENDENT: s->res_independent = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_PREVIEW_RESOLUTION: s->res_preview = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_XMIN: s->xmin = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_XMAX: s->xmax = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_YMIN: s->ymin = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_YMAX: s->ymax = *(SANE_Word *) v; flags |= SANE_INFO_RELOAD_PARAMS; break; case CS3_OPTION_FOCUS_ON_CENTRE: s->focus_on_centre = *(SANE_Word *) v; if (s->focus_on_centre) { s->option_list[CS3_OPTION_FOCUSX].cap |= SANE_CAP_INACTIVE; s->option_list[CS3_OPTION_FOCUSY].cap |= SANE_CAP_INACTIVE; } else { s->option_list[CS3_OPTION_FOCUSX].cap &= ~SANE_CAP_INACTIVE; s->option_list[CS3_OPTION_FOCUSY].cap &= ~SANE_CAP_INACTIVE; } flags |= SANE_INFO_RELOAD_OPTIONS; break; case CS3_OPTION_FOCUS: s->focus = *(SANE_Word *) v; break; case CS3_OPTION_AUTOFOCUS: s->autofocus = *(SANE_Word *) v; break; case CS3_OPTION_FOCUSX: s->focusx = *(SANE_Word *) v; break; case CS3_OPTION_FOCUSY: s->focusy = *(SANE_Word *) v; break; case CS3_OPTION_SCAN_AE: s->ae = *(SANE_Word *) v; break; case CS3_OPTION_SCAN_AE_WB: s->aewb = *(SANE_Word *) v; break; default: DBG(4, "Error: sane_control_option(): Unknown option number (bug?).\n"); return SANE_STATUS_INVAL; break; } break; default: DBG(1, "BUG: sane_control_option(): Unknown action number.\n"); return SANE_STATUS_INVAL; break; } if (i) *i = flags; return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters(SANE_Handle h, SANE_Parameters * p) { cs3_t *s = (cs3_t *) h; SANE_Status status; DBG(10, "%s\n", __func__); if (!s->scanning) { /* only recalculate when not scanning */ status = cs3_convert_options(s); if (status != SANE_STATUS_GOOD) return status; } p->bytes_per_line = s->n_colors * s->logical_width * s->bytes_per_pixel; #ifdef SANE_FRAME_RGBI if (s->infrared) { p->format = SANE_FRAME_RGBI; } else { #endif p->format = SANE_FRAME_RGB; /* XXXXXXXX CCCCCCCCCC */ #ifdef SANE_FRAME_RGBI } #endif p->last_frame = SANE_TRUE; p->lines = s->logical_height; p->depth = 8 * s->bytes_per_pixel; p->pixels_per_line = s->logical_width; return SANE_STATUS_GOOD; } SANE_Status sane_start(SANE_Handle h) { cs3_t *s = (cs3_t *) h; SANE_Status status; DBG(10, "%s\n", __func__); if (s->scanning) return SANE_STATUS_INVAL; if (s->n_frames > 1 && s->frame_count == 0) { DBG(4, "%s: no more frames\n", __func__); return SANE_STATUS_NO_DOCS; } if (s->n_frames > 1) { DBG(4, "%s: scanning frame at position %d, %d to go\n", __func__, s->i_frame, s->frame_count); } status = cs3_convert_options(s); if (status != SANE_STATUS_GOOD) return status; s->i_line_buf = 0; s->xfer_position = 0; s->scanning = SANE_TRUE; /* load if appropriate */ if (s->autoload) { status = cs3_load(s); if (status != SANE_STATUS_GOOD) return status; } /* check for documents */ status = cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); if (status != SANE_STATUS_GOOD) return status; if (s->status & CS3_STATUS_NO_DOCS) return SANE_STATUS_NO_DOCS; if (s->autofocus) { status = cs3_autofocus(s); if (status != SANE_STATUS_GOOD) return status; } if (s->aewb) { status = cs3_autoexposure(s, 1); if (status != SANE_STATUS_GOOD) return status; } else if (s->ae) { status = cs3_autoexposure(s, 0); if (status != SANE_STATUS_GOOD) return status; } return cs3_scan(s, CS3_SCAN_NORMAL); } SANE_Status sane_read(SANE_Handle h, SANE_Byte * buf, SANE_Int maxlen, SANE_Int * len) { cs3_t *s = (cs3_t *) h; SANE_Status status; ssize_t xfer_len_in, xfer_len_line, xfer_len_out; unsigned long index; int color, sample_pass; uint8_t *s8 = NULL; uint16_t *s16 = NULL; double m_avg_sum; SANE_Byte *line_buf_new; DBG(32, "%s, maxlen = %i.\n", __func__, maxlen); if (!s->scanning) { *len = 0; return SANE_STATUS_CANCELLED; } /* transfer from buffer */ if (s->i_line_buf > 0) { xfer_len_out = s->n_line_buf - s->i_line_buf; if (xfer_len_out > maxlen) xfer_len_out = maxlen; memcpy(buf, &(s->line_buf[s->i_line_buf]), xfer_len_out); s->i_line_buf += xfer_len_out; if (s->i_line_buf >= s->n_line_buf) s->i_line_buf = 0; *len = xfer_len_out; return SANE_STATUS_GOOD; } xfer_len_line = s->n_colors * s->logical_width * s->bytes_per_pixel; xfer_len_in = xfer_len_line + (s->n_colors * s->odd_padding); if ((xfer_len_in & 0x3f)) { int d = ((xfer_len_in / 512) * 512) + 512; s->block_padding = d - xfer_len_in; } DBG(22, "%s: block_padding = %d, odd_padding = %d\n", __func__, s->block_padding, s->odd_padding); DBG(22, "%s: colors = %d, logical_width = %ld, bytes_per_pixel = %d\n", __func__, s->n_colors, s->logical_width, s->bytes_per_pixel); /* Do not change the behaviour of older models, pad to 512 */ if ((s->type == CS3_TYPE_LS50) || (s->type == CS3_TYPE_LS5000)) { xfer_len_in += s->block_padding; if (xfer_len_in & 0x3f) DBG(1, "BUG: %s, not a multiple of 64. (0x%06lx)\n", __func__, (long) xfer_len_in); } if (s->xfer_position + xfer_len_line > s->xfer_bytes_total) xfer_len_line = s->xfer_bytes_total - s->xfer_position; /* just in case */ if (xfer_len_line == 0) { /* no more data */ *len = 0; /* increment frame number if appropriate */ if (s->n_frames > 1 && --s->frame_count) { s->i_frame++; } s->scanning = SANE_FALSE; return SANE_STATUS_EOF; } if (xfer_len_line != s->n_line_buf) { line_buf_new = (SANE_Byte *) cs3_xrealloc(s->line_buf, xfer_len_line * sizeof(SANE_Byte)); if (!line_buf_new) { *len = 0; return SANE_STATUS_NO_MEM; } s->line_buf = line_buf_new; s->n_line_buf = xfer_len_line; } /* adapt for multi-sampling */ xfer_len_in *= s->samples_per_scan; cs3_scanner_ready(s, CS3_STATUS_READY); cs3_init_buffer(s); cs3_parse_cmd(s, "28 00 00 00 00 00"); cs3_pack_byte(s, (xfer_len_in >> 16) & 0xff); cs3_pack_byte(s, (xfer_len_in >> 8) & 0xff); cs3_pack_byte(s, xfer_len_in & 0xff); cs3_parse_cmd(s, "00"); s->n_recv = xfer_len_in; status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) { *len = 0; return status; } for (index = 0; index < s->logical_width; index++) { for (color = 0; color < s->n_colors; color++) { int where = s->bytes_per_pixel * (s->n_colors * index + color); m_avg_sum = 0.0; switch (s->bytes_per_pixel) { case 1: { /* target address */ s8 = (uint8_t *) & (s->line_buf[where]); if (s->samples_per_scan > 1) { /* calculate average of multi samples */ for (sample_pass = 0; sample_pass < s->samples_per_scan; sample_pass++) { /* source index */ int p8 = (sample_pass * s->n_colors + color) * s->logical_width + (color + 1) * s->odd_padding + index; m_avg_sum += (double) s->recv_buf[p8]; } *s8 = (uint8_t) (m_avg_sum / s->samples_per_scan + 0.5); } else { /* shortcut for single sample */ int p8 = s->logical_width * color + (color + 1) * s->odd_padding + index; *s8 = s->recv_buf[p8]; } } break; case 2: { /* target address */ s16 = (uint16_t *) & (s->line_buf[where]); if (s->samples_per_scan > 1) { /* calculate average of multi samples */ for (sample_pass = 0; sample_pass < s->samples_per_scan; sample_pass++) { /* source index */ int p16 = 2 * ((sample_pass * s->n_colors + color) * s->logical_width + index); m_avg_sum += (double) ((s->recv_buf[p16] << 8) + s->recv_buf[p16 + 1]); } *s16 = (uint16_t) (m_avg_sum / s->samples_per_scan + 0.5); } else { /* shortcut for single sample */ int p16 = 2 * (color * s->logical_width + index); *s16 = (s->recv_buf[p16] << 8) + s->recv_buf[p16 + 1]; } *s16 <<= s->shift_bits; } break; default: DBG(1, "BUG: sane_read(): Unknown number of bytes per pixel.\n"); *len = 0; return SANE_STATUS_INVAL; break; } } } s->xfer_position += xfer_len_line; xfer_len_out = xfer_len_line; if (xfer_len_out > maxlen) xfer_len_out = maxlen; memcpy(buf, s->line_buf, xfer_len_out); if (xfer_len_out < xfer_len_line) s->i_line_buf = xfer_len_out; /* data left in the line buffer, read out next time */ *len = xfer_len_out; return SANE_STATUS_GOOD; } void sane_cancel(SANE_Handle h) { cs3_t *s = (cs3_t *) h; DBG(10, "%s, scanning = %d.\n", __func__, s->scanning); if (s->scanning) { cs3_init_buffer(s); cs3_parse_cmd(s, "c0 00 00 00 00 00"); cs3_issue_cmd(s); } s->scanning = SANE_FALSE; } SANE_Status sane_set_io_mode(SANE_Handle h, SANE_Bool m) { cs3_t *s = (cs3_t *) h; DBG(10, "%s\n", __func__); if (!s->scanning) return SANE_STATUS_INVAL; if (m == SANE_FALSE) return SANE_STATUS_GOOD; else return SANE_STATUS_UNSUPPORTED; } SANE_Status sane_get_select_fd(SANE_Handle h, SANE_Int * fd) { cs3_t *s = (cs3_t *) h; DBG(10, "%s\n", __func__); fd = fd; /* to shut up compiler */ s = s; /* to shut up compiler */ return SANE_STATUS_UNSUPPORTED; } /* ========================================================================= */ /* private functions */ static void cs3_trim(char *s) { int i, l = strlen(s); for (i = l - 1; i > 0; i--) { if (s[i] == ' ') s[i] = '\0'; else break; } } static SANE_Status cs3_open(const char *device, cs3_interface_t interface, cs3_t ** sp) { SANE_Status status; cs3_t *s; char *prefix = NULL, *line; int i; int alloc_failed = 0; SANE_Device **device_list_new; DBG(6, "%s, device = %s, interface = %i\n", __func__, device, interface); if (!strncmp(device, "auto", 5)) { try_interface = CS3_INTERFACE_SCSI; sanei_config_attach_matching_devices("scsi Nikon *", cs3_attach); try_interface = CS3_INTERFACE_USB; sanei_usb_attach_matching_devices("usb 0x04b0 0x4000", cs3_attach); sanei_usb_attach_matching_devices("usb 0x04b0 0x4001", cs3_attach); sanei_usb_attach_matching_devices("usb 0x04b0 0x4002", cs3_attach); return SANE_STATUS_GOOD; } if ((s = (cs3_t *) cs3_xmalloc(sizeof(cs3_t))) == NULL) return SANE_STATUS_NO_MEM; memset(s, 0, sizeof(cs3_t)); /* fill magic bits */ s->magic = SANE_COOKIE; s->cookie_ptr = &s->cookie; s->cookie.version = 0x01; s->cookie.vendor = s->vendor_string; s->cookie.model = s->product_string; s->cookie.revision = s->revision_string; s->send_buf = s->recv_buf = NULL; s->send_buf_size = s->recv_buf_size = 0; switch (interface) { case CS3_INTERFACE_UNKNOWN: for (i = 0; i < 2; i++) { switch (i) { case 1: prefix = "usb:"; try_interface = CS3_INTERFACE_USB; break; default: prefix = "scsi:"; try_interface = CS3_INTERFACE_SCSI; break; } if (!strncmp(device, prefix, strlen(prefix))) { const void *p = device + strlen(prefix); cs3_xfree(s); return cs3_open(p, try_interface, sp); } } cs3_xfree(s); return SANE_STATUS_INVAL; break; case CS3_INTERFACE_SCSI: s->interface = CS3_INTERFACE_SCSI; DBG(6, "%s, trying to open %s, assuming SCSI or SBP2 interface\n", __func__, device); status = sanei_scsi_open(device, &s->fd, cs3_scsi_sense_handler, s); if (status != SANE_STATUS_GOOD) { DBG(6, " ...failed: %s.\n", sane_strstatus(status)); cs3_xfree(s); return status; } break; case CS3_INTERFACE_USB: s->interface = CS3_INTERFACE_USB; DBG(6, "%s, trying to open %s, assuming USB interface\n", __func__, device); status = sanei_usb_open(device, &s->fd); if (status != SANE_STATUS_GOOD) { DBG(6, " ...failed: %s.\n", sane_strstatus(status)); cs3_xfree(s); return status; } break; } open_devices++; DBG(6, "%s, trying to identify device.\n", __func__); /* identify scanner */ status = cs3_page_inquiry(s, -1); if (status != SANE_STATUS_GOOD) { cs3_close(s); return status; } strncpy(s->vendor_string, (char *) s->recv_buf + 8, 8); s->vendor_string[8] = '\0'; strncpy(s->product_string, (char *) s->recv_buf + 16, 16); s->product_string[16] = '\0'; strncpy(s->revision_string, (char *) s->recv_buf + 32, 4); s->revision_string[4] = '\0'; DBG(10, "%s, vendor = '%s', product = '%s', revision = '%s'.\n", __func__, s->vendor_string, s->product_string, s->revision_string); if (!strncmp(s->product_string, "COOLSCANIII ", 16)) s->type = CS3_TYPE_LS30; else if (!strncmp(s->product_string, "LS-40 ED ", 16)) s->type = CS3_TYPE_LS40; else if (!strncmp(s->product_string, "LS-50 ED ", 16)) s->type = CS3_TYPE_LS50; else if (!strncmp(s->product_string, "LS-2000 ", 16)) s->type = CS3_TYPE_LS2000; else if (!strncmp(s->product_string, "LS-4000 ED ", 16)) s->type = CS3_TYPE_LS4000; else if (!strncmp(s->product_string, "LS-5000 ED ", 16)) s->type = CS3_TYPE_LS5000; else if (!strncmp(s->product_string, "LS-8000 ED ", 16)) s->type = CS3_TYPE_LS8000; if (s->type != CS3_TYPE_UNKOWN) DBG(10, "%s, device identified as coolscan3 type #%i.\n", __func__, s->type); else { DBG(10, "%s, device not identified.\n", __func__); cs3_close(s); return SANE_STATUS_UNSUPPORTED; } cs3_trim(s->vendor_string); cs3_trim(s->product_string); cs3_trim(s->revision_string); if (sp) *sp = s; else { device_list_new = (SANE_Device **) cs3_xrealloc(device_list, (n_device_list + 2) * sizeof(SANE_Device *)); if (!device_list_new) return SANE_STATUS_NO_MEM; device_list = device_list_new; device_list[n_device_list] = (SANE_Device *) cs3_xmalloc(sizeof(SANE_Device)); if (!device_list[n_device_list]) return SANE_STATUS_NO_MEM; switch (interface) { case CS3_INTERFACE_UNKNOWN: DBG(1, "BUG: cs3_open(): unknown interface.\n"); cs3_close(s); return SANE_STATUS_UNSUPPORTED; break; case CS3_INTERFACE_SCSI: prefix = "scsi:"; break; case CS3_INTERFACE_USB: prefix = "usb:"; break; } line = (char *) cs3_xmalloc(strlen(device) + strlen(prefix) + 1); if (!line) alloc_failed = 1; else { strcpy(line, prefix); strcat(line, device); device_list[n_device_list]->name = line; } line = (char *) cs3_xmalloc(strlen(s->vendor_string) + 1); if (!line) alloc_failed = 1; else { strcpy(line, s->vendor_string); device_list[n_device_list]->vendor = line; } line = (char *) cs3_xmalloc(strlen(s->product_string) + 1); if (!line) alloc_failed = 1; else { strcpy(line, s->product_string); device_list[n_device_list]->model = line; } device_list[n_device_list]->type = "film scanner"; if (alloc_failed) { 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++; device_list[n_device_list] = NULL; cs3_close(s); } return SANE_STATUS_GOOD; } void cs3_close(cs3_t * s) { cs3_xfree(s->lut_r); cs3_xfree(s->lut_g); cs3_xfree(s->lut_b); cs3_xfree(s->lut_neutral); cs3_xfree(s->line_buf); switch (s->interface) { case CS3_INTERFACE_UNKNOWN: DBG(0, "BUG: %s: Unknown interface number.\n", __func__); break; case CS3_INTERFACE_SCSI: sanei_scsi_close(s->fd); open_devices--; break; case CS3_INTERFACE_USB: sanei_usb_close(s->fd); open_devices--; break; } cs3_xfree(s); } static SANE_Status cs3_attach(const char *dev) { SANE_Status status; if (try_interface == CS3_INTERFACE_UNKNOWN) return SANE_STATUS_UNSUPPORTED; status = cs3_open(dev, try_interface, NULL); return status; } static SANE_Status cs3_scsi_sense_handler(int fd, u_char * sense_buffer, void *arg) { cs3_t *s = (cs3_t *) arg; fd = fd; /* to shut up compiler */ /* sort this out ! XXX */ s->sense_key = sense_buffer[2] & 0x0f; s->sense_asc = sense_buffer[12]; s->sense_ascq = sense_buffer[13]; s->sense_info = sense_buffer[3]; return cs3_parse_sense_data(s); } static SANE_Status cs3_parse_sense_data(cs3_t * s) { SANE_Status status = SANE_STATUS_GOOD; s->sense_code = (s->sense_key << 24) + (s->sense_asc << 16) + (s->sense_ascq << 8) + s->sense_info; if (s->sense_key) DBG(14, "sense code: %02lx-%02lx-%02lx-%02lx\n", s->sense_key, s->sense_asc, s->sense_ascq, s->sense_info); switch (s->sense_key) { case 0x00: s->status = CS3_STATUS_READY; break; case 0x02: switch (s->sense_asc) { case 0x04: DBG(15, " processing\n"); s->status = CS3_STATUS_PROCESSING; break; case 0x3a: DBG(15, " no docs\n"); s->status = CS3_STATUS_NO_DOCS; break; default: DBG(15, " default\n"); s->status = CS3_STATUS_ERROR; status = SANE_STATUS_IO_ERROR; break; } break; case 0x09: if ((s->sense_code == 0x09800600) || (s->sense_code == 0x09800601)) s->status = CS3_STATUS_REISSUE; break; default: s->status = CS3_STATUS_ERROR; status = SANE_STATUS_IO_ERROR; break; } return status; } static void cs3_init_buffer(cs3_t * s) { s->n_cmd = 0; s->n_send = 0; s->n_recv = 0; } static SANE_Status cs3_pack_byte(cs3_t * s, SANE_Byte byte) { while (s->send_buf_size <= s->n_send) { s->send_buf_size += 16; s->send_buf = (SANE_Byte *) cs3_xrealloc(s->send_buf, s->send_buf_size); if (!s->send_buf) return SANE_STATUS_NO_MEM; } s->send_buf[s->n_send++] = byte; return SANE_STATUS_GOOD; } static void cs3_pack_long(cs3_t * s, unsigned long val) { cs3_pack_byte(s, (val >> 24) & 0xff); cs3_pack_byte(s, (val >> 16) & 0xff); cs3_pack_byte(s, (val >> 8) & 0xff); cs3_pack_byte(s, val & 0xff); } static void cs3_pack_word(cs3_t * s, unsigned long val) { cs3_pack_byte(s, (val >> 8) & 0xff); cs3_pack_byte(s, val & 0xff); } static SANE_Status cs3_parse_cmd(cs3_t * s, char *text) { size_t i, j; char c, h; SANE_Status status; for (i = 0; i < strlen(text); i += 2) if (text[i] == ' ') i--; /* a bit dirty... advance by -1+2=1 */ else { if ((!isxdigit(text[i])) || (!isxdigit(text[i + 1]))) DBG(1, "BUG: cs3_parse_cmd(): Parser got invalid character.\n"); c = 0; for (j = 0; j < 2; j++) { h = tolower(text[i + j]); if ((h >= 'a') && (h <= 'f')) c += 10 + h - 'a'; else c += h - '0'; if (j == 0) c <<= 4; } status = cs3_pack_byte(s, c); if (status != SANE_STATUS_GOOD) return status; } return SANE_STATUS_GOOD; } static SANE_Status cs3_grow_send_buffer(cs3_t * s) { if (s->n_send > s->send_buf_size) { s->send_buf_size = s->n_send; s->send_buf = (SANE_Byte *) cs3_xrealloc(s->send_buf, s->send_buf_size); if (!s->send_buf) return SANE_STATUS_NO_MEM; } return SANE_STATUS_GOOD; } static SANE_Status cs3_issue_cmd(cs3_t * s) { SANE_Status status = SANE_STATUS_INVAL; size_t n_data, n_status; static SANE_Byte status_buf[8]; int status_only = 0; DBG(20, "cs3_issue_cmd(): opcode = 0x%02x, n_send = %lu, n_recv = %lu.\n", s->send_buf[0], (unsigned long) s->n_send, (unsigned long) s->n_recv); s->status = CS3_STATUS_READY; if (!s->n_cmd) switch (s->send_buf[0]) { case 0x00: case 0x12: case 0x15: case 0x16: case 0x17: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0xc0: case 0xc1: s->n_cmd = 6; break; case 0x24: case 0x25: case 0x28: case 0x2a: case 0xe0: case 0xe1: s->n_cmd = 10; break; default: DBG(1, "BUG: cs3_issue_cmd(): Unknown command opcode 0x%02x.\n", s->send_buf[0]); break; } if (s->n_send < s->n_cmd) { DBG(1, "BUG: cs3_issue_cmd(): Negative number of data out bytes requested.\n"); return SANE_STATUS_INVAL; } n_data = s->n_send - s->n_cmd; if (s->n_recv > 0) { if (n_data > 0) { DBG(1, "BUG: cs3_issue_cmd(): Both data in and data out requested.\n"); return SANE_STATUS_INVAL; } else { n_data = s->n_recv; } } s->recv_buf = (SANE_Byte *) cs3_xrealloc(s->recv_buf, s->n_recv); if (!s->recv_buf) return SANE_STATUS_NO_MEM; switch (s->interface) { case CS3_INTERFACE_UNKNOWN: DBG(1, "BUG: cs3_issue_cmd(): Unknown or uninitialized interface number.\n"); break; case CS3_INTERFACE_SCSI: sanei_scsi_cmd2(s->fd, s->send_buf, s->n_cmd, s->send_buf + s->n_cmd, s->n_send - s->n_cmd, s->recv_buf, &s->n_recv); status = SANE_STATUS_GOOD; break; case CS3_INTERFACE_USB: status = sanei_usb_write_bulk(s->fd, s->send_buf, &s->n_cmd); if (status != SANE_STATUS_GOOD) { DBG(1, "Error: cs3_issue_cmd(): Could not write command.\n"); return SANE_STATUS_IO_ERROR; } switch (cs3_phase_check(s)) { case CS3_PHASE_OUT: if (s->n_send - s->n_cmd < n_data || !n_data) { DBG(4, "Error: cs3_issue_cmd(): Unexpected data out phase.\n"); return SANE_STATUS_IO_ERROR; } status = sanei_usb_write_bulk(s->fd, s->send_buf + s->n_cmd, &n_data); break; case CS3_PHASE_IN: if (s->n_recv < n_data || !n_data) { DBG(4, "Error: cs3_issue_cmd(): Unexpected data in phase.\n"); return SANE_STATUS_IO_ERROR; } status = sanei_usb_read_bulk(s->fd, s->recv_buf, &n_data); s->n_recv = n_data; break; case CS3_PHASE_NONE: DBG(4, "%s: No command received!\n", __func__); return SANE_STATUS_IO_ERROR; default: if (n_data) { DBG(4, "%s: Unexpected non-data phase, but n_data != 0 (%lu).\n", __func__, (u_long) n_data); status_only = 1; } break; } n_status = 8; status = sanei_usb_read_bulk(s->fd, status_buf, &n_status); if (n_status != 8) { DBG(4, "Error: cs3_issue_cmd(): Failed to read 8 status bytes from USB.\n"); return SANE_STATUS_IO_ERROR; } s->sense_key = status_buf[1] & 0x0f; s->sense_asc = status_buf[2] & 0xff; s->sense_ascq = status_buf[3] & 0xff; s->sense_info = status_buf[4] & 0xff; status = cs3_parse_sense_data(s); break; } if (status_only) return SANE_STATUS_IO_ERROR; else return status; } static cs3_phase_t cs3_phase_check(cs3_t * s) { static SANE_Byte phase_send_buf[1] = { 0xd0 }, phase_recv_buf[1]; SANE_Status status = 0; size_t n = 1; status = sanei_usb_write_bulk(s->fd, phase_send_buf, &n); status |= sanei_usb_read_bulk(s->fd, phase_recv_buf, &n); DBG(40, "%s: returned phase = 0x%02x.\n", __func__, phase_recv_buf[0]); if (status != SANE_STATUS_GOOD) return -1; else return phase_recv_buf[0]; } static SANE_Status cs3_scanner_ready(cs3_t * s, int flags) { SANE_Status status = SANE_STATUS_GOOD; int i = -1; unsigned long count = 0; int retry = 3; do { if (i >= 0) /* dirty !!! */ usleep(1000000); /* test unit ready */ cs3_init_buffer(s); for (i = 0; i < 6; i++) cs3_pack_byte(s, 0x00); status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) if (--retry < 0) return status; if (++count > 120) { /* 120s timeout */ DBG(4, "Error: %s: Timeout expired.\n", __func__); status = SANE_STATUS_IO_ERROR; break; } } while (s->status & ~flags); /* until all relevant bits are 0 */ return status; } static SANE_Status cs3_page_inquiry(cs3_t * s, int page) { SANE_Status status; size_t n; if (page >= 0) { cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); cs3_init_buffer(s); cs3_parse_cmd(s, "12 01"); cs3_pack_byte(s, page); cs3_parse_cmd(s, "00 04 00"); s->n_recv = 4; status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) { DBG(4, "Error: cs3_page_inquiry(): Inquiry of page size failed: %s.\n", sane_strstatus(status)); return status; } n = s->recv_buf[3] + 4; } else n = 36; cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); cs3_init_buffer(s); if (page >= 0) { cs3_parse_cmd(s, "12 01"); cs3_pack_byte(s, page); cs3_parse_cmd(s, "00"); } else cs3_parse_cmd(s, "12 00 00 00"); cs3_pack_byte(s, n); cs3_parse_cmd(s, "00"); s->n_recv = n; status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) { DBG(4, "Error: %s: inquiry of page failed: %s.\n", __func__, sane_strstatus(status)); return status; } return SANE_STATUS_GOOD; } static SANE_Status cs3_full_inquiry(cs3_t * s) { SANE_Status status; int pitch, pitch_max; cs3_pixel_t pixel; DBG(4, "%s\n", __func__); status = cs3_page_inquiry(s, 0xc1); if (status != SANE_STATUS_GOOD) return status; s->maxbits = s->recv_buf[82]; if (s->type == CS3_TYPE_LS30) /* must be overridden, LS-30 claims to have 12 bits */ s->maxbits = 10; s->n_lut = 1; s->n_lut <<= s->maxbits; s->lut_r = (cs3_pixel_t *) cs3_xrealloc(s->lut_r, s->n_lut * sizeof(cs3_pixel_t)); s->lut_g = (cs3_pixel_t *) cs3_xrealloc(s->lut_g, s->n_lut * sizeof(cs3_pixel_t)); s->lut_b = (cs3_pixel_t *) cs3_xrealloc(s->lut_b, s->n_lut * sizeof(cs3_pixel_t)); s->lut_neutral = (cs3_pixel_t *) cs3_xrealloc(s->lut_neutral, s->n_lut * sizeof(cs3_pixel_t)); if (!s->lut_r || !s->lut_g || !s->lut_b || !s->lut_neutral) { cs3_xfree(s->lut_r); cs3_xfree(s->lut_g); cs3_xfree(s->lut_b); cs3_xfree(s->lut_neutral); return SANE_STATUS_NO_MEM; } for (pixel = 0; pixel < s->n_lut; pixel++) { s->lut_r[pixel] = s->lut_g[pixel] = s->lut_b[pixel] = s->lut_neutral[pixel] = pixel; } s->resx_optical = 256 * s->recv_buf[18] + s->recv_buf[19]; s->resx_max = 256 * s->recv_buf[20] + s->recv_buf[21]; s->resx_min = 256 * s->recv_buf[22] + s->recv_buf[23]; s->boundaryx = 65536 * (256 * s->recv_buf[36] + s->recv_buf[37]) + 256 * s->recv_buf[38] + s->recv_buf[39]; s->resy_optical = 256 * s->recv_buf[40] + s->recv_buf[41]; s->resy_max = 256 * s->recv_buf[42] + s->recv_buf[43]; s->resy_min = 256 * s->recv_buf[44] + s->recv_buf[45]; s->boundaryy = 65536 * (256 * s->recv_buf[58] + s->recv_buf[59]) + 256 * s->recv_buf[60] + s->recv_buf[61]; s->focus_min = 256 * s->recv_buf[76] + s->recv_buf[77]; s->focus_max = 256 * s->recv_buf[78] + s->recv_buf[79]; s->n_frames = s->recv_buf[75]; s->frame_offset = s->resy_max * 1.5 + 1; /* works for LS-30, maybe not for others */ /* generate resolution list for x */ s->resx_n_list = pitch_max = floor(s->resx_max / (double) s->resx_min); s->resx_list = (unsigned int *) cs3_xrealloc(s->resx_list, pitch_max * sizeof(unsigned int)); for (pitch = 1; pitch <= pitch_max; pitch++) s->resx_list[pitch - 1] = s->resx_max / pitch; /* generate resolution list for y */ s->resy_n_list = pitch_max = floor(s->resy_max / (double) s->resy_min); s->resy_list = (unsigned int *) cs3_xrealloc(s->resy_list, pitch_max * sizeof(unsigned int)); for (pitch = 1; pitch <= pitch_max; pitch++) s->resy_list[pitch - 1] = s->resy_max / pitch; s->unit_dpi = s->resx_max; s->unit_mm = 25.4 / s->unit_dpi; DBG(4, " maximum depth: %d\n", s->maxbits); DBG(4, " focus: %d/%d\n", s->focus_min, s->focus_max); DBG(4, " resolution (x): %d (%d-%d)\n", s->resx_optical, s->resx_min, s->resx_max); DBG(4, " resolution (y): %d (%d-%d)\n", s->resy_optical, s->resy_min, s->resy_max); DBG(4, " frames: %d\n", s->n_frames); DBG(4, " frame offset: %ld\n", s->frame_offset); return SANE_STATUS_GOOD; } static SANE_Status cs3_execute(cs3_t * s) { DBG(16, "%s\n", __func__); cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); cs3_init_buffer(s); cs3_parse_cmd(s, "c1 00 00 00 00 00"); return cs3_issue_cmd(s); } static SANE_Status cs3_issue_and_execute(cs3_t * s) { SANE_Status status; DBG(10, "%s, opcode = %02x\n", __func__, s->send_buf[0]); status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) return status; return cs3_execute(s); } static SANE_Status cs3_mode_select(cs3_t * s) { DBG(4, "%s\n", __func__); cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); cs3_init_buffer(s); cs3_parse_cmd(s, "15 10 00 00 14 00 00 00 00 08 00 00 00 00 00 00 00 01 03 06 00 00"); cs3_pack_word(s, s->unit_dpi); cs3_parse_cmd(s, "00 00"); return cs3_issue_cmd(s); } static SANE_Status cs3_load(cs3_t * s) { SANE_Status status; DBG(6, "%s\n", __func__); cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); cs3_init_buffer(s); cs3_parse_cmd(s, "e0 00 d1 00 00 00 00 00 0d 00"); s->n_send += 13; status = cs3_grow_send_buffer(s); if (status != SANE_STATUS_GOOD) return status; return cs3_issue_and_execute(s); } static SANE_Status cs3_eject(cs3_t * s) { SANE_Status status; cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); cs3_init_buffer(s); cs3_parse_cmd(s, "e0 00 d0 00 00 00 00 00 0d 00"); s->n_send += 13; status = cs3_grow_send_buffer(s); if (status != SANE_STATUS_GOOD) return status; return cs3_issue_and_execute(s); } static SANE_Status cs3_reset(cs3_t * s) { SANE_Status status; cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); cs3_init_buffer(s); cs3_parse_cmd(s, "e0 00 80 00 00 00 00 00 0d 00"); s->n_send += 13; status = cs3_grow_send_buffer(s); if (status != SANE_STATUS_GOOD) return status; return cs3_issue_and_execute(s); } static SANE_Status cs3_reserve_unit(cs3_t * s) { DBG(10, "%s\n", __func__); cs3_init_buffer(s); cs3_parse_cmd(s, "16 00 00 00 00 00"); return cs3_issue_cmd(s); } static SANE_Status cs3_release_unit(cs3_t * s) { DBG(10, "%s\n", __func__); cs3_init_buffer(s); cs3_parse_cmd(s, "17 00 00 00 00 00"); return cs3_issue_cmd(s); } static SANE_Status cs3_set_focus(cs3_t * s) { DBG(6, "%s: setting focus to %d\n", __func__, s->focus); cs3_scanner_ready(s, CS3_STATUS_READY); cs3_init_buffer(s); cs3_parse_cmd(s, "e0 00 c1 00 00 00 00 00 09 00 00"); cs3_pack_long(s, s->focus); cs3_parse_cmd(s, "00 00 00 00"); return cs3_issue_and_execute(s); } static SANE_Status cs3_read_focus(cs3_t * s) { SANE_Status status; cs3_scanner_ready(s, CS3_STATUS_READY); cs3_init_buffer(s); cs3_parse_cmd(s, "e1 00 c1 00 00 00 00 00 0d 00"); s->n_recv = 13; status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) return status; s->focus = 65536 * (256 * s->recv_buf[1] + s->recv_buf[2]) + 256 * s->recv_buf[3] + s->recv_buf[4]; DBG(4, "%s: focus at %d\n", __func__, s->focus); return status; } static SANE_Status cs3_autofocus(cs3_t * s) { SANE_Status status; DBG(6, "%s: focusing at %ld,%ld\n", __func__, s->real_focusx, s->real_focusy); cs3_convert_options(s); status = cs3_read_focus(s); if (status != SANE_STATUS_GOOD) return status; /* set parameter, autofocus */ cs3_scanner_ready(s, CS3_STATUS_READY); cs3_init_buffer(s); cs3_parse_cmd(s, "e0 00 a0 00 00 00 00 00 09 00 00"); cs3_pack_long(s, s->real_focusx); cs3_pack_long(s, s->real_focusy); /*cs3_parse_cmd(s, "00 00 00 00"); */ status = cs3_issue_and_execute(s); if (status != SANE_STATUS_GOOD) return status; return cs3_read_focus(s); } static SANE_Status cs3_autoexposure(cs3_t * s, int wb) { SANE_Status status; DBG(6, "%s, wb = %d\n", __func__, wb); cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); status = cs3_scan(s, wb ? CS3_SCAN_AE_WB : CS3_SCAN_AE); if (status != SANE_STATUS_GOOD) return status; status = cs3_get_exposure(s); if (status != SANE_STATUS_GOOD) return status; s->exposure = 1.; s->exposure_r = s->real_exposure[1] / 100.; s->exposure_g = s->real_exposure[2] / 100.; s->exposure_b = s->real_exposure[3] / 100.; return status; } static SANE_Status cs3_get_exposure(cs3_t * s) { SANE_Status status; int i_color, colors = s->n_colors; DBG(6, "%s\n", __func__); if ((s->type == CS3_TYPE_LS50) || (s->type == CS3_TYPE_LS5000)) colors = 3; cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); /* GET WINDOW */ for (i_color = 0; i_color < colors; i_color++) { /* XXXXXXXXXXXXX CCCCCCCCCCCCC */ cs3_init_buffer(s); cs3_parse_cmd(s, "25 01 00 00 00"); cs3_pack_byte(s, cs3_colors[i_color]); cs3_parse_cmd(s, "00 00 3a 00"); s->n_recv = 58; status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) return status; s->real_exposure[cs3_colors[i_color]] = 65536 * (256 * s->recv_buf[54] + s->recv_buf[55]) + 256 * s->recv_buf[56] + s->recv_buf[57]; DBG(6, "%s, exposure for color %i: %li * 10ns\n", __func__, cs3_colors[i_color], s->real_exposure[cs3_colors[i_color]]); DBG(6, "%02x %02x %02x %02x\n", s->recv_buf[48], s->recv_buf[49], s->recv_buf[50], s->recv_buf[51]); } return SANE_STATUS_GOOD; } static SANE_Status cs3_convert_options(cs3_t * s) { int i_color; unsigned long xmin, xmax, ymin, ymax; DBG(4, "%s\n", __func__); s->real_depth = (s->preview ? 8 : s->depth); s->bytes_per_pixel = (s->real_depth > 8 ? 2 : 1); s->shift_bits = 8 * s->bytes_per_pixel - s->real_depth; DBG(12, " depth = %d, bpp = %d, shift = %d\n", s->real_depth, s->bytes_per_pixel, s->shift_bits); if (s->preview) { s->real_resx = s->res_preview; s->real_resy = s->res_preview; } else if (s->res_independent) { s->real_resx = s->resx; s->real_resy = s->resy; } else { s->real_resx = s->res; s->real_resy = s->res; } s->real_pitchx = s->resx_max / s->real_resx; s->real_pitchy = s->resy_max / s->real_resy; s->real_resx = s->resx_max / s->real_pitchx; s->real_resy = s->resy_max / s->real_pitchy; DBG(12, " resx = %d, resy = %d, pitchx = %d, pitchy = %d\n", s->real_resx, s->real_resy, s->real_pitchx, s->real_pitchy); /* The prefix "real_" refers to data in device units (1/maxdpi), * "logical_" refers to resolution-dependent data. */ if (s->xmin < s->xmax) { xmin = s->xmin; xmax = s->xmax; } else { xmin = s->xmax; xmax = s->xmin; } if (s->ymin < s->ymax) { ymin = s->ymin; ymax = s->ymax; } else { ymin = s->ymax; ymax = s->ymin; } DBG(12, " xmin = %ld, xmax = %ld\n", xmin, xmax); DBG(12, " ymin = %ld, ymax = %ld\n", ymin, ymax); s->real_xoffset = xmin; s->real_yoffset = ymin + (s->i_frame - 1) * s->frame_offset + s->subframe / s->unit_mm; DBG(12, " xoffset = %ld, yoffset = %ld\n", s->real_xoffset, s->real_yoffset); s->logical_width = (xmax - xmin + 1) / s->real_pitchx; /* XXX use mm units */ s->logical_height = (ymax - ymin + 1) / s->real_pitchy; s->real_width = s->logical_width * s->real_pitchx; s->real_height = s->logical_height * s->real_pitchy; DBG(12, " lw = %ld, lh = %ld, rw = %ld, rh = %ld\n", s->logical_width, s->logical_height, s->real_width, s->real_height); s->odd_padding = 0; if ((s->bytes_per_pixel == 1) && (s->logical_width & 0x01) && (s->type != CS3_TYPE_LS30) && (s->type != CS3_TYPE_LS2000)) s->odd_padding = 1; if (s->focus_on_centre) { s->real_focusx = s->real_xoffset + s->real_width / 2; s->real_focusy = s->real_yoffset + s->real_height / 2; } else { s->real_focusx = s->focusx; s->real_focusy = s->focusy + (s->i_frame - 1) * s->frame_offset + s->subframe / s->unit_mm; } DBG(12, " focusx = %ld, focusy = %ld\n", s->real_focusx, s->real_focusy); s->real_exposure[1] = s->exposure * s->exposure_r * 100.; s->real_exposure[2] = s->exposure * s->exposure_g * 100.; s->real_exposure[3] = s->exposure * s->exposure_b * 100.; /* XXX IR? */ for (i_color = 0; i_color < 3; i_color++) if (s->real_exposure[cs3_colors[i_color]] < 1) s->real_exposure[cs3_colors[i_color]] = 1; s->n_colors = 3; /* XXXXXXXXXXXXXX CCCCCCCCCCCCCC */ if (s->infrared) s->n_colors = 4; s->xfer_bytes_total = s->bytes_per_pixel * s->n_colors * s->logical_width * s->logical_height; if (s->preview) s->infrared = SANE_FALSE; return SANE_STATUS_GOOD; } static SANE_Status cs3_set_boundary(cs3_t * s) { SANE_Status status; int i_boundary; /* Ariel - Check this function */ cs3_scanner_ready(s, CS3_STATUS_READY); cs3_init_buffer(s); cs3_parse_cmd(s, "2a 00 88 00 00 03"); cs3_pack_byte(s, ((4 + s->n_frames * 16) >> 16) & 0xff); cs3_pack_byte(s, ((4 + s->n_frames * 16) >> 8) & 0xff); cs3_pack_byte(s, (4 + s->n_frames * 16) & 0xff); cs3_parse_cmd(s, "00"); cs3_pack_byte(s, ((4 + s->n_frames * 16) >> 8) & 0xff); cs3_pack_byte(s, (4 + s->n_frames * 16) & 0xff); cs3_pack_byte(s, s->n_frames); cs3_pack_byte(s, s->n_frames); for (i_boundary = 0; i_boundary < s->n_frames; i_boundary++) { unsigned long lvalue = s->frame_offset * i_boundary + s->subframe / s->unit_mm; cs3_pack_long(s, lvalue); cs3_pack_long(s, 0); lvalue = s->frame_offset * i_boundary + s->subframe / s->unit_mm + s->frame_offset - 1; cs3_pack_long(s, lvalue); cs3_pack_long(s, s->boundaryx - 1); } status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) return status; return SANE_STATUS_GOOD; } static SANE_Status cs3_send_lut(cs3_t * s) { int color; SANE_Status status; cs3_pixel_t *lut, pixel; DBG(6, "%s\n", __func__); for (color = 0; color < s->n_colors; color++) { /*cs3_scanner_ready(s, CS3_STATUS_READY); */ switch (color) { case 0: lut = s->lut_r; break; case 1: lut = s->lut_g; break; case 2: lut = s->lut_b; break; case 3: lut = s->lut_neutral; break; default: DBG(1, "BUG: %s: Unknown color number for LUT download.\n", __func__); return SANE_STATUS_INVAL; break; } cs3_init_buffer(s); cs3_parse_cmd(s, "2a 00 03 00"); cs3_pack_byte(s, cs3_colors[color]); cs3_pack_byte(s, 2 - 1); /* XXX number of bytes per data point - 1 */ cs3_pack_byte(s, ((2 * s->n_lut) >> 16) & 0xff); /* XXX 2 bytes per point */ cs3_pack_byte(s, ((2 * s->n_lut) >> 8) & 0xff); /* XXX 2 bytes per point */ cs3_pack_byte(s, (2 * s->n_lut) & 0xff); /* XXX 2 bytes per point */ cs3_pack_byte(s, 0x00); for (pixel = 0; pixel < s->n_lut; pixel++) { /* XXX 2 bytes per point */ cs3_pack_word(s, lut[pixel]); } status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) return status; } return status; } static SANE_Status cs3_set_window(cs3_t * s, cs3_scan_t type) { int color; SANE_Status status = SANE_STATUS_INVAL; /* SET WINDOW */ for (color = 0; color < s->n_colors; color++) { DBG(8, "%s: color %d\n", __func__, cs3_colors[color]); cs3_scanner_ready(s, CS3_STATUS_READY); cs3_init_buffer(s); if ((s->type == CS3_TYPE_LS40) || (s->type == CS3_TYPE_LS4000) || (s->type == CS3_TYPE_LS50) || (s->type == CS3_TYPE_LS5000)) cs3_parse_cmd(s, "24 00 00 00 00 00 00 00 3a 80"); else cs3_parse_cmd(s, "24 00 00 00 00 00 00 00 3a 00"); cs3_parse_cmd(s, "00 00 00 00 00 00 00 32"); cs3_pack_byte(s, cs3_colors[color]); cs3_pack_byte(s, 0x00); cs3_pack_word(s, s->real_resx); cs3_pack_word(s, s->real_resy); cs3_pack_long(s, s->real_xoffset); cs3_pack_long(s, s->real_yoffset); cs3_pack_long(s, s->real_width); cs3_pack_long(s, s->real_height); cs3_pack_byte(s, 0x00); /* brightness, etc. */ cs3_pack_byte(s, 0x00); cs3_pack_byte(s, 0x00); cs3_pack_byte(s, 0x05); /* image composition CCCCCCC */ cs3_pack_byte(s, s->real_depth); /* pixel composition */ cs3_parse_cmd(s, "00 00 00 00 00 00 00 00 00 00 00 00 00"); cs3_pack_byte(s, ((s->samples_per_scan - 1) << 4) | 0x00); /* multiread, ordering */ cs3_pack_byte(s, 0x80 | (s->negative ? 0 : 1)); /* averaging, pos/neg */ switch (type) { /* scanning kind */ case CS3_SCAN_NORMAL: cs3_pack_byte(s, 0x01); break; case CS3_SCAN_AE: cs3_pack_byte(s, 0x20); break; case CS3_SCAN_AE_WB: cs3_pack_byte(s, 0x40); break; default: DBG(1, "BUG: cs3_scan(): Unknown scanning type.\n"); return SANE_STATUS_INVAL; } if (s->samples_per_scan == 1) cs3_pack_byte(s, 0x02); /* scanning mode single */ else cs3_pack_byte(s, 0x10); /* scanning mode multi */ cs3_pack_byte(s, 0x02); /* color interleaving */ cs3_pack_byte(s, 0xff); /* (ae) */ if (color == 3) /* infrared */ cs3_parse_cmd(s, "00 00 00 00"); /* automatic */ else { DBG(4, "%s: exposure = %ld * 10ns\n", __func__, s->real_exposure[cs3_colors[color]]); cs3_pack_long(s, s->real_exposure[cs3_colors[color]]); } status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) return status; } return status; } static SANE_Status cs3_scan(cs3_t * s, cs3_scan_t type) { SANE_Status status; s->block_padding = 0; DBG(6, "%s, type = %d, colors = %d\n", __func__, type, s->n_colors); switch (type) { case CS3_SCAN_NORMAL: DBG(16, "%s: normal scan\n", __func__); break; case CS3_SCAN_AE: DBG(16, "%s: ae scan\n", __func__); break; case CS3_SCAN_AE_WB: DBG(16, "%s: ae wb scan\n", __func__); break; } /* wait for device to be ready with document, and set device unit */ status = cs3_scanner_ready(s, CS3_STATUS_NO_DOCS); if (status != SANE_STATUS_GOOD) return status; if (s->status & CS3_STATUS_NO_DOCS) return SANE_STATUS_NO_DOCS; status = cs3_convert_options(s); if (status != SANE_STATUS_GOOD) return status; status = cs3_set_boundary(s); if (status != SANE_STATUS_GOOD) return status; cs3_set_focus(s); cs3_scanner_ready(s, CS3_STATUS_READY); if (type == CS3_SCAN_NORMAL) cs3_send_lut(s); status = cs3_set_window(s, type); if (status != SANE_STATUS_GOOD) return status; status = cs3_get_exposure(s); if (status != SANE_STATUS_GOOD) return status; /* cs3_scanner_ready(s, CS3_STATUS_READY); */ cs3_init_buffer(s); switch (s->n_colors) { case 3: cs3_parse_cmd(s, "1b 00 00 00 03 00 01 02 03"); break; case 4: cs3_parse_cmd(s, "1b 00 00 00 04 00 01 02 03 09"); break; default: DBG(0, "BUG: %s: Unknown number of input colors.\n", __func__); break; } status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) { DBG(6, "scan setup failed\n"); return status; } if (s->status == CS3_STATUS_REISSUE) { status = cs3_issue_cmd(s); if (status != SANE_STATUS_GOOD) return status; } return SANE_STATUS_GOOD; } static void * cs3_xmalloc(size_t size) { register void *value = malloc(size); if (value == NULL) { DBG(0, "error: %s: failed to malloc() %lu bytes.\n", __func__, (unsigned long) size); } return value; } static void * cs3_xrealloc(void *p, size_t size) { register void *value; if (!size) return p; value = realloc(p, size); if (value == NULL) { DBG(0, "error: %s: failed to realloc() %lu bytes.\n", __func__, (unsigned long) size); } return value; } static void cs3_xfree(void *p) { if (p) free(p); } sane-backends-1.0.29/backend/u12-image.c0000666000000000000000000006414713615534521014437 00000000000000/* @file u12_image.c * @brief functions to convert scanner data into image data * * based on sources acquired from Plustek Inc. * Copyright (c) 2003-2004 Gerhard Jaeger * * History: * - 0.01 - initial version * - 0.02 - fixed fnColor42() to return 16bit values instead of * only 12bit (this is the maximum the scanner can) * - added scaling function u12image_ScaleX() * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ /*************************** local vars **************************************/ static u_short wPreviewScanned = 0; static ExpXStepDef negScan[5] = { {128, 8}, {96, 12}, {96, 24}, {96, 48}, {96, 96} }; static ExpXStepDef posScan[5] = { {128, 8}, {96, 12}, {96, 24}, {96, 48}, {96, 96} }; static ExpXStepDef nmlScan[5] = { {160, 10}, {96, 12}, {96, 24}, {96, 48}, {96, 96}, }; /*************************** local functions *********************************/ /** */ static SANE_Bool fnReadToDriver( U12_Device *dev ) { dev->regs.RD_ModeControl = _ModeFifoBSel; u12io_ReadMonoData( dev, dev->scan.BufPut.blue.bp, dev->DataInf.dwAsicBytesPerPlane ); dev->regs.RD_ModeControl = _ModeFifoGSel; u12io_ReadMonoData( dev, dev->scan.BufPut.green.bp, dev->DataInf.dwAsicBytesPerPlane ); if( dev->scan.gd_gk.wGreenKeep ) dev->scan.gd_gk.wGreenKeep--; else { dev->scan.BufPut.green.bp += dev->DataInf.dwAsicBytesPerPlane; if( dev->scan.BufPut.green.bp >= dev->scan.BufEnd.green.bp ) dev->scan.BufPut.green.bp = dev->scan.BufBegin.green.bp; } dev->regs.RD_ModeControl = _ModeFifoRSel; u12io_ReadMonoData( dev, dev->scan.BufPut.red.bp, dev->DataInf.dwAsicBytesPerPlane ); dev->scan.BufPut.red.bp += dev->DataInf.dwAsicBytesPerPlane; if( dev->scan.BufPut.red.bp >= dev->scan.BufEnd.red.bp ) dev->scan.BufPut.red.bp = dev->scan.BufBegin.red.bp; if( dev->scan.bd_rk.wRedKeep ) { dev->scan.bd_rk.wRedKeep--; return SANE_FALSE; } else { dev->scan.BufData.green.bp = dev->scan.BufGet.green.bp; dev->scan.BufData.red.bp = dev->scan.BufGet.red.bp; dev->scan.BufData.blue.bp = dev->scan.BufGet.blue.bp; dev->scan.BufGet.red.bp += dev->DataInf.dwAsicBytesPerPlane; dev->scan.BufGet.green.bp += dev->DataInf.dwAsicBytesPerPlane; if( dev->scan.BufGet.red.bp >= dev->scan.BufEnd.red.bp ) dev->scan.BufGet.red.bp = dev->scan.BufBegin.red.bp; if( dev->scan.BufGet.green.bp >= dev->scan.BufEnd.green.bp ) dev->scan.BufGet.green.bp = dev->scan.BufBegin.green.bp; return SANE_TRUE; } } /** */ static SANE_Bool fnReadOutScanner( U12_Device *dev ) { if( dev->scan.bd_rk.wBlueDiscard ) { dev->scan.bd_rk.wBlueDiscard--; dev->regs.RD_ModeControl = _ModeFifoBSel; u12io_ReadMonoData( dev, dev->bufs.b1.pReadBuf, dev->DataInf.dwAsicBytesPerPlane ); if( dev->scan.gd_gk.wGreenDiscard ) { dev->scan.gd_gk.wGreenDiscard--; dev->regs.RD_ModeControl = _ModeFifoGSel; u12io_ReadMonoData( dev, dev->bufs.b1.pReadBuf, dev->DataInf.dwAsicBytesPerPlane ); } return SANE_FALSE; } else { u12io_ReadColorData( dev, dev->bufs.b1.pReadBuf, dev->DataInf.dwAsicBytesPerPlane ); return SANE_TRUE; } } /** some sampling functions */ static SANE_Bool fnEveryLine( U12_Device *dev ) { _VAR_NOT_USED( dev ); return SANE_TRUE; } static SANE_Bool fnSampleLines( U12_Device *dev ) { dev->DataInf.wYSum += dev->DataInf.xyAppDpi.y; if( dev->DataInf.wYSum >= dev->DataInf.xyPhyDpi.y ) { dev->DataInf.wYSum -= dev->DataInf.xyPhyDpi.y; return SANE_TRUE; } return SANE_FALSE; } static SANE_Bool fnSamplePreview( U12_Device *dev ) { dev->DataInf.wYSum += wPreviewScanned; if( dev->DataInf.wYSum >= 150 ) { dev->DataInf.wYSum -= 150; return SANE_TRUE; } return SANE_FALSE; } /** this function is used when * - the data type is B/W or GrayScale. * - the required horizontal resolution doesn't exceed the optic spec. * - the required vertical resolution exceeds the optic spec. */ static void fnDataDirect( U12_Device *dev, void *src, void *dest, u_long len ) { _VAR_NOT_USED( dev ); memcpy( dest, src, len ); } /** merges the color planes to pixels style without enlarge operation. */ static void fnColorDirect( U12_Device *dev, void *pb, void *img, u_long len ) { SANE_Byte *src; RGBByteDef *dest; src = (SANE_Byte*)img; dest = (RGBByteDef*)pb; for ( len = dev->DataInf.dwAsicPixelsPerPlane; len; len--, src++, dest++) { dest->Red = *src; dest->Green = src[dev->DataInf.dwAsicPixelsPerPlane]; dest->Blue = src[dev->DataInf.dwAsicPixelsPerPlane*2]; } } /** merges the color planes to pixels style without enlarge operation. * The scanner returns the pixel data in Motorola-Format, so we have to swap * (at least on x86) */ static void fnColor42( U12_Device *dev, void *pb, void *img, u_long len ) { u_short *src; RGBUShortDef *dest; register u_long i; _VAR_NOT_USED( len ); src = (u_short*)img; dest = (RGBUShortDef*)pb; for ( i = dev->DataInf.dwAsicPixelsPerPlane; i; i--, src++, dest++) { dest->Red = (*src) << 4; dest->Green = (src[dev->DataInf.dwAsicPixelsPerPlane]) << 4; dest->Blue = (src[dev->DataInf.dwAsicPixelsPerPlane * 2]) << 4; } } /** */ static void u12image_SetupScanStateVariables( U12_Device *dev, u_long index ) { DataType var; DBG( _DBG_INFO, "u12image_SetupScanStateVariables(%lu)\n", index ); dev->scan.dpiIdx = index; if(!(dev->DataInf.dwScanFlag & _SCANDEF_TPA)) { dev->shade.wExposure = nmlScan[index].exposureTime; dev->shade.wXStep = nmlScan[index].xStepTime; if( dev->shade.intermediate & _ScanMode_AverageOut ) { dev->shade.wExposure >>= 1; dev->shade.wXStep >>= 1; } } else { if( dev->DataInf.dwScanFlag & _SCANDEF_Transparency ) { dev->shade.wExposure = posScan[index].exposureTime; dev->shade.wXStep = posScan[index].xStepTime; } else { dev->shade.wExposure = dev->scan.negScan[index].exposureTime; dev->shade.wXStep = dev->scan.negScan[index].xStepTime; } } dev->scan.dwInterval = 1; if( dev->DataInf.wPhyDataType == COLOR_BW ) var.dwValue = 0; else { if( dev->DataInf.wPhyDataType == COLOR_256GRAY ) var.dwValue = 2500; else var.dwValue = 3200; } /* for small size/descreen */ if((dev->DataInf.xyAppDpi.y >= 300) && var.dwValue && (dev->DataInf.dwAsicBytesPerPlane <= var.dwValue)) { dev->scan.dwInterval <<= 1; } if( var.dwValue && dev->DataInf.dwAsicBytesPerPlane > var.dwValue ) { if((var.dwValue << 1) > dev->DataInf.dwAsicBytesPerPlane) dev->scan.dwInterval <<= 1; else if((var.dwValue << 2) > dev->DataInf.dwAsicBytesPerPlane) dev->scan.dwInterval <<= 2; else dev->scan.dwInterval <<= 3; } if( dev->DataInf.wPhyDataType >= COLOR_TRUE24 ) { if( dev->DataInf.xyPhyDpi.y > 75U ) { if( dev->f0_8_16 ) { dev->scan.gd_gk.wGreenDiscard = dev->DataInf.xyPhyDpi.y / 75U; } else { dev->scan.gd_gk.wGreenDiscard = dev->DataInf.xyPhyDpi.y / 150U; } } else { dev->scan.gd_gk.wGreenDiscard = 1; } dev->scan.bd_rk.wBlueDiscard = dev->scan.gd_gk.wGreenDiscard << 1; } else { dev->scan.bd_rk.wBlueDiscard = dev->scan.gd_gk.wGreenDiscard = 0; } } /** limit the resolution */ static u_short u12image_GetPhysDPI( U12_Device *dev, ImgDef *img, SANE_Bool fDpiX ) { if( fDpiX ) { if( img->xyDpi.x > dev->dpi_max_x ) return dev->dpi_max_x; else return img->xyDpi.x; } else { if( img->xyDpi.y > dev->dpi_max_y ) return dev->dpi_max_y; else return img->xyDpi.y; } } /** calculate the image properties according to the scanmode * set all internally needed information */ static void u12image_GetImageInfo( U12_Device *dev, ImgDef *image ) { DBG( _DBG_INFO, "u12image_GetImageInfo()\n" ); dev->DataInf.xyPhyDpi.x = u12image_GetPhysDPI(dev, image, SANE_TRUE ); dev->DataInf.xyPhyDpi.y = u12image_GetPhysDPI(dev, image, SANE_FALSE); DBG( _DBG_INFO, "* xyPhyDpi.x = %u, xyPhyDpi.y = %u\n", dev->DataInf.xyPhyDpi.x, dev->DataInf.xyPhyDpi.y ); DBG( _DBG_INFO, "* crArea.x = %u, crArea.y = %u\n", image->crArea.x, image->crArea.y ); DBG( _DBG_INFO, "* crArea.cx = %u, crArea.cy = %u\n", image->crArea.cx, image->crArea.cy ); dev->DataInf.xyRatio = (double)dev->DataInf.xyPhyDpi.y/ (double)dev->DataInf.xyPhyDpi.x; dev->DataInf.dwAppLinesPerArea = (u_long)image->crArea.cy * image->xyDpi.y / _MEASURE_BASE; dev->DataInf.dwAppPixelsPerLine = (u_long)image->crArea.cx * image->xyDpi.x / _MEASURE_BASE; dev->DataInf.dwPhysBytesPerLine = (u_long)image->crArea.cx * dev->DataInf.xyPhyDpi.x / _MEASURE_BASE; if( image->wDataType <= COLOR_BW ) { dev->DataInf.dwAsicPixelsPerPlane = (dev->DataInf.dwAppPixelsPerLine+7UL) & 0xfffffff8UL; dev->DataInf.dwAppPhyBytesPerLine = dev->DataInf.dwAppBytesPerLine = dev->DataInf.dwAsicBytesPerLine = dev->DataInf.dwAsicBytesPerPlane = dev->DataInf.dwAsicPixelsPerPlane>>3; } else { dev->DataInf.dwAsicBytesPerPlane = dev->DataInf.dwAsicPixelsPerPlane = dev->DataInf.dwAppPixelsPerLine; } if( COLOR_TRUE42 == image->wDataType ) { dev->DataInf.dwAsicBytesPerPlane *= 2; } switch( image->wDataType ) { case COLOR_BW: dev->scan.DataProcess = fnDataDirect; dev->DataInf.wPhyDataType = COLOR_BW; dev->shade.intermediate = _ScanMode_Mono; break; case COLOR_256GRAY: dev->scan.DataProcess = fnDataDirect; dev->DataInf.dwAsicBytesPerLine = dev->DataInf.dwAppPhyBytesPerLine = dev->DataInf.dwAppPixelsPerLine; dev->DataInf.wPhyDataType = COLOR_256GRAY; dev->shade.intermediate = _ScanMode_Mono; break; case COLOR_TRUE24: dev->scan.DataProcess = fnColorDirect; dev->DataInf.dwAsicBytesPerLine = dev->DataInf.dwAppPhyBytesPerLine = dev->DataInf.dwAppPixelsPerLine * 3; dev->DataInf.wPhyDataType = COLOR_TRUE24; dev->shade.intermediate = _ScanMode_Color; break; case COLOR_TRUE42: dev->scan.DataProcess = fnColor42; dev->DataInf.dwAsicBytesPerLine = dev->DataInf.dwAppPhyBytesPerLine = dev->DataInf.dwAppPixelsPerLine * 6; dev->DataInf.wPhyDataType = COLOR_TRUE42; dev->shade.intermediate = _ScanMode_Color; break; } /* raus mit einem von beiden!!!!*/ dev->DataInf.dwAppBytesPerLine = dev->DataInf.dwAppPhyBytesPerLine; DBG( _DBG_INFO, "AppLinesPerArea = %lu\n", dev->DataInf.dwAppLinesPerArea ); DBG( _DBG_INFO, "AppPixelsPerLine = %lu\n", dev->DataInf.dwAppPixelsPerLine ); DBG( _DBG_INFO, "AppPhyBytesPerLine = %lu\n", dev->DataInf.dwAppPhyBytesPerLine ); DBG( _DBG_INFO, "AppBytesPerLine = %lu\n", dev->DataInf.dwAppBytesPerLine ); DBG( _DBG_INFO, "AsicPixelsPerPlane = %lu\n", dev->DataInf.dwAsicPixelsPerPlane ); DBG( _DBG_INFO, "AsicBytesPerPlane = %lu\n", dev->DataInf.dwAsicBytesPerPlane ); DBG( _DBG_INFO, "AsicBytesPerLine = %lu\n", dev->DataInf.dwAsicBytesPerLine ); DBG( _DBG_INFO, "Physical Bytes = %lu\n", dev->DataInf.dwPhysBytesPerLine ); } /** */ static int imageSetupScanSettings( U12_Device *dev, ImgDef *img ) { u_short brightness; DBG( _DBG_INFO, "imageSetupScanSettings()\n" ); dev->DataInf.dwScanFlag = img->dwFlag; dev->DataInf.crImage = img->crArea; DBG( _DBG_INFO,"* DataInf.dwScanFlag = 0x%08lx\n",dev->DataInf.dwScanFlag); dev->DataInf.crImage.x <<= 1; dev->DataInf.xyAppDpi = img->xyDpi; dev->DataInf.wAppDataType = img->wDataType; u12image_GetImageInfo( dev, img ); dev->scan.lBufferAdjust = (long)dev->DataInf.dwAppBytesPerLine; DBG( _DBG_INFO, "* Scan settings:\n" ); DBG( _DBG_INFO, "* ImageInfo: (x=%u,y=%u,dx=%u,dy=%u)\n", dev->DataInf.crImage.x, dev->DataInf.crImage.y, dev->DataInf.crImage.cx, dev->DataInf.crImage.cy ); /* * 0 _DEF_BW_THRESHOLD 255 * +-------------------------+--------------------------------+ * |<------- Black --------->|<----------- White ------------>| * So, if user wish to make image darker, the threshold value should be * higher than _defBwThreshold, otherwise it should lower than the * _DefBwThreshold. * Darker = _DEF_BW_THRESHOLD + White * Input / 127; * Input < 0, and White = 255 - _DEF_BW_THRESHOLD, so * = _DEF_BW_THRESHOLD - (255 - _DEF_BW_THRESHOLD) * Input / 127; * The brighter is the same idea. */ /* CHECK: We have now two methods for setting the brightness... */ DBG( _DBG_INFO, "* brightness = %i\n", dev->DataInf.siBrightness ); if ( dev->DataInf.siBrightness < 0) { brightness = (u_short)(_DEF_BW_THRESHOLD - (255 - _DEF_BW_THRESHOLD) * dev->DataInf.siBrightness /127); } else { brightness = (u_short)(_DEF_BW_THRESHOLD - _DEF_BW_THRESHOLD * dev->DataInf.siBrightness /127); } dev->regs.RD_ThresholdControl = brightness; DBG( _DBG_INFO, "* RD_ThresholdControl = %i\n", brightness ); return 0; } /** PrepareScanningVariables() !!! */ static SANE_Status u12image_SetupScanSettings( U12_Device *dev, ImgDef *img ) { DBG( _DBG_INFO, "u12image_SetupScanSettings()\n" ); wPreviewScanned = 0; dev->scan.dpiIdx = 0; dev->scan.negScan = negScan; imageSetupScanSettings( dev, img ); if( !(dev->DataInf.dwScanFlag & _SCANDEF_TPA )) { dev->scan.dwScanOrigin = dev->adj.upNormal * 4 + _RFT_SCANNING_ORG; } else if( dev->DataInf.dwScanFlag & _SCANDEF_Transparency) { dev->scan.dwScanOrigin = dev->adj.upPositive * 4 + _POS_SCANNING_ORG; } else { dev->scan.dwScanOrigin = dev->adj.upNegative * 4 + _NEG_SCANNING_ORG; } dev->scan.dwScanOrigin += 64 /*dev->dwModelOriginY*/; if( dev->DataInf.xyAppDpi.y <= 75 ) { if( dev->DataInf.dwScanFlag & _SCANDEF_PREVIEW ) { dev->scan.bDiscardAll = 0; dev->DataInf.xyPhyDpi.y = 150; dev->shade.intermediate |= _ScanMode_AverageOut; u12image_SetupScanStateVariables( dev, 1 ); dev->scan.gd_gk.wGreenDiscard = 0; if( dev->DataInf.xyAppDpi.y >= 38 ) dev->scan.bd_rk.wBlueDiscard = 1; else dev->scan.bd_rk.wBlueDiscard = 0; if( dev->DataInf.wPhyDataType >= COLOR_256GRAY ) { dev->shade.wXStep = 6; dev->shade.wExposure = 8 * dev->shade.wXStep; } } else { if(!(dev->DataInf.dwScanFlag & _SCANDEF_TPA) && (dev->DataInf.xyAppDpi.y <= 50) && (dev->DataInf.wPhyDataType >= COLOR_TRUE24)) { dev->shade.intermediate |= _ScanMode_AverageOut; } if((dev->DataInf.wPhyDataTypef0_8_16 || (dev->shade.intermediate & _ScanMode_AverageOut)) { dev->scan.bDiscardAll = 1; dev->DataInf.xyPhyDpi.y = 75; u12image_SetupScanStateVariables( dev, 0 ); } else { dev->scan.bDiscardAll = 2; dev->DataInf.xyPhyDpi.y = 150; u12image_SetupScanStateVariables( dev, 1 ); } } } else { if( dev->DataInf.xyAppDpi.y <= 150 ) { dev->scan.bDiscardAll = 2; dev->DataInf.xyPhyDpi.y = 150; u12image_SetupScanStateVariables( dev, 1 ); } else if( dev->DataInf.xyAppDpi.y <= 300 ) { dev->scan.bDiscardAll = 4; dev->DataInf.xyPhyDpi.y = 300; u12image_SetupScanStateVariables( dev, 2 ); } else if( dev->DataInf.xyAppDpi.y <= 600 ) { dev->scan.bDiscardAll = 8; dev->DataInf.xyPhyDpi.y = 600; u12image_SetupScanStateVariables( dev, 3 ); } else { dev->scan.bDiscardAll = 16; dev->DataInf.xyPhyDpi.y = 1200; u12image_SetupScanStateVariables( dev, 4 ); } } /* ------- lines to sample or not? ------- */ if( dev->DataInf.xyAppDpi.y == dev->DataInf.xyPhyDpi.y ) { DBG( _DBG_INFO, "* Sample every line\n" ); dev->scan.DoSample = fnEveryLine; } else { if( dev->DataInf.dwScanFlag & _SCANDEF_PREVIEW ) { DBG( _DBG_INFO, "* Sample preview\n" ); dev->scan.DoSample = fnSamplePreview; dev->DataInf.wYSum = 150; if( dev->DataInf.xyAppDpi.y >= 38 ) wPreviewScanned = dev->DataInf.xyAppDpi.y * 2; else if( dev->DataInf.xyAppDpi.y >= 19 ) wPreviewScanned = dev->DataInf.xyAppDpi.y * 4; else wPreviewScanned = dev->DataInf.xyAppDpi.y * 8; } else { DBG( _DBG_INFO, "* Sample lines (%u - %u)...\n", dev->DataInf.xyPhyDpi.y, dev->DataInf.xyAppDpi.y ); dev->scan.DoSample = fnSampleLines; dev->DataInf.wYSum = dev->DataInf.xyPhyDpi.y - dev->DataInf.xyAppDpi.y; } } /* now assign the buffer pointers for image aquisition */ dev->scan.p48BitBuf.pb = NULL; if( dev->DataInf.wPhyDataType >= COLOR_TRUE24 ) { u_long r, g, b; r = (u_long)_SIZE_REDFIFO / dev->DataInf.dwAsicBytesPerPlane - dev->scan.bd_rk.wRedKeep; g = (u_long)_SIZE_GREENFIFO / dev->DataInf.dwAsicBytesPerPlane - dev->scan.gd_gk.wGreenKeep; if((int)r < 16 || (int)g < 16) { b = (u_long)(dev->scan.bd_rk.wRedKeep + dev->scan.gd_gk.wGreenKeep + 2U) * dev->DataInf.dwAsicBytesPerPlane; DBG( _DBG_INFO, "48Bit buffer request: " "len=%lu bytes, available=%lu\n", b, _SIZE_TOTAL_BUF_TPA ); if( b > _SIZE_TOTAL_BUF_TPA ) { DBG( _DBG_ERROR, "Not that much FIFO memory available!\n" ); return SANE_STATUS_NO_MEM; } dev->scan.p48BitBuf.pb = dev->bufs.b1.pReadBuf; } } if( dev->scan.p48BitBuf.pb ){ dev->scan.DataRead = fnReadToDriver; dev->scan.BufGet.red.bp = dev->scan.BufPut.red.bp = dev->scan.BufBegin.red.bp = dev->scan.p48BitBuf.pb; dev->scan.BufEnd.red.bp = dev->scan.BufBegin.green.bp = dev->scan.BufGet.green.bp = dev->scan.BufPut.green.bp = dev->scan.p48BitBuf.pb + dev->DataInf.dwAsicBytesPerLine * (dev->scan.bd_rk.wRedKeep + 1U); dev->scan.BufEnd.green.bp = dev->scan.BufBegin.green.bp + dev->DataInf.dwAsicBytesPerLine * (dev->scan.gd_gk.wGreenKeep + 1U); dev->scan.BufPut.blue.bp = dev->scan.BufGet.blue.bp = dev->bufs.b1.pReadBuf + dev->DataInf.dwAsicBytesPerLine * 2; } else { dev->scan.DataRead = fnReadOutScanner; dev->scan.BufPut.red.bp = dev->bufs.b1.pReadBuf; dev->scan.BufData.green.bp = dev->scan.BufPut.green.bp = dev->scan.BufPut.red.bp + dev->DataInf.dwAsicBytesPerLine; dev->scan.BufPut.blue.bp = dev->scan.BufPut.green.bp + dev->DataInf.dwAsicBytesPerLine; dev->scan.BufData.red.bp = dev->scan.BufPut.red.bp; dev->scan.BufData.blue.bp = dev->scan.BufPut.blue.bp; } /* CHECK: maybe remove this stuff */ #if 0 if( ps->DataInf.dwScanFlag & _SCANDEF_Transparency) { posScan[1].exposureTime = 96; posScan[1].xStepTime = 12; posScan[2].exposureTime = 96; posScan[2].xStepTime = 24; posScan[3].exposureTime = 96; posScan[3].xStepTime = 48; posScan[4].exposureTime = 96; posScan[4].xStepTime = 96; /* Reset shading Exposure Time & xStep Time */ ps->Shade.wExposure = posScan[ps->Scan.dpiIdx].exposureTime; ps->Shade.wXStep = posScan[ps->Scan.dpiIdx].xStepTime; } else if( ps->DataInf.dwScanFlag & _SCANDEF_Negative) { ps->Scan.negScan[1].exposureTime = 96; ps->Scan.negScan[1].xStepTime = 12; ps->Scan.negScan[2].exposureTime = 96; ps->Scan.negScan[2].xStepTime = 24; ps->Scan.negScan[3].exposureTime = 96; ps->Scan.negScan[3].xStepTime = 48; ps->Scan.negScan[4].exposureTime = 96; ps->Scan.negScan[4].xStepTime = 96; /* Reset shading Exposure Time & xStep Time */ ps->Shade.wExposure = ps->Scan.negScan[ps->Scan.dpiIdx].exposureTime; ps->Shade.wXStep = ps->Scan.negScan[ps->Scan.dpiIdx].xStepTime; } #endif return SANE_STATUS_GOOD; } /** */ static SANE_Bool u12image_DataIsReady( U12_Device *dev, void* buf ) { DBG( _DBG_READ, "* DataIsReady()\n" ); if( dev->scan.bDiscardAll ) { dev->scan.bDiscardAll--; if( dev->DataInf.wPhyDataType <= COLOR_256GRAY ) { dev->regs.RD_ModeControl = _ModeFifoGSel; u12io_ReadMonoData( dev, dev->bufs.b1.pReadBuf, dev->DataInf.dwAsicBytesPerPlane ); } else { u12io_ReadColorData( dev, dev->bufs.b1.pReadBuf, dev->DataInf.dwAsicBytesPerPlane ); } return SANE_FALSE; } if( dev->DataInf.wPhyDataType <= COLOR_256GRAY ) { dev->regs.RD_ModeControl = _ModeFifoGSel; u12io_ReadMonoData( dev, buf, dev->DataInf.dwAsicBytesPerPlane ); } else { if( !dev->scan.DataRead( dev )) { return SANE_FALSE; } } if( dev->scan.DoSample( dev )) { /* direct is done here without copying...*/ if( fnDataDirect != dev->scan.DataProcess ) { (*dev->scan.DataProcess)(dev, buf, (void*)(dev->scan.BufPut.red.bp), dev->DataInf.dwAppPhyBytesPerLine); } return SANE_TRUE; } return SANE_FALSE; } /** */ static SANE_Status u12image_ReadOneImageLine( U12_Device *dev, void* buf ) { SANE_Byte b, state; TimerDef timer, t2; DBG( _DBG_READ, "u12image_ReadOneImageLine()\n" ); u12io_StartTimer( &timer, _LINE_TIMEOUT ); u12io_StartTimer( &t2, _SECOND*2 ); do { state = u12io_GetScanState( dev ); dev->scan.bNowScanState = (state & _SCANSTATE_MASK); if( state & _SCANSTATE_STOP ) { DBG( _DBG_READ, "* SCANSTATE_STOP\n" ); u12motor_ModuleForwardBackward( dev ); if( u12io_GetFifoLength( dev ) >= dev->scan.dwMinReadFifo ) if( u12image_DataIsReady( dev, buf )) return SANE_STATUS_GOOD; } else { dev->scan.bModuleState = _MotorInNormalState; b = dev->scan.bNowScanState - dev->scan.oldScanState; if((char) b < 0) b += _NUMBER_OF_SCANSTEPS; if( b >= dev->scan.bRefresh ) { u12io_RegisterToScanner( dev, REG_REFRESHSCANSTATE ); dev->scan.oldScanState = u12io_GetScanState( dev ); dev->scan.oldScanState &= _SCANSTATE_MASK; } if( u12io_GetFifoLength( dev ) >= dev->scan.dwMaxReadFifo ) { if( u12image_DataIsReady( dev, buf )) return SANE_STATUS_GOOD; } else { b = dev->scan.bNowScanState - dev->scan.oldScanState; if((char) b < 0) b += _NUMBER_OF_SCANSTEPS; if( b >= dev->scan.bRefresh ) { u12io_RegisterToScanner( dev, REG_REFRESHSCANSTATE ); dev->scan.oldScanState = u12io_GetScanState( dev ); dev->scan.oldScanState &= _SCANSTATE_MASK; } if( u12io_GetFifoLength( dev ) >= dev->scan.dwMinReadFifo ) { if( u12image_DataIsReady( dev, buf )) return SANE_STATUS_GOOD; } } } } while( !u12io_CheckTimer( &timer )); DBG( _DBG_ERROR, "Timeout - Scanner malfunction !!\n" ); u12motor_ToHomePosition( dev, SANE_TRUE ); /* timed out, scanner malfunction */ return SANE_STATUS_IO_ERROR; } /** */ static void u12image_PrepareScaling( U12_Device *dev ) { int step; double ratio; dev->scaleBuf = NULL; DBG( _DBG_INFO, "APP-DPIX=%u, MAX-DPIX=%u\n", dev->DataInf.xyAppDpi.x, dev->dpi_max_x ); if( dev->DataInf.xyAppDpi.x > dev->dpi_max_x ) { dev->scaleBuf = malloc( dev->DataInf.dwAppBytesPerLine ); ratio = (double)dev->DataInf.xyAppDpi.x/(double)dev->dpi_max_x; dev->scaleIzoom = (int)(1.0/ratio * 1000); switch( dev->DataInf.wAppDataType ) { case COLOR_BW : step = 0; break; case COLOR_256GRAY : step = 1; break; case COLOR_TRUE24 : step = 3; break; case COLOR_TRUE42 : step = 6; break; default : step = 99; break; } dev->scaleStep = step; DBG( _DBG_INFO, "u12image_PrepareScaling: izoom=%i, step=%u\n", dev->scaleIzoom, step ); } else { DBG( _DBG_INFO, "u12image_PrepareScaling: DISABLED\n" ); } } /** scaling picture data in x-direction, using a DDA algorithm * (digital differential analyzer). */ static void u12image_ScaleX( U12_Device *dev, SANE_Byte *ib, SANE_Byte *ob ) { SANE_Byte tmp; int ddax; u_long i, j, x; /* when not supported, only copy the data */ if( 99 == dev->scaleStep ) { memcpy( ob, ib, dev->DataInf.dwAppBytesPerLine ); return; } /* now scale... */ if( 0 == dev->scaleStep ) { /* binary scaling */ ddax = 0; x = 0; memset( ob, 0, dev->DataInf.dwAppBytesPerLine ); for( i = 0; i < dev->DataInf.dwPhysBytesPerLine*8; i++ ) { ddax -= 1000; while( ddax < 0 ) { tmp = ib[(i>>3)]; if((x>>3) < dev->DataInf.dwAppBytesPerLine ) { if( 0 != (tmp &= (1 << ((~(i & 0x7))&0x7)))) ob[x>>3] |= (1 << ((~(x & 0x7))&0x7)); } x++; ddax += dev->scaleIzoom; } } } else { /* color and gray scaling */ ddax = 0; x = 0; for( i = 0; i < dev->DataInf.dwPhysBytesPerLine*dev->scaleStep; i+=dev->scaleStep ) { ddax -= 1000; while( ddax < 0 ) { for( j = 0; j < (u_long)dev->scaleStep; j++ ) { if((x+j) < dev->DataInf.dwAppBytesPerLine ) { ob[x+j] = ib[i+j]; } } x += dev->scaleStep; ddax += dev->scaleIzoom; } } } } /* END U12_IMAGE.C ..........................................................*/ sane-backends-1.0.29/backend/hp5590_low.h0000666000000000000000000000775113615534521014566 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2007 Ilia Sotnikov 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP ScanJet 4500C/4570C/5500C/5550C/5590/7650 Scanners */ #ifndef HP5590_LOW_H #define HP5590_LOW_H #include "../include/sane/sane.h" enum proto_flags { PF_NONE = 0, PF_NO_USB_IN_USB_ACK = 1 << 0 /* Getting acknowledge after USB-in-USB command * will be skipped */ }; /* Flags for hp5590_cmd() */ #define CMD_IN 1 << 0 /* Indicates IN direction, otherwise - OUT */ #define CMD_VERIFY 1 << 1 /* Requests last command verification */ /* Core flags for hp5590_cmd() - they indicate so called CORE commands */ #define CORE_NONE 0 /* No CORE operation */ #define CORE_DATA 1 << 0 /* Operate on CORE data */ #define CORE_BULK_IN 1 << 1 /* CORE bulk operation - prepare for bulk IN * transfer (not used yet) */ #define CORE_BULK_OUT 1 << 2 /* CORE bulk operation - prepare for bulk OUT * transfer */ static SANE_Status hp5590_cmd (SANE_Int dn, enum proto_flags proto_flags, unsigned int flags, unsigned int cmd, unsigned char *data, unsigned int size, unsigned int core_flags); static SANE_Status hp5590_bulk_read (SANE_Int dn, enum proto_flags proto_flags, unsigned char *bytes, unsigned int size, void *state); static SANE_Status hp5590_bulk_write (SANE_Int dn, enum proto_flags proto_flags, int cmd, unsigned char *bytes, unsigned int size); static SANE_Status hp5590_get_status (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_low_init_bulk_read_state (void **state); static SANE_Status hp5590_low_free_bulk_read_state (void **state); #endif /* HP5590_LOW_H */ /* vim: sw=2 ts=8 */ sane-backends-1.0.29/backend/qcam.c0000666000000000000000000016200113615534521013655 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 David Mosberger-Tang 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for the Connectix QuickCam. At present, only the color camera is supported though the driver should be able to easily accommodate black and white cameras. Portions of this code are derived from Scott Laird's qcam driver. It's copyright notice is reproduced here: Copyright (C) 1996 by Scott Laird Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SCOTT LAIRD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifdef _AIX # include "lalloca.h" /* MUST come first for AIX! */ #endif #include "../include/sane/config.h" #include "lalloca.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #define BACKEND_NAME qcam #include "../include/sane/sanei_backend.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #include "../include/sane/sanei_config.h" #define QCAM_CONFIG_FILE "qcam.conf" #include "qcam.h" /* status bits */ #define NeedRamTable (1 << 1) #define BlackBalanceInProgress (1 << 6) #define CameraNotReady (1 << 7) /* lpdata bits: */ #define Cmd0_7 0xff #define CamRdy2 ( 1 << 0) /* byte mode */ #define Data0_6 (0x7f << 1) /* byte mode */ /* lpstatus bits: */ #define CamRdy1 ( 1 << 3) /* nibble mode */ #define Nibble0_3 (0x0f << 4) /* nibble mode */ #define Data7_11 (0x1f << 3) /* byte mode */ /* lpcontrol bits: */ #define Strobe ( 1 << 0) /* unused */ #define Autofeed ( 1 << 1) #define Reset_N ( 1 << 2) #define PCAck ( 1 << 3) #define BiDir ( 1 << 5) static int num_devices; static QC_Device *first_dev; static QC_Scanner *first_handle; static const SANE_String_Const resolution_list[] = { "Low", /* million-mode */ "High", /* billion-mode */ 0 }; static const SANE_Int mono_depth_list[] = { 2, /* # of elements */ 4, 6 }; static const SANE_Int color_depth_list[] = { /*2 */ 1, /* # of elements */ /*16, */ 24 /* "thousand" mode not implemented yet */ }; static const SANE_Int xfer_scale_list[] = { 3, /* # of elements */ 1, 2, 4 }; static const SANE_Range u8_range = { /* min, max, quantization */ 0, 255, 0 }; static const SANE_Range brightness_range = { /* min, max, quantization */ 0, 254, 0 /* 255 is bulb mode! */ }; static const SANE_Range x_range[] = { /* min, max, quantization */ {0, 338, 2}, /* million mode */ {0, 676, 4}, /* billion mode */ }; static const SANE_Range odd_x_range[] = { /* min, max, quantization */ {1, 339, 2}, /* million mode */ {3, 683, 4}, /* billion mode */ }; static const SANE_Range y_range[] = { /* min, max, quantization */ {0, 249, 1}, /* million mode */ {0, 498, 2}, /* billion mode */ }; static const SANE_Range odd_y_range[] = { /* min, max, quantization */ {0, 249, 1}, /* million mode */ {1, 499, 2}, /* billion mode */ }; static const SANE_Range bw_x_range = { 0, 334, 2 }; static const SANE_Range odd_bw_x_range = { 1, 335, 2 }; static const SANE_Range bw_y_range = { 0, 241, 1 }; static const SANE_Range odd_bw_y_range = { 1, 242, 1 }; #if defined(HAVE_SYS_IO_H) || defined(HAVE_ASM_IO_H) || defined (HAVE_SYS_HW_H) #ifdef HAVE_SYS_IO_H # include /* GNU libc based OS */ #elif HAVE_ASM_IO_H # include /* older Linux */ #elif HAVE_SYS_HW_H # include /* OS/2 */ #endif #endif /* || || */ #define read_lpdata(d) inb ((d)->port) #define read_lpstatus(d) inb ((d)->port + 1) #define read_lpcontrol(d) inb ((d)->port + 2) #define write_lpdata(d,v) outb ((v), (d)->port) #define write_lpcontrol(d,v) outb ((v), (d)->port + 2) static SANE_Status enable_ports (QC_Device * q) { /* better safe than sorry */ if (q->port < 0x278 || q->port > 0x3bc) return SANE_STATUS_INVAL; if (ioperm (q->port, 3, 1) < 0) return SANE_STATUS_INVAL; return SANE_STATUS_GOOD; } static SANE_Status disable_ports (QC_Device * q) { if (ioperm (q->port, 3, 0) < 0) return SANE_STATUS_INVAL; return SANE_STATUS_GOOD; } /* We need a short delay loop -- somthing well under a millisecond. Unfortunately, adding 2 usleep(1)'s to qc_command slowed it down by a factor of over 1000 over the same loop with 2 usleep(0)'s, and that's too slow -- qc_start was taking over a second to run. This seems to help, but if anyone has a good speed-independent pause routine, please tell me. -- Scott If you're worried about hogging the CPU: don't worry, the qcam interface leaves you no choice, so this doesn't make the situation any worse... */ static int qc_wait (QC_Device * q) { return read_lpstatus (q); } /* This function uses POSIX fcntl-style locking on a file created in the /tmp directory. Because it uses the Unix record locking facility, locks are relinquished automatically on process termination, so "dead locks" are not a problem. (FYI, the lock file will remain after process termination, but this is actually desired so that the next process need not re-creat(2)e it... just lock it.) The wait argument indicates whether or not this funciton should "block" waiting for the previous lock to be relinquished. This is ideal so that multiple processes (eg. qcam) taking "snapshots" can peacefully coexist. -- Dave Plonka (plonka@carroll1.cc.edu) */ static SANE_Status qc_lock_wait (QC_Device * q, int wait) { #ifdef F_SETLK #ifndef HAVE_STRUCT_FLOCK struct flock { off_t l_start; off_t l_len; pid_t l_pid; short l_type; short l_whence; }; #endif /* !HAVE_STRUCT_FLOCK */ struct flock sfl; #endif DBG (3, "qc_lock_wait: acquiring lock for 0x%x\n", q->port); #ifdef F_SETLK memset (&sfl, 0, sizeof (sfl)); #endif if (q->lock_fd < 0) { char lockfile[128]; sprintf (lockfile, "/tmp/LOCK.qcam.0x%x", q->port); q->lock_fd = open (lockfile, O_WRONLY | O_CREAT | O_EXCL, 0666); if (q->lock_fd < 0) { DBG (1, "qc_lock_wait: failed to open %s (%s)\n", lockfile, strerror (errno)); return SANE_STATUS_INVAL; } } #ifdef F_SETLK sfl.l_type = F_WRLCK; if (fcntl (q->lock_fd, wait ? F_SETLKW : F_SETLK, &sfl) != 0) { DBG (1, "qc_lock_wait: failed to acquire lock (%s)\n", strerror (errno)); return SANE_STATUS_INVAL; } #endif DBG (3, "qc_lock_wait: got lock for 0x%x\n", q->port); return SANE_STATUS_GOOD; } static SANE_Status qc_unlock (QC_Device * q) { SANE_Status status; char lockfile[128]; #ifdef F_SETLK #ifndef HAVE_STRUCT_FLOCK struct flock { off_t l_start; off_t l_len; pid_t l_pid; short l_type; short l_whence; }; #endif /* !HAVE_STRUCT_FLOCK */ struct flock sfl; #endif DBG (3, "qc_unlock: releasing lock for 0x%x\n", q->port); #ifdef F_SETLK memset (&sfl, 0, sizeof (sfl)); #endif if (q->lock_fd < 0) { DBG (3, "qc_unlock; port was not locked\n"); return SANE_STATUS_INVAL; } /* clear the exclusive lock */ #ifdef F_SETLK sfl.l_type = F_UNLCK; if (fcntl (q->lock_fd, F_SETLK, &sfl) != 0) { DBG (3, "qc_unlock: failed to release lock (%s)\n", strerror (errno)); return SANE_STATUS_INVAL; } #endif sprintf (lockfile, "/tmp/LOCK.qcam.0x%x", q->port); DBG (1, "qc_unlock: /tmp/LOCK.qcam.0x%x\n", q->port); unlink (lockfile); close (q->lock_fd); q->lock_fd = -1; DBG (1, "qc_unlock: exit\n"); status = SANE_STATUS_GOOD; return status; } static SANE_Status qc_lock (QC_Device * q) { return qc_lock_wait (q, 1); } /* Busy-waits for a handshake signal from the QuickCam. Almost all communication with the camera requires handshaking. This is why qcam is a CPU hog. */ static int qc_waithand (QC_Device * q, int val) { int status; while (((status = read_lpstatus (q)) & CamRdy1) != val); return status; } /* This is used when the qcam is in bidirectional ("byte") mode, and the handshaking signal is CamRdy2 (bit 0 of data reg) instead of CamRdy1 (bit 3 of status register). It also returns the last value read, since this data is useful. */ static unsigned int qc_waithand2 (QC_Device * q, int val) { unsigned int status; do { status = read_lpdata (q); } while ((status & CamRdy2) != (unsigned int) val); return status; } static unsigned int qc_send (QC_Device * q, unsigned int byte) { unsigned int echo; int n1, n2; write_lpdata (q, byte); qc_wait (q); write_lpcontrol (q, Autofeed | Reset_N); qc_wait (q); n1 = qc_waithand (q, CamRdy1); write_lpcontrol (q, Autofeed | Reset_N | PCAck); qc_wait (q); n2 = qc_waithand (q, 0); echo = (n1 & 0xf0) | ((n2 & 0xf0) >> 4); #ifndef NDEBUG if (echo != byte) { DBG (1, "qc_send: sent 0x%02x, camera echoed 0x%02x\n", byte, echo); n2 = read_lpstatus (q); echo = (n1 & 0xf0) | ((n2 & 0xf0) >> 4); if (echo != byte) DBG (1, "qc_send: (re-read does not help)\n"); else DBG (1, "qc_send: (fixed on re-read)\n"); } #endif return echo; } static int qc_readparam (QC_Device * q) { int n1, n2; int cmd; write_lpcontrol (q, Autofeed | Reset_N); /* clear PCAck */ n1 = qc_waithand (q, CamRdy1); write_lpcontrol (q, Autofeed | Reset_N | PCAck); /* set PCAck */ n2 = qc_waithand (q, 0); cmd = (n1 & 0xf0) | ((n2 & 0xf0) >> 4); return cmd; } static unsigned int qc_getstatus (QC_Device * q) { unsigned int status; qc_send (q, QC_SEND_STATUS); status = qc_readparam (q); DBG (3, "qc_getstatus: status=0x%02x\n", status); return status; } static void qc_setscanmode (QC_Scanner * s, u_int * modep) { QC_Device *q = s->hw; u_int mode = 0; if (q->version != QC_COLOR) { switch (s->val[OPT_XFER_SCALE].w) { case 1: mode = 0; break; case 2: mode = 4; break; case 4: mode = 8; break; } switch (s->val[OPT_DEPTH].w) { case 4: break; case 6: mode += 2; break; } } else { switch (s->val[OPT_XFER_SCALE].w) { case 1: mode = 0; break; case 2: mode = 2; break; case 4: mode = 4; break; } if (s->resolution == QC_RES_LOW) mode |= 0x18; /* millions mode */ else mode |= 0x10; /* billions mode */ } if (s->val[OPT_TEST].w) mode |= 0x40; /* test mode */ if (q->port_mode == QC_BIDIR) mode |= 1; DBG (2, "scanmode (before increment): 0x%x\n", mode); if (q->version == QC_COLOR) ++mode; *modep = mode; } /* Read data bytes from the camera. The number of bytes read is returned as the function result. Depending on the mode, it may be either 1, 3 or 6. On failure, 0 is returned. If buffer is 0, the internal state-machine is reset. */ static size_t qc_readbytes (QC_Scanner * s, unsigned char buffer[]) { QC_Device *q = s->hw; unsigned int hi, lo; unsigned int hi2, lo2; size_t bytes = 0; if (!buffer) { s->readbytes_state = 0; return 0; } switch (q->port_mode) { case QC_BIDIR: /* bi-directional port */ /* read off 24 bits: */ write_lpcontrol (q, Autofeed | Reset_N | BiDir); lo = qc_waithand2 (q, 1) >> 1; hi = (read_lpstatus (q) >> 3) & 0x1f; write_lpcontrol (q, Autofeed | Reset_N | PCAck | BiDir); lo2 = qc_waithand2 (q, 0) >> 1; hi2 = (read_lpstatus (q) >> 3) & 0x1f; if (q->version == QC_COLOR) { /* is Nibble3 inverted for color quickcams only? */ hi ^= 0x10; hi2 ^= 0x10; } switch (s->val[OPT_DEPTH].w) { case 4: buffer[0] = lo & 0xf; buffer[1] = ((lo & 0x70) >> 4) | ((hi & 1) << 3); buffer[2] = (hi & 0x1e) >> 1; buffer[3] = lo2 & 0xf; buffer[4] = ((lo2 & 0x70) >> 4) | ((hi2 & 1) << 3); buffer[5] = (hi2 & 0x1e) >> 1; bytes = 6; break; case 6: buffer[0] = lo & 0x3f; buffer[1] = ((lo & 0x40) >> 6) | (hi << 1); buffer[2] = lo2 & 0x3f; buffer[3] = ((lo2 & 0x40) >> 6) | (hi2 << 1); bytes = 4; break; case 24: buffer[0] = lo | ((hi & 0x1) << 7); buffer[1] = ((hi2 & 0x1e) >> 1) | ((hi & 0x1e) << 3); buffer[2] = lo2 | ((hi2 & 0x1) << 7); bytes = 3; break; } break; case QC_UNIDIR: /* Unidirectional Port */ write_lpcontrol (q, Autofeed | Reset_N); lo = (qc_waithand (q, CamRdy1) & 0xf0) >> 4; write_lpcontrol (q, Autofeed | Reset_N | PCAck); hi = (qc_waithand (q, 0) & 0xf0) >> 4; if (q->version == QC_COLOR) { /* invert Nibble3 */ hi ^= 8; lo ^= 8; } switch (s->val[OPT_DEPTH].w) { case 4: buffer[0] = lo; buffer[1] = hi; bytes = 2; break; case 6: switch (s->readbytes_state) { case 0: buffer[0] = (lo << 2) | ((hi & 0xc) >> 2); s->saved_bits = (hi & 3) << 4; s->readbytes_state = 1; bytes = 1; break; case 1: buffer[0] = lo | s->saved_bits; s->saved_bits = hi << 2; s->readbytes_state = 2; bytes = 1; break; case 2: buffer[0] = ((lo & 0xc) >> 2) | s->saved_bits; buffer[1] = ((lo & 3) << 4) | hi; s->readbytes_state = 0; bytes = 2; break; default: DBG (1, "qc_readbytes: bad unidir 6-bit stat %d\n", s->readbytes_state); break; } break; case 24: buffer[0] = (lo << 4) | hi; bytes = 1; break; default: DBG (1, "qc_readbytes: bad unidir bit depth %d\n", s->val[OPT_DEPTH].w); break; } break; default: DBG (1, "qc_readbytes: bad port_mode %d\n", q->port_mode); break; } return bytes; } static void qc_reset (QC_Device * q) { write_lpcontrol (q, Strobe | Autofeed | Reset_N | PCAck); qc_wait (q); write_lpcontrol (q, Strobe | Autofeed | PCAck); qc_wait (q); write_lpcontrol (q, Strobe | Autofeed | Reset_N | PCAck); } /* This function is executed as a child process. The reason this is executed as a subprocess is because the qcam interface directly reads off of a I/O port (rather than a filedescriptor). Thus, to have something to select() on, we transfer the data through a pipe. WARNING: Since this is executed as a subprocess, it's NOT possible to update any of the variables in the main process (in particular the scanner state cannot be updated). */ static jmp_buf env; static void sighandler (int signal) { DBG (3, "sighandler: got signal %d\n", signal); longjmp (env, 1); } /* Original despeckling code by Patrick Reynolds */ static void despeckle (int width, int height, SANE_Byte * in, SANE_Byte * out) { long x, i; /* The light-check threshold. Higher numbers remove more lights but blur the image more. 30 is good for indoor lighting. */ # define NO_LIGHTS 30 /* macros to make the code a little more readable, p=previous, n=next */ # define R in[i*3] # define G in[i*3+1] # define B in[i*3+2] # define pR in[i*3-3] # define pG in[i*3-2] # define pB in[i*3-1] # define nR in[i*3+3] # define nG in[i*3+4] # define nB in[i*3+5] DBG (1, "despeckle: width=%d, height=%d\n", width, height); for (x = i = 0; i < width * height; ++i) { if (x == 0 || x == width - 1) memcpy (&out[i * 3], &in[i * 3], 3); else { if (R - (G + B) / 2 > NO_LIGHTS + ((pR - (pG + pB) / 2) + (nR - (nG + nB) / 2))) out[i * 3] = (pR + nR) / 2; else out[i * 3] = R; if (G - (R + B) / 2 > NO_LIGHTS + ((pG - (pR + pB) / 2) + (nG - (nR + nB) / 2))) out[i * 3 + 1] = (pG + nG) / 2; else out[i * 3 + 1] = G; if (B - (G + R) / 2 > NO_LIGHTS + ((pB - (pG + pR) / 2) + (nB - (nG + nR) / 2))) out[i * 3 + 2] = (pB + nB) / 2; else out[i * 3 + 2] = B; } if (++x >= width) x = 0; } # undef R # undef G # undef B # undef pR # undef pG # undef pB # undef nR # undef nG # undef nB } static void despeckle32 (int width, int height, SANE_Byte * in, SANE_Byte * out) { long x, i; /* macros to make the code a little more readable, p=previous, n=next */ # define B in[i*4] # define Ga in[i*4 + 1] # define Gb in[i*4 + 1] /* ignore Gb and use Ga instead---Gb is weird */ # define R in[i*4 + 3] # define pB in[i*4 - 4] # define pGa in[i*4 - 3] # define pGb in[i*4 - 1] /* ignore Gb and use Ga instead---Gb is weird */ # define pR in[i*4 - 1] # define nB in[i*4 + 4] # define nGa in[i*4 + 5] # define nGb in[i*4 + 5] /* ignore Gb and use Ga instead---Gb is weird */ # define nR in[i*4 + 7] DBG (1, "despeckle32: width=%d, height=%d\n", width, height); for (x = i = 0; i < width * height; ++i) { if (x == 0 || x == width - 1) memcpy (&out[i * 4], &in[i * 4], 4); else { if (x >= width - 2) /* the last red pixel seems to be black at all times, use R instead: */ nR = R; if (R - ((Ga + Gb) / 2 + B) / 2 > NO_LIGHTS + ((pR - ((pGa + pGb) / 2 + pB) / 2) + (nR - ((nGa + nGb) / 2 + nB) / 2))) out[i * 4 + 3] = (pR + nR) / 2; else out[i * 4 + 3] = R; if (Ga - (R + B) / 2 > NO_LIGHTS + ((pGa - (pR + pB) / 2) + (nGa - (nR + nB) / 2))) out[i * 4 + 1] = (pGa + nGa) / 2; else out[i * 4 + 1] = Ga; if (Gb - (R + B) / 2 > NO_LIGHTS + ((pGb - (pR + pB) / 2) + (nGb - (nR + nB) / 2))) out[i * 4 + 2] = (pGb + nGb) / 2; else out[i * 4 + 2] = Gb; if (B - ((Ga + Gb) / 2 + R) / 2 > NO_LIGHTS + ((pB - ((pGa + pGb) / 2 + pR) / 2) + (nB - ((nGa + nGb) / 2 + nR) / 2))) out[i * 4 + 0] = (pB + nB) / 2; else out[i * 4 + 0] = B; } if (++x >= width) x = 0; } # undef R # undef Ga # undef Gb # undef B # undef pR # undef pGa # undef pGb # undef pB # undef nR # undef nGa # undef nGb # undef nB } static int reader_process (QC_Scanner * s, int in_fd, int out_fd) { static SANE_Byte *buffer = 0, *extra = 0; static size_t buffer_size = 0; size_t count, len, num_bytes; QC_Device *q = s->hw; QC_Scan_Request req; int width, height; SANE_Byte *src; FILE *ofp; DBG (5, "reader_process: enter\n"); enable_ports (q); ofp = fdopen (out_fd, "w"); if (!ofp) return 1; while (1) { if (setjmp (env)) { char ch; /* acknowledge the signal: */ DBG (1, "reader_process: sending signal ACK\n"); fwrite (&ch, 1, 1, ofp); fflush (ofp); /* force everything out the pipe */ continue; } signal (SIGINT, sighandler); /* the main process gets us started by writing a size_t giving the number of bytes we should expect: */ if (read (in_fd, &req, sizeof (req)) != sizeof (req)) { perror ("read"); return 1; } num_bytes = req.num_bytes; DBG (3, "reader_process: got request for %lu bytes\n", (u_long) num_bytes); /* Don't do this in sane_start() since there may be a long timespan between it and the first sane_read(), which would result in poor images. */ qc_send (q, QC_SEND_VIDEO_FRAME); qc_send (q, req.mode); if (req.despeckle && (!extra || buffer_size < num_bytes || buffer_size >= 2 * num_bytes)) { if (extra) extra = realloc (extra, num_bytes); else extra = malloc (num_bytes); if (!extra) { DBG (1, "reader_process: malloc(%ld) failed\n", (long) num_bytes); exit (1); } } if (buffer_size < num_bytes || buffer_size >= 2 * num_bytes) { if (buffer) buffer = realloc (buffer, num_bytes); else buffer = malloc (num_bytes); if (!buffer) { DBG (1, "reader_process: malloc(%ld) failed\n", (long) num_bytes); exit (1); } buffer_size = num_bytes; } if (q->port_mode == QC_BIDIR) { /* turn port into input port */ write_lpcontrol (q, Autofeed | Reset_N | PCAck | BiDir); usleep (3); write_lpcontrol (q, Autofeed | Reset_N | BiDir); qc_waithand (q, CamRdy1); write_lpcontrol (q, Autofeed | Reset_N | PCAck | BiDir); qc_waithand (q, 0); } if (q->version == QC_COLOR) for (len = 0; len < num_bytes; len += count) count = qc_readbytes (s, buffer + len); else { /* strange -- should be 15:63 below, but 4bpp is odd */ int shift, invert; unsigned int i; u_char val; switch (s->val[OPT_DEPTH].w) { case 4: invert = 16; shift = 4; break; case 6: invert = 63; shift = 2; break; default: DBG (1, "reader_process: unexpected depth %d\n", s->val[OPT_DEPTH].w); return 1; } for (len = 0; len < num_bytes; len += count) { count = qc_readbytes (s, buffer + len); for (i = 0; i < count; ++i) { /* 4bpp is odd (again) -- inverter is 16, not 15, but output must be 0-15 */ val = buffer[len + i]; if (val > 0 || invert != 16) val = invert - val; buffer[len + i] = (val << shift) | (val >> (8 - 2 * shift)); } } qc_readbytes (s, 0); /* reset state machine */ } /* we're done reading this frame: */ DBG (2, "reader_process: frame complete\n"); if (q->port_mode == QC_BIDIR) { /* return port to output mode */ write_lpcontrol (q, Autofeed); usleep (3); write_lpcontrol (q, Autofeed | Reset_N); usleep (3); write_lpcontrol (q, Autofeed | Reset_N | PCAck); } if (req.resolution == QC_RES_HIGH) { SANE_Byte buf[6]; int x, y; /* in billions mode, we need to oversample the data: */ src = buffer; width = req.params.pixels_per_line; height = req.params.lines; if (req.despeckle) { despeckle32 (width / 2, req.params.lines / 2, buffer, extra); src = extra; } assert (!(width & 1)); /* width must be even */ for (y = 0; y < height; ++y) { /* even line */ for (x = 0; x < width; x += 2) { int red1, green1, blue1, green2, blue2; blue1 = src[0]; green1 = src[1]; red1 = src[3]; if (x >= width - 2) { red1 = src[-1]; /* last red seems to be missing */ blue2 = blue1; green2 = green1; } else { blue2 = src[4]; green2 = src[5]; } src += 4; buf[0] = red1; buf[1] = green1; buf[2] = blue1; buf[3] = red1; buf[4] = green2; buf[5] = blue2; if (fwrite (buf, 1, 6, ofp) != 6) { perror ("fwrite: short write"); return 1; } } if (++y >= height) break; src -= 2 * width; /* 4 bytes/pixel -> 2 pixels of 3 bytes each */ /* odd line */ for (x = 0; x < width; x += 2) { int red1, green3, blue3, green4, blue4; int yoff; if (x >= width - 2) red1 = src[-1]; /* last red seems to be missing */ else red1 = src[3]; yoff = 2 * width; if (y >= height - 1) yoff = 0; green3 = src[yoff + 1]; blue3 = src[yoff + 0]; if (x >= width - 2) { blue4 = blue3; green4 = green3; } else { blue4 = src[yoff + 4]; green4 = src[yoff + 5]; } src += 4; buf[0] = red1; buf[1] = green3; buf[2] = blue3; buf[3] = red1; buf[4] = green4; buf[5] = blue4; if (fwrite (buf, 1, 6, ofp) != 6) { perror ("fwrite: short write"); return 1; } } } } else { src = buffer; if (req.despeckle) { despeckle (req.params.pixels_per_line, req.params.lines, buffer, extra); src = extra; } /* now write the whole thing to the main process: */ if (fwrite (src, 1, num_bytes, ofp) != num_bytes) { perror ("fwrite: short write"); return 1; } } fflush (ofp); } assert (SANE_FALSE); /* not reached */ DBG (5, "reader_process: exit\n"); return 1; } static SANE_Status attach (const char *devname, QC_Device ** devp) { int i, n1, n2, s1, s2, cmd, port, force_unidir; SANE_Status result, status; QC_Device *q; char *endp; DBG (3, "attach: enter\n"); errno = 0; force_unidir = 0; if (devname[0] == 'u') { force_unidir = 1; ++devname; } port = strtol (devname, &endp, 0); if (endp == devname || errno == ERANGE) { DBG (1, "attach: invalid port address `%s'\n", devname); return SANE_STATUS_INVAL; } for (q = first_dev; q; q = q->next) if (port == q->port) { if (devp) *devp = q; return SANE_STATUS_GOOD; } q = malloc (sizeof (*q)); if (!q) return SANE_STATUS_NO_MEM; memset (q, 0, sizeof (*q)); q->port = port; q->lock_fd = -1; result = enable_ports (q); if (result != SANE_STATUS_GOOD) { DBG (1, "attach: cannot enable ports (%s)\n", strerror (errno)); free (q); return SANE_STATUS_INVAL; } /* lock camera while we determine its version: */ qc_lock (q); qc_reset (q); write_lpdata (q, QC_SEND_VERSION); qc_wait (q); write_lpcontrol (q, Autofeed | Reset_N); /* make PCAck inactive */ qc_wait (q); for (i = 0; (i < 1000) && !(s1 = (n1 = read_lpstatus (q)) & CamRdy1); i++); if (!s1) { DBG (2, "attach: failed to get CamRdy1 at port 0x%x\n", q->port); goto unlock_and_fail; } write_lpcontrol (q, Autofeed | Reset_N | PCAck); qc_wait (q); for (i = 0; (i < 1000) && (s2 = (n2 = read_lpstatus (q)) & CamRdy1); i++); if (s2) { DBG (2, "attach: CamRdy1 failed to clear at port 0x%x\n", q->port); goto unlock_and_fail; } cmd = (n1 & 0xf0) | ((n2 & 0xf0) >> 4); if (cmd != QC_SEND_VERSION) { DBG (2, "attach: got 0x%02x instead of 0x%02x\n", cmd, QC_SEND_VERSION); goto unlock_and_fail; } q->version = qc_readparam (q); DBG (1, "attach: found QuickCam version 0x%02x\n", q->version); q->port_mode = QC_UNIDIR; if (!force_unidir) { write_lpcontrol (q, BiDir); write_lpdata (q, 0x75); if (read_lpdata (q) != 0x75) q->port_mode = QC_BIDIR; } /* For some reason the color quickcam needs two set-black commands after a reset. Thus, we now set the black-level to some reasonable value (0) so that the next set-black level command will really go through. */ if (q->version == QC_COLOR) { qc_send (q, QC_SET_BLACK); qc_send (q, 0); DBG (3, "attach: resetting black_level\n"); /* wait for set black level command to finish: */ while (qc_getstatus (q) & (CameraNotReady | BlackBalanceInProgress)) usleep (10000); } status = qc_unlock (q); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: status qc_unlock NOK\n"); /* status = SANE_STATUS_GOOD; */ } q->sane.name = strdup (devname); q->sane.vendor = "Connectix"; q->sane.model = (q->version == QC_COLOR) ? "Color QuickCam" : "B&W QuickCam"; q->sane.type = "video camera"; ++num_devices; q->next = first_dev; first_dev = q; if (devp) *devp = q; DBG (3, "attach: exit status OK\n"); status = SANE_STATUS_GOOD; return status; unlock_and_fail: status = qc_unlock (q); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: unlock_and_fail status qc_unlock NOK\n"); } free (q); DBG (3, "attach: exit status NOK\n"); status = SANE_STATUS_INVAL; return status; } static SANE_Status init_options (QC_Scanner * s) { int i; DBG (3, "init_options: enter\n"); memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = (SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT); } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = "Scan Mode"; s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_STRING; s->opt[OPT_RESOLUTION].size = 5; /* sizeof("High") */ s->opt[OPT_RESOLUTION].unit = SANE_UNIT_NONE; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_RESOLUTION].constraint.string_list = resolution_list; s->val[OPT_RESOLUTION].s = strdup (resolution_list[QC_RES_LOW]); /* bit-depth */ s->opt[OPT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->opt[OPT_DEPTH].title = "Pixel depth"; s->opt[OPT_DEPTH].desc = "Number of bits per pixel."; s->opt[OPT_DEPTH].type = SANE_TYPE_INT; s->opt[OPT_DEPTH].unit = SANE_UNIT_BIT; s->opt[OPT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_DEPTH].constraint.word_list = color_depth_list; s->val[OPT_DEPTH].w = color_depth_list[NELEMS (color_depth_list) - 1]; /* test */ s->opt[OPT_TEST].name = "test-image"; s->opt[OPT_TEST].title = "Force test image"; s->opt[OPT_TEST].desc = "Acquire a test-image instead of the image seen by the camera. " "The test image consists of red, green, and blue squares of " "32x32 pixels each. Use this to find out whether the " "camera is connected properly."; s->opt[OPT_TEST].type = SANE_TYPE_BOOL; s->val[OPT_TEST].w = SANE_FALSE; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = "Geometry"; s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_INT; s->opt[OPT_TL_X].unit = SANE_UNIT_PIXEL; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &x_range[QC_RES_LOW]; s->val[OPT_TL_X].w = 10; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_INT; s->opt[OPT_TL_Y].unit = SANE_UNIT_PIXEL; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &y_range[QC_RES_LOW]; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_INT; s->opt[OPT_BR_X].unit = SANE_UNIT_PIXEL; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &odd_x_range[QC_RES_LOW]; s->val[OPT_BR_X].w = 339; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_INT; s->opt[OPT_BR_Y].unit = SANE_UNIT_PIXEL; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &odd_y_range[QC_RES_LOW]; s->val[OPT_BR_Y].w = 245; /* xfer-scale */ s->opt[OPT_XFER_SCALE].name = "transfer-scale"; s->opt[OPT_XFER_SCALE].title = "Transfer scale"; s->opt[OPT_XFER_SCALE].desc = "The transferscale determines how many of the acquired pixels actually " "get sent to the computer. For example, a transfer scale of 2 would " "request that every other acquired pixel would be omitted. That is, " "when scanning a 200 pixel wide and 100 pixel tall area, the resulting " "image would be only 100x50 pixels large. Using a large transfer scale " "improves acquisition speed, but reduces resolution."; s->opt[OPT_XFER_SCALE].type = SANE_TYPE_INT; s->opt[OPT_XFER_SCALE].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_XFER_SCALE].constraint.word_list = xfer_scale_list; s->val[OPT_XFER_SCALE].w = xfer_scale_list[1]; /* despeckle */ s->opt[OPT_DESPECKLE].name = "despeckle"; s->opt[OPT_DESPECKLE].title = "Speckle filter"; s->opt[OPT_DESPECKLE].desc = "Turning on this filter will remove the " "christmas lights that are typically present in dark images."; s->opt[OPT_DESPECKLE].type = SANE_TYPE_BOOL; s->opt[OPT_DESPECKLE].constraint_type = SANE_CONSTRAINT_NONE; s->val[OPT_DESPECKLE].w = 0; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = "Enhancement"; s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS " In a conventional camera, this control corresponds to the " "exposure time."; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].cap |= SANE_CAP_AUTOMATIC; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &brightness_range; s->val[OPT_BRIGHTNESS].w = 135; /* contrast */ s->opt[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->opt[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->opt[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->opt[OPT_CONTRAST].type = SANE_TYPE_INT; s->opt[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_CONTRAST].constraint.range = &u8_range; s->val[OPT_CONTRAST].w = 104; /* black-level */ s->opt[OPT_BLACK_LEVEL].name = SANE_NAME_BLACK_LEVEL; s->opt[OPT_BLACK_LEVEL].title = SANE_TITLE_BLACK_LEVEL; s->opt[OPT_BLACK_LEVEL].desc = SANE_DESC_BLACK_LEVEL " This value should be selected so that black areas just start " "to look really black (not gray)."; s->opt[OPT_BLACK_LEVEL].type = SANE_TYPE_INT; s->opt[OPT_BLACK_LEVEL].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BLACK_LEVEL].constraint.range = &u8_range; s->val[OPT_BLACK_LEVEL].w = 0; /* white-level */ s->opt[OPT_WHITE_LEVEL].name = SANE_NAME_WHITE_LEVEL; s->opt[OPT_WHITE_LEVEL].title = SANE_TITLE_WHITE_LEVEL; s->opt[OPT_WHITE_LEVEL].desc = SANE_DESC_WHITE_LEVEL " This value should be selected so that white areas just start " "to look really white (not gray)."; s->opt[OPT_WHITE_LEVEL].type = SANE_TYPE_INT; s->opt[OPT_WHITE_LEVEL].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_WHITE_LEVEL].constraint.range = &u8_range; s->val[OPT_WHITE_LEVEL].w = 150; /* hue */ s->opt[OPT_HUE].name = SANE_NAME_HUE; s->opt[OPT_HUE].title = SANE_TITLE_HUE; s->opt[OPT_HUE].desc = SANE_DESC_HUE; s->opt[OPT_HUE].type = SANE_TYPE_INT; s->opt[OPT_HUE].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_HUE].constraint.range = &u8_range; s->val[OPT_HUE].w = 128; /* saturation */ s->opt[OPT_SATURATION].name = SANE_NAME_SATURATION; s->opt[OPT_SATURATION].title = SANE_TITLE_SATURATION; s->opt[OPT_SATURATION].desc = SANE_DESC_SATURATION; s->opt[OPT_SATURATION].type = SANE_TYPE_INT; s->opt[OPT_SATURATION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_SATURATION].constraint.range = &u8_range; s->val[OPT_SATURATION].w = 100; DBG (3, "init_options: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { char dev_name[PATH_MAX], *str; size_t len; FILE *fp; authorize = authorize; /* silence compilation warnings */ DBG_INIT (); DBG (1, "sane_init: enter\n"); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); fp = sanei_config_open (QCAM_CONFIG_FILE); if (!fp) { DBG (1, "sane_init: file `%s' not accessible\n", QCAM_CONFIG_FILE); return SANE_STATUS_INVAL; } while (sanei_config_read (dev_name, sizeof (dev_name), fp)) { if (dev_name[0] == '#') /* ignore line comments */ continue; len = strlen (dev_name); if (!len) continue; /* ignore empty lines */ for (str = dev_name; *str && !isspace (*str) && *str != '#'; ++str); *str = '\0'; attach (dev_name, 0); } fclose (fp); DBG (1, "sane_init: exit\n"); return SANE_STATUS_GOOD; } void sane_exit (void) { QC_Device *dev, *next; static const SANE_Device **devlist; DBG (5, "sane_exit: enter\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; free ((void *) dev->sane.name); disable_ports (dev); free (dev); } if (devlist) { free (devlist); devlist = NULL; } DBG (5, "sane_exit: exit\n"); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { static const SANE_Device **devlist = 0; QC_Device *dev; int i; DBG (5, "sane_get_devices: enter\n"); local_only = local_only; /* silence compilation warnings */ if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; *device_list = devlist; DBG (5, "sane_get_devices: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { SANE_Status status; QC_Device *dev; QC_Scanner *s; DBG (5, "sane_open: enter: (devicename = %s)\n", devicename); if (devicename[0]) { status = attach (devicename, &dev); if (status != SANE_STATUS_GOOD) return status; } else /* empty devicname -> use first device */ dev = first_dev; if (!dev) return SANE_STATUS_INVAL; s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->user_corner = 0; s->hw = dev; s->value_changed = ~0; /* ensure all options get updated */ s->reader_pid = -1; s->to_child = -1; s->from_child = -1; s->read_fd = -1; init_options (s); /* The contrast option seems to have an effect for b&w cameras only, so don't give the user the impression that this is a useful thing to set... */ if (s->hw->version == QC_COLOR) s->opt[OPT_CONTRAST].cap |= SANE_CAP_INACTIVE; else { /* Black level, Hue and Saturation are things the b&w cameras know nothing about. Despeckle might be useful, but this code seems to work for color cameras only right now. The framesize seems to work better in these ranges. */ s->opt[OPT_DESPECKLE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_BLACK_LEVEL].cap |= SANE_CAP_INACTIVE; s->opt[OPT_HUE].cap |= SANE_CAP_INACTIVE; s->opt[OPT_SATURATION].cap |= SANE_CAP_INACTIVE; s->opt[OPT_RESOLUTION].cap |= SANE_CAP_INACTIVE; s->opt[OPT_TEST].cap |= SANE_CAP_INACTIVE; s->opt[OPT_DEPTH].constraint.word_list = mono_depth_list; s->val[OPT_DEPTH].w = mono_depth_list[NELEMS (mono_depth_list) - 1]; s->opt[OPT_TL_X].constraint.range = &bw_x_range; s->val[OPT_TL_X].w = 14; s->opt[OPT_TL_Y].constraint.range = &bw_y_range; s->val[OPT_TL_Y].w = 0; s->opt[OPT_BR_X].constraint.range = &odd_bw_x_range; s->val[OPT_BR_X].w = 333; s->opt[OPT_BR_Y].constraint.range = &odd_bw_y_range; s->val[OPT_BR_Y].w = 239; s->val[OPT_BRIGHTNESS].w = 170; s->val[OPT_CONTRAST].w = 150; s->val[OPT_WHITE_LEVEL].w = 150; } /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; DBG (5, "sane_open: exit\n"); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { QC_Scanner *prev, *s; DBG (5, "sane_close: enter\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) { DBG (1, "sane_close: bad handle %p\n", handle); return; /* oops, not a handle we know about */ } if (prev) prev->next = s->next; else first_handle = s->next; if (s->scanning) sane_cancel (handle); if (s->reader_pid >= 0) { kill (s->reader_pid, SIGTERM); waitpid (s->reader_pid, 0, 0); s->reader_pid = 0; } if (s->to_child >= 0) close (s->to_child); if (s->from_child >= 0) close (s->from_child); if (s->read_fd >= 0) close (s->read_fd); free (s); DBG (5, "sane_close: exit\n"); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { QC_Scanner *s = handle; DBG (5, "sane_get_option_descriptor: enter\n"); if ((unsigned) option >= NUM_OPTIONS) return 0; DBG (5, "sane_get_option_descriptor: exit\n"); return s->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { QC_Scanner *s = handle; QC_Resolution old_res; SANE_Status status; SANE_Word cap; char *old_val; int i; DBG (5, "sane_control_option: enter\n"); if (info) *info = 0; if (option >= NUM_OPTIONS) return SANE_STATUS_INVAL; cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) return SANE_STATUS_INVAL; if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_NUM_OPTS: case OPT_DEPTH: case OPT_DESPECKLE: case OPT_TEST: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_XFER_SCALE: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_BLACK_LEVEL: case OPT_WHITE_LEVEL: case OPT_HUE: case OPT_SATURATION: *(SANE_Word *) val = s->val[option].w; return SANE_STATUS_GOOD; /* string options: */ case OPT_RESOLUTION: strcpy (val, s->val[option].s); return SANE_STATUS_GOOD; default: DBG (1, "control_option: option %d unknown\n", option); } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) return SANE_STATUS_INVAL; status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) return status; if (option >= OPT_TL_X && option <= OPT_BR_Y) s->user_corner |= 1 << (option - OPT_TL_X); assert (option <= 31); s->value_changed |= 1 << option; switch (option) { /* (mostly) side-effect-free word options: */ case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_XFER_SCALE: case OPT_DEPTH: if (!s->scanning && info && s->val[option].w != *(SANE_Word *) val) /* only signal the reload params if we're not scanning---no point in creating the frontend useless work */ *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_NUM_OPTS: case OPT_TEST: case OPT_DESPECKLE: case OPT_BRIGHTNESS: case OPT_CONTRAST: case OPT_BLACK_LEVEL: case OPT_WHITE_LEVEL: case OPT_HUE: case OPT_SATURATION: s->val[option].w = *(SANE_Word *) val; return SANE_STATUS_GOOD; /* options with side-effects: */ case OPT_RESOLUTION: old_val = s->val[OPT_RESOLUTION].s; if (strcmp (old_val, val) != 0) return SANE_STATUS_GOOD; /* no change */ if (info) { *info |= SANE_INFO_RELOAD_OPTIONS; if (!s->scanning) *info |= SANE_INFO_RELOAD_PARAMS; } free (old_val); s->val[OPT_RESOLUTION].s = strdup (val); /* low-resolution mode: */ old_res = s->resolution; s->resolution = QC_RES_LOW; if (strcmp (val, resolution_list[QC_RES_HIGH]) == 0) /* high-resolution mode: */ s->resolution = QC_RES_HIGH; s->opt[OPT_TL_X].constraint.range = &x_range[s->resolution]; s->opt[OPT_BR_X].constraint.range = &odd_x_range[s->resolution]; s->opt[OPT_TL_Y].constraint.range = &y_range[s->resolution]; s->opt[OPT_BR_Y].constraint.range = &odd_y_range[s->resolution]; if (old_res == QC_RES_LOW && s->resolution == QC_RES_HIGH) { for (i = OPT_TL_X; i <= OPT_BR_Y; ++i) s->val[i].w *= 2; s->val[OPT_BR_X].w += 1; s->val[OPT_BR_Y].w += 1; s->opt[OPT_TEST].cap |= SANE_CAP_INACTIVE; } else if (old_res == QC_RES_HIGH && s->resolution == QC_RES_LOW) { for (i = OPT_TL_X; i <= OPT_BR_Y; ++i) s->val[i].w /= 2; s->opt[OPT_TEST].cap &= ~SANE_CAP_INACTIVE; } if (!(s->user_corner & 0x4)) s->val[OPT_BR_X].w = odd_x_range[s->resolution].max; if (!(s->user_corner & 0x8)) s->val[OPT_BR_Y].w = odd_y_range[s->resolution].max - 4; /* make sure the affected options have valid values: */ for (i = OPT_TL_X; i <= OPT_BR_Y; ++i) if (s->val[i].w > s->opt[i].constraint.range->max) s->val[i].w = s->opt[i].constraint.range->max; DBG (5, "sane_control_option: exit\n"); return SANE_STATUS_GOOD; } } else if (action == SANE_ACTION_SET_AUTO) { switch (option) { case OPT_BRIGHTNESS: /* not implemented yet */ DBG (5, "sane_control_option: exit\n"); return SANE_STATUS_GOOD; default: break; } } DBG (5, "sane_control_option: NOK exit\n"); return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { QC_Scanner *s = handle; QC_Device *q = s->hw; int xfer_scale; size_t Bpp = 3; /* # of bytes per pixel */ DBG (5, "sane_get_parameters: enter\n"); if (!s->scanning) { /* Only compute new parameters when not scanning---allows changing width/height etc while scan is in progress. */ xfer_scale = s->val[OPT_XFER_SCALE].w; s->params.format = SANE_FRAME_RGB; if (q->version != QC_COLOR) { s->params.format = SANE_FRAME_GRAY; Bpp = 1; } s->params.last_frame = SANE_TRUE; s->params.pixels_per_line = s->val[OPT_BR_X].w - s->val[OPT_TL_X].w + 1; s->params.pixels_per_line /= xfer_scale; s->params.pixels_per_line &= ~1UL; /* ensure it's even */ if (s->params.pixels_per_line < 2) s->params.pixels_per_line = 2; s->params.lines = s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w + 1; s->params.lines /= xfer_scale; if (s->params.lines < 1) s->params.lines = 1; s->params.bytes_per_line = Bpp * s->params.pixels_per_line; s->params.depth = 8; } if (params) *params = s->params; DBG (5, "sane_get_parameters: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { int top, left, width, height, undecimated_width, undecimated_height; QC_Scanner *s = handle; QC_Device *q = s->hw; QC_Scan_Request req; DBG (5, "sane_start: enter\n"); if (s->scanning) return SANE_STATUS_DEVICE_BUSY; if (s->reader_pid < 0) { int p2c_pipe[2]; /* parent->child pipe */ int c2p_pipe[2]; /* child->parent pipe */ if (pipe (p2c_pipe) < 0 || pipe (c2p_pipe) < 0) { DBG (3, "start: failed to create pipes\n"); return SANE_STATUS_IO_ERROR; } s->reader_pid = fork (); if (s->reader_pid == 0) { /* this is the child */ signal (SIGHUP, SIG_DFL); signal (SIGINT, SIG_DFL); signal (SIGPIPE, SIG_DFL); signal (SIGTERM, SIG_DFL); _exit (reader_process (s, p2c_pipe[0], c2p_pipe[1])); } close (p2c_pipe[0]); close (c2p_pipe[1]); s->to_child = p2c_pipe[1]; s->from_child = c2p_pipe[0]; } s->read_fd = dup (s->from_child); sane_get_parameters (s, 0); /* ensure uptodate parameters */ qc_lock (q); s->holding_lock = SANE_TRUE; if (q->version == QC_COLOR) { qc_send (q, QC_SET_SPEED); qc_send (q, 2); /* wait for camera to become ready: */ while (qc_getstatus (q) & CameraNotReady) usleep (10000); /* Only send black_level if necessary; this optimization may fail if two applications access the camera in an interleaved fashion; but the black-level command is slow enough that it cannot be issued for every image acquisition. */ if (s->value_changed & (1 << OPT_BLACK_LEVEL)) { s->value_changed &= ~(1 << OPT_BLACK_LEVEL); qc_send (q, QC_SET_BLACK); qc_send (q, s->val[OPT_BLACK_LEVEL].w); DBG (3, "start: black_level=%d\n", s->val[OPT_BLACK_LEVEL].w); /* wait for set black level command to finish: */ while (qc_getstatus (q) & (CameraNotReady | BlackBalanceInProgress)) usleep (10000); } if (s->value_changed & (1 << OPT_HUE)) { s->value_changed &= ~(1 << OPT_HUE); qc_send (q, QC_COL_SET_HUE); qc_send (q, s->val[OPT_HUE].w); } if (s->value_changed & (1 << OPT_SATURATION)) { s->value_changed &= ~(1 << OPT_SATURATION); qc_send (q, QC_SET_SATURATION); qc_send (q, s->val[OPT_SATURATION].w); } } if (q->version != QC_COLOR) qc_reset (q); if (s->value_changed & (1 << OPT_CONTRAST)) { s->value_changed &= ~(1 << OPT_CONTRAST); qc_send (q, ((q->version == QC_COLOR) ? QC_COL_SET_CONTRAST : QC_MONO_SET_CONTRAST)); qc_send (q, s->val[OPT_CONTRAST].w); } if (s->value_changed & (1 << OPT_BRIGHTNESS)) { s->value_changed &= ~(1 << OPT_BRIGHTNESS); qc_send (q, QC_SET_BRIGHTNESS); qc_send (q, s->val[OPT_BRIGHTNESS].w); } width = s->params.pixels_per_line; height = s->params.lines; if (s->resolution == QC_RES_HIGH) { width /= 2; /* the expansion occurs through oversampling */ height /= 2; /* we acquire only half the lines that we generate */ } undecimated_width = width * s->val[OPT_XFER_SCALE].w; undecimated_height = height * s->val[OPT_XFER_SCALE].w; s->num_bytes = 0; s->bytes_per_frame = s->params.lines * s->params.bytes_per_line; qc_send (q, QC_SET_NUM_V); qc_send (q, undecimated_height); if (q->version == QC_COLOR) { qc_send (q, QC_SET_NUM_H); qc_send (q, undecimated_width / 2); } else { int val, val2; if (q->port_mode == QC_UNIDIR && s->val[OPT_DEPTH].w == 6) { val = undecimated_width; val2 = s->val[OPT_XFER_SCALE].w * 4; } else { val = undecimated_width * s->val[OPT_DEPTH].w; val2 = ((q->port_mode == QC_BIDIR) ? 24 : 8) * s->val[OPT_XFER_SCALE].w; } val = (val + val2 - 1) / val2; qc_send (q, QC_SET_NUM_H); qc_send (q, val); } left = s->val[OPT_TL_X].w / 2; top = s->val[OPT_TL_Y].w; if (s->resolution == QC_RES_HIGH) { left /= 2; top /= 2; } DBG (3, "sane_start: top=%d, left=%d, white=%d, bright=%d, contr=%d\n", top, left, s->val[OPT_WHITE_LEVEL].w, s->val[OPT_BRIGHTNESS].w, s->val[OPT_CONTRAST].w); qc_send (q, QC_SET_LEFT); qc_send (q, left); qc_send (q, QC_SET_TOP); qc_send (q, top + 1); /* not sure why this is so... ;-( */ if (s->value_changed & (1 << OPT_WHITE_LEVEL)) { s->value_changed &= ~(1 << OPT_WHITE_LEVEL); qc_send (q, QC_SET_WHITE); qc_send (q, s->val[OPT_WHITE_LEVEL].w); } DBG (2, "start: %s %d lines of %d pixels each (%ld bytes) => %dx%d\n", (q->port_mode == QC_BIDIR) ? "bidir" : "unidir", height, width, (long) s->bytes_per_frame, s->params.pixels_per_line, s->params.lines); /* send scan request to reader process: */ qc_setscanmode (s, &req.mode); req.num_bytes = width * height; if (q->version == QC_COLOR) { if (s->resolution == QC_RES_LOW) req.num_bytes *= 3; else req.num_bytes *= 4; } req.resolution = s->resolution; req.params = s->params; req.despeckle = s->val[OPT_DESPECKLE].w; write (s->to_child, &req, sizeof (req)); s->scanning = SANE_TRUE; s->deliver_eof = 0; DBG (5, "sane_start: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * lenp) { SANE_Status status; QC_Scanner *s = handle; QC_Device *q = s->hw; ssize_t nread; size_t len; DBG (5, "sane_read: enter\n"); *lenp = 0; if (s->deliver_eof) { s->deliver_eof = 0; return SANE_STATUS_EOF; } if (!s->scanning) return SANE_STATUS_CANCELLED; len = max_len; if (s->num_bytes + len > s->bytes_per_frame) len = s->bytes_per_frame - s->num_bytes; DBG (8, "read(buf=%p,num_bytes=%ld,max_len=%d,len=%ld)\n", buf, (long) s->num_bytes, max_len, (long) len); nread = read (s->read_fd, buf, len); if (nread <= 0) { if (nread == 0 || errno == EAGAIN) { DBG (3, "read: no more data available\n"); return SANE_STATUS_GOOD; } DBG (3, "read: short read (%s)\n", strerror (errno)); return SANE_STATUS_IO_ERROR; } if (nread > 0 && s->holding_lock) { status = qc_unlock (q); /* now we can unlock the camera */ if (status != SANE_STATUS_GOOD) DBG(3, "sane_read: qc_unlock error\n"); s->holding_lock = SANE_FALSE; } s->num_bytes += nread; if (s->num_bytes >= s->bytes_per_frame) { s->scanning = SANE_FALSE; close (s->read_fd); s->read_fd = -1; s->deliver_eof = 1; } if (lenp) *lenp = nread; DBG (5, "sane_read: exit, read got %d bytes\n", *lenp); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { QC_Scanner *s = handle; SANE_Bool was_scanning; SANE_Status status; DBG (5, "sane_cancel: enter\n"); was_scanning = s->scanning; s->scanning = SANE_FALSE; s->deliver_eof = 0; if (s->read_fd >= 0) { close (s->read_fd); s->read_fd = -1; } if (s->reader_pid >= 0 && was_scanning) { char buf[1024]; ssize_t nread; int flags; DBG (1, "cancel: cancelling read request\n"); kill (s->reader_pid, SIGINT); /* tell reader to stop reading */ /* save non-blocking i/o flags: */ flags = fcntl (s->from_child, F_GETFL, 0); /* block until we read at least one byte: */ read (s->from_child, buf, 1); /* put descriptor in non-blocking i/o: */ fcntl (s->from_child, F_SETFL, O_NONBLOCK); /* read what's left over in the pipe/file buffer: */ do { while ((nread = read (s->from_child, buf, sizeof (buf))) > 0); usleep (100000); nread = read (s->from_child, buf, sizeof (buf)); } while (nread > 0); /* now restore non-blocking i/o flag: */ fcntl (s->from_child, F_SETFL, flags & O_NONBLOCK); waitpid (s->reader_pid, 0, 0); s->reader_pid = 0; DBG (1, "cancel: cancellation completed\n"); } if (s->holding_lock) { status = qc_unlock (s->hw); if (status != SANE_STATUS_GOOD) DBG(3, "sane_cancel: qc_unlock error\n"); s->holding_lock = SANE_FALSE; } DBG (5, "sane_cancel: exit\n"); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { QC_Scanner *s = handle; DBG (5, "sane_set_io_mode: enter\n"); if (!s->scanning) return SANE_STATUS_INVAL; if (fcntl (s->read_fd, F_SETFL, non_blocking ? O_NONBLOCK : 0) < 0) return SANE_STATUS_IO_ERROR; DBG (5, "sane_set_io_mode: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { QC_Scanner *s = handle; DBG (5, "sane_get_select_fd: enter\n"); if (!s->scanning) return SANE_STATUS_INVAL; *fd = s->read_fd; DBG (5, "sane_get_select_fd: exit\n"); return SANE_STATUS_GOOD; } sane-backends-1.0.29/backend/magicolor.c0000666000000000000000000024101413615534521014712 00000000000000/* * magicolor.c - SANE library for Magicolor scanners. * * (C) 2010 Reinhold Kainhofer * * Based on the epson2 sane backend: * Based on Kazuhiro Sasayama previous * Work on epson.[ch] file from the SANE package. * Please see those files for additional copyrights. * Copyright (C) 2006-10 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 MAGICOLOR_VERSION 0 #define MAGICOLOR_REVISION 0 #define MAGICOLOR_BUILD 1 /* debugging levels: * * 127 mc_recv buffer * 125 mc_send buffer * 35 fine-grained status and progress * 30 sane_read * 25 setvalue, getvalue, control_option * 20 low-level (I/O) mc_* functions * 15 mid-level mc_* functions * 10 high-level cmd_* functions * 7 open/close/attach * 6 print_params * 5 basic functions * 3 status info and progress * 2 scanner info and capabilities * 1 errors & warnings */ #include "sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_SYS_SOCKET_H #include #endif #if HAVE_LIBSNMP #include #include #include #include #endif #include "../include/sane/saneopts.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_tcp.h" #include "../include/sane/sanei_udp.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_backend.h" #include "magicolor.h" #define min(x,y) (((x)<(y))?(x):(y)) /**************************************************************************** * Devices supported by this backend ****************************************************************************/ /* Scanner command type * | Start scan * | | Poll for error * | | | Stop scan? * | | | | Query image parameters * | | | | | set scan parameters * | | | | | | Get status? * | | | | | | | Read scanned data * | | | | | | | | Unknown * | | | | | | | | | Unknown * | | | | | | | | | | Net wrapper command type * | | | | | | | | | | | Net Welcome * | | | | | | | | | | | | Net Lock * | | | | | | | | | | | | | Net Lock ACK * | | | | | | | | | | | | | | Net Unlock * | | | | | | | | | | | | | | | */ static struct MagicolorCmd magicolor_cmd[] = { {"mc1690mf", CMD, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x12, NET, 0x00, 0x01, 0x02, 0x03}, {"mc4690mf", CMD, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x12, NET, 0x00, 0x01, 0x02, 0x03}, }; static SANE_Int magicolor_default_resolutions[] = {150, 300, 600}; static SANE_Int magicolor_default_depths[] = {1,8}; static struct MagicolorCap magicolor_cap[] = { /* KONICA MINOLTA magicolor 1690MF, USB ID 0x123b:2089 */ { 0x2089, "mc1690mf", "KONICA MINOLTA magicolor 1690MF", "1.3.6.1.4.1.183341.1.1.2.1.32.3.2", -1, 0x85, 600, {150, 600, 0}, magicolor_default_resolutions, 3, /* 600 dpi max, 3 resolutions */ 8, magicolor_default_depths, /* color depth 8 default, 1 and 8 possible */ {1, 9, 0}, /* brightness ranges (TODO!) */ {0, SANE_FIX(0x13f8 * MM_PER_INCH / 600), 0}, {0, SANE_FIX(0x1b9c * MM_PER_INCH / 600), 0}, /* FBF x/y ranges (TODO!) */ SANE_TRUE, SANE_FALSE, /* non-duplex ADF, x/y ranges (TODO!) */ {0, SANE_FIX(0x1390 * MM_PER_INCH / 600), 0}, {0, SANE_FIX(0x20dc * MM_PER_INCH / 600), 0}, }, /* KONICA MINOLTA magicolor 4690MF, USB ID 0x132b:2079 */ { 0x2079, "mc4690mf", "KONICA MINOLTA magicolor 4690MF", "FIXME", /* FIXME: fill in the correct OID! */ 0x03, 0x85, 600, {150, 600, 0}, magicolor_default_resolutions, 3, /* 600 dpi max, 3 resolutions */ 8, magicolor_default_depths, /* color depth 8 default, 1 and 8 possible */ {1, 9, 0}, /* brightness ranges (TODO!) */ {0, SANE_FIX(0x13f8 * MM_PER_INCH / 600), 0}, {0, SANE_FIX(0x1b9c * MM_PER_INCH / 600), 0}, /* FBF x/y ranges (TODO!) */ SANE_TRUE, SANE_TRUE, /* duplex ADF, x/y ranges (TODO!) */ {0, SANE_FIX(0x1390 * MM_PER_INCH / 600), 0}, {0, SANE_FIX(0x20dc * MM_PER_INCH / 600), 0}, }, }; static int MC_SNMP_Timeout = 2500; static int MC_Scan_Data_Timeout = 15000; static int MC_Request_Timeout = 5000; /**************************************************************************** * General configuration parameter definitions ****************************************************************************/ /* * Definition of the mode_param struct, that is used to * specify the valid parameters for the different scan modes. * * The depth variable gets updated when the bit depth is modified. */ static struct mode_param mode_params[] = { {0x00, 1, 1}, /* Lineart, 1 color, 1 bit */ {0x02, 1, 24}, /* Grayscale, 1 color, 24 bit */ {0x03, 3, 24} /* Color, 3 colors, 24 bit */ }; static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, NULL }; static const SANE_String_Const adf_mode_list[] = { SANE_I18N("Simplex"), SANE_I18N("Duplex"), NULL }; /* Define the different scan sources */ #define FBF_STR SANE_I18N("Flatbed") #define ADF_STR SANE_I18N("Automatic Document Feeder") /* * source list need one dummy entry (save device settings is crashing). * NOTE: no const - this list gets created while exploring the capabilities * of the scanner. */ static SANE_String_Const source_list[] = { FBF_STR, NULL, NULL, NULL }; /* Some utility functions */ static size_t max_string_size(const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; i++) { size = strlen(strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } static SANE_Status attach_one_usb(SANE_String_Const devname); static SANE_Status attach_one_net(SANE_String_Const devname, unsigned int device); static void print_params(const SANE_Parameters params) { DBG(6, "params.format = %d\n", params.format); DBG(6, "params.last_frame = %d\n", params.last_frame); DBG(6, "params.bytes_per_line = %d\n", params.bytes_per_line); DBG(6, "params.pixels_per_line = %d\n", params.pixels_per_line); DBG(6, "params.lines = %d\n", params.lines); DBG(6, "params.depth = %d\n", params.depth); } /**************************************************************************** * Low-level Network communication functions ****************************************************************************/ #define MAGICOLOR_SNMP_SYSDESCR_OID ".1.3.6.1.2.1.1.1.0" #define MAGICOLOR_SNMP_SYSOBJECT_OID ".1.3.6.1.2.1.1.2.0" #define MAGICOLOR_SNMP_MAC_OID ".1.3.6.1.2.1.2.2.1.6.1" #define MAGICOLOR_SNMP_DEVICE_TREE ".1.3.6.1.4.1.18334.1.1.1.1.1" /* We don't have a packet wrapper, which holds packet size etc., so we don't have to use a *read_raw and a *_read function... */ static int sanei_magicolor_net_read(struct Magicolor_Scanner *s, unsigned char *buf, size_t wanted, SANE_Status * status) { size_t size, read = 0; struct pollfd fds[1]; *status = SANE_STATUS_GOOD; /* poll for data-to-be-read (using a 5 seconds timeout) */ fds[0].fd = s->fd; fds[0].events = POLLIN; if (poll (fds, 1, MC_Request_Timeout) <= 0) { *status = SANE_STATUS_IO_ERROR; return read; } while (read < wanted) { size = sanei_tcp_read(s->fd, buf + read, wanted - read); if (size == 0) break; read += size; } if (read < wanted) *status = SANE_STATUS_IO_ERROR; return read; } /* We need to optionally pad the buffer with 0x00 to send 64-byte chunks. On the other hand, the 0x04 commands don't need this, so we need two functions, one *_write function that pads the buffer and then calls *_write_raw */ static int sanei_magicolor_net_write_raw(struct Magicolor_Scanner *s, const unsigned char *buf, size_t buf_size, SANE_Status *status) { sanei_tcp_write(s->fd, buf, buf_size); /* TODO: Check whether sending failed... */ *status = SANE_STATUS_GOOD; return buf_size; } static int sanei_magicolor_net_write(struct Magicolor_Scanner *s, const unsigned char *buf, size_t buf_size, SANE_Status *status) { size_t len = 64; unsigned char *new_buf = malloc(len); if (!new_buf) { *status = SANE_STATUS_NO_MEM; return 0; } memset(new_buf, 0x00, len); if (buf_size > len) buf_size = len; if (buf_size) memcpy(new_buf, buf, buf_size); return sanei_magicolor_net_write_raw (s, new_buf, len, status); } static SANE_Status sanei_magicolor_net_open(struct Magicolor_Scanner *s) { SANE_Status status; unsigned char buf[5]; ssize_t read; struct timeval tv; struct MagicolorCmd *cmd = s->hw->cmd; tv.tv_sec = 5; tv.tv_usec = 0; setsockopt(s->fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)); DBG(1, "%s\n", __func__); /* the scanner sends a kind of welcome msg */ read = sanei_magicolor_net_read(s, buf, 3, &status); if (read != 3) return SANE_STATUS_IO_ERROR; if (buf[0] != cmd->net_wrapper_cmd || buf[1] != cmd->net_welcome) { DBG (32, "Invalid welcome message received, Expected 0x%02x %02x 00, but got 0x%02x %02x %02x\n", cmd->net_wrapper_cmd, cmd->net_welcome, buf[0], buf[1], buf[2]); return SANE_STATUS_IO_ERROR; } else if (buf[2] != 0x00) { /* TODO: Handle response "04 00 01", indicating an error! */ DBG (32, "Welcome message received, busy status %02x\n", buf[2]); /* TODO: Return a human-readable error message (Unable to connect to scanner, scanner is not ready) */ return SANE_STATUS_DEVICE_BUSY; } buf[0] = cmd->net_wrapper_cmd; buf[1] = cmd->net_lock; buf[2] = 0x00; /* Copy the device's USB id to bytes 3-4: */ buf[3] = s->hw->cap->id & 0xff; buf[4] = (s->hw->cap->id >> 8) & 0xff; DBG(32, "Proper welcome message received, locking the scanner...\n"); sanei_magicolor_net_write_raw(s, buf, 5, &status); read = sanei_magicolor_net_read(s, buf, 3, &status); if (read != 3) return SANE_STATUS_IO_ERROR; if (buf[0] != cmd->net_wrapper_cmd || buf[1] != cmd->net_lock_ack || buf[2] != 0x00) { DBG (32, "Welcome message received, Expected 0x%x %x 00, but got 0x%x %x %x\n", cmd->net_wrapper_cmd, cmd->net_lock_ack, buf[0], buf[1], buf[2]); return SANE_STATUS_IO_ERROR; } DBG(32, "scanner locked\n"); return status; } static SANE_Status sanei_magicolor_net_close(struct Magicolor_Scanner *s) { SANE_Status status; struct MagicolorCmd *cmd = s->hw->cmd; unsigned char buf[3]; DBG(1, "%s\n", __func__); buf[0] = cmd->net_wrapper_cmd; buf[1] = cmd->net_unlock; buf[2] = 0x00; sanei_magicolor_net_write_raw(s, buf, 3, &status); return status; } /**************************************************************************** * Low-level USB communication functions ****************************************************************************/ #define SANE_MAGICOLOR_VENDOR_ID (0x132b) SANE_Word sanei_magicolor_usb_product_ids[] = { 0x2089, /* magicolor 1690MF */ 0x2079, /* magicolor 4690MF */ 0 /* last entry - this is used for devices that are specified in the config file as "usb " */ }; static int sanei_magicolor_getNumberOfUSBProductIds (void) { return sizeof (sanei_magicolor_usb_product_ids) / sizeof (SANE_Word); } /**************************************************************************** * Magicolor low-level communication commands ****************************************************************************/ static void dump_hex_buffer_dense (int level, const unsigned char *buf, size_t buf_size) { size_t k; char msg[1024], fmt_buf[1024]; memset (&msg[0], 0x00, 1024); memset (&fmt_buf[0], 0x00, 1024); for (k = 0; k < min(buf_size, 80); k++) { if (k % 16 == 0) { if (k>0) { DBG (level, "%s\n", msg); memset (&msg[0], 0x00, 1024); } sprintf (fmt_buf, " 0x%04lx ", (unsigned long)k); strcat (msg, fmt_buf); } if (k % 8 == 0) { strcat (msg, " "); } sprintf (fmt_buf, " %02x" , buf[k]); strcat (msg, fmt_buf); } if (msg[0] != 0 ) { DBG (level, "%s\n", msg); } } /* Create buffers containing the command and arguments. Length of reserved * buffer is returned. It's the caller's job to free the buffer! */ static int mc_create_buffer (Magicolor_Scanner *s, unsigned char cmd_type, unsigned char cmd, unsigned char **buf, unsigned char* arg1, size_t len1, SANE_Status *status) { unsigned char* b = NULL; size_t buf_len = 2+4+len1+4; NOT_USED (s); if (len1 <= 0) buf_len = 6; /* no args, just cmd + final 0x00 00 00 00 */ *buf = b = malloc (buf_len); memset (b, 0x00, buf_len); if (!b) { *status = SANE_STATUS_NO_MEM; return 0; } b[0] = cmd_type; b[1] = cmd; if (len1>0) { b[2] = len1 & 0xff; b[3] = (len1 >> 8) & 0xff; b[4] = (len1 >> 16) & 0xff; b[5] = (len1 >> 24) & 0xff; if (arg1) memcpy(b+6, arg1, len1); } /* Writing the final 0x00 00 00 00 is not necessary, they are 0x00 already */ *status = SANE_STATUS_GOOD; return buf_len; } static int mc_create_buffer2 (Magicolor_Scanner *s, unsigned char cmd_type, unsigned char cmd, unsigned char **buf, unsigned char* arg1, size_t len1, unsigned char* arg2, size_t len2, SANE_Status *status) { unsigned char* b = NULL; size_t buf_len = 2+4+len1+4+len2+4; /* If any of the two args has size 0, use the simpler mc_create_buffer */ if (len1<=0) return mc_create_buffer (s, cmd_type, cmd, buf, arg2, len2, status); else if (len2<=0) return mc_create_buffer (s, cmd_type, cmd, buf, arg1, len1, status); /* Allocate memory and copy over args and their lengths */ *buf = b = malloc (buf_len); if (!b) { *status = SANE_STATUS_NO_MEM; return 0; } memset (b, 0x00, buf_len); b[0] = cmd_type; b[1] = cmd; /* copy over the argument length in lower endian */ b[2] = len1 & 0xff; b[3] = (len1 >> 8) & 0xff; b[4] = (len1 >> 16) & 0xff; b[5] = (len1 >> 24) & 0xff; if (arg1) { /* Copy the arguments */ memcpy(b+6, arg1, len1); } /* copy over the second argument length in little endian */ b[6+len1] = len2 & 0xff; b[7+len1] = (len2 >> 8) & 0xff; b[8+len1] = (len2 >> 16) & 0xff; b[9+len1] = (len2 >> 24) & 0xff; if (arg2) { memcpy(b+10+len1, arg2, len2); } *status = SANE_STATUS_GOOD; return buf_len; } static int mc_send(Magicolor_Scanner * s, void *buf, size_t buf_size, SANE_Status * status) { DBG(15, "%s: size = %lu\n", __func__, (u_long) buf_size); if (DBG_LEVEL >= 125) { const unsigned char *s = buf; DBG(125, "Cmd: 0x%02x %02x, complete buffer:\n", s[0], s[1]); dump_hex_buffer_dense (125, s, buf_size); } if (s->hw->connection == SANE_MAGICOLOR_NET) { return sanei_magicolor_net_write(s, buf, buf_size, status); } else if (s->hw->connection == SANE_MAGICOLOR_USB) { size_t n; n = buf_size; *status = sanei_usb_write_bulk(s->fd, buf, &n); DBG(125, "USB: wrote %lu bytes, status: %s\n", (unsigned long)n, sane_strstatus(*status)); return n; } *status = SANE_STATUS_INVAL; return 0; /* never reached */ } static ssize_t mc_recv(Magicolor_Scanner * s, void *buf, ssize_t buf_size, SANE_Status * status) { ssize_t n = 0; DBG(15, "%s: size = %ld, buf = %p\n", __func__, (long) buf_size, buf); if (s->hw->connection == SANE_MAGICOLOR_NET) { n = sanei_magicolor_net_read(s, buf, buf_size, status); } else if (s->hw->connection == SANE_MAGICOLOR_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); if (n > 0) *status = SANE_STATUS_GOOD; } if (n < buf_size) { DBG(1, "%s: expected = %lu, got = %ld\n", __func__, (u_long) buf_size, (long) n); *status = SANE_STATUS_IO_ERROR; } /* dump buffer if appropriate */ if (DBG_LEVEL >= 127 && n > 0) { const unsigned char* b=buf; dump_hex_buffer_dense (125, b, buf_size); } return n; } /* Simple function to exchange a fixed amount of * data with the scanner */ static SANE_Status mc_txrx(Magicolor_Scanner * s, unsigned char *txbuf, size_t txlen, unsigned char *rxbuf, size_t rxlen) { SANE_Status status; mc_send(s, txbuf, txlen, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: tx err, %s\n", __func__, sane_strstatus(status)); return status; } mc_recv(s, rxbuf, rxlen, &status); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: rx err, %s\n", __func__, sane_strstatus(status)); } return status; } /**************************************************************************** * Magicolor high-level communication commands ****************************************************************************/ /** 0x03 09 01 - Request last error * <- Information block (0x00 for OK, 0x01 for ERROR) */ static SANE_Status cmd_request_error (SANE_Handle handle) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char params[1]; unsigned char *buf; size_t buflen; DBG(8, "%s\n", __func__); if (s->hw->cmd->request_status == 0) return SANE_STATUS_UNSUPPORTED; buflen = mc_create_buffer (s, s->hw->cmd->scanner_cmd, s->hw->cmd->request_error, &buf, NULL, 1, &status); if (buflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } status = mc_txrx (s, buf, buflen, params, 1); free(buf); if (status != SANE_STATUS_GOOD) return status; DBG(1, "status: %02x\n", params[0]); switch (params[0]) { case STATUS_READY: DBG(1, " ready\n"); break; case STATUS_ADF_JAM: DBG(1, " paper jam in ADF\n"); return SANE_STATUS_JAMMED; break; case STATUS_OPEN: DBG(1, " printer door open or waiting for button press\n"); return SANE_STATUS_COVER_OPEN; break; case STATUS_NOT_READY: DBG(1, " scanner not ready (in use on another interface or warming up)\n"); return SANE_STATUS_DEVICE_BUSY; break; default: DBG(1, " unknown status 0x%x\n", params[0]); } return status; } /** 0x03 0d - Request status command */ static SANE_Status cmd_request_status(SANE_Handle handle, unsigned char *b) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char *buf; size_t buflen; DBG(8, "%s\n", __func__); if (!b) { DBG(1, "%s called with NULL buffer\n", __func__); return SANE_STATUS_INVAL; } memset (b, 0x00, 0x0b); /* initialize all 0x0b bytes with 0 */ buflen = mc_create_buffer (s, s->hw->cmd->scanner_cmd, s->hw->cmd->request_status, &buf, NULL, 0x0b, &status); if (buflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } status = mc_txrx (s, buf, buflen, b, 0x0b); free (buf); if (status != SANE_STATUS_GOOD) DBG(8, "%s: Status NOT successfully retrieved\n", __func__); else { DBG(8, "%s: Status successfully retrieved:\n", __func__); /* TODO: debug output of the returned parameters... */ DBG (11, " ADF status: 0x%02x", b[1]); if (b[1] & ADF_LOADED) { DBG (11, " loaded\n"); } else { DBG (11, " not loaded\n"); } } return status; } /** 0x03 08 - Start scan command */ static SANE_Status cmd_start_scan (SANE_Handle handle, size_t value) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char params1[4], params2[1]; unsigned char *buf; size_t buflen; DBG(8, "%s\n", __func__); /* Copy params to buffers */ /* arg1 is expected returned bytes per line, 4-byte little endian */ /* arg2 is unknown, seems to be always 0x00 */ params1[0] = value & 0xff; params1[1] = (value >> 8) & 0xff; params1[2] = (value >> 16) & 0xff; params1[3] = (value >> 24) & 0xff; params2[0] = 0x00; buflen = mc_create_buffer2 (s, s->hw->cmd->scanner_cmd, s->hw->cmd->start_scanning, &buf, params1, 4, params2, 1, &status); if (buflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } mc_send(s, buf, buflen, &status); free (buf); if (status != SANE_STATUS_GOOD) DBG(8, "%s: Data NOT successfully sent\n", __func__); else DBG(8, "%s: Data successfully sent\n", __func__); return status; } /** 0x03 0a - Cancel(?) Scan command */ /* TODO: Does this command really mean CANCEL??? */ static SANE_Status cmd_cancel_scan (SANE_Handle handle) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char *buf; size_t buflen; DBG(8, "%s\n", __func__); buflen = mc_create_buffer (s, s->hw->cmd->scanner_cmd, s->hw->cmd->stop_scanning, &buf, NULL, 0, &status); if (buflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } mc_send(s, buf, buflen, &status); free (buf); if (status != SANE_STATUS_GOOD) DBG(8, "%s: Data NOT successfully sent\n", __func__); else DBG(8, "%s: Data successfully sent\n", __func__); return status; } /** 0x03 12 - Finish(?) scan command */ /* TODO: Does this command really mean FINISH??? */ static SANE_Status cmd_finish_scan (SANE_Handle handle) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char *buf, returned[0x0b]; size_t buflen; DBG(8, "%s\n", __func__); buflen = mc_create_buffer (s, s->hw->cmd->scanner_cmd, s->hw->cmd->unknown2, &buf, NULL, 0x0b, &status); if (buflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } memset (&returned[0], 0x00, 0x0b); status = mc_txrx (s, buf, buflen, returned, 0x0b); free (buf); if (status != SANE_STATUS_GOOD) DBG(8, "%s: Data NOT successfully sent\n", __func__); else DBG(8, "%s: Data successfully sent\n", __func__); return status; } /** 0x03 0b - Get scanning parameters command * input buffer seems to be 0x00 always */ static SANE_Status cmd_get_scanning_parameters(SANE_Handle handle, SANE_Frame *format, SANE_Int *depth, SANE_Int *data_pixels, SANE_Int *pixels_per_line, SANE_Int *lines) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char *txbuf, rxbuf[8]; size_t buflen; NOT_USED (format); NOT_USED (depth); DBG(8, "%s\n", __func__); buflen = mc_create_buffer (s, s->hw->cmd->scanner_cmd, s->hw->cmd->request_scan_parameters, &txbuf, NULL, 8, &status); if (buflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } status = mc_txrx (s, txbuf, buflen, rxbuf, 8); free (txbuf); if (status != SANE_STATUS_GOOD) DBG(8, "%s: Parameters NOT successfully retrieved\n", __func__); else { DBG(8, "%s: Parameters successfully retrieved\n", __func__); /* Assign px_per_line and lines. Bytes 7-8 must match 3-4 */ if (rxbuf[2]!=rxbuf[6] || rxbuf[3]!=rxbuf[7]) { DBG (1, "%s: ERROR: Returned image parameters indicate an " "unsupported device: Bytes 3-4 do not match " "bytes 7-8! Trying to continue with bytes 3-4.\n", __func__); dump_hex_buffer_dense (1, rxbuf, 8); } /* Read returned values, encoded in 2-byte little endian */ *data_pixels = rxbuf[1] * 0x100 + rxbuf[0]; *lines = rxbuf[3] * 0x100 + rxbuf[2]; *pixels_per_line = rxbuf[5] * 0x100 + rxbuf[4]; DBG (8, "%s: data_pixels = 0x%x (%u), lines = 0x%x (%u), " "pixels_per_line = 0x%x (%u)\n", __func__, *data_pixels, *data_pixels, *lines, *lines, *pixels_per_line, *pixels_per_line); } return status; } /** 0x03 0c - Set scanning parameters command */ static SANE_Status cmd_set_scanning_parameters(SANE_Handle handle, unsigned char resolution, unsigned char color_mode, unsigned char brightness, unsigned char contrast, int tl_x, int tl_y, int width, int height, unsigned char source) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char param[0x11]; unsigned char *buf; size_t buflen; DBG(8, "%s\n", __func__); /* Copy over the params to the param byte array */ /* Byte structure: * byte 0: resolution * byte 1: color mode * byte 2: brightness * byte 3: 0xff * byte 4-5: x-start * byte 6-7: y-start * byte 8-9: x-extent * byte 10-11: y-extent * byte 12: source (ADF/FBF) **/ memset (¶m[0], 0x00, 0x11); param[0] = resolution; param[1] = color_mode; param[2] = brightness; param[3] = contrast | 0xff; /* TODO: Always 0xff? What about contrast? */ /* Image coordinates are encoded 2-byte little endian: */ param[4] = tl_x & 0xff; param[5] = (tl_x >> 8) & 0xff; param[6] = tl_y & 0xff; param[7] = (tl_y >> 8) & 0xff; param[8] = width & 0xff; param[9] = (width >> 8) & 0xff; param[10] = height & 0xff; param[11] = (height >> 8) & 0xff; param[12] = source; /* dump buffer if appropriate */ DBG (127, " Scanning parameter buffer:"); dump_hex_buffer_dense (127, param, 0x11); buflen = mc_create_buffer (s, s->hw->cmd->scanner_cmd, s->hw->cmd->set_scan_parameters, &buf, param, 0x11, &status); if (buflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } mc_send(s, buf, buflen, &status); free (buf); if (status != SANE_STATUS_GOOD) DBG(8, "%s: Data NOT successfully sent\n", __func__); else DBG(8, "%s: Data successfully sent\n", __func__); return status; } /** 0x03 ?? - Request push button status command */ #if 0 static SANE_Status cmd_request_push_button_status(SANE_Handle handle, unsigned char *bstatus) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char *buf; size_t buflen; DBG(8, "%s\n", __func__); if (s->hw->cmd->unknown1 == 0) return SANE_STATUS_UNSUPPORTED; DBG(8, "%s: Supported\n", __func__); memset (bstatus, 0x00, 1); buflen = mc_create_buffer (s, s->hw->cmd->scanner_cmd, s->hw->cmd->unknown1, &buf, bstatus, 1, &status); if (buflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } status = mc_txrx (s, buf, buflen, bstatus, 1); free(buf); if (status != SANE_STATUS_GOOD) return status; DBG(1, "push button status: %02x ", bstatus[0]); switch (bstatus[0]) { /* TODO: What's the response code for button pressed??? */ default: DBG(1, " unknown\n"); status = SANE_STATUS_UNSUPPORTED; } return status; } #endif /** 0x03 0e - Read data command */ static SANE_Status cmd_read_data (SANE_Handle handle, unsigned char *buf, size_t len) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; unsigned char *txbuf; unsigned char param[4]; size_t txbuflen; int oldtimeout = MC_Request_Timeout; DBG(8, "%s\n", __func__); param[0] = len & 0xff; param[1] = (len >> 8) & 0xff; param[2] = (len >> 16) & 0xff; param[3] = (len >> 24) & 0xff; txbuflen = mc_create_buffer (s, s->hw->cmd->scanner_cmd, s->hw->cmd->request_data, &txbuf, param, 4, &status); if (txbuflen <= 0 ) { return SANE_STATUS_NO_MEM; } else if (status != SANE_STATUS_GOOD) { return status; } /* Temporarily set the poll timeout to 10 seconds instead of 2, * because a color scan needs >5 seconds to initialize. */ MC_Request_Timeout = MC_Scan_Data_Timeout; status = mc_txrx (s, txbuf, txbuflen, buf, len); MC_Request_Timeout = oldtimeout; free (txbuf); if (status != SANE_STATUS_GOOD) DBG(8, "%s: Image data NOT successfully retrieved\n", __func__); else { DBG(8, "%s: Image data successfully retrieved\n", __func__); } return status; } /* TODO: 0x03 0f command (unknown), 0x03 10 command (set button wait) */ /**************************************************************************** * Magicolor backend high-level operations ****************************************************************************/ static void mc_dev_init(Magicolor_Device *dev, const char *devname, int conntype) { DBG(5, "%s\n", __func__); dev->name = NULL; dev->model = NULL; dev->connection = conntype; dev->sane.name = devname; dev->sane.model = NULL; dev->sane.type = "flatbed scanner"; dev->sane.vendor = "Magicolor"; dev->cap = &magicolor_cap[MAGICOLOR_CAP_DEFAULT]; dev->cmd = &magicolor_cmd[MAGICOLOR_LEVEL_DEFAULT]; /* Change default level when using a network connection */ if (dev->connection == SANE_MAGICOLOR_NET) dev->cmd = &magicolor_cmd[MAGICOLOR_LEVEL_NET]; } static SANE_Status mc_dev_post_init(struct Magicolor_Device *dev) { DBG(5, "%s\n", __func__); NOT_USED (dev); /* Correct device parameters if needed */ return SANE_STATUS_GOOD; } static SANE_Status mc_set_model(Magicolor_Scanner * s, const char *model, size_t len) { unsigned char *buf; unsigned char *p; struct Magicolor_Device *dev = s->hw; buf = malloc(len + 1); if (buf == NULL) return SANE_STATUS_NO_MEM; memcpy(buf, model, len); buf[len] = '\0'; p = &buf[len - 1]; while (*p == ' ') { *p = '\0'; p--; } if (dev->model) free(dev->model); dev->model = strndup((const char *) buf, len); dev->sane.model = dev->model; DBG(10, "%s: model is '%s'\n", __func__, dev->model); free(buf); return SANE_STATUS_GOOD; } static void mc_set_device (SANE_Handle handle, unsigned int device) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; Magicolor_Device *dev = s->hw; const char* cmd_level; int n; DBG(1, "%s: 0x%x\n", __func__, device); for (n = 0; n < NELEMS (magicolor_cap); n++) { if (magicolor_cap[n].id == device) break; } if (n < NELEMS(magicolor_cap)) { dev->cap = &magicolor_cap[n]; } else { dev->cap = &magicolor_cap[MAGICOLOR_CAP_DEFAULT]; DBG(1, " unknown device 0x%x, using default %s\n", device, dev->cap->model); } mc_set_model (s, dev->cap->model, strlen (dev->cap->model)); cmd_level = dev->cap->cmds; /* set command type and level */ for (n = 0; n < NELEMS(magicolor_cmd); n++) { if (!strcmp(cmd_level, magicolor_cmd[n].level)) break; } if (n < NELEMS(magicolor_cmd)) { dev->cmd = &magicolor_cmd[n]; } else { dev->cmd = &magicolor_cmd[MAGICOLOR_LEVEL_DEFAULT]; DBG(1, " unknown command level %s, using %s\n", cmd_level, dev->cmd->level); } } static SANE_Status mc_discover_capabilities(Magicolor_Scanner *s) { SANE_Status status; Magicolor_Device *dev = s->hw; SANE_String_Const *source_list_add = source_list; DBG(5, "%s\n", __func__); /* always add flatbed */ *source_list_add++ = FBF_STR; /* TODO: How can I check for existence of an ADF??? */ if (dev->cap->ADF) *source_list_add++ = ADF_STR; /* TODO: Is there any capability that we can extract from the * device by some scanne command? So far, it looks like * the device does not support any reporting. I don't even * see a way to determine which device we are talking to! */ /* request error status */ status = cmd_request_error(s); if (status != SANE_STATUS_GOOD) return status; dev->x_range = &dev->cap->fbf_x_range; dev->y_range = &dev->cap->fbf_y_range; DBG(5, " x-range: %f %f\n", SANE_UNFIX(dev->x_range->min), SANE_UNFIX(dev->x_range->max)); DBG(5, " y-range: %f %f\n", SANE_UNFIX(dev->y_range->min), SANE_UNFIX(dev->y_range->max)); DBG(5, "End of %s, status:%s\n", __func__, sane_strstatus(status)); *source_list_add = NULL; /* add end marker to source list */ return status; } static SANE_Status mc_setup_block_mode (Magicolor_Scanner *s) { /* block_len should always be a multiple of bytes_per_line, so * we retrieve only whole lines at once */ s->block_len = (int)(0xff00/s->scan_bytes_per_line) * s->scan_bytes_per_line; s->blocks = s->data_len / s->block_len; s->last_len = s->data_len - (s->blocks * s->block_len); if (s->last_len>0) s->blocks++; DBG(5, "%s: block_len=0x%x, last_len=0x%0x, blocks=%d\n", __func__, s->block_len, s->last_len, s->blocks); s->counter = 0; s->bytes_read_in_line = 0; if (s->line_buffer) free(s->line_buffer); s->line_buffer = malloc(s->scan_bytes_per_line); if (s->line_buffer == NULL) { DBG(1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } DBG (5, " %s: Setup block mode - scan_bytes_per_line=%d, pixels_per_line=%d, depth=%d, data_len=%x, block_len=%x, blocks=%d, last_len=%x\n", __func__, s->scan_bytes_per_line, s->params.pixels_per_line, s->params.depth, s->data_len, s->block_len, s->blocks, s->last_len); return SANE_STATUS_GOOD; } /* Call the 0x03 0c command to set scanning parameters from the s->opt list */ static SANE_Status mc_set_scanning_parameters(Magicolor_Scanner * s) { SANE_Status status; unsigned char rs, source, brightness; struct mode_param *mparam = &mode_params[s->val[OPT_MODE].w]; SANE_Int scan_pixels_per_line = 0; DBG(1, "%s\n", __func__); /* Find the resolution in the res list and assign the index to buf[1] */ for (rs=0; rs < s->hw->cap->res_list_size; rs++ ) { if ( s->val[OPT_RESOLUTION].w == s->hw->cap->res_list[rs] ) break; } if (SANE_OPTION_IS_ACTIVE(s->opt[OPT_BRIGHTNESS].cap)) { brightness = s->val[OPT_BRIGHTNESS].w; } else { brightness = 5; } /* ADF used? */ if (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) == 0) { /* Use ADF */ if (s->val[OPT_ADF_MODE].w == 0) { source = 0x01; } else { /* Use duplex */ source = 0x02; } } else { source = 0x00; } /* TODO: Any way to set PREVIEW??? */ /* Remaining bytes unused */ status = cmd_set_scanning_parameters(s, rs, mparam->flags, /* res, color mode */ brightness, 0xff, /* brightness, contrast? */ s->left, s->top, /* top/left start */ s->width, s->height, /* extent */ source); /* source */ if (status != SANE_STATUS_GOOD) DBG (2, "%s: Command cmd_set_scanning_parameters failed, %s\n", __func__, sane_strstatus(status)); /* Now query the scanner for the current image parameters */ status = cmd_get_scanning_parameters (s, &s->params.format, &s->params.depth, &scan_pixels_per_line, &s->params.pixels_per_line, &s->params.lines); if (status != SANE_STATUS_GOOD) { DBG (2, "%s: Command cmd_get_scanning_parameters failed, %s\n", __func__, sane_strstatus(status)); return status; } /* Calculate how many bytes are really used per line */ s->params.bytes_per_line = ceil (s->params.pixels_per_line * s->params.depth / 8.0); if (s->val[OPT_MODE].w == MODE_COLOR) s->params.bytes_per_line *= 3; /* Calculate how many bytes per line will be returned by the scanner. * The values needed for this are returned by get_scannign_parameters */ s->scan_bytes_per_line = ceil (scan_pixels_per_line * s->params.depth / 8.0); if (s->val[OPT_MODE].w == MODE_COLOR) { s->scan_bytes_per_line *= 3; } s->data_len = s->params.lines * s->scan_bytes_per_line; status = mc_setup_block_mode (s); if (status != SANE_STATUS_GOOD) DBG (2, "%s: Command mc_setup_block_mode failed, %s\n", __func__, sane_strstatus(status)); DBG (1, "%s: bytes_read in line: %d\n", __func__, s->bytes_read_in_line); return status; } static SANE_Status mc_check_adf(Magicolor_Scanner * s) { SANE_Status status; unsigned char buf[0x0b]; DBG(5, "%s\n", __func__); status = cmd_request_status(s, buf); if (status != SANE_STATUS_GOOD) return status; if (!(buf[1] & ADF_LOADED)) return SANE_STATUS_NO_DOCS; /* TODO: Check for jam in ADF */ return SANE_STATUS_GOOD; } static SANE_Status mc_scan_finish(Magicolor_Scanner * s) { SANE_Status status; DBG(5, "%s\n", __func__); /* If we have not yet read all data, cancel the scan */ if (s->buf && !s->eof) status = cmd_cancel_scan (s); if (s->line_buffer) free (s->line_buffer); s->line_buffer = NULL; free(s->buf); s->buf = s->end = s->ptr = NULL; /* TODO: Any magicolor command for "scan finished"? */ status = cmd_finish_scan (s); status = cmd_request_error(s); if (status != SANE_STATUS_GOOD) { cmd_cancel_scan (s); return status; } /* XXX required? */ /* TODO: cmd_reset(s);*/ return SANE_STATUS_GOOD; } static void mc_copy_image_data(Magicolor_Scanner * s, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { DBG (1, "%s: bytes_read in line: %d\n", __func__, s->bytes_read_in_line); if (s->params.format == SANE_FRAME_RGB) { SANE_Int bytes_available, scan_pixels_per_line = s->scan_bytes_per_line/3; *length = 0; while ((max_length >= s->params.bytes_per_line) && (s->ptr < s->end)) { SANE_Int bytes_to_copy = s->scan_bytes_per_line - s->bytes_read_in_line; /* First, fill the line buffer for the current line: */ bytes_available = (s->end - s->ptr); /* Don't copy more than we have buffer and available */ if (bytes_to_copy > bytes_available) bytes_to_copy = bytes_available; if (bytes_to_copy > 0) { memcpy (s->line_buffer + s->bytes_read_in_line, s->ptr, bytes_to_copy); s->ptr += bytes_to_copy; s->bytes_read_in_line += bytes_to_copy; } /* We have filled as much as possible of the current line * with data from the scanner. If we have a complete line, * copy it over. */ if ((s->bytes_read_in_line >= s->scan_bytes_per_line) && (s->params.bytes_per_line <= max_length)) { SANE_Int i; SANE_Byte *line = s->line_buffer; *length += s->params.bytes_per_line; for (i=0; i< s->params.pixels_per_line; ++i) { *data++ = line[0]; *data++ = line[scan_pixels_per_line]; *data++ = line[2 * scan_pixels_per_line]; line++; } max_length -= s->params.bytes_per_line; s->bytes_read_in_line -= s->scan_bytes_per_line; } } } else { /* B/W and Grayscale use the same structure, so we use the same code */ SANE_Int bytes_available; *length = 0; while ((max_length != 0) && (s->ptr < s->end)) { SANE_Int bytes_to_skip, bytes_to_copy; bytes_available = (s->end - s->ptr); bytes_to_copy = s->params.bytes_per_line - s->bytes_read_in_line; bytes_to_skip = s->scan_bytes_per_line - s->bytes_read_in_line; /* Don't copy more than we have buffer */ if (bytes_to_copy > max_length) { bytes_to_copy = max_length; bytes_to_skip = max_length; } /* Don't copy/skip more bytes than we have read in */ if (bytes_to_copy > bytes_available) bytes_to_copy = bytes_available; if (bytes_to_skip > bytes_available) bytes_to_skip = bytes_available; if (bytes_to_copy > 0) { /* we have not yet copied all pixels of the line */ memcpy (data, s->ptr, bytes_to_copy); max_length -= bytes_to_copy; *length += bytes_to_copy; data += bytes_to_copy; } if (bytes_to_skip > 0) { s->ptr += bytes_to_skip; s->bytes_read_in_line += bytes_to_skip; } if (s->bytes_read_in_line >= s->scan_bytes_per_line) s->bytes_read_in_line -= s->scan_bytes_per_line; } } } static SANE_Status mc_init_parameters(Magicolor_Scanner * s) { int dpi, optres; DBG(5, "%s\n", __func__); memset(&s->params, 0, sizeof(SANE_Parameters)); dpi = s->val[OPT_RESOLUTION].w; optres = s->hw->cap->optical_res; if (SANE_UNFIX(s->val[OPT_BR_Y].w) == 0 || SANE_UNFIX(s->val[OPT_BR_X].w) == 0) return SANE_STATUS_INVAL; /* TODO: Use OPT_RESOLUTION or fixed 600dpi for left/top/width/height? */ s->left = ((SANE_UNFIX(s->val[OPT_TL_X].w) / MM_PER_INCH) * optres) + 0.5; s->top = ((SANE_UNFIX(s->val[OPT_TL_Y].w) / MM_PER_INCH) * optres) + 0.5; s->width = ((SANE_UNFIX(s->val[OPT_BR_X].w - s->val[OPT_TL_X].w) / MM_PER_INCH) * optres) + 0.5; s->height = ((SANE_UNFIX(s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w) / MM_PER_INCH) * optres) + 0.5; s->params.pixels_per_line = s->width * dpi / optres + 0.5; s->params.lines = s->height * dpi / optres + 0.5; DBG(1, "%s: resolution = %d, preview = %d\n", __func__, dpi, s->val[OPT_PREVIEW].w); DBG(1, "%s: %p %p tlx %f tly %f brx %f bry %f [mm]\n", __func__, (void *) s, (void *) s->val, SANE_UNFIX(s->val[OPT_TL_X].w), SANE_UNFIX(s->val[OPT_TL_Y].w), SANE_UNFIX(s->val[OPT_BR_X].w), SANE_UNFIX(s->val[OPT_BR_Y].w)); /* * The default color depth is stored in mode_params.depth: */ DBG(1, " %s, vor depth\n", __func__); if (mode_params[s->val[OPT_MODE].w].depth == 1) s->params.depth = 1; else s->params.depth = s->val[OPT_BIT_DEPTH].w; s->params.last_frame = SANE_TRUE; s->params.bytes_per_line = ceil (s->params.depth * s->params.pixels_per_line / 8.0); switch (s->val[OPT_MODE].w) { case MODE_BINARY: case MODE_GRAY: s->params.format = SANE_FRAME_GRAY; break; case MODE_COLOR: s->params.format = SANE_FRAME_RGB; s->params.bytes_per_line *= 3; break; } DBG(1, "%s: Parameters are format=%d, bytes_per_line=%d, lines=%d\n", __func__, s->params.format, s->params.bytes_per_line, s->params.lines); return (s->params.lines > 0) ? SANE_STATUS_GOOD : SANE_STATUS_INVAL; } static SANE_Status mc_start_scan(Magicolor_Scanner * s) { SANE_Status status = cmd_start_scan (s, s->data_len); if (status != SANE_STATUS_GOOD ) { DBG (1, "%s: starting the scan failed (%s)\n", __func__, sane_strstatus(status)); } return status; } static SANE_Status mc_read(struct Magicolor_Scanner *s) { SANE_Status status = SANE_STATUS_GOOD; ssize_t buf_len = 0; /* did we passed everything we read to sane? */ if (s->ptr == s->end) { if (s->eof) return SANE_STATUS_EOF; s->counter++; buf_len = s->block_len; if (s->counter == s->blocks && s->last_len) buf_len = s->last_len; DBG(18, "%s: block %d/%d, size %lu\n", __func__, s->counter, s->blocks, (unsigned long) buf_len); /* receive image data + error code */ status = cmd_read_data (s, s->buf, buf_len); if (status != SANE_STATUS_GOOD) { DBG (1, "%s: Receiving image data failed (%s)\n", __func__, sane_strstatus(status)); cmd_cancel_scan(s); return status; } DBG(18, "%s: successfully read %lu bytes\n", __func__, (unsigned long) buf_len); if (s->counter < s->blocks) { if (s->canceling) { cmd_cancel_scan(s); return SANE_STATUS_CANCELLED; } } else s->eof = SANE_TRUE; s->end = s->buf + buf_len; s->ptr = s->buf; } return status; } /**************************************************************************** * SANE API implementation (high-level functions) ****************************************************************************/ #if HAVE_LIBSNMP static struct MagicolorCap * mc_get_device_from_identification (const char*ident) { int n; for (n = 0; n < NELEMS (magicolor_cap); n++) { if (strcmp (magicolor_cap[n].model, ident) || strcmp (magicolor_cap[n].OID, ident)) return &magicolor_cap[n]; } return NULL; } #endif /* * close_scanner() * * Close the open scanner. Depending on the connection method, a different * close function is called. */ static void close_scanner(Magicolor_Scanner *s) { DBG(7, "%s: fd = %d\n", __func__, s->fd); if (s->fd == -1) return; mc_scan_finish(s); if (s->hw->connection == SANE_MAGICOLOR_NET) { sanei_magicolor_net_close(s); sanei_tcp_close(s->fd); } else if (s->hw->connection == SANE_MAGICOLOR_USB) { sanei_usb_close(s->fd); } s->fd = -1; } static SANE_Bool split_scanner_name (const char *name, char * IP, unsigned int *model) { const char *device = name; const char *qm; *model = 0; /* cut off leading net: */ if (strncmp(device, "net:", 4) == 0) device = &device[4]; qm = strchr(device, '?'); if (qm != NULL) { size_t len = qm-device; strncpy (IP, device, len); IP[len] = '\0'; qm++; if (strncmp(qm, "model=", 6) == 0) { qm += 6; if (!sscanf(qm, "0x%x", model)) sscanf(qm, "%x", model); } } else { strcpy (IP, device); } return SANE_TRUE; } /* * open_scanner() * * Open the scanner device. Depending on the connection method, * different open functions are called. */ static SANE_Status open_scanner(Magicolor_Scanner *s) { SANE_Status status = 0; DBG(7, "%s: %s\n", __func__, s->hw->sane.name); if (s->fd != -1) { DBG(7, "scanner is already open: fd = %d\n", s->fd); return SANE_STATUS_GOOD; /* no need to open the scanner */ } if (s->hw->connection == SANE_MAGICOLOR_NET) { /* device name has the form net:ipaddr?model=... */ char IP[1024]; unsigned int model = 0; if (!split_scanner_name (s->hw->sane.name, IP, &model)) return SANE_STATUS_INVAL; status = sanei_tcp_open(IP, 4567, &s->fd); if (model>0) mc_set_device (s, model); if (status == SANE_STATUS_GOOD) { DBG(7, "awaiting welcome message\n"); status = sanei_magicolor_net_open (s); } } else if (s->hw->connection == SANE_MAGICOLOR_USB) { status = sanei_usb_open(s->hw->sane.name, &s->fd); if (s->hw->cap->out_ep>0) sanei_usb_set_endpoint (s->fd, USB_DIR_OUT | USB_ENDPOINT_TYPE_BULK, s->hw->cap->out_ep); if (s->hw->cap->in_ep>0) sanei_usb_set_endpoint (s->fd, USB_DIR_IN | USB_ENDPOINT_TYPE_BULK, s->hw->cap->in_ep); } if (status == SANE_STATUS_ACCESS_DENIED) { DBG(1, "please check that you have permissions on the device.\n"); DBG(1, "if this is a multi-function device with a printer,\n"); DBG(1, "disable any conflicting driver (like usblp).\n"); } if (status != SANE_STATUS_GOOD) DBG(1, "%s open failed: %s\n", s->hw->sane.name, sane_strstatus(status)); else DBG(3, "scanner opened\n"); return status; } static SANE_Status detect_usb(struct Magicolor_Scanner *s) { SANE_Status status; int vendor, product; int i, numIds; SANE_Bool is_valid; /* if the sanei_usb_get_vendor_product call is not supported, * then we just ignore this and rely on the user to config * the correct device. */ status = sanei_usb_get_vendor_product(s->fd, &vendor, &product); if (status != SANE_STATUS_GOOD) { DBG(1, "the device cannot be verified - will continue\n"); return SANE_STATUS_GOOD; } /* check the vendor ID to see if we are dealing with an MAGICOLOR device */ if (vendor != SANE_MAGICOLOR_VENDOR_ID) { /* this is not a supported vendor ID */ DBG(1, "not an Magicolor device at %s (vendor id=0x%x)\n", s->hw->sane.name, vendor); return SANE_STATUS_INVAL; } numIds = sanei_magicolor_getNumberOfUSBProductIds(); is_valid = SANE_FALSE; i = 0; /* check all known product IDs to verify that we know * about the device */ while (i != numIds && !is_valid) { if (product == sanei_magicolor_usb_product_ids[i]) is_valid = SANE_TRUE; i++; } if (is_valid == SANE_FALSE) { DBG(1, "the device at %s is not a supported (product id=0x%x)\n", s->hw->sane.name, product); return SANE_STATUS_INVAL; } DBG(2, "found valid Magicolor scanner: 0x%x/0x%x (vendorID/productID)\n", vendor, product); mc_set_device(s, product); return SANE_STATUS_GOOD; } /* * used by attach* and sane_get_devices * a ptr to a single-linked list of Magicolor_Device structs * a ptr to a null term array of ptrs to SANE_Device structs */ static int num_devices; /* number of scanners attached to backend */ static Magicolor_Device *first_dev; /* first MAGICOLOR scanner in list */ static const SANE_Device **devlist = NULL; static struct Magicolor_Scanner * scanner_create(struct Magicolor_Device *dev, SANE_Status *status) { struct Magicolor_Scanner *s; s = malloc(sizeof(struct Magicolor_Scanner)); if (s == NULL) { *status = SANE_STATUS_NO_MEM; return NULL; } memset(s, 0x00, sizeof(struct Magicolor_Scanner)); s->fd = -1; s->hw = dev; return s; } static struct Magicolor_Scanner * device_detect(const char *name, int type, SANE_Status *status) { struct Magicolor_Scanner *s; struct Magicolor_Device *dev; /* try to find the device in our list */ for (dev = first_dev; dev; dev = dev->next) { if (strcmp(dev->sane.name, name) == 0) { dev->missing = 0; DBG (10, "%s: Device %s already attached!\n", __func__, name); return scanner_create(dev, status); } } if (type == SANE_MAGICOLOR_NODEV) { *status = SANE_STATUS_INVAL; return NULL; } /* alloc and clear our device structure */ dev = malloc(sizeof(*dev)); if (!dev) { *status = SANE_STATUS_NO_MEM; return NULL; } memset(dev, 0x00, sizeof(struct Magicolor_Device)); s = scanner_create(dev, status); if (s == NULL) return NULL; mc_dev_init(dev, name, type); *status = open_scanner(s); if (*status != SANE_STATUS_GOOD) { free(s); return NULL; } /* from now on, close_scanner() must be called */ /* USB requires special care */ if (dev->connection == SANE_MAGICOLOR_USB) { *status = detect_usb(s); } if (*status != SANE_STATUS_GOOD) goto close; /* set name and model (if not already set) */ if (dev->model == NULL) mc_set_model(s, "generic", 7); dev->name = strdup(name); dev->sane.name = dev->name; *status = mc_discover_capabilities(s); if (*status != SANE_STATUS_GOOD) goto close; if (source_list[0] == NULL || dev->cap->dpi_range.min == 0) { DBG(1, "something is wrong in the discovery process, aborting.\n"); *status = SANE_STATUS_IO_ERROR; goto close; } mc_dev_post_init(dev); /* add this scanner to the device list */ num_devices++; dev->missing = 0; dev->next = first_dev; first_dev = dev; return s; close: close_scanner(s); free(s); return NULL; } #if HAVE_LIBSNMP /* Keep a linked list of already observed IP addresses */ /* typedef struct snmp_ip SNMP_IP; */ typedef struct snmp_ip { char ip_addr[1024]; struct snmp_ip*next; } snmp_ip; typedef struct { int nr; snmp_ip*handled; snmp_ip*detected; } snmp_discovery_data; /** Handle one SNMP response (whether received sync or async) and if describes * a magicolor device, attach it. Returns the number of attached devices (0 * or 1) */ static int mc_network_discovery_handle (struct snmp_pdu *pdu, snmp_discovery_data *magic) { netsnmp_variable_list *varlist = pdu->variables, *vp; oid anOID[MAX_OID_LEN]; size_t anOID_len = MAX_OID_LEN; /* Device information variables */ char ip_addr[1024]; char model[1024]; char device[1024]; /* remote IP detection variables */ netsnmp_indexed_addr_pair *responder = (netsnmp_indexed_addr_pair *) pdu->transport_data; struct sockaddr_in *remote = NULL; struct MagicolorCap *cap; snmp_ip *ip = NULL; DBG(5, "%s: Handling SNMP response \n", __func__); if (responder == NULL || pdu->transport_data_length != sizeof(netsnmp_indexed_addr_pair )) { DBG(1, "%s: Unable to extract IP address from SNMP response.\n", __func__); return 0; } remote = (struct sockaddr_in *) &(responder->remote_addr); if (remote == NULL) { DBG(1, "%s: Unable to extract IP address from SNMP response.\n", __func__); return 0; } snprintf(ip_addr, sizeof(ip_addr), "%s", inet_ntoa(remote->sin_addr)); DBG(35, "%s: IP Address of responder is %s\n", __func__, ip_addr); if (magic) ip = magic->handled; while (ip) { if (strcmp (ip->ip_addr, ip_addr) == 0) { DBG (5, "%s: Already handled device %s, skipping\n", __func__, ip_addr); return 0; } ip = ip->next; } if (magic) { snmp_ip *new_handled = malloc(sizeof(snmp_ip)); strcpy (&new_handled->ip_addr[0], ip_addr); new_handled->next = magic->handled; magic->handled = new_handled; } /* System Object ID (Unique OID identifying model) * This determines whether we really have a magicolor device */ anOID_len = MAX_OID_LEN; read_objid(MAGICOLOR_SNMP_SYSOBJECT_OID, anOID, &anOID_len); vp = find_varbind_in_list (varlist, anOID, anOID_len); if (vp) { size_t value_len = vp->val_len/sizeof(oid); if (vp->type != ASN_OBJECT_ID) { DBG (3, "%s: SystemObjectID does not return an OID, device is not a magicolor device\n", __func__); return 0; } snprint_objid (device, sizeof(device), vp->val.objid, value_len); DBG (5, "%s: Device object ID is '%s'\n", __func__, device); anOID_len = MAX_OID_LEN; read_objid (MAGICOLOR_SNMP_DEVICE_TREE, anOID, &anOID_len); if (netsnmp_oid_is_subtree (anOID, anOID_len, vp->val.objid, value_len) == 0) { DBG (5, "%s: Device appears to be a magicolor device (OID=%s)\n", __func__, device); } else { DBG (5, "%s: Device is not a Magicolor device\n", __func__); return 0; } } /* Retrieve sysDescr (i.e. model name) */ anOID_len = MAX_OID_LEN; read_objid(MAGICOLOR_SNMP_SYSDESCR_OID, anOID, &anOID_len); vp = find_varbind_in_list (varlist, anOID, anOID_len); if (vp) { memcpy(model,vp->val.string,vp->val_len); model[vp->val_len] = '\0'; DBG (5, "%s: Found model: %s\n", __func__, model); } DBG (1, "%s: Detected device '%s' on IP %s\n", __func__, model, ip_addr); vp = pdu->variables; /* TODO: attach the IP with attach_one_net(ip) */ cap = mc_get_device_from_identification (device); if (cap) { DBG(1, "%s: Found autodiscovered device: %s (type 0x%x)\n", __func__, cap->model, cap->id); attach_one_net (ip_addr, cap->id); if (magic) { snmp_ip *new_detected = malloc(sizeof(snmp_ip)); strcpy (&new_detected->ip_addr[0], ip_addr); new_detected->next = magic->detected; magic->detected = new_detected; } return 1; } return 0; } static int mc_network_discovery_cb (int operation, struct snmp_session *sp, int reqid, struct snmp_pdu *pdu, void *magic) { NOT_USED (reqid); NOT_USED (sp); DBG(5, "%s: Received broadcast response \n", __func__); if (operation == NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE) { snmp_discovery_data *m = (snmp_discovery_data*)magic; int nr = mc_network_discovery_handle (pdu, m); m->nr += nr; DBG(5, "%s: Added %d discovered host(s) for SNMP response.\n", __func__, nr); } return 0; } #endif /* Use SNMP for automatic network discovery. If host is given, try to detect * that one host (using sync SNMP, otherwise send an SNMP broadcast (async). */ static int mc_network_discovery(const char*host) { #if HAVE_LIBSNMP netsnmp_session session, *ss; netsnmp_pdu *pdu; oid anOID[MAX_OID_LEN]; size_t anOID_len = MAX_OID_LEN; snmp_discovery_data magic; magic.nr = 0; magic.handled = 0; magic.detected = 0; DBG(1, "%s: running network discovery \n", __func__); /* Win32: init winsock */ SOCK_STARTUP; init_snmp("sane-magicolor-backend"); snmp_sess_init (&session); session.version = SNMP_VERSION_2c; session.community = (u_char *) "public"; session.community_len = strlen ((char *)session.community); if (host) { session.peername = (char *) host; } else { /* Do a network discovery via a broadcast */ session.peername = "255.255.255.255"; session.flags |= SNMP_FLAGS_UDP_BROADCAST; session.callback = mc_network_discovery_cb; session.callback_magic = &magic; } ss = snmp_open (&session); /* establish the session */ if (!ss) { snmp_sess_perror ("ack", &session); SOCK_CLEANUP; return 0; } /* Create the PDU for the data for our request and add the three * desired OIDs to the PDU */ pdu = snmp_pdu_create (SNMP_MSG_GET); /* SNMPv2-MIB::sysDescr.0 */ anOID_len = MAX_OID_LEN; if (read_objid(MAGICOLOR_SNMP_SYSDESCR_OID, anOID, &anOID_len)) { snmp_add_null_var (pdu, anOID, anOID_len); } /* SNMPv2-MIB::sysObjectID.0 */ anOID_len = MAX_OID_LEN; if (read_objid(MAGICOLOR_SNMP_SYSOBJECT_OID, anOID, &anOID_len)) { snmp_add_null_var (pdu, anOID, anOID_len); } /* IF-MIB::ifPhysAddress.1 */ anOID_len = MAX_OID_LEN; if (read_objid(MAGICOLOR_SNMP_MAC_OID, anOID, &anOID_len)) { snmp_add_null_var (pdu, anOID, anOID_len); } /* TODO: Add more interesting OIDs, in particular vendor OIDs */ /* Now send out the request and wait for responses for some time. * If we get a response, connect to that device (in the callback), * otherwise we probably don't have a magicolor device in the * LAN (or SNMP is turned off, in which case we have no way to detect * it. */ DBG(100, "%s: Sending SNMP packet\n", __func__); if (host) { /* sync request to given hostname, immediately read the reply */ netsnmp_pdu *response = 0; int status = snmp_synch_response(ss, pdu, &response); if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR) { magic.nr = mc_network_discovery_handle (response, &magic); } if (response) snmp_free_pdu(response); } else { /* No hostname, so do a broadcast */ struct timeval nowtime, endtime; /* end time for SNMP scan */ struct timeval timeout; int i=0; if (!snmp_send(ss, pdu)) { snmp_free_pdu(pdu); DBG(100, "%s: Sending SNMP packet NOT successful\n", __func__); return 0; } /* listen for responses for MC_AutoDetectionTimeout milliseconds: */ /* First get the final timeout time */ gettimeofday (&nowtime, NULL); timeout.tv_sec = MC_SNMP_Timeout / 1000; timeout.tv_usec = (MC_SNMP_Timeout % 1000) * 1000; timeradd (&nowtime, &timeout, &endtime); while (timercmp(&nowtime, &endtime, <)) { int fds = 0, block = 0; fd_set fdset; DBG(1, " loop=%d\n", i++); timeout.tv_sec = 0; /* Use a 125ms timeout for select. If we get a response, * the loop will be entered earlier again, anyway */ timeout.tv_usec = 125000; FD_ZERO (&fdset); snmp_select_info (&fds, &fdset, &timeout, &block); fds = select (fds, &fdset, NULL, NULL, /*block?NULL:*/&timeout); if (fds) snmp_read(&fdset); else snmp_timeout(); gettimeofday(&nowtime, NULL); } /* Clean up the data in magic */ while (magic.handled) { snmp_ip *tmp = magic.handled->next; free (magic.handled); magic.handled = tmp; } while (magic.detected) { snmp_ip *tmp = magic.detected->next; free (magic.detected); magic.detected = tmp; } } /* Clean up */ snmp_close(ss); SOCK_CLEANUP; DBG (5, "%s: Discovered %d host(s)\n", __func__, magic.nr); return magic.nr; #else DBG (1, "%s: net-snmp library not enabled, auto-detecting network scanners not supported.\n", __func__); NOT_USED (host); return 0; #endif } static SANE_Status attach(const char *name, int type) { SANE_Status status; Magicolor_Scanner *s; DBG(7, "%s: devname = %s, type = %d\n", __func__, name, type); s = device_detect(name, type, &status); if(s == NULL) return status; close_scanner(s); free(s); return status; } SANE_Status attach_one_usb(const char *dev) { DBG(7, "%s: dev = %s\n", __func__, dev); return attach(dev, SANE_MAGICOLOR_USB); } static SANE_Status attach_one_net(const char *dev, unsigned int model) { char name[1024]; DBG(7, "%s: dev = %s\n", __func__, dev); if (model > 0) { snprintf(name, 1024, "net:%s?model=0x%x", dev, model); } else { snprintf(name, 1024, "net:%s", dev); } return attach(name, SANE_MAGICOLOR_NET); } static SANE_Status attach_one_config(SANEI_Config __sane_unused__ *config, const char *line) { int vendor, product, timeout; int len = strlen(line); DBG(7, "%s: len = %d, line = %s\n", __func__, len, line); if (sscanf(line, "usb %i %i", &vendor, &product) == 2) { /* add the vendor and product IDs to the list of * known devices before we call the attach function */ int numIds = sanei_magicolor_getNumberOfUSBProductIds(); if (vendor != SANE_MAGICOLOR_VENDOR_ID) return SANE_STATUS_INVAL; /* this is not a KONICA MINOLTA device */ sanei_magicolor_usb_product_ids[numIds - 1] = product; sanei_usb_attach_matching_devices(line, attach_one_usb); } else if (strncmp(line, "usb", 3) == 0 && len == 3) { int i, numIds; numIds = sanei_magicolor_getNumberOfUSBProductIds(); for (i = 0; i < numIds; i++) { sanei_usb_find_devices(SANE_MAGICOLOR_VENDOR_ID, sanei_magicolor_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); char IP[1024]; unsigned int model = 0; if (strncmp(name, "autodiscovery", 13) == 0) { DBG (50, "%s: Initiating network autodiscovervy via SNMP\n", __func__); mc_network_discovery(NULL); } else if (sscanf(name, "%s %x", IP, &model) == 2) { DBG(50, "%s: Using network device on IP %s, forcing model 0x%x\n", __func__, IP, model); attach_one_net(IP, model); } else { /* use SNMP to detect the type. If not successful, * add the host with model type 0 */ DBG(50, "%s: Using network device on IP %s, trying to autodetect model\n", __func__, IP); if (mc_network_discovery(name)==0) { DBG(1, "%s: Autodetecting device model failed, using default model\n", __func__); attach_one_net(name, 0); } } } else if (sscanf(line, "snmp-timeout %i\n", &timeout)) { /* Timeout for SNMP network discovery */ DBG(50, "%s: SNMP timeout set to %d\n", __func__, timeout); MC_SNMP_Timeout = timeout; } else if (sscanf(line, "scan-data-timeout %i\n", &timeout)) { /* Timeout for scan data requests */ DBG(50, "%s: Scan data timeout set to %d\n", __func__, timeout); MC_Scan_Data_Timeout = timeout; } else if (sscanf(line, "request-timeout %i\n", &timeout)) { /* Timeout for all other read requests */ DBG(50, "%s: Request timeout set to %d\n", __func__, timeout); MC_Request_Timeout = timeout; } else { /* TODO: Warning about unparsable line! */ } return SANE_STATUS_GOOD; } static void free_devices(void) { Magicolor_Device *dev, *next; DBG(5, "%s\n", __func__); for (dev = first_dev; dev; dev = next) { next = dev->next; free(dev->name); free(dev->model); free(dev); } if (devlist) free(devlist); devlist = NULL; first_dev = NULL; } SANE_Status sane_init(SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize) { DBG_INIT(); DBG(2, "%s: " PACKAGE " " VERSION "\n", __func__); DBG(1, "magicolor backend, version %i.%i.%i\n", MAGICOLOR_VERSION, MAGICOLOR_REVISION, MAGICOLOR_BUILD); if (version_code != NULL) *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, MAGICOLOR_BUILD); sanei_usb_init(); return SANE_STATUS_GOOD; } /* Clean up the list of attached scanners. */ void sane_exit(void) { DBG(5, "%s\n", __func__); free_devices(); } SANE_Status sane_get_devices(const SANE_Device ***device_list, SANE_Bool __sane_unused__ local_only) { Magicolor_Device *dev, *s, *prev=0; int i; DBG(5, "%s\n", __func__); sanei_usb_init(); /* mark all existing scanners as missing, attach_one will remove mark */ for (s = first_dev; s; s = s->next) { s->missing = 1; } /* Read the config, mark each device as found, possibly add new devs */ sanei_configure_attach(MAGICOLOR_CONFIG_FILE, NULL, attach_one_config); /*delete missing scanners from list*/ for (s = first_dev; s;) { if (s->missing) { DBG (5, "%s: missing scanner %s\n", __func__, s->name); /*splice s out of list by changing pointer in prev to next*/ if (prev) { prev->next = s->next; free (s); s = prev->next; num_devices--; } else { /*remove s from head of list */ first_dev = s->next; free(s); s = first_dev; prev=NULL; num_devices--; } } else { prev = s; s = prev->next; } } DBG (15, "%s: found %d scanner(s)\n", __func__, num_devices); for (s = first_dev; s; s=s->next) { DBG (15, "%s: found scanner %s\n", __func__, s->name); } if (devlist) free (devlist); devlist = malloc((num_devices + 1) * sizeof(devlist[0])); if (!devlist) { DBG(1, "out of memory (line %d)\n", __LINE__); return SANE_STATUS_NO_MEM; } DBG(5, "%s - results:\n", __func__); for (i = 0, dev = first_dev; i < num_devices && dev; dev = dev->next, i++) { DBG(1, " %d (%d): %s\n", i, dev->connection, dev->model); devlist[i] = &dev->sane; } devlist[i] = NULL; if(device_list){ *device_list = devlist; } return SANE_STATUS_GOOD; } static SANE_Status init_options(Magicolor_Scanner *s) { int i; SANE_Word *res_list; for (i = 0; i < NUM_OPTIONS; i++) { s->opt[i].size = sizeof(SANE_Word); s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Scan Mode" group: */ s->opt[OPT_MODE_GROUP].name = SANE_NAME_STANDARD; s->opt[OPT_MODE_GROUP].title = SANE_TITLE_STANDARD; s->opt[OPT_MODE_GROUP].desc = SANE_DESC_STANDARD; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].cap = 0; /* scan mode */ s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].size = max_string_size(mode_list); s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].w = 0; /* Binary */ /* bit depth */ s->opt[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; s->opt[OPT_BIT_DEPTH].type = SANE_TYPE_INT; s->opt[OPT_BIT_DEPTH].unit = SANE_UNIT_NONE; s->opt[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->opt[OPT_BIT_DEPTH].constraint.word_list = s->hw->cap->depth_list; s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; s->val[OPT_BIT_DEPTH].w = s->hw->cap->depth_list[1]; /* the first "real" element is the default */ if (s->hw->cap->depth_list[0] == 1) /* only one element in the list -> hide the option */ s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; /* brightness */ s->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BRIGHTNESS].constraint.range = &s->hw->cap->brightness; s->val[OPT_BRIGHTNESS].w = 5; /* Normal */ /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; res_list = malloc((s->hw->cap->res_list_size + 1) * sizeof(SANE_Word)); if (res_list == NULL) { return SANE_STATUS_NO_MEM; } *(res_list) = s->hw->cap->res_list_size; memcpy(&(res_list[1]), s->hw->cap->res_list, s->hw->cap->res_list_size * sizeof(SANE_Word)); s->opt[OPT_RESOLUTION].constraint.word_list = res_list; s->val[OPT_RESOLUTION].w = s->hw->cap->dpi_range.min; /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_PREVIEW].w = SANE_FALSE; /* source */ s->opt[OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; s->opt[OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; s->opt[OPT_SOURCE].type = SANE_TYPE_STRING; s->opt[OPT_SOURCE].size = max_string_size(source_list); s->opt[OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_SOURCE].constraint.string_list = source_list; s->val[OPT_SOURCE].w = 0; /* always use Flatbed as default */ s->opt[OPT_ADF_MODE].name = "adf-mode"; s->opt[OPT_ADF_MODE].title = SANE_I18N("ADF Mode"); s->opt[OPT_ADF_MODE].desc = SANE_I18N("Selects the ADF mode (simplex/duplex)"); s->opt[OPT_ADF_MODE].type = SANE_TYPE_STRING; s->opt[OPT_ADF_MODE].size = max_string_size(adf_mode_list); s->opt[OPT_ADF_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_ADF_MODE].constraint.string_list = adf_mode_list; s->val[OPT_ADF_MODE].w = 0; /* simplex */ if ((!s->hw->cap->ADF) || (s->hw->cap->adf_duplex == SANE_FALSE)) s->opt[OPT_ADF_MODE].cap |= SANE_CAP_INACTIVE; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].name = SANE_NAME_GEOMETRY; s->opt[OPT_GEOMETRY_GROUP].title = SANE_TITLE_GEOMETRY; s->opt[OPT_GEOMETRY_GROUP].desc = SANE_DESC_GEOMETRY; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = s->hw->x_range; s->val[OPT_TL_X].w = 0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = s->hw->y_range; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = s->hw->x_range; s->val[OPT_BR_X].w = s->hw->x_range->max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = s->hw->y_range; s->val[OPT_BR_Y].w = s->hw->y_range->max; return SANE_STATUS_GOOD; } SANE_Status sane_open(SANE_String_Const name, SANE_Handle *handle) { SANE_Status status; Magicolor_Scanner *s = NULL; int l = strlen(name); DBG(7, "%s: name = %s\n", __func__, name); /* probe if empty device name provided */ if (l == 0) { status = sane_get_devices(NULL,0); if (status != SANE_STATUS_GOOD) { return status; } if (first_dev == NULL) { DBG(1, "no device detected\n"); return SANE_STATUS_INVAL; } s = device_detect(first_dev->sane.name, first_dev->connection, &status); if (s == NULL) { DBG(1, "cannot open a perfectly valid device (%s)," " please report to the authors\n", name); return SANE_STATUS_INVAL; } } else { if (strncmp(name, "net:", 4) == 0) { s = device_detect(name, SANE_MAGICOLOR_NET, &status); if (s == NULL) return status; } else if (strncmp(name, "libusb:", 7) == 0) { s = device_detect(name, SANE_MAGICOLOR_USB, &status); if (s == NULL) return status; } else { /* as a last resort, check for a match * in the device list. This should handle platforms without libusb. */ if (first_dev == NULL) { status = sane_get_devices(NULL,0); if (status != SANE_STATUS_GOOD) { return status; } } s = device_detect(name, SANE_MAGICOLOR_NODEV, &status); if (s == NULL) { DBG(1, "invalid device name: %s\n", name); return SANE_STATUS_INVAL; } } } /* s is always valid here */ DBG(1, "handle obtained\n"); init_options(s); *handle = (SANE_Handle) s; status = open_scanner(s); if (status != SANE_STATUS_GOOD) { free(s); return status; } return status; } void sane_close(SANE_Handle handle) { Magicolor_Scanner *s; /* * XXX Test if there is still data pending from * the scanner. If so, then do a cancel */ s = (Magicolor_Scanner *) handle; if (s->fd != -1) close_scanner(s); free(s); } const SANE_Option_Descriptor * sane_get_option_descriptor(SANE_Handle handle, SANE_Int option) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; if (option < 0 || option >= NUM_OPTIONS) return NULL; return s->opt + option; } static const SANE_String_Const * search_string_list(const SANE_String_Const *list, SANE_String value) { while (*list != NULL && strcmp(value, *list) != 0) list++; return ((*list == NULL) ? NULL : list); } /* Activate, deactivate an option. Subroutines so we can add debugging info if we want. The change flag is set to TRUE if we changed an option. If we did not change an option, then the value of the changed flag is not modified. */ static void activateOption(Magicolor_Scanner *s, SANE_Int option, SANE_Bool *change) { if (!SANE_OPTION_IS_ACTIVE(s->opt[option].cap)) { s->opt[option].cap &= ~SANE_CAP_INACTIVE; *change = SANE_TRUE; } } static void deactivateOption(Magicolor_Scanner *s, SANE_Int option, SANE_Bool *change) { if (SANE_OPTION_IS_ACTIVE(s->opt[option].cap)) { s->opt[option].cap |= SANE_CAP_INACTIVE; *change = SANE_TRUE; } } static SANE_Status getvalue(SANE_Handle handle, SANE_Int option, void *value) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Option_Descriptor *sopt = &(s->opt[option]); Option_Value *sval = &(s->val[option]); DBG(17, "%s: option = %d\n", __func__, option); switch (option) { case OPT_NUM_OPTS: case OPT_BIT_DEPTH: case OPT_BRIGHTNESS: case OPT_RESOLUTION: case OPT_PREVIEW: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: *((SANE_Word *) value) = sval->w; break; case OPT_MODE: case OPT_SOURCE: case OPT_ADF_MODE: strcpy((char *) value, sopt->constraint.string_list[sval->w]); break; default: return SANE_STATUS_INVAL; } return SANE_STATUS_GOOD; } /* * Handles setting the source (flatbed, or auto document feeder (ADF)). * */ static void change_source(Magicolor_Scanner *s, SANE_Int optindex, char *value) { int force_max = SANE_FALSE; SANE_Bool dummy; DBG(1, "%s: optindex = %d, source = '%s'\n", __func__, optindex, value); if (s->val[OPT_SOURCE].w == optindex) return; s->val[OPT_SOURCE].w = optindex; if (s->val[OPT_TL_X].w == s->hw->x_range->min && s->val[OPT_TL_Y].w == s->hw->y_range->min && s->val[OPT_BR_X].w == s->hw->x_range->max && s->val[OPT_BR_Y].w == s->hw->y_range->max) { force_max = SANE_TRUE; } if (strcmp(ADF_STR, value) == 0) { s->hw->x_range = &s->hw->cap->adf_x_range; s->hw->y_range = &s->hw->cap->adf_y_range; if (s->hw->cap->adf_duplex) { activateOption(s, OPT_ADF_MODE, &dummy); } else { deactivateOption(s, OPT_ADF_MODE, &dummy); s->val[OPT_ADF_MODE].w = 0; } DBG(1, "adf activated (%d)\n",s->hw->cap->adf_duplex); } else { /* ADF not active */ s->hw->x_range = &s->hw->cap->fbf_x_range; s->hw->y_range = &s->hw->cap->fbf_y_range; deactivateOption(s, OPT_ADF_MODE, &dummy); } s->opt[OPT_BR_X].constraint.range = s->hw->x_range; s->opt[OPT_BR_Y].constraint.range = s->hw->y_range; if (s->val[OPT_TL_X].w < s->hw->x_range->min || force_max) s->val[OPT_TL_X].w = s->hw->x_range->min; if (s->val[OPT_TL_Y].w < s->hw->y_range->min || force_max) s->val[OPT_TL_Y].w = s->hw->y_range->min; if (s->val[OPT_BR_X].w > s->hw->x_range->max || force_max) s->val[OPT_BR_X].w = s->hw->x_range->max; if (s->val[OPT_BR_Y].w > s->hw->y_range->max || force_max) s->val[OPT_BR_Y].w = s->hw->y_range->max; } static SANE_Status setvalue(SANE_Handle handle, SANE_Int option, void *value, SANE_Int *info) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Option_Descriptor *sopt = &(s->opt[option]); Option_Value *sval = &(s->val[option]); SANE_Status status; const SANE_String_Const *optval = NULL; int optindex = 0; SANE_Bool reload = SANE_FALSE; DBG(17, "%s: option = %d, value = %p, as word: %d\n", __func__, option, value, *(SANE_Word *) value); status = sanei_constrain_value(sopt, value, info); if (status != SANE_STATUS_GOOD) return status; if (info && value && (*info & SANE_INFO_INEXACT) && sopt->type == SANE_TYPE_INT) DBG(17, "%s: constrained val = %d\n", __func__, *(SANE_Word *) value); if (sopt->constraint_type == SANE_CONSTRAINT_STRING_LIST) { optval = search_string_list(sopt->constraint.string_list, (char *) value); if (optval == NULL) return SANE_STATUS_INVAL; optindex = optval - sopt->constraint.string_list; } switch (option) { case OPT_MODE: { sval->w = optindex; /* if binary, then disable the bit depth selection */ if (optindex == 0) { s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; } else { if (s->hw->cap->depth_list[0] == 1) s->opt[OPT_BIT_DEPTH].cap |= SANE_CAP_INACTIVE; else { s->opt[OPT_BIT_DEPTH].cap &= ~SANE_CAP_INACTIVE; s->val[OPT_BIT_DEPTH].w = mode_params[optindex].depth; } } reload = SANE_TRUE; break; } case OPT_BIT_DEPTH: sval->w = *((SANE_Word *) value); mode_params[s->val[OPT_MODE].w].depth = sval->w; reload = SANE_TRUE; break; case OPT_RESOLUTION: sval->w = *((SANE_Word *) value); DBG(17, "setting resolution to %d\n", sval->w); reload = SANE_TRUE; break; case OPT_BR_X: case OPT_BR_Y: if (SANE_UNFIX(*((SANE_Word *) value)) == 0) { DBG(17, "invalid br-x or br-y\n"); return SANE_STATUS_INVAL; } // fall through case OPT_TL_X: case OPT_TL_Y: sval->w = *((SANE_Word *) value); DBG(17, "setting size to %f\n", SANE_UNFIX(sval->w)); if (NULL != info) *info |= SANE_INFO_RELOAD_PARAMS; break; case OPT_SOURCE: change_source(s, optindex, (char *) value); reload = SANE_TRUE; break; case OPT_ADF_MODE: sval->w = optindex; /* Simple lists */ break; case OPT_BRIGHTNESS: case OPT_PREVIEW: /* needed? */ sval->w = *((SANE_Word *) value); break; default: return SANE_STATUS_INVAL; } if (reload && info != NULL) *info |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; DBG(17, "%s: end\n", __func__); return SANE_STATUS_GOOD; } SANE_Status sane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int *info) { DBG(17, "%s: action = %x, option = %d\n", __func__, action, option); if (option < 0 || option >= NUM_OPTIONS) return SANE_STATUS_INVAL; if (info != NULL) *info = 0; switch (action) { case SANE_ACTION_GET_VALUE: return getvalue(handle, option, value); case SANE_ACTION_SET_VALUE: return setvalue(handle, option, value, info); default: return SANE_STATUS_INVAL; } return SANE_STATUS_INVAL; } SANE_Status sane_get_parameters(SANE_Handle handle, SANE_Parameters *params) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; DBG(5, "%s\n", __func__); if (params == NULL) DBG(1, "%s: params is NULL\n", __func__); /* * If sane_start was already called, then just retrieve the parameters * from the scanner data structure */ if (!s->eof && s->ptr != NULL) { DBG(5, "scan in progress, returning saved params structure\n"); } else { /* otherwise initialize the params structure and gather the data */ mc_init_parameters(s); } if (params != NULL) *params = s->params; print_params(s->params); return SANE_STATUS_GOOD; } /* * This function is part of the SANE API and gets called from the front end to * start the scan process. */ SANE_Status sane_start(SANE_Handle handle) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; SANE_Status status; DBG(5, "%s\n", __func__); /* calc scanning parameters */ status = mc_init_parameters(s); if (status != SANE_STATUS_GOOD) return status; print_params(s->params); /* set scanning parameters; also query the current image * parameters from the sanner and save * them to s->params */ status = mc_set_scanning_parameters(s); if (status != SANE_STATUS_GOOD) return status; /* if we scan from ADF, check if it is loaded */ if (strcmp(source_list[s->val[OPT_SOURCE].w], ADF_STR) == 0) { status = mc_check_adf(s); if (status != SANE_STATUS_GOOD) return status; } /* prepare buffer here so that a memory allocation failure * will leave the scanner in a sane state. */ s->buf = realloc(s->buf, s->block_len); if (s->buf == NULL) return SANE_STATUS_NO_MEM; s->eof = SANE_FALSE; s->ptr = s->end = s->buf; s->canceling = SANE_FALSE; /* start scanning */ DBG(1, "%s: scanning...\n", __func__); status = mc_start_scan(s); if (status != SANE_STATUS_GOOD) { DBG(1, "%s: start failed: %s\n", __func__, sane_strstatus(status)); return status; } return status; } /* this moves data from our buffers to SANE */ SANE_Status sane_read(SANE_Handle handle, SANE_Byte *data, SANE_Int max_length, SANE_Int *length) { SANE_Status status; Magicolor_Scanner *s = (Magicolor_Scanner *) handle; if (s->buf == NULL || s->canceling) return SANE_STATUS_CANCELLED; *length = 0; status = mc_read(s); if (status == SANE_STATUS_CANCELLED) { mc_scan_finish(s); return status; } DBG(18, "moving data %p %p, %d (%d lines)\n", s->ptr, s->end, max_length, max_length / s->params.bytes_per_line); mc_copy_image_data(s, data, max_length, length); DBG(18, "%d lines read, status: %d\n", *length / s->params.bytes_per_line, status); /* continue reading if appropriate */ if (status == SANE_STATUS_GOOD) return status; mc_scan_finish(s); return status; } /* * void sane_cancel(SANE_Handle handle) * * Set the cancel flag to true. The next time the backend requests data * from the scanner the CAN message will be sent. */ void sane_cancel(SANE_Handle handle) { Magicolor_Scanner *s = (Magicolor_Scanner *) handle; s->canceling = SANE_TRUE; } /* * SANE_Status sane_set_io_mode() * * not supported - for asynchronous I/O */ SANE_Status sane_set_io_mode(SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { return SANE_STATUS_UNSUPPORTED; } /* * SANE_Status sane_get_select_fd() * * not supported - for asynchronous I/O */ SANE_Status sane_get_select_fd(SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ *fd) { return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/ma1509.h0000666000000000000000000001175613615534521013667 00000000000000/* sane - Scanner Access Now Easy. (C) 2003 Henning Meier-Geinitz . Based on the mustek (SCSI) backend. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for scanners based on the Mustek MA-1509 chipset. Currently the Mustek BearPaw 1200F is known to work. */ #ifndef ma1509_h #define ma1509_h #include "../include/sane/config.h" #include /* Some constants */ #define INQ_LEN 0x60 /* Length of SCSI inquiry */ #define MA1509_COMMAND_LENGTH 8 #define MA1509_GAMMA_SIZE 1024 #define MA1509_BUFFER_SIZE (1024 * 128) #define MA1509_WARMUP_TIME 30 #ifndef PATH_MAX # define PATH_MAX 1024 #endif #define MA1509_CONFIG_FILE "ma1509.conf" /* Convenience macros */ #if defined(MIN) #undef MIN #endif #if defined(MAX) #undef MAX #endif #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) /* Copy values to memory ('L' = little endian, 'B' = big endian */ #define STORE16L(cp,v) \ do { \ int value = (v); \ \ *(cp)++ = (value >> 0) & 0xff; \ *(cp)++ = (value >> 8) & 0xff; \ } while (0) #define STORE16B(cp,v) \ do { \ int value = (v); \ \ *(cp)++ = (value >> 8) & 0xff; \ *(cp)++ = (value >> 0) & 0xff; \ } while (0) #define STORE32B(cp,v) \ do { \ long int value = (v); \ \ *(cp)++ = (value >> 24) & 0xff; \ *(cp)++ = (value >> 16) & 0xff; \ *(cp)++ = (value >> 8) & 0xff; \ *(cp)++ = (value >> 0) & 0xff; \ } while (0) /* declarations */ enum Ma1509_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, OPT_RESOLUTION, OPT_SOURCE, OPT_PREVIEW, OPT_GEOMETRY_GROUP, OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_THRESHOLD, OPT_CUSTOM_GAMMA, /* use custom gamma tables? */ OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, /* must come last: */ NUM_OPTIONS }; typedef struct Ma1509_Device { struct Ma1509_Device *next; SANE_String name; SANE_Device sane; SANE_Bool has_ta; SANE_Bool has_adf; SANE_Range x_range; SANE_Range y_range; /* scan area when transparency adapter is used: */ SANE_Range x_trans_range; SANE_Range y_trans_range; /* values actually used by scanner, not necessarily the desired! */ SANE_Int bpl, ppl, lines; } Ma1509_Device; typedef struct Ma1509_Scanner { /* all the state needed to define a scan request: */ struct Ma1509_Scanner *next; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Bool scanning; SANE_Bool cancelled; SANE_Parameters params; /* Parsed option values and variables that are valid only during actual scanning: */ int fd; /* filedescriptor */ long start_time; /* at this time the scan started */ long lamp_time; /* at this time the lamp was turned on */ SANE_Word total_bytes; /* bytes read from scanner */ SANE_Word read_bytes; /* bytes transmitted by sane_read */ SANE_Int red_gamma_table[MA1509_GAMMA_SIZE]; SANE_Int green_gamma_table[MA1509_GAMMA_SIZE]; SANE_Int blue_gamma_table[MA1509_GAMMA_SIZE]; SANE_Byte *buffer, *buffer_start; SANE_Int buffer_bytes; /* scanner dependent/low-level state: */ Ma1509_Device *hw; } Ma1509_Scanner; #endif /* ma1509_h */ sane-backends-1.0.29/backend/umax-usb.c0000666000000000000000000002346413615534521014506 00000000000000/* ---------------------------------------------------------------------- */ /* sane - Scanner Access Now Easy. umax-usb.c (C) 2001-2002 Frank Zago 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for UMAX USB flatbed scanners. */ /* ---------------------------------------------------------------------- */ #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_pv8630.h" /* USB specific parts */ /* Apparently this will recover from some errors. */ static void pv8630_mini_init_scanner(int fd) { DBG(DBG_info, "mini_init_scanner\n"); /* (re-)init the device (?) */ sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04 ); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02 ); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02 ); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xd0, 0xff, 1000); } /* Length of the CDB given the SCSI command. The last two are not correct (vendor reserved). */ static u_char cdb_sizes[8] = { 6, 10, 10, 6, 16, 12, 0, 0 }; #define CDB_SIZE(opcode) cdb_sizes[(((opcode) >> 5) & 7)] /* Sends a CDB to the scanner. Also sends the parameters and receives * the data, if necessary. When this function returns with a * SANE_STATUS_GOOD, the SCSI command has been completed. * * Note: I don't know about deferred commands. */ static SANE_Status sanei_umaxusb_cmd(int fd, const void *src, size_t src_size, void *dst, size_t * dst_size) { unsigned char result; size_t cmd_size = CDB_SIZE (*(const char *) src); size_t param_size = src_size - cmd_size; const char * param_ptr = ((const char *) src) + cmd_size; size_t tmp_len; DBG(DBG_info, "Sending SCSI cmd 0x%02x cdb len %ld, param len %ld, result len %ld\n", ((const unsigned char *)src)[0], (long)cmd_size, (long)param_size, dst_size? (long)*dst_size:(long)0); /* This looks like some kind of pre-initialization. */ sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x0c); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000); sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04); /* Send the CDB and check it's been received OK. */ sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x16); sanei_pv8630_flush_buffer(fd); sanei_pv8630_prep_bulkwrite(fd, cmd_size); tmp_len = cmd_size; sanei_pv8630_bulkwrite(fd, src, &tmp_len); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000); sanei_pv8630_flush_buffer(fd); sanei_pv8630_prep_bulkread(fd, 1); result = 0xA5; /* to be sure */ tmp_len = 1; sanei_pv8630_bulkread(fd, &result, &tmp_len); if (result != 0) { DBG(DBG_info, "error in sanei_pv8630_bulkread (got %02x)\n", result); if (result == 8) { pv8630_mini_init_scanner(fd); } return(SANE_STATUS_IO_ERROR); } /* Send the parameters and check they've been received OK. */ if (param_size) { sanei_pv8630_flush_buffer(fd); sanei_pv8630_prep_bulkwrite(fd, param_size); tmp_len = param_size; sanei_pv8630_bulkwrite(fd, param_ptr, &tmp_len); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000); sanei_pv8630_flush_buffer(fd); sanei_pv8630_prep_bulkread(fd, 1); result = 0xA5; /* to be sure */ tmp_len = 1; sanei_pv8630_bulkread(fd, &result, &tmp_len); if (result != 0) { DBG(DBG_info, "error in sanei_pv8630_bulkread (got %02x)\n", result); if (result == 8) { pv8630_mini_init_scanner(fd); } return(SANE_STATUS_IO_ERROR); } } /* If the SCSI command expect a return, get it. */ if (dst_size != NULL && *dst_size != 0 && dst != NULL) { sanei_pv8630_flush_buffer(fd); sanei_pv8630_prep_bulkread(fd, *dst_size); sanei_pv8630_bulkread(fd, dst, dst_size); DBG(DBG_info, " SCSI cmd returned %lu bytes\n", (u_long) *dst_size); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000); sanei_pv8630_flush_buffer(fd); sanei_pv8630_prep_bulkread(fd, 1); result = 0x5A; /* just to be sure */ tmp_len = 1; sanei_pv8630_bulkread(fd, &result, &tmp_len); if (result != 0) { DBG(DBG_info, "error in sanei_pv8630_bulkread (got %02x)\n", result); if (result == 8) { pv8630_mini_init_scanner(fd); } return(SANE_STATUS_IO_ERROR); } } sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xd0, 0xff, 1000); DBG(DBG_info, " SCSI command successfully executed\n"); return(SANE_STATUS_GOOD); } /* Initialize the PowerVision 8630. */ static SANE_Status pv8630_init_umaxusb_scanner(int fd) { DBG(DBG_info, "Initializing the PV8630\n"); /* Init the device */ sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xd0, 0xff, 1000); sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x0c); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000); sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000); sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x0c); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf8, 0xff, 1000); sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x02); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xd0, 0xff, 1000); sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x0c); sanei_pv8630_wait_byte(fd, PV8630_RSTATUS, 0xf0, 0xff, 1000); sanei_pv8630_write_byte(fd, PV8630_UNKNOWN, 0x04); sanei_pv8630_write_byte(fd, PV8630_RMODE, 0x16); DBG(DBG_info, "PV8630 initialized\n"); return(SANE_STATUS_GOOD); } /* * SCSI functions for the emulation. * * The following functions emulate their sanei_scsi_* counterpart. * */ /* * sanei_umaxusb_req_wait() and sanei_umaxusb_req_enter() * * I don't know if it is possible to queue the reads to the * scanner. So The queing is disabled. The performance does not seems * to be bad anyway. */ static void *umaxusb_req_buffer; /* keep the buffer ptr as an ID */ static SANE_Status sanei_umaxusb_req_enter (int fd, const void *src, size_t src_size, void *dst, size_t * dst_size, void **idp) { umaxusb_req_buffer = *idp = dst; return(sanei_umaxusb_cmd(fd, src, src_size, dst, dst_size)); } static SANE_Status sanei_umaxusb_req_wait (void *id) { if (id != umaxusb_req_buffer) { DBG(DBG_info, "sanei_umaxusb_req_wait: AIE, invalid id\n"); return(SANE_STATUS_IO_ERROR); } return(SANE_STATUS_GOOD); } /* Open the device. */ static SANE_Status sanei_umaxusb_open (const char *dev, int *fdp, SANEI_SCSI_Sense_Handler handler, void *handler_arg) { SANE_Status status; handler = handler; /* silence gcc */ handler_arg = handler_arg; /* silence gcc */ status = sanei_usb_open (dev, fdp); if (status != SANE_STATUS_GOOD) { DBG (1, "sanei_umaxusb_open: open of `%s' failed: %s\n", dev, sane_strstatus(status)); return status; } else { SANE_Word vendor; SANE_Word product; /* We have openned the device. Check that it is a USB scanner. */ if (sanei_usb_get_vendor_product (*fdp, &vendor, &product) != SANE_STATUS_GOOD) { /* This is not a USB scanner, or SANE or the OS doesn't support it. */ sanei_usb_close(*fdp); *fdp = -1; return SANE_STATUS_UNSUPPORTED; } /* So it's a scanner. Does this backend support it? * Only the UMAX 2200 USB is currently supported. */ if ((vendor != 0x1606) || (product != 0x0230)) { sanei_usb_close(*fdp); *fdp = -1; return SANE_STATUS_UNSUPPORTED; } /* It's a good scanner. Initialize it. * * Note: pv8630_init_umaxusb_scanner() is for the UMAX * 2200. Other UMAX scanner might need a different * initialization routine. */ pv8630_init_umaxusb_scanner(*fdp); } return(SANE_STATUS_GOOD); } /* sanei_umaxusb_open_extended() is just a passthrough for sanei_umaxusb_open(). */ static SANE_Status sanei_umaxusb_open_extended (const char *dev, int *fdp, SANEI_SCSI_Sense_Handler handler, void *handler_arg, int *buffersize) { buffersize = buffersize; return(sanei_umaxusb_open(dev, fdp, handler, handler_arg)); } /* Close the scanner. */ static void sanei_umaxusb_close (int fd) { sanei_usb_close(fd); } sane-backends-1.0.29/backend/kvs40xx.h0000666000000000000000000001454613615534521014302 00000000000000#ifndef __KVS40XX_H #define __KVS40XX_H /* Copyright (C) 2009, Panasonic Russia Ltd. */ /* Panasonic KV-S40xx USB-SCSI scanner driver. */ #include "../include/sane/config.h" #include #ifdef HAVE_SYS_TYPES_H #include #endif #undef BACKEND_NAME #define BACKEND_NAME kvs40xx #define DBG_ERR 1 #define DBG_WARN 2 #define DBG_MSG 3 #define DBG_INFO 4 #define DBG_DBG 5 #define PANASONIC_ID 0x04da #define KV_S4085C 0x100c #define KV_S4065C 0x100d #define KV_S7075C 0x100e #define KV_S4085CL (KV_S4085C|0x10000) #define KV_S4085CW (KV_S4085C|0x20000) #define KV_S4065CL (KV_S4065C|0x10000) #define KV_S4065CW (KV_S4065C|0x20000) #define USB 1 #define SCSI 2 #define BULK_HEADER_SIZE 12 #define MAX_READ_DATA_SIZE (0x10000-0x100) #define BUF_SIZE MAX_READ_DATA_SIZE #define INCORRECT_LENGTH 0xfafafafa typedef unsigned char u8; typedef unsigned u32; typedef unsigned short u16; #define SIDE_FRONT 0x00 #define SIDE_BACK 0x80 /* options */ typedef enum { NUM_OPTS = 0, /* General options */ MODE_GROUP, MODE, /* scanner modes */ RESOLUTION, /* X and Y resolution */ SOURCE, DUPLEX, /* Duplex mode */ FEEDER_MODE, /* Feeder mode, fixed to Continous */ LENGTHCTL, /* Length control mode */ LONG_PAPER, MANUALFEED, /* Manual feed mode */ FEED_TIMEOUT, /* Feed timeout */ DBLFEED, /* Double feed detection mode */ DFEED_SENCE, DFSTOP, DFEED_L, DFEED_C, DFEED_R, STAPELED_DOC, /* Detect stapled document */ FIT_TO_PAGE, /* Scanner shrinks image to fit scanned page */ /* Geometry group */ GEOMETRY_GROUP, PAPER_SIZE, /* Paper size */ LANDSCAPE, /* true if landscape */ TL_X, /* upper left X */ TL_Y, /* upper left Y */ BR_X, /* bottom right X */ BR_Y, /* bottom right Y */ ADVANCED_GROUP, BRIGHTNESS, /* Brightness */ CONTRAST, /* Contrast */ THRESHOLD, /* Binary threshold */ AUTOMATIC_THRESHOLD, WHITE_LEVEL, NOISE_REDUCTION, INVERSE, /* Monochrome reversing */ IMAGE_EMPHASIS, /* Image emphasis */ GAMMA_CORRECTION, /* Gamma correction */ LAMP, /* Lamp -- color drop out */ RED_CHROMA, BLUE_CHROMA, HALFTONE_PATTERN, /* Halftone pattern */ COMPRESSION, /* JPEG Compression */ COMPRESSION_PAR, /* Compression parameter */ DESKEW, STOP_SKEW, CROP, MIRROR, BTMPOS, TOPPOS, /* must come last: */ NUM_OPTIONS } KV_OPTION; struct buf { u8 **buf; volatile int head; volatile int tail; volatile unsigned size; volatile int sem; volatile SANE_Status st; pthread_mutex_t mu; pthread_cond_t cond; }; struct scanner { char name[128]; unsigned id; volatile int scanning; int page; int side; int bus; SANE_Int file; SANE_Option_Descriptor opt[NUM_OPTIONS]; Option_Value val[NUM_OPTIONS]; SANE_Parameters params; u8 *buffer; struct buf buf[2]; u8 *data; unsigned side_size; unsigned read; pthread_t thread; }; struct window { u8 reserved[6]; u8 window_descriptor_block_length[2]; u8 window_identifier; u8 reserved2; u8 x_resolution[2]; u8 y_resolution[2]; u8 upper_left_x[4]; u8 upper_left_y[4]; u8 width[4]; u8 length[4]; u8 brightness; u8 threshold; u8 contrast; u8 image_composition; u8 bit_per_pixel; u8 halftone_pattern[2]; u8 rif_padding; /*RIF*/ u8 bit_ordering[2]; u8 compression_type; u8 compression_argument; u8 reserved4[6]; u8 vendor_unique_identifier; u8 nobuf_fstspeed_dfstop; u8 mirror_image; u8 image_emphasis; u8 gamma_correction; u8 mcd_lamp_dfeed_sens; u8 reserved5; /*rmoir*/ u8 document_size; u8 document_width[4]; u8 document_length[4]; u8 ahead_deskew_dfeed_scan_area_fspeed_rshad; u8 continuous_scanning_pages; u8 automatic_threshold_mode; u8 automatic_separation_mode; u8 standard_white_level_mode; u8 b_wnr_noise_reduction; u8 mfeed_toppos_btmpos_dsepa_hsepa_dcont_rstkr; u8 stop_mode; u8 red_chroma; u8 blue_chroma; }; struct support_info { /*TODO: */ unsigned char data[32]; }; void kvs40xx_init_options (struct scanner *); SANE_Status kvs40xx_test_unit_ready (struct scanner *s); SANE_Status kvs40xx_set_timeout (struct scanner *s, int timeout); void kvs40xx_init_window (struct scanner *s, struct window *wnd, int wnd_id); SANE_Status kvs40xx_set_window (struct scanner *s, int wnd_id); SANE_Status kvs40xx_reset_window (struct scanner *s); SANE_Status kvs40xx_read_picture_element (struct scanner *s, unsigned side, SANE_Parameters * p); SANE_Status read_support_info (struct scanner *s, struct support_info *inf); SANE_Status kvs40xx_read_image_data (struct scanner *s, unsigned page, unsigned side, void *buf, unsigned max_size, unsigned *size); SANE_Status kvs40xx_document_exist (struct scanner *s); SANE_Status get_buffer_status (struct scanner *s, unsigned *data_avalible); SANE_Status kvs40xx_scan (struct scanner *s); SANE_Status kvs40xx_sense_handler (int fd, u_char * sense_buffer, void *arg); SANE_Status stop_adf (struct scanner *s); SANE_Status hopper_down (struct scanner *s); SANE_Status inquiry (struct scanner *s, char *id); static inline u16 swap_bytes16 (u16 x) { return x << 8 | x >> 8; } static inline u32 swap_bytes32 (u32 x) { return x << 24 | x >> 24 | (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) { p[2] = x >> 16; p[1] = x >> 8; p[0] = x >> 0; } #define cpu2be16(x) (x) #define cpu2be32(x) (x) #define cpu2le16(x) swap_bytes16(x) #define cpu2le32(x) swap_bytes32(x) #define le2cpu16(x) swap_bytes16(x) #define le2cpu32(x) swap_bytes32(x) #define be2cpu16(x) (x) #define be2cpu32(x) (x) #define BIT_ORDERING 0 #elif __BYTE_ORDER == __LITTLE_ENDIAN static inline void set24 (u8 * p, u32 x) { p[0] = x >> 16; p[1] = x >> 8; p[2] = x >> 0; } #define cpu2le16(x) (x) #define cpu2le32(x) (x) #define cpu2be16(x) swap_bytes16(x) #define cpu2be32(x) swap_bytes32(x) #define le2cpu16(x) (x) #define le2cpu32(x) (x) #define be2cpu16(x) swap_bytes16(x) #define be2cpu32(x) swap_bytes32(x) #define BIT_ORDERING 1 #else #error __BYTE_ORDER not defined #endif static inline u32 get24 (u8 * p) { u32 x = (((u32) p[0]) << 16) | (((u32) p[1]) << 8) | (((u32) p[0]) << 0); return x; } #endif /*__KVS40XX_H*/ sane-backends-1.0.29/backend/plustek-pp_hwdefs.h0000666000000000000000000007641213615534521016417 00000000000000/* @file plustek-pp_hwdefs.h * @brief different definitions for describing the scanner hardware * * based on sources acquired from Plustek Inc. * Copyright (C) 1998 Plustek Inc. * Copyright (C) 2000-2004 Gerhard Jaeger * also based on the work done by Rick Bronson * * History: * 0.30 - initial version * 0.31 - corrected the values of _GAIN_P98_HIGH, _GAIN_P96_HIGH and _GAIN_LOW * 0.32 - removed _LampDelay defines * removed _MODE_xxx defines * 0.33 - cosmetic changes * removed _PORT_BPP from modelist * 0.34 - no changes * 0.35 - no changes * 0.36 - moved struct ScanState to this header * moved some definitions from scandata.h to this file * 0.37 - some cleanup work * added model override defines here * added _A3 * changed some _ defines to _ defines * 0.38 - added ASIC98003 stuff * removed the _ASIC_xxxxx definitions * 0.39 - major changes: moved a lot of stuff to this file * 0.40 - no changes * 0.41 - added _OVR_PLUSTEK_4800P definition * 0.42 - added _OVR_PRIMAX_4800D30 definition * 0.43 - no changes * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #ifndef __HWDEFS_H__ #define __HWDEFS_H__ /* * port modes * (WARNING: never change these defines, as they are used as entries * to jump tables !!!) */ #define _PORT_EPP 0 #define _PORT_SPP 1 #define _PORT_BIDI 2 #define _PORT_ECP 3 #define _PORT_ESP 4 #define _PORT_NONE 5 /* * ScannerSize */ #define _SCANSIZE_A4 0 #define _SCANSIZE_LETTER 1 #define _SCANSIZE_LEGAL 2 #define _SCANSIZE_A3 3 /* * Magic IDs switch printer port to scanner mode */ #define _ID1ST 0x69 #define _ID2ND 0x96 #define _ID3RD 0xa5 #define _ID4TH 0x5a /* * Special IDs used to reset scanner (ASIC98003) */ #define _RESET1ST 0x69 #define _RESET2ND 0x96 #define _RESET3RD 0xaa #define _RESET4TH 0x55 /* * ID switch to printer mode */ #define _ID_TO_PRINTER 0 /* * Flags for internal use */ #define _VF_BUILDMAP 0x0000001 #define _VF_DATATOUSERBUFFER 0x0000002 #define _VF_ENVIRONMENT_READY 0x0000004 #define _VF_FIRSTSCANLINE 0x0000008 #define _VF_PREVIEW 0x0000020 /* * Printer Control Port: Definitions */ #define _CTRL_STROBE 0x01 #define _CTRL_AUTOLF 0x02 #define _CTRL_NOT_INIT 0x04 #define _CTRL_SELECT_IN 0x08 #define _CTRL_ENABLE_IRQ 0x10 #define _CTRL_DIRECTION 0x20 #define _CTRL_RESERVED 0xc0 /* * here are the definitions for the different registers * first the ASIC 96001/3 section */ /* Status Register 0x10 */ #define _FLAG_P96_PAPER 0x01 #define _FLAG_P96_ADF 0x02 #define _FLAG_P96_KEY 0x04 #define _FLAG_P96_EPP 0x08 #define _FLAG_P96_FIFOFULL 0x10 #define _FLAG_P96_FIFOEMPTY 0x20 #define _FLAG_P96_CCDTYPE 0x40 #define _FLAG_P96_MOTORTYPE 0x80 /* * the 98001 section */ #define _DEFAULT_LINESCANTIME 96 /* Status Register (Addr: 0x30) */ #define _FLAG_P98_PAPER 0x01 #define _FLAG_P98_KEY 0x80 /* * some buffer sizes (for ASIC 98001 based devices) */ #define _LINE_BUFSIZE (5500 * 6) #define _LINE_BUFSIZE1 (5500 * 8) #define _PROCESS_BUFSIZE (5120 * 3) /* * generic equates */ #define _DEF_BW_THRESHOLD 111 /* default B/W mode threshold value */ #define _NUMBER_OF_SCANSTEPS 64 /* Asic spec.: up to 64 scan steps */ #define _SCANSTATE_BYTES (_NUMBER_OF_SCANSTEPS/2) /* CHECK: Play around with the P98003/1 * gain values - maybe we get a brighter picture... */ #define _GAIN_P98_HIGH 225 /* Volt. max. value, Asic 98001 */ #define _GAIN_P98003_HIGH 240 /* Volt. max. value, Asic 98003 */ #define _GAIN_P96_HIGH 240 /* Volt. max. value, Asic 96001/3 */ #define _GAIN_LOW 210 /* Volt. min. value */ #define _GAIN_P98003_LOW 220 /* Volt. min. value, Asic 98003 */ #define _MOTOR_ONE_LINE_TIME 4 /* for ASIC 98001/3 shading */ #define _DEF_BRIGHTEST_SKIP 3 #define _DEF_DARKEST_SKIP 5 #define _BUF_SIZE_BASE_CONST 1280 #define _SCANSTATE_TABLE_SIZE 250 /* was 200 for 4830 */ #define _P98_OFFSET70 60 /* for Data channel (BYTE) */ #define _RED_DATA_READY 0x01 #define _GREEN_DATA_READY 0x02 #define _BLUE_DATA_READY 0x04 #define _ASIC_REDCOLOR 0x01 #define _ASIC_GREENCOLOR 0x03 #define _ASIC_BLUECOLOR 0x02 /* * for Asic I/O signal control */ #define _CTRL_GENSIGNAL (_CTRL_RESERVED + _CTRL_NOT_INIT) /* 0xc4 */ #define _CTRL_START_REGWRITE (_CTRL_GENSIGNAL + _CTRL_SELECT_IN) /* 0xcc */ #define _CTRL_END_REGWRITE (_CTRL_GENSIGNAL) /* 0xc4 */ #define _CTRL_START_DATAWRITE (_CTRL_GENSIGNAL + _CTRL_AUTOLF) /* 0xc6 */ #define _CTRL_END_DATAWRITE (_CTRL_GENSIGNAL) /* 0xc4 */ #define _CTRL_EPPSIGNAL_WRITE (_CTRL_GENSIGNAL + _CTRL_STROBE) /* 0xc5 */ #define _CTRL_EPPTRIG_REGWRITE (_CTRL_GENSIGNAL + _CTRL_SELECT_IN + _CTRL_STROBE) #define _CTRL_START_BIDIREAD (_CTRL_GENSIGNAL + _CTRL_DIRECTION + _CTRL_AUTOLF) #define _CTRL_END_BIDIREAD (_CTRL_GENSIGNAL + _CTRL_DIRECTION) /* 0xe4 */ typedef struct { ULong dwFullSpeed; Byte bCurrentSpeed; Byte bStepSpeed; } DiffModeVar, *pDiffModeVar; typedef struct { UShort wHomePos; /* scanner's scanning home position */ UShort wMaxSteps; /* maximum steps for this scan */ Byte bExposureTime; /* exposure time for one line */ Byte bMotorStep; Byte bFlagScanMode; /* see below */ Byte bTimesShading; /* see below */ } ModeTypeVar, *pModeTypeVar; typedef struct { Byte bStep; Byte bStatus; } ScanState, *pScanState; typedef struct { Byte bReg; Byte bParam; } RegDef, *pRegDef; typedef union { RGBByteDef Colors; UChar bColors[3]; } ColorByte, *pColorByte; typedef union { RGBUShortDef Colors; UShort wColors[3]; } ColorWord, *pColorWord; typedef struct { UShort exposureTime; UShort xStepTime; } ExpXStepDef, *pExtXStepDef; typedef struct { UShort thresholdBW; UShort thresholdGray; UShort thresholdColor; } ThreshDef, *pThreshDef; /* for decription of the DAC specific stuff*/ typedef struct { ColorWord GainResize; ColorWord DarkCmpHi; ColorWord DarkCmpLo; ColorWord DarkOffSub; ColorByte DarkDAC; UChar Reserved; } DACTblDef, *pDACTblDef; /* * some function types */ typedef struct scandata *pScanData; typedef void (*pFnDataProcess)(pScanData, pVoid, pVoid, ULong); typedef Bool (*pFnReadData)(pScanData, pUChar, ULong); typedef void (*pFnVoid)(pScanData); typedef Bool (*pFnBool)(pScanData); typedef void (*pFnDACOffs)(pScanData, pDACTblDef, ULong); typedef void (*pFnDACDark)(pScanData, pDACTblDef, ULong, UShort); typedef void (*pFnOut)(Byte,UShort); typedef Byte (*pFnIn)(UShort); /* * For Motor step control */ #define _FullStepStrong 0x10 #define _HalfStep 0x04 #define _QuarterStep 0x08 #define _EightStep 0x0c /* bTimesShading */ #define _Shading_32Times 0 #define _Shading_4Times 1 #define _Shading_16Times 2 /* Scan.bModuleState */ #define _MotorInNormalState 0 #define _MotorGoBackward 1 #define _MotorInStopState 2 #define _MotorAdvancing 3 #define _MotorAdvanced 4 /* bMoveDataOutFlag */ #define _DataInNormalState 0 #define _DataAfterRefreshState 1 #define _DataFromStopState 2 /* bFastMoveFlag */ #define _FastMove_Fast_C50_G100 0 #define _FastMove_Middle_C75_G150 1 #define _FastMove_Low_C75_G150 2 #define _FastMove_Low_C75_G150_Back 4 #define _FastMove_Pos_300 5 #define _FastMove_Film_150 6 /* * ASIC 98003 base models... */ #define _TPA_P98003_SHADINGORG 2172U #define _RFT_SCANNING_ORG 380U #define _POS_SCANNING_ORG 2840U #define _POS_PAGEWIDTH 450U #define _POS_ORG_OFFSETX 0x41C #define _NEG_SCANNING_ORG 3000U #define _NEG_PAGEWIDTH 464U #define _NEG_PAGEWIDTH600 992U #define _NEG_ORG_OFFSETX 0x430 #define _NEG_SHADING_OFFS 1500U #define _NEG_EDGE_VALUE 0x800 #define _SHADING_BEGINX 4U /* home positions */ #define _Home_CE50 0x1f /* 0x1d 1b */ #define _Home_CE100 0x27 /* 0x34 23 */ #define _Home_CE150 0x29 /* 0x23 25 */ #define _Home_CE300 0x34 /* 0x2e 30 */ #define _Home_CE600 0x3a /* 0x35 36 */ #define _Home_CB50 0x20 /* 0x22 1c */ #define _Home_CB100 0x41 /* 0x42 3d */ #define _Home_CB150 0x41 /* 0x3f 3d */ #define _Home_CB300 0x4c /* 0x4a 48 */ #define _Home_CB600 0x53 /* 0x54 4f */ #define _Home_CS50 0x20 /* 0x1b 1c */ #define _Home_CS100 0x41 /* 0x40 3d */ #define _Home_CS150 0x41 /* 0x3e 3d */ #define _Home_CS300 0x4c /* 0x4b 48 */ #define _Home_CS600 0x53 /* 0x4f 4f */ #define _Home_GE75 0x08 /* 7-14-98 00 */ #define _Home_GE150 0x04 /* 0x22 00 */ #define _Home_GE300 0x12 /* 0x2d 0e */ #define _Home_GE600 0x19 /* 0x33 15 */ #define _Home_GB75 0x40 /* 7-14-98 3e */ #define _Home_GB150 0x40 /* 0x3f 3e */ #define _Home_GB300 0x4e /* 0x4c 4a */ #define _Home_GB600 0x53 /* 0x51 4f */ #define _Home_GS75 0x40 /* 7-14-98 3c */ #define _Home_GS150 0x40 /* 0x3f 3c */ #define _Home_GS300 0x4e /* 0x4d 4a */ #define _Home_GS600 0x53 /* 0x51 4f */ #define _Home_BE75 0x30 /* 7-14-98 20 */ #define _Home_BE150 0x30 /* 0x3c 20 */ #define _Home_BE300 0x32 /* 0x48 2e */ #define _Home_BE600 0x37 /* 0x35 33 */ #define _Home_BB75 0x42 /* 7-14-98 3e */ #define _Home_BB150 0x42 /* 0x47 3e */ #define _Home_BB300 0x50 /* 0x51 4c */ #define _Home_BB600 0x53 /* 0x51 4f */ #define _Home_BS75 0x42 /* 7-14-98 3e */ #define _Home_BS150 0x42 /* 0x46 3e */ #define _Home_BS300 0x50 /* 0x4f 4c */ #define _Home_BS600 0x53 /* 0x55 4f */ /* * for ModeTypeVar indexes */ #define _FixParamEppBw 0 #define _FixParamBppBw _FixParamEppBw + 4 #define _FixParamSppBw _FixParamBppBw + 4 #define _FixParamEppGray 0 #define _FixParamBppGray _FixParamEppGray + 4 #define _FixParamSppGray _FixParamBppGray + 4 #define _FixParamEppColor 0 #define _FixParamBppColor _FixParamEppColor + 5 #define _FixParamSppColor _FixParamBppColor + 5 #define _FixParamSppNegative 0 #define _FixParamBppNegative _FixParamSppNegative + 3 #define _FixParamEppNegative _FixParamBppNegative + 3 #define _FixParamSppPositive _FixParamEppNegative + 3 #define _FixParamBppPositive _FixParamSppPositive + 3 #define _FixParamEppPositive _FixParamBppPositive + 3 /* * for DiffModeVar indexes */ #define _BwEpp150 0 #define _BwEpp300 1 #define _BwEpp600 2 #define _BwBpp150 _BwEpp150 #define _BwBpp300 _BwEpp300 #define _BwBpp600 _BwEpp600 #define _BwSpp150 3 #define _BwSpp300 4 #define _BwSpp600 5 #define _GrayEpp150 6 #define _GrayEpp300 7 #define _GrayEpp600 8 #define _GrayEpp600_3000 9 /* > 3000 pixels per channel */ #define _GrayBpp150 10 #define _GrayBpp300 11 #define _GrayBpp300_1600 12 #define _GrayBpp600 13 #define _GrayBpp600_1600 14 #define _GrayBpp600_3200 15 #define _GraySpp150 16 #define _GraySpp150_800 17 #define _GraySpp300 18 #define _GraySpp300_800 19 #define _GraySpp300_1600 20 #define _GraySpp600 21 #define _GraySpp600_800 22 #define _GraySpp600_1600 23 #define _GraySpp600_3200 24 #define _ColorEpp60 25 #define _ColorEpp100 _ColorEpp60 #define _ColorEpp150 26 #define _ColorEpp300 27 #define _ColorEpp300_1200 28 #define _ColorEpp600 29 #define _ColorEpp600_1400 30 #define _ColorEpp600_2800 31 #define _ColorEpp600_4000 32 #define _ColorBpp60 33 #define _ColorBpp100 34 #define _ColorBpp150 35 #define _ColorBpp150_800 36 #define _ColorBpp300 37 #define _ColorBpp300_800 38 #define _ColorBpp300_1600 39 #define _ColorBpp600 40 #define _ColorBpp600_800 41 #define _ColorBpp600_1600 42 #define _ColorBpp600_3200 43 #define _ColorSpp60 _ColorBpp60 #define _ColorSpp100 _ColorBpp100 #define _ColorSpp150 _ColorBpp150 #define _ColorSpp150_800 _ColorBpp150_800 #define _ColorSpp300 44 #define _ColorSpp300_500 45 #define _ColorSpp300_1000 46 #define _ColorSpp300_2000 47 #define _ColorSpp600 48 #define _ColorSpp600_500 49 #define _ColorSpp600_1000 50 #define _ColorSpp600_2000 51 #define _ColorSpp600_4000 52 #define _NegativeSpp150 53 #define _NegativeSpp300 54 #define _NegativeSpp600 55 #define _NegativeBpp150 _NegativeSpp150 #define _NegativeBpp300 _NegativeSpp300 #define _NegativeBpp600 _NegativeSpp600 #define _NegativeEpp150 _NegativeSpp150 #define _NegativeEpp300 _NegativeSpp300 #define _NegativeEpp600 _NegativeSpp600 #define _BwEpp75 56 #define _BwBpp75 56 #define _BwSpp75 56 #define _GrayEpp75 56 #define _GrayBpp75 56 #define _GraySpp75 56 #define _TransparencySpp150 _NegativeSpp150 #define _TransparencySpp300 _NegativeSpp300 #define _TransparencySpp600 _NegativeSpp600 #define _TransparencyBpp150 _NegativeSpp150 #define _TransparencyBpp300 _NegativeSpp300 #define _TransparencyBpp600 _NegativeSpp600 #define _TransparencyEpp150 _NegativeSpp150 #define _TransparencyEpp300 _NegativeSpp300 #define _TransparencyEpp600 _NegativeSpp600 /* for 48 bits color */ #define _ColorEpp100_1400 63 #define _ColorEpp150_1900 64 #define _ColorEpp300_4000 65 #define _ColorEpp600_9600 66 #define _ColorSpp300_3000 67 /* * for mirroring parts of the 98001/3 asic register set */ typedef struct { Byte RD_Motor1Control; /* 0x0b */ Byte RD_StepControl; /* 0x14 */ Byte RD_Motor0Control; /* 0x15 */ Byte RD_XStepTime; /* 0x16 */ Byte RD_ModeControl; /* 0x1b */ Byte RD_LineControl; /* 0x1c */ Byte RD_ScanControl; /* 0x1d, init = 5 */ Byte RD_ModelControl; /* 0x1f */ Byte RD_Model1Control; /* 0x20 */ UShort RD_Dpi; /* 0x21 */ UShort RD_Origin; /* 0x23 */ UShort RD_Pixels; /* 0x25 */ UShort RD_ThresholdControl; /* 0x27 */ Byte RD_ThresholdGapCtrl; /* 0x29 */ UShort RD_RedDarkOff; /* 0x33 */ UShort RD_GreenDarkOff; /* 0x35 */ UShort RD_BlueDarkOff; /* 0x37 */ ULong RD_BufFullSize; /* 0x54, ASIC 98003 */ UShort RD_MotorTotalSteps; /* 0x57, ASIC 98003 */ Byte RD_ScanControl1; /* 0x5b, ASIC 98003 */ Byte RD_MotorDriverType; /* 0x64, ASIC 98003 */ Byte RD_ExtLineControl; /* 0x6d, ASIC 98003 */ Byte RD_ExtXStepTime; /* 0x6e, ASIC 98003 */ } RegData, *pRegData; /* * for registers, that only exist on the 96001/3 */ typedef struct { Byte RD_MotorControl; /* 0x1b, init = 3 */ Byte RD_MemAccessControl; /* 0x1d */ Byte RD_WatchDogControl; /* 0x25, init = 0x8f */ union { Byte RD_ModelControl2; /* 0x26, P96003 */ } u26; union { Byte RD_RedChShadingOff; /* 0x28, P96003 */ } u28; union { Byte RD_GreenChShadingOff; /* 0x29, P96003 */ } u29; Byte RD_BlueChShadingOff; /* 0x2a, P96003 */ Byte RD_RedChDarkOff; /* 0x2b, P96003 */ Byte RD_GreenChDarkOff; /* 0x2c, P96003 */ Byte RD_BlueChDarkOff; /* 0x2d, P96003 */ Byte RD_RedChEvenOff; /* 0x31, P96003 */ Byte RD_GreenChEvenOff; /* 0x32, P96003 */ Byte RD_BlueChEvenOff; /* 0x33, P96003 */ Byte RD_RedChOddOff; /* 0x34, P96003 */ Byte RD_GreenChOddOff; /* 0x35, P96003 */ Byte RD_BlueChOddOff; /* 0x36, P96003 */ Byte RD_RedGainOut; /* 0x37, P96003 */ Byte RD_GreenGainOut; /* 0x38, P96003 */ Byte RD_BlueGainOut; /* 0x39, P96003 */ Byte RD_LedControl; /* 0x3a, P96003 */ Byte RD_ShadingCorrectCtrl; /* 0x3b, P96003 */ } Reg96, *pReg96; /* * model override defines */ #define _OVR_NONE 0 #define _OVR_PLUSTEK_9630PL 1 /* for legal version of the OP9630 */ #define _OVR_PRIMAX_4800D 2 /* for the Primax 4800 Direct */ #define _OVR_PLUSTEK_9636 3 /* for 9636T/P+/Turbo */ #define _OVR_PLUSTEK_9636P 4 /* for 9636P */ #define _OVR_PLUSTEK_A3I 5 /* for A3I */ #define _OVR_PLUSTEK_4800P 6 /* for OpticPro4800 */ #define _OVR_PRIMAX_4800D30 7 /* for the Primax 4800 Direct 30bit */ /* CHECK: THIS has to be changed and merged with the old code */ /* * structure to hold IO port specific stuff */ typedef struct { #ifdef __KERNEL__ pFnOut fnOut; pFnIn fnIn; UShort pbSppDataPort; UShort pbEppDataPort; UShort pbStatusPort; UShort pbControlPort; UShort pbAddrOffsetPort; #endif UShort portBase; UShort portMode; UShort lastPortMode; Byte bOldControlValue; Byte bOldDataValue; Byte bOpenCount; Byte delay; /* to allow various delay on port operations */ Bool slowIO; UShort forceMode; Bool useEPPCmdMode; } IODef, *pIODef; /* * structure to hold device specific stuff */ typedef struct { #if 0 PFNVOID pfnIOWrite; PFNVOID pfnCCDInit; DWORD dwLampOnTicks; DWORD dwLampOnBegin; LONG lLeftPositive; LONG lLeftNegative; UCHAR bLampOnMinutes; DRVBOOL fButton; DRVBOOL fSoftReset; UCHAR bStatusLamp; #endif pFnReadData ReadData; /* read function, portmode specific */ ULong dwModelOriginY; Bool f0_8_16; Bool fTpa; /* transparency adapter ? */ Bool f2003; /* has 2003 motor driver ? */ UChar bMotorID; /* the type of the motor drivers */ UChar bPCBID; /* which version of the PCB */ UChar bCCDID; /* what CCD do we have */ pRegDef pCCDRegisters; /* pointer to the register descr */ UShort wNumCCDRegs; /* number of values to write */ UShort DataOriginX; UChar bDACType; /* what DAC do we have */ pRegDef pDACRegisters; /* pointer to DAC reg descr. */ UShort wNumDACRegs; /* number of values to write */ pFnDACOffs fnDarkOffset; /* func-ptr to func for DAC */ pFnDACDark fnDACDark; /* adjustments */ RGBByteDef RegDACOffset; RGBByteDef RegDACGain; UChar buttons; /* Number of buttons */ UChar ModelCtrl; /* contents of the model control reg*/ UChar Model1Mono; /* for model control 1 in mono mode */ UChar Model1Color; /* for model control 1 in color mode*/ UChar XStepMono; UChar XStepColor; UChar XStepBack; long lUpNormal; /* device specific offsets */ long lUpPositive; long lUpNegative; long lLeftNormal; } DeviceDef, *pDeviceDef; /* * to hold all the shading stuff for calibrating a scanner */ typedef struct { pRGBUShortDef pHilight; ColorByte Hilight; ULong dwDiv; UShort wExposure; UShort wXStep; UChar skipHilight; UChar skipShadow; ULong shadingBytes; pDACTblDef pCcdDac; ColorByte DarkDAC; ColorWord DarkOffset; UShort wDarkLevels; UChar bIntermediate; ColorByte Gain; UChar bGainDouble; UChar bUniGain; Byte bMinGain; Byte bMaxGain; Byte bGainHigh; Byte bGainLow; Bool fStop; } ShadingDef, *pShadingDef; /* * structure to hold scan-specific data */ typedef struct _SCANDEF { #if 0 DWORD dwLinesRead; LONG lBufAdjust; DRVBOOL fBackmove; DRVBOOL fEsc; UCHAR Reserved; #endif pFnBool DoSample; pFnDataProcess DataProcess; /* to convert RGB buffers to RGB pixels */ pFnBool DataRead; /* function to get data from scanner */ ULong dwLinesToRead; /* number of images lines to read */ Long lBufferAdjust; ULong dwScanOrigin; /* where to start the scan */ Bool fRefreshState; /* refresh ? */ Bool fMotorBackward; UChar motorPower; /* how to drive the motor */ ULong dwMinReadFifo; ULong dwMaxReadFifo; Byte bFifoSelect; /* defines which FIFO to use */ UChar bDiscardAll; ULong dwInterval; ULong dwInterlace; /* CHECK: here always 0 - remove ? */ union { UShort wGreenDiscard; UShort wGreenKeep; } gd_gk; union { UShort wBlueDiscard; UShort wRedKeep; } bd_rk; UChar bRefresh; /* for controlling the movement */ UChar bOldScanState; UChar bNowScanState; UChar bModuleState; DataPointer p48BitBuf; /* for handling 48-bit data */ union { pUChar pMonoBuf; DataPointer ColorBuf; } bp; RBGPtrDef BufBegin; /* for reading/writing the scan-data */ RBGPtrDef BufEnd; RBGPtrDef BufGet; RBGPtrDef BufData; RBGPtrDef BufPut; ULong negBegin; /* used while scanning in TPA modes */ ULong posBegin; ULong dpiIdx; /* index to get/set values in the table */ pExtXStepDef negScan; /* reference to exposure/xtep table */ } ScanDef, *pScanDef; /* * structure to hold buffer pointers */ typedef struct { union { pUChar pReadBuf; pUChar pShadingMap; pUChar pRWTestBuffer; pUShort pShadingRam; DataPointer Buf; } b1; union { pUChar pSumBuf; pRGBUShortDef pSumRGB; pUChar pRWTestBuffer1; } b2; DataPointer TpaBuf; } BufferDef, *pBufferDef; /* Register RegBitDepth (Addr: 0x13) - ASIC 9800x */ #define _BIT0_7 0x00 #define _BIT8_15 0x01 #define _BIT16_20 0x02 /* Register RegStepControl (Addr: 0x14) - ASIC 9800x */ #define _MOTOR0_ONESTEP 0x01 #define _MOTOR0_SCANSTATE 0x02 #define _MOTOR_FREERUN 0x40 #define _MOTOR_NOFREERUN 0x00 /* Register RegGetScanState (Addr: 0x17, 0x12 on 9600x) - ASIC 9800x */ #define _SCANSTATE_MASK 0x3f /* bit 0-5 */ #define _SCANSTATE_STOP 0x80 /* Register RegReadIOBufBus (Addr: 0x17) - ASIC 9600x only */ #define _IOBUF_BUSMASK 0x0f /* bit 0-3 */ /* Register RegMemoryLow/High (Addr: 0x19/0x1a) - ASIC 9800x */ #define _MAP_ADDR_RED 0x00 #define _MAP_ADDR_GREEN 0x40 #define _MAP_ADDR_BLUE 0x80 #define _MAP_ADDR_SIZE 0x40 /* 0x4000 */ /* Register RegModeControl (Addr: 0x1b, 0x18 on 9600x) - all ASICs*/ #define _ModeScan 0x00 /* all ASICs */ #define _ModeProgram 0x01 /* 9600x def */ #define _ModeIdle 0x01 /* 9800x defs */ #define _ModeShadingMem 0x02 #define _ModeMappingMem 0x03 #define _ModeReadMappingMem 0x07 #define _ModeFifoRSel 0x00 #define _ModeFifoGSel 0x08 #define _ModeFifoBSel 0x10 #define _ModeFifoClose 0x18 /* Register RegLineControl (Addr: 0x1c, 0x19 on 9600x) - all ASICs*/ #define _LINE_SCANTIME_MASK 0x3f /* bit 0-6 */ #define _LINE_CDSINVERSE 0x80 /* Color Drive Signal */ /* Register RegScanControl (Addr: 0x1d) - all ASICs*/ #define _SCAN_BITMODE 0x00 #define _SCAN_BYTEMODE 0x01 /* Gray/Color mode */ #define _SCAN_1ST_AVERAGE 0x04 /* first pixel is averaged pixel */ #define _SCAN_BITDIRR2L 0x08 /* bit shift from right to left */ /* ASIC 9600x section */ #define _P96_SCANDATA_INVERT 0x02 #define _SCAN_LAMP_ON 0x10 /* ASIC 9800x section */ #define _SCAN_12BITMODE 0x02 #define _SCAN_NORMALLAMP_ON 0x10 /* normal Lamp */ #define _SCAN_TPALAMP_ON 0x20 #define _P98_SCANDATA_INVERT 0x40 #define _BITALIGN_LEFT 0x80 #define _SCAN_LAMPS_ON (_SCAN_NORMALLAMP_ON | _SCAN_TPALAMP_ON) /* Register RegMotor0Control (Addr: 0x15) */ #define _MotorDirForward 0x01 #define _MotorDirBackward 0x00 #define _MotorOn 0x02 #define _MotorHFullStepH 0x00 #define _MotorHHalfStep 0x04 #define _MotorHQuarterStep 0x08 #define _MotorHEightStep 0x08 /* for 2916 driver */ #define _MotorPowerEnable 0x40 /* ASIC 98003 specific */ #define _MotorHHomeStop 0x80 #define _FORWARD_MOTOR (_MotorDirForward + _MotorOn + \ _MotorHQuarterStep + _MotorPowerEnable) /* Register RegConfiguration (Addr: 0x1e), ASIC 9800x */ #define _P98_CCD_TYPE_ID 0x07 #define _P98_NEC_MACHINE 0x08 #define _P98_PCBID 0xF0 #define _CCD_3797 0 #define _CCD_3717 1 #define _CCD_3799 1 /* new for 98003 */ #define _CCD_535 2 #define _CCD_2556 3 #define _CCD_518 4 #define _CCD_539 5 /* default for 98001 */ #define _CCD_3777 6 /* new for 98003 */ #define _CCD_548 7 /* new for 98003 */ /* ASIC 98003 section */ #define _OPTICWORKS2000 0x00 #define _PLUSTEK_SCANNER 0x10 #define _SCANNER_WITH_TPA 0x20 #define _SCANNER4Button 0x30 #define _SCANNER4ButtonTPA 0x40 #define _SCANNER5Button 0x50 #define _SCANNER5ButtonTPA 0x60 #define _SCANNER1Button 0x70 #define _SCANNER1ButtonTPA 0x80 #define _SCANNER2Button 0x90 #define _AGFA_SCANNER 0xf0 #define _AGFA_PCB 0x1f /* Register RegModelControl (Addr: 0x1f), all ASICs */ #define _ModelSampleAndHold 0x01 /* sample and hold */ #define _ModelWhiteIs0 0x02 /* white is 0 */ #define _ModelInvertPF 0x04 /* invert paper flag */ #define _ModelDpi200 0 /* (400 / 2) */ #define _ModelDpi300 0x08 /* (600 / 2) */ #define _ModelDpi400 0x10 /* (800 / 2) */ #define _ModelDpi600 0x18 /* (1200 / 2) */ #define _ModelMemSize32k3 0 /* 32k for 300 dpi color */ #define _ModelMemSize64k3 0x20 /* 64k for 300 dpi color */ #define _ModelMemSize128k3 0x40 /* 128k for 300 dpi color */ #define _ModelMemSize64k4 0x60 /* 64k for 400/600 dpi color */ #define _ModelMemSize128k4 0x80 /* 128k for 400/600 dpi color */ #define _ModelMemSize8k 0 /* for 96001 */ #define _ModelMemSize8k3 0x20 #define _ModelMemSize32k96001 0x40 #define _ModelMemSize128k396001 0x60 #define _ModelMemSize128k696001 0x80 #define _HOME_SENSOR_POLARITY 0x01 /* 9800x */ #define _LED_CONTROL 0x02 #define _LED_ACTIVITY 0x04 #define _MODEL_DPI800 0x20 #define _MODEL_DPI1200 0x28 #define _DUMMY_12BIT 0x40 /* Register RegModel1Control (Addr: 0x20), 9800x */ #define _SCAN_GRAYTYPE 0x01 #define _CCD_SHIFT_GATE 0x02 #define _CCD_SHIFT_PULSE 0x04 #define _BUTTON_MODE 0x08 #define _MOTOR_2003 0x00 #define _MOTOR_2916 0x10 #define _MOTOR_7042 0x20 /* Register RegThresholdGapControl (Addr: 0x29, 0x27 on 9600x ) - all ASICs */ #define _THRESHOLDGAP_MASK 0x0f /* Register RegResetConfig (Addr: 0x2e) */ #define _ADC_MASK 0x07 #define _DA_WOLFSON8143 0x00 #define _DA_ESIC 0x04 #define _DA_SAMSUNG8531 0x05 #define _DA_WOLFSON8141 0x06 #define _DA_SAMSUNG1224 0x07 #define _MOTOR0_MASK 0x18 #define _MOTOR0_2003 0x00 #define _MOTOR0_2916 0x08 #define _MOTOR0_7042 0x10 #define _MOTOR1_MASK 0x60 #define _MOTOR1_2003 0x00 #define _MOTOR1_2916 0x20 #define _MOTOR1_7042 0x40 /* Register RegFifoFullLength (Addr: 0x54) */ #define _RED_FULLSIZE 0x00 #define _GREEN_FULLSIZE 0x08 #define _BLUE_FULLSIZE 0x10 /* Register RegScanControl1 (Addr: 0x5b) */ #define _MTSC_ENABLE 0x01 #define _SCANSTOPONBUFFULL 0x02 #define _MFRC_RUNSCANSTATE 0x04 #define _MFRC_BY_XSTEP 0x08 /* Register RegMotorDriverType (Addr: 0x64) */ #define _MOTORS_MASK 0x33 #define _MOTORR_MASK 0xf3 #define _MOTORR_WEAK 0x04 #define _MOTORR_MEDIUM 0x08 #define _MOTORR_STRONG 0x0c #define _MOTORT_WEAK 0x40 #define _MOTORT_MEDIUM 0x80 #define _MOTORT_STRONG 0xc0 #define _BUTTON_SELECT1 0x40 #define _BUTTON_SELECT2 0x80 #define _BUTTON_DISABLE 0xc0 /* Register RegStatus2 (Addr: 0x66) */ #define _REFLECTIONLAMP_ON 0x01 #define _TPALAMP_ON 0x02 #define _STILL_FREE_RUNNING 0x04 #define _BUFFER_IS_FULL 0x08 /* Register RegTestMode (Addr: 0xf0) */ #define _SW_TESTMODE 0x20 /* other stuff... */ /* CHECK: changes this stuff... */ #define _BytesPerChannel 5500UL #define _SizeDataBuf (ULong)(_BytesPerChannel * 3 * 2) #define _SizeTpaDataBuf (ULong)(_BytesPerChannel * 3 * 2) #define _SizeShadingSumBuf (ULong)(_BytesPerChannel * 3 * 4) #define _SizeTotalBuf (ULong)(_SizeDataBuf + _SizeShadingSumBuf) #define _SizeTotalBufTpa (ULong)(_SizeTotalBuf + _SizeTpaDataBuf) /* for DAC programming (ASIC 98003)*/ #define _VALUE_CONFIG 0x51 #define _DAC_RED (Byte)(_VALUE_CONFIG | 0x00) #define _DAC_GREENCOLOR (Byte)(_VALUE_CONFIG | 0x04) #define _DAC_GREENMONO (Byte)(_VALUE_CONFIG | 0x06) #define _DAC_BLUE (Byte)(_VALUE_CONFIG | 0x08) /* internal FIFO buffers (ASIC 9800x) */ #define _SIZE_REDFIFO 196608UL /* 192k */ #define _SIZE_GREENFIFO 147456UL /* 144k */ #define _SIZE_BLUEFIFO 114688UL /* 112k */ #define _SIZE_COLORFIFO _SIZE_BLUEFIFO #define _SIZE_GRAYFIFO (_SIZE_REDFIFO + _SIZE_GREENFIFO + _SIZE_BLUEFIFO) /* Scan State Definitions */ #define _SS_STEP 0x08 #define _SS_RED 0x04 #define _SS_GREEN 0x02 #define _SS_BLUE 0x01 #define _SS_MONO _SS_GREEN #define _SS_COLOR (_SS_RED | _SS_GREEN | _SS_BLUE) /* for shading */ #define _CHANNEL_RED 0 #define _CHANNEL_GREEN 1 #define _CHANNEL_BLUE 2 #endif /* guard __HWDEFS_H__ */ /* END PLUSTEK-PP_HWDEFS.H ..................................................*/ sane-backends-1.0.29/backend/mustek_usb2_transparent.c0000666000000000000000000013361113615534521017625 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2005 Mustek. Originally maintained by Mustek Author:Jack Roy 2005.5.24 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for the Mustek BearPaw 2448 TA Pro and similar USB2 scanners. */ /* forward declarations */ static SANE_Bool Transparent_Reset (void); static SANE_Bool Transparent_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest); static SANE_Bool Transparent_SetupScan (COLORMODE ColorMode, unsigned short XDpi, unsigned short YDpi, SANE_Bool isInvert, unsigned short X, unsigned short Y, unsigned short Width, unsigned short Height); static SANE_Bool Transparent_StopScan (void); static SANE_Bool Transparent_GetRows (SANE_Byte * lpBlock, unsigned short * Rows, SANE_Bool isOrderInvert); static SANE_Bool Transparent_AdjustAD (void); static SANE_Bool Transparent_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY); static SANE_Bool Transparent_LineCalibration16Bits (unsigned short wTAShadingMinus); static SANE_Bool Transparent_PrepareScan (void); /*function description*/ /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: reset the scanner Parameters: none Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_Reset () { DBG (DBG_FUNC, "Transparent_Reset: call in\n"); if (g_bOpened) { DBG (DBG_FUNC, "Transparent_Reset: scanner has been opened\n"); return FALSE; } if (STATUS_GOOD != Asic_Open (&g_chip, g_pDeviceFile)) { DBG (DBG_FUNC, "Transparent_Reset: can not open scanner\n"); return FALSE; } if (STATUS_GOOD != Asic_Reset (&g_chip)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_Reset return error\n"); return FALSE; } if (STATUS_GOOD != Asic_SetSource (&g_chip, LS_POSITIVE)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_SetSource return error\n"); return FALSE; } if (STATUS_GOOD != Asic_TurnLamp (&g_chip, FALSE)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_TurnLamp return error\n"); return FALSE; } if (STATUS_GOOD != Asic_TurnTA (&g_chip, TRUE)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_TurnTA return error\n"); return FALSE; } if (STATUS_GOOD != Asic_Close (&g_chip)) { DBG (DBG_FUNC, "Reflective_Reset: Asic_Close return error\n"); return FALSE; } g_Y = 0; g_wLineartThreshold = 128; g_dwTotalTotalXferLines = 0; g_bFirstReadImage = TRUE; g_pGammaTable = NULL; DBG (DBG_FUNC, "Transparent_Reset: leave Transparent_Reset\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: get suggest parameter of scaning Parameters: pTarget: the information of scaning pSuggest: the suggest parameter of scaning Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_ScanSuggest (PTARGETIMAGE pTarget, PSUGGESTSETTING pSuggest) { unsigned short wMaxWidth, wMaxHeight; int i; DBG (DBG_FUNC, "Transparent_ScanSuggest: call in\n"); for (i = 0; s_wOpticalYDpi[i] != 0; i++) { if (s_wOpticalYDpi[i] <= pTarget->wDpi) { pSuggest->wYDpi = s_wOpticalYDpi[i]; break; } } if (s_wOpticalYDpi[i] == 0) { i--; pSuggest->wYDpi = s_wOpticalYDpi[i]; } for (i = 0; s_wOpticalXDpi[i] != 0; i++) { if (s_wOpticalXDpi[i] <= pTarget->wDpi) { pSuggest->wXDpi = s_wOpticalXDpi[i]; break; } } if (s_wOpticalXDpi[i] == 0) { i--; pSuggest->wXDpi = s_wOpticalXDpi[i]; } pSuggest->wX = (unsigned short) (((unsigned int) (pTarget->wX) * (unsigned int) (pSuggest->wXDpi)) / (unsigned int) (pTarget->wDpi)); pSuggest->wY = (unsigned short) (((unsigned int) (pTarget->wY) * (unsigned int) (pSuggest->wYDpi)) / (unsigned int) (pTarget->wDpi)); pSuggest->wWidth = (unsigned short) (((unsigned int) (pTarget->wWidth) * (unsigned int) (pSuggest->wXDpi)) / (unsigned int) (pTarget->wDpi)); pSuggest->wHeight = (unsigned short) (((unsigned int) (pTarget->wHeight) * (unsigned int) (pSuggest->wYDpi)) / (unsigned int) (pTarget->wDpi)); pSuggest->wWidth = (pSuggest->wWidth / 2) * 2; if (pTarget->cmColorMode == CM_TEXT) { pSuggest->wWidth = ((pSuggest->wWidth + 7) >> 3) << 3; if (pSuggest->wWidth < 8) pSuggest->wWidth = 8; } g_Width = ((pSuggest->wWidth + 15) >> 4) << 4; /* Real Scan Width */ g_Height = pSuggest->wHeight; wMaxWidth = (MAX_SCANNING_WIDTH * pSuggest->wXDpi) / 300; wMaxHeight = (MAX_SCANNING_HEIGHT * pSuggest->wYDpi) / 300; if (pTarget->cmColorMode == CM_TEXT) wMaxWidth = (wMaxWidth >> 3) << 3; if (pSuggest->wWidth > wMaxWidth) pSuggest->wWidth = wMaxWidth; if (pSuggest->wHeight > wMaxHeight) pSuggest->wHeight = wMaxHeight; if (pTarget->isOptimalSpeed) { DBG (DBG_FUNC, "Transparent_ScanSuggest: isOptimalSpeed is true\n"); switch (pTarget->cmColorMode) { case CM_RGB48: pSuggest->cmScanMode = CM_RGB48; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6); break; case CM_RGB24: pSuggest->cmScanMode = CM_RGB24ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3); break; case CM_GRAY16: pSuggest->cmScanMode = CM_GRAY16ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2); break; case CM_GRAY8: pSuggest->cmScanMode = CM_GRAY8ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth)); break; case CM_TEXT: pSuggest->cmScanMode = CM_TEXT; pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8; break; default: break; } } else { DBG (DBG_FUNC, "Transparent_ScanSuggest: isOptimalSpeed not true\n"); switch (pTarget->cmColorMode) { case CM_RGB48: pSuggest->cmScanMode = CM_RGB48; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 6); break; case CM_RGB24: pSuggest->cmScanMode = CM_RGB24ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 3); break; case CM_GRAY16: pSuggest->cmScanMode = CM_GRAY16ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth) * 2); break; case CM_GRAY8: pSuggest->cmScanMode = CM_GRAY8ext; pSuggest->dwBytesPerRow = (unsigned int) ((pSuggest->wWidth)); break; case CM_TEXT: pSuggest->cmScanMode = CM_TEXT; pSuggest->dwBytesPerRow = (unsigned int) (pSuggest->wWidth) / 8; break; default: break; } } DBG (DBG_FUNC, "Transparent_ScanSuggest: leave Transparent_ScanSuggest\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: setup scanning process Parameters: ColorMode: ScanMode of Scanning, CM_RGB48, CM_GRAY and so on XDpi: X Resolution YDpi: Y Resolution isInvert: the RGB order X: X start coordinate Y: Y start coordinate Width: Width of Scan Image Height: Height of Scan Image Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_SetupScan (COLORMODE ColorMode, unsigned short XDpi, unsigned short YDpi, SANE_Bool isInvert, unsigned short X, unsigned short Y, unsigned short Width, unsigned short Height) { SANE_Bool hasTA; unsigned short wTAShadingMinus = 0; isInvert = isInvert; DBG (DBG_FUNC, "Transparent_SetupScan: call in\n"); if (g_bOpened) { DBG (DBG_FUNC, "Transparent_SetupScan: scanner has been opened\n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Transparent_SetupScan: scanner not prepared\n"); return FALSE; } g_ScanMode = ColorMode; g_XDpi = XDpi; g_YDpi = YDpi; g_SWWidth = Width; g_SWHeight = Height; switch (g_YDpi) { case 1200: g_wPixelDistance = 4; g_wLineDistance = 24; g_Height += g_wPixelDistance; break; case 600: g_wPixelDistance = 0; g_wLineDistance = 12; g_Height += g_wPixelDistance; break; case 300: g_wPixelDistance = 0; g_wLineDistance = 6; break; case 150: g_wPixelDistance = 0; g_wLineDistance = 3; break; case 75: case 50: g_wPixelDistance = 0; g_wLineDistance = 1; break; default: g_wLineDistance = 0; } DBG (DBG_FUNC, "Transparent_SetupScan: g_YDpi=%d\n", g_YDpi); DBG (DBG_FUNC, "Transparent_SetupScan: g_wLineDistance=%d\n", g_wLineDistance); DBG (DBG_FUNC, "Transparent_SetupScan: g_wPixelDistance=%d\n", g_wPixelDistance); switch (g_ScanMode) { case CM_RGB48: g_BytesPerRow = 6 * g_Width; /* ASIC limit : width must be 8x */ g_SWBytesPerRow = 6 * g_SWWidth; /* ASIC limit : width must be 8x */ g_bScanBits = 48; g_Height += g_wLineDistance * 2; break; case CM_RGB24ext: g_BytesPerRow = 3 * g_Width; /*ASIC limit : width must be 8x */ g_SWBytesPerRow = 3 * g_SWWidth; g_bScanBits = 24; g_Height += g_wLineDistance * 2; break; case CM_GRAY16ext: g_BytesPerRow = 2 * g_Width; /* ASIC limit : width must be 8x */ g_SWBytesPerRow = 2 * g_SWWidth; g_bScanBits = 16; break; case CM_GRAY8ext: case CM_TEXT: g_BytesPerRow = g_Width; /*ASIC limit : width must be 8x */ g_SWBytesPerRow = g_SWWidth; g_bScanBits = 8; break; default: break; } if (Asic_Open (&g_chip, g_pDeviceFile) != STATUS_GOOD) { DBG (DBG_FUNC, "Transparent_SetupScan: Asic_Open return error\n"); return FALSE; } g_bOpened = TRUE; if (STATUS_GOOD != Asic_TurnLamp (&g_chip, FALSE)) { DBG (DBG_FUNC, "Transparent_SetupScan: Asic_TurnLamp return error\n"); return FALSE; } if (Asic_IsTAConnected (&g_chip, &hasTA) != STATUS_GOOD) { DBG (DBG_FUNC, "Transparent_SetupScan: Asic_IsTAConnected return error\n"); return FALSE; } if (!hasTA) { DBG (DBG_FUNC, "Transparent_SetupScan: no TA device\n"); return FALSE; } if (Asic_TurnTA (&g_chip, TRUE) != STATUS_GOOD) { DBG (DBG_FUNC, "Transparent_SetupScan: Asic_TurnTA return error\n"); return FALSE; } /* Begin Find Left&Top Side */ Asic_MotorMove (&g_chip, TRUE, TRAN_START_POS); if (1200 == g_XDpi) { wTAShadingMinus = 1680; g_XDpi = 600; Transparent_AdjustAD (); Transparent_FindTopLeft (&g_X, &g_Y); g_XDpi = 1200; Transparent_AdjustAD (); } else { wTAShadingMinus = 840; Transparent_AdjustAD (); Transparent_FindTopLeft (&g_X, &g_Y); } DBG (DBG_FUNC, "Transparent_SetupScan: after find top and left g_X=%d, g_Y=%d\n", g_X, g_Y); if (1200 == g_XDpi) { g_X = g_X * 1200 / FIND_LEFT_TOP_CALIBRATE_RESOLUTION + X * 1200 / g_XDpi; } else { if (75 == g_XDpi) { g_X = g_X + X * 600 / g_XDpi - 23; } else { g_X = g_X + X * 600 / g_XDpi; } } DBG (DBG_FUNC, "Transparent_SetupScan: before line calibration,g_X=%d,g_Y=%d\n", g_X, g_Y); Transparent_LineCalibration16Bits (wTAShadingMinus); DBG (DBG_FUNC, "Transparent_SetupScan: after Reflective_LineCalibration16Bits,g_X=%d,g_Y=%d\n", g_X, g_Y); DBG (DBG_FUNC, "Transparent_SetupScan: g_bScanBits=%d, g_XDpi=%d, g_YDpi=%d, g_X=%d, g_Y=%d, g_Width=%d, g_Height=%d\n", g_bScanBits, g_XDpi, g_YDpi, g_X, g_Y, g_Width, g_Height); g_Y = Y * 1200 / g_YDpi + (300 - 40) + 189; Asic_MotorMove (&g_chip, TRUE, g_Y - 360); g_Y = 360; Asic_SetWindow (&g_chip, g_bScanBits, g_XDpi, g_YDpi, g_X, g_Y, g_Width, g_Height); DBG (DBG_FUNC, "Transparent_SetupScan: leave Transparent_SetupScan\n"); return Transparent_PrepareScan (); } /********************************************************************** Author: Jack Date: 2005/05/14 Routine Description: Stop scan Parameters: none Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_StopScan () { DBG (DBG_FUNC, "Transparent_StopScan: call in\n"); if (!g_bOpened) { return FALSE; } if (!g_bPrepared) { return FALSE; } g_isCanceled = TRUE; pthread_cancel (g_threadid_readimage); pthread_join (g_threadid_readimage, NULL); DBG (DBG_FUNC, "Transparent_StopScan: thread exit\n"); Asic_ScanStop (&g_chip); Asic_Close (&g_chip); g_bOpened = FALSE; DBG (DBG_FUNC, "Transparent_StopScan: leave Transparent_StopScan\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Get the data of image Parameters: lpBlock: the data of image Rows: the rows of image isOrderInvert: the RGB order Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_GetRows (SANE_Byte * lpBlock, unsigned short * Rows, SANE_Bool isOrderInvert) { DBG (DBG_FUNC, "Transparent_GetRows: call in\n"); if (!g_bOpened) { return FALSE; } if (!g_bPrepared) { return FALSE; } switch (g_ScanMode) { case CM_RGB48: if (g_XDpi == 1200) return MustScanner_GetRgb48BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetRgb48BitLine (lpBlock, isOrderInvert, Rows); case CM_RGB24ext: if (g_XDpi == 1200) return MustScanner_GetRgb24BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetRgb24BitLine (lpBlock, isOrderInvert, Rows); case CM_GRAY16ext: if (g_XDpi == 1200) return MustScanner_GetMono16BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetMono16BitLine (lpBlock, isOrderInvert, Rows); case CM_GRAY8ext: if (g_XDpi == 1200) return MustScanner_GetMono8BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetMono8BitLine (lpBlock, isOrderInvert, Rows); case CM_TEXT: if (g_XDpi == 1200) return MustScanner_GetMono1BitLine1200DPI (lpBlock, isOrderInvert, Rows); else return MustScanner_GetMono1BitLine (lpBlock, isOrderInvert, Rows); default: return FALSE; } return FALSE; } /********************************************************************** Author: Jack Date: 2005/05/13 Routine Description: To adjust the value of offset gain of R/G/B Parameters: none Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_AdjustAD () { SANE_Byte * lpCalData; unsigned short wCalWidth; int nTimesOfCal; unsigned short wMaxValueR, wMinValueR, wMaxValueG, wMinValueG, wMaxValueB, wMinValueB; #if 0 float fRFactor = 1.0; float fGFactor = 1.0; float fBFactor = 1.0; SANE_Byte bDarkMaxLevel; SANE_Byte bDarkMinLevel; SANE_Byte bLastMinR, bLastROffset, bROffsetUpperBound = 255, bROffsetLowerBound = 0; SANE_Byte bLastMinG, bLastGOffset, bGOffsetUpperBound = 255, bGOffsetLowerBound = 0; SANE_Byte bLastMinB, bLastBOffset, bBOffsetUpperBound = 255, bBOffsetLowerBound = 0; #endif unsigned short wAdjustADResolution; DBG (DBG_FUNC, "Transparent_AdjustAD: call in\n"); if (!g_bOpened) { return FALSE; } if (!g_bPrepared) { return FALSE; } g_chip.AD.DirectionR = R_DIRECTION; g_chip.AD.DirectionG = G_DIRECTION; g_chip.AD.DirectionB = B_DIRECTION; g_chip.AD.GainR = R_GAIN; g_chip.AD.GainG = G_GAIN; g_chip.AD.GainB = B_GAIN; g_chip.AD.OffsetR = 159; g_chip.AD.OffsetG = 50; g_chip.AD.OffsetB = 45; if (g_XDpi <= 600) { wAdjustADResolution = 600; } else { wAdjustADResolution = 1200; } wCalWidth = 10240; lpCalData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * wCalWidth * 3); if (lpCalData == NULL) { return FALSE; } Asic_SetMotorType (&g_chip, FALSE, TRUE); Asic_SetCalibrate (&g_chip, 24, wAdjustADResolution, wAdjustADResolution, 0, 0, wCalWidth, 1, FALSE); MustScanner_PrepareCalculateMaxMin (wAdjustADResolution); nTimesOfCal = 0; #ifdef DEBUG_SAVE_IMAGE Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpCalData, wCalWidth * 3, 24); Asic_ScanStop (&g_chip); FILE *stream = NULL; SANE_Byte * lpBuf = (SANE_Byte *) malloc (50); if (NULL == lpBuf) { DBG (DBG_FUNC, "Transparent_AdjustAD: Leave Transparent_AdjustAD for malloc fail!\n"); return FALSE; } memset (lpBuf, 0, 50); stream = fopen ("/root/AD(Tra).pnm", "wb+\n"); sprintf (lpBuf, "P6\n%d %d\n255\n", wCalWidth, 3); fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream); fwrite (lpCalData, sizeof (SANE_Byte), wCalWidth * 3, stream); fclose (stream); free (lpBuf); #endif do { DBG (DBG_FUNC, "Transparent_AdjustAD: run in first adjust offset do-while\n"); Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpCalData, wCalWidth * 3, 24); Asic_ScanStop (&g_chip); MustScanner_CalculateMaxMin (lpCalData, &wMaxValueR, &wMinValueR, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth, &wMaxValueG, &wMinValueG, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth * 2, &wMaxValueB, &wMinValueB, wAdjustADResolution); if (g_chip.AD.DirectionR == 0) { if (wMinValueR > 15) { if (g_chip.AD.OffsetR < 8) g_chip.AD.DirectionR = 1; else g_chip.AD.OffsetR -= 8; } else if (wMinValueR < 5) g_chip.AD.OffsetR += 8; } else { if (wMinValueR > 15) g_chip.AD.OffsetR += 8; else if (wMinValueR < 5) g_chip.AD.OffsetR -= 8; } if (g_chip.AD.DirectionG == 0) { if (wMinValueG > 15) { if (g_chip.AD.OffsetG < 8) g_chip.AD.DirectionG = 1; else g_chip.AD.OffsetG -= 8; } else if (wMinValueG < 5) g_chip.AD.OffsetG += 8; } else { if (wMinValueG > 15) g_chip.AD.OffsetG += 8; else if (wMinValueG < 5) g_chip.AD.OffsetG -= 8; } if (g_chip.AD.DirectionB == 0) { if (wMinValueB > 15) { if (g_chip.AD.OffsetB < 8) g_chip.AD.DirectionB = 1; else g_chip.AD.OffsetB -= 8; } else if (wMinValueB < 5) g_chip.AD.OffsetB += 8; } else { if (wMinValueB > 15) g_chip.AD.OffsetB += 8; else if (wMinValueB < 5) g_chip.AD.OffsetB -= 8; } nTimesOfCal++; if (nTimesOfCal > 10) break; } while (wMinValueR > 15 || wMinValueR < 5 || wMinValueG > 15 || wMinValueG < 5 || wMinValueB > 15 || wMinValueB < 5); g_chip.AD.GainR = 1 - (double) (wMaxValueR - wMinValueR) / 210 > 0 ? (SANE_Byte) (((1 - (double) (wMaxValueR - wMinValueR) / 210)) * 63 * 6 / 5) : 0; g_chip.AD.GainG = 1 - (double) (wMaxValueG - wMinValueG) / 210 > 0 ? (SANE_Byte) (((1 - (double) (wMaxValueG - wMinValueG) / 210)) * 63 * 6 / 5) : 0; g_chip.AD.GainB = 1 - (double) (wMaxValueB - wMinValueB) / 210 > 0 ? (SANE_Byte) (((1 - (double) (wMaxValueB - wMinValueB) / 210)) * 63 * 6 / 5) : 0; if (g_chip.AD.GainR > 63) g_chip.AD.GainR = 63; if (g_chip.AD.GainG > 63) g_chip.AD.GainG = 63; if (g_chip.AD.GainB > 63) g_chip.AD.GainB = 63; nTimesOfCal = 0; do { Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpCalData, wCalWidth * 3, 24); Asic_ScanStop (&g_chip); MustScanner_CalculateMaxMin (lpCalData, &wMaxValueR, &wMinValueR, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth, &wMaxValueG, &wMinValueG, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth * 2, &wMaxValueB, &wMinValueB, wAdjustADResolution); DBG (DBG_FUNC, "Transparent_AdjustAD: " "RGain=%d, ROffset=%d, RDir=%d GGain=%d, GOffset=%d, GDir=%d BGain=%d, BOffset=%d, BDir=%d\n", g_chip.AD.GainR, g_chip.AD.OffsetR, g_chip.AD.DirectionR, g_chip.AD.GainG, g_chip.AD.OffsetG, g_chip.AD.DirectionG, g_chip.AD.GainB, g_chip.AD.OffsetB, g_chip.AD.DirectionB); DBG (DBG_FUNC, "Transparent_AdjustAD: " "MaxR=%d, MinR=%d MaxG=%d, MinG=%d MaxB=%d, MinB=%d\n", wMaxValueR, wMinValueR, wMaxValueG, wMinValueG, wMaxValueB, wMinValueB); /*R Channel */ if ((wMaxValueR - wMinValueR) > TRAN_MAX_LEVEL_RANGE) { if (g_chip.AD.GainR > 0) g_chip.AD.GainR--; } else { if ((wMaxValueR - wMinValueR) < TRAN_MIN_LEVEL_RANGE) { if (wMaxValueR < TRAN_WHITE_MIN_LEVEL) { g_chip.AD.GainR++; if (g_chip.AD.GainR > 63) g_chip.AD.GainR = 63; } else { if (wMaxValueR > TRAN_WHITE_MAX_LEVEL) { if (g_chip.AD.GainR < 1) g_chip.AD.GainR = 0; else g_chip.AD.GainR--; } else { if (g_chip.AD.GainR > 63) g_chip.AD.GainR = 63; else g_chip.AD.GainR++; } } } else { if (wMaxValueR > TRAN_WHITE_MAX_LEVEL) { if (g_chip.AD.GainR < 1) g_chip.AD.GainR = 0; else g_chip.AD.GainR--; } if (wMaxValueR < TRAN_WHITE_MIN_LEVEL) { if (g_chip.AD.GainR > 63) g_chip.AD.GainR = 63; else g_chip.AD.GainR++; } } } /*G Channel */ if ((wMaxValueG - wMinValueG) > TRAN_MAX_LEVEL_RANGE) { if (g_chip.AD.GainG > 0) g_chip.AD.GainG--; } else { if ((wMaxValueG - wMinValueG) < TRAN_MIN_LEVEL_RANGE) { if (wMaxValueG < TRAN_WHITE_MIN_LEVEL) { g_chip.AD.GainG++; if (g_chip.AD.GainG > 63) g_chip.AD.GainG = 63; } else { if (wMaxValueG > TRAN_WHITE_MAX_LEVEL) { if (g_chip.AD.GainG < 1) g_chip.AD.GainG = 0; else g_chip.AD.GainG--; } else { if (g_chip.AD.GainG > 63) g_chip.AD.GainG = 63; else g_chip.AD.GainG++; } } } else { if (wMaxValueG > TRAN_WHITE_MAX_LEVEL) { if (g_chip.AD.GainG < 1) g_chip.AD.GainG = 0; else g_chip.AD.GainG--; } if (wMaxValueG < TRAN_WHITE_MIN_LEVEL) { if (g_chip.AD.GainG > 63) g_chip.AD.GainG = 63; else g_chip.AD.GainG++; } } } /* B Channel */ if ((wMaxValueB - wMinValueB) > TRAN_MAX_LEVEL_RANGE) { if (g_chip.AD.GainB > 0) g_chip.AD.GainB--; } else { if ((wMaxValueB - wMinValueB) < TRAN_MIN_LEVEL_RANGE) { if (wMaxValueB < TRAN_WHITE_MIN_LEVEL) { g_chip.AD.GainB++; if (g_chip.AD.GainB > 63) g_chip.AD.GainB = 63; } else { if (wMaxValueB > TRAN_WHITE_MAX_LEVEL) { if (g_chip.AD.GainB < 1) g_chip.AD.GainB = 0; else g_chip.AD.GainB--; } else { if (g_chip.AD.GainB > 63) g_chip.AD.GainB = 63; else g_chip.AD.GainB++; } } } else { if (wMaxValueB > TRAN_WHITE_MAX_LEVEL) { if (g_chip.AD.GainB < 1) g_chip.AD.GainB = 0; else g_chip.AD.GainB--; } if (wMaxValueB < TRAN_WHITE_MIN_LEVEL) { if (g_chip.AD.GainB > 63) g_chip.AD.GainB = 63; else g_chip.AD.GainB++; } } } nTimesOfCal++; if (nTimesOfCal > 10) break; } while ((wMaxValueR - wMinValueR) > TRAN_MAX_LEVEL_RANGE || (wMaxValueR - wMinValueR) < TRAN_MIN_LEVEL_RANGE || (wMaxValueG - wMinValueG) > TRAN_MAX_LEVEL_RANGE || (wMaxValueG - wMinValueG) < TRAN_MIN_LEVEL_RANGE || (wMaxValueB - wMinValueB) > TRAN_MAX_LEVEL_RANGE || (wMaxValueB - wMinValueB) < TRAN_MIN_LEVEL_RANGE); /* Adjust Offset 2nd */ nTimesOfCal = 0; do { Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpCalData, wCalWidth * 3, 24); Asic_ScanStop (&g_chip); MustScanner_CalculateMaxMin (lpCalData, &wMaxValueR, &wMinValueR, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth, &wMaxValueG, &wMinValueG, wAdjustADResolution); MustScanner_CalculateMaxMin (lpCalData + wCalWidth * 2, &wMaxValueB, &wMinValueB, wAdjustADResolution); DBG (DBG_FUNC, "Transparent_AdjustAD: " "RGain=%d, ROffset=%d, RDir=%d GGain=%d, GOffset=%d, GDir=%d BGain=%d, BOffset=%d, BDir=%d\n", g_chip.AD.GainR, g_chip.AD.OffsetR, g_chip.AD.DirectionR, g_chip.AD.GainG, g_chip.AD.OffsetG, g_chip.AD.DirectionG, g_chip.AD.GainB, g_chip.AD.OffsetB, g_chip.AD.DirectionB); DBG (DBG_FUNC, "Transparent_AdjustAD: " "MaxR=%d, MinR=%d MaxG=%d, MinG=%d MaxB=%d, MinB=%d\n", wMaxValueR, wMinValueR, wMaxValueG, wMinValueG, wMaxValueB, wMinValueB); if (g_chip.AD.DirectionR == 0) { if (wMinValueR > 20) { if (g_chip.AD.OffsetR < 8) g_chip.AD.DirectionR = 1; else g_chip.AD.OffsetR -= 8; } else if (wMinValueR < 10) g_chip.AD.OffsetR += 8; } else { if (wMinValueR > 20) g_chip.AD.OffsetR += 8; else if (wMinValueR < 10) g_chip.AD.OffsetR -= 8; } if (g_chip.AD.DirectionG == 0) { if (wMinValueG > 20) { if (g_chip.AD.OffsetG < 8) g_chip.AD.DirectionG = 1; else g_chip.AD.OffsetG -= 8; } else if (wMinValueG < 10) g_chip.AD.OffsetG += 8; } else { if (wMinValueG > 20) g_chip.AD.OffsetG += 8; else if (wMinValueG < 10) g_chip.AD.OffsetG -= 8; } if (g_chip.AD.DirectionB == 0) { if (wMinValueB > 20) { if (g_chip.AD.OffsetB < 8) g_chip.AD.DirectionB = 1; else g_chip.AD.OffsetB -= 8; } else if (wMinValueB < 10) g_chip.AD.OffsetB += 8; } else { if (wMinValueB > 20) g_chip.AD.OffsetB += 8; else if (wMinValueB < 10) g_chip.AD.OffsetB -= 8; } nTimesOfCal++; if (nTimesOfCal > 8) break; } while (wMinValueR > 20 || wMinValueR < 10 || wMinValueG > 20 || wMinValueG < 10 || wMinValueB > 20 || wMinValueB < 10); DBG (DBG_FUNC, "Transparent_AdjustAD: leave Transparent_AdjustAD\n"); free (lpCalData); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/14 Routine Description: Find top and left side Parameters: lpwStartX: the left side lpwStartY: the top side Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_FindTopLeft (unsigned short * lpwStartX, unsigned short * lpwStartY) { unsigned short wCalWidth = TA_FIND_LEFT_TOP_WIDTH_IN_DIP; unsigned short wCalHeight = TA_FIND_LEFT_TOP_HEIGHT_IN_DIP; int i, j; unsigned short wLeftSide; unsigned short wTopSide; int nScanBlock; SANE_Byte * lpCalData; unsigned int dwTotalSize; unsigned short wXResolution, wYResolution; DBG (DBG_FUNC, "Transparent_FindTopLeft: call in\n"); if (!g_bOpened) { DBG (DBG_FUNC, "Transparent_FindTopLeft: scanner not opened\n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Transparent_FindTopLeft: scanner not prepared\n"); return FALSE; } wXResolution = wYResolution = FIND_LEFT_TOP_CALIBRATE_RESOLUTION; lpCalData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * wCalWidth * wCalHeight); if (lpCalData == NULL) { DBG (DBG_FUNC, "Transparent_FindTopLeft: lpCalData malloc fail\n"); return FALSE; } dwTotalSize = wCalWidth * wCalHeight; nScanBlock = (int) (dwTotalSize / g_dwCalibrationSize); Asic_SetMotorType (&g_chip, TRUE, TRUE); Asic_SetCalibrate (&g_chip, 8, wXResolution, wYResolution, 0, 0, wCalWidth, wCalHeight, FALSE); Asic_SetAFEGainOffset (&g_chip); Asic_ScanStart (&g_chip); for (i = 0; i < nScanBlock; i++) Asic_ReadCalibrationData (&g_chip, lpCalData + i * g_dwCalibrationSize, g_dwCalibrationSize, 8); Asic_ReadCalibrationData (&g_chip, lpCalData + (nScanBlock) * g_dwCalibrationSize, (dwTotalSize - g_dwCalibrationSize * nScanBlock), 8); Asic_ScanStop (&g_chip); #ifdef DEBUG_SAVE_IMAGE FILE *stream = NULL; SANE_Byte * lpBuf = (SANE_Byte *) malloc (50); if (NULL == lpBuf) { return FALSE; } memset (lpBuf, 0, 50); stream = fopen ("/root/bound(Tra).pnm", "wb+\n"); sprintf (lpBuf, "P5\n%d %d\n255\n", wCalWidth, wCalHeight); fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream); fwrite (lpCalData, sizeof (SANE_Byte), wCalWidth * wCalHeight, stream); fclose (stream); free (lpBuf); #endif wLeftSide = 0; wTopSide = 0; /* Find Left Side */ for (i = (wCalWidth - 1); i > 0; i--) { wLeftSide = *(lpCalData + i); wLeftSide += *(lpCalData + wCalWidth * 2 + i); wLeftSide += *(lpCalData + wCalWidth * 4 + i); wLeftSide += *(lpCalData + wCalWidth * 6 + i); wLeftSide += *(lpCalData + wCalWidth * 8 + i); wLeftSide /= 5; if (wLeftSide < 60) { if (i == (wCalWidth - 1)) { break; } *lpwStartX = i; break; } } /* Find Top Side i=left side */ for (j = 0; j < wCalHeight; j++) { wTopSide = *(lpCalData + wCalWidth * j + i + 2); wTopSide += *(lpCalData + wCalWidth * j + i + 4); wTopSide += *(lpCalData + wCalWidth * j + i + 6); wTopSide += *(lpCalData + wCalWidth * j + i + 8); wTopSide += *(lpCalData + wCalWidth * j + i + 10); wTopSide /= 5; if (wTopSide < 60) { if (j == 0) { break; } *lpwStartY = j; break; } } if ((*lpwStartX < 2200) || (*lpwStartX > 2300)) { *lpwStartX = 2260; } if ((*lpwStartY < 100) || (*lpwStartY > 200)) { *lpwStartY = 124; } Asic_MotorMove (&g_chip, FALSE, (wCalHeight - *lpwStartY) * 1200 / wYResolution + 300); free (lpCalData); DBG (DBG_FUNC, "Transparent_FindTopLeft: *lpwStartY = %d, *lpwStartX = %d\n", *lpwStartY, *lpwStartX); DBG (DBG_FUNC, "Transparent_FindTopLeft: leave Transparent_FindTopLeft\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/15 Routine Description: Get the calibration data Parameters: none Return value: if the operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_LineCalibration16Bits (unsigned short wTAShadingMinus) { unsigned short *lpWhiteShading; unsigned short *lpDarkShading; double wRWhiteLevel = 0; double wGWhiteLevel = 0; double wBWhiteLevel = 0; unsigned int dwRDarkLevel = 0; unsigned int dwGDarkLevel = 0; unsigned int dwBDarkLevel = 0; unsigned int dwREvenDarkLevel = 0; unsigned int dwGEvenDarkLevel = 0; unsigned int dwBEvenDarkLevel = 0; unsigned short * lpRWhiteSort; unsigned short * lpGWhiteSort; unsigned short * lpBWhiteSort; unsigned short * lpRDarkSort; unsigned short * lpGDarkSort; unsigned short * lpBDarkSort; int i, j; SANE_Byte * lpWhiteData; SANE_Byte * lpDarkData; unsigned int dwWhiteTotalSize; unsigned int dwDarkTotalSize; unsigned short wCalHeight = LINE_CALIBRATION__16BITS_HEIGHT; unsigned short wCalWidth = g_Width; DBG (DBG_FUNC, "Transparent_LineCalibration16Bits: call in\n"); if (!g_bOpened) { DBG (DBG_FUNC, "Transparent_LineCalibration16Bits: scanner not opened\n"); return FALSE; } if (!g_bPrepared) { DBG (DBG_FUNC, "Transparent_LineCalibration16Bits: scanner not prepared\n"); return FALSE; } if (g_XDpi < 600) { wTAShadingMinus = wTAShadingMinus * g_XDpi / 600; } dwWhiteTotalSize = wCalWidth * wCalHeight * 3 * 2; dwDarkTotalSize = wCalWidth * wCalHeight * 3 * 2; lpWhiteData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * dwWhiteTotalSize); lpDarkData = (SANE_Byte *) malloc (sizeof (SANE_Byte) * dwDarkTotalSize); if (lpWhiteData == NULL || lpDarkData == NULL) { DBG (DBG_FUNC, "Transparent_LineCalibration16Bits: lpWhiteData or lpDarkData malloc fail\n"); return FALSE; } /*Read white level data */ Asic_SetMotorType (&g_chip, TRUE, TRUE); Asic_SetAFEGainOffset (&g_chip); Asic_SetCalibrate (&g_chip, 48, g_XDpi, g_YDpi, g_X, 0, wCalWidth, wCalHeight, TRUE); Asic_ScanStart (&g_chip); /* Read Data */ Asic_ReadCalibrationData (&g_chip, lpWhiteData, dwWhiteTotalSize, 8); Asic_ScanStop (&g_chip); /* Read dark level data */ Asic_SetMotorType (&g_chip, FALSE, TRUE); Asic_SetAFEGainOffset (&g_chip); Asic_SetCalibrate (&g_chip, 48, g_XDpi, g_YDpi, g_X, 0, wCalWidth, wCalHeight, TRUE); Asic_TurnLamp (&g_chip, FALSE); Asic_TurnTA (&g_chip, FALSE); usleep (500000); Asic_ScanStart (&g_chip); Asic_ReadCalibrationData (&g_chip, lpDarkData, dwDarkTotalSize, 8); Asic_ScanStop (&g_chip); Asic_TurnTA (&g_chip, TRUE); #ifdef DEBUG_SAVE_IMAGE FILE *stream = NULL; SANE_Byte * lpBuf = (SANE_Byte *) malloc (50); if (NULL == lpBuf) { return FALSE; } memset (lpBuf, 0, 50); stream = fopen ("/root/whiteshading(Tra).pnm", "wb+\n"); sprintf (lpBuf, "P6\n%d %d\n65535\n", wCalWidth, wCalHeight); fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream); fwrite (lpWhiteData, sizeof (SANE_Byte), wCalWidth * wCalHeight * 3 * 2, stream); fclose (stream); memset (lpBuf, 0, 50); stream = fopen ("/root/darkshading(Tra).pnm", "wb+\n"); sprintf (lpBuf, "P6\n%d %d\n65535\n", wCalWidth, wCalHeight); fwrite (lpBuf, sizeof (SANE_Byte), strlen (lpBuf), stream); fwrite (lpDarkData, sizeof (SANE_Byte), wCalWidth * wCalHeight * 3 * 2, stream); fclose (stream); free (lpBuf); #endif lpWhiteShading = (unsigned short *) malloc (sizeof (unsigned short) * wCalWidth * 3); lpDarkShading = (unsigned short *) malloc (sizeof (unsigned short) * wCalWidth * 3); lpRWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpGWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpBWhiteSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpRDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpGDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); lpBDarkSort = (unsigned short *) malloc (sizeof (unsigned short) * wCalHeight); if (lpWhiteShading == NULL || lpDarkShading == NULL || lpRWhiteSort == NULL || lpGWhiteSort == NULL || lpBWhiteSort == NULL || lpRDarkSort == NULL || lpGDarkSort == NULL || lpBDarkSort == NULL) { DBG (DBG_FUNC, "Transparent_LineCalibration16Bits: malloc fail\n"); free (lpWhiteData); free (lpDarkData); return FALSE; } DBG (DBG_FUNC, "Transparent_LineCalibration16Bits: wCalWidth = %d, wCalHeight = %d\n", wCalWidth, wCalHeight); /* create dark level shading */ dwRDarkLevel = 0; dwGDarkLevel = 0; dwBDarkLevel = 0; dwREvenDarkLevel = 0; dwGEvenDarkLevel = 0; dwBEvenDarkLevel = 0; for (i = 0; i < wCalWidth; i++) { for (j = 0; j < wCalHeight; j++) { lpRDarkSort[j] = (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 0)); lpRDarkSort[j] += (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 1) << 8); lpGDarkSort[j] = (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 2)); lpGDarkSort[j] += (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 3) << 8); lpBDarkSort[j] = (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 4)); lpBDarkSort[j] += (unsigned short) (*(lpDarkData + j * wCalWidth * 6 + i * 6 + 5) << 8); } /* sum of dark level for all pixels */ if (g_XDpi == 1200) { /* do dark shading table with mean */ if (i % 2) { dwRDarkLevel += (unsigned int) MustScanner_FiltLower (lpRDarkSort, wCalHeight, 20, 30); dwGDarkLevel += (unsigned int) MustScanner_FiltLower (lpGDarkSort, wCalHeight, 20, 30); dwBDarkLevel += (unsigned int) MustScanner_FiltLower (lpBDarkSort, wCalHeight, 20, 30); } else { dwREvenDarkLevel += (unsigned int) MustScanner_FiltLower (lpRDarkSort, wCalHeight, 20, 30); dwGEvenDarkLevel += (unsigned int) MustScanner_FiltLower (lpGDarkSort, wCalHeight, 20, 30); dwBEvenDarkLevel += (unsigned int) MustScanner_FiltLower (lpBDarkSort, wCalHeight, 20, 30); } } else { dwRDarkLevel += (unsigned int) MustScanner_FiltLower (lpRDarkSort, wCalHeight, 20, 30); dwGDarkLevel += (unsigned int) MustScanner_FiltLower (lpGDarkSort, wCalHeight, 20, 30); dwBDarkLevel += (unsigned int) MustScanner_FiltLower (lpBDarkSort, wCalHeight, 20, 30); } } if (g_XDpi == 1200) { dwRDarkLevel = (unsigned int) (dwRDarkLevel / (wCalWidth / 2)) - 512; dwGDarkLevel = (unsigned int) (dwGDarkLevel / (wCalWidth / 2)) - 512; dwBDarkLevel = (unsigned int) (dwBDarkLevel / (wCalWidth / 2)) - 512; dwREvenDarkLevel = (unsigned int) (dwREvenDarkLevel / (wCalWidth / 2)) - 512; dwGEvenDarkLevel = (unsigned int) (dwGEvenDarkLevel / (wCalWidth / 2)) - 512; dwBEvenDarkLevel = (unsigned int) (dwBEvenDarkLevel / (wCalWidth / 2)) - 512; } else { dwRDarkLevel = (unsigned int) (dwRDarkLevel / wCalWidth) - 512; dwGDarkLevel = (unsigned int) (dwGDarkLevel / wCalWidth) - 512; dwBDarkLevel = (unsigned int) (dwBDarkLevel / wCalWidth) - 512; } /* Create white shading */ for (i = 0; i < wCalWidth; i++) { wRWhiteLevel = 0; wGWhiteLevel = 0; wBWhiteLevel = 0; for (j = 0; j < wCalHeight; j++) { lpRWhiteSort[j] = (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 0)); lpRWhiteSort[j] += (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 1) << 8); lpGWhiteSort[j] = (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 2)); lpGWhiteSort[j] += (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 3) << 8); lpBWhiteSort[j] = (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 4)); lpBWhiteSort[j] += (unsigned short) (*(lpWhiteData + j * wCalWidth * 2 * 3 + i * 6 + 5) << 8); } if (1200 == g_XDpi) { if (i % 2) { if (SS_Negative == g_ssScanSource) { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwRDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) dwGDarkLevel; *(lpDarkShading + i * 3 + 2) = (unsigned short) dwBDarkLevel; } else { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwRDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) (dwGDarkLevel * 0.78); *(lpDarkShading + i * 3 + 2) = (unsigned short) dwBDarkLevel; } } else { if (SS_Negative == g_ssScanSource) { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwREvenDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) dwGEvenDarkLevel; *(lpDarkShading + i * 3 + 2) = (unsigned short) dwBEvenDarkLevel; } else { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwREvenDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) (dwGEvenDarkLevel * 0.78); *(lpDarkShading + i * 3 + 2) = (unsigned short) dwBEvenDarkLevel; } } } else { if (SS_Negative == g_ssScanSource) { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwRDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) dwRDarkLevel; *(lpDarkShading + i * 3 + 2) = (unsigned short) dwRDarkLevel; } else { *(lpDarkShading + i * 3 + 0) = (unsigned short) dwRDarkLevel; *(lpDarkShading + i * 3 + 1) = (unsigned short) (dwRDarkLevel * 0.78); *(lpDarkShading + i * 3 + 2) = (unsigned short) dwRDarkLevel; } } /* Create white shading */ wRWhiteLevel = (double) (MustScanner_FiltLower (lpRWhiteSort, wCalHeight, 20, 30) - *(lpDarkShading + i * 3 + 0)); wGWhiteLevel = (double) (MustScanner_FiltLower (lpGWhiteSort, wCalHeight, 20, 30) - *(lpDarkShading + i * 3 + 1)); wBWhiteLevel = (double) (MustScanner_FiltLower (lpBWhiteSort, wCalHeight, 20, 30) - *(lpDarkShading + i * 3 + 2)); if (g_ssScanSource == SS_Negative) { if (wRWhiteLevel > 0) *(lpWhiteShading + i * 3 + 0) = (unsigned short) ((float) 65536 / wRWhiteLevel * 0x1000); else *(lpWhiteShading + i * 3 + 0) = 0x1000; if (wGWhiteLevel > 0) *(lpWhiteShading + i * 3 + 1) = (unsigned short) ((float) (65536 * 1.5) / wGWhiteLevel * 0x1000); else *(lpWhiteShading + i * 3 + 1) = 0x1000; if (wBWhiteLevel > 0) *(lpWhiteShading + i * 3 + 2) = (unsigned short) ((float) (65536 * 2.0) / wBWhiteLevel * 0x1000); else *(lpWhiteShading + i * 3 + 2) = 0x1000; } else { if (wRWhiteLevel > 0) *(lpWhiteShading + i * 3 + 0) = (unsigned short) ((float) 65536 / wRWhiteLevel * 0x1000); else *(lpWhiteShading + i * 3 + 0) = 0x1000; if (wGWhiteLevel > 0) *(lpWhiteShading + i * 3 + 1) = (unsigned short) ((float) (65536 * 1.04) / wGWhiteLevel * 0x1000); else *(lpWhiteShading + i * 3 + 1) = 0x1000; if (wBWhiteLevel > 0) *(lpWhiteShading + i * 3 + 2) = (unsigned short) ((float) 65536 / wBWhiteLevel * 0x1000); else *(lpWhiteShading + i * 3 + 2) = 0x1000; } } free (lpWhiteData); free (lpDarkData); free (lpRWhiteSort); free (lpGWhiteSort); free (lpBWhiteSort); free (lpRDarkSort); free (lpGDarkSort); free (lpBDarkSort); Asic_SetShadingTable (&g_chip, lpWhiteShading, lpDarkShading, g_XDpi, wCalWidth, 0); free (lpWhiteShading); free (lpDarkShading); DBG (DBG_FUNC, "Transparent_LineCalibration16Bits: leave Transparent_LineCalibration16Bits\n"); return TRUE; } /********************************************************************** Author: Jack Date: 2005/05/14 Routine Description: Prepare scan image Parameters: none Return value: if operation is success return TRUE else return FALSE ***********************************************************************/ static SANE_Bool Transparent_PrepareScan () { DBG (DBG_FUNC, "Transparent_PrepareScan: call in\n"); g_wScanLinesPerBlock = g_dwBufferSize / g_BytesPerRow; g_wMaxScanLines = g_dwImageBufferSize / g_BytesPerRow; g_wMaxScanLines = (g_wMaxScanLines / g_wScanLinesPerBlock) * g_wScanLinesPerBlock; g_isCanceled = FALSE; g_dwScannedTotalLines = 0; g_wReadedLines = 0; g_wtheReadyLines = 0; g_wReadImageLines = 0; g_wReadyShadingLine = 0; g_wStartShadingLinePos = 0; switch (g_ScanMode) { case CM_RGB48: g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance; g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n"); return FALSE; } break; case CM_RGB24ext: g_wtheReadyLines = g_wLineDistance * 2 + g_wPixelDistance; g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n"); return FALSE; } break; case CM_GRAY16ext: g_wtheReadyLines = g_wPixelDistance; g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n"); return FALSE; } break; case CM_GRAY8ext: g_wtheReadyLines = g_wPixelDistance; g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n"); return FALSE; } break; case CM_TEXT: g_wtheReadyLines = g_wPixelDistance; g_lpReadImageHead = (SANE_Byte *) malloc (g_dwImageBufferSize); if (g_lpReadImageHead == NULL) { DBG (DBG_FUNC, "Transparent_PrepareScan:malloc fail\n"); return FALSE; } break; default: return FALSE; } Asic_ScanStart (&g_chip); DBG (DBG_FUNC, "Transparent_PrepareScan: leave Transparent_PrepareScan\n"); return TRUE; } /* end of the file ScannerTransparent.c */ sane-backends-1.0.29/backend/canon_pp-dev.c0000666000000000000000000011322613615534521015312 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001-2002 Matthew C. Duggan and Simon Krix 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. ----- This file is part of the canon_pp backend, supporting Canon CanoScan Parallel scanners and also distributed as part of the stand-alone driver. canon_pp-dev.c: $Revision$ Misc constants for Canon CanoScan Parallel scanners and high-level scan functions. Simon Krix */ #ifdef _AIX #include #endif #ifndef NOSANE #include "../include/sane/config.h" #endif #include #include #include #include #include #include #include #include "canon_pp-io.h" #include "canon_pp-dev.h" #ifdef NOSANE /* No SANE, Things that only apply to stand-alone */ #include #include static void DBG(int level, const char *format, ...) { va_list args; va_start(args, format); if (level < 50) vfprintf(stderr, format, args); va_end(args); } #else /* Definitions which only apply to SANE compiles */ #ifndef VERSION #define VERSION "$Revision$" #endif #define DEBUG_DECLARE_ONLY #include "canon_pp.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_backend.h" #endif struct scanner_hardware_desc { char *name; unsigned int natural_xresolution; unsigned int natural_yresolution; unsigned int scanbedlength; unsigned int scanheadwidth; /* 0 means provided by scanner */ unsigned int type; }; static const struct scanner_hardware_desc /* The known scanner types */ hw_fb320p = { "FB320P", 2, 2, 3508, 2552, 0 }, hw_fb330p = { "FB330P", 2, 2, 3508, 0, 1 }, hw_fb620p = { "FB620P", 3, 3, 7016, 5104, 0 }, hw_fb630p = { "FB630P", 3, 3, 7016, 0, 1 }, hw_n640p = { "N640P", 3, 3, 7016, 0, 1 }, hw_n340p = { "N340P", 2, 2, 3508, 0, 1 }, /* A few generic scanner descriptions for aliens */ hw_alien600 = { "Unknown 600dpi", 3, 3, 7016, 0, 1 }, hw_alien300 = { "Unknown 300dpi", 2, 2, 3508, 0, 1 }, hw_alien = { "Unknown (600dpi?)", 3, 3, 7016, 0, 1 }; /* ID table linking ID strings with hardware descriptions */ struct scanner_id { char *id; const struct scanner_hardware_desc *hw; }; static const struct scanner_id scanner_id_table[] = { { "CANON IX-03055C", &hw_fb320p }, { "CANON IX-06025C", &hw_fb620p }, { "CANON IX-03075E", &hw_fb330p }, { "CANON IX-06075E", &hw_fb630p }, { "CANON IX-03095G", &hw_n340p }, { "CANON IX-06115G", &hw_n640p }, { NULL, NULL } }; /*const int scanline_count = 6;*/ static const char *header = "#CANONPP"; static const int fileversion = 3; /* Internal functions */ static unsigned long column_sum(image_segment *image, int x); static int adjust_output(image_segment *image, scan_parameters *scanp, scanner_parameters *scannerp); static int check8(unsigned char *p, int s); /* Converts from weird scanner format -> sequential data */ static void convdata(unsigned char *srcbuffer, unsigned char *dstbuffer, int width, int mode); /* Sets up the scan command. This could use a better name (and a rewrite). */ static int scanner_setup_params(unsigned char *buf, scanner_parameters *sp, scan_parameters *scanp); /* file reading and writing helpers */ static int safe_write(int fd, const char *p, unsigned long len); static int safe_read(int fd, char *p, unsigned long len); /* Command sending loop (waiting for ready status) */ static int send_command(struct parport *port, unsigned char *buf, int bufsize, int delay, int timeout); /* Commands ================================================ */ /* Command_1[] moved to canon_pp-io.c for neatness */ /* Read device ID command */ /* after this 0x26 (38) bytes are read */ static unsigned char cmd_readid[] = { 0xfe, 0x20, 0, 0, 0, 0, 0, 0, 0x26, 0 }; /* Reads 12 bytes of unknown information */ static unsigned char cmd_readinfo[] = { 0xf3, 0x20, 0, 0, 0, 0, 0, 0, 0x0c, 0 }; /* Scan init command: Always followed immediately by command cmd_scan */ static unsigned char cmd_initscan[] = { 0xde, 0x20, 0, 0, 0, 0, 0, 0, 0x2e, 0 }; /* Scan information block */ static unsigned char cmd_scan[45] = { 0x11, 0x2c, 0x11, 0x2c, 0x10, 0x4b, 0x10, 0x4b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x08, 0x01, 0x01, 0x80, 0x01, 0x80, 0x80, 0x02, 0, 0, 0xc1, 0, 0x08, 0x01, 0x01, 0, 0, 0, 0, 0 }; /* Read 6 byte buffer status block */ static unsigned char cmd_buf_status[] = { 0xf3, 0x21, 0, 0, 0, 0, 0, 0, 0x06, 0 }; /* Request a block of image data */ static unsigned char cmd_packet_req[] = {0xd4, 0x20, 0, 0, 0, 0, 0, 0x09, 0x64, 0}; /* "*SCANEND" command - returns the scanner to transparent mode */ static unsigned char cmd_scanend[] = { 0x1b, 0x2a, 0x53, 0x43, 0x41, 0x4e, 0x45, 0x4e, 0x44, 0x0d }; /* Reads BLACK calibration image */ static unsigned char cmd_calblack[] ={0xf8, 0x20, 0, 0, 0, 0, 0, 0x4a, 0xc4, 0}; /* Clear the existing gamma table and create a new one */ static unsigned char cmd_cleargamma[] = {0xc5, 0x20, 0, 0, 0, 0, 0, 0, 0, 0}; /* Read back the gamma table values */ static unsigned char cmd_readgamma[] = {0xf6, 0x20, 0, 0, 0, 0, 0, 0, 0x20, 0}; /* Reads COLOUR (R,G or B) calibration image */ static unsigned char cmd_calcolour[]={0xf9, 0x20, 0, 0, 0, 0, 0, 0x4a, 0xc4, 0}; /* Abort scan */ static unsigned char cmd_abort[] = {0xef, 0x20, 0, 0, 0, 0, 0, 0, 0, 0}; /* Upload the gamma table (followed by 32 byte write) */ static unsigned char cmd_setgamma[] = {0xe6, 0x20, 0, 0, 0, 0, 0, 0, 0x20, 0}; #if 0 /* Something about RGB gamma/gain values? Not currently used by this code */ static unsigned char command_14[32] = { 0x2, 0x0, 0x3, 0x7f, 0x2, 0x0, 0x3, 0x7f, 0x2, 0x0, 0x3, 0x7f, 0, 0, 0, 0, 0x12, 0xd1, 0x14, 0x82, 0, 0, 0, 0, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0, 0 }; #endif /* Misc functions =================================== */ /* * safe_write(): a small wrapper which ensures all the data is written in calls * to write(), since the POSIX call doesn't ensure it. */ static int safe_write(int fd, const char *p, unsigned long len) { int diff; unsigned long total = 0; do { diff = write(fd, p+total, len-total); if (diff < 0) { if (errno == EINTR) continue; return -1; } total += diff; } while (len > total); return 0; } /* same dealie for read, except in the case of read the return of 0 bytes with * no INTR error indicates EOF */ static int safe_read(int fd, char *p, unsigned long len) { int diff; unsigned long total = 0; do { diff = read(fd, p+total, len-total); if (diff <= 0) { if (errno == EINTR) continue; if (diff == 0) return -2; return -1; } total += diff; } while (len > total); return 0; } /* Scan-related functions =================================== */ int sanei_canon_pp_init_scan(scanner_parameters *sp, scan_parameters *scanp) { /* Command for: Initialise and begin the scan procedure */ unsigned char command_b[56]; /* Buffer for buffer info block */ unsigned char buffer_info_block[6]; /* The image size the scanner says we asked for (based on the scanner's replies) */ int true_scanline_size, true_scanline_count; /* The image size we expect to get (based on *scanp) */ int expected_scanline_size, expected_scanline_count; /* Set up the default scan command packet */ memcpy(command_b, cmd_initscan, 10); memcpy(command_b+10, cmd_scan, 45); /* Load the proper settings into it */ scanner_setup_params(command_b+10, sp, scanp); /* Add checksum byte */ command_b[55] = check8(command_b+10, 45); if (send_command(sp->port, command_b, 56, 50000, 1000000)) return -1; /* Ask the scanner about the buffer */ if (send_command(sp->port, cmd_buf_status, 10, 50000, 1000000)) return -1; /* Read buffer information block */ sanei_canon_pp_read(sp->port, 6, buffer_info_block); if (check8(buffer_info_block, 6)) DBG(1, "init_scan: ** Warning: Checksum error reading buffer " "info block.\n"); expected_scanline_count = scanp->height; switch(scanp->mode) { case 0: /* greyscale; 10 bits per pixel */ expected_scanline_size = scanp->width * 1.25; break; case 1: /* true-colour; 30 bits per pixel */ expected_scanline_size = scanp->width * 3.75; break; default: DBG(1, "init_scan: Illegal mode %i requested in " "init_scan().\n", scanp->mode); DBG(1, "This is a bug. Please report it.\n"); return -1; } /* The scanner's idea of the length of each scanline in bytes */ true_scanline_size = (buffer_info_block[0]<<8) | buffer_info_block[1]; /* The scanner's idea of the number of scanlines in total */ true_scanline_count = (buffer_info_block[2]<<8) | buffer_info_block[3]; if ((expected_scanline_size != true_scanline_size) || (expected_scanline_count != true_scanline_count)) { DBG(10, "init_scan: Warning: Scanner is producing an image " "of unexpected size:\n"); DBG(10, "expected: %i bytes wide, %i scanlines tall.\n", expected_scanline_size, expected_scanline_count); DBG(10, "true: %i bytes wide, %i scanlines tall.\n", true_scanline_size, true_scanline_count); if (scanp->mode == 0) scanp->width = true_scanline_size / 1.25; else scanp->width = true_scanline_size / 3.75; scanp->height = true_scanline_count; } return 0; } /* Wake the scanner, detect it, and fill sp with stuff */ int sanei_canon_pp_initialise(scanner_parameters *sp, int mode) { unsigned char scanner_info[12]; const struct scanner_id *cur_id; const struct scanner_hardware_desc *hw; /* Hopefully take the scanner out of transparent mode */ if (sanei_canon_pp_wake_scanner(sp->port, mode)) { DBG(10, "initialise: could not wake scanner\n"); return 1; } /* This block of code does something unknown but necessary */ DBG(50, "initialise: >> scanner_init\n"); if (sanei_canon_pp_scanner_init(sp->port)) { /* If we're using an unsupported ieee1284 mode here, this is * where it will fail, so fall back to nibble. */ sanei_canon_pp_set_ieee1284_mode(M1284_NIBBLE); if (sanei_canon_pp_scanner_init(sp->port)) { DBG(10, "initialise: Could not init scanner.\n"); return 1; } } DBG(50, "initialise: << scanner_init\n"); /* Read Device ID */ memset(sp->id_string, 0, sizeof sp->id_string); if (send_command(sp->port, cmd_readid, 10, 10000, 100000)) return -1; sanei_canon_pp_read(sp->port, 38, (unsigned char *)(sp->id_string)); /* Read partially unknown data */ if (send_command(sp->port, cmd_readinfo, 10, 10000, 100000)) return -1; sanei_canon_pp_read(sp->port, 12, scanner_info); if (check8(scanner_info, 12)) { DBG(10, "initialise: Checksum error reading Info Block.\n"); return 2; } sp->scanheadwidth = (scanner_info[2] << 8) | scanner_info[3]; /* Set up various known values */ cur_id = scanner_id_table; while (cur_id->id) { if (!strncmp(sp->id_string+8, cur_id->id, strlen(cur_id->id))) break; cur_id++; } if (cur_id->id) { hw = cur_id->hw; } else if (sp->scanheadwidth == 5104) { /* Guess 600dpi scanner */ hw = &hw_alien600; } else if (sp->scanheadwidth == 2552) { /* Guess 300dpi scanner */ hw = &hw_alien300; } else { /* Guinea Pigs :) */ hw = &hw_alien; } strcpy(sp->name, hw->name); sp->natural_xresolution = hw->natural_xresolution; sp->natural_yresolution = hw->natural_yresolution; sp->scanbedlength = hw->scanbedlength; if (hw->scanheadwidth) sp->scanheadwidth = hw->scanheadwidth; sp->type = hw->type; return 0; } /* Shut scanner down */ int sanei_canon_pp_close_scanner(scanner_parameters *sp) { /* Put scanner in transparent mode */ sanei_canon_pp_sleep_scanner(sp->port); /* Free memory (with purchase of memory of equal or greater value) */ if (sp->blackweight != NULL) { free(sp->blackweight); sp->blackweight = NULL; } if (sp->redweight != NULL) { free(sp->redweight); sp->redweight = NULL; } if (sp->greenweight != NULL) { free(sp->greenweight); sp->greenweight = NULL; } if (sp->blueweight != NULL) { free(sp->blueweight); sp->blueweight = NULL; } return 0; } /* Read the calibration information from file */ int sanei_canon_pp_load_weights(const char *filename, scanner_parameters *sp) { int fd; int cal_data_size = sp->scanheadwidth * sizeof(unsigned long); int cal_file_size; char buffer[10]; int temp, ret; /* Open file */ if ((fd = open(filename, O_RDONLY)) == -1) return -1; /* Read header and check it's right */ ret = safe_read(fd, buffer, strlen(header) + 1); if ((ret < 0) || strcmp(buffer, header) != 0) { DBG(1,"Calibration file header is wrong, recalibrate please\n"); close(fd); return -2; } /* Read and check file version (the calibrate file format changes from time to time) */ ret = safe_read(fd, (char *)&temp, sizeof(int)); if ((ret < 0) || (temp != fileversion)) { DBG(1,"Calibration file is wrong version, recalibrate please\n"); close(fd); return -3; } /* Allocate memory for calibration values */ if (((sp->blueweight = malloc(cal_data_size)) == NULL) || ((sp->redweight = malloc(cal_data_size)) == NULL) || ((sp->greenweight = malloc(cal_data_size)) == NULL) || ((sp->blackweight = malloc(cal_data_size)) == NULL)) return -4; /* Read width of calibration data */ ret = safe_read(fd, (char *)&cal_file_size, sizeof(cal_file_size)); if ((ret < 0) || (cal_file_size != sp->scanheadwidth)) { DBG(1, "Calibration doesn't match scanner, recalibrate?\n"); close(fd); return -5; } /* Read calibration data */ if (safe_read(fd, (char *)(sp->blackweight), cal_data_size) < 0) { DBG(1, "Error reading black calibration data, recalibrate?\n"); close(fd); return -6; } if (safe_read(fd, (char *)sp->redweight, cal_data_size) < 0) { DBG(1, "Error reading red calibration data, recalibrate?\n"); close(fd); return -7; } if (safe_read(fd, (char *)sp->greenweight, cal_data_size) < 0) { DBG(1, "Error reading green calibration data, recalibrate?\n"); close(fd); return -8; } if (safe_read(fd, (char *)sp->blueweight, cal_data_size) < 0) { DBG(1, "Error reading blue calibration data, recalibrate?\n"); close(fd); return -9; } /* Read white-balance/gamma data */ if (safe_read(fd, (char *)&(sp->gamma), 32) < 0) { close(fd); return -10; } close(fd); return 0; } /* Mode is 0 for greyscale source data or 1 for RGB */ static void convert_to_rgb(image_segment *dest, unsigned char *src, int width, int scanlines, int mode) { int curline; const int colour_size = width * 1.25; const int scanline_size = (mode == 0 ? colour_size : colour_size * 3); for (curline = 0; curline < scanlines; curline++) { if (mode == 0) /* Grey */ { convdata(src + (curline * scanline_size), dest->image_data + (curline * width * 2), width, 1); } else if (mode == 1) /* Truecolour */ { /* Red */ convdata(src + (curline * scanline_size), dest->image_data + (curline * width *3*2) + 4, width, 2); /* Green */ convdata(src + (curline * scanline_size) + colour_size, dest->image_data + (curline * width *3*2) + 2, width, 2); /* Blue */ convdata(src + (curline * scanline_size) + (2 * colour_size), dest->image_data + (curline * width *3*2), width, 2); } } /* End of scanline loop */ } int sanei_canon_pp_read_segment(image_segment **dest, scanner_parameters *sp, scan_parameters *scanp, int scanline_number, int do_adjust, int scanlines_left) { unsigned char *input_buffer = NULL; image_segment *output_image = NULL; unsigned char packet_header[4]; unsigned char packet_req_command[10]; int read_data_size; int scanline_size; if (scanp->mode == 1) /* RGB */ scanline_size = scanp->width * 3.75; else /* Greyscale */ scanline_size = scanp->width * 1.25; read_data_size = scanline_size * scanline_number; /* Allocate output_image struct */ if ((output_image = malloc(sizeof(*output_image))) == NULL) { DBG(1, "read_segment: Error: Not enough memory for scanner " "input buffer\n"); goto error_out; } /* Allocate memory for input buffer */ if ((input_buffer = malloc(scanline_size * scanline_number)) == NULL) { DBG(1, "read_segment: Error: Not enough memory for scanner " "input buffer\n"); goto error_out; } output_image->width = scanp->width; output_image->height = scanline_number; /* Allocate memory for dest image segment */ output_image->image_data = malloc(output_image->width * output_image->height * (scanp->mode ? 3 : 1) * 2); if (output_image->image_data == NULL) { DBG(1, "read_segment: Error: Not enough memory for " "image data\n"); goto error_out; } /* Set up packet request command */ memcpy(packet_req_command, cmd_packet_req, 10); packet_req_command[7] = ((read_data_size + 4) & 0xFF00) >> 8; packet_req_command[8] = (read_data_size + 4) & 0xFF; /* Send packet req. and wait for the scanner's READY signal */ if (send_command(sp->port, packet_req_command, 10, 9000, 2000000)) { DBG(1, "read_segment: Error: didn't get response within 2s " "of sending request"); goto error_out; } /* Read packet header */ if (sanei_canon_pp_read(sp->port, 4, packet_header)) { DBG(1, "read_segment: Error reading packet header\n"); goto error_out; } if ((packet_header[2]<<8) + packet_header[3] != read_data_size) { DBG(1, "read_segment: Error: Expected data size: %i bytes.\n", read_data_size); DBG(1, "read_segment: Expecting %i bytes times %i " "scanlines.\n", scanline_size, scanline_number); DBG(1, "read_segment: Actual data size: %i bytes.\n", (packet_header[2] << 8) + packet_header[3]); goto error_out; } /* Read scanlines_this_packet scanlines into the input buf */ if (sanei_canon_pp_read(sp->port, read_data_size, input_buffer)) { DBG(1, "read_segment: Segment read incorrectly, and we don't " "know how to recover.\n"); goto error_out; } /* This is the only place we can abort safely - * between reading one segment and requesting the next one. */ if (sp->abort_now) goto error_out; if (scanlines_left >= (scanline_number * 2)) { DBG(100, "read_segment: Speculatively starting more scanning " "(%d left)\n", scanlines_left); sanei_canon_pp_write(sp->port, 10, packet_req_command); /* Don't read status, it's unlikely to be ready *just* yet */ } DBG(100, "read_segment: Convert to RGB\n"); /* Convert data */ convert_to_rgb(output_image, input_buffer, scanp->width, scanline_number, scanp->mode); /* Adjust pixel readings according to calibration data */ if (do_adjust) { DBG(100, "read_segment: Adjust output\n"); adjust_output(output_image, scanp, sp); } /* output */ *dest = output_image; /* finished with this now */ free(input_buffer); return 0; error_out: if (output_image && output_image->image_data) free(output_image->image_data); if (output_image) free(output_image); if (input_buffer) free(input_buffer); sp->abort_now = 0; return -1; } /* check8: Calculates the checksum-8 for s bytes pointed to by p. For messages from the scanner, this should normally end up returning 0, since the last byte of most packets is the value that makes the total up to 0 (or 256 if you're left-handed). Hence, usage: if (check8(buffer, size)) {DBG(10, "checksum error!\n");} Can also be used to generate valid checksums for sending to the scanner. */ static int check8(unsigned char *p, int s) { int total=0,i; for(i=0;i linear width is in pixels, not bytes. */ /* This function could use a rewrite */ static void convdata(unsigned char *srcbuffer, unsigned char *dstbuffer, int width, int mode) /* This is a tricky (read: crap) function (read: hack) which is why I probably spent more time commenting it than programming it. The thing to remember here is that the scanner uses interpolated scanlines, so it's RRRRRRRGGGGGGBBBBBB not RGBRGBRGBRGBRGB. So, the calling function just increments the destination pointer slightly to handle green, then a bit more for blue. If you don't understand, tough. */ { int count; int i, j, k; for (count = 0; count < width; count++) { /* The scanner stores data in a bizzare butchered 10-bit format. I'll try to explain it in 100 words or less: Scanlines are made up of groups of 4 pixels. Each group of 4 is stored inside 5 bytes. The first 4 bytes of the group contain the lowest 8 bits of one pixel each (in the right order). The 5th byte contains the most significant 2 bits of each pixel in the same order. */ i = srcbuffer[count + (count >> 2)]; /* Low byte for pixel */ j = srcbuffer[(((count / 4) + 1) * 5) - 1]; /* "5th" byte */ j = j >> ((count % 4) * 2); /* Get upper 2 bits of intensity */ j = j & 0x03; /* Can't hurt */ /* And the final 10-bit pixel value is: */ k = (j << 8) | i; /* now we return this as a 16 bit value */ k = k << 6; if (mode == 1) /* Scanner -> Grey */ { dstbuffer[count * 2] = HIGH_BYTE(k); dstbuffer[(count * 2) + 1] = LOW_BYTE(k); } else if (mode == 2) /* Scanner -> RGB */ { dstbuffer[count * 3 * 2] = HIGH_BYTE(k); dstbuffer[(count * 3 * 2) + 1] = LOW_BYTE(k); } } } static int adjust_output(image_segment *image, scan_parameters *scanp, scanner_parameters *scannerp) /* Needing a good cleanup */ { /* light and dark points for the CCD sensor in question * (stored in file as 0-1024, scaled to 0-65536) */ unsigned long hi, lo; /* The result of our calculations */ unsigned long result; unsigned long temp; /* The CCD sensor which read the current pixel - this is a tricky value to get right. */ int ccd, scaled_xoff; /* Loop variables */ unsigned int scanline, pixelnum, colour; unsigned long int pixel_address; unsigned int cols = scanp->mode ? 3 : 1; for (scanline = 0; scanline < image->height; scanline++) { for (pixelnum = 0; pixelnum < image->width; pixelnum++) { /* Figure out CCD sensor number */ /* MAGIC FORMULA ALERT! */ ccd = (pixelnum << (scannerp->natural_xresolution - scanp->xresolution)) + (1 << (scannerp->natural_xresolution - scanp->xresolution)) - 1; scaled_xoff = scanp->xoffset << (scannerp->natural_xresolution - scanp->xresolution); ccd += scaled_xoff; for (colour = 0; colour < cols; colour++) { /* Address of pixel under scrutiny */ pixel_address = (scanline * image->width * cols * 2) + (pixelnum * cols * 2) + (colour * 2); /* Dark value is easy * Range of lo is 0-18k */ lo = (scannerp->blackweight[ccd]) * 3; /* Light value depends on the colour, * and is an average in greyscale mode. */ if (scanp->mode == 1) /* RGB */ { switch (colour) { case 0: hi = scannerp->redweight[ccd] * 3; break; case 1: hi = scannerp->greenweight[ccd] * 3; break; default: hi = scannerp->blueweight[ccd] * 3; break; } } else /* Grey - scanned using green */ { hi = scannerp->greenweight[ccd] * 3; } /* Check for bad calibration data as it can cause a divide-by-0 error */ if (hi <= lo) { DBG(1, "adjust_output: Bad cal data!" " hi: %ld lo: %ld\n" "Recalibrate, that " "should fix it.\n", hi, lo); return -1; } /* Start with the pixel value in result */ result = MAKE_SHORT(*(image->image_data + pixel_address), *(image->image_data + pixel_address + 1)); result = result >> 6; /* Range now = 0-1023 */ /* if (scanline == 10) DBG(200, "adjust_output: Initial pixel" " value: %ld\n", result); */ result *= 54; /* Range now = 0-54k */ /* Clip to dark and light values */ if (result < lo) result = lo; if (result > hi) result = hi; /* result = (base-lo) * max_value / (hi-lo) */ temp = result - lo; temp *= 65536; temp /= (hi - lo); /* Clip output result has been clipped to lo, * and hi >= lo, so temp can't be < 0 */ if (temp > 65535) temp = 65535; /* if (scanline == 10) { DBG(200, "adjust_output: %d: base = " "%lu, result %lu (%lu " "- %lu)\n", pixelnum, result, temp, lo, hi); } */ result = temp; /* Store the value back where it came * from (always bigendian) */ *(image->image_data + pixel_address) = HIGH_BYTE(result); *(image->image_data + pixel_address+1) = LOW_BYTE(result); } } } /*DBG(100, "Finished adjusting output\n");*/ return 0; } /* Calibration run. Aborting allowed at "safe" points where the scanner won't * be left in a crap state. */ int sanei_canon_pp_calibrate(scanner_parameters *sp, char *cal_file) { int count, readnum, colournum, scanlinenum; int outfile; int scanline_size; int scanline_count = 6; /* Don't change this unless you also want to change do_adjust */ const int calibration_reads = 3; unsigned char command_buffer[10]; image_segment image; unsigned char *databuf; char colours[3][6] = {"Red", "Green", "Blue"}; /* Calibration data is monochromatic (greyscale format) */ scanline_size = sp->scanheadwidth * 1.25; /* 620P has to be difficult here... */ if (!(sp->type) ) scanline_count = 8; /* Probably shouldn't have to abort *just* yet, but may as well check */ if (sp->abort_now) return -1; DBG(40, "Calibrating %ix%i pixels calibration image " "(%i bytes each scan).\n", sp->scanheadwidth, scanline_count, scanline_size * scanline_count); /* Allocate memory for calibration data */ sp->blackweight = (unsigned long *) calloc(sizeof(unsigned long), sp->scanheadwidth); sp->redweight = (unsigned long *) calloc(sizeof(unsigned long), sp->scanheadwidth); sp->greenweight = (unsigned long *) calloc(sizeof(unsigned long), sp->scanheadwidth); sp->blueweight = (unsigned long *) calloc(sizeof(unsigned long), sp->scanheadwidth); /* The data buffer needs to hold a number of images (calibration_reads) * per colour, each sp->scanheadwidth x scanline_count */ databuf = malloc(scanline_size * scanline_count * calibration_reads*3); /* And allocate space for converted image data in this image_segment */ image.image_data = malloc(scanline_count * sp->scanheadwidth * 2 * calibration_reads); image.width = sp->scanheadwidth; image.height = scanline_count * calibration_reads; /* Sending the "dark calibration" command */ memcpy(command_buffer, cmd_calblack, 10); /* Which includes the size of data we expect the scanner to return */ command_buffer[7] = ((scanline_size * scanline_count) & 0xff00) >> 8; command_buffer[8] = (scanline_size * scanline_count) & 0xff; DBG(40, "Step 1/3: Calibrating black level...\n"); for (readnum = 0; readnum < calibration_reads; readnum++) { DBG(40, " * Black scan number %d/%d.\n", readnum + 1, calibration_reads); if (sp->abort_now) return -1; if (send_command(sp->port, command_buffer, 10, 100000, 5000000)) { DBG(1, "Error reading black level!\n"); free (image.image_data); free(databuf); return -1; } /* Black reference data */ sanei_canon_pp_read(sp->port, scanline_size * scanline_count, databuf + (readnum * scanline_size * scanline_count)); } /* Convert scanner format to a greyscale 16bpp image */ for (scanlinenum = 0; scanlinenum < scanline_count * calibration_reads; scanlinenum++) { convdata(databuf + (scanlinenum * scanline_size), image.image_data + (scanlinenum * sp->scanheadwidth*2), sp->scanheadwidth, 1); } /* Take column totals */ for (count = 0; count < sp->scanheadwidth; count++) { /* Value is normalised as if we took 6 scanlines, even if we * didn't (620P I'm looking at you!) */ sp->blackweight[count] = (column_sum(&image, count) * 6) / scanline_count >> 6; } /* 620P has to be difficult here... */ if (!(sp->type) ) { scanline_count = 6; image.height = scanline_count * calibration_reads; } DBG(40, "Step 2/3: Gamma tables...\n"); DBG(40, " * Requesting creation of new of gamma tables...\n"); if (sp->abort_now) return -1; if (send_command(sp->port, cmd_cleargamma, 10, 100000, 5000000)) { DBG(1,"Error sending gamma command!\n"); free (image.image_data); free(databuf); return -1; } DBG(20, " * Snoozing for 15 seconds while the scanner calibrates..."); usleep(15000000); DBG(40, "done.\n"); DBG(40, " * Requesting gamma table values..."); if (send_command(sp->port, cmd_readgamma, 10, 100000, 10000000)) { DBG(1,"Error sending gamma table request!\n"); free (image.image_data); free(databuf); return -1; } DBG(40, "done.\n"); DBG(40, " * Reading white-balance/gamma data... "); sanei_canon_pp_read(sp->port, 32, sp->gamma); DBG(40, "done.\n"); if (sp->abort_now) return -1; memcpy(command_buffer, cmd_calcolour, 10); /* Set up returned data size */ command_buffer[7] = ((scanline_size * scanline_count) & 0xff00) >> 8; command_buffer[8] = (scanline_size * scanline_count) & 0xff; DBG(40, "Step 3/3: Calibrating sensors...\n"); /* Now for the RGB high-points */ for (colournum = 1; colournum < 4; colournum++) { /* Set the colour we want to read */ command_buffer[3] = colournum; for (readnum = 0; readnum < 3; readnum++) { DBG(10, " * %s sensors, scan number %d/%d.\n", colours[colournum-1], readnum + 1, calibration_reads); if (sp->abort_now) return -1; if (send_command(sp->port, command_buffer, 10, 100000, 5000000)) { DBG(1,"Error sending scan request!"); free (image.image_data); free(databuf); return -1; } sanei_canon_pp_read(sp->port, scanline_size * scanline_count, databuf + (readnum * scanline_size * scanline_count)); } /* Convert colour data from scanner format to RGB data */ for (scanlinenum = 0; scanlinenum < scanline_count * calibration_reads; scanlinenum++) { convdata(databuf + (scanlinenum * scanline_size), image.image_data + (scanlinenum * sp->scanheadwidth * 2), sp->scanheadwidth, 1); } /* Sum each column of the image and store the results in sp */ for (count = 0; count < sp->scanheadwidth; count++) { if (colournum == 1) sp->redweight[count] = column_sum(&image, count) >> 6; else if (colournum == 2) sp->greenweight[count] = column_sum(&image, count) >> 6; else sp->blueweight[count] = column_sum(&image, count) >> 6; } } if (sp->abort_now) return -1; /* cal_file == NUL indicates we want an in-memory scan only */ if (cal_file != NULL) { DBG(40, "Writing calibration to %s\n", cal_file); outfile = open(cal_file, O_WRONLY | O_TRUNC | O_CREAT, 0600); if (outfile < 0) { DBG(10, "Error opening cal file for writing\n"); } /* Header */ if (safe_write(outfile, header, strlen(header) + 1) < 0) DBG(10, "Write error on calibration file %s", cal_file); if (safe_write(outfile, (const char *)&fileversion, sizeof(int)) < 0) DBG(10, "Write error on calibration file %s", cal_file); /* Data */ if (safe_write(outfile, (char *)&(sp->scanheadwidth), sizeof(sp->scanheadwidth)) < 0) DBG(10, "Write error on calibration file %s", cal_file); if (safe_write(outfile, (char *)(sp->blackweight), sp->scanheadwidth * sizeof(long)) < 0) DBG(10, "Write error on calibration file %s", cal_file); if (safe_write(outfile, (char *)(sp->redweight), sp->scanheadwidth * sizeof(long)) < 0) DBG(10, "Write error on calibration file %s", cal_file); if (safe_write(outfile, (char *)(sp->greenweight), sp->scanheadwidth * sizeof(long)) < 0) DBG(10, "Write error on calibration file %s", cal_file); if (safe_write(outfile, (char *)(sp->blueweight), sp->scanheadwidth * sizeof(long)) < 0) DBG(10, "Write error on calibration file %s", cal_file); if (safe_write(outfile, (char *)(sp->gamma), 32) < 0) DBG(10, "Write error on calibration file %s", cal_file); close(outfile); } free(databuf); free(image.image_data); return 0; } static unsigned long column_sum(image_segment *image, int x) /* This gives us a number from 0-n*65535 where n is the height of the image */ { unsigned int row, p; unsigned long total = 0; p = x; for (row = 0; row < image->height; row++) { total+= MAKE_SHORT(image->image_data[2*p], image->image_data[2*p+1]); p += image->width; } return total; } static int scanner_setup_params(unsigned char *buf, scanner_parameters *sp, scan_parameters *scanp) { int scaled_width, scaled_height; int scaled_xoff, scaled_yoff; /* Natural resolution (I think) */ if (sp->scanheadwidth == 2552) { buf[0] = 0x11; /* 300 | 0x1000 */ buf[1] = 0x2c; buf[2] = 0x11; buf[3] = 0x2c; } else { buf[0] = 0x12; /* 600 | 0x1000*/ buf[1] = 0x58; buf[2] = 0x12; buf[3] = 0x58; } scaled_width = scanp->width << (sp->natural_xresolution - scanp->xresolution); /* YO! This needs fixing if we ever use yresolution! */ scaled_height = scanp->height << (sp->natural_xresolution - scanp->xresolution); scaled_xoff = scanp->xoffset << (sp->natural_xresolution - scanp->xresolution); scaled_yoff = scanp->yoffset << (sp->natural_xresolution - scanp->xresolution); /* Input resolution */ buf[4] = (((75 << scanp->xresolution) & 0xff00) >> 8) | 0x10; buf[5] = (75 << scanp->xresolution) & 0xff; /* Interpolated resolution */ buf[6] = (((75 << scanp->xresolution) & 0xff00) >> 8) | 0x10;; buf[7] = (75 << scanp->xresolution) & 0xff; /* X offset */ buf[8] = (scaled_xoff & 0xff000000) >> 24; buf[9] = (scaled_xoff & 0xff0000) >> 16; buf[10] = (scaled_xoff & 0xff00) >> 8; buf[11] = scaled_xoff & 0xff; /* Y offset */ buf[12] = (scaled_yoff & 0xff000000) >> 24; buf[13] = (scaled_yoff & 0xff0000) >> 16; buf[14] = (scaled_yoff & 0xff00) >> 8; buf[15] = scaled_yoff & 0xff; /* Width of image to be scanned */ buf[16] = (scaled_width & 0xff000000) >> 24; buf[17] = (scaled_width & 0xff0000) >> 16; buf[18] = (scaled_width & 0xff00) >> 8; buf[19] = scaled_width & 0xff; /* Height of image to be scanned */ buf[20] = (scaled_height & 0xff000000) >> 24; buf[21] = (scaled_height & 0xff0000) >> 16; buf[22] = (scaled_height & 0xff00) >> 8; buf[23] = scaled_height & 0xff; /* These appear to be the only two colour mode possibilities. Pure black-and-white mode probably just uses greyscale and then gets its contrast adjusted by the driver. I forget. */ if (scanp->mode == 1) /* Truecolour */ buf[24] = 0x08; else /* Greyscale */ buf[24] = 0x04; return 0; } int sanei_canon_pp_abort_scan(scanner_parameters *sp) { /* The abort command (hopefully) */ sanei_canon_pp_write(sp->port, 10, cmd_abort); sanei_canon_pp_check_status(sp->port); return 0; } /* adjust_gamma: Upload a gamma profile to the scanner */ int sanei_canon_pp_adjust_gamma(scanner_parameters *sp) { sp->gamma[31] = check8(sp->gamma, 31); if (sanei_canon_pp_write(sp->port, 10, cmd_setgamma)) return -1; if (sanei_canon_pp_write(sp->port, 32, sp->gamma)) return -1; return 0; } int sanei_canon_pp_sleep_scanner(struct parport *port) { /* *SCANEND Command - puts scanner to sleep */ sanei_canon_pp_write(port, 10, cmd_scanend); sanei_canon_pp_check_status(port); ieee1284_terminate(port); return 0; /* FIXME: I murdered Simon's code here */ /* expect(port, "Enter Transparent Mode", 0x1f, 0x1f, 1000000); */ } int sanei_canon_pp_detect(struct parport *port, int mode) { /*int caps;*/ /* This code needs to detect whether or not a scanner is present on * the port, quickly and reliably. Fast version of * sanei_canon_pp_initialise() * * If this detect returns true, a more comprehensive check will * be conducted * Return values: * 0 = scanner present * anything else = scanner not present * PRE: port is open/unclaimed * POST: port is closed/unclaimed */ /* port is already open, just need to claim it */ if (ieee1284_claim(port) != E1284_OK) { DBG(0,"detect: Unable to claim port\n"); return 2; } if (sanei_canon_pp_wake_scanner(port, mode)) { DBG(10, "detect: could not wake scanner\n"); ieee1284_release(port); return 3; } /* Goodo, sleep (snaps fingers) */ sanei_canon_pp_sleep_scanner(port); ieee1284_release(port); /* ieee1284_close(port); */ return 0; } static int send_command(struct parport *port, unsigned char *buf, int bufsize, int delay, int timeout) /* Sends a command until the scanner says it is ready. * sleeps for delay microsecs between reads * returns -1 on error, -2 on timeout */ { int retries = 0; do { /* Send command */ if (sanei_canon_pp_write(port, bufsize, buf)) return -1; /* sleep a bit */ usleep(delay); } while (sanei_canon_pp_check_status(port) && retries++ < (timeout/delay)); if (retries >= (timeout/delay)) return -2; return 0; } sane-backends-1.0.29/backend/hp.c0000666000000000000000000006612513615534521013355 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 1997 Geoffrey T. Dairiki Support for HP PhotoSmart Photoscanner by Peter Kirchgessner 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP Scanners supporting HP Scanner Control Language (SCL). */ static char *hp_backend_version = "1.06"; static char *hp_backend_revision = "$Revision$"; /* Changes: V 1.06: $Log$ Revision 1.22 2008/11/26 21:21:25 kitno-guest * backend/ *.[ch]: nearly every backend used V_MAJOR instead of SANE_CURRENT_MAJOR in sane_init() * backend/snapscan.c: remove EXPECTED_VERSION check since new SANE standard is forward compatible Revision 1.21 2004-10-04 18:09:05 kig-guest Rename global function hp_init_openfd to sanei_hp_init_openfd Revision 1.20 2004/03/27 13:52:39 kig-guest Keep USB-connection open (was problem with Linux 2.6.x) V 1.05: Revision 1.19 2003/10/24 17:26:07 kig-guest Use new sanei-thread-interface Revision 1.18 2003/10/09 19:37:29 kig-guest Redo when TEST UNIT READY failed Redo when read returns with 0 bytes (non-SCSI only) Bug #300241: fix invers image on 3c/4c/6100C at 10 bit depth Revision 1.17 2003/10/06 19:54:07 kig-guest Bug #300248: correct "Negatives" to "Negative" in option description V 1.04, 24-Jul-2003, PK (peter@kirchgessner.net) - Add internationalization V 1.03, 14-Apr-2003, PK (peter@kirchgessner.net) - check valp in call of sane_control_option() V 1.02, 02-Feb-2003, PK (peter@kirchgessner.net) - add OS/2-support by Franz Bakan V 1.01, 06-Dec-2002, PK (peter@kirchgessner.net) - add option dumb-read to work around problems with BusLogic SCSI driver (error during device I/O) V 1.00, 17-Nov-2002, PK (peter@kirchgessner.net) - add libusb support V 0.96, 05-Aug-2002, PK (peter@kirchgessner.net) - check USB device names V 0.95, 07-Jul-2001, PK (peter@kirchgessner.net) - add support for active XPA - check if paper in ADF for ADF scan - add option lamp off - remove some really unused parameters V 0.94, 31-Dec-2000, PK (peter@kirchgessner.net) - always switch off lamp after scan V 0.93, 04-Dec-2000, PK (peter@kirchgessner.net) - fix problem with ADF-support on ScanJet 6350 (and maybe others) V 0.92, 03-Oct-2000, Rupert W. Curwen (rcurwen@uk.research.att.com): - try to not allocate accessors twice (only for accessors that have fixed length) - fix problem with leaving connection open for some error conditions V 0.91, 04-Sep-2000, David Paschal (paschal@rcsis.com): - Added support for flatbed HP OfficeJets - (PK) fix problem with cancel preview V 0.90, 02-Sep-2000, PK: - fix timing problem between killing child and writing to pipe - change fprintf(stderr,...) to DBG - change include to "sane.." in hp.h - change handling of options that have global effects. i.e. if option scanmode is received (has global effect), all options that "may change" are send to the scanner again. This fixes a problem that --resolution specified infront of --mode on command line of scanimage was ignored. NOTE: This change does not allow to specify --depth 12 infront of --mode color, because --depth is only enabled with --mode color. - add depth greater 8 bits for mode grayscale - add option for 8 bit output but 10/12 bit scanning V 0.88, 25-Jul-2000, PK: - remove inlines V 0.88, 20-Jul-2000, PK: - Use sanei_config_read() - dont write chars < 32 to DBG V 0.88, 09-Jul-2000, PK: - Add front button support by Chris S. Cowles, Houston, Texas, c_cowles@ieee.org V 0.87, 28-Jun-2000, PK: - ADF-support for ScanJet IIp - Return error SANE_STATUS_NO_DOCS if no paper in ADF V 0.86, 12-Feb-2000, PK: - fix gcc warnings - fix problems with bitdepths > 8 - allow hp_data_resize to be called with newsize==bufsiz (Jens Heise, ) - add option enable-image-buffering V 0.85, 30-Jan-2000, PK: - correct and enhace data widths > 8 (Ewald de Wit ) - enable data width for all scanners - PhotoSmart: exposure "Off" changed to "Default" - PhotoSmart: even if max. datawidth 24 is reported, allow 30 bits. - change keyword -data-width to -depth and use value for bits per sample - change keyword -halftone-type to -halftone-pattern - change keyword -scantype to -source - fix problem with multiple definition of sanei_debug_hp V 0.83, 04-Jul-99, PK: - reset scanner before downloading parameters (fixes problem with sleep mode of scanners) - fix problem with coredump if non-scanner HP SCSI devices are connected (CDR) - option scan-from-adf replaced by scantype normal/adf/xpa - change value "Film strip" to "Film-strip" for option --media-type - PhotoScanner: allow only scanning at multiple of 300 dpi for scanning slides/film strips. This also fixes a problem with the preview which uses arbitrary resolutions. - Marian Szebenyi: close pipe (endless loop on Digital UNIX) V 0.82, 28-Feb-99, Ewald de Wit : - add options 'exposure time' and 'data width' V 0.81, 11-Jan-99, PK: - occasionally 'scan from ADF' was active for Photoscanner V 0.80, 10-Jan-99, PK: - fix problem with scan size for ADF-scan (thanks to Christop Biardzki for tests) - add option "unload after scan" for HP PhotoScanner - no blanks in command line options - fix problem with segmentation fault for scanimage -d hp:/dev/sga with /dev/sga not included in hp.conf V 0.72, 25-Dec-98, PK: - add patches from mike@easysw.com to fix problems: - core dumps by memory alignment - config file to accept matching devices (scsi HP) - add simulation for brightness/contrast/custom gamma table if not supported by scanner - add configuration options for connect-... V 0.72c, 04-Dec-98, PK: - use sanei_pio - try ADF support V 0.72b, 29-Nov-98 James Carter , PK: - try to add parallel scanner support V 0.71, 14-Nov-98 PK: - add HP 6200 C - cleanup hp_scsi_s structure - show calibrate button on photoscanner only for print media - suppress halftone mode on photoscanner - add media selection for photoscanner V 0.70, 26-Jul-98 PK: - Rename global symbols to sanei_... Change filenames to hp-... Use backend name hp V 0.65, 18-Jul-98 PK: - Dont use pwd.h for VACPP-Compiler to get home-directory, check $SANE_HOME_XHP instead V 0.64, 12-Jul-98 PK: - only download calibration file for media = 1 (prints) - Changes for VACPP-Compiler (check macros __IBMC__, __IBMCPP__) V 0.63, 07-Jun-98 PK: - fix problem with custom gamma table - Add unload button V 0.62, 25-May-98 PK: - make it compilable under sane V 0.73 V 0.61, 28-Mar-98, Peter Kirchgessner : - Add support for HP PhotoSmart Photoscanner - Use more inquiries to see what the scanner supports - Add options: calibrate/Mirror horizontal+vertical - Upload/download calibration data */ #define VERSIO 8 #include "../include/sane/config.h" #include "hp.h" #include /* #include */ /* #include "../include/sane/sane.h" */ #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_thread.h" /* #include "../include/sane/sanei_debug.h" */ #include "hp-device.h" #include "hp-handle.h" #ifndef PATH_MAX # define PATH_MAX 1024 #endif #ifndef NDEBUG #include void sanei_hp_dbgdump (const void * bufp, size_t len) { const hp_byte_t *buf = bufp; int offset = 0; int i; char line[128], pt[32]; for (offset = 0; offset < (int)len; offset += 16) { sprintf (line," 0x%04X ", offset); for (i = offset; i < offset + 16 && i < (int)len; i++) { sprintf (pt," %02X", buf[i]); strcat (line, pt); } while (i++ < offset + 16) strcat (line, " "); strcat (line, " "); for (i = offset; i < offset + 16 && i < (int)len; i++) { sprintf (pt, "%c", isprint(buf[i]) ? buf[i] : '.'); strcat (line, pt); } DBG(16,"%s\n",line); } } #endif typedef struct info_list_el_s * HpDeviceInfoList; struct info_list_el_s { HpDeviceInfoList next; HpDeviceInfo info; }; typedef struct device_list_el_s * HpDeviceList; struct device_list_el_s { HpDeviceList next; HpDevice dev; }; /* Global state */ static struct hp_global_s { hp_bool_t is_up; hp_bool_t config_read; const SANE_Device ** devlist; HpDeviceList device_list; HpDeviceList handle_list; HpDeviceInfoList infolist; HpDeviceConfig config; } global; /* Get the info structure for a device. If not available in global list */ /* add new entry and return it */ static HpDeviceInfo * hp_device_info_create (const char *devname) { HpDeviceInfoList *infolist = &(global.infolist); HpDeviceInfoList infolistelement; HpDeviceInfo *info; int k, found; if (!global.is_up) return 0; found = 0; infolistelement = 0; info = 0; while (*infolist) { infolistelement = *infolist; info = &(infolistelement->info); if (strcmp (info->devname, devname) == 0) /* Already in list ? */ { found = 1; break; } infolist = &(infolistelement->next); } if (found) /* Clear old entry */ { memset (infolistelement, 0, sizeof (*infolistelement)); } else /* New element */ { infolistelement = (HpDeviceInfoList) sanei_hp_allocz (sizeof (*infolistelement)); if (!infolistelement) return 0; info = &(infolistelement->info); *infolist = infolistelement; } k = sizeof (info->devname); strncpy (info->devname, devname, k); info->devname[k-1] = '\0'; info->max_model = -1; info->active_xpa = -1; return info; } static void hp_init_config (HpDeviceConfig *config) { if (config) { config->connect = HP_CONNECT_SCSI; config->use_scsi_request = 1; config->use_image_buffering = 0; config->got_connect_type = 0; config->dumb_read = 0; } } static HpDeviceConfig * hp_global_config_get (void) { if (!global.is_up) return 0; return &(global.config); } static SANE_Status hp_device_config_add (const char *devname) { HpDeviceInfo *info; HpDeviceConfig *config; info = hp_device_info_create (devname); if (!info) return SANE_STATUS_INVAL; config = hp_global_config_get (); if (config) { memcpy (&(info->config), config, sizeof (info->config)); info->config_is_up = 1; } else /* Initialize with default configuration */ { DBG(3, "hp_device_config_add: No configuration found for device %s.\n\tUseing default\n", devname); hp_init_config (&(info->config)); info->config_is_up = 1; } return SANE_STATUS_GOOD; } HpDeviceInfo * sanei_hp_device_info_get (const char *devname) { HpDeviceInfoList *infolist; HpDeviceInfoList infolistelement; HpDeviceInfo *info; int retries = 1; if (!global.is_up) { DBG(17, "sanei_hp_device_info_get: global.is_up = %d\n", (int)global.is_up); return 0; } DBG(250, "sanei_hp_device_info_get: searching %s\n", devname); do { infolist = &(global.infolist); while (*infolist) { infolistelement = *infolist; info = &(infolistelement->info); DBG(250, "sanei_hp_device_info_get: check %s\n", info->devname); if (strcmp (info->devname, devname) == 0) /* Found ? */ { return info; } infolist = &(infolistelement->next); } /* No configuration found. Assume default */ DBG(1, "hp_device_info_get: device %s not configured. Using default\n", devname); if (hp_device_config_add (devname) != SANE_STATUS_GOOD) return 0; } while (retries-- > 0); return 0; } HpDevice sanei_hp_device_get (const char *devname) { HpDeviceList ptr; for (ptr = global.device_list; ptr; ptr = ptr->next) if (strcmp(sanei_hp_device_sanedevice(ptr->dev)->name, devname) == 0) return ptr->dev; return 0; } static void hp_device_info_remove (void) { HpDeviceInfoList next, infolistelement = global.infolist; if (!global.is_up) return; while (infolistelement) { next = infolistelement->next; sanei_hp_free (infolistelement); infolistelement = next; } } static SANE_Status hp_device_list_add (HpDeviceList * list, HpDevice dev) { HpDeviceList new = sanei_hp_alloc(sizeof(*new)); if (!new) return SANE_STATUS_NO_MEM; while (*list) list = &(*list)->next; *list = new; new->next = 0; new->dev = dev; return SANE_STATUS_GOOD; } static SANE_Status hp_device_list_remove (HpDeviceList * list, HpDevice dev) { HpDeviceList old; while (*list && (*list)->dev != dev) list = &(*list)->next; if (!*list) return SANE_STATUS_INVAL; old = *list; *list = (*list)->next; sanei_hp_free(old); return SANE_STATUS_GOOD; } static SANE_Status hp_handle_list_add (HpDeviceList * list, HpHandle h) { return hp_device_list_add(list, (HpDevice)h); } static SANE_Status hp_handle_list_remove (HpDeviceList * list, HpHandle h) { return hp_device_list_remove(list, (HpDevice)h); } static SANE_Status hp_init (void) { memset(&global, 0, sizeof(global)); global.is_up++; DBG(3, "hp_init: global.is_up = %d\n", (int)global.is_up); return SANE_STATUS_GOOD; } static void hp_destroy (void) { if (global.is_up) { /* Close open handles */ while (global.handle_list) sane_close(global.handle_list->dev); /* Remove device infos */ hp_device_info_remove (); sanei_hp_free_all(); global.is_up = 0; DBG(3, "hp_destroy: global.is_up = %d\n", (int)global.is_up); } } static SANE_Status hp_get_dev (const char *devname, HpDevice* devp) { HpDeviceList ptr; HpDevice new; const HpDeviceInfo *info; char *connect; HpConnect hp_connect; SANE_Status status; for (ptr = global.device_list; ptr; ptr = ptr->next) if (strcmp(sanei_hp_device_sanedevice(ptr->dev)->name, devname) == 0) { if (devp) *devp = ptr->dev; return SANE_STATUS_GOOD; } info = sanei_hp_device_info_get (devname); hp_connect = info->config.connect; if (hp_connect == HP_CONNECT_SCSI) connect = "scsi"; else if (hp_connect == HP_CONNECT_DEVICE) connect = "device"; else if (hp_connect == HP_CONNECT_PIO) connect = "pio"; else if (hp_connect == HP_CONNECT_USB) connect = "usb"; else if (hp_connect == HP_CONNECT_RESERVE) connect = "reserve"; else connect = "unknown"; DBG(3, "hp_get_dev: New device %s, connect-%s, scsi-request=%lu\n", devname, connect, (unsigned long)info->config.use_scsi_request); if (!ptr) { status = sanei_hp_device_new (&new, devname); if ( status != SANE_STATUS_GOOD ) return status; } if (devp) *devp = new; RETURN_IF_FAIL( hp_device_list_add(&global.device_list, new) ); return SANE_STATUS_GOOD; } static SANE_Status hp_attach (const char *devname) { DBG(7,"hp_attach: \"%s\"\n", devname); hp_device_config_add (devname); return hp_get_dev (devname, 0); } static void hp_attach_matching_devices (HpDeviceConfig *config, const char *devname) { static int usb_initialized = 0; if (strncmp (devname, "usb", 3) == 0) { config->connect = HP_CONNECT_USB; config->use_scsi_request = 0; DBG(1,"hp_attach_matching_devices: usb attach matching \"%s\"\n",devname); if (!usb_initialized) { sanei_usb_init (); usb_initialized = 1; } sanei_usb_attach_matching_devices (devname, hp_attach); } else { DBG(1, "hp_attach_matching_devices: attach matching %s\n", devname); sanei_config_attach_matching_devices (devname, hp_attach); } } static SANE_Status hp_read_config (void) { FILE * fp; char buf[PATH_MAX], arg1[PATH_MAX], arg2[PATH_MAX], arg3[PATH_MAX]; int nl, nargs; HpDeviceConfig *config, df_config, dev_config; hp_bool_t is_df_config; char cu_device[PATH_MAX]; if (!global.is_up) return SANE_STATUS_INVAL; if (global.config_read) return SANE_STATUS_GOOD; /* The default config will keep options set up until the first device is specified */ hp_init_config (&df_config); config = &df_config; is_df_config = 1; cu_device[0] = '\0'; DBG(1, "hp_read_config: hp backend v%s/%s starts reading config file\n", hp_backend_version, hp_backend_revision); if ((fp = sanei_config_open(HP_CONFIG_FILE)) != 0) { while (sanei_config_read(buf, sizeof(buf), fp)) { char *dev_name; nl = strlen (buf); while (nl > 0) { nl--; if ( (buf[nl] == ' ') || (buf[nl] == '\t') || (buf[nl] == '\r') || (buf[nl] == '\n')) buf[nl] = '\0'; else break; } DBG(1, "hp_read_config: processing line <%s>\n", buf); nargs = sscanf (buf, "%s%s%s", arg1, arg2, arg3); if ((nargs <= 0) || (arg1[0] == '#')) continue; /* Option to process ? */ if ((strcmp (arg1, "option") == 0) && (nargs >= 2)) { if (strcmp (arg2, "connect-scsi") == 0) { config->connect = HP_CONNECT_SCSI; config->got_connect_type = 1; } else if (strcmp (arg2, "connect-device") == 0) { config->connect = HP_CONNECT_DEVICE; config->got_connect_type = 1; config->use_scsi_request = 0; } else if (strcmp (arg2, "connect-pio") == 0) { config->connect = HP_CONNECT_PIO; config->got_connect_type = 1; config->use_scsi_request = 0; } else if (strcmp (arg2, "connect-usb") == 0) { config->connect = HP_CONNECT_USB; config->got_connect_type = 1; config->use_scsi_request = 0; } else if (strcmp (arg2, "connect-reserve") == 0) { config->connect = HP_CONNECT_RESERVE; config->got_connect_type = 1; config->use_scsi_request = 0; } else if (strcmp (arg2, "disable-scsi-request") == 0) { config->use_scsi_request = 0; } else if (strcmp (arg2, "enable-image-buffering") == 0) { config->use_image_buffering = 1; } else if (strcmp (arg2, "dumb-read") == 0) { config->dumb_read = 1; } else { DBG(1,"hp_read_config: Invalid option %s\n", arg2); } } else /* No option. This is the start of a new device */ { if (is_df_config) /* Did we only read default configurations ? */ { is_df_config = 0; /* Stop reading default config */ /* Initialize device config with default-config */ memcpy (&dev_config, &df_config, sizeof (dev_config)); config = &dev_config; /* Start reading a device config */ } if (cu_device[0] != '\0') /* Did we work on a device ? */ { memcpy (hp_global_config_get(), &dev_config,sizeof (dev_config)); hp_attach_matching_devices (hp_global_config_get(), cu_device); cu_device[0] = '\0'; } /* Initialize new device with default config */ memcpy (&dev_config, &df_config, sizeof (dev_config)); /* Cut off leading blanks of device name */ dev_name = buf+strspn (buf, " \t\n\r"); strcpy (cu_device, dev_name); /* Save the device name */ } } if (cu_device[0] != '\0') /* Did we work on a device ? */ { memcpy (hp_global_config_get (), &dev_config, sizeof (dev_config)); DBG(1, "hp_read_config: attach %s\n", cu_device); hp_attach_matching_devices (hp_global_config_get (), cu_device); cu_device[0] = '\0'; } fclose (fp); DBG(1, "hp_read_config: reset to default config\n"); memcpy (hp_global_config_get (), &df_config, sizeof (df_config)); } else { /* default to /dev/scanner instead of insisting on config file */ char *dev_name = "/dev/scanner"; memcpy (hp_global_config_get (), &df_config, sizeof (df_config)); hp_attach_matching_devices (hp_global_config_get (), dev_name); } global.config_read++; return SANE_STATUS_GOOD; } static SANE_Status hp_update_devlist (void) { HpDeviceList devp; const SANE_Device **devlist; int count = 0; RETURN_IF_FAIL( hp_read_config() ); if (global.devlist) sanei_hp_free(global.devlist); for (devp = global.device_list; devp; devp = devp->next) count++; if (!(devlist = sanei_hp_alloc((count + 1) * sizeof(*devlist)))) return SANE_STATUS_NO_MEM; global.devlist = devlist; for (devp = global.device_list; devp; devp = devp->next) *devlist++ = sanei_hp_device_sanedevice(devp->dev); *devlist = 0; return SANE_STATUS_GOOD; } /* * */ SANE_Status sane_init (SANE_Int *version_code, SANE_Auth_Callback __sane_unused__ authorize) {SANE_Status status; DBG_INIT(); DBG(3, "sane_init called\n"); sanei_thread_init (); sanei_hp_init_openfd (); hp_destroy(); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, VERSIO); status = hp_init(); DBG(3, "sane_init will finish with %s\n", sane_strstatus (status)); return status; } void sane_exit (void) { DBG(3, "sane_exit called\n"); hp_destroy(); DBG(3, "sane_exit will finish\n"); } SANE_Status sane_get_devices (const SANE_Device ***device_list, SANE_Bool __sane_unused__ local_only) { DBG(3, "sane_get_devices called\n"); RETURN_IF_FAIL( hp_update_devlist() ); *device_list = global.devlist; DBG(3, "sane_get_devices will finish with %s\n", sane_strstatus (SANE_STATUS_GOOD)); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle *handle) { HpDevice dev = 0; HpHandle h; DBG(3, "sane_open called\n"); RETURN_IF_FAIL( hp_read_config() ); if (devicename[0]) RETURN_IF_FAIL( hp_get_dev(devicename, &dev) ); else { /* empty devicname -> use first device */ if (global.device_list) dev = global.device_list->dev; } if (!dev) return SANE_STATUS_INVAL; if (!(h = sanei_hp_handle_new(dev))) return SANE_STATUS_NO_MEM; RETURN_IF_FAIL( hp_handle_list_add(&global.handle_list, h) ); *handle = h; DBG(3, "sane_open will finish with %s\n", sane_strstatus (SANE_STATUS_GOOD)); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { HpHandle h = handle; DBG(3, "sane_close called\n"); if (!FAILED( hp_handle_list_remove(&global.handle_list, h) )) sanei_hp_handle_destroy(h); DBG(3, "sane_close will finish\n"); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int optnum) { HpHandle h = handle; const SANE_Option_Descriptor *optd; DBG(10, "sane_get_option_descriptor called\n"); optd = sanei_hp_handle_saneoption(h, optnum); DBG(10, "sane_get_option_descriptor will finish\n"); return optd; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int optnum, SANE_Action action, void *valp, SANE_Int *info) { HpHandle h = handle; SANE_Status status; DBG(10, "sane_control_option called\n"); status = sanei_hp_handle_control(h, optnum, action, valp, info); DBG(10, "sane_control_option will finish with %s\n", sane_strstatus (status)); return status; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters *params) { HpHandle h = handle; SANE_Status status; DBG(10, "sane_get_parameters called\n"); status = sanei_hp_handle_getParameters(h, params); DBG(10, "sane_get_parameters will finish with %s\n", sane_strstatus (status)); return status; } SANE_Status sane_start (SANE_Handle handle) { HpHandle h = handle; SANE_Status status; DBG(3, "sane_start called\n"); status = sanei_hp_handle_startScan(h); DBG(3, "sane_start will finish with %s\n", sane_strstatus (status)); return status; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte *buf, SANE_Int max_len, SANE_Int *len) { HpHandle h = handle; size_t length = max_len; SANE_Status status; DBG(16, "sane_read called\n"); status = sanei_hp_handle_read(h, buf, &length); *len = length; DBG(16, "sane_read will finish with %s\n", sane_strstatus (status)); return status; } void sane_cancel (SANE_Handle handle) { HpHandle h = handle; DBG(3, "sane_cancel called\n"); sanei_hp_handle_cancel(h); DBG(3, "sane_cancel will finish\n"); } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { HpHandle h = handle; SANE_Status status; DBG(3, "sane_set_io_mode called\n"); status = sanei_hp_handle_setNonblocking(h, non_blocking); DBG(3, "sane_set_io_mode will finish with %s\n", sane_strstatus (status)); return status; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int *fd) { HpHandle h = handle; SANE_Status status; DBG(10, "sane_get_select_fd called\n"); status = sanei_hp_handle_getPipefd(h, fd); DBG(10, "sane_get_select_fd will finish with %s\n", sane_strstatus (status)); return status; } sane-backends-1.0.29/backend/kodak.c0000666000000000000000000023635213615534521014040 00000000000000/* 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 modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. -------------------------------------------------------------------------- The source code is divided in sections which you can easily find by searching for the tag "@@". Section 1 - Init & static stuff Section 2 - sane_init, _get_devices, _open & friends Section 3 - sane_*_option functions Section 4 - sane_start, _get_param, _read & friends Section 5 - sane_close functions Section 6 - misc functions Changes: v0 through v5 2008-01-15, MAN - development versions v6 2009-06-22, MAN - improved set_window() to build desciptor from scratch - initial release v7 2010-02-10, MAN - add SANE_I18N to static strings - don't fail if scsi buffer is too small SANE FLOW DIAGRAM - sane_init() : initialize backend . - sane_get_devices() : query list of scanner devices . - sane_open() : open a particular scanner device . . - sane_set_io_mode : set blocking mode . . - sane_get_select_fd : get scanner fd . . . . - sane_get_option_descriptor() : get option information . . - sane_control_option() : change option values . . - sane_get_parameters() : returns estimated scan parameters . . - (repeat previous 3 functions) . . . . - sane_start() : start image acquisition . . - sane_get_parameters() : returns actual scan parameters . . - sane_read() : read image data (from pipe) . . (sane_read called multiple times; after sane_read returns EOF, . . loop may continue with sane_start which may return a 2nd page . . when doing duplex scans, or load the next page from the ADF) . . . . - sane_cancel() : cancel operation . - sane_close() : close opened scanner device - sane_exit() : terminate use of backend */ /* * @@ Section 1 - Init */ #include "sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_LIBC_H # include /* NeXTStep/OpenStep */ #endif #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_scsi.h" #include "../include/sane/saneopts.h" #include "../include/sane/sanei_config.h" #include "kodak-cmd.h" #include "kodak.h" #define DEBUG 1 #define BUILD 7 /* values for SANE_DEBUG_KODAK env var: - errors 5 - function trace 10 - function detail 15 - get/setopt cmds 20 - scsi cmd trace 25 - scsi cmd detail 30 - useless noise 35 */ /* ------------------------------------------------------------------------- */ #define STRING_ADFFRONT SANE_I18N("ADF Front") #define STRING_ADFBACK SANE_I18N("ADF Back") #define STRING_ADFDUPLEX SANE_I18N("ADF Duplex") #define STRING_LINEART SANE_VALUE_SCAN_MODE_LINEART #define STRING_HALFTONE SANE_VALUE_SCAN_MODE_HALFTONE #define STRING_GRAYSCALE SANE_VALUE_SCAN_MODE_GRAY #define STRING_COLOR SANE_VALUE_SCAN_MODE_COLOR /* Also set via config file. */ static int global_buffer_size = DEFAULT_BUFFER_SIZE; /* * used by attach* and sane_get_devices * a ptr to a null term array of ptrs to SANE_Device structs * a ptr to a single-linked list of scanner structs */ static const SANE_Device **sane_devArray = NULL; static struct scanner *scanner_devList = NULL; /* * @@ Section 2 - SANE & scanner init code */ /* * Called by SANE initially. * * From the SANE spec: * This function must be called before any other SANE function can be * called. The behavior of a SANE backend is undefined if this * function is not called first. The version code of the backend is * returned in the value pointed to by version_code. If that pointer * is NULL, no version code is returned. Argument authorize is either * a pointer to a function that is invoked when the backend requires * authentication for a specific resource or NULL if the frontend does * not support authentication. */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { authorize = authorize; /* get rid of compiler warning */ DBG_INIT (); DBG (10, "sane_init: start\n"); if (version_code) *version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, BUILD); DBG (5, "sane_init: kodak backend %d.%d.%d, from %s\n", V_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); DBG (10, "sane_init: finish\n"); return SANE_STATUS_GOOD; } /* * Called by SANE to find out about supported devices. * * From the SANE spec: * This function can be used to query the list of devices that are * available. If the function executes successfully, it stores a * pointer to a NULL terminated array of pointers to SANE_Device * structures in *device_list. The returned list is guaranteed to * remain unchanged and valid until (a) another call to this function * is performed or (b) a call to sane_exit() is performed. This * function can be called repeatedly to detect when new devices become * available. If argument local_only is true, only local devices are * returned (devices directly attached to the machine that SANE is * running on). If it is false, the device list includes all remote * devices that are accessible to the SANE library. * * SANE does not require that this function is called before a * sane_open() call is performed. A device name may be specified * explicitly by a user which would make it unnecessary and * undesirable to call this function first. */ /* Read the config file, find scanners with help from sanei_* * store in two global lists of device structs */ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { struct scanner *dev; char line[PATH_MAX]; const char *lp; FILE *fp; int num_devices=0; int i=0; local_only = local_only; /* get rid of compiler warning */ DBG (10, "sane_get_devices: start\n"); /* set this to default before reading the file */ global_buffer_size = DEFAULT_BUFFER_SIZE; fp = sanei_config_open (KODAK_CONFIG_FILE); if (fp) { DBG (15, "sane_get_devices: reading config file %s\n", KODAK_CONFIG_FILE); while (sanei_config_read (line, PATH_MAX, fp)) { lp = line; /* ignore comments */ if (*lp == '#') continue; /* skip empty lines */ if (*lp == 0) continue; if ((strncmp ("option", lp, 6) == 0) && isspace (lp[6])) { lp += 6; lp = sanei_config_skip_whitespace (lp); /* we allow setting buffersize too big */ if ((strncmp (lp, "buffer-size", 11) == 0) && isspace (lp[11])) { int buf; lp += 11; lp = sanei_config_skip_whitespace (lp); buf = atoi (lp); if (buf < 4096) { DBG (5, "sane_get_devices: config option \"buffer-size\" \ (%d) is < 4096, ignoring!\n", buf); continue; } if (buf > DEFAULT_BUFFER_SIZE) { DBG (5, "sane_get_devices: config option \"buffer-size\" \ (%d) is > %d, warning!\n", buf, DEFAULT_BUFFER_SIZE); } DBG (15, "sane_get_devices: setting \"buffer-size\" to %d\n", buf); global_buffer_size = buf; } else { DBG (5, "sane_get_devices: config option \"%s\" \ unrecognized\n", lp); } } else if ((strncmp ("scsi", lp, 4) == 0) && isspace (lp[4])) { DBG (15, "sane_get_devices: looking for '%s'\n", lp); sanei_config_attach_matching_devices (lp, attach_one); } else{ DBG (5, "sane_get_devices: config line \"%s\" unrecognized\n", lp); } } fclose (fp); } else { DBG (5, "sane_get_devices: no config file '%s', using defaults\n", KODAK_CONFIG_FILE); DBG (15, "sane_get_devices: looking for 'scsi KODAK'\n"); sanei_config_attach_matching_devices ("scsi KODAK", attach_one); } for (dev = scanner_devList; dev; dev=dev->next) { DBG (15, "sane_get_devices: found scanner %s\n",dev->device_name); num_devices++; } DBG (15, "sane_get_devices: found %d scanner(s)\n",num_devices); sane_devArray = calloc (num_devices + 1, sizeof (SANE_Device*)); if (!sane_devArray) return SANE_STATUS_NO_MEM; for (dev = scanner_devList; dev; dev=dev->next) { sane_devArray[i++] = (SANE_Device *)&dev->sane; } sane_devArray[i] = 0; if(device_list){ *device_list = sane_devArray; } DBG (10, "sane_get_devices: finish\n"); return SANE_STATUS_GOOD; } /* build the scanner struct and link to global list * unless struct is already loaded, then pretend */ static SANE_Status attach_one (const char *device_name) { struct scanner *s; int ret; DBG (10, "attach_one: start\n"); DBG (15, "attach_one: looking for '%s'\n", device_name); for (s = scanner_devList; s; s = s->next) { if (strcmp (s->sane.name, device_name) == 0) { DBG (10, "attach_one: already attached!\n"); return SANE_STATUS_GOOD; } } /* build a struct to hold it */ if ((s = calloc (sizeof (*s), 1)) == NULL) return SANE_STATUS_NO_MEM; /* scsi command/data buffer */ s->buffer_size = global_buffer_size; /* copy the device name */ s->device_name = strdup (device_name); if (!s->device_name){ free (s); return SANE_STATUS_NO_MEM; } /* connect the fd */ s->fd = -1; ret = connect_fd(s); if(ret != SANE_STATUS_GOOD){ free (s->device_name); free (s); return ret; } /* Now query the device to load its vendor/model/version */ ret = init_inquire (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s->device_name); free (s); DBG (5, "attach_one: inquiry 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); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s->device_name); free (s); DBG (5, "attach_one: model failed\n"); return ret; } /* sets user 'values' to good defaults */ ret = init_user (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s->device_name); free (s); DBG (5, "attach_one: user failed\n"); return ret; } /* sets SANE option 'values' to good defaults */ ret = init_options (s); if (ret != SANE_STATUS_GOOD) { disconnect_fd(s); free (s->device_name); free (s); DBG (5, "attach_one: options failed\n"); return ret; } /* we close the connection, so that another backend can talk to scanner */ disconnect_fd(s); /* load info into sane_device struct */ s->sane.name = s->device_name; s->sane.vendor = s->vendor_name; s->sane.model = s->product_name; s->sane.type = "scanner"; s->next = scanner_devList; scanner_devList = s; DBG (10, "attach_one: finish\n"); return SANE_STATUS_GOOD; } /* * connect the fd in the scanner struct */ static SANE_Status connect_fd (struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; int buffer_size = s->buffer_size; DBG (10, "connect_fd: start\n"); if(s->fd > -1){ DBG (5, "connect_fd: already open\n"); ret = SANE_STATUS_GOOD; } else { ret = sanei_scsi_open_extended (s->device_name, &(s->fd), sense_handler, s, &s->buffer_size); if(!ret && buffer_size != s->buffer_size){ DBG (5, "connect_fd: cannot get requested buffer size (%d/%d)\n", buffer_size, s->buffer_size); } else{ DBG (15, "connect_fd: opened SCSI device\n"); } } DBG (10, "connect_fd: finish %d\n", ret); return ret; } /* * This routine will check if a certain device is a Kodak scanner * It also copies interesting data from INQUIRY into the handle structure */ static SANE_Status init_inquire (struct scanner *s) { int i; SANE_Status ret; unsigned char cmd[INQUIRY_len]; size_t cmdLen = INQUIRY_len; unsigned char in[I_data_len]; size_t inLen = I_data_len; DBG (10, "init_inquire: start\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd, INQUIRY_code); set_I_evpd (cmd, 0); set_I_page_code (cmd, I_page_code_default); set_I_data_length (cmd, inLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, in, &inLen ); if (ret != SANE_STATUS_GOOD){ return ret; } if (get_I_periph_qual(in) != I_periph_qual_valid){ DBG (5, "The device at '%s' has invalid periph_qual.\n", s->device_name); return SANE_STATUS_INVAL; } if (get_I_periph_devtype(in) != I_periph_devtype_scanner){ DBG (5, "The device at '%s' is not a scanner.\n", s->device_name); return SANE_STATUS_INVAL; } get_I_vendor (in, s->vendor_name); get_I_product (in, s->product_name); get_I_version (in, s->version_name); get_I_build (in, s->build_name); s->vendor_name[8] = 0; s->product_name[16] = 0; s->version_name[4] = 0; s->build_name[2] = 0; /* gobble trailing spaces */ for (i = 7; s->vendor_name[i] == ' ' && i >= 0; i--) s->vendor_name[i] = 0; for (i = 15; s->product_name[i] == ' ' && i >= 0; i--) s->product_name[i] = 0; for (i = 3; s->version_name[i] == ' ' && i >= 0; i--) s->version_name[i] = 0; for (i = 2; s->build_name[i] == ' ' && i >= 0; i--) s->build_name[i] = 0; if (strcmp ("KODAK", s->vendor_name)) { DBG (5, "The device at '%s' is reported to be made by '%s'\n", s->device_name, s->vendor_name); DBG (5, "This backend only supports Kodak products.\n"); return SANE_STATUS_INVAL; } DBG (15, "init_inquire: Found '%s' '%s' '%s' '%s' at '%s'\n", s->vendor_name, s->product_name, s->version_name, s->build_name, s->device_name); /*defined in SCSI spec*/ DBG (15, "standard inquiry options\n"); /*FIXME: do we need to save these?*/ DBG (15, " PQ: %d\n",get_I_periph_qual(in)); DBG (15, " PDT: %d\n",get_I_periph_devtype(in)); DBG (15, " RMB: %d\n",get_I_rmb(in)); DBG (15, " DTQ: %d\n",get_I_devtype_qual(in)); DBG (15, " ISO: %d\n",get_I_iso_version(in)); DBG (15, " ECMA: %d\n",get_I_ecma_version(in)); DBG (15, " ANSI: %d\n",get_I_ansi_version(in)); DBG (15, " AENC: %d\n",get_I_aenc(in)); DBG (15, " TrmIOP: %d\n",get_I_trmiop(in)); DBG (15, " RDF: %d\n",get_I_resonse_format(in)); DBG (15, " Length: %d\n",get_I_length(in)); DBG (15, " RelAdr: %d\n",get_I_reladr(in)); DBG (15, " WBus32: %d\n",get_I_wbus32(in)); DBG (15, " WBus16: %d\n",get_I_wbus16(in)); DBG (15, " Sync: %d\n",get_I_sync(in)); DBG (15, " Linked: %d\n",get_I_linked(in)); DBG (15, " CmdQue: %d\n",get_I_cmdque(in)); DBG (15, " SftRe: %d\n",get_I_sftre(in)); /*kodak specific*/ DBG (15, "vendor inquiry options\n"); DBG (15, " MF Disable: %d\n",get_I_mf_disable(in)); DBG (15, " Checkdigit: %d\n",get_I_checkdigit(in)); DBG (15, " Front Prism: %d\n",get_I_front_prism(in)); DBG (15, " Comp Gray: %d\n",get_I_compressed_gray(in)); DBG (15, " Front Toggle: %d\n",get_I_front_toggle(in)); DBG (15, " Front DP1: %d\n",get_I_front_dp1(in)); DBG (15, " Front Color: %d\n",get_I_front_color(in)); DBG (15, " Front ATP: %d\n",get_I_front_atp(in)); DBG (15, " DP1 180: %d\n",get_I_dp1_180(in)); DBG (15, " MF Pause: %d\n",get_I_mf_pause(in)); DBG (15, " Rear Prism: %d\n",get_I_rear_prism(in)); DBG (15, " Uncomp Gray: %d\n",get_I_uncompressed_gray(in)); DBG (15, " Rear Toggle: %d\n",get_I_rear_toggle(in)); DBG (15, " Rear DP1: %d\n",get_I_rear_dp1(in)); DBG (15, " Rear Color: %d\n",get_I_rear_color(in)); DBG (15, " Rear ATP: %d\n",get_I_rear_atp(in)); /* we actually care about these */ DBG (15, " Min Binary Res: %d\n",get_I_min_bin_res(in)); s->s_res_min[MODE_LINEART] = get_I_min_bin_res(in); DBG (15, " Max Binary Res: %d\n",get_I_max_bin_res(in)); s->s_res_max[MODE_LINEART] = get_I_max_bin_res(in); DBG (15, " Min Color Res: %d\n",get_I_min_col_res(in)); s->s_res_min[MODE_COLOR] = get_I_min_col_res(in); DBG (15, " Max Color Res: %d\n",get_I_max_col_res(in)); s->s_res_max[MODE_COLOR] = get_I_max_col_res(in); DBG (15, " Max Width: %d\n",get_I_max_image_width(in)); s->s_width_max = get_I_max_image_width(in); DBG (15, " Max Length: %d\n",get_I_max_image_length(in)); s->s_length_max = get_I_max_image_length(in); /*FIXME: do we need to save these?*/ DBG (15, " Finecrop: %d\n",get_I_finecrop(in)); DBG (15, " iThresh: %d\n",get_I_ithresh(in)); DBG (15, " ECD: %d\n",get_I_ecd(in)); DBG (15, " VBLR: %d\n",get_I_vblr(in)); DBG (15, " Elevator: %d\n",get_I_elevator(in)); DBG (15, " RelCrop: %d\n",get_I_relcrop(in)); DBG (15, " CDeskew: %d\n",get_I_cdeskew(in)); DBG (15, " IA: %d\n",get_I_ia(in)); DBG (15, " Patch: %d\n",get_I_patch(in)); DBG (15, " Null Mode: %d\n",get_I_nullmode(in)); DBG (15, " SABRE: %d\n",get_I_sabre(in)); DBG (15, " LDDDS: %d\n",get_I_lddds(in)); DBG (15, " UDDDS: %d\n",get_I_uddds(in)); DBG (15, " Fixed Gap: %d\n",get_I_fixedgap(in)); DBG (15, " HR Printer: %d\n",get_I_hr_printer(in)); DBG (15, " Elev 100/250: %d\n",get_I_elev_100_250(in)); DBG (15, " UDDS Individual: %d\n",get_I_udds_individual(in)); DBG (15, " Auto Color: %d\n",get_I_auto_color(in)); DBG (15, " WB: %d\n",get_I_wb(in)); DBG (15, " ES: %d\n",get_I_es(in)); DBG (15, " FC: %d\n",get_I_fc(in)); DBG (15, " Max Rate: %d\n",get_I_max_rate(in)); DBG (15, " Buffer Size: %d\n",get_I_buffer_size(in)); DBG (10, "init_inquire: finish\n"); return SANE_STATUS_GOOD; } /* * get model specific info that is not in vpd, and correct * errors in vpd data. struct is already initialized to 0. */ static SANE_Status init_model (struct scanner *s) { DBG (10, "init_model: start\n"); s->s_mode[MODE_LINEART] = 1; s->s_mode[MODE_HALFTONE] = 1; s->s_mode[MODE_GRAYSCALE] = 1; s->s_mode[MODE_COLOR] = 1; /* scanner did not tell us these */ s->s_res_min[MODE_HALFTONE] = s->s_res_min[MODE_LINEART]; s->s_res_max[MODE_HALFTONE] = s->s_res_max[MODE_LINEART]; s->s_res_min[MODE_GRAYSCALE] = s->s_res_min[MODE_COLOR]; s->s_res_max[MODE_GRAYSCALE] = s->s_res_max[MODE_COLOR]; s->s_width_min = 96; s->s_length_min = 96; s->s_brightness_steps = 0; s->s_contrast_steps = 255; s->s_threshold_steps = 255; s->s_rif = 1; DBG (10, "init_model: finish\n"); return SANE_STATUS_GOOD; } /* * set good default user values. * struct is already initialized to 0. */ static SANE_Status init_user (struct scanner *s) { DBG (10, "init_user: start\n"); /* source */ s->u_source = SOURCE_ADF_FRONT; /* scan mode */ s->u_mode = MODE_LINEART; /*res, minimum for this mode*/ s->u_res = s->s_res_min[s->u_mode]; /* page width US-Letter */ s->u_page_width = 8.5 * 1200; if(s->u_page_width > s->s_width_max){ s->u_page_width = s->s_width_max; } /* page height US-Letter */ s->u_page_height = 11 * 1200; if(s->u_page_height > s->s_length_max){ s->u_page_height = s->s_length_max; } /* bottom-right x */ s->u_br_x = s->u_page_width; /* bottom-right y */ s->u_br_y = s->u_page_height; DBG (10, "init_user: finish\n"); return SANE_STATUS_GOOD; } /* * This function presets the "option" array to blank */ static SANE_Status init_options (struct scanner *s) { int i; DBG (10, "init_options: start\n"); memset (s->opt, 0, sizeof (s->opt)); for (i = 0; i < NUM_OPTIONS; ++i) { s->opt[i].name = "filler"; s->opt[i].size = sizeof (SANE_Word); s->opt[i].cap = SANE_CAP_INACTIVE; } /* go ahead and setup the first opt, because * frontend may call control_option on it * before calling get_option_descriptor */ s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; DBG (10, "init_options: finish\n"); return SANE_STATUS_GOOD; } /* * From the SANE spec: * This function is used to establish a connection to a particular * device. The name of the device to be opened is passed in argument * name. If the call completes successfully, a handle for the device * is returned in *h. As a special case, specifying a zero-length * string as the device requests opening the first available device * (if there is such a device). */ SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle) { struct scanner *dev = NULL; struct scanner *s = NULL; SANE_Status ret; unsigned char cmd[SEND_len]; size_t cmdLen = SEND_len; unsigned char out[SR_len_time]; /*longest used in this function*/ int try=0; time_t gmt_tt; struct tm * gmt_tm_p; struct tm * local_tm_p; DBG (10, "sane_open: start\n"); if(scanner_devList){ DBG (15, "sane_open: searching currently attached scanners\n"); } else{ DBG (15, "sane_open: no scanners currently attached, attaching\n"); ret = sane_get_devices(NULL,0); if(ret != SANE_STATUS_GOOD){ return ret; } } if(name[0] == 0){ DBG (15, "sane_open: no device requested, using default\n"); s = scanner_devList; } else{ DBG (15, "sane_open: device %s requested\n", name); for (dev = scanner_devList; dev; dev = dev->next) { if (strcmp (dev->sane.name, name) == 0) { s = dev; break; } } } if (!s) { DBG (5, "sane_open: no device found\n"); return SANE_STATUS_INVAL; } DBG (15, "sane_open: device %s found\n", s->sane.name); *handle = s; /* connect the fd so we can talk to scanner */ ret = connect_fd(s); if(ret != SANE_STATUS_GOOD){ return ret; } /*send the end batch (GX) command*/ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,SEND_code); set_SR_datatype_code(cmd,SR_datatype_random); set_SR_datatype_qual(cmd,SR_qual_end); set_SR_xfer_length(cmd,SR_len_end); /*start the following loop*/ ret = SANE_STATUS_DEVICE_BUSY; s->rs_info = 0; /*loop until scanner is ready*/ while(ret == SANE_STATUS_DEVICE_BUSY){ DBG (15, "sane_open: GX, try %d, sleep %lu\n", try, (unsigned long)s->rs_info); try++; sleep(s->rs_info); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, NULL, NULL ); if(try > 5){ break; } } if(ret){ DBG (5, "sane_open: GX error %d\n",ret); return ret; } /*send the clear buffer (CB) command*/ DBG (15, "sane_open: CB\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,SEND_code); set_SR_datatype_code(cmd,SR_datatype_random); set_SR_datatype_qual(cmd,SR_qual_clear); set_SR_xfer_length(cmd,SR_len_clear); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, NULL, NULL ); if(ret){ DBG (5, "sane_open: CB error %d\n",ret); return ret; } /*send the GT command*/ DBG (15, "sane_open: GT\n"); gmt_tt = time(NULL); gmt_tm_p = gmtime(&gmt_tt); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,SEND_code); set_SR_datatype_code(cmd,SR_datatype_random); set_SR_datatype_qual(cmd,SR_qual_gmt); set_SR_xfer_length(cmd,SR_len_time); memset(out,0,SR_len_time); set_SR_payload_len(out,SR_len_time); set_SR_time_hour(out,gmt_tm_p->tm_hour); set_SR_time_min(out,gmt_tm_p->tm_min); set_SR_time_mon(out,gmt_tm_p->tm_mon); set_SR_time_day(out,gmt_tm_p->tm_mday); set_SR_time_year(out,gmt_tm_p->tm_year+1900); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, SR_len_time, NULL, NULL ); if(ret){ DBG (5, "sane_open: GT error %d\n",ret); return ret; } /*FIXME: read the LC command? */ /*send the LC command*/ DBG (15, "sane_open: LC\n"); gmt_tt = time(NULL); local_tm_p = localtime(&gmt_tt); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,SEND_code); set_SR_datatype_code(cmd,SR_datatype_random); set_SR_datatype_qual(cmd,SR_qual_clock); set_SR_xfer_length(cmd,SR_len_time); memset(out,0,SR_len_time); set_SR_payload_len(out,SR_len_time); set_SR_time_hour(out,local_tm_p->tm_hour); set_SR_time_min(out,local_tm_p->tm_min); set_SR_time_mon(out,local_tm_p->tm_mon); set_SR_time_day(out,local_tm_p->tm_mday); set_SR_time_year(out,local_tm_p->tm_year+1900); ret = do_cmd ( s, 1, 0, cmd, cmdLen, out, SR_len_time, NULL, NULL ); if(ret){ DBG (5, "sane_open: LC error %d\n",ret); return ret; } DBG (10, "sane_open: finish\n"); return SANE_STATUS_GOOD; } /* * @@ Section 3 - SANE Options functions */ /* * Returns the options we know. * * From the SANE spec: * This function is used to access option descriptors. The function * returns the option descriptor for option number n of the device * represented by handle h. Option number 0 is guaranteed to be a * valid option. Its value is an integer that specifies the number of * options that are available for device handle h (the count includes * option 0). If n is not a valid option index, the function returns * NULL. The returned option descriptor is guaranteed to remain valid * (and at the returned address) until the device is closed. */ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct scanner *s = handle; int i; SANE_Option_Descriptor *opt = &s->opt[option]; DBG (20, "sane_get_option_descriptor: %d\n", option); if ((unsigned) option >= NUM_OPTIONS) return NULL; /* "Mode" group -------------------------------------------------------- */ if(option==OPT_MODE_GROUP){ opt->title = "Scan Mode"; opt->desc = ""; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* source */ if(option==OPT_SOURCE){ i=0; s->o_source_list[i++]=STRING_ADFFRONT; s->o_source_list[i++]=STRING_ADFBACK; s->o_source_list[i++]=STRING_ADFDUPLEX; s->o_source_list[i]=NULL; opt->name = SANE_NAME_SCAN_SOURCE; opt->title = SANE_TITLE_SCAN_SOURCE; opt->desc = SANE_DESC_SCAN_SOURCE; opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->o_source_list; opt->size = maxStringSize (opt->constraint.string_list); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* scan mode */ if(option==OPT_MODE){ i=0; if(s->s_mode[MODE_LINEART]){ s->o_mode_list[i++]=STRING_LINEART; } if(s->s_mode[MODE_HALFTONE]){ s->o_mode_list[i++]=STRING_HALFTONE; } if(s->s_mode[MODE_GRAYSCALE]){ s->o_mode_list[i++]=STRING_GRAYSCALE; } if(s->s_mode[MODE_COLOR]){ s->o_mode_list[i++]=STRING_COLOR; } s->o_mode_list[i]=NULL; opt->name = SANE_NAME_SCAN_MODE; opt->title = SANE_TITLE_SCAN_MODE; opt->desc = SANE_DESC_SCAN_MODE; opt->type = SANE_TYPE_STRING; opt->constraint_type = SANE_CONSTRAINT_STRING_LIST; opt->constraint.string_list = s->o_mode_list; opt->size = maxStringSize (opt->constraint.string_list); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* resolution */ /* build a list of possible choices for current mode */ if(option==OPT_RES){ int reslist[]={100,150,200,240,300,400}; int j; i=0; for(j=0;j<6;j++){ if(reslist[j] >= s->s_res_min[s->u_mode] && reslist[j] <= s->s_res_max[s->u_mode]){ s->o_res_list[s->u_mode][++i] = reslist[j]; } } s->o_res_list[s->u_mode][0] = i; opt->name = SANE_NAME_SCAN_RESOLUTION; opt->title = SANE_TITLE_SCAN_RESOLUTION; opt->desc = SANE_DESC_SCAN_RESOLUTION; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_DPI; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opt->constraint_type = SANE_CONSTRAINT_WORD_LIST; opt->constraint.word_list = s->o_res_list[s->u_mode]; } /* "Geometry" group ---------------------------------------------------- */ if(option==OPT_GEOMETRY_GROUP){ opt->title = "Geometry"; opt->desc = ""; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* top-left x */ if(option==OPT_TL_X){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->o_tl_x_range.min = SCANNER_UNIT_TO_FIXED_MM(s->s_width_min); s->o_tl_x_range.max = SCANNER_UNIT_TO_FIXED_MM(s->s_width_max); s->o_tl_x_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_TL_X; opt->title = SANE_TITLE_SCAN_TL_X; opt->desc = SANE_DESC_SCAN_TL_X; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->o_tl_x_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* top-left y */ if(option==OPT_TL_Y){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->o_tl_y_range.min = SCANNER_UNIT_TO_FIXED_MM(s->s_length_min); s->o_tl_y_range.max = SCANNER_UNIT_TO_FIXED_MM(s->s_length_max); s->o_tl_y_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_TL_Y; opt->title = SANE_TITLE_SCAN_TL_Y; opt->desc = SANE_DESC_SCAN_TL_Y; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->o_tl_y_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* bottom-right x */ if(option==OPT_BR_X){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->o_br_x_range.min = SCANNER_UNIT_TO_FIXED_MM(s->s_width_min); s->o_br_x_range.max = SCANNER_UNIT_TO_FIXED_MM(s->s_width_max); s->o_br_x_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_BR_X; opt->title = SANE_TITLE_SCAN_BR_X; opt->desc = SANE_DESC_SCAN_BR_X; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->o_br_x_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* bottom-right y */ if(option==OPT_BR_Y){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->o_br_y_range.min = SCANNER_UNIT_TO_FIXED_MM(s->s_length_min); s->o_br_y_range.max = SCANNER_UNIT_TO_FIXED_MM(s->s_length_max); s->o_br_y_range.quant = MM_PER_UNIT_FIX; opt->name = SANE_NAME_SCAN_BR_Y; opt->title = SANE_TITLE_SCAN_BR_Y; opt->desc = SANE_DESC_SCAN_BR_Y; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &(s->o_br_y_range); opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* page width */ if(option==OPT_PAGE_WIDTH){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->o_page_x_range.min = SCANNER_UNIT_TO_FIXED_MM(s->s_width_min); s->o_page_x_range.max = SCANNER_UNIT_TO_FIXED_MM(s->s_width_max); s->o_page_x_range.quant = MM_PER_UNIT_FIX; opt->name = "pagewidth"; opt->title = "ADF paper width"; opt->desc = "Must be set properly to align scanning window"; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->o_page_x_range; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* page height */ if(option==OPT_PAGE_HEIGHT){ /* values stored in 1200 dpi units */ /* must be converted to MM for sane */ s->o_page_y_range.min = SCANNER_UNIT_TO_FIXED_MM(s->s_length_min); s->o_page_y_range.max = SCANNER_UNIT_TO_FIXED_MM(s->s_length_max); s->o_page_y_range.quant = MM_PER_UNIT_FIX; opt->name = "pageheight"; opt->title = "ADF paper length"; opt->desc = "Must be set properly to eject pages"; opt->type = SANE_TYPE_FIXED; opt->unit = SANE_UNIT_MM; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->o_page_y_range; opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } /* "Enhancement" group ------------------------------------------------- */ if(option==OPT_ENHANCEMENT_GROUP){ opt->title = "Enhancement"; opt->desc = ""; opt->type = SANE_TYPE_GROUP; opt->constraint_type = SANE_CONSTRAINT_NONE; } /* brightness */ if(option==OPT_BRIGHTNESS){ opt->name = SANE_NAME_BRIGHTNESS; opt->title = SANE_TITLE_BRIGHTNESS; opt->desc = SANE_DESC_BRIGHTNESS; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->o_brightness_range; s->o_brightness_range.quant=1; s->o_brightness_range.min=-(s->s_brightness_steps/2); s->o_brightness_range.max=s->s_brightness_steps/2; if(opt->constraint.range->max > opt->constraint.range->min){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } else{ opt->cap = SANE_CAP_INACTIVE; } } /* contrast */ if(option==OPT_CONTRAST){ opt->name = SANE_NAME_CONTRAST; opt->title = SANE_TITLE_CONTRAST; opt->desc = SANE_DESC_CONTRAST; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->o_contrast_range; s->o_contrast_range.quant=1; s->o_contrast_range.min=-(s->s_contrast_steps/2); s->o_contrast_range.max=s->s_contrast_steps/2; if(opt->constraint.range->max > opt->constraint.range->min){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } else{ opt->cap = SANE_CAP_INACTIVE; } } /*threshold*/ if(option==OPT_THRESHOLD){ opt->name = SANE_NAME_THRESHOLD; opt->title = SANE_TITLE_THRESHOLD; opt->desc = SANE_DESC_THRESHOLD; opt->type = SANE_TYPE_INT; opt->unit = SANE_UNIT_NONE; opt->constraint_type = SANE_CONSTRAINT_RANGE; opt->constraint.range = &s->o_threshold_range; s->o_threshold_range.min=0; s->o_threshold_range.max=s->s_threshold_steps; s->o_threshold_range.quant=1; if(opt->constraint.range->max > opt->constraint.range->min){ opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } else{ opt->cap = SANE_CAP_INACTIVE; } } /*rif*/ if(option==OPT_RIF){ opt->name = "rif"; opt->title = "RIF"; opt->desc = "Reverse image format"; opt->type = SANE_TYPE_BOOL; opt->unit = SANE_UNIT_NONE; if (s->s_rif) opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; else opt->cap = SANE_CAP_INACTIVE; } return opt; } /** * Gets or sets an option value. * * From the SANE spec: * This function is used to set or inquire the current value of option * number n of the device represented by handle h. The manner in which * the option is controlled is specified by parameter action. The * possible values of this parameter are described in more detail * below. The value of the option is passed through argument val. It * is a pointer to the memory that holds the option value. The memory * area pointed to by v must be big enough to hold the entire option * value (determined by member size in the corresponding option * descriptor). * * The only exception to this rule is that when setting the value of a * string option, the string pointed to by argument v may be shorter * since the backend will stop reading the option value upon * encountering the first NUL terminator in the string. If argument i * is not NULL, the value of *i will be set to provide details on how * well the request has been met. */ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { struct scanner *s = (struct scanner *) handle; SANE_Int dummy = 0; /* Make sure that all those statements involving *info cannot break (better * than having to do "if (info) ..." everywhere!) */ if (info == 0) info = &dummy; if (option >= NUM_OPTIONS) { DBG (5, "sane_control_option: %d too big\n", option); return SANE_STATUS_INVAL; } if (!SANE_OPTION_IS_ACTIVE (s->opt[option].cap)) { DBG (5, "sane_control_option: %d inactive\n", option); return SANE_STATUS_INVAL; } /* * SANE_ACTION_GET_VALUE: We have to find out the current setting and * return it in a human-readable form (often, text). */ if (action == SANE_ACTION_GET_VALUE) { SANE_Word * val_p = (SANE_Word *) val; DBG (20, "sane_control_option: get value for '%s' (%d)\n", s->opt[option].name,option); switch (option) { case OPT_NUM_OPTS: *val_p = NUM_OPTIONS; return SANE_STATUS_GOOD; case OPT_SOURCE: if(s->u_source == SOURCE_ADF_FRONT){ strcpy (val, STRING_ADFFRONT); } else if(s->u_source == SOURCE_ADF_BACK){ strcpy (val, STRING_ADFBACK); } else if(s->u_source == SOURCE_ADF_DUPLEX){ strcpy (val, STRING_ADFDUPLEX); } else{ DBG(5,"missing option val for source\n"); } return SANE_STATUS_GOOD; case OPT_MODE: if(s->u_mode == MODE_LINEART){ strcpy (val, STRING_LINEART); } else if(s->u_mode == MODE_HALFTONE){ strcpy (val, STRING_HALFTONE); } else if(s->u_mode == MODE_GRAYSCALE){ strcpy (val, STRING_GRAYSCALE); } else if(s->u_mode == MODE_COLOR){ strcpy (val, STRING_COLOR); } return SANE_STATUS_GOOD; case OPT_RES: *val_p = s->u_res; return SANE_STATUS_GOOD; case OPT_TL_X: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->u_tl_x); return SANE_STATUS_GOOD; case OPT_TL_Y: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->u_tl_y); return SANE_STATUS_GOOD; case OPT_BR_X: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->u_br_x); return SANE_STATUS_GOOD; case OPT_BR_Y: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->u_br_y); return SANE_STATUS_GOOD; case OPT_PAGE_WIDTH: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->u_page_width); return SANE_STATUS_GOOD; case OPT_PAGE_HEIGHT: *val_p = SCANNER_UNIT_TO_FIXED_MM(s->u_page_height); return SANE_STATUS_GOOD; case OPT_BRIGHTNESS: *val_p = s->u_brightness; return SANE_STATUS_GOOD; case OPT_CONTRAST: *val_p = s->u_contrast; return SANE_STATUS_GOOD; case OPT_THRESHOLD: *val_p = s->u_threshold; return SANE_STATUS_GOOD; case OPT_RIF: *val_p = s->u_rif; return SANE_STATUS_GOOD; } } 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); if ( s->started ) { DBG (5, "sane_control_option: cant set, device busy\n"); return SANE_STATUS_DEVICE_BUSY; } if (!SANE_OPTION_IS_SETTABLE (s->opt[option].cap)) { DBG (5, "sane_control_option: not settable\n"); return SANE_STATUS_INVAL; } status = sanei_constrain_value (s->opt + option, val, info); if (status != SANE_STATUS_GOOD) { DBG (5, "sane_control_option: bad value\n"); 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 * exactly one of those values because that's what * sanei_constrain_value does. Hence no "else: invalid" branches * below. */ switch (option) { /* Mode Group */ case OPT_SOURCE: if (!strcmp (val, STRING_ADFFRONT)) { tmp = SOURCE_ADF_FRONT; } else if (!strcmp (val, STRING_ADFBACK)) { tmp = SOURCE_ADF_BACK; } else{ tmp = SOURCE_ADF_DUPLEX; } if (s->u_source != tmp) { s->u_source = tmp; *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_MODE: if (!strcmp (val, STRING_LINEART)) { tmp = MODE_LINEART; } else if (!strcmp (val, STRING_HALFTONE)) { tmp = MODE_HALFTONE; } else if (!strcmp (val, STRING_GRAYSCALE)) { tmp = MODE_GRAYSCALE; } else{ tmp = MODE_COLOR; } if (tmp != s->u_mode){ s->u_mode = tmp; *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_RES: if (s->u_res != val_c) { s->u_res = val_c; *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; /* Geometry Group */ case OPT_TL_X: if (s->u_tl_x != FIXED_MM_TO_SCANNER_UNIT(val_c)){ s->u_tl_x = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_TL_Y: if (s->u_tl_y != FIXED_MM_TO_SCANNER_UNIT(val_c)){ s->u_tl_y = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_BR_X: if (s->u_br_x != FIXED_MM_TO_SCANNER_UNIT(val_c)){ s->u_br_x = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_BR_Y: if (s->u_br_y != FIXED_MM_TO_SCANNER_UNIT(val_c)){ s->u_br_y = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_PAGE_WIDTH: if (s->u_page_width != FIXED_MM_TO_SCANNER_UNIT(val_c)){ s->u_page_width = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; case OPT_PAGE_HEIGHT: if (s->u_page_height != FIXED_MM_TO_SCANNER_UNIT(val_c)){ s->u_page_height = FIXED_MM_TO_SCANNER_UNIT(val_c); *info |= SANE_INFO_RELOAD_OPTIONS; } return SANE_STATUS_GOOD; /* Enhancement Group */ case OPT_BRIGHTNESS: if (s->u_brightness != val_c){ s->u_brightness = val_c; } return SANE_STATUS_GOOD; case OPT_CONTRAST: if (s->u_contrast != val_c){ s->u_contrast = val_c; } return SANE_STATUS_GOOD; case OPT_THRESHOLD: if (s->u_threshold != val_c){ s->u_threshold = val_c; } return SANE_STATUS_GOOD; case OPT_RIF: if (s->u_rif != val_c){ s->u_rif = val_c; } return SANE_STATUS_GOOD; } /* switch */ } /* else */ return SANE_STATUS_INVAL; } /* * @@ Section 4 - SANE scanning functions */ /* * Called by SANE to retrieve information about the type of data * that the current scan will return. * * From the SANE spec: * This function is used to obtain the current scan parameters. The * returned parameters are guaranteed to be accurate between the time * a scan has been started (sane_start() has been called) and the * completion of that request. Outside of that window, the returned * values are best-effort estimates of what the parameters will be * when sane_start() gets invoked. * * Calling this function before a scan has actually started allows, * for example, to get an estimate of how big the scanned image will * be. The parameters passed to this function are the handle h of the * device for which the parameters should be obtained and a pointer p * to a parameter structure. */ /* SANE_Parameters is defined 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_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { SANE_Status ret = SANE_STATUS_GOOD; struct scanner *s = (struct scanner *) handle; DBG (10, "sane_get_parameters: start\n"); /* started? get param data from image header */ if(s->started){ DBG (15, "sane_get_parameters: image settings:\n"); DBG (15, " tlx=%d, brx=%d, iw=%d, maxx=%d\n", s->i_tlx, (s->i_tlx+s->i_width), s->i_width, s->s_width_max/1200); DBG (15, " tly=%d, bry=%d, il=%d, maxy=%d\n", s->i_tly, (s->i_tly+s->i_length), s->i_length, s->s_length_max/1200); DBG (15, " res=%d, id=%d, bytes=%d\n", s->i_dpi, s->i_id, s->i_bytes); params->last_frame = 1; params->lines = s->i_length; params->pixels_per_line = s->i_width; /* bitonal */ if (s->i_bpp == 1) { params->format = SANE_FRAME_GRAY; params->depth = 1; params->bytes_per_line = params->pixels_per_line / 8; #ifdef SANE_FRAME_G42D /*G4 fax compression*/ if (s->i_compr) { params->format = SANE_FRAME_G42D; } #endif } /* gray */ else if (s->i_bpp == 8) { params->format = SANE_FRAME_GRAY; params->depth = 8; params->bytes_per_line = params->pixels_per_line; #ifdef SANE_FRAME_JPEG /*jpeg compression*/ if (s->i_compr) { params->format = SANE_FRAME_JPEG; } #endif } /* color */ else if (s->i_bpp == 24 || s->i_bpp == 96) { params->format = SANE_FRAME_RGB; params->depth = 8; params->bytes_per_line = params->pixels_per_line * 3; #ifdef SANE_FRAME_JPEG /*jpeg compression*/ if (s->i_compr) { params->format = SANE_FRAME_JPEG; } #endif } else{ DBG(5,"sane_get_parameters: unsupported depth %d\n", s->i_bpp); return SANE_STATUS_INVAL; } } /* not started? get param data from user input */ else{ DBG (15, "sane_get_parameters: user settings:\n"); DBG (15, " tlx=%d, brx=%d, pw=%d, maxx=%d\n", s->u_tl_x, s->u_br_x, s->u_page_width, s->s_width_max); DBG (15, " tly=%d, bry=%d, ph=%d, maxy=%d\n", s->u_tl_y, s->u_br_y, s->u_page_height, s->s_length_max); DBG (15, " res=%d, user_x=%d, user_y=%d\n", s->u_res, (s->u_res * (s->u_br_x - s->u_tl_x) / 1200), (s->u_res * (s->u_br_y - s->u_tl_y) / 1200)); if (s->u_mode == MODE_COLOR) { params->format = SANE_FRAME_RGB; params->depth = 8; } else if (s->u_mode == MODE_GRAYSCALE) { params->format = SANE_FRAME_GRAY; params->depth = 8; } else { params->format = SANE_FRAME_GRAY; params->depth = 1; } params->last_frame = 1; params->lines = s->u_res * (s->u_br_y - s->u_tl_y) / 1200; params->pixels_per_line = s->u_res * (s->u_br_x - s->u_tl_x) / 1200; /* bytes per line differs by mode */ if (s->u_mode == MODE_COLOR) { params->bytes_per_line = params->pixels_per_line * 3; } else if (s->u_mode == MODE_GRAYSCALE) { params->bytes_per_line = params->pixels_per_line; } else { params->bytes_per_line = params->pixels_per_line / 8; } } DBG (15, "sane_get_parameters: returning:\n"); DBG (15, " scan_x=%d, Bpl=%d, depth=%d\n", params->pixels_per_line, params->bytes_per_line, params->depth ); DBG (15, " scan_y=%d, frame=%d, last=%d\n", params->lines, params->format, params->last_frame ); DBG (10, "sane_get_parameters: finish\n"); return ret; } /* * Called by SANE when a page acquisition operation is to be started. * commands: scanner control (lampon), send (lut), send (dither), * set window, object pos, and scan * * this will be called before each image, including duplex backsides, * and at the start of adf batch. * hence, we spend alot of time playing with s->started, etc. */ SANE_Status sane_start (SANE_Handle handle) { struct scanner *s = handle; SANE_Status ret; DBG (10, "sane_start: start\n"); DBG (15, "started=%d, source=%d\n", s->started, s->u_source); /* batch already running */ if(s->started){ /* not finished with current image, error */ if (s->bytes_tx != s->i_bytes) { DBG(5,"sane_start: previous transfer not finished?"); return do_cancel(s); } } /* first page of batch */ else{ unsigned char cmd[SCAN_len]; unsigned char pay[SR_len_startstop]; /* set window command */ ret = set_window(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot set window\n"); do_cancel(s); return ret; } /* read/send JQ command */ /* read/send SC command */ ret = send_sc(s); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR: cannot send SC\n"); do_cancel(s); return ret; } /* read/send CT command */ DBG (15, "sane_start: send SCAN\n"); memset(cmd, 0, SCAN_len); set_SCSI_opcode(cmd, SCAN_code); ret = do_cmd ( s, 1, 0, cmd, SCAN_len, NULL, 0, NULL, NULL ); if (ret != SANE_STATUS_GOOD) { DBG (5, "sane_start: ERROR sending SCAN\n"); do_cancel(s); return ret; } /* send SS command */ DBG (15, "sane_start: send SS\n"); memset(cmd,0,SEND_len); set_SCSI_opcode(cmd,SEND_code); set_SR_datatype_code(cmd,SR_datatype_random); set_SR_datatype_qual(cmd,SR_qual_startstop); set_SR_xfer_length(cmd,SR_len_startstop); memset(pay,0,SR_len_startstop); set_SR_payload_len(pay,SR_len_startstop); set_SR_startstop_cmd(pay,1); ret = do_cmd ( s, 1, 0, cmd, SEND_len, pay, SR_len_startstop, NULL, NULL ); if(ret){ DBG (5, "sane_open: SS error %d\n",ret); return ret; } DBG (15, "sane_start: sleeping\n"); sleep(2); s->started=1; } ret = read_imageheader(s); if(ret){ DBG (5, "sane_open: error reading imageheader %d\n",ret); return ret; } /* set clean defaults */ s->bytes_rx = 0; s->bytes_tx = 0; /* make large buffer to hold the images */ DBG (15, "sane_start: setup buffer\n"); /* free current buffer if too small */ if (s->buffer && s->bytes_buf < s->i_bytes) { DBG (15, "sane_start: free buffer.\n"); free(s->buffer); s->buffer = NULL; s->bytes_buf = 0; } /* grab new buffer if dont have one */ if (!s->buffer) { DBG (15, "sane_start: calloc buffer.\n"); s->buffer = calloc (1,s->i_bytes); if (!s->buffer) { DBG (5, "sane_start: Error, no buffer\n"); do_cancel(s); return SANE_STATUS_NO_MEM; } } DBG (15, "started=%d, source=%d\n", s->started, s->u_source); DBG (10, "sane_start: finish\n"); return SANE_STATUS_GOOD; } /* * This routine issues a SCSI SET WINDOW command to the scanner, using the * values currently in the scanner data structure. * the scanner has 4 separate windows, and all must be set similarly, * even if you dont intend to aquire images from all of them. */ static SANE_Status set_window (struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[SET_WINDOW_len]; size_t cmdLen = SET_WINDOW_len; /* the data phase has a header, followed by a window desc block * the header specifies the number of bytes in 1 window desc block */ unsigned char pay[WINDOW_HEADER_len + WINDOW_DESCRIPTOR_len]; size_t payLen = WINDOW_HEADER_len + WINDOW_DESCRIPTOR_len; unsigned char * desc = pay + WINDOW_HEADER_len; int width = (s->u_br_x - s->u_tl_x) * s->u_res/1200; int length = (s->u_br_y - s->u_tl_y) * s->u_res/1200; DBG (10, "set_window: start\n"); /* binary window settings */ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,SET_WINDOW_code); set_SW_xferlen(cmd,payLen); memset(pay,0,payLen); set_WH_desc_len(pay,WINDOW_DESCRIPTOR_len); set_WD_wid(desc,WD_wid_front_binary); /* common settings */ set_WD_Xres (desc, s->u_res); set_WD_Yres (desc, s->u_res); set_WD_ULX (desc, s->u_tl_x); set_WD_ULY (desc, s->u_tl_y); /* width % 32 == 0 && length % 1 == 0 */ width -= width % 32; width = width*1200/s->u_res; length = length*1200/s->u_res; set_WD_width (desc, width); set_WD_length (desc, length); /* brightness not supported? */ set_WD_brightness (desc, 0); set_WD_threshold (desc, s->u_threshold); set_WD_contrast (desc, 0); if(s->s_contrast_steps){ /*convert our common -127 to +127 range into HW's range *FIXME: this code assumes hardware range of 1-255 */ set_WD_contrast (desc, s->u_contrast+128); } if(s->u_mode == MODE_HALFTONE){ set_WD_composition (desc, WD_compo_HALFTONE); set_WD_bitsperpixel (desc, 1); } else{ set_WD_composition (desc, WD_compo_LINEART); set_WD_bitsperpixel (desc, 1); } /* FIXME ht pattern */ set_WD_rif (desc, s->u_rif); set_WD_bitorder (desc, 1); /* compression options */ if(s->u_compr) set_WD_compress_type (desc, WD_compr_FAXG4); /*FIXME: noise filter */ set_WD_allow_zero(desc,1); set_WD_cropping (desc, WD_crop_RELATIVE); /*FIXME: more settings here*/ hexdump(15, "front binary window:", desc, WINDOW_DESCRIPTOR_len); DBG (15, "set_window: set window binary back\n"); ret = do_cmd ( s, 1, 0, cmd, cmdLen, pay, payLen, NULL, NULL ); if(ret){ DBG (5, "set_window: error setting binary front window %d\n",ret); return ret; } /*send the window for backside too*/ set_WD_wid(desc,WD_wid_back_binary); DBG (15, "set_window: set window binary back\n"); ret = do_cmd ( s, 1, 0, cmd, cmdLen, pay, payLen, NULL, NULL ); if(ret){ DBG (5, "set_window: error setting binary back window %d\n",ret); return ret; } #if 0 memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,GET_WINDOW_code); set_GW_single(cmd,1); set_GW_wid(cmd,WD_wid_front_color); set_GW_xferlen(cmd,payLen); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, pay, &payLen ); if(ret){ DBG (5, "set_window: error getting window %d\n",ret); return ret; } hexdump(15,"foo",pay,payLen); #endif /* color window settings */ memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,SET_WINDOW_code); set_SW_xferlen(cmd,payLen); memset(pay,0,payLen); set_WH_desc_len(pay,WINDOW_DESCRIPTOR_len); set_WD_wid(desc,WD_wid_front_color); /* common settings */ set_WD_Xres (desc, s->u_res); set_WD_Yres (desc, s->u_res); set_WD_ULX (desc, s->u_tl_x); set_WD_ULY (desc, s->u_tl_y); set_WD_width (desc, width); set_WD_length (desc, length); /*gray mode*/ if(s->u_mode == MODE_GRAYSCALE){ /* gamma width % 8 == 0 && length % 8 == 0 */ set_WD_composition (desc, WD_compo_MULTILEVEL); set_WD_bitsperpixel (desc, 8); } /*color mode or color window in binary mode*/ else{ /* width % 16 == 0 && length % 8 == 0 */ set_WD_composition (desc, WD_compo_MULTILEVEL); set_WD_bitsperpixel (desc, 24); /* compression options */ if(s->u_compr) set_WD_compress_type (desc, WD_compr_JPEG); } set_WD_bitorder (desc, 1); /*FIXME: noise filter */ set_WD_allow_zero(desc,1); set_WD_cropping (desc, WD_crop_RELATIVE); /*FIXME: more settings here*/ DBG (15, "set_window: set window color front\n"); ret = do_cmd ( s, 1, 0, cmd, cmdLen, pay, payLen, NULL, NULL ); if(ret){ DBG (5, "set_window: error setting color front window %d\n",ret); return ret; } /*send the window for backside too*/ set_WD_wid(desc,WD_wid_back_color); DBG (15, "set_window: set window color back\n"); ret = do_cmd ( s, 1, 0, cmd, cmdLen, pay, payLen, NULL, NULL ); if(ret){ DBG (5, "set_window: error setting color back window %d\n",ret); return ret; } DBG (10, "set_window: finish\n"); return ret; } /* * This routine reads the SC (scanner config) data from the scanner * modifies a few params based on user data, and sends it back */ static SANE_Status send_sc(struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[READ_len]; size_t cmdLen = READ_len; unsigned char pay[SR_len_config]; size_t payLen = SR_len_config; /* send SC command */ DBG (10, "send_sc: start\n"); DBG (15, "send_sc: reading config\n"); memset(cmd,0,READ_len); set_SCSI_opcode(cmd,READ_code); set_SR_datatype_code(cmd,SR_datatype_random); set_SR_datatype_qual(cmd,SR_qual_config); set_SR_xfer_length(cmd,SR_len_config); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, pay, &payLen ); if(ret || !payLen){ DBG (5, "send_sc: error reading: %d\n",ret); return ret; } memset(cmd,0,SEND_len); set_SCSI_opcode(cmd,SEND_code); set_SR_datatype_code(cmd,SR_datatype_random); set_SR_datatype_qual(cmd,SR_qual_config); set_SR_xfer_length(cmd,payLen); if(s->u_source == SOURCE_ADF_FRONT){ if(s->u_mode == MODE_COLOR || s->u_mode == MODE_GRAYSCALE){ set_SR_sc_io1(pay,SR_sc_io_front_color); } else{ set_SR_sc_io1(pay,SR_sc_io_front_binary); } set_SR_sc_io2(pay,SR_sc_io_none); set_SR_sc_io3(pay,SR_sc_io_none); set_SR_sc_io4(pay,SR_sc_io_none); } else if(s->u_source == SOURCE_ADF_BACK){ if(s->u_mode == MODE_COLOR || s->u_mode == MODE_GRAYSCALE){ set_SR_sc_io1(pay,SR_sc_io_rear_color); } else{ set_SR_sc_io1(pay,SR_sc_io_rear_binary); } set_SR_sc_io2(pay,SR_sc_io_none); set_SR_sc_io3(pay,SR_sc_io_none); set_SR_sc_io4(pay,SR_sc_io_none); } else{ if(s->u_mode == MODE_COLOR || s->u_mode == MODE_GRAYSCALE){ set_SR_sc_io1(pay,SR_sc_io_front_color); set_SR_sc_io2(pay,SR_sc_io_rear_color); } else{ set_SR_sc_io1(pay,SR_sc_io_front_binary); set_SR_sc_io2(pay,SR_sc_io_rear_binary); } set_SR_sc_io3(pay,SR_sc_io_none); set_SR_sc_io4(pay,SR_sc_io_none); } /*FIXME: there are hundreds of other settings in this payload*/ ret = do_cmd ( s, 1, 0, cmd, cmdLen, pay, payLen, NULL, NULL ); DBG (10, "send_sc: finish %d\n",ret); return ret; } /* * This routine reads the image header from the scanner, and updates * values currently in the scanner data structure. */ static SANE_Status read_imageheader (struct scanner *s) { SANE_Status ret = SANE_STATUS_GOOD; unsigned char cmd[READ_len]; unsigned char pay[SR_len_imageheader]; size_t payLen = SR_len_imageheader; int pass = 0; /* read img header */ DBG (10, "read_imageheader: start\n"); memset(cmd,0,READ_len); set_SCSI_opcode(cmd,READ_code); set_SR_datatype_code(cmd,SR_datatype_imageheader); set_SR_xfer_length(cmd,SR_len_imageheader); while (pass++ < 1000){ DBG (15, "read_imageheader: pass %d\n", pass); payLen = SR_len_imageheader; ret = do_cmd ( s, 1, 0, cmd, READ_len, NULL, 0, pay, &payLen ); DBG (15, "read_imageheader: pass status %d\n", ret); if(ret != SANE_STATUS_DEVICE_BUSY){ break; } usleep(50000); } if (ret == SANE_STATUS_GOOD){ DBG (15, "image header:\n"); DBG (15, " bytes: %d\n",get_SR_ih_image_length(pay)); s->i_bytes = get_SR_ih_image_length(pay); DBG (15, " id: %d\n",get_SR_ih_image_id(pay)); s->i_id = get_SR_ih_image_id(pay); DBG (15, " dpi: %d\n",get_SR_ih_resolution(pay)); s->i_dpi = get_SR_ih_resolution(pay); DBG (15, " tlx: %d\n",get_SR_ih_ulx(pay)); s->i_tlx = get_SR_ih_ulx(pay); DBG (15, " tly: %d\n",get_SR_ih_uly(pay)); s->i_tly = get_SR_ih_uly(pay); DBG (15, " width: %d\n",get_SR_ih_width(pay)); s->i_width = get_SR_ih_width(pay); DBG (15, " length: %d\n",get_SR_ih_length(pay)); s->i_length = get_SR_ih_length(pay); DBG (15, " bpp: %d\n",get_SR_ih_bpp(pay)); s->i_bpp = get_SR_ih_bpp(pay); DBG (15, " comp: %d\n",get_SR_ih_comp_type(pay)); s->i_compr = get_SR_ih_comp_type(pay); /*FIXME: there are alot more of these?*/ } DBG (10, "read_imageheader: finish %d\n", ret); return ret; } /* * Called by SANE to read data. * * From the SANE spec: * This function is used to read image data from the device * represented by handle h. Argument buf is a pointer to a memory * area that is at least maxlen bytes long. The number of bytes * returned is stored in *len. A backend must set this to zero when * the call fails (i.e., when a status other than SANE_STATUS_GOOD is * returned). * * When the call succeeds, the number of bytes returned can be * anywhere in the range from 0 to maxlen bytes. */ SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { struct scanner *s = (struct scanner *) handle; SANE_Status ret=0; DBG (10, "sane_read: start\n"); *len=0; /* maybe cancelled? */ if(!s->started){ DBG (5, "sane_read: not started, call sane_start\n"); return SANE_STATUS_CANCELLED; } /* sane_start required between images */ if(s->bytes_tx == s->i_bytes){ DBG (15, "sane_read: returning eof\n"); return SANE_STATUS_EOF; } if(s->i_bytes > s->bytes_rx ){ ret = read_from_scanner(s); if(ret){ DBG(5,"sane_read: returning %d\n",ret); return ret; } } /* copy a block from buffer to frontend */ ret = read_from_buffer(s,buf,max_len,len); DBG (10, "sane_read: finish\n"); return ret; } static SANE_Status read_from_scanner(struct scanner *s) { SANE_Status ret=SANE_STATUS_GOOD; int bytes = s->buffer_size; int remain = s->i_bytes - s->bytes_rx; unsigned char * buf; size_t inLen = 0; unsigned char cmd[READ_len]; int cmdLen=READ_len; DBG (10, "read_from_scanner: start\n"); memset(cmd, 0, cmdLen); set_SCSI_opcode(cmd, READ_code); /* figure out the max amount to transfer */ if(bytes > remain){ bytes = remain; } DBG(15, "read_from_scanner: to:%d rx:%d re:%d bu:%d pa:%d\n", s->i_bytes, s->bytes_rx, remain, s->buffer_size, bytes); if(ret){ return ret; } inLen = bytes; buf = malloc(bytes); if(!buf){ DBG(5, "read_from_scanner: not enough mem for buffer: %d\n",bytes); return SANE_STATUS_NO_MEM; } set_SR_datatype_code (cmd, SR_datatype_imagedata); set_SR_xfer_length (cmd, bytes); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, buf, &inLen ); if (ret == SANE_STATUS_GOOD) { DBG(15, "read_from_scanner: got GOOD, returning GOOD\n"); } else if (ret == SANE_STATUS_EOF) { DBG(15, "read_from_scanner: got EOF, finishing\n"); } else if (ret == SANE_STATUS_DEVICE_BUSY) { DBG(5, "read_from_scanner: got BUSY, returning GOOD\n"); inLen = 0; ret = SANE_STATUS_GOOD; } else { DBG(5, "read_from_scanner: error reading data block status = %d\n",ret); inLen = 0; } if(inLen){ copy_buffer (s, buf, inLen); } free(buf); if(ret == SANE_STATUS_EOF){ DBG (5, "read_from_scanner: unexpected EOF, shortening image\n"); s->i_bytes = s->bytes_rx; ret = SANE_STATUS_GOOD; } DBG (10, "read_from_scanner: finish\n"); return ret; } static SANE_Status copy_buffer(struct scanner *s, unsigned char * buf, int len) { SANE_Status ret=SANE_STATUS_GOOD; DBG (10, "copy_buffer: start\n"); memcpy(s->buffer+s->bytes_rx,buf,len); s->bytes_rx += len; DBG (10, "copy_buffer: finish\n"); return ret; } static SANE_Status read_from_buffer(struct scanner *s, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { SANE_Status ret=SANE_STATUS_GOOD; int bytes = max_len; int remain = s->bytes_rx - s->bytes_tx; DBG (10, "read_from_buffer: start\n"); /* figure out the max amount to transfer */ if(bytes > remain){ bytes = remain; } *len = bytes; DBG(15, "read_from_buffer: to:%d tx:%d re:%d bu:%d pa:%d\n", s->i_bytes, s->bytes_tx, remain, max_len, bytes); /*FIXME this needs to timeout eventually */ if(!bytes){ DBG(5,"read_from_buffer: nothing to do\n"); return SANE_STATUS_GOOD; } memcpy(buf,s->buffer+s->bytes_tx,bytes); s->bytes_tx += *len; DBG (10, "read_from_buffer: finish\n"); return ret; } /* * @@ Section 4 - SANE cleanup functions */ /* * Cancels a scan. * * It has been said on the mailing list that sane_cancel is a bit of a * misnomer because it is routinely called to signal the end of a * batch - quoting David Mosberger-Tang: * * > In other words, the idea is to have sane_start() be called, and * > collect as many images as the frontend wants (which could in turn * > consist of multiple frames each as indicated by frame-type) and * > when the frontend is done, it should call sane_cancel(). * > Sometimes it's better to think of sane_cancel() as "sane_stop()" * > but that name would have had some misleading connotations as * > well, that's why we stuck with "cancel". * * The current consensus regarding duplex and ADF scans seems to be * the following call sequence: sane_start; sane_read (repeat until * EOF); sane_start; sane_read... and then call sane_cancel if the * batch is at an end. I.e. do not call sane_cancel during the run but * as soon as you get a SANE_STATUS_NO_DOCS. * * From the SANE spec: * This function is used to immediately or as quickly as possible * cancel the currently pending operation of the device represented by * handle h. This function can be called at any time (as long as * handle h is a valid handle) but usually affects long-running * operations only (such as image is acquisition). It is safe to call * this function asynchronously (e.g., from within a signal handler). * It is important to note that completion of this operaton does not * imply that the currently pending operation has been cancelled. It * only guarantees that cancellation has been initiated. Cancellation * completes only when the cancelled call returns (typically with a * status value of SANE_STATUS_CANCELLED). Since the SANE API does * not require any other operations to be re-entrant, this implies * that a frontend must not call any other operation until the * cancelled operation has returned. */ void sane_cancel (SANE_Handle handle) { DBG (10, "sane_cancel: start\n"); do_cancel ((struct scanner *) handle); DBG (10, "sane_cancel: finish\n"); } /* * Performs cleanup. * FIXME: do better cleanup if scanning is ongoing... */ static SANE_Status do_cancel (struct scanner *s) { DBG (10, "do_cancel: start\n"); s->started = 0; DBG (10, "do_cancel: finish\n"); return SANE_STATUS_CANCELLED; } /* * Ends use of the scanner. * * From the SANE spec: * This function terminates the association between the device handle * passed in argument h and the device it represents. If the device is * presently active, a call to sane_cancel() is performed first. After * this function returns, handle h must not be used anymore. */ void sane_close (SANE_Handle handle) { DBG (10, "sane_close: start\n"); do_cancel((struct scanner *) handle); disconnect_fd((struct scanner *) handle); DBG (10, "sane_close: finish\n"); } static SANE_Status disconnect_fd (struct scanner *s) { DBG (10, "disconnect_fd: start\n"); if(s->fd > -1){ DBG (15, "disconnecting scsi device\n"); sanei_scsi_close (s->fd); s->fd = -1; } DBG (10, "disconnect_fd: finish\n"); return SANE_STATUS_GOOD; } /* * Terminates the backend. * * From the SANE spec: * This function must be called to terminate use of a backend. The * function will first close all device handles that still might be * open (it is recommended to close device handles explicitly through * a call to sane_close(), but backends are required to release all * resources upon a call to this function). After this function * returns, no function other than sane_init() may be called * (regardless of the status value returned by sane_exit(). Neglecting * to call this function may result in some resources not being * released properly. */ void sane_exit (void) { struct scanner *dev, *next; DBG (10, "sane_exit: start\n"); for (dev = scanner_devList; dev; dev = next) { disconnect_fd(dev); next = dev->next; free (dev->device_name); free (dev); } if (sane_devArray) free (sane_devArray); scanner_devList = NULL; sane_devArray = NULL; DBG (10, "sane_exit: finish\n"); } /* * @@ Section 5 - misc helper functions */ /* * Called by the SANE SCSI core on device errors * parses the request sense return data buffer, * decides the best SANE_Status for the problem * and produces debug msgs */ static SANE_Status sense_handler (int fd, unsigned char * sensed_data, void *arg) { struct scanner *s = arg; unsigned int ili = get_RS_ILI (sensed_data); unsigned int sk = get_RS_sense_key (sensed_data); unsigned int asc = get_RS_ASC (sensed_data); unsigned int ascq = get_RS_ASCQ (sensed_data); DBG (5, "sense_handler: start\n"); /* kill compiler warning */ fd = fd; /* save for later */ s->rs_info = get_RS_information (sensed_data); DBG (5, "SK=%#02x, ASC=%#02x, ASCQ=%#02x, ILI=%d, info=%#08lx\n", sk, asc, ascq, ili, (unsigned long)s->rs_info); switch (sk) { /* no sense */ case 0x0: if (0x00 != asc) { DBG (5, "No sense: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if (0x00 != ascq) { DBG (5, "No sense: unknown ascq\n"); return SANE_STATUS_IO_ERROR; } if (ili) { DBG (5, "No sense: ILI set\n"); return SANE_STATUS_EOF; } DBG (5, "No sense: ready\n"); return SANE_STATUS_GOOD; /* not ready */ case 0x2: if (0x80 != asc) { DBG (5, "Not ready: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if (0x00 != ascq) { DBG (5, "Not ready: unknown ascq\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "Not ready: end of job\n"); return SANE_STATUS_NO_DOCS; break; /* hardware error */ case 0x4: if (0x3b != asc) { DBG (5, "Hardware error: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if (0x05 == ascq) { DBG (5, "Hardware error: paper jam\n"); return SANE_STATUS_JAMMED; } if (0x80 == ascq) { DBG (5, "Hardware error: multi-feed\n"); return SANE_STATUS_JAMMED; } DBG (5, "Hardware error: unknown ascq\n"); return SANE_STATUS_IO_ERROR; break; /* illegal request */ case 0x5: if (asc != 0x20 && asc != 0x24 && asc != 0x25 && asc != 0x26 && asc != 0x83 && asc != 0x8f) { DBG (5, "Illegal request: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if (0x20 == asc && 0x00 == ascq) { DBG (5, "Illegal request: invalid opcode\n"); return SANE_STATUS_INVAL; } if (0x24 == asc && 0x00 == ascq) { DBG (5, "Illegal request: invalid field in CDB\n"); return SANE_STATUS_INVAL; } if (0x25 == asc && 0x00 == ascq) { DBG (5, "Illegal request: invalid LUN\n"); return SANE_STATUS_INVAL; } if (0x26 == asc && 0x00 == ascq) { DBG (5, "Illegal request: invalid field in params\n"); return SANE_STATUS_INVAL; } if (0x83 == asc && 0x00 == ascq) { DBG (5, "Illegal request: command failed, check log\n"); return SANE_STATUS_INVAL; } if (0x83 == asc && 0x01 == ascq) { DBG (5, "Illegal request: command failed, invalid state\n"); return SANE_STATUS_INVAL; } if (0x83 == asc && 0x02 == ascq) { DBG (5, "Illegal request: command failed, critical error\n"); return SANE_STATUS_INVAL; } if (0x8f == asc && 0x00 == ascq) { DBG (5, "Illegal request: no image\n"); return SANE_STATUS_DEVICE_BUSY; } DBG (5, "Illegal request: unknown asc/ascq\n"); return SANE_STATUS_IO_ERROR; break; /* unit attention */ case 0x6: if (asc != 0x29 && asc != 0x80) { DBG (5, "Unit attention: unknown asc\n"); return SANE_STATUS_IO_ERROR; } if (0x29 == asc && 0x60 == ascq) { DBG (5, "Unit attention: device reset\n"); return SANE_STATUS_GOOD; } if (0x80 == asc && 0x00 == ascq) { DBG (5, "Unit attention: Energy Star warm up\n"); return SANE_STATUS_DEVICE_BUSY; } if (0x80 == asc && 0x01 == ascq) { DBG (5, "Unit attention: lamp warm up for scan\n"); return SANE_STATUS_DEVICE_BUSY; } if (0x80 == asc && 0x02 == ascq) { DBG (5, "Unit attention: lamp warm up for cal\n"); return SANE_STATUS_DEVICE_BUSY; } if (0x80 == asc && 0x04 == ascq) { DBG (5, "Unit attention: calibration failed\n"); return SANE_STATUS_INVAL; } DBG (5, "Unit attention: unknown asc/ascq\n"); return SANE_STATUS_IO_ERROR; break; /* ia overflow */ case 0x9: if (0x80 == asc && 0x00 == ascq) { DBG (5, "IA overflow: IA field overflow\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "IA overflow: unknown asc/ascq\n"); return SANE_STATUS_IO_ERROR; break; /* volume overflow */ case 0xd: if (0x80 == asc && 0x00 == ascq) { DBG (5, "Volume overflow: Image buffer full\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "Volume overflow: unknown asc/ascq\n"); return SANE_STATUS_IO_ERROR; break; default: DBG (5, "Unknown Sense Code\n"); return SANE_STATUS_IO_ERROR; } DBG (5, "sense_handler: should never happen!\n"); return SANE_STATUS_IO_ERROR; } /* SANE_Status do_rs(scanner * s) { SANE_Status ret; unsigned char cmd[REQUEST_SENSE_len]; size_t cmdLen = REQUEST_SENSE_len; DBG (10, "do_rs: start\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,REQUEST_SENSE_code); set_SR_datatype_code(cmd,SR_datatype_random); set_SR_datatype_qual(cmd,SR_qual_end); ret = do_cmd ( s, 1, 0, cmd, cmdLen, NULL, 0, NULL, NULL ); while(ret == SANE_STATUS_DEVICE_BUSY){ ret = run_rs(s); } DBG (10, "do_rs: finish\n"); return SANE_STATUS_GOOD; } */ SANE_Status do_cmd(struct scanner *s, int runRS, int shortTime, unsigned char * cmdBuff, size_t cmdLen, unsigned char * outBuff, size_t outLen, unsigned char * inBuff, size_t * inLen ) { SANE_Status ret = SANE_STATUS_GOOD; /*shut up compiler*/ runRS=runRS; shortTime=shortTime; DBG(10, "do_cmd: start\n"); DBG(25, "cmd: writing %d bytes\n", (int)cmdLen); hexdump(30, "cmd: >>", cmdBuff, cmdLen); if(outBuff && outLen){ DBG(25, "out: writing %d bytes\n", (int)outLen); hexdump(30, "out: >>", outBuff, outLen); } if (inBuff && inLen){ DBG(25, "in: reading %d bytes\n", (int)*inLen); } ret = sanei_scsi_cmd2(s->fd, cmdBuff, cmdLen, outBuff, outLen, inBuff, inLen); if(ret != SANE_STATUS_GOOD && ret != SANE_STATUS_EOF){ DBG(5,"do_cmd: return '%s'\n",sane_strstatus(ret)); return ret; } /* FIXME: should we look at s->rs_info here? */ if (inBuff && inLen){ hexdump(30, "in: <<", inBuff, *inLen); DBG(25, "in: read %d bytes\n", (int)*inLen); } DBG(10, "do_cmd: finish\n"); return ret; } #if 0 /* unused */ static SANE_Status wait_scanner(struct scanner *s) { int ret; unsigned char cmd[TEST_UNIT_READY_len]; size_t cmdLen = TEST_UNIT_READY_len; DBG (10, "wait_scanner: start\n"); memset(cmd,0,cmdLen); set_SCSI_opcode(cmd,TEST_UNIT_READY_code); ret = do_cmd ( s, 0, 1, cmd, cmdLen, NULL, 0, NULL, NULL ); if (ret != SANE_STATUS_GOOD) { DBG(5,"WARNING: Brain-dead scanner. Hitting with stick\n"); ret = do_cmd ( s, 0, 1, cmd, cmdLen, NULL, 0, NULL, NULL ); } if (ret != SANE_STATUS_GOOD) { DBG(5,"WARNING: Brain-dead scanner. Hitting with stick again\n"); ret = do_cmd ( s, 0, 1, cmd, cmdLen, NULL, 0, NULL, NULL ); } if (ret != SANE_STATUS_GOOD) { DBG (5, "wait_scanner: error '%s'\n", sane_strstatus (ret)); } DBG (10, "wait_scanner: finish\n"); return ret; } #endif /* 0 - unused */ /** * Convenience method to determine longest string size in a list. */ static size_t maxStringSize (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return max_size; } /** * Prints a hex dump of the given buffer onto the debug output stream. */ static void hexdump (int level, char *comment, unsigned char *p, int l) { int i; char line[128]; char *ptr; if(DBG_LEVEL < level) return; DBG (level, "%s\n", comment); ptr = line; for (i = 0; i < l; i++, p++) { if ((i % 16) == 0) { if (ptr != line) { *ptr = '\0'; DBG (level, "%s\n", line); ptr = line; } sprintf (ptr, "%3.3x:", i); ptr += 4; } sprintf (ptr, " %2.2x", *p); ptr += 3; } *ptr = '\0'; DBG (level, "%s\n", line); } /** * An advanced method we don't support but have to define. */ SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking) { DBG (10, "sane_set_io_mode\n"); DBG (15, "%d %p\n", non_blocking, h); return SANE_STATUS_UNSUPPORTED; } /** * An advanced method we don't support but have to define. */ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int *fdp) { DBG (10, "sane_get_select_fd\n"); DBG (15, "%p %d\n", h, *fdp); return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/rts88xx_lib.h0000666000000000000000000001564013615534521015145 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2007-2012 stef.dev@free.fr 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #ifndef RTS88XX_LIB_H #define RTS88XX_LIB_H #include "../include/sane/sane.h" #include "../include/sane/sanei_usb.h" #include #include /* TODO put his in a place where it can be reused */ #define DBG_error0 0 /* errors/warnings printed even with debuglevel 0 */ #define DBG_error 1 /* fatal errors */ #define DBG_init 2 /* initialization and scanning time messages */ #define DBG_warn 3 /* warnings and non-fatal errors */ #define DBG_info 4 /* informational messages */ #define DBG_proc 5 /* starting/finishing functions */ #define DBG_io 6 /* io functions */ #define DBG_io2 7 /* io functions that are called very often */ #define DBG_data 8 /* log data sent and received */ /* * defines for registers name */ #define CONTROL_REG 0xb3 #define CONTROLER_REG 0x1d /* geometry registers */ #define START_LINE 0x60 #define END_LINE 0x62 #define START_PIXEL 0x66 #define END_PIXEL 0x6c #define RTS88XX_MAX_XFER_SIZE 0xFFC0 #define LOBYTE(x) ((uint8_t)((x) & 0xFF)) #define HIBYTE(x) ((uint8_t)((x) >> 8)) /* this function init the rts88xx library */ void sanei_rts88xx_lib_init (void); SANE_Bool sanei_rts88xx_is_color (SANE_Byte * regs); void sanei_rts88xx_set_gray_scan (SANE_Byte * regs); void sanei_rts88xx_set_color_scan (SANE_Byte * regs); void sanei_rts88xx_set_offset (SANE_Byte * regs, SANE_Byte red, SANE_Byte green, SANE_Byte blue); void sanei_rts88xx_set_gain (SANE_Byte * regs, SANE_Byte red, SANE_Byte green, SANE_Byte blue); void sanei_rts88xx_set_scan_frequency (SANE_Byte * regs, int frequency); /* * set scan area */ void sanei_rts88xx_set_scan_area (SANE_Byte * reg, SANE_Int ystart, SANE_Int yend, SANE_Int xstart, SANE_Int xend); /* * read one register at given index */ SANE_Status sanei_rts88xx_read_reg (SANE_Int devnum, SANE_Int index, SANE_Byte * reg); /* * read scanned data from scanner up to the size given. The actual length read is returned. */ SANE_Status sanei_rts88xx_read_data (SANE_Int devnum, SANE_Word * length, unsigned char *dest); /* * write one register at given index */ SANE_Status sanei_rts88xx_write_reg (SANE_Int devnum, SANE_Int index, SANE_Byte * reg); /* * write length consecutive registers, starting at index * register 0xb3 is never wrote in bulk register write, so we split * write if it belongs to the register set sent */ SANE_Status sanei_rts88xx_write_regs (SANE_Int devnum, SANE_Int start, SANE_Byte * source, SANE_Int length); /* read several registers starting at the given index */ SANE_Status sanei_rts88xx_read_regs (SANE_Int devnum, SANE_Int start, SANE_Byte * dest, SANE_Int length); /* * get status by reading registers 0x10 and 0x11 */ SANE_Status sanei_rts88xx_get_status (SANE_Int devnum, SANE_Byte * regs); /* * set status by writing registers 0x10 and 0x11 */ SANE_Status sanei_rts88xx_set_status (SANE_Int devnum, SANE_Byte * regs, SANE_Byte reg10, SANE_Byte reg11); /* * get lamp status by reading registers 0x84 to 0x8d */ SANE_Status sanei_rts88xx_get_lamp_status (SANE_Int devnum, SANE_Byte * regs); /* reset lamp */ SANE_Status sanei_rts88xx_reset_lamp (SANE_Int devnum, SANE_Byte * regs); /* get lcd panel status */ SANE_Status sanei_rts88xx_get_lcd (SANE_Int devnum, SANE_Byte * regs); /* * write to special control register CONTROL_REG=0xb3 */ SANE_Status sanei_rts88xx_write_control (SANE_Int devnum, SANE_Byte value); /* * send the cancel control sequence */ SANE_Status sanei_rts88xx_cancel (SANE_Int devnum); /* * read available data count from scanner */ SANE_Status sanei_rts88xx_data_count (SANE_Int devnum, SANE_Word * count); /* * wait for scanned data to be available, if busy is true, check is scanner is busy * while waiting. The number of data bytes of available data is returned in 'count'. */ SANE_Status sanei_rts88xx_wait_data (SANE_Int devnum, SANE_Bool busy, SANE_Word * count); /* * write the given number of bytes pointed by value into memory */ SANE_Status sanei_rts88xx_write_mem (SANE_Int devnum, SANE_Int length, SANE_Int extra, SANE_Byte * value); /* * set memory with the given data */ SANE_Status sanei_rts88xx_set_mem (SANE_Int devnum, SANE_Byte ctrl1, SANE_Byte ctrl2, SANE_Int length, SANE_Byte * value); /* * read the given number of bytes from memory into buffer */ SANE_Status sanei_rts88xx_read_mem (SANE_Int devnum, SANE_Int length, SANE_Byte * value); /* * get memory */ SANE_Status sanei_rts88xx_get_mem (SANE_Int devnum, SANE_Byte ctrl1, SANE_Byte ctrl2, SANE_Int length, SANE_Byte * value); /* * write to the nvram controler */ SANE_Status sanei_rts88xx_nvram_ctrl (SANE_Int devnum, SANE_Int length, SANE_Byte * value); /* * setup nvram */ SANE_Status sanei_rts88xx_setup_nvram (SANE_Int devnum, SANE_Int length, SANE_Byte * value); /* does a simple scan, putting data in image */ /* SANE_Status sanei_rts88xx_simple_scan (SANE_Int devnum, SANE_Byte * regs, int regcount, SANE_Word size, unsigned char *image); */ #endif /* not RTS88XX_LIB_H */ sane-backends-1.0.29/backend/hp5400_internal.h0000666000000000000000000002034213615534521015556 00000000000000#ifndef _HP5400_INTERNAL_H_ #define _HP5400_INTERNAL_H_ /* sane - Scanner Access Now Easy. (C) 2003 Thomas Soumarmon (c) 2003 Martijn van Oosterhout, kleptog@svana.org (c) 2002 Bertrik Sikken, bertrik@zonnet.nl 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. HP5400/5470 Test util. Currently is only able to read back the scanner version string, but this basically demonstrates ability to communicate with the scanner. Massively expanded. Can do calibration scan, upload gamma and calibration tables and stores the results of a scan. - 19/02/2003 Martijn */ #include "../include/_stdint.h" #ifdef __GNUC__ #define PACKED __attribute__ ((packed)) #else #define PACKED #endif /* If this is enabled, a copy of the raw data from the scanner will be saved to imagedebug.dat and the attempted conversion to imagedebug.ppm */ /* #define IMAGE_DEBUG */ /* If this is defined you get extra info on the calibration */ /* #define CALIB_DEBUG */ #define CMD_GETVERSION 0x1200 #define CMD_GETUITEXT 0xf00b #define CMD_GETCMDID 0xc500 #define CMD_SCANREQUEST 0x2505 /* This is for previews */ #define CMD_SCANREQUEST2 0x2500 /* This is for real scans */ #define CMD_SCANRESPONSE 0x3400 /* Testing stuff to make it work */ #define CMD_SETDPI 0x1500 /* ??? */ #define CMD_STOPSCAN 0x1B01 /* 0x40 = lamp in on, 0x00 = lamp is off */ #define CMD_STARTSCAN 0x1B05 /* 0x40 = lamp in on, 0x00 = lamp is off */ #define CMD_UNKNOWN 0x2300 /* Send fixed string */ #define CMD_UNKNOWN2 0xD600 /* ??? Set to 0x04 */ #define CMD_UNKNOWN3 0xC000 /* ??? Set to 02 03 03 3C */ #define CMD_SETOFFSET 0xE700 /* two ints in network order. X-offset, Y-offset of full scan */ /* Given values seem to be 0x0054 (=4.57mm) and 0x0282 (=54.36mm) */ #define CMD_INITBULK1 0x0087 /* send 0x14 */ #define CMD_INITBULK2 0x0083 /* send 0x24 */ #define CMD_INITBULK3 0x0082 /* transfer length 0xf000 */ struct ScanRequest { uint8_t x1; /* Set to 0x08 */ uint16_t dpix, dpiy; /* Set to 75, 150 or 300 in network order */ uint16_t offx, offy; /* Offset to scan, in 1/300th of dpi, in network order */ uint16_t lenx, leny; /* Size of scan, in 1/300th of dpi, in network order */ uint16_t flags1, flags2, flags3; /* Undetermined flag info */ /* Known combinations are: 1st calibration scan: 0x0000, 0x0010, 0x1820 = 24bpp 2nd calibration scan: 0x0000, 0x0010, 0x3020 = 48bpp ??? 3rd calibration scan: 0x0000, 0x0010, 0x3024 = 48bpp ??? Preview scan: 0x0080, 0x0000, 0x18E8 = 8bpp 4th & 5th like 2nd and 3rd B&W scan: 0x0080, 0x0040, 0x08E8 = 8bpp 6th & 7th like 2nd and 3rd True colour scan 0x0080, 0x0040, 0x18E8 = 24bpp */ uint8_t zero; /* Seems to always be zero */ uint16_t gamma[3]; /* Set to 100 in network order. Gamma? */ uint16_t pad[3]; /* Zero padding ot 32 bytes??? */ } PACKED; /* More known combos (All 24-bit): 300 x 300 light calibration: 0x0000, 0x0010, 0x1820 300 x 300 dark calibration: 0x0000, 0x0010, 0x3024 75 x 75 preview scan: 0x0080, 0x0000, 0x18E8 300 x 300 full scan: 0x0080, 0x0000, 0x18E8 600 x 300 light calibration: 0x0000, 0x0010, 0x3000 600 x 300 dark calibration: 0x0000, 0x0010, 0x3004 600 x 600 full scan: 0x0080, 0x0000, 0x18C8 1200 x 300 light calibration: 0x0000, 0x0010, 0x3000 1200 x 300 dark calibration: 0x0000, 0x0010, 0x3004 1200 x 1200 full scan: 0x0080, 0x0000, 0x18C8 2400 x 300 light calibration: 0x0000, 0x0010, 0x3000 2400 x 300 dark calibration: 0x0000, 0x0010, 0x3004 2400 x 2400 full scan: 0x0080, 0x0000, 0x18C0 */ struct ScanResponse { uint16_t x1; /* Usually 0x0000 or 0x4000 */ uint32_t transfersize; /* Number of bytes to be transferred */ uint32_t xsize; /* Shape of returned bitmap */ uint16_t ysize; /* Why does the X get more bytes? */ uint16_t pad[2]; /* Zero padding to 16 bytes??? */ } PACKED; HP5400_SANE_STATIC int InitScan2 (enum ScanType type, struct ScanRequest *req, THWParams * pHWParams, struct ScanResponse *res, int iColourOffset, int code); HP5400_SANE_STATIC void FinishScan (THWParams * pHWParams); HP5400_SANE_STATIC int WriteByte (int iHandle, int cmd, char data); HP5400_SANE_STATIC int SetLamp (THWParams * pHWParams, int fLampOn); HP5400_SANE_STATIC int WarmupLamp (int iHandle); HP5400_SANE_STATIC int SetCalibration (int iHandle, int numPixels, unsigned int *low_vals[3], unsigned int *high_vals[3], int dpi); HP5400_SANE_STATIC void WriteGammaCalibTable (int iHandle, const int *pabGammaR, const int *pabGammaG, const int *pabGammaB); #ifdef STANDALONE HP5400_SANE_STATIC void SetDefaultGamma (int iHandle); #endif HP5400_SANE_STATIC void CircBufferInit (int iHandle, TDataPipe * p, int iBytesPerLine, int bpp, int iMisAlignment, int blksize, int iTransferSize); HP5400_SANE_STATIC int CircBufferGetLine (int iHandle, TDataPipe * p, void *pabLine); HP5400_SANE_STATIC void CircBufferExit (TDataPipe * p); #ifdef STANDALONE HP5400_SANE_STATIC void DecodeImage (FILE * file, int planes, int bpp, int xsize, int ysize, const char *filename); HP5400_SANE_STATIC int hp5400_test_scan_response (struct ScanResponse *resp, struct ScanRequest *req); #endif HP5400_SANE_STATIC int DoAverageScan (int iHandle, struct ScanRequest *req, int code, unsigned int **array); #ifdef STANDALONE HP5400_SANE_STATIC int DoScan (int iHandle, struct ScanRequest *req, const char *filename, int code, struct ScanResponse *res); #endif HP5400_SANE_STATIC int Calibrate (int iHandle, int dpi); #ifdef STANDALONE HP5400_SANE_STATIC int hp5400_scan (int iHandle, TScanParams * params, THWParams * pHWParams, const char *filename); HP5400_SANE_STATIC int PreviewScan (int iHandle); HP5400_SANE_STATIC int InitScanner (int iHandle); #endif HP5400_SANE_STATIC int InitScan (enum ScanType scantype, TScanParams * pParams, THWParams * pHWParams); HP5400_SANE_STATIC void FinishScan (THWParams * pHWParams); HP5400_SANE_STATIC int HP5400Open (THWParams * params, const char *filename); HP5400_SANE_STATIC void HP5400Close (THWParams * params); HP5400_SANE_STATIC int HP5400Detect (const char *filename, int (*_ReportDevice) (TScannerModel * pModel, const char *pszDeviceName)); HP5400_SANE_STATIC int InitHp5400_internal( void ); HP5400_SANE_STATIC int FreeHp5400_internal( void ); #ifdef STANDALONE int main (int argc, char *argv[]); #endif #endif sane-backends-1.0.29/backend/umax-uc1200s.c0000666000000000000000000001050013615534521014775 00000000000000 /* ------------------------------------------------------------------------- */ /* umax-uc1200s.c: inquiry for UMAX scanner uc1200s (C) 1997-2002 Oliver Rauch 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* ------------------------------------------------------------------------- */ #include "umax-scanner.h" /* ------------------------------------------------------------------------- */ static unsigned char UC1200S_INQUIRY[] = { #define UC1200S_INQUIRY_LEN 0x9d /* 24 F/W support function */ 0x03, /* 25 -27 exposure-times */ 0x00, 0x00, 0x00, /* 28 - 29 reserved */ 0x00, 0x00, /* 2a - 35 exposure times */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 36 - 37 reserved */ 0x00, 0x00, /* 38 - 5f scsi reserved */ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, /* 60 -62 scanner capability*/ 0x2f, 0x0c, 0x07, /* 63 reserved */ 0x00, /* 64 gamma */ 0xa3, /* 65 reserved */ 0x00, /* 66 GIB */ 0x01, /* 67 reserved */ 0x00, /* 68 GOB */ 0x01, /* 69 - 6a halftone */ 0x0c, 0x2f, /* 6b - 6c reserved */ 0x00, 0x00, /* 6d color sequence */ 0xe8, /* 0xe9 or 0xe1 ? */ /* 6e - 71 video memory */ 0x00, 0x04, 0x00, 0x00, /* 72 reserved */ 0x00, /* 73 max optical res in 100 dpi */ 0x06, /* 74 max x_res in 100 dpi */ 0x0c, /* 75 max y_res in 100 dpi */ 0x0c, /* 76-77 fb max scan width in 0.01 inch */ 0x03, 0x20, /* 78-79 fb max scan length in 0.01 inch */ 0x04, 0x9c, /* 7a-7b uta x original point, may be 0x05, 0x89 */ 0x00, 0x76, /* 7c-7d uta y original point, may be 0x06, 0x75 */ 0x00, 0x89, /* 7e-7f uta max scan width in 0.01 inch */ 0x02, 0x4e, /* 80-81 uta max scan length in 0.01 inch */ 0x03, 0x65, /* 82-85 reserved */ 00, 00, 00, 00, /* 86-87 dor x original point */ 0x00, 0x00, /* 88-89 dor x original point */ 0x00, 0x00, /* 8a-8b dor max scan width in 0.01 inch */ 0x00, 0x00, /* 8c-8d dor max scan length in 0.01 inch */ 0x00, 0x00, /* 8e reserved */ 0x00, /* 8f last calibration lamp density */ 0x00, /* 90 reserved */ 0x00, /* 91 lamp warmup max time */ 0x00, /* 92-93 window descriptor block length */ 0x00, 0x30, /* 94 optical resolution residue (1dpi) */ 0x00, /* 95 x_resolution residue (1dpi) */ 0x00, /* 96 y_resolution residue (1dpi) */ 0x00, /* 97 analog gamma table */ 0x00, /* 98-99 reserved */ 0x00, 0x00, /* 9a max calibration data lines */ 0x00, /* 9b fb/uta colour-sequnce-mode */ 0x01, /* 9c adf colour-sequnce-mode */ 0x01, /* 9d line-distance of ccd */ 0x08 }; static inquiry_blk inquiry_uc1200s = { "UC1200S ",UC1200S_INQUIRY, UC1200S_INQUIRY_LEN }; sane-backends-1.0.29/backend/canon_dr.conf.in0000666000000000000000000000757013615534521015640 00000000000000####################################################################### # NOTE: 'option' lines only apply to the devices found by # the NEXT 'usb' or 'scsi' line. You may repeat the option line if # required for multiple scanners of different models/connections. ####################################################################### # Some machines are incapable of providing basic inquiry info, and will # lock up if asked for it. The driver will not ask for this info if all # three of these options are provided. They should NOT be used unless # you know for sure that your machine requires it. # NOTE: the vendor and model must be correct. The version need not. #option vendor-name CANON #option model-name DR-2050C #option version-name XXXX ####################################################################### # Set data buffer size, in bytes. The value ranges from 4096 - infinity # Large values may cause timeouts, or long pauses at the end of each # page. Small values may cause slow scans. 2MB is the default. #option buffer-size 2097152 ####################################################################### # Most scanners dont pad their reads #option padded-read 0 ####################################################################### # SCSI scanners: # To search for any CANON scsi device, if name starts with 'CR' or 'DR' scsi CANON CR scsi CANON DR # To use a specific scsi device #scsi /dev/sg1 ####################################################################### # USB scanners: # For Canon scanners connected via USB on a known device (kernel driver): #usb /dev/usb/scanner0 # For Canon scanners connected via USB using vendor and device ids (libusb): #usb VENDORID PRODUCTID # NOTE: if you have to add your device here- please send the id and model # to the author via email, so it can be included in next version. kitno455 at # gmail dot com - with canon_dr in the subject line # DR-2080C (uses weird protocol) option duplex-offset 840 option vendor-name CANON option model-name DR-2080C option version-name XXXX option padded-read 1 usb 0x04a9 0x1601 # CR-180 usb 0x04a9 0x1602 # DR-9080C usb 0x04a9 0x1603 # DR-7080C usb 0x04a9 0x1604 # DR-5010C usb 0x04a9 0x1606 # DR-6080C usb 0x04a9 0x1607 # DR-2580C option duplex-offset 432 usb 0x04a9 0x1608 # DR-3080CII option padded-read 1 usb 0x04a9 0x1609 # DR-2050C/SP (uses weird protocol) option duplex-offset 840 option vendor-name CANON option model-name DR-2050C option version-name XXXX option padded-read 1 usb 0x04a9 0x160a # DR-7580 usb 0x04a9 0x160b # CR-55 usb 0x1083 0x160c # DR-1210C (two versions?) usb 0x1083 0x160f usb 0x04a9 0x2222 # DR-4010C usb 0x1083 0x1614 # DR-2510C option duplex-offset 400 usb 0x1083 0x1617 # DR-X10C usb 0x1083 0x1618 # CR-25 usb 0x1083 0x161a # DR-2010C option duplex-offset 400 usb 0x1083 0x161b # DR-3010C option duplex-offset 400 usb 0x1083 0x161d # DR-7090C usb 0x1083 0x1620 # DR-9050C usb 0x1083 0x1622 # DR-7550C usb 0x1083 0x1623 # DR-6050C usb 0x1083 0x1624 # DR-6010C usb 0x1083 0x1626 # CR-190i usb 0x1083 0x162b # P-150M usb 0x1083 0x162c # DR-6030C usb 0x1083 0x1638 # CR-135i usb 0x1083 0x1639 # DR-M160 option extra-status 1 option duplex-offset 400 usb 0x1083 0x163e # DR-M140 option extra-status 1 option duplex-offset 400 usb 0x1083 0x163f # DR-C125 option duplex-offset 400 usb 0x1083 0x1640 # DR-P215 usb 0x1083 0x1641 # P-215 usb 0x1083 0x1646 # FSU-201 usb 0x1083 0x1648 # DR-C130 usb 0x1083 0x164a # DR-P208 usb 0x1083 0x164b # P-208 usb 0x1083 0x164c # DR-G1130 option buffer-size 8000000 usb 0x1083 0x164f # DR-G1100 option buffer-size 8000000 usb 0x1083 0x1650 # DR-C120 usb 0x1083 0x1651 # P-201 usb 0x1083 0x1652 # DR-F120 option duplex-offset 1640 usb 0x1083 0x1654 # DR-M1060 usb 0x1083 0x1657 # DR-C225 usb 0x1083 0x1658 # DR-P215II usb 0x1083 0x1659 # P-215II usb 0x1083 0x165b # DR-P208II usb 0x1083 0x165d # P-208II usb 0x1083 0x165f sane-backends-1.0.29/backend/sm3840.c0000666000000000000000000005772013615534521013705 00000000000000/* sane - Scanner Access Now Easy. ScanMaker 3840 Backend Copyright (C) 2005-7 Earle F. Philhower, III earle@ziplabel.com - http://www.ziplabel.com 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/saneopts.h" #define BACKENDNAME sm3840 #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/sanei_config.h" #include "sm3840.h" #include "sm3840_scan.c" #include "sm3840_lib.c" static double sm3840_unit_convert (SANE_Int val); static int num_devices; static SM3840_Device *first_dev; static SM3840_Scan *first_handle; static const SANE_Device **devlist = 0; static const SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_COLOR, SANE_VALUE_SCAN_MODE_LINEART, SANE_VALUE_SCAN_MODE_HALFTONE, 0 }; static const SANE_Word resolution_list[] = { 4, 1200, 600, 300, 150 }; static const SANE_Word bpp_list[] = { 2, 8, 16 }; static const SANE_Range x_range = { SANE_FIX (0), SANE_FIX (215.91), /* 8.5 inches */ SANE_FIX (0) }; static const SANE_Range y_range = { SANE_FIX (0), SANE_FIX (297.19), /* 11.7 inches */ SANE_FIX (0) }; static const SANE_Range brightness_range = { 1, 4096, 1.0 }; static const SANE_Range contrast_range = { SANE_FIX (0.1), SANE_FIX (9.9), SANE_FIX (0.1) }; static const SANE_Range lamp_range = { 1, 15, 1 }; static const SANE_Range threshold_range = { 0, 255, 1 }; /*--------------------------------------------------------------------------*/ static int min (int a, int b) { if (a < b) return a; else return b; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { SM3840_Scan *s = handle; unsigned char c, d; int i; DBG (2, "+sane-read:%p %p %d %p\n", (unsigned char *) s, buf, max_len, (unsigned char *) len); DBG (2, "+sane-read:remain:%lu offset:%lu linesleft:%d linebuff:%p linesread:%d\n", (u_long)s->remaining, (u_long)s->offset, s->linesleft, s->line_buffer, s->linesread); if (!s->scanning) return SANE_STATUS_INVAL; if (!s->remaining) { if (!s->linesleft) { *len = 0; s->scanning = 0; /* Move to home position */ reset_scanner ((p_usb_dev_handle)s->udev); /* Send lamp timeout */ set_lamp_timer ((p_usb_dev_handle)s->udev, s->sm3840_params.lamp); /* Free memory */ if (s->save_scan_line) free (s->save_scan_line); s->save_scan_line = NULL; if (s->save_dpi1200_remap) free (s->save_dpi1200_remap); s->save_dpi1200_remap = NULL; if (s->save_color_remap) free (s->save_color_remap); s->save_color_remap = NULL; return SANE_STATUS_EOF; } record_line ((s->linesread == 0) ? 1 : 0, (p_usb_dev_handle) s->udev, s->line_buffer, s->sm3840_params.dpi, s->sm3840_params.scanpix, s->sm3840_params.gray, (s->sm3840_params.bpp == 16) ? 1 : 0, &s->save_i, &s->save_scan_line, &s->save_dpi1200_remap, &s->save_color_remap); s->remaining = s->sm3840_params.linelen; s->offset = 0; s->linesread++; s->linesleft--; } /* Need to software emulate 1-bpp modes, simple threshold and error */ /* diffusion dither implemented. */ if (s->sm3840_params.lineart || s->sm3840_params.halftone) { d = 0; for (i = 0; i < min (max_len * 8, s->remaining); i++) { d = d << 1; if (s->sm3840_params.halftone) { c = (*(unsigned char *) (s->offset + s->line_buffer + i)); if (c + s->save_dither_err < 128) { d |= 1; s->save_dither_err += c; } else { s->save_dither_err += c - 255; } } else { if ((*(unsigned char *) (s->offset + s->line_buffer + i)) < s->threshold ) d |= 1; } if (i % 8 == 7) *(buf++) = d; } *len = i / 8; s->offset += i; s->remaining -= i; } else { memcpy (buf, s->offset + s->line_buffer, min (max_len, s->remaining)); *len = min (max_len, s->remaining); s->offset += min (max_len, s->remaining); s->remaining -= min (max_len, s->remaining); } DBG (2, "-sane_read\n"); return SANE_STATUS_GOOD; } /*--------------------------------------------------------------------------*/ void sane_cancel (SANE_Handle h) { SM3840_Scan *s = h; DBG (2, "trying to cancel...\n"); if (s->scanning) { if (!s->cancelled) { /* Move to home position */ reset_scanner ((p_usb_dev_handle) s->udev); /* Send lamp timeout */ set_lamp_timer ((p_usb_dev_handle) s->udev, s->sm3840_params.lamp); /* Free memory */ if (s->save_scan_line) free (s->save_scan_line); s->save_scan_line = NULL; if (s->save_dpi1200_remap) free (s->save_dpi1200_remap); s->save_dpi1200_remap = NULL; if (s->save_color_remap) free (s->save_color_remap); s->save_color_remap = NULL; s->scanning = 0; s->cancelled = SANE_TRUE; } } } /*--------------------------------------------------------------------------*/ SANE_Status sane_start (SANE_Handle handle) { SM3840_Scan *s = handle; SANE_Status status; /* First make sure we have a current parameter set. Some of the * parameters will be overwritten below, but that's OK. */ DBG (2, "sane_start\n"); status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; DBG (1, "Got params again...\n"); s->scanning = SANE_TRUE; s->cancelled = 0; s->line_buffer = malloc (s->sm3840_params.linelen); s->remaining = 0; s->offset = 0; s->linesleft = s->sm3840_params.scanlines; s->linesread = 0; s->save_i = 0; s->save_scan_line = NULL; s->save_dpi1200_remap = NULL; s->save_color_remap = NULL; s->save_dither_err = 0; s->threshold = s->sm3840_params.threshold; setup_scan ((p_usb_dev_handle) s->udev, &(s->sm3840_params)); return (SANE_STATUS_GOOD); } static double sm3840_unit_convert (SANE_Int val) { double d; d = SANE_UNFIX (val); d /= MM_PER_INCH; return d; } /*--------------------------------------------------------------------------*/ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { SM3840_Scan *s = handle; DBG (2, "sane_get_parameters\n"); if (!s->scanning) { memset (&s->sane_params, 0, sizeof (s->sane_params)); /* Copy from options to sm3840_params */ s->sm3840_params.gray = (!strcasecmp (s->value[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY)) ? 1 : 0; s->sm3840_params.halftone = (!strcasecmp (s->value[OPT_MODE].s, SANE_VALUE_SCAN_MODE_HALFTONE)) ? 1 : 0; s->sm3840_params.lineart = (!strcasecmp (s->value[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART)) ? 1 : 0; s->sm3840_params.dpi = s->value[OPT_RESOLUTION].w; s->sm3840_params.bpp = s->value[OPT_BIT_DEPTH].w; s->sm3840_params.gain = SANE_UNFIX (s->value[OPT_CONTRAST].w); s->sm3840_params.offset = s->value[OPT_BRIGHTNESS].w; s->sm3840_params.lamp = s->value[OPT_LAMP_TIMEOUT].w; s->sm3840_params.threshold = s->value[OPT_THRESHOLD].w; if (s->sm3840_params.lineart || s->sm3840_params.halftone) { s->sm3840_params.gray = 1; s->sm3840_params.bpp = 8; } s->sm3840_params.top = sm3840_unit_convert (s->value[OPT_TL_Y].w); s->sm3840_params.left = sm3840_unit_convert (s->value[OPT_TL_X].w); s->sm3840_params.width = sm3840_unit_convert (s->value[OPT_BR_X].w) - s->sm3840_params.left; s->sm3840_params.height = sm3840_unit_convert (s->value[OPT_BR_Y].w) - s->sm3840_params.top; /* Legalize and calculate pixel sizes */ prepare_params (&(s->sm3840_params)); /* Copy into sane_params */ s->sane_params.pixels_per_line = s->sm3840_params.scanpix; s->sane_params.lines = s->sm3840_params.scanlines; s->sane_params.format = s->sm3840_params.gray ? SANE_FRAME_GRAY : SANE_FRAME_RGB; s->sane_params.bytes_per_line = s->sm3840_params.linelen; s->sane_params.depth = s->sm3840_params.bpp; if (s->sm3840_params.lineart || s->sm3840_params.halftone) { s->sane_params.bytes_per_line += 7; s->sane_params.bytes_per_line /= 8; s->sane_params.depth = 1; s->sane_params.pixels_per_line = s->sane_params.bytes_per_line * 8; } s->sane_params.last_frame = SANE_TRUE; } /*!scanning */ if (params) *params = s->sane_params; return (SANE_STATUS_GOOD); } /*--------------------------------------------------------------------------*/ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { SM3840_Scan *s = handle; SANE_Status status = 0; SANE_Word cap; DBG (2, "sane_control_option\n"); if (info) *info = 0; if (s->scanning) return SANE_STATUS_DEVICE_BUSY; if (option >= NUM_OPTIONS) return SANE_STATUS_INVAL; cap = s->options_list[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) return SANE_STATUS_INVAL; if (action == SANE_ACTION_GET_VALUE) { DBG (1, "sane_control_option %d, get value\n", option); switch (option) { /* word options: */ case OPT_RESOLUTION: case OPT_BIT_DEPTH: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_NUM_OPTS: case OPT_CONTRAST: case OPT_BRIGHTNESS: case OPT_LAMP_TIMEOUT: case OPT_THRESHOLD: *(SANE_Word *) val = s->value[option].w; return (SANE_STATUS_GOOD); /* string options: */ case OPT_MODE: strcpy (val, s->value[option].s); return (SANE_STATUS_GOOD); } } else if (action == SANE_ACTION_SET_VALUE) { DBG (1, "sane_control_option %d, set value\n", option); if (!SANE_OPTION_IS_SETTABLE (cap)) return (SANE_STATUS_INVAL); if (status != SANE_STATUS_GOOD) return (status); status = sanei_constrain_value (s->options_list + option, val, info); switch (option) { /* (mostly) side-effect-free word options: */ case OPT_RESOLUTION: case OPT_BIT_DEPTH: case OPT_BR_X: case OPT_BR_Y: case OPT_TL_X: case OPT_TL_Y: if (info) *info |= SANE_INFO_RELOAD_PARAMS; /* fall through */ case OPT_NUM_OPTS: case OPT_CONTRAST: case OPT_BRIGHTNESS: case OPT_LAMP_TIMEOUT: case OPT_THRESHOLD: s->value[option].w = *(SANE_Word *) val; return (SANE_STATUS_GOOD); case OPT_MODE: if (s->value[option].s) free (s->value[option].s); s->value[option].s = strdup (val); if (info) *info |= SANE_INFO_RELOAD_PARAMS; return (SANE_STATUS_GOOD); } } return (SANE_STATUS_INVAL); } /*--------------------------------------------------------------------------*/ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { SM3840_Scan *s = handle; DBG (2, "sane_get_option_descriptor\n"); if ((unsigned) option >= NUM_OPTIONS) return (0); return (&s->options_list[option]); } /*--------------------------------------------------------------------------*/ void sane_close (SANE_Handle handle) { SM3840_Scan *prev, *s; DBG (2, "sane_close\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) { DBG (1, "close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (s->scanning) { sane_cancel (handle); } sanei_usb_close (s->udev); if (s->line_buffer) free (s->line_buffer); if (s->save_scan_line) free (s->save_scan_line); if (s->save_dpi1200_remap) free (s->save_dpi1200_remap); if (s->save_color_remap) free (s->save_color_remap); if (prev) prev->next = s->next; else first_handle = s; free (handle); } /*--------------------------------------------------------------------------*/ void sane_exit (void) { SM3840_Device *next; DBG (2, "sane_exit\n"); while (first_dev != NULL) { next = first_dev->next; free (first_dev); first_dev = next; } if (devlist) free (devlist); } /*--------------------------------------------------------------------------*/ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { DBG_INIT (); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, 0); if (authorize) DBG (2, "Unused authorize\n"); sanei_usb_init (); return (SANE_STATUS_GOOD); } /*--------------------------------------------------------------------------*/ static SANE_Status add_sm_device (SANE_String_Const devname, SANE_String_Const modname) { SM3840_Device *dev; dev = calloc (sizeof (*dev), 1); if (!dev) return (SANE_STATUS_NO_MEM); memset (dev, 0, sizeof (*dev)); dev->sane.name = strdup (devname); dev->sane.model = modname; dev->sane.vendor = "Microtek"; dev->sane.type = "flatbed scanner"; ++num_devices; dev->next = first_dev; first_dev = dev; return (SANE_STATUS_GOOD); } static SANE_Status add_sm3840_device (SANE_String_Const devname) { return add_sm_device (devname, "ScanMaker 3840"); } static SANE_Status add_sm4800_device (SANE_String_Const devname) { return add_sm_device (devname, "ScanMaker 4800"); } /*--------------------------------------------------------------------------*/ SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { static const SANE_Device **devlist = 0; SM3840_Device *dev; int i; DBG (3, "sane_get_devices (local_only = %d)\n", local_only); while (first_dev) { dev = first_dev->next; free (first_dev); first_dev = dev; } first_dev = NULL; num_devices = 0; /* If we get enough scanners should use an array, but for now */ /* do it one-by-one... */ sanei_usb_find_devices (0x05da, 0x30d4, add_sm3840_device); sanei_usb_find_devices (0x05da, 0x30cf, add_sm4800_device); if (devlist) free (devlist); devlist = calloc ((num_devices + 1) * sizeof (devlist[0]), 1); if (!devlist) return SANE_STATUS_NO_MEM; i = 0; for (dev = first_dev; i < num_devices; dev = dev->next) devlist[i++] = &dev->sane; devlist[i++] = 0; if (device_list) *device_list = devlist; return (SANE_STATUS_GOOD); } /*--------------------------------------------------------------------------*/ static size_t max_string_size (const SANE_String_Const strings[]) { size_t size, max_size = 0; int i; for (i = 0; strings[i]; ++i) { size = strlen (strings[i]) + 1; if (size > max_size) max_size = size; } return (max_size); } /*--------------------------------------------------------------------------*/ static void initialize_options_list (SM3840_Scan * s) { SANE_Int option; DBG (2, "initialize_options_list\n"); for (option = 0; option < NUM_OPTIONS; ++option) { s->options_list[option].size = sizeof (SANE_Word); s->options_list[option].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->options_list[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->options_list[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->options_list[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->options_list[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->options_list[OPT_NUM_OPTS].unit = SANE_UNIT_NONE; s->options_list[OPT_NUM_OPTS].size = sizeof (SANE_Word); s->options_list[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->options_list[OPT_NUM_OPTS].constraint_type = SANE_CONSTRAINT_NONE; s->value[OPT_NUM_OPTS].w = NUM_OPTIONS; s->options_list[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->options_list[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->options_list[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->options_list[OPT_MODE].type = SANE_TYPE_STRING; s->options_list[OPT_MODE].size = max_string_size (mode_list); s->options_list[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->options_list[OPT_MODE].constraint.string_list = mode_list; s->value[OPT_MODE].s = strdup (mode_list[1]); s->options_list[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->options_list[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->options_list[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->options_list[OPT_RESOLUTION].type = SANE_TYPE_INT; s->options_list[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->options_list[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->options_list[OPT_RESOLUTION].constraint.word_list = resolution_list; s->value[OPT_RESOLUTION].w = 300; s->options_list[OPT_BIT_DEPTH].name = SANE_NAME_BIT_DEPTH; s->options_list[OPT_BIT_DEPTH].title = SANE_TITLE_BIT_DEPTH; s->options_list[OPT_BIT_DEPTH].desc = SANE_DESC_BIT_DEPTH; s->options_list[OPT_BIT_DEPTH].type = SANE_TYPE_INT; s->options_list[OPT_BIT_DEPTH].unit = SANE_UNIT_NONE; s->options_list[OPT_BIT_DEPTH].constraint_type = SANE_CONSTRAINT_WORD_LIST; s->options_list[OPT_BIT_DEPTH].constraint.word_list = bpp_list; s->value[OPT_BIT_DEPTH].w = 8; s->options_list[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->options_list[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->options_list[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->options_list[OPT_TL_X].type = SANE_TYPE_FIXED; s->options_list[OPT_TL_X].unit = SANE_UNIT_MM; s->options_list[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->options_list[OPT_TL_X].constraint.range = &x_range; s->value[OPT_TL_X].w = s->options_list[OPT_TL_X].constraint.range->min; s->options_list[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->options_list[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->options_list[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->options_list[OPT_TL_Y].type = SANE_TYPE_FIXED; s->options_list[OPT_TL_Y].unit = SANE_UNIT_MM; s->options_list[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->options_list[OPT_TL_Y].constraint.range = &y_range; s->value[OPT_TL_Y].w = s->options_list[OPT_TL_Y].constraint.range->min; s->options_list[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->options_list[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->options_list[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->options_list[OPT_BR_X].type = SANE_TYPE_FIXED; s->options_list[OPT_BR_X].unit = SANE_UNIT_MM; s->options_list[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->options_list[OPT_BR_X].constraint.range = &x_range; s->value[OPT_BR_X].w = s->options_list[OPT_BR_X].constraint.range->max; s->options_list[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->options_list[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->options_list[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->options_list[OPT_BR_Y].type = SANE_TYPE_FIXED; s->options_list[OPT_BR_Y].unit = SANE_UNIT_MM; s->options_list[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->options_list[OPT_BR_Y].constraint.range = &y_range; s->value[OPT_BR_Y].w = s->options_list[OPT_BR_Y].constraint.range->max; s->options_list[OPT_CONTRAST].name = SANE_NAME_CONTRAST; s->options_list[OPT_CONTRAST].title = SANE_TITLE_CONTRAST; s->options_list[OPT_CONTRAST].desc = SANE_DESC_CONTRAST; s->options_list[OPT_CONTRAST].type = SANE_TYPE_FIXED; s->options_list[OPT_CONTRAST].unit = SANE_UNIT_NONE; s->options_list[OPT_CONTRAST].constraint_type = SANE_CONSTRAINT_RANGE; s->options_list[OPT_CONTRAST].constraint.range = &contrast_range; s->value[OPT_CONTRAST].w = SANE_FIX (3.5); s->options_list[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; s->options_list[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; s->options_list[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; s->options_list[OPT_BRIGHTNESS].type = SANE_TYPE_INT; s->options_list[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; s->options_list[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; s->options_list[OPT_BRIGHTNESS].constraint.range = &brightness_range; s->value[OPT_BRIGHTNESS].w = 1800; s->options_list[OPT_LAMP_TIMEOUT].name = "lamp-timeout"; s->options_list[OPT_LAMP_TIMEOUT].title = SANE_I18N ("Lamp timeout"); s->options_list[OPT_LAMP_TIMEOUT].desc = SANE_I18N ("Minutes until lamp is turned off after scan"); s->options_list[OPT_LAMP_TIMEOUT].type = SANE_TYPE_INT; s->options_list[OPT_LAMP_TIMEOUT].unit = SANE_UNIT_NONE; s->options_list[OPT_LAMP_TIMEOUT].constraint_type = SANE_CONSTRAINT_RANGE; s->options_list[OPT_LAMP_TIMEOUT].constraint.range = &lamp_range; s->value[OPT_LAMP_TIMEOUT].w = 15; s->options_list[OPT_THRESHOLD].name = "threshold"; s->options_list[OPT_THRESHOLD].title = SANE_I18N ("Threshold"); s->options_list[OPT_THRESHOLD].desc = SANE_I18N ("Threshold value for lineart mode"); s->options_list[OPT_THRESHOLD].type = SANE_TYPE_INT; s->options_list[OPT_THRESHOLD].unit = SANE_UNIT_NONE; s->options_list[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->options_list[OPT_THRESHOLD].constraint.range = &threshold_range; s->value[OPT_THRESHOLD].w = 128; } /*--------------------------------------------------------------------------*/ SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { SANE_Status status; SM3840_Device *dev; SM3840_Scan *s; DBG (2, "sane_open\n"); /* Make sure we have first_dev */ sane_get_devices (NULL, 0); if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; } else { /* empty devicename -> use first device */ dev = first_dev; } DBG (2, "using device: %s %p\n", dev->sane.name, (unsigned char *) dev); if (!dev) return SANE_STATUS_INVAL; s = calloc (sizeof (*s), 1); if (!s) return SANE_STATUS_NO_MEM; status = sanei_usb_open (dev->sane.name, &(s->udev)); if (status != SANE_STATUS_GOOD) return status; initialize_options_list (s); s->scanning = 0; /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; return (SANE_STATUS_GOOD); } /*--------------------------------------------------------------------------*/ SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { SM3840_Scan *s = handle; DBG (2, "sane_set_io_mode( %p, %d )\n", handle, non_blocking); if (s->scanning) { if (non_blocking == SANE_FALSE) return SANE_STATUS_GOOD; else return (SANE_STATUS_UNSUPPORTED); } else return SANE_STATUS_INVAL; } /*---------------------------------------------------------------------------*/ SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { DBG (2, "sane_get_select_fd( %p, %p )\n", (void *) handle, (void *) fd); return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/canon_pp-io.h0000666000000000000000000000476513615534521015157 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2001-2002 Matthew C. Duggan and Simon Krix 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. ----- canon_pp-io.h: $Revision$ This file is part of the canon_pp backend, supporting Canon FBX30P and NX40P scanners and also distributed as part of the stand-alone driver. Low-level scanner interface */ #ifndef CANON_PP_IO_H #define CANON_PP_IO_H /* Actual Interface */ void sanei_canon_pp_set_ieee1284_mode(int m); int sanei_canon_pp_wake_scanner(struct parport *port, int mode); int sanei_canon_pp_write(struct parport *port, int length, unsigned char *data); int sanei_canon_pp_read(struct parport *port, int length, unsigned char *data); int sanei_canon_pp_check_status(struct parport *port); int sanei_canon_pp_scanner_init(struct parport *port); #endif sane-backends-1.0.29/backend/epson_usb.h0000666000000000000000000000030413615534521014733 00000000000000#ifndef _EPSON_USB_H_ #define _EPSON_USB_H_ #define SANE_EPSON_VENDOR_ID (0x4b8) extern SANE_Word sanei_epson_usb_product_ids[]; extern int sanei_epson_getNumberOfUSBProductIds (void); #endif sane-backends-1.0.29/backend/dll.conf.in0000666000000000000000000000213313615534521014616 00000000000000# 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 apple artec artec_eplus48u as6e avision bh canon canon630u canon_dr #canon_pp cardscan coolscan #coolscan2 coolscan3 #dc210 #dc240 #dc25 dell1600n_net dmc epjitsu #epson epson2 epsonds escl fujitsu genesys #gphoto2 gt68xx hp hp3500 hp3900 hp4200 hp5400 hp5590 hpljm1005 hpsj5s hs2p ibm kodak kodakaio kvs1025 kvs20xx kvs40xx leo lexmark ma1509 magicolor matsushita microtek microtek2 mustek #mustek_pp mustek_usb mustek_usb2 nec niash #p5 pie pieusb pint pixma plustek #plustek_pp #pnm qcam ricoh ricoh2 rts8891 s9036 sceptre sharp sm3600 sm3840 snapscan sp15c #st400 #stv680 tamarack teco1 teco2 teco3 #test u12 umax umax1220u #umax_pp v4l xerox_mfp sane-backends-1.0.29/backend/u12-hw.c0000666000000000000000000007104413615534521013765 00000000000000/** @file u12-hw.c * @brief The HW-access functions to the U12 backend stuff. * * Copyright (c) 2003-2004 Gerhard Jaeger * * History: * - 0.01 - initial version * - 0.02 - cleanup * - added lampTimer stuff * - fixed issue for Genius device - reported by * Jose Alberto Reguero * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #define _TEST_SIZE 1000 /*************************** some local vars *********************************/ static RegDef u12CcdStop[] = { /* this was the original sequence from parport backend*/ #if 0 #define _STOP_LEN 13 {0x41, 0xff}, {0x42, 0xff}, {0x60, 0xff}, {0x61, 0xff}, {0x4b, 0xff}, {0x4c, 0xff}, {0x4d, 0xff}, {0x4e, 0xff}, {0x2a, 0x01}, {0x2b, 0x00}, {0x2d, 0x00}, {0x1b, 0x19}, {0x15, 0x00} #else #define _STOP_LEN 29 /* this is what we see from usb-snoop... */ {0x60, 0xff}, {0x61, 0xff}, {0x1b, 0x19}, {0x15, 0x00}, {0x20, 0x14}, {0x2c, 0x02}, {0x39, 0x00}, {0x3a, 0x00}, {0x3b, 0x00}, {0x3c, 0x00}, {0x41, 0x00}, {0x42, 0x00}, {0x43, 0x00}, {0x44, 0x00}, {0x45, 0x01}, {0x46, 0x00}, {0x47, 0x00}, {0x48, 0x00}, {0x49, 0x00}, {0x4a, 0x09}, {0x4b, 0x00}, {0x4c, 0x00}, {0x4d, 0x00}, {0x4e, 0x01}, {0x50, 0x00}, {0x51, 0x00}, {0x52, 0x00}, {0x53, 0x01}, {0x67, 0x00} #endif }; /** */ static void u12hw_SelectLampSource( U12_Device *dev ) { dev->regs.RD_ScanControl &= (~_SCAN_LAMPS_ON); if( dev->DataInf.dwScanFlag & (_SCANDEF_TPA)) { dev->regs.RD_ScanControl |= _SCAN_TPALAMP_ON; } else { dev->regs.RD_ScanControl |= _SCAN_NORMALLAMP_ON; } } /** as the function name says */ static void u12hw_PutToIdleMode( U12_Device *dev ) { DBG( _DBG_INFO, "CCD-Stop\n" ); u12io_DataToRegs( dev, (SANE_Byte*)u12CcdStop, _STOP_LEN ); } /** program the CCD relevant stuff */ static void u12hw_ProgramCCD( U12_Device *dev ) { SANE_Byte *reg_val; DBG( _DBG_INFO, "u12hw_ProgramCCD: 0x%08lx[%lu]\n", (u_long)dev->CCDRegs, ((u_long)dev->numCCDRegs * dev->shade.intermediate)); DBG( _DBG_INFO, " * %u regs * %u (intermediate)\n", dev->numCCDRegs, dev->shade.intermediate ); reg_val = (SANE_Byte*)(dev->CCDRegs + (u_long)dev->numCCDRegs * dev->shade.intermediate); u12io_DataToRegs( dev, reg_val, dev->numCCDRegs ); } /** init the stuff according to the buttons */ static void u12hw_ButtonSetup( U12_Device *dev, SANE_Byte numButtons ) { dev->Buttons = numButtons; dev->regs.RD_MotorDriverType |= _BUTTON_DISABLE; dev->MotorPower |= _BUTTON_DISABLE; } /** According to what we have detected, set the other stuff */ static void u12hw_InitiateComponentModel( U12_Device *dev ) { /* preset some stuff and do the differences later */ dev->Buttons = 0; dev->ModelOriginY = 64; dev->Tpa = SANE_FALSE; dev->ModelCtrl = (_LED_ACTIVITY | _LED_CONTROL); switch( dev->PCBID ) { /* typical for Plustek OpticPro U12 and 1212U */ case _PLUSTEK_SCANNER: DBG( _DBG_INFO, "We have a Plustek Scanner ;-)\n" ); break; case _SCANNER_WITH_TPA: DBG( _DBG_INFO, "Scanner has TPA\n" ); dev->Tpa = SANE_TRUE; break; case _SCANNER4Button: DBG( _DBG_INFO, "Scanner has 4 Buttons\n" ); u12hw_ButtonSetup( dev, 4 ); break; /* typical for Plustek OpticPro UT12 */ case _SCANNER4ButtonTPA: DBG( _DBG_INFO, "Scanner has 4 Buttons & TPA\n" ); dev->Tpa = SANE_TRUE; u12hw_ButtonSetup( dev, 4 ); break; case _SCANNER5Button: DBG( _DBG_INFO, "Scanner has 5 Buttons\n" ); dev->ModelOriginY += 20; u12hw_ButtonSetup( dev, 5 ); break; /* typical for Genius Colorpage HR6 */ case _SCANNER5ButtonTPA: DBG( _DBG_INFO, "Scanner has 5 Buttons & TPA\n" ); dev->ModelOriginY += 20; dev->Tpa = SANE_TRUE; u12hw_ButtonSetup( dev, 5 ); break; case _SCANNER1Button: DBG( _DBG_INFO, "Scanner has 1 Button\n" ); u12hw_ButtonSetup( dev, 1 ); break; case _SCANNER1ButtonTPA: DBG( _DBG_INFO, "Scanner has 1 Button & TPA\n" ); dev->Tpa = SANE_TRUE; u12hw_ButtonSetup( dev, 1 ); break; case _AGFA_SCANNER: DBG( _DBG_INFO, "Agfa Scanner\n" ); dev->ModelOriginY = 24; /* 1200 dpi */ break; case _SCANNER2Button: DBG( _DBG_INFO, "Scanner has 2 Buttons\n" ); dev->ModelOriginY -= 33; u12hw_ButtonSetup( dev, 2 ); break; default: DBG( _DBG_INFO, "Default Model: U12\n" ); break; } #if 0 if( _MOTOR0_2003 == dev->MotorID ) { dev->f2003 = SANE_TRUE; dev->XStepMono = 10; dev->XStepColor = 6; dev->XStepBack = 5; dev->regs.RD_MotorDriverType |= _MOTORR_STRONG; } else { #endif dev->f2003 = SANE_FALSE; dev->XStepMono = 8; dev->XStepColor = 4; dev->XStepBack = 5; dev->regs.RD_MotorDriverType |= _MOTORR_WEAK; /* } */ } /** */ static SANE_Status u12hw_InitAsic( U12_Device *dev, SANE_Bool shading ) { SANE_Byte rb[6]; int c; DBG( _DBG_INFO, "u12hw_InitAsic(%d)\n", shading ); /* get DAC and motor stuff */ dev->DACType = u12io_DataFromRegister( dev, REG_RESETCONFIG ); dev->MotorID = (SANE_Byte)(dev->DACType & _MOTOR0_MASK); dev->regs.RD_MotorDriverType = (SANE_Byte)((dev->DACType & _MOTOR0_MASK) >> 3); dev->regs.RD_MotorDriverType |= (SANE_Byte)((dev->DACType & _MOTOR1_MASK) >> 1); dev->DACType &= _ADC_MASK; dev->MotorPower = dev->regs.RD_MotorDriverType | _MOTORR_STRONG; /*get CCD and PCB ID */ dev->PCBID = u12io_DataFromRegister( dev, REG_CONFIG ); dev->CCDID = dev->PCBID & 0x07; dev->PCBID &= 0xf0; if( _AGFA_SCANNER == dev->PCBID ) dev->DACType = _DA_WOLFSON8141; DBG( _DBG_INFO, "* PCB-ID=0x%02x, CCD-ID=0x%02x, DAC-TYPE=0x%02x\n", dev->PCBID, dev->CCDID, dev->DACType ); u12hw_InitiateComponentModel( dev ); u12ccd_InitCCDandDAC( dev, shading ); dev->regs.RD_Model1Control = _CCD_SHIFT_GATE; if( dev->Buttons != 0 ) dev->regs.RD_Model1Control += _BUTTON_MODE; if( dev->shade.intermediate & _ScanMode_Mono ) dev->regs.RD_Model1Control += _SCAN_GRAYTYPE; DBG( _DBG_INFO, "* MotorDrvType = 0x%02x\n", dev->regs.RD_MotorDriverType); DBG( _DBG_INFO, "* Model1Cntrl = 0x%02x\n", dev->regs.RD_Model1Control ); #if 0 u12io_DataToRegister( dev, REG_MOTORDRVTYPE, dev->regs.RD_MotorDriverType); u12io_DataToRegister( dev, REG_WAITSTATEINSERT, 4 ); u12io_DataToRegister( dev, REG_MODEL1CONTROL, dev->regs.RD_Model1Control ); #else c = 0; _SET_REG( rb, c, REG_MOTORDRVTYPE, dev->regs.RD_MotorDriverType); _SET_REG( rb, c, REG_WAITSTATEINSERT, 4 ); _SET_REG( rb, c, REG_MODEL1CONTROL, dev->regs.RD_Model1Control ); u12io_DataToRegs( dev, rb, c ); #endif u12hw_ProgramCCD( dev ); DBG( _DBG_INFO, "u12hw_InitAsic done.\n" ); return SANE_STATUS_GOOD; } /** */ static void u12hw_ControlLampOnOff( U12_Device *dev ) { SANE_Byte lampStatus; dev->warmupNeeded = SANE_TRUE; lampStatus = dev->regs.RD_ScanControl & _SCAN_LAMPS_ON; if ( dev->lastLampStatus != lampStatus ) { DBG( _DBG_INFO, "* Using OTHER Lamp --> warmup needed\n" ); dev->lastLampStatus = lampStatus; u12io_DataToRegister( dev, REG_SCANCONTROL, dev->regs.RD_ScanControl ); return; } dev->warmupNeeded = SANE_FALSE; DBG( _DBG_INFO, "* Using SAME Lamp --> no warmup needed\n" ); } /** set all necessary register contents */ static void u12hw_SetGeneralRegister( U12_Device *dev ) { DBG( _DBG_INFO, "u12hw_SetGeneralRegister()\n" ); dev->scan.motorBackward = SANE_FALSE; dev->scan.refreshState = SANE_FALSE; if( COLOR_BW == dev->DataInf.wPhyDataType ) dev->regs.RD_ScanControl = _SCAN_BITMODE; else { if( dev->DataInf.wPhyDataType <= COLOR_TRUE24 ) dev->regs.RD_ScanControl = _SCAN_BYTEMODE; else dev->regs.RD_ScanControl = _SCAN_12BITMODE; } u12hw_SelectLampSource( dev ); dev->regs.RD_ModelControl = (_LED_CONTROL | _LED_ACTIVITY); if( dev->shade.intermediate & _ScanMode_AverageOut ) dev->regs.RD_ModelControl |= _MODEL_DPI300; else dev->regs.RD_ModelControl |= _MODEL_DPI600; dev->regs.RD_Motor0Control = _MotorOn | _MotorHQuarterStep | _MotorPowerEnable; dev->regs.RD_ScanControl1 = _SCANSTOPONBUFFULL | _MFRC_BY_XSTEP; dev->regs.RD_StepControl = _MOTOR0_SCANSTATE; } /** */ static void u12hw_SetupPreviewCondition( U12_Device *dev ) { int i, c; SANE_Byte rb[100]; DBG( _DBG_INFO, "u12_SetupPreviewCondition()\n" ); u12hw_SetGeneralRegister( dev ); u12io_RegisterToScanner( dev, REG_RESETMTSC ); _DODELAY(250); /* ------- Set the max. read fifo to Asic ------- */ memset( dev->scanStates, 0, _SCANSTATE_BYTES ); if( dev->DataInf.xyAppDpi.x >= 38 ) { /* 38 <= x <= 75 */ for(i = 0; i < _SCANSTATE_BYTES; i++ ) dev->scanStates[i] = 0xad; } else if( dev->DataInf.xyAppDpi.x >= 19 ) { /* 19 <= x <= 30(37) */ u_short *pState = (u_short*)dev->scanStates; for( i = 0; i < (_SCANSTATE_BYTES / 2); i++ ) pState[i] = 0x89ac; } else { /* 16 <= x <= 18 */ u_long *pState = (u_long*)dev->scanStates; for(i = 0; i < (_SCANSTATE_BYTES / 4); i++) pState[i] = 0x888889ac; } dev->regs.RD_BufFullSize = dev->DataInf.dwAppPixelsPerLine * ((dev->DataInf.xyPhyDpi.y * dev->max_y + 299) / 300) + 1; if( dev->regs.RD_BufFullSize > _SIZE_BLUEFIFO ) dev->regs.RD_BufFullSize = _SIZE_BLUEFIFO - dev->DataInf.dwAppPixelsPerLine - 1; dev->scan.dwMaxReadFifo = dev->scan.dwMinReadFifo = dev->DataInf.dwAppPixelsPerLine *2 ; if( dev->scan.dwMinReadFifo < 1024) dev->scan.dwMinReadFifo = dev->scan.dwMaxReadFifo = 1024; dev->scan.dwMaxReadFifo += (dev->DataInf.dwAsicBytesPerPlane / 2); if( dev->DataInf.wPhyDataType > COLOR_256GRAY ) dev->scan.bFifoSelect = REG_BFIFOOFFSET; else dev->scan.bFifoSelect = REG_GFIFOOFFSET; dev->regs.RD_BufFullSize = _SIZE_BLUEFIFO; dev->regs.RD_LineControl = _LOBYTE(dev->shade.wExposure); dev->regs.RD_ExtLineControl = _HIBYTE(dev->shade.wExposure); dev->regs.RD_XStepTime = _LOBYTE(dev->shade.wXStep); dev->regs.RD_ExtXStepTime = _HIBYTE(dev->shade.wXStep); dev->regs.RD_Motor0Control = _FORWARD_MOTOR; dev->regs.RD_StepControl = _MOTOR0_SCANSTATE | _MOTOR_FREERUN; dev->regs.RD_ModeControl = _ModeScan; if( dev->DataInf.wPhyDataType == COLOR_BW ) { dev->regs.RD_ScanControl = _SCAN_BITMODE; } else if( dev->DataInf.wPhyDataType <= COLOR_TRUE24 ) dev->regs.RD_ScanControl = _SCAN_BYTEMODE; else { dev->regs.RD_ScanControl = _SCAN_12BITMODE; } dev->regs.RD_ScanControl |= _SCAN_1ST_AVERAGE; u12hw_SelectLampSource( dev ); dev->regs.RD_MotorTotalSteps = (dev->DataInf.crImage.cy * 4) + (dev->f0_8_16 ? 32 : 16) + (dev->scan.bDiscardAll ? 32 : 0); DBG( _DBG_INFO, "* RD_MotorTotalSteps = 0x%04x\n", dev->regs.RD_MotorTotalSteps); dev->regs.RD_ScanControl1 = (_MTSC_ENABLE | _SCANSTOPONBUFFULL | _MFRC_RUNSCANSTATE | _MFRC_BY_XSTEP); DBG( _DBG_INFO, "* RD_ScanControl1 = 0x%02x\n", dev->regs.RD_ScanControl1); dev->regs.RD_Dpi = dev->DataInf.xyPhyDpi.x; dev->regs.RD_Origin = (u_short)(dev->adj.leftNormal*2+_DATA_ORIGIN_X); dev->regs.RD_Origin += dev->DataInf.crImage.x; if( dev->shade.intermediate & _ScanMode_AverageOut ) dev->regs.RD_Origin >>= 1; if( dev->DataInf.wPhyDataType == COLOR_BW ) dev->regs.RD_Pixels = dev->DataInf.dwAsicBytesPerPlane; else dev->regs.RD_Pixels = dev->DataInf.dwAppPixelsPerLine; /* ------- Wait for scan state stop ------- */ u12io_DataToRegister( dev, REG_MODECONTROL, _ModeIdle ); u12io_DownloadScanStates( dev ); c = 0; _SET_REG( rb, c, REG_LINECONTROL, dev->regs.RD_LineControl ); _SET_REG( rb, c, REG_EXTENDEDLINECONTROL, dev->regs.RD_ExtLineControl); _SET_REG( rb, c, REG_XSTEPTIME, dev->regs.RD_XStepTime ); _SET_REG( rb, c, REG_EXTENDEDXSTEP, dev->regs.RD_ExtXStepTime ); _SET_REG( rb, c, REG_MOTORDRVTYPE, dev->regs.RD_MotorDriverType ); _SET_REG( rb, c, REG_STEPCONTROL, dev->regs.RD_StepControl ); _SET_REG( rb, c, REG_MOTOR0CONTROL, dev->regs.RD_Motor0Control ); _SET_REG( rb, c, REG_MODELCONTROL, dev->regs.RD_ModelControl ); _SET_REG( rb, c, REG_DPILO, (_LOBYTE(dev->regs.RD_Dpi))); _SET_REG( rb, c, REG_DPIHI, (_HIBYTE(dev->regs.RD_Dpi))); _SET_REG( rb, c, REG_SCANPOSLO, (_LOBYTE(dev->regs.RD_Origin))); _SET_REG( rb, c, REG_SCANPOSHI,(_HIBYTE(dev->regs.RD_Origin))); _SET_REG( rb, c, REG_WIDTHPIXELLO,(_LOBYTE(dev->regs.RD_Pixels))); _SET_REG( rb, c, REG_WIDTHPIXELHI,(_HIBYTE(dev->regs.RD_Pixels))); _SET_REG( rb, c, REG_THRESHOLDLO, (_LOBYTE(dev->regs.RD_ThresholdControl))); _SET_REG( rb, c, REG_THRESHOLDHI, (_HIBYTE(dev->regs.RD_ThresholdControl))); _SET_REG( rb, c, REG_MOTORTOTALSTEP0, (_LOBYTE(dev->regs.RD_MotorTotalSteps))); _SET_REG( rb, c, REG_MOTORTOTALSTEP1, (_HIBYTE(dev->regs.RD_MotorTotalSteps))); _SET_REG( rb, c, REG_SCANCONTROL, dev->regs.RD_ScanControl); u12io_DataToRegs( dev, rb, c ); _DODELAY(100); u12io_RegisterToScanner( dev, REG_INITDATAFIFO ); } /** */ static void u12hw_SetupScanningCondition( U12_Device *dev ) { TimerDef timer; u_long channel; int c; SANE_Byte state; SANE_Byte rb[100]; SANE_Byte *pState; DBG( _DBG_INFO, "u12_SetupScanningCondition()\n" ); u12hw_SetGeneralRegister( dev ); u12io_RegisterToScanner( dev, REG_RESETMTSC ); _DODELAY(250); /* ------- Setup MinRead/MaxRead Fifo size ------- */ if( dev->DataInf.wPhyDataType <= COLOR_TRUE24 ) { dev->scan.dwMaxReadFifo = dev->scan.dwMinReadFifo = dev->DataInf.dwAsicBytesPerPlane * 2; } else { dev->scan.dwMaxReadFifo = dev->scan.dwMinReadFifo = dev->DataInf.dwAppPixelsPerLine << 1; } if( dev->scan.dwMinReadFifo < 1024) dev->scan.dwMinReadFifo = dev->scan.dwMaxReadFifo = 1024; dev->scan.dwMaxReadFifo += (dev->DataInf.dwAsicBytesPerPlane / 2); DBG( _DBG_INFO, "* MinReadFifo=%lu, MaxReadFifo=%lu\n", dev->scan.dwMinReadFifo, dev->scan.dwMaxReadFifo ); /* ------- Set the max. read fifo to asic ------- */ if( dev->DataInf.wPhyDataType > COLOR_256GRAY ) { dev->scan.bFifoSelect = REG_BFIFOOFFSET; if( !dev->scan.p48BitBuf.pb ) { long lRed, lGreen; lRed = (_SIZE_REDFIFO - _SIZE_BLUEFIFO) / dev->DataInf.dwAsicBytesPerPlane - dev->scan.bd_rk.wRedKeep; lGreen = (_SIZE_GREENFIFO - _SIZE_BLUEFIFO) / dev->DataInf.dwAsicBytesPerPlane - dev->scan.gd_gk.wGreenKeep; if((lRed < 0) || (lGreen < 0)) { if( lRed < lGreen ) { channel = _RED_FULLSIZE << 16; dev->regs.RD_BufFullSize = _SIZE_REDFIFO; lGreen = lRed; } else { channel = _GREEN_FULLSIZE << 16; dev->regs.RD_BufFullSize = _SIZE_GREENFIFO; } lGreen = (u_long)(-lGreen * dev->DataInf.dwAsicBytesPerPlane); if( dev->DataInf.wPhyDataType > COLOR_TRUE24 ) lGreen >>= 1; dev->scan.dwMinReadFifo += (u_long)lGreen; dev->scan.dwMaxReadFifo += (u_long)lGreen; } else { channel = _BLUE_FULLSIZE << 16; dev->regs.RD_BufFullSize = _SIZE_BLUEFIFO; } } else { channel = _BLUE_FULLSIZE << 16; dev->regs.RD_BufFullSize = _SIZE_BLUEFIFO; } } else { dev->scan.bFifoSelect = REG_GFIFOOFFSET; channel = _GREEN_FULLSIZE << 16; dev->regs.RD_BufFullSize = _SIZE_GRAYFIFO; } dev->regs.RD_BufFullSize -= (dev->DataInf.dwAsicBytesPerPlane << 1); if( dev->DataInf.wPhyDataType > COLOR_TRUE24 ) dev->regs.RD_BufFullSize >>= 1; dev->regs.RD_BufFullSize |= channel; dev->scan.bRefresh = (SANE_Byte)(dev->scan.dwInterval << 1); dev->regs.RD_LineControl = _LOBYTE(dev->shade.wExposure); dev->regs.RD_ExtLineControl = _HIBYTE(dev->shade.wExposure); dev->regs.RD_XStepTime = _LOBYTE(dev->shade.wXStep); dev->regs.RD_ExtXStepTime = _HIBYTE(dev->shade.wXStep); dev->regs.RD_Motor0Control = _FORWARD_MOTOR; dev->regs.RD_StepControl = _MOTOR0_SCANSTATE; dev->regs.RD_ModeControl = _ModeScan/*(_ModeScan | _ModeFifoGSel)*/; DBG( _DBG_INFO, "* bRefresh = %i\n", dev->scan.bRefresh ); if( dev->DataInf.wPhyDataType == COLOR_BW ) { dev->regs.RD_ScanControl = _SCAN_BITMODE; } else if( dev->DataInf.wPhyDataType <= COLOR_TRUE24 ) dev->regs.RD_ScanControl = _SCAN_BYTEMODE; else { dev->regs.RD_ScanControl = _SCAN_12BITMODE; } dev->regs.RD_ScanControl |= _SCAN_1ST_AVERAGE; u12hw_SelectLampSource( dev ); DBG( _DBG_INFO, "* RD_ScanControl = 0x%02x\n", dev->regs.RD_ScanControl ); DBG( _DBG_INFO, "* ImageInfo: x=%u,y=%u,dx=%u,dy=%u\n", dev->DataInf.crImage.x, dev->DataInf.crImage.y, dev->DataInf.crImage.cx, dev->DataInf.crImage.cy ); dev->regs.RD_MotorTotalSteps = (dev->DataInf.crImage.cy * 4) + (dev->f0_8_16 ? 32 : 16) + (dev->scan.bDiscardAll ? 32 : 0); DBG( _DBG_INFO, "* RD_MotorTotalSteps = 0x%04x\n", dev->regs.RD_MotorTotalSteps); dev->regs.RD_ScanControl1 = (_MTSC_ENABLE | _SCANSTOPONBUFFULL | _MFRC_RUNSCANSTATE | _MFRC_BY_XSTEP); DBG( _DBG_INFO, "* RD_ScanControl1 = 0x%02x\n", dev->regs.RD_ScanControl1); dev->regs.RD_Dpi = dev->DataInf.xyPhyDpi.x; if(!(dev->DataInf.dwScanFlag & _SCANDEF_TPA )) { dev->regs.RD_Origin = (u_short)(dev->adj.leftNormal*2+_DATA_ORIGIN_X); } else if( dev->DataInf.dwScanFlag & _SCANDEF_Transparency ) { dev->regs.RD_Origin = (u_short)dev->scan.posBegin; } else { dev->regs.RD_Origin = (u_short)dev->scan.negBegin; } dev->regs.RD_Origin += dev->DataInf.crImage.x; if( dev->shade.intermediate & _ScanMode_AverageOut ) dev->regs.RD_Origin >>= 1; if( dev->DataInf.wPhyDataType == COLOR_BW ) dev->regs.RD_Pixels = (u_short)dev->DataInf.dwAsicBytesPerPlane; else dev->regs.RD_Pixels = (u_short)dev->DataInf.dwAppPixelsPerLine; DBG( _DBG_INFO, "* RD_Origin = %u, RD_Pixels = %u\n", dev->regs.RD_Origin, dev->regs.RD_Pixels ); /* ------- Prepare scan states ------- */ memset( dev->scanStates, 0, _SCANSTATE_BYTES ); memset( dev->bufs.b1.pReadBuf, 0, _NUMBER_OF_SCANSTEPS ); if( dev->DataInf.wPhyDataType <= COLOR_256GRAY ) state = (_SS_MONO | _SS_STEP); else state = (_SS_COLOR | _SS_STEP); for( channel = _NUMBER_OF_SCANSTEPS, pState = dev->bufs.b1.pReadBuf; channel; channel -= dev->scan.dwInterval ) { *pState = state; pState += dev->scan.dwInterval; } for( channel = 0, pState = dev->bufs.b1.pReadBuf; channel < _SCANSTATE_BYTES; channel++) { dev->scanStates[channel] = pState[0] | (pState[1] << 4); pState += 2; } /* ------- Wait for scan state stop ------- */ u12io_StartTimer( &timer, _SECOND * 2 ); u12io_ResetFifoLen(); while(!(u12io_GetScanState( dev ) & _SCANSTATE_STOP) && !u12io_CheckTimer(&timer)); u12io_DownloadScanStates( dev ); c = 0; _SET_REG( rb, c, REG_LINECONTROL, dev->regs.RD_LineControl ); _SET_REG( rb, c, REG_EXTENDEDLINECONTROL, dev->regs.RD_ExtLineControl); _SET_REG( rb, c, REG_XSTEPTIME, dev->regs.RD_XStepTime ); _SET_REG( rb, c, REG_EXTENDEDXSTEP, dev->regs.RD_ExtXStepTime ); _SET_REG( rb, c, REG_MOTORDRVTYPE, dev->regs.RD_MotorDriverType ); _SET_REG( rb, c, REG_STEPCONTROL, dev->regs.RD_StepControl ); _SET_REG( rb, c, REG_MOTOR0CONTROL, dev->regs.RD_Motor0Control ); _SET_REG( rb, c, REG_MODELCONTROL, dev->regs.RD_ModelControl ); _SET_REG( rb, c, REG_DPILO, (_LOBYTE(dev->regs.RD_Dpi))); _SET_REG( rb, c, REG_DPIHI, (_HIBYTE(dev->regs.RD_Dpi))); _SET_REG( rb, c, REG_SCANPOSLO, (_LOBYTE(dev->regs.RD_Origin))); _SET_REG( rb, c, REG_SCANPOSHI,(_HIBYTE(dev->regs.RD_Origin))); _SET_REG( rb, c, REG_WIDTHPIXELLO,(_LOBYTE(dev->regs.RD_Pixels))); _SET_REG( rb, c, REG_WIDTHPIXELHI,(_HIBYTE(dev->regs.RD_Pixels))); _SET_REG( rb, c, REG_THRESHOLDLO, (_LOBYTE(dev->regs.RD_ThresholdControl))); _SET_REG( rb, c, REG_THRESHOLDHI, (_HIBYTE(dev->regs.RD_ThresholdControl))); _SET_REG( rb, c, REG_MOTORTOTALSTEP0, (_LOBYTE(dev->regs.RD_MotorTotalSteps))); _SET_REG( rb, c, REG_MOTORTOTALSTEP1, (_HIBYTE(dev->regs.RD_MotorTotalSteps))); _SET_REG( rb, c, REG_SCANCONTROL, dev->regs.RD_ScanControl); u12io_DataToRegs( dev, rb, c ); _DODELAY(100); u12io_RegisterToScanner( dev, REG_INITDATAFIFO ); } /** */ static SANE_Status u12hw_Memtest( U12_Device *dev ) { SANE_Byte tmp; SANE_Byte buf[_TEST_SIZE]; int i; DBG( _DBG_INFO, "u12hw_Memtest()\n" ); /* prepare buffer */ for( i = 0; i < _TEST_SIZE; i++ ) { buf[i] = (SANE_Byte)((i * 3) & 0xff); } /* avoid switching to Lamp0, when previously scanned in transp./neg mode */ tmp = dev->lastLampStatus + _SCAN_BYTEMODE; u12io_DataToRegister( dev, REG_SCANCONTROL, tmp ); u12io_DataToRegister( dev, REG_MODECONTROL, _ModeMappingMem ); u12io_DataToRegister( dev, REG_MEMORYLO, 0 ); u12io_DataToRegister( dev, REG_MEMORYHI, 0 ); /* fill to buffer */ u12io_MoveDataToScanner( dev, buf, _TEST_SIZE ); u12io_DataToRegister( dev, REG_MODECONTROL, _ModeMappingMem ); u12io_DataToRegister( dev, REG_MEMORYLO, 0 ); u12io_DataToRegister( dev, REG_MEMORYHI, 0 ); u12io_DataToRegister( dev, REG_WIDTHPIXELLO, 0 ); u12io_DataToRegister( dev, REG_WIDTHPIXELHI, 5 ); memset( buf, 0, _TEST_SIZE ); dev->regs.RD_ModeControl = _ModeReadMappingMem; u12io_ReadData( dev, buf, _TEST_SIZE ); for( i = 0; i < _TEST_SIZE; i++ ) { if((SANE_Byte)((i * 3) & 0xff) != buf[i] ) { DBG( _DBG_ERROR, "* Memtest failed at pos %u: %u != %u\n", i+1, buf[i], (SANE_Byte)((i * 3) & 0xff) ); return SANE_STATUS_INVAL; } } DBG( _DBG_INFO, "* Memtest passed.\n" ); return SANE_STATUS_GOOD; } /** check if ASIC can be accessed, if the version is supported and the memory * is also accessible... */ static SANE_Status u12hw_CheckDevice( U12_Device *dev ) { #ifndef _FAKE_DEVICE SANE_Byte tmp; SANE_Byte rb[8]; int c; #if 1 if( !u12io_IsConnected( dev )) { if( !u12io_OpenScanPath( dev )) return SANE_STATUS_IO_ERROR; } #else /* u12io_IsConnected( dev ); */ if( !u12io_OpenScanPath( dev )) return SANE_STATUS_IO_ERROR; #endif /* some setup stuff... */ tmp = u12io_GetExtendedStatus( dev ); DBG( _DBG_INFO, "* REG_STATUS2 = 0x%02x\n", tmp ); if( tmp & _REFLECTIONLAMP_ON ) { DBG( _DBG_INFO, "* Normal lamp is ON\n" ); dev->lastLampStatus = _SCAN_NORMALLAMP_ON; } else if( tmp & _TPALAMP_ON ) { dev->lastLampStatus = _SCAN_TPALAMP_ON; DBG( _DBG_INFO, "* TPA lamp is ON\n" ); } c = 0; _SET_REG( rb, c, REG_PLLPREDIV, 1 ); _SET_REG( rb, c, REG_PLLMAINDIV, 0x20 ); _SET_REG( rb, c, REG_PLLPOSTDIV, 2 ); _SET_REG( rb, c, REG_CLOCKSELECTOR, 2 ); u12io_DataToRegs( dev, rb, c ); #if 0 return u12hw_Memtest( dev ); #else if( !dev->initialized ) return u12hw_Memtest( dev ); else return SANE_STATUS_GOOD; #endif #else _VAR_NOT_USED( dev ); return SANE_STATUS_GOOD; #endif } /* prototypes... */ static void u12motor_PositionModuleToHome( U12_Device *); static void u12motor_ToHomePosition( U12_Device *, SANE_Bool ); /** */ static void u12hw_CancelSequence( U12_Device *dev ) { int c = 0; SANE_Byte rb[6]; DBG( _DBG_INFO, "u12hw_CancelSequence()\n" ); u12motor_PositionModuleToHome( dev ); u12motor_ToHomePosition( dev, SANE_TRUE ); u12io_DataToRegister( dev, REG_MOTOR0CONTROL, 0 ); u12io_DataToRegister( dev, REG_MODELCONTROL, 0x1a ); u12hw_PutToIdleMode( dev ); if( strcmp( dev->usbId, "0x0458-0x2004" )) u12io_SoftwareReset( dev ); u12motor_PositionModuleToHome( dev ); u12io_DataToRegister( dev, REG_SCANCONTROL, 0x05 ); u12io_DataToRegister( dev, REG_MODELCONTROL, 0x1f ); u12hw_PutToIdleMode( dev ); u12io_DataToRegister( dev, REG_MODELCONTROL, 0x00 ); u12io_DataToRegister( dev, REG_ADCADDR, 0x01 ); u12io_DataToRegister( dev, REG_ADCDATA, 0x00 ); u12io_DataToRegister( dev, REG_ADCSERIALOUT, 0x00 ); _SET_REG( rb, c, REG_MODECONTROL, 0x19 ); _SET_REG( rb, c, REG_STEPCONTROL, 0xff ); _SET_REG( rb, c, REG_MOTOR0CONTROL, 0 ); u12io_DataToRegs( dev, rb, c ); u12io_CloseScanPath( dev ); } /** */ static SANE_Status u12hw_WarmupLamp( U12_Device *dev ) { TimerDef timer; DBG( _DBG_INFO, "u12hw_WarmupLamp()\n" ); if( dev->warmupNeeded ) { DBG( _DBG_INFO, "* warming up...\n" ); u12io_StartTimer( &timer, _SECOND * dev->adj.warmup ); while( !u12io_CheckTimer( &timer )) { if( u12io_IsEscPressed()) { DBG( _DBG_INFO, "* CANCEL detected!\n" ); return SANE_STATUS_CANCELLED; } } } else { DBG( _DBG_INFO, "* skipped\n" ); } return SANE_STATUS_GOOD; } /* FIXME: replace!!! */ static U12_Device *dev_xxx = NULL; /** ISR to switch lamp off after time has elapsed */ static void usb_LampTimerIrq( int sig ) { SANE_Byte tmp; int handle = -1; if( NULL == dev_xxx ) return; _VAR_NOT_USED( sig ); DBG( _DBG_INFO, "*** LAMP OFF!!! ***\n" ); if( -1 == dev_xxx->fd ) { if( SANE_STATUS_GOOD == sanei_usb_open(dev_xxx->sane.name, &handle)) { dev_xxx->fd = handle; } } if( -1 != dev_xxx->fd ) { if( !u12io_IsConnected( dev_xxx )) { if( u12io_OpenScanPath( dev_xxx )) { /* some setup stuff... */ tmp = u12io_GetExtendedStatus( dev_xxx ); if( tmp & _REFLECTIONLAMP_ON ) { DBG( _DBG_INFO, "* Normal lamp is ON\n" ); } else if( tmp & _TPALAMP_ON ) { DBG( _DBG_INFO, "* TPA lamp is ON\n" ); } u12io_DataToRegister( dev_xxx, REG_SCANCONTROL, 0 ); u12io_CloseScanPath( dev_xxx ); } } } if( -1 != handle ) { dev_xxx->fd = -1; sanei_usb_close( handle ); } } /** */ static void u12hw_StartLampTimer( U12_Device *dev ) { sigset_t block, pause_mask; struct sigaction s; #ifdef HAVE_SETITIMER struct itimerval interval; #endif /* block SIGALRM */ sigemptyset( &block ); sigaddset ( &block, SIGALRM ); sigprocmask( SIG_BLOCK, &block, &pause_mask ); /* setup handler */ sigemptyset( &s.sa_mask ); sigaddset ( &s.sa_mask, SIGALRM ); s.sa_flags = 0; s.sa_handler = usb_LampTimerIrq; if( sigaction( SIGALRM, &s, NULL ) < 0 ) DBG( _DBG_ERROR, "Can't setup timer-irq handler\n" ); sigprocmask( SIG_UNBLOCK, &block, &pause_mask ); #ifdef HAVE_SETITIMER /* * define a one-shot timer */ interval.it_value.tv_usec = 0; interval.it_value.tv_sec = dev->adj.lampOff; interval.it_interval.tv_usec = 0; interval.it_interval.tv_sec = 0; if( 0 != dev->adj.lampOff ) { dev_xxx = dev; setitimer( ITIMER_REAL, &interval, &dev->saveSettings ); DBG( _DBG_INFO, "Lamp-Timer started (using ITIMER)\n" ); } #else if( 0 != dev->adj.lampOff ) { dev_xxx = dev; alarm( dev->adj.lampOff ); DBG( _DBG_INFO, "Lamp-Timer started (using ALARM)\n" ); } #endif } /** */ static void u12hw_StopLampTimer( U12_Device *dev ) { sigset_t block, pause_mask; /* block SIGALRM */ sigemptyset( &block ); sigaddset ( &block, SIGALRM ); sigprocmask( SIG_BLOCK, &block, &pause_mask ); dev_xxx = NULL; #ifdef HAVE_SETITIMER if( 0 != dev->adj.lampOff ) setitimer( ITIMER_REAL, &dev->saveSettings, NULL ); #else _VAR_NOT_USED( dev ); alarm( 0 ); #endif DBG( _DBG_INFO, "Lamp-Timer stopped\n" ); } /* END U12-HW.C .............................................................*/ sane-backends-1.0.29/backend/sm3840_lib.h0000666000000000000000000001246113615534521014531 00000000000000/* sane - Scanner Access Now Easy. ScanMaker 3840 Backend Copyright (C) 2005-7 Earle F. Philhower, III earle@ziplabel.com - http://www.ziplabel.com 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ #include #include #ifndef BACKENDNAME #include #include #ifndef DEFINED_USB_HANDLE #define DEFINED_USB_HANDLE typedef usb_dev_handle *p_usb_dev_handle; #endif static p_usb_dev_handle find_device (unsigned int idVendor, unsigned int idProduct); #else #include "../include/sane/sanei_usb.h" #ifndef USBWRAPPER #define USBWRAPPER typedef SANE_Int p_usb_dev_handle; #define usb_control_msg my_usb_control_msg #define usb_bulk_read my_usb_bulk_read #define usb_bulk_write my_usb_bulk_write static int my_usb_bulk_write (p_usb_dev_handle dev, int ep, unsigned char *bytes, int size, int timeout); static int my_usb_bulk_read (p_usb_dev_handle dev, int ep, unsigned char *bytes, int size, int timeout); static int my_usb_control_msg (p_usb_dev_handle dev, int requesttype, int request, int value, int index, unsigned char *bytes, int size, int timeout); #endif /* USBWRAPPER */ #endif #include "sm3840_params.h" static void idle_ab (p_usb_dev_handle udev); static void write_regs (p_usb_dev_handle udev, int regs, unsigned char reg1, unsigned char val1, ... /*unsigned char reg, unsigned char val, ... */ ); static int write_vctl (p_usb_dev_handle udev, int request, int value, int index, unsigned char byte); static int read_vctl (p_usb_dev_handle udev, int request, int value, int index, unsigned char *byte); #ifndef BACKENDNAME static void record (p_usb_dev_handle udev, char *fname, int bytes); static void record_image (p_usb_dev_handle udev, char *fname, int dpi, int scanpix, int scanlines, int gray, char *head, int bpp16); static void check_buttons (p_usb_dev_handle udev, int *scan, int *print, int *mail); static void record_head (p_usb_dev_handle udev, char *fname, int bytes, char *header); #endif static void poll1 (p_usb_dev_handle udev); static void poll2 (p_usb_dev_handle udev); static void reset_scanner (p_usb_dev_handle udev); static void set_lightmap_white (unsigned short *map, int dpi, int color); static void calc_lightmap (unsigned short *buff, unsigned short *storage, int index, int dpi, double gain, int offset); static void select_pixels (unsigned short *map, int dpi, int start, int end); static void record_mem (p_usb_dev_handle udev, unsigned char **dest, int bytes); static void set_lamp_timer (p_usb_dev_handle udev, int timeout_in_mins); static void set_gain_black (p_usb_dev_handle udev, int r_gain, int g_gain, int b_gain, int r_black, int g_black, int b_black); static void idle_ab (p_usb_dev_handle udev); static void write_regs (p_usb_dev_handle udev, int regs, unsigned char reg1, unsigned char val1, ... /*unsigned char reg, unsigned char val, ... */ ); static int write_vctl (p_usb_dev_handle udev, int request, int value, int index, unsigned char byte); static int read_vctl (p_usb_dev_handle udev, int request, int value, int index, unsigned char *byte); static void download_lut8 (p_usb_dev_handle udev, int dpi, int incolor); static void record_line (int reset, p_usb_dev_handle udev, unsigned char *storeline, int dpi, int scanpix, int gray, int bpp16, int *save_i, unsigned char **save_scan_line, unsigned char **save_dpi1200_remap, unsigned char **save_color_remap); static void prepare_params (SM3840_Params * params); static void fix_endian_short (unsigned short *data, int count); #define rd_timeout 10000 #define wr_timeout 10000 sane-backends-1.0.29/backend/plustek-pp_misc.c0000666000000000000000000005072513615534521016064 00000000000000/* @file plustek-pp_misc.c * @brief here we have some helpful functions * * based on sources acquired from Plustek Inc. * Copyright (C) 1998 Plustek Inc. * Copyright (C) 2000-2013 Gerhard Jaeger * also based on the work done by Rick Bronson * * History: * - 0.30 - initial version * - 0.31 - no changes * - 0.32 - moved the parport functions inside this module * - now using the information, the parport-driver provides * - for selecting the port-mode this driver uses * - 0.33 - added code to use faster portmodes * - 0.34 - added sample code for changing from ECP to PS/2 bidi mode * - 0.35 - added Kevins' changes (new function miscSetFastMode()) * - moved function initPageSettings() to module models.c * - 0.36 - added random generator * - added additional debug messages * - changed prototype of MiscInitPorts() * - added miscPreemptionCallback() * - 0.37 - changed inb_p/outb_p to macro calls (kernel-mode) * - added MiscGetModelName() * - added miscShowPortModes() * - 0.38 - fixed a small bug in MiscGetModelName() * - 0.39 - added forceMode support * - 0.40 - no changes * - 0.41 - merged Kevins' patch to make EPP(ECP) work * - 0.42 - changed get_fast_time to _GET_TIME * - changed include names * - 0.43 - added LINUX_26 stuff * - minor fixes * - removed floating point stuff * - 0.44 - fix format string issues, as Long types default to int32_t * now * . *
* 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; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * As a special exception, the authors of SANE give permission for * additional uses of the libraries contained in this release of SANE. * * The exception is that, if you link a SANE library with other files * to produce an executable, this does not by itself cause the * resulting executable to be covered by the GNU General Public * License. Your use of that executable is in no way restricted on * account of linking the SANE library code into it. * * This exception does not, however, invalidate any other reasons why * the executable file might be covered by the GNU General Public * License. * * If you submit changes to SANE to the maintainers to be included in * a subsequent release, you agree by submitting the changes that * those changes may be distributed with this exception intact. * * If you write modifications of your own for SANE, it is your choice * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. *
*/ #include "plustek-pp_scan.h" /*************************** some definitions ********************************/ #ifndef __KERNEL__ # define PPA_PROBE_SPP 0x0001 # define PPA_PROBE_PS2 0x0002 # define PPA_PROBE_ECR 0x0010 # define PPA_PROBE_EPP17 0x0100 # define PPA_PROBE_EPP19 0x0200 #else /* the parport driver in Kernel 2.4 has changed. It does report the * possible modes in a different, more general way. As long, as * we do not use the parport-module change mode facility, I assume * the following correlations */ #if defined LINUX_24 || defined LINUX_26 # define PARPORT_MODE_PCPS2 PARPORT_MODE_TRISTATE # define PARPORT_MODE_PCEPP PARPORT_MODE_EPP # define PARPORT_MODE_PCECPPS2 PARPORT_MODE_TRISTATE # define PARPORT_MODE_PCECPEPP PARPORT_MODE_EPP # define PARPORT_MODE_PCECR PARPORT_MODE_ECP #endif #endif #define _PP_A 16807 /**< multiplier */ #define _PP_M 2147483647L /**< 2**31 - 1 */ /*************************** some local vars *********************************/ static int port_feature = 0; static long randomnum = 1; #ifdef __KERNEL__ static int portIsClaimed[_MAX_PTDEVS] = { [0 ... (_MAX_PTDEVS-1)] = 0 }; MODELSTR; /**< a static char array (see plustek-pp.h) */ #else static int portIsClaimed[_MAX_PTDEVS] = { 0, 0, 0, 0 }; #endif /*************************** local functions *********************************/ #ifdef __KERNEL__ #ifdef LINUX_26 static pScanData __ps = NULL; static int __pa = -1; /** callback from parport driver */ static void misc_attach(struct parport *port) { DBG( DBG_LOW, "misc_attach\n" ); __ps->pp = NULL; if( port->base == (unsigned long)__pa ) { DBG( DBG_LOW, "Requested port (0x%02x) found\n", __pa ); DBG( DBG_LOW, "Port mode reported: (0x%04x)\n", port->modes ); __ps->pp = port; } } static void misc_detach( struct parport *port ) { DBG( DBG_LOW, "misc_detach\n" ); } static struct parport_driver pt_drv = { .name = "pt_drv", .attach = misc_attach, .detach = misc_detach, }; #endif /** display the avaialable port-modes */ #ifdef DEBUG static void miscShowPortModes( int modes ) { DBG( DBG_LOW, "parport-modi:" ); if( modes & PARPORT_MODE_PCSPP ) DBG( DBG_LOW, " SPP" ); if( modes & PARPORT_MODE_PCPS2 ) DBG( DBG_LOW, " PS/2" ); if( modes & PARPORT_MODE_PCEPP ) DBG( DBG_LOW, " EPP" ); if( modes & PARPORT_MODE_PCECR ) DBG( DBG_LOW, " ECP" ); if( modes & PARPORT_MODE_PCECPEPP ) DBG( DBG_LOW, " EPP(ECP)" ); if( modes & PARPORT_MODE_PCECPPS2 ) DBG( DBG_LOW, " PS/2(ECP)" ); DBG( DBG_LOW, "\n" ); } #endif /** probe the parallel port */ static int initPortProbe( pScanData ps ) { int retv = 0; /* clear the controls */ ps->IO.lastPortMode = 0xFFFF; if( NULL != ps->pardev ) retv = ps->pardev->port->modes; return retv; } /** will be called by the parport module when we already have access, but * another module wants access to the port... */ static int miscPreemptionCallback( pVoid data ) { pScanData ps = (pScanData)data; if( NULL != ps ) { /* never release during scanning */ if( ps->DataInf.dwScanFlag & _SCANNER_SCANNING ) { DBG( DBG_LOW, "no way!!!\n" ); return 1; } } /* let the port go...*/ return 0; } /** depending on the reported possible port modes, we try to set a faster mode * than SPP */ static int miscSetFastMode( pScanData ps ) { UChar a, b; /* * when previously found the EPP mode, break right here */ if (( _PORT_EPP == ps->IO.portMode ) && (!(port_feature & PARPORT_MODE_PCECR))) return _OK; /* CHECK REMOVE: from here we should have SPP (Paranoia Code !) */ if (( _PORT_SPP != ps->IO.portMode ) && (!(port_feature & PARPORT_MODE_PCECR))) return _OK; DBG(DBG_LOW, "Trying faster mode...\n" ); /* * ECP mode usually has sub-modes of EPP and/or PS2. * First we try to set EPP */ if((port_feature & PARPORT_MODE_PCECR) && (port_feature & PARPORT_MODE_PCECPEPP)){ DBG(DBG_LOW, "Attempting to set EPP from ECP mode.\n" ); a = _INB_ECTL(ps); /* get current ECR */ ps->IO.lastPortMode = a; /* save it for restoring later */ a = (a & 0x1F) | 0x80; /* set to EPP */ _OUTB_ECTL(ps, a); /* write it back */ _DO_UDELAY(1); /* * It is probably unnecessary to * do this check but it makes me feel better */ b = _INB_ECTL(ps); /* check to see if port set */ if( a == b ) { DBG( DBG_LOW, "Port is set to (ECP) EPP mode.\n" ); ps->IO.portMode = _PORT_EPP; return _OK; } else { DBG( DBG_LOW, "Port could not be set to (ECP) EPP mode. " "Using SPP mode.\n" ); _OUTB_ECTL(ps,(Byte)ps->IO.lastPortMode); /* restore */ _DO_UDELAY(1); ps->IO.portMode = _PORT_SPP; /* go ahead and try with other settings...*/ } } /* If port cannot be set to EPP, try PS2 */ if((port_feature & PARPORT_MODE_PCECR) && (port_feature & PARPORT_MODE_PCECPPS2)) { DBG(DBG_LOW, "Attempting to set PS2 from ECPPS2 mode.\n" ); a = _INB_ECTL(ps); /* get current ECR */ ps->IO.lastPortMode = a; /* save it for restoring later */ /* set to Fast Centronics/bi-directional/PS2 */ a = (a & 0x1F) | 0x20; _OUTB_ECTL(ps,a); /* write it back */ _DO_UDELAY(1); /* * It is probably unnecessary to do this check * but it makes me feel better */ b = _INB_ECTL(ps); /* check to see if port set */ if (a == b) { DBG(DBG_LOW, "Port is set to (ECP) PS2 bidirectional mode.\n"); ps->IO.portMode = _PORT_BIDI; return _OK; } else { DBG(DBG_LOW, "Port could not be set to (ECP) PS2 mode. " "Using SPP mode.\n"); a = ps->IO.lastPortMode & 0x1F; _OUTB_ECTL(ps, a); /* set ECP ctrl to SPP */ _DO_UDELAY(1); ps->IO.portMode = _PORT_SPP; /* next mode, last attempt... */ } } /* * Some BIOS/cards have only a Bi-directional/PS2 mode (no EPP). * Make one last attemp to set to PS2 mode. */ if ( port_feature & PARPORT_MODE_PCPS2 ){ DBG(DBG_LOW, "Attempting to set PS2 mode.\n" ); a = _INB_CTRL(ps); /* get current setting of control register*/ ps->IO.lastPortMode = a; /* save it for restoring later */ a = a | 0x20; /* set bit 5 of control reg */ _OUTB_CTRL(ps,a); /* set to Fast Centronics/bi-directional/PS2 */ _DO_UDELAY(1); a = 0; _OUTB_DATA(ps,0x55); _DO_UDELAY(1); if ((inb(ps->IO.portBase)) != 0x55) /* read data */ a++; _OUTB_DATA(ps,0xAA); _DO_UDELAY(1); if (_INB_DATA(ps) != 0xAA) /* read data */ a++; if( 2 == a ) { DBG(DBG_LOW, "Port is set to PS2 bidirectional mode.\n"); ps->IO.portMode = _PORT_BIDI; return _OK; } else { DBG(DBG_LOW, "Port could not be set to PS2 mode. " "Using SPP mode.\n"); _OUTB_CTRL(ps,(Byte)ps->IO.lastPortMode); /* restore */ _DO_UDELAY(1); ps->IO.portMode = _PORT_SPP; } } /* reaching this point, we're back in SPP mode and there's no need * to restore at shutdown... */ ps->IO.lastPortMode = 0xFFFF; return _OK; } /** check the state of the par-port and switch to EPP-mode if possible */ static int miscSetPortMode( pScanData ps ) { /* try to detect the port settings, SPP seems to work in any case ! */ port_feature = initPortProbe( ps ); #ifdef DEBUG miscShowPortModes( port_feature ); #endif switch( ps->IO.forceMode ) { case 1: DBG( DBG_LOW, "Use of SPP-mode enforced\n" ); ps->IO.portMode = _PORT_SPP; return _OK; break; case 2: DBG( DBG_LOW, "Use of EPP-mode enforced\n" ); ps->IO.portMode = _PORT_EPP; return _OK; break; default: break; } if( !(port_feature & PARPORT_MODE_PCEPP)) { if( !(port_feature & PARPORT_MODE_PCSPP )) { _PRINT("\nThis Port supports not the SPP- or EPP-Mode\n" ); _PRINT("Please activate SPP-Mode, EPP-Mode or\nEPP + ECP-Mode!\n"); return _E_NOSUPP; } else { DBG(DBG_LOW, "Using SPP-mode\n" ); ps->IO.portMode = _PORT_SPP; } } else { DBG(DBG_LOW, "Using EPP-mode\n" ); ps->IO.portMode = _PORT_EPP; } /* else try to set to a faster mode than SPP */ return miscSetFastMode( ps ); } #endif /** miscNextLongRand() -- generate 2**31-2 random numbers ** ** public domain by Ray Gardner ** ** based on "Random Number Generators: Good Ones Are Hard to Find", ** S.K. Park and K.W. Miller, Communications of the ACM 31:10 (Oct 1988), ** and "Two Fast Implementations of the 'Minimal Standard' Random ** Number Generator", David G. Carta, Comm. ACM 33, 1 (Jan 1990), p. 87-88 ** ** linear congruential generator f(z) = 16807 z mod (2 ** 31 - 1) ** ** uses L. Schrage's method to avoid overflow problems */ static Long miscNextLongRand( Long seed ) { ULong lo, hi; lo = _PP_A * (Long)(seed & 0xFFFF); hi = _PP_A * (Long)((ULong)seed >> 16); lo += (hi & 0x7FFF) << 16; if (lo > _PP_M) { lo &= _PP_M; ++lo; } lo += hi >> 15; if (lo > _PP_M) { lo &= _PP_M; ++lo; } return (Long)lo; } /** initialize the random number generator */ static void miscSeedLongRand( long seed ) { randomnum = seed ? (seed & _PP_M) : 1; /* nonzero seed */ } /************************ exported functions *********************************/ /** allocate and initialize some memory for the scanner structure */ _LOC pScanData MiscAllocAndInitStruct( void ) { pScanData ps; ps = (pScanData)_KALLOC(sizeof(ScanData), GFP_KERNEL); if( NULL != ps ) { MiscReinitStruct( ps ); } DBG( DBG_HIGH, "ScanData = 0x%08lx\n", (unsigned long)ps ); return ps; } /** re-initialize the memory for the scanner structure */ _LOC int MiscReinitStruct( pScanData ps ) { if( NULL == ps ) return _E_NULLPTR; memset( ps, 0, sizeof(ScanData)); /* first init all constant stuff in ScanData */ ps->bCurrentSpeed = 1; ps->pbMapRed = ps->a_bMapTable; ps->pbMapGreen = &ps->a_bMapTable[256]; ps->pbMapBlue = &ps->a_bMapTable[512]; ps->sCaps.wIOBase = _NO_BASE; /* use memory address to seed the generator */ miscSeedLongRand((long)ps); DBG( DBG_HIGH, "Init settings done\n" ); return _OK; } /** in USER-Mode: probe the specified port and try to get the port-mode * in KERNEL-Mode: only use the modes, the driver returns */ _LOC int MiscInitPorts( pScanData ps, int port ) { #ifdef __KERNEL__ int status; if( NULL == ps ) return _E_NULLPTR; /* * Get access to the ports */ ps->IO.portBase = (UShort)port; status = miscSetPortMode(ps); if( _OK != status ) { ps->sCaps.wIOBase = _NO_BASE; ps->IO.portBase = _NO_BASE; return status; } /* * the port settings */ ps->IO.pbSppDataPort = (UShort)port; ps->IO.pbStatusPort = (UShort)port+1; ps->IO.pbControlPort = (UShort)port+2; ps->IO.pbEppDataPort = (UShort)port+4; #else int mode, mts; if( NULL == ps ) return _E_NULLPTR; if( SANE_STATUS_GOOD != sanei_pp_getmodes( ps->pardev, &mode )) { DBG( DBG_HIGH, "Cannot get port mode!\n" ); return _E_NO_PORT; } ps->IO.portMode = _PORT_NONE; mts = -1; if( mode & SANEI_PP_MODE_SPP ) { DBG( DBG_LOW, "Setting SPP-mode\n" ); ps->IO.portMode = _PORT_SPP; mts = SANEI_PP_MODE_SPP; } if( mode & SANEI_PP_MODE_BIDI ) { DBG( DBG_LOW, "Setting PS/2-mode\n" ); ps->IO.portMode = _PORT_BIDI; mts = SANEI_PP_MODE_BIDI; } if( mode & SANEI_PP_MODE_EPP ) { DBG( DBG_LOW, "Setting EPP-mode\n" ); ps->IO.portMode = _PORT_EPP; mts = SANEI_PP_MODE_EPP; } if( mode & SANEI_PP_MODE_ECP ) { DBG( DBG_HIGH, "ECP detected --> not supported\n" ); } if( sanei_pp_uses_directio()) { DBG( DBG_LOW, "We're using direct I/O\n" ); } else { DBG( DBG_LOW, "We're using libIEEE1284 I/O\n" ); } if( ps->IO.portMode == _PORT_NONE ) { DBG( DBG_HIGH, "None of the portmodes is supported.\n" ); return _E_NOSUPP; } sanei_pp_setmode( ps->pardev, mts ); _VAR_NOT_USED( port ); #endif return _OK; } /** Function to restore the port */ _LOC void MiscRestorePort( pScanData ps ) { #ifdef __KERNEL__ if( 0 == ps->IO.pbSppDataPort ) return; #endif DBG(DBG_LOW,"MiscRestorePort()\n"); /* don't restore if not necessary */ if( 0xFFFF == ps->IO.lastPortMode ) { DBG(DBG_LOW,"- no need to restore portmode !\n"); return; } /*Restore Port-Mode*/ #ifdef __KERNEL__ if( port_feature & PARPORT_MODE_PCECR ){ _OUTB_ECTL( ps, (Byte)ps->IO.lastPortMode ); _DO_UDELAY(1); } else { _OUTB_CTRL( ps, (Byte)ps->IO.lastPortMode ); _DO_UDELAY(1); } #else if( port_feature & PPA_PROBE_ECR ){ _OUTB_ECTL(ps,ps->IO.lastPortMode); } #endif } /** Initializes a timer. * @param timer - pointer to the timer to start * @param us - timeout value in micro-seconds */ _LOC void MiscStartTimer( TimerDef *timer , unsigned long us) { struct timeval start_time; #ifdef __KERNEL__ _GET_TIME( &start_time ); #else gettimeofday(&start_time, NULL); #endif *timer = (TimerDef)start_time.tv_sec * 1000000 + (TimerDef)start_time.tv_usec + us; } /** Checks if a timer has been expired or not. In Kernel-mode, the scheduler * will also be triggered, if the timer has not been expired. * @param timer - pointer to the timer to check * @return Function returns _E_TIMEOUT when the timer has been expired, * otherwise _OK; */ _LOC int MiscCheckTimer( TimerDef *timer ) { struct timeval current_time; #ifdef __KERNEL__ _GET_TIME( ¤t_time ); #else gettimeofday(¤t_time, NULL); #endif if ((TimerDef)current_time.tv_sec * 1000000 + (TimerDef)current_time.tv_usec > *timer) { return _E_TIMEOUT; } else { #ifdef __KERNEL__ schedule(); /*#else sched_yield(); */ #endif return _OK; } } /** Checks the function pointers * @param ps - pointer to the scanner data structure. * @return Function returns _TRUE if everything is okay and _FALSE if a NULL * ptr has been detected. */ #ifdef DEBUG _LOC Bool MiscAllPointersSet( pScanData ps ) { int i; unsigned long *ptr; for( ptr = (unsigned long *)&ps->OpenScanPath, i = 1; ptr <= (unsigned long *)&ps->ReadOneImageLine; ptr++, i++ ) { if( NULL == (pVoid)*ptr ) { DBG( DBG_HIGH, "Function pointer not set (pos = %d) !\n", i ); return _FALSE; } } return _TRUE; } #endif /** registers this driver to use port "portAddr" (KERNEL-Mode only) * @param ps - pointer to the scanner data structure. * @param portAddr - */ _LOC int MiscRegisterPort( pScanData ps, int portAddr ) { #ifndef __KERNEL__ DBG( DBG_LOW, "Assigning port handle %i\n", portAddr ); ps->pardev = portAddr; #else #ifdef LINUX_26 __ps = ps; __pa = portAddr; DBG( DBG_LOW, "Requested port at 0x%02x\n", portAddr ); if( parport_register_driver(&pt_drv)) { /* Failed; nothing we can do. */ return _E_REGISTER; } #else struct parport *pp = NULL; DBG( DBG_LOW, "Requested port at 0x%02x\n", portAddr ); pp = parport_enumerate(); ps->pardev = NULL; if( NULL == pp ) { return _E_PORTSEARCH; } /* go through the list */ for( ps->pp = NULL; NULL != pp; ) { if( pp->base == (unsigned long)portAddr ) { DBG( DBG_LOW, "Requested port (0x%02x) found\n", portAddr ); DBG( DBG_LOW, "Port mode reported: (0x%04x)\n", pp->modes ); ps->pp = pp; break; } pp = pp->next; } #endif if( NULL == ps->pp ) { printk("PORT not found!!!\n"); return _E_NO_PORT; } /* * register this device */ ps->pardev = parport_register_device( ps->pp, "Plustek Driver", miscPreemptionCallback, NULL, NULL, 0, (pVoid)ps ); if( NULL == ps->pardev ) { return _E_REGISTER; } DBG( DBG_LOW, "Port for device %u registered\n", ps->devno ); #endif portIsClaimed[ps->devno] = 0; return _OK; } /** unregisters the port from driver */ _LOC void MiscUnregisterPort( pScanData ps ) { #ifdef __KERNEL__ if( NULL != ps->pardev ) { DBG( DBG_LOW, "Port unregistered\n" ); parport_unregister_device( ps->pardev ); } #ifdef LINUX_26 parport_unregister_driver( &pt_drv ); #endif #else sanei_pp_close( ps->pardev ); #endif } /** Try to claim the port * @param ps - pointer to the scanner data structure. * @return Function returns _OK on success, otherwise _E_BUSY. */ _LOC int MiscClaimPort( pScanData ps ) { if( 0 == portIsClaimed[ps->devno] ) { DBG( DBG_HIGH, "Try to claim the parport\n" ); #ifdef __KERNEL__ if( 0 != parport_claim( ps->pardev )) { #else if( SANE_STATUS_GOOD != sanei_pp_claim( ps->pardev )) { #endif return _E_BUSY; } } portIsClaimed[ps->devno]++; return _OK; } /** Release previously claimed port * @param ps - pointer to the scanner data structure */ _LOC void MiscReleasePort( pScanData ps ) { if( portIsClaimed[ps->devno] > 0 ) { portIsClaimed[ps->devno]--; if( 0 == portIsClaimed[ps->devno] ) { DBG( DBG_HIGH, "Releasing parport\n" ); #ifdef __KERNEL__ parport_release( ps->pardev ); #else sanei_pp_release( ps->pardev ); #endif } } } /** Get random number * @return a random number. */ _LOC Long MiscLongRand( void ) { randomnum = miscNextLongRand( randomnum ); return randomnum; } /** According to the id, the function returns a pointer to the model name * @param id - internal id of the various scanner models. * @return a pointer to the model-string. */ _LOC const char *MiscGetModelName( UShort id ) { DBG( DBG_HIGH, "MiscGetModelName - id = %i\n", id ); if( MODEL_OP_PT12 < id ) return ModelStr[0]; return ModelStr[id]; } /* END PLUSTEK-PP_MISC.C ....................................................*/ sane-backends-1.0.29/backend/microtek.h0000666000000000000000000003127713615534521014570 00000000000000/*************************************************************************** * SANE - Scanner Access Now Easy. microtek.h This file Copyright 2002 Matthew Marjanovic 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. *************************************************************************** This file implements a SANE backend for Microtek scanners. (feedback to: mtek-bugs@mir.com) (for latest info: http://www.mir.com/mtek/) ***************************************************************************/ #ifndef microtek_h #define microtek_h #include /*******************************************************************/ /***** enumeration of Option Descriptors *****/ /*******************************************************************/ enum Mtek_Option { OPT_NUM_OPTS = 0, OPT_MODE_GROUP, OPT_MODE, /* -a,b,c,g */ OPT_HALFTONE_PATTERN, /* -H */ OPT_RESOLUTION, /* -r */ OPT_EXP_RES, OPT_NEGATIVE, /* -n */ OPT_SPEED, /* -v */ OPT_SOURCE, /* -t */ OPT_PREVIEW, OPT_CALIB_ONCE, OPT_GEOMETRY_GROUP, /* -f .... */ OPT_TL_X, /* top-left x */ OPT_TL_Y, /* top-left y */ OPT_BR_X, /* bottom-right x */ OPT_BR_Y, /* bottom-right y */ OPT_ENHANCEMENT_GROUP, OPT_EXPOSURE, OPT_BRIGHTNESS, /* -d */ OPT_CONTRAST, /* -k */ OPT_HIGHLIGHT, /* -l */ OPT_SHADOW, /* -s */ OPT_MIDTONE, /* -m */ OPT_GAMMA_GROUP, OPT_CUSTOM_GAMMA, OPT_ANALOG_GAMMA, OPT_ANALOG_GAMMA_R, OPT_ANALOG_GAMMA_G, OPT_ANALOG_GAMMA_B, /* "The gamma vectors MUST appear in the order gray, red, green, blue." */ OPT_GAMMA_VECTOR, OPT_GAMMA_VECTOR_R, OPT_GAMMA_VECTOR_G, OPT_GAMMA_VECTOR_B, OPT_GAMMA_BIND, NUM_OPTIONS, OPT_BACKTRACK, /* -B */ /* must come last: */ RNUM_OPTIONS }; /*******************************************************************/ /***** scanner hardware information (as discovered by INQUIRY) *****/ /*******************************************************************/ typedef struct Microtek_Info { char vendor_id[9]; char model_name[17]; char revision_num[5]; char vendor_string[21]; SANE_Byte device_type; SANE_Byte SCSI_firmware_ver_major; SANE_Byte SCSI_firmware_ver_minor; SANE_Byte scanner_firmware_ver_major; SANE_Byte scanner_firmware_ver_minor; SANE_Byte response_data_format; #define MI_RESSTEP_1PER 0x01 #define MI_RESSTEP_5PER 0x02 SANE_Byte res_step; #define MI_MODES_LINEART 0x01 #define MI_MODES_HALFTONE 0x02 #define MI_MODES_GRAY 0x04 /* ??????? or "MultiBit"??? XXXXX*/ #define MI_MODES_COLOR 0x08 #define MI_MODES_TRANSMSV 0x20 #define MI_MODES_ONEPASS 0x40 #define MI_MODES_NEGATIVE 0x80 SANE_Byte modes; SANE_Int pattern_count; SANE_Byte pattern_dwnld; #define MI_FEED_FLATBED 0x01 #define MI_FEED_EDGEFEED 0x02 #define MI_FEED_AUTOSUPP 0x04 SANE_Byte feed_type; #define MI_COMPRSS_HUFF 0x10 #define MI_COMPRSS_RD 0x20 SANE_Byte compress_type; #define MI_UNIT_8TH_INCH 0x40 #define MI_UNIT_PIXELS 0x80 SANE_Byte unit_type; SANE_Byte doc_size_code; SANE_Int max_x; /* pixels */ SANE_Int max_y; /* pixels */ SANE_Range doc_x_range; /* mm */ SANE_Range doc_y_range; /* mm */ SANE_Int cont_settings; SANE_Int exp_settings; SANE_Byte model_code; SANE_Int base_resolution; /* dpi, guessed by backend, per model code */ #define MI_SRC_FEED_SUPP 0x01 /* support for feeder */ #define MI_SRC_FEED_BT 0x02 /* support for feed backtracking control */ #define MI_SRC_HAS_FEED 0x04 /* feeder installed */ #define MI_SRC_FEED_RDY 0x08 /* feeder ready */ #define MI_SRC_GET_FEED 0x10 /* if opaque: get from feeder */ #define MI_SRC_GET_TRANS 0x20 /* get transparency (not opaque) */ #define MI_SRC_HAS_TRANS 0x40 /* transparency adapter installed */ SANE_Byte source_options; SANE_Byte expanded_resolution; #define MI_ENH_CAP_SHADOW 0x01 /* can adjust shadow/highlight */ #define MI_ENH_CAP_MIDTONE 0x02 /* can adjust midtone */ SANE_Byte enhance_cap; SANE_Int max_lookup_size; /* max. size of gamma LUT */ SANE_Int max_gamma_bit_depth; /* max. bits of a gamma LUT element */ SANE_Int gamma_size; /* size (bytes) of each LUT element */ SANE_Byte fast_color_preview; /* allows fast color preview? */ SANE_Byte xfer_format_select; /* allows select of transfer format? */ #define MI_COLSEQ_PLANE 0x00 #define MI_COLSEQ_PIXEL 0x01 #define MI_COLSEQ_RGB 0x02 #define MI_COLSEQ_NONRGB 0x03 #define MI_COLSEQ_2PIXEL 0x11 /* Agfa StudioStar */ SANE_Byte color_sequence; /* color sequence spec. code */ SANE_Byte does_3pass; /* allows 3-pass scanning? */ SANE_Byte does_mode1; /* allows MODE1 sense/select comm's? */ #define MI_FMT_CAP_4BPP 0x01 #define MI_FMT_CAP_10BPP 0x02 #define MI_FMT_CAP_12BPP 0x04 #define MI_FMT_CAP_16BPP 0x08 SANE_Byte bit_formats; /* output bit formats capabilities */ #define MI_EXCAP_OFF_CTL 0x01 #define MI_EXCAP_DIS_LNTBL 0x02 #define MI_EXCAP_DIS_RECAL 0x04 SANE_Byte extra_cap; /* SANE_Int contrast_vals; rolled into cont_settings */ SANE_Int min_contrast; SANE_Int max_contrast; /* SANE_Int exposure_vals; rolled into exp_settings */ SANE_Int min_exposure; SANE_Int max_exposure; SANE_Byte does_expansion; /* does expanded-mode expansion internally? */ } Microtek_Info; /*******************************************************************/ /***** device structure (one for each device discovered) *****/ /*******************************************************************/ typedef struct Microtek_Device { struct Microtek_Device *next; /* next, for linked list */ SANE_Device sane; /* SANE generic device block */ Microtek_Info info; /* detailed scanner spec */ } Microtek_Device; /*******************************************************************/ /***** ring buffer structure *****/ /***** ....image workspace during scan *****/ /*******************************************************************/ typedef struct ring_buffer { size_t bpl; /* bytes per line */ size_t ppl; /* pixels per line */ uint8_t *base; /* base address of buffer */ size_t size; /* size (bytes) of ring buffer */ size_t initial_size; /* initial size of ring buffer */ size_t tail_blue; /* byte index, next blue line */ size_t tail_green; /* byte index, next green line */ size_t tail_red; /* byte index, next red line */ size_t blue_extra; /* unmatched blue bytes */ size_t green_extra; /* unmatched green bytes */ size_t red_extra; /* unmatched red bytes */ size_t complete_count; size_t head_complete; } ring_buffer; /*******************************************************************/ /***** scanner structure (one for each device in use) *****/ /***** ....all the state needed to define a scan request *****/ /*******************************************************************/ typedef struct Microtek_Scanner { struct Microtek_Scanner *next; /* for linked list */ Microtek_Device *dev; /* raw device info */ SANE_Option_Descriptor sod[RNUM_OPTIONS]; /* option list for session */ Option_Value val[RNUM_OPTIONS]; /* option values for session */ /* SANE_Int gamma_table[4][256];*/ SANE_Int *gray_lut; SANE_Int *red_lut; SANE_Int *green_lut; SANE_Int *blue_lut; SANE_Range res_range; /* range desc. for resolution */ SANE_Range exp_res_range; /* range desc. for exp. resolution */ /* scan parameters, ready to toss to SCSI commands*/ /* ...set by sane_open (i.e. general/default scanner parameters) */ #define MS_UNIT_PIXELS 0 #define MS_UNIT_18INCH 1 SANE_Byte unit_type; /* pixels or 1/8" */ #define MS_RES_1PER 0 #define MS_RES_5PER 1 SANE_Byte res_type; /* 1% or 5% */ SANE_Bool midtone_support; SANE_Int paper_length; /* whatever unit */ SANE_Bool do_clever_precal; /* calibrate scanner once, via fake scan */ SANE_Bool do_real_calib; /* calibrate via magic commands */ SANE_Bool calib_once; /* ...only calibrate magically once */ SANE_Bool allow_calibrate; SANE_Bool onepass; SANE_Bool prescan, allowbacktrack; SANE_Bool reversecolors; SANE_Bool fastprescan; SANE_Int bits_per_color; SANE_Int gamma_entries; SANE_Int gamma_entry_size; SANE_Int gamma_bit_depth; /* SANE_Int gamma_max_entry;*/ SANE_Range gamma_entry_range; SANE_Range contrast_range; SANE_Range exposure_range; /* ...set by sane_get_parameters (i.e. parameters specified by options) */ SANE_Parameters params; /* format, lastframe, lines, depth, ppl, bpl */ SANE_Int x1; /* in 'units' */ SANE_Int y1; SANE_Int x2; SANE_Int y2; #define MS_MODE_LINEART 0 #define MS_MODE_HALFTONE 1 #define MS_MODE_GRAY 2 #define MS_MODE_COLOR 3 SANE_Int mode; #define MS_FILT_CLEAR 0 #define MS_FILT_RED 1 #define MS_FILT_GREEN 2 #define MS_FILT_BLUE 3 SANE_Byte filter; SANE_Bool onepasscolor, transparency, useADF; SANE_Bool threepasscolor, expandedresolution; SANE_Int resolution; SANE_Byte resolution_code; SANE_Byte exposure, contrast; SANE_Byte pattern; SANE_Byte velocity; SANE_Byte shadow, highlight, midtone; SANE_Byte bright_r, bright_g, bright_b; /* ??? XXXXXXXX signed char */ SANE_Bool multibit; SANE_Byte color_seq; /* ...stuff needed while in mid-scan */ #define MS_LNFMT_FLAT 0 #define MS_LNFMT_SEQ_RGB 1 #define MS_LNFMT_GOOFY_RGB 2 #define MS_LNFMT_SEQ_2R2G2B 3 SANE_Int line_format; /* specify how we need to repackage scanlines */ SANE_Int pixel_bpl; /* bytes per line, pixels */ SANE_Int header_bpl; /* bytes per line, headers */ SANE_Int ppl; /* pixels per line */ SANE_Int planes; /* color planes */ SANE_Bool doexpansion; double exp_aspect; SANE_Int dest_pixel_bpl; SANE_Int dest_ppl; SANE_Int unscanned_lines; /* lines still to be read from scanner */ SANE_Int undelivered_bytes; /* bytes still to be returned to frontend */ SANE_Int max_scsi_lines; /* max number of lines that fit in SCSI buffer */ int sfd; /* SCSI device file descriptor, -1 when not opened */ int scanning; /* true == mid-pass (between sane_start & sane_read=EOF) */ int scan_started; /* true == start_scan has scanner going... */ int woe; /* Woe! */ int this_pass; /* non-zero => in midst of a multipass scan (1,2,3) */ int cancel; /* we cleverly compare mode_sense results between scans to detect if the scanner may have been reset/power-cycled in the meantime */ SANE_Byte mode_sense_cache[10]; #define MS_PRECAL_NONE 0 #define MS_PRECAL_GRAY 1 #define MS_PRECAL_COLOR 2 #define MS_PRECAL_EXP_COLOR 3 SANE_Byte precal_record; /* record what precalibrations have been done */ #define MS_SENSE_IGNORE 1 int sense_flags; /* flags passed to the sense handler */ uint8_t *scsi_buffer; ring_buffer *rb; } Microtek_Scanner; #endif /* microtek_h */ sane-backends-1.0.29/backend/mustek_usb.c0000666000000000000000000013105613615534521015123 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2000 Mustek. Originally maintained by Tom Wang Copyright (C) 2001 - 2004 by Henning Meier-Geinitz. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file implements a SANE backend for Mustek 1200UB and similar USB flatbed scanners. */ #define BUILD 18 #include "../include/sane/config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "../include/sane/sane.h" #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" #define BACKEND_NAME mustek_usb #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_config.h" #include "../include/sane/sanei_usb.h" #include "mustek_usb.h" #include "mustek_usb_high.c" #ifndef SANE_I18N #define SANE_I18N(text) text #endif static SANE_Int num_devices; static Mustek_Usb_Device *first_dev; static Mustek_Usb_Scanner *first_handle; static const SANE_Device **devlist = 0; /* Maximum amount of data read in one turn from USB. */ static SANE_Word max_block_size = (8 * 1024); /* Array of newly attached devices */ static Mustek_Usb_Device **new_dev; /* Length of new_dev array */ static SANE_Int new_dev_len; /* Number of entries alloced for new_dev */ static SANE_Int new_dev_alloced; static SANE_String_Const mode_list[6]; static const SANE_Range u8_range = { 0, /* minimum */ 255, /* maximum */ 0 /* quantization */ }; static size_t max_string_size (const SANE_String_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; } static SANE_Status calc_parameters (Mustek_Usb_Scanner * s) { SANE_String val; SANE_Status status = SANE_STATUS_GOOD; SANE_Int max_x, max_y; DBG (5, "calc_parameters: start\n"); val = s->val[OPT_MODE].s; s->params.last_frame = SANE_TRUE; if (!strcmp (val, SANE_VALUE_SCAN_MODE_LINEART)) { s->params.format = SANE_FRAME_GRAY; s->params.depth = 1; s->bpp = 1; s->channels = 1; } else if (!strcmp (val, SANE_VALUE_SCAN_MODE_GRAY)) { s->params.format = SANE_FRAME_GRAY; s->params.depth = 8; s->bpp = 8; s->channels = 1; } else if (!strcmp (val, SANE_VALUE_SCAN_MODE_COLOR)) { s->params.format = SANE_FRAME_RGB; s->params.depth = 8; s->bpp = 24; s->channels = 3; } else { DBG (1, "calc_parameters: invalid mode %s\n", (SANE_Char *) val); status = SANE_STATUS_INVAL; } s->tl_x = SANE_UNFIX (s->val[OPT_TL_X].w) / MM_PER_INCH; s->tl_y = SANE_UNFIX (s->val[OPT_TL_Y].w) / MM_PER_INCH; s->width = SANE_UNFIX (s->val[OPT_BR_X].w) / MM_PER_INCH - s->tl_x; s->height = SANE_UNFIX (s->val[OPT_BR_Y].w) / MM_PER_INCH - s->tl_y; if (s->width < 0) { DBG (1, "calc_parameters: warning: tl_x > br_x\n"); } if (s->height < 0) { DBG (1, "calc_parameters: warning: tl_y > br_y\n"); } max_x = s->hw->max_width * SANE_UNFIX (s->val[OPT_RESOLUTION].w) / 300; max_y = s->hw->max_height * SANE_UNFIX (s->val[OPT_RESOLUTION].w) / 300; s->tl_x_dots = s->tl_x * SANE_UNFIX (s->val[OPT_RESOLUTION].w); s->width_dots = s->width * SANE_UNFIX (s->val[OPT_RESOLUTION].w); s->tl_y_dots = s->tl_y * SANE_UNFIX (s->val[OPT_RESOLUTION].w); s->height_dots = s->height * SANE_UNFIX (s->val[OPT_RESOLUTION].w); if (s->width_dots > max_x) s->width_dots = max_x; if (s->height_dots > max_y) s->height_dots = max_y; if (!strcmp (val, SANE_VALUE_SCAN_MODE_LINEART)) { s->width_dots = (s->width_dots / 8) * 8; if (s->width_dots == 0) s->width_dots = 8; } if (s->tl_x_dots < 0) s->tl_x_dots = 0; if (s->tl_y_dots < 0) s->tl_y_dots = 0; if (s->tl_x_dots + s->width_dots > max_x) s->tl_x_dots = max_x - s->width_dots; if (s->tl_y_dots + s->height_dots > max_y) s->tl_y_dots = max_y - s->height_dots; s->val[OPT_TL_X].w = SANE_FIX (s->tl_x * MM_PER_INCH); s->val[OPT_TL_Y].w = SANE_FIX (s->tl_y * MM_PER_INCH); s->val[OPT_BR_X].w = SANE_FIX ((s->tl_x + s->width) * MM_PER_INCH); s->val[OPT_BR_Y].w = SANE_FIX ((s->tl_y + s->height) * MM_PER_INCH); s->params.pixels_per_line = s->width_dots; if (s->params.pixels_per_line < 0) s->params.pixels_per_line = 0; s->params.lines = s->height_dots; if (s->params.lines < 0) s->params.lines = 0; s->params.bytes_per_line = s->params.pixels_per_line * s->params.depth / 8 * s->channels; DBG (4, "calc_parameters: format=%d\n", s->params.format); DBG (4, "calc_parameters: last frame=%d\n", s->params.last_frame); DBG (4, "calc_parameters: lines=%d\n", s->params.lines); DBG (4, "calc_parameters: pixels per line=%d\n", s->params.pixels_per_line); DBG (4, "calc_parameters: bytes per line=%d\n", s->params.bytes_per_line); DBG (4, "calc_parameters: Pixels %dx%dx%d\n", s->params.pixels_per_line, s->params.lines, 1 << s->params.depth); DBG (5, "calc_parameters: exit\n"); return status; } static SANE_Status init_options (Mustek_Usb_Scanner * s) { SANE_Int option; SANE_Status status; DBG (5, "init_options: start\n"); memset (s->opt, 0, sizeof (s->opt)); memset (s->val, 0, sizeof (s->val)); for (option = 0; option < NUM_OPTIONS; ++option) { s->opt[option].size = sizeof (SANE_Word); s->opt[option].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; } s->opt[OPT_NUM_OPTS].name = SANE_NAME_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; s->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; s->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; s->val[OPT_NUM_OPTS].w = NUM_OPTIONS; /* "Mode" group: */ s->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); s->opt[OPT_MODE_GROUP].desc = ""; s->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_MODE_GROUP].size = 0; s->opt[OPT_MODE_GROUP].cap = 0; s->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* scan mode */ mode_list[0] = SANE_VALUE_SCAN_MODE_COLOR; mode_list[1] = SANE_VALUE_SCAN_MODE_GRAY; mode_list[2] = SANE_VALUE_SCAN_MODE_LINEART; mode_list[3] = NULL; s->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; s->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; s->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; s->opt[OPT_MODE].type = SANE_TYPE_STRING; s->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; s->opt[OPT_MODE].size = max_string_size (mode_list); s->opt[OPT_MODE].constraint.string_list = mode_list; s->val[OPT_MODE].s = strdup (mode_list[1]); /* resolution */ s->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; s->opt[OPT_RESOLUTION].type = SANE_TYPE_FIXED; s->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; s->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_RESOLUTION].constraint.range = &s->hw->dpi_range; s->val[OPT_RESOLUTION].w = s->hw->dpi_range.min; if (s->hw->chip->scanner_type == MT_600CU) s->hw->dpi_range.max = SANE_FIX (600); else s->hw->dpi_range.max = SANE_FIX (1200); /* preview */ s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; s->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; s->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; s->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; s->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; s->val[OPT_PREVIEW].w = SANE_FALSE; /* "Geometry" group: */ s->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); s->opt[OPT_GEOMETRY_GROUP].desc = ""; s->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_GEOMETRY_GROUP].cap = SANE_CAP_ADVANCED; s->opt[OPT_GEOMETRY_GROUP].size = 0; s->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* top-left x */ s->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; s->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; s->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; s->opt[OPT_TL_X].type = SANE_TYPE_FIXED; s->opt[OPT_TL_X].unit = SANE_UNIT_MM; s->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_X].constraint.range = &s->hw->x_range; s->val[OPT_TL_X].w = 0; /* top-left y */ s->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; s->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; s->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; s->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; s->opt[OPT_TL_Y].unit = SANE_UNIT_MM; s->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_TL_Y].constraint.range = &s->hw->y_range; s->val[OPT_TL_Y].w = 0; /* bottom-right x */ s->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; s->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; s->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; s->opt[OPT_BR_X].type = SANE_TYPE_FIXED; s->opt[OPT_BR_X].unit = SANE_UNIT_MM; s->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_X].constraint.range = &s->hw->x_range; s->val[OPT_BR_X].w = s->hw->x_range.max; /* bottom-right y */ s->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; s->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; s->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; s->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; s->opt[OPT_BR_Y].unit = SANE_UNIT_MM; s->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_BR_Y].constraint.range = &s->hw->y_range; s->val[OPT_BR_Y].w = s->hw->y_range.max; /* "Enhancement" group: */ s->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); s->opt[OPT_ENHANCEMENT_GROUP].desc = ""; s->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; s->opt[OPT_ENHANCEMENT_GROUP].size = 0; s->opt[OPT_ENHANCEMENT_GROUP].cap = 0; s->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; /* threshold */ s->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; s->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; s->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; s->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; s->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; s->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_THRESHOLD].constraint.range = &u8_range; s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; s->val[OPT_THRESHOLD].w = 128; /* custom-gamma table */ s->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; s->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; s->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; /* gray gamma vector */ s->opt[OPT_GAMMA_VECTOR].name = SANE_NAME_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].title = SANE_TITLE_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].desc = SANE_DESC_GAMMA_VECTOR; s->opt[OPT_GAMMA_VECTOR].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR].wa = &s->gray_gamma_table[0]; /* red gamma vector */ s->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; s->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_R].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_R].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_R].wa = &s->red_gamma_table[0]; /* green gamma vector */ s->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; s->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_G].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_G].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_G].wa = &s->green_gamma_table[0]; /* blue gamma vector */ s->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; s->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; s->opt[OPT_GAMMA_VECTOR_B].size = 256 * sizeof (SANE_Word); s->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; s->opt[OPT_GAMMA_VECTOR_B].constraint.range = &u8_range; s->val[OPT_GAMMA_VECTOR_B].wa = &s->blue_gamma_table[0]; RIE (calc_parameters (s)); DBG (5, "init_options: exit\n"); return SANE_STATUS_GOOD; } static SANE_Status attach (SANE_String_Const devname, Mustek_Usb_Device ** devp, SANE_Bool may_wait) { Mustek_Usb_Device *dev; SANE_Status status; Mustek_Type scanner_type; SANE_Int fd; DBG (5, "attach: start: devp %s NULL, may_wait = %d\n", devp ? "!=" : "==", may_wait); if (!devname) { DBG (1, "attach: devname == NULL\n"); return SANE_STATUS_INVAL; } for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devname) == 0) { if (devp) *devp = dev; DBG (4, "attach: device `%s' was already in device list\n", devname); return SANE_STATUS_GOOD; } DBG (4, "attach: trying to open device `%s'\n", devname); status = sanei_usb_open (devname, &fd); if (status != SANE_STATUS_GOOD) { DBG (3, "attach: couldn't open device `%s': %s\n", devname, sane_strstatus (status)); return status; } DBG (4, "attach: device `%s' successfully opened\n", devname); /* try to identify model */ DBG (4, "attach: trying to identify device `%s'\n", devname); status = usb_low_identify_scanner (fd, &scanner_type); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: device `%s' doesn't look like a supported scanner\n", devname); sanei_usb_close (fd); return status; } sanei_usb_close (fd); if (scanner_type == MT_UNKNOWN) { DBG (3, "attach: warning: couldn't identify device `%s', must set " "type manually\n", devname); } dev = malloc (sizeof (Mustek_Usb_Device)); if (!dev) { DBG (1, "attach: couldn't malloc Mustek_Usb_Device\n"); return SANE_STATUS_NO_MEM; } memset (dev, 0, sizeof (*dev)); dev->name = strdup (devname); dev->sane.name = (SANE_String_Const) dev->name; dev->sane.vendor = "Mustek"; switch (scanner_type) { case MT_1200CU: dev->sane.model = "1200 CU"; break; case MT_1200CU_PLUS: dev->sane.model = "1200 CU Plus"; break; case MT_1200USB: dev->sane.model = "1200 USB (unsupported)"; break; case MT_1200UB: dev->sane.model = "1200 UB"; break; case MT_600CU: dev->sane.model = "600 CU"; break; case MT_600USB: dev->sane.model = "600 USB (unsupported)"; break; default: dev->sane.model = "(unidentified)"; break; } dev->sane.type = "flatbed scanner"; dev->x_range.min = 0; dev->x_range.max = SANE_FIX (8.4 * MM_PER_INCH); dev->x_range.quant = 0; dev->y_range.min = 0; dev->y_range.max = SANE_FIX (11.7 * MM_PER_INCH); dev->y_range.quant = 0; dev->max_height = 11.7 * 300; dev->max_width = 8.4 * 300; dev->dpi_range.min = SANE_FIX (50); dev->dpi_range.max = SANE_FIX (600); dev->dpi_range.quant = SANE_FIX (1); status = usb_high_scan_init (dev); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: usb_high_scan_init returned status: %s\n", sane_strstatus (status)); free (dev); return status; } dev->chip->scanner_type = scanner_type; dev->chip->max_block_size = max_block_size; DBG (2, "attach: found %s %s %s at %s\n", dev->sane.vendor, dev->sane.type, dev->sane.model, dev->sane.name); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; DBG (5, "attach: exit\n"); return SANE_STATUS_GOOD; } static SANE_Status attach_one_device (SANE_String_Const devname) { Mustek_Usb_Device *dev; SANE_Status status; RIE (attach (devname, &dev, SANE_FALSE)); if (dev) { /* Keep track of newly attached devices so we can set options as necessary. */ if (new_dev_len >= new_dev_alloced) { new_dev_alloced += 4; if (new_dev) new_dev = realloc (new_dev, new_dev_alloced * sizeof (new_dev[0])); else new_dev = malloc (new_dev_alloced * sizeof (new_dev[0])); if (!new_dev) { DBG (1, "attach_one_device: out of memory\n"); return SANE_STATUS_NO_MEM; } } new_dev[new_dev_len++] = dev; } return SANE_STATUS_GOOD; } static SANE_Status fit_lines (Mustek_Usb_Scanner * s, SANE_Byte * src, SANE_Byte * dst, SANE_Word src_lines, SANE_Word * dst_lines) { SANE_Int threshold; SANE_Word src_width, dst_width; SANE_Word dst_pixel, src_pixel; SANE_Word dst_line, src_line; SANE_Word pixel_switch; SANE_Word src_address, dst_address; src_width = s->hw->width; dst_width = s->width_dots; threshold = s->val[OPT_THRESHOLD].w; DBG (5, "fit_lines: dst_width=%d, src_width=%d, src_lines=%d, " "offset=%d\n", dst_width, src_width, src_lines, s->hw->line_offset); dst_line = 0; src_line = s->hw->line_offset; while (src_line < src_lines) { DBG (5, "fit_lines: getting line: dst_line=%d, src_line=%d, " "line_switch=%d\n", dst_line, src_line, s->hw->line_switch); src_pixel = 0; pixel_switch = src_width; for (dst_pixel = 0; dst_pixel < dst_width; dst_pixel++) { while (pixel_switch > dst_width) { src_pixel++; pixel_switch -= dst_width; } pixel_switch += src_width; src_address = src_pixel * s->hw->bpp / 8 + src_width * src_line * s->hw->bpp / 8; dst_address = dst_pixel * s->bpp / 8 + dst_width * dst_line * s->bpp / 8; if (s->bpp == 8) { dst[dst_address] = s->gray_table[src[src_address]]; } else if (s->bpp == 24) { dst[dst_address] = s->red_table[s->gray_table[src[src_address]]]; dst[dst_address + 1] = s->green_table[s->gray_table[src[src_address + 1]]]; dst[dst_address + 2] = s->blue_table[s->gray_table[src[src_address + 2]]]; } else /* lineart */ { if ((dst_pixel % 8) == 0) dst[dst_address] = 0; dst[dst_address] |= (((src[src_address] > threshold) ? 0 : 1) << (7 - (dst_pixel % 8))); } } dst_line++; while (s->hw->line_switch >= s->height_dots) { src_line++; s->hw->line_switch -= s->height_dots; } s->hw->line_switch += s->hw->height; } *dst_lines = dst_line; s->hw->line_offset = (src_line - src_lines); DBG (4, "fit_lines: exit, src_line=%d, *dst_lines=%d, offset=%d\n", src_line, *dst_lines, s->hw->line_offset); return SANE_STATUS_GOOD; } static SANE_Status check_gamma_table (SANE_Word * table) { SANE_Word entry, value; SANE_Status status = SANE_STATUS_GOOD; for (entry = 0; entry < 256; entry++) { value = table[entry]; if (value > 255) { DBG (1, "check_gamma_table: warning: entry %d > 255 (%d) - fixed\n", entry, value); table[entry] = 255; status = SANE_STATUS_INVAL; } } return status; } /* -------------------------- SANE API functions ------------------------- */ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) { SANE_Char line[PATH_MAX]; SANE_Char *word, *end; SANE_String_Const cp; SANE_Int linenumber; FILE *fp; DBG_INIT (); DBG (2, "SANE Mustek USB backend version %d.%d build %d from %s\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (5, "sane_init: authorize %s null\n", authorize ? "!=" : "=="); num_devices = 0; first_dev = 0; first_handle = 0; devlist = 0; new_dev = 0; new_dev_len = 0; new_dev_alloced = 0; sanei_usb_init (); fp = sanei_config_open (MUSTEK_USB_CONFIG_FILE); if (!fp) { /* default to /dev/usb/scanner instead of insisting on config file */ DBG (3, "sane_init: couldn't open config file `%s': %s. Using " "/dev/usb/scanner directly\n", MUSTEK_USB_CONFIG_FILE, strerror (errno)); attach ("/dev/usb/scanner", 0, SANE_FALSE); return SANE_STATUS_GOOD; } linenumber = 0; DBG (4, "sane_init: reading config file `%s'\n", MUSTEK_USB_CONFIG_FILE); while (sanei_config_read (line, sizeof (line), fp)) { word = 0; linenumber++; cp = sanei_config_get_string (line, &word); if (!word || cp == line) { DBG (5, "sane_init: config file line %d: ignoring empty line\n", linenumber); if (word) free (word); continue; } if (word[0] == '#') { DBG (5, "sane_init: config file line %d: ignoring comment line\n", linenumber); free (word); continue; } if (strcmp (word, "option") == 0) { free (word); word = 0; cp = sanei_config_get_string (cp, &word); if (!word) { DBG (1, "sane_init: config file line %d: missing quotation mark?\n", linenumber); continue; } if (strcmp (word, "max_block_size") == 0) { free (word); word = 0; cp = sanei_config_get_string (cp, &word); if (!word) { DBG (1, "sane_init: config file line %d: missing quotation mark?\n", linenumber); continue; } errno = 0; max_block_size = strtol (word, &end, 0); if (end == word) { DBG (3, "sane-init: config file line %d: max_block_size " "must have a parameter; using 8192 bytes\n", linenumber); max_block_size = 8192; } if (errno) { DBG (3, "sane-init: config file line %d: max_block_size `%s' " "is invalid (%s); using 8192 bytes\n", linenumber, word, strerror (errno)); max_block_size = 8192; } else { DBG (3, "sane_init: config file line %d: max_block_size set " "to %d bytes\n", linenumber, max_block_size); } if (word) free (word); word = 0; } else if (strcmp (word, "1200ub") == 0) { if (new_dev_len > 0) { /* this is a 1200 UB */ new_dev[new_dev_len - 1]->chip->scanner_type = MT_1200UB; new_dev[new_dev_len - 1]->sane.model = "1200 UB"; DBG (3, "sane_init: config file line %d: `%s' is a Mustek " "1200 UB\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "1200ub ignored, was set before any device " "name\n", linenumber); } if (word) free (word); word = 0; } else if (strcmp (word, "1200cu") == 0) { if (new_dev_len > 0) { /* this is a 1200 CU */ new_dev[new_dev_len - 1]->chip->scanner_type = MT_1200CU; new_dev[new_dev_len - 1]->sane.model = "1200 CU"; DBG (3, "sane_init: config file line %d: `%s' is a Mustek " "1200 CU\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "1200cu ignored, was set before any device " "name\n", linenumber); } if (word) free (word); word = 0; } else if (strcmp (word, "1200cu_plus") == 0) { if (new_dev_len > 0) { /* this is a 1200 CU Plus */ new_dev[new_dev_len - 1]->chip->scanner_type = MT_1200CU_PLUS; new_dev[new_dev_len - 1]->sane.model = "1200 CU Plus"; DBG (3, "sane_init: config file line %d: `%s' is a Mustek " "1200 CU Plus\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "1200cu_plus ignored, was set before any device " "name\n", linenumber); } if (word) free (word); word = 0; } else if (strcmp (word, "600cu") == 0) { if (new_dev_len > 0) { /* this is a 600 CU */ new_dev[new_dev_len - 1]->chip->scanner_type = MT_600CU; new_dev[new_dev_len - 1]->sane.model = "600 CU"; DBG (3, "sane_init: config file line %d: `%s' is a Mustek " "600 CU\n", linenumber, new_dev[new_dev_len - 1]->sane.name); } else { DBG (3, "sane_init: config file line %d: option " "600cu ignored, was set before any device " "name\n", linenumber); } if (word) free (word); word = 0; } else { DBG (3, "sane_init: config file line %d: option " "%s is unknown\n", linenumber, word); if (word) free (word); word = 0; } } else { new_dev_len = 0; DBG (4, "sane_init: config file line %d: trying to attach `%s'\n", linenumber, line); sanei_usb_attach_matching_devices (line, attach_one_device); if (word) free (word); word = 0; } } if (new_dev_alloced > 0) { new_dev_len = new_dev_alloced = 0; free (new_dev); } fclose (fp); DBG (5, "sane_init: exit\n"); return SANE_STATUS_GOOD; } void sane_exit (void) { Mustek_Usb_Device *dev, *next; SANE_Status status; DBG (5, "sane_exit: start\n"); for (dev = first_dev; dev; dev = next) { next = dev->next; if (dev->is_prepared) { status = usb_high_scan_clearup (dev); if (status != SANE_STATUS_GOOD) DBG (3, "sane_close: usb_high_scan_clearup returned %s\n", sane_strstatus (status)); } status = usb_high_scan_exit (dev); if (status != SANE_STATUS_GOOD) DBG (3, "sane_close: usb_high_scan_exit returned %s\n", sane_strstatus (status)); if (dev->chip) { status = usb_high_scan_exit (dev); if (status != SANE_STATUS_GOOD) DBG (3, "sane_exit: while closing %s, usb_high_scan_exit returned: " "%s\n", dev->name, sane_strstatus (status)); } free ((void *) dev->name); free (dev); } first_dev = 0; if (devlist) free (devlist); devlist = 0; DBG (5, "sane_exit: exit\n"); } SANE_Status sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) { Mustek_Usb_Device *dev; SANE_Int dev_num; DBG (5, "sane_get_devices: start: local_only = %s\n", local_only == SANE_TRUE ? "true" : "false"); if (devlist) free (devlist); devlist = malloc ((num_devices + 1) * sizeof (devlist[0])); if (!devlist) return SANE_STATUS_NO_MEM; dev_num = 0; for (dev = first_dev; dev_num < num_devices; dev = dev->next) devlist[dev_num++] = &dev->sane; devlist[dev_num++] = 0; *device_list = devlist; DBG (5, "sane_get_devices: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { Mustek_Usb_Device *dev; SANE_Status status; Mustek_Usb_Scanner *s; SANE_Int value; DBG (5, "sane_open: start (devicename = `%s')\n", devicename); if (devicename[0]) { for (dev = first_dev; dev; dev = dev->next) if (strcmp (dev->sane.name, devicename) == 0) break; if (!dev) { DBG (5, "sane_open: couldn't find `%s' in devlist, trying attach)\n", devicename); RIE (attach (devicename, &dev, SANE_TRUE)); } else DBG (5, "sane_open: found `%s' in devlist\n", dev->name); } else { /* empty devicname -> use first device */ dev = first_dev; if (dev) DBG (5, "sane_open: empty devicename, trying `%s'\n", dev->name); } if (!dev) return SANE_STATUS_INVAL; if (dev->chip->scanner_type == MT_UNKNOWN) { DBG (0, "sane_open: the type of your scanner is unknown, edit " "mustek_usb.conf before using the scanner\n"); return SANE_STATUS_INVAL; } s = malloc (sizeof (*s)); if (!s) return SANE_STATUS_NO_MEM; memset (s, 0, sizeof (*s)); s->hw = dev; RIE (init_options (s)); /* insert newly opened handle into list of open handles: */ s->next = first_handle; first_handle = s; *handle = s; strcpy (s->hw->device_name, dev->name); RIE (usb_high_scan_turn_power (s->hw, SANE_TRUE)); RIE (usb_high_scan_back_home (s->hw)); s->hw->scan_buffer = (SANE_Byte *) malloc (SCAN_BUFFER_SIZE * 2); if (!s->hw->scan_buffer) { DBG (5, "sane_open: couldn't malloc s->hw->scan_buffer (%d bytes)\n", SCAN_BUFFER_SIZE * 2); return SANE_STATUS_NO_MEM; } s->hw->scan_buffer_len = 0; s->hw->scan_buffer_start = s->hw->scan_buffer; s->hw->temp_buffer = (SANE_Byte *) malloc (SCAN_BUFFER_SIZE); if (!s->hw->temp_buffer) { DBG (5, "sane_open: couldn't malloc s->hw->temp_buffer (%d bytes)\n", SCAN_BUFFER_SIZE); return SANE_STATUS_NO_MEM; } s->hw->temp_buffer_len = 0; s->hw->temp_buffer_start = s->hw->temp_buffer; for (value = 0; value < 256; value++) { s->linear_gamma_table[value] = value; s->red_gamma_table[value] = value; s->green_gamma_table[value] = value; s->blue_gamma_table[value] = value; s->gray_gamma_table[value] = value; } s->red_table = s->linear_gamma_table; s->green_table = s->linear_gamma_table; s->blue_table = s->linear_gamma_table; s->gray_table = s->linear_gamma_table; DBG (5, "sane_open: exit\n"); return SANE_STATUS_GOOD; } void sane_close (SANE_Handle handle) { Mustek_Usb_Scanner *prev, *s; SANE_Status status; DBG (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) { DBG (5, "close: invalid handle %p\n", handle); return; /* oops, not a handle we know about */ } if (prev) prev->next = s->next; else first_handle = s->next; if (s->hw->is_open) { status = usb_high_scan_turn_power (s->hw, SANE_FALSE); if (status != SANE_STATUS_GOOD) DBG (3, "sane_close: usb_high_scan_turn_power returned %s\n", sane_strstatus (status)); } #if 0 if (s->hw->is_prepared) { status = usb_high_scan_clearup (s->hw); if (status != SANE_STATUS_GOOD) DBG (3, "sane_close: usb_high_scan_clearup returned %s\n", sane_strstatus (status)); } status = usb_high_scan_exit (s->hw); if (status != SANE_STATUS_GOOD) DBG (3, "sane_close: usb_high_scan_exit returned %s\n", sane_strstatus (status)); #endif if (s->hw->scan_buffer) { free (s->hw->scan_buffer); s->hw->scan_buffer = 0; } if (s->hw->temp_buffer) { free (s->hw->temp_buffer); s->hw->temp_buffer = 0; } free (handle); DBG (5, "sane_close: exit\n"); } const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { Mustek_Usb_Scanner *s = handle; if ((unsigned) option >= NUM_OPTIONS) return 0; DBG (5, "sane_get_option_descriptor: option = %s (%d)\n", s->opt[option].name, option); return s->opt + option; } SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *val, SANE_Int * info) { Mustek_Usb_Scanner *s = handle; SANE_Status status; SANE_Word cap; SANE_Int myinfo = 0; DBG (5, "sane_control_option: start: action = %s, option = %s (%d)\n", (action == SANE_ACTION_GET_VALUE) ? "get" : (action == SANE_ACTION_SET_VALUE) ? "set" : (action == SANE_ACTION_SET_AUTO) ? "set_auto" : "unknown", s->opt[option].name, option); if (info) *info = 0; if (s->scanning) { DBG (1, "sane_control_option: don't call this function while " "scanning\n"); return SANE_STATUS_DEVICE_BUSY; } if (option >= NUM_OPTIONS || option < 0) { DBG (1, "sane_control_option: option %d >= NUM_OPTIONS || option < 0\n", option); return SANE_STATUS_INVAL; } cap = s->opt[option].cap; if (!SANE_OPTION_IS_ACTIVE (cap)) { DBG (2, "sane_control_option: option %d is inactive\n", option); return SANE_STATUS_INVAL; } if (action == SANE_ACTION_GET_VALUE) { switch (option) { /* word options: */ case OPT_NUM_OPTS: case OPT_RESOLUTION: case OPT_PREVIEW: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: case OPT_THRESHOLD: case OPT_CUSTOM_GAMMA: *(SANE_Word *) val = s->val[option].w; break; /* word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (val, s->val[option].wa, s->opt[option].size); break; /* string options: */ case OPT_MODE: strcpy (val, s->val[option].s); break; default: DBG (2, "sane_control_option: can't get unknown option %d\n", option); } } else if (action == SANE_ACTION_SET_VALUE) { if (!SANE_OPTION_IS_SETTABLE (cap)) { DBG (2, "sane_control_option: option %d is not settable\n", option); return SANE_STATUS_INVAL; } status = sanei_constrain_value (s->opt + option, val, &myinfo); if (status != SANE_STATUS_GOOD) { DBG (2, "sane_control_option: sanei_constrain_value returned %s\n", sane_strstatus (status)); return status; } switch (option) { /* (mostly) side-effect-free word options: */ case OPT_RESOLUTION: case OPT_TL_X: case OPT_TL_Y: case OPT_BR_X: case OPT_BR_Y: s->val[option].w = *(SANE_Word *) val; RIE (calc_parameters (s)); myinfo |= SANE_INFO_RELOAD_PARAMS; break; case OPT_THRESHOLD: s->val[option].w = *(SANE_Word *) val; break; /* Boolean */ case OPT_PREVIEW: s->val[option].w = *(SANE_Bool *) val; break; /* side-effect-free word-array options: */ case OPT_GAMMA_VECTOR: case OPT_GAMMA_VECTOR_R: case OPT_GAMMA_VECTOR_G: case OPT_GAMMA_VECTOR_B: memcpy (s->val[option].wa, val, s->opt[option].size); check_gamma_table (s->val[option].wa); break; case OPT_CUSTOM_GAMMA: s->val[OPT_CUSTOM_GAMMA].w = *(SANE_Word *) val; myinfo |= SANE_INFO_RELOAD_OPTIONS; if (s->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE) { s->red_table = s->red_gamma_table; s->green_table = s->green_gamma_table; s->blue_table = s->blue_gamma_table; s->gray_table = s->gray_gamma_table; if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY) == 0) s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; else if (strcmp (s->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } else { s->red_table = s->linear_gamma_table; s->green_table = s->linear_gamma_table; s->blue_table = s->linear_gamma_table; s->gray_table = s->linear_gamma_table; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; } break; case OPT_MODE: if (s->val[option].s) free (s->val[option].s); s->val[option].s = strdup (val); RIE (calc_parameters (s)); s->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; if (strcmp (val, SANE_VALUE_SCAN_MODE_LINEART) == 0) { s->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; } else { s->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; if (s->val[OPT_CUSTOM_GAMMA].w == SANE_TRUE) { s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; } } myinfo |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS; break; default: DBG (2, "sane_control_option: can't set unknown option %d\n", option); } } else { DBG (2, "sane_control_option: unknown action %d for option %d\n", action, option); return SANE_STATUS_INVAL; } if (info) *info = myinfo; DBG (5, "sane_control_option: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { Mustek_Usb_Scanner *s = handle; SANE_Status status; DBG (5, "sane_get_parameters: start\n"); RIE (calc_parameters (s)); if (params) *params = s->params; DBG (5, "sane_get_parameters: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_start (SANE_Handle handle) { Mustek_Usb_Scanner *s = handle; SANE_Status status; SANE_String val; Colormode color_mode; SANE_Word dpi, x, y, width, height; DBG (5, "sane_start: start\n"); /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ s->total_bytes = 0; s->total_lines = 0; RIE (calc_parameters (s)); if (s->width_dots <= 0) { DBG (0, "sane_start: top left x > bottom right x --- exiting\n"); return SANE_STATUS_INVAL; } if (s->height_dots <= 0) { DBG (0, "sane_start: top left y > bottom right y --- exiting\n"); return SANE_STATUS_INVAL; } val = s->val[OPT_MODE].s; if (!strcmp (val, SANE_VALUE_SCAN_MODE_LINEART)) color_mode = GRAY8; else if (!strcmp (val, SANE_VALUE_SCAN_MODE_GRAY)) color_mode = GRAY8; else /* Color */ color_mode = RGB24; dpi = SANE_UNFIX (s->val[OPT_RESOLUTION].w); x = s->tl_x_dots; y = s->tl_y_dots; width = s->width_dots; height = s->height_dots; if (!s->hw->is_prepared) { RIE (usb_high_scan_prepare (s->hw)); RIE (usb_high_scan_reset (s->hw)); } RIE (usb_high_scan_set_threshold (s->hw, 128)); RIE (usb_high_scan_embed_gamma (s->hw, NULL)); RIE (usb_high_scan_suggest_parameters (s->hw, dpi, x, y, width, height, color_mode)); RIE (usb_high_scan_setup_scan (s->hw, s->hw->scan_mode, s->hw->x_dpi, s->hw->y_dpi, 0, s->hw->x, s->hw->y, s->hw->width)); DBG (3, "sane_start: wanted: dpi=%d, x=%d, y=%d, width=%d, height=%d, " "scan_mode=%d\n", dpi, x, y, width, height, color_mode); DBG (3, "sane_start: got: x_dpi=%d, y_dpi=%d, x=%d, y=%d, width=%d, " "height=%d, scan_mode=%d\n", s->hw->x_dpi, s->hw->y_dpi, s->hw->x, s->hw->y, s->hw->width, s->hw->height, s->hw->scan_mode); s->scanning = SANE_TRUE; s->read_rows = s->hw->height; s->hw->line_switch = s->hw->height; s->hw->line_offset = 0; s->hw->scan_buffer_len = 0; DBG (5, "sane_start: exit\n"); return SANE_STATUS_GOOD; } SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len) { Mustek_Usb_Scanner *s = handle; SANE_Word lines_to_read, lines_read; SANE_Status status; DBG (5, "sane_read: start\n"); if (!s) { DBG (1, "sane_read: handle is null!\n"); return SANE_STATUS_INVAL; } if (!buf) { DBG (1, "sane_read: buf is null!\n"); return SANE_STATUS_INVAL; } if (!len) { DBG (1, "sane_read: len is null!\n"); return SANE_STATUS_INVAL; } *len = 0; if (!s->scanning) { DBG (3, "sane_read: scan was cancelled, is over or has not been " "initiated yet\n"); return SANE_STATUS_CANCELLED; } if (s->hw->scan_buffer_len == 0) { if (s->read_rows > 0) { lines_to_read = SCAN_BUFFER_SIZE / (s->hw->width * s->hw->bpp / 8); if (lines_to_read > s->read_rows) lines_to_read = s->read_rows; s->hw->temp_buffer_start = s->hw->temp_buffer; s->hw->temp_buffer_len = (s->hw->width * s->hw->bpp / 8) * lines_to_read; DBG (4, "sane_read: reading %d source lines\n", lines_to_read); RIE (usb_high_scan_get_rows (s->hw, s->hw->temp_buffer, lines_to_read, SANE_FALSE)); RIE (fit_lines (s, s->hw->temp_buffer, s->hw->scan_buffer, lines_to_read, &lines_read)); s->read_rows -= lines_to_read; if ((s->total_lines + lines_read) > s->height_dots) lines_read = s->height_dots - s->total_lines; s->total_lines += lines_read; DBG (4, "sane_read: %d destination lines, %d total\n", lines_read, s->total_lines); s->hw->scan_buffer_start = s->hw->scan_buffer; s->hw->scan_buffer_len = (s->width_dots * s->bpp / 8) * lines_read; } else { DBG (4, "sane_read: scan finished -- exit\n"); return SANE_STATUS_EOF; } } if (s->hw->scan_buffer_len == 0) { DBG (4, "sane_read: scan finished -- exit\n"); return SANE_STATUS_EOF; } *len = MIN (max_len, (SANE_Int) s->hw->scan_buffer_len); memcpy (buf, s->hw->scan_buffer_start, *len); DBG (4, "sane_read: exit, read %d bytes from scan_buffer; " "%ld bytes remaining\n", *len, (long int) (s->hw->scan_buffer_len - *len)); s->hw->scan_buffer_len -= (*len); s->hw->scan_buffer_start += (*len); s->total_bytes += (*len); return SANE_STATUS_GOOD; } void sane_cancel (SANE_Handle handle) { Mustek_Usb_Scanner *s = handle; SANE_Status status; DBG (5, "sane_cancel: start\n"); status = usb_high_scan_stop_scan (s->hw); if (status != SANE_STATUS_GOOD) DBG (3, "sane_cancel: usb_high_scan_stop_scan returned `%s' for `%s'\n", sane_strstatus (status), s->hw->name); usb_high_scan_back_home (s->hw); if (status != SANE_STATUS_GOOD) DBG (3, "sane_cancel: usb_high_scan_back_home returned `%s' for `%s'\n", sane_strstatus (status), s->hw->name); if (s->scanning) { s->scanning = SANE_FALSE; if (s->total_bytes != (s->params.bytes_per_line * s->params.lines)) DBG (1, "sane_cancel: warning: scanned %d bytes, expected %d " "bytes\n", s->total_bytes, s->params.bytes_per_line * s->params.lines); else DBG (3, "sane_cancel: scan finished, scanned %d bytes\n", s->total_bytes); } else { DBG (4, "sane_cancel: scan has not been initiated yet, " "or it is already aborted\n"); } DBG (5, "sane_cancel: exit\n"); return; } SANE_Status sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Mustek_Usb_Scanner *s = handle; DBG (5, "sane_set_io_mode: handle = %p, non_blocking = %s\n", handle, non_blocking == SANE_TRUE ? "true" : "false"); if (!s->scanning) { DBG (1, "sane_set_io_mode: not scanning\n"); return SANE_STATUS_INVAL; } if (non_blocking) return SANE_STATUS_UNSUPPORTED; return SANE_STATUS_GOOD; } SANE_Status sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Mustek_Usb_Scanner *s = handle; DBG (5, "sane_get_select_fd: handle = %p, fd = %p\n", handle, (void *) fd); if (!s->scanning) { DBG (1, "sane_get_select_fd: not scanning\n"); return SANE_STATUS_INVAL; } return SANE_STATUS_UNSUPPORTED; } sane-backends-1.0.29/backend/hp5590.c0000666000000000000000000027515713615534521013707 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2007 Ilia Sotnikov HP ScanJet 4570c support by Markham Thomas ADF page detection and high DPI fixes by Bernard Badeer scanbd integration by Damiano Scaramuzza and Bernard Badeer 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP ScanJet 4500C/4570C/5500C/5550C/5590/7650 Scanners */ #include "../include/sane/config.h" #include #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #include "../include/sane/sane.h" #define BACKEND_NAME hp5590 #include "../include/sane/sanei_backend.h" #include "../include/sane/sanei_usb.h" #include "../include/sane/saneopts.h" #include "hp5590_cmds.c" #include "hp5590_low.c" #include "../include/sane/sanei_net.h" /* Debug levels */ #define DBG_err 0 #define DBG_proc 10 #define DBG_verbose 20 #define DBG_details 30 #define hp5590_assert(exp) if(!(exp)) { \ DBG (DBG_err, "Assertion '%s' failed at %s:%u\n", #exp, __FILE__, __LINE__);\ return SANE_STATUS_INVAL; \ } #define hp5590_assert_void_return(exp) if(!(exp)) { \ DBG (DBG_err, "Assertion '%s' failed at %s:%u\n", #exp, __FILE__, __LINE__);\ return; \ } #define MY_MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MY_MAX(a, b) (((a) > (b)) ? (a) : (b)) /* #define HAS_WORKING_COLOR_48 */ #define BUILD 8 #define USB_TIMEOUT 30 * 1000 static SANE_Word res_list[] = { 6, 100, 200, 300, 600, 1200, 2400 }; #define SANE_VALUE_SCAN_SOURCE_FLATBED SANE_I18N("Flatbed") #define SANE_VALUE_SCAN_SOURCE_ADF SANE_I18N("ADF") #define SANE_VALUE_SCAN_SOURCE_ADF_DUPLEX SANE_I18N("ADF Duplex") #define SANE_VALUE_SCAN_SOURCE_TMA_SLIDES SANE_I18N("TMA Slides") #define SANE_VALUE_SCAN_SOURCE_TMA_NEGATIVES SANE_I18N("TMA Negatives") static SANE_String_Const sources_list[] = { SANE_VALUE_SCAN_SOURCE_FLATBED, SANE_VALUE_SCAN_SOURCE_ADF, SANE_VALUE_SCAN_SOURCE_ADF_DUPLEX, SANE_VALUE_SCAN_SOURCE_TMA_SLIDES, SANE_VALUE_SCAN_SOURCE_TMA_NEGATIVES, NULL }; #define SANE_VALUE_SCAN_MODE_COLOR_24 SANE_VALUE_SCAN_MODE_COLOR #define SANE_VALUE_SCAN_MODE_COLOR_48 SANE_I18N("Color (48 bits)") #define HAS_WORKING_COLOR_48 1 #define SANE_NAME_LAMP_TIMEOUT "extend-lamp-timeout" #define SANE_TITLE_LAMP_TIMEOUT SANE_I18N("Extend lamp timeout") #define SANE_DESC_LAMP_TIMEOUT SANE_I18N("Extends lamp timeout (from 15 minutes to 1 hour)") #define SANE_NAME_WAIT_FOR_BUTTON "wait-for-button" #define SANE_TITLE_WAIT_FOR_BUTTON SANE_I18N("Wait for button") #define SANE_DESC_WAIT_FOR_BUTTON SANE_I18N("Waits for button before scanning") #define SANE_NAME_BUTTON_PRESSED "button-pressed" #define SANE_TITLE_BUTTON_PRESSED SANE_I18N("Last button pressed") #define SANE_DESC_BUTTON_PRESSED SANE_I18N("Get ID of last button pressed (read only)") #define SANE_NAME_LCD_COUNTER "counter-value" #define SANE_TITLE_LCD_COUNTER SANE_I18N("LCD counter") #define SANE_DESC_LCD_COUNTER SANE_I18N("Get value of LCD counter (read only)") #define SANE_NAME_COLOR_LED "color-led" #define SANE_TITLE_COLOR_LED SANE_I18N("Color LED indicator") #define SANE_DESC_COLOR_LED SANE_I18N("Get value of LED indicator (read only)") #define SANE_NAME_DOC_IN_ADF "doc-in-adf" #define SANE_TITLE_DOC_IN_ADF SANE_I18N("Document available in ADF") #define SANE_DESC_DOC_IN_ADF SANE_I18N("Get state of document-available indicator in ADF (read only)") #define SANE_NAME_OVERWRITE_EOP_PIXEL "hide-eop-pixel" #define SANE_TITLE_OVERWRITE_EOP_PIXEL SANE_I18N("Hide end-of-page pixel") #define SANE_DESC_OVERWRITE_EOP_PIXEL SANE_I18N("Hide end-of-page indicator pixels and overwrite with neighbor pixels") #define SANE_NAME_TRAILING_LINES_MODE "trailing-lines-mode" #define SANE_TITLE_TRAILING_LINES_MODE SANE_I18N("Filling mode of trailing lines after scan data (ADF)") #define SANE_DESC_TRAILING_LINES_MODE SANE_I18N("raw = raw scan data, last = repeat last scan line, raster = b/w raster, "\ "white = white color, black = black color, color = RGB or gray color value") #define SANE_NAME_TRAILING_LINES_COLOR "trailing-lines-color" #define SANE_TITLE_TRAILING_LINES_COLOR SANE_I18N("RGB or gray color value for filling mode 'color'") #define SANE_DESC_TRAILING_LINES_COLOR SANE_I18N("Color value for trailing lines filling mode 'color'. "\ "RGB color as r*65536+256*g+b or gray value (default=violet or gray)") #define BUTTON_PRESSED_VALUE_COUNT 11 #define BUTTON_PRESSED_VALUE_NONE_KEY "none" #define BUTTON_PRESSED_VALUE_POWER_KEY "power" #define BUTTON_PRESSED_VALUE_SCAN_KEY "scan" #define BUTTON_PRESSED_VALUE_COLLECT_KEY "collect" #define BUTTON_PRESSED_VALUE_FILE_KEY "file" #define BUTTON_PRESSED_VALUE_EMAIL_KEY "email" #define BUTTON_PRESSED_VALUE_COPY_KEY "copy" #define BUTTON_PRESSED_VALUE_UP_KEY "up" #define BUTTON_PRESSED_VALUE_DOWN_KEY "down" #define BUTTON_PRESSED_VALUE_MODE_KEY "mode" #define BUTTON_PRESSED_VALUE_CANCEL_KEY "cancel" #define BUTTON_PRESSED_VALUE_MAX_KEY_LEN 32 static SANE_String_Const buttonstate_list[] = { BUTTON_PRESSED_VALUE_NONE_KEY, BUTTON_PRESSED_VALUE_POWER_KEY, BUTTON_PRESSED_VALUE_SCAN_KEY, BUTTON_PRESSED_VALUE_COLLECT_KEY, BUTTON_PRESSED_VALUE_FILE_KEY, BUTTON_PRESSED_VALUE_EMAIL_KEY, BUTTON_PRESSED_VALUE_COPY_KEY, BUTTON_PRESSED_VALUE_UP_KEY, BUTTON_PRESSED_VALUE_DOWN_KEY, BUTTON_PRESSED_VALUE_MODE_KEY, BUTTON_PRESSED_VALUE_CANCEL_KEY, NULL }; #define COLOR_LED_VALUE_COUNT 2 #define COLOR_LED_VALUE_COLOR_KEY "color" #define COLOR_LED_VALUE_BLACKWHITE_KEY "black_white" #define COLOR_LED_VALUE_MAX_KEY_LEN 32 static SANE_String_Const colorledstate_list[] = { COLOR_LED_VALUE_COLOR_KEY, COLOR_LED_VALUE_BLACKWHITE_KEY, NULL }; #define LCD_COUNTER_VALUE_MIN 1 #define LCD_COUNTER_VALUE_MAX 99 #define LCD_COUNTER_VALUE_QUANT 1 static SANE_Range lcd_counter_range = { LCD_COUNTER_VALUE_MIN, LCD_COUNTER_VALUE_MAX, LCD_COUNTER_VALUE_QUANT }; #define TRAILING_LINES_MODE_RAW 0 #define TRAILING_LINES_MODE_LAST 1 #define TRAILING_LINES_MODE_RASTER 2 #define TRAILING_LINES_MODE_WHITE 3 #define TRAILING_LINES_MODE_BLACK 4 #define TRAILING_LINES_MODE_COLOR 5 #define TRAILING_LINES_MODE_VALUE_COUNT 6 #define TRAILING_LINES_MODE_RAW_KEY "raw" #define TRAILING_LINES_MODE_LAST_KEY "last" #define TRAILING_LINES_MODE_RASTER_KEY "raster" #define TRAILING_LINES_MODE_WHITE_KEY "white" #define TRAILING_LINES_MODE_BLACK_KEY "black" #define TRAILING_LINES_MODE_COLOR_KEY "color" #define TRAILING_LINES_MODE_MAX_KEY_LEN 24 static SANE_String_Const trailingmode_list[] = { TRAILING_LINES_MODE_RAW_KEY, TRAILING_LINES_MODE_LAST_KEY, TRAILING_LINES_MODE_RASTER_KEY, TRAILING_LINES_MODE_WHITE_KEY, TRAILING_LINES_MODE_BLACK_KEY, TRAILING_LINES_MODE_COLOR_KEY, NULL }; #define MAX_SCAN_SOURCE_VALUE_LEN 24 #define MAX_SCAN_MODE_VALUE_LEN 24 static SANE_Range range_x, range_y, range_qual; static SANE_String_Const mode_list[] = { SANE_VALUE_SCAN_MODE_COLOR_24, #ifdef HAS_WORKING_COLOR_48 SANE_VALUE_SCAN_MODE_COLOR_48, #endif /* HAS_WORKING_COLOR_48 */ SANE_VALUE_SCAN_MODE_GRAY, SANE_VALUE_SCAN_MODE_LINEART, NULL }; enum hp5590_opt_idx { HP5590_OPT_NUM = 0, HP5590_OPT_TL_X, HP5590_OPT_TL_Y, HP5590_OPT_BR_X, HP5590_OPT_BR_Y, HP5590_OPT_MODE, HP5590_OPT_SOURCE, HP5590_OPT_RESOLUTION, HP5590_OPT_LAMP_TIMEOUT, HP5590_OPT_WAIT_FOR_BUTTON, HP5590_OPT_BUTTON_PRESSED, HP5590_OPT_COLOR_LED, HP5590_OPT_LCD_COUNTER, HP5590_OPT_DOC_IN_ADF, HP5590_OPT_PREVIEW, HP5590_OPT_OVERWRITE_EOP_PIXEL, HP5590_OPT_TRAILING_LINES_MODE, HP5590_OPT_TRAILING_LINES_COLOR, HP5590_OPT_LAST }; struct hp5590_scanner { struct scanner_info *info; enum proto_flags proto_flags; SANE_Device sane; SANE_Int dn; float br_x, br_y, tl_x, tl_y; unsigned int dpi; enum color_depths depth; enum scan_sources source; SANE_Bool extend_lamp_timeout; SANE_Bool wait_for_button; SANE_Bool preview; unsigned int quality; SANE_Option_Descriptor *opts; struct hp5590_scanner *next; unsigned long long image_size; unsigned long long transferred_image_size; void *bulk_read_state; SANE_Bool scanning; SANE_Bool overwrite_eop_pixel; SANE_Byte *eop_last_line_data; unsigned int eop_last_line_data_rpos; SANE_Int eop_trailing_lines_mode; SANE_Int eop_trailing_lines_color; SANE_Byte *adf_next_page_lines_data; unsigned int adf_next_page_lines_data_size; unsigned int adf_next_page_lines_data_rpos; unsigned int adf_next_page_lines_data_wpos; SANE_Byte *one_line_read_buffer; unsigned int one_line_read_buffer_rpos; SANE_Byte *color_shift_line_buffer1; unsigned int color_shift_buffered_lines1; SANE_Byte *color_shift_line_buffer2; unsigned int color_shift_buffered_lines2; }; static struct hp5590_scanner *scanners_list; /******************************************************************************/ static SANE_Status calc_image_params (struct hp5590_scanner *scanner, unsigned int *pixel_bits, unsigned int *pixels_per_line, unsigned int *bytes_per_line, unsigned int *lines, unsigned long long *image_size) { unsigned int _pixel_bits; SANE_Status ret; unsigned int _pixels_per_line; unsigned int _bytes_per_line; unsigned int _lines; unsigned int _image_size; float var; DBG (DBG_proc, "%s\n", __func__); if (!scanner) return SANE_STATUS_INVAL; ret = hp5590_calc_pixel_bits (scanner->dpi, scanner->depth, &_pixel_bits); if (ret != SANE_STATUS_GOOD) return ret; var = (float) (1.0 * (scanner->br_x - scanner->tl_x) * scanner->dpi); _pixels_per_line = var; if (var > _pixels_per_line) _pixels_per_line++; var = (float) (1.0 * (scanner->br_y - scanner->tl_y) * scanner->dpi); _lines = var; if (var > _lines) _lines++; var = (float) (1.0 * _pixels_per_line / 8 * _pixel_bits); _bytes_per_line = var; if (var > _bytes_per_line) _bytes_per_line++; _image_size = (unsigned long long) _lines * _bytes_per_line; DBG (DBG_verbose, "%s: pixel_bits: %u, pixels_per_line: %u, " "bytes_per_line: %u, lines: %u, image_size: %u\n", __func__, _pixel_bits, _pixels_per_line, _bytes_per_line, _lines, _image_size); if (pixel_bits) *pixel_bits = _pixel_bits; if (pixels_per_line) *pixels_per_line = _pixels_per_line; if (bytes_per_line) *bytes_per_line = _bytes_per_line; if (lines) *lines = _lines; if (image_size) *image_size = _image_size; return SANE_STATUS_GOOD; } /******************************************************************************/ static SANE_Status attach_usb_device (SANE_String_Const devname, enum hp_scanner_types hp_scanner_type) { struct scanner_info *info; struct hp5590_scanner *scanner, *ptr; unsigned int max_count, count; SANE_Int dn; SANE_Status ret; const struct hp5590_model *hp5590_model; 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", __func__); ret = hp5590_model_def (hp_scanner_type, &hp5590_model); if (ret != SANE_STATUS_GOOD) return ret; if (hp5590_init_scanner (dn, hp5590_model->proto_flags, &info, hp_scanner_type) != 0) return SANE_STATUS_IO_ERROR; DBG (1, "%s: found HP%s scanner at '%s'\n", __func__, info->model, devname); 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", __func__, max_count); 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", __func__, count); ret = hp5590_read_part_number (dn, hp5590_model->proto_flags); if (ret != SANE_STATUS_GOOD) return ret; ret = hp5590_stop_scan (dn, hp5590_model->proto_flags); if (ret != SANE_STATUS_GOOD) return ret; scanner = malloc (sizeof(struct hp5590_scanner)); if (!scanner) return SANE_STATUS_NO_MEM; memset (scanner, 0, sizeof(struct hp5590_scanner)); scanner->sane.model = info->model; scanner->sane.vendor = "HP"; scanner->sane.type = info->kind; scanner->sane.name = devname; scanner->dn = dn; scanner->proto_flags = hp5590_model->proto_flags; scanner->info = info; scanner->bulk_read_state = NULL; scanner->opts = NULL; scanner->eop_last_line_data = NULL; scanner->eop_last_line_data_rpos = 0; scanner->adf_next_page_lines_data = NULL; scanner->adf_next_page_lines_data_size = 0; scanner->adf_next_page_lines_data_rpos = 0; scanner->adf_next_page_lines_data_wpos = 0; scanner->one_line_read_buffer = NULL; scanner->one_line_read_buffer_rpos = 0; scanner->color_shift_line_buffer1 = NULL; scanner->color_shift_buffered_lines1 = 0; scanner->color_shift_line_buffer2 = NULL; scanner->color_shift_buffered_lines2 = 0; if (!scanners_list) scanners_list = scanner; else { for (ptr = scanners_list; ptr->next; ptr = ptr->next); ptr->next = scanner; } return SANE_STATUS_GOOD; } /******************************************************************************/ static SANE_Status attach_hp4570 (SANE_String_Const devname) { return attach_usb_device (devname, SCANNER_HP4570); } /******************************************************************************/ static SANE_Status attach_hp5550 (SANE_String_Const devname) { return attach_usb_device (devname, SCANNER_HP5550); } /******************************************************************************/ static SANE_Status attach_hp5590 (SANE_String_Const devname) { return attach_usb_device (devname, SCANNER_HP5590); } /******************************************************************************/ static SANE_Status attach_hp7650 (SANE_String_Const devname) { return attach_usb_device (devname, SCANNER_HP7650); } /******************************************************************************/ SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback __sane_unused__ authorize) { SANE_Status ret; SANE_Word vendor_id, product_id; DBG_INIT(); DBG (1, "SANE backed for HP ScanJet 4500C/4570C/5500C/5550C/5590/7650 %u.%u.%u\n", SANE_CURRENT_MAJOR, V_MINOR, BUILD); DBG (1, "(c) Ilia Sotnikov \n"); if (version_code) *version_code = SANE_VERSION_CODE(SANE_CURRENT_MAJOR, V_MINOR, BUILD); sanei_usb_init(); sanei_usb_set_timeout (USB_TIMEOUT); scanners_list = NULL; ret = hp5590_vendor_product_id (SCANNER_HP4570, &vendor_id, &product_id); if (ret != SANE_STATUS_GOOD) return ret; ret = sanei_usb_find_devices (vendor_id, product_id, attach_hp4570); if (ret != SANE_STATUS_GOOD) return ret; ret = hp5590_vendor_product_id (SCANNER_HP5550, &vendor_id, &product_id); if (ret != SANE_STATUS_GOOD) return ret; ret = sanei_usb_find_devices (vendor_id, product_id, attach_hp5550); if (ret != SANE_STATUS_GOOD) return ret; ret = hp5590_vendor_product_id (SCANNER_HP5590, &vendor_id, &product_id); if (ret != SANE_STATUS_GOOD) return ret; ret = sanei_usb_find_devices (vendor_id, product_id, attach_hp5590); if (ret != SANE_STATUS_GOOD) return ret; ret = hp5590_vendor_product_id (SCANNER_HP7650, &vendor_id, &product_id); if (ret != SANE_STATUS_GOOD) return ret; ret = sanei_usb_find_devices (vendor_id, product_id, attach_hp7650); if (ret != SANE_STATUS_GOOD) return ret; return SANE_STATUS_GOOD; } /******************************************************************************/ void sane_exit (void) { struct hp5590_scanner *ptr, *pnext; DBG (DBG_proc, "%s\n", __func__); for (ptr = scanners_list; ptr; ptr = pnext) { if (ptr->opts != NULL) free (ptr->opts); if (ptr->eop_last_line_data != NULL) { free (ptr->eop_last_line_data); ptr->eop_last_line_data = NULL; ptr->eop_last_line_data_rpos = 0; } if (ptr->adf_next_page_lines_data != NULL) { free (ptr->adf_next_page_lines_data); ptr->adf_next_page_lines_data = NULL; ptr->adf_next_page_lines_data_size = 0; ptr->adf_next_page_lines_data_wpos = 0; ptr->adf_next_page_lines_data_rpos = 0; } if (ptr->one_line_read_buffer != NULL) { free (ptr->one_line_read_buffer); ptr->one_line_read_buffer = NULL; ptr->one_line_read_buffer_rpos = 0; } if (ptr->color_shift_line_buffer1 != NULL) { free (ptr->color_shift_line_buffer1); ptr->color_shift_line_buffer1 = NULL; ptr->color_shift_buffered_lines1 = 0; } if (ptr->color_shift_line_buffer2 != NULL) { free (ptr->color_shift_line_buffer2); ptr->color_shift_line_buffer2 = NULL; ptr->color_shift_buffered_lines2 = 0; } pnext = ptr->next; free (ptr); } } /******************************************************************************/ SANE_Status 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", __func__, local_only); if (!device_list) return SANE_STATUS_INVAL; for (found = 0, ptr = scanners_list; ptr; found++, ptr = ptr->next); DBG (1, "Found %u devices\n", found); found++; *device_list = malloc (found * sizeof (SANE_Device)); if (!*device_list) return SANE_STATUS_NO_MEM; memset (*device_list, 0, found * sizeof(SANE_Device)); for (i = 0, ptr = scanners_list; ptr; i++, ptr = ptr->next) { (*device_list)[i] = &(ptr->sane); } return SANE_STATUS_GOOD; } /******************************************************************************/ SANE_Status sane_open (SANE_String_Const devicename, SANE_Handle * handle) { struct hp5590_scanner *ptr; SANE_Option_Descriptor *opts; DBG (DBG_proc, "%s: device name: %s\n", __func__, devicename); if (!handle) return SANE_STATUS_INVAL; /* Allow to open the first available device by specifying zero-length name */ if (!devicename || !devicename[0]) { ptr = scanners_list; } else { for (ptr = scanners_list; ptr && strcmp (ptr->sane.name, devicename) != 0; ptr = ptr->next); } if (!ptr) return SANE_STATUS_INVAL; /* DS: Without this after the first scan (and sane_close) * it was impossible to use again the read_buttons usb routine. * Function sane_close puts dn = -1. Now sane_open needs to open * the usb communication again. */ if (ptr->dn < 0) { DBG (DBG_proc, "%s: Reopening USB device\n", __func__); if (sanei_usb_open (ptr->sane.name, &ptr->dn) != SANE_STATUS_GOOD) return SANE_STATUS_IO_ERROR; DBG (DBG_proc, "%s: USB device reopened\n", __func__); } ptr->tl_x = 0; ptr->tl_y = 0; ptr->br_x = ptr->info->max_size_x; ptr->br_y = ptr->info->max_size_y; ptr->dpi = res_list[1]; ptr->depth = DEPTH_BW; ptr->source = SOURCE_FLATBED; ptr->extend_lamp_timeout = SANE_FALSE; ptr->wait_for_button = SANE_FALSE; ptr->preview = SANE_FALSE; ptr->quality = 4; ptr->image_size = 0; ptr->scanning = SANE_FALSE; ptr->overwrite_eop_pixel = SANE_TRUE; ptr->eop_trailing_lines_mode = TRAILING_LINES_MODE_LAST; ptr->eop_trailing_lines_color = 0x7f007f; *handle = ptr; opts = malloc (sizeof (SANE_Option_Descriptor) * HP5590_OPT_LAST); if (!opts) return SANE_STATUS_NO_MEM; opts[HP5590_OPT_NUM].name = SANE_NAME_NUM_OPTIONS; opts[HP5590_OPT_NUM].title = SANE_TITLE_NUM_OPTIONS; opts[HP5590_OPT_NUM].desc = SANE_DESC_NUM_OPTIONS; opts[HP5590_OPT_NUM].type = SANE_TYPE_INT; opts[HP5590_OPT_NUM].unit = SANE_UNIT_NONE; opts[HP5590_OPT_NUM].size = sizeof(SANE_Word); opts[HP5590_OPT_NUM].cap = SANE_CAP_INACTIVE | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_NUM].constraint_type = SANE_CONSTRAINT_NONE; opts[HP5590_OPT_NUM].constraint.string_list = NULL; range_x.min = SANE_FIX(0); range_x.max = SANE_FIX(ptr->info->max_size_x * 25.4); range_x.quant = SANE_FIX(0.1); range_y.min = SANE_FIX(0); range_y.max = SANE_FIX(ptr->info->max_size_y * 25.4); range_y.quant = SANE_FIX(0.1); range_qual.min = SANE_FIX(4); range_qual.max = SANE_FIX(16); range_qual.quant = SANE_FIX(1); opts[HP5590_OPT_TL_X].name = SANE_NAME_SCAN_TL_X; opts[HP5590_OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; opts[HP5590_OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; opts[HP5590_OPT_TL_X].type = SANE_TYPE_FIXED; opts[HP5590_OPT_TL_X].unit = SANE_UNIT_MM; opts[HP5590_OPT_TL_X].size = sizeof(SANE_Fixed); opts[HP5590_OPT_TL_X].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; opts[HP5590_OPT_TL_X].constraint.range = &range_x; opts[HP5590_OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; opts[HP5590_OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; opts[HP5590_OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; opts[HP5590_OPT_TL_Y].type = SANE_TYPE_FIXED; opts[HP5590_OPT_TL_Y].unit = SANE_UNIT_MM; opts[HP5590_OPT_TL_Y].size = sizeof(SANE_Fixed); opts[HP5590_OPT_TL_Y].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; opts[HP5590_OPT_TL_Y].constraint.range = &range_y; opts[HP5590_OPT_BR_X].name = SANE_NAME_SCAN_BR_X; opts[HP5590_OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; opts[HP5590_OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; opts[HP5590_OPT_BR_X].type = SANE_TYPE_FIXED; opts[HP5590_OPT_BR_X].unit = SANE_UNIT_MM; opts[HP5590_OPT_BR_X].size = sizeof(SANE_Fixed); opts[HP5590_OPT_BR_X].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; opts[HP5590_OPT_BR_X].constraint.range = &range_x; opts[HP5590_OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; opts[HP5590_OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; opts[HP5590_OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; opts[HP5590_OPT_BR_Y].type = SANE_TYPE_FIXED; opts[HP5590_OPT_BR_Y].unit = SANE_UNIT_MM; opts[HP5590_OPT_BR_Y].size = sizeof(SANE_Fixed); opts[HP5590_OPT_BR_Y].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; opts[HP5590_OPT_BR_Y].constraint.range = &range_y; opts[HP5590_OPT_MODE].name = SANE_NAME_SCAN_MODE; opts[HP5590_OPT_MODE].title = SANE_TITLE_SCAN_MODE; opts[HP5590_OPT_MODE].desc = SANE_DESC_SCAN_MODE; opts[HP5590_OPT_MODE].type = SANE_TYPE_STRING; opts[HP5590_OPT_MODE].unit = SANE_UNIT_NONE; opts[HP5590_OPT_MODE].size = MAX_SCAN_MODE_VALUE_LEN; opts[HP5590_OPT_MODE].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; opts[HP5590_OPT_MODE].constraint.string_list = mode_list; /* Show all features, check on feature in command line evaluation. */ opts[HP5590_OPT_SOURCE].name = SANE_NAME_SCAN_SOURCE; opts[HP5590_OPT_SOURCE].title = SANE_TITLE_SCAN_SOURCE; opts[HP5590_OPT_SOURCE].desc = SANE_DESC_SCAN_SOURCE; opts[HP5590_OPT_SOURCE].type = SANE_TYPE_STRING; opts[HP5590_OPT_SOURCE].unit = SANE_UNIT_NONE; opts[HP5590_OPT_SOURCE].size = MAX_SCAN_SOURCE_VALUE_LEN; opts[HP5590_OPT_SOURCE].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_SOURCE].constraint_type = SANE_CONSTRAINT_STRING_LIST; opts[HP5590_OPT_SOURCE].constraint.string_list = sources_list; opts[HP5590_OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; opts[HP5590_OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; opts[HP5590_OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; opts[HP5590_OPT_RESOLUTION].type = SANE_TYPE_INT; opts[HP5590_OPT_RESOLUTION].unit = SANE_UNIT_DPI; opts[HP5590_OPT_RESOLUTION].size = sizeof(SANE_Int); opts[HP5590_OPT_RESOLUTION].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_WORD_LIST; opts[HP5590_OPT_RESOLUTION].constraint.word_list = res_list; opts[HP5590_OPT_LAMP_TIMEOUT].name = SANE_NAME_LAMP_TIMEOUT; opts[HP5590_OPT_LAMP_TIMEOUT].title = SANE_TITLE_LAMP_TIMEOUT; opts[HP5590_OPT_LAMP_TIMEOUT].desc = SANE_DESC_LAMP_TIMEOUT; opts[HP5590_OPT_LAMP_TIMEOUT].type = SANE_TYPE_BOOL; opts[HP5590_OPT_LAMP_TIMEOUT].unit = SANE_UNIT_NONE; opts[HP5590_OPT_LAMP_TIMEOUT].size = sizeof(SANE_Bool); opts[HP5590_OPT_LAMP_TIMEOUT].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; opts[HP5590_OPT_LAMP_TIMEOUT].constraint_type = SANE_CONSTRAINT_NONE; opts[HP5590_OPT_LAMP_TIMEOUT].constraint.string_list = NULL; opts[HP5590_OPT_WAIT_FOR_BUTTON].name = SANE_NAME_WAIT_FOR_BUTTON; opts[HP5590_OPT_WAIT_FOR_BUTTON].title = SANE_TITLE_WAIT_FOR_BUTTON; opts[HP5590_OPT_WAIT_FOR_BUTTON].desc = SANE_DESC_WAIT_FOR_BUTTON; opts[HP5590_OPT_WAIT_FOR_BUTTON].type = SANE_TYPE_BOOL; opts[HP5590_OPT_WAIT_FOR_BUTTON].unit = SANE_UNIT_NONE; opts[HP5590_OPT_WAIT_FOR_BUTTON].size = sizeof(SANE_Bool); opts[HP5590_OPT_WAIT_FOR_BUTTON].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_WAIT_FOR_BUTTON].constraint_type = SANE_CONSTRAINT_NONE; opts[HP5590_OPT_WAIT_FOR_BUTTON].constraint.string_list = NULL; opts[HP5590_OPT_BUTTON_PRESSED].name = SANE_NAME_BUTTON_PRESSED; opts[HP5590_OPT_BUTTON_PRESSED].title = SANE_TITLE_BUTTON_PRESSED; opts[HP5590_OPT_BUTTON_PRESSED].desc = SANE_DESC_BUTTON_PRESSED; opts[HP5590_OPT_BUTTON_PRESSED].type = SANE_TYPE_STRING; opts[HP5590_OPT_BUTTON_PRESSED].unit = SANE_UNIT_NONE; opts[HP5590_OPT_BUTTON_PRESSED].size = BUTTON_PRESSED_VALUE_MAX_KEY_LEN; opts[HP5590_OPT_BUTTON_PRESSED].cap = SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_BUTTON_PRESSED].constraint_type = SANE_CONSTRAINT_STRING_LIST; opts[HP5590_OPT_BUTTON_PRESSED].constraint.string_list = buttonstate_list; opts[HP5590_OPT_COLOR_LED].name = SANE_NAME_COLOR_LED; opts[HP5590_OPT_COLOR_LED].title = SANE_TITLE_COLOR_LED; opts[HP5590_OPT_COLOR_LED].desc = SANE_DESC_COLOR_LED; opts[HP5590_OPT_COLOR_LED].type = SANE_TYPE_STRING; opts[HP5590_OPT_COLOR_LED].unit = SANE_UNIT_NONE; opts[HP5590_OPT_COLOR_LED].size = COLOR_LED_VALUE_MAX_KEY_LEN; opts[HP5590_OPT_COLOR_LED].cap = SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_COLOR_LED].constraint_type = SANE_CONSTRAINT_STRING_LIST; opts[HP5590_OPT_COLOR_LED].constraint.string_list = colorledstate_list; opts[HP5590_OPT_LCD_COUNTER].name = SANE_NAME_LCD_COUNTER; opts[HP5590_OPT_LCD_COUNTER].title = SANE_TITLE_LCD_COUNTER; opts[HP5590_OPT_LCD_COUNTER].desc = SANE_DESC_LCD_COUNTER; opts[HP5590_OPT_LCD_COUNTER].type = SANE_TYPE_INT; opts[HP5590_OPT_LCD_COUNTER].unit = SANE_UNIT_NONE; opts[HP5590_OPT_LCD_COUNTER].size = sizeof(SANE_Int); opts[HP5590_OPT_LCD_COUNTER].cap = SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_LCD_COUNTER].constraint_type = SANE_CONSTRAINT_RANGE; opts[HP5590_OPT_LCD_COUNTER].constraint.range = &lcd_counter_range; opts[HP5590_OPT_DOC_IN_ADF].name = SANE_NAME_DOC_IN_ADF; opts[HP5590_OPT_DOC_IN_ADF].title = SANE_TITLE_DOC_IN_ADF; opts[HP5590_OPT_DOC_IN_ADF].desc = SANE_DESC_DOC_IN_ADF; opts[HP5590_OPT_DOC_IN_ADF].type = SANE_TYPE_BOOL; opts[HP5590_OPT_DOC_IN_ADF].unit = SANE_UNIT_NONE; opts[HP5590_OPT_DOC_IN_ADF].size = sizeof(SANE_Bool); opts[HP5590_OPT_DOC_IN_ADF].cap = SANE_CAP_HARD_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_DOC_IN_ADF].constraint_type = SANE_CONSTRAINT_NONE; opts[HP5590_OPT_DOC_IN_ADF].constraint.range = NULL; opts[HP5590_OPT_PREVIEW].name = SANE_NAME_PREVIEW; opts[HP5590_OPT_PREVIEW].title = SANE_TITLE_PREVIEW; opts[HP5590_OPT_PREVIEW].desc = SANE_DESC_PREVIEW; opts[HP5590_OPT_PREVIEW].type = SANE_TYPE_BOOL; opts[HP5590_OPT_PREVIEW].unit = SANE_UNIT_NONE; opts[HP5590_OPT_PREVIEW].size = sizeof(SANE_Bool); opts[HP5590_OPT_PREVIEW].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; opts[HP5590_OPT_PREVIEW].constraint_type = SANE_CONSTRAINT_NONE; opts[HP5590_OPT_PREVIEW].constraint.string_list = NULL; opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].name = SANE_NAME_OVERWRITE_EOP_PIXEL; opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].title = SANE_TITLE_OVERWRITE_EOP_PIXEL; opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].desc = SANE_DESC_OVERWRITE_EOP_PIXEL; opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].type = SANE_TYPE_BOOL; opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].unit = SANE_UNIT_NONE; opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].size = sizeof(SANE_Bool); opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].constraint_type = SANE_CONSTRAINT_NONE; opts[HP5590_OPT_OVERWRITE_EOP_PIXEL].constraint.string_list = NULL; opts[HP5590_OPT_TRAILING_LINES_MODE].name = SANE_NAME_TRAILING_LINES_MODE; opts[HP5590_OPT_TRAILING_LINES_MODE].title = SANE_TITLE_TRAILING_LINES_MODE; opts[HP5590_OPT_TRAILING_LINES_MODE].desc = SANE_DESC_TRAILING_LINES_MODE; opts[HP5590_OPT_TRAILING_LINES_MODE].type = SANE_TYPE_STRING; opts[HP5590_OPT_TRAILING_LINES_MODE].unit = SANE_UNIT_NONE; opts[HP5590_OPT_TRAILING_LINES_MODE].size = TRAILING_LINES_MODE_MAX_KEY_LEN; opts[HP5590_OPT_TRAILING_LINES_MODE].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; opts[HP5590_OPT_TRAILING_LINES_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; opts[HP5590_OPT_TRAILING_LINES_MODE].constraint.string_list = trailingmode_list; opts[HP5590_OPT_TRAILING_LINES_COLOR].name = SANE_NAME_TRAILING_LINES_COLOR; opts[HP5590_OPT_TRAILING_LINES_COLOR].title = SANE_TITLE_TRAILING_LINES_COLOR; opts[HP5590_OPT_TRAILING_LINES_COLOR].desc = SANE_DESC_TRAILING_LINES_COLOR; opts[HP5590_OPT_TRAILING_LINES_COLOR].type = SANE_TYPE_INT; opts[HP5590_OPT_TRAILING_LINES_COLOR].unit = SANE_UNIT_NONE; opts[HP5590_OPT_TRAILING_LINES_COLOR].size = sizeof(SANE_Int); opts[HP5590_OPT_TRAILING_LINES_COLOR].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT | SANE_CAP_ADVANCED; opts[HP5590_OPT_TRAILING_LINES_COLOR].constraint_type = SANE_CONSTRAINT_NONE; opts[HP5590_OPT_TRAILING_LINES_COLOR].constraint.string_list = NULL; ptr->opts = opts; return SANE_STATUS_GOOD; } /******************************************************************************/ void sane_close (SANE_Handle handle) { struct hp5590_scanner *scanner = handle; DBG (DBG_proc, "%s\n", __func__); sanei_usb_close (scanner->dn); scanner->dn = -1; } /******************************************************************************/ const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) { struct hp5590_scanner *scanner = handle; DBG (DBG_proc, "%s, option: %u\n", __func__, option); if (option >= HP5590_OPT_LAST) return NULL; return &scanner->opts[option]; } /*************************************DS:Support function read buttons status */ SANE_Status read_button_pressed(SANE_Handle handle, enum button_status * button_pressed) { struct hp5590_scanner * scanner = handle; *button_pressed = BUTTON_NONE; enum button_status status = BUTTON_NONE; DBG (DBG_verbose, "%s: Checking button status (device_number = %u) (device_name = %s)\n", __func__, scanner->dn, scanner->sane.name); SANE_Status ret = hp5590_read_buttons (scanner->dn, scanner->proto_flags, &status); if (ret != SANE_STATUS_GOOD) { DBG (DBG_proc, "%s: Error reading button status (%u)\n", __func__, ret); return ret; } DBG (DBG_verbose, "%s: Button pressed = %d\n", __func__, status); *button_pressed = status; return SANE_STATUS_GOOD; } /******************************************************************************/ SANE_Status read_lcd_and_led_values(SANE_Handle handle, SANE_Int * lcd_counter, enum color_led_status * color_led) { struct hp5590_scanner * scanner = handle; *lcd_counter = 1; *color_led = LED_COLOR; DBG (DBG_verbose, "%s: Reading LCD and LED values (device_number = %u) (device_name = %s)\n", __func__, scanner->dn, scanner->sane.name); SANE_Status ret = hp5590_read_lcd_and_led (scanner->dn, scanner->proto_flags, lcd_counter, color_led); if (ret != SANE_STATUS_GOOD) { DBG (DBG_proc, "%s: Error reading LCD and LED values (%u)\n", __func__, ret); return ret; } DBG (DBG_verbose, "%s: LCD = %d, LED = %s\n", __func__, *lcd_counter, *color_led == LED_BLACKWHITE ? COLOR_LED_VALUE_BLACKWHITE_KEY : COLOR_LED_VALUE_COLOR_KEY); return SANE_STATUS_GOOD; } /******************************************************************************/ SANE_Status read_doc_in_adf_value(SANE_Handle handle, SANE_Bool * doc_in_adf) { struct hp5590_scanner * scanner = handle; DBG (DBG_verbose, "%s: Reading state of document-available in ADF (device_number = %u) (device_name = %s)\n", __func__, scanner->dn, scanner->sane.name); SANE_Status ret = hp5590_is_data_available (scanner->dn, scanner->proto_flags); if (ret == SANE_STATUS_GOOD) *doc_in_adf = SANE_TRUE; else if (ret == SANE_STATUS_NO_DOCS) *doc_in_adf = SANE_FALSE; else { DBG (DBG_proc, "%s: Error reading state of document-available in ADF (%u)\n", __func__, ret); return ret; } DBG (DBG_verbose, "%s: doc_in_adf = %s\n", __func__, *doc_in_adf == SANE_FALSE ? "false" : "true"); return SANE_STATUS_GOOD; } /******************************************************************************/ SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int * info) { struct hp5590_scanner *scanner = handle; if (!value) return SANE_STATUS_INVAL; if (!handle) return SANE_STATUS_INVAL; if (option >= HP5590_OPT_LAST) return SANE_STATUS_INVAL; if (action == SANE_ACTION_GET_VALUE) { if (option == HP5590_OPT_NUM) { DBG(3, "%s: get total number of options - %u\n", __func__, HP5590_OPT_LAST); *((SANE_Int *) value) = HP5590_OPT_LAST; return SANE_STATUS_GOOD; } if (!scanner->opts) return SANE_STATUS_INVAL; DBG (DBG_proc, "%s: get option '%s' value\n", __func__, scanner->opts[option].name); if (option == HP5590_OPT_BR_X) { *(SANE_Fixed *) value = SANE_FIX (scanner->br_x * 25.4); } if (option == HP5590_OPT_BR_Y) { *(SANE_Fixed *) value = SANE_FIX (scanner->br_y * 25.4); } if (option == HP5590_OPT_TL_X) { *(SANE_Fixed *) value = SANE_FIX ((scanner->tl_x) * 25.4); } if (option == HP5590_OPT_TL_Y) { *(SANE_Fixed *) value = SANE_FIX (scanner->tl_y * 25.4); } if (option == HP5590_OPT_MODE) { switch (scanner->depth) { case DEPTH_BW: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_MODE_LINEART, strlen (SANE_VALUE_SCAN_MODE_LINEART)); break; case DEPTH_GRAY: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_MODE_GRAY, strlen (SANE_VALUE_SCAN_MODE_GRAY)); break; case DEPTH_COLOR_24: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_MODE_COLOR_24, strlen (SANE_VALUE_SCAN_MODE_COLOR_24)); break; case DEPTH_COLOR_48: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_MODE_COLOR_48, strlen (SANE_VALUE_SCAN_MODE_COLOR_48)); break; default: return SANE_STATUS_INVAL; } } if (option == HP5590_OPT_SOURCE) { switch (scanner->source) { case SOURCE_FLATBED: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_SOURCE_FLATBED, strlen (SANE_VALUE_SCAN_SOURCE_FLATBED)); break; case SOURCE_ADF: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_SOURCE_ADF, strlen (SANE_VALUE_SCAN_SOURCE_ADF)); break; case SOURCE_ADF_DUPLEX: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_SOURCE_ADF_DUPLEX, strlen (SANE_VALUE_SCAN_SOURCE_ADF_DUPLEX)); break; case SOURCE_TMA_SLIDES: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_SOURCE_TMA_SLIDES, strlen (SANE_VALUE_SCAN_SOURCE_TMA_SLIDES)); break; case SOURCE_TMA_NEGATIVES: memset (value , 0, scanner->opts[option].size); memcpy (value, SANE_VALUE_SCAN_SOURCE_TMA_NEGATIVES, strlen (SANE_VALUE_SCAN_SOURCE_TMA_NEGATIVES)); break; case SOURCE_NONE: default: return SANE_STATUS_INVAL; } } if (option == HP5590_OPT_RESOLUTION) { *(SANE_Int *) value = scanner->dpi; } if (option == HP5590_OPT_LAMP_TIMEOUT) { *(SANE_Bool *) value = scanner->extend_lamp_timeout; } if (option == HP5590_OPT_WAIT_FOR_BUTTON) { *(SANE_Bool *) value = scanner->wait_for_button; } if (option == HP5590_OPT_BUTTON_PRESSED) { enum button_status button_pressed = BUTTON_NONE; SANE_Status ret = read_button_pressed(scanner, &button_pressed); if (ret != SANE_STATUS_GOOD) return ret; switch (button_pressed) { case BUTTON_POWER: strncpy (value, BUTTON_PRESSED_VALUE_POWER_KEY, scanner->opts[option].size); break; case BUTTON_SCAN: strncpy (value, BUTTON_PRESSED_VALUE_SCAN_KEY, scanner->opts[option].size); break; case BUTTON_COLLECT: strncpy (value, BUTTON_PRESSED_VALUE_COLLECT_KEY, scanner->opts[option].size); break; case BUTTON_FILE: strncpy (value, BUTTON_PRESSED_VALUE_FILE_KEY, scanner->opts[option].size); break; case BUTTON_EMAIL: strncpy (value, BUTTON_PRESSED_VALUE_EMAIL_KEY, scanner->opts[option].size); break; case BUTTON_COPY: strncpy (value, BUTTON_PRESSED_VALUE_COPY_KEY, scanner->opts[option].size); break; case BUTTON_UP: strncpy (value, BUTTON_PRESSED_VALUE_UP_KEY, scanner->opts[option].size); break; case BUTTON_DOWN: strncpy (value, BUTTON_PRESSED_VALUE_DOWN_KEY, scanner->opts[option].size); break; case BUTTON_MODE: strncpy (value, BUTTON_PRESSED_VALUE_MODE_KEY, scanner->opts[option].size); break; case BUTTON_CANCEL: strncpy (value, BUTTON_PRESSED_VALUE_CANCEL_KEY, scanner->opts[option].size); break; case BUTTON_NONE: default: strncpy (value, BUTTON_PRESSED_VALUE_NONE_KEY, scanner->opts[option].size); } } if (option == HP5590_OPT_COLOR_LED) { SANE_Int lcd_counter = 0; enum color_led_status color_led = LED_COLOR; SANE_Status ret = read_lcd_and_led_values(scanner, &lcd_counter, &color_led); if (ret != SANE_STATUS_GOOD) return ret; switch (color_led) { case LED_BLACKWHITE: strncpy (value, COLOR_LED_VALUE_BLACKWHITE_KEY, scanner->opts[option].size); break; case LED_COLOR: default: strncpy (value, COLOR_LED_VALUE_COLOR_KEY, scanner->opts[option].size); } } if (option == HP5590_OPT_LCD_COUNTER) { SANE_Int lcd_counter = 0; enum color_led_status color_led = LED_COLOR; SANE_Status ret = read_lcd_and_led_values(scanner, &lcd_counter, &color_led); if (ret != SANE_STATUS_GOOD) return ret; *(SANE_Int *) value = lcd_counter; } if (option == HP5590_OPT_DOC_IN_ADF) { SANE_Bool doc_in_adf = SANE_FALSE; SANE_Status ret = read_doc_in_adf_value(scanner, &doc_in_adf); if (ret != SANE_STATUS_GOOD) return ret; *(SANE_Bool *) value = doc_in_adf; } if (option == HP5590_OPT_PREVIEW) { *(SANE_Bool *) value = scanner->preview; } if (option == HP5590_OPT_OVERWRITE_EOP_PIXEL) { *(SANE_Bool *) value = scanner->overwrite_eop_pixel; } if (option == HP5590_OPT_TRAILING_LINES_MODE) { switch (scanner->eop_trailing_lines_mode) { case TRAILING_LINES_MODE_RAW: memset (value , 0, scanner->opts[option].size); memcpy (value, TRAILING_LINES_MODE_RAW_KEY, strlen (TRAILING_LINES_MODE_RAW_KEY)); break; case TRAILING_LINES_MODE_LAST: memset (value , 0, scanner->opts[option].size); memcpy (value, TRAILING_LINES_MODE_LAST_KEY, strlen (TRAILING_LINES_MODE_LAST_KEY)); break; case TRAILING_LINES_MODE_RASTER: memset (value , 0, scanner->opts[option].size); memcpy (value, TRAILING_LINES_MODE_RASTER_KEY, strlen (TRAILING_LINES_MODE_RASTER_KEY)); break; case TRAILING_LINES_MODE_BLACK: memset (value , 0, scanner->opts[option].size); memcpy (value, TRAILING_LINES_MODE_BLACK_KEY, strlen (TRAILING_LINES_MODE_BLACK_KEY)); break; case TRAILING_LINES_MODE_WHITE: memset (value , 0, scanner->opts[option].size); memcpy (value, TRAILING_LINES_MODE_WHITE_KEY, strlen (TRAILING_LINES_MODE_WHITE_KEY)); break; case TRAILING_LINES_MODE_COLOR: memset (value , 0, scanner->opts[option].size); memcpy (value, TRAILING_LINES_MODE_COLOR_KEY, strlen (TRAILING_LINES_MODE_COLOR_KEY)); break; default: return SANE_STATUS_INVAL; } } if (option == HP5590_OPT_TRAILING_LINES_COLOR) { *(SANE_Int *) value = scanner->eop_trailing_lines_color; } } if (action == SANE_ACTION_SET_VALUE) { if (option == HP5590_OPT_NUM) return SANE_STATUS_INVAL; if (option == HP5590_OPT_BR_X) { float val = SANE_UNFIX(*(SANE_Fixed *) value) / 25.4; if (val <= scanner->tl_x) return SANE_STATUS_GOOD; scanner->br_x = val; if (info) *info = SANE_INFO_RELOAD_PARAMS; } if (option == HP5590_OPT_BR_Y) { float val = SANE_UNFIX(*(SANE_Fixed *) value) / 25.4; if (val <= scanner->tl_y) return SANE_STATUS_GOOD; scanner->br_y = val; if (info) *info = SANE_INFO_RELOAD_PARAMS; } if (option == HP5590_OPT_TL_X) { float val = SANE_UNFIX(*(SANE_Fixed *) value) / 25.4; if (val >= scanner->br_x) return SANE_STATUS_GOOD; scanner->tl_x = val; if (info) *info = SANE_INFO_RELOAD_PARAMS; } if (option == HP5590_OPT_TL_Y) { float val = SANE_UNFIX(*(SANE_Fixed *) value) / 25.4; if (val >= scanner->br_y) return SANE_STATUS_GOOD; scanner->tl_y = val; if (info) *info = SANE_INFO_RELOAD_PARAMS; } if (option == HP5590_OPT_MODE) { if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_MODE_LINEART) == 0) { scanner->depth = DEPTH_BW; } else if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_MODE_GRAY) == 0) { scanner->depth = DEPTH_GRAY; } else if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_MODE_COLOR_24) == 0) { scanner->depth = DEPTH_COLOR_24; } else if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_MODE_COLOR_48) == 0) { scanner->depth = DEPTH_COLOR_48; } else { return SANE_STATUS_INVAL; } if (info) *info = SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } if (option == HP5590_OPT_SOURCE) { range_y.max = SANE_FIX(scanner->info->max_size_y * 25.4); if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_SOURCE_FLATBED) == 0) { scanner->source = SOURCE_FLATBED; range_x.max = SANE_FIX(scanner->info->max_size_x * 25.4); range_y.max = SANE_FIX(scanner->info->max_size_y * 25.4); scanner->br_x = scanner->info->max_size_x; scanner->br_y = scanner->info->max_size_y; } else if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_SOURCE_ADF) == 0) { /* In ADF modes the device can scan up to ADF_MAX_Y_INCHES, which is usually * bigger than what scanner reports back during initialization */ if (! (scanner->info->features & FEATURE_ADF)) { DBG(DBG_err, "ADF feature not available: %s\n", (char *) value); return SANE_STATUS_UNSUPPORTED; } scanner->source = SOURCE_ADF; range_x.max = SANE_FIX(scanner->info->max_size_x * 25.4); range_y.max = SANE_FIX(ADF_MAX_Y_INCHES * 25.4); scanner->br_x = scanner->info->max_size_x; scanner->br_y = ADF_MAX_Y_INCHES; } else if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_SOURCE_ADF_DUPLEX) == 0) { if (! (scanner->info->features & FEATURE_ADF)) { DBG(DBG_err, "ADF feature not available: %s\n", (char *) value); return SANE_STATUS_UNSUPPORTED; } scanner->source = SOURCE_ADF_DUPLEX; range_x.max = SANE_FIX(scanner->info->max_size_x * 25.4); range_y.max = SANE_FIX(ADF_MAX_Y_INCHES * 25.4); scanner->br_x = scanner->info->max_size_x; scanner->br_y = ADF_MAX_Y_INCHES; } else if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_SOURCE_TMA_SLIDES) == 0) { if (! (scanner->info->features & FEATURE_TMA)) { DBG(DBG_err, "TMA feature not available: %s\n", (char *) value); return SANE_STATUS_UNSUPPORTED; } scanner->source = SOURCE_TMA_SLIDES; range_x.max = SANE_FIX(TMA_MAX_X_INCHES * 25.4); range_y.max = SANE_FIX(TMA_MAX_Y_INCHES * 25.4); scanner->br_x = TMA_MAX_X_INCHES; scanner->br_y = TMA_MAX_Y_INCHES; } else if (strcmp ((char *) value, (char *) SANE_VALUE_SCAN_SOURCE_TMA_NEGATIVES) == 0) { if (! (scanner->info->features & FEATURE_TMA)) { DBG(DBG_err, "TMA feature not available: %s\n", (char *) value); return SANE_STATUS_UNSUPPORTED; } scanner->source = SOURCE_TMA_NEGATIVES; range_x.max = SANE_FIX(TMA_MAX_X_INCHES * 25.4); range_y.max = SANE_FIX(TMA_MAX_Y_INCHES * 25.4); scanner->br_x = TMA_MAX_X_INCHES; scanner->br_y = TMA_MAX_Y_INCHES; } else { return SANE_STATUS_INVAL; } if (info) *info = SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS; } if (option == HP5590_OPT_RESOLUTION) { scanner->dpi = *(SANE_Int *) value; if (info) *info = SANE_INFO_RELOAD_PARAMS; } if (option == HP5590_OPT_LAMP_TIMEOUT) { scanner->extend_lamp_timeout = *(SANE_Bool *) value; } if (option == HP5590_OPT_WAIT_FOR_BUTTON) { scanner->wait_for_button = *(SANE_Bool *) value; } if (option == HP5590_OPT_BUTTON_PRESSED) { DBG(DBG_verbose, "State of buttons is read only. Setting of state will be ignored.\n"); } if (option == HP5590_OPT_COLOR_LED) { DBG(DBG_verbose, "State of color LED indicator is read only. Setting of state will be ignored.\n"); } if (option == HP5590_OPT_LCD_COUNTER) { DBG(DBG_verbose, "Value of LCD counter is read only. Setting of value will be ignored.\n"); } if (option == HP5590_OPT_DOC_IN_ADF) { DBG(DBG_verbose, "Value of document-available indicator is read only. Setting of value will be ignored.\n"); } if (option == HP5590_OPT_PREVIEW) { scanner->preview = *(SANE_Bool *) value; } if (option == HP5590_OPT_OVERWRITE_EOP_PIXEL) { scanner->overwrite_eop_pixel = *(SANE_Bool *) value; } if (option == HP5590_OPT_TRAILING_LINES_MODE) { if (strcmp ((char *) value, (char *) TRAILING_LINES_MODE_RAW_KEY) == 0) scanner->eop_trailing_lines_mode = TRAILING_LINES_MODE_RAW; if (strcmp ((char *) value, (char *) TRAILING_LINES_MODE_LAST_KEY) == 0) scanner->eop_trailing_lines_mode = TRAILING_LINES_MODE_LAST; if (strcmp ((char *) value, (char *) TRAILING_LINES_MODE_RASTER_KEY) == 0) scanner->eop_trailing_lines_mode = TRAILING_LINES_MODE_RASTER; if (strcmp ((char *) value, (char *) TRAILING_LINES_MODE_BLACK_KEY) == 0) scanner->eop_trailing_lines_mode = TRAILING_LINES_MODE_BLACK; if (strcmp ((char *) value, (char *) TRAILING_LINES_MODE_WHITE_KEY) == 0) scanner->eop_trailing_lines_mode = TRAILING_LINES_MODE_WHITE; if (strcmp ((char *) value, (char *) TRAILING_LINES_MODE_COLOR_KEY) == 0) scanner->eop_trailing_lines_mode = TRAILING_LINES_MODE_COLOR; } if (option == HP5590_OPT_TRAILING_LINES_COLOR) { scanner->eop_trailing_lines_color = *(SANE_Int *) value; } } return SANE_STATUS_GOOD; } /******************************************************************************/ SANE_Status sane_get_parameters (SANE_Handle handle, SANE_Parameters * params) { struct hp5590_scanner *scanner = handle; SANE_Status ret; unsigned int pixel_bits; DBG (DBG_proc, "%s\n", __func__); if (!params) return SANE_STATUS_INVAL; if (!handle) return SANE_STATUS_INVAL; ret = calc_image_params (scanner, (unsigned int *) &pixel_bits, (unsigned int *) ¶ms->pixels_per_line, (unsigned int *) ¶ms->bytes_per_line, (unsigned int *) ¶ms->lines, NULL); if (ret != SANE_STATUS_GOOD) return ret; switch (scanner->depth) { case DEPTH_BW: params->depth = pixel_bits; params->format = SANE_FRAME_GRAY; params->last_frame = SANE_TRUE; break; case DEPTH_GRAY: params->depth = pixel_bits; params->format = SANE_FRAME_GRAY; params->last_frame = SANE_TRUE; break; case DEPTH_COLOR_24: params->depth = pixel_bits / 3; params->last_frame = SANE_TRUE; params->format = SANE_FRAME_RGB; break; case DEPTH_COLOR_48: params->depth = pixel_bits / 3; params->last_frame = SANE_TRUE; params->format = SANE_FRAME_RGB; break; default: DBG(DBG_err, "%s: Unknown depth\n", __func__); return SANE_STATUS_INVAL; } DBG (DBG_proc, "format: %u, last_frame: %u, bytes_per_line: %u, " "pixels_per_line: %u, lines: %u, depth: %u\n", params->format, params->last_frame, params->bytes_per_line, params->pixels_per_line, params->lines, params->depth); return SANE_STATUS_GOOD; } /******************************************************************************/ SANE_Status sane_start (SANE_Handle handle) { struct hp5590_scanner *scanner = handle; SANE_Status ret; unsigned int bytes_per_line; DBG (DBG_proc, "%s\n", __func__); if (!scanner) return SANE_STATUS_INVAL; /* Cleanup for all pages. */ if (scanner->eop_last_line_data) { /* Release last line data */ free (scanner->eop_last_line_data); scanner->eop_last_line_data = NULL; scanner->eop_last_line_data_rpos = 0; } if (scanner->one_line_read_buffer) { /* Release temporary line buffer. */ free (scanner->one_line_read_buffer); scanner->one_line_read_buffer = NULL; scanner->one_line_read_buffer_rpos = 0; } if (scanner->color_shift_line_buffer1) { /* Release line buffer1 for shifting colors. */ free (scanner->color_shift_line_buffer1); scanner->color_shift_line_buffer1 = NULL; scanner->color_shift_buffered_lines1 = 0; } if (scanner->color_shift_line_buffer2) { /* Release line buffer2 for shifting colors. */ free (scanner->color_shift_line_buffer2); scanner->color_shift_line_buffer2 = NULL; scanner->color_shift_buffered_lines2 = 0; } if ( scanner->scanning == SANE_TRUE && ( scanner->source == SOURCE_ADF || scanner->source == SOURCE_ADF_DUPLEX)) { DBG (DBG_verbose, "%s: Scanner is scanning, check if more data is available\n", __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", __func__); scanner->transferred_image_size = scanner->image_size; return SANE_STATUS_GOOD; } if (ret != SANE_STATUS_NO_DOCS) return ret; } sane_cancel (handle); if (scanner->wait_for_button) { enum button_status status; for (;;) { ret = hp5590_read_buttons (scanner->dn, scanner->proto_flags, &status); if (ret != SANE_STATUS_GOOD) return ret; if (status == BUTTON_CANCEL) return SANE_STATUS_CANCELLED; if (status != BUTTON_NONE && status != BUTTON_POWER) break; usleep (100 * 1000); } } DBG (DBG_verbose, "Init scanner\n"); ret = hp5590_init_scanner (scanner->dn, scanner->proto_flags, NULL, SCANNER_NONE); if (ret != SANE_STATUS_GOOD) return ret; ret = hp5590_power_status (scanner->dn, scanner->proto_flags); if (ret != SANE_STATUS_GOOD) return ret; DBG (DBG_verbose, "Wakeup\n"); ret = hp5590_select_source_and_wakeup (scanner->dn, scanner->proto_flags, scanner->source, scanner->extend_lamp_timeout); if (ret != SANE_STATUS_GOOD) return ret; ret = hp5590_set_scan_params (scanner->dn, scanner->proto_flags, scanner->info, scanner->tl_x * scanner->dpi, scanner->tl_y * scanner->dpi, (scanner->br_x - scanner->tl_x) * scanner->dpi, (scanner->br_y - scanner->tl_y) * scanner->dpi, scanner->dpi, scanner->depth, scanner->preview ? MODE_PREVIEW : MODE_NORMAL, scanner->source); if (ret != SANE_STATUS_GOOD) { hp5590_reset_scan_head (scanner->dn, scanner->proto_flags); return ret; } ret = calc_image_params (scanner, NULL, NULL, &bytes_per_line, NULL, &scanner->image_size); if (ret != SANE_STATUS_GOOD) { hp5590_reset_scan_head (scanner->dn, scanner->proto_flags); return ret; } scanner->transferred_image_size = scanner->image_size; if ( scanner->depth == DEPTH_COLOR_24 || scanner->depth == DEPTH_COLOR_48) { DBG (1, "Color 24/48 bits: checking if image size is correctly " "aligned on number of colors\n"); if (bytes_per_line % 3) { DBG (DBG_err, "Color 24/48 bits: image size doesn't lined up on number of colors (3) " "(image size: %llu, bytes per line %u)\n", scanner->image_size, bytes_per_line); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags); return SANE_STATUS_INVAL; } DBG (1, "Color 24/48 bits: image size is correctly aligned on number of colors " "(image size: %llu, bytes per line %u)\n", scanner->image_size, bytes_per_line); DBG (1, "Color 24/48 bits: checking if image size is correctly " "aligned on bytes per line\n"); if (scanner->image_size % bytes_per_line) { DBG (DBG_err, "Color 24/48 bits: image size doesn't lined up on bytes per line " "(image size: %llu, bytes per line %u)\n", scanner->image_size, bytes_per_line); hp5590_reset_scan_head (scanner->dn, scanner->proto_flags); return SANE_STATUS_INVAL; } DBG (1, "Color 24/48 bits: image size correctly aligned on bytes per line " "(images size: %llu, bytes per line: %u)\n", scanner->image_size, bytes_per_line); } DBG (DBG_verbose, "Final image size: %llu\n", scanner->image_size); DBG (DBG_verbose, "Reverse calibration maps\n"); ret = hp5590_send_reverse_calibration_map (scanner->dn, scanner->proto_flags); if (ret != SANE_STATUS_GOOD) { hp5590_reset_scan_head (scanner->dn, scanner->proto_flags); return ret; } DBG (DBG_verbose, "Forward calibration maps\n"); ret = hp5590_send_forward_calibration_maps (scanner->dn, scanner->proto_flags); if (ret != SANE_STATUS_GOOD) { hp5590_reset_scan_head (scanner->dn, scanner->proto_flags); return ret; } if (scanner->adf_next_page_lines_data) { free (scanner->adf_next_page_lines_data); scanner->adf_next_page_lines_data = NULL; scanner->adf_next_page_lines_data_size = 0; scanner->adf_next_page_lines_data_rpos = 0; scanner->adf_next_page_lines_data_wpos = 0; } scanner->scanning = SANE_TRUE; DBG (DBG_verbose, "Starting scan\n"); ret = hp5590_start_scan (scanner->dn, scanner->proto_flags); /* Check for paper jam */ if ( ret == SANE_STATUS_DEVICE_BUSY && ( scanner->source == SOURCE_ADF || scanner->source == SOURCE_ADF_DUPLEX)) return SANE_STATUS_JAMMED; if (ret != SANE_STATUS_GOOD) { hp5590_reset_scan_head (scanner->dn, scanner->proto_flags); return ret; } return SANE_STATUS_GOOD; } /******************************************************************************/ static void invert_negative_colors (unsigned char *buf, unsigned int bytes_per_line, struct hp5590_scanner *scanner) { /* Invert lineart or negatives. */ int is_linear = (scanner->depth == DEPTH_BW); int is_negative = (scanner->source == SOURCE_TMA_NEGATIVES); if (is_linear ^ is_negative) { for (unsigned int k = 0; k < bytes_per_line; k++) buf[k] ^= 0xff; } } /******************************************************************************/ static SANE_Status convert_gray_and_lineart (struct hp5590_scanner *scanner, SANE_Byte *data, SANE_Int size) { unsigned int pixels_per_line; unsigned int pixel_bits; unsigned int bytes_per_line; unsigned int lines; unsigned char *buf; SANE_Status ret; hp5590_assert (scanner != NULL); hp5590_assert (data != NULL); if ( ! (scanner->depth == DEPTH_BW || scanner->depth == DEPTH_GRAY)) return SANE_STATUS_GOOD; DBG (DBG_proc, "%s\n", __func__); ret = calc_image_params (scanner, &pixel_bits, &pixels_per_line, &bytes_per_line, NULL, NULL); if (ret != SANE_STATUS_GOOD) return ret; lines = size / bytes_per_line; buf = data; for (unsigned int i = 0; i < lines; buf += bytes_per_line, ++i) { if (! scanner->eop_last_line_data) { if (pixels_per_line > 0) { /* Test for last-line indicator pixel. If found, store last line * and optionally overwrite indicator pixel with neighbor value. */ unsigned int j = bytes_per_line - 1; int eop_found = 0; if (scanner->depth == DEPTH_GRAY) { eop_found = (buf[j] != 0); if (scanner->overwrite_eop_pixel && (j > 0)) { buf[j] = buf[j-1]; } } else if (scanner->depth == DEPTH_BW) { eop_found = (buf[j] != 0); if (scanner->overwrite_eop_pixel && (j > 0)) { buf[j] = (buf[j-1] & 0x01) ? 0xff : 0; } } invert_negative_colors (buf, bytes_per_line, scanner); if (eop_found && (! scanner->eop_last_line_data)) { DBG (DBG_verbose, "Found end-of-page at line %u in reading block.\n", i); scanner->eop_last_line_data = malloc(bytes_per_line); if (! scanner->eop_last_line_data) return SANE_STATUS_NO_MEM; memcpy (scanner->eop_last_line_data, buf, bytes_per_line); scanner->eop_last_line_data_rpos = 0; /* Fill trailing line buffer with requested color. */ if (scanner->eop_trailing_lines_mode == TRAILING_LINES_MODE_RASTER) { /* Black-white raster. */ if (scanner->depth == DEPTH_BW) { memset (scanner->eop_last_line_data, 0xaa, bytes_per_line); } else { /* Gray. */ for (unsigned int k = 0; k < bytes_per_line; ++k) { scanner->eop_last_line_data[k] = (k & 1 ? 0xff : 0); } } } else if (scanner->eop_trailing_lines_mode == TRAILING_LINES_MODE_WHITE) { /* White. */ if (scanner->depth == DEPTH_BW) { memset (scanner->eop_last_line_data, 0x00, bytes_per_line); } else { memset (scanner->eop_last_line_data, 0xff, bytes_per_line); } } else if (scanner->eop_trailing_lines_mode == TRAILING_LINES_MODE_BLACK) { /* Black. */ if (scanner->depth == DEPTH_BW) { memset (scanner->eop_last_line_data, 0xff, bytes_per_line); } else { memset (scanner->eop_last_line_data, 0x00, bytes_per_line); } } else if (scanner->eop_trailing_lines_mode == TRAILING_LINES_MODE_COLOR) { if (scanner->depth == DEPTH_BW) { /* Black or white. */ memset (scanner->eop_last_line_data, scanner->eop_trailing_lines_color & 0x01 ? 0x00 : 0xff, bytes_per_line); } else { /* Gray value */ memset (scanner->eop_last_line_data, scanner->eop_trailing_lines_color & 0xff, bytes_per_line); } } } } } else { DBG (DBG_verbose, "Trailing lines mode: line=%u, mode=%d, color=%u\n", i, scanner->eop_trailing_lines_mode, scanner->eop_trailing_lines_color); if ((scanner->source == SOURCE_ADF) || (scanner->source == SOURCE_ADF_DUPLEX)) { /* We are in in ADF mode after last-line and store next page data * to buffer. */ if (! scanner->adf_next_page_lines_data) { unsigned int n_rest_lines = lines - i; unsigned int buf_size = n_rest_lines * bytes_per_line; scanner->adf_next_page_lines_data = malloc(buf_size); if (! scanner->adf_next_page_lines_data) return SANE_STATUS_NO_MEM; scanner->adf_next_page_lines_data_size = buf_size; scanner->adf_next_page_lines_data_rpos = 0; scanner->adf_next_page_lines_data_wpos = 0; DBG (DBG_verbose, "ADF between pages: Save n=%u next page lines in buffer.\n", n_rest_lines); } DBG (DBG_verbose, "ADF between pages: Store line %u of %u.\n", i, lines); invert_negative_colors (buf, bytes_per_line, scanner); memcpy (scanner->adf_next_page_lines_data + scanner->adf_next_page_lines_data_wpos, buf, bytes_per_line); scanner->adf_next_page_lines_data_wpos += bytes_per_line; } if (scanner->eop_trailing_lines_mode != TRAILING_LINES_MODE_RAW) { /* Copy last line data or corresponding color over trailing lines * data. */ memcpy (buf, scanner->eop_last_line_data, bytes_per_line); } } } return SANE_STATUS_GOOD; } /******************************************************************************/ static unsigned char get_checked (unsigned char *ptr, unsigned int i, unsigned int length) { if (i < length) { return ptr[i]; } DBG (DBG_details, "get from array out of range: idx=%u, size=%u\n", i, length); return 0; } /******************************************************************************/ static SANE_Status convert_to_rgb (struct hp5590_scanner *scanner, SANE_Byte *data, SANE_Int size) { unsigned int pixels_per_line; unsigned int pixel_bits; unsigned int bytes_per_color; unsigned int bytes_per_line; unsigned int bytes_per_line_limit; unsigned int lines; unsigned int i, j; unsigned char *buf; unsigned char *bufptr; unsigned char *ptr; SANE_Status ret; hp5590_assert (scanner != NULL); hp5590_assert (data != NULL); if ( ! (scanner->depth == DEPTH_COLOR_24 || scanner->depth == DEPTH_COLOR_48)) return SANE_STATUS_GOOD; DBG (DBG_proc, "%s\n", __func__); #ifndef HAS_WORKING_COLOR_48 if (scanner->depth == DEPTH_COLOR_48) return SANE_STATUS_UNSUPPORTED; #endif ret = calc_image_params (scanner, &pixel_bits, &pixels_per_line, &bytes_per_line, NULL, NULL); if (ret != SANE_STATUS_GOOD) return ret; lines = size / bytes_per_line; bytes_per_color = (pixel_bits + 7) / 8; bytes_per_line_limit = bytes_per_line; if ((scanner->depth == DEPTH_COLOR_48) && (bytes_per_line_limit > 3)) { /* Last-line indicator pixel has only 3 bytes instead of 6. */ bytes_per_line_limit -= 3; } DBG (DBG_verbose, "Length : %u\n", size); DBG (DBG_verbose, "Converting row RGB to normal RGB\n"); DBG (DBG_verbose, "Bytes per line %u\n", bytes_per_line); DBG (DBG_verbose, "Bytes per line limited %u\n", bytes_per_line_limit); DBG (DBG_verbose, "Bytes per color %u\n", bytes_per_color); DBG (DBG_verbose, "Pixels per line %u\n", pixels_per_line); DBG (DBG_verbose, "Lines %u\n", lines); /* Use working buffer for color mapping. */ bufptr = malloc (size); if (! bufptr) return SANE_STATUS_NO_MEM; memset (bufptr, 0, size); buf = bufptr; ptr = data; for (j = 0; j < lines; ptr += bytes_per_line_limit, buf += bytes_per_line, j++) { for (i = 0; i < pixels_per_line; i++) { /* Color mapping from raw scanner data to RGB buffer. */ if (scanner->depth == DEPTH_COLOR_24) { /* R */ buf[i*3] = get_checked(ptr, i, bytes_per_line_limit); /* G */ buf[i*3+1] = get_checked(ptr, i+pixels_per_line, bytes_per_line_limit);; /* B */ buf[i*3+2] = get_checked(ptr, i+pixels_per_line*2, bytes_per_line_limit); } else if (scanner->depth == DEPTH_COLOR_48) { /* Note: The last-line indicator pixel uses only 24 bits, not 48. *Blue uses offset of 2 bytes. Green swaps lo and hi. */ /* R lo, hi*/ buf[i*6] = get_checked(ptr, 2*i+(pixels_per_line-1)*0+1, bytes_per_line_limit); buf[i*6+1] = get_checked(ptr, 2*i+(pixels_per_line-1)*0+0, bytes_per_line_limit); /* G lo, hi*/ buf[i*6+2] = get_checked(ptr, 2*i+(pixels_per_line-1)*2+0, bytes_per_line_limit); buf[i*6+3] = get_checked(ptr, 2*i+(pixels_per_line-1)*2+1, bytes_per_line_limit); /* B lo, hi*/ buf[i*6+4] = get_checked(ptr, 2*i+(pixels_per_line-1)*4+1+2, bytes_per_line_limit); buf[i*6+5] = get_checked(ptr, 2*i+(pixels_per_line-1)*4+0+2, bytes_per_line_limit); } } if (! scanner->eop_last_line_data) { if (pixels_per_line > 0) { /* Test for last-line indicator pixel on blue. If found, store * last line and optionally overwrite indicator pixel with * neighbor value. */ i = pixels_per_line - 1; int eop_found = 0; if (scanner->depth == DEPTH_COLOR_24) { /* DBG (DBG_details, "BUF24: %u %u %u\n", buf[i*3], buf[i*3+1], buf[i*3+2]); */ eop_found = (buf[i*3+2] != 0); if (scanner->overwrite_eop_pixel && (i > 0)) { buf[i*3] = buf[(i-1)*3]; buf[i*3+1] = buf[(i-1)*3+1]; buf[i*3+2] = buf[(i-1)*3+2]; } } else if (scanner->depth == DEPTH_COLOR_48) { /* DBG (DBG_details, "BUF48: %u %u %u\n", buf[i*6+1], buf[i*6+3], buf[i*6+5]); */ eop_found = (buf[i*6+5] != 0); if (scanner->overwrite_eop_pixel && (i > 0)) { buf[i*6] = buf[(i-1)*6]; buf[i*6+1] = buf[(i-1)*6+1]; buf[i*6+2] = buf[(i-1)*6+2]; buf[i*6+3] = buf[(i-1)*6+3]; buf[i*6+4] = buf[(i-1)*6+4]; buf[i*6+5] = buf[(i-1)*6+5]; } } invert_negative_colors (buf, bytes_per_line, scanner); if (eop_found && (! scanner->eop_last_line_data)) { DBG (DBG_verbose, "Found end-of-page at line %u in reading block.\n", j); scanner->eop_last_line_data = malloc(bytes_per_line); if (! scanner->eop_last_line_data) return SANE_STATUS_NO_MEM; memcpy (scanner->eop_last_line_data, buf, bytes_per_line); scanner->eop_last_line_data_rpos = 0; /* Fill trailing line buffer with requested color. */ if (scanner->eop_trailing_lines_mode == TRAILING_LINES_MODE_RASTER) { /* Black-white raster. */ if (scanner->depth == DEPTH_COLOR_24) { for (unsigned int k = 0; k < bytes_per_line; ++k) { scanner->eop_last_line_data[k] = (k % 6 < 3 ? 0xff : 0); } } else { /* Color48. */ for (unsigned int k = 0; k < bytes_per_line; ++k) { scanner->eop_last_line_data[k] = (k % 12 < 6 ? 0xff : 0); } } } else if (scanner->eop_trailing_lines_mode == TRAILING_LINES_MODE_WHITE) { memset (scanner->eop_last_line_data, 0xff, bytes_per_line); } else if (scanner->eop_trailing_lines_mode == TRAILING_LINES_MODE_BLACK) { memset (scanner->eop_last_line_data, 0x00, bytes_per_line); } else if (scanner->eop_trailing_lines_mode == TRAILING_LINES_MODE_COLOR) { /* RGB color value. */ int rgb[3]; rgb[0] = (scanner->eop_trailing_lines_color >> 16) & 0xff; rgb[1] = (scanner->eop_trailing_lines_color >> 8) & 0xff; rgb[2] = scanner->eop_trailing_lines_color & 0xff; if (scanner->depth == DEPTH_COLOR_24) { for (unsigned int k = 0; k < bytes_per_line; ++k) { scanner->eop_last_line_data[k] = rgb[k % 3]; } } else { /* Color48. */ for (unsigned int k = 0; k < bytes_per_line; ++k) { scanner->eop_last_line_data[k] = rgb[(k % 6) >> 1]; } } } } } } else { DBG (DBG_verbose, "Trailing lines mode: line=%u, mode=%d, color=%u\n", j, scanner->eop_trailing_lines_mode, scanner->eop_trailing_lines_color); if ((scanner->source == SOURCE_ADF) || (scanner->source == SOURCE_ADF_DUPLEX)) { /* We are in in ADF mode after last-line and store next page data * to buffer. */ if (! scanner->adf_next_page_lines_data) { unsigned int n_rest_lines = lines - j; unsigned int buf_size = n_rest_lines * bytes_per_line; scanner->adf_next_page_lines_data = malloc(buf_size); if (! scanner->adf_next_page_lines_data) return SANE_STATUS_NO_MEM; scanner->adf_next_page_lines_data_size = buf_size; scanner->adf_next_page_lines_data_rpos = 0; scanner->adf_next_page_lines_data_wpos = 0; DBG (DBG_verbose, "ADF between pages: Save n=%u next page lines in buffer.\n", n_rest_lines); } DBG (DBG_verbose, "ADF between pages: Store line %u of %u.\n", j, lines); invert_negative_colors (buf, bytes_per_line, scanner); memcpy (scanner->adf_next_page_lines_data + scanner->adf_next_page_lines_data_wpos, buf, bytes_per_line); scanner->adf_next_page_lines_data_wpos += bytes_per_line; } if (scanner->eop_trailing_lines_mode != TRAILING_LINES_MODE_RAW) { /* Copy last line data or corresponding color over trailing lines * data. */ memcpy (buf, scanner->eop_last_line_data, bytes_per_line); } } } memcpy (data, bufptr, size); free (bufptr); return SANE_STATUS_GOOD; } /******************************************************************************/ static void read_data_from_temporary_buffer(struct hp5590_scanner *scanner, SANE_Byte * data, unsigned int max_length, unsigned int bytes_per_line, SANE_Int *length) { *length = 0; if (scanner && scanner->one_line_read_buffer) { /* Copy scan data from temporary read buffer and return size copied data. */ /* Release buffer, when no data left. */ unsigned int rest_len; rest_len = bytes_per_line - scanner->one_line_read_buffer_rpos; rest_len = (rest_len < max_length) ? rest_len : max_length; if (rest_len > 0) { memcpy (data, scanner->one_line_read_buffer + scanner->one_line_read_buffer_rpos, rest_len); scanner->one_line_read_buffer_rpos += rest_len; scanner->transferred_image_size -= rest_len; *length = rest_len; } DBG (DBG_verbose, "Copy scan data from temporary buffer: length = %u, rest in buffer = %u.\n", *length, bytes_per_line - scanner->one_line_read_buffer_rpos); if (scanner->one_line_read_buffer_rpos >= bytes_per_line) { DBG (DBG_verbose, "Release temporary buffer.\n"); free (scanner->one_line_read_buffer); scanner->one_line_read_buffer = NULL; scanner->one_line_read_buffer_rpos = 0; } } } /******************************************************************************/ static SANE_Status sane_read_internal (struct hp5590_scanner * scanner, SANE_Byte * data, SANE_Int max_length, SANE_Int * length, unsigned int bytes_per_line) { SANE_Status ret; DBG (DBG_proc, "%s, length %u, left %llu\n", __func__, max_length, scanner->transferred_image_size); SANE_Int length_limited = 0; *length = max_length; if ((unsigned long long) *length > scanner->transferred_image_size) *length = (SANE_Int) scanner->transferred_image_size; /* Align reading size to bytes per line. */ *length -= *length % bytes_per_line; if (scanner->depth == DEPTH_COLOR_48) { /* Note: The last-line indicator pixel uses only 24 bits (3 bytes), not * 48 bits (6 bytes). */ if (bytes_per_line > 3) { length_limited = *length - *length % (bytes_per_line - 3); } } DBG (DBG_verbose, "Aligning requested size to bytes per line " "(requested: %d, aligned: %u, limit_for_48bit: %u)\n", max_length, *length, length_limited); if (max_length <= 0) { DBG (DBG_verbose, "Buffer too small for one scan line. Need at least %u bytes per line.\n", bytes_per_line); scanner->scanning = SANE_FALSE; return SANE_STATUS_UNSUPPORTED; } if (scanner->one_line_read_buffer) { /* Copy scan data from temporary read buffer. */ read_data_from_temporary_buffer (scanner, data, max_length, bytes_per_line, length); if (*length > 0) { DBG (DBG_verbose, "Return %d bytes, left %llu bytes.\n", *length, scanner->transferred_image_size); return SANE_STATUS_GOOD; } } /* Buffer to return scanned data. We need at least space for one line to * simplify color processing and last-line detection. If call buffer is too * small, use temporary read buffer for reading one line instead. */ SANE_Byte * scan_data; SANE_Int scan_data_length; scan_data = data; scan_data_length = *length; /* Note, read length is shorter in 48bit mode. */ SANE_Int length_for_read = length_limited ? length_limited : scan_data_length; if (length_for_read == 0) { /* Call buffer is too small for one line. Use temporary read buffer * instead. */ if (! scanner->one_line_read_buffer) { scanner->one_line_read_buffer = malloc (bytes_per_line); if (! scanner->one_line_read_buffer) return SANE_STATUS_NO_MEM; memset (scanner->one_line_read_buffer, 0, bytes_per_line); } DBG (DBG_verbose, "Call buffer too small for one scan line. Use temporary read buffer for one line with %u bytes.\n", bytes_per_line); /* Scan and process next line in temporary buffer. */ scan_data = scanner->one_line_read_buffer; scan_data_length = bytes_per_line; length_for_read = bytes_per_line; if (scanner->depth == DEPTH_COLOR_48) { /* The last-line indicator pixel uses only 24 bits (3 bytes), not 48 * bits (6 bytes). */ if (length_for_read > 3) { length_for_read -= 3; } } } int read_from_scanner = 1; if ((scanner->source == SOURCE_ADF) || (scanner->source == SOURCE_ADF_DUPLEX)) { if (scanner->eop_last_line_data) { /* Scanner is in ADF mode between last-line of previous page and * start of next page. * Fill remaining lines with last-line data. */ unsigned int wpos = 0; while (wpos < (unsigned int) scan_data_length) { unsigned int n1 = scan_data_length - wpos; unsigned int n2 = bytes_per_line - scanner->eop_last_line_data_rpos; n1 = (n1 < n2) ? n1 : n2; memcpy (scan_data + wpos, scanner->eop_last_line_data + scanner->eop_last_line_data_rpos, n1); wpos += n1; scanner->eop_last_line_data_rpos += n1; if (scanner->eop_last_line_data_rpos >= bytes_per_line) scanner->eop_last_line_data_rpos = 0; } read_from_scanner = (wpos == 0); DBG (DBG_verbose, "ADF use last-line data, wlength=%u, length=%u\n", wpos, scan_data_length); } else if (scanner->adf_next_page_lines_data) { /* Scanner is in ADF mode at start of next page and already some next * page data is available from earlier read operation. Return this * data. */ unsigned int wpos = 0; while ((wpos < (unsigned int) scan_data_length) && (scanner->adf_next_page_lines_data_rpos < scanner->adf_next_page_lines_data_size)) { unsigned int n1 = scan_data_length - wpos; unsigned int n2 = scanner->adf_next_page_lines_data_size - scanner->adf_next_page_lines_data_rpos; n1 = (n1 < n2) ? n1 : n2; memcpy (scan_data + wpos, scanner->adf_next_page_lines_data + scanner->adf_next_page_lines_data_rpos, n1); wpos += n1; scanner->adf_next_page_lines_data_rpos += n1; if (scanner->adf_next_page_lines_data_rpos >= scanner->adf_next_page_lines_data_size) { free (scanner->adf_next_page_lines_data); scanner->adf_next_page_lines_data = NULL; scanner->adf_next_page_lines_data_size = 0; scanner->adf_next_page_lines_data_rpos = 0; scanner->adf_next_page_lines_data_wpos = 0; } } scan_data_length = wpos; read_from_scanner = (wpos == 0); DBG (DBG_verbose, "ADF use next-page data, wlength=%u, length=%u\n", wpos, scan_data_length); } } if (read_from_scanner) { /* Read data from scanner. */ ret = hp5590_read (scanner->dn, scanner->proto_flags, scan_data, length_for_read, scanner->bulk_read_state); if (ret != SANE_STATUS_GOOD) { scanner->scanning = SANE_FALSE; return ret; } /* Look for last-line indicator pixels in convert functions. * If found: * - Overwrite indicator pixel with neighboring color (optional). * - Save last line data for later use. */ ret = convert_to_rgb (scanner, scan_data, scan_data_length); if (ret != SANE_STATUS_GOOD) { scanner->scanning = SANE_FALSE; return ret; } ret = convert_gray_and_lineart (scanner, scan_data, scan_data_length); if (ret != SANE_STATUS_GOOD) return ret; } if (data == scan_data) { /* Scanned to call buffer. */ scanner->transferred_image_size -= scan_data_length; *length = scan_data_length; } else { /* Scanned to temporary read buffer. */ if (scanner->one_line_read_buffer) { /* Copy scan data from temporary read buffer. */ read_data_from_temporary_buffer (scanner, data, max_length, scan_data_length, length); } else { *length = 0; } } DBG (DBG_verbose, "Return %d bytes, left %llu bytes\n", *length, scanner->transferred_image_size); return SANE_STATUS_GOOD; } /****************************************************************************** * Copy at maximum the last n lines from the src buffer to the begin of the dst * buffer. * Return number of lines copied. */ static SANE_Int copy_n_last_lines(SANE_Byte * src, SANE_Int src_len, SANE_Byte * dst, SANE_Int n, unsigned int bytes_per_line) { DBG (DBG_proc, "%s\n", __func__); SANE_Int n_copy = MY_MIN(src_len, n); SANE_Byte * src1 = src + (src_len - n_copy) * bytes_per_line; memcpy (dst, src1, n_copy * bytes_per_line); return n_copy; } /****************************************************************************** * Copy the color values from line - delta_lines to line. * buffer2 : Source and target buffer. * buffer1 : Only source buffer. Contains lines scanned before lines in buffer1. * color_idx : Index of color to be copied (0..2). * delta_lines : color shift. * color_48 : True = 2 byte , false = 1 byte per color. */ static void shift_color_lines(SANE_Byte * buffer2, SANE_Int n_lines2, SANE_Byte * buffer1, SANE_Int n_lines1, SANE_Int color_idx, SANE_Int delta_lines, SANE_Bool color_48, unsigned int bytes_per_line) { DBG (DBG_proc, "%s\n", __func__); for (SANE_Int i = n_lines2 - 1; i >= 0; --i) { SANE_Byte * dst = buffer2 + i * bytes_per_line; SANE_Int ii = i - delta_lines; SANE_Byte * src = NULL; SANE_Int source_color_idx = color_idx; if (ii >= 0) { /* Read from source and target buffer. */ src = buffer2 + ii * bytes_per_line; } else { ii += n_lines1; if (ii >= 0) { /* Read from source only buffer. */ src = buffer1 + ii * bytes_per_line; } else { /* Read other color from source position. */ src = dst; source_color_idx = 2; } } /* Copy selected color values. */ SANE_Int step = color_48 ? 2 : 1; SANE_Int stride = 3 * step; for (unsigned int pos = 0; pos < bytes_per_line; pos += stride) { SANE_Int p1 = pos + step * source_color_idx; SANE_Int p2 = pos + step * color_idx; dst[p2] = src[p1]; if (color_48) { dst[p2 + 1] = src[p1 + 1]; } } } } /****************************************************************************** * Append all lines from buffer2 to the end of buffer1 and keep max_lines last * lines. * buffer2 : Source line buffer. * buffer1 : Target line buffer. Length will be adjusted. * max_lines : Max number of lines in buffer1. */ static void append_and_move_lines(SANE_Byte * buffer2, SANE_Int n_lines2, SANE_Byte * buffer1, unsigned int * n_lines1_ptr, SANE_Int max_lines, unsigned int bytes_per_line) { DBG (DBG_proc, "%s\n", __func__); SANE_Int rest1 = max_lines - *n_lines1_ptr; SANE_Int copy2 = MY_MIN(n_lines2, max_lines); if (copy2 > rest1) { SANE_Int shift1 = *n_lines1_ptr + copy2 - max_lines; SANE_Int blen = MY_MIN(max_lines - shift1, (SANE_Int) *n_lines1_ptr); SANE_Byte * pdst = buffer1; SANE_Byte * psrc = pdst + shift1 * bytes_per_line; for (SANE_Int i = 0; i < blen; ++i) { memcpy (pdst, psrc, bytes_per_line); pdst += bytes_per_line; psrc += bytes_per_line; } *n_lines1_ptr -= shift1; } SANE_Int n_copied = copy_n_last_lines(buffer2, n_lines2, buffer1 + *n_lines1_ptr * bytes_per_line, copy2, bytes_per_line); *n_lines1_ptr += n_copied; } /******************************************************************************/ SANE_Status sane_read (SANE_Handle handle, SANE_Byte * data, SANE_Int max_length, SANE_Int * length) { struct hp5590_scanner *scanner = handle; SANE_Status ret; DBG (DBG_proc, "%s, length %u, left %llu\n", __func__, max_length, scanner->transferred_image_size); if (!length) { scanner->scanning = SANE_FALSE; return SANE_STATUS_INVAL; } if (scanner->transferred_image_size == 0) { *length = 0; DBG (DBG_verbose, "Setting scan count\n"); ret = hp5590_inc_scan_count (scanner->dn, scanner->proto_flags); if (ret != SANE_STATUS_GOOD) return ret; /* Don't free bulk read state, some bytes could be left * for the next images from ADF */ return SANE_STATUS_EOF; } if (!scanner->bulk_read_state) { ret = hp5590_low_init_bulk_read_state (&scanner->bulk_read_state); if (ret != SANE_STATUS_GOOD) { scanner->scanning = SANE_FALSE; return ret; } } unsigned int bytes_per_line; ret = calc_image_params (scanner, NULL, NULL, &bytes_per_line, NULL, NULL); if (ret != SANE_STATUS_GOOD) return ret; ret = sane_read_internal(scanner, data, max_length, length, bytes_per_line); if ((ret == SANE_STATUS_GOOD) && (scanner->dpi == 2400) && ((scanner->depth == DEPTH_COLOR_48) || (scanner->depth == DEPTH_COLOR_24))) { /* Correct color shift bug for 2400 dpi. * Note: 2400 dpi only works in color mode. Grey mode and lineart seem to * fail. * Align colors by shifting B channel by 48 lines and G channel by 24 * lines. */ const SANE_Int offset_max = 48; const SANE_Int offset_part = 24; SANE_Bool color_48 = (scanner->depth == DEPTH_COLOR_48); if (! scanner->color_shift_line_buffer1) { scanner->color_shift_buffered_lines1 = 0; scanner->color_shift_line_buffer1 = malloc (bytes_per_line * offset_max); if (! scanner->color_shift_line_buffer1) return SANE_STATUS_NO_MEM; memset (scanner->color_shift_line_buffer1, 0, bytes_per_line * offset_max); } if (! scanner->color_shift_line_buffer2) { scanner->color_shift_buffered_lines2 = 0; scanner->color_shift_line_buffer2 = malloc (bytes_per_line * offset_max); if (! scanner->color_shift_line_buffer2) return SANE_STATUS_NO_MEM; memset (scanner->color_shift_line_buffer2, 0, bytes_per_line * offset_max); } SANE_Int n_lines = *length / bytes_per_line; scanner->color_shift_buffered_lines2 = MY_MIN(n_lines, offset_max); copy_n_last_lines(data, n_lines, scanner->color_shift_line_buffer2, scanner->color_shift_buffered_lines2, bytes_per_line); shift_color_lines(data, n_lines, scanner->color_shift_line_buffer1, scanner->color_shift_buffered_lines1, 1, offset_part, color_48, bytes_per_line); shift_color_lines(data, n_lines, scanner->color_shift_line_buffer1, scanner->color_shift_buffered_lines1, 0, offset_max, color_48, bytes_per_line); append_and_move_lines(scanner->color_shift_line_buffer2, scanner->color_shift_buffered_lines2, scanner->color_shift_line_buffer1, &(scanner->color_shift_buffered_lines1), offset_max, bytes_per_line); } return ret; } /******************************************************************************/ void sane_cancel (SANE_Handle handle) { struct hp5590_scanner *scanner = handle; SANE_Status ret; DBG (DBG_proc, "%s\n", __func__); scanner->scanning = SANE_FALSE; if (scanner->dn < 0) return; hp5590_low_free_bulk_read_state (&scanner->bulk_read_state); ret = hp5590_stop_scan (scanner->dn, scanner->proto_flags); if (ret != SANE_STATUS_GOOD) return; } /******************************************************************************/ SANE_Status sane_set_io_mode (SANE_Handle __sane_unused__ handle, SANE_Bool __sane_unused__ non_blocking) { DBG (DBG_proc, "%s\n", __func__); return SANE_STATUS_UNSUPPORTED; } /******************************************************************************/ SANE_Status sane_get_select_fd (SANE_Handle __sane_unused__ handle, SANE_Int __sane_unused__ * fd) { DBG (DBG_proc, "%s\n", __func__); return SANE_STATUS_UNSUPPORTED; } /* vim: sw=2 ts=8 */ sane-backends-1.0.29/backend/epsonds-net.h0000666000000000000000000000113613615534521015201 00000000000000#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 sane-backends-1.0.29/backend/hp5590_cmds.h0000666000000000000000000001626013615534521014706 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2007 Ilia Sotnikov HP ScanJet 4570c support by Markham Thomas 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. This file is part of a SANE backend for HP ScanJet 4500C/4570C/5500C/5550C/5590/7650 Scanners */ #ifndef HP5590_H #define HP5590_H #include "hp5590_low.h" #define TMA_MAX_X_INCHES 1.69 #define TMA_MAX_Y_INCHES 6 #define ADF_MAX_Y_INCHES 14 enum hp_scanner_types { SCANNER_NONE = 0, SCANNER_HP4570, SCANNER_HP5550, SCANNER_HP5590, SCANNER_HP7650 }; enum scan_sources { SOURCE_NONE = 1, SOURCE_FLATBED, SOURCE_ADF, SOURCE_ADF_DUPLEX, SOURCE_TMA_NEGATIVES, SOURCE_TMA_SLIDES }; enum scan_modes { MODE_NORMAL = 1, MODE_PREVIEW }; enum color_depths { DEPTH_BW = 1, DEPTH_GRAY, DEPTH_COLOR_24, DEPTH_COLOR_48 }; enum button_status { BUTTON_NONE = 1, BUTTON_POWER, BUTTON_SCAN, BUTTON_COLLECT, BUTTON_FILE, BUTTON_EMAIL, BUTTON_COPY, BUTTON_UP, BUTTON_DOWN, BUTTON_MODE, BUTTON_CANCEL }; enum color_led_status { LED_COLOR = 1, LED_BLACKWHITE }; enum hp5590_lamp_state { LAMP_STATE_TURNOFF = 1, LAMP_STATE_TURNON, LAMP_STATE_SET_TURNOFF_TIME, LAMP_STATE_SET_TURNOFF_TIME_LONG }; struct hp5590_model { enum hp_scanner_types scanner_type; unsigned int usb_vendor_id; unsigned int usb_product_id; const char *vendor_id; const char *model; const char *kind; enum proto_flags proto_flags; }; #define FEATURE_NONE 0 #define FEATURE_ADF 1 << 0 #define FEATURE_TMA 1 << 1 #define FEATURE_LCD 1 << 2 struct scanner_info { const char *model; const char *kind; unsigned int features; const char *fw_version; unsigned int max_dpi_x; unsigned int max_dpi_y; unsigned int max_pixels_x; unsigned int max_pixels_y; float max_size_x; float max_size_y; unsigned int max_motor_param; unsigned int normal_motor_param; }; static SANE_Status hp5590_model_def (enum hp_scanner_types scanner_type, const struct hp5590_model ** model); static SANE_Status hp5590_vendor_product_id (enum hp_scanner_types scanner_type, SANE_Word * vendor_id, SANE_Word * product_id); static SANE_Status hp5590_init_scanner (SANE_Int dn, enum proto_flags proto_flags, struct scanner_info **info, enum hp_scanner_types scanner_type); static SANE_Status hp5590_power_status (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_read_max_scan_count (SANE_Int dn, enum proto_flags proto_flags, unsigned int *max_count); static SANE_Status hp5590_select_source_and_wakeup (SANE_Int dn, enum proto_flags proto_flags, enum scan_sources source, SANE_Bool extend_lamp_timeout); static SANE_Status hp5590_stop_scan (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_read_scan_count (SANE_Int dn, enum proto_flags proto_flags, unsigned int *count); static SANE_Status hp5590_set_scan_params (SANE_Int dn, enum proto_flags proto_flags, struct scanner_info *scanner_info, unsigned int top_x, unsigned int top_y, unsigned int width, unsigned int height, unsigned int dpi, enum color_depths color_depth, enum scan_modes scan_mode, enum scan_sources scan_source); static SANE_Status hp5590_send_forward_calibration_maps (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_send_reverse_calibration_map (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_inc_scan_count (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_start_scan (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_read (SANE_Int dn, enum proto_flags proto_flags, unsigned char *bytes, unsigned int size, void *state); static SANE_Status hp5590_read_buttons (SANE_Int dn, enum proto_flags proto_flags, enum button_status *status); static SANE_Status hp5590_read_part_number (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_calc_pixel_bits (unsigned int dpi, enum color_depths color_depth, unsigned int *pixel_bits); static SANE_Status hp5590_is_data_available (SANE_Int dn, enum proto_flags proto_flags); static SANE_Status hp5590_reset_scan_head (SANE_Int dn, enum proto_flags proto_flags); #endif /* HP5590_H */ /* vim: sw=2 ts=8 */ sane-backends-1.0.29/backend/ibm-scsi.c0000666000000000000000000002744013615534521014451 00000000000000/* sane - Scanner Access Now Easy. 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, the authors of SANE give permission for additional uses of the libraries contained in this release of SANE. The exception is that, if you link a SANE library with other files to produce an executable, this does not by itself cause the resulting executable to be covered by the GNU General Public License. Your use of that executable is in no way restricted on account of linking the SANE library code into it. This exception does not, however, invalidate any other reasons why the executable file might be covered by the GNU General Public License. If you submit changes to SANE to the maintainers to be included in a subsequent release, you agree by submitting the changes that those changes may be distributed with this exception intact. If you write modifications of your own for SANE, it is your choice whether to permit this exception to apply to your modifications. If you do not wish that, delete this exception notice. */ /* */ #include /* SCSI commands that the Ibm scanners understand: */ #define IBM_SCSI_TEST_UNIT_READY 0x00 #define IBM_SCSI_SET_WINDOW 0x24 #define IBM_SCSI_GET_WINDOW 0x25 #define IBM_SCSI_READ_SCANNED_DATA 0x28 #define IBM_SCSI_INQUIRY 0x12 #define IBM_SCSI_MODE_SELECT 0x15 #define IBM_SCSI_START_SCAN 0x1b #define IBM_SCSI_MODE_SENSE 0x1a #define IBM_SCSI_GET_BUFFER_STATUS 0x34 #define IBM_SCSI_OBJECT_POSITION 0x31 /* How long do we wait for scanner to have data for us */ #define MAX_WAITING_TIME 15 /* for object_position command */ #define OBJECT_POSITION_UNLOAD 0 #define OBJECT_POSITION_LOAD 1 struct scsi_window_cmd { SANE_Byte opcode; SANE_Byte byte2; SANE_Byte reserved[4]; SANE_Byte len[3]; SANE_Byte control; }; struct scsi_mode_select_cmd { SANE_Byte opcode; SANE_Byte byte2; #define SMS_SP 0x01 #define SMS_PF 0x10 SANE_Byte page_code; /* for mode_sense, reserved for mode_select */ SANE_Byte unused[1]; SANE_Byte len; SANE_Byte control; }; struct scsi_mode_header { SANE_Byte data_length; /* Sense data length */ SANE_Byte medium_type; SANE_Byte dev_spec; SANE_Byte blk_desc_len; }; /* next struct introduced by mf */ struct scsi_object_position_cmd { SANE_Byte opcode; SANE_Byte position_func; SANE_Byte count[3]; SANE_Byte res[3]; SANE_Byte control; SANE_Byte res2; }; struct scsi_get_buffer_status_cmd { SANE_Byte opcode; SANE_Byte byte2; SANE_Byte res[5]; SANE_Byte len[2]; SANE_Byte control; }; struct scsi_status_desc { SANE_Byte window_id; SANE_Byte byte2; SANE_Byte available[3]; SANE_Byte filled[3]; }; struct scsi_status_data { SANE_Byte len[3]; SANE_Byte byte4; struct scsi_status_desc desc; }; struct scsi_start_scan_cmd { SANE_Byte opcode; SANE_Byte byte2; SANE_Byte unused[2]; SANE_Byte len; SANE_Byte control; }; struct scsi_read_scanner_cmd { SANE_Byte opcode; SANE_Byte byte2; SANE_Byte data_type; SANE_Byte byte3; SANE_Byte data_type_qualifier[2]; SANE_Byte len[3]; SANE_Byte control; }; static SANE_Status test_unit_ready (int fd) { static SANE_Byte cmd[6]; SANE_Status status; DBG (11, ">> test_unit_ready\n"); cmd[0] = IBM_SCSI_TEST_UNIT_READY; memset (cmd, 0, sizeof (cmd)); status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), 0, 0); DBG (11, "<< test_unit_ready\n"); return (status); } static SANE_Status inquiry (int fd, void *buf, size_t * buf_size) { static SANE_Byte cmd[6]; SANE_Status status; DBG (11, ">> inquiry\n"); memset (cmd, 0, sizeof (cmd)); cmd[0] = IBM_SCSI_INQUIRY; cmd[4] = *buf_size; status = sanei_scsi_cmd (fd, cmd, sizeof (cmd), buf, buf_size); DBG (11, "<< inquiry\n"); return (status); } static SANE_Status mode_select (int fd, struct mode_pages *mp) { static struct { struct scsi_mode_select_cmd cmd; struct scsi_mode_header smh; struct mode_pages mp; } select_cmd; SANE_Status status; DBG (11, ">> mode_select\n"); memset (&select_cmd, 0, sizeof (select_cmd)); select_cmd.cmd.opcode = IBM_SCSI_MODE_SELECT; select_cmd.cmd.byte2 |= SMS_PF; select_cmd.cmd.len = sizeof(select_cmd.smh) + sizeof(select_cmd.mp); /* next line by mf */ /* select_cmd.cmd.page_code= 20; */ memcpy (&select_cmd.mp, mp, sizeof(*mp)); status = sanei_scsi_cmd (fd, &select_cmd, sizeof (select_cmd), 0, 0); DBG (11, "<< mode_select\n"); return (status); } #if 0 static SANE_Status mode_sense (int fd, struct mode_pages *mp, SANE_Byte page_code) { static struct scsi_mode_select_cmd cmd; /* no type, we can reuse it for sensing */ static struct { struct scsi_mode_header smh; struct mode_pages mp; } select_data; static size_t select_size = sizeof(select_data); SANE_Status status; DBG (11, ">> mode_sense\n"); memset (&cmd, 0, sizeof (cmd)); cmd.opcode = IBM_SCSI_MODE_SENSE; cmd.page_code = page_code; cmd.len = sizeof(select_data); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), &select_data, &select_size); memcpy (mp, &select_data.mp, sizeof(*mp)); DBG (11, "<< mode_sense\n"); return (status); } #endif static SANE_Status trigger_scan (int fd) { static struct scsi_start_scan_cmd cmd; static char window_id_list[1] = { '\0' }; /* scan start data out */ static size_t wl_size = 1; SANE_Status status; DBG (11, ">> trigger scan\n"); memset (&cmd, 0, sizeof (cmd)); cmd.opcode = IBM_SCSI_START_SCAN; cmd.len = wl_size; /* next line by mf */ /* cmd.unused[0] = 1; */ if (wl_size) status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), &window_id_list, &wl_size); else status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), 0, 0); DBG (11, "<< trigger scan\n"); return (status); } static SANE_Status set_window (int fd, struct ibm_window_data *iwd) { static struct { struct scsi_window_cmd cmd; struct ibm_window_data iwd; } win; SANE_Status status; DBG (11, ">> set_window\n"); memset (&win, 0, sizeof (win)); win.cmd.opcode = IBM_SCSI_SET_WINDOW; _lto3b(sizeof(*iwd), win.cmd.len); memcpy (&win.iwd, iwd, sizeof(*iwd)); status = sanei_scsi_cmd (fd, &win, sizeof (win), 0, 0); DBG (11, "<< set_window\n"); return (status); } static SANE_Status get_window (int fd, struct ibm_window_data *iwd) { static struct scsi_window_cmd cmd; static size_t iwd_size; SANE_Status status; iwd_size = sizeof(*iwd); DBG (11, ">> get_window datalen = %lu\n", (unsigned long) iwd_size); memset (&cmd, 0, sizeof (cmd)); cmd.opcode = IBM_SCSI_GET_WINDOW; #if 1 /* it was if 0 */ cmd.byte2 |= (SANE_Byte)0x01; /* set Single bit to get one window desc. */ #endif _lto3b(iwd_size, cmd.len); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), iwd, &iwd_size); DBG (11, "<< get_window, datalen = %lu\n", (unsigned long) iwd_size); return (status); } static SANE_Status read_data (int fd, void *buf, size_t * buf_size) { static struct scsi_read_scanner_cmd cmd; SANE_Status status; DBG (11, ">> read_data %lu\n", (unsigned long) *buf_size); memset (&cmd, 0, sizeof (cmd)); cmd.opcode = IBM_SCSI_READ_SCANNED_DATA; _lto3b(*buf_size, cmd.len); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), buf, buf_size); DBG (11, "<< read_data %lu\n", (unsigned long) *buf_size); return (status); } static SANE_Status object_position (int fd, int load) { static struct scsi_object_position_cmd cmd; SANE_Status status; DBG (11, ">> object_position\n"); #if 0 /* At least the Ricoh 420 doesn't like that command */ DBG (11, "object_position: ignored\n"); return SANE_STATUS_GOOD; #endif memset (&cmd, 0, sizeof (cmd)); cmd.opcode = IBM_SCSI_OBJECT_POSITION; if (load) cmd.position_func = OBJECT_POSITION_LOAD; else cmd.position_func = OBJECT_POSITION_UNLOAD; _lto3b(1, cmd.count); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), 0, 0); DBG (11, "<< object_position\n"); return (status); } static SANE_Status get_data_status (int fd, struct scsi_status_desc *dbs) { static struct scsi_get_buffer_status_cmd cmd; static struct scsi_status_data ssd; size_t ssd_size = sizeof(ssd); SANE_Status status; DBG (11, ">> get_data_status %lu\n", (unsigned long) ssd_size); memset (&cmd, 0, sizeof (cmd)); cmd.opcode = IBM_SCSI_GET_BUFFER_STATUS; _lto2b(ssd_size, cmd.len); status = sanei_scsi_cmd (fd, &cmd, sizeof (cmd), &ssd, &ssd_size); memcpy (dbs, &ssd.desc, sizeof(*dbs)); if (status == SANE_STATUS_GOOD && ((unsigned int) _3btol(ssd.len) <= sizeof(*dbs) || _3btol(ssd.desc.filled) == 0)) { DBG (11, "get_data_status: busy\n"); status = SANE_STATUS_DEVICE_BUSY; } DBG (11, "<< get_data_status %lu\n", (unsigned long) ssd_size); return (status); } #if 0 static SANE_Status ibm_wait_ready_tur (int fd) { struct timeval now, start; SANE_Status status; gettimeofday (&start, 0); while (1) { DBG(3, "scsi_wait_ready: sending TEST_UNIT_READY\n"); status = sanei_scsi_cmd (fd, test_unit_ready, sizeof (test_unit_ready), 0, 0); switch (status) { default: /* Ignore errors while waiting for scanner to become ready. Some SCSI drivers return EIO while the scanner is returning to the home position. */ DBG(1, "scsi_wait_ready: test unit ready failed (%s)\n", sane_strstatus (status)); /* fall through */ case SANE_STATUS_DEVICE_BUSY: gettimeofday (&now, 0); if (now.tv_sec - start.tv_sec >= MAX_WAITING_TIME) { DBG(1, "ibm_wait_ready: timed out after %lu seconds\n", (u_long) (now.tv_sec - start.tv_sec)); return SANE_STATUS_INVAL; } usleep (100000); /* retry after 100ms */ break; case SANE_STATUS_GOOD: return status; } } return SANE_STATUS_INVAL; } #endif static SANE_Status ibm_wait_ready (Ibm_Scanner * s) { struct scsi_status_desc dbs; time_t now, start; SANE_Status status; start = time(NULL); while (1) { status = get_data_status (s->fd, &dbs); switch (status) { default: /* Ignore errors while waiting for scanner to become ready. Some SCSI drivers return EIO while the scanner is returning to the home position. */ DBG(1, "scsi_wait_ready: get datat status failed (%s)\n", sane_strstatus (status)); /* fall through */ case SANE_STATUS_DEVICE_BUSY: now = time(NULL); if (now - start >= MAX_WAITING_TIME) { DBG(1, "ibm_wait_ready: timed out after %lu seconds\n", (u_long) (now - start)); return SANE_STATUS_INVAL; } break; case SANE_STATUS_GOOD: DBG(11, "ibm_wait_ready: %d bytes ready\n", _3btol(dbs.filled)); return status; break; } usleep (1000000); /* retry after 100ms */ } return SANE_STATUS_INVAL; } sane-backends-1.0.29/backend/niash_xfer.h0000666000000000000000000000515413615534521015074 00000000000000/* Copyright (C) 2001 Bertrik Sikken (bertrik@zonnet.nl) 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. $Id$ */ /* Provides a simple interface to read and write data from the scanner, without any knowledge whether it's a parallel or USB scanner */ #ifndef _NIASH_XFER_H_ #define _NIASH_XFER_H_ #include /* for FILE * */ /* register codes for the USB - IEEE1284 bridge */ #define USB_SETUP 0x82 #define EPP_ADDR 0x83 #define EPP_DATA_READ 0x84 #define EPP_DATA_WRITE 0x85 #define SPP_STATUS 0x86 #define SPP_CONTROL 0x87 #define SPP_DATA 0x88 typedef enum { eUnknownModel = 0, eHp3300c, eHp3400c, eHp4300c, eAgfaTouch } EScannerModel; typedef struct { char *pszVendor; char *pszName; int iVendor; int iProduct; EScannerModel eModel; } TScannerModel; typedef int (TFnReportDevice) (TScannerModel * pModel, const char *pszDeviceName); /* Creates our own DBG definitions, externs are define in main.c*/ #ifndef WITH_NIASH #define DBG fprintf extern FILE *DBG_MSG; extern FILE *DBG_ERR; extern FILE *BG_ASSERT; #endif /* NO WITH_NIASH */ /* we do not make data prototypes */ #ifndef WITH_NIASH /* list of supported models, the actual list is in niash_xfer.c */ extern TScannerModel ScannerModels[]; #endif /* NO WITH_NIASH */ STATIC void NiashXferInit (TFnReportDevice * pfnReport); STATIC int NiashXferOpen (const char *pszName, EScannerModel * peModel); STATIC void NiashXferClose (int iXferHandle); STATIC void NiashWriteReg (int iXferHandle, unsigned char bReg, unsigned char bData); STATIC void NiashReadReg (int iXferHandle, unsigned char bReg, unsigned char *pbData); STATIC void NiashWriteBulk (int iXferHandle, unsigned char *pabBuf, int iSize); STATIC void NiashReadBulk (int iXferHandle, unsigned char *pabBuf, int iSize); STATIC void NiashWakeup (int iXferHandle); STATIC SANE_Bool MatchUsbDevice (int iVendor, int iProduct, TScannerModel ** ppeModel); #endif /* _NIASH_XFER_H_ */ sane-backends-1.0.29/backend/p5_device.h0000666000000000000000000001762513615534521014617 00000000000000/* sane - Scanner Access Now Easy. Copyright (C) 2009-2012 stef.dev@free.fr 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; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** @file p5_device.h * @brief Declaration of low level structures used by the p5 backend. * * The structures and function declared here are used to do the low level * communication with the physical device. */ #ifndef P5_DEVICE_H #define P5_DEVICE_H #include #include #include #include "../include/_stdint.h" #ifdef HAVE_LINUX_PPDEV_H #include #include #include #include #include #include #endif /** @name debugging levels */ /* @{ */ #define DBG_error0 0 /* errors/warnings printed even with devuglevel 0 */ #define DBG_error 1 /* fatal errors */ #define DBG_warn 2 /* warnings and non-fatal errors */ #define DBG_info 4 /* informational messages */ #define DBG_proc 8 /* starting/finishing functions */ #define DBG_trace 16 /* tracing messages */ #define DBG_io 32 /* io functions */ #define DBG_io2 64 /* io functions that are called very often */ #define DBG_data 128 /* log image data */ /* @} */ /** * maximal number of resolutions */ #define MAX_RESOLUTIONS 8 /**> sensor's number of pixels 8.5' @ 300 dpi */ #define MAX_SENSOR_PIXELS 2550 /**> number of lines to skip when doing calibration */ #define CALIBRATION_SKIP_LINES 80 /**> last value considered as black for calibration */ #define BLACK_LEVEL 40 /**> white target value for calibration */ #define WHITE_TARGET 220.0 /** per dpi calibration rgb data * Calibration data structure */ typedef struct P5_Calibration_Data { unsigned int dpi; uint8_t black_data[MAX_SENSOR_PIXELS * 3]; uint8_t white_data[MAX_SENSOR_PIXELS * 3]; } P5_Calibration_Data; /** * This structure describes a particular model which is handled by the backend. * Contained data is immutable and is used to initalize the P5_Device * structure. */ typedef struct P5_Model { /** @name device identifier * These values are set up once the physical device has been detected. They * are used to build the return value of sane_get_devices(). */ /* @{ */ SANE_String_Const name; SANE_String_Const vendor; SANE_String_Const product; SANE_String_Const type; /* @} */ /** @name resolution * list of avalailable physical resolution. * The resolutions must sorted from lower to higher value. The list is terminated * by a value of 0. */ /* @{ */ int xdpi_values[MAX_RESOLUTIONS]; /** possible x resolutions */ int ydpi_values[MAX_RESOLUTIONS]; /** possible y resolutions */ /* @} */ /** @name scan area description * Minimal and maximal values. It's easier to have dedicated members instead * of searching these values in the dpi lists. They are initialized from dpi * lists. */ /* @{ */ int max_xdpi; /** physical maximum x dpi */ int max_ydpi; /** physical maximum y dpi */ int min_xdpi; /** physical minimum x dpi */ int min_ydpi; /** physical minimum y dpi */ /* @} */ /** @name line distance shift * Distance between CCD arrays for each color. Expressed in line * number at maximum motor resolution. */ int lds; /** @name scan area description * The geometry values are expressed from the head parking position, * or the start. For a given model, the scan area selected by a frontend * will have to fit within these values. */ /* @{ */ SANE_Fixed x_offset; /** Start of scan area in mm */ SANE_Fixed y_offset; /** Start of scan area in mm */ SANE_Fixed x_size; /** Size of scan area in mm */ SANE_Fixed y_size; /** Size of scan area in mm */ /* @} */ } P5_Model; /** * Enumeration of configuration options for a device. It must starts at 0. */ enum P5_Configure_Option { CFG_MODEL_NAME = 0, /**